Skip to content

fix: batteries and mathlib4 breakage from the upstream batteries shake - #133

Closed
downstream-lean4[bot] wants to merge 2 commits into
masterfrom
push-quylzryvoutx
Closed

downstream-lean4[bot] wants to merge 2 commits into
masterfrom
push-quylzryvoutx

Conversation

@downstream-lean4

Copy link
Copy Markdown
Contributor

master is red in run 37324507057 on nightly-2026-10-05: batteries fails to build, aesop, mathlib4 and cslib are skipped behind it, and repl's test phase compiles both and fails. The nightly is not to blame — run 37298300152 was green on the same toolchain three hours earlier. The one commit in between is downstream: update repo batteries, which merged batteries' main into nightly-testing and so brought in chore: shake (batteries#2005), a repo-wide import minimization computed on the v4.35.0-rc3 toolchain.

batteries — Trie.asNode is in Lean.Meta.DiscrTree.Util, not .Types

shake replaced public import Lean.Meta.DiscrTree by public import Lean.Meta.DiscrTree.Types in Batteries/Lean/Meta/DiscrTree.lean. That is correct on main, where Trie.mergePreservingDuplicates pattern-matches the node constructor directly. It is not correct on nightly-testing, which carries the adaptation to lean4#14805's new Trie.chain constructor and therefore goes through Trie.asNode / Trie.mkNode — and those live in Lean.Meta.DiscrTree.Util. The merge combined main's import line with nightly-testing's body, so the module fails with

Invalid field `asNode`: The environment does not contain `Lean.Meta.DiscrTree.Trie.asNode`
Unknown constant `Lean.Meta.DiscrTree.Trie.mkNode`

Fixed by importing Lean.Meta.DiscrTree.Util, which publicly imports .Basic and hence .Types, so Key, Trie and DiscrTree stay in scope. Batteries' own nightly-testing build is red the same way, so this hunk will most likely be superseded by their adaptation at the next downstream: update repo batteries.

mathlib4 — transitive re-exports from batteries are gone

The same shake demoted public import to import throughout batteries, which removes re-exports Mathlib was relying on. CI never saw this: it stopped at batteries.

  • Batteries.Logic now imports Batteries.Tactic.Alias privately and Batteries.Data.Nat.Lemmas not at all, so the alias command is no longer in scope in Mathlib.Data.Nat.Init, Mathlib.Data.Int.Init, Mathlib.Basic.Logic.Basic and Mathlib.Basic.Logic.Lemmas. Every alias in those files turns into unexpected identifier; expected command, which takes em, dec_em, Iff.not, HEq.eq and the rest of what they declare with it. Each of the four now imports Batteries.Tactic.Alias itself.
  • Counterexamples.ZeroDivisorsInAddMonoidAlgebras lost Batteries.Tactic.OpenPrivate, which is where instance : DecidableEq ModuleIdx := instDecidableEqNat lives. Its local guard_decl elaborator compares two ModuleIdx, and ModuleIdx is a plain def, so without that instance nothing solves Decidable (dcli = mdni) and the elaborator is never implemented. Imported directly, as the error message suggests.

This half is not nightly-specific: upstream mathlib will meet it at its next batteries bump.

Verified locally on nightly-2026-10-05

repo result
batteries lake build --wfail ✔, lake test ✔, lake lint ✔
aesop lake build --wfail ✔, lake test ✔ (no change needed)
mathlib4 lake build --wfail Mathlib Archive Counterexamples Wanted cache ✔, lake test --iofail ✔, lake lint ✔
cslib lake build --wfail --iofail ✔, lake test --wfail --iofail ✔, lake lint ✔ (no change needed)
repl lake build ✔, lake test ✔ (no change needed)

Not covered here: verso-slides, which has been red since before this run for an unrelated reason and is fixed by #126.

downstream-lean4 Bot and others added 2 commits October 5, 2026 16:21
`chore: shake` (leanprover-community/batteries#2005), merged into
`nightly-testing` by the last `downstream: update repo batteries`, replaced
`public import Lean.Meta.DiscrTree` with `public import Lean.Meta.DiscrTree.Types`
in `Batteries/Lean/Meta/DiscrTree.lean`. `Trie.asNode` and `Trie.mkNode` live in
`Lean.Meta.DiscrTree.Util`, not in `.Types`, so `Trie.mergePreservingDuplicates`
stopped elaborating.

Import `Lean.Meta.DiscrTree.Util` instead; it publicly imports `.Basic`, which
publicly imports `.Types`, so the `Key`/`Trie`/`DiscrTree` types stay available.

Co-Authored-By: Claude Opus 5 <[email protected]>
The same `chore: shake` (leanprover-community/batteries#2005) that broke
`batteries` itself also demoted `public import` to `import` across the library,
so transitive re-exports Mathlib relied on are gone:

* `Batteries.Logic` and `Batteries.Data.Nat.Lemmas` no longer re-export
  `Batteries.Tactic.Alias`, so every `alias` command in `Mathlib.Data.Nat.Init`,
  `Mathlib.Data.Int.Init`, `Mathlib.Basic.Logic.Basic` and
  `Mathlib.Basic.Logic.Lemmas` stopped parsing (`unexpected identifier; expected
  command`), taking `em`, `dec_em`, `Iff.not` and the rest down with them.
  Each of the four files now imports `Batteries.Tactic.Alias` itself.
* `Counterexamples.ZeroDivisorsInAddMonoidAlgebras` lost
  `Batteries.Tactic.OpenPrivate`, whose `instance : DecidableEq ModuleIdx` its
  `guard_decl` elaborator needs; `ModuleIdx` is a plain `def`, so nothing else
  supplies the instance. Imported directly, as the error message suggests.

Verified: `lake build --wfail Mathlib Archive Counterexamples Wanted cache`,
`lake test --iofail` and `lake lint` all pass.

Co-Authored-By: Claude Opus 5 <[email protected]>
@downstream-lean4

Copy link
Copy Markdown
Contributor Author

Build report for fix: mathlib4 breakage from the upstream batteries shake

Turned green:

Repo Critical Build Test Lint
aesop ✅ ✅ in 11s ✅ in 4s ⏭️
batteries ✅ ✅ in 1s ✅ in 4s ✅ in 2s
mathlib4 ✅ ✅ in 16m 18s ✅ in 41s ✅ in 1m 30s
cslib ✅ in 30s ✅ in 9s ✅ in 3s
repl ✅ in 0s ✅ in 52s ⏭️
Stayed red
Repo Critical Build Test Lint
verso-slides 🟥 in 27s ⏭️ ⏭️
Stayed green
Repo Critical Build Test Lint
import-graph ✅ ✅ in 2s ✅ in 4s ⏭️
lean4-cli ✅ ✅ in 0s ✅ in 0s ⏭️
plausible ✅ ✅ in 0s ✅ in 2s ⏭️
ProofWidgets4 ✅ ✅ in 1s ✅ in 1s ⏭️
quote4 ✅ ✅ in 0s ✅ in 1s ⏭️
reference-manual ✅ ✅ in 11s ⏭️ ⏭️
BibtexQuery ✅ in 1s ⏭️ ⏭️
comparator ✅ in 2s ⏭️ ⏭️
doc-gen4 ✅ in 4s ⏭️ ⏭️
illuminate ✅ in 1s ✅ in 10s ⏭️
lean4-unicode-basic ✅ in 0s ⏭️ ⏭️
lean4export ✅ in 0s ✅ in 8s ⏭️
LeanSearchClient ✅ in 0s ✅ in 0s ⏭️
leansqlite ✅ in 3s ✅ in 21s ⏭️
nerodia ✅ in 1s ✅ in 22s ⏭️
verso ✅ in 16s ✅ in 2m 59s ⏭️
verso-web-components ✅ in 25s ⏭️ ⏭️

View run

@downstream-lean4

Copy link
Copy Markdown
Contributor Author

Superseded by #134. downstream: update repo mathlib4 turned this PR CONFLICTING: upstream mathlib resolved the five mathlib4 hunks here by itself — the three Batteries.Tactic.Alias imports are now in those files upstream, and guard_decl compares module indices with == rather than =, so Batteries.Tactic.OpenPrivate is no longer needed. Only the one-line batteries DiscrTree hunk is still live; #134 carries it on top of current master, plus a cslib adaptation to mathlib4#42909 that was hidden behind the skip.

@downstream-lean4 downstream-lean4 Bot closed this Oct 6, 2026
@downstream-lean4
downstream-lean4 Bot deleted the push-quylzryvoutx branch October 6, 2026 03:29
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