In the theory of formal languages, Ogden's lemma (named after William F. Ogden) is a generalization of the pumping lemma for context-free languages. Despite Ogden's lemma being a strengthening of the pumping lemma, it is insufficient to fully characterize the class of context-free languages. This is in contrast to the Myhill–Nerode theorem, which unlike the pumping lemma for regular languages is a necessary and sufficient condition for regularity.
Statement We will use underlines to indicate "marked" positions.
Special cases Ogden's lemma is often stated in the following form, which can be obtained by "forgetting about" the grammar, and concentrating on the language itself: If a language L is context-free, then there exists some number p ≥ 1 {\displaystyle p\geq 1} (where p may or may not be a pumping length) such that for any string s of length at least p in L and every way of "marking" p or more of the positions in s, s can be written as
s = u v w x y {\displaystyle s=uvwxy}
with strings u, v, w, x, and y, such that
vx has at least one marked position, vwx has at most p marked positions, and
u v n w x n y ∈ L {\displaystyle uv^{n}wx^{n}y\in L} for all n ≥ 0 {\displaystyle n\geq 0} . In the special case where every position is marked, Ogden's lemma is equivalent to the pumping lemma for context-free languages. Ogden's lemma can be used to show that certain languages are not context-free in cases where the pumping lemma is not sufficient. An example is the language { a i b j c k d l : i = 0 or j = k = l } {\displaystyle \{a^{i}b^{j}c^{k}d^{l}:i=0{\text{ or }}j=k=l\}} .
Example applications
Non-context-freeness The special case of Ogden's lemma is often sufficient to prove some languages are not context-free. For example, { a m b n c m d n | m , n ≥ 1 } {\displaystyle \{a^{m}b^{n}c^{m}d^{n}|m,n\geq 1\}} is a standard example of non-context-free language,
Similarly, one can prove the "copy twice" language L = { w 2 | w ∈ { a , b } ∗ } {\displaystyle L=\{w^{2}|w\in \{a,b\}^{*}\}} is not context-free, by using Ogden's lemma on a 2 p b 2 p _ a 2 p b 2 p {\displaystyle a^{2p}{\underline {b^{2p}}}a^{2p}b^{2p}} . And the given example last section { a i b j c k d l : i = 0 or j = k = l } {\displaystyle \{a^{i}b^{j}c^{k}d^{l}:i=0{\text{ or }}j=k=l\}} is not context-free by using Ogden's lemma on a b 2 p c 2 p _ d 2 p {\displaystyle ab^{2p}{\underline {c^{2p}}}d^{2p}} .
Inherent ambiguity Ogden's lemma can be used to prove the inherent ambiguity of some languages, which is implied by the title of Ogden's paper. Example: Let L 0 = { a n b m c m | m , n ≥ 1 } , L 1 = { a m b m c n | m , n ≥ 1 } {\displaystyle L_{0}=\{a^{n}b^{m}c^{m}|m,n\geq 1\},L_{1}=\{a^{m}b^{m}c^{n}|m,n\geq 1\}} . The language L = L 0 ∪ L 1 {\displaystyle L=L_{0}\cup L_{1}} is inherently ambiguous. (Example from page 3 of Ogden's paper.)
Similarly, L ∗ {\displaystyle L^{*}} is inherently ambiguous, and for any CFG of the language, letting p {\displaystyle p} be the constant for Ogden's lemma, we find that ( a p ! + p b p ! + p c p ! + p ) n {\displaystyle (a^{p!+p}b^{p!+p}c^{p!+p})^{n}} has at least 2 n {\displaystyle 2^{n}} different parses. Thus L ∗ {\displaystyle L^{*}} has an unbounded degree of inherent ambiguity.
Undecidability The proof can be extended to show that deciding whether a CFG is inherently ambiguous is undecidable, by reduction to the Post correspondence problem. It can also show that deciding whether a CFG has an unbounded degree of inherent ambiguity is undecidable. (page 4 of Ogden's paper)
Generalized condition Bader and Moura have generalized the lemma to allow marking some positions that are not to be included in vx. Their dependence of the parameters was later improved by Dömösi and Kudlek. If we denote the number of such excluded positions by e, then the number d of marked positions must satisfy d ≥ p ( e + 1 ) {\displaystyle d\geq p^{(e+1)}} , where p is some constant that depends only on the language. The statement becomes that every s can be written as
s = u v w x y {\displaystyle s=uvwxy}
with strings u, v, w, x, and y, such that
vx has at least one marked position and no excluded position, Let r {\displaystyle r} be the number of marked positions and s {\displaystyle s} the number of excluded positions in vwx; then r ≤ p s + 1 {\displaystyle r\leq p^{s+1}} .
u v n w x n y ∈ L {\displaystyle uv^{n}wx^{n}y\in L} for all n ≥ 0 {\displaystyle n\geq 0} .
References
