Context-free languages can manage one nested dependency well. That is why they are good at patterns such as .
Intersection can force two independent dependencies to hold at the same time. In the standard counterexample, one language requires the -block and -block to match, while the other requires the -block and -block to match.
Their intersection therefore requires all three blocks to match:
This is beyond what one pushdown automaton can handle. A useful memory aid is: intersection would force two stacks, and CFLs only have one.
Examples
Complement need not be infinite
The statement that the complement of every context-free language is always infinite is false.
Let . This language is context-free.
Its complement with respect to is
which is finite.
Therefore, the complement of a context-free language is not necessarily infinite.
Finite complement
Every language with finite complement is context-free.
Let be a language such that is finite. Then is regular, because every finite language is regular.
Regular languages are closed under complement. Hence is regular.