Ogden's Lemma for Context-Free Languages #
This file states and proves Ogden's lemma, a strengthened version of the pumping lemma for context-free languages. While the pumping lemma guarantees that long enough strings in a CFL can be "pumped", Ogden's lemma allows the user to mark certain positions of the string and guarantees that the pump pieces contain marked positions.
Main declarations #
countMarkedIn— counts how many positions in a range[start, start + len)are marked.Language.IsContextFree.ogdens_lemma— Ogden's lemma stated using Mathlib'sLanguage.IsContextFree.CF_ogdens_lemma— Ogden's lemma stated using the project'sis_CFpredicate.
Implementation notes #
The proof follows the standard Ogden argument:
- Convert to Chomsky Normal Form (CNF).
- Navigate along the "marked path" to find a subtree with bounded marked height.
- Use the pigeonhole principle on branching nonterminals to find a repeat.
- The branching property ensures marked positions in the pump parts (v, y).
- The bounded marked height ensures the marked-count bound on vxy.
The core technical lemma ogdens_marked_path_decomp implements the marked-path
pigeonhole argument. It tracks branching nonterminals in a finite set and detects
collisions to construct the Ogden decomposition.
References #
- William F. Ogden, "A Helpful Result for Proving Inherent Ambiguity", Mathematical Systems Theory 2 (1968), 191–194.
Counting marked positions #
Count how many natural numbers in the interval [start, start + len) satisfy P.
Equations
- countMarkedIn P start len = {i ∈ Finset.range len | P (start + i)}.card
Instances For
Parse tree marked count #
The number of marked positions in a parse tree's yield.
Equations
- ChomskyNormalFormGrammar.parseTree.mc P offset t = countMarkedIn P offset t.yield.length
Instances For
Marked height #
The "marked branching depth": maximum number of branching points (where both children have marked descendants) on any root-to-leaf path.
Equations
- One or more equations did not get rendered due to their size.
- ChomskyNormalFormGrammar.parseTree.markedHeight P offset (ChomskyNormalFormGrammar.parseTree.leaf t hnt) = 0
Instances For
Key bounds #
mc ≤ 2^markedHeight
2^h ≤ mc → h ≤ markedHeight
markedHeight ≤ height
Derivation helper lemmas #
From a derivation of the left child, build a derivation of the node.
From a derivation of the right child, build a derivation of the node.
Helper lemmas for extending Ogden results through nodes #
Core Ogden marked-path pigeonhole #
Navigation to bounded-markedHeight subtree #
Ogden's lemma for CNF grammars #
Ogden's lemma for general context-free languages #
Ogden's lemma for context-free languages (Mathlib formulation).
Ogden's lemma for context-free languages (project formulation).