Franz Inc
Module XIII: Extending OWL with Rules
Executive Overview of Semantic languages
Franz Inc
Semantic Web Layers
© Copyright 2011 Franz Inc. slide 1
Franz Inc
Why Go Beyond XML?
Issue Solution
Same word has two meanings XML
Namespaces
Describe what tags to use, how to use them (syntax) XML Schema
Manage distributed definitions and content RDF
Express relationships between elements RDFS
Express semantics for concepts, instances and relationships OWL
Manage evolution of schema and content OWL
© Copyright 2001-2007 TopQuadrant Inc., “TopMIND Training - Getting Ready for the Semantic Web”, slide 2
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!)
“A small amount of RDF goes a long way” – Jim Hendler
“subclass”, “domain”, “range”
“sameAs”, “differentFrom”, “equivalentClass”, “intersectionOf”, “unionOf”, “complementOf”, “disjointWith”
“cardinality”, “transitive”, “inverseOf”, “symmetricProperty”, “restriction”, “subPropertyOf”, “FunctionalProperty”, “InverseFunctionalProperty” “allValuesFrom”, “someValuesFrom”, “hasValue”, “oneOf” “DeprecatedClass”, “DeprecatedProperty”,” versionInfo”, “priorVersion, “backwardCompatibleWith”, “inCompatibleWith”
Franz Inc
How Semantic Languages Work Bring information together
Draw inferencesfor further processing
© Copyright 2001-2007 TopQuadrant Inc., “TopMIND Training - Getting Ready for the Semantic Web”, slide 3
RDF
RDFS
OWL
Franz Inc
What is RDF?
RDF (Resource Description Framework) is an infrastructure for:
Encoding,
Exchange and
Distributing metadata
© Copyright 2001-2007 TopQuadrant Inc., “TopMIND Training - Getting Ready for the Semantic Web”, slide 4
RDF Triple: Subject
Safety Harbor Object
Massage Predicate
offers
Franz Inc
RDF – A Distributed Network of Data!
© Copyright 2001-2007 TopQuadrant Inc., “TopMIND Training - Getting Ready for the Semantic Web”, slide 5
offeredBy
Safety Harbor Facial
offers Massage Safety Harbor offers Massage Facial offeredBy Safety Harbor RDF Files: “bags of triples” … …
Franz Inc
RDFS – A Schema Language for RDF RDFS allows us to create vocabularies
© Copyright 2001-2007 TopQuadrant Inc., “TopMIND Training - Getting Ready for the Semantic Web”, slide 6
offers Spa Resort rdfs:subClassOf Safety Harbor Massage Treatment Activity rdfs:subClassOf offers rdfs:domain rdf:type Franz Inc RDFS is RDF, Too!
© Copyright 2001-2007 TopQuadrant Inc., “TopMIND Training - Getting Ready for the Semantic Web”, slide 7
SafetyHarbor offers Massage offers rdfs:domain Safety Harbor rdfs:subClassOf Resort Spa Spa rdf:type Spa rdf:type Resort rdfs:subClassOf Safety Harbor Massage offers Treatment Activity rdfs:subClassOf rdf:type offers rdfs:domain rdfs:range If the bags contain RDFS key symbols, then RDFS can infer
certain conclusions …
…
Franz Inc
OWL – Specify Rich Relationships
© Copyright 2001-2007 TopQuadrant Inc., “TopMIND Training - Getting Ready for the Semantic Web”, slide 8
SafetyHarbor
Facial offers
offeredBy
Massage
offers owl:inverseOf offeredBy
offeredBy
offers
Franz Inc
The Kennedy Family
© Copyright 2011 Franz Inc. slide 9
Joseph Rose
Rosemary Kathleen Eunice Patricia Jean
Joseph Jr. John Robert Edward hasDaughter hasDaughter hasSon hasSon rdfs:domain Person Person rdfs:range FemalePerson FemalePerson rdfs:domain Person Person MalePerson MalePerson rdfs:range subPropertyOf hasDaughter
hasDaughter hasSonhasSon
Has Has--childchild
Franz Inc
© Copyright 2011 Franz Inc. slide 10
OWL vs. RDF vs. RDFS
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”
Franz Inc
© Copyright 2011 Franz Inc. slide 11
OWL vs. Other Schema (Data Model) Languages
XML schema is used to Validate Database schema is used to interpret RDF schema is used for inference Object Models define behavior OWL Model
Can have multiple uses
Franz Inc
Limitations of RDF, RDFS & OWL
Class definition and reasoning requiringnumerical 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
Franz Inc
Rules Complement RDF/RDFS/OWL
Franz Inc.
© Copyright 2011 Franz Inc. slide 1
Module XII – Extending OWL with Rules
Allegro RDF Prolog
Franz Inc.
Limitations of 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 2
Franz Inc.
Rules Complement RDF/RDFS/OWL
© Copyright 2011 Franz Inc. slide 3
Franz Inc.
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 4
Franz Inc.
Rules and RDF – SWRL
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
Franz Inc.
© Copyright 2011 Franz Inc. slide 6
SWRL Rules for Semantic Technology “IFa person has been CEO of a big, Fortune 500 company THENthis person is an important person”
Major:
(?company rdf:type BigCompany) (Fortune500 lists ?company) (?company hasCEO ?person) -> (?person rdf:type ImportantPerson)
Body
Head Rule name
2
Franz Inc.
OWL vs. SWRL
OWL SWRL
W3C Recommendation Not yet a standard Recent implementations >20 years technology Formal decidability Possibility of Spaghetti code Restriction language
highly constrained Powerful pattern language
© Copyright 2011 Franz Inc. slide 7
Franz Inc.
SPARQL vs. SWRL
SPARQL SWRL
Complex patterns with
?variables Complex patterns with ?variables Defaults, options, boolean
operations AND only
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
© Copyright 2011 Franz Inc. slide 8
Franz Inc.
Requirements for Rule Languages
Well-defined language semantics
Formal decidability
Expressive syntax
Standard based
Small set of composable logical operators
Flexibility, reusability …
Extensible syntax
Scalablility
Apply rules to very large data set (e.g., > 1 billion RDF triples)
© Copyright 2011 Franz Inc. slide 9
Franz Inc.
Well-defined
language semantics Yes
Small set of composable
logical operators Yes
Extensible syntax No
Scalablility No
Requirement
Requirement OWL scoreOWL score
The last two no’s deserve more discussion ...
OWL vs. Rule Requirements
© Copyright 2011 Franz Inc. slide 10
Franz Inc.
SPARQL vs. Rule Requirements
Well-defined language semantics
Procedural semantics for access language
Small set of composable
logical operators Kitchen sink
Extensible syntax Unfortunate choice of syntax
Scalablility Yes, SPARQL scales
Requirement
Requirement SPARQL hasSPARQL has
© Copyright 2011 Franz Inc. slide 11
Franz Inc.
Well-defined
language semantics Yes
Small set of composable
logical operators Yes
Extensible syntax Yes
Scalablility For subsets
Requirement
Requirement CL (Prolog) scoreCL (Prolog) score
CL / Prolog vs. Rule Requirements
Franz Inc.
Semantic RDF Database Needs …
A Simple QUERY language
An efficient and easy to understand
mechanism for RULES
A server based PROGRAMMING
LANGUAGE
Franz Inc.
Does SPARQL Qualify?
SPARQL is an access language, no rules, no
programming.
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)
Franz Inc.
Prolog Almost Qualify
Query language + Rules + Full programming
language + a Standard language
And very fast:
AllegroGraph RDFS++ reasoner is implemented
in Prolog
For 1.1 Billion triples for the Leheigh University Benchmark: 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 12 34 5678 910 11 12 13 14 S e c o n d s Queries
LUBM(8000) with long queries zeroed
A lleg roGraph 3.2 Othe r
Franz Inc.
PROLOG
AllegroGraph Rule Language
© Copyright 2011 Franz Inc. slide 16
Franz Inc.
Prolog Rule – Based On Unification
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)
+, appendand memberare functions
A Prolog functorwill try to unify the
“input” and “output” arguments
(?- (append (1 3) (5) ?z)) (?- (member ?x (1 3 5))) © Copyright 2011 Franz Inc. slide 17
Franz Inc.
Prolog Functor: append
(?- (append ?x ?y (1 3 5))) ?x = () ?y = (1 3 5); ?x = (1) ?y = (3 5); ?x = (1 3) ?y = (5); ?x = (1 3 5) ?y = (); No. (?- (append (1 3) (5) ?z)) ?z = (1 3 5); No. (?- (append (1) ?y (?x 3 5))) ?y = (3 5) ?x = 1; No.
4
Franz Inc.
Prolog Functor: member
(?- (member ?x (1 3 5))) ?x = 1; ?x = 3; ?x = 5; No. (?- (member 1 (?x 3 5))) ?x = 1; No. (?- (member (1 ?x) ((?y 3) 5))) ?x = 3 ?y = 1; No.
© Copyright 2011 Franz Inc. slide 19
Franz Inc.
© Copyright 2011 Franz Inc. slide 20
Allegro Prolog as Query Language
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
Franz Inc.
© Copyright 2011 Franz Inc. slide 21
Basic Allegro Prolog Syntax for RDF
The functor q-&qtells RDF Prolog to look
for data for variable unification in the AllegroGraph triple database
q- only search the original triples q include inferred triples in the search
By convention, all Prolog variables start
with a “?”, e.g., ?company, ?person, to separate them from Lisp variables
Franz Inc.
Encapsulated / Federated Encapsulated / Federated
RDF Database RDF Database
© Copyright 2011 Franz Inc. slide 22
Allegro Prolog Query Language
A very expressive query language, finding
semantic relations in RDF database automatically Query can be applied to inferred RDF triples,
combining with semantic reasoning
Asserted RDF Triples Inferred RDF Triples RDFS++ Reasoning Prolog Query Engine
Semantic Applications
Franz Inc.
selectWrapper in Lisp
(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)) (({person1}))
© Copyright 2011 Franz Inc. slide 23
Franz Inc.
© Copyright 2011 Franz Inc. slide 24
Allegro Prolog as Rule Language
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
Franz Inc.
© Copyright 2011 Franz Inc. slide 25
Rule in SWRL and Allegro Prolog
Rule in SWRL
Major:
(?company rdf:type BigCompany) (Fortune500 lists ?company) (?company hasCEO ?person) -> (?person rdf:type ImportantPerson)
Rule in Prolog (1) Rule in Prolog (1)
(<-- (ImportantPerson ?person) (q ?company rdf:type BigCompany) (q Fortune500 lists ?company) (q ?company hasCEO ?person) )
Rule in Prolog (2) Rule in Prolog (2)
(<-- (MajorCompany ?company) (q ?company rdf:type BigCompany) (q Fortune500 lists ?company) ) (<-- (ImportantPerson ?person)
(MajorCompany ?company) (q ?company hasCEO ?person) )
Franz Inc.
The Kennedy Family
© Copyright 2011 Franz Inc. slide 26
Joseph Rose
Rosemary Kathleen Eunice Patricia Jean
Joseph Jr. John Robert Edward
hasDaughter hasDaughter hasSon hasSon rdfs:domain Person Person rdfs:range FemalePerson FemalePerson rdfs:domain Person Person MalePerson MalePerson rdfs:range subPropertyOf hasDaughter
hasDaughter hasSonhasSon Has Has--childchild
Franz Inc.
© Copyright 2011 Franz Inc. slide 27 (<-- (male ?x) (q- ?x !ex:sex !ex:male)) (<-- (female ?x) (q- ?x !ex:sex !ex:female)) (<-- (father ?x ?y) (male ?x) (q ?x !ex:has-child ?y)) (<-- (mother ?x ?y) (female ?x) (q ?x !ex:has-child ?y)) (<-- (parent ?x ?y) (father ?x ?y)) (<- (parent ?x ?y) (mother ?x ?y)) (<-- (grandparent ?x ?y) (parent ?x ?z) (parent ?z ?y)) (<-- (grandchild ?x ?y) (grandparent ?y ?x)) (<-- (ancestor ?x ?y) (parent ?x ?y)) (<- (ancestor ?x ?y) (parent ?x ?z) (ancestor ?z ?y)) (<-- (descendent ?x ?y) (ancestor ?y ?x)) Building Semantic Relations with RDF Prolog on RDF Database
Franz Inc.
© Copyright 2011 Franz Inc. slide 28
Building Complex Semantic Relations (<-- (aunt ?x ?y) (parent ?z ?x) (female ?x) (parent ?z ?w) (not(=?x ?w)) (parent ?w ?y)) (<-- (niece ?x ?y) (aunt ?y ?x) (female ?x)) (<- (niece ?x ?y) (uncle ?y ?x) (female ?x)) ?Z ?Y ?X ?W parent parent parent aunt (<-- (uncle ?x ?y) (parent ?z ?x) (male ?x) (parent ?z ?w) (not (= ?x ?w)) (parent ?w ?y)) (<-- (nephew ?x ?y) (aunt ?y ?x) (male ?x)) (<- (nephew ?x ?y) (uncle ?y ?x) (male ?x)) Franz Inc.
© Copyright 2011 Franz Inc. slide 29
“Semantic” Rule Inference
Allegro Prolog rules can be applied to inferred RDF triples, combining rule inference and
semantic reasoning Encapsulated / Federated Encapsulated / Federated RDF Database RDF Database Asserted RDF Triples Inferred RDF Triples RDFS++ Reasoning Prolog Rule Engine
Semantic Applications
Prolog Rules
Franz Inc.
© Copyright 2011 Franz Inc. slide 30
Interact with AllegroGraph Database
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
6
Franz Inc.
© Copyright 2011 Franz Inc. slide 31
Execute Lisp Code inside Prolog
(lisparg form) : Execute Lisp form(code) inside Prolog, the result of executing the
formis returned to Prolog variable, arg
(lispform) : For side effect only
(lisppform): unified if formreturns “true”
(select (?name ?birth-year) (q- ?person rdfs:label ?name) (q- ?person :birth-year ?birth-year) (lispp (>= (read-from-string
(upi->value ?birth-year)) 1965) ) )
Franz Inc.
© Copyright 2011 Franz Inc. slide 32
Execute Prolog Rules Inside Lisp
(prolog…) : invoke prolog inside Lisp code
(lisparg form) : Execute Lisp code inside
Prolog, the result is returned to arg
(lispform) : For side effect only
(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))
Franz Inc.
© Copyright 2011 Franz Inc. slide 33
RDF Prolog Exercise
Using Allegro Prolog in AllegroGraph
Using Prolog query and rules on Kennedy
database
Franz Inc.
Use Prolog to Find Maria Shriver & Her Birth Year
(select (?p ?year)
(lisp ?name (literal "Maria Shriver ")) (q- ?p !rdfs:label ?name)
(q- ?p !ex:birth-year ?year))
© Copyright 2011 Franz Inc. slide 34
Assuming that the data has NOT been normalize Use lispfunctor to bind a value from Lisp to Prolog
Franz Inc.
Find All Ancestors of Maria Shriver (select (?name)
(lisp ?y !ex:person26) (ancestor ?x ?y)
(q- ?x !rdfs:label ?name))
© Copyright 2011 Franz Inc. slide 35
(select (?name) (:distinct t) (lisp ?y !ex:person26) (ancestor ?x ?y) (q- ?x !rdfs:label ?name)) Franz Inc.
Find All Ancestors of Maria Shriver (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)
Franz Inc.
Find Nieces of Edward Kennedy (select (?niece ?name)
(lisp ?edward (literal "Edward Kennedy ")) (q- ?p !rdfs:label ?edward)
(niece ?niece ?p)
(q- ?niece !rdfs:label ?name))
© Copyright 2011 Franz Inc. slide 37
Franz Inc.
Find Old Men (borne before 1950) in Kennedy Family (<-- (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 38
Franz Inc.
Old Living Men 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))
(lispp (< (read-from-string (upi->value ?birth-year)) 1950)) )
(select (?name) (OldMan ?x)
(q- ?x !rdfs:label ?name) )
© Copyright 2011 Franz Inc. slide 39
<- Negation
Franz Inc.
Young Men (borne after 1965) in Kennedy Family
(<-- (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 40
Franz Inc.
Expressive Logics are Coming to RDF
SPARQL OWL
First Order Logic Logic Programs Common Logic, Prolog
SILK RIF
RDF
© Copyright 2011 Franz Inc. slide 41
No Semantics
Franz Inc.
Franz Rule Language
Rule language for AllegroGraph RDF store
Has expressive syntax – CLIF (Common
Logic Interchange Format)
Has a well-defined, constructive semantics
Aligns as much as possible with an existing
8
Franz Inc. Prefix CLIF Infix CLIF SPARQL ACL Prolog Translator CLIF Translator Franz Inc. Events Container Container Actions Decision Engine “Sesame” AllegroGraph Triple Store DB Event Ingestion Scheduled Events Inference Engine Business Business Rules Rules Bayesian Belief Network Events Events CRM Operational Systems Operational SystemsEvent Data Sources Event Data Sources
Amdocs Event Collector Work Bench CRM RM Amdocs Integration Framework OMS NW Web 2.0
Amdocs Intelligent Decision Automation
© Copyright Franz Inc. slide 44
Trillion Triples
Franz Inc.
Copyright Franz Inc. 45
Franz Inc.
Dr. Sheng-Chuan Wu
[email protected] Thank You