RuleML Rules Lite
Concrete Syntax

September 30th, 2003

This version:
http://www.ruleml.org/submission/ruleslite/concretesyntax.html
Authors:
Harold Boley, NRC mailto:harold.boley@nrc.gc.ca
Said Tabet, mailto:stabet@ruleml.org

Acknowledgments

Gerd Wagner, Benjamin Grosof, and others from the RuleML Initiative as well as Mike Dean and Sandro Hawke from the Joint Committee gave valuable input for this document. David Hirtle from UNB has helped implement and validate the examples.


Abstract

A new Abridged RuleML/XML Syntax compatible with RDF and OWL-DL is developed into the Rules Lite Concrete Syntax. This covers webized unary and binary Datalog facts, rules, and queries. Principles, Prolog-like and XML examples, as well as a DTD are given.


Table of Contents

1. Introduction

2. Facts, Rules and Queries

2. Herbrand-like Models

2. Webizing

2. Conclusions

2. Appendix: RulesLite DTD


1. Introduction

This is our report on the Rules Lite Concrete Syntax work for Datalog facts, rules, and queries, envisaged in recent JC telecons (http://www.daml.org/listarchive/joint-committee/1431.html).

In this work all predicates are now going to be unary or binary (compatible with OWL-DL). Certain unary predicates could also be employed for typing some of the rule variables (the others being of type 'any'), as discussed in an earlier series of JC telecons(http://www.daml.org/listarchive/joint-committee/1230.html).

By allowing OWL's allValuesFrom and someValuesFrom restrictions (http://www.w3.org/TR/owl-guide/#allValuesFrom) in Rules Lite's bodies and (perhaps) heads, the concrete syntax could be further adapted to the recent OWL Rules proposal: http://www.daml.org/listarchive/joint-committee/1430.html

For preparing Webizing, the following use of "#"-prefixed fragment identifiers is made for symbolic 'href'-attribute naming:

<ind>constant</ind>

<ind href="#constant"/>

The earlier:

<_opr>relation</_opr>

becomes:

<_opr href="#relation">

While the (always empty) 'ind' element is used -- in the first or second argument position -- for 'href'-naming individual constants, a new 'data' element is used -- in the second argument position -- for tagging various data types as content (cf. RDF literals).

An Abridged RuleML/XML Syntax is employed except for Herbrand Models, which are represented using Deep Markup:

1. The earlier:

<_opr>
   <rel>relation</rel>
</_opr>

is abridged to:

<_opr href="#relation"/>

2. The earlier:

<_body>
   <and>
       atom 1 ... atom k
   </and>
</_body>

is abridged to:

<_body>atom 1 ... atom k</_body>

3. Similarly:

<_head>
   <and>
       atom 1 ... atom k
   </and>
</_head>

could be abridged to (for OWL Rules):

<_head>atom 1 ... atom k</_head>

4. The following prefix form will be allowed ( 0 < n < 3 ):

<atom>
   <_opr href="#relation"/>
   term 1 ... atom n
</atom>

and the following postfix form will be forbidden ( 0 < n < 3 ):

<atom>
   term 1 ... atom n
   <_opr href="#relation"/>
</atom>

5. The earlier:

<fact>
   <_head>
      <atom>...</atom>
   </_head>
</fact>

will be further abridged to:

<facto>
   ...
</facto>

While this is a concrete XML syntax, it builds on a data model integrating the data models of XML and RDF: A role like _opr corresponds to an RDF property (used as an arc label in its DLG model). The concrete syntax in *4* becomes an 'atom'-rooted tree with the operator and a sequence of the 1 or 2 argument terms as subtrees in the abstract syntax.

In the next main sections PR-Prolog examples will be followed by Abridged RuleML/XML syntax (except for the Deep RuleML/XML Markup of Models):

PR-Prolog: Uses a Prolog-like presentation syntax as proposed in: http://www.daml.org/listarchive/joint-committee/1406.html.

(The current PR syntax does not yet capture all information that is in the XML syntax such as the new ind/data distinction or the namespace declarations modeled on N3.)

XML: Uses a version of the Abridged RuleML/XML syntax proposed in: http://www.daml.org/listarchive/joint-committee/1411.html.

The following section discusses Facts, Rules, and Queries (also usable as 'positive' or 'negative' integrity constraints) as well as Models. A general form of webizing will then be introduced for individuals as well as for for unary and binary predicates.

The appendix will give the (DTD) syntax grammar.


2. Facts, Rules and Queries

2.1 Facts

Since an N-ary relation can always be reduced to a conjunction of binary predicates, we will not go beyond binary here.

For instance, the fact

North America is flanked by the Atlantic and the Pacific

may initially seem to express a ternary relationship, but it can, e.g., be re-expressed using three binary facts glued together by a new individual, Oceanics, as shown below.

PR-Prolog:

continent(North_America).
country(Canada).
country(USA).
province(Ontario).
oceanpair(Oceanics).
ocean(Atlantic).
ocean(Pacific).

has_as_part(North_America,Canada).
has_as_part(North_America,USA).
has_as_part(Canada,Ontario).

area(Canada,sqkm9976140).
area(USA,sqkm9629091).

flanked_by(North_America,Oceanics).
flanked_by(Canada,Oceanics).
flanked_by(USA,Oceanics).

eastern(Oceanics,Atlantic).
western(Oceanics,Pacific).

XML:

<rulebase>
  <facto>
    <_opr href="#continent"/>
    <ind href="#North_America"/>
  </facto>

  <facto>
    <_opr href="#country"/>
    <ind href="#Canada"/>
  </facto>

  <facto>
    <_opr href="#country"/>
    <ind href="#USA"/>
  </facto>

  <facto>
    <_opr href="#province"/>
    <ind href="#Ontario"/>
  </facto>

  <facto>
    <_opr href="#oceanpair"/>
    <ind href="#Oceanics"/>
  </facto>

  <facto>
    <_opr href="#ocean"/>
    <ind href="#Atlantic"/>
  </facto>

  <facto>
    <_opr href="#ocean"/>
    <ind href="#Pacific"/>
  </facto>

  <facto>
    <_opr href="#has_as_part"/>
    <ind href="#North_America"/>
    <ind href="#Canada"/>
  </facto>

  <facto>
    <_opr href="#has_as_part"/>
    <ind href="#North_America"/>
    <ind href="#USA"/>
  </facto>

  <facto>
    <_opr href="#has_as_part"/>
    <ind href="#Canada"/>
    <ind href="#Ontario"/>
  </facto>

  <facto>
    <_opr href="#area"/>
    <ind href="#Canada"/>
    <data>sqkm 9976140</data>
  </facto>

  <facto>
    <_opr href="#area"/>
    <ind href="#USA"/>
    <data>sqkm 9629091</data>
  </facto>

  <facto>
    <_opr href="#flanked_by"/>
    <ind href="#North_America"/>
    <ind href="#Oceanics"/>
  </facto>

  <facto>
    <_opr href="#flanked_by"/>
    <ind href="#Canada"/>
    <ind href="#Oceanics"/>
  </facto>

  <facto>
    <_opr href="#flanked_by"/>
    <ind href="#USA"/>
    <ind href="#Oceanics"/>
  </facto>

  <facto>
    <_opr href="#eastern"/>
    <ind href="#Oceanics"/>
    <ind href="#Atlantic"/>
  </facto>

  <facto>
    <_opr href="#western"/>
    <ind href="#Oceanics"/>
    <ind href="#Pacific"/>
  </facto>
</rulebase>

2.2 Rules

PR-Prolog:

stretches(?x,?y) :- has_as_part(?y,?x), co-flanked(?x,?y).
co-flanked(?x,?y) :- flanked_by(?x,?z), flanked_by(?y,?z). 

The XML encoding is as follows:

<rulebase>
   <imp>
      <_head>
         <atom>
            <_opr href="#stretches"/>
            <var>x</var>
            <var>y</var>
         </atom>
      </_head>
      <_body>
         <atom>
            <_opr href="#has_as_part"/>
            <var>y</var>
            <var>x</var>
         </atom>
         <atom>
            <_opr href="#co-flanked"/>
            <var>x</var>
            <var>y</var>
         </atom>
      </_body>
   </imp>
   <imp>
      <_head>
         <atom>
            <_opr href="#co-flanked"/>
            <var>x</var>
            <var>y</var>
         </atom>
      </_head>
      <_body>
         <atom>
            <_opr href="#flanked_by"/>
            <var>x</var>
            <var>z</var>
         </atom>
         <atom>
            <_opr href="#flanked_by"/>
            <var>y</var>
            <var>z</var>
         </atom>
      </_body>
   </imp>
</rulebase>

2.3 Queries

By queries, we mean conjunctive queries (as 'Negative' Integrity Constraints).

The PR-Prolog representation is:

continent(x), ocean(x)

The XML encoding:

<query>
   <_body>
      <atom>
         <_opr href="#continent"/>
         <var>x</var>
      </atom>
      <atom>
         <_opr href="#ocean"/>
         <var>x</var>
      </atom>
   </_body>
</query>

3. Herbrand-like Models

Herbrand Models are represented using the unabridged Deep Markup (close to the abstract syntax).

The PR-Prolog representation is:

continent(North_America).
country(Canada).
country(USA).
province(Ontario).
oceanpair(Oceanics).
ocean(Atlantic).
ocean(Pacific).

has_as_part(North_America,Canada).
has_as_part(Canada,Ontario).

has_as_part(North_America,Ontario).   % from OWL

area(Canada, sqkm9976140).
area(USA, sqkm9629091).

flanked_by(North_America,Oceanics).
flanked_by(Canada, Oceanics).
flanked_by(USA, Oceanics).

flanks(Oceanics,North_America).   % from OWL
flanks(Oceanics,Canada).          % from OWL
flanks(Oceanics,USA).             % from OWL

co-flanked(North_America,Canada).
co-flanked(Canada,North_America).
co-flanked(North_America,USA).
co-flanked(USA,North_America).
co-flanked(Canada,USA).
co-flanked(USA,Canada).
co-flanked(North_America,North_America).
co-flanked(Canada,Canada).
co-flanked(USA,USA).

stretches(Canada,North_America).
stretches(USA,North_America).

eastern(Oceanics,Atlantic).
western(Oceanics,Pacific).

The XML encoding is:

<rulebase>

  <fact>
    <_head>
      <atom>
        <_opr><rel href="#continent"/></_opr>
        <ind href="#North_America"/>
      </atom>
    </_head>
  </fact>

  <fact>
    <_head>
      <atom>
        <_opr><rel href="#country"/></_opr>
        <ind href="#Canada"/>
      </atom>
    </_head>
  </fact>

  <fact>
    <_head>
      <atom>
        <_opr><rel href="#country"/></_opr>
        <ind href="#USA"/>
      </atom>
    </_head>
  </fact>

  <fact>
    <_head>
      <atom>
        <_opr><rel href="#province"/></_opr>
        <ind href="#Ontario"/>
      </atom>
    </_head>
  </fact>

  <fact>
    <_head>
      <atom>
        <_opr><rel href="#oceanpair"/></_opr>
        <ind href="#Oceanics"/>
      </atom>
    </_head>
  </fact>

  <fact>
    <_head>
      <atom>
        <_opr><rel href="#ocean"/></_opr>
        <ind href="#Atlantic"/>
      </atom>
    </_head>
  </fact>

  <fact>
    <_head>
      <atom>
        <_opr><rel href="#ocean"/></_opr>
        <ind href="#Pacific"/>
      </atom>
    </_head>
  </fact>

  <fact>
    <_head>
      <atom>
        <_opr><rel href="#has_as_part"/></_opr>
        <ind href="#North_America"/>
        <ind href="#Canada"/>
      </atom>
    </_head>
  </fact>

  <fact>
    <_head>
      <atom>
        <_opr><rel href="#has_as_part"/></_opr>
        <ind href="#North_America"/>
        <ind href="#USA"/>
      </atom>
    </_head>
  </fact>

  <fact>
    <_head>
      <atom>
        <_opr><rel href="#has_as_part"/></_opr>
        <ind href="#Canada"/>
        <ind href="#Ontario"/>
      </atom>
    </_head>
  </fact>

  <fact>                                          <!-- from OWL -->
    <_head>
      <atom>
        <_opr><rel href="#has_as_part"/></_opr>
        <ind href="#North_America"/>
        <ind href="#Ontario"/>
      </atom>
    </_head>
  </fact>

  <fact>
    <_head>
      <atom>
        <_opr><rel href="#area"/></_opr>
        <ind href="#Canada"/>
        <data>sqkm 9976140</data>
      </atom>
    </_head>
  </fact>

  <fact>
    <_head>
      <atom>
        <_opr><rel href="#area"/></_opr>
        <ind href="#USA"/>
        <data>sqkm 9629091</data>
      </atom>
    </_head>
  </fact>

  <fact>
    <_head>
      <atom>
        <_opr><rel href="#flanked_by"/></_opr>
        <ind href="#North_America"/>
        <ind href="#Oceanics"/>
      </atom>
    </_head>
  </fact>

  <fact>
    <_head>
      <atom>
        <_opr><rel href="#flanked_by"/></_opr>
        <ind href="#Canada"/>
        <ind href="#Oceanics"/>
      </atom>
    </_head>
  </fact>

  <fact>
    <_head>
      <atom>
        <_opr><rel href="#flanked_by"/></_opr>
        <ind href="#USA"/>
        <ind href="#Oceanics"/>
      </atom>
    </_head>
  </fact>

  <fact>                                          <!-- from OWL -->
    <_head>
      <atom>
        <_opr><rel href="#flanks"/></_opr>
        <ind href="#Oceanics"/>
        <ind href="#North_America"/>
      </atom>
    </_head>
  </fact>

  <fact>                                          <!-- from OWL -->
    <_head>
      <atom>
        <_opr><rel href="#flanks"/></_opr>
        <ind href="#Oceanics"/>
        <ind href="#Canada"/>
      </atom>
    </_head>
  </fact>

  <fact>                                          <!-- from OWL -->
    <_head>
      <atom>
        <_opr><rel href="#flanks"/></_opr>
        <ind href="#Oceanics"/>
        <ind href="#USA"/>
      </atom>
    </_head>
  </fact>

  <fact>
    <_head>
      <atom>
        <_opr><rel href="#co-flanked"/></_opr>
        <ind href="#North_America"/>
        <ind href="#Canada"/>
      </atom>
    </_head>
  </fact>

  <fact>
    <_head>
      <atom>
        <_opr><rel href="#co-flanked"/></_opr>
        <ind href="#Canada"/>
        <ind href="#North_America"/>
      </atom>
    </_head>
  </fact>

  <fact>
    <_head>
      <atom>
        <_opr><rel href="#co-flanked"/></_opr>
        <ind href="#North_America"/>
        <ind href="#USA"/>
      </atom>
    </_head>
  </fact>

  <fact>
    <_head>
      <atom>
        <_opr><rel href="#co-flanked"/></_opr>
        <ind href="#USA"/>
        <ind href="#North_America"/>
      </atom>
    </_head>
  </fact>

  <fact>
    <_head>
      <atom>
        <_opr><rel href="#co-flanked"/></_opr>
        <ind href="#Canada"/>
        <ind href="#USA"/>
      </atom>
    </_head>
  </fact>

  <fact>
    <_head>
      <atom>
        <_opr><rel href="#co-flanked"/></_opr>
        <ind href="#USA"/>
        <ind href="#Canada"/>
      </atom>
    </_head>
  </fact>

  <fact>
    <_head>
      <atom>
        <_opr><rel href="#co-flanked"/></_opr>
        <ind href="#North_America"/>
        <ind href="#North_America"/>
      </atom>
    </_head>
  </fact>

  <fact>
    <_head>
      <atom>
        <_opr><rel href="#co-flanked"/></_opr>
        <ind href="#Canada"/>
        <ind href="#Canada"/>
      </atom>
    </_head>
  </fact>

  <fact>
    <_head>
      <atom>
        <_opr><rel href="#co-flanked"/></_opr>
        <ind href="#USA"/>
        <ind href="#USA"/>
      </atom>
    </_head>
  </fact>

  <fact>
    <_head>
      <atom>
        <_opr><rel href="#eastern"/></_opr>
        <ind href="#Oceanics"/>
        <ind href="#Atlantic"/>
      </atom>
    </_head>
  </fact>

  <fact>
    <_head>
      <atom>
        <_opr><rel href="#western"/></_opr>
        <ind href="#Oceanics"/>
        <ind href="#Pacific"/>
      </atom>
    </_head>
  </fact>

</rulebase>

4. Webizing

Individuals as well as unary and binary predicates can be webized by augmenting, within the href's, their symbolic "#"-names by URIs, so that two possibilities result:

1.Symbolic names: in XML with "#"-prefixed fragment identifiers (the pre-webized situation).

2. URIs: in XML with "#"-separated fragment identifiers (cf. RDF).

PR-Prolog (with N3-like URIs and namespace declarations):

w := http://www.waters.org

continent(<http://www.northamerica.org#North_America>).
...
oceanpair<http://www.pairs.org#oceanpair>(<http://w#oceanics>).
...
<http://www.mereology.org#has_as_part>(North_America,Canada).
...
<http://www.direction.org#western>(<http://w#oceanics>,Pacific).

The XML encoding is as follows:

<rulebase>
  xmlns:w="http://www.waters.org">

  <facto>
    <_opr href="#continent"/>
    <ind href="http://www.north_america.org#North_America"/>
  </facto>

  ...

  <facto>
    <_opr href="http://www.pairs.org/ocean#oceanpair"/>
    <ind href="w#Oceanics"/>
  </facto>

  ...

  <facto>
    <_opr href="http://www.mereology.org#has_as_part"/>
    <ind href="#North_America"/>
    <ind href="#Canada"/>
  </facto>

  ...

  <facto>
    <_opr href="http://www.direction.org#western"/>
    <ind href="w#Oceanics"/>
    <ind href="#Pacific"/>
  </facto>

</rulebase>

5. Conclusions

After the definition of the Rules Lite Concrete Syntax, the next step is to modify existing parsers (and generators), allowing this syntax to be used for rule interchange. Possible implementations have been envisaged for cwm, Jena 2, OWL engines, jDREW, and Jess adaptations.

To demonstrate the extension path to N-ary relations ternary predicates could be added later as exemplified in: http://www.daml.org/listarchive/joint-committee/1444.html. as an alternative or complement, the transition to full Horn logic could be attempted, where data like sqkm9976140 could be 'analyzed' as complex terms like sqkm[9976140].

6. Appendix: Rules Lite DTD

The following DTD for rules lite supports both rules and facts.

<!ELEMENT rulebase ((imp | facto)*)>

<!ELEMENT imp ((_head, _body) | (_body, _head))>

<!ELEMENT facto (_opr, ind, (ind | data)?)>

<!ELEMENT _head (atom)>

<!ELEMENT _body (atom*)>

<!ELEMENT atom (_opr, (ind | var), (ind | data | var)?)>

<!ELEMENT _opr EMPTY>

<!ELEMENT ind  EMPTY>

<!ELEMENT data (#PCDATA)>

<!ELEMENT var  (#PCDATA)>

<!ATTLIST _opr href CDATA #REQUIRED>

<!ATTLIST ind  href CDATA #REQUIRED>

<!-- The CDATA must be either URIs with "#"-separated fragment identifiers (for URI naming) -->
<!-- or local, "#"-prefixed fragment identifiers (for symbolic naming).                     -->