How can I prove that the following grammar is ambiguous:
$$ A \to AA\mid B \\ B \to aBb\mid ab $$
I tried finding a string that can be derived in two different ways, but to no avail.
Computer Science Stack Exchange is a question and answer site for students, researchers and practitioners of computer science. It only takes a minute to sign up.Sign up to join this community
The word $ababab$ can be derived in two different ways.
If you don't see why, I suggest starting with the simpler grammar $A \to AA|a$.
I could suggest a 6-letter word here but that would be too easy.
The productions for $B$ do not look promising. So check what can be done with $A$. Can you produce the same sequence of 3 non-terminals via 2 different derivations?