next up previous contents
Next: A note on filenames Up: An Example Previous: Posing a goal   Contents


You will frequently want to see what Prolog does while it is evaluating your programs. This is often necessary when you are trying to track down bugs in your program. Unfortunately, Prolog's debugging environment is not very good. To trace the execution of a goal (such as grandmother(liz, Who).), type


and then a goal, such as

|?- grandmother(liz, Who).

Prolog will then output to the screen the sequence of steps it carries out in executing this goal

  ?- grandmother(liz, Who).
   Call: (6) grandmother(liz, _G396) ? creep
   Call: (7) mother(liz, _G450) ? creep
   Call: (8) female(liz) ? creep
   Exit: (8) female(liz) ? creep
   Call: (8) parent(liz, _G450) ? creep
   Exit: (8) parent(liz, chas) ? creep
   Exit: (7) mother(liz, chas) ? creep
   Call: (7) parent(chas, _G396) ? creep
   Exit: (7) parent(chas, harry) ? creep
   Exit: (6) grandmother(liz, harry) ? creep

Who = harry 


[debug]  ?-

At each point where it calls a goal, Prolog pauses and requires a carriage return from you before proceeding.

To turn off tracing, type

| ?- nodebug. <return>
(Note the full stop!)

Steve Harlow 2001-11-12