Writing correct software is hard and math alone won’t help us (2016)
Through computability and complexity theory, this essay demonstrates that complete software correctness is fundamentally constrained and cannot be solved by math alone.
read it A deeply grounded exploration of computer science theory that reframes why software engineering will always struggle with absolute correctness.
summary
The article examines computability and complexity results—such as the halting problem, Rice's theorem, and bounded halting—to show why writing correct software is inherently difficult. It argues that the cost of complete verification scales beyond computable bounds, meaning programs cannot be fully understood or analyzed faster than they run. Consequently, computer science diverges from pure mathematics because programs must confront the physical and computational limits of complexity. Even small programs can have behaviors entirely independent of standard mathematical systems like ZFC.
key points
- The halting problem and Rice's theorem establish that general program behavior and non-trivial properties are undecidable.
- Bounded halting complexity proves that determining whether a program terminates within n steps cannot be computed faster than running it.
- Gödel's incompleteness results manifest in computer science as small, hundreds-of-lines programs whose termination cannot be proven within ZFC set theory.
who should read it
Software engineers and computer science practitioners interested in the theoretical limits of formal verification and software correctness.
discussion positive
consensus
Commenters largely agree that absolute formal correctness is impractical and often misaligned with real-world business needs, where requirements constantly shift and environments are messy. Most view software development as an engineering compromise balancing iteration speed and usability rather than a mathematical pursuit.
pushback
A minority argues that citing undecidability and extreme edge cases like ZFC-independent Turing machines is irrelevant to everyday software, since typical programs rely on simple, easily analyzed structures where verification is fully tractable.
There’s something I used to say that I haven’t repeated in a while and I’m not sure why since I still believe it:
Software is effectively contract law, and if one were solvable the other would be too. The fact that we have so many lawyers, and loopholes are a constant issue is the same reason we have so many programmers and so many bugs.
We cannot nail down what is and isn’t acceptable input, acceptable output, and acceptable intermediate states all at the same time. And that’s what you need for correct software.
It draws a compelling parallel between software bugs and loopholes in contract law, illustrating why nailing down acceptable inputs, outputs, and intermediate states simultaneously is fundamentally impossible.
Generated by an LLM from the article and thread. Check the sources before relying on it.