We will proceed in a manner analogous to Kleene's theorem for regular
languages: that is, we will try to slice up the machine into various
components (each of which has a corresponding language), and then put
them back together again using a CFG.
For any PDA, let us define the language
Now, given any PDA, we construct a context-free grammar which accepts the same language as follows: