Derivation Rules in R2ML

We consider the following derivation rule extracted from UServ Product Derby 2005 Use Case:

If the following are not true, then eligible driver:
   • Young driver,
   • Senior driver.

The rule text can by ambiguous. This rule stipulates that the driver is an eligible driver only if is nor young driver neither senior driver. For this rule, the R2ML markup can be more clear than the natural language.

The R2ML markup for this rule is described below:

 1  <r2ml:RuleBase xmlns:r2ml="http://www.rewerse.net/I1/2006/R2ML" xmlns:dc="http://purl.org/dc/elements/1.1/" 
                   xmlns:userv="http://www.businessrulesforum.com/2005/userv#"
                   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
                   xsi:schemaLocation="http://www.rewerse.net/I1/2006/R2ML http://oxygen.informatik.tu-cottbus.de/R2ML/0.5/R2ML.xsd"
 
 2   <r2ml:DerivationRuleSet r2ml:ruleSetID="UServDerivationRulesSet" 
                             r2ml:externalVocabulary="http://oxygen.informatik.tu-cottbus.de/rewerse-i1/files/UServ_DE.rdfs" 
                             r2ml:externalVocabularyLanguage="RDFS">
  
 3    <r2ml:DerivationRule r2ml:ruleID="DE_DAC06">
 4     <r2ml:Documentation>
 5      <r2ml:RuleText r2ml:textFormat="plain">
          If the following are not true, then eligible driver:
                 - Young driver,
                 - Senior driver.
 6      </r2ml:RuleText>
 7     </r2ml:Documentation>

 8     <r2ml:conditions>
 9      <r2ml:ObjectClassificationAtom r2ml:class="userv:YoungDriver" r2ml:isNegated="true">
10       <r2ml:ObjectVariable r2ml:name="driver"/>
11      </r2ml:ObjectClassificationAtom>
12      <r2ml:ObjectClassificationAtom r2ml:class="userv:SeniorDriver" r2ml:isNegated="true">
13       <r2ml:ObjectVariable r2ml:name="driver"/>
14      </r2ml:ObjectClassificationAtom>
15     </r2ml:conditions>

16     <r2ml:conclusion>
17      <r2ml:ObjectClassificationAtom r2ml:class="userv:EligibleDriver">
18       <r2ml:ObjectVariable r2ml:name="driver"/>
19      </r2ml:ObjectClassificationAtom>
20     </r2ml:conclusion>

21    </r2ml:DerivationRule>
22   </r2ml:DerivationRuleSet>
23  </r2ml:RuleBase>

The r2ml:RuleBase element (see Line 1) is the parent of one or many rule sets. Namespaces which must be available in all rules can be declared here.

A derivation rule set is declared by the element r2ml:DerivationRuleSet (see Line 2). This element contains three optional attributes:

  • r2ml:ruleSetID - is the name of the rule set. In our example this is UServDerivationRulesSet
  • r2ml:externalVocabulary - represent an URI of an external vocabulary. We use RDFS to represent vocabulary for this rule, and the description of the vocabulary definition is available at the http://oxygen.informatik.tu-cottbus.de/rewerse-i1/files/UServ_DE.rdfs
  • r2ml:externalVocabularyLanguage - refers the language of the external vocabulary.

Every derivation rule is enclosed into a r2ml:DerivationRule element (see line 3). An optional element r2ml:Documentation (see line 4) can contains elements which enclose the rule text (Lines 5-7) and the representation of the rule in a specific rules language.

The r2ml:conditions element (Lines 8-15) contains all atoms which forms the rule's body. By default, all atoms from the rule body are connected by conjunction.

In this example, rule conditions are expressed with the help of r2ml:ObjectClassificationAtom (Lines 9-11 and 12-14). The meaning of this atom is to classify an object to the class that it belong to. The class is specified by the value of the attribute r2ml:class. Since our condition specify that the driver must not be Young Driver neither Senior Driver, we use the attribute r2ml:isNegated with true value. By default the value of r2ml:isNegated attribute is false.

The r2ml:ObjectVariable element (Lines 11, 13, 18) express an object variable with a name represented by the value of r2ml:name attribute. The type of this variable can be expressed by the value of the optional attribute r2ml:class or if is an child of r2ml:ObjectClassificationAtom, like in our example, by the value of the attribute r2ml:class of this atom.

The head of the rule is represented by the content of r2ml:conclusion element (Lines 16-20). The conclusion for our example is a classification of the driver object variable to an userv:EligibleDriver class.

The rule has an external vocabulary described using RDFS:

 1  <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
             xmlns:rdf="http://www.w3.org/2000/01/rdf-schema#"
             xmlns:userv="http://www.businessrulesforum.com/2005/userv#"> 

 2   <rdfs:Class rdf:about="http://www.businessrulesforum.com/2005/userv#Driver"/>
  
 3   <rdfs:Class rdf:about="http://www.businessrulesforum.com/2005/userv#YoungDriver">
 4    <rdfs:subClassOf rdf:resource="http://www.businessrulesforum.com/2005/userv#Driver">
 5   </rdfs:Class>
  
 6   <rdfs:Class rdf:about="http://www.businessrulesforum.com/2005/userv#SeniorDriver">
 7    <rdfs:subClassOf rdf:resource="http://www.businessrulesforum.com/2005/userv#Driver">
 8   </rdfs:Class>
  
 9   <rdfs:Class rdf:about="http://www.businessrulesforum.com/2005/userv#EligibleDriver">
10    <rdfs:subClassOf rdf:resource="http://www.businessrulesforum.com/2005/userv#Driver">
11   </rdfs:Class>
  
12  </rdf:RDF>

The vocabulary describe classes which appear in our rule. The Driver class which is also the parent of the other two classes. The classes YoungDriver and SeniorDriver which appears in the rule conditions are extensions of Driver class.

Derivation Rules