Unformatted text preview: Johny Nguyen November 9th, 2010 CS 473 Homework 4 Downey Problem 1 Show that L = {anbmcndm  m, n ≥ 1} is not CFL. Proof: Suppose L is context free. Let p be the pumping length of L that is guaranteed to exist by the pumping lemma. Let s = apbpcpdp, which is a member of L. the pumping lemma states that s can be pumped. Let s = uvxyz. Then we consider one of two cases. a. When both v and y contain only one type of alphabet symbol. This can be divided into three sub cases. a. v and y are adjacent letters WLOG, let v = a and y = b, and let s = abcd. uvxy = ab, z = cd uv2xy2 = aabb, z = cd uv2xy2z = aabbcd which is not in L. This is will work for any number of a’s and b’s. Contradiction. b. v and y are not adjacent letters. WLOG let v = a and y = c, and let s = abcd. vxy must be abc, therefore z = d. but vxy > p, which violates the pumping lemma. Contradiction. c. v and y equal each other. WLOG, let v = y = a. Let s = abcd. uvxy = a, z = bcd uv2xy2 = aa, z = bcd uv2xy2z = aabcd which is not in L. This is will work for any number of a’s Contradiction. b. When both v and y contain more than one type of alphabet symbol. If v and y contained more than one symbol, let v = y = ij where i and j are a,b,c,d and i ≠ j. Then uv2xy2z will have ij repeat which will cause letters to be out of order. Contradiction. One of the cases must occur, but each derives a contradiction, therefore L is not a CFL. Problem 2 (a) Show that A = {ambncn  m, n ≥ 0} and B = {anbncm  m, n ≥ 0} are not closed under intersection. A ∩ B = {akbkck  k ≥ 0}. By Example 3.36, A ∩ B is not a CFL. (b) Use part (a) and DeMorgan’s law to show that the class of context
free languages is not closed under complementation. DeMorgan’s Law: For any two sets A and B, Context Free Languages are closed under Union. Therefore, A ∪ B is a context
free language. By DeMorgan’s law, the complement of A ∪ B results in the intersection of two CFL’s, which by part (a) is not a context free language. Therefore, the class of context
free languages is not closed under complementation. . Problem 3 In theorem 4.21 we showed that the language is Turing
recognizable iff some enumerator enumerates it. Why not use the simpler algorithm for the forward direction? E = “Ignore the input. 1. Repeat the following for i = 1, 2, 3, … 2. Run M on si 3. If it accepts, print out si” SOLUTION The potential problem is that M on si may loop forever. If this were to occur, it will not enumerate on all strings of L or print them out. For this reason, we must only run M on a finite amount of times to prevent this looping. Problem 4 Show that the collection of decidable languages is closed under the operation. For any two decidable languages L1 and L2, let M1 and M2 be the TMs that recognize them. (b) We construct TM M’ that recognizes the concatenation. “On input w: 1. Partition w into strings ab. 2. Input a into M1 and b into M2. 3. accept if both M1 and M2 accept, otherwise reject.” It will split w into two different strings, and split them up. If M’ accepts, then we have found a successful split in w. If M’ rejects then there was not a successful split in w. (c) We construct TM M’ that recognizes the star. “On input w: For each way to split w into parts w1w2…wn. 1. Run M1 on wi for i = 1,…, n. 2. If M1 accepts each string, accepts 3. If we have gone through each split without accepting, reject.“ It will split w into every possible way. For each of those splits, if the TM accepts the string, the whole thing will accept. If we go through every possible concatenation without accepting, then it will reject. (d) We construct TM M’ that recognizes the complementation. Let M2 be M1’s compliment. “On input w: 1. Run M2 on w. 2. If M2 rejects, accept. Otherwise reject. For L1, whenever M2 rejects, then the TM that accepts the language will accept. But if the compliment accepts, then the TM that accepts the language will reject. (e) We construct TM M’ that recognizes the intersection. “On input w: 1. Run M1 on w. If it rejects, reject. 2. Run M2 on w. If it rejects, reject. Otherwise accept.” M’ will only accept if M1 and M2 both accept and do not reject. If either reject, then M’ rejects. Problem 5 I. For any two Turing
recognizable languages L1 and L2, let M1 and M2 be the TMs that recognize them. (b) We construct TM M’ that recognizes the concatenation. “On input w: 1. Partition w into strings ab. 2. Run M1 on a. If it halts and rejects, reject 3. Run M2 on b. If it accepts, accept. If it halts and rejects, reject.” The same as problem 4, except here we need to keep track of whether M1 and M2 halts. (c) We construct TM M’ that recognizes the star operation. “On input w: 1. Split w into parts w1w2…wn. 2. Run M1 on wi for all i. If all of them are accepted, accept. If M1 halts and rejects for any wi reject.” If w can be split into parts w1w2…wn, then there is a recognizing path that accepts w in a finite amount of steps (d) We construct TM M’ that recognizes the intersection. “On input w: 1. Run M1 and M2 alternatively on w step by step. If either halts, reject. If both accept, accept.” If M1 and M2 both accept w, then M’ accepts w because the accepting TM arrives to its accepting state after a finite number of steps. II. Are the TM
Recognizable languages, like the Decidable language, closed under complement? No, TM
Recognizable language are not closed under complement Show that the collection of Turing
recognizable languages is closed under the operation. Problem 6 Show that the language is decidable iff some enumerator enumerates the language in lexicographic order. (⇒) Assume we have a TM M that decides a language L. Use M to construct an enumerator E Generate strings in lexicographic order and input each into M. If M accepts, print it. E prints all of the strings of L in lexicographical order. (⇐) We must consider two cases. a. L is a finite language. All finite languages are decidable. b. L is infinite. Let M be a TM. M: “On input w: 1. Enumerate all strings of L in lexicographic order until a string bigger than w appears. 2. If w is in the enumerator, accept. Otherwise reject.” This will make the language decidable. Q.E.D. ...
View
Full
Document
This note was uploaded on 11/29/2010 for the course CSC 873569 taught by Professor Roberts during the Spring '10 term at ASU.
 Spring '10
 Roberts

Click to edit the document details