Knowledge Management: OWL Web Ontology Language
Knowledge Management: OWL Web Ontology Language
Knowledge Management: OWL Web Ontology Language
1
RDF/RDFS
• RDF: triples for making assertions about resources
• RDFS extends RDF with “schema
schema vocabulary”,
vocabulary ,
e.g.:
– Class, Property
– type, subClassOf, subPropertyOf
g , domain
– range,
2
Limitations of RDFS
• RDFS too weak to describe resources in sufficient
detail:
– No localized range
g and domain constraints
• Can’t say that the range of hasChild is person when
applied to persons and elephant when applied to
elephants
l h t
– No existence/cardinality constraints
• Can’t say that all instances of person have a mother
that is also a person, or that persons have exactly 2
parents
3
Limitations of RDFS
– No transitive, inverse or symmetrical properties
• Can’t say that isPartOf is a transitive property, that
hasPart is the inverse of isPartOf or that touches is
symmetrical
– No in/equality
• Can
Can’tt say that a class/instance is the same as some
other class/instance, can’t say that the
classes/instances are definitely disjoint/different.
– No boolean algebra
• Can’t say that that one class is the union, intersection,
etc. of other classes
4
Ontology Web Language -- OWL
DAML+OIL
OWL
• Th
Three species
i off OWL
– OWL Lite is the simplest language (+easy to implement/-less
expressive)
p )
– OWL DL (+more expressive)
– OWL Full is union of OWL syntax and RDF
• OWL allows greater expressiveness than RDF-S
5
THE STRUCTURE OF OWL
ONTOLOGIES
6
OWL: Ontology Namespaces
• Standard namespaces in an OWL ontology:
<rdf:RDF
xmlns:owl ="http://www.w3.org/2002/07/owl#"
xmlns:rdf ="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:xsd ="http://www.w3.org/2001/XMLSchema#"
p g >
7
OWL: Ontology Namespaces
• Example:
<rdf:RDF
xmlns:sm ="http://www.example.org/superMarket#"
xmlns:owl ="http://www.w3.org/2002/07/owl#"
http://www.w3.org/2002/07/owl#
xmlns:rdf ="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:xsd ="http://www.w3.org/2001/XMLSchema#"
p // g/ / >
<rdf:RDF
xmlns:sm = "&sm;"
…>
8
OWL: Ontology Headers
• Collection of assertions about the ontology grouped
under an owl:Ontology gy tag
g
<owl:Ontology rdf:about="">
<rdfs:comment>An example OWL ontology</rdfs:comment>
<owl:priorVersion
rdf:resource="http://www.example.org/old/superMarket"/>
<owl:imports
p rdf:resource="http://www.example.org/person"/>
p // p g/p /
<rdfs:label>Super Market Ontology</rdfs:label>
…
</owl:Ontology>
gy
9
BASIC ELEMENTS OF OWL
ONTOLOGIES
10
Classes: Declaration
• Every class in the OWL world is a member of the
class owl:Thingg
• Example of classes in the super Market Ontology
<owl:Class rdf:ID=“Shelf"/>
rdf:ID= Shelf />
<owl:Class rdf:ID=“Product"/>
<owl:Class rdf:ID=“Customer"/>
11
Classes: Definition
• A class definition has two parts: a name introduction
or reference and a list of restrictions.
<owl:Class rdf:ID="Customer">
<rdfs:subClassOf rdf:resource="cl:Person"/>
<rdfs:label xml:lang="en">customer</rdfs:label>
<rdfs:label xml:lang="fr">client</rdfs:label>
...
</owl:Class>
12
Individuals
• Individuals are the members of a class
<Product rdf:ID= "Apple" />
Equivalent to
<owl:Thing rdf:ID="Apple" />
<owl:Thing rdf:about="#Apple">
<rdf:type rdf:resource="#Product"/>
</owl:Thing>
13
Properties
• Two types of properties:
– Object
j p
property:
p y resource p
property
p y resource
owl:ObjectProperty
– Datatype
yp pproperty:
p y resource p property
p y literal
owl:DatatypeProperty
14
Properties Hierarchy
• Example (Wine Ontology)
<owl:Class rdf:ID="WineDescriptor"
rdf:ID= WineDescriptor />
<owl:Class rdf:ID="WineColor">
<rdfs:subClassOf
rdfs:subClassOf rdf:resource="#WineDescriptor"
rdf:resource #WineDescriptor />/
...
</owl:Class>
<owl:ObjectProperty rdf:ID="hasWineDescriptor">
<rdfs:domain rdf:resource="#Wine" />
<rdfs:range rdf:resource="#WineDescriptor" />
</owl:ObjectProperty>
<owl:ObjectProperty rdf:ID="hasColor">
<rdfs:subPropertyOf rdf:resource="#hasWineDescriptor" />
<rdfs:range rdf:resource="#WineColor" />
...
</owl:ObjectProperty>
15
Properties Characteristics (1/5)
• Transitive property
– P(x,y)
( ,y) and P(y,z)
(y, ) P(x,z)
( , )
– Wine Ontology Example:
<owl:ObjectProperty rdf:ID="locatedIn">
<rdf:type rdf:resource="&owl;TransitiveProperty" />
<rdfs:domain rdf:resource=
rdf:resource="&owl;Thing"
&owl;Thing />
<rdfs:range rdf:resource="#Region" />
</owl:ObjectProperty>
<Region rdf:ID="SantaCruzMountainsRegion">
<locatedIn rdf:resource="#CaliforniaRegion" />
</Region>
<Region rdf:ID="CaliforniaRegion">
<locatedIn rdf:resource="#USRegion" />
</Region>
/ eg o
16
Properties Characteristics (2/5)
• Symmetric property
– P(x,y)
( ,y) if and only
y if P(y,x)
(y, )
– Wine Ontology Example:
<owl:ObjectProperty rdf:ID="adjacentRegion">
<rdf:type rdf:resource="&owl;SymmetricProperty" />
<rdfs:domain rdf:resource=
rdf:resource="#Region"
#Region />
<rdfs:range rdf:resource="#Region" />
</owl:ObjectProperty>
<Region rdf:ID="MendocinoRegion">
<locatedIn rdf:resource="#CaliforniaRegion" />
<adjacentRegion rdf:resource
rdf:resource="#SonomaRegion"
#SonomaRegion />
</Region>
17
Properties Characteristics (3/5)
• Functional property
– P(x,y)
( ,y) and P(x,z)
( , ) implies
p y = z
– A functional property states that the value of range
for a certain object
j in the domain is always
y the same.
– Wine Ontology Example:
<owl:ObjectProperty
j p y rdf:ID="hasVintageYear">
g
<rdf:type rdf:resource="&owl;FunctionalProperty" />
<rdfs:domain rdf:resource="#Vintage" />
<rdfs:range rdf:resource="#VintageYear" />
</owl:ObjectProperty>
18
Properties Characteristics (4/5)
• InverseOf property
– P1(x,y)
( ,y) iff P2(y,x)
(y, )
– Wine Ontology Example:
<owl:ObjectProperty rdf:ID="hasMaker">
<rdf:type rdf:resource="&owl;FunctionalProperty" />
</owl:ObjectProperty>
<owl:ObjectProperty rdf:ID="producesWine">
<owl:inverseOf rdf:resource="#hasMaker" />
/
</owl:ObjectProperty>
19
Properties Characteristics (5/5)
• Inverse Functional property
– P(y,x)
(y, ) and P(z,x)
( , ) implies
p y = z
– A functional property states that the value of range
for a certain object
j in the domain is always
y the same.
– Wine Ontology Example:
<owl:ObjectProperty
j p y rdf:ID="producesWine">
p
<rdf:type rdf:resource="&owl;InverseFunctionalProperty" />
<owl:inverseOf rdf:resource="#hasMaker" />
</owl:ObjectProperty>
20
Exercise
• Represent the following Object Properties:
– ancestor such as If a p
person A is an ancestor of pperson
B and B of C then A is also an ancestor of C.
– akin such as if a Person A is akin to a Person B then B
is also akin to A.
– hasFather such as a child has always the same
(bi l i l) F
(biological) Father
th
– hasChild such as If a Person A hasChild a Person B then
B hasFather A
<rdf:type rdf:resource="&owl;TransitiveProperty" />
• O
OWL d
distinguishes
st gu s es bet
between
ee the
t e following
o o g two:
t o
– Value constraint
• ((Mother ≡ Woman ِ ∃hasChild.Person))
– Cardinality constraint
• (MotherWithManyChildren ≡ Mother ِ ≥3hasChild)
22
Property Restrictions: allValuesFrom
• Wine Ontology example:
<owl:Class rdf:ID="Wine">
<rdfs:subClassOf rdf:resource="&food;PotableLiquid" />
...
<rdfs:subClassOf>
<owl:Restriction>
<owl:onProperty rdf:resource="#hasMaker" />
<owl:allValuesFrom rdf:resource="#Winery" />
</owl:Restriction>
</rdfs:subClassOf>
...
</owl:Class>
– The
h makerk off a Wine must beb a Winery.
– The restriction is on the hasMaker property of
this Wine class only.
only
23
Property Restrictions: someValuesFrom
• Wine Ontology example:
<owl:Class rdf:ID="Wine">
<rdfs:subClassOf rdf:resource="&food;PotableLiquid" />
...
<rdfs:subClassOf>
<owl:Restriction>
<owl:onProperty rdf:resource="#hasMaker" />
<owl:someValuesFrom rdf:resource="#Winery" />
</owl:Restriction>
</rdfs:subClassOf>
...
</owl:Class>
– At least
l one off the
h makers
k off a Wine must be
b a Winery.
24
allValuesFrom vs. someValuesFrom
25
Property Restrictions: hasValue
• Allows to define classes based on the existence
of particular property values
• Wine Ontology example:
<owl:Class rdf:ID="Burgundy">
...
<rdfs:subClassOf>
<owl:Restriction>
l R t i ti
<owl:onProperty rdf:resource="#hasSugar" />
<owl:hasValue rdf:resource="#Dry" />
</o l Rest iction>
</owl:Restriction>
</rdfs:subClassOf>
</owl:Class>
26
Property Restrictions: cardinality
• Definition of cardinality:
– the number of occurrences, either maximum
(maxCardinality) or minimum (minCardinality) or
exact (cardinality) based upon the context (class)
in which it is used
• Wine Ontology example:
<owl:Class rdf:ID="Vintage">
<rdfs:subClassOf>
<owl:Restriction>
<owl:onProperty rdf:resource="#hasVintageYear"/>
<owl:cardinality rdf:datatype="&xsd;nonNegativeInteger">
1
</owl:cardinality>
</owl:Restriction>
</rdfs:subClassOf>
/
</owl:Class>
27
Property Restrictions: Summary
• define a class using LOCAL restrictions on a specific
Property
p y
rdfs:Class
owl:Class
28
Exercises on Property Restrictions
• A Mother is a Woman that has a child (some Person)
Mother َ Woman ِ ∃ hasChild.Person
• The set of parents that only have daughters (female
children)
ParentsWithOnlyDaughters َ Person ِ ∀hasChild.Woman
• The set of all child of the woman MARRY
MarysChildren َ Person ِ hasParent.{MARRY}
• A half Orphan (i.e. a person that has only one Parent)
HalfOrphan َ Person ِ =1hasParent.Person
1
29
COMPLEX CLASSES IN OWL
ONTOLOGIES
30
Complex Classes
• (OWL DL) provide constructors with which we can
form classes based on basic set operations:
p
– Intersection
– Union
– Complement
• Enumerated classes
• Disjoint classes
31
Complex Classes: Intersection of Classes
• Instances/Individuals of the Intersection of two
Classes are simultaneouslyy instances of both class
• Wine Ontology example:
<owl:Class rdf:ID="WhiteWine">
rdf:ID "WhiteWine">
<owl:intersectionOf rdf:parseType="Collection">
<owl:Class rdf:about="#Wine" />
<owl:Restriction>
<owl:onProperty rdf:resource="#hasColor" />
<owl:hasValue rdf:resource="#White" />
</owl:Restriction>
</owl:intersectionOf>
</owl:Class>
32
Complex Classes: Union of Classes
• Instances/Individuals of the Union of two Classes are
either the instance of one or both classes
• Wine Ontology example:
<owl:Class rdf:ID="Fruit">
rdf:ID "Fruit">
<owl:unionOf rdf:parseType="Collection">
<owl:Class rdf:about="#SweetFruit" />
<owl:Class rdf:about=
rdf:about="#NonSweetFruit"
#NonSweetFruit />
</owl:unionOf>
</owl:Class>
33
Complex Classes: Complement
<owl:Class rdf:ID="ConsumableThing" />
<owl:Class rdf:ID="NonConsumableThing">
<owl:complementOf rdf:resource="#ConsumableThing" />
</owl:Class>
• Question: What is the meaning of
<owl:Class rdf:ID="NonFrenchWine">
<owl:intersectionOf rdf:parseType="Collection">
p yp
<owl:Class rdf:about="#Wine"/>
<owl:Class>
<owl:complementOf>
<owl:Restriction>
<owl:onProperty rdf:resource="#locatedIn" />
<owl:hasValue rdf:resource="#FrenchRegion" />
</owl:Restriction>
</owl:complementOf>
</owl:Class>
</owl:intersectionOf>
/ l i t ti Of
</owl:Class>
34
Complex Classes: Enumerated Classes
• OWL provides the means to specify a class via a
direct enumeration of its members
– the owl:oneOf construct.
• Completely
Co p ete y spec
specifies
es the
t e class
c ass extension,
e te s o , and
a d no
o other
ot e
individuals can be declared to belong to the class.
• Wine Ontologygy example:
p
<owl:Class rdf:ID="WineColor">
<rdfs:subClassOf rdf:resource="#WineDescriptor"/>
p /
<owl:oneOf rdf:parseType="Collection">
<WineColor rdf:about="#White" />
<WineColor rdf:about="#Rose" />
<WineColor rdf:about="#Red" />
</owl:oneOf>
</owl:Class>
35
Complex Classes: Disjoint Classes
• The disjointness of a set of classes can be expressed
using the owl:disjointWith constructor
• An individual that is a member of one class cannot
simultaneously be an instance of another one.
• Example:
<owl:Class rdf:ID="Pasta">
<rdfs:subClassOf rdf:resource="#EdibleThing"/>
<owl:disjointWith rdf:resource="#Meat"/>
rdf:resource #Meat />
<owl:disjointWith rdf:resource="#Fowl"/>
<owl:disjointWith rdf:resource="#Seafood"/>
<owl:disjointWith
owl:disjointWith rdf:resource="#Dessert"/>
rdf:resource #Dessert /
<owl:disjointWith rdf:resource="#Fruit"/>
</owl:Class>
36
Exercises complex classes
• Person ≡ Man ّ Woman
• Man ≡ Person ِ Male
37
ONTOLOGY MAPPING AND
REUSE
38
Ontology Reuse
39
Ontology Reuse: equivalence (1/3)
• When several ontologies are used as part of another
ontology,
gy it’s useful to be able to indicate that a
particular class (or property) in one ontology is
equivalent to a class (or property) in a second
ontology.
l
– owl:equivalentClass
– owl:equivalentProperty
• Example: SuperMarket ontology linking to Wine Ontology
<rdf:RDF
xmlns:vin ="http://www.w3.org/REC-owl-guide-20040210/wine#
xmlns:owl ="http://www.w3.org/2002/07/owl#"
p // g/ / /
…>
<owl:Class rdf:ID="Wine">
<owl:equivalentClass rdf:resource=“vin:Wine"/>
</owl:Class>
40
Ontology Reuse: equivalence (2/3)
41
Ontology Reuse: equivalence (3/3)
43
Ontology Reuse: Property equivalence
44
Ontology Reuse: Identity between Individuals
<owl:Thing rdf:about="#BancroftChardonnay">
<hasMaker
h M k rdf:resource="#Bancroft"
df "#B ft" />
/
<hasMaker rdf:resource="#Beringer" />
</owl:Thing>
#Bancroft is the same as #Beringer?
45
Ontology Reuse: Different Individuals (1/2)
<WineSugar rdf:ID="Sweet">
<owl:differentFrom rdf:resource="#Dry"/>
</WineSugar>
<owl:AllDifferent>
<owl:distinctMembers rdf:parseType="Collection">
<vin:WineColor rdf:about="#Red" />
<vin:WineColor rdf:about="#White" />
<vin:WineColor rdf:about="#Rose" />
</owl:distinctMembers>
</owl:AllDifferent>
R d White,
Red, Whit and
d Rose
R are pairwise
i i di distinct
ti t
• N
Note:
t owl:distinctMembers can only l be
b used
d in
i
combination with owl:AllDifferent
47
OWL on 2 slides
• Symmetric:
S t i if P(
P(x, y)) then
th P(y,
P( x))
• Transitive: if P(x,y) and P(y,z) then P(x, z)
• Functional: if P(x,y) and P(x,z) then y y=zz
• InverseOf: if P1(x,y) then P2(y,x)
• InverseFunctional: if P(y,x) and P(z,x) then y=z
• allValuesFrom:
llV l F P(
P(x,y)) and
d y=allValuesFrom(C)
llV l F (C)
• someValuesFrom: P(x,y) and y=someValuesFrom(C)
• hasValue: P(x
P(x,y)
y) and y=hasValue(v)
• cardinality: cardinality(P) = N
• minCardinality: minCardinality(P) = N
• maxCardinality: maxCardinality(P) = N
• equivalentProperty: P1 = P2
Legend:
Properties are indicated by: P, P1, P2, etc
Specific classes are indicated by: x, y, z
Generic classes are indicated by: C, C1, C2
V l
Values are iindicated
di t d bby: v, v1,
1 v2
2
Instance documents are indicated by: I1, I2, I3
48
OWL on 2 slides
• iintersectionOf:
t ti Of C = intersectionOf(C1,
i t ti Of(C1 C2 C2, …))
• unionOf: C = unionOf(C1, C2, …)
• complementOf: C = complementOf(C1)
• oneOf: C = one of(v1, v2, …)
• equivalentClass: C1 = C2
• disjointWith: C1 != C2
• sameIndividualAs: I1 = I2
• diffe entF om I1 !!= I2
differentFrom:
• AllDifferent: I1 != I2, I1 != I3, I2 != I3, …
• Thing: I1
I1, I2,
I2 …
Legend:
Properties are indicated by: P, P1, P2, etc
Specific classes are indicated by: x, y, z
Generic classes are indicated by:y C, C1, C2
Values are indicated by: v, v1, v2
Instance documents are indicated by: I1, I2, I3
49
Exercise
Create an OWL ontology that models the following concepts:
1. There should be three classes: Customer, Shop and Product.
2. Customer and Shop should be equipped with properties name
(xsd:string) and email (xsd:string), which are equivalent to
foaf:name and foaf:mbox.
3. Each Product should have an order number (xsd:int). An order
number can be unambiguously assigned to a Product.
4 A Sh
4. Shop should
h ld hhave a property
t sells
ll (range:
( P
Product)
d t) andda
Product should have a property soldBy (range: Shop) respectively.
5. Instances of class Shop
p that sell more than 100 pproducts should
belong to a new class BigShop.
6. A Product must not be a Customer.
7 Instances
7. I t th t are b
that both,
th Shop
Sh andd Customer
C t should
h ld b
belong
l tto a
class PurchaseAndSale.
51