Trace of Prolog example from Test 1

This is the "trace" output using SWI-Prolog: you would write only the "conclusions", e.g.
X = bob

ancestor-of(High,Low) :-
	parent-of(High,Low).
ancestor-of(High,Low) :-
	parent-of(High,Middle),
	ancestor-of(Middle,Low).

[debug]  ?- trace.

Yes
[trace]  ?- ancestor-of(me,X).
   Call: (7) ancestor-of(me, _G287) ? creep
   Call: (8) parent-of(me, _G287) ? creep
   Call: (9) child(me, _G287) ? creep
   Exit: (9) child(me, bob) ? creep
   Exit: (8) parent-of(me, bob) ? creep
   Exit: (7) ancestor-of(me, bob) ? creep

X = bob ;
   Fail: (9) child(me, _G287) ? creep
   Redo: (8) parent-of(me, _G287) ? creep
   Call: (9) spouse(me, _G350) ? creep
   Exit: (9) spouse(me, mary) ? creep
   Call: (9) child(mary, _G287) ? creep
   Exit: (9) child(mary, bob) ? creep
   Exit: (8) parent-of(me, bob) ? creep
   Exit: (7) ancestor-of(me, bob) ? creep

X = bob ;
   Redo: (9) child(mary, _G287) ? creep
   Exit: (9) child(mary, sally) ? creep
   Exit: (8) parent-of(me, sally) ? creep
   Exit: (7) ancestor-of(me, sally) ? creep

X = sally ;
   Fail: (9) child(mary, _G287) ? creep
   Fail: (9) spouse(me, _G350) ? creep
   Fail: (8) parent-of(me, _G287) ? creep
   Redo: (7) ancestor-of(me, _G287) ? creep
   Call: (8) parent-of(me, _G343) ? creep
   Call: (9) child(me, _G343) ? creep
   Exit: (9) child(me, bob) ? creep
   Exit: (8) parent-of(me, bob) ? creep
   Call: (8) ancestor-of(bob, _G287) ? creep
   Call: (9) parent-of(bob, _G287) ? creep
   Call: (10) child(bob, _G287) ? creep
   Fail: (10) child(bob, _G287) ? creep
   Redo: (9) parent-of(bob, _G287) ? creep
   Call: (10) spouse(bob, _G356) ? creep
   Fail: (10) spouse(bob, _G356) ? creep
   Fail: (9) parent-of(bob, _G287) ? creep
   Redo: (8) ancestor-of(bob, _G287) ? creep
   Call: (9) parent-of(bob, _G349) ? creep
   Call: (10) child(bob, _G349) ? creep
   Fail: (10) child(bob, _G349) ? creep
   Redo: (9) parent-of(bob, _G349) ? creep
   Call: (10) spouse(bob, _G356) ? creep
   Fail: (10) spouse(bob, _G356) ? creep
   Fail: (9) parent-of(bob, _G349) ? creep
   Fail: (8) ancestor-of(bob, _G287) ? creep
   Fail: (9) child(me, _G343) ? creep
   Redo: (8) parent-of(me, _G343) ? creep
   Call: (9) spouse(me, _G350) ? creep
   Exit: (9) spouse(me, mary) ? creep
   Call: (9) child(mary, _G343) ? creep
   Exit: (9) child(mary, bob) ? creep
   Exit: (8) parent-of(me, bob) ? creep
   Call: (8) ancestor-of(bob, _G287) ? creep
   Call: (9) parent-of(bob, _G287) ? creep
   Call: (10) child(bob, _G287) ? creep
   Fail: (10) child(bob, _G287) ? creep
   Redo: (9) parent-of(bob, _G287) ? creep
   Call: (10) spouse(bob, _G356) ? creep
   Fail: (10) spouse(bob, _G356) ? creep
   Fail: (9) parent-of(bob, _G287) ? creep
   Redo: (8) ancestor-of(bob, _G287) ? creep
   Call: (9) parent-of(bob, _G349) ? creep
   Call: (10) child(bob, _G349) ? creep
   Fail: (10) child(bob, _G349) ? creep
   Redo: (9) parent-of(bob, _G349) ? creep
   Call: (10) spouse(bob, _G356) ? creep
   Fail: (10) spouse(bob, _G356) ? creep
   Fail: (9) parent-of(bob, _G349) ? creep
   Fail: (8) ancestor-of(bob, _G287) ? creep
   Redo: (9) child(mary, _G343) ? creep
   Exit: (9) child(mary, sally) ? creep
   Exit: (8) parent-of(me, sally) ? creep
   Call: (8) ancestor-of(sally, _G287) ? creep
   Call: (9) parent-of(sally, _G287) ? creep
   Call: (10) child(sally, _G287) ? creep
   Exit: (10) child(sally, bill) ? creep
   Exit: (9) parent-of(sally, bill) ? creep
   Exit: (8) ancestor-of(sally, bill) ? creep
   Exit: (7) ancestor-of(me, bill) ? creep

X = bill ;
   Fail: (10) child(sally, _G287) ? creep
   Redo: (9) parent-of(sally, _G287) ? creep
   Call: (10) spouse(sally, _G356) ? creep
   Exit: (10) spouse(sally, dad) ? creep
   Call: (10) child(dad, _G287) ? creep
   Exit: (10) child(dad, me) ? creep
   Exit: (9) parent-of(sally, me) ? creep
   Exit: (8) ancestor-of(sally, me) ? creep
   Exit: (7) ancestor-of(me, me) ? creep

X = me ;
   Redo: (10) child(dad, _G287) ? creep
   Exit: (10) child(dad, bill) ? creep
   Exit: (9) parent-of(sally, bill) ? creep
   Exit: (8) ancestor-of(sally, bill) ? creep
   Exit: (7) ancestor-of(me, bill) ? creep

X = bill ;
   Fail: (10) child(dad, _G287) ? creep
   Fail: (10) spouse(sally, _G356) ? creep
   Fail: (9) parent-of(sally, _G287) ? creep
   Redo: (8) ancestor-of(sally, _G287) ? creep
   Call: (9) parent-of(sally, _G349) ? creep
   Call: (10) child(sally, _G349) ? creep
   Exit: (10) child(sally, bill) ? creep
   Exit: (9) parent-of(sally, bill) ? creep
   Call: (9) ancestor-of(bill, _G287) ? creep
   Call: (10) parent-of(bill, _G287) ? creep
   Call: (11) child(bill, _G287) ? creep
   Fail: (11) child(bill, _G287) ? creep
   Redo: (10) parent-of(bill, _G287) ? creep
   Call: (11) spouse(bill, _G362) ? creep
   Fail: (11) spouse(bill, _G362) ? creep
   Fail: (10) parent-of(bill, _G287) ? creep
   Redo: (9) ancestor-of(bill, _G287) ? creep
   Call: (10) parent-of(bill, _G355) ? creep
   Call: (11) child(bill, _G355) ? creep
   Fail: (11) child(bill, _G355) ? creep
   Redo: (10) parent-of(bill, _G355) ? creep
   Call: (11) spouse(bill, _G362) ? creep
   Fail: (11) spouse(bill, _G362) ? creep
   Fail: (10) parent-of(bill, _G355) ? creep
   Fail: (9) ancestor-of(bill, _G287) ? creep
   Fail: (10) child(sally, _G349) ? creep
   Redo: (9) parent-of(sally, _G349) ? creep
   Call: (10) spouse(sally, _G356) ? creep
   Exit: (10) spouse(sally, dad) ? creep
   Call: (10) child(dad, _G349) ? creep
   Exit: (10) child(dad, me) ? creep
   Exit: (9) parent-of(sally, me) ? creep
   Call: (9) ancestor-of(me, _G287) ? creep
   Call: (10) parent-of(me, _G287) ? creep
   Call: (11) child(me, _G287) ? creep
   Exit: (11) child(me, bob) ? creep
   Exit: (10) parent-of(me, bob) ? creep
   Exit: (9) ancestor-of(me, bob) ? creep
   Exit: (8) ancestor-of(sally, bob) ? creep
   Exit: (7) ancestor-of(me, bob) ? creep

X = bob ;
   Fail: (11) child(me, _G287) ? 


Website maintained by Andy Long. Comments appreciated.