← RGPV CD-501 Theory of Computation December 2024 Solved Question Paper
Question
Construct a CFG for L(G)={aⁿbᵐcᵐd²ⁿ | n≥0, m>0}.
Asked in: CD-501 | December 2024 | 3(b)
Answer
The grammar must match each a with two d symbols and each b with one c, while keeping the b and c blocks nonempty. Choose variables S,T and terminals a,b,c,d.
Productions: S→aSdd | T; T→bTc | bc. Each use of the first S rule introduces one a and two d symbols. The rule S→T ends this recursion. Each use of T→bTc adds a matched pair, while T→bc guarantees at least one pair.
For n=1,m=2: S⇒aSdd⇒aTdd⇒abTcdd⇒abbccdd. For n=0,m=1: S⇒T⇒bc. For n=2,m=1: S⇒aSdd⇒aaSdddd⇒aaTdddd⇒aabcdddd.
Soundness follows by induction on the number of recursive rule applications: every generated string has the required block order and counts. Completeness follows by choosing exactly n applications of S→aSdd and m−1 applications of T→bTc, then the terminating rules. Thus the grammar generates precisely the requested language.
← RGPV CD-501 Theory of Computation December 2024 Solved Question Paper
Discussion
Ask a question, share your thoughts or report an error.
Sign in to participate in the discussion.
Join the discussion