2

There is a grammar G given:

    S->XaX
    X->aX|bX|eps

I just replied to the first question that was about showing that this grammar is ambiguous. The second question is to find an unambiguous equivalent grammar of this grammar given. I don't really know how to do it or from where to start. Can anyone help me?

Annie
  • 21
  • 1
  • Have you seen: https://cs.stackexchange.com/questions/74467/finding-a-unambiguous-grammar ? – Evil May 18 '18 at 16:47

1 Answers1

1

Your language consists of all words over $\{a,b\}$ which contain $a$. This is a regular language, and so it has an unambiguous regular grammar - essentially a DFA - which is not so difficult to construct for this language. Regular grammars constructed from DFAs are unambiguous, so this would be an unambiguous grammar for the same language.

Yuval Filmus
  • 276,994
  • 27
  • 311
  • 503