Sie sind auf Seite 1von 69

A PRACTICAL INTRODUCTION TO 

ONTOLOGIES & OWL

Session 1: Primitive Classes in OWL
By Amna Basharat Haider

Adapted by Tutorial by Nick Drummond & Matthew Horridge @ Manchester University
Overview

ƒ Pizzas – Card Sorting
ƒ Protégé Introduction
ƒ Subsumption
ƒ Creating a Class Hierarchy
ƒ Consistency
y
ƒ Disjointness
ƒ Relationships & Properties
ƒ Restrictions
ƒ Polyhierarchies ‐
P l hi hi   Issues
I
FAST – NU, Islamabad, Fall 2008
Our Domain
ƒ Pizzas have been used in Manchester tutorials 
y
for years.
ƒ Pizzas were selected as a domain for several 
reasons:
à They are fun
Th    f
à They are internationally known
à They are highly compositional
à They have a natural limit to their scope
à They are fairly neutral
‚ Although arguments still break out over representation
t oug a gu e ts st b ea out o e ep ese tat o
‚ Even pizzas can do this ‐ its an inevitable part of 
knowledge modelling
‚ ARGUING IS NOT BAD!

FAST – NU, Islamabad, Fall 2008


You are the Expert

ƒ Most often it is not the domain expert that 
formalises their knowledge – because of the 
complexity of the modelling it is normally a 
specialist “knowledge engineer”
p g g
Hopefully, as tools get easier to use, this will change

ƒ Having access to experts is critical for most 
domains

ƒ Luckily, we are all experts in Pizzas, so we 
j
just need some material to verify our 
y
knowledge…
FAST – NU, Islamabad, Fall 2008
Reference Materials

ƒ Having references to validate decisions, and 
act as provenance can be useful for 
t       b   f l f  
maintaining an ontology

ƒ Mistakes, omissions and intentions can be 
more easily traced if a reference can be made
  il   d if    f    b   d
à When building, we highly recommend documenting your model as you go –
keeping provenance information is a good way of doing this

ƒ We have provided you with a pizza menu and 
several cards with ingredients on
FAST – NU, Islamabad, Fall 2008
Our Ontology
ƒ When building an ontology we need an application in mind –
ontologies should not be built for the sake of it

ƒ Keep the application in mind when creating concepts – this should 
help you scope the project

ƒ The PizzaFinder application has been developed so that you can 
plug your ontology in at the end of the day and see it in action
l     t l  i   t th   d  f th  d   d   it i   ti

Let us know your ideas for extending the application

FAST – NU, Islamabad, Fall 2008


Our Application

www.co-ode.org/downloads/pizzafinder/
FAST – NU, Islamabad, Fall 2008
EXERCISE 1: CARD SORTING
Card Sorting ‐ Issues
ƒ different viewpoints
à Tomato – Vegetable or Fruit?
à culinary vs biological
ƒ Ambiguity
à words not concepts
ƒ Missing Knowledge
à What is peperonata?
ƒ multiple classifications (2+ parents)
ƒ lots of missing categories (superclasses?)
ƒ competency questions
à What are we likely to want to “ask” our ontology?
Wh      lik l        “ k”    l ?
à bear the application in mind

FAST – NU, Islamabad, Fall 2008


OWL Constructs

Person Country
Elvis Belgium
Holger
Paraguay
Kylie
Class (concept)
Latvia
S.Claus China
Hai
Individual (instance)

Flipper arrow = relationship


label = Property
Animal
Rudolph

FAST – NU, Islamabad, Fall 2008


OWL Constructs: Classes
Eg Mammal, Tree, Person, Building, Fluid, Company
ƒ Classes are sets of Individuals
ƒ aka “Type”, “Concept”, “Category”
ƒ Membership of a Class is dependent on its logical description, not its name
ƒ Classes do not have to be named – they can be logical expressions –
Classes do not have to be named  they can be logical expressions  eg 
things that have colour Blue
ƒ A Class should be described such that it is possible for it to contain 
Individuals (unless the intention is to represent the empty class)
ƒ Classes that cannot possibly contain any Individuals are said to be 
inconsistent

FAST – NU, Islamabad, Fall 2008


OWL Constructs: Properties
Eg hasPart, isInhabitedBy, isNextTo, occursBefore
ƒ p
Properties are used to relate Individuals
ƒ We often say that Individuals are related along a given property
ƒ Relationships in OWL are binary:
Subject Æ predicate Æ Object
Individual a Æ hasProperty Æ Individual b
nick_drummond Æ givesTutorial Æ Manchester_ProtegeOWL_tutorial_29_June_2005

ƒ N‐ary relationships can be modelled with workarounds in OWL, but this 
design pattern will not be discussed today

FAST – NU, Islamabad, Fall 2008


OWL Constructs: Individuals
Eg me, you, this tutorial, this room
ƒ j
Individuals are the objects in the domain
ƒ aka “Instance”, “Object”
ƒ Individuals may be (and are likely to be) a member of multiple Classes

FAST – NU, Islamabad, Fall 2008



ƒ Is a knowledge modelling environment
ƒ Is free, open source software
ƒ Is developed by Stanford Medical 
Informatics
ƒ Has a large user community (approx 30k)

FAST – NU, Islamabad, Fall 2008



ƒ core is based on Frames (object oriented) 
modelling
d lli
ƒ has an open architecture that allows other 
modelling languages to be built on top
d lli  l  t  b  b ilt   t
ƒ supports development of plugins to allow 
b k d / i
backend / interface extensions
f   i
ƒ now supports OWL through the Protégé‐
OWL plugin
So let’s
let s have a look
look…

FAST – NU, Islamabad, Fall 2008


Protégé‐OWL

FAST – NU, Islamabad, Fall 2008


Class Hierarchy

Subsumption hierarchy
Structure as asserted by the ontology engineer

owl:Thing is the root class
FAST – NU, Islamabad, Fall 2008
Subsumption
ƒ Superclass/subclass relationship, “isa”
ƒ All members of a subclass can be inferred to be members of its 
superclasses
owl:Thing: superclass of all OWL Classes
A
• A subsumes B
B • A is a superclass of B
• B is a subclass of A
• All members of B are also 
members of A

FAST – NU, Islamabad, Fall 2008


Class Editor
Class annotations (for class metadata)
Class name and documentation

Properties 
“available” to 
Class

Disjoints 
widget

Conditions Widget
Class‐specific tools (find usage etc)

FAST – NU, Islamabad, Fall 2008


EXERCISE 2: CREATE CLASS HIERARCHY
Exercise 2: Create Class Hierarchy

ƒ You will notice that we use naming 
conventions for our ontology entities

ƒ Typically, we use CamelNotation
Typically  we use CamelNotation with a 
starting capital for Classes

ƒ Use whatever conventions you like

ƒ It is helpful to be consistent – especially 
when trying to find things in your ontology

FAST – NU, Islamabad, Fall 2008


Saving OWL Files

OWL = easy to make mistakes = save regularly


1. Select File Æ Save Project As
A dialog (as shown) will pop up

2. Select a file directly by clicking the button on the top right


You will notice that 2 files are created
.pprj – the project file
this just stores information about the GUI
and the workspace
.owl – the OWL file
this is where
here your
o r ontolog
ontology is stored in
RDF/OWL format

3 Select OK
3.

FAST – NU, Islamabad, Fall 2008


Loading OWL files

1. If you only have an OWL


file:
- FileÆ New Project
- Select OWL Files as the type
- Tick Create from existing sources
- Next to select the .owl file

2. If you’ve got a valid project file*:


- File Æ Open Project
- select the .pprj file

* ie one created on this version of Protégé - the s/w gets updated once every few
days, so don’t count on it unless you’ve created it recently– safest to build from
the .owl file if in doubt

FAST – NU, Islamabad, Fall 2008


Consistency Checking

ƒ We’ve just created a class that doesn’t really make sense 
à What is a MeatyVegetableTopping?

ƒ We’d like to be able to check the logical consistency of our 
model

ƒ This is one of the tasks that can be done automatically by 
software known as a Reasoner

ƒ Being able to use a reasoner is one of the main advantages of 
using a logic‐based formalism such as OWL (and why we are 
g
using OWL‐DL)

FAST – NU, Islamabad, Fall 2008


REASONERS AND INFERENCE
Reasoners & Inference
?
? ?

!
! !
Reasoner: A clever (probably magic) black box designed by clever people
Best to let them worry about how they work
FAST – NU, Islamabad, Fall 2008
Reasoners: Inference infer: Conclude

ƒ Reasoners are used to infer information that is 
not explicitly contained within the ontology

ƒ You may also hear them being referred to as 
Classifiers

ƒ Standard reasoner services are:
à Consistency Checking
à Subsumption Checking (Automatic Subsumption)
b i h ki i b i
à Equivalence Checking
à Instantiation Checking

FAST – NU, Islamabad, Fall 2008


Automatic Classification
Trivial example

DangerousAnimal (defined class)
Animal and
hasMouthPart some Teeth Teeth
Fangs

Shark (primitive class)
Animal and
hasMouthPart some Fangs

FAST – NU, Islamabad, Fall 2008


Consistency Checking

Shark (p
(primitive class))
Animal and
eats some (Person and Seal)
Inconsistent = cannot contain any individuals

Person Seal Disjoint (Person, Seal)


Person and Seal = empty
Cannot have some empty

FAST – NU, Islamabad, Fall 2008


When to use a Reasoner
ƒ Modelling /Compile Time Reasoning
à We often use one during development as an ontology 
g p gy
compiler. 

à A well designed ontology can be compiled to check its 
e des g ed o to ogy ca be co p ed to c ec ts
meaning is that intended

ƒ Publish Time
à Or at publish time – so many inferences are already made 
for the user apps

ƒ Runtime Reasoning
à Or at runtime in applications as a querying mechanism 
(
(esp. useful for smaller ontologies)
  f l f   ll   t l i )

FAST – NU, Islamabad, Fall 2008


Reasoners and the tools
ƒ Many of the editing tools and APIs support the use of 
reasoners implementing the DIG (Description Logics 
Implementation Group) interface
I l t ti  G ) i t f

ƒ This means that the reasoner you choose is independent 
of the application using it,
f h li i i i
à so you can choose the implementation you want depending on 
your needs (eg some may be more optimised for speed/memory, 
others may have more features)

ƒ These reasoners typically set up a service running locally 
or on a remote server

ƒ Protégé‐OWL, for example can connect to reasoners over 
an http:// connection

FAST – NU, Islamabad, Fall 2008


Reasoners and Protégé
ƒ Protégé‐OWL supports the use of reasoners 
p g
implementing the DIG interface

ƒ This means that the reasoner you choose is 
independent of the ontology editor, so you can 
independent of the ontology editor  so you can 
choose the implementation you want depending on 
your needs (eg some may be more optimised for 
speed/memory  others may have more features)
speed/memory, others may have more features)

ƒ These reasoners typically set up a service running 
llocally or on a remote server –
ll             Protégé‐OWL can 
P é é OWL   
only connect to reasoners over an http:// 
connection

FAST – NU, Islamabad, Fall 2008


Accessing the Reasoner

Classify taxonomy
(and check consistency)

Compute inferred types


(for individuals)

Just check consistency
(for efficiency)

FAST – NU, Islamabad, Fall 2008


Reasoning about our Pizzas
ƒ When we classify an ontology we could just use the “Check 
Consistency” button but we’ll get into the habit of doing a full 
classification as we ll be doing this later
classification as we’ll be doing this later

ƒ The reasoner dialog will pop up while the
reasoner works

ƒ When the reasoner has finished, you will see an inferred 
hierarchy appear, which will show any movement of classes in 
the hierarchy

ƒ If the reasoner has inferred anything about our model, this is 
reported in the reasoner dialog and in a separate results window
t d i  th    di l   d i     t   lt   i d

ƒ inconsistent classes turn red
ƒ moved classes turn blue

FAST – NU, Islamabad, Fall 2008


Disjointness

ƒ OWL assumes that 
classes overlap
l   l
MeatTopping
pp g VegetableTopping

= individual
 i di id l

► This means an individual could be both a MeatTopping and a 
VegetableTopping at the same time
► We want to state this is not the case

FAST – NU, Islamabad, Fall 2008


Disjointness

ƒ If we state that classes are disjoint

MeatTopping
pp g VegetableTopping

= individual
i di id l

► This means an individual cannot be both a MeatTopping and a 
VegetableTopping at the same time
► We must do this explicitly in the interface

FAST – NU, Islamabad, Fall 2008


ClassesTab: Disjoints Widget

Add siblings as disjoint


Add new disjoint Remove
disjoint siblings

List of disjoint classes

FAST – NU, Islamabad, Fall 2008


Save Your Work

OWL = easy to make mistakes – save regularly


1. Select File Æ Save
A dialog (as shown) will pop up
2. Select a file using a file selector by clicking the button on the top right

You will notice that there are 2 files created


.pprj
pp j – the p
project
j file
this just stores information about the GUI
and the workspace
.owl – the OWL file
this iis where
thi h your ontology
t l iis stored
t d iin
RDF/OWL format

3 Select
3. S l t OK

38 CS646: N. Drummond, M. Horridge 29/11/2004


FAST – NU, Islamabad, Fall 2008
EXERCISE 3: ADD DISJOINTS

Run a reasoner locally on your machine

f
Your reasoner may be found at…
Why is MeatyVegetableTopping Inconsistent?

ƒ We have asserted that a MeatyVegetableTopping is a subclass 
j
of two classes we have stated are disjoint

ƒ The disjoint means nothing can be a MeatTopping and a 
VegetableTopping at the same time
ƒ This means that MeatyVegetableTopping can never contain 
any individuals

ƒ The class is therefore inconsistent
h l i h f i i
ƒ This is what we expect!

ƒ It can be useful to create classes we expect to be inconsistent 
to “test” your model – often we refer to these classes as 
“probes” – generally it is a good idea to document them as such 
to avoid later confusion

FAST – NU, Islamabad, Fall 2008


Other Inconsistencies?
ƒ Your ontology is likely to have several classes with multiple parents
ƒ We call this a tangle
g
ƒ As we have seen, a class cannot have 2 disjoint parents – it will be 
inconsistent
ƒ To remove other inconsistencies you will have to be careful about 
y
where your disjoints are – remove disjoints between multiple 
parents by hand

ƒ This is obviously an awkward thing to manage – we will later show 
you how to manage your tangle to simplify these issues

FAST – NU, Islamabad, Fall 2008


What have we got?

ƒ We’ve created a tangled graph (not a tree – multiple 


parents) of mostly disjoint classes

ƒ Disjoints are inherited
j down the subsumption hierarchy
p y
eg something that is a TomatoTopping cannot be a Pizza because 
its superclass, PizzaTopping, is disjoint from Pizza

ƒ You should now be able to select every class and see its 
siblings in the disjoints widget (if it has any)

FAST – NU, Islamabad, Fall 2008


What are we missing?
ƒ This is not a semantically rich model
ƒ Apart from  is kind of  (subsumption) and 
Apart from “is kind of” (subsumption) is not kind of  
and “is not kind of” 
(disjoint), we currently don’t have any other information of interest
ƒ We want to say more about Pizza Individuals, such as their 
relationship with other Individuals

Pizza PizzaTopping

= individual

FAST – NU, Islamabad, Fall 2008


RELATIONSHIPS IN OWL
Relationships in OWL

ƒ In OWL‐DL, relationships can only be formed 
between Individuals or between an 
Individual and a data value.
(In OWL‐Full, Classes can be related, but this cannot be reasoned with) 

ƒ Relationships are formed along Properties

ƒ We can restrict how these Properties are 
used:
à Globally – by stating things about the Property 
itself
à Or locally – by restricting their use for a given 
Class

FAST – NU, Islamabad, Fall 2008


OWL Properties

ƒ Object Property – relates Individuals
ƒ Datatype Property – relates Individuals to 
data (int, string, float etc)
ƒ Annotation Property – for attaching 
metadata to classes, individuals or 
properties
i

FAST – NU, Islamabad, Fall 2008


Properties Tab: Property Browser
Note that Properties can be in a 
hierarchy, although we are not going to 
be using this feature today
b   i   hi  f   d

FAST – NU, Islamabad, Fall 2008


Creating Properties

Delete Property

New Object Property:
Associates an individual to another individual

not used today:
‐ New Datatype Property (String, int etc)
‐ New Annotation Properties for metadata

‐ New SubProperty – ie create “under” the 
current selection

FAST – NU, Islamabad, Fall 2008


Creating Properties
ƒ We tend to name properties using camelNotation with a 
lowercase letter to begin

ƒ We often create properties using 2 standard naming 
patterns:
à has… (eg
h  ( hasColour)
h C l )
à is…Of (eg isTeacherOf) or other suffixes (eg …In …To)

ƒ This has several advantages:
à It is easier to find properties
à It is easier for tools to generate a more readable form
(see tooltips on the classes in the hierarchy later)
à Inverses properties typically follow this pattern
eg hasPart, isPartOf

ƒ Our example hasBase fits into this
(we will not create the inverse in this tutorial)

FAST – NU, Islamabad, Fall 2008


Property Characteristics
à Inverses – if property p has inverse property q, and p relates A‐B, then 
it can be inferred q relates B‐A

à Functional – if property p relates A‐B then all relations along p relate A‐
B (m..1 relation)
(B could also be a datatype value)

à I
Inverse Functional
 F ti l – the inverse of the property is functional
th  i   f th   t  i  f ti l

à Symmetric – if a property relates A‐B then it also relates B‐A

à AntiSymmetric

à Transitive – if a property relates A‐B and B‐C then it relates A‐C

à Reflexive

à Irreflexive

FAST – NU, Islamabad, Fall 2008


Functional Property
ƒ If Peggy and Margaret are not stated Different
à Inferred same ggy
Peggy
ƒ Else 
à Inconsistency

Implies the same


Individual

Jean

FAST – NU, Islamabad, Fall 2008 Margaret


Inverse Property

hasChild

Jean Mathew

hasParent

FAST – NU, Islamabad, Fall 2008


Inverse Functional Property
Peggy ƒ If Peggy and Margaret are not stated Different
à Inferred same
ƒ Else 
à Inconsistency

Jean
Implies the
same
Individual

Margaret

FAST – NU, Islamabad, Fall 2008


Transitive Property

Peggy

Jean

Margaret

FAST – NU, Islamabad, Fall 2008


Symmetric Properties

hasSibling

Jean Mathew

hasSibling

FAST – NU, Islamabad, Fall 2008


AntiSymmetric Properties

isChildOf

isChildOf

Jean Mathew
David

isChildOf
X

FAST – NU, Islamabad, Fall 2008


Reflexive Property

knows

Jean Micheal

knows

FAST – NU, Islamabad, Fall 2008


IrReflexive Property

isMotherOf

Alice Bob
X
isMotherOf

FAST – NU, Islamabad, Fall 2008


Functional Properties
ƒ An individual can only have relationships with at most one other 
individual along a functional property
eg Setting hasBase to Functional means:
“Every Pizza can have at most one PizzaBase”
D
Description of DoubleBasePizza:
i ti   f D bl B Pi

ƒ The reasoner finds this inconsistent
ƒ It looks like the interface is warning us that we can’t use the 
g
property more than once, but actually…

FAST – NU, Islamabad, Fall 2008


PROPERTIES AND RESTRICTIONS
Associating Properties with Classes

ƒ We now have a property we want to use to describe Pizza 
individuals

ƒ To do this, we must go back to the Pizza class and add some 
further information
ƒ This comes in the form of Restrictions
ƒ We create Restrictions using the Conditions widget

ƒ Conditions can be any kind of Class – you have already added Named 
superclasses in the Conditions Widget. Restrictions are a type of 
Anonymous Class

FAST – NU, Islamabad, Fall 2008


Conditions Widget

Conditions asserted by the ontology engineer
Add different types of condition

Definition 
of the class
(
(later)
)

Description
of the class
Conditions inherited from superclasses

FAST – NU, Islamabad, Fall 2008


Conditions Types
Logical (Anonymous) Classes

Create Restriction (next)
Create Class Expression Add Named Superclass

FAST – NU, Islamabad, Fall 2008


Creating Restrictions
Restricted Property

Restriction
Type

Filler
Expression

Expression
Syntax
Construct
check
Palette

FAST – NU, Islamabad, Fall 2008


What does this mean?

ƒ We have created a restriction: ∃ hasBase PizzaBase
on Class Pizza as a necessary condition

Pizza PizzaBase

► “If an individual is a member of this class, it is necessary that it has 
If an individual is a member of this class, it is necessary that it has 
at least one hasBase relationship with an individual from the class 
PizzaBase”
► “Every individual of the Pizza class must have at least one base 
Every individual of the Pizza class must have at least one base 
from the class PizzaBase”

FAST – NU, Islamabad, Fall 2008


What does this mean?

ƒ We have created a restriction: ∃ hasBase PizzaBase
on Class Pizza as a necessary condition

Pizza PizzaBase

► “There can be no individual, that is a member of this class, that 
There can be no individual, that is a member of this class, that 
does not have at least one hasBase relationship with an individual 
from the class PizzaBase”

FAST – NU, Islamabad, Fall 2008


Why?

ƒ We have created a restriction: ∃ hasBase PizzaBase


on Class Pizza as a necessary condition

PizzaBase
∃ hasBase
PizzaBase

► Each Restriction or Class Expression describes the set of all


individuals that satisfy the condition

FAST – NU, Islamabad, Fall 2008


Why? Necessary conditions

ƒ We have created a restriction: ∃ hasBase PizzaBase
on Class Pizza as a necessary condition

Pizza PizzaBase
∃ hasBase
PizzaBase

► Each necessary condition on a class is a superclass of that class


► ie The restriction ∃ hasBase PizzaBase is a superclass of Pizza
► As Pizza is a subclass of the restriction,
restriction all Pizzas must satisfy
the restriction that they have at least one base from PizzaBase

FAST – NU, Islamabad, Fall 2008


EXERCISE 4: PROPERTIES & 
RESTRICTIONS

Das könnte Ihnen auch gefallen