Dr. Friedman-Hill (and others),
This problem took up an unplanned portion of my day today, so even 
though I've achieved my end goal, I'm hoping you can shed some light on 
what I've been missing or doing wrong.

I was trying to write a rule that basically implements the statement "if 
for any two lists the second list contains all members of the first list 
or has a member in a given relation with a member of the first list, 
fire the rule." This breaks down into "if there does not exist a member 
of the first list which is not in the second list or is not in the 
relation with a member of the second list, fire the rule." I think this 
implements that:

(defrule rule3
   (rule-holds ?list2 ?list1)
   (not
     (and
       (list-item ?list1 ?x)
       (not
         (and (list-item ?list2 ?y)
           (or
             (sugar ?x ?y)
             (test (eq ?x ?y))
           )
         )
       )
     )
   )
=>
   (printout t "Rule 3 fired..." crlf);
   ; end rule 1
)


For example, on this input it fires as you'd expect:
(assert
   (list-item Foo A)
   (list-item Foo B)

   (list-item Bar A)

   (rule-holds Foo Bar)
)

However, if I take this rule pretty much verbatim (changing the 
relation) and incorporate it into my (largeish) rulebase, it doesn't 
work as I'd expect. More correctly, if I remove the or and the sugar 
relation it works as I expect, and if I remove the sugar but keep the or 
it works as I expect, but as soon as I add in the sugar it doesn't fire 
(even though I would think it still should since they are indeed eq and 
it fired without the sugar there).

This drove me crazy because it worked in my small test but not in the 
larger application (and I was pretty sure there were no typos present). 
In the end I got it to work by transforming the rule into this form:

(defrule rule4

   (rule-holds ?list2 ?list1)

   (not
     (and
       (list-item ?list1 ?y)

       (not
         (or
           (list-item ?list2 ?y)
           (and
             (list-item ?list2 ?x)
             (sugar ?x ?y)
           )
         )
       )
     )
   )

=>
   (printout t "Rule 4 fired..." crlf);

   ; end rule 1
)

So, am I missing something here about what forms Jess can compile or did 
I make an actual mistake?

Thanks

-- 
- joe kopena

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