Hi Wolfgang,
Thanks for the reply.
Leo.
On Fri, Nov 27, 2009 at 7:38 AM, Wolfgang Laun <wolfgang.laun(a)gmail.com>wrote:
2009/11/26 Leonardo Gomes <leonardo.f.gomes(a)gmail.com>
>
>
> On Tue, Nov 24, 2009 at 10:42 PM, Leonardo Gomes <
> leonardo.f.gomes(a)gmail.com> wrote:
>
>> H
>>
>> Now, let's say FactA(1) indicates a fact of type FactA and id = 1.
>>
>> - Then, in the beginning, I insert FactA(1) and FactA(2) in my working
>> memory and fire the rules.
>>
>> rule "test non existence"
>> when
>> not FactA( id == 4 )
>> then
>> output.add("there's no FactA id 4");
>>
>> - This rule is fired and the message is added to my output object.
>>
>> Later on, I have a notification that a FactA has changed, then I:
>> - retract all FactAs from my working memory
>> - clear all FactA-related messages from my output object
>> - reload FactAs (let's say now I have FactA(1), FactA(3), but NOT
>> FactA(4))
>> - reinsert them in the WM
>> - fire the rules
>>
>> The rule that checks that there's no FactA(4) doesn't refire.
>>
>
Why should it? The truth of the non-existance of FactA(4) has been
established, and this truth never changed, certainly not by removing any
FactA(n) and also not by inserting any FactA(x) with x!= 4.
As a solution, you could
- establish an explicit fact, asserted in rule "test non existence" and
retracted by a rule checking the negated condition;
- add a Trigger fact to rule "test non existence" which you modify after
each reload of the FactA set
- do something else which I'm not clever enough to think about at the
moment
-W