Repository navigation
Review fixes for counted pulls - #3
Open
MauroToscano wants to merge 6 commits into
Open
MauroToscano wants to merge 6 commits into
MauroToscano wants to merge 6 commits into
Conversation
…st are. `BinaryFibonacci`, `FibonacciVm` and `OpcodeVm` each keep their ensemble and its generation test side by side as `Ensemble.lean` and `WitnessGenerationTest.lean` in a directory of their own. `CountedSquares` now does the same. Only the paths change: the imports in `Clean.lean` and `Clean/Test.lean`, the test's own imports, and the path the example's module doc cites.
REVIEWERS.md asks a theorem's name to state its conclusion and then, after `_of_`, its hypotheses in order, each part naming a declaration of the statement. - `countUpTo_of_val` assumes `mult ≠ 0` and `mult.val ≤ N`, and is now `countUpTo_of_ne_zero_of_val_le`. - `countUpTo_of_one_or_two` assumes `(c - 1) * (c - 2) = 0`, not a disjunction, and is now `countUpTo_of_sub_one_mul_sub_two_eq_zero`. - `partialBalancedChannel_of_balancedInteractions` has assumed `BalancedUpTo N` since the bound was threaded through, and is now `partialBalancedChannel_of_balancedUpTo`. - `partialBalancedChannel_of_balancedChannel` and `verifierChannelGuarantees_of_tableRequirements` state their balance hypothesis as `witness.BalancedChannel N channel` again, the abbreviation they were written against, rather than its unfolding. The two are definitionally equal, so no caller changes. `RawChannel.eq_false_of_name_ne` moves above `namespace Channel`, so it no longer needs `_root_`.
doc/conventions.md (§4) asks new simplification lemmas to go into `circuit_norm` only: "We do not modify the default `[simp]` set." `Balance.logUp_pullBound`, `Balance.logUpUpTo_pullBound` and `Balance.multiset_pullBound` were tagged `@[simp, circuit_norm]`; they are now `@[circuit_norm]`, and their docstrings name `circuit_norm` alone. Every proof that reduces a `pullBound` already passes `circuit_norm`, so nothing else changes.
…oes. Docstrings only, no change to any proof. - `Channel.counted`: a counted channel under a new name would not silently stop generating rows. No component would answer its interactions, so generation fails with `unhandledImbalance`. A second channel under a taken name fails the `fresh` argument of `SoundEnsemble.addChannel`, which is how in-tree ensembles add channels, or `unique_channel_names` for an `Ensemble` built directly. - `counted_consistentUpTo_of_le`: `haveI` is one way to supply it. Passing it explicitly through `@` to `SoundEnsemble.markFinished` works too. - The `Channel.counted` module doc says how to finish under a bound above `N`. - `Balance.logUpUpTo`: the bound `count * N < ringChar F` applies to every channel of the ensemble, counted or not, because `Ensemble.interactionsFit` applies `fits` to each channel. The PR's Extraction section already said so; the docstring now does too. - `exists_logUpBalanced_not_matchedUpTo`: the two-pull sentence now includes `2 ≤ N`. Without it, `N = 1` over `ZMod 2` meets the stated conditions, yet the list has length `2 = ringChar F` and fails the bound on the length, the boundary the next paragraph excludes. - `countUpTo_of_ne_zero_of_val_le`: a range check gives `mult.val ≤ N`, and `mult ≠ 0` comes from splitting off the requirement's `mult = 0` case. The check does not give both. - `CountedSquares`: `counted_not_consistent` does not show that a row free to claim any multiplicity breaks the channel. Both pulls of that counterexample meet their obligation, and what fails is the plain balance premise. The module doc now gives the row-level reason, a pull at `-1` counted as a push, and cites the theorem for the balance-check half. - `CountedSquares`: generation does not split a row at `N`, so a chip that counts its demand in a multiplicity cell and pulls with it fails its constraint past `N`. The consumer here pulls a fixed count per row. - Generation test: the three runs make `6`, `7` and `8` interactions, and the padding section's first scenario checks the unpadded state before the second one pads it.
The README's "Organization" section listed neither `CountedChannel.lean` nor the bound a `Balance` now carries. The `Balance.lean` paragraph gains a sentence on `pullBound`, `Balance.logUpUpTo` and `RawChannel.ConsistentUpTo`, and `CountedChannel.lean` gets a paragraph of its own pointing at `Clean/Examples/CountedSquares`.
Comments and docs only; with comments stripped, the code is unchanged.
Stale or wrong:
- `MatchedUpTo` cited `exists_push_of_pull` for `N = 1`; it is `matchedUpTo_one`.
- `pullBound` was "the largest" multiplicity matched, which nothing proves.
- `countUpTo_of_ne_zero_of_val_le` claimed to be how a circuit discharges a counted pull's
requirement; it is stated as what it gives, with no claim about callers.
- The `example` after the counted instance spoke of any concrete balance check; it is
`Balance.logUpUpTo`, which is reducible, unlike `Balance.logUp`.
- `ProviderInput.mult` said how many pulls a row answers; the row pushes `mult + 1` times.
- `consumerComponent` said one row per pushed square, then that two rows answer four pushes.
- The README called `Channel.counted N` a typed channel; it is a `RawChannel`. Its "every pull is
matched" now says multiplicity `1`, next to the counted pulls of the same paragraph.
Shorter: history wording ("before counted pulls", "already had") is gone, the `_one` lemmas say
what they equate, and the module docs no longer repeat the docstrings beneath them.
`counted_not_consistent` and `exists_logUpBalanced_not_matchedUpTo` keep every hypothesis and the
range their counterexamples need, in about half the lines.
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.
Review fixes for #1, into
pr1-counted-pulls. Nothing here changes what a theorem proves.Names, following REVIEWERS.md (conclusion, then
_of_and the hypotheses):countUpTo_of_val→countUpTo_of_ne_zero_of_val_lecountUpTo_of_one_or_two→countUpTo_of_sub_one_mul_sub_two_eq_zeropartialBalancedChannel_of_balancedInteractions→partialBalancedChannel_of_balancedUpTopartialBalancedChannel_of_balancedChannelandverifierChannelGuarantees_of_tableRequirementsstate their hypothesis as
witness.BalancedChannel N channel, the abbreviation, not itsunfolding. No caller changes.
RawChannel.eq_false_of_name_nemoves abovenamespace Channeland drops_root_.Simp set: the three
pullBoundlemmas are@[circuit_norm]only, per doc/conventions.md §4.Layout:
CountedSquaresmoves toClean/Examples/CountedSquares/, asEnsemble.leanandWitnessGenerationTest.lean, like the other examples with a generation test.Docs:
beneath them.
CountedChannel.lean.Each commit message lists what was stale.
Verified on this branch merged with upstream
main(71cd9a32):lake build --wfailandlake build CleanTestspass.sorrys inTestCircuitProofStart.lean.Left for follow-up: a
fitsbound per channel rather than one for the whole ensemble, andgeneration splitting a demand row at
N.Once this merges, #1's description is stale in three places:
pullBoundlemmas are no longer@[simp];Clean/Examples/CountedSquares/Ensemble.lean;Clean/Examples/CountedSquares/WitnessGenerationTest.lean.