next up previous
Next: Problem 3 - Programming Up: Information Science I Previous: Problem 1 - Operating

Problem 2 - Context-free Grammars

For languages on $ \Sigma = \{ a, b, c \}$, prove the following:

1.
$ \{ a^m b^n c^{m+n} \; \vert \; m,n \geq 1 \}$ is context-free.
2.
$ \{ a^m b^n c^{mn} \; \vert \; m, n \geq 1 \}$ is not context-free.


1.
We shall prove that the context-free grammar $ G = (V, T, P, S)$ where generates the first language.

Let $ w = a^m b^n c^{m+n}$ be a word of $ \{ a^m b^n c^{m+n} \; \vert \; m,n \geq 1 \}$. Then, $ w$ can be derivated from $ S$ by the following sequence of reduction $ S \Rightarrow aAc \Rightarrow^{m-1} a^m A c^m
\Rightarrow a^m bBc c^m \Rightarrow^{n-1} a^m b^n B c^{m+n} \Rightarrow w$ by using first $ m$ times the production $ A\rightarrow aAc$ and then $ n$ times the production $ B\rightarrow bBc$. Thus, the language is at least a subset of $ L(G)$.

The sortest word that can be produced is $ abcc$ of length 4. And that is also by definition of $ \{ a^m b^n c^{m+n} \; \vert \; m,n \geq 1 \}$ the shortest word from the language. By construction of the grammar, all the derivations have the same scheme. A word is guaranteed to have at least one leftmost $ a$ and one rightmost $ c$. Then it can go through a sequence of derivations adding at the same time one $ a$ on the left and one $ c$ one the right. To terminate, a derivation must use the $ A\rightarrow bBc$ production that guarantees the word to have at least one $ b$ between the $ a$'s and the $ c$'s (together with one $ c$ so that the property that the number of $ a$ plus the number of $ b$ is equal to the number of $ c$ is always true). Before reaching the final derivation (the $ \epsilon$ one), the derivation yields $ b$'s at the center together with $ c$'s (always taking care of the above property) so that all the words derived from $ S$ are words of $ \{ a^m b^n c^{m+n} \; \vert \; m,n \geq 1 \}$. Thus, $ L(G)$ is a subset of the language and in fact $ L(G) = \{a^mb^nc^{m+n}\;\vert\;m,n\geq 1\}$.

2.
Let $ N$ be the constant of the pumping lemma. We have $ a^Nb^Nc^{NN}$ in the language and, by the pumping lemma, it can be said that $ a^Nb^Nc^{NN} = uvwxy$ with $ \vert vx\vert \geq 1$ and $ \vert vwx\vert \leq N$. If $ i\geq 0$, then $ uv^iwx^iy$ is still a word of the language (this is the pumping lemma for CFL).

Many situations may occur:

The situation where $ v$ and $ x$ are shared between $ a$'s and $ c$'s cannot occur since $ \vert vwyx\vert \leq N$. Since we have a contradiction in each possible situation, we conclude that the language proposed is not regular.


next up previous
Next: Problem 3 - Programming Up: Information Science I Previous: Problem 1 - Operating
Reynald AFFELDT
2000-06-08