-1

The context free grammar: (e represents epsilon)

  S --> aSb|aSa|bSa|bSb|e

It could generate regular language which means it can be converted to a right linear grammar. Is there a general rule to convert CFG into a RLG?

henry
  • 185
  • 2
  • 2
  • 13

1 Answers1

1

There is no general algorithm for converting a CFG to a right-linear grammar because right-linear grammars generate precisely the regular languages, which are a strict subset of the context-free languages. Accordingly, if a general algorithm existed that performed this transformation, it would prove all context-free languages are regular, which is known to be false.

Hope this helps!

templatetypedef
  • 362,284
  • 104
  • 897
  • 1,065
  • If there is no general rule to do that, could you show me how to convert the CFG above into a RLG? – henry Feb 07 '13 at 13:54
  • @henry- If you look at the above grammar, you'll note that it generates all even-length strings made from a's and b's. Given that insight, you can try creating, from scratch, a right linear grammar that generates the same language. – templatetypedef Feb 07 '13 at 18:46