Closure Properties of Context Free Languages
Closure Properties of Context Free Languages
Context Free Languages (CFLs) are accepted by pushdown automata. Context free languages
can be generated by context free grammars, which have productions (substitution rules)
Properties of Context Free Languages
Union : If L1 ab nd L2 are two context free languages, their union L1 ∪ L2 will also be
context free. For example,
L1 = { anbncm | m >= 0 and n >= 0 } and L2 = { anbmcm | n >= 0 and m >= 0 }
L3 = L1 ∪ L2 = { anbncm ∪ anbmcm | n >= 0, m >= 0 } is also context free.
L1 says number of a’s should be equal to number of b’s and L2 says number of b’s should be
equal to number of c’s. Their union says either of two conditions to be true. So it is also
context free language.
Note: So CFL are closed under Union.
Concatenation : If L1 and If L2 are two context free languages, their concatenation L1.L2
will also be context free. For example,
L1 = { anbn | n >= 0 } and L2 = { cmdm | m >= 0 }
L3 = L1.L2 = { anbncmdm | m >= 0 and n >= 0} is also context free.
L1 says number of a’s should be equal to number of b’s and L2 says number of c’s should be
equal to number of d’s. Their concatenation says first number of a’s should be equal to
number of b’s, then number of c’s should be equal to number of d’s. So, we can create a PDA
which will first push for a’s, pop for b’s, push for c’s then pop for d’s. So it can be accepted
by pushdown automata, hence context free.
Note: So CFL are closed under Concatenation.
Kleene Closure : If L1 is context free, its Kleene closure L1* will also be context free. For
example,
L1 = { anbn | n >= 0 }
L1* = { anbn | n >= 0 }* is also context free.
Note :So CFL are closed under Kleen Closure.