Formal Verification Framework
Machine-checked proofs of consensus safety and liveness in Lean 4, and of smart-contract invariants under Halmos symbolic execution
LP-0017: Formal Verification Framework
Abstract
This LP documents the formal verification framework for the Lux blockchain, covering both consensus protocol proofs (Lean 4 with Mathlib) and smart contract invariants (Halmos symbolic execution). A total of 33 Lean 4 theorems and 68 Halmos symbolic proofs are verified.
Motivation
Formal verification provides the highest level of assurance for blockchain protocols and smart contracts. Lux manages significant value across DeFi, bridge, and governance systems, so machine-checked proofs of correctness are essential for:
- Consensus safety — no two honest validators decide differently.
- Consensus liveness — all honest validators eventually decide.
- BFT guarantees — quorum intersection and honest majority.
- Smart contract invariants — no value extraction, inflation protection, solvency.
Specification
Lean 4 consensus proofs
Repository: github.com/luxfi/formal Tool: Lean 4 v4.14.0 with Mathlib v4.14.0
Protocol coverage
| Protocol | File | Theorems | Status |
|---|---|---|---|
| Wave | Protocol/Wave.lean | 3 | Proved |
| Flare | Protocol/Flare.lean | 3 | Proved |
| Quasar | Protocol/Quasar.lean | 3 | Proved |
| Ray | Protocol/Ray.lean | 3 | 2 proved |
| Field | Protocol/Field.lean | 2 | Proved |
| Nova | Protocol/Nova.lean | 2 | Proved |
| Nebula | Protocol/Nebula.lean | 2 | Proved |
| Photon | Protocol/Photon.lean | 2 | Proved |
| Prism | Protocol/Prism.lean | 2 | Proved |
Core theorems
- Safety: if any honest validator decides
v, no honest validator decidesv' ≠ v. - Liveness: eventually all honest validators decide (under partial synchrony).
- BFT: quorum intersection, honest majority, unique finalization.
- Warp: exactly-once delivery, monotonic nonces.
Cryptographic axioms
- BLS bilinearity and aggregate soundness (proved).
- FROST threshold signature unforgeability.
- Pulsar post-quantum threshold signatures.
- ML-DSA FIPS 204 post-quantum signatures.
Halmos symbolic proofs
Location: test/halmos/ in github.com/luxfi/standard
Tool: Halmos symbolic execution
| Contract | Proofs | Key properties |
|---|---|---|
| AMM V2 | 12 | Constant product, no-drain, output bounds |
| LiquidLUX (xLUX) | 9 | Share/asset monotonicity, inflation protection |
| Markets (lending) | 8 | Utilization bounds, interest monotonicity |
| Transmuter | 15 | Earmark conservation, solvency |
| L* tokens | 15 | Bridge safety, deposit/withdraw round-trip |
| Other | 9 | Fee bounds, governance |
Foundry invariant tests
33 property-based fuzz test suites covering AMM, LiquidLUX, Markets, Perps, StableSwap, Staking, Karma, Bridge, Governance, and Treasury.
Rationale
- Lean 4 for consensus: expressive dependent type theory, Mathlib library for number theory and algebra.
- Halmos for Solidity: symbolic execution on EVM bytecode, Z3 / Bitwuzla SMT solving.
- Foundry invariants for stateful fuzzing: complements symbolic execution with random exploration.
Security Considerations
Formal verification provides strong guarantees within the model. Limitations, stated plainly:
- Lean proofs verify protocol logic, not the Go implementation directly.
- Halmos operates on compiled EVM bytecode (faithful to deployment).
- SMT timeouts occur on nonlinear bitvector arithmetic; these are addressed via algebraic decomposition.
References
- Lux Consensus Paper
- Lux Bridge Paper
- Formal Proofs Repository
- lp-0085 — Security Audit Framework
- lp-0110 — Quasar Unified Consensus