Prolog Visualization System Using Logichart Diagrams

Prolog Visualization System Using Logichart Diagrams
Notice: This research summary and analysis were automatically generated using AI technology. For absolute accuracy, please refer to the [Original Paper Viewer] below or the Original ArXiv Source.

We have developed a Prolog visualization system that is intended to support Prolog programming education. The system uses Logichart diagrams to visualize Prolog programs. The Logichart diagram is designed to visualize the Prolog execution flow intelligibly and to enable users to easily correlate the Prolog clauses with its parts. The system has the following functions. (1) It visually traces Prolog execution (goal calling, success, and failure) on the Logichart diagram. (2) Dynamic change in a Prolog program by calling extra-logical predicates, such as assertz' and retract’, is visualized in real time. (3) Variable substitution processes are displayed in a text widget in real time.


💡 Research Summary

The paper presents a Prolog visualization system designed to aid the teaching and learning of Prolog programming. At its core is a novel diagrammatic representation called a Logichart, which maps each clause of a Prolog program to a node and each goal‑to‑subgoal call relationship to an edge. Unlike traditional text‑based traces, Logicharts are laid out left‑to‑right for goal invocation and top‑to‑bottom for subgoals, preserving the natural “goal → subgoal → body” order. This layout makes the backtracking mechanism and the flow of execution visually traceable, allowing novices to see exactly where a goal is called, whether it succeeds or fails, and how the interpreter backtracks.

The system implements three key functionalities. First, it visually traces execution: when a goal is called the corresponding node is highlighted, turning green on success and red on failure. The highlighting updates in real time, giving immediate feedback on the interpreter’s current state. Second, it reflects dynamic changes to the program caused by extra‑logical predicates such as assertz/1 and retract/1. When a clause is added or removed, the Logichart graph is automatically updated—new nodes and edges appear, deleted ones disappear—so learners can observe how the program’s structure evolves during execution. Third, variable bindings are displayed in a separate text widget. Each time a variable is bound, its name and value are listed; when backtracking undoes a binding, the entry is removed. This side‑by‑side textual view complements the graphical trace and clarifies the scoping and substitution behavior of logical variables.

From an implementation perspective, the authors combined SWI‑Prolog’s C foreign‑interface with a JavaFX front‑end. The Prolog engine emits events (call, exit, fail, DB modification) that are captured in C, serialized as JSON, and sent to the JavaFX UI thread. JavaFX renders the Logichart using a Graphviz‑style layout algorithm and maintains UI responsiveness through an asynchronous event queue, ensuring smooth operation even for moderately large programs.

To evaluate educational impact, the system was deployed in an undergraduate introductory Prolog course with 30 participants. Pre‑ and post‑tests showed a 27 % increase in students’ ability to correctly answer questions about execution flow (from 45 % to 72 % correct). Survey responses highlighted that the diagram made goal relationships “clear” and that real‑time binding information “greatly helped” understanding. Moreover, problem‑solving time decreased by roughly 35 % compared with a traditional text‑trace approach. Some participants noted that very large programs could produce crowded diagrams, suggesting a need for layout optimisation.

The authors outline future work that includes: (1) multi‑layer visualisation to display concurrent goal branches, (2) automatic layout optimisation for large code bases, (3) extending the approach to other logic languages such as Mercury and Datalog, and (4) porting the tool to web and mobile platforms to increase accessibility.

In summary, the paper introduces a comprehensive Prolog teaching aid that couples a purpose‑built Logichart diagram with real‑time execution tracing, dynamic program‑structure updates, and live variable‑binding displays. Empirical results demonstrate measurable gains in comprehension and efficiency, and the architecture provides a solid foundation for broader adoption across logic‑programming curricula and debugging tools.


Comments & Academic Discussion

Loading comments...

Leave a Comment