Top Banner
Experiences Using Deliberation RuleML 1.01 as a Rule Interchange Language Do Rulebases Need an External Vocabulary? The 8th International Web Rule Symposium Prague, Czech Republic, August 18-20, 2014 Matthias Tylkowski and Martin Müller Binarypark, Erich-Weinertstr. 1, 03044 Cottbus, Germany
23
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Experiences Using Deliberation RuleML 1.01 as a Rule Interchange Language

Experiences Using Deliberation RuleML 1.01 asa Rule Interchange Language

Do Rulebases Need an External Vocabulary?

The 8th International Web Rule Symposium Prague, Czech Republic, August 18-20, 2014

Matthias Tylkowski and Martin MüllerBinarypark, Erich-Weinertstr. 1, 03044 Cottbus, Germany

Page 2: Experiences Using Deliberation RuleML 1.01 as a Rule Interchange Language

RuleML Basics

• Individuals, Data, Atomic statements, logical

formulas, rules, quantifiers

• Hierarchical sub-languages – RuleML lattice

• Support for various semantics

• Schema configurability via MYNG 1.01

• Design based on Relax NG and XML Schema

The 8th International Web Rule Symposium Prague, Czech Republic, August 18-20, 2014 2

Page 3: Experiences Using Deliberation RuleML 1.01 as a Rule Interchange Language

UServ Product Derby

• Describes a virtual car insurance company

• Business model based on business rules

• Traditional object-oriented data model

o classes (Car, Driver, ConvertibleCar, …),

o properties (price, eligibilityScore, potentialTheftRating )

o objects (car1, car2, …)

The 8th International Web Rule Symposium Prague, Czech Republic, August 18-20, 2014

If all of the following are true, then the car’s potential theft rating is low:- car’s price is less that $20,000- car model is not on the list of “High Theft Probability Auto”

Any senior driver is not a young driver.

3

Page 4: Experiences Using Deliberation RuleML 1.01 as a Rule Interchange Language

Individuals, Data and Variables (1)

The 8th International Web Rule Symposium Prague, Czech Republic, August 18-20, 2014

RuleML Support:

• IRIs (@iri) to provide unique names for individuals. Typing

of individuals (@type)

• Declaration of property values for individuals.

<Atom>

<oid>

<Ind iri="http://userv.org/ontology/i/a9fccd3a-a851-4e80-de3a8c2e15ba"

type="http://userv.org/ontology/LuxuryCar">

</Ind>

</oid>

<slot>

<Rel iri="http://userv.org/ontology/price">price</Rel>

<Data xsi:type="xs:positiveInteger">39000</Data>

</slot>

</Atom>

4

Page 5: Experiences Using Deliberation RuleML 1.01 as a Rule Interchange Language

Individuals, Data and Variables (2)

The 8th International Web Rule Symposium Prague, Czech Republic, August 18-20, 2014

<Assert>

<Atom>

<Rel iri="http://userv.org/ontology/carModel"/>

<Ind iri="http://userv.org/ontology/i/a9fccd3a-a851-4e80-de3a8c2e15ba"

type="http://userv.org/ontology/LuxuryCar">car4</Ind>

<Data xsi:type="xs:string">Honda Odyssey</Data>

</Atom>

<Atom>

<Rel iri="http://userv.org/ontology/price">price</Rel>

<Ind iri="http://userv.org/ontology/i/a9fccd3a-a851-4e80-de3a8c2e15ba"

type="http://userv.org/ontology/LuxuryCar">car4</Ind>

<Data xsi:type="xs:positiveInteger">39000</Data>

</Atom>

</Assert>

RuleML Support:

• Best practice of declarative definition of instances (facts)

by atoms/formulas (𝑙𝑢𝑥𝑢𝑟𝑦𝐶𝑎𝑟 becomes a type)

𝑙𝑢𝑥𝑢𝑟𝑦𝐶𝑎𝑟 𝑐𝑎𝑟4 ∧ 𝑐𝑎𝑟𝑀𝑜𝑑𝑒𝑙 𝑐𝑎𝑟4, ′Honda Odyssey′ ∧ 𝑝𝑟𝑖𝑐𝑒 𝑐𝑎𝑟4, 39000 .

5

Page 6: Experiences Using Deliberation RuleML 1.01 as a Rule Interchange Language

Individuals, Data and Variables (3)

The 8th International Web Rule Symposium Prague, Czech Republic, August 18-20, 2014

<Data xsi:type="xs:positiveInteger">39000</Data>

<Var type="http://userv.org/ontology/ConvertibleCar">C</Var>

RuleML Support:

• Beyond the logic programming tradition, allows typing of XML data(@xsi:type). However, only RuleML supported XML datatypes are permitted.

• Typed variables (@type).

<Data type="us:Rating">

<us:ratingValue xsi:type="xs:positiveInteger">4</us:ratingValue>

<us:ratingVerbalization xml:lang="en">

high

</us:ratingVerbalization>

</Data>

6

• No typing of User-defined structured data

Page 7: Experiences Using Deliberation RuleML 1.01 as a Rule Interchange Language

UServ - Design

The 8th International Web Rule Symposium Prague, Czech Republic, August 18-20, 2014

• Object instances (such as specific cars) map to

RuleML individuals

• Classes map to RuleML unary relations.

• Type classification (aka classes) can also be

declared explicitly inside typed variables or typed

individuals

• Properties map to RuleML binary relations

• Rules are based on ontology models

• UServ rules are based on relations and properties

defined by an external ontology (accessible via RuleML @type ) – the rule vocabulary .

7

Page 8: Experiences Using Deliberation RuleML 1.01 as a Rule Interchange Language

Encoding Types/Classes

<Atom>

<Rel iri="us:Car">car</Rel>

<Var>C</Var>

</Atom>

The 8th International Web Rule Symposium Prague, Czech Republic, August 18-20, 2014

RuleML Support:

• Type/class encoding using variables or individuals

• Type/class encoding using atoms with unary relations

<Ind type="us:Car">car4</Ind>

<Var type="us:Car">C</Var>

∀𝐶 𝑐𝑎𝑟(𝐶)

8

𝑐𝑎𝑟(𝑐𝑎𝑟4)

Page 9: Experiences Using Deliberation RuleML 1.01 as a Rule Interchange Language

Multi-typing

RuleML Support:

• Explicit typing of individuals

The 8th International Web Rule Symposium Prague, Czech Republic, August 18-20, 2014

<Assert>

<Atom>

<Rel iri="http://userv.org/ontology/Car">car</Rel>

<Ind iri="http://userv.org/ontology/i/a9fccd3a-a851-4e80">car1</Ind>

</Atom>

<Atom>

<Rel iri="http://userv.org/ontology/ConvertibleCar">car</Rel>

<Ind iri="http://userv.org/ontology/i/a9fccd3a-a851-4e80">car1</Ind>

</Atom></Assert>

𝑐𝑎𝑟 𝑐𝑎𝑟1 ∧ 𝑐𝑜𝑛𝑣𝑒𝑟𝑡𝑖𝑏𝑙𝑒𝐶𝑎𝑟(𝑐𝑎𝑟1)

9

Page 10: Experiences Using Deliberation RuleML 1.01 as a Rule Interchange Language

Inheritance (1)

RuleML Support:

• No internal subClassOf inheritance support

• Define inheritance externally (e.g. RDFS) or via of rules

<Implies>

<Atom>

<Rel iri="us:ConvertibleCar">convertibleCar</Rel>

<Var>X</Var>

</Atom>

<Atom>

<Rel iri="us:Car">car</Rel>

<Var>X</Var>

</Atom>

</Implies>

The 8th International Web Rule Symposium Prague, Czech Republic, August 18-20, 2014

∀𝐶 𝑐𝑜𝑛𝑣𝑒𝑟𝑡𝑖𝑏𝑙𝑒𝐶𝑎𝑟 𝐶 → 𝑐𝑎𝑟(𝐶)

10

Page 11: Experiences Using Deliberation RuleML 1.01 as a Rule Interchange Language

Inheritance (2)

The 8th International Web Rule Symposium Prague, Czech Republic, August 18-20, 2014

<owl:Class rdf:about="http://userv.org/ontology/ConvertibleCar">

<rdfs:subClassOf rdf:resource="http://userv.org/ontology/Car"/></owl:Class>

<Atom>

<Rel iri="rdfs:subClassOf">subClassOf</Rel>

<arg index="1">

<Rel iri="us:ConvertibleCar" type="owl:Class">convertibleCar</Rel>

</arg>

<arg index="2">

<Plex>

<Rel iri="us:Car" type="owl:Class">car</Rel>

<Rel iri="us:LuxuryCar" type="owl:Class">luxuryCar</Rel>

</Plex>

</arg></Atom>

RuleML Support:• Rule-based inheritance may introduce complexity in execution.

• Usually search (backtracking) used for multiple inheritance

• Keep inheritance in external vocabulary or use higher-order syntax

𝐶𝑜𝑛𝑣𝑒𝑟𝑡𝑖𝑏𝑙𝑒𝐶𝑎𝑟 ⊑ 𝐶𝑎𝑟

∀𝐶 ([𝑐𝑜𝑛𝑣𝑒𝑟𝑡𝑖𝑏𝑙𝑒𝐶𝑎𝑟 𝐶 → 𝑐𝑎𝑟 𝐶 ] ∨ [𝑐𝑜𝑛𝑣𝑒𝑟𝑡𝑖𝑏𝑙𝑒𝐶𝑎𝑟 𝐶 → 𝑙𝑢𝑥𝑢𝑟𝑦𝐶𝑎𝑟 𝐶 ]).

11

Page 12: Experiences Using Deliberation RuleML 1.01 as a Rule Interchange Language

Encoding Properties (1)

The 8th International Web Rule Symposium Prague, Czech Republic, August 18-20, 2014

<Atom>

<Rel iri="us:price">price</Rel>

<!-- the subject of the property -->

<Var type="us:Car">C</Var>

<!-- the value of the property -->

<Data xsi:type="xs:positiveInteger">25000</Data>

</Atom>

<Atom>

<Rel iri="us:price">price</Rel>

<Ind iri="http://userv.org/ontology/i/a9fccd3a-a851-4e80-de3a8c2e15ba"

type="http://userv.org/ontology/LuxuryCar">car4</Ind>

<Data xsi:type="xs:positiveInteger">39000</Data>

</Atom>

∀𝐶 𝑐𝑎𝑟(𝐶) ∧ 𝑝𝑟𝑖𝑐𝑒 𝐶, 25000 .

luxuryCar(𝑐𝑎𝑟4) ∧ 𝑝𝑟𝑖𝑐𝑒 𝑐𝑎𝑟4, 39000 .

12

Page 13: Experiences Using Deliberation RuleML 1.01 as a Rule Interchange Language

Encoding Properties(2)

The 8th International Web Rule Symposium Prague, Czech Republic, August 18-20, 2014

<Atom>

<Rel iri="us:airbag">airbags</Rel>

<Var type="http://userv.org/ontology/Car">C</Var>

<Plex>

<Data xsi:type="xs:string">driverAirbag</Data>

<Data xsi:type="xs:string">frontAirbag</Data>

</Plex>

</Atom>

<Atom>

<Rel iri="us:theftRating">theftRating</Rel>

<Var type="http://userv.org/ontology/LuxuryCar">C</Var>

<Data type="us:Rating" >

<us:ratingValue xsi:type="xs:positiveInteger">4</us:ratingValue>

<us:ratingVerbalization xsi:type="xs:string" xml:lang="en">

high

</us:ratingVerbalization>

</Data>

</Atom>

∀𝐶 𝑙𝑢𝑥𝑢𝑟𝑦𝐶𝑎𝑟 𝐶 ∧ 𝑡ℎ𝑒𝑓𝑡𝑅𝑎𝑡𝑖𝑛𝑔 𝐶, 𝑟𝑎𝑡𝑖𝑛𝑔(4, ′high′) .

13

∀𝐶 𝑐𝑎𝑟 𝐶 ∧ 𝑎𝑖𝑟𝑏𝑎𝑔𝑠 𝐶, [′driverAirbag′, ′𝑓𝑟𝑜𝑛𝑡𝐴𝑖𝑟𝑏𝑎𝑔′]

Page 14: Experiences Using Deliberation RuleML 1.01 as a Rule Interchange Language

Encoding Properties (3)• Definition of properties via external ontology

The 8th International Web Rule Symposium Prague, Czech Republic, August 18-20, 2014

<Atom>

<Rel iri="us:price">price</Rel>

<Var type="us:Car">C</Var>

<Plex>

<Data xsi:type="xs:string">high</Data>

<Data xsi:type="xs:positiveInteger">25000</Data>

</Plex>

</Atom><owl:DatatypeProperty

rdf:about="http://userv.org/ontology/price">

<rdfs:domain rdf:resource=http://userv.org/ontology/Car/>

<rdfs:range>

<owl:Class>

<owl:unionOf rdf:parseType="Collection">

<owl:Class rdf:about="xs:positiveInteger"/>

<owl:Class rdf:about="xs:string"/>

</owl:unionOf>

</owl:Class>

</rdfs:range>

</owl:DatatypeProperty>

14

Page 15: Experiences Using Deliberation RuleML 1.01 as a Rule Interchange Language

Built-ins

RuleML Support:

• Tests such as for numerical constraints and list memberships

• Operators with an @iri attribute refer to libraries of built-in

predicates such as one defined by RIF

The 8th International Web Rule Symposium Prague, Czech Republic, August 18-20, 2014

<Atom>

<Rel iri="pred:numeric-less-than-or-equal">gt</Rel>

<Var type="xs:positiveInteger">P</Var>

<Data xsi:type="xs:integer">45000</Data>

</Atom>

𝑃 ≤ 45000.

15

Page 16: Experiences Using Deliberation RuleML 1.01 as a Rule Interchange Language

Collection membership (1)

RuleML Support:

• List membership tests via use of collections (<Plex>) in atoms

The 8th International Web Rule Symposium Prague, Czech Republic, August 18-20, 2014

<Atom>

<Rel iri="prolog:member">member</Rel>

<Var>M</Var>

<Plex>

<Ind iri="http://userv.org/ontology/i/a9fccd3a-a851-4e80">car1</Ind>

<Ind iri="http://userv.org/ontology/i/5bff7cc6-72f7-4be3">car3</Ind>

<Ind iri="http://userv.org/ontology/i/5eb91389-f1f3-473c">car5</Ind>

</Plex>

</Atom>

16

Page 17: Experiences Using Deliberation RuleML 1.01 as a Rule Interchange Language

Collection membership (2)

RuleML Support:

• Collections must be repeatedly given wherever needed

• Best practice to define collection constants via equality

The 8th International Web Rule Symposium Prague, Czech Republic, August 18-20, 2014

<Equal oriented="yes">

<Ind>HighTheftProbabilityAutoList</Ind>

<Plex>

<Ind iri="http://userv.org/ontology/i/a9fccd3a-a851-4e80">car1</Ind>

<Ind iri="http://userv.org/ontology/i/5bff7cc6-72f7-4be3">car3</Ind>

<Ind iri="http://userv.org/ontology/i/5eb91389-f1f3-473c">car5</Ind>

</Plex>

</Equal>

17

Page 18: Experiences Using Deliberation RuleML 1.01 as a Rule Interchange Language

Rules and Rulebases (1)

RuleML Support:

• Rules are defined similarly with logical implications, but

many flavours are supported. A rulebase is a set of rules.

The 8th International Web Rule Symposium Prague, Czech Republic, August 18-20, 2014

<Implies direction="backward">

<Naf>

<Atom>

<Rel iri="http://userv.org/ontology/hasRollBar">hasRollBar</Rel>

<Var type="http://userv.org/ontology/ConvertibleCar">C</Var>

</Atom>

</Naf>

<Atom>

<Rel iri="http://userv.org/ontology/injuryRating">injuryRating</Rel>

<Var>C</Var>

<Data><us:Value xsi:type="xs:positiveInteger">5</us:Value></Data>

</Atom>

</Implies>

If the car is a convertible and has no roll

bar, then the potential occupant injury is

extremely high.

18

Page 19: Experiences Using Deliberation RuleML 1.01 as a Rule Interchange Language

Rules and Rulebases (2)RuleML Support:

• Limited support for annotations of rulebases: o Logic programming defines a relation by rules. All rules referring

that relation are grouped

o Production rules define a rulebase towards performing a specific task

• No global identity for rulebases (@iri)

The 8th International Web Rule Symposium Prague, Czech Republic, August 18-20, 2014

<Rulebase xml:id="theftRating">

<!-- Processing cars' theftRating -->

<meta>

<Atom>

<Rel iri="http://userv.org/ontology/theftRating">theftRating</Rel>

</Atom>

</meta>

</Rulebase>

19

Page 20: Experiences Using Deliberation RuleML 1.01 as a Rule Interchange Language

Rulebase Metrics

• This rulebase covers around 40% of the use case

• We encoded:

o 30 rules

o 32 predicates, 5 built-ins

o 11 compound facts, 5 descriptions of individuals

o 7 usages of Naf

o 2 usages of Neg

The 8th International Web Rule Symposium Prague, Czech Republic, August 18-20, 2014 20

Page 21: Experiences Using Deliberation RuleML 1.01 as a Rule Interchange Language

Conclusion

The 8th International Web Rule Symposium Prague, Czech Republic, August 18-20, 2014

• RuleML 1.01 can be used as a rule interchange language

• Improvements on handling types, inheritance, collections

and global constants are possible

• UServ design used classes and properties, defined by the

UServ ontology

• Our knowledge base uses NafNegHornlogEq family

• However, except for collections we do not use functions

("Datalog with Plex")

• Equality is used only to define collections as individuals

• Strong negation is used twice because of an explicit

negative information

• NafDatalog+FiniteCollections would be great

21

Page 22: Experiences Using Deliberation RuleML 1.01 as a Rule Interchange Language

Acknowledgments

We would like to thank to Tara Athan, Harold Boley,

Adrian Giurca and Adrian Paschke for their essential

feedback and insights.

The 8th International Web Rule Symposium Prague, Czech Republic, August 18-20, 2014 22

Page 23: Experiences Using Deliberation RuleML 1.01 as a Rule Interchange Language

Useful information sources

• Tutorial introduction (http://ruleml.org/papers/Primer)

• RuleML MediaWiki (http://wiki.ruleml.org)

• RuleML Blog & Social Mediazine

(http://blog.ruleml.org)

• Mailing lists

(http://wiki.ruleml.org/index.php/Mailing_Lists)

• Technical Groups

(http://wiki.ruleml.org/index.php/Technical_Groups)

• RuleML sources hosted on Github

(https://github.com/RuleML)

The 8th International Web Rule Symposium Prague, Czech Republic, August 18-20, 2014 23