A logically asserted object seems to be retracted only when the fact(s)
leading to its inital assertion are invalid/retracted. Even if the
depended object is "backed" by some other rule/facts.
so in the following example:
1 => A
2 => A
As soon, as 1 is asserted, A is asserted. When 2 is asserted, the truth
of A is "backed" but nothing happens as A is already asserted (in terms
of memory management, the reference counter would increase i guess).
When 1 becomes false and is retracted, the truth of A is still given by
2 => A and A should not be retracted (which it is). Only if 2 also
becomes false and is retracted, A should be retracted too.
Gets even more interesting if a fact is backed by itself after inital
assertion: A => A
Without this behaviour logical assertion are not useful in my opinion.
Checked it with JESS which does it properly.
Will it change in the future, and probably already for 3.0?
Juergen.
Example:
--------
DRL:
----
rule "1"
when
s : String()
then
System.out.println("s=" + s);
end
rule "2"
when
i : Integer()
then
System.out.println("i=" + i);
assertLogical("A");
end
Java:
-----
FactHandle h = workingMemory.assertObject(new Integer(1));
workingMemory.fireAllRules();
workingMemory.assertObject(new Integer(2));
workingMemory.fireAllRules();
workingMemory.retractObject(h); // A will be retracted, but should not
workingMemory.fireAllRules();
List l = workingMemory.getObjects();
System.out.println(l);