More PDAs, Pumping Lemma for CFGs, Compression




CS154

Chris Pollett

Mar 18, 2013

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 (Sec 1)

Which of the following is true?

  1. The CYK algorithm requires a grammar to be in Greibach Normal Form.
  2. The PDA one gets from class for converting a CFG to an equivalent PDA has at least three states.
  3. We gave an algorithm to convert nondeterministic PDAs into deterministic ones.

Quiz (Sec 3)

Which of the following is true?

  1. The algorithm from class for converting CFGs to equivalent PDAs gives a PDA with at most three states.
  2. The CYK algorithm from class makes use of a CFG in Chomsky Normal Form (CNF).
  3. `epsilon`-rules on a non-start variable are allowed in CNF.

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 in `A` of length at least `p`, then `s` may be 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