blockchainsv
News

Moving Beyond Testing: Using Formal Verification to Eliminate Smart Contract Bugs

According to Varun Pant, who leads AI product teams at AWS working on formal verification, coding agents ship hundreds to thousands of pull requests weekly.

Caleb North·updated August 31, 2026

Moving Beyond Testing: Using Formal Verification to Eliminate Smart Contract Bugs

Existing quality gates do not scale — LLM-as-judge is probabilistic, tests sample inputs, and human review cannot match agent velocity. Only mathematical proof covers every input path.

Spec Owns the Risk

Pant inverts the standard AI coding loop. Humans write what correct means. Machines write code and proof. A wrong spec poisons every artifact below it. A wrong implementation is caught mechanically. This is an asymmetric stake.

The term is "back driven development." The engineer defines the invariant. The spec is validated by review or sample testing. The agent implements against it. The verifier proves the match. Human effort moves upstream. To the artifact that cannot be checked later. Smart contract work follows the same rule. State invariants must be specified before any execution path exists. Otherwise the proof target is undefined.

Engine Selection

Lean4 is the interactive engine. Code and proof share one language. The trusted computing base is the kernel. Independent kernels exist in C++, Rust, and Lean. Each validates the same proof. AI may be wrong. The kernel cannot be fooled.

SMT solvers like Z3 are the automated alternative. Input is a formula. Output is satisfiable or unsatisfiable. Lean is chess. Z3 is arithmetic. The two dispatch by problem type. Production case studies include zlib and Cedar. AWS's Strata framework extends verification across any programming language.

Property writing has blocked formal adoption for decades. Knowledge graphs, per Cohen and Chibani, store specs as nodes, edges, and triples. LLMs query the graph instead of parsing prose. Grounding improves. Invention drops. Ravindra Aneja, director of applications engineering at Synopsys, notes that a perfect spec rarely exists in practice. Most designs ship with partial documentation or none. The verification chain stays only as strong as the spec itself.

The principle extends past code. Separating marketing claims from verifiable invariants applies identical logic. Every statement must be checkable against a stated criterion. Not narrative.

Audit Checklist

  • Express every invariant as a formal predicate. Reject prose.
  • Treat the specification as the highest-value artifact.
  • Prove the implementation against the spec. Not the reverse.
  • Maintain multiple independent kernels for trust distribution.
  • Audit properties, not just code. A missing property is a missing guarantee.