Let $G=(V,T,Q,S)$ be a CFG. Construct the PDA $P$ that accepts $L(G)$ by empty stack as follows:
$$ P=(\{q\}, T, V\cup T, \delta, q, S) $$
where transition function $\delta$ is defined by:
Type 1 rules: (Rule 2 on book)
$$
\text{For each terminal $a$, $δ(q, a, a) = \{(q, ε)\}.$}
$$
This step does not change the LSF (Left-Sentential Form) represented, but “moves” responsibility for $a$ from the stack to the consumed input.
Type 2 rules: (Rule 1 on book)
$$ \delta(q, \varepsilon, A) = \{(q,\beta)~|~A\rightarrow\beta\text{ is a production of }G\} $$
Guess a production for A, and represent the next LSF in the derivation.
Intuition
At each step, P represents some left-sentential form (step of a leftmost derivation).
- If the stack of P is $\rm a$, and P has so far consumed $\rm x$ from its input, then P represents left-sentential form $\rm xa$.
- At empty stack, the input consumed is a string in L(G).
To show that $(q, wx, S)\vdash^* (q, x, \alpha)$ for any x if and only if $S \Rightarrow^*_{lm}w\alpha$
Proved by an induction on the number of steps made by P
Basis: 0 steps ⇒ $\alpha = S$, $w = ε$, and $S \Rightarrow^*_{lm} S$ is surely true
Induction: Consider n moves of P. Assume the IH for sequences of n-1 moves.
There are two cases, depending on whether the last move uses a Type 1 or Type 2 rule.
Suppose $w$ is in $L(G)$. Then $w$ has a lm derivation:
$$ \gdef\rlm{\Rightarrow_{lm}}
S=\gamma_1 ~\rlm \gamma_2~\rlm … ~\rlm \gamma_n = w $$