% begruende (Bratko Kap. 15 Abb. 15.8. 'present') % % Displaying the conclusion of a consultation and 'how' explanation % this part assumes: :- op(800, xfx, was). :- op(600, xfx, from). :- op(700,xfx,is). % wenn nun Deutsch sein soll ... begruende(Answer) :- present(Answer). % sorry, for the typo % trotzdem stehts im Englischen so: present(Answer) :- nl, showconclusion(Answer), nl, write('Would you like to see how? '), getreply(Reply), (Reply = yes,!, show(Answer) % Show solution tree ; true ). showconclusion( and(Answer1,Answer2) ) :- !, showconclusion(Answer1), write(' and '), showconclusion(Answer2). showconclusion(Conclusion was Found) :- write(Conclusion). % 'show' displays a complete solution tree show(Solution) :- nl, show(Solution,0),!. % Indent by 0 show( and(Answer1,Answer2) , H) :- !, % Indent by H show(Answer1, H), tab(H),write(and),nl, show(Answer2,H). show( Answer was Found, H) :- % Indent by H tab(H),writeans(Answer), % Show conclusion nl, tab(H), write('was '), show1(Found, H). % Show evidence show1( Derived from Answer, H) :- !, write(Derived), write('from '), % Show rule name nl, H1 is H+4, show(Answer,H1). % Show antecedent show1( Found, _) :- write(Found),nl. writeans(Goal is true) :- !, write(Goal). % Omit 'is true' on output writeans(Answer) :- % This is negative answer write(Answer).