GATE Computer ScienceHardGATE CS (PYQ pattern)

L₁ is context-free, L₂ is regular and L₃ is deterministic context-free (all over the same alphabet Σ, complements taken w.r.t. Σ*). Which of the following is NOT necessarily context-free?

  1. A. (L₁ ∪ L₃) − L₂
  2. B. (complement of L₃) ∩ L₂
  3. C. (complement of L₁) ∪ L₂
  4. D. L₁ · (L₃)*

Correct answer: C. (complement of L₁) ∪ L₂

(L₁ ∪ L₃) − L₂ = (CFL) ∩ (complement of L₂, regular): CFL. Complement of a DCFL is a DCFL, and ∩ regular stays DCFL. CFLs are closed under concatenation and star. But (complement of L₁) ∪ L₂ = complement of (L₁ ∩ complement L₂), the complement of an arbitrary CFL, which need not be context-free (take L₂ = ∅).

More Theory of Computation questions

Exams that ask this topic