computability and complexity 3-1 turing machine computability and complexity andrei bulatov

25
Computability and Complexity 3-1 Turing Machine Computability and Complex Andrei Bula

Post on 21-Dec-2015

231 views

Category:

Documents


5 download

TRANSCRIPT

Page 1: Computability and Complexity 3-1 Turing Machine Computability and Complexity Andrei Bulatov

Computability and Complexity 3-1

Turing Machine

Computability and ComplexityAndrei Bulatov

Page 2: Computability and Complexity 3-1 Turing Machine Computability and Complexity Andrei Bulatov

Computability and Complexity 3-2

What is a computation?

Alan Turing considered this question in 1936

He argued that any computation can be done using the following steps:

• Concentrate on one part of the problem (for example, one piece of paper, one arithmetic operation, etc.)

• Depending on this, and present state of the computer:

- Modify this part of problem;

- Move to another part of problem;

- Change into a new state.

• Repeat this until finished.

Page 3: Computability and Complexity 3-1 Turing Machine Computability and Complexity Andrei Bulatov

Computability and Complexity 3-3

Implications

• If the computation can be described in a finite space, then there can can be only a finite number of different situations to deal with

• Therefore, there can be only a finite number of “states” and a finite number of “symbols”.

• But note that the computation might continue forever and never finish, and it might use (potentially) infinite storage space

Page 4: Computability and Complexity 3-1 Turing Machine Computability and Complexity Andrei Bulatov

I N P U T

Computability and Complexity 3-4

000

The Turing Machine

Page 5: Computability and Complexity 3-1 Turing Machine Computability and Complexity Andrei Bulatov

Computability and Complexity 3-5

Turing Machine Configuration

Tape contains a sequence (infinite to the right) of symbols from an alphabet almost all of the members of this sequence (except for a finite number) are the blank symbol At the first step it contains the input, i.e. the non-blank symbols on the tape constitutes the input

Head reads one cell (one symbol on the tape) at the first step it reads the leftmost symbol on the tape

Control Device is in one of the states from a finite set of states Q at the first step it is in the initial state 0q

Page 6: Computability and Complexity 3-1 Turing Machine Computability and Complexity Andrei Bulatov

Computability and Complexity 3-6

Turing Machine Operation

1. At each step of operation machine is in one of the states, say q (initially state is )

2. The machine is reading one symbol on tape, say s

3. To execute one step, the machine looks up the value of a transition function (q,s), which is, say, (q’,s’,m)

4. The machine:

• changes to state q’;

• overwrites the symbol s with s’;

• moves the head along the tape according to m (R=Right, L=Left, S=Static).

5. Execution stops when a final state is reached

0q

Page 7: Computability and Complexity 3-1 Turing Machine Computability and Complexity Andrei Bulatov

Computability and Complexity 3-7

Turing Machine Definition

Definition A Turing Machine is a 6-tuple where

1. Q is a finite set of states

2. is the input alphabet not containing the blank symbol

3. is the tape alphabet, where and

4. is a transition function

5. is the initial state

6. F Q is a set of final states

FqQ ,,,,, 0

Qq 0

},,{: SRLQQ

Page 8: Computability and Complexity 3-1 Turing Machine Computability and Complexity Andrei Bulatov

Computability and Complexity 3-8

Question

What do the following machines do?

Page 9: Computability and Complexity 3-1 Turing Machine Computability and Complexity Andrei Bulatov

Computability and Complexity 3-9

TM Example

Let T be the TM :

Q = {1,2,3}

= {a,b}

= {,a,b} = { (1,a),(2,a,R), (1,b),(2,b,R), (1, ),(2, ,R), (2,a),(3,a,S), (2,b),(2,b,R), (2,),(2,,R) } = 1 F = {3}

FqQ ,,,,, 0

0q

Page 10: Computability and Complexity 3-1 Turing Machine Computability and Complexity Andrei Bulatov

Computability and Complexity 3-10

TM Example

Let T be the TM :

Q = {a,b,c,d,e}

= {0,1}

= {,0,1} = { (a,0),(e,1,L), (c,0),(d,,R), (a,1),(a,0,L), (c,1),(b,,R), (a, ),(e,1,S), (c, ),(e,,S), (b,0),(d,1,R), (d,0),(d,0,R), (b,1),(b,1,R), (d,1),(b,0,R), (b,),(a,1,S), (d,),(a,0,S) } = c F = {e}

FqQ ,,,,, 0

0q

Page 11: Computability and Complexity 3-1 Turing Machine Computability and Complexity Andrei Bulatov

Computability and Complexity 3-11

TM Diagram

c

e

a

b d

||S 0|01|LS

0||R

1||R

|1|S

0|1|R1|1|R

1|0|R

0|0|R

|0|S

1|0|L

Page 12: Computability and Complexity 3-1 Turing Machine Computability and Complexity Andrei Bulatov

Computability and Complexity 3-12

Configurations

Configurations: To completely describe a TM in operation we need:

• The current state• The content of the tape• The position of the head

This information is called the configuration (or global state)

Computation: a (possibly infinite) sequence of configurations entered by a TM beginning with an initial configuration

Initial configuration: for machine T and input string x consists of:

• The initial state,• The tape starting with x, all other cells blank• The head on the leftmost cell

0q

Page 13: Computability and Complexity 3-1 Turing Machine Computability and Complexity Andrei Bulatov

Computability and Complexity 3-13

Acceptors and Transducers

Acceptor machines: have 2 final states

• “Accept” ( )• “Reject” ( )

These machines can be used to solve decision problems: input x is accepted by T if T(x) is finite and ends in the “Accept” state.

Language accepted: set of inputs accepted by T, denoted by L(T)

Aq

Rq

Page 14: Computability and Complexity 3-1 Turing Machine Computability and Complexity Andrei Bulatov

Computability and Complexity 3-14

I N P U T

A? R?

Page 15: Computability and Complexity 3-1 Turing Machine Computability and Complexity Andrei Bulatov

Computability and Complexity 3-15

Transducer: T computes (partial) function f if computation T(x) halts in a final state with f(x) on the output tape

Page 16: Computability and Complexity 3-1 Turing Machine Computability and Complexity Andrei Bulatov

Computability and Complexity 3-16

I N P U T

H?

O U T P U T

Page 17: Computability and Complexity 3-1 Turing Machine Computability and Complexity Andrei Bulatov

Computability and Complexity 3-17

Turing’s Thesis

“Any function which can be computed by any well-defined procedurecan be computed by a Turing Machine”

(Also called Church’s Hypothesis, Sequential Computing Hypothesis)

Page 18: Computability and Complexity 3-1 Turing Machine Computability and Complexity Andrei Bulatov

Computability and Complexity 3-18

k-tape TM

Transition function:

times times times

},,{},,{:kkk

SRLSRLQQ

),,;',,';'(),,;( 111 kkk mmssqssq

Initial configuration:

• the first tape contains an input

• the other tapes contain only blank symbols

Page 19: Computability and Complexity 3-1 Turing Machine Computability and Complexity Andrei Bulatov

Computability and Complexity 3-19

Nondeterministic TM

We can relax the definition of a TM to allow more than one possible transition for any pair q,s of state and symbol

This gives a nondeterministic TM (i.e. it has a choice of actions)

Nondeterministic computation: a tree of possible configurations resulting from a start configuration For machine NT and input x this is denoted NT(x)

Page 20: Computability and Complexity 3-1 Turing Machine Computability and Complexity Andrei Bulatov

Computability and Complexity 3-20

Nondeterministic Acceptor

Computation path: is any path (finite or infinite) from the root of NT(x)

Accepting computation: is a finite computation path ending in the “Accept” state

Language accepted: is the set of inputs x having some accepting computation in NT(x), denoted L(NT).

Page 21: Computability and Complexity 3-1 Turing Machine Computability and Complexity Andrei Bulatov

Computability and Complexity 3-21

R R

R

R

R A R

Tim

e

Page 22: Computability and Complexity 3-1 Turing Machine Computability and Complexity Andrei Bulatov

Computability and Complexity 3-22

Random Access Machines

Another model of computation is the Random Access Machine,which has

• an infinite series of memory locations, where each can contain an arbitrary integer

• a processor which can perform basic operations, including addition, subtraction, integer division by 2, indirect addressing, conditional goto, and halt

• a finite program specifying a sequence of basic operations involving the contents of memory locations

,, ,21 MM

iM

Theorem Given a RAM, it is possible to derive an equivalent 3-tape deterministic TM

Page 23: Computability and Complexity 3-1 Turing Machine Computability and Complexity Andrei Bulatov

Computability and Complexity 3-23

H?

1. READ 12. STORE 13. STORE 54. READ 25. STORE 26. HALF7. STORE 38. ADD 39. SUB 210. JZERO 1411. LOAD 412. ADD 513. STORE 414. LOAD 515. ADD 516. STORE 517. LOAD 318. JZERO 2019. JUMP 520. LOAD 421. HALT

1

2

3

4

5

6

7

8

9

3556

21

Page 24: Computability and Complexity 3-1 Turing Machine Computability and Complexity Andrei Bulatov

Computability and Complexity 3-24

Simulations

The following machines can all be simulated by a TM with one tapeand alphabet {0,1}

• TMs with tape infinite in both directions

• TMs with more than one tape

• TMs with 2-dimensional tape (or more!)

• TMs with several read/write heads on each tape

• Nondeterministic TMs

• RAM Machines

Page 25: Computability and Complexity 3-1 Turing Machine Computability and Complexity Andrei Bulatov

Computability and Complexity 3-25

Other Models

The following people also proposed models of general computation*:

• Post (1936) — “Post’s normal systems”

• Kleene (1936) — “recursive functions”

• Church (1941) — “lambda calculus”

• Markov (1954) — “Markov’s rewriting systems”

All of these have been shown to be equivalent to Turing Machines

*see “Machine Models and Simulations” in the Handbook of Theoretical ComputerScience, MIT Press, 1990