After lurking on this list for several years, I am finally starting to
use Jess...
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. Supposed I have a template object with is-a,
concept, and value slots, which I had declard "do-backward-chaining".
Suppose I have the following rules:
(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]
--------------------------------------------------------------------