Let \(L_1\), \(L_2\) be any two context-free languages and \(R\) be any…

2017

Let \(L_1\)\(L_2\) be any two context-free languages and \(R\) be any regular language. Then which of the following is/are CORRECT?

I.    \(L_1 \cup L_2\) is context-free

II.    \(\overline{L_1}\) is context-free

III.    \(L_1 - R\) is context-free

IV.    \(L_1 \cap L_2\) is context-free

  1. A.

    I, II and IV only

  2. B.

    I and III only

  3. C.

    II and IV only

  4. D.

    I only

Attempted by 87 students.

Show answer & explanation

Correct answer: B

Answer: I and III only.

  • I. L1 ∪ L2 is context-free: True. Context-free languages are closed under union (you can combine grammars or use nondeterministic pushdown automata to accept the union).

  • II. Complement of L1 is context-free: False in general. Context-free languages are not closed under complementation. For example, L = {a^n b^n | n ≥ 0} is context-free but its complement over {a,b}* is not context-free.

  • III. L1 − R is context-free: True. L1 − R = L1 ∩ (complement of R). Regular languages are closed under complement, so complement of R is regular; intersection of a context-free language with a regular language is context-free.

  • IV. L1 ∩ L2 is context-free: False in general. The class of context-free languages is not closed under intersection; for instance, intersecting {a^n b^n c^m} and {a^m b^n c^n} (both context-free) yields {a^n b^n c^n}, which is not context-free.

Therefore the only statements that are always true for arbitrary context-free L1, L2 and regular R are I and III.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Gate Guidance By Sanchit Sir