Download Introduction to Computational Complexity - Solutions to Homework 3 | CS 530 and more Assignments Computer Science in PDF only on Docsity! CS530: Introduction to Computational Complexity Homework 3 Oct 28th, 2008 Problem 1: Give pseudocode for the Turing machine that accepts the following lan- guage: L = {xxrw | x โ ฮฃ+, w โ ฮฃ+}. Here ฮฃ = {a, b, c}. Then draw the diagram of the Turing machine. Solution 1: The pseudocode is as following: Algorithm 1 TM1 1: Mark the last unmarked character on the tape as END 2: if There is no unmarked characters then 3: Reject w 4: Compare teh first character without any mark with the last character before a marked character 5: if Matching then 6: Marking the two characters as CROSS 7: Go to (2) 8: if There is no unmarked characters then 9: Accept w 10: else 11: Clear all the CROSS marks. 12: Go to (1) a,b,c โ> R B, END โ> L a,b,cโ> END(a,b,c),L a,b,c โ> L CROSS(a,b,c)โ> R a,b,c โ> Stay aโ> CROSS(a),R bโ>CROSS(b),R cโ>CROSS(c),R a,b,cโ>R a,b,c โ>R a,b,cโ>R END(a,b,c)โ>L CROSS(a,b,c)โ>L END(a,b,c)โ>L CROSS(a,b,c)โ>L END(a,b,c)โ>L CROSS(a,b,c)โ>L aโ>CROSS(a),L bโ>CROSS(b),L cโ>CROSS(c),L a,b,cโ>L CROSS(a,b,c)โ>R a,b,cโ>Stay Problem 2: Without directly using Rice Theorem, prove that the following language is not decidable. L = {ใMใ | M is a Turing machine and the size of L(M) can be divided by 3}. Proof: Assume that there exists a TM R decides L. Now we construct a TM S decides ATM = {ใM, wใ | 3-1 M accepts w}. S = input ใM,wใ 1. construct a TM M2 input: a TM ใT ใ if size of L(T ) can not be diveded by 3, accept. else run M on w, if M accepts w, accept 2. Run R on ใM2ใ if R accepts it, then accept, else reject it. Clearly, S is a decider for ATM . However, ATM is not recursive as we have already know. Thus there is a contradiction. So L is not decidable. Problem 3: Which of the following languages is undecidable? Give proofs of your answer. You can use Rice Theorem whenever you can to say a language is not decidable. 1. L = {ใMใ | M is a Turing machine and the size of L(M) can be divided by 3}. 2. L = {ใMใ | M is a Turing machine and M has at most 75 states}. 3. L = {ใM1,M2ใ | M1 and M2 are Turing machines and L(M1) โฉ L(M2) = โ
}. 4. L = {ใMใ | M is a Turing machine and L(M) is recursive}. Solution 3: 1. There are three languages can not be decided. They are: (a) L = {ใMใ | M is a Turing machine and the size of L(M) can be divided by 3} (b) L = {ใM1,M2ใ | M1 and M2 are Turing machines and L(M1) โฉ L(M2) = โ
}. (c) L = {ใMใ | M is a Turing machine and L(M) is recursive}. Proof: We use Rice Theorem to proof these three languages are not decidable. By Rice Theorem, to prove language is not decidable, we only need to prove that the property of that language is non-trivial. For that the property of all these three languages are not trivial, thus they are all undecidable. 2. There is only one language can be decided. It is: (a) L = {ใMใ | M is a Turing machine and M has at most 75 states}. Proof: For that we only need to check that the size of Q is 75 or not, which can be done at most 75 steps. So we can decide this language. Problem 4: Prove that Turing machines as a generator is equivalent to Turing machines as acceptor. Here a TM G as a generator produces a language L(G), if it will print all strings of L(G) on the tape (here the printer will not go backward when printing). In other words, you have to prove 1. Given a generator G, there is always a TM M such that L(M) = L(G), and 2. Given a TM M , there is always a generator G, such that L(M) = L(G). Proof: 1. In this part, we proof that given a generator G, there is always a TM M such that L(M) = L(G). Given a generator G, we construct the TM M in the following way: TM M = input w: (a) Lineary compare w with all the strings generated by G. (b) If matching, then accept. 3-2