<br>&nbsp;&nbsp; Barath,<br><br>&nbsp;&nbsp; Your mistake is treating NOT as a boolean operator instead of existential quantifier. <br>&nbsp;&nbsp; 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:<br>
<br>Case 1 :&nbsp;&nbsp; $a : Order($value : 1)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;not Order( value &gt; 1)<br> <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; So match is false because there are Orders whose value are 2 and 3.<br><br>Case 2 :&nbsp;&nbsp; $a : Order($value : 2)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;not Order( value &gt; 2)<br>
 <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; So match is false because there is an Order whose value is 3.<br>
<br> Case 3 :&nbsp;&nbsp; $a : Order($value : 3)<br>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;not Order( value &gt; 3)<br>

 <br>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; So match is TRUE because there are NO Orders whose value is greater than 3. <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Rule will fire and retract Order( value : 3)<br><br>

Case 4 :&nbsp;&nbsp; $a : Order($value : 2)<br>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;not Order( value &gt; 2)<br>&nbsp;&nbsp;

 <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 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.<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; And so on...<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Hope it helps,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Edson<br><br><br><div><span class="gmail_quote">2008/2/21, Barath &lt;<a href="mailto:barathguna@gmail.com">barathguna@gmail.com</a>&gt;:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br> Hi,<br> <br> I apologize for my logic fault i made in previous post.<br> <br> The correct logic as follows,<br> <br><br> rule &quot;Descending order&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;when<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$a : Order( $value : value )<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;not Order( value &gt; $value)<br>
&nbsp;&nbsp;&nbsp;&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(&quot;value :&quot;+$value);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;retract($a);<br> end<br> <br> 1. Order value=1<br> <br>2. Order value=2<br> 3. Order value=3<br> <br> <br>Case 1 :&nbsp;&nbsp; $a : Order($value : 1)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;not Order(2 &gt; 1)<br> <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; So rule is False.<br> <br><br> Case 2 :&nbsp;&nbsp; $a : Order($value : 1)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;not Order(3 &gt; 1)<br> <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; So rule is False.<br> <br><br> Case 3 :&nbsp;&nbsp; $a : Order($value : 2)<br>
 <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;not Order(1 &gt; 2)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; So rule is True.<br> <br><br> Case 4 :&nbsp;&nbsp; $a : Order($value : 2)<br> <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;not Order(3 &gt; 2)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; So rule is False.<br> <br><br> Case 5 :&nbsp;&nbsp; $a : Order($value : 3)<br>
 <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;not Order(1 &gt; 3)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; So rule is True.<br> <br><br> Case 6 :&nbsp;&nbsp; $a : Order($value : 3)<br> <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;not Order(2 &gt; 3)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; So rule is True.<br> <br><br> This indicates the rule should fire for three times but its not the case.<br>
 I know i going wrong some where but i couldn&#39;t figure out.<br> Plz do help me.....<br> <br> Barath.<br> <br>--<br> View this message in context: <a href="http://www.nabble.com/Plz-reply-%3A-Descending-order-rule-tp15606103p15610848.html">http://www.nabble.com/Plz-reply-%3A-Descending-order-rule-tp15606103p15610848.html</a><br>
 <br>Sent from the drools - user mailing list archive at <a href="http://Nabble.com">Nabble.com</a>.<br> <br> _______________________________________________<br> rules-users mailing list<br> <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
 <a href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a><br> </blockquote></div><br><br clear="all"><br>-- <br>&nbsp;&nbsp;Edson Tirelli<br>&nbsp;&nbsp;JBoss Drools Core Development<br>
&nbsp;&nbsp;Office: +55 11 3529-6000<br>&nbsp;&nbsp;Mobile: +55 11 9287-5646<br>&nbsp;&nbsp;JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a>