Skip to content

Forward-port to Lean/mathlib v4.31.0 - #7

Closed
gotrevor wants to merge 4 commits into
v4.31-port-basefrom
forward-port-v4.31
Closed

Forward-port to Lean/mathlib v4.31.0#7
gotrevor wants to merge 4 commits into
v4.31-port-basefrom
forward-port-v4.31

Conversation

@gotrevor

@gotrevor gotrevor commented Jul 2, 2026

Copy link
Copy Markdown
Owner

Forward-ports FormalizedFormalLogic/Foundation from Lean/mathlib v4.29.0 → v4.31.0, on top of current upstream master (c089e7ab, which already includes FormalizedFormalLogic#794 FirstOrder redesign and FormalizedFormalLogic#829 ProvabilityLogic removal).

Authorship: this port was written by Claude (Anthropic's Claude Code), driven by @gotrevor. It is AI-generated work — please review accordingly.

Base: this PR targets v4.31-port-base, a branch pinned to the exact upstream-master commit c089e7ab, so the diff is only the port. master is left untouched.

What changed

  • Config bump: lean-toolchain, lakefile.toml (mathlib + doc-gen4 → v4.31.0), lake-manifest.json regenerated.
  • Foundation.lean: regenerated via lake exe mk_all --module (v4.31 module-system header).
  • Source changes to build green on v4.31.0 (recurring patterns below).

Verification

  • Builds green locally: 1730/1730 targets.
  • Audit vs the base commit: no files added/removed/renamed, no declaration dropped, no new axiom/sorry/admit. The only additions are 5 small proved helpers/compat-shims; several instances became def/lemma (same names) under v4.31's stricter instance checker.

Recurring change patterns

  • simpa … using esimpa … using! e — v4.31 tightened simpa's final match to reducible transparency; using! opts back into semireducible, so goals that hold only up to unfolding a semireducible def still close.
  • coe_injective'coe_injective (mathlib FunLike/SetLike field rename).
  • zero_le aArithmetic.zero_le a (mathlib's zero_le now shadows the protected lemma).
  • instancelemma/def where v4.31's instance checker rejects a non-typeclass return type or an uninferable hypothesis.
  • Function.comp_def added to simp sets; Nat.testBit / Nat.bitIndices API update in Proof/Coding.

Related work

  • Port to Lean 4.31 FormalizedFormalLogic/Foundation#828 by @lividgreen is a parallel v4.31 port (also AI-assisted). It was cut against master as of late June, and for the operator-eval lemmas it unfolds via explicit simp lemmas (e.g. Semiterm.Operator.val) rather than using!. Both approaches are valid; posting this as an alternative, not a replacement.

🤖 Generated with Claude Code

gotrevor and others added 4 commits July 2, 2026 20:43
Forward-ports the library from Lean/mathlib v4.29.0 to v4.31.0 on top of
current master (which already includes the FormalizedFormalLogic#794 FirstOrder redesign and the
FormalizedFormalLogic#829 ProvabilityLogic removal).

- Config bump: lean-toolchain, lakefile.toml (mathlib + doc-gen4 pinned to
  v4.31.0), lake-manifest.json regenerated.
- Source changes to build green on v4.31.0.

Whole library builds green (1730/1730 targets). No new proof holes: the
sorry/admit count is unchanged versus the base commit.

Recurring change patterns:
- `simpa … using X` -> `simpa … using! X` (v4.31 needs the defeq-close hatch
  where the elaborated term is defeq but not syntactically equal to the goal).
- `coe_injective'` -> `coe_injective` on mathlib FunLike/SetLike instance
  bodies (field renamed upstream).
- Bare `zero_le a` -> `Arithmetic.zero_le a` across the arithmetic tree
  (mathlib's `zero_le` now shadows the protected Foundation lemma).
- `instance` -> `lemma`/`def` where v4.31's stricter instance checker rejects
  a non-typeclass return type (`.Nonempty`, `.Countable`) or a hypothesis it
  cannot infer.
- `Function.comp_def` added to simp sets for `f ∘ v` vs pointwise mismatches.
- `Nat.testBit` / `Nat.bitIndices` API update in Proof/Coding.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@gotrevor

gotrevor commented Jul 2, 2026

Copy link
Copy Markdown
Owner Author

merged upstream: FormalizedFormalLogic#830

@gotrevor gotrevor closed this Jul 2, 2026
@gotrevor
gotrevor deleted the forward-port-v4.31 branch July 2, 2026 23:12
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