GATE / CS ARCHIVE

GATE CSE 2021 SET 1 / QUESTION 1

GATE CSE 2021 Set 1 Q1

Theory of Computation · Closure Properties & Language Hierarchy · Full GATE CSE 2021 Set 1 paper

GATE 2021 Set 1, Q1 1 mark · MCQ
Report issue

Closure Properties & Language Hierarchy

Question 1, GATE 2021: L1 is regular and L2 is context-free. Which language need NOT be context-free? A L1∩L2; B L1·L2 (concatenation); C L1−L2; D L1∪L2.
Tap to enlarge
Your answer
Answer & solution

Official answer: C

CFLs are closed under intersection with regular languages, concatenation with regular languages, and union with regular languages. They are not closed under complement, so choosing regular L1=Σ* makes L1−L2 the complement of a CFL, which need not be context-free. For a concrete witness, the complement of the non-context-free copy language {ww} is context-free; using that complement as L2 yields the non-CFL {ww}. Thus C.

A simpler explicit counterexample to closure under difference uses Σ={a,b,c}. Define L2=Σ*\{an bn cn:n≥0}. This is context-free: strings outside a*b*c* form a regular language; inside that regular pattern, unequal a/b counts or unequal b/c counts form a union of CFLs, each checkable by a PDA. With regular L1=Σ*, L1−L2 is the standard non-CFL {an bn cn}. For A, run the DFA alongside the PDA; for B,D, use standard CFL concatenation/union constructions because regular languages are also CFLs.

Original paper, page 12 · Answer key