The pumping lemma for context-free languages #
Every context-free language has the pumping property: beyond the pumping constant of a grammar,
every word splits as u ++ v ++ x ++ y ++ z with v ++ x ++ y short, v ++ y nonempty, and
every u ++ vⁱ ++ x ++ yⁱ ++ z in the language.
The proof is the textbook one through derivation trees. A word longer than
maxBranch ^ (rules.card + 1) has a licensed tree of height above rules.card + 1
(RoseTree.Licensed.length_yield_le); a longest path in a tree of least size passes two nodes
with the same nonterminal (RoseTree.Licensed.exists_repeat); replacing the lower by the upper
would shrink the tree unless it adds terminals, and grafting the lower into the upper repeatedly
pumps them (RoseTree.Licensed.replaceAt, RoseTree.Licensed.derives).
Main definitions #
Language.HasCFLPumpingProperty: the pumping property of a language.ContextFreeGrammar.maxBranch,ContextFreeGrammar.pumpingConstant: the branching bound and the pumping constant of a grammar.
Main results #
RoseTree.Licensed.length_yield_le: a licensed tree of heighthhas at mostmaxBranch ^ hterminals.Language.IsContextFree.hasCFLPumpingProperty: every context-free language has the pumping property.
A language has the pumping property when, beyond some length, every word splits as
u ++ v ++ x ++ y ++ z with v ++ x ++ y no longer than that length, v ++ y nonempty, and every
u ++ vⁱ ++ x ++ yⁱ ++ z in the language.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The branching bound #
The branching bound of a grammar is the length of its longest right-hand side, and at least
2.
Equations
- g.maxBranch = max 2 (g.rules.sup fun (r : ContextFreeRule T g.NT) => r.output.length)
Instances For
The pumping constant is maxBranch ^ (rules.card + 1), so that a licensed tree with more
terminals has a path through two nodes with the same nonterminal.
Equations
- g.pumpingConstant = g.maxBranch ^ (g.rules.card + 1)
Instances For
A licensed tree from the start symbol whose yield reaches the pumping constant pumps.
The pumping lemma for context-free languages.