GATE / CS ARCHIVE

GATE CSE 2017 SET 2 / QUESTION 4

GATE CSE 2017 Set 2 Q4

Theory of Computation · Closure Properties & Language Hierarchy · Full GATE CSE 2017 Set 2 paper

GATE 2017 Set 2, Q4 1 mark · MCQ
Report issue

Closure Properties & Language Hierarchy

Question 4, GATE 2017: Let L1,L2 be arbitrary context-free languages and R an arbitrary regular language. Which claims always hold? I:L1∪L2 is context-free. II:complement(L1) is context-free. III:L1−R is context-free. IV:L1∩L2 is context-free. A:I,II,IV. B:I,III. C:II,IV. D:I only.
Tap to enlarge
Your answer
Answer & solution

Official answer: B

1. I holds: take disjoint copies of the two grammars and add a new start production S→S1|S2. The resulting CFG generates their union.

2. III also holds because L1−R=L1∩complement(R). Regular languages are closed under complement, and a PDA for L1 can be combined with a finite automaton for complement(R). Thus the intersection remains context-free.

3. IV fails in general: {an bn cm} and {am bn cn} are CFLs, but their intersection {an bn cn} is not. II cannot hold for all CFLs either, since closure under both complement and union would imply intersection closure by De Morgan's law. Only I and III are guaranteed, B.

Original paper, page 3 · Answer key