I have found an interaction between the logical keyword and the backchaining facility which is either a bug or something I don't understand.


Suppose that I am doing backchaining with a template foo:

(deftemplate foo
  (declare (backchain-reactive TRUE))
  (slot x)
  (slot y))

It turns out that the rule:

(defrule getFoo
  (logical (enableGetFoo))
  (logical (need-foo (x  ?x)))
  (logical (adder (z ?z)))
  =>
  (assert (foo (x ?x) (y (+ ?x ?z)))))

doesn't seem to work. This rule will not activate or fire even when all the preconditions are satisfied.


If I take out the logical keyword, things appear to work as expected. The getFoo rule fires when I need a foo but the logical support is not there.

If I move the "(logical (enableGetFoo))" line below the need-foo line, then the rule works exactly as I need. (This is what I actually did in my application.)

I put the "adder" predicate in this example to show why I would be putting a logical around a "need-foo". It is because there are other items on the LHS of my rule that I want to be logical but that I don't want to put before the "need-foo".

Is this expected behavior? I have included a file below - sorry for the complexity.

-Timothy
------------------------------------------------------------------------ -----------------


(deftemplate foo
  (declare (backchain-reactive TRUE))
  (slot x)
  (slot y))

(deftemplate adder
  (slot z))


(defrule getFoo (logical (enableGetFoo)) (logical (need-foo (x ?x))) (logical (adder (z ?z))) => (assert (foo (x ?x) (y (+ ?x ?z)))))

(defrule doPropagate
  (logical (propagate ?x))
  (logical (foo (x ?x) (y ?y)))
  =>
  (assert (foobar ?y)))


(reset) (watch all)

(bind ?fact (assert (adder (z 8))))
(assert (propagate 3))
(assert (enableGetFoo))

(printout t "starting run" crlf)
(run)
(printout t "finishing run" crlf)


(modify ?fact (z 11))

(printout t "starting run" crlf)
(run)
(printout t "finishing run" crlf)

--------------------------------------------------------------------
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