Presentation is loading. Please wait.

Presentation is loading. Please wait.

Theory of Computation Lecture 22: Turing Machines II

Similar presentations


Presentation on theme: "Theory of Computation Lecture 22: Turing Machines II"— Presentation transcript:

1 Theory of Computation Lecture 22: Turing Machines II
Simulation of Ln in T We are going to prove the following theorem: Theorem 5.1: If f(x1, …, xm) is partially computable in Ln, then there is a Post-Turing program that computes f strictly. Proof: Let P be a program in Ln which computes f. We assume that P uses the following variables: X1, …, Xm, Z1, …, Zk, Y. So all in all there are l variables, where l = m + k + 1. Therefore, we can rename the variables as follows (while keeping their order): V1, …, Vl. May 2, 2019 Theory of Computation Lecture 22: Turing Machines II

2 Theory of Computation Lecture 22: Turing Machines II
Simulation of Ln 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 x1 B x2 B … B xm B z1 B z2 B … B zk B y ,  where x1, x2, …, xm, z1, z2 , …, zk, y are the current values of the variables X1, X2, …, Xm, Z1, Z2 , …, Zk, Y (using the original variable names). May 2, 2019 Theory of Computation Lecture 22: Turing Machines II

3 Theory of Computation Lecture 22: Turing Machines II
Simulation of Ln in T An advantage of this system is that the initial tape configuration is already in the correct form: B x1 B x2 B … B xm .  What needs to be done now is to show how to program the effect of each instruction type of Ln in the language T. In the following, we will define some macros that will help us to do this task. May 2, 2019 Theory of Computation Lecture 22: Turing Machines II

4 Theory of Computation Lecture 22: Turing Machines II
Simulation of Ln in T The macro GOTO L has the expansion IF s0 GOTO L // Remember: s0 = B IF s1 GOTO L : IF sn GOTO L May 2, 2019 Theory of Computation Lecture 22: Turing Machines II

5 Theory of Computation Lecture 22: Turing Machines II
Simulation of Ln 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 May 2, 2019 Theory of Computation Lecture 22: Turing Machines II

6 Theory of Computation Lecture 22: Turing Machines II
Simulation of Ln in T The macro MOVE BLOCK RIGHT has the expansion [C] LEFT IF s0 GOTO A0 IF s1 GOTO A1 : IF sn GOTO An [Ai] RIGHT i = 1, 2, …, n PRINT si : LEFT : GOTO C : [A0] RIGHT PRINT B LEFT Example: s3Bs1s2B  s3Bs1s2B  s3Bs1s2s  s3Bs1s2s  s3Bs1s2s  s3Bs1s2s  s3Bs1s1s  s3Bs1s1s  s3Bs1s1s2  s3BBs1s  s3BBs1s2  May 2, 2019 Theory of Computation Lecture 22: Turing Machines II

7 Theory of Computation Lecture 22: Turing Machines II
Simulation of Ln 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. May 2, 2019 Theory of Computation Lecture 22: Turing Machines II

8 Theory of Computation Lecture 22: Turing Machines II
Simulation of Ln 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 May 2, 2019 Theory of Computation Lecture 22: Turing Machines II

9 Theory of Computation Lecture 22: Turing Machines II
Simulation of Ln in T Now we can start simulating the three instruction types in the language Ln by Post-Turing programs. We begin the instruction type Vj  siVj . In order to place the symbol si to the left of the j-th variable on the tape, the values of the variables Vj, …, Vl must all be moved one square to the right to make room. After inserting si the tapehead must go back to the blank at the left of the value of V1 in order to be ready for the next simulated instruction. May 2, 2019 Theory of Computation Lecture 22: Turing Machines II

10 Theory of Computation Lecture 22: Turing Machines II
Simulation of Ln in T Here is the program for the simulation of Vj  siVj: RIGHT TO NEXT BLANK [ l ] MOVE BLOCK RIGHT [ l – j + 1 ] RIGHT PRINT si LEFT TO NEXT BLANK [ j ] May 2, 2019 Theory of Computation Lecture 22: Turing Machines II

11 Theory of Computation Lecture 22: Turing Machines II
Simulation of Ln in T Now we want to show how to simulate Vj  Vj- . The problem here is that if Vj contains the null string, it must be left unchanged. Thus, we move to the blank immediately to the right of the value of Vj. Then we move one step to the left, and if we find another blank there, Vj must contain the null string (indicated by two successive blanks). May 2, 2019 Theory of Computation Lecture 22: Turing Machines II

12 Theory of Computation Lecture 22: Turing Machines II
Simulation of Ln in T Here is the program for the simulation of Vj  Vj- : RIGHT TO NEXT BLANK [ j ] LEFT IF B GOTO C // Vj contains null string MOVE BLOCK RIGHT [ j ] RIGHT GOTO E [C] LEFT TO NEXT BLANK [ j - 1 ] May 2, 2019 Theory of Computation Lecture 22: Turing Machines II

13 Theory of Computation Lecture 22: Turing Machines II
Simulation of Ln in T And finally, here is the program for the simulation of IF Vj ENDS si GOTO L: RIGHT TO NEXT BLANK [ j ] LEFT IF si GOTO C // Vj ends in si GOTO D [C] LEFT TO NEXT BLANK [ j ] GOTO L // Note: transfer all labels from Ln to T [D] RIGHT // Vj could contain null string LEFT TO NEXT BLANK [ j ] May 2, 2019 Theory of Computation Lecture 22: Turing Machines II

14 Theory of Computation Lecture 22: Turing Machines II
Simulation of Ln in T Now we are able to translate any program in the language Ln 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 …  May 2, 2019 Theory of Computation Lecture 22: Turing Machines II


Download ppt "Theory of Computation Lecture 22: Turing Machines II"

Similar presentations


Ads by Google