Context-Free Grammars & Languages



Answer & solution
Answer: i, j, k, m≥0 and i+k=j+m (no official key was published)
Let t be the number of uses of S→bSe before S→PQR. Let p,q,r be the numbers of recursive productions used by P,Q,R. Their contributions are P⇒bp cp, Q⇒cq dq and R⇒dr er. Combining them with the outer b/e pairs gives
i=t+p, j=p+q, k=q+r, m=r+t,
where t,p,q,r are nonnegative integers. Adding opposite equations yields the necessary relation i+k=j+m.
To prove sufficiency, assume all four exponents are nonnegative and i+k=j+m. Choose any integer t satisfying max(0,i−j)≤t≤min(i,m), and put p=i−t, q=j−i+t, r=m−t. These parameters are nonnegative and reproduce every exponent, including k=j−i+m. Such a t always exists: i−j≤m follows from k≥0, while i−j≤i follows from j≥0. Thus the equality, together with nonnegativity, is also sufficient.
Its full generated form is bt+pcp+qdq+rer ct, with a trailing block of c symbols after the d/e blocks. For example S⇒bSc⇒bPQRc⇒bcdc is possible, contradicting that the paper's claim that every generated word is in b*c*d*e*. Restricting to words of the claimed block form forces either t=0, or q=r=0 so no d/e lies before the final c. The t=0 case gives i=p,j=p+q,k=q+r,m=r, hence i+k=j+m and j≥i. The other case gives only bi ci, already included in that subset.
Taken literally as string exponents, only zero exponents are meaningful, leaving ε; the language intended by the grammar is not that singleton. This solution uses nonnegative counts, as explicitly printed, and discloses both source differences.