Practice free →
HomeGATE CSEcomputerscienceTheory of Computation › Context-free languages are CLOSED under which of…

Context-free languages are CLOSED under which of the following operations?

AUnion, concatenation, Kleene star
BIntersection and complement only
CSet difference
DNone of the above
Answer & Solution
Correct answer: A. Union, concatenation, Kleene star
1. CFL closure properties: - UNION: yes. Given $G_1, G_2$, build $G = G_1 \cup G_2$ with new start $S \to S_1 \mid S_2$. - CONCATENATION: yes. New rule $S \to S_1 S_2$. - KLEENE STAR: yes. New rule $S \to S_1 S \mid \varepsilon$. 2. NOT closed: - INTERSECTION: $L_1 = \{a^n b^n c^k\}$ and $L_2 = \{a^k b^n c^n\}$ are both CFL, but $L_1 \cap L_2 = \{a^n b^n c^n\}$ is NOT CFL. - COMPLEMENT: a consequence of the above (since $A \cap B = \overline{\overline{A} \cup \overline{B}}$). 3. EXCEPTION: CFL intersected with a REGULAR language IS a CFL. This is useful for combining grammars with regex filters. 4. Options B, C, D misstate. _Source: Jeff Erickson, "Models of Computation", §5.12 (Closure of CFLs)._
Solve this in the app — GATE CSE practice & 24k+ MCQs →
Related questions