I think Igor Gorbunov wrote:
> Err... OK! I think I understand your point. (not) now
> verifies the presence of (count) facts "before" any
> backward-chaining logic starts its work. This is
> helpful and valid. Let me call it "behavior-1".
Whether this "not" is tested before or after some other pattern
generates "need-count" facts is unspecified. It depends on esoteric
things like the order in which your rules are defined, and the
relative positions within the various rules of the "not" pattern and
the positive pattern. It's not supposed to matter. But Jess doesn't
make any conscious decision regarding *when* to check this "not"
vs. when to generate "need-count" facts. The need-count facts are
generated at the precise moment that the pattern before a positive
count pattern is matched, but the count itself is not; i.e., if
there's a rule
(defrule foo
(something)
(count)
=>...
then as soon as a "something" fact is asserted, need-count will be
generated. The "(not (count))" may have been processed long before,
when the fact matching the preceding pattern was asserted.
>
> But now how can I achive the behavior I need? I want
> (not) to verify precence of (count) facts "after"
> backward-chainig logic finished ("behavior-2").
OK, well, there's always more than one way to do things. Here's one
made up off the top of my head: Your "not" pattern doesn't really mean
"not (count)". It means "not (count) even after need-count was
asserted." Therefore, you might consider changing "not (count)" to
"(couldnt-create-count)" and writing your goal-seeking rule like this:
(defrule create-count-facts
(need-count ...)
=>
(if (possible) then
(assert (count ...))
else
(assert (couldnt-create-count))))
The rule(s) you've already got presumably already make some decision
about when to assert a count fact and when not; all you need to do is
add an "else" clause to that rule, either explicitly, as here, or in
the form of a second goal-seeking rule.
>
> But if you'd choose "behavior-2" as default, then
> achieving "behavior-1" would be easier, and would not
> require salience tuning. Right?
Sure, if that's how Jess worked, but it doesn't.
>
> Would you consider changing standard behavior to
> "behavior-2" in future versions, or it has some other
> implications I am not aware of?
Backward chaining, like everything else in pattern-matching, is driven
by facts being pushed through the Rete network. There are no "phases"
which I could reorder, so no, I can't consider reordering them!
---------------------------------------------------------
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]
--------------------------------------------------------------------