4.1 Problem 6 Note that the symmetric difference between L1 and L2 can be expressed in terms of basic set operations. In particular we have that the symmetric difference of S1 and S2 is equal to, (S1 - S2) union (S2 - S1) since we have that for any sets A and B (A - B) = (A intersect ~B) where ~B is the complement of B, we can write the symmetric difference as (S1 intersect ~S2) union (~S1 intersect S2) Since regular languages is closed under set intersection, set union, and set complementation, we see that the symmetric difference of two regular languages must be regular since it can be expressed in terms of these operations. ************************* 4.1 Problem 17: TAIL(L) = {y : xy \in L for some x \in Sigma*} In other words, TAIL(L) is the set of all suffixes of strings in L. For example, if L = ab*, then TAIL(L) = ab* + b*. If L=a*b, then TAIL(L) = a*b. We want to show that if L is regular, then TAIL(L) is regular. To show this we will show how to convert a DFA for L into an NFA for TAIL(L). Showing that TAIL(L) is regular. Let the DFA for L be M = (Q, Sigma, delta, q0, F). To construct an NFA for TAIL(L) let Q' be the set of all states that can be reached from q0 by some path in the M. That is, Q' = {q : delta*(q0,w) = q, for some w \in Sigma*} Construct the NFA N by starting with M and then drawing a lambda transition from q0 to each state in Q'. The result will that L(N)=TAIL(L). To see this note that if M is able to accept a string xy then there must be a path from q0 to some other state q in Q' that reads x and then from q to a final state that reads y. This means that N will be able to take a lambda transition from q0 to q and then read in y ending in a final state. Thus N accepts y as it should. This shows that any string in TAIL(L) will be accepted by N. We now need to argue that any string accepted by N will also be in TAIL(L). Consider a string y accepted by N. If y is accepted without traversing an initial lambda transition then y would have been accepted by M and hence y is in L and hence is also in TAIL(L) (since L is a subset of TAIL(L)). In the case that y was accepted after traversing an initial lambda transition to state q and then reading in y on a path from q to a final state. By the construction of N, we know that there is a path from q0 to q. Let x be the string corresponding to the labels along the path from q0 to q. This shows that xy is a string that could be accepted by M and hence xy is in L, proving that y is in TAIL(L). So we have shown both that TAIL(L) is a subset of L(N) and L(N) is a subset of TAIL(L), which implies that L(N) = TAIL(N) showing that TAIL(L) is regular. ************************* 4.1 Problem 25: Min(L) = {w \in L : there is no u in L, v in Sigma^+, such that w = uv} In other words, MIN(L) is the set of strings in L such that no proper prefix of those strings is in L. For example, if L = ab*, then MIN(L) = {a}. If L = a*b, then MIN(L) = a*b. If L=a*b*, MIN(L) = lambda. Let the DFA for L be M = (Q, Sigma, delta, q_0, F). We construct MIN(L) as M' = (Q, Sigma, delta', q_0, F). For any a \in Sigma, and state q \in Q - F, delta(q.a) = delta'(q, a). For any a \in Sigma, and state q \in F, delta'(q,a) = Empty. (We cut off all arc coming out of final states.) Since M' has a subset of arcs than those in M, the walks that reach the final states of M' are a subset of those that reach the the final states in M. So L(M') is a subset of L(M). Since there are no arcs from any final state of M', if there is a string w accepted by M', then there are no final states of M' (or M) on the walk labeled w from its initial state to the final state. This means that if w in L(M') then (w is in L(M)=L and) no proper prefix of w is in L. Hence w is in MIN(L). Similarly, if w is in MIN(L), then it is in L and no proper prefix of w is in L. Hence, there should not be any final states in the walk traced by w in the machine M. This means that all the edges traversed by the walk labeled w are also in M'. So w is accepted by M'. So MIN(L) is L(M') for an NFA M'. Hence MIN(L) is regular. *********************** 4.2 Problem 14 An algorithm to determine if a regular language contains an infinite number of even length strings: 1. Let M be a DFA that accepts a regular language L over an alphabet Sigma. 2. Let E = (Sigma^2)^* be the set of all even length strings over Sigma. Let M' be a DFA that accepts E. 3. Now construct a cross product DFA D that accepts L \intersection E. (Use the cross-product construction for intersection languages). 4. Say `yes' if there is a cycle in D on a path from some initial state to some final state; otherwise say `no'. Proof: The last condition is met iff L(D) is infinite. L(D) consists of all even length strings in L. So the algorithm says `yes' if and only if there are infinitely many even length strings in L. 4.3 problem 4c L = {a^n b^l a^k: n = l or l =/= k} The trick here is to choose a w such that it is easy to derive a contradiction. Since a string is in L if either of the two conditions is satisfied, to derive a contradiction, both conditions must be violated. So we pick a string where one of the conditions (2'nd one) is already violated. Then pumping is only required to destroy the first condition. So we choose w = a^m b^m a^m, where m is the pumping lemma constant. Note that w is in L because n = l = m (although l = k = m, violating the second condition). The adversary splits this into xyz so that |xy| <= m and |y| >= 1. This means that x and y can only have a's in them. Let y = a^j (j>=1). By pumping lemma, xy^iz will have to be in L for any i. Let i = 2. xy^iz = a^{m+j} b^m a^m. This violates the two conditions n=l and l =/= k in the definition of L; so it cannot be in L. We reached a contradiction, and therefore L is not regular. ****************************** 4.3 problem 4d L = {a^nb^l : n <= l} Assume that L is regular for the sake of contradiction and let m be the pumping constant. Consider the string w = a^mb^m. We know that w is in L and |w| >= m, so the Pumping Lemma applies to w. This means that for some decomposition w = xyz, where |xy| <= m, and |y| > 0 that w_i = xy^iz is in L for any i >= 0. Since |xy| <= m we know that xy contains only a's and hence y contains only a's. In particular since y is not empty we know that for some integer q > 0 that y = a^q. Now consider w_2 which is obtained by replicating y in the string w giving an extra q a's at the beginning of w. We have that w_2 = xy^2z = a^(m+q)b^m which is clearly not in L since the number of a's is greater than the number of b's. However, the Pumping Lemma says that w_2 is in L, which is a contradition. This shows that L is not regular. ****************************** 4.3 problem 5d L = {a^n : n = 2^k for some k >= 0}. Let m be the Pumping Lemma constant. Choose the string a^{2^m} which must be in L. Let a^{2^m} be split into xyz by the adversary so that |xy| <= m and |y| > =1. Let |y| = k, so that 1 <= k <= m. Choose i = 2. w_i = x y^2 z = a^{2^m + k}. Note that m < 2^m for any m >= 0. 2^m + k <= 2^m + m < 2^m + 2^m = 2^{m+1} Hence, 2^m < 2^m + k < 2^{m+1} So the length of w_i is in between 2^m and 2^{m+1} and hence cannot be a power of 2. But w_i must be in L according to the P.L. Hence L cannot be regular. ********************************* 4.3 Problem 12 L = {a^nb^kc^(n+k) : n >= 0, k >= 0} Assume that L is regular and let m be the pumping constant. Consider the string w = a^mb^mc^(2m). Since w is in L and |w| >= m we know that the Pumping Lemma applies to w. So w=xyz where |xy| <= m and |y| > 0. This implies that y contains only a's. Let q > 0 be the number of a's in y so that y = a^q. Consider the string w_0 = xy^0z = xz. Since w_0 is just a version of w with y removed we know that it will be equal to w_0 = a^(m-q)b^mc^(2m) Clearly since the sum of the number of a's and b's does not equal the number of c's we see that w_0 is not in L. However, the Pumping Lemma says that w_0 is in L giving a contradiction. Thus, L must not be regular. ********************************* 4.3 Problem 16 L = {w1 c w2: w1, w2 \in {a,b}*, w1 =/= w2}. We will use closure properties and pumping lemma to show that this language is not regular. Suppose L is regular. Let L' represent the complement of L with respect to {a,b,c}*. L' \intersection a*ca* = {w1 c w2 : w1, w2 \in {a}*, w1 = w2}. = a^nca^n Call the above language L1. Since L is regular, its complement L' is regular. And its intersection with another regular language a*ca* is also regular. So L1 is regular. Now we show L1 is not regular using Pumping Lemma. Let m be the Pumping Lemma constant. Choose the string a^mca^m. The adversary splits it as xyz, where |xy| <= m, and |y| = k >= 1. Since |xy| <= m, x's and y's only consist of a's. Setting i =0, we get that a^{m-k}ca^m is in L1. But this contradicts the definition of L1. So our initial assumption that L is regular must be wrong.