∴Logic WikiA library of reasoningSearch concepts, fallacies, and cases/中文

Computability and the halting problem

可计算性与停机问题

Computability concerns whether an algorithm exists, not merely how fast current machines run.

The concept and its limits

Turing machines and recursive functions formalize algorithmic computation. The Church–Turing thesis links an informal notion of effective calculation to formal models and is not simply an ordinary mathematical theorem.

Undecidability of halting excludes a general algorithm correctly deciding termination for every program and input. It does not prevent proofs of termination for many particular programs.

Working through an example

A loop that runs exactly ten times and exits is easy to prove terminating. General undecidability does not invalidate this particular proof.

Deciding versus recognizing

A decision algorithm must halt with the correct yes or no answer on every input in its domain. A recognizer may eventually confirm positive instances while running forever on some negative ones. Simulation confirms a particular halt when it occurs; waiting without termination does not establish nontermination.

Complexity asks how much time or space a computable task requires. An exponential-time algorithm is still an algorithm. Faster hardware may improve runtime but does not by itself overcome a proof of general undecidability.

Section sources: SEP, Computability and Complexity, §§2.1–2.4 ↗

The diagonal contradiction

Suppose H always halts and correctly decides whether any program p halts on input x. Construct D(x): query H(x,x); if it predicts halting, loop forever; otherwise halt immediately. If H really is a total correct algorithm, D can be constructed using it.

Now run D on its own code. If H predicts halting, D does not halt; if H predicts nontermination, D halts. Either answer is wrong, contradicting the assumed universal decider. The contradiction defeats that assumption, not the existence of programs or computation.

Restricted problems can remain decidable

The question “Does this program halt within 1,000 steps?” can be decided by simulating at most 1,000 steps. This bounded problem differs from eventual halting. A report must distinguish failure to halt within a test limit from a proof of nontermination.

Specific programs may admit termination arguments using invariants or a strictly decreasing natural-number measure. If each iteration reduces a nonnegative n by one and exits at zero, the loop executes at most the initial n times, provided those conditions hold. General undecidability does not invalidate such local proofs.

Check the algorithm’s promise

Check whether termination is promised on every input and which question is answered.

Independent exercise 1

An analyzer returns unknown after one minute. Does this contradict undecidability of halting?

Show answer and reasoning

No. It does not promise a correct yes or no for every program. Allowing unknown may make analysis terminate or remain practical, but it is not a decider for the general halting problem.

Independent exercise 2

A program repeatedly sets n to n−1, but resets n to 10 at zero. Can strict decrease of n prove termination?

Show answer and reasoning

That argument fails because the reset violates strict decrease. Without another exit, the cycle repeats. A termination measure must meet its required condition at every relevant iteration, not merely most of them.

Check your understanding

Question: Does being very slow mean uncomputable? Answer: No. Computability and complexity are different questions.

References

  1. Computability and Complexity ↗
    Stanford Encyclopedia of Philosophy · Selected sections
    §§1–2: computation and the halting problem
    Version, terms, and access scope