Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Here's a minimal ontology with classes as you've described, i.e., the class LivingPlace has two direct subclasses, City and RuralArea. There is one individual, ruralArea1, which is of type RuralArea, and the ontology contains the SWRL rule</p> <blockquote> <p>RuralArea(?x) &rarr; hasHospital(?x,false)</p> </blockquote> <pre class="lang-xml prettyprint-override"><code>&lt;rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://example.org/places#" xmlns:owl="http://www.w3.org/2002/07/owl#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#" xmlns:swrl="http://www.w3.org/2003/11/swrl#" xmlns:swrlb="http://www.w3.org/2003/11/swrlb#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"&gt; &lt;owl:Ontology rdf:about="http://example.org/places"/&gt; &lt;owl:Class rdf:about="http://example.org/places#LivingPlace"/&gt; &lt;owl:Class rdf:about="http://example.org/places#City"&gt; &lt;rdfs:subClassOf rdf:resource="http://example.org/places#LivingPlace"/&gt; &lt;/owl:Class&gt; &lt;owl:Class rdf:about="http://example.org/places#RuralArea"&gt; &lt;rdfs:subClassOf rdf:resource="http://example.org/places#LivingPlace"/&gt; &lt;/owl:Class&gt; &lt;owl:DatatypeProperty rdf:about="http://example.org/places#hasHospital"&gt; &lt;rdfs:domain rdf:resource="http://example.org/places#LivingPlace"/&gt; &lt;rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#boolean"/&gt; &lt;/owl:DatatypeProperty&gt; &lt;swrl:Imp&gt; &lt;swrl:body&gt; &lt;swrl:AtomList&gt; &lt;rdf:rest rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"/&gt; &lt;rdf:first&gt; &lt;swrl:ClassAtom&gt; &lt;swrl:classPredicate rdf:resource="http://example.org/places#RuralArea"/&gt; &lt;swrl:argument1&gt; &lt;swrl:Variable rdf:about="urn:swrl#x"/&gt; &lt;/swrl:argument1&gt; &lt;/swrl:ClassAtom&gt; &lt;/rdf:first&gt; &lt;/swrl:AtomList&gt; &lt;/swrl:body&gt; &lt;swrl:head&gt; &lt;swrl:AtomList&gt; &lt;rdf:rest rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"/&gt; &lt;rdf:first&gt; &lt;swrl:DatavaluedPropertyAtom&gt; &lt;swrl:argument2 rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean" &gt;false&lt;/swrl:argument2&gt; &lt;swrl:propertyPredicate rdf:resource="http://example.org/places#hasHospital"/&gt; &lt;swrl:argument1 rdf:resource="urn:swrl#x"/&gt; &lt;/swrl:DatavaluedPropertyAtom&gt; &lt;/rdf:first&gt; &lt;/swrl:AtomList&gt; &lt;/swrl:head&gt; &lt;/swrl:Imp&gt; &lt;owl:NamedIndividual rdf:about="http://example.org/places#ruralArea1"&gt; &lt;rdf:type rdf:resource="http://example.org/places#RuralArea"/&gt; &lt;/owl:NamedIndividual&gt; &lt;/rdf:RDF&gt; </code></pre> <p>When I load this ontology in Protégé 4.x and use Pellet as the reasoner, and also ensure that inferences about datatype properties are displyed in the UI (as discussed in <a href="https://mailman.stanford.edu/pipermail/protege-owl/2013-August/019672.html" rel="nofollow noreferrer">this message on the Protégé OWL mailing list</a>), the inference that </p> <pre><code>ruralArea1 hasHospital false </code></pre> <p>is displayed, as shown in the following screenshot.</p> <p><img src="https://i.stack.imgur.com/68moL.png" alt="inference displayed in the Protege UI"></p> <p>Another way to see that Pellet can draw this inference is to ask using SPARQL. For instance, using the SPARQL query saved in <code>query.sparql</code></p> <pre><code>prefix : &lt;http://example.org/places#&gt; select ?s ?o where { ?s :hasHospital ?o } </code></pre> <p>and the <code>pellet</code> command line tool, we obtain these results:</p> <pre><code>$ pellet query -q query.sparql ./places.owl Query Results (1 answers): s | o ============================================================ ruralArea1 | false^^http://www.w3.org/2001/XMLSchema#boolean </code></pre> <p>It is worth pointing out that you don't actually need SWRL to do this particular inference. You can simply say that </p> <blockquote> <p>RuralArea subClassOf (hasHospital value false)</p> </blockquote> <p>and get the same results. In Protégé, that would look like the following screenshot. This has the advantage that it will give you the same results if you're using an OWL reasoner that doesn't have SWRL support.</p> <p><img src="https://i.stack.imgur.com/W061T.png" alt="OWL restriction accomplishing the same effect as the SWRL rule"></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload