What is the CFG of the complement of L={ww|w belongs to {0,1}*}?
First of all observe the fact that any odd word is part of the language. Let's define the following languages:
L1={w1w|w{0,1}*}, L0={w0w|w{0,1}*}.
These languages can be defined with the following CFG:
Now look at L3:
It is context free from closure to union and concatenation.
Let's prove that L3 is the language we're looking for. First of all as we have seen it deals with all possible odd length words. As for the even length words, if they are in the language, there is one pair of terminals, at least, which is different on both sides of the word. Call this pair a and b. Every even word can be divided like this:
and this is exactly
This implies that CFG languages are not closed under complement.