Thanks, Oana. I think I’m finally starting to get a grip on this thing J.






From: [] On Behalf Of nicolae oana
Sent: 20 February 2007 03:38
To: Rules Users List
Subject: Re: [rules-users] exists + normal column constraints - how many times a rule is cal led in the end????



exists Person(role == "parent") 

checks if in workingMemory is at least one Person fact having  attribute role == "parent", in both your examples.

Your reasoning is correct: the four facts with role =="child" will activate the rule. So, the result for your second example will be the same as the first result, for your list of facts, no matter how you switch the columns.


"Olenin, Vladimir (MOH)" <> wrote:



I’m not sure my understanding of ‘existential quantifiers’ is correct. Hopefully, someone can clear it up a bit…


Providing I have the following fact class:


Person(role: parent/child, name)


And following facts:


1: parent, John

2: parent, Alice

3: parent, Steve

4: parent, Jane

5: child, Eric

6: child, Rob

7: child, May

8: child, April


I expect the rule


Rule “iterate children if at least one parent is found”


            exists Person(role == ‘parent’)

            $child: Person(role == ‘child’)


            // do smth for each $child if at least one parent is found




To iterate through all ‘child’ persons (facts 5 through 8), ie the action will be called exactly 4 times. Is this correct? What would happen if I swap the order of the conditions (with ‘parent exists’ constrain going _after_ ‘child’ constraint):



            $child: Person(role == ‘child’)

            exists Person(role == ‘parent’)





rules-users mailing list



Now that's room service! Choose from over 150,000 hotels
in 45,000 destinations on Yahoo! Travel
to find your fit.