For each section there will about 15 minutes to solve exercises. There is probably more work than 15 minutes allows for, but there are exercises of different degree of difficulty, so choose the level you are comfortable with.


In these exercises we will create an ontology which defines some of the vocabulary used in the world database we queried in the previous exercise.

The first exercise is some simple modelling exercises using Protégé: making classes, subclasses, setting domain and range and so on. If you already know how to do this you can skip this exercise.

1.1 Exercise

This exercise is a walk-through of how to get started with creating and editing ontologies in Protégé, showing the basic concepts.1

1.1.1 Getting started with Protégé

  1. Open Protégé and choose to "Create new OWL ontology".
  2. Set the Ontology IRI to
  3. Choose a location on your local computer to save your ontology, anywhere will do.
  4. Set the Ontology Format to RDF/XML.

1.1.2 Create classes, object properties and data properties

To create a class, select the "Classes" tab, select the class "Thing" and click the "Add subclass" button immediately above "Thing". Create new subclasses of Thing:

  • Country,
  • City and
  • Region.

Repeat the process for object properties and data properties:

Object properties:

  • isCityInCountry,
  • isCapitalOfCountry,
  • isCityInRegion and
  • isRegionInCountry.

Data properties:

  • hasPopulation,
  • hasHeadOfState and
  • hasLocalName.

1.1.3 Creating subclasses and subproperties

State that a capital of a country is always a city in the same country.

This can be done by making isCapitalOfCountry a subproperty of isCityInCountry. In Protégé it is done by selecting isCapitalOfCountry and adding isCityInCountry as a superproperty, or by dragging isCapitalOfCountry onto isCityInCountry in the Object property hierarchy frame.

The process of creating subclasses and subproperties for data properties is similar.

Create a new class "CityState", and make it a subclass of both Country and City.2

1.1.4 Set domain and range for property

Specify the correct domain and range for the object property isCityInCountry.

The domain should be City and the range should be Country.

In Protégé, select the property and add domain and range in the Description frame.

Specify also the correct domain and range for isRegionInCountry and hasHeadOfState.

1.1.5 Disjoint classes

State that a city is not a region, and vice versa.

This is done by making the two classes disjoint. Disjoint classes cannot share any members. In Protégé select one of the classes and add the other class as a disjoint class.

1.1.6 Adding more restrictions

State that a city lies in exactly one country.

Specify this by adding an anonymous superclass to City. Select City, and click to add a new superclass. In the box that appears, select the "Class expression editor" and write (remember to be sensitive to cases):

isCityInCountry exactly 1 Country

State also that a city lies in not more than one region. Tip: use max.

1.2 Exercise

Download and open the dump of the RDF world database in Protégé. Import the ontology you created in the previous exercise3. Add more axioms to the ontology:

  1. Create a new object property hasCapital state that it is the inverse of isCapitalInCountry.
  2. Set the correct domain and range for the object properties:
    • isCountryInRegion
    • isRegionInContinent
    • isCountryInContinent
  3. Set the correct domain and range for the object properties:
    • hasCityPopulation
    • hasGNP (GNP = Gross National Product)
    • hasLifeExpectancy
  4. Define the class Capital such that it contains all capitals. In the reasoner menu, select a reasoner, wait for the reasoner to calculate classifications and check if all capitals are inferred as members of the class.
  5. Define the class Metropolis such that is contains all cities with a population of more than 1.000.000. Apply reasoning and see if you have modelled correctly.
  6. State that isCountryInContinent is the property chain
    isCountryInRegion o isRegionInContinent

    Create also a object property isCityInContinent and define it as the correct property chain.

  7. Define a class DevelopingCountry as a country which has low life expectancy, e.g., 45 years, and a low GNP, e.g., 10000. Apply reasoning and see if it looks correct.
  8. Define a class DevelopedCountry to be the class of countries which are not a developing country. Again, use reasoning to check the results; are they what you expected?
  9. Set hasGNP and hasLifeExpectancy to be functional properties. Apply reasoning4, check the members of the class DevelopedCountry and explain the effects.
  10. Define AmericanCity as a city which lies on the American continent.
  11. Can you define CityState so that the country Singapore is inferred as a member of this class?

1.2.1 Solution

Solutions to all, except the last, of the modelling exercises are found in the ontology http://sws.ifi.uio.no/ont/world.owl.

It is not possible to make a good definition that would force Singapore as a member, except of course by adding Singapore explicitly. There is not enough information in the dataset to create such a definition. One could try to define a CityState as a Country with only one City, but that would not just be wrong, but it would also not force Singapore as a member because of the open world assumption.


1 An in-depth tutorial for Protégé is developed by the University of Manchester and is available online: http://owl.cs.manchester.ac.uk/tutorials/protegeowltutorial/

2 A possible member of this class could be Singapore, although in the world database the city Singapore and the country Singapore are not the same individual.

3 If you have skipped the previous exercise, you can get up to speed by downloading the ontology file http://sws.ifi.uio.no/semdays2010/downloads/world.1.owl.

4 In my experience, the reasoner FaCT++ tackled this task better than Pellet.

Author: Martin G. Skjæveland <martige@ifi.uio.no>

Date: 2010-05-31 10:58:36 CEST

HTML generated by org-mode 6.34trans in emacs 23