GATE / CS ARCHIVE

GATE CSE 2009 / QUESTION 40

Intersection leaves an equal-block prefix

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

GATE 2009, Q40 2 marks · MCQ
Report issue

Context-Free Grammars & Languages

Question 40, GATE 2009: L1={a^m b^m c a^n b^n:m, n≥0}; L2={a^i b^j c^k:i, j, k≥0}; L=L1∩L2. Classify: A not recursive; B regular; C context-free but nonregular; D RE but not context-free.
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

L1 contains exactly one c between am bm and an bn. For membership in L2=a*b*c*, no a or b may follow that c, so n=0. Thus the intersection is{am bm c:m≥0}. A grammar for it is S→Tc, T→aTb|ε. The language is context-free and nonregular: removing its fixed final c by regular right quotient would otherwise make{am bm} regular. Therefore C.

L2 permits only a block of a’s, then b’s, then c’s. A word of L1 has one central c, so its trailing an bn must be empty to fit L2. Thus L={am bm c:m≥0}. The grammar S→Tc and T→aTb|ε proves context-freeness. For nonregularity, removing the final fixed c from a hypothetical finite automaton would recognize the classic nonregular language am bm. Hence C, not the much stronger undecidability alternatives.

Original paper, page 9