title: Prolog and ancestor relationship
body: <p>I have to write a small prolog program which checks if a given person is a ancestor of a second one.
  These are the facts and rules:</p>
  
  <pre><code>mother(tim, anna).
  mother(anna, fanny).
  mother(daniel, fanny).
  mother(celine, gertrude).
  father(tim, bernd).
  father(anna, ephraim).
  father(daniel, ephraim).
  father(celine, daniel).
  
  parent(X,Y) :- mother(X,Y).
  parent(X,Y) :- father(X,Y).
  </code></pre>
  
  <p>The test if a person is an ancestor of another person is easy:</p>
  
  <pre><code>ancestor(X, Y) :- parent(X, Y).
  ancestor(X, Y) :- parent(X, Z), ancestor(Z, Y).
  </code></pre>
  
  <p>But now I have to write a method ancestor(X,Y,Z) which also prints out the relationship between two persons. It should look like this</p>
  
  <pre><code>?- ancestor(ephraim, tim, X).
  false.
  ?- ancestor(tim, ephraim, X).
  X = father(mother(tim)).
  </code></pre>
  
  <p>And that is the problem: I have no clue how do to this.</p>