GATE / CS ARCHIVE

GATE CSE 1997 / QUESTION 11(a)

Characterize a block grammar

Theory of Computation · Context-Free Grammars & Languages · Full GATE CSE 1997 paper

GATE 1997, Q11(a) 3 marks · Descriptive
Report issue

Context-Free Grammars & Languages

Question 11(a), GATE 1997: Use the GFG grammar with start symbol S:
S → bSe | PQR
P → bPc | ε
Q → cQd | ε
R → dRe | ε.
Terminals are b,c,d,e. Generated words are b^i c^j d^k e^m with nonnegative integer exponents. GateForum instead prints S→bSc and mistakenly gives nonpositive exponents; those literal variants must be distinguished.
What condition on i,j,k,m characterizes the generated language?
Question 11(a), GATE 1997: Use the GFG grammar with start symbol S:
S → bSe | PQR
P → bPc | ε
Q → cQd | ε
R → dRe | ε.
Terminals are b,c,d,e. Generated words are b^i c^j d^k e^m with nonnegative integer exponents. GateForum instead prints S→bSc and mistakenly gives nonpositive exponents; those literal variants must be distinguished.
What condition on i,j,k,m characterizes the generated language?
Question 11(a), GATE 1997: Use the GFG grammar with start symbol S:
S → bSe | PQR
P → bPc | ε
Q → cQd | ε
R → dRe | ε.
Terminals are b,c,d,e. Generated words are b^i c^j d^k e^m with nonnegative integer exponents. GateForum instead prints S→bSc and mistakenly gives nonpositive exponents; those literal variants must be distinguished.
What condition on i,j,k,m characterizes the generated language?
Tap to enlarge
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.

Original paper, page 7