graphic with four colored squares
Cover page images (keys)

RIF: Bringing Order to Chaos

Sandro Hawke (sandro@w3.org), W3C / MIT
RuleML 2009, 5 November 2009
http://www.w3.org/2009/Talks/1105-ruleml/

An Emergent Order

It's a diverse world

Can't control chaos

Interlingua

Translators

Overview

General outline:

  1. RIF as interlingua for rules (now)
  2. RIF and the Semantic Web
    • Data integration, via RIF mapping rules (soon)
    • Micro Applications (vision)

My angle:

Plus Discussion

Rule Interchange: Mission

Produce:

... which together allow rules to be:

The Working Group will have to balance the needs of a diverse community

... specifying extensions for which it can:

RIF History

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)

Community

Rule Language Features

scattered names of rule language features

Rule Language Features - BLD

scattered names of rule language features, with one set grouped as BLD

Rule Language Features - PRD

scattered names of rule language features, with one set grouped as PRD

Rule Language Features - Core

scattered names of rule language features, grouped into PRD, BLD, Core

Result

Dialects (Core + Extensions)

Builtins

Works with RDF, OWL

Standard access to XML data: in development

Test Suite

Extensible

RIF Core

Datalog

Datatypes, Builtins

Aligned with RDF (as superset)

RIF Basic Logic Dialect (BLD)

Same Datatypes, Builtins

Adds functions terms (Positive Horn Logic)

Adds open lists (like Prolog)

May add equality in conclusion (open issue)

RIF Production Rule Dialect (PRD)

Operational Semantics (not Model Theoretic)

Adds: Retract, Modify, Execute (Print)

Adds: New

Adds: ineg (true if fact is not in current KB)

Machine-Friendly XML

<!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>

Presentation Syntaxes

One used in BLD spec, another used in PRD spec

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)
    )
  )
)

Room for something better.

RDF and OWL

Okay to use RIF rules on RDF

Okay to use with OWL (in all its variants)

Okay to implement OWL 2 RL with RIF Core

XML

Draft (won't be a standard soon)

Access to XML / XML-like data from rules

What if my feature is missing?

Double-check the specs

Check mailing list, Wiki

Check the Framework for Logic Dialects

Okay to define your own dialects

Extensions: Interoperability

What should non-implementing systems do?

If non-implementers should... Your extension should...
ignore it use annotations (metadata)
stop extend the syntax
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 Status

RIF implementations

Test Suite

It's time!

The Future:

Part 2: RIF in the Semantic Web

You already believe in rule interchange

Relation to the Web?

Decentralization

Massive Scale

(My main use case for RIF)

Simple Semantic Web Scenario

Alice publishes an RDF web page:

She wants to say... Her RDF (in Turtle)
I'm selling a 1st Generation Apple iPod Nano.
@prefix sales: <http://example.org/sales>
@prefix apple: <http://apple.example.com/products>
@prefix : <>

:Alice sales:offering :item22.
:item22 rdf:type apple:iPodNanoGen1.

Charlie queries for:

?who sales:offering ?item.   
?item rdf:type apple:iPodNanoGen1.

... and he see Alice's listing!

Add a Little Inference

But really Charlie queries for:

?who sales:offering ?item.   
?item rdf:type apple:iPod.

If he wants to see Alice's listing, he must:

And Apple must:

Apple's Content Which means...
apple:iPodNanoGen1 rdfs:subClassOf apple:iPodNano.
apple:iPodNano rdfs:subClassOf apple:iPod.
Every Gen1 Nano is a Nano, every Nano is an iPod
apply:iPodNanoGen1 rdfs:subClassOf [
    rdf:type owl:Restriction;
    owl:onProperty apple:memorySizeMeg;
    owl:hasValue "1024";
]
Every Gen1 Nano has 1024M memory

Rules?

Implement "RL" subset of OWL

More expressive than OWL (eg builtins)

Especially vocabulary mapping

Many Kinds of Data

Some data currently in some computer:

Data Source (cont'd)

Wild Scenario

A Shopping Scenario

More...

Data Publication

Those are all things some computer knows about

It's a question of permissions

And the cost of data integration

Knowledge is Power (Information has Value)

The Future of Applications

Apps using data from unknown sources

IT Dashboard

A lot of apps are just queries

And the rest just add update?

Model-View-Controller revisited

MVC takes over...

  1. Model = Data + Rules
  2. View = XML transform (rules?)
  3. Controller = Data authoring

All shared on Web

Application = pick one of each

Micro Applications

Models * Views * Controllers = Ocean of Apps

Micro App is a bookmark, an ad hoc collection of these

(Someday.)

Conclusion

RIF is ready to try out. Pick your dialect.

Extend it as necessary

Rules are key to open data integration

The future is: