This is a little tutorial on how to write debuggers for Prolog and Prolog like languages, e.g. the DSL in http://www.reddit.com/r/prolog/comments/303txw/problem_solving_with_layered_design_domain/ I'll give the examples for Prolog as we all know the language.
I first read about the key to tracing Prolog like languages in Tracing Requirements for Multi-Layered Meta-Programming by Bowles and Wilk, in Meta-Programming in Logic Programming by Abramson and Rogers, MIT Press.
Consider the following program:
:- set_prolog_flag(unknown, fail).
a :- b, c ; d.
b :- true.
d :- true.
In Prolog the following query succeeds:
| ?- a.
% yes
Now consider our own little Pro