I have the following Prolog definite clause grammar:
s-->[a],s,[b].
s-->[].
This will result in words like [a,a,b,b] being accepted in opposite to words like [a,b,a,b]. To put it in a nutshell the grammar is obviously a^n b^n. Now I want to return n to the user. How can I calculate n?