Ernest,

There appears to be a problem with the (not (exists (XYZ))) pattern.

Here is an example:

(deftemplate processing-state
   (slot currentTaskId)
)

(deftemplate task
   (slot id)
   (slot complete)
)

(deftemplate futureResult
   (slot done)
)

(deffacts initial-tasks
   (task (id 1) (complete FALSE))
   (task (id 2) (complete FALSE))
   (task (id 3) (complete FALSE))
   (task (id 4) (complete FALSE))
   (processing-state (currentTaskId 1))
)

(defrule start-task
   (processing-state (currentTaskId ?taskId))
   (task (id ?taskId) (complete FALSE))
   (not (exists (futureResult)))
=>
   (printout t "Starting task " ?taskId)
   (assert (futureResult (done FALSE)))
)

(defrule process-task
   ?f <- (futureResult (done FALSE))
=>
   (printout t " processing... ")
   (modify ?f (done TRUE))
)

(defrule task-ended
   ?f1 <- (processing-state (currentTaskId ?taskId))
   ?f2 <- (task (id ?taskId) (complete FALSE))
   ?f3 <- (futureResult (done TRUE))
=>
   (printout t "done!" crlf)
   (bind ?nextTaskId (+ ?taskId 1))
   (modify ?f1 (currentTaskId ?nextTaskId))
   (modify ?f2 (complete TRUE))
   (retract ?f3)
)

When this is reset/run no rules fire. If you remove the (exists) portion of
the pattern everything seems to work.

Am I using the (not (exists()) pattern incorrectly? In a previous post you
indicated that (not (XYZ)) and (not (exists (XYZ)) are logically equivalent
so I'm assuming there could be a bug here.

In our actual rules the symptom is the opposite of this example - the
start-task rule fires even in the presence of a (futureResult) fact.

Our rules are more complicated and involve java beans instead of
deftemplates and the process-task rule doesn't exist but is work performed
on another thread started by the start-task rule.

Hopefully this small code snippet can help identify the problem without my
having to cook up another bean/threaded example.

alan

Alan Moore - mailto:[EMAIL PROTECTED]
Ciphergen Biosystems - http://www.ciphergen.com

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