66.8k views
1 vote
Convert the given grammar to CNF:

S --> aAD
A --> aB | bAB
B --> b
D --> d

1 Answer

3 votes

Final answer:

To convert the given grammar to CNF, introduce new non-terminals for terminal symbols and break down longer productions into binary rules. The result involves several new rules including S → XA | YA and A → XB | YB, with X and Y representing the terminal symbols a and b, respectively.

Step-by-step explanation:

To convert the given grammar to Chomsky Normal Form (CNF), we need to ensure that all production rules adhere to one of these forms: either A → BC, where A, B, and C are non-terminal variables (and B and C aren't the start variable), or A → a, where A is a non-terminal and a is a terminal symbol.

If a production contains only a single non-terminal symbol on the right-hand side, that is also allowed as it's considered to be in CNF. The given grammar is: S → aAD, A → aB | bAB, B → b, D → d. To convert it to CNF, follow these steps:Introduce new non-terminals for terminal symbols in the rules with more than two symbols on the right-hand side. Break down rules with more than two non-terminals on the right-hand side into binary rules.

The conversion results in: S → XA | YA, A → XB | YB, B → b, D → d, X → a, Y → b, XA → XD, YA → AB. Now, all the production rules are in CNF. We introduced new variables X and Y to represent the terminals. We modified the rule S → aAD to two rules S → XA and XA → XD. Similarly, we replaced A → aB | bAB with A → XB | YB and YA → AB.

User Vikingsteve
by
8.2k points