Consider the context-free grammar below
where and are non-terminals, and and are terminal symbols. The starting non-terminal is .
Which one of the following statements is
GATE CSE 2023Theory of Computation › Context-Free Languages & Pushdown AutomataVerified
(B) The language generated by G G G is a ∗ ( a + b ) b ∗ a^{\ast}(a+b) b^{\ast} a ∗ ( a + b ) b ∗
Determine the language generated by X first, then substitute it into S's recursive production S -> aSb | X. X generates any nonempty string of the form $a^m b^n$. Wrapping such a string with k layers of a...b from S yields all nonempty strings of the form $a^*b^*$, which matches option B.
The grammar generates exactly the nonempty strings consisting of zero or more a's followed by zero or more b's. This is the regular expression $a^*(a+b)b^*$, so option B is correct.
Reviewed by GateIQ Editorial Team: IIT & IISc Alumni.