511 views
Convert the given CFG to GNF.

$S \rightarrow MN$
$M\rightarrow aMb|\epsilon$
$N\rightarrow aNb|\epsilon$
| 511 views
+1

@Utkarsh  , Please check it :-

S ---> aB | aMB | aNB | aMBANB | ɛ

M ----> aB | aA1B

N -----> aB | aA2B

A1 ----> aA1B |aB

A2 -----> aA2B | aB

A  ----> a

B ------> b

0

I don't think $\epsilon$ would be there since it will be eliminated when we convert into CNF.

S-> MN

M->aMb | $\epsilon$

N-> aNb | $\epsilon$

Remove $\epsilon$ by substitution, we get

S-> MN

M->aMb | ab

N-> aNb | ab

S-> aBN | aMBN

M->aMB | aB

N-> aNB | aB

B-> b

+1

ϵ  is in the language ..So,it can't be eliminated..In CNF ,  ϵ is also allowed when language contains empty string ..

https://gateoverflow.in/188159/chomskey-normal-form

0

ankitgupta.1729 why $A_{1}$ and $A_{2}$

0
by the way language for this grammar is

L = $a^{n}b^{n}a^{m}b^{m} ; m,n \geq0$
0
@Utkarsh ,Can u please tell me any string which is generated by your grammar and not by my grammar ?
0
i'm not saying its wrong just asking that is there any need of variables A1 and A2
0

@Utkarsh , yes , I think I have taken extra A1 and  A2 ...we can replace it by M and N

+1
yeah it seems correct otherwise.

Although, @Tuhin Dutta is quite right in his approach. I would just like to add something.

The initial steps involving the conversion (CFG to GNF) actually mention that the UNIT & NULL productions must be removed before the final conversion.

So, I guess that the 'ϵ' would not stay in the final result.

To summarize, here is the solution:

In Step-2, I think the substitution method (to eliminate 'ϵ') will also be applied to 'S' because of which we'll have more number of symbols in the final GNF form.

Different sources tell different methods of doing this conversion so, I'm open to any critical evaluation.