I am working on the following problem and I do make a little progress.
Let me state the question first: Prove that the set of strings consisting of $a$'s and $b$'s with an equal number of $a$'s and $b$'s, but not containing the substring $aab$ is context free.
The following is what I have tried so far. Now, intuitiviely, this language defines strings without consecutive two a's except for the end of the string.
For example: $ababababaaaa \in L$ and $babbab \in L$.
The grammar is:
S->C|Sa
C->Bab|CC|aB
B->BB|b
But then, I realize that I should have use closure property to solve this problem. Because the intersection of a regular language and a context free language is context free. I would appreciate if you can help me with the proof using closure property. Thanks ahead!!!
Let $A = \{a,b\}$ be the alphabet. Let $E = \{u \in \{a,b\}^* \mid |u|_a = |u|_b\}$ and let $K = A^* - A^*aabA^*$. You certainly know that $E$ is context-free and that $K$ is regular. Now $L = E \cap K$ and thus $L$ is context-free.