turing machines - taubchor/cm05/compute6.pdf · configuration qibv yields qjcv. special case (2):...

234
Computational Models - Lecture 6 Turing Machines Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.1

Upload: others

Post on 01-Aug-2020

6 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Computational Models - Lecture 6

TuringMachines

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.1

Page 2: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Computational Models - Lecture 6

TuringMachines

TuringMachines

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.1

Page 3: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Computational Models - Lecture 6

TuringMachines

TuringMachines

TuringMachines

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.1

Page 4: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Computational Models - Lecture 6

TuringMachines

TuringMachines

TuringMachines

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.1

Page 5: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Computational Models - Lecture 6

TuringMachines

TuringMachines

TuringMachines

Alternative Models of Computers

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.1

Page 6: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Computational Models - Lecture 6

TuringMachines

TuringMachines

TuringMachines

Alternative Models of Computers

Multitape TMs, RAMs,Non DeterministicTMs

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.1

Page 7: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Computational Models - Lecture 6

TuringMachines

TuringMachines

TuringMachines

Alternative Models of Computers

Multitape TMs, RAMs,Non DeterministicTMs

TheChurch-Turing Thesis

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.1

Page 8: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Computational Models - Lecture 6

TuringMachines

TuringMachines

TuringMachines

Alternative Models of Computers

Multitape TMs, RAMs,Non DeterministicTMs

TheChurch-Turing Thesis

David Hilbert’s Tenth Problem

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.1

Page 9: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

A Finite Automaton

011011001

read unread

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.2

Page 10: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

A Pushdown Automaton

01101

read unread

pop

push

10

abba

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.3

Page 11: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

A Turing Machine

1 010

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.4

Page 12: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Turing Machines

Machines so far (DFA, PDA) read input onlyonce

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.5

Page 13: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Turing Machines

Machines so far (DFA, PDA) read input onlyonce

Turing Machines

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.5

Page 14: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Turing Machines

Machines so far (DFA, PDA) read input onlyonce

Turing MachinesCan back up over the input

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.5

Page 15: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Turing Machines

Machines so far (DFA, PDA) read input onlyonce

Turing MachinesCan back up over the inputCan overwrite the input

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.5

Page 16: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Turing Machines

Machines so far (DFA, PDA) read input onlyonce

Turing MachinesCan back up over the inputCan overwrite the inputCan write information on tape and come backto it later

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.5

Page 17: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Turing Machines

Input string is written on a tape:

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.6

Page 18: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Turing Machines

Input string is written on a tape:

At each step, machine reads a symbol, and then

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.6

Page 19: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Turing Machines

Input string is written on a tape:

At each step, machine reads a symbol, and thenwrites a new symbol, and

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.6

Page 20: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Turing Machines

Input string is written on a tape:

At each step, machine reads a symbol, and thenwrites a new symbol, andeither moves read/write head to right,

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.6

Page 21: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Turing Machines

Input string is written on a tape:

At each step, machine reads a symbol, and thenwrites a new symbol, andeither moves read/write head to right,or moves read/write head to left

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.6

Page 22: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

TM vs. DFA: DifferencesA Turing machine can both write on the tape andread from it.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.7

Page 23: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

TM vs. DFA: DifferencesA Turing machine can both write on the tape andread from it.

The read-write head can move both to the left andto the right

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.7

Page 24: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

TM vs. DFA: DifferencesA Turing machine can both write on the tape andread from it.

The read-write head can move both to the left andto the right

the tape is infinite

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.7

Page 25: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

TM vs. DFA: DifferencesA Turing machine can both write on the tape andread from it.

The read-write head can move both to the left andto the right

the tape is infinite

special accepting/rejecting states take immediateeffect

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.7

Page 26: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Configurations (reminder)

One step of computation changes

current state,

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.8

Page 27: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Configurations (reminder)

One step of computation changes

current state,

current head position,

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.8

Page 28: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Configurations (reminder)

One step of computation changes

current state,

current head position,

and tape contents.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.8

Page 29: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Configurations (reminder)

One step of computation changes

current state,

current head position,

and tape contents.

For example, configuration1011q70111 means:

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.8

Page 30: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Configurations (reminder)

One step of computation changes

current state,

current head position,

and tape contents.

For example, configuration1011q70111 means:

Current state isq7,

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.8

Page 31: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Configurations (reminder)

One step of computation changes

current state,

current head position,

and tape contents.

For example, configuration1011q70111 means:

Current state isq7,

left hand side of tape is1011,

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.8

Page 32: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Configurations (reminder)

One step of computation changes

current state,

current head position,

and tape contents.

For example, configuration1011q70111 means:

Current state isq7,

left hand side of tape is1011,

right hand side of tape is0111,

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.8

Page 33: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Configurations (reminder)

One step of computation changes

current state,

current head position,

and tape contents.

For example, configuration1011q70111 means:

Current state isq7,

left hand side of tape is1011,

right hand side of tape is0111,

and head is on right hand side0.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.8

Page 34: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Configurations (2)

If δ(qi, b) = (qj, c, L) then configurationuaqibv yieldsconfigurationuqjacv.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.9

Page 35: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Configurations (2)

If δ(qi, b) = (qj, c, L) then configurationuaqibv yieldsconfigurationuqjacv.

If δ(qi, b) = (qj, c, R), then configurationuaqibv yieldsconfigurationuacqjv .

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.9

Page 36: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Configurations (2)

If δ(qi, b) = (qj, c, L) then configurationuaqibv yieldsconfigurationuqjacv.

If δ(qi, b) = (qj, c, R), then configurationuaqibv yieldsconfigurationuacqjv .

Special case (1): When head is at left end andtries to move left, it changes state and writes ontape butdoes not move, so if δ(qi, b) = (qj, c, L),configurationqibv yieldsqjcv.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.9

Page 37: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Configurations (2)

If δ(qi, b) = (qj, c, L) then configurationuaqibv yieldsconfigurationuqjacv.

If δ(qi, b) = (qj, c, R), then configurationuaqibv yieldsconfigurationuacqjv .

Special case (1): When head is at left end andtries to move left, it changes state and writes ontape butdoes not move, so if δ(qi, b) = (qj, c, L),configurationqibv yieldsqjcv.

Special case (2): What happens when head is atright end? We letwqi andwqi denotes the sameconfiguration, somoves to the rightcan now beaccomodated.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.9

Page 38: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

More Configurations

We have

starting configurationq0w

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.10

Page 39: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

More Configurations

We have

starting configurationq0w

accepting configurationw0qaw1

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.10

Page 40: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

More Configurations

We have

starting configurationq0w

accepting configurationw0qaw1

rejecting configurationw0qrw1

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.10

Page 41: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

More Configurations

We have

starting configurationq0w

accepting configurationw0qaw1

rejecting configurationw0qrw1

halting configurationsw0qaw1 andw0qrw1

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.10

Page 42: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Accepting a Language

A Turing machineM acceptsinput anw if there is asequence of configurationsC1, C2, . . . , Ck such that

C1 is start configuration ofM onw,

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.11

Page 43: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Accepting a Language

A Turing machineM acceptsinput anw if there is asequence of configurationsC1, C2, . . . , Ck such that

C1 is start configuration ofM onw,

eachCi yieldsCi+1,

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.11

Page 44: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Accepting a Language

A Turing machineM acceptsinput anw if there is asequence of configurationsC1, C2, . . . , Ck such that

C1 is start configuration ofM onw,

eachCi yieldsCi+1,

Ck is an accepting configuration.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.11

Page 45: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Accepting a Language

A Turing machineM acceptsinput anw if there is asequence of configurationsC1, C2, . . . , Ck such that

C1 is start configuration ofM onw,

eachCi yieldsCi+1,

Ck is an accepting configuration.

The collection of stringsaccepted byM is called the

languageof M , and is denotedL(M).

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.11

Page 46: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Enumerable Languages

Definition: A language is (recursively) enumerable ifsome Turing machine accepts it.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.12

Page 47: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Enumerable Languages (2)

On an input,w, a TM may

accept

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.13

Page 48: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Enumerable Languages (2)

On an input,w, a TM may

accept

reject

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.13

Page 49: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Enumerable Languages (2)

On an input,w, a TM may

accept

reject

loop (run forever)

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.13

Page 50: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Enumerable Languages (2)

On an input,w, a TM may

accept

reject

loop (run forever)

Major concern: In general, we never know if TMwillhalt.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.13

Page 51: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Decidable Languages

Definition: A TM decidesa language if for everyinputw ∈ Σ∗, the TM halts.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.14

Page 52: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Decidable Languages

Definition: A TM decidesa language if for everyinputw ∈ Σ∗, the TM halts.

Namely the TM either reaches stateqa (in casew ∈ L(M)) or it reaches stateqr (in casew /∈ L(M)),but it does not loop.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.14

Page 53: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Decidable Languages

Definition: A TM decidesa language if for everyinputw ∈ Σ∗, the TM halts.

Namely the TM either reaches stateqa (in casew ∈ L(M)) or it reaches stateqr (in casew /∈ L(M)),but it does not loop.

Definition: A language isdecidableif some Turingmachine decides it.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.14

Page 54: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Example

Here is a TM that decides{

aibjck|i × j = k wherei, j, k ≥ 1}

scan from left to right to check that input isa∗b∗c∗

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.15

Page 55: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Example

Here is a TM that decides{

aibjck|i × j = k wherei, j, k ≥ 1}

scan from left to right to check that input isa∗b∗c∗

return to start of tape

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.15

Page 56: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Example

Here is a TM that decides{

aibjck|i × j = k wherei, j, k ≥ 1}

scan from left to right to check that input isa∗b∗c∗

return to start of tape

cross off onea and scan right untilb occurs.Shuttle betweenb’s andc’s, crossing off one ofeach, until allb’s are gone.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.15

Page 57: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Example

Here is a TM that decides{

aibjck|i × j = k wherei, j, k ≥ 1}

scan from left to right to check that input isa∗b∗c∗

return to start of tape

cross off onea and scan right untilb occurs.Shuttle betweenb’s andc’s, crossing off one ofeach, until allb’s are gone.

Restore the crossed-offb’s and repeat previousstep if morea’s exist. If all a’s crossed off, checkif all c’s crossed off. If yes,accept, otherwisereject.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.15

Page 58: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Example (cont.)

Question: To implement algorithm, should be able totell when a TM is at the left end of the tape.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.16

Page 59: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Example (cont.)

Question: To implement algorithm, should be able totell when a TM is at the left end of the tape.Answer: Mark it with a special symbol.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.16

Page 60: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Example

Consider theelement distinctnessproblem

E = {#x1#x2# . . . #xℓ |eachxi ∈ {0, 1}∗ and for eachi 6= j, xi 6= xj} .

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.17

Page 61: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Example

Consider theelement distinctnessproblem

E = {#x1#x2# . . . #xℓ |eachxi ∈ {0, 1}∗ and for eachi 6= j, xi 6= xj} .

Verbally,

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.17

Page 62: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Example

Consider theelement distinctnessproblem

E = {#x1#x2# . . . #xℓ |eachxi ∈ {0, 1}∗ and for eachi 6= j, xi 6= xj} .

Verbally,

List of strings in{0, 1}∗ separated by#’s.

List is in language (& machineshouldaccept) ifall strings aredifferent.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.17

Page 63: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Element Distinctness – SolutionOn inputw

place a mark on leftmost tape symbol. If symbolnot#, reject.

#011#00#1111Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.18

Page 64: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Element Distinctness – Solution (2)

scan right to next# and place mark on top. Ifnone encountered, reject

#011#00#1111

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.19

Page 65: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Element Distinctness – Solution (3)

By zig-zagging, compare the two strings to theright of the marked#’s. If equal, reject.

#011#00#1111

Ok

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.20

Page 66: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Element Distinctness – Solution (4)

Move rightmost mark to next# on right, if any.

Otherwise move leftmost mark to next# on rightand rightmost mark to# after that.

If not possible, accept.

#011#00#1111Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.21

Page 67: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Element Distinctness – Solution (end)

Question: How do we “mark” a symbol?

Answer: For each tape symbol#, add tape symbol•

# to the tape alphabetΓ.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.22

Page 68: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

TMs VariantsAlternative Turing machine definitions abound.

For example, suppose the Turing machine head isallowed tostay put.

δ : Q × Γ → Q × Γ × {L,R, S}

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.23

Page 69: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

TMs VariantsAlternative Turing machine definitions abound.

For example, suppose the Turing machine head isallowed tostay put.

δ : Q × Γ → Q × Γ × {L,R, S}

Question: Does this add any power?

Answer: No. Replace eachS transition with twotransitions:R thenL. (Why not vice-versa?)

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.23

Page 70: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

TMs VariantsAlternative Turing machine definitions abound.

For example, suppose the Turing machine head isallowed tostay put.

δ : Q × Γ → Q × Γ × {L,R, S}

Question: Does this add any power?

Answer: No. Replace eachS transition with twotransitions:R thenL. (Why not vice-versa?)

Important notion here: Two-waysimulation(modelAcapable of simulating modelB; modelB capable ofsimulating modelA).

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.23

Page 71: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

MultitapeTuring Machines

each tape has its own head

initially, input string on tape 1 and rest blank

For the transition function:δ : Q × Γk → Q × Γk × {L,R}k ,

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.24

Page 72: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

MultitapeTuring Machines

each tape has its own head

initially, input string on tape 1 and rest blank

For the transition function:δ : Q × Γk → Q × Γk × {L,R}k , the expressionδ(qi, a1, . . . , ak) = (qj, b1, . . . , bk, L,R, . . . , L) means

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.24

Page 73: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

MultitapeTuring Machines

each tape has its own head

initially, input string on tape 1 and rest blank

For the transition function:δ : Q × Γk → Q × Γk × {L,R}k , the expressionδ(qi, a1, . . . , ak) = (qj, b1, . . . , bk, L,R, . . . , L) means

machine starts in stateqi

if heads1 throughk readinga1, . . . , ak,

then machine goes to stateqj,

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.24

Page 74: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

MultitapeTuring Machines

each tape has its own head

initially, input string on tape 1 and rest blank

For the transition function:δ : Q × Γk → Q × Γk × {L,R}k , the expressionδ(qi, a1, . . . , ak) = (qj, b1, . . . , bk, L,R, . . . , L) means

machine starts in stateqi

if heads1 throughk readinga1, . . . , ak,

then machine goes to stateqj,

heads1 thoughtk write b1, . . . , bk,

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.24

Page 75: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

MultitapeTuring Machines

each tape has its own head

initially, input string on tape 1 and rest blank

For the transition function:δ : Q × Γk → Q × Γk × {L,R}k , the expressionδ(qi, a1, . . . , ak) = (qj, b1, . . . , bk, L,R, . . . , L) means

machine starts in stateqi

if heads1 throughk readinga1, . . . , ak,

then machine goes to stateqj,

heads1 thoughtk write b1, . . . , bk,

and moves each headright or left as specified.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.24

Page 76: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Equivalence

Theorem: A language is enumerable if and only ifthere is somemultitapeTuring machine that accepts it.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.25

Page 77: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Equivalence

Theorem: A language is enumerable if and only ifthere is somemultitapeTuring machine that accepts it.

One direction is trivial.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.25

Page 78: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Equivalence

Theorem: A language is enumerable if and only ifthere is somemultitapeTuring machine that accepts it.

One direction is trivial.

To prove the other direction, we will show how toconvert amultitapeTM, M , into an equivalentsingle-tapeTM, S.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.25

Page 79: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Simulation

11 # a a a

11 ... ba ... x ...a

# x # ...

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.26

Page 80: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Simulation

11 # a a a

11 ... ba ... x ...a

# x # ...

S simulatesk tapes ofM by storing them all onasingle tapewith delimiter#.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.26

Page 81: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Simulation

11 # a a a

11 ... ba ... x ...a

# x # ...

S simulatesk tapes ofM by storing them all onasingle tapewith delimiter#.

S marks the current positions of thek heads byplacing• “above” the letters in current positions.It “knows” which tape the mark belongs to bycounting (up tok) from the#’s to the left.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.26

Page 82: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Simulation (2)

11 # a a a

11 ... ba ... x ...a

# x # ... On inputw = w1 · · ·wn, S:writes on its tape#

w1 w2 · wn# • # • # · · ·#

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.27

Page 83: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Simulation (2)

11 # a a a

11 ... ba ... x ...a

# x # ... On inputw = w1 · · ·wn, S:writes on its tape#

w1 w2 · wn# • # • # · · ·#

scans its tape from first# to k + 1-st# to read symbols

under “virtual” heads.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.27

Page 84: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Simulation (2)

11 # a a a

11 ... ba ... x ...a

# x # ... On inputw = w1 · · ·wn, S:writes on its tape#

w1 w2 · wn# • # • # · · ·#

scans its tape from first# to k + 1-st# to read symbols

under “virtual” heads.

rescans to write new symbols and move heads

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.27

Page 85: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Simulation (2)

11 # a a a

11 ... ba ... x ...a

# x # ... On inputw = w1 · · ·wn, S:writes on its tape#

w1 w2 · wn# • # • # · · ·#

scans its tape from first# to k + 1-st# to read symbols

under “virtual” heads.

rescans to write new symbols and move heads

S tries to move virtual head onto# whenM is trying to

move head onto unused blank square.S writes blank on

tape, and shifts rest of the tape one square to the right.Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.27

Page 86: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

RAMCPU

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.28

Page 87: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

RAMCPU

3 Registers (Instruction Register (IR), ProgramCounter (PC), Accumulator (ACC)

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.28

Page 88: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

RAMCPU

3 Registers (Instruction Register (IR), ProgramCounter (PC), Accumulator (ACC)

Memory

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.28

Page 89: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

RAMCPU

3 Registers (Instruction Register (IR), ProgramCounter (PC), Accumulator (ACC)

Memory

Operation:

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.28

Page 90: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

RAMCPU

3 Registers (Instruction Register (IR), ProgramCounter (PC), Accumulator (ACC)

Memory

Operation:Set IR→ MEM[PC]

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.28

Page 91: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

RAMCPU

3 Registers (Instruction Register (IR), ProgramCounter (PC), Accumulator (ACC)

Memory

Operation:Set IR→ MEM[PC]Increment PC

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.28

Page 92: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

RAMCPU

3 Registers (Instruction Register (IR), ProgramCounter (PC), Accumulator (ACC)

Memory

Operation:Set IR→ MEM[PC]Increment PCExecute instruction in IR

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.28

Page 93: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

RAMCPU

3 Registers (Instruction Register (IR), ProgramCounter (PC), Accumulator (ACC)

Memory

Operation:Set IR→ MEM[PC]Increment PCExecute instruction in IRRepeat

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.28

Page 94: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

RAM

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.29

Page 95: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

RAMInstruction Meaning

00 HALT Stop Computation

01 LOAD x ACC← MEM[x]

02 LOADI x ACC← x

03 STORE x MEM[x]← AC

04 ADD x ACC← ACC + MEM[x]

05 ADDI x ACC← ACC + x

06 SUB x ACC← ACC - MEM[x]

07 SUBI x ACC← ACC - x

08 JUMP x IP← x

09 JZERO x IP← x if ACC = 0

10 JGT x IP← x if ACC > 0

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.30

Page 96: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

RAMWrite a program that multiplies two numbers (inlocations 1000 & 1001), and stores the result in 1002

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.31

Page 97: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

RAMWrite a program that multiplies two numbers (inlocations 1000 & 1001), and stores the result in 1002

Memory Machine Code Assembly

0001 011000 LOAD 1000

0002 031003 STORE 1003

0003 020000 LOADI 0

0004 031002 STORE 1002

0005 021003 LOAD 1003

0006 090012 JZERO 0012

0007 070001 SUBI 1

0008 031003 STORE 1003

0009 011002 LOAD 1002

0010 041001 ADD 1001

0011 080004 STORE 1002

0012 000000 HALT

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.31

Page 98: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Computers & TMs

We can simulate this computer with a multi-tapTuring machine:

One tape for each register (IR, IP, ACC)

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.32

Page 99: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Computers & TMs

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.33

Page 100: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Computers & TMs

Operation:Scan through memory until reach an addressthat matches the IP

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.34

Page 101: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Computers & TMs

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.35

Page 102: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Computers & TMs

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.36

Page 103: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Computers & TMs

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.37

Page 104: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Computers & TMs

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.38

Page 105: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Computers & TMs

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.39

Page 106: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Computers & TMs

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.40

Page 107: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Computers & TMs

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.41

Page 108: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Computers & TMs

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.42

Page 109: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Computers & TMs

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.43

Page 110: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Computers & TMs

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.44

Page 111: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Computers & TMs

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.45

Page 112: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Computers & TMs

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.46

Page 113: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Computers & TMs

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.47

Page 114: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Computers & TMs

RAM can be modeled by a Turing Machine

Any current machine can be modeled in the sameway by a Turing Machine

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.48

Page 115: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Turing Complete

A computation formalism is “Turing Complete”if it can simulate a Turing Machine

Turing Complete⇒ can compute anything

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.49

Page 116: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Non-DeterministicTuring Machines

Transition function:

δ : Q × Γ → P(Q × Γ × {L,R})

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.50

Page 117: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Non-DeterministicTuring Machines

Transition function:

δ : Q × Γ → P(Q × Γ × {L,R})

Computation is atree.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.50

Page 118: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Non-DeterministicTuring Machines

Transition function:

δ : Q × Γ → P(Q × Γ × {L,R})

Computation is atree.

Accepts ifthere is(∃) an accepting branch.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.50

Page 119: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Equivalence

Theorem: A language is enumerable if and only ifthere is somenon-deterministicTuring machine thataccepts it.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.51

Page 120: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Equivalence

Theorem: A language is enumerable if and only ifthere is somenon-deterministicTuring machine thataccepts it.

One direction is trivial.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.51

Page 121: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Equivalence

Theorem: A language is enumerable if and only ifthere is somenon-deterministicTuring machine thataccepts it.

One direction is trivial.

To prove the other direction, we will show how toconvert anon-deterministicTM, N , into an equivalentdeterministicTM, D.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.51

Page 122: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Simulating Non-Determinism

Basic idea:

D tries all possible branches

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.52

Page 123: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Simulating Non-Determinism

Basic idea:

D tries all possible branches

If D finds anyacceptingbranch, itaccepts.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.52

Page 124: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Simulating Non-Determinism

Basic idea:

D tries all possible branches

If D finds anyacceptingbranch, itaccepts.

If all branchesreject, D rejects.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.52

Page 125: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Simulating Non-Determinism

Basic idea:

D tries all possible branches

If D finds anyacceptingbranch, itaccepts.

If all branchesreject, D rejects.

If all branchesreject or loop, D loops.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.52

Page 126: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Simulating Non-Determinism (2)

N ’s computation is a tree.

each tree branch is branch ofN ’snon-deterministic computation

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.53

Page 127: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Simulating Non-Determinism (2)

N ’s computation is a tree.

each tree branch is branch ofN ’snon-deterministic computation

each tree node is aconfigurationof N

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.53

Page 128: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Simulating Non-Determinism (2)

N ’s computation is a tree.

each tree branch is branch ofN ’snon-deterministic computation

each tree node is aconfigurationof N

root is starting configuration

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.53

Page 129: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Simulating Non-Determinism (2)

N ’s computation is a tree.

each tree branch is branch ofN ’snon-deterministic computation

each tree node is aconfigurationof N

root is starting configuration

the number of children of each node isat mostthe number ofN ’s states, denoted byb.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.53

Page 130: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Simulating Non-Determinism (2)

N ’s computation is a tree.

each tree branch is branch ofN ’snon-deterministic computation

each tree node is aconfigurationof N

root is starting configuration

the number of children of each node isat mostthe number ofN ’s states, denoted byb.

depth-first search doesn’t work (why?)

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.53

Page 131: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Simulating Non-Determinism (2)

N ’s computation is a tree.

each tree branch is branch ofN ’snon-deterministic computation

each tree node is aconfigurationof N

root is starting configuration

the number of children of each node isat mostthe number ofN ’s states, denoted byb.

depth-first search doesn’t work (why?)

breadth-first searchdoes work, as we’ll show.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.53

Page 132: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Simulating Non-Determinism (3)

11 ... ba ... 1 ...#

input tape(never altered)

simulationtape

addresstape

2 3 3

D has three tapes

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.54

Page 133: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Simulating Non-Determinism (3)

11 ... ba ... 1 ...#

input tape(never altered)

simulationtape

addresstape

2 3 3

D has three tapes

the input tape is never altered

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.54

Page 134: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Simulating Non-Determinism (3)

11 ... ba ... 1 ...#

input tape(never altered)

simulationtape

addresstape

2 3 3

D has three tapes

the input tape is never altered

the simulation tape is a copy ofN ’s tape

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.54

Page 135: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Simulating Non-Determinism (3)

11 ... ba ... 1 ...#

input tape(never altered)

simulationtape

addresstape

2 3 3

D has three tapes

the input tape is never altered

the simulation tape is a copy ofN ’s tape

the address tape keeps track ofD’s location inN ’s computation tree.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.54

Page 136: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Simulating Non-Determinism (4)

The address tape:

every node in the tree has at mostb children

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.55

Page 137: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Simulating Non-Determinism (4)

The address tape:

every node in the tree has at mostb children

every node in the tree is assigned an address thatis a string over the alphabetΣb = {1, 2, . . . , b}

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.55

Page 138: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Simulating Non-Determinism (4)

The address tape:

every node in the tree has at mostb children

every node in the tree is assigned an address thatis a string over the alphabetΣb = {1, 2, . . . , b}

to get to node with address231

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.55

Page 139: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Simulating Non-Determinism (4)

The address tape:

every node in the tree has at mostb children

every node in the tree is assigned an address thatis a string over the alphabetΣb = {1, 2, . . . , b}

to get to node with address231start at root

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.55

Page 140: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Simulating Non-Determinism (4)

The address tape:

every node in the tree has at mostb children

every node in the tree is assigned an address thatis a string over the alphabetΣb = {1, 2, . . . , b}

to get to node with address231start at roottakesecondchild of root

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.55

Page 141: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Simulating Non-Determinism (4)

The address tape:

every node in the tree has at mostb children

every node in the tree is assigned an address thatis a string over the alphabetΣb = {1, 2, . . . , b}

to get to node with address231start at roottakesecondchild of roottakethird child of current node

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.55

Page 142: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Simulating Non-Determinism (4)

The address tape:

every node in the tree has at mostb children

every node in the tree is assigned an address thatis a string over the alphabetΣb = {1, 2, . . . , b}

to get to node with address231start at roottakesecondchild of roottakethird child of current nodetakefirst child of current node

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.55

Page 143: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Simulating Non-Determinism (4)

The address tape:

every node in the tree has at mostb children

every node in the tree is assigned an address thatis a string over the alphabetΣb = {1, 2, . . . , b}

to get to node with address231start at roottakesecondchild of roottakethird child of current nodetakefirst child of current node

ignore meaningless addresses (choices notavailable for configuration along branch)

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.55

Page 144: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Simulating Non-Determinism (5)Initially, the input tape containsw, and the othertwo tapes are empty.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.56

Page 145: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Simulating Non-Determinism (5)Initially, the input tape containsw, and the othertwo tapes are empty.Copy input tape to simulation tape.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.56

Page 146: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Simulating Non-Determinism (5)Initially, the input tape containsw, and the othertwo tapes are empty.Copy input tape to simulation tape.Use simulation tape to simulateN on inputw ona finite portion of one non-deterministic branch.On each choice, consult the next symbol onaddress tape. Accept if accepting configurationreached. Skip to next step if

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.56

Page 147: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Simulating Non-Determinism (5)Initially, the input tape containsw, and the othertwo tapes are empty.Copy input tape to simulation tape.Use simulation tape to simulateN on inputw ona finite portion of one non-deterministic branch.On each choice, consult the next symbol onaddress tape. Accept if accepting configurationreached. Skip to next step if

symbols on address tape exhausted

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.56

Page 148: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Simulating Non-Determinism (5)Initially, the input tape containsw, and the othertwo tapes are empty.Copy input tape to simulation tape.Use simulation tape to simulateN on inputw ona finite portion of one non-deterministic branch.On each choice, consult the next symbol onaddress tape. Accept if accepting configurationreached. Skip to next step if

symbols on address tape exhaustednon-deterministic choice invalid

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.56

Page 149: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Simulating Non-Determinism (5)Initially, the input tape containsw, and the othertwo tapes are empty.Copy input tape to simulation tape.Use simulation tape to simulateN on inputw ona finite portion of one non-deterministic branch.On each choice, consult the next symbol onaddress tape. Accept if accepting configurationreached. Skip to next step if

symbols on address tape exhaustednon-deterministic choice invalidrejecting configuration reached

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.56

Page 150: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Simulating Non-Determinism (5)Initially, the input tape containsw, and the othertwo tapes are empty.Copy input tape to simulation tape.Use simulation tape to simulateN on inputw ona finite portion of one non-deterministic branch.On each choice, consult the next symbol onaddress tape. Accept if accepting configurationreached. Skip to next step if

symbols on address tape exhaustednon-deterministic choice invalidrejecting configuration reached

Replace string on address tape with thelexicographically nextstring. Jump to Step 2 tosimulate this branch ofN ’s computation. ♣

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.56

Page 151: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

DecidersDefinition: A non-deterministic TM is adeciderif onall inputs, all branches halt (in either stateqa or qr).

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.57

Page 152: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

DecidersDefinition: A non-deterministic TM is adeciderif onall inputs, all branches halt (in either stateqa or qr).

Theorem: A language isdecidableif and only ifthere is anon-deterministicTuring machine thatdecides it.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.57

Page 153: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

DecidersDefinition: A non-deterministic TM is adeciderif onall inputs, all branches halt (in either stateqa or qr).

Theorem: A language isdecidableif and only ifthere is anon-deterministicTuring machine thatdecides it.

Definition (reminder): A language isdecidableif some

deterministicTuring machine decides it.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.57

Page 154: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

EnumeratorsA language isenumerableif it is accepted by someTuring machine.But why enumerable?

1 010

aaabba

Definition: An enumeratoris a TM with a printer.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.58

Page 155: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

EnumeratorsA language isenumerableif it is accepted by someTuring machine.But why enumerable?

1 010

aaabba

Definition: An enumeratoris a TM with a printer.

TM sends strings to printer

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.58

Page 156: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

EnumeratorsA language isenumerableif it is accepted by someTuring machine.But why enumerable?

1 010

aaabba

Definition: An enumeratoris a TM with a printer.

TM sends strings to printer

may create infinite list of strings

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.58

Page 157: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

EnumeratorsA language isenumerableif it is accepted by someTuring machine.But why enumerable?

1 010

aaabba

Definition: An enumeratoris a TM with a printer.

TM sends strings to printer

may create infinite list of strings

TM enumeratesa language –all strings produced.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.58

Page 158: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

TheoremTheorem: A language isacceptedby some Turingmachine if and only if some enumeratorenumerates it.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.59

Page 159: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

TheoremTheorem: A language isacceptedby some Turingmachine if and only if some enumeratorenumerates it.

Will show

If E enumerates languageA, then some TMMacceptsA.

If M acceptsA, then some enumeratorEenumerates it.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.59

Page 160: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

TheoremClaim: If E enumerates languageA, then some TMM acceptsA.

On inputw, TM M

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.60

Page 161: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

TheoremClaim: If E enumerates languageA, then some TMM acceptsA.

On inputw, TM M

RunsE. Every timeE outputs a stringv, Mcompares it tow.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.60

Page 162: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

TheoremClaim: If E enumerates languageA, then some TMM acceptsA.

On inputw, TM M

RunsE. Every timeE outputs a stringv, Mcompares it tow.

If v = w, M accept.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.60

Page 163: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

TheoremClaim: If E enumerates languageA, then some TMM acceptsA.

On inputw, TM M

RunsE. Every timeE outputs a stringv, Mcompares it tow.

If v = w, M accept.

If v 6= w, M continues runningE.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.60

Page 164: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

TheoremClaim: If M acceptsA, then some enumeratorEenumerates it.

Let s1, s2, s3, . . . is a list of all strings inΣ∗ (e.g.strings in lexicographic order).The enumerator,E

repeat the following fori = 1, 2, 3, . . .

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.61

Page 165: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

TheoremClaim: If M acceptsA, then some enumeratorEenumerates it.

Let s1, s2, s3, . . . is a list of all strings inΣ∗ (e.g.strings in lexicographic order).The enumerator,E

repeat the following fori = 1, 2, 3, . . .

runM for i stepsoneachinputs1, s2, . . . , si.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.61

Page 166: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

TheoremClaim: If M acceptsA, then some enumeratorEenumerates it.

Let s1, s2, s3, . . . is a list of all strings inΣ∗ (e.g.strings in lexicographic order).The enumerator,E

repeat the following fori = 1, 2, 3, . . .

runM for i stepsoneachinputs1, s2, . . . , si.

if any computation accepts, print out thecorrespondings. ♣

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.61

Page 167: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

TheoremClaim: If M acceptsA, then some enumeratorEenumerates it.

Let s1, s2, s3, . . . is a list of all strings inΣ∗ (e.g.strings in lexicographic order).The enumerator,E

repeat the following fori = 1, 2, 3, . . .

runM for i stepsoneachinputs1, s2, . . . , si.

if any computation accepts, print out thecorrespondings. ♣

Note that with this procedure, each output isduplicatedinfinitely often.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.61

Page 168: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

TheoremClaim: If M acceptsA, then some enumeratorEenumerates it.

Let s1, s2, s3, . . . is a list of all strings inΣ∗ (e.g.strings in lexicographic order).The enumerator,E

repeat the following fori = 1, 2, 3, . . .

runM for i stepsoneachinputs1, s2, . . . , si.

if any computation accepts, print out thecorrespondings. ♣

Note that with this procedure, each output isduplicatedinfinitely often.

How can this duplication beavoided?Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.61

Page 169: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

What is an Algorithm?

Informally

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.62

Page 170: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

What is an Algorithm?

Informallya recipe

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.62

Page 171: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

What is an Algorithm?

Informallya recipea procedure

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.62

Page 172: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

What is an Algorithm?

Informallya recipea procedurea computer program

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.62

Page 173: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

What is an Algorithm?

Informallya recipea procedurea computer programwho cares? I know it when I see it⌢

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.62

Page 174: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

What is an Algorithm?

Informallya recipea procedurea computer programwho cares? I know it when I see it⌢

Historically,

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.62

Page 175: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

What is an Algorithm?

Informallya recipea procedurea computer programwho cares? I know it when I see it⌢

Historically,notion has long history in Mathematics(starting withEuclid’s gcd algorithm), but

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.62

Page 176: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

What is an Algorithm?

Informallya recipea procedurea computer programwho cares? I know it when I see it⌢

Historically,notion has long history in Mathematics(starting withEuclid’s gcd algorithm), butnot precisely defined until 20th century

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.62

Page 177: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

What is an Algorithm?

Informallya recipea procedurea computer programwho cares? I know it when I see it⌢

Historically,notion has long history in Mathematics(starting withEuclid’s gcd algorithm), butnot precisely defined until 20th centuryinformal notions rarely questioned,

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.62

Page 178: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

What is an Algorithm?

Informallya recipea procedurea computer programwho cares? I know it when I see it⌢

Historically,notion has long history in Mathematics(starting withEuclid’s gcd algorithm), butnot precisely defined until 20th centuryinformal notions rarely questioned,still, they were insufficient

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.62

Page 179: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

RemarksMany models have been proposed forgeneral-purpose computation.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.63

Page 180: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

RemarksMany models have been proposed forgeneral-purpose computation.

Remarkably, all “reasonable” models areequivalent to Turing machines.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.63

Page 181: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

RemarksMany models have been proposed forgeneral-purpose computation.

Remarkably, all “reasonable” models areequivalent to Turing machines.

All “reasonable” programming languages (e.g.Java, Pascal, C,Scheme, Mathematica, Maple, Cobol,. . . )are equivalent.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.63

Page 182: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

RemarksMany models have been proposed forgeneral-purpose computation.

Remarkably, all “reasonable” models areequivalent to Turing machines.

All “reasonable” programming languages (e.g.Java, Pascal, C,Scheme, Mathematica, Maple, Cobol,. . . )are equivalent.

The notion of analgorithmismodel-independent!

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.63

Page 183: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

RemarksMany models have been proposed forgeneral-purpose computation.

Remarkably, all “reasonable” models areequivalent to Turing machines.

All “reasonable” programming languages (e.g.Java, Pascal, C,Scheme, Mathematica, Maple, Cobol,. . . )are equivalent.

The notion of analgorithmis model-independent!

We don’t really care about Turing machinesperse, we care about understanding computation.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.63

Page 184: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Church-Turing Thesis

Formal notionsappeared in 1936:

λ-calculusof Alonzo Church

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.64

Page 185: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Church-Turing Thesis

Formal notionsappeared in 1936:

λ-calculusof Alonzo Church

Turing machinesof Alan Turing

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.64

Page 186: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Church-Turing Thesis

Formal notionsappeared in 1936:

λ-calculusof Alonzo Church

Turing machinesof Alan Turing

Recursivefunctions of Godel and Kleene

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.64

Page 187: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Church-Turing Thesis

Formal notionsappeared in 1936:

λ-calculusof Alonzo Church

Turing machinesof Alan Turing

Recursivefunctions of Godel and Kleene

Countermachines

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.64

Page 188: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Church-Turing Thesis

Formal notionsappeared in 1936:

λ-calculusof Alonzo Church

Turing machinesof Alan Turing

Recursivefunctions of Godel and Kleene

Countermachines

Unrestrictedgrammars

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.64

Page 189: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Church-Turing Thesis

Formal notionsappeared in 1936:

λ-calculusof Alonzo Church

Turing machinesof Alan Turing

Recursivefunctions of Godel and Kleene

Countermachines

Unrestrictedgrammars

Two stackautomata

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.64

Page 190: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Church-Turing Thesis

Formal notionsappeared in 1936:

λ-calculusof Alonzo Church

Turing machinesof Alan Turing

Recursivefunctions of Godel and Kleene

Countermachines

Unrestrictedgrammars

Two stackautomata

Random accessmachines (RAMs)

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.64

Page 191: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Church-Turing Thesis

Formal notionsappeared in 1936:

λ-calculusof Alonzo Church

Turing machinesof Alan Turing

Recursivefunctions of Godel and Kleene

Countermachines

Unrestrictedgrammars

Two stackautomata

Random accessmachines (RAMs)...

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.64

Page 192: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Church-Turing Thesis

Formal notionsappeared in 1936:

λ-calculusof Alonzo Church

Turing machinesof Alan Turing

Recursivefunctions of Godel and Kleene

Countermachines

Unrestrictedgrammars

Two stackautomata

Random accessmachines (RAMs)...These definitions look very different, but are provablyequivalent.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.64

Page 193: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Church-Turing Thesis

These definitions look very different, but are provablyequivalent.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.65

Page 194: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Church-Turing Thesis

These definitions look very different, but are provablyequivalent.

The Church-Turing Thesis:

“The intuitive notion of reasonable models ofcomputation equals Turing machinealgorithms”.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.65

Page 195: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Wild ModelsWhat about “wild” models of computation?Consider MUntel’sℵ-AXP2 c© processor (to bereleased XMAS 2004).

Like a Turing machine, except

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.66

Page 196: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Wild ModelsWhat about “wild” models of computation?Consider MUntel’sℵ-AXP2 c© processor (to bereleased XMAS 2004).

Like a Turing machine, except

Takes first step in1 second.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.66

Page 197: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Wild ModelsWhat about “wild” models of computation?Consider MUntel’sℵ-AXP2 c© processor (to bereleased XMAS 2004).

Like a Turing machine, except

Takes first step in1 second.

Takes second step in1/2 second.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.66

Page 198: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Wild ModelsWhat about “wild” models of computation?Consider MUntel’sℵ-AXP2 c© processor (to bereleased XMAS 2004).

Like a Turing machine, except

Takes first step in1 second.

Takes second step in1/2 second.

Takesi-th step in2−i seconds . . .

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.66

Page 199: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Wild ModelsWhat about “wild” models of computation?Consider MUntel’sℵ-AXP2 c© processor (to bereleased XMAS 2004).

Like a Turing machine, except

Takes first step in1 second.

Takes second step in1/2 second.

Takesi-th step in2−i seconds . . .

After 2 seconds, theℵ-AXP c© decidesany enumerablelanguage!

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.66

Page 200: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Wild ModelsWhat about “wild” models of computation?Consider MUntel’sℵ-AXP2 c© processor (to bereleased XMAS 2004).

Like a Turing machine, except

Takes first step in1 second.

Takes second step in1/2 second.

Takesi-th step in2−i seconds . . .

After 2 seconds, theℵ-AXP c© decidesany enumerablelanguage!

Question: Does theℵ-AXP c© invalidate theChurch-Turing Thesis?

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.66

Page 201: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Hilbert’s 10th ProblemIn 1900, David Hilbert delivered a now-famousaddress at the International Congress ofMathematicians in Paris, France.

Presented23 central mathematical problems

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.67

Page 202: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Hilbert’s 10th ProblemIn 1900, David Hilbert delivered a now-famousaddress at the International Congress ofMathematicians in Paris, France.

Presented23 central mathematical problems

challenge for the next (20th) century

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.67

Page 203: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Hilbert’s 10th ProblemIn 1900, David Hilbert delivered a now-famousaddress at the International Congress ofMathematicians in Paris, France.

Presented23 central mathematical problems

challenge for the next (20th) century

the10th problemdirectly concerned algorithms

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.67

Page 204: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Hilbert’s 10th ProblemIn 1900, David Hilbert delivered a now-famousaddress at the International Congress ofMathematicians in Paris, France.

Presented23 central mathematical problems

challenge for the next (20th) century

the10th problemdirectly concerned algorithms

November 2003: significant progress onthe6th problem.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.67

Page 205: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Hilbert’s 10th ProblemIn 1900, David Hilbert delivered a now-famousaddress at the International Congress ofMathematicians in Paris, France.

Presented23 central mathematical problems

challenge for the next (20th) century

the10th problemdirectly concerned algorithms

November 2003: significant progress onthe6th problem.

But for us, start with some background onthe10th . . .

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.67

Page 206: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Hilbert’s 10th Problems

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.68

Page 207: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Hilbert’s 10th Problems

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.68

Page 208: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Hilbert’s 10th Problems

Too much beer last night? We are supposed to talkaboutD. Hilbert’s problems, not ’boutDilbert’sproblems, ...

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.68

Page 209: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Polynomials

A termis a product ofvariablesand a constantcoefficient, e.g. 6x3yz2.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.69

Page 210: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Polynomials

A termis a product ofvariablesand a constantcoefficient, e.g. 6x3yz2.

A polynomialis a sum of terms,e.g.6x3yz2 + 3xy2 − x3 − 10 .

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.69

Page 211: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Polynomials

A termis a product ofvariablesand a constantcoefficient, e.g. 6x3yz2.

A polynomialis a sum of terms,e.g.6x3yz2 + 3xy2 − x3 − 10 .

A rootof a polynomial is an assignment of valuesto variables so that the polynomial equalszero.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.69

Page 212: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Polynomials

A termis a product ofvariablesand a constantcoefficient, e.g. 6x3yz2.

A polynomialis a sum of terms,e.g.6x3yz2 + 3xy2 − x3 − 10 .

A rootof a polynomial is an assignment of valuesto variables so that the polynomial equalszero.

For example,x = 5, y = 3, andz = 0 is a root ofthe polynomial above.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.69

Page 213: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Polynomials

A termis a product ofvariablesand a constantcoefficient, e.g. 6x3yz2.

A polynomialis a sum of terms,e.g.6x3yz2 + 3xy2 − x3 − 10 .

A rootof a polynomial is an assignment of valuesto variables so that the polynomial equalszero.

For example,x = 5, y = 3, andz = 0 is a root ofthe polynomial above.

Here, we are interested inintegralroots, namelyan assignment ofintegersto all variables.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.69

Page 214: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Polynomials

A termis a product ofvariablesand a constantcoefficient, e.g. 6x3yz2.

A polynomialis a sum of terms,e.g.6x3yz2 + 3xy2 − x3 − 10 .

A rootof a polynomial is an assignment of valuesto variables so that the polynomial equalszero.

For example,x = 5, y = 3, andz = 0 is a root ofthe polynomial above.

Here, we are interested inintegralroots, namelyan assignment ofintegersto all variables.

Some polynomials have integral roots, somedon’t (e.g. x2 − 2).

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.69

Page 215: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Hilbert’s Tenth Problem

The Problem:Devise an algorithm that tests whether apolynomial has an integral root.

Actually, what he said (translated from German) was

“to devise a process according to which itcan be determined by a finite number ofoperations”.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.70

Page 216: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Hilbert’s Tenth Problem

The Problem:Devise an algorithm that tests whether apolynomial has an integral root.

Actually, what he said (translated from German) was

“to devise a process according to which itcan be determined by a finite number ofoperations”.

Note that

Hilbert explicitly asks that algorithm be“devised”

apparently Hilbert assumes that such an algorithmmust exist, and someone “only” need find it.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.70

Page 217: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Hilbert’s Tenth ProblemWe now know no algorithm exists for this task.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.71

Page 218: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Hilbert’s Tenth ProblemWe now know no algorithm exists for this task.

Mathematicians of 1900 could not have provedthis, because they didn’t have aformal notionofan algorithm.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.71

Page 219: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Hilbert’s Tenth ProblemWe now know no algorithm exists for this task.

Mathematicians of 1900 could not have provedthis, because they didn’t have aformal notionofan algorithm.

Intuitive notionswork fine forconstructingalgorithms (we know one when we see it).

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.71

Page 220: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Hilbert’s Tenth ProblemWe now know no algorithm exists for this task.

Mathematicians of 1900 could not have provedthis, because they didn’t have aformal notionofan algorithm.

Intuitive notionswork fine forconstructingalgorithms (we know one when we see it).

Formal notionsare required to show thatnoalgorithm exists.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.71

Page 221: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Hilbert’s Tenth Problem

In 1970,23 years oldYuri Matijasevic, building onwork of Martin Davis, Hilary Putnam, andJuliaRobinson, proved thatno algorithmexists for testingwhether a polynomial has integral roots(a survey of the proof)

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.72

Page 222: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Reformulating Hilbert’s Tenth Problem

Consider the language:

D = {p | p is a polynomial with an integral root}

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.73

Page 223: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Reformulating Hilbert’s Tenth Problem

Consider the language:

D = {p | p is a polynomial with an integral root}

Hilbert’s tenth problem asks whether this language isdecidable.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.73

Page 224: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Reformulating Hilbert’s Tenth Problem

Consider the language:

D = {p | p is a polynomial with an integral root}

Hilbert’s tenth problem asks whether this language isdecidable.

We now know it isnot decidable, but it isenumerable!

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.73

Page 225: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Univariate Polynomials

Consider thesimplerlanguage:

D1 = {p | p is a polynomialoverx with an integral root}

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.74

Page 226: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Univariate Polynomials

Consider thesimplerlanguage:

D1 = {p | p is a polynomialoverx with an integral root}

Here is a Turing machine thatacceptsD1.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.74

Page 227: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Univariate Polynomials

Consider thesimplerlanguage:

D1 = {p | p is a polynomialoverx with an integral root}

Here is a Turing machine thatacceptsD1.On inputp,

evaluatep with x set successively to0, 1,−1, 2,−2, . . ..

if p evaluates to zero,accept.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.74

Page 228: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Univariate Polynomials (2)

D1 = {p | p is a polynomialoverx with an integral root}

Note that

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.75

Page 229: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Univariate Polynomials (2)

D1 = {p | p is a polynomialoverx with an integral root}

Note that

If p has an integral root, the machineaccepts.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.75

Page 230: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Univariate Polynomials (2)

D1 = {p | p is a polynomialoverx with an integral root}

Note that

If p has an integral root, the machineaccepts.

If not, M1 loops.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.75

Page 231: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Univariate Polynomials (2)

D1 = {p | p is a polynomialoverx with an integral root}

Note that

If p has an integral root, the machineaccepts.

If not, M1 loops.

M1 is anacceptor, butnot a decider.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.75

Page 232: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Univariate Polynomials (3)

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.76

Page 233: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Univariate Polynomials (4)

In fact,D1 is decidable.

Can show that all real roots ofp[x] lie inside interval

( −|kcmax/c1|, |kcmax/c1| ) ,

wherek is number of terms,cmax is max coefficient,andc1 is high-order coefficient.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.77

Page 234: Turing Machines - TAUbchor/CM05/Compute6.pdf · configuration qibv yields qjcv. Special case (2): What happens when head is at right end? We let wqi and wqi denotes the same configuration,

Univariate Polynomials (4)

In fact,D1 is decidable.

Can show that all real roots ofp[x] lie inside interval

( −|kcmax/c1|, |kcmax/c1| ) ,

wherek is number of terms,cmax is max coefficient,andc1 is high-order coefficient.

By Matijasevic theorem, such effective bounds onrange of real roots cannot be computed formultivariable polynomials.

Slides modified by Benny Chor, based on original slides by David Galles, Univ. of San Francisco, and Maurice Herlihy, Brown Univ. – p.77