CNF and GNF
CNF and GNF
CNF and GNF
S bA -------(1)
SaB -------(2)
AbAA ----(3)
AaS ----(4)
A a ----(5)
B aBB ----(6)
BbS ----(7)
Bb ----(8)
S bA-------(1)
C1 b
S C1A
SaB -------(2)
C2 a
S C2B
AaS ----(4)
A C2S
BbS ----(7)
BC1S
AbAA ----(3)
A C1AA
B aBB ----(6)
B C2BB
AbAA ----(3)
D AA
AC1 D
B aBB ----(6)
EBB
BC2E
A a ----(5)
Bb ----(8)
C 1 b
S C1A
C 2 a
S C2B
A C2S
BC1S
A C1AA
B aBB ----(6)
B C2BB
A3 A2 A3 A2 ---------(3)
A3 A3 A1 A3 A2 -------(3a)
A3 b A3 A2-------------(3b)
Lemma 4.4
Let G =(V,T,P,S) be the context free grammar CFG
Let A A1|A2|A3.. Ar be the set of A-productions for which
A is the leftmost symbol of the right-hand side.
Let A 1|2|3.|s be the remaining A-productions.
Let G1= (V {B}, T,P1,S} be the context free grammar formed by adding
the variable B to V and replacing all the A-productions:
1) Ai
A iB Where 1 =< i <= s
2) B i
B iB where 1 =< i <= r
Then L(G) = L(G1)
Now replace A2 in A1 A2 A3
production
A1
A1
A1
A1
A1
aA1 A3-------(10)
b A3 A2 A1 A3-------(11)
b A3 A2 B A3-------(12)
aBA1 A3-------(13)
b A3-------(14)
A3 a ---------(1)
A3 b A3 A2-------(2)
A3 b A3 A2 B-------(3)
A3 a B-------(4)
A2 aA1-------(5)
A2 b A3 A2 A1-------(6)
A2 b A3 A2 BA1-------(7)
A2 aBA1-------(8)
A2 b-------(9)
Now replace A2 in A1 A2 A3
production
A1 aA1 A3-------(10)
A1 b A3 A2 A1 A3-------(11)
A1 b A3 A2 B A3-------(12)
A1 aBA1 A3-------(13)
A1 b A3-------(14)
B aA1 A3 A3 A2
B b A3 A2 A1 A3 A3 A2
B b A3 A2 B A3 A3 A2
B aBA1 A3 A3 A2
B b A3 A3 A2
B aA1 A3 A3 A2 B
B b A3 A2 A1 A3 A3 A2 B
B b A3 A2 B A3 A3 A2 B
B aBA1 A3 A3 A2 B
B b A3 A3 A2 B