Skip to content

Commit 2234dda

Browse files
mathlib-nightly-testing[bot]kim-emleanprover-community-mathlib4-botclaudenomeata
authored
chore: adaptations for nightly-2026-06-05 (#235)
* remove `change` tactics flagged by unusedTactics linter * fix * fix * fix * fix * fix * fixes * fixes * fixes * fixes * adaptation note * linting * chore: adaptations for nightly-2026-05-03 (#215) Co-authored-by: mathlib-nightly-testing[bot] <mathlib-nightly-testing[bot]@users.noreply.github.com> * Update lean-toolchain for https://github.com/leanprover/lean4/pull/13651 * Apply suggestions from code review Co-authored-by: Kim Morrison <477956+kim-em@users.noreply.github.com> * chore: bump to nightly-2026-05-09 * chore: revert spurious blank-line additions Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: revert remaining spurious blank-line additions Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: undo over-eager blank-line reverts (restore lines from PR base) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: bump to nightly-2026-05-10 * chore(Cache/IO): drop `open private` for now-public `Lake.Glob.ofString?` `Lake.Glob.ofString?` is now `public` in Lake (nightly-2026-05-10), so the `open private ... from Lake.Load.Toml in` line fails to elaborate and blocks `lake exe cache get` from building. The call site uses the fully-qualified name, so dropping the line is sufficient. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore(Data/String/Lemmas): add `length_toList` to `simp` set in leftpad lemmas Upstream `simp` no longer normalises `s.toList.length` and `s.length` to a common form, so `simp [leftpad, ...]` leaves a mixed goal that `Nat.sub_add_eq_max` (and the prefix reasoning at line 34) cannot match. Passing `String.length_toList` explicitly unifies the two forms and closes both goals. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore(RingTheory/Bialgebra/TensorProduct): enable `backward.defeqAttrib.useBackward` for `comm` The `rw [comul a]` inside `comm` no longer matches after upstream changes to defeq attribute handling. Locally re-enabling the backward behaviour with `set_option backward.defeqAttrib.useBackward true` restores the previous elaboration and lets the existing proof go through. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Apply suggestions from code review Co-authored-by: Kim Morrison <477956+kim-em@users.noreply.github.com> * fix: restore mapFreeIso_hom lemma from #38341 Lost during the master-merge resolution in 7aa60c9cea7. The upstream refactor in #38341 introduced this lemma; the merge dropped it because the adaptation branch had reorganised the surrounding declarations. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix: drop stale Reorder defs re-added during merge `Reorder.permuteUniv` and `Reorder.isEmpty` (on the pre-#36604 shape of `Reorder`) were deleted by #36604 when the structure was renamed to `ArgReorder` and a new `Reorder` wrapper was introduced. They were accidentally re-added during a merge resolution and reference a `Reorder` type that is not yet in scope at that point. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: adaptations for nightly-2026-05-07 (#218) * Update lean-toolchain for https://github.com/leanprover/lean4/pull/13492 * Revert "chore: more proof-level `irreducible_def` patches" and predecessor Revert 6c4ca63236b and 265db6f0b35. The cherry-picked Lean fixes 8741db2872 ("store eqn-affecting options at definition time instead of eager generation") and 3d985fc54b ("use `.local` asyncMode for `eqnOptionsExt`") make the `@[eqns X_def]` override installed by `irreducible_def` win again, so `simp [X]` / `rw [X]` no longer leak `wrapped.1`. The `X` → `X_def` workarounds are therefore unnecessary on the adaptation branch. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: restore module-level `set_option backward.defeqAttrib.useBackward true` on three files These three files need the option set at module scope for reasons *unrelated* to the eager-eqn-generation bug that the Lean cherry-picks (8741db2872, 3d985fc54b) addressed — they contain `@[backward_defeq]`-only simp lemmas whose simp rewrites only fire with `useBackward = true` via `useImplicitDefEqProof`. Without the option their proofs no longer check (e.g. `Module.Basis.det`'s `MultilinearMap.mk'` arguments). The broader revert 60d49842875 dropped them alongside the now-unnecessary `rw [X]` → `rw [X_def]` workarounds; restore only the `set_option` lines. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Update lean-toolchain for https://github.com/leanprover/lean4/pull/13492 * chore: bump to nightly-2026-04-22 * chore: strip all `set_option backward.defeqAttrib.useBackward true` Baseline for re-adding the option only where actually needed. * chore: add scoped \`set_option backward.defeqAttrib.useBackward true\` only where locally needed Down from the bulk module-level set in 99.7% of mathlib files to scoped \`set_option ... true in\` before ~170 specific declarations across 82 files. Remaining failures all appear to be non-local (option needed on a transitive dependency, not the failing module itself): * Mathlib.Order.JordanHolder * Mathlib.CategoryTheory.Equivalence * Mathlib.RingTheory.TensorProduct.Maps These will be fixed by \`scripts/fix_nonlocal_set_option.py\`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore(scripts): thread --value through fix_nonlocal_set_option.py Allow `--value true` (matching add_set_option.py). Without this, the script hard-coded 'false' and was unusable for restoring legacy behavior. * fix(Order/JordanHolder): restructure `Equivalent.snoc` proof The original relied on simp reducing an equiv chain inside a `let`: specifically `((finSuccEquivLast.trans (Functor.mapEquiv Option h)).trans finSuccEquivLast.symm) (Fin.last _)` to `Fin.last _`. Under the stricter `inferDefEqAttr` rules, simp no longer fires the needed chain through the `let`-bound equiv in this particular goal shape. Rewrite the proof to extract `e_last` and `e_castSucc` auxiliary equalities explicitly, using tactic mode with `show`/`rw`/`simpa`, so the proof no longer depends on simp magic inside `let`. * fix(RingTheory/TensorProduct/Maps): use `simpa` instead of `dsimp; exact` `dsimp` no longer normalizes the nested `AlgebraTensorModule.curry` applications down to the `f (_ \u2297\u209c _ \u2297\u209c _)` form `h_mul` expects. `simpa using h_mul _ _ _ _ _ _` handles it — the simp call it wraps reduces the curry chains successfully. * fix(CategoryTheory/Equivalence): module-level \`set_option backward.defeqAttrib.useBackward true\` The \`@[to_dual existing ...]\` validations fail without this option because the \`Equivalence\` structure's field types are emitted in a slightly different binder-order shape under the stricter defeq rules, so the generated \`to_dual\` expected form no longer matches the structure-generated one. Setting the option at module level restores the legacy behavior for elaborating this file's structure and its \`to_dual\`-tagged theorems. * chore: 2nd round of scoped `set_option backward.defeqAttrib.useBackward true` After fixing JordanHolder/Equivalence/TensorProduct.Maps, re-ran `add_set_option.py --value true`. 99 more modules needed the option locally (scoped per-declaration). Mostly CategoryTheory (especially Bicategory and Functor APIs). * chore: file-level `set_option backward.defeqAttrib.useBackward true` on 8 CategoryTheory files `add_set_option.py` could not fix these locally because the failures are in `NatIso.ofComponents` / `@[simps!]` bodies where `aesop` fails to synthesize naturality fields; the option has to be module-level so that all structure-field elaboration sees it. * chore: 3rd iteration of scoped + file-level `set_option` additions Add option per-declaration to 9 more modules via `add_set_option.py`, and at module level to 2 more (Adjunction/Basic, Limits/Cones) where local scoping didn't suffice. * chore: 4th iteration of scoped `set_option backward.defeqAttrib.useBackward true` 164 modules fixed. 15 remaining need file-level option or proof restructuring (Mates, Grothendieck, Pseudo, KanExtension, etc.). * chore: file-level `set_option backward.defeqAttrib.useBackward true` on 13 category theory files Modules with `@[simps!]` / structure-field elaboration that don't accept scoped set_option (Mates, KanExtension, Elements, Monoidal, etc.). * chore: 5th iteration of scoped `set_option backward.defeqAttrib.useBackward true` (72 modules) * chore: file-level `set_option backward.defeqAttrib.useBackward true` on 17 more files * chore: 6th iteration scoped set_option additions (27 modules) * fix(Tactic/Simps): run projection-lemma normalization with \`useBackward=true\` The \`@[simps!]\` pipeline normalizes the RHS via \`dsimp\` then \`simp\` to produce the cleanest possible body for the generated projection lemma. With the stricter \`inferDefEqAttr\` rules, many \`@[simps]\`-generated lemmas from upstream structures are tagged \`@[backward_defeq]\` only — without \`useBackward=true\` the \`dsimp\` step doesn't pick them up, the RHS no longer reduces to a rfl-shape, and the projection lemma ends up with a compound proof (\`congrArg …\`). \`inferDefEqAttr\` then fails to tag it, which cascades: every downstream \`@[simps!]\` that relied on this lemma being rfl also gets a compound proof, and so on. Forcing \`useBackward=true\` inside \`addProjection\` keeps \`@[simps!]\`'s dsimp normalization as aggressive as before, so rfl-shaped projections stay rfl-shaped and \`inferDefEqAttr\` can tag them. * chore: add scoped `set_option backward.defeqAttrib.useBackward true` After the `Tactic.Simps.Basic` fix (`@[simps!]` now runs normalization with `useBackward=true`), many previously-broken downstream files now only need the option scoped per-declaration. Run `add_set_option.py` to add it where needed — 409 modules fixed this round. * chore: file-level `set_option backward.defeqAttrib.useBackward true` on 8 files where scoped failed * fix(Tactic/DSimpPercent): elaborate `dsimp%` with `useBackward=true` `dsimp%` runs at definition time and the result is stored in the theorem's signature. If the defining file doesn't have `backward.defeqAttrib.useBackward=true`, the stored form differs from what a use site with the option enabled expects, so `rw`/`simp` match fails. Wrap the elaborator in `withOptions (fun opts => ...useBackward.set opts true)` so `dsimp%` always normalizes under the permissive rules, matching pre-stricter-inference `dsimp` behavior. This is analogous to the fix applied to `@[simps!]`'s projection generator. * Revert "fix(Tactic/DSimpPercent): elaborate `dsimp%` with `useBackward=true`" This reverts commit dc5c3e65f15867bf3107206a36cb5377f6c063e1. * fix: scope useBackward=true around `extendRestrictScalarsAdj_counit_app_apply_one_tmul` This lemma uses `dsimp%` in its type, and since `dsimp%` normalizes at elaboration time, the stored form depends on `useBackward`. Downstream users (e.g. `ModuleCat/Monoidal/Adjunction.lean`) set `useBackward=true` and expect the pre-stricter-inference normal form, so the definition site must agree. * fix: proof-level adaptations for 2 files under stricter defeq For files where `useBackward=true` cannot restore pre-PR behavior because the stored forms of imported lemmas (generated via `dsimp%`, `@[reassoc]`, `@[elementwise]` etc. at elaboration time without `useBackward=true`) differ from use-site expectations, adapt the proofs: - `RelativeCellComplex.lean`: replace `dsimp; rw [Cell.map_app_objEquiv_symm_δ_index]` with `exact c.map_app_objEquiv_symm_δ_index`, avoiding dsimp through `Subcomplex.lift_app_coe` whose `dsimp%` stored form differs. - `Ext/Map.lean`: reorder and augment the rewrite chain in `DerivedCategory.map_triangleOfSESδ` so that intermediate forms match the stored reassoc lemmas; replace a trailing `simp` chain with explicit simp lemmas that cancel the inserted `commShiftIso.hom ≫ inv` pair. * fix: add `id_comp` to simp list in `CoGrothendieck.map.map_comp` Under the stricter defeq inference, the prior `simp only` chain no longer reduces some `𝟙 _ ≫ ...` residues because the `eqToHom`-from-compound proofs leave identity morphisms in left-composition position. Adding `id_comp` to the simp list (alongside the existing `comp_id`) cancels them and closes the goal. * fix: spell out `ofIso`'s `s'_comp_ε` and `s₀_comp_δ₁` proofs The previous `simpa` / `simp` closings relied on `w₀` (whose type contains `dsimp%`) and the reassoc-generated `s'_comp_ε_assoc` / `s₀_comp_δ₁_assoc` taking a particular normalized form. Under stricter defeq inference those stored forms no longer match the use-site goal, so replace the one-line closers with explicit rewrite chains that apply `w₀`, `ed.s'_comp_ε_assoc`, and `ed.s₀_comp_δ₁` step by step. * fix: adapt `colimitLimitToLimitColimit_injective`/`_surjective` proofs Under stricter defeq inference the stored form of `ι_colimitLimitToLimitColimit_π_apply` (generated by `@[elementwise (attr := simp)]`) and `Limit.π_mk` (involving `dsimp%` and proof-dependent shapes) no longer match through plain `simp`/`rw`. Replace `simpa using ...` with an explicit `simp only [...]; exact ...`, and replace the final `rw [← dsimp% e j, dsimp% Limit.π_mk _ _ h]` with `erw [ι_colimitLimitToLimitColimit_π_apply]; generalize_proofs ...; erw [Limit.π_mk (h := p6), ← e j]`. The `erw` lets the residual universe/def-equality differences on the outer namespace be resolved. Also adapt the intermediate naturality step via an explicit `change` + `ι_colimMap` rewrite. * chore: add `set_option backward.defeqAttrib.useBackward true` scoped to failing decls (round 7) * chore: add useBackward to failing decls (round 8) * chore: add useBackward to failing decls (round 9, partial) * fix: add useBackward to fix remaining failures in round 9 * chore: add useBackward to failing decls (round 10) * chore: add useBackward to failing decls (round 11) * chore: add useBackward to failing decls (round 12) * chore: add useBackward to failing decls (round 13) * chore: partial adds in round 14 (4 files still need manual fix) * fix: scope useBackward at more decl sites (round 14 manual fixes) * chore: useBackward on mapComp'_inv_naturality and pullHom_pullHom (doesn't fix IsPrestack yet) * chore: partial attempts in IsPrestack (remains broken) * chore: add useBackward to failing decls (round 15) * fix: Stalk.lean needs useBackward on 4 decls * chore: add useBackward to failing decls (round 16) * fix: add useBackward to mapComp'₀₂₃_inv_comp_mapComp'₀₁₃_hom and variants * chore: round 17 partial (DescentData still broken) * chore: partial useBackward on DescentData (still broken) * chore: partial DescentData fixes (still has cascading issues) * chore: file-level useBackward on DescentData, minor proof edits * chore: OpenImmersion.lean useBackward * chore: partial DescentData - line 352 still has metavar issue * fix: DescentData + useBackward on mapComp'₀₂₃_hom * chore: round 18 partial * fix: Precoverage.lean file-level useBackward * chore: round 20 * fix: `add_set_option.py` skip `variable`/`include`/`omit`/`open` lines The walk-back heuristic lands on the first blank line above the error, but then needs to advance past non-declaration preamble lines to reach an actual target of `set_option ... in`. Previously the script would insert before `variable`, producing invalid syntax; now it skips past such statements. * chore: round 21 (GammaSpecAdjunction, Gluing) * Revert "fix: `add_set_option.py` skip `variable`/`include`/`omit`/`open` lines" This reverts commit a3a71e3288d5a7899b501579a32531b7a207d08a. * chore: round 22 * chore: round 23 * chore: script-fixed 36 more mathlib modules with useBackward * fix: add useBackward to 3 decls in Representability.lean * chore: remove unused simp arguments (326 across 123 files) Added scripts/fix_unused_simp_args.py which parses the \"This simp argument is unused\" warnings from a lake build log and rewrites the corresponding simp call. For plain arguments it drops them; for \`← X\` arguments it rewrites to \`- X\` (simp's own hint notes the \`←\` form has side effects on the simp set even when the rewrite itself is unused, so the \`-\` form preserves that behavior while silencing the warning). * chore: fix long lines, `show` -> `change`, drop unused `- X` simp args * chore: one more long-line fix * Update lean-toolchain for https://github.com/leanprover/lean4/pull/13492 * chore: useBackward on 3 MathlibTest files for lake test * Empty line * Bump batteries * Update lean-toolchain for https://github.com/leanprover/lean4/pull/13492 * doc(scripts): document new helpers (fix_unused_simp_args.py, fix_long_lines.py, *_module_set_option.py, fix_nonlocal_set_option.py) * chore: add `simpNF` nolints for 178 lemmas that simp can now prove Under the stricter `@[defeq]` inference the set of theorems that `simp` treats as reflexivity-lemmas shrank slightly, which means a number of previously-accepted `@[simp]` lemmas can now be derived from other simp lemmas and so fail the `simpNF` linter. Add them to `nolints.json` rather than individually removing the `@[simp]` attribute, since the ideal long-term fix (actually removing the attributes) is better done in follow-up PRs with proper code-review of each individual lemma. * chore: bump to nightly-2026-04-23 * cleanup * revert an unnecessary change * revert unnecessary changes * add adaptation notes * minor fixes, whitespace and PR links * adaptation notes * two improvements * fix * fix FilteredColimitCommutesFiniteLimit * fix IsPrestack * improvements * improvements * fix extra degeneracy * small improvement in DerivedCategory/Ext * slightly improve the proof in Limits/Shapes/Equalizers.lean * removed adaptation note for DerivedCategory/Ext/Map * More * chore: bump to nightly-2026-04-24 * adapt to lean4#13363: canUnfoldAtMatcher allowlist changes Adapt proofs to lean4#13363 which replaces the transparency bump from `.reducible` to `.instances` in `whnfMatcher` with an explicit allowlist in `canUnfoldAtMatcher`. Class projections like `CategoryStruct.comp`, `CategoryStruct.id`, `Stream.next?`, `Min.min` etc. are no longer auto-unfolded in match discriminants and need explicit unfolding in proofs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * chore: remove unused helper lemmas from Ordinal/Notation adaptation Remove `zero_zero_eq`, `one_one_eq`, `repr_zero'`, and `ofNat_unfold` which were added during the lean4#13363 adaptation but are not used in any proofs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Update lean-toolchain for https://github.com/leanprover/lean4/pull/13363 * more cleaningup * adapt Limits/Shapes/ConcreteCategory to lean4#13363 Use `WalkingMulticospan.Hom.id_eq_id` and `Functor.map_id` to reduce stuck matches on `𝟙` in WalkingMulticospan naturality proofs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Bump batteries * Update lean-toolchain for https://github.com/leanprover/lean4/pull/13363 * chore: bump to nightly-2026-04-25 * Update lean-toolchain for testing https://github.com/leanprover/lean4/pull/13528 * satisfy linter * fixes * archive and counterexamples * fix: round 30 - Pi/Basic + TensorProduct/Pi after nightly merge * chore: round 32 fixed by script * chore: round 33 (5 of 6 fixed by script) * fix: Biproducts isoCoproduct simp leaves isTrue goal needing subst * chore: round 34 (3 of 5 by script) * fix: round 34 SequentialProduct + StdSimplex * chore: round 35 * chore: round 36 * chore: round 37 * chore: round 37 - remove unused simp args * chore: avoid 'adaptation note' substring in adaptation note bodies * chore: round 41 (2 of 3 fixed by script) * chore: resolve merge conflict in Sheaf/Free.lean Drop the leftover ιFree_mapFree_inv lemma from the adaption branch; the upstream refactor (mapFreeIso) replaces it and provides a deprecated alias. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: nolint two simpNF auto-generated lemmas These are @[simps]-style auto-generated lemmas whose LHS now simplifies via new simp set behavior; nolint to keep adaption focused. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Remove my custom scripts used for managing lean4#13492 migration * chore: bump to nightly-2026-04-27 * Update lean-toolchain for https://github.com/leanprover/lean4/pull/13528 * chore: bump to nightly-2026-04-28 * Update lean-toolchain for https://github.com/leanprover/lean4/pull/13528 * chore: drop stale `DeprecatedModule` import in `RingTheory/Regular/Depth` The internal `Mathlib.Tactic.Linter.DeprecatedModule` module was removed on master in 9037b087ee0; `deprecated_module` is now a built-in Lean command. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: extend `lean-pr-testing-13492` set_option pattern to remaining decls Newly-added or master-merged declarations need the same `set_option backward.defeqAttrib.useBackward true in` adaptation as the rest of the lean4#13492 mathlib branch. One genuine proof-level breakage remains in `AlternatingFaceMapComplex.ε.naturality` (line 233). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(AlgebraicTopology): repair `ε.naturality` under stricter defeq Under lean4#13492, `simp [ChainComplex.toSingle₀Equiv]` no longer expands the `(toSingle₀Equiv).symm.f 0` redex. Use the explicit projection lemma `ChainComplex.toSingle₀Equiv_symm_apply_f_zero` instead. Includes `#adaptation_note`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: extend `useBackward` set_option to two more pushout-product files Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: remove redundant `@[expose]` attributes flagged by lean4#13359 The new `warn.redundantExpose` linter from lean4#13359 reports that these declarations would be exposed by default, so the explicit attribute is redundant. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: add `@[expose] public section` to silence private-module warning Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: drop redundant `@[simp]` from `Pretriangulated.{id,comp}_hom₁/₂/₃` Under lean4#13492's stricter defeq, `(f ≫ g).hom₃` already simplifies via the `@[simps]`-generated `triangleCategory_comp` to the form these manually-written simp lemmas were producing, so simpNF now reports them as redundant. Lemmas remain available as named references (just not `@[simp]`). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: drop redundant `@[simp]` from `coe_id`/`coe_comp` in `Order.Category` Under lean4#13492's stricter defeq, the `ConcreteCategory` simp lemmas already cover these — the file comment already noted they are duplicates "kept for `dsimp`". Lemmas remain available as named references. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: drop redundant `@[simp]` flagged by simpNF in CategoryTheory + Topology Under lean4#13492's stricter defeq, several auto-generated and manually-written `@[simp]` lemmas in `CategoryTheory.{Comma/Over,Core, Functor/KanExtension,Limits/Shapes/Pullback/Iso,ObjectProperty,Sites}, Topology.Category.TopCat.OpenNhds` are flagged as having LHSs that simplify further. Drop the offending `@[simp]` (via `attribute [-simp]` on `@[simps]`-generated lemmas, by trimming the `@[simps]` projection list, or by removing `@[simp]` from manually-written ones). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: drop more `@[simp]` flagged by simpNF as 'LHS simplifies from' Finishes Phase 1 of the lean4#13492 simpNF cleanup on `nightly-testing`: the remaining `Left-hand side simplifies from` reports become non-simp lemmas (or have the corresponding `@[simps]` projection's `@[simp]` removed via `attribute [-simp]`). Lemmas remain available as named references. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: drop redundant `@[simp]` from `coe_id`/`coe_comp` in `Algebra.Category` Mirror of the `Order.Category` fixes — these `@[to_additive (attr := simp)]` lemmas are explicitly documented as duplicates of the `ConcreteCategory` simp lemmas kept "for `dsimp`". Under lean4#13492's stricter defeq, simp can already prove them, so drop the simp attribute. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: drop redundant `@[simps!]` on `WeierstrassCurve.{Affine,Jacobian,Projective}.{map,baseChange}` These are `abbrev`s aliasing the underlying `WeierstrassCurve.{map,baseChange}`, whose `@[simps]`-generated lemmas (`WeierstrassCurve.map_a₁`, etc.) already cover what these abbreviations expose. Under lean4#13492's stricter defeq the simpNF linter flags every `_a₁`...`_a₆` projection as provable by simp. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: drop redundant `@[simps!]`/`@[simp]` in CategoryTheory bicategory + monoidal Continues the lean4#13492 simpNF cleanup: - `Bicategory.Opposites.{op2,op2_unop,unop2,unop2_op}`: drop `@[simps!]` - `Monoidal.Action.Basic.{actionLeft,actionRight}` (×2): drop `@[simps!]` - `Bicategory.Functor.LocallyDiscrete.toOplaxFunctor{,'}`: trim `@[simps!]` projection list to just `map` (the others are redundant) - `Monoidal.Grp.{id,comp}_hom_hom`: drop `@[simp]` - `Monoidal.Grp.mkIso`: keep `@[simps!]` (the auto-generated lemmas are referenced by `@[deprecated] alias`) but `attribute [-simp]` on the flagged projections. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: trim more `@[simp]`/`@[simps]` flagged by simpNF Continues the lean4#13492 cleanup, mostly trimming `@[simps]` projection lists or dropping `@[simp]` attributes (`Bicategory.LocallyGroupoid`, `Monoidal.Mon.mkIso`, `Comma.{toPUnitIdEquiv,toIdPUnitEquiv}`, `Combinatorics.Graph.noEdge`, `RootSystem.Equiv.comp`, `Group.Equiv.{monoid,addMonoid}HomCongr{Left,Right}Equiv`, `Free{Magma,Semigroup}.{map_pure,pure_bind}`). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: trim more `@[simps]`/`@[simp]` flagged by simpNF (batch 4) - `NonUnitalAlgHom.{fst,snd,prod}`: `@[simps]` → `@[simps toFun]` - `Unitization.{lift,starLift}`: drop `apply_apply` from `@[simps!]` list - `Unitization.inrNonUnitalAlgHom`: `@[simps]` → `@[simps toFun]` - `Cat.Hom.comp_obj`, `Cat.{whiskerLeft,whiskerRight}_app`: drop `@[simp]` - `Graph.copy`: `@[simps]` → `@[simps -isSimp]` + add `[copy]` to `simp_all` in `copy_eq` proof Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: trim more `@[simps]`/`@[simp]` flagged by simpNF (batch 5, big) Continues the lean4#13492 simpNF cleanup across the long-tail 2-error and 1-error files. Pattern is consistent: trim the `@[simps]` projection list to drop the redundant projection, or drop `@[simp]` (or its `(attr := simp)` to_additive directive) on a manually-written lemma. For a few cases where the auto-generated lemma is referenced downstream, the `@[simps!]` is kept and `attribute [-simp]` is used to drop only the `@[simp]` status. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: bump to nightly-2026-04-29 * chore: fix namespace context in `attribute [-simp]` calls Inside `namespace Foo`, `attribute [-simp] Foo.bar` is interpreted relative to the current namespace and fails to resolve. Use `_root_.` prefix on the fully-qualified name so the directive actually fires. This fixes ~12 of the simpNF errors that the previous batches were intended to address but where the directive was a no-op. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: trim more simpNF-flagged simp lemmas (batch 6) Reduces simpNF lint errors from 56 → 20. Patterns used: - For `@[to_additive (attr := simp)]` cases where only the additive version is flagged, switch to `@[to_additive] / attribute [simp] foo` pattern, which puts simp only on the multiplicative version. - For redundant `_symm_apply` lemmas auto-generated by `@[simps]` on equivs, switch to `@[simps apply]` (omitting the redundant `_symm_apply` projection). - For deeper-recursion projections like `_val_inv_*` in `@[simps!]` on Units-of-Units structures, drop `@[simps]` entirely or restrict the projection list. - Manually-written `@[simp]` lemmas redundant with other simp lemmas: drop `@[simp]`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: trim more simpNF-flagged simps via explicit projection lists Reduces simpNF lint errors from 20 → 11. Pattern used: switch from `@[simps!]` + `attribute [-simp] foo` (which doesn't actually remove simp from `simps!`-generated lemmas in this lean version) to either: - `@[simps! GOOD_PROJECTIONS]` listing only projections that should remain simp lemmas, omitting the redundant deep-recursion ones; or - `@[simps! TOP_PROJECTIONS]` plus a manually-written non-simp theorem for the remaining declaration name (e.g. `noEdge_isLink`). Files: Combinatorics/Graph/Basic, CategoryTheory/Comma/Over/Basic, CategoryTheory/Core, Analysis/Normed/Module/PiTensorProduct/InjectiveSeminorm. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: drop redundant `@[simp]` from def equation lemmas Removes `@[simp]` from `def addY`, `def piPremeasure`, `def zeroDefaultSupp`, `def equivExterior` (in WeierstrassCurve, MeasureTheory, Plausible, CliffordAlgebra). The auto-generated `_eq_1` equation lemmas for these defs are redundant given other simp lemmas, per simpNF. Adjusts `Petersson.lean` to drop `-Matrix.SpecialLinearGroup.coe_matrix_coe` from a simp arg list since that lemma is no longer simp. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Update lean-toolchain for https://github.com/leanprover/lean4/pull/13528 * adaptation notes about nolint simpNF * chore: nolint simpNF on auto-generated equation lemmas The previous commit added `nolint simpNF` to the parent `def`s, but the linter still complained about their auto-generated `.eq_1`/`.eq_2` equation lemmas. Add explicit `attribute [nolint simpNF]` for each. Also fix Contraction.lean: the `#adaptation_note` was placed between the doc-comment and the `def`, which is a syntax error. Move it before the doc-comment. Linter is now clean. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: add adaptation_note to each `attribute [nolint simpNF]` Followup to a3dbe9e910c: each bare `attribute [nolint simpNF]` for the `.eq_1`/`.eq_2` lemmas now has its own `#adaptation_note` so it can be grepped for and revisited. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * lake update batteries * chore: fix mutual instance + filtered closure rfl failures Two unrelated breakages exposed by the master merge: * `Mathlib/SetTheory/Lists.lean`: the `mutual` block of three `instance` declarations now triggers an "instance `..._mutual` target ... is not a type class" error from the new mutual-instance handling. Switch the mutual-block declarations to `def` and add a separate `attribute [instance]` afterwards. The old workaround `attribute [nolint nonClassInstance] Lists.Equiv.decidable._mutual` is no longer needed. * `Mathlib/CategoryTheory/Filtered/Small.lean`: two `rfl` calls in `small_fullSubcategory_{filtered,cofiltered}Closure` started failing under the new defeq regime. Wrap both theorems with `set_option backward.defeqAttrib.useBackward true in`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: bump to nightly-2026-04-30 * chore: bump to nightly-2026-05-01 * chore: bump to nightly-2026-05-02 * fix * adaptation note * fix bad merge * adaptation notes * fix * fixes * attributes * fixes * fixes via attributes * fixes * linter * nolint * Update lean-toolchain for testing https://github.com/leanprover/lean4/pull/13613 * chore: bump to nightly-2026-05-03 * remove unneeded simp * Update lean-toolchain for https://github.com/leanprover/lean4/pull/13613 * chore: bump to nightly-2026-05-04 * fixes * Apply suggestions from code review Co-authored-by: Kim Morrison <477956+kim-em@users.noreply.github.com> * fixes from nightly-testing * lake-manifest * lake-manifest * fix from nightly-testing * fix test * chore: bump to nightly-2026-05-05 * chore: restore @[to_additive (attr := simp)] symmetry PR 215 rewrote a number of `@[to_additive (attr := simp)]` attributes to `@[to_additive]`, sometimes followed by an asymmetric `attribute [simp]` on only one side of the to_additive pair. Restore the original symmetric form everywhere this pattern appears. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Revert "chore: restore @[to_additive (attr := simp)] symmetry" This reverts commit d79879fec19f7f3ea2ab4f2f038661047c74e7c4. * fix(to_additive): propagate @[defeq] symmetrically to additive translations Under lean4#13492's stricter `@[defeq]` inference, `inferDefEqAttr` only tags a theorem `@[defeq]` if its rfl proof passes `withReducibleAndInstances <| isDefEq lhs rhs`. For `to_additive`-generated additive lemmas this check fails systematically — even on cases like `AddMonoidHom.coe_id` whose proof is rfl and whose multiplicative source `MonoidHom.coe_id` is `@[defeq]`. The result was a divergence: `dsimp` reduced `(𝟙 X : X → X)` to `id` for `X : GrpCat` but stopped at `⇑(AddMonoidHom.id X)` for `X : AddGrpCat`, which made simpNF flag a host of additive `coe_id`/`coe_comp` lemmas as redundant simp lemmas even though their multiplicative twins were fine. Fix: in `to_additive`'s `defeqAttr` propagation, after calling `inferDefEqAttr` on the target, promote it to `@[defeq]` whenever the source is `@[defeq]` and the target is at least `@[backward_defeq]` (i.e. rfl-shaped). The translation preserves rfl-ness, so a multiplicative `@[defeq]` source implies the additive translation should also be `@[defeq]` for symmetric `dsimp` behaviour. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: restore @[to_additive (attr := simp)] symmetry PR 215 rewrote a number of `@[to_additive (attr := simp)]` attributes to `@[to_additive]`, sometimes followed by an asymmetric `attribute [simp]` on only one side of the to_additive pair. Restore the original symmetric form everywhere this pattern appears. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: drop redundant @[simps!] on Mon.mkIso / AddMon.mkIso `mkIso` is an abbrev for `mkIso'`, and `mkIso'` already has `@[simps]`. The `simps!` projections of `mkIso` would just rederive what `simps` on `mkIso'` already provides, and simpNF rightly flags the duplicates. Dropping the `(attr := simps!)` here matches PR 215's original intent and leaves the `@[to_additive (attr := simp)]` symmetry restoration in place for the rest. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * deprecation * fix * deprecation * chore: restore lost content from #38972 merge in Cartesian/Mon.lean The merge of master into nightly-testing dropped the `IsMonHom (toUnit M)`, `IsMonHom η[M]`, `Mono η[M]` instances in the `SemiCartesianMonoidalCategory` section, plus `IsMonHom.monoidHom` and the matching `yonedaMon.map`. Restore upstream/master's version of the file and re-add scoped `backward.defeqAttrib.useBackward true` on `Mon.uniqueHomToTrivial` and `yonedaMonFullyFaithful` for compatibility with the nightly Lean toolchain. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * add missing imports (as public) * chore: bump to nightly-2026-05-06 * Update lean-toolchain for https://github.com/leanprover/lean4/pull/13613 * chore: bump to nightly-2026-05-07 * fix * remove `change` tactics flagged by unusedTactics linter * fix * fix * fix * fix * fix * fixes * fixes * fixes * fixes * adaptation note * linting * Apply suggestions from code review Co-authored-by: Kim Morrison <477956+kim-em@users.noreply.github.com> * chore: revert spurious blank-line additions Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: revert remaining spurious blank-line additions Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: undo over-eager blank-line reverts (restore lines from PR base) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Apply suggestions from code review Co-authored-by: Kim Morrison <477956+kim-em@users.noreply.github.com> * fix: restore mapFreeIso_hom lemma from #38341 Lost during the master-merge resolution in 7aa60c9cea7. The upstream refactor in #38341 introduced this lemma; the merge dropped it because the adaptation branch had reorganised the surrounding declarations. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix: drop stale Reorder defs re-added during merge `Reorder.permuteUniv` and `Reorder.isEmpty` (on the pre-#36604 shape of `Reorder`) were deleted by #36604 when the structure was renamed to `ArgReorder` and a new `Reorder` wrapper was introduced. They were accidentally re-added during a merge resolution and reference a `Reorder` type that is not yet in scope at that point. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore(RingTheory/Bialgebra/TensorProduct): enable `backward.defeqAttrib.useBackward` for `comm` The `rw [comul a]` inside `comm` no longer matches after upstream changes to defeq attribute handling. Locally re-enabling the backward behaviour with `set_option backward.defeqAttrib.useBackward true` restores the previous elaboration and lets the existing proof go through. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: leanprover-community-mathlib4-bot <leanprover-community-mathlib4-bot@users.noreply.github.com> Co-authored-by: Joachim Breitner <mail@joachim-breitner.de> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Co-authored-by: mathlib-nightly-testing[bot] <mathlib-nightly-testing[bot]@users.noreply.github.com> Co-authored-by: Dagur Asgeirsson <dagurtomas@gmail.com> Co-authored-by: Julia Markus Himmel <2065352+TwoFX@users.noreply.github.com> Co-authored-by: Joël Riou <joel.riou@universite-paris-saclay.fr> Co-authored-by: Kyle Miller <kmill31415@gmail.com> Co-authored-by: Kim Morrison <kim.morrison@anu.edu.au> Co-authored-by: Sebastian Ullrich <sebasti@nullri.ch> * fixes * fixes * fix * fix * chore: bump to nightly-2026-05-11 * partial fixes * Update lean-toolchain for https://github.com/leanprover/lean4/pull/13636 * fixes * fix * fix * chore: remove orphan blank lines left by f46fb2595a2 strip The strip commit f46fb2595a ("strip all `set_option backward.defeqAttrib.useBackward true`") deleted only the set_option line; for files where it had been inserted between two blank lines (typically right after `@[expose] public section`), the deletion left an extra blank line behind. That orphan blank then surfaces as PR-diff noise on every nightly bump branch forked from those files. Eighteen files still carry this orphan on nightly-testing; remove the extra blank in each. No code change. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: adaptations for nightly-2026-05-10 (#219) * Update lean-toolchain for https://github.com/leanprover/lean4/pull/13636 * Update lean-toolchain for https://github.com/leanprover/lean4/pull/13636 * refactor: use `simpa using!` for lean4 PR 13636 (reducible-close) * chore: bump batteries pin to 5796d42 (simpa using! transformation) * fix: convert 10 additional sites to `simpa using!` (post-Jack-wrapping master drift) * Update lean-toolchain for https://github.com/leanprover/lean4/pull/13636 * fix: convert 11 more sites to `simpa using!` (second batch) * fix: revert over-converted using! in non-simpa tactics (filter_upwards, convert, induction) * fix: convert ~14 more sites to `simpa using!` (third batch + WittVector macro) * fix: convert 4 more sites to `simpa using!` (fourth batch) * fix: convert 4 more sites to `simpa using!` (fifth batch) * fix: convert 7 more sites to `simpa using!` (sixth batch) * fix: convert 9 more sites to `simpa using!` (seventh batch) * chore: bump to nightly-2026-05-12 * fix: convert 2 more sites to `simpa using!` (eighth batch) * fix: convert 9 more sites to `simpa using!` (ninth batch) * fix: convert 1 more site to `simpa using!` (tenth batch) * fix: convert 2 more sites to `simpa using!` (eleventh batch) * fix: line 194 of ZMod (missed in previous batch) * style: split long lines exceeding 100 chars after `using!` conversion * fix: restructure Ramification.lean simpa to single-line (line-split broke parser in struct literal) * fix: revert using! to using in FunctorExtension (test if Mathlib master simp lemmas resolve) * fix: restore FunctorExtension and Filtration to pristine (using! conversion was incorrect) * fix: restore FunctorExtension/Filtration with using! + disable longLine linter for affected decls * Update lean-toolchain for testing https://github.com/leanprover/lean4/pull/13715 * fixes * update simps config * fix test * update * fix: add `simpaUsingBang` to flexible linter's allowed-finishers set * fix: convert 9 Archive sites to `simpa using!` * fix: convert 7 Counterexamples sites to `simpa using!` * docstrings to appease linter * style: split long line in DimensionPolynomial * chore(nightly-testing): fix build after lean updates Drop the no-longer-existing `Mathlib.Tactic.Linter.DeprecatedModule` import from two deprecation stubs, and add `set_option backward.defeqAttrib.useBackward true in` to the simps-generated natural transformation in `Nondegenerate.lean`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Update lean-toolchain for https://github.com/leanprover/lean4/pull/13651 * chore: fix `WhitespaceLinter` test * chore: bump to nightly-2026-05-13 * chore: adaptations for nightly-2026-05-13 * chore: adaptations for nightly-2026-05-11 (#220) Co-authored-by: mathlib-nightly-testing[bot] <mathlib-nightly-testing[bot]@users.noreply.github.com> * chore: adaptations for nightly-2026-05-12 (#221) Co-authored-by: Kim Morrison <kim@tqft.net> Co-authored-by: mathlib4-bot <github-mathlib4-bot@leanprover.zulipchat.com> Co-authored-by: Kim Morrison <477956+kim-em@users.noreply.github.com> * chore: adaptations for nightly-2026-05-13 (#222) Co-authored-by: Kim Morrison <kim@tqft.net> Co-authored-by: mathlib4-bot <github-mathlib4-bot@leanprover.zulipchat.com> Co-authored-by: Kim Morrison <477956+kim-em@users.noreply.github.com> * chore: adaptations for nightly-2026-05-13 (#223) Co-authored-by: Kim Morrison <kim@tqft.net> Co-authored-by: mathlib4-bot <github-mathlib4-bot@leanprover.zulipchat.com> Co-authored-by: Kim Morrison <477956+kim-em@users.noreply.github.com> * chore: bump to nightly-2026-05-14 * chore: adaptations for nightly-2026-05-14 * Update lean-toolchain for https://github.com/leanprover/lean4/pull/13651 * chore: adaptations for nightly-2026-05-14 (#224) * chore: add useBackward to failing decls (round 13) * chore: partial adds in round 14 (4 files still need manual fix) * fix: scope useBackward at more decl sites (round 14 manual fixes) * chore: useBackward on mapComp'_inv_naturality and pullHom_pullHom (doesn't fix IsPrestack yet) * chore: partial attempts in IsPrestack (remains broken) * chore: add useBackward to failing decls (round 15) * fix: Stalk.lean needs useBackward on 4 decls * chore: add useBackward to failing decls (round 16) * fix: add useBackward to mapComp'₀₂₃_inv_comp_mapComp'₀₁₃_hom and variants * chore: round 17 partial (DescentData still broken) * chore: partial useBackward on DescentData (still broken) * chore: partial DescentData fixes (still has cascading issues) * chore: file-level useBackward on DescentData, minor proof edits * chore: OpenImmersion.lean useBackward * chore: partial DescentData - line 352 still has metavar issue * fix: DescentData + useBackward on mapComp'₀₂₃_hom * chore: round 18 partial * fix: Precoverage.lean file-level useBackward * chore: round 20 * fix: `add_set_option.py` skip `variable`/`include`/`omit`/`open` lines The walk-back heuristic lands on the first blank line above the error, but then needs to advance past non-declaration preamble lines to reach an actual target of `set_option ... in`. Previously the script would insert before `variable`, producing invalid syntax; now it skips past such statements. * chore: round 21 (GammaSpecAdjunction, Gluing) * Revert "fix: `add_set_option.py` skip `variable`/`include`/`omit`/`open` lines" This reverts commit a3a71e3288d5a7899b501579a32531b7a207d08a. * chore: round 22 * chore: round 23 * chore: script-fixed 36 more mathlib modules with useBackward * fix: add useBackward to 3 decls in Representability.lean * chore: remove unused simp arguments (326 across 123 files) Added scripts/fix_unused_simp_args.py which parses the \"This simp argument is unused\" warnings from a lake build log and rewrites the corresponding simp call. For plain arguments it drops them; for \`← X\` arguments it rewrites to \`- X\` (simp's own hint notes the \`←\` form has side effects on the simp set even when the rewrite itself is unused, so the \`-\` form preserves that behavior while silencing the warning). * chore: fix long lines, `show` -> `change`, drop unused `- X` simp args * chore: one more long-line fix * Update lean-toolchain for https://github.com/leanprover/lean4/pull/13492 * chore: useBackward on 3 MathlibTest files for lake test * Empty line * Bump batteries * Update lean-toolchain for https://github.com/leanprover/lean4/pull/13492 * doc(scripts): document new helpers (fix_unused_simp_args.py, fix_long_lines.py, *_module_set_option.py, fix_nonlocal_set_option.py) * chore: add `simpNF` nolints for 178 lemmas that simp can now prove Under the stricter `@[defeq]` inference the set of theorems that `simp` treats as reflexivity-lemmas shrank slightly, which means a number of previously-accepted `@[simp]` lemmas can now be derived from other simp lemmas and so fail the `simpNF` linter. Add them to `nolints.json` rather than individually removing the `@[simp]` attribute, since the ideal long-term fix (actually removing the attributes) is better done in follow-up PRs with proper code-review of each individual lemma. * chore: bump to nightly-2026-04-23 * cleanup * revert an unnecessary change * revert unnecessary changes * add adaptation notes * minor fixes, whitespace and PR links * adaptation notes * two improvements * fix * fix FilteredColimitCommutesFiniteLimit * fix IsPrestack * improvements * improvements * fix extra degeneracy * small improvement in DerivedCategory/Ext * slightly improve the proof in Limits/Shapes/Equalizers.lean * removed adaptation note for DerivedCategory/Ext/Map * More * chore: bump to nightly-2026-04-24 * adapt to lean4#13363: canUnfoldAtMatcher allowlist changes Adapt proofs to lean4#13363 which replaces the transparency bump from `.reducible` to `.instances` in `whnfMatcher` with an explicit allowlist in `canUnfoldAtMatcher`. Class projections like `CategoryStruct.comp`, `CategoryStruct.id`, `Stream.next?`, `Min.min` etc. are no longer auto-unfolded in match discriminants and need explicit unfolding in proofs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * chore: remove unused helper lemmas from Ordinal/Notation adaptation Remove `zero_zero_eq`, `one_one_eq`, `repr_zero'`, and `ofNat_unfold` which were added during the lean4#13363 adaptation but are not used in any proofs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Update lean-toolchain for https://github.com/leanprover/lean4/pull/13363 * more cleaningup * adapt Limits/Shapes/ConcreteCategory to lean4#13363 Use `WalkingMulticospan.Hom.id_eq_id` and `Functor.map_id` to reduce stuck matches on `𝟙` in WalkingMulticospan naturality proofs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Bump batteries * Update lean-toolchain for https://github.com/leanprover/lean4/pull/13363 * chore: bump to nightly-2026-04-25 * Update lean-toolchain for testing https://github.com/leanprover/lean4/pull/13528 * satisfy linter * fixes * archive and counterexamples * fix: round 30 - Pi/Basic + TensorProduct/Pi after nightly merge * chore: round 32 fixed by script * chore: round 33 (5 of 6 fixed by script) * fix: Biproducts isoCoproduct simp leaves isTrue goal needing subst * chore: round 34 (3 of 5 by script) * fix: round 34 SequentialProduct + StdSimplex * chore: round 35 * chore: round 36 * chore: round 37 * chore: round 37 - remove unused simp args * chore: avoid 'adaptation note' substring in adaptation note bodies * chore: round 41 (2 of 3 fixed by script) * chore: resolve merge conflict in Sheaf/Free.lean Drop the leftover ιFree_mapFree_inv lemma from the adaption branch; the upstream refactor (mapFreeIso) replaces it and provides a deprecated alias. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: nolint two simpNF auto-generated lemmas These are @[simps]-style auto-generated lemmas whose LHS now simplifies via new simp set behavior; nolint to keep adaption focused. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Remove my custom scripts used for managing lean4#13492 migration * chore: bump to nightly-2026-04-27 * Update lean-toolchain for https://github.com/leanprover/lean4/pull/13528 * chore: bump to nightly-2026-04-28 * Update lean-toolchain for https://github.com/leanprover/lean4/pull/13528 * chore: drop stale `DeprecatedModule` import in `RingTheory/Regular/Depth` The internal `Mathlib.Tactic.Linter.DeprecatedModule` module was removed on master in 9037b087ee0; `deprecated_module` is now a built-in Lean command. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: extend `lean-pr-testing-13492` set_option pattern to remaining decls Newly-added or master-merged declarations need the same `set_option backward.defeqAttrib.useBackward true in` adaptation as the rest of the lean4#13492 mathlib branch. One genuine proof-level breakage remains in `AlternatingFaceMapComplex.ε.naturality` (line 233). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(AlgebraicTopology): repair `ε.naturality` under stricter defeq Under lean4#13492, `simp [ChainComplex.toSingle₀Equiv]` no longer expands the `(toSingle₀Equiv).symm.f 0` redex. Use the explicit projection lemma `ChainComplex.toSingle₀Equiv_symm_apply_f_zero` instead. Includes `#adaptation_note`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: extend `useBackward` set_option to two more pushout-product files Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: remove redundant `@[expose]` attributes flagged by lean4#13359 The new `warn.redundantExpose` linter from lean4#13359 reports that these declarations would be exposed by default, so the explicit attribute is redundant. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: add `@[expose] public section` to silence private-module warning Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: drop redundant `@[simp]` from `Pretriangulated.{id,comp}_hom₁/₂/₃` Under lean4#13492's stricter defeq, `(f ≫ g).hom₃` already simplifies via the `@[simps]`-generated `triangleCategory_comp` to the form these manually-written simp lemmas were producing, so simpNF now reports them as redundant. Lemmas remain available as named references (just not `@[simp]`). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: drop redundant `@[simp]` from `coe_id`/`coe_comp` in `Order.Category` Under lean4#13492's stricter defeq, the `ConcreteCategory` simp lemmas already cover these — the file comment already noted they are duplicates "kept for `dsimp`". Lemmas remain available as named references. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: drop redundant `@[simp]` flagged by simpNF in CategoryTheory + Topology Under lean4#13492's stricter defeq, several auto-generated and manually-written `@[simp]` lemmas in `CategoryTheory.{Comma/Over,Core, Functor/KanExtension,Limits/Shapes/Pullback/Iso,ObjectProperty,Sites}, Topology.Category.TopCat.OpenNhds` are flagged as having LHSs that simplify further. Drop the offending `@[simp]` (via `attribute [-simp]` on `@[simps]`-generated lemmas, by trimming the `@[simps]` projection list, or by removing `@[simp]` from manually-written ones). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: drop more `@[simp]` flagged by simpNF as 'LHS simplifies from' Finishes Phase 1 of the lean4#13492 simpNF cleanup on `nightly-testing`: the remaining `Left-hand side simplifies from` reports become non-simp lemmas (or have the corresponding `@[simps]` projection's `@[simp]` removed via `attribute [-simp]`). Lemmas remain available as named references. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: drop redundant `@[simp]` from `coe_id`/`coe_comp` in `Algebra.Category` Mirror of the `Order.Category` fixes — these `@[to_additive (attr := simp)]` lemmas are explicitly documented as duplicates of the `ConcreteCategory` simp lemmas kept "for `dsimp`". Under lean4#13492's stricter defeq, simp can already prove them, so drop the simp attribute. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: drop redundant `@[simps!]` on `WeierstrassCurve.{Affine,Jacobian,Projective}.{map,baseChange}` These are `abbrev`s aliasing the underlying `WeierstrassCurve.{map,baseChange}`, whose `@[simps]`-generated lemmas (`WeierstrassCurve.map_a₁`, etc.) already cover what these abbreviations expose. Under lean4#13492's stricter defeq the simpNF linter flags every `_a₁`...`_a₆` projection as provable by simp. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: drop redundant `@[simps!]`/`@[simp]` in CategoryTheory bicategory + monoidal Continues the lean4#13492 simpNF cleanup: - `Bicategory.Opposites.{op2,op2_unop,unop2,unop2_op}`: drop `@[simps!]` - `Monoidal.Action.Basic.{actionLeft,actionRight}` (×2): drop `@[simps!]` - `Bicategory.Functor.LocallyDiscrete.toOplaxFunctor{,'}`: trim `@[simps!]` projection list to just `map` (the others are redundant) - `Monoidal.Grp.{id,comp}_hom_hom`: drop `@[simp]` - `Monoidal.Grp.mkIso`: keep `@[simps!]` (the auto-generated lemmas are referenced by `@[deprecated] alias`) but `attribute [-simp]` on the flagged projections. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: trim more `@[simp]`/`@[simps]` flagged by simpNF Continues the lean4#13492 cleanup, mostly trimming `@[simps]` projection lists or dropping `@[simp]` attributes (`Bicategory.LocallyGroupoid`, `Monoidal.Mon.mkIso`, `Comma.{toPUnitIdEquiv,toIdPUnitEquiv}`, `Combinatorics.Graph.noEdge`, `RootSystem.Equiv.comp`, `Group.Equiv.{monoid,addMonoid}HomCongr{Left,Right}Equiv`, `Free{Magma,Semigroup}.{map_pure,pure_bind}`). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: trim more `@[simps]`/`@[simp]` flagged by simpNF (batch 4) - `NonUnitalAlgHom.{fst,snd,prod}`: `@[simps]` → `@[simps toFun]` - `Unitization.{lift,starLift}`: drop `apply_apply` from `@[simps!]` list - `Unitization.inrNonUnitalAlgHom`: `@[simps]` → `@[simps toFun]` - `Cat.Hom.comp_obj`, `Cat.{whiskerLeft,whiskerRight}_app`: drop `@[simp]` - `Graph.copy`: `@[simps]` → `@[simps -isSimp]` + add `[copy]` to `simp_all` in `copy_eq` proof Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: trim more `@[simps]`/`@[simp]` flagged by simpNF (batch 5, big) Continues the lean4#13492 simpNF cleanup across the long-tail 2-error and 1-error files. Pattern is consistent: trim the `@[simps]` projection list to drop the redundant projection, or drop `@[simp]` (or its `(attr := simp)` to_additive directive) on a manually-written lemma. For a few cases where the auto-generated lemma is referenced downstream, the `@[simps!]` is kept and `attribute [-simp]` is used to drop only the `@[simp]` status. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: bump to nightly-2026-04-29 * chore: fix namespace context in `attribute [-simp]` calls Inside `namespace Foo`, `attribute [-simp] Foo.bar` is interpreted relative to the current namespace and fails to resolve. Use `_root_.` prefix on the fully-qualified name so the directive actually fires. This fixes ~12 of the simpNF errors that the previous batches were intended to address but where the directive was a no-op. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: trim more simpNF-flagged simp lemmas (batch 6) Reduces simpNF lint errors from 56 → 20. Patterns used: - For `@[to_additive (attr := simp)]` cases where only the additive version is flagged, switch to `@[to_additive] / attribute [simp] foo` pattern, which puts simp only on the multiplicative version. - For redundant `_symm_apply` lemmas auto-generated by `@[simps]` on equivs, switch to `@[simps apply]` (omitting the redundant `_symm_apply` projection). - For deeper-recursion projections like `_val_inv_*` in `@[simps!]` on Units-of-Units structures, drop `@[simps]` entirely or restrict the projection list. - Manually-written `@[simp]` lemmas redundant with other simp lemmas: drop `@[simp]`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: trim more simpNF-flagged simps via explicit projection lists Reduces simpNF lint errors from 20 → 11. Pattern used: switch from `@[simps!]` + `attribute [-simp] foo` (which doesn't actually remove simp from `simps!`-generated lemmas in this lean version) to either: - `@[simps! GOOD_PROJECTIONS]` listing only projections that should remain simp lemmas, omitting the redundant deep-recursion ones; or - `@[simps! TOP_PROJECTIONS]` plus a manually-written non-simp theorem for the remaining declaration name (e.g. `noEdge_isLink`). Files: Combinatorics/Graph/Basic, CategoryTheory/Comma/Over/Basic, CategoryTheory/Core, Analysis/Normed/Module/PiTensorProduct/InjectiveSeminorm. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: drop redundant `@[simp]` from def equation lemmas Removes `@[simp]` from `def addY`, `def piPremeasure`, `def zeroDefaultSupp`, `def equivExterior` (in WeierstrassCurve, MeasureTheory, Plausible, CliffordAlgebra). The auto-generated `_eq_1` equation lemmas for these defs are redundant given other simp lemmas, per simpNF. Adjusts `Petersson.lean` to drop `-Matrix.SpecialLinearGroup.coe_matrix_coe` from a simp arg list since that lemma is no longer simp. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Update lean-toolchain for https://github.com/leanprover/lean4/pull/13528 * adaptation notes about nolint simpNF * chore: nolint simpNF on auto-generated equation lemmas The previous commit added `nolint simpNF` to the parent `def`s, but the linter still complained about their auto-generated `.eq_1`/`.eq_2` equation lemmas. Add explicit `attribute [nolint simpNF]` for each. Also fix Contraction.lean: the `#adaptation_note` was placed between the doc-comment and the `def`, which is a syntax error. Move it before the doc-comment. Linter is now clean. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: add adaptation_note to each `attribute [nolint simpNF]` Followup to a3dbe9e910c: each bare `attribute [nolint simpNF]` for the `.eq_1`/`.eq_2` lemmas now has its own `#adaptation_note` so it can be grepped for and revisited. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * lake update batteries * chore: fix mutual instance + filtered closure rfl failures Two unrelated breakages exposed by the master merge: * `Mathlib/SetTheory/Lists.lean`: the `mutual` block of three `instance` declarations now triggers an "instance `..._mutual` target ... is not a type class" error from the new mutual-instance handling. Switch the mutual-block declarations to `def` and add a separate `attribute [instance]` afterwards. The old workaround `attribute [nolint nonClassInstance] Lists.Equiv.decidable._mutual` is no longer needed. * `Mathlib/CategoryTheory/Filtered/Small.lean`: two `rfl` calls in `small_fullSubcategory_{filtered,cofiltered}Closure` started failing under the new defeq regime. Wrap both theorems with `set_option backward.defeqAttrib.useBackward true in`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: bump to nightly-2026-04-30 * chore: bump to nightly-2026-05-01 * chore: bump to nightly-2026-05-02 * fix * adaptation note * fix bad merge * adaptation notes * fix * fixes * attributes * fixes * fixes via attributes * fixes * linter * nolint * Update lean-toolchain for testing https://github.com/leanprover/lean4/pull/13613 * chore: bump to nightly-2026-05-03 * remove unneeded simp * Update lean-toolchain for https://github.com/leanprover/lean4/pull/13613 * chore: bump to nightly-2026-05-04 * fixes * Apply suggestions from code review Co-authored-by: Kim Morrison <477956+kim-em@users.noreply.github.com> * fixes from nightly-testing * lake-manifest * lake-manifest * fix from nightly-testing * fix test * chore: bump to nightly-2026-05-05 * chore: restore @[to_additive (attr := simp)] symmetry PR 215 rewrote a number of `@[to_additive (attr := simp)]` attributes to `@[to_additive]`, sometimes followed by an asymmetric `attribute [simp]` on only one side of the to_additive pair. Restore the original symmetric form everywhere this pattern appears. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Revert "chore: restore @[to_additive (attr := simp)] symmetry" This reverts commit d79879fec19f7f3ea2ab4f2f038661047c74e7c4. * fix(to_additive): propagate @[defeq] symmetrically to additive translations Under lean4#13492's stricter `@[defeq]` inference, `inferDefEqAttr` only tags a theorem `@[defeq]` if its rfl proof passes `withReducibleAndInstances <| isDefEq lhs rhs`. For `to_additive`-generated additive lemmas this check fails systematically — even on cases like `AddMonoidHom.coe_id` whose proof is rfl and whose multiplicative source `MonoidHom.coe_id` is `@[defeq]`. The result was a divergence: `dsimp` reduced `(𝟙 X : X → X)` to `id` for `X : GrpCat` but stopped at `⇑(AddMonoidHom.id X)` for `X : AddGrpCat`, which made simpNF flag a host of additive `coe_id`/`coe_comp` lemmas as redundant simp lemmas even though their multiplicative twins were fine. Fix: in `to_additive`'s `defeqAttr` propagation, after calling `inferDefEqAttr` on the target, promote it to `@[defeq]` whenever the source is `@[defeq]` and the target is at least `@[backward_defeq]` (i.e. rfl-shaped). The translation preserves rfl-ness, so a multiplicative `@[defeq]` source implies the additive translation should also be `@[defeq]` for symmetric `dsimp` behaviour. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: restore @[to_additive (attr := simp)] symmetry PR 215 rewrote a number of `@[to_additive (attr := simp)]` attributes to `@[to_additive]`, sometimes followed by an asymmetric `attribute [simp]` on only one side of the to_additive pair. Restore the original symmetric form everywhere this pattern appears. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: drop redundant @[simps!] on Mon.mkIso / AddMon.mkIso `mkIso` is an abbrev for `mkIso'`, and `mkIso'` already has `@[simps]`. The `simps!` projections of `mkIso` would just rederive what `simps` on `mkIso'` already provides, and simpNF rightly flags the duplicates. Dropping the `(attr := simps!)` here matches PR 215's original intent and leaves the `@[to_additive (attr := simp)]` symmetry restoration in place for the rest. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * deprecation * fix * deprecation * chore: restore lost content from #38972 merge in Cartesian/Mon.lean The merge of master into nightly-testing dropped the `IsMonHom (toUnit M)`, `IsMonHom η[M]`, `Mono η[M]` instances in the `SemiCartesianMonoidalCategory` section, plus `IsMonHom.monoidHom` and the matching `yonedaMon.map`. Restore upstream/master's version of the file and re-add scoped `backward.defeqAttrib.useBackward true` on `Mon.uniqueHomToTrivial` and `yonedaMonFullyFaithful` for compatibility with the nightly Lean toolchain. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * add missing imports (as…
1 parent 847812f commit 2234dda

23 files changed

Lines changed: 218 additions & 200 deletions

File tree

Cache/IO.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ TODO: write a better predicate. -/
2929
def isPartOfMathlibCache (mod : Name) : Bool := #[
3030
`Mathlib,
3131
`Batteries,
32+
`BatteriesRecycling,
3233
`Aesop,
3334
`Cli,
3435
`ImportGraph,

Mathlib/CategoryTheory/Monoidal/OfHasFiniteProducts.lean

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ variable [PreservesLimit (Functor.empty.{0} C) F]
181181
[PreservesLimitsOfShape (Discrete WalkingPair) F]
182182

183183
set_option backward.defeqAttrib.useBackward true in
184+
set_option linter.deprecated false in
184185
@[deprecated inferInstance (since := "2025-10-19")]
185186
instance :
186187
have : HasFiniteProducts C := hasFiniteProducts_of_has_binary_and_terminal
@@ -190,6 +191,7 @@ instance :
190191
IsIso (η F) := by dsimp [η_eq]; apply instIsIsoTerminalComparison
191192

192193
set_option backward.defeqAttrib.useBackward true in
194+
set_option linter.deprecated false in
193195
@[deprecated inferInstance (since := "2025-10-19")]
194196
instance (X Y : C) :
195197
have : HasFiniteProducts C := hasFiniteProducts_of_has_binary_and_terminal

Mathlib/CategoryTheory/MorphismProperty/Local.lean

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,13 @@ instance inf (P Q : MorphismProperty C) [IsLocalAtTarget P K] [IsLocalAtTarget Q
135135

136136
end IsLocalAtTarget
137137

138-
alias of_zeroHypercover_target := IsLocalAtTarget.of_zeroHypercover
138+
set_option backward.defeqAttrib.useBackward true in
139+
lemma of_zeroHypercover_target {P : MorphismProperty C} {K : Precoverage C} [K.HasPullbacks]
140+
[P.IsLocalAtTarget K] {X Y : C} {f : X ⟶ Y} (𝒰 : Precoverage.ZeroHypercover.{w} K Y)
141+
[Precoverage.ZeroHypercover.Small.{v} 𝒰] (h : ∀ i, P (pullback.snd f (𝒰.f i))) :
142+
P f := by
143+
rw [IsLocalAtTarget.iff_of_zeroHypercover (P := P) 𝒰.restrictIndexOfSmall]
144+
simp [h]
139145

140146
alias iff_of_zeroHypercover_target := IsLocalAtTarget.iff_of_zeroHypercover
141147

@@ -211,7 +217,13 @@ instance inf (P Q : MorphismProperty C) [IsLocalAtSource P K] [IsLocalAtSource Q
211217

212218
end IsLocalAtSource
213219

214-
alias of_zeroHypercover_source := IsLocalAtSource.of_zeroHypercover
220+
set_option backward.defeqAttrib.useBackward true in
221+
lemma of_zeroHypercover_source {P : MorphismProperty C} {K : Precoverage C}
222+
[P.IsLocalAtSource K] {X Y : C} {f : X ⟶ Y} (𝒰 : Precoverage.ZeroHypercover.{w} K X)
223+
[Precoverage.ZeroHypercover.Small.{v} 𝒰] (h : ∀ i, P (𝒰.f i ≫ f)) :
224+
P f := by
225+
rw [IsLocalAtSource.iff_of_zeroHypercover (P := P) 𝒰.restrictIndexOfSmall]
226+
simp [h]
215227

216228
alias iff_of_zeroHypercover_source := IsLocalAtSource.iff_of_zeroHypercover
217229

Mathlib/Data/Fin/Tuple/Reflection.lean

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,10 @@ open Lean Meta Qq
175175
that shows it is equal to `∏ i, f i`. -/
176176
meta def mkProdEqQ {u : Level} {α : Q(Type u)}
177177
(inst : Q(CommMonoid $α)) (n : ℕ) (f : Q(Fin $n → $α)) :
178-
MetaM <| (val : Q($α)) × Q(∏ i, $f i = $val) := do
178+
MetaM <| (val : Q($α)) × Q(∏ i, $f i = $val) :=
179179
match n with
180-
| 0 => return ⟨q((1 : $α)), q(Fin.prod_univ_zero $f)⟩
181-
| m + 1 =>
180+
| 0 => do return ⟨q((1 : $α)), q(Fin.prod_univ_zero $f)⟩
181+
| m + 1 => do
182182
let nezero : Q(NeZero ($m + 1)) := q(⟨Nat.succ_ne_zero _⟩)
183183
let val ← makeRHS (m + 1) f nezero (m + 1)
184184
let _ : $val =Q FinVec.prod $f := ⟨⟩
@@ -198,10 +198,10 @@ where
198198
that shows it is equal to `∑ i, f i`. -/
199199
meta def mkSumEqQ {u : Level} {α : Q(Type u)}
200200
(inst : Q(AddCommMonoid $α)) (n : ℕ) (f : Q(Fin $n → $α)) :
201-
MetaM <| (val : Q($α)) × Q(∑ i, $f i = $val) := do
201+
MetaM <| (val : Q($α)) × Q(∑ i, $f i = $val) :=
202202
match n with
203203
| 0 => return ⟨q((0 : $α)), q(Fin.sum_univ_zero $f)⟩
204-
| m + 1 =>
204+
| m + 1 => do
205205
let nezero : Q(NeZero ($m + 1)) := q(⟨Nat.succ_ne_zero _⟩)
206206
let val ← makeRHS (m + 1) f nezero (m + 1)
207207
let _ : $val =Q FinVec.sum $f := ⟨⟩
@@ -228,7 +228,7 @@ open Qq Lean FinVec
228228
simproc_decl prod_univ_ofNat (∏ _ : Fin _, _) := .ofQ fun u _ e => do
229229
match u, e with
230230
| .succ _, ~q(@Finset.prod (Fin $n) _ $inst (@Finset.univ _ $instF) $f) => do
231-
match (generalizing := false) n.nat? with
231+
match n.nat? with
232232
| none =>
233233
return .continue
234234
| some nVal =>

Mathlib/Init.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ run_cmd liftTermElabM do
136136
let DefinedInScripts : Array Name :=
137137
#[`linter.checkInitImports, `linter.allScriptsDocumented]
138138
let env ← getEnv
139-
let ls := linterSetsExt.getEntries env
139+
let ls := (linterSetsExt.getState env).localEntries
140140
let some (_, mlLinters) := ls.find? (·.1 == ``linter.mathlibStandardSet) |
141141
throwError m!"'linter.mathlibStandardSet' is not defined."
142142
let some (_, nrLinters) := ls.find? (·.1 == ``linter.nightlyRegressionSet) |

Mathlib/Tactic/Algebra/Basic.lean

Lines changed: 40 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -165,24 +165,24 @@ namespace RingCompute
165165

166166
/-- Evaluate the sum of two normalized expressions in `R` using `ring`. -/
167167
def add (cR : Common.Cache sR) {a b : Q($A)} (za : BaseType sAlg a) (zb : BaseType sAlg b) :
168-
MetaM (Common.Result (BaseType sAlg) q($a + $b) × Option Q(IsNat ($a + $b) 0)) := do
169-
let ⟨r, vr⟩ := za
170-
let ⟨s, vs⟩ := zb
171-
let ⟨t, vt, pt⟩ ← Common.evalAdd (Ring.ringCompute cR) rcℕ vr vs
172-
match vt with
173-
| .zero =>
174-
have : $t =Q 0 := ⟨⟩
175-
return ⟨⟨_, .mk _ vt, q(add_algebraMap $pt)⟩, some q(add_algebraMap_isNat_zero $pt)⟩
176-
| vt =>
177-
return ⟨⟨_, .mk _ vt, q(add_algebraMap $pt)⟩, none⟩
168+
MetaM (Common.Result (BaseType sAlg) q($a + $b) × Option Q(IsNat ($a + $b) 0)) :=
169+
match za, zb with
170+
| .mk r vr, .mk s vs => do
171+
let ⟨t, vt, pt⟩ ← Common.evalAdd (Ring.ringCompute cR) rcℕ vr vs
172+
match (dependent := true) vt with
173+
| .zero =>
174+
have : $t =Q 0 := ⟨⟩
175+
return ⟨⟨_, .mk _ vt, q(add_algebraMap $pt)⟩, some q(add_algebraMap_isNat_zero $pt)⟩
176+
| vt =>
177+
return ⟨⟨_, .mk _ vt, q(add_algebraMap $pt)⟩, none⟩
178178

179179
/-- Evaluate the product of two normalized expressions in `R` using `ring`. -/
180180
def mul (cR : Common.Cache sR) {a b : Q($A)} (za : BaseType sAlg a) (zb : BaseType sAlg b) :
181-
MetaM (Common.Result (BaseType sAlg) q($a * $b)) := do
182-
let ⟨r, vr⟩ := za
183-
let ⟨s, vs⟩ := zb
184-
let ⟨t, vt, pt⟩ ← Common.evalMul (Ring.ringCompute cR) rcℕ vr vs
185-
return ⟨_, .mk _ vt, q(by simp [← $pt, map_mul])⟩
181+
MetaM (Common.Result (BaseType sAlg) q($a * $b)) :=
182+
match za, zb with
183+
| .mk r vr, .mk s vs => do
184+
let ⟨t, vt, pt⟩ ← Common.evalMul (Ring.ringCompute cR) rcℕ vr vs
185+
return ⟨_, .mk _ vt, q(by simp [← $pt, map_mul])⟩
186186

187187
/-- Take an expression `r'` in a ring `R'` such that `R` is an `R'`-algebra and cast `r'` to `R`
188188
using `algebraMap R' R`, so that the scalar multiplication action on `A` is preserved. -/
@@ -195,7 +195,7 @@ def cast (cR : Algebra.Cache sR) (u' : Level) (R' : Q(Type u'))
195195
let ⟨r, pf_smul⟩ ← evalSMulCast q($sAlg) q($_smul) r'
196196
let ⟨_r'', vr, pr⟩ ←
197197
Common.eval rcℕ (Ring.ringCompute cR.toCache) cR.toCache q($r)
198-
match vr with
198+
match (dependent := true) vr with
199199
| .zero .. =>
200200
assumeInstancesCommute
201201
return ⟨_, .zero, q(cast_zero_smul_eq_zero_mul $pr $pf_smul)⟩
@@ -206,37 +206,40 @@ def cast (cR : Algebra.Cache sR) (u' : Level) (R' : Q(Type u'))
206206

207207
/-- Evaluate the product of two normalized expressions in `R` using `ring`. -/
208208
def neg (cR : Algebra.Cache sR) {a : Q($A)} (_rA : Q(CommRing $A)) (za : BaseType sAlg a) :
209-
MetaM (Common.Result (BaseType sAlg) q(-$a)) := do
210-
let ⟨r, vr⟩ := za
211-
match cR.rα with
212-
| some rR =>
213-
let ⟨_, vt, pt⟩ ← Common.evalNeg (Ring.ringCompute cR.toCache) q($rR) vr
214-
assumeInstancesCommute
215-
return ⟨_, .mk _ vt, q(neg_algebraMap $pt)⟩
216-
| none => failure
209+
MetaM (Common.Result (BaseType sAlg) q(-$a)) :=
210+
match za with
211+
| .mk r vr => do
212+
match cR.rα with
213+
| some rR =>
214+
let ⟨_, vt, pt⟩ ← Common.evalNeg (Ring.ringCompute cR.toCache) q($rR) vr
215+
assumeInstancesCommute
216+
return ⟨_, .mk _ vt, q(neg_algebraMap $pt)⟩
217+
| none => failure
217218

218219
/-- Raise a normalized expression in `R` to the power of a normalized natural number expression
219220
using `ring`. -/
220221
def pow (cR : Common.Cache sR) {a : Q($A)} {b : Q(ℕ)} (za : BaseType sAlg a)
221222
(vb : Common.ExProdNat q($b)) :
222-
OptionT MetaM (Common.Result (BaseType sAlg) q($a ^ $b)) := do
223-
let ⟨r, vr⟩ := za
224-
let ⟨_, vs, ps⟩ ← Common.evalPow₁ (Ring.ringCompute cR) rcℕ vr vb
225-
return ⟨_, ⟨_, vs⟩, q(pow_algebraMap $ps)⟩
223+
OptionT MetaM (Common.Result (BaseType sAlg) q($a ^ $b)) :=
224+
match za with
225+
| .mk r vr => do
226+
let ⟨_, vs, ps⟩ ← Common.evalPow₁ (Ring.ringCompute cR) rcℕ vr vb
227+
return ⟨_, ⟨_, vs⟩, q(pow_algebraMap $ps)⟩
226228

227229
/-- Evaluate the inverse of two normalized expressions in `R` using `ring`. -/
228230
/- We include the CharZero argument to match the type signature of the ringCompute entry. -/
229231
@[nolint unusedArguments]
230232
def inv (cR : Algebra.Cache sR) {a : Q($A)} (_ : Option Q(CharZero $A)) (fA : Q(Semifield $A))
231-
(za : BaseType sAlg a) : AtomM (Option (Common.Result (BaseType sAlg) q($a⁻¹))) := do
232-
match cR.dsα with
233-
| some fR =>
234-
let ⟨r, vr⟩ := za
235-
let ⟨_, vs, ps⟩ ← Common.ExSum.evalInv (Ring.ringCompute cR.toCache) rcℕ q($fR) cR.czα vr
236-
assumeInstancesCommute
237-
return some ⟨_, ⟨_, vs⟩, q(inv_algebraMap $ps)⟩
238-
| none =>
239-
return none
233+
(za : BaseType sAlg a) : AtomM (Option (Common.Result (BaseType sAlg) q($a⁻¹))) :=
234+
match za with
235+
| .mk r vr => do
236+
match cR.dsα with
237+
| some fR =>
238+
let ⟨_, vs, ps⟩ ← Common.ExSum.evalInv (Ring.ringCompute cR.toCache) rcℕ q($fR) cR.czα vr
239+
assumeInstancesCommute
240+
return some ⟨_, ⟨_, vs⟩, q(inv_algebraMap $ps)⟩
241+
| none =>
242+
return none
240243

241244
/-- Evaluate constants in `A` using `norm_num`. -/
242245
def derive (cR : Algebra.Cache sR) (cA : Algebra.Cache sA) (x : Q($A)) :

Mathlib/Tactic/FieldSimp.lean

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def onExponent (l : qNF M) (f : ℤ → ℤ) : qNF M :=
6262

6363
/-- Build a transparent expression for the product of powers represented by `l : qNF M`. -/
6464
def evalPrettyMonomial (iM : Q(GroupWithZero $M)) (r : ℤ) (x : Q($M)) :
65-
MetaM (Σ e : Q($M), Q(zpow' $x $r = $e)) := do
65+
MetaM (Σ e : Q($M), Q(zpow' $x $r = $e)) :=
6666
match r with
6767
| 0 => /- If an exponent is zero then we must not have been able to prove that x is nonzero. -/
6868
return ⟨q($x / $x), q(zpow'_zero_eq_div ..)⟩
@@ -111,10 +111,10 @@ def removeZeros
111111
of) the negative powers. -/
112112
def split (iM : Q(CommGroupWithZero $M)) (l : qNF M) :
113113
MetaM (Σ l_n l_d : qNF M, Q(NF.eval $(l.toNF)
114-
= NF.eval $(l_n.toNF) / NF.eval $(l_d.toNF))) := do
114+
= NF.eval $(l_n.toNF) / NF.eval $(l_d.toNF))) :=
115115
match l with
116116
| [] => return ⟨[], [], q(Eq.symm (div_one (1:$M)))⟩
117-
| ((r, x), i) :: t =>
117+
| ((r, x), i) :: t => do
118118
let ⟨t_n, t_d, pf⟩ ← split iM t
119119
if r > 0 then
120120
return ⟨((r, x), i) :: t_n, t_d, (q(NF.cons_eq_div_of_eq_div $r $x $pf):)⟩
@@ -125,13 +125,13 @@ def split (iM : Q(CommGroupWithZero $M)) (l : qNF M) :
125125
return ⟨t_n, ((r', x), i) :: t_d, (q(NF.cons_eq_div_of_eq_div' $r' $x $pf):)⟩
126126

127127
private def evalPrettyAux (iM : Q(CommGroupWithZero $M)) (l : qNF M) :
128-
MetaM (Σ e : Q($M), Q(NF.eval $(l.toNF) = $e)) := do
128+
MetaM (Σ e : Q($M), Q(NF.eval $(l.toNF) = $e)) :=
129129
match l with
130130
| [] => return ⟨q(1), q(rfl)⟩
131-
| [((r, x), _)] =>
131+
| [((r, x), _)] => do
132132
let ⟨e, pf⟩ ← evalPrettyMonomial q(inferInstance) r x
133133
return ⟨e, q(by rw [NF.eval_cons]; exact Eq.trans (one_mul _) $pf)⟩
134-
| ((r, x), k) :: t =>
134+
| ((r, x), k) :: t => do
135135
let ⟨e, pf_e⟩ ← evalPrettyMonomial q(inferInstance) r x
136136
let ⟨t', pf⟩ ← evalPrettyAux iM t
137137
have pf'' : Q(NF.eval $(qNF.toNF (((r, x), k) :: t)) = (NF.eval $(qNF.toNF t)) * zpow' $x $r) :=
@@ -144,7 +144,7 @@ def evalPretty (iM : Q(CommGroupWithZero $M)) (l : qNF M) :
144144
let ⟨l_n, l_d, pf⟩ ← split iM l
145145
let ⟨num, pf_n⟩ ← evalPrettyAux q(inferInstance) l_n
146146
let ⟨den, pf_d⟩ ← evalPrettyAux q(inferInstance) l_d
147-
match l_d with
147+
match (dependent := true) l_d with
148148
| [] => return ⟨num, q(eq_div_of_eq_one_of_subst $pf $pf_n)⟩
149149
| _ =>
150150
let pf_n : Q(NF.eval $(l_n.toNF) = $num) := pf_n
@@ -281,14 +281,14 @@ def mkDenomConditionProofSucc {iM : Q(CommGroupWithZero $M)}
281281
(disch : ∀ {u : Level} (type : Q(Sort u)), MetaM Q($type))
282282
{cond : DenomCondition (M := M) q(inferInstance)}
283283
{L : qNF M} (hL : cond.proof L) (e : Q($M)) (r : ℤ) (i : ℕ) :
284-
MetaM (Q($e ≠ 0) × cond.proof (((r, e), i) :: L)) := do
284+
MetaM (Q($e ≠ 0) × cond.proof (((r, e), i) :: L)) :=
285285
match cond with
286286
| .none => return (← disch q($e ≠ 0), Unit.unit)
287-
| .nonzero =>
287+
| .nonzero => do
288288
let pf ← disch q($e ≠ 0)
289289
let pf₀ : Q(NF.eval $(qNF.toNF L) ≠ 0) := hL
290290
return (pf, q(NF.cons_ne_zero $r $pf $pf₀))
291-
| .positive _ _ _ _ =>
291+
| .positive _ _ _ _ => do
292292
let pf ← disch q(0 < $e)
293293
let pf₀ : Q(0 < NF.eval $(qNF.toNF L)) := hL
294294
let pf' := q(NF.cons_pos $r (x := $e) $pf $pf₀)
@@ -301,14 +301,14 @@ def mkDenomConditionProofSucc' {iM : Q(CommGroupWithZero $M)}
301301
(disch : ∀ {u : Level} (type : Q(Sort u)), MetaM Q($type))
302302
{cond : DenomCondition (M := M) q(inferInstance)}
303303
{L : qNF M} (hL : cond.proof L) (e : Q($M)) (r : ℤ) (i : ℕ) :
304-
MetaM (cond.proof (((r, e), i) :: L)) := do
304+
MetaM (cond.proof (((r, e), i) :: L)) :=
305305
match cond with
306306
| .none => return Unit.unit
307-
| .nonzero =>
307+
| .nonzero => do
308308
let pf ← disch q($e ≠ 0)
309309
let pf₀ : Q(NF.eval $(qNF.toNF L) ≠ 0) := hL
310310
return q(NF.cons_ne_zero $r $pf $pf₀)
311-
| .positive _ _ _ _ =>
311+
| .positive _ _ _ _ => do
312312
let pf ← disch q(0 < $e)
313313
let pf₀ : Q(0 < NF.eval $(qNF.toNF L)) := hL
314314
return q(NF.cons_pos $r (x := $e) $pf $pf₀)

Mathlib/Tactic/FieldSimp/Lemmas.lean

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ def Sign.expr : Sign M → Q($M) → Q($M)
398398
the product with `c` of (± `y`) (here taking the specified sign) is ± `c * y`. -/
399399
def Sign.mulRight (iM : Q(CommGroupWithZero $M)) (c y : Q($M)) (g : Sign M) :
400400
MetaM Q($(g.expr q($c * $y)) = $c * $(g.expr y)) := do
401-
match g with
401+
match (dependent := true) g with
402402
| .plus => pure q(rfl)
403403
| .minus _ =>
404404
assumeInstancesCommute
@@ -409,7 +409,7 @@ the product of (± `y₁`) and (± `y₂`) (here taking the specified signs) is
409409
proof and the computed sign. -/
410410
def Sign.mul (iM : Q(CommGroupWithZero $M)) (y₁ y₂ : Q($M)) (g₁ g₂ : Sign M) :
411411
MetaM (Σ (G : Sign M), Q($(g₁.expr y₁) * $(g₂.expr y₂) = $(G.expr q($y₁ * $y₂)))) := do
412-
match g₁, g₂ with
412+
match (dependent := true) g₁, g₂ with
413413
| .plus, .plus => pure ⟨.plus, q(rfl)⟩
414414
| .plus, .minus i =>
415415
assumeInstancesCommute
@@ -425,7 +425,7 @@ def Sign.mul (iM : Q(CommGroupWithZero $M)) (y₁ y₂ : Q($M)) (g₁ g₂ : Sig
425425
the inverse of (± `y`) (here taking the specified sign) is ± `y⁻¹`. -/
426426
def Sign.inv (iM : Q(CommGroupWithZero $M)) (y : Q($M)) (g : Sign M) :
427427
MetaM (Q($(g.expr y)⁻¹ = $(g.expr q($y⁻¹)))) := do
428-
match g with
428+
match (dependent := true) g with
429429
| .plus => pure q(rfl)
430430
| .minus _ =>
431431
assumeInstancesCommute
@@ -436,7 +436,7 @@ the quotient of (± `y₁`) and (± `y₂`) (here taking the specified signs) is
436436
proof and the computed sign. -/
437437
def Sign.div (iM : Q(CommGroupWithZero $M)) (y₁ y₂ : Q($M)) (g₁ g₂ : Sign M) :
438438
MetaM (Σ (G : Sign M), Q($(g₁.expr y₁) / $(g₂.expr y₂) = $(G.expr q($y₁ / $y₂)))) := do
439-
match g₁, g₂ with
439+
match (dependent := true) g₁, g₂ with
440440
| .plus, .plus => pure ⟨.plus, q(rfl)⟩
441441
| .plus, .minus i =>
442442
assumeInstancesCommute
@@ -452,7 +452,7 @@ def Sign.div (iM : Q(CommGroupWithZero $M)) (y₁ y₂ : Q($M)) (g₁ g₂ : Sig
452452
the negation of (± `y`) (here taking the specified sign) is ∓ `y`. -/
453453
def Sign.neg (iM : Q(Field $M)) (y : Q($M)) (g : Sign M) :
454454
MetaM (Σ (G : Sign M), Q(-$(g.expr y) = $(G.expr y))) := do
455-
match g with
455+
match (dependent := true) g with
456456
| .plus => pure ⟨.minus iM, q(rfl)⟩
457457
| .minus _ =>
458458
assumeInstancesCommute
@@ -463,7 +463,7 @@ the exponentiation to power `s : ℕ` of (± `y`) (here taking the specified sig
463463
return this proof and the computed sign. -/
464464
def Sign.pow (iM : Q(CommGroupWithZero $M)) (y : Q($M)) (g : Sign M) (s : ℕ) :
465465
MetaM (Σ (G : Sign M), Q($(g.expr y) ^ $s = $(G.expr q($y ^ $s)))) := do
466-
match g with
466+
match (dependent := true) g with
467467
| .plus => pure ⟨.plus, q(rfl)⟩
468468
| .minus i =>
469469
assumeInstancesCommute
@@ -479,7 +479,7 @@ the exponentiation to power `s : ℤ` of (± `y`) (here taking the specified sig
479479
return this proof and the computed sign. -/
480480
def Sign.zpow (iM : Q(CommGroupWithZero $M)) (y : Q($M)) (g : Sign M) (s : ℤ) :
481481
MetaM (Σ (G : Sign M), Q($(g.expr y) ^ $s = $(G.expr q($y ^ $s)))) := do
482-
match g with
482+
match (dependent := true) g with
483483
| .plus => pure ⟨.plus, q(rfl)⟩
484484
| .minus i =>
485485
assumeInstancesCommute

Mathlib/Tactic/Linter/Whitespace.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ def whitespaceLinter : Linter where run := withSetOptionIn fun stx ↦ do
335335

336336
let fmt : Option Format := ←
337337
try
338-
liftCoreM <| PrettyPrinter.ppCategory `command stx
338+
liftCoreM <| some <$> PrettyPrinter.ppCategory `command stx
339339
catch _ =>
340340
Linter.logLintIf linter.style.whitespace.verbose (stx.getHead?.getD stx)
341341
m!"The `whitespace` linter had some parsing issues: \

Mathlib/Tactic/NormNum/Core.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ and returning the truth or falsity of `p' : Prop` from an equivalence `p ↔ p'`
150150
def deriveBoolOfIff (p p' : Q(Prop)) (hp : Q($p ↔ $p')) :
151151
MetaM ((b : Bool) × BoolResult p' b) := do
152152
let ⟨b, pb⟩ ← deriveBool p
153-
match b with
153+
match (dependent := true) b with
154154
| true => returntrue, q(Iff.mp $hp $pb)⟩
155155
| false => returnfalse, q((Iff.not $hp).mp $pb)⟩
156156

0 commit comments

Comments
 (0)