What exactly is the halting problem?

前端 未结 22 740
时光说笑
时光说笑 2020-11-29 00:01

Whenever people ask about the halting problem as it pertains to programming, people respond with \"If you just add one loop, you\'ve got the halting program and therefore yo

22条回答
  •  隐瞒了意图╮
    2020-11-29 00:18

    Here is a simple explanation of the proof that the halting problem is undecidable.

    Assume you have a program, H, which computes whether or not a program halts. H takes two parameters, the first is a description of a program, P, and the second is an input, I. H returns true if P halts on input I, and false otherwise.

    Now write a program, p2, which takes as it's input the description of another program, p3. p2 calls H(p3, p3), then loops if H returns true and halts otherwise.

    What happens when we run p2(p2)?

    It must loop and halt at the same time, causing the universe to explode.

提交回复
热议问题