Reasoning in ontologies
- Last verification: 20221121
- Tools required for this lab:
- Reasoner:
- HermiT (mirror: HermiT-1.3.8.1099.zip)
- Pellet 2.3.1 (mirror: pellet-2.3.1.zip) (works only on Java ⇐ 8)
Prepare yourself for the lab
- Semantic Web Misconceptions (this is probably the right moment for this text, as you already know something about the ontologies
)
- OPTIONAL: OWL is based on Description Logics formalism –- if you want to know more about it, you can familiarize yourself with a Description Logics Tutorial
Lab instructions
1. TBox and ABox [10 minutes]
- The knowledge base in OWL (which is based on Description Logics) consists of two types of concepts:
- TBox – terminology, intensional representation
- ABox – assertions about individuals, extensional representation
- Let's check if you understand this difference properly: Take your ontology from previous lab. Identify five statements that belong to Terminology (TBox) and five to World Description (ABox).
Note: we will not use ontology from previous classes during the following exercises (we will only check it using Pellet reasoner in OWL Reasoning - Reasoners section). There will be mini-examples for each of them to show particular ideas.
2. OWL Reasoning - Class Inference [10 minutes]
- In Description Logics on which the OWL language is based there are the following reasoning tasks for classes (terminology, TBox):
- Class subsumption (Structuring the knowledge base)
- Class equivalence (Are two classes in fact the same class?)
- Class disjointness (Do classes A and B have common members?)
- Class consistency (Isn't class A empty?)
- Model the following ontology axioms in Protege:
Class: bus_driver EquivalentTo: person that drives some bus Class: driver EquivalentTo: person that drives some vehicle Class: bus SubClassOf: vehicleHints:
- To build the first axiom:
- Start the reasoner (
Reasoner → start reasoner) and observe the inferred class hierarchy.- Explain the inferred relations and conclusions.
- Analyze the reasoning examples given here in “Class Inferences” section.
3. OWL Reasoning - Instance Inferences [10 minutes]
- In Description Logics on which the OWL language is based there are the following reasoning tasks for instances (world description, ABox):
- Class membership (is instance a contained in class C?)
- Instance retrieval (find all (known) individuals belonging to a given class)
- and for the whole Knowledge Base (ABox+TBox):
- Global consistency of a knowledge base (Is the knowledge base meaningful?)
- Download the pre-prepared ontology and load it in Protege (NB: the ontology classes and those on screenshots may differ a little).
- Model the following ontology axioms in Protege:
Individual: Daily_Mirror Types: owl:Thing Individual: Q123ABC Types: van, white_thing Individual: Mick Types: man Facts: reads Daily_Mirror, drives Q123ABC Class: white_van_man EquivalentTo: man that drives some (van and white_thing) SubClassOf: reads only tabloidFor those not familiar with UK culture, White Van Man is a stereotype used to describe a particular kind of driver. Wikipedia provides an entry with some additional information and references.
Hints: - Start the reasoner (
Reasoner → Start reasoner) and observe the inferred class hierarchy. Where is thewhite_van_man? What conclusions have been drawn?- Explain the inferred relations and conclusions.
- Analyze the reasoning examples given here in “Instance Inferences” section.
4. OWL Reasoning - Reasoners [5 minutes]
Description Logics (DL) reasoners may be integrated with other tools – as in the case of Protege presented before – as well as run independently via various interfaces. Popular DL reasoners include: FaCT++, Pellet, HermiT, RacerPro and many others.
We will use the HermiT reasoner (you can also use Pellet reasoner; the link is at the top of this page).
- Download the reasoner and unpack the zip.
- Get familiar with available commands:
- For HermiT:
java -jar HermiT.jar –help - For Pellet:
pellet.sh help(usepellet.batif you are using Windows)
- Check the consistency of the ontology and observe the results:
- For HermiT:
java -jar HermiT.jar -k <ontology>where<ontology>is:- Your ontology from previous lab
pizza.owlontology provided with HermiT inproject/examples/ontologies/directory
- For Pellet:
pellet.sh consistency <ontology>where the<ontology>is:- Your ontology from previous lab
people+pets.owlontology provided with Pellet inexamples/data/directory
- Classify two above mentioned ontologies and observe the results:
- For HermiT:
java -jar HermiT.jar -cP <ontology> - For Pellet:
pellet.sh classify <ontology>
5. Advanced OWL reasoning [50 minutes]
These instructions are based on the The Family History Knowledge Base Tutorial1) by The University of Manchester, School of Computer Science.
- Download the fhkb-ontologies.zip pack.
- Open Protege
5.1 Warm up
- Load
Family-tree-0.owl - It contains
Sex,Female,Male,Person,ManandWomanclasses. - Create
hasSexproperty. Set domain and ranges onhasSex(Person/Sex). Make it functional. - Create restrictions on
Person:hasSex some Sex. - Import
plain-individuals.owlfile. Observe that none of them have any assertions on them (Active Ontologytab →Imported ontologies→Direct imports). - Using the
Reasonermenu in Protege (Reasoner → Start/Synchronize reasoner), classify the ontology. What inferences are made?
5.2 Characteristics of properties
- Close the previous ontology. Load
Family-tree-1.owl. Check howManandWomanclasses are defined. - Load
individuals-1-parantage.owlfile. - Classify the ontology. What inferences are made?
5.3 Datatype properties
- Close the previous ontology. Load
Family-tree-2.owl. - Create
Victorianclass:Person and birthYear some integer[>=1837, <=1901]- If
<=does not work, try:Person and (birthYear some xsd:integer[>=1837]) and not (birthYear some xsd:integer[>1901])
- Classify the ontology. How many individuals have been classified as Victorians?
5.4 Transitive properties
- Close the previous ontology. Load
Family-tree-3.owl. - Create a new super-property of
hasParentcalledhasAncestor, - Make it transitive and create inverse property.
- Clasify, look at property hierarchy. What do we know about Robert?
- Close the previous ontology. Load
Family-tree-4.owl. - Classify the ontology. Answer the questions:
- What type does
David_bright_1934have? - How many children does he have?
5.5 Property chains
- Close the previous ontology. Load
Family-tree-5.owl. - Add
hasGrandParentsubProperty ofhasAncestor(inversegrandparentOf). - Add domain and ranges.
- Add subProperties
hasGrandMother/Father+ domains and ranges - Classify the ontology. What do we learn about Robert?
5.6 Classes with Individuals, Open World Assumption
- Close the previous ontology. Load
Family-tree-6.owl. - Classify. What are the results?
- Make class of people with min 3 children.
- Classify the ontology, do we find parents with 3 children? Why?
- How to really find parents that have 3 children?
- How to make individuals different from each other?

















