Britannica Sources used in this answer

Why can no program correctly predict whether every possible program will halt?

Created from Britannica articles using AI. AI can make mistakes, so verify using Britannica articles.

The assertion that no program can correctly predict whether every possible program will halt is a fundamental result in computer science known as the halting problem.1

This is not a limitation of current technology, but a proven mathematical impossibility. In his work to define the essential features of an algorithm, the mathematician Alan Turing demonstrated that there is no universal algorithmic method—or Turing machine—capable of determining whether an arbitrary program will eventually stop or continue running forever.23

The problem is considered "unsolvable" because any attempt to construct such a predictor leads to a logical contradiction: if a program could perfectly predict the behavior of all others, one could create a scenario where the predictor is forced to produce an answer that contradicts its own logic. Consequently, while we can identify infinite loops in specific, simple cases, it is impossible to create a general-purpose software tool that reliably detects infinite loops in all possible programs. This boundary between decidable and undecidable problems remains a cornerstone of computer science theory.12