Repository navigation
fix: batteries and cslib breakage from the batteries shake and the mathlib uniformOfFinset refactor - #134
fix: batteries and cslib breakage from the batteries shake and the mathlib uniformOfFinset refactor#134downstream-lean4[bot] wants to merge 2 commits into
shake and the mathlib uniformOfFinset refactor#134Conversation
`downstream: update repo batteries` 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. It
narrowed `Batteries/Lean/Meta/DiscrTree.lean` to `public import
Lean.Meta.DiscrTree.Types`, which is correct on `main`, where
`Trie.mergePreservingDuplicates` matches the `node` constructor directly,
but not on `nightly-testing`, which carries the adaptation to lean4#14805
and its new `Trie.chain` constructor and therefore goes through
`Trie.asNode` / `Trie.mkNode`. Those live in `Lean.Meta.DiscrTree.Util`,
so the module failed with
Invalid field `asNode`: The environment does not contain
`Lean.Meta.DiscrTree.Trie.asNode`
Unknown constant `Lean.Meta.DiscrTree.Trie.mkNode`
Import `Lean.Meta.DiscrTree.Util` instead; it publicly imports `.Basic`
and hence `.Types`, so `Key`, `Trie` and `DiscrTree` stay in scope.
Verified with `lake build --wfail`, `lake test` and `lake lint`.
Co-Authored-By: Claude Opus 5 <[email protected]>
The merge with mathlib master brought in `refactor(Probability/Distributions/Uniform): change uniformOfFinset and ofMultiset from PMF to Measure` ([mathlib4#42909](leanprover-community/mathlib4#42909)), which removes `PMF.uniformOfFinset` and `PMF.uniformOfFintype` and replaces them by `MeasureTheory.Measure.uniformOfFinset : Finset α → Measure α`. The deprecated aliases point at the measure, so they do not type-check at the old call sites: Application type mismatch: The argument Seed has type Type u_1 but is expected to have type Finset ?m.1 in the application PMF.uniformOfFintype Seed Nothing in mathlib supplies a uniform `PMF` any more, and all of `Cslib.Crypto` is phrased with `PMF`s — `bind`, `map`, `normalize`, `support` — so porting the call sites to `Measure` would be a rewrite of the crypto development rather than an adaptation. Instead the two `PMF` definitions move into `Cslib.Probability.PMF`, which already exists as a temporary holding place for `PMF` material awaiting upstreaming, together with the three lemmas the call sites use (`uniformOfFinset_apply`, `mem_support_uniformOfFinset_iff`, `uniformOfFintype_apply`). The definitions are mathlib's former ones unchanged. Call sites drop the `PMF.` prefix and pick the names up from `open Cslib.Probability.PMF`, which `OneTimePad` and `Shamir` already had. CI never saw this: it stopped at `batteries` and skipped `mathlib4` and `cslib` behind it. It is not nightly-specific — upstream cslib meets it at its next mathlib bump. Verified with `lake build --wfail --iofail`, `lake test --wfail --iofail` and `lake lint`. Co-Authored-By: Claude Opus 5 <[email protected]>
Build report for fix: cslib breakage from the mathlib
|
| Repo | Critical | Build | Test | Lint |
|---|---|---|---|---|
| aesop | ✅ | ✅ in 16s | ✅ in 4s | ⏭️ |
| batteries | ✅ | ✅ in 1s | ✅ in 4s | ✅ in 2s |
| mathlib4 | ✅ | ✅ in 16m 7s | ✅ in 42s | ✅ in 1m 33s |
| cslib | ✅ in 30s | ✅ in 9s | ✅ in 3s | |
| repl | ✅ in 0s | ✅ in 54s | ⏭️ |
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 1m 14s | ⏭️ | ⏭️ |
| BibtexQuery | ✅ in 3s | ⏭️ | ⏭️ | |
| comparator | ✅ in 2s | ⏭️ | ⏭️ | |
| doc-gen4 | ✅ in 7s | ⏭️ | ⏭️ | |
| illuminate | ✅ in 1s | ✅ in 11s | ⏭️ | |
| lean4-unicode-basic | ✅ in 0s | ⏭️ | ⏭️ | |
| lean4export | ✅ in 0s | ✅ in 8s | ⏭️ | |
| LeanSearchClient | ✅ in 0s | ✅ in 0s | ⏭️ | |
| leansqlite | ✅ in 7s | ✅ in 21s | ⏭️ | |
| nerodia | ✅ in 1s | ✅ in 21s | ⏭️ | |
| verso | ✅ in 1m 20s | ✅ in 2m 57s | ⏭️ | |
| verso-slides | ✅ in 45s | ✅ in 9s | ⏭️ | |
| verso-web-components | ✅ in 31s | ⏭️ | ⏭️ |
…#137) Split out of [#134](#134): this is its `batteries` commit on its own, unchanged (`b3bd4b838`), so it can land independently of the `cslib` half. `master` is red in [run 37404438445](https://github.com/leanprover/downstream-lean4/actions/runs/37404438445) on `nightly-2026-10-05`: `batteries` fails to build, and `aesop`, `mathlib4` and `cslib` are skipped behind it. ## batteries — `Trie.asNode` is in `Lean.Meta.DiscrTree.Util`, not `.Types` `downstream: update repo batteries` merged batteries' `main` into `nightly-testing` and so brought in [`chore: shake` (batteries#2005)](leanprover-community/batteries#2005), a repo-wide import minimization computed on the `v4.35.0-rc3` toolchain. It 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. ## Not covered here With `batteries` building again, CI reaches `cslib`, which then fails on the removal of `PMF.uniformOfFinset` / `PMF.uniformOfFintype` ([mathlib4#42909](leanprover-community/mathlib4#42909)). That fix stays in #134, so this PR alone is not expected to turn `master` fully green. ## Verification Not re-run for this split: the commit is byte-identical to the one in #134 and sits on the same `master` parent (`7768fa695`). There it was verified on `nightly-2026-10-05` with `lake build --wfail`, `lake test` and `lake lint` in `batteries`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01XyR8dP17VkvXwNSrqLMRcq Co-authored-by: downstream-lean4[bot] <downstream-lean4[bot]@users.noreply.github.com> Co-authored-by: Claude Opus 5 <[email protected]>
|
Superseded on both halves, closing. The The ( |
`master` went red with the bump to `nightly-2026-10-06` ([run 37451416455](https://github.com/leanprover/downstream-lean4/actions/runs/37451416455), toolchain-only commit 0c29ffc). Four repos are red; this PR fixes the one that can be fixed downstream. ## reference-manual (critical) — fixed Two expectation blocks went stale, from two different lean4 changes. **`Manual/Runtime.lean`** — lean4#15486 ("chore: pre-compute information about IR decls") renumbers IR variables and join points, so the `leanOutput discardElems` block no longer matched: `block_4`/`block_9` are now `block_1`/`block_2` and the variables shift accordingly. The block is regenerated from the new output. The prose below it names two of those variables; both are re-pointed at the new numbering — `x_11` for the discarded element whose reference count is decremented and `x_9` for the freshly allocated `List.cons`. (The old `x_5` was already stale: it named the reused cons cell rather than the decremented element, and after the renumbering it names a `u8`.) **`extended-examples/IndexMapGrind.lean`** — lean4#15506 ("fix: `grind` runs upward propagation from the `toProcess` queue") changes the order in which terms enter cutsat's equivalence classes, which reorders the members of two `[eqc]` lines in the `grind` diagnostics that the tutorial's `#check_msgs` docstring captures verbatim. Eighteen lines, pure reordering — nothing about the proof or the diagnostics' content changed. Expect this block to move again when the blocker below is fixed. Verified: full `lake build` locally, 1577/1577 jobs, exit 0. `reference-manual` defines neither a test nor a lint driver, so `lake build` is the whole phase set (matching `test`/`lint` being `null` in the build reports). ## mathlib4 (critical) — blocker, not fixable downstream `grind` throws the internal error ``unknown free variable `_fvar.771.11634` `` on `List.pairwise_iff_forall_infix` in `Mathlib/Data/List/Pairwise.lean:49`. Roughly 110 Mathlib modules sit behind it, and with them `repl`'s test phase (which compiles Mathlib) and `cslib` (skipped, no build for `mathlib4`). Bisected to lean4#15506 against the pr-release toolchains, with a repro that needs core only — no Mathlib, no Batteries: ```lean namespace List theorem test {α : Type u} {l : List α} {R : α → α → Prop} : l.Pairwise R ↔ ∀ l', (h : 1 < l'.length) → l' <:+: l → R (l'.head <| by grind) (l'.getLast <| by grind) := by refine l.pairwise_iff_getElem.trans ⟨fun h l' hne ⟨l₁, l₂, hl⟩ ↦ ?_, fun h i j hi hj hij ↦ ?_⟩ · grind [getElem_append_left', getElem_append_right'] · grind [h _ _ <| List.drop_suffix i _ |>.isInfix.trans <| l.take_prefix (j + 1) |>.isInfix] ``` | toolchain | result | | --- | --- | | `nightly-2026-10-05` | clean | | `pr-release-15503` | clean | | `pr-release-15506` | `unknown free variable` | | `nightly-2026-10-06` | `unknown free variable` | Dropping either bullet makes the error disappear, so it is the interaction of the two `grind` calls, not either one alone. An internal error is not something downstream can adapt to, so this is left to lean4 and `master` stays red until it is fixed. ## Left unfinished - **mathlib4** — the blocker above. Note that its build stopped at `Mathlib.Data.List.Pairwise`, so whatever sits behind those ~110 modules has never been elaborated on this nightly; more may appear once the internal error is gone. - **repl** — behind mathlib4, nothing of its own. - **cslib** — skipped behind mathlib4; its own breakage from the mathlib `uniformOfFinset` refactor is still open in #134. <!-- downstream-watch: unattended --> Co-authored-by: downstream-lean4[bot] <downstream-lean4[bot]@users.noreply.github.com> Co-authored-by: Claude Opus 5 <[email protected]>
masteris red in run 37404438445 onnightly-2026-10-05:batteriesfails to build,aesop,mathlib4andcslibare skipped behind it, andrepl's test phase compiles both and fails.This replaces #133, which
downstream: update repo mathlib4turnedCONFLICTING: upstream mathlib resolved that PR'smathlib4half by itself, in its own way, so only the one-linebatterieshunk survives. The same merge unmasked a newcslibfailure that CI has never reached.batteries —
Trie.asNodeis inLean.Meta.DiscrTree.Util, not.Typesdownstream: update repo batteriesmerged batteries'mainintonightly-testingand so brought inchore: shake(batteries#2005), a repo-wide import minimization computed on thev4.35.0-rc3toolchain. It replacedpublic import Lean.Meta.DiscrTreebypublic import Lean.Meta.DiscrTree.TypesinBatteries/Lean/Meta/DiscrTree.lean. That is correct onmain, whereTrie.mergePreservingDuplicatespattern-matches thenodeconstructor directly. It is not correct onnightly-testing, which carries the adaptation to lean4#14805's newTrie.chainconstructor and therefore goes throughTrie.asNode/Trie.mkNode— and those live inLean.Meta.DiscrTree.Util. The merge combinedmain's import line withnightly-testing's body, so the module fails withFixed by importing
Lean.Meta.DiscrTree.Util, which publicly imports.Basicand hence.Types, soKey,TrieandDiscrTreestay in scope.#133 predicted this hunk would be superseded by batteries' own adaptation at the next merge. That has not happened: batteries'
nightly-testingis still red the same way (their run of 2026-10-05 17:56), and thedownstream: update repo batteriesthat did land in between carriedUnnecessarySeqFocusandArray/Mergechanges but nothing for this module.cslib —
PMF.uniformOfFinsetandPMF.uniformOfFintypeare goneThe merge with mathlib master brought in
refactor(Probability/Distributions/Uniform): change uniformOfFinset and ofMultiset from PMF to Measure(mathlib4#42909), which removes both definitions and replaces them byMeasureTheory.Measure.uniformOfFinset : Finset α → Measure α. The deprecated aliases point at the measure, so they do not type-check at the old call sites:Nothing in mathlib supplies a uniform
PMFany more, and all ofCslib.Cryptois phrased withPMFs —bind,map,normalize,support— so moving the call sites toMeasurewould be a rewrite of the crypto development rather than an adaptation. Instead mathlib's two former definitions move, unchanged, intoCslib.Probability.PMF, which already exists as a temporary holding place forPMFmaterial awaiting upstreaming, along with the three lemmas the call sites use (uniformOfFinset_apply,mem_support_uniformOfFinset_iff,uniformOfFintype_apply). The call sites drop thePMF.prefix and pick the names up fromopen Cslib.Probability.PMF, whichOneTimePadandShamiralready had;PRG.Defs,PRG.BasicandCslibTests.PRGgain it.This half is not nightly-specific: upstream cslib meets it at its next mathlib bump.
mathlib4 — superseded upstream, nothing to do here
For the record, since #133 carried five hunks here:
downstream: update repo mathlib4brought mathlib's own resolution of the sameshakefallout.Mathlib/Basic/Logic/Basic.lean,Mathlib/Data/Nat/Init.leanandMathlib/Data/Int/Init.leannowpublic import Batteries.Tactic.Aliasthemselves (which also coversBasic/Logic/Lemmas.leantransitively), andCounterexamples/ZeroDivisorsInAddMonoidAlgebras.lean'sguard_declelaborator compares module indices with==instead of=, so it no longer needs theDecidableEq ModuleIdxinstance fromBatteries.Tactic.OpenPrivate.Verified locally on
nightly-2026-10-05Every phase below was re-run from scratch on the final tree, all green:
batterieslake build --wfail✔,lake test✔,lake lint✔aesoplake build --wfail✔,lake test✔ (no change needed)mathlib4lake build --wfail Mathlib Archive Counterexamples Wanted cache✔,lake test --iofail✔,lake lint✔ (no change needed)csliblake build --wfail --iofail✔,lake test --wfail --iofail✔,lake lint✔repllake build✔,lake test✔ (no change needed)Nothing was left unfinished: this is the whole red set of run 37404438445.
🤖 Generated with Claude Code