Converting CFG to Chomsky-Normal-Form?

105 Views Asked by At

After removing $\epsilon$-productions and unit-productions of a grammar I obtain the following transformed CFG:

$S\rightarrow aAa|bBb|\epsilon|aa|bb$
$A\rightarrow a$
$B \rightarrow b$.

Now for a grammar to be in CNF it has to satisfy $S\rightarrow\epsilon$ if $\epsilon \in L(G)$, $A \rightarrow BC$ or $A \rightarrow a$.

Now using these rules I've transfored the grammar to:

$S \rightarrow CA|DB|\epsilon|AA|BB$
$A \rightarrow a$
$B \rightarrow b$
$C \rightarrow AA$
$D \rightarrow BB$

Now the question is, is this grammar in Chomsky-Normal-Form or am I missing something obvious?