Skip to content

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

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

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

Conversation

@jotabulacios

@jotabulacios jotabulacios commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Replaces #1031, which was rebased onto a base that changed the toolchain under it and stopped
compiling. Same end state, in two commits that build.

Base is formal/clean-model (#1027), not main. Merge order: #1027 → #1033 → this.

What changes

be86021 — the proofs. LT's multiplicity is counted in bytes rather than bits, and each
table's soundness follows from a finishing order of its channels instead of a global balance.
StaticLookup replaces the static-channel abbrevs, EqLookup takes a Balance parameter, and
two ensembles are added: LtStaged and CountedSameBus. The same commit moves the Clean pin to
the fork and regenerates the exported tables, whose format changed with Clean main.

1e45b46 — the workflow. A merge_group trigger, so the job also runs on the commit that
actually merges, and an axiom gate over the new LambdaVM/Axioms.lean.

Both commit messages carry the details. What follows is what they don't say.

Why the fork and not upstream

Two reasons, each sufficient on its own.

  1. The feature is not upstream. CountedChannel.lean (262 lines) and StagedChannels.lean
    (360) do not exist in Verified-zkEVM/clean, and Balance.lean gains 360 lines there. This
    branch uses them in 16 places.
  2. The toolchain — the Sail reason be86021 explains: upstream is on Lean v4.35.0, and
    formal-riscv/ needs v4.33.1.

So fixing leanprover/lean4#8930 would not bring us back to upstream. The unblocker is the fork's
counted-pulls branch landing in Verified-zkEVM/clean.

The pin is a sha in both rev and inputRev, so moving the fork's branch cannot move this
build. The fork's own CI never ran on that branch — it triggers on main, PRs and dispatch only
— so I checked the revision by hand: lake build --wfail over all of Clean (1936 jobs) and
CleanTests (2341 jobs), both clean, with 18 SKIPs for snarkjs and wasm-validate not installed.

What this proves, and what it does not

The consumers are real: LT.circuit, MinToy.circuit and CountedMin.circuit do counted pulls
on real channels, with muMax = 255 derived from LT's own ARE_BYTES[μ, 0] pull rather than
assumed.

The provider side is a stand-in. The BITWISE-shaped tables in these ensembles are
providerComponent / countedProviderComponent placeholders, not the real BITWISE circuit with
its numRows = 2^20. Proving the ensembles against the real provider is the next step, not this
PR.

Not vacuous, though: GeneralFormalCircuit requires completeness as well as soundness, and
the fork's CountedSquaresWitnessGenerationTest.lean generates a real witness for a counted pull
with native_decide.

Checked before opening

Full build (2000 jobs), the axiom gate (10 expected, 10 found, no sorryAx, only the three
standard axioms), and the export — all four JSON files regenerate byte-identical to the committed
ones.

Follow-ups

LT's multiplicity is counted in bytes rather than bits, and each table's
soundness now follows from a finishing order of its channels instead of a
global balance argument. StaticLookup replaces the static-channel abbrevs, and
the EqLookup ensemble is parameterised by a Balance.

The model builds against the Clean fork rather than upstream:

    git = "https://github.com/yetanotherco/clean"
    rev = "98e339e9ae2a02e8e0c4d6cfe81c2a5ce9467729"

That revision is upstream Clean main f3abad7c plus two commits: counted pulls
and staged channels, and a build on Lean v4.33.1. Upstream moved to v4.35.0 on
2026-10-22, and v4.35.0 cannot compile the Sail-generated RISC-V model that
formal-riscv/ depends on: its `inductive instruction` has 361 constructors and
the runtime caps constructor tags at 243 (LeanMaxCtorTag in lean.h). See
leanprover/lean4#8930, open and unmilestoned.

So this keeps 10856f8 in force rather than undoing it: lean-toolchain stays
at v4.33.1 and only the Clean entry of the manifest moves. Mathlib, CompPoly
and the rest are already the v4.33.1 set.

The export format changes with Clean main: a pull is no longer a negated
multiplicity but a "direction": "pull" field with a non-negative multiplicity.
prover/src/tests/lean_diff.rs reads that field, so the exported tables and the
Rust test that compares them move together.
The repository merges through a queue, so without a merge_group trigger the job
runs on the PR but not on the commit that actually merges: a change that only
breaks the model once combined with another queued PR would merge unchecked.
The other queued workflows already have the trigger.

The new step runs LambdaVM/Axioms.lean, a list of `#print axioms` lines that is
not part of the library and so never reaches `lake build`. It fails on sorryAx,
on any axiom outside propext, Classical.choice and Quot.sound, and on a count
mismatch, so a declaration that is renamed or deleted fails the build instead
of quietly dropping out of the check.
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.

1 participant