1

I have the proof below in my lecture. I would be very grateful if someone could explain the argumentation for the case $\alpha = BC$. Furthermore, I do not fully understand the subsequent arguments for cases 2 and 3. Overall, I have been wondering what the big picture is in the part of the proof that deals with the converse direction, i.e., how the individual proof steps fit together here.

I would be very grateful for your help. Please tell if I missed some information instead of just voting down. Thank you.

Sentence 74: A language L is context-free if and only if L is accepted by a pushdown automaton.

Proof: To prove this statement, we need to show two different directions:

  • Given a context-free grammar G, construct a pushdown automaton $M$ such that $L(G) = L(M)$.
  • Given a pushdown automaton $M'$, construct a context-free grammar $G'$ such that $L(M') = L(G')$.

"$\Rightarrow$": Let $G = (\Sigma, N, P,S)$ be a type-2 grammar with $L = L(G)$. We construct a pushdown automaton that simulates the production steps of $G$ using the contents of its stack.

The stack alphabet of $M$ is $\Gamma =_{def} N \cup \Sigma$, where the bottom symbol of the stack is $S$. If this is removed with a pop operation, then $M$ accepts. Thus, we have: $$M = (\{z\}, \Sigma, \Gamma, \delta, z, S)\text{, where } \delta \text{ is defined as follows:}$$ For every rule $A \rightarrow \alpha \in P$ and $\alpha \in(N \cup \Sigma)^*$, set $\delta(z, \epsilon, A) \ni(z, \alpha)$ and $\delta(z, a, a) \ni(z, \epsilon)$ for $a \in \Sigma$.

This way, whenever the top symbol of the stack is a non-terminal of the grammar, a rule from $P$ is non-deterministically applied without reading an input symbol. Whenever a terminal symbol is on top of the stack, it is removed with a pop operation if and only if it matches the current input symbol.

Thus, $x \in \mathrm{L}(\mathrm{G})$ if and only if $x$ can be generated from $S$ (i.e., $\mathrm{S}\underset{\mathrm{G}}{\stackrel{*}{\vdash}} x$) if and only if there is a sequence of configurations of $M$ with $(z, x, S) \underset{\mathrm{M}}{\stackrel{*}{\vdash}} \ldots \underset{\mathrm{M}}{\stackrel{*}{\vdash}} (z, \epsilon, \epsilon)$ iff $x \in \mathrm{L}(M)$, i.e. $M$ accepts $x$.

"$\Leftarrow$": Let $M$ be a PDA with $M=\left(Z, \Sigma, \Gamma, \delta, z_0, \#\right)$ and $L=L(M)$. We want to find a type-2 grammar $G$ with $L=L(G)$.

Without loss of generality, we can assume that for every line of the $\delta$-function $z a A \rightarrow z^{\prime} B_1 \ldots B_k$ with $k \leqslant 2$, because if $k>2$, we can equivalently replace this line by

enter image description here

where $z_1, \ldots, z_{k-2}$ are new states. We now construct a grammar that simulates the steps of $M$, where the non-terminals of the grammar are composed of several parts (via cross-product). Let $G=(\Sigma, N, P, S)$ and

$$ N=\{S\} \cup(Z \times \Gamma \times Z) $$

The first component of a triple from $Z \times \Gamma \times Z$ stands for the previous state, the second component stands for the processed stack symbol, and the last component symbolizes the reached state. Now we define

$$ P = \{S \rightarrow \overbrace{\left(z_0, \#, z\right)}^{\text {non-terminal}} \mid z \in Z\} \cup \left\{\left(z, A, z^{\prime}\right) \rightarrow a \mid \delta(z, a, A) \ni\left(z^{\prime}, \epsilon\right) \text { and } z^{\prime} \in Z\right\} \cup\left\{\left(z, A, z^{\prime}\right) \rightarrow \mathrm{a}\left(z_1, \mathrm{~B}, z^{\prime}\right) \mid \delta(z, \mathrm{a}, \mathrm{A}) \ni\left(z_1, \mathrm{~B}\right) \text { and } z^{\prime} \in Z\right\} \cup \left\{\left(z, A, z^{\prime}\right) \rightarrow \mathrm{a}\left(z_1, \mathrm{~B}, z_2\right)\left(z_2, \mathrm{C}, z^{\prime}\right) \mid \delta(z, \mathrm{a}, \mathrm{A}) \ni\left(z_1, \mathrm{BC}\right) \text { and } z^{\prime}, z_2 \in Z \right\} $$

This construction can generate rules of the form $A \rightarrow \epsilon$, which are actually illegal according to our definition. However, rules of this form can easily be removed from the grammar afterwards. We now show that $\left(z, A, z'\right) \underset{\mathrm{G}}{\stackrel{*}{\vdash}} x$ if and only if $\left(z, x, A\right) \underset{\mathrm{M}}{\stackrel{*}{\vdash}}\left(z^{\prime}, \epsilon, \epsilon\right)$. To do this, we first observe that for $a \in \Sigma \cup\{\epsilon\}$, $$ \left(z, A, z^{\prime}\right) \underset{\mathrm{G}}{\stackrel{}{\vdash}} \mathrm{a} \quad \text { iff } \quad\left(z, A, z^{\prime}\right) \rightarrow \mathrm{a} \in \mathrm{P}(\star \star) $$

holds. Now we prove by induction over the number of induction steps that if $\left(z, A, z^{\prime}\right)\underset{\mathrm{G}}{\stackrel{*}{\vdash}} x$, then $\left(z, x, A\right) \underset{\mathrm{M}}{\stackrel{*}{\vdash}} \left(z^{\prime}, \epsilon, \epsilon\right)$.

(BC) This is directly shown by observation ($\star \star$).

(IS) We have $(z, a y, A)\underset{\mathrm{M}}{\stackrel{}{\vdash}}\left(z_1, y, \alpha\right)\underset{\mathrm{M}}{\stackrel{*}{\vdash}}\left(z^{\prime}, \epsilon, \epsilon\right)$, where $a \in \Sigma \cup\{\epsilon\}, z_1 \in Z$, and $\alpha \in \Gamma^*$. We consider three possible stack contents:

$\alpha=\epsilon$: This is not possible because $\left(z_1, \gamma, \epsilon\right)$ does not have a successor configuration, i.e., the computation would terminate.

$\alpha=$ B: By the induction hypothesis, we have $\left(z_1, B, z^{\prime}\right) \underset{\mathrm{G}}{\stackrel{*}{\vdash}} y$. Furthermore, there exists a rule in $P$ of the form $\left(z, A, z^{\prime}\right) \rightarrow a\left(z_1, B, z^{\prime}\right)$. Together, this implies $\left(z, A, z^{\prime}\right)\underset{\mathrm{G}}{\stackrel{}{\vdash}} a\left(z_1, B, z^{\prime}\right) \underset{\mathrm{G}}{\stackrel{*}{\vdash}}\underbrace{a y}_{=x}$.

Remark: I added the $\underset{\mathrm{G}}{\stackrel{*}{\vdash}}$ in the line above since it was missing in the original proof.

$\alpha=$ BC: We decompose $\left(z_1, y, B C\right)\underset{\mathrm{M}}{\stackrel{*}{\vdash}}\left(z^{\prime}, \epsilon, \epsilon\right)$ into two parts $\left(z_1, y, B C\right)\underset{\mathrm{M}}{\stackrel{*}{\vdash}}\left(z_1, y_2, C\right)$ and $\left(z_2, y_2, C\right)\underset{\mathrm{M}}{\stackrel{*}{\vdash}}\left(z^{\prime}, \epsilon, \epsilon\right)$ such that $y=y_1 y_2$. For the initial segment $y_1$, we have $\left(z_1, y, B\right)\underset{\mathrm{M}}{\stackrel{*}{\vdash}}\left(z_2, \epsilon, \epsilon\right)$. By (IH), we have $\left(z_1, B, z_2\right)\underset{\mathrm{G}}{\stackrel{*}{\vdash}} y_1$, $\left(z_2, X, z^{\prime}\right) \underset{\mathrm{G}}{\stackrel{*}{\vdash}} y_2$, and there must exist a rule $\left(z, A, z^{\prime}\right) \rightarrow a\left(z_1, ~B, z_2\right)\left(z_2, C, z^{\prime}\right) \in P$. Together, we have $\left(z, A, z^{\prime}\right)\underset{\mathrm{G}}{\stackrel{}{\vdash}} \mathrm{a}\left(z_1, \mathrm{~B}, z_2\right)\left(z_2, \mathrm{B}, z^{\prime}\right) \underset{\mathrm{G}}{\stackrel{*}{\vdash}} \mathrm{a}y_1\left(z_2, \mathrm{C}, z^{\prime}\right)\underset{\mathrm{G}}{\stackrel{*}{\vdash}} \underbrace{\mathrm{a}y_1 y_2}_{=x}$. Finally, we show by induction on the number of induction steps that if $(z, x, A)\underset{\mathrm{M}}{\stackrel{*}{\vdash}}\left(z^{\prime}, \epsilon, \epsilon\right)$, then also $\left(z, A, z^{\prime}\right) \underset{\mathrm{G}}{\stackrel{*}{\vdash}} x$.

(BC) See observation ($\star \star$).

(IS) The induction step is divided into three sub-proofs:

Case 1: If $\left(z, A, z^{\prime}\right) \underset{\mathrm{G}}{\stackrel{}{\vdash}} a \underset{\mathrm{G}}{\stackrel{}{\vdash}} x$, then $x=a \in \Sigma$. This is not possible since $k>1$ and $|x|=1$.

Case 2: If $\left(z, a, z^{\prime}\right) \underset{\mathrm{G}}{\stackrel{}{\vdash}} a\left(z_1, B, z^{\prime}\right)\underset{\mathrm{G}}{\stackrel{*}{\vdash}} a y$, where $a y=x$. Then, $\delta(z, a, A) \ni\left(z_1, B\right)$ and by (IA), we have $\left(z_1, B, z^{\prime}\right) \underset{\mathrm{M}}{\stackrel{*}{\vdash}} \left(z^{\prime}, \epsilon, \epsilon\right)$. Together, we have $(z, a y, A)\underset{\mathrm{M}}{\stackrel{}{\vdash}}\left(z_1, y, B\right)\underset{\mathrm{M}}{\stackrel{*}{\vdash}}\left(z^{\prime}, \epsilon, \epsilon\right)$.

Case 3: If $\left(z, A, z^{\prime}\right) \underset{\mathrm{G}}{\stackrel{}{\vdash}} a\left(z_1, B, z_2\right)\left(z_2, C, z^{\prime}\right) \underset{\mathrm{G}}{\stackrel{*}{\vdash}} a y$, where $a y=x$, then $\delta(z, a, A) \ni$ $\left(z_1\right.$, BC) and by (IA), we have both $\left(z_1, y_1, \mathrm{~B}\right)\underset{\mathrm{M}}{\stackrel{*}{\vdash}} \left(z_2, \epsilon, \epsilon\right)$ and $\left(z_2, y_2, C\right) \underset{\mathrm{M}}{\stackrel{*}{\vdash}} \left(z^{\prime}, \epsilon, \epsilon\right)$. Together, we have $\left(z, a y_1 y_2, A\right)\underset{\mathrm{M}}{\stackrel{}{\vdash}}\left(z_1, y_1, y_2, B C\right)\underset{\mathrm{M}}{\stackrel{*}{\vdash}}\left(z_2, y_2, \mathrm{C}\right)\underset{\mathrm{M}}{\stackrel{*}{\vdash}}\left(z^{\prime}, \epsilon, \epsilon\right)$.

Therefore, we have $L(M)=L(G)$ and

$$ \begin{array}{lll} x \in \mathrm{L}(M) & \text { iff } & \left(z_0, x, \#\right) \underset{\mathrm{M}}{\stackrel{*}{\vdash}} (z, \epsilon, \epsilon) \text { for } z \in Z . \\ & \text { iff } & S \underset{\mathrm{G}}{\stackrel{}{\vdash}} \left(z_0, \#, z\right) \underset{\mathrm{G}}{\stackrel{*}{\vdash}} x \text { for } z \in Z . \\ & \text { iff } & x \in \mathrm{L}(\mathrm{G}) \end{array} $$

This shows that a language L is context-free iff it is accepted by a pushdown automaton. $\#$

Rico1990
  • 295

0 Answers0