<br>&nbsp;&nbsp; Bryan,<br><br>&nbsp;&nbsp; I&#39;m not sure I completely understood your scenario, but Drools supports FOL and your scenario can be implemented whatever it is.<br><br>&nbsp;&nbsp; I think the best way is giving you some examples:<br><br>
rule &quot;Fires FOR EACH fact that does not have a corresponding Exception Range&quot;<br>&nbsp;&nbsp;when<br>&nbsp;&nbsp;&nbsp;&nbsp;Fact1($number : number)<br>&nbsp;&nbsp;&nbsp;&nbsp;not ExceptionRange(startRange &lt;= $number, stopRange &gt;= $number)<br>&nbsp;&nbsp;then<br>&nbsp;&nbsp;&nbsp; // do something
<br>end<br><br>rule &quot;Fires only IF ALL Facts have a corresponding Exception Range (this rule will fire only once)&quot; <br>
&nbsp;&nbsp;when<br>
&nbsp;&nbsp;&nbsp; not ( <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Fact1($number : number) and<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; not ExceptionRange(startRange &lt;= $number, stopRange &gt;= $number)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; )<br>
&nbsp;&nbsp;then<br>
&nbsp;&nbsp;&nbsp; // do something<br>
end<br>
<br>rule &quot;SAME AS ABOVE: Fires only if all Facts have a corresponding Exception Range (this rule will fire only once)&quot; <br>

&nbsp;&nbsp;when<br>

&nbsp;&nbsp;&nbsp; forall( Fact1($number : number)<br>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ExceptionRange(startRange &lt;= $number, stopRange &gt;= $number) )<br>

&nbsp;&nbsp;then<br>
&nbsp;&nbsp;&nbsp; // do something<br>

end<br>

<br>rule &quot;Fires only if THERE IS ANY Fact that does not have a corresponding Exception Range (this rule will fire only once)&quot; <br>


&nbsp;&nbsp;when<br>


&nbsp;&nbsp;&nbsp; not( forall( Fact1($number : number)<br>


&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ExceptionRange(startRange &lt;= $number, stopRange &gt;= $number) ) )<br>


&nbsp;&nbsp;then<br>
&nbsp;&nbsp;&nbsp; // do something<br>

end<br>


<br>rule &quot;fires FOR EACH PAIR [fact, exception range] (cross product)&quot;<br>&nbsp;&nbsp;when<br>&nbsp;&nbsp;&nbsp;&nbsp;Fact1($number : number)<br>&nbsp;&nbsp;&nbsp;&nbsp;ExceptionRange(startRange &lt;= $number, stopRange &gt;= $number)<br>&nbsp;&nbsp;then<br>&nbsp;&nbsp;&nbsp; // do something
<br>
end<br><br>rule &quot;fires if THERE ARE NO facts that have a corresponding exception range (fires only once)&quot;<br>
&nbsp;&nbsp;when<br>
&nbsp;&nbsp;&nbsp; not ( <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Fact1($number : number) and<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; ExceptionRange(startRange &lt;= $number, stopRange &gt;= $number)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; )<br>
&nbsp;&nbsp;then<br>
&nbsp;&nbsp;&nbsp; // do something<br>

end<br>
<br>&nbsp;&nbsp;&nbsp; Take a look at the &quot;exists&quot; qualifier that is the same as &quot;not( not( ... ) )&quot;.<br>&nbsp;&nbsp;&nbsp; Hope it helps. <br><br>&nbsp;&nbsp;&nbsp; []s<br>&nbsp;&nbsp;&nbsp; Edson<br>
<br><br><div><span class="gmail_quote">2007/9/19, wasabifan &lt;<a href="mailto:bryan.rickman@kewill.com">bryan.rickman@kewill.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>I have several rules I am working on that I am having problems implementing.<br>Most of our tests are composed of at least one &quot;pass&quot; and one &quot;fail&quot; rule.<br>Basically, there are some tests where exceptions need to be thrown based on
<br>a date or number being inside a range where these exceptions occur (causing<br>a possible failure).<br><br>The problem is that we are testing several objects, so using the existensial<br>not, is problematic.<br><br>For example, in the pass, if we write:
<br><br>rule &quot;pass example&quot;<br>&nbsp;&nbsp;when<br>&nbsp;&nbsp;&nbsp;&nbsp;Fact1($number : number)<br>&nbsp;&nbsp;&nbsp;&nbsp;not ExceptionRange(startRange &lt;= $number, stopRange &gt;= $number)<br>&nbsp;&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(&quot;Pass&quot; + $number);<br>
end<br><br>For the fail, it would be like:<br><br>rule &quot;fail example&quot;<br>&nbsp;&nbsp;when<br>&nbsp;&nbsp;&nbsp;&nbsp;Fact1($number : number)<br>&nbsp;&nbsp;&nbsp;&nbsp;ExceptionRange(startRange &lt;= $number, stopRange &gt;= $number)<br>&nbsp;&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;System.out.println
(&quot;Fail&quot; + $number);<br>end<br><br>Is there a way to rewrite the pass rule, so that it checks the existence of<br>a range satisfying each number from Fact1?&nbsp;&nbsp;If I understand not correctly,<br>it will either pass once, and only once if ANY range matches at least one
<br>number from Fact1.&nbsp;&nbsp;Or it would pass for all Fact1&#39;s if any Fact1&#39;s match<br>any exception range.<br><br>A little clarification here would be appreciated, and if you know of a<br>workaround to actually test for getting exactly one and only one pass or
<br>fail (exclusively) for each Fact1 asserted.<br><br>Thanks,<br>Bryan Rickman<br><br><br>--<br>View this message in context: <a href="http://www.nabble.com/Existensial-not-question-tf4481066.html#a12777641">http://www.nabble.com/Existensial-not-question-tf4481066.html#a12777641
</a><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;Software Engineer - JBoss Rules Core Developer<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>