# CFL Closure Property

Context-free languages are **closed** under −

- Union
- Concatenation
- Kleene Star operation

## Union

Let L_{1} and L_{2} be two context free languages. Then L_{1} ∪ L_{2} is also context free.

### Example

Let L_{1} = { a^{n}b^{n} , n > 0}. Corresponding grammar G_{1} will have P: S1 → aAb|ab

Let L_{2} = { c^{m}d^{m} , m ≥ 0}. Corresponding grammar G_{2} will have P: S2 → cBb| ε

Union of L_{1} and L_{2}, L = L_{1} ∪ L_{2} = { a^{n}b^{n} } ∪ { c^{m}d^{m} }

The corresponding grammar G will have the additional production S → S1 | S2

## Concatenation

If L_{1} and L_{2} are context free languages, then L_{1}L_{2} is also context free.

### Example

Union of the languages L_{1} and L_{2}, L = L_{1}L_{2} = { a^{n}b^{n}c^{m}d^{m} }

The corresponding grammar G will have the additional production S → S1 S2

## Kleene Star

If L is a context free language, then L* is also context free.

### Example

Let L = { a^{n}b^{n} , n ≥ 0}. Corresponding grammar G will have P: S → aAb| ε

Kleene Star L_{1} = { a^{n}b^{n }}*

The corresponding grammar G_{1} will have additional productions S1 → SS_{1} | ε

Context-free languages are **not closed** under −

**Intersection**− If L1 and L2 are context free languages, then L1 ∩ L2 is not necessarily context free.**Intersection with Regular Language**− If L1 is a regular language and L2 is a context free language, then L1 ∩ L2 is a context free language.**Complement**− If L1 is a context free language, then L1’ may not be context free.