N3 in Object-Oriented RuleML

Harold Boley, NRC                    Original Version: 2003-04-02
                                     Current Version:  2006-05-30


This document is on how to serialize key constructs of Notation 3 (N3)
in Object-Oriented RuleML (OO RuleML). N3 and RDF facts plus rules will
thus be exchangeable as valid XML documents. The alignment of N3 and
OO RuleML constructs shows N3's "ASCII writing compactness" and RuleML's
"XML tagging discipline": both are useful for their respective purposes
in Semantic Web KR.

OO RuleML:  http://www.ruleml.org/indoo
FOL RuleML: http://www.ruleml.org/fol
N3 facts: http://www.w3.org/2000/10/swap/Primer.html
N3 rules: http://www.w3.org/2000/10/swap/doc/Rules


N3 subject-verb-object triples as oid-anchored slotted atoms in RuleML
(since subject has no class or rdf:type, no relation is used):

<#pat> <#child> <#al> .

<Atom>
  <oid> <Ind uri="#pat"/> </oid>
  <slot>
    <Ind uri="#child"/>
    <Ind uri="#al"/>
  </slot>
</Atom>


N3 subject classes as webized relations in RuleML:

<#pat> a <#Person> ;
       <#child> <#al> .

<Atom>
  <oid> <Ind uri="#pat"/> </oid>
  <Rel uri="#Person"/>
  <slot>
    <Ind uri="#child"/>
    <Ind uri="#al"/>
  </slot>
</Atom>


N3 "[...]"-bNodes as 'uninterpreted' slotted atoms in RuleML
(the embedded Atom's in="no" makes it uninterpreted):

<#pat> <#child> [ <#age> "3" ] .

<Atom>
  <oid> <Ind uri="#pat"/> </oid>
  <slot>
    <Ind uri="#child"/>
    <Atom in="no">
      <slot>
        <Ind uri="#age"/>
        <Ind>3</Ind>
      </slot>
    </Atom>
  </slot>
</Atom>


N3 data tables as conjoined atoms in RuleML:

<#pat>   <#age> "24";  <#eyecolor> "blue" .
<#al>    <#age>  "3";  <#eyecolor> "green" .
<#jo>    <#age>  "5";  <#eyecolor> "green" .

<And>
  <Atom>
    <oid> <Ind uri="#pat"/> </oid>
    <slot> <Ind uri="#age"/> <Ind>24</Ind> </slot>
    <slot> <Ind uri="#eyecolor"/> <Ind>blue</Ind> </slot>
  </Atom>
  <Atom>
    <oid> <Ind uri="#al"/> </oid>
    <slot> <Ind uri="#age"/> <Ind>3/Ind> </slot>
    <slot> <Ind uri="#eyecolor"/> <Ind>green</Ind> </slot>
  </Atom>
  <Atom>
    <oid> <Ind uri="#jo"/> </oid>
    <slot> <Ind uri="#age"/> <Ind>5/Ind> </slot>
    <slot> <Ind uri="#eyecolor"/> <Ind>green</Ind> </slot>
  </Atom>
</And>


N3 rules in RuleML:

@forAll :x.
{ :thermostat :temp :x } log:implies { :cooling :power :x } .

<Forall>
  <Var>x</Var>
  <Implies>
    <Atom>
      <oid> <Ind uri=":thermostat"/> </oid>
      <slot> <Ind uri=":temp"> <Var>x</Var> </slot>
    </Atom>
    <Atom>
      <oid> <Ind uri=":cooling"/> </oid>
      <slot> <Ind uri=":power"> <Var>x</Var> </slot>
    </Atom>
  </Implies>
</Forall>