Proof of closure of context-free languages under union

December 4, 2026 · Team EasyExamNotes · 1 min read (est.) · 0 comments

Share on WhatsApp

← RGPV CS-501 (CBGS) Theory of Computation November 2019 Solved Paper

Question

Let A and B be context-free languages over the same alphabet Σ. Prove that A ∪ B is context-free.

Asked in: CS-501 | November 2019 | 2(b)

Answer

Let G₁ and G₂ generate A and B respectively. Rename their variables so the variable sets are disjoint. Introduce a fresh start variable S and retain all productions of both grammars, adding S→S₁ | S₂.

Every derivation from S chooses one original start variable. Because the variable sets are disjoint, subsequent derivations remain in that grammar. Therefore every generated word belongs to A or B. Conversely every word in either language is generated by selecting its corresponding branch.

Hence L(G)=A∪B and the union is context-free. This construction also preserves ε whenever either original language contains it.

← RGPV CS-501 (CBGS) Theory of Computation November 2019 Solved Paper

Discussion

Ask a question, share your thoughts or report an error.

Sign in to participate in the discussion.

Join the discussion