Universal Turing Machine
Universal Turing Machine
Universal Turing Machine
1
A limitation of Turing Machines:
they execute
only one program
2
Solution: Universal Turing Machine
Attributes:
• Reprogrammable machine
3
Universal Turing Machine
simulates any Turing Machine M
Description of transitions of M
Input string of M
4
Tape 1
Three tapes
Description of M
Universal
Tape 2
Turing
Machine
Tape Contents of M
Tape 3
State of M 5
Tape 1
Description of M
6
Alphabet Encoding
Symbols: a b c d
7
State Encoding
States: q1 q2 q3 q4
Move: L R
Encoding: 1 11
8
Transition Encoding
Encoding: 1 0 1 0 11 0 11 0 1
separator
9
Turing Machine Encoding
Transitions:
(q1, a ) (q2 , b, L) (q2 , b) (q3 , c, R)
Encoding:
1 0 1 0 11 0 11 0 1 00 11 0 1 10 111 0 111 0 11
separator
10
Tape 1 contents of Universal Turing Machine:
binary encoding
of the simulated machine M
Tape 1
1 0 1 0 11 0 11 0 10011 0 1 10 111 0 111 0 1100
11
A Turing Machine is described
with a binary string of 0’s and 1’s
Therefore:
The set of Turing machines
forms a language:
12
Language of Turing Machines
111010011110010101, ……
…… }
13
Countable Sets
14
Infinite sets are either: Countable
or
Uncountable
15
Countable set:
There is a one to one correspondence
of
elements of the set
to
Natural numbers (Positive Integers)
16
Example: The set of even integers
is countable
Even integers: 0, 2, 4, 6,
(positive)
Correspondence:
Positive integers: 1, 2, 3, 4,
2n corresponds to n 1
17
Example: The set of rational numbers
is countable
1 3 7
Rational numbers: , , ,
2 4 8
18
Naïve Approach Nominator 1
1 1 1
Rational numbers: , , ,
1 2 3
Correspondence:
Positive integers: 1, 2, 3,
Doesn’t work:
we will never count 2 2 2
, , ,
numbers with nominator 2: 1 2 3
19
Better Approach
1 1 1 1
1 2 3 4
2 2 2
1 2 3
3 3
1 2
4
1 20
1 1 1 1
1 2 3 4
2 2 2
1 2 3
3 3
1 2
4
1 21
1 1 1 1
1 2 3 4
2 2 2
1 2 3
3 3
1 2
4
1 22
1 1 1 1
1 2 3 4
2 2 2
1 2 3
3 3
1 2
4
1 23
1 1 1 1
1 2 3 4
2 2 2
1 2 3
3 3
1 2
4
1 24
1 1 1 1
1 2 3 4
2 2 2
1 2 3
3 3
1 2
4
1 25
1 1 2 1 2
Rational Numbers: , , , , ,
1 2 1 3 2
Correspondence:
Positive Integers: 1, 2, 3, 4, 5,
26
We proved:
27
Definition
and
each string is generated in finite time
28
strings s1, s2 , s3 , S
29
Enumerator Machine
Configuration
Time 0
q0
prints s1
Time t1 x1 # s1
qs
30
prints s2
Time t2 x2 # s2
qs
prints s3
Time t3 x3 # s3
qs
31
Observation:
If for a set S there is an enumerator,
then the set is countable
32
Example: The set of strings S {a , b , c }
is countable
Approach:
We will describe an enumerator for S
33
Naive enumerator:
Produce the strings in lexicographic order:
s1 a
s2 aa
aaa
aaaa
......
Doesn’t work:
strings starting with b
will never be produced
34
Better procedure: Proper Order
(Canonical Order)
1. Produce all strings of length 1
35
s1 a
s2 b length 1
c
aa
ab
ac
Produce strings in ba
Proper Order: bb length 2
bc
ca
cb
cc
aaa
aab length 3
aac
......
36
Theorem: The set of all Turing Machines
is countable
37
Enumerator:
Repeat
1. Generate the next binary string
of 0’s and 1’s in proper order
1 0 1 0 11 0 11 0 0 s1
1 0 1 0 11 0 11 0 1 1 0 1 0 11 0 11 0 1
s2
1 0 11 0 1010010101 101 1 0 11 0 1010010101 101
End of Proof
39
Uncountable Sets
40
We will prove that there is a language L
which is not accepted by any Turing machine
Technique:
Turing machines are countable
42
Theorem:
43
Proof:
Elements of S
{s1, s3}
{s5 , s7 , s9 , s10 }
……
45
We encode each element of the powerset
with a binary string of 0’s and 1’s
Powerset
Binary encoding
element
(in arbitrary order)
s1 s2 s3 s4
{s1} 1 0 0 0
{s2 , s 3 } 0 1 1 0
{s1, s 3 , s4 } 1 0 1 1
46
Observation:
Every infinite binary string corresponds
to an element of the powerset:
Example: 10 0 111 0
S
Corresponds to: {s1, s4 , s5 , s6 ,} 2
47
Let’s assume (for contradiction)
that the powerset 2 is countable
S
S
2 {t1, t2 , t3 ,}
48
suppose that this is the respective
Powerset
Binary encoding
element
t1 1 0 0 0 0
t2 1 1 0 0 0
t3 1 1 0 1 0
t4 1 1 0 0 1
49
Take the binary string whose bits
are the complement of the diagonal
t1 1 0 0 0 0
t2 1 1 0 0 0
t3 1 1 0 1 0
t4 1 1 0 0 1
Binary string: t 0011
(birary complement of diagonal)
50
The binary string t 0011
corresponds
to an element of
S
the powerset 2 : t {s3 , s 4 , } 2
S
51
Thus, t must be equal to some ti
t ti
However,
the i-th bit in the encoding of t is
the complement of the i-th bit of ti , thus:
t ti
Contradiction!!!
52
Since we have a contradiction:
The powerset S of
2 S is uncountable
End of proof
53
An Application: Languages
54
Consider Alphabet : A {a, b}
The set of all Strings:
55
Consider Alphabet : A {a, b}
The set of all Strings:
uncountable
56
Consider Alphabet : A {a, b}
countable
Turing machines: M1 M2 M3
accepts
Languages accepted
By Turing Machines: L1 L2 L3
countable
57
Conclusion:
There is a language L not accepted
by any Turing Machine:
S L 2 S
and L X
X 2
58
Non Turing-Acceptable Languages
L
Turing-Acceptable
Languages
59
Note that: X {L1, L2 , L3 ,}
is a multi-set (elements may repeat)
since a language may be accepted
by more than one Turing machine
60