Download - Rule Languages and Rule Interchange
![Page 1: Rule Languages and Rule Interchange](https://reader035.vdocument.in/reader035/viewer/2022062323/56815869550346895dc5c7ad/html5/thumbnails/1.jpg)
Sujit R NairNovember 30,2009
![Page 2: Rule Languages and Rule Interchange](https://reader035.vdocument.in/reader035/viewer/2022062323/56815869550346895dc5c7ad/html5/thumbnails/2.jpg)
IntroductionNeed / Requirement.Characteristics of current rule markup
Languages.A sample Scenario of Rule InterchangeFuture Work.Conclusion.
![Page 3: Rule Languages and Rule Interchange](https://reader035.vdocument.in/reader035/viewer/2022062323/56815869550346895dc5c7ad/html5/thumbnails/3.jpg)
Need / RequirementExpressiveness.Machine-interpretation.Automated Processing.Translation and Interchange.Publication and Serialization.
![Page 4: Rule Languages and Rule Interchange](https://reader035.vdocument.in/reader035/viewer/2022062323/56815869550346895dc5c7ad/html5/thumbnails/4.jpg)
Current Rule LanguagesRuleML.SWRL.R2ML.W3C RIF.Triple.N3.Jena Rules.Prova.
![Page 5: Rule Languages and Rule Interchange](https://reader035.vdocument.in/reader035/viewer/2022062323/56815869550346895dc5c7ad/html5/thumbnails/5.jpg)
RuleMLBased on XML.Rules consists of derivation, integrity
constraints, production, reaction, tools and transformation.
Datalog RuleML and Hornlog RuleML.
![Page 6: Rule Languages and Rule Interchange](https://reader035.vdocument.in/reader035/viewer/2022062323/56815869550346895dc5c7ad/html5/thumbnails/6.jpg)
SWRLCombining Sublanguages of OWL and
RuleML.Union of DLP and Horn Logic.Adds rules at the cost of undecidability and
lack of complete implementation.Protégé.Rules = Antecedent + Consequent.
![Page 7: Rule Languages and Rule Interchange](https://reader035.vdocument.in/reader035/viewer/2022062323/56815869550346895dc5c7ad/html5/thumbnails/7.jpg)
R2MLBased on concept of RuleML and SWRL.Rules consists of derivation, integrity
constraints, production, reaction.MOF/UML support.
![Page 8: Rule Languages and Rule Interchange](https://reader035.vdocument.in/reader035/viewer/2022062323/56815869550346895dc5c7ad/html5/thumbnails/8.jpg)
W3C RIFFacilitate rule exchange.Dialects.Basic Logic Dialect(RIF-BLD) ↔ Horn Rule
Language.Datatypes and Built-Ins(RIF-DTB).Core.Production Rule Dialect.
![Page 9: Rule Languages and Rule Interchange](https://reader035.vdocument.in/reader035/viewer/2022062323/56815869550346895dc5c7ad/html5/thumbnails/9.jpg)
Jena RulesJava Rule object.Jena2 is much simpler, allows rules to be
specified in compact form in text source files.
![Page 10: Rule Languages and Rule Interchange](https://reader035.vdocument.in/reader035/viewer/2022062323/56815869550346895dc5c7ad/html5/thumbnails/10.jpg)
ProvaWeb rule language + Highly expressive
distributed Web rule engine.Supports complex reaction rule-based
workflow, rule-based event processing, distributed inference services, rule interchange, rule-based decision logic, dynamic access to external data , Web Services and JAVA APIs.
![Page 11: Rule Languages and Rule Interchange](https://reader035.vdocument.in/reader035/viewer/2022062323/56815869550346895dc5c7ad/html5/thumbnails/11.jpg)
Rule Interchange Sample Using RIF to interchange F-Logic Rules and Drools. Scenario :
To supply a vendor-neutral representation of rules, so that rule-system developers can do their work without concern about a vendor-specific format and in particular without concern about the compatibility with the technology of its business partners.
Jane's e-commerce system uses Drools therefore the rules vocabulary is represented using Java beans
John uses an OWL vocabulary and its rules are represented in F-Logic.
![Page 12: Rule Languages and Rule Interchange](https://reader035.vdocument.in/reader035/viewer/2022062323/56815869550346895dc5c7ad/html5/thumbnails/12.jpg)
Rule Interchange (contd)The Two rules that are to be implemented :
a. Rule R1: If an item is perishable and it is delivered more than 10 days after the scheduled delivery date then the item will be rejected.
b. Rule R2: If an item is perishable and it is delivered more than 7 days after the scheduled delivery date but less than 14 days after the scheduled delivery date then a discount of 18.7% will be applied to this delivery.
![Page 13: Rule Languages and Rule Interchange](https://reader035.vdocument.in/reader035/viewer/2022062323/56815869550346895dc5c7ad/html5/thumbnails/13.jpg)
Rule Interchange (contd)Points to be kept in mind:
RIF needs to deal with different vocabularies.
RIF needs an uniform mechanism to address vocabulary elements. The usage of URI's may be such a mechanism.
Vocabulary and rules are separate layers
![Page 14: Rule Languages and Rule Interchange](https://reader035.vdocument.in/reader035/viewer/2022062323/56815869550346895dc5c7ad/html5/thumbnails/14.jpg)
Rule Interchange (contd)John's OWL vocabulary: <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-
syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:owl="http://www.w3.org/2002/07/owl#" xmlns="http://www.example.org/JohnSystem/vocabulary">
<owl:Class rdf:ID="Item"/> <owl:DatatypeProperty rdf:ID="perishable"> <rdfs:domain rdf:resource="#Item"/> <rdfs:range rdf:resource="xs:boolean"/></owl:DatatypeProperty>
![Page 15: Rule Languages and Rule Interchange](https://reader035.vdocument.in/reader035/viewer/2022062323/56815869550346895dc5c7ad/html5/thumbnails/15.jpg)
Rule Interchange (contd)<owl:DatatypeProperty rdf:ID="actualDeliveryDate">
<rdfs:domain rdf:resource="#Item"/> <rdfs:range rdf:resource="xs:date"/> </owl:DatatypeProperty> <owl:DatatypeProperty rdf:ID="scheduledDeliveryDate">
<rdfs:domain rdf:resource="#Item"/> <rdfs:range rdf:resource="xs:date"/> </owl:DatatypeProperty> <owl:DatatypeProperty rdf:ID="status"> <rdfs:domain rdf:resource="#Item"/> <rdfs:range rdf:resource="Status"/>
</owl:DatatypeProperty>
![Page 16: Rule Languages and Rule Interchange](https://reader035.vdocument.in/reader035/viewer/2022062323/56815869550346895dc5c7ad/html5/thumbnails/16.jpg)
Rule Interchange (contd) <owl:DatatypeProperty rdf:ID="discount">
<rdfs:domain rdf:resource="#Item"/>
<rdfs:range rdf:resource="xs:double"/>
</owl:DatatypeProperty>
<owl:Class rdf:ID="Delivery"/>
<owl:Class rdf:ID="Status">
<owl:oneOf rdf:parseType="Collection"> <rdf:List>
<rdf:first rdf:datatype="xs:string">rejected</rdf:first> <rdf:rest>
<rdf:first rdf:datatype="xs:string">accepted</rdf:first> </rdf:rest> </rdf:List>
</owl:oneOf>
</owl:Class>
</rdf:RDF>
![Page 17: Rule Languages and Rule Interchange](https://reader035.vdocument.in/reader035/viewer/2022062323/56815869550346895dc5c7ad/html5/thumbnails/17.jpg)
Rule Interchange (contd)John Rules (F-Logic)
//If an item is perishable and it is delivered more than 10 days after the scheduled delivery date then the item will be rejected RULE R1 I:item[status -> "rejected"] <-
I:item[isPerishable -> true] AND I[actualDeliveryDate -> A] AND
I[scheduledDeliveryDate -> S] AND R is (A - S) AND R > 10.
![Page 18: Rule Languages and Rule Interchange](https://reader035.vdocument.in/reader035/viewer/2022062323/56815869550346895dc5c7ad/html5/thumbnails/18.jpg)
Rule Interchange (contd) //If an item is perishable and it is delivered more than 7 days after the scheduled delivery date but less than 14 days after the scheduled delivery date then a discount of 18.7% will be applied to this delivery. RULE R2 I:item[discount -> 18.7] <-
D:delivery[hasItems->>Items] AND I:item[isPerishable -> true] AND I[actualDeliveryDate -> A] AND I[scheduledDeliveryDate-> S] AND member(I, Items) AND R is (A - S) AND R > 7.
![Page 19: Rule Languages and Rule Interchange](https://reader035.vdocument.in/reader035/viewer/2022062323/56815869550346895dc5c7ad/html5/thumbnails/19.jpg)
Rule Interchange (contd)Jane's Rules (Drools)
package com.sample
import com.sample.Item; rule "R1" when i :
Item( isPerishable==true, actualDeliveryDate : actualDeliveryDate, scheduledDeliveryDate :
scheduledDeliveryDate ) eval( actualDeliveryDate.getDay() – scheduledDeliveryDate.getDay() > 10 ) then i.isRejected(true); modify(i); end
![Page 20: Rule Languages and Rule Interchange](https://reader035.vdocument.in/reader035/viewer/2022062323/56815869550346895dc5c7ad/html5/thumbnails/20.jpg)
Rule Interchange (contd)rule "R2" when d:Delivery(hasItems: hasItems) i : Item(actualDeliveryDate : actualDeliveryDate, scheduledDeliveryDate :
scheduledDeliveryDate ) eval( (actualDeliveryDate.getDay() – scheduledDeliveryDate.getDay() > 7) && hasItems.contains(i)) then i.setDiscount(18.7); modify(i); end
![Page 21: Rule Languages and Rule Interchange](https://reader035.vdocument.in/reader035/viewer/2022062323/56815869550346895dc5c7ad/html5/thumbnails/21.jpg)
Rule Interchange (contd)Importing Jane's Rules in the John's rule
systemTranslating from Drools into RIF Presentation Syntax proposed by RIF-BLD is
used to perform the vocabulary interchange.
![Page 22: Rule Languages and Rule Interchange](https://reader035.vdocument.in/reader035/viewer/2022062323/56815869550346895dc5c7ad/html5/thumbnails/22.jpg)
Rule Interchange (contd)Translation of Jane's Drools Rules rules into
RIFrule "R1" when i :
Item(isPerishable==true, actualDeliveryDate :actualDeliveryDate, scheduledDeliveryDate :
scheduledDeliveryDate ) eval( actualDeliveryDate.getDay() – scheduledDeliveryDate.getDay() > 10) then i.isRejected(true); modify(i); end
![Page 23: Rule Languages and Rule Interchange](https://reader035.vdocument.in/reader035/viewer/2022062323/56815869550346895dc5c7ad/html5/thumbnails/23.jpg)
Rule Interchange (contd)// Translation to RIF Rule ("http://jane.com/R1" ?i#Item[(isRejected->"true"^^xs:boolean) :- And(?i#Item[(isPerishable->"true"^^xs:boolean) (actualDeliveryDate->?actualDeliveryDate ) (scheduledDeliveryDate ->?scheduledDeliveryDate)] op:numeric-greater-than( op:numeric-subtract( user-defined:getDay(?actualDeliveryDate), user-defined:getDay(?scheduledDeliveryDate) ), "10"^^xs:int ) ) )
![Page 24: Rule Languages and Rule Interchange](https://reader035.vdocument.in/reader035/viewer/2022062323/56815869550346895dc5c7ad/html5/thumbnails/24.jpg)
Future WorkOn going research to develop a general rule
mark up language.Most of the research is concentrating on
RuleML and RIF.To cover the shortcomings such as –
procedural call to external objects, operating systems , terminological descriptions for dealing with real world distributed Web Applications.
![Page 25: Rule Languages and Rule Interchange](https://reader035.vdocument.in/reader035/viewer/2022062323/56815869550346895dc5c7ad/html5/thumbnails/25.jpg)
ConclusionWhy is rule markup needed ?Current rule markup languages.RuleML and RIF.W3C RIF BLD provides a robust core for the
interchange of business rules among commercial and academic rule systems.
Embodies both production rules and derivation rules.
![Page 26: Rule Languages and Rule Interchange](https://reader035.vdocument.in/reader035/viewer/2022062323/56815869550346895dc5c7ad/html5/thumbnails/26.jpg)
References1. Adrian Paschke , Harold Boley – Rule Markup
Languages and SWRL.2. W3C Rule Interchange Format,
http://www.w3.org/2005/rules/wiki/RIF_Working_Group
3. RIF Basic Logic Dialect, http://www.w3.org/TR/rif-bld/
4. W3C RIF Use Cases and Requirements, http://www.w3.org/TR/rif-ucr/
Gary Hallmark , Christian de Sainte Marie, Marcos Didonet Del Fabro, Patrick Albert , and Adrian Paschke - Please Pass the Rules: A Rule Interchange Demonstration
![Page 27: Rule Languages and Rule Interchange](https://reader035.vdocument.in/reader035/viewer/2022062323/56815869550346895dc5c7ad/html5/thumbnails/27.jpg)
Contact InformationSujit Raveendran Nair.Email: [email protected]: 972-983-4886.