3. Ontologies and OWL Syntax

Definition

An ontology is a way of modelling a domain by identifying its concepts, organising them in relation to each other, identifying the properties that connect them, and designating the objects that represent them.

3.1 Introduction

1- OWL (Ontology Web Language)

OWL is the language recommended by the W3C for expressing ontologies. It is characterised by the following:

  • It uses URIs to designate all its elements.
  • It adopts a set-theoretic view of ontologies:
    • concepts are sets,
    • objects are elements of sets, and
    • properties connect these elements.
  • The set of all sets is represented by the URI owl:Thing, where owl is the prefix for: http://www.w3.org/2002/07/owl#
  • OWL classes represent sets, instances represent their elements, and properties allow links to be created between instances.

2- The set-theoretic principle of OWL

In the semantic web, an ontology defines a domain through classes, individuals, and properties. Each class can be interpreted mathematically as a set of individuals that share certain characteristics. In mathematics, the algebra of sets, defines the properties and laws of sets, the set-theoretic operations of union, intersection, and complementation and the relations of set equality and set inclusion. It also provides systematic procedures for evaluating expressions, and performing calculations, involving these operations and relations.

OWL provides constructors that map directly onto set-theoretic operations to describe relations between classes of concepts. Typical relations are :

  • Inclusion and equivalence
  • Union
  • Intersection
  • Complement
  • Difference

3.2 Instance creation and characterisation

The creation of class instances in an ontology is done as follows:

  1. An instance can be associated with a class using rdf:type.
1
2
:JulesVerne
   rdf:type :Person;
  1. An instance can be an instance of several classes, as in the following example:
1
2
3
:JulesVerne
   rdf:type :Person;
   rdf:type :Writer;
  1. Instances that have an URI are called individuals. OWL allows to characterize instances by specifying that they are also instances of the class owl:NamedIndividual.
1
2
3
4
:JulesVerne
   rdf:type :Person;
   rdf:type :Writer;
rdf:type owl:NamedIndividual.
  1. The same entity can be represented by two different individuals. For example, :Jules_Verne is represented by both:

    This can be expressed with the owl:sameAS relationship.

1
2
3
4
5
6
:JulesVerne
   rdf:type :Person;
   rdf:type :Writer;
   rdf:type owl:NamedIndividual;
   owl:sameAs wd:Q33977;
   owl:sameAs dpr:Jules_Verne.
  1. Conversely, it is possible to specify that two different URIs represent two different entities using owl:differentFrom. For example, Brest refers to two different entities in the Wikidata database:

    This can be expressed as follows:

1
2
3
4
5
:Brest
   rdf:type :City;
   rdf:type owl:NamedIndividual;
   owl:sameAs wd:Q12193;
   owl:differentFrom wd:Q140147.

3.3 Class creation and characterisation

3.3.1 Inheritance

A class B inherits from a class A if all instances of B are also instances of A (the reverse relationship is not true). We say that A is a superclass of B, and that B is a subclass of A. A class can inherit from multiple classes. From a set-theoretic point of view, inheritance is equivalent to inclusion.

The syntax for expressing inheritance is as follows: rdfs:subClassOf, for example:

:B rdfs:subClassOf :A

If a class has no superclass, the class owl:Thing must be used as the superclass, for example:

:B rdfs:subClassOf owl:Thing, which is equivalent to: :B rdf:type owl:class

There is also the class owl:noThing, which has no individuals. From a set-theoretic point of view, this is equivalent to the empty set, and therefore it is a subclass of all classes and has no subclasses. owl:Thing has no superclass.

3.3.2 Equivalence

If two classes are equivalent, then every individual in one class is also an individual in the other. This characteristic is expressed as follows:

:A owl:equivalentClass :B

This allows for what is known as ontology alignment, or ontology matching, which is the process of determining correspondences between concepts in ontologies. A set of correspondences is also called an alignment. We can express that a class A1 in an ontology O1 (O1:A1) is equivalent to a class A2 in an ontology O2 (O2:A2), for example:

The class wd:Q215627 (Person) in Wikidata is equivalent to the class Person in the Dbpedia ontology (dpo:Person) and the class Person in the foaf ontology (foaf:Person).

1
2
3
:Person    owl:equivalentClass  wd:Q215627, 
                                 dpo:Person, 
                                 foaf:Person. 

3.3.3 Union

A union of classes is declared as a new class as follows (owl:unionOf): any individual in one of the constituent classes is also an individual in this new class (the union).

Example:

1
2
:Person  rdf:type   owl:Class;
     owl:unionOf (:Man  :Woman).

3.3.4 Intersection

An intersection of classes is declared as a new class as follows (owl:intersectionOf): any individual belonging to all of the classes is also an individual in the new class (the intersection) .

Example:

1
2
:LiteraryWork  rdf:type  owl:Class;
     owl:intersectionOf (:Book  :Work). 

3.3.5. Complement

The complement of a class allows to identify all individuals that do not belong to that class (owl:complementOf).

Example :

1
2
3
# We want to express the class of all written works that are not novels.
:X  rdf:type  owl:Class
     owl:intersectionOf (:LiteraryWork [owl:complementOf  :Novel]).

3.3.6 Enumeration

Enumeration allows to create a class and its instances at the same time with owl:oneOf, without using rdf:type.

Example :

1
:Gender  owl:oneOf (:mal  :femal).  # :Gender is a class, :mal and :femal are its instances.

3.3.7 Disjunction (difference)

We can indicate that classes are disjoint or different, i.e. there is no individual that can belong to both classes at the same time. To this end, we must create an instance of the owl:AllDisjointClasses class and associate it with the list of classes that we declare as disjoint using the owl:members property.

Example :

1
2
 []  rdf:type  owl:AllDisjointClasses;
     owl:members (:Animals :Plants)  # :Animals and :Plants are disjoint

3.3.8. Property restrictions

A restriction describes a class of individuals based on the relationships that members of the class participate in. In other words a restriction is a kind of class, in the same way that a named class is a kind of class.

1- Specifying the cardinalities of a property

The following property restrictions are used to specify the minimum, maximum, or exact cardinality of the property: owl:minCardinality, owl:maxCardinality, owl:cardinality.

  • If owl:minCardinality is not used, then the value 0 is used.

  • If owl:maxCardinality is not used, then there is no cardinality limit.

Example:

1
2
3
4
5
6
:Writer
   rdfs:subClassOf  [
       rdf:type  owl:Restriction;
       owl:onProperty  :Writes;
       owl:minCardinality '1'^^xsd:nonNegativeInteger; 
   ]; # a minimum cardinality of 1 is specified for the property `writes`

2- Specifying the classe of a value property

  • owl:allValuesFrom is the restriction that allows to specify that a property only takes values from a single class.

  • owl:someValuesFrom is the restriction that allows to specify that a property takes some of its values from a certain class.

  • owl:hasValue is the restriction that allows to specify that a property has at least the specified value (it may have other values).

Example:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# We express that a writer is a person who must have written at least one book.
:Writer
   rdfs:subClassOf  :Person;
   rdfs:subClassOf  [
       rdf:type  owl:Restriction;
       owl:onProperty  :write;
       owl:minCardinality '1'^^xsd:nonNegativeInteger; 
   ];
   rdfs:subClassOf [
       rdf:type  owl:Restriction;
       owl:onProperty  :write;
       owl:allValuesFrom :Book
   ].

3.4 Property creation and characterisation

3.4.1 Creating properties

OWL distinguishes between two types of properties:

1. Object property: used when the object of the triple is an instance of a class. An object property describes a relationship between two individuals. This property is declared as an instance of the owl:ObjectProperty class. Its domain class (rdfs:domain) and range class (rdfs:range) can be specified, as in the following example:

1
2
3
4
:write
   rdf:type     owl:ObjectProperty;
   rdfs:domain  :Writer;
   rdfs:range   :Book.

2. Datatype property: used when the object of the triple is a datatype. A datatype property describes a relationship between an individual and a data value. It is an instance of the owl:DatatypeProperty class. The value types are those of XML Schema. Example :

1
2
3
4
:name 
   rdf:type     owl:DatatypeProperty;
   rdfs:domain  :Person;
   rdfs:range   xsd:normalizedString.

3.4.2 Creating subproperties

Subproperties can be created using rdfs:subPropertyOf. For example:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
:create
   rdf:type      owl:ObjectProperty;
   rdfs:domain   :Person;
   rdfs:range    [owl:unionOf(:Book :LiteraryWork)].

:write
   rdf:type            owl:ObjectProperty;
   rdfs:subProperty    :create;
   rdfs:domain         :Writer;
   rdfs:range          :Book.

3.4.3. Characterizing properties

OWL allows the meaning of object properties to be enriched through the use of property characteristics. The following discuss the various characteristics that properties may have:

1 - Inverse properties

If a property :p2 is the inverse of a property :p1 (:p1 and :p2 are linked by the property owl:inverseOf), then when the individual :i1 is linked to the individual :i2 by the property :p1, the individual :i2 is considered to be linked to :i1 by the property :p2.

Example :

1
2
3
:hasParent
   rdf:type  Owl:ObjectProperty;
   owl:inverseOf  :hasChild.

Inverse Property Inverse Property

2 - Transitive properties

If a property :p is transitive, then when an individual :i1 is linked to individual :i2 by property :p, and the same individual :i2 is linked to another individual :i3 by the same property :p, individual :i1 is also considered to be linked to :i3 by property :p.

:p must be an instance of the class owl:TransitiveProperty:

:p rdf:type owl:TransitiveProperty.

Example :

1
2
3
4
:hasAncestor
   rdf:type owl:TransitiveProperty;
   rdfs:domain  :Person;
   rdfs:range  :Person.  

Symmetric Property Symmetric Property

3 - Symmetric properties

If an individual :i1 is linked to another individual :i2 by the property :p and :p is symmetric, then we consider that :i2 is linked to :i1 by :p.

Example :

1
2
3
4
:hasSibling
   rdf:type  owl:SymmetricProperty;
   rdfs:domain  :Person;
   rdfs:range  :Person.  

Symmetric Property Symmetric Property

3 - Asymmetric properties

If an individual :i1 is linked to another individual :i2 by the property :p and :p is asymmetric, then :i2 cannot be linked to :i1 by :p under any circumstances.

Example :

1
2
3
4
:hasChild
   rdf:type  owl:AsymmetricProperty;
   rdfs:domain  :Person;
   rdfs:range  :Person.   

Asymmetric Property Asymmetric Property

4 - Functional properties

If an individual :i1 is linked to two individuals :i2 and :i3 by the property :p and :p is functional, then :i2 and :i3 represent the same individual. This property is declared as follows:

:p rdf:type Owl:FunctionalProperty.

Example :

1
2
3
4
:hasBirthMother 
   rdf:type   Owl:FunctionalProperty;
   rdfs:domain  :Person;
   rdfs:range  :Person

Functional Property Functional Property

5 - Inverse functional properties

If two individuals :i1 and :i2 are linked to another individual :i3 by property :p and :p is inverse functional, then :i1 and :i2 represent the same individual. This property is declared as follows:

:p rdf:type Owl:InverseFunctionalProperty.

Example :

1
2
3
4
:isBirthMotherOf
   rdf:type   Owl:InverseFunctionalProperty;
   rdfs:domain  :Person;
   rdfs:range  :Person

Inverse functional Property Inverse functional Property

6 - Chain of properties

Let us consider individuals :i0,:i1, ..., :in-1 and property :p, which is defined as the chain of properties :p1,:p2,...,:pn

1
2
3
4
5
6
If    :i0  :P1  :i1;
      :i1  :P2  :i2;
      . . .
      :in-1  :Pn  :in.
Then 
      :i0  :P  :in;

The property owl:propertyChainAxiom allows this chaining to be defined.

Example:

1
2
3
4
5
6
:hasBrother 
    rdfs:subProperty   :hasSibling;
    rdfs:domain   :Man.

:hasUncle
    rdfs:propertyChainAxiom   (:hasBrother :hasParent).  

7 - Disjoint properties

If two properties :p1 and :P2 are disjoint, and if the individual :i1 is linked to the individual :i2 by the property :p1, then the two individuals cannot be linked by the property :p2 under any circumstances. The owl:propertyDisjointWith property allows to declare that two properties are disjoint.

Example :

1
2
3
4
 :hasSpouse
     owl:propertyDisjointWith  :parent;   
     rdfs:domain  :Person;
     rdfs:range   :Person.

8 - Equivalent properties

As with classes, the owl:equivalentProperty property allows to specify that two properties are equivalent.

Example:

1
2
3
4
 :hasSpouse
     owl:equivalentProperty   wdt:P26;
     rdfs:domain  :Person;
     rdfs:range   :Person.