A Universal Turing Machine
A limitation of Turing Machines: Turing Machines are hardwired they execute only one program Real Computers are re-programmable
Solution: Universal Turing Machine Attributes: Reprogrammable machine Simulates any other Turing Machine
Universal Turing Machine simulates any other Turing Machine M Input of Universal Turing Machine: Description of transitions of M Initial tape contents of M 4
Three tapes Tape Description of M Universal Turing Machine Tape Tape Contents of M Tape State of M 5
Tape Description of M We describe Turing machine as a string of symbols: M We encode M as a string of symbols 6
Alphabet Encoding Symbols: a b c d Encoding: 7
State Encoding States: q q q q4 Encoding: Head Move Encoding Move: L R Encoding: 8
Transition Encoding Transition: ( q, a) ( q, b, L) Encoding: 0000 separator 9
Machine Encoding Transitions: ( q, a) ( q, b, L) ( q, b) ( q, c, R) Encoding: 0000 00 0000 separator 0
Tape contents of Universal Turing Machine: encoding of the simulated machine as a binary string of 0 s and s M
A Turing Machine is described with a binary string of 0 s and s Therefore: The set of Turing machines forms a language: each string of the language is the binary encoding of a Turing Machine
Language of Turing Machines L = { 00000, 0000000, 0000000, (Turing Machine ) (Turing Machine ) }
Countable Sets 4
Infinite sets are either: Countable or Uncountable 5
Countable set: There is a one to one correspondence between elements of the set and positive integers 6
Example: The set of even integers is countable Even integers: 0,, 4, 6, Correspondence: Positive integers:,,, 4, n corresponds to n 7
Example: The set of rational numbers is countable Rational numbers:,, 7, 4 8 8
Naïve Proof Rational numbers:,,, Correspondence: Positive integers:,,, Doesn t work: we will never count numbers with nominator :,,, 9
Better Approach 4 4 0
4 4
4 4
4 4
4 4 4
4 4 5
Rational Numbers:,,,,, Correspondence: Positive Integers:,,, 4, 5, 6
We proved: the set of rational numbers is countable by describing an enumeration procedure 7
Definition Let S be a set of strings An enumeration procedure for Turing Machine that generates all strings of S one by one S is a and Each string is generated in finite time 8
strings s, s, s, S Enumeration Machine for S output (on tape) s, s, s, Finite time: t, t, t, 9
Enumeration Machine Time 0 Configuration q 0 Time t x # s q s 0
Time t x # s q s Time t x # s q s
Observation: A set is countable if there is an enumeration procedure for it
Example: The set of all strings is countable { a, b, c } Proof: We will describe the enumeration procedure
Naive procedure: Produce the strings in lexicographic order: a aa aaa aaaa... Doesn t work: strings starting with will never be produced b 4
Better procedure: Proper Order. Produce all strings of length. Produce all strings of length. Produce all strings of length 4. Produce all strings of length 4... 5
a b c length Produce strings in Proper Order: aa ab ac ba bb bc ca cb cc aaa aab aac... length length 6
Theorem: The set of all Turing Machines is countable Proof: Any Turing Machine can be encoded with a binary string of 0 s and s Find an enumeration procedure for the set of Turing Machine strings 7
Enumeration Procedure: Repeat. Generate the next binary string of 0 s and s in proper order. Check if the string describes a Turing Machine if YES: print string on output tape if NO: ignore string 8
Uncountable Sets 9
Definition: A set is uncountable if it is not countable 40
Theorem: Let S be an infinite countable set S The powerset of S is uncountable 4
Proof: Since S is countable, we can write S { s, s, s, } Elements of S 4
Elements of the powerset have the form: { s, s } { s5, s7, s9, s 0 } 4
We encode each element of the power set with a binary string of 0 s and s Powerset element Encoding s s s s4 { s } 0 0 0 { s, s } 0 0 { s, s, s 4 } 0 44
Let s assume (for contradiction) that the powerset is countable. Then: we can enumerate the elements of the powerset 45
Powerset element t Encoding 0 0 0 0 t 0 0 0 t 0 0 t 4 0 0 46
Take the powerset element whose bits are the complements in the diagonal 47
t 0 0 0 0 t 0 0 0 t 0 0 t 4 0 0 New element: 00 (birary complement of diagonal) 48
The new element must be some of the powerset t i However, that s impossible: from definition of ti the i-th bit of t i must be the complement of itself Contradiction!!! 49
Since we have a contradiction: The powerset of is uncountable S S 50
An Application: Languages Example Alphabet : { a, b} The set of all Strings: S { a, b} * {, a, b, aa, ab, ba, bb, aaa, aab, } infinite and countable 5
Example Alphabet : { a, b} The set of all Strings: S { a, b} * {, a, b, aa, ab, ba, bb, aaa, aab, } infinite and countable A language is a subset of : S L { aa, ab, aab} 5
Example Alphabet : { a, b} The set of all Strings: S { a, b} * {, a, b, aa, ab, ba, bb, aaa, aab, } infinite and countable The powerset of S S contains all languages: {{ },{ a},{ a, b}{ aa, ab, aab}, } L L L L 4 uncountable 5
Languages: uncountable L L L Lk M M M? Turing machines: countable There are infinitely many more languages than Turing Machines 54
Conclusion: There are some languages not accepted by Turing Machines These languages cannot be described by algorithms 55