1 introduction to computability theory lecture14: the halting problem prof. amos israeli

29
1 Introduction to Computability Theory Lecture14: The Halting Problem Prof. Amos Israeli

Upload: cassidy-berman

Post on 02-Apr-2015

220 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 1 Introduction to Computability Theory Lecture14: The Halting Problem Prof. Amos Israeli

1

Introduction to Computability Theory

Lecture14: The Halting Problem

Prof. Amos Israeli

Page 2: 1 Introduction to Computability Theory Lecture14: The Halting Problem Prof. Amos Israeli

In this lecture we present an undecidable language.

The language that we prove to be undecidable is a very natural language namely the language consisting of pairs of the form where Mis a TM accepting string w:

The Halting Problem

2

wMwMATM acceptingTM a is ,

wM ,

Page 3: 1 Introduction to Computability Theory Lecture14: The Halting Problem Prof. Amos Israeli

Since this language requires to decide whether the computation of TM M halts on input w, it is often called The Halting Problem.

Theorem

The halting problem is Turing Recognizable.

The Halting Problem

3

Page 4: 1 Introduction to Computability Theory Lecture14: The Halting Problem Prof. Amos Israeli

Consider a TM U that gets a pair as input and simulates the run of M on input w. If M accepts or rejects so does U. Otherwise, U loops.

Note: U recognizes ATM ,since it accepts any pair

, that is: any pair in which M accepts input w.

Proof

4

wM ,

LwM ,

Page 5: 1 Introduction to Computability Theory Lecture14: The Halting Problem Prof. Amos Israeli

On the previous lecture, we detailed the simulation of a DFA by a TM.

Simulating one TM by another, using the encoding of the first TM is a very similar process. In the next slide we review the main characteristics of TM N simulating TM M, using M’s encoding <M>.

Simulating an Input TM

5

Page 6: 1 Introduction to Computability Theory Lecture14: The Halting Problem Prof. Amos Israeli

TM N works as follows:

1. Mark M’s initial state and w’s initial symbol as the “current state” and “current head location”.

2. Look for M’s next transition on the description of its transition function.

3. Execute M’s transition.

Simulating an Input TM

6

Page 7: 1 Introduction to Computability Theory Lecture14: The Halting Problem Prof. Amos Israeli

4. Move M’s “current state” and “current head location” to their new places.

5. If M’s new state is a deciding state decide according to the state, otherwise – repeat stages 2-5.

Simulating an Input TM

7

Page 8: 1 Introduction to Computability Theory Lecture14: The Halting Problem Prof. Amos Israeli

So far we proved the existence of a language which is not Turing recognizable. Now we continue our quest to prove:

Theorem

The language

is undecidable.

The Language ___ Is Undecidable

8

TMA

wMwMATM acceptingTM a is ,

Page 9: 1 Introduction to Computability Theory Lecture14: The Halting Problem Prof. Amos Israeli

Before we start the proof let us consider two ancient questions:

Question1:

Can god create a boulder so heavy such that he (god) cannot lift?

The Language ___ Is Undecidable

9

TMA

Page 10: 1 Introduction to Computability Theory Lecture14: The Halting Problem Prof. Amos Israeli

Question2:

In the small town of L.J. there is a single barber:

Over the barber’s chair there is a note saying:“I will shave you on one condition: Thaw

shall never shave thyself!!!”

Who Shaves the Barber?

The Language ___ Is Undecidable

10

TMA

Page 11: 1 Introduction to Computability Theory Lecture14: The Halting Problem Prof. Amos Israeli

Assume, by way of contradiction, that is decidable and let H be a TM deciding .

That is

Define now another TM, D, that uses H as a subroutine as follows:

Proof

11

TMA

wMreject

wMacceptwMH

accept not does if

accepts if ,

TMA

Page 12: 1 Introduction to Computability Theory Lecture14: The Halting Problem Prof. Amos Israeli

Define now another TM new D that uses H as a subroutine as follows:

D=“On input where M is a TM:

1. Run H on input .

2. Output the opposite of H’s output namely: If H accepts reject, otherwise accept.“

Proof

12

M

MM ,

Page 13: 1 Introduction to Computability Theory Lecture14: The Halting Problem Prof. Amos Israeli

Note: What we do here is taking advantage of the two facts:

Fact1: TM M should be able to compute with any string as input.

Fact2: The encoding of M, , is a string.

Proof

13

M

Page 14: 1 Introduction to Computability Theory Lecture14: The Halting Problem Prof. Amos Israeli

Running a machine on its encoding is analogous to using a compiler for the computer language Pascal, to compile itself (the compiler is written in Pascal).

As we recall from the two questions self-reference is sometimes means trouble (god forbid…)

Proof

14

Page 15: 1 Introduction to Computability Theory Lecture14: The Halting Problem Prof. Amos Israeli

What we got now is:

Consider now the result of running D with input . What we get is:

Proof

15

M accepts if

M ejects if

Mreject

MacceptMD

r

D

D accepts if

D ejects if

Dreject

DacceptDD

r

Page 16: 1 Introduction to Computability Theory Lecture14: The Halting Problem Prof. Amos Israeli

So if D accepts, it rejects and if it rejects it accepts. Double Trouble.

And it all caused by our assumption that TM H exists!!!

Proof

16

D accepts if

D ejects if

Dreject

DacceptDD

r

Page 17: 1 Introduction to Computability Theory Lecture14: The Halting Problem Prof. Amos Israeli

1. Define .

2. Assume that id decidable and let H be a TM deciding it.

3. Use H to build TM D that gets a string and behaves exactly opposite to H’s behavior, namely:

Proof Review

17

wMwMATM acceptingTM a is ,

TMA

M accepts if

M ejects if

Mreject

MacceptMD

r

Page 18: 1 Introduction to Computability Theory Lecture14: The Halting Problem Prof. Amos Israeli

4. Run TM D on its encoding and conclude:

Contradiction.

Proof Review

18

D accepts if

D ejects if

Dreject

DacceptDD

r

D

Page 19: 1 Introduction to Computability Theory Lecture14: The Halting Problem Prof. Amos Israeli

The following table describes the behavior of each machine on some machine encodings:

So Where is the Diagonalization?

19

acceptacceptM

M

acceptacceptacceptacceptM

acceptacceptM

MMMM

4

3

2

1

4321

Page 20: 1 Introduction to Computability Theory Lecture14: The Halting Problem Prof. Amos Israeli

This table describes the behavior of TM H. Note: TM H rejects where loops.

So Where is the Diagonalization?

20

rejectrejectacceptacceptM

rejectrejectrejectrejectM

acceptacceptacceptacceptM

rejectacceptrejectacceptM

MMMM

4

3

2

1

4321

iM

Page 21: 1 Introduction to Computability Theory Lecture14: The Halting Problem Prof. Amos Israeli

Now TM D is added to the table…

Proof Review

21

???

4

3

2

1

4321

acceptacceptrejectrejectD

acceptrejectrejectacceptacceptM

rejectrejectrejectrejectrejectM

acceptacceptacceptacceptacceptM

acceptrejectacceptrejectacceptM

DMMMM

Page 22: 1 Introduction to Computability Theory Lecture14: The Halting Problem Prof. Amos Israeli

So far we proved the existence of a language which is not Turing recognizable. Now we will prove a theorem that will enable us to identify a specific language, namely , as a language that is not Turing recognizable.

__ Is Not Turing Reecognizable

22

TMA

TMA

Page 23: 1 Introduction to Computability Theory Lecture14: The Halting Problem Prof. Amos Israeli

(Reminder) A Language L is Turing recognizable if there exists a TM recognizing L. That is, a TM that accepts any input .

A Language L is co-Turing recognizable if the complement of L, , is Turing recognizable.

__ Is Not Turing Reecognizable

23

TMA

Lw

L

Page 24: 1 Introduction to Computability Theory Lecture14: The Halting Problem Prof. Amos Israeli

Theorem

A language L Is decidable, if and only if it is Turing recognizable and co-Turing recognizable.

Proof ->

If L is decidable so is its complement, . Any decidable language is Turing recognizable.

__ Is Not Turing Reecognizable

24

TMA

L

Page 25: 1 Introduction to Computability Theory Lecture14: The Halting Problem Prof. Amos Israeli

Proof ->

If L is decidable so is its complement, . A TM to decide , is obtained by running a TM deciding L and deciding the opposite. Any decidable language is Turing recognizable, hence is Turing recognizable and L is co-Turing recognizable.

__ Is Not Turing Reecognizable

25

TMA

L

L

L

Page 26: 1 Introduction to Computability Theory Lecture14: The Halting Problem Prof. Amos Israeli

Proof <-

If L and are both Turing recognizable, there exist two TM-s, , and , that recognize and , respectively. A TM M to decide L can be obtained by running both , and in parallel and halt when one of them accepts.

__ Is Not Turing Recognizable

26

TMA

L

1M 2M

L L

1M 2M

Page 27: 1 Introduction to Computability Theory Lecture14: The Halting Problem Prof. Amos Israeli

Corollary

The language is not Turing recognizable.

Proof

We already know that is Turing recognizable. Assume is Turing recognizable. Then, is co-Turing recognizable. By the previous theorem is decidable, a contradiction.

__ Is Not Turing Recognizable

27

TMA

TMA

TMA

TMA

TMA

TMA

Page 28: 1 Introduction to Computability Theory Lecture14: The Halting Problem Prof. Amos Israeli

This is the diagram we had after we studied CFL-s:

CFL-s Ex: 0| nba nn

RL-s Ex: 0| nan

Discussion

28

Non CFL-s Ex: 0| ncba nnn

???

Page 29: 1 Introduction to Computability Theory Lecture14: The Halting Problem Prof. Amos Israeli

Now, we can add some more details:

CFL-s Ex: 0| nba nn

RL-s Ex: 0| nan

Discussion

29

Decidable Ex: 0| ncba nnn

Turing recognizableEx: TMA

Non Turing recognizableEx: TMA