Document 244816

Franz Inc
Franz Inc
Semantic Web Layers
Module XIII: Extending OWL with Rules
Executive Overview of Semantic languages
© Copyright 2011 Franz Inc. slide 1
Franz Inc
Franz Inc
How Semantic Languages Work
Why Go Beyond XML?
Issue
Solution
XML
Namespaces
Same word has two meanings
Suppliers and Consumers agree on what tags to use (maybe)
Suppliers and Consumers agree on what tags mean (less likely)
Each item is described by only one supplier (sure!)
Describe what tags to use, how to use them (syntax)
XML Schema
Manage distributed definitions and content
RDF
Bring information together
Draw inferences for further processing
“A small amount of RDF goes a long way” – Jim Hendler
RDFS
Express relationships between elements
“subclass”, “domain”, “range”
Express semantics for concepts, instances and relationships
“sameAs”, “differentFrom”, “equivalentClass”, “intersectionOf”, “unionOf”,
“complementOf”, “disjointWith”
“cardinality”, “transitive”, “inverseOf”, “symmetricProperty”, “restriction”,
“subPropertyOf”, “FunctionalProperty”, “InverseFunctionalProperty”
“allValuesFrom”, “someValuesFrom”, “hasValue”, “oneOf”
OWL
RDF
OWL
RDFS
OWL
Manage evolution of schema and content
“DeprecatedClass”, “DeprecatedProperty”,” versionInfo”,
“priorVersion, “backwardCompatibleWith”, “inCompatibleWith”
© Copyright 2001-2007 TopQuadrant Inc., “TopMIND Training - Getting Ready for the Semantic Web”, slide 2
Franz Inc
© Copyright 2001-2007 TopQuadrant Inc., “TopMIND Training - Getting Ready for the Semantic Web”, slide 3
Franz Inc
What is RDF?
RDF – A Distributed Network of Data!
RDF (Resource Description Framework) is
an infrastructure for:
Encoding,
Exchange and
Distributing metadata
Safety Harbor
offers
Facial
…
offeredBy
…
Safety Harbor
Massage
RDF Triple:
Subject
Safety Harbor
Predicate
Safety Harbor
RDF Files: “bags
of triples”
Object
offers
offeredBy
Facial
offers
Massage
Massage
© Copyright 2001-2007 TopQuadrant Inc., “TopMIND Training - Getting Ready for the Semantic Web”, slide 4
© Copyright 2001-2007 TopQuadrant Inc., “TopMIND Training - Getting Ready for the Semantic Web”, slide 5
1
Franz Inc
Franz Inc
RDFS – A Schema Language for RDF
RDFS is RDF, Too!
RDFS allows us to create vocabularies
Activity
Resort
rdfs:subClassOf
rdfs:subClassOf
rdfs:subClassOf
rdfs:domain
…
Massage
Treatment
Spa
rdf:type
Spa
offers
offers
…
If the bags contain
RDFS key symbols,
then RDFS can infer
certain conclusions
Resort
SafetyHarbor
offers
rdfs:domain
Safety Harbor
Activity
Resort
rdfs:subClassOf
rdfs:subClassOf
Safety Harbor
Treatment
Spa
offers
rdf:type
Massage
offers
rdfs:domain
Safety Harbor
rdfs:range
rdf:type
offers
© Copyright 2001-2007 TopQuadrant Inc., “TopMIND Training - Getting Ready for the Semantic Web”, slide 6
Spa
rdf:type
Massage
© Copyright 2001-2007 TopQuadrant Inc., “TopMIND Training - Getting Ready for the Semantic Web”, slide 7
Franz Inc
Franz Inc
OWL – Specify Rich Relationships
The Kennedy Family
offers
MalePerson
rdfs:domain
SafetyHarbor
offeredBy
offeredBy
Facial
Joseph
offers
hasSon
rdfs:range
Person
Rose
hasDaughter
rdfs:range
rdfs:domain
Massage
FemalePerson
Person
Joseph Jr.
John
Robert
Edward
HasHas
-child
offers owl:inverseOf offeredBy
subPropertyOf
Rosemary
Kathleen
Eunice
© Copyright 2001-2007 TopQuadrant Inc., “TopMIND Training - Getting Ready for the Semantic Web”, slide 8
Franz Inc
Patricia
hasDaughter
hasSon
Jean
© Copyright 2011 Franz Inc. slide 9
Franz Inc
OWL vs. RDF vs. RDFS
OWL vs. Other Schema (Data Model) Languages
OWL and RDFS add no syntax to RDF
RDF allows symbols from any package
RDFS uses symbols from the RDFS package
OWL uses symbols from the OWL package
Syntactically, RDF = RDFS = OWL
“The difference is in the inference”
© Copyright 2011 Franz Inc. slide 10
RDF schema is used
for inference
Database schema is
used to interpret
OWL Model
Can have multiple
uses
XML schema
is used to
Validate
Object Models
define behavior
© Copyright 2011 Franz Inc. slide 11
© Copyright 2011 Franz Inc. slide 11
2
Franz Inc
Limitations of RDF, RDFS & OWL
Franz Inc
Rules Complement RDF/RDFS/OWL
Class definition and reasoning requiring
numerical computation
For example, VIP customers are those that spent over
$1,000 across all purchases in the last 3 months
For example, a young man is a MalePerson who is less than
20 years old.
Classification of an individual depends on
examining specific relationships between 2
or more other individuals:
For example, city’s first lady is a wife of city’s mayor. Mr.
Bloomberg is New York’s mayor. Mrs. Bloomberg is his
wife. Is Mrs. Bloomberg New York’s first lady?
© Copyright 2011 Franz Inc. slide 12
© Copyright 2011 Franz Inc. slide 13
3
Franz Inc.
Franz Inc.
Limitations of RDF, RDFS & OWL
Class definition and reasoning requiring
numerical computation
Module XII – Extending OWL with Rules
Allegro RDF Prolog
For example, VIP customers are those that spent over
$1,000 across all purchases in the last 3 months
For example, a young man is a MalePerson who is less than
20 years old.
Classification of an individual depends on
examining specific relationships between 2
or more other individuals:
For example, city’s first lady is a wife of city’s mayor. Mr.
Bloomberg is New York’s mayor. Mrs. Bloomberg is his
wife. Is Mrs. Bloomberg New York’s first lady?
© Copyright 2011 Franz Inc. slide 1
© Copyright 2011 Franz Inc. slide 2
Franz Inc.
Franz Inc.
Rules Complement RDF/RDFS/OWL
Rules Technology
Venerable tradition
Expert Systems (1970’s and 1980’s)
Rules embedded in application code
Not scalable, extendable, maintainable, …
Business Rules
Datalog (DATAbase LOGic)
Sophisticated algorithms (RETE, Magic Sets)
SWRL – a rule exchange language in RDF
© Copyright 2011 Franz Inc. slide 3
© Copyright 2011 Franz Inc. slide 4
Franz Inc.
Franz Inc.
Rules and RDF – SWRL
SWRL Rules for Semantic Technology
Rules can be distributed just like anything
else
Therefore, rules can be expressed in RDF
SWRL (Semantic Web Rule Language) is a
representation of rules in RDF
© Copyright 2011 Franz Inc. slide 5
“IF a person has been CEO of a big, Fortune 500 company
THEN this person is an important person”
Rule name
Body
Major:
(?company rdf:type BigCompany)
(Fortune500 lists ?company)
(?company hasCEO ?person)
Head
-> (?person rdf:type ImportantPerson)
© Copyright 2011 Franz Inc. slide 6
1
Franz Inc.
Franz Inc.
OWL vs. SWRL
SPARQL vs. SWRL
SPARQL
OWL
SWRL
Complex patterns with
?variables
Complex patterns with
?variables
>20 years technology
Defaults, options, boolean
operations
AND only
Possibility of Spaghetti
code
Filters with math
SWRL built-ins for math
Run under user/program
control
chaining opportunistically
Optimized for a single
query
Optimized for groups of rules
W3C Recommendation
Not yet a standard
Recent implementations
Formal decidability
Restriction language
highly constrained
SWRL
Powerful pattern
language
© Copyright 2011 Franz Inc. slide 7
© Copyright 2011 Franz Inc. slide 8
Franz Inc.
Franz Inc.
Requirements for Rule Languages
OWL vs. Rule Requirements
Well-defined language semantics
Formal decidability
Expressive syntax
Standard based
Requirement
OWL score
Well-defined
language semantics
Yes
Small set of composable
logical operators
Yes
Extensible syntax
No
Scalablility
No
Small set of composable logical operators
Flexibility, reusability …
Extensible syntax
Scalablility
Apply rules to very large data set (e.g.,
> 1 billion RDF triples)
The last two no’s deserve more discussion ...
© Copyright 2011 Franz Inc. slide 9
© Copyright 2011 Franz Inc. slide 10
Franz Inc.
Franz Inc.
SPARQL vs. Rule Requirements
CL / Prolog vs. Rule Requirements
Requirement
SPARQL has
Requirement
Well-defined
language semantics
Procedural semantics
for access language
Well-defined
language semantics
Yes
Small set of composable
logical operators
Kitchen sink
Small set of composable
logical operators
Yes
Extensible syntax
Unfortunate choice of syntax
Extensible syntax
Yes
Scalablility
For subsets
Scalablility
Yes, SPARQL scales
© Copyright 2011 Franz Inc. slide 11
CL (Prolog) score
© Copyright 2011 Franz Inc. slide 12
2
Franz Inc.
Franz Inc.
Semantic RDF Database Needs …
Does SPARQL Qualify?
SPARQL is an access language, no rules, no
programming.
A Simple QUERY language
No defined way to deal with rules
2+ arity is hell, needs ‘magic predicates’ to help
Negation is hard
Filters should go, replaced by magic predicates
Datatype handling is bizarre
No way to deal with unpredictable path lengths
(yes, they are working on this)
An efficient and easy to understand
mechanism for RULES
A server based PROGRAMMING
LANGUAGE
Franz Inc.
Franz Inc.
Prolog Almost Qualify
Query language + Rules + Full programming
language + a Standard language
And very fast:
Seconds
AllegroGraph RDFS++ reasoner is implemented
in Prolog
For 1.1 Billion triples for the Leheigh University
Benchmark:
LUBM(8000) with long queries zeroed
1
0.9
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
AllegroGraph Rule Language
PROLOG
Alleg roGraph 3.2
Othe r
1
2
3
4
5
6
7
8
9 10 11 12 13 14
Queries
© Copyright 2011 Franz Inc. slide 16
Franz Inc.
Franz Inc.
Prolog Rule – Based On Unification
Prolog Functor: append
A function call returns an output value
based on the input supplied
(+ 1 (* 2 3) 4) => 11
(append ‘(1 3) ‘(5)) => (1 3 5)
(member 3 '(1 3 5)) => (3 5)
+, append and member are functions
A Prolog functor will try to unify the
“input” and “output” arguments
(?- (append (1 3) (5) ?z))
(?- (member ?x (1 3 5)))
© Copyright 2011 Franz Inc. slide 17
(?- (append (1 3) (5) ?z))
?z = (1 3 5);
(?- (append ?x ?y (1 3 5)))
?x = ()
?y = (1 3 5);
No.
?x = (1)
?y = (3 5);
(?- (append (1) ?y (?x 3 5)))
?y = (3 5)
?x = 1;
No.
?x = (1 3)
?y = (5);
?x = (1 3 5)
?y = ();
No.
© Copyright 2011 Franz Inc. slide 18
3
Franz Inc.
Franz Inc.
Prolog Functor: member
Allegro Prolog as Query Language
(?- (member ?x (1 3 5)))
(?- (member 1 (?x 3 5)))
?x = 1;
?x = 1;
No.
?x = 3;
(?- (member (1 ?x) ((?y 3) 5)))
?x = 5;
?x = 3
?y = 1;
No.
No.
© Copyright 2011 Franz Inc. slide 19
Unify over RDF database with q functor
(q ?person rdf:type :Patriarch)
A much more powerful query language for
RDF triples, more versatile than SPARQL
An industrial strength Prolog embedded in
Allegro CL, geared to RDF query
Conform to Clocksin & Mellishs Prolog and
ISO kernel specification
Prolog clauses are compiled to Lisp then
to machine code, running at processor
speed
© Copyright 2011 Franz Inc. slide 20
Franz Inc.
Franz Inc.
Basic Allegro Prolog Syntax for RDF
Allegro Prolog Query Language
The functor q- & q tells RDF Prolog to look
for data for variable unification in the
AllegroGraph triple database
q- only search the original triples
A very expressive query language, finding
semantic relations in RDF database automatically
Query can be applied to inferred RDF triples,
combining with semantic reasoning
q include inferred triples in the search
Semantic Applications
By convention, all Prolog variables start
with a “?”, e.g., ?company, ?person, to
separate them from Lisp variables
Encapsulated / Federated
RDF Database
Prolog Query Engine
Asserted
RDF
Triples
© Copyright 2011 Franz Inc. slide 21
RDFS++
Reasoning
Inferred
RDF
Triples
© Copyright 2011 Franz Inc. slide 22
Franz Inc.
Franz Inc.
select Wrapper in Lisp
Allegro Prolog as Rule Language
(select … ) returns the values of unified
variables in a list, for further processing
by application code
(select (?x ?y)
(append ?x ?y (1 3 5)))
(("nil" (1 3 5))
((1) (3 5))
((1 3) (5))
((1 3 5) "nil"))
(select (?person)
(q- ?person rdf:type :Patriarch))
Assert a fact or rule
<-- clause : (<-- (ImportantPerson ?person) … )
starts a new rule
<- clause : (<- (ImportantPerson ?person) … )
add to the rule
Iteratively prove the concatenation of
clauses
(select ?person (ImportantPerson ?person) )
Allegro Prolog will look for data (maybe in RDF
database) that unifies the variables and
satisfies ALL the clauses
(({person1}))
© Copyright 2011 Franz Inc. slide 23
© Copyright 2011 Franz Inc. slide 24
4
Franz Inc.
Franz Inc.
Rule in SWRL and Allegro Prolog
The Kennedy Family
Rule in SWRL
MalePerson
Major:
(?company rdf:type BigCompany)
(Fortune500 lists ?company)
(?company hasCEO ?person)
-> (?person rdf:type ImportantPerson)
rdfs:domain
Joseph
hasSon
hasDaughter
rdfs:range
rdfs:domain
Rule in Prolog (2)
Rule in Prolog (1)
(<-- (MajorCompany ?company)
(<-- (ImportantPerson ?person)
(q ?company
rdf:type
BigCompany)
(q ?company
rdf:type
BigCompany)
(q Fortune500
?company) )
(q Fortune500
listslists
?company)
(<--?company
(ImportantPerson
?person))
(q
hasCEO ?person)
(MajorCompany ?company)
(q ?company hasCEO ?person) )
FemalePerson
Person
Joseph Jr.
John
Robert
HasHas
-child
subPropertyOf
Rosemary
Kathleen
Eunice
Patricia
hasDaughter
hasSon
Jean
Franz Inc.
Franz Inc.
Building Semantic Relations with RDF
Prolog on RDF Database
Building Complex Semantic Relations
(<-- (grandparent ?x ?y)
(parent ?x ?z)
(parent ?z ?y))
(<-- (male ?x)
(q- ?x !ex:sex !ex:male))
(<-- (female ?x)
(q- ?x !ex:sex !ex:female))
(<-- (grandchild ?x ?y)
(grandparent ?y ?x))
(<-- (father ?x ?y)
(male ?x)
(q ?x !ex:has-child ?y))
(<-- (ancestor ?x ?y)
(parent ?x ?y))
(<-- (mother ?x ?y)
(female ?x)
(q ?x !ex:has-child ?y))
(<- (ancestor ?x ?y)
(parent ?x ?z)
(ancestor ?z ?y))
(<-- (parent ?x ?y)
(father ?x ?y))
(<-- (descendent ?x ?y)
(ancestor ?y ?x))
(<- (parent ?x ?y)
(mother ?x ?y))
© Copyright 2011 Franz Inc. slide 27
(<-- (aunt ?x ?y)
(parent ?z ?x)
(female ?x)
(parent ?z ?w)
(not (= ?x ?w))
(parent ?w ?y))
(<-- (uncle ?x ?y)
(parent ?z ?x)
(male ?x)
(parent ?z ?w)
(not (= ?x ?w))
(parent ?w ?y))
?Z
parent
parent
?X
?W
aunt
parent
?Y
(<-- (nephew ?x ?y)
(aunt ?y ?x)
(male ?x))
(<-- (niece ?x ?y)
(aunt ?y ?x)
(female ?x))
(<- (nephew ?x ?y)
(uncle ?y ?x)
(male ?x))
(<- (niece ?x ?y)
(uncle ?y ?x)
(female ?x))
© Copyright 2011 Franz Inc. slide 28
Franz Inc.
Franz Inc.
“Semantic” Rule Inference
Interact with AllegroGraph Database
Allegro Prolog rules can be applied to inferred
RDF triples, combining rule inference and
semantic reasoning
Semantic Applications
Prolog Rule Engine
Encapsulated / Federated
RDF Database
Asserted
RDF
Triples
© Copyright 2011 Franz Inc. slide 29
Edward
© Copyright 2011 Franz Inc. slide 26
© Copyright 2011 Franz Inc. slide 25
Prolog
Rules
rdfs:range
Person
Rose
RDFS++
Reasoning
Inferred
RDF
Triples
All “data” values stored in the DB as UPI’s;
convert to its original value with lisp
function upi->value, e.g.,
(upi->value ?birth-year)
Data need to be converted to UPI before
it can be compared with db values, e.g.,
(literal “Maria Shriver“)
Use (read-from-string …) to convert a
string (come out of DB) to its native type
© Copyright 2011 Franz Inc. slide 30
5
Franz Inc.
Franz Inc.
Execute Lisp Code inside Prolog
Execute Prolog Rules Inside Lisp
(lisp arg form) : Execute Lisp form (code)
inside Prolog, the result of executing the
form is returned to Prolog variable, arg
(prolog …) : invoke prolog inside Lisp code
(lisp form) : For side effect only
(lisp form) : For side effect only
(lispp form): unified if form returns “true”
(lisp arg form) : Execute Lisp code inside
Prolog, the result is returned to arg
(defun animal-friends-of (person)
(let ((list-friends nil))
(prolog
(lisp ?person person)
(q ?person :likes ?x)
(q ?x rdf:type :animal)
(lisp (pushnew ?x list-friends)))
list-friends))
(select (?name ?birth-year)
(q- ?person rdfs:label ?name)
(q- ?person :birth-year ?birth-year)
(lispp (>= (read-from-string
(upi->value ?birth-year)) 1965) )
)
© Copyright 2011 Franz Inc. slide 31
© Copyright 2011 Franz Inc. slide 32
Franz Inc.
Franz Inc.
RDF Prolog Exercise
Use Prolog to Find Maria Shriver &
Her Birth Year
Using Allegro Prolog in AllegroGraph
Using Prolog query and rules on Kennedy
database
(select (?p ?year)
(lisp ?name (literal "Maria Shriver "))
(q- ?p !rdfs:label ?name)
(q- ?p !ex:birth-year ?year))
Assuming that the data has NOT been normalize
Use lisp functor to bind a value from Lisp to Prolog
© Copyright 2011 Franz Inc. slide 34
© Copyright 2011 Franz Inc. slide 33
Franz Inc.
Franz Inc.
Find All Ancestors of Maria Shriver
Find All Ancestors of Maria Shriver
(select (?name)
(lisp ?y !ex:person26)
(ancestor ?x ?y)
(q- ?x !rdfs:label ?name))
(select (?name)
(:distinct t)
(lisp ?y !ex:person26)
(ancestor ?x ?y)
(q- ?x !rdfs:label ?name))
© Copyright 2011 Franz Inc. slide 35
(let ((anc nil)
(anc-list nil))
(setq anc (select (?name)
(lisp ?y !ex:person26)
(ancestor ?x ?y)
(q- ?x !rdfs:label ?name)))
(dolist (e anc)
(pushnew (first e) anc-list))
anc-list)
© Copyright 2011 Franz Inc. slide 36
6
Franz Inc.
Franz Inc.
Find Nieces of Edward Kennedy
Find Old Men (borne before 1950) in
Kennedy Family
(select (?niece ?name)
(lisp ?edward (literal "Edward Kennedy "))
(q- ?p !rdfs:label ?edward)
(niece ?niece ?p)
(q- ?niece !rdfs:label ?name))
(<-- (old-kennedy ?x)
(male ?x)
(q- ?x !ex:birth-year ?year)
(lispp (< (read-from-string
(upi->value ?year)) 1950)))
(select (?name)
(old-kennedy ?x)
(q- ?x !rdfs:label ?name))
© Copyright 2011 Franz Inc. slide 37
© Copyright 2011 Franz Inc. slide 38
Franz Inc.
Franz Inc.
Old Living Men in Kennedy Family
Young Men (borne after 1965) in
Kennedy Family
(<-- (OldMan ?person)
(q- ?person !ex:birth-year ?birth-year)
(q ?person !rdf:type !ex:MalePerson)
(not (q ?person !ex:death-year ?death-year)) <- Negation
(lispp (< (read-from-string (upi->value ?birth-year)) 1950))
)
(select (?name)
(OldMan ?x)
(q- ?x !rdfs:label ?name)
)
(<-- (YoungMan ?person)
(q- ?person !ex:birth-year ?birth-year)
(q ?person !rdf:type !ex:MalePerson)
(lispp (>= (read-from-string
(upi->value ?birth-year)) 1965))
)
(select (?name)
(YoungMan ?x)
(q- ?x !rdfs:label ?name)
)
© Copyright 2011 Franz Inc. slide 39
© Copyright 2011 Franz Inc. slide 40
Franz Inc.
Franz Inc.
Expressive Logics are Coming to RDF
Franz Rule Language
Rule language for AllegroGraph RDF store
Common Logic, Prolog
First Order Logic
RIF
SILK
Logic
Programs
OWL
No
Semantics
Has expressive syntax – CLIF (Common
Logic Interchange Format)
Has a well-defined, constructive semantics
Aligns as much as possible with an existing
or emerging RDF standard
SPARQL
RDF
© Copyright 2011 Franz Inc. slide 41
7
Franz Inc.
Franz Inc.
CLIF Translator
Amdocs Intelligent Decision Automation
Events
Decision Engine
Container
Container
Amdocs
Event Collector
Prefix CLIF
Event
Ingestion
SPARQL
Events
Translator
Infix CLIF
Scheduled
Events
ACL Prolog
RM
CRM
Inference
Engine
Business
Rules
OMS
“Sesame”
NW
Actions
Amdocs
Integration
Framework
Bayesian
Belief
Network
CRM
Work
Bench
Operational Systems
Web 2.0
Event Data Sources
AllegroGraph
Triple Store DB
Trillion Triples
© Copyright Franz Inc. slide 44
Franz Inc.
Thank You
Franz Inc.
Dr. Sheng-Chuan Wu
[email protected]
Copyright Franz Inc.
45
8