Ogden's lemma

From HandWiki

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

  1. vx has at least one marked position,
  2. vwx has at most p marked positions, and
  3. [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).

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.)

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)

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

  1. vx has at least one marked position and no excluded position,
  2. vwx has at most [math]\displaystyle{ p^{(e+1)} }[/math] marked positions, and
  3. [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

  1. 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. 
  2. 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. 
  3. 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. 
  4. 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