Henriette's Notes

Home » The mathematics of object orientation

Category Archives: The mathematics of object orientation

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.

 

Inheritance

In this post we will look at how different types of inheritance can be translated to OWL. We consider the case where Person is specialized by Employee and Client (Fig. 1). In a UML class diagram if inheritance is not annotated the default annotation {incomplete, disjoint} is assumed. incomplete means there are instances of Person which are neither of type Employee nor Client. disjoint means there is no instance of Person that is both of type Employee and of type Client. The set representation is given in Fig. 2 and the OWL translation in Fig. 3.

InheritanceDefault

Fig. 1

InheritanceDefaultSet

Fig. 2

InheritanceDefaultOWL

Fig. 3

The annotation {complete, disjoint} means every instance of Person is either a instance of Employee or an instance of Client(Fig. 4). The corresponding Venn diagram is  given in Fig. 5 and the OWL translation in Fig. 6.

InheritanceCompleteDisjoint

Fig. 4

InheritanceCompleteDisjointSet

Fig. 5

InheritanceCompleteDisjointOWL

Fig. 6

When overlapping is used rather than disjoint it means an instance of Person may be both of type Employee and of type Client.  Fig. 7 – 9 provides a UML class diagram, Venn diagram and OWL translation as example for the annotation {incomplete, overlapping}. Fig. 10 – 12 provides a UML class diagram, Venn diagram and OWL translation as example for the annotation {complete, overlapping}.

InheritanceIncompleteOverlapping

Fig. 7

InheritanceIncompleteOverlappingSet

Fig. 8

InheritanceIncompleteOverlappingOWL

Fig. 9

InheritanceCompleteOverlapping

Fig. 10

InheritanceCompleteOverlappingSet

Fig. 11

InheritanceCompleteOverlappingOWL

Fig. 12

A Brief Introduction to Protégé and Reasoners

A question you rightfully may be pondering is: Why translate object oriented classes into OWL? The answer is that it can help you to find logical inconsistencies in your class designs. In this post I will introduce the tools that will eventually enable you to find logical inconsistencies in your class designs.

The tool we will use is called Protégé. Download and installations instructions for Protégé can be found at https://protegewiki.stanford.edu/wiki/Install_Protege5.

In this post I will provide two screencasts:

  1. In the first screencast I will show you how to enter the OWL representation of the Person class introduced in the previous post.
  2. In the second screencast I will show you how to run a reasoner and how an inconsistency can arise.

On to the first screencast:

  1. Create a Person class.
  2. Create the data properties.
    1. name
    2. surname
    3. age
  3. Through sub-classing state that the Person class necessarily have a
    1. name,
    2. surname and
    3. age.
  4. If we run the reasoner on this ontology, no inconsistencies will be found.

In the second screencast I show how an inconsistency can arise. The steps are as follows:

  1. Create an individual called sarah of type Person.
  2. Run the reasoner. You will see the reasoner give no errors (nothing happened). This may come as a surprise to you since we have not set the name, surname or age data properties for the individual called sarah. In OWL this behaviour is expected due to what is called the open world assumption. OWL makes no assumption with regards to knowledge that is not stated explicitly. Since we did not state that the sarah individual does not have, for example, a name, the reasoner found no error in our ontology. This is different from typical database behaviour where absence of information is often assumed to indicate that the information does not exist, which is referred to as the closed world assumption.
  3. Now let us change our sarah individual to state that it does not have a name. This is achieved by stating that the sarah individual is of type name max 0 xsd:string. This states that the sarah individual can have a maximum of 0 name data properties of type xsd:string.
    SarahDoesNotHaveName
  4. If we run the reasoner now it shows that we have an inconsistency. We can ask Protégé to explain the inconsistency.ExplainSarahInconsistency
  5. The explanation states that sarah is of type Person and of type name max 0 xsd:string. But Person is a subclass of name some xsd:string. This states that individuals of type Person must have at least 1 name property of type xsd:string. Hence, the reason for the inconsistency.

 

Admittedly this example is contrived: there is not much sense in creating a Person class which we state must have a name and then create an individual of type Person which we then state does not have a name. But this was done here to show you how to use a reasoner to find inconsistencies in your ontology and to show you what information you can expect when your ontology is inconsistent.

Add Some More Attributes

Person with added attributes

 

In this post what I want to do is add some attributes to the Person class of the previous post. The important thing to understand is that as you add attributes to a class, what you are doing in effect is adding additional constraints that will cause the number of objects that can be of that type to shrink. This is illustrated in the Venn diagram below. Note that our Person class is now a subset of the intersection of the sets of objects with name as attribute, surname as attribute and age as attribute.

 

Person with more attributes subset

 

If we now consider the OWL 2 representation of this class in Manchester syntax, it matches our Venn diagram exactly. It further states that name, surname and age are properties. It states that individuals of the Person class have a name property of type xsd:string, a surname property of type xsd:string and a age property of type xsd:integer.

 

Add some attributes OWL

A Simple Class

A Simple Class

Let us start with a simple example. Assume we have a Person class, which models a person that has a name. Let us just think about what this means. If we think of our domain of interest and we list all the objects of the domain, some objects will belong to a set that is a subset of the domain of interest, which is called the Person set, which is represented by our Person class. Our Person class also has a name attribute of type String, but it is likely that we will have other classes in our domain that may have a name attribute of type String. Thus, the Person class represents objects that are a subset of all the objects in the domain that have a name attribute of type String. This is shown in the Venn diagram below.

Person Subset

 

Note that the Person class is not necessarily a strict subset of the objects that have a name attribute of type String. It is possible that the Person class is the only class in our domain that has a name attribute of type String, in which case these two sets are in fact equal.

The OWL 2 equivalent representation in Manchester syntax is given in the image below. Note that for the name attribute in the UML class we have defined a related DataProperty. Furthermore, a Person class is also defined, which is defined as SubClassOf: name some xsd:string. What this means is that individuals that belongs to the Person class also belongs to the class of individuals that have a name property of type xsd:string. Thus, the Person class is a subclass of the class representing individuals that have a name property of type xsd:string.

Person Manchester

The Correspondence between DLs/OWL and OO

The analogy between DLs and object-orientation can be observed when it is considered that the basic task in constructing an ontology is classification. Explicit subsumption relationships between concepts can be defined in the TBox. In object-orientation this can be achieved by definition of an inheritance hierarchy between classes. Classification is further solidified as the basis of DLs in that the core reasoning capabilities they provide are subsumption and instance checking. Subsumption computes a subsumption hierarchy, which essentially categorizes concepts into superconcept/subconcept relationships. Instance checking verifies whether a given individual is an instance of a specific concept [1].

In object-orientation the domain of interest is described in terms of classes that have properties, which are defined via attributes and/or associations. Classes in essence have a set-theoretic semantics, i.e. a class represents a set of objects in the domain of interest which shares attributes. Objects that are classified by a class are called instances of the class. The analogy with DLs is that classes, attributes/associations and instances (or sometimes called objects) correspond respectively with concepts, roles and individuals in DLs, which in OWL corresponds respectively to classes, properties and individuals.

This correspondence between object orientation, DLs and OWL 2 is summarized in the table below.

Object orientation DLs OWL 2
Class Concept Class
Attribute/association Role Property
Object Individual Individual

Bibliography

[1] F. Baader, D. Calvanese, D. L. McGuinness, D. Nardi and P. F. Patel-Schneider, The Description Logic Handbook: Theory, Implementation and Applications, Cambridge University Press, 2007.

Theoretical Basis of Object-oriented Analysis

Classification is the core activity of object-oriented analysis. Classification is the means via which people order knowledge according to the similarities they recognize between different objects they observe in the world. The specific classification approach that is applied when doing object-oriented analysis is called classical categorization. Classification, in specific classical categorization, does not pertain to object-orientation alone, but rather, it reflects how people think in general about the world [1] [2] [3]. Olive explains the need and use of classification as follows [2]:

Classification provides cognitive economy because it allows us to structure knowledge about objects into two levels: concept and instance. At the concept level, we find the properties (both defining and nondefining) common to all instances of the concept. At the instance level, we find only the concept of which the object is an instance, and the particular properties of that instance. In the absence of classification, we would have to associate every instance with all of its properties. Classification reduces the amount of information we have to remember, communicate, and process; the extent to which it is reduced depends on the number of properties of the concept.

It is precisely this cognitive economy, provided by a complete and consistent object-oriented conceptual schema, that is the essence of enabling efficient communication between stakeholders of software development projects. When software development projects decide to forgo the creation of conceptual schemas, it is at the cost of efficient communication.

 

Notice that classification is inherently set theoretic. Sets have a characteristic function that essentially determines from a possible universe of elements, which elements belong to the set. With classification commonalities between instances are recognized which cause us to classify these instances as belonging to the same concept. In this way concepts and sets are equivalent.

 

Bibliography

[1] G. Booch, R. A. Maksimchuk, M. W. Engel, B. J. Young, J. Conallen and K. A. Houston, Object-oriented analysis and design with applications, Addison-Wesley Professional, 2007.

[2] A. Olive, Conceptual modeling of information systems, Springer, 2007.

[3] G. Lakoff, Women, fire and dangerous things: what categories reveal about the mind, Chicago: University of Chicago Press, 1990.