Skip to content

chore: Fin.castLE consistency + README version drift fix#21

Merged
cameronfreer merged 1 commit into
mainfrom
refactor-fin-castLE-and-readme
May 18, 2026
Merged

chore: Fin.castLE consistency + README version drift fix#21
cameronfreer merged 1 commit into
mainfrom
refactor-fin-castLE-and-readme

Conversation

@cameronfreer

Copy link
Copy Markdown
Owner

Summary

Small batched cleanup PR with two unrelated-but-trivial items:

  1. Fin.castLE consistency — two open-coded fun i => ⟨i.val, Nat.lt_of_lt_of_le i.isLt h⟩ inclusions are replaced with the mathlib spelling Fin.castLE h. The codebase already uses Fin.castLE in many places (Core.lean, the recently refactored Contractability.exists_perm_extending_strictMono from refactor: thin exists_perm_extending_strictMono via mathlib API (−46 lines) #18, and the new Core.exists_approxPerm from refactor: route Core.approxPerm through Equiv.Perm.exists_extending_pair (−31 lines) #20); these two sites had been missed.
  2. README version drift fixREADME.md:51 still claimed lean-toolchain was pinned to 4.27.0-rc1; the v4.30.0-rc2 bump (bump Lean to v4.30.0-rc2 + mathlib v4.30.0-rc2 #17) missed updating it. Rather than re-pin (and re-drift on the next bump), point at the file itself.

Net diff: 3 files, +7 / −13 (−6 lines).

What changed

Lean (proof-body-only, statements unchanged)

File Site Change
Exchangeability/Contractability.lean:470 contractable_of_exchangeable call site let ι := fun i => ⟨i.val, Nat.lt_of_lt_of_le i.isLt hmn⟩let ι := Fin.castLE hmn. Existing simpa [ι] and simp [..., ι] calls work unchanged (still unfold the let).
Exchangeability/Util/FinsetHelpers.lean:32 filter_val_lt_card Same let substitution. Inline hf_inj collapses from a 3-line proof to Fin.castLE_injective h. The Finset.image ext-step's simp only [f] is replaced by direct Fin.ext rfl / rintro ⟨j, rfl⟩.

Contractability.lean:408 was deliberately left alone — that let is inside a lemma statement (not the proof body), and per agreed scope this PR is proof-body-only churn. A statement-level cleanup pass can address it later if desired.

Docs

File Before After
README.md:51 (this project uses lean-toolchain pinned to 4.27.0-rc1) (see lean-toolchain for the pinned version)

This makes the README impervious to future bump drift.

Verification

Check Baseline (main = 18bf7ab) This branch
lake build clean (3531 jobs) clean (3531 jobs)
Axioms (11 theorem decls) standard only standard only
Sorries (Exchangeability + ForMathlib) 0 0
Proof-file churn 2 files, +5 / −12
Docs churn 1 file, +1 / −1

Notes for review

Two open-coded initial-segment inclusions are replaced with the
mathlib spelling `Fin.castLE`. Both substitutions are in let-bindings
inside proof bodies (statements unchanged):

- Exchangeability/Contractability.lean:470 — `contractable_of_exchangeable`
  call site: `let ι := fun i => ⟨i.val, Nat.lt_of_lt_of_le i.isLt hmn⟩`
  -> `let ι := Fin.castLE hmn`. Existing `simpa [ι]` and `simp [..., ι]`
  unfold the new RHS the same way; no other proof changes needed.

- Exchangeability/Util/FinsetHelpers.lean:32 — `filter_val_lt_card`:
  same substitution; the inline `hf_inj` proof collapses to
  `Fin.castLE_injective h`, and the `Finset.image` branch's `simp only [f]`
  steps simplify directly via `Fin.ext rfl` / `rintro ⟨j, rfl⟩`.

  (`Contractability.lean:408` was deliberately left alone — that `let` is
  inside a lemma statement, not the proof body, and the agreed scope is
  proof-body-only churn.)

README.md:51 was still claiming `lean-toolchain` was pinned to 4.27.0-rc1;
the v4.30.0-rc2 bump (#17) missed updating it. Rather than re-pin and
re-drift, point at the file itself:
"(see `lean-toolchain` for the pinned version)".
@cameronfreer cameronfreer merged commit 1ded130 into main May 18, 2026
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