Program Visualisation and Debugging Logic Programs: The Development of the Transparent Prolog Machine (TPM), 1983-1988

The Transparent Prolog Machine (TPM) is a medium for visualising and animating the execution of Prolog programs. Conceived as a tool for use by novice and expert Prolog programmers alike, TPM provides a faithful (slow-motion) representation of the inner workings of the Prolog interpreter, yet allows a high-speed visual overview of execution for rapidly homing in on buggy code. Our current version serves as the uniform basis for textbook diagrams, video animations, and a graphics workstation implementation. The workstation implementation has a 'replay facility with buttons for single step forward, single step backward, rewind, and normal play, so that code may be observed either live or retrospectively at different levels of granularity. A selective highlight option allows the user to home in on troublesome code specified in a context-sensitive way. The system additionally allows for user definable abstracted views of the program trace. Unlike earlier attempts to provide graphical tracing facilities for Prolog, TPM can deal with extremely large search spaces (thousands of nodes), and has a simple visual metaphor for displaying extra-logical features such as the cut.

Figure 1. TPM's coarse-grained view of Prolog execution. The scissors and the cloud indicate precisely the effect and scope of the Prolog cut primitive.

Considerable effort has been put into producing a system that scales up to the demands of large applications. This has led to the development of four separate ways of navigation through large program traces. At a coarse-grained level the user can see the program just in terms of goal outcomes (see figure 1). Large traces can be greatly condensed by compressing parts of the tree into user- defined black-boxes'. The close-up, fine-grained view called the AORTA (And/Or Tree Augmented) contains information down to the level of individual variable unification and clause head matching (see figure 2). A third technique allows the user to define abstract views of the program so that the trace can be observed at a level which conforms more closely to the users plans and intentions. Finally, under development is an on-board bug location aid that allows the user to switch paradigms between declarative and procedural readings of the program, whilst debugging. This facility can also carry out simple diagnostic on a bug, once it has been located. We intend to extend this tool to become a full scale knowledge-based debugger.

Figure 2. A close up view of the same execution trace that was shown in figure 3. Notice the individual nodes have been expanded so that we can see clause head matching, unification, and dataflow information. We call this an AORTA diagram, and it forms the close-up, fine-grained information used in TPM.

This project was initially funded by SERC (£47,000, 1983-1986), and a further award of £136,000 (1986-1988, shared between the Open University and Expert Systems Ltd.) supported the design and implementation of a dedicated graphics workstation version of our environment. This environment, known as the Transparent Prolog Machine (TPM), is now available as a commercial product (from Expert Systems Ltd.) running on Unix graphics workstations. For teaching purposes, we have developed an Apple Macintosh version of TPM which supports all the examples used in The Open University's Intensive Prolog course. This program, MacTPM, was launched in 1991 as a freely available educational resource; a new implementation which carries all the above features but is available on a readily affordable platform. The software was used both in the undergraduate D309 Cognitive Psychology summer school and on the M.Sc. course DM862 Intensive Prolog where it was used as a key teaching resource.

Selected publications