This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: Theory of Computation — CSE 105 Computability Theory Solutions to Selected Problems Turing Machine Design 1. Problem 3.8 (a), Page 148. Give an implementationlevel description of a Turing machine that decides contains an equal number of 0s and 1s . Solution: The idea to solve this problem is that for each 0 or 1 we see at the input tape, we should look for a matching 1 or 0, respectively, and cross both symbols. If the respective symbol is not found (which means the string contains a unequal number of 0s and 1s), then we reject. If all 0s and 1s are matched (which means the contains an number of 0s and 1s), then we accept. So, an informal definition for the Turing machine would be the following: T = “Given a string, s, 1. Read next input symbol different from . 2. If it’s a 0, then cross it and keep reading every symbol to the right until either a 1 or is found. If it’s a 1, then cross it too. If it’s a , then reject . 3. If it’s a 1, then cross it and keep reading every symbol to the right until either a 0 or is found. If it’s a 0, then cross it too. If it’s a , then reject . 4. If it’s a , then accept . 5. Move back to the beginning of the tape and go to step 1.” A formal description of , where: , , , and is given with the state diagram in figure 1. 1 ,R 1 ,R 1,x R 0,x R 1 x,L x,L L 0,1,x x,R 1 x,R R R R R R R x 1 q q 2 q rej q 3 q 4 q acc q R x Figure 1: State diagram for Turing machine Closure Properties 2. Problem 3.15 (part a), Page 149. Show that the collection of recursively enumerable (Turingrecognizable) languages is closed under the union operation. Solution: Given two recursively enumerable languages, A and B, we would like to show that A B is recursively enumerable. Because A is recursively enumerable, there is a Turing machine, T , which will accept a string s if and only if s A. Similarly, there is a machine T which will accept a string s if and only if s B. (T and T will not necessarily halt any input.) Construct a Turing machine T as follows: T = “Given a string, s, 1. Start a counter, i, at 1. 2. Simulate T for i steps on s. If T accepts, accept . 3. Simulate T for i steps on s. If T accepts, accept . 4. Increment i, and return to step 2.” Claim : T accepts a string s if and only if s is in the language A B. 2 Proof : If T accepts s, then s must have either been accepted by T in step 2, or by T in step 3. Thus s A or s B. Thus, s Conversely, if s A B then s A or s B. If s A then A accepts s after a certain number of steps. Call this number k. Then T accepts s when i=k in step 2. Similarly, if s B then B accepts s after some number of steps, k. Thus T accepts s when i=k in step 3. Because we have constructed a Turing machine which accepts A B, the language A B is recursively enu merable....
View
Full
Document
This homework help was uploaded on 02/08/2008 for the course CSE 105 taught by Professor Paturi during the Summer '99 term at UCSD.
 Summer '99
 Paturi

Click to edit the document details