95.1k views
1 vote
Show all steps and label each step for possible full credit. A full explanation must acoompany the written steps for passible full crediL 1. Convert the following CFG into Chomsky Normal Form using the method demonstrated in lecture:

G={{S,A,B,C,D},{a,b,d},S,P} where P is the fallouing
S⟶aABDλ
A⟶BC∣a
B⟶Bb∣b∣λ
C⟶CD∣λ
D⟶d


User AmShaegar
by
8.8k points

1 Answer

6 votes

Answer:

To convert the given context-free grammar (CFG) into Chomsky Normal Form (CNF), we need to follow the following steps:

Step 1: Eliminate the start symbol from the right-hand side of the productions.

We can eliminate the start symbol S from the right-hand side of the first production by introducing a new non-terminal symbol S' and a new production S'⟶S.

So, the new productions are:

S'⟶S

S⟶aABDλ

A⟶BC∣a

B⟶Bb∣b∣λ

C⟶CD∣λ

D⟶d

Step 2: Eliminate λ-productions.

The non-terminal symbol B generates λ, so we need to add new productions to eliminate λ-productions.

The new productions are:

B⟶Bb∣b∣bB'

B'⟶B∣λ

So, the new set of productions are:

S'⟶S

S⟶aABDλ

A⟶BC∣a

B⟶Bb∣b∣bB'

B'⟶B∣λ

C⟶CD∣λ

D⟶d

Step 3: Eliminate unit productions.

The non-terminal symbol A generates B and C, so we can replace A with B and C in the production S⟶aABDλ.

The new productions are:

S'⟶S

S⟶aBCDλ∣aBDλ∣aBD∣aCD∣aC∣aD∣aB∣a

A⟶BC∣a

B⟶Bb∣b∣bB'

B'⟶B∣λ

C⟶CD∣λ

D⟶d

Step 4: Convert productions to CNF.

The new productions are:

S'⟶S

S⟶aBCDλ∣aBDλ∣aBD∣aCD∣aC∣aD∣aB∣a

A⟶BC∣a

B⟶BB1∣b∣bB'

B'⟶B∣λ

C⟶CC1∣λ

D⟶d

B1⟶b

C1⟶CD

The resulting CFG is in Chomsky Normal Form (

User Aaron Gong
by
9.3k points