53
Ontology languages

Ontology languages and OWL

Embed Size (px)

DESCRIPTION

An introduction to the OWL ontology language and ontology editing with Protégé. Slides for the PhD Course on Semantic Web (http://elite.polito.it/).

Citation preview

Page 1: Ontology languages and OWL

Ontology languages

Page 2: Ontology languages and OWL

RDF / RDF Schema

F. Corno, L. Farinetti - Politecnico di Torino 2

Page 3: Ontology languages and OWL

RDF Schema example

F. Corno, L. Farinetti - Politecnico di Torino 3

Page 4: Ontology languages and OWL

RDFS blRDFS problemsRDFS is too “weak” to describe resources with a suitable level of details

range and domain cannot be localized (e.g. the range of hasChild is a person whenthe range of hasChild is a person when applied to a person, elephant when applied to an elephant)an elephant)no constraints on existence or cardinality (e.g. all instances of persons have one and onlyall instances of persons have one and only one mother which is a person, and have exactly two parents)

F. Corno, L. Farinetti - Politecnico di Torino 4

exactly two parents)

Page 5: Ontology languages and OWL

RDFS problemsit is not possible to define transitive, inverseor symmetrical statements (e.g. part of is a y ( g ptransitive property, hasPart is the inverse of isPartOf, touches is symmetrical), y )

Reasoning is not well supportedN t d d ti tiNon standard semantics, no native reasoner exists

F. Corno, L. Farinetti - Politecnico di Torino 5

Page 6: Ontology languages and OWL

Requirements for an ontologyRequirements for an ontology languageg g

Extend existing Web standardsExtend existing Web standardsXML, RDF, RDFS, ...

E t d t d d tEasy to understand and to usebased on well known KR languages

Formally specifiedAdeq ate e pressi e po erAdequate expressive powerAutomatic support for reasoning

F. Corno, L. Farinetti - Politecnico di Torino 6

pp g

Page 7: Ontology languages and OWL

Stack of Web languages

OWLIST EU project OntoKnowledge

W3C

DARPAOIL DAML+OIL

bioinformatics community University of

Washington

g DARPA

XOL SHOE OML RDF(S)

University of XML

yMaryland

F. Corno, L. Farinetti - Politecnico di Torino 7

Page 8: Ontology languages and OWL

O t l W b L (OWL)Ontology Web Language (OWL)4th le el on the semantic eb cake4th level on the semantic web cakeBuilt on top ofp

XMLRDF/SRDF/S

Three versionsLiteDL (maps to Description Logic)DL (maps to Description Logic)Full (not fully tractable)

S i li bl XMLF. Corno, L. Farinetti - Politecnico di Torino 8

Serializable as XML

Page 9: Ontology languages and OWL

Ontology Web Language (OWL)Ontology Web Language (OWL)

F. Corno, L. Farinetti - Politecnico di Torino 9

Page 10: Ontology languages and OWL

OWL DLOWL-DLBased on Description LogicBased on Description LogicWell defined formal semantics

well defined rules to treat sentence meaningwell defined assumptions on the world being p gmodeled

Well known reasoning/inferencing g galgorithms

tractable conclusions can be derived in finitetractable, conclusions can be derived in finite time

Widely available reasoning systemsF. Corno, L. Farinetti - Politecnico di Torino 10

Widely available reasoning systems

Page 11: Ontology languages and OWL

Building blocks in OWLBuilding blocks in OWLOntology declaration (XML syntax)Ontology declaration (XML syntax)

<rdf:RDF xmlns:owl =http://www.w3.org/2002/07/owl#" l df "h // 3 /1999/02/22 df #"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#">

Ontology metadata (information about the ontology)ontology)

<owl:Ontology rdf:about=""><rdfs:comment>An example OWL ontology</rdfs:comment>< l i V i<owl:priorVersion

rdf:resource="http://www.mydomain.org/uni-ns-old"/><owl:imports

rdf:resource="http://www.mydomain.org/persons"/>

F. Corno, L. Farinetti - Politecnico di Torino 11

p y g p<rdfs:label>University Ontology</rdfs:label>

</owl:Ontology>

Page 12: Ontology languages and OWL

ClClassesE l i d d t fEvery class is a descendant of

owl:ThinggClasses are defined using

owl:Classowl:Class<owl:Class rdf:ID="Vehicle"/>

Equivalenceowl:equivalentClassowl:equivalentClass

<owl:Class rdf:ID="Car"><owl:equivalentClass rdf:resource="#Automobile"/>

F. Corno, L. Farinetti - Politecnico di Torino 12

q</owl:Class>

Page 13: Ontology languages and OWL

Subsumption

Provided byowl:subClassOf

< l Cl df ID "2 Wh l D i "><owl:Class rdf:ID="2-Wheel-Drive"><rdfs:subClassOf rdf:resource="#Car"/>

</owl:Class>

F. Corno, L. Farinetti - Politecnico di Torino 13

Page 14: Ontology languages and OWL

Partitions

Disjoint partitionowl:disjointWith

<owl:Class rdf:about="#2-Wheel-Drive"><owl:disjointWith

rdf:resource="#4-Wheel-Drive"/></owl:Class>

F. Corno, L. Farinetti - Politecnico di Torino 14

Page 15: Ontology languages and OWL

Partitions

Exhaustive partitionowl:oneOf

<owl:Class rdf:ID="Car"><owl:oneOf rdf:parseType="Collection">

<owl:Thing rdf:about="#2-Wheel-Drive"/>g # /<owl:Thing rdf:about="#4-Wheel-Drive"/>

</owl:oneOf></owl:Class>

F. Corno, L. Farinetti - Politecnico di Torino 15

Page 16: Ontology languages and OWL

A ibAttributesKnown also as “properties”Datatype propertiesDatatype properties

Attributes that specify a class features by means of data (XSD datatype)means of data (XSD datatype)Phone, title, age

Object propertiesObject propertiesAttributes that define relationships between classes (Relations)classes (Relations)isTaughtBy(Class(course), Class(professor))

F. Corno, L. Farinetti - Politecnico di Torino 16

Page 17: Ontology languages and OWL

Datatype propertiesAllow to describe a specific aspect of a conceptconcept

Based on XSD data typesThe range specifies the data typeThe range specifies the data typeThe domain specifies the class to which the property is referredproperty is referred

<owl:DatatypeProperty rdf:ID="age">< df d i df "#P "/><rdfs:domain rdf:resource="#Person"/><rdfs:range rdf:resource="http://www.w3.org/2001/

XMLSchema#nonNegativeInteger"/></owl:DatatypeProperty>

F. Corno, L. Farinetti - Politecnico di Torino 17

</owl:DatatypeProperty>

Page 18: Ontology languages and OWL

Relationships

Directed From one concept to another, no viceversa

Defined through object propertiesDefined through object propertiesDomain: the class(es) from which the relation departsdepartsRange: the relation destination(s)

Subsumption between relationships is possible

F. Corno, L. Farinetti - Politecnico di Torino 18

possible

Page 19: Ontology languages and OWL

Relationships

Example

<owl:ObjectProperty rdf:ID="isTaughtBy"><rdfs:domain rdf:resource="#course"/><rdfs:range rdf:resource="#academicStaffMember"/><rdfs:subPropertyOf rdf:resource="#involves"/>

</owl:ObjectProperty>

F. Corno, L. Farinetti - Politecnico di Torino 19

Page 20: Ontology languages and OWL

I t (i di id l )Instances (individuals)N i ti i OWLNo unique name assumption in OWL

If two instances have a different name or ID this does not imply that they are different individualsE.g.: “Queen Elizabeth”, “The Queen” and “Elizabeth Windsor” might all refer to the gsame individual It must be explicitly stated that individuals areIt must be explicitly stated that individuals are the same as each other, or different to each other

F. Corno, L. Farinetti - Politecnico di Torino 20

other

Page 21: Ontology languages and OWL

I t (i di id l )Instances (individuals)D fi d b fDefined by means of

rdf:Description + rdf:Typep yp

<academicStaffMember rdf:ID="949352"><academicStaffMember rdf:ID= 949352 ><uni:age rdf:datatype="&xsd;integer">

39</uni:age>

</academicStaffMember><rdf:Description rdf:ID="949353">

<rdf:type rdf:resource="#academicStaffMember"/></rdf:Description></rdf:Description>

F. Corno, L. Farinetti - Politecnico di Torino 21

Page 22: Ontology languages and OWL

Ad d t tAdvanced constructsOWL supports several advanced constructs to define classes and relationshipsIntensional definition of classes

By defining constraints on attribute values (either y g (object or datatype properties)

<owl:Class rdf:about="#academicStaffMember"><rdfs:subClassOf>

<owl:Restriction><owl:onProperty rdf:resource="#teaches"/>< l V l F<owl:someValuesFrom

rdf:resource="#undergraduateCourse"/></owl:Restriction>

</rdfs:subClassOf>

F. Corno, L. Farinetti - Politecnico di Torino 22

</owl:Class>

Page 23: Ontology languages and OWL

Ad d t tAdvanced constructsCardinality

Used to fix the number of instances that can be relatedE.g.: a department should have at least 10 members

<owl:Class rdf:about="#department"><rdfs:subClassOf>

<owl:Restriction><owl:Restriction><owl:onProperty rdf:resource="#hasMember"/><owl:minCardinality

rdf:datatype="&xsd;nonNegativeInteger"> 10</owl:minCardinality>

</owl:Restriction></rdfs:subClassOf></owl:Class>

F. Corno, L. Farinetti - Politecnico di Torino 23

</owl:Class>

Page 24: Ontology languages and OWL

S i l tiSpecial propertiesowl:TransitiveProperty

defines a transitive property, such as “has better grade than”, “is taller than”, or “is ancestor of”

owl:SymmetricProperty defines a symmetric property, such as “has same grade as” or “is sibling of”

owl:FunctionalPropertydefines a property that has at most one value for each object, such as “age”, “height”, or “directSupervisor”

F. Corno, L. Farinetti - Politecnico di Torino 24

Page 25: Ontology languages and OWL

Special properties

owl:InverseFunctionalProperty defines a property for which two different objects cannot have the same valuejE.g.: the property “isTheSocialSecurityNumberFor”: a socialisTheSocialSecurityNumberFor : a social security number is assigned to one person onlyonly

F. Corno, L. Farinetti - Politecnico di Torino 25

Page 26: Ontology languages and OWL

OWL class constructors

F. Corno, L. Farinetti - Politecnico di Torino 26

Page 27: Ontology languages and OWL

OWL axioms

F. Corno, L. Farinetti - Politecnico di Torino 27

Page 28: Ontology languages and OWL

OWL h t f ?OWL: what for?To build an ontology

define classes and provide information on thempdefine properties and provide information on themthem

To express facts about a domainprovide information on instances (individuals)

To reason about ontologies and factsTo reason about ontologies and factsdiscover consequences of what is expressly stated

F. Corno, L. Farinetti - Politecnico di Torino 28

stated

Page 29: Ontology languages and OWL

Example of ontology p gybuilding in OWL

ith P té éwith Protégé

Page 30: Ontology languages and OWL

Protégé

Open source ontology editor Developed by Stanford Center for Biomedical Informatics Research at theBiomedical Informatics Research at the Stanford University School of Medicinehtt // t t f d d /http://protege.stanford.edu/

F. Corno, L. Farinetti - Politecnico di Torino 30

Page 31: Ontology languages and OWL

F. Corno, L. Farinetti - Politecnico di Torino 31

Page 32: Ontology languages and OWL

Project steps

0. Conceptual design of the ontology1. Classes definition2 Properties definition2. Properties definition3. Individuals definition4. Restrictions definition

F. Corno, L. Farinetti - Politecnico di Torino 32

Page 33: Ontology languages and OWL

Step 0

Conceptual design of the ontology

F. Corno, L. Farinetti - Politecnico di Torino 33

Page 34: Ontology languages and OWL

Accommodation

Bed&Breakfast

AccommodationAccommodationRating

OneStarRating

TwoStarRating

hasRating

BudgetAccommodation

Hotel

CampingThreeStarRating

inthasZipCode

ContactBackpackerDestinationHiking

SurfingSheraton

Luxury Hotel string

string

hasAccommodation

C

hasZipCode

hasEMail

hasStreet

DestinationBeach

Activity

Sports

YogaCaprera

Sheraton stringhasContact

isOffered

FamilyDestination

QuietDestination

Activity

Relaxation

SunbathingGallipoli

string

hasActivityhasCity

Adventure Sightseeing

MuseumsSafari

BunjeeJumping

RiminiBardonecchia

F. Corno, L. Farinetti - Politecnico di Torino 34

Page 35: Ontology languages and OWL

Step 1a

Define classes and subclassesIs-a relationship, or subsumption

F. Corno, L. Farinetti - Politecnico di Torino 35

Page 36: Ontology languages and OWL

Accommodation

AccommodationAccommodationRating

Bed&Breakfast

BudgetAccommodation

Hotel

Camping

ContactLuxury Hotel

BackpackerDestinationHiking

Surfing

Destination

ActivityBeachYoga

Sports

Activity

FamilyDestination

QuietDestination

Sunbathing

Relaxation

SafariBunjeeJumping

Museums

Adventure Sightseeing

F. Corno, L. Farinetti - Politecnico di Torino 36

Page 37: Ontology languages and OWL

OWL code<owl:Class rdf:ID="Camping">

<rdfs:subClassOf><owl:Class rdf:ID="Accommodation"/>

OWL code

<owl:Class rdf:ID Accommodation /></rdfs:subClassOf>

</owl:Class><owl:Class rdf:ID="BudgetAccommodation"><rdfs:subClassOf rdf:resource="#Accommodation"/><rdfs:subClassOf rdf:resource #Accommodation />

</owl:Class><owl:Class rdf:ID="BedAndBreakfast"><rdfs:subClassOf rdf:resource="#Accommodation"/>

</owl:Class></owl:Class><owl:Class rdf:ID="LuxuryHotel"><rdfs:subClassOf><owl:Class rdf:ID="Hotel"/>

</rdfs:subClassOf></rdfs:subClassOf></owl:Class><owl:Class rdf:about="#Hotel"><rdfs:subClassOf rdf:resource="#Accommodation"/>

</owl:Class>

F. Corno, L. Farinetti - Politecnico di Torino 37

</owl:Class>

Page 38: Ontology languages and OWL

Step 1b

Define disjoint Bed&BreakfastDisjoint

classes Accommodation

BudgetAccommodation

Hotel

Camping

Hotel

<owl:Class rdf:about="#Hotel"><owl:disjointWith rdf:resource="#Camping"/><owl:disjointWith><owl:Class rdf:about="#BedAndBreakfast"/>

</owl:disjointWith><rdfs:subClassOf rdf:resource="#Accommodation"/>

</owl:Class>

F. Corno, L. Farinetti - Politecnico di Torino 38

Page 39: Ontology languages and OWL

Step 1c Activity

Define multipleAdventure Sightseeing

inheritance MuseumsSafari

BunjeeJumping

F. Corno, L. Farinetti - Politecnico di Torino 39

Page 40: Ontology languages and OWL

Step 2aAccommodation

Range

Define object propertieshasAccommodation

relationshipshasAccommodation

Domain

Destination

<owl:ObjectProperty rdf:ID="hasAccommodation"><rdfs:domain rdf:resource="#Destination"/><rdfs:range rdf:resource="#Accommodation"/>

</owl:ObjectProperty>

F. Corno, L. Farinetti - Politecnico di Torino 40

</owl:ObjectProperty>

Page 41: Ontology languages and OWL

Step 2bDefine object properties characteristics

E g: define an inverse object propertyE.g: define an inverse object property

isOfferedDestination

Activity

hasActivity

isOffered

<owl:ObjectProperty rdf:about="#isOffered"><owl:ObjectProperty rdf:about #isOffered ><rdfs:range rdf:resource="#Destination"/><owl:inverseOf rdf:resource="#hasActivity"/><rdfs:domain rdf:resource="#Activity"/>

</owl:ObjectProperty>

F. Corno, L. Farinetti - Politecnico di Torino 41

</owl:ObjectProperty>

Page 42: Ontology languages and OWL

int

Step 2cContact

int

string

hasZipCode

hasStreet

Define datatype propertiesstringhasEMail

The range specifies thedata typeyp

<owl:DatatypeProperty rdf:ID="hasEMail"><rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#string"/><rdfs:domain rdf:resource="#Contact"/>

</owl:DatatypeProperty>/owl:DatatypeProperty<owl:DatatypeProperty rdf:ID="hasZipCode"><rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#int"/><rdfs:domain rdf:resource="#Contact"/>

</owl:DatatypeProperty>

F. Corno, L. Farinetti - Politecnico di Torino 42

</owl:DatatypeProperty>

Page 43: Ontology languages and OWL

Step 3AccommodationAccommodation

Rating

OneStarRating

Define individuals

gTwoStarRating

ThreeStarRating

instances FamilyDestination

RiminiBardonecchia

<AccommodationRating rdf:ID="OneStarRating"/><AccommodationRating rdf:ID="ThreeStarRating"/><AccommodationRating rdf:ID="TwoStarRating"/><F il D ti ti df ID "B d hi "/><FamilyDestination rdf:ID="Bardonecchia"/><FamilyDestination rdf:ID="Rimini"/>

F. Corno, L. Farinetti - Politecnico di Torino 43

Page 44: Ontology languages and OWL

Step 4

Define restrictionsTo restrict the individuals that belong to a classQuantifier restrictions (existential, universal quantifiers)quantifiers)Cardinality restrictionsh V l t i tihasValue restrictions

F. Corno, L. Farinetti - Politecnico di Torino 44

Page 45: Ontology languages and OWL

Step 4 – example 1 Accommodation

FamilyDestination is a D ti ti ith t l t

Destination

Activity

hasAccommodation >= 1

Destination with at least one accommodation and at least 2 activities

FamilyDestination

hasActivity >= 2

2 activities

Necessary andNecessary andsufficient condition

F. Corno, L. Farinetti - Politecnico di Torino 45

Cardinality restriction

Page 46: Ontology languages and OWL

St 4 l 1 FamilyDestination is aStep 4 – example 1<owl:Class rdf:ID="FamilyDestination">

FamilyDestination is a Destination with at least one accommodation and at least 2 activities<owl:Class rdf:ID= FamilyDestination >

<owl:equivalentClass><owl:Class><owl:intersectionOf rdf:parseType="Collection"><owl:Restriction>

at least 2 activities

<owl:onProperty><owl:ObjectProperty rdf:ID="hasAccommodation"/>

</owl:onProperty><owl:minCardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#int"

/ i i i>1</owl:minCardinality></owl:Restriction><owl:Restriction><owl:minCardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#int">2</owl:minCardinality>>2</owl:minCardinality><owl:onProperty><owl:ObjectProperty rdf:ID="hasActivity"/>

</owl:onProperty></owl:Restriction><owl:Class rdf:about="#Destination"/>

</owl:intersectionOf></owl:Class>

</owl:equivalentClass>/

F. Corno, L. Farinetti - Politecnico di Torino 46

</owl:Class>

Page 47: Ontology languages and OWL

Step 4 – example 2

QuietDestination is a Destination th t i t h b i

Destination

that is not chosen by noisy families

FamilyDestination

QuietDestination

Complement restriction

F. Corno, L. Farinetti - Politecnico di Torino 47

Page 48: Ontology languages and OWL

St 4 l 2Step 4 – example 2QuietDestination is a Destination that is not

<owl:Class rdf:ID="QuietDestination"><owl:equivalentClass><owl:Class>

chosen by noisy families

<owl:Class><owl:intersectionOf rdf:parseType="Collection"><owl:Class><owl:complementOf rdf:resource="#FamilyDestination"/>

</owl:Class></owl:Class><owl:Class rdf:about="#Destination"/>

</owl:intersectionOf></owl:Class>

</owl:equivalentClass></owl:equivalentClass></owl:Class>

F. Corno, L. Farinetti - Politecnico di Torino 48

Page 49: Ontology languages and OWL

St 4 l 3OneStarRating

Step 4 – example 3Bed&Breakfast

AccommodationAccommodationRating

TwoStarRating

BudgetAccommodation

Bed&Breakfast

Camping

ThreeStarRating

hasRating

BudgetAccommodation isAccommodation

Accommodation

BudgetAccommodation is an Accommodation that has either one or two star rating

Hotel

Sheraton

Luxury Hotel

gSheraton

F. Corno, L. Farinetti - Politecnico di Torino 49Existential restriction

Page 50: Ontology languages and OWL

St 4 l 3Step 4 – example 3<owl:Class rdf:ID "BudgetAccommodation">

BudgetAccommodation is an Accommodation that has either one or t t ti<owl:Class rdf:ID="BudgetAccommodation">

<owl:equivalentClass><owl:Class><owl:intersectionOf rdf:parseType="Collection"><owl:Restriction>

two star rating

<owl:Restriction><owl:onProperty><owl:ObjectProperty rdf:ID="hasRating"/>

</owl:onProperty><owl:someValuesFrom><owl:someValuesFrom><owl:Class><owl:oneOf rdf:parseType="Collection">

<AccommodationRating rdf:ID="OneStarRating"/><AccommodationRating rdf:ID="TwoStarRating"/><AccommodationRating rdf:ID= TwoStarRating />

</owl:oneOf></owl:Class>

</owl:someValuesFrom></owl:Restriction></owl:Restriction><owl:Class rdf:about="#Accommodation"/>

</owl:intersectionOf></owl:Class>

</owl:equivalentClass>

F. Corno, L. Farinetti - Politecnico di Torino 50

</owl:equivalentClass></owl:Class>

Page 51: Ontology languages and OWL

B d&B kf t

Step 4 – example 4Accommodation

Bed&BreakfastHotel

Camping

BackpackerDestination is a Destination that

BudgetAccommodation

Backpacker

hasAccommodation

provides budget accommodation and ff t

Destination

Destination

Activity

Sports hasActivity

Relaxation

offers sport or adventure activities Adventure

Sightseeing

F. Corno, L. Farinetti - Politecnico di Torino 51

Page 52: Ontology languages and OWL

Step 4 example 4 BackpackerDestination is Step 4 – example 4<owl:Class rdf:ID="BackpackerDestination">

pa Destination that provides budget accommodation and offers sport or

<owl:equivalentClass><owl:Class>

<owl:intersectionOf rdf:parseType="Collection"><owl:Restriction>

<owl:onProperty>

adventure activities

<owl:onProperty><owl:ObjectProperty rdf:ID="hasAccommodation"/>

</owl:onProperty><owl:someValuesFrom rdf:resource="#BudgetAccommodation"/>

</owl:Restriction>< l Cl df b t "#D ti ti "/><owl:Class rdf:about="#Destination"/><owl:Restriction>

<owl:onProperty><owl:ObjectProperty rdf:ID="hasActivity"/>

</owl:onProperty><owl:someValuesFrom>

<owl:Class><owl:unionOf rdf:parseType="Collection">

<owl:Class rdf:about="#Sports"/><owl:Class rdf:about="#Adventure"/><owl:Class rdf:about #Adventure />

</owl:unionOf></owl:Class>

</owl:someValuesFrom></owl:Restriction>

</owl:intersectionOf>

F. Corno, L. Farinetti - Politecnico di Torino 52

</owl:intersectionOf></owl:Class>

</owl:equivalentClass></owl:Class>

Page 53: Ontology languages and OWL

LicenseLicenseThis work is licensed under the Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.To view a copy of this license visitTo view a copy of this license, visit http://creativecommons.org/licenses/by-

/3 0/ Cnc-sa/3.0/ or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA.

F. Corno, L. Farinetti - Politecnico di Torino 53