I normally construct my search tree by following the common convention:
- Place Queries or Goals in need of unification inside node boxes.
- Write down decision points on the edges, where Prolog has assigned an element to a variable.
- Leaf nodes which are fully satisifed will be an empty box, they represent a solution.
- Leaf nodes which can not be satisifed and represent failed attempts will have the unfulfilled goal in their box, to make them even more clear I also follow the convention of marking them by placeing a cross symbol below them.
The above way has the nice side effect that it's easy to see the decision points. But what about creating a search tree for something like:
accLen([_|T],A,L) :- Anew is A+1, accLen(T,Anew,L). accLen(,A,A).
How should the assignment of Anew be represented in the search tree? It's not a decision point, the code has no other option then assigning it 1 plus the current value of A. Do you still place it on the edge, but underline it or something?