1 2 3 8 4 7 6 5Such a position will be represented by a list
[XE/YE,X1/Y1,X2/Y2,X3/Y3,X4/Y4,X5/Y5,X6/Y6,X7/Y7,X8/Y8]with the first pair denoting the coordinates of the empty space, X1/Y1 denoting the coordinates of tile 1, and so on. Coordinates 1/1 refer to the lower left square. The position above is thus represented by the list
[2/2,1/3,2/3,3/3,3/2,3/1,2/1,1/1,1/2]
| ?- prove_e(student_of(S,T),Explanation). S = paul, T = peter, Explanation = student_of(paul,peter)because(follows(paul,computer_science)because given)and(teaches(peter,computer_science)because given) ? ; S = paul, T = adrian, Explanation = student_of(paul,adrian)because(follows(paul,expert_systems)because given)and(teaches(adrian,expert_systems)because given) ? ; S = maria, T = peter, Explanation = student_of(maria,peter)because(follows(maria,ai_techniques)because given)and(teaches(peter,ai_techniques)because given) ? ; noNotice that because and and are declared as infix functors. Also notice that any predicate on which we use clause(Head,Body) should be declared as dynamic.
| ?- prove_e(sublist1(SL,[a,b]),Explanation). SL = [], Explanation = sublist1([],[a,b])because append([],[a,b],[a,b])and append([],[a,b],[a,b]) ? ; SL = [a], Explanation = sublist1([a],[a,b])because append([],[a,b],[a,b])and append([a],[b],[a,b]) ? ; SL = [a,b], Explanation = sublist1([a,b],[a,b])because append([],[a,b],[a,b])and append([a,b],[],[a,b]) ? ; SL = [], Explanation = sublist1([],[a,b])because append([a],[b],[a,b])and append([],[b],[b]) ? ; SL = [b], Explanation = sublist1([b],[a,b])because append([a],[b],[a,b])and append([b],[],[b]) ? ; SL = [], Explanation = sublist1([],[a,b])because append([a,b],[],[a,b])and append([],[],[]) ? ; noMake use of the built-in predicate call(Goal) to prove goals without explaining them.
| ?- prove_e(bachelor(X),Explanation). X = peter, Explanation = bachelor(peter)because(man(peter)because given)and(not married(peter)) ?