Ogden's lemma
In the theory of formal languages, Ogden's lemma (named after William F. Ogden)[1] is a generalization of the pumping lemma for context-free languages.
Statement
Ogden's lemma — If a language [math]\displaystyle{ L }[/math] is generated by a context-free grammar, then there exists some [math]\displaystyle{ p\geq 1 }[/math] such that [math]\displaystyle{ \forall w \in L }[/math] with length [math]\displaystyle{ \geq p }[/math], and any way of marking [math]\displaystyle{ \geq p }[/math] positions of [math]\displaystyle{ w }[/math] as "marked", there exists a nonterminal [math]\displaystyle{ A }[/math] and a way to split [math]\displaystyle{ w }[/math] into 5 segments [math]\displaystyle{ uxzyv }[/math], such that
[math]\displaystyle{ S \Rightarrow^* uAv \Rightarrow^* uxAyv \Rightarrow^* uxzyv }[/math]
[math]\displaystyle{ z }[/math] contains at least one marked position.
[math]\displaystyle{ xzy }[/math] contains at most [math]\displaystyle{ p }[/math] marked positions.
[math]\displaystyle{ u, x }[/math] both contain marked positions, or [math]\displaystyle{ y, v }[/math] both contain marked positions.
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 [math]\displaystyle{ p\geq 1 }[/math] (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
- [math]\displaystyle{ s = uvwxy }[/math]
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
- [math]\displaystyle{ uv^n wx^n y \in L }[/math] for all [math]\displaystyle{ n \geq 0 }[/math].
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 [math]\displaystyle{ \{a^i b^j c^k d^l : i = 0 \text{ or } j = k = l\} }[/math].
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, [math]\displaystyle{ \{ a^m b^n c^m d^n | m, n \geq 1\} }[/math] is a standard example of non-context-free language ([2], p. 128).
Suppose the language is generated by a context-free grammar, then let [math]\displaystyle{ p }[/math] be the length required in Ogden's lemma, then consider the word [math]\displaystyle{ a^p\underline{b^pc^p}d^p }[/math] in the language. Then the three conditions implied by Ogden's lemma cannot all be satisfied.
Similarly, one can prove the "copy twice" language [math]\displaystyle{ L=\{w^2 | w \in \{a, b\}^*\} }[/math] is not context-free, by using Ogden's lemma on [math]\displaystyle{ a^{2p}\underline{b^{2p}}a^{2p}b^{2p} }[/math].
And the given example last section [math]\displaystyle{ \{a^i b^j c^k d^l : i = 0 \text{ or } j = k = l\} }[/math] is not context-free by using Ogden's lemma on [math]\displaystyle{ ab^{2p} \underline{c^{2p}}d^{2p} }[/math].
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 [math]\displaystyle{ L_0 = \{a^nb^mc^m | m, n \geq 1\}, L_1 = \{a^mb^mc^n | m, n \geq 1\} }[/math]. The language [math]\displaystyle{ L = L_0 \cup L_1 }[/math] is inherently ambiguous. (Example from page 3 of Ogden's paper.)
Let [math]\displaystyle{ p }[/math] be the pumping length needed for Ogden's lemma, and apply it to the sentence [math]\displaystyle{ a^{p!+p}\underline{b^pc^p} }[/math].
By routine checking of the conditions of Ogden's lemma, we find that the derivation is
[math]\displaystyle{ S \Rightarrow^* uAv \Rightarrow^* uxAyv \Rightarrow^* uxzyv }[/math] where [math]\displaystyle{ u = a^{p! + p}b^{p - s - k}, x = b^{k}, z = b^{s}c^{s'}, y = c^k, v = c^{p - s' - k} }[/math], satisfying [math]\displaystyle{ s+s' \geq 1 }[/math] and [math]\displaystyle{ k \geq 1 }[/math] and [math]\displaystyle{ p \geq s+s' + 2k }[/math].
Thus, we obtain a derivation of [math]\displaystyle{ a^{p!+p}b^{p!+p}c^{p!+p} }[/math] by interpolating the derivation with [math]\displaystyle{ p!/k }[/math] copies of [math]\displaystyle{ A \Rightarrow^* xAy }[/math]. According to this derivation, an entire sub-sentence [math]\displaystyle{ x^{p!/k+1}zy^{p!/k+1} = b^{p!+k+s}c^{p!+k+s'} }[/math] is the descendent of one node [math]\displaystyle{ A }[/math] in the derivation tree.
Symmetrically, we can obtain another derivation of [math]\displaystyle{ a^{p!+p}b^{p!+p}c^{p!+p} }[/math], according to which there is an entire sub-sentence [math]\displaystyle{ a^{p!+k''+s''}b^{p!+k''+s'''} }[/math] being the descendent of one node in the derivation tree.
Since [math]\displaystyle{ (p!+k+s) + (p!+k''+s''') \gt 2p! +1 \gt p! + p }[/math], the two sub-sentences have nonempty intersection, and since neither contains the other, the two derivation trees are different.
Similarly, [math]\displaystyle{ L^* }[/math] is inherently ambiguous, and for any CFG of the language, letting [math]\displaystyle{ p }[/math] be the constant for Ogden's lemma, we find that [math]\displaystyle{ (a^{p!+p}b^{p!+p}c^{p!+p})^n }[/math] has at least [math]\displaystyle{ 2^n }[/math] different parses. Thus [math]\displaystyle{ L^* }[/math] 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)
Given any Post correspondence problem over binary strings, we reduce it to a decision problem over a CFG.
Given any two lists of binary strings [math]\displaystyle{ \xi_1, ..., \xi_n }[/math] and [math]\displaystyle{ \eta_1, ..., \eta_n }[/math], rewrite the binary alphabet to [math]\displaystyle{ \{d, e\} }[/math].
Let [math]\displaystyle{ L\left(\xi_1, \cdots, \xi_{n}\right) }[/math] be the language over alphabet [math]\displaystyle{ \{d,e,f\} }[/math], generated by the CFG with rules [math]\displaystyle{ S \to \xi_iS d^i e| f }[/math] for every [math]\displaystyle{ i = 1, ..., n }[/math]. Similarly define [math]\displaystyle{ L\left(\eta_1, \cdots, \eta_{n}\right) }[/math].
Now, by the same argument as above, the language [math]\displaystyle{ (L_0 \cdot L\left(\xi_1, \cdots, \xi_{n}\right))\cup (L_1 \cdot L\left(\eta_1, \cdots, \eta_{n}\right)) }[/math] is inherently ambiguous iff the Post correspondence problem has a solution.
And the language [math]\displaystyle{ ((L_0 \cdot L\left(\xi_1, \cdots, \xi_{n}\right))\cup (L_1 \cdot L\left(\eta_1, \cdots, \eta_{n}\right)))^* }[/math] has an unbounded degree of inherent ambiguity iff the Post correspondence problem has a solution.
Generalized condition
Bader and Moura have generalized the lemma[3] 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.[4] If we denote the number of such excluded positions by e, then the number d of marked positions of which we want to include some in vx must satisfy [math]\displaystyle{ d\geq p(e+1) }[/math], where p is some constant that depends only on the language. The statement becomes that every s can be written as
- [math]\displaystyle{ s = uvwxy }[/math]
with strings u, v, w, x, and y, such that
- vx has at least one marked position and no excluded position,
- vwx has at most [math]\displaystyle{ p^{(e+1)} }[/math] marked positions, and
- [math]\displaystyle{ uv^n wx^n y \in L }[/math] for all [math]\displaystyle{ n \geq 0 }[/math].
Moreover, either each of u,v,w has a marked position, or each of [math]\displaystyle{ w,x,y }[/math] has a marked position.
References
- ↑ Ogden, William (September 1968). "A helpful result for proving inherent ambiguity". Mathematical Systems Theory 2 (3): 191–194. doi:10.1007/bf01694004. ISSN 0025-5661. http://dx.doi.org/10.1007/bf01694004.
- ↑ Hopcroft, John E. (1979). Introduction to automata theory, languages, and computation. Jeffrey D. Ullman. Reading, Mass.: Addison-Wesley. ISBN 0-201-02988-X. OCLC 4549363. https://www.worldcat.org/oclc/4549363.
- ↑ Bader, Christopher; Moura, Arnaldo (April 1982). "A Generalization of Ogden's Lemma". Applied Mathematics and Computation 29 (2): 404–407. doi:10.1145/322307.322315.
- ↑ Dömösi, Pál; Kudlek, Manfred (1999), "Strong iteration lemmata for regular, linear, context-free, and linear indexed languages", Fundamentals of Computation Theory (Berlin, Heidelberg: Springer Berlin Heidelberg): pp. 226–233, doi:10.1007/3-540-48321-7_18, ISBN 978-3-540-66412-3, http://dx.doi.org/10.1007/3-540-48321-7_18, retrieved 2023-02-26
Original source: https://en.wikipedia.org/wiki/Ogden's lemma.
Read more |