> > It seems that the following code, proposed as a FORALL equivalent in the
> > manual, doesn't work anymore in versions 6.1b2 nor 6.1b3:
> >
> > Jess> (defrule forall-example
> >     (not (and (a ?x) (not (b ?x))))
> >     =>)
> > Jess> (assert (a 1))
> > Jess> (assert (a 2))
> > Jess> (assert (b 1))
> > Jess> (assert (b 2))
> > Jess> (run)
> > 0
>
> It looks like you've neglected to call (reset) first. Most (not) CEs
> won't work unless you've called (reset) to assert the
> initial-fact. The manual tries to very plain about this. If you
> pretty-print this rule, you'll see that an initial-fact pattern has
> been inserted -- this is just how the (not) CE works.

My fault. In trying to isolate the bug from my code, I forgot to call
(reset) and even failed to correctly demonstrate my actual problem.
The problem I'm experiencing is better shown by the following transcript of
a Jess session:

Jess, the Java Expert System Shell
Copyright (C) 2001 E.J. Friedman Hill and the Sandia Corporation
Jess Version 6.1b3 2/28/2003

Jess> (watch all)
TRUE
Jess> (defrule forall-example
    (not (and (a ?x) (not (b ?x))))
    =>)
MAIN::forall-example: +1+1+1+1+2+1+1+2+a+2+t
TRUE
Jess> (reset)
 ==> Focus MAIN
 ==> f-0 (MAIN::initial-fact)
==> Activation: MAIN::forall-example :  f-0,
TRUE
Jess> (assert (a 1))
 ==> f-1 (MAIN::a 1)
<== Activation: MAIN::forall-example :  f-0,
<Fact-1>
Jess> (assert (a 2))
 ==> f-2 (MAIN::a 2)
<Fact-2>
Jess> (assert (b 1))
 ==> f-3 (MAIN::b 1)
==> Activation: MAIN::forall-example :  f-0,
<Fact-3>
Jess> (run)
FIRE 1 MAIN::forall-example f-0,
 <== Focus MAIN
1

As you can see, one (a) with a corresponding (b) is enough to activate the
rule, even if there is another (a)without corresponding (b), which is
incorrect.

> > With version 6.0 (and 6.1b1 I believe, but I cannot test anymore), the
> > result of (run) is correctly 2.
>
> The right answer is 1, not 2. Either it is, or is not, true that there
> are a's without corresponding b's. The rule corectly fires once under
> Jess 6.1b3 if you've reset first.

This is in fact the behavior I expected in the first place.

----
Carlo Jelmini - Research Assistant
Computer Vision and Multimedia Laboratory, Viper Group
University of Geneva - Switzerland
Tel: +41 (0)22 705 7632
Fax: +41 (0)22 705 7780
Email: [EMAIL PROTECTED]
URL: http://viper.unige.ch/

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