Repository navigation
Prove RISC-V instructions match Clean model: shifts, comparisons and branch conditions. - #1033
Open
nicole-graus wants to merge 41 commits into
Open
nicole-graus wants to merge 41 commits into
nicole-graus wants to merge 41 commits into
Conversation
…fs and a differential check against the prover
…el to its channel API. Clean removed StaticLookupChannel in favour of Air.Flat.Lookup, so the structure moves to LambdaVM/StaticLookup.lean and BITWISE reads its tables through toChannel. Interactions now carry a direction and a nonnegative multiplicity, and a pull must have multiplicity 0 or 1: EQ, LT and SHIFT discharge that from their existing bit constraints, and their guarantees are stated for multiplicity 1 instead of -1. EqLookup is rewritten for the current SoundEnsemble API (a balance parameter, channels added before tables, unique table names, a demand generation mode per component), and eq_rows_correct takes the InteractionsFit premise that TableSoundness now has. Channels/Counted.lean is ported to directions; not_consistent needs only two interactions, since a pull of multiplicity N >= 2 counts as a push. A grind call in IsByte that no longer closes its goal is replaced by a direct proof. The export now records each interaction's direction, so the JSON files are regenerated and lean_diff.rs signs Lean multiplicities by direction. Nothing that is proven changes.
…p fallback the linter flags. if_true, if_false, if_pos, if_neg, dif_pos and dif_neg become ite_true, ite_false, ite_eq_left, ite_eq_right, dite_eq_left and dite_eq_right, as in Clean. In SHIFT, first | ... | skip becomes try first | ..., which behaves the same. The build has no warnings left.
… the bump, and the renames left in SHIFT's completeness proof. Both lemmas discharged a pull requirement stated with the old multiplicity -1 (`¬ -e = -1 → ¬ e = 0 → P`), which the directed interactions no longer produce. In SHIFT, the hypotheses that needed neg_inj.mp to go from `-x = -1` to `x = 1` now arrive as `x = 1`, so they are introduced under their final names instead of being copied.
…tates the sign the comparison uses: a sender (Clean's pull) counts −m and a receiver (Clean's push) +m. The old first sentence described the prover's LogUp sum, where a sender adds +m, and read as if it contradicted the code below it. Comment only, no code change.
Clean's Demand.direction is the net sign of a message, pushes minus pulls, so a demand of direction .pull is one that was pulled more often than pushed and needs a component that pushes to answer it. EQ pushes its result on the ALU bus, so its generation mode has to trigger on .pull, the same way pushStaticComponent does and the same way Clean's own add8Component and lookup provider do. The field is inert today, since generation is not part of TableSoundness and nothing here runs Clean's witness generator, but .push described a component that answers pushes by pulling, which EQ never does.
The Clean bump changed the things this file documents: pulls carry a nonnegative multiplicity with an explicit direction instead of a negative one, a pull owes a multiplicity of 0 or 1, BalancedInteractions no longer carries the interaction count bound (it moved to the Balance's fits, reaching soundness as the InteractionsFit premise), and not_consistent is now a two-interaction witness instead of the p/N construction. Also lists LambdaVM/StaticLookup.lean, which the bump added, and records that the export format carries the direction.
Bump Clean to current main (f3abad7c) and Lean to v4.35.0 in formal/
…ked export check, BITWISE note in README
…ed elan, export fails on a missing table entry
…n in README, slimmer lake cache, review fixes
Collaborator
Author
|
/ai-review |
Codex Code ReviewNo actionable issues found in the PR changes during static review. No builds or tests were run, as requested. |
AI ReviewPR #1033 · 216 changed files
FindingsNo non-rejected structured findings were reported. Reviewer Lanes
Native Codex and Claude reviews run separately and post their own comments. They are not included in this structured provenance report. Raw lane outputs, candidates, final issues, and model metrics are uploaded as workflow artifacts. |
nicole-graus
marked this pull request as ready for review
November 17, 2026 14:25
jotabulacios
approved these changes
Nov 19, 2026
ColoCarletti
approved these changes
Nov 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Proves, instruction by instruction, that the Clean model in
formal/computes what the official RISC-V spec says.PR Size: 175 of the 217 files (~176k of ~177.8k lines) are the generated Sail model in
sail-riscv-lean/LeanRV64D/; GitHub collapses them (.gitattributes) and CI checks they match their pinned sources. The hand-written part is ~1.8k lines, mostlyformal-riscv/.What's in it
formal-riscv/: one chain of three proofs per instruction:Sail.lean: Sail'sexecute_*is a pure function (*Pure).Bridge.lean:*Pure, read as a natural, is the Clean model's function (shiftResult,ltBit,eqBit).Alu.lean: an ALU bus message with the instruction's flags carries that result, usingAlu.Guarantees.SLL/SRL/SRA(+ immediate and word versions),SLT/SLTU(+ immediate), and the conditions ofBEQ/BNE/BLT/BGE/BLTU/BGEU. 22*_alu_matches_sailtheorems, nosorry.sail-riscv-lean/: the Sail RISC-V model in Lean, generated from pinned commits ofriscv/sail-riscvandrems-project/sail(PINS,scripts/generate.sh). It replacesopencompl/sail-riscv-lean, which is no longer updated. The Sail compiler is pinned to fix(lean): split variants exceeding runtime constructor limits rems-project/sail#1823 (not merged yet), which splits theinstructiontype so it compiles on Lean v4.35.0;PINSwill move to Sail's main once it is merged..github/workflows/sail-riscv-lean.yml: regenerates the model and fails if it differs from the committed one.Not covered yet
ha,hb).Notes
formal/. Lean ≥ 4.35 rejects inductive types with more than 244 constructors (error: Error: tag for constructor 'ast.ZIMOP_MOP_RR' is too big, this is a limitation of the current runtime leanprover/lean4#8930), and the model'sinstructiontype has 361; fix(lean): split variants exceeding runtime constructor limits rems-project/sail#1823 generates it in chunks, which is why the compiler is pinned to that PR.formal-riscvis not built by CI yet.