Universal turing coastus

62
Costas Busch - LSU 1 A Universal Turing Machine

Transcript of Universal turing coastus

Page 1: Universal turing coastus

Costas Busch - LSU 1

A Universal Turing Machine

Page 2: Universal turing coastus

Costas Busch - LSU 2

Turing Machines are “hardwired”

they executeonly one program

A limitation of Turing Machines:

Real Computers are re-programmable

Page 3: Universal turing coastus

Costas Busch - LSU 3

Solution: Universal Turing Machine

• Reprogrammable machine

• Simulates any other Turing Machine

Attributes:

Page 4: Universal turing coastus

Costas Busch - LSU 4

Universal Turing Machine simulates any Turing MachineM

Input of Universal Turing Machine:

Description of transitions of M

Input string of M

Page 5: Universal turing coastus

Costas Busch - LSU 5

Universal Turing Machine M

Description of

Tape Contents of

M

State of M

Three tapes

Tape 2

Tape 3

Tape 1

Page 6: Universal turing coastus

Costas Busch - LSU 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: Universal turing coastus

Costas Busch - LSU 7

Alphabet Encoding

Symbols: a b c d

Encoding: 1 11 111 1111

Page 8: Universal turing coastus

Costas Busch - LSU 8

State Encoding

States: 1q 2q 3q 4q

Encoding: 1 11 111 1111

Head Move Encoding

Move:

Encoding:

L R

1 11

Page 9: Universal turing coastus

Costas Busch - LSU 9

Transition Encoding

Transition: ),,(),( 21 Lbqaq

Encoding: 10110110101

separator

Page 10: Universal turing coastus

Costas Busch - LSU 10

Turing Machine Encoding

Transitions:),,(),( 21 Lbqaq

Encoding:10110110101

),,(),( 32 Rcqbq

110111011110101100

separator

Page 11: Universal turing coastus

Costas Busch - LSU 11

Tape 1 contents of Universal Turing Machine:

binary encoding of the simulated machineM

1100011101111010100110110110101Tape 1

Page 12: Universal turing coastus

Costas Busch - LSU 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: Universal turing coastus

Costas Busch - LSU 13

Language of Turing Machines

L = { 010100101,

00100100101111,

111010011110010101, …… }

(Turing Machine 1)

(Turing Machine 2)

……

Page 14: Universal turing coastus

Costas Busch - LSU 14

Countable Sets

Page 15: Universal turing coastus

Costas Busch - LSU 15

Infinite sets are either: Countable

or

Uncountable

Page 16: Universal turing coastus

Costas Busch - LSU 16

Countable set:There is a one to one correspondence (injection)ofelements of the setto Positive integers (1,2,3,…)

Every element of the set is mapped to a positive number such that no two elements are mapped to same number

Page 17: Universal turing coastus

Costas Busch - LSU 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: Universal turing coastus

Costas Busch - LSU 18

Example:The set of rational numbersis countable

Rational numbers: ,87,

43,

21

Page 19: Universal turing coastus

Costas Busch - LSU 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: Universal turing coastus

Costas Busch - LSU 20

Better Approach

11

21

31

41

12

22

32

13

23

14

Page 21: Universal turing coastus

Costas Busch - LSU 21

11

21

31

41

12

22

32

13

23

14

Page 22: Universal turing coastus

Costas Busch - LSU 22

11

21

31

41

12

22

32

13

23

14

Page 23: Universal turing coastus

Costas Busch - LSU 23

11

21

31

41

12

22

32

13

23

14

Page 24: Universal turing coastus

Costas Busch - LSU 24

11

21

31

41

12

22

32

13

23

14

Page 25: Universal turing coastus

Costas Busch - LSU 25

11

21

31

41

12

22

32

13

23

14

Page 26: Universal turing coastus

Costas Busch - LSU 26

Rational Numbers: ,22,

31,

12,

21,

11

Correspondence:

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

Page 27: Universal turing coastus

Costas Busch - LSU 27

We proved:

the set of rational numbers is countable by describing an enumeration procedure (enumerator) for the correspondence to natural numbers

Page 28: Universal turing coastus

Costas Busch - LSU 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: Universal turing coastus

Costas Busch - LSU 29

EnumeratorMachine for ,,, 321 sss

Ssss ,,, 321

Finite time: ,,, 321 ttt

strings

Soutput(on tape)

Page 30: Universal turing coastus

Costas Busch - LSU 30

Enumerator MachineConfiguration

Time 0

0q

Time

sq

1x 1s#1tprints 1s

Page 31: Universal turing coastus

Costas Busch - LSU 31

Time

sq

3x 3s#3t

Time

sq

2x 2s#2tprints 2s

prints 3s

Page 32: Universal turing coastus

Costas Busch - LSU 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: Universal turing coastus

Costas Busch - LSU 33

Example: The set of stringsis countable

},,{ cbaS

We will describe an enumerator forApproach:

S

Page 34: Universal turing coastus

Costas Busch - LSU 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: Universal turing coastus

Costas Busch - LSU 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: Universal turing coastus

Costas Busch - LSU 36

Produce strings in Proper Order:

aaabacbabbbccacbccaaaaabaac......

length 2

length 3

length 1abc

1s2s

Page 37: Universal turing coastus

Costas Busch - LSU 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: Universal turing coastus

Costas Busch - LSU 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

Page 39: Universal turing coastus

Costas Busch - LSU 39

010001

10110110101 1011011010100110110101

101101001010101101

Binary strings Turing Machines

1s

2s 101101001010101101

End of Proof

ignoreignoreignore

Page 40: Universal turing coastus

Costas Busch - LSU 40

Uncountable Sets

Page 41: Universal turing coastus

Costas Busch - LSU 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: Universal turing coastus

Costas Busch - LSU 42

Theorem:

If is an infinite countable set, then

the powerset of is uncountable. S2 S

S

The powerset contains all possible subsets of

Example:

S2 S

}},{},{},{,{2},{ bababaS S

Page 43: Universal turing coastus

Costas Busch - LSU 43

Proof:

Since is countable, we can list its elements in some order

S

},,,{ 321 sssS

Elements ofS

Page 44: Universal turing coastus

Costas Busch - LSU 44

Elements of the powerset have the form:

},{ 31 ss

},,,{ 10975 ssss

……

S2

They are subsets ofS

Page 45: Universal turing coastus

Costas Busch - LSU 45

We encode each subset of with a binary string of 0’s and 1’s

1s 2s 3s 4s

1 0 0 0}{ 1s

Subset of

Binary encoding

0 1 1 0},{ 32 ss

1 0 1 1},,{ 431 sss

S

S

Page 46: Universal turing coastus

Costas Busch - LSU 46

Every infinite binary string correspondsto a subset of :

10 Example: 0111 0

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

S

Page 47: Universal turing coastus

Costas Busch - LSU 47

Let’s assume (for contradiction) that the powerset is countable

Then: we can list the elements of the powerset in some order

},,,{2 321 tttS

S2

Subsets of S

Page 48: Universal turing coastus

Costas Busch - LSU 48

1 0 0 0 0

1 1 0 0 0

1 1 0 1 0

1 1 0 0 1

Powerset element Binary encoding example

1t

2t

3t

4t

Page 49: Universal turing coastus

Costas Busch - LSU 49

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)

the binary string whose bits are the complement of the diagonal

t

t

Page 50: Universal turing coastus

Costas Busch - LSU 50

0011tThe binary string

correspondsto a subset of : Ssst 2},,{ 43 S

Page 51: Universal turing coastus

Costas Busch - LSU 51

1 0 0 0 0

1 1 0 0 0

1 1 0 1 0

1 1 0 0 1

1t

2t

3t

4t

Question:0011

the binary string whose bits are the complement of the diagonal

t?1tt NO: differ in 1st bit

t

Page 52: Universal turing coastus

Costas Busch - LSU 52

1 0 0 0 0

1 1 0 0 0

1 1 0 1 0

1 1 0 0 1

1t

2t

3t

4t

Question:0011

the binary string whose bits are the complement of the diagonal

t?2tt NO: differ in 2nd bit

t

Page 53: Universal turing coastus

Costas Busch - LSU 53

1 0 0 0 0

1 1 0 0 0

1 1 0 1 0

1 1 0 0 1

1t

2t

3t

4t

Question:0011

the binary string whose bits are the complement of the diagonal

t?3tt NO: differ in 3rd bit

t

Page 54: Universal turing coastus

Costas Busch - LSU 54

Thus: for every i

However,

since they differ in the th bit

Contradiction!!!

itt

iS ttt 2 for some i

i

S2Therefore the powerset is uncountable

End of proof

Page 55: Universal turing coastus

Costas Busch - LSU 55

An Application: Languages

The set of all strings:},,,,,,,,,{},{ * aabaaabbbaabaababaS

infinite and countable

Consider Alphabet : },{ baA

because we can enumerate the strings in proper order

Page 56: Universal turing coastus

Costas Busch - LSU 56

The set of all strings:},,,,,,,,,{},{ * aabaaabbbaabaababaS

infinite and countable

Any language is a subset of :},,{ aababaaL

S

Consider Alphabet : },{ baA

Page 57: Universal turing coastus

Costas Busch - LSU 57

Consider Alphabet : },{ baA

The set of all Strings:},,,,,,,,,{},{ ** aabaaabbbaabaababaAS

infinite and countable

The powerset of contains all languages:}},,,{},...,,{},,{},{},{,{2 aababaabaabaaS

uncountable

S

Page 58: Universal turing coastus

Costas Busch - LSU 58

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 59: Universal turing coastus

Costas Busch - LSU 59

X countable

S2 uncountable

Languages acceptedby Turing machines:

All possible languages:

Therefore: SX 2

SS XX 2get we,2 since

Page 60: Universal turing coastus

Costas Busch - LSU 60

There is a language not acceptedby any Turing Machine:

Conclusion:

L

SX 2 XLL S and 2

Page 61: Universal turing coastus

Costas Busch - LSU 61

Turing-Acceptable Languages

Non Turing-Acceptable Languages

L

Page 62: Universal turing coastus

Costas Busch - LSU 62

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