Regular Expressions & Languages


Answer & solution
Answer: C (no official key was published)
1. Interpret S,A,B as states tracking the number of a symbols modulo 3: a advances S→A→B→S, while b leaves the state unchanged. Terminating production S→b ends with residue 0, and B→a also ends with residue 0.
2. Consequently every generated word has #a divisible by 3. Conversely any nonempty word with that property can be scanned along these transitions; if its last symbol is b it terminates via S→b, and if its last symbol is a it terminates via B→a.
3. Thus L={w in {a,b}^+ : #a(w)≡0 mod3}, option C in the stated positive-word universe.
4. Teaching check: There is no ε production, so the empty word is excluded despite having zero a symbols. The problem explicitly uses {a,b}^+, which resolves that apparent exception. Each a advances one of three residue states while any b preserves it.