LPsLux Proposals
Consensus Systems
LP-17

Formal Verification Framework

Final

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:

  1. Consensus safety — no two honest validators decide differently.
  2. Consensus liveness — all honest validators eventually decide.
  3. BFT guarantees — quorum intersection and honest majority.
  4. 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

ProtocolFileTheoremsStatus
WaveProtocol/Wave.lean3Proved
FlareProtocol/Flare.lean3Proved
QuasarProtocol/Quasar.lean3Proved
RayProtocol/Ray.lean32 proved
FieldProtocol/Field.lean2Proved
NovaProtocol/Nova.lean2Proved
NebulaProtocol/Nebula.lean2Proved
PhotonProtocol/Photon.lean2Proved
PrismProtocol/Prism.lean2Proved

Core theorems

  • Safety: if any honest validator decides v, no honest validator decides v' ≠ 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

ContractProofsKey properties
AMM V212Constant product, no-drain, output bounds
LiquidLUX (xLUX)9Share/asset monotonicity, inflation protection
Markets (lending)8Utilization bounds, interest monotonicity
Transmuter15Earmark conservation, solvency
L* tokens15Bridge safety, deposit/withdraw round-trip
Other9Fee 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