sample problems and soln3

# Introduction to the Theory of Computation

This preview shows pages 1–4. Sign up to view the full content.

Theory of Computation — CSE 105 Computability Theory Solutions to Selected Problems Turing Machine Design 1. Problem 3.8 (a), Page 148. Give an implementation-level 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

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
0 ,R 1 ,R 1,x R 0,x R 1 x,L 0 x,L L 0,1,x 0 x,R 1 x,R R R R R R R x 1 q 0 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 (Turing-recognizable) 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. 3. Problem 3.15 (b), Page 149. Show that the collection of recursively enumerable (Turing-recognizable) languages is closed under the concatenation operation.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern