Repository navigation
Counted pulls in formal/: LT with byte μ and soundness by finishing order, on the Clean fork - #1031
jotabulacios wants to merge 20 commits into
Conversation
cb1f718 to
984d2b2
Compare
…ove the counted channel consistent there. The lakefile points at the fork branch, which adds pulls of multiplicity up to N, a counted channel and soundness by finishing order on top of Clean f3abad7c. For now it is a path dependency on the build server (../../clean-fork-main); it becomes a git dependency on yetanotherco/clean once the branch is pushed. Channels/Counted.lean gains consistentUpTo: under BalancedUpTo N, which the fork's balance checks provide, the counted channel is consistent. It is the positive counterpart of not_consistent, which still shows the gap under BalancedInteractions alone.
…oes. mu is now a byte instead of a bit: the row pulls IS_HALF and MSB16 with multiplicity mu through counted channels, and bounds mu by pulling ARE_BYTES[mu, 0]. The row spec holds for rows with mu != 0, and the honest prover keeps mu below 2^8. With this the Lean LT chip matches the Rust one exactly, so lean_diff.rs no longer expects the mu bit constraint on the Lean side and ARE_BYTES on the Rust side; it asserts that no constraint or interaction appears on one side only.
…d pulls on one bus. MIN is not an RV64IM operation. Its chip pulls an LT result from the ALU bus and pushes its own result on the same bus, as the division chip pulls LT and MUL results and pushes DIVREM. The ALU guarantee gets a MIN clause (opsel 7), so EQ, LT and SHIFT also prove that their pushes are not MIN results.
… the ALU bus. LtStaged builds the LT ensemble with counted IS_HALF and MSB16 and proves its table soundness with tableSoundness_of_staged: ARE_BYTES is finished first, so LT's bound mu <= 255 on its counted pulls follows from that guarantee. It then adds MIN, finishing the ALU bus in two stages, every message that is not MIN before MIN. CountedSameBus does the same with CMIN, which pulls LT and pushes MIN with a counted multiplicity on the ALU bus, the shape of a deduplicated division chip, and proves it sound with tableSoundness_of_stagedOn.
…rk on GitHub instead of a local path, so the branch builds anywhere and not only on the build server. The pinned revision, 1cf67e24, is the same Clean the model was built against (counted pulls and soundness by finishing order on top of Clean main f3abad7c); Mathlib and CompPoly are unchanged.
…6 with multiplicity μ through Channel.counted 255 and matches lt.rs exactly, so the LT deltas and the "LT keeps μ a bit" notes are gone. The counted-pulls section says what the model takes from the yetanotherco/clean fork (Balance.logUpUpTo, Channel.counted, soundness by finishing order) and describes the LtStaged and CountedSameBus ensembles; the layout lists MinToy and flags MIN as a toy stand-in for DVRM on the ALU bus.
…It announced an end-to-end LT theorem and then described LtStaged as proving the LT ensemble sound, which overstates it: LtStaged proves Ensemble.TableSoundness, which is one premise of a sound ensemble and not the conclusion, and it leaves witness.Assumptions to the caller. That premise is not free here, because the ARE_BYTES, IS_HALF and MSB16 providers are not tables: provider and countedProvider push whatever value they are handed under Assumptions input data := channel.Guarantees input.1 data, so each one assumes its own answers are correct, and CountedSameBus reuses both of those components. The section now says that, says there is no lt_rows_correct, and keeps the contrast with EqLookup explicit, where pushStatic proves the guarantee from membership in a real static table and eq_rows_correct discharges witness.Assumptions outright. The technical content about what the fork supplies is unchanged.
…is branch removed. LT no longer has the isBit mu constraint: it pulls ARE_BYTES[mu, 0] as lt.rs does, so no table has a Lean-only constraint and all three lean_diff tests assert that the four unmatched lists are empty. The comment in lean_diff.rs still named that delta as the reason Lean-only constraints are skipped on honest rows, and the differential-check section of formal/README still said the deltas are skipped there while the Known differences section lists none. Both now describe what the test does, and the skip in lean_diff.rs is marked as a guard for a future table rather than something that fires today.
… rests on a sorry or on an axiom outside propext, Classical.choice and Quot.sound. The job built formal/ and checked that the export was up to date, but nothing ruled out a proof that holds only because a hole was left in it, which is the one failure mode a reader of the README cannot see. LambdaVM/Axioms.lean lists the five circuits (LT, EQ, SHIFT, MinToy, CountedMin) and the four ensemble theorems (eq_rows_correct, LtStaged.tableSoundness, LtStaged.tableSoundness_withMin, CountedMin.tableSoundness) as #print axioms lines; it is not imported by LambdaVM.lean, so lake build ignores it and the workflow runs it with lake env lean. The step also counts the reports against the #print axioms lines in the file, so a renamed or deleted declaration fails instead of dropping out of the check, and an unknown constant fails lean itself.
…with the four fixes that came out of the audit of that branch. The pin is a raw sha rather than a branch name, so the fork and this file move in lockstep and a reader of either knows exactly which Clean the proofs were checked against. The four are not a rewrite of the mechanism, only of how it is stated and what it is known to require. SoundChannels takes the pull bound after the subject, matching the argument order of every other predicate in that file; matchedUpTo_of_balanced gets a default so a plain balance check compiles again without naming the bound; each balance check exposes its pullBound to simp, which is what lets a proof discharge the bound instead of unfolding the check; and not_consistent proves the bound cannot be weakened, by exhibiting for 2 <= N <= 255 over Goldilocks a pair of pulls that satisfies plain BalancedInteractions while the counted channel reads both as pulls and the second guarantee is false. The model does not use the three APIs whose signatures moved, so nothing in formal/LambdaVM changes with the pin. That was checked by building all of lambda_vm against the new Clean before this commit, not inferred from the diff.
…u_op enum. prover/src/tables/types.rs numbers the ALU operations up to MUL = 7 and DIVREM = 8, so the toy MIN shared a flag byte with MUL. Nothing is wrong today: no clause of Alu.Guarantees mentions MUL, and AluOp.lean transcribes the enum only up to opselSHIFT = 5, which is why the collision was invisible from Lean. It stops being invisible the day MUL is modelled on this bus, because opselMUL has to be 7 and then two clauses of the same guarantee answer the same flag byte. The literal moves everywhere the model writes it, not only in the def: MinToy and CountedSameBus push it, LtStaged's isMinMsg classifies the ALU bus by it, and the proofs name it through val_lit. Moving the def alone would leave the MIN clause of Alu.Guarantees unreachable and every proof would still compile, which is the hazard the literals create: opselMIN is documentation until a circuit uses it.
…e so the workflow can read it. Axioms.lean listed five circuits and four ensemble theorems but not Counted.Demo.circuit, a GeneralFormalCircuit with its own soundness and completeness proofs, and the one the counted-pulls section of the README sends a reader to. A sorry there passed CI. The file now holds ten reports. The step's sed needs the opening [ and the closing ] of an axiom list on the same line, and Lean wraps #print axioms output at the default format width; the longest report on this branch already runs to about 108 characters. So the check got weaker exactly as it got more to check: more axioms, longer line, a sed that matches nothing and a step that passes. -Dformat.width=1000 keeps each report on one line.
… credit EqLookup to its PR. The section linked the fork by branch name while lakefile.toml pins by sha, so the two could drift, and the link dies when the branch is renamed or deleted once the upstream PRs land. It also said "Clean main f3abad7c plus three commits", which was true of the old pin and not of 73309694: that one is the three commits plus the four review fixes answering the audit of them. And EqLookup, described there as "in this same PR", is already in the model from PR #1027.
…t bits.
formal/README.md and the docstring of LT.Honest both said completeness holds for rows with
μ ∈ {0, 1} only, and the README sent the reader to "Known differences" for the reason. Neither is
true of this branch: Honest asks r.mu.val < 2^8, the completeness proof uses that definition, and
the deduplicated rows it excludes are exactly the ones this branch set out to model. The entry in
Known differences that justified the restriction went away with the LT deltas, so the pointer led
to a section that no longer mentions it.
Both now say μ ∈ [0, 255] with deduplicated rows included, and the docstring says what the
statement is about: completeness of the row circuit, not of the Rust generator that fills the
trace, which is not formalized.
…s already do. The repository merges through a queue: pr_main.yaml and gpu-tests.yml both take merge_group, and gpu-tests.yml says so in a comment. formal.yml was the only workflow without it, so the Lean build, the axiom check and the export check ran on the pull request and then not on the commit that actually merges. A change that breaks the model only once combined with another queued pull request went in unchecked, which is the failure the queue exists to catch.
…moves. formal/clean-model 04449f1 added a "What is intentionally not proven" section to the README and a docstring on LT.circuit, both written for a branch where mu is a bit. They merged without a conflict, because this branch never touched those lines, and they now contradict it: the docstring says soundness and completeness do not cover the deduplicated rows that lt.rs produces, one bullet says LT is proven for mu in {0, 1} only, and the bullet above it says LT has no ensemble. The docstring and the bullets now say what holds here: mu is a byte bounded by the ARE_BYTES[mu, 0] pull, the deduplicated rows are covered, and the ensembles this branch adds prove Ensemble.TableSoundness. What stays unproven is kept rather than dropped, and made precise: there is no lt_rows_correct, because the ARE_BYTES, IS_HALF and MSB16 providers assume their own answers, so nothing concludes about the LT rows of a real trace. SHIFT still has no ensemble.
21a274b to
3f43438
Compare
…reach every declaration from the axiom gate. MinToy.circuit and CountedSameBus.circuit carried Spec _ _ _ := True, so CountedMin.tableSoundness and LtStaged.tableSoundness_withMin concluded nothing about the rows they quantify over: the first is provable with all four of its hypotheses discarded, which a check of it confirmed before this commit. MIN now states that its outputs are 32-bit and equal the min of its inputs, with no guard, because its LT pull is unconditional; CMIN states the same under mu != 0, which is what its counted pull gives. Both derivations are the same once LT has answered, so they share MinToy.min_of_lt_answer. Separately, neither ensemble listed a table that pulls the bus it finishes, so the two tableSoundness statements held for want of anyone to contradict them; LtStaged.consumer and LtStaged.countedConsumer add that puller. A consumer owes the channel nothing a provider does not: a pull gains the guarantee rather than discharging it, and the honest-prover obligation sits in ProverAssumptions, which only completeness sees. That also puts bytes_ne_alu to use, which until now no proof referenced. The axiom gate listed ten declarations and missed eight -- the four Templates assertions, the two static Bitwise tables, and Counted.consistentUpTo and not_consistent -- and since lake build only warns on a sorry, the build step now fails on one anywhere in the library, not only in what Axioms.lean names. The comment on LT's ARE_BYTES pull claimed the model and spec/src/lt.toml agree; the model follows lt.rs and lt.toml is the one that still declares mu a Bit. Counted.lean's docstring now names the pinned sha next to the branch. The Clean pin and the toolchain are unchanged.
|
/ai-review |
Codex Code Review
|
AI ReviewPR #1031 · 16 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. |
|
Review (static, from the diff) I found no correctness issues. The LT change matches Minor points:
Overall, LGTM. |
…Channel.counted keeps the base channel's name, so Bitwise.IsHalf.counted 255, which Tables/Lt.lean pulls, and Bitwise.IsHalf.toRaw, which Tables/Eq.lean and Tables/Shift.lean pull through pullIf, are two different RawChannels both called IS_HALF, and Ensemble.unique_channel_names rejects a tables list holding both; MSB16 is the same. Nothing in the tree hits this, because LtStaged and CountedSameBus hold LT and its toy MIN only, but a reader adding EQ or SHIFT to either ensemble would meet it with no warning. A combined ensemble would have to move EQ and SHIFT onto the counted channel at N = 1, and the pinned fork has no lemma collapsing Channel.counted 1 to the plain channel, so that is a proof obligation rather than a rename. Documentation only: no .lean file changes, so the proofs and the export are untouched.
…ne, which until now passed it. The gate counts one report per #print axioms line and then extracts each axiom list with a sed that needs the opening [ and the closing ] on the same line. A report split across lines still carries the phrase on its first line, so the count matched, the sed extracted nothing, and an axiom outside the standard three went unseen: a report of 18 declarations with one list split and a fake axiom inside it passes the old check on all three of its tests. Requiring that every report carrying a list was actually parsed closes that. While checking this, -Dformat.width=1000 turned out not to be what keeps the reports on one line: #print axioms ignores it on v4.35.0 and emits the same 111-column lines at width 1 as at width 1000. The flag stays as a precaution for a future toolchain, but the comment no longer claims it is the guarantee, because the new parse check is. Also drops a double blank line from Channels/Counted.lean's module docstring.
…te literal is pinned. The honest-trace loop in lean_diff.rs skipped the unmatched Lean constraints, and its comment said the skip was kept for a table that lands in Lean before its Rust side does; it could never serve that. The loop runs while the report is still being built, and each caller then asserts that the unmatched list is empty, so a Lean-only constraint fails the test with or without the skip, which only moved the failure to a message that says less about it. Removing it leaves all four differential tests green, which is what says the skip was dead. isMinMsg compares the flag byte against the literal 9; the literal stays, because the proofs normalise to `(9 : F p)` and a cast of the named constant no longer matches those rewrites, but its docstring now names MinToy.opsel_literals, the theorem that pins both names to their values, so a reader meeting the 9 can see what holds it there. Finally, lakefile.toml says to keep `rev` a sha: Clean's own lakefile sets preferReleaseBuild with releaseRepo on Verified-zkEVM, so pinning a release tag would download a prebuilt library from upstream instead of compiling this fork's source. A tag in the fork is still worth having as an anchor against the branch moving, but beside the pin, not in it.
|
/ai-review |
Codex Code Review
|
ReviewI reviewed this statically from the diff. The proofs themselves are left to CI ( MediumThe spec now disagrees with both the model and the Rust on μ. Low
Nits
The rest looks good: the CI gate ( |
Models LT rows with byte multiplicities, which removes the documented LT constraint and
interaction deltas against Rust, and exercises finishing order of channels and of message classes
with two toy MIN circuits.
The dependency is the
yetanotherco/cleanfork pinned at73309694,seven commits after Clean main
f3abad7c: three feature commits and four review fixes. Theextensions used are
Balance.logUpUpTo N,Channel.counted N, and soundness by finishing order ofchannels and message classes. The pinned fork is part of the review scope — this does not build
against Clean upstream.
Changes
ARE_BYTES[μ, 0]and derives itsμ ≤ 255bound from that pull, then uses it for thecounted
IS_HALFandMSB16pulls. Its differential now has no unmatched constraints orinteractions.
LtStagedprovesEnsemble.TableSoundness (Balance.logUpUpTo 255), first for LT and then for LTplus toy MIN, splitting the ALU messages into non-MIN and MIN stages.
CountedSameBuschecks the same shape with counted pulls on the ALU bus itself.alu_openum (which ends atMUL = 7,DIVREM = 8).It is not an RV64IM instruction.
MinToypulls LT on every row, padding included, which isdeliberate;
CountedMingates both its counted pull and its emit with μ.sorryor on an axiomoutside
propext,Classical.choiceandQuot.sound, and the formal workflow now also runs onmerge-group commits, as the other workflows do.
μ ∈ [0, 255], which is whatLT.Honestasks; the text saidμ ∈ {0, 1}.What the result is, and is not
TableSoundnesskeeps witness assumptions, constraints, interaction-count bounds and balance aspremises. It is not an end-to-end correctness theorem for LT or for the zkVM.
ARE_BYTES,IS_HALFandMSB16providers assume their own answers satisfy the channelguarantees; this PR does not discharge that from BITWISE rows. There is no
lt_rows_correct.Spec := True, soCountedMin's final witness spec isunconditionally true. What that example buys is the checked channel and stage obligations, not a
public theorem about MIN outputs.
eq_rows_correctdoes discharge its component assumptions, but its ensemble has noALU consumer, so balance forces
μ = 0and no active EQ row can occur under its premises.evaluation points from a fixed seed. BITWISE additionally does not compare receiver
multiplicities, nor the independence of messages from the multiplicity columns; both gaps are
inherited from the base and are open in this head.
Validation
Build, the ten axiom reports, the export comparison and the four differential tests pass. The
formal workflow runs the Lean checks; the general Rust workflow runs the differential tests.
Based on #1027. The rest of the stack is outside this PR's scope.