Definition
Halting Problem
The halting problem is a decision problem that asks for an algorithm to determine, for any given program and its input, whether the program will eventually halt or run forever.
Instance: program
, input (string)
Question: Does programterminate for every input ? It is undecidable and semi-decidable.
Properties
Undecidability
Assume that the halting problem is decidable, i.e. there exists a program
takes in 2 strings as input: : a program : the input for
produces the following output:
Given that
And again, we can generate another program
First, we can observe:
halts on does not halt on input . does not hold on halts on input .
What happens when
- Case:
halts on input . Then from observation (1) follows that does not hold on input , which is a contradiction. - Case:
does not halt on input . Then from observation (2) follows that halts on input . We found another contradiction.
Therefore, that our initial assumption was wrong, i.e. there is no program
The halting problem is undecidable.
Semi-Decidability
The halting problem is undecidable. We can write an interpreter which steps through the code and on termination, signals that the interpreted program terminated, and returns TRUE. Otherwise, it never halts. This complies with semi-decidability.