Вы находитесь на странице: 1из 9

Theory of Computation Chapter 8 Turing Machine

Exercise 8.1.1: Give reduction from the hello-world problem to each of the problem below. Use the informal style of this section for describing plausible program transformations, and do not worry about the real limits such as maximum file size or memory size that real computer impose. a) Given a program and an input, does the program eventually halt; i.e., does the program not loop forever on the input?

The construction makes problem P with Pp as input and problem Q with Pq as input have consistent yes/no answer.

Theory of Computation Chapter 8 Turing Machine

b) Given a program and input, does the program ever produce any output?

The construction makes problem P with Pp as input and problem Q with Pq as input have consistent yes/no answer.

Theory of Computation Chapter 8 Turing Machine

c) Given two programs and an input, do the programs produce the same output for the given input?

The construction makes problem P with Pp as input and problem Q with Pq as input have consistent yes/no answer.

Theory of Computation Chapter 8 Turing Machine 8.2.2 Notation for the Turing Machine

Exercise: How does the Turing Machine work?

Theory of Computation Chapter 8 Turing Machine ID: Instantaneous Description We shall use the string x1 x 2 xi 1 qxi xi +1 x n to represent an ID in which 1. q is the state of Turing machine. 2. The tape head is scanning the ith symbol from the left. 3. x1 x 2 x n is the portion of the tape between the leftmost and rightmost nonblank. We describe moves of a Turing Machine M = (Q, , , , q 0 , B, F ) by the notation. * will be used to indicate 0 move, one or more moves of the TM. Suppose (q, xi ) = ( p, Y , L) . Then x1 x 2 xi 1 qxi xi +1 x n x1 x 2 pxi 1Yxi +1 x n 1. If i =1 then TM moves to the blank to the left of x1 . In that case, the ID are: qx1 x 2 xi 1 xi xi +1 x n pBYx2 xi 1 xi xi +1 x n 2. If i = n and Y=B, then the ID are: x1 x 2 xi 1 xi xi +1 qx n x1 x 2 xi 1 xi xi +1 px n 1 Exercise: Suppose (q, xi ) = ( p, Y , R ) . Then x1 x 2 xi 1 qxi xi +1 x n x1 x 2 xi 1Ypxi +1 x n 1. If i =n then TM moves to the blank to the left of x1 . In that case, the ID are: ( x1 x 2 xi 1 xi xi +1 qx n x1 x 2 xi 1 xi xi +1 YpB ) 2. If i = 1 and Y=B, then the ID are:

( qx1 x 2 xi 1 xi xi +1 x n px 2 xi 1 xi xi +1 px n 1 )

Theory of Computation Chapter 8 Turing Machine Exercise: State q0 q1 q2 q3 q4 0 ( q1 ,X,R) ( q1 ,0,R) ( q 2 ,0,L) 1 ( q 2 ,Y,L) X ( q 0 ,X,R) Y ( q3 ,Y,R) ( q1 ,Y,R) ( q 2 ,Y,L) ( q3 ,Y,R) B ( q 4 ,B,R) -

Figure 8.9 A Turing machine to accept { 0 n1n | n 1 } Show the IDs of the Turing machine of the above figure if the input tape contains: a) 00

b) 000111

c) 00111

Theory of Computation Chapter 8 Turing Machine

Transition diagram for TM Example 8.3

There is a goal for each state: State q0: Check a 0, mark as X; Go to q1. (q0 000111 X q1 00111) State q1: skip 0 and Y until check a 1, mark as Y. Go to q2. (X q1 00111 X0 q2 0 Y11) State q2: skip 0 and Y until check a X; Go to q0. (X0 q2 0 Y11 X q0 00Y11) State q3: from q0, if no more 0; skip Y till check a B. (XXX q3 YYYXXXY q3 YY) State q4: accepting state.

Theory of Computation Chapter 8 Turing Machine

Library project for the week 04/05 04/09 Submit your answer to Blackboard in MS Word file. Homework is not graded, but quiz will test if you do the homework. Draw the transition diagram for multiplication TM demonstrated in http://www.warthman.com/ex-turing.htm. You can use the software paint (start-> programs -> accessories->paints) for drawing. Dictate the goal for each state. Sol: (See file 06_TM_sol.doc)

A more complicated example--Example 8.4 Proper Subtraction m n = max( m n,0) m n m-n input string 0 | 0 0 m n
.

4.2 = 2 B B B B B B B

0 B B B B B B

0 0 0 B B B B

0 0 0 0 0 B 0

0 0 0 0 0 0 0

1 1 1 1 1 1 B

0 0 0 0 B B B

0 0 B B B B B

B B B B B B B

2-4 = -2 2 4 = max( 2,0) = 0 B 0 0 1 B B 0 1 B B 0 1 B B B 1 B B B 1 B B B B

0 0 0 0 0 B

0 0 0 0 0 B

0 0 0 B B B

0 0 B B B B

B B B B B B

Theory of Computation Chapter 8 Turing Machine

Exercise: Design the Turing machine for Proper Subtraction m n = max( m n,0) . M = ({q 0, q1, q 2, q3, q 4, q5, q 6, q 7, q8}, {0,1}, {0,1, B}, , q 0 , B, q8) Transition table: q0 q1 q2 q3 q4 q5 q6 q7 q8 Exercise: Exercise 8.2.2 Design Turing machines for the following languages: The set of strings with an equal number of 0s and 1s { a nb nc n | n 1} 0 (q1, B, ) 1 (q6,B, ) B -.

Вам также может понравиться