Some software now comes with a mathematical proof that it behaves correctly, checked line by line by a computer. That is a genuinely stronger kind of evidence than testing, and it is easy to overstate. This lesson explains what such a proof actually shows, the assumptions every proof rests on, and the questions to ask when someone tells you their system is “formally verified”.
Testing versus proving
Most software is checked by testing: run it on many inputs and see whether the outputs are right. Testing can show that bugs exist. It cannot show that they don’t, because there are always inputs nobody tried.
Formal verification takes a different approach. Engineers write down precisely what the software is supposed to do, as a mathematical statement called a specification. They then build a proof that the code always meets that specification, for every possible input. A machine-checked proof is one where every step of that proof has been checked by a program called a proof assistant, such as Isabelle/HOL, Coq or Lean. Humans write the proof; the computer refuses to accept it unless every step follows logically.
The point of the machine is reliability. As the seL4 team puts it, humans are good at creating proofs, but computers are very good at checking them [4]. Proof assistants are deliberately designed so that only a small core, often called the kernel, has to be trusted to check each step. Lean 4’s designers, for example, describe it as having “a relatively small trusted kernel” [9].
What a landmark proof looks like
The best-known example is seL4, an operating system microkernel developed in Australia at NICTA and UNSW (the work continues today under the seL4 Foundation). A microkernel is the small core of an operating system that controls memory, scheduling and which programs can talk to which.
In 2009 the team published the first formal proof of functional correctness for a complete, general-purpose operating system kernel [1]. At the time the kernel was about 8,700 lines of C, and the proof was about 200,000 lines of Isabelle [1]. Later work extended it: a proof that the compiled binary matches the C code, and proofs of security properties, namely that the kernel enforces integrity (no unauthorised changes) and confidentiality (no unauthorised information flow) between isolated components [2].
The seL4 project reports that, in more than 15 years of use, testing and deployment since the functional correctness proof was completed in 2009, no functional correctness defects have been found in the verified code [3]. That is a remarkable record. It is also a careful claim, and the care is the lesson.
What a proof establishes
A machine-checked proof establishes one thing very strongly: if its assumptions hold, then the code behaves exactly as the specification says. For seL4 this rules out whole categories of bugs, such as buffer overflows and null pointer errors, because the proof shows the code does nothing outside the specification [3].
The same approach has worked elsewhere. CompCert, a C compiler built and proved correct in the Coq proof assistant by Xavier Leroy at Inria, guarantees that the compiled program behaves as the source program does [5]. University of Utah researchers stress-tested many C compilers with randomly generated programs. As of early 2011, the development version of CompCert was the only compiler they tested in which their tool could not find wrong-code errors, after about six CPU-years of trying [6].
What a proof doesn’t establish
Every proof has edges. Three matter most.
1. The specification can be wrong
A proof shows the code matches the specification. It cannot show the specification describes what you actually wanted. The original seL4 paper addresses this head on: a sceptic might say the proof only shows the implementation has the same bugs as the specification, and “this is true: the proof does not guarantee that the specification describes the behaviour the user expects” [1]. Its defence is that a short, abstract specification is far easier to check by eye than thousands of lines of code.
2. Assumptions sit outside the proof
Proofs model the world. Whatever the model leaves out becomes an assumption. The seL4 project publishes its list openly [4]: hand-written assembly code and boot code, correct hardware behaviour, correct cache and memory-management handling, and no misbehaving devices writing directly to memory. Its confidentiality proof covers storage channels in the kernel but explicitly does not cover timing channels, the kind of side channel where information leaks through how long things take [4].
Everything that must be correct but is not itself proved is called the trusted computing base. A good verification project makes it small and lists it. A weak one leaves it vague.
3. The parts around the proof still break
The Utah compiler study did find bugs in CompCert, in parts that were not then verified, such as its front end. The authors’ conclusion is worth quoting: “verification does not obviate testing, but rather complements it” [6]. A 2017 University of Washington study of three formally verified distributed systems found 16 bugs, and they sat at the interface between verified and unverified code: in the specifications, in the “shim” code connecting the system to the operating system, and in supporting tools [7]. The proofs held; the glue around them did not.
Ken Thompson’s 1984 Turing Award lecture adds a deeper point: the tools you build software with, such as compilers, can be compromised in ways that are invisible in the source code [8]. Any proof about source code inherits trust in whatever turns that source into a running program, unless that step is also verified, as seL4 does for some configurations by checking the binary [4].
A worked example: reading a claim
Sam is choosing a secure messaging gateway for a legal practice. Two vendors say “formally verified”.
| Question | Vendor A | Vendor B |
|---|---|---|
| What exactly is proved? | “The encryption is verified.” | “Functional correctness of the message routing core against a published specification.” |
| Which code is covered? | Not stated | The routing core; parsers and admin UI are tested, not proved |
| What is assumed? | Not stated | Hardware, OS kernel, TLS library and compiler listed in a public document |
| Can someone check it? | No | Proof scripts published; checks run on each release |
Vendor B is making a narrower claim, and it is the more useful one. Sam now knows what is covered, what to test separately, and what still has to be trusted.
Questions to ask about any “verified” claim
- What property is proved: functional correctness, a security property, or the absence of one bug class?
- Which components and which configurations does the proof cover?
- What is the published list of assumptions?
- Is the specification readable, and has anyone outside the team reviewed it?
- Is the proof kept current as the code changes, and is it checked automatically?
- Does it go down to the binary, or stop at source code?
Key takeaways
A machine-checked proof is the strongest evidence available that code does what its specification says, because a computer has checked every step and the result holds for all inputs, not just the ones tested. Its guarantee is conditional: it holds only for the code covered, only against that specification, and only if the listed assumptions about hardware, compilers and surrounding components are true. In practice the failures in verified systems cluster where the proof stops, in specifications, unverified glue code and environmental assumptions, which is why verification complements testing rather than replacing it. A trustworthy verification claim states exactly what is proved, what is assumed, and how you can check it; a vague one should be treated as marketing until it does.
Sources and further reading
- Klein, G., Elphinstone, K., Heiser, G., Andronick, J., Cock, D., Derrin, P., Elkaduwe, D., Engelhardt, K., Kolanski, R., Norrish, M., Sewell, T., Tuch, H., & Winwood, S. (2009). seL4: Formal Verification of an OS Kernel. Proceedings of the 22nd ACM Symposium on Operating Systems Principles (SOSP ’09), 207–220. https://doi.org/10.1145/1629575.1629596 (open copy: https://www.sigops.org/s/conferences/sosp/2009/papers/klein-sosp09.pdf)
- Klein, G., Andronick, J., Elphinstone, K., Murray, T., Sewell, T., Kolanski, R., & Heiser, G. (2014). Comprehensive Formal Verification of an OS Microkernel. ACM Transactions on Computer Systems, 32(1), 2:1–2:70. https://doi.org/10.1145/2560537 (open copy: https://sel4.systems/Research/pdfs/comprehensive-formal-verification-os-microkernel.pdf)
- seL4 Project. (n.d.). seL4 Proofs. https://sel4.systems/Verification/proofs.html
- seL4 Project. (n.d.). What the Proofs Assume. https://sel4.systems/Verification/assumptions.html
- Leroy, X. (2009). Formal verification of a realistic compiler. Communications of the ACM, 52(7), 107–115. https://doi.org/10.1145/1538788.1538814 (open copy: https://xavierleroy.org/publi/compcert-CACM.pdf)
- Yang, X., Chen, Y., Eide, E., & Regehr, J. (2011). Finding and Understanding Bugs in C Compilers. Proceedings of the 32nd ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI ’11), 283–294. https://doi.org/10.1145/1993498.1993532 (open copy: https://users.cs.utah.edu/~regehr/papers/pldi11-preprint.pdf)
- Fonseca, P., Zhang, K., Wang, X., & Krishnamurthy, A. (2017). An Empirical Study on the Correctness of Formally Verified Distributed Systems. Proceedings of the Twelfth European Conference on Computer Systems (EuroSys ’17), 328–343. https://doi.org/10.1145/3064176.3064183 (open copy: https://homes.cs.washington.edu/~pfonseca/papers/eurosys2017-dsbugs.pdf)
- Thompson, K. (1984). Reflections on Trusting Trust. Communications of the ACM, 27(8), 761–763. https://doi.org/10.1145/358198.358210 (open copy: https://www.cs.cmu.edu/~rdriley/487/papers/Thompson_1984_ReflectionsonTrustingTrust.pdf)
- de Moura, L., & Ullrich, S. (2021). The Lean 4 Theorem Prover and Programming Language (System Description). Automated Deduction – CADE 28, Lecture Notes in Computer Science 12699. Springer. https://doi.org/10.1007/978-3-030-79876-5_37