2. Fall 2006 Costas Busch - RPI 2
Turing Machines are “hardwired”
they execute
only one program
A limitation of Turing Machines:
Real Computers are re-programmable
3. Fall 2006 Costas Busch - RPI 3
Solution: Universal Turing Machine
• Reprogrammable machine
• Simulates any other Turing Machine
Attributes:
4. Fall 2006 Costas Busch - RPI 4
Universal Turing Machine
simulates any Turing Machine M
Input of Universal Turing Machine:
Description of transitions of M
Input string of M
5. Fall 2006 Costas Busch - RPI 5
Universal
Turing
Machine
M
Description of
Tape Contents of
M
State of M
Three tapes
Tape 2
Tape 3
Tape 1
6. Fall 2006 Costas Busch - RPI 6
We describe Turing machine
as a string of symbols:
We encode as a string of symbols
M
M
Description of M
Tape 1
7. Fall 2006 Costas Busch - RPI 7
Alphabet Encoding
Symbols: a b c d
Encoding: 1 11 111 1111
8. Fall 2006 Costas Busch - RPI 8
State Encoding
States: 1
q 2
q 3
q 4
q
Encoding: 1 11 111 1111
Head Move Encoding
Move:
Encoding:
L R
1 11
9. Fall 2006 Costas Busch - RPI 9
Transition Encoding
Transition: )
,
,
(
)
,
( 2
1 L
b
q
a
q
Encoding: 1
0
11
0
11
0
1
0
1
separator
10. Fall 2006 Costas Busch - RPI 10
Turing Machine Encoding
Transitions:
)
,
,
(
)
,
( 2
1 L
b
q
a
q
Encoding:
1
0
11
0
11
0
1
0
1
)
,
,
(
)
,
( 3
2 R
c
q
b
q
11
0
111
0
111
10
1
0
11
00
separator
11. Fall 2006 Costas Busch - RPI 11
Tape 1 contents of Universal Turing Machine:
binary encoding
of the simulated machine M
1100
0
111
0
111
10
1
0
10011
0
11
0
11
0
1
0
1
Tape 1
12. Fall 2006 Costas Busch - RPI 12
A Turing Machine is described
with a binary string of 0’s and 1’s
The set of Turing machines
forms a language:
each string of this language is
the binary encoding of a Turing Machine
Therefore:
13. Fall 2006 Costas Busch - RPI 13
Language of Turing Machines
L = { 010100101,
00100100101111,
111010011110010101,
…… }
(Turing Machine 1)
(Turing Machine 2)
……
15. Fall 2006 Costas Busch - RPI 15
Infinite sets are either: Countable
or
Uncountable
16. Fall 2006 Costas Busch - RPI 16
Countable set:
There is a one to one correspondence
of
elements of the set
to
Natural numbers (Positive Integers)
(every element of the set is mapped to a number
such that no two elements are mapped to same number)
17. Fall 2006 Costas Busch - RPI 17
Example:
Even integers:
(positive)
,
6
,
4
,
2
,
0
The set of even integers
is countable
Positive integers:
Correspondence:
,
4
,
3
,
2
,
1
n
2 corresponds to 1
n
18. Fall 2006 Costas Busch - RPI 18
Example:The set of rational numbers
is countable
Rational numbers:
,
8
7
,
4
3
,
2
1
27. Fall 2006 Costas Busch - RPI 27
We proved:
the set of rational numbers is countable
by describing an enumeration procedure
(enumerator)
for the correspondence to natural numbers
28. Fall 2006 Costas Busch - RPI 28
Definition
An enumerator for is a Turing Machine
that generates (prints on tape)
all the strings of one by one
Let be a set of strings (Language)
S
S
S
and
each string is generated in finite time
29. Fall 2006 Costas Busch - RPI 29
Enumerator
Machine for
,
,
, 3
2
1 s
s
s
S
s
s
s
,
,
, 3
2
1
Finite time:
,
,
, 3
2
1 t
t
t
strings
S
output
(on tape)
30. Fall 2006 Costas Busch - RPI 30
Enumerator Machine
Configuration
Time 0
0
q
Time
s
q
1
x 1
s
#
1
t
prints 1
s
31. Fall 2006 Costas Busch - RPI 31
Time
s
q
3
x 3
s
#
3
t
Time
s
q
2
x 2
s
#
2
t
prints 2
s
prints 3
s
32. Fall 2006 Costas Busch - RPI 32
If for a set there is an enumerator,
then the set is countable
Observation:
The enumerator describes the
correspondence of to natural numbers
S
S
33. Fall 2006 Costas Busch - RPI 33
Example: The set of strings
is countable
}
,
,
{ c
b
a
S
We will describe an enumerator for
Approach:
S
34. Fall 2006 Costas Busch - RPI 34
Naive enumerator:
Produce the strings in lexicographic order:
a
aa
aaa
......
Doesn’t work:
strings starting with
will never be produced
b
aaaa
1
s
2
s
35. Fall 2006 Costas Busch - RPI 35
Better procedure:
1. Produce all strings of length 1
2. Produce all strings of length 2
3. Produce all strings of length 3
4. Produce all strings of length 4
..........
Proper Order
(Canonical Order)
36. Fall 2006 Costas Busch - RPI 36
Produce strings in
Proper Order:
aa
ab
ac
ba
bb
bc
ca
cb
cc
aaa
aab
aac
......
length 2
length 3
length 1
a
b
c
1
s
2
s
37. Fall 2006 Costas Busch - RPI 37
Theorem: The set of all Turing Machines
is countable
Proof:
Find an enumeration procedure
for the set of Turing Machine strings
Any Turing Machine can be encoded
with a binary string of 0’s and 1’s
38. Fall 2006 Costas Busch - RPI 38
1. Generate the next binary string
of 0’s and 1’s in proper order
2. Check if the string describes a
Turing Machine
if YES: print string on output tape
if NO: ignore string
Enumerator:
Repeat
41. Fall 2006 Costas Busch - RPI 41
We will prove that there is a language
which is not accepted by any Turing machine
L
Technique:
Turing machines are countable
Languages are uncountable
(there are more languages than Turing Machines)
42. Fall 2006 Costas Busch - RPI 42
A set is uncountable
if it is not countable
Definition:
We will prove that there is a language
which is not accepted by any Turing machine
43. Fall 2006 Costas Busch - RPI 43
Theorem:
If is an infinite countable set, then
the powerset of is uncountable.
S
2 S
S
(the powerset is the set whose elements
are all possible sets made from the elements of )
S
2
S
44. Fall 2006 Costas Busch - RPI 44
Proof:
Since is countable, we can write
S
}
,
,
,
{ 3
2
1
s
s
s
S
Elements of S
45. Fall 2006 Costas Busch - RPI 45
Elements of the powerset have the form:
}
,
{ 3
1 s
s
}
,
,
,
{ 10
9
7
5 s
s
s
s
……
S
2
46. Fall 2006 Costas Busch - RPI 46
We encode each element of the powerset
with a binary string of 0’s and 1’s
1
s 2
s 3
s 4
s
1 0 0 0
}
{ 1
s
Powerset
element
Binary encoding
0 1 1 0
}
,
{ 3
2 s
s
1 0 1 1
}
,
,
{ 4
3
1 s
s
s
(in arbitrary order)
47. Fall 2006 Costas Busch - RPI 47
Observation:
Every infinite binary string corresponds
to an element of the powerset:
10
Example: 0111 0
Corresponds to:
S
s
s
s
s 2
}
,
,
,
,
{ 6
5
4
1
48. Fall 2006 Costas Busch - RPI 48
Let’s assume (for contradiction)
that the powerset is countable
Then: we can enumerate
the elements of the powerset
}
,
,
,
{
2 3
2
1
t
t
t
S
S
2
49. Fall 2006 Costas Busch - RPI 49
1 0 0 0 0
1 1 0 0 0
1 1 0 1 0
1 1 0 0 1
Powerset
element
Binary encoding
1
t
2
t
3
t
4
t
suppose that this is the respective
50. Fall 2006 Costas Busch - RPI 50
1 0 0 0 0
1 1 0 0 0
1 1 0 1 0
1 1 0 0 1
1
t
2
t
3
t
4
t
Binary string:
0011
(birary complement of diagonal)
Take the binary string whose bits
are the complement of the diagonal
t
51. Fall 2006 Costas Busch - RPI 51
0011
t
The binary string
corresponds
to an element of
the powerset : S
s
s
t 2
}
,
,
{ 4
3
S
2
52. Fall 2006 Costas Busch - RPI 52
Thus, must be equal to some i
t
However,
the i-th bit in the encoding of is
the complement of the bit of , thus:
Contradiction!!!
t
i
t
t
i-th i
t
i
t
t
t
53. Fall 2006 Costas Busch - RPI 53
Since we have a contradiction:
The powerset of is uncountable
S
2 S
End of proof
54. Fall 2006 Costas Busch - RPI 54
An Application: Languages
The set of all Strings:
}
,
,
,
,
,
,
,
,
,
{
}
,
{ *
aab
aaa
bb
ba
ab
aa
b
a
b
a
S
infinite and countable
Consider Alphabet : }
,
{ b
a
A
(we can enumerate the strings
in proper order)
55. Fall 2006 Costas Busch - RPI 55
The set of all Strings:
}
,
,
,
,
,
,
,
,
,
{
}
,
{ *
aab
aaa
bb
ba
ab
aa
b
a
b
a
S
infinite and countable
Any language is a subset of :
}
,
,
{ aab
ab
aa
L
S
Consider Alphabet : }
,
{ b
a
A
56. Fall 2006 Costas Busch - RPI 56
Consider Alphabet : }
,
{ b
a
A
The set of all Strings:
}
,
,
,
,
,
,
,
,
,
{
}
,
{ *
*
aab
aaa
bb
ba
ab
aa
b
a
b
a
A
S
infinite and countable
The powerset of contains all languages:
}
},
,
,
{
},...,
,
{
},
,
{
},
{
},
{
,
{
2
aab
ab
aa
b
aa
b
a
a
S
uncountable
S
57. Fall 2006 Costas Busch - RPI 57
Turing machines: 1
M 2
M 3
M
Languages accepted
By Turing Machines: 1
L 2
L 3
L
accepts
Denote: }
,
,
,
{ 3
2
1
L
L
L
X
countable
Note:
S
X 2
countable
countable
*
}
,
{ b
a
S
Consider Alphabet : }
,
{ b
a
A
58. Fall 2006 Costas Busch - RPI 58
X countable
S
2 uncountable
Languages accepted
by Turing machines:
All possible languages:
Therefore:
S
X 2
S
S
X
X 2
have
we
,
2
since
59. Fall 2006 Costas Busch - RPI 59
There is a language not accepted
by any Turing Machine:
(Language cannot be described
by any algorithm)
Conclusion:
L
S
X 2
X
L
and
2
S
L
L
60. Fall 2006 Costas Busch - RPI 60
Turing-Acceptable
Languages
Non Turing-Acceptable Languages
L
61. Fall 2006 Costas Busch - RPI 61
Note that: }
,
,
,
{ 3
2
1
L
L
L
X
is a multi-set (elements may repeat)
since a language may be accepted
by more than one Turing machine
However, if we remove the repeated elements,
the resulting set is again countable since every element
still corresponds to a positive integer