I think there is some fundamental error in deriving truths from givens and other derived facts that are then interpreted as given truths, and, moreover, with subtly varying semantics. In terms of graph theory: reachability is based on (directed) edges, but it does not establish additional edges. <br>
<br>Deriving Reachability should be done by:<br><br>rule deriveLink<br>when<br>    Link( $a: a, $b: b )<br>then<br>    insertLogical(new Reachable($a,$b));<br>    System.out.println( &quot;ins reach &quot; + $a + &quot; &quot; + $b );<br>
end<br><br>rule deriveReachReach<br>no-loop true<br>when<br>    Reachable( $a: a, $b: b )<br>    Reachable( a == $b, $c: b != $a )<br>then<br>    insertLogical(new Reachable($a,$c));<br>end<br><br>Ideally, I would like to use <br>
   not Reachable(a == $a, b == $c)<br>instead of the (last resort) no-loop in the second rule, but Drools&#39; truth maintenance is incomplete: it does not let your define the logical dependency on part of the condition (i.e., excluding the CE &quot;not&quot; in this case).<br>
<br>-W<br><br><br>   <br><br><br><br><div class="gmail_quote">On 8 March 2011 05:49, Simon Chen <span dir="ltr">&lt;<a href="mailto:simonchennj@gmail.com">simonchennj@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
What I had is a very simplified version of how calculating transitive<br>
closure could go wrong...<br>
<br>
Let&#39;s say we have two rules:<br>
rule 1<br>
when<br>
  link(a,b)<br>
then<br>
  insertLogical(new reachable(a,b))<br>
<br>
rule 2<br>
when<br>
  link(a,b) reachable(b,c)<br>
then<br>
  insertLogical(new reachable(a,c))<br>
<br>
Let&#39;s say, I have link(a,b), link(b,c), link(b,a), link(c,b). So,<br>
we&#39;ll have reachable(a,b), reachable(b,c), reachable(a,c), etc. But,<br>
after I retract link(a,b) and link(b,a), guess what, reachable(c,a)<br>
still exists! This doesn&#39;t sound right to me.<br>
<br>
But in Drools, this is possible, because we have:<br>
reachable(c,a) &lt;- link(c,b), reachable(b,a)<br>
reachable(b,a) &lt;- link(b,c), reachable(c,a)<br>
<br>
The problem here is that we actually inserted reachable(b,a) multiple<br>
times: first supported by link(b,a) and rule 1, and secondly by<br>
link(b,c) and reachable(c,a) and rule 2. When reachable(b,a) was<br>
inserted the second time, link(b,c) and reachable(c,a) become the<br>
additional supporting condition - maintained by the truth maintenance<br>
system. So, even if link(b,a) is retracted, reachable(b,a) still<br>
exists further supporting reachable(c,a).<br>
<br>
Is it clearer?<br>
<br>
Thanks.<br>
-Simon<br>
<br>
2011/3/7 Edson Tirelli &lt;<a href="mailto:ed.tirelli@gmail.com">ed.tirelli@gmail.com</a>&gt;:<br>
<div><div></div><div class="h5">&gt;<br>
&gt;    Simon,<br>
&gt;    The behavior seems correct to me as B is justified by either A or C (or<br>
&gt; both). Of course, from the initial state, A is required for C to first<br>
&gt; exist, but once it starts to exist, your rules say that B and C justify each<br>
&gt; other and so both remain in memory.<br>
&gt;    This is design as intended, but do you think that is wrong?<br>
&gt;    Edson<br>
&gt;<br>
&gt; 2011/3/7 Simon Chen &lt;<a href="mailto:simonchennj@gmail.com">simonchennj@gmail.com</a>&gt;<br>
&gt;&gt;<br>
&gt;&gt; Hi all,<br>
&gt;&gt;<br>
&gt;&gt; An interesting finding:<br>
&gt;&gt;<br>
&gt;&gt; I have three simple rules:<br>
&gt;&gt; rule &quot;A2B&quot;<br>
&gt;&gt;        when<br>
&gt;&gt;                A()<br>
&gt;&gt;        then<br>
&gt;&gt;                insertLogical(new B());<br>
&gt;&gt; end<br>
&gt;&gt; rule &quot;B2C&quot;<br>
&gt;&gt;        when<br>
&gt;&gt;                B()<br>
&gt;&gt;        then<br>
&gt;&gt;                insertLogical(new C());<br>
&gt;&gt; end<br>
&gt;&gt; rule &quot;C2B&quot;<br>
&gt;&gt;        when<br>
&gt;&gt;                C()<br>
&gt;&gt;        then<br>
&gt;&gt;                insertLogical(new B());<br>
&gt;&gt; end<br>
&gt;&gt;<br>
&gt;&gt; Basically, once we have an A(), we&#39;ll logically insert a B(). Once we<br>
&gt;&gt; have a B(), we&#39;ll logically insert a C(). Once we have a C(), we&#39;ll<br>
&gt;&gt; logically insert a B().<br>
&gt;&gt;<br>
&gt;&gt; So, I first insert an A(), print all the objects. Retract A(), and<br>
&gt;&gt; print all the objects. Here&#39;s what I got:<br>
&gt;&gt; com.sample.B@42<br>
&gt;&gt; com.sample.C@43<br>
&gt;&gt; com.sample.A@548997d1<br>
&gt;&gt; after retract!<br>
&gt;&gt; com.sample.B@42<br>
&gt;&gt; com.sample.C@43<br>
&gt;&gt;<br>
&gt;&gt; So, B() and C(), which should be logically depend on A(), somehow are<br>
&gt;&gt; not retracted. The problem I see is the truth maintenance system allow<br>
&gt;&gt; B() and C() to depend on each other, thus not affected by losing A().<br>
&gt;&gt;<br>
&gt;&gt; Is this a bug or my bad usage?<br>
&gt;&gt;<br>
&gt;&gt; Thanks.<br>
&gt;&gt; -Simon<br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; rules-users mailing list<br>
&gt;&gt; <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; --<br>
&gt;   Edson Tirelli<br>
&gt;   JBoss Drools Core Development<br>
&gt;   JBoss by Red Hat @ <a href="http://www.jboss.com" target="_blank">www.jboss.com</a><br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; rules-users mailing list<br>
&gt; <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
&gt;<br>
&gt;<br>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</div></div></blockquote></div><br>