← RGPV CS-501 (CBGS) Theory of Computation November 2019 Solved Paper
Question
Find Chomsky Normal Form for the CFG: S → ABA; A → aA | ε; B → bB | ε.
Asked in: CS-501 | November 2019 | 3(a)
Answer
All three variables are nullable. Introduce a fresh start T. Removing ε-productions while retaining ε at T yields S→ABA | AB | BA | AA | A | B; A→aA | a; B→bB | b; T→S | ε.
Eliminate unit productions by copying non-unit alternatives of A and B into S, then copying S alternatives into T. S is now unnecessary because it occurs nowhere on a right-hand side.
Introduce X→a, Y→b and C→BA. The final CNF is:
T→AC | AB | BA | AA | XA | YB | a | b | ε
A→XA | a
B→YB | b
C→BA
X→a
Y→b
Every rule has two variables or one terminal, except the permitted start ε-rule. T never occurs on a right-hand side. The grammar preserves a*b*a*, including ε.
← 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