Skip to content

Counted pulls in formal/: LT with byte μ and soundness by finishing order, on the Clean fork - #1031

Draft
jotabulacios wants to merge 20 commits into
formal/clean-modelfrom
formal/counted-pulls
Draft

jotabulacios wants to merge 20 commits into
formal/clean-modelfrom
formal/counted-pulls

Conversation

@jotabulacios

@jotabulacios jotabulacios commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator

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/clean fork pinned at
73309694,
seven commits after Clean main f3abad7c: three feature commits and four review fixes. The
extensions used are Balance.logUpUpTo N, Channel.counted N, and soundness by finishing order of
channels and message classes. The pinned fork is part of the review scope — this does not build
against Clean upstream.

Changes

  • LT pulls ARE_BYTES[μ, 0] and derives its μ ≤ 255 bound from that pull, then uses it for the
    counted IS_HALF and MSB16 pulls. Its differential now has no unmatched constraints or
    interactions.
  • LtStaged proves Ensemble.TableSoundness (Balance.logUpUpTo 255), first for LT and then for LT
    plus toy MIN, splitting the ALU messages into non-MIN and MIN stages.
  • CountedSameBus checks the same shape with counted pulls on the ALU bus itself.
  • Toy MIN uses opsel 9, outside the Rust alu_op enum (which ends at MUL = 7, DIVREM = 8).
    It is not an RV64IM instruction. MinToy pulls LT on every row, padding included, which is
    deliberate; CountedMin gates both its counted pull and its emit with μ.
  • CI fails if any of ten listed circuit and ensemble declarations depends on sorry or on an axiom
    outside propext, Classical.choice and Quot.sound, and the formal workflow now also runs on
    merge-group commits, as the other workflows do.
  • LT's completeness is documented as covering byte multiplicities μ ∈ [0, 255], which is what
    LT.Honest asks; the text said μ ∈ {0, 1}.

What the result is, and is not

  • TableSoundness keeps witness assumptions, constraints, interaction-count bounds and balance as
    premises. It is not an end-to-end correctness theorem for LT or for the zkVM.
  • The ARE_BYTES, IS_HALF and MSB16 providers assume their own answers satisfy the channel
    guarantees; this PR does not discharge that from BITWISE rows. There is no lt_rows_correct.
  • MIN and the providers have Spec := True, so CountedMin's final witness spec is
    unconditionally true. What that example buys is the checked channel and stage obligations, not a
    public theorem about MIN outputs.
  • The inherited eq_rows_correct does discharge its component assumptions, but its ensemble has no
    ALU consumer, so balance forces μ = 0 and no active EQ row can occur under its premises.
  • The differential is testing evidence, not formal identity of the Lean and Rust systems: 64
    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

cd formal
lake exe cache get
lake build
lake env lean -Dformat.width=1000 LambdaVM/Axioms.lean
lake env lean --run LambdaVM/Export.lean && git diff --exit-code -- export
cd .. && cargo test -p lambda-vm-prover lean_diff -- --nocapture

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.

…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.
…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.
@nicole-graus

Copy link
Copy Markdown
Collaborator

/ai-review

@github-actions

Copy link
Copy Markdown

Codex Code Review

  • Medium — The axiom check can silently accept a wrapped axiom list. The report count only looks for depends on axioms, while sed extracts the list only when both brackets appear on the same line. format.width=1000 still allows longer reports to wrap. Parse multiline lists or fail when any counted report cannot be parsed. formal.yml
  • Low — The honest-trace comparison still skips unmatched Lean constraints, even though every caller now requires the unmatched list to be empty. Remove the skip and check every Lean constraint on the honest trace. lean_diff.rs

@github-actions

Copy link
Copy Markdown

AI Review

PR #1031 · 16 changed files

Findings

No non-rejected structured findings were reported.

Reviewer Lanes

Lane Model Prompt Status Findings

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.

@claude

claude Bot commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Review (static, from the diff)

I found no correctness issues. The LT change matches lt.rs: ARE_BYTES[μ, 0] replaces μ·(1−μ), and every IS_HALF/MSB16 pull is counted at muMax = 255. The new Guarantees MIN clause is discharged in LT, SHIFT, MIN and CMIN. Opsel 9 does not collide with the Rust alu_op values. lean_diff.rs now asserts that both unmatched lists are empty and keeps the check for deduplicated rows. Removing random_rows/challenges and the Multiplicity import leaves nothing unused that I could see in the diff.

Minor points:

  • Low (CI cost): merge_group ignores paths filters, so the full Lean/Mathlib build and the axiom check now run on every merge-queue entry, including PRs that don't touch formal/. That may be intended, given the comment, but it is a fixed cost on every merge. If the cost matters, you could keep the job and skip the Lean steps when the merge-group diff doesn't touch formal/**.
  • Low (supply chain / scope): Clean now comes from the yetanotherco/clean fork. It is pinned by sha, which is good. As the PR says, the fork's 7 commits (Balance.logUpUpTo, Channel.counted, tableSoundness_of_staged*) are part of the trusted base. The axiom gate only checks this repo's declarations, so an unsound lemma in the fork would pass, as long as it uses no sorry and no extra axioms. Please make sure the fork commits get their own review.
  • Nit: Channels/Counted.lean module docstring has a double blank line before "This file's counted is not…".

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.
@jotabulacios

Copy link
Copy Markdown
Collaborator Author

/ai-review

@github-actions

Copy link
Copy Markdown

Codex Code Review

  • Low — Remove unused proof helpers. isMinMsg_eval has no callers, and msg_eval_array is only used by that lemma. The active proof in cmin_alu_shape uses msg_eval and isMinMsg_toElements directly. Remove both unused lemmas. CountedSameBus.lean

@claude

claude Bot commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Review

I reviewed this statically from the diff. The proofs themselves are left to CI (lake build plus the new axiom gate). I found no Critical or High issues. This PR touches only formal/, CI and a test, so it changes no prover or VM runtime behaviour.

Medium

The spec now disagrees with both the model and the Rust on μ. Tables/Lt.lean now pulls ARE_BYTES[μ, 0] and treats μ as a byte, as lt.rs does. spec/src/lt.toml still declares μ as type = "Bit" (around line 85) and has no ARE_BYTES pull. The new comment in Lt.lean says the spec needs updating. Until it is, the spec is the one artifact that disagrees with the other two. Please update lt.toml here, or open a tracked follow-up, so it doesn't stay out of date.

Low

  1. Clean dependency pinned to a commit on a fork branch (lakefile.toml, lake-manifest.json). If the counted-pulls branch is ever force-pushed or deleted, 73309694 becomes unreachable and lake can no longer fetch it. The lakefile comment already says a tag is worth having. Please create a tag in yetanotherco/clean (or protect the branch) before merging, rather than leaving it for later. Per the PR description, the fork's seven commits are part of this review's scope, so someone needs to sign off on them explicitly.
  2. tableSoundness_withMin has no consumer for MIN messages (Ensembles/LtStaged.lean, ensembleMin). Nothing pulls MIN's pushIf μ messages, so under Balanced every MIN row's μ is forced to 0, and the "MIN class finished second" stage only ever balances zero-multiplicity pushes. MinToy.RowSpec is unguarded, so the row conclusion still holds. But this is the same vacuity the README calls out for eq_rows_correct and that CountedMin avoids with aluConsumerComponent. Either add a consumer here, as CountedSameBus does, or say so in the README next to the paragraph about consumers.
  3. Two different functions named counted. LambdaVM.Counted.counted (charges an out-of-range pull like a push) and the fork's Channel.counted (forbids it) now coexist, which the new docstring and README table have to explain. Renaming the local one (for example countedCharged) would make the difference visible at use sites instead of only in the docs. This is optional.

Nits

  • prover/src/tests/lean_diff.rs: the new comment above the honest-row loop mostly narrates history ("This used to skip the unmatched ones…"). Two lines saying what the loop checks would read better.
  • After the LT-specific checks are removed, please confirm that capture_interaction, rust_interaction_at and Challenges::fingerprint still have other callers in lean_diff.rs. If not, they are dead code (or will raise unused warnings) and should go. I couldn't check this from the diff alone.

The rest looks good: the CI gate (set -o pipefail, the per-line report count, the wrap check before the sed parse), adding merge_group, the opsel 9 choice for MIN outside alu_op, and the opsel_literals pin all look correct.

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