Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>First, note that using <code>rdf:List</code>s in your OWL code means that you're going to be in OWL Full, whereas many of the reasoners are designed to work with OWL DL. You might be OK with this, and if you are, then great. If you need to remain in OWL DL, then you'll have to use your own vocabulary for lists, e.g., a class <code>warp:List</code> and properties <code>warp:first</code> and <code>warp:rest</code>, and use those instead of their RDF counterparts.</p> <p>At any rate, once you've decided on your <code>List</code> class and your <code>first</code> and <code>rest</code> properties, you can define a list type <code>ListOfElements</code> that can only contain members of some class <code>Element</code> with the following restriction:</p> <blockquote> <p>ElementList &sqsubseteq; List <strong>and</strong> (first <strong>only</strong> Element) <strong>and</strong> (rest <strong>only</strong> ElementList)</p> </blockquote> <p>This means that an <code>ElementList</code> is: (i) a <code>List</code>; (ii) has an value for the <code>first</code> property that is an <code>Element</code>; and (iii) has an <code>ElementList</code> as its <code>rest</code>, which means that the rest of the things in the <code>List</code> must also be <code>Element</code>s. Whatever the <code>nil</code> object is should already be declared as a <code>List</code>, but you may also want to include:</p> <blockquote> <p>nil <strong>a</strong> ElementList</p> </blockquote> <p>but this isn't necessarily as important. For your case, you'd want to define a class <code>TitleList</code> in a similar fashion, and then declare the range of your property as <code>TitleList</code>.</p> <p>Here's an example ontology that includes just defines these type of <code>List</code> class and an <code>ElementList</code> class (in human readable Turtle):</p> <pre><code>@prefix : &lt;http://stackoverflow.com/a/19480798/1281433/code#&gt; . @prefix rdfs: &lt;http://www.w3.org/2000/01/rdf-schema#&gt; . @prefix owl: &lt;http://www.w3.org/2002/07/owl#&gt; . @prefix xsd: &lt;http://www.w3.org/2001/XMLSchema#&gt; . @prefix rdf: &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#&gt; . :rest a owl:ObjectProperty ; rdfs:domain :List ; rdfs:range :List . :List a owl:Class . :nil a owl:NamedIndividual , :ElementList , :List . :ElementList a owl:Class ; rdfs:subClassOf [ a owl:Class ; owl:intersectionOf ( :List [ a owl:Restriction ; owl:allValuesFrom :Element ; owl:onProperty :first ] [ a owl:Restriction ; owl:allValuesFrom :ElementList ; owl:onProperty :rest ] ) ] . :Element a owl:Class . :first a owl:ObjectProperty ; rdfs:domain :List . &lt;http://stackoverflow.com/a/19480798/1281433/code&gt; a owl:Ontology . [ a owl:Axiom ; rdfs:comment "It's probably a good idea to specify that nil is an ElementList. This could also be inferred, though, if there is a nil-terminated List that is known to be an ElementList." ; owl:annotatedProperty rdf:type ; owl:annotatedSource :nil ; owl:annotatedTarget :ElementList ] . </code></pre> <p>For full generality, I've defined new a new <code>List</code> class, <code>first</code> and <code>rest</code> properties, and an individual <code>nil</code>, but if OWL Full is OK with you, then you can just use <code>rdf:List</code>, etc. For completeness, here's the same ontology in RDF/XML:</p> <pre class="lang-xml prettyprint-override"><code>&lt;rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:owl="http://www.w3.org/2002/07/owl#" xmlns="http://stackoverflow.com/a/19480798/1281433/code#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"&gt; &lt;owl:Ontology rdf:about="http://stackoverflow.com/a/19480798/1281433/code"/&gt; &lt;owl:Class rdf:about="http://stackoverflow.com/a/19480798/1281433/code#List"/&gt; &lt;owl:Class rdf:about="http://stackoverflow.com/a/19480798/1281433/code#ElementList"&gt; &lt;rdfs:subClassOf&gt; &lt;owl:Class&gt; &lt;owl:intersectionOf rdf:parseType="Collection"&gt; &lt;owl:Class rdf:about="http://stackoverflow.com/a/19480798/1281433/code#List"/&gt; &lt;owl:Restriction&gt; &lt;owl:onProperty&gt; &lt;owl:ObjectProperty rdf:about="http://stackoverflow.com/a/19480798/1281433/code#first"/&gt; &lt;/owl:onProperty&gt; &lt;owl:allValuesFrom&gt; &lt;owl:Class rdf:about="http://stackoverflow.com/a/19480798/1281433/code#Element"/&gt; &lt;/owl:allValuesFrom&gt; &lt;/owl:Restriction&gt; &lt;owl:Restriction&gt; &lt;owl:onProperty&gt; &lt;owl:ObjectProperty rdf:about="http://stackoverflow.com/a/19480798/1281433/code#rest"/&gt; &lt;/owl:onProperty&gt; &lt;owl:allValuesFrom rdf:resource="http://stackoverflow.com/a/19480798/1281433/code#ElementList"/&gt; &lt;/owl:Restriction&gt; &lt;/owl:intersectionOf&gt; &lt;/owl:Class&gt; &lt;/rdfs:subClassOf&gt; &lt;/owl:Class&gt; &lt;owl:ObjectProperty rdf:about="http://stackoverflow.com/a/19480798/1281433/code#rest"&gt; &lt;rdfs:range rdf:resource="http://stackoverflow.com/a/19480798/1281433/code#List"/&gt; &lt;rdfs:domain rdf:resource="http://stackoverflow.com/a/19480798/1281433/code#List"/&gt; &lt;/owl:ObjectProperty&gt; &lt;owl:ObjectProperty rdf:about="http://stackoverflow.com/a/19480798/1281433/code#first"&gt; &lt;rdfs:domain rdf:resource="http://stackoverflow.com/a/19480798/1281433/code#List"/&gt; &lt;/owl:ObjectProperty&gt; &lt;owl:Axiom&gt; &lt;rdfs:comment&gt;It's probably a good idea to specify that nil is an ElementList. This could also be inferred, though, if there is a nil-terminated List that is known to be an ElementList.&lt;/rdfs:comment&gt; &lt;owl:annotatedTarget rdf:resource="http://stackoverflow.com/a/19480798/1281433/code#ElementList"/&gt; &lt;owl:annotatedSource&gt; &lt;owl:NamedIndividual rdf:about="http://stackoverflow.com/a/19480798/1281433/code#nil"&gt; &lt;rdf:type rdf:resource="http://stackoverflow.com/a/19480798/1281433/code#ElementList"/&gt; &lt;rdf:type rdf:resource="http://stackoverflow.com/a/19480798/1281433/code#List"/&gt; &lt;/owl:NamedIndividual&gt; &lt;/owl:annotatedSource&gt; &lt;owl:annotatedProperty rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#type"/&gt; &lt;/owl:Axiom&gt; &lt;/rdf:RDF&gt; </code></pre>
 

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