Proof (equivalence of context-free grammar and parse tree)
Call a sequence $(\mathbf{T}_0, \mathbf{T}_1, \ldots, \mathbf{T}_n)$ of $G$-parse trees derivative if
-
$T_0 = \set{ε}$ and $l_0(ε) = S$;
-
for each $i<n$, the parse tree $\mathbf{T}_{i+1} = (T_{i+1}, l_{i+1})$ is obtained by taking a leaf $t$ of $T_i$ with $l_i(t)\in V$ and a rule $l_i(t) \to x_0 \ldots x_m\in P$, adding $m+1$ successors of $t$ and labelling them $l_{i+1}(tk) = x_k$.
There is a one-to-one correspondence between $G$-derivations and derivative sequences of $G$-parse trees: a derivation $S = σ_0 \xrightarrow{G}_1 σ_1 \xrightarrow{G}_1 \ldots \xrightarrow{G}_1 σ_n$ uniquely defines a derivative sequence of $G$-parse trees $(\mathbf{T}_0, \ldots, \mathbf{T}_n)$ such that $σ_{\mathbf{T}_i} = σ_i$ and vice versa.
This shows that a $G$-parse tree starting from $S$ exists to parse every $w\in \mathcal{L}(G)$.
Conversely, let $\mathbf{T} = (T, l)$ be a $G$-parse tree starting from $S$ with $σ_\mathbf{T} = w$. We construct a derivative sequence of subtrees of $\mathbf{T}$:
-
Let $\mathbf{T}_0 = (\set{ε}, l|_{\set{ε}})$.
-
Having constructed $\mathbf{T}_i$, find some $t\in T_i$ that is a leaf in $T_i$ but not a leaf in $T$.
-
If such $t$ does not exist, we terminate.
-
Otherwise form $T_{i+1}$ by adding the $T$-successors of $t$ to $T_i$, and repeat step 2.
-
We claim that the construction terminates when $T_i = T$: suppose not. Since $T_i$ is a subtree of $T$, this means there exists $t\in T\setminus T_i$. On the branch leading to $t$ in $T$, there must be a maximal element of $T_i$. It is then a leaf of $T_i$ but not a leaf of $T$. This means our construction has not terminated.