What is a formal proof?
A short explanation for non-specialists
A formal proof is a program that a computer can check. Either the proof is accepted, or it is rejected. There is no middle ground.
A test checks that code works for a few examples. A formal proof checks that it works for every possible input.
A concrete example
Consider a simplified ERC-20 token. The contract stores balances and a total supply. Here is the transfer function written in Verity, a framework for formally verified smart contracts:
This reads like pseudocode, but it compiles to real EVM bytecode. Now we state a property we want to guarantee:
“Calling transfer never changes the total supply.”
And we prove it:
The theorem keyword tells Lean: “I claim this is true, and here is my proof.” The by block contains the actual proof steps. If any step has a gap or error, Lean refuses to compile.
How does the checking work?
Lean has a small, well-audited kernel that accepts or rejects proofs. Every proof must pass through this kernel. It does not care how the proof was found: by a human, an AI, or an automated solver. What matters is that each step is valid.
If the proof compiles, it is correct. If it doesn't, it isn't.
Tests vs. formal proofs
A test says: “I transferred 50 tokens from Alice to Bob and the total supply didn't change.”
A formal proof says: “For every sender, every recipient, and every amount, transfer preserves total supply.”
Why does this matter for smart contracts?
Smart contracts handle real money. A bug in token arithmetic can drain millions. Tests catch some bugs, audits catch more, but neither can guarantee correctness for all possible states.
A formal proof can. It is a mathematical certificate that the property holds in every case, not just the ones the auditor thought to check.
See it in practice
Lido V3 Vault Solvency Guarantee. A formally verified property of a production smart contract.