How does this proof, that the halting problem is undecidable, work?

后端 未结 2 574
不思量自难忘°
不思量自难忘° 2021-01-31 04:47

I\'m going over the proof for The Halting Problem in Intro to the Theory of Computation by Sipser and my main concern is about the proof below:

If TM M doesn\'

2条回答
  •  梦如初夏
    2021-01-31 05:34

    After reading this and trying to visualize the proof I came up with this code which is a simplified version of the code in this answer to a related question:

    function halts(func) {
      // Insert code here that returns "true" if "func" halts and "false" otherwise.
    }
    
    function deceiver() {
      if(halts(deceiver))
        while(true) { }
    }
    

    If halts(deceiver) returns true, deceiver will run forever, and if it returns false, deceiver will halt, which contradicts the definition of halts. Hence, the function halts is impossible.

提交回复
热议问题