More PDAs, Pumping Lemma for CFGs, Compression




CS154

Chris Pollett

Mar 14, 2011

Outline

PDA to CFL

Let `P` be a PDA. We want to make a CFG `G` that generates the same language.

The proof that languages given by PDAs and the CFLs are the same is due independently to Chomsky (1962), Schutzenberger (1963), and Evey (1963).

Example PDA in JFLAP and of PDA to CFL conversion

Another Proof of the PDA to CFL result

Quiz

Which of the following is true?

  1. The CYK algorithm requires the CFG to be in Greiback Normal Form.
  2. The PDA constructed to simulate a given CFG presented last day had three main states as well as auxiliary states that depended on the grammar.
  3. The grammar obtained from our conversion of a CFG to Chomsky Normal Form will be of size at most the size of the original grammar.

Pumping Lemma for Context Free Languages

Theorem. If `A` is a context free language, then there is a number `p` (the pumping length) where, if `s` is any string `A` of length at least `p`, then `s` maybe divided into five pieces `s = uvxyz` satisfying the conditions:

  1. For each `i ge 0`, `uv^ixy^iz` is in `A`,
  2. `|vy| > 0`, and
  3. `|vxy| le p`.

Proof. Let `G` be a CFG for our context free language `A`. Let `|V|` be the number of variables in `G`. Let `b` be the maximum number of symbols on the right hand side of a rule. So the maximum number of leaves a parse tree of height `d` can have is `b^d`. We set the pumping length to `p = b^(|V|+1)`. So if `s` is in `A` of length bigger than `p`, its smallest parse tree must be of height greater than `|V|+1`. So some variable `R` must be repeated. So we can do the following kind of surgeries on the parse tree to show Condition 1 of the pumping lemma:
CFG pumping lemma proof tree surgery Condition 2 of the pumping lemma will hold since if `v` and `y` were the empty string then the pumped down tree would be a smaller derivations of `s` contradicting our choice of parse tree. Condition 3 can be guaranteed by choosing `R` so both occurrence are among the last `|V|+1` nonterminals of the longest path in the tree. The upper `R` generates `vxy` is therefore of height at most `|V|+1` and so can generate a string of length at most `b^(|V|+1) = p`.

Remarks on the Pumping Lemma

Example use of the CFL Pumping Lemma

Grammar-Based Compression Algorithms

SEQUITUR

Example of Compressing with SEQUITUR