Is it possible for an ambiguous CFG to convert into GNF?

215 Views Asked by At

So I was studying how to convert CFG to GNF and I tried to do it using my letters in my name so the production rule would be like:-

A->AkS|SA S->AtA

Where S,A are Non Terminals and k,t are terminals but this is an ambigous CFG, so can we convert it into GNF?

1

There are 1 best solutions below

0
rici On

Yes, any CFG can be transformed to an equivalent grammar in Greibach Normal Form. If the original grammar is ambiguous, so will be the transformed grammar, but the reverse is not necessarily true; the transformation can introduce ambiguity.

The above claim assumes you are using the relaxed definition of GNF, which allows the production S→ε but only for the start symbol S. For the strict definition of GNF, only grammars which cannot derive ε can be transformed; strict ε-elimination will result on a grammar which recognises every sentence recognised by the original grammar except ε.