How statement and proof provenance work
The first chip identifies the source of the statement or construction; the second identifies the source of its local proof or verification.
- Literature-sourced: the exact statement appears in a cited source; only wording and notation differ.
- AI-adapted: a semantically identical restatement of literature-sourced material, modulo indexing, notation, and boundary cases adopted by the library.
- AI-generated: a genuinely novel statement formulated by AI, with no source for the claim itself.
These labels describe origin, not correctness: citations and verification chips remain separate evidence.
Context-Free Pumping, Ogden's Lemma, and Parsing
1 · Prerequisites
- Construction of the Natural Numbers
- Construction of the Real Numbers via Cauchy Sequences
- Construction of the Real Numbers via Dedekind Cuts
- Context-Free Grammars and Normal Forms
- Countability and Uncountability
- Finite Counting, Factorials and Binomial Coefficients
- Formal Languages, Encodings, and Decision Problems
- Foundations of the Real Numbers for Analysis
- Linear Recurrences and Rational Generating Functions
- Pushdown Automata and Context-Free Languages
- Ramsey Theory
- Relations, Functions, and Quotients
- Roots, Rational Powers, and Classical Inequalities
- The ZFC Axioms and the Basic Set Constructions
2 · Summary
This page records the two standard pumping obstructions for context-free languages, uses them to isolate nonclosure phenomena, and then turns to parsing and decision procedures through the CNF-based CYK algorithm and basic CFG graph tests.
3 · Logical flowchart
4 · Definitions, theorems and proofs
A Chomsky-normal-form parse tree of height has yield length at most
Statement
Let be a context-free grammar in Chomsky normal form, and let be a parse tree for of height . If is the yield of , then
Facts & Assumptions
Given: A Chomsky-normal-form grammar and a parse tree of height .
By Parse trees and their yields, the yield of a parse tree is the left-to-right list of its terminal leaves, and every internal node is labeled by a variable together with one production used at that node.
By Chomsky normal form, every production in a CNF grammar is either , , or the exceptional start rule .
Proof
We induct on the height . If , then the root is already a leaf. By [L1], a leaf at the root can only be the variable leaf corresponding to the exceptional CNF rule from [L2]. Thus , so .
Suppose . If the root uses a terminal production , then the yield has length , so the bound is immediate. Otherwise the root uses a binary production by [L2]. The two child subtrees have heights at most , so by the induction hypothesis each contributes at most terminal leaves. Therefore .
The bound holds for height and is preserved when the height increases, so every CNF parse tree of height has yield length at most .
The pumping lemma for context-free languages
Statement
If is a context-free language, then there exists an integer such that every word with can be written as with
Facts & Assumptions
Given: A context-free language .
By The language generated by a CFG, there exists a context-free grammar with .
By Every context-free language has an equivalent grammar in Chomsky normal form, has an equivalent grammar in Chomsky normal form.
By Derivations and parse trees correspond, every word of the language of a CFG is the yield of some parse tree for that grammar.
By A Chomsky-normal-form parse tree of height has yield length at most , a CNF parse tree of height has yield length at most .
Proof
Choose a CNF grammar with by [L1] and [L2], and let . Set . Let satisfy . By [L3], is the yield of some parse tree for . If every root-to-leaf path of had at most variable nodes, then would have height at most , so [L4] would give , contradicting . Therefore some root-to-leaf path has at least variable occurrences.
Choose two equal variables on the last variable occurrences of such a path, with the upper one above the lower one. Let the yield of the upper -subtree be and the yield of the lower -subtree be , so the whole word is . Because the lower occurrence lies strictly below the upper one and is in CNF, the path segment from the upper to the lower one cannot consist only of unit moves, so at least one of the side contexts and is nonempty. Hence . The upper -subtree contains at most the last variable occurrences on the path, so its height is at most ; therefore [L4] gives .
The parse-tree segment from the upper occurrence of down to the lower one shows that , and the lower subtree shows . Repeating or deleting the first derivation segment any number of times while keeping the rest of the tree fixed yields derivations of in for every . Hence every such word lies in .
Therefore the integer satisfies the required pumping property.
Marked positions and admissible Ogden decompositions
Definition
Let be a word over . A set is a set of marked positions of .
Fix an integer . A decomposition is -admissible with respect to when:
- the concatenated substring contains at least one marked position;
- the substring contains at most marked positions.
Remarks
-
Ogden's lemma strengthens the ordinary pumping lemma by controlling where the pumped material must lie relative to the marked positions.
-
The definition does not itself assert that pumping preserves the language; it only records the combinatorial shape of the decomposition.
Ogden's lemma
Statement
If is a context-free language, then there exists an integer such that for every word and every choice of at least marked positions in , there is a decomposition that is -admissible with respect to the marked positions and satisfies
Facts & Assumptions
Given: A context-free language .
By Marked positions and admissible Ogden decompositions, a -admissible decomposition is one in which contains at least one marked position while contains at most marked positions.
By The language generated by a CFG, there exists a context-free grammar generating .
By Every context-free language has an equivalent grammar in Chomsky normal form, that grammar may be replaced by an equivalent grammar in Chomsky normal form.
By Derivations and parse trees correspond, every word in the language of a CFG is the yield of some parse tree for that grammar.
By Parse trees and their yields, a parse tree records the production used at each internal node and its yield is read from the terminal leaves from left to right.
Proof
Choose a context-free grammar with by [L2], then replace it by an equivalent Chomsky-normal-form grammar by [L3]. Set . Let and mark at least positions of . Because , the word is nonempty, so by [L4] fix a parse tree for in the CNF grammar .
Starting at the root of , build a path to a marked leaf by always moving to a child whose subtree contains the larger number of marked positions; when both children contain marked positions, choose one of the heavier children. Call such a node a branch point. Each time the path passes through a branch point, the chosen child still contains at least half of the marked positions seen at that node. Therefore, if there were at most branch points on the path, the terminal leaf at the end would still lie below at least marked positions, impossible for one leaf. So the path contains at least branch points.
Among the last branch points on that path, choose two with the same variable label , with the upper one above the lower one. Let the lower -subtree yield , and let the material in the upper -subtree to the left and right of the lower subtree yield and , so that the whole word is . The upper branch point has marked material outside the lower subtree, so the concatenation contains a marked position. Also, if the upper -subtree contained more than marked positions, then repeating the branch-point-halving argument inside that subtree would produce more than branch points below it on the chosen path, contradicting that we selected the upper among the last branch points. Hence contains at most marked positions. By [L1], the decomposition is -admissible.
The upper occurrence of derives the lower one by a derivation segment , and the lower subtree derives . Repeating or deleting that segment while keeping the rest of the parse tree fixed produces derivations of for every . Therefore every such word lies in .
Hence the integer satisfies Ogden's lemma for .
Context-free languages are not closed under intersection
Statement
Context-free languages are not closed under intersection.
Facts & Assumptions
Given: The languages
By The language generated by a CFG, a language is context-free exactly when some context-free grammar generates it.
By The pumping lemma for context-free languages, every context-free language satisfies the CFL pumping property.
Proof
The grammar , , generates , and the grammar , , generates . Therefore both languages are context-free by [L1].
A word belongs to exactly when its number of 's equals its number of 's and its number of 's equals its number of 's. Hence .
Suppose were context-free. Let be the pumping length from [L2], and consider the word . Any factor with lies within one block or crosses only one of the two block boundaries. Pumping and therefore changes at most two of the three symbol counts, so for or the word cannot still have equal numbers of 's, 's, and 's. This contradicts [L2].
Thus is not context-free even though each of and is. So context-free languages are not closed under intersection.
Context-free languages are not closed under complement
Statement
Context-free languages are not closed under complement.
Facts & Assumptions
Given: The class of context-free languages.
By Context-free languages are not closed under intersection, context-free languages are not closed under intersection.
By Context-free languages are closed under union, concatenation, Kleene star, and homomorphism, context-free languages are closed under union.
De Morgan's law gives for languages over one alphabet.
Proof
Assume for contradiction that context-free languages were closed under complement. Then the complements and of context-free languages would again be context-free.
By [L2], the union would then be context-free, and by the contradiction hypothesis its complement would be context-free as well. By [A1], that complement is exactly . So the contradiction hypothesis would force closure under intersection.
This contradicts [L1]. Therefore context-free languages are not closed under complement.
Context-free languages are closed under reversal
Statement
If is context-free, then its reversal is also context-free.
Facts & Assumptions
Given: A context-free language .
By Context-free grammars, a context-free grammar is a finite set of productions with one variable on the left.
By The language generated by a CFG, a language is context-free exactly when some CFG generates it.
By Word reversal and language reversal, reversing a word reverses the order of its letters, and is the set of reversals of words of .
By Derivations and parse trees correspond, parse trees and derivations determine exactly the generated words of a CFG.
Proof
Choose a grammar with by [L2]. Define a new grammar by putting a production in whenever belongs to . This is again a context-free grammar by [L1].
Mirror every parse tree of by reversing the left-to-right order of the children at each internal node. The mirrored tree uses exactly the reversed productions from step 1.1, so by [L4] it is a parse tree of . Its yield is the reversal of the original yield, by [L3]. Therefore implies . Mirroring back proves the converse implication.
Hence , so is context-free by [L2].
The CYK parsing table and span variables
Definition
Let be a grammar in Chomsky normal form, and let be a nonempty word over .
The CYK table of on is the triangular array of sets defined for and by:
and, for ,
When , we say that is a span variable for the substring .
Remarks
-
The definition uses only the CNF production types and .
-
The top cell corresponds to the whole input word.
A variable lies in a CYK table cell exactly when it derives that span
Statement
Let be a Chomsky-normal-form grammar, let be a nonempty word, and let be the CYK table of on . Then for every variable and every valid cell ,
Facts & Assumptions
Given: A CNF grammar , a nonempty word , and its CYK table.
By The CYK parsing table and span variables, the cells are defined by terminal productions for and by binary productions together with a split point for .
By One-step derivation and finite derivation in a context-free grammar, means that the sentential form derives the word by finitely many grammar steps.
Proof
We induct on the span length . For , [L1] says that exactly when is a production, and by [L2] that is exactly when .
Assume the claim known for all shorter spans and let . If , then [L1] provides a split and a production with and . By the induction hypothesis, and , so one use of followed by those derivations gives .
Conversely, suppose with . Because is in CNF, the first derivation step from must be a binary production , and the derived word must split at some into a prefix from and a suffix from . The induction hypothesis then gives and , so [L1] places in .
Steps 1.1, 2.1, and 2.2 prove the equivalence for every cell.
The CYK algorithm decides membership for CNF grammars
Statement
Let be a grammar in Chomsky normal form.
- On input , accept exactly when is a production of .
- On input a nonempty word , fill the CYK table of on and accept exactly when .
This procedure decides whether .
Facts & Assumptions
Given: A CNF grammar and an input word .
By A variable lies in a CYK table cell exactly when it derives that span, for a nonempty input word, exactly when derives the corresponding span.
By The language generated by a CFG, a word lies in exactly when it is derivable from the start symbol .
Proof
If , then by the definition of Chomsky normal form the only way to derive is the exceptional start production . So the empty-word branch is correct.
Suppose is nonempty. By [L1], the condition is equivalent to . By [L2], that is equivalent to . Therefore the table branch accepts exactly the generated nonempty words.
The two branches together decide membership in .
Context-free-language membership is decidable
Statement
Given a context-free grammar and a word , one can decide whether .
Facts & Assumptions
Given: A context-free grammar and a word .
By Every context-free language has an equivalent grammar in Chomsky normal form, has an equivalent grammar in Chomsky normal form.
By The CYK algorithm decides membership for CNF grammars, the CYK procedure decides membership for CNF grammars.
Proof
Convert to an equivalent CNF grammar using [L1].
Run the CYK membership procedure from [L2] on and . Because is equivalent to , the answer is "yes" exactly when .
Therefore context-free-language membership is decidable.
CFG emptiness and finiteness are decidable
Statement
Given a context-free grammar , one can decide whether is empty and whether is finite.
Facts & Assumptions
Given: A context-free grammar .
By The language generated by a CFG, the language of is the set of words derivable from the start symbol .
By Eliminating useless symbols preserves the generated language, useless symbols can be removed without changing the generated language.
By Epsilon-productions can be eliminated except possibly at the start symbol, epsilon-productions can be removed except for the standard start-symbol exception.
By Unit productions can be eliminated, unit productions can be removed without changing the generated language.
Proof
To decide emptiness, compute the least set of generating variables: start with variables that have a production to a terminal word, and repeatedly add a variable once some production has every variable occurring in already marked generating. Because is finite, this fixed-point computation halts. By [L1], the language is empty exactly when the start variable never becomes generating.
For finiteness, first replace by an equivalent grammar using [L2], [L3], and [L4], so that every remaining variable is useful, there are no unit productions, and there are no epsilon-productions except possibly the start-symbol exception. Build the directed dependency graph on the variables of with an edge whenever some production for contains on its right-hand side.
If some reachable variable lies on a directed cycle of this graph, then usefulness gives a terminal derivation from each variable on the cycle, while the removal of unit and nonstart epsilon-productions forces at least one terminal symbol to be added when the cycle is traversed once. Hence there is a derivation with . Repeating that cycle any number of times and then finishing to terminals yields words of arbitrarily large length in , so the language is infinite.
Conversely, if the reachable part of the dependency graph is acyclic, then no root-to-leaf path in a parse tree can repeat a reachable variable. So parse trees have uniformly bounded depth. Because has only finitely many productions and bounded branching, only finitely many parse trees can occur, and therefore only finitely many terminal yields occur. Thus is finite.
Step 1.1 decides emptiness, and steps 2.1-2.2 decide finiteness by a finite graph-cycle test.
The CFG equivalence and ambiguity problems
Definition
The CFG equivalence problem asks, given two context-free grammars and over the same alphabet, whether
The CFG ambiguity problem asks, given a context-free grammar , whether is ambiguous in the sense of Ambiguous grammars, unambiguous grammars, and inherently ambiguous languages.
Remarks
-
Equivalence is a problem about pairs of grammars; ambiguity is a problem about one grammar.
-
Normal-form conversions preserve the languages of grammars, but they do not by themselves answer either decision problem.
FALSE: the context-free pumping lemma characterizes the context-free languages
Statement
False claim: a language is context-free exactly when it satisfies the ordinary Bar-Hillel pumping condition.
Facts & Assumptions
Given: Put , let be a new symbol, and set
The statement refuted is: a language is context-free exactly when it satisfies the ordinary Bar-Hillel pumping condition.
The proof of Context-free languages are not closed under intersection establishes that is not context free.
PDA's recognize exactly the context-free languages (PDAs recognize exactly the context-free languages), and context-free languages are closed under homomorphic image (Context-free languages are closed under union, concatenation, Kleene star, and homomorphism).
Refutation
We verify the ordinary pumping condition with pumping length . Let have length at least , with . If , pump the first letter of . If , then , and pump the unique initial . If and is nonempty, pump its first letter. In all three cases take the pumped letter as and take ; pumping preserves membership because it either keeps or changes the single initial to , which belongs to the second part of for every .
Suppose for contradiction that were context free. Let , which is regular. Choose a PDA for using [L3] and a DFA for . The product control consisting of the PDA state and DFA state, with the same stack operation as the PDA and with epsilon moves leaving the DFA state fixed, is a PDA for . Hence is context free.
It remains to treat with . For , take ; for , take . Put and let be the remaining suffix. Pumping produces respectively or , whose exponent is never . Thus , , and every pumped word lies in .
By definition, . Apply the homomorphism that deletes the initial symbol and fixes . Closure under homomorphism from [L3] would make context free, contradicting [L2]. Therefore is not context free.
Steps 1.1 and 2.1 show that satisfies the ordinary pumping condition, while step 2.2 shows that it is not context free. Thus [A1] is false.
FALSE: CYK needs no normal-form preprocessing
Statement
False claim: the CYK algorithm can be applied directly to any context-free grammar without first converting it to a suitable normal form.
Facts & Assumptions
Given: The grammar
The statement refuted is: the CYK algorithm can be applied directly to any context-free grammar without first converting it to a suitable normal form.
By The CYK parsing table and span variables, the CYK table recurrence uses only productions of the forms and .
By The CYK algorithm decides membership for CNF grammars, the CYK algorithm is proved correct exactly for grammars in the required CNF shape.
By Every context-free language has an equivalent grammar in Chomsky normal form, an arbitrary context-free grammar can first be converted to an equivalent CNF grammar.
Refutation
In the displayed grammar, the production has length three and mixes terminals with a variable, while has two terminals on the right-hand side. Neither production has one of the two forms listed in [L1].
Therefore the literal CYK recurrence does not know how to place into any table cell directly from those productions, so the proof of correctness in [L2] does not apply. One must first normalize the grammar as in [L3], or else modify the algorithm itself.
This contradicts [A1]. So CYK does require the normal-form preprocessing built into its proof.
FALSE: CFG equivalence is decidable by normalization
Statement
False claim: converting context-free grammars to normal form gives a decision procedure for the CFG equivalence problem.
Facts & Assumptions
Given: The CFG equivalence problem.
The statement refuted is: converting context-free grammars to normal form gives a decision procedure for the CFG equivalence problem.
By The CFG equivalence and ambiguity problems, CFG equivalence asks whether two grammars over the same alphabet generate exactly the same language.
Aho's cited Lecture 11 lists the problem “do two given CFG's generate the same language?” among the undecidable problems for context-free grammars.
Refutation
Normalization preserves the language generated by a grammar, so it may be used as preprocessing for [L1], but it does not produce a canonical normal form whose literal equality settles language equality.
More decisively, [F1] states that the general CFG equivalence problem is undecidable. So no normalization-only method can decide it in full generality.
This contradicts [A1]. Therefore CFG equivalence is not decidable merely by normalization.
5 · Examples, counterexamples and false statements
None yet.
Sources
- Jean Gallier and Jocelyn Quaintance, Introduction to the Theory of Computation: Some Notes for CIS511
- Alfred V. Aho, COMS W3261 CS Theory, Lecture 10
- Alfred V. Aho, COMS W3261 CS Theory, Lecture 11
- H. Conrad Cunningham, CSci 311, Models of Computation, Chapter 8
- David S. Wise, A Strong Pumping Lemma for Context-Free Languages
- Computer Science Stack Exchange, Example of a non-context-free language that nonetheless can be pumped
- ROIFE BLOG, [形式语言] 06 Context-free Language