2

schoolmistInternet and Web Development

Oct 22, 2013 (3 years and 7 months ago)

76 views

ENSM
-
SE

Aspects Avancés du Web

Practical session II

Juri Luca De Coi

Saint
-
Etienne, France, 19
-
11
-
2010

ENSM
-
SE

Outline

The second step toward a Semantic Web

Inferring implicit knowledge

Reasoner
-
oriented languages: RDF Schema and the OWL
2 Web Ontology Language (OWL 2)

Make use of the Semantic Web (II)

An overview of inference problems

A tableau algorithm for the consistency problem

Practical exercises

Create an OWL ontology

Query the OWL ontology

2

ENSM
-
SE

Outline

The second step toward a Semantic Web

Inferring implicit knowledge

Reasoner
-
oriented languages: RDF Schema and the
OWL 2 Web Ontology Language (OWL 2)

Make use of the Semantic Web (II)

An overview of inference problems

A tableau algorithm for the consistency problem

Practical exercises

Create an OWL ontology

Query the OWL ontology

3

ENSM
-
SE

Only seemingly unrelated…

Turing machine

“Everything computable can be computed by some
Turing machine” (Church
-
Turing thesis)

Drawback: Every (computable) problem requires a
different Turing machine

Universal Turing machine (U)

The description of a Turing machine is provided as input
to U



Every Turing machine can be simulated by U



Everything computable can be computed by U

4

ENSM
-
SE

Use case 1

Assume this knowledge base is given

The Java class
java.util.ArrayList

directly extends
the Java class
java.util.AbstractList

The Java class
java.util.ArrayList

directly extends
the Java class
java.util.AbstractCollection

What can you say about it?


We want to build a machine (
reasoner
) able to infer
such implicit knowledge

Build knowledge about Java into the reasoner

5

ENSM
-
SE

Use case 2

Assume this knowledge base is given

Alice is Bob’s mother

Charles is Alice’s brother

Is there any relationship between Bob and Charles?


We want to build a machine (
reasoner
) able to infer
such implicit knowledge

Build knowledge about family relationships into the
reasoner

6

ENSM
-
SE

Use case 1 vs Use case 2

Drawback

We need different reasoners for the two Use Cases

Solution

Create a universal reasoner (U)

Provide the description of a reasoner as input to U

How to describe reasoners(’ built
-
in knowledge)?

Which kind of language?

Which expressivity?

7

ENSM
-
SE

Use
case 1 revisited

8

Explicit
knowledge


The
Java class
java.util.ArrayList

directly extends
the Java class
java.util.AbstractList


The
Java class
java.util.ArrayList

directly extends
the Java class
java.util.AbstractCollection

Built
-
in
knowled
ge


Java
classes can directly extend at most one Java
class


Implicit

knowled
ge


The knowledge base is inconsistent


What do we need to describe the built
-
in knowledge?

Individuals

Relationships
between
individuals

Constraints on
relationships

Sets of
individuals

Ontologies

ENSM
-
SE

Use case 2 revisited

9

Explicit
knowle
dge



Alice is Bob’s mother



Charles is Alice’s brother

Built
-
in
knowledge

If

someone X is someone Y’s mother
and

someone Z

is X’s brother

then

Z is X’s uncle

Implicit

knowled
ge


Charles is Bob‘s uncle


What do we need to describe the built
-
in knowledge?

Rules

ENSM
-
SE

Reasoner
-
oriented language

Research on languages with such an expressiveness
is still ongoing

Two concurrent and partially overlapping
approaches available to date

Ontology languages (this lecture)

Rule languages (next lecture)

10

ENSM
-
SE

RDF Schema


RDSF (I)

A (limited) ontology language (and something
more) built on top of RDF

Allows to express

individuals

sets of individuals (
classes
)

relationships between individuals (
properties
)

Provides two built
-
in classes

The set of all RDF resources
rdfs:Resource

The set of all RDF literals
rdfs:Literal

11

Recall that in RDF
you also have literals
(beside entities)

ENSM
-
SE

RDSF (II)

Allows to state that

a given class C1 is a subclass of a given class C2

SubClassOf(C1 C2)

a given property P1 is a subproperty of a given property P2

SubPropertyOf(P1 P2)

a given property has a given domain/range

PropertyDomain(P C)

vs
PropertyRange(P C)

a given individual belongs to a given class

ClassAssertion(CE a)

two given individuals are connected through a given
property

ObjectPropertyAssertion(P a1 a2)

12

ENSM
-
SE

RDSF (III)

Does not allow to

combine classes/properties to form more complex
ones

set restrictions on properties

assert negative information

Disjointness of classes/properties

Inequality of individuals

Negative properties of individuals

13

ENSM
-
SE

OWL 2 (I)

An expressive ontology language for the Semantic
Web built on top of RDF

Supports all features of RDSF and many more

Enforces a strict separation between

classes

(composed of individuals) and
datatypes

(composed of literals)

object properties

(connecting individuals to individuals)
and
data properties

(connecting individuals to literals)

Allows to combine classes/properties in a number
of ways to form more complex ones

14

ENSM
-
SE

OWL 2 Class expressions

Individuals belonging to some class expression
CEi

ObjectUnionOf(CE1… CEn)

Individuals not belonging to the class expression
CE

ObjectComplementOf(CE)

Individuals connected by
OPE
/
DPE1… DPEn

to some instance of
CE
/
DR

ObjectSomeValuesFrom(OPE CE)

DataSomeValuesFrom(DPE1… DPEn DR)

Individuals connected by
OPE
/
DPE1… DPEn

only to instances of
CE
/
DR

ObjectAllValuesFrom(OPE CE)

DataAllValuesFrom(DPE1… DPEn DR)

Individuals connected by
OPE

to themselves

ObjectHasSelf(OPE)

Individuals connected by
OPE
/
DPE

to at most
n

different instances of
CE
/
DR

ObjectMaxCardinality(n OPE CE)

DataMaxCardinality(n DPE DR)

15

ENSM
-
SE

OWL 2 (II)

OWL 2 Property expressions

Connects
I1

with
I2

if and only if

OPE

connects
I2

with
I1

ObjectInverseOf(OPE)

Connects
I1

with
I2

if and only if
I1

is connected with
I2

by the sequence
OPE1

OPEn

ObjectPropertyChain(OPE1… OPEn)

OWL 2 built
-
in classes

The set of all individuals
owl:Thing

The set of all literals (?)
rdfs:Literal

The empty set
owl:Nothing

16

ENSM
-
SE

OWL 2 Axioms (I)

The class expression CE1 is a subclass of the class expression CE2

SubClassOf(CE1 CE2)

The property expression OPE1/DPE1 is a subproperty of the property
expression OPE2/DPE2

SubObjectPropertyOf(OPE1 OPE2)

SubDataPropertyOf(DPE1 DPE2)

All of the property expressions OPEi/DPEi are pairwise disjoint

DisjointObjectProperties(OPE1… OPEn)

DisjointDataProperties(DPE1… DPEn)

The object property expression OPE is asymmetric

AsymmetricObjectProperty(OPE)

The datatype DT is semantically equivalent to the (unary) data range DR

DatatypeDefinition(DT DR)

17

ENSM
-
SE

OWL 2 Axioms (I)

Each (named) instance of the class expression
CE

is uniquely identified
by the property expressions
OPEi
/
DPEj

HasKey(CE (OPE1… OPEm) (DPE1… DPEn))

All of the individuals
ai

are equal to (resp. different from) each other

SameIndividual(a1… an)

DifferentIndividuals(a1… an)

The individual
a

is an instance of the class expression
CE

ClassAssertion(CE a)

The individual
a1
/
a

is (resp. is not) connected by the property
expression
OPE
/
DPE

to the individual
a2
/literal
lt

ObjectPropertyAssertion(OPE a1 a2)

DataPropertyAssertion(DPE a lt)

NegativeObjectPropertyAssertion(OPE a1 a2)

NegativeDataPropertyAssertion(DPE a lt)

18

ENSM
-
SE

Outline

The second step toward a Semantic Web

Inferring implicit knowledge

Reasoner
-
oriented languages: RDF Schema and the OWL
2 Web Ontology Language (OWL 2)

Make use of the Semantic Web (II)

An overview of inference problems

A tableau algorithm for the consistency problem

Practical exercises

Create an OWL ontology

Query the OWL ontology

19

ENSM
-
SE

Let the reasoner reason

Consistency

Satisfiability

Subsumption

Instance

Least common subsumer

Most specific concept

Rewriting

Minimal rewriting

Approximation

Matching

Unification

20

Standard
reasoning
problems

Non
-
standard
reasoning
problems

ENSM
-
SE

A tableau algorithm for the
consistency problem (I)

Tableau algorithms are the standard approach to the
consistency problem

The following algorithm applies to a subset of OWL 2

No literals, no property expressions

Only following class expressions

ObjectIntersectionOf(CE1… CEn)

ObjectUnionOf(CE1… CEn)

ObjectComplementOf(CE)

ObjectSomeValuesFrom(OPE CE)

ObjectAllValuesFrom(OPE CE)

Only following axioms

SubClassOf(CE1 CE2)

ClassAssertion(CE a)

ObjectPropertyAssertion(OPE a1 a2)

21

ENSM
-
SE

A tableau algorithm for the
consistency problem (II)

It assumes concepts are in negation normal form

ObjectComplementOf(ObjectIntersectionOf(CE1…
CEn))



ObjectUnionOf(ObjectComplementOf(CE1)…
ObjectComplementOf(CEn))

ObjectComplementOf(ObjectUnionOf(CE1… CEn))



ObjectIntersectionOf(ObjectComplementOf(CE1)…
ObjectComplementOf(CEn))

ObjectComplementOf(ObjectSomeValuesFrom(OPE CE))



ObjectAllValuesFrom(OPE
ObjectComplementOf(CE))

ObjectComplementOf(ObjectAllValuesFrom(OPE CE))



ObjectSomeValuesFrom(OPE
ObjectComplementOf(CE))

22

ENSM
-
SE

A tableau algorithm for the
consistency problem (III)

Input:

a class
C

and a TBox
T

Output:

a boolean

Local variables:

an ABox
A

and an individual
i


i := getNewIndividual()

A := { C(i) }

while(!
isComplete(A)
)

applyRule(A)

if(
isClosed(A)
)

return false

else return true

23

A set of axioms not
involving individuals

A set of axioms
involving individuals

Returns a fresh
individual (i.e., not
available in the Abox yet)

No rule can be applied anymore

Whichever of the rules in the next slide

A class assertion and his negation
are available in the ABox

ENSM
-
SE

A tableau algorithm for the
consistency problem (IV)

24

These are alternatives


If the first alternative does not work, you
have to try the second one (
backtracking
)


Whenever you apply this rule, you have to
keep track of the other alternatives

ENSM
-
SE

Outline

The second step toward a Semantic Web

Inferring implicit knowledge

Reasoner
-
oriented languages: RDF Schema and the OWL
2 Web Ontology Language (OWL 2)

Make use of the Semantic Web (II)

An overview of inference problems

A tableau algorithm for the consistency problem

Practical exercises

Create an OWL ontology

Query the OWL ontology

25

ENSM
-
SE

Create an OWL ontology

If you do not have Eclipse, download it

http://www.eclipse.org/downloads/

Create an OWL ontology of Java entities

Think at the classes and properties you want to model

Package
java.lang.reflect

might help

Represent them in OWL: you might want to use

OWL’s functional or RDF syntax


http://www.w3.org/TR/2009/REC
-
owl2
-
quick
-
reference
-
20091027/

Protégé


http://protege.stanford.edu/download/download
.html

26

ENSM
-
SE

Query the OWL ontology

Download
http://www.emse.fr/~decoi/owlapi.zip

Import it into Eclipse

You will find an OWL ontology in
db/
owl
-
s.owl

It is the Process ontology of the OWL
-
S standard proposal

http://www.ai.sri.com/daml/services/owl
-
s/1.2/

27

ENSM
-
SE

OWL tools

Many tools available to help working with OWL
ontologies

http://www.w3.org/2001/sw/wiki/Tools

OWL API is a Java API and reference
implementation for managing OWL Ontologies

Enables creation, modification and deletion of OWL
ontologies

Can read, query and write OWL ontologies

Further information:
http://owlapi.sourceforge.net/


28

ENSM
-
SE

Enjoy OWL API

Have a look at classes

src/
fr.emse.owlapi.OWLAPIinterface

src/
fr.emse.owlapi.HermiTinterface

Try to understand how they work

If in trouble, have a look at the
doc

folder or the internet

Modify them, experiment with them, play with
them

E.g., use the OWL ontology you created previously

29

ENSM
-
SE

Query the OWL ontology

You have no idea of the data available in
db/
owl
-
s.owl

Try to get an idea by querying it (black
-
box
approach): e.g.

Find all classes, object/data properties, datatypes

Find all named individuals

Find all subclass/subproperty/membership relationships

Explore it, experiment with it, play with it

30

ENSM
-
SE

Homeworks

Download
http://www.emse.fr/~decoi/OWLlight.zip

Import it into Eclipse

Try to implement the tableau algorithm presented before

Implements interface
fr.emse.dl.reasoner.
IReasoner

You get

a class (
fr.emse.dl.datamodel.Concept
)

a TBox (
fr.emse.dl.datamodel.TBox
)

You return
true

if the class is satisfiable w.r.t. the
TBox,
false

otherwise.

31

ENSM
-
SE

Homeworks

You might want to exploit classes

fr.emse.dl.visitor.NNFVisitor

Brings a generic class into negative normal form

32

ENSM
-
SE

Homework delivery

Send a mail

to
decoi@emse.fr

by November, the 26
th

2010 at 2pm

with

your full name

Aspects Avancés du Web

as subject

all Java files you created (and only them) as a
.zip

attachment

33