<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Greetings:<div><br></div><div>It's been interesting watching this thread develop. &nbsp;Originally, I wasn't going to comment but then I threw caution to the four corners of the globe and said, "Why not?" &nbsp;<div><br></div><div>Originally, rulebased systems were simple IF-THEN clauses in a non-monotonic environment such the engine rules were evaluated as true or false, those that were true were placed on the agenda to be fired, which rule to fire next was then selected via some conflict resolution strategy (such as MEA or LEX), the engine fired that rule, and the process started all over until &nbsp;there were no more rules to fire.</div><div><br></div><div>Along the way, a rule might not be true until some other rule fired that made it true. &nbsp;Conversely, if some rule fired that made another rule false that the second rule was removed from the agenda table. &nbsp;A rule is composed of its data and its logic. &nbsp;Originally, an OR statement meant that another rule had to be written. &nbsp;Likewise, an ELSE statement meant that DeMorgan's theorem was applied to the LHS of the rule and a new rules was written.</div><div><br></div><div>Then came OPSJ that featured OR, ELSE and Conditional ELSE where the ELSE (1) clause would only be evaluated if the first CE was false. &nbsp;Very selective and very handy. Normally an ELSE fires if ANY of the CEs are false on the LHS. &nbsp;It seems to me that the idea of "undo" and "rollback" comes from the database world. &nbsp;If a rule no longer matches that does not mean that one of the other rules might not change the data of another CE in another rule so that it does, in fact, match later. &nbsp;Refraction - a feature of almost all rulebased systems - will remove a rule (logic+data) once it fires so I would not think that this is not a matter under consideration.</div><div><br></div><div>Now, to the part that mystifies me: &nbsp;If there was a previous "fireAllRules" and that rule did not match does not mean that the rule would not match this time we run a "fireAllrules" unless the data and the rule logic remained unchanged. &nbsp;if a rule never fires and never will fire, why would it be in the system? &nbsp;Conversely, if the data changes why would one want to "undo" the run from a previous match in another run? &nbsp;You wouldn't. &nbsp;Obviously. &nbsp;But that seems to be what has been promulgated in the foregoing discussion. &nbsp;"No longer matching" does not mean that the rule will never match in the preset "fireAllrules" run - you don't know that until all of the rules on the Agenda (and the changes to the Agenda) have been processed completely. &nbsp;And by that time it's way too late to consider an "undo" for those rules.</div><div><br><div apple-content-edited="true"> <span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-size: 18px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-size: 18px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-size: 18px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-size: 18px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-size: 18px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div><div><div><div><div><div>SDG</div><div>jco</div><div><font class="Apple-style-span" face="'Snell Roundhand'"><i><font class="Apple-style-span" color="#996633"><b>"This above all: to thine own self be true,</b></font></i></font></div><div><div><font class="Apple-style-span" face="'Snell Roundhand'"><i><font class="Apple-style-span" color="#996633"><b>And it must follow, as the night the day,</b></font></i></font></div><div><font class="Apple-style-span" face="'Snell Roundhand'"><i><font class="Apple-style-span" color="#996633"><b>Thou canst not then be false to any man."</b></font></i></font></div><div><font class="Apple-style-span" face="'Snell Roundhand'"><i><font class="Apple-style-span" color="#996633"><b>Hamlet, Act 1, Scene III</b></font></i></font></div><div><font class="Apple-style-span" face="'Snell Roundhand'"><i><font class="Apple-style-span" color="#996633"><b><a href="http://www-tech.mit.edu/Shakespeare/hamlet/hamlet.1.3.html">http://www-tech.mit.edu/Shakespeare/hamlet/hamlet.1.3.html</a></b></font></i></font></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div><div><br></div></div></span></div></span></div></span></div></span></div></span></div><div><div>On Feb 19, 2009, at 8:45 AM, Mark Proctor wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>Geoffrey De Smet wrote:<br><blockquote type="cite">What would an "else clause" do?<br></blockquote><blockquote type="cite">Imagine a rule with matches on 5 different fact sets.<br></blockquote><blockquote type="cite">How many times would the else part match?<br></blockquote><blockquote type="cite">- none (because it matches at least one)<br></blockquote><blockquote type="cite">- a very lot (because it matches on any fact set that isn't that one of those 5)<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">The "undo-then" is another concept:<br></blockquote><blockquote type="cite">it matches when a rule that matched before (in a previous fireAllRules), now no longer matches.<br></blockquote><blockquote type="cite">"undo-then" probably isn't the best name, so better suggestions are welcome, but "else" isn't a good name for it as it's not about "not matching" but about "no longer matching".<br></blockquote>As I mentioned, i'd do it as a logical closure using an anonymous code block, in a similar manner that we do for logical insertions.<br><br>Mark<br><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Anyway, I 've been thinking and it wouldn't work for all use cases in drools-solver:<br></blockquote><blockquote type="cite">rule<br></blockquote><blockquote type="cite"> &nbsp;when<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;q1 : Queen()<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;q2 : Queen()<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;eval(q1.getY() - q2.getY() &lt; 10)<br></blockquote><blockquote type="cite"> &nbsp;then<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;a.add(q1.getY() - q2.getY());<br></blockquote><blockquote type="cite"> &nbsp;undo-then<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;a.subtract(q1.getY() - q2.getY())<br></blockquote><blockquote type="cite">end<br></blockquote><blockquote type="cite">The y of a queen changes, so the subtract wouldn't subtract the exact same number that was added.<br></blockquote><blockquote type="cite">Any way we could work around that, or is there no avoiding insertLogical?<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">With kind regards,<br></blockquote><blockquote type="cite">Geoffrey De Smet<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Mark Proctor schreef:<br></blockquote><blockquote type="cite"><blockquote type="cite">Greg Barton wrote:<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">--- On Wed, 2/18/09, Geoffrey De Smet &lt;<a href="mailto:ge0ffrey.spam@gmail.com">ge0ffrey.spam@gmail.com</a>> wrote:<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> <br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">The current workarounds [to undo-then] are clunky:<br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">- Writing an negative (opposite) rule isn't efficient:<br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">it means declaring the rule twice effectively. Also the<br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">negative rule is usually using lots of or's and<br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">not's which isn't fast.<br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> &nbsp;&nbsp;&nbsp;<br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">This would be made easier by...drum roll please...the else clause! :)<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> &nbsp;<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">yes we want OPSJ style else statements, edson has an idea on how to do that, just a matter of time :(<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">Now, if there was the else clause plus undo-then/closures you could probably write an entire complex ruleset in one rule. &nbsp;Might as well just use perl, then. :P &nbsp;&nbsp;<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">heh, that's true you would have potentially encapsulated 4 possible executions in a single rule.<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_______________________________________________<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">rules-dev mailing list<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><a href="mailto:rules-dev@lists.jboss.org">rules-dev@lists.jboss.org</a><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><a href="https://lists.jboss.org/mailman/listinfo/rules-dev">https://lists.jboss.org/mailman/listinfo/rules-dev</a><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> &nbsp;<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">------------------------------------------------------------------------<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">_______________________________________________<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">rules-dev mailing list<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><a href="mailto:rules-dev@lists.jboss.org">rules-dev@lists.jboss.org</a><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><a href="https://lists.jboss.org/mailman/listinfo/rules-dev">https://lists.jboss.org/mailman/listinfo/rules-dev</a><br></blockquote></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">_______________________________________________<br></blockquote><blockquote type="cite">rules-dev mailing list<br></blockquote><blockquote type="cite"><a href="mailto:rules-dev@lists.jboss.org">rules-dev@lists.jboss.org</a><br></blockquote><blockquote type="cite"><a href="https://lists.jboss.org/mailman/listinfo/rules-dev">https://lists.jboss.org/mailman/listinfo/rules-dev</a><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><br><br>_______________________________________________<br>rules-dev mailing list<br><a href="mailto:rules-dev@lists.jboss.org">rules-dev@lists.jboss.org</a><br>https://lists.jboss.org/mailman/listinfo/rules-dev<br></div></blockquote></div><br></div></div></body></html>