<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 12 (filtered medium)">
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
span.apple-style-span
        {mso-style-name:apple-style-span;}
span.il
        {mso-style-name:il;}
span.EmailStyle20
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page Section1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.Section1
        {page:Section1;}
-->
</style><!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-GB" link="blue" vlink="purple">
<div class="Section1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;
color:#1F497D">Presumably all your RHS do is insert your Proven objects.&nbsp; If this is the case then my first question is do you actually need to put in an optimisation here?&nbsp;
 How much is the work of evaluating a few extra rule nodes compared to the work and memory that will be required to evaluate the shadow facts and prevent the rules from firing.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;
color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;
color:#1F497D">If you do want to try suppress rules firing couldn&#8217;t you have the following LHS?<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;
color:#1F497D">Piton(predicate == $sentence, rule=&#8221;uniquerulename&#8221;) or not Proven(predicate == $sentence)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;
color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;
color:#1F497D">What I would recommend is lots of reading up about performance, testing, trying different combinations and generating the rete graph that drools produces
 to see whether you have added more or less complexity to the graph.&nbsp; Also make sure you order your conditions so that the ones which are most likely to stop processing are placed first.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;
color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;
color:#1F497D">Thomas<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;
color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;
color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:10.0pt;font-family:
&quot;Tahoma&quot;,&quot;sans-serif&quot;">From:</span></b><span lang="EN-US" style="font-size:10.0pt;
font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;"> rules-users-bounces@lists.jboss.org [mailto:rules-users-bounces@lists.jboss.org]
<b>On Behalf Of </b>Tracey Lall<br>
<b>Sent:</b> 20 March 2010 20:55<br>
<b>To:</b> rules-users@lists.jboss.org<br>
<b>Subject:</b> [rules-users] Mechanism to prevent redundant inferences<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<div>
<p><span lang="EN-US" style="font-size:10.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;">Hi folks</span><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;"><o:p></o:p></span></p>
<p><span lang="EN-US" style="font-size:10.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;">&nbsp;&nbsp;I am writing a logical inference engine in&nbsp;<span class="il"><span style="background:#FFFFCC">drools.</span></span></span><span class="il"><span lang="EN-US" style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;background:
#FFFFCC">&nbsp;</span></span><span class="apple-style-span"><span lang="EN-US" style="font-size:10.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;background:#FFFFCC">Logical
 sentences</span></span><span class="apple-style-span"><span lang="EN-US" style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;background:#FFFFCC">&nbsp;(class Sentence)&nbsp;</span></span><span class="apple-style-span"><span lang="EN-US" style="font-size:10.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;background:#FFFFCC">which
 are proven are indicated by the&nbsp;fact Proven( sentence = $sentence )</span></span><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;"><o:p></o:p></span></p>
<p><span lang="EN-US" style="font-size:10.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;">All Proven(sentence) facts are asserted using the&nbsp;<span class="il"><span style="background:#FFFFCC">drools</span></span>&nbsp;logical mechanism (since logical backtracking is required).</span><span style="font-size:10.0pt;
font-family:&quot;Arial&quot;,&quot;sans-serif&quot;"><o:p></o:p></span></p>
<p><span class="apple-style-span"><span lang="EN-US" style="font-size:10.0pt;
font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;">For efficiency purposes</span></span><span class="apple-style-span"><span lang="EN-US" style="font-size:10.0pt;font-family:
&quot;Arial&quot;,&quot;sans-serif&quot;">&nbsp;I&nbsp;</span></span><span class="apple-style-span"><span lang="EN-US" style="font-size:10.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;">want
 to be able to suppress firing any</span></span><span class="apple-style-span"><span lang="EN-US" style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;">&nbsp;</span></span><span class="apple-style-span"><span lang="EN-US" style="font-size:10.0pt;font-family:
&quot;Calibri&quot;,&quot;sans-serif&quot;">rules</span></span><span class="apple-style-span"><span lang="EN-US" style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;">&nbsp;</span></span><span class="apple-style-span"><span lang="EN-US" style="font-size:10.0pt;font-family:
&quot;Calibri&quot;,&quot;sans-serif&quot;">which&nbsp;assert&nbsp;proof
 of a</span></span><span class="apple-style-span"><span lang="EN-US" style="font-size:10.0pt;font-family:
&quot;Arial&quot;,&quot;sans-serif&quot;">&nbsp;</span></span><span class="apple-style-span"><span lang="EN-US" style="font-size:10.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;">logical
 sentence</span></span><span class="apple-style-span"><span lang="EN-US" style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;">&nbsp;</span></span><span class="apple-style-span"><span lang="EN-US" style="font-size:10.0pt;font-family:
&quot;Calibri&quot;,&quot;sans-serif&quot;">which
 has already been proven (there may be multiple</span></span><span class="apple-style-span"><span lang="EN-US" style="font-size:10.0pt;font-family:
&quot;Arial&quot;,&quot;sans-serif&quot;">&nbsp;</span></span><span class="apple-style-span"><span lang="EN-US" style="font-size:10.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;">inferences
 which prove the same sentence).</span></span><span style="font-size:10.0pt;
font-family:&quot;Arial&quot;,&quot;sans-serif&quot;"><o:p></o:p></span></p>
<p><span class="apple-style-span"><span lang="EN-US" style="font-size:10.0pt;
font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;">If the non existence of a proof of a</span></span><span class="apple-style-span"><span lang="EN-US" style="font-size:10.0pt;font-family:
&quot;Arial&quot;,&quot;sans-serif&quot;">&nbsp;</span></span><span class="apple-style-span"><span lang="EN-US" style="font-size:10.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;">sentence</span></span><span class="apple-style-span"><span lang="EN-US" style="font-size:10.0pt;font-family:
&quot;Arial&quot;,&quot;sans-serif&quot;">&nbsp;(not
 exists Proven(sentence=$sentence)&nbsp;</span></span><span class="apple-style-span"><span lang="EN-US" style="font-size:10.0pt;font-family:
&quot;Calibri&quot;,&quot;sans-serif&quot;">is included in the&nbsp;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 inserted fact handle return is null).</span></span><span style="font-size:
10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;"><o:p></o:p></span></p>
<p><span class="apple-style-span"><span style="font-size:10.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;">As a way around this I created a class Piton() to record whether a particular rule has fired. The lhs conditions then become:</span></span><span style="font-size:
10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;"><o:p></o:p></span></p>
<p><span style="font-size:10.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;">(Proven( predicate == $sentence ) or Piton( fireName == $descriptor ) )<o:p></o:p></span></p>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;">And then in the body of the rule the first thing it asserts is the fact:<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;"><o:p>&nbsp;</o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;">Piton( fireName == $descriptor )<o:p></o:p></span></p>
</div>
<p><span style="font-size:10.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;">Where $descriptor is a string built from the rulename &nbsp;&#43; the set of facts which matched the lhs&nbsp;(ie a descriptor which is unique to the rule fire)</span><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;"><o:p></o:p></span></p>
<p><span style="font-size:10.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;">With this approach when a rule asserts Proven(sentence) because it has also asserted&nbsp;&nbsp;Piton( fireName == descriptor ) ) the lhs of the rule still matches the the rule fire is not retracted.</span><span style="font-size:10.0pt;
font-family:&quot;Arial&quot;,&quot;sans-serif&quot;"><o:p></o:p></span></p>
<p><span style="font-size:10.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;">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.</span><span style="font-size:10.0pt;font-family:
&quot;Arial&quot;,&quot;sans-serif&quot;"><o:p></o:p></span></p>
<p><span style="font-size:10.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;">Is this approach the only way to prevent multiple rule firings for the same proof, or is there a simpler way to achieve this?</span><span style="font-size:10.0pt;
font-family:&quot;Arial&quot;,&quot;sans-serif&quot;"><o:p></o:p></span></p>
<p><span style="font-size:10.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;">Any advice greatly appreciated!</span><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;"><o:p></o:p></span></p>
<p><span class="apple-style-span"><span style="font-size:10.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;">thanks</span></span><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;"><o:p></o:p></span></p>
<p><span style="font-size:10.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;">Tracey</span><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;"><o:p></o:p></span></p>
<p><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;"><o:p>&nbsp;</o:p></span></p>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;"><o:p>&nbsp;</o:p></span></p>
</div>
</div>
</div>
</div>
<br>
<hr>
<font face="Arial" color="Gray" size="1"><br>
**************************************************************************************<br>
This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmaster@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data
 may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary.<br>
<br>
NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00<br>
**************************************************************************************<br>
</font><br>
<hr>
<font face="Arial" color="Gray" size="1">This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmaster@nds.com and delete it from your system as well as any copies. The
 content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes.<br>
To protect the environment please do not print this e-mail unless necessary.<br>
<br>
An NDS Group Limited company. www.nds.com<br>
</font>
</body>
</html>