refactor: thin exists_perm_extending_strictMono via mathlib API (−46 lines)#18
Merged
Conversation
Reduces the local proof from 58 lines of hand-built subtype equivalences + `Equiv.extendSubtype` to a 13-line wrapper around `Equiv.Perm.exists_extending_pair` (landed in mathlib via PR #34599) plus `Fin.castLE` / `Fin.castLE_injective` for the initial-segment inclusion. Statement is unchanged; only the proof body is touched. The single call site (`contractable_of_exchangeable`) is unaffected. - Exchangeability/Contractability.lean: -44 net lines.
Two docstrings still described the old subtype-equivalence construction, which no longer matches the refactored proof body. - Module header (lines 55-58): "uses `Equiv.extendSubtype` to extend a bijection between subtypes" -> "thin wrapper around mathlib's `Equiv.Perm.exists_extending_pair`". - `exists_perm_extending_strictMono` docstring: 4-step "Construction outline" describing domain/codomain partition + manual `extendSubtype` -> short note pointing at `Equiv.Perm.exists_extending_pair` with the choice of `f` and `g`. Statement, signature, and behavior are unchanged.
This was referenced May 18, 2026
cameronfreer
added a commit
that referenced
this pull request
May 18, 2026
) Mines safe-subset replacements from the PR #16 autoGolf draft and applies them to current main, skipping the suspicious subset (lia / bare assumption / Real.ext_cauchy / grind only on non-arithmetic goals). `fun_prop` adoptions (replace hand-built `Measurable.const_mul + Finset.measurable_sum + .comp` chains): - `DeFinetti/ViaKoopman/BlockAverage.lean` (1 site) - `DeFinetti/ViaL2/BlockAvgDef.lean` (1 site) - `DeFinetti/ViaL2/AlphaConvergence.lean` (2 sites) - `DeFinetti/ViaL2/CesaroConvergence.lean` (3 sites) - `DeFinetti/ViaL2/DirectingMeasureIntegral.lean` (4 sites, incl. one Integrable wrap via `fun_prop`) - `DeFinetti/ViaL2/MainConvergence.lean` (1 site) - `DeFinetti/ViaMartingale/PairLawEquality.lean` (1 site, `measurable_consRV` → fun_prop) - `Ergodic/ShiftInvariantRepresentatives.lean` (1 site, `measurable_coe_real_ereal.comp …` → fun_prop) - `Core.lean:683` — collapse `simpa using (show … from by fun_prop)` to bare `fun_prop`. Named-lemma replacements: - `DeFinetti/ViaL2/DirectingMeasureIntegral.lean` 2× hand-built `IsPiSystem` proof for `Set.range Iic` → `isPiSystem_Iic`. - `Contractability.lean:perm_range_eq` — 4-line `ext`+`use`+`simp` → `Finset.image_univ_equiv σ`. Minor `by exact` removals in `BlockAvgDef.lean`. Out of scope (per the audit, suspicious-category from #16): - `BlockAverage.lean:82` `congr 1; ring` → `lia` swap (opaque substitution on non-arithmetic context). - The proof-golfing-branch reversion of #18's `exists_perm_extending_strictMono` refactor. Net -62 lines across 10 files. Build clean (3527 jobs), axioms standard, 0 sorries. No statement or signature changes.
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
First in the post-bump series of targeted mathlib-refactor PRs. Replaces the local 58-line proof of
exists_perm_extending_strictMonoinContractability.leanwith a 13-line wrapper around mathlib'sEquiv.Perm.exists_extending_pair(landed via mathlib #34599) plusFin.castLE/Fin.castLE_injectivefor the initial-segment inclusion, and updates two stale docstrings that still described the old subtype-equivalence construction.Net diff: 1 file, +15 / −61 (−46 lines), across two commits.
Why now
The exchangeability-papers#1 camera-ready revisions explicitly flagged the local permutation-extension code as a candidate for refactoring against existing mathlib infrastructure, and mathlib #34599 landed exactly this API. With the toolchain now at v4.30.0-rc2 (PR #17),
Equiv.Perm.exists_extending_pairis directly available.Commits
07695a91— refactor: thinexists_perm_extending_strictMonovia mathlib APIcontractable_of_exchangeable) are unchanged.c6d3cb95— docs: update Contractability docstrings to match refactored proofEquiv.Perm.exists_extending_pair.What the new proof body looks like
Verification
lake buildExchangeability+ForMathlib)Out of scope (planned follow-up PR)
The refactor exposes some spillover cleanup that does not belong here:
fun i => ⟨i.val, Nat.lt_of_lt_of_le i.isLt hmn⟩inclusions that could becomeFin.castLE hmn(Contractability.lean:410,:472,Util/FinsetHelpers.lean:32).Core.approxPermand its companionapproxEquivuse the sameEquiv.extendSubtypepattern (~32 lines ofapproxEquivmachinery) and can collapse via the sameEquiv.Perm.exists_extending_pairroute, saving ~35 lines.Both will land as a single follow-up PR after this merges.
Notes for review
ForMathlib/Combinatorics/PermutationExtension.leanfile proposed in PR refactor: Extract general-purpose lemmas to ForMathlib for upstream contribution #13 was never merged tomain, so nothing to delete there.σ (Fin.castLE hmn i) = ⟨k i, hk_bound i⟩to match the mathlib API shape directly) is deferred — it would broaden the PR semantically.