GATE / CS ARCHIVE

GATE CSE 2013 / QUESTION 32

Regular and unequal-block languages

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

GATE 2013, Q32 2 marks · MCQ
Report issue

Context-Free Grammars & Languages

Question 32, GATE 2013: Let L1={0^p1^q0^r:p, q, r≥0} and L2={0^p1^q0^r:p, q, r≥0, p≠r}. Which is false? A L2 is context-free. B L1∩L2 is context-free. C complement(L2) is recursive. D complement(L1) is context-free but not regular.
Tap to enlarge
Your answer
Answer & solution

Official answer: D

L1=0*1*0* is regular. L2, whose outer zero-block counts differ, is context-free: split into more leading zeros or more trailing zeros and use a pushdown comparison. Since L2⊆L1, their intersection is L2 and context-free. L2 is decidable by finite examination of the block counts (including the possible zero middle block), so its complement is recursive. The complement of regular L1 is regular and consequently context-free. Thus option D, which says this last complement is context-free but not regular, has a false not-regular clause. It is regular and therefore context-free; D is the requested false statement.

For the decisive option D, L1 is represented directly by 0*1*0*, hence is regular. Complement a complete DFA by swapping accepting and nonaccepting states; this proves its complement is regular as well. Being regular implies context-free, but it contradicts the extra words “not regular.” For L2, a pushdown machine can compare the first and final zero blocks when a nonempty middle 1block separates them; the all-zero case can be treated separately. A finite input can also be tested by enumerating its finitely many possible block splits, giving decidability without needing a closed form.

Original paper, page 7 · Answer key