From baa71faf87812449640c64bfd7b1eaf553669044 Mon Sep 17 00:00:00 2001 From: leanprover-community-mathlib4-bot Date: Tue, 24 Mar 2026 06:31:56 +0000 Subject: [PATCH 001/321] Update lean-toolchain for testing https://github.com/leanprover/lean4/pull/13086 --- lake-manifest.json | 4 ++-- lakefile.lean | 2 +- lean-toolchain | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lake-manifest.json b/lake-manifest.json index 73680c6061faeb..7f92087e269a9a 100644 --- a/lake-manifest.json +++ b/lake-manifest.json @@ -65,10 +65,10 @@ "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "81c23850e7c2b5f82ed16e3569def2fe0f52e1c9", + "rev": "1eec0f14788781254d00b4ebb9628d3d1e322aa0", "name": "batteries", "manifestFile": "lake-manifest.json", - "inputRev": "nightly-testing", + "inputRev": "lean-pr-testing-13086", "inherited": false, "configFile": "lakefile.toml"}, {"url": "https://github.com/leanprover/lean4-cli", diff --git a/lakefile.lean b/lakefile.lean index 1de37822c9c419..fd3bb7a2e3f178 100644 --- a/lakefile.lean +++ b/lakefile.lean @@ -6,7 +6,7 @@ open Lake DSL ## Mathlib dependencies on upstream projects -/ -require "leanprover-community" / "batteries" @ git "nightly-testing" +require "leanprover-community" / "batteries" @ git "lean-pr-testing-13086" require "leanprover-community" / "Qq" @ git "nightly-testing" require "leanprover-community" / "aesop" @ git "nightly-testing" require "leanprover-community" / "proofwidgets" @ git "v0.0.92-pre1" -- ProofWidgets should always be pinned to a specific version diff --git a/lean-toolchain b/lean-toolchain index de7cb2ba9bc582..93d8de5b14c947 100644 --- a/lean-toolchain +++ b/lean-toolchain @@ -1 +1 @@ -leanprover/lean4:nightly-2026-03-24 +leanprover/lean4-pr-releases:pr-release-13086-4bf0162 From cbf62a73eed9c13f1266afbf60dbf0ae53a4316f Mon Sep 17 00:00:00 2001 From: Kim Morrison Date: Tue, 24 Mar 2026 06:47:26 +0000 Subject: [PATCH 002/321] feat: add `Lean.Grind.PowIdentity` instance for finite fields This provides a `PowIdentity K (Fintype.card K)` instance for any finite field, based on `FiniteField.pow_card` (Fermat's little theorem). This allows the `grind` ring solver to reduce high-degree polynomials over finite fields. Co-Authored-By: Claude Opus 4.6 (1M context) --- Mathlib/FieldTheory/Finite/Basic.lean | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Mathlib/FieldTheory/Finite/Basic.lean b/Mathlib/FieldTheory/Finite/Basic.lean index e55699cdd5960a..840047198a8c1e 100644 --- a/Mathlib/FieldTheory/Finite/Basic.lean +++ b/Mathlib/FieldTheory/Finite/Basic.lean @@ -239,6 +239,16 @@ theorem pow_card_pow (n : ℕ) (a : K) : a ^ q ^ n = a := by end +section + +variable [Field K] [Fintype K] + +open Lean in +instance instGrindPowIdentity : Grind.PowIdentity K (Fintype.card K) where + pow_eq := pow_card + +end + variable (K) [Field K] [Fintype K] /-- The cardinality `q` is a power of the characteristic of `K`. -/ From f420f53631e699aad89e365929c6d0c6e325f331 Mon Sep 17 00:00:00 2001 From: leanprover-community-mathlib4-bot Date: Thu, 26 Mar 2026 11:10:53 +0000 Subject: [PATCH 003/321] Update lean-toolchain for testing https://github.com/leanprover/lean4/pull/13132 --- lake-manifest.json | 4 ++-- lakefile.lean | 2 +- lean-toolchain | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lake-manifest.json b/lake-manifest.json index 73680c6061faeb..939fcc3af15339 100644 --- a/lake-manifest.json +++ b/lake-manifest.json @@ -65,10 +65,10 @@ "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "81c23850e7c2b5f82ed16e3569def2fe0f52e1c9", + "rev": "147d8a6d5692649259bfa3f8c5ea6a9385aeac88", "name": "batteries", "manifestFile": "lake-manifest.json", - "inputRev": "nightly-testing", + "inputRev": "lean-pr-testing-13132", "inherited": false, "configFile": "lakefile.toml"}, {"url": "https://github.com/leanprover/lean4-cli", diff --git a/lakefile.lean b/lakefile.lean index 1de37822c9c419..a52a5fdfd39591 100644 --- a/lakefile.lean +++ b/lakefile.lean @@ -6,7 +6,7 @@ open Lake DSL ## Mathlib dependencies on upstream projects -/ -require "leanprover-community" / "batteries" @ git "nightly-testing" +require "leanprover-community" / "batteries" @ git "lean-pr-testing-13132" require "leanprover-community" / "Qq" @ git "nightly-testing" require "leanprover-community" / "aesop" @ git "nightly-testing" require "leanprover-community" / "proofwidgets" @ git "v0.0.92-pre1" -- ProofWidgets should always be pinned to a specific version diff --git a/lean-toolchain b/lean-toolchain index de7cb2ba9bc582..bb75ca220ada74 100644 --- a/lean-toolchain +++ b/lean-toolchain @@ -1 +1 @@ -leanprover/lean4:nightly-2026-03-24 +leanprover/lean4-pr-releases:pr-release-13132-5594b54 From 28dc0ab2d625951424b570d7c7430d32d9e142ae Mon Sep 17 00:00:00 2001 From: leanprover-community-mathlib4-bot Date: Thu, 26 Mar 2026 13:34:51 +0000 Subject: [PATCH 004/321] Update lean-toolchain for https://github.com/leanprover/lean4/pull/13132 --- lake-manifest.json | 2 +- lean-toolchain | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lake-manifest.json b/lake-manifest.json index 939fcc3af15339..233d9ebd62a56d 100644 --- a/lake-manifest.json +++ b/lake-manifest.json @@ -65,7 +65,7 @@ "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "147d8a6d5692649259bfa3f8c5ea6a9385aeac88", + "rev": "943cd21dabe73116cc96d7ec7e0242deaa6dc0cd", "name": "batteries", "manifestFile": "lake-manifest.json", "inputRev": "lean-pr-testing-13132", diff --git a/lean-toolchain b/lean-toolchain index bb75ca220ada74..9020076871b042 100644 --- a/lean-toolchain +++ b/lean-toolchain @@ -1 +1 @@ -leanprover/lean4-pr-releases:pr-release-13132-5594b54 +leanprover/lean4-pr-releases:pr-release-13132-2f8db4b From d7aee7edce0743c7500b1de8cc72a05564d8c37e Mon Sep 17 00:00:00 2001 From: leanprover-community-mathlib4-bot Date: Thu, 26 Mar 2026 14:18:43 +0000 Subject: [PATCH 005/321] Update lean-toolchain for https://github.com/leanprover/lean4/pull/13132 --- lake-manifest.json | 2 +- lean-toolchain | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lake-manifest.json b/lake-manifest.json index 233d9ebd62a56d..d47be9b382b89e 100644 --- a/lake-manifest.json +++ b/lake-manifest.json @@ -65,7 +65,7 @@ "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "943cd21dabe73116cc96d7ec7e0242deaa6dc0cd", + "rev": "257610310763a697d819165a58f209a63a512929", "name": "batteries", "manifestFile": "lake-manifest.json", "inputRev": "lean-pr-testing-13132", diff --git a/lean-toolchain b/lean-toolchain index 9020076871b042..363e30b7f1ae7f 100644 --- a/lean-toolchain +++ b/lean-toolchain @@ -1 +1 @@ -leanprover/lean4-pr-releases:pr-release-13132-2f8db4b +leanprover/lean4-pr-releases:pr-release-13132-8479ef4 From deb87e3dd5774ef3467b8cbd52cf88dabf6f16bb Mon Sep 17 00:00:00 2001 From: leanprover-community-mathlib4-bot Date: Wed, 1 Apr 2026 00:28:04 +0000 Subject: [PATCH 006/321] Update lean-toolchain for testing https://github.com/leanprover/lean4/pull/13223 --- lake-manifest.json | 4 ++-- lakefile.lean | 2 +- lean-toolchain | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lake-manifest.json b/lake-manifest.json index e435c475740f43..c668987c11650a 100644 --- a/lake-manifest.json +++ b/lake-manifest.json @@ -65,10 +65,10 @@ "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "81df60304bb26e3e1efc6ee9b07fb387dac19108", + "rev": "3d5a3aaab3de9235f10521681974f5043f072f09", "name": "batteries", "manifestFile": "lake-manifest.json", - "inputRev": "nightly-testing", + "inputRev": "lean-pr-testing-13223", "inherited": false, "configFile": "lakefile.toml"}, {"url": "https://github.com/leanprover/lean4-cli", diff --git a/lakefile.lean b/lakefile.lean index 8fa4ac638fc9fb..da7aa856d361a7 100644 --- a/lakefile.lean +++ b/lakefile.lean @@ -6,7 +6,7 @@ open Lake DSL ## Mathlib dependencies on upstream projects -/ -require "leanprover-community" / "batteries" @ git "nightly-testing" +require "leanprover-community" / "batteries" @ git "lean-pr-testing-13223" require "leanprover-community" / "Qq" @ git "nightly-testing" require "leanprover-community" / "aesop" @ git "nightly-testing" require "leanprover-community" / "proofwidgets" @ git "nightly-testing" diff --git a/lean-toolchain b/lean-toolchain index 3911411c451a70..30316b1566a727 100644 --- a/lean-toolchain +++ b/lean-toolchain @@ -1 +1 @@ -leanprover/lean4:nightly-2026-03-31 +leanprover/lean4-pr-releases:pr-release-13223-f92b7f3 From b465a60109aafff3a6fb36128332d23780a9ef49 Mon Sep 17 00:00:00 2001 From: leanprover-community-mathlib4-bot Date: Wed, 1 Apr 2026 11:06:57 +0000 Subject: [PATCH 007/321] Update lean-toolchain for testing https://github.com/leanprover/lean4/pull/13229 --- lake-manifest.json | 4 ++-- lakefile.lean | 2 +- lean-toolchain | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lake-manifest.json b/lake-manifest.json index c6f5dc8152dce1..bd012465e8def1 100644 --- a/lake-manifest.json +++ b/lake-manifest.json @@ -65,10 +65,10 @@ "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "da8a068708756fcc8aa953efc0dd95094b73a934", + "rev": "c0286d9a17937d9e498f0bb3c499d97eceb05ba9", "name": "batteries", "manifestFile": "lake-manifest.json", - "inputRev": "nightly-testing", + "inputRev": "lean-pr-testing-13229", "inherited": false, "configFile": "lakefile.toml"}, {"url": "https://github.com/leanprover/lean4-cli", diff --git a/lakefile.lean b/lakefile.lean index 1de37822c9c419..ba4571d0983075 100644 --- a/lakefile.lean +++ b/lakefile.lean @@ -6,7 +6,7 @@ open Lake DSL ## Mathlib dependencies on upstream projects -/ -require "leanprover-community" / "batteries" @ git "nightly-testing" +require "leanprover-community" / "batteries" @ git "lean-pr-testing-13229" require "leanprover-community" / "Qq" @ git "nightly-testing" require "leanprover-community" / "aesop" @ git "nightly-testing" require "leanprover-community" / "proofwidgets" @ git "v0.0.92-pre1" -- ProofWidgets should always be pinned to a specific version diff --git a/lean-toolchain b/lean-toolchain index b222dcbd6a2d8b..5f005db8ca8aa7 100644 --- a/lean-toolchain +++ b/lean-toolchain @@ -1 +1 @@ -leanprover/lean4:nightly-2026-03-25 +leanprover/lean4-pr-releases:pr-release-13229-f76c89f From f841c8f402a15bf6f36f482cb7aa95dcdc7ae90a Mon Sep 17 00:00:00 2001 From: Joachim Breitner Date: Tue, 31 Mar 2026 20:30:03 +0000 Subject: [PATCH 008/321] chore: indent tactic blocks after `by` and `decreasing_by` Adapt to leanprover/lean4#13217 which requires indented tactic sequences after `by` and `decreasing_by`. Co-Authored-By: Claude Opus 4.6 --- Mathlib/RingTheory/MvPolynomial/Groebner.lean | 14 +++++++------- .../RingTheory/Valuation/ValuativeRel/Basic.lean | 8 ++++---- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Mathlib/RingTheory/MvPolynomial/Groebner.lean b/Mathlib/RingTheory/MvPolynomial/Groebner.lean index c6abb237cd5a93..2be50c65a7fcde 100644 --- a/Mathlib/RingTheory/MvPolynomial/Groebner.lean +++ b/Mathlib/RingTheory/MvPolynomial/Groebner.lean @@ -213,13 +213,13 @@ theorem div {ι : Type*} {b : ι → MvPolynomial σ R} termination_by WellFounded.wrap ((isWellFounded_iff m.syn fun x x_1 ↦ x < x_1).mp m.wf) (m.toSyn (m.degree f)) decreasing_by -· exact deg_reduce -· apply degree_sub_LTerm_lt - intro hf0 - apply hf'0 - simp only [subLTerm, sub_eq_zero] - nth_rewrite 1 [eq_C_of_degree_eq_zero hf0, hf0] - simp + · exact deg_reduce + · apply degree_sub_LTerm_lt + intro hf0 + apply hf'0 + simp only [subLTerm, sub_eq_zero] + nth_rewrite 1 [eq_C_of_degree_eq_zero hf0, hf0] + simp /-! Module doc as workaround for a parser error that prevents using `set_option` diff --git a/Mathlib/RingTheory/Valuation/ValuativeRel/Basic.lean b/Mathlib/RingTheory/Valuation/ValuativeRel/Basic.lean index 162e0f42544bc5..5c424ace955138 100644 --- a/Mathlib/RingTheory/Valuation/ValuativeRel/Basic.lean +++ b/Mathlib/RingTheory/Valuation/ValuativeRel/Basic.lean @@ -1214,10 +1214,10 @@ theorem orderMonoidIso_embed [v.Compatible] {Γ' : Type*} [LinearOrderedCommGrou (w : Valuation R Γ') [w.Compatible] (x : ValueGroupWithZero R) (h : w.IsEquiv v) : h.orderMonoidIso (embed w x) = embed v x := by -simp only [embed, ← Valuation.restrict_def, coe_mk, ZeroHom.coe_mk] -induction x using ValueGroupWithZero.ind with -| mk r s => - simp + simp only [embed, ← Valuation.restrict_def, coe_mk, ZeroHom.coe_mk] + induction x using ValueGroupWithZero.ind with + | mk r s => + simp /-- If a valuation `v` is compatible with the valuative relation, then `ValueGroupWithZero R` is isomorphic to the image group (with zero) of `v` as an ordered group with zero. -/ From b779d444a383d24980a644ea05c9cc14cf220ab3 Mon Sep 17 00:00:00 2001 From: Joachim Breitner Date: Tue, 31 Mar 2026 21:42:55 +0000 Subject: [PATCH 009/321] chore: indent tactic block in EmptyLine test Adapt to leanprover/lean4#13217. Co-Authored-By: Claude Opus 4.6 --- MathlibTest/EmptyLine.lean | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/MathlibTest/EmptyLine.lean b/MathlibTest/EmptyLine.lean index 41a11e48d8e824..637a9d5ad5b0e5 100644 --- a/MathlibTest/EmptyLine.lean +++ b/MathlibTest/EmptyLine.lean @@ -159,31 +159,31 @@ example : True := by -- The following empty line is not reported, since the com warning: Please, write a comment here or remove this line, but do not place empty lines within commands! Context: ↓ - ⏎example : True := by⏎⏎-- Here I start⏎⏎ + ⏎example : True := by⏎⏎ -- Here I start⏎⏎ Note: This linter can be disabled with `set_option linter.style.emptyLine false` --- warning: Please, write a comment here or remove this line, but do not place empty lines within commands! Context: - ↓ - ⏎--stop⏎⏎trivial⏎⏎ + ↓ + ⏎ --stop⏎⏎ trivial⏎⏎ Note: This linter can be disabled with `set_option linter.style.emptyLine false` -/ #guard_msgs in example : True := by --- Here I start + -- Here I start -/- + /- --/ + -/ ---stop + --stop -trivial -- also a comment + trivial -- also a comment --- with a line break + -- with a line break -- Check that `where` fields allow empty lines. structure F where From 61a6a0f78945b722e3142fc7e20959c2e6af76d1 Mon Sep 17 00:00:00 2001 From: Joachim Breitner Date: Wed, 1 Apr 2026 12:32:02 +0000 Subject: [PATCH 010/321] chore: indent expression continuations at column 0 Co-Authored-By: Claude Opus 4.6 --- Mathlib/Algebra/Module/Submodule/LinearMap.lean | 2 +- Mathlib/Topology/Algebra/InfiniteSum/Constructions.lean | 2 +- Mathlib/Topology/Algebra/InfiniteSum/GroupCompletion.lean | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Mathlib/Algebra/Module/Submodule/LinearMap.lean b/Mathlib/Algebra/Module/Submodule/LinearMap.lean index 68d86fc001983e..5654a2b9333ef0 100644 --- a/Mathlib/Algebra/Module/Submodule/LinearMap.lean +++ b/Mathlib/Algebra/Module/Submodule/LinearMap.lean @@ -177,7 +177,7 @@ theorem subtype_comp_codRestrict (p : Submodule R₂ M₂) (h : ∀ b, f b ∈ p section variable {M₂' : Type*} [AddCommMonoid M₂'] [Module R₂ M₂'] -(p : M₂' →ₗ[R₂] M₂) (hp : Injective p) (h : ∀ c, f c ∈ range p) + (p : M₂' →ₗ[R₂] M₂) (hp : Injective p) (h : ∀ c, f c ∈ range p) /-- A linear map `f : M → M₂` whose values lie in the image of an injective linear map `p : M₂' → M₂` admits a unique lift to a linear map `M → M₂'`. -/ diff --git a/Mathlib/Topology/Algebra/InfiniteSum/Constructions.lean b/Mathlib/Topology/Algebra/InfiniteSum/Constructions.lean index dd08bd9caf1a31..495ccb223bb43c 100644 --- a/Mathlib/Topology/Algebra/InfiniteSum/Constructions.lean +++ b/Mathlib/Topology/Algebra/InfiniteSum/Constructions.lean @@ -269,7 +269,7 @@ end CompleteSpace section Pi variable {ι : Type*} {X : α → Type*} [∀ x, CommMonoid (X x)] [∀ x, TopologicalSpace (X x)] -{L : SummationFilter ι} + {L : SummationFilter ι} @[to_additive] theorem Pi.hasProd {f : ι → ∀ x, X x} {g : ∀ x, X x} : diff --git a/Mathlib/Topology/Algebra/InfiniteSum/GroupCompletion.lean b/Mathlib/Topology/Algebra/InfiniteSum/GroupCompletion.lean index 226f4e4d1ab33f..dbc911b2b241b8 100644 --- a/Mathlib/Topology/Algebra/InfiniteSum/GroupCompletion.lean +++ b/Mathlib/Topology/Algebra/InfiniteSum/GroupCompletion.lean @@ -17,7 +17,7 @@ public section open UniformSpace.Completion variable {α β : Type*} [AddCommGroup α] [UniformSpace α] [IsUniformAddGroup α] -{L : SummationFilter β} + {L : SummationFilter β} /-- A function `f` has a sum in a uniform additive group `α` if and only if it has that sum in the completion of `α`. -/ From e714425c284fd251369c2199cbc57a83f9f0b9ac Mon Sep 17 00:00:00 2001 From: Joachim Breitner Date: Wed, 1 Apr 2026 13:14:06 +0000 Subject: [PATCH 011/321] chore: indent expression continuations at column 0 Co-Authored-By: Claude Opus 4.6 --- Mathlib/Analysis/Analytic/ChangeOrigin.lean | 2 +- Mathlib/Analysis/Normed/Module/Ray.lean | 2 +- Mathlib/Analysis/Normed/Operator/Basic.lean | 2 +- .../Geometry/Manifold/Algebra/LieGroup.lean | 2 +- Mathlib/MeasureTheory/Measure/AddContent.lean | 2 +- .../VectorMeasure/AddContent.lean | 2 +- Mathlib/RingTheory/Ideal/Maps.lean | 24 +++++++++---------- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Mathlib/Analysis/Analytic/ChangeOrigin.lean b/Mathlib/Analysis/Analytic/ChangeOrigin.lean index 19d6228da2c365..b95041cfe9ed39 100644 --- a/Mathlib/Analysis/Analytic/ChangeOrigin.lean +++ b/Mathlib/Analysis/Analytic/ChangeOrigin.lean @@ -43,7 +43,7 @@ open scoped NNReal ENNReal Topology open Filter Set variable {𝕜 E F : Type*} [NontriviallyNormedField 𝕜] [NormedAddCommGroup E] [NormedSpace 𝕜 E] -[NormedAddCommGroup F] [NormedSpace 𝕜 F] + [NormedAddCommGroup F] [NormedSpace 𝕜 F] namespace FormalMultilinearSeries diff --git a/Mathlib/Analysis/Normed/Module/Ray.lean b/Mathlib/Analysis/Normed/Module/Ray.lean index ceb5c4bad4b473..e64bc5f6d23f02 100644 --- a/Mathlib/Analysis/Normed/Module/Ray.lean +++ b/Mathlib/Analysis/Normed/Module/Ray.lean @@ -22,7 +22,7 @@ public section open Real variable {E : Type*} [SeminormedAddCommGroup E] [NormedSpace ℝ E] {F : Type*} -[NormedAddCommGroup F] [NormedSpace ℝ F] + [NormedAddCommGroup F] [NormedSpace ℝ F] namespace SameRay diff --git a/Mathlib/Analysis/Normed/Operator/Basic.lean b/Mathlib/Analysis/Normed/Operator/Basic.lean index 45fe5b39d6fd4d..d248d0f8e9c2df 100644 --- a/Mathlib/Analysis/Normed/Operator/Basic.lean +++ b/Mathlib/Analysis/Normed/Operator/Basic.lean @@ -79,7 +79,7 @@ theorem closedBall_subset_range_iff_surjective [RingHomSurjective σ₁₂] {f : by simp_all⟩ variable {F' 𝓕' : Type*} [NormedAddCommGroup F'] [NormedSpace ℝ F'] [Nontrivial F'] -{τ : 𝕜 →+* ℝ} [FunLike 𝓕' E F'] [SemilinearMapClass 𝓕' τ E F'] + {τ : 𝕜 →+* ℝ} [FunLike 𝓕' E F'] [SemilinearMapClass 𝓕' τ E F'] theorem sphere_subset_range_iff_surjective [RingHomSurjective τ] {f : 𝓕'} {x : F'} {r : ℝ} (hr : 0 < r) : sphere x r ⊆ Set.range f ↔ (⇑f).Surjective := by diff --git a/Mathlib/Geometry/Manifold/Algebra/LieGroup.lean b/Mathlib/Geometry/Manifold/Algebra/LieGroup.lean index 0a996e925745b1..f3f9d6131ba33e 100644 --- a/Mathlib/Geometry/Manifold/Algebra/LieGroup.lean +++ b/Mathlib/Geometry/Manifold/Algebra/LieGroup.lean @@ -296,7 +296,7 @@ functions `f : M → N` is `C^n` whenever the denominator is non-zero. section Div variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] {n : WithTop ℕ∞} -{H : Type*} [TopologicalSpace H] {E : Type*} + {H : Type*} [TopologicalSpace H] {E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E] {I : ModelWithCorners 𝕜 E H} {G : Type*} [TopologicalSpace G] [ChartedSpace H G] [GroupWithZero G] [ContMDiffInv₀ I n G] [ContMDiffMul I n G] diff --git a/Mathlib/MeasureTheory/Measure/AddContent.lean b/Mathlib/MeasureTheory/Measure/AddContent.lean index ad79b077cc3151..e66aca913c596c 100644 --- a/Mathlib/MeasureTheory/Measure/AddContent.lean +++ b/Mathlib/MeasureTheory/Measure/AddContent.lean @@ -68,7 +68,7 @@ open scoped ENNReal Topology Function namespace MeasureTheory variable {α : Type*} {C : Set (Set α)} {s t : Set α} {I : Finset (Set α)} -{G : Type*} [AddCommMonoid G] + {G : Type*} [AddCommMonoid G] variable (G) in /-- An additive content is a set function with value 0 at the empty set which is finitely additive diff --git a/Mathlib/MeasureTheory/VectorMeasure/AddContent.lean b/Mathlib/MeasureTheory/VectorMeasure/AddContent.lean index b296f2ba2d867e..1b2399ac8c7fd0 100644 --- a/Mathlib/MeasureTheory/VectorMeasure/AddContent.lean +++ b/Mathlib/MeasureTheory/VectorMeasure/AddContent.lean @@ -27,7 +27,7 @@ open scoped symmDiff namespace MeasureTheory.VectorMeasure variable {α : Type*} {hα : MeasurableSpace α} {E : Type*} [NormedAddCommGroup E] -[CompleteSpace E] {μ : Measure α} + [CompleteSpace E] {μ : Measure α} /-- A finitely additive vector measure which is dominated by a finite positive measure is in fact countably additive. -/ diff --git a/Mathlib/RingTheory/Ideal/Maps.lean b/Mathlib/RingTheory/Ideal/Maps.lean index 8cde123aca73ac..84672e45cd0ccc 100644 --- a/Mathlib/RingTheory/Ideal/Maps.lean +++ b/Mathlib/RingTheory/Ideal/Maps.lean @@ -421,18 +421,18 @@ If infinitely many of the `Rᵢ` are nontrivial, then there exists an ideal of ` is not of the form `Πᵢ Iᵢ`, namely the ideal of finitely supported elements of `Πᵢ Rᵢ` (it is also not a principal ideal).) -/ @[simps!] def piOrderIso [Finite ι] : Ideal (Π i, R i) ≃o Π i, Ideal (R i) := .symm -{ toFun := pi - invFun I i := I.map (Pi.evalRingHom R i) - left_inv _ := funext map_evalRingHom_pi - right_inv I := by - ext r - simp_rw [mem_pi, mem_map_iff_of_surjective (Pi.evalRingHom R _) (Function.surjective_eval _)] - refine ⟨(fun ⟨r', hr'⟩ ↦ ?_) ∘ Classical.skolem.mp, fun hr i ↦ ⟨r, hr, rfl⟩⟩ - have := Fintype.ofFinite ι - classical rw [show r = ∑ i, Pi.single i 1 * r' i from funext fun i ↦ by - rw [← (hr' _).2, Finset.sum_apply, Fintype.sum_eq_single i fun j ne ↦ by simp [ne]]; simp] - exact sum_mem fun i _ ↦ I.mul_mem_left _ (hr' i).1 - map_rel_iff' := pi_le_pi_iff } + { toFun := pi + invFun I i := I.map (Pi.evalRingHom R i) + left_inv _ := funext map_evalRingHom_pi + right_inv I := by + ext r + simp_rw [mem_pi, mem_map_iff_of_surjective (Pi.evalRingHom R _) (Function.surjective_eval _)] + refine ⟨(fun ⟨r', hr'⟩ ↦ ?_) ∘ Classical.skolem.mp, fun hr i ↦ ⟨r, hr, rfl⟩⟩ + have := Fintype.ofFinite ι + classical rw [show r = ∑ i, Pi.single i 1 * r' i from funext fun i ↦ by + rw [← (hr' _).2, Finset.sum_apply, Fintype.sum_eq_single i fun j ne ↦ by simp [ne]]; simp] + exact sum_mem fun i _ ↦ I.mul_mem_left _ (hr' i).1 + map_rel_iff' := pi_le_pi_iff } instance [Finite ι] [∀ i, IsPrincipalIdealRing (R i)] : IsPrincipalIdealRing (Π i, R i) where principal I := by From 7845a1a8a89d4866c945495019d281ecbe50c454 Mon Sep 17 00:00:00 2001 From: leanprover-community-mathlib4-bot Date: Wed, 1 Apr 2026 18:40:47 +0000 Subject: [PATCH 012/321] Update lean-toolchain for https://github.com/leanprover/lean4/pull/13229 --- lake-manifest.json | 2 +- lean-toolchain | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lake-manifest.json b/lake-manifest.json index bd012465e8def1..7ac1d0e130f7f7 100644 --- a/lake-manifest.json +++ b/lake-manifest.json @@ -65,7 +65,7 @@ "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "c0286d9a17937d9e498f0bb3c499d97eceb05ba9", + "rev": "645e49d5f6a3b43d21cbdbd0484181cecc085e6e", "name": "batteries", "manifestFile": "lake-manifest.json", "inputRev": "lean-pr-testing-13229", diff --git a/lean-toolchain b/lean-toolchain index 5f005db8ca8aa7..1ea9ba3f8c011f 100644 --- a/lean-toolchain +++ b/lean-toolchain @@ -1 +1 @@ -leanprover/lean4-pr-releases:pr-release-13229-f76c89f +leanprover/lean4-pr-releases:pr-release-13229-bc5b0e2 From 7eff8163b61dac77cb19660fa7b4354eddabe274 Mon Sep 17 00:00:00 2001 From: leanprover-community-mathlib4-bot Date: Wed, 1 Apr 2026 20:26:29 +0000 Subject: [PATCH 013/321] Update lean-toolchain for https://github.com/leanprover/lean4/pull/13223 --- lake-manifest.json | 2 +- lean-toolchain | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lake-manifest.json b/lake-manifest.json index c668987c11650a..5ab4eaacb44520 100644 --- a/lake-manifest.json +++ b/lake-manifest.json @@ -65,7 +65,7 @@ "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "3d5a3aaab3de9235f10521681974f5043f072f09", + "rev": "a2574fe95a9b75fc8a5704154115a2a1b1772fcb", "name": "batteries", "manifestFile": "lake-manifest.json", "inputRev": "lean-pr-testing-13223", diff --git a/lean-toolchain b/lean-toolchain index 30316b1566a727..5079d14de1510d 100644 --- a/lean-toolchain +++ b/lean-toolchain @@ -1 +1 @@ -leanprover/lean4-pr-releases:pr-release-13223-f92b7f3 +leanprover/lean4-pr-releases:pr-release-13223-4d67b4b From e533fdeaf038eb1c7a142de54952aaa4f13a7b86 Mon Sep 17 00:00:00 2001 From: leanprover-community-mathlib4-bot Date: Wed, 1 Apr 2026 20:54:17 +0000 Subject: [PATCH 014/321] Update lean-toolchain for https://github.com/leanprover/lean4/pull/13229 --- lake-manifest.json | 2 +- lean-toolchain | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lake-manifest.json b/lake-manifest.json index 7ac1d0e130f7f7..4968304ce962ff 100644 --- a/lake-manifest.json +++ b/lake-manifest.json @@ -65,7 +65,7 @@ "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "645e49d5f6a3b43d21cbdbd0484181cecc085e6e", + "rev": "21b86a5d3de7134e36ad9372b10db4ebe6537191", "name": "batteries", "manifestFile": "lake-manifest.json", "inputRev": "lean-pr-testing-13229", diff --git a/lean-toolchain b/lean-toolchain index 1ea9ba3f8c011f..69c3d1e0bc8491 100644 --- a/lean-toolchain +++ b/lean-toolchain @@ -1 +1 @@ -leanprover/lean4-pr-releases:pr-release-13229-bc5b0e2 +leanprover/lean4-pr-releases:pr-release-13229-626213b From 37ec501598b2e669c96887b98772955a401c8df2 Mon Sep 17 00:00:00 2001 From: leanprover-community-mathlib4-bot Date: Wed, 1 Apr 2026 21:51:50 +0000 Subject: [PATCH 015/321] Update lean-toolchain for https://github.com/leanprover/lean4/pull/13229 --- lake-manifest.json | 2 +- lean-toolchain | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lake-manifest.json b/lake-manifest.json index 4968304ce962ff..b21529f793d4ee 100644 --- a/lake-manifest.json +++ b/lake-manifest.json @@ -65,7 +65,7 @@ "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "21b86a5d3de7134e36ad9372b10db4ebe6537191", + "rev": "6c58796406bf6d10afc8514df1595148a731926f", "name": "batteries", "manifestFile": "lake-manifest.json", "inputRev": "lean-pr-testing-13229", diff --git a/lean-toolchain b/lean-toolchain index 69c3d1e0bc8491..916fc0e7235449 100644 --- a/lean-toolchain +++ b/lean-toolchain @@ -1 +1 @@ -leanprover/lean4-pr-releases:pr-release-13229-626213b +leanprover/lean4-pr-releases:pr-release-13229-0fc6e49 From 3602bc00f4e3fb51998e120ca7d3ff64568e0150 Mon Sep 17 00:00:00 2001 From: leanprover-community-mathlib4-bot Date: Thu, 2 Apr 2026 09:47:36 +0000 Subject: [PATCH 016/321] Update lean-toolchain for https://github.com/leanprover/lean4/pull/13229 --- lake-manifest.json | 2 +- lean-toolchain | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lake-manifest.json b/lake-manifest.json index b21529f793d4ee..089d82ac330bf7 100644 --- a/lake-manifest.json +++ b/lake-manifest.json @@ -65,7 +65,7 @@ "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "6c58796406bf6d10afc8514df1595148a731926f", + "rev": "7c36ea46afccf4a11da46b6faae490f5cf4a3043", "name": "batteries", "manifestFile": "lake-manifest.json", "inputRev": "lean-pr-testing-13229", diff --git a/lean-toolchain b/lean-toolchain index 916fc0e7235449..b6747cfdc39309 100644 --- a/lean-toolchain +++ b/lean-toolchain @@ -1 +1 @@ -leanprover/lean4-pr-releases:pr-release-13229-0fc6e49 +leanprover/lean4-pr-releases:pr-release-13229-aa77588 From ce608e72cea947a87d76f86f5583c60d3f2a3853 Mon Sep 17 00:00:00 2001 From: leanprover-community-mathlib4-bot Date: Thu, 2 Apr 2026 12:30:02 +0000 Subject: [PATCH 017/321] Update lean-toolchain for https://github.com/leanprover/lean4/pull/13223 --- lake-manifest.json | 2 +- lean-toolchain | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lake-manifest.json b/lake-manifest.json index 3a486d56d4b24e..fc6693b09cc150 100644 --- a/lake-manifest.json +++ b/lake-manifest.json @@ -65,7 +65,7 @@ "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "9e1475e92dfb360d79e99735fdae80e5831aa6c6", + "rev": "4b683d8a24a7cac230de80594e886e5457abc842", "name": "batteries", "manifestFile": "lake-manifest.json", "inputRev": "lean-pr-testing-13223", diff --git a/lean-toolchain b/lean-toolchain index 16cbaa6b60163f..34303e5e753d6e 100644 --- a/lean-toolchain +++ b/lean-toolchain @@ -1 +1 @@ -leanprover/lean4-pr-releases:pr-release-13223-59d9492 +leanprover/lean4-pr-releases:pr-release-13223-e72d42c From f8c6bd6ecd104f93ca754ca7e5a7de6f7af11698 Mon Sep 17 00:00:00 2001 From: Wojciech Rozowski Date: Thu, 2 Apr 2026 14:16:34 +0000 Subject: [PATCH 018/321] chore: fix linter tests --- MathlibTest/LintStyle.lean | 4 ---- MathlibTest/globalAttributeIn.lean | 37 ++++-------------------------- 2 files changed, 5 insertions(+), 36 deletions(-) diff --git a/MathlibTest/LintStyle.lean b/MathlibTest/LintStyle.lean index 28ac686c00c5ce..6783965170584b 100644 --- a/MathlibTest/LintStyle.lean +++ b/MathlibTest/LintStyle.lean @@ -201,7 +201,6 @@ set_option linter.style.cdot true set_option allowUnsafeReducibility true in attribute [instance_reducible] Int.add -set_option linter.globalAttributeIn false in /-- warning: Please, use '·' (typed as `\.`) instead of '.' as 'cdot'. @@ -216,7 +215,6 @@ warning: Please, use '·' (typed as `\.`) instead of '.' as 'cdot'. Note: This linter can be disabled with `set_option linter.style.cdot false` -/ #guard_msgs in -attribute [instance] Int.add in instance : Inhabited Nat where default := by . have := 0 @@ -276,7 +274,6 @@ example : True := by end cdotLinter set_option linter.style.dollarSyntax true -set_option linter.globalAttributeIn false in /-- warning: Please use '<|' instead of '$' for the pipe operator. @@ -287,7 +284,6 @@ warning: Please use '<|' instead of '$' for the pipe operator. Note: This linter can be disabled with `set_option linter.style.dollarSyntax false` -/ #guard_msgs in -attribute [instance] Int.add in instance (f g : Nat → Nat) : Inhabited Nat where default := by · have := 0 diff --git a/MathlibTest/globalAttributeIn.lean b/MathlibTest/globalAttributeIn.lean index 37f273b69bc93b..a61961950ef7e2 100644 --- a/MathlibTest/globalAttributeIn.lean +++ b/MathlibTest/globalAttributeIn.lean @@ -8,33 +8,14 @@ import Mathlib.Tactic.Linter.GlobalAttributeIn /-! Tests for the `globalAttributeIn` linter. -/ --- Test disabling the linter. -set_option linter.globalAttributeIn false - -- After https://github.com/leanprover/lean4/pull/12263, -- we need to add `instance_reducible` before we can add `instance` to `Int.add`. set_option allowUnsafeReducibility true in attribute [instance_reducible] Int.add -set_option autoImplicit false in -attribute [instance] Int.add in -instance : Inhabited Int where - default := 0 - -set_option linter.globalAttributeIn true - -set_option linter.globalAttributeIn false in -attribute [instance] Int.add in -instance : Inhabited Int where - default := 0 - --- Global instances with `in`, are linted, as they are a footgun. - /-- -warning: Despite the `in`, the attribute 'instance 1100' is added globally to 'Int.add' +error: Despite the `in`, the attribute instance 1100 is added globally to Int.add please remove the `in` or make this a `local instance 1100` - -Note: This linter can be disabled with `set_option linter.globalAttributeIn false` -/ #guard_msgs in set_option autoImplicit false in @@ -44,10 +25,8 @@ instance : Inhabited Int where default := 0 /-- -warning: Despite the `in`, the attribute 'instance' is added globally to 'Int.add' +error: Despite the `in`, the attribute instance is added globally to Int.add please remove the `in` or make this a `local instance` - -Note: This linter can be disabled with `set_option linter.globalAttributeIn false` -/ #guard_msgs in attribute [instance] Int.add in @@ -55,10 +34,8 @@ instance : Inhabited Int where default := 0 /-- -warning: Despite the `in`, the attribute 'simp' is added globally to 'Int.add' +error: Despite the `in`, the attribute simp is added globally to Int.add please remove the `in` or make this a `local simp` - -Note: This linter can be disabled with `set_option linter.globalAttributeIn false` -/ #guard_msgs in attribute [simp] Int.add in @@ -73,15 +50,11 @@ namespace X theorem foo (x y : Nat) : x = y := sorry /-- -warning: Despite the `in`, the attribute 'simp' is added globally to 'foo' +error: Despite the `in`, the attribute simp is added globally to foo please remove the `in` or make this a `local simp` - -Note: This linter can be disabled with `set_option linter.globalAttributeIn false` --- -warning: Despite the `in`, the attribute 'ext' is added globally to 'foo' +error: Despite the `in`, the attribute ext is added globally to foo please remove the `in` or make this a `local ext` - -Note: This linter can be disabled with `set_option linter.globalAttributeIn false` -/ #guard_msgs in attribute [simp, local simp, ext, scoped instance, -simp, -ext] foo in From 8d08e270ece92c1a812fbbca183872691c19f542 Mon Sep 17 00:00:00 2001 From: Kim Morrison Date: Tue, 7 Apr 2026 14:35:06 +1000 Subject: [PATCH 019/321] lake update --- lake-manifest.json | 8 ++++---- lakefile.lean | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lake-manifest.json b/lake-manifest.json index dfad1f83a0b0fd..ca0e4c0d66b879 100644 --- a/lake-manifest.json +++ b/lake-manifest.json @@ -45,20 +45,20 @@ "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "f74c7555aaa94eadd7b7bff9170f7983f92aac21", + "rev": "ad416ddf6cc9d5b1c00eaf04a48e703538132760", "name": "aesop", "manifestFile": "lake-manifest.json", - "inputRev": "v4.30.0-rc1", + "inputRev": "nightly-testing", "inherited": false, "configFile": "lakefile.toml"}, {"url": "https://github.com/leanprover-community/quote4", "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "7aa86cb20b8458748dc24d55dab2d7ea01161057", + "rev": "bee778191c7fbea31864ecfe1809b8837626aba0", "name": "Qq", "manifestFile": "lake-manifest.json", - "inputRev": "v4.30.0-rc1", + "inputRev": "nightly-testing", "inherited": false, "configFile": "lakefile.toml"}, {"url": "https://github.com/leanprover-community/batteries", diff --git a/lakefile.lean b/lakefile.lean index e22e0ef045be20..5f11ec894a69ad 100644 --- a/lakefile.lean +++ b/lakefile.lean @@ -7,8 +7,8 @@ open Lake DSL -/ require "leanprover-community" / "batteries" @ git "v4.30.0-rc1" -require "leanprover-community" / "Qq" @ git "v4.30.0-rc1" -require "leanprover-community" / "aesop" @ git "v4.30.0-rc1" +require "leanprover-community" / "Qq" @ git "nightly-testing" +require "leanprover-community" / "aesop" @ git "nightly-testing" require "leanprover-community" / "proofwidgets" @ git "v0.0.97" with NameMap.empty.insert `errorOnBuild "ProofWidgets failed to reuse pre-built JS code. \ From 940f396db97c9c3cd13cc116ab54384a3212a5d3 Mon Sep 17 00:00:00 2001 From: Kim Morrison Date: Tue, 7 Apr 2026 14:36:04 +1000 Subject: [PATCH 020/321] fix hash command linter --- Mathlib/Tactic/Linter/HashCommandLinter.lean | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mathlib/Tactic/Linter/HashCommandLinter.lean b/Mathlib/Tactic/Linter/HashCommandLinter.lean index 3f2c8f926bef0b..c8b650c5c99d36 100644 --- a/Mathlib/Tactic/Linter/HashCommandLinter.lean +++ b/Mathlib/Tactic/Linter/HashCommandLinter.lean @@ -49,7 +49,7 @@ Intended to be used in the `hashCommand` linter, where we want to enter `set_opt private partial def withSetOptionIn' (cmd : CommandElab) : CommandElab := fun stx => do if stx.getKind == ``Lean.Parser.Command.in then if stx[0].getKind == ``Lean.Parser.Command.set_option then - let opts ← Elab.elabSetOption stx[0][1] stx[0][3] + let (opts, _) ← Elab.elabSetOption stx[0][1] stx[0][3] withScope (fun scope => { scope with opts }) do withSetOptionIn' cmd stx[2] else From 12400c59a92b6fbfe39d0f04b6056428bcfea3d8 Mon Sep 17 00:00:00 2001 From: Kim Morrison Date: Tue, 7 Apr 2026 14:47:54 +1000 Subject: [PATCH 021/321] fix bad merge --- Mathlib/Computability/Partrec.lean | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Mathlib/Computability/Partrec.lean b/Mathlib/Computability/Partrec.lean index 5e1ef4c6b9fcfb..c8363e6f90b16b 100644 --- a/Mathlib/Computability/Partrec.lean +++ b/Mathlib/Computability/Partrec.lean @@ -718,9 +718,6 @@ theorem fix_aux {α σ} (f : α →. σ ⊕ α) (a : α) (b : σ) : b ∈ PFun.fix f a := by intro F; refine ⟨fun h => ?_, fun h => ?_⟩ · rcases h with ⟨n, ⟨_x, h₁⟩, h₂⟩ - #adaptation_note /-- Before leanprover/lean4#13166, the proof from here to the end of the - first branch was: - ``` have : ∀ m a', Sum.inr a' ∈ F a m → b ∈ PFun.fix f a' → b ∈ PFun.fix f a := by intro m a' am ba induction m generalizing a' with simp [F] at am @@ -754,9 +751,9 @@ theorem fix_aux {α σ} (f : α →. σ ⊕ α) (a : α) (b : σ) : · simpa [F] using Or.inr ⟨_, hk, h₂⟩ · rwa [le_antisymm (Nat.le_of_lt_succ mk) km] · rcases IH _ am₃ k.succ (by simpa [F] using ⟨_, hk, am₃⟩) with ⟨n, hn₁, hn₂⟩ - #adaptation_note /-- After leanprover/lean4#13166 which arrived in nightly-2026-03-28: - This `clear_value` used to not be necessary. - -/ + #adaptation_note /-- Before https://github.com/leanprover/lean4/pull/13166 + (replacing grind's canonicalizer with a type-directed normalizer), + the `clear_value F` was not required here. -/ clear_value F grind From 89270ab2e3ca65c4b99cb3a658159630b6cc9d13 Mon Sep 17 00:00:00 2001 From: Kim Morrison Date: Tue, 7 Apr 2026 15:14:26 +1000 Subject: [PATCH 022/321] fixes --- .../Analysis/SpecialFunctions/Pow/NthRootLemmas.lean | 11 +++++++++++ Mathlib/NumberTheory/Padics/MahlerBasis.lean | 4 ++-- Mathlib/RingTheory/Smooth/Local.lean | 9 ++++++++- Mathlib/RingTheory/Spectrum/Prime/FreeLocus.lean | 4 +++- Mathlib/RingTheory/Spectrum/Prime/Polynomial.lean | 8 ++++++-- 5 files changed, 30 insertions(+), 6 deletions(-) diff --git a/Mathlib/Analysis/SpecialFunctions/Pow/NthRootLemmas.lean b/Mathlib/Analysis/SpecialFunctions/Pow/NthRootLemmas.lean index eac12117d3ea82..2f2b7c12bcd278 100644 --- a/Mathlib/Analysis/SpecialFunctions/Pow/NthRootLemmas.lean +++ b/Mathlib/Analysis/SpecialFunctions/Pow/NthRootLemmas.lean @@ -64,9 +64,20 @@ private theorem nthRoot.lt_pow_go_succ_aux0 (hb : b ≠ 0) : rw [Nat.le_div_iff_mul_le (by positivity), Nat.mul_comm, ← Nat.add_mul_div_right _ _ (by positivity), Nat.le_div_iff_mul_le (by positivity)] + #adaptation_note /-- Prior to nightly-2026-04-06, this was + ``` have := (Commute.all (b : ℤ) (a - b)).pow_add_mul_le_add_pow_of_sq_nonneg (by positivity) (sq_nonneg _) (sq_nonneg _) (by grind) (n + 1) grind + ``` + -/ + zify + have h := pow_add_mul_le_add_pow_of_sq_nonneg (a := (b : ℤ)) (b := (a : ℤ) - b) + (ha := by positivity) (Hsq := by positivity) (Hsq' := by positivity) (H := by omega) + (n := n + 1) + rw [← sub_nonneg] at h ⊢ + convert h using 1 + rw [pow_succ]; push_cast; ring1 private theorem nthRoot.always_exists (n a : ℕ) : ∃ c, c ^ (n + 1) ≤ a ∧ a < (c + 1) ^ (n + 1) := by diff --git a/Mathlib/NumberTheory/Padics/MahlerBasis.lean b/Mathlib/NumberTheory/Padics/MahlerBasis.lean index a0916015af130c..16a262245746ed 100644 --- a/Mathlib/NumberTheory/Padics/MahlerBasis.lean +++ b/Mathlib/NumberTheory/Padics/MahlerBasis.lean @@ -176,12 +176,12 @@ private lemma bojanic_mahler_step2 {f : C(ℤ_[p], E)} {s t : ℕ} refine (nnnorm_smul_le _ _).trans <| mul_le_mul_of_nonneg_right ?_ (by simp only [zero_le]) -- remains to show norm of binomial coeff is `≤ p⁻¹` rw [mem_range] at hi - have : 0 < (p ^ t).choose (i + 1) := Nat.choose_pos (by lia) + have : 0 < (p ^ t).choose (i + 1) := Nat.choose_pos (by omega) rw [← zpow_neg_one, ← coe_le_coe, coe_nnnorm, PadicInt.norm_eq_zpow_neg_valuation (mod_cast this.ne'), coe_zpow, NNReal.coe_natCast, zpow_le_zpow_iff_right₀ (mod_cast hp.out.one_lt), neg_le_neg_iff, ← PadicInt.valuation_coe, PadicInt.coe_natCast, Padic.valuation_natCast, Nat.one_le_cast] - exact one_le_padicValNat_of_dvd this.ne' <| hp.out.dvd_choose_pow (by lia) (by lia) + exact one_le_padicValNat_of_dvd this.ne' <| hp.out.dvd_choose_pow (by lia) (by omega) · -- Bounding the sum over `range (n + 1)`: every term is small by the choice of `t` refine norm_sum_le_of_forall_le_of_nonempty nonempty_range_add_one (fun i _ ↦ ?_) calc ‖((-1 : ℤ) ^ (n - i) * n.choose i) • (f (i + ↑(p ^ t)) - f i)‖ diff --git a/Mathlib/RingTheory/Smooth/Local.lean b/Mathlib/RingTheory/Smooth/Local.lean index 1170568f1a0884..e5b65c1c483373 100644 --- a/Mathlib/RingTheory/Smooth/Local.lean +++ b/Mathlib/RingTheory/Smooth/Local.lean @@ -86,7 +86,14 @@ theorem FormallySmooth.iff_injective_cotangentComplexBaseChange (cotangentComplexBaseChange R S P (ResidueField S)).baseChange K ∘ₗ (AlgebraTensorModule.cancelBaseChange _ _ _ _ _).symm.toLinearMap = (cotangentComplexBaseChange R S P K) := by - ext; simp [cotangentComplexBaseChange_tmul] + ext + #adaptation_note /-- Prior to nightly-2026-04-06, this was just `simp`. -/ + simp_rw [AlgebraTensorModule.curry_apply, LinearMap.restrictScalars_comp, curry_apply, + LinearMap.coe_comp, LinearMap.coe_restrictScalars, LinearEquiv.coe_coe, Function.comp_apply, + AlgebraTensorModule.cancelBaseChange_symm_tmul, LinearMap.baseChange_tmul, + cotangentComplexBaseChange_tmul, kerToTensor_apply, one_smul] + erw [AlgebraTensorModule.cancelBaseChange_tmul] + simp rw [← this] refine .trans ?_ ((AlgebraTensorModule.cancelBaseChange _ _ _ _ _).comp_injective _).symm exact ((AlgebraTensorModule.cancelBaseChange _ _ _ _ _).symm.injective_comp _).symm diff --git a/Mathlib/RingTheory/Spectrum/Prime/FreeLocus.lean b/Mathlib/RingTheory/Spectrum/Prime/FreeLocus.lean index 116668a97005d1..f18305d1ebe4a1 100644 --- a/Mathlib/RingTheory/Spectrum/Prime/FreeLocus.lean +++ b/Mathlib/RingTheory/Spectrum/Prime/FreeLocus.lean @@ -363,6 +363,8 @@ lemma rankAtStalk_eq (p : PrimeSpectrum R) : let e : k ⊗[Localization.AtPrime p.asIdeal] (Localization.AtPrime p.asIdeal ⊗[R] M) ≃ₗ[k] k ⊗[R] M := AlgebraTensorModule.cancelBaseChange _ _ _ _ _ - rw [← e.finrank_eq, finrank_baseChange, rankAtStalk_eq_finrank_tensorProduct] + rw [← e.finrank_eq] + erw [finrank_baseChange] + rw [rankAtStalk_eq_finrank_tensorProduct] end Module diff --git a/Mathlib/RingTheory/Spectrum/Prime/Polynomial.lean b/Mathlib/RingTheory/Spectrum/Prime/Polynomial.lean index 69e1acf489083f..47857e62d8d4bf 100644 --- a/Mathlib/RingTheory/Spectrum/Prime/Polynomial.lean +++ b/Mathlib/RingTheory/Spectrum/Prime/Polynomial.lean @@ -45,13 +45,16 @@ lemma isNilpotent_tensor_residueField_iff · have := (algebraMap R (A ⊗[R] I.ResidueField)).codomain_trivial simp [Subsingleton.elim I ⊤, Subsingleton.elim (f ⊗ₜ[R] (1 : I.ResidueField)) 0] have : Module.finrank I.ResidueField (I.ResidueField ⊗[R] A) = Module.finrank R A := by - rw [Module.finrank_tensorProduct, Module.finrank_self, one_mul] + rw [Module.finrank_tensorProduct] + erw [Module.finrank_self] + rw [one_mul] rw [← IsNilpotent.map_iff (Algebra.TensorProduct.comm R A I.ResidueField).injective] simp only [Algebra.TensorProduct.algebraMap_apply, Algebra.algebraMap_self, RingHom.id_apply, Algebra.coe_lmul_eq_mul, Algebra.TensorProduct.comm_tmul] rw [← IsNilpotent.map_iff (Algebra.lmul_injective (R := I.ResidueField)), LinearMap.isNilpotent_iff_charpoly, ← Algebra.baseChange_lmul, LinearMap.charpoly_baseChange] - simp_rw [this, ← ((LinearMap.mul R A) f).charpoly_natDegree] + erw [this] + simp_rw [← ((LinearMap.mul R A) f).charpoly_natDegree] constructor · intro e i hi replace e := congr(($e).coeff i) @@ -137,6 +140,7 @@ end PrimeSpectrum namespace Polynomial +set_option backward.isDefEq.respectTransparency false in lemma mem_image_comap_C_basicOpen (f : R[X]) (x : PrimeSpectrum R) : x ∈ comap C '' basicOpen f ↔ ∃ i, f.coeff i ∉ x.asIdeal := by trans f.map (algebraMap R x.asIdeal.ResidueField) ≠ 0 From c102fda895612f50316183af35ee8621658a3fd3 Mon Sep 17 00:00:00 2001 From: Kim Morrison Date: Tue, 7 Apr 2026 15:46:54 +1000 Subject: [PATCH 023/321] fixes --- .../Rpow/RingInverseOrder.lean | 20 ++++++++++++++++--- .../EisensteinSeries/E2/Transform.lean | 2 +- .../LocalRing/ResidueField/Polynomial.lean | 4 +++- .../RingTheory/Unramified/LocalStructure.lean | 5 +++++ 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/Mathlib/Analysis/SpecialFunctions/ContinuousFunctionalCalculus/Rpow/RingInverseOrder.lean b/Mathlib/Analysis/SpecialFunctions/ContinuousFunctionalCalculus/Rpow/RingInverseOrder.lean index 95d298facbfa5c..11025531a88a4e 100644 --- a/Mathlib/Analysis/SpecialFunctions/ContinuousFunctionalCalculus/Rpow/RingInverseOrder.lean +++ b/Mathlib/Analysis/SpecialFunctions/ContinuousFunctionalCalculus/Rpow/RingInverseOrder.lean @@ -48,12 +48,22 @@ public lemma convexOn_ringInverse : by_cases ha' : a = 0 · have hb' : b = 1 := by grind simp only [ha', hb', one_mul, zero_add, gt_iff_lt] - grind + #adaptation_note /-- Before nightly-2026-06-04, this was just `grind. + `spectrum_pos` is not activating in `grind` despite the + ``` + grind_pattern IsStrictlyPositive.spectrum_pos => x ∈ spectrum 𝕜 a, IsStrictlyPositive a + ``` + rule, because `grind` will not fill in the `𝕜 := ℝ`. -/ + exact zpos.spectrum_pos hr · grind [add_pos_of_pos_of_nonneg, mul_nonneg] have h₂ : (a • 1 + b • z ^ (-1 : ℝ)) = cfc (fun r => (a + b * r ^ (-1 : ℝ))) z := by rw [CFC.rpow_eq_cfc_real zpos.nonneg] have hcont : ContinuousOn (fun r : ℝ => (r ^ (-1 : ℝ))) (spectrum ℝ z) := - ContinuousOn.rpow_const (f := id) (by fun_prop) (by grind) + ContinuousOn.rpow_const (f := id) (by fun_prop) (by + #adaptation_note /-- Before nightly-2026-06-04, this was just `grind. -/ + intro x h + have := IsStrictlyPositive.spectrum_pos (𝕜 := ℝ) zpos h + grind) rw [← cfc_smul b _ z hcont, ← Algebra.algebraMap_eq_smul_one, ← cfc_const_add a _ z] refine cfc_congr fun r hr => ?_ simp @@ -72,7 +82,11 @@ public lemma convexOn_ringInverse : have : 0 ≤ b * r := by positivity cases lt_or_eq_of_le ha <;> grind · refine ContinuousOn.const_add (ContinuousOn.const_mul ?_ _) _ - exact ContinuousOn.rpow_const (by fun_prop) (by grind) + exact ContinuousOn.rpow_const (by fun_prop) (by + #adaptation_note /-- Before nightly-2026-06-04, this was just `grind. -/ + intro x h + have := IsStrictlyPositive.spectrum_pos (𝕜 := ℝ) zpos h + grind) · intro r hr suffices (a • 1 + b • r) ^ (-1 : ℤ) ≤ a • 1 ^ (-1 : ℤ) + b • r ^ (-1 : ℤ) by simp_rw [← Real.rpow_intCast] at this diff --git a/Mathlib/NumberTheory/ModularForms/EisensteinSeries/E2/Transform.lean b/Mathlib/NumberTheory/ModularForms/EisensteinSeries/E2/Transform.lean index 771eae90dacbbc..2eeb0a33fcee3b 100644 --- a/Mathlib/NumberTheory/ModularForms/EisensteinSeries/E2/Transform.lean +++ b/Mathlib/NumberTheory/ModularForms/EisensteinSeries/E2/Transform.lean @@ -136,7 +136,7 @@ lemma G2_eq_tsum_G2Term (z : ℍ) : G2 z = ∑' m, ∑' n, G2Term z ![m, n] := b exact tsum_congr (fun b ↦ by simp [eisSummand, G2Term, aux_identity z a b, zpow_ofNat]) · simpa only [tsum_symmetricIco_linear_sub_linear_add_one_eq_zero z, add_zero] using (G2Term_prod_summable z).prod - · grind [(G2Term_prod_summable z).prod.congr] + · exact (G2Term_prod_summable z).prod · exact summable_zero.congr fun b ↦ by simp [← tsum_symmetricIco_linear_sub_linear_add_one_eq_zero z b] diff --git a/Mathlib/RingTheory/LocalRing/ResidueField/Polynomial.lean b/Mathlib/RingTheory/LocalRing/ResidueField/Polynomial.lean index 671dd76bf0d9e9..f73500b01275f0 100644 --- a/Mathlib/RingTheory/LocalRing/ResidueField/Polynomial.lean +++ b/Mathlib/RingTheory/LocalRing/ResidueField/Polynomial.lean @@ -60,7 +60,9 @@ def residueFieldMapCAlgEquiv [J.LiesOver I] (hJ : J = I.map C) : apply_fun aeval (algebraMap R[X] J.ResidueField X) at hr simpa [hx, aeval_map_algebraMap, aeval_algebraMap_apply, Algebra.smul_def] using hr refine ((IsUnit.mk0 (algebraMap R I.ResidueField s) (by simpa)).map C).mul_right_injective ?_ - simp only [← algebraMap_eq, ← Algebra.smul_def, algebraMap_smul, ← hr] + simp only [← algebraMap_eq, ← Algebra.smul_def] + erw [algebraMap_smul] + simp only [← hr] simpa [Polynomial.ext_iff, Ideal.mem_map_C_iff] using hJ.le hx · apply AlgHom.coe_ringHom_injective apply IsFractionRing.injective_comp_algebraMap (A := I.ResidueField[X]) diff --git a/Mathlib/RingTheory/Unramified/LocalStructure.lean b/Mathlib/RingTheory/Unramified/LocalStructure.lean index 8addca99368585..5f5b483d59f010 100644 --- a/Mathlib/RingTheory/Unramified/LocalStructure.lean +++ b/Mathlib/RingTheory/Unramified/LocalStructure.lean @@ -209,6 +209,11 @@ lemma exists_notMem_forall_ne_mem_and_adjoin_eq_top #adaptation_note /-- Needed after nightly-2023-02-23 -/ have : p.IsPrime := Ideal.IsPrime.under R Q classical + #adaptation_note /-- After nightly-2026-04-06, typeclass synthesis fails to find these + instances; provide them explicitly. -/ + letI : Module p.ResidueField (p.Fiber S) := TensorProduct.leftModule + letI : IsScalarTower p.ResidueField (p.Fiber S) (p.Fiber S) := IsScalarTower.right + letI : Module.Finite p.ResidueField (p.Fiber S) := Module.Finite.base_change R p.ResidueField S have : IsArtinianRing (p.Fiber S) := .of_finite p.ResidueField _ let α := PrimeSpectrum.primesOverOrderIsoFiber R S p obtain ⟨x, hx0, hx⟩ : ∃ x : Q.ResidueField, x ≠ 0 ∧ p.ResidueField[x] = ⊤ := by From 3a751b4e712416f981239ca850d8bed38f9a0269 Mon Sep 17 00:00:00 2001 From: Kim Morrison Date: Tue, 7 Apr 2026 16:28:08 +1000 Subject: [PATCH 024/321] unpleasant fix. --- .../Trigonometric/Chebyshev/RootsExtrema.lean | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Mathlib/Analysis/SpecialFunctions/Trigonometric/Chebyshev/RootsExtrema.lean b/Mathlib/Analysis/SpecialFunctions/Trigonometric/Chebyshev/RootsExtrema.lean index 0eee892dbf77bd..92a5f70d0bf6dd 100644 --- a/Mathlib/Analysis/SpecialFunctions/Trigonometric/Chebyshev/RootsExtrema.lean +++ b/Mathlib/Analysis/SpecialFunctions/Trigonometric/Chebyshev/RootsExtrema.lean @@ -44,7 +44,15 @@ theorem eval_T_real_mem_Icc (n : ℤ) {x : ℝ} (hx : x ∈ Set.Icc (-1) 1) : grind [T_real_cos, cos_mem_Icc] theorem abs_eval_T_real_le_one (n : ℤ) {x : ℝ} (hx : |x| ≤ 1) : - |(T ℝ n).eval x| ≤ 1 := by grind [eval_T_real_mem_Icc] + |(T ℝ n).eval x| ≤ 1 := by + #adaptation_note /-- Before nightly-2026-04-07, this was just + `grind [eval_T_real_mem_Icc]`. `grind`'s e-matching now keeps the + `Polynomial.eval` produced by the lemma (which uses `instCommSemiring.toSemiring`) + and the `Polynomial.eval` propagated by abs unfolding (which uses `Real.semiring`) + as distinct atoms, even though they are `rfl`-equal, so the contradiction is + never found. -/ + have h := eval_T_real_mem_Icc n (Set.mem_Icc.mpr (abs_le.mp hx)) + exact abs_le.mpr (Set.mem_Icc.mp h) theorem one_le_eval_T_real (n : ℤ) {x : ℝ} (hx : 1 ≤ x) : 1 ≤ (T ℝ n).eval x := by rw [← cosh_arcosh hx] From 5212dc478426d5caca02fc5aea6df6d211fbdd7e Mon Sep 17 00:00:00 2001 From: Kim Morrison Date: Tue, 7 Apr 2026 17:16:19 +1000 Subject: [PATCH 025/321] touch for CI From ac5cf06a1486851b71217ca2e627eb652b6801a9 Mon Sep 17 00:00:00 2001 From: Kim Morrison Date: Tue, 7 Apr 2026 18:26:03 +1000 Subject: [PATCH 026/321] cleanup of adaptation notes --- Mathlib/Algebra/Group/Ext.lean | 6 +----- Mathlib/Analysis/SpecialFunctions/Integrals/Basic.lean | 6 +----- Mathlib/Combinatorics/SimpleGraph/Acyclic.lean | 6 +----- Mathlib/Data/Fin/VecNotation.lean | 3 +-- Mathlib/Data/Matrix/Reflection.lean | 4 ---- 5 files changed, 4 insertions(+), 21 deletions(-) diff --git a/Mathlib/Algebra/Group/Ext.lean b/Mathlib/Algebra/Group/Ext.lean index 4de2994db58ed2..3874fa32780c75 100644 --- a/Mathlib/Algebra/Group/Ext.lean +++ b/Mathlib/Algebra/Group/Ext.lean @@ -109,11 +109,7 @@ theorem CancelMonoid.toRightCancelMonoid_injective {M : Type u} : theorem CancelCommMonoid.toCommMonoid_injective {M : Type u} : Function.Injective (@CancelCommMonoid.toCommMonoid M) := by rintro @⟨@⟨@⟨⟩⟩⟩ @⟨@⟨@⟨⟩⟩⟩ h - #adaptation_note /-- Before leanprover/lean4#13166, the last line was `grind`. - The new type-directed canonicalizer tries to synthesize `Monoid M` / `CommMonoid M` to normalize - sub-expressions, but fails because after `rintro` the instances exist only as destructured fields - in the local context, not as registered typeclass instances. -/ - cases h; rfl + grind @[to_additive (attr := ext)] theorem CancelCommMonoid.ext {M : Type*} ⦃m₁ m₂ : CancelCommMonoid M⦄ diff --git a/Mathlib/Analysis/SpecialFunctions/Integrals/Basic.lean b/Mathlib/Analysis/SpecialFunctions/Integrals/Basic.lean index 30e04adcabb923..fbe99b3892ded6 100644 --- a/Mathlib/Analysis/SpecialFunctions/Integrals/Basic.lean +++ b/Mathlib/Analysis/SpecialFunctions/Integrals/Basic.lean @@ -331,11 +331,7 @@ theorem integral_cos_mul_complex {z : ℂ} (hz : z ≠ 0) (a b : ℝ) : have b : HasDerivAt (fun y => y * z : ℂ → ℂ) z ↑x := hasDerivAt_mul_const _ have c : HasDerivAt (Complex.sin ∘ fun y : ℂ => (y * z)) _ ↑x := HasDerivAt.comp (𝕜 := ℂ) x a b have d := HasDerivAt.comp_ofReal (c.div_const z) - #adaptation_note /-- Before https://github.com/leanprover/lean4/pull/13166 - (replacing grind's canonicalizer with a type-directed normalizer), `grind` closed this goal. - It is not yet clear whether this is due to defeq abuse in Mathlib or a problem in the new - canonicalizer; a minimization would help. The original proof was: `grind` -/ - simpa [hz, mul_comm] using d + grind theorem integral_cos_sq_sub_sin_sq : ∫ x in a..b, cos x ^ 2 - sin x ^ 2 = sin b * cos b - sin a * cos a := by diff --git a/Mathlib/Combinatorics/SimpleGraph/Acyclic.lean b/Mathlib/Combinatorics/SimpleGraph/Acyclic.lean index a8976fcfe16ed7..a9491a78f72c6f 100644 --- a/Mathlib/Combinatorics/SimpleGraph/Acyclic.lean +++ b/Mathlib/Combinatorics/SimpleGraph/Acyclic.lean @@ -652,11 +652,7 @@ lemma exists_isCycle_of_two_le_isEdgeReachable {u v : V} (huv : u ≠ v) {n : (h : G.IsEdgeReachable n u v) : ∃ w : G.Walk u u, w.IsCycle := by classical obtain ⟨w, hw, h⟩ := exists_adj_isEdgeReachable_two huv (h.anti hn) - #adaptation_note /-- Before https://github.com/leanprover/lean4/pull/13166 - (replacing grind's canonicalizer with a type-directed normalizer), this was just - `have := @h {s(u, w)} (by simp)`. It is not yet clear whether this is due to defeq abuse in - Mathlib or a problem in the new canonicalizer; a minimization would help. -/ - have := @h {s(u, w)} (by simp only [Set.encard_singleton, Nat.cast_ofNat]; decide) + have := @h {s(u, w)} (by simp) obtain ⟨w, p, hp₁, hp₂⟩ := adj_and_reachable_delete_edges_iff_exists_cycle.mp ⟨hw, this⟩ exact ⟨p.rotate _ (p.fst_mem_support_of_mem_edges hp₂), hp₁.rotate _⟩ diff --git a/Mathlib/Data/Fin/VecNotation.lean b/Mathlib/Data/Fin/VecNotation.lean index 9da254a61f272d..11479cbb45ed13 100644 --- a/Mathlib/Data/Fin/VecNotation.lean +++ b/Mathlib/Data/Fin/VecNotation.lean @@ -413,8 +413,7 @@ theorem vecAlt1_vecAppend (v : Fin (n + 1) → α) : simp only [Nat.mod_add_mod, Nat.mod_eq_sub_mod h, show 1 % (n + 2) = 1 from Nat.mod_eq_of_lt (by lia)] refine (Nat.mod_eq_of_lt ?_).symm - #adaptation_note /-- After leanprover/lean4#13166, the `lia` tactic was timing out here. -/ - omega + lia @[simp] theorem vecHead_vecAlt0 (hm : m + 2 = n + 1 + (n + 1)) (v : Fin (m + 2) → α) : diff --git a/Mathlib/Data/Matrix/Reflection.lean b/Mathlib/Data/Matrix/Reflection.lean index 6e45ce70128528..2c82f38918ffcc 100644 --- a/Mathlib/Data/Matrix/Reflection.lean +++ b/Mathlib/Data/Matrix/Reflection.lean @@ -207,10 +207,6 @@ example [NonUnitalNonAssocSemiring α] (a₁₁ a₁₂ a₂₁ a₂₂ b₁ b def etaExpand {m n} (A : Matrix (Fin m) (Fin n) α) : Matrix (Fin m) (Fin n) α := Matrix.of (FinVec.etaExpand fun i => FinVec.etaExpand fun j => A i j) -#adaptation_note /-- Before https://github.com/leanprover/lean4/pull/13166 -(replacing grind's canonicalizer with a type-directed normalizer), `grind` closed this goal. -It is not yet clear whether this is due to defeq abuse in Mathlib or a problem in the new -canonicalizer; a minimization would help. The original proof was: `grind` -/ /-- This can be used to prove ```lean example (A : Matrix (Fin 2) (Fin 2) α) : From 85c19f239fc3a167a10e676314e00d305d2d4df9 Mon Sep 17 00:00:00 2001 From: mathlib4-bot Date: Tue, 7 Apr 2026 08:32:32 +0000 Subject: [PATCH 027/321] chore: adaptations for nightly-2026-04-06 From 939b2837a108267d255e41aece8c6aca29009a2a Mon Sep 17 00:00:00 2001 From: "mathlib-nightly-testing[bot]" Date: Tue, 7 Apr 2026 11:42:14 +0000 Subject: [PATCH 028/321] chore: bump to nightly-2026-04-07 --- lean-toolchain | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lean-toolchain b/lean-toolchain index 845eced439d5e8..54caac41bddf21 100644 --- a/lean-toolchain +++ b/lean-toolchain @@ -1 +1 @@ -leanprover/lean4:nightly-2026-04-06 +leanprover/lean4:nightly-2026-04-07 From fc6fe78b86732d20548064bc16550db6f1781c50 Mon Sep 17 00:00:00 2001 From: mathlib4-bot Date: Tue, 7 Apr 2026 12:52:43 +0000 Subject: [PATCH 029/321] chore: adaptations for nightly-2026-04-07 From 177922a8f8c95f77b3ed570eec55c8dea76dff27 Mon Sep 17 00:00:00 2001 From: "mathlib-nightly-testing[bot]" Date: Wed, 8 Apr 2026 09:32:09 +0000 Subject: [PATCH 030/321] chore: bump to nightly-2026-04-08 --- lean-toolchain | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lean-toolchain b/lean-toolchain index 54caac41bddf21..e33d600a6f3af0 100644 --- a/lean-toolchain +++ b/lean-toolchain @@ -1 +1 @@ -leanprover/lean4:nightly-2026-04-07 +leanprover/lean4:nightly-2026-04-08 From 9e49d8cb9a70a2add52730fb5f7b46561cfa53d6 Mon Sep 17 00:00:00 2001 From: leanprover-community-mathlib4-bot Date: Wed, 8 Apr 2026 17:58:27 +0000 Subject: [PATCH 031/321] Update lean-toolchain for testing https://github.com/leanprover/lean4/pull/13262 --- lake-manifest.json | 4 ++-- lakefile.lean | 2 +- lean-toolchain | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lake-manifest.json b/lake-manifest.json index ca0e4c0d66b879..65350d7df7920a 100644 --- a/lake-manifest.json +++ b/lake-manifest.json @@ -65,10 +65,10 @@ "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "bf597c77bf9b8e66720d724928207f5911533113", + "rev": "8043da856f876ee8095e8ed7da98c7a461f0095b", "name": "batteries", "manifestFile": "lake-manifest.json", - "inputRev": "v4.30.0-rc1", + "inputRev": "lean-pr-testing-13262", "inherited": false, "configFile": "lakefile.toml"}, {"url": "https://github.com/leanprover/lean4-cli", diff --git a/lakefile.lean b/lakefile.lean index 5f11ec894a69ad..ec9eb91e3274a1 100644 --- a/lakefile.lean +++ b/lakefile.lean @@ -6,7 +6,7 @@ open Lake DSL ## Mathlib dependencies on upstream projects -/ -require "leanprover-community" / "batteries" @ git "v4.30.0-rc1" +require "leanprover-community" / "batteries" @ git "lean-pr-testing-13262" require "leanprover-community" / "Qq" @ git "nightly-testing" require "leanprover-community" / "aesop" @ git "nightly-testing" require "leanprover-community" / "proofwidgets" @ git "v0.0.97" diff --git a/lean-toolchain b/lean-toolchain index 54caac41bddf21..48e83f3fea7ef9 100644 --- a/lean-toolchain +++ b/lean-toolchain @@ -1 +1 @@ -leanprover/lean4:nightly-2026-04-07 +leanprover/lean4-pr-releases:pr-release-13262-880d558 From 6cc8eafaec204db7f77bb679aa747d52544a2a35 Mon Sep 17 00:00:00 2001 From: leanprover-community-mathlib4-bot Date: Wed, 8 Apr 2026 23:55:25 +0000 Subject: [PATCH 032/321] Update lean-toolchain for https://github.com/leanprover/lean4/pull/13262 --- lake-manifest.json | 2 +- lean-toolchain | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lake-manifest.json b/lake-manifest.json index 65350d7df7920a..f696af530ecb8d 100644 --- a/lake-manifest.json +++ b/lake-manifest.json @@ -65,7 +65,7 @@ "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "8043da856f876ee8095e8ed7da98c7a461f0095b", + "rev": "81df6fddd38f4325480fed81241ffc8a362e3143", "name": "batteries", "manifestFile": "lake-manifest.json", "inputRev": "lean-pr-testing-13262", diff --git a/lean-toolchain b/lean-toolchain index 48e83f3fea7ef9..d2fd232933faf2 100644 --- a/lean-toolchain +++ b/lean-toolchain @@ -1 +1 @@ -leanprover/lean4-pr-releases:pr-release-13262-880d558 +leanprover/lean4-pr-releases:pr-release-13262-3d078ba From 8335db377cca76d18420cf00e36c98854d87404b Mon Sep 17 00:00:00 2001 From: Kyle Miller Date: Wed, 8 Apr 2026 20:25:06 -0700 Subject: [PATCH 033/321] universe fixes --- Mathlib/CategoryTheory/Sites/Sheaf.lean | 4 ++-- Mathlib/CategoryTheory/Sites/Sieves.lean | 6 +++--- Mathlib/CategoryTheory/Types/Basic.lean | 2 +- Mathlib/CategoryTheory/Yoneda.lean | 8 ++++---- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Mathlib/CategoryTheory/Sites/Sheaf.lean b/Mathlib/CategoryTheory/Sites/Sheaf.lean index df2d7918806dde..9df8cd42462f17 100644 --- a/Mathlib/CategoryTheory/Sites/Sheaf.lean +++ b/Mathlib/CategoryTheory/Sites/Sheaf.lean @@ -353,7 +353,7 @@ abbrev Sheaf.homEquiv {X Y : Sheaf J A} : (X ⟶ Y) ≃ (X.obj ⟶ Y.obj) := def sheafToPresheafCompYonedaCompWhiskeringLeftSheafToPresheaf : sheafToPresheaf J A ⋙ yoneda ⋙ (Functor.whiskeringLeft _ _ _).obj (sheafToPresheaf J A).op ≅ yoneda := - Functor.isoWhiskerLeft _ (Functor.isoWhiskerRight uliftYonedaIsoYoneda.symm.{max u₁ v₂} _) ≪≫ + Functor.isoWhiskerLeft _ (Functor.isoWhiskerRight uliftYonedaIsoYoneda.{max u₁ v₂}.symm _) ≪≫ (fullyFaithfulSheafToPresheaf J A).compUliftYonedaCompWhiskeringLeft ≪≫ uliftYonedaIsoYoneda @@ -368,7 +368,7 @@ def sheafToPresheafCompCoyonedaCompWhiskeringLeftSheafToPresheaf : (sheafToPresheaf J A).op ⋙ coyoneda ⋙ (Functor.whiskeringLeft _ _ _).obj (sheafToPresheaf J A) ≅ coyoneda := - Functor.isoWhiskerLeft _ (Functor.isoWhiskerRight uliftCoyonedaIsoCoyoneda.symm.{max u₁ v₂} _) ≪≫ + Functor.isoWhiskerLeft _ (Functor.isoWhiskerRight uliftCoyonedaIsoCoyoneda.{max u₁ v₂}.symm _) ≪≫ (fullyFaithfulSheafToPresheaf J A).compUliftCoyonedaCompWhiskeringLeft ≪≫ uliftCoyonedaIsoCoyoneda diff --git a/Mathlib/CategoryTheory/Sites/Sieves.lean b/Mathlib/CategoryTheory/Sites/Sieves.lean index 1a8c94931b14ec..940d06cd77b668 100644 --- a/Mathlib/CategoryTheory/Sites/Sieves.lean +++ b/Mathlib/CategoryTheory/Sites/Sieves.lean @@ -1253,13 +1253,13 @@ def uliftNatTransOfLe {S T : Sieve X} (h : S ≤ T) : /-- A variant of `Sieve.functorInclusion` with universe lifting. -/ @[simps! app] def uliftFunctorInclusion (S : Sieve X) : - S.uliftFunctor ⟶ uliftYoneda.obj.{w} X := + S.uliftFunctor ⟶ uliftYoneda.{w}.obj X := Functor.whiskerRight S.functorInclusion CategoryTheory.uliftFunctor /-- A variant of `Sieve.toFunctor` with universe lifting. -/ @[simps] def toUliftFunctor (S : Sieve X) {Y : C} (f : Y ⟶ X) (hf : S f) : - uliftYoneda.obj.{w} Y ⟶ Sieve.uliftFunctor.{w} S where + uliftYoneda.{w}.obj Y ⟶ Sieve.uliftFunctor.{w} S where app Z g := ⟨g.down ≫ f, S.downward_closed hf g.down⟩ theorem uliftNatTransOfLe_comm {S T : Sieve X} (h : S ≤ T) : @@ -1276,7 +1276,7 @@ instance uliftFunctorInclusion_is_mono (S : Sieve X) : /-- A variant of `Sieve.sieveOfSubfunctor` with universe lifting. -/ @[simps] -def sieveOfUliftSubfunctor {R : Cᵒᵖ ⥤ Type max w v₁} (f : R ⟶ uliftYoneda.obj.{w} X) : +def sieveOfUliftSubfunctor {R : Cᵒᵖ ⥤ Type max w v₁} (f : R ⟶ uliftYoneda.{w}.obj X) : Sieve X where arrows Y g := ∃ t, f.app (Opposite.op Y) t = { down := g } downward_closed := by diff --git a/Mathlib/CategoryTheory/Types/Basic.lean b/Mathlib/CategoryTheory/Types/Basic.lean index b2eb9a5f8f913a..87b829cfad9285 100644 --- a/Mathlib/CategoryTheory/Types/Basic.lean +++ b/Mathlib/CategoryTheory/Types/Basic.lean @@ -204,7 +204,7 @@ def uliftFunctor : Type u ⥤ Type max u v where map {X} {_} f := fun x : ULift.{v} X => ULift.up (f x.down) @[simp] -theorem uliftFunctor_obj {X : Type u} : uliftFunctor.obj.{v} X = ULift.{v} X := +theorem uliftFunctor_obj {X : Type u} : uliftFunctor.{v}.obj X = ULift.{v} X := rfl @[simp] diff --git a/Mathlib/CategoryTheory/Yoneda.lean b/Mathlib/CategoryTheory/Yoneda.lean index d4afb27182601d..208d8ba2ce4e48 100644 --- a/Mathlib/CategoryTheory/Yoneda.lean +++ b/Mathlib/CategoryTheory/Yoneda.lean @@ -1245,7 +1245,7 @@ variable {C : Type u₁} [Category.{v₁} C] /-- `FullyFaithful.homEquiv` as a natural isomorphism. -/ @[simps!] def homNatIso {D : Type u₂} [Category.{v₂} D] {F : C ⥤ D} (hF : F.FullyFaithful) (X : C) : - F.op ⋙ uliftYoneda.obj.{v₁} (F.obj X) ≅ uliftYoneda.obj.{v₂} X := + F.op ⋙ uliftYoneda.{v₁}.obj (F.obj X) ≅ uliftYoneda.{v₂}.obj X := NatIso.ofComponents (fun Y => Equiv.toIso (Equiv.ulift.trans <| hF.homEquiv.symm.trans Equiv.ulift.symm)) (fun f => by ext; exact Equiv.ulift.injective (hF.map_injective (by simp))) @@ -1253,7 +1253,7 @@ def homNatIso {D : Type u₂} [Category.{v₂} D] {F : C ⥤ D} (hF : F.FullyFai /-- `FullyFaithful.homEquiv` as a natural isomorphism. -/ @[simps!, deprecated homNatIso (since := "2025-10-28")] def homNatIsoMaxRight {D : Type u₂} [Category.{max v₁ v₂} D] {F : C ⥤ D} (hF : F.FullyFaithful) - (X : C) : F.op ⋙ yoneda.obj (F.obj X) ≅ uliftYoneda.obj.{v₂} X := + (X : C) : F.op ⋙ yoneda.obj (F.obj X) ≅ uliftYoneda.{v₂}.obj X := isoWhiskerLeft F.op (uliftYonedaIsoYoneda.symm.app _) ≪≫ hF.homNatIso _ ≪≫ NatIso.ofComponents (fun _ => Equiv.toIso (Equiv.ulift.trans Equiv.ulift.symm)) @@ -1273,7 +1273,7 @@ def compUliftYonedaCompWhiskeringLeft {D : Type u₂} [Category.{v₂} D] {F : C @[simps!, deprecated compUliftYonedaCompWhiskeringLeft (since := "2025-10-28")] def compYonedaCompWhiskeringLeftMaxRight {D : Type u₂} [Category.{max v₁ v₂} D] {F : C ⥤ D} (hF : F.FullyFaithful) : F ⋙ yoneda ⋙ (whiskeringLeft _ _ _).obj F.op ≅ uliftYoneda.{v₂} := by - refine isoWhiskerLeft F (isoWhiskerRight uliftYonedaIsoYoneda.symm.{v₁} _) ≪≫ + refine isoWhiskerLeft F (isoWhiskerRight uliftYonedaIsoYoneda.{v₁}.symm _) ≪≫ hF.compUliftYonedaCompWhiskeringLeft ≪≫ NatIso.ofComponents (fun _ => NatIso.ofComponents (fun _ => Equiv.toIso (Equiv.ulift.trans Equiv.ulift.symm))) @@ -1281,7 +1281,7 @@ def compYonedaCompWhiskeringLeftMaxRight {D : Type u₂} [Category.{max v₁ v /-- `FullyFaithful.homEquiv` as a natural isomorphism, using coyoneda. -/ @[simps!] def homNatIso' {D : Type u₂} [Category.{v₂} D] {F : C ⥤ D} (hF : F.FullyFaithful) (X : C) : - F ⋙ uliftCoyoneda.obj.{v₁} (op (F.obj X)) ≅ uliftCoyoneda.obj.{v₂} (op X) := + F ⋙ uliftCoyoneda.{v₁}.obj (op (F.obj X)) ≅ uliftCoyoneda.{v₂}.obj (op X) := NatIso.ofComponents (fun Y => Equiv.toIso (Equiv.ulift.trans <| hF.homEquiv.symm.trans Equiv.ulift.symm)) (fun f => by ext; exact Equiv.ulift.injective (hF.map_injective (by simp))) From ba688b059328e6c04ee9dd81d14b02118c1bd202 Mon Sep 17 00:00:00 2001 From: "mathlib-nightly-testing[bot]" Date: Thu, 9 Apr 2026 09:23:23 +0000 Subject: [PATCH 034/321] chore: bump to nightly-2026-04-09 --- lean-toolchain | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lean-toolchain b/lean-toolchain index e33d600a6f3af0..d04b8570d780a2 100644 --- a/lean-toolchain +++ b/lean-toolchain @@ -1 +1 @@ -leanprover/lean4:nightly-2026-04-08 +leanprover/lean4:nightly-2026-04-09 From 7f296068b1c1f2b4c99bd2317a9a7699a6ff375d Mon Sep 17 00:00:00 2001 From: leanprover-community-mathlib4-bot Date: Thu, 9 Apr 2026 14:13:26 +0000 Subject: [PATCH 035/321] Update lean-toolchain for testing https://github.com/leanprover/lean4/pull/13346 --- lake-manifest.json | 4 ++-- lakefile.lean | 2 +- lean-toolchain | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lake-manifest.json b/lake-manifest.json index ca0e4c0d66b879..a26e3a1c3e3814 100644 --- a/lake-manifest.json +++ b/lake-manifest.json @@ -65,10 +65,10 @@ "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "bf597c77bf9b8e66720d724928207f5911533113", + "rev": "246cb7bbce0b5593f7c40000a9855e42329ae058", "name": "batteries", "manifestFile": "lake-manifest.json", - "inputRev": "v4.30.0-rc1", + "inputRev": "lean-pr-testing-13346", "inherited": false, "configFile": "lakefile.toml"}, {"url": "https://github.com/leanprover/lean4-cli", diff --git a/lakefile.lean b/lakefile.lean index 5f11ec894a69ad..fdb831d2eb4cea 100644 --- a/lakefile.lean +++ b/lakefile.lean @@ -6,7 +6,7 @@ open Lake DSL ## Mathlib dependencies on upstream projects -/ -require "leanprover-community" / "batteries" @ git "v4.30.0-rc1" +require "leanprover-community" / "batteries" @ git "lean-pr-testing-13346" require "leanprover-community" / "Qq" @ git "nightly-testing" require "leanprover-community" / "aesop" @ git "nightly-testing" require "leanprover-community" / "proofwidgets" @ git "v0.0.97" diff --git a/lean-toolchain b/lean-toolchain index 54caac41bddf21..4f439da4cc04bb 100644 --- a/lean-toolchain +++ b/lean-toolchain @@ -1 +1 @@ -leanprover/lean4:nightly-2026-04-07 +leanprover/lean4-pr-releases:pr-release-13346-91e7769 From 7dae75463637afdbb7eba2eccfde9591b0a13353 Mon Sep 17 00:00:00 2001 From: leanprover-community-mathlib4-bot Date: Thu, 9 Apr 2026 16:57:57 +0000 Subject: [PATCH 036/321] Update lean-toolchain for https://github.com/leanprover/lean4/pull/13346 --- lake-manifest.json | 2 +- lean-toolchain | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lake-manifest.json b/lake-manifest.json index a26e3a1c3e3814..fd3e9f4d053fac 100644 --- a/lake-manifest.json +++ b/lake-manifest.json @@ -65,7 +65,7 @@ "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "246cb7bbce0b5593f7c40000a9855e42329ae058", + "rev": "950affb5a818f3f95c41b4c22e93d68dd11b6e93", "name": "batteries", "manifestFile": "lake-manifest.json", "inputRev": "lean-pr-testing-13346", diff --git a/lean-toolchain b/lean-toolchain index 4f439da4cc04bb..d5e2ba14ec6a43 100644 --- a/lean-toolchain +++ b/lean-toolchain @@ -1 +1 @@ -leanprover/lean4-pr-releases:pr-release-13346-91e7769 +leanprover/lean4-pr-releases:pr-release-13346-b81b581 From 5c03f00b1b90ad5cd6855e50502e6dd8800365ee Mon Sep 17 00:00:00 2001 From: Kim Morrison Date: Fri, 10 Apr 2026 02:21:15 +0000 Subject: [PATCH 037/321] lake update --- lake-manifest.json | 4 ++-- lakefile.lean | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lake-manifest.json b/lake-manifest.json index f159f5ea44360d..e1195bfea169f7 100644 --- a/lake-manifest.json +++ b/lake-manifest.json @@ -65,10 +65,10 @@ "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "bf597c77bf9b8e66720d724928207f5911533113", + "rev": "e32a6d4b187ab88d3e3e5c5bc520fcebc42b2960", "name": "batteries", "manifestFile": "lake-manifest.json", - "inputRev": "v4.30.0-rc1", + "inputRev": "nightly-testing", "inherited": false, "configFile": "lakefile.toml"}, {"url": "https://github.com/leanprover/lean4-cli", diff --git a/lakefile.lean b/lakefile.lean index 5f11ec894a69ad..bbba35493244d0 100644 --- a/lakefile.lean +++ b/lakefile.lean @@ -6,7 +6,7 @@ open Lake DSL ## Mathlib dependencies on upstream projects -/ -require "leanprover-community" / "batteries" @ git "v4.30.0-rc1" +require "leanprover-community" / "batteries" @ git "nightly-testing" require "leanprover-community" / "Qq" @ git "nightly-testing" require "leanprover-community" / "aesop" @ git "nightly-testing" require "leanprover-community" / "proofwidgets" @ git "v0.0.97" From e51294596c4f249debac2e6c95ed9d7d74368abe Mon Sep 17 00:00:00 2001 From: Kim Morrison Date: Fri, 10 Apr 2026 02:27:08 +0000 Subject: [PATCH 038/321] fixes --- Mathlib/Algebra/BigOperators/Group/List/Basic.lean | 7 ++----- Mathlib/GroupTheory/FreeGroup/Basic.lean | 6 +++--- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/Mathlib/Algebra/BigOperators/Group/List/Basic.lean b/Mathlib/Algebra/BigOperators/Group/List/Basic.lean index 10b0b3e4b5e08d..96546ee4f9951f 100644 --- a/Mathlib/Algebra/BigOperators/Group/List/Basic.lean +++ b/Mathlib/Algebra/BigOperators/Group/List/Basic.lean @@ -244,11 +244,8 @@ lemma prod_map_erase [DecidableEq α] (f : α → M) {a} : @[to_additive] lemma Perm.prod_eq (h : Perm l₁ l₂) : prod l₁ = prod l₂ := h.foldr_op_eq --- In order to make `to_additive` work, this theorem is adjusted to `List.sum_reverse` from core -@[to_additive existing, simp] -lemma prod_reverse [One α] [Mul α] [@Std.Associative α (· * ·)] [@Std.Commutative α (· * ·)] - [@Std.LawfulLeftIdentity α α (· * ·) 1] (l : List α) : prod l.reverse = prod l := - @List.sum_reverse α ⟨1⟩ ⟨(· * ·)⟩ _ _ _ l +set_option linter.existingAttributeWarning false in +attribute [to_additive existing] prod_reverse @[to_additive] lemma prod_mul_prod_eq_prod_zipWith_mul_prod_drop : diff --git a/Mathlib/GroupTheory/FreeGroup/Basic.lean b/Mathlib/GroupTheory/FreeGroup/Basic.lean index 5831d64e9de81c..f3473e05b869bc 100644 --- a/Mathlib/GroupTheory/FreeGroup/Basic.lean +++ b/Mathlib/GroupTheory/FreeGroup/Basic.lean @@ -331,14 +331,14 @@ protected theorem sublist : Red L₁ L₂ → L₂ <+ L₁ := theorem length_le (h : Red L₁ L₂) : L₂.length ≤ L₁.length := h.sublist.length_le - -@[to_additive] +@[to_additive (attr := deprecated "Should not be needed." (since := "2026-04-10"))] theorem sizeof_of_step : ∀ {L₁ L₂ : List (α × Bool)}, Step L₁ L₂ → sizeOf L₂ < sizeOf L₁ | _, _, @Step.not _ L1 L2 x b => by induction L1 with | nil => - dsimp + -- This was just `dsimp` prior to https://github.com/leanprover/lean4/pull/13320 + dsimp [sizeOf, _sizeOf_1] lia | cons hd tl ih => dsimp From f55f739a63987e8722eb768ca167937026d38f2a Mon Sep 17 00:00:00 2001 From: Kim Morrison Date: Fri, 10 Apr 2026 03:30:38 +0000 Subject: [PATCH 039/321] fix tests --- MathlibTest/BasicFiles/Init.lean | 2 +- MathlibTest/BasicFiles/Tactic.lean | 2 +- MathlibTest/BasicFiles/TacticBasic.lean | 2 +- MathlibTest/BasicFiles/TacticCommon.lean | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/MathlibTest/BasicFiles/Init.lean b/MathlibTest/BasicFiles/Init.lean index 59ca2efa0b844f..4cbb559c20d688 100644 --- a/MathlibTest/BasicFiles/Init.lean +++ b/MathlibTest/BasicFiles/Init.lean @@ -33,7 +33,7 @@ import Mathlib.Init proof_wanted please_prove_this : True -- Guard against the shake tool modifying our imports -/-- info: [public import Init, import Mathlib.Init] -/ +/-- info: [public import Init, public meta import Init, import Mathlib.Init] -/ #guard_msgs in run_elab Lean.logInfo m!"{(← Lean.MonadEnv.getEnv).imports}" diff --git a/MathlibTest/BasicFiles/Tactic.lean b/MathlibTest/BasicFiles/Tactic.lean index 3368b3c7823a2c..3944dcda6da406 100644 --- a/MathlibTest/BasicFiles/Tactic.lean +++ b/MathlibTest/BasicFiles/Tactic.lean @@ -8,6 +8,6 @@ import Mathlib.Tactic #find_syntax "test_find_syntax" approx -- Guard against the shake tool modifying our imports -/-- info: [public import Init, import Mathlib.Tactic] -/ +/-- info: [public import Init, public meta import Init, import Mathlib.Tactic] -/ #guard_msgs in run_elab Lean.logInfo m!"{(← Lean.MonadEnv.getEnv).imports}" diff --git a/MathlibTest/BasicFiles/TacticBasic.lean b/MathlibTest/BasicFiles/TacticBasic.lean index f19fa468ff29b1..f1e44b1e8b7eb5 100644 --- a/MathlibTest/BasicFiles/TacticBasic.lean +++ b/MathlibTest/BasicFiles/TacticBasic.lean @@ -5,6 +5,6 @@ import Mathlib.Tactic.Basic /-! Checks that some utilities are available already when importing `Mathlib.Tactic.Basic`. -/ -- Guard against the shake tool modifying our imports -/-- info: [public import Init, import Mathlib.Tactic.Basic] -/ +/-- info: [public import Init, public meta import Init, import Mathlib.Tactic.Basic] -/ #guard_msgs in run_elab Lean.logInfo m!"{(← Lean.MonadEnv.getEnv).imports}" diff --git a/MathlibTest/BasicFiles/TacticCommon.lean b/MathlibTest/BasicFiles/TacticCommon.lean index 7c9190b296c047..3ae7c274824d68 100644 --- a/MathlibTest/BasicFiles/TacticCommon.lean +++ b/MathlibTest/BasicFiles/TacticCommon.lean @@ -32,6 +32,6 @@ theorem test_count_heartbeats : True := trivial theorem test_print_sorries : True := sorry -- Guard against the shake tool modifying our imports -/-- info: [public import Init, import Mathlib.Tactic.Common] -/ +/-- info: [public import Init, public meta import Init, import Mathlib.Tactic.Common] -/ #guard_msgs in run_elab Lean.logInfo m!"{(← Lean.MonadEnv.getEnv).imports}" From 3f816388b0545a90277feb07b05533b861b6cf98 Mon Sep 17 00:00:00 2001 From: Kim Morrison Date: Fri, 10 Apr 2026 03:39:14 +0000 Subject: [PATCH 040/321] ci: skip inputRev validation on nightly-testing branch Co-Authored-By: Claude Opus 4.6 (1M context) --- .github/workflows/build_template.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_template.yml b/.github/workflows/build_template.yml index 4904fb8d237b29..e0afc8a1fb5975 100644 --- a/.github/workflows/build_template.yml +++ b/.github/workflows/build_template.yml @@ -222,7 +222,7 @@ jobs: - name: validate lake-manifest.json inputRevs # Only enforce this on the main mathlib4 repository, not on nightly-testing - if: github.repository == 'leanprover-community/mathlib4' + if: github.repository == 'leanprover-community/mathlib4' && github.ref_name != 'nightly-testing' shell: bash run: | cd pr-branch From d5cca85ca533f1d1f3cf20656fc7ac3aa90960be Mon Sep 17 00:00:00 2001 From: "mathlib-nightly-testing[bot]" Date: Fri, 10 Apr 2026 09:28:23 +0000 Subject: [PATCH 041/321] chore: bump to nightly-2026-04-10 --- lean-toolchain | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lean-toolchain b/lean-toolchain index d04b8570d780a2..9187f2ebfc2754 100644 --- a/lean-toolchain +++ b/lean-toolchain @@ -1 +1 @@ -leanprover/lean4:nightly-2026-04-09 +leanprover/lean4:nightly-2026-04-10 From 40c6fcbf4da12c6926f59c7777be46168f0f33a0 Mon Sep 17 00:00:00 2001 From: Sebastian Ullrich Date: Fri, 10 Apr 2026 12:29:17 +0000 Subject: [PATCH 042/321] fix --- Mathlib/Tactic/Linter/PrivateModule.lean | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Mathlib/Tactic/Linter/PrivateModule.lean b/Mathlib/Tactic/Linter/PrivateModule.lean index 08905121646445..62d403b0939a52 100644 --- a/Mathlib/Tactic/Linter/PrivateModule.lean +++ b/Mathlib/Tactic/Linter/PrivateModule.lean @@ -82,6 +82,8 @@ def privateModule : Linter where run stx := do for (decl, _) in (← getEnv).constants.map₂ do -- Ignore both private and reserved names; see implementation notes if !isPrivateName decl && !isReservedName (← getEnv) decl then return + -- `@[initialize]` can be private and still have public side effects, ignore + if isIOUnitInitFn (← getEnv) decl then return -- Lint if all names are private: let topOfFileRef := Syntax.atom (.synthetic ⟨0⟩ ⟨0⟩) "" logLint linter.privateModule topOfFileRef From aaa0ccc93755fdd58c45d49bdeea9fbf628ae207 Mon Sep 17 00:00:00 2001 From: Kim Morrison Date: Fri, 10 Apr 2026 12:51:02 +0000 Subject: [PATCH 043/321] chore(nolints): add docBlame exceptions for auto-generated `instInhabited.default` Co-Authored-By: Claude Opus 4.6 (1M context) --- scripts/nolints.json | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/nolints.json b/scripts/nolints.json index 60e690f82c2121..28f12584330383 100644 --- a/scripts/nolints.json +++ b/scripts/nolints.json @@ -224,4 +224,9 @@ ["docBlame", "Mathlib.Tactic.Coherence.LiftObj.lift"], ["docBlame", "Mathlib.Tactic.GCongr.ForwardExt.eval"], ["docBlame", "Mathlib.Tactic.Monotonicity.mono.side"], - ["docBlame", "Mathlib.Tactic.Sat.buildReify.mkPS"]] + ["docBlame", "Mathlib.Tactic.Sat.buildReify.mkPS"], + ["docBlame", "Lean.Meta.RefinedDiscrTree.instInhabitedPartialMatch.default"], + ["docBlame", "Mathlib.Linter.Flexible.instInhabitedStained.default"], + ["docBlame", "Mathlib.Linter.instInhabitedImportState.default"], + ["docBlame", "Mathlib.Linter.TextBased.instInhabitedStyleError.default"], + ["docBlame", "Mathlib.Linter.instInhabitedFormatError.default"]] From ba9bf0f57e8bc6882141df12167ca3ce52be30c1 Mon Sep 17 00:00:00 2001 From: Kim Morrison Date: Fri, 10 Apr 2026 13:05:49 +0000 Subject: [PATCH 044/321] fix(lint-style): filter out duplicate `Init` from `Mathlib.lean` imports `Lean.parseImports'` now emits `Init` more than once for module-system files such as `Mathlib.lean`, but `findImportsFromSource` (in importGraph) only `.erase`s the first occurrence. The remaining `Init` was treated as a module to lint, producing `uncaught exception: no such file or directory ... file: Init.lean` and breaking the `lint-style` CI job on `nightly-testing`. Defensively filter out any remaining `Init` after `findImportsFromSource`. Co-Authored-By: Claude Opus 4.6 (1M context) --- scripts/lint-style.lean | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/lint-style.lean b/scripts/lint-style.lean index 05b2e645c49a20..7097007f2de8bf 100644 --- a/scripts/lint-style.lean +++ b/scripts/lint-style.lean @@ -105,7 +105,11 @@ def missingInitImports (opts : LinterOptions) : IO Nat := do -- Find any file in the Mathlib directory which does not contain any Mathlib import. -- We simply parse `Mathlib.lean`, as CI ensures this file is up to date. - let allModuleNames := eraseExplicitImports (← findImportsFromSource "Mathlib.lean") + -- Note: `findImportsFromSource` only erases the *first* occurrence of `Init`. + -- On module-system files (such as `Mathlib.lean`), `Lean.parseImports'` may emit + -- `Init` multiple times, so we filter out any remaining occurrences here. + let allModuleNames := (eraseExplicitImports (← findImportsFromSource "Mathlib.lean")).filter + (· != `Init) let mut modulesWithoutMathlibImports := #[] let mut importsHeaderLinter := #[] for module in allModuleNames do From b6db754b69d7c3e6a3ff338c1b9fabd8a1adea9f Mon Sep 17 00:00:00 2001 From: Sebastian Ullrich Date: Fri, 10 Apr 2026 13:15:45 +0000 Subject: [PATCH 045/321] fix --- Mathlib/Tactic/DefEqAbuse.lean | 4 ++-- Mathlib/Tactic/Linter/DirectoryDependency.lean | 2 +- Mathlib/Tactic/Linter/HashCommandLinter.lean | 4 ++-- Mathlib/Tactic/Linter/MinImports.lean | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Mathlib/Tactic/DefEqAbuse.lean b/Mathlib/Tactic/DefEqAbuse.lean index b72edd96e10676..7475962923f945 100644 --- a/Mathlib/Tactic/DefEqAbuse.lean +++ b/Mathlib/Tactic/DefEqAbuse.lean @@ -299,7 +299,7 @@ Comparison is whitespace-insensitive to handle cases where LHS and RHS are seman but rendered with different line breaks or spacing. TODO: once https://github.com/leanprover/lean4/pull/12698 is available, refactor to use `TraceData.result?` and compare the LHS/RHS `Expr`s structurally instead of string-matching. -/ -private def isIdenticalSidesStr (raw : String) : Bool := +def isIdenticalSidesStr (raw : String) : Bool := if let [lhsRaw, rhs] := raw.splitOn " =?= " then -- Strip the leading status emoji/word (first whitespace-delimited token). let lhs := match lhsRaw.splitOn " " with @@ -315,7 +315,7 @@ private def isIdenticalSidesStr (raw : String) : Bool := Each level adds more detail to pretty-printed expressions. We prefer symmetric options (`pp.universes`, `pp.explicit`) over `pp.analyze`, which is context-dependent and can add annotations to only one side. -/ -private def ppEscalations : List (Options → Options) := +def ppEscalations : List (Options → Options) := [ fun o => o.setBool `pp.universes true , fun o => o.setBool `pp.explicit true ] diff --git a/Mathlib/Tactic/Linter/DirectoryDependency.lean b/Mathlib/Tactic/Linter/DirectoryDependency.lean index d048f9b23c198a..24a689902168e5 100644 --- a/Mathlib/Tactic/Linter/DirectoryDependency.lean +++ b/Mathlib/Tactic/Linter/DirectoryDependency.lean @@ -620,7 +620,7 @@ open DirectoryDependency /-- Check if one of the imports `imports` to `mainModule` is forbidden by `forbiddenImportDirs`; if so, return an error describing how the import transitively arises. -/ -private def checkBlocklist (env : Environment) (mainModule : Name) (imports : Array Name) : Option MessageData := Id.run do +def checkBlocklist (env : Environment) (mainModule : Name) (imports : Array Name) : Option MessageData := Id.run do match forbiddenImportDirs.findAny mainModule imports with | some (n₁, n₂) => do if let some imported := n₂.prefixToName imports then diff --git a/Mathlib/Tactic/Linter/HashCommandLinter.lean b/Mathlib/Tactic/Linter/HashCommandLinter.lean index 3f2c8f926bef0b..0b9741bd5005ae 100644 --- a/Mathlib/Tactic/Linter/HashCommandLinter.lean +++ b/Mathlib/Tactic/Linter/HashCommandLinter.lean @@ -46,7 +46,7 @@ open Command in /-- Exactly like `withSetOptionIn`, but recursively discards nested uses of `in`. Intended to be used in the `hashCommand` linter, where we want to enter `set_option` `in` commands. -/ -private partial def withSetOptionIn' (cmd : CommandElab) : CommandElab := fun stx => do +partial def withSetOptionIn' (cmd : CommandElab) : CommandElab := fun stx => do if stx.getKind == ``Lean.Parser.Command.in then if stx[0].getKind == ``Lean.Parser.Command.set_option then let opts ← Elab.elabSetOption stx[0][1] stx[0][3] @@ -58,7 +58,7 @@ private partial def withSetOptionIn' (cmd : CommandElab) : CommandElab := fun st cmd stx /-- `allowed_commands` is the `HashSet` of `#`-commands that are allowed in 'Mathlib'. -/ -private abbrev allowed_commands : Std.HashSet String := { "#adaptation_note" } +abbrev allowed_commands : Std.HashSet String := { "#adaptation_note" } /-- Checks that no command beginning with `#` is present in 'Mathlib', except for the ones in `allowed_commands`. diff --git a/Mathlib/Tactic/Linter/MinImports.lean b/Mathlib/Tactic/Linter/MinImports.lean index ae2a42c439c518..510c707f3e9dbe 100644 --- a/Mathlib/Tactic/Linter/MinImports.lean +++ b/Mathlib/Tactic/Linter/MinImports.lean @@ -52,7 +52,7 @@ structure ImportState where /-- `minImportsRef` keeps track of cumulative imports across multiple commands, using `ImportState`. -/ -private initialize minImportsRef : IO.Ref ImportState ← IO.mkRef {} +initialize minImportsRef : IO.Ref ImportState ← IO.mkRef {} /-- `#reset_min_imports` sets to empty the current list of cumulative imports. -/ elab "#reset_min_imports" : command => minImportsRef.set {} From 4712c41aba1acf84d9e89e2fe4b78f9c1b0829cb Mon Sep 17 00:00:00 2001 From: leanprover-community-mathlib4-bot Date: Fri, 10 Apr 2026 14:57:41 +0000 Subject: [PATCH 046/321] Update lean-toolchain for testing https://github.com/leanprover/lean4/pull/13359 --- lake-manifest.json | 4 ++-- lakefile.lean | 2 +- lean-toolchain | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lake-manifest.json b/lake-manifest.json index ca0e4c0d66b879..29395b93e9dfe3 100644 --- a/lake-manifest.json +++ b/lake-manifest.json @@ -65,10 +65,10 @@ "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "bf597c77bf9b8e66720d724928207f5911533113", + "rev": "17716bd2156dd90a11aef49ffd4108439eacff2f", "name": "batteries", "manifestFile": "lake-manifest.json", - "inputRev": "v4.30.0-rc1", + "inputRev": "lean-pr-testing-13359", "inherited": false, "configFile": "lakefile.toml"}, {"url": "https://github.com/leanprover/lean4-cli", diff --git a/lakefile.lean b/lakefile.lean index 5f11ec894a69ad..b625433d50da10 100644 --- a/lakefile.lean +++ b/lakefile.lean @@ -6,7 +6,7 @@ open Lake DSL ## Mathlib dependencies on upstream projects -/ -require "leanprover-community" / "batteries" @ git "v4.30.0-rc1" +require "leanprover-community" / "batteries" @ git "lean-pr-testing-13359" require "leanprover-community" / "Qq" @ git "nightly-testing" require "leanprover-community" / "aesop" @ git "nightly-testing" require "leanprover-community" / "proofwidgets" @ git "v0.0.97" diff --git a/lean-toolchain b/lean-toolchain index 54caac41bddf21..ef138a02c85ec8 100644 --- a/lean-toolchain +++ b/lean-toolchain @@ -1 +1 @@ -leanprover/lean4:nightly-2026-04-07 +leanprover/lean4-pr-releases:pr-release-13359-663798c From f053cf0373d5987130c5aa0669d505209827612c Mon Sep 17 00:00:00 2001 From: Sebastian Ullrich Date: Fri, 10 Apr 2026 16:11:39 +0000 Subject: [PATCH 047/321] fix plausible --- lake-manifest.json | 20 ++++++++++---------- lakefile.lean | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lake-manifest.json b/lake-manifest.json index d47be9b382b89e..fdf39b00ac9c1f 100644 --- a/lake-manifest.json +++ b/lake-manifest.json @@ -1,14 +1,14 @@ {"version": "1.2.0", "packagesDir": ".lake/packages", "packages": - [{"url": "https://github.com/leanprover-community/plausible", + [{"url": "https://github.com/Kha/plausible", "type": "git", "subDir": null, - "scope": "leanprover-community", - "rev": "4d955ffd04d5f6d1143c5bf8fffab59ea7d84595", + "scope": "", + "rev": "1e454fed5528d2df0f45708f6b9e8e519c47fc5a", "name": "plausible", "manifestFile": "lake-manifest.json", - "inputRev": "main", + "inputRev": "push-nuzuuroszpvz", "inherited": false, "configFile": "lakefile.toml"}, {"url": "https://github.com/leanprover-community/LeanSearchClient", @@ -25,7 +25,7 @@ "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "4270b99dc7c5e90d5ee5c6cb2dd91aaba5b19557", + "rev": "86503d416c875fdcf3b6b6c54c22581e96c6bda7", "name": "importGraph", "manifestFile": "lake-manifest.json", "inputRev": "main", @@ -45,7 +45,7 @@ "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "2ac0e066410c02c7f755c865c2a4770855d47291", + "rev": "ad416ddf6cc9d5b1c00eaf04a48e703538132760", "name": "aesop", "manifestFile": "lake-manifest.json", "inputRev": "nightly-testing", @@ -55,7 +55,7 @@ "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "0b2df33836dabcfbb05acaf73179ca8bb21c34cf", + "rev": "bee778191c7fbea31864ecfe1809b8837626aba0", "name": "Qq", "manifestFile": "lake-manifest.json", "inputRev": "nightly-testing", @@ -65,7 +65,7 @@ "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "257610310763a697d819165a58f209a63a512929", + "rev": "09de4da19089efce3746d2b69930387b4709f110", "name": "batteries", "manifestFile": "lake-manifest.json", "inputRev": "lean-pr-testing-13132", @@ -75,10 +75,10 @@ "type": "git", "subDir": null, "scope": "leanprover", - "rev": "33583e6fb5096defc38f0c7f67d1c4a3825aee1f", + "rev": "f7d0ca7c926cdde0562af20394dd25d028b839a5", "name": "Cli", "manifestFile": "lake-manifest.json", - "inputRev": "v4.29.0-rc7", + "inputRev": "v4.30.0-rc1", "inherited": true, "configFile": "lakefile.toml"}], "name": "mathlib", diff --git a/lakefile.lean b/lakefile.lean index a52a5fdfd39591..d5c82b86b819d4 100644 --- a/lakefile.lean +++ b/lakefile.lean @@ -16,7 +16,7 @@ require "leanprover-community" / "proofwidgets" @ git "v0.0.92-pre1" -- ProofWid If this does not work, report your issue on the Lean Zulip." require "leanprover-community" / "importGraph" @ git "main" require "leanprover-community" / "LeanSearchClient" @ git "main" -require "leanprover-community" / "plausible" @ git "main" +require plausible from git "https://github.com/Kha/plausible" @ "push-nuzuuroszpvz" /-! From f48d5bbff01918f9ec5d17680bdeeed6060469bc Mon Sep 17 00:00:00 2001 From: leanprover-community-mathlib4-bot Date: Fri, 10 Apr 2026 19:59:36 +0000 Subject: [PATCH 048/321] Update lean-toolchain for https://github.com/leanprover/lean4/pull/13346 --- lake-manifest.json | 2 +- lean-toolchain | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lake-manifest.json b/lake-manifest.json index 4b7564c372bceb..3f8018cc7edf62 100644 --- a/lake-manifest.json +++ b/lake-manifest.json @@ -65,7 +65,7 @@ "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "a46a330786af9a74fd0c366aad4279eab329007d", + "rev": "3244daa32f48802a8a3e72ce7e45ca76dd41a847", "name": "batteries", "manifestFile": "lake-manifest.json", "inputRev": "lean-pr-testing-13346", diff --git a/lean-toolchain b/lean-toolchain index 66182b04b9f690..abad233d536cdd 100644 --- a/lean-toolchain +++ b/lean-toolchain @@ -1 +1 @@ -leanprover/lean4-pr-releases:pr-release-13346-077164e +leanprover/lean4-pr-releases:pr-release-13346-812c173 From a1c9945976087d1e6b8226b856c5c19ca2dda1ab Mon Sep 17 00:00:00 2001 From: Kim Morrison Date: Sat, 11 Apr 2026 01:05:24 +0000 Subject: [PATCH 049/321] chore: update importGraph, remove duplicate Init workaround MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Updates importGraph to pick up leanprover-community/import-graph#115, which fixes `findImportsFromSource` to filter (not just erase) `Init`. This removes the need for the defensive `.filter (· != `Init)` we added to `lint-style.lean`. Co-Authored-By: Claude Opus 4.6 (1M context) --- lake-manifest.json | 6 +++--- scripts/lint-style.lean | 6 +----- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/lake-manifest.json b/lake-manifest.json index 7071f31f8baa9e..b3d3a8b9363482 100644 --- a/lake-manifest.json +++ b/lake-manifest.json @@ -5,7 +5,7 @@ "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "a3b459a8312125758e51c354b93d54ba620efda6", + "rev": "2541d6b9e923b0b2f867d7b037ac344551cc7feb", "name": "plausible", "manifestFile": "lake-manifest.json", "inputRev": "main", @@ -25,7 +25,7 @@ "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "86503d416c875fdcf3b6b6c54c22581e96c6bda7", + "rev": "4411c5f89c797401c609b3a946c8874569e69731", "name": "importGraph", "manifestFile": "lake-manifest.json", "inputRev": "main", @@ -65,7 +65,7 @@ "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "ac74d33e9166b34a985f7c774a9e7f4b1c1adc35", + "rev": "896fee4b88a27faa234591ab515a6f9f70f9a096", "name": "batteries", "manifestFile": "lake-manifest.json", "inputRev": "nightly-testing", diff --git a/scripts/lint-style.lean b/scripts/lint-style.lean index 7097007f2de8bf..05b2e645c49a20 100644 --- a/scripts/lint-style.lean +++ b/scripts/lint-style.lean @@ -105,11 +105,7 @@ def missingInitImports (opts : LinterOptions) : IO Nat := do -- Find any file in the Mathlib directory which does not contain any Mathlib import. -- We simply parse `Mathlib.lean`, as CI ensures this file is up to date. - -- Note: `findImportsFromSource` only erases the *first* occurrence of `Init`. - -- On module-system files (such as `Mathlib.lean`), `Lean.parseImports'` may emit - -- `Init` multiple times, so we filter out any remaining occurrences here. - let allModuleNames := (eraseExplicitImports (← findImportsFromSource "Mathlib.lean")).filter - (· != `Init) + let allModuleNames := eraseExplicitImports (← findImportsFromSource "Mathlib.lean") let mut modulesWithoutMathlibImports := #[] let mut importsHeaderLinter := #[] for module in allModuleNames do From 0ab07d5e95e2928ad3810de7d682c51a68cac49d Mon Sep 17 00:00:00 2001 From: "mathlib-nightly-testing[bot]" Date: Sat, 11 Apr 2026 14:59:26 +0000 Subject: [PATCH 050/321] chore: bump to nightly-2026-04-11 --- lean-toolchain | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lean-toolchain b/lean-toolchain index 9187f2ebfc2754..bca52a66f4273a 100644 --- a/lean-toolchain +++ b/lean-toolchain @@ -1 +1 @@ -leanprover/lean4:nightly-2026-04-10 +leanprover/lean4:nightly-2026-04-11 From 8da25c31bbe645ed439257ff710a4c1df21f0172 Mon Sep 17 00:00:00 2001 From: Kim Morrison Date: Sat, 11 Apr 2026 23:52:27 +0000 Subject: [PATCH 051/321] silence linter --- Mathlib/Combinatorics/Matroid/Init.lean | 2 +- Mathlib/Combinatorics/SimpleGraph/Init.lean | 2 +- Mathlib/Data/Finset/Attr.lean | 2 +- Mathlib/Data/Sym/Sym2/Init.lean | 2 +- Mathlib/Tactic/ArithMult/Init.lean | 2 +- Mathlib/Tactic/Bound/Init.lean | 2 +- Mathlib/Tactic/Continuity/Init.lean | 2 +- Mathlib/Tactic/Finiteness/Attr.lean | 2 +- Mathlib/Tactic/FunProp/Attr.lean | 4 +++- Mathlib/Tactic/Measurability/Init.lean | 2 +- Mathlib/Topology/Sheaves/Init.lean | 2 +- 11 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Mathlib/Combinatorics/Matroid/Init.lean b/Mathlib/Combinatorics/Matroid/Init.lean index 6e434c01bdf627..ea8bd6b7ef7fdb 100644 --- a/Mathlib/Combinatorics/Matroid/Init.lean +++ b/Mathlib/Combinatorics/Matroid/Init.lean @@ -16,6 +16,6 @@ This module defines the `Matroid` Aesop rule set which is used by the they're declared is imported, so we must put this declaration into its own file. -/ -public section +set_option linter.privateModule false declare_aesop_rule_sets [Matroid] diff --git a/Mathlib/Combinatorics/SimpleGraph/Init.lean b/Mathlib/Combinatorics/SimpleGraph/Init.lean index e33f62ae3c0e25..036d3d9068a3ea 100644 --- a/Mathlib/Combinatorics/SimpleGraph/Init.lean +++ b/Mathlib/Combinatorics/SimpleGraph/Init.lean @@ -16,6 +16,6 @@ This module defines the `SimpleGraph` Aesop rule set which is used by the they're declared is imported, so we must put this declaration into its own file. -/ -public section +set_option linter.privateModule false declare_aesop_rule_sets [SimpleGraph] diff --git a/Mathlib/Data/Finset/Attr.lean b/Mathlib/Data/Finset/Attr.lean index 19a757ed46f9aa..73ea5e2f67435b 100644 --- a/Mathlib/Data/Finset/Attr.lean +++ b/Mathlib/Data/Finset/Attr.lean @@ -14,7 +14,7 @@ public import Aesop.Frontend This file defines `finsetNonempty`, an aesop rule set to prove that a given finset is nonempty. -/ -public section +set_option linter.privateModule false -- `finsetNonempty` rules try to prove that a given finset is nonempty, -- for use in positivity extensions. diff --git a/Mathlib/Data/Sym/Sym2/Init.lean b/Mathlib/Data/Sym/Sym2/Init.lean index cda8468ef86fa9..c51268af88812f 100644 --- a/Mathlib/Data/Sym/Sym2/Init.lean +++ b/Mathlib/Data/Sym/Sym2/Init.lean @@ -16,6 +16,6 @@ visible once the file in which they're declared is imported, so we must put this declaration into its own file. -/ -public section +set_option linter.privateModule false declare_aesop_rule_sets [Sym2] diff --git a/Mathlib/Tactic/ArithMult/Init.lean b/Mathlib/Tactic/ArithMult/Init.lean index 4c95026124c1a6..f65598b911fe16 100644 --- a/Mathlib/Tactic/ArithMult/Init.lean +++ b/Mathlib/Tactic/ArithMult/Init.lean @@ -16,6 +16,6 @@ This module defines the `IsMultiplicative` Aesop rule set which is used by the they're declared is imported, so we must put this declaration into its own file. -/ -public meta section +set_option linter.privateModule false declare_aesop_rule_sets [IsMultiplicative] diff --git a/Mathlib/Tactic/Bound/Init.lean b/Mathlib/Tactic/Bound/Init.lean index 8168cf288aefd4..a41685bdb3b91e 100644 --- a/Mathlib/Tactic/Bound/Init.lean +++ b/Mathlib/Tactic/Bound/Init.lean @@ -16,6 +16,6 @@ This module defines the `Bound` Aesop rule set which is used by the they're declared is imported, so we must put this declaration into its own file. -/ -public meta section +set_option linter.privateModule false declare_aesop_rule_sets [Bound] diff --git a/Mathlib/Tactic/Continuity/Init.lean b/Mathlib/Tactic/Continuity/Init.lean index e988564a6b947d..05428ea6dd0d9c 100644 --- a/Mathlib/Tactic/Continuity/Init.lean +++ b/Mathlib/Tactic/Continuity/Init.lean @@ -16,6 +16,6 @@ This module defines the `Continuous` Aesop rule set which is used by the they're declared is imported, so we must put this declaration into its own file. -/ -public meta section +set_option linter.privateModule false declare_aesop_rule_sets [Continuous] diff --git a/Mathlib/Tactic/Finiteness/Attr.lean b/Mathlib/Tactic/Finiteness/Attr.lean index bb64d9e46af3de..e6946c319bd774 100644 --- a/Mathlib/Tactic/Finiteness/Attr.lean +++ b/Mathlib/Tactic/Finiteness/Attr.lean @@ -10,6 +10,6 @@ public import Aesop.Frontend /-! # Finiteness tactic attribute -/ -public meta section +set_option linter.privateModule false declare_aesop_rule_sets [finiteness] diff --git a/Mathlib/Tactic/FunProp/Attr.lean b/Mathlib/Tactic/FunProp/Attr.lean index e0e8b89ad02e2f..10550960a98fc3 100644 --- a/Mathlib/Tactic/FunProp/Attr.lean +++ b/Mathlib/Tactic/FunProp/Attr.lean @@ -12,7 +12,9 @@ public import Mathlib.Tactic.FunProp.Theorems ## `funProp` attribute -/ -public meta section +set_option linter.privateModule false + +meta section namespace Mathlib open Lean Meta diff --git a/Mathlib/Tactic/Measurability/Init.lean b/Mathlib/Tactic/Measurability/Init.lean index 85e8ae3add56fb..16f02034afa7ce 100644 --- a/Mathlib/Tactic/Measurability/Init.lean +++ b/Mathlib/Tactic/Measurability/Init.lean @@ -16,6 +16,6 @@ This module defines the `Measurable` Aesop rule set which is used by the they're declared is imported, so we must put this declaration into its own file. -/ -public meta section +set_option linter.privateModule false declare_aesop_rule_sets [Measurable] diff --git a/Mathlib/Topology/Sheaves/Init.lean b/Mathlib/Topology/Sheaves/Init.lean index 053c3cdee10982..2556c0ac7d7595 100644 --- a/Mathlib/Topology/Sheaves/Init.lean +++ b/Mathlib/Topology/Sheaves/Init.lean @@ -16,7 +16,7 @@ visible once the file in which they're declared is imported, so we must put this declaration into its own file. -/ -public section +set_option linter.privateModule false /- to prove subset relations -/ declare_aesop_rule_sets [Restrict] From d2d45e83089fcb3e28184674ef50eb8de150c20d Mon Sep 17 00:00:00 2001 From: Kim Morrison Date: Sun, 12 Apr 2026 00:59:17 +0000 Subject: [PATCH 052/321] broken test: still broken, but doesn't stop the build. --- MathlibTest/PrivateModuleLinter/initialize.lean | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MathlibTest/PrivateModuleLinter/initialize.lean b/MathlibTest/PrivateModuleLinter/initialize.lean index 7d5b5a0db2e050..4d7e3a2a7e339e 100644 --- a/MathlibTest/PrivateModuleLinter/initialize.lean +++ b/MathlibTest/PrivateModuleLinter/initialize.lean @@ -2,7 +2,7 @@ module import Mathlib.Tactic.Linter.PrivateModule -set_option linter.privateModule true +set_option linter.privateModule false -- Changed in nightly-testing, as this test no longer works. open Lean From eb7a77483db8367698858255fafa3b594faecd86 Mon Sep 17 00:00:00 2001 From: thorimur <68410468+thorimur@users.noreply.github.com> Date: Sat, 11 Apr 2026 23:44:06 -0400 Subject: [PATCH 053/321] fix: exempt files registering initializers from the `privateModule` linter --- Mathlib/Tactic/Linter/PrivateModule.lean | 33 ++++++++++++++---------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/Mathlib/Tactic/Linter/PrivateModule.lean b/Mathlib/Tactic/Linter/PrivateModule.lean index 08905121646445..bf5a2aa6a32502 100644 --- a/Mathlib/Tactic/Linter/PrivateModule.lean +++ b/Mathlib/Tactic/Linter/PrivateModule.lean @@ -26,6 +26,9 @@ the file. Note that private declarations from the current module are exactly those which satisfy `isPrivateName`, whether private due to an explicit `private` or due to not being made `public`. +Since initializers have downstream effects regardless of whether they're `private` or `public`, any +module which registers an initializer is considered non-private. + We also do not count declarations which satisfy `isReservedName` as public declarations *from the current module*. While they might indeed be public, the declarations associated with reserved names are generated automatically and lazily, sometimes in downstream modules from the one in which the @@ -46,8 +49,7 @@ See also the type `Lean.ReservedNameAction`, invocations of `registerReservedNam Note that metaprograms should not add public declarations when run in private scopes. Doing so would likely be a bug in the metaprogram. As such, we do not perform further checks for automatically -generated declarations such as those detected by `isAutoDecl` or `isInternalDetail`, which would -wrongly exclude e.g. public declarations generated by `initialize`. +generated declarations such as those detected by `isAutoDecl` or `isInternalDetail`. -/ meta section @@ -75,19 +77,22 @@ def privateModule : Linter where run stx := do if stx.isOfKind ``Parser.Command.eoi then unless getLinterValue linter.privateModule (← getLinterOptions) do return - if (← getEnv).header.isModule then + if (← getEnv).header.isModule + -- If there are new initializers, this module has a downstream effect and is not private. + && (regularInitAttr.ext.getState (← getEnv)).1.isEmpty -- Don't lint an imports-only module: - if !(← getEnv).constants.map₂.isEmpty then - -- Exit if any declaration from the current module is public: - for (decl, _) in (← getEnv).constants.map₂ do - -- Ignore both private and reserved names; see implementation notes - if !isPrivateName decl && !isReservedName (← getEnv) decl then return - -- Lint if all names are private: - let topOfFileRef := Syntax.atom (.synthetic ⟨0⟩ ⟨0⟩) "" - logLint linter.privateModule topOfFileRef - "The current module only contains private declarations.\n\n\ - Consider adding `@[expose] public section` at the beginning of the module, \ - or selectively marking declarations as `public`." + && !(← getEnv).constants.map₂.isEmpty + then + -- Exit if any declaration from the current module is public: + for (decl, _) in (← getEnv).constants.map₂ do + -- Ignore both private and reserved names; see implementation notes + if !isPrivateName decl && !isReservedName (← getEnv) decl then return + -- Lint if all names are private: + let topOfFileRef := Syntax.atom (.synthetic ⟨0⟩ ⟨0⟩) "" + logLint linter.privateModule topOfFileRef + "The current module only contains private declarations.\n\n\ + Consider adding `@[expose] public section` at the beginning of the module, \ + or selectively marking declarations as `public`." initialize addLinter privateModule From 853d41e08f58f1553cfd58fd1d7f66abd438a815 Mon Sep 17 00:00:00 2001 From: thorimur <68410468+thorimur@users.noreply.github.com> Date: Sat, 11 Apr 2026 23:45:52 -0400 Subject: [PATCH 054/321] Revert "silence linter" This reverts commit 8da25c31bbe645ed439257ff710a4c1df21f0172. --- Mathlib/Combinatorics/Matroid/Init.lean | 2 +- Mathlib/Combinatorics/SimpleGraph/Init.lean | 2 +- Mathlib/Data/Finset/Attr.lean | 2 +- Mathlib/Data/Sym/Sym2/Init.lean | 2 +- Mathlib/Tactic/ArithMult/Init.lean | 2 +- Mathlib/Tactic/Bound/Init.lean | 2 +- Mathlib/Tactic/Continuity/Init.lean | 2 +- Mathlib/Tactic/Finiteness/Attr.lean | 2 +- Mathlib/Tactic/FunProp/Attr.lean | 4 +--- Mathlib/Tactic/Measurability/Init.lean | 2 +- Mathlib/Topology/Sheaves/Init.lean | 2 +- 11 files changed, 11 insertions(+), 13 deletions(-) diff --git a/Mathlib/Combinatorics/Matroid/Init.lean b/Mathlib/Combinatorics/Matroid/Init.lean index ea8bd6b7ef7fdb..6e434c01bdf627 100644 --- a/Mathlib/Combinatorics/Matroid/Init.lean +++ b/Mathlib/Combinatorics/Matroid/Init.lean @@ -16,6 +16,6 @@ This module defines the `Matroid` Aesop rule set which is used by the they're declared is imported, so we must put this declaration into its own file. -/ -set_option linter.privateModule false +public section declare_aesop_rule_sets [Matroid] diff --git a/Mathlib/Combinatorics/SimpleGraph/Init.lean b/Mathlib/Combinatorics/SimpleGraph/Init.lean index 036d3d9068a3ea..e33f62ae3c0e25 100644 --- a/Mathlib/Combinatorics/SimpleGraph/Init.lean +++ b/Mathlib/Combinatorics/SimpleGraph/Init.lean @@ -16,6 +16,6 @@ This module defines the `SimpleGraph` Aesop rule set which is used by the they're declared is imported, so we must put this declaration into its own file. -/ -set_option linter.privateModule false +public section declare_aesop_rule_sets [SimpleGraph] diff --git a/Mathlib/Data/Finset/Attr.lean b/Mathlib/Data/Finset/Attr.lean index 73ea5e2f67435b..19a757ed46f9aa 100644 --- a/Mathlib/Data/Finset/Attr.lean +++ b/Mathlib/Data/Finset/Attr.lean @@ -14,7 +14,7 @@ public import Aesop.Frontend This file defines `finsetNonempty`, an aesop rule set to prove that a given finset is nonempty. -/ -set_option linter.privateModule false +public section -- `finsetNonempty` rules try to prove that a given finset is nonempty, -- for use in positivity extensions. diff --git a/Mathlib/Data/Sym/Sym2/Init.lean b/Mathlib/Data/Sym/Sym2/Init.lean index c51268af88812f..cda8468ef86fa9 100644 --- a/Mathlib/Data/Sym/Sym2/Init.lean +++ b/Mathlib/Data/Sym/Sym2/Init.lean @@ -16,6 +16,6 @@ visible once the file in which they're declared is imported, so we must put this declaration into its own file. -/ -set_option linter.privateModule false +public section declare_aesop_rule_sets [Sym2] diff --git a/Mathlib/Tactic/ArithMult/Init.lean b/Mathlib/Tactic/ArithMult/Init.lean index f65598b911fe16..4c95026124c1a6 100644 --- a/Mathlib/Tactic/ArithMult/Init.lean +++ b/Mathlib/Tactic/ArithMult/Init.lean @@ -16,6 +16,6 @@ This module defines the `IsMultiplicative` Aesop rule set which is used by the they're declared is imported, so we must put this declaration into its own file. -/ -set_option linter.privateModule false +public meta section declare_aesop_rule_sets [IsMultiplicative] diff --git a/Mathlib/Tactic/Bound/Init.lean b/Mathlib/Tactic/Bound/Init.lean index a41685bdb3b91e..8168cf288aefd4 100644 --- a/Mathlib/Tactic/Bound/Init.lean +++ b/Mathlib/Tactic/Bound/Init.lean @@ -16,6 +16,6 @@ This module defines the `Bound` Aesop rule set which is used by the they're declared is imported, so we must put this declaration into its own file. -/ -set_option linter.privateModule false +public meta section declare_aesop_rule_sets [Bound] diff --git a/Mathlib/Tactic/Continuity/Init.lean b/Mathlib/Tactic/Continuity/Init.lean index 05428ea6dd0d9c..e988564a6b947d 100644 --- a/Mathlib/Tactic/Continuity/Init.lean +++ b/Mathlib/Tactic/Continuity/Init.lean @@ -16,6 +16,6 @@ This module defines the `Continuous` Aesop rule set which is used by the they're declared is imported, so we must put this declaration into its own file. -/ -set_option linter.privateModule false +public meta section declare_aesop_rule_sets [Continuous] diff --git a/Mathlib/Tactic/Finiteness/Attr.lean b/Mathlib/Tactic/Finiteness/Attr.lean index e6946c319bd774..bb64d9e46af3de 100644 --- a/Mathlib/Tactic/Finiteness/Attr.lean +++ b/Mathlib/Tactic/Finiteness/Attr.lean @@ -10,6 +10,6 @@ public import Aesop.Frontend /-! # Finiteness tactic attribute -/ -set_option linter.privateModule false +public meta section declare_aesop_rule_sets [finiteness] diff --git a/Mathlib/Tactic/FunProp/Attr.lean b/Mathlib/Tactic/FunProp/Attr.lean index 10550960a98fc3..e0e8b89ad02e2f 100644 --- a/Mathlib/Tactic/FunProp/Attr.lean +++ b/Mathlib/Tactic/FunProp/Attr.lean @@ -12,9 +12,7 @@ public import Mathlib.Tactic.FunProp.Theorems ## `funProp` attribute -/ -set_option linter.privateModule false - -meta section +public meta section namespace Mathlib open Lean Meta diff --git a/Mathlib/Tactic/Measurability/Init.lean b/Mathlib/Tactic/Measurability/Init.lean index 16f02034afa7ce..85e8ae3add56fb 100644 --- a/Mathlib/Tactic/Measurability/Init.lean +++ b/Mathlib/Tactic/Measurability/Init.lean @@ -16,6 +16,6 @@ This module defines the `Measurable` Aesop rule set which is used by the they're declared is imported, so we must put this declaration into its own file. -/ -set_option linter.privateModule false +public meta section declare_aesop_rule_sets [Measurable] diff --git a/Mathlib/Topology/Sheaves/Init.lean b/Mathlib/Topology/Sheaves/Init.lean index 2556c0ac7d7595..053c3cdee10982 100644 --- a/Mathlib/Topology/Sheaves/Init.lean +++ b/Mathlib/Topology/Sheaves/Init.lean @@ -16,7 +16,7 @@ visible once the file in which they're declared is imported, so we must put this declaration into its own file. -/ -set_option linter.privateModule false +public section /- to prove subset relations -/ declare_aesop_rule_sets [Restrict] From 7a5e5b4706f978e7d67bc1e22d7941809deed670 Mon Sep 17 00:00:00 2001 From: thorimur <68410468+thorimur@users.noreply.github.com> Date: Sat, 11 Apr 2026 23:57:50 -0400 Subject: [PATCH 055/321] chore: remove unused sections in front of lone `declare_aesop_rule_sets` --- Mathlib/Combinatorics/Matroid/Init.lean | 2 -- Mathlib/Combinatorics/SimpleGraph/Init.lean | 2 -- Mathlib/Data/Finset/Attr.lean | 2 -- Mathlib/Data/Sym/Sym2/Init.lean | 2 -- Mathlib/Tactic/ArithMult/Init.lean | 2 -- Mathlib/Tactic/Bound/Init.lean | 2 -- Mathlib/Tactic/Continuity/Init.lean | 2 -- Mathlib/Tactic/Finiteness/Attr.lean | 2 -- Mathlib/Tactic/Measurability/Init.lean | 2 -- Mathlib/Topology/Sheaves/Init.lean | 2 -- 10 files changed, 20 deletions(-) diff --git a/Mathlib/Combinatorics/Matroid/Init.lean b/Mathlib/Combinatorics/Matroid/Init.lean index 6e434c01bdf627..bf806f06d08923 100644 --- a/Mathlib/Combinatorics/Matroid/Init.lean +++ b/Mathlib/Combinatorics/Matroid/Init.lean @@ -16,6 +16,4 @@ This module defines the `Matroid` Aesop rule set which is used by the they're declared is imported, so we must put this declaration into its own file. -/ -public section - declare_aesop_rule_sets [Matroid] diff --git a/Mathlib/Combinatorics/SimpleGraph/Init.lean b/Mathlib/Combinatorics/SimpleGraph/Init.lean index e33f62ae3c0e25..0928e07666be5f 100644 --- a/Mathlib/Combinatorics/SimpleGraph/Init.lean +++ b/Mathlib/Combinatorics/SimpleGraph/Init.lean @@ -16,6 +16,4 @@ This module defines the `SimpleGraph` Aesop rule set which is used by the they're declared is imported, so we must put this declaration into its own file. -/ -public section - declare_aesop_rule_sets [SimpleGraph] diff --git a/Mathlib/Data/Finset/Attr.lean b/Mathlib/Data/Finset/Attr.lean index 19a757ed46f9aa..a8894132142c32 100644 --- a/Mathlib/Data/Finset/Attr.lean +++ b/Mathlib/Data/Finset/Attr.lean @@ -14,8 +14,6 @@ public import Aesop.Frontend This file defines `finsetNonempty`, an aesop rule set to prove that a given finset is nonempty. -/ -public section - -- `finsetNonempty` rules try to prove that a given finset is nonempty, -- for use in positivity extensions. declare_aesop_rule_sets [finsetNonempty] (default := true) diff --git a/Mathlib/Data/Sym/Sym2/Init.lean b/Mathlib/Data/Sym/Sym2/Init.lean index cda8468ef86fa9..69faa4d163130c 100644 --- a/Mathlib/Data/Sym/Sym2/Init.lean +++ b/Mathlib/Data/Sym/Sym2/Init.lean @@ -16,6 +16,4 @@ visible once the file in which they're declared is imported, so we must put this declaration into its own file. -/ -public section - declare_aesop_rule_sets [Sym2] diff --git a/Mathlib/Tactic/ArithMult/Init.lean b/Mathlib/Tactic/ArithMult/Init.lean index 4c95026124c1a6..4afdad3dd49e0f 100644 --- a/Mathlib/Tactic/ArithMult/Init.lean +++ b/Mathlib/Tactic/ArithMult/Init.lean @@ -16,6 +16,4 @@ This module defines the `IsMultiplicative` Aesop rule set which is used by the they're declared is imported, so we must put this declaration into its own file. -/ -public meta section - declare_aesop_rule_sets [IsMultiplicative] diff --git a/Mathlib/Tactic/Bound/Init.lean b/Mathlib/Tactic/Bound/Init.lean index 8168cf288aefd4..f2a48a6687e866 100644 --- a/Mathlib/Tactic/Bound/Init.lean +++ b/Mathlib/Tactic/Bound/Init.lean @@ -16,6 +16,4 @@ This module defines the `Bound` Aesop rule set which is used by the they're declared is imported, so we must put this declaration into its own file. -/ -public meta section - declare_aesop_rule_sets [Bound] diff --git a/Mathlib/Tactic/Continuity/Init.lean b/Mathlib/Tactic/Continuity/Init.lean index e988564a6b947d..19e4f9da717012 100644 --- a/Mathlib/Tactic/Continuity/Init.lean +++ b/Mathlib/Tactic/Continuity/Init.lean @@ -16,6 +16,4 @@ This module defines the `Continuous` Aesop rule set which is used by the they're declared is imported, so we must put this declaration into its own file. -/ -public meta section - declare_aesop_rule_sets [Continuous] diff --git a/Mathlib/Tactic/Finiteness/Attr.lean b/Mathlib/Tactic/Finiteness/Attr.lean index bb64d9e46af3de..226794663ee9b0 100644 --- a/Mathlib/Tactic/Finiteness/Attr.lean +++ b/Mathlib/Tactic/Finiteness/Attr.lean @@ -10,6 +10,4 @@ public import Aesop.Frontend /-! # Finiteness tactic attribute -/ -public meta section - declare_aesop_rule_sets [finiteness] diff --git a/Mathlib/Tactic/Measurability/Init.lean b/Mathlib/Tactic/Measurability/Init.lean index 85e8ae3add56fb..20debd09a5bf8b 100644 --- a/Mathlib/Tactic/Measurability/Init.lean +++ b/Mathlib/Tactic/Measurability/Init.lean @@ -16,6 +16,4 @@ This module defines the `Measurable` Aesop rule set which is used by the they're declared is imported, so we must put this declaration into its own file. -/ -public meta section - declare_aesop_rule_sets [Measurable] diff --git a/Mathlib/Topology/Sheaves/Init.lean b/Mathlib/Topology/Sheaves/Init.lean index 053c3cdee10982..f5fc267eee2827 100644 --- a/Mathlib/Topology/Sheaves/Init.lean +++ b/Mathlib/Topology/Sheaves/Init.lean @@ -16,7 +16,5 @@ visible once the file in which they're declared is imported, so we must put this declaration into its own file. -/ -public section - /- to prove subset relations -/ declare_aesop_rule_sets [Restrict] From 8568f337c9d994d0b5080c81dba80bde96b17773 Mon Sep 17 00:00:00 2001 From: thorimur <68410468+thorimur@users.noreply.github.com> Date: Sun, 12 Apr 2026 00:00:57 -0400 Subject: [PATCH 056/321] chore: restore `initialize` test for `privateModule` linter with correct wording --- MathlibTest/PrivateModuleLinter/initialize.lean | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/MathlibTest/PrivateModuleLinter/initialize.lean b/MathlibTest/PrivateModuleLinter/initialize.lean index 4d7e3a2a7e339e..0cc6d129a209b2 100644 --- a/MathlibTest/PrivateModuleLinter/initialize.lean +++ b/MathlibTest/PrivateModuleLinter/initialize.lean @@ -2,11 +2,9 @@ module import Mathlib.Tactic.Linter.PrivateModule -set_option linter.privateModule false -- Changed in nightly-testing, as this test no longer works. - open Lean --- Should not fire, since `initialize` creates a genuinely public declaration. +-- Should not fire, since `initialize` has effects downstream despite creating a private decl here. initialize pure () /- Check that we have indeed created a declaration, and aren't not linting just due to being an From d49f1edb8c3c52b4d6b64537efdddd7f320cec12 Mon Sep 17 00:00:00 2001 From: thorimur <68410468+thorimur@users.noreply.github.com> Date: Sun, 12 Apr 2026 00:02:11 -0400 Subject: [PATCH 057/321] chore: restore `privateModule` `initialize` test with linter turned on --- MathlibTest/PrivateModuleLinter/initialize.lean | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MathlibTest/PrivateModuleLinter/initialize.lean b/MathlibTest/PrivateModuleLinter/initialize.lean index 0cc6d129a209b2..2b8a212c1dd662 100644 --- a/MathlibTest/PrivateModuleLinter/initialize.lean +++ b/MathlibTest/PrivateModuleLinter/initialize.lean @@ -4,6 +4,8 @@ import Mathlib.Tactic.Linter.PrivateModule open Lean +set_option linter.privateModule true + -- Should not fire, since `initialize` has effects downstream despite creating a private decl here. initialize pure () From 365191c6c9c65a53619deda0d752e5d47de563ef Mon Sep 17 00:00:00 2001 From: Kim Morrison Date: Sun, 12 Apr 2026 08:42:35 +0000 Subject: [PATCH 058/321] fixes --- scripts/create_deprecated_modules.lean | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/scripts/create_deprecated_modules.lean b/scripts/create_deprecated_modules.lean index 9017f4fee82a7f..d17459a8128f45 100644 --- a/scripts/create_deprecated_modules.lean +++ b/scripts/create_deprecated_modules.lean @@ -5,6 +5,7 @@ Authors: Damiano Testa -/ --import Mathlib.Init +import Std.Time.Format import Std.Time.Zoned import Lean.Meta.Tactic.TryThis -- a comment here to test `keepTrailing @@ -49,8 +50,12 @@ It returns just the imports of `fileContent`, including trailing comments if `ke -/ def getHeader (fname fileContent : String) (keepTrailing : Bool) : IO String := do let (stx, _) ← Parser.parseHeader (Parser.mkInputContext fileContent fname) - let stx := if keepTrailing then stx.raw else stx.raw.unsetTrailing - let some substring := stx.getSubstring? | throw <| .userError "No substring: we have a problem!" + let imports := stx.raw.getArg 2 -- extract just the imports list + let imports := if keepTrailing then imports else imports.unsetTrailing + -- Use `withLeading := false` to exclude leading comments (e.g. copyright header) that the + -- parser now attaches to the first token (see leanprover/lean4#12662). + let some substring := imports.getSubstring? (withLeading := false) | + throw <| .userError "No substring: we have a problem!" return substring.toString /-- @@ -374,7 +379,8 @@ the deprecations later on. -- #find_deleted_files 0 /-- -info: import Std.Time.Zoned +info: import Std.Time.Format +import Std.Time.Zoned import Lean.Meta.Tactic.TryThis -/ #guard_msgs in @@ -384,7 +390,8 @@ run_cmd logInfo head /-- -info: import Std.Time.Zoned +info: import Std.Time.Format +import Std.Time.Zoned import Lean.Meta.Tactic.TryThis -- a comment here to test `keepTrailing -/ From 7913a6962ac866777c53bbd9586bada367e78e09 Mon Sep 17 00:00:00 2001 From: Kim Morrison Date: Mon, 13 Apr 2026 08:20:09 +1000 Subject: [PATCH 059/321] fix from nightly-testing --- scripts/create_deprecated_modules.lean | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/scripts/create_deprecated_modules.lean b/scripts/create_deprecated_modules.lean index 3b0d79fd3b8ebf..17dff24f395335 100644 --- a/scripts/create_deprecated_modules.lean +++ b/scripts/create_deprecated_modules.lean @@ -371,17 +371,10 @@ replaced by the suggestion, which means that you can click on multiple suggestio the deprecations later on. -/ --- #find_deleted_files 0 +#find_deleted_files 0 /-- -info: /- -Copyright (c) 2025 Damiano Testa. All rights reserved. -Released under Apache 2.0 license as described in the file LICENSE. -Authors: Damiano Testa --/ - ---import Mathlib.Init -import Std.Time.Zoned +info: import Std.Time.Zoned import Lean.Meta.Tactic.TryThis -/ #guard_msgs in @@ -391,14 +384,7 @@ run_cmd logInfo head /-- -info: /- -Copyright (c) 2025 Damiano Testa. All rights reserved. -Released under Apache 2.0 license as described in the file LICENSE. -Authors: Damiano Testa --/ - ---import Mathlib.Init -import Std.Time.Zoned +info: import Std.Time.Zoned import Lean.Meta.Tactic.TryThis -- a comment here to test `keepTrailing -/ From af85844a19259e2b76e10ac00aa22a0348c31a17 Mon Sep 17 00:00:00 2001 From: Kim Morrison Date: Mon, 13 Apr 2026 08:24:45 +1000 Subject: [PATCH 060/321] importGraph has been fixed --- lake-manifest.json | 2 +- scripts/lint-style.lean | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/lake-manifest.json b/lake-manifest.json index 918a1a5ac43321..b3d3a8b9363482 100644 --- a/lake-manifest.json +++ b/lake-manifest.json @@ -25,7 +25,7 @@ "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "86503d416c875fdcf3b6b6c54c22581e96c6bda7", + "rev": "4411c5f89c797401c609b3a946c8874569e69731", "name": "importGraph", "manifestFile": "lake-manifest.json", "inputRev": "main", diff --git a/scripts/lint-style.lean b/scripts/lint-style.lean index 7097007f2de8bf..05b2e645c49a20 100644 --- a/scripts/lint-style.lean +++ b/scripts/lint-style.lean @@ -105,11 +105,7 @@ def missingInitImports (opts : LinterOptions) : IO Nat := do -- Find any file in the Mathlib directory which does not contain any Mathlib import. -- We simply parse `Mathlib.lean`, as CI ensures this file is up to date. - -- Note: `findImportsFromSource` only erases the *first* occurrence of `Init`. - -- On module-system files (such as `Mathlib.lean`), `Lean.parseImports'` may emit - -- `Init` multiple times, so we filter out any remaining occurrences here. - let allModuleNames := (eraseExplicitImports (← findImportsFromSource "Mathlib.lean")).filter - (· != `Init) + let allModuleNames := eraseExplicitImports (← findImportsFromSource "Mathlib.lean") let mut modulesWithoutMathlibImports := #[] let mut importsHeaderLinter := #[] for module in allModuleNames do From 88bfa5e79079ab027ccc4c1ac74d29557e35b539 Mon Sep 17 00:00:00 2001 From: Sebastian Ullrich Date: Mon, 13 Apr 2026 08:52:11 +0000 Subject: [PATCH 061/321] fix --- Mathlib/AlgebraicGeometry/StructureSheaf.lean | 4 ++-- .../SpecialFunctions/Trigonometric/Inverse.lean | 2 +- Mathlib/Tactic/NormNum/Result.lean | 14 +++++++------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Mathlib/AlgebraicGeometry/StructureSheaf.lean b/Mathlib/AlgebraicGeometry/StructureSheaf.lean index 065ae6ec40b900..014f3feb10231b 100644 --- a/Mathlib/AlgebraicGeometry/StructureSheaf.lean +++ b/Mathlib/AlgebraicGeometry/StructureSheaf.lean @@ -562,11 +562,11 @@ public lemma algebraMap_germ @[deprecated (since := "2026-02-10")] public alias toOpen_germ := algebraMap_germ -@[expose] public +public instance (x : PrimeSpectrum.Top R) : Algebra R ((structurePresheafInCommRingCat R).stalk x) := (toStalk R x).hom.toAlgebra -@[expose] public +public instance (x : PrimeSpectrum.Top R) : Module R ↑(TopCat.Presheaf.stalk (moduleStructurePresheaf R M).presheaf x) := .compHom _ (toStalk R x).hom diff --git a/Mathlib/Analysis/SpecialFunctions/Trigonometric/Inverse.lean b/Mathlib/Analysis/SpecialFunctions/Trigonometric/Inverse.lean index a2c2f9aab8e388..1c0179ee7254e2 100644 --- a/Mathlib/Analysis/SpecialFunctions/Trigonometric/Inverse.lean +++ b/Mathlib/Analysis/SpecialFunctions/Trigonometric/Inverse.lean @@ -446,7 +446,7 @@ def cosPartialHomeomorph : OpenPartialHomeomorph ℝ ℝ where continuousOn_invFun := continuous_arccos.continuousOn /-- `Real.cos` and `Real.arccos` as a (partial) equivalence from `[0, π]` to `[-1, 1]` -/ -@[simps, expose] +@[simps] noncomputable def cosPartialEquiv : PartialEquiv ℝ ℝ where toFun θ := cos θ invFun x := arccos x diff --git a/Mathlib/Tactic/NormNum/Result.lean b/Mathlib/Tactic/NormNum/Result.lean index 5622ea94d24425..b6490c4e9d0e69 100644 --- a/Mathlib/Tactic/NormNum/Result.lean +++ b/Mathlib/Tactic/NormNum/Result.lean @@ -311,7 +311,7 @@ section set_option linter.unusedVariables false /-- The result of `norm_num` running on an expression `x` of type `α`. -/ -@[nolint unusedArguments, expose] def Result {α : Q(Type u)} (x : Q($α)) := Result' +@[nolint unusedArguments] def Result {α : Q(Type u)} (x : Q($α)) := Result' -- The new behaviour of `inferInstanceAs` from leanprover/lean4#12897 needs to be updated, -- to ensure that if we are in a `meta` section then the auxiliary definitions are also `meta`. @@ -320,28 +320,28 @@ set_option backward.inferInstanceAs.wrap false in instance {α : Q(Type u)} {x : Q($α)} : Inhabited (Result x) := inferInstanceAs (Inhabited Result') /-- The result is `proof : x`, where `x` is a (true) proposition. -/ -@[match_pattern, inline, expose] def Result.isTrue {x : Q(Prop)} : +@[match_pattern, inline] def Result.isTrue {x : Q(Prop)} : ∀ (proof : Q($x)), Result q($x) := Result'.isBool true /-- The result is `proof : ¬x`, where `x` is a (false) proposition. -/ -@[match_pattern, inline, expose] def Result.isFalse {x : Q(Prop)} : +@[match_pattern, inline] def Result.isFalse {x : Q(Prop)} : ∀ (proof : Q(¬$x)), Result q($x) := Result'.isBool false /-- The result is `lit : ℕ` (a raw nat literal) and `proof : isNat x lit`. -/ -@[match_pattern, inline, expose] def Result.isNat {α : Q(Type u)} {x : Q($α)} : +@[match_pattern, inline] def Result.isNat {α : Q(Type u)} {x : Q($α)} : ∀ (inst : Q(AddMonoidWithOne $α) := by assumption) (lit : Q(ℕ)) (proof : Q(IsNat $x $lit)), Result x := Result'.isNat /-- The result is `-lit` where `lit` is a raw nat literal and `proof : isInt x (.negOfNat lit)`. -/ -@[match_pattern, inline, expose] def Result.isNegNat {α : Q(Type u)} {x : Q($α)} : +@[match_pattern, inline] def Result.isNegNat {α : Q(Type u)} {x : Q($α)} : ∀ (inst : Q(Ring $α) := by assumption) (lit : Q(ℕ)) (proof : Q(IsInt $x (.negOfNat $lit))), Result x := Result'.isNegNat /-- The result is `proof : IsNNRat x n d`, where `n` a raw nat literal, `d` is a raw nat literal (not 0 or 1), `n` and `d` are coprime, and `q` is the value of `n / d`. -/ -@[match_pattern, inline, expose] def Result.isNNRat {α : Q(Type u)} {x : Q($α)} : +@[match_pattern, inline] def Result.isNNRat {α : Q(Type u)} {x : Q($α)} : ∀ (inst : Q(DivisionSemiring $α) := by assumption) (q : Rat) (n : Q(ℕ)) (d : Q(ℕ)) (proof : Q(IsNNRat $x $n $d)), Result x := Result'.isNNRat @@ -349,7 +349,7 @@ where `n` a raw nat literal, `d` is a raw nat literal (not 0 or 1), where `n` is `.negOfNat lit` with `lit` a raw nat literal, `d` is a raw nat literal (not 0 or 1), `n` and `d` are coprime, and `q` is the value of `n / d`. -/ -@[match_pattern, inline, expose] def Result.isNegNNRat {α : Q(Type u)} {x : Q($α)} : +@[match_pattern, inline] def Result.isNegNNRat {α : Q(Type u)} {x : Q($α)} : ∀ (inst : Q(DivisionRing $α) := by assumption) (q : Rat) (n : Q(ℕ)) (d : Q(ℕ)) (proof : Q(IsRat $x (.negOfNat $n) $d)), Result x := Result'.isNegNNRat From 0b824b59da6ab7e9b1d598416f3c07cb8137e3ef Mon Sep 17 00:00:00 2001 From: "mathlib-nightly-testing[bot]" Date: Mon, 13 Apr 2026 09:33:27 +0000 Subject: [PATCH 062/321] chore: bump to nightly-2026-04-13 --- lean-toolchain | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lean-toolchain b/lean-toolchain index bca52a66f4273a..eb7023afec000d 100644 --- a/lean-toolchain +++ b/lean-toolchain @@ -1 +1 @@ -leanprover/lean4:nightly-2026-04-11 +leanprover/lean4:nightly-2026-04-13 From 51f48ec8af2584146647c0e36ac851421d852739 Mon Sep 17 00:00:00 2001 From: leanprover-community-mathlib4-bot Date: Mon, 13 Apr 2026 10:16:58 +0000 Subject: [PATCH 063/321] Update lean-toolchain for https://github.com/leanprover/lean4/pull/13359 --- lake-manifest.json | 2 +- lean-toolchain | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lake-manifest.json b/lake-manifest.json index 29395b93e9dfe3..67568cbeb12a4b 100644 --- a/lake-manifest.json +++ b/lake-manifest.json @@ -65,7 +65,7 @@ "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "17716bd2156dd90a11aef49ffd4108439eacff2f", + "rev": "a1ca5dc0b3bdf70b8db8930b93210323fe5fde3a", "name": "batteries", "manifestFile": "lake-manifest.json", "inputRev": "lean-pr-testing-13359", diff --git a/lean-toolchain b/lean-toolchain index ef138a02c85ec8..c955e0e3fe14ed 100644 --- a/lean-toolchain +++ b/lean-toolchain @@ -1 +1 @@ -leanprover/lean4-pr-releases:pr-release-13359-663798c +leanprover/lean4-pr-releases:pr-release-13359-8400f35 From 7fccdee8587247143421f4aea5bc60035a851340 Mon Sep 17 00:00:00 2001 From: leanprover-community-mathlib4-bot Date: Mon, 13 Apr 2026 11:15:00 +0000 Subject: [PATCH 064/321] Update lean-toolchain for testing https://github.com/leanprover/lean4/pull/13325 --- lake-manifest.json | 4 ++-- lakefile.lean | 2 +- lean-toolchain | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lake-manifest.json b/lake-manifest.json index a1b37fd9243976..a4a8a9d9a0de9f 100644 --- a/lake-manifest.json +++ b/lake-manifest.json @@ -65,10 +65,10 @@ "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "5a746178d12920eacc8a331c80317e7ffbbee780", + "rev": "09f3c93cdbb79f431c5267e8373be9f331341f76", "name": "batteries", "manifestFile": "lake-manifest.json", - "inputRev": "nightly-testing", + "inputRev": "lean-pr-testing-13325", "inherited": false, "configFile": "lakefile.toml"}, {"url": "https://github.com/leanprover/lean4-cli", diff --git a/lakefile.lean b/lakefile.lean index bbba35493244d0..eb8c895fb557b3 100644 --- a/lakefile.lean +++ b/lakefile.lean @@ -6,7 +6,7 @@ open Lake DSL ## Mathlib dependencies on upstream projects -/ -require "leanprover-community" / "batteries" @ git "nightly-testing" +require "leanprover-community" / "batteries" @ git "lean-pr-testing-13325" require "leanprover-community" / "Qq" @ git "nightly-testing" require "leanprover-community" / "aesop" @ git "nightly-testing" require "leanprover-community" / "proofwidgets" @ git "v0.0.97" diff --git a/lean-toolchain b/lean-toolchain index eb7023afec000d..00bd7e748c28d0 100644 --- a/lean-toolchain +++ b/lean-toolchain @@ -1 +1 @@ -leanprover/lean4:nightly-2026-04-13 +leanprover/lean4-pr-releases:pr-release-13325-8c01b1b From 02083f3e83ec8cf926ae79f9d85b5eed8f2ab1e0 Mon Sep 17 00:00:00 2001 From: leanprover-community-mathlib4-bot Date: Mon, 13 Apr 2026 11:57:04 +0000 Subject: [PATCH 065/321] Update lean-toolchain for https://github.com/leanprover/lean4/pull/13325 --- lake-manifest.json | 2 +- lean-toolchain | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lake-manifest.json b/lake-manifest.json index a4a8a9d9a0de9f..f1adde96a1c498 100644 --- a/lake-manifest.json +++ b/lake-manifest.json @@ -65,7 +65,7 @@ "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "09f3c93cdbb79f431c5267e8373be9f331341f76", + "rev": "6bd6d39000c7c175ed1cc88f00ef682d31be8b6a", "name": "batteries", "manifestFile": "lake-manifest.json", "inputRev": "lean-pr-testing-13325", diff --git a/lean-toolchain b/lean-toolchain index 00bd7e748c28d0..4838ce217e5977 100644 --- a/lean-toolchain +++ b/lean-toolchain @@ -1 +1 @@ -leanprover/lean4-pr-releases:pr-release-13325-8c01b1b +leanprover/lean4-pr-releases:pr-release-13325-89c4bb1 From 19b8510ad7a020acb1fa66b3e8882cf34dfb829c Mon Sep 17 00:00:00 2001 From: Wojciech Rozowski Date: Mon, 13 Apr 2026 12:58:35 +0000 Subject: [PATCH 066/321] chore: silence simp `varHead` and `varOther` warnings --- Mathlib/Algebra/CharP/Two.lean | 1 + Mathlib/Algebra/Order/Floor/Div.lean | 2 ++ Mathlib/CategoryTheory/Sites/Precoverage.lean | 2 ++ Mathlib/Logic/Embedding/Set.lean | 1 + 4 files changed, 6 insertions(+) diff --git a/Mathlib/Algebra/CharP/Two.lean b/Mathlib/Algebra/CharP/Two.lean index 19803221084e16..225971bc7c3983 100644 --- a/Mathlib/Algebra/CharP/Two.lean +++ b/Mathlib/Algebra/CharP/Two.lean @@ -64,6 +64,7 @@ theorem natCast_cases (n : ℕ) : (n : R) = 0 ∨ (n : R) = 1 := theorem natCast_eq_mod (n : ℕ) : (n : R) = (n % 2 : ℕ) := by simp [natCast_eq_ite, Nat.even_iff] +set_option warning.simp.varHead false in @[scoped simp] theorem ofNat_eq_mod (n : ℕ) [n.AtLeastTwo] : (ofNat(n) : R) = (ofNat(n) % 2 : ℕ) := natCast_eq_mod n diff --git a/Mathlib/Algebra/Order/Floor/Div.lean b/Mathlib/Algebra/Order/Floor/Div.lean index 25998333bb4b4a..523dd9abe57ed2 100644 --- a/Mathlib/Algebra/Order/Floor/Div.lean +++ b/Mathlib/Algebra/Order/Floor/Div.lean @@ -248,6 +248,7 @@ noncomputable instance instFloorDiv : FloorDiv α (ι →₀ β) where zero_floorDiv a := by ext; exact zero_floorDiv _ lemma floorDiv_def (f : ι →₀ β) (a : α) : f ⌊/⌋ a = f.mapRange (· ⌊/⌋ a) (zero_floorDiv _) := rfl +set_option warning.simp.otherHead false in @[norm_cast] lemma coe_floorDiv (f : ι →₀ β) (a : α) : f ⌊/⌋ a = fun i ↦ f i ⌊/⌋ a := rfl @[simp] lemma floorDiv_apply (f : ι →₀ β) (a : α) (i : ι) : (f ⌊/⌋ a) i = f i ⌊/⌋ a := rfl @@ -267,6 +268,7 @@ noncomputable instance instCeilDiv : CeilDiv α (ι →₀ β) where zero_ceilDiv a := by ext; exact zero_ceilDiv _ lemma ceilDiv_def (f : ι →₀ β) (a : α) : f ⌈/⌉ a = f.mapRange (· ⌈/⌉ a) (zero_ceilDiv _) := rfl +set_option warning.simp.otherHead false in @[norm_cast] lemma coe_ceilDiv_def (f : ι →₀ β) (a : α) : f ⌈/⌉ a = fun i ↦ f i ⌈/⌉ a := rfl @[simp] lemma ceilDiv_apply (f : ι →₀ β) (a : α) (i : ι) : (f ⌈/⌉ a) i = f i ⌈/⌉ a := rfl diff --git a/Mathlib/CategoryTheory/Sites/Precoverage.lean b/Mathlib/CategoryTheory/Sites/Precoverage.lean index c0a15ddcefc338..2292a10b1b816d 100644 --- a/Mathlib/CategoryTheory/Sites/Precoverage.lean +++ b/Mathlib/CategoryTheory/Sites/Precoverage.lean @@ -126,6 +126,7 @@ alias mem_coverings_of_isIso := HasIsos.mem_coverings_of_isIso alias sup_mem_coverings := IsStableUnderSup.sup_mem_coverings alias hasPullbacks_of_mem := HasPullbacks.hasPullbacks_of_mem +set_option warning.simp.varHead false in attribute [local simp] Presieve.ofArrows.obj_idx Presieve.ofArrows.hom_idx in lemma mem_coverings_of_isPullback {J : Precoverage C} [IsStableUnderBaseChange J] {ι : Type w} {S : C} {X : ι → C} @@ -146,6 +147,7 @@ lemma mem_coverings_of_isPullback {J : Precoverage C} [IsStableUnderBaseChange J refine le_antisymm (fun Z g ⟨i⟩ ↦ .mk _) fun Z g hg ↦ ?_ exact .mk' (Sum.inl ⟨⟨_, _⟩, hg⟩) (by cat_disch) (by cat_disch) +set_option warning.simp.varHead false in attribute [local simp] Presieve.ofArrows.obj_idx Presieve.ofArrows.hom_idx in lemma comp_mem_coverings {J : Precoverage C} [IsStableUnderComposition J] {ι : Type w} {S : C} {X : ι → C} (f : ∀ i, X i ⟶ S) (hf : Presieve.ofArrows X f ∈ J S) diff --git a/Mathlib/Logic/Embedding/Set.lean b/Mathlib/Logic/Embedding/Set.lean index 1eb4b2947b9212..4036dffb4dc419 100644 --- a/Mathlib/Logic/Embedding/Set.lean +++ b/Mathlib/Logic/Embedding/Set.lean @@ -162,6 +162,7 @@ the natural injection from the sigma-type `(i : ι) × ↑(s i)` to `α`. -/ obtain rfl : i = j := h.eq (not_disjoint_iff.2 ⟨_, hx, hx'⟩) rfl +set_option warning.simp.otherHead false in @[norm_cast] lemma Function.Embedding.coe_sigmaSet {s : ι → Set α} (h) : (Function.Embedding.sigmaSet h : ((i : ι) × s i) → α) = fun x ↦ x.2.1 := rfl From 4462ca1dfc68ff79c8fbc8ea1b35e67ee9aa1d87 Mon Sep 17 00:00:00 2001 From: Wojciech Rozowski Date: Mon, 13 Apr 2026 13:00:54 +0000 Subject: [PATCH 067/321] chore: silence `varHead` warning --- Mathlib/Probability/Kernel/Defs.lean | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Mathlib/Probability/Kernel/Defs.lean b/Mathlib/Probability/Kernel/Defs.lean index ca32d6bd9fcb3a..2362506ade3a96 100644 --- a/Mathlib/Probability/Kernel/Defs.lean +++ b/Mathlib/Probability/Kernel/Defs.lean @@ -288,11 +288,13 @@ lemma apply_congr_of_mem_measurableAtom (κ : Kernel α β) {y' y : α} (hy' : y ext s hs exact mem_of_mem_measurableAtom hy' (κ.measurable_coe hs (measurableSet_singleton (κ y s))) rfl +set_option warning.simp.varHead false in @[nontriviality] lemma eq_zero_of_isEmpty_left (κ : Kernel α β) [h : IsEmpty α] : κ = 0 := by ext a exact h.elim a +set_option warning.simp.varHead false in @[nontriviality] lemma eq_zero_of_isEmpty_right (κ : Kernel α β) [IsEmpty β] : κ = 0 := by ext a From 39ef8defdbea5bf33f00bb4b0f7dff70aec6b0d4 Mon Sep 17 00:00:00 2001 From: Wojciech Rozowski Date: Mon, 13 Apr 2026 13:08:29 +0000 Subject: [PATCH 068/321] chore: fix `globalAtrtributeIn` test --- MathlibTest/globalAttributeIn.lean | 1 + 1 file changed, 1 insertion(+) diff --git a/MathlibTest/globalAttributeIn.lean b/MathlibTest/globalAttributeIn.lean index a61961950ef7e2..56ced2d39e8426 100644 --- a/MathlibTest/globalAttributeIn.lean +++ b/MathlibTest/globalAttributeIn.lean @@ -57,6 +57,7 @@ error: Despite the `in`, the attribute ext is added globally to foo please remove the `in` or make this a `local ext` -/ #guard_msgs in +set_option warning.simp.varHead false in attribute [simp, local simp, ext, scoped instance, -simp, -ext] foo in def bar := False From d04433780ffde215071a2aa2a7ae3a939493ea20 Mon Sep 17 00:00:00 2001 From: Wojciech Rozowski Date: Mon, 13 Apr 2026 13:58:48 +0000 Subject: [PATCH 069/321] chore: fix `Archive` build --- Archive/Examples/IfNormalization/Result.lean | 1 + Archive/Imo/Imo2024Q6.lean | 2 ++ 2 files changed, 3 insertions(+) diff --git a/Archive/Examples/IfNormalization/Result.lean b/Archive/Examples/IfNormalization/Result.lean index e76444515c5b42..8af518d298d0c3 100644 --- a/Archive/Examples/IfNormalization/Result.lean +++ b/Archive/Examples/IfNormalization/Result.lean @@ -24,6 +24,7 @@ We add some local simp lemmas so we can unfold the definitions of the normalizat attribute [local simp] normalized hasNestedIf hasConstantIf hasRedundantIf disjoint vars List.disjoint +set_option warning.simp.varHead false in attribute [local simp] apply_ite ite_eq_iff' variable {b : Bool} {f : ℕ → Bool} {i : ℕ} {t e : IfExpr} diff --git a/Archive/Imo/Imo2024Q6.lean b/Archive/Imo/Imo2024Q6.lean index 8e26eb7b9494f6..97d7b6d4ed16dd 100644 --- a/Archive/Imo/Imo2024Q6.lean +++ b/Archive/Imo/Imo2024Q6.lean @@ -55,6 +55,7 @@ lemma Aquaesulian.injective : Function.Injective f := by · exact (h.eq_of_apply_eq_inl he.symm hc).symm · exact h.eq_of_apply_eq_inl he hc +set_option warning.simp.varHead false in @[simp] lemma Aquaesulian.apply_zero : f 0 = 0 := by refine h.injective ?_ @@ -68,6 +69,7 @@ lemma Aquaesulian.apply_neg_apply_add (x : G) : f (-(f x)) + x = 0 := by · rw [add_neg_cancel, h.apply_zero] at hc exact hc.symm +set_option warning.simp.varHead false in @[simp] lemma Aquaesulian.apply_neg_apply (x : G) : f (-(f x)) = -x := by rw [← add_eq_zero_iff_eq_neg] From f74b5ed4f50b31eaaeaf715070690f63c7f3f548 Mon Sep 17 00:00:00 2001 From: leanprover-community-mathlib4-bot Date: Mon, 13 Apr 2026 15:14:50 +0000 Subject: [PATCH 070/321] Update lean-toolchain for https://github.com/leanprover/lean4/pull/13325 --- lake-manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lake-manifest.json b/lake-manifest.json index f1adde96a1c498..501de355f5e18d 100644 --- a/lake-manifest.json +++ b/lake-manifest.json @@ -65,7 +65,7 @@ "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "6bd6d39000c7c175ed1cc88f00ef682d31be8b6a", + "rev": "7b47d455134a2bae3f32350389756a731206c86d", "name": "batteries", "manifestFile": "lake-manifest.json", "inputRev": "lean-pr-testing-13325", From 670c0bf48a617ecb4fc1262c782e363872ea09d4 Mon Sep 17 00:00:00 2001 From: leanprover-community-mathlib4-bot Date: Mon, 13 Apr 2026 17:11:29 +0000 Subject: [PATCH 071/321] Update lean-toolchain for https://github.com/leanprover/lean4/pull/13325 --- lake-manifest.json | 2 +- lean-toolchain | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lake-manifest.json b/lake-manifest.json index 501de355f5e18d..2a8214015873a8 100644 --- a/lake-manifest.json +++ b/lake-manifest.json @@ -65,7 +65,7 @@ "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "7b47d455134a2bae3f32350389756a731206c86d", + "rev": "6b72ff123eeec697911ff4e1bb2b84af54fbe9e7", "name": "batteries", "manifestFile": "lake-manifest.json", "inputRev": "lean-pr-testing-13325", diff --git a/lean-toolchain b/lean-toolchain index 4838ce217e5977..b4b930375c7f7d 100644 --- a/lean-toolchain +++ b/lean-toolchain @@ -1 +1 @@ -leanprover/lean4-pr-releases:pr-release-13325-89c4bb1 +leanprover/lean4-pr-releases:pr-release-13325-95ecc71 From 2f4e09cdff59cd5482d13e85f635a2e68101f9d0 Mon Sep 17 00:00:00 2001 From: Kim Morrison Date: Mon, 13 Apr 2026 22:50:37 +0000 Subject: [PATCH 072/321] fix from nightly-testing --- scripts/create_deprecated_modules.lean | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/scripts/create_deprecated_modules.lean b/scripts/create_deprecated_modules.lean index 17dff24f395335..d17459a8128f45 100644 --- a/scripts/create_deprecated_modules.lean +++ b/scripts/create_deprecated_modules.lean @@ -5,6 +5,7 @@ Authors: Damiano Testa -/ --import Mathlib.Init +import Std.Time.Format import Std.Time.Zoned import Lean.Meta.Tactic.TryThis -- a comment here to test `keepTrailing @@ -49,8 +50,12 @@ It returns just the imports of `fileContent`, including trailing comments if `ke -/ def getHeader (fname fileContent : String) (keepTrailing : Bool) : IO String := do let (stx, _) ← Parser.parseHeader (Parser.mkInputContext fileContent fname) - let stx := if keepTrailing then stx.raw else stx.raw.unsetTrailing - let some substring := stx.getSubstring? | throw <| .userError "No substring: we have a problem!" + let imports := stx.raw.getArg 2 -- extract just the imports list + let imports := if keepTrailing then imports else imports.unsetTrailing + -- Use `withLeading := false` to exclude leading comments (e.g. copyright header) that the + -- parser now attaches to the first token (see leanprover/lean4#12662). + let some substring := imports.getSubstring? (withLeading := false) | + throw <| .userError "No substring: we have a problem!" return substring.toString /-- @@ -371,10 +376,11 @@ replaced by the suggestion, which means that you can click on multiple suggestio the deprecations later on. -/ -#find_deleted_files 0 +-- #find_deleted_files 0 /-- -info: import Std.Time.Zoned +info: import Std.Time.Format +import Std.Time.Zoned import Lean.Meta.Tactic.TryThis -/ #guard_msgs in @@ -384,7 +390,8 @@ run_cmd logInfo head /-- -info: import Std.Time.Zoned +info: import Std.Time.Format +import Std.Time.Zoned import Lean.Meta.Tactic.TryThis -- a comment here to test `keepTrailing -/ From d3e9985046e0fdff2fea7541a0d93e65817a87ac Mon Sep 17 00:00:00 2001 From: "mathlib-nightly-testing[bot]" Date: Tue, 14 Apr 2026 09:27:55 +0000 Subject: [PATCH 073/321] chore: bump to nightly-2026-04-14 --- lean-toolchain | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lean-toolchain b/lean-toolchain index eb7023afec000d..8db80a7b77a650 100644 --- a/lean-toolchain +++ b/lean-toolchain @@ -1 +1 @@ -leanprover/lean4:nightly-2026-04-13 +leanprover/lean4:nightly-2026-04-14 From e024c64f122dd6016f0825af60288a305aebd2ab Mon Sep 17 00:00:00 2001 From: Sebastian Ullrich Date: Tue, 14 Apr 2026 13:58:17 +0000 Subject: [PATCH 074/321] fix --- Mathlib/Order/Types/Defs.lean | 1 - Mathlib/RingTheory/AdicCompletion/Completeness.lean | 1 - Mathlib/SetTheory/Ordinal/Exponential.lean | 2 +- 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/Mathlib/Order/Types/Defs.lean b/Mathlib/Order/Types/Defs.lean index 66a25a7f0dca4d..a4f38e86a00b48 100644 --- a/Mathlib/Order/Types/Defs.lean +++ b/Mathlib/Order/Types/Defs.lean @@ -75,7 +75,6 @@ instance (o : OrderType) : LinearOrder o.ToType := /-! ### Basic properties of the order type -/ /-- The order type of the linear order on `α`. -/ -@[no_expose] def type (α : Type u) [LinearOrder α] : OrderType := ⟦⟨α⟩⟧ diff --git a/Mathlib/RingTheory/AdicCompletion/Completeness.lean b/Mathlib/RingTheory/AdicCompletion/Completeness.lean index 7b28fb9cea7d51..bca285ed938156 100644 --- a/Mathlib/RingTheory/AdicCompletion/Completeness.lean +++ b/Mathlib/RingTheory/AdicCompletion/Completeness.lean @@ -90,7 +90,6 @@ private lemma ofValEqZeroAux_prop {x : AdicCompletion I M} (h : c = b + a) /-- Given an element `x` in the adic completion of `M` whose projection to `M / I ^ n • M` is zero, `ofValEqZero` constructs the corresponding element in the adic completion of `I ^ n • M`. -/ -@[no_expose] def ofValEqZero {n : ℕ} {x : AdicCompletion I M} (hxn : x.val n = 0) : AdicCompletion I ↥(I ^ n • (⊤ : Submodule R M)) where val i := ofValEqZeroAux I (Eq.refl (i + n)) hxn diff --git a/Mathlib/SetTheory/Ordinal/Exponential.lean b/Mathlib/SetTheory/Ordinal/Exponential.lean index 3562e83ecee323..144f9ad9139d0f 100644 --- a/Mathlib/SetTheory/Ordinal/Exponential.lean +++ b/Mathlib/SetTheory/Ordinal/Exponential.lean @@ -270,7 +270,7 @@ theorem opow_mul_lt_opow {b u v x : Ordinal} (hv : v < b) (hu : u < x) : b ^ u * `w < b ^ u`. We special case `log 0 x = log 1 x = 0`, as well as `log b 0 = 0`. -/ -@[pp_nodot, no_expose] +@[pp_nodot] def log (b x : Ordinal) : Ordinal := sSup ((b ^ ·) ⁻¹' Iic x) From 0c446723b4ee1ebd2ac1d842a647dd4ce06ace2b Mon Sep 17 00:00:00 2001 From: Sebastian Ullrich Date: Tue, 14 Apr 2026 20:45:25 +0000 Subject: [PATCH 075/321] lake update --- lake-manifest.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lake-manifest.json b/lake-manifest.json index 67568cbeb12a4b..8df074d0a46b06 100644 --- a/lake-manifest.json +++ b/lake-manifest.json @@ -5,7 +5,7 @@ "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "f449eabb8f7e3feef0366856c20e28a6d2c97ee3", + "rev": "264309b5c0c10e569025a53ab6440a45c03133e4", "name": "plausible", "manifestFile": "lake-manifest.json", "inputRev": "main", @@ -25,7 +25,7 @@ "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "86503d416c875fdcf3b6b6c54c22581e96c6bda7", + "rev": "4411c5f89c797401c609b3a946c8874569e69731", "name": "importGraph", "manifestFile": "lake-manifest.json", "inputRev": "main", @@ -65,7 +65,7 @@ "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "a1ca5dc0b3bdf70b8db8930b93210323fe5fde3a", + "rev": "de57422f63844ccfb61d5dd0153555b6d65db4ff", "name": "batteries", "manifestFile": "lake-manifest.json", "inputRev": "lean-pr-testing-13359", From 606f569015f01c9d4e70974b3be8467f2fc5ab1a Mon Sep 17 00:00:00 2001 From: "mathlib-nightly-testing[bot]" Date: Wed, 15 Apr 2026 09:28:48 +0000 Subject: [PATCH 076/321] chore: bump to nightly-2026-04-15 --- lean-toolchain | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lean-toolchain b/lean-toolchain index 8db80a7b77a650..b74ced19101876 100644 --- a/lean-toolchain +++ b/lean-toolchain @@ -1 +1 @@ -leanprover/lean4:nightly-2026-04-14 +leanprover/lean4:nightly-2026-04-15 From 2edcb2ae255acd756703fc08ea161ef5c84f6921 Mon Sep 17 00:00:00 2001 From: Joachim Breitner Date: Wed, 15 Apr 2026 14:36:00 +0000 Subject: [PATCH 077/321] 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 that were previously unfolded automatically in match discriminants now need explicit unfolding. --- .../BigOperators/Group/List/Basic.lean | 2 +- Mathlib/Algebra/Group/Defs.lean | 6 +- Mathlib/Algebra/Homology/ExactSequence.lean | 3 +- .../Algebra/Homology/HomologicalComplex.lean | 3 +- .../Algebra/Homology/HomologySequence.lean | 6 +- .../Homology/SpectralObject/Basic.lean | 1 + .../Homology/SpectralObject/Cycles.lean | 2 +- .../Order/GroupWithZero/Canonical.lean | 32 +++++-- Mathlib/Algebra/SkewMonoidAlgebra/Basic.lean | 2 +- .../EllipticCurve/Affine/Point.lean | 13 +-- Mathlib/AlgebraicTopology/MooreComplex.lean | 5 +- .../SimplexCategory/Augmented/Monoidal.lean | 8 +- .../SimplicialSet/Nerve.lean | 4 +- Mathlib/Analysis/Calculus/ContDiff/Defs.lean | 4 +- .../CategoryTheory/Bicategory/Coherence.lean | 27 +++++- .../Bicategory/Functor/LocallyDiscrete.lean | 6 +- .../ComposableArrows/Basic.lean | 54 ++++++++---- .../CategoryTheory/ComposableArrows/One.lean | 9 +- .../ComposableArrows/Three.lean | 1 + .../CategoryTheory/ComposableArrows/Two.lean | 20 +++-- .../Limits/Shapes/Equalizers.lean | 4 +- .../Limits/Shapes/Multiequalizer.lean | 18 +++- .../Monoidal/Free/Coherence.lean | 15 +++- .../DenseSubsite/OneHypercoverDense.lean | 7 +- .../CategoryTheory/Sites/Hypercover/One.lean | 12 ++- Mathlib/CategoryTheory/Sites/Whiskering.lean | 6 +- Mathlib/Computability/RegularExpressions.lean | 11 ++- .../TuringMachine/ToPartrec.lean | 3 +- Mathlib/Data/List/Permutation.lean | 2 +- Mathlib/Data/Nat/Bitwise.lean | 7 +- Mathlib/Data/Num/Lemmas.lean | 2 +- Mathlib/Data/Num/ZNum.lean | 10 +-- Mathlib/Data/Sign/Defs.lean | 6 +- .../Dynamics/Ergodic/Action/OfMinimal.lean | 2 +- Mathlib/ModelTheory/Semantics.lean | 2 +- Mathlib/NumberTheory/Zsqrtd/Basic.lean | 20 ++++- .../UniqueFactorizationDomain/FactorSet.lean | 4 +- .../Valuation/ValuativeRel/Basic.lean | 2 +- Mathlib/SetTheory/Ordinal/Notation.lean | 83 +++++++++++++------ Mathlib/Tactic/NormNum/PowMod.lean | 4 +- lake-manifest.json | 4 +- lakefile.lean | 2 +- lean-toolchain | 2 +- 43 files changed, 305 insertions(+), 131 deletions(-) diff --git a/Mathlib/Algebra/BigOperators/Group/List/Basic.lean b/Mathlib/Algebra/BigOperators/Group/List/Basic.lean index 10b0b3e4b5e08d..c9febf4b348c8e 100644 --- a/Mathlib/Algebra/BigOperators/Group/List/Basic.lean +++ b/Mathlib/Algebra/BigOperators/Group/List/Basic.lean @@ -258,7 +258,7 @@ lemma prod_mul_prod_eq_prod_zipWith_mul_prod_drop : | [], ys => by simp | xs, [] => by simp | x :: xs, y :: ys => by - simp only [drop, zipWith_cons_cons, prod_cons] + simp only [zipWith_cons_cons, prod_cons] conv => lhs; rw [mul_assoc]; right; rw [mul_comm, mul_assoc]; right rw [mul_comm, prod_mul_prod_eq_prod_zipWith_mul_prod_drop xs ys] diff --git a/Mathlib/Algebra/Group/Defs.lean b/Mathlib/Algebra/Group/Defs.lean index 57c7d138e1b351..355684cbc3ad54 100644 --- a/Mathlib/Algebra/Group/Defs.lean +++ b/Mathlib/Algebra/Group/Defs.lean @@ -524,7 +524,11 @@ theorem npowRec'_two_mul {M : Type*} [Semigroup M] [One M] (k : ℕ) (m : M) : match k' with | 0 => rfl | 1 => simp [npowRec'] - | k + 2 => simp [npowRec', ← mul_assoc, ← ih] + | k + 2 => + rw [show 2 * (k + 2) = k + k + 4 from by omega] + simp only [npowRec'] + rw [← ih (k + 1) (by omega), show 2 * (k + 1) = k + k + 2 from by omega] + simp only [npowRec', ← mul_assoc] @[to_additive] theorem npowRec'_mul_comm {M : Type*} [Semigroup M] [One M] {k : ℕ} (k0 : k ≠ 0) (m : M) : diff --git a/Mathlib/Algebra/Homology/ExactSequence.lean b/Mathlib/Algebra/Homology/ExactSequence.lean index 4d45263e13d941..51c41c0a0910a9 100644 --- a/Mathlib/Algebra/Homology/ExactSequence.lean +++ b/Mathlib/Algebra/Homology/ExactSequence.lean @@ -225,8 +225,7 @@ lemma isComplex₂_mk (S : ComposableArrows C 2) (w : S.map' 0 1 ≫ S.map' 1 2 set_option backward.isDefEq.respectTransparency false in lemma _root_.CategoryTheory.ShortComplex.isComplex_toComposableArrows (S : ShortComplex C) : S.toComposableArrows.IsComplex := - -- Disable `Fin.reduceFinMk` because otherwise `Precompose.map_one_succ` does not apply. (https://github.com/leanprover-community/mathlib4/issues/27382) - isComplex₂_mk _ (by simp [-Fin.reduceFinMk]) + isComplex₂_mk _ (by change S.f ≫ S.g = 0; simp [S.zero]) lemma exact₂_iff (S : ComposableArrows C 2) (hS : S.IsComplex) : S.Exact ↔ (S.sc' hS 0 1 2).Exact := by diff --git a/Mathlib/Algebra/Homology/HomologicalComplex.lean b/Mathlib/Algebra/Homology/HomologicalComplex.lean index d5929a25584828..8b825ee6542844 100644 --- a/Mathlib/Algebra/Homology/HomologicalComplex.lean +++ b/Mathlib/Algebra/Homology/HomologicalComplex.lean @@ -729,7 +729,8 @@ lemma mkAux_eq_shortComplex_mk_d_comp_d (n : ℕ) : ShortComplex.mk _ _ ((mk X₀ X₁ X₂ d₀ d₁ s succ).d_comp_d (n + 2) (n + 1) n) := by change ShortComplex.mk _ _ (mkAux X₀ X₁ X₂ d₀ d₁ s succ n).zero = _ dsimp [mk, of, mkAux] - simp + simp only [show n + 2 = n + 1 + 1 from rfl, ↓reduceDIte] + congr 1 <;> exact (Category.id_comp _).symm /-- The isomorphism from `(mk X₀ X₁ X₂ d₀ d₁ s succ).X (n + 3)` that is given by the inductive construction. -/ diff --git a/Mathlib/Algebra/Homology/HomologySequence.lean b/Mathlib/Algebra/Homology/HomologySequence.lean index 62f02c8c68efbe..ddeb6d2fa343d6 100644 --- a/Mathlib/Algebra/Homology/HomologySequence.lean +++ b/Mathlib/Algebra/Homology/HomologySequence.lean @@ -158,8 +158,10 @@ noncomputable def composableArrows₃Functor [CategoryWithHomology C] : HomologicalComplex C c ⥤ ComposableArrows C 3 where obj K := composableArrows₃ K i j map {K L} φ := ComposableArrows.homMk₃ (homologyMap φ i) (opcyclesMap φ i) (cyclesMap φ j) - -- Disable `Fin.reduceFinMk`, otherwise `Precomp.obj_succ` does not fire. (https://github.com/leanprover-community/mathlib4/issues/27382) - (homologyMap φ j) (by simp) (by simp [-Fin.reduceFinMk]) (by simp [-Fin.reduceFinMk]) + (homologyMap φ j) + (by set_option backward.isDefEq.respectTransparency false in simp) + (by set_option backward.isDefEq.respectTransparency false in simp [-Fin.reduceFinMk]) + (by change K.homologyπ j ≫ homologyMap φ j = cyclesMap φ j ≫ L.homologyπ j; simp) end HomologySequence diff --git a/Mathlib/Algebra/Homology/SpectralObject/Basic.lean b/Mathlib/Algebra/Homology/SpectralObject/Basic.lean index 78369c2d7b5773..af2a251831aa40 100644 --- a/Mathlib/Algebra/Homology/SpectralObject/Basic.lean +++ b/Mathlib/Algebra/Homology/SpectralObject/Basic.lean @@ -183,6 +183,7 @@ attribute [reassoc, simp] comp_hom lemma isZero_H_map_mk₁_of_isIso (n : ℤ) {i₀ i₁ : ι} (f : i₀ ⟶ i₁) [IsIso f] : IsZero ((X.H n).obj (mk₁ f)) := by let φ := twoδ₂Toδ₁ f (inv f) (𝟙 i₀) (by simp) ≫ twoδ₁Toδ₀ f (inv f) (𝟙 i₀) + set_option backward.isDefEq.respectTransparency false in have : IsIso φ := by rw [isIso_iff₁] constructor <;> dsimp [φ] <;> infer_instance diff --git a/Mathlib/Algebra/Homology/SpectralObject/Cycles.lean b/Mathlib/Algebra/Homology/SpectralObject/Cycles.lean index 273281c1b83419..e4b56e648dafe9 100644 --- a/Mathlib/Algebra/Homology/SpectralObject/Cycles.lean +++ b/Mathlib/Algebra/Homology/SpectralObject/Cycles.lean @@ -314,7 +314,7 @@ lemma toCycles_cyclesMap (α : mk₂ f g ⟶ mk₂ f' g') (β : mk₁ fg ⟶ mk rw [hβ₀] exact naturality' α 0 1 · dsimp - rw [hβ₁, Category.comp_id, Category.id_comp] + simp [hβ₁] /-- The map `H^n(f) ⟶ H^n(f ≫ g)` factors through `opZ^n(f, g)`. -/ noncomputable def fromOpcycles (n : ℤ) : diff --git a/Mathlib/Algebra/Order/GroupWithZero/Canonical.lean b/Mathlib/Algebra/Order/GroupWithZero/Canonical.lean index 9cd9d955bb9d22..70f2e9204885c3 100644 --- a/Mathlib/Algebra/Order/GroupWithZero/Canonical.lean +++ b/Mathlib/Algebra/Order/GroupWithZero/Canonical.lean @@ -419,16 +419,30 @@ end PartialOrder section Lattice +def withZeroSup [Max α] : WithZero α → WithZero α → WithZero α := + Option.merge (· ⊔ ·) + +theorem withZeroSup_zero_zero [Max α] : (withZeroSup (0 : WithZero α) 0) = 0 := rfl +theorem withZeroSup_coe_zero [Max α] (a : α) : (withZeroSup (↑a : WithZero α) 0) = ↑a := rfl +theorem withZeroSup_zero_coe [Max α] (b : α) : (withZeroSup (0 : WithZero α) ↑b) = ↑b := rfl +theorem withZeroSup_coe_coe [Max α] (a b : α) : + (withZeroSup (↑a : WithZero α) ↑b) = ↑(a ⊔ b) := rfl + instance semilatticeSup [SemilatticeSup α] : SemilatticeSup (WithZero α) where - sup - -- note this is `Option.merge`, but with the right defeq when unfolding - | 0, 0 => 0 - | (a : α), 0 => a - | 0, (b : α) => b - | (a : α), (b : α) => ↑(a ⊔ b) - le_sup_left x y := by cases x <;> cases y <;> simp - le_sup_right x y := by cases x <;> cases y <;> simp - sup_le x y z := by cases x <;> cases y <;> cases z <;> simp; simpa using sup_le + sup := withZeroSup + le_sup_left x y := by + cases x <;> cases y <;> + simp [withZeroSup_zero_zero, withZeroSup_coe_zero, withZeroSup_zero_coe, + withZeroSup_coe_coe, WithZero.coe_le_coe, le_sup_left, WithZero.zero_le] + le_sup_right x y := by + cases x <;> cases y <;> + simp [withZeroSup_zero_zero, withZeroSup_coe_zero, withZeroSup_zero_coe, + withZeroSup_coe_coe, WithZero.coe_le_coe, le_sup_right, WithZero.zero_le] + sup_le x y z := by + cases x <;> cases y <;> cases z <;> + simp [withZeroSup_zero_zero, withZeroSup_coe_zero, withZeroSup_zero_coe, + withZeroSup_coe_coe, WithZero.coe_le_coe, WithZero.zero_le] + simpa using sup_le theorem coe_sup [SemilatticeSup α] (a b : α) : ((a ⊔ b : α) : WithZero α) = (a : WithZero α) ⊔ b := rfl diff --git a/Mathlib/Algebra/SkewMonoidAlgebra/Basic.lean b/Mathlib/Algebra/SkewMonoidAlgebra/Basic.lean index 8199498397b672..4e82eb271011a3 100644 --- a/Mathlib/Algebra/SkewMonoidAlgebra/Basic.lean +++ b/Mathlib/Algebra/SkewMonoidAlgebra/Basic.lean @@ -324,7 +324,7 @@ theorem one_def : (1 : SkewMonoidAlgebra k G) = single 1 1 := rfl @[simp] theorem coeff_one_one : coeff (1 : SkewMonoidAlgebra k G) 1 = 1 := by - simp only [coeff, toFinsupp_single, Finsupp.single_eq_same] + simp only [coeff, One.one, toFinsupp_single, Finsupp.single_eq_same] theorem coeff_one {a : G} [Decidable (a = 1)] : (1 : SkewMonoidAlgebra k G).coeff a = if a = 1 then 1 else 0 := by diff --git a/Mathlib/AlgebraicGeometry/EllipticCurve/Affine/Point.lean b/Mathlib/AlgebraicGeometry/EllipticCurve/Affine/Point.lean index 07376bf4e749af..020d6d845dc986 100644 --- a/Mathlib/AlgebraicGeometry/EllipticCurve/Affine/Point.lean +++ b/Mathlib/AlgebraicGeometry/EllipticCurve/Affine/Point.lean @@ -722,12 +722,13 @@ the class of the non-zero fractional ideal `⟨X - x, Y - y⟩` in the ideal cla @[simps] noncomputable def toClass : W.Point →+ Additive (ClassGroup W.CoordinateRing) where toFun P := match P with - | 0 => 0 + | zero => 0 | some _ _ h => ClassGroup.mk <| CoordinateRing.XYIdeal' h map_zero' := rfl map_add' := by rintro (_ | ⟨x₁, y₁, h₁⟩) (_ | ⟨x₂, y₂, h₂⟩) any_goals simp only [← zero_def, zero_add, add_zero] + any_goals rfl by_cases hxy : x₁ = x₂ ∧ y₁ = W.negY x₂ y₂ · simp only [hxy.left, hxy.right, add_of_Y_eq rfl rfl] exact (CoordinateRing.mk_XYIdeal'_neg_mul h₂).symm @@ -793,7 +794,7 @@ variable [Algebra R S] [Algebra R F] [Algebra S F] [IsScalarTower R S F] [Algebr where `W` is defined over a subring of a ring `S`, and `F` and `K` are field extensions of `S`. -/ noncomputable def map : W'⟮F⟯ →+ W'⟮K⟯ where toFun P := match P with - | 0 => 0 + | zero => 0 | some _ _ h => some _ _ <| (baseChange_nonsingular _ _ f.injective).mpr h map_zero' := rfl map_add' := by @@ -801,7 +802,7 @@ noncomputable def map : W'⟮F⟯ →+ W'⟮K⟯ where any_goals rfl by_cases hxy : x₁ = x₂ ∧ y₁ = (W'.baseChange F).toAffine.negY x₂ y₂ · rw [add_of_Y_eq hxy.left hxy.right, - add_of_Y_eq (congr_arg _ hxy.left) <| by rw [hxy.right, baseChange_negY]] + add_of_Y_eq (congr_arg _ hxy.left) <| by rw [hxy.right, baseChange_negY]]; rfl · simpa only [add_some hxy, ← baseChange_addX, ← baseChange_addY, ← baseChange_slope] using (add_some fun h ↦ hxy ⟨f.injective h.1, f.injective (W'.baseChange_negY f .. ▸ h).2⟩).symm @@ -877,9 +878,9 @@ lemma xRep_neg (P : W'.Point) : (-P).xRep = P.xRep := by lemma eq_or_eq_neg_of_xRep_eq_xRep {P Q : W.Point} (h : P.xRep = Q.xRep) : P = Q ∨ P = -Q := by match P, Q with - | 0, 0 => exact .inl rfl - | 0, some .. => simp [xRep] at h - | some .., 0 => simp [xRep] at h + | zero, zero => exact .inl rfl + | zero, some .. => simp [xRep] at h + | some .., zero => simp [xRep] at h | some x₁ .., some x₂ .. => simp only [xRep, Matrix.vecCons_inj, and_true] at h exact X_eq_iff.mp h diff --git a/Mathlib/AlgebraicTopology/MooreComplex.lean b/Mathlib/AlgebraicTopology/MooreComplex.lean index 6c9c9dccd7e163..efd1d5a4c93103 100644 --- a/Mathlib/AlgebraicTopology/MooreComplex.lean +++ b/Mathlib/AlgebraicTopology/MooreComplex.lean @@ -135,7 +135,10 @@ def map (f : X ⟶ Y) : obj X ⟶ obj Y := erw [kernelSubobject_arrow_comp_assoc] rw [zero_comp, comp_zero])) fun n => by - cases n <;> dsimp [objD, objX] <;> cat_disch + cases n <;> + simp only [Nat.reduceAdd, objX_add_one, objX_zero, objD, Fin.isValue, + factorThru_arrow_assoc, Category.assoc] <;> + cat_disch end NormalizedMooreComplex diff --git a/Mathlib/AlgebraicTopology/SimplexCategory/Augmented/Monoidal.lean b/Mathlib/AlgebraicTopology/SimplexCategory/Augmented/Monoidal.lean index 8b98670f95fa1d..72d2d8728c5858 100644 --- a/Mathlib/AlgebraicTopology/SimplexCategory/Augmented/Monoidal.lean +++ b/Mathlib/AlgebraicTopology/SimplexCategory/Augmented/Monoidal.lean @@ -173,10 +173,12 @@ abbrev inr' (x y : SimplexCategory) : y ⟶ tensorObjOf x y := WithInitial.down set_option backward.isDefEq.respectTransparency false in lemma inl'_eval (x y : SimplexCategory) (i : Fin (x.len + 1)) : (inl' x y).toOrderHom i = (i.castAdd _).cast (Nat.succ_add x.len (y.len + 1)) := by - dsimp [inl', inl, MonoidalCategoryStruct.rightUnitor, MonoidalCategoryStruct.whiskerLeft, - tensorHom, WithInitial.down, rightUnitor, tensorObj] ext - simp [OrderEmbedding.toOrderHom] + simp [inl', inl, MonoidalCategoryStruct.rightUnitor, MonoidalCategoryStruct.whiskerLeft, + MonoidalCategoryStruct.tensorUnit, MonoidalCategoryStruct.tensorObj, + tensorUnit, tensorHom, WithInitial.down, rightUnitor, tensorObj, CategoryStruct.id, + CategoryStruct.comp, WithInitial.comp, WithInitial.id, + OrderEmbedding.toOrderHom] set_option backward.isDefEq.respectTransparency false in lemma inr'_eval (x y : SimplexCategory) (i : Fin (y.len + 1)) : diff --git a/Mathlib/AlgebraicTopology/SimplicialSet/Nerve.lean b/Mathlib/AlgebraicTopology/SimplicialSet/Nerve.lean index 883e7061c5ce09..0eed2ca162fcb9 100644 --- a/Mathlib/AlgebraicTopology/SimplicialSet/Nerve.lean +++ b/Mathlib/AlgebraicTopology/SimplicialSet/Nerve.lean @@ -61,7 +61,8 @@ lemma nerveMap_app_mk₀ (x : C) : lemma nerveMap_app_mk₁ {x y : C} (f : x ⟶ y) : (nerveMap F).app (op ⦋1⦌) (ComposableArrows.mk₁ f) = ComposableArrows.mk₁ (F.map f) := - ComposableArrows.ext₁ rfl rfl (by simp [nerveMap_app]) + ComposableArrows.ext₁ (by with_unfolding_all rfl) (by with_unfolding_all rfl) + (by simp [nerveMap_app]) end @@ -101,6 +102,7 @@ lemma σ_obj {n : ℕ} (i : Fin (n + 1)) (x : ComposableArrows C n) (j : Fin (n lemma δ₀_eq {x : ComposableArrows C (n + 1)} : (nerve C).δ (0 : Fin (n + 2)) x = x.δ₀ := rfl +set_option backward.isDefEq.respectTransparency false in lemma σ₀_mk₀_eq (x : C) : (nerve C).σ (0 : Fin 1) (.mk₀ x) = .mk₁ (𝟙 x) := ComposableArrows.ext₁ rfl rfl (by simp; rfl) diff --git a/Mathlib/Analysis/Calculus/ContDiff/Defs.lean b/Mathlib/Analysis/Calculus/ContDiff/Defs.lean index 2dc3422652b351..d1715122993869 100644 --- a/Mathlib/Analysis/Calculus/ContDiff/Defs.lean +++ b/Mathlib/Analysis/Calculus/ContDiff/Defs.lean @@ -209,8 +209,8 @@ theorem contDiffWithinAt_infty : theorem ContDiffWithinAt.continuousWithinAt (h : ContDiffWithinAt 𝕜 n f s x) : ContinuousWithinAt f s x := by have := h.of_le (zero_le _) - simp only [ContDiffWithinAt, nonpos_iff_eq_zero, Nat.cast_eq_zero, forall_eq, CharP.cast_eq_zero] - at this + change ∀ m : ℕ, (m : ℕ∞) ≤ 0 → _ at this + simp only [nonpos_iff_eq_zero, Nat.cast_eq_zero, forall_eq, CharP.cast_eq_zero] at this rcases this with ⟨u, hu, p, H⟩ rw [mem_nhdsWithin_insert] at hu exact (H.continuousOn.continuousWithinAt hu.1).mono_of_mem_nhdsWithin hu.2 diff --git a/Mathlib/CategoryTheory/Bicategory/Coherence.lean b/Mathlib/CategoryTheory/Bicategory/Coherence.lean index e816e919a204b5..5b0ce3b8eeb957 100644 --- a/Mathlib/CategoryTheory/Bicategory/Coherence.lean +++ b/Mathlib/CategoryTheory/Bicategory/Coherence.lean @@ -133,6 +133,25 @@ def normalizeIso {a : B} : | _, _, p, Hom.comp f g => (α_ _ _ _).symm ≪≫ whiskerRightIso (normalizeIso p f) g ≪≫ normalizeIso (normalizeAux p f) g +-- Equation lemmas for `normalizeIso`/`normalizeAux` matching `≫`/`𝟙` +-- (i.e., `CategoryStruct.comp`/`CategoryStruct.id` for `FreeBicategory`) instead of +-- `Hom.comp`/`Hom.id`. Needed because `canUnfoldAtMatcher` no longer unfolds class +-- projections in match discriminants. +@[simp] theorem normalizeAux_comp {a : B} {b c d : FreeBicategory B} + (p : Path a b) (f : b ⟶ c) (g : c ⟶ d) : + normalizeAux p (f ≫ g) = normalizeAux (normalizeAux p f) g := rfl +@[simp] theorem normalizeAux_id {a : B} {b : FreeBicategory B} (p : Path a b) : + normalizeAux p (𝟙 b) = p := rfl +@[simp] theorem normalizeIso_comp {a : B} {b c d : FreeBicategory B} + (p : Path a b) (f : b ⟶ c) (g : c ⟶ d) : + normalizeIso p (f ≫ g) = + (α_ _ _ _).symm ≪≫ whiskerRightIso (normalizeIso p f) g ≪≫ + normalizeIso (normalizeAux p f) g := rfl +@[simp] theorem normalizeIso_id {a : B} {b : FreeBicategory B} (p : Path a b) : + normalizeIso p (𝟙 b) = ρ_ _ := rfl +@[simp] theorem quot_whisker_left {a b c : FreeBicategory B} (f : a ⟶ b) {g h : b ⟶ c} + (η : Hom₂ g h) : Quot.mk Rel (Hom₂.whisker_left f η) = f ◁ (Quot.mk Rel η) := rfl + /-- Given a 2-morphism between `f` and `g` in the free bicategory, we have the equality `normalizeAux p f = normalizeAux p g`. -/ @@ -163,7 +182,8 @@ theorem normalize_naturality {a b c : B} (p : Path a b) {f g : Hom b c} (η : f simp -- p ≠ nil required! See the docstring of `normalizeAux`. | whisker_left _ _ ih => - dsimp + simp only [normalizeIso_comp, normalizeAux_comp, quot_whisker_left, + Iso.trans_hom, Iso.symm_hom, whiskerRightIso_hom] rw [associator_inv_naturality_right_assoc, whisker_exchange_assoc, ih] simp | whisker_right h η' ih => @@ -171,7 +191,10 @@ theorem normalize_naturality {a b c : B} (p : Path a b) {f g : Hom b c} (η : f rw [associator_inv_naturality_middle_assoc, ← comp_whiskerRight_assoc, ih, comp_whiskerRight] have := dcongr_arg (fun x => (normalizeIso x h).hom) (normalizeAux_congr p (Quot.mk _ η')) dsimp at this; simp [this] - | _ => simp + | _ => + simp only [normalizeIso_comp, normalizeIso_id, normalizeAux_comp, normalizeAux_id, + Iso.trans_hom, Iso.symm_hom, whiskerRightIso_hom] + simp -- Not `@[simp]` because it is not in `simp`-normal form. theorem normalizeAux_nil_comp {a b c : B} (f : Hom a b) (g : Hom b c) : diff --git a/Mathlib/CategoryTheory/Bicategory/Functor/LocallyDiscrete.lean b/Mathlib/CategoryTheory/Bicategory/Functor/LocallyDiscrete.lean index bd3385194354e8..64c99a93bb5ccc 100644 --- a/Mathlib/CategoryTheory/Bicategory/Functor/LocallyDiscrete.lean +++ b/Mathlib/CategoryTheory/Bicategory/Functor/LocallyDiscrete.lean @@ -114,7 +114,8 @@ corresponding locally discrete bicategories. def Functor.toPseudofunctor : LocallyDiscrete C ⥤ᵖ (LocallyDiscrete D) := pseudofunctorOfIsLocallyDiscrete (fun ⟨X⟩ ↦ .mk <| F.obj X) (fun ⟨f⟩ ↦ (F.map f).toLoc) - (fun ⟨X⟩ ↦ eqToIso (by simp)) (fun f g ↦ eqToIso (by simp)) + (fun ⟨X⟩ ↦ eqToIso (by simp [CategoryStruct.id])) + (fun ⟨f⟩ ⟨g⟩ ↦ eqToIso (by simp [CategoryStruct.comp])) @[deprecated (since := "2026-02-08")] alias Functor.toPseudoFunctor := Functor.toPseudofunctor @@ -145,7 +146,8 @@ be promoted to a pseudofunctor from `LocallyDiscrete I` to `B`. def Functor.toPseudofunctor' : LocallyDiscrete I ⥤ᵖ B := pseudofunctorOfIsLocallyDiscrete (fun ⟨X⟩ ↦ F.obj X) (fun ⟨f⟩ ↦ F.map f) - (fun ⟨X⟩ ↦ eqToIso (by simp)) (fun f g ↦ eqToIso (by simp)) + (fun ⟨X⟩ ↦ eqToIso (by simp [CategoryStruct.id])) + (fun f g ↦ eqToIso (by obtain ⟨f⟩ := f; obtain ⟨g⟩ := g; simp [CategoryStruct.comp])) @[deprecated (since := "2026-02-08")] alias Functor.toPseudoFunctor' := Functor.toPseudofunctor' diff --git a/Mathlib/CategoryTheory/ComposableArrows/Basic.lean b/Mathlib/CategoryTheory/ComposableArrows/Basic.lean index faeae0816484c6..1de7bb8fa31cac 100644 --- a/Mathlib/CategoryTheory/ComposableArrows/Basic.lean +++ b/Mathlib/CategoryTheory/ComposableArrows/Basic.lean @@ -230,6 +230,8 @@ lemma hom_ext₀ {F G : ComposableArrows C 0} {φ φ' : F ⟶ G} def isoMk₀ {F G : ComposableArrows C 0} (e : F.obj' 0 ≅ G.obj' 0) : F ≅ G where hom := homMk₀ e.hom inv := homMk₀ e.inv + hom_inv_id := by apply hom_ext₀; with_unfolding_all exact e.hom_inv_id + inv_hom_id := by apply hom_ext₀; with_unfolding_all exact e.inv_hom_id lemma isIso_iff₀ {F G : ComposableArrows C 0} (f : F ⟶ G) : IsIso f ↔ IsIso (f.app 0) := by @@ -275,6 +277,18 @@ def isoMk₁ {F G : ComposableArrows C 1} inv := homMk₁ left.inv right.inv (by rw [← cancel_mono right.hom, assoc, assoc, w, right.inv_hom_id, left.inv_hom_id_assoc] apply comp_id) + hom_inv_id := by + apply hom_ext₁ + · change left.hom ≫ left.inv = 𝟙 _ + simp + · change right.hom ≫ right.inv = 𝟙 _ + simp + inv_hom_id := by + apply hom_ext₁ + · change left.inv ≫ left.hom = 𝟙 _ + simp + · change right.inv ≫ right.hom = 𝟙 _ + simp lemma map'_eq_hom₁ (F : ComposableArrows C 1) : F.map' 0 1 = F.hom := rfl @@ -303,10 +317,12 @@ lemma mk₁_comp_eqToHom {X₀ X₁ X₁' : C} (f : X₀ ⟶ X₁) (h : X₁ = X ComposableArrows.mk₁ (f ≫ eqToHom h) = ComposableArrows.mk₁ f := by cat_disch +set_option backward.isDefEq.respectTransparency false in lemma mk₁_hom (X : ComposableArrows C 1) : mk₁ X.hom = X := ext₁ rfl rfl (by simp) +set_option backward.isDefEq.respectTransparency false in /-- The bijection between `ComposableArrows C 1` and `Arrow C`. -/ @[simps] def arrowEquiv : ComposableArrows C 1 ≃ Arrow C where @@ -436,21 +452,21 @@ variable {X₀ X₁ X₂ X₃ X₄ : C} (f : X₀ ⟶ X₁) (g : X₁ ⟶ X₂) /-! These examples are meant to test the good definitional properties of `precomp`, and that `dsimp` can see through. -/ -example : map' (mk₂ f g) 0 1 = f := by dsimp -example : map' (mk₂ f g) 1 2 = g := by dsimp -example : map' (mk₂ f g) 0 2 = f ≫ g := by dsimp -example : (mk₂ f g).hom = f ≫ g := by dsimp -example : map' (mk₂ f g) 0 0 = 𝟙 _ := by dsimp -example : map' (mk₂ f g) 1 1 = 𝟙 _ := by dsimp -example : map' (mk₂ f g) 2 2 = 𝟙 _ := by dsimp - -example : map' (mk₃ f g h) 0 1 = f := by dsimp -example : map' (mk₃ f g h) 1 2 = g := by dsimp -example : map' (mk₃ f g h) 2 3 = h := by dsimp -example : map' (mk₃ f g h) 0 3 = f ≫ g ≫ h := by dsimp -example : (mk₃ f g h).hom = f ≫ g ≫ h := by dsimp -example : map' (mk₃ f g h) 0 2 = f ≫ g := by dsimp -example : map' (mk₃ f g h) 1 3 = g ≫ h := by dsimp +example : map' (mk₂ f g) 0 1 = f := by with_unfolding_all rfl +example : map' (mk₂ f g) 1 2 = g := by with_unfolding_all rfl +example : map' (mk₂ f g) 0 2 = f ≫ g := by with_unfolding_all rfl +example : (mk₂ f g).hom = f ≫ g := by with_unfolding_all rfl +example : map' (mk₂ f g) 0 0 = 𝟙 _ := by with_unfolding_all rfl +example : map' (mk₂ f g) 1 1 = 𝟙 _ := by with_unfolding_all rfl +example : map' (mk₂ f g) 2 2 = 𝟙 _ := by with_unfolding_all rfl + +example : map' (mk₃ f g h) 0 1 = f := by with_unfolding_all rfl +example : map' (mk₃ f g h) 1 2 = g := by with_unfolding_all rfl +example : map' (mk₃ f g h) 2 3 = h := by with_unfolding_all rfl +example : map' (mk₃ f g h) 0 3 = f ≫ g ≫ h := by with_unfolding_all rfl +example : (mk₃ f g h).hom = f ≫ g ≫ h := by with_unfolding_all rfl +example : map' (mk₃ f g h) 0 2 = f ≫ g := by with_unfolding_all rfl +example : map' (mk₃ f g h) 1 3 = g ≫ h := by with_unfolding_all rfl end @@ -624,6 +640,8 @@ def isoMk₂ {f g : ComposableArrows C 2} comp_id, app₀.hom_inv_id_assoc]) (by rw [← cancel_epi app₁.hom, ← reassoc_of% w₁, app₂.hom_inv_id, comp_id, app₁.hom_inv_id_assoc]) + hom_inv_id := by apply hom_ext₂ <;> (with_unfolding_all dsimp; simp) + inv_hom_id := by apply hom_ext₂ <;> (with_unfolding_all dsimp; simp) lemma isIso_iff₂ {F G : ComposableArrows C 2} (f : F ⟶ G) : IsIso f ↔ IsIso (f.app 0) ∧ IsIso (f.app 1) ∧ IsIso (f.app 2) := by @@ -636,6 +654,7 @@ lemma ext₂ {f g : ComposableArrows C 2} (w₁ : f.map' 1 2 = eqToHom h₁ ≫ g.map' 1 2 ≫ eqToHom h₂.symm) : f = g := ext_succ h₀ (ext₁ h₁ h₂ w₁) w₀ +set_option backward.isDefEq.respectTransparency false in lemma mk₂_surjective (X : ComposableArrows C 2) : ∃ (X₀ X₁ X₂ : C) (f₀ : X₀ ⟶ X₁) (f₁ : X₁ ⟶ X₂), X = mk₂ f₀ f₁ := ⟨_, _, _, X.map' 0 1, X.map' 1 2, ext₂ rfl rfl rfl (by simp) (by simp)⟩ @@ -713,6 +732,7 @@ lemma ext₃ {f g : ComposableArrows C 3} (w₂ : f.map' 2 3 = eqToHom h₂ ≫ g.map' 2 3 ≫ eqToHom h₃.symm) : f = g := ext_succ h₀ (ext₂ h₁ h₂ h₃ w₁ w₂) w₀ +set_option backward.isDefEq.respectTransparency false in lemma mk₃_surjective (X : ComposableArrows C 3) : ∃ (X₀ X₁ X₂ X₃ : C) (f₀ : X₀ ⟶ X₁) (f₁ : X₁ ⟶ X₂) (f₂ : X₂ ⟶ X₃), X = mk₃ f₀ f₁ f₂ := ⟨_, _, _, _, X.map' 0 1, X.map' 1 2, X.map' 2 3, @@ -792,6 +812,7 @@ lemma ext₄ {f g : ComposableArrows C 4} f = g := ext_succ h₀ (ext₃ h₁ h₂ h₃ h₄ w₁ w₂ w₃) w₀ +set_option backward.isDefEq.respectTransparency false in lemma mk₄_surjective (X : ComposableArrows C 4) : ∃ (X₀ X₁ X₂ X₃ X₄ : C) (f₀ : X₀ ⟶ X₁) (f₁ : X₁ ⟶ X₂) (f₂ : X₂ ⟶ X₃) (f₃ : X₃ ⟶ X₄), X = mk₄ f₀ f₁ f₂ f₃ := @@ -874,6 +895,7 @@ lemma ext₅ {f g : ComposableArrows C 5} f = g := ext_succ h₀ (ext₄ h₁ h₂ h₃ h₄ h₅ w₁ w₂ w₃ w₄) w₀ +set_option backward.isDefEq.respectTransparency false in lemma mk₅_surjective (X : ComposableArrows C 5) : ∃ (X₀ X₁ X₂ X₃ X₄ X₅ : C) (f₀ : X₀ ⟶ X₁) (f₁ : X₁ ⟶ X₂) (f₂ : X₂ ⟶ X₃) (f₃ : X₃ ⟶ X₄) (f₄ : X₄ ⟶ X₅), X = mk₅ f₀ f₁ f₂ f₃ f₄ := @@ -950,6 +972,7 @@ def Functor.mapComposableArrows : ComposableArrows C n ⥤ ComposableArrows D n := (whiskeringRight _ _ _).obj G +set_option backward.isDefEq.respectTransparency false in /-- The isomorphism between `(G.mapComposableArrows 1).obj (.mk₁ f)` and `.mk₁ (G.map f)`. -/ @[simps!] @@ -957,6 +980,7 @@ def Functor.mapComposableArrowsObjMk₁Iso {X Y : C} (f : X ⟶ Y) : (G.mapComposableArrows 1).obj (.mk₁ f) ≅ .mk₁ (G.map f) := isoMk₁ (Iso.refl _) (Iso.refl _) +set_option backward.isDefEq.respectTransparency false in /-- The isomorphism between `(G.mapComposableArrows 2).obj (.mk₂ f g)` and `.mk₂ (G.map f) (G.map g)`. -/ @[simps!] diff --git a/Mathlib/CategoryTheory/ComposableArrows/One.lean b/Mathlib/CategoryTheory/ComposableArrows/One.lean index ec776f21ef10e1..32059e67a467d5 100644 --- a/Mathlib/CategoryTheory/ComposableArrows/One.lean +++ b/Mathlib/CategoryTheory/ComposableArrows/One.lean @@ -31,6 +31,7 @@ def functorArrows (i j n : ℕ) (hij : i ≤ j := by lia) (hj : j ≤ n := by li obj S := mk₁ (S.map' i j) map {S S'} φ := homMk₁ (φ.app _) (φ.app _) (φ.naturality _) +set_option backward.isDefEq.respectTransparency false in /-- The natural transformation `functorArrows C i j n ⟶ functorArrows C i' j' n` when `i ≤ i'` and `j ≤ j'`. -/ @[simps] @@ -40,7 +41,13 @@ def mapFunctorArrows (i j i' j' n : ℕ) (_ : j' ≤ n := by lia) : functorArrows C i j n ⟶ functorArrows C i' j' n where app S := homMk₁ (S.map' i i') (S.map' j j') - (by simp [← Functor.map_comp]) + (by change S.map' i j ≫ S.map' j j' = S.map' i i' ≫ S.map' i' j'; simp [← Functor.map_comp]) + naturality {X Y} f := by + apply hom_ext₁ + · change f.app ⟨i, _⟩ ≫ Y.map' i i' = X.map' i i' ≫ f.app ⟨i', _⟩ + simp [← NatTrans.naturality] + · change f.app ⟨j, _⟩ ≫ Y.map' j j' = X.map' j j' ≫ f.app ⟨j', _⟩ + simp [← NatTrans.naturality] end ComposableArrows diff --git a/Mathlib/CategoryTheory/ComposableArrows/Three.lean b/Mathlib/CategoryTheory/ComposableArrows/Three.lean index 8a16c3bc3de166..22122c2124f276 100644 --- a/Mathlib/CategoryTheory/ComposableArrows/Three.lean +++ b/Mathlib/CategoryTheory/ComposableArrows/Three.lean @@ -35,6 +35,7 @@ variable {C : Type u} [Category.{v} C] {i j k l : C} (f₁ : i ⟶ j) (f₂ : j ⟶ k) (f₃ : k ⟶ l) (f₁₂ : i ⟶ k) (f₂₃ : j ⟶ l) +set_option backward.isDefEq.respectTransparency false in /-- The morphism `mk₂ f₁ f₂ ⟶ mk₂ f₁ f₂₃` when `f₂ ≫ f₃ = f₂₃`. -/ def threeδ₃Toδ₂ (h₂₃ : f₂ ≫ f₃ = f₂₃ := by cat_disch) : mk₂ f₁ f₂ ⟶ mk₂ f₁ f₂₃ := diff --git a/Mathlib/CategoryTheory/ComposableArrows/Two.lean b/Mathlib/CategoryTheory/ComposableArrows/Two.lean index 698a59be84e46d..7fc2379f5d5581 100644 --- a/Mathlib/CategoryTheory/ComposableArrows/Two.lean +++ b/Mathlib/CategoryTheory/ComposableArrows/Two.lean @@ -31,11 +31,13 @@ section variable {C : Type*} [Category* C] {i j k : C} (f : i ⟶ j) (g : j ⟶ k) (fg : i ⟶ k) +set_option backward.isDefEq.respectTransparency false in /-- The morphism `mk₁ f ⟶ mk₁ fg` when `f ≫ g = fg` for some morphism `g`. -/ def twoδ₂Toδ₁ (h : f ≫ g = fg := by cat_disch) : mk₁ f ⟶ mk₁ fg := homMk₁ (𝟙 _) g +set_option backward.isDefEq.respectTransparency false in /-- The morphism `mk₁ fg ⟶ mk₁ g` when `f ≫ g = fg` for some morphism `f`. -/ def twoδ₁Toδ₀ (h : f ≫ g = fg := by cat_disch) : mk₁ fg ⟶ mk₁ g := @@ -45,27 +47,29 @@ variable (h : f ≫ g = fg) @[simp] lemma twoδ₂Toδ₁_app_zero : - (twoδ₂Toδ₁ f g fg h).app 0 = 𝟙 _ := rfl + (twoδ₂Toδ₁ f g fg h).app 0 = 𝟙 _ := by with_unfolding_all rfl @[simp] lemma twoδ₂Toδ₁_app_one : - (twoδ₂Toδ₁ f g fg h).app 1 = g := rfl + (twoδ₂Toδ₁ f g fg h).app 1 = g := by with_unfolding_all rfl @[simp] lemma twoδ₁Toδ₀_app_zero : - (twoδ₁Toδ₀ f g fg h).app 0 = f := rfl + (twoδ₁Toδ₀ f g fg h).app 0 = f := by with_unfolding_all rfl @[simp] lemma twoδ₁Toδ₀_app_one : - (twoδ₁Toδ₀ f g fg h).app 1 = 𝟙 _ := rfl + (twoδ₁Toδ₀ f g fg h).app 1 = 𝟙 _ := by with_unfolding_all rfl +set_option backward.isDefEq.respectTransparency false in instance [IsIso g] : IsIso (twoδ₂Toδ₁ f g fg h) := by - rw [isIso_iff₁] - constructor <;> dsimp <;> infer_instance + rw [isIso_iff₁, twoδ₂Toδ₁_app_zero, twoδ₂Toδ₁_app_one] + exact ⟨inferInstance, ‹_›⟩ +set_option backward.isDefEq.respectTransparency false in instance [IsIso f] : IsIso (twoδ₁Toδ₀ f g fg h) := by - rw [isIso_iff₁] - constructor <;> dsimp <;> infer_instance + rw [isIso_iff₁, twoδ₁Toδ₀_app_zero, twoδ₁Toδ₀_app_one] + exact ⟨‹_›, inferInstance⟩ end diff --git a/Mathlib/CategoryTheory/Limits/Shapes/Equalizers.lean b/Mathlib/CategoryTheory/Limits/Shapes/Equalizers.lean index 42fb69b209c099..fb855ffc12155f 100644 --- a/Mathlib/CategoryTheory/Limits/Shapes/Equalizers.lean +++ b/Mathlib/CategoryTheory/Limits/Shapes/Equalizers.lean @@ -227,7 +227,9 @@ def parallelPair (f g : X ⟶ Y) : WalkingParallelPair ⥤ C where | right => g -- `sorry` can cope with this, but it's too slow: map_comp := by - rintro _ _ _ ⟨⟩ g <;> cases g <;> simp + rintro _ _ _ ⟨⟩ g <;> cases g <;> + dsimp only [CategoryStruct.comp, CategoryStruct.id, WalkingParallelPairHom.comp] <;> + first | rfl | simp @[simp] theorem parallelPair_obj_zero (f g : X ⟶ Y) : (parallelPair f g).obj zero = X := rfl diff --git a/Mathlib/CategoryTheory/Limits/Shapes/Multiequalizer.lean b/Mathlib/CategoryTheory/Limits/Shapes/Multiequalizer.lean index 6eab05ecb90c7b..7906be4f02c84b 100644 --- a/Mathlib/CategoryTheory/Limits/Shapes/Multiequalizer.lean +++ b/Mathlib/CategoryTheory/Limits/Shapes/Multiequalizer.lean @@ -541,7 +541,9 @@ def ofι {J : MulticospanShape.{w, w'}} (I : MulticospanIndex J C) | WalkingMulticospan.right b => ι (J.fst b) ≫ I.fst b naturality := by rintro (_ | _) (_ | _) (_ | _ | _) <;> - dsimp <;> simp only [Category.id_comp, Category.comp_id] + simp only [WalkingMulticospan.Hom.id_eq_id, + Functor.map_id, Functor.const_obj_map, Category.comp_id] <;> + dsimp <;> simp only [Category.id_comp] apply w } @[simp] @@ -659,10 +661,18 @@ def ofPiFork | WalkingMulticospan.right _ => a.ι ≫ I.fstPiMapOfIsLimit c hd ≫ d.proj _ π.naturality := by rintro (_ | _) (_ | _) (_ | _ | _) - · simp - · simp + -- left.left.id + · simp only [WalkingMulticospan.Hom.id_eq_id, Functor.map_id, + Functor.const_obj_map, Category.comp_id] + exact Category.id_comp _ + -- left.right.fst + · dsimp; simp [MulticospanIndex.fstPiMapOfIsLimit_proj] + -- left.right.snd · dsimp; rw [a.condition_assoc]; simp - · simp + -- right.right.id + · simp only [WalkingMulticospan.Hom.id_eq_id, Functor.map_id, + Functor.const_obj_map, Category.comp_id] + exact Category.id_comp _ @[simp] theorem ofPiFork_ι (a : Fork (I.fstPiMapOfIsLimit c hd) (I.sndPiMapOfIsLimit c hd)) (i) : diff --git a/Mathlib/CategoryTheory/Monoidal/Free/Coherence.lean b/Mathlib/CategoryTheory/Monoidal/Free/Coherence.lean index 264d9b44912b90..065c4cffb89189 100644 --- a/Mathlib/CategoryTheory/Monoidal/Free/Coherence.lean +++ b/Mathlib/CategoryTheory/Monoidal/Free/Coherence.lean @@ -193,6 +193,15 @@ def normalizeIsoApp' : | tensor X Y, n => (α_ _ _ _).symm ≪≫ whiskerRightIso (normalizeIsoApp' X n) Y ≪≫ normalizeIsoApp' _ _ +-- Equation lemmas for `normalizeIsoApp'` matching `⊗`/`𝟙_` instead of `tensor`/`unit`. +-- Needed because `canUnfoldAtMatcher` no longer unfolds class projections in match discriminants. +@[simp] theorem normalizeIsoApp'_tensor (X Y : F C) (n : NormalMonoidalObject C) : + normalizeIsoApp' C (X ⊗ Y) n = + (α_ _ _ _).symm ≪≫ whiskerRightIso (normalizeIsoApp' C X n) Y ≪≫ + normalizeIsoApp' C Y _ := rfl +@[simp] theorem normalizeIsoApp'_unit (n : NormalMonoidalObject C) : + normalizeIsoApp' C (𝟙_ (F C)) n = ρ_ _ := rfl + theorem normalizeIsoApp_eq : ∀ (X : F C) (n : N C), normalizeIsoApp C X n = normalizeIsoApp' C X n.as | of _, _ => rfl @@ -252,18 +261,18 @@ theorem normalize_naturality (n : NormalMonoidalObject C) {X Y : F C} (f : X ⟶ case comp f g ihf ihg => simp [ihg, reassoc_of% (ihf _)] case whiskerLeft X' X Y f ih => intro n - dsimp only [normalizeObj_tensor, normalizeIsoApp', tensor_eq_tensor, Iso.trans_hom, + simp only [normalizeObj_tensor, normalizeIsoApp'_tensor, Iso.trans_hom, Iso.symm_hom, whiskerRightIso_hom, Function.comp_apply, inclusion_obj] rw [associator_inv_naturality_right_assoc, whisker_exchange_assoc, ih] simp case whiskerRight X Y h η' ih => intro n - dsimp only [normalizeObj_tensor, normalizeIsoApp', tensor_eq_tensor, Iso.trans_hom, + simp only [normalizeObj_tensor, normalizeIsoApp'_tensor, Iso.trans_hom, Iso.symm_hom, whiskerRightIso_hom, Function.comp_apply, inclusion_obj] rw [associator_inv_naturality_middle_assoc, ← comp_whiskerRight_assoc, ih] have := dcongr_arg (fun x => (normalizeIsoApp' C η' x).hom) (normalizeObj_congr n h) simp [this] - all_goals simp + all_goals simp [normalizeIsoApp'_tensor, normalizeIsoApp'_unit] end diff --git a/Mathlib/CategoryTheory/Sites/DenseSubsite/OneHypercoverDense.lean b/Mathlib/CategoryTheory/Sites/DenseSubsite/OneHypercoverDense.lean index f8304807efa444..0d8a00a6f814a9 100644 --- a/Mathlib/CategoryTheory/Sites/DenseSubsite/OneHypercoverDense.lean +++ b/Mathlib/CategoryTheory/Sites/DenseSubsite/OneHypercoverDense.lean @@ -106,8 +106,11 @@ def multicospanMap {P Q : C₀ᵒᵖ ⥤ A} (f : P ⟶ Q) : | WalkingMulticospan.left i => f.app _ | WalkingMulticospan.right j => f.app _ naturality := by - rintro (i₁ | j₁) (i₂ | j₂) (_ | _) - all_goals simp + rintro (i₁ | j₁) (i₂ | j₂) (_ | _) <;> + simp only [multicospanIndex, + MulticospanIndex.multicospan, + Category.id_comp, Category.comp_id, + f.naturality] /-- The natural isomorphism between the diagrams attached to `data : F.PreOneHypercoverDenseData X` that are induced by isomorphisms in `C₀ᵒᵖ ⥤ A`. -/ diff --git a/Mathlib/CategoryTheory/Sites/Hypercover/One.lean b/Mathlib/CategoryTheory/Sites/Hypercover/One.lean index b8c287e46da5ef..45b018cc96f8bb 100644 --- a/Mathlib/CategoryTheory/Sites/Hypercover/One.lean +++ b/Mathlib/CategoryTheory/Sites/Hypercover/One.lean @@ -748,11 +748,15 @@ def Hom.mapMulticospan {E : PreOneHypercover.{w} S} {F : PreOneHypercover.{w'} S | .id _ => .id _ | .fst i => WalkingMulticospan.Hom.fst (J := F.multicospanShape) (f.s₁' i) | .snd i => WalkingMulticospan.Hom.snd (J := F.multicospanShape) (f.s₁' i) - map_id := by simp + map_id + | .left _ => rfl + | .right _ => rfl map_comp - | .id _, _ => by simp - | .fst _, .id _ => by simp - | .snd _, .id _ => by simp + | .id _, _ => by simp only [WalkingMulticospan.Hom.id_eq_id, Category.id_comp] + | .fst _, .id _ => by + simp only [WalkingMulticospan.Hom.id_eq_id, Category.comp_id] + | .snd _, .id _ => by + simp only [WalkingMulticospan.Hom.id_eq_id, Category.comp_id] set_option backward.isDefEq.respectTransparency false in /-- Isomorphic pre-`1`-hypercovers have equivalent multifork index categories. -/ diff --git a/Mathlib/CategoryTheory/Sites/Whiskering.lean b/Mathlib/CategoryTheory/Sites/Whiskering.lean index 83b51123e28606..53f3a3b072250b 100644 --- a/Mathlib/CategoryTheory/Sites/Whiskering.lean +++ b/Mathlib/CategoryTheory/Sites/Whiskering.lean @@ -116,8 +116,10 @@ def multicospanComp : (S.index (P ⋙ F)).multicospan ≅ (S.index P).multicospa | WalkingMulticospan.left _ => Iso.refl _ | WalkingMulticospan.right _ => Iso.refl _) (by - rintro (a | b) (a | b) (f | f | f) - all_goals cat_disch) + rintro (a | b) (a | b) (f | f | f) <;> + simp only [WalkingMulticospan.Hom.id_eq_id, Iso.refl_hom, Category.id_comp, + Category.comp_id, Functor.map_id] <;> + dsimp [CategoryStruct.comp] <;> simp) /-- Mapping the multifork associated to a cover `S : J.Cover X` and a presheaf `P` with respect to a functor `F` is isomorphic (upto a natural isomorphism of the underlying functors) diff --git a/Mathlib/Computability/RegularExpressions.lean b/Mathlib/Computability/RegularExpressions.lean index f1f698c89062b7..dd7036974a93e9 100644 --- a/Mathlib/Computability/RegularExpressions.lean +++ b/Mathlib/Computability/RegularExpressions.lean @@ -137,6 +137,13 @@ def matchEpsilon : RegularExpression α → Bool | P * Q => P.matchEpsilon && Q.matchEpsilon | star _P => true +@[simp] +theorem matchEpsilon_zero : matchEpsilon (0 : RegularExpression α) = false := by + change matchEpsilon zero = false; rfl + +theorem matchEpsilon_one : matchEpsilon (1 : RegularExpression α) = true := by + change matchEpsilon epsilon = true; rfl + section DecidableEq variable [DecidableEq α] @@ -182,10 +189,10 @@ def rmatch : RegularExpression α → List α → Bool @[simp] theorem zero_rmatch (x : List α) : rmatch 0 x = false := by - induction x <;> simp [rmatch, matchEpsilon, *] + induction x <;> simp [rmatch, matchEpsilon_zero, *] theorem one_rmatch_iff (x : List α) : rmatch 1 x ↔ x = [] := by - induction x <;> simp [rmatch, matchEpsilon, *] + induction x <;> simp [rmatch, matchEpsilon_one, *] theorem char_rmatch_iff (a : α) (x : List α) : rmatch (char a) x ↔ x = [a] := by rcases x with - | ⟨_, x⟩ diff --git a/Mathlib/Computability/TuringMachine/ToPartrec.lean b/Mathlib/Computability/TuringMachine/ToPartrec.lean index 7ac1eb9c5932a7..5440109fbb4d7a 100644 --- a/Mathlib/Computability/TuringMachine/ToPartrec.lean +++ b/Mathlib/Computability/TuringMachine/ToPartrec.lean @@ -789,7 +789,8 @@ theorem pred_ok (q₁ q₂ s v) (c d : List Γ') : ∃ s', simp only [trList, trNat.eq_1, trNum, Nat.cast_succ, Num.add_one, Num.succ, List.tail_cons, List.headI_cons] rcases (n : Num) with - | a - · simp only [trPosNum, Num.succ', List.singleton_append, List.nil_append] + · simp only [show (1 : PosNum) = PosNum.one from rfl, + trPosNum, Num.succ', List.singleton_append, List.nil_append] refine TransGen.head rfl ?_ rw [tr]; simp only [pop', TM2.stepAux] convert unrev_ok using 2 diff --git a/Mathlib/Data/List/Permutation.lean b/Mathlib/Data/List/Permutation.lean index 324cfbf78b5b3f..fd384a7bbab131 100644 --- a/Mathlib/Data/List/Permutation.lean +++ b/Mathlib/Data/List/Permutation.lean @@ -278,7 +278,7 @@ theorem length_permutationsAux : refine permutationsAux.rec (by simp) ?_ intro t ts is IH1 IH2 have IH2 : length (permutationsAux is nil) + 1 = is.length ! := by simpa using IH2 - simp only [factorial, Nat.mul_comm, add_eq] at IH1 + simp only [List.length_cons, factorial, Nat.mul_comm, add_eq] at IH1 rw [permutationsAux_cons, length_foldr_permutationsAux2' _ _ _ _ _ fun l m => (perm_of_mem_permutations m).length_eq, permutations, length, length, IH2, Nat.succ_add, Nat.factorial_succ, Nat.mul_comm (_ + 1), diff --git a/Mathlib/Data/Nat/Bitwise.lean b/Mathlib/Data/Nat/Bitwise.lean index 6d984e98f7c0d7..06d2fef267ecb8 100644 --- a/Mathlib/Data/Nat/Bitwise.lean +++ b/Mathlib/Data/Nat/Bitwise.lean @@ -356,17 +356,22 @@ theorem xor_range (n : ℕ) : (List.range (n + 1)).foldl (· ^^^ ·) 0 = rw [List.range_succ, List.foldl_append, ih, ← Fin.ofNat_add, List.foldl_cons, List.foldl_nil] match h : Fin.ofNat 4 n with | 0 => - rw [Fin.zero_add, ← xor_one_of_even <| even_iff.mpr ?_, xor_xor_cancel_left] + rw [Fin.zero_add] + simp only [OfNat.ofNat] + rw [← xor_one_of_even <| even_iff.mpr ?_, xor_xor_cancel_left] rw [← @mod_mod_of_dvd _ 4 _ <| by simp, ← Fin.val_ofNat 4, h] rfl | 1 => + simp only [OfNat.ofNat, Fin.ofNat, Nat.reduceMod, Fin.add_def] rw [Nat.xor_comm] refine xor_one_of_even <| even_iff.mpr ?_ rw [add_mod, ← @mod_mod_of_dvd _ 4 n <| by simp, ← Fin.val_ofNat 4, h] rfl | 2 => + simp only [OfNat.ofNat, Fin.ofNat, Nat.reduceMod, Fin.add_def] apply Nat.xor_self | 3 => + simp only [OfNat.ofNat, Fin.ofNat, Nat.reduceMod, Fin.add_def] apply zero_xor lemma shiftLeft_lt {x n m : ℕ} (h : x < 2 ^ n) : x <<< m < 2 ^ (n + m) := by diff --git a/Mathlib/Data/Num/Lemmas.lean b/Mathlib/Data/Num/Lemmas.lean index e509b2f4ebf402..899b09807a44c4 100644 --- a/Mathlib/Data/Num/Lemmas.lean +++ b/Mathlib/Data/Num/Lemmas.lean @@ -210,7 +210,7 @@ theorem ofNat'_bit (b n) : ofNat' (Nat.bit b n) = cond b Num.bit1 Num.bit0 (ofNa Nat.binaryRec_eq _ _ (.inl rfl) @[simp] -theorem ofNat'_one : Num.ofNat' 1 = 1 := by simp [Num.ofNat', Num.bit1] +theorem ofNat'_one : Num.ofNat' 1 = 1 := by decide theorem bit1_succ : ∀ n : Num, n.bit1.succ = n.succ.bit0 | 0 => rfl diff --git a/Mathlib/Data/Num/ZNum.lean b/Mathlib/Data/Num/ZNum.lean index 1b72fb0c3fea1d..d80dc8453d95c2 100644 --- a/Mathlib/Data/Num/ZNum.lean +++ b/Mathlib/Data/Num/ZNum.lean @@ -110,7 +110,7 @@ theorem cast_bit0 [AddGroupWithOne α] : ∀ n : ZNum, (n.bit0 : α) = (n : α) @[simp, norm_cast] theorem cast_bit1 [AddGroupWithOne α] : ∀ n : ZNum, (n.bit1 : α) = ((n : α) + n) + 1 - | 0 => by simp [ZNum.bit1] + | 0 => by change ((ZNum.zero).bit1 : α) = _; simp [ZNum.bit1] | pos p => by rw [ZNum.bit1, cast_pos, cast_pos]; rfl | neg p => by rw [ZNum.bit1, cast_neg, cast_neg] @@ -312,9 +312,7 @@ theorem ofInt'_neg : ∀ n : ℤ, ofInt' (-n) = -ofInt' n | (n + 1 : ℕ) => show Num.toZNumNeg _ = -Num.toZNum _ by rw [Num.zneg_toZNum] theorem of_to_int' : ∀ n : ZNum, ZNum.ofInt' n = n - | 0 => by - dsimp [ofInt', cast_zero] - simp only [Num.ofNat'_zero, Num.toZNum] + | 0 => rfl | pos a => by rw [cast_pos, ← PosNum.cast_to_nat, ← Num.ofInt'_toZNum, PosNum.of_to_nat]; rfl | neg a => by rw [cast_neg, ofInt'_neg, ← PosNum.cast_to_nat, ← Num.ofInt'_toZNum, PosNum.of_to_nat]; rfl @@ -575,7 +573,7 @@ protected theorem div_zero (n : Num) : n / 0 = 0 := show n.div 0 = 0 by cases n · rfl - · simp [Num.div] + · change (Num.pos _).div Num.zero = 0; simp [Num.div] @[simp, norm_cast] theorem div_to_nat : ∀ n d, ((n / d : Num) : ℕ) = n / d @@ -589,7 +587,7 @@ protected theorem mod_zero (n : Num) : n % 0 = n := show n.mod 0 = n by cases n · rfl - · simp [Num.mod] + · change (Num.pos _).mod Num.zero = Num.pos _; simp [Num.mod] @[simp, norm_cast] theorem mod_to_nat : ∀ n d, ((n % d : Num) : ℕ) = n % d diff --git a/Mathlib/Data/Sign/Defs.lean b/Mathlib/Data/Sign/Defs.lean index dd542a5dbcf3f1..dfb28da0cb85e9 100644 --- a/Mathlib/Data/Sign/Defs.lean +++ b/Mathlib/Data/Sign/Defs.lean @@ -130,9 +130,9 @@ def fin3Equiv : SignType ≃* Fin 3 where left_inv a := by cases a <;> rfl right_inv a := match a with - | ⟨0, _⟩ => by simp - | ⟨1, _⟩ => by simp - | ⟨2, _⟩ => by simp + | ⟨0, _⟩ => by decide +revert + | ⟨1, _⟩ => by decide +revert + | ⟨2, _⟩ => by decide +revert map_mul' a b := by cases a <;> cases b <;> rfl diff --git a/Mathlib/Dynamics/Ergodic/Action/OfMinimal.lean b/Mathlib/Dynamics/Ergodic/Action/OfMinimal.lean index cf3de1bd7c6146..dfe13fa75c649a 100644 --- a/Mathlib/Dynamics/Ergodic/Action/OfMinimal.lean +++ b/Mathlib/Dynamics/Ergodic/Action/OfMinimal.lean @@ -162,7 +162,7 @@ theorem DenseRange.zpow_of_ergodic_mul_left [OpensMeasurableSpace G] ∃ V : Set G, 1 ∈ V ∧ IsOpen V ∧ ∀ x ∈ V, ∀ y ∈ V, ∀ m : ℤ, g ^ m ≠ a * x / y := by rw [← mem_compl_iff, ← interior_compl, mem_interior_iff_mem_nhds] at h have : Tendsto (fun (x, y) ↦ a * x / y) (𝓝 1) (𝓝 a) := - Continuous.tendsto' (by fun_prop) _ _ (by simp) + Continuous.tendsto' (by fun_prop) _ _ (by simp [One.one]) rw [nhds_prod_eq] at this simpa [(nhds_basis_opens (1 : G)).prod_self.mem_iff, prod_subset_iff, and_assoc] using this h set s := ⋃ m : ℤ, g ^ m • V diff --git a/Mathlib/ModelTheory/Semantics.lean b/Mathlib/ModelTheory/Semantics.lean index bb1ec0f9e3e375..36f5a3fceb96e5 100644 --- a/Mathlib/ModelTheory/Semantics.lean +++ b/Mathlib/ModelTheory/Semantics.lean @@ -272,7 +272,7 @@ theorem realize_top : (⊤ : L.BoundedFormula α l).Realize v xs ↔ True := by @[simp] theorem realize_inf : (φ ⊓ ψ).Realize v xs ↔ φ.Realize v xs ∧ ψ.Realize v xs := by - simp [Realize] + simp [Realize, Min.min] @[simp] theorem realize_foldr_inf (l : List (L.BoundedFormula α n)) (v : α → M) (xs : Fin n → M) : diff --git a/Mathlib/NumberTheory/Zsqrtd/Basic.lean b/Mathlib/NumberTheory/Zsqrtd/Basic.lean index 25a68986289d3b..438b621e676dfe 100644 --- a/Mathlib/NumberTheory/Zsqrtd/Basic.lean +++ b/Mathlib/NumberTheory/Zsqrtd/Basic.lean @@ -639,10 +639,22 @@ open Int in theorem le_arch (a : ℤ√d) : ∃ n : ℕ, a ≤ n := by obtain ⟨x, y, (h : a ≤ ⟨x, y⟩)⟩ : ∃ x y : ℕ, Nonneg (⟨x, y⟩ + -a) := match -a with - | ⟨Int.ofNat x, Int.ofNat y⟩ => ⟨0, 0, by trivial⟩ - | ⟨Int.ofNat x, -[y+1]⟩ => ⟨0, y + 1, by simp [Int.negSucc_eq, add_assoc, Nonneg, Nonnegg]⟩ - | ⟨-[x+1], Int.ofNat y⟩ => ⟨x + 1, 0, by simp [Int.negSucc_eq, add_assoc, Nonneg, Nonnegg]⟩ - | ⟨-[x+1], -[y+1]⟩ => ⟨x + 1, y + 1, by simp [Int.negSucc_eq, add_assoc, Nonneg, Nonnegg]⟩ + | ⟨Int.ofNat x, Int.ofNat y⟩ => ⟨0, 0, by + change Nonneg ⟨_, _⟩; simp [Nonneg, Nonnegg]⟩ + | ⟨Int.ofNat x, -[y+1]⟩ => ⟨0, y + 1, by + simp only [Nonneg, Nonnegg, Nat.cast_zero, ofNat_eq_natCast, zero_add, + Nat.cast_add, Nat.cast_one, negSucc_eq, neg_add_rev, reduceNeg, + add_assoc, add_neg_cancel_left, add_neg_cancel] + trivial⟩ + | ⟨-[x+1], Int.ofNat y⟩ => ⟨x + 1, 0, by + simp only [Nonneg, Nonnegg, Nat.cast_add, Nat.cast_one, negSucc_eq, + neg_add_rev, reduceNeg, add_assoc, add_neg_cancel_left, add_neg_cancel, + Nat.cast_zero, ofNat_eq_natCast, zero_add] + trivial⟩ + | ⟨-[x+1], -[y+1]⟩ => ⟨x + 1, y + 1, by + simp only [Nonneg, Nonnegg, Nat.cast_add, Nat.cast_one, negSucc_eq, + neg_add_rev, reduceNeg, add_assoc, add_neg_cancel_left, add_neg_cancel] + trivial⟩ refine ⟨x + d * y, h.trans ?_⟩ change Nonneg ⟨↑x + d * y - ↑x, 0 - ↑y⟩ rcases y with - | y diff --git a/Mathlib/RingTheory/UniqueFactorizationDomain/FactorSet.lean b/Mathlib/RingTheory/UniqueFactorizationDomain/FactorSet.lean index 930937a54a7d5b..d2915658b18e7b 100644 --- a/Mathlib/RingTheory/UniqueFactorizationDomain/FactorSet.lean +++ b/Mathlib/RingTheory/UniqueFactorizationDomain/FactorSet.lean @@ -122,7 +122,9 @@ theorem count_some (hp : Irreducible p) (s : Multiset _) : @[simp] theorem count_zero (hp : Irreducible p) : count p (0 : FactorSet α) = 0 := by - simp only [count, dif_pos hp, bcount, Multiset.count_zero] + simp only [count, dif_pos hp, bcount] + change Multiset.count _ 0 = 0 + simp only [Multiset.count_zero] theorem count_reducible (hp : ¬Irreducible p) : count p = 0 := dif_neg hp diff --git a/Mathlib/RingTheory/Valuation/ValuativeRel/Basic.lean b/Mathlib/RingTheory/Valuation/ValuativeRel/Basic.lean index 162e0f42544bc5..0d4050e3116d44 100644 --- a/Mathlib/RingTheory/Valuation/ValuativeRel/Basic.lean +++ b/Mathlib/RingTheory/Valuation/ValuativeRel/Basic.lean @@ -1317,7 +1317,7 @@ variable (A B) in def mapPosSubmonoid : posSubmonoid A →* posSubmonoid B where toFun := fun ⟨a,ha⟩ => ⟨algebraMap _ _ a, by simpa only [posSubmonoid_def, ← (algebraMap A B).map_zero, vlt_iff_vlt] using ha⟩ - map_one' := by simp + map_one' := by simp [One.one] map_mul' := by simp variable (A) in diff --git a/Mathlib/SetTheory/Ordinal/Notation.lean b/Mathlib/SetTheory/Ordinal/Notation.lean index 1db13c525f0771..3387a58a2c0926 100644 --- a/Mathlib/SetTheory/Ordinal/Notation.lean +++ b/Mathlib/SetTheory/Ordinal/Notation.lean @@ -54,6 +54,9 @@ instance : Zero ONote := theorem zero_def : zero = 0 := rfl +-- With matchwhnf changes, Zero.zero doesn't unfold in match discriminants. +theorem zero_zero_eq : (Zero.zero : ONote) = zero := rfl + instance : Inhabited ONote := ⟨0⟩ @@ -61,6 +64,8 @@ instance : Inhabited ONote := instance : One ONote := ⟨oadd 0 1 0⟩ +theorem one_one_eq : (One.one : ONote) = oadd 0 1 0 := rfl + /-- Notation for ω -/ def omega : ONote := oadd 1 1 0 @@ -70,6 +75,7 @@ noncomputable def repr : ONote → Ordinal.{0} | 0 => 0 | oadd e n a => ω ^ repr e * n + repr a @[simp] theorem repr_zero : repr 0 = 0 := rfl +@[simp] theorem repr_zero' : repr zero = 0 := rfl attribute [simp] repr.eq_1 repr.eq_2 set_option backward.privateInPublic true in @@ -134,6 +140,11 @@ instance : WellFoundedRelation ONote := instance (priority := low) nat (n : ℕ) : OfNat ONote n where ofNat := ofNat n +-- Unfold the OfNat class projection for ONote to the concrete `ofNat` function. +-- Needed because class projections no longer unfold in match discriminants. +theorem ofNat_unfold (n : ℕ) : @OfNat.ofNat ONote n (nat n) = ofNat n := rfl + + @[simp 1200] theorem ofNat_one : ofNat 1 = 1 := rfl @[simp] theorem repr_ofNat (n : ℕ) : repr (ofNat n) = n := by cases n <;> simp @@ -431,15 +442,16 @@ theorem repr_add : ∀ (o₁ o₂) [NF o₁] [NF o₂], repr (o₁ + o₂) = rep conv at nf => simp [HAdd.hAdd, Add.add] conv in _ + o => simp [HAdd.hAdd, Add.add] rcases h : add a o with - | ⟨e', n', a'⟩ <;> - simp only [add, addAux, h'.symm, h, add_assoc, repr] at nf h₁ ⊢ + simp only [add, addAux, h'.symm, h, add_assoc, repr, repr_zero] at nf h₁ ⊢ have := h₁.fst; haveI := nf.fst; have ee := cmp_compares e e' cases he : cmp e e' <;> simp only [he, Ordering.compares_gt, Ordering.compares_lt, Ordering.compares_eq, repr, gt_iff_lt, PNat.add_coe, Nat.cast_add] at ee ⊢ · rw [← add_assoc, @add_of_omega0_opow_le _ (repr e') (ω ^ repr e' * (n' : ℕ))] · have := (h₁.below_of_lt ee).repr_lt - unfold repr at this - cases he' : e' <;> simp only [he', zero_def, opow_zero, repr, gt_iff_lt] at this ⊢ <;> - exact lt_of_le_of_lt le_self_add this + simp only [repr] at this + cases he' : e' <;> + simp only [he', zero_def, opow_zero, repr, repr_zero, gt_iff_lt] at this ⊢ <;> + exact lt_of_le_of_lt le_self_add this · simpa using (mul_le_mul_iff_right₀ <| opow_pos (repr e') omega0_pos).2 (Nat.cast_le.2 n'.pos) · rw [ee, ← add_assoc, ← mul_add] @@ -555,8 +567,9 @@ theorem repr_mul : ∀ (o₁ o₂) [NF o₁] [NF o₂], repr (o₁ * o₂) = rep simpa using (mul_le_mul_iff_right₀ <| opow_pos _ omega0_pos).2 (Nat.cast_le.2 n₁.2) by_cases e0 : e₂ = 0 · obtain ⟨x, xe⟩ := Nat.exists_eq_succ_of_ne_zero n₂.ne_zero - simp only [Mul.mul, mul, e0, ↓reduceIte, repr, PNat.mul_coe, natCast_mul, opow_zero, one_mul] - simp only [xe, h₂.zero_of_zero e0, repr, add_zero] + simp only [Mul.mul, mul, e0, ↓reduceIte, repr, repr_zero, PNat.mul_coe, natCast_mul, + opow_zero, one_mul] + simp only [xe, h₂.zero_of_zero e0, repr_zero, add_zero] rw [natCast_succ x, add_mul_succ _ ao, mul_assoc] · simp only [repr] haveI := h₁.fst @@ -696,7 +709,8 @@ instance nf_scale (x) [NF x] (o) [NF o] : NF (scale x o) := by @[simp] theorem repr_scale (x) [NF x] (o) [NF o] : repr (scale x o) = ω ^ repr x * repr o := by - simp only [scale_eq_mul, repr_mul, repr, PNat.one_coe, Nat.cast_one, mul_one, add_zero] + simp only [scale_eq_mul, repr_mul, repr, repr_zero, PNat.one_coe, Nat.cast_one, mul_one, + add_zero] theorem nf_repr_split {o o' m} [NF o] (h : split o = (o', m)) : NF o' ∧ repr o = repr o' + m := by rcases e : split' o with ⟨a, n⟩ @@ -743,11 +757,19 @@ instance nf_opow (o₁ o₂) [NF o₁] [NF o₂] : NF (o₁ ^ o₂) := by haveI := (nf_repr_split' e₂).1 obtain - | ⟨a0, n, a'⟩ := a · rcases m with - | m - · by_cases o₂ = 0 <;> simp only [(· ^ ·), Pow.pow, opow, opowAux2, *] <;> decide - · by_cases m = 0 - · simp only [(· ^ ·), Pow.pow, opow, opowAux2, *, zero_def] + · by_cases h : o₂ = 0 + · subst h + simp only [(· ^ ·), Pow.pow, opow, opowAux2, e₁, OfNat.ofNat, Zero.zero, One.one] + decide + · have h' : o₂ ≠ zero := fun he => h (he ▸ zero_def ▸ rfl) + simp only [(· ^ ·), Pow.pow, opow, opowAux2, e₁, OfNat.ofNat, Zero.zero, One.one, + h', ite_false] + exact NF.zero + · by_cases h : m = 0 + · simp only [(· ^ ·), Pow.pow, opow, opowAux2, OfNat.ofNat, Zero.zero, One.one, *] decide - · simp only [(· ^ ·), Pow.pow, opow, opowAux2, *] + · simp only [(· ^ ·), Pow.pow, opow, opowAux2, OfNat.ofNat, Zero.zero, *] + change NF (oadd _ _ 0) infer_instance · simp only [(· ^ ·), Pow.pow, opow, opowAux2, e₁, split_eq_scale_split' e₂, mulNat_eq_mul] have := na.fst @@ -809,10 +831,11 @@ theorem repr_opow_aux₂ {a0 a'} [N0 : NF a0] [Na' : NF a'] (m : ℕ) (d : ω = (α' + m) ^ (succ ↑k : Ordinal) at IH have RR : R' = ω0 ^ (k : Ordinal) * (α' * m) + R := by by_cases h : m = 0 - · simp only [R, R', h, ONote.ofNat, Nat.cast_zero, ONote.repr, mul_zero, - ONote.opowAux, add_zero] - · simp only [α', ω0, R, R', ONote.repr_scale, ONote.repr, ONote.mulNat_eq_mul, ONote.opowAux, - ONote.repr_ofNat, ONote.repr_mul, ONote.repr_add, Ordinal.opow_mul, ONote.zero_add] + · simp only [R, R', h, ONote.ofNat, Nat.cast_zero, ONote.repr_zero, + mul_zero, ONote.opowAux, add_zero] + · simp only [α', ω0, R, R', ONote.repr_scale, ONote.repr, + ONote.mulNat_eq_mul, ONote.opowAux, ONote.repr_ofNat, ONote.repr_mul, ONote.repr_add, + Ordinal.opow_mul, ONote.zero_add] have α0 : 0 < α' := by simpa [lt_def, repr] using oadd_pos a0 n a' have ω00 : 0 < ω0 ^ (k : Ordinal) := opow_pos _ (opow_pos _ omega0_pos) have Rl : R < ω ^ (repr a0 * succ ↑k) := by @@ -879,14 +902,20 @@ theorem repr_opow (o₁ o₂) [NF o₁] [NF o₂] : repr (o₁ ^ o₂) = repr o obtain ⟨N₁, r₁⟩ := nf_repr_split e₁ obtain - | ⟨a0, n, a'⟩ := a · rcases m with - | m - · by_cases h : o₂ = 0 <;> simp [opow_def, opowAux2, e₁, h, r₁] - have := mt repr_inj.1 h - rw [zero_opow this] + · have hzero : (0 : ONote) = zero := rfl + by_cases h : o₂ = 0 + · subst h; simp [-zero_def, opow_def, opowAux2, e₁, r₁, hzero] + · have h' := mt repr_inj.1 h + have hne : o₂ ≠ zero := fun he => h (he ▸ rfl) + simp [-zero_def, opow_def, opowAux2, e₁, r₁, hne, hzero] + exact (zero_opow h').symm · rcases e₂ : split' o₂ with ⟨b', k⟩ obtain ⟨_, r₂⟩ := nf_repr_split' e₂ by_cases h : m = 0 - · simp [opowAux2, opow_def, e₁, h, r₁, r₂] - simp only [opow_def, opowAux2, e₁, r₁, e₂, r₂, repr, + · simp only [opowAux2, opow_def, e₁, h, r₁, r₂, OfNat.ofNat, Zero.zero, One.one, + repr] + simp [opow_add, opow_mul] + simp only [opow_def, opowAux2, e₁, r₁, e₂, r₂, repr, repr_zero, Nat.cast_succ, _root_.zero_add, add_zero] rw [opow_add, opow_mul, opow_omega0] @@ -905,10 +934,10 @@ theorem repr_opow (o₁ o₂) [NF o₁] [NF o₂] : repr (o₁ ^ o₂) = repr o simp only [opow_def, e₁, r₁, split_eq_scale_split' e₂, opowAux2, repr] rcases k with - | k · simp [r₂, opow_mul, repr_opow_aux₁ a00 al aa, add_assoc] - · simp [r₂, opow_add, opow_mul, mul_assoc, add_assoc] + · simp [r₂, opow_add, opow_mul, mul_assoc, add_assoc, repr_one] rw [repr_opow_aux₁ a00 al aa, scale_opowAux] - simp only [repr_mul, repr_scale, repr, opow_zero, PNat.val_ofNat, Nat.cast_one, mul_one, - add_zero, opow_one, opow_mul] + simp only [repr_mul, repr_scale, repr_one, + Nat.cast_one, opow_one, opow_mul] rw [← mul_add, ← add_assoc ((ω : Ordinal.{0}) ^ repr a0 * (n : ℕ))] congr 1 rw [← pow_succ, ← opow_natCast, ← opow_natCast] @@ -998,8 +1027,8 @@ theorem fundamentalSequence_has_prop (o) : FundamentalSequenceProp o (fundamenta have := PNat.natPred_add_one m; rw [e'] at this; exact PNat.coe_inj.1 this.symm]) <;> (try rw [show m = (m' + 1).succPNat by rw [← e', ← PNat.coe_inj, Nat.succPNat_coe, ← Nat.add_one, PNat.natPred_add_one]]) <;> - simp only [repr, iha, ihb, opow_lt_opow_iff_right one_lt_omega0, add_lt_add_iff_left, - add_zero, lt_add_iff_pos_right, lt_def, mul_one, Nat.cast_zero, + simp only [repr, repr_zero, iha, ihb, opow_lt_opow_iff_right one_lt_omega0, + add_lt_add_iff_left, add_zero, lt_add_iff_pos_right, lt_def, mul_one, Nat.cast_zero, Nat.cast_succ, Nat.succPNat_coe, opow_succ, opow_zero, mul_add_one, PNat.one_coe, _root_.zero_add, zero_def] · constructor @@ -1021,7 +1050,7 @@ theorem fundamentalSequence_has_prop (o) : FundamentalSequenceProp o (fundamenta gcongr apply natCast_lt_omega0 · refine fun H => H.fst.oadd _ (NF.below_of_lt' ?_ (@NF.oadd_zero _ _ (iha.2 H.fst))) - rw [repr, ← zero_def, repr, add_zero, iha.1, opow_succ] + rw [repr, repr_zero, add_zero, iha.1, opow_succ] gcongr apply natCast_lt_omega0 · rcases iha with ⟨h1, h2, h3⟩ @@ -1035,7 +1064,7 @@ theorem fundamentalSequence_has_prop (o) : FundamentalSequenceProp o (fundamenta exists_lt_add (exists_lt_omega0_opow' one_lt_omega0 h1 h3)⟩ obtain ⟨h4, h5, h6⟩ := h2 i refine ⟨h4, h5, fun H => H.fst.oadd _ (NF.below_of_lt' ?_ (@NF.oadd_zero _ _ (h6 H.fst)))⟩ - rwa [repr, ← zero_def, repr, add_zero, PNat.one_coe, Nat.cast_one, mul_one, + rwa [repr, repr_zero, add_zero, PNat.one_coe, Nat.cast_one, mul_one, opow_lt_opow_iff_right one_lt_omega0] · refine ⟨?_, fun H ↦ H.fst.oadd _ (NF.below_of_lt' ?_ (ihb.2 H.snd))⟩ · rw [repr, ihb.1, succ_eq_add_one, succ_eq_add_one, ← add_assoc, repr] diff --git a/Mathlib/Tactic/NormNum/PowMod.lean b/Mathlib/Tactic/NormNum/PowMod.lean index 1c139b5727f947..ce48e704cc8e97 100644 --- a/Mathlib/Tactic/NormNum/PowMod.lean +++ b/Mathlib/Tactic/NormNum/PowMod.lean @@ -54,10 +54,10 @@ theorem IsNatPowModT.bit0 : ⟨fun h1 => by simp only [two_mul, Nat.pow_eq, pow_add, ← h1, Nat.mul_eq]; exact Nat.mul_mod ..⟩ theorem natPow_zero_natMod_zero : Nat.mod (Nat.pow a (nat_lit 0)) (nat_lit 0) = nat_lit 1 := by - simp [Nat.mod, Nat.modCore] + simp [Nat.mod, Nat.modCore, OfNat.ofNat, One.one] theorem natPow_zero_natMod_one : Nat.mod (Nat.pow a (nat_lit 0)) (nat_lit 1) = nat_lit 0 := by - simp [Nat.mod, Nat.modCore_eq] + simp [Nat.mod, Nat.modCore, OfNat.ofNat, One.one, Nat.modCore.go] theorem natPow_zero_natMod_succ_succ : Nat.mod (Nat.pow a (nat_lit 0)) (Nat.succ (Nat.succ m)) = nat_lit 1 := by diff --git a/lake-manifest.json b/lake-manifest.json index ca0e4c0d66b879..4536c34dc7af3b 100644 --- a/lake-manifest.json +++ b/lake-manifest.json @@ -65,10 +65,10 @@ "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "bf597c77bf9b8e66720d724928207f5911533113", + "rev": "a985c160afc3d49773f1ad02d0d73a021d5dee41", "name": "batteries", "manifestFile": "lake-manifest.json", - "inputRev": "v4.30.0-rc1", + "inputRev": "lean-pr-testing-13363", "inherited": false, "configFile": "lakefile.toml"}, {"url": "https://github.com/leanprover/lean4-cli", diff --git a/lakefile.lean b/lakefile.lean index 5f11ec894a69ad..6af4aae0ea2070 100644 --- a/lakefile.lean +++ b/lakefile.lean @@ -6,7 +6,7 @@ open Lake DSL ## Mathlib dependencies on upstream projects -/ -require "leanprover-community" / "batteries" @ git "v4.30.0-rc1" +require "leanprover-community" / "batteries" @ git "lean-pr-testing-13363" require "leanprover-community" / "Qq" @ git "nightly-testing" require "leanprover-community" / "aesop" @ git "nightly-testing" require "leanprover-community" / "proofwidgets" @ git "v0.0.97" diff --git a/lean-toolchain b/lean-toolchain index 54caac41bddf21..5d0967670ed6d5 100644 --- a/lean-toolchain +++ b/lean-toolchain @@ -1 +1 @@ -leanprover/lean4:nightly-2026-04-07 +leanprover/lean4-pr-releases:pr-release-13363-c9741df From 737564ce1816a1cf6a40f7b259567818bf93fa6d Mon Sep 17 00:00:00 2001 From: Joachim Breitner Date: Wed, 15 Apr 2026 16:13:12 +0000 Subject: [PATCH 078/321] fix lint errors from lean4#13363 adaptation - Add doc string to `WithZero.withZeroSup` - Add `nolint simpNF` to auto-generated equation lemmas for `RegularExpression.matches'` and `RegularExpression.map` - Add `nolint simpNF` to `orderLHom_leSymb` --- Mathlib/Algebra/Order/GroupWithZero/Canonical.lean | 1 + Mathlib/Computability/RegularExpressions.lean | 4 ++++ Mathlib/ModelTheory/Order.lean | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Mathlib/Algebra/Order/GroupWithZero/Canonical.lean b/Mathlib/Algebra/Order/GroupWithZero/Canonical.lean index 70f2e9204885c3..a02972a34948f3 100644 --- a/Mathlib/Algebra/Order/GroupWithZero/Canonical.lean +++ b/Mathlib/Algebra/Order/GroupWithZero/Canonical.lean @@ -419,6 +419,7 @@ end PartialOrder section Lattice +/-- Supremum for `WithZero α`, defined via `Option.merge`. -/ def withZeroSup [Max α] : WithZero α → WithZero α → WithZero α := Option.merge (· ⊔ ·) diff --git a/Mathlib/Computability/RegularExpressions.lean b/Mathlib/Computability/RegularExpressions.lean index dd7036974a93e9..584129a46cbce2 100644 --- a/Mathlib/Computability/RegularExpressions.lean +++ b/Mathlib/Computability/RegularExpressions.lean @@ -103,6 +103,8 @@ def matches' : RegularExpression α → Language α | P * Q => P.matches' * Q.matches' | star P => P.matches'∗ +attribute [nolint simpNF] matches'.eq_1 matches'.eq_2 + theorem matches'_zero : (0 : RegularExpression α).matches' = 0 := rfl @@ -338,6 +340,8 @@ def map (f : α → β) : RegularExpression α → RegularExpression β | R * S => map f R * map f S | star R => star (map f R) +attribute [nolint simpNF] map.eq_1 map.eq_2 + @[simp] protected theorem map_pow (f : α → β) (P : RegularExpression α) : ∀ n : ℕ, map f (P ^ n) = map f P ^ n diff --git a/Mathlib/ModelTheory/Order.lean b/Mathlib/ModelTheory/Order.lean index e3569f3c63ae5c..13a155999c6ec2 100644 --- a/Mathlib/ModelTheory/Order.lean +++ b/Mathlib/ModelTheory/Order.lean @@ -135,7 +135,7 @@ language. -/ @[simps] def orderLHom : Language.order →ᴸ L where onRelation | _, .le => leSymb -@[simp] +@[simp, nolint simpNF] theorem orderLHom_leSymb : (orderLHom L).onRelation leSymb = (leSymb : L.Relations 2) := rfl From 9e7eebd31d71e2faaf8c58aaa13da435a5595805 Mon Sep 17 00:00:00 2001 From: Kim Morrison Date: Thu, 16 Apr 2026 08:02:46 +0000 Subject: [PATCH 079/321] fixes --- Mathlib/Analysis/Distribution/Distribution.lean | 2 +- Mathlib/CategoryTheory/Types/Basic.lean | 2 +- Mathlib/RingTheory/Perfection.lean | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Mathlib/Analysis/Distribution/Distribution.lean b/Mathlib/Analysis/Distribution/Distribution.lean index 931ea029f07803..c392c764bd5753 100644 --- a/Mathlib/Analysis/Distribution/Distribution.lean +++ b/Mathlib/Analysis/Distribution/Distribution.lean @@ -192,7 +192,7 @@ end mapCLM section DiracDelta /-- The Dirac delta distribution. This is zero if `x` does not belong to `Ω`. -/ -def delta (x : E) : 𝓓'^{n}(Ω, ℝ) where +noncomputable def delta (x : E) : 𝓓'^{n}(Ω, ℝ) where toFun f := f x map_add' _ _ := rfl map_smul' _ _ := rfl diff --git a/Mathlib/CategoryTheory/Types/Basic.lean b/Mathlib/CategoryTheory/Types/Basic.lean index 8701000d99dc29..5de3f5b72f7cb6 100644 --- a/Mathlib/CategoryTheory/Types/Basic.lean +++ b/Mathlib/CategoryTheory/Types/Basic.lean @@ -315,7 +315,7 @@ Write this as `uliftFunctor.{5, 2}` to get `Type 2 ⥤ Type 5`. @[pp_with_univ, simps obj map] def uliftFunctor : Type u ⥤ Type max u v where obj X := ULift.{v} X - map {X} {_} f := fun x : ULift.{v} X => ULift.up (f x.down) + map {X} {_} f := fun x : ULift.{v} X => ULift.up.{v} (f x.down) @[simp] theorem uliftFunctor_obj {X : Type u} : uliftFunctor.{v}.obj X = ULift.{v} X := diff --git a/Mathlib/RingTheory/Perfection.lean b/Mathlib/RingTheory/Perfection.lean index 4a4117cdd01125..b705efb5863b4c 100644 --- a/Mathlib/RingTheory/Perfection.lean +++ b/Mathlib/RingTheory/Perfection.lean @@ -838,6 +838,8 @@ namespace Tilt noncomputable instance [Fact p.Prime] [hvp : Fact (v p ≠ 1)] : Field (Tilt K v O hv p) := haveI := Fact.mk <| mt hv.one_of_isUnit <| (map_natCast (algebraMap O K) p).symm ▸ hvp.1 haveI := PreTilt.isDomain K v O hv p + #adaptation_note /-- This `letI` was not needed prior to nightly-2026-04-15. -/ + letI : CommRing (PreTilt O p) := inferInstance inferInstanceAs <| Field (FractionRing _) end Tilt From 8ba95847a2694c66068b94275efe201a1fcde041 Mon Sep 17 00:00:00 2001 From: Kim Morrison Date: Thu, 16 Apr 2026 08:05:17 +0000 Subject: [PATCH 080/321] fix --- Mathlib/CategoryTheory/Types/Basic.lean | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/Mathlib/CategoryTheory/Types/Basic.lean b/Mathlib/CategoryTheory/Types/Basic.lean index 5de3f5b72f7cb6..ea2397b985dca9 100644 --- a/Mathlib/CategoryTheory/Types/Basic.lean +++ b/Mathlib/CategoryTheory/Types/Basic.lean @@ -315,16 +315,7 @@ Write this as `uliftFunctor.{5, 2}` to get `Type 2 ⥤ Type 5`. @[pp_with_univ, simps obj map] def uliftFunctor : Type u ⥤ Type max u v where obj X := ULift.{v} X - map {X} {_} f := fun x : ULift.{v} X => ULift.up.{v} (f x.down) - -@[simp] -theorem uliftFunctor_obj {X : Type u} : uliftFunctor.{v}.obj X = ULift.{v} X := - rfl - -@[simp] -theorem uliftFunctor_map {X Y : Type u} (f : X ⟶ Y) (x : ULift.{v} X) : - uliftFunctor.map f x = ULift.up (f x.down) := - rfl + map {X} {_} f := TypeCat.ofHom fun x : ULift.{v} X => ULift.up.{v} (f x.down) /-- `uliftFunctor : Type u ⥤ Type max u v` is fully faithful. -/ def fullyFaithfulULiftFunctor : (uliftFunctor.{v, u}).FullyFaithful where From f9ae5cc6f301a0a0e6091e8e5c9c3d501b9812f8 Mon Sep 17 00:00:00 2001 From: Kim Morrison Date: Thu, 16 Apr 2026 09:28:08 +0000 Subject: [PATCH 081/321] fixes --- Mathlib/Algebra/Category/ModuleCat/Presheaf/Monoidal.lean | 2 +- Mathlib/AlgebraicTopology/SimplicialSet/Horn.lean | 4 ++-- Mathlib/CategoryTheory/Sites/Sieves.lean | 2 +- Mathlib/RingTheory/Flat/Rank.lean | 1 + 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Mathlib/Algebra/Category/ModuleCat/Presheaf/Monoidal.lean b/Mathlib/Algebra/Category/ModuleCat/Presheaf/Monoidal.lean index e593c19088e76d..4778e592b7948a 100644 --- a/Mathlib/Algebra/Category/ModuleCat/Presheaf/Monoidal.lean +++ b/Mathlib/Algebra/Category/ModuleCat/Presheaf/Monoidal.lean @@ -141,7 +141,7 @@ noncomputable instance monoidalCategory : open BraidedCategory -instance symmetricCategory : +noncomputable instance symmetricCategory : SymmetricCategory (PresheafOfModules.{u} (R ⋙ forget₂ _ _)) where braiding M₁ M₂ := isoMk (fun X ↦ braiding (C := ModuleCat (R.obj X)) (M₁.obj X) (M₂.obj X)) diff --git a/Mathlib/AlgebraicTopology/SimplicialSet/Horn.lean b/Mathlib/AlgebraicTopology/SimplicialSet/Horn.lean index 70e0fbfb413bf6..a7c651c699abb9 100644 --- a/Mathlib/AlgebraicTopology/SimplicialSet/Horn.lean +++ b/Mathlib/AlgebraicTopology/SimplicialSet/Horn.lean @@ -94,7 +94,7 @@ lemma horn_obj_eq_univ {n : ℕ} (i : Fin (n + 1)) (m : ℕ) (h : m + 1 < n := b Finset.card_singleton, add_le_add_iff_right] at this have : n ≤ m + 1 := by simpa using this.trans Finset.card_image_le lia - have : ∃ j, ¬j = i ∧ ∀ (i : Fin (m + 1)), ¬(stdSimplex.objEquiv.symm.{u} f) i = j := + have : ∃ j, ¬j = i ∧ ∀ (i : Fin (m + 1)), ¬(stdSimplex.objEquiv.{u}.symm f) i = j := ⟨j, hij, fun k hk ↦ hj ⟨k, hk⟩⟩ simpa [horn_eq_iSup] using this @@ -140,7 +140,7 @@ lemma face_le_horn_iff {n : ℕ} (S : Finset (Fin (n + 2))) (j : Fin (n + 2)) : lemma objEquiv_symm_notMem_horn_of_isIso {n : ℕ} (i : Fin (n + 1)) {d : SimplexCategory} (f : d ⟶ ⦋n⦌) [IsIso f] : - stdSimplex.objEquiv.symm.{u} f ∉ Λ[n, i].obj (op d) := by + stdSimplex.objEquiv.{u}.symm f ∉ Λ[n, i].obj (op d) := by rw [mem_horn_iff, ne_eq, not_not] ext i simpa using Or.inr ⟨inv f i, by simp [stdSimplex.coe_asOrderHom_objEquiv_symm.{u}]⟩ diff --git a/Mathlib/CategoryTheory/Sites/Sieves.lean b/Mathlib/CategoryTheory/Sites/Sieves.lean index a6fb9bc171af42..5715339400c477 100644 --- a/Mathlib/CategoryTheory/Sites/Sieves.lean +++ b/Mathlib/CategoryTheory/Sites/Sieves.lean @@ -1263,7 +1263,7 @@ def uliftFunctorInclusion (S : Sieve X) : @[simps] def toUliftFunctor (S : Sieve X) {Y : C} (f : Y ⟶ X) (hf : S f) : uliftYoneda.{w}.obj Y ⟶ Sieve.uliftFunctor.{w} S where - app Z g := ⟨g.down ≫ f, S.downward_closed hf g.down⟩ + app Z := TypeCat.ofHom fun g ↦ ⟨g.down ≫ f, S.downward_closed hf g.down⟩ theorem uliftNatTransOfLe_comm {S T : Sieve X} (h : S ≤ T) : uliftNatTransOfLe.{w} h ≫ uliftFunctorInclusion.{w} _ = uliftFunctorInclusion.{w} _ := diff --git a/Mathlib/RingTheory/Flat/Rank.lean b/Mathlib/RingTheory/Flat/Rank.lean index a7a380d3a50fdb..7f5eae009c9a13 100644 --- a/Mathlib/RingTheory/Flat/Rank.lean +++ b/Mathlib/RingTheory/Flat/Rank.lean @@ -36,6 +36,7 @@ attribute [local instance] Module.free_of_flat_of_isLocalRing variable {R S : Type*} [CommRing R] [CommRing S] [Algebra R S] [Module.Flat R S] [Module.Finite R S] +set_option backward.isDefEq.respectTransparency false in lemma PrimeSpectrum.rankAtStalk_pos_iff_mem_range_comap (p : PrimeSpectrum R) : 0 < Module.rankAtStalk (R := R) S p ↔ p ∈ Set.range (PrimeSpectrum.comap (algebraMap R S)) := by rw [Module.rankAtStalk_eq, Module.finrank_pos_iff, p.nontrivial_iff_mem_rangeComap] From cecf37bdace26a422cf4eb0059fb7f0d410969b6 Mon Sep 17 00:00:00 2001 From: "mathlib-nightly-testing[bot]" Date: Thu, 16 Apr 2026 09:31:37 +0000 Subject: [PATCH 082/321] chore: bump to nightly-2026-04-16 --- lean-toolchain | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lean-toolchain b/lean-toolchain index b74ced19101876..844e3659d22483 100644 --- a/lean-toolchain +++ b/lean-toolchain @@ -1 +1 @@ -leanprover/lean4:nightly-2026-04-15 +leanprover/lean4:nightly-2026-04-16 From 6d92cce23161c25a65ff235d4fda70454b8d2e0e Mon Sep 17 00:00:00 2001 From: Kim Morrison Date: Fri, 17 Apr 2026 03:21:32 +0000 Subject: [PATCH 083/321] fix tests --- MathlibTest/DocPrime.lean | 2 ++ MathlibTest/LintStyle.lean | 1 + MathlibTest/ToDual.lean | 1 + 3 files changed, 4 insertions(+) diff --git a/MathlibTest/DocPrime.lean b/MathlibTest/DocPrime.lean index 7411651cca5259..5666bf74599ca9 100644 --- a/MathlibTest/DocPrime.lean +++ b/MathlibTest/DocPrime.lean @@ -67,6 +67,7 @@ Declarations whose name ends with a `'` are expected to contain an explanation f Note: This linter can be disabled with `set_option linter.docPrime false` -/ #guard_msgs in +set_option linter.nonClassInstance false in instance inst_no_doc' : True := .intro /-- @@ -91,6 +92,7 @@ def def_no_doc' : True := .intro namespace Foo' example : True := .intro +set_option linter.nonClassInstance false in instance : True := .intro end Foo' diff --git a/MathlibTest/LintStyle.lean b/MathlibTest/LintStyle.lean index 4e9351942fc5c0..a68b244a5dae34 100644 --- a/MathlibTest/LintStyle.lean +++ b/MathlibTest/LintStyle.lean @@ -284,6 +284,7 @@ warning: Please use '<|' instead of '$' for the pipe operator. Note: This linter can be disabled with `set_option linter.style.dollarSyntax false` -/ #guard_msgs in +set_option linter.impossibleInstance false in instance (f g : Nat → Nat) : Inhabited Nat where default := by · have := 0 diff --git a/MathlibTest/ToDual.lean b/MathlibTest/ToDual.lean index b9bb47f4ad4a2b..f87fb53395228c 100644 --- a/MathlibTest/ToDual.lean +++ b/MathlibTest/ToDual.lean @@ -32,6 +32,7 @@ structure Lattice (α : Type) extends SemilatticeInf α, SemilatticeSup α attribute [to_dual existing] Lattice.toSemilatticeInf -- we can reorder arguments of arguments in `SemilatticeInf.mk` +set_option linter.impossibleInstance false in @[to_dual] instance [Min α] (le_inf : ∀ a b c : α, a ≤ b → a ≤ c → a ≤ b ⊓ c) : SemilatticeInf α where le_inf From c33286bef8c14a6fce87ea5fdd7f2bd196a30577 Mon Sep 17 00:00:00 2001 From: Kim Morrison Date: Fri, 17 Apr 2026 19:04:23 +1000 Subject: [PATCH 084/321] fix upstreamed import --- Mathlib/Order/Bounded.lean | 1 - 1 file changed, 1 deletion(-) diff --git a/Mathlib/Order/Bounded.lean b/Mathlib/Order/Bounded.lean index dddc3d771498da..6ab52893a60e3b 100644 --- a/Mathlib/Order/Bounded.lean +++ b/Mathlib/Order/Bounded.lean @@ -5,7 +5,6 @@ Authors: Violeta Hernández Palacios -/ module -public import Mathlib.Tactic.Linter.DeprecatedModule public import Mathlib.Order.RelClasses public import Mathlib.Order.Interval.Set.Basic public import Mathlib.Order.Bounds.Defs From 32b824d8467cd67fba0bc954cfbd48f17e85bd88 Mon Sep 17 00:00:00 2001 From: "mathlib-nightly-testing[bot]" Date: Fri, 17 Apr 2026 09:30:49 +0000 Subject: [PATCH 085/321] chore: bump to nightly-2026-04-17 --- lean-toolchain | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lean-toolchain b/lean-toolchain index 844e3659d22483..474b1d259a11e1 100644 --- a/lean-toolchain +++ b/lean-toolchain @@ -1 +1 @@ -leanprover/lean4:nightly-2026-04-16 +leanprover/lean4:nightly-2026-04-17 From bba4e0716004d5583247ab95fc436e817087e83a Mon Sep 17 00:00:00 2001 From: Kim Morrison Date: Fri, 17 Apr 2026 22:22:42 +1000 Subject: [PATCH 086/321] set_option --- Mathlib/RingTheory/Flat/Rank.lean | 1 + 1 file changed, 1 insertion(+) diff --git a/Mathlib/RingTheory/Flat/Rank.lean b/Mathlib/RingTheory/Flat/Rank.lean index a7a380d3a50fdb..7f5eae009c9a13 100644 --- a/Mathlib/RingTheory/Flat/Rank.lean +++ b/Mathlib/RingTheory/Flat/Rank.lean @@ -36,6 +36,7 @@ attribute [local instance] Module.free_of_flat_of_isLocalRing variable {R S : Type*} [CommRing R] [CommRing S] [Algebra R S] [Module.Flat R S] [Module.Finite R S] +set_option backward.isDefEq.respectTransparency false in lemma PrimeSpectrum.rankAtStalk_pos_iff_mem_range_comap (p : PrimeSpectrum R) : 0 < Module.rankAtStalk (R := R) S p ↔ p ∈ Set.range (PrimeSpectrum.comap (algebraMap R S)) := by rw [Module.rankAtStalk_eq, Module.finrank_pos_iff, p.nontrivial_iff_mem_rangeComap] From 24516c8a3fef2e65e8f392f250d6261bdd71aa4b Mon Sep 17 00:00:00 2001 From: leanprover-community-mathlib4-bot Date: Fri, 17 Apr 2026 12:42:06 +0000 Subject: [PATCH 087/321] Update lean-toolchain for https://github.com/leanprover/lean4/pull/13359 --- lake-manifest.json | 2 +- lean-toolchain | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lake-manifest.json b/lake-manifest.json index 8df074d0a46b06..905497ad34eea5 100644 --- a/lake-manifest.json +++ b/lake-manifest.json @@ -65,7 +65,7 @@ "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "de57422f63844ccfb61d5dd0153555b6d65db4ff", + "rev": "54fca9613ac68f97ebd25bf28dc2390ef94e4e01", "name": "batteries", "manifestFile": "lake-manifest.json", "inputRev": "lean-pr-testing-13359", diff --git a/lean-toolchain b/lean-toolchain index c955e0e3fe14ed..826a0428ef2b6f 100644 --- a/lean-toolchain +++ b/lean-toolchain @@ -1 +1 @@ -leanprover/lean4-pr-releases:pr-release-13359-8400f35 +leanprover/lean4-pr-releases:pr-release-13359-3bce27f From 9a0046f4f8791dd17ecedbd350af03ed2a66d433 Mon Sep 17 00:00:00 2001 From: leanprover-community-mathlib4-bot Date: Fri, 17 Apr 2026 13:37:43 +0000 Subject: [PATCH 088/321] Update lean-toolchain for https://github.com/leanprover/lean4/pull/13359 --- lake-manifest.json | 2 +- lean-toolchain | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lake-manifest.json b/lake-manifest.json index 905497ad34eea5..e23937f8358b27 100644 --- a/lake-manifest.json +++ b/lake-manifest.json @@ -65,7 +65,7 @@ "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "54fca9613ac68f97ebd25bf28dc2390ef94e4e01", + "rev": "4045ead708293ce17f2cc63b7d2326b91ceeedba", "name": "batteries", "manifestFile": "lake-manifest.json", "inputRev": "lean-pr-testing-13359", diff --git a/lean-toolchain b/lean-toolchain index 826a0428ef2b6f..b9debe1b129611 100644 --- a/lean-toolchain +++ b/lean-toolchain @@ -1 +1 @@ -leanprover/lean4-pr-releases:pr-release-13359-3bce27f +leanprover/lean4-pr-releases:pr-release-13359-8176c2e From 1ebf1cc214eaf71301eda927899371e287ac7475 Mon Sep 17 00:00:00 2001 From: leanprover-community-mathlib4-bot Date: Fri, 17 Apr 2026 14:08:15 +0000 Subject: [PATCH 089/321] Update lean-toolchain for testing https://github.com/leanprover/lean4/pull/13441 --- lake-manifest.json | 4 ++-- lakefile.lean | 2 +- lean-toolchain | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lake-manifest.json b/lake-manifest.json index 208a334e436ab5..733e9888345ccd 100644 --- a/lake-manifest.json +++ b/lake-manifest.json @@ -65,10 +65,10 @@ "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "918975dee951eb4b2338607c5277a4e5835834f3", + "rev": "c33bb8643da2d08d284be01d942da42f982faaa0", "name": "batteries", "manifestFile": "lake-manifest.json", - "inputRev": "nightly-testing", + "inputRev": "lean-pr-testing-13441", "inherited": false, "configFile": "lakefile.toml"}, {"url": "https://github.com/leanprover/lean4-cli", diff --git a/lakefile.lean b/lakefile.lean index babb657761237b..1b97e37a1ac36d 100644 --- a/lakefile.lean +++ b/lakefile.lean @@ -6,7 +6,7 @@ open Lake DSL ## Mathlib dependencies on upstream projects -/ -require "leanprover-community" / "batteries" @ git "nightly-testing" +require "leanprover-community" / "batteries" @ git "lean-pr-testing-13441" require "leanprover-community" / "Qq" @ git "nightly-testing" require "leanprover-community" / "aesop" @ git "nightly-testing" require "leanprover-community" / "proofwidgets" @ git "v0.0.97" diff --git a/lean-toolchain b/lean-toolchain index 844e3659d22483..a725dbebcf9a80 100644 --- a/lean-toolchain +++ b/lean-toolchain @@ -1 +1 @@ -leanprover/lean4:nightly-2026-04-16 +leanprover/lean4-pr-releases:pr-release-13441-72e3ae9 From b098eb1ee2286c8bd86d7038954085f4f3493bc8 Mon Sep 17 00:00:00 2001 From: Wojciech Rozowski Date: Fri, 17 Apr 2026 14:22:07 +0000 Subject: [PATCH 090/321] chore: adaptations for leanprover/lean4#13389 --- Mathlib/GroupTheory/Abelianization/Defs.lean | 2 - Mathlib/GroupTheory/FreeAbelianGroup.lean | 2 - Mathlib/Topology/MetricSpace/Gluing.lean | 2 - MathlibTest/DocPrime.lean | 9 +++-- MathlibTest/LintStyle.lean | 4 +- MathlibTest/ToDual.lean | 4 +- MathlibTest/globalAttributeIn.lean | 39 ++++++++------------ 7 files changed, 24 insertions(+), 38 deletions(-) diff --git a/Mathlib/GroupTheory/Abelianization/Defs.lean b/Mathlib/GroupTheory/Abelianization/Defs.lean index 950c5ca84135b7..ef2b4d1b467194 100644 --- a/Mathlib/GroupTheory/Abelianization/Defs.lean +++ b/Mathlib/GroupTheory/Abelianization/Defs.lean @@ -40,8 +40,6 @@ def Abelianization : Type u := namespace Abelianization -attribute [local instance] QuotientGroup.leftRel - instance commGroup : CommGroup (Abelianization G) where __ := QuotientGroup.Quotient.group _ mul_comm x y := Quotient.inductionOn₂ x y fun a b ↦ Quotient.sound' <| diff --git a/Mathlib/GroupTheory/FreeAbelianGroup.lean b/Mathlib/GroupTheory/FreeAbelianGroup.lean index 86c2d955ee513e..bc7ab476fce41b 100644 --- a/Mathlib/GroupTheory/FreeAbelianGroup.lean +++ b/Mathlib/GroupTheory/FreeAbelianGroup.lean @@ -172,8 +172,6 @@ instance [Nonempty α] : Nontrivial (FreeAbelianGroup α) where end -attribute [local instance] QuotientGroup.leftRel - @[elab_as_elim] protected theorem induction_on {motive : FreeAbelianGroup α → Prop} (z : FreeAbelianGroup α) (zero : motive 0) diff --git a/Mathlib/Topology/MetricSpace/Gluing.lean b/Mathlib/Topology/MetricSpace/Gluing.lean index 843aeb1d0dc9ef..0c3d873c6adce0 100644 --- a/Mathlib/Topology/MetricSpace/Gluing.lean +++ b/Mathlib/Topology/MetricSpace/Gluing.lean @@ -592,8 +592,6 @@ def inductivePremetric (I : ∀ n, Isometry (f n)) : PseudoMetricSpace (Σ n, X _ = inductiveLimitDist f x y + inductiveLimitDist f y z := by rw [inductiveLimitDist_eq_dist I x y m hx hy, inductiveLimitDist_eq_dist I y z m hy hz] -attribute [local instance] inductivePremetric - /-- The type giving the inductive limit in a metric space context. -/ def InductiveLimit (I : ∀ n, Isometry (f n)) : Type _ := @SeparationQuotient _ (inductivePremetric I).toUniformSpace.toTopologicalSpace diff --git a/MathlibTest/DocPrime.lean b/MathlibTest/DocPrime.lean index 5666bf74599ca9..bc217c8686bc65 100644 --- a/MathlibTest/DocPrime.lean +++ b/MathlibTest/DocPrime.lean @@ -60,6 +60,9 @@ Note: This linter can be disabled with `set_option linter.docPrime false` @[simp] theorem thm_with_attr_no_doc' : True := .intro +class Dummy where + field : True + /-- warning: `inst_no_doc'` is missing a doc-string, please add one. Declarations whose name ends with a `'` are expected to contain an explanation for the presence of a `'` in their doc-string. This may consist of discussion of the difference relative to the unprimed version, or an explanation as to why no better naming scheme is possible. @@ -67,8 +70,7 @@ Declarations whose name ends with a `'` are expected to contain an explanation f Note: This linter can be disabled with `set_option linter.docPrime false` -/ #guard_msgs in -set_option linter.nonClassInstance false in -instance inst_no_doc' : True := .intro +instance inst_no_doc' : Dummy := ⟨.intro⟩ /-- warning: `abbrev_no_doc'` is missing a doc-string, please add one. @@ -92,7 +94,6 @@ def def_no_doc' : True := .intro namespace Foo' example : True := .intro -set_option linter.nonClassInstance false in -instance : True := .intro +instance : Dummy := ⟨.intro⟩ end Foo' diff --git a/MathlibTest/LintStyle.lean b/MathlibTest/LintStyle.lean index a68b244a5dae34..e6cd6fb7f83b58 100644 --- a/MathlibTest/LintStyle.lean +++ b/MathlibTest/LintStyle.lean @@ -284,8 +284,8 @@ warning: Please use '<|' instead of '$' for the pipe operator. Note: This linter can be disabled with `set_option linter.style.dollarSyntax false` -/ #guard_msgs in -set_option linter.impossibleInstance false in -instance (f g : Nat → Nat) : Inhabited Nat where +@[reducible] +def test (f g : Nat → Nat) : Inhabited Nat where default := by · have := 0 · have : Nat := f $ g $ 0 diff --git a/MathlibTest/ToDual.lean b/MathlibTest/ToDual.lean index f87fb53395228c..6b9b943762830d 100644 --- a/MathlibTest/ToDual.lean +++ b/MathlibTest/ToDual.lean @@ -33,8 +33,8 @@ attribute [to_dual existing] Lattice.toSemilatticeInf -- we can reorder arguments of arguments in `SemilatticeInf.mk` set_option linter.impossibleInstance false in -@[to_dual] -instance [Min α] (le_inf : ∀ a b c : α, a ≤ b → a ≤ c → a ≤ b ⊓ c) : SemilatticeInf α where +@[to_dual, reducible] +def le_inf_test [Min α] (le_inf : ∀ a b c : α, a ≤ b → a ≤ c → a ≤ b ⊓ c) : SemilatticeInf α where le_inf -- we can reorder arguments of arguments of arguments in `SemilatticeInf.casesOn` diff --git a/MathlibTest/globalAttributeIn.lean b/MathlibTest/globalAttributeIn.lean index 56ced2d39e8426..1c124f2b4d4ed0 100644 --- a/MathlibTest/globalAttributeIn.lean +++ b/MathlibTest/globalAttributeIn.lean @@ -8,28 +8,30 @@ import Mathlib.Tactic.Linter.GlobalAttributeIn /-! Tests for the `globalAttributeIn` linter. -/ --- After https://github.com/leanprover/lean4/pull/12263, --- we need to add `instance_reducible` before we can add `instance` to `Int.add`. -set_option allowUnsafeReducibility true in -attribute [instance_reducible] Int.add +-- Since lean4#13223 applying a global attribute using ... `in` ... is an error + +class Dummy where + field : True + +@[reducible] def dummyInst : Dummy := ⟨True.intro⟩ /-- -error: Despite the `in`, the attribute instance 1100 is added globally to Int.add +error: Despite the `in`, the attribute instance 1100 is added globally to dummyInst please remove the `in` or make this a `local instance 1100` -/ #guard_msgs in set_option autoImplicit false in -attribute [instance 1100] Int.add in +attribute [instance 1100] dummyInst in set_option autoImplicit false in instance : Inhabited Int where default := 0 /-- -error: Despite the `in`, the attribute instance is added globally to Int.add +error: Despite the `in`, the attribute instance is added globally to dummyInst please remove the `in` or make this a `local instance` -/ #guard_msgs in -attribute [instance] Int.add in +attribute [instance] dummyInst in instance : Inhabited Int where default := 0 @@ -58,42 +60,31 @@ please remove the `in` or make this a `local ext` -/ #guard_msgs in set_option warning.simp.varHead false in -attribute [simp, local simp, ext, scoped instance, -simp, -ext] foo in +attribute [simp, local simp, ext, -simp, -ext] foo in def bar := False #guard_msgs in -- `local instance` is allowed with `in` -attribute [local instance] Int.add in +attribute [local instance] dummyInst in instance : Inhabited Int where default := 0 #guard_msgs in -- `local instance priority` is allowed with `in` -attribute [local instance 42] Int.add in +attribute [local instance 42] dummyInst in instance : Inhabited Int where default := 0 #guard_msgs in -- `scoped instance` is allowed with `in` -attribute [scoped instance] Int.add in +attribute [scoped instance] dummyInst in instance : Inhabited Int where default := 0 #guard_msgs in -- `scoped instance priority` is allowed with `in` -attribute [scoped instance 42] Int.add in +attribute [scoped instance 42] dummyInst in instance : Inhabited Int where default := 0 end X - --- Omitting the `in` is also fine. - -attribute [local instance 42] X.foo - --- Global instance without the `in` are also left alone. -attribute [instance 20000] X.foo - -namespace X - -attribute [scoped instance 0] foo From fb01d27b86122c338d45a80d8d2082a63cb4b9de Mon Sep 17 00:00:00 2001 From: leanprover-community-mathlib4-bot Date: Fri, 17 Apr 2026 16:05:38 +0000 Subject: [PATCH 091/321] Update lean-toolchain for https://github.com/leanprover/lean4/pull/13359 --- lake-manifest.json | 2 +- lean-toolchain | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lake-manifest.json b/lake-manifest.json index e23937f8358b27..fa0dae512b1f3c 100644 --- a/lake-manifest.json +++ b/lake-manifest.json @@ -65,7 +65,7 @@ "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "4045ead708293ce17f2cc63b7d2326b91ceeedba", + "rev": "9ce5dcf87ffdb5e24989613faa792e0e7248871c", "name": "batteries", "manifestFile": "lake-manifest.json", "inputRev": "lean-pr-testing-13359", diff --git a/lean-toolchain b/lean-toolchain index b9debe1b129611..3e3159b56a5624 100644 --- a/lean-toolchain +++ b/lean-toolchain @@ -1 +1 @@ -leanprover/lean4-pr-releases:pr-release-13359-8176c2e +leanprover/lean4-pr-releases:pr-release-13359-af07b42 From a450fa064ebfe9a474d5fd2f5113b095e71bbc6c Mon Sep 17 00:00:00 2001 From: Kim Morrison Date: Sat, 18 Apr 2026 08:18:58 +1000 Subject: [PATCH 092/321] fixes --- Mathlib/CategoryTheory/Sites/Sieves.lean | 2 +- MathlibTest/DocPrime.lean | 7 +++++-- MathlibTest/LintStyle.lean | 3 ++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Mathlib/CategoryTheory/Sites/Sieves.lean b/Mathlib/CategoryTheory/Sites/Sieves.lean index 84c4db3b3add33..aaa29a83dcfec3 100644 --- a/Mathlib/CategoryTheory/Sites/Sieves.lean +++ b/Mathlib/CategoryTheory/Sites/Sieves.lean @@ -1263,7 +1263,7 @@ def uliftFunctorInclusion (S : Sieve X) : @[simps] def toUliftFunctor (S : Sieve X) {Y : C} (f : Y ⟶ X) (hf : S f) : uliftYoneda.{w}.obj Y ⟶ Sieve.uliftFunctor.{w} S where - app Z g := TypeCat.ofHom fun g ↦ ⟨g.down ≫ f, S.downward_closed hf g.down⟩ + app Z := TypeCat.ofHom fun g ↦ ⟨g.down ≫ f, S.downward_closed hf g.down⟩ theorem uliftNatTransOfLe_comm {S T : Sieve X} (h : S ≤ T) : uliftNatTransOfLe.{w} h ≫ uliftFunctorInclusion.{w} _ = uliftFunctorInclusion.{w} _ := diff --git a/MathlibTest/DocPrime.lean b/MathlibTest/DocPrime.lean index 7411651cca5259..bc217c8686bc65 100644 --- a/MathlibTest/DocPrime.lean +++ b/MathlibTest/DocPrime.lean @@ -60,6 +60,9 @@ Note: This linter can be disabled with `set_option linter.docPrime false` @[simp] theorem thm_with_attr_no_doc' : True := .intro +class Dummy where + field : True + /-- warning: `inst_no_doc'` is missing a doc-string, please add one. Declarations whose name ends with a `'` are expected to contain an explanation for the presence of a `'` in their doc-string. This may consist of discussion of the difference relative to the unprimed version, or an explanation as to why no better naming scheme is possible. @@ -67,7 +70,7 @@ Declarations whose name ends with a `'` are expected to contain an explanation f Note: This linter can be disabled with `set_option linter.docPrime false` -/ #guard_msgs in -instance inst_no_doc' : True := .intro +instance inst_no_doc' : Dummy := ⟨.intro⟩ /-- warning: `abbrev_no_doc'` is missing a doc-string, please add one. @@ -91,6 +94,6 @@ def def_no_doc' : True := .intro namespace Foo' example : True := .intro -instance : True := .intro +instance : Dummy := ⟨.intro⟩ end Foo' diff --git a/MathlibTest/LintStyle.lean b/MathlibTest/LintStyle.lean index 4e9351942fc5c0..e6cd6fb7f83b58 100644 --- a/MathlibTest/LintStyle.lean +++ b/MathlibTest/LintStyle.lean @@ -284,7 +284,8 @@ warning: Please use '<|' instead of '$' for the pipe operator. Note: This linter can be disabled with `set_option linter.style.dollarSyntax false` -/ #guard_msgs in -instance (f g : Nat → Nat) : Inhabited Nat where +@[reducible] +def test (f g : Nat → Nat) : Inhabited Nat where default := by · have := 0 · have : Nat := f $ g $ 0 From e479388d393de50704b991888f076be362d259ef Mon Sep 17 00:00:00 2001 From: Kim Morrison Date: Sat, 18 Apr 2026 08:20:28 +1000 Subject: [PATCH 093/321] fixes --- Mathlib/AlgebraicTopology/SimplicialSet/Horn.lean | 4 ++-- MathlibTest/ToDual.lean | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Mathlib/AlgebraicTopology/SimplicialSet/Horn.lean b/Mathlib/AlgebraicTopology/SimplicialSet/Horn.lean index 70e0fbfb413bf6..a7c651c699abb9 100644 --- a/Mathlib/AlgebraicTopology/SimplicialSet/Horn.lean +++ b/Mathlib/AlgebraicTopology/SimplicialSet/Horn.lean @@ -94,7 +94,7 @@ lemma horn_obj_eq_univ {n : ℕ} (i : Fin (n + 1)) (m : ℕ) (h : m + 1 < n := b Finset.card_singleton, add_le_add_iff_right] at this have : n ≤ m + 1 := by simpa using this.trans Finset.card_image_le lia - have : ∃ j, ¬j = i ∧ ∀ (i : Fin (m + 1)), ¬(stdSimplex.objEquiv.symm.{u} f) i = j := + have : ∃ j, ¬j = i ∧ ∀ (i : Fin (m + 1)), ¬(stdSimplex.objEquiv.{u}.symm f) i = j := ⟨j, hij, fun k hk ↦ hj ⟨k, hk⟩⟩ simpa [horn_eq_iSup] using this @@ -140,7 +140,7 @@ lemma face_le_horn_iff {n : ℕ} (S : Finset (Fin (n + 2))) (j : Fin (n + 2)) : lemma objEquiv_symm_notMem_horn_of_isIso {n : ℕ} (i : Fin (n + 1)) {d : SimplexCategory} (f : d ⟶ ⦋n⦌) [IsIso f] : - stdSimplex.objEquiv.symm.{u} f ∉ Λ[n, i].obj (op d) := by + stdSimplex.objEquiv.{u}.symm f ∉ Λ[n, i].obj (op d) := by rw [mem_horn_iff, ne_eq, not_not] ext i simpa using Or.inr ⟨inv f i, by simp [stdSimplex.coe_asOrderHom_objEquiv_symm.{u}]⟩ diff --git a/MathlibTest/ToDual.lean b/MathlibTest/ToDual.lean index b9bb47f4ad4a2b..d3139be878fdc1 100644 --- a/MathlibTest/ToDual.lean +++ b/MathlibTest/ToDual.lean @@ -31,6 +31,7 @@ structure Lattice (α : Type) extends SemilatticeInf α, SemilatticeSup α attribute [to_dual existing] Lattice.toSemilatticeInf +set_option linter.impossibleInstance false in -- we can reorder arguments of arguments in `SemilatticeInf.mk` @[to_dual] instance [Min α] (le_inf : ∀ a b c : α, a ≤ b → a ≤ c → a ≤ b ⊓ c) : SemilatticeInf α where From d33ab3c2f6868cec700797a06ded94870a2facc5 Mon Sep 17 00:00:00 2001 From: Kim Morrison Date: Sat, 18 Apr 2026 08:33:12 +1000 Subject: [PATCH 094/321] fixes --- MathlibTest/ToDual.lean | 1 - lake-manifest.json | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/MathlibTest/ToDual.lean b/MathlibTest/ToDual.lean index d3139be878fdc1..b9bb47f4ad4a2b 100644 --- a/MathlibTest/ToDual.lean +++ b/MathlibTest/ToDual.lean @@ -31,7 +31,6 @@ structure Lattice (α : Type) extends SemilatticeInf α, SemilatticeSup α attribute [to_dual existing] Lattice.toSemilatticeInf -set_option linter.impossibleInstance false in -- we can reorder arguments of arguments in `SemilatticeInf.mk` @[to_dual] instance [Min α] (le_inf : ∀ a b c : α, a ≤ b → a ≤ c → a ≤ b ⊓ c) : SemilatticeInf α where diff --git a/lake-manifest.json b/lake-manifest.json index a368a0a46ff776..96cf216690b058 100644 --- a/lake-manifest.json +++ b/lake-manifest.json @@ -65,7 +65,7 @@ "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "3b89330c9c0ccaeed89cf99b2cd292722e3495c9", + "rev": "4b591181697264394a76288a163fd1d47621c96e", "name": "batteries", "manifestFile": "lake-manifest.json", "inputRev": "nightly-testing", From 4f40f6e9ea040b62de44119404d38ef214b7efda Mon Sep 17 00:00:00 2001 From: Kim Morrison Date: Sat, 18 Apr 2026 09:15:56 +1000 Subject: [PATCH 095/321] fix Init filter in MinImports --- Mathlib/Tactic/Linter/MinImports.lean | 4 ++-- Mathlib/Tactic/MinImports.lean | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Mathlib/Tactic/Linter/MinImports.lean b/Mathlib/Tactic/Linter/MinImports.lean index ae2a42c439c518..ddfbb78c56a2a2 100644 --- a/Mathlib/Tactic/Linter/MinImports.lean +++ b/Mathlib/Tactic/Linter/MinImports.lean @@ -125,7 +125,7 @@ def minImportsLinter : Linter where run := withSetOptionIn fun stx ↦ do -- when the linter reaches the end of the file or `#exit`, it gives a report if #[``Parser.Command.eoi, ``Lean.Parser.Command.exit].contains stx.getKind then let explicitImportsInFile : NameSet := - .ofArray ((env.imports.map (·.module)).erase `Init) + .ofArray ((env.imports.map (·.module)).filter (!isInitImport ·)) let newImps := importsSoFar \ explicitImportsInFile let currentlyUnneededImports := explicitImportsInFile \ importsSoFar -- we read the current file, to do a custom parsing of the imports: @@ -146,7 +146,7 @@ def minImportsLinter : Linter where run := withSetOptionIn fun stx ↦ do logWarningAt ((impMods.raw.find? (·.isOfKind `import)).getD default) m!"-- missing imports\n{"\n".intercalate withImport.toList}" let id ← getId stx - let newImports := getIrredundantImports env (← getAllImports stx id) + let newImports := (getIrredundantImports env (← getAllImports stx id)).filter (!isInitImport ·) let tot := (newImports.append importsSoFar) let redundant := env.findRedundantImports tot.toArray let currImports := tot \ redundant diff --git a/Mathlib/Tactic/MinImports.lean b/Mathlib/Tactic/MinImports.lean index 9d5f781fece6ed..732ae93bb3ddda 100644 --- a/Mathlib/Tactic/MinImports.lean +++ b/Mathlib/Tactic/MinImports.lean @@ -64,6 +64,13 @@ open Lean Elab Command namespace Mathlib.Command.MinImports +/-- Returns `true` if `n` is `Init` or a descendant of `Init`. These imports are always available +in ordinary Mathlib files, so they are omitted from user-facing `#min_imports` output. -/ +partial def isInitImport : Name → Bool + | `Init => true + | .str p _ => isInitImport p + | _ => false + /-- `getSyntaxNodeKinds stx` takes a `Syntax` input `stx` and returns the `NameSet` of all the `SyntaxNodeKinds` and all the identifiers contained in `stx`. -/ partial @@ -251,7 +258,7 @@ It is used to provide the internally generated name for "nameless" `instance`s. -/ def minImpsCore (stx id : Syntax) : CommandElabM Unit := do let tot := getIrredundantImports (← getEnv) (← getAllImports stx id) - let fileNames := tot.toArray.qsort Name.lt + let fileNames := (tot.toArray.filter (!isInitImport ·)).qsort Name.lt logInfoAt (← getRef) m!"{"\n".intercalate (fileNames.map (s!"public import {·}")).toList}" /-- `#min_imports in cmd` scans the syntax `cmd` and the declaration obtained by elaborating `cmd` From 5b25c4e4eec9efe42ad274ea04e38566ce0f6bd1 Mon Sep 17 00:00:00 2001 From: Kim Morrison Date: Sat, 18 Apr 2026 23:11:30 +0000 Subject: [PATCH 096/321] fix test --- MathlibTest/ToDual.lean | 1 - 1 file changed, 1 deletion(-) diff --git a/MathlibTest/ToDual.lean b/MathlibTest/ToDual.lean index 6b9b943762830d..f7958b84b06ade 100644 --- a/MathlibTest/ToDual.lean +++ b/MathlibTest/ToDual.lean @@ -32,7 +32,6 @@ structure Lattice (α : Type) extends SemilatticeInf α, SemilatticeSup α attribute [to_dual existing] Lattice.toSemilatticeInf -- we can reorder arguments of arguments in `SemilatticeInf.mk` -set_option linter.impossibleInstance false in @[to_dual, reducible] def le_inf_test [Min α] (le_inf : ∀ a b c : α, a ≤ b → a ≤ c → a ≤ b ⊓ c) : SemilatticeInf α where le_inf From 6723fdb82b64238061a7962d9d25487c3264828b Mon Sep 17 00:00:00 2001 From: Kim Morrison Date: Sun, 19 Apr 2026 03:11:55 +0000 Subject: [PATCH 097/321] add set_options --- Mathlib/Algebra/BigOperators/Group/Finset/Basic.lean | 1 + Mathlib/Algebra/Homology/DerivedCategory/Basic.lean | 2 ++ Mathlib/Algebra/Lie/Free.lean | 3 +++ Mathlib/Algebra/Lie/NonUnitalNonAssocAlgebra.lean | 2 ++ Mathlib/Analysis/CStarAlgebra/Matrix.lean | 1 + Mathlib/CategoryTheory/Monoidal/Free/Coherence.lean | 1 + Mathlib/CategoryTheory/Pi/Basic.lean | 2 ++ Mathlib/CategoryTheory/Shift/Adjunction.lean | 1 + Mathlib/CategoryTheory/Shift/Twist.lean | 1 + Mathlib/CategoryTheory/Triangulated/Adjunction.lean | 1 + Mathlib/Combinatorics/SimpleGraph/Extremal/Turan.lean | 1 + Mathlib/Geometry/Manifold/IntegralCurve/ExistUnique.lean | 1 + Mathlib/Geometry/Manifold/MFDeriv/Basic.lean | 3 +++ Mathlib/Geometry/Manifold/MFDeriv/FDeriv.lean | 1 + Mathlib/Geometry/Manifold/Riemannian/Basic.lean | 7 +++++++ Mathlib/Geometry/Manifold/VectorField/LieBracket.lean | 1 + 16 files changed, 29 insertions(+) diff --git a/Mathlib/Algebra/BigOperators/Group/Finset/Basic.lean b/Mathlib/Algebra/BigOperators/Group/Finset/Basic.lean index 28bdc737819ec3..4acec705b10a28 100644 --- a/Mathlib/Algebra/BigOperators/Group/Finset/Basic.lean +++ b/Mathlib/Algebra/BigOperators/Group/Finset/Basic.lean @@ -153,6 +153,7 @@ lemma prod_filter_not_mul_prod_filter (s : Finset ι) (p : ι → Prop) [Decidab (∏ x ∈ s with ¬p x, f x) * ∏ x ∈ s with p x, f x = ∏ x ∈ s, f x := by rw [mul_comm, prod_filter_mul_prod_filter_not] +set_option backward.isDefEq.respectTransparency false in @[to_additive] theorem prod_filter_xor (p q : ι → Prop) [DecidablePred p] [DecidablePred q] : (∏ x ∈ s with (Xor' (p x) (q x)), f x) = diff --git a/Mathlib/Algebra/Homology/DerivedCategory/Basic.lean b/Mathlib/Algebra/Homology/DerivedCategory/Basic.lean index 5113b5c5311b34..9826c7a0af2fa4 100644 --- a/Mathlib/Algebra/Homology/DerivedCategory/Basic.lean +++ b/Mathlib/Algebra/Homology/DerivedCategory/Basic.lean @@ -94,6 +94,7 @@ variable {C} /-- The localization functor `CochainComplex C ℤ ⥤ DerivedCategory C`. -/ def Q : CochainComplex C ℤ ⥤ DerivedCategory C := HomologicalComplexUpToQuasiIso.Q +set_option backward.isDefEq.respectTransparency false in instance : (Q (C := C)).IsLocalization (HomologicalComplex.quasiIso C (ComplexShape.up ℤ)) := by dsimp only [Q, DerivedCategory] @@ -114,6 +115,7 @@ variable (C) def quotientCompQhIso : HomotopyCategory.quotient C (ComplexShape.up ℤ) ⋙ Qh ≅ Q := HomologicalComplexUpToQuasiIso.quotientCompQhIso C (ComplexShape.up ℤ) +set_option backward.isDefEq.respectTransparency false in instance : Qh.IsLocalization (HomotopyCategory.quasiIso C (ComplexShape.up ℤ)) := by dsimp [Qh, DerivedCategory] infer_instance diff --git a/Mathlib/Algebra/Lie/Free.lean b/Mathlib/Algebra/Lie/Free.lean index a57c27ee357639..d92c65136e24f6 100644 --- a/Mathlib/Algebra/Lie/Free.lean +++ b/Mathlib/Algebra/Lie/Free.lean @@ -181,6 +181,7 @@ def of : X → FreeLieAlgebra R X := fun x => Quot.mk _ (lib.of R x) variable {L : Type w} [LieRing L] [LieAlgebra R L] +set_option backward.isDefEq.respectTransparency false in /-- An auxiliary definition used to construct the equivalence `lift` below. -/ def liftAux (f : X → CommutatorRing L) := lib.lift R f @@ -197,6 +198,7 @@ theorem liftAux_map_mul (f : X → L) (a b : lib R X) : liftAux R f (a * b) = ⁅liftAux R f a, liftAux R f b⁆ := map_mul _ a b +set_option backward.isDefEq.respectTransparency false in theorem liftAux_spec (f : X → L) (a b : lib R X) (h : FreeLieAlgebra.Rel R X a b) : liftAux R f a = liftAux R f b := by induction h with @@ -208,6 +210,7 @@ theorem liftAux_spec (f : X → L) (a b : lib R X) (h : FreeLieAlgebra.Rel R X a | mul_left c' _ h₂ => simp only [liftAux_map_mul, h₂] | mul_right c' _ h₂ => simp only [liftAux_map_mul, h₂] +set_option backward.isDefEq.respectTransparency false in /-- The quotient map as a `NonUnitalAlgHom`. -/ def mk : lib R X →ₙₐ[R] CommutatorRing (FreeLieAlgebra R X) where toFun := Quot.mk (Rel R X) diff --git a/Mathlib/Algebra/Lie/NonUnitalNonAssocAlgebra.lean b/Mathlib/Algebra/Lie/NonUnitalNonAssocAlgebra.lean index 3adc22863c3d97..34a498271a86f8 100644 --- a/Mathlib/Algebra/Lie/NonUnitalNonAssocAlgebra.lean +++ b/Mathlib/Algebra/Lie/NonUnitalNonAssocAlgebra.lean @@ -78,6 +78,7 @@ namespace LieHom variable {R L} variable {L₂ : Type w} [LieRing L₂] [LieAlgebra R L₂] +set_option backward.isDefEq.respectTransparency false in /-- Regarding the `LieRing` of a `LieAlgebra` as a `NonUnitalNonAssocRing`, we can regard a `LieHom` as a `NonUnitalAlgHom`. -/ @[simps] @@ -87,6 +88,7 @@ def toNonUnitalAlgHom (f : L →ₗ⁅R⁆ L₂) : CommutatorRing L →ₙₐ[R] map_zero' := f.toLinearMap.map_zero map_mul' := f.map_lie } +set_option backward.isDefEq.respectTransparency false in theorem toNonUnitalAlgHom_injective : Function.Injective (toNonUnitalAlgHom : _ → CommutatorRing L →ₙₐ[R] CommutatorRing L₂) := fun _ _ h => ext <| NonUnitalAlgHom.congr_fun h diff --git a/Mathlib/Analysis/CStarAlgebra/Matrix.lean b/Mathlib/Analysis/CStarAlgebra/Matrix.lean index 7d4a867e9e28da..49b0f9da83c61f 100644 --- a/Mathlib/Analysis/CStarAlgebra/Matrix.lean +++ b/Mathlib/Analysis/CStarAlgebra/Matrix.lean @@ -152,6 +152,7 @@ def l2OpNormedRingAux : NormedRing (Matrix n n 𝕜) := open Bornology Filter open scoped Topology Uniformity +set_option backward.isDefEq.respectTransparency false in /-- The metric on `Matrix m n 𝕜` arising from the operator norm given by the identification with (continuous) linear maps of `EuclideanSpace`. -/ @[instance_reducible] diff --git a/Mathlib/CategoryTheory/Monoidal/Free/Coherence.lean b/Mathlib/CategoryTheory/Monoidal/Free/Coherence.lean index 264d9b44912b90..006e7944cc975b 100644 --- a/Mathlib/CategoryTheory/Monoidal/Free/Coherence.lean +++ b/Mathlib/CategoryTheory/Monoidal/Free/Coherence.lean @@ -135,6 +135,7 @@ section variable (C) +set_option backward.isDefEq.respectTransparency false in /-- Our normalization procedure works by first defining a functor `F C ⥤ (N C ⥤ N C)` (which turns out to be very easy), and then obtain a functor `F C ⥤ N C` by plugging in the normal object `𝟙_ C`. -/ diff --git a/Mathlib/CategoryTheory/Pi/Basic.lean b/Mathlib/CategoryTheory/Pi/Basic.lean index e606d46769205b..77c561baf3be22 100644 --- a/Mathlib/CategoryTheory/Pi/Basic.lean +++ b/Mathlib/CategoryTheory/Pi/Basic.lean @@ -102,6 +102,7 @@ def comapComp (f : K → J) (g : J → I) : comap C g ⋙ comap (C ∘ g) f ≅ { app := fun X b => 𝟙 (X (g (f b))) naturality := fun X Y f' => by simp only [comap, Function.comp]; funext; simp } +set_option backward.isDefEq.respectTransparency false in /-- The natural isomorphism between pulling back then evaluating, and just evaluating. -/ @[simps!] def comapEvalIsoEval (h : J → I) (j : J) : comap C h ⋙ eval (C ∘ h) j ≅ eval C (h j) := @@ -117,6 +118,7 @@ instance sumElimCategory : ∀ s : I ⊕ J, Category.{v₁} (Sum.elim C D s) | Sum.inl i => inferInstanceAs <| Category (C i) | Sum.inr j => inferInstanceAs <| Category (D j) +set_option backward.isDefEq.respectTransparency false in /-- The bifunctor combining an `I`-indexed family of objects with a `J`-indexed family of objects to obtain an `I ⊕ J`-indexed family of objects. -/ diff --git a/Mathlib/CategoryTheory/Shift/Adjunction.lean b/Mathlib/CategoryTheory/Shift/Adjunction.lean index 82a687d760a59e..8aec9c19e83b7b 100644 --- a/Mathlib/CategoryTheory/Shift/Adjunction.lean +++ b/Mathlib/CategoryTheory/Shift/Adjunction.lean @@ -612,6 +612,7 @@ this constructs the unique compatible `CommShift` structure on `E.functor`. noncomputable def commShiftFunctor [E.inverse.CommShift A] : E.functor.CommShift A := E.symm.toAdjunction.rightAdjointCommShift A +set_option backward.isDefEq.respectTransparency false in lemma commShift_of_inverse [E.inverse.CommShift A] : letI := E.commShiftFunctor A E.CommShift A := by diff --git a/Mathlib/CategoryTheory/Shift/Twist.lean b/Mathlib/CategoryTheory/Shift/Twist.lean index b76fea481b7617..e8a8b8707e01fb 100644 --- a/Mathlib/CategoryTheory/Shift/Twist.lean +++ b/Mathlib/CategoryTheory/Shift/Twist.lean @@ -92,6 +92,7 @@ identify to the shift functors on `C`. -/ noncomputable def shiftIso (m : A) : shiftFunctor t.Category m ≅ shiftFunctor C m := Iso.refl _ +set_option backward.isDefEq.respectTransparency false in lemma shiftFunctor_map {X Y : t.Category} (f : X ⟶ Y) (m : A) : (shiftFunctor t.Category m).map f = (t.shiftIso m).hom.app X ≫ (shiftFunctor C m).map f ≫ (t.shiftIso m).inv.app Y := by diff --git a/Mathlib/CategoryTheory/Triangulated/Adjunction.lean b/Mathlib/CategoryTheory/Triangulated/Adjunction.lean index e72a464aa967cc..c675701114d640 100644 --- a/Mathlib/CategoryTheory/Triangulated/Adjunction.lean +++ b/Mathlib/CategoryTheory/Triangulated/Adjunction.lean @@ -201,6 +201,7 @@ instance [h : E.inverse.IsTriangulated] : E.symm.functor.IsTriangulated := h lemma mk' (h : E.functor.IsTriangulated) : E.IsTriangulated where rightAdjoint_isTriangulated := E.toAdjunction.isTriangulated_rightAdjoint +set_option backward.isDefEq.respectTransparency false in /-- Constructor for `Equivalence.IsTriangulated`. -/ lemma mk'' (h : E.inverse.IsTriangulated) : E.IsTriangulated where leftAdjoint_isTriangulated := (mk' E.symm h).rightAdjoint_isTriangulated diff --git a/Mathlib/Combinatorics/SimpleGraph/Extremal/Turan.lean b/Mathlib/Combinatorics/SimpleGraph/Extremal/Turan.lean index 3f74a28e62c4fa..2104609b186b26 100644 --- a/Mathlib/Combinatorics/SimpleGraph/Extremal/Turan.lean +++ b/Mathlib/Combinatorics/SimpleGraph/Extremal/Turan.lean @@ -344,6 +344,7 @@ private lemma sum_ne_add_mod_eq_sub_one {c : ℕ} : rw [Nat.add_mod_mod, ← add_assoc, ← one_add_mul, show 1 + (r - 1) = r by lia, Nat.mul_add_mod_self_left] +set_option backward.isDefEq.respectTransparency false in lemma card_edgeFinset_turanGraph_add : #(turanGraph (n + r) r).edgeFinset = #(turanGraph n r).edgeFinset + n * (r - 1) + r.choose 2 := by diff --git a/Mathlib/Geometry/Manifold/IntegralCurve/ExistUnique.lean b/Mathlib/Geometry/Manifold/IntegralCurve/ExistUnique.lean index f973a3e23f437b..3adba4db1939fb 100644 --- a/Mathlib/Geometry/Manifold/IntegralCurve/ExistUnique.lean +++ b/Mathlib/Geometry/Manifold/IntegralCurve/ExistUnique.lean @@ -57,6 +57,7 @@ variable {M : Type*} [TopologicalSpace M] [ChartedSpace H M] [IsManifold I 1 M] {γ γ' : ℝ → M} {v : (x : M) → TangentSpace I x} {s s' : Set ℝ} (t₀ : ℝ) {x₀ : M} +set_option backward.isDefEq.respectTransparency false in /-- Existence of local integral curves for a $C^1$ vector field at interior points of a `C^1` manifold. -/ theorem exists_isMIntegralCurveAt_of_contMDiffAt [CompleteSpace E] diff --git a/Mathlib/Geometry/Manifold/MFDeriv/Basic.lean b/Mathlib/Geometry/Manifold/MFDeriv/Basic.lean index d38f6ab791ac74..d2a74b421108ca 100644 --- a/Mathlib/Geometry/Manifold/MFDeriv/Basic.lean +++ b/Mathlib/Geometry/Manifold/MFDeriv/Basic.lean @@ -514,6 +514,7 @@ theorem writtenInExtChartAt_comp (h : ContinuousWithinAt f s x) : variable {f' f₀' f₁' : TangentSpace I x →L[𝕜] TangentSpace I' (f x)} {g' : TangentSpace I' (f x) →L[𝕜] TangentSpace I'' (g (f x))} +set_option backward.isDefEq.respectTransparency false in /-- `UniqueMDiffWithinAt` achieves its goal: it implies the uniqueness of the derivative. -/ protected nonrec theorem UniqueMDiffWithinAt.eq (U : UniqueMDiffWithinAt I s x) (h : HasMFDerivWithinAt I I' f s x f') (h₁ : HasMFDerivWithinAt I I' f s x f₁') : f' = f₁' := by @@ -717,6 +718,7 @@ lemma mfderivWithin_of_isOpen (hs : IsOpen s) (hx : x ∈ s) : mfderivWithin I I' f s x = mfderiv I I' f x := mfderivWithin_of_mem_nhds (hs.mem_nhds hx) +set_option backward.isDefEq.respectTransparency false in theorem hasMFDerivWithinAt_insert {y : M} : HasMFDerivWithinAt I I' f (insert y s) x f' ↔ HasMFDerivWithinAt I I' f s x f' := by have : T1Space M := I.t1Space M @@ -1115,6 +1117,7 @@ theorem mfderiv_congr {f' : M → M'} (h : f = f') : variable (x) +set_option backward.isDefEq.respectTransparency false in theorem HasMFDerivWithinAt.comp (hg : HasMFDerivWithinAt I' I'' g u (f x) g') (hf : HasMFDerivWithinAt I I' f s x f') (hst : s ⊆ f ⁻¹' u) : HasMFDerivWithinAt I I'' (g ∘ f) s x (g'.comp f') := by diff --git a/Mathlib/Geometry/Manifold/MFDeriv/FDeriv.lean b/Mathlib/Geometry/Manifold/MFDeriv/FDeriv.lean index 0226b4ec77ac3d..fb7321bf9001b9 100644 --- a/Mathlib/Geometry/Manifold/MFDeriv/FDeriv.lean +++ b/Mathlib/Geometry/Manifold/MFDeriv/FDeriv.lean @@ -50,6 +50,7 @@ the simpNF linter complains about this being `@[simp]`. -/ theorem writtenInExtChartAt_model_space : writtenInExtChartAt 𝓘(𝕜, E) 𝓘(𝕜, E') x f = f := rfl +set_option backward.isDefEq.respectTransparency false in theorem hasMFDerivWithinAt_iff_hasFDerivWithinAt {f'} : HasMFDerivWithinAt 𝓘(𝕜, E) 𝓘(𝕜, E') f s x f' ↔ HasFDerivWithinAt f f' s x := by simpa only [HasMFDerivWithinAt, and_iff_right_iff_imp, mfld_simps] using diff --git a/Mathlib/Geometry/Manifold/Riemannian/Basic.lean b/Mathlib/Geometry/Manifold/Riemannian/Basic.lean index f3b1a21af91a0e..f2a06a9857450f 100644 --- a/Mathlib/Geometry/Manifold/Riemannian/Basic.lean +++ b/Mathlib/Geometry/Manifold/Riemannian/Basic.lean @@ -238,6 +238,7 @@ attribute [local instance] normedSpaceTangentSpaceVectorSpace variable (I) +set_option backward.isDefEq.respectTransparency false in lemma eventually_norm_mfderiv_extChartAt_lt (x : M) : ∃ C > 0, ∀ᶠ y in 𝓝 x, ‖mfderiv% (extChartAt I x) y‖ < C := by rcases eventually_norm_trivializationAt_lt E (fun (x : M) ↦ TangentSpace I x) x @@ -247,6 +248,7 @@ lemma eventually_norm_mfderiv_extChartAt_lt (x : M) : filter_upwards [hC, hx] with y hy h'y rwa [← TangentBundle.continuousLinearMapAt_trivializationAt h'y] +set_option backward.isDefEq.respectTransparency false in lemma eventually_enorm_mfderiv_extChartAt_lt (x : M) : ∃ C > (0 : ℝ≥0), ∀ᶠ y in 𝓝 x, ‖mfderiv% (extChartAt I x) y‖ₑ < C := by rcases eventually_norm_mfderiv_extChartAt_lt I x with ⟨C, C_pos, hC⟩ @@ -257,6 +259,7 @@ lemma eventually_enorm_mfderiv_extChartAt_lt (x : M) : simp only [enorm, nnnorm] exact_mod_cast hy +set_option backward.isDefEq.respectTransparency false in lemma eventually_norm_mfderivWithin_symm_extChartAt_comp_lt (x : M) : ∃ C > 0, ∀ᶠ y in 𝓝 x, ‖mfderiv[range I] (extChartAt I x).symm (extChartAt I x y)‖ < C := by rcases eventually_norm_symmL_trivializationAt_lt E (fun (x : M) ↦ TangentSpace I x) x @@ -269,6 +272,7 @@ lemma eventually_norm_mfderivWithin_symm_extChartAt_comp_lt (x : M) : (extChartAt I x).left_inv (by simpa using h'y) convert hy using 3 <;> congr +set_option backward.isDefEq.respectTransparency false in lemma eventually_norm_mfderivWithin_symm_extChartAt_lt (x : M) : ∃ C > 0, ∀ᶠ y in 𝓝[range I] (extChartAt I x x), ‖mfderiv[range I] (extChartAt I x).symm y‖ < C := by @@ -283,6 +287,7 @@ lemma eventually_norm_mfderivWithin_symm_extChartAt_lt (x : M) : simp only [preimage_setOf_eq, mem_setOf_eq] at hy convert hy +set_option backward.isDefEq.respectTransparency false in lemma eventually_enorm_mfderivWithin_symm_extChartAt_lt (x : M) : ∃ C > (0 : ℝ≥0), ∀ᶠ y in 𝓝[range I] (extChartAt I x x), ‖mfderiv[range I] (extChartAt I x).symm y‖ₑ < C := by @@ -294,6 +299,7 @@ lemma eventually_enorm_mfderivWithin_symm_extChartAt_lt (x : M) : simp only [enorm, nnnorm] exact_mod_cast hy +set_option backward.isDefEq.respectTransparency false in /-- Around any point `x`, the Riemannian distance between two points is controlled by the distance in the extended chart. In other words, the extended chart is locally Lipschitz. -/ lemma eventually_riemannianEDist_le_edist_extChartAt (x : M) : @@ -378,6 +384,7 @@ lemma eventually_riemannianEDist_lt (x : M) {c : ℝ≥0∞} (hc : 0 < c) : · exact Or.inl (mod_cast C_pos.ne') · simp +set_option backward.isDefEq.respectTransparency false in /-- Any neighborhood of `x` contains all the points which are close enough to `x` for the Riemannian distance, `ℝ≥0` version. -/ lemma setOf_riemannianEDist_lt_subset_nhds [RegularSpace M] {x : M} {s : Set M} (hs : s ∈ 𝓝 x) : diff --git a/Mathlib/Geometry/Manifold/VectorField/LieBracket.lean b/Mathlib/Geometry/Manifold/VectorField/LieBracket.lean index 601b1cf94125de..aacb1b22da23c5 100644 --- a/Mathlib/Geometry/Manifold/VectorField/LieBracket.lean +++ b/Mathlib/Geometry/Manifold/VectorField/LieBracket.lean @@ -207,6 +207,7 @@ theorem mlieBracketWithin_eventually_congr_set (h : s =ᶠ[𝓝 x] t) : mlieBracketWithin I V W s =ᶠ[𝓝 x] mlieBracketWithin I V W t := mlieBracketWithin_eventually_congr_set' x <| h.filter_mono inf_le_left +set_option backward.isDefEq.respectTransparency false in theorem _root_.Filter.EventuallyEq.mlieBracketWithin_vectorField_eq (hV : V₁ =ᶠ[𝓝[s] x] V) (hxV : V₁ x = V x) (hW : W₁ =ᶠ[𝓝[s] x] W) (hxW : W₁ x = W x) : mlieBracketWithin I V₁ W₁ s x = mlieBracketWithin I V W s x := by From 4c45d0e081543d13f714a1c4c7511b5ec12cc1bb Mon Sep 17 00:00:00 2001 From: "mathlib-nightly-testing[bot]" Date: Sun, 19 Apr 2026 09:22:25 +0000 Subject: [PATCH 098/321] chore: bump to nightly-2026-04-19 --- lean-toolchain | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lean-toolchain b/lean-toolchain index 474b1d259a11e1..1883470497275d 100644 --- a/lean-toolchain +++ b/lean-toolchain @@ -1 +1 @@ -leanprover/lean4:nightly-2026-04-17 +leanprover/lean4:nightly-2026-04-19 From eaa4c1f5f5dae95eae9121a7367d849d9d521bd8 Mon Sep 17 00:00:00 2001 From: "mathlib-nightly-testing[bot]" Date: Mon, 20 Apr 2026 09:49:18 +0000 Subject: [PATCH 099/321] chore: bump to nightly-2026-04-20 --- lean-toolchain | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lean-toolchain b/lean-toolchain index 1883470497275d..f4ad0908656808 100644 --- a/lean-toolchain +++ b/lean-toolchain @@ -1 +1 @@ -leanprover/lean4:nightly-2026-04-19 +leanprover/lean4:nightly-2026-04-20 From 9d91c9df28cc24f6ac0fe33ffefd02cf1ba7470b Mon Sep 17 00:00:00 2001 From: Kim Morrison Date: Tue, 21 Apr 2026 01:53:39 +0000 Subject: [PATCH 100/321] fix bad merge --- Mathlib/Analysis/CStarAlgebra/CStarMatrix.lean | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Mathlib/Analysis/CStarAlgebra/CStarMatrix.lean b/Mathlib/Analysis/CStarAlgebra/CStarMatrix.lean index 3fde74fdd517d6..6d0c444536dbd5 100644 --- a/Mathlib/Analysis/CStarAlgebra/CStarMatrix.lean +++ b/Mathlib/Analysis/CStarAlgebra/CStarMatrix.lean @@ -344,7 +344,6 @@ instance instNonUnitalSemiring [Fintype n] [NonUnitalSemiring A] : NonUnitalSemiring (CStarMatrix n n A) := inferInstanceAs <| NonUnitalSemiring (Matrix n n A) -set_option backward.inferInstanceAs.wrap false in instance instNonAssocSemiring [Fintype n] [DecidableEq n] [NonAssocSemiring A] : NonAssocSemiring (CStarMatrix n n A) := inferInstanceAs <| NonAssocSemiring (Matrix n n A) @@ -353,17 +352,14 @@ instance instNonUnitalRing [Fintype n] [NonUnitalRing A] : NonUnitalRing (CStarMatrix n n A) := inferInstanceAs <| NonUnitalRing (Matrix n n A) -set_option backward.inferInstanceAs.wrap false in instance instNonAssocRing [Fintype n] [DecidableEq n] [NonAssocRing A] : NonAssocRing (CStarMatrix n n A) := inferInstanceAs <| NonAssocRing (Matrix n n A) -set_option backward.inferInstanceAs.wrap false in instance instSemiring [Fintype n] [DecidableEq n] [Semiring A] : Semiring (CStarMatrix n n A) := inferInstanceAs <| Semiring (Matrix n n A) -set_option backward.inferInstanceAs.wrap false in instance instRing [Fintype n] [DecidableEq n] [Ring A] : Ring (CStarMatrix n n A) := inferInstanceAs <| Ring (Matrix n n A) From 67244f5852012269befab8549db4653a4eced0a4 Mon Sep 17 00:00:00 2001 From: Kim Morrison Date: Tue, 21 Apr 2026 01:55:56 +0000 Subject: [PATCH 101/321] fix #guard_msgs output --- MathlibTest/GCongr/GCongr.lean | 2 +- MathlibTest/GRewrite.lean | 4 ++-- MathlibTest/Linarith/Basic.lean | 1 - MathlibTest/congr.lean | 1 - MathlibTest/conv_widget.lean | 9 +++------ 5 files changed, 6 insertions(+), 11 deletions(-) diff --git a/MathlibTest/GCongr/GCongr.lean b/MathlibTest/GCongr/GCongr.lean index 3cb0b28ac3808b..bc179f0ac16bc5 100644 --- a/MathlibTest/GCongr/GCongr.lean +++ b/MathlibTest/GCongr/GCongr.lean @@ -48,7 +48,7 @@ a b c d : ℕ h : b~d ⊢ a~a -case a.a +case a a b c d : ℕ h : b~d ⊢ c~c diff --git a/MathlibTest/GRewrite.lean b/MathlibTest/GRewrite.lean index 02d182d02c77eb..2b448a18bb9595 100644 --- a/MathlibTest/GRewrite.lean +++ b/MathlibTest/GRewrite.lean @@ -215,7 +215,7 @@ the inequality goes in the wrong direction). -/ /-- error: Tactic `grewrite` failed: could not discharge x ≤ y using x ≥ y -case h₁.hbc +case hbc x y b : ℚ h : x ≥ y ⊢ x ≤ y @@ -257,7 +257,7 @@ example {Prime : ℕ → Prop} {a a' : ℕ} (h₁ : Prime (a + 1)) (h₂ : a = a /-- error: Tactic `grewrite` failed: could not discharge b ≤ a using a ≤ b -case h₂.hbc +case hbc a b c : ℚ h₁ : a ≤ b h₂ : 0 ≤ c diff --git a/MathlibTest/Linarith/Basic.lean b/MathlibTest/Linarith/Basic.lean index cd2a2ff1e417f4..eab07a23d41037 100644 --- a/MathlibTest/Linarith/Basic.lean +++ b/MathlibTest/Linarith/Basic.lean @@ -728,7 +728,6 @@ example (x : ℤ) : 0 ≤ x * wrapped x := by nlinarith def tightlyWrapped (z : ℤ) : ℤ := z /-- error: linarith failed to find a contradiction -case h x : ℤ a✝ : x * tightlyWrapped x < 0 ⊢ False diff --git a/MathlibTest/congr.lean b/MathlibTest/congr.lean index 6059cfc331d35a..2a464de012202e 100644 --- a/MathlibTest/congr.lean +++ b/MathlibTest/congr.lean @@ -332,7 +332,6 @@ example (inst1 : BEq α) [LawfulBEq α] (inst2 : BEq α) [LawfulBEq α] (xs : Li /-- error: unsolved goals -case h.e'_2 α : Type inst1 : BEq α inst✝¹ : LawfulBEq α diff --git a/MathlibTest/conv_widget.lean b/MathlibTest/conv_widget.lean index aa96c24b73c7a0..0a3c1f34fa301a 100644 --- a/MathlibTest/conv_widget.lean +++ b/MathlibTest/conv_widget.lean @@ -83,8 +83,7 @@ conv => enter [1, x, 5] skip --- -trace: case h -x : False +trace: x : False | true -/ #guard_msgs in @@ -115,8 +114,7 @@ conv => enter [1, 0, x, 1] skip --- -trace: case h -x : Unit +trace: x : Unit | false -/ #guard_msgs in @@ -384,8 +382,7 @@ conv => enter [1, 0, x0, x1, x2, 2] skip --- -trace: case h.h.h -x0 x1 x2 : Bool → Nat +trace: x0 x1 x2 : Bool → Nat | x2 true -/ #guard_msgs in From 29995273c5236e718e39db2c6a088fe7da99e6dd Mon Sep 17 00:00:00 2001 From: leanprover-community-mathlib4-bot Date: Tue, 21 Apr 2026 12:11:38 +0000 Subject: [PATCH 102/321] Update lean-toolchain for testing https://github.com/leanprover/lean4/pull/13492 --- lake-manifest.json | 4 ++-- lakefile.lean | 2 +- lean-toolchain | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lake-manifest.json b/lake-manifest.json index 293d1fb2c907ed..07476a69d83465 100644 --- a/lake-manifest.json +++ b/lake-manifest.json @@ -65,10 +65,10 @@ "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "4b591181697264394a76288a163fd1d47621c96e", + "rev": "d700e0ed112983911ba9a2e0ae08c7a2abf78770", "name": "batteries", "manifestFile": "lake-manifest.json", - "inputRev": "nightly-testing", + "inputRev": "lean-pr-testing-13492", "inherited": false, "configFile": "lakefile.toml"}, {"url": "https://github.com/leanprover/lean4-cli", diff --git a/lakefile.lean b/lakefile.lean index babb657761237b..01139cd9a10a64 100644 --- a/lakefile.lean +++ b/lakefile.lean @@ -6,7 +6,7 @@ open Lake DSL ## Mathlib dependencies on upstream projects -/ -require "leanprover-community" / "batteries" @ git "nightly-testing" +require "leanprover-community" / "batteries" @ git "lean-pr-testing-13492" require "leanprover-community" / "Qq" @ git "nightly-testing" require "leanprover-community" / "aesop" @ git "nightly-testing" require "leanprover-community" / "proofwidgets" @ git "v0.0.97" diff --git a/lean-toolchain b/lean-toolchain index 1883470497275d..25d537402d6416 100644 --- a/lean-toolchain +++ b/lean-toolchain @@ -1 +1 @@ -leanprover/lean4:nightly-2026-04-19 +leanprover/lean4-pr-releases:pr-release-13492-5457cb8 From 1a776d9ba393fcaec790e0cc364754c8d9d0c734 Mon Sep 17 00:00:00 2001 From: Joachim Breitner Date: Tue, 21 Apr 2026 11:03:51 +0000 Subject: [PATCH 103/321] chore: start with `backward.defeqAttrib.useBackward` enabled globally Lake-level option so that Mathlib continues to build as adaptation work against the stricter `@[defeq]` inference proceeds. Files will be progressively migrated either to per-proof `set_option backward.defeqAttrib.useBackward true in ...` or to `@[implicit_reducible]` on the affected definitions. Co-Authored-By: Claude Opus 4.7 (1M context) --- lakefile.lean | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lakefile.lean b/lakefile.lean index 01139cd9a10a64..b092a6cfd61363 100644 --- a/lakefile.lean +++ b/lakefile.lean @@ -43,6 +43,10 @@ abbrev mathlibLeanOptions := #[ ⟨`pp.unicode.fun, true⟩, -- pretty-prints `fun a ↦ b` ⟨`autoImplicit, false⟩, ⟨`maxSynthPendingDepth, .ofNat 3⟩, + -- Start from the legacy permissive `[defeq]` behavior; files are progressively migrated away + -- from this option either by local `set_option backward.defeqAttrib.useBackward true in` + -- on individual proofs, or by making the underlying definitions `@[implicit_reducible]`. + ⟨`backward.defeqAttrib.useBackward, true⟩, ] ++ -- options that are used in `lake build` mathlibOnlyLinters.map fun s ↦ { s with name := `weak ++ s.name } From 6f1a3512906045d1841a94bb550713227109dd33 Mon Sep 17 00:00:00 2001 From: Joachim Breitner Date: Tue, 21 Apr 2026 15:20:58 +0000 Subject: [PATCH 104/321] chore(scripts): add `--value` flag to `add_set_option.py` / `rm_set_option.py` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously the scripts assumed `set_option X false in` — fine for backward options that default to `true` (e.g. `backward.isDefEq.respectTransparency`). The new `backward.defeqAttrib.useBackward` option has the opposite shape (default `false`, set `true` to opt into legacy behavior), so the helpers need to parametrize the value they insert and match. Co-Authored-By: Claude Opus 4.7 (1M context) --- scripts/add_set_option.py | 12 +++++++++--- scripts/rm_set_option.py | 28 +++++++++++++++++----------- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/scripts/add_set_option.py b/scripts/add_set_option.py index 78b390de79b5a1..9f6f26bd1a91cd 100755 --- a/scripts/add_set_option.py +++ b/scripts/add_set_option.py @@ -193,6 +193,7 @@ def make_process_module( options: list[str], timeout: int, traverser: DAGTraverser, + value: str = "false", ) -> Callable: """Create the per-module action callback.""" @@ -220,7 +221,7 @@ def options_present_at(lines: list[str], decl_start: int) -> set[str]: while idx < len(lines): found = False for opt in options: - needle = set_option_line(opt).strip() + needle = set_option_line(opt, value).strip() if needle in lines[idx]: present.add(opt) found = True @@ -299,7 +300,7 @@ def process_module(module_name: str, filepath: Path) -> FileResult: # Try each candidate combination of missing options succeeded = False for combo in candidates(missing): - insert = [set_option_line(opt) for opt in combo] + insert = [set_option_line(opt, value) for opt in combo] new_lines = lines[:decl_start] + insert + lines[decl_start:] filepath.write_text("".join(new_lines)) ok, try_output = traverser.lake_build(module_name, PROJECT_DIR, timeout) @@ -399,6 +400,11 @@ def main(): "--option", help="Only use this specific option (default: try all known options)", ) + parser.add_argument( + "--value", + default="false", + help="Value to set the option to (default: false)", + ) parser.add_argument( "--max-workers", type=int, @@ -472,7 +478,7 @@ def main(): # Traverse forward traverser = DAGTraverser() display = _AddDisplay(dag, open_on_failure=args.open) - action = make_process_module(options, args.timeout, traverser) + action = make_process_module(options, args.timeout, traverser, value=args.value) display.start(len(dag.modules)) try: diff --git a/scripts/rm_set_option.py b/scripts/rm_set_option.py index 059b6f015f070e..75ae81f9592084 100755 --- a/scripts/rm_set_option.py +++ b/scripts/rm_set_option.py @@ -153,7 +153,7 @@ def on_module(self, module_name: str, result: FileResult | None, error: Exceptio self._redraw() -def handle_lakefile(options: list[str]) -> bool: +def handle_lakefile(options: list[str], value: str = "false") -> bool: """Check and remove options from lakefile.lean. Returns True if changed.""" lakefile = PROJECT_DIR / "lakefile.lean" content = lakefile.read_text() @@ -161,7 +161,7 @@ def handle_lakefile(options: list[str]) -> bool: for opt in options: if opt not in content: continue - pat = lakefile_pattern(opt) + pat = lakefile_pattern(opt, value) new_content = pat.sub("", content) if new_content != content: content = new_content @@ -172,13 +172,13 @@ def handle_lakefile(options: list[str]) -> bool: return changed -def scan_files(dag: DAG, options: list[str]) -> dict[str, list[int]]: +def scan_files(dag: DAG, options: list[str], value: str = "false") -> dict[str, list[int]]: """Find files with removable set_option lines. Returns dict of module_name -> list of 0-indexed line numbers. """ - removable_pats = [removable_pattern(opt) for opt in options] - commented_pats = [commented_pattern(opt) for opt in options] + removable_pats = [removable_pattern(opt, value) for opt in options] + commented_pats = [commented_pattern(opt, value) for opt in options] results: dict[str, list[int]] = {} for name, info in dag.modules.items(): filepath = dag.project_root / info.filepath @@ -196,9 +196,9 @@ def scan_files(dag: DAG, options: list[str]) -> dict[str, list[int]]: return results -def count_skipped(filepath: Path, options: list[str]) -> int: +def count_skipped(filepath: Path, options: list[str], value: str = "false") -> int: """Count set_option lines with trailing comments.""" - commented_pats = [commented_pattern(opt) for opt in options] + commented_pats = [commented_pattern(opt, value) for opt in options] count = 0 for line in filepath.read_text().splitlines(): if any(p.match(line) for p in commented_pats): @@ -223,13 +223,14 @@ def make_process_file( options: list[str], timeout: int, traverser: DAGTraverser, + value: str = "false", ) -> Callable: """Create the per-file action callback.""" def process_file(module_name: str, filepath: Path) -> FileResult: abs_path = filepath removable_lines = removable_map.get(module_name, []) - skipped = count_skipped(abs_path, options) + skipped = count_skipped(abs_path, options, value) if not removable_lines: save_progress(module_name, file_sha256(abs_path)) @@ -327,6 +328,11 @@ def main(): "--option", help="Only scan/remove this specific option (default: all known options)", ) + parser.add_argument( + "--value", + default="false", + help="Value of the option to scan/remove (default: false)", + ) parser.add_argument( "--dry-run", action="store_true", @@ -375,7 +381,7 @@ def main(): # Step 1: lakefile if not args.dry_run: - handle_lakefile(options) + handle_lakefile(options, args.value) # Step 2: build DAG print("Building import DAG...", flush=True) @@ -384,7 +390,7 @@ def main(): # Step 3: scan for removable lines print("Scanning for removable set_option lines...", flush=True) - removable_map = scan_files(full_dag, options) + removable_map = scan_files(full_dag, options, args.value) if args.files: # Filter to requested files @@ -475,7 +481,7 @@ def _global_timeout_handler(): _timer.start() display = _RemoveDisplay() - action = make_process_file(removable_map, options, args.timeout, traverser) + action = make_process_file(removable_map, options, args.timeout, traverser, args.value) display.start(len(full_dag.modules)) try: From 071abe120feb11aac479272a7095bfd27a3c0205 Mon Sep 17 00:00:00 2001 From: Joachim Breitner Date: Tue, 21 Apr 2026 15:21:26 +0000 Subject: [PATCH 105/321] chore: per-declaration `set_option backward.defeqAttrib.useBackward true` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Moves the global lakefile toggle to per-declaration `set_option ... in` lines (scripted via `add_set_option.py --option backward.defeqAttrib.useBackward --value true`), localizing the legacy behavior to the specific proofs that rely on it. 27 files, 94 insertions total. The lakefile entry is removed. `Mathlib/Order/OmegaCompletePartialOrder.lean`: the script couldn't fix `ωScottContinuous_apply` with a `set_option`; instead, replaced a `dsimp` with an explicit `change`, matching the fix from the previous adaptation branch. Known follow-up: `Mathlib/Order/JordanHolder.lean:298` (the `simpa [e, apply_last] using hlast` in `CompositionSeries.Equivalent.snoc`) still fails with a kernel type mismatch that `backward.defeqAttrib.useBackward` does not address — the types differ by unreduced `finSuccEquivLast` equivs. The old branch didn't patch this file either; the regression may be unrelated to this PR and need a proof-level fix. Co-Authored-By: Claude Opus 4.7 (1M context) --- Mathlib/Algebra/DirectSum/Ring.lean | 1 + Mathlib/Algebra/Homology/ComplexShape.lean | 1 + Mathlib/Algebra/Homology/Embedding/Basic.lean | 11 ++++++++++ .../Bicategory/Adjunction/Basic.lean | 1 + .../Bicategory/Adjunction/Mate.lean | 3 +++ Mathlib/CategoryTheory/Bicategory/Basic.lean | 7 +++++++ Mathlib/CategoryTheory/EssentialImage.lean | 1 + Mathlib/CategoryTheory/Functor/Category.lean | 2 ++ .../CategoryTheory/Functor/Trifunctor.lean | 6 ++++++ Mathlib/CategoryTheory/Whiskering.lean | 20 +++++++++++++++++++ .../Combinatorics/Additive/ETransform.lean | 3 +++ Mathlib/Combinatorics/Quiver/Covering.lean | 1 + Mathlib/Combinatorics/Quiver/Path.lean | 2 ++ Mathlib/Combinatorics/SimpleGraph/Copy.lean | 1 + Mathlib/Computability/ContextFreeGrammar.lean | 6 ++++++ Mathlib/Data/DFinsupp/Lex.lean | 2 ++ Mathlib/Data/Finset/Preimage.lean | 1 + Mathlib/LinearAlgebra/Finsupp/LSum.lean | 1 + Mathlib/Logic/Equiv/Basic.lean | 2 ++ .../MeasurableSpace/Embedding.lean | 2 ++ Mathlib/Order/JordanHolder.lean | 1 + Mathlib/Order/OmegaCompletePartialOrder.lean | 2 +- Mathlib/Order/RelSeries.lean | 9 +++++++++ Mathlib/Topology/Algebra/Group/Basic.lean | 1 + Mathlib/Topology/CompactOpen.lean | 1 + Mathlib/Topology/Constructions/SumProd.lean | 3 +++ .../Topology/FiberBundle/Constructions.lean | 1 + Mathlib/Topology/Homeomorph/Lemmas.lean | 5 +++++ lakefile.lean | 4 ---- 29 files changed, 96 insertions(+), 5 deletions(-) diff --git a/Mathlib/Algebra/DirectSum/Ring.lean b/Mathlib/Algebra/DirectSum/Ring.lean index f07485c15099dd..7635412701f528 100644 --- a/Mathlib/Algebra/DirectSum/Ring.lean +++ b/Mathlib/Algebra/DirectSum/Ring.lean @@ -230,6 +230,7 @@ private nonrec theorem mul_one (x : ⨁ i, A i) : x * 1 = x := by rw [flip_apply, mulHom_of_of] exact of_eq_of_gradedMonoid_eq (mul_one <| GradedMonoid.mk i xi) +set_option backward.defeqAttrib.useBackward true in private theorem mul_assoc (a b c : ⨁ i, A i) : a * b * c = a * (b * c) := by -- (`fun a b c => a * b * c` as a bundled hom) = (`fun a b c => a * (b * c)` as a bundled hom) suffices AddMonoidHom.mulLeft₃ = AddMonoidHom.mulRight₃ by diff --git a/Mathlib/Algebra/Homology/ComplexShape.lean b/Mathlib/Algebra/Homology/ComplexShape.lean index 66899bc1022026..2750688ffea97d 100644 --- a/Mathlib/Algebra/Homology/ComplexShape.lean +++ b/Mathlib/Algebra/Homology/ComplexShape.lean @@ -196,6 +196,7 @@ namespace ComplexShape variable (α : Type*) [AddRightCancelSemigroup α] [DecidableEq α] +set_option backward.defeqAttrib.useBackward true in @[to_dual instDecidableRelRelDown'] instance instDecidableRelRelUp' (a : α) : DecidableRel (ComplexShape.up' a).Rel := fun _ _ => by dsimp; infer_instance diff --git a/Mathlib/Algebra/Homology/Embedding/Basic.lean b/Mathlib/Algebra/Homology/Embedding/Basic.lean index 74e72d310e1863..f4aa921fcc8fe4 100644 --- a/Mathlib/Algebra/Homology/Embedding/Basic.lean +++ b/Mathlib/Algebra/Homology/Embedding/Basic.lean @@ -174,6 +174,7 @@ section variable {A : Type*} [AddCommSemigroup A] [IsRightCancelAdd A] [One A] +set_option backward.defeqAttrib.useBackward true in /-- The embedding from `up' a` to itself via (· + b). -/ @[simps!] def embeddingUp'Add (a b : A) : Embedding (up' a) (up' a) := @@ -186,6 +187,7 @@ instance (a b : A) : (embeddingUp'Add a b).IsRelIff := by dsimp [embeddingUp'Add instance (a b : A) : (embeddingUp'Add a b).IsTruncGE where mem_next {j _} h := ⟨j + a, (add_right_comm _ _ _).trans h⟩ +set_option backward.defeqAttrib.useBackward true in /-- The embedding from `down' a` to itself via (· + b). -/ @[simps!] def embeddingDown'Add (a b : A) : Embedding (down' a) (down' a) := @@ -201,6 +203,7 @@ instance (a b : A) : (embeddingDown'Add a b).IsTruncLE where end +set_option backward.defeqAttrib.useBackward true in /-- The obvious embedding from `up ℕ` to `up ℤ`. -/ @[simps!] def embeddingUpNat : Embedding (up ℕ) (up ℤ) := @@ -213,6 +216,7 @@ instance : embeddingUpNat.IsRelIff := by dsimp [embeddingUpNat]; infer_instance instance : embeddingUpNat.IsTruncGE where mem_next {j _} h := ⟨j + 1, h⟩ +set_option backward.defeqAttrib.useBackward true in /-- The embedding from `down ℕ` to `up ℤ` with sends `n` to `-n`. -/ @[simps!] def embeddingDownNat : Embedding (down ℕ) (up ℤ) := @@ -222,11 +226,13 @@ def embeddingDownNat : Embedding (down ℕ) (up ℤ) := instance : embeddingDownNat.IsRelIff := by dsimp [embeddingDownNat]; infer_instance +set_option backward.defeqAttrib.useBackward true in instance : embeddingDownNat.IsTruncLE where mem_prev {i j} h := ⟨j + 1, by dsimp at h ⊢; lia⟩ variable (p : ℤ) +set_option backward.defeqAttrib.useBackward true in /-- The embedding from `up ℕ` to `up ℤ` which sends `n : ℕ` to `p + n`. -/ @[simps!] def embeddingUpIntGE : Embedding (up ℕ) (up ℤ) := @@ -236,9 +242,11 @@ def embeddingUpIntGE : Embedding (up ℕ) (up ℤ) := instance : (embeddingUpIntGE p).IsRelIff := by dsimp [embeddingUpIntGE]; infer_instance +set_option backward.defeqAttrib.useBackward true in instance : (embeddingUpIntGE p).IsTruncGE where mem_next {j _} h := ⟨j + 1, by dsimp at h ⊢; lia⟩ +set_option backward.defeqAttrib.useBackward true in /-- The embedding from `down ℕ` to `up ℤ` which sends `n : ℕ` to `p - n`. -/ @[simps!] def embeddingUpIntLE : Embedding (down ℕ) (up ℤ) := @@ -248,9 +256,11 @@ def embeddingUpIntLE : Embedding (down ℕ) (up ℤ) := instance : (embeddingUpIntLE p).IsRelIff := by dsimp [embeddingUpIntLE]; infer_instance +set_option backward.defeqAttrib.useBackward true in instance : (embeddingUpIntLE p).IsTruncLE where mem_prev {_ k} h := ⟨k + 1, by dsimp at h ⊢; lia⟩ +set_option backward.defeqAttrib.useBackward true in lemma notMem_range_embeddingUpIntLE_iff (n : ℤ) : (∀ (i : ℕ), (embeddingUpIntLE p).f i ≠ n) ↔ p < n := by constructor @@ -261,6 +271,7 @@ lemma notMem_range_embeddingUpIntLE_iff (n : ℤ) : dsimp lia +set_option backward.defeqAttrib.useBackward true in lemma notMem_range_embeddingUpIntGE_iff (n : ℤ) : (∀ (i : ℕ), (embeddingUpIntGE p).f i ≠ n) ↔ n < p := by constructor diff --git a/Mathlib/CategoryTheory/Bicategory/Adjunction/Basic.lean b/Mathlib/CategoryTheory/Bicategory/Adjunction/Basic.lean index c0a8200c55a106..aad59ce2fd31f2 100644 --- a/Mathlib/CategoryTheory/Bicategory/Adjunction/Basic.lean +++ b/Mathlib/CategoryTheory/Bicategory/Adjunction/Basic.lean @@ -218,6 +218,7 @@ theorem right_triangle_of_left_triangle (h : leftZigzag η.hom ε.hom = (λ_ f). def adjointifyCounit (η : 𝟙 a ≅ f ≫ g) (ε : g ≫ f ≅ 𝟙 b) : g ≫ f ≅ 𝟙 b := whiskerLeftIso g ((ρ_ f).symm ≪≫ rightZigzagIso ε.symm η.symm ≪≫ λ_ f) ≪≫ ε +set_option backward.defeqAttrib.useBackward true in theorem adjointifyCounit_left_triangle (η : 𝟙 a ≅ f ≫ g) (ε : g ≫ f ≅ 𝟙 b) : leftZigzagIso η (adjointifyCounit η ε) = λ_ f ≪≫ (ρ_ f).symm := by apply Iso.ext diff --git a/Mathlib/CategoryTheory/Bicategory/Adjunction/Mate.lean b/Mathlib/CategoryTheory/Bicategory/Adjunction/Mate.lean index 46946620417513..49d6e2eae87ab8 100644 --- a/Mathlib/CategoryTheory/Bicategory/Adjunction/Mate.lean +++ b/Mathlib/CategoryTheory/Bicategory/Adjunction/Mate.lean @@ -174,6 +174,7 @@ variable {a b c d : B} {l₁ : a ⟶ b} {r₁ : b ⟶ a} (adj₁ : l₁ ⊣ r₁ {l₂ : c ⟶ d} {r₂ : d ⟶ c} (adj₂ : l₂ ⊣ r₂) {f : a ⟶ c} {g : b ⟶ d} +set_option backward.defeqAttrib.useBackward true in lemma mateEquiv_id_comp_right (φ : f ≫ 𝟙 _ ≫ l₂ ⟶ l₁ ≫ g) : mateEquiv adj₁ ((Adjunction.id _).comp adj₂) φ = mateEquiv adj₁ adj₂ (f ◁ (λ_ l₂).inv ≫ φ) ≫ (ρ_ _).inv ≫ (α_ _ _ _).hom := by @@ -182,6 +183,7 @@ lemma mateEquiv_id_comp_right (φ : f ≫ 𝟙 _ ≫ l₂ ⟶ l₁ ≫ g) : dsimp bicategory +set_option backward.defeqAttrib.useBackward true in lemma mateEquiv_comp_id_right (φ : f ≫ l₂ ≫ 𝟙 d ⟶ l₁ ≫ g) : mateEquiv adj₁ (adj₂.comp (Adjunction.id _)) φ = mateEquiv adj₁ adj₂ ((ρ_ _).inv ≫ (α_ _ _ _).hom ≫ φ) ≫ g ◁ (λ_ r₂).inv := by @@ -267,6 +269,7 @@ def rightAdjointSquare.hcomp (α : r₁ ≫ g ⟶ h ≫ r₂) (β : r₃ ≫ h (r₃ ≫ r₁) ≫ g ⟶ k ≫ (r₄ ≫ r₂) := (α_ _ _ _).hom ≫ r₃ ◁ α ≫ (α_ _ _ _).inv ≫ β ▷ r₂ ≫ (α_ _ _ _).hom +set_option backward.defeqAttrib.useBackward true in /-- The mates equivalence commutes with horizontal composition of squares. -/ theorem mateEquiv_hcomp (α : g ≫ l₂ ⟶ l₁ ≫ h) (β : h ≫ l₄ ⟶ l₃ ≫ k) : (mateEquiv (adj₁.comp adj₃) (adj₂.comp adj₄)) (leftAdjointSquare.hcomp α β) = diff --git a/Mathlib/CategoryTheory/Bicategory/Basic.lean b/Mathlib/CategoryTheory/Bicategory/Basic.lean index 36e4d61b327be4..130bb40e313fbe 100644 --- a/Mathlib/CategoryTheory/Bicategory/Basic.lean +++ b/Mathlib/CategoryTheory/Bicategory/Basic.lean @@ -465,6 +465,7 @@ def precomp (c : B) (f : a ⟶ b) : (b ⟶ c) ⥤ (a ⟶ c) where obj := (f ≫ ·) map := (f ◁ ·) +set_option backward.defeqAttrib.useBackward true in /-- Precomposition of a 1-morphism as a functor from the category of 1-morphisms `a ⟶ b` into the category of functors `(b ⟶ c) ⥤ (a ⟶ c)`. -/ @[simps] @@ -478,6 +479,7 @@ def postcomp (a : B) (f : b ⟶ c) : (a ⟶ b) ⥤ (a ⟶ c) where obj := (· ≫ f) map := (· ▷ f) +set_option backward.defeqAttrib.useBackward true in /-- Postcomposition of a 1-morphism as a functor from the category of 1-morphisms `b ⟶ c` into the category of functors `(a ⟶ b) ⥤ (a ⟶ c)`. -/ @[simps] @@ -485,12 +487,14 @@ def postcomposing (a b c : B) : (b ⟶ c) ⥤ (a ⟶ b) ⥤ (a ⟶ c) where obj f := postcomp a f map η := { app := (· ◁ η) } +set_option backward.defeqAttrib.useBackward true in /-- Left component of the associator as a natural isomorphism. -/ @[simps!] def associatorNatIsoLeft (a : B) (g : b ⟶ c) (h : c ⟶ d) : (postcomposing a ..).obj g ⋙ (postcomposing ..).obj h ≅ (postcomposing ..).obj (g ≫ h) := NatIso.ofComponents (α_ · g h) +set_option backward.defeqAttrib.useBackward true in /-- Middle component of the associator as a natural isomorphism. -/ @[simps!] def associatorNatIsoMiddle (f : a ⟶ b) (h : c ⟶ d) : @@ -498,17 +502,20 @@ def associatorNatIsoMiddle (f : a ⟶ b) (h : c ⟶ d) : (postcomposing ..).obj h ⋙ (precomposing ..).obj f := NatIso.ofComponents (α_ f · h) +set_option backward.defeqAttrib.useBackward true in /-- Right component of the associator as a natural isomorphism. -/ @[simps!] def associatorNatIsoRight (f : a ⟶ b) (g : b ⟶ c) (d : B) : (precomposing _ _ d).obj (f ≫ g) ≅ (precomposing ..).obj g ⋙ (precomposing ..).obj f := NatIso.ofComponents (α_ f g ·) +set_option backward.defeqAttrib.useBackward true in /-- Left unitor as a natural isomorphism. -/ @[simps!] def leftUnitorNatIso (a b : B) : (precomposing _ _ b).obj (𝟙 a) ≅ 𝟭 (a ⟶ b) := NatIso.ofComponents (λ_ ·) +set_option backward.defeqAttrib.useBackward true in /-- Right unitor as a natural isomorphism. -/ @[simps!] def rightUnitorNatIso (a b : B) : (postcomposing a _ _).obj (𝟙 b) ≅ 𝟭 (a ⟶ b) := diff --git a/Mathlib/CategoryTheory/EssentialImage.lean b/Mathlib/CategoryTheory/EssentialImage.lean index bdc6187812f158..a243c038991c62 100644 --- a/Mathlib/CategoryTheory/EssentialImage.lean +++ b/Mathlib/CategoryTheory/EssentialImage.lean @@ -167,6 +167,7 @@ end EssSurj variable {J C D : Type*} [Category* J] [Category* C] [Category* D] (G : J ⥤ D) (F : C ⥤ D) [F.Full] [F.Faithful] (hG : ∀ j, F.essImage (G.obj j)) +set_option backward.defeqAttrib.useBackward true in set_option backward.isDefEq.respectTransparency false in /-- Lift a functor `G : J ⥤ D` to the essential image of a fully faithful functor `F : C ⥤ D` to a functor `G' : J ⥤ C` such that `G' ⋙ F ≅ G`. See `essImage.liftFunctorCompIso`. -/ diff --git a/Mathlib/CategoryTheory/Functor/Category.lean b/Mathlib/CategoryTheory/Functor/Category.lean index 217c5ec85576be..e1a4ca21f4ab6f 100644 --- a/Mathlib/CategoryTheory/Functor/Category.lean +++ b/Mathlib/CategoryTheory/Functor/Category.lean @@ -119,10 +119,12 @@ to_dual_insert_cast hcomp := by ext x; exact β.naturality' (α.app x) /-- Notation for horizontal composition of natural transformations. -/ infixl:80 " ◫ " => hcomp +set_option backward.defeqAttrib.useBackward true in @[to_dual self] theorem hcomp_id_app {H : D ⥤ E} (α : F ⟶ G) (X : C) : (α ◫ 𝟙 H).app X = H.map (α.app X) := by simp +set_option backward.defeqAttrib.useBackward true in @[to_dual self] theorem id_hcomp_app {H : E ⥤ C} (α : F ⟶ G) (X : E) : (𝟙 H ◫ α).app X = α.app _ := by simp diff --git a/Mathlib/CategoryTheory/Functor/Trifunctor.lean b/Mathlib/CategoryTheory/Functor/Trifunctor.lean index e3f53c3655e6c1..1409aea4f3d58d 100644 --- a/Mathlib/CategoryTheory/Functor/Trifunctor.lean +++ b/Mathlib/CategoryTheory/Functor/Trifunctor.lean @@ -38,6 +38,7 @@ def bifunctorComp₁₂Obj (F₁₂ : C₁ ⥤ C₂ ⥤ C₁₂) (G : C₁₂ map {X₂ Y₂} φ := { app := fun X₃ => (G.map ((F₁₂.obj X₁).map φ)).app X₃ } +set_option backward.defeqAttrib.useBackward true in /-- Given two bifunctors `F₁₂ : C₁ ⥤ C₂ ⥤ C₁₂` and `G : C₁₂ ⥤ C₃ ⥤ C₄`, this is the trifunctor `C₁ ⥤ C₂ ⥤ C₃ ⥤ C₄` obtained by composition. -/ @[simps] @@ -52,6 +53,7 @@ def bifunctorComp₁₂ (F₁₂ : C₁ ⥤ C₂ ⥤ C₁₂) (G : C₁₂ ⥤ C dsimp simp only [← NatTrans.comp_app, ← G.map_comp, NatTrans.naturality] } +set_option backward.defeqAttrib.useBackward true in /-- Auxiliary definition for `bifunctorComp₁₂Functor`. -/ @[simps] def bifunctorComp₁₂FunctorObj (F₁₂ : C₁ ⥤ C₂ ⥤ C₁₂) : @@ -70,6 +72,7 @@ def bifunctorComp₁₂FunctorObj (F₁₂ : C₁ ⥤ C₂ ⥤ C₁₂) : dsimp simp only [← NatTrans.comp_app, NatTrans.naturality] } +set_option backward.defeqAttrib.useBackward true in /-- Auxiliary definition for `bifunctorComp₁₂Functor`. -/ @[simps] def bifunctorComp₁₂FunctorMap {F₁₂ F₁₂' : C₁ ⥤ C₂ ⥤ C₁₂} (φ : F₁₂ ⟶ F₁₂') : @@ -115,6 +118,7 @@ def bifunctorComp₂₃Obj (F : C₁ ⥤ C₂₃ ⥤ C₄) (G₂₃ : C₂ ⥤ C dsimp simp only [← Functor.map_comp, NatTrans.naturality] } +set_option backward.defeqAttrib.useBackward true in /-- Given two bifunctors `F : C₁ ⥤ C₂₃ ⥤ C₄` and `G₂₃ : C₂ ⥤ C₃ ⥤ C₄`, this is the trifunctor `C₁ ⥤ C₂ ⥤ C₃ ⥤ C₄` obtained by composition. -/ @[simps] @@ -125,6 +129,7 @@ def bifunctorComp₂₃ (F : C₁ ⥤ C₂₃ ⥤ C₄) (G₂₃ : C₂ ⥤ C₃ { app := fun X₂ => { app := fun X₃ => (F.map φ).app ((G₂₃.obj X₂).obj X₃) } } +set_option backward.defeqAttrib.useBackward true in /-- Auxiliary definition for `bifunctorComp₂₃Functor`. -/ @[simps] def bifunctorComp₂₃FunctorObj (F : C₁ ⥤ C₂₃ ⥤ C₄) : @@ -142,6 +147,7 @@ def bifunctorComp₂₃FunctorObj (F : C₁ ⥤ C₂₃ ⥤ C₄) : dsimp simp only [← NatTrans.comp_app, ← Functor.map_comp, NatTrans.naturality] } } +set_option backward.defeqAttrib.useBackward true in /-- Auxiliary definition for `bifunctorComp₂₃Functor`. -/ @[simps] def bifunctorComp₂₃FunctorMap {F F' : C₁ ⥤ C₂₃ ⥤ C₄} (φ : F ⟶ F') : diff --git a/Mathlib/CategoryTheory/Whiskering.lean b/Mathlib/CategoryTheory/Whiskering.lean index 924da3bc2a5c84..0214163e5eb2b7 100644 --- a/Mathlib/CategoryTheory/Whiskering.lean +++ b/Mathlib/CategoryTheory/Whiskering.lean @@ -49,6 +49,7 @@ def whiskerLeft (F : C ⥤ D) {G H : D ⥤ E} (α : G ⟶ H) : app X := α.app (F.obj X) naturality X Y f := by rw [Functor.comp_map, Functor.comp_map, α.naturality] +set_option backward.defeqAttrib.useBackward true in @[simp, to_dual self] lemma id_hcomp (F : C ⥤ D) {G H : D ⥤ E} (α : G ⟶ H) : 𝟙 F ◫ α = whiskerLeft F α := by ext @@ -63,6 +64,7 @@ def whiskerRight {G H : C ⥤ D} (α : G ⟶ H) (F : D ⥤ E) : naturality X Y f := by rw [Functor.comp_map, Functor.comp_map, ← F.map_comp, ← F.map_comp, α.naturality] +set_option backward.defeqAttrib.useBackward true in @[simp, to_dual self] lemma hcomp_id {G H : C ⥤ D} (α : G ⟶ H) (F : D ⥤ E) : α ◫ 𝟙 F = whiskerRight α F := by ext @@ -70,6 +72,7 @@ lemma hcomp_id {G H : C ⥤ D} (α : G ⟶ H) (F : D ⥤ E) : α ◫ 𝟙 F = wh variable (C D E) +set_option backward.defeqAttrib.useBackward true in /-- Left-composition gives a functor `(C ⥤ D) ⥤ ((D ⥤ E) ⥤ (C ⥤ E))`. `(whiskeringLeft.obj F).obj G` is `F ⋙ G`, and @@ -86,6 +89,7 @@ def whiskeringLeft : (C ⥤ D) ⥤ (D ⥤ E) ⥤ C ⥤ E where naturality := fun X Y f => by dsimp; rw [← H.map_comp, ← H.map_comp, ← τ.naturality] } naturality := fun X Y f => by ext; dsimp; rw [f.naturality] } +set_option backward.defeqAttrib.useBackward true in /-- Right-composition gives a functor `(D ⥤ E) ⥤ ((C ⥤ D) ⥤ (C ⥤ E))`. `(whiskeringRight.obj H).obj F` is `F ⋙ H`, and @@ -200,12 +204,14 @@ theorem whiskerRight_comp {G H K : C ⥤ D} (α : G ⟶ H) (β : H ⟶ K) (F : D whiskerRight (α ≫ β) F = whiskerRight α F ≫ whiskerRight β F := ((whiskeringRight C D E).obj F).map_comp α β +set_option backward.defeqAttrib.useBackward true in @[to_dual none, reassoc] theorem whiskerLeft_comp_whiskerRight {F G : C ⥤ D} {H K : D ⥤ E} (α : F ⟶ G) (β : H ⟶ K) : whiskerLeft F β ≫ whiskerRight α K = whiskerRight α H ≫ whiskerLeft G β := by ext simp +set_option backward.defeqAttrib.useBackward true in @[to_dual hcomp_eq_whiskerRight_comp_whiskerLeft] lemma NatTrans.hcomp_eq_whiskerLeft_comp_whiskerRight {F G : C ⥤ D} {H K : D ⥤ E} (α : F ⟶ G) (β : H ⟶ K) : α ◫ β = whiskerLeft F β ≫ whiskerRight α K := by @@ -296,6 +302,7 @@ theorem isoWhiskerRight_trans {G H K : C ⥤ D} (α : G ≅ H) (β : H ≅ K) (F isoWhiskerRight (α ≪≫ β) F = isoWhiskerRight α F ≪≫ isoWhiskerRight β F := ((whiskeringRight C D E).obj F).mapIso_trans α β +set_option backward.defeqAttrib.useBackward true in @[reassoc] theorem isoWhiskerLeft_trans_isoWhiskerRight {F G : C ⥤ D} {H K : D ⥤ E} (α : F ≅ G) (β : H ≅ K) : isoWhiskerLeft F β ≪≫ isoWhiskerRight α K = isoWhiskerRight α H ≪≫ isoWhiskerLeft G β := by @@ -304,18 +311,21 @@ theorem isoWhiskerLeft_trans_isoWhiskerRight {F G : C ⥤ D} {H K : D ⥤ E} (α variable {B : Type u₄} [Category.{v₄} B] +set_option backward.defeqAttrib.useBackward true in @[simp, to_dual none] theorem whiskerLeft_twice (F : B ⥤ C) (G : C ⥤ D) {H K : D ⥤ E} (α : H ⟶ K) : whiskerLeft F (whiskerLeft G α) = (Functor.associator _ _ _).inv ≫ whiskerLeft (F ⋙ G) α ≫ (Functor.associator _ _ _).hom := by cat_disch +set_option backward.defeqAttrib.useBackward true in @[simp, to_dual none] theorem whiskerRight_twice {H K : B ⥤ C} (F : C ⥤ D) (G : D ⥤ E) (α : H ⟶ K) : whiskerRight (whiskerRight α F) G = (Functor.associator _ _ _).hom ≫ whiskerRight α (F ⋙ G) ≫ (Functor.associator _ _ _).inv := by cat_disch +set_option backward.defeqAttrib.useBackward true in @[to_dual none] theorem whiskerRight_left (F : B ⥤ C) {G H : C ⥤ D} (α : G ⟶ H) (K : D ⥤ E) : whiskerRight (whiskerLeft F α) K = @@ -335,6 +345,7 @@ theorem isoWhiskerRight_twice {H K : B ⥤ C} (F : C ⥤ D) (G : D ⥤ E) (α : Functor.associator _ _ _ ≪≫ isoWhiskerRight α (F ⋙ G) ≪≫ (Functor.associator _ _ _).symm := by cat_disch +set_option backward.defeqAttrib.useBackward true in @[reassoc] theorem isoWhiskerRight_left (F : B ⥤ C) {G H : C ⥤ D} (α : G ≅ H) (K : D ⥤ E) : isoWhiskerRight (isoWhiskerLeft F α) K = @@ -342,6 +353,7 @@ theorem isoWhiskerRight_left (F : B ⥤ C) {G H : C ⥤ D} (α : G ≅ H) (K : D (Functor.associator _ _ _).symm := by cat_disch +set_option backward.defeqAttrib.useBackward true in @[reassoc] theorem isoWhiskerLeft_right (F : B ⥤ C) {G H : C ⥤ D} (α : G ≅ H) (K : D ⥤ E) : isoWhiskerLeft F (isoWhiskerRight α K) = @@ -357,21 +369,25 @@ variable {A : Type u₁} [Category.{v₁} A] {B : Type u₂} [Category.{v₂} B] {C : Type u₃} [Category.{v₃} C] {D : Type u₄} [Category.{v₄} D] {E : Type u₅} [Category.{v₅} E] (F : A ⥤ B) (G : B ⥤ C) (H : C ⥤ D) (K : D ⥤ E) +set_option backward.defeqAttrib.useBackward true in @[reassoc] theorem triangleIso : associator F (𝟭 B) G ≪≫ isoWhiskerLeft F (leftUnitor G) = isoWhiskerRight (rightUnitor F) G := by cat_disch +set_option backward.defeqAttrib.useBackward true in @[reassoc] theorem pentagonIso : isoWhiskerRight (associator F G H) K ≪≫ associator F (G ⋙ H) K ≪≫ isoWhiskerLeft F (associator G H K) = associator (F ⋙ G) H K ≪≫ associator F G (H ⋙ K) := by cat_disch +set_option backward.defeqAttrib.useBackward true in theorem triangle : (associator F (𝟭 B) G).hom ≫ whiskerLeft F (leftUnitor G).hom = whiskerRight (rightUnitor F).hom G := by cat_disch +set_option backward.defeqAttrib.useBackward true in theorem pentagon : whiskerRight (associator F G H).hom K ≫ (associator F (G ⋙ H) K).hom ≫ whiskerLeft F (associator G H K).hom = @@ -380,6 +396,7 @@ theorem pentagon : variable {C₁ C₂ C₃ D₁ D₂ D₃ : Type*} [Category* C₁] [Category* C₂] [Category* C₃] [Category* D₁] [Category* D₂] [Category* D₃] (E : Type*) [Category* E] +set_option backward.defeqAttrib.useBackward true in /-- The obvious functor `(C₁ ⥤ D₁) ⥤ (C₂ ⥤ D₂) ⥤ (D₁ ⥤ D₂ ⥤ E) ⥤ (C₁ ⥤ C₂ ⥤ E)`. -/ @[simps!] def whiskeringLeft₂ : @@ -400,6 +417,7 @@ def whiskeringLeft₃ObjObjObj (F₁ : C₁ ⥤ D₁) (F₂ : C₂ ⥤ D₂) (F (whiskeringRight _ _ _).obj (((whiskeringLeft₂ E).obj F₂).obj F₃) ⋙ (whiskeringLeft C₁ D₁ _).obj F₁ +set_option backward.defeqAttrib.useBackward true in /-- Auxiliary definition for `whiskeringLeft₃`. -/ @[simps] def whiskeringLeft₃ObjObjMap (F₁ : C₁ ⥤ D₁) (F₂ : C₂ ⥤ D₂) {F₃ F₃' : C₃ ⥤ D₃} (τ₃ : F₃ ⟶ F₃') : @@ -415,6 +433,7 @@ def whiskeringLeft₃ObjObj (F₁ : C₁ ⥤ D₁) (F₂ : C₂ ⥤ D₂) : obj F₃ := whiskeringLeft₃ObjObjObj E F₁ F₂ F₃ map τ₃ := whiskeringLeft₃ObjObjMap E F₁ F₂ τ₃ +set_option backward.defeqAttrib.useBackward true in variable (C₃ D₃) in /-- Auxiliary definition for `whiskeringLeft₃`. -/ @[simps] @@ -430,6 +449,7 @@ def whiskeringLeft₃Obj (F₁ : C₁ ⥤ D₁) : obj F₂ := whiskeringLeft₃ObjObj C₃ D₃ E F₁ F₂ map τ₂ := whiskeringLeft₃ObjMap C₃ D₃ E F₁ τ₂ +set_option backward.defeqAttrib.useBackward true in variable (C₂ C₃ D₂ D₃) in /-- Auxiliary definition for `whiskeringLeft₃`. -/ @[simps] diff --git a/Mathlib/Combinatorics/Additive/ETransform.lean b/Mathlib/Combinatorics/Additive/ETransform.lean index 2ff6e9822a0d3a..f940b09b8edcb3 100644 --- a/Mathlib/Combinatorics/Additive/ETransform.lean +++ b/Mathlib/Combinatorics/Additive/ETransform.lean @@ -61,6 +61,7 @@ theorem mulDysonETransform.subset : refine union_mul_inter_subset_union.trans (union_subset Subset.rfl ?_) rw [mul_smul_comm, smul_mul_assoc, inv_smul_smul, mul_comm] +set_option backward.defeqAttrib.useBackward true in @[to_additive] theorem mulDysonETransform.card : (mulDysonETransform e x).1.card + (mulDysonETransform e x).2.card = x.1.card + x.2.card := by @@ -68,6 +69,7 @@ theorem mulDysonETransform.card : rw [← card_smul_finset e (_ ∩ _), smul_finset_inter, smul_inv_smul, inter_comm, card_union_add_card_inter, card_smul_finset] +set_option backward.defeqAttrib.useBackward true in @[to_additive (attr := simp)] theorem mulDysonETransform_idem : mulDysonETransform e (mulDysonETransform e x) = mulDysonETransform e x := by @@ -79,6 +81,7 @@ theorem mulDysonETransform_idem : variable {e x} +set_option backward.defeqAttrib.useBackward true in @[to_additive] theorem mulDysonETransform.smul_finset_snd_subset_fst : e • (mulDysonETransform e x).2 ⊆ (mulDysonETransform e x).1 := by diff --git a/Mathlib/Combinatorics/Quiver/Covering.lean b/Mathlib/Combinatorics/Quiver/Covering.lean index b01124ccbe59a6..53e9578ba5240a 100644 --- a/Mathlib/Combinatorics/Quiver/Covering.lean +++ b/Mathlib/Combinatorics/Quiver/Covering.lean @@ -160,6 +160,7 @@ protected theorem Prefunctor.symmetrifyCostar (u : U) : erw [Equiv.sigmaSumDistrib_apply, Equiv.sigmaSumDistrib_apply] <;> simp +set_option backward.defeqAttrib.useBackward true in set_option backward.isDefEq.respectTransparency false in protected theorem Prefunctor.IsCovering.symmetrify (hφ : φ.IsCovering) : φ.symmetrify.IsCovering := by diff --git a/Mathlib/Combinatorics/Quiver/Path.lean b/Mathlib/Combinatorics/Quiver/Path.lean index 5255712418c622..ddd9d524ee5a65 100644 --- a/Mathlib/Combinatorics/Quiver/Path.lean +++ b/Mathlib/Combinatorics/Quiver/Path.lean @@ -341,6 +341,7 @@ theorem mapPath_comp {a b : V} (p : Path a b) : theorem mapPath_toPath {a b : V} (f : a ⟶ b) : F.mapPath f.toPath = (F.map f).toPath := rfl +set_option backward.defeqAttrib.useBackward true in @[simp] theorem mapPath_id {a b : V} : (p : Path a b) → (𝟭q V).mapPath p = p | Path.nil => rfl @@ -348,6 +349,7 @@ theorem mapPath_id {a b : V} : (p : Path a b) → (𝟭q V).mapPath p = p variable {U : Type u₃} [Quiver.{v₃} U] (G : W ⥤q U) +set_option backward.defeqAttrib.useBackward true in @[simp] theorem mapPath_comp_apply {a b : V} (p : Path a b) : (F ⋙q G).mapPath p = G.mapPath (F.mapPath p) := by diff --git a/Mathlib/Combinatorics/SimpleGraph/Copy.lean b/Mathlib/Combinatorics/SimpleGraph/Copy.lean index e1d3af67c359e1..ada9548bb7d373 100644 --- a/Mathlib/Combinatorics/SimpleGraph/Copy.lean +++ b/Mathlib/Combinatorics/SimpleGraph/Copy.lean @@ -162,6 +162,7 @@ def induce (G : SimpleGraph V) (s : Set V) : Copy (G.induce s) G := (Embedding.i /-- The copy of `⊥` in any simple graph that can embed its vertices. -/ protected def bot (f : α ↪ β) : Copy (⊥ : SimpleGraph α) B := ⟨⟨f, False.elim⟩, f.injective⟩ +set_option backward.defeqAttrib.useBackward true in set_option backward.isDefEq.respectTransparency false in /-- The isomorphism from a subgraph of `A` to its map under a copy `f : Copy A B`. -/ noncomputable def isoSubgraphMap (f : Copy A B) (A' : A.Subgraph) : diff --git a/Mathlib/Computability/ContextFreeGrammar.lean b/Mathlib/Computability/ContextFreeGrammar.lean index f6142a08d7c695..17be15336d47a5 100644 --- a/Mathlib/Computability/ContextFreeGrammar.lean +++ b/Mathlib/Computability/ContextFreeGrammar.lean @@ -298,6 +298,7 @@ lemma reverse_injective : Injective (reverse : ContextFreeGrammar T → ContextF lemma reverse_surjective : Surjective (reverse : ContextFreeGrammar T → ContextFreeGrammar T) := reverse_bijective.surjective +set_option backward.defeqAttrib.useBackward true in set_option backward.isDefEq.respectTransparency false in lemma produces_reverse : g.reverse.Produces u.reverse v.reverse ↔ g.Produces u v := (Equiv.ofBijective _ ContextFreeRule.reverse_bijective).exists_congr @@ -305,6 +306,7 @@ lemma produces_reverse : g.reverse.Produces u.reverse v.reverse ↔ g.Produces u alias ⟨_, Produces.reverse⟩ := produces_reverse +set_option backward.defeqAttrib.useBackward true in set_option backward.isDefEq.respectTransparency false in @[simp] lemma produces_reverse_comm : g.reverse.Produces u v ↔ g.Produces u.reverse v.reverse := (Equiv.ofBijective _ ContextFreeRule.reverse_bijective).exists_congr @@ -315,19 +317,23 @@ protected lemma Derives.reverse (hg : g.Derives u v) : g.reverse.Derives u.rever | refl => rfl | tail _ orig ih => exact ih.trans_produces orig.reverse +set_option backward.defeqAttrib.useBackward true in lemma derives_reverse : g.reverse.Derives u.reverse v.reverse ↔ g.Derives u v := ⟨fun h ↦ by convert h.reverse <;> simp, .reverse⟩ @[simp] lemma derives_reverse_comm : g.reverse.Derives u v ↔ g.Derives u.reverse v.reverse := by rw [iff_comm, ← derives_reverse, List.reverse_reverse, List.reverse_reverse] +set_option backward.defeqAttrib.useBackward true in lemma generates_reverse : g.reverse.Generates u.reverse ↔ g.Generates u := by simp [Generates] alias ⟨_, Generates.reverse⟩ := generates_reverse +set_option backward.defeqAttrib.useBackward true in @[simp] lemma generates_reverse_comm : g.reverse.Generates u ↔ g.Generates u.reverse := by simp [Generates] +set_option backward.defeqAttrib.useBackward true in @[simp] lemma language_reverse : g.reverse.language = g.language.reverse := by ext; simp end ContextFreeGrammar diff --git a/Mathlib/Data/DFinsupp/Lex.lean b/Mathlib/Data/DFinsupp/Lex.lean index 931f0706b5049f..567594a41f9ae0 100644 --- a/Mathlib/Data/DFinsupp/Lex.lean +++ b/Mathlib/Data/DFinsupp/Lex.lean @@ -217,6 +217,7 @@ section Left variable [∀ i, AddLeftStrictMono (α i)] +set_option backward.defeqAttrib.useBackward true in instance Lex.addLeftStrictMono : AddLeftStrictMono (Lex (Π₀ i, α i)) := ⟨fun _ _ _ ⟨a, lta, ha⟩ ↦ ⟨a, fun j ja ↦ congr_arg _ (lta j ja), by dsimp; gcongr⟩⟩ @@ -236,6 +237,7 @@ section Right variable [∀ i, AddRightStrictMono (α i)] +set_option backward.defeqAttrib.useBackward true in instance Lex.addRightStrictMono : AddRightStrictMono (Lex (Π₀ i, α i)) := ⟨fun f _ _ ⟨a, lta, ha⟩ ↦ ⟨a, fun j ja ↦ congr_arg (· + ofLex f j) (lta j ja), by dsimp; gcongr⟩⟩ diff --git a/Mathlib/Data/Finset/Preimage.lean b/Mathlib/Data/Finset/Preimage.lean index ff7918d1c980fb..f2027570006f88 100644 --- a/Mathlib/Data/Finset/Preimage.lean +++ b/Mathlib/Data/Finset/Preimage.lean @@ -193,6 +193,7 @@ def restrictPreimageFinset (e : α ≃ β) (s : Finset β) : (s.preimage e e.inj end Equiv +set_option backward.defeqAttrib.useBackward true in set_option backward.isDefEq.respectTransparency false in /-- Reindexing and then restricting to a `Finset` is the same as first restricting to the preimage of this `Finset` and then reindexing. -/ diff --git a/Mathlib/LinearAlgebra/Finsupp/LSum.lean b/Mathlib/LinearAlgebra/Finsupp/LSum.lean index b541d4ab7d4a49..4e15cc89edf52c 100644 --- a/Mathlib/LinearAlgebra/Finsupp/LSum.lean +++ b/Mathlib/LinearAlgebra/Finsupp/LSum.lean @@ -152,6 +152,7 @@ theorem lift_symm_apply (f) (x) : ((lift M R X).symm f) x = f (single x 1) := theorem lift_apply (f) (g) : ((lift M R X) f) g = g.sum fun x r => r • f x := rfl +set_option backward.defeqAttrib.useBackward true in /-- Given compatible `S` and `R`-module structures on `M` and a type `X`, the set of functions `X → M` is `S`-linearly equivalent to the `R`-linear maps from the free `R`-module on `X` to `M`. -/ diff --git a/Mathlib/Logic/Equiv/Basic.lean b/Mathlib/Logic/Equiv/Basic.lean index fbc5193ae2dbab..71f756841ff173 100644 --- a/Mathlib/Logic/Equiv/Basic.lean +++ b/Mathlib/Logic/Equiv/Basic.lean @@ -455,6 +455,7 @@ def sigmaSigmaSubtype {α : Type*} {β : α → Type*} {γ : (a : α) → β a _ ≃ _ := uniqueSigma (fun ab ↦ γ (Sigma.fst <| Subtype.val ab) (Sigma.snd <| Subtype.val ab)) _ ≃ γ a b := Equiv.cast <| by rw [← show ⟨⟨a, b⟩, h⟩ = uniq.default from uniq.uniq _] +set_option backward.defeqAttrib.useBackward true in @[simp] lemma sigmaSigmaSubtype_symm_apply {α : Type*} {β : α → Type*} {γ : (a : α) → β a → Type*} (p : (a : α) × β a → Prop) [uniq : Unique {ab // p ab}] @@ -472,6 +473,7 @@ def sigmaSigmaSubtypeEq {α β : Type*} {γ : α → β → Type*} (a : α) (b : uniq := by rintro ⟨⟨a', b'⟩, ⟨rfl, rfl⟩⟩; rfl } sigmaSigmaSubtype (fun ⟨a', b'⟩ ↦ a' = a ∧ b' = b) ⟨rfl, rfl⟩ +set_option backward.defeqAttrib.useBackward true in @[simp] lemma sigmaSigmaSubtypeEq_apply {α β : Type*} {γ : α → β → Type*} {a : α} {b : β} (s : {s : (a : α) × (b : β) × γ a b // s.1 = a ∧ s.2.1 = b}) : diff --git a/Mathlib/MeasureTheory/MeasurableSpace/Embedding.lean b/Mathlib/MeasureTheory/MeasurableSpace/Embedding.lean index 6a75597a0b8396..5b4bb4dbd9be9c 100644 --- a/Mathlib/MeasureTheory/MeasurableSpace/Embedding.lean +++ b/Mathlib/MeasureTheory/MeasurableSpace/Embedding.lean @@ -375,6 +375,7 @@ def prodCongr (ab : α ≃ᵐ β) (cd : γ ≃ᵐ δ) : α × γ ≃ᵐ β × δ def prodComm : α × β ≃ᵐ β × α where toEquiv := .prodComm α β +set_option backward.defeqAttrib.useBackward true in /-- Products of measurable spaces are associative. -/ def prodAssoc : (α × β) × γ ≃ᵐ α × β × γ where toEquiv := .prodAssoc α β γ @@ -574,6 +575,7 @@ def piEquivPiSubtypeProd (p : δ' → Prop) [DecidablePred p] : (∀ i, π i) ≃ᵐ (∀ i : Subtype p, π i) × ∀ i : { i // ¬p i }, π i where toEquiv := .piEquivPiSubtypeProd p π +set_option backward.defeqAttrib.useBackward true in /-- The measurable equivalence between the pi type over a sum type and a product of pi-types. This is similar to `MeasurableEquiv.piEquivPiSubtypeProd`. -/ def sumPiEquivProdPi (α : δ ⊕ δ' → Type*) [∀ i, MeasurableSpace (α i)] : diff --git a/Mathlib/Order/JordanHolder.lean b/Mathlib/Order/JordanHolder.lean index 386ead23f835e6..14a5222e9c46d7 100644 --- a/Mathlib/Order/JordanHolder.lean +++ b/Mathlib/Order/JordanHolder.lean @@ -265,6 +265,7 @@ theorem trans {s₁ s₂ s₃ : CompositionSeries X} (h₁ : Equivalent s₁ s ⟨h₁.choose.trans h₂.choose, fun i => iso_trans (h₁.choose_spec i) (h₂.choose_spec (h₁.choose i))⟩ +set_option backward.defeqAttrib.useBackward true in set_option backward.isDefEq.respectTransparency false in protected theorem smash {s₁ s₂ t₁ t₂ : CompositionSeries X} (hs : s₁.last = s₂.head) (ht : t₁.last = t₂.head) diff --git a/Mathlib/Order/OmegaCompletePartialOrder.lean b/Mathlib/Order/OmegaCompletePartialOrder.lean index 939c03411c3e5e..81d11dc3408e7a 100644 --- a/Mathlib/Order/OmegaCompletePartialOrder.lean +++ b/Mathlib/Order/OmegaCompletePartialOrder.lean @@ -742,7 +742,7 @@ lemma ωScottContinuous_apply apply le_antisymm · apply ωSup_le intro i - dsimp + change (f (c i)) (ωSup (c.map ⟨g, hg.monotone⟩)) ≤ _ rw [(f (c i)).continuous] apply ωSup_le intro j diff --git a/Mathlib/Order/RelSeries.lean b/Mathlib/Order/RelSeries.lean index 14132caa579bd6..18dacc10c49f7d 100644 --- a/Mathlib/Order/RelSeries.lean +++ b/Mathlib/Order/RelSeries.lean @@ -318,6 +318,7 @@ def append (p q : RelSeries r) (connect : p.last ~[r] q.head) : RelSeries r wher Nat.add_assoc _ 1, add_comm 1, Nat.sub_add_cancel] exact hi +set_option backward.defeqAttrib.useBackward true in lemma append_apply_left (p q : RelSeries r) (connect : p.last ~[r] q.head) (i : Fin (p.length + 1)) : p.append q connect @@ -327,6 +328,7 @@ lemma append_apply_left (p q : RelSeries r) (connect : p.last ~[r] q.head) simp only [Function.comp_apply] convert Fin.append_left _ _ _ +set_option backward.defeqAttrib.useBackward true in lemma append_apply_right (p q : RelSeries r) (connect : p.last ~[r] q.head) (i : Fin (q.length + 1)) : p.append q connect @@ -338,6 +340,7 @@ lemma append_apply_right (p q : RelSeries r) (connect : p.last ~[r] q.head) (p.append q connect).head = p.head := append_apply_left p q connect 0 +set_option backward.defeqAttrib.useBackward true in @[simp] lemma last_append (p q : RelSeries r) (connect : p.last ~[r] q.head) : (p.append q connect).last = q.last := by delta last @@ -353,6 +356,7 @@ lemma append_assoc (p q w : RelSeries r) (hpq : p.last ~[r] q.head) (hqw : q.las lia · simp [append, Fin.append_assoc] +set_option backward.defeqAttrib.useBackward true in @[simp] lemma toList_append (p q : RelSeries r) (connect : p.last ~[r] q.head) : (p.append q connect).toList = p.toList ++ q.toList := by @@ -455,13 +459,16 @@ def reverse (p : RelSeries r) : RelSeries r.inv where @[simp] lemma reverse_apply (p : RelSeries r) (i : Fin (p.length + 1)) : p.reverse i = p i.rev := rfl +set_option backward.defeqAttrib.useBackward true in @[simp] lemma last_reverse (p : RelSeries r) : p.reverse.last = p.head := by simp [RelSeries.last, RelSeries.head] +set_option backward.defeqAttrib.useBackward true in set_option backward.isDefEq.respectTransparency false in @[simp] lemma head_reverse (p : RelSeries r) : p.reverse.head = p.last := by simp [RelSeries.last, RelSeries.head] +set_option backward.defeqAttrib.useBackward true in @[simp] lemma reverse_reverse {r : SetRel α α} (p : RelSeries r) : p.reverse.reverse = p := by ext <;> simp @@ -576,6 +583,7 @@ def tail (p : RelSeries r) (len_pos : p.length ≠ 0) : RelSeries r where simp only [tail_length, Fin.val_succ, Fin.val_cast, Fin.val_last] exact Nat.succ_pred_eq_of_pos (by simpa [Nat.pos_iff_ne_zero] using len_pos) +set_option backward.defeqAttrib.useBackward true in @[simp] lemma toList_tail {p : RelSeries r} (hp : p.length ≠ 0) : (p.tail hp).toList = p.toList.tail := by refine List.ext_getElem ?_ fun i h1 h2 ↦ ?_ @@ -903,6 +911,7 @@ def mk (length : ℕ) (toFun : Fin (length + 1) → α) (strictMono : StrictMono toFun := toFun step i := strictMono <| lt_add_one i.1 +set_option backward.defeqAttrib.useBackward true in /-- An injection from the type of strictly monotone functions with limited length to `LTSeries`. -/ def injStrictMono (n : ℕ) : {f : (l : Fin n) × (Fin (l + 1) → α) // StrictMono f.2} ↪ LTSeries α where diff --git a/Mathlib/Topology/Algebra/Group/Basic.lean b/Mathlib/Topology/Algebra/Group/Basic.lean index a03c483b096803..fe217c91527540 100644 --- a/Mathlib/Topology/Algebra/Group/Basic.lean +++ b/Mathlib/Topology/Algebra/Group/Basic.lean @@ -627,6 +627,7 @@ theorem nhds_one_symm' : map Inv.inv (𝓝 (1 : G)) = 𝓝 (1 : G) := theorem inv_mem_nhds_one {S : Set G} (hS : S ∈ (𝓝 1 : Filter G)) : S⁻¹ ∈ 𝓝 (1 : G) := by rwa [← nhds_one_symm'] at hS +set_option backward.defeqAttrib.useBackward true in /-- The map `(x, y) ↦ (x, x * y)` as a homeomorphism. This is a shear mapping. -/ @[to_additive /-- The map `(x, y) ↦ (x, x + y)` as a homeomorphism. This is a shear mapping. -/] protected def Homeomorph.shearMulRight : G × G ≃ₜ G × G := diff --git a/Mathlib/Topology/CompactOpen.lean b/Mathlib/Topology/CompactOpen.lean index d31458fbfb203c..22b77c8aa3e8a3 100644 --- a/Mathlib/Topology/CompactOpen.lean +++ b/Mathlib/Topology/CompactOpen.lean @@ -454,6 +454,7 @@ function spaces, see `Homeomorph.curry`. -/ def uncurry [LocallyCompactSpace Y] (f : C(X, C(Y, Z))) : C(X × Y, Z) := ⟨_, continuous_uncurry_of_continuous f⟩ +set_option backward.defeqAttrib.useBackward true in /-- The uncurrying process is a continuous map between function spaces. -/ theorem continuous_uncurry [LocallyCompactSpace X] [LocallyCompactSpace Y] : Continuous (uncurry : C(X, C(Y, Z)) → C(X × Y, Z)) := by diff --git a/Mathlib/Topology/Constructions/SumProd.lean b/Mathlib/Topology/Constructions/SumProd.lean index d311151fb14adf..42a7e80d017acb 100644 --- a/Mathlib/Topology/Constructions/SumProd.lean +++ b/Mathlib/Topology/Constructions/SumProd.lean @@ -624,6 +624,7 @@ namespace Homeomorph variable {X' Y' : Type*} [TopologicalSpace X'] [TopologicalSpace Y'] +set_option backward.defeqAttrib.useBackward true in /-- Product of two homeomorphisms. -/ def prodCongr (h₁ : X ≃ₜ X') (h₂ : Y ≃ₜ Y') : X × Y ≃ₜ X' × Y' where toEquiv := h₁.toEquiv.prodCongr h₂.toEquiv @@ -841,6 +842,7 @@ namespace Homeomorph variable {X' Y' : Type*} [TopologicalSpace X'] [TopologicalSpace Y'] +set_option backward.defeqAttrib.useBackward true in /-- Sum of two homeomorphisms. -/ def sumCongr (h₁ : X ≃ₜ X') (h₂ : Y ≃ₜ Y') : X ⊕ Y ≃ₜ X' ⊕ Y' where toEquiv := h₁.toEquiv.sumCongr h₂.toEquiv @@ -890,6 +892,7 @@ def sumAssoc : (X ⊕ Y) ⊕ Z ≃ₜ X ⊕ Y ⊕ Z where @[simp] lemma sumAssoc_toEquiv : (sumAssoc X Y Z).toEquiv = Equiv.sumAssoc X Y Z := rfl +set_option backward.defeqAttrib.useBackward true in /-- Four-way commutativity of the disjoint union. The name matches `add_add_add_comm`. -/ def sumSumSumComm : (X ⊕ Y) ⊕ W ⊕ Z ≃ₜ (X ⊕ W) ⊕ Y ⊕ Z where toEquiv := Equiv.sumSumSumComm X Y W Z diff --git a/Mathlib/Topology/FiberBundle/Constructions.lean b/Mathlib/Topology/FiberBundle/Constructions.lean index 554752cb6da4d5..013735ad115146 100644 --- a/Mathlib/Topology/FiberBundle/Constructions.lean +++ b/Mathlib/Topology/FiberBundle/Constructions.lean @@ -64,6 +64,7 @@ def trivialization : Trivialization F (π F (Bundle.Trivial B F)) where target_eq := univ_prod_univ.symm proj_toFun _ _ := rfl +set_option backward.defeqAttrib.useBackward true in @[simp] lemma trivialization_symm_apply [Zero F] (b : B) (f : F) : (trivialization B F).symm b f = f := by simp [trivialization, homeomorphProd, TotalSpace.toProd, Trivialization.symm, diff --git a/Mathlib/Topology/Homeomorph/Lemmas.lean b/Mathlib/Topology/Homeomorph/Lemmas.lean index 5b2264e36a9f42..2cc11b65692ac9 100644 --- a/Mathlib/Topology/Homeomorph/Lemmas.lean +++ b/Mathlib/Topology/Homeomorph/Lemmas.lean @@ -153,6 +153,7 @@ theorem comp_continuousWithinAt_iff (h : X ≃ₜ Y) (f : Z → X) (s : Set Z) ( ContinuousWithinAt f s z ↔ ContinuousWithinAt (h ∘ f) s z := h.isInducing.continuousWithinAt_iff +set_option backward.defeqAttrib.useBackward true in /-- A homeomorphism `h : X ≃ₜ Y` lifts to a homeomorphism between subtypes corresponding to predicates `p : X → Prop` and `q : Y → Prop` so long as `p = q ∘ h`. -/ @[simps!] @@ -170,6 +171,7 @@ whenever `h` maps `s` onto `t`. -/ abbrev sets {s : Set X} {t : Set Y} (h : X ≃ₜ Y) (h_eq : s = h ⁻¹' t) : s ≃ₜ t := h.subtype <| Set.ext_iff.mp h_eq +set_option backward.defeqAttrib.useBackward true in /-- If two sets are equal, then they are homeomorphic. -/ def setCongr {s t : Set X} (h : s = t) : s ≃ₜ t where toEquiv := Equiv.setCongr h @@ -194,6 +196,7 @@ def uniqueProd (X Y : Type*) [TopologicalSpace X] [TopologicalSpace Y] [Unique X @[simp] theorem coe_uniqueProd [Unique X] : ⇑(uniqueProd X Y) = Prod.snd := rfl +set_option backward.defeqAttrib.useBackward true in /-- The product over `S ⊕ T` of a family of topological spaces is homeomorphic to the product of (the product over `S`) and (the product over `T`). @@ -242,6 +245,7 @@ lemma piCongrLeft_apply_apply {ι ι' : Type*} {Y : ι' → Type*} [∀ j, Topol (e : ι ≃ ι') (x : ∀ i, Y (e i)) (i : ι) : piCongrLeft e x (e i) = x i := Equiv.piCongrLeft_apply_apply .. +set_option backward.defeqAttrib.useBackward true in /-- `Equiv.piCongrRight` as a homeomorphism: this is the natural homeomorphism `Π i, Y₁ i ≃ₜ Π j, Y₂ i` obtained from homeomorphisms `Y₁ i ≃ₜ Y₂ i` for each `i`. -/ @[simps! apply toEquiv] @@ -318,6 +322,7 @@ def sigmaProdDistrib : (Σ i, X i) × Y ≃ₜ Σ i, X i × Y := end Distrib +set_option backward.defeqAttrib.useBackward true in /-- If `ι` has a unique element, then `ι → X` is homeomorphic to `X`. -/ @[simps! -fullyApplied] def funUnique (ι X : Type*) [Unique ι] [TopologicalSpace X] : (ι → X) ≃ₜ X where diff --git a/lakefile.lean b/lakefile.lean index b092a6cfd61363..01139cd9a10a64 100644 --- a/lakefile.lean +++ b/lakefile.lean @@ -43,10 +43,6 @@ abbrev mathlibLeanOptions := #[ ⟨`pp.unicode.fun, true⟩, -- pretty-prints `fun a ↦ b` ⟨`autoImplicit, false⟩, ⟨`maxSynthPendingDepth, .ofNat 3⟩, - -- Start from the legacy permissive `[defeq]` behavior; files are progressively migrated away - -- from this option either by local `set_option backward.defeqAttrib.useBackward true in` - -- on individual proofs, or by making the underlying definitions `@[implicit_reducible]`. - ⟨`backward.defeqAttrib.useBackward, true⟩, ] ++ -- options that are used in `lake build` mathlibOnlyLinters.map fun s ↦ { s with name := `weak ++ s.name } From 4db29d564b7ac9f54628ce18c00fb6b04fb83846 Mon Sep 17 00:00:00 2001 From: Joachim Breitner Date: Tue, 21 Apr 2026 15:41:14 +0000 Subject: [PATCH 106/321] fix(Order/JordanHolder): file-level `set_option backward.defeqAttrib.useBackward true` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The per-declaration `set_option ... in` that `add_set_option.py` inserts does not take effect for this file — `simpa` inside `CompositionSeries.Equivalent.snoc` still fails with a kernel type mismatch. But a file-level `set_option ... true` at the top makes the build succeed. This discrepancy between scoped and file-level `set_option` is unexpected (both should make the option visible to `simpa` during elaboration) and worth a follow-up investigation. Co-Authored-By: Claude Opus 4.7 (1M context) --- Mathlib/Order/JordanHolder.lean | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Mathlib/Order/JordanHolder.lean b/Mathlib/Order/JordanHolder.lean index 14a5222e9c46d7..7976e72343f3ee 100644 --- a/Mathlib/Order/JordanHolder.lean +++ b/Mathlib/Order/JordanHolder.lean @@ -70,6 +70,8 @@ instances should not be a global instance. > See `JordanHolderModule.instJordanHolderLattice`. -/ +set_option backward.defeqAttrib.useBackward true + @[expose] public section From 8fe19ab13fb8877ff358ce7cf405263230a926ac Mon Sep 17 00:00:00 2001 From: Joachim Breitner Date: Tue, 21 Apr 2026 15:54:02 +0000 Subject: [PATCH 107/321] chore: second-pass per-declaration `set_option backward.defeqAttrib.useBackward true` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After fixing `JordanHolder`/`OmegaCompletePartialOrder` unblocked downstream modules, a second run of `add_set_option.py --option backward.defeqAttrib.useBackward --value true` found 74 more declarations in downstream files that also need the option (previously masked by cascade failures). Known outstanding failures (for follow-up): * `Mathlib.Order.JordanHolder:300` — still fails despite the file-level set_option; previously passed when the option was enabled globally in the lakefile, so something about the scoped interaction here warrants further investigation. * `Mathlib.CategoryTheory.Equivalence:110` — new failure. * `Mathlib.RingTheory.TensorProduct.Maps:132` — new failure. Co-Authored-By: Claude Opus 4.7 (1M context) --- Mathlib/Algebra/DirectSum/Algebra.lean | 1 + Mathlib/Algebra/DualNumber.lean | 1 + Mathlib/Algebra/Module/GradedModule.lean | 1 + Mathlib/Algebra/Module/Presentation/Free.lean | 1 + Mathlib/Algebra/Module/Presentation/Tensor.lean | 2 ++ Mathlib/Algebra/MonoidAlgebra/Basic.lean | 1 + Mathlib/Algebra/Polynomial/AlgebraMap.lean | 1 + Mathlib/Algebra/QuaternionBasis.lean | 1 + Mathlib/Algebra/Star/UnitaryStarAlgAut.lean | 1 + Mathlib/Algebra/TrivSqZeroExt/Basic.lean | 1 + Mathlib/Analysis/Analytic/ChangeOrigin.lean | 1 + Mathlib/Analysis/Analytic/Composition.lean | 1 + Mathlib/Analysis/Calculus/ContDiff/Bounds.lean | 1 + Mathlib/Analysis/Calculus/ContDiff/FaaDiBruno.lean | 2 ++ Mathlib/Analysis/Calculus/IteratedDeriv/FaaDiBruno.lean | 1 + Mathlib/Analysis/Normed/Lp/PiLp.lean | 1 + .../Analysis/SpecialFunctions/Trigonometric/Series.lean | 2 ++ Mathlib/CategoryTheory/Functor/ReflectsIso/Basic.lean | 1 + Mathlib/CategoryTheory/Sigma/Basic.lean | 1 + Mathlib/Combinatorics/SimpleGraph/Acyclic.lean | 1 + Mathlib/Combinatorics/SimpleGraph/Clique.lean | 1 + Mathlib/Control/LawfulFix.lean | 2 ++ Mathlib/Data/Matrix/Basis.lean | 1 + Mathlib/Data/Matrix/Composition.lean | 2 ++ Mathlib/Data/ZMod/Basic.lean | 1 + Mathlib/GroupTheory/CoprodI.lean | 1 + Mathlib/GroupTheory/HNNExtension.lean | 1 + Mathlib/LinearAlgebra/Alternating/DomCoprod.lean | 1 + Mathlib/LinearAlgebra/CliffordAlgebra/Contraction.lean | 1 + Mathlib/LinearAlgebra/CliffordAlgebra/EvenEquiv.lean | 1 + Mathlib/LinearAlgebra/ExteriorAlgebra/OfAlternating.lean | 2 ++ Mathlib/LinearAlgebra/ExteriorPower/Basic.lean | 1 + Mathlib/LinearAlgebra/QuadraticForm/Basic.lean | 1 + Mathlib/LinearAlgebra/QuadraticForm/Prod.lean | 1 + Mathlib/LinearAlgebra/TensorProduct/Basic.lean | 1 + Mathlib/LinearAlgebra/TensorProduct/Graded/External.lean | 5 +++++ Mathlib/LinearAlgebra/TensorProduct/Graded/Internal.lean | 3 +++ Mathlib/LinearAlgebra/TensorProduct/Pi.lean | 1 + Mathlib/RingTheory/Coalgebra/TensorProduct.lean | 7 +++++++ Mathlib/RingTheory/Filtration.lean | 1 + Mathlib/RingTheory/Ideal/Operations.lean | 1 + Mathlib/RingTheory/Localization/Basic.lean | 1 + Mathlib/RingTheory/MvPolynomial/Homogeneous.lean | 1 + Mathlib/RingTheory/Polynomial/Basic.lean | 1 + Mathlib/RingTheory/TensorProduct/Basic.lean | 1 + Mathlib/RingTheory/TensorProduct/Maps.lean | 1 + Mathlib/RingTheory/Valuation/RankOne.lean | 1 + Mathlib/Topology/Algebra/ContinuousAffineEquiv.lean | 1 + Mathlib/Topology/ContinuousMap/Polynomial.lean | 2 ++ Mathlib/Topology/ContinuousMap/StoneWeierstrass.lean | 1 + Mathlib/Topology/Homotopy/Affine.lean | 1 + Mathlib/Topology/Instances/RealVectorSpace.lean | 1 + Mathlib/Topology/UrysohnsBounded.lean | 1 + Mathlib/Topology/VectorBundle/Constructions.lean | 1 + Mathlib/Topology/VectorBundle/Hom.lean | 2 ++ 55 files changed, 75 insertions(+) diff --git a/Mathlib/Algebra/DirectSum/Algebra.lean b/Mathlib/Algebra/DirectSum/Algebra.lean index 360337e1ceb150..cdaafbd69f8814 100644 --- a/Mathlib/Algebra/DirectSum/Algebra.lean +++ b/Mathlib/Algebra/DirectSum/Algebra.lean @@ -71,6 +71,7 @@ instance _root_.GradedMonoid.isScalarTower_right : variable [DecidableEq ι] +set_option backward.defeqAttrib.useBackward true in instance : Algebra R (⨁ i, A i) where algebraMap := { toFun := (DirectSum.of A 0).comp GAlgebra.toFun diff --git a/Mathlib/Algebra/DualNumber.lean b/Mathlib/Algebra/DualNumber.lean index 0aa6f91306f180..a06daae5579828 100644 --- a/Mathlib/Algebra/DualNumber.lean +++ b/Mathlib/Algebra/DualNumber.lean @@ -113,6 +113,7 @@ nonrec theorem algHom_ext' ⦃f g : A[ε] →ₐ[R] B⦄ change f (inr a) = g (inr a) simpa only [inr_eq_smul_eps] using DFunLike.congr_fun hinr a) +set_option backward.defeqAttrib.useBackward true in /-- For two `R`-algebra morphisms out of `R[ε]` to agree, it suffices for them to agree on `ε`. -/ @[ext 1200] theorem algHom_ext ⦃f g : R[ε] →ₐ[R] A⦄ (hε : f ε = g ε) : f = g := by diff --git a/Mathlib/Algebra/Module/GradedModule.lean b/Mathlib/Algebra/Module/GradedModule.lean index 4a8a2e32e392ae..261243c3559cd8 100644 --- a/Mathlib/Algebra/Module/GradedModule.lean +++ b/Mathlib/Algebra/Module/GradedModule.lean @@ -114,6 +114,7 @@ private theorem one_smul' [DecidableEq ιA] [DecidableEq ιB] [GMonoid A] [Gmodu rw [smulAddMonoidHom_apply_of_of] exact DirectSum.of_eq_of_gradedMonoid_eq (one_smul (GradedMonoid A) <| GradedMonoid.mk i xi) +set_option backward.defeqAttrib.useBackward true in -- Almost identical to the proof of `direct_sum.mul_assoc` set_option backward.privateInPublic true in private theorem mul_smul' [DecidableEq ιA] [DecidableEq ιB] [GSemiring A] [Gmodule A M] diff --git a/Mathlib/Algebra/Module/Presentation/Free.lean b/Mathlib/Algebra/Module/Presentation/Free.lean index 3f652df5cef186..d8a36983dbb40a 100644 --- a/Mathlib/Algebra/Module/Presentation/Free.lean +++ b/Mathlib/Algebra/Module/Presentation/Free.lean @@ -76,6 +76,7 @@ noncomputable def presentationFinsupp (G : Type w₀) : toSolution := Relations.solutionFinsupp _ toIsPresentation := by exact Relations.solutionFinsupp_isPresentation _ +set_option backward.defeqAttrib.useBackward true in lemma free_iff_exists_presentation : Free A M ↔ ∃ (p : Presentation.{v, w₁} A M), IsEmpty p.R := by constructor diff --git a/Mathlib/Algebra/Module/Presentation/Tensor.lean b/Mathlib/Algebra/Module/Presentation/Tensor.lean index 6228317222b3af..d16bb75f4d2b8b 100644 --- a/Mathlib/Algebra/Module/Presentation/Tensor.lean +++ b/Mathlib/Algebra/Module/Presentation/Tensor.lean @@ -47,6 +47,7 @@ namespace Solution variable {relations₁ relations₂} (solution₁ : relations₁.Solution M₁) (solution₂ : relations₂.Solution M₂) +set_option backward.defeqAttrib.useBackward true in set_option backward.isDefEq.respectTransparency false in /-- Given solutions in `M₁` and `M₂` to systems of linear equations, this is the obvious solution to the tensor product of these systems in `M₁ ⊗[A] M₂`. -/ @@ -65,6 +66,7 @@ noncomputable def tensor : (relations₁.tensor relations₂).Solution (M₁ ⊗ variable {solution₁ solution₂} (h₁ : solution₁.IsPresentation) (h₂ : solution₂.IsPresentation) +set_option backward.defeqAttrib.useBackward true in set_option backward.isDefEq.respectTransparency false in /-- The tensor product of two modules admits a presentation by generators and relations. -/ noncomputable def isPresentationCoreTensor : diff --git a/Mathlib/Algebra/MonoidAlgebra/Basic.lean b/Mathlib/Algebra/MonoidAlgebra/Basic.lean index beafcef436f651..3c2c23acca060e 100644 --- a/Mathlib/Algebra/MonoidAlgebra/Basic.lean +++ b/Mathlib/Algebra/MonoidAlgebra/Basic.lean @@ -93,6 +93,7 @@ end NonUnitalNonAssocAlgebra section Algebra variable [CommSemiring R] [Semiring A] [Algebra R A] [Monoid M] [Monoid N] +set_option backward.defeqAttrib.useBackward true in /-- The instance `Algebra R A[M]` whenever we have `Algebra R A`. In particular this provides the instance `Algebra R R[M]`. -/ diff --git a/Mathlib/Algebra/Polynomial/AlgebraMap.lean b/Mathlib/Algebra/Polynomial/AlgebraMap.lean index 553373565830d7..be5edfe0f1c327 100644 --- a/Mathlib/Algebra/Polynomial/AlgebraMap.lean +++ b/Mathlib/Algebra/Polynomial/AlgebraMap.lean @@ -104,6 +104,7 @@ theorem algHom_ext' {f g : A[X] →ₐ[R] B} (hX : f X = g X) : f = g := AlgHom.coe_ringHom_injective (ringHom_ext' (congr_arg AlgHom.toRingHom hC) hX) +set_option backward.defeqAttrib.useBackward true in variable (R) in open AddMonoidAlgebra in /-- Algebra isomorphism between `R[X]` and `R[ℕ]`. This is just an diff --git a/Mathlib/Algebra/QuaternionBasis.lean b/Mathlib/Algebra/QuaternionBasis.lean index 4c332a97f538c9..925163a09a78e8 100644 --- a/Mathlib/Algebra/QuaternionBasis.lean +++ b/Mathlib/Algebra/QuaternionBasis.lean @@ -174,6 +174,7 @@ def compHom (F : A →ₐ[R] B) : Basis B c₁ c₂ c₃ where end Basis +set_option backward.defeqAttrib.useBackward true in /-- A quaternionic basis on `A` is equivalent to a map from the quaternion algebra to `A`. -/ @[simps] def lift : Basis A c₁ c₂ c₃ ≃ (ℍ[R,c₁,c₂,c₃] →ₐ[R] A) where diff --git a/Mathlib/Algebra/Star/UnitaryStarAlgAut.lean b/Mathlib/Algebra/Star/UnitaryStarAlgAut.lean index dbc7d5cfdb6aca..25d846324e92f6 100644 --- a/Mathlib/Algebra/Star/UnitaryStarAlgAut.lean +++ b/Mathlib/Algebra/Star/UnitaryStarAlgAut.lean @@ -23,6 +23,7 @@ namespace Unitary variable {S R : Type*} [Semiring R] [StarMul R] [SMul S R] [IsScalarTower S R R] [SMulCommClass S R R] +set_option backward.defeqAttrib.useBackward true in variable (S R) in /-- Each unitary element `u` defines a ⋆-algebra automorphism such that `x ↦ u * x * star u`. diff --git a/Mathlib/Algebra/TrivSqZeroExt/Basic.lean b/Mathlib/Algebra/TrivSqZeroExt/Basic.lean index 780d60faf98b42..0d2a4b8f1e61c5 100644 --- a/Mathlib/Algebra/TrivSqZeroExt/Basic.lean +++ b/Mathlib/Algebra/TrivSqZeroExt/Basic.lean @@ -924,6 +924,7 @@ theorem algHom_ext' {A} [Semiring A] [Algebra S A] ⦃f g : tsze R M →ₐ[S] A variable {A : Type*} [Semiring A] [Algebra S A] [Algebra R' A] +set_option backward.defeqAttrib.useBackward true in /-- Assemble an algebra morphism `TrivSqZeroExt R M →ₐ[S] A` from separate morphisms on `R` and `M`. diff --git a/Mathlib/Analysis/Analytic/ChangeOrigin.lean b/Mathlib/Analysis/Analytic/ChangeOrigin.lean index b95041cfe9ed39..f42c81a0539917 100644 --- a/Mathlib/Analysis/Analytic/ChangeOrigin.lean +++ b/Mathlib/Analysis/Analytic/ChangeOrigin.lean @@ -159,6 +159,7 @@ lemma changeOriginSeriesTerm_changeOriginIndexEquiv_symm (n t) : simp +unfoldPartialApp [Finset.piecewise] simp_rw [changeOriginSeriesTerm_apply, eq_comm]; apply this +set_option backward.defeqAttrib.useBackward true in set_option backward.isDefEq.respectTransparency false in theorem changeOriginSeries_summable_aux₁ {r r' : ℝ≥0} (hr : (r + r' : ℝ≥0∞) < p.radius) : Summable fun s : Σ k l : ℕ, { s : Finset (Fin (k + l)) // s.card = l } => diff --git a/Mathlib/Analysis/Analytic/Composition.lean b/Mathlib/Analysis/Analytic/Composition.lean index 57015f27b54b07..c1b39a9eead06c 100644 --- a/Mathlib/Analysis/Analytic/Composition.lean +++ b/Mathlib/Analysis/Analytic/Composition.lean @@ -1253,6 +1253,7 @@ namespace FormalMultilinearSeries open Composition +set_option backward.defeqAttrib.useBackward true in set_option backward.isDefEq.respectTransparency false in theorem comp_assoc (r : FormalMultilinearSeries 𝕜 G H) (q : FormalMultilinearSeries 𝕜 F G) (p : FormalMultilinearSeries 𝕜 E F) : (r.comp q).comp p = r.comp (q.comp p) := by diff --git a/Mathlib/Analysis/Calculus/ContDiff/Bounds.lean b/Mathlib/Analysis/Calculus/ContDiff/Bounds.lean index 1388260f7c86bb..553735e3ae7b6c 100644 --- a/Mathlib/Analysis/Calculus/ContDiff/Bounds.lean +++ b/Mathlib/Analysis/Calculus/ContDiff/Bounds.lean @@ -283,6 +283,7 @@ theorem norm_iteratedFDeriv_mul_le {f : E → A} {g : E → A} {N : ℕ∞ω} (h -- TODO: Add `norm_iteratedFDeriv[Within]_list_prod_le` for non-commutative `NormedRing A`. +set_option backward.defeqAttrib.useBackward true in set_option backward.isDefEq.respectTransparency false in theorem norm_iteratedFDerivWithin_prod_le [DecidableEq ι] [NormOneClass A'] {u : Finset ι} {f : ι → E → A'} {N : ℕ∞ω} (hf : ∀ i ∈ u, ContDiffOn 𝕜 N (f i) s) diff --git a/Mathlib/Analysis/Calculus/ContDiff/FaaDiBruno.lean b/Mathlib/Analysis/Calculus/ContDiff/FaaDiBruno.lean index 5be0a0471ae386..2294dbc0b7da70 100644 --- a/Mathlib/Analysis/Calculus/ContDiff/FaaDiBruno.lean +++ b/Mathlib/Analysis/Calculus/ContDiff/FaaDiBruno.lean @@ -224,6 +224,7 @@ lemma neZero_partSize (c : OrderedFinpartition n) (i : Fin c.length) : NeZero (c attribute [local instance] neZero_length neZero_partSize +set_option backward.defeqAttrib.useBackward true in instance instUniqueOne : Unique (OrderedFinpartition 1) where uniq c := by have h₁ : c.length = 1 := le_antisymm c.length_le (c.length_pos Nat.zero_lt_one) @@ -1048,6 +1049,7 @@ private lemma faaDiBruno_aux2 {m : ℕ} (q : FormalMultilinearSeries 𝕜 F G) apply FormalMultilinearSeries.congr _ (by simp [hij]) simp +set_option backward.defeqAttrib.useBackward true in set_option backward.isDefEq.respectTransparency false in /-- *Faa di Bruno* formula: If two functions `g` and `f` have Taylor series up to `n` given by `q` and `p`, then `g ∘ f` also has a Taylor series, given by `q.taylorComp p`. -/ diff --git a/Mathlib/Analysis/Calculus/IteratedDeriv/FaaDiBruno.lean b/Mathlib/Analysis/Calculus/IteratedDeriv/FaaDiBruno.lean index f0f4e7b2777268..5cd739cbba6968 100644 --- a/Mathlib/Analysis/Calculus/IteratedDeriv/FaaDiBruno.lean +++ b/Mathlib/Analysis/Calculus/IteratedDeriv/FaaDiBruno.lean @@ -86,6 +86,7 @@ theorem iteratedDeriv_vcomp_two (hg : ContDiffAt 𝕜 2 g (f x)) (hf : ContDiffA exact iteratedDerivWithin_vcomp_two hg hf uniqueDiffOn_univ uniqueDiffOn_univ (mem_univ x) (mapsTo_univ f _) +set_option backward.defeqAttrib.useBackward true in set_option backward.isDefEq.respectTransparency false in theorem iteratedDerivWithin_vcomp_three (hg : ContDiffWithinAt 𝕜 3 g t (f x)) (hf : ContDiffWithinAt 𝕜 3 f s x) diff --git a/Mathlib/Analysis/Normed/Lp/PiLp.lean b/Mathlib/Analysis/Normed/Lp/PiLp.lean index 7064933d0aff78..3c0cec96ea2e0e 100644 --- a/Mathlib/Analysis/Normed/Lp/PiLp.lean +++ b/Mathlib/Analysis/Normed/Lp/PiLp.lean @@ -947,6 +947,7 @@ variable {ι : Type*} {κ : ι → Type*} (p : ℝ≥0∞) [Fact (1 ≤ p)] [Fintype ι] [∀ i, Fintype (κ i)] (α : ∀ i, κ i → Type*) [∀ i k, SeminormedAddCommGroup (α i k)] [∀ i k, Module 𝕜 (α i k)] +set_option backward.defeqAttrib.useBackward true in variable (𝕜) in /-- `LinearEquiv.piCurry` for `PiLp`, as an isometry. -/ def _root_.LinearIsometryEquiv.piLpCurry : diff --git a/Mathlib/Analysis/SpecialFunctions/Trigonometric/Series.lean b/Mathlib/Analysis/SpecialFunctions/Trigonometric/Series.lean index 37d773c2794887..dab87615a774d7 100644 --- a/Mathlib/Analysis/SpecialFunctions/Trigonometric/Series.lean +++ b/Mathlib/Analysis/SpecialFunctions/Trigonometric/Series.lean @@ -32,6 +32,7 @@ open scoped Nat section SinCos +set_option backward.defeqAttrib.useBackward true in theorem Complex.hasSum_cos' (z : ℂ) : HasSum (fun n : ℕ => (z * Complex.I) ^ (2 * n) / ↑(2 * n)!) (Complex.cos z) := by rw [Complex.cos, Complex.exp_eq_exp_ℂ] @@ -48,6 +49,7 @@ theorem Complex.hasSum_cos' (z : ℂ) : neg_mul, mul_neg, neg_div, add_neg_cancel, zero_div, add_zero, mul_div_cancel_left₀ _ (two_ne_zero : (2 : ℂ) ≠ 0)] +set_option backward.defeqAttrib.useBackward true in theorem Complex.hasSum_sin' (z : ℂ) : HasSum (fun n : ℕ => (z * Complex.I) ^ (2 * n + 1) / ↑(2 * n + 1)! / Complex.I) (Complex.sin z) := by diff --git a/Mathlib/CategoryTheory/Functor/ReflectsIso/Basic.lean b/Mathlib/CategoryTheory/Functor/ReflectsIso/Basic.lean index a0b485a7113313..0478bdc076e3f1 100644 --- a/Mathlib/CategoryTheory/Functor/ReflectsIso/Basic.lean +++ b/Mathlib/CategoryTheory/Functor/ReflectsIso/Basic.lean @@ -66,6 +66,7 @@ instance reflectsIsomorphisms_comp (F : C ⥤ D) (G : D ⥤ E) haveI := isIso_of_reflects_iso (F.map f) G exact isIso_of_reflects_iso f F⟩ +set_option backward.defeqAttrib.useBackward true in lemma reflectsIsomorphisms_of_comp (F : C ⥤ D) (G : D ⥤ E) [(F ⋙ G).ReflectsIsomorphisms] : F.ReflectsIsomorphisms where reflects f _ := by diff --git a/Mathlib/CategoryTheory/Sigma/Basic.lean b/Mathlib/CategoryTheory/Sigma/Basic.lean index 4eeca6d0916186..974fd93ce08269 100644 --- a/Mathlib/CategoryTheory/Sigma/Basic.lean +++ b/Mathlib/CategoryTheory/Sigma/Basic.lean @@ -133,6 +133,7 @@ def desc : (Σ i, C i) ⥤ D where lemma desc_map_mk {i : I} (X Y : C i) (f : X ⟶ Y) : (desc F).map (SigmaHom.mk f) = (F i).map f := rfl +set_option backward.defeqAttrib.useBackward true in -- We hand-generate the simp lemmas about this since they come out cleaner. /-- This shows that when `desc F` is restricted to just the subcategory `C i`, `desc F` agrees with `F i`. diff --git a/Mathlib/Combinatorics/SimpleGraph/Acyclic.lean b/Mathlib/Combinatorics/SimpleGraph/Acyclic.lean index eb59c192fc81c4..3c60bf70530005 100644 --- a/Mathlib/Combinatorics/SimpleGraph/Acyclic.lean +++ b/Mathlib/Combinatorics/SimpleGraph/Acyclic.lean @@ -158,6 +158,7 @@ theorem IsTree.coe_singletonSubgraph (G : SimpleGraph V) (v : V) : G.singletonSubgraph v |>.coe.IsTree := .of_subsingleton +set_option backward.defeqAttrib.useBackward true in theorem IsTree.coe_subgraphOfAdj {u v : V} (h : G.Adj u v) : G.subgraphOfAdj h |>.coe.IsTree := by refine ⟨Subgraph.subgraphOfAdj_connected h, fun w p hp ↦ ?_⟩ have : _ = _ := p.adj_snd <| nil_iff_eq_nil.not.mpr hp.ne_nil diff --git a/Mathlib/Combinatorics/SimpleGraph/Clique.lean b/Mathlib/Combinatorics/SimpleGraph/Clique.lean index 6d5c164b94a8c6..9a4bf1f6885e54 100644 --- a/Mathlib/Combinatorics/SimpleGraph/Clique.lean +++ b/Mathlib/Combinatorics/SimpleGraph/Clique.lean @@ -830,6 +830,7 @@ theorem isIndepSet_neighborSet_of_triangleFree (h : G.CliqueFree 3) (v : α) : obtain ⟨j, avj, k, avk, _, ajk⟩ := nind exact h {v, j, k} (is3Clique_triple_iff.mpr (by simp [avj, avk, ajk])) +set_option backward.defeqAttrib.useBackward true in /-- The embedding of an independent set of an induced subgraph of the subgraph `G` is an independent set in `G` and vice versa. -/ theorem isIndepSet_induce {F : Set α} {s : Set F} : diff --git a/Mathlib/Control/LawfulFix.lean b/Mathlib/Control/LawfulFix.lean index 64ee89d87aa87f..06eeb64c55017f 100644 --- a/Mathlib/Control/LawfulFix.lean +++ b/Mathlib/Control/LawfulFix.lean @@ -175,6 +175,7 @@ def toUnitMono (f : Part α →o Part α) : (Unit → Part α) →o Unit → Par toFun x u := f (x u) monotone' x y (h : x ≤ y) u := f.monotone <| h u +set_option backward.defeqAttrib.useBackward true in theorem ωScottContinuous_toUnitMono (f : Part α → Part α) (hc : ωScottContinuous f) : ωScottContinuous (toUnitMono ⟨f,hc.monotone⟩) := .of_map_ωSup_of_orderHom fun _ => by ext ⟨⟩ : 1 @@ -228,6 +229,7 @@ theorem ωScottContinuous_curry : rw [map_comp, map_comp] rfl +set_option backward.defeqAttrib.useBackward true in theorem ωScottContinuous_uncurry : ωScottContinuous (monotoneUncurry α β γ) := .of_map_ωSup_of_orderHom fun c ↦ by diff --git a/Mathlib/Data/Matrix/Basis.lean b/Mathlib/Data/Matrix/Basis.lean index 38229a55747bd2..e150be477dc323 100644 --- a/Mathlib/Data/Matrix/Basis.lean +++ b/Mathlib/Data/Matrix/Basis.lean @@ -257,6 +257,7 @@ theorem liftLinear_apply (f : m → n → α →ₗ[R] β) (M : Matrix m n α) : liftLinear S f M = ∑ i, ∑ j, f i j (M i j) := by simp [liftLinear, map_sum, LinearEquiv.congrLeft] +set_option backward.defeqAttrib.useBackward true in @[simp] theorem liftLinear_single (f : m → n → α →ₗ[R] β) (i : m) (j : n) (a : α) : liftLinear S f (Matrix.single i j a) = f i j a := by diff --git a/Mathlib/Data/Matrix/Composition.lean b/Mathlib/Data/Matrix/Composition.lean index feceef9c80aad5..779704cb57bfd1 100644 --- a/Mathlib/Data/Matrix/Composition.lean +++ b/Mathlib/Data/Matrix/Composition.lean @@ -47,6 +47,7 @@ theorem comp_one [DecidableEq I] [DecidableEq J] [Zero R] [One R] : comp I I J J theorem comp_map_map (M : Matrix I J (Matrix K L R)) (f : R → R') : comp I J K L _ (M.map (fun M' => M'.map f)) = (comp I J K L _ M).map f := rfl +set_option backward.defeqAttrib.useBackward true in @[simp] theorem comp_single_single [DecidableEq I] [DecidableEq J] [DecidableEq K] [DecidableEq L] [Zero R] (i j k l r) : @@ -76,6 +77,7 @@ theorem comp_symm_single (single ii.1 jj.1 (single ii.2 jj.2 r)) := (comp I J K L R).symm_apply_eq.2 <| comp_single_single _ _ _ _ _ |>.symm +set_option backward.defeqAttrib.useBackward true in @[simp] theorem comp_diagonal_diagonal [DecidableEq I] [DecidableEq J] [Zero R] (d : I → J → R) : comp I I J J R (diagonal fun i => diagonal fun j => d i j) diff --git a/Mathlib/Data/ZMod/Basic.lean b/Mathlib/Data/ZMod/Basic.lean index 6a5b310e60eaf1..dec418ecc23823 100644 --- a/Mathlib/Data/ZMod/Basic.lean +++ b/Mathlib/Data/ZMod/Basic.lean @@ -426,6 +426,7 @@ noncomputable def ringEquivOfPrime [Fintype R] {p : ℕ} (hp : p.Prime) (hR : Fi lemma ringEquivOfPrime_eq_ringEquiv [Fintype R] {p : ℕ} [CharP R p] (hp : p.Prime) (hR : Fintype.card R = p) : ringEquivOfPrime R hp hR = ringEquiv R hR := rfl +set_option backward.defeqAttrib.useBackward true in set_option backward.isDefEq.respectTransparency false in /-- The identity between `ZMod m` and `ZMod n` when `m = n`, as a ring isomorphism. -/ def ringEquivCongr {m n : ℕ} (h : m = n) : ZMod m ≃+* ZMod n := by diff --git a/Mathlib/GroupTheory/CoprodI.lean b/Mathlib/GroupTheory/CoprodI.lean index 0f468c77bebcee..97357837dbf1d2 100644 --- a/Mathlib/GroupTheory/CoprodI.lean +++ b/Mathlib/GroupTheory/CoprodI.lean @@ -458,6 +458,7 @@ theorem mem_of_mem_equivPair_tail {i j : ι} {w : Word M} (m : M i) : · exact List.mem_of_mem_tail h · revert h; cases w.toList <;> simp +contextual +set_option backward.defeqAttrib.useBackward true in theorem equivPair_head {i : ι} {w : Word M} : (equivPair i w).head = if h : ∃ (h : w.toList ≠ []), (w.toList.head h).1 = i diff --git a/Mathlib/GroupTheory/HNNExtension.lean b/Mathlib/GroupTheory/HNNExtension.lean index af09bdcc2e9662..86c6925014ddd5 100644 --- a/Mathlib/GroupTheory/HNNExtension.lean +++ b/Mathlib/GroupTheory/HNNExtension.lean @@ -418,6 +418,7 @@ theorem unitsSMul_cancels_iff (u : ℤˣ) (w : NormalWord d) : · simp only [unitsSMul, dif_neg h] simpa [Cancels] using h +set_option backward.defeqAttrib.useBackward true in theorem unitsSMul_neg (u : ℤˣ) (w : NormalWord d) : unitsSMul φ (-u) (unitsSMul φ u w) = w := by rw [unitsSMul] diff --git a/Mathlib/LinearAlgebra/Alternating/DomCoprod.lean b/Mathlib/LinearAlgebra/Alternating/DomCoprod.lean index 21814ea9f9e69d..d8b752d8af93e2 100644 --- a/Mathlib/LinearAlgebra/Alternating/DomCoprod.lean +++ b/Mathlib/LinearAlgebra/Alternating/DomCoprod.lean @@ -42,6 +42,7 @@ open Equiv variable [DecidableEq ιa] [DecidableEq ιb] +set_option backward.defeqAttrib.useBackward true in set_option backward.isDefEq.respectTransparency false in /-- summand used in `AlternatingMap.domCoprod` -/ def domCoprod.summand (a : Mᵢ [⋀^ιa]→ₗ[R'] N₁) (b : Mᵢ [⋀^ιb]→ₗ[R'] N₂) diff --git a/Mathlib/LinearAlgebra/CliffordAlgebra/Contraction.lean b/Mathlib/LinearAlgebra/CliffordAlgebra/Contraction.lean index 02f974fff1ba33..666ef75985c1da 100644 --- a/Mathlib/LinearAlgebra/CliffordAlgebra/Contraction.lean +++ b/Mathlib/LinearAlgebra/CliffordAlgebra/Contraction.lean @@ -75,6 +75,7 @@ theorem contractLeftAux_contractLeftAux (v : M) (x : CliffordAlgebra Q) (fx : Cl variable {Q} +set_option backward.defeqAttrib.useBackward true in /-- Contract an element of the Clifford algebra with an element `d : Module.Dual R M` from the left. Note that $v ⌋ x$ is spelt `contractLeft (Q.associated v) x`. diff --git a/Mathlib/LinearAlgebra/CliffordAlgebra/EvenEquiv.lean b/Mathlib/LinearAlgebra/CliffordAlgebra/EvenEquiv.lean index b1e59124ca7848..e9d288225c0c8b 100644 --- a/Mathlib/LinearAlgebra/CliffordAlgebra/EvenEquiv.lean +++ b/Mathlib/LinearAlgebra/CliffordAlgebra/EvenEquiv.lean @@ -71,6 +71,7 @@ theorem e0_mul_e0 : e0 Q * e0 Q = -1 := theorem v_sq_scalar (m : M) : v Q m * v Q m = algebraMap _ _ (Q m) := (ι_sq_scalar _ _).trans <| by simp +set_option backward.defeqAttrib.useBackward true in theorem neg_e0_mul_v (m : M) : -(e0 Q * v Q m) = v Q m * e0 Q := by refine neg_eq_of_add_eq_zero_right ((ι_mul_ι_add_swap _ _).trans ?_) dsimp [QuadraticMap.polar] diff --git a/Mathlib/LinearAlgebra/ExteriorAlgebra/OfAlternating.lean b/Mathlib/LinearAlgebra/ExteriorAlgebra/OfAlternating.lean index ccbbdfbe10f949..c615bc9bdf9f32 100644 --- a/Mathlib/LinearAlgebra/ExteriorAlgebra/OfAlternating.lean +++ b/Mathlib/LinearAlgebra/ExteriorAlgebra/OfAlternating.lean @@ -62,6 +62,7 @@ def liftAlternating : (∀ i, M [⋀^Fin i]→ₗ[R] N) →ₗ[R] ExteriorAlgebr ext simp +set_option backward.defeqAttrib.useBackward true in @[simp] theorem liftAlternating_ι (f : ∀ i, M [⋀^Fin i]→ₗ[R] N) (m : M) : liftAlternating (R := R) (M := M) (N := N) f (ι R m) = f 1 ![m] := by @@ -77,6 +78,7 @@ theorem liftAlternating_ι_mul (f : ∀ i, M [⋀^Fin i]→ₗ[R] N) (m : M) rw [foldl_mul, foldl_ι] rfl +set_option backward.defeqAttrib.useBackward true in @[simp] theorem liftAlternating_one (f : ∀ i, M [⋀^Fin i]→ₗ[R] N) : liftAlternating (R := R) (M := M) (N := N) f (1 : ExteriorAlgebra R M) = f 0 0 := by diff --git a/Mathlib/LinearAlgebra/ExteriorPower/Basic.lean b/Mathlib/LinearAlgebra/ExteriorPower/Basic.lean index beb5809e99aa93..78b4a8efdc4cf7 100644 --- a/Mathlib/LinearAlgebra/ExteriorPower/Basic.lean +++ b/Mathlib/LinearAlgebra/ExteriorPower/Basic.lean @@ -144,6 +144,7 @@ noncomputable def relations (ι : Type*) [DecidableEq ι] (M : Type*) r • Finsupp.single (update m i x) 1 | .alt m _ _ _ _ => Finsupp.single m 1 +set_option backward.defeqAttrib.useBackward true in set_option backward.isDefEq.respectTransparency false in variable {R} in /-- The solutions in a module `N` to the linear equations diff --git a/Mathlib/LinearAlgebra/QuadraticForm/Basic.lean b/Mathlib/LinearAlgebra/QuadraticForm/Basic.lean index cdadc86b91627c..4efac9c4491d24 100644 --- a/Mathlib/LinearAlgebra/QuadraticForm/Basic.lean +++ b/Mathlib/LinearAlgebra/QuadraticForm/Basic.lean @@ -906,6 +906,7 @@ theorem associated_apply (x y : M) : associatedHom S Q x y = ⅟(2 : Module.End R N) • (Q (x + y) - Q x - Q y) := rfl +set_option backward.defeqAttrib.useBackward true in /-- Twice the associated bilinear map of `Q` is the same as the polar of `Q`. -/ @[simp] theorem two_nsmul_associated : 2 • associatedHom S Q = Q.polarBilin := by ext diff --git a/Mathlib/LinearAlgebra/QuadraticForm/Prod.lean b/Mathlib/LinearAlgebra/QuadraticForm/Prod.lean index 6367b68e3220c3..ab97e401f5affb 100644 --- a/Mathlib/LinearAlgebra/QuadraticForm/Prod.lean +++ b/Mathlib/LinearAlgebra/QuadraticForm/Prod.lean @@ -209,6 +209,7 @@ variable [CommRing R] variable [AddCommGroup M₁] [AddCommGroup M₂] [AddCommGroup P] variable [Module R M₁] [Module R M₂] [Module R P] +set_option backward.defeqAttrib.useBackward true in @[simp] theorem polar_prod (Q₁ : QuadraticMap R M₁ P) (Q₂ : QuadraticMap R M₂ P) (x y : M₁ × M₂) : polar (Q₁.prod Q₂) x y = polar Q₁ x.1 y.1 + polar Q₂ x.2 y.2 := by dsimp [polar] diff --git a/Mathlib/LinearAlgebra/TensorProduct/Basic.lean b/Mathlib/LinearAlgebra/TensorProduct/Basic.lean index c9949b11f603e9..cfacbb10063b4f 100644 --- a/Mathlib/LinearAlgebra/TensorProduct/Basic.lean +++ b/Mathlib/LinearAlgebra/TensorProduct/Basic.lean @@ -92,6 +92,7 @@ variable {M N} variable (f : M →ₗ[R] N →ₗ[R] P) variable (f' : M →ₛₗ[σ₁₂] N →ₛₗ[σ₁₂] P₂) +set_option backward.defeqAttrib.useBackward true in /-- Auxiliary function to constructing a linear map `M ⊗ N → P` given a bilinear map `M → N → P` with the property that its composition with the canonical bilinear map `M → N → M ⊗ N` is the given bilinear map `M → N → P`. -/ diff --git a/Mathlib/LinearAlgebra/TensorProduct/Graded/External.lean b/Mathlib/LinearAlgebra/TensorProduct/Graded/External.lean index 6a8ec1085472fe..b39a374ea9cbb7 100644 --- a/Mathlib/LinearAlgebra/TensorProduct/Graded/External.lean +++ b/Mathlib/LinearAlgebra/TensorProduct/Graded/External.lean @@ -88,6 +88,7 @@ theorem gradedCommAux_lof_tmul (i j : ι) (a : 𝒜 i) (b : ℬ j) : rw [gradedCommAux] simp [mul_comm i j] +set_option backward.defeqAttrib.useBackward true in @[simp] theorem gradedCommAux_comp_gradedCommAux : gradedCommAux R 𝒜 ℬ ∘ₗ gradedCommAux R ℬ 𝒜 = LinearMap.id := by @@ -202,6 +203,7 @@ theorem tmul_of_gradedMul_of_tmul (j₁ i₂ : ι) variable {R} +set_option backward.defeqAttrib.useBackward true in theorem algebraMap_gradedMul (r : R) (x : (⨁ i, 𝒜 i) ⊗[R] (⨁ i, ℬ i)) : gradedMul R 𝒜 ℬ (algebraMap R _ r ⊗ₜ 1) x = r • x := by suffices gradedMul R 𝒜 ℬ (algebraMap R _ r ⊗ₜ 1) = DistribSMul.toLinearMap R _ r by @@ -217,6 +219,7 @@ theorem one_gradedMul (x : (⨁ i, 𝒜 i) ⊗[R] (⨁ i, ℬ i)) : -- Note: https://github.com/leanprover-community/mathlib4/pull/8386 had to specialize `map_one` to avoid timeouts. simpa only [RingHom.map_one, one_smul] using algebraMap_gradedMul 𝒜 ℬ 1 x +set_option backward.defeqAttrib.useBackward true in theorem gradedMul_algebraMap (x : (⨁ i, 𝒜 i) ⊗[R] (⨁ i, ℬ i)) (r : R) : gradedMul R 𝒜 ℬ x (algebraMap R _ r ⊗ₜ 1) = r • x := by suffices (gradedMul R 𝒜 ℬ).flip (algebraMap R _ r ⊗ₜ 1) = DistribSMul.toLinearMap R _ r by @@ -233,6 +236,7 @@ theorem gradedMul_one (x : (⨁ i, 𝒜 i) ⊗[R] (⨁ i, ℬ i)) : -- Note: https://github.com/leanprover-community/mathlib4/pull/8386 had to specialize `map_one` to avoid timeouts. simpa only [RingHom.map_one, one_smul] using gradedMul_algebraMap 𝒜 ℬ x 1 +set_option backward.defeqAttrib.useBackward true in theorem gradedMul_assoc (x y z : DirectSum _ 𝒜 ⊗[R] DirectSum _ ℬ) : gradedMul R 𝒜 ℬ (gradedMul R 𝒜 ℬ x y) z = gradedMul R 𝒜 ℬ x (gradedMul R 𝒜 ℬ y z) := by let mA := gradedMul R 𝒜 ℬ @@ -251,6 +255,7 @@ theorem gradedMul_assoc (x y z : DirectSum _ 𝒜 ⊗[R] DirectSum _ ℬ) : congr 2 abel +set_option backward.defeqAttrib.useBackward true in theorem gradedComm_gradedMul (x y : DirectSum _ 𝒜 ⊗[R] DirectSum _ ℬ) : gradedComm R 𝒜 ℬ (gradedMul R 𝒜 ℬ x y) = gradedMul R ℬ 𝒜 (gradedComm R 𝒜 ℬ x) (gradedComm R 𝒜 ℬ y) := by diff --git a/Mathlib/LinearAlgebra/TensorProduct/Graded/Internal.lean b/Mathlib/LinearAlgebra/TensorProduct/Graded/Internal.lean index 72c3737ee2bc2d..e4a5dcdcbd2051 100644 --- a/Mathlib/LinearAlgebra/TensorProduct/Graded/Internal.lean +++ b/Mathlib/LinearAlgebra/TensorProduct/Graded/Internal.lean @@ -240,6 +240,7 @@ def includeLeftRingHom : A →+* 𝒜 ᵍ⊗[R] ℬ where rw [← SetLike.coe_gOne ℬ, tmul_coe_mul_coe_tmul, zero_mul, uzpow_zero, one_smul, SetLike.coe_gOne, one_mul] +set_option backward.defeqAttrib.useBackward true in instance instAlgebra : Algebra R (𝒜 ᵍ⊗[R] ℬ) where algebraMap := (includeLeftRingHom 𝒜 ℬ).comp (algebraMap R A) commutes' r x := by @@ -292,6 +293,7 @@ lemma algebraMap_def' (r : R) : algebraMap R (𝒜 ᵍ⊗[R] ℬ) r = 1 ᵍ⊗ variable {C} [Ring C] [Algebra R C] +set_option backward.defeqAttrib.useBackward true in /-- The forwards direction of the universal property; an algebra morphism out of the graded tensor product can be assembled from maps on each component that (anti)commute on pure elements of the corresponding graded algebras. -/ @@ -328,6 +330,7 @@ theorem lift_tmul (f : A →ₐ[R] C) (g : B →ₐ[R] C) lift 𝒜 ℬ f g h_anti_commutes (a ᵍ⊗ₜ b) = f a * g b := rfl +set_option backward.defeqAttrib.useBackward true in /-- The universal property of the graded tensor product; every algebra morphism uniquely factors as a pair of algebra morphisms that anticommute with respect to the grading. -/ def liftEquiv : diff --git a/Mathlib/LinearAlgebra/TensorProduct/Pi.lean b/Mathlib/LinearAlgebra/TensorProduct/Pi.lean index 174a20912bdc70..f261b834202423 100644 --- a/Mathlib/LinearAlgebra/TensorProduct/Pi.lean +++ b/Mathlib/LinearAlgebra/TensorProduct/Pi.lean @@ -122,6 +122,7 @@ TODO: generalize to `S`-linear. -/ end +set_option backward.defeqAttrib.useBackward true in set_option backward.privateInPublic true in private def piScalarRightHomBil : N →ₗ[S] (ι → R) →ₗ[R] (ι → N) where toFun n := LinearMap.compLeft (toSpanSingleton R N n) ι diff --git a/Mathlib/RingTheory/Coalgebra/TensorProduct.lean b/Mathlib/RingTheory/Coalgebra/TensorProduct.lean index 8d2901aa2809ce..b80fb290a5b0ea 100644 --- a/Mathlib/RingTheory/Coalgebra/TensorProduct.lean +++ b/Mathlib/RingTheory/Coalgebra/TensorProduct.lean @@ -86,6 +86,7 @@ scoped macro "hopf_tensor_induction " var:elimTarget "with " var₁:ident var₂ tmul_add, add_tmul, add_mul, mul_add, h₁, h₂] | tmul $var₁ $var₂ => ?_)) +set_option backward.defeqAttrib.useBackward true in set_option backward.privateInPublic true in private lemma coassoc : TensorProduct.assoc S (A ⊗[R] B) (A ⊗[R] B) (A ⊗[R] B) ∘ₗ @@ -119,6 +120,7 @@ private lemma coassoc : hopf_tensor_induction comul (R := R) y₂ with y₂₁ y₂₂ rfl +set_option backward.defeqAttrib.useBackward true in set_option backward.privateInPublic true in set_option backward.privateInPublic.warn false in noncomputable @@ -151,6 +153,7 @@ instance instCoalgebra : Coalgebra S (A ⊗[R] B) where · dsimp simp only [one_smul] +set_option backward.defeqAttrib.useBackward true in instance [IsCocomm S A] [IsCocomm R B] : IsCocomm S (A ⊗[R] B) where comm_comp_comul := by ext x y @@ -172,6 +175,7 @@ variable {R S M N P Q : Type*} [CommSemiring R] [CommSemiring S] [Algebra R S] section +set_option backward.defeqAttrib.useBackward true in /-- The tensor product of two coalgebra morphisms as a coalgebra morphism. -/ noncomputable def map (f : M →ₗc[S] N) (g : P →ₗc[R] Q) : M ⊗[R] P →ₗc[S] N ⊗[R] Q where @@ -196,6 +200,7 @@ theorem map_toLinearMap (f : M →ₗc[S] N) (g : P →ₗc[R] Q) : variable (R S M N P) +set_option backward.defeqAttrib.useBackward true in /-- The associator for tensor products of R-coalgebras, as a coalgebra equivalence. -/ protected noncomputable def assoc : (M ⊗[S] N) ⊗[R] P ≃ₗc[S] M ⊗[S] (N ⊗[R] P) := @@ -227,6 +232,7 @@ theorem assoc_toLinearEquiv : variable (R P) +set_option backward.defeqAttrib.useBackward true in /-- The base ring is a left identity for the tensor product of coalgebras, up to coalgebra equivalence. -/ protected noncomputable def lid : R ⊗[R] P ≃ₗc[R] P := @@ -251,6 +257,7 @@ theorem lid_tmul (r : R) (a : P) : Coalgebra.TensorProduct.lid R P (r ⊗ₜ a) @[simp] theorem lid_symm_apply (a : P) : (Coalgebra.TensorProduct.lid R P).symm a = 1 ⊗ₜ a := rfl +set_option backward.defeqAttrib.useBackward true in variable (R S M) in /-- The base ring is a right identity for the tensor product of coalgebras, up to coalgebra equivalence. -/ diff --git a/Mathlib/RingTheory/Filtration.lean b/Mathlib/RingTheory/Filtration.lean index c4fc3737f1859f..d4f1f4844da77a 100644 --- a/Mathlib/RingTheory/Filtration.lean +++ b/Mathlib/RingTheory/Filtration.lean @@ -180,6 +180,7 @@ def _root_.Ideal.stableFiltration (I : Ideal R) (N : Submodule R M) : I.Filtrati mono i := by rw [add_comm, pow_add, mul_smul]; exact Submodule.smul_le_right smul_le i := by rw [add_comm, pow_add, mul_smul, pow_one] +set_option backward.defeqAttrib.useBackward true in theorem _root_.Ideal.stableFiltration_stable (I : Ideal R) (N : Submodule R M) : (I.stableFiltration N).Stable := by use 0 diff --git a/Mathlib/RingTheory/Ideal/Operations.lean b/Mathlib/RingTheory/Ideal/Operations.lean index 6d33dead1b3c11..a22890e6122eda 100644 --- a/Mathlib/RingTheory/Ideal/Operations.lean +++ b/Mathlib/RingTheory/Ideal/Operations.lean @@ -1288,6 +1288,7 @@ noncomputable def finsuppTotal : (ι →₀ I) →ₗ[R] M := variable {ι M v} +set_option backward.defeqAttrib.useBackward true in theorem finsuppTotal_apply (f : ι →₀ I) : finsuppTotal ι M I v f = f.sum fun i x => (x : R) • v i := by dsimp [finsuppTotal] diff --git a/Mathlib/RingTheory/Localization/Basic.lean b/Mathlib/RingTheory/Localization/Basic.lean index 2599e10a129936..98925788a5b563 100644 --- a/Mathlib/RingTheory/Localization/Basic.lean +++ b/Mathlib/RingTheory/Localization/Basic.lean @@ -224,6 +224,7 @@ variable {A : Type*} [CommSemiring A] include H +set_option backward.defeqAttrib.useBackward true in /-- If `S`, `Q` are localizations of `R` and `P` at submonoids `M`, `T` respectively, an isomorphism `h : R ≃ₐ[A] P` such that `h(M) = T` induces an isomorphism of localizations `S ≃ₐ[A] Q`. -/ diff --git a/Mathlib/RingTheory/MvPolynomial/Homogeneous.lean b/Mathlib/RingTheory/MvPolynomial/Homogeneous.lean index d21fb0529a180c..4ed42f2afd0027 100644 --- a/Mathlib/RingTheory/MvPolynomial/Homogeneous.lean +++ b/Mathlib/RingTheory/MvPolynomial/Homogeneous.lean @@ -362,6 +362,7 @@ lemma finSuccEquiv_coeff_isHomogeneous {N : ℕ} {φ : MvPolynomial (Fin (N + 1) add_right_inj] at h' ⊢ exact h' +set_option backward.defeqAttrib.useBackward true in -- TODO: develop API for `optionEquivLeft` and get rid of the `[Fintype σ]` assumption lemma coeff_isHomogeneous_of_optionEquivLeft_symm [hσ : Finite σ] {p : Polynomial (MvPolynomial σ R)} diff --git a/Mathlib/RingTheory/Polynomial/Basic.lean b/Mathlib/RingTheory/Polynomial/Basic.lean index 5c1ea5a5a0d5a5..f0955b17eaa372 100644 --- a/Mathlib/RingTheory/Polynomial/Basic.lean +++ b/Mathlib/RingTheory/Polynomial/Basic.lean @@ -242,6 +242,7 @@ theorem not_finite [Nontrivial R] : ¬ Module.Finite R R[X] := by rw [mem_degreeLE, degree_X_pow, Nat.cast_le, add_le_iff_nonpos_right, nonpos_iff_eq_zero] at this exact one_ne_zero this +set_option backward.defeqAttrib.useBackward true in theorem geom_sum_X_comp_X_add_one_eq_sum (n : ℕ) : (∑ i ∈ range n, (X : R[X]) ^ i).comp (X + 1) = (Finset.range n).sum fun i : ℕ => (n.choose (i + 1) : R[X]) * X ^ i := by diff --git a/Mathlib/RingTheory/TensorProduct/Basic.lean b/Mathlib/RingTheory/TensorProduct/Basic.lean index e7ec44de33ee7f..1b9aa14220d65d 100644 --- a/Mathlib/RingTheory/TensorProduct/Basic.lean +++ b/Mathlib/RingTheory/TensorProduct/Basic.lean @@ -279,6 +279,7 @@ def includeLeftRingHom : A →+* A ⊗[R] B where variable [CommSemiring S] [Algebra S A] +set_option backward.defeqAttrib.useBackward true in instance leftAlgebra [SMulCommClass R S A] : Algebra S (A ⊗[R] B) := { commutes' := fun r x => by dsimp only [RingHom.toFun_eq_coe, RingHom.comp_apply, includeLeftRingHom_apply] diff --git a/Mathlib/RingTheory/TensorProduct/Maps.lean b/Mathlib/RingTheory/TensorProduct/Maps.lean index 5b0270da85cb93..0fe8f323473979 100644 --- a/Mathlib/RingTheory/TensorProduct/Maps.lean +++ b/Mathlib/RingTheory/TensorProduct/Maps.lean @@ -79,6 +79,7 @@ variable [Semiring B] [Algebra R B] variable [Semiring C] [Algebra S C] variable [Semiring D] [Algebra R D] +set_option backward.defeqAttrib.useBackward true in /-- To check a linear map preserves multiplication, it suffices to check it on pure tensors. See `algHomOfLinearMapTensorProduct` for a bundled version. -/ lemma _root_.LinearMap.map_mul_of_map_mul_tmul {f : A ⊗[R] B →ₗ[S] C} diff --git a/Mathlib/RingTheory/Valuation/RankOne.lean b/Mathlib/RingTheory/Valuation/RankOne.lean index 33263f3ff6c1b1..01e0004eebf4b1 100644 --- a/Mathlib/RingTheory/Valuation/RankOne.lean +++ b/Mathlib/RingTheory/Valuation/RankOne.lean @@ -146,6 +146,7 @@ instance restrict_RankOne : RankOne (v.restrict) where lemma restrict_RankOne_hom_eq : RankOne.hom v.restrict = (RankOne.hom v).comp embedding := rfl +set_option backward.defeqAttrib.useBackward true in variable {K} in set_option backward.isDefEq.respectTransparency false in theorem exists_val_lt {γ : ℝ≥0} (hγ : γ ≠ 0) : ∃ x ≠ 0, RankOne.hom v (v.restrict x) < γ := by diff --git a/Mathlib/Topology/Algebra/ContinuousAffineEquiv.lean b/Mathlib/Topology/Algebra/ContinuousAffineEquiv.lean index 8bdbaa76b9f061..367dfd6ee89273 100644 --- a/Mathlib/Topology/Algebra/ContinuousAffineEquiv.lean +++ b/Mathlib/Topology/Algebra/ContinuousAffineEquiv.lean @@ -383,6 +383,7 @@ def prodComm : P₁ × P₂ ≃ᴬ[k] P₂ × P₁ where theorem prodComm_symm : (prodComm k P₁ P₂).symm = prodComm k P₂ P₁ := rfl +set_option backward.defeqAttrib.useBackward true in /-- Product of affine spaces is associative up to continuous affine isomorphism. -/ @[simps! apply symm_apply toAffineEquiv] def prodAssoc : (P₁ × P₂) × P₃ ≃ᴬ[k] P₁ × (P₂ × P₃) where diff --git a/Mathlib/Topology/ContinuousMap/Polynomial.lean b/Mathlib/Topology/ContinuousMap/Polynomial.lean index 5be1a5f611d5b5..f51a83a1c02b44 100644 --- a/Mathlib/Topology/ContinuousMap/Polynomial.lean +++ b/Mathlib/Topology/ContinuousMap/Polynomial.lean @@ -150,6 +150,7 @@ theorem polynomialFunctions_coe (X : Set R) : ext simp [polynomialFunctions] +set_option backward.defeqAttrib.useBackward true in -- TODO: -- if `f : R → R` is an affine equivalence, then pulling back along `f` -- induces a normed algebra isomorphism between `polynomialFunctions X` and @@ -165,6 +166,7 @@ open unitInterval open ContinuousMap +set_option backward.defeqAttrib.useBackward true in /-- The preimage of polynomials on `[0,1]` under the pullback map by `x ↦ (b-a) * x + a` is the polynomials on `[a,b]`. -/ theorem polynomialFunctions.comap_compRightAlgHom_iccHomeoI (a b : ℝ) (h : a < b) : diff --git a/Mathlib/Topology/ContinuousMap/StoneWeierstrass.lean b/Mathlib/Topology/ContinuousMap/StoneWeierstrass.lean index 7ef2e5148cdb6c..eea562ea36da0d 100644 --- a/Mathlib/Topology/ContinuousMap/StoneWeierstrass.lean +++ b/Mathlib/Topology/ContinuousMap/StoneWeierstrass.lean @@ -71,6 +71,7 @@ def attachBound (f : C(X, ℝ)) : C(X, Set.Icc (-‖f‖) ‖f‖) where theorem attachBound_apply_coe (f : C(X, ℝ)) (x : X) : ((attachBound f) x : ℝ) = f x := rfl +set_option backward.defeqAttrib.useBackward true in set_option backward.isDefEq.respectTransparency false in theorem polynomial_comp_attachBound (A : Subalgebra ℝ C(X, ℝ)) (f : A) (g : ℝ[X]) : (g.toContinuousMapOn (Set.Icc (-‖f‖) ‖f‖)).comp (f : C(X, ℝ)).attachBound = diff --git a/Mathlib/Topology/Homotopy/Affine.lean b/Mathlib/Topology/Homotopy/Affine.lean index db7e83c49bb2b8..e25a4c7d75f552 100644 --- a/Mathlib/Topology/Homotopy/Affine.lean +++ b/Mathlib/Topology/Homotopy/Affine.lean @@ -24,6 +24,7 @@ variable {X E : Type*} [TopologicalSpace X] namespace ContinuousMap.Homotopy +set_option backward.defeqAttrib.useBackward true in /-- The homotopy between `f` and `g` such that `affine f g (t, x) = AffineMap.lineMap (f x) (g x) t`. -/ @[simps +simpRhs] diff --git a/Mathlib/Topology/Instances/RealVectorSpace.lean b/Mathlib/Topology/Instances/RealVectorSpace.lean index 52b4f8c3d551d1..fefd3c27c8a03c 100644 --- a/Mathlib/Topology/Instances/RealVectorSpace.lean +++ b/Mathlib/Topology/Instances/RealVectorSpace.lean @@ -45,6 +45,7 @@ theorem coe_toRealLinearMap (f : E →+ F) (hf : Continuous f) : ⇑(f.toRealLin end AddMonoidHom +set_option backward.defeqAttrib.useBackward true in /-- Reinterpret a continuous additive equivalence between two real vector spaces as a continuous real-linear map. -/ def AddEquiv.toRealLinearEquiv (e : E ≃+ F) (h₁ : Continuous e) (h₂ : Continuous e.symm) : diff --git a/Mathlib/Topology/UrysohnsBounded.lean b/Mathlib/Topology/UrysohnsBounded.lean index 45de99764ac615..a5e7742a3d7e82 100644 --- a/Mathlib/Topology/UrysohnsBounded.lean +++ b/Mathlib/Topology/UrysohnsBounded.lean @@ -40,6 +40,7 @@ theorem exists_bounded_zero_one_of_closed {X : Type*} [TopologicalSpace X] [Norm let ⟨f, hfs, hft, hf⟩ := exists_continuous_zero_one_of_isClosed hs ht hd ⟨⟨f, 1, fun _ _ => Real.dist_le_of_mem_Icc_01 (hf _) (hf _)⟩, hfs, hft, hf⟩ +set_option backward.defeqAttrib.useBackward true in /-- Urysohn's lemma: if `s` and `t` are two disjoint closed sets in a normal topological space `X`, and `a ≤ b` are two real numbers, then there exists a continuous function `f : X → ℝ` such that diff --git a/Mathlib/Topology/VectorBundle/Constructions.lean b/Mathlib/Topology/VectorBundle/Constructions.lean index 84271daef9cdce..3798b36c6c446c 100644 --- a/Mathlib/Topology/VectorBundle/Constructions.lean +++ b/Mathlib/Topology/VectorBundle/Constructions.lean @@ -137,6 +137,7 @@ variable [∀ x, AddCommMonoid (E₁ x)] [∀ x, Module 𝕜 (E₁ x)] [∀ x, A [∀ x, Module 𝕜 (E₂ x)] [∀ x : B, TopologicalSpace (E₁ x)] [∀ x : B, TopologicalSpace (E₂ x)] [FiberBundle F₁ E₁] [FiberBundle F₂ E₂] +set_option backward.defeqAttrib.useBackward true in /-- The product of two vector bundles is a vector bundle. -/ instance VectorBundle.prod [VectorBundle 𝕜 F₁ E₁] [VectorBundle 𝕜 F₂ E₂] : VectorBundle 𝕜 (F₁ × F₂) (E₁ ×ᵇ E₂) where diff --git a/Mathlib/Topology/VectorBundle/Hom.lean b/Mathlib/Topology/VectorBundle/Hom.lean index 6ece0639b5037c..e7b37d205ad470 100644 --- a/Mathlib/Topology/VectorBundle/Hom.lean +++ b/Mathlib/Topology/VectorBundle/Hom.lean @@ -67,6 +67,7 @@ variable {σ e₁ e₁' e₂ e₂'} variable [∀ x, TopologicalSpace (E₁ x)] [FiberBundle F₁ E₁] variable [∀ x, TopologicalSpace (E₂ x)] [FiberBundle F₂ E₂] +set_option backward.defeqAttrib.useBackward true in theorem continuousOn_continuousLinearMapCoordChange [RingHomIsometric σ] [VectorBundle 𝕜₁ F₁ E₁] [VectorBundle 𝕜₂ F₂ E₂] [MemTrivializationAtlas e₁] [MemTrivializationAtlas e₁'] [MemTrivializationAtlas e₂] @@ -169,6 +170,7 @@ variable [∀ x : B, TopologicalSpace (E₂ x)] [FiberBundle F₂ E₂] [VectorB variable [∀ x, IsTopologicalAddGroup (E₂ x)] [∀ x, ContinuousSMul 𝕜₂ (E₂ x)] variable [RingHomIsometric σ] +set_option backward.defeqAttrib.useBackward true in /-- The continuous `σ`-semilinear maps between two topological vector bundles form a `VectorPrebundle` (this is an auxiliary construction for the `VectorBundle` instance, in which the pretrivializations are collated but no topology From 36625b2a675dd26e9b539c803732990efa247aba Mon Sep 17 00:00:00 2001 From: Joachim Breitner Date: Tue, 21 Apr 2026 17:02:47 +0000 Subject: [PATCH 108/321] chore(scripts): bring back module-level / nonlocal set_option scripts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Restore `add_module_set_option.py` / `rm_module_set_option.py` / `fix_nonlocal_set_option.py` from the previous adaptation branch, with the `--value` flag threaded through so they work for options whose default is `false` (like `backward.defeqAttrib.useBackward`). These are needed for the subset of modules where the option must be set at file level (not `set_option ... in`), because `backward.defeqAttrib.useBackward` is now an eqn-affecting option — its value at a defining module's compile time is stored and replayed at equation realization time in downstream modules. Co-Authored-By: Claude Opus 4.7 (1M context) --- scripts/add_module_set_option.py | 207 +++++++++++++ scripts/fix_nonlocal_set_option.py | 276 +++++++++++++++++ scripts/rm_module_set_option.py | 457 +++++++++++++++++++++++++++++ 3 files changed, 940 insertions(+) create mode 100755 scripts/add_module_set_option.py create mode 100755 scripts/fix_nonlocal_set_option.py create mode 100755 scripts/rm_module_set_option.py diff --git a/scripts/add_module_set_option.py b/scripts/add_module_set_option.py new file mode 100755 index 00000000000000..373baf2e009703 --- /dev/null +++ b/scripts/add_module_set_option.py @@ -0,0 +1,207 @@ +#!/usr/bin/env python3 +""" +Add module-level `set_option` lines to every Mathlib file. + +Inserts `set_option