title: Stop condition for recursion in prolog
body: <p>Here are the facts that I have in my knowledge base (<a href="http://www.doc.gold.ac.uk/~mas02gw/prolog_tutorial/prologpages/recursion.html" rel="nofollow noreferrer">http://www.doc.gold.ac.uk/~mas02gw/prolog_tutorial/prologpages/recursion.html</a> (Recursion Exercise 2)):</p>
  
  <pre><code>taller(bob,mike).   % bob is taller than mike
  taller(mike,jim).   % mike is taller than jim
  taller(jim,george). % jim is taller than george
  </code></pre>
  
  <p>Now I want to use recursion to deduce something that is obvious "bob" is taller than "george".</p>
  
  <p>I tried to add this rule to solve this:</p>
  
  <pre><code>taller(X,Y) :- taller(X,Z),taller(Z,Y).
  </code></pre>
  
  <p>I need your help to make a stop condition to this recursion because now I have a stack overflow error:</p>
  
  <pre><code>| ?- taller(bob,george).
  
  Fatal Error: local stack overflow (size: 8192 Kb, environment variable used: LOCALSZ)
  </code></pre>
  
  <p>Thanks</p>