You are on page 1of 21

Lecture: 1 The Complexity of Computatio

17.2

Turing Machines
TMs described in 1936 Well before the days of modern computers but remains a popular model for what is possible to compute on todays systems Advances in computing still fall under the TM model, so even if they may run faster, they are still subject to the same limitations A TM consists of a finite control (i.e. a finite state automaton) that is connected to an infinite tape.

Turing Machines
The tape consists of cells where each cell holds a symbol from the tape alphabet. Initially the input consists of a finite-length string of symbols and is placed on the tape. To the left of the input and to the right of the input, extending to infinity, are placed blanks. The tape head is initially positioned at the leftmost cell holding the input.
Finite control

B B X1 X2

Xi

Xn B B

Turing Machines Details


In one move the TM will: Change state, which may be the same as the current state Write a tape symbol in the current cell, which may be the same as the current symbol Move the tape head left or right one cell The special states for rejecting and accepting take effect immediately Formally, the Turing Machine is denoted by the 8tuple: M = (Q, , , , q0, B, qa, qr)

Turing Machines Description


Q = finite states of the control = finite set of input symbols, which is a subset of below = finite set of tape symbols = transition function. (q,X) are a state and tape symbol X.
The output is the triple, (p, Y, D) Where p = next state, Y = new symbol written on the tape, D = direction to move the tape head

q0= start state for finite control B = blank symbol. This symbol is in but not in . qaccept = set of final or accepting states of Q. qreject = set of rejecting states of Q

TM for L={w#w:w0,1}
0R, 1R 0R, 1R 0L, 1L, #L Start

a
#R 0R, 1R

BL BR

c
0R, 1R ##

Check for #

#R

#R

0X R

1X R

#R

Match symbols

0L, 1L, #L 0# L 1# L

i
0X R XR 1X R #R

Return to left No input left


BR

j
#R

Multitape Machine
0 1 0 1 0 B M a a a B

b a

Equivalent Single Tape Machine:

Single Tape Equivalent


One final detail
If at any point S moves one of the virtual tape heads onto a #, then this action signifies that M has moved the corresponding head onto the previously unread blank portion of that tape. To accommodate this situation, S writes a blank symbol on this tape cell and shifts the tape contents to the rightmost # by one, adds a new #, and then continues back where it left off

Nondeterministic TM
Replace the DFA part of the TM with an NFA
Each time we make a nondeterministic move, you can think of this as a branch or fork to two simultaneously running machines. Each machine gets a copy of the entire tape. If any one of these machines ends up in an accepting state, then the input is accepted.

Although powerful, nondeterminism does not affect the power of the TM model Theorem: Every nondeterministic TM has an equivalent deterministic TM.
We can prove this theorem by simulating nondeterministic TM, N, with a deterministic TM, D. any

Nondeterministic TM
ID1 is the sequence of moves we make from the start state. The * indicates that this is the current ID we are executing. We make a move on the TM. If this move results in a fork by following nondeterministic paths, then we create a new ID and copy it to the end of the queue using the scratch tape. Scratch Tape
D

ID1*

Queue of IDs

CROSSING SEQUENCES
Let us reacquaint ourselves with Turing machines by deriving a couple of results from [59, 115] on Turing machine time and space usage. These results illustrate the use of a counting technique to show lower complexity bounds.

CROSSING SEQUENCES
Here rev x denotes x written backwards. Note that this result holds for one-tape TMs only; PAL can be accepted in linear time on a two-tape machine. Proof. Let M be any machine accepting PAL. Assume without loss of generality that whenever M accepts, it first moves to the right end of the nonblank portion of the tape before entering its accept state. For each n that is a multiple of 4, consider the action of M on elements of PAL of the form

CROSSING SEQUENCES
Lemma 1.2 If x, y PALn and x = y, then C(x) C(y) = .
Proof. Suppose c C(x) C(y), say c = ci(x) = cj(y). Let x be the prefix of x consisting of the first i symbols, and let y be the suffix of y consisting of the last n j symbols. Then xy is accepted by M, because the machine behaves to the left of c as if it were scanning x and to the right of c as if it were scanning y; in particular, it accepts. But xy is not in PAL, because it is not a palindrome. This is a contradiction.

CROSSING SEQUENCES
Theorem 1.3 If M runs in o(log log n) space, then M accepts a regular set. There is a nonregular set accepted in O(log log n) space: {#bk(0)#bk(1)#bk(2)# #bk(2k 1)# | k 0}, where bk(i) denotes the k-bit binary representation of i.

CROSSING SEQUENCES
Proof. Assume without loss of generality that M has a read-only input tape and one read/write worktape, and that M always moves its input head all the way to the right of the input string before accepting. If M is S(n) space-bounded, then on inputs of length n there are at most N = q S(n) dS(n)

CROSSING SEQUENCES
Proof. Assume without loss of generality that M has a read-only input tape and one read/write worktape, and that M always moves its input head all the way to the right of the input string before accepting. If M is S(n) space-bounded, then on inputs of length n there are at most N = q S(n) dS(n)

CROSSING SEQUENCES
where q is the number of states and d is the size of the worktape alphabet of M (the position of the input head is not counted). These data constitute the total information that can be transferred across a vertical line drawn at some position i in the input string as the input head passes over that line. For this proof, the crossing sequence at i consists of the sequence of such configurations occurring at position i in the input string in either direction. There are

CROSSING SEQUENCES
Lemma 1.4 If there is a fixed finite bound k on the amount of space used by M on accepted inputs, then L(M) is a regular set. Proof. If M uses at most k worktape cells on all accepted inputs, we can modify M to mark off k cells initially (k can be kept in the finite control) and reject if the computation ever tries to use more than k cells. That way we can make sure that M uses no more than k tape cells on any input. But then no work tape memory is needed at all; the contents of the work tape can be kept in the finite control. Thus M is equivalent to a two-way finite automaton.

CROSSING SEQUENCES
In order to have n/2 distinct crossing sequences, there must be a crossing sequence of length at least m, where

Moreover, no crossing sequence can be of length greater than 2N, otherwise a configuration would be repeated in the crossing sequence twice in the same direction, thus M would be looping, contradicting the fact that x is accepted. Thus m 2N. (1.5) Combining (1.3), (1.4), and (1.5) and taking logs, we get S(n) (log log n).

You might also like