[RuleML-all] Re: Need help to define to understand RuleML
Adrian Paschke
paschke at in.tum.de
Wed Aug 1 12:18:58 ADT 2007
Hi Baher,
The solution depends on how the table data is represented.
Assume each row (data set) in the table has a unique id (like a primary
key) then the fact representation could be tableName(ID,X,Y), e.g.
pair(1,x1,y1).
pair(2,x2,y2).
&
A backward-reasoning derivation rule to detect the error could then be
as follows:
error(X1,Y2) :- pair(ID1, X1,Y1), pair(ID2, X2,Y2), ID1!= ID2, X1=X2, Y1=Y2.
The RuleML serialization is:
<Implies>
<head>
<Atom><Rel>error</Rel></Atom>
<Var>X1</Var>
<Var>X2</Var>
</head>
<body>
<And>
<Atom>
<Rel>pair</Rel>
<Var>ID1</Var>
<Var>X1</Var>
<Var>Y1</Var>
</Atom>
<Atom>
<Rel>pair</Rel>
<Var>ID2</Var>
<Var>X2</Var>
<Var>Y2</Var>
</Atom>
<Not>
<Equals>
<Var>ID1</Var><Var>ID2</Var>
</Equals>
</Not>
<Equals>
<Var>X1</Var>
<Var>X2</Var>
</Equals>
<Equals>
<Var>Y1</Var>
<Var>Y2</Var>
</Equals>
</body>
<Implies>
If you dont have an ID, then you might use a function like
findall(pair(X,Y),pair(X,Y),List)
which aggregates all pairs in a list
which you might traverse and look for repeated members. However, your
execution environment needs to support findall (many derivation rule
engines support it, e.g. Prova).
You might also use assert and retract update primitives (if supported)
to implement a global solution. Reaction RuleML
(http://ibis.in.tum.de/research/ReactionRuleML) is supporting derivation
rules with update primitives.
Or is your execution environment a production rule system? XML
serialization of production rules are also addressed by Reaction RuleML.
Best,
Adrian
________________________________________
Von: ruleml-all-bounces at ruleml.org
[mailto:ruleml-all-bounces at ruleml.org] Im Auftrag von Baher Omar
Gesendet: Mittwoch, 1. August 2007 06:30
An: ruleml-all at ruleml.org
Betreff: [RuleML-all] Need help to define to understand RuleML
I'm new to RuleML and I have difficultly coming up with an equivalent
RuleML for the following rule:
"if X is repeated in a sequence of variables then that's an error"
Suppose I have the following table data:
X Y
----------
x1 y1
x2 y2
x3 y2
x1 y1
x2 y3
x1 occurs twice under y1, that's the violation I'm looking for..
How can I describe this rule in RuleML?!
Thanks,
-b
More information about the RuleML-all
mailing list