Chapter 9 Undecidability

49
1 Chapter 9 Chapter 9 Undecidability Undecidability Lithuania 2002---Island Castle

description

Chapter 9 Undecidability. Lithuania 2002---Island Castle. Outline. 9.0 Introduction 9.1 A Language That Is Not Recursively Enumerable 9.2 An Undecidable Problem That Is RE 9.3 Undecidable Problems about TM’s 9.4 Post Correspondence Problem 9.5 Other Undecidable Problems. 9.0 Introduction. - PowerPoint PPT Presentation

Transcript of Chapter 9 Undecidability

Page 1: Chapter 9  Undecidability

11

Chapter 9 Chapter 9 UndecidabilityUndecidability

Lithuania 2002---Island Castle

Page 2: Chapter 9  Undecidability

22

OutlineOutline

9.0 Introduction9.0 Introduction 9.1 A Language That Is Not Recursively 9.1 A Language That Is Not Recursively

EnumerableEnumerable 9.2 An Undecidable Problem That Is RE9.2 An Undecidable Problem That Is RE 9.3 Undecidable Problems about TM’s9.3 Undecidable Problems about TM’s 9.4 Post Correspondence Problem9.4 Post Correspondence Problem 9.5 Other Undecidable Problems9.5 Other Undecidable Problems

Page 3: Chapter 9  Undecidability

33

9.0 Introduction9.0 Introduction

Concepts to be taught:Concepts to be taught: We will prove the undecidability of several problems We will prove the undecidability of several problems

formally:formally: Does a TM accept (the code for) itself as input?Does a TM accept (the code for) itself as input?

Does a TM accept a certain input?Does a TM accept a certain input?

Actually all nontrivial problems about the language Actually all nontrivial problems about the language accepted by a TM are undecidable. accepted by a TM are undecidable.

Review: An algorithm is a procedure which always halts.Review: An algorithm is a procedure which always halts.

Page 4: Chapter 9  Undecidability

44

9.1 A Language That Is Not RE9.1 A Language That Is Not RE

Review of definitions:Review of definitions:

A language A language LL is is recursiverecursive enumerableenumerable (RE) if (RE) if LL = =

LL((MM) for some TM ) for some TM MM..

A language A language LL is is recursiverecursive if if LL = = LL((MM) for some TM ) for some TM

M M which always halts, regardless of whether or not it which always halts, regardless of whether or not it

accepts (i.e., halts both when accepting and when accepts (i.e., halts both when accepting and when

rejecting).rejecting).

Page 5: Chapter 9  Undecidability

55

9.1 A Language That Is Not RE9.1 A Language That Is Not RE

Goal of this studyGoal of this study

Want to prove Want to prove undecidableundecidable the the languagelanguage of pairs ( of pairs (MM, , ww) )

wherewhere

MM is a TM (suitably coded in binary) with alphabet {0, 1}; is a TM (suitably coded in binary) with alphabet {0, 1};

ww is a string of 0’s and 1’s; is a string of 0’s and 1’s;

MM accepts input accepts input ww..

If this problem is undecidable, then those with If this problem is undecidable, then those with generalgeneral

alphabet is also undecidable.alphabet is also undecidable.

Page 6: Chapter 9  Undecidability

66

9.1 A Language That Is Not RE9.1 A Language That Is Not RE

Steps to achieve the goal in the 1Steps to achieve the goal in the 1stst stage (the 2 stage (the 2ndnd stage is in the next section):stage is in the next section): Coding the TM into a binary string.Coding the TM into a binary string.

Treating Treating anyany binary string as a TM. binary string as a TM.

Regarding a Regarding a non-well-formed stringnon-well-formed string as a TM with no move. as a TM with no move.

Setting up a language Setting up a language LLdd (called (called diagonalization languagediagonalization language) )

consisting of all strings consisting of all strings ww such that the TM represented by such that the TM represented by ww does does notnot accept the input accept the input ww..

Page 7: Chapter 9  Undecidability

77

9.1 A Language That Is Not RE9.1 A Language That Is Not RE

Steps to achieve the goal in the 1Steps to achieve the goal in the 1stst stage (the stage (the 22ndnd stage is in the next section): stage is in the next section): Language Language LLdd (called (called diagonalization languagediagonalization language):):

TM M TM M represented represented

by by www No! (not

accepted)

w Ld

Ld = {w|w not accepted by TM represented by w}

Page 8: Chapter 9  Undecidability

88

9.1 A Language That Is Not RE9.1 A Language That Is Not RE

Properties of the diagonalization language Properties of the diagonalization language LLdd

It can be proved that there is no TM which can accept LIt can be proved that there is no TM which can accept Ldd

(later) !!!(later) !!!

Showing that no TM can accept a language is Showing that no TM can accept a language is strongerstronger than than

showing that it is undecidable (i.e., it has no algorithm or has showing that it is undecidable (i.e., it has no algorithm or has

no TM that always haltsno TM that always halts).).

LLdd plays the same role as the program plays the same role as the program HH22 in Section 8.1.2 of in Section 8.1.2 of

the last chapter (with self-contradictthe last chapter (with self-contradictionion property) . property) .

Page 9: Chapter 9  Undecidability

99

9.1 A Language That Is Not RE9.1 A Language That Is Not RE

9.1.1 Enumerating the Binary Numbers9.1.1 Enumerating the Binary Numbers

We want to assign integers to binary strings in We want to assign integers to binary strings in

the following way:the following way:

if if ww is a binary string, then regard 1 is a binary string, then regard 1ww as an as an

integer integer ii, and call , and call ww the the iith string, denoted th string, denoted

as as wwii.. (1w)2 = i10 w = ith string = wi

Page 10: Chapter 9  Undecidability

1010

9.1 A Language That Is Not RE9.1 A Language That Is Not RE

9.1.2 Codes for the TM’s9.1.2 Codes for the TM’s We want to define the We want to define the iith TM th TM MMii after encoding the after encoding the

7-tuple of the TM and assigning integers to the states, 7-tuple of the TM and assigning integers to the states, tape symbols, and directions tape symbols, and directions LL and and RR in the following in the following way:way:

States are numbered as States are numbered as qq11, , qq22, …, , …, qqrr, with , with qq11 as the as the

start state, and start state, and qq22 the only accepting state. the only accepting state.

Tape symbols are numbered as Tape symbols are numbered as XX11, , XX22, …, , …, XXss, with , with

XX11 = 0, = 0, XX22 = 1, = 1, XX33 = = BB..

LL as as DD11, and , and RR as as DD22..

Page 11: Chapter 9  Undecidability

1111

9.1 A Language That Is Not RE9.1 A Language That Is Not RE

9.1.2 Codes for the TM’s9.1.2 Codes for the TM’s

Each transition rule Each transition rule ((qqii, , XXjj) = () = (qqkk, , XXll, , DDmm) is ) is

represented by integers represented by integers ii, , jj, , kk, , ll, and , and mm, and , and is coded as is coded as CC = = 0 0ii1010jj1010kk1010ll1010mm with 1’s as with 1’s as separators separators (an unary number (an unary number representation).representation).

Note that Note that ii, , jj, , kk, , ll, and , and mm are all at least 1, are all at least 1, so there will be no occurrence of two or so there will be no occurrence of two or more consecutive 1’s in the code.more consecutive 1’s in the code.

Page 12: Chapter 9  Undecidability

1212

9.1 A Language That Is Not RE9.1 A Language That Is Not RE

9.1.2 Codes for the TM’s9.1.2 Codes for the TM’s

A complete code for a TM A complete code for a TM MM consists of all consists of all the codes for the transitions, in a certain order, the codes for the transitions, in a certain order, separated by pairs of 1’s:separated by pairs of 1’s:

code of code of MM = = CC111111CC221111……CCnn-1-11111CCnn

where each where each CCii is the code for a transition. is the code for a transition.

Code for (Code for (MM, , ww) is that of ) is that of M,M, followed by followed by 111111 and then and then ww.. Code for (M, w) = CC111111CC221111……CCnn-1-11111CCnn111111ww

Page 13: Chapter 9  Undecidability

1313

9.1 A Language That Is Not RE9.1 A Language That Is Not RE

9.1.2 Codes for the TM’s9.1.2 Codes for the TM’s

Example 9.1Example 9.1

Given a TM Given a TM MM = ({ = ({qq11, , qq22, , qq33}, {0, 1}, {0, 1, }, {0, 1}, {0, 1, BB}, }, , , qq11, , BB, ,

{{qq22}) where }) where is such that is such that

((qq11, 1) = (, 1) = (qq33, 0, , 0, RR),), ((qq33, 0) = (, 0) = (qq11, 1, , 1, RR),), ((qq33, 1) = (, 1) = (qq22, 0, , 0, RR), ),

((qq33, , BB) = () = (qq33, 1, , 1, LL).).

The codes for the transition rules areThe codes for the transition rules are

0011101022101033101011101022, , 0033101011101011101022101022, …, …

And the code for And the code for MM is is

0011101022101033101011101022111100331010111010111010221010221111……

Page 14: Chapter 9  Undecidability

1414

9.1 A Language That Is Not RE9.1 A Language That Is Not RE

9.1.3 The Diagonalization Language9.1.3 The Diagonalization Language Previous coding of TM’s allows a concrete notion of Previous coding of TM’s allows a concrete notion of

MMii, the , the iith TM, which is TM th TM, which is TM MM whose code is whose code is wwii, the , the iith th

binary string.binary string. If If wwii is is notnot a valid code of a TM a valid code of a TM, we take , we take MMii to be the to be the

TM with one state and TM with one state and nono transition. transition. That is, a TM with an invalid code That is, a TM with an invalid code wwii will halt will halt

immediately on any input.immediately on any input. Therefore, we have a list of TM’s in a certain order and Therefore, we have a list of TM’s in a certain order and

there is a 1-to-1 mapping between TM’s there is a 1-to-1 mapping between TM’s MMii and and wwii..

Page 15: Chapter 9  Undecidability

1515

9.1 A Language That Is Not RE9.1 A Language That Is Not RE

9.1.3 The Diagonalization Language9.1.3 The Diagonalization Language

DefinitionDefinition::

The diagonalization language The diagonalization language LLdd is the set of is the set of

strings strings wwii such that such that wwii is is notnot in in LL((MMii).).

That is, That is, LLdd consists of all strings consists of all strings ww such that such that

the TM the TM M,M, whose code is whose code is w,w, does not accept does not accept w w

when given when given ww as input. as input. Ld = {wi | wi L(Mi)}

Page 16: Chapter 9  Undecidability

1616

9.1 A Language That Is Not RE9.1 A Language That Is Not RE 9.1.3 The Diagonalization Language9.1.3 The Diagonalization Language

Why Why LLdd is called “diagonalization language”? See is called “diagonalization language”? See Fig. 9.1 first.Fig. 9.1 first.

11 22 33 44 .. .. ..

11 00 11 11 00 .. .. ..

22 11 11 00 00 .. .. ..

33 00 00 11 11 .. .. ..

44 00 11 00 11 .. .. ..

.. .. .. .. .. .. .. ..

.. .. .. .. .. .. ..

.. .. .. .. .. .. .. .. Fig. 9.1Fig. 9.1

Mi

wi

Page 17: Chapter 9  Undecidability

1717

9.1 A Language That Is Not RE9.1 A Language That Is Not RE 9.1.3 The Diagonalization Language9.1.3 The Diagonalization Language

Meaning of the Meaning of the diagonaldiagonal values: values:

1 means 1 means MMii accepts accepts wwii;;

0 means 0 means MMii does not accept does not accept wwii..

The The iith row is the th row is the characteristic vectorcharacteristic vector for language for language

LL((MMii):):

An An 11’s’s in the row indicate in the row indicatess that the corresponding that the corresponding

string is in the language.string is in the language.

Page 18: Chapter 9  Undecidability

1818

9.1 A Language That Is Not RE9.1 A Language That Is Not RE 9.1.3 The Diagonalization Language9.1.3 The Diagonalization Language

To construct To construct LLdd, just complement the , just complement the diagonaldiagonal to to

collect the corresponding strings; all the resulting 1’s collect the corresponding strings; all the resulting 1’s in the diagonal means that the corresponding in the diagonal means that the corresponding MMii does does

not accept not accept wwii. This is called the . This is called the technique of technique of

diagonalizationdiagonalization,, useful for proving that “ useful for proving that “LLdd is not is not

RE.” RE.”

Because the complement of the diagonal is 1000… in Because the complement of the diagonal is 1000… in the previous figure, so the previous figure, so LLdd contains contains ww11 = = (from 1(from 1), ),

but does not contain but does not contain ww22, , ww33, , ww44,…,…

Page 19: Chapter 9  Undecidability

1919

9.1 A Language That Is Not RE9.1 A Language That Is Not RE 9.1.3 The Diagonalization Language9.1.3 The Diagonalization Language

The The complementedcomplemented diagonaldiagonal disagrees in some disagrees in some columncolumn with every rowwith every row of the table of Fig. 9.1, of the table of Fig. 9.1, therefore it (any row) cannot be the characteristic therefore it (any row) cannot be the characteristic vector of any TM!vector of any TM!

( ( 對每一列對每一列 rowrow,至少在某一行,至少在某一行 columncolumn 不會與原來不會與原來的列一致!的列一致! ))

A A non-zeronon-zero element at location ( element at location (ii, , ii) in the ) in the complemented diagonal means that complemented diagonal means that MMii does not does not

accept the corresponding accept the corresponding wwii. . (A)(A)

Page 20: Chapter 9  Undecidability

2020

9.1 A Language That Is Not RE9.1 A Language That Is Not RE

9.1.5 Proof that 9.1.5 Proof that LLdd is not RE is not RE

Theorem 9.2Theorem 9.2 (“ (“悲劇定理“悲劇定理“ ))

LLd d is not an RE language. That is, no TM acceptsis not an RE language. That is, no TM accepts LLd.d.

Proof. Proof. Prove by contradiction.Prove by contradiction.

Let Let LLdd be be LL((MM) for some TM ) for some TM MM. Then . Then MM is one of is one of

the TM’s in the TM list mentioned previouslythe TM’s in the TM list mentioned previously, , say say

MMii.. Now, check Now, check if if the corresponding the corresponding wwii is in is in LLdd (see (see

the next page).the next page).

Page 21: Chapter 9  Undecidability

2121

9.1 A Language That Is Not RE9.1 A Language That Is Not RE 9.1.5 Proof that 9.1.5 Proof that LLdd is not RE is not RE

Proof. (cont’d)Proof. (cont’d) If If wwiiLLdd, then , then MMii accepts accepts wwii (because (because LL((MMii) = ) = LLdd). But this ). But this

is is impossibleimpossible because by definition of because by definition of LLdd, , wwii cannot be cannot be

accepted by accepted by MMii. Contradiction.. Contradiction.

If If wwiiLLdd, then , then wwii is is notnot accepted by accepted by MMii because because LLdd = = LL((MMii). ).

This in turns means This in turns means wwiiLLdd by the definition of by the definition of LLdd (see (see

statement (A) in the last page). Contradiction.statement (A) in the last page). Contradiction. Neither case holds, so the assumption that Neither case holds, so the assumption that LLdd = = LL((MM) for some ) for some

TM TM MM must be false. must be false. That is, no TM accepts That is, no TM accepts LLdd. Done.. Done.

Page 22: Chapter 9  Undecidability

2222

9.2 An Undecidable Problem 9.2 An Undecidable Problem That Is REThat Is RE

Concepts to be taught:Concepts to be taught: RE languages are RE languages are acceptedaccepted ( (recognizedrecognized) by TM’s.) by TM’s. RE languages may be grouped into two classes:RE languages may be grouped into two classes:

Class 1 (Class 1 (recursive languagerecursive language) --- each language ) --- each language LL in this class has a TM (thought as an algorithm) in this class has a TM (thought as an algorithm) which not only accepts strings of which not only accepts strings of LL, , but also tells but also tells us what strings are not in us what strings are not in LL by haltingby halting..

Class 2 (Class 2 (RE but not recursiveRE but not recursive) --- each language ) --- each language LL in this class has a TM (in this class has a TM (notnot thought as an thought as an algorithm) which accepts strings of algorithm) which accepts strings of LL, , but may but may notnot halthalt when a given input string is not in when a given input string is not in LL..

Page 23: Chapter 9  Undecidability

2323

9.2 An Undecidable Problem 9.2 An Undecidable Problem That Is REThat Is RE

9.2.1 Recursive Languages9.2.1 Recursive Languages Formally, Formally, a language a language LL is is recursiverecursive if if LL = = LL((MM) for ) for

some TM some TM MM such that: such that:

(1) If (1) If wwLL, then , then MM acceptsaccepts ( (and therefore haltsand therefore halts).).

(2) If (2) If wwLL, then , then MM eventually haltseventually halts, although it , although it nevernever

enters an accepting state (enters an accepting state (i.e., i.e., “reject”“reject”) .) .

A TM of this type corresponds to the formal notion A TM of this type corresponds to the formal notion

of of algorithmalgorithm..

Page 24: Chapter 9  Undecidability

2424

9.2 An Undecidable Problem 9.2 An Undecidable Problem That Is REThat Is RE

9.2.1 Recursive Languages9.2.1 Recursive Languages

A given language A given language L, L, regarded as a problemregarded as a problem,, is called is called

decidabledecidable if if LL is a recursive language; and is a recursive language; and

undecidableundecidable if not. if not.

The existence or nonexistence of an algorithm to The existence or nonexistence of an algorithm to

solve a problem (i.e., the problem is decidable or solve a problem (i.e., the problem is decidable or

undecidable) is undecidable) is more importantmore important than the existence or than the existence or

nonexistence of a TM to solve the problem.nonexistence of a TM to solve the problem.

Page 25: Chapter 9  Undecidability

2525

9.2 An Undecidable Problem 9.2 An Undecidable Problem That Is REThat Is RE

9.2.1 Recursive Languages9.2.1 Recursive Languages

A given language A given language L, L, regarded as a problemregarded as a problem,, is called is called

decidabledecidable if if LL is a recursive language; and is a recursive language; and undecidableundecidable if if

not. not.

Decidable prob. Decidable prob. recursive lang. recursive lang. LL

there is a TM there is a TM MM halts with halts with LL as input as input

Page 26: Chapter 9  Undecidability

2626

9.2 An Undecidable Problem 9.2 An Undecidable Problem That Is REThat Is RE

9.2.1 Recursive Languages9.2.1 Recursive Languages Relationships among three classes of languages (Relationships among three classes of languages (only only

LLdd is studied so faris studied so far))

Recursive

RE but not Recursive Not RE

Ld

LuLd Lne

Figure 9.2

Le

Lu

Page 27: Chapter 9  Undecidability

2727

9.2 An Undecidable Problem 9.2 An Undecidable Problem That Is REThat Is RE

9.2.1 Recursive Languages9.2.1 Recursive Languages LLuu, the , the universal languageuniversal language, will soon be , will soon be

defined and proved defined and proved notnot to be recursive, though to be recursive, though it is an RE language.it is an RE language.

9.2.2 Complements of Recursive and RE 9.2.2 Complements of Recursive and RE LanguagesLanguages A powerful tool of proving is A powerful tool of proving is languagelanguage

complementationcomplementation.. We will show that the We will show that the recursive language is recursive language is closedclosed

under complementationunder complementation..

Page 28: Chapter 9  Undecidability

2828

9.2 An Undecidable Problem That 9.2 An Undecidable Problem That Is REIs RE

9.2.2 Complements of Recursive & RE Langs.9.2.2 Complements of Recursive & RE Langs. Theorem 9.3Theorem 9.3: If a language : If a language LL is recursive, so is is recursive, so isLL..

Proof. Proof. Prove by constructing a halting TMProve by constructing a halting TM to acceptto acceptL.L.

Let TM Let TM MM accepts accepts L, L, which always halts which always halts.. Construct a new Construct a new TMTMMM for for MM as follows (illustrated by Fig. 9.3). as follows (illustrated by Fig. 9.3).

Mw

Accept

Reject

Accept

Reject

Figure 9.3MM

Page 29: Chapter 9  Undecidability

2929

9.2 An Undecidable Problem 9.2 An Undecidable Problem That Is REThat Is RE

9.2.2 Complements of Recursive & RE langs.9.2.2 Complements of Recursive & RE langs.Proof. Proof. (cont’d)(cont’d)..

1. The accepting states of 1. The accepting states of MM are made nonaccepting are made nonaccepting with with nono transitions, i.e., in these states transitions, i.e., in these states MM will will halthalt without accepting.without accepting.

2.2.MM has a has a newnew accepting state accepting state rr & no transition from & no transition from rr..3. For each combination of a nonaccepting state of 3. For each combination of a nonaccepting state of MM & &

a tape symbol of a tape symbol of MM such that such that MM has has nono transition (i.e., transition (i.e., MM halts without acceptinghalts without accepting), ), add a transitionadd a transition to the to the accepting state accepting state rr..

Then if Then if MM halts, so is halts, so isMM, and, andMM accepts strings not accepts strings not accepted by accepted by MM..

Page 30: Chapter 9  Undecidability

3030

9.2 An Undecidable Problem 9.2 An Undecidable Problem That Is REThat Is RE

9.2.2 Complements of Recursive & RE 9.2.2 Complements of Recursive & RE

LanguagesLanguages Theorem 9.4 Theorem 9.4

If a language If a language LL and its complement are RE, then and its complement are RE, then LL is is

recursive, recursive, and so isand so isLL (by Theorem 9.3) (by Theorem 9.3)..

ProofProof. See the text book. (. See the text book. (Easy by Fig. 9.4 Easy by Fig. 9.4 in the next in the next

pagepage..))

Page 31: Chapter 9  Undecidability

3131

9.2 An Undecidable Problem 9.2 An Undecidable Problem That Is REThat Is RE

9.2.2 Complements of Recursive & RE 9.2.2 Complements of Recursive & RE LanguagesLanguages Theorem 9.4 Theorem 9.4

M1

w

Accept Accept

RejectM2Accept

Fig. 9.4.Fig. 9.4.

Accept halt

Page 32: Chapter 9  Undecidability

3232

9.2 An Undecidable Problem 9.2 An Undecidable Problem That Is REThat Is RE

9.2.2 Complements of Recursive & RE langs.9.2.2 Complements of Recursive & RE langs. Of the 9 possibilities of placing Of the 9 possibilities of placing LL and andLL in Fig. 9.2, in Fig. 9.2,

only the following 4 are valid by Theorems 9.3 and only the following 4 are valid by Theorems 9.3 and 9.4:9.4: Both Both LL and andLL are recursive ( are recursive (bothboth in the in the innerinner ring ring

of Fig. 9.2)of Fig. 9.2) Neither Neither LL nor norLL is RE. ( is RE. (bothboth in the in the outerouter ring) ring) LL is RE but not recursive, and is RE but not recursive, andLL is not in RE ( is not in RE (oneone

in the in the middlemiddle ring, and the ring, and the otherother in the in the outerouter ring) ring) L L is RE but not recursive, and is RE but not recursive, and LL is not in RE (a is not in RE (a

swapswap of above) of above)

Page 33: Chapter 9  Undecidability

3333

9.2 An Undecidable Problem 9.2 An Undecidable Problem That Is REThat Is RE

9.2.2 Complements of Recursive & RE langs.9.2.2 Complements of Recursive & RE langs. Of the 9 possibilities of placing Of the 9 possibilities of placing LL and andLL in Fig. 9.2, in Fig. 9.2,

only the following 4 are valid by Theorems 9.3 and only the following 4 are valid by Theorems 9.3 and 9.4:9.4:

Recursive

RE but not Recursive Not RE

Recursive

RE but not Recursive Not RE

Recursive

RE but not Recursive Not RE

Case 1 Case 2 Cases 3 & 4

Page 34: Chapter 9  Undecidability

3434

9.2 An Undecidable Problem 9.2 An Undecidable Problem That Is REThat Is RE

9.2.2 Complements of Recursive & RE langs.9.2.2 Complements of Recursive & RE langs. Example 9.5Example 9.5

LLdd is not RE as shown before. is not RE as shown before.So,So,LLdd cannot be recursive (not in the four cases cannot be recursive (not in the four cases

above). above). (Otherwise, (Otherwise, LLdd is recursive by Thm 9.4 and so is recursive by Thm 9.4 and so is RE too by definition, contradiction!)is RE too by definition, contradiction!)

It can be shown thatIt can be shown thatLLdd is RE (omitted) is RE (omitted), just , just like the way we show the universal language like the way we show the universal language LLuu to be RE (shown next).to be RE (shown next).

Note thatNote thatLLdd is the set of strings is the set of strings wwii such that the such that the corresponding corresponding MMii accepts accepts wwii..

Page 35: Chapter 9  Undecidability

3535

9.2 An Undecidable Problem 9.2 An Undecidable Problem That Is REThat Is RE

9.2.2 Complements of Recursive & RE langs.9.2.2 Complements of Recursive & RE langs. Example 9.5Example 9.5

It can be shown thatIt can be shown thatLLdd is RE is RE (omitted) (omitted) but not recursivebut not recursive..

Recursive

RE but not Recursive Not RE

Ld

LuLd Lne

Figure 9.2

Le

Lu

Page 36: Chapter 9  Undecidability

3636

9.2 An Undecidable Problem 9.2 An Undecidable Problem That Is REThat Is RE

9.2.2 Complements of Recursive & RE langs.9.2.2 Complements of Recursive & RE langs.

In conclusionIn conclusion,,LLdd is is RERE butbut not recursive not recursive andand soso

undecidable undecidable

ThatThat isis, , althoughalthough therethere isis a TM a TM forforLLdd, , thethe problemproblem

defineddefined bybyLLdd is undecidable is undecidable (there(there isis nono

algorithmalgorithm forfor it).it).

TheThe universaluniversal languagelanguage L Luu hashas thethe same same propertyproperty, ,

as as provedproved nextnext..

Page 37: Chapter 9  Undecidability

3737

9.2 An Undecidable Problem 9.2 An Undecidable Problem That Is REThat Is RE

9.2.3 The Universal Language9.2.3 The Universal Language

DefinitionDefinition::

The universal language The universal language LLuu is the set of binary strings, is the set of binary strings,

each of which encodes, in the notation of 9.1.2, a pair each of which encodes, in the notation of 9.1.2, a pair

((MM,, w w), where ), where MM is a TM with the binary alphabet, is a TM with the binary alphabet,

and and ww is a string in ( is a string in (00 + + 11))**, such that , such that ww is in is in LL((MM).). Compare:Compare:LLdd is the set of strings is the set of strings wwii such that the such that the corresponding corresponding MMii accepts accepts wwii (note the numbering (note the numbering ii here)here)

Page 38: Chapter 9  Undecidability

3838

9.2 An Undecidable Problem 9.2 An Undecidable Problem That Is REThat Is RE

9.2.3 The Universal Language9.2.3 The Universal Language It can be shown It can be shown (Thm 9.6)(Thm 9.6) that there is a TM that there is a TM UU, called , called

universaluniversal Turing machineTuring machine, which accepts , which accepts LLuu, i.e., , i.e., LL((UU) = ) = LLuu..

For the proof, see the textbook (p. 387~389). Easy in concept.For the proof, see the textbook (p. 387~389). Easy in concept.

Essence of proof: construct a multitape TM Essence of proof: construct a multitape TM UU to simulate to simulate MM on on ww, so that , so that UU accepts ( accepts (MM, , ww) ) if and onlyif and only MM accepts accepts ww. .

So So LLuu is an RE language. is an RE language.

UU is in the TM list mentioned previously. is in the TM list mentioned previously.

Page 39: Chapter 9  Undecidability

3939

9.2 An Undecidable Problem 9.2 An Undecidable Problem That Is REThat Is RE

9.2.3 The Universal Language9.2.3 The Universal Language Construct a multitape TM Construct a multitape TM UU to simulate to simulate MM on on ww, so that , so that UU accepts ( accepts (MM, , ww) )

if and only if and only MM accepts accepts ww. .

Finite control

Tape 1

Tape 2

Tape 3

Tape 4

Tape 1: place input (M, w)

Tape 2: place tape of M

Tape 3: place state of M

Tape 4: as a scratch tape

For simulation detail, see the textbook (p. 388~389).the textbook (p. 388~389).

Page 40: Chapter 9  Undecidability

4040

9.2 An Undecidable Problem 9.2 An Undecidable Problem That Is REThat Is RE

9.2.4 Undecidability of the Universal Language9.2.4 Undecidability of the Universal Language Theorem 9.6 Theorem 9.6

LLuu is RE but not recursive. is RE but not recursive.Proof. To prove the second half (Proof. To prove the second half (not recursivenot recursive) by contradiction.) by contradiction.

We know We know LLuu is RE. Now suppose is RE. Now suppose L Luu is recursive. is recursive.

By Theorem 9.3,By Theorem 9.3,LLuu is also recursiveis also recursive..

So we can construct a TM So we can construct a TM MM to to acceptacceptLLuu, and , and then we also can then we also can

construct a TM construct a TM MM’’ to accept to accept LLd d (shown in the next pages)(shown in the next pages)..

But this is contradictory, because we have know But this is contradictory, because we have know LLdd is not RE. is not RE.

Therefore the assumption Therefore the assumption LLuu is recursive is wrong. Done. is recursive is wrong. Done.

What is left is to show the construction of TM What is left is to show the construction of TM MM’’to accept to accept LLdd. .

Correct !!!

Page 41: Chapter 9  Undecidability

4141

8.1 Problems That Computers 8.1 Problems That Computers Cannot Solve Cannot Solve (revisited)(revisited)

8.1.3 Reducing One Problem to Another8.1.3 Reducing One Problem to Another The above example illustrates how to reduce a The above example illustrates how to reduce a

problem to another.problem to another. An illustration of this idea is:An illustration of this idea is:

ConstructP1 instance

P2 instance

Decide yes

noOld problem Ld

New

problem LLuu

Page 42: Chapter 9  Undecidability

4242

9.2 An Undecidable Problem 9.2 An Undecidable Problem That Is REThat Is RE

9.2.4 Undecidability of the Universal Language9.2.4 Undecidability of the Universal LanguageProof. (cont’d)Proof. (cont’d)

The construction of The construction of MM’’ is illustrated as follows. The is illustrated as follows. The details are explained in the next page. The concept is details are explained in the next page. The concept is a a reductionreduction of of LLdd to to LLuu..

Hypothetical algorithm M

forLu

w

Accept

Reject

Accept

Reject

Figure 9.6

Copy w111w

M’ for Ld

Page 43: Chapter 9  Undecidability

4343

9.2 An Undecidable Problem 9.2 An Undecidable Problem That Is REThat Is RE

9.2.4 Undecidability of the Universal Language9.2.4 Undecidability of the Universal LanguageProof. (cont’d)Proof. (cont’d) Let Let MM be the TM such that be the TM such that LL((MM) =) =LLuu. As shown in . As shown in

Fig. 9.6, we modify Fig. 9.6, we modify MM into into M'M' such that it accepts such that it accepts LLdd as as follows (in the next page).follows (in the next page). Note that each input into Note that each input into MM is a pair ( is a pair (MMii, , wwii) where ) where

MMii is the code of a TM is the code of a TM MMii and and wwii is a binary input is a binary input string into string into MMii..

Also, note that each input into Also, note that each input into M'M' is the code of a is the code of a TM because TM because M'M' accept accept LLdd..

Page 44: Chapter 9  Undecidability

4444

9.2 An Undecidable Problem 9.2 An Undecidable Problem That Is REThat Is RE

9.2.4 Undecidability of the Universal Language9.2.4 Undecidability of the Universal Language

Proof. (cont’d)Proof. (cont’d)

(1)(1) Given input binary string Given input binary string ww, , M'M' changes it to changes it to ww111111ww

which means the pair (which means the pair (M''M'', , ww), where ), where M''M'' is the TM is the TM

encoded by encoded by ww. This can be done by a TM called . This can be done by a TM called

““copycopy” as shown in Fig. 9.6.” as shown in Fig. 9.6.

Page 45: Chapter 9  Undecidability

4545

9.2 An Undecidable Problem 9.2 An Undecidable Problem That Is REThat Is RE

9.2.4 Undecidability of the Universal 9.2.4 Undecidability of the Universal LanguageLanguage

Proof. (cont’d)Proof. (cont’d)

(2)(2) If If ww into into M'M' is is wwii representing representing MMii in the TM list, then in the TM list, then

the input to the hypothetical algorithm the input to the hypothetical algorithm MM for forLLuu is is

((MMii, , wwii). Also, since ). Also, since MM accepts acceptsLLuu, this means that , this means that MM

accepts accepts wwii111111wwii = ( = (MMii, , wwii)) if and only if if and only if MMii does not does not

accept accept wwii. This in turn means . This in turn means M'M' accepts if and only if accepts if and only if

MMii does not accept does not accept wwii..

Page 46: Chapter 9  Undecidability

4646

9.2 An Undecidable Problem 9.2 An Undecidable Problem That Is REThat Is RE

9.2.4 Undecidability of the Universal 9.2.4 Undecidability of the Universal LanguageLanguage

Proof. (cont’d)Proof. (cont’d)

Hypothetical algorithm M

forLu

wi

Accept

Reject

Accept

Reject

Figure 9.6

Copy wi111wi

M’ for Ld

(Mi, wi)

M accepts wi111wi=(Mi, wi) if only if Mi does not accept wi

M’ accepts wi if only if Mi does not accept wi

Page 47: Chapter 9  Undecidability

4747

9.2 An Undecidable Problem 9.2 An Undecidable Problem That Is REThat Is RE

9.2.4 Undecidability of the Universal 9.2.4 Undecidability of the Universal LanguageLanguageProof. (cont’d)Proof. (cont’d)

In other words, In other words, M'M' accepts accepts ww if and only if if and only if ww is in is in

LLdd..

That is, we have TM That is, we have TM M‘M‘ which accepts which accepts LLdd, which is , which is

impossible because impossible because LLd d is not an RE language is not an RE language as as

proved previously (Thm 9.2 proved previously (Thm 9.2 悲劇定理悲劇定理 ))..

Page 48: Chapter 9  Undecidability

4848

9.2 An Undecidable Problem 9.2 An Undecidable Problem That Is REThat Is RE

9.2.4 Undecidability of the Universal 9.2.4 Undecidability of the Universal Language Language (cont’d)(cont’d)

Recursive

RE but not Recursive Not RE

Ld

LuLd Lne

Figure 9.2

Le

Lu

Page 49: Chapter 9  Undecidability

4949

9.3 Undecidable Problems about TM’s9.3 Undecidable Problems about TM’s 9.4 Post Correspondence Problem9.4 Post Correspondence Problem 9.5 Other Undecidable Problems9.5 Other Undecidable Problems (see the textbook)(see the textbook)