PDAs and CFLs, Pumping Lemma for CFLs




CS154

Chris Pollett

Apr 6, 2020

Outline

Introduction

CFL to PDA

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. In LL-Parsing, the second L denotes that the parsing is being done according to a left-most derivation of the string being parsed.
  2. Greibach Normal Form shows that parsing can be done using only logarithmic in the input length amount of space.
  3. A pushdown automata is a deterministic finite automata augmented with a queue.

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