Since the following rule is just a variant of (Expert) Example 4.66, "All Buses are Red", I think that there is a bug, in 5.1.1:<br><br>// Does not fire even though all Triangle have all sides > 0<br>rule "All triangle sides are greater than 0"<br>
when<br> forall( Triangle( a > 0, b > 0, c > 0 ) )<br>then<br> System.out.println( "All triangle sides are > 0." );<br>end<br><br>Also, the tortuous equivalent does not fire: <br><br>// Does not fire even though all Triangle have all sides > 0<br>
rule "All triangle sides are greater than 0"<br>
when<br>
forall( $t: Triangle()<br> Triangle( this == $t, a > 0, b > 0, c > 0 ) )<br>
then<br>
System.out.println( "All triangle sides are > 0." );<br>
end<br><br>-W<br><br><br><div class="gmail_quote">On 12 September 2010 19:45, Wolfgang Laun <span dir="ltr"><<a href="mailto:wolfgang.laun@gmail.com">wolfgang.laun@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Given classes<br> class Triangle { int a, b, c;... }<br> class Quadrangle { int a, b, c, d;... }<br>with appropriate getters (but no hashCode or equals) and these facts<br> Triangle( 3, 3, 3 )<br> Triangle( 3, 3, 3 ) // a duplicate, intentional<br>
Quadrangle ( 3, 4, 5, 6 );<br>the rule<br> rule "all equilaterals have a 'fitting' quadrangle"<br> when<br> forall( Triangle( $a: a, b == $a, c == $a )<br> Quadrangle( a == $a || b == $a || c == $a || d == $a ) )<br>
then // ...<br> end<br>works as expected - it fires.<br><br>But the rule<br> rule "all equilaterals have a duplicate"<br>
when<br>
forall( $t: Triangle( $a: a, b == $a, c == $a )<br>
Triangle( this != $t, a == $a, b == $a , c == $a ) )<br>
then // ...<br>
end<br>does not fire, not even when I omit this != $t. Why?<br><br>Do I have a white spot in my grey cells? Please tint my taint...<br><font color="#888888"><br>-W<br><br>
</font></blockquote></div><br>