Equivalence of Left-Regular and Right-Regular Grammars #
This file proves that the class of languages generated by left-regular grammars coincides with the class of languages generated by right-regular grammars, i.e., both define exactly the regular languages.
Proof strategy #
The key observation is that reversing the output of each rule converts a left-regular grammar into a right-regular grammar (and vice versa), and a derivation step in one corresponds to a derivation step on the reversed sentential form in the other.
Concretely, if g is a left-regular grammar, we construct a right-regular grammar
RG_of_LG g such that LG_language g = (RG_language (RG_of_LG g)).reverse.
Since the class of right-regular languages is closed under reversal (via Mathlib's
Language.isRegular_reverse_iff and is_RG_iff_isRegular), this gives
is_LG L → is_RG L. The converse direction is symmetric.
Main results #
is_LG_iff_is_RG— A language is left-regular iff it is right-regular.LG_eq_RG— The class of left-regular languages equals the class of right-regular languages.
References #
- Hopcroft, Motwani, Ullman. Introduction to Automata Theory, Languages, and Computation, 3rd ed. Section 3.3.
Convert a left-regular rule to a right-regular rule by reversing the output.
A → BabecomesA → aBA → astaysA → aA → εstaysA → ε
Equations
- RG_rule_of_LG_rule (LG_rule.cons A a B) = RG_rule.cons A a B
- RG_rule_of_LG_rule (LG_rule.single A a) = RG_rule.single A a
- RG_rule_of_LG_rule (LG_rule.epsilon A) = RG_rule.epsilon A
Instances For
Convert a right-regular rule to a left-regular rule by reversing the output.
A → aBbecomesA → BaA → astaysA → aA → εstaysA → ε
Equations
- LG_rule_of_RG_rule (RG_rule.cons A a B) = LG_rule.cons A a B
- LG_rule_of_RG_rule (RG_rule.single A a) = LG_rule.single A a
- LG_rule_of_RG_rule (RG_rule.epsilon A) = LG_rule.epsilon A
Instances For
Convert a left-regular grammar to a right-regular grammar.
Equations
Instances For
Convert a right-regular grammar to a left-regular grammar.
Equations
Instances For
An LG transformation step corresponds to an RG transformation step on the reversed sentential form.
An RG transformation step on RG_of_LG g corresponds to an LG transformation
step on the reversed sentential form.
LG derivation corresponds to RG derivation on reversed sentential forms.
RG derivation on RG_of_LG g corresponds to LG derivation on reversed sentential forms.
An RG transformation step corresponds to an LG transformation step on the reversed sentential form.