Experience with N3 rules

Tim Berners-lee, Dan Connolly, Eric Prud'homeaux, Yosi Scharf

W3C Rules language Workshop April 2005

MIT/CSAIL Decentralized Information Group

See also

A universal data language: RDF

Semantic web works by: ... but RDF/XMl syntax is rather verbose for some cases.

A human-readable syntax for RDF: N3

ex:c1 rdf:type ex:Car;
      ex:licensedYear  2002, 2003, 2004;
      ex:color  "green";
      ex:users  ( ex:Joe ex:Jill).

Adding graphs to N3: {}

ex:Joe  ex:said   {  ex:c1 ex:color "charcoal" }.

"Graph" or N3 "Formula"

Adding variables: ?x

Making rules: log:implies

{ ?x fam:brother ?y; fam:son ?z }
     =>  { ?x fam:nephew ?z }.
In <http://www.w3.org/2000/10/swap/log#> namespace

Cwm processing

N3 can of course be constrained to prohibit nesting

Built-in Functions and operators: Use RDF Properties

{ ex:d test:point ?x.  ?x math:sin ?y }
     =>  {...} 

N-ary functions: Use argument lists

{   ?x a ex:TestData.
    ( ?x 1 ) math:sum ?y.
    (  ?y  " is one more than " ?x ) string:concatenation ?s
} => { ?s a ex:Result }.
 

Functions using graphs

log:semantics
Retrieve resource and parse to graph
log:includes
Is graph G subset of graph F?
@forAll v:DOC, c:G1, v:Order, v:y.
{   <master.rdf>  log:semantics v:G1.
    v:G1 log:includes   {  vi:DOC a biz:CustomerOrder }.
    v:DOC  log:semantics  v:ORDER.
    v:ORDER log:includes  { []  biz:item v:y }.
} => {
    v:DOC ex:orderItem v:y
}.

Defaults: Use explicit domain

{    <thisOrder.rdf>  log:semantics ?ORDER.
     ?ORDER  log:includes    { ?x  biz:item ?y. ?y a ex:Car };
     ?ORDER  log:notIncludes { ?y  ex:color [] }
} => {
     ?y ex:Color "black"
}.

Syntactic sugar?

Implementation features

Other Implementations and Subsets

N3 extensions also been used to represent queries and patches/updates.

Status of N3

Summary of requirents