Conversion into GNF of a given language

165 Views Asked by At

Consider the language

$$\{a^ib^jc^k\mid i+j=k\geq1 \}$$

How many number of productions are there into GNF of grammar representing ?


My attempt:

I have converted it into equivalent Context free grammar:

$S →aSc\mid A\mid ac$

$A →bAc\mid bc$

But, I stuck here, how to proceed for GNF.

Can you explain it, please?

1

There are 1 best solutions below

1
On BEST ANSWER

There is more than one way to construct an equivalent context-free grammar in GNF from a context-free grammar.

In this case, the solution is quite simple, once we notice that the only problem lies in the production rule $S \rightarrow A$, and that the natural way to fix it is to replace it with $S \rightarrow b A$. Then, of course, we have to change also the rules of $A$, i.e. $A \rightarrow b A c \mid c$. Finally, we can introduce a new variable $C$ with the single rule $C \rightarrow c$ and replace the occurrences of $c$ with $C$ in the other production rules.

The equivalent grammar in GNF is thus $$\begin{align*} S & \rightarrow a S C \mid b A \mid a C \\ A & \rightarrow b A C \mid c \\ C & \rightarrow c\end{align*}$$