Presentation is loading. Please wait.

Presentation is loading. Please wait.

December 1, 2009Theory of Computation Lecture 21: Turing Machines II 1 Simulation of L n in T We will now construct a Post-Turing program Q that simulates.

Similar presentations


Presentation on theme: "December 1, 2009Theory of Computation Lecture 21: Turing Machines II 1 Simulation of L n in T We will now construct a Post-Turing program Q that simulates."— Presentation transcript:

1 December 1, 2009Theory of Computation Lecture 21: Turing Machines II 1 Simulation of L n in T We will now construct a Post-Turing program Q that simulates P step by step. Of course, the information available to Q must be put onto the tape. Therefore, we have to use a system for storing the values of all variables at certain positions on the tape: B x 1 B x 2 B … B x m B z 1 B z 2 B … B z k B y,  where x 1, x 2, …, x m, z 1, z 2, …, z k, y are the current values of the variables X 1, X 2, …, X m, Z 1, Z 2, …, Z k, Y (using the original variable names).

2 December 1, 2009Theory of Computation Lecture 21: Turing Machines II 2 Simulation of L n in T An advantage of this system is that the initial tape configuration is already in the correct form: B x 1 B x 2 B … B x m.  What needs to be done now is to show how to program the effect of each instruction type of L n in the language T. In the following, we will define some macros that will help us to do this task.

3 December 1, 2009Theory of Computation Lecture 21: Turing Machines II 3 Simulation of L n in T The macro GOTO L has the expansion IF s 0 GOTO L// Remember: s 0 = B IF s 1 GOTO L : IF s n GOTO L

4 December 1, 2009Theory of Computation Lecture 21: Turing Machines II 4 Simulation of L n in T The macro RIGHT TO NEXT BLANK has the expansion [A]RIGHT IF B GOTO E GOTO A The macro LEFT TO NEXT BLANK has the expansion [A]LEFT IF B GOTO E GOTO A

5 December 1, 2009Theory of Computation Lecture 21: Turing Machines II 5 Simulation of L n in T The macro MOVE BLOCK RIGHT has the expansion [C]LEFT IF s 0 GOTO A 0 IF s 1 GOTO A 1 : IF s n GOTO A n [A i ]RIGHTi = 1, 2, …, n PRINT s i : LEFT: GOTO C: [A 0 ]RIGHT PRINT B LEFT Example: s 3 Bs 1 s 2 B  s 3 Bs 1 s 2 s 2  s 3 Bs 1 s 2 s 2  s 3 Bs 1 s 2 s 2  s 3 Bs 1 s 1 s 2  s 3 BBs 1 s 2 

6 December 1, 2009Theory of Computation Lecture 21: Turing Machines II 6 Simulation of L n in T The macro ERASE A BLOCK has the expansion [A]RIGHT IF B GOTO E PRINT B GOTO A This program causes the head to move to the right, erasing everything between its initial position and the first blank to its right.

7 December 1, 2009Theory of Computation Lecture 21: Turing Machines II 7 Simulation of L n in T We introduce another convention: A number in square brackets after the name of a macro indicates how many times the macro expansion is to be inserted into the program. For example, MOVE BLOCK RIGHT [4] is short for MOVE BLOCK RIGHT MOVE BLOCK RIGHT MOVE BLOCK RIGHT MOVE BLOCK RIGHT

8 December 1, 2009Theory of Computation Lecture 21: Turing Machines II 8 Simulation of L n in T Now we can start simulating the three instruction types in the language L n by Post-Turing programs. We begin the instruction type V j  s i V j. In order to place the symbol s i to the left of the j-th variable on the tape, the values of the variables V j, …, V l must all be moved one square to the right to make room. After inserting s i the tapehead must go back to the blank at the left of the value of V 1 in order to be ready for the next simulated instruction.

9 December 1, 2009Theory of Computation Lecture 21: Turing Machines II 9 Simulation of L n in T Here is the program for the simulation of V j  s i V j : RIGHT TO NEXT BLANK [ l ] MOVE BLOCK RIGHT [ l – j + 1 ] RIGHT PRINT s i LEFT TO NEXT BLANK [ j ]

10 December 1, 2009Theory of Computation Lecture 21: Turing Machines II 10 Simulation of L n in T Now we want to show how to simulate V j  V j -. The problem here is that if V j contains the null string, it must be left unchanged. Thus, we move to the blank immediately to the right of the value of V j. Then we move one step to the left, and if we find another blank there, V j must contain the null string (indicated by two successive blanks).

11 December 1, 2009Theory of Computation Lecture 21: Turing Machines II 11 Simulation of L n in T Here is the program for the simulation of V j  V j - : RIGHT TO NEXT BLANK [ j ] LEFT IF B GOTO C// V j contains null string MOVE BLOCK RIGHT [ j ] RIGHT GOTO E [C]LEFT TO NEXT BLANK [ j - 1 ]

12 December 1, 2009Theory of Computation Lecture 21: Turing Machines II 12 Simulation of L n in T And finally, here is the program for the simulation of IF V j ENDS s i GOTO L: RIGHT TO NEXT BLANK [ j ] LEFT IF s i GOTO C// V j ends in s i GOTO D [C]LEFT TO NEXT BLANK [ j ] GOTO L// Note: transfer all labels from L n to T [D]RIGHT// V j could contain null string LEFT TO NEXT BLANK [ j ]

13 December 1, 2009Theory of Computation Lecture 21: Turing Machines II 13 Simulation of L n in T Now we are able to translate any program in the language L n into a corresponding program in T. There is only one thing that needs to be fixed: After the program terminates, we want only the string y to remain on the tape as the program’s output. This can be done by appending the following code to our generated T program: ERASE A BLOCK [ l – 1 ] This will erase the values of the first l – 1 variables on the tape, so only the last variable will remain and the final tape configuration will be … B B B y B B B … 

14 December 1, 2009Theory of Computation Lecture 21: Turing Machines II 14 Simulation of T in L The next thing we want to prove is the following: Theorem 6.1: If there is a Post-Turing program that computes the partial function f(x 1, …, x m ), then f is partially computable. Since our definition of partial computability is based on the language L, this theorem states the following: If the m-ary partial function f on A* is computed by a program of T, then there is a program of L that computes f (using base n values of strings).

15 December 1, 2009Theory of Computation Lecture 21: Turing Machines II 15 Simulation of T in L Based on Theorem 6.1 and also Theorems 3.2 and 5.1, we can derive another Theorem: Theorem 6.2: Let f be an m-ary partial function on A*, where A is an alphabet of n symbols. Then the following conditions are all equivalent: 1. f is partially computable; 2. f is partially computable in L n ; 3. f is computed strictly by a Post-Turing program; 4. f is computed by a Post-Turing program. The fact that there are so many equivalent notions of computability constitutes important evidence for the correctness of Church’s Thesis.

16 December 1, 2009Theory of Computation Lecture 21: Turing Machines II 16 Simulation of T in L For the proof of Theorem 6.1, let us now consider an m-ary partial function on N. Corollary 6.3: For any n, l  1, an m-ary partial function f on N is partially computable in L n if and only if it is also partially computable in L l. Proof: Each of these conditions is equivalent to the function f being partially computable.

17 December 1, 2009Theory of Computation Lecture 21: Turing Machines II 17 Simulation of T in L Considering the language L 1, we have: Corollary 6.4: Every partially computable function is computed strictly by some Post-Turing program that uses only the symbols s 0 and s 1. Proof: This follows immediately from the fact that we can simulate L n in T, as shown before.

18 December 1, 2009Theory of Computation Lecture 21: Turing Machines II 18 Simulation of T in L Now let P be a Post-Turing program that computes f. We want to construct a program Q in the language L that computes f. Q will consist of three sections: BEGINNINGMIDDLEEND The MIDDLE section will simulate P in a step-by-step “interpretive” manner. The BEGINNING section will arrange the input to Q in the appropriate format for MIDDLE. The END section will extract the output.

19 December 1, 2009Theory of Computation Lecture 21: Turing Machines II 19 Simulation of T in L Let f be an m-ary partial function on A*, where A = {s 1, …, s n }. The Post-Turing program P will also use the blank B and perhaps other symbols s n+1, …, s r (we are not assuming that the computation is strict). We write the symbols that P uses in the following order: s 1, …, s n, s n+1, …, s r, B. The program Q will simulate P by using the numbers that strings on this alphabet represent in base r + 1 as “codes” for the corresponding strings.

20 December 1, 2009Theory of Computation Lecture 21: Turing Machines II 20 Simulation of T in L Note that we will write the blank as s r+1 instead of s 0. The current tape configuration will be kept track of by Q using three numbers stored in the variables L, H, and R. H will contain the numerical value of the symbol currently being scanned by the head. L will contain a number that represents in base r + 1 a string of symbols w such that the tape contents to the left of the head consists of infinitely many blanks followed by w. R will contain a number that represents in a similar manner the string of symbols to the right of the string.

21 December 1, 2009Theory of Computation Lecture 21: Turing Machines II 21 Simulation of T in L Example: Consider the following tape configuration for r = 3 (so we will use base 4): … B B B s 1 s 3 s 2 B s 1 s 2 B B B …  Obviously, H = 2. L = 1·4 + 3 = 7 R = 4·4 2 + 1·4 + 2 = 70 (remember that B = s r+1 )

22 December 1, 2009Theory of Computation Lecture 21: Turing Machines II 22 Simulation of T in L We are now able to simulate all of the instruction types of T by programs of L. As usual, we will specify how to simulate each type of instruction. An instruction PRINT s i is simulated in L by H  i An instruction IF s i GOTO L is simulated in L by IF H = i GOTO L

23 December 1, 2009Theory of Computation Lecture 21: Turing Machines II 23 Simulation of T in L An instruction RIGHT is simulated in L by L  CONCAT r+1 (L, H) H  LTEND r+1 (R) R  LTRUNC r+1 (R) IF R  0 GOTO E R  r + 1// if R = 0, then there is a blank // (s r+1 ) to the right of the head

24 December 1, 2009Theory of Computation Lecture 21: Turing Machines II 24 Simulation of T in L An instruction LEFT is simulated in L by R  CONCAT r+1 (H, R) H  RTEND r+1 (L) L  RTRUNC r+1 (L) IF L  0 GOTO E L  r + 1// if L = 0, then there is a blank // (s r+1 ) to the left of the head

25 December 1, 2009Theory of Computation Lecture 21: Turing Machines II 25 Simulation of T in L Now the MIDDLE section of Q can be generated by replacing each instruction in P by its simulation. When we write BEGINNING and END, we must consider the following: f is an m-ary function on {s 1, …, s n }*. Thus the initial values of X 1, …, X m for Q are numbers that represent the input strings in base n. However, the computations in Q assume a base r + 1 representation of the input strings.

26 December 1, 2009Theory of Computation Lecture 21: Turing Machines II 26 Simulation of T in L Fortunately, we have Theorem 1.1 of Chapter 5, which tells us that the functions UPCHANGE n,l and DOWNCHANGE n,l are computable. Now we can develop the BEGINNING section. Its task is to calculate the initial values of L, H, and R, which represent the initial tape configuration B x 1 B x 2 B … B x m,  where the numbers x 1, …, x m are represented in base n notation.


Download ppt "December 1, 2009Theory of Computation Lecture 21: Turing Machines II 1 Simulation of L n in T We will now construct a Post-Turing program Q that simulates."

Similar presentations


Ads by Google