To solve this problem correctly in all cases, the Jess compiler would need the ability to convert any boolean formula into its DNF equivalent (an OR of AND-s with only positive or negative literals inside the AND-s). The problem is that this conversion is NP-complete in general, therefore I'm not even sure if it's a good idea to have this feature in the first place. If full DNF conversion is a goal of Jess, until this becomes available maybe we should not allow rules to use arbitrary nesting of and/or/not operators.
Mihai [EMAIL PROTECTED] wrote: > Hi Joe, > > Once again, it looks like you've exceeded Jess's current > capabilities. I'm really quite grateful to you for coming up with > these stress tests! > > There's no quick patch, although I made a bit of progress > already. Look for an improvement here in the next release. > > I think Joe Kopena wrote: > > > > 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] > > -------------------------------------------------------------------- > > > > --------------------------------------------------------- > 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] > -------------------------------------------------------------------- -------------------------------------------------------------------- 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] --------------------------------------------------------------------
