1

I was reading about regular languages. I did not understand one thing.

Why

Variable -> Variable is not allowed ?

What is the reasoning behind it ?

What happens if there is such a rule ? What kind of grammar does it become ?

Harish Kayarohanam
  • 3,886
  • 4
  • 31
  • 55

1 Answers1

0

Nothing happens: any otherwise regular grammar to which you add rules of the form A := B will continue to be a grammar for a regular language - although possibly not the same regular language, of course.

What such rules introduce is akin to the lambda/epsilon/empty transition used in NFAs. Such rules say "you can go to from the state corresponding to nonterminal A to the state corresponding to the nonterminal B without consuming any new input symbols". Rules like "A := xB" and "C := Dy" mean "you can go from A to B when you consume an x" and "you an go from D to C by consuming a C", respectively.

Formally, we can show that these productions can always be removed from an otherwise regular grammar by replacing "A := B" when "C := xB" for all C, x such that "C := xA" is a production in your grammar. And "A := A" can always be removed.

Patrick87
  • 27,682
  • 3
  • 38
  • 73