2. Invented by Alan Turing in 1936.
A simple mathematical model of a general
purpose computer.
It is capable of performing any calculation
which can be performed by any computing
machine.
3. The Language Hierarchy
n n n ?
a b c ww ?
Context-Free Languages
n n R
a b ww
Regular Languages
a* a *b *
4. Languages accepted by
Turing Machines
n n n
a b c ww
Context-Free Languages
n n R
a b ww NDPA
Regular Languages
Finite
a * a *b * Automata
6. The Tape
No boundaries -- infinite length
...... ......
Read-Write head
The head moves Left or Right
7. ...... ......
Read-Write head
The head at each time step:
1. Reads a symbol
2. Writes a symbol
3. Moves Left or Right
8. Example:
Time 0
...... a b a c ......
Time 1
...... a b k c ......
1. Reads a
2. Writes k
3. Moves Left
9. Time 1
...... a b k c ......
Time 2
...... a f k c ......
1. Reads b
2. Writes f
3. Moves Right
10. The Input String
Input string Blank symbol
...... a b a c ......
head
Head starts at the leftmost position
of the input string
Are treated as left and right brackets for the
input written on the tape.
34. Time 2 a b a
q0
Time 3 a b a
q0
Time 4 a b a
q0
Time 5 a b a
q0
... Infinite Loop
35. Because of the infinite loop:
•The final state cannot be reached
•The machine never halts
•The input is not accepted
36. Another Turing Machine
Example n n
Turing machine for the language {a b }
q4 y y, R y y, L
y y, R a a, R a a, L
,L
y y, R a x, R b y, L
q3 q0 q1 q2
x x, R
37. Time 0 a a b b
q0
q4 y y, R y y, L
y y, R a a, R a a, L
,L
y y, R a x, R b y, L
q3 q0 q1 q2
x x, R
38. Time 1 x a b b
q1
q4 y y, R y y, L
y y, R a a, R a a, L
,L
y y, R a x, R b y, L
q3 q0 q1 q2
x x, R
39. Time 2 x a b b
q1
q4 y y, R y y, L
y y, R a a, R a a, L
,L
y y, R a x, R b y, L
q3 q0 q1 q2
x x, R
40. Time 3 x a y b
q2
q4 y y, R y y, L
y y, R a a, R a a, L
,L
y y, R a x, R b y, L
q3 q0 q1 q2
x x, R
41. Time 4 x a y b
q2
q4 y y, R y y, L
y y, R a a, R a a, L
,L
y y, R a x, R b y, L
q3 q0 q1 q2
x x, R
42. Time 5 x a y b
q0
q4 y y, R y y, L
y y, R a a, R a a, L
,L
y y, R a x, R b y, L
q3 q0 q1 q2
x x, R
43. Time 6 x x y b
q1
q4 y y, R y y, L
y y, R a a, R a a, L
,L
y y, R a x, R b y, L
q3 q0 q1 q2
x x, R
44. Time 7 x x y b
q1
q4 y y, R y y, L
y y, R a a, R a a, L
,L
y y, R a x, R b y, L
q3 q0 q1 q2
x x, R
45. Time 8 x x y y
q2
q4 y y, R y y, L
y y, R a a, R a a, L
,L
y y, R a x, R b y, L
q3 q0 q1 q2
x x, R
46. Time 9 x x y y
q2
q4 y y, R y y, L
y y, R a a, R a a, L
,L
y y, R a x, R b y, L
q3 q0 q1 q2
x x, R
47. Time 10 x x y y
q0
q4 y y, R y y, L
y y, R a a, R a a, L
,L
y y, R a x, R b y, L
q3 q0 q1 q2
x x, R
48. Time 11 x x y y
q3
q4 y y, R y y, L
y y, R a a, R a a, L
,L
y y, R a x, R b y, L
q3 q0 q1 q2
x x, R
49. Time 12 x x y y
q3
q4 y y, R y y, L
y y, R a a, R a a, L
,L
y y, R a x, R b y, L
q3 q0 q1 q2
x x, R
50. Time 13 x x y y
q4
Halt & Accept
q4 y y, R y y, L
y y, R a a, R a a, L
,L
y y, R a x, R b y, L
q3 q0 q1 q2
x x, R
51. Observation:
If we modify the
machine for the language n n
{a b }
we can easily construct
n n n
a machine for the language {a b c }
54. Turing Machine:
Input Tape
alphabet alphabet
States
M (Q, , , , q0 , , F )
A partial Final
Transition states
function Initial Blank : a special symbol
state Of
55. Configuration
c a b a
q1
Instantaneous description: ca q1 ba
56. Time 4 Time 5
x a y b x a y b
q2 q0
A Move: q2 xayb x q0 ayb
57. Time 4 Time 5
x a y b x a y b
q2 q0
Time 6 Time 7
x x y b x x y b
q1 q1
q2 xayb x q0 ayb xx q1 yb xxy q1 b
58. q2 xayb x q0 ayb xx q1 yb xxy q1 b
Equivalent notation: q2 xayb xxy q1 b
60. The Accepted Language
For any Turing Machine M
L( M ) {w : q0 w x1 q f x2 }
Initial state Final state
61. Standard Turing Machine
The machine we described is the standard:
• Deterministic
• Infinite tape in both directions
•Tape is the input/output file
62. Design a Turing machine to recognize all
strings in which 010 is present as a
substring. 0,0,R
0,0,R 1,1,R 0,0,R
q0 q1 q2 H
1,1,R
1,1, R
63. DFA for the previous language
0
0 1 0
q0 q1 q2
1
1
0,1
66. Definition:
A language is recursively enumerable
if some Turing machine accepts it
67. Let L be a recursively enumerable language
and M the Turing Machine that accepts it
For string w:
if w L then M halts in a final state
if w L then M halts in a non-final state
or loops forever
68. Definition:
A language is recursive
if some Turing machine accepts it
and halts on any input string
In other words:
A language is recursive if there is
a membership algorithm for it
69. Let L be a recursive language
and M the Turing Machine that accepts it
For string w:
if w L then M halts in a final state
if w L then M halts in a non-final state
70. We will prove:
1. There is a specific language
which is not recursively enumerable
(not accepted by any Turing Machine)
2. There is a specific language
which is recursively enumerable
but not recursive
72. We will first prove:
• If a language is recursive then
there is an enumeration procedure for it
• A language is recursively enumerable
if and only if
there is an enumeration procedure for it