Skip to content
Official PYQ · 2021

GATE CS 2021 Set 2 Q12 — Regular and Context-free Languages

Explain with AI

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

Select all correct options
View worked solution

Answer: B;C;D

Given that L1L_1 is a regular language and L2L_2 is a context-free language (CFL).

  • Option A: L1∩L2‾L_1 \cap \overline{L_2}. Since CFLs are not closed under complementation, L2‾\overline{L_2} is not necessarily a CFL. If we choose L1=Σ∗L_1 = \Sigma^*, then L1∩L2‾=L2‾L_1 \cap \overline{L_2} = \overline{L_2}, which may not be a CFL. Thus, this is not always context-free.
  • Option B: L1‾∪L2‾‾\overline{\overline{L_1} \cup \overline{L_2}}. Applying De Morgan's laws, this simplifies to L1∩L2L_1 \cap L_2. Since the intersection of a regular language and a CFL is always a CFL, this language is always context-free.
  • Option C: L1∪(L2∪L2‾)L_1 \cup (L_2 \cup \overline{L_2}). Since L2∪L2‾=Σ∗L_2 \cup \overline{L_2} = \Sigma^*, the expression simplifies to L1∪Σ∗=Σ∗L_1 \cup \Sigma^* = \Sigma^*. Since Σ∗\Sigma^* is regular, it is also context-free.
  • Option D: (L1∩L2)∪(L1‾∩L2)(L_1 \cap L_2) \cup (\overline{L_1} \cap L_2). Factoring out L2L_2 using the distributive law gives (L1∪L1‾)∩L2=Σ∗∩L2=L2(L_1 \cup \overline{L_1}) \cap L_2 = \Sigma^* \cap L_2 = L_2. Since L2L_2 is a CFL, this language is always context-free.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Regular and Context-free Languages questions