Production Rules in R2ML

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

 If young driver and married and not located in CA, NY or VA, 
 then increase premium by $300.

The R2ML markup for this rule is depicted below:

 1  <r2ml:RuleBase xmlns:r2ml="" xmlns:dc="" 
 2   <r2ml:ProductionRuleSet r2ml:ruleSetID="UServProductionRulesSet" 
 3    <r2ml:ProductionRule r2ml:ruleID="DP_03">
 4     <r2ml:Documentation>
 5      <r2ml:RuleText r2ml:textFormat="plain">
 6       <[!CDATA[
            If young driver and married and not located in CA, NY or VA, 
            then increase premium by $300.
 7      </r2ml:RuleText>
 8     </r2ml:Documentation>

 9     <r2ml:conditions>
10      <r2ml:AttributionAtom r2ml:attribute="userv:YoungDriver.maritalStatus">
11       <r2ml:subject>
12        <r2ml:ObjectVariable r2ml:name="driver" r2ml:class="userv:YoungDriver"/>
13       </r2ml:subject>
14       <r2ml:dataValue>
15        <r2ml:TypedLiteral r2ml:lexicalValue="married" r2ml:datatype="xs:string"/>
16       </r2ml:dataValue>
17      </r2ml:AttributionAtom>

18      <r2ml:qf.Disjunction>
19       <r2ml:AttributionAtom r2ml:attribute="userv:YoungDriver.usState" r2ml:isNegated="true">
20        <r2ml:subject>
21         <r2ml:ObjectVariable r2ml:name="driver" r2ml:class="userv:YoungDriver"/>
22        </r2ml:subject>
23        <r2ml:dataValue>
24         <r2ml:TypedLiteral r2ml:lexicalValue="CA" r2ml:datatype="xs:string"/>
25        </r2ml:dataValue>
26       </r2ml:AttributionAtom>
27       <r2ml:AttributionAtom r2ml:attribute="userv:YoungDriver.usState" r2ml:isNegated="true">
28        <r2ml:subject>
29         <r2ml:ObjectVariable r2ml:name="driver" r2ml:class="userv:YoungDriver"/>
30        </r2ml:subject>
31        <r2ml:dataValue>
32         <r2ml:TypedLiteral r2ml:lexicalValue="NY" r2ml:datatype="xs:string"/>
33        </r2ml:dataValue>
34       </r2ml:AttributionAtom>

35       <r2ml:AttributionAtom r2ml:attribute="userv:YoungDriver.usState" r2ml:isNegated="true">
36        <r2ml:subject>
37         <r2ml:ObjectVariable r2ml:name="driver" r2ml:class="userv:YoungDriver"/>
38        </r2ml:subject>
39        <r2ml:dataValue>
40         <r2ml:TypedLiteral r2ml:lexicalValue="VA" r2ml:datatype="xs:string"/>
41        </r2ml:dataValue>
42       </r2ml:AttributionAtom>

43      </r2ml:qf.Disjunction>
44     </r2ml:conditions>

45     <r2ml:producedActionExpr>
46      <r2ml:UpdateActionExpr r2ml:property="userv:VehicleInsurancePolicy.premium">
47       <r2ml:contextArgument>
48        <r2ml:ObjectVariable r2ml:name="vehicleInsurancePolicy" r2ml:class="userv:VehicleInsurancePolicy"/>
49       </r2ml:contextArgument>
50       <r2ml:DatatypeFunctionTerm r2ml:datatypeFunction="op:numeric-add">
51        <r2ml:dataArguments>
52         <r2ml:AttributeFunctionTerm r2ml:attribute="userv:VehicleInsurancePolicy.premium">
53          <r2ml:contextArgument>
54           <r2ml:ObjectVariable r2ml:name="vehicleInsurancePolicy" r2ml:class="userv:VehicleInsurancePolicy"/>
55          </r2ml:contextArgument>
56         </r2ml:AttributeFunctionTerm>
57         <r2ml:TypedLiteral r2ml:lexicalValue="300" r2ml:datatype="xs:integer"/>
58        </r2ml:dataArguments>
59       </r2ml:DatatypeFunctionTerm>
60      </r2ml:UpdateActionExpr>
61     </r2ml:producedActionExpr>

62    </r2ml:ProductionRule>

63   </r2ml:ProductionRuleSet>
64  </r2ml:RuleBase>

The r2ml:RuleBase element (see Line 1) is the parent of one or many rule sets. A r2ml:RuleBase element can contains different kibd of rule sets: derivation, production, reaction rule sets and so on. All namespaces which must be available in all rules are declared here.

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

  • r2ml:ruleSetID - is the name of the rule set. In our example this is UServProductionRulesSet
  • r2ml:externalVocabulary - represent an URI of an external vocabulary. In our example we use OWL to describe the vocabulary.
  • r2ml:externalVocabularyLanguage - refers the language of the external vocabulary.

Every production rule is enclosed into a r2ml:ProductionRule element (see line 3). An optional element r2ml:Documentation (Lines 4-8) 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 (Lines 9-44) can contains one or more atoms. If nothing is specified, then atoms are connected by default by conjunction. Disjunction between atoms can be expressed using r2ml:qf.Disjunction (Lines 18-43).

The rule contains several r2ml:AttributionAtom elements (Lines 10-17, 19-26, 27-34, 35-42). The value of the mandatory attribute r2ml:attribute is the name of the property to which we need to refer. It can contains also the attribute r2ml:isNegated with true (see Line 35) which by default is set to false.

The r2ml:AttributionAtom contains a r2ml:subject element which enclose the object to which we refer. This can be expressed for example by an r2ml:ObjectVariable (i.e. Line 21). The value of the property is referred by a r2ml:dataValue. In this example the value is encoded by a r2ml:TypedLiteral element (i.e. Line 24).

The r2ml:producedActionExp represent the rule head. Several actions are suported in this section. The example use a r2ml:UpdateActionExpre action. This preform an update of the property referred by the value of the r2ml:property attribute. The r2ml:contextArgument contains the object which contains that property. In this example it is expressed by a r2ml:ObjectVariable.

This action must update the premium property of the vehicleInsuranceProperty object increasing the actual value by 300 (Lines 50-59). The sum is expressed with the help of the r2ml:DatatypeFunctionTerm element and it's property r2ml:datatypeFunction which has the value op:numeric-add. This calculate the new value of the premium property.

The rule use an external vocabulary, described using OWL:

 1  <rdf:RDF xmlns:owl=""

 2   <owl:Class rdf:about=""/>
 3   <owl:Class rdf:about="">
      <rdfs:subClassOf rdf:resource="">
 4   </owl:Class>
 5   <owl:Class rdf:about=""/>
 6   <owl:Class rdf:about="">
 7    <rdfs:subClassOf rdf:resource="">
 8   </owl:Class>
 9   <owl:DatatypeProperty rdf:about="">
10    <rdfs:comment>The marital status of the driver</rdfs:comment>
11    <rdfs:range rdf:resource=""/>
12    <rdfs:domain rdf:resource=""/>
13   </owl:DatatypeProperty>
14   <owl:DatatypeProperty rdf:about="">
15    <rdfs:comment>The US state where the client live.</rdfs:comment>
16    <rdfs:range rdf:resource=""/>
17    <rdfs:domain rdf:resource=""/>
18   </owl:DatatypeProperty>

19   <owl:DatatypeProperty rdf:about="">
20    <rdfs:comment>The value of the insurance premium.</rdfs:comment>
21    <rdfs:range rdf:resource=""/>
22    <rdfs:domain rdf:resource=""/>
22   </owl:DatatypeProperty>
19  </rdf:RDF>

The OWL vocabulary contains all structures which appears in that rule. It define Driver, YoungDriver, InsurancePolicy and VehicleInsurancePolicy classes. Also, properties of these classes which appears in the rule are defined: maritalStatus, usState and premium.

Production Rules

Imprint      Privacy Disclaimer