The difference is actually that the "not" in Rule1 doesn't have a
"preceding pattern", and therefore Jess inserts "(initial-fact)", so that
the rule won't work unless you've executed "(reset)" at the beginning of
the session, as described in section 6.10 of the Jess 7.1 manual. See

http://www.jessrules.com/jess/docs/71/rules.html#not_ce


On 1/6/12 8:40 AM, "Theodore Patkos" <pat...@ics.forth.gr> wrote:

>Hello everyone and best wishes for the new year
>
>could someone please give me an explanation why the following two rules
>behave in a different way, although they express the same logical
>formula (i.e., not (Object ^ Pred) )? In fact, only the second rule
>reaches correct conclusions, as I note below.
>
>(defrule Rule1
>(not
>    (and
>       ?o <- (Object (name B))
>       (Pred (obj ?o))
>))
>=>
>(printout t "OK1" crlf)
>)
>
>
>(defrule Rule2
>(or
>    (not (Object (name B)))
>    (and
>       ?o <- (Object (name B))
>       (not (Pred (obj ?o)))
>))
>=>
>(printout t "OK2" crlf)
>)
>
>The definition of facts could be like:
>(deftemplate Object (slot name))
>(assert (Object (name A)))
>(assert (Object (name B)))
>(deftemplate Pred (slot obj))
>
>where <obj> is the id of some Object fact, eg.
>
>(defrule Rule
>(declare (salience 10))
>?o <- (Object (name A))
>=>
>(assert (Pred (obj ?o)))
>)
>
>
>What I notice is that Rule1 behaves erroneously when the Object fact
>exists in the KB, but not the Pred fact: although it is supposed to be
>triggered, it is not! Rule2, on the other hand, behaves correctly all
>the times.
>
>When both Object and Pred facts exist or when the Object does not exist,
>both rules behave fine.
>
>So, what is wrong with the syntax of the first rule? No variable
>definition is used outside the not pattern..
>
>Thanks
>
>Theodore
>
>
>--------------------------------------------------------------------
>To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
>in the BODY of a message to majord...@sandia.gov, NOT to the list
>(use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
>--------------------------------------------------------------------


--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
in the BODY of a message to majord...@sandia.gov, NOT to the list
(use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
--------------------------------------------------------------------

Reply via email to