The halting problem is a problem that asks, for an arbitrary computer program and input, is it possible to determine if the program will run forever or halt. It was proved that the halting problem is undecidable, meaning that it is impossible to create an algorithm that will determine if an arbitrary program will halt.
Proof of undecidability
The halting problem’s undecidability was proved via contradiction. Assume that a program exists, where is a program that always gives the solution to the halting problem, is the program to decide the halting program for, and is the input to . Create a second program , where is the input program. does the opposite of , i.e. if says will halt on input , then will not halt.
will then either not halt if says it will halt, or halt if says it will not halt. In either case, is incorrect, which contradicts the initial assumption that is always correct. Therefore, there is no program that determines the solution to the halting problem for a arbitrary program and input. In this model, any input is allowed, which is why programs can be passed as input.