Not and forall operator behaviour

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Not and forall operator behaviour

rogerL
Are the two following statements not equivalent?

    forall($msg:Message()
            Message(this==$msg, sent==true, status!=State._INITIALIZED)
    )


    not( Message(sent==false, status==State._INITIALIZED) )

My understanding is that they both ensure that there are no Message objects in WM with property 'sent' set to false and property 'status' set to State._INITIALIZED.

In my situation, the 'forall' approach is working as expected, the 'not' approach fires once (when there are no Message objects in WM) and never again.

Appreciate if anyone could shed light on this.
Reply | Threaded
Open this post in threaded view
|

Re: [rules-users] Not and forall operator behaviour

Davide Sottara
Both should fire when there is no message.

This said, the two are not equivalent.
The negation of
Message( sent == true, status != INITIALIZED )
is:
Message( sent == false || status == INITIALIZED )
That is, by deMorgan's laws, you need to negate
the operators AND flip the and/or connectives.

In case something still seems weird, could you
please specify the drools version you're using,
as well as which facts you are inserting exactly?

Thanks
Davide


On 05/29/2014 09:33 PM, rogerL wrote:
Are the two following statements not equivalent?

    forall($msg:Message()
            Message(this==$msg, sent==true, status!=State._INITIALIZED)
    )


    not( Message(sent==false, status==State._INITIALIZED) )

My understanding is that they both ensure that there are no Message objects
in WM with property 'sent' set to false and property 'status' set to
State._INITIALIZED.

In my situation, the 'forall' approach is working as expected, the 'not'
approach fires once (when there are no Message objects in WM) and never
again.

Appreciate if anyone could shed light on this.



--
View this message in context: http://drools.46999.n3.nabble.com/Not-and-forall-operator-behaviour-tp4029761.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users



_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users
Reply | Threaded
Open this post in threaded view
|

Re: [rules-users] Not and forall operator behaviour

rogerL
Davide,

Thank you for the clarification. My error was to interpret the "not" operator as an existential function (ie: "there is no such object that exists") and viewing the object as a unit, rather than, as you pointed out, logically manipulable.
In light of that, the logical OR in place of the comma makes sense.

Roger