The Spectrum Dispatch News

technology

Why Writing Correct Software Is Hard: The Limits of Formal Verification

A researcher explores how fundamental theorems in computability theory explain why achieving software correctness requires inherent trade-offs that no tool can fully overcome.

Why Writing Correct Software Is Hard: The Limits of Formal Verification

According to a talk and extended article by a computer scientist who worked on formal verification for Galaxy, the difficulty of writing correct software stems from deep theoretical results in computability and complexity theory, not merely from a lack of proper tools.

Why Writing Correct Software Is Hard: The Limits of Formal Verification

The author challenges claims that software correctness is easily achievable with the right tools, arguing instead that correctness demands a fundamental cost rooted in “natural laws” of computation. This perspective draws from classical results in theoretical computer science dating back nearly a century.

The analysis begins with David Hilbert’s early 20th-century program to formalize all mathematics. Hilbert sought to prove that formal mathematical systems were consistent (free from contradictions), complete (all true statements provable), and decidable (an algorithm could determine the truth of any statement). Hilbert famously rejected the 19th-century maxim “ignoramus et ignorabimus” (we do not know and will not know), declaring instead: “We must know, we shall know.”

However, this program faced decisive challenges. Kurt Gödel’s incompleteness theorems, announced in 1931, undermined the consistency and completeness pillars. In 1936, Alonzo Church and Alan Turing independently proved that no algorithm can decide whether a given program terminates—the halting theorem, described as “CS’s first theorem.” The halting theorem immediately implies several consequences directly relevant to software verification.

One corollary states that no program can determine whether another program ever reaches a particular state, given initial conditions. Another critical result is Rice’s Theorem, which holds that for any non-trivial property of functions computed by programs, no algorithm can decide whether a program computes a function with that property. For example, there is no algorithm to determine whether a program’s output is always the square of its input.

The author highlights the “Busy Beaver theorem” as particularly illuminating for understanding program analysis complexity. This theorem defines a function measuring the maximum steps a halting Turing machine of size n can take before terminating. The theorem proves this function is non-computable—if it were computable, one could decide the halting problem by running any machine for that many steps and observing whether it terminates, creating a logical contradiction.

These results demonstrate that complete understanding of programs—which the author identifies as necessary for true correctness—fundamentally conflicts with the nature of computation itself. The cost of achieving correctness, like reducing entropy in thermodynamics, is constrained by unavoidable natural laws of computation.

Key facts

  • The halting theorem, proven independently by Church and Turing in 1936, states no algorithm can determine whether a program terminates
  • Rice’s Theorem shows no algorithm can decide whether a program computes a function with any non-trivial property
  • The Busy Beaver function, which measures maximum steps a halting program of given size can take, is non-computable
  • Gödel’s incompleteness theorems, announced in 1931, demolished foundational pillars of Hilbert’s formalization program
  • Software correctness is constrained by fundamental laws of computation that no tools can fully overcome

Sources

← All posts