I think Waldek Jaronski wrote:

> 
> (defrule need_a
>   (declare (salience 2))
>   (exists (need-zz (a ?v&:(neq ?v nil))))
>   ?fzz <- (explicit (zz))
> =>
 ....
>   (modify ?fzz (a ?zza))
>   (bind ?itr (run-query search_to_clean_a ?zza))

This is a fairly involved problem, so hang on. The thing you probably
don't know is that run-query allows pending rules to fire *during the
call to run-query*. Why? Well, the desired results for some queries
may need to be generated using backward chaining (although that's not
directly relevant here, it's at least ironic.) The release notes for
Jess 6.x mention that by 6.1, there will be a way to control how many
rules are allowed to be fired during a given query call.

OK, so. This rule fires if two facts are present: a need-zz, and any
zz, with any slot values whatsoever. Now, you modify the zz fact,
which means that this rule will be reactivated. You're depending on
the code after the run-query to deactivate the rule by retracting the
need-zz facts. But since run-query will fire activated rules, this
rule fires again before that code executes!

You need a way to keep this rule from being reactivated when you
modify the zz fact. That would be very easy to do: just make the
pattern a little more specific:

>   ?fzz <- (explicit (zz (b nil)))

i.e., only activate this rule using a zz with a b slot containing no
value. In fact, this is what you really wanted to say in the first
place, right?



---------------------------------------------------------
Ernest Friedman-Hill  
Distributed Systems Research        Phone: (925) 294-2154
Sandia National Labs                FAX:   (925) 294-2234
Org. 8920, MS 9012                  [EMAIL PROTECTED]
PO Box 969                  http://herzberg.ca.sandia.gov
Livermore, CA 94550

--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
--------------------------------------------------------------------

Reply via email to