title: Dynamic predicate in Prolog
body: <p>I have started using Prolog and I am having this problem with a dynamic predicate - I don't get the right result.</p>
  
  <p>This is my database:</p>
  
  <pre><code>:- dynamic mother/2.
  
  mother(X,Y).
  
  grandemother(X,Y) :- 
      mother(X,A),
      mother(A,Y).
  </code></pre>
  
  <p>These are some of the results I get:</p>
  
  <pre><code>1 ?- assert(mother(alice,lise)).
  true.
  
  2 ?- assert(mother(lise,kate)).
  true.
  
  3 ?- grandemother(alice,X). % should only give X = kate.
  true ;
  X = lise ;
  X = kate ;
  true ;
  X = kate.
  
  4 ?- grandemother(alice,lise). % should only give false.
  true ;
  true ;
  true ;
  false.
  
  5 ?- grandemother(X,kate). % should only give X = alice.
  true ;
  true ;
  X = alice ;
  X = alice ;
  X = lise.
  </code></pre>
  
  <p>I really don't know where the problem is, any ideas?</p>