% UBC CPSC 312
% A small example to illustrate Prolog's tracing.
% Author: Steve Wolfman
% Released into public domain.

foo(a).
foo(b).
bar(b).
baz :- foo(X), bar(X).

% Now, try `trace.` and `?- baz.`

% The result shows how we can retry an atom and have it succeed *differently* than the first time:
% 
% [trace]  ?- baz.
%    Call: (10) baz ? creep
%    Call: (11) foo(_5666) ? creep
%    Exit: (11) foo(a) ? creep      % foo SUCCEEDS, with X (AKA _5666) matched to a.
%    Call: (11) bar(a) ? creep
%    Fail: (11) bar(a) ? creep      % But bar(a) fails; so, 
%    Redo: (11) foo(_5666) ? creep  % we must retry foo.
%    Exit: (11) foo(b) ? creep      % foo succeeds again, differently, with X matched to b.
%    Call: (11) bar(b) ? creep
%    Exit: (11) bar(b) ? creep      % And bar(b) succeeds!
%    Exit: (10) baz ? creep
% true.
