- 688 Views
- Updated On :
- Presentation posted in: Computers / Electronics

Turing Machines. Motivation. Our main goal in this course is to analyze problems and categorize them according to their complexity . Motivation. We ask question such as “how much time it takes to compute something?”. Motivation.

Turing Machines

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Turing Machines

Our main goal in this course is to analyze problems and categorize them according to their complexity.

We ask question such as “how much time it takes to compute something?”

But in order to answer them we must first have a computational model to relate to.

- Objectives:
- To introduce the computational model called “Turing Machine”.

- Overview:
- DeterministicTuring machines
- Multi-tape Turing machines
- Non-deterministic Turing machines
- The Church-Turing thesis
- Complexity classes as bounds on resources required by TMs.

Read/Write head

There’s b here!

moves: left/right

a

infinite tape

SIP 128-129

A deterministic Turing Machine is a tuple consisting of several objects.

1. Q - a finite set of states.

2. - the input alphabet, finite set not containing the blank symbol _.

b

a

c

d

3. - the tape alphabet, where and _.

B

_

A

b

a

C

c

d

4. :QQ{L,R} - the transition function.

q0

q0

a

5. q0 - the start state

6. qacceptQ - the accept state.

7. qrejectQ - the reject state. qrejectqaccept.

1. Q - the set of states.

2. - the input alphabet.

3. - the tape alphabet

4. :QQ{L,R} - the transition function.

5. q0- the start state.

6. qacceptQ - the accept state.

7. qrejectQ - the reject state.

start state

q0

head: on the leftmost square

the input: starting from left

(q0,a)=(q0,b,R)

q0

q0

b

Note: the head cannot move to the left of this square!

If the computation ever enters the accept state, it halts.

qaccept

Note: the machine may loop and not reach any of these two!

If the computation ever enters the reject state, it also halts.

qreject

- A Turing Machine accepts its input, if it reaches an accepting configuration.
- The set of inputs it accepts is called its language.

the state

the content of the tape

the position of the head

- How many distinct configurations may a Turing machine which uses N cells have?

||N

N

|Q|

Examples:

Member of L:

aaabbbccc

Non-Member of L:

aaabbcccc

L = { anbncn | n0 }

1. Q = {q0,q1,q2,q3,q4,qaccept,qreject}

2. = {a,b,c}

3. = {a,b,c,_,X,Y,Z}

4. will be specified shortly.

5. q0 - the start state.

6. qacceptQ - the accept state.

7. qrejectQ - the reject state.

aa, R

bb, R

YY, R

ZZ, R

q1

bY,R

q2

aX,R

q0

cZ,L

XX, R

q3

bb, L aa, LYY, L

YY, R

qac

q4

ZZ, L

__, R

YY, R ZZ, R

aa, R

bb, R

YY, R

ZZ, R

q1

bY,R

transitions not specified here yield qreject

q2

aX,R

q0

cZ,L

XX, R

__, R

q3

bb, L aa, LYY, L

YY, R

qac

q4

ZZ, L

__, R

YY, R ZZ, R

aa, R YY, R

bb, R ZZ, R

q1

q1

q1

bY,R

aX,R

q2

q2

q2

q0

q0

q0

q0

q0

cZ,L

XX, R

__, R

q3

q3

q3

ZZ, L bb, L YY, L aa, L

YY, R

qac

qac

__, R

q4

q4

q4

YY, R ZZ, R

. . .

X

a

Y

b

Z

c

_

_

- Deterministic Turing machines are extremely powerful.
- We can simulate many other models by them and vice-versa with only a polynomial loss of efficiency.
- Next we’ll see an example for such model.

SIP 136-138

The input is written on the first tape

. . .

. . .

. . .

1. Q - the set of states.

2. - the input alphabet.

3. - the tape alphabet

4. :QkQ({L,R})k- the transition function, where k (the number of tapes) is some constant.

5. q0- the start state.

6. qacceptQ - the accept state.

7. qrejectQ - the reject state.

- Multi-tape machines are polynomially equivalent to single-tape machines.
- We can state a much stronger claim concerning the robustness of the Turing machine model:

Intuitive notion of algorithms

Turing machine algorithms

- We proceed with a less realistic computational model,
- Which can be simulated by DTMs
- However, with an exponential loss of efficiency.

1. Q - the set of states.

2. - the input alphabet.

3. - the tape alphabet

4. :QP(Q{L,R}) - the transition function.

5. q0- the start state.

6. qacceptQ - the accept state.

7. qrejectQ - the reject state.

power set P(A)={B | BA}

.

.

.

deterministic computation

non-deterministic computation tree

accepts if some branch reaches an accepting configuration

time

Note: the size of the tree is exponential in its height

A non-deterministic machine always guesses correctly the ultimate choice.

- A non-deterministic TM which checks if two vertices are connected in a graph may simply guess a path between them.
- Now it only needs to verify this is a valid path.

SIP 138-140

- We’ll describe a deterministic 3-tapes Turing machine which simulates a given non-deterministic machine.

. . .

input tape

. . .

simulation tape

. . .

address tape

1

non-deterministic computation

1

2

3

111

1

1

2

1

1312

1

1

2

1

2

1

1

1

2

- Write 111…1 on the address tape.
- Copy the input to the simulation tape.
- Simulate the NTM: use the choices dictated by the address tape (if valid).
- If it accepted – accept.
- Replace the address string with the lexicographically next string. If there is no such – reject.
- Go to step 2.

- Now that we have a formal computational model
- We may begin to categorize problems
- According to the resources TMs which compute them require.

Definition: Let t:nn be a function.

TIME(t(n))={L | L is a language decidable by a O(t(n)) deterministic TM}

NTIME(t(n))={L | L is a language decidable by a O(t(n)) non-deterministic TM}

Example:

{ anbncn | n0 } P

Definition:

The Towers of Hanoi

The Halting Problem

Minimum Spanning Tree

Definition:

Examples:

- the TSP problem
- the ILP problem

- Claim:PNP
- Proof: A deterministic Turing machine is a special case of non-deterministic Turing machines.

Definition:

Definition: Let f:nn be a function.

SPACE(f(n))={L | L is a language decidable by an O(f(n)) space deterministic TM}

NSPACE(f(n))={L | L is a language decidable by an O(f(n)) space non-deterministic TM}

input

work

output

. . .

read-only

Only the size of the work tape is counted for complexity purposes

read/write

. . .

write-only

. . .

Definition:

Example:

{ anbncn | n0 } PSPACE

Definition:

- Claim:PPSPACE
- Proof: A TM which runs in time t(n) can use at most t(n) space.

- Claim:PSPACEEXPTIME
- Proof:
- A machine which uses polynomial space has at most exponential number of configurations (remember? ).
- As deterministicmachine that halts may not repeat a configuration,
- its running time is bounded by the number of possible configurations.

EXPTIME

PSPACE

P

Theorem:S(n) ≥ log(n) NSPACE(S(n)) SPACE(S(n)2)

Theorem:S(n) ≥ log(n)

NSPACE(s(n))

=co-NSPACE(s(n))

Speed-up and Compression

- More time or space will allow you to compute more
- This is not always true
- Constant factor speed-up
- Non Constructible time/space bounds: Gap theorems.

- Compression theorems for constructible bounds

A Turing Machine Alphabet is easily compressed

by coding k symbols in one symbol of a larger

alphabet:

Sk--->S’

S’ = S3

This yields automatic constant factor speed-up

in space:

Space( S(n) ) = Space( S(n)/k )

Snags: Input is not compressed!

This may require additional steps and another

worktape.

It shows space speed-up for single tape model

only for w(n) bounds.

And what about Time?

PREPARE

COMPUTE &

UPDATE

Snags: you must compress the alphabet 6 times

more dense than you expected.

Input must be preprocessed so it works only nice

for time t(n) = w(n) (even w(n2) in single tape model)

1172

1173

1176

1177

1174

1175

Encode two blocks in

finite control simulator

Turing Machine.

Externally scan the block

adjacent to the block

scanned internally

Finite

Control

Now one can allways simulate k steps for 1 step and

still preserve the above invariant after every step.

THEOREM: Time( t(n) ) = Time( t(n)/ k )

for fixed k , as long as t(n)/k > (1+ e).n

Doesn’t work for single tape model; there the

input compression already requires time W(n2)

So in order that Time( t(n) ) Time( G(t(n)) )

it is necessary that G(m) = w(m)

This is however not sufficient......

≠

t(n) is time constructible when some TM on input

n (in binary) can initialize a binary counter with

value t(n) in time < t(n)

s(n) is space constructible when some TM on input

x of length n can mark a block of s(n) tape cells

without ever exceeding this block.

Against constructible boundseffective

diagonalization is possible

If S1(n) > log(n) is space constructible and

S2(n) = o(S1(n)) then

Space( S2(n) ) Space( S1(n) )

≠

On input i # x :

1)mark S1(|i#x|) tape cells

2)simulate Mi( i#x ) within this block

if simulation leaves the block accept

if simulation cycles accept -

counting OK since S1(n) > log(n)

3)if simulation terminates do the opposite:

if accept reject and accept otherwise

This program runs in space S1(n) by construction

The result can’t be computed by any device in

space S2(n) . Assume Mj does it then on input

j#x for x sufficiently large, cases 1 and 2 won’t

occur and therefore Mj( j#x )accepts iff it rejects.....

CONTRADICTION !

A similar result for Time Compression is affected

by the overhead required for maintaining the counter

ticking down from T1(n) to 0 . If we assume that

this overhead is logarithmic the result becomes:

If T1(n) > n is time constructible and

T2(n) = o(T1(n)) then

Time( T2(n) ) Time( T1(n).log(T1(n)) )

≠

Improvements:

Add an extra tape. Storing the clock on it makes

the overhead vanish.....

At least two tapes: Divide clock in head and tail

and move the head only when the tail underflows.

This reduces overhead to loglog(n); the trick

extends yielding log*(n) overhead (W. Paul)

Use distributed super redundant clock; overhead

vanishes (Fürer 1982)

The diagonalization argument is generic; the minimal

overhead determining the size of the separation gaps

is fully machine dependent.

Extends to the world of nondeterministic computation;

proof become rather complex. (Seiferas et al. for

TM time measure)

For the RAM world diagonalization results are similar;

Constant factor speed-up is difficult.

- Reasonable bounds turn out to be constructible:
- polynomials,
- simple exponentials,
- polylog functions
- closed under sum & product
- not closed under difference!

- Many Theorems are proven assuming constructibility of bounds
- Some theorems extend to general case, using trick of incremental resources
- Savitch Theorem
- Hopcroft, Paul, Valiant Theorem
- resulting bounds are weak (terminating computations only)

Diagonalization

M

Yes

M’

No

x

- Assume a TM M that, given a TM M’ and input x, decides if M’ halts on x
- Construct M”
- Run M” on the representation of M” contradiction

M”

<M”>

Yes

Thm: P EXPTIME

Proof:We construct a language L EXPTIMEhowever, L is not accepted by any TM running in polynomial time.

Let

L ={x | x= <M>#1c#1e#(01)*, M doesn’t accept xwithinc|x|etime }

L ={x | x= <M>#1c#1e#(01)*,M doesn’t accept xwithinc|x|etime }

Lemma: L EXPTIME

Proof: in fact in |x||x||x| time

Lemma: L P

Proof: assume, by way of contradiction, a TM M that accepts every xL in time c|x|e run it on the string <M>#1c#1e# to arrive at contradiction

NP

Co-NP

P

Def: Co-NP = {*-L | LNP}

- We presented two main computational models deterministic Turing machines and non-deterministic Turing machines.
- We simulated NTM by DTM with an exponential loss of efficiency.

- The Church-Turing thesis: Deterministic Turing Machines are equivalent to our intuitive notion of algorithms.
- Keeping it in mind, we’ll usually describe algorithms in pseudo-code rather than as TMs.

- Using Turing machines we’ve defined various complexity classes:
- P – Polynomial time
- NP – Non-deterministic Polynomial time
- EXPTIME – Exponential time
- L – Logarithmic space
- NL – Non-deterministic Logarithmic space
- PSPACE – Polynomial Space

- And discussed the relations between them.

Tile Type: square divided in 4

coloured triangles.

Infinite stock available

No rotations or reflections allowed

Tiling: Covering of region of the

plane such that adjacent tiles have

matching colours

Boundary condition: colours given along

(part of) edge of region, or some given

tile at some given position.

Tape

Q: states

S: tape

symbols

Read/Write

Head

Finite Control

Program : P

P (Q ) (Q {L,0,R}) :

(q,s,q’,s’,m) P denotes the instruction:

when readingsin stateqprints’perform

movemand go to stateq’ . Nondterminism!

Configurationc : finite string in S*(Q) S*

Computation Stepc --> c’ obtained by

performing an instruction in P

Computation: sequence of steps

Final Configuration: no instruction applicable

Initial Configuration: start state & leftmost

symbol scanned

Complete Computation: computation starting

in initial configuration and terminating

in finite one

Accepting / Rejecting computation ....

Idea: tile a region and let successive

color sequences along rows correspond to

successive configurations.....

s

s

s

symbol

passing

tile

state

accepting

tiles

q

q

s

qs

qs

instruction

step

tiles

qs

qs

qs

q’

q’

s’

s’

q’s’

(q,s,q’,s’,L)

(q,s,q’,s’,0)

(q,s,q’,s’,R)

SNAG: Pairs of phantom heads appearing out of nowhere...

Solution: Right and Left Moving States....

q0 1 0 1 1 B

0 q1 0 1 1 B

0 1 q0 1 1 B

0 1 0 q1 1 B

0 1 0 1 q1 B

0 1 0 1 1 qB

0 1 0 1 r1 B

0 1 0 r1 0 B

0 1 r0 0 0 B

0 1 1 0 0 B

K = {q,r,_}

S = {0,1,B}

P = { (q,0,q,0,R),

(q,1,q,1,R),

(q,B,r,B,L),

(r,0,_,1,0),

(r,1,r,0,L),

(r,B,_,1,0) }

Successor Machine;

adds 1 to a binary integer.

_ denotes empty halt state.

11 + 1 = 12

q0 1 0 1 1 B

0 q1 0 1 1 B

0 1 q0 1 1 B

0 1 0 q1 1 B

0 1 0 1 q1 B

0 1 0 1 1 qB

0 1 0 1 r1 B

0 1 0 r1 0 B

0 1 r0 0 0 B

0 1 1 0 0 B

space

initial configuration

Program : Tile Types

Input: Boundary

condition

Space: Width region

Time: Height region

blank

border

time

blank

border

accepting configuration/

by construction unique

Square Tiling: Tiling a given square with

boundary condition: Complete for NP.

Corridor Tiling: Tiling a rectangle with

boundary conditions on entrance and exit

(length is undetermined):

Complete for PSPACE .

Origin Constrained Tiling: Tiling the entire plane

with a given Tile at the Origin.

Complete for co-RE hence Undecidable

Tiling: Tiling the entire plain without constraints.

Still Complete for co-RE

(Wang/Berger’s Theorem). Hard to Prove!