## Lemma 2.22

### If a pushdown automaton recognizes some language, then the language is context-free.

### Constructive proof (p. 122)

Let *P* = (*Q*, Σ, Γ, δ, *q*_{0},
{*q*_{accept}}). The variables of *G* are
{*A*_{p, q} | *p, q* ∈ *Q*}. The start variable is
*A*_{q0, qaccept}.
Construct the rules of gramamr *G* as follows:
- For each
*p*, *q*, *r* *s* ∈ *Q*, *t* ∈ Γ, and
*a*, *b* ∈ Σ_{ε}, if δ(*p*, *a*, ε)
contains (*r*, *t*) and δ(*s*, *b*, *t*) contains
(*q*, ε), put the rule *A*_{pq}→ *aA*_{rs}b in
*G*.

- For each
*p*, *q*, *r* ∈ *Q*, put the rule
*A*_{pq}→ *A*_{pr} A_{rq} in *G*.

- For each
*p* ∈ *Q*, put the rule *A*_{pp} → ε
in *G*.