(11) semantic web technologies - rules
Post on 18-Oct-2014
925 views
DESCRIPTION
TRANSCRIPT
Semantic Web Technologies
LectureDr. Harald Sack
Hasso-Plattner-Institut für IT Systems EngineeringUniversity of Potsdam
Winter Semester 2012/13
Lecture Blog: http://semweb2013.blogspot.com/This file is licensed under the Creative Commons Attribution-NonCommercial 3.0 (CC BY-NC 3.0)
Dienstag, 8. Januar 13
Semantic Web Technologies , Dr. Harald Sack, Hasso-Plattner-Institut, Universität Potsdam
2 1. Introduction 2. Semantic Web - Basic Architecture
Languages of the Semantic Web - Part 1
3. Knowledge Representation and LogicsLanguages of the Semantic Web - Part 2
4. Applications in the ,Web of Data‘
Semantic Web Technologies Content
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität Potsdam
3 OWL
Extension
SHROIQ(D)
SHOIN(D)
OWL2last lecture
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität Potsdam
4 OWLOWL 2
Erweiterung
SHROIQ(D)
SHOIN(D)
SHROIQ(D) Overview
Class Expressions• Class names A,B• Conjunction C ⊓ D• Disjunction C ⊔ D• Negation ¬C• Exist. property restriction ∃R.C• Univ property restriction ∀R.C• Self ∃S.Self• Greater-than ≥n S.C• Less-than ≤ S• Enumerated classes {a}
Properties• Property names R,S,T• Simple properties S,T• Inverse properties R-
• Universal property U
Tbox (Class axioms)• Inclusion C ⊑ D• Equivalence C ≣ D
Rbox (Property Axioms)• Inclusion R1 ⊑ R2
• General Inclusion R(-)1 º R (-) 2 º ..... º R (-) n ⊑ R• Transitivity• Symmetry• Reflexivity• Irreflexivity• Disjunctiveness
Abox (Facts)• Class membership C(a)• Property relation R(a,b)• Negated property relation ¬S(a,b)• Equality a=b• Inequality a≠b
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität Potsdam
5
OWLOWL 2
Erweiterung
SHROIQ(D)
SHOIN(D)
• OWL2 is a semantic fragment of FOL• OWL2 exists in different flavors
• OWL2 EL, OWL2 RL, OWL QL2 ⊆ OWL2 DL ⊆ OWL2 Full
Turmbau zu Babel, Pieter Brueghel, 1563
OWL2 – Web Ontology Language
OWL1 DL SHOIN(D)
OWL2 Full
OWL2
OWL2 DL SHROIQ(D)
OWL2 EL EL++OWL2 RL
OWL2 QL DL-Lite
undecidable
2NExpTimeComplete
NExpTimeComplete
PTimeComplete
AC0
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität Potsdam
6 Can we do SPARQL with OWL?
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität PotsdamTurmbau zu Babel, Pieter Brueghel, 1563
7
Using SPARQL with OWL Knowledge Bases
foaf:Person rdfs:subClassOf foaf:Agent . foaf:Person rdfs:subclassOf [ a owl:Restriction ; owl:onProperty :hasFather ; owl:someValuesFrom foaf:Person. ] foaf:knows rdfs:range foaf:Person. :Magnus a Person . :Magnus foaf:knows :Nadine .
•Consider the following OWL KB
•SPARQL 1.0 returns only :Magnus but it should also return :Nadine
SELECT ?X { ?X a foaf:Person }
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität PotsdamTurmbau zu Babel, Pieter Brueghel, 1563
8
Using SPARQL with OWL Knowledge Bases
•SPARQL 1.0 is a Query Language for RDF Graphs•does not support RDFS/OWL entailment
•Complex (OWL) ontologies cannot be represented with an explicit graph, there exist numerous possible interpretations
•In difference to RDF, there is no most specific interpretation as foundation for a graph
•OWL DL Interpretations might contain an (possibly) infinite number of elements
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität PotsdamTurmbau zu Babel, Pieter Brueghel, 1563
9
Using SPARQL with OWL Knowledge Bases
foaf:Person rdfs:subClassOf foaf:Agent . foaf:Person rdfs:subclassOf [ a owl:Restriction ; owl:onProperty :hasFather ; owl:someValuesFrom foaf:Person. ] foaf:knows rdfs:range foaf:Person. :Magnus a Person . :Magnus foaf:knows :Nadine .
•Consider the following OWL KB
•SPARQL 1.1 enables OWL entailment and returns :Magnus :Nadine
SELECT ?X { ?X a foaf:Person }
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität PotsdamTurmbau zu Babel, Pieter Brueghel, 1563
10
SPARQL 1.1 with RDFS/OWL Entailment
•Challenges and Pittfalls•possibly infinite answers
•non-distinguished variables
•other SPARQL 1.1 features, e.g. aggregates
•SPARQL 1.1 follows a simple pragmatic approach:•Restrict results to terms occurring in the graph
•Answers must result from BGP matching
•Aggregates are evaluated as post-processing after BGP matching
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität PotsdamTurmbau zu Babel, Pieter Brueghel, 1563
11
Alternative Variant for Querying OWL DL
•Conjunctive Queries
•no official specification
•Goal: more expressive queries about individuals
•Formatting or post-processing of results is not considered
•practical relevance for applications•various implementations available
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität PotsdamTurmbau zu Babel, Pieter Brueghel, 1563
12 •conjunctive queries are simple•Example:
•„Which books are published by Springer and who is the author?“
•Syntax similar to FOL
•Main elements: Properties/Classes/Individuals, Variables, Conjunction ∧
Syntax and Intuition of Conjunctive Queries
Book(x) ∧ publishedBy(x, Springer) ∧ hasAuthor(x, y)
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität PotsdamTurmbau zu Babel, Pieter Brueghel, 1563
13•Main elements (Atoms):
•C(e) or ¬C(e) , C is class name, e is variable or name of an individual
•R(e,f), R is property name, e and f are variables or names of individuals
•Example:
Syntax and Intuition of Conjunctive Queries
Book(x) ∧ publishedBy(x, Springer) ∧ hasAuthor(x, y)
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität PotsdamTurmbau zu Babel, Pieter Brueghel, 1563
14
Semantics of Conjunctive Queries
•Conjunctive Queries are similar to logical formulas•Queries without variables might be entailed directly from the ontology
•Variables are used as placeholders for individuals
•Function μ is result of a conjunctiven query q for an OWL DL Ontology O, iff:(1) Domain of μ is the set of free variables in q(2) Range of μ is the set of all individuals in O(3) O ⊨ μ(q), i.e. conjunctive query q with given variable
assignment is entailed by O
•no partial function – all Variables must be assigned
•Literals (Datatypes) are not considered for simplicity
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität PotsdamTurmbau zu Babel, Pieter Brueghel, 1563
15
Elements Without Names
•Variables are placeholders for (named) individuals•OWL Ontologies can entail the existence of not named individuals
•Example:
Book(a) (a is a book)Book ⊑ ∃hasAuthor.⊤ (every book has an author)
Anfrage:Book(x) ∧ hasAuthor(x,y)
→ no possible solution
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität PotsdamTurmbau zu Babel, Pieter Brueghel, 1563
16
Non-distinguished Variables
•How to consider not named elements for the query?•Output of not named elements as part of the result is problematic
•But a statement of existence is possible vianon-distinguished variables(=variables bound via existential quantification)
Anfrage:∃y.(Book(x) ∧ hasAuthor(x,y))
Solution {x ↦ a}, but y is NOT PART of the result
Book(a) (a is a book)Book ⊑ ∃hasAuthor.⊤ (every book has an author)
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität PotsdamTurmbau zu Babel, Pieter Brueghel, 1563
17
SPARQL vs. Conjunctive Queries
SPARQL Conjunctive Queries
graph patterns logical conjunctions
canonical model many possible models
options, alternatives, filters -
query for arbitrary elements only query for individuals (strict typing)
variables for arbitrary elements distinguished and non-distinguished variables
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität PotsdamTurmbau zu Babel, Pieter Brueghel, 1563
18•KAON2: conjunctive queries without non-distinguished variables, restricted negation possible
•Pellet: conjunctive queries with non-distinguished variables and negation, not complete for OWL DL
•further implementations with special query languages (RacerPro) or restrictions to simpler DLs (QuOnto for OWL2 QL)
• see also http://www.cs.man.ac.uk/~sattler/reasoners.html
Restrict the problem and the implementation gets simpler
Implementations of Conjunctive Queries
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität Potsdam
19 3. Knowledge Representation and LogicsThe Languages of the Semantic Web - Part 2
• Excursion: Ontologies in Philosophy and Computer Science
• Recapitulation: Propositional Logic and First Order Logic
• Description Logics
• RDF(S) Semantics• OWL and OWL-Semantics• OWL 2
• Rules & The Semantic Web
Semantic Web Technologies Content
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität Potsdam
20 Can we model everything with
OWL?
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität Potsdam
21
Rules
&
the Se
mantic
Web
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität Potsdam
22
3.7 Rules & The Semantic Web3.7.1 Rules from a Semantic Web Perspective3.7.2 Rules for OWL with SWRL3.7.3 Rules expressible in OWL3.7.4 Exchanging Rules with RIF
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität PotsdamTurmbau zu Babel, Pieter Brueghel, 1563
23
• The Semantic Web concentrates on declarative forms of knowledge representation• OWL, RDFS
• Rules are a common form of procedural knowledge representation in Knowledge Engineering• Expert Systems• Prolog, CLIPS, JESS, OPS, …
• Knowledge representation formalisms of the Semantic Web have expressive limitations which can be overcome by rule-based knowledge• e.g. composition of complex classes from classes and
properties
The Role of Rules
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität PotsdamTurmbau zu Babel, Pieter Brueghel, 1563
24
What are Rules?
•Interpretation of a rule depends on context• General Inference:
Premise → Conclusion• Hypothesis:
Cause → Effect• Production:
Condition → Action
IF A .... THEN B ....
A ! B
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität PotsdamTurmbau zu Babel, Pieter Brueghel, 1563
25
What are Rules?
•Logical Rules (FOL implication):•F ! G is equivalent with ¬F ∨ G•Logical extension of the KB (static)•Open World, declarative
•Procedural Rules (e.g. Production Rules):•If X then Y else Z •executable machine instructions (dynamic)•operational (semantics = effect at application)
•Logic Programming Rules (e.g. Prolog, F-Logic):•„woman(X) <- person(X) AND NOT man(X)“•Approximation of logical semantics with operational aspects•Closed World (mostly), semi-declarative
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität PotsdamTurmbau zu Babel, Pieter Brueghel, 1563
26
FOL as Rule Language•Rules as FOL implications (Horn Clause)
•semantically equivalent with
•where Ai, H are atomic formulas•Quantification most times ommitted, free variables are considered to be universally quantified•i.e. the rule holds for all possible assignments
A1 ∧ A2 ∧ . . . ∧ An ! H
⎧ | |
|
| ⎨ |
|
|
| ⎩Body
¬A1 ∨ ¬A2 ∨ . . . ∨ ¬An ∨ H
→
⎧ ⎨ ⎩
Head
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität PotsdamTurmbau zu Babel, Pieter Brueghel, 1563
27
FOL as Rule Language•Rules as FOL implications (Horn Clause)
•semantically equivalent with
•where Ai, H are atomic formulas•Quantification most times ommitted, free variables are considered to be universally quantified•i.e. the rule holds for all possible assignments
H ← A1 ∧ A2 ∧ . . . ∧ An
⎧ | |
|
| ⎨ |
|
|
| ⎩Body
¬A1 ∨ ¬A2 ∨ . . . ∨ ¬An ∨ H
←⎧ ⎨ ⎩
Head
often written from right to left ( ← or :- )
Dienstag, 8. Januar 13
•Lloyd-Topor Transformation•Several atoms in the head are usually considered as conjunction
•is equal to
•this transformation is called Lloyd-Topor Transformation
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität PotsdamTurmbau zu Babel, Pieter Brueghel, 1563
28
Variants of FOL Rules
A1 A2...An ! H1 H2...Hm
A1 A2...An ! H1A1 A2...An ! H2
...
A1 A2...An ! Hm
Dienstag, 8. Januar 13
•Disjunctive Rules•Disjunction of several non-negated Atoms
•reverse implication, as e.g.„if I see someting, then the light is on or the sun is shining“
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität PotsdamTurmbau zu Babel, Pieter Brueghel, 1563
29
Variants of FOL Rules
⎧ | |
|
| ⎨ |
|
|
| ⎩⎧ |
|
|
| ⎨ |
|
|
| ⎩
A1 ∧ A2 ∧ . . . ∧ An → H1 ∨ H2 ∨ . . . ∨ Hm
Body Head
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität PotsdamTurmbau zu Babel, Pieter Brueghel, 1563
30•FOL Rules
•Clause: Disjunction of atomic formulas or negated atomaric formulas
•Horn Clause: Claus with at most one not negated atom
•Definite Clause: Clause with exactly one not negated atom
•Fact: Clause of a single not negated atom
¬p ∨ ¬q ∨ . . . ∨ ¬t ∨ u can be written as p ∧ q ∧ . . . ∧ t ! u
Variants of FOL Rules
Dienstag, 8. Januar 13
•Examples
•Semantic of rules complies to FOL semantics
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität PotsdamTurmbau zu Babel, Pieter Brueghel, 1563
31
Person(x) ! Woman(x) ∨ Man(x) (clause)
Man(x) ∧ hasChild(x,y) ! Father(x)(definite clause)
hasBrother(mother(x),y) ! isUncle(x,y)(with function symbol)
Variants of FOL Rules
Man(x) ∧ Woman(x) ! (horn clause)
Woman(Nadine) (fact)
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität PotsdamTurmbau zu Babel, Pieter Brueghel, 1563
32
Description Logics vs. Rules
•Rules are usually considered to apply only to known constants.
•No possibility to „create“ new things „on the flight“by using existential quantification ∃
•If rules are considered FOL formulas, then combining rules with ALC leads to undecidability.
Human ⊑ ∃hasParent.Human
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität PotsdamTurmbau zu Babel, Pieter Brueghel, 1563
33
DATALOG
• is a logical rule language that consists of •horn clauses without function symbols
•conjunction, constants, universally quantified variables, predicate symbols
•no disjunction, no negation, no existential quantification, no function symbols
•originally developed as foundation of deductive databases•Knowledge Bases (Datalog Programs) are sets of horn
clauses (without function symbols)•DATALOG is decidable
•DATALOG is computationally efficient, complexity corresponds to OWL Lite, i.e. ExpTime
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität PotsdamTurmbau zu Babel, Pieter Brueghel, 1563
34
DATALOG
•Datalog Term: constant c or variable v
•Datalog Atom: p(t1,...,tn) with predicate p, terms t1,...,tn
•Datalog Rule: ∀x1,...,∀xn (B1 ⋀ ... ⋀ Bn → H) with B1,...,Bn,H atoms and x1,...,xn variables of the atoms
•Datalog Program: set of Datalog rules
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität PotsdamTurmbau zu Babel, Pieter Brueghel, 1563
35
DATALOG
Examples
(1) Vegetarian(x) ⋀ FishProduct(y) → dislikes(x,y) (2) orderedDish(x,y) ⋀ dislikes(x,y) → Unhappy(x)(3) orderedDish(x,y) → Dish(y)(4) dislikes(x,z) ⋀ Dish(y) ⋀ contains(y,z) → dislikes(x,y)(5) → Vegetarian(Matthias)(6) Happy(x) ⋀ Unhappy(x) →
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität PotsdamTurmbau zu Babel, Pieter Brueghel, 1563
36
DATALOG Semantics
• Interpretation I with Domain ΔI
• Interpretation of variables: variable assignment Z (mapping of variables to ΔI)
• Interpretation of rules and terms wrt. I (and Z):
• Interpretation of a constant: aI,Z = aI∈ΔI
• Interpretation of a variable: xI,Z = Z(x)∈ΔI
• Interpretation of an n-ary predicate: pI ∈ ΔI n
• I,Z ⊨ p(t1,...,tn) iff (tI,Z1,...,tI,Zn)∈pI,
• I ⊨ B!H iff for all variable assignments Z it holds: either I,Z ⊨ H or I,Z ⊭ B.
• I is a Model for a rule set (program), iff:I ⊨ B!H for all rules B!H of the rule set
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität PotsdamTurmbau zu Babel, Pieter Brueghel, 1563
37
How to combine OWL and Datalog?
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität PotsdamTurmbau zu Babel, Pieter Brueghel, 1563
38
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität Potsdam
39
3.7 Rules & The Semantic Web3.7.1 Rules from a Semantic Web Perspective3.7.2 Rules for OWL with SWRL3.7.3 Rules expressible in OWL3.7.4 Exchanging Rules with RIF
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität PotsdamTurmbau zu Babel, Pieter Brueghel, 1563
40
•W3C Submission (bereits im Mai 2004)(developed by the Joint US/EU ad hoc Agent Markup Language Committee (JC),in collaboration with RuleML Initiative)
•based on combination of parts of OWL and RuleML/Datalog•here OWL DL and Unary/Binary Datalog RuleML
•Idea: Datalog Rules that apply on OWL ontologies
•Symbols in rules can be OWL identifiers (or new Datalog identifiers)
•Syntax: XML Concrete Syntax (extends OWL XML Presentation Language), RDF Concrete Syntax and abstract Syntax
•Rules are represented as Implication of an Antecedent (Body) and a Consequent (Head)
•SWRL is undecidable
SWRL SemanticWeb Rule Language
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität PotsdamTurmbau zu Babel, Pieter Brueghel, 1563
41
SWRL SemanticWeb Rule Language
•Antecedent and Consequent are Conjunctions of
assertions (atoms) of the form•C(x) or P(x,y) •sameAs(x,y), differentFrom(x,y)
•where x,y are variables, OWL individuals or elements of an OWL concrete domain,
•C(x) is an OWL class description P(x,y) is an OWL property description
Antecedent → Consequent
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität PotsdamTurmbau zu Babel, Pieter Brueghel, 1563
42
SWRL - Abstract Language Definition
•SWRL Rule
•SWRL Knowledge Base
•Atoms are defined as
•C ... Class, D ... Datatype
•R ... Object Property
•U ... Datatype Property
• i,j ... Variable / Individual identifier
a ← b1,...,bn where a: head, b1,...,bn: body
Atom ← C(i) | D(v) | R(i, j) | U(i,v) | builtIn(p, v1, ..., vn) | i = j | i ≠ j
•v,v1,...vn ... Datatype Variable / Value Identifier
•p ... name of a BuiltIn function
k=(Σ,P) where Σ is an OWL knowledge base P is a finite rule set
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität PotsdamTurmbau zu Babel, Pieter Brueghel, 1563
43
SWRL - Semantics
•OWL DL (Description Logics) and Datalog are applying the same interpretations•OWL individuals are Datalog constants•OWL classes are unary Datalog predicates•OWL properties are binary Datalog predicates
•Interpretation can be model for OWL ontology as well as for a set of Datalog rules
Entailment for OWL/Datalog combination is possible
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität PotsdamTurmbau zu Babel, Pieter Brueghel, 1563
44
SWRL - Semantics
•Let I=(ΔI, ΔD,.I ,.D) an interpretation with
•ΔI = Object Interpretation domain
•ΔD = Datatype Interpretation domain•.I = Object Interpretation function•.D = Datatype Interpretation function•with ΔI ∩ ΔD =⊥
•VIX are object variables with VIX ! 2ΔI
•VDX are datatype variables with VDX ! 2ΔD
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität PotsdamTurmbau zu Babel, Pieter Brueghel, 1563
45
SWRL - Semantics
•Interpretation of SWRL atoms:
SWRL atom Interpretation
C(i) iI∈CI
R(i,j) (iI,jI)∈RI
U(i,v) (iI,vD)∈UI
D(v) vD∈DD
builtIn(p,v1,...,vn) v1D,...,vnD∈pD
i=j iI=jI
i≠j iI≠jI
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität PotsdamTurmbau zu Babel, Pieter Brueghel, 1563
46
SWRL - Semantics
•SWRL Antecedent is satisfied, iff•antecedent is empty (trivial)•all atoms of the antecedent are satisfied
•SWRL Consequent is satisfied, iff•it is not empty and•the atom of the consequent is satisfied
•A rule is satisfied for an Interpretation I, iff•the Interpretation I, which satisfies the antecedent also satisfies the consequent.
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität PotsdamTurmbau zu Babel, Pieter Brueghel, 1563
47
SWRL - ExamplehatOnkel(?x,?z) ← hatVater(?x,?y) Λ hatBruder(?y,?z)
<ruleml:imp> <ruleml:_rlab ruleml:href="#onkel"/> <owlx:Annotation> <owlx:Documentation>Bruder des Vaters</owlx:Documentation> </owlx:Annotation> <ruleml:_body> <swrlx:individualPropertyAtom swrlx:property=“&family;hatVater"> <ruleml:var>x</ruleml:var> <ruleml:var>y</ruleml:var> </swrlx:individualPropertyAtom> <swrlx:individualPropertyAtom swrlx:property=“&family;hatBruder"> <ruleml:var>y</ruleml:var> <ruleml:var>z</ruleml:var> </swrlx:individualPropertyAtom> </ruleml:_body> <ruleml:_head> <swrlx:individualPropertyAtom swrlx:property=“&family;hatOnkel"> <ruleml:var>x</ruleml:var> <ruleml:var>z</ruleml:var> </swrlx:individualPropertyAtom> </ruleml:_head></ruleml:imp>
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität PotsdamTurmbau zu Babel, Pieter Brueghel, 1563
48
SWRL is undecidable
•Logical Inference for OWL+SWRL is undecidable
•There is no known algorithm that is able to entail all possible inferences for all SWRL knowledge bases, even with unlimited resources and time
•But, from a practical perspective, there are•Algorithms that are able to entail all possible inferences for
some SWRL knowledge bases•Algorithms that are able to entail some inferences for all
SWRL knowledge bases
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität Potsdam
49
Tool Support for SWRL•Bossam, R2ML, Hoolet, Pellet, KAON2, RacerPro,•Jess, SWRLTab, SWRLQueryTab
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität Potsdam
50
3.7 Rules & The Semantic Web3.7.1 Rules from a Semantic Web Perspective3.7.2 Rules for OWL with SWRL3.7.3 Rules expressible in OWL3.7.4 Exchanging Rules with RIF
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität PotsdamTurmbau zu Babel, Pieter Brueghel, 1563
51
Decidable Fragments of SWRL
•Which SWRL knowledge bases enable complete inference algorithms?
•All SWRL knowledge bases that exist only of OWL / OWL2 axioms
•All SWRL knowledge bases that exist only of sets of Datalog programs
•Every static finite class of SWRL knowledge bases
•Are there more SWRL fragments that are decidable?(1)Description Logics Rules
SWRL Rules that can already be expressed with OWL2
(2)DL-safe Rules Restriction of SWRL Rules via variable assignment constraints
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität PotsdamTurmbau zu Babel, Pieter Brueghel, 1563
52
Description Logics Rules
•General Idea:Find out, which rules can be expressed via OWL2
•Simple Rules in OWL2
•become
Class1 ⊑ Class2Property1 ⊑ Property2
Class1(x) ! Class2(x)Property1(x,y) ! Property2(x,y)
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität PotsdamTurmbau zu Babel, Pieter Brueghel, 1563
53•Some classes can be fragmented into rules
A ⊓ B ⊑ ⊥ becomes A(x) ∧ B(x) !
A ⊓ ∃R.∃S.B ⊑ CbecomesA(x) ∧ R(x,y) ∧ S(y,z) ∧ B(z) ! C(x)
A ⊑ ∀R.B becomes A(x) ∧ R(x,y) ! B(y)
A ⊑ ¬B ⊔ C becomes A(x) ∧ B(x) ! C(x)
⊤ ⊑ ≤1R.⊤ becomes R(x,y) ∧ R(x,z) ! y=z
Description Logics Rules
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität PotsdamTurmbau zu Babel, Pieter Brueghel, 1563
54
(1) Description Logics Rules
•Some classes can be fragmented into rules
{a} ≣ {b} becomes ! a=b
A ⊓ ∃R.{b} ⊑ C becomes A(x) ∧ R(x,b) ! C(x)
A ⊑ B ⊓ C becomes A(x) ! B(x) and A(x) ! C(x)
A ⊔ B ⊑ C becomes A(x) ! C(x) and B(x)! C(x)
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität PotsdamTurmbau zu Babel, Pieter Brueghel, 1563
55
(1) Description Logics Rules
•In general:•A DL axiom α can be translated into rules, if after translating α into a FOL expression α‘, and after normalizing this expression into a set of clauses M, each formula in M is a Horn clause (i.e. a rule)
•What about complex properties (property chains)?
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität PotsdamTurmbau zu Babel, Pieter Brueghel, 1563
56
(1) Description Logics Rules
•Property chains can be expressed as rules:
•becomes
•in general
hasParent(x,y) ∧ hasBrother(y,z) ! hasUncle(x,z)
hasParent ∘ hasBrother ⊑ hasUncle
R ∘ S ⊑ T becomes R(x,y) ∧ S(y,z) ! T(x,z)
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität PotsdamTurmbau zu Babel, Pieter Brueghel, 1563
57
(1) Description Logics Rules
•Problems:•What if on both sides of the rule are not only properties or not only classes ?
•How to express this in OWL2?
Example.: Man(x) ∧ hasChild(x,y) ! fatherOf(x,y)
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität PotsdamTurmbau zu Babel, Pieter Brueghel, 1563
58
(1) Description Logics Rules
•How to express this in OWL2?
•Idea: •substitute Man(x) with a property to make a property chain
•Apply „Self“ to transform classes into properties•Auxiliary property PMan•Auxiliary axiom Man ≣ ∃PMan.Self
•Thus:
PMan ∘ hasChild ⊑ fatherOf
Example.: Man(x) ∧ hasChild(x,y) ! fatherOf(x,y)
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität PotsdamTurmbau zu Babel, Pieter Brueghel, 1563
59
(1) Description Logics Rules
•Rolification of concept/class
A(x) ∧ R(x,y) ! S(x,y) becomes PA ∘ R ⊑ S
A(y) ∧ R(x,y) ! S(x,y) becomes R ∘ PA ⊑ S
A(x) ∧ B(y) ∧ R(x,y) ! S(x,y) becomes PB ∘ R ∘ PB ⊑ S
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität PotsdamTurmbau zu Babel, Pieter Brueghel, 1563
60
(1) Description Logics Rules
•More problems:
•How to express this in OWL2?
•Idea:•Apply universal property U to connect classes•Auxiliary properties: PVegetarian und PFishproduct
Example.: Vegetarian(x) ∧ Fishproduct(y) ! dislikes(x,y)
Vegetarian ≣ ∃PVegetarian.SelfFishproduct ≣ ∃PFishproduct.SelfPVegetarian ∘ U ∘ PFishproduct ⊑ dislikes
Dienstag, 8. Januar 13
•More Problems:
•How to express this in OWL 2?
•Is it possible to eliminate variable y to form a class inclusion in OWL2?
?
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität PotsdamTurmbau zu Babel, Pieter Brueghel, 1563
61
(1) Description Logics Rules
?
Example.: orderedDish(x,y) ∧ dislikes(x,y) ! Unhappy(x)
∃orderedDish.⊤ ⊓ ∃dislikes.⊤ ⊑ Unhappy
∃orderedDish.∃dislikes–.⊤ ⊑ Unhappy
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität PotsdamTurmbau zu Babel, Pieter Brueghel, 1563
62
Decidable Fragments of SWRL
•Which SWRL knowledge bases enable complete inference algorithms?
•All SWRL knowledge bases that exist only of OWL / OWL2 axioms
•All SWRL knowledge bases that exist only of sets of Datalog programs
•Every static finite class of SWRL knowledge bases
•Are there more SWRL fragments that are decidable?(1) Description Logics Rules
SWRL Rules that can already be expressed with OWL2
(2) DL-safe Rules Restriction of SWRL Rules via variable assignment constraints
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität PotsdamTurmbau zu Babel, Pieter Brueghel, 1563
63
(2) DL-Safe Rules
•Idea:•Restrict SWRL to guarantee decidability via restricting the number of possible variable assignments
•Arbitrary Datalog rules are allowed with names of OWL classes and OWL properties
•Rules must be DL-safe: each variable must also be represented within an expression of the rule body that doesn‘t use an OWL class or OWL property (= Datalog Atom)
•Semantics can be adopted from OWL+SWRL (FOL).
DL-safety restricts the application of rules to known individuals
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität PotsdamTurmbau zu Babel, Pieter Brueghel, 1563
64
Forcing DL-Safety
•Example:
•NOT DL-safe, if „bruder“ and „father“ are OWL properties
•Force DL-Safeness by Restricting the rules to known individuals
•whereby the fact O(a) has to be asserted for all OWL individuals
•Rule is only applicable to known OWL individuals (Named Individuals)
brother(x, z) ⋀ father(z, y) ! uncle(x, y)
O(x) ⋀ O(y) ⋀ O(z) ⋀ bruder(x, z) ⋀ vater(z, y) ! onkel(x, y)
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität Potsdam
65
Forcing DL-Safety
•Example: „He, who hates his brother, is evil.“
•this implies: evil(Kain), evil(Romulus)•this implies (safe): evilsafe(Kain), BUT NOT: evilsafe(Romulus)
Knowledge Base:father(Kain, Adam) "
father(Abel, Adam) "hates(Kain, Abel)
∃father.father—{Remus}(Romulus) " hates(Romulus, Remus)
father(x,z) ⋀ father(y,z) ⋀ hates(x,y) ! evil(x)O(x)⋀O(y)⋀O(z)⋀father(x,z)⋀father(y,z)⋀hates(x,y) ! evilsafe(x)
O(Kain), O(Abel), O(Adam), O(Romulus), O(Remus)
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität Potsdam
66
Summary
•SWRL („OWL + Datalog“) is not decidable•Description Logic Rules
•SWRL fragment that can be expressed with OWL2•indirectly supported by OWL 2 reasoners
•DL-safe Rules•SWRL fragment where variables only can be assigned to concrete values (constants)
•supported by OWL reasoner•DL-safety can be forced
•Standard and Best-Practice for rules still does not exist
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität Potsdam
67
3.7 Rules & The Semantic Web3.7.1 Rules from a Semantic Web Perspective3.7.2 Rules for OWL with SWRL3.7.3 Rules expressible in OWL3.7.4 Exchanging Rules with RIF
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität Potsdam
68
RIF - Rule Interchange Format
•W3C Standard (June 2010)•Goal: Definition of a standard to exchange rules (esp. for web-based rule engines)
Rule Engine A
Rule Engine B
RIF dialect X
semantic preservicemapping
semantic preservingmapping
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität Potsdam
69
RIF - Rule Interchange Format
•Components:•RIF BLD (Basic Logic Dialect) - language standard•RIF-RDF / RIF-OWL - interoperable Semantic with existing knowledge representation languages of the semantic web
•RIF-PRD (Production Rules Dialect) - standard for production rules
•RIF-DTB (Data Types and Builtins)•RIF-FLD (Framework of Logic Dialects)
•W3C RIF Working Grouphttp://www.w3.org/2001/sw/wiki/RIF
RIF Core
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität Potsdam
70
RIF - CORE
•RIF-Core is •restricted variant of RIF BLD (definite Horn rules without function symbols, i.e. similar to Datalog)
•part of RIF PRD (Production Rule Dialect)
•W3C recommendation since 2010
•Syntax variants:•(readable) BLD presentation syntax•XML-based serialization
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität Potsdam
71
RIF-CORE Dialect
•Example.: uncle(x,y) ← brother(x,z) ⋀ father(z,y)
brother(Martin, Johannes)
father(Johannes, Max)
Document (
Prefix(ex <http://example.com/>)
Group(
Forall ?x ?y ?z(
ex:uncle(?x,?y) :- And(ex:brother(?x,?z) ex:father(?z,?y))
)
ex:brother(ex:Martin ex:Johannes)
ex:father(ex:Johannes ex:Max)
)
)
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität Potsdam
72
•Property values can be assigned comfortably via ‘Frames‘
•Example.:
ex:book[ex:authoredBy -> ex:Harald
ex:title -> “Internetworking“^^xsd:string
ex:publishedBy -> ex:Springer]
Forall ?person ?book (
?person[ex:authorOf -> ?book :- ?book [ex:hasAuthor -> ?person]]
)
subject [ property -> object ]
RIF-CORE Dialect
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität Potsdam
73
•Another RIF Example:
Document(
Prefix(dbp <http://dbpedia.org/property/>)
Prefix(my <http://mydata.org/resource#>)
Prefix(rdfs <http://www.w3.org/2000/01/rdf-schema#>)
Group ( Forall ?mname ?aname ?movie ?actor
my:actorIn(?aname ?mname) :-
And( ?movie[dbp:starring -> ?actor rdfs:label -> ?mname]
?actor[rdfs:label ?aname]
)
)
)
RIF-CORE Dialect
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität Potsdam
74
RIF-CORE XML Syntax
𝜒 = mapping function to map presentation syntax to XML syntax
<Document>
<payload>
<Group>
<sentence>𝜒(regel1)</sentence>
...
<sentence>𝜒(regeln)</sentence>
</Group>
</payload>
</Document>
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität Potsdam
75
RIF-CORE XML Syntax
RIF presentation Syntax RIF XML Syntax
Forall ?x1...?xn (content)
<Forall>
<declare>𝜒(?x1)</declare)
...
<declare>𝜒(?xn)</declare)
<formula>
𝜒(content)
</formula>
</Forall>
𝜒 = mapping function to map presentation syntax to XML syntax
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität Potsdam
76
RIF-CORE XML Syntax
RIF presentation Syntax RIF XML Syntax
head :- body
<Implies>
<if>𝜒(body)</if)
<then>𝜒(head)</then>
</Implies>
And(content1...contentn)
<And> <formula> 𝜒(content1)
</formula> ...<formula> 𝜒(contentn)
</formula> </And>
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität Potsdam
77
RIF-CORE XML Syntax
RIF presentation Syntax RIF XML Syntax
predicate(t1...tn)
<Atom>
<op>𝜒(predicate)</op)
<args ordered=“yes“>
𝜒(t1)
...
𝜒(tn)
</args>
</Atom>
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität Potsdam
78
RIF-CORE XML Syntax
RIF presentation Syntax RIF XML Syntax
subject(p1-> o1 ... pn-> on)
<Frame>
<object>𝜒(subject)</object)
<slot ordered=“yes“> 𝜒(o1)
𝜒(p1)
</slot> ... <slot ordered=“yes“> 𝜒(on)
𝜒(pn)
</slot></Frame>
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität Potsdam
79
RIF-CORE XML Syntax
RIF presentation Syntax RIF XML Syntax
“literal“^^datatype<Const type=“datatype“> literal</Const>
?variablenname
<Var> variablenname</Var>
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität Potsdam
80
3.7 Rules & The Semantic Web3.7.1 Rules from a Semantic Web Perspective3.7.2 Rules for OWL with SWRL3.7.3 Rules expressible in OWL3.7.4 Exchanging Rules with RIF
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität Potsdam
81 3. Knowledge Representation and LogicsThe Languages of the Semantic Web - Part 2
• Excursion: Ontologies in Philosophy and Computer Science
• Recapitulation: Propositional Logic and First Order Logic
• Description Logics
• RDF(S) Semantics• OWL and OWL-Semantics• OWL 2
• Rules & The Semantic Web
Semantic Web Technologies Content
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität Potsdam
Next Lecture:
82
Ontolo
gical
Engine
ering
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität Potsdam
83
• P. Hitzler, S. Roschke, Y. Sure: Semantic Web Grundlagen, Springer, 2007.
• P. Hitzler, M. Krötzsch, S. Rudolph:Foundations of Semantic Web Technologies,CRC Press, 2009.
Bibliography
3. Knowledge Representation & Logic3.7 Rules & the Semantic Web
Dienstag, 8. Januar 13
Vorlesung Semantic Web, Dr. Harald Sack, Hasso-Plattner-Institut, Universität Potsdam
84
□Bloghttp://semweb2013.blogspot.com/
□Webseitehttp://www.hpi.uni-potsdam.de/studium/lehrangebot/itse/veranstaltung/semantic_web_technologien-3.html
□bibsonomy - Bookmarkshttp://www.bibsonomy.org/user/lysander07/swt1213_11
3. Knowledge Representation & Logic3.7 Rules & The Semantic Web
Dienstag, 8. Januar 13