title: What are the steps that Prolog follows with the definition of natural numbers?
body: <p>I'm learning how to program in Prolog and I found the next program that defines the natural numbers and their sum:</p>
  
  <pre><code>sum( succ( X ), Y, succ( Z )) :- sum( X, Y, Z ).
  sum( 0, X, X ).
  ?- sum( succ( succ(0)), succ( succ( succ(0))), Answer ).
  Answer = succ( succ( succ( succ( succ(0)))))
  </code></pre>
  
  <p>(found <a href="http://www.augustana.ualberta.ca/~jmohr/courses/2000.fall/csc370/lecture_notes/prolog3.html" rel="nofollow">here</a>)</p>
  
  <p>The problem is that I'm struggling with the execution flow of this program. To tell the truth I don't know what it does. How can Prolog figure out the Answer's value? What are the steps that Prolog follows to find the Answer's value?</p>
  
  <p>Thanks in advance.</p>