Upload
elam
View
46
Download
0
Tags:
Embed Size (px)
DESCRIPTION
Semantic Web in Depth. Rules. Dr Nicholas Gibbins - nmg @ecs.soton.ac.uk 2013-2014. The Role of Rules. The Semantic Web concentrates on declarative forms of knowledge representation OWL, RDF Schema - PowerPoint PPT Presentation
Citation preview
Semantic Web in DepthRules
Dr Nicholas Gibbins - [email protected]
The Role of RulesThe Semantic Web concentrates on declarative forms of knowledge representation
– OWL, RDF Schema
Rules are a common form of procedural knowledge representation elsewhere in Knowledge Engineering
– Expert Systems– CLIPS, JESS, OPS, Prolog…
The Role of RulesThe KR formalisms of the Semantic Web have expressive limitations which can be overcome by rule-based knowledge
For example, we cannot express the fact that a person’s parent’s brother is the person’s uncle in either RDFS or OWL (including OWL Full)
– No role composition in OWL 1.0
The Role of RulesTrivial to express in a language like Prolog:
hasUncle(X,Y) :- hasParent(X,Z), hasBrother(Z,Y).
hasBrother(X,Y) :- isMale(Y),hasParent(X,Z),hasParent(Y,Z).
Rules
XML + Namespaces
URI Unicode
Sign
atur
e
Encr
yptio
n
RDF
RDF Schema
OWL
Identity
Standard syntax
Metadata
Ontologies +Inference
Explanation
Attribution
SPARQL(queries)
Proof
Trust
User Interface and Applications
The Semantic Web layer cake
SPARQL CONSTRUCTPREFIX foaf: <http://xmlns.com/foaf/0.1/>PREFIX vcard: <http://www.w3.org/2001/vcard-rdf/3.0#>CONSTRUCT {
?x vcard:FN ?name .?x vcard:EMAIL ?mail .
}WHERE {
?x foaf:name ?name .?x foaf:mbox ?mail .
}
SPARQL CONSTRUCT is not a rule languageFrom the Data Access Working Group Charter:
“While it is hoped that the product of the RDF Data Access Working Group will be useful in later development of a rules language, development of such a rules language is out of scope for this working group. However, any serializations of a query language must not preclude extension to, or inclusion in, a rules language. The group should expend minimal effort assuring that such an extension be intuitive and and consistent with any query language produced by the group.”
Rules and the Semantic WebSeveral proposed rule languages for use with the SW:
– RuleML– N3 Rules– Jena Rules– Semantic Web Rule Language (SWRL)– Rule Interchange Format (RIF)
Rule FormatThe majority of rules in rule-based systems are of the form:
A ⇐ B1 ∧ B2 ∧ … ∧ Bn
• A is known as the consequent or head of the rule
• B1…Bn are known as the antecedents or body of the rule
• Also known as Horn Clauses (disjunction with at most one positive literal)
Description Logics and RulesSome work on designing DLs which include trigger rules of the form:
C ⇒D
(if an individual is a member of C, then it must be a member of D
Description Logics and RulesC ⇒D is not the same as saying C ⊑ D (every instance of C is an instance of D)
– C ⊑ D is equivalent to saying ¬D ⊑ ¬C (contrapositive)– The trigger rule C ⇒D is not equivalent to ¬D ⇒ ¬C
DLs with rules include an epistemic (modal) operator K:
– KC can be read as “the class of things which are known to be of class C”
– C ⇒D is equivalent to KC ⊑ D– Used as a foundation for SWRL, etc
N3 Rules
N3 RulesDefines log: namespace for logical operators
– Some triples are “special” – interpreted as components of rules
– log: namespace puts ontology into OWL Full
Relies on N3 syntax for graphs: {} (not in Turtle, etc)
Not widely implemented– cwm (TimBL’s pet reasoner)– +?
N3 RulesGeneral form:
{ antecedent graph } log:implies { consequent graph }.
Example:
{?x ont:parent ?y. ?y ont:brother ?z. } log:implies {?x ont:uncle ?z. }.
Jena Rules
Jena RulesJena RDF/OWL library contains support for forward- and backward-chaining rules
– Only implemented in Jena
Syntax:
[rule name: antecedents -> consequent ]
Antecedents expressed as triple patterns (unfortunately not in a SPARQL-like syntax)
Jena Rule Example# Example rule file@prefix ont: <http://example.org/ontology#>.@include <RDFS>.
[rule1: (?x ont:parent ?t) (?t ont:brother ?z) -> (?x ont:uncle ?z)]
can include other rulebases – these are the entailment rules for RDFS
Semantic Web Rule Language
SWRLSubmitted to W3C in 2004
– Based on RuleML subset and OWL– XML and RDF-based serialisations
(also, human-readable abstract syntax)– Obeys constraints put on OWL re: disjointness of instances
and datatype values
Two types of variable in expressions– I-variable – matches class instances– D-variable – matches datatype values
SWRL Rule ExamplehasParent(?x1,?x2) ∧ hasBrother(?x2,?x3) ⇒ hasUncle(?x1,?x3)
In abstract syntax:
Implies(Antecedent(hasParent(I-variable(x1) I-variable(x2)) hasBrother(I-variable(x2) I-variable(x3)))
Consequent(hasUncle(I-variable(x1) I-variable(x3))))
SWRL Rule ExampleArtist(?x) ∧ artistStyle(?x,?y) ∧ Style(?y) ∧ creator(?z,?x) ⇒
style/period(?z,?y)
Implies(Antecedent(Artist(I-variable(x)) artistStyle(I-variable(x) I-variable(y)) Style(I-variable(y)) creator(I-variable(z) I-variable(x)))
Consequent(style/period(I-variable(z) I-variable(y))))
SWRL Rule ExampleArtist(?x) ∧ (≤1 artistStyle)(?x) ∧ creator(?z,?x) ⇒
(≤1 style/period)(?z)
Implies(Antecedent(Artist(I-variable(x)) (restriction(artistStyle maxCardinality(1)))
(I-variable(x)) Style(I-variable(y)) creator(I-variable(z) I-variable(x)))
Consequent((restriction(style/period maxCardinality(1)) (I-variable(z))))
SWRL XML Syntax<ruleml:imp>
<ruleml:_rlab ruleml:href="#example1"/><ruleml:_body>
<swrlx:individualPropertyAtom swrlx:property="hasParent"> <ruleml:var>x1</ruleml:var><ruleml:var>x2</ruleml:var>
</swrlx:individualPropertyAtom><swrlx:individualPropertyAtom swrlx:property="hasBrother">
<ruleml:var>x2</ruleml:var><ruleml:var>x3</ruleml:var>
</swrlx:individualPropertyAtom> </ruleml:_body> <ruleml:_head>
<swrlx:individualPropertyAtom swrlx:property="hasUncle"> <ruleml:var>x1</ruleml:var><ruleml:var>x3</ruleml:var>
</swrlx:individualPropertyAtom> </ruleml:_head>
</ruleml:imp>
SWRL RDF Syntax<swrl:Variable rdf:ID="x1"/><swrl:Variable rdf:ID="x2"/><swrl:Variable rdf:ID="x3"/><ruleml:Imp>
<ruleml:body rdf:parseType="Collection”><swrl:IndividualPropertyAtom>
<swrl:propertyPredicate rdf:resource="⪚hasParent"/>
<swrl:argument1 rdf:resource="#x1" /><swrl:argument2 rdf:resource="#x2" />
</swrl:IndividualPropertyAtom><swrl:IndividualPropertyAtom>
<swrl:propertyPredicate rdf:resource="⪚hasSibling"/>
<swrl:argument1 rdf:resource="#x2" /><swrl:argument2 rdf:resource="#x3" />
</swrl:IndividualPropertyAtom></ruleml:body>…
Rule Interchange
Format
Rule Interchange Format•W3C Working Group chartered in late 2005
•More expressive language than SWRL– Common core with extensions
•Reached Recommendation in June 2010
Rule Interchange Format•Defines XML syntax and non-XML presentation syntax (c.f. OWL)
• Latest version from:http://www.w3.org/2005/rules/wiki/RIF_Working_Group
RIF DialectsTwo dialects (building on a common core):
•RIF Basic Logic Dialect– Monotonic condition and conclusion– Statements are either true or false– The values of predicates cannot be changed, you can only
add new staements
•RIF Production Rule Dialect– Non-monotonic condition and conclusion– Values of predicates can be changed
RIF Basic Logic Dialect•Definite Horn rules
– Disjunction with exactly one positive literal
A :- B and C and D
•N-ary predicates (sugared syntax)
RIF StructureRules occur in Groups:Group( (Forall ?x Q(?x) :- P(?x))
(Forall ?x Q(?x) :- R(?x)))
Groups occur in Documents:Document(
Group( (Forall ?x Q(?x) :- P(?x))(Forall ?x Q(?x) :- R(?x))
)Group( (Forall ?y R(?y) :- S(?y)) )
)
RIF ExampleDocument(
Prefix(cpt http://example.com/concepts#)Prefix(ppl http://example.com/people#)Prefix(bks http://example.com/books#)Group (
Forall ?Buyer ?Item ?Seller (cpt:buy(?Buyer ?Item ?Seller) :-
cpt:sell(?Seller ?Item ?Buyer))cpt:sell(ppl:John bks:LeRif ppl:Mary)
))
RIF ExampleDocument(
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( dbp:starring(?movie ?actor) rdfs:label(?movie ?mname) rdfs:label(?actor ?aname) )
))
RIF ExampleDocument(
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] )
))