Information Technology Reference
In-Depth Information
Figure 11.8.
A general explanation program
explain.pl
% This program uses three predicates defined elsewhere:
% est - the procedure that establishes a query
% background - the background knowledge to be used
% assumable - an atom that can be used in an explanation
% explain(Q,E): Q can be established if E is added to background KB.
explain(Q,E) :- background(K), merge(E,K,K1), est(K1,Q).
% merge(E,K,K1): adding the atoms E as atomic clauses to K produces K1.
merge([],K,K).
merge([A|E],K,[[A]|K1]) :-
merge(E,K,K1), assumable(A), \+ member(A,E).
?- background(K), assumable(A),
est([[A]|K], [sore_elbow(sue),sore_hips(sue)]).
A = arthritis(sue)
;
No
In this case, only one explanation does the job; tennis elbow is no longer sufficient. In
other cases, there may be no single atom that gives the desired explanation, and one
may need to look for multiple atoms to assume.
11.2.2 A general explanation program
The general explanation program shown in figure 11.8 attempts to find one or more
atoms to assume. The predicate explain takes two arguments: a query Q that is to
be explained and an explanation E that it will generate as a list of atoms to assume.
The merge predicate takes the list of atoms and adds them as atomic clauses to the
knowledge base K , checking along the way that they are assumable and that there are
no repeats in the list.
The explain predicate can be seen in action by looking at another diagnostic exam-
ple, this time involving car trouble (see the knowledge base in figure 11.9). Some
queries for this example appear in figure 11.10.
The first query, without additional assumptions, cannot get an explanation of the
car's not starting.
The second query shows that a dead battery and being out of gas are both single-
atom explanations for the car's not starting.
The third query shows that being out of gas is the only single-atom explanation
for the car's not starting when the radio is working.
 
Search WWH ::




Custom Search