Designing An Ontology In OWL - Using A Domain Or Range

Designing an Ontology (using the Web Ontology Language – OWL) can be a difficult thing. Creating a model is difficult on its own, and it is further complicated by the subtleties of the language. Consider an Ontology with the following classes and properties

  • Class Cat

  • Class Dog

  • Class Person

  • Class Male is subclass of Person

  • Class Female is subclass of Person

  • Object Property Has_Brother maps a Person (domain) to a Male (range)

  • Object Property Has_Sister maps a Person (domain) to a Female (range)

  • Person Bob

  • Person Sue

  • Object Property Has_Pet maps a Person (domain)

The usual (incorrect) reason that I am given for setting the range for has brother to Male is to prevent a non-male from being a brother. This is wrong. OWL uses an Open World Assumption that if a statement cannot be proven true using current knowledge, we cannot draw the conclusion that the statement is false. In other words, there is an assumption that we do not have all of the information and there may, or may not, exist information that makes something true. With an open world assumption in mind, is it legal to state that Sue Has_Brother Bob? The answer is yes.

It is common to use a reasoner with an Ontology. The result is that the reasoner uses logic to find things out about the world. If I state that Sue Has_Brother Bob, a reasoner will then decide that Bob must be a Male and Sue must be a Person. In other words, a range or domain does not typically limit what can be used, but rather, provides information about what is used. If the individuals are expanded and Sue is listed as a Female, what is the effect of stating that Bob Has_Brother Sue? Sue is then interpreted by a reasoner as type Male. As it stands, this is not a problem; Sue is both a Male and a Female. If you desire that it is a problem, then the Ontology should state that Male disjointWith Female (or Female disjointWith Male). Stating that Sue is a Female and that she is the brother of Bob allows a reasoner to notice that the Ontology individuals are inconsistent.

In the presented Ontology, Has_Pet has no range specified. This is another very common error, set Cat and Dog for the range?

  • Has_Pet Range Dog

  • Has_Pet Range Cat

If Bob Has_Pet Fluffy, a reasoner will decide that Fluffy is a Dog and Fluffy is a Cat, because Fluffy is used in the range of Has_Pet. Although this may be what you want, for this example, it is not. The correct way to represent the range is as the union of Cat and Dog. Expressed as XML, this is pretty ugly.

  1. <rdf:Description rdf:about="http://www#Has_Pet">
  2.   <rdf:type rdf:resource=""/>
  3.   <rdfs:range rdf:nodeID="A0"/>
  4. </rdf:Description>
  5. <rdf:Description rdf:nodeID="A0">
  6.   <rdf:type rdf:resource=""/>
  7.   <owl:unionOf rdf:nodeID="A1"/>
  8. </rdf:Description>
  9. <rdf:Description rdf:nodeID="A1">
  10.     <rdf:first rdf:resource="http://www#Cat"/>
  11.     <rdf:rest rdf:nodeID="A2"/>
  12. </rdf:Description>
  13. <rdf:Description rdf:nodeID="A2">
  14.     <rdf:first rdf:resource="http://www#Dog"/>
  15.     <rdf:rest rdf:resource=""/>
  16. </rdf:Description>

Setting the domain and range on a property allows you to set inferential consequences on every individual using a property. You can use owl:allValuesFrom to set inference rules that are only valid in the context of a specific class. For example, I might have a property "has_parent". I can then use allValuesFrom to specify that in the context of the Human class, the range of has_parent is human.
  1. <owl:Class rdf:ID="Human"> 
  2.   <rdfs:subClassOf>
  3.     <owl:Restriction> 
  4.       <owl:onProperty rdf:resource="#has_parent"/>
  5.       <owl:allValuesFrom rdf:resource="#Human"/>
  6.     </owl:Restriction> 
  7.   </rdfs:subClassOf>
  8. </owl:Class>

The restriction defines an anonymous class of individuals for which the has_parent property has values of class Human. This restriction is used specifically with classes of type Human, so all of their parents are Human.

Until next time... You may find useful information here: