Turing’s Thesis
Fall 2005 Costas Busch - RPI 1
Turing’s thesis:
Any computation carried out
by mechanical means
can be performed by a Turing Machine
(1930)
Fall 2005 Costas Busch - RPI 2
Computer Science Law:
A computation is mechanical
if and only if
it can be performed by a Turing Machine
There is no known model of computation
more powerful than Turing Machines
Fall 2005 Costas Busch - RPI 3
Definition of Algorithm:
An algorithm for function f (w)
is a
Turing Machine which computes f (w)
Fall 2005 Costas Busch - RPI 4
Algorithms are Turing Machines
When we say:
There exists an algorithm
We mean:
There exists a Turing Machine
that executes the algorithm
Fall 2005 Costas Busch - RPI 5
Variations
of the
Turing Machine
Fall 2005 Costas Busch - RPI 6
The Standard Model
Infinite Tape
aababbcac a
Read-Write Head (Left or Right)
Control Unit
Deterministic
Fall 2005 Costas Busch - RPI 7
Variations of the Standard Model
Turing machines with: • Stay-Option
• Semi-Infinite Tape
• Off-Line
• Multitape
• Multidimensional
• Nondeterministic
Fall 2005 Costas Busch - RPI 8
The variations form different
Turing Machine Classes
Same Power of two classes means:
Both classes of Turing machines accept
the same set of languages
We want to prove:
Each Class has the same power
with the Standard Turing Machine Model
Fall 2005 Costas Busch - RPI 9
Same Power of two classes means:
For any machine M1 of first class
there is a machine M 2 of second class
such that: L( M1 ) L( M 2 )
And vice-versa
Fall 2005 Costas Busch - RPI 10
Simulation: a technique to prove same power
Simulate the machine of one class
with a machine of the other class
Second Class
First Class Simulation Machine
Original Machine M2
M1 M1
Fall 2005 Costas Busch - RPI 11
Configurations in the Original Machine M1
have corresponding configurations
in the Simulation Machine M 2
M1
Original Machine: d0 d1 d n
Simulation Machine: d 0 d1 d n
M2
Fall 2005 Costas Busch - RPI 12
Final Configuration
Original Machine: df
Simulation Machine: d f
The Simulation Machine
and the Original Machine
accept the same language
Fall 2005 Costas Busch - RPI 13
Turing Machines with Stay-Option
The head can stay in the same position
aababbcac a
Left, Right, Stay
L,R,S: possible head moves
Fall 2005 Costas Busch - RPI 14
Example: Time 1
aababbcac a
q1
Time 2
b ab abb c ac a
q2
q1 a b, S q2
Fall 2005 Costas Busch - RPI 15
Theorem: Stay-Option machines
have the same power with
Standard Turing machines
Proof: 1. Stay-Option Machines
simulate Standard Turing machines
2. Standard Turing machines
simulate Stay-Option machines
Fall 2005 Costas Busch - RPI 16
1. Stay-Option Machines
simulate Standard Turing machines
Trivial: any standard Turing machine
is also a Stay-Option machine
Fall 2005 Costas Busch - RPI 17
2. Standard Turing machines
simulate Stay-Option machines
We need to simulate the stay head option
with two head moves, one left and one right
Fall 2005 Costas Busch - RPI 18
Stay-Option Machine
a b, S
q1 q2
Simulation in Standard Machine
a b, L x x, R
q1 q2
For every possible symbol x
Fall 2005 Costas Busch - RPI 19
For other transitions nothing changes
Stay-Option Machine
a b, L
q1 q2
Simulation in Standard Machine
a b, L
q1 q2
Similar for Right moves
Fall 2005 Costas Busch - RPI 20
example of simulation
Stay-Option Machine:
q1 a b , S q2 aaba baba
1 2
q1 q2
Simulation in Standard Machine:
aaba baba baba
1 2 3
q1 q2 q3
END OF PROOF
Fall 2005 Costas Busch - RPI 21
Standard Machine
Multiple Track Tape
A useful trick to perform more
complicated simulations
a b a b track 1
b a c d track 2
One head
One symbol (a, b)
Fall 2005 Costas Busch - RPI 22
a b a b track 1
b a c d track 2
q1
a c a b track 1
b d c d track 2
q2
(b, a ) (c, d ), L
q1 q2
Fall 2005 Costas Busch - RPI 23
Semi-Infinite Tape
The head extends infinitely only to the right
a b a c .........
• Initial position is the leftmost cell
• When the head moves left from the border,
it returns to the same position
Fall 2005 Costas Busch - RPI 24
Theorem: Semi-Infinite machines
have the same power with
Standard Turing machines
Proof: 1. Standard Turing machines
simulate Semi-Infinite machines
2. Semi-Infinite Machines
simulate Standard Turing machines
Fall 2005 Costas Busch - RPI 25
1. Standard Turing machines simulate
Semi-infinite machines:
# a b a c
Standard Turing Machine
a. Move input string to the right,
and insert special symbol #
Modify Semi-Infinite Machine
b. Add a self loop ## , R
to every state
(except states with no
outgoing transitions)
Fall 2005 Costas Busch - RPI 26
2. Semi-infinite tape machines simulate
Standard Turing machines:
Standard machine
......... .........
Semi-infinite tape machine
.........
Squeeze infinity to two directions
to infinity in one direction
Fall 2005 Costas Busch - RPI 27
Standard machine
......... a b c d e .........
reference point
Semi-infinite tape machine with two tracks
Right part # d e .........
Left part # c b a
Fall 2005 Costas Busch - RPI 28
Standard machine
q2
q1
Semi-infinite tape machine
Left part Right part
L R
q2 R q2
L
q1 q1
Fall 2005 Costas Busch - RPI 29
Standard machine
a g, R
q1 q2
Semi-infinite tape machine
R ( a, x ) ( g , x), R R
Right part q1 q2
L ( x, a ) ( x, g ), L L
Left part q1 q2
For all symbols x
Fall 2005 Costas Busch - RPI 30
Time 1
Standard machine
......... a b c d e .........
q1
Semi-infinite tape machine
Right part # d e .........
Left part # c b a
L
q1
Fall 2005 Costas Busch - RPI 31
Time 2
Standard machine
......... g b c d e .........
q2
Semi-infinite tape machine
Right part # d e .........
Left part # c b g
L
q2
Fall 2005 Costas Busch - RPI 32
At the border:
Semi-infinite tape machine
Right part R (# , # ) (# , # ), R L
q1 q1
Left part L (# , # ) (# , # ), R R
q1 q1
Fall 2005 Costas Busch - RPI 33
Semi-infinite tape machine
Time 1
Right part # d e .........
Left part # c b g
L
q1
Time 2
Right part # d e .........
Left part # c b g
R
q1
END OF PROOF
Fall 2005 Costas Busch - RPI 34
The Off-Line Machine
Input File read-only (once)
a b c
Input string
Input string
Appears on
input file only
Control Unit
(state machine)
Tape read-write
g d e
Fall 2005 Costas Busch - RPI 35
Theorem: Off-Line machines
have the same power with
Standard Turing machines
Proof: 1. Off-Line machines
simulate Standard Turing machines
2. Standard Turing machines
simulate Off-Line machines
Fall 2005 Costas Busch - RPI 36
1. Off-line machines simulate
Standard Turing Machines
Off-line machine does the following:
1. Copy input file to tape
2. Continue computation as in
Standard Turing machine
Fall 2005 Costas Busch - RPI 37
Standard machine
a b c
Off-line machine
Input File Tape
a b c a b c
1. Copy input file to tape
Fall 2005 Costas Busch - RPI 38
Standard machine
a b c
q1
Off-line machine
Input File Tape
a b c a b c
q1
2. Do computations as in Turing machine
Fall 2005 Costas Busch - RPI 39
2. Standard Turing machines simulate
Off-Line machines:
Use a Standard machine with
a four-track tape to keep track of
the Off-line input file and tape contents
Fall 2005 Costas Busch - RPI 40
Off-line Machine
Input File Tape
a b c d e f g
Standard Machine -- Four track tape
# a b c d Input File
# 0 0 1 0 head position
e f g Tape
0 1 0 head position
Fall 2005 Costas Busch - RPI 41
Reference point (uses special symbol # )
# a b c d Input File
# 0 0 1 0 head position
# e f g Tape
# 0 1 0 head position
Repeat for each state transition:
1. Return to reference point
2. Find current input file symbol
3. Find current tape symbol
4. Make transition
Fall 2005 Costas Busch - RPI END OF PROOF 42
Multitape Turing Machines
Control unit
(state machine)
Tape 1 Tape 2
a b c e f g
Input string
Input string appears on Tape 1
Fall 2005 Costas Busch - RPI 43
Tape 1 Time 1 Tape 2
a b c e f g
q1 q1
Tape 1 Time 2 Tape 2
a g c e d g
q2 q2
(b, f ) ( g , d ), L, R
q1 q2
Fall 2005 Costas Busch - RPI 44
Theorem: Multitape machines
have the same power with
Standard Turing machines
Proof: 1. Multitape machines
simulate Standard Turing machines
2. Standard Turing machines
simulate Multitape machines
Fall 2005 Costas Busch - RPI 45
1. Multitape machines simulate
Standard Turing Machines:
Trivial: Use just one tape
Fall 2005 Costas Busch - RPI 46
2. Standard Turing machines simulate
Multitape machines:
Simulation in Standard machine:
• Uses a multi-track tape to simulate
the multiple tapes
• A tape of the Multiple tape machine
corresponds to a pair of tracks
Fall 2005 Costas Busch - RPI 47
Multitape Machine
Tape 1 Tape 2
a b c e f g h
Standard machine with four track tape
a b c Tape 1
0 1 0 head position
e f g h Tape 2
0 0 1 0 head position
Fall 2005 Costas Busch - RPI 48
Reference point
a b c Tape 1
#
# 0 1 0 head position
# e f g h Tape 2
# 0 0 1 0 head position
Repeat for each state transition:
1. Return to reference point
2. Find current symbol in Tape 1
3. Find current symbol in Tape 2
4. Make transition
END OF PROOF
Fall 2005 Costas Busch - RPI 49
Same power doesn’t imply same speed:
n n
Language L {a b }
Acceptance Time
(number of transitions followed)
2
Standard Turing machine n
Two-tape machine n
Fall 2005 Costas Busch - RPI 50
n n
L {a b }
Standard Turing machine:
2
Go back and forth O(n ) times
Tto match the a’s with the b’s
Two-tape machine:
n
1. Copy b to tape 2 (O(n) steps)
n
2. Compare a on tape 1
n (O(n) steps)
and b tape 2
Fall 2005 Costas Busch - RPI 51
MultiDimensional Turing Machines
Two-dimensional tape y
c a x
b
MOVES: L,R,U,D HEAD
U: up D: down Position: +2, -1
Fall 2005 Costas Busch - RPI 52
Theorem: MultiDimensional machines
have the same power with
Standard Turing machines
Proof: 1. MultiDimensional machines
simulate Standard Turing machines
2. Standard Turing machines
simulate Multi-Dimensional machines
Fall 2005 Costas Busch - RPI 53
1. Multidimensional machines simulate
Standard Turing machines
Trivial: Use one dimension
Fall 2005 Costas Busch - RPI 54
2. Standard Turing machines simulate
MultiDimensional machines
Simulation in Standard machine:
• Use a two track tape
• Store symbols in track 1
• Store coordinates in track 2
Fall 2005 Costas Busch - RPI 55
2-dimensional machine
y
c a x
b
Standard Machine q1
a b c symbols
1 # 1 # 2 # 1 # 1 coordinates
Fall 2005 q1 Costas Busch - RPI 56
Standard machine:
Repeat for each transition
of the 2-dimensional machine
1. Update current symbol
2. Compute coordinates of next position
3. Go to new position
END OF PROOF
Fall 2005 Costas Busch - RPI 57
NonDeterministic Turing Machines
a b, L q2
q1
a c, R q3
Allows Non Deterministic Choices
Fall 2005 Costas Busch - RPI 58
a b, L q2
Time 0
q1
a b c
a c, R q3 q1
Time 1
Choice 1 Choice 2
b b c c b c
q2 q3
Fall 2005 Costas Busch - RPI 59
Input string w is accepted if
this is a possible computation
q0 w x q f y
Initial configuration Final Configuration
Accept state
There is a computation:
Fall 2005 Costas Busch - RPI 60
Theorem: NonDeterministic machines
have the same power with
Standard Turing machines
Proof: 1. NonDeterministic machines
simulate Standard Turing machines
2. Standard Turing machines
simulate NonDeterministic machines
Fall 2005 Costas Busch - RPI 61
1. NonDeterministic Machines simulate
Standard (deterministic) Turing Machines
Trivial: every deterministic machine
is also nondeterministic
Fall 2005 Costas Busch - RPI 62
2. Standard (deterministic) Turing machines
simulate NonDeterministic machines:
Deterministic machine:
• Uses a 2-dimensional tape
(which is equivalent to 1-dimensional tape,
see previous slides)
• Stores all possible computations
of the non-deterministic machine
on the 2-dimensional tape
Fall 2005 Costas Busch - RPI 63
All Possible computation paths
Initial state
Step 1
Step 2
Step i
reject accept
Step i+1
Fall 2005 Costas Busch - RPI 64
NonDeterministic machine
Time 0
a b, L q2
a b c
q1
q1
a c, R q3
Deterministic machine
# # # # # #
# a b c # Computation 1
# q1 #
# # # # #
Fall 2005 Costas Busch - RPI 65
NonDeterministic machine
Time 1
b b c Choice 1
a b, L q2
q2
q1
c b c Choice 2
a c, R q3 q3
Deterministic machine
# # # # # #
# b b c # Computation 1
# q2 #
# c b c #
q3 Computation 2
# #
Fall 2005 Costas Busch - RPI 66
The Deterministic Turing machine
simulates all possible computations:
• Step by step
• Simultaneously all possible computations
in each step
Fall 2005 Costas Busch - RPI 67
Deterministic Turing machine
Repeat
For each configuration in current step
of non-deterministic machine,
if there are two or more choices:
1. Replicate configuration
2. Change the state in the replica
Until the string is accepted
Or rejected in all configurations
END OF PROOF
Fall 2005 Costas Busch - RPI 68
Remark:
The simulation in the Deterministic machine
takes in the worst case exponential time for
accepting a string compared to an accepting
computation in the NonDeterministic machine
Fall 2005 Costas Busch - RPI 69