Barath, Your mistake is treating NOT as a boolean operator instead of existential quantifier. In other words: NOT is an EXISTENTIAL quantifier. It will be true only if there are no facts that satisfy your pattern. So, the rule engine will bind a fact to the first pattern and will try to match the existential quantifier NOT against all existing facts:
Case 1 : $a : Order($value : 1) not Order( value > 1) So match is false because there are Orders whose value are 2 and 3. Case 2 : $a : Order($value : 2) not Order( value > 2) So match is false because there is an Order whose value is 3. Case 3 : $a : Order($value : 3) not Order( value > 3) So match is TRUE because there are NO Orders whose value is greater than 3. Rule will fire and retract Order( value : 3) Case 4 : $a : Order($value : 2) not Order( value > 2) Now, this match is true, because there are no more Orders whose value is greater than 2, since Order( value : 3 ) was retracted in the previous step. And so on... Hope it helps, Edson 2008/2/21, Barath <[EMAIL PROTECTED]>: > > > Hi, > > I apologize for my logic fault i made in previous post. > > The correct logic as follows, > > > rule "Descending order" > when > $a : Order( $value : value ) > not Order( value > $value) > then > System.out.println("value :"+$value); > retract($a); > end > > 1. Order value=1 > > 2. Order value=2 > 3. Order value=3 > > > Case 1 : $a : Order($value : 1) > not Order(2 > 1) > > So rule is False. > > > Case 2 : $a : Order($value : 1) > not Order(3 > 1) > > So rule is False. > > > Case 3 : $a : Order($value : 2) > > not Order(1 > 2) > So rule is True. > > > Case 4 : $a : Order($value : 2) > > not Order(3 > 2) > So rule is False. > > > Case 5 : $a : Order($value : 3) > > not Order(1 > 3) > So rule is True. > > > Case 6 : $a : Order($value : 3) > > not Order(2 > 3) > So rule is True. > > > This indicates the rule should fire for three times but its not the case. > I know i going wrong some where but i couldn't figure out. > Plz do help me..... > > Barath. > > -- > View this message in context: > http://www.nabble.com/Plz-reply-%3A-Descending-order-rule-tp15606103p15610848.html > > Sent from the drools - user mailing list archive at Nabble.com. > > _______________________________________________ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > -- Edson Tirelli JBoss Drools Core Development Office: +55 11 3529-6000 Mobile: +55 11 9287-5646 JBoss, a division of Red Hat @ www.jboss.com
_______________________________________________ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users