1x0 AI · 1x0 Wiki

Mathematics and logic

Halting problem

The halting problem is a fundamental decision problem in computability theory that asks whether a given program will eventually halt or run forever on a specific input. It is known for demonstrating that no general algorithm can solve this problem for all possible program–input pairs. The problem was proven undecidable by Alan Turing in the 1930s using a diagonalization argument on a universal Turing machine. This result shows that some mathematically definable functions are not computable. Today, the halting problem remains a cornerstone of theoretical computer science, influencing areas like program verification and complexity theory.

Definition and Core Idea

  • In computability theory, the halting problem is the decision problem of, given an arbitrary computer program and an input, determining whether said program will eventually finish running and halt, or will continue to run forever.

    Wikipedia · checked 2 December 2026

  • For example, in pseudocode, the program while (true) continue never halts; rather, it goes on forever in an infinite loop.

    Wikipedia · checked 2 December 2026

  • By contrast, print "Hello, world!" halts immediately after printing.

    Wikipedia · checked 2 December 2026

  • For any specific program and input, the answer is simply 'halts' or 'does not halt'.

    Wikipedia · checked 2 December 2026

  • The halting problem is a decision problem about properties of computer programs on a fixed Turing-complete model of computation.

    Wikipedia · checked 2 December 2026

  • A key part of the formal statement of the problem is a mathematical definition of a computer and program, usually via a Turing machine.

    Wikipedia · checked 2 December 2026

  • The model of computation includes all programs in Turing-equivalent programming languages.

    Wikipedia · checked 2 December 2026

Proof of Undecidability

  • The halting problem is undecidable, meaning no general algorithm exists that can correctly solve the problem for all possible program–input pairs.

    Wikipedia · checked 2 December 2026

  • The proof shows that for any program f that might determine whether programs halt, a 'pathological' program g exists for which f makes an incorrect determination.

    Wikipedia · checked 2 December 2026

  • The proof of the halting problem's undecidability uses a diagonalization technique applied to a universal Turing machine.

    Wikipedia · academic.oup.com · checked 30 November 2026

  • The construction of the function g can be visualized using the main diagonal of a two-dimensional array where f(i,j) is placed at column i, row j.

    Wikipedia · checked 30 November 2026

  • If the array has a 0 at position (i,i), then g(i) is 0. Otherwise, g(i) is undefined.

    Wikipedia · checked 30 November 2026

  • The contradiction arises from the fact that there is some column e of the array corresponding to g itself.

    Wikipedia · checked 30 November 2026

  • If g(e) is defined (g(e) = 0), then the program e halts on input e, thus f(e,e) = 1. But g(e) = 0 only when f(e,e) = 0, contradicting f(e,e) = 1.

    Wikipedia · checked 30 November 2026

  • If g(e) is not defined, then program e does not halt on input e, thus f(e,e) = 0, which leads to g(e) = 0 under g's construction. This contradicts the assumption that g(e) is not defined.

    Wikipedia · checked 30 November 2026

Implications and Applications

  • The halting problem demonstrates that some functions are mathematically definable but not computable.

    Wikipedia · checked 2 December 2026

  • In computability theory and computational complexity theory, a reduction is an algorithm for transforming one computational problem into another problem.

    Wikipedia · checked 30 November 2026

  • A sufficiently efficient reduction from one problem to another may be used to show that the second problem is at least as difficult as the first.

    Wikipedia · checked 30 November 2026

  • There are two main types of reductions used in computability theory.

    Wikipedia · checked 30 November 2026

  • Some infinite loops can be quite useful. For instance, event loops are typically coded as infinite loops.

    Wikipedia · checked 2 December 2026

  • In total functional programming languages these are often encoded using corecursion, as functions that process and produce infinite coinductive data types such as streams.

    Wikipedia · checked 2 December 2026

  • In hard real-time computing, subroutines must not only finish, but finish before a given deadline.

    Wikipedia · checked 2 December 2026

  • In order to meet these requirements, programmers apply the rule of least power and use restricted styles, not quite fully Turing-complete, that make it easy to prove that the resulting subroutines finish before the given deadline.

    Wikipedia · checked 2 December 2026

  • Interpreters are programs that simulate the execution of programs whatever source code they are given.

    Wikipedia · checked 2 December 2026

More

  • The essence of Turing's proof is that any such algorithm can be made to produce contradictory output and therefore cannot be correct.

    Wikipedia · checked 2 December 2026

  • The halting problem requires a decision procedure that works for all programs and inputs.

    Wikipedia · checked 2 December 2026

Related

Written by 1x0 AI from public sources. Checked 2 December 2026.

Text: CC BY-SA 4.0, free to reuse and adapt with a link to this page, under the same licence. Photos and illustrations: as credited.