Question

Let L1L_1 be a regular language and L2L_2 be a context-free language. Which of the following languages is/are context-free?

Choose every correct option
Official answer and solution
Official answer
B, C and D
From
Official GATE 2021 answer key

Solution

Apply Boolean and set-theoretic identities alongside standard closure properties of regular and context-free languages.

Given that L1L_1 is regular and L2L_2 is context-free:

  • Regular languages are closed under complementation, union, and intersection.
  • Context-free languages (CFLs) are closed under union, but are NOT closed under intersection or complementation.
  • The intersection of a regular language and a context-free language is always a context-free language.

Analyze each option:

  • Option A: L1∩L2‾L_1 \cap \overline{L_2}. Because CFLs are not closed under complementation, L2‾\overline{L_2} is not necessarily a CFL. If L1=Σ∗L_1 = \Sigma^*, then L1∩L2‾=L2‾L_1 \cap \overline{L_2} = \overline{L_2}, which need not be context-free. Thus, option A is not necessarily context-free.
  • Option B: L1‾∪L2‾‾\overline{\overline{L_1} \cup \overline{L_2}}. By De Morgan's laws, L1‾∪L2‾‾=L1∩L2\overline{\overline{L_1} \cup \overline{L_2}} = L_1 \cap L_2. Because the intersection of a regular language L1L_1 and a context-free language L2L_2 is always context-free, this language is always context-free. Option B is correct.
  • Option C: L1∪(L2∪L1‾)L_1 \cup (L_2 \cup \overline{L_1}). By associativity and commutativity of union, this simplifies to (L1∪L1‾)∪L2=Σ∗∪L2=Σ∗(L_1 \cup \overline{L_1}) \cup L_2 = \Sigma^* \cup L_2 = \Sigma^*. Since Σ∗\Sigma^* is regular, it is also context-free. Option C is correct.
  • Option D: (L1∩L2)∪(L1‾∩L2)(L_1 \cap L_2) \cup (\overline{L_1} \cap L_2). Using the distributive law of intersection over union:
(L1∩L2)∪(L1‾∩L2)=(L1∪L1‾)∩L2=Σ∗∩L2=L2(L_1 \cap L_2) \cup (\overline{L_1} \cap L_2) = (L_1 \cup \overline{L_1}) \cap L_2 = \Sigma^* \cap L_2 = L_2

Since L2L_2 is given to be context-free, this language is context-free. Option D is correct.

Final answer

B, C, D

The answer is the one in the official GATE answer key. The solution is this site's own explanation.

Source

Paper
GATE 2021 Computer Science and Information Technology - Session 2 (CS2)
Question
22 of 65, printed as CS Q.12
Section
Computer Science and Information Technology

Report an error in this question

GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.