Problem 1
Part a
Let be given by the pumping lemma for CFLs. Choose of length such that . Note that . By the pumping lemma, we can write such that and for all .
- If is a substring of , taking yields a word that is not in .
- If , since . If , take . Otherwise, taking yields a word of the form , where is forced by our choice of and the fact that .
Thus, is not context free.
Part b
Unlabelled arrows are of type . represents . The transition represents every transition of its type where , , and .

Problem 2
Part a
Let be a DFA recognizing . For , let , where
Let
where is the language of . Since regular languages are closed under union, is regular. Suppose such that and . If , it follows that , hence . Conversely, if , can be expressed as such that and , so and hence . Thus, is regular (and hence also context free).
Part b
For context free , is context free.
Let be a context free grammar for a language in CNF (I assume ).
Let be a collection of new non-terminals. For each pair of productions and in , define productions
For each pair of productions and in , define productions
For each production in , define productions
For each pair of productions and in for some , define the production
For each pair of productions and in for some , define the production
For each production in for some , define the production .
Let be the set of newly defined productions. Let .
Claim 25.1.
.
Proof.
Suppose , and be the first letter of . It is clear from the definition of that the derivation tree of must have a chain of non-terminals , where each , or for some , and . Denote the child of not in by . Here’s an example:
For , depending on weather is or , we have or in respectively. If , then , else if , then , where is such that . Let be such that . Similarly, let be such that . Then, we have the derivation
in . It is clear from the derivation tree of that
is a derivation in . Thus, we conclude that is a cyclic shift of a word in .
Suppose . Let be the cyclic shift of such that . Suppose and . Let be the first letter of , so .
Let be the chain of nonterminals in the derivation tree of such that and is a production in . Let the child of which is not be . Set if and if for . Let and be as defined previously. Then, it again holds that
Further, it is evident that and . However, we also have the valid derivation
in . Therefore, .□
Part c
Let .
If were context free, then would be context free, a contradiction. Thus, for regular is not context free in general.
Part d
Every regular language is context free. Thus, by the previous problem, is not context free.
