title: Can someone explain how to do unification to get the answer in a definite clause grammar?
body: <p>I am trying to understand the concept of unification within definite clause grammar, is someone able to explain step by step how one gets from the following DCG to the answer.</p>
  
  <pre><code>s --&gt; symbols(Sem,a), symbols(Sem,b).
  
  symbols(s(end),S) --&gt; [S].
  symbols(s(Sem),S) --&gt; [S], symbols(Sem,S).
  </code></pre>
  
  <p>The answer produces <code>aaabbb</code>, but i have been searching the web for ages to try and find how you get this answer, i would be forever grateful if someone could explain this in a few steps, or at least show the working out, so i can see what is happening.</p>
  
  <p>A similar example can be found on the wikipedia page for DCG's, except it produces <code>aaabbbccc</code>.</p>
  
  <p>Thanks</p>