The Halting Problem Joseph Paul Cohen Joseph Paul Cohen The - - PowerPoint PPT Presentation

the halting problem
SMART_READER_LITE
LIVE PREVIEW

The Halting Problem Joseph Paul Cohen Joseph Paul Cohen The - - PowerPoint PPT Presentation

Basics The Halting Problem Joseph Paul Cohen Joseph Paul Cohen The Halting Problem Basics What is the halting problem? Given some program and some input, determine if the program will halt on the given input. HALT ( # p , x ) = Does the


slide-1
SLIDE 1

Basics

The Halting Problem

Joseph Paul Cohen

Joseph Paul Cohen The Halting Problem

slide-2
SLIDE 2

Basics

What is the halting problem? Given some program and some input, determine if the program will halt on the given input. HALT(#p,x) = Does the program #p halt on input x HALT(#p,x) = TRUE When #p is run on x it ends FALSE When #p is run on x it does not end

Joseph Paul Cohen The Halting Problem

slide-3
SLIDE 3

Basics

What is a program? Some set of instructions that operate on some input f(x) :

1

while x < 3 do

2

print x

3

x = x+1

4

Joseph Paul Cohen The Halting Problem

slide-4
SLIDE 4

Basics

f(x) :

1

while x < 3 do

2

print x

3

x = x+1

4

f(0) − → 0,1,2 f(−1) − → −1,0,1,2 f(5) − → NOTHING PRINTED

Joseph Paul Cohen The Halting Problem

slide-5
SLIDE 5

Basics

What is a program? Every program can be represented as some number f(x) can be represented as some number #f , such as 239847238 f(x) − → #f

Joseph Paul Cohen The Halting Problem

slide-6
SLIDE 6

Basics

f(x) :

1

while x < 3 do

2

print x

3

x = x+1

4

What does this return? HALT(#f ,2)

Joseph Paul Cohen The Halting Problem

slide-7
SLIDE 7

Basics

f(x) :

1

while x < 3 do

2

print x

3

x = x+1

4

What does this return? HALT(#f ,2) TRUE

Joseph Paul Cohen The Halting Problem

slide-8
SLIDE 8

Basics

t(x) :

1

while x > 3 do

2

print x

3

x = x+1

4

What does this return? HALT(#t,2)

Joseph Paul Cohen The Halting Problem

slide-9
SLIDE 9

Basics

t(x) :

1

while x > 3 do

2

print x

3

x = x+1

4

What does this return? HALT(#t,2) TRUE

Joseph Paul Cohen The Halting Problem

slide-10
SLIDE 10

Basics

t(x) :

1

while x > 3 do

2

print x

3

x = x+1

4

What does this return? HALT(#t,5)

Joseph Paul Cohen The Halting Problem

slide-11
SLIDE 11

Basics

t(x) :

1

while x > 3 do

2

print x

3

x = x+1

4

What does this return? HALT(#t,5) FALSE

Joseph Paul Cohen The Halting Problem

slide-12
SLIDE 12

Basics

There can never be a program for the the function HALT

Joseph Paul Cohen The Halting Problem

slide-13
SLIDE 13

Basics

There can never be a program for the the function HALT This is a big deal

Joseph Paul Cohen The Halting Problem

slide-14
SLIDE 14

Basics

Outline for Proof We assume that a program for HALT exists. (There is a #HALT) We write a program with #HALT We use that program and come to a contradiction

Joseph Paul Cohen The Halting Problem

slide-15
SLIDE 15

Basics

g(x) = FALSE If x run on x never halts ↑ Never returns if x run on x halts g(x) :

1

if HALT(x,x) == TRUE then

2

while TRUE do

3

print “Never Returns”

4

else

5

return FALSE

6

Joseph Paul Cohen The Halting Problem

slide-16
SLIDE 16

Basics

g(x) = FALSE If x run on x never halts ↑ Never returns if x run on x halts g(x) :

1

if HALT(x,x) == TRUE then

2

while TRUE do

3

print “Never Returns”

4

else

5

return FALSE

6

HALT(#p,x) = TRUE If when #p is run on x it ends FALSE If when #p is run on x it does not end

Joseph Paul Cohen The Halting Problem

slide-17
SLIDE 17

Basics

g is a program so it has a number #g

Joseph Paul Cohen The Halting Problem

slide-18
SLIDE 18

Basics

What happens when we run #g on itself? g(#g)

Joseph Paul Cohen The Halting Problem

slide-19
SLIDE 19

Basics

g(x) :

1

if HALT(x,x) == TRUE then

2

while TRUE do

3

print “Never Returns”

4

else

5

return FALSE

6

Lets look at what happens when: g halts when run on g = ⇒ HALT(#g,#g) == FALSE = ⇒ g does not halt on g

Joseph Paul Cohen The Halting Problem

slide-20
SLIDE 20

Basics

g(x) :

1

if HALT(x,x) == TRUE then

2

while TRUE do

3

print “Never Returns”

4

else

5

return FALSE

6

How about: g does not halt when run on g = ⇒ HALT(#g,#g) == TRUE = ⇒ g halts when run on g

Joseph Paul Cohen The Halting Problem

slide-21
SLIDE 21

Basics

We have a contradiction so there can be no program for HALT

Joseph Paul Cohen The Halting Problem