Why Writing Correct Software Is Hard pron.github.io · 290 points · 126 comments ...

@best30

Why Writing Correct Software Is Hard pron.github.io · 290 points · 126 comments · HN thread

TL;DR Pron (Ron Pressler) argues in a long essay that software correctness is fundamentally hard because of computability and complexity results: the halting problem, Rice's theorem, Busy Beaver, and PSPACE-completeness of model checking mean no general tool can make programs feasibly verifiable. He concludes that correctness costs effort that cannot be avoided, and that the field should pursue empirical study of real programs and ad hoc techniques rather than general solutions.

  • The article traces Hilbert's program to Gödel's incompleteness theorems and the Church-Turing halting theorem, arguing computation is inherently beyond full mathematical understanding.
  • Bounded halting is Θ(n) in the number of steps, so no program's behavior can be decided faster than running it in the worst case; verification is framed as the hardest problem in computer science.
  • Restricting to total languages does not make verification easier, and symbolic model checking is PSPACE-complete, so succinct representations do not help in the worst case.
  • Correctness does not decompose: a short Goldbach-encoding Java example shows that composing correct modules can yield an unverifiable whole.
  • Abstract interpretation and types trade precision for tractability, which is why they can prove properties without contradicting Rice's theorem.
  • The author calls for empirical study of programs and bugs, citing a study where most catastrophic distributed-system failures came from mishandled non-fatal errors.

Discussion The thread is a broad, mostly thoughtful debate that quickly moved from the article's theory to practical software development. Many commenters push back that real-world specifications are fuzzy, shifting, and politically contested, so formal proof is only useful in narrow domains; others argue that formal methods can still be applied selectively, and that the article's appeal to Rice's theorem and undecidability is largely irrelevant to ordinary engineering. Several threads digress into AI and LLMs, the terminology of 'halting', and an unrelated telescope quote. The mood is intellectually engaged and somewhat skeptical of the article's most sweeping claims.

  • Real-world specifications are too fuzzy to formalize (many): Commenters note that requirements shift, stakeholders disagree on what 'correct' means, and business definitions (such as what counts as a sale) vary by department. Formal proof therefore runs against a moving target, and much of software work is pinning down the target rather than hitting it.
  • Formal methods are useful selectively, so pick the right domains (many): Safety-critical, military, medical, and security-sensitive software justify rigorous verification, while most business software does not. Several argue that formal methods and testing should be applied where the payoff is clear, such as memory safety or not letting attackers run code.
  • Rice's theorem and undecidability are irrelevant to practical verification (some): Some commenters argue the article conflates undecidability with the difficulty of proving specific programs, and that practical programs are usually well-behaved. Restricting languages or programming styles makes many useful properties provable in practice.
  • Most bugs come from specs and integrations, not code (some): One practitioner estimates that roughly half of bugs are specification errors and about half involve integrated third-party systems, leaving only a small share as code bugs that formal verification would catch. Others counter that good tests and architecture reduce code bugs well.
  • Types and proofs already deliver real correctness benefits (some): Commenters point out that type systems prove meaningful properties today, and that programs are mathematical objects under denotational and axiomatic semantics. The stated premise that programming is not math is challenged as overstated.
  • Unreliable hardware and environments limit formal guarantees (a few): A few note that formally verified code still runs on hardware and operating systems with few reliable properties, so defensive code and assertions remain necessary. Systems like seL4 are cited as partial answers.

Links from the comments

#formalVerification #computability #complexityTheory #softwareCorrectness #halting #AI