Repository navigation
fix: mathlib4, reference-manual breakage from nightly-2026-11-24 (lean4#16694) - #282
Merged
Merged
Conversation
lean4#16694 renamed `Nat.repeat`/`Nat.repeatTR` to
`Nat.iterate`/`Nat.iterateTR`, leaving deprecated `abbrev`s behind.
`{docstring Nat.repeat}` is an error (verso refuses to document a
deprecated name), and `simp [Nat.repeat]` in the `Day` range example
now unfolds the `abbrev` instead of supplying `Nat.iterate`'s
equations, so the `succMany?` lemmas and everything that depended on
them failed.
Rename both docstring blocks, the one prose reference, and the three
`simp`/`simp_all` sets. Semantics are unchanged: the definition only
moved from `Type u` to `Sort u`.
lean4#16694 renames `Nat.repeat` to `Nat.iterate` and generalizes it to
`Sort u`, which is where Mathlib's own `Nat.iterate` — the denotation of
`f^[n]` — used to live. The name now clashes (`'Nat.iterate' has already
been declared`), so the definition goes; but the two differ in which end
the step is applied to:
mathlib: iterate f (n+1) a = iterate f n (f a) -- `f^[n+1] = f^[n] ∘ f`
core: iterate f (n+1) a = f (iterate f n a) -- `f^[n+1] = f ∘ f^[n]`
So `Function.iterate_succ`/`iterate_succ_apply` are no longer `rfl` and
`iterate_succ'`/`iterate_succ_apply'` now are; the file swaps the two.
Everything else follows from that one flip, in 28 further files:
* `X.iterate` lemmas built as `Nat.recOn n id fun _ ih ↦ ih.comp h` need
`h.comp ih` — 14 of them (`Injective`, `Surjective`, `Monotone`,
`StrictMono`, `MapsTo`, `InjOn`, `SurjOn`, `BijOn`, `Continuous`,
`ContinuousAt`, `ContinuousOn`, `Differentiable`, `DifferentiableOn`,
`LipschitzWith`, `Measurable`, `MeasurePreserving`,
`QuasiMeasurePreserving`, `LeftOrdContinuous`, `Semiconj`,
`Semiconj₂`, `Tendsto`). Where the composite's data also flips, the
companion argument comes along: `MapsTo.iterate` for `InjOn`/
`DifferentiableOn`/`ContinuousOn`, `iterate_fixed` for `ContinuousAt`,
`pow_succ'` for `LipschitzWith`'s constant.
* Proofs that were `rfl` only through the old unfolding get
`Function.iterate_succ_apply` (`Iterate.rec`, `agmSequences_succ`,
`iteratedDerivWithin_succ'`, `PerfectClosure.mk_eq_iff`,
`eq_iterate_verschiebung`, `Int.sign`-induction in `Imo2006Q5`,
`iterated_kk`, `List.iterate_add`, `birkhoffSum_succ_apply'`).
* `iterate_succ` was a *dsimp* lemma while it was `rfl`; three `dsimp`
calls that relied on that now name the lemma they need, and two
now-dead `rw`/`simp only [iterate_succ_apply']` cleanups in
`Imo2006Q5` go away — they would fail `--wfail` as unused tactics.
* `Mathlib/Tactic/Core.lean` uses the deprecated `Nat.repeat` via dot
notation.
Verified on `master@origin` 3e38a16 with the open #273 and #279
applied: `lake build Mathlib Archive Counterexamples Wanted cache
--wfail` (18661 jobs, no warnings), `lake test --iofail` and `lake lint`
all green.
Contributor
Author
Build report for fix: mathlib4 breakage from nightly-2026-11-24 (lean4#16694)Stayed red
Stayed green
|
mhuisi
added a commit
that referenced
this pull request
Nov 26, 2026
Fixes the `import-graph` breakage from nightly-2026-11-24 (lean4#15218). Needs a toolchain that contains lean4#16718, that is nightly-2026-11-25 or later. ## `import-graph` — `Lean.SourceInfo.getLeading?` was declared twice lean4#15218 added the core formatter. Its module `Lean.Fmt.Util.Basic` declared `Lean.SourceInfo.getLeading?` with the same signature as `ImportGraph.Lean.Syntax`. Every module that imports both failed: ``` ImportGraphTest.lean:1:0: import Lean.Fmt.Util.Basic failed, environment already contains 'Lean.SourceInfo.getLeading?' from ImportGraph.Lean.Syntax ``` lean4#16718 removed `Lean.Fmt.Util.Basic` and moved `Lean.SourceInfo.getLeading?` into `Init.Prelude`. This PR deletes the duplicate definition in `ImportGraph.Lean.Syntax`, and `SourceInfo.getLeading` uses the core function. import-graph does not import a formatter module. The `#min_imports` fixtures use `SourceInfo.getLeading`, which stays in import-graph. Their expected output does not change. ### Merge order - With nightly-2026-11-24, this PR does not compile, because `Lean.Syntax` does not give `getLeading?` on that nightly. - With nightly-2026-11-25 or later, master does not compile without this PR: `ImportGraph.Lean.Syntax` fails with "`Lean.SourceInfo.getLeading?` has already been declared". Thus merge this PR together with the bump to nightly-2026-11-25. #282 needs this PR for a green `import-graph`. ### Verified `ImportGraph.Lean.Syntax` compiles against a lean4 build that contains lean4#16718. `lake build` and `lake test` of import-graph did not run yet. CI runs them after the bump. <!-- downstream-watch: unattended --> --------- Co-authored-by: downstream-lean4[bot] <downstream-lean4[bot]@users.noreply.github.com> Co-authored-by: mhuisi <[email protected]>
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.
2 of 2 for run 45376637887, with #281 — and master additionally needs the still-open #268, #273, #275 and #279. Verified together; on its own this PR's CI stays red on
import-graphuntil #281 merges.lean4#16694 renames
Nat.repeattoNat.iterateand generalizes it toSort u, leaving deprecatedabbrevs behind. Both repos here are hit by it, for different reasons.mathlib4—f^[n]unfolds the other way round nowNat.iterateis also the name of Mathlib's own definition, the denotation off^[n], so it is now'Nat.iterate' has already been declaredand the definition has to go. But the PR's description — "this effectively upstreamsNat.iteratefrom mathlib" — understates one thing: the two definitions apply the step at opposite ends.The question for @Rob23oba: was flipping the recursion deliberate? If core's
Nat.iteratematched the definition it replaces, the wholemathlib4half of this PR — 29 files — would be unnecessary, and the statements ofiterate_succ/iterate_succ'would keep their current roles. Nothing below is a fix for a bug; it is all bookkeeping that follows from that one flip. Happy to drop it if the direction changes upstream instead.What the flip costs, in
Mathlib/Logic/Function/Iterate.leanfirst:iterate_succ/iterate_succ_applyare no longerrfl(they get a one-line induction) anditerate_succ'/iterate_succ_apply'now are, so the two swap proofs. Then, in 28 further files:X.iterateproved asNat.recOn n id fun _ ih ↦ ih.comp hnow needsh.comp ih:Injective,Surjective,Monotone,StrictMono,MapsTo,InjOn,SurjOn,BijOn,Continuous,ContinuousAt,ContinuousOn,Differentiable,DifferentiableOn,LipschitzWith,Measurable,MeasurePreserving,QuasiMeasurePreserving,LeftOrdContinuous(and its@[to_dual]twin),Semiconj,Semiconj₂,Tendsto. Where the composite carries extra data, its companion comes along too —MapsTo.iterateforInjOn/DifferentiableOn/ContinuousOn,iterate_fixedforContinuousAt,pow_succ'instead ofpow_succforLipschitzWith's constant.rflonly through the old unfolding now nameFunction.iterate_succ_apply:Iterate.rec,agmSequences_succand two of its inductions,iteratedDerivWithin_succ',PerfectClosure.mk_eq_iff,eq_iterate_verschiebung,iterated_kk,List.iterate_add,birkhoffSum_succ_apply',Equiv.Perm.pow_aux, theInt.signinduction inImo2006Q5,SetRel.subset_iterate_comp,supportsStmt_move,le_invariants_iterate,Lie.trivial_iff_lower_central_eq_bot, andPicardLindelof.dist_iterate_iterate_next_le_of_lipschitzWith(where therwthat used to line the goal up now has to go).iterate_succwas adsimplemma while it wasrfl. Threedsimpcalls relied on that silently and now name the lemma they want; tworw/simp only [iterate_succ_apply']cleanups inImo2006Q5became dead and would fail--wfailas unused tactics.Mathlib/Tactic/Core.leanreaches the deprecatedNat.repeatthrough dot notation ((n - pats.size).repeat …), which--wfailmakes fatal.Worth knowing when this recurs: the wave is visible only one layer at a time, because a failing module hides everything that imports it. The run's report named three modules; it took eleven full builds to reach the end of the list.
reference-manual— two deprecated names and asimpset{docstring Nat.repeat}and{docstring Nat.repeatTR}inManual/BasicTypes/Nat.leanare errors, since verso refuses to document a deprecated name. InManual/BasicTypes/Range.lean,simp [Std.PRange.succMany?, Nat.repeat]now unfolds theabbrevinstead of supplyingNat.iterate's equations, so the chapter's twosuccMany?lemmas and theDayinstance built on them failed, and the three#evalblocks below them reported the resultingsorry. Renaming the two docstring blocks, one prose reference and threesimp/simp_allsets is the whole change; the definition's semantics are unchanged.Verified
On
master@origin3e38a16 (nightly-2026-11-24), with the open #273 and #279 (mathlib4) and #268 and #275 (reference-manual) applied locally:mathlib4:lake build Mathlib Archive Counterexamples Wanted cache --wfail— 18661 jobs, no warnings;lake test --iofail;lake lint. All green.reference-manual:lake buildgreen (it defines no test or lint driver). Built against elan v4.4.0, so theelanHelpblocks match what CI installs.repl, whose test phase recompiles this Mathlib, is green unchanged:lake buildandlake test.