<span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; "><div><p dir="LTR"><span lang="en-us"><font face="Calibri">Hi folks</font></span></p><p dir="LTR"><span lang="en-us"><font face="Calibri">  I am writing a logical inference engine in <span class="il" style="background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: rgb(255, 255, 204); background-position: initial initial; ">drools.<font class="Apple-style-span" face="arial, sans-serif"> </font><span class="Apple-style-span" style="font-family: arial, sans-serif; "><span lang="en-us"><font face="Calibri">Logical sentences</font></span><span lang="en-us"> (class Sentence) <font face="Calibri">which are proven are indicated by the<span class="Apple-style-span" style="font-family: arial, sans-serif; "><span lang="en-us"><font face="Calibri"> fact Proven( sentence = $sentence )</font></span></span></font></span></span></span></font></span></p>
<p dir="LTR"><span lang="en-us"><font face="Calibri">All Proven(sentence) facts are asserted using the <span class="il" style="background-image: initial; background-repeat: initial; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: rgb(255, 255, 204); background-position: initial initial; ">drools</span> logical mechanism (since logical backtracking is required).</font></span><span lang="en-us"></span></p>
<p dir="LTR"><font class="Apple-style-span" face="Calibri, sans-serif"><span class="Apple-style-span" style="font-family: arial, sans-serif; "><span lang="en-us"><font face="Calibri">For efficiency purposes</font></span><span lang="en-us"> I <font face="Calibri">want to be able to suppress firing any</font></span><span lang="en-us"> <font face="Calibri">rules</font></span><span lang="en-us"> <font face="Calibri">which</font></span><span lang="en-us"><font face="Calibri"> assert</font></span><span lang="en-us"><font face="Calibri"> proof of a</font></span><span lang="en-us"> <font face="Calibri">logical sentence</font></span><span lang="en-us"> <font face="Calibri">which has already been proven (there may be multiple</font></span><span lang="en-us"> <font face="Calibri">inferences which prove the same sentence</font></span><span lang="en-us"><font face="Calibri">).</font></span></span></font></p>
<p dir="LTR"><font class="Apple-style-span" face="Calibri, sans-serif"><span class="Apple-style-span" style="font-family: arial, sans-serif; "><span lang="en-us"><font face="Calibri"><span class="Apple-style-span" style="font-family: arial, sans-serif; "><span lang="en-us"><font face="Calibri">If the non existence of a proof of a</font></span><span lang="en-us"> <font face="Calibri">sentence</font></span><span lang="en-us"> (not exists Proven(sentence=$sentence) <font face="Calibri">is included in the</font></span><span lang="en-us"><font face="Calibri"> lhs conditions then that causes problems when the rule logically asserts Proven(sentence) since the insertion invalidates the lhs conditions and hence the rule causes its own retraction (the i</font></span><span lang="en-us"><font face="Calibri">nserted fact handle return is null).</font></span></span></font></span></span></font></p>
<p dir="LTR"><span class="Apple-style-span" style="font-family: Calibri, sans-serif; ">As a way around this I created a class Piton() to record whether a particular rule has fired. The lhs conditions then become:</span></p>
<p dir="LTR"><font class="Apple-style-span" face="Calibri, sans-serif"></font></p><font class="Apple-style-span" face="Calibri, sans-serif"><p dir="LTR">(Proven( predicate == $sentence ) or Piton( fireName == $descriptor ) )</p>
<div>And then in the body of the rule the first thing it asserts is the fact:</div><div><br></div><div>Piton( fireName == $descriptor )</div></font><p></p><p dir="LTR"><font class="Apple-style-span" face="Calibri, sans-serif">Where $descriptor is a string built from the rulename  + the set of facts which matched the lhs (ie a descriptor which is unique to the rule fire)</font></p>
<p dir="LTR"><font class="Apple-style-span" face="Calibri, sans-serif">With this approach when a rule asserts Proven(sentence) because it has also asserted  Piton( fireName == descriptor ) ) the lhs of the rule still matches the the rule fire is not retracted.</font></p>
<p dir="LTR"><font class="Apple-style-span" face="Calibri, sans-serif">This approach works, but it is rather tedious to implement since the descriptor must be defined in such as way to make it unique (or as far as possible unique) to the particular rule activation. Since the drools variable is not accessible in the lhs of a rule (and hence the activation details are not accessible in the lhs), this means that the descriptor must be handcoded to consist of all matching facts for that lhs.</font></p>
<p dir="LTR"><font class="Apple-style-span" face="Calibri, sans-serif">Is this approach the only way to prevent multiple rule firings for the same proof, or is there a simpler way to achieve this?</font></p><p dir="LTR"><font class="Apple-style-span" face="Calibri, sans-serif">Any advice greatly appreciated!</font></p>
<p dir="LTR"><span class="Apple-style-span" style="font-family: Calibri, sans-serif; ">thanks</span></p><p dir="LTR"><font class="Apple-style-span" face="Calibri, sans-serif">Tracey</font></p><p dir="LTR"><font class="Apple-style-span" face="Calibri, sans-serif"><br>
</font></p><p dir="LTR"><span lang="en-us"></span></p><div><font class="Apple-style-span" face="Calibri, sans-serif"><br></font></div><p dir="LTR"><span lang="en-us"></span></p><p dir="LTR"><span lang="en-us"></span></p></div>
<div></div></span>