Hi Ernest.
I took a short look at this problem yesterday and noticed: If you
perform a (reset) -- and create an initial-fact -- before performing
(run) this problem does NOT appear. Here's what I ran (a very slightly
modified form of the original list of commands):
(defrule r
(logical (a))
(not (b))
=>
(assert (b)))
(defmodule mod)
(defrule bad-rule
(b)
=>
(printout t "BAD!!!" crlf))
(watch all)
(reset) ;; added by Win Carus
(assert (a))
(facts *) ;; added by Win Carus
(run)
(retract 1) ;; (retract (b))
(run)
(facts *) ;; added by Win Carus
(retract 0) ;; (retract (a))
(focus mod)
(run)
(facts *)
Regards,
Win
Ernest Friedman-Hill wrote:
There's definitely something wrong there. I'll let you know what we
find out when we've tracked it down. Thanks for the report!
On Aug 23, 2007, at 12:47 AM, Aaron Novstrup wrote:
We seem to have found a problem with logical dependencies in Jess. We
have a fact (b) that logically depends on a fact (a). If (b) is
retracted, it is automatically reasserted as long as (a) is still
true. Initially, we assert (a) as fact 0. This causes (b) to be
asserted as fact 1. We retract fact 1, causing (b) to be reasserted
as fact 2. Finally, we retract fact 0. At this point, (b) is not in
working memory, but a rule or query with (b) on the LHS still fires.
The code and output appear below. Looking at the trace, you'll note
that when (a) is retracted, fact 1 is consequently retracted (even
though it was already retracted) and fact 2 is not retracted (even
though it depends on (a)).
Code:
(defrule r
(logical (a))
(not (b))
=>
(assert (b)))
(defmodule mod)
(defrule bad-rule
(b)
=>
(printout t "BAD!!!" crlf))
(watch all)
(assert (a))
(run)
(retract 1) ;; (retract (b))
(run)
(retract 0) ;; (retract (a))
(focus mod)
(run)
(facts *)
Output:
Jess, the Rule Engine for the Java Platform
Copyright (C) 2006 Sandia Corporation
Jess Version 7.0p1 12/21/2006
==> f-0 (MAIN::a)
==> Activation: MAIN::r : f-0,
FIRE 1 MAIN::r f-0,
==> f-1 (MAIN::b)
==> Activation: mod::bad-rule : f-1
<== f-1 (MAIN::b)
==> Activation: MAIN::r : f-0,
<== Activation: mod::bad-rule : f-1
FIRE 1 MAIN::r f-0,
==> f-2 (MAIN::b)
==> Activation: mod::bad-rule : f-2
<== f-0 (MAIN::a)
<== f-1 (MAIN::b)
<== Focus MAIN
==> Focus mod
FIRE 1 mod::bad-rule f-2
BAD!!!
<== Focus mod
==> Focus MAIN
For a total of 0 facts in all modules.
<anovstrup.vcf>
---------------------------------------------------------
Ernest Friedman-Hill
Advanced Software Research Phone: (925) 294-2154
Sandia National Labs FAX: (925) 294-2234
PO Box 969, MS 9012 [EMAIL PROTECTED]
Livermore, CA 94550 http://www.jessrules.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]
--------------------------------------------------------------------
begin:vcard
fn:Win Carus
n:Carus;Win
org:Information Extraction Systems, Inc. (tm)
adr:;;20 East Quinobequin Road;Waban;MA;02468;USA
email;internet:[EMAIL PROTECTED]
title:President
tel;work:(617) 244-5068
tel;fax:(617) 244-5068
note;quoted-printable:=E2=80=9CInformation Extraction Systems=E2=80=9D,
=E2=80=9CInfoExtract=E2=
=80=9D, and =E2=80=9CIEBuilder=E2=80=9D are trademarks or registered
trad=
emarks owned by Information Extraction Systems, Inc.
x-mozilla-html:FALSE
url:http://www.InfoExtract.com
version:2.1
end:vcard