<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Semantic Web Programming &#187; Tutorial</title>
	<atom:link href="http://semwebprogramming.org/?feed=rss2&#038;tag=tutorial" rel="self" type="application/rss+xml" />
	<link>http://semwebprogramming.org</link>
	<description>A practical guide to the Semantic Web for programmers</description>
	<lastBuildDate>Thu, 02 Sep 2010 01:59:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>OWL 2 in Action &#8211; Property Chains</title>
		<link>http://semwebprogramming.org/?p=175</link>
		<comments>http://semwebprogramming.org/?p=175#comments</comments>
		<pubDate>Tue, 16 Jun 2009 02:01:49 +0000</pubDate>
		<dc:creator>Ryan Blace</dc:creator>
				<category><![CDATA[Book]]></category>
		<category><![CDATA[OWL 2 In Action]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Owl 2]]></category>
		<category><![CDATA[Pellet]]></category>
		<category><![CDATA[Property Chains]]></category>
		<category><![CDATA[reasoning]]></category>
		<category><![CDATA[Semantic Web]]></category>

		<guid isPermaLink="false">http://semwebprogramming.org/?p=175</guid>
		<description><![CDATA[This is the second article in our series that expands the code example from Chapter 5 of Semantic Web Programming to cover the semantics of OWL 2. This article covers property chains. The code can be downloaded from here (zip, 7z, tar.gz) and includes an Eclipse project with all required dependencies. This article focuses on [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-179" title="pc_tutorial_ontology" src="http://semwebprogramming.org/wp-content/uploads/2009/06/pc_tutorial_ontology.bmp" alt="pc_tutorial_ontology" /></p>
<p style="text-align: left;">This is the second article in our series that expands the code example from Chapter 5 of <a href="http://www.amazon.com/dp/047041801X?tag=semawebprog-20&amp;camp=14573&amp;creative=327641&amp;linkCode=as1&amp;creativeASIN=047041801X&amp;adid=0BCWVHCAAQBZANCXVBMG&amp;" target="_blank">Semantic Web Programming</a> to cover the semantics of OWL 2. This article covers property chains. The code can be downloaded from here (<a href="http://semwebprogramming.org/code/PCReasoningExample.zip">zip</a>, <a href="http://semwebprogramming.org/code/PCReasoningExample.7z">7z</a>,<a href="http://semwebprogramming.org/code/PCReasoningExample.tar.gz"> tar.gz</a>) and includes an Eclipse project with all required dependencies.</p>
<p style="text-align: left;">This article focuses on the semantics of property chains and how they are interpreted and applied in a reasoner that supports most of OWL 2 semantics (<a href="http://clarkparsia.com/weblog/2009/04/30/pellet-20-rc6/" target="_blank">Pellet 2.0 RC6</a> &#8211; see the Pellet documentation for a full list of the semantics supported in each release candidate).</p>
<p style="text-align: left;">As I said in the <a href="http://semwebprogramming.org/?p=143">first article</a>, for a more in-depth exploration of OWL and Semantic Web, feel free to reference the book as needed or <a href="http://www.amazon.com/dp/047041801X?tag=semawebprog-20&amp;camp=14573&amp;creative=327641&amp;linkCode=as1&amp;creativeASIN=047041801X&amp;adid=0BCWVHCAAQBZANCXVBMG&amp;" target="_blank">buy a copy</a> so you can learn about the cool stuff in this article and more. Click the link below to read the rest of the article&#8230;</p>
<p style="text-align: left;"><span id="more-175"></span></p>
<p style="text-align: left;">Recall from Chapter 4 in the book that property chains are a way to define a property in terms of a chain of object properties that connect resources. One of the most common examples of a property that is defined in terms of a property chain is the <em>hasUncle</em> relationship, which is our first example and is defined in OWL below:</p>
<pre style="text-align: left;">ex:Ryan rdf:type ex:Person;
        ex:hasParent ex:Jean.
ex:Jean rdf:type ex:Person;
        ex:hasBrother ex:Doug.
ex:Doug rdf:type ex:Person.

ex:hasUncle rdf:type owl:ObjectProperty.
ex:hasParent rdf:type owl:ObjectProperty.
ex:hasBrother rdf:type owl:ObjectProperty.

[] rdfs:subPropertyOf ex:hasUncle;
   owl:propertyChain (
     ex:hasParent
     ex:hasBrother
     ).</pre>
<p style="text-align: left;">The excerpt above is in the file <em>pc_1.ttl</em>. As you can see, we&#8217;ve defined that there exists a sub-property of <em>ex:hasUncle</em> that is the property chain consisting of <em>ex:hasParent</em> and <em>ex:hasBrother</em>. This means that the any time the property chain exists, the super-property (<em>ex:hasUncle</em>) exists. More precisely stated: if A <em>ex:hasParent</em> B and B <em>ex:hasBrother</em> C then A <em>ex:hasUncle</em> C. Note that I didn&#8217;t say if and only if. The implication only goes in the one direction. The existence of a statement A <em>ex:hasUncle</em> B alone does not imply anything in this context. In OWL 2 you can&#8217;t make a property chain an equivalent-property or a super-property of another property.  Despite these limitations, we will soon see that property chains enable the definition of properties that cannot be defined in any other way.</p>
<p style="text-align: left;">Executing the code in the accompanying project with the input file <em>pc_1.ttl</em> (input parameters: test/pc_1.ttl TTL output1.txt owl) produces the following output:</p>
<pre>Individual: Doug
  type : http://example.org#Person
  type : http://www.w3.org/2002/07/owl#Thing
  sameAs : http://example.org#Doug

Individual: Ryan
  type : http://example.org#Person
  type : http://www.w3.org/2002/07/owl#Thing
  sameAs : http://example.org#Ryan<span style="color: #ff0000;">
  hasUncle : http://example.org#Doug</span>
  hasParent : http://example.org#Jean

Individual: Jean
  type : http://example.org#Person
  type : http://www.w3.org/2002/07/owl#Thing
  sameAs : http://example.org#Jean
  hasBrother : http://example.org#Doug</pre>
<p style="text-align: left;">As you can see, Pellet correctly infers that <em>Ryan hasUncle Doug</em>. All we said in the input file was (<em>ex:Ryan</em> <em>ex:hasParent</em> <em>ex:Jean</em>) and (<em>ex:Jean ex:hasBrother ex:Doug</em>). This chain of relationships combined with the property chain definition implied the existence of the statement (<em>ex:Ryan ex:hasUncle ex:Doug</em>). As an exercise for yourself, try defining the <em>ex:hasAunt</em> relationship and give <em>ex:Jean</em> a sister.</p>
<p style="text-align: left;">This was a relatively simple example, so let&#8217;s explore some more interesting applications of property chains. For the first example, consider a trust management system in which a user is a trusted user if he or she is trusted by a trusted user. One way to express this concept is to say that the property <em>trusts</em> is transitive.  That way, if A <em>trusts </em>B and B <em>trusts</em> C, A will trust C. The following RDF captures these concepts (from <em>pc_2.ttl</em>):</p>
<pre style="text-align: left;">ex:Person rdf:type owl:Class.
ex:trusts rdf:type owl:ObjectProperty;
          rdf:type owl:TransitiveProperty.

ex:Ryan rdf:type ex:Person;
        ex:trusts ex:John.
ex:John rdf:type ex:Person;
        ex:trusts ex:Matt;
        ex:trusts ex:Ryan.
ex:Matt rdf:type ex:Person;
        ex:trusts ex:Andrew.
ex:Andrew rdf:type ex:Person;
          ex:trusts ex:Mike.
ex:Mike rdf:type ex:Person.</pre>
<p style="text-align: left;">Focus on <em>ex:Ryan</em>. As the excerpt specifies, Ryan trusts John, who trusts Matt. Matt trusts Andrew, and Andrew trusts Mike. Apparently Mike doesn&#8217;t trust anyone. Running this example produces the following output (only the statements about Ryan are included):</p>
<pre style="text-align: left;">Individual: Ryan
  type : http://example.org#Person
  type : http://www.w3.org/2002/07/owl#Thing
  sameAs : http://example.org#Ryan
<span style="color: #ff0000;">  trusts : http://example.org#Andrew
<span style="color: #000000;">  trusts : http://example.org#John</span>
  trusts : http://example.org#Ryan
  trusts : http://example.org#Mike
  trusts : http://example.org#Matt</span></pre>
<p style="text-align: left;">As you can see, Pellet entails that Ryan trusts everyone. While this is logically correct given our ontology, it isn&#8217;t really practical to chain a relationship such as trusts in this manner. This illustrates the potential limitation to this approach using transitivity &#8211; there is no way to constrain how far the transitivity is applied. In other words, Ryan trusts John, and may be comfortable trusting someone John trusts. But that trust will likely diminish as the relationship becomes less and less direct. Does Ryan really trust Mike? After all, it took a chain of Ryan trusts John trusts Matt trusts Andrew trusts Mike in order to entail the fact that Ryan trusts Mike. That&#8217;s quite a lot of indirection. Let&#8217;s see if we can use property chains to introduce some finer grain control over this situation.</p>
<p style="text-align: left;">As shown below, in <em>pc_3.ttl</em> we define a new property <em>ex:indirectlyTrusts</em> as the super-property of the property chain of two <em>ex:trust</em>s relationships.</p>
<pre style="text-align: left;">ex:Person rdf:type owl:Class.
ex:trusts rdf:type owl:ObjectProperty.
ex:indirectlyTrusts rdf:type owl:ObjectProperty.

ex:Ryan rdf:type ex:Person;
        ex:trusts ex:John.
ex:John rdf:type ex:Person;
        ex:trusts ex:Matt;
        ex:trusts ex:Ryan.
ex:Matt rdf:type ex:Person;
        ex:trusts ex:Andrew.
ex:Andrew rdf:type ex:Person;
          ex:trusts ex:Mike.
ex:Mike rdf:type ex:Person.

[] rdfs:subPropertyOf ex:indirectlyTrusts;
   owl:propertyChain (
     ex:trusts
     ex:trusts
     ).</pre>
<p style="text-align: left;">
<p style="text-align: left;">Running <em>pc_3.ttl</em> produces the following output for Ryan:</p>
<pre style="text-align: left;">Individual: Ryan
  type : http://example.org#Person
  type : http://www.w3.org/2002/07/owl#Thing
  sameAs : http://example.org#Ryan
<span style="color: #ff0000;">  indirectlyTrusts : http://example.org#Ryan
  indirectlyTrusts : http://example.org#Matt</span>
  trusts : http://example.org#John</pre>
<p style="text-align: left;">As you can see, Ryan trusts John and indirectly trusts Matt (and Ryan), and that is the extent to which Ryan has any trust relationship with anyone. Even if we added the indirectly-trusts relationship to our ontology, transitivity wouldn&#8217;t be enough to achieve this same result that we just achieved with property chains. This isn&#8217;t to say that transitive properties aren&#8217;t useful, it&#8217;s just to highlight a scenario in which we may need something else to model our relationships.</p>
<p style="text-align: left;">For the next and final example, we&#8217;ll apply property chains to a slightly more complex example, the ontology for which is shown below (from <em>pc_4.ttl</em>):</p>
<pre style="text-align: left;">ex:User rdf:type owl:Class.
ex:System rdf:type owl:Class.
ex:trusts rdf:type owl:ObjectProperty.
ex:authorizes rdf:type owl:ObjectProperty.
ex:grantsReadTo rdf:type owl:ObjectProperty.
ex:grantsWriteTo rdf:type owl:ObjectProperty;
                 rdfs:subPropertyOf ex:grantsReadTo.

[] rdfs:subPropertyOf ex:grantsWriteTo;
   owl:propertyChain (
     ex:trusts
     ex:authorizes
     ).

[] rdfs:subPropertyOf ex:grantsReadTo;
   owl:propertyChain (
     ex:trusts
     ex:authorizes
     ex:trusts
     ex:authorizes
     ).</pre>
<p style="text-align: left;">What we&#8217;ve done here is described a very simple authorization protocol. In this protocol there are Systems and Users. Systems authorize users and Users trust Systems. A User decides who to grant read and write access to based on the set of Users who are authorized by the Systems the original user trust. Now, property chains don&#8217;t allow you to constrain the resources that are endpoints for the properties in the chain. As such, we can&#8217;t actually specify that the (trusts, authorizes) chain is specific to &#8220;trusts System&#8221; and &#8220;authorizes User.&#8221; All we can do is specify that any three <em>resources</em> associated by the chain of properties (trusts, authorizes). So, with that said &#8211; a resource grants write access to those resources who are authorized by the resources they trust. Read access is granted based on the same property chain, only with an additional step. So, a resource grants read access to those resources who are authorized by resources that are trusted by resources that are authorized by resources that are trusted by them (confused yet?). Anyways, take a look at the rest of the contents of <em>pc_4.ttl</em>:</p>
<pre style="text-align: left;">ex:Ryan rdf:type ex:User;
        ex:trusts ex:System1.
ex:John rdf:type ex:User;
        ex:trusts ex:System1;
        ex:trusts ex:System2.
ex:Matt rdf:type ex:User.
ex:Andrew rdf:type ex:User;
        ex:trusts ex:System3.
ex:Mike rdf:type ex:User;
        ex:trusts ex:System3.

ex:System1 rdf:type ex:System;
           ex:authorizes ex:Ryan;
           ex:authorizes ex:John.

ex:System2 rdf:type ex:System;
           ex:authorizes ex:Matt;
           ex:authorizes ex:Mike;
           ex:authorizes ex:John.

ex:System3 rdf:type ex:System;
           ex:authorizes ex:Andrew;
           ex:authorizes ex:Mike.</pre>
<p style="text-align: left;">Take a look at the output generated describing Ryan when we run this example in the Pellet reasoning application:</p>
<pre style="text-align: left;">Individual: Ryan
  type : http://example.org#User
  type : http://www.w3.org/2002/07/owl#Thing
  sameAs : http://example.org#Ryan
<span style="color: #ff0000;">  grantsWriteTo : http://example.org#John
  grantsWriteTo : http://example.org#Ryan</span>
  trusts : http://example.org#System1
<span style="color: #ff0000;">  grantsReadTo : http://example.org#John
  grantsReadTo : http://example.org#Ryan
  grantsReadTo : http://example.org#Mike
  grantsReadTo : http://example.org#Matt</span></pre>
<p style="text-align: left;">As we would expect, Pellet has entailed that Ryan grants write access to John (and Ryan) because Ryan trusts System1 which authorizes John and Ryan. Read access is granted to John, Mike, and Matt. This is because John trusts the system that authorizes Mike and Matt and because <em>ex:grantsReadTo</em> is a sub-property of <em>ex:grantsWriteTo</em>.</p>
<p style="text-align: left;">Hopefully this article has given you some more insight into the semantics of property chains. Have fun tweaking these examples and building those knowledge models! Excited for more? Make comments, leave feedback, request a tutorial on a specific topic! And above all else &#8211; stay tuned for the next article&#8230;</p>
<p style="text-align: left;">Code downloads:  <a href="http://semwebprogramming.org/code/PCReasoningExample.zip">zip</a>, <a href="http://semwebprogramming.org/code/PCReasoningExample.7z">7z</a>,<a href="http://semwebprogramming.org/code/PCReasoningExample.tar.gz"> tar.gz</a><a href="http://semwebprogramming.org/code/QCRReasoningExample.tar.gz"></a></p>
]]></content:encoded>
			<wfw:commentRss>http://semwebprogramming.org/?feed=rss2&amp;p=175</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OWL 2 in Action &#8211; Qualified Cardinality Restrictions</title>
		<link>http://semwebprogramming.org/?p=143</link>
		<comments>http://semwebprogramming.org/?p=143#comments</comments>
		<pubDate>Mon, 01 Jun 2009 21:44:36 +0000</pubDate>
		<dc:creator>Ryan Blace</dc:creator>
				<category><![CDATA[Book]]></category>
		<category><![CDATA[OWL 2 In Action]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Jena]]></category>
		<category><![CDATA[Owl 2]]></category>
		<category><![CDATA[Pellet]]></category>
		<category><![CDATA[qualified cardinality restrictions]]></category>
		<category><![CDATA[reasoning]]></category>
		<category><![CDATA[Semantic Web]]></category>
		<category><![CDATA[semantics]]></category>

		<guid isPermaLink="false">http://semwebprogramming.org/?p=143</guid>
		<description><![CDATA[This article is the first in a short series of articles that expands the code example from Chapter 5 of Semantic Web Programming to include some of the features of OWL 2. The code can be downloaded from here (zip, 7z, tar.gz), including an Eclipse project and all dependencies. This article focuses on how the [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;"><img class="size-full wp-image-159 alignleft" title="Cmap of a qualified cardinality restriction" src="http://semwebprogramming.org/wp-content/uploads/2009/06/qcr-tutorial-ontology.bmp" alt="Cmap of a qualified cardinality restriction" /></p>
<p style="text-align: left;">This article is the first in a short series of articles that expands the code example from Chapter 5 of <a href="http://www.amazon.com/dp/047041801X?tag=semawebprog-20&amp;camp=14573&amp;creative=327641&amp;linkCode=as1&amp;creativeASIN=047041801X&amp;adid=0BCWVHCAAQBZANCXVBMG&amp;" target="_blank">Semantic Web Programming</a> to include some of the features of OWL 2. The code can be downloaded from here (<a href="http://semwebprogramming.org/code/QCRReasoningExample.zip">zip</a>, <a href="http://semwebprogramming.org/code/QCRReasoningExample.7z">7z</a>,<a href="http://semwebprogramming.org/code/QCRReasoningExample.tar.gz"> tar.gz</a>), including an Eclipse project and all dependencies. This article focuses on how the semantics of qualified cardinality restrictions are interpreted and applied in a reasoner that supports most of OWL 2 semantics (<a href="http://clarkparsia.com/weblog/2009/04/30/pellet-20-rc6/" target="_blank">Pellet 2.0 RC6</a> &#8211; see the Pellet documentation for a full list of the semantics supported in each release candidate).</p>
<p style="text-align: left;">For a more in-depth exploration of OWL and Semantic Web, feel free to reference the book as needed or <a href="http://www.amazon.com/dp/047041801X?tag=semawebprog-20&amp;camp=14573&amp;creative=327641&amp;linkCode=as1&amp;creativeASIN=047041801X&amp;adid=0BCWVHCAAQBZANCXVBMG&amp;" target="_blank">buy a copy</a> so you can learn about the cool stuff in this article and more <img src='http://semwebprogramming.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p style="text-align: left;">Recall from Chapter 4 in the book that cardinality restrictions are a way to specify the number of statements that describe an individual with a unique value that have a particular property as the predicate of each statement&#8230; <span id="more-143"></span>e.g.  a person has exactly one date of birth or a parent has at least one child. Qualified cardinality restrictions (QCRs) allow you to further describe that set of statements by specifying the number of those statements which should have an individual of a particular class or value of a particular data range as the object of the statement&#8230; e.g. a molecule of water has three atoms, exactly two of which are hydrogen atoms and one of which is an oxygen atom &#8211; or a person has exactly two parents, one of which is male and the other which is female. Qualified cardinality restrictions can be on both object and datatype properties; however, RC6 of Pellet 2.0 only currently supports them for object properties.</p>
<p style="text-align: left;">Qualified cardinality restrictions are convenient because they avoid the need to add extra properties to an ontology in order to make cardinality restrictions specific to the range of the statements to which they apply. Without QCRs, specifying that a person has a mother and a father would likely require gender-specific properties like hasMother and hasFather. These predicates may be useful, but they are not necessary &#8211; at least when we can use QCRs instead.</p>
<p style="text-align: left;">For this example, we are reusing the code from Chapter 5&#8242;s code project with only a few minor modifications (we changed the way we create the Pellet reasoner-enabled model). The major difference is that we are using the latest version of Pellet (2.0RC6), which supports most of the semantics of the OWL 2 vocabulary. So, let&#8217;s get started!</p>
<p style="text-align: left;">Our goal is to express (in our ontology) the fact that a mammal has two parents, one of which is male and one of which is female. For our purposes, the property hasParent is an object property and male and female are classes. We will extend the class mammal with the axioms for the QCR definition. The excerpt of turtle that expresses these concepts is below (taken from <em>qcr_1.ttl</em>):</p>
<pre style="text-align: left;">ex:Male rdf:type owl:Class.
ex:Female rdf:type owl:Class.

ex:hasParent rdf:type owl:ObjectProperty.
ex:isParentOf rdf:type owl:ObjectProperty;
             owl:inverseOf ex:hasParent.

ex:Mammal rdf:type owl:Class;
          rdfs:subClassOf
          [
            rdf:type owl:Restriction;
            owl:onProperty ex:hasParent;
            owl:cardinality 2
          ];
          rdfs:subClassOf
          [
            rdf:type owl:Restriction;
            owl:qualifiedCardinality 1;
            owl:onProperty ex:hasParent;
            owl:onClass ex:Female
          ];
          rdfs:subClassOf
          [
            rdf:type owl:Restriction;
            owl:qualifiedCardinality 1;
            owl:onProperty ex:hasParent;
            owl:onClass ex:Male
          ].</pre>
<p style="text-align: left;">The class definition for <em>ex:Mammal</em> now contains three restrictions, the first specifies that all mammals have exactlly two statements with <em>ex:hasParent</em> as the predicate and a unique individual as the object, the second specifies that one of the statements with <em>ex:hasParent</em> as the predicate must have an object that is an instance of the class <em>ex:Female</em> and the third is the same only for <em>ex:Male</em>. Now that we have the capacity to describe parents, let&#8217;s define a couple of instances of canine and associate them with our example pooch from before: Daisy.</p>
<pre style="text-align: left;">ex:Kujo rdf:type ex:Mammal;
         rdf:type ex:Male;
         ex:name "King Kujo".

ex:Lady rdf:type ex:Canine;
        ex:name "Lady";
        ex:breed ex:GoldenRetriever.

ex:Daisy rdf:type ex:Canine;
         ex:name "Daisy";
         ex:registeredName "Morning Daisy Bathed in Sunshine";
         ex:breed ex:GoldenRetriever;
         ex:hasParent ex:Kujo;
         ex:hasParent ex:Lady.</pre>
<p style="text-align: left;">We&#8217;ve described <em>ex:Kujo</em> and <em>ex:Lady</em> and stated that they are the parents of <em>ex:Daisy</em>. Run the program in the project (execute the main method with the parameters <em>qcr_1.ttl TURTLE qcr_out.txt owl</em>) and take a look at the results. You will notice that the inverse property as well as the subproperty and subclass semantics have been applied; however, no entailments have been made as a result of the QCR. You may expect that Pellet should infer that Lady is female because Kujo is a male, and the two of them are the parents of Daisy. This after all, is sort of the goal we are going for in defining this restriction in our ontology. But, we haven&#8217;t described the situation completely enough for the reasoner to assert this new fact. For all we (and the reasoner) know, Lady is the same individual as Kujo (recall the no unique names assumption from Chapter 4?), meaning that they could both be male. Also, we haven&#8217;t said anything about the relationship between the classes <em>ex:Male</em> and <em>ex:Female</em>. For all we know an individual could be both male and female. Because of these facts, the reasoner cannot make any correct conclusions about Lady despite our QCR on <em>ex:Mammal</em>.</p>
<p style="text-align: left;">To correct this situation and enable Pellet to make the expected conclusions, we must assert two facts: 1) <em>ex:Kujo</em> and <em>ex:Lady</em> are different individuals and 2) <em>ex:Male</em> and <em>ex:Female</em> are disjoint classes. These atoms are below (and are added in the file <em>qcr_2.ttl</em>):</p>
<pre style="text-align: left;">ex:Male rdf:type owl:Class.
ex:Female rdf:type owl:Class;
          owl:disjointWith ex:Male.

ex:Lady rdf:type ex:Canine;
        ex:name "Lady";
        ex:breed ex:GoldenRetriever;
        owl:differentFrom ex:Kujo.</pre>
<p style="text-align: left;">Both <em>owl:disjointWith</em> and <em>owl:differentFrom</em> are symmetric properties, so they only need to be asserted in one direction. Run the program with the input file <em>qcr_2.ttl</em> and take a look at the results. Voila! Lady is now an instance of the class <em>ex:Female</em>:</p>
<pre style="text-align: left;">Individual: Lady
<strong>  type : http://example.org#Female</strong>
  type : http://www.w3.org/2002/07/owl#Thing
  type : http://example.org#Canine
  type : http://example.org#Mammal
  sameAs : http://example.org#Lady
  differentFrom : http://example.org#Kujo
  breed : http://example.org#GoldenRetriever
  name : Lady
  isParentOf : http://example.org#Daisy</pre>
<p style="text-align: left;">This worked because we asserted that Lady and Kujo are different individuals, meaning that Lady has to be the other parent of Daisy. Also, we asserted that male and female are disjoint classes, meaning that Kujo cannot be female, and that the only individual who can be the female parent of Daisy is Lady. This latter point is tricky, if male and female were not disjoint, Kujo could be both the female parent as well as the male parent of Daisy, allowing Lady to be neither male nor female while still leaving the restriction satisfied (2 parents, one female parent, one male parent).</p>
<p style="text-align: left;">Now, let&#8217;s play around a bit. As we saw from the previous example, the semantics of our QCR plus the fact that male and female are disjoint classes and Lady and Kujo are different individuals is enough for the reasoner to entail that Lady is female (even though we didn&#8217;t explicity state that). So, what happens when there are more than two parents of Daisy? Let&#8217;s take a look at how the QCR semantics can be applied in this situation. The file <em>qcr_3.ttl</em> has the following modifications to it:</p>
<pre style="text-align: left;">ex:KingKujo rdf:type ex:Canine;
         rdf:type ex:Male;
         ex:breed ex:GoldenRetriever;
         ex:isParentOf ex:Daisy;
         ex:name "King Kujo of Calvert County".</pre>
<p style="text-align: left;">Notice that all we&#8217;ve done is described a new individual <em>ex:KingKujo</em> and stated that he is a parent of <em>ex:Daisy</em>. Run the program with the input <em>qcr_3.ttl</em> and take a look at the output file. This is really interesting stuff! The reasoner combined the inverse-of semantics of <em>ex:isParentOf</em> with the fact that there are two male parents of <em>ex:Daisy</em> to infer that <em>ex:KingKujo</em> has to be the same individual as <em>ex:Kujo</em>. Notice that because the <em>owl:sameAs</em> statement now exists between <em>ex:Kujo</em> and <em>ex:KingKujo</em>, both individuals are described by the union of the statements about each:</p>
<pre style="text-align: left;">Individual: KingKujo
  type : http://www.w3.org/2002/07/owl#Thing
  type : http://example.org#Canine
  type : http://example.org#Mammal
  type : http://example.org#Male
  sameAs : http://example.org#KingKujo
<strong>  sameAs : http://example.org#Kujo</strong>
  differentFrom : http://example.org#Lady
  breed : http://example.org#GoldenRetriever
  name : King Kujo
  name : King Kujo of Calvert County
  isParentOf : http://example.org#Daisy

Individual: Kujo
  type : http://www.w3.org/2002/07/owl#Thing
  type : http://example.org#Canine
  type : http://example.org#Mammal
  type : http://example.org#Male
<strong>  sameAs : http://example.org#KingKujo</strong>
  sameAs : http://example.org#Kujo
  differentFrom : http://example.org#Lady
  breed : http://example.org#GoldenRetriever
  name : King Kujo
  name : King Kujo of Calvert County
  isParentOf : http://example.org#Daisy</pre>
<p style="text-align: left;">In this ontology, if <em>ex:Kujo</em> and <em>ex:KingKujo</em> are in fact not the same individual, the KB will have reached an inconsistent state. Two individuals who are different will also be the same. Just to drive this point home, lets see what happens if we explicity state that <em>ex:Kujo</em> and <em>ex:KingKujo</em> are different individuals by adding an <em>owl:differentFrom</em> statement between them (run the program with input file <em>qcr_4.ttl</em>). As you will see, Pellet generates a warning:</p>
<pre style="text-align: left;"><span style="color: #ff0000;">Jun 1, 2009 5:15:35 PM
   org.mindswap.pellet.KnowledgeBase consistency
WARNING: Inconsistent ontology.
Reason: Individual http://example.org#Daisy
        has more than 1 values for property
        http://example.org#hasParent violating
        the cardinality restriction
</span></pre>
<p style="text-align: left;">This is to be expected because we knowingly asserted something that is inconsistent with the axioms of our ontology. This warning is an indication that something in our knowledgebase violates the conditions of our ontology. Mike Smith (book tech editor/Clark and Parsia Pellet developer/all round awesome guy) tells me we can&#8217;t expect that specific warning will be generated in future release candidates as there are many situations in which an inconsistent ontology may be desirable and it is irritating to have ever instance logged by default. But, the good news is there are alternate ways to check the consistency of an ontology using Jena and Pellet. So, we will still be able to detect these inconsistencies when they occur (reading the documentation for Pellet and Jena to figure out the best way to do this is your homework assignment)</p>
<p style="text-align: left;">Hopefully this exploration has given you greater insight into the semantics of of qualified cardinality restrictions. We could go on for hours with other examples, but this should provide you with some more building blocks that you can apply to your own experimentation.  Have fun, and stay consistent <img src='http://semwebprogramming.org/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p style="text-align: left;">Code downloads:  <a href="http://semwebprogramming.org/code/QCRReasoningExample.zip">zip</a>, <a href="http://semwebprogramming.org/code/QCRReasoningExample.7z">7z</a>,<a href="http://semwebprogramming.org/code/QCRReasoningExample.tar.gz"> tar.gz</a></p>
<p style="text-align: left;"><em>Author&#8217;s note: Thanks to John Hebeler and Mike Dean for their inputs and Mike Smith for the feedback regarding Pellet.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://semwebprogramming.org/?feed=rss2&amp;p=143</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Semantic Technology Conference</title>
		<link>http://semwebprogramming.org/?p=109</link>
		<comments>http://semwebprogramming.org/?p=109#comments</comments>
		<pubDate>Wed, 08 Apr 2009 02:59:27 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Events]]></category>
		<category><![CDATA[SemTech 2009]]></category>
		<category><![CDATA[Conference]]></category>
		<category><![CDATA[Event]]></category>
		<category><![CDATA[SemTech]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://semwebprogramming.org/?p=109</guid>
		<description><![CDATA[The authors will be presenting a tutorial and overview of future issues on the Semantic Web at the Semantic Technology Conference in San Jose, California June 14-18. This tutorial outlines a step-by-step, code-based approach to enable you to quickly master the fundamentals in building a semantic Web application. We quickly establish the key concepts and [...]]]></description>
			<content:encoded><![CDATA[<p>The authors will be presenting a tutorial and overview of future issues on the Semantic Web at the <a href="http://www.semantic-conference.com/" target="_blank">Semantic Technology Conference</a> in San Jose, California June 14-18.</p>
<p>This tutorial outlines a step-by-step, code-based approach to enable you to quickly master the fundamentals in building a semantic Web application. We quickly establish the key concepts and their relationship to application development. Then we programmaticly build the knowledge model, integrate diverse information sources, expose to various reasoners, query the unified value, and then export to various formats and methods using an iterative, collaborative format to get you involved and learning. This takes you through all necessary tools and techniques to quickly get started on your own solution.</p>
<p>For more information see the <a href="http://www.semantic-conference.com/session/1763/">official SemTech site</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://semwebprogramming.org/?feed=rss2&amp;p=109</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JavaOne Semantic Web Tutorial</title>
		<link>http://semwebprogramming.org/?p=105</link>
		<comments>http://semwebprogramming.org/?p=105#comments</comments>
		<pubDate>Wed, 08 Apr 2009 02:50:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Events]]></category>
		<category><![CDATA[JavaOne]]></category>
		<category><![CDATA[Conference]]></category>
		<category><![CDATA[Event]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://semwebprogramming.org/?p=105</guid>
		<description><![CDATA[The authors will be presenting a tutorial on the Semantic Web at the 2009 JavaOne Conference June 2-5. The tutorial will be based on the content of the book and outlines a step-by-step, Java-based approach to enable participants to quickly master the fundamentals of building a Semantic Web application using Java. More information can be [...]]]></description>
			<content:encoded><![CDATA[<p>The authors will be presenting a tutorial on the Semantic Web at the <a href="http://java.sun.com/javaone" target="_blank">2009 JavaOne Conference</a> June 2-5. The tutorial will be based on the content of the book and outlines a step-by-step, Java-based approach to enable participants to quickly master the fundamentals of building a Semantic Web application using Java.</p>
<p>More information can be found <a href="http://www28.cplan.com/cc230/session_details.jsp?isid=304449&amp;ilocation_id=230-1&amp;ilanguage=english">here</a>. We hope to see some of you there!</p>
]]></content:encoded>
			<wfw:commentRss>http://semwebprogramming.org/?feed=rss2&amp;p=105</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
