<?xml version="1.0" encoding="UTF-8"?>
<!-- $Rev: 939 $ $Date: 2006-04-11 10:49:22 +0200 (Tue, 11 Apr 2006) $ $Author: giurca $ -->
<!-- This example file is based on the Version 0.1 of R2ML -->
<r2ml:RuleBase xmlns:r2ml="http://oxygen.informatik.tu-cottbus.de/R2ML/0.1/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://oxygen.informatik.tu-cottbus.de/R2ML/0.1/ http://oxygen.informatik.tu-cottbus.de/R2ML/0.1/R2ML.xsd">
	<r2ml:DerivationRuleSet>
		<!--
Prolog  derivation rule 1
-->
		<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"><![CDATA[ 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:predicateID="parent">
					<r2ml:arguments>
						<r2ml:Variable r2ml:name="X"/>
						<r2ml:Variable r2ml:name="Y"/>
					</r2ml:arguments>
				</r2ml:GenericAtom>
				<r2ml:GenericAtom r2ml:predicateID="brother">
					<r2ml:arguments>
						<r2ml:Variable r2ml:name="X"/>
						<r2ml:Variable r2ml:name="Z"/>
					</r2ml:arguments>
				</r2ml:GenericAtom>
			</r2ml:conditions>
			<r2ml:conclusion>
				<r2ml:GenericAtom r2ml:predicateID="uncle">
					<r2ml:arguments>
						<r2ml:Variable r2ml:name="Z"/>
						<r2ml:Variable r2ml:name="Y"/>
					</r2ml:arguments>
				</r2ml:GenericAtom>
			</r2ml:conclusion>
		</r2ml:DerivationRule>
		<!--

Prolog  derivation rule 2

-->
		<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"><![CDATA[ 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:predicateID="natural_number">
					<r2ml:arguments>
						<r2ml:Variable r2ml:name="N"/>
					</r2ml:arguments>
				</r2ml:GenericAtom>
			</r2ml:conditions>
			<r2ml:conclusion>
				<r2ml:GenericAtom r2ml:predicateID="natural_number">
					<r2ml:arguments>
						<r2ml:FunctionTerm r2ml:functorID="succ">
							<r2ml:arguments>
								<r2ml:Variable r2ml:name="N"/>
							</r2ml:arguments>
						</r2ml:FunctionTerm>
					</r2ml:arguments>
				</r2ml:GenericAtom>
			</r2ml:conclusion>
		</r2ml:DerivationRule>
		<!--

RuleML derivation rule 1

-->
		<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"><![CDATA[
						<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:DataPredicateAtom r2ml:dataPredicateID="swrlb:subtract">
					<r2ml:dataArguments>
						<r2ml:DataOperationTerm r2ml:operationID="fn:year-from-dateTime">
							<r2ml:arguments>
								<r2ml:DataOperationTerm r2ml:operationID="fn:current-dateTime"/>
							</r2ml:arguments>
						</r2ml:DataOperationTerm>
						<r2ml:TypedLiteral r2ml:type="xs:integer" r2ml:lexicalValue="1"/>
						<r2ml:DataVariable r2ml:name="previous_year" r2ml:dataTypeID="xs:gYear"/>
					</r2ml:dataArguments>
				</r2ml:DataPredicateAtom>
				<r2ml:DataPredicateAtom r2ml:dataPredicateID="swrlb:greaterThan">
					<r2ml:dataArguments>
						<r2ml:DataOperationTerm r2ml:operationID="spending">
							<r2ml:contextArgument>
								<r2ml:ObjectVariable r2ml:name="customer" r2ml:classID="Customer"/>
							</r2ml:contextArgument>
							<r2ml:arguments>
								<r2ml:DataVariable r2ml:name="previous_year" r2ml:dataTypeID="xs:gYear"/>
							</r2ml:arguments>
						</r2ml:DataOperationTerm>
						<r2ml:TypedLiteral r2ml:type="xs:positiveInteger" r2ml:lexicalValue="5000"/>
					</r2ml:dataArguments>
				</r2ml:DataPredicateAtom>
			</r2ml:conditions>
			<r2ml:conclusion>
				<r2ml:ObjectClassificationAtom r2ml:classID="PremiumCustomer">
					<r2ml:ObjectVariable r2ml:name="customer"/>
				</r2ml:ObjectClassificationAtom>
			</r2ml:conclusion>
		</r2ml:DerivationRule>
		<!-- 

RuleML derivation rule 2

-->
		<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"><![CDATA[
				<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:classID="PremiumCustomer">
					<r2ml:ObjectVariable r2ml:name="customer" r2ml:classID="Customer"/>
				</r2ml:ObjectClassificationAtom>
				<r2ml:ObjectClassificationAtom r2ml:classID="LuxuryProduct">
					<r2ml:ObjectVariable r2ml:name="product" r2ml:classID="Product"/>
				</r2ml:ObjectClassificationAtom>
				<r2ml:AssociationAtom r2ml:associationPredicateID="buy">
					<r2ml:objectArguments>
						<r2ml:ObjectVariable r2ml:name="customer"/>
						<r2ml:ObjectVariable r2ml:name="product"/>
					</r2ml:objectArguments>
				</r2ml:AssociationAtom>
			</r2ml:conditions>
			<r2ml:conclusion>
				<r2ml:AttributionAtom r2ml:attributeID="discount">
					<r2ml:subject>
						<r2ml:ObjectVariable r2ml:name="customer"/>
					</r2ml:subject>
					<r2ml:value>
						<r2ml:TypedLiteral r2ml:type="xs:decimal" r2ml:lexicalValue="7.5"/>
					</r2ml:value>
				</r2ml:AttributionAtom>
			</r2ml:conclusion>
		</r2ml:DerivationRule>
		<!--

SQL derivation rule (view) 1

-->
		<r2ml:DerivationRule r2ml:id="DR005">
			<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:predicateID="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:predicateID="location">
					<r2ml:arguments>
						<r2ml:Variable r2ml:name="id"/>
						<r2ml:Variable r2ml:name="city"/>
					</r2ml:arguments>
				</r2ml:GenericAtom>
			</r2ml:conditions>
			<r2ml:conclusion>
				<r2ml:GenericAtom r2ml:predicateID="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>
		<!--

OCL derivation rule 1

-->
		<r2ml:DerivationRule r2ml:id="DR006" xmlns:srv="http://www.services.org/EU-Rent/">
			<r2ml:Documentation>
				<r2ml:RuleText r2ml:textFormat="plain" r2ml:ruleDiagram="http://oxygen.informatik.tu-cottbus.de/R2ML/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"><![CDATA[
			 	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:associationPredicateID="srv:isStoredAt">
					<r2ml:objectArguments>
						<r2ml:ObjectVariable r2ml:name="rentalCar" r2ml:classID="srv:RentalCar"/>
						<r2ml:ObjectVariable r2ml:name="branch" r2ml:classID="srv:Branch"/>
					</r2ml:objectArguments>
				</r2ml:AssociationAtom>
				<r2ml:ObjectClassificationAtom r2ml:isNegated="true" r2ml:classID="srv:RentalCarScheduledForService">
					<r2ml:ObjectVariable r2ml:name="rentalCar"/>
				</r2ml:ObjectClassificationAtom>
				<r2ml:AssociationAtom r2ml:isNegated="true" r2ml:associationPredicateID="srv:isAssignedTo">
					<r2ml:objectArguments>
						<r2ml:ObjectVariable r2ml:name="rentalCar" r2ml:classID="srv:rentalCar"/>
						<r2ml:ObjectVariable r2ml:name="rental" r2ml:classID="srv:Rental"/>
					</r2ml:objectArguments>
				</r2ml:AssociationAtom>
			</r2ml:conditions>
			<r2ml:conclusion>
				<r2ml:AssociationAtom r2ml:isNegated="false" r2ml:associationPredicateID="srv:isAvailableAt">
					<r2ml:objectArguments>
						<r2ml:ObjectVariable r2ml:name="rentalCar" r2ml:classID="srv:RentalCar"/>
						<r2ml:ObjectVariable r2ml:name="branch" r2ml:classID="srv:Branch"/>
					</r2ml:objectArguments>
				</r2ml:AssociationAtom>
			</r2ml:conclusion>
		</r2ml:DerivationRule>
		<!--

OCL derivation rule 2

-->
		<r2ml:DerivationRule r2ml:id="DR007" xmlns:swrlb="http://www.w3.org/2003/11/swrlb">
			<r2ml:Documentation>
				<r2ml:RuleText r2ml:textFormat="plain" r2ml:ruleDiagram="http://oxygen.informatik.tu-cottbus.de/R2ML/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"><![CDATA[
						 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:date>2006-03-30</dc:date>
			</r2ml:Documentation>
			<r2ml:conditions>
				<r2ml:qf.Disjunction>
					<r2ml:DataPredicateAtom r2ml:dataPredicateID="swrlb:greaterThan">
						<r2ml:dataArguments>
							<r2ml:AttributeFunctionTerm r2ml:attributeID="last_maintenance_date">
								<r2ml:contextArgument>
									<r2ml:ObjectVariable r2ml:name="rentalCar" r2ml:classID="srv:RentalCar"/>
								</r2ml:contextArgument>
							</r2ml:AttributeFunctionTerm>
							<r2ml:TypedLiteral r2ml:lexicalValue="90" r2ml:type="xs:positiveInteger"/>
						</r2ml:dataArguments>
					</r2ml:DataPredicateAtom>
					<r2ml:DataPredicateAtom r2ml:dataPredicateID="swrlb:greaterThan">
						<r2ml:dataArguments>
							<r2ml:AttributeFunctionTerm r2ml:attributeID="service_reading">
								<r2ml:contextArgument>
									<r2ml:ObjectVariable r2ml:name="rentalCar"/>
								</r2ml:contextArgument>
							</r2ml:AttributeFunctionTerm>
							<r2ml:TypedLiteral r2ml:lexicalValue="5000" r2ml:type="xs:positiveInteger"/>
						</r2ml:dataArguments>
					</r2ml:DataPredicateAtom>
				</r2ml:qf.Disjunction>
			</r2ml:conditions>
			<r2ml:conclusion>
				<r2ml:ObjectClassificationAtom r2ml:classID="srv:RentalCarScheduledForService">
					<r2ml:ObjectVariable r2ml:name="rentalCar"/>
				</r2ml:ObjectClassificationAtom>
			</r2ml:conclusion>
		</r2ml:DerivationRule>
		<!--

Derivation rule 

-->
		<r2ml:DerivationRule r2ml:id="DR008">
			<r2ml:Documentation>
				<r2ml:RuleText r2ml:textFormat="plain" r2ml:ruleDiagram="http://oxygen.informatik.tu-cottbus.de/R2ML/examples/DR_Bachelor.gif">
					If a (male) person is a husband (because he is maried to a female person) than he is a bachelor.				
				</r2ml:RuleText>
				<dc:creator>Sergey Lukichev</dc:creator>
				<dc:contributor>Gerd Wagner</dc:contributor>
				<dc:date>2006-04-05</dc:date>
			</r2ml:Documentation>
			<r2ml:conditions>
				<!-- class: Male -->
				<r2ml:ObjectClassificationAtom r2ml:classID="Male">
					<r2ml:ObjectVariable r2ml:name="x"/>
				</r2ml:ObjectClassificationAtom>
				<r2ml:ObjectClassificationAtom r2ml:classID="Bachelor" r2ml:isNegated="true">
					<r2ml:ObjectVariable r2ml:name="x"/>
				</r2ml:ObjectClassificationAtom>
			</r2ml:conditions>
			<r2ml:conclusion>
				<!-- association: isMarriedTo -->
				<r2ml:AssociationAtom r2ml:associationPredicateID="isMarriedTo">
					<r2ml:objectArguments>
						<r2ml:RoleFunctionTerm r2ml:refPropertyID="husband">
							<r2ml:argument>
								<r2ml:ObjectVariable r2ml:name="x"/>
							</r2ml:argument>
						</r2ml:RoleFunctionTerm>
						<r2ml:ObjectVariable r2ml:name="y"/>
					</r2ml:objectArguments>
				</r2ml:AssociationAtom>
			</r2ml:conclusion>
		</r2ml:DerivationRule>
	</r2ml:DerivationRuleSet>
	<!--

Production rule set

-->
	<r2ml:ProductionRuleSet>
		<!--
IRL production rule 1

-->
		<r2ml:ProductionRule r2ml:id="PR001" xmlns:srv="http://www.services.org/EU-Rent/">
			<r2ml:Documentation>
				<r2ml:RuleText r2ml:textFormat="plain" r2ml:ruleDiagram="http://oxygen.informatik.tu-cottbus.de/R2ML/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:qf.Conjunction>
					<r2ml:DataPredicateAtom r2ml:dataPredicateID="swrlb:greaterThan">
						<r2ml:dataArguments>
							<r2ml:AttributeFunctionTerm r2ml:attributeID="orderValue">
								<r2ml:contextArgument>
									<r2ml:ObjectVariable r2ml:name="order" r2ml:classID="srv:Order"/>
								</r2ml:contextArgument>
							</r2ml:AttributeFunctionTerm>
							<r2ml:TypedLiteral r2ml:lexicalValue="1000" r2ml:type="xs:positiveInteger"/>
						</r2ml:dataArguments>
					</r2ml:DataPredicateAtom>
					<r2ml:DataPredicateAtom r2ml:dataPredicateID="swrlb:equal" r2ml:isNegated="true">
						<r2ml:dataArguments>
							<r2ml:AttributeFunctionTerm r2ml:attributeID="customerRating">
								<r2ml:contextArgument>
									<r2ml:ObjectVariable r2ml:name="order" r2ml:classID="srv:Order"/>
								</r2ml:contextArgument>
							</r2ml:AttributeFunctionTerm>
							<r2ml:TypedLiteral r2ml:lexicalValue="gold" r2ml:type="xs:string"/>
						</r2ml:dataArguments>
					</r2ml:DataPredicateAtom>
				</r2ml:qf.Conjunction>
			</r2ml:conditions>
			<r2ml:producedAction>
				<r2ml:AssignActionExpression r2ml:propertyID="srv:discount">
					<r2ml:contextArgument>
						<r2ml:ObjectVariable r2ml:name="order" r2ml:classID="srv:Order"/>
					</r2ml:contextArgument>
					<r2ml:TypedLiteral r2ml:lexicalValue="10" r2ml:type="xs:positiveInteger"/>
				</r2ml:AssignActionExpression>
			</r2ml:producedAction>
		</r2ml:ProductionRule>
		<!--
JESS production rule 1

-->
		<r2ml:ProductionRule r2ml:id="PR002">
			<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"><![CDATA[
			       (defrule welcome-toddlers  "Give a special greeting to young children"
					(person {age < 3})	=>	(printout  "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:GenericAtom r2ml:predicateID="swrlb:lessThan">
					<r2ml:arguments>
						<r2ml:FunctionTerm r2ml:functorID="person">
							<r2ml:arguments>
								<r2ml:Variable r2ml:name="age"/>
							</r2ml:arguments>
						</r2ml:FunctionTerm>
						<r2ml:IndividualConstant r2ml:individualConstantID="3"/>
					</r2ml:arguments>
				</r2ml:GenericAtom>
			</r2ml:conditions>
			<r2ml:producedAction>
				<r2ml:InvokeActionExpression r2ml:operationID="printout">
					<r2ml:contextArgument>
						<r2ml:ObjectVariable r2ml:name="person"/>
					</r2ml:contextArgument>
					<r2ml:argument>
						<r2ml:TypedLiteral r2ml:lexicalValue="Hello, little one! &#x000D;&#x000A;" r2ml:type="xs:string"/>
					</r2ml:argument>
				</r2ml:InvokeActionExpression>
			</r2ml:producedAction>
		</r2ml:ProductionRule>
		<!--

 production rule 	

-->
		<r2ml:ProductionRule r2ml:id="PR003">
			<r2ml:Documentation>
				<r2ml:RuleText r2ml:textFormat="plain" r2ml:ruleDiagram="http://oxygen.informatik.tu-cottbus.de/R2ML/examples/PR_RentalDiscount.gif" r2ml:ruleVocabularyDiagram="http://oxygen.informatik.tu-cottbus.de/R2ML/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:DataPredicateAtom r2ml:dataPredicateID="swrlb:greaterThanOrEqual">
					<r2ml:dataArguments>
						<r2ml:DataOperationTerm r2ml:operationID="minus">
							<r2ml:contextArgument>
								<r2ml:ObjectVariable r2ml:name="r" r2ml:classID="Rental"/>
							</r2ml:contextArgument>
							<r2ml:arguments>
								<r2ml:AttributeFunctionTerm r2ml:attributeID="startDate">
									<r2ml:contextArgument>
										<r2ml:ObjectVariable r2ml:name="sd" r2ml:classID="Rental"/>
									</r2ml:contextArgument>
								</r2ml:AttributeFunctionTerm>
								<r2ml:AttributeFunctionTerm r2ml:attributeID="reservationDate">
									<r2ml:contextArgument>
										<r2ml:ObjectVariable r2ml:name="rd" r2ml:classID="Rental"/>
									</r2ml:contextArgument>
								</r2ml:AttributeFunctionTerm>
							</r2ml:arguments>
						</r2ml:DataOperationTerm>
						<r2ml:TypedLiteral r2ml:lexicalValue="5" r2ml:type="xs:positiveInteger"/>
					</r2ml:dataArguments>
				</r2ml:DataPredicateAtom>
			</r2ml:conditions>
			<r2ml:producedAction>
				<r2ml:AssignActionExpression r2ml:propertyID="discount">
					<r2ml:contextArgument>
						<r2ml:ObjectVariable r2ml:name="r" r2ml:classID="Rental"/>
					</r2ml:contextArgument>
					<r2ml:TypedLiteral r2ml:lexicalValue="10" r2ml:type="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"><![CDATA[
				<swrl:variable rdf:ID=”r1”/>
				<swrl:variable rdf:ID=”rb”/>
				<swrl:variable rdf:ID=”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: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:classID="Rental"/>
					<r2ml:Implication>
						<!-- antecedent -->
						<!--					<r2ml:Conjunction>-->
						<r2ml:WeakNegation>
							<r2ml:ObjectClassificationAtom r2ml:classID="OneWayRental">
								<r2ml:ObjectVariable r2ml:name="r1"/>
							</r2ml:ObjectClassificationAtom>
						</r2ml:WeakNegation>
						<!--					</r2ml:Conjunction>-->
						<!-- consequent -->
						<r2ml:EqualityAtom>
							<r2ml:RoleFunctionTerm r2ml:refPropertyID="returnBranch">
								<r2ml:argument>
									<r2ml:ObjectVariable r2ml:name="r1"/>
								</r2ml:argument>
							</r2ml:RoleFunctionTerm>
							<r2ml:RoleFunctionTerm r2ml:refPropertyID="pickupBranch">
								<r2ml:argument>
									<r2ml:ObjectVariable r2ml:name="r1"/>
								</r2ml:argument>
							</r2ml:RoleFunctionTerm>
						</r2ml:EqualityAtom>
					</r2ml:Implication>
				</r2ml:UniversallyQuantifiedFormula>
			</r2ml:constraint>
		</r2ml:AlethicIntegrityRule>
		<r2ml:AlethicIntegrityRule r2ml:id="AIT1001">
			<r2ml:Documentation>
				<r2ml:RuleText r2ml:ruleDiagram="" r2ml:textFormat="plain">Each additional driver of a rental must be a qualified driver</r2ml:RuleText>
				<r2ml:SourceCode r2ml:language="SWRL"><![CDATA[
				<swrl:variable rdf:ID=”r1”/>
				<swrl:variable rdf:ID=”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=”#p1”/>
				 </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:classID="Person"/>
					<r2ml:Implication>
						<r2ml:Conjunction>
							<r2ml:ObjectClassificationAtom r2ml:classID="srv:Rental">
								<r2ml:ObjectVariable r2ml:name="r1"/>
							</r2ml:ObjectClassificationAtom>
							<r2ml:ReferencePropertyAtom r2ml:refPropertyID="srv:additionalDriver">
								<r2ml:subject>
									<r2ml:ObjectVariable r2ml:name="p1" r2ml:classID="Person"/>
								</r2ml:subject>
								<r2ml:object>
									<r2ml:ObjectVariable r2ml:name="r1"/>
								</r2ml:object>
							</r2ml:ReferencePropertyAtom>
						</r2ml:Conjunction>
						<r2ml:ObjectClassificationAtom r2ml:classID="srv:QualifiedDriver">
							<r2ml:ObjectVariable r2ml:name="p1"/>
						</r2ml:ObjectClassificationAtom>
					</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=""><![CDATA[
				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:eventTypeID="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:classID="RentalCar"/>
						<r2ml:ObjectVariable r2ml:name="customer" r2ml:classID="Customer"/>
					</r2ml:arguments>
				</r2ml:MessageEventExpression>
			</r2ml:triggeringEvent>
			<r2ml:conditions>
				<r2ml:DataPredicateAtom r2ml:dataPredicateID="ge">
					<r2ml:dataArguments>
						<r2ml:AttributeFunctionTerm r2ml:attributeID="srv:lastservice">
							<r2ml:contextArgument>
								<r2ml:ObjectVariable r2ml:name="rentalCar" r2ml:classID="srv:RentalCar"/>
							</r2ml:contextArgument>
						</r2ml:AttributeFunctionTerm>
						<r2ml:AttributeFunctionTerm r2ml:attributeID="odometer_reading">
							<r2ml:contextArgument>
								<r2ml:ObjectVariable r2ml:name="rentalCar" r2ml:classID="srv:RentalCar"/>
							</r2ml:contextArgument>
						</r2ml:AttributeFunctionTerm>
						<r2ml:TypedLiteral r2ml:type="xs:positiveInteger" r2ml:lexicalValue="5000"/>
					</r2ml:dataArguments>
				</r2ml:DataPredicateAtom>
			</r2ml:conditions>
			<r2ml:producedAction>
				<r2ml:InvokeActionExpression r2ml:operationID="service">
					<r2ml:contextArgument>
						<r2ml:ObjectVariable r2ml:name="rentalCar" r2ml:classID="srv:RentalCar"/>
					</r2ml:contextArgument>
				</r2ml:InvokeActionExpression>
			</r2ml:producedAction>
		</r2ml:ReactionRule>
		<!-- 

ECA 2 		

-->
		<r2ml:ReactionRule r2ml:id="ECA002" xmlns:srv="http://www.example.org/">
			<r2ml:Documentation>
				<r2ml:RuleText r2ml:ruleDiagram="http://oxygen.informatik.tu-cottbus.de/R2ML/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"><![CDATA[
            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:eventTypeID="productOrder">
					<r2ml:arguments>
						<r2ml:ObjectVariable r2ml:name="car" r2ml:classID="srv:Car"/>
						<r2ml:ObjectVariable r2ml:name="customer" r2ml:classID="srv:Customer"/>
					</r2ml:arguments>
				</r2ml:MessageEventExpression>
			</r2ml:triggeringEvent>
			<r2ml:conditions>
				<r2ml:ObjectClassificationAtom r2ml:classID="srv:AvailableCar">
					<r2ml:ObjectVariable r2ml:name="car"/>
				</r2ml:ObjectClassificationAtom>
			</r2ml:conditions>
			<r2ml:producedAction>
				<r2ml:InvokeActionExpression r2ml:operationID="approveOrder">
					<r2ml:contextArgument>
						<r2ml:ObjectVariable r2ml:name="car"/>
					</r2ml:contextArgument>
					<r2ml:argument>
						<r2ml:ObjectName r2ml:objectID="customer"/>
					</r2ml:argument>
				</r2ml:InvokeActionExpression>
			</r2ml:producedAction>
			<r2ml:postcondition>
				<r2ml:ObjectClassificationAtom r2ml:classID="srv:SoldCar">
					<r2ml:ObjectVariable r2ml:name="car"/>
				</r2ml:ObjectClassificationAtom>
			</r2ml:postcondition>
		</r2ml:ReactionRule>
	</r2ml:ReactionRuleSet>
</r2ml:RuleBase>
