I think John Barr wrote:

> My gps1 rule is not firing as expected:
> 
...
> (defrule gps1
>     (tpf (id ?tpf-id) (ls G))
>     (suf
>         (id ?tid&:(eq ?tid ?tpf-id))
>         (rn gps1)
>         (cu ?c)
>         (nu ?n))
>     (or (> ?c 65) (> ?n 75))
> =>
>     (printout t "Fired gps1 for " ?tid crlf))

In section 2.8 of Jess the manual, there is an indented paragraph, set
in italics for emphasis, which reads:
----------------------------------------------------------------------
     "The LHS of a rule (the "if" part) consists of patterns that match
facts, NOT function calls. The actions of a rule (the "then" clause)
are made up of function calls. The following rule does NOT work:

        Jess> (defrule wrong-rule
           (eq 1 1)
           =>
           (printout t "Just as I thought,  1 == 1!" crlf))

     This rule will NOT fire just because the function call (eq 1 1)
would evaluate to true. Instead, Jess will try to find a fact on the
knowledge base that looks like (eq 1 1). Unless you have previously
asserted such a fact, this rule will NOT be activated and will not
fire. If you want to fire a rule based on the evaluation of a
function, you can use the test CE."
----------------------------------------------------------------------
In your rule above, you're typing to match either a "(> ?c 65)" fact
or a "(> ?n 75)" fact, neither of which exist.

The "or" conditional element, which is used on the left-hand-side of a
rule and operates on patterns, is a different thing from the "or"
logical function, which can appear on the RHS of a rule or inside a
"test" CE on the LHS of a rule and operates on arbitrary values (the
whole point of the "test" CE is to allow you to use arbitrary function
calls on the LHS of a rule -- no patterns can appear inside of a
test.) In your gps1 rule, you're using the "or" conditional element,
while in your gps2 rule, you're using the "or" logical
function. Although sometimes you can accomplish the same task using
either construct, often only one or the other is appropriate.


---------------------------------------------------------
Ernest Friedman-Hill  
Distributed Systems Research        Phone: (925) 294-2154
Sandia National Labs                FAX:   (925) 294-2234
Org. 8920, MS 9012                  [EMAIL PROTECTED]
PO Box 969                  http://herzberg.ca.sandia.gov
Livermore, CA 94550

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