Greibach Normal Form conversion

December 4, 2026 · Team EasyExamNotes · 1 min read (est.) · 0 comments

Share on WhatsApp

← RGPV CS-501 (CBGS) Theory of Computation November 2019 Solved Paper

Question

Convert the grammar to GNF: A₁ → A₂A₃; A₂ → A₃A₁ | b; A₃ → A₁A₂ | a.

Asked in: CS-501 | November 2019 | 3(b)

Answer

Assume A₁ is the start symbol. Substitute A₁→A₂A₃ into A₃, giving A₃→A₂A₃A₂ | a. Substitute A₂→A₃A₁ | b into that rule: A₃→A₃A₁A₃A₂ | bA₃A₂ | a.

Eliminate immediate left recursion with a new variable R. Let β range over bA₃A₂ and a. Then A₃→β | βR and R→A₁A₃A₂ | A₁A₃A₂R. This uses one or more repetitions of A₁A₃A₂ when R is present.

For a compact specification of the final productions, define the finite set U={bA₃A₂, a, bA₃A₂R, aR}. Write A₃→u for every u∈U. Next define V={b}∪{uA₁ : u∈U}; write A₂→v for every v∈V. Finally define W={vA₃ : v∈V}; write A₁→w for every w∈W.

For each w∈W add R→wA₃A₂ | wA₃A₂R. These set-based production lists are finite and every alternative begins with a terminal followed only by variables. Hence the result is in GNF. Each substitution and the left-recursion elimination preserves the generated language.

← RGPV CS-501 (CBGS) Theory of Computation November 2019 Solved Paper

Discussion

Ask a question, share your thoughts or report an error.

Sign in to participate in the discussion.

Join the discussion