This is the first concrete slice to bridge toward a full Lean-verified VM.
The formalization is intentionally staged to keep the trusted base small and mechanically checkable:
- Keep the existing Go implementation as the executable behavior reference.
- Define pure Lean operational semantics for each slice first (currently:
VMand subsetEVMkernels). - Prove byte/stack/gas invariants and compile-time safety properties before adding concurrency or I/O.
- Strengthen cross-module correctness theorems from bytecode decode → AST
Program→ run state. - Extend features incrementally (
jump, memory accounting, calldata, storage, receipts). - Lift verified semantics into the RISC-V witness pipeline and prove a full refinement bridge.
- Install Lean 4.28.0 and Lake:
curl -sSf https://raw.githubusercontent.com/leanprover/elan/master/elan-init.sh | shelan toolchain install 4.28.0cd formal/lean && elan install(if required by your environment)
- Run Lean checks:
cd formal/lean && lake buildcd formal/lean && lake test
- Introduce
formal/leanas a Lean 4 proof workspace. - Define a complete formal model for the current
pkg/zkvm/leanvminstruction set. - Prove core invariants about stack size, gas monotonicity, and byte-level operations.
Current progress from this commit:
- Added
formal/lean/lakefile.leanandformal/lean/lean-toolchain. - Added
formal/lean/Lean2030/VM/Spec.leanwith executable Lean semantics. - Added
formal/lean/Lean2030/VM/Compile.leanmatchingpkg/zkvm/leanvm.gotranslation. - Added
formal/lean/Lean2030/VM/Proofs.leanwith initial theorem skeletons and invariants.
-
Core EVM VM kernel extraction
- Port
pkg/core/vminstruction semantics for pure logic-first components. - Separate pure gas/memory/accounting layer first, leaving I/O and RPC out.
- For each opcode, prove:
- stack discipline
- gas monotonicity
- deterministic state transition
- invalid-state erroring instead of panicking
- Port
-
RISC-V front-end in Lean
- Formalize a small RTL-level machine (
riscv_cpu,riscv_memory,riscv_encode). - Prove a compiler/correctness theorem from EVM bytecode IR → RISC-V micro-ops.
- Formalize a small RTL-level machine (
-
Witness and constraint bridge
- Mirror
pkg/zkvm/riscv_witness.goandpkg/zkvm/constraint_compiler.goin Lean structures. - Show witness extraction is complete and cycle-aligned.
- Mirror
-
Cross-language refinement bridge (Go ↔ Lean)
- Add a Go test harness that emits deterministic state-transition traces.
- Add Lean parser over these traces and prove trace acceptance implies Go-state equivalence for the modeled slice.
-
Proof-carrying production path
- Replace trusted Go subset with Lean-certified kernel via generated/statically checked artifacts.
- Keep the rest of the Go client intact and progressively reduce trusted attack surface.