title: Why am I getting this result from recursive query in Prolog
body: <p>I'm trying to write a prolog predicate that generates a horizontal line using SWI-Prolog 7. I started with a simple generator referenced here: <a href="https://stackoverflow.com/questions/12109558/simple-prolog-generator">Simple Prolog generator</a></p>
  
  <p>In playing around, I came up with a result I don't understand. If I create these rules (hline is intended to take two x coordinates (X and A) and a single Y coordinate Y, and generate the X and Y coordinates of a horizontal line in S and T:</p>
  
  <pre><code>gen(Cur, Top, Cur) :- =&lt;(Cur, Top). 
  gen(Cur, Top, Next):- =&lt;(Cur, Top), is(Cur1, +(Cur, 1)), gen(Cur1, Top, Next).
  hline(X,A,Y,S,T) :- gen(X,A,S), T is Y.
  </code></pre>
  
  <p>When I run this query:</p>
  
  <pre><code>hline(0,5,0,X,Y).
  </code></pre>
  
  <p>I get these results.  The first one is the one I don't understand:</p>
  
  <pre><code>X = Y, Y = 0
  X = 1,
  Y = 0
  X = 2,
  Y = 0
  X = 3,
  Y = 0
  X = 4,
  Y = 0
  X = 5,
  Y = 0
  </code></pre>
  
  <p>Can someone explain why the first result is X=Y, Y=0?  I can't see anywhere that X and Y are even in the same clause through unification or reduction...</p>