fall 2006costas busch - rpi1 a universal turing machine

61
Fall 2006 Costas Busch - RPI 1 A Universal Turing Machine

Upload: dontae-andros

Post on 29-Mar-2015

226 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Fall 2006Costas Busch - RPI1 A Universal Turing Machine

Fall 2006 Costas Busch - RPI 1

A Universal Turing Machine

Page 2: Fall 2006Costas Busch - RPI1 A Universal Turing Machine

Fall 2006 Costas Busch - RPI 2

Turing Machines are “hardwired”

they executeonly one program

A limitation of Turing Machines:

Real Computers are re-programmable

Page 3: Fall 2006Costas Busch - RPI1 A Universal Turing Machine

Fall 2006 Costas Busch - RPI 3

Solution: Universal Turing Machine

• Reprogrammable machine

• Simulates any other Turing Machine

Attributes:

Page 4: Fall 2006Costas Busch - RPI1 A Universal Turing Machine

Fall 2006 Costas Busch - RPI 4

Universal Turing Machine

simulates any Turing MachineM

Input of Universal Turing Machine:

Description of transitions of M

Input string of M

Page 5: Fall 2006Costas Busch - RPI1 A Universal Turing Machine

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

Page 6: Fall 2006Costas Busch - RPI1 A Universal Turing Machine

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

Page 7: Fall 2006Costas Busch - RPI1 A Universal Turing Machine

Fall 2006 Costas Busch - RPI 7

Alphabet Encoding

Symbols: a b c d

Encoding: 1 11 111 1111

Page 8: Fall 2006Costas Busch - RPI1 A Universal Turing Machine

Fall 2006 Costas Busch - RPI 8

State Encoding

States: 1q 2q 3q 4q

Encoding: 1 11 111 1111

Head Move Encoding

Move:

Encoding:

L R

1 11

Page 9: Fall 2006Costas Busch - RPI1 A Universal Turing Machine

Fall 2006 Costas Busch - RPI 9

Transition Encoding

Transition: ),,(),( 21 Lbqaq

Encoding: 10110110101

separator

Page 10: Fall 2006Costas Busch - RPI1 A Universal Turing Machine

Fall 2006 Costas Busch - RPI 10

Turing Machine Encoding

Transitions:

),,(),( 21 Lbqaq

Encoding:

10110110101

),,(),( 32 Rcqbq

110111011110101100

separator

Page 11: Fall 2006Costas Busch - RPI1 A Universal Turing Machine

Fall 2006 Costas Busch - RPI 11

Tape 1 contents of Universal Turing Machine:

binary encoding of the simulated machineM

1100011101111010100110110110101

Tape 1

Page 12: Fall 2006Costas Busch - RPI1 A Universal Turing Machine

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 isthe binary encoding of a Turing Machine

Therefore:

Page 13: Fall 2006Costas Busch - RPI1 A Universal Turing Machine

Fall 2006 Costas Busch - RPI 13

Language of Turing Machines

L = { 010100101,

00100100101111,

111010011110010101, …… }

(Turing Machine 1)

(Turing Machine 2)

……

Page 14: Fall 2006Costas Busch - RPI1 A Universal Turing Machine

Fall 2006 Costas Busch - RPI 14

Countable Sets

Page 15: Fall 2006Costas Busch - RPI1 A Universal Turing Machine

Fall 2006 Costas Busch - RPI 15

Infinite sets are either: Countable

or

Uncountable

Page 16: Fall 2006Costas Busch - RPI1 A Universal Turing Machine

Fall 2006 Costas Busch - RPI 16

Countable set:

There is a one to one correspondenceofelements of the setto Natural numbers (Positive Integers)

(every element of the set is mapped to a number such that no two elements are mapped to same number)

Page 17: Fall 2006Costas Busch - RPI1 A Universal Turing Machine

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

n2 corresponds to 1n

Page 18: Fall 2006Costas Busch - RPI1 A Universal Turing Machine

Fall 2006 Costas Busch - RPI 18

Example:The set of rational numbersis countable

Rational numbers: ,87

,43

,21

Page 19: Fall 2006Costas Busch - RPI1 A Universal Turing Machine

Fall 2006 Costas Busch - RPI 19

Naïve Approach

Rational numbers: ,31

,21

,11

Positive integers:

Correspondence:

,3,2,1

Doesn’t work:

we will never count numbers with nominator 2:

,32

,22

,12

Nominator 1

Page 20: Fall 2006Costas Busch - RPI1 A Universal Turing Machine

Fall 2006 Costas Busch - RPI 20

Better Approach

11

21

31

41

12

22

32

13

23

14

Page 21: Fall 2006Costas Busch - RPI1 A Universal Turing Machine

Fall 2006 Costas Busch - RPI 21

11

21

31

41

12

22

32

13

23

14

Page 22: Fall 2006Costas Busch - RPI1 A Universal Turing Machine

Fall 2006 Costas Busch - RPI 22

11

21

31

41

12

22

32

13

23

14

Page 23: Fall 2006Costas Busch - RPI1 A Universal Turing Machine

Fall 2006 Costas Busch - RPI 23

11

21

31

41

12

22

32

13

23

14

Page 24: Fall 2006Costas Busch - RPI1 A Universal Turing Machine

Fall 2006 Costas Busch - RPI 24

11

21

31

41

12

22

32

13

23

14

Page 25: Fall 2006Costas Busch - RPI1 A Universal Turing Machine

Fall 2006 Costas Busch - RPI 25

11

21

31

41

12

22

32

13

23

14

Page 26: Fall 2006Costas Busch - RPI1 A Universal Turing Machine

Fall 2006 Costas Busch - RPI 26

Rational Numbers: ,22

,31

,12

,21

,11

Correspondence:

Positive Integers: ,5,4,3,2,1

Page 27: Fall 2006Costas Busch - RPI1 A Universal Turing Machine

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

Page 28: Fall 2006Costas Busch - RPI1 A Universal Turing Machine

Fall 2006 Costas Busch - RPI 28

Definition

An enumerator for is a Turing Machinethat generates (prints on tape)all the strings of one by one

Let be a set of strings (Language) S

S

S

andeach string is generated in finite time

Page 29: Fall 2006Costas Busch - RPI1 A Universal Turing Machine

Fall 2006 Costas Busch - RPI 29

EnumeratorMachine for

,,, 321 sss

Ssss ,,, 321

Finite time: ,,, 321 ttt

strings

Soutput

(on tape)

Page 30: Fall 2006Costas Busch - RPI1 A Universal Turing Machine

Fall 2006 Costas Busch - RPI 30

Enumerator MachineConfiguration

Time 0

0q

Time

sq

1x 1s#1tprints 1s

Page 31: Fall 2006Costas Busch - RPI1 A Universal Turing Machine

Fall 2006 Costas Busch - RPI 31

Time

sq

3x 3s#3t

Time

sq

2x 2s#2tprints 2s

prints 3s

Page 32: Fall 2006Costas Busch - RPI1 A Universal Turing Machine

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

Page 33: Fall 2006Costas Busch - RPI1 A Universal Turing Machine

Fall 2006 Costas Busch - RPI 33

Example: The set of stringsis countable

},,{ cbaS

We will describe an enumerator for

Approach:

S

Page 34: Fall 2006Costas Busch - RPI1 A Universal Turing Machine

Fall 2006 Costas Busch - RPI 34

Naive enumerator:

Produce the strings in lexicographic order:

aaaaaa

......

Doesn’t work: strings starting with will never be produced

b

aaaa

1s

2s

Page 35: Fall 2006Costas Busch - RPI1 A Universal Turing Machine

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)

Page 36: Fall 2006Costas Busch - RPI1 A Universal Turing Machine

Fall 2006 Costas Busch - RPI 36

Produce strings in Proper Order:

aaabacbabbbccacbcc

aaaaabaac......

length 2

length 3

length 1abc

1s

2s

Page 37: Fall 2006Costas Busch - RPI1 A Universal Turing Machine

Fall 2006 Costas Busch - RPI 37

Theorem: The set of all Turing Machinesis countable

Proof:

Find an enumeration procedure for the set of Turing Machine strings

Any Turing Machine can be encodedwith a binary string of 0’s and 1’s

Page 38: Fall 2006Costas Busch - RPI1 A Universal Turing Machine

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:YES: print string on output tape if NO:NO: ignore string

Enumerator:

Repeat

Page 39: Fall 2006Costas Busch - RPI1 A Universal Turing Machine

Fall 2006 Costas Busch - RPI 39

010001

10110110101 1011011010100110110101

101101001010101101

Binary strings Turing Machines

1s

2s 101101001010101101

End of Proof

Page 40: Fall 2006Costas Busch - RPI1 A Universal Turing Machine

Fall 2006 Costas Busch - RPI 40

Uncountable Sets

Page 41: Fall 2006Costas Busch - RPI1 A Universal Turing Machine

Fall 2006 Costas Busch - RPI 41

We will prove that there is a languagewhich is not accepted by any Turing machine

L

Technique:

Turing machines are countable

Languages are uncountable

(there are more languages than Turing Machines)

Page 42: Fall 2006Costas Busch - RPI1 A Universal Turing Machine

Fall 2006 Costas Busch - RPI 42

A set is uncountable if it is not countable

Definition:

We will prove that there is a languagewhich is not accepted by any Turing machine

Page 43: Fall 2006Costas Busch - RPI1 A Universal Turing Machine

Fall 2006 Costas Busch - RPI 43

Theorem:

If is an infinite countable set, then

the powerset of is uncountable. S2 S

S

(the powerset is the set whose elements are all possible sets made from the elements of )

S2S

Page 44: Fall 2006Costas Busch - RPI1 A Universal Turing Machine

Fall 2006 Costas Busch - RPI 44

Proof:

Since is countable, we can write S

},,,{ 321 sssS

Elements of S

Page 45: Fall 2006Costas Busch - RPI1 A Universal Turing Machine

Fall 2006 Costas Busch - RPI 45

Elements of the powerset have the form:

},{ 31 ss

},,,{ 10975 ssss

……

S2

Page 46: Fall 2006Costas Busch - RPI1 A Universal Turing Machine

Fall 2006 Costas Busch - RPI 46

We encode each element of the powersetwith a binary string of 0’s and 1’s

1s 2s 3s 4s

1 0 0 0}{ 1s

Powersetelement

Binary encoding

0 1 1 0},{ 32 ss

1 0 1 1},,{ 431 sss

(in arbitrary order)

Page 47: Fall 2006Costas Busch - RPI1 A Universal Turing Machine

Fall 2006 Costas Busch - RPI 47

Observation:Every infinite binary string correspondsto an element of the powerset:

10 Example: 0111 0

Corresponds to: Sssss 2},,,,{ 6541

Page 48: Fall 2006Costas Busch - RPI1 A Universal Turing Machine

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 321 tttS

S2

Page 49: Fall 2006Costas Busch - RPI1 A Universal Turing Machine

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

1t

2t

3t

4t

suppose that this is the respective

Page 50: Fall 2006Costas Busch - RPI1 A Universal Turing Machine

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

1t

2t

3t

4t

Binary string: 0011(birary complement of diagonal)

Take the binary string whose bits are the complement of the diagonal

t

Page 51: Fall 2006Costas Busch - RPI1 A Universal Turing Machine

Fall 2006 Costas Busch - RPI 51

0011tThe binary string

correspondsto an element of the powerset : Ssst 2},,{ 43 S2

Page 52: Fall 2006Costas Busch - RPI1 A Universal Turing Machine

Fall 2006 Costas Busch - RPI 52

Thus, must be equal to some it

However,

the i-th bit in the encoding of is the complement of the bit of , thus:

Contradiction!!!

t

itt

i-th it

itt

t

Page 53: Fall 2006Costas Busch - RPI1 A Universal Turing Machine

Fall 2006 Costas Busch - RPI 53

Since we have a contradiction:

The powerset of is uncountable S2 S

End of proof

Page 54: Fall 2006Costas Busch - RPI1 A Universal Turing Machine

Fall 2006 Costas Busch - RPI 54

An Application: Languages

The set of all Strings:

},,,,,,,,,{},{ * aabaaabbbaabaababaS infinite and countable

Consider Alphabet : },{ baA

(we can enumerate the strings in proper order)

Page 55: Fall 2006Costas Busch - RPI1 A Universal Turing Machine

Fall 2006 Costas Busch - RPI 55

The set of all Strings:

},,,,,,,,,{},{ * aabaaabbbaabaababaS infinite and countable

Any language is a subset of :

},,{ aababaaL

S

Consider Alphabet : },{ baA

Page 56: Fall 2006Costas Busch - RPI1 A Universal Turing Machine

Fall 2006 Costas Busch - RPI 56

Consider Alphabet : },{ baA

The set of all Strings:

},,,,,,,,,{},{ ** aabaaabbbaabaababaAS infinite and countable

The powerset of contains all languages:

}},,,{},...,,{},,{},{},{,{2 aababaabaabaaS uncountable

S

Page 57: Fall 2006Costas Busch - RPI1 A Universal Turing Machine

Fall 2006 Costas Busch - RPI 57

Turing machines: 1M 2M 3M

Languages acceptedBy Turing Machines: 1L 2L 3L

accepts

Denote: },,,{ 321 LLLX countable

Note: SX 2

countable

countable

*},{ baS

Consider Alphabet : },{ baA

Page 58: Fall 2006Costas Busch - RPI1 A Universal Turing Machine

Fall 2006 Costas Busch - RPI 58

X countable

S2 uncountable

Languages acceptedby Turing machines:

All possible languages:

Therefore:SX 2

SS XX 2 have we,2 since

Page 59: Fall 2006Costas Busch - RPI1 A Universal Turing Machine

Fall 2006 Costas Busch - RPI 59

There is a language not acceptedby any Turing Machine:

(Language cannot be described by any algorithm)

Conclusion:

L

SX 2 XL and 2 SL

L

Page 60: Fall 2006Costas Busch - RPI1 A Universal Turing Machine

Fall 2006 Costas Busch - RPI 60

Turing-Acceptable Languages

Non Turing-Acceptable Languages

L

Page 61: Fall 2006Costas Busch - RPI1 A Universal Turing Machine

Fall 2006 Costas Busch - RPI 61

Note that: },,,{ 321 LLLX

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