GATE / CS ARCHIVE

GATE CSE 1999 / QUESTION 7

The marked copy language is not context-free

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

GATE 1999, Q7 5 marks · Descriptive
Report issue

Context-Free Grammars & Languages

Question 7, GATE 1999: Prove L={xcx:x∈{0,1}*} is not context-free, where c is a terminal different from 0 and 1.
Tap to enlarge
Shared context

Prove L={xcx:x∈{0,1}*} is not context-free, where c is a terminal different from 0 and 1.

Answer & solution

Answer: A context-free pumping-lemma argument on 0ᵖ1ᵖc0ᵖ1ᵖ yields a contradiction. (no official key was published)

Suppose L were context-free and let p be its pumping length. Choose w=0ᵖ1ᵖc0ᵖ1ᵖ∈L. For any pumping decomposition w=uvxyz, the lemma requires |vxy|≤p, |vy|>0, and uvⁱxyⁱz∈L for every i≥0. We show pumping down (i=0) always fails.

If v or y contains c, removing v and y removes the unique separator. The result cannot be in L.

Otherwise c is not pumped. If vxy lies entirely on one side of c, pumping down shortens only that copy. The two sides have unequal lengths, so cannot be equal.

The remaining case is that vxy spans c, with c inside the unpumped substring x. Because |vxy|≤p, everything it can reach to the left of c is in the first block of ones, and everything to the right is in the second block of zeros: it cannot reach the first zeros or the final ones, each separated by a whole length-p block. Thus v=1ᵃ and y=0ᵇ, allowing a or b to be zero, but a+b>0. Pumping down leaves 0ᵖ1p−ac0p−b1ᵖ. Equality of the two copies would force both a=0 (compare ones) and b=0 (compare zeros), contrary to |vy|>0.

Every allowable decomposition fails the lemma, so L is not context-free. The argument relies on a genuine copy xc x, not the context-free reversed-copy language xc xᴿ.

Original paper, page 7