title: Adventure In Prolog: Why does ?- gizmo(X,X). fail?
body: <p>I'm new to Prolog and working through the exercises for <a href="http://www.amzi.com/AdventureInProlog/a3simple.php" rel="nofollow">Chapter 3 of Adventure In Prolog</a>. Given the logicbase:</p>
  
  <pre><code>gizmo(a,1).
  gizmo(b,3).
  gizmo(a,2).
  gizmo(d,5).
  gizmo(c,3).
  gizmo(a,3).
  gizmo(c,4).
  </code></pre>
  
  <p>Why is it that </p>
  
  <pre><code>| ?- gizmo(X,X).
  </code></pre>
  
  <p>results in the following trace? </p>
  
  <p>More specifically, why does it fail?</p>
  
  <pre><code>| ?- gizmo(X,X).
        1    1  Call: gizmo(_279,_279) ? c
        1    1  Fail: gizmo(_279,_279) ? c
  
  (1 ms) no
  {trace}
  </code></pre>
  
  <p>Since</p>
  
  <pre><code>gizmo(a,X)
  </code></pre>
  
  <p>and</p>
  
  <pre><code>gizmo (X,3)
  </code></pre>
  
  <p>,for example, both seem to act like wildcards and return every possible a and every possible 3 result respectively... </p>
  
  <p>I thought that</p>
  
  <pre><code>gizmo(X,X)
  </code></pre>
  
  <p>would return every possible result for both sides (both the letters and numbers) but instead returns a fail, and no other result. </p>
  
  <p>Would someone be willing to explain why it's a fail instead of returning all values from each side, keeping in mind I am a beginner?</p>
  
  <p>Thanks in advance.</p>