Closure Property of Context-Free Languages
Theorem 8.3 — Closure Properties of CFLs
The family of context-free languages is closed under union, concatenation, and star-closure.
That is,
If are context-free languages, then
-
is context-free.
-
-
is context-free.
Proof
Let
be two context-free grammars generating and respectively.
Without loss of generality, assume that
—that is, the two grammars use disjoint sets of variables.
1. Closure under Union
Construct a new grammar
where
That is, is a new start variable not in
So, contains all the productions of both grammars plus one extra production:
Now, any derivation in begins with either or .
-
If , then
-
If , then
Hence,
Since is a CFG, the union of two CFLs is a CFL.
2. Closure under Concatenation
Construct
where
Thus, generates strings where something from is followed by something from :
with and
Hence,
So, CFLs are closed under concatenation.
3. Closure under Kleene Star
Let
where
Now the grammar can either:
-
Produce a string from and then repeat the process (), or
-
Stop ().
Thus, it generates any finite concatenation of strings from :
Therefore, CFLs are closed under the Kleene star operation.
✅ Conclusion
We have constructed context-free grammars for each of the three operations. Therefore:
🧩 Additional Note
CFLs are not closed under certain operations such as:
-
Intersection
-
Complement
-
Difference
This is an important distinction—while regular languages are closed under all Boolean operations, context-free languages are not.
Comments
Post a Comment