Context-Free Grammars & Languages


Shared context
Grammar S→aSAb | ε and A→bA | ε, with start S, generates strings aⁱbʲ, i,j≥0.
Answer & solution
Answer: (i,j)=(0,0), or i≥1 and j≥i. (no official key was published)
1. Every application of S→aSAb adds one a at the front and one mandatory b at the end, with an A that can generate any additional number of b symbols.
2. After i recursive applications and S→ε, the form is aⁱ(Ab)ⁱ. Thus j=i+k₁+⋯+kᵢ for arbitrary nonnegative integers k₁,…,kᵢ.
3. If i≥1, this gives j≥i. Every such j is attainable by assigning j−i extra b symbols to one A and zero to all the others.
4. If i=0, S goes directly to ε and there are no A symbols, so j must also be zero. The looser answer j≥i incorrectly includes nonempty strings consisting only of b.