lean4-proving
Formal verification with Lean 4 — propositions as types, structured proofs, statements you can trust.
SKILL.mdskills/lean4-proving/SKILL.md
GitHubLean 4 Proving
For the invariants that must never break — protocols, consensus, critical algorithms — prove it or don't claim it. Lean 4 turns specs into checked theorems.
When to use
- Critical invariants where a bug is unacceptable (protocol/consensus logic, state machines, safety properties).
- Formalizing a design before or alongside implementation.
- Reviewing proofs and verification claims.
Method
- Project setup:
elantoolchain,lakebuild, Mathlib as needed; pin versions; CI runslake buildso proofs stay green. - Types as propositions: state the theorem first —
theorem name (args) : Prop— and make sure the statement says what you mean before proving it. - Definitions first: total, executable definitions of the system model; specs separate from implementation.
- Proof craft: structured proofs;
simp,rw,induction,cases,omegawhere appropriate; keep proofs readable — they are code and docs. - No cheating:
sorry, new axioms, andnative_decideshortcuts are tracked (tickets), never smuggled into deliverables; a landmark proof ships with zerosorry. - Statement review: statements reviewed independently of tactics (a proof of the wrong theorem is worthless).
- Model ↔ code alignment: keep the verified model and the implementation in sync — document the mapping; port changes go back through the model.
Quality gates
-
lake buildgreen in CI (proofs compile). - Zero
sorry/axioms in delivered theorems (or explicitly tracked with sign-off). - Statements reviewed by a second pair of eyes.
- Model-to-implementation mapping documented.
Red lines
- Never weaken a statement silently to make it provable.
- No unproven claims dressed as "formally verified".
Related
architecture-decisions · rust-engineering (verified models → code) · secure-build-pattern.