Artificial Intelligence and Prolog
Copyright © 2020 Jiri Kriz, www.nosco.ch

11    Rule-based Shell, Explanations

Solutions

11.1    Rule-based Shell with Explanations

Start with a simple rule-based shell for backward reasoning that was developed in Exercise 10. The knowledge is represented in if-then rules that have the following syntax:

Rule # if Premise then Conclusion.

Premise can be built out simpler premises using

and, or, not.

The rule grammar is given by the definition of the operators.

The shell operates backwards according to the Prolog proof method. A goal can also be asked from the user (at most once).

Extend this shell by an explanation facility. The shell can justify and explain the solution process to the user:

Test the developed rule-based shell with explanations on the example of the fault diagnosis 11.2.

Solution 11.1

11.2    Rule-based Diagnosis

Test the rule-based shell with explanations on the example of the fault diagnosis of a steam iron using the method of the hypothesis testing. The rules have the form:

Rule # if Symptom then Diagnosis.

Expert knowledge about the steam iron:

  1. If the cloth is burnt, then the temperature is too high.
  2. If the temperature is too high or to low, then the temperature is wrong.
  3. If the temperature is wrong and the thermostat is set correctly, then the thermostat is faulty.
  4. If the temperature is wrong and the thermostat is not set correctly, then the thermostat should be set correctly.
  5. If no steam comes out, then the temperature is too low or there is a problem in the steam system.
  6. If there is a problem in the steam system, then there is no water or the nozzle is congested.
  7. If the iron result is poor, then the temperature is too low.
  8. If the iron is cold and the control lamp shines, then we need to wait.
  9. If the iron is cold and the control lamp does not shine, then there is no power.

Remark:

The rule 5 can be approximated by two rules:
5a) If no steam comes out, then the temperature is too low.
5b) If no steam comes out, then there is a problem in the steam system.
The interpretation of the implication is: "It could be that ...".

Examle of a session with the shell:

?- diagnose.

cloth_burnt [yes./no./why.] ? yes.

thermostat(setup_correctly) [yes./no./why.] ? yes.

diagnosis: thermostat(faulty)

explanation ? [Goal./no.]:  thermostat(faulty).

thermostat(faulty) was proved by using the rule: 
r3 # 
   if   temperature(wrong)and thermostat(setup_correctly)
   then thermostat(faulty)

explanation ? [Goal./no.]:  temperature(wrong).

temperature(wrong) was proved by using the rule: 
r2 # 
   if   temperature(too_high)or temperature(too_low)
   then temperature(wrong)

explanation ? [Goal./no.]: temperature(too_high).

temperature(too_high) was proved by using the rule: 
r1 # 
   if   cloth_burnt
   then temperature(too_high)

explanation ? [Goal./no.]: cloth_burnt.

cloth_burnt was told me

explanation ? [Goal./no.]: no.


further solutions ? [yes./no.]: no.
true .

Solution 11.2