<?xml version="1.0" encoding="UTF-8"?>
<!-- This example file is based on the Version 0.3 of R2ML -->
<r2ml:RuleBase xmlns:r2ml="http://www.rewerse.net/I1/2006/R2ML" xmlns:dc="http://purl.org/dc/elements/1.1/" 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.3/R2ML.xsd"
xmlns:examples="http://oxygen.informatik.tu-cottbus.de/R2ML/0.3/">
 <r2ml:DerivationRuleSet>
  <r2ml:DerivationRule r2ml:id="DR001">
   <r2ml:Documentation>
    <r2ml:RuleText r2ml:textFormat="plain">If X is the parent of Y and X is brother of Z then Z is the uncle of Y</r2ml:RuleText>
    <r2ml:SourceCode r2ml:language="Prolog">uncle(Z,Y):-parent(X,Y),brother(X,Z).</r2ml:SourceCode>
    <dc:subject>Uncle definition</dc:subject>
    <dc:creator>Adrian Giurca</dc:creator>
    <dc:contributor>Gerd Wagner</dc:contributor>
    <dc:contributor>Sergey Lukichev</dc:contributor>
    <dc:title>Uncle Rule</dc:title>
    <dc:description>REWERSE I1 Rules Markup Language</dc:description>
    <dc:date>2006-04-06</dc:date>
   </r2ml:Documentation>
   <r2ml:conditions>
    <r2ml:GenericAtom r2ml:predicate="parent">
     <r2ml:arguments>
      <r2ml:Variable r2ml:name="X"/>
      <r2ml:Variable r2ml:name="Y"/>
     </r2ml:arguments>
    </r2ml:GenericAtom>
    <r2ml:GenericAtom r2ml:predicate="brother">
     <r2ml:arguments>
      <r2ml:Variable r2ml:name="X"/>
      <r2ml:Variable r2ml:name="Z"/>
     </r2ml:arguments>
    </r2ml:GenericAtom>
   </r2ml:conditions>
   <r2ml:conclusion>
    <r2ml:GenericAtom r2ml:predicate="uncle">
     <r2ml:arguments>
      <r2ml:Variable r2ml:name="Z"/>
      <r2ml:Variable r2ml:name="Y"/>
     </r2ml:arguments>
    </r2ml:GenericAtom>
   </r2ml:conclusion>
  </r2ml:DerivationRule>
  <r2ml:DerivationRule r2ml:id="DR002">
   <r2ml:Documentation>
    <r2ml:RuleText r2ml:textFormat="plain">The succesor of a natural number is a natural number</r2ml:RuleText>
    <r2ml:SourceCode r2ml:language="Prolog">natural_number(succ(N)):-natural_number(N).</r2ml:SourceCode>
    <dc:subject>Defining natural numbers</dc:subject>
    <dc:creator>Adrian Giurca</dc:creator>
    <dc:contributor>Gerd Wagner</dc:contributor>
    <dc:contributor>Sergey Lukichev</dc:contributor>
    <dc:title>Successor Rule</dc:title>
    <dc:date>2006-04-06</dc:date>
   </r2ml:Documentation>
   <r2ml:conditions>
    <r2ml:GenericAtom r2ml:predicate="natural_number">
     <r2ml:arguments>
      <r2ml:Variable r2ml:name="N"/>
     </r2ml:arguments>
    </r2ml:GenericAtom> 
   </r2ml:conditions>
   <r2ml:conclusion>
    <r2ml:GenericAtom r2ml:predicate="natural_number">
     <r2ml:arguments>
      <r2ml:FunctionTerm r2ml:functor="succ">
       <r2ml:arguments>
        <r2ml:Variable r2ml:name="N"/>
       </r2ml:arguments>
      </r2ml:FunctionTerm>
     </r2ml:arguments>
    </r2ml:GenericAtom>
   </r2ml:conclusion>
  </r2ml:DerivationRule>
  <r2ml:DerivationRule r2ml:id="DR003" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:swrlb="http://www.w3.org/2003/11/swrlb">
   <r2ml:Documentation>
    <r2ml:RuleText r2ml:textFormat="plain">A customer is premium if their spending has been min 5000 euro in the previous year.</r2ml:RuleText>
    <r2ml:SourceCode r2ml:language="RuleML">
     <Implies>
      <head>
       <Atom>
        <Rel>premium</Rel>
        <Var>customer</Var>
       </Atom>
      </head>
      <body>
       <Atom>
        <Rel>spending</Rel>
        <Var>customer</Var>
        <Ind>min 5000 euro</Ind>
        <Ind>previous year</Ind>
       </Atom>
      </body>
     </Implies>
    </r2ml:SourceCode>
    <dc:creator>Adrian Giurca</dc:creator>
    <dc:title>Premium customer</dc:title>
    <dc:source>http://www.ruleml.org/papers/tutorial-ruleml-20050513.html</dc:source>
    <dc:date>2006-04-05</dc:date>
   </r2ml:Documentation>
   <r2ml:conditions>
    <r2ml:DatatypePredicateAtom r2ml:datatypePredicate="swrlb:subtract">
     <r2ml:dataArguments>
      <r2ml:DatatypeFunctionTerm r2ml:datatypeFunction="fn:year-from-dateTime">
       <r2ml:dataArguments>
        <r2ml:DatatypeFunctionTerm r2ml:datatypeFunction="fn:current-dateTime">
         <r2ml:dataArguments/>
        </r2ml:DatatypeFunctionTerm>
       </r2ml:dataArguments>
      </r2ml:DatatypeFunctionTerm>
      <r2ml:TypedLiteral r2ml:datatype="xs:integer" r2ml:lexicalValue="1"/>
      <r2ml:DataVariable r2ml:name="previous_year" r2ml:datatype="xs:gYear"/>
     </r2ml:dataArguments>
    </r2ml:DatatypePredicateAtom>
    <r2ml:DatatypePredicateAtom r2ml:datatypePredicate="swrlb:greaterThan">
     <r2ml:dataArguments>
      <r2ml:DataOperationTerm r2ml:operation="spending">
       <r2ml:contextArgument>
        <r2ml:ObjectVariable r2ml:name="customer" r2ml:class="Customer"/>
       </r2ml:contextArgument>
       <r2ml:arguments>
        <r2ml:DataVariable r2ml:name="previous_year" r2ml:datatype="xs:gYear"/>
       </r2ml:arguments>
      </r2ml:DataOperationTerm>
      <r2ml:TypedLiteral r2ml:datatype="xs:positiveInteger" r2ml:lexicalValue="5000"/>
     </r2ml:dataArguments>
    </r2ml:DatatypePredicateAtom>
   </r2ml:conditions>
   <r2ml:conclusion>
    <r2ml:ObjectClassificationAtom r2ml:class="PremiumCustomer">
     <r2ml:ObjectVariable r2ml:name="customer"/>
    </r2ml:ObjectClassificationAtom>
   </r2ml:conclusion>
  </r2ml:DerivationRule>
  <r2ml:DerivationRule r2ml:id="DR004">
   <r2ml:Documentation>
    <r2ml:RuleText r2ml:textFormat="plain">The discount for a customer buying a product is 7.5 percent if the customer is premium and the product is luxury.</r2ml:RuleText>
    <r2ml:SourceCode r2ml:language="RuleML">
     <Implies>
      <head>
       <Atom>
        <Rel>discount</Rel>
        <Var>customer</Var>
        <Var>product</Var>
        <Ind>7.5 percent</Ind>
       </Atom>
      </head>
      <body>
       <And>
        <Atom>
         <Rel>premium</Rel>
         <Var>customer</Var>
        </Atom>
        <Atom>
         <Rel>luxury</Rel>
         <Var>product</Var>
        </Atom>
       </And>
      </body>
     </Implies>
    </r2ml:SourceCode>
    <dc:subject>RuleML example in R2ML</dc:subject>
    <dc:creator>Adrian Giurca</dc:creator>
    <dc:title>Give discount</dc:title>
    <dc:source>http://www.ruleml.org/papers/tutorial-ruleml-20050513.html</dc:source>
    <dc:date>2006-04-05</dc:date>
   </r2ml:Documentation>
   <r2ml:conditions>
    <r2ml:ObjectClassificationAtom r2ml:class="PremiumCustomer">
     <r2ml:ObjectVariable r2ml:name="customer" r2ml:class="Customer"/>
    </r2ml:ObjectClassificationAtom>
    <r2ml:ObjectClassificationAtom r2ml:class="LuxuryProduct">
     <r2ml:ObjectVariable r2ml:name="product" r2ml:class="Product"/>
    </r2ml:ObjectClassificationAtom>
    <r2ml:AssociationAtom r2ml:associationPredicate="buy">
     <r2ml:objectArguments>
      <r2ml:ObjectVariable r2ml:name="customer"/>
      <r2ml:ObjectVariable r2ml:name="product"/>
     </r2ml:objectArguments>
    </r2ml:AssociationAtom>
   </r2ml:conditions>
   <r2ml:conclusion>
    <r2ml:AttributionAtom r2ml:attribute="discount">
     <r2ml:subject>
      <r2ml:ObjectVariable r2ml:name="customer"/>
     </r2ml:subject>
     <r2ml:value>
      <r2ml:TypedLiteral r2ml:datatype="xs:decimal" r2ml:lexicalValue="7.5"/>
     </r2ml:value>
    </r2ml:AttributionAtom>
   </r2ml:conclusion>
  </r2ml:DerivationRule>
  <r2ml:DerivationRule r2ml:id="DR005">
   <r2ml:Documentation>
    <r2ml:RuleText r2ml:textFormat="plain"/>
    <r2ml:SourceCode r2ml:language="FLogic">FORALL X,Y,Z X[ancestor->>Y] - X[father->Z] AND Z[ancestor->>Y].</r2ml:SourceCode>
    <dc:subject>A rule from ancestor definition in F-Logic</dc:subject>
    <dc:creator>Adrian Giurca</dc:creator>
    <dc:source>http://www.ontoprise.de/content/e2/e29/e30/e490/e600/F-Logic_Tutorial_eng.pdf</dc:source>
    <dc:date>2006-05-05</dc:date>
   </r2ml:Documentation>
   <r2ml:conditions>
    <r2ml:ReferencePropertyAtom r2ml:referenceProperty="father">
     <r2ml:subject>
      <r2ml:ObjectVariable r2ml:name="X"/>
     </r2ml:subject>
     <r2ml:object>
      <r2ml:ObjectVariable r2ml:name="Z"/>
     </r2ml:object>
    </r2ml:ReferencePropertyAtom>
    <r2ml:ReferencePropertyAtom r2ml:referenceProperty="ancestor">
     <r2ml:subject>
      <r2ml:ObjectVariable r2ml:name="Z"/>
     </r2ml:subject>
     <r2ml:object>
      <r2ml:ObjectVariable r2ml:name="Y"/>
     </r2ml:object>
    </r2ml:ReferencePropertyAtom>
   </r2ml:conditions>
   <r2ml:conclusion>
    <r2ml:ReferencePropertyAtom r2ml:referenceProperty="ancestor">
     <r2ml:subject>
      <r2ml:ObjectVariable r2ml:name="X"/>
     </r2ml:subject>
     <r2ml:object>
      <r2ml:ObjectVariable r2ml:name="Y"/>
     </r2ml:object>
    </r2ml:ReferencePropertyAtom>
   </r2ml:conclusion>
  </r2ml:DerivationRule>
  <r2ml:DerivationRule r2ml:id="DR007">
   <r2ml:Documentation>
    <r2ml:RuleText r2ml:textFormat="plain"/>
    <r2ml:SourceCode r2ml:language="SQL"><![CDATA[
					CREATE VIEW part_locations (part, quantity, town) AS
					SELECT part, qty, city
					FROM inventory, location
					WHERE inventory.id = location.id	
				]]></r2ml:SourceCode>
    <dc:subject>SQL View as derivation rule</dc:subject>
    <dc:creator>Adrian Giurca</dc:creator>
    <dc:contributor>Gerd Wagner</dc:contributor>
    <dc:contributor>Sergey Lukichev</dc:contributor>
    <dc:title>SQL View Example</dc:title>
    <dc:date>2006-04-07</dc:date>
   </r2ml:Documentation>
   <r2ml:conditions>
    <r2ml:GenericAtom r2ml:predicate="inventory">
     <r2ml:arguments>
      <r2ml:Variable r2ml:name="id"/>
      <r2ml:Variable r2ml:name="part"/>
      <r2ml:Variable r2ml:name="qty"/>
     </r2ml:arguments>
    </r2ml:GenericAtom>
    <r2ml:GenericAtom r2ml:predicate="location">
     <r2ml:arguments>
      <r2ml:Variable r2ml:name="id"/>
      <r2ml:Variable r2ml:name="city"/>
     </r2ml:arguments>
    </r2ml:GenericAtom>
   </r2ml:conditions>
   <r2ml:conclusion>
    <r2ml:GenericAtom r2ml:predicate="part_locations">
     <r2ml:arguments>
      <r2ml:Variable r2ml:name="part"/>
      <r2ml:Variable r2ml:name="qty"/>
      <r2ml:Variable r2ml:name="city"/>
     </r2ml:arguments>
    </r2ml:GenericAtom>
   </r2ml:conclusion>
  </r2ml:DerivationRule>
  <r2ml:DerivationRule r2ml:id="DR008" xmlns:srv="http://www.services.org/EU-Rent/">
   <r2ml:Documentation>
    <r2ml:RuleText r2ml:textFormat="plain" r2ml:ruleDiagram="examples:DR_isAvailable.gif">

						If rental car is stored at the branch and it is not assigned to a rental and it is not scheduled for service, then rental car is available at the branch.
				</r2ml:RuleText>
    <r2ml:SourceCode r2ml:language="OCL">
			 	context Branch::availableCar: RentalCar derive:
	            self.storedCar -> select (c | 
	                                              not oclIsKindOf(RentalCarScheduledForService) 
	                                              and c.Rental --> isEmpty()
	                                    )
	            </r2ml:SourceCode>
    <dc:creator>Sergey Lukichev</dc:creator>
    <dc:contributor>Gerd Wagner</dc:contributor>
    <dc:contributor>Adrian Giurca</dc:contributor>
    <dc:date>2006-04-07</dc:date>
   </r2ml:Documentation>
   <r2ml:conditions>
    <r2ml:AssociationAtom r2ml:isNegated="false" r2ml:associationPredicate="srv:isStoredAt">
     <r2ml:objectArguments>
      <r2ml:ObjectVariable r2ml:name="rentalCar" r2ml:class="srv:RentalCar"/>
      <r2ml:ObjectVariable r2ml:name="branch" r2ml:class="srv:Branch"/>
     </r2ml:objectArguments>
    </r2ml:AssociationAtom>
    <r2ml:ObjectClassificationAtom r2ml:isNegated="true" r2ml:class="srv:RentalCarScheduledForService">
     <r2ml:ObjectVariable r2ml:name="rentalCar"/>
    </r2ml:ObjectClassificationAtom>
    <r2ml:AssociationAtom r2ml:isNegated="true" r2ml:associationPredicate="srv:isAssignedTo">
     <r2ml:objectArguments>
      <r2ml:ObjectVariable r2ml:name="rentalCar" r2ml:class="srv:rentalCar"/>
      <r2ml:ObjectVariable r2ml:name="rental" r2ml:class="srv:Rental"/>
     </r2ml:objectArguments>
    </r2ml:AssociationAtom>
   </r2ml:conditions>
   <r2ml:conclusion>
    <r2ml:AssociationAtom r2ml:isNegated="false" r2ml:associationPredicate="srv:isAvailableAt">
     <r2ml:objectArguments>
      <r2ml:ObjectVariable r2ml:name="rentalCar" r2ml:class="srv:RentalCar"/>
      <r2ml:ObjectVariable r2ml:name="branch" r2ml:class="srv:Branch"/>
     </r2ml:objectArguments>
    </r2ml:AssociationAtom>
   </r2ml:conclusion>
  </r2ml:DerivationRule>
  <r2ml:DerivationRule r2ml:id="DR009" xmlns:swrlb="http://www.w3.org/2003/11/swrlb">
   <r2ml:Documentation>
    <r2ml:RuleText r2ml:textFormat="plain" r2ml:ruleDiagram="examples:DR_scheduledService.gif">
                      If a rental car has more than 90 days or more than 5000 km since the last service then rental car is a rental car scheduled for service.			
				</r2ml:RuleText>
    <r2ml:SourceCode r2ml:language="OCL">
						 context RentalCar:: isScheduledForService:Boolean derive:
	                     last_maintenance_date >=90 or service_reading>5000
	            </r2ml:SourceCode>
    <dc:creator>Sergey Lukichev</dc:creator>
    <dc:contributor>Gerd Wagner</dc:contributor>
    <dc:contributor>Gerd Wagner</dc:contributor>
    <dc:date>2006-03-30</dc:date>
   </r2ml:Documentation>
   <r2ml:conditions>
    <r2ml:qf.Disjunction>
     <r2ml:DatatypePredicateAtom r2ml:datatypePredicate="swrlb:greaterThan">
      <r2ml:dataArguments>
       <r2ml:AttributeFunctionTerm r2ml:attribute="last_maintenance_date">
        <r2ml:contextArgument>
         <r2ml:ObjectVariable r2ml:name="rentalCar" r2ml:class="srv:RentalCar"/>
        </r2ml:contextArgument>
       </r2ml:AttributeFunctionTerm>
       <r2ml:TypedLiteral r2ml:lexicalValue="90" r2ml:datatype="xs:positiveInteger"/>
      </r2ml:dataArguments>
     </r2ml:DatatypePredicateAtom>
     <r2ml:DatatypePredicateAtom r2ml:datatypePredicate="swrlb:greaterThan">
      <r2ml:dataArguments>
       <r2ml:AttributeFunctionTerm r2ml:attribute="service_reading">
        <r2ml:contextArgument>
         <r2ml:ObjectVariable r2ml:name="rentalCar"/>
        </r2ml:contextArgument>
       </r2ml:AttributeFunctionTerm>
       <r2ml:TypedLiteral r2ml:lexicalValue="5000" r2ml:datatype="xs:positiveInteger"/>
      </r2ml:dataArguments>
     </r2ml:DatatypePredicateAtom>
    </r2ml:qf.Disjunction>
   </r2ml:conditions>
   <r2ml:conclusion>
    <r2ml:ObjectClassificationAtom r2ml:class="srv:RentalCarScheduledForService">
     <r2ml:ObjectVariable r2ml:name="rentalCar"/>
    </r2ml:ObjectClassificationAtom>
   </r2ml:conclusion>
  </r2ml:DerivationRule>
  <r2ml:DerivationRule r2ml:id="DR010">
   <r2ml:Documentation>
    <r2ml:RuleText r2ml:textFormat="plain" r2ml:ruleDiagram="examples:DR_isHusband.png">
					If a person is male and no bachelor then he is maried and a husband.				
				</r2ml:RuleText>
    <dc:creator>Marco Pehla</dc:creator>
    <dc:contributor>Gerd Wagner</dc:contributor>
    <dc:date>2006-04-05</dc:date>
   </r2ml:Documentation>
   <r2ml:conditions>
    <r2ml:ObjectClassificationAtom r2ml:class="Male">
     <r2ml:ObjectVariable r2ml:name="m"/>
    </r2ml:ObjectClassificationAtom>
    <r2ml:ObjectClassificationAtom r2ml:class="Bachelor" r2ml:isNegated="true">
     <r2ml:ObjectVariable r2ml:name="b"/>
    </r2ml:ObjectClassificationAtom>
   </r2ml:conditions>
   <r2ml:conclusion>
    <r2ml:AssociationAtom r2ml:associationPredicate="isMarriedTo">
     <r2ml:objectArguments>
      <r2ml:RoleFunctionTerm r2ml:referenceProperty="husband">
       <r2ml:contextArgument>
        <r2ml:ObjectVariable r2ml:name="m" r2ml:class="Male"/>
       </r2ml:contextArgument>
      </r2ml:RoleFunctionTerm>
      <r2ml:RoleFunctionTerm r2ml:referenceProperty="wife">
       <r2ml:contextArgument>
        <r2ml:ObjectVariable r2ml:name="w" r2ml:class="Female"/>
       </r2ml:contextArgument>
      </r2ml:RoleFunctionTerm>
     </r2ml:objectArguments>
    </r2ml:AssociationAtom>
   </r2ml:conclusion>
  </r2ml:DerivationRule>
  <r2ml:DerivationRule r2ml:id="DR011" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:swrlb="http://www.w3.org/2003/11/swrlb">
   <r2ml:Documentation>
    <r2ml:RuleText r2ml:textFormat="plain" r2ml:ruleDiagram="examples:DR_authenticate.png">
				Any person who was some time in the last 2 months an employee of an organization which was some time in the last 2 months a W3C member may register.
			</r2ml:RuleText>
    <dc:creator>Marco Pehla</dc:creator>
    <dc:contributor>Adrian Giurca</dc:contributor>
    <dc:title>authentication</dc:title>
    <dc:source>http://www.ruleml.org/0.9/exa/authenticate.ruleml</dc:source>
    <dc:date>11-05-2006</dc:date>
    <r2ml:SourceCode r2ml:language="RuleML">
     <Implies>
      <head>
       <Atom>
        <op>
         <Rel>may register</Rel>
        </op>
        <Var>any</Var>
       </Atom>
      </head>
      <body>
       <And>
        <Atom>
         <op>
          <Rel>person</Rel>
         </op>
         <Var>any</Var>
        </Atom>
        <Atom>
         <op>
          <Rel>organization</Rel>
         </op>
         <Var>org</Var>
        </Atom>
        <Atom>
         <op>
          <Rel>employee in</Rel>
         </op>
         <Var>any</Var>
         <Var>org</Var>
         <Cterm>
          <op>
           <Ctor>last</Ctor>
          </op>
          <Cterm>
           <op>
            <Ctor>month</Ctor>
           </op>
           <Ind>2</Ind>
          </Cterm>
         </Cterm>
        </Atom>
        <Atom>
         <op>
          <Rel>member in</Rel>
         </op>
         <Var>org</Var>
         <Ind uri="http://www.w3.org/">W3C</Ind>
         <Cterm>
          <op>
           <Ctor>last</Ctor>
          </op>
          <Cterm>
           <op>
            <Ctor>month</Ctor>
           </op>
           <Ind>2</Ind>
          </Cterm>
         </Cterm>
        </Atom>
       </And>
      </body>
     </Implies>
    </r2ml:SourceCode>
   </r2ml:Documentation>
   <r2ml:conditions>
    <!-- person -->
    <r2ml:ObjectClassificationAtom r2ml:class="Person">
     <r2ml:ObjectVariable r2ml:name="p"/>
    </r2ml:ObjectClassificationAtom>
    <r2ml:ObjectClassificationAtom r2ml:class="Organisation">
     <r2ml:ObjectVariable r2ml:name="o"/>
    </r2ml:ObjectClassificationAtom>
    <r2ml:ObjectClassificationAtom r2ml:class="W3C">
     <r2ml:ObjectVariable r2ml:name="w" r2ml:class="Organisation"/>
    </r2ml:ObjectClassificationAtom>
    <!-- employee is working for an organisation -->
    <r2ml:AssociationAtom r2ml:associationPredicate="isWorkingFor">
     <r2ml:objectArguments>
      <r2ml:ObjectVariable r2ml:name="employee" r2ml:class="Person"/>
      <r2ml:ObjectVariable r2ml:name="org" r2ml:class="Organisation"/>
     </r2ml:objectArguments>
    </r2ml:AssociationAtom>
    <!-- Organisation is a member of W3C -->
    <r2ml:AssociationAtom r2ml:associationPredicate="isMemberOf">
     <r2ml:objectArguments>
      <r2ml:ObjectVariable r2ml:name="org" r2ml:class="Organisation"/>
      <r2ml:ObjectVariable r2ml:name="w3" r2ml:class="W3C"/>
     </r2ml:objectArguments>
    </r2ml:AssociationAtom>
    <!--  "...the last 2 months..." -->
    <!-- currentMonthMinusTwo = currentMonth - 2  -->
    <r2ml:DatatypePredicateAtom r2ml:datatypePredicate="swrlb:subtract">
     <r2ml:dataArguments>
      <r2ml:DataOperationTerm r2ml:operation="fn:month-from-dateTime">
       <r2ml:arguments>
        <r2ml:DataOperationTerm r2ml:operation="fn:current-dateTime">
         <r2ml:arguments/>
        </r2ml:DataOperationTerm>
       </r2ml:arguments>
      </r2ml:DataOperationTerm>
      <r2ml:TypedLiteral r2ml:datatype="xs:integer" r2ml:lexicalValue="2"/>
      <r2ml:DataVariable r2ml:name="currentMonthMinusTwo" r2ml:datatype="xs:gMonth"/>
     </r2ml:dataArguments>
    </r2ml:DatatypePredicateAtom>
    <!--  "...person who was some time in the last 2 months an employee of an organization..."-->
    <!-- lastWorkingMonth  > currentMonthMinusTwo -->
    <r2ml:DatatypePredicateAtom r2ml:datatypePredicate="swrlb:greaterThan">
     <r2ml:dataArguments>
      <r2ml:AttributeFunctionTerm r2ml:attribute="lastWorkingMonth">
       <r2ml:contextArgument>
        <r2ml:ObjectVariable r2ml:name="employee" r2ml:class="Person"/>
       </r2ml:contextArgument>
      </r2ml:AttributeFunctionTerm>
      <r2ml:DataVariable r2ml:name="currentMonthMinusTwo" r2ml:datatype="xs:gMonth"/>
     </r2ml:dataArguments>
    </r2ml:DatatypePredicateAtom>
    <!--"...an organization which was some time in the last 2 months a W3C member..." -->
    <!-- lastW3cMembershipMonth > currentMonthMinusTwo -->
    <r2ml:DatatypePredicateAtom r2ml:datatypePredicate="swrlb:greaterThan">
     <r2ml:dataArguments>
      <r2ml:AttributeFunctionTerm r2ml:attribute="lastW3cMembershipMonth">
       <r2ml:contextArgument>
        <r2ml:ObjectVariable r2ml:name="org" r2ml:class="Organisation"/>
       </r2ml:contextArgument>
      </r2ml:AttributeFunctionTerm>
      <r2ml:DataVariable r2ml:name="currentMonthMinusTwo" r2ml:datatype="xs:gMonth"/>
     </r2ml:dataArguments>
    </r2ml:DatatypePredicateAtom>
   </r2ml:conditions>
   <r2ml:conclusion>
    <!-- ...the person may register -->
    <r2ml:ObjectClassificationAtom r2ml:class="PersonAllowedToRegister">
     <r2ml:ObjectVariable r2ml:name="p" r2ml:class="Person"/>
    </r2ml:ObjectClassificationAtom>
   </r2ml:conclusion>
  </r2ml:DerivationRule>
  <r2ml:DerivationRule r2ml:id="DR012" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:swrlb="http://www.w3.org/2003/11/swrlb">
   <r2ml:Documentation>
    <r2ml:RuleText r2ml:textFormat="plain" r2ml:ruleDiagram="examples:DR_broker.png">a simplified broker definition</r2ml:RuleText>
    <dc:creator>Marco Pehla</dc:creator>
    <dc:contributor>Adrian Giurca</dc:contributor>
    <dc:title>broker</dc:title>
    <dc:source>http://www.ruleml.org/0.9/exa/broker.ruleml</dc:source>
    <dc:date>24-05-2006</dc:date>
    <r2ml:SourceCode r2ml:language="RuleML">
     <Implies>
      <head>
       <Atom>
        <op>
         <Rel>buy</Rel>
        </op>
        <Var>broker</Var>
        <Var>prod</Var>
       </Atom>
      </head>
      <body>
       <And>
        <Atom>
         <op>
          <Rel>want</Rel>
         </op>
         <Ind>customer-of-broker</Ind>
         <Var>prod</Var>
        </Atom>
        <Atom>
         <op>
          <Rel>deal</Rel>
         </op>
         <Var>prod</Var>
         <Cterm>
          <op>
           <Ctor>cost</Ctor>
          </op>
          <Ind>prod</Ind>
         </Cterm>
         <Ind>benefit-of-prod</Ind>
        </Atom>
       </And>
      </body>
     </Implies>
    </r2ml:SourceCode>
   </r2ml:Documentation>
   <r2ml:conditions>
    <!-- a customer has a broker -->
    <r2ml:AssociationAtom r2ml:associationPredicate="hasBroker">
     <r2ml:objectArguments>
      <r2ml:Object r2ml:objectID="customer" r2ml:class="Customer"/>
      <r2ml:Object r2ml:objectID="broker" r2ml:class="Broker"/>
     </r2ml:objectArguments>
    </r2ml:AssociationAtom>
    <!-- a customer want a product -->
    <r2ml:AssociationAtom r2ml:associationPredicate="want">
     <r2ml:objectArguments>
      <r2ml:Object r2ml:objectID="customer" r2ml:class="Customer"/>
      <r2ml:ObjectVariable r2ml:name="prod" r2ml:class="Product"/>
     </r2ml:objectArguments>
    </r2ml:AssociationAtom>
    <!-- "a product is a deal if it's benefit of money (e.g. after selling it ) is greater ( or equal ) it's cost" -->
    <!-- prod.benefit >= prod.cost -->
    <r2ml:DatatypePredicateAtom r2ml:datatypePredicate="swrlb:greaterThanOrEqual">
     <r2ml:dataArguments>
      <r2ml:AttributeFunctionTerm r2ml:attribute="benefit">
       <r2ml:contextArgument>
        <r2ml:ObjectVariable r2ml:name="prod" r2ml:class="Product"/>
       </r2ml:contextArgument>
      </r2ml:AttributeFunctionTerm>
      <r2ml:AttributeFunctionTerm r2ml:attribute="cost">
       <r2ml:contextArgument>
        <r2ml:ObjectVariable r2ml:name="prod" r2ml:class="Product"/>
       </r2ml:contextArgument>
      </r2ml:AttributeFunctionTerm>
     </r2ml:dataArguments>
    </r2ml:DatatypePredicateAtom>
   </r2ml:conditions>
   <r2ml:conclusion>
    <!-- broker buy this product -->
    <r2ml:AssociationAtom r2ml:associationPredicate="buy">
     <r2ml:objectArguments>
      <r2ml:ObjectVariable r2ml:name="broker" r2ml:class="Broker"/>
      <r2ml:ObjectVariable r2ml:name="prod" r2ml:class="Product"/>
     </r2ml:objectArguments>
    </r2ml:AssociationAtom>
   </r2ml:conclusion>
  </r2ml:DerivationRule>
  <r2ml:DerivationRule r2ml:id="DR013">
   <r2ml:Documentation>
    <r2ml:RuleText r2ml:textFormat="plain" r2ml:ruleDiagram="examples:DR_own.png">A person owns an object if it buys the object from a merchant and the keeps it.</r2ml:RuleText>
    <dc:creator>Marco Pehla</dc:creator>
    <dc:contributor>Adrian Giurca</dc:contributor>
    <dc:title>own</dc:title>
    <dc:source>http://www.ruleml.org/0.9/exa/own.ruleml</dc:source>
    <dc:date>29-05-2006</dc:date>
    <r2ml:SourceCode r2ml:language="RuleML">
     <Implies>
      <head>
       <Atom>
        <op>
         <Rel>own</Rel>
        </op>
        <Var>person</Var>
        <Var>object</Var>
       </Atom>
      </head>
      <body>
       <!-- explicit 'And' -->
       <And>
        <Atom>
         <op>
          <Rel>buy</Rel>
         </op>
         <Var>person</Var>
         <Var>merchant</Var>
         <Var>object</Var>
        </Atom>
        <Atom>
         <op>
          <Rel>keep</Rel>
         </op>
         <Var>person</Var>
         <Var>object</Var>
        </Atom>
       </And>
      </body>
     </Implies>
    </r2ml:SourceCode>
   </r2ml:Documentation>
   <r2ml:conditions>
    <!-- person has a merchant-->
    <r2ml:ReferencePropertyAtom r2ml:referenceProperty="hasMerchant">
     <r2ml:subject>
      <r2ml:ObjectVariable r2ml:name="person"/>
     </r2ml:subject>
     <r2ml:object>
      <r2ml:ObjectVariable r2ml:name="merchant"/>
     </r2ml:object>
    </r2ml:ReferencePropertyAtom>
    <!-- "...the person keeps the object.."-->
    <r2ml:AssociationAtom r2ml:associationPredicate="keep">
     <r2ml:objectArguments>
      <r2ml:ObjectVariable r2ml:name="person" r2ml:class="Person"/>
      <r2ml:ObjectVariable r2ml:name="object" r2ml:class="Object"/>
     </r2ml:objectArguments>
    </r2ml:AssociationAtom>
   </r2ml:conditions>
   <r2ml:conclusion>
    <!-- "...person owns an object..."-->
    <r2ml:AssociationAtom r2ml:associationPredicate="own">
     <r2ml:objectArguments>
      <r2ml:ObjectVariable r2ml:name="person" r2ml:class="Person"/>
      <r2ml:ObjectVariable r2ml:name="object" r2ml:class="Object"/>
     </r2ml:objectArguments>
    </r2ml:AssociationAtom>
   </r2ml:conclusion>
  </r2ml:DerivationRule>
  <r2ml:DerivationRule r2ml:id="DR014">
   <r2ml:Documentation>
    <r2ml:RuleText r2ml:textFormat="plain" r2ml:ruleDiagram="examples:DR_recomment.png">If you want to review rule principles, you may have a look at the rule based system at http://www.cs.brandeis.edu .</r2ml:RuleText>
    <dc:creator>Marco Pehla</dc:creator>
    <dc:contributor>Adrian Giurca</dc:contributor>
    <dc:title>recommend</dc:title>
    <dc:source>http://www.ruleml.org/0.9/exa/recommend.ruleml</dc:source>
    <dc:date>30-05-2006</dc:date>
    <r2ml:SourceCode r2ml:language="RuleML">
     <Implies>
      <head>
       <Atom>
        <op>
         <Rel>may look at</Rel>
        </op>
        <Var>you</Var>
        <Ind uri="http://www.cs.brandeis.edu/...">Rule-Based Systems</Ind>
       </Atom>
      </head>
      <body>
       <Atom>
        <op>
         <Rel>want to review</Rel>
        </op>
        <Var>you</Var>
        <Ind>rule principles</Ind>
       </Atom>
      </body>
     </Implies>
     <Atom>
      <op>
       <Rel>want to review</Rel>
      </op>
      <Ind>fred</Ind>
      <Ind>rule principles</Ind>
     </Atom>
    </r2ml:SourceCode>
   </r2ml:Documentation>
   <r2ml:conditions>
    <!-- "...you want to review rule principles..." -->
    <r2ml:AssociationAtom r2ml:associationPredicate="wantsToReview">
     <r2ml:objectArguments>
      <r2ml:ObjectVariable r2ml:name="p" r2ml:class="Person"/>
      <r2ml:Object r2ml:objectID="rulePrinciples" r2ml:class="Principles"/>
     </r2ml:objectArguments>
    </r2ml:AssociationAtom>
   </r2ml:conditions>
   <r2ml:conclusion>
    <!-- "...you may have a look at the rule based system at http://www.cs.brandeis.edu..."-->
    <r2ml:AssociationAtom r2ml:associationPredicate="lookAt">
     <r2ml:objectArguments>
      <r2ml:ObjectVariable r2ml:name="p" r2ml:class="Person"/>
      <r2ml:Object r2ml:objectID="b:rules" r2ml:class="Resource" xmlns:b="http://www.brandeis.edu"/>
     </r2ml:objectArguments>
    </r2ml:AssociationAtom>
   </r2ml:conclusion>
  </r2ml:DerivationRule>
 </r2ml:DerivationRuleSet>
 <!--

Production rule set

-->
 <r2ml:ProductionRuleSet>
  <r2ml:ProductionRule r2ml:id="PR001" xmlns:srv="http://www.services.org/EU-Rent/">
   <r2ml:Documentation>
    <r2ml:RuleText r2ml:textFormat="plain" r2ml:ruleDiagram="examples:PR_AssignDiscount.gif">
                     If the order value is greater than 1000 and the customer type is not gold then give a 10% discount.               
                  </r2ml:RuleText>
    <r2ml:SourceCode r2ml:language="IRL">
when {
						IlrContext() from ?context;
						evaluate(orderValue >=1000 and  !(customerRating equals "Gold"));
					}
					then discount = 10
</r2ml:SourceCode>
    <dc:creator>Sergey Lukichev</dc:creator>
    <dc:contributor>Gerd Wagner</dc:contributor>
    <dc:date>2006-04-05</dc:date>
   </r2ml:Documentation>
   <r2ml:conditions>
    <r2ml:DatatypePredicateAtom r2ml:datatypePredicate="swrlb:greaterThan">
     <r2ml:dataArguments>
      <r2ml:AttributeFunctionTerm r2ml:attribute="orderValue">
       <r2ml:contextArgument>
        <r2ml:ObjectVariable r2ml:name="order" r2ml:class="srv:Order"/>
       </r2ml:contextArgument>
      </r2ml:AttributeFunctionTerm>
      <r2ml:TypedLiteral r2ml:lexicalValue="1000" r2ml:datatype="xs:positiveInteger"/>
     </r2ml:dataArguments>
    </r2ml:DatatypePredicateAtom>
    <r2ml:DatatypePredicateAtom r2ml:datatypePredicate="swrlb:equal" r2ml:isNegated="true">
     <r2ml:dataArguments>
      <r2ml:AttributeFunctionTerm r2ml:attribute="customerRating">
       <r2ml:contextArgument>
        <r2ml:ObjectVariable r2ml:name="order" r2ml:class="srv:Order"/>
       </r2ml:contextArgument>
      </r2ml:AttributeFunctionTerm>
      <r2ml:TypedLiteral r2ml:lexicalValue="gold" r2ml:datatype="xs:string"/>
     </r2ml:dataArguments>
    </r2ml:DatatypePredicateAtom>
   </r2ml:conditions>
   <r2ml:producedAction>
    <r2ml:AssignActionExpression r2ml:property="srv:discount">
     <r2ml:contextArgument>
      <r2ml:ObjectVariable r2ml:name="order" r2ml:class="srv:Order"/>
     </r2ml:contextArgument>
     <r2ml:TypedLiteral r2ml:lexicalValue="10" r2ml:datatype="xs:positiveInteger"/>
    </r2ml:AssignActionExpression>
   </r2ml:producedAction>
  </r2ml:ProductionRule>
  <!-- <r2ml:ProductionRule r2ml:id="PR002" xmlns:cim="cim">
   <r2ml:Documentation>
    <r2ml:RuleText r2ml:textFormat="plain"/>
    <r2ml:SourceCode r2ml:language="Jena-CLIPS">
				[PR009:
                    ( ?authtarget http://www.w3.org/1999/02/22-rdf-syntax-ns#type 	cim#CIM_AuthorizedTarget )
					( ?authsubject1 http://www.w3.org/1999/02/22-rdf-syntax-ns#type 	cim#CIM_AuthorizedSubject )
					( ?printer http://www.w3.org/1999/02/22-rdf-syntax-ns#type cim#CIM_ComputerSystem )
					( ?privilege http://www.w3.org/1999/02/22-rdf-syntax-ns#type 	cim#CIM_AuthorizedPrivilege )
					
					( ?printer cim#Dedicated â€™Printâ€™ )
					( ?authtarget cim#CATPrivilege ?privilege )
					( ?authtarget cim#TargetElement ?printer )	
					( ?authsubject1 cim#CASPrivilege ?privilege )		
					( ?authsubject1 cim#PrivilegedElement cim#ST_PHY )
					->
					( ?authsubject2 http://www.w3.org/1999/02/22-rdf-syntax-ns#type cim#CIM_AuthorizedSubject )
					( ?authsubject2 cim#CASPrivilege ?privilege )
					( ?authsubject2 cim#PrivilegedElement cim#ST_COMP )]				
				</r2ml:SourceCode>
    <dc:creator>Adrian Giurca</dc:creator>
    <dc:date>2006-05-05</dc:date>
    <dc:source>http://www.positif.org/docs/051031_UMU_SWRL_SEMANTIC_SECURITY_POLICY_PPT_v0100.pdf</dc:source>
   </r2ml:Documentation>
   <r2ml:conditions>
    <r2ml:AttributionAtom r2ml:attribute="cim:Dedicated">
     <r2ml:subject>
      <r2ml:ObjectVariable r2ml:name="printer" r2ml:class="cim:CIM_ComputerSystem"/>
     </r2ml:subject>
     <r2ml:value>
      <r2ml:TypedLiteral r2ml:lexicalValue="Print" r2ml:datatype="xs:string"/>
     </r2ml:value>
    </r2ml:AttributionAtom>
    <r2ml:ReferencePropertyAtom r2ml:referenceProperty="cim:CATPrivilege">
     <r2ml:subject>
      <r2ml:ObjectVariable r2ml:name="authtarget" r2ml:class="cim:CIM_AuthorizedTarget"/>
     </r2ml:subject>
     <r2ml:object>
      <r2ml:ObjectVariable r2ml:name="privilege" r2ml:class="cim:CIM_AuthorizedPrivilege"/>
     </r2ml:object>
    </r2ml:ReferencePropertyAtom>
    <r2ml:ReferencePropertyAtom r2ml:referenceProperty="cim:TargetElement">
     <r2ml:subject>
      <r2ml:ObjectVariable r2ml:name="authtarget" r2ml:class="cim:CIM_AuthorizedTarget"/>
     </r2ml:subject>
     <r2ml:object>
      <r2ml:ObjectVariable r2ml:name="printer"/>
     </r2ml:object>
    </r2ml:ReferencePropertyAtom>
    <r2ml:ReferencePropertyAtom r2ml:referenceProperty="cim:CASPrivilege">
     <r2ml:subject>
      <r2ml:ObjectVariable r2ml:name="authsubject1" r2ml:class="cim:CIM_AuthorizedSubject"/>
     </r2ml:subject>
     <r2ml:object>
      <r2ml:ObjectVariable r2ml:name="privilege"/>
     </r2ml:object>
    </r2ml:ReferencePropertyAtom>
    <r2ml:ReferencePropertyAtom r2ml:referenceProperty="cim:PrivilegedElement">
     <r2ml:subject>
      <r2ml:ObjectVariable r2ml:name="authsubject1"/>
     </r2ml:subject>
     <r2ml:object>
      <r2ml:Object r2ml:objectID="cim:ST_PHY"/>
     </r2ml:object>
    </r2ml:ReferencePropertyAtom>
   </r2ml:conditions>
   <r2ml:producedAction>
    <r2ml:CreateActionExpression r2ml:class="cim:CIM_AuthorizedSubject">
     <r2ml:contextArgument>
      <r2ml:ObjectVariable r2ml:name="authsubject2"/>
     </r2ml:contextArgument>
    </r2ml:CreateActionExpression>
   </r2ml:producedAction>
   <r2ml:postcondition>
    <r2ml:ReferencePropertyAtom r2ml:referenceProperty="cim:CASPrivilege">
     <r2ml:subject>
      <r2ml:ObjectVariable r2ml:name="authsubject2" r2ml:class="cim:CIM_AuthorizedSubject"/>
     </r2ml:subject>
     <r2ml:object>
      <r2ml:ObjectVariable r2ml:name="privilege"/>
     </r2ml:object>
    </r2ml:ReferencePropertyAtom>
    <r2ml:ReferencePropertyAtom r2ml:referenceProperty="cim:PrivilegedElement">
     <r2ml:subject>
      <r2ml:ObjectVariable r2ml:name="authsubject2"/>
     </r2ml:subject>
     <r2ml:object>
      <r2ml:Object r2ml:object="cim:ST_COMP"/>
     </r2ml:object>
    </r2ml:ReferencePropertyAtom>
   </r2ml:postcondition>
  </r2ml:ProductionRule> -->
  <r2ml:ProductionRule r2ml:id="PR003">
   <r2ml:Documentation>
    <r2ml:RuleText r2ml:textFormat="plain">If the person age  is less than 3 then send him a greeting.</r2ml:RuleText>
    <r2ml:SourceCode r2ml:language="JESS">
			       (defrule welcome-toddlers  "Give a special greeting to young children"
					(&lt; ( age ?person) 3)	=>	(printout  ?person "Hello, little one!"  crlf))
				</r2ml:SourceCode>
    <dc:subject>Give a special greeting to young children</dc:subject>
    <dc:creator>Adrian Giurca</dc:creator>
    <dc:contributor>Gerd Wagner</dc:contributor>
    <dc:contributor>Sergey Lukichev</dc:contributor>
    <dc:title>welcome-toddlers </dc:title>
    <dc:description>REWERSE I1 Rules Markup Language</dc:description>
    <dc:date>2006-03-30</dc:date>
   </r2ml:Documentation>
   <r2ml:conditions>
    <r2ml:DatatypePredicateAtom r2ml:datatypePredicate="swrlb:lessThan">
     <r2ml:dataArguments>
      <r2ml:AttributeFunctionTerm r2ml:attribute="age">
       <r2ml:contextArgument>
       <r2ml:ObjectVariable r2ml:name="person"/>
       </r2ml:contextArgument>
      </r2ml:AttributeFunctionTerm>
      <r2ml:TypedLiteral r2ml:lexicalValue="3" r2ml:datatype="xs:positiveInteger"/>
     </r2ml:dataArguments>
    </r2ml:DatatypePredicateAtom>
   </r2ml:conditions>
   <r2ml:producedAction>
    <r2ml:InvokeActionExpression r2ml:operation="printout">
     <r2ml:contextArgument>
      <r2ml:ObjectVariable r2ml:name="person"/>
     </r2ml:contextArgument>
     <r2ml:arguments>
      <r2ml:TypedLiteral r2ml:lexicalValue="Hello, little one! crlf" r2ml:datatype="xs:string"/>
     </r2ml:arguments>
    </r2ml:InvokeActionExpression>
   </r2ml:producedAction>
  </r2ml:ProductionRule>
  <r2ml:ProductionRule r2ml:id="aRule">
   <r2ml:Documentation>
    <r2ml:RuleText r2ml:textFormat="plain">If the person age  is less than 3 then send him a greeting.</r2ml:RuleText>
    <r2ml:SourceCode r2ml:language="JESS">
				(defrule aRule (Person (name ?x))(Man (name ?y))
						(hasSibling ?x ?y)(hasAge ?x ?a1)
						(hasAge ?y ?a2)(test (> ?age2 ?age1))
					=> (assert (hasOlderBrother ?x ?y))
				</r2ml:SourceCode>
    <dc:creator>Adrian Giurca</dc:creator>
    <dc:source>http://www.med.univ-rennes1.fr/~cgolb/Protege2005/SWRLJessOConnor.pdf</dc:source>
    <dc:date>2006-05-05</dc:date>
   </r2ml:Documentation>
   <r2ml:conditions>
    <r2ml:ReferencePropertyAtom r2ml:referenceProperty="hasSibling">
     <r2ml:subject>
      <r2ml:ObjectVariable r2ml:name="x" r2ml:class="Person"/>
     </r2ml:subject>
     <r2ml:object>
      <r2ml:ObjectVariable r2ml:name="y" r2ml:class="Man"/>
     </r2ml:object>
    </r2ml:ReferencePropertyAtom>
    <r2ml:ObjectDescriptionAtom r2ml:class="Person">
     <r2ml:subject>
      <r2ml:ObjectVariable r2ml:name="x"/>
     </r2ml:subject>
     <r2ml:DataSlot r2ml:attribute="hasAge">
      <r2ml:value>
       <r2ml:DataVariable r2ml:name="a1"/>
      </r2ml:value>
     </r2ml:DataSlot>
    </r2ml:ObjectDescriptionAtom>
    <r2ml:ObjectDescriptionAtom r2ml:class="Man">
     <r2ml:subject>
      <r2ml:ObjectVariable r2ml:name="y"/>
     </r2ml:subject>
     <r2ml:DataSlot r2ml:attribute="hasAge">
      <r2ml:value>
       <r2ml:DataVariable r2ml:name="a2"/>
      </r2ml:value>
     </r2ml:DataSlot>
    </r2ml:ObjectDescriptionAtom>
    <r2ml:DatatypePredicateAtom r2ml:datatypePredicate="swrlx:greaterThan">
     <r2ml:dataArguments>
      <r2ml:DataVariable r2ml:name="a2"/>
      <r2ml:DataVariable r2ml:name="a1"/>
     </r2ml:dataArguments>
    </r2ml:DatatypePredicateAtom>
   </r2ml:conditions>
   <r2ml:producedAction>
    <r2ml:AssignActionExpression r2ml:property="hasOlderBrother">
     <r2ml:contextArgument>
      <r2ml:ObjectVariable r2ml:name="x"/>
     </r2ml:contextArgument>
     <r2ml:ObjectVariable r2ml:name="y"/>
    </r2ml:AssignActionExpression>
   </r2ml:producedAction>
  </r2ml:ProductionRule>
  <r2ml:ProductionRule r2ml:id="PR005">
   <r2ml:Documentation>
    <r2ml:RuleText r2ml:textFormat="plain" r2ml:ruleDiagram="examples:PR_RentalDiscount.gif" r2ml:ruleVocabularyDiagram="examples:Vocabulary.gif">
                 If reservation date of a rental is  5 days in advance then give rental a 10 % discount.		   
		        </r2ml:RuleText>
    <dc:creator>Adrian Giurca</dc:creator>
    <dc:contributor>Gerd Wagner</dc:contributor>
    <dc:date>2006-04-05</dc:date>
   </r2ml:Documentation>
   <r2ml:conditions>
    <r2ml:DatatypePredicateAtom r2ml:datatypePredicate="swrlb:greaterThanOrEqual">
     <r2ml:dataArguments>
      <r2ml:DataOperationTerm r2ml:operation="minus">
       <r2ml:contextArgument>
        <r2ml:ObjectVariable r2ml:name="r" r2ml:class="Rental"/>
       </r2ml:contextArgument>
       <r2ml:arguments>
        <r2ml:AttributeFunctionTerm r2ml:attribute="startDate">
         <r2ml:contextArgument>
          <r2ml:ObjectVariable r2ml:name="sd" r2ml:class="Rental"/>
         </r2ml:contextArgument>
        </r2ml:AttributeFunctionTerm>
        <r2ml:AttributeFunctionTerm r2ml:attribute="reservationDate">
         <r2ml:contextArgument>
          <r2ml:ObjectVariable r2ml:name="rd" r2ml:class="Rental"/>
         </r2ml:contextArgument>
        </r2ml:AttributeFunctionTerm>
       </r2ml:arguments>
      </r2ml:DataOperationTerm>
      <r2ml:TypedLiteral r2ml:lexicalValue="5" r2ml:datatype="xs:positiveInteger"/>
     </r2ml:dataArguments>
    </r2ml:DatatypePredicateAtom>
   </r2ml:conditions>
   <r2ml:producedAction>
    <r2ml:AssignActionExpression r2ml:property="discount">
     <r2ml:contextArgument>
      <r2ml:ObjectVariable r2ml:name="r" r2ml:class="Rental"/>
     </r2ml:contextArgument>
     <r2ml:TypedLiteral r2ml:lexicalValue="10" r2ml:datatype="xs:positiveInteger"/>
    </r2ml:AssignActionExpression>
   </r2ml:producedAction>
  </r2ml:ProductionRule>
 </r2ml:ProductionRuleSet>

<!-- 

Integrity rule set

-->
 <r2ml:IntegrityRuleSet>
  <!--

SRWL integrity rule 1

-->
  <r2ml:AlethicIntegrityRule r2ml:id="IR001">
   <r2ml:Documentation>
    <r2ml:RuleText r2ml:textFormat="plain">
				If rental is not a one way rental then return branch of rental must be the same as  pick-up branch of a rental.
				</r2ml:RuleText>
    <r2ml:SourceCode r2ml:language="SWRL" xmlns:swrl="http://www.w3. org/2003/11/swrl#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:ruleml="http://www.w3. org/2003/11/ruleml" xmlns:owl="http://www.w3.org/2002/07/owl#">
     <swrl:variable rdf:resource="r1"/>
     <swrl:variable rdf:rwesource="rb"/>
     <swrl:variable rdf:resource="pb"/>
     <ruleml:Imp>
      <ruleml:body>
       <swrl:ClassAtom>
        <swrl:classPredicate rdf:resource="#Rental"/>
        <swrl:argument1 rdf:resource="#r1"/>
       </swrl:ClassAtom>
       <swrl:IndividualPropertyAtom>
        <swrl:propertyPredicate rdf:resource="#returnBranch"/>
        <swrl:argument1 rdf:resource="#r1"/>
        <swrl:argument2 rdf:resource="#rb"/>
       </swrl:IndividualPropertyAtom>
       <swrl:IndividualPropertyAtom>
        <swrl:propertyPredicate rdf:resource="#pickupBranch"/>
        <swrl:argument1 rdf:resource="#r1"/>
        <swrl:argument2 rdf:resource="#pb"/>
       </swrl:IndividualPropertyAtom>
       <swrl:ClassAtom>
        <swrl:classPredicate>
         <owl:Class>
          <owl:complementOf rdf:resource="#OneWayRental"/>
         </owl:Class>
        </swrl:classPredicate>
        <swrl:argument1 rdf:resource="#r1"/>
       </swrl:ClassAtom>
      </ruleml:body>
      <ruleml:head>
       <swrl:SameIndividualAtom>
        <swrl:argument1 rdf:resource="#rb"/>
        <swrl:argument1 rdf:resource="#pb"/>
       </swrl:SameIndividualAtom>
      </ruleml:head>
     </ruleml:Imp>
    </r2ml:SourceCode>
    <dc:creator>Sergey Lukichev</dc:creator>
    <dc:contributor>Gerd Wagner</dc:contributor>
    <dc:contributor>Adrian Giurca</dc:contributor>
    <dc:date>2006-03-30</dc:date>
   </r2ml:Documentation>
   <r2ml:constraint>
    <r2ml:UniversallyQuantifiedFormula>
     <r2ml:ObjectVariable r2ml:name="r1" r2ml:class="Rental"/>
     <r2ml:Implication>
      <r2ml:antecedent>

      <r2ml:NegationAsFailure>
       <r2ml:ObjectClassificationAtom r2ml:class="OneWayRental">
        <r2ml:ObjectVariable r2ml:name="r1"/>
       </r2ml:ObjectClassificationAtom>
      </r2ml:NegationAsFailure>
</r2ml:antecedent>
<r2ml:consequent>
      <r2ml:EqualityAtom>
       <r2ml:RoleFunctionTerm r2ml:referenceProperty="returnBranch">
        <r2ml:contextArgument>
         <r2ml:ObjectVariable r2ml:name="r1"/>
        </r2ml:contextArgument>
       </r2ml:RoleFunctionTerm>
       <r2ml:RoleFunctionTerm r2ml:referenceProperty="pickupBranch">
        <r2ml:contextArgument>
         <r2ml:ObjectVariable r2ml:name="r1"/>
        </r2ml:contextArgument>
       </r2ml:RoleFunctionTerm>
      </r2ml:EqualityAtom>
      </r2ml:consequent>
     </r2ml:Implication>
    </r2ml:UniversallyQuantifiedFormula>
   </r2ml:constraint>
  </r2ml:AlethicIntegrityRule>
  <r2ml:AlethicIntegrityRule r2ml:id="IR002">
   <r2ml:Documentation>
    <r2ml:RuleText  r2ml:textFormat="plain">Each additional driver of a rental must be a qualified driver</r2ml:RuleText>
    <r2ml:SourceCode r2ml:language="SWRL" xmlns:swrl="http://www.w3. org/2003/11/swrl#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:ruleml="http://www.w3. org/2003/11/ruleml" xmlns:owl="http://www.w3.org/2002/07/owl#">
     <swrl:variable rdf:resource="r1"/>
     <swrl:variable rdf:resource="p1"/>
     <ruleml:Imp>
      <ruleml:body>
       <swrl:ClassAtom>
        <swrl:classPredicate rdf:resource="#Rental"/>
        <swrl:argument1 rdf:resource="#r1"/>
       </swrl:ClassAtom>
       <swrl:ClassAtom>
        <swrl:classPredicate rdf:resource="#Person"/>
        <swrl:argument1 rdf:resource="#p"/>
       </swrl:ClassAtom>
       <swrl:IndividualPropertyAtom>
        <swrl:propertyPredicate rdf:resource="#additionalDriver"/>
        <swrl:argument1 rdf:resource="#r1"/>
        <swrl:argument2 rdf:resource="#p1"/>
       </swrl:IndividualPropertyAtom>
      </ruleml:body>
      <ruleml:head>
       <swrl:ClassAtom>
        <swrl:classPredicate rdf:resource="#QualifiedDriver"/>
        <swrl:argument1 rdf:resource="#p1"/>
       </swrl:ClassAtom>
      </ruleml:head>
     </ruleml:Imp>
    </r2ml:SourceCode>
    <dc:creator>Sergey Lukichev</dc:creator>
   </r2ml:Documentation>
   <r2ml:constraint>
    <r2ml:UniversallyQuantifiedFormula>
     <r2ml:ObjectVariable r2ml:name="p1" r2ml:class="Person"/>
     <r2ml:Implication>
      <r2ml:antecedent>
      <r2ml:Conjunction>
       <r2ml:ObjectClassificationAtom r2ml:class="srv:Rental">
        <r2ml:ObjectVariable r2ml:name="r1"/>
       </r2ml:ObjectClassificationAtom>
       <r2ml:ReferencePropertyAtom r2ml:referenceProperty="srv:additionalDriver">
        <r2ml:subject>
         <r2ml:ObjectVariable r2ml:name="p1" r2ml:class="Person"/>
        </r2ml:subject>
        <r2ml:object>
         <r2ml:ObjectVariable r2ml:name="r1"/>
        </r2ml:object>
       </r2ml:ReferencePropertyAtom>
       </r2ml:Conjunction>
      </r2ml:antecedent>
      <r2ml:consequent>
      <r2ml:ObjectClassificationAtom r2ml:class="srv:QualifiedDriver">
       <r2ml:ObjectVariable r2ml:name="p1"/>
      </r2ml:ObjectClassificationAtom>
      </r2ml:consequent>
     </r2ml:Implication>
    </r2ml:UniversallyQuantifiedFormula>
   </r2ml:constraint>
  </r2ml:AlethicIntegrityRule>
 </r2ml:IntegrityRuleSet>
 <!-- 

Reaction rule set 

-->
 <r2ml:ReactionRuleSet>
  <r2ml:ReactionRule r2ml:id="ECA001">
   <r2ml:Documentation>
    <r2ml:RuleText r2ml:textFormat="plain">
					If customer returns a car and the car has more than 5000km from the last service then send the car to the service
				</r2ml:RuleText>
    <r2ml:SourceCode r2ml:language="">
				on car_returned(car,customer) 
				if car.odometer_reading-car.lastservice.odometer_reading>5000
				do service(car)
			</r2ml:SourceCode>
    <dc:subject>Send a car to service</dc:subject>
    <dc:creator>Jens Dietrich</dc:creator>
    <dc:contributor>Gerd Wagner</dc:contributor>
    <dc:contributor>Adrian Giurca</dc:contributor>
    <dc:title>SendCar</dc:title>
    <dc:description>REWERSE I1 Rules Markup Language</dc:description>
    <dc:date>2006-04-05</dc:date>
   </r2ml:Documentation>
   <r2ml:triggeringEvent>
    <r2ml:MessageEventExpression r2ml:eventType="alert" r2ml:startTime="2006-03-21T09:00:00" r2ml:duration="P0Y0M0DT0H0M0S" r2ml:sender="http://www.mywebsite.org">
     <r2ml:arguments>
      <r2ml:ObjectVariable r2ml:name="car" r2ml:class="RentalCar"/>
      <r2ml:ObjectVariable r2ml:name="customer" r2ml:class="Customer"/>
     </r2ml:arguments>
    </r2ml:MessageEventExpression>
   </r2ml:triggeringEvent>
   <r2ml:conditions>
    <r2ml:DatatypePredicateAtom r2ml:datatypePredicate="ge">
     <r2ml:dataArguments>
      <r2ml:AttributeFunctionTerm r2ml:attribute="srv:lastservice">
       <r2ml:contextArgument>
        <r2ml:ObjectVariable r2ml:name="rentalCar" r2ml:class="srv:RentalCar"/>
       </r2ml:contextArgument>
      </r2ml:AttributeFunctionTerm>
      <r2ml:AttributeFunctionTerm r2ml:attribute="odometer_reading">
       <r2ml:contextArgument>
        <r2ml:ObjectVariable r2ml:name="rentalCar" r2ml:class="srv:RentalCar"/>
       </r2ml:contextArgument>
      </r2ml:AttributeFunctionTerm>
      <r2ml:TypedLiteral r2ml:datatype="xs:positiveInteger" r2ml:lexicalValue="5000"/>
     </r2ml:dataArguments>
    </r2ml:DatatypePredicateAtom>
   </r2ml:conditions>
   <r2ml:producedAction>
    <r2ml:InvokeActionExpression r2ml:operation="service">
     <r2ml:contextArgument>
      <r2ml:ObjectVariable r2ml:name="rentalCar" r2ml:class="srv:RentalCar"/>
     </r2ml:contextArgument>
    </r2ml:InvokeActionExpression>
   </r2ml:producedAction>
  </r2ml:ReactionRule>
  <r2ml:ReactionRule r2ml:id="ECA002" xmlns:srv="http://www.example.org/">
   <r2ml:Documentation>
    <r2ml:RuleText r2ml:ruleDiagram="examples:RR_ProductRequest.gif" r2ml:textFormat="plain">
				 On a car request, if the car is available then send approval and mark the ordered car as sold.
				</r2ml:RuleText>
    <r2ml:SourceCode r2ml:language="R2ML">
					on productOrder(VW, customer)
					if AvailableCar(VW)
					do approveOrder(VW, customer) 		
			   </r2ml:SourceCode>
    <dc:creator>Sergey Lukichev</dc:creator>
    <dc:contributor>Adrian Giurca</dc:contributor>
   </r2ml:Documentation>
   <r2ml:triggeringEvent>
    <r2ml:MessageEventExpression r2ml:sender="eshop.org" r2ml:startTime="2006-03-21T09:00:00" r2ml:duration="P0Y0M0DT0H0M0S" r2ml:eventType="productOrder">
     <r2ml:arguments>
      <r2ml:ObjectVariable r2ml:name="car" r2ml:class="srv:Car"/>
      <r2ml:ObjectVariable r2ml:name="customer" r2ml:class="srv:Customer"/>
     </r2ml:arguments>
    </r2ml:MessageEventExpression>
   </r2ml:triggeringEvent>
   <r2ml:conditions>
    <r2ml:ObjectClassificationAtom r2ml:class="srv:AvailableCar">
     <r2ml:ObjectVariable r2ml:name="car"/>
    </r2ml:ObjectClassificationAtom>
   </r2ml:conditions>
   <r2ml:producedAction>
    <r2ml:InvokeActionExpression r2ml:operation="approveOrder">
     <r2ml:contextArgument>
      <r2ml:ObjectVariable r2ml:name="car"/>
     </r2ml:contextArgument>
     <r2ml:arguments>
      <r2ml:Object r2ml:objectID="customer"/>
     </r2ml:arguments>
    </r2ml:InvokeActionExpression>
   </r2ml:producedAction>
   <r2ml:postcondition>
    <r2ml:ObjectClassificationAtom r2ml:class="srv:SoldCar">
     <r2ml:ObjectVariable r2ml:name="car"/>
    </r2ml:ObjectClassificationAtom>
   </r2ml:postcondition>
  </r2ml:ReactionRule>
 </r2ml:ReactionRuleSet>
</r2ml:RuleBase>
