As I noted in the SO comment for the question, I will help guide you to a possible solution but you will be writing the code so expect do some leg work.
Since the goal is to translate the execution of the Prolog code into a graph with the edges being calls to goals and the nodes being goals (statements) you will need a way to capture the steps as they occur. One common way is to use a meta interpreter but trying to create one that works for all of the SWI-Prolog code is not easy. What I find easier is to use prolog_trace_interception/4.
The image that I share in the post has been obtained using the sldDraw software. You can find it at this link: http://www.lcc.uma.es/~pacog/sldDraw/
Although it draws a sld tree in Windows platform, it is not working for Ubuntu 20.04 (or I can not figure out how it is done). There is also a Java version, that works in Ubuntu but with some limitations.
The nodes are the selected predicates with unification.
Another limitation of this specific app has to do with a query that returns ERROR: Out of local stack. In fact, the obtained graph does not explicitly shows that an “infinite” recursion is happening, although we can figure out. I have not tried it extensively, but you may find a comparison with sldnfDraw in Chapter 4 of this article: https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.156.8281&rep=rep1&type=pdf
It does not show anything. Although it is an infinite recursion it would be nice to have some input from the tool. Or, am I doing something wrong with the tool?
It does not show anything. Although it is an infinite recursion it would be nice to have some input from the tool. Or, am I doing something wrong with the tool?
the problem is that the tree is too big. If you run the second query, you will get the latex code that you can insert into a document and compile
The above program inverts a list.
The query is inverte(X,[a,b,c]).
From the output of the tool, it does not support dependencies. I think this means that inverte/2
depends on junta/2. Is it correct? This is a limitation of the sldnfdraw library?