Giovanni Pirrotta

Just a curious person

Semantic Web Ingredients: the Web Ontology Language

July 22, 2014

In this post, after nearly six months, I continue my Semantic Web series speaking about the OWL language, acronym of Web Ontology Language, that provides a rich set of concepts for defining classes and properties.


Although RDFS represents a very useful language to model domains, it suffers the following limitations:

  • the rdfs:range property defines the range of a certain property for all classes, but in RDF Schema we cannot declare a constraint only for a single class;
  • we cannot say that two classes are disjoint, for example you cannot declare that the Male class is disjoint from the Female class;
  • we cannot define new classes using boolean operators. In fact, to create a new class, we could use the union, the intersection and the complement operators, but the RDFS does not provide tools powerful enough to express it;
  • we cannot define cardinality constraints on properties. For example, we cannot declare that a Person instance can have only one hasMother property;
  • we cannot specify particular features on properties such as transitivity, symmetry or inverse properties.

Because of these limitations, the W3C Consortium defined a new knowledge representation language called OWL that provides a well defined syntax and semantics with a sufficiently expressive mechanism to ensure automate processing using a reasoner engine. Depending on the level of expressiveness, OWL specification includes the definition of three variants:

  • The OWL Full language uses all primitives provided by the OWL Definition Language with the possibility of changing the meaning of OWL/RDF pre-defined primitives. It is either syntactically or semantically compatible with RDF, namely, each valid document in RDF is also valid in OWL Full, and each inference obtained in RDFS is a valid inference in OWL Full. Unfortunately, the OWL Full language is undecidable, so it cannot work on a reasoner engine.

  • The OWL DL is a sublanguage of OWL Full and, limiting the way to use OWL and RDF constructors, it allows to map the OWL language on a description logic, in order to gain computational efficiency. In fact, it allows the reasoning support not permitted by OWL Full, but we lose the full compatibility with RDF; an RDF document cannot be considered an OWL DL document. Vice versa, each valid OWL DL document is also a valid RDF document.

  • The OWL Lite is an OWL DL sublanguage and provides a limited set of constructors. For example, it excludes enumerated classes, the disjunction operator and some cardinality features. The OWL Lite is very simple to use but allows less expressiveness.

In the following Figure we can see the relationships between OWL dialects.


In the OWL language we can model our domain with the concept of class, that represents one of the most important aspect of the language. To do this we use the owl:Class; Also exist two pre-defined classes:

  • owl:Thing is the superclass of all classes and a default class of all individuals. Thus, every individual in OWL world is member of owl:Thing;
  • owl:Nothing is a class that has no instances and is a subclass of all classes.

Thanks to the expressiveness of the OWL language, we can define more characteristics of classes we need to design. The language provides the owl:EquivalentClass construct to declare the equivalence between two classes or the owl:disjointWith construct to define the classes that do not share any individuals.

An owl:Property is instead a binary relation defining relationships between individuals, or between individuals and data value. There are two pre-defined property classes:

  • the owl:ObjectTypeProperty resource defines the relation between instances of two classes;
  • the owl:DataTypeProperty resource defines the relation between instances of classes and literal values, such as string, date, float, etc.

Also, the OWL language provides some owl:ObjectTypeProperty subclasses specifying some interesting class characteristics.

  • The owl:TransitiveProperty construct defines a transitive property: if a relation between the class A and the class B exists, and a relation between the class B and the class C exists, the also a relation between the class A and the class C does exist.
  • The owl:SymmetricProperty construct defines a symmetric property: if a relation between the class A and the class B exists, then also a relation between the class B and the class A does exist.
  • The owl:FunctionalProperty construct defines a property with at most one value for each instance.

Also, we can set the cardinality of properties using the following OWL resources: owl:Restriction, owl:onProperty, owl:minCardinality, owl:maxCardinality, so we can create new classes using boolean operators through the owl:unionOf, owl:complementOf and owl:intersectionClass constructs. Obviously, there are many other constructs and language features provided by OWL language. For more details you can refer to the official documentation.

Let us come back to our old statement (in the previous post), and let us try to draw the relative ontology using the OWL language.

@prefix rdf: <>.
@prefix rdfs: <>.
@prefix owl: <>.
@prefix ex: <>.

ex:Person rdf:type owl:Class.
ex:name rdf:type owl:DatatypeProperty.
ex:surname rdf:type owl:DatatypeProperty.
ex:title rdf:type owl:DatatypeProperty.
ex:isbn rdf:type owl:DatatypeProperty.

ex:hasAuthor rdf:type owl:ObjectProperty.
             rdfs:domain ex:Book;
             rdfs:range ex:Person.

ex:hasUniqueAuthor rdf:type owl:ObjectProperty ;
                   rdfs:subPropertyOf ex:hasAuthor.

ex:Book rdf:type owl:Class;
         [ rdf:type owl:Restriction ;
           owl:onProperty ex:hasUniqueAuthor ;
           owl:maxCardinality "1"^^<>
         ] .

ex:umld rdf:type ex:Book;
               ex:hasUniqueAuthor ex:mfowler;
               ex:title "UML Distilled";
               ex:isbn "0201325632".

ex:mfowler rdf:type ex:Person;
            ex:name "Martin";
            ex:surname "Fowler".

As can be seen in the code, the rdfs:Class resources were replaced by the relative owl:Class constructs.

Depending on the type of object, we can identify owl:DatatypeProperty and owl:ObjectProperty property instances. In our example only ex:hasAuthor is an owl:ObjectProperty instance, whereas the remaining ones are owl:DatatypeProperty property instances.

Now let us imagine we want to specialize the ex:hasAuthor property. We want to define a particular property modeling books with a single author. To do this, we define the ex:hasUniqueAuthor property as subproperty (rdfs:subPropertyOf ) of ex:hasAuthor property. To define this constraint we must create an anonymous owl:Restriction class, specifying as properties the attributes that have to be constrained. In this case we indicate the resource ex:hasUniqueAuthor through the owl:onProperty property and we indicate the maximum number of relations the ex:hasUniqueAuthor property can join between classes, in this case only one, through the owl:maxCardinality property.

That’s all folks! Stay tuned!