Download presentation
Presentation is loading. Please wait.
Published byJette Lange Modified over 5 years ago
1
Theory of Computation Lecture 21: Turing Machines II
Post-Turing Programs Example 3: We want to compute a function f(x1, x2, x3), where A = {s1, s2}, x1 = 0, x2 = s2s1s2, and x3 = 0. Then the initial tape configuration is as follows: B B s2 s1 s2 B Notice that it is impossible to distinguish this initial tape configuration from that with two inputs x1 = 0 and x2 = s2s1s2. Therefore, the number of arguments must be provided externally. November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
2
Theory of Computation Lecture 21: Turing Machines II
Post-Turing Programs Now let us look at the execution of a very simple T program. The arrow in the program indicates the next instruction to be executed. PRINT s1 LEFT PRINT s2 B x November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
3
Theory of Computation Lecture 21: Turing Machines II
Post-Turing Programs Now let us look at the execution of a very simple T program. The arrow in the program indicates the next instruction to be executed. PRINT s1 LEFT PRINT s2 LEFT s1 x November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
4
Theory of Computation Lecture 21: Turing Machines II
Post-Turing Programs Now let us look at the execution of a very simple T program. The arrow in the program indicates the next instruction to be executed. PRINT s1 LEFT PRINT s2 B s1 x November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
5
Theory of Computation Lecture 21: Turing Machines II
Post-Turing Programs Now let us look at the execution of a very simple T program. The arrow in the program indicates the next instruction to be executed. PRINT s1 LEFT PRINT s2 LEFT s2 s1 x November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
6
Theory of Computation Lecture 21: Turing Machines II
Post-Turing Programs Now let us look at the execution of a very simple T program. The arrow in the program indicates the next instruction to be executed. PRINT s1 LEFT PRINT s2 B s2 s1 x program terminated November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
7
Theory of Computation Lecture 21: Turing Machines II
Post-Turing Programs What function did the previous program compute? Definition: Let f(x1, …, xm) be an m-ary partial function on the alphabet A = {s1, …, sn}. Then the program P in the Post-Turing language T is said to compute f if when started in the tape configuration B x1 B x2 B x3 …B xm it eventually halts if and only if f(x1, …, xm) is defined and if, on halting, the string f(x1, …, xm) can be read from the tape by ignoring all symbols except s1, …, sn. November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
8
Theory of Computation Lecture 21: Turing Machines II
Post-Turing Programs Notice that this definition allows P to contain instructions that mention symbols other than s1, …, sn. We further define the following: The program P will be said to compute f strictly if two additional conditions are met: 1. no instruction in P mentions any other symbol than s0, s1, …, sn; 2. whenever P halts, the tape configuration is … B B B y B B B …, where the string y contains no blanks. November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
9
Theory of Computation Lecture 21: Turing Machines II
Post-Turing Programs Do you remember our simple example program? It turned the tape configuration B x into the configuration B s2 s1 x So what does it compute? It strictly computes the function f(x) = s2s1x. November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
10
Theory of Computation Lecture 21: Turing Machines II
Post-Turing Programs Another example (A = {s1}): [A] RIGHT B s1 s1 IF B GOTO E PRINT M [B] RIGHT IF s1 GOTO B [C] RIGHT IF s1 GOTO C PRINT s1 [D] LEFT IF s1 GOTO D IF B GOTO D IF s1 GOTO A November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
11
Theory of Computation Lecture 21: Turing Machines II
Post-Turing Programs Another example (A = {s1}): [A] RIGHT B s1 s1 IF B GOTO E PRINT M [B] RIGHT IF s1 GOTO B [C] RIGHT IF s1 GOTO C PRINT s1 [D] LEFT IF s1 GOTO D IF B GOTO D IF s1 GOTO A November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
12
Theory of Computation Lecture 21: Turing Machines II
Post-Turing Programs Another example (A = {s1}): [A] RIGHT B s1 s1 IF B GOTO E PRINT M [B] RIGHT IF s1 GOTO B [C] RIGHT IF s1 GOTO C PRINT s1 [D] LEFT IF s1 GOTO D IF B GOTO D IF s1 GOTO A November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
13
Theory of Computation Lecture 21: Turing Machines II
Post-Turing Programs Another example (A = {s1}): [A] RIGHT B M s1 IF B GOTO E PRINT M [B] RIGHT IF s1 GOTO B [C] RIGHT IF s1 GOTO C PRINT s1 [D] LEFT IF s1 GOTO D IF B GOTO D IF s1 GOTO A November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
14
Theory of Computation Lecture 21: Turing Machines II
Post-Turing Programs Another example (A = {s1}): [A] RIGHT B M s1 IF B GOTO E PRINT M [B] RIGHT IF s1 GOTO B [C] RIGHT IF s1 GOTO C PRINT s1 [D] LEFT IF s1 GOTO D IF B GOTO D IF s1 GOTO A November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
15
Theory of Computation Lecture 21: Turing Machines II
Post-Turing Programs Another example (A = {s1}): [A] RIGHT B M s1 IF B GOTO E PRINT M [B] RIGHT IF s1 GOTO B [C] RIGHT IF s1 GOTO C PRINT s1 [D] LEFT IF s1 GOTO D IF B GOTO D IF s1 GOTO A November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
16
Theory of Computation Lecture 21: Turing Machines II
Post-Turing Programs Another example (A = {s1}): [A] RIGHT B M s1 B IF B GOTO E PRINT M [B] RIGHT IF s1 GOTO B [C] RIGHT IF s1 GOTO C PRINT s1 [D] LEFT IF s1 GOTO D IF B GOTO D IF s1 GOTO A November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
17
Theory of Computation Lecture 21: Turing Machines II
Post-Turing Programs Another example (A = {s1}): [A] RIGHT B M s1 B IF B GOTO E PRINT M [B] RIGHT IF s1 GOTO B [C] RIGHT IF s1 GOTO C PRINT s1 [D] LEFT IF s1 GOTO D IF B GOTO D IF s1 GOTO A November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
18
Theory of Computation Lecture 21: Turing Machines II
Post-Turing Programs Another example (A = {s1}): [A] RIGHT B M s1 B B IF B GOTO E PRINT M [B] RIGHT IF s1 GOTO B [C] RIGHT IF s1 GOTO C PRINT s1 [D] LEFT IF s1 GOTO D IF B GOTO D IF s1 GOTO A November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
19
Theory of Computation Lecture 21: Turing Machines II
Post-Turing Programs Another example (A = {s1}): [A] RIGHT B M s1 B B IF B GOTO E PRINT M [B] RIGHT IF s1 GOTO B [C] RIGHT IF s1 GOTO C PRINT s1 [D] LEFT IF s1 GOTO D IF B GOTO D PRINT s1 IF s1 GOTO A November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
20
Theory of Computation Lecture 21: Turing Machines II
Post-Turing Programs Another example (A = {s1}): [A] RIGHT B M s1 B s1 IF B GOTO E PRINT M [B] RIGHT IF s1 GOTO B [C] RIGHT IF s1 GOTO C PRINT s1 [D] LEFT IF s1 GOTO D IF B GOTO D IF s1 GOTO A November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
21
Theory of Computation Lecture 21: Turing Machines II
Post-Turing Programs Another example (A = {s1}): [A] RIGHT B M s1 B s1 IF B GOTO E PRINT M [B] RIGHT IF s1 GOTO B [C] RIGHT IF s1 GOTO C PRINT s1 [D] LEFT IF s1 GOTO D IF B GOTO D IF s1 GOTO A November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
22
Theory of Computation Lecture 21: Turing Machines II
Post-Turing Programs Another example (A = {s1}): [A] RIGHT B M s1 B s1 IF B GOTO E PRINT M [B] RIGHT IF s1 GOTO B [C] RIGHT IF s1 GOTO C PRINT s1 [D] LEFT IF s1 GOTO D IF B GOTO D IF s1 GOTO A November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
23
Theory of Computation Lecture 21: Turing Machines II
Post-Turing Programs Another example (A = {s1}): [A] RIGHT B M s1 B s1 IF B GOTO E PRINT M [B] RIGHT IF s1 GOTO B [C] RIGHT IF s1 GOTO C PRINT s1 [D] LEFT IF s1 GOTO D IF B GOTO D IF s1 GOTO A November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
24
Theory of Computation Lecture 21: Turing Machines II
Post-Turing Programs Another example (A = {s1}): [A] RIGHT B M s1 B s1 IF B GOTO E PRINT M [B] RIGHT IF s1 GOTO B [C] RIGHT IF s1 GOTO C PRINT s1 [D] LEFT IF s1 GOTO D IF B GOTO D IF s1 GOTO A November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
25
Theory of Computation Lecture 21: Turing Machines II
Post-Turing Programs Another example (A = {s1}): [A] RIGHT B M s1 B s1 IF B GOTO E PRINT M [B] RIGHT IF s1 GOTO B [C] RIGHT IF s1 GOTO C PRINT s1 [D] LEFT IF s1 GOTO D IF B GOTO D IF s1 GOTO A November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
26
Theory of Computation Lecture 21: Turing Machines II
Post-Turing Programs Another example (A = {s1}): [A] RIGHT B M s1 B s1 IF B GOTO E PRINT M [B] RIGHT IF s1 GOTO B [C] RIGHT IF s1 GOTO C PRINT s1 [D] LEFT IF s1 GOTO D IF B GOTO D IF s1 GOTO A November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
27
Theory of Computation Lecture 21: Turing Machines II
Post-Turing Programs Another example (A = {s1}): [A] RIGHT B M s1 B s1 IF B GOTO E PRINT M [B] RIGHT IF s1 GOTO B [C] RIGHT IF s1 GOTO C PRINT s1 [D] LEFT IF s1 GOTO D IF B GOTO D IF s1 GOTO A November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
28
Theory of Computation Lecture 21: Turing Machines II
Post-Turing Programs Another example (A = {s1}): [A] RIGHT B M s1 B s1 IF B GOTO E PRINT M [B] RIGHT IF s1 GOTO B [C] RIGHT IF s1 GOTO C PRINT s1 [D] LEFT IF s1 GOTO D IF B GOTO D PRINT s1 IF s1 GOTO A November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
29
Theory of Computation Lecture 21: Turing Machines II
Post-Turing Programs Another example (A = {s1}): [A] RIGHT B s1 s1 B s1 IF B GOTO E PRINT M [B] RIGHT IF s1 GOTO B [C] RIGHT IF s1 GOTO C PRINT s1 [D] LEFT IF s1 GOTO D IF B GOTO D IF s1 GOTO A November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
30
Theory of Computation Lecture 21: Turing Machines II
Post-Turing Programs Another example (A = {s1}): [A] RIGHT B s1 s1 B s1 IF B GOTO E PRINT M [B] RIGHT IF s1 GOTO B [C] RIGHT IF s1 GOTO C PRINT s1 [D] LEFT IF s1 GOTO D IF B GOTO D IF s1 GOTO A November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
31
Theory of Computation Lecture 21: Turing Machines II
Post-Turing Programs Another example (A = {s1}): [A] RIGHT B s1 s1 B s1 IF B GOTO E PRINT M [B] RIGHT IF s1 GOTO B [C] RIGHT IF s1 GOTO C PRINT s1 [D] LEFT IF s1 GOTO D IF B GOTO D IF s1 GOTO A November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
32
Theory of Computation Lecture 21: Turing Machines II
Post-Turing Programs Another example (A = {s1}): [A] RIGHT B s1 s1 B s1 IF B GOTO E PRINT M [B] RIGHT IF s1 GOTO B [C] RIGHT IF s1 GOTO C PRINT s1 [D] LEFT IF s1 GOTO D IF B GOTO D IF s1 GOTO A November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
33
Theory of Computation Lecture 21: Turing Machines II
Post-Turing Programs Another example (A = {s1}): [A] RIGHT B s1 M B s1 IF B GOTO E PRINT M [B] RIGHT IF s1 GOTO B [C] RIGHT IF s1 GOTO C PRINT s1 [D] LEFT IF s1 GOTO D IF B GOTO D IF s1 GOTO A November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
34
Theory of Computation Lecture 21: Turing Machines II
Post-Turing Programs Another example (A = {s1}): [A] RIGHT B s1 M B s1 IF B GOTO E PRINT M [B] RIGHT IF s1 GOTO B [C] RIGHT IF s1 GOTO C PRINT s1 [D] LEFT IF s1 GOTO D IF B GOTO D IF s1 GOTO A November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
35
Theory of Computation Lecture 21: Turing Machines II
Post-Turing Programs Another example (A = {s1}): [A] RIGHT B s1 M B s1 IF B GOTO E PRINT M [B] RIGHT IF s1 GOTO B [C] RIGHT IF s1 GOTO C PRINT s1 [D] LEFT IF s1 GOTO D IF B GOTO D IF s1 GOTO A November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
36
Theory of Computation Lecture 21: Turing Machines II
Post-Turing Programs Another example (A = {s1}): [A] RIGHT B s1 M B s1 IF B GOTO E PRINT M [B] RIGHT IF s1 GOTO B [C] RIGHT IF s1 GOTO C PRINT s1 [D] LEFT IF s1 GOTO D IF B GOTO D IF s1 GOTO A November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
37
Theory of Computation Lecture 21: Turing Machines II
Post-Turing Programs Another example (A = {s1}): [A] RIGHT B s1 M B s1 IF B GOTO E PRINT M [B] RIGHT IF s1 GOTO B [C] RIGHT IF s1 GOTO C PRINT s1 [D] LEFT IF s1 GOTO D IF B GOTO D IF s1 GOTO A November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
38
Theory of Computation Lecture 21: Turing Machines II
Post-Turing Programs Another example (A = {s1}): [A] RIGHT B s1 M B s1 B IF B GOTO E PRINT M [B] RIGHT IF s1 GOTO B [C] RIGHT IF s1 GOTO C PRINT s1 [D] LEFT IF s1 GOTO D IF B GOTO D IF s1 GOTO A November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
39
Theory of Computation Lecture 21: Turing Machines II
Post-Turing Programs Another example (A = {s1}): [A] RIGHT B s1 M B s1 B IF B GOTO E PRINT M [B] RIGHT IF s1 GOTO B [C] RIGHT IF s1 GOTO C PRINT s1 [D] LEFT IF s1 GOTO D IF B GOTO D PRINT s1 IF s1 GOTO A November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
40
Theory of Computation Lecture 21: Turing Machines II
Post-Turing Programs Another example (A = {s1}): [A] RIGHT B s1 M B s1 s1 IF B GOTO E PRINT M [B] RIGHT IF s1 GOTO B [C] RIGHT IF s1 GOTO C PRINT s1 [D] LEFT IF s1 GOTO D IF B GOTO D IF s1 GOTO A November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
41
Theory of Computation Lecture 21: Turing Machines II
Post-Turing Programs Another example (A = {s1}): [A] RIGHT B s1 M B s1 s1 IF B GOTO E PRINT M [B] RIGHT IF s1 GOTO B [C] RIGHT IF s1 GOTO C PRINT s1 [D] LEFT IF s1 GOTO D IF B GOTO D IF s1 GOTO A November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
42
Theory of Computation Lecture 21: Turing Machines II
Post-Turing Programs Another example (A = {s1}): [A] RIGHT B s1 M B s1 s1 IF B GOTO E PRINT M [B] RIGHT IF s1 GOTO B [C] RIGHT IF s1 GOTO C PRINT s1 [D] LEFT IF s1 GOTO D IF B GOTO D IF s1 GOTO A November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
43
Theory of Computation Lecture 21: Turing Machines II
Post-Turing Programs Another example (A = {s1}): [A] RIGHT B s1 M B s1 s1 IF B GOTO E PRINT M [B] RIGHT IF s1 GOTO B [C] RIGHT IF s1 GOTO C PRINT s1 [D] LEFT IF s1 GOTO D IF B GOTO D IF s1 GOTO A November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
44
Theory of Computation Lecture 21: Turing Machines II
Post-Turing Programs Another example (A = {s1}): [A] RIGHT B s1 M B s1 s1 IF B GOTO E PRINT M [B] RIGHT IF s1 GOTO B [C] RIGHT IF s1 GOTO C PRINT s1 [D] LEFT IF s1 GOTO D IF B GOTO D IF s1 GOTO A November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
45
Theory of Computation Lecture 21: Turing Machines II
Post-Turing Programs Another example (A = {s1}): [A] RIGHT B s1 M B s1 s1 IF B GOTO E PRINT M [B] RIGHT IF s1 GOTO B [C] RIGHT IF s1 GOTO C PRINT s1 [D] LEFT IF s1 GOTO D IF B GOTO D IF s1 GOTO A November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
46
Theory of Computation Lecture 21: Turing Machines II
Post-Turing Programs Another example (A = {s1}): [A] RIGHT B s1 M B s1 s1 IF B GOTO E PRINT M [B] RIGHT IF s1 GOTO B [C] RIGHT IF s1 GOTO C PRINT s1 [D] LEFT IF s1 GOTO D IF B GOTO D IF s1 GOTO A November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
47
Theory of Computation Lecture 21: Turing Machines II
Post-Turing Programs Another example (A = {s1}): [A] RIGHT B s1 M B s1 s1 IF B GOTO E PRINT M [B] RIGHT IF s1 GOTO B [C] RIGHT IF s1 GOTO C PRINT s1 [D] LEFT IF s1 GOTO D IF B GOTO D IF s1 GOTO A November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
48
Theory of Computation Lecture 21: Turing Machines II
Post-Turing Programs Another example (A = {s1}): [A] RIGHT B s1 M B s1 s1 IF B GOTO E PRINT M [B] RIGHT IF s1 GOTO B [C] RIGHT IF s1 GOTO C PRINT s1 [D] LEFT IF s1 GOTO D IF B GOTO D PRINT s1 IF s1 GOTO A November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
49
Theory of Computation Lecture 21: Turing Machines II
Post-Turing Programs Another example (A = {s1}): [A] RIGHT B s1 s1 B s1 s1 IF B GOTO E PRINT M [B] RIGHT IF s1 GOTO B [C] RIGHT IF s1 GOTO C PRINT s1 [D] LEFT IF s1 GOTO D IF B GOTO D IF s1 GOTO A November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
50
Theory of Computation Lecture 21: Turing Machines II
Post-Turing Programs Another example (A = {s1}): [A] RIGHT B s1 s1 B s1 s1 IF B GOTO E PRINT M [B] RIGHT IF s1 GOTO B [C] RIGHT IF s1 GOTO C PRINT s1 [D] LEFT IF s1 GOTO D IF B GOTO D IF s1 GOTO A November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
51
Theory of Computation Lecture 21: Turing Machines II
Post-Turing Programs Another example (A = {s1}): [A] RIGHT B s1 s1 B s1 s1 IF B GOTO E PRINT M [B] RIGHT IF s1 GOTO B [C] RIGHT IF s1 GOTO C PRINT s1 [D] LEFT IF s1 GOTO D IF B GOTO D IF s1 GOTO A November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
52
Theory of Computation Lecture 21: Turing Machines II
Post-Turing Programs Another example (A = {s1}): [A] RIGHT B s1 s1 B s1 s1 IF B GOTO E PRINT M [B] RIGHT IF s1 GOTO B program terminated [C] RIGHT IF s1 GOTO C This program computes PRINT s1 the function f(x) = xx. [D] LEFT IF s1 GOTO D Or, if we interpret x as IF B GOTO D a number, f(x) = 2x. PRINT s1 IF s1 GOTO A November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
53
Theory of Computation Lecture 21: 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. November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
54
Theory of Computation Lecture 21: 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). November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
55
Theory of Computation Lecture 21: 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. November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
56
Theory of Computation Lecture 21: 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 November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
57
Theory of Computation Lecture 21: 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 November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
58
Theory of Computation Lecture 21: 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 November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
59
Theory of Computation Lecture 21: 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. November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
60
Theory of Computation Lecture 21: 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 November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
61
Theory of Computation Lecture 21: 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. November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
62
Theory of Computation Lecture 21: 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 ] November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
63
Theory of Computation Lecture 21: 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). November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
64
Theory of Computation Lecture 21: 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 ] November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
65
Theory of Computation Lecture 21: 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 ] November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
66
Theory of Computation Lecture 21: 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 … November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
67
Theory of Computation Lecture 21: Turing Machines II
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(x1, …, xm), 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). November 30, 2017 Theory of Computation Lecture 21: Turing Machines II
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.