title: Binary tree in Prolog and leaves
body: <p>I'm very new to Prolog and we didn't have much theory about it. In the lectures we looked at basic stuff like atoms, variables, what a relation means etc.
  But now I have a task I don't understand how to begin/how to solve.</p>
  
  <p>We should create a relation <code>leaf(X,Y)</code> where <code>X</code> is a binary tree and <code>Y</code> an atom. The relation should be true if <code>Y</code> is a leaf of <code>X</code>. We can test if a variable <code>A</code> is a leaf by using <code>atom(A)</code>. Further it is important to note that <code>Y</code> should be an atom and not a subtree.</p>
  
  <p>Examples:</p>
  
  <pre><code>?- leaf([x,[y,[z,v]]], v).
  true
  
  ?- leaf([x,[y,[z,v]]], w).
  false
  </code></pre>