Outline
- Where RIF Came From
- What RIF Is (Rule Interchange Format)
- Extending RIF
- Why the Semantic Web Needs RIF
What is a Rule?
- Logic programming (LP), from Prolog (early 70s)
- Production Rules (PR), OPS5/Rete (late 70s)
- Automated Theorem Proving (ATP), (resolution, 1965)
- app-specific rule systems (eg mail handling, access control)
- Business Rules
- not natural language rules
A way of programming, and a way of not programming
Semantic Web Perspective
What does RIF do for the Semantic Web?
- A companion to RDFS and OWL -- another logic
- Can express different kinds of things
- A different way of thinking -- which many people want
- Data integration, ontology mapping, ad hoc reasoning
- ... even data processing (N3)
Business Rules Perspective
Thinking in terms of the business
- reduce vendor lock-in (portability)
- coordinating businesses, eg in a supply chain
- integrated decision support, eg in medical decisions
Diversity
Simplicity vs Research
- Different traditions
- Different technologies
- Different kinds of problems
- Different people
Dream vs Reality
The Plan
Start with a common core
- Find out what rule systems have in common (60%)
- Standardize that ("RIF Core")
- Then work on extensions
Core must be truly extensible
More Details
Focus on translating to/from RIF
- So it's fine to be verbose XML
- Nothing very pretty, for humans
- Implementation burden is on translators
- Not necessary rule engine maintainers
Extensions may be incompatible
- Dialect == group of extensions that work well together
- Some standard, some non-standard
"Rule Interchange Format", not "Semantic Web Rule Language"
Timeline
- RuleML initiative, TimBL's cwm/n3 (Fall 2000)
- W3C Submissions (2004-2005): SWRL, SWRL-FOL, SWSL, WRL
- Workshop (April 2005), ~80 people
- F2F1 (December 2005) ~50 people
- Use Cases and Requirements (2006)
- F2F5, RIF Core WD1 (2007 Q1) ~ 20 people
- Production Rules, Builtins, etc (2008)
- F2F13, RIF Last Call (July 2009) ~ 15 people
- Candidate Recommendation (October 2009)
- W3C Recommendation (June 2010)
Community
- Business rules vendors
- ILOG [now IBM] (chair), Fair Isaac, Oracle, TIBCO, JBoss...
- Commercial Research
- Non-Commercial Research
- NRC, Bolzano, DERI, MITRE, REWERSE, ...
- ... others
RIF: XML Syntax for Rules
<!DOCTYPE Document [
<!ENTITY ppl "http://example.com/people#">
<!ENTITY cpt "http://example.com/concepts#">
<!ENTITY dc "http://purl.org/dc/terms/">
<!ENTITY rif "http://www.w3.org/2007/rif#">
<!ENTITY func "http://www.w3.org/2007/rif-builtin-function#">
<!ENTITY pred "http://www.w3.org/2007/rif-builtin-predicate#">
<!ENTITY xs "http://www.w3.org/2001/XMLSchema#">
]>
<Document
xmlns="http://www.w3.org/2007/rif#"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xs="http://www.w3.org/2001/XMLSchema#">
<payload>
<Group>
<id>
<Const type="&rif;iri">http://sample.org</Const>
</id>
<meta>
<Frame>
<object>
<Const type="&rif;local">pd</Const>
</object>
<slot ordered="yes">
<Const type="&rif;iri">&dc;publisher</Const>
<Const type="&rif;iri">http://www.w3.org/</Const>
</slot>
<slot ordered="yes">
<Const type="&rif;iri">&dc;date</Const>
<Const type="&xs;date">2008-04-04</Const>
</slot>
</Frame>
</meta>
<sentence>
<Forall>
<declare><Var>item</Var></declare>
<declare><Var>deliverydate</Var></declare>
<declare><Var>scheduledate</Var></declare>
<declare><Var>diffduration</Var></declare>
<declare><Var>diffdays</Var></declare>
<formula>
<Implies>
<if>
<And>
<formula>
<Atom>
<op><Const type="&rif;iri">&cpt;perishable</Const></op>
<args ordered="yes"><Var>item</Var></args>
</Atom>
</formula>
<formula>
<Atom>
<op><Const type="&rif;iri">&cpt;delivered</Const></op>
<args ordered="yes">
<Var>item</Var>
<Var>deliverydate</Var>
<Const type="&rif;iri">&ppl;John</Const>
</args>
</Atom>
</formula>
<formula>
<Atom>
<op><Const type="&rif;iri">&cpt;scheduled</Const></op>
<args ordered="yes">
<Var>item</Var>
<Var>scheduledate</Var>
</args>
</Atom>
</formula>
<formula>
<Equal>
<left><Var>diffduration</Var></left>
<right>
<External>
<content>
<Expr>
<op><Const type="&rif;iri">&func;subtract-dateTimes</Const></op>
<args ordered="yes">
<Var>deliverydate</Var>
<Var>scheduledate</Var>
</args>
</Expr>
</content>
</External>
</right>
</Equal>
</formula>
<formula>
<Equal>
<left><Var>diffdays</Var></left>
<right>
<External>
<content>
<Expr>
<op><Const type="&rif;iri">&func;days-from-duration</Const></op>
<args ordered="yes">
<Var>diffduration</Var>
</args>
</Expr>
</content>
</External>
</right>
</Equal>
</formula>
<formula>
<External>
<content>
<Atom>
<op><Const type="&rif;iri">&pred;numeric-greater-than</Const></op>
<args ordered="yes">
<Var>diffdays</Var>
<Const type="&xs;integer">10</Const>
</args>
</Atom>
</content>
</External>
</formula>
</And>
</if>
<then>
<Atom>
<op><Const type="&rif;iri">&cpt;reject</Const></op>
<args ordered="yes">
<Const type="&rif;iri">&ppl;John</Const>
<Var>item</Var>
</args>
</Atom>
</then>
</Implies>
</formula>
</Forall>
</sentence>
<sentence>
<Forall>
<declare><Var>item</Var></declare>
<formula>
<Implies>
<if>
<Atom>
<op><Const type="&rif;iri">&cpt;unsolicited</Const></op>
<args ordered="yes"><Var>item</Var></args>
</Atom>
</if>
<then>
<Atom>
<op><Const type="&rif;iri">&cpt;reject</Const></op>
<args ordered="yes">
<Const type="&rif;iri">&ppl;Fred</Const>
<Var>item</Var>
</args>
</Atom>
</then>
</Implies>
</formula>
</Forall>
</sentence>
</Group>
</payload>
</Document>
One of the Presentation Syntaxes
Document(
Prefix(ppl <http://example.com/people#>)
Prefix(cpt <http://example.com/concepts#>)
Prefix(dc <http://purl.org/dc/terms/>)
Prefix(rif <http://www.w3.org/2007/rif#>)
Prefix(func <http://www.w3.org/2007/rif-builtin-function#>)
Prefix(pred <http://www.w3.org/2007/rif-builtin-predicate#>)
Prefix(xs <http://www.w3.org/2001/XMLSchema#>)
(* "http://sample.org"^^rif:iri _:pd[dc:publisher -> "http://www.w3.org/"^^rif:iri
dc:date -> "2008-04-04"^^xs:date] *)
Group
(
Forall ?item ?deliverydate ?scheduledate ?diffduration ?diffdays (
cpt:reject(ppl:John ?item) :-
And(cpt:perishable(?item)
cpt:delivered(?item ?deliverydate ppl:John)
cpt:scheduled(?item ?scheduledate)
?diffduration = External(func:subtract-dateTimes(?deliverydate ?scheduledate))
?diffdays = External(func:days-from-duration(?diffduration))
External(pred:numeric-greater-than(?diffdays 10)))
)
Forall ?item (
cpt:reject(ppl:Fred ?item) :- cpt:unsolicited(?item)
)
)
)
Other Presentation Syntaxes
Nothing standard... room for experimentation
Prefix ppl <http://example.com/people#>
Prefix cpt <http://example.com/concepts#>
Prefix dc <http://purl.org/dc/terms/>
Prefix rif <http://www.w3.org/2007/rif#>
Prefix func <http://www.w3.org/2007/rif-builtin-function#>
Prefix pred <http://www.w3.org/2007/rif-builtin-predicate#>
Prefix xs <http://www.w3.org/2001/XMLSchema#>
(* <http://sample.org> { _:pd dc:publisher lt;http://www.w3.org/>;
dc:date "2008-04-04"^^xs:date] } *)
if cpt:perishable(?item) and
cpt:delivered(?item ?deliverydate ppl:John) and
cpt:scheduled(?item ?scheduledate) and
func:days-from-duration(?deliverydate - ?scheduledate) > 10
then cpt:reject(ppl:John ?item).
if cpt:unsolicited(?item)
then cpt:reject(ppl:Fred ?item).
Slippery slope to "real" rule languages.
A Family of Dialects
But...
Not all engines implement the same features
Some features (retract and negation) are incompatible
Forward chaining, Backward chaining
So...
Core: common subset
BLD: (basic logic dialect) common subset of Prolog-style languages
PRD: (production rule dialect) common subset of Production Rule languages
Rule Language Features
Rule Language Features - BLD
Rule Language Features - PRD
Rule Language Features - Core
What if my feature is missing?
Double-check the specs
Check mailing list, Wiki
Check the Framework for Logic Dialects
- Use as a menu of features
- Already has negations, aggregates, etc
- Can't all be used together
- Implementation may be difficult
Okay to define your own dialects
Extensions: Interoperability
When adding an extension, consider:
What should non-implementing systems do?
(controlling this is "extensibility")
If non-implementers should... |
Your extension should... |
ignore it |
use RIF annotations (metadata) |
stop |
define new XML elements |
rewrite |
[not yet supported] |
Extending the Syntax
Add XML Elements, in your own namespace
Non-implementing systems will reject document
Document it, share on public-rif-dev@w3.org
Possible Fallback Mechanism
Ideally, non-implementing systems could look up extension
Syntactic sugar -> perfect rewrites
Other rewrites have some "impact"
Proposed as XTAN, but not adopted in RIF
RIF Summary
- Developed by diverse community over several years
- Stable XML format; evolving presentation syntaxes
- Three Stable Dialects; evolving set of extensions
Useful, yes. But "necessary"?
Use Case: Ad Hoc Reasoning
if { ?p rdfs:range ?c.
?x ?p ?y }
then
{ ?y rdf:type ?c }
See OWL 2 RL in RIF
Use Case: Vocabulary Migration
In the January 2010 version, FOAF changed foaf:family_name to
foaf:familyName. How many apps did this break?
Let's use this rule:
if { ?person foaf:family_name ?fam }
then { ?person foaf:familyName ?fam }
- Put this rule at http://xmlns.com/foaf/0.1/family_name for forward chainers, crawlers
- Put this rule at http://xmlns.com/foaf/0.1/famileName for backward chainers, query systems
- Encourage all data consumers to do RIF inference
Then: migration becomes possible
(Yes, you could also do this with owl:equivalentProperty.)
Use Case: Scalable Data Integration 1
FOAF has both firstName + lastName and (combined) name. Many data
sources do not provide both. (Vocabulary Mapping)
if { ?person foaf:firstName ?first;
foaf:lastName ?last }
then
{ ?person foaf:name func:string-join(?first " " ?last) }
# Works for Hillary Rodham Clinton, not Sarah Jessica Parker
if { ?person foaf:name ?name } and pred:contains(?name, " ")
then
{ ?x foaf:firstName func:string-before(?name, " ");
foaf:lastName func:string-after(?name, " ")
}
- Do this within FOAF
- ...and between FOAF and vCard
Allows new vocabs to be deployed
Use Case: Scalable Data Integration 2
Facebook's Open Graph Protocol uses a simple-to-use (page-style) RDF vocabulary:
og:type - The type of your object, e.g., "movie". Depending on the type you specify, other properties may also be required.
That is:
<http://www.imdb.com/title/tt0117500/> og:type "movie".
Is an IMDB web page a movie??
Convert to standard RDF modeling:
if { ?page og:type "movie";
foaf:primaryTopic ?resource }
then { ?resource rdf:type dbpedia-owl:Film }
These rules should be reachable Linked Data.
Motivation Summary
RIF for Linked Data Allows:
- Renaming of terms
- Migration in modeling
- Simultaneous use of multiple models
- ... without coordination or agreement
Web-Scale Data Integration
What Now?
RIF is stable, widely reviewed
Many implementation (not many products yet)
Use for Linked Data is experimental, but critical.
Test Suite:
- http://www.w3.org/2005/rules/wiki/Category:Test_Case
- http://www.w3.org/2005/rules/test/repository/
- Currently: 78 Approved
The Future:
- Products
- New Extensions, Dialects
- Look for deployment with Linked Data