Repository navigation
Prove table soundness from a finishing order of channels and of message classes - #2
Open
jotabulacios wants to merge 3 commits into
Open
jotabulacios wants to merge 3 commits into
jotabulacios wants to merge 3 commits into
Conversation
…ge classes. A table's requirements on a channel may follow from its guarantees on channels finished before it, not only from its constraints. A counted pull needs this: its multiplicity bound comes from a lookup on another channel, which OrderedChannel can't express. Component.StagedRequirements states it for a finishing order, and Ensemble.tableSoundness_of_staged proves soundness by induction from the oldest channel. A stage is a channel together with a class of its messages. A table that pulls some messages of a channel and pushes others, like a division chip pulling LT and MUL results and pushing DIVREM results on the ALU bus, is not a cycle when the classes are finished in order. Ensemble.tableSoundness_of_stagedOn proves soundness from a finishing order of stages; balance is message by message, so each stage balances by itself (BalancedUpTo.filter_msg). Genuine cycles still have no valid order.
…ma too. Both staged soundness theorems inlined the same derivation over the ensemble's channels that `balancedChannels_of_balanced` names, which is the pattern just removed from `OrderedChannel.lean` and `Vm.lean`. All four call sites now go through the lemma, and `Balance.balancedUpTo_of_balanced` is applied in one place.
…eady does. `Component.StagedRequirements` has `@[circuit_norm]` nil and cons lemmas, so a caller discharging `∀ component ∈ ens.tables, component.StagedRequirements finished` with `simp [circuit_norm]` gets the list unfolded. `StagedRequirementsOn` had neither, so the identical proof over stages left a stuck goal.
jotabulacios
force-pushed
the
pr2-staged-channels
branch
from
November 16, 2026 13:38
79f1e1b to
17091cc
Compare
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.
Stacked on #1: the base of this PR is
pr1-counted-pulls, so the diff below is this PR's own work —one new file, plus 40 lines of
Balance.leanand one import.Why
OrderedChannelorders tables: a table may not both pull from a channel and owe requirements onit. Two shapes a VM needs break that.
The first has no workaround. A table that both pulls from a channel and pushes to it, on different
messages, is not a cycle: what it reads and what it writes are disjoint. The ALU bus is the
example — a division table pulls the
LTandMULresults it needs and pushes its ownDIVREMresults, all on one bus. Ordering whole channels cannot express that, and giving each operation a
channel of its own costs a channel per operation.
The second is a table whose requirements on one channel follow from its guarantees on another:
LTpullsIS_HALFwith multiplicityμ, andμ ≤ 255is known only because the same tablepulls
ARE_BYTES[μ, 0]. This one does have a workaround, unrolling the counted pull intoNpullsof multiplicity one, at
Ninteractions per row instead of one.This PR orders channels, and then stages: a channel together with a class of its messages.
finishedlists them newest first, and a component's requirements on one may use its guarantees onthose finished before it. By induction from the oldest, every one's requirements hold, so by
consistency its guarantees hold, and every table's spec follows. Balance is message by message
(
BalancedUpTo.filter_msg), so a stage balances by itself; a whole channel is the stage whoseclass is every message.
What
Component.RequirementsAfter/StagedRequirements, withEnsemble.channelGuarantees_of_stagedandEnsemble.tableSoundness_of_staged.Stageis a channel together with a class of messages, soone channel can be finished in several steps (byte lookups before the rows that use them).
RequirementsAfterOn/StagedRequirementsOn, withguaranteesOn_of_stagedOnandtableSoundness_of_stagedOn.BalancedUpTo.filter_msginBalance.lean: balance holds message by message, so it restricts toany class of messages.
Both staged theorems take their per-channel balance from
EnsembleWitness.balancedChannels_of_balanced, the same named step thatOrderedChannel.leanandVm.leanuse, rather than inlining the derivation over the ensemble's channels.Both forms are kept: the plain one is the simpler statement for an ensemble whose channels finish
whole, the staged-on one is what a VM ensemble needs.
requirementsAfterOn_of_requirementsAfterrelates them.Scope
Both theorems require
ens.verifier = .empty F PublicIO. For an ensemble of tables this is free:Ensemble.verifierdefaults to the empty program, so the hypothesis is discharged byrfl. It isnot free for a VM.
Ensemble.addVmpropagates the VM's verifier, which pushes the initial stateand pulls the final one on the very channel being staged, and neither
StagedRequirementsnorStagedRequirementsOnsays anything about what a verifier owes — the hypothesis is what lets theproofs use
interactionsWith_of_verifier_empty. So the finishing order covers table ensembles,while
OrderedChannel, which carriesOrderedChannelRefl channel ens.verifier, remains the paththat handles a verifier. Lifting the restriction means stating what a verifier owes on a staged
channel, which this PR does not do.
Checks
lake buildclean, zero warnings.lake build CleanTestspasses.sorry, nonative_decidein this PR's own files.Open point
tableSoundness_of_stagedconcludes onlyens.TableSoundness balance. The per-channel guaranteesit proves on the way are exported separately as
channelGuarantees_of_staged/guaranteesOn_of_stagedOn, which is what a caller that needs both uses.