Backward Debugging

Ordinary Prolog interpreter execution works with backward chaining goal search. In this execu-tion schema a rule is read as "Goal :- Sub-goals". A common debugging model are Byrd Boxes named after Lawrence Byrd. Our debugger framework from the development environment supports this model with a few extensions and adaptions.

The Byrd Boxes model features the ports "call", "exit", "redo" and "fail". Among the extensions in our debugger framework, we find the additional ports "head" and "chop" which are not visible by default. Further, deterministic execution of a goal is detected and then the ports "redo" and "fail" of that goal become invisible as well.

Backward chaining has a distinct top-down pattern from goals to sub-goals. We will first demonstrate this pattern and later compare it with the pattern of our forward chaining engine. As an example problem, we will use a propositional problem, which can be represented in Prolog. The problem consists of the following Prolog facts, rules and query:

r :- p.
q :- p.
s :- q, r.
?- s.

When we run the query in our default debugger, we get the following trace. We have also de-picted the dependency graph among the facts, rules and query. The numbering in the depend-ency graph shows the order of the Byrd Box calls during tracing. Since the dependency shows sub-goals further down, the tracing also happens in a top-down fashion:

?- trace.
?- s.
    0 Call s ?
    1 Call q ?
    2 Call p ?
    2 Exit p ?
    1 Exit q ?
    1 Call r ?
    2 Call p ?
    2 Exit p ?
    1 Exit r ?
    0 Exit s ?

The debugger framework and the default debugger is not part of the Minlog module. The de-bugger allows issuing debugger directives by mouse and keyboard. For further information about the debugger and the available directives, please consult the language reference manu-al of the development environment.