Closure Properties of CFLs
San Skulrattanakulchai
March 27, 2019
Closure Properties of CFL’s
- Theorem. The CFLs are closed under union, concatenation, and Kleene closure.
- Theorem. If \(A\) is a CFL and \(B\) is a regular language, then \(A\cap B\) is a CFL.
- In the rest of this handout let \(\Sigma=\{a, b, c\}\).
- Lemma. The language \(E = \{ w \in\Sigma^*: |w|_a = |w|_b = |w|_c \}\) is not a CFL.
Proof. Suppose it were. Then \(F = E\cap L(a^*b^*c^*)\) would be a CFL. But \(F = \{a^nb^nc^n : n\ge0\}\) and we have already seen that \(F\) is not a CFL, a contradiction. \[\tag*{$\Box$}\]
More Theorems
- Theorem. The CFLs are not closed under intersection.
Proof. This is because \(E\) is the intersection of 2 CFLs: \[
E = \{\,w\in\Sigma^*:|w|_a = |w|_b\,\} \cap \{\,w\in\Sigma^*:
|w|_b = |w|_c\,\}.
\] To show the RHS languages are CFL’s, we can use either PDAs or CFGs. \[\tag*{$\Box$}\]
- Theorem. The CFLs are not closed under complement.
Proof. \(E\) is the complement of the CFL \[
\overline{E} =
\{ w\in\Sigma^*: |w|_a \ne |w|_b\,\} \cup \{\, w\in\Sigma^*:
|w|_b \ne |w|_c\}.
\] To show the RHS languages are CFL’s, note that \(i\ne j\) means \(i<j\) or \(i>j\). \[\tag*{$\Box$}\]
- Another way to prove the above theorem is to note that the language \[\verb|SQ| = \{ww : w \in\{a,b\}^*\}\] is not context-free; however, its complement is.