[rules-users] first order logic for every fact exists at least one ...

Wolfgang Laun wolfgang.laun at gmail.com
Mon Aug 26 10:57:21 EDT 2013


On 26/08/2013, hamorsky <peter.hamorsky at kogerusa.com> wrote:
> Hello all,
> how to denote this rule, which will be fulfilled when
>
> for every Integer(this>10) exists at least one Integer, where existing
> Integer's value is equal to -(this)

rule match
when
    forall( Integer( $a: intValue > 10 )
            Integer( intValue == -$a ) )
then
    System.out.println( "YES!" );
end

Note that the "at least one Integer where the value is x" does not
require any extra effort, because there shouldn't be two Integers with
the same value in the first place.
-W

>
> For example:
> If in working memory are present only these facts:
> Integer(5)
> Integer(20)
> Integer(-20)
>
> then requested condition should be fulfilled because
> 5 is not above 10
> -20 is not above 10
> 20 is above 10 and exists -20 where -20 =-(20)
>
> Peter
>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/first-order-logic-for-every-fact-exists-at-least-one-tp4025678.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>


More information about the rules-users mailing list