Following the short intro on RDF, this post is a short intro on RDFS and OWL.
Historically, RDFS was first. Then came OWL. They are two very different languages and deserve to be treated separately. However, OWL builds on RDFS and the core purpose of these languages is arguably present in RDFS. For the purpose here, I am thus going to discuss them together.
Let’s discuss the languages with an example.
I live in Finland and drive a Volkswagen Passat.
I am going to visit my Swedish friend.
The natural language sentences above may be translated into RDF statements as follows:
hp:me ex:livesIn dbpedia:Finland hp:me ex:drives dbpedia:Volkswagen_Passat hp:me ex:visiting hp:friend-012 hp:friend-012 ex:livesIn dbpedia:Sweden
Each of the four RDF statements (triples) consists of three RDF resources. This tells something but not much. We can add more meaning by structuring the resources. Clearly, the eight distinct resources mean different things. Some refer to people, e.g.
hp:friend-012, while some refer to countries, e.g.
dbpedia:Sweden. We also have a car model,
dbpedia:Volkswagen_Passat, and some properties, such as
RDFS and OWL support the structuring of resources into classes. This allows us to group (and differentiate) the various resources that make up RDF data. It is useful if we can name classes so that we can refer to them. Furthermore, it is useful if we can explicitly state that something is a class. In RDFS,
rdfs:Class is the class of all classes and we use
rdf:type to state that a resource is a class.
Let’s create a named class for resources that are countries.
dbpedia-owl:Country rdf:type rdfs:Class
The statement above says that the resource named
dbpedia-owl:Country is a
dbpedia-owl:Country can have instances, such as resources for Finland and Sweden. It is a DBpedia resource and I am borrowing it here. Note that the statement is RDF: it is a triple and it consists of a subject, predicate, and object.
We can do the same for another group of resources, such as people, as follows:
dbpedia-owl:Person rdf:type rdfs:Class
We have now two named classes,
dbpedia-owl:Person. However, we have so far not told how the resources in our RDF data relate to our named classes. What we like to do next is to tell that
hp:me is a person while
dbpedia:Finland is a country.
hp:me rdf:type dbpedia-owl:Person dbpedia:Finland rdf:type dbpedia-owl:Country
Done. The first statement tells that
hp:me is an instance of the named class
dbpedia-owl:Person. The second statement tells that
dbpedia:Finland is an instance of the named class
dbpedia-owl:Country. We can do the same for other resources.
hp:friend-012 rdf:type dbpedia-owl:Person dbpedia:Sweden rdf:type dbpedia-owl:Country
The class of persons and the class of countries each consists of two resource, also called individuals (in OWL). All statements are RDF statements and we can merge them as follows:
hp:me ex:livesIn dbpedia:Finland hp:me rdf:type dbpedia-owl:Person dbpedia:Finland rdf:type dbpedia-owl:Country dbpedia-owl:Person rdf:type rdfs:Class dbpedia-owl:Country rdf:type rdfs:Class hp:me ex:drives dbpedia:Volkswagen_Passat hp:me ex:visiting hp:friend-012 hp:friend-012 rdf:type dbpedia-owl:Person hp:friend-012 ex:livesIn dbpedia:Sweden dbpedia:Sweden rdf:type dbpedia-owl:Country
Another important building block of RDFS and OWL is the support for the construction of class hierarchies, i.e. the specialization of a class into one or more sub classes. DBpedia states:
dbpedia-owl:Country rdfs:subClassOf dbpedia-owl:PopulatedPlace dbpedia-owl:Continent rdfs:subClassOf dbpedia-owl:PopulatedPlace
Of primary interest here is the first statement, which tells that the named class
dbpedia-owl:Country is a sub class of the named class
dbpedia-owl:PopulatedPlace. Together, the statements above demonstrate that a class can be specialized into multiple sub classes. The statements tell that populated places can be further structured as contries or continents.
Such statements have implications for systems that implement RDFS and OWL. For instance, given the following statements
dbpedia:Finland rdf:type dbpedia-owl:Country dbpedia-owl:Country rdfs:subClassOf dbpedia-owl:PopulatedPlace
a system that implements RDFS can consider the following statement as an implicit fact
dbpedia:Finland rdf:type dbpedia-owl:PopulatedPlace
meaning that Finland is not just a country but also a populated place.
RDFS has more language constructs. For example,
rdfs:subPropertyOf, for the construction of property hierarchies, and the two properties
C and range
D are defined for properties
P. For RDF statements
t with predicate
P, the subject of
t is an instance of
C and the object of
t is an instance of
D are classes.
OWL builds on RDFS. It introduces many more language constructs and allows for the construction of more expressive ontologies. For instance, OWL supports the definition of complex class descriptions, which allows you to state, e.g., that a child is a person and has a parent that is a person. OWL is more expressive than RDFS and is also more complex. Discussing OWL in more details is beyond the scope of this post. However, some of the exercises below provide a hands-on experience with OWL.
RDFS and OWL are intended for the construction of ontologies, also called vocabularies. The RDFS constructs discussed above (e.g.
rdfs:subPropertyOf) and those of OWL (e.g.
owl:disjointWith) should indicate how such ontologies are constructed and what the result looks like.
People have written and published many RDFS and OWL ontologies. These are often very useful organizations of things relevant to a particular domain. The Semantic Sensor Network (SSN) ontology is an example of particular interest here. SSN organizes things relevant to the domain of sensing, including observations made by sensors. Observation is defined as “a Situation in which a Sensing method has been used to estimate or calculate a value of a Property of a FeatureOfInterest.” It thus provides classes for observations, properties, features of interest, etc. and properties to relate individuals of such classes, for instance to state that an observation is made by a sensor.
Ontologies are useful in various ways but one of my favorite is that they often reduce, or take away altogether, the burden of domain knowledge modelling. A whole team of experts has designed the SSN ontology. It is unlikely that I can come up with a significantly better way to model such domain knowledge. In my opinion it makes good sense to reuse existing ontologies. Sharing ontologies makes also good sense because ontologies can create a common vocabulary, between people but also between people and computer systems as well as between two or more computer systems.
In principle you can write RDFS and OWL with any text editor. Simply choose one of the RDF syntaxes, such as RDF/XML, and type away. However, in practice you want to avoid doing that. There are good editors for these languages and the most popular is arguably Protégé. Protégé is free and open source, and is available for all major platforms. Protégé can also be used on the Web.
DBpedia states that an island is a popuplated place, just like a country. Try to extend the RDF data so that it states that
dbpedia-owl:Islandis a sub class of the named class for populated place. Next, state that Iceland is a country and an island. (Hint: in RDF a resource can be an instance of multiple classes.)
We have not said anything about
dbpedia:Volkswagen_Passat. Check out its page on DBpedia and try to locate the
rdf:typeproperty. Among other classes, DBpedia states that Passat is an automobile. If you follow the link for automobile, you will notice that it is a means of transportation. Try to extend our RDF data with the corresponding RDF statements for Passat and automobile. Note that means of transportation is disjoint with the class
dbpedia-owl:Person. Assume your extended RDF data with statements for Passat and the disjointness of means of transportation (automobile) and person. Let it also state that the thing
hp:friend-100is a person and an automobile. What would an OWL reasoner tell? Is the RDF data consistent or inconsistent? (Hint: no thing can be a means of transportation and a person.)
(Advanced) Download Protégé. In the tab “Classes”, try to build a class hierarchy that includes
PopulatedPlaceas sub class of
Thing. Then specialize populated place into the classes
Island. Add also the class
Personas sub class of
Thing. Next, choose the “Object Properties” tab and add the property
livesInas sub property of
topObjectProperty. Specify the domain and range of
PopulatedPlace, respectively. Next, choose the “Individuals” tab, select the
Personclass and add the individual
me(“Members list” panel). This states that
meis an instance of
Person. Next, select the
Countryclass and add the individual
Finland. Select the class
Personagain and add the object property assertion to state that
me livesIn Finland.
(Advanced) Using the ontology created in the previous exercise, choose the “Classes” tab and add the class
Automobileas sub class of
Thing. In the “Description” panel, state that automobile is disjoint with
Person. Now, switch to the “Individuals” tab and select the
Personclass. For the individual
me, in the “Description” panel add
Automobileas a type in addition to
Person. Select “HermitT” in the “Reasoner” menu and then start the reasoner. What does Protégé tell you? Let Protégé explain you the inconsistency. Try to make sense of the explanations.