title: Prolog trace output to search tree
body: <p>I'm trying to translate the trace output from prolog to a search tree, but I'm not sure if it's correct.
  Any help on how to make a search tree from the trace information is appreciated.</p>
  
  <pre><code>Database/Input:
  
  rara([X|L],A,M):- 
      rara(L,[Y|A],M).
  
  rara([M|L],L,[M]).
  
  rara(L,M):- 
      rara(L,[],M). 
  
  Query:
  
  rara([a,b,c,d],X).
  
  Trace output:
  Call: (8) rara([a, b, c, d], _G922) ? creep
  Call: (9) rara([a, b, c, d], [], _G922) ? creep
  Call: (10) rara([b, c, d], [_G1043], _G922) ? creep
  Call: (11) rara([c, d], [_G1046, _G1043], _G922) ? creep
  Call: (12) rara([d], [_G1049, _G1046, _G1043], _G922) ? creep
  Call: (13) rara([], [_G1052, _G1049, _G1046, _G1043], _G922) ? creep
  Fail: (13) rara([], [_G1052, _G1049, _G1046, _G1043], _G922) ? creep
  Redo: (12) rara([d], [_G1049, _G1046, _G1043], _G922) ? creep
  Fail: (12) rara([d], [_G1049, _G1046, _G1043], _G922) ? creep
  Redo: (11) rara([c, d], [_G1046, _G1043], _G922) ? creep
  Fail: (11) rara([c, d], [_G1046, _G1043], _G922) ? creep
  Redo: (10) rara([b, c, d], [_G1043], _G922) ? creep
  Fail: (10) rara([b, c, d], [_G1043], _G922) ? creep
  Redo: (9) rara([a, b, c, d], [], _G922) ? creep
  Fail: (9) rara([a, b, c, d], [], _G922) ? creep
  Fail: (8) rara([a, b, c, d], _G922) ? creep
  </code></pre>
  
  <p>Current search tree:</p>
  
  <pre><code>                     rara([a,b,c,d],X).
  
                  |                                 |
     rara([a, b, c, d], _G922)          rara([b, c, d], [_G1043], _G922)
     X = _G922                                   |        
                                  rara([c, d], [_G1046, _G1043], _G922)  
                                             |
                        rara([d], [_G1049, _G1046, _G1043], _G922)
                                          |
                 rara([], [_G1052, _G1049, _G1046, _G1043], _G922)
  </code></pre>