Bottom line. Formal verification proves that your code matches the spec. It cannot tell you what the spec forgot, and that is where the bugs live: in implicit invariants that sit in the heads of the people who wrote the code. Agents are good at finding them and at proving them now. One sentence is enough:
Find every implicit invariant in this code, turn each one into an explicit spec, and formally prove that the code keeps it.
Then have someone who knows the domain read the list before you trust the proofs. Here is the difference on a tiny program, a money transfer transfer(from, to, amount)
Explicit invariants. Somebody wrote these down, and tests check them:
Implicit invariants. Everyone relies on these, and nothing checks them:
Every test in the first list can be green while any line in the second is broken. That second list is what the agent should find
After the Octra run I kept asking myself one question: would formal verification have caught the bad commit? Then no agent could have sneaked it in. The answer turned out to be the most useful thing I learned this month
A formal proof shows that the code does what the spec says. Every input, every path, no exceptions. That is a much stronger statement than any test suite can make. But the spec is a document a person wrote, and the proof is exactly as complete as that document
Donald Knuth put the other half of it in a 1977 note: “Beware of bugs in the above code; I have only proved it correct, not tried it”
Two studies show where bugs go once code is proved. The Csmith team spent three years throwing random C programs at compilers and reported more than 325 bugs. CompCert, the formally verified C compiler, was the only one where they found no wrong-code bugs in the middle end. The bugs they did find in it sat in its unverified front end. In 2017 a team at the University of Washington studied three verified distributed systems, IronFleet, Verdi and Chapar, and found 16 bugs. They sat at the edges: in the specification, in the glue code between verified and unverified parts, and in the tooling
In both cases the proof did its job. The trouble was always next to it: what it assumed, and what nobody had written down
A lot of people hear “formally verified” and read it as “correct”. It means something narrower: correct with respect to this spec, under these assumptions. If the spec forgot something, or one of the assumptions is false, the proof still holds and the program is still wrong
The classic story is binary search. Jon Bentley proved his version correct by hand in Programming Pearls, then tested it, and it was used and copied for two decades. In 2006 Joshua Bloch pointed out that it was broken, and so was the one he had written for the Java standard library. The line mid = (low + high) / 2 overflows once an array has more than about a billion elements. The proof was fine. It assumed that integers never overflow, and nobody had written that assumption down
Good verification projects know this and publish their assumptions. The seL4 microkernel, one of the most thoroughly verified pieces of software there is, has a page listing what its proofs assume: that the hardware behaves as specified, that a few hundred lines of assembly and the boot code are right, and so on. That page is the honest part of a proof. Everything on it is an invariant that someone else has to keep
It also works the other way around. In 2015 a team tried to formally verify TimSort, the sort used by Java, Android and Python, and the proof would not go through. The invariant the code relied on, written down only in a comment, did not actually hold, and a crafted input could crash the sort. Writing the implicit invariant down explicitly is what found the bug
An invariant is a property that has to stay true whatever the code does. Some are explicit. You wrote them into tests, types, asserts or a spec, and a machine checks them. Others are implicit. They live in the heads of the people who wrote the code, in a comment from three years ago, in the fact that every caller happens to do the same thing
In the Octra run the explicit ones were mine: proofs stay byte-identical, the old verifier accepts them, checking stays as fast. The implicit ones were the ones that mattered. Every field element is carried back under 51 bits after every step. Every scalar operation goes through the rule the caller passes in. None of that was written anywhere a machine could see. lambda knew all of it
So verification does not remove the hard question. It moves it from “is the code right” to “is the spec complete”, and no tool answers the second one for you
Once you start looking, they are in every app you use
Each of these is true almost every day. That is exactly why nobody writes it down, and why every test that assumed it is still green on the day it breaks
Crypto is where implicit invariants cost the most. The code is public, anyone can call any function in any order, a flash loan hands an attacker millions for the length of one transaction, and the money is gone in seconds. Every invariant the authors never wrote down is a bounty waiting for someone to claim it
transfer, so code that expects a return value fails on every callThe Octra story is the same thing in a proof system. “A cheater cannot prove something false” holds the whole chain together, and no test with honest users will ever exercise it. Audits read the explicit list. The money is in the implicit one
Finding implicit invariants is mostly reading: every function, every caller, every comment, asking what each one silently assumes. People are bad at it because it is slow and dull. Models are good at it for the same reason. There is an old research line here too: Daikon infers likely invariants by watching a program run. A language model does a rough version of that just by reading the code
To try it, I gave a model the field arithmetic from Octra, the file the bad commit later touched, and asked it for the implicit invariants: what the code and its callers rely on that no type, assert or test enforces
It came back with eight items. Two of them, straight from its answer:
2. Invariant: every limb fed to multiplication is small enough (roughly < 2^54) that `19 * g.v[i]` fits in 64 bits. Relied on in: fe_mul, fe_sq. If violated: the pre-multiplied limbs silently overflow uint64 before being widened to u128, producing a wrong product. 3. Invariant: each accumulated column t[i] stays below about 2^110, so the carry `t[i] >> 51` fits in uint64 and `c * 19` does not overflow. Relied on in: fe_mul and fe_sq, at the `(uint64_t)(t[i] >> 51)` casts. If violated: the carry is truncated, high bits are dropped and the result is wrong.
That is the exact edge the agent walked up to in the first run. My Python check of their multiplication put it at 2^54.2. The model found it from the code alone, with no swarm and no benchmark
It also got one detail wrong. It said that negating zero leaves the limbs of 2p, and after the carry pass the value is actually p. Still not zero in its limbs, so the warning behind it was right, but the detail was not. That is the general pattern: the model is a fast, tireless source of candidates, and a person who knows the domain decides which ones are real
The order matters. Prove first and specify later, and you get a very confident proof of an incomplete list
Formal verification verifies. It does not tell you what to verify. The explicit invariants are your job, and you can think them through on purpose. The implicit ones are where the bugs live, and finding them is mostly patient reading, which is exactly what AI is good at. Use models to make the list, people to judge it, and proofs to hold it