Skip to content

fix: mathlib4 breakage from the batteries on_goal change - #130

Merged
Kha merged 1 commit into
masterfrom
push-wtoqwpvpnrou
Oct 4, 2026
Merged

Kha merged 1 commit into
masterfrom
push-wtoqwpvpnrou

Conversation

@downstream-lean4

Copy link
Copy Markdown
Contributor

Run 37207955571
on nightly-2026-10-04 went red in mathlib4 (critical) and repl, with cslib
skipped behind mathlib4. The cause is not the nightly — it is the
downstream: update repo batteries merge 4cfce6c, which brought in
batteries#1990.

mathlib4

batteries#1990 lets on_goal act on several goals at once. It introduces

syntax goalNum := "-"? num

and replaces elab "on_goal " reverse:"-"? n:num " => " seq:tacticSeq with
elab "on_goal " ns:goalNum+ " => " seq:tacticSeq, and pick_goal likewise.
That breaks Mathlib in two independent ways.

1. The on_goal quotations in Mathlib.Tactic.ClickSuggestions.Util — $n₁ is now
a TSyntax goalNum where the code wants a NumLit, and the term-position quotation
wants a goalNum where Syntax.mkNatLit gives a NumLit. This is the only error CI
reported. The fix is the author's own adaptation,
mathlib4#44446, applied
verbatim: annotate the three antiquotations :num.

2. The syntax node kinds were renamed. The - used to be an atom of the tactic
syntax itself and is now part of goalNum, so the generated kinds change:

old new
Batteries.Tactic.«tacticOn_goal-_=>_» Batteries.Tactic.«tacticOn_goal_=>_»
Batteries.Tactic.«tacticPick_goal-_» Batteries.Tactic.tacticPick_goal_

Mathlib's multiGoal and unusedTactic linters keep those kinds in exclusion lists,
written out by name, so after the rename neither linter recognises on_goal or
pick_goal as focusing the goal any more and every use in Mathlib starts warning —
--wfail turns that into a build failure. Renamed in
Mathlib/Tactic/Linter/Multigoal.lean (both entries) and
Mathlib/Tactic/Linter/UnusedTacticExtension.lean.

44446 does not carry this half, because upstream Mathlib still builds against the
pre-#1990 batteries, where the old kinds exist and the exclusions work. Upstream will
need it at its next batteries bump.

(Mathlib/Tactic/Linter/FlexibleLinter.lean:299 holds a third such entry, under the
pre-Batteries name Std.Tactic.«tacticOn_goal-_=>_». It has been dead since the
rename to batteries and is left alone here — reviving it would change that linter's
output, which is not this breakage.)

Verified locally on 4cfce6c + nightly-2026-10-04:

  • lake build Mathlib Archive Counterexamples Wanted cache --wfail — 18352 jobs, no
    warnings
  • lake test --iofail — 18868 jobs
  • lake lint — Linting passed for Mathlib.

repl, whose test phase failed on the very same module, needs no change of its own:
lake build and lake test pass here, including the test/Mathlib build and the
on_goal case of the test/*.in suite.

Not fixed here

cslib and verso-slides are the two repos this run left red that are already covered
by open PRs, and no second fix is opened for them:

Nothing was left unfinished: every phase of every repo in this run's red set passes
locally, given those two PRs.

[batteries#1990](leanprover-community/batteries#1990)
lets `on_goal` act on several goals at once: it adds
`syntax goalNum := "-"? num` and replaces
`elab "on_goal " reverse:"-"? n:num " => " seq:tacticSeq` with
`elab "on_goal " ns:goalNum+ " => " seq:tacticSeq`, and `pick_goal`
likewise. That breaks Mathlib twice.

`Mathlib.Tactic.ClickSuggestions.Util` quotes `on_goal` in both pattern
and term position, so `$n₁` is now a `TSyntax goalNum` where a `NumLit`
is wanted and vice versa. Fixed as the author's own adaptation
[mathlib4#44446](leanprover-community/mathlib4#44446)
does, by annotating the three antiquotations `:num`.

The `-` also used to be an atom of the tactic syntax and is now part of
`goalNum`, so the generated syntax node kinds are renamed:
`Batteries.Tactic.«tacticOn_goal-_=>_»` to
`Batteries.Tactic.«tacticOn_goal_=>_»`, and
`Batteries.Tactic.«tacticPick_goal-_»` to
`Batteries.Tactic.tacticPick_goal_`. Mathlib's `multiGoal` and
`unusedTactic` linters keep those kinds in exclusion lists written out by
name, so after the rename every `on_goal` in Mathlib warns that it leaves
goals untouched, and `--wfail` makes that a build failure. Renamed in
both lists. 44446 does not carry this half, upstream Mathlib still
building against the pre-#1990 batteries.

Verified on 4cfce6c + nightly-2026-10-04: `lake build Mathlib Archive
Counterexamples Wanted cache --wfail` (18352 jobs, no warnings),
`lake test --iofail` (18868 jobs), `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 batteries on_goal change

Turned green:

Repo Critical Build Test Lint
mathlib4 ✅ ✅ in 19m 13s ✅ in 51s ✅ in 1m 30s
repl ✅ in 0s ✅ in 49s ⏭️
Stayed red
Repo Critical Build Test Lint
cslib 🟥 in 35s ⏭️ ⏭️
verso-slides 🟥 in 26s ⏭️ ⏭️
Stayed green
Repo Critical Build Test Lint
aesop ✅ ✅ in 0s ✅ in 5s ⏭️
batteries ✅ ✅ in 0s ✅ in 4s ✅ in 2s
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 1m 16s ⏭️ ⏭️
BibtexQuery ✅ in 3s ⏭️ ⏭️
comparator ✅ in 2s ⏭️ ⏭️
doc-gen4 ✅ in 7s ⏭️ ⏭️
illuminate ✅ in 1s ✅ in 10s ⏭️
lean4-unicode-basic ✅ in 0s ⏭️ ⏭️
lean4export ✅ in 0s ✅ in 7s ⏭️
LeanSearchClient ✅ in 0s ✅ in 0s ⏭️
leansqlite ✅ in 7s ✅ in 16s ⏭️
nerodia ✅ in 1s ✅ in 21s ⏭️
verso ✅ in 1m 20s ✅ in 2m 50s ⏭️
verso-web-components ✅ in 30s ⏭️ ⏭️

View run

@Kha

Kha commented Oct 4, 2026

Copy link
Copy Markdown
Member

@JovanGerb fyi

@Kha
Kha merged commit 202219d into master Oct 4, 2026
22 of 24 checks passed
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