COMS W3261: Computer Science Theory Instructor: Tal Malkin Homework 3 Due: Tuesday, 02/17/15 (at the beginning of class) Reading: Chapters 1.2, 1.3 Important: please start each of the four problems on a new page so they can be submitted separately to make life easier for the TAs Remember to include your name, UNI, and section number on each page of your submission! 1. (a) Show languages S∞ Li (defined for every i = 0, 1, 2, . . .), such that Li is regular for every i, yet i=0 Li is not regular. You may assume without proof that there exists some non-regular language (if it helps you to use a specific one, you can use the fact that {0i 1i : i ≥ 0} is not regular). (b) Given two languages L1 , L2 , we define XOR(L1 , L2 ) = {w|w ∈ L1 \ L2 or w ∈ L2 \ L1 } (i.e., all strings that are in exactly one of the languages). Prove that the class of regular languages is closed under XOR. 2. (a) Give regular expressions generating each of the following languages over {a, b}. i. {w : there is at most one b in w}. ii. {w : w does not end in ba}. iii. {w : w has both aa and aba as substrings}. (b) Use the general transformation we saw to construct an NFA for the language generated by the regular expression (b(b ∪ )b)∗ . 3. For a string w = w1 w2 . . . wn where wi ∈ Σ, we define the reverse of w as wR = wn . . . w2 w1 (namely the string w in reverse order). For a language L we define LR = {wR : w ∈ L}. Prove that for every regular expression α there is a regular expression β of the exact same length |β| = |α|, such that L(β) = (L(α))R . Note that it is not sufficient to prove that regular languages are closed under reversal (which was proved in the last recitation using NFAs). Instead, here you are asked to work with regular expressions and have an extra requirement that the length is preserved. 4. 1.21(b) in the text (NFA to RE conversion). Extra Credit: (Include with Problem 4) For any fixed n, let Σn = {a1 , ..., an }. Define the language Ln = {w ∈ Σ∗n | there is at least one symbol ∈ Σn that does not appear in w}. (Note that on Homework 2, Problem 3b you were asked to prove that L5 is regular). It is not hard to show that for any n, Ln has an NFA with linearly many states O(n) (namely, a constant times n), and a RE of quadratic length O(n2 ) (namely, a constant times n2 ). Now consider the language Ln = {w ∈ Σ∗n | every symbol in Σn appears in w}, namely, the complement of Ln . 1 (a) Argue that every NFA for Ln must have at least 2n states. (b) Conclude that every RE for Ln must be of length at least 2n . This shows that the exponential blow up in the general transformation from an NFA or RE to an NFA or RE for the complement language is inherent. It turns out that in the RE case there is in fact an inherent double exponential blow up. 2

© Copyright 2018