Jump to content

Ogden's lemma: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
Add reference to Ogden's lemma being insufficient to characterize CFLs
m Moved punctuation mark to correct place + other fixes, References after punctuation per WP:CITEFOOT and WP:PAIC
Line 34: Line 34:


=== Non-context-freeness ===
=== Non-context-freeness ===
The special case of Ogden's lemma is often sufficient to prove some languages are not context-free. For example, <math>\{ a^m b^n c^m d^n | m, n \geq 1\} </math> is a standard example of non-context-free language (<ref>{{Cite book |last=Hopcroft |first=John E. |url=https://www.worldcat.org/oclc/4549363 |title=Introduction to automata theory, languages, and computation |date=1979 |publisher=Addison-Wesley |others=Jeffrey D. Ullman |isbn=0-201-02988-X |location=Reading, Mass. |oclc=4549363}}</ref>, p. 128).
The special case of Ogden's lemma is often sufficient to prove some languages are not context-free. For example, <math>\{ a^m b^n c^m d^n | m, n \geq 1\} </math> is a standard example of non-context-free language (,<ref>{{Cite book |last=Hopcroft |first=John E. |url=https://www.worldcat.org/oclc/4549363 |title=Introduction to automata theory, languages, and computation |date=1979 |publisher=Addison-Wesley |others=Jeffrey D. Ullman |isbn=0-201-02988-X |location=Reading, Mass. |oclc=4549363}}</ref> p.&nbsp;128).
{{Math proof|title=Proof|proof=
{{Math proof|title=Proof|proof=


Line 72: Line 72:
{{Math proof|title=Construction|proof=
{{Math proof|title=Construction|proof=


Given any Post correspondence problem over binary strings, we reduce it to a decision problem over a CFG.
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>\xi_1, ..., \xi_n</math> and <math>\eta_1, ..., \eta_n</math>, rewrite the binary alphabet to <math>\{d, e\}</math>.
Given any two lists of binary strings <math>\xi_1, ..., \xi_n</math> and <math>\eta_1, ..., \eta_n</math>, rewrite the binary alphabet to <math>\{d, e\}</math>.
Line 82: Line 82:
And the language <math>((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.
And the language <math>((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 ==
== Generalized condition ==



Revision as of 18:56, 24 May 2024

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.

Despite Ogden's lemma being a strengthening of the pumping lemma, it is insufficient to fully characterize the class of context-free languages.[2] 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

Ogden's lemma — If a language is generated by a context-free grammar, then there exists some such that with length , and any way of marking positions of as "marked", there exists a nonterminal and a way to split into 5 segments , such that

contains at least one marked position.

contains at most marked positions.

both contain marked positions, or 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 (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

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. for all .

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 .

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, is a standard example of non-context-free language (,[3] p. 128).

Proof

Suppose the language is generated by a context-free grammar, then let be the length required in Ogden's lemma, then consider the word in the language. Then the three conditions implied by Ogden's lemma cannot all be satisfied.

Similarly, one can prove the "copy twice" language is not context-free, by using Ogden's lemma on .

And the given example last section is not context-free by using Ogden's lemma on .

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 . The language is inherently ambiguous. (Example from page 3 of Ogden's paper.)

Proof

Let be the pumping length needed for Ogden's lemma, and apply it to the sentence .

By routine checking of the conditions of Ogden's lemma, we find that the derivation is

where , satisfying and and .

Thus, we obtain a derivation of by interpolating the derivation with copies of . According to this derivation, an entire sub-sentence is the descendent of one node in the derivation tree.

Symmetrically, we can obtain another derivation of , according to which there is an entire sub-sentence being the descendent of one node in the derivation tree.

Since , the two sub-sentences have nonempty intersection, and since neither contains the other, the two derivation trees are different.

Similarly, is inherently ambiguous, and for any CFG of the language, letting be the constant for Ogden's lemma, we find that has at least different parses. Thus 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)

Construction

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 and , rewrite the binary alphabet to .

Let be the language over alphabet , generated by the CFG with rules for every . Similarly define .

Now, by the same argument as above, the language is inherently ambiguous iff the Post correspondence problem has a solution.

And the language has an unbounded degree of inherent ambiguity iff the Post correspondence problem has a solution.

Generalized condition

Bader and Moura have generalized the lemma[4] 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.[5] 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 , where p is some constant that depends only on the language. The statement becomes that every s can be written as

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 marked positions, and
  3. for all .

Moreover, either each of u,v,w has a marked position, or each of 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. S2CID 13197551.
  2. ^ Kracht, Marcus (2004). Too Many Languages Satisfy Ogden’s Lemma (PDF). Proceedings of the 27th Pennsylvania Linguistics Colloquium. Philadelphia. pp. 115–121. Retrieved 16 May 2024.
  3. ^ 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.
  4. ^ 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. S2CID 33988796.
  5. ^ 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, retrieved 2023-02-26