Skip to content
UoL CS Notes

Closure Properties of Context-Free Languages

COMP218 Lectures

Union

The union of two CFLs:

\[L_1\cup L_2\]

is context free.

In general, for two context free languages $L_1$ and $L_2$ with start variables $S_1$ and $S_2$ the grammar of the union can be represented as:

\[S\rightarrow S_1\vert S_2\]

Where all other productions are kept the same.

Concatenation

The concatenation of two CFLs:

\[L_1L_2\]

is context free.

In general, for two context free languages $L_1$ and $L_2$ with start variables $S_1$ and $S_2$ the grammar of the concatenation can be represented as:

\[S\rightarrow S_1S_2\]

Kleene Star

The star operation of a CFL:

\[L^*\]

is context free.

In general the star operation of a language can be represented as:

\[S_1\text{ (new start variable)}\\ S_1\rightarrow SS_1\vert \epsilon\]

Intersection

The intersection of two CFLs:

\[L_1\cap L_2\]

is not necessarily context free.

Complement

The complement of a CFL:

\[\bar L\]

is not necessarily context free.