I am working on a simple diagnosis rule based expert system. It should ask questions and recognize animal health problems. I am using backward chaining for reasoning. How do i know which questions to ask on front end for asserting new rules? Lets say i have a bunch of rules IF A THEN B, IF B THEN C. Know it will check for C if B is asserted, then it will check if A is asserted. Now since a isn't asserted, i need to ask the question on front end. Is there some methodology for knowing what question to ask?
It largely depends on the details of how the backward chaining is implemented. For example, here's how you can do it in Jess where the engine generates goals that can be matched by rules:
Jess>
(deftemplate symptom
(declare (backchain-reactive TRUE))
(slot name)
(slot value))
TRUE
Jess>
(deftemplate diagnosis
(slot name))
TRUE
Jess>
(deftemplate question
(slot name)
(slot string))
TRUE
Jess>
(deffacts questions
(question (name has-fever) (string "Does patient have a fever?"))
(question (name swollen-neck) (string "Does patient have a swollen neck?"))
(question (name skin-rash) (string "Does patient have a skin rash?")))
TRUE
Jess>
(defrule measles
(symptom (name has-fever) (value yes))
(symptom (name skin-rash) (value yes))
=>
(assert (diagnosis (name measles)))
(printout t "Patient has measles." crlf))
TRUE
Jess>
(defrule mumps
(symptom (name has-fever) (value yes))
(symptom (name swollen-neck) (value yes))
=>
(assert (diagnosis (name mumps)))
(printout t "Patient has mumps." crlf))
TRUE
Jess>
(defrule ask-question
(need-symptom (name ?name))
(question (name ?name) (string ?string))
(not (diagnosis))
=>
(printout t ?string " ")
(assert (symptom (name ?name) (value (read)))))
TRUE
Jess> (reset)
TRUE
Jess> (run)
Does patient have a fever? yes
Does patient have a swollen neck? yes
Patient has mumps.
3
Jess> (reset)
TRUE
Jess> (run)
Does patient have a fever? yes
Does patient have a swollen neck? no
Does patient have a skin rash? yes
Patient has measles.
4
Jess>