<<

5/9/2019

Turing Turing Machines

Now let us look at a sample : The previous Turing computes (but not 1/ strictly) the f(x) = x + 2, where we are using q2 unary (base 1) notation. B/R The steps of the computation, given by q1 B/1 B/1 1 • the state of the machine, q • the string of symbols on the tape, and Exit 3 1/R • the square on the tape currently being scanned are called configurations. B111 B111 … B111B B1111 B1111B B11111      

q1 q2 q2 q3 q3 q1 May 9, 2019 1 May 9, 2019 Theory of Computation 2 Lecture 24: Turing Machines IV Lecture 24: Turing Machines IV

Another Example Another Turing Machine Example

a,b/ M/L a,b/L M/L B/L B/L q4 q3 q4 q3 B/a a/M M/R B/a a/M M/R B/R B/R q1 q2 Exit q1 q2 Exit B B a,b/R a,b/R B/b b/M B/b b/M B/L B/L q6 q5 q6 q5

a,b/L M/L a,b/L M/L BbaaB Alphabet A = {a, b} 

q1 May 9, 2019 Theory of Computation 3 May 9, 2019 Theory of Computation 4 Lecture 24: Turing Machines IV Lecture 24: Turing Machines IV

Another Turing Machine Example Another Turing Machine Example

a,b/L M/L a,b/L M/L B/L B/L q4 q3 q4 q3 B/a a/M M/R B/a a/M M/R B/R B/R q1 q2 Exit q1 q2 Exit B B a,b/R a,b/R B/b b/M B/b b/M B/L B/L q6 q5 q6 q5

a,b/L M/L a,b/L M/L BbaaB BMaaB  

q2 q5 May 9, 2019 Theory of Computation 5 May 9, 2019 Theory of Computation 6 Lecture 24: Turing Machines IV Lecture 24: Turing Machines IV

1 5/9/2019

Another Turing Machine Example Another Turing Machine Example

a,b/L M/L a,b/L M/L B/L B/L q4 q3 q4 q3 B/a a/M M/R B/a a/M M/R B/R B/R q1 q2 Exit q1 q2 Exit B B a,b/R a,b/R B/b b/M B/b b/M B/L B/L q6 q5 q6 q5

a,b/L M/L a,b/L M/L BMaaB BBMaaB  

q5 q6 May 9, 2019 Theory of Computation 7 May 9, 2019 Theory of Computation 8 Lecture 24: Turing Machines IV Lecture 24: Turing Machines IV

Another Turing Machine Example Another Turing Machine Example

a,b/L M/L a,b/L M/L B/L B/L q4 q3 q4 q3 B/a a/M M/R B/a a/M M/R B/R B/R q1 q2 Exit q1 q2 Exit B B a,b/R a,b/R B/b b/M B/b b/M B/L B/L q6 q5 q6 q5

a,b/L M/L a,b/L M/L bBMaaB bBMaaB  

q1 q1 May 9, 2019 Theory of Computation 9 May 9, 2019 Theory of Computation 10 Lecture 24: Turing Machines IV Lecture 24: Turing Machines IV

Another Turing Machine Example Another Turing Machine Example

a,b/L M/L a,b/L M/L B/L B/L q4 q3 q4 q3 B/a a/M M/R B/a a/M M/R B/R B/R q1 q2 Exit q1 q2 Exit B B a,b/R a,b/R B/b b/M B/b b/M B/L B/L q6 q5 q6 q5

a,b/L M/L a,b/L M/L bBMaaB bBMaaB  

q2 q2 May 9, 2019 Theory of Computation 11 May 9, 2019 Theory of Computation 12 Lecture 24: Turing Machines IV Lecture 24: Turing Machines IV

2 5/9/2019

Another Turing Machine Example Another Turing Machine Example

a,b/L M/L a,b/L M/L B/L B/L q4 q3 q4 q3 B/a a/M M/R B/a a/M M/R B/R B/R q1 q2 Exit q1 q2 Exit B B a,b/R a,b/R B/b b/M B/b b/M B/L B/L q6 q5 q6 q5

a,b/L M/L a,b/L M/L bBMMaB bBMMaB  

q3 q3 May 9, 2019 Theory of Computation 13 May 9, 2019 Theory of Computation 14 Lecture 24: Turing Machines IV Lecture 24: Turing Machines IV

Another Turing Machine Example Another Turing Machine Example

a,b/L M/L a,b/L M/L B/L B/L q4 q3 q4 q3 B/a a/M M/R B/a a/M M/R B/R B/R q1 q2 Exit q1 q2 Exit B B a,b/R a,b/R B/b b/M B/b b/M B/L B/L q6 q5 q6 q5

a,b/L M/L a,b/L M/L bBMMaB bBMMaB  

q3 q4 May 9, 2019 Theory of Computation 15 May 9, 2019 Theory of Computation 16 Lecture 24: Turing Machines IV Lecture 24: Turing Machines IV

Another Turing Machine Example Another Turing Machine Example

a,b/L M/L a,b/L M/L B/L B/L q4 q3 q4 q3 B/a a/M M/R B/a a/M M/R B/R B/R q1 q2 Exit q1 q2 Exit B B a,b/R a,b/R B/b b/M B/b b/M B/L B/L q6 q5 q6 q5

a,b/L M/L a,b/L M/L BbBMMaB abBMMaB  

q4 q1 May 9, 2019 Theory of Computation 17 May 9, 2019 Theory of Computation 18 Lecture 24: Turing Machines IV Lecture 24: Turing Machines IV

3 5/9/2019

Another Turing Machine Example Another Turing Machine Example

a,b/L M/L a,b/L M/L B/L B/L q4 q3 q4 q3 B/a a/M M/R B/a a/M M/R B/R B/R q1 q2 Exit q1 q2 Exit B B a,b/R a,b/R B/b b/M B/b b/M B/L B/L q6 q5 q6 q5

a,b/L M/L a,b/L M/L abBMMaB abBMMaB  

q1 q1 May 9, 2019 Theory of Computation 19 May 9, 2019 Theory of Computation 20 Lecture 24: Turing Machines IV Lecture 24: Turing Machines IV

Another Turing Machine Example Another Turing Machine Example

a,b/L M/L a,b/L M/L B/L B/L q4 q3 q4 q3 B/a a/M M/R B/a a/M M/R B/R B/R q1 q2 Exit q1 q2 Exit B B a,b/R a,b/R B/b b/M B/b b/M B/L B/L q6 q5 q6 q5

a,b/L M/L a,b/L M/L abBMMaB abBMMaB  

q2 q2 May 9, 2019 Theory of Computation 21 May 9, 2019 Theory of Computation 22 Lecture 24: Turing Machines IV Lecture 24: Turing Machines IV

Another Turing Machine Example Another Turing Machine Example

a,b/L M/L a,b/L M/L B/L B/L q4 q3 q4 q3 B/a a/M M/R B/a a/M M/R B/R B/R q1 q2 Exit q1 q2 Exit B B a,b/R a,b/R B/b b/M B/b b/M B/L B/L q6 q5 q6 q5

a,b/L M/L a,b/L M/L abBMMaB abBMMMB  

q2 q3 May 9, 2019 Theory of Computation 23 May 9, 2019 Theory of Computation 24 Lecture 24: Turing Machines IV Lecture 24: Turing Machines IV

4 5/9/2019

Another Turing Machine Example Another Turing Machine Example

a,b/L M/L a,b/L M/L B/L B/L q4 q3 q4 q3 B/a a/M M/R B/a a/M M/R B/R B/R q1 q2 Exit q1 q2 Exit B B a,b/R a,b/R B/b b/M B/b b/M B/L B/L q6 q5 q6 q5

a,b/L M/L a,b/L M/L abBMMMB abBMMMB  

q3 q3 May 9, 2019 Theory of Computation 25 May 9, 2019 Theory of Computation 26 Lecture 24: Turing Machines IV Lecture 24: Turing Machines IV

Another Turing Machine Example Another Turing Machine Example

a,b/L M/L a,b/L M/L B/L B/L q4 q3 q4 q3 B/a a/M M/R B/a a/M M/R B/R B/R q1 q2 Exit q1 q2 Exit B B a,b/R a,b/R B/b b/M B/b b/M B/L B/L q6 q5 q6 q5

a,b/L M/L a,b/L M/L abBMMMB abBMMMB  

q3 q4 May 9, 2019 Theory of Computation 27 May 9, 2019 Theory of Computation 28 Lecture 24: Turing Machines IV Lecture 24: Turing Machines IV

Another Turing Machine Example Another Turing Machine Example

a,b/L M/L a,b/L M/L B/L B/L q4 q3 q4 q3 B/a a/M M/R B/a a/M M/R B/R B/R q1 q2 Exit q1 q2 Exit B B a,b/R a,b/R B/b b/M B/b b/M B/L B/L q6 q5 q6 q5

a,b/L M/L a,b/L M/L abBMMMB BabBMMMB  

q4 q4 May 9, 2019 Theory of Computation 29 May 9, 2019 Theory of Computation 30 Lecture 24: Turing Machines IV Lecture 24: Turing Machines IV

5 5/9/2019

Another Turing Machine Example Another Turing Machine Example

a,b/L M/L a,b/L M/L B/L B/L q4 q3 q4 q3 B/a a/M M/R B/a a/M M/R B/R B/R q1 q2 Exit q1 q2 Exit B B a,b/R a,b/R B/b b/M B/b b/M B/L B/L q6 q5 q6 q5

a,b/L M/L a,b/L M/L aabBMMMB aabBMMMB  

q1 q1 May 9, 2019 Theory of Computation 31 May 9, 2019 Theory of Computation 32 Lecture 24: Turing Machines IV Lecture 24: Turing Machines IV

Another Turing Machine Example Another Turing Machine Example

a,b/L M/L a,b/L M/L B/L B/L q4 q3 q4 q3 B/a a/M M/R B/a a/M M/R B/R B/R q1 q2 Exit q1 q2 Exit B B a,b/R a,b/R B/b b/M B/b b/M B/L B/L q6 q5 q6 q5

a,b/L M/L a,b/L M/L aabBMMMB aabBMMMB  

q1 q1 May 9, 2019 Theory of Computation 33 May 9, 2019 Theory of Computation 34 Lecture 24: Turing Machines IV Lecture 24: Turing Machines IV

Another Turing Machine Example Another Turing Machine Example

a,b/L M/L a,b/L M/L B/L B/L q4 q3 q4 q3 B/a a/M M/R B/a a/M M/R B/R B/R q1 q2 Exit q1 q2 Exit B B a,b/R a,b/R B/b b/M B/b b/M B/L B/L q6 q5 q6 q5

a,b/L M/L a,b/L M/L aabBMMMB aabBMMMB  

q2 q2 May 9, 2019 Theory of Computation 35 May 9, 2019 Theory of Computation 36 Lecture 24: Turing Machines IV Lecture 24: Turing Machines IV

6 5/9/2019

Another Turing Machine Example Another Turing Machine Example

a,b/L M/L a,b/L M/L B/L B/L q4 q3 q4 q3 B/a a/M M/R B/a a/M M/R B/R B/R q1 q2 Exit q1 q2 Exit B B a,b/R a,b/R B/b b/M B/b b/M B/L B/L q6 q5 q6 q5

a,b/L M/L a,b/L M/L aabBMMMB aabBMMMB  

q2 q2 May 9, 2019 Theory of Computation 37 May 9, 2019 Theory of Computation 38 Lecture 24: Turing Machines IV Lecture 24: Turing Machines IV

Another Turing Machine Example Turing Machines

a,b/L M/L Theorem 1.1: B/L Any that can be computed by a Post- q4 q3 B/a a/M M/R Turing program can be computed by a Turing machine B/R using the same alphabet. q1 q2 Exit B a,b/R Proof: B/b b/M B/L Let be a given Post-Turing program consisting of the q6 q5 P instructions I1, …, Ik. a,b/L M/L Let s0, s1, …, sn be a list that includes all of the aabBMMMB Output: aab symbols mentioned in P.  Reversed! We will construct a Turing machine M that simulates P. q2 May 9, 2019 Theory of Computation 39 May 9, 2019 Theory of Computation 40 Lecture 24: Turing Machines IV Lecture 24: Turing Machines IV

Turing Machines Turing Machines

Our idea is that M will be in state qi precisely when P If Ii is IF sk GOTO L, then let m be the least is about to execute instruction Ii. such that Im is labeled L if there is an instruction of P So if Ii is PRINT sk, then we place in M all of the labeled L; otherwise let m = K + 1. following quadruples: We place in M the quadruple qi sj sk qi+1, j = 0, 1, …, n. qi sk sk qm, If I is RIGHT, then we place in all of the following i M as well as the following quadruples: quadruples: qi sj sj qi+1, j = 0, 1, …, n; j  k. qi sj Rqi+1, j = 0, 1, …, n. Obviously, the actions of M correspond precisely to the If Ii is LEFT, then we place in M all of the following quadruples: instructions of P, so our proof is complete. qi sj Lqi+1, j = 0, 1, …, n. May 9, 2019 Theory of Computation 41 May 9, 2019 Theory of Computation 42 Lecture 24: Turing Machines IV Lecture 24: Turing Machines IV

7 5/9/2019

Turing Machines Turing Machines Do you remember Corollary 6.4 of Chapter 5? Thus, if f(x1, …, xm) is any partially on N, then there is a Turing machine that “Every partially computable function is computed computes f using only the symbols B and 1. strictly by some Post-Turing program that uses only The initial configuration corresponding to inputs the symbols s0 and s1.” x1, …, xm is Given this corollary and the proof we just completed, [x ] [x ] we can derive the following: B 1 1 B … B 1 m 

Theorem 1.2: Let f be an m-ary partially computable q1 function on A* for a given alphabet A. Then there is a and the final configuration if f(x , …, x ) is Turing machine M that computes f strictly. 1 m B 1[f(x1, …, xm)] It is interesting to see the application of Theorem 1.2  to the case A = {1}. qK+1 May 9, 2019 Theory of Computation 43 May 9, 2019 Theory of Computation 44 Lecture 24: Turing Machines IV Lecture 24: Turing Machines IV

Turing Machines Turing Machines Now we will take a look at Turing machines that A quintuple Turing machine is a finite set of quintuples, consist of quintuples instead of quadruples. no two of which begin with the same pair qi sj. There are two kinds of quintuples: Theorem 1.3: Any partial function that can be 1. qi sj sk Rql computed by a Turing machine can be computed by a

2. qi sj sk Lql quintuple Turing machine using the same alphabet.

So you see that in either case the head prints the Proof: Let M be a Turing machine with states q1, …, q and alphabet {s , …, s }. symbol sk, which of course can be the same as the K 1 n current symbol sj. We construct a quintuple Turing machine M’ to Then a quintuple of type 1 makes the head move one simulate M. step to the right, while type 2 makes it move one step The states of M’ are q1, …, q2K. to the left.

May 9, 2019 Theory of Computation 45 May 9, 2019 Theory of Computation 46 Lecture 24: Turing Machines IV Lecture 24: Turing Machines IV

Turing Machines Turing Machines For each quadruple of of the form M So for each quadruple of M of the form qi sj Rql qi sj sk ql we place in the corresponding quintuple M’ we place in M’ the corresponding quintuple qi sj sj Rql . qi sj sk RqK+l . Similarly, for each quadruple of of the form M Finally, we place in M’ all quintuples of the form qi sj Lql qK+i sj sj Lqi , i = 1, …, K; j = 0, …, n. we place in M’ the corresponding quintuple qi sj sj Lql . The extra states qK+1, …, q2K are used to “remember” that we have gone one square too far to the right. The third type of quadruple, qi sj sk ql , is harder to simulate, because the quintuples always demand a move to either the right or the left. May 9, 2019 Theory of Computation 47 May 9, 2019 Theory of Computation 48 Lecture 24: Turing Machines IV Lecture 24: Turing Machines IV

8 5/9/2019

Turing Machines Turing Machines Theorem 1.4: Any partial function that can be Proof of Theorem 1.4: computed by a quintuple Turing machine can be Let M be a given quintuple Turing machine with states computed by a Post-Turing program using the same q1, …, qK and alphabet {s1, …, sn}. alphabet. We associate with each state qi a label Ai and with This theorem, together with Theorems 1.1, 1.3, and each pair qi sj a label Bij.

1.4 in this chapter, gives us the following corollary: Each label Ai is to be placed next to the first instruction in the following filter: Corollary 1.5: For a given partial function f, the

following are equivalent: [Ai]IF s0 GOTO Bi0

1. f can be computed by a Post-Turing program, IF s1 GOTO Bi1 2. f can be computed by a Turing machine, :

3. f can be computed by a quintuple Turing machine. IF sn GOTO Bin May 9, 2019 Theory of Computation 49 May 9, 2019 Theory of Computation 50 Lecture 24: Turing Machines IV Lecture 24: Turing Machines IV

Turing Machines Turing Machines If contains the quintuple M Finally, if there is no quintuple in M beginning with qi sj sk Rql , qi sj , then we introduce the following block: then we introduce the following block of instructions: [Bij] GOTO E [Bij] PRINT sk Now we can easily construct a Post-Turing program RIGHT that simulates M simply by putting all of these blocks

GOTO Al and filters one under the other. The order of placement only matters for the filter Similarly, for the quintuple qi sj sk L ql we introduce labeled A1, which must begin the program. [B ] PRINT s ij k The next slide will show the entire program. LEFT

GOTO Al May 9, 2019 Theory of Computation 51 May 9, 2019 Theory of Computation 52 Lecture 24: Turing Machines IV Lecture 24: Turing Machines IV

Turing Machines A

[A1]IF s0 GOTO B10 Do you remember the universal program from : Section 4.3? IF s GOTO B n 1n It computes the output of another program when it is [A2]IF s0 GOTO B20 : given that program’s number and the input to that

IF sn GOTO B2n program. : We defined (x, z) to be the unary partial function [AK]IF s0 GOTO BK0 : computed by the program with number z for the input x.

IF sn GOTO BKn Now let M be a Turing machine that computes this [B ] PRINT s i1j1 k1 function with alphabet {1}. RIGHT Then let g(x) be any partially computable function of GOTO Al [B ] PRINT s one variable, and let z0 be the number of some program i2j2 k2 : in the language L that computes g.

May 9, 2019 Theory of Computation 53 May 9, 2019 Theory of Computation 54 Lecture 24: Turing Machines IV Lecture 24: Turing Machines IV

9 5/9/2019

A Universal Turing Machine A Universal Turing Machine If we begin with the configuration We can always find such a universal Turing machine M: B x B z0  • The Universality Theorem tells us that there exists q an L program that computes (x, z) 1 (and we discussed how to write it). where x and z0 are written in unary notation, that is, as • Theorem 1.2 in this chapter tells us that for every L blocks of ones, then M will compute (x, z0) = g(x). program there is a Turing machine that does the (While unary notation is not very practical, it is intuitive same computation (we discussed how to build it). and avoids the consideration of different bases and Of course we could also develop a numbering scheme converting representations between them.) for Turing machines. Thus, M can be used to compute any partially Then we could build a universal Turing machine that computable function of one variable. simulates the computation by another Turing machine.

May 9, 2019 Theory of Computation 55 May 9, 2019 Theory of Computation 56 Lecture 24: Turing Machines IV Lecture 24: Turing Machines IV

A Universal Turing Machine Overview of

The universal Turing Machine was Turing’s original A B means that we simulated in language theoretical construction of a programmable A using language B, showing that the computational power of B is at least as great as that of A. . It provides a model of an all-purpose computer, in L Ln which data and programs are stored together in a single memory. Post-Turing In the year 1936, this achievement showed that such language an all-purpose computer would be possible. It led to the anticipation of the modern digital computer. Turing quintuple machine Turing machine May 9, 2019 Theory of Computation 57 May 9, 2019 Theory of Computation 58 Lecture 24: Turing Machines IV Lecture 24: Turing Machines IV

Overview of Simulations

Our simulations show that the computational power of all five languages is identical. In other words, these languages can compute exactly the same functions. This result supports Church’s Thesis – any function that can be computed in principle can be computed by a Turing machine. THE END

May 9, 2019 Theory of Computation 59 Lecture 24: Turing Machines IV

10