PLOGHELP TRACER                            Kathryn Seifert  October 1986

(buggy) library program for tracing the action of simple predicates

Keywords: tracing, debugging


This file shows you how to use a special program to watch your Prolog
programs working in 'slow motion'.  To find out about the standard
Prolog debugging package, see PLOGHELP * SPY.

To make the 'tracer' program available, type:

    ?- library(tracer).

Once the tracing program has been read into the Prolog database, the
behaviour when you ask a question will change. Instead of you (perhaps)
seeing a justification for each answer when Prolog has already worked it
out, you will be shown how Prolog builds up the justification, and how
it searches through the possible ways of coming to an answer by trial
and error. In order to slow things down to human speed Prolog
pauses every so often and prints a message on the VED 'command line'.
Just press any key to cause it to continue.

    1. Prolog prints out a variable that doesn't yet stand for anything as
       a '_' sign followed by a number (it forgets the names that were
       used for variables in programs). If '_'s followed by the SAME
       number appear in different places, then it means that the objects
       that these two variables stand for must end up the same.

    2. When the subgoals arising from the clause are displayed, the
       variables in the two subgoals (printed as '_1') are both the same,
       and they are the same as the variable in the question. This means
       that to show that this person is a model student it must show that
       the SAME person is a student and a liker of Prolog.

    3. When Prolog reaches a goal (the little line moves up to it), it
       must use trial and error to pick a fact or rule that is
       appropriate. The number in the brackets tells you which fact or
       rule it is currently considering.

    4. When Prolog successfully uses a fact for the 'student' goal, this
       causes '_1' to be matched with 'john' (the first time; next time
       'mary'; next time 'jane'). All the '_1's show this value
        simultaneously.

    5. When Prolog comes back to the 'student' goal (because it couldn't
       show that the student it chose likes Prolog or because that
       solution was rejected later on) all the '_1's get set back again
       (because that student was no good). It can then try another
       possibility for '_1'.

    6. In general, when the line is moving down the page, Prolog is being
       successful in satisfying goals. When it comes to a 'dead end' (a
       goal that cannot be satisfied), the line retreats back up the page,
       looking for an alternative choice to make.


NOTE for experienced programmers: The TRACER package will not
necessarily work for programs that contain 'cut's or which perform input
and output.


-- RELATED DOCUMENTATION ----------------------------------------------


PLOGHELP * CHATTY
 Library program for tracing Prolog programs

PLOGHELP * SPY
 Main predicates used to invoke and control the SPY package.

PLOGHELP * DEBUG
 Overview of the debugging facilities provided by POPLOG Prolog

TEACH * TRACER
 Tutorial introduction to the TRACER library package
