Skip to content

fix: reference-manual breakage from nightly-2026-11-20 (lean4#16557, lean4#16569) - #268

Closed
downstream-lean4[bot] wants to merge 1 commit into
masterfrom
push-uxmqlxnvpnqn
Closed

downstream-lean4[bot] wants to merge 1 commit into
masterfrom
push-uxmqlxnvpnqn

Conversation

@downstream-lean4

Copy link
Copy Markdown
Contributor

Sole fix for run 44720445467 — reference-manual was the only red repo, and both causes are by the same author, so there is nothing to split.

reference-manual — do-elaborator chapter (lean4#16557)

lean4#16557 ("perf: memoize the control information of do sequences") moved Lean.Elab.Do.InferControlInfo.ofSeq and its siblings into the new InferControlInfo.InferM = ReaderT ControlInfoCache TermElabM. The three direct calls in Manual/NotationsMacros/DoElab.lean therefore no longer typecheck, and the knock-on effect is larger than the type errors: inferOnce/elabOnce failing to elaborate leaves @[doElem_control_info doOnce] unregistered, so the chapter's once and locally examples fail with elaboration function for 'doOnce' has not been implemented and No 'ControlInfo' inference handler found for 'doLocally', and two pinned leanOutput blocks mismatch.

The fix uses the public wrappers:

  • inferControlInfoSeq body in the two ControlInfoHandlers (inferOnce, inferLocally) — matching the openMutInfo handler further down the same chapter, which was already written this way;
  • inferControlInfoSeq body (← read).controlInfoCache in the DoElab elabOnce, which is what core's own do-element elaborators (BuiltinDo/For.lean, Repeat.lean, Forward.lean, …) do with the enclosing block's cache.

The prose already pointed readers at inferControlInfoSeq/inferControlInfoElem as the normal entry points, so no narrative change was needed here.

reference-manual — vcgen chapters (lean4#16569)

lean4#16569 ("feat: vcgen checks an early return in a loop against the code after the loop") deprecated Std.WP.Invariant.withEarlyReturnNewDo: the invariant of a loop with an early return now ranges over the loop's mutable variables only, and the early return is checked against the code that follows the loop instead of being threaded through the accumulator as Option γ × β.

  • Tutorial/VCGen.lean's nodup_correct now states the former onContinue half directly as the invariant, and the paragraph that explained the two-part invariant explains the new treatment instead.
  • Manual/VCGen.lean drops the {docstring Invariant.withEarlyReturnNewDo} block — documenting a deprecated name is a hard error in Verso — in favour of a sentence in the "Invariant Specifications" section on how early returns are handled.

Manual/MVCGen.lean and Tutorial/MVCGen.lean are untouched: they document the older Std.Do stack, whose Invariant.withEarlyReturnNewDo is not deprecated.

Verification

Full lake build of reference-manual green, 1668 jobs, with elan 4.4.0 first on PATH so the pinned elan --help blocks match CI. The repo defines no test or lint driver (lake check-test and lake check-lint both fail), so lake build is the whole phase set. The three edited modules really recompiled before the full build replayed them.

Nothing was left unfinished. No other repo was red or skipped in this run; cslib, mathlib4 and repl were all green.

Not adaptable upstream: leanprover/reference-manual's nightly-testing has not seen this nightly (its newest commit on either file is from 2026-11-06) and there is no open upstream PR touching them.

…lean4#16569)

lean4#16557 ("perf: memoize the control information of `do` sequences") moved
`Lean.Elab.Do.InferControlInfo.ofSeq` and its siblings into the new
`InferControlInfo.InferM = ReaderT ControlInfoCache TermElabM`, so the three
direct calls in the `do`-elaborator chapter no longer typecheck. Use the public
wrappers instead: `inferControlInfoSeq` in the two `ControlInfoHandler`s
(`inferOnce`, `inferLocally`), as the `openMutInfo` handler further down the
same chapter already does, and `inferControlInfoSeq body
(← read).controlInfoCache` in the `DoElab` `elabOnce`, which is what core's own
`do`-element elaborators do with the enclosing block's cache.

lean4#16569 ("feat: `vcgen` checks an early return in a loop against the code
after the loop") deprecated `Std.WP.Invariant.withEarlyReturnNewDo`: the
invariant of a loop with an early return now ranges over the loop's mutable
variables only, and `vcgen` checks the early return against the code that
follows the loop. `Tutorial/VCGen.lean`'s `nodup_correct` therefore states the
former `onContinue` half directly, and `Manual/VCGen.lean` drops the
`{docstring}` for the deprecated combinator — documenting a deprecated name is
a hard error in Verso — in favour of a sentence on how early returns are
handled. Both chapters' prose is updated to match.

Verified: full `lake build` of `reference-manual` green (1668 jobs), with elan
4.4.0 first on `PATH` for the pinned `elan --help` blocks; the repo defines no
test or lint driver.

Co-Authored-By: Claude Opus 5 <[email protected]>
@downstream-lean4
downstream-lean4 Bot requested a review from sgraf812 November 20, 2026 11:34
@downstream-lean4

Copy link
Copy Markdown
Contributor Author

Build report for fix: reference-manual breakage from nightly-2026-11-20 (lean4#16557, lean4#16569)

Turned green:

Repo Critical Build Test Lint
reference-manual ✅ ✅ in 59s ⏭️ ⏭️
Stayed green
Repo Critical Build Test Lint
aesop ✅ ✅ in 0s ✅ in 4s ⏭️
batteries ✅ ✅ in 0s ✅ in 3s ✅ in 1s
import-graph ✅ ✅ in 2s ✅ in 3s ⏭️
lean4-cli ✅ ✅ in 0s ✅ in 0s ⏭️
mathlib4 ✅ ✅ in 7s ✅ in 34s ✅ in 43s
plausible ✅ ✅ in 0s ✅ in 2s ⏭️
ProofWidgets4 ✅ ✅ in 0s ✅ in 0s ⏭️
quote4 ✅ ✅ in 0s ✅ in 1s ⏭️
BibtexQuery ✅ in 2s ⏭️ ⏭️
cslib ✅ in 1s ✅ in 10s ✅ in 2s
doc-gen4 ✅ in 5s ⏭️ ⏭️
illuminate ✅ in 0s ✅ in 9s ⏭️
lean4-unicode-basic ✅ in 3s ⏭️ ⏭️
lean4export ✅ in 0s ✅ in 5s ⏭️
LeanSearchClient ✅ in 0s ✅ in 0s ⏭️
leansqlite ✅ in 6s ✅ in 15s ⏭️
nerodia ✅ in 0s ✅ in 22s ⏭️
repl ✅ in 0s ✅ in 1m 49s ⏭️
verso ✅ in 1m 15s ✅ in 3m 8s ⏭️
verso-slides ✅ in 16s ✅ in 9s ⏭️
verso-web-components ✅ in 3s ⏭️ ⏭️

View run

Rob23oba pushed a commit that referenced this pull request Nov 21, 2026
…Do.Context.controlInfoCache` (#271)

Run
[44844350878](https://github.com/leanprover/downstream-lean4/actions/runs/44844350878)
on `nightly-2026-11-20`. This fixes the run's **new** breakage,
`batteries` (critical), which took `aesop`, `mathlib4` and `cslib` down
with it as skips. The rest of the red set is carried by PRs that are
already open — `reference-manual` by #268, and `mathlib4` + `repl` by
#270 (approved) — so **this PR's own CI stays red on
`reference-manual`** until those merge.

## `batteries` — `Do.Context` gained a field, and `#do` builds one by
hand

[lean4#16557](leanprover/lean4#16557) ("perf:
memoize the control information of `do` sequences", @sgraf812, in
`nightly-2026-11-20`) added a field with no default to
`Lean.Elab.Do.Context`:

```lean
  /-- The `ControlInfo` of the `doSeq` nodes of this `do` block inferred so far. -/
  controlInfoCache : ControlInfoCache
```

The `downstream: update repo batteries` merge at the head of this run
then brought in
[batteries#1962](leanprover-community/batteries#1962)
("feat: `#do` command", @Rob23oba), whose `elabDoCommandCore` assembles
a `Do.Context` itself rather than going through `Do.mkContext`. That
file was written against batteries `main`, which still pins
`v4.37.0-rc1`, so on the nightly it fails:

```
error: Batteries/Tactic/DoCommand.lean:213:15: Fields missing: `controlInfoCache`
```

`Batteries.Tactic.DoCommand` is reachable from the `Batteries` root
module, so this is a critical-repo build failure, and `aesop`,
`mathlib4` and `cslib` were all skipped behind it.

### The fix

One field, a fresh cache, exactly what core's own `Do.mkContext` writes:

```lean
      controlInfoCache := ← ControlInfoCache.new
```

A `ControlInfoCache` memoizes the inferred `ControlInfo` of the `doSeq`
nodes *within one `do` block*; `#do` elaborates one `doSeq` per
invocation, so there is nothing to carry across calls and no reason to
park a cache in `DoCommandExtensionState` next to the local context and
the `mut` variables.

Upstream batteries cannot see this yet: `nightly-testing` is on
`nightly-2026-11-20` and carries the same unadapted file
(byte-identical), and there is no batteries PR open that mentions
`controlInfoCache` or lean4#16557 — so the same fix is wanted there.

### Verified

* `batteries`: `lake build --wfail` (531 jobs), `lake test` (including
the new `BatteriesTest.do_command`) and `lake lint`.
* `aesop`: `lake build --wfail` and `lake test`, the two phases CI
skipped (no lint driver).
* `mathlib4`: `lake build Mathlib Archive Counterexamples Wanted cache
--wfail` (18647 jobs), `lake test --iofail` (19211 jobs) and `lake
lint`, with #270's `import-graph` fix applied locally, since `mathlib4`
does not parse without it.

`repl` was not rebuilt: it is noncritical, and the sites it failed at
are #270's. `cslib` is left to `mathlib-nightly-testing` as before.

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

Co-authored-by: downstream-lean4[bot] <downstream-lean4[bot]@users.noreply.github.com>
thorimur added a commit that referenced this pull request Nov 23, 2026
… the `all` token (#270)

Run
[44826859647](https://github.com/leanprover/downstream-lean4/actions/runs/44826859647)
on `nightly-2026-11-20`. This fixes the run's **new** breakage —
`mathlib4` (critical) and `repl`. `reference-manual` has been red since
run 44720445467 and is carried by the open #268, so **this PR's own CI
stays red on `reference-manual`** until that one merges. `cslib` was
only skipped behind `mathlib4` here; its own break is Mathlib-caused and
left to its bump bot.

## `import-graph` — `#import_diff`'s syntax reserved the `all` keyword


[importGraph#193](leanprover-community/import-graph#193)
(@thorimur) gave `#import_diff` a module-system-aware syntax that
mentions `Lean.Parser.Module.import`:

```lean
syntax diffAbsolute :=
  (&"from" ppLine sepByIndentSemicolon(Parser.Module.import))?
  &"to" ppLine sepByIndentSemicolon(Parser.Module.import)
```

A `syntax` declaration registers every token the parsers it mentions can
read, and `Lean.Parser.Module.import` can read `all` — core has `def
«all» := leading_parser (withAnonymousAntiquot := false) "all"` in
`Lean/Parser/Module/Syntax.lean`. Until now that token only ever reached
the builtin table used for the module header. `ImportGraph.Tools` is in
`Mathlib.Init`'s closure, so `all` became a reserved keyword in *every*
Mathlib module, where it is an ordinary identifier:

```
Mathlib/Algebra/Group/Commute/Defs.lean:105:17   -- protected theorem all
Mathlib/Util/GetAllModules.lean:43:9             -- let all ← walkDir ml
Mathlib/Util/CompileInductive.lean:44:16         -- def mkRecNames (all : List Name)
Mathlib/Data/Bool/AllAny.lean:27:31              -- (all l fun a => p a)
Mathlib/Tactic/Widget/SelectPanelUtils.lean:91:7 -- let all := …
Mathlib/Tactic/ClickSuggestions/SectionState.lean:102:9
```

all as `unexpected token 'all'; expected …`, plus the cascades behind
them (`Unknown identifier mkRecNames`, `elaboration function for
commandCompile_inductive% has not been implemented`). `repl`'s test
phase fails at the same sites, since it compiles Mathlib. Reducible
without any of this tree:

```lean
import Lean
open Lean Parser
syntax myDiff := Module.import
syntax (name := myCmd) "#my_diff " myDiff : command
def f (all : Nat) := all   -- unexpected token 'all'; expected '_' or identifier
```

### The fix

`ImportGraph.importStx` is a local copy of `Lean.Parser.Module.import`
that reads `all` with `nonReservedSymbol` instead of core's reserved
atom, and the three `#import_diff` syntax declarations use it.
`nonReservedSymbolInfo` registers no token, so nothing is reserved
downstream; it matches the identifier `all` and pushes the same atom, so
`#import_diff … import all M` keeps working. The syntax kind is still
``Lean.Parser.Module.import``, so the `` `(Parser.Module.import| …) ``
quotations in the same file and in `ImportGraph/Imports/Pretty.lean`
match unchanged, and `withAntiquot (mkAntiquot "import" …)` is what
`leading_parser` would have added — the `` `(diffCurrentItem| +$imp) ``
quotations need it.

`public` and `meta` are still registered by this syntax, exactly as
before: both were already reserved keywords, which is why only `all`
broke.

Two tests at the end of `ImportGraphTest/ImportDiff/Test.lean`: a `def`
with an `all` binder, which does not parse without the fix, and an
`#import_diff … import all`, whose table shows the `import all` row and
`ir loaded +1` — that branch had no test before.

The proper home for this is upstream `import-graph`; the same trap waits
for any tool that reuses core's module-header parsers from a command, so
a core-side `nonReservedSymbol` for `Module.all` may be the better
long-term answer.

### Verified

* `import-graph`: `lake build` (148 jobs) and `lake test` (189 jobs,
including `ImportGraphTest.ImportDiff.Test`).
* `mathlib4`: `lake build Mathlib Archive Counterexamples Wanted cache
--wfail` (18641 jobs — a full recompile, since the change invalidates
all of Mathlib's artifact cache; the six modules that failed in CI were
really `Built`), `lake test --iofail` (19205 jobs) and `lake lint`.
* `repl`: `lake build` and `lake test`, including the `test/Mathlib`
suite that CI failed in.

Nothing else was adapted: `reference-manual` is #268's, and `cslib` is
left to `mathlib-nightly-testing`.

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

---------

Co-authored-by: downstream-lean4[bot] <downstream-lean4[bot]@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <[email protected]>
Co-authored-by: Thomas R. Murrills <[email protected]>
TwoFX added a commit that referenced this pull request Nov 23, 2026
…274)

3 of 4 for [run
45055845730](https://github.com/leanprover/downstream-lean4/actions/runs/45055845730),
with #272, #273 and #275 — `reference-manual` goes green only with this
PR *and* #275 *and* the still-open #268, so on its own this PR's CI
stays red on `reference-manual` until those merge. Verified together.

### `reference-manual` — lean4#16627 (`TwoFX`)

lean4#16627 makes `MessageData.format` respect `maxTraceChildren`, so a
trace node with
more than 50 children now prints its first 50 followed by
`` N more entries... (increase `maxTraceChildren` to see more) ``. Two
nodes of the
`grind` diagnostics that the `#check_msgs` block in front of the first
`eraseSwap` pins
(`extended-examples/IndexMapGrind.lean`) have 86 and 119 entries, so the
block fails with

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

and the two truncation markers are the *only* difference in the diff —
everything else
still matches. `Tutorial.Grind.IndexMap` then fails too, because it
extracts anchors
from that module through a nested `lake build`.

Those diagnostics are the whole point of the example, so this lifts the
limit for the
one command (`maxTraceChildren 0` = no limit, which is how core's own
guard reads it)
rather than pinning a truncated list. The `set_option` sits outside
`-- ANCHOR: eraseSwap_init`, so the code the manual renders is
unchanged.

**Verified:** `lake build IndexMapGrind` green, and the repo's full
`lake build` is green
with the two commits of this round plus #268 applied (`lake test` and
`lake lint` report
no driver configured, so `build` is the whole phase set here).

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

---------

Co-authored-by: downstream-lean4[bot] <downstream-lean4[bot]@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <[email protected]>
Co-authored-by: Julia Markus Himmel <[email protected]>
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>
@downstream-lean4

Copy link
Copy Markdown
Contributor Author

Superseded: downstream: update repo reference-manual (3d92f74) brought in upstream's own rewrite of Manual/VCGen.lean, Tutorial/VCGen.lean and Manual/NotationsMacros/DoElab.lean (leanprover/reference-manual#1008). All three modules build green on master without this PR — verified locally in the 1680-job reference-manual build for #283 — and this PR had become CONFLICTING against the rewritten files. Closing; reopen if the breakage comes back.

@downstream-lean4 downstream-lean4 Bot closed this Nov 25, 2026
@downstream-lean4
downstream-lean4 Bot deleted the push-uxmqlxnvpnqn branch November 25, 2026 11:09
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>
Kha pushed a commit that referenced this pull request Nov 26, 2026
Sole fix for [run
45176665928](https://github.com/leanprover/downstream-lean4/actions/runs/45176665928)
— everything else that run reports red is already carried by open PRs:
`mathlib4` also needs #273 (lean4#16668) and the bot's #163
(`adaptation-13851`), and `reference-manual` needs #268 and #275. On its
own this PR's CI therefore stays red on `mathlib4` (at
`Mathlib.Data.Int.Init`, four thousand modules before the one fixed
here) and on `reference-manual`; that is expected, and it was verified
with all four applied. `repl` fails on the same `mathlib4` modules
rebuilt through `test/Mathlib`, and `cslib` was only ever skipped behind
`mathlib4`.

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

lean4#16680 makes `grind`'s *local* E-matching theorems — the ones built
from `∀`-hypotheses in the context — take their instances and anchors
from the **preprocessed** type of the hypothesis rather than from
whatever `mkOfEqTrueCore` handed back. In `Pentagonal.tprod_one_sub_pow`
(`Mathlib/Combinatorics/Enumerative/Pentagonal/Ring.lean`) the line
before the failure is exactly such a hypothesis:

```lean
have h1 (k : ℕ) : pentagonal (k + 1) = ((k + 1) * (3 * k + 2) / 2) := by grind [pentagonal_def]
have h2 (k : ℕ) : pentagonal (-k) = (k * (3 * k + 1) / 2) := by grind [pentagonal_neg]
```

and with `h1` in the context the second `grind` now exhausts `(instances
:= 1000)`, `(ematch := 5)` and `(ringSteps := 100000)`. The
declaration's heartbeats are gone with it, so the `rw` two lines further
down fails as `(deterministic) timeout` — two errors, one cause. The
module takes **315s** to fail, where the whole file used to elaborate in
well under a second.

`h1` is the whole trigger, not the theorem's five hypotheses and not `h`
above it:

* `clear h1` alone, before the `grind`, fixes it — the module is back to
**0.9s** for the entire file;
* `h1`'s own `grind` is fine with the full context, as long as `h2` has
not run yet;
* the same `h2` goal in a file with no context at all proves in 0.6s on
this nightly.

`h1` is only used by the `simp_rw` after both `have`s, so clearing it
inside `h2`'s proof costs nothing. An `#adaptation_note` records why,
because the interesting question is upstream: whether `grind` should be
300× slower because an unrelated equation about the same function sits
in the context is for lean4#16680's author to decide, and that is a
better outcome than `clear`ing hypotheses at every future site. Nothing
else in `mathlib4` moved on this nightly.

### Verification

On `master@origin` (`c2ff11e2`, `nightly-2026-11-23`) with #273 and
#163's three `mathlib4` hunks applied locally:

* `lake build Mathlib Archive Counterexamples Wanted cache --wfail` —
green, 18655 jobs (the previous build stopped at 18647/18655 on this
module, which also hid `Pentagonal.PowerSeries`,
`Pentagonal.EulerFunction` and `Mathlib` itself);
* `lake test --iofail` — green, 19219 jobs;
* `lake lint` — green.

`reference-manual` was verified in the same tree with #268 and #275
applied: full `lake build` green, 1668 jobs, with elan 4.4.0 first on
`PATH` so the pinned `elan --help` blocks match CI. It defines no test
or lint driver.

`repl`'s test phase was not rebuilt here — its failures are these same
`mathlib4` modules compiled through `test/Mathlib`.

One thing that is *not* fixed by anything, because it needs no fix:
`Tutorial.Grind.IndexMap` failed in this run with `permission denied
(error code: 13)` on `.lake/build/lib/lean/IndexMapGrind.ilean`. #274
changed `IndexMapGrind.lean`, so for one run no cached artifact existed,
and the parent `lake build` and the nested `lake build
+IndexMapGrind:highlighted` that `Tutorial/Grind/IndexMap.lean` spawns
both had to build the module — the parent won and replaced the output
with a read-only hardlink into the artifact cache. The artifact is in
the cache now, both sides replay it, and the module builds green
locally. It will recur for one run on every future change to that file.

<!-- 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.

0 participants