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 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
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
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
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
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
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
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
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
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
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
Basics There can never be a program for the the function HALT Joseph Paul Cohen The Halting Problem
Basics There can never be a program for the the function HALT This is a big deal Joseph Paul Cohen The Halting Problem
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
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
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
Basics g is a program so it has a number # g Joseph Paul Cohen The Halting Problem
Basics What happens when we run # g on itself? g ( # g ) Joseph Paul Cohen The Halting Problem
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
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
Basics We have a contradiction so there can be no program for HALT Joseph Paul Cohen The Halting Problem
Recommend
More recommend