Presentation is loading. Please wait.

Presentation is loading. Please wait.

December 3, 2009Theory of Computation Lecture 21: Turing Machines III 1 Simulation of T in L Now the MIDDLE section of Q can be generated by replacing.

Similar presentations


Presentation on theme: "December 3, 2009Theory of Computation Lecture 21: Turing Machines III 1 Simulation of T in L Now the MIDDLE section of Q can be generated by replacing."— Presentation transcript:

1 December 3, 2009Theory of Computation Lecture 21: Turing Machines III 1 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.

2 December 3, 2009Theory of Computation Lecture 21: Turing Machines III 2 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.

3 December 3, 2009Theory of Computation Lecture 21: Turing Machines III 3 Simulation of T in L The BEGINNING section then looks like this: L  r + 1 H  r + 1 Z 1  UPCHANGE n,r+1 (X 1 ) Z 2  UPCHANGE n,r+1 (X 2 ) : Z m  UPCHANGE n,r+1 (X m ) R  CONCAT r+1 (Z 1, r + 1, Z 2, r + 1, …, r + 1, Z m )

4 December 3, 2009Theory of Computation Lecture 21: Turing Machines III 4 Simulation of T in L Now let us write the END section. It is supposed to put the output of the simulated program in base n representation into variable Y. Since we are not demanding a strict computation by P, the output is the concatenation of all symbols on the tape that belong to the alphabet A = {s 1, …, s n }. Therefore, our END section is written as follows: Z  CONCAT r+1 (L, H, R) Y  DOWNCHANGE n,r+1 (Z) (Remember that DOWNCHANGE n,r+1 automatically removes all symbols s n+1, …, s r+1 ).

5 December 3, 2009Theory of Computation Lecture 21: Turing Machines III 5 Turing Machines Actually, Turing’s original model of a computer was different from the Post-Turing language. We will now look at a model that is closer to Turing’s original idea, the Turing machine. Its main difference to the Post-Turing language is that it does not read a list of instructions, but it is defined by a finite number of internal states and transitions between them. The machine’s next state is always determined by its current state and the current symbol under the head. Each transition also includes printing a symbol or moving the head one square to the left or right.

6 December 3, 2009Theory of Computation Lecture 21: Turing Machines III 6 Turing Machines The states are represented by the symbols q 1, q 2, q 3, …, and the symbols that can appear on the tape are written as s 0, s 1, s 2, …, where as usual s 0 = B is the blank. Expressions of one of the following three forms will be referred to as quadruples: 1.q i s j s k q l 2.q i s j Rq l 3.q i s j Lq l They indicate that if when we are in state q i and the current symbol under the head is s j, the machine goes into state q l and 1. prints symbol s k at the current head position, 2. moves the head one square to the right, or 3. moves the head one square to the left.

7 December 3, 2009Theory of Computation Lecture 21: Turing Machines III 7 Turing Machines We now define a Turing machine to be a finite set of quadruples, no two of which begin with the same pair q i s j. This means that at any time during the computation there is no ambiguity about the next action to be performed. A Turing Machine without this requirement is called a nondeterministic Turing machine. In this course, however, we will only consider deterministic Turing machines.

8 December 3, 2009Theory of Computation Lecture 21: Turing Machines III 8 Turing Machines The alphabet of a given Turing machine M consists of all the symbols s i which occur in quadruples of M except the symbol s 0. A Turing machine begins its computation in state q 1. A Turing machine halts if it is in state q i, scans the symbol s j, and does not have a quadruple that begins with q i s j. We use the same conventions with regard to input and output as we did for Post-Turing programs. So it should be clear what it means to say that some given Turing machine M computes a partial function f on A* for a given alphabet A.

9 December 3, 2009Theory of Computation Lecture 21: Turing Machines III 9 Turing Machines Just as for Post-Turing programs, we may speak of a Turing machine M to compute a function strictly. If M computes f, where f is a partial function on A*, we say that M computes f strictly if 1. the alphabet of M is a subset of A and 2. whenever M halts, the final configuration has the form: By  q i (We indicate the current state of a Turing machine by writing the state symbol below the arrow.)

10 December 3, 2009Theory of Computation Lecture 21: Turing Machines III 10 Turing Machines Example: Consider the following Turing machine with alphabet A = {1} (we will write s 0 = B and s 1 = 1): q1BRq2q1BRq2q1BRq2q1BRq2 q21Rq2q21Rq2q21Rq2q21Rq2 q2B1q3q2B1q3q2B1q3q2B1q3 q31Rq3q31Rq3q31Rq3q31Rq3 q3B1q1q3B1q1q3B1q1q3B1q1 We can also represent the machine by a state transition diagram… q1q1q1q1 q2q2q2q2 q3q3q3q3B/R 1/R B/1 1/R B/1 Exit1 … or a table: q 1 q 2 q 3 B 1 R q 2 1 q 3 R q 2 1 q 1 R q 3

11 December 3, 2009Theory of Computation Lecture 21: Turing Machines III 11 Turing Machines Now let us look at a sample computation: q1q1q1q1 q2q2q2q2 q3q3q3q3 B/R1/RB/1 1/R B/1 Exit 1 B111  q 1 B111  q 2 … B111B  q 2 B1111  q 3 B1111B  q 3 B11111  q 1

12 December 3, 2009Theory of Computation Lecture 21: Turing Machines III 12 Turing Machines The previous Turing machine computes (but not strictly) the function f(x) = x + 2, where we are using unary (base 1) notation. The steps of the computation, given by the state of the machine, the state of the machine, the string of symbols on the tape, and the string of symbols on the tape, and the square on the tape currently being scanned are called configurations. the square on the tape currently being scanned are called configurations.


Download ppt "December 3, 2009Theory of Computation Lecture 21: Turing Machines III 1 Simulation of T in L Now the MIDDLE section of Q can be generated by replacing."

Similar presentations


Ads by Google