Hide predicates from Trace

Is there a way to hide individual predicates from the trace? In this rule:

p(<Stuff>) :-
    q(),
    p(<ModifiedStuff>);
    s(),
    p(<ModifiedStuff>);
    p(<ModifiedStuff>).

I would, for example, to hide q()and s()by tracing, because I was only interested in the challenges p(). q()and s()can cause many other predicates, which completely blocks the trace and makes it difficult to find the corresponding calls in it.

change 1

Now I tried to execute from the command line, and not from inside the interpreter, and pass the trace to grep for grepping lines containing p... but to my disappointment, which I had to understand when starting from the command line, this still opens the prolog shell. therefore, the layout of the output does not work at all. Only printreally send to the shell that starts the prolog process.

edit 2 (output when using trace (p, all))

?- trace(shift_reduce, all).
%         shift_reduce/2: [call,redo,exit,fail]
true.

[debug]  ?- shift_reduce([λ,x,x], T).
 T Call: (8) shift_reduce([λ, x, x], _7344)
 T Exit: (8) shift_reduce([λ, x, x], [e, [λ], [v, [x]], [e, [v, [...]]]])
T = [e, [λ], [v, [x]], [e, [v, [x]]]] ;
 T Exit: (8) shift_reduce([λ, x, x], [e, [λ], [v, [x]], [e, [v, [...]]]])
T = [e, [λ], [v, [x]], [e, [v, [x]]]] ;
 T Fail: (8) shift_reduce([λ, x, x], _7344)
false.

[debug]  ?-
+4
source share
1 answer

In SWI-Prolog you can use trace/2as:

trace(p, all), and this will enable the information associated with p, and also activates debugging mode.

while you are in debug mode, you can call:

p(<Stuff>).

p.

+2

Source: https://habr.com/ru/post/1679646/


All Articles