A Universal Turing Machine Fall 2004 COMP 335

  • Slides: 56
Download presentation
A Universal Turing Machine Fall 2004 COMP 335 1

A Universal Turing Machine Fall 2004 COMP 335 1

A limitation of Turing Machines: Turing Machines are “hardwired” they execute only one program

A limitation of Turing Machines: Turing Machines are “hardwired” they execute only one program Real Computers are re-programmable Fall 2004 COMP 335 2

Solution: Universal Turing Machine Attributes: • Reprogrammable machine • Simulates any other Turing Machine

Solution: Universal Turing Machine Attributes: • Reprogrammable machine • Simulates any other Turing Machine Fall 2004 COMP 335 3

Universal Turing Machine simulates any other Turing Machine Input of Universal Turing Machine: Description

Universal Turing Machine simulates any other Turing Machine Input of Universal Turing Machine: Description of transitions of Initial tape contents of Fall 2004 COMP 335 4

Tape 1 Three tapes Description of Universal Turing Machine Tape 2 Tape Contents of

Tape 1 Three tapes Description of Universal Turing Machine Tape 2 Tape Contents of Tape 3 Fall 2004 COMP 335 State of 5

Tape 1 Description of We describe Turing machine as a string of symbols: We

Tape 1 Description of We describe Turing machine as a string of symbols: We encode Fall 2004 as a string of symbols COMP 335 6

Alphabet Encoding Symbols: Encoding: Fall 2004 COMP 335 7

Alphabet Encoding Symbols: Encoding: Fall 2004 COMP 335 7

State Encoding States: Encoding: Head Move Encoding Move: Encoding: Fall 2004 COMP 335 8

State Encoding States: Encoding: Head Move Encoding Move: Encoding: Fall 2004 COMP 335 8

Transition Encoding Transition: Encoding: separator Fall 2004 COMP 335 9

Transition Encoding Transition: Encoding: separator Fall 2004 COMP 335 9

Machine Encoding Transitions: Encoding: separator Fall 2004 COMP 335 10

Machine Encoding Transitions: Encoding: separator Fall 2004 COMP 335 10

Tape 1 contents of Universal Turing Machine: encoding of the simulated machine as a

Tape 1 contents of Universal Turing Machine: encoding of the simulated machine as a binary string of 0’s and 1’s Fall 2004 COMP 335 11

A Turing Machine is described with a binary string of 0’s and 1’s Therefore:

A Turing Machine is described with a binary string of 0’s and 1’s Therefore: The set of Turing machines forms a language: each string of the language is the binary encoding of a Turing Machine Fall 2004 COMP 335 12

Language of Turing Machines (Turing Machine 1) L = { 010100101, 00100100101111, 111010011110010101, (Turing

Language of Turing Machines (Turing Machine 1) L = { 010100101, 00100100101111, 111010011110010101, (Turing Machine 2) …… …… } Fall 2004 COMP 335 13

Countable Sets Fall 2004 COMP 335 14

Countable Sets Fall 2004 COMP 335 14

Infinite sets are either: Countable or Uncountable Fall 2004 COMP 335 15

Infinite sets are either: Countable or Uncountable Fall 2004 COMP 335 15

Countable set: Any finite set or Any Countably infinite set: There is a one

Countable set: Any finite set or Any Countably infinite set: There is a one to one correspondence between elements of the set and Natural numbers Fall 2004 COMP 335 16

Example: The set of even integers is countable Even integers: Correspondence: Positive integers: corresponds

Example: The set of even integers is countable Even integers: Correspondence: Positive integers: corresponds to Fall 2004 COMP 335 17

Example: The set of rational numbers is countable Rational numbers: Fall 2004 COMP 335

Example: The set of rational numbers is countable Rational numbers: Fall 2004 COMP 335 18

Naïve Proof Rational numbers: Correspondence: Positive integers: Doesn’t work: we will never count numbers

Naïve Proof Rational numbers: Correspondence: Positive integers: Doesn’t work: we will never count numbers with nominator 2: Fall 2004 COMP 335 19

Better Approach Fall 2004 COMP 335 20

Better Approach Fall 2004 COMP 335 20

Fall 2004 COMP 335 21

Fall 2004 COMP 335 21

Fall 2004 COMP 335 22

Fall 2004 COMP 335 22

Fall 2004 COMP 335 23

Fall 2004 COMP 335 23

Fall 2004 COMP 335 24

Fall 2004 COMP 335 24

Fall 2004 COMP 335 25

Fall 2004 COMP 335 25

Rational Numbers: Correspondence: Positive Integers: Fall 2004 COMP 335 26

Rational Numbers: Correspondence: Positive Integers: Fall 2004 COMP 335 26

We proved: the set of rational numbers is countable by describing an enumeration procedure

We proved: the set of rational numbers is countable by describing an enumeration procedure Fall 2004 COMP 335 27

Definition Let be a set of strings An enumeration procedure for Turing Machine that

Definition Let be a set of strings An enumeration procedure for Turing Machine that generates all strings of one by one is a and Each string is generated in finite time Fall 2004 COMP 335 28

strings Enumeration Machine for output (on tape) Finite time: Fall 2004 COMP 335 29

strings Enumeration Machine for output (on tape) Finite time: Fall 2004 COMP 335 29

Enumeration Machine Configuration Time 0 Time Fall 2004 COMP 335 30

Enumeration Machine Configuration Time 0 Time Fall 2004 COMP 335 30

Time Fall 2004 COMP 335 31

Time Fall 2004 COMP 335 31

Observation: If for a set there is an enumeration procedure, then the set is

Observation: If for a set there is an enumeration procedure, then the set is countable Fall 2004 COMP 335 32

Example: The set of all strings is countable Proof: We will describe an enumeration

Example: The set of all strings is countable Proof: We will describe an enumeration procedure Fall 2004 COMP 335 33

Naive procedure: Produce the strings in lexicographic order: Doesn’t work: strings starting with will

Naive procedure: Produce the strings in lexicographic order: Doesn’t work: strings starting with will never be produced Fall 2004 COMP 335 34

Better procedure: Proper Order 1. Produce all strings of length 1 2. Produce all

Better procedure: Proper Order 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. . Fall 2004 COMP 335 35

length 1 Produce strings in Proper Order: length 2 length 3 Fall 2004 COMP

length 1 Produce strings in Proper Order: length 2 length 3 Fall 2004 COMP 335 36

Theorem: The set of all Turing Machines is countable Proof: Any Turing Machine can

Theorem: The set of all Turing Machines is countable Proof: Any Turing Machine can be encoded with a binary string of 0’s and 1’s Find an enumeration procedure for the set of Turing Machine strings Fall 2004 COMP 335 37

Enumeration Procedure: Repeat 1. Generate the next binary string of 0’s and 1’s in

Enumeration Procedure: Repeat 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 Fall 2004 COMP 335 38

Uncountable Sets Fall 2004 COMP 335 39

Uncountable Sets Fall 2004 COMP 335 39

Definition: Fall 2004 A set is uncountable if it is not countable COMP 335

Definition: Fall 2004 A set is uncountable if it is not countable COMP 335 40

Theorem: Let be an infinite countable set The powerset Fall 2004 of COMP 335

Theorem: Let be an infinite countable set The powerset Fall 2004 of COMP 335 is uncountable 41

Proof: Since is countable, we can write Elements of Fall 2004 COMP 335 42

Proof: Since is countable, we can write Elements of Fall 2004 COMP 335 42

Elements of the powerset have the form: …… Fall 2004 COMP 335 43

Elements of the powerset have the form: …… Fall 2004 COMP 335 43

We encode each element of the power set with a binary string of 0’s

We encode each element of the power set with a binary string of 0’s and 1’s Powerset element Fall 2004 Encoding COMP 335 44

Let’s assume (for contradiction) that the powerset is countable. Then: Fall 2004 we can

Let’s assume (for contradiction) that the powerset is countable. Then: Fall 2004 we can enumerate the elements of the powerset COMP 335 45

Powerset element Fall 2004 Encoding COMP 335 46

Powerset element Fall 2004 Encoding COMP 335 46

Take the powerset element whose bits are the complements in the diagonal Fall 2004

Take the powerset element whose bits are the complements in the diagonal Fall 2004 COMP 335 47

New element: Fall 2004 (birary complement of diagonal) COMP 335 48

New element: Fall 2004 (birary complement of diagonal) COMP 335 48

The new element must be some of the powerset However, that’s impossible: from definition

The new element must be some of the powerset However, that’s impossible: from definition of the i-th bit of must be the complement of itself Contradiction!!! Fall 2004 COMP 335 49

Since we have a contradiction: The powerset Fall 2004 of COMP 335 is uncountable

Since we have a contradiction: The powerset Fall 2004 of COMP 335 is uncountable 50

An Application: Languages Example Alphabet : The set of all Strings: infinite and countable

An Application: Languages Example Alphabet : The set of all Strings: infinite and countable Fall 2004 COMP 335 51

Example Alphabet : The set of all Strings: infinite and countable A language is

Example Alphabet : The set of all Strings: infinite and countable A language is a subset of Fall 2004 COMP 335 : 52

Example Alphabet : The set of all Strings: infinite and countable The powerset of

Example Alphabet : The set of all Strings: infinite and countable The powerset of Fall 2004 contains all languages: uncountable COMP 335 53

Languages: uncountable Turing machines: countable There are more languages than Turing Machines Fall 2004

Languages: uncountable Turing machines: countable There are more languages than Turing Machines Fall 2004 COMP 335 54

Conclusion: There are some languages not accepted by Turing Machines (These languages cannot be

Conclusion: There are some languages not accepted by Turing Machines (These languages cannot be described by algorithms) Fall 2004 COMP 335 55

Languages not accepted by Turing Machines Languages Accepted by Turing Machines Fall 2004 COMP

Languages not accepted by Turing Machines Languages Accepted by Turing Machines Fall 2004 COMP 335 56