0

The halting problem states that given an input and a program, there is no algorithm that can decide weather the program will halt. This renders this problem undecidable. My misunderstanding of the halting problem is that, can't we just create another program that could check if the program has infinite loops. I just mean that it may be possible to check the cases where a loop will not stop and based on that decides if the program will halt or not. Please could you let me know what's wrong of my understanding of this problem?

MK.
  • 33,605
  • 18
  • 74
  • 111
Monalizza
  • 27
  • 3

1 Answers1

0

Well, you know, the proof of the halting problem is pretty trivial. Let's assume you have a program that tells you whether a given program will halt or not (forget about inputs for simplicity). Let's call this program doesHalt(program). Let's now write a new program called

myHalt() 
  if doesHalt(myHalt):
     infinite loop
  else 
     return

What should be the return value of

doesHalt(myHalt)

To answer your specific question: how does your program examining loops will know whether a given loop halt or not? Does the loop

for (i = 1; i += 10; ) {
   if (i == 7) break;
}

loop forever or not? How did your program figure that out?

MK.
  • 33,605
  • 18
  • 74
  • 111
  • Great, you mean the program itself which examines the myHalt program may not halt! I see, I don't think my program would ever be able to evaluate the the 7th i. Thanks a lot – Monalizza Nov 13 '15 at 05:19
  • no, in this proof we take a alleged working program doesHalt() and show that we can use it to construct a new program which will cause a logical paradox/contradiction and thus prove our assumption that doesHalt exists wrong. – MK. Nov 13 '15 at 05:22