Académique Documents
Professionnel Documents
Culture Documents
Turing Machines
Andrej Bogdanov
http://www.cse.cuhk.edu.hk/~andrejb/csc3130
What is a computer?
program
input
computer output
deep blue
?
E2-E4
?
computer
Turing Machines
head
control
a b b ☐ ☐ …
input blanks
Strategy:
Read and remember the first symbol abbaa#abbaa
Strategy:
Look for the first uncrossed symbol xbbaa#xbbaa
q1
a/bL q2
a b a ☐ …
new state
q1
a/bL q2
a b b ☐ …
Formal Definition
A Turing Machine is (Q, , , , q0, qacc, qrej):
– Q is a finite set of states;
– is the input alphabet not containing the blank symbol ☐
– is the tape alphabet ( ) including ☐
– q0 in Q is the start state;
– qacc, qrej in Q are the accepting and rejecting state
– is the transition function
: (Q – {qacc, qrej}) → Q {L, R}
configuration
q1
a b a ☐ … abq1a
q1
a/bR qacc
qacc abbqacc
a b b ☐ …
Configurations
• We say configuration C yields C’ if the TM can go
from C to C’ in one step
abq1a yields abbqacc
qacc qrej
Ck is accepting
C0 is starting Ci yields Ci+1
or rejecting
#/#R a/aL
qa1 qa2 a/aL
4 b/bL
x/xR x/xL b/bL
#/#L
q0 #/#R
1 q1 ☐/☐R qacc q2 q3 qrej
8
7
everything else
4
qb1 qb2
#/#R
a/aR x/xR
b/bR
x/xR
Programming Turing Machines
a/aR input: aab#aab
b/bR x/xR
configurations:
#/#R a/aL
qa1
4
qa2
b/bL a/aL q0aab#aab
x/xR x/xL b/bL xqa1ab#aab
#/#R #/#L xaqa1b#aab
q0 q1 ☐/☐R qacc q2 q3
1
8
7 xabqa1#aab
xab#qa2aab
qb1 4
qb2 xabq2#xab
#/#R xaq3b#xab
a/aR x/xR xq3ab#xab
b/bR
q3xab#xab
x/xR xq0ab#xab
Programming Turing Machines
L2 = {aibjck: i × j = k and i, j, k > 0 }
aabbcccc
High-level description of TM:
For every a: aabbcccc
Cross off the same number of bs and cs aabbcccc
Uncross the crossed bs (but not the cs) aabbcccc
Cross off this a aabbcccc
If all as and cs are crossed off, accept. aabbcccc
aabbcccc
= {a, b, c} = {a, b, c, a, b, c, ☐} aabbcccc
Programming Turing Machines
L2 = {aibjck: i × j = k and i, j, k > 0 }
Replace b by b aabqbcccc
Replace c by c aabqbcccc
aabbqcccc
= {a, b, c} = {a, b, c, a, b, c, a, a, ☐}
Programming Turing Machines
On input w,
For every pair of blocks xi and xj in w,
Compare the blocks xi and xj
If they are the same, reject.
Otherwise, accept.
Programming Turing Machines
5. Repeat Step 3
#01#0011#1
Programming Turing Machines
(1,2,3,4)((1,4),(2,3),(3,4)(4,2))
1 2
Convention for describing graphs:
(nodes)(edges)
3 4 no node must repeat
edges are pairs (node1,node2)
Programming Turing Machines
L4 = {〈G〉: G is a connected undirected graph}
On input 〈G〉,
0. Verify that 〈G〉 is the description of a graph
(no vertex repeats; edges only go between nodes)
1 2 (1,2,3,4)((1,4)(2,3)(3,4)(4,2))
(1,2,3,4)((1,4)(2,3)(3,4)(4,2))
(1,2,3,4)((1,4)(2,3)(3,4)(4,2))
3 4
(1,2,3,4)((1,4)(2,3)(3,4)(4,2))
(1,2,3,4)((1,4)(2,3)(3,4)(4,2))
(1,2,3,4)((1,4)(2,3)(3,4)(4,2))
etc.
(1,2,3,4)((1,4)(2,3)(3,4)(4,2))
What’s so great about
Turing Machines?
Hilbert’s list of 23 problems
• Leading mathematician in the 1900s
Turing Machine
Turing Machine
quantum computing cosmic computing
DNA computing
Alan Turing