# The Fundamental Limits of Software Correctness

Why mathematical logic and computation make perfect software an unreachable theoretical goal.

- **Source:** [Hacker News](https://news.ycombinator.com)
- **Published:** 2026-11-12
- **Topic:** [science](https://brifing.si/c/science)
- **Original article:** <https://pron.github.io/posts/correctness-and-complexity>
- **On Brifing:** https://brifing.si/s/04147113-97dc-47eb-8b8a-9589eb2aa8f4

## The Illusion of Perfect Software

Many developers believe that with the right tools, achieving perfect software correctness is a manageable task. However, theoretical computer science suggests otherwise. The quest for bug-free code faces fundamental barriers rooted in the natural laws of computation, making absolute verification an impossible goal regardless of the sophistication of modern development tools.

## Hilbert's Failed Formalization Dream

In the early 20th century, David Hilbert aimed to formalize all of mathematics, seeking a decision procedure to determine the truth of any statement. His ambitious program was dismantled in 1930 by Kurt Gödel’s incompleteness theorems. These results proved that logical systems are inherently limited, preventing the complete understanding Hilbert once envisioned.

## The Halting Theorem Explained

Proven by Alan Turing and Alonzo Church in 1936, the halting theorem is the bedrock of computer science. It states that no algorithm can determine if an arbitrary program will eventually terminate or run forever. This proof uses diagonalization, a self-referential technique that creates logical contradictions, demonstrating that some problems are undecidable.

## Rice's Theorem and Program Properties

Rice’s Theorem extends the halting problem by stating that no algorithm can decide any non-trivial property of a program's partial function. For instance, determining if a program always outputs the square of its input is mathematically impossible. This highlights that deep analysis of program behavior is fundamentally barred by undecidability constraints.

## The Busy Beaver Function

The Busy Beaver function, f(n), defines the maximum steps a halting program of size n can take. This function is non-computable, meaning no algorithm can calculate it for all n. Its existence provides a quantitative measure of the inherent complexity involved in analyzing program behavior, whether viewed dynamically or statically.

## Static Analysis and Proof Size

Similar to the dynamic Busy Beaver function, the static version g(n) measures the size of the minimal proof required to verify a program. Because g(n) is also non-computable, there is no universal method to determine the complexity of verifying code. This confirms that program size and verification difficulty are inextricably linked.

## Practical Limits of Verification

While we cannot compute f(n) for all values, we can calculate lower bounds for small programs. For a Turing machine with six control states, the value is approximately 7.4 times 10 to the power of 36,534. These astronomical numbers illustrate why exhaustive verification is physically impossible for even moderately sized software systems.

## Independence from Formal Systems

Gödel’s second incompleteness theorem implies that some programs are independent of ZFC set theory. Researchers like Adam Yedidiya and Scott Aaronson have created small programs, under 200 lines, whose termination cannot be proven within standard mathematics. Their behavior is mathematically indeterminate, existing beyond the reach of formal logic and verification tools.

## Turing's Physical View of Computation

Alan Turing emphasized that computation is a physical process, not just an abstract mathematical concept. By linking algorithms to machines that operate in the physical world, he justified the centrality of the halting problem. This perspective confirms that the limitations of computation are not merely theoretical but apply to all realizable physical processes.

## The Church-Turing Thesis Context

The Church-Turing thesis conjectures that any computation performed by a physical process can be simulated by universal models. This implies that the entire universe could theoretically be simulated as a program. However, this also means that the same fundamental undecidability constraints apply to any system that can be modeled computationally.

## Computer Science Versus Mathematics

While mathematics focuses on provable truths within formal systems, computer science often deals with the vast, unprovable space outside those circles. Many programs are only provable in principle, not in practice. This distinction suggests that computer science is a distinct discipline, constrained by the physical and logical limits of computation.

## The Cost of Correctness

Software correctness is not just a technical challenge but a fundamental constraint of the universe. The cost of achieving it mirrors the energy required to reduce entropy. Because verification is often undecidable or computationally infeasible, developers must accept that perfect software is an unattainable ideal, limited by the laws of logic.

## Sources covering this story

- https://pron.github.io/posts/correctness-and-complexity — 

---

_Summary written by Brifing from the original reporting. Copyright in the original article belongs to its publisher; read the full piece at the link above._
