the halting problem
play

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


  1. Basics The Halting Problem Joseph Paul Cohen Joseph Paul Cohen The Halting Problem

  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 � TRUE When # p is run on x it ends HALT ( # p , x ) = FALSE When # p is run on x it does not end Joseph Paul Cohen The Halting Problem

  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

  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

  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

  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

  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

  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

  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

  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

  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

  12. Basics There can never be a program for the the function HALT Joseph Paul Cohen The Halting Problem

  13. Basics There can never be a program for the the function HALT This is a big deal Joseph Paul Cohen The Halting Problem

  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

  15. Basics � FALSE If x run on x never halts g ( x ) = ↑ 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

  16. Basics � FALSE If x run on x never halts g ( x ) = ↑ 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 � TRUE If when # p is run on x it ends HALT ( # p , x ) = If when # p is run on x it does not end FALSE Joseph Paul Cohen The Halting Problem

  17. Basics g is a program so it has a number # g Joseph Paul Cohen The Halting Problem

  18. Basics What happens when we run # g on itself? g ( # g ) Joseph Paul Cohen The Halting Problem

  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

  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

  21. Basics We have a contradiction so there can be no program for HALT Joseph Paul Cohen The Halting Problem

Recommend


More recommend