# It has been asked to prove that a grammar is unambiguous which seem ambiguous to me

S->aAB

A->bBb

B->A|epsilon

It seems that the string abbbb can be derived by using more than one ways. After using the starting production and the production for A, we get: S=>abBbB.

From here, either of the B's can be replaced with epsilon and the other one replaced with bBb. So, there are two ways of deriving abbbb.

Isn't this ambiguous grammar?

It's a question from Formal Languages and Automata by Peter Linz (5th edition) Exercise 5.2.16

• What did you try? Where did you get stuck? We're happy to help you understand the concepts but just solving exercises for you is unlikely to achieve that. See also meta.cs.stackexchange.com/q/1284/755. Your first step is to look at the definition of "ambiguous grammar" and see how it applies here. Did you try that? What happened when you tried to follow that approach? – D.W. Sep 15 '16 at 4:16
• @D.W. I already mentioned what I tried. I tried to create two "different" ways of generating the string (which may be wrong hence, the confusion). – aste123 Sep 15 '16 at 5:52

• As I mentioned in my question, we can reach at S=>abBbB. If I draw the parse tree, I get two trees but they seem synonymous to one another. Using that we can say it is unambiguous. But my confusion is that when the machine is parsing the string, how would it know which path to go? Doesn't this look like ambiguity even though the parse trees look synonymous? – aste123 Sep 14 '16 at 13:10