Skip to content

formal: scaffold the Rust-to-Lean extraction (hax), after Plonky3-lean - #736

Open
tcoratger wants to merge 1 commit into
mainfrom
lean-extraction-scaffold
Open

tcoratger wants to merge 1 commit into
mainfrom
lean-extraction-scaffold

Conversation

@tcoratger

Copy link
Copy Markdown
Collaborator

Sets up formal/extraction/, a Lake project for proving that leanVM's Rust refines the Lean statement. The layout follows Plonky3-lean. Nothing is extracted yet.

Why

formal/Statement/ transcribes the Rust by hand, and differential tests (check-all.sh vectors) pin the transcription to the Rust. Extracting the crates with hax (charon + aeneas) turns that pin into a theorem: each extracted function computes what its statement definition computes. With everything in place now, the first extraction only has to fill in one directory.

What

  • toolchain.toml: pins hax, charon, aeneas and charon's Rust to the same builds as Plonky3-lean, whose aeneas build already targets Lean 4.35 and the statement's Mathlib. The target is riscv64gc-unknown-linux-gnu. Because it is neither x86-64 nor aarch64, every SIMD arm is excluded, while usize stays 64-bit and std builds (Plonky3-lean's thumbv7em would give neither).
  • lakefile.toml: requires the statement (by path), Aeneas and CoreModels. All three resolve to one Mathlib, and the statement's pins are unchanged.
  • crates/<crate>/: one directory per workspace crate except bench. Each has a crate.toml giving its state (stub/scoped/extracted) and the statement modules its claims will target (spec), plus an empty stub whose imports follow the Cargo graph.
  • Refinement/ (Claims, Spec, Proofs, Lib), claims.toml, TRUST.md and HaxExt.lean. Spec defines its first reading function, from a model u64 to the statement's K.
  • tools/:
    • check-layout.py (new) checks that crates/, the lakefile and Cargo agree, and that imports follow Cargo.
    • check-claims.py and extract/ are ported from Plonky3-lean.
  • CI: a new extraction job in lean.yml, and an extraction step in check-all.sh.

Plan

  1. verifier, against Statement/LeanVmVerifier.lean: it has no dependencies, no unsafe and no cfg(target_arch).
  2. signatures.
  3. The prover crates, against Statement/Prover/.

Checks

  • ./check-all.sh extraction passes: escape scan, layout, build (Aeneas, CoreModels, statement field modules, all 12 crate libraries) and claims.
  • check-layout.py fails, as it should, on a stray import and on a stray extraction/ directory.
  • check-claims.py fails, as it should, on a claim that has no claims.toml entry.
  • extract.sh --tools-only reports the missing toolchain cleanly. The full extraction path has not run yet: no crate is extracted, and hax is not installed here.

Open questions

  • Library names follow hax's convention (LeanvmCore for leanvm_core), inferred from Plonky3-lean. The first extraction will confirm them.

🤖 Generated with Claude Code

…lean

A new Lake project, formal/extraction, where the crates' Lean models
(hax: charon + aeneas) will be proved to refine the statement. Nothing
is extracted: every crate is an empty stub fixing its library's name and
its imports along the Cargo graph.

- toolchain.toml pins hax, charon, aeneas and charon's Rust as
  Plonky3-lean does; the target is riscv64gc-unknown-linux-gnu, so the
  SIMD arms are excluded while usize stays 64-bit and std builds.
- lakefile.toml requires the statement (path), Aeneas and CoreModels;
  all resolve to the statement's Mathlib, with its pins unchanged.
- crates/<crate>/crate.toml per workspace crate (state, spec modules).
- Refinement/{Claims,Spec,Proofs,Lib}, claims.toml, TRUST.md, HaxExt.
- tools: check-layout.py (crates/, lakefile and Cargo agree, imports
  follow Cargo), check-claims.py and extract/ ported from Plonky3-lean.
- CI job `extraction` and check-all.sh step `extraction`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dhsorens

Copy link
Copy Markdown

This proposal makes sense in that it's very similar to the structure on Plonky3-lean - an alternative way to do this would be to just have a proofs/ directory in each crate, like is done here. I will think about this a little bit more but I wonder if the latter will be easier to keep up-to-date with how the repo moves? I guess there are engineering questions here

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants