Lecture 06

Context-free Language Equivalence Theorem

Theorem A language is context-free if and only if it is generated by context-free gramma.

Proof Sketch CFG$$\rightarrow$$PDA PDA$$\rightarrow$$CFG

1. One accepts state
2. Every transition either pushes a symbol on the stack or pops one off (but not both)
3. Only accept with an empty stack
• $$V=\{A_{pq}\}_{p,q\in Q}$$
• $$S=A_{q_0,q_{acc}}$$
• $$A_{pp}\rightarrow\epsilon,\forall p\in Q$$
• $$A_{pq}\rightarrow aA_{rs}b$$
• $$A_{pq}\rightarrow A_{pr}A_{rq},\forall p\in Q$$ Chomsky Normal Form

Definition The context-free gramma $$G$$ in Chomsky Normal Form if all its rule are of the form

1. $$A\rightarrow BC$$, for any $$A\in V$$, $$B,C\in V-\{S\}$$
2. $$A\rightarrow a$$, for any $$A\in V, a\in\Sigma$$
3. $$S\rightarrow\epsilon$$

Theorem For every context-free gramma $$G$$, there is a context-free gramma $$G'$$ in Chomsky Normal Form that generates the same language.

• $$A\rightarrow C_{a_1}...C_{a_k}$$
• $$C_a\rightarrow a$$
• $$A\rightarrow C_{a_1}A^{(1)}$$
• $$A^{(1)}\rightarrow C_{a_2}A^{(2)}$$
• ...
• $$A^{(k-2)}\rightarrow C_{a_{k-1}}C_{a_k}$$
• $$A\rightarrow\epsilon\Rightarrow$$ propagate $$B\rightarrow ABC|BC$$
• $$A\rightarrow B$$ propagate again
• $$A\rightarrow S$$

Regular Grammars

Definition The context-free gramma $$G$$ is regular if their rules are of the form

• $$A\rightarrow bC$$, $$C\neq S$$ (?)
• $$A\rightarrow a$$
• $$S\rightarrow\epsilon$$ (?)

Theorem The language $$L$$ is regular if and only if it is generated by a regular gramma