0
6.4kviews
Convert the following CFG to CNF

Convert the following CFG to CNF

S =>aAbB

A =>aA|a

B =>bB|b

1 Answer
1
656views

If we replace A =>a, we would get A =>AA, which would cause a left recursion Hence, we need another production rule to hold the terminal value of „a‟

Let C1 => a

Consider A =>aA

Substituting C1 =>a, we get

A =>C1A which is a CNF

Similarly, let us take C2 =>b

Consider B =>bB

Substituting C2 =>b, we get

B =>C2B which is a CNF

Consider S =>aAbB

Substituting values for C1andC2, we get

S =>C1AC2B

Let C3 =>C1A

Substituting this value, we get

S =>C3C2B

Let C4 => C3C2

Substituting this value, we get

S =>C4B which is a CNF

Please log in to add an answer.