0

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

aste123
  • 445
  • 2
  • 9
  • 18

1 Answers1

2

You need to revisit the definition of ambiguity. The point is not whether multiple derivations exist; all non-linear grammars have many derivations per word. You have to check if there is only one left-derivation per word. Equivalently, you can check right-derivations or syntax trees.

If you think this grammar is ambiguous, prove it by giving two different syntax trees for some word.

If you think it is unambiguous, see here for how to prove that; it's often more tricky.

Raphael
  • 73,212
  • 30
  • 182
  • 400