What is the safest order while simplifying Context Free Grammar?

2022

What is the safest order while simplifying Context Free Grammar?

  1. A.

    Elimination of 𝜀-productions, Unit productions and then Useless symbols \& productions.

  2. B.

    Elimination of useless symbols \& productions, 𝜀-productions and then Unit productions.

  3. C.

    Elimination of Unit productions, 𝜀-productions and then Useless symbols and productions.

  4. D.

    Elimination of 𝜀-productions, Useless symbols and productions and then Unit productions.

Attempted by 144 students.

Show answer & explanation

Correct answer: A

Correct order: Eliminate ε-productions, then eliminate unit productions, then remove useless symbols and productions.

  • Step 1 — Eliminate ε-productions: Remove all null (ε) productions by identifying nullable variables and adding productions that account for omitting nullable variables. Preserve the ability for the start symbol to produce ε only if the original grammar allowed it.

  • Step 2 — Eliminate unit productions: Replace chains of single-variable productions (A → B) by directly adding A → α for every non-unit production B → α. This removes unit chains while preserving generated strings.

  • Step 3 — Remove useless symbols and productions: First remove non-generating symbols (those that cannot derive any terminal string), then remove unreachable symbols (those not reachable from the start symbol). Doing this last avoids deleting symbols that earlier steps might make necessary.

Why this order is safest: Eliminating ε-productions first prevents ε-removal from reintroducing unit productions after you thought you had removed them. Eliminating unit productions next ensures chains are resolved after any new units appear from ε-elimination. Finally, removing useless symbols and productions last ensures you do not accidentally discard symbols that become useful as a result of the earlier transformations.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Mppsc Assistant Professor