Re: [PATCH] lisa bug: matching on retracted facts
Andy Sloane <[email protected]> Fri, 08 Jul 2005 16:04:16 -0500
| Newsgroups | gmane.lisp.lisa.general |
|---|---|
| Message-ID | <[email protected]> |
Andy Sloane wrote: > ...And now I have a patch. Ok, I now believe my patch is wrong. It works, but for the wrong reason -- the effect is only to replicate a token where a destructive operation occurs on it. I'm concerned that simply doing this might not catch all cases, because node2-not and node2-exists work similarly to node2. > +(defmethod test-against-right-memory ((self node2) (left-tokens > remove-token)) > + (loop for right-token being the hash-value > + of (join-node-right-memory self) > + do (when (test-tokens self left-tokens right-token) > + (pass-tokens-to-successor > + self (combine-tokens > + (make-remove-token left-tokens) right-token))))) The problem stems from the fact that combine-tokens is a destructive operation when the left token is not an add token. From src/rete/reference/join-node.lisp: (defmethod combine-tokens ((left-tokens add-token) (right-token token)) (token-push-fact (replicate-token left-tokens) (token-top-fact right-token))) (defmethod combine-tokens ((left-tokens add-token) (right-token t)) (token-push-fact (replicate-token left-tokens) right-token)) (defmethod combine-tokens ((left-tokens token) (right-token token)) (token-push-fact left-tokens (token-top-fact right-token))) (defmethod combine-tokens ((left-tokens token) (right-token t)) (token-push-fact left-tokens right-token)) I'm guessing this is an optimization to avoid replicating tokens? In my test case, a remove-token is having a fact combined with it, being tested against one branch in the tree, and then the -same- token is being tested against the other branch in the tree, only combine-tokens has stuffed a fact inside it which is no longer relevant, so it no longer matches anything correctly. Changing these simply to always replicate, by getting rid of the add-token specialization and nuking the last two defmethods, fixes the problem in a much more general way. -Andy ------------------------------------------------------- This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual core and dual graphics technology at this free one hour event hosted by HP, AMD, and NVIDIA. To register visit http://www.hp.com/go/dualwebinar