Henriette's Notes

Home » Posts tagged 'ontology'

Tag Archives: ontology

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.

Associations between Classes

This far we have only considered UML classes where the attributes are primitive types rather than classes. Here we will consider UML classes that have classes as attributes. Assume we want to model projects. Assume a project must have one name, one sponsor that must be a manager and it must have a team of between 3 and 10 employees. In UML this can be stated using attributes (see Fig.1(a)) or associations (see Fig. 1(b)). For interest sake Wazlawick [1] suggests using attribute notation for data types and associations for classes. His motivation is that associations makes dependencies between classes more apparent. I usually follow this guideline myself.

Fig. 1

Fig. 1

The OWL representation for these 2 class diagrams is given in Fig. 2. The first thing to notice is that we use ObjectProperty instead of DataProperty to represent the sponsor attribute/association. Similar for the team attribute/association. Our property definitions also now have Domain and Range restrictions. When we say that Susan is the sponsor for ABC, we can infer that Susan is a manager and ABC is project. This information can be captured through Domain and Range restrictions. For the purpose of finding modeling errors in it is preferable to add Domain and Range restrictions.

Association between Classes Manchester

Fig. 2

To limit the number of employees on a team to between 3 and 10 employees we use the property cardinality restrictions team min 3 owl:Thing and team max 10 owl:Thing. It may seem strange that we use team max 10 owl:Thing rather than team max 10 Employee. Surely we want to restrict team members to employees? Well true, but that is achieved through our range restriction on the team object property. Here we restricting our team to 10 whatever classes and the range restriction will infer that the team must be of type Employee.

References

1. R. S. Wazlawick, Object-oriented Analysis and Design for Information Systems: Modeling with UML, OCL and IFML, Morgan Kaufmann, 2014.