Pets

This exercise is intended to explore further the semantics of the restriction operations in OWL. You might want to try experimenting with an editor as you work through these examples. It can also be helpful to add sample individuals in order to test your assumptions about the classes and their interpretations. You should also experiment and add further classes or change the class definitions given here in order to test out your thinking.

Assume the following initial ontology of pets.

Namespace: owl = <http://www.w3.org/2002/07/owl#>
Namespace:  = <http://owl.cs.manchester.ac.uk/2009/07/sssw/pets#>

Ontology: <http://owl.cs.manchester.ac.uk/2009/07/sssw/pets>


ObjectProperty: hasPet
    Range: 
        Animal
    Inverse: isPetOf

Class: Person

Class: Animal

Class: Cat
    SubClassOf: 
        Animal

Class: Dog
    SubClassOf: 
        Animal
Cats I

Given the following class definition:

Class: PetOwner
    SubClassOf: Person
      that hasPet some Cat
  1. How many Cats does a PetOwner have?
  2. Can a PetOwner have pets which are not Cats?
  3. Is owning a Cat enough to recognise a person as a PetOwner?
  4. How many Dogs does a PetOwner have?
  1. We know that a PetOwner has at least one Cat.
  2. We don't know. A PetOwner may have another pet or may not.
  3. No. This is a subclass, thus we do not have sufficient information to recognise PetOwners. A subclass axiom states necessary conditions for class membership, but does not state sufficient conditions.
  4. We don't know (see answer above).

We should always bear in mind the way in which the semantics of OWL DL is defined using interpretations. Thus in the above, when we say "we don't know X", we mean that there can be interpretations of the ontology which are models (e.g. which respect all the axioms) in which X is true, and there can interpretations of the ontology which are models in which X is false. Thus X isn't a consequence of the stated axioms, and we "don't know" in general whether it will be true or not.


Cats II

Given the following class definition:

Class: PetOwner
    EquivalentTo: Person
      that hasPet some Cat
  1. How many Cats does a PetOwner have?
  2. Can a PetOwner have pets which are not Cats?
  3. Is owning a Cat enough to recognise a person as a PetOwner?
  4. How many Dogs does a PetOwner have?
  1. We know that a PetOwner has at least one Cat.
  2. We don't know. A PetOwner may have another pet or may not.
  3. Yes. We now have an equivalance, so any person having a Cat as pet will be recognised as a PetOwner.
  4. We don't know (see answer above).

Cats III

Given the following class definition:

Class: PetOwner
    SubClassOf: Person
      that hasPet some Cat
       and hasPet only Cat
  1. How many Cats does a PetOwner have?
  2. Can a PetOwner have pets which are not Cats?
  3. Is owning a Cat enough to recognise a person as a PetOwner?
  4. How many Dogs does a PetOwner have?
  1. We know that a PetOwner has at least one Cat.
  2. No the universal restriction (only), means that any pets a PetOwner has must be Cats.
  3. No. This is again a subclass, thus we do not have sufficient information to recognise PetOwners.
  4. We don't know. You may think the answer to this should be none, but it's not. What would you add to the ontology to make this be the case? Left as an exercise for the reader.....

Cats IV

Given the following class definition:

Class: PetOwner
    EquivalentTo: Person
      that hasPet some Cat
       and hasPet only Cat
  1. How many Cats does a PetOwner have?
  2. Can a PetOwner have pets which are not Cats?
  3. Is owning a Cat enough to recognise a person as a PetOwner?
  1. We know that a PetOwner has at least one Cat.
  2. No. The universal restriction (only), means that any pets a PetOwner has must be Cats.
  3. No. Although this is an equivalence, the definition includes a universal restriction (only). Thus, in order to recognise a person as an instance of this class, we need to know not just that they have a Cat as a pet, but that also they have no other pets that are not cats.

Cats V

Given the following class definition:

Class: PetOwner
    SubClassOf: Person
    EquivalentTo: 
       hasPet some Cat

Individual: Sean
    Facts: hasPet Fluffy

Individual: Fluffy
    Types: Cat
  1. What (if anything) can we infer about Sean?
  1. We can infer that Sean is a PetOwner (and is thus a Person).

In this example, we have an interaction between a subclass and an equivalence. The equivalence gives us sufficent conditions to recognise Sean as a PetOwner, and the subclass states some necessary conditions that must then hold, i.e. Sean is a Person. If we had modelled this as in example Cats II above, i.e.:

Class: PetOwner
    EquivalentTo: Person
      that hasPet some Cat

Individual: Sean
    Facts: hasPet Fluffy

Individual: Fluffy
    Types: Cat

we would not be able to draw the inference that Sean is a PetOwner, as we don't know that he's a Person.

Although this may be exactly what we want to model, we sometimes see this kind of modelling pattern as an "error", where an equivelance is stated for a single expression, rather than a conjunction of a number of restrictions.


Cats VI

Given the following class definition:

Class: PetOwner
    SubClassOf: Person 
       that hasPet some (not Cat)
  1. How many Animals does a PetOwner has as pets?
  2. How many Cats does a PetOwner has as pets?
  1. At least one. We know that a PetOwner has a pet, and the range restriction on hasPet allows us to infer that it must be an animal.
  2. We don't know. Could be zero, one or many.

The second answer above may be unexpected. Note that this definition says that a PetOwner must have at least one pet that is not a Cat, but doesn't say anything about any other pets they might have.


Cats VII

Given the following class definition:

Class: PetOwner
    SubClassOf: Person 
       and not (hasPet some Cat)
  1. How many Animals does a PetOwner has as pets?
  2. How many Cats does a PetOwner has as pets?
  1. We don't know. Could be zero, one or many.
  2. None

For this example, we now know that a PetOwner is a subclass of (not (hasPet some Cat)), thus a PetOwner cannot have a Cat as a Pet. However, this definition doesn't tell us whether a PetOwner actually has any Pets (hence the answer to the first question).

Generalisation of De Morgan's laws tells us that this definition is actually the same as the following:

Class: PetOwner
    SubClassOf: Person 
       and hasPet only (not Cat)

Here, it perhaps clearer that this definition states that anything related to a PetOwner via hasPet is not a Cat — but we must remember that the universal quantification (only in Manchester syntax) does not make any statement about the existence of a related object.

Note the difference between example VI and VII.

Bonus Question Explore the consequences of replacing only with some and vice versa in examples VI and VII.


Cats and Dogs I

Given the following additional definitions:

DisjointClasses: Dog, Cat

Class: PetOwner
    subClassOf: Person
        that hasPet some (Cat or Dog)
        and hasPet only (Animal)
  1. How many animals does a PetOwner as pets?
  2. How many Cats does a PetOwner as pets?
  3. How many Dogs does a PetOwner as pets?
  1. A PetOwner has at least one animal as a pet. We know they must have a pet, and any pet must be an animal.
  2. We don't know.
  3. We don't know.

You may find the last two answers above surprising. All we do know is that a PetOwner has a pet, and that pet is a Cat or a Dog. But we don't know which it is. Thus we can't say for sure that a PetOwner has a Dog or that a PetOwner has a Cat.


Cats and Dogs II

Given the following additional definitions:

DisjointClasses: Dog, Cat

Class: PetOwner1
    EquivalentTo: Person
        that (hasPet some Cat 
        and hasPet some Dog)

Class: PetOwner2
    EquivalentTo: Person
        that (hasPet some Cat 
        or hasPet some Dog)

Class: PetOwner3
    EquivalentTo: Person
        that hasPet some (Cat or Dog) 

Class: PetOwner4
    EquivalentTo: Person
        that hasPet some (Cat and Dog) 


  1. Which of these classes (if any) are equivalent?
  2. Which classes subsume others?
  3. Are all classes satisfiable?
  1. PetOwner2 and PetOwner3 are equivalent. Stating that a PetOwner has a Cat or has a Dog is the same as stating that they have a Cat or a Dog. Note that the same is not the case with and.
  2. PetOwner1 is subsumed by PetOwner2 and PetOwner3. Anyone with a Cat and a Dog has a Cat or a Dog.
  3. PetOwner4 is unsatisfiable as Cat and Dog are disjoint, thus we cannot have anything that is both a Cat and a Dog. Note the difference with definition PetOwner1 — in this case of PetOwner1, we can have two different pets, one Cat and one Dog. In fact, we'll be able to infer here that a PetOwner1 must have at least two pets.

Fleas I

Given the following additional information

ObjectProperty : hasPet
    Characteristics: transitive

Class: Flea
    SubClassOf: Animal
    
Class: PetOwner
    SubClassOf: Person
        that hasPet some (Cat that hasPet some Flea)
  1. How many Cats does a PetOwner have as pets?
  2. What animals does a Cat have as pets?
  3. What animals does a PetOwner have as pets?
  4. What happens if I add the restriction hasPet only Cat to the description of PetOwner?
  1. A PetOwner will have at least one Cat as a pet.
  2. We don't know
  3. A PetOwner has at least one Cat and one Flea. The Flea is due to the transitivity of the hasPet relationship.
  4. Nothing obvious happens (i.e. none of the classes become unsatisfiable, and the hierarchical classification doesn't change). We might have expected the PetOwner class to be inconsistent, but this won't happen — What would we need to add in order for this to happen?
  1. Does every Cat that's a pet have a Flea as a pet?
  1. No.

This answer may be a little surprising. The class definition of PetOwner states that a PetOwner has a Cat as a pet that has a Flea as a pet. This does not means that every Cat that is a pet has a Flea. Simply that if someone is a PetOwner, one of the Cats they have as a pet has a Fleas.

In order to illustrate this, consider the following:

Individual: Tibbs
    Types: Cat
    DifferentFrom: Fluffy
    
Individual: Fluffy
    Types: Cat

Individual: Sean
    Types: PetOwner, hasPet max 2
    Facts: hasPet Tibbs,
           hasPet Fluffy

In this case, we know that Sean has two pets, Tibbs and Fluffy. As every PetOwner has a Cat which has a Flea, we know that either Tibbs or Fluffy has a Flea, but we can't tell which one. There are valid interpretations of this ontology in which Tibbs has a Flea and Fluffy does not, and vice versa. Thus Tibbs having a Flea is not a consequence of these statements.

This example is primarily intended to illustrate the subtle difference between an unqualified and a qualified property restriction.

Bonus question! Why might we have included assertions concerning the cardinality of the hasPet property and the differentFrom statements about Tibbs and Fluffy? If those assertions are not there, what can we say about Tibbs and Fluffy?

Bonus bonus question! If we state:

Individual: Tibbs
    Types: Cat, not hasParasite Fleas
    DifferentFrom: Fluffy
    

What can we now infer? And why?


Fleas II

The following example makes use of a new feature introduced into OWL2: Role chains. Given the following additional information

ObjectProperty: hasParasite
    SubPropertyChain: 
        hasPet o hasParasite

Class: Flea
    SubClassOf: Animal
    
Class: PetOwner
    SubClassOf: Person
        that hasPet some (Cat that hasParasite some Flea)
  1. How many Cats does a PetOwner have as pets?
  2. What animals does a Cat have as parasites?
  3. What animals does a PetOwner have as pets?
  4. What animals does a PetOwner have as parasites?
  1. A PetOwner will have at least one Cat as a pet.
  2. We don't know
  3. A PetOwner has at least one Cat.
  4. A PetOwner will have a Flea as a parasite. This is due to the role chain assertion on hasParasite, which means that parasites of a pet will be parasites of the PetOwner.

Cardinality I

Assuming the following additional statements:

Class: PetOwner
    SubClassOf: Person
        that hasPet max 2
  1. How many Cats can a PetOwner have as pets?
  2. How many Animals can a PetOwner have as pets?
  1. A PetOwner can have at most 2 Cats as Pets
  2. A PetOwner can have at most 2 Animals as Pets

This particular example is rather straightforward. The cardinality restriction means that a PetOwner can have at most two things related via the hasPet relation, whether they're Cats, Dogs or any other kind of Animal

Cardinality II

This example uses a new features from OWL2: qualified cardinality restrictions.

Assuming the following additional statements:

Class: PetOwner
    SubClassOf: Person
        that hasPet max 2 Cat
  1. How many Cats can a PetOwner have as pets?
  2. How many Animals can a PetOwner have as pets?
  1. A PetOwner can have at most 2 Cats as Pets
  2. A PetOwner can have any number of Animals as Pets. This may seem a surprising result. The cardinality restriction here states that a PetOwner can have a maximum of 2 Cats as pets, but this doesn't restrict the total number of Animals that can be pets. Thus perhaps a more accurate response would be that a PetOwner can have any number of Animals as Pets, as long as no more than 2 of them are Cats.

To further illustrate this example, consider the following collection of instances:

Individual: Sean
    Types: PetOwner
    Facts: hasPet Tibbs,
	       hasPet Fluffy,
           hasPet Spot

Individual: Fluffy
    Types: Cat
    DifferentFrom: Spot, Tibbs

Individual: Spot
    DifferentFrom: Fluffy, Tibbs

Individual: Tibbs
    Types: Cat
    DifferentFrom: Fluffy, Spot

Sean has three pets (Fluffy, Spot and Tibbs, which are all different). A reasoner will be able to infer for us that, as Sean has two pets that are Cats (Fluffy and Tibbs), Spot is not a Cat.

Bonus Question What would happen if we were to assert that Spot was a Cat?


Grumpy Old Men

OWL2 provides a property characteristic of reflexivity. If a property is reflexive, then every individual in the domain must be related to itself via that property.

If we add the following to our ontology:

ObjectProperty: likes
    Characteristics: 
        Reflexive

Class: Misanthrope
    EquivalentTo: 
        Person
        and (likes only (not (Person)))
  1. What do we know about the class Misanthrope, and why?
  1. The reflexivity of likes means that for all individuals in the domain, there must be a likes relationship with itself. The definition of Misanthrope, however, means that any instance of this class must be a Person, but cannot be related to a Person via likes. Thus we can have no instances of this class and it is unsatisfiable.

Reflexivity can have some subtle side-effect. For example, what are the consequences of stating the following?

ObjectProperty: likes
    Characteristics: 
        Reflexive
    domain: Person

Note also that a reflexive relation doesn't just mean that individuals are related to themselves. Thus an individual can like other things than itself (but it must, at minimum, like itself).

Bonus Question Additional property characteristics include irreflexivity and asymmetry. Try experimenting with the results of stating these characteristics for properties.