Skip to content

fix: import-graph breakage from nightly-2026-11-24 (lean4#15218) - #281

Merged
mhuisi merged 2 commits into
masterfrom
push-urpwrxowwonk
Nov 26, 2026
Merged

mhuisi merged 2 commits into
masterfrom
push-urpwrxowwonk

Conversation

@downstream-lean4

@downstream-lean4 downstream-lean4 Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

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-lean4
downstream-lean4 Bot requested a review from mhuisi November 24, 2026 11:39
TwoFX pushed a commit that referenced this pull request Nov 24, 2026
…n4#16694) (#282)

2 of 2 for [run
45376637887](https://github.com/leanprover/downstream-lean4/actions/runs/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-graph` until #281 merges.

lean4#16694 renames `Nat.repeat` to `Nat.iterate` and generalizes it to
`Sort u`, leaving deprecated `abbrev`s behind. Both repos here are hit
by it, for different reasons.

## `mathlib4` — `f^[n]` unfolds the other way round now

`Nat.iterate` is also the name of Mathlib's own definition, the
denotation of `f^[n]`, so it is now `'Nat.iterate' has already been
declared` and the definition has to go. But the PR's description — "this
effectively upstreams `Nat.iterate` from mathlib" — understates one
thing: the two definitions apply the step at opposite ends.

```
mathlib:  iterate f (n+1) a = iterate f n (f a)   -- `f^[n+1] = f^[n] ∘ f` by rfl
core:     iterate f (n+1) a = f (iterate f n a)   -- `f^[n+1] = f ∘ f^[n]` by rfl
```

**The question for @Rob23oba:** was flipping the recursion deliberate?
If core's `Nat.iterate` matched the definition it replaces, the whole
`mathlib4` half of this PR — 29 files — would be unnecessary, and the
statements of `iterate_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.lean` first:
`iterate_succ`/`iterate_succ_apply` are no longer `rfl` (they get a
one-line induction) and `iterate_succ'`/`iterate_succ_apply'` now are,
so the two swap proofs. Then, in 28 further files:

* **Composition order (19 lemmas).** `X.iterate` proved as `Nat.recOn n
id fun _ ih ↦ ih.comp h` now needs `h.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.iterate` for
`InjOn`/`DifferentiableOn`/`ContinuousOn`, `iterate_fixed` for
`ContinuousAt`, `pow_succ'` instead of `pow_succ` for `LipschitzWith`'s
constant.
* **Proofs that were `rfl` only through the old unfolding** now name
`Function.iterate_succ_apply`: `Iterate.rec`, `agmSequences_succ` and
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`, the
`Int.sign` induction in `Imo2006Q5`, `SetRel.subset_iterate_comp`,
`supportsStmt_move`, `le_invariants_iterate`,
`Lie.trivial_iff_lower_central_eq_bot`, and
`PicardLindelof.dist_iterate_iterate_next_le_of_lipschitzWith` (where
the `rw` that used to line the goal up now has to go).
* **`iterate_succ` was a `dsimp` lemma while it was `rfl`.** Three
`dsimp` calls relied on that silently and now name the lemma they want;
two `rw`/`simp only [iterate_succ_apply']` cleanups in `Imo2006Q5`
became dead and would fail `--wfail` as unused tactics.
* `Mathlib/Tactic/Core.lean` reaches the deprecated `Nat.repeat` through
dot notation (`(n - pats.size).repeat …`), which `--wfail` makes 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 a `simp` set

`{docstring Nat.repeat}` and `{docstring Nat.repeatTR}` in
`Manual/BasicTypes/Nat.lean` are errors, since verso refuses to document
a deprecated name. In `Manual/BasicTypes/Range.lean`, `simp
[Std.PRange.succMany?, Nat.repeat]` now unfolds the `abbrev` instead of
supplying `Nat.iterate`'s equations, so the chapter's two `succMany?`
lemmas and the `Day` instance built on them failed, and the three
`#eval` blocks below them reported the resulting `sorry`. Renaming the
two docstring blocks, one prose reference and three `simp`/`simp_all`
sets is the whole change; the definition's semantics are unchanged.

## Verified

On `master@origin` 3e38a16 (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 build` green (it defines no test or lint
driver). Built against elan v4.4.0, so the `elanHelp` blocks match what
CI installs.
* `repl`, whose test phase recompiles this Mathlib, is green unchanged:
`lake build` and `lake test`.

<!-- downstream-watch: unattended -->

---------

Co-authored-by: downstream-lean4[bot] <downstream-lean4[bot]@users.noreply.github.com>
david-christiansen pushed a commit that referenced this pull request Nov 25, 2026
…4#16627) (#283)

Fix for the `reference-manual` half of [run
45592905939](https://github.com/leanprover/downstream-lean4/actions/runs/45592905939)
(`nightly-2026-11-24`). One commit. The rest of the red set is either
carried by PRs that are already open or cannot be fixed on this nightly
at all — see "Rest of the red set" below.

## `reference-manual` — stale `maxTraceChildren` adaptation

`extended-examples/IndexMapGrind.lean` pins the `grind` diagnostics of
the `eraseSwap` example in a `#check_msgs` docstring. lean4#16627 made
`MessageData.format` respect `maxTraceChildren`, so that output grew two
`N more entries... (increase maxTraceChildren to see more)` lines.

Both sides then adapted, in opposite directions:

* downstream, #274 put `set_option maxTraceChildren 0 in` above the
block, so the full trace is printed again and the old expectation still
matches;
* upstream,
[leanprover/reference-manual#1008](leanprover/reference-manual#1008)
(in `nightly-testing` as `226acc32c`) regenerated the expected output
*with* the two truncation lines.

`downstream: update repo reference-manual` (3d92f74) merged the second
one in. The two changes touch different lines, so there was no conflict
and both survived — and the `set_option` suppresses exactly the
truncation the new expectation requires. `IndexMapGrind` failed with

```
error: extended-examples/IndexMapGrind.lean:637:0: ❌️ Docstring on `#check_msgs` does not match generated message:
```

and `Tutorial.Grind.IndexMap`, which builds `IndexMapGrind` as a nested
project to resolve its anchors, failed behind it at 76 sites with `Build
process failed.`.

**Fix:** delete the now-stale `set_option`. The file is byte-identical
to upstream `226acc32c` again.

**Verified:** `lake build` green, 1680/1680 jobs, with `IndexMapGrind`
and `Tutorial.Grind.IndexMap` genuinely recompiled rather than replayed.
`reference-manual` defines no test or lint driver (`lake check-test` and
`lake check-lint` both exit 1), so `build` is its full set of phases.
Built with elan v4.4.0 first on `PATH`, matching CI, because the manual
pins `elan --help` output.

## Superseded PRs closed

The same `reference-manual` update rewrote `Manual/VCGen.lean`,
`Tutorial/VCGen.lean` and `Manual/NotationsMacros/DoElab.lean` upstream,
which makes #268 (lean4#16557, lean4#16569) and #275 (lean4#16451)
unnecessary: all three modules compiled green in the verification build
without them, and both PRs had become `CONFLICTING` against `master`.
Closed as superseded.

## Rest of the red set, not in this PR

Verified on `3d92f744` with the open #273 and #279 applied locally:

* **`mathlib4` build — green.** `lake build Mathlib Archive
Counterexamples Wanted cache --wfail`: 18661 jobs, 0 warnings.
`Mathlib.Data.Int.Init` (`lia`, lean4#16668) was fixed by #273's hunk;
master has since taken a different fix for that one file directly
(`d9ac508c`, `congr 1; lia` instead of `congrArg motive`), so #273 will
need its `Data/Int/Init.lean` hunk dropped, but its other 27 files are
still the next `lia` layers. `Pentagonal.Ring` (lean4#16680) is fixed by
#279.
* **`mathlib4` test and lint — still red, and not fixable on this
nightly.** Once the build is unblocked, both phases hit the clash that
also keeps `import-graph` red: `environment already contains
'Lean.SourceInfo.getLeading?' from ImportGraph.Lean.Syntax`. 22
`MathlibTest` modules fail on it, and `batteries/runLinter` dies with
the same message as an `uncaught exception`, so `lake lint` never runs a
linter at all. CI has never reached these phases, because the `mathlib4`
build failed first.
* **`repl` — also this clash, not the `lia` cascade.** Its `test` phase
fails at `test/Mathlib/test/H20231020`, and it still fails with Mathlib
fully built: the REPL reports no error for `import Mathlib.…` but hands
back an environment with none of Mathlib's contents, so the following
`open BigOperators`/`Real`/`Nat`/`Topology` all fail with `unknown
namespace`. A plain `lake env lean` on a one-line `import
Mathlib.Basic.Real.Basic` in that project shows what the REPL swallows:
`import Lean.Fmt.Util.Basic failed, environment already contains
'Lean.SourceInfo.getLeading?'`. So the duplicate breaks *every
non-module consumer* of Mathlib, not only `ImportGraphTest` — Mathlib's
own module-system build does not see `ImportGraph`'s private imports,
but a non-module importer does.
* **`import-graph`** — `ImportGraphTest` fails with the same clash. #281
fixes it by deleting the duplicate and using the core declaration that
lean4#16718 moved into `Init.Prelude`; that needs `nightly-2026-11-25`
or later, so #281 is deliberately red on the current nightly (its own
run 45411679303 fails `ImportGraph.Lean.Syntax` with `Invalid field
getLeading?`). Nothing here changes that and no competing fix is
proposed — this is the PR author's own call.
* **`cslib`** — skipped behind `mathlib4`, left to its own bot.

So merging this PR, #273 and #279 does *not* turn `master` green:
`mathlib4`'s test and lint phases, `import-graph` and `repl` all need
the `nightly-2026-11-25` bump together with #281.

<!-- downstream-watch: unattended -->

Co-authored-by: downstream-lean4[bot] <downstream-lean4[bot]@users.noreply.github.com>
downstream-lean4 Bot and others added 2 commits November 26, 2026 00:14
The new core formatter (lean4#15218) ships
`Lean.SourceInfo.getLeading?` in `Lean.Fmt.Util.Basic`, which
`ImportGraph.Lean.Syntax` also declared. Each module still compiles on
its own, but as soon as both land in one environment the import fails
with `environment already contains 'Lean.SourceInfo.getLeading?'` —
which is what `ImportGraphTest`, importing every test module, hit.

Drop the duplicate and inline its one-line body into
`SourceInfo.getLeading`, rather than importing `Lean.Fmt.Util.Basic`
here: that module also carries `Ord`/`Hashable` instances and a
`MonadLift Option (OptionT m)` that would become visible to everything
downstream of `ImportGraph`, Mathlib included.
lean4#16718 moved `Lean.SourceInfo.getLeading?` into `Init.Prelude`. Delete the duplicate definition in `ImportGraph.Lean.Syntax` and let `SourceInfo.getLeading` use the core function again, instead of an inlined `match`. This needs a toolchain that contains lean4#16718 (nightly-2026-11-25 or later).
@downstream-lean4

Copy link
Copy Markdown
Contributor Author

Build report for fix: use the core SourceInfo.getLeading? in import-graph

Turned green:

Repo Critical Build Test Lint
import-graph ✅ ✅ in 4s ✅ in 4s ⏭️
Stayed red
Repo Critical Build Test Lint
mathlib4 ✅ 🟥 in 10m 45s ⏭️ ⏭️
cslib 🛑 by mathlib4 ⏭️ ⏭️
repl ✅ in 0s 🟥 in 3m 31s ⏭️
Stayed green
Repo Critical Build Test Lint
aesop ✅ ✅ in 0s ✅ in 4s ⏭️
batteries ✅ ✅ in 0s ✅ in 3s ✅ in 1s
lean4-cli ✅ ✅ in 0s ✅ in 0s ⏭️
plausible ✅ ✅ in 0s ✅ in 2s ⏭️
ProofWidgets4 ✅ ✅ in 1s ✅ in 1s ⏭️
quote4 ✅ ✅ in 0s ✅ in 1s ⏭️
reference-manual ✅ ✅ in 2s ⏭️ ⏭️
BibtexQuery ✅ in 1s ⏭️ ⏭️
doc-gen4 ✅ in 1s ⏭️ ⏭️
illuminate ✅ in 0s ✅ in 9s ⏭️
lean4-unicode-basic ✅ in 1s ⏭️ ⏭️
lean4export ✅ in 0s ✅ in 5s ⏭️
LeanSearchClient ✅ in 0s ✅ in 0s ⏭️
leansqlite ✅ in 3s ✅ in 16s ⏭️
nerodia ✅ in 0s ✅ in 23s ⏭️
verso ✅ in 17s ✅ in 3m 43s ⏭️
verso-slides ✅ in 4s ✅ in 9s ⏭️
verso-web-components ✅ in 0s ⏭️ ⏭️

View run

@mhuisi
mhuisi merged commit 2b1ffef into master Nov 26, 2026
20 of 24 checks passed
Kha pushed a commit that referenced this pull request Nov 26, 2026
Replaces #273, which went `CONFLICTING` on `Mathlib/Data/Int/Init.lean`.
That file was fixed straight on `master` as `d9ac508c` by `Rob23oba` —
the same two `cast` goals, spelled `cast (by congr 1; lia)` where #273's
first commit had `cast (congrArg motive (by lia))`. This PR is #273's
**second** commit, unchanged, rebased onto `d9ac508c`: the remaining 54
`lia` sites in 27 modules. #273 carried nothing else and is now closed.

To turn `master` green this also needs the still-open #279 (`mathlib4`,
lean4#16680) and #283 (`reference-manual`), plus the
`nightly-2026-11-25` bump together with #281 (`import-graph`) — see
**Verified** below.

### `mathlib4` — lean4#16668 (`leodemoura`)

lean4#16668 makes `lia` skip facts that are irrelevant to linear integer
arithmetic, and the negated goal is filtered along with them: an
`Eq`/`Ne` whose relation type is not one `lia` treats as arithmetic is
relevant to no active solver, so it is dropped before the arithmetic
hypotheses are ever consulted. 54 sites in 27 modules lost their proof
that way — type equalities behind `eqToHom`, `Finset` memberships,
`ENNReal` disequalities, a `Prod` equality.

`lia -filterFacts` processes all facts again, which is the escape hatch
the change ships and what its author suggested for these sites. Three of
them sat under `try`/`any_goals`, where the failure was silent and
surfaced as unsolved goals further down.

[Run
45598923234](https://github.com/leanprover/downstream-lean4/actions/runs/45598923234)
is the first to get past `Mathlib.Data.Int.Init`, so it is also the
first that shows this whole layer. Part of what it reports needs no
change of its own: `Counterexamples/AharoniKorman.lean:757`/`758` call
`mem_sdiff` an `Ambiguous term` only while the `lia` above them fails,
and the `unknown metavariable` / `(kernel) declaration has
metavariables` errors in `HasSpectralSequence`, `CochainComplex` and
`CommShiftTwo` are those files' own sorried `lia` goals reaching the
kernel. Both clear with the `-filterFacts` sites.

### Verified

On `nightly-2026-11-24`, with #279 applied:

- `lake build --wfail Mathlib Archive Counterexamples Wanted cache` —
green, 18661 jobs, 0 warnings
- `lake test --iofail` — green
- `lake lint` — green

`test` and `lint` only run at all once the `Lean.SourceInfo.getLeading?`
duplicate is gone, which is #281. On this nightly that means the
inlined-`match` form #281 carried before `mhuisi` replaced it with
core's `getLeading?` for `nightly-2026-11-25`; that form was applied
locally for these two phases, and is no part of this PR.

<!-- downstream-watch: unattended -->

Co-authored-by: downstream-lean4[bot] <downstream-lean4[bot]@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant