Henriette's Notes

Category Archives: OWL

Understanding OWL min vs max vs exactly Property Restrictions

The open world assumption trips people up in many ways. In this post we will be looking at how the open world assumption affects the semantics of the property restrictions min, max and exactly.

The example we will use throughout this post is that of a product that may have no price, 1 price, exactly 1 price, or many prices. We will firstly assume a product must have at least 1 price, then that it can have a maximum of 1 price, and finally we will assume that it must have exactly 1 price. We therefore assume that we have a hasPrice data property that is defined as follows:

DataProperty: hasPrice
  Range: 
    xsd:decimal

The example ontology can be found on GitHub. To be able to distinguish the different product types having different rules regarding how many prices they have, we will create 3 different classes called ProductWith_Min_1_Price, ProductWith_Max_1_Price and ProductWith_Exactly_1_Price respectively.

Before we look at examples and the semantics of the min, max, exactly property restrictions, let us briefly recall what is meant by the open world assumption.

Open World Assumption versus Closed World Assumption

OWL has been designed with the explicit intention to be able to deal with incomplete information. Consequently, OWL intentionally does not make any assumptions with regards to information that is not known. In particular, no assumption is made about the truth or falsehood of facts that cannot be deduced from the ontology. This approach is known as the open world assumption. This approach is in contrast with the closed world assumption typically used in information systems. With the closed world assumption facts that cannot be deduced from a knowledge base (i.e. database) are implicitly understood as being false [1, 2, 3].

As an example, in a database when a product does not have a price, the general assumption is that the product does not have price. Moreover, in a database if a product has 1 price, the assumption is that the product has only 1 price and no other prices. This in stark contrast to OWL. If an OWL ontology defines a product for which no explicit price is given, the assumption is not that the product has no price. Rather, no assumption is made as to whether the product has a price, has many prices or whether it has no price. Futhermore, if a product has a price, the assumption is not that this is necessarily the only price for that product. Rather, it allows for the possibility that no other price may exist, or that many other prices may exist, which is merely not known. The only information that holds in an ontology is information that is either explicitly stated, or that can be derived form explicit information.

The min Property Restriction

To define a product that must have at least 1 price we define it as follows:

Class: ProductWith_Min_1_Price
  SubClassOf: 
    hasPrice min 1 xsd:decimal
  
Individual: productWithoutPrice
  Types:  
    ProductWith_Min_1_Price

If we now create an individual of type ProductWith_Min_1_Price, say productWithoutPrice, which has no price information, we will find that the reasoner will not give an inconsistency. The reason for this is that the reasoner has no information with regards to whether productWithoutPrice has any price information. Hence, it is possible
that productWithoutPrice has a price (or prices) that is merely unknown. To make explicit that productWithoutPrice has no price information, we can define it as follows:

Individual: productWithoutPrice
  Types:  
    ProductWith_Min_1_Price,
    hasPrice max 0 xsd:decimal

This revised definition of productWithoutPrice will now result in the reasoner detecting an inconsistency. However, note that ProductWith_Min_1_Price allows for products
that have more than 1 price. Hence, the following will not result in an inconsistency.

Individual: productWithManyPrices
  Types:  
    ProductWith_Min_1_Price
  Facts:  
    hasPrice 2.5,
    hasPrice 3.25 

The max Property Restriction

To define a product that cannot have more than 1 price, we can define it as
follows:

Class: ProductWith_Max_1_Price
  SubClassOf: 
    hasPrice max 1 xsd:decimal 

If we now define an individual productWithMoreThan1Price with more than 1 price (as shown in the example below), the reasoner will detect an inconsistency.

Individual: productWithMoreThan1Price
  Types: 
    ProductWith_Max_1_Price
  Facts:  
    hasPrice 2.5,
    hasPrice 3.25

Note that individuals of type ProductWith_Max_1_Price can also have no price information without resulting in the reasoner giving an inconsistency. I.e., if we define the individual productWithoutPrice as

Individual: productWithoutPrice
  Types:  
    ProductWith_Max_1_Price,
    hasPrice max 0 xsd:decimal

it will not give an inconsistency.

The exactly Property Restriction

Let us now define ProductWith_Exactly_1_Price with the individual productWithExactly1Price as follows:

Class: ProductWith_Exactly_1_Price
  SubClassOf: 
    hasPrice exactly 1 xsd:decimal    
    
Individual: productWithExactly1Price
  Types: 
    ProductWith_Exactly_1_Price  
  Facts:
    hasPrice 7.1

The exactly property is essentially syntactical shorthand for specifying both the min and max restrictions using the same cardinality. Thus, we could just as well have defined ProductWith_Exactly_1_Price as:

Class: ProductWith_Exactly_1_Price
  SubClassOf: 
     hasPrice min 1 xsd:decimal,
     hasPrice max 1 xsd:decimal

or, given the classes we have already defined in the ontology, we can define it as:

Class: ProductWith_Exactly_1_Price
  SubClassOf: 
    ProductWith_Max_1_Price,
    ProductWith_Min_1_Price

Prefer exactly

Given that the exactly property restriction is syntactical sugar, should we prefer using the combination of min and max directly as shown above? My answer to this is no. My motivation for this is that the semantics of exactly is only equivalent to the intersection of min and max if the cardinalities are the same and the data/object types are the same. As such specifying

Class: ProductWith_Exactly_1_Price
  SubClassOf: 
    hasPrice exactly 1 xsd:decimal

has less opportunities for mistakes than specifying

Class: ProductWith_Exactly_1_Price
  SubClassOf: 
    hasPrice min 1 xsd:decimal,
    hasPrice max 1 xsd:decimal

Conclusion

In this post we looked at some of the ways in which the min, max and exactly property restrictions can trip people up due to the open world assumption. Please feel free to leave a comment if you have questions or suggestions about this post.

References

1. F. Baader and W. Nutt, Basic Description Logics, The Description Logic Handbook: Theory, Implementation and Applications (F. Baader, D. Calvanese, D. L. McGuinness, D. Nardi, and P. Patel-Schneider, eds.), Cambridge University Press, New York, USA, 2007, pp. 45–104.

2. M. Krötzsch, F. Simančı́k, and I. Horrocks, A Description Logic Primer, Computing Research Repository (CoRR) abs/1201.4089 (2012).

3. S. Rudolph, Foundations of Description Logics, Proceedings of the 7th International Conference on Reasoning Web: Semantic Technologies for the Web of Data (A. Polleres, C. d’Amato, M. Arenas, S. Handschuh, P. Kroner, S. Ossowski, and P. F. Patel-Schneider, eds.), Lecture Notes in Computer Science, vol. 6848, Springer, 2011, pp. 76–136.

A Common Misconception regarding OWL Properties

A misconception w.r.t. OWL properties that I come across from time-to-time is that people mistakenly think that properties express relations between classes rather than relations between individuals. In this post

  1. I explain how this misconception fails,
  2. I explain what is the meaning of OWL properties, and
  3. I explain how you can model relations between classes if that is really what you want to do.

Throughout this post I will refer to object properties only, even though what I say applies to data properties as well, except of course that object properties relate objects to objects whereas data properties relate objects to data type values.

As an example ontology I will use the following:

Class: Employer
Class: Employee

ObjectProperty: employs
   Domain: Employer
   Range: Employee

How thinking that Properties express Relations between Classes fails

Thinking that properties express relations between classes fails in two different ways:

  1. The first way in which the expectations of users fail under this misconception is that their assumption is that domain and range axioms behave as constraints. That is if we extend our Employer ontology with something nonsensical like
    Class: Cheese
    Class: Fridge
    
    Individual: companyFridge 
        Types: Fridge
        
    Individual: blueCheese
       Types: Cheese
       Facts: employs companyFridge
    

    the reasoner will indicate that our ontology is inconsistent because the individual blueCheese is not of type Employer and neither is the individual companyFridge an instance of Employee. However, this is not the case. This ontology is in fact consistent because domain and range axioms do not behave as constraints.

  2. The other way in which the assumption of users is shattered is that they tend to think that domain and range axioms mean that in our Employer ontology it means that instances of the Employer class must necessarily be linked via the employs property to an instance (or instances?) of Employee. Thus, the expectation is that if we have an instance Employer that is not linked to an instance of Employee via the employs property, the reasoner should give an inconsistency. Again, this is wrong. This ontology will still be consistent.

The Real Meaning of OWL Object Properties

The OWL specification is very explicit about the meaning of object properties. It states:

Object properties connect pairs of individuals.

So what is the meaning of domain and range axioms then? Domain and range axioms are not constraints to be checked, but rather they are axioms from which the reasoner can make inferences. What domain and range axioms state is that whenever two instances are linked via the employs property, for example, it means that the first instance is of type Employer and the second instance is of type Employee. Thus, in our cheese and fridge example, no matter how silly it is, the reasoner will infer that blueCheese is an instance of Employer and companyFridge is an instance of Employee.

Finally, the underlying mathematical formalization of object properties themselves does not enable linking of pairs of classes. An OWL object r is represented as a role r in description logics. Stating that the role r has the domain C and the range D, where C and D are concepts, is achieved through the following axioms:

DomainRangeAxiom whereTopis the set representing the application domain. An object property r between instances a and b is expressed as a role assertion
RoleAssertion in description logics. Note that this assertion contains no information regarding description logic concepts (i.e. classes in OWL).

If you really, really want to have a Link between Classes

So if you really, really want to express a relation between classes, how can this be done? For our Employer ontology we can state the following:

Class: Employer
   SubClassOf: employs some Employee

This states that the Employer class is a subclass of the class consisting of the instances that are linked to at least 1 instance of the Employee class. If we now have an instance of Employer that is not linked via employs to an instance of Employee, the reasoner will find that our ontology is inconsistent. To state that acme is an employer without employees, we state it as follows:

Individual: acme
   Types: Employer
   Facts: employs max 0 Employee

Conclusion

In this post I explained that object properties link individuals (not classes!) and that thinking otherwise can lead to various errors when designing an ontology.

Understanding OWL Universal Property Restrictions

In my previous post I explained existential property restrictions. In this post I want to deal with universal property restrictions. In designing ontologies existential property restrictions tend to be used more often than universal property restrictions. However, beginners in ontology design tend to prefer universal property restrictions, which can lead to inconsistencies that can be very difficult to debug, even for experienced ontology designers [1, 2].

We again start with a very simple ontolgy:

ObjectProperty: owns
        
Class: Cat
  SubClassOf: Pet
    
Class: Dog
  SubClassOf: Pet
    
Class: Person
  DisjointWith: Pet
        
Class: Pet
  DisjointUnionOf: Cat, Dog
  DisjointWith: Person

We will use this ontology as basis for explaining universal property restrictions. We assume we want to extend this ontology with a DogLover class to represent persons owning only dogs. In this post:

  1. I will introduce the DogLover class which I will define as Class: DogLover EquivalentTo: owns only Dog,
  2. I will show you how this definition can lead to inconsistencies that can be difficult to debug, and
  3. I will explain how we can fix this error.

Class: DogLover EquivalentTo: owns only Dog

Let us start out by defining the DogLover class as

Class: DogLover
  EquivalentTo: owns only Dog

We can run the reasoner to ensure that our ontology is currently consistent. We can test our ontology by adding a aDogOnlyOwner individual owning a Dog.

Individual: aDog
  Types: Dog

Individual: aDogOnlyOwner
  Facts: owns aDog

If we run the reasoner it will not infer that aDogOnlyOwner is a DogLover, reason being that due to the open world assumption the reasoner has no information from which it can derive that aDogOnlyOwner owns only dogs. We can try and fix this by stating that

Individual: aDogOnlyOwner
  Types: owns max 0 Cat

Again the reasoner will not infer that aDogOnlyOwner owns only dogs. This is because it still allows for the possibility that aDogOnlyOwner can own, say a house. To exclude all other options we have to define aDogOnlyOwner as follows:

Individual: aDogOnlyOwner
  Types: owns max 0 (not Dog)

which enforces that aDogOnlyOwner owns nothing besides dogs. The reasoner will now infer that aDogOnlyOwner is a DogLover. We can also test that individuals of type DogLover cannot own cats, for example:

Individual: aCat
  Types: Cat

Individual: aDogLover
  Types: DogLover
  Facts: owns aCat

If we run the reasoner, it will give an inconsistency. As I said in my previous post, it is always a good idea to review the explanations for an inconsistency, even when you expect an inconsistency, as seen in Figure 1. It states that the inconsistency is due to

  1. aDogLover owning a cat (aDogLover owns aCat),
  2. a cat is not a dog (Pet DisjointUnionOf Cat, Dog),
  3. an individual that loves dogs owns only dogs (DogLover EquivalentTo owns only Dog),
  4. the aDogLover individual is of type DogLover (aDogLover Type DogLover), and
  5. the aCat individual is of type Cat (aCat Type Cat).
ExplanationForDogLoverWithCat

Figure 1

At this point you may think our definition of DogLover is exactly what we need, but it contains a rather serious flaw.

A Serious Flaw

To keep our ontology as simple as possible for this section, please remove any
individuals you may have added to your ontology, but leave the DogLover class as we have defined it in the previous section. Just to ensure that our ontology is consistent, you can run the reasoner to confirm that it is consistent. What we now want to do is to infer that when an individual owns something, that individual is a person. The way we can achieve this is by defining the domain for the owns property:

ObectProperty: owns
  Domain: Person

Now, this looks like a rather innocent change, but when you run the reasoner again you will find that Pet, Cat and Dog are all equivalent to owl:Nothing while Person is equivalent to owl:Thing. An explanation for why Pet is equivalent to owl:Nothing is given in Figure 2.

ExplanationForPetEquivalentToNothing

Figure 2

The explanation given in Figure 2 can be difficult to understand. Indeed, research has shown that there are explanations that are difficult to understand even for experienced ontology designers [1, 2]. In cases where it is hard to understand explanations, using laconic explanations can be helpful. Laconic justifications aim to remove subexpressions from axioms that do not contribute to explaining an entailment or inconsistency [1, 2]. Ticking the “Display laconic explanation” displays the laconic explanation in Figure 3.

LaconicExplanationForPetEquivalentToNothing

Figure 3

The main difference between the explanations in Figures 2 and 3 are

DogLover EquivalentTo owns only Dog

versus

owns only owl:Nothing SubClassOf DogLover

Where does owns only owl:nothing SubClassOf DogLover come from? Recall that A EquivalentTo B is just syntactical sugar for the two axioms A SubClassOf B and B SubClassOf A. What this explanation is saying is that there is a problem with the owns only Dog SubClassOf DogLover part of our axiom (there is no problem with the DogLover SubClassOf owns only Dog part of our axiom). Furthermore, it states that Dog is inferred to be equivalent to owl:Nothing. For this we need to understand the meaning of owns only Dog better.

OwnsOnlyDog

Figure 4

In Figure 4 I give an example domain where I make the assumption that for all individuals all ownership information is specified explicitly. Thus, individuals with no ownership links own nothing and individuals with ownership links own only what is specified and nothing else. The owns only Dog class includes all individuals that are known to own nothing besides dogs. However, a confusing aspect of the semantics of universal restrictions is that it also includes those individuals that owns nothing. To confirm this for yourself you can use the following ontology (from which I removed the domain restriction for the moment). This ontology will infer that anIndividualOwningNothing is of type DogLover.

ObjectProperty: owns
        
Class: Cat
  SubClassOf: Pet
    
Class: Dog
  SubClassOf: Pet
    
Class: Person
  DisjointWith: Pet
        
Class: Pet
  DisjointUnionOf: Cat, Dog
  DisjointWith: Person
  
Class: DogLover
  SubClassOf: Person
  owns only Dog SubClassOf: DogLover
  
Individual: anIndividualOwningNothing
  Types: owns only (not owl:Thing)

We are now ready to explain why Pet is equivalent to owl:Nothing:

  1. owns Domain Person states that whenever an individual owns something, that individual is a Person.
  2. owns only Pet SubClassOf DogLover includes saying that when an individual owns nothing at all, that individual is a DogLover.
  3. Since DogLover is a subclass of Person it means Person now includes individuals that owns something and individuals that owns nothing, which means Person is equivalent to owl:Thing.
  4. Person and Pet are disjoint, hence Pet must be equivalent to owl:Nothing.

Conclusion

So how do we fix our ontology? Simple, we enforce that for someone to be a DogLover, they must own at least 1 dog and nothing else but dogs.

Class: DogLover
  EquivalentTo: owns some Dog and owns only Dog

The example ontologies of this post can be found in github.

Bibliography

[1] M. Horridge, Justification Based Explanation in Ontologies, Ph.D. Thesis, University of Manchester, 2011.

[2] M. Horridge, S. Bail, B. Parsia, and U. Sattler, Toward Cognitive Support for OWL Justifications., Knowl.-Based Syst. 53 (2013), 66–79.