Is there any way to get swi prolog to print the current working output tree?

That would be great support on my course.

+4
source share
1 answer

You can try and expand the usual vanilla meta-interpreter by tracking evidence information. Basically, a simple vanilla interpreter looks like this:

  solve ([]).
 solve ([A | T]): - solve_atom (A), solve (T).

 solve_atom (A): - my_clause (A, B), solve (B).

 my_clause (doubleapp (X, Y, Z, R), [app (X, Y, I), app (I, Z, R)]).
 my_clause (app ([], L, L), []).

You can add an extra argument to the interpreter to track the resolution steps ... You might want to use the built-in / 2 clause rather than my_clause (so you don’t have to manually insert the program you want to track).

I really wrote a (draft) solution for SICStus Prolog for my lectures. It can be launched from the command line. It should be easily adapted for SWI. It can generate a point view of an SLD or And-Or-Tree tree. I can send you the source code upon request.

But maybe there is a lighter solution in SWI that I don't know.

+1
source

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


All Articles