Question

Suppose that L1L_1 is a regular language and L2L_2 is a context-free language. Which one of the following languages is NOT necessarily context-free?

Choose one option
Official answer and solution
Official answer
C
From
Official GATE 2021 answer key

Solution

Apply closure properties of context-free languages under set operations.

Let L1L_1 be regular and L2L_2 be context-free (CFL). We evaluate each option:

  • Option A: L1∩L2L_1 \cap L_2. The intersection of a regular language and a CFL is always a CFL. (True)
  • Option B: L2−L1=L2∩L1‾L_2 - L_1 = L_2 \cap \overline{L_1}. Because L1L_1 is regular, its complement L1‾\overline{L_1} is also regular. The intersection of a CFL with a regular language is always a CFL. (True)
  • Option D: L1∪L2L_1 \cup L_2. The union of two CFLs (noting that every regular language is a CFL) is always a CFL. (True)

Now consider Option C: L1−L2=L1∩L2‾L_1 - L_2 = L_1 \cap \overline{L_2}. CFLs are not closed under complementation. If we choose L1=Σ∗L_1 = \Sigma^* (which is regular), then L1−L2=Σ∗−L2=L2‾L_1 - L_2 = \Sigma^* - L_2 = \overline{L_2}.

Since the complement of a CFL is not necessarily context-free, L1−L2L_1 - L_2 is NOT necessarily context-free. Hence, option C is the correct answer.

Final answer

C

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 (CS, Set-1)
Question
11 of 65, printed as CS Q.1
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.