Henriette's Notes

Home » Posts tagged 'ontology'

Tag Archives: ontology

Introduction to ontology semantics and reasoning

I recently had the pleasure to present at the OntoSpot meeting at EBI to help my colleagues gain an intuitive understanding of ontology semantics and reasoning. In this talk I assume that you have a very basic understanding of what an ontology is, but I assume no previous knowledge wrt logic. I provide a number of examples and graphics to explain logic and description logic (DL) concepts.

Here I provide both the slides of this presentation and the link to the recording. If you have any questions or suggestions, please let me know in the comments. I have already had the very helpful suggestion for adding a reference of DL symbols, which I will do shortly.

Errata:

  1. In the section on speaking about propositional logic, I accidentally said predicate logic instead of propositional logic.
  2. At the end while answering questions, I said RFD rather than RDF.

This video will also be made available at the OBO Academy.

EquivalentTo versus SubClassOf

In creating their first OWL ontology, there are at least two aspects of EquivalentTo and SubClassOf that perplex users. The first is when to use EquivalentTo and when to use SubClassOf. The second problem is best illustrated by the following example:


ObjectProperty: a_to_b

Class: A1
   EquivalentTo: (a_to_b some B)

Class: A2
   SubClassOf: (a_to_b some B)

Class: B

Individual: b1
   Types: 
       B

Individual: x
   Facts:  
       a_to_b  b1

When running a reasoner on this example, the individual x is inferred to be of type A1. What perplex users sometimes is that x is not inferred to be of type A2 as well. This is shown in the next figure.

x inferred to be of type A1

The difference between EquivalentTo and SubClassOf

The first thing to be aware of wrt equivalentTo is that

Class: C
   	EquivalentTo: D

is an abbreviation for

Class: C
    SubClassOf: D
	
Class: D
    SubClassOf: C

The semantics of SubClassOf is subset. Thus, the above states that the set C is a subset of the set D and the set D is a subset of the set C. Which means that the sets C and D are exactly the same set. We say they are equivalent.

Note that if I know that the classes C1 and C2 are both subclasses of class C, there is nothing more I can say about how class C1 relates to class C2. This is a bit like knowing that bicycles and trucks are both vehicles – I can say nothing more about how bicycles relate to trucks beyond knowing that they are both vehicles.

Back to our initial example

Understanding the semantics of EquivalentTo we can see that indeed the individual x is an instance of A1. Understanding the semantics of SubClassOf helps us to understand why x is not inferred to be of type A2. We know that A2 is a subclass of a_to_b some B and that x is an instance of a_to_b some B, but there is nothing that can force the reasoner to infer that x is necessarily an instance of the class A2. This is illustrated in the next figure.

A2 and x wrt the set (a_to_b some B)

When to use EquivalentTo versus SubClassOf

EquivalentTo is used for definitions. That is when you want to state the necessary and sufficient conditions for a concept.

SubClassOf is used when you want to define a hierarchy from the most general to the most specific. I.e., it is typically what you see in taxonomies or in object oriented programming languages where one can define class hierarchies. In fact there is a strong relation between OWL 2 ontologies and object orientation which I explore here in more detail.

Conclusion

In this post I explained the difference between EquivalentTo versus SubClassOf and how they are used, as well as some inferences thatmay be confusing to new users. You can find the example ontology on GitHub.

Why does the OWL Reasoner ignore my Constraint?

A most frustrating problem often encountered by people, with experience in relational databases when they are introduced to OWL ontologies, is that OWL ontology reasoners seem to ignore constraints. In this post I give examples of this problem, explain why they happen and I provide ways to deal with each example.

An Example

A typical example encountered in relational databases is that of modeling orders with orderlines, which can be modeled via Orders and Orderlines tables where the Orderlines table has a foreign key constraint to the Orders table. A related OWL ontology is given in Figure 1. It creates as expected Order and Orderline classes with a hasOrder object property. That individuals of Orderline are necessarily associated with one order is enforced by Orderline being a subclass of hasOrder
exactly 1 owl:Thing
.

Order

Figure 1: Order ontology

Two Problems

Two frustrating and most surprising errors given the Order ontology are: (1) if an Orderline individual is created for which no associated Order individual exists, the reasoner will not give an inconsistency, and (2) if an Orderline individual is created for which two or more Order individuals exist, the reasoner will also not give an inconsistency.

Missing Association Problem

Say we create an individual orderline123 of type Orderline, which is not associated with an individual of type Order, in this case the reasoner will not give an inconsistency. The reason for this is due to the open world assumption. Informally it means that the only inferences that the reasoner can make from an ontology is based on explicit information stated in the ontology or what can derived from explicit stated information.

When you state orderline123 is an Orderline, there is no explicit information in the ontology that states that orderline123 is not associated with an individual of Order via the hasOrder property. To make explicit that orderline123 is not in such a relation, you have to define orderline123 as in Figure 2. hasOrder max 0 owl:Thing states that it is known that orderline123 is not associated with an individual via the hasOrder property.

HasNoOrder

Figure 2: orderline123 is not in hasOrder association

Too Many Associated Individuals Problem

Assume we now change our definition of our orderline123 individual to be associated via hasOrder to two individuals of Order as shown in Figure 3. Again, most frustratingly the reasoner does not find that the ontology is inconsistent. The reason for this is that OWL does not make the unique name assumption. This means that individuals with different names can be assumed by the reasoner to represent a single individual. To force the reasoner to see order1 and order2 as necessarily different, you can state order1 is different from order2 by adding DifferentFrom:order2 to order1 (or similarly for order2).

HasTwoOrders

Figure 3: orderline123 has two orders

Constraint Checking versus Deriving Inferences

The source of the problems described here is due to the difference between the
purposes of a relational database and an OWL reasoner. The main purpose of a
relational database is to enable view and edit access of the data in such a way that the integrity of the data is maintained. A relational database will ensure that the data adheres to the constraints of its schema, but it cannot make any claims beyond what is stated by the data it contains. The main purpose of an OWL reasoner is to derive inferences from statements and facts. As an example, from the statement Class: Dog SubclassOf: Animal and the fact Individual: pluto Type: Dog it can be derived that pluto is an Animal, even though the ontology nowhere states explicitly that pluto is an Animal.

Conclusion

Many newcomers to OWL ontologies get tripped up by the difference in purpose of relational databases and OWL ontologies. In this post I explained these pitfalls and how to deal with them.

If you have an ontology modeling problem, you are welcome leaving a comment detailing the problem.