% File: ECMI01.FF_EXPLAIN % Author: Peter Hammond, IC, 1982. Rewritten by Peter Ross % Updated: 30 Nov 1983 % Purpose: the explanation subsystem for FAULTFINDER % The only export is read_ans/2. The first arg is a variable, the % second is a history list containing the (explainable) goals that % led to the calling of read_ans/2. The goals in the list have arity % one less than in reality, because the History argument is omitted. read_ans(Ans, History) :- read_poss_ans(Ans1), check_for_query(Ans1, Ans, History). check_for_query(A, A, _) :- A \== why. check_for_query(why, A, History) :- trace_query(History), check_again_for_query(A). check_again_for_query(A) :- read_poss_ans(A), A \== why. trace_query(History) :- member(Predicate, History), explain(Predicate). trace_query(_) :- repeat, writef('Answer the question, please\l'). explain(find_fault) :- writef('You ask too many questions!\l'), writef('Please answer the original question\l'). explain(ask_for_apparent(F,_)) :- recorded(F, name(FullNameOfFault), _), writef('To determine the apparent state of the fault\l\t%w\l', [FullNameOfFault]). explain(check_again_for(F)) :- recorded(F, name(FullNameOfFault), _), writef('To check if the fault\l\t%w\lis still there.\l', [FullNameOfFault]). explain(test_action_for(F,_)) :- recorded(F, name(FullNameOfFault), _), writef('To determine which faults to consider next in finding the '), writef('state of\l\t%w\l', [FullNameOfFault]). explain(check_proceed_answer(F, cannot_be_corrected)) :- recorded(F, name(FullNameOfFault), _), writef('Although the fault\l\t%w\lcannot be corrected, ', [FullNameOfFault]), writef('you get the chance to investigate other causes.\l'). explain(check_proceed_answer(F, corrected)) :- recorded(F, name(FullNameOfFault), _), writef('A cause of the fault\l\t%w\lhas just been ', [FullNameOfFault]), writef('corrected. Therefore I must check whether it '), writef('has been corrected.\l'). explain(check_preconditions(F)) :- recorded(F, name(FullNameOfFault), _), writef('I am checking a precondition for the fault\l\t%w\l', [FullNameOfFault]). explain(check_one_cause(F,C)) :- recorded(F, name(FullNameOfFault), _), recorded(C, name(FullNameOfCause), _), writef('The fault\l\t%w\lcan cause the fault\l\t%w\l', [FullNameOfCause, FullNameOfFault]).