Lean 4.22: A New Verification Infrastructure for Imperative Programs

2025-07-07

Lean 4.22 introduces an exciting new feature: a new verification infrastructure for proving properties of imperative programs. The post uses a simple example—determining if a list contains two integers that sum to zero—to demonstrate the feature's use and compares it to similar tools like Dafny and Verus. The new framework, Std.Do, leverages Hoare triples and combines the `mvcgen` and `grind` tactics to greatly simplify the verification process for imperative programs, even those with complex control flow like loops and early returns. Unlike automated systems relying on external SMT solvers, Lean's interactive proving approach offers greater reliability, easier debugging, and better maintainability, making it a compelling choice for real-world program verification tasks.