I think Samson Tu wrote: > > After lurking on this list for several years, I am finally starting to > use Jess...
Welcome! > > I want to use the backward-chaining facility in Jess. I am using the > JessTab, which has functions that are not stardard Jess, but I think the > problem is the same. The problem here is that you're picturing in your mind only the "immunosuppressed" Assertion as a goal, but that's not how Jess sees it. Because everything in your program is an Assertion fact, and you've declared Assertion to be backward-chaining reactive, every Assertion pattern is a goal in itself. Jess will independently assert (need-Assertion (concept "chronic_steroids")) and (need-Assertion (concept "cancer_chemotherapy")) facts that have nothing to do with the "immunosuppressed" Assertion. In fact, there will be no backtracking at all from the "immunosuppressed" goal, because there is no corresponding "need-Assertion" rule for that goal. To get the behavior you want you'll need to make the backwards paths explicit. Jess's backward chaining is not as automatic as Prolog's is, for example. A final note: need-Assertion rules don't need to include the (not) pattern you've written: Jess inserts precisely this pattern automatically. > (defrule R8b " " > (object (is-a Assertion) > (concept "chronic_steroids") > (value TRUE)) > => (make-instance (str-cat Assertion (gensym*)) of Assertion > (concept "immunosuppressed")(value TRUE)) > ) > > > (defrule R8a " " > (object (is-a Assertion) > (concept "cancer_chemotherapy") > (value TRUE)) > => (make-instance (str-cat Assertion (gensym*)) of Assertion > (concept "immunosuppressed")(value TRUE)) > ) > > > (defrule R9a" " > (object (is-a Assertion) > (concept "immunosuppressed") > (value TRUE)) > => (make-instance (str-cat Assertion (gensym*)) of Assertion > (concept "infection possible")(value TRUE)) > ) > > "make-instance" is a JessTab function that creates the appropriate > Protege instance and assert it as a Jess fact. From Jess documentation, > my understanding is that, if I want to conclude "infection possible", > and ask a user about "chronic_steroids" and "cancer_chemotherapy" if > necessary, I need to write two rules that use the "need-object" > construct: > > (defrule R14a " " > (need-object (is-a Assertion)(concept "cancer_chemotherapy")) > (not (object (is-a Assertion)(concept "cancer_chemotherapy"))) > => > (printout t "Is the patient receiving cancer chemotherapy? (y/n):") > (bind ?answer (read t)) > (if (eq ?answer y) then > (make-instance (str-cat Assertion (gensym*)) of > Assertion > (concept "cancer_chemotherapy") > (value TRUE)) > else (make-instance (str-cat Assertion (gensym*)) of Assertion > (concept "cancer_chemotherapy") > (value FALSE)) > ) > ) > > > (defrule R14b " " > (need-object (is-a Assertion)(concept "chronic_steroids")) > (not (object (is-a Assertion)(concept "chronic_steroids"))) > => > (printout t "Is the patient taking chronic steroids? (y/n):") > (bind ?answer (read t)) > (if (eq ?answer y) then > (make-instance (str-cat Assertion (gensym*)) of > Assertion > (concept "chronic_steroids") > (value TRUE)) > else (make-instance (str-cat Assertion (gensym*)) of Assertion > (concept "chronic_steroids") > (value FALSE)) > ) > ) > > > My problem is that both R14a and R14b will fire, no matter what answer I > give. In backward-chaining systems I know about, the rule engine would > seek to satisfy the LHS of rules, and if *either* R8a and R8b fires > (e.g. because of chronic steroids), the system will not pursue the other > possibility (e.g. will not ask about cancer chemotherapy). Is there a > way in Jess to simulate this behavior? I tried to give R14a and R14b > lower salience, but that did not produced the desired behavior. > > Thanks. > > Samson > -- > Samson Tu email: [EMAIL PROTECTED] > Stanford Medical Informatics phone: 1-650-725-3391 > Stanford University fax: 1-650-725-7944 > > -------------------------------------------------------------------- > 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] --------------------------------------------------------------------
