TL;DR
This paper introduces the Transparent Prolog Machine (TPM), a novel graphical debugger for Prolog that visualizes program execution using augmented AND/OR trees (AORTA diagrams). TPM offers both high-level overviews and detailed close-ups, enabling efficient debugging for both novices and experienced programmers by making complex execution flows intuitive.
What Problem Does This Paper Address?
Debugging logic programs, particularly Prolog, can be notoriously challenging. Traditional text-based trace outputs often become overwhelming for large programs, making it difficult to understand the flow of execution, variable instantiations, and the impact of backtracking and control flow primitives like the 'cut'. Experienced programmers need tools that can handle complexity without sacrificing clarity, while novices require intuitive visualizations to grasp fundamental execution concepts. Existing debugging tools often lack the ability to provide both a global perspective and granular detail simultaneously, leading to the "forest vs. trees" problem where it's hard to see the overall structure or the specific details of interest.
Methods
The core of TPM is the AORTA (Augmented AND/OR Tree) diagram. This is an enhanced traditional AND/OR tree where each node represents a clause's execution status.
- Status Boxes: Procedure status boxes display the goal's status (pending, success, failure, or mixed) and the specific clause head that matched. Clause status boxes similarly represent individual clauses.
- Clause Branches: Visual cues (dangling lines and square boxes) represent clause branches, distinguishing between "OR" choices and making clause processing clear.
- Family Metaphor: A "family metaphor" is used to describe goal lineage (sisters, mothers, step-fathers), which helps explain the behavior of the 'cut' primitive by freezing older goals and eliminating future ones.
- Slow-Motion/Close-Up Mode: For novices, TPM offers a detailed, step-by-step view of execution.
- High-Speed/Long-Distance Mode (LDV - Long Distance View): For experts, this mode provides a summarized view of thousands of nodes, highlighting "points of interest." This uses a schematized AND/OR tree where nodes summarize outcomes.
- Selective Highlighting: Users can specify search "forms" (e.g., "where did goal X with argument Y succeed?") to highlight relevant parts of the LDV.
- Replay Facility: Allows users to step through the execution history, visualizing backtracking and re-attempts.
- Zooming: Users can zoom into any node in the LDV to see its corresponding AORTA diagram, providing context.
Datasets
Not discussed in the paper. The paper focuses on a worked example using a small Prolog program describing warehouse contents.
Key Insights and Ideas
- Visualizing Execution Flow: AORTA diagrams provide a powerful, intuitive way to visualize the complex, non-linear execution of Prolog programs, including backtracking and unification.
- Bridging Novice and Expert Needs: TPM successfully caters to both beginners needing clear conceptual understanding and experienced programmers requiring efficient debugging of large codebases through its dual-mode approach (close-up vs. long-distance).
- The Power of Gestalt: The LDV leverages "gestalt effects," allowing users to quickly recognize familiar patterns and "clusters" of nodes in large execution trees, aiding in identifying anomalies.
- Contextual Zooming: Combining LDV with AORTA zooming ensures that users always understand the context of the detailed view they are examining, mitigating the "forest vs. trees" problem.
- Explaining the 'Cut': The family metaphor provides a surprisingly clear and concise way to explain the behavior of the 'cut' operator.
Key Results
The paper demonstrates TPM's effectiveness through a worked example where it successfully identifies a subtle bug in a Prolog program. The bug involved an uninstantiated variable in a clause head that was accidentally unified with a ground term, leading to an incorrect success. TPM's LDV highlighting and subsequent AORTA zoom pinpointed the exact clause and the problematic unification, which would have been difficult to spot with traditional debugging methods. The authors claim TPM is suitable for both teaching introductory Prolog and assisting experienced programmers.
Limitations and Future Work
- Non-termination: The authors acknowledge that non-termination is a potential issue and must be avoided, suggesting interpreter stack monitoring as a solution.
- History Preservation Overhead: While deemed worthwhile, the overhead of storing the exhaustive execution history for the replay facility is noted.
- Future Work: The paper mentions that more detailed worked examples, including a replay facility for a compiler and discussions on declarative debugging, are presented in other works by the authors. The current paper focuses on the core graphical debugging concepts.
Summary updated