CFG for strings with at least two a symbols

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

Share on WhatsApp

← RGPV CS-501 Theory of Computation November 2023 Solved Paper

Question

Specify a CFG as a four-tuple (V,T,P,S) over {a,b} for strings containing at least two a symbols.

Asked in: CS-501 | November 2023 | 6(b)(i)

Answer

G=(V,T,P,S), V={S,X}, T={a,b}, P={S→XaXaX, X→aX|bX|ε}. X generates any string over the alphabet; the two explicit a symbols ensure the required minimum. Conversely split any qualifying string at its first two a symbols to obtain the three X substrings.

← RGPV CS-501 Theory of Computation November 2023 Solved Paper

Discussion

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

Sign in to participate in the discussion.

Join the discussion