Context-Free Grammars as Unrestricted Grammars #
This file gives an alternative characterization of context-free grammars as unrestricted grammars satisfying an additional structural property on their rules.
Overview #
A standard unrestricted grammar has rules of the form
input_L ++ [nonterminal input_N] ++ input_R → output_string
where there are no restrictions on the relationship between the left- and right-hand sides.
A context-free grammar is one where each rule has no context: i.e., for every rule,
input_L = [] and input_R = [].
In other words, each rule rewrites a single nonterminal A to a string γ,
independently of the surrounding context.
This file proves that the unrestricted characterization agrees with the
CF_grammar presentation.
Main declarations #
is_CF_via_cfg— language class induced byCF_grammaris_CF_via_cfg_implies_is_CF— conversion to the default unrestricted characterizationis_CF_implies_is_CF_via_cfg— extraction of aCF_grammarwitnessis_CF_iff_is_CF_via_cfg— equivalence of the two characterizations
Forward direction: CF_grammar → context-free unrestricted grammar #
Convert a context-free grammar to the corresponding unrestricted grammar with empty left and right contexts in every rule.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The unrestricted grammar obtained from a context-free grammar (via grammar_of_cfg)
satisfies the context-free property.
Every language generated by a CF_grammar satisfies the default
unrestricted characterization.
Backward direction: context-free unrestricted grammar → CF_grammar #
Convert an unrestricted grammar rule (from a context-free unrestricted grammar) into a context-free rule (a pair of nonterminal and output string).
Equations
Instances For
Construct a CF_grammar from a context-free unrestricted grammar.
Equations
- cfg_of_grammar g _hg = { nt := g.nt, initial := g.initial, rules := List.map cfrule_of_grule g.rules }
Instances For
The derivation relation of the constructed CF_grammar coincides with that of the
original unrestricted grammar.
The language of the constructed CF_grammar equals that of the original grammar.
Every language satisfying the default unrestricted characterization is generated by
a CF_grammar.
Equivalence #
The default unrestricted characterization of context-freeness agrees with the
CF_grammar characterization.