ABI Layer 3: div/mod completeness of the block partition — closes the Layer-2 residual#42
Merged
Merged
Conversation
Adds Chapeliser.ABI.Invariants, a new machine-checked theorem deeper than
and distinct from the Layer-2 Partition tiling proof. Partition.idr proved
the block partition is a gapless, non-overlapping tiling for all n,k but
explicitly left open the arithmetic residual `sumNat (perItemCounts n k) = n`
("the only div/mod obligation"). This module discharges exactly that.
blockCountsComplete : (n,k') -> sumNat (blockCounts n k') = n proves every
item is covered exactly once, for ALL n and all k>0, via the Euclidean
division theorem (contrib Data.Nat.Division) plus a self-contained count of
remainder slots. Counts are expressed with the public-export divNatNZ/modNatNZ
(the reducing form of Prelude div/mod on a positive divisor) so the proof and
its concrete controls reduce at the type level.
Includes: a sound+complete Dec (decCoversExactly), positive controls
(covers10over3, covers12over4 by Refl + via the general theorem), and
non-vacuity/negative controls (notCovers10as9, dec10over3as9No,
remainderCountMatters). Genuine proof: no believe_me/postulate/assert_total/
sorry/admitted. Builds clean (0 warnings); a deliberately false variant is
rejected by the type checker.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01A6PSzJWpRxtzGDjUCEh7Mx
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.
Summary
Layer 3 (second, deeper invariant): proves
sumNat (blockCounts n k) = nfor all n and all k>0 — every item is covered exactly once. This discharges the exactdiv/modarithmetic residual the Layer-2Partitiontiling proof explicitly left open, via the Euclidean division theorem plus a self-contained count of remainder slots.New module
Chapeliser.ABI.Invariants(imports the Layer-2Partitionmodel; usesdivNatNZ/modNatNZbecause Preludediv/moddon't reduce at the type level). Sound+completeDec, corollaries tying back toPartitionComplete, positive + non-vacuity controls.Testing
Idris2 0.7.0
--build→ exit 0, zero warnings (6 modules). Adversarial: false variants (=9,=11) rejected.build/removed. Nobelieve_me/postulate/sorry.🤖 Generated with Claude Code
https://claude.ai/code/session_01A6PSzJWpRxtzGDjUCEh7Mx
Generated by Claude Code