Skip to content

Commit 4f47420

Browse files
kim-emeric-wieser
andcommitted
chore: forward-port backports (#3752)
* `data.mv_polynomial.basic`, `data.mv_polynomial.funext`: leanprover-community/mathlib3#18839 * `category_theory.limits.preserves.finite`, `category_theory.preadditive.projective`: leanprover-community/mathlib3#18890 * `category_theory.abelian.basic`, `category_theory.abelian.opposite`: leanprover-community/mathlib3#18740 * `topology.category.Top.limits.basic`: leanprover-community/mathlib3#18871. Note that this does not show a useful diff on the dashboard pages as file splits aren't tracked well by git. Co-authored-by: Scott Morrison <scott.morrison@gmail.com> Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
1 parent 097ba15 commit 4f47420

File tree

7 files changed

+57
-26
lines changed

7 files changed

+57
-26
lines changed

Mathlib/CategoryTheory/Abelian/Basic.lean

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Markus Himmel, Johan Commelin, Scott Morrison
55
66
! This file was ported from Lean 3 source module category_theory.abelian.basic
7-
! leanprover-community/mathlib commit 8c75ef3517d4106e89fe524e6281d0b0545f47fc
7+
! leanprover-community/mathlib commit a5ff45a1c92c278b03b52459a620cfd9c49ebc80
88
! Please do not edit these lines, except to modify the commit id
99
! if you have ported upstream changes.
1010
-/
@@ -268,12 +268,12 @@ namespace CategoryTheory.Abelian
268268

269269
variable {C : Type u} [Category.{v} C] [Abelian C]
270270

271-
/-- An abelian category has finite biproducts. -/
272-
-- Porting note: we would like this to be an instance, and indeed it worked in mathlib3
273-
-- however it triggers https://github.com/leanprover/lean4/issues/2055
274-
-- during the simpNF linter, so for now we turn it on locally in this file.
275-
-- This will likely cause problems in downstream ports, unfortunately.
271+
-- Porting note: the below porting note is from mathlib3!
272+
-- Porting note: this should be an instance,
273+
-- but triggers https://github.com/leanprover/lean4/issues/2055
274+
-- We set it as a local instance instead.
276275
-- instance (priority := 100)
276+
/-- An abelian category has finite biproducts. -/
277277
theorem hasFiniteBiproducts : HasFiniteBiproducts C :=
278278
Limits.HasFiniteBiproducts.of_hasFiniteProducts
279279
#align category_theory.abelian.has_finite_biproducts CategoryTheory.Abelian.hasFiniteBiproducts

Mathlib/CategoryTheory/Abelian/Opposite.lean

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Scott Morrison
55
66
! This file was ported from Lean 3 source module category_theory.abelian.opposite
7-
! leanprover-community/mathlib commit 8c75ef3517d4106e89fe524e6281d0b0545f47fc
7+
! leanprover-community/mathlib commit a5ff45a1c92c278b03b52459a620cfd9c49ebc80
88
! Please do not edit these lines, except to modify the commit id
99
! if you have ported upstream changes.
1010
-/
@@ -29,6 +29,7 @@ variable (C : Type _) [Category C] [Abelian C]
2929
--attribute [local instance]
3030
-- hasFiniteLimits_of_hasEqualizers_and_finite_products
3131
-- hasFiniteColimits_of_hasCoequalizers_and_finite_coproducts
32+
-- Abelian.hasFiniteBiproducts
3233

3334
instance : Abelian Cᵒᵖ := by
3435
-- porting note: priorities of `Abelian.has_kernels` and `Abelian.has_cokernels` have

Mathlib/CategoryTheory/Limits/Preserves/Finite.lean

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Andrew Yang
55
66
! This file was ported from Lean 3 source module category_theory.limits.preserves.finite
7-
! leanprover-community/mathlib commit 024a4231815538ac739f52d08dd20a55da0d6b23
7+
! leanprover-community/mathlib commit 3974a774a707e2e06046a14c0eaef4654584fada
88
! Please do not edit these lines, except to modify the commit id
99
! if you have ported upstream changes.
1010
-/
@@ -60,19 +60,22 @@ noncomputable instance (priority := 100) preservesLimitsOfShapeOfPreservesFinite
6060
apply preservesLimitsOfShapeOfEquiv (FinCategory.equivAsType J)
6161
#align category_theory.limits.preserves_limits_of_shape_of_preserves_finite_limits CategoryTheory.Limits.preservesLimitsOfShapeOfPreservesFiniteLimits
6262

63-
-- Porting note: this is a dangerous instance as it has unbound universe variables.
63+
-- This is a dangerous instance as it has unbound universe variables.
64+
/-- If we preserve limits of some arbitrary size, then we preserve all finite limits. -/
6465
noncomputable def PreservesLimitsOfSize.preservesFiniteLimits (F : C ⥤ D)
6566
[PreservesLimitsOfSize.{w, w₂} F] : PreservesFiniteLimits F where
6667
preservesFiniteLimits J (sJ : SmallCategory J) fJ := by
6768
haveI := preservesSmallestLimitsOfPreservesLimits F
6869
exact preservesLimitsOfShapeOfEquiv (FinCategory.equivAsType J) F
6970
#align category_theory.limits.preserves_limits.preserves_finite_limits_of_size CategoryTheory.Limits.PreservesLimitsOfSize.preservesFiniteLimits
7071

71-
-- Porting note: added as a specialization of the dangerous instance above.
72+
-- Added as a specialization of the dangerous instance above, for limits indexed in Type 0.
7273
noncomputable instance (priority := 120) PreservesLimitsOfSize0.preservesFiniteLimits
7374
(F : C ⥤ D) [PreservesLimitsOfSize.{0, 0} F] : PreservesFiniteLimits F :=
7475
PreservesLimitsOfSize.preservesFiniteLimits F
76+
#align preserves_limits_of_size.zero.preserves_finite_limits CategoryTheory.Limits.PreservesLimitsOfSize0.preservesFiniteLimits
7577

78+
-- An alternative specialization of the dangerous instance for small limits.
7679
noncomputable instance (priority := 120) PreservesLimits.preservesFiniteLimits (F : C ⥤ D)
7780
[PreservesLimits F] : PreservesFiniteLimits F :=
7881
PreservesLimitsOfSize.preservesFiniteLimits F
@@ -128,18 +131,22 @@ noncomputable instance (priority := 100) preservesColimitsOfShapeOfPreservesFini
128131
apply preservesColimitsOfShapeOfEquiv (FinCategory.equivAsType J)
129132
#align category_theory.limits.preserves_colimits_of_shape_of_preserves_finite_colimits CategoryTheory.Limits.preservesColimitsOfShapeOfPreservesFiniteColimits
130133

131-
-- Porting note: this is a dangerous instance as it has unbound universe variables.
134+
-- This is a dangerous instance as it has unbound universe variables.
135+
/-- If we preserve colimits of some arbitrary size, then we preserve all finite colimits. -/
132136
noncomputable def PreservesColimitsOfSize.preservesFiniteColimits (F : C ⥤ D)
133137
[PreservesColimitsOfSize.{w, w₂} F] : PreservesFiniteColimits F where
134138
preservesFiniteColimits J (sJ : SmallCategory J) fJ := by
135139
haveI := preservesSmallestColimitsOfPreservesColimits F
136140
exact preservesColimitsOfShapeOfEquiv (FinCategory.equivAsType J) F
141+
#align category_theory.limits.preserves_colimits_of_size.preserves_finite_colimits CategoryTheory.Limits.PreservesColimitsOfSize.preservesFiniteColimits
137142

138-
-- Porting note: added as a specialization of the dangerous instance above.
143+
-- Added as a specialization of the dangerous instance above, for colimits indexed in Type 0.
139144
noncomputable instance (priority := 120) PreservesColimitsOfSize0.preservesFiniteColimits
140145
(F : C ⥤ D) [PreservesColimitsOfSize.{0, 0} F] : PreservesFiniteColimits F :=
141146
PreservesColimitsOfSize.preservesFiniteColimits F
147+
#align preserves_colimits_of_size.zero.preserves_finite_colimits CategoryTheory.Limits.PreservesColimitsOfSize0.preservesFiniteColimits
142148

149+
-- An alternative specialization of the dangerous instance for small colimits.
143150
noncomputable instance (priority := 120) PreservesColimits.preservesFiniteColimits (F : C ⥤ D)
144151
[PreservesColimits F] : PreservesFiniteColimits F :=
145152
PreservesColimitsOfSize.preservesFiniteColimits F

Mathlib/CategoryTheory/Preadditive/Projective.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Markus Himmel, Scott Morrison
55
66
! This file was ported from Lean 3 source module category_theory.preadditive.projective
7-
! leanprover-community/mathlib commit f8d8465c3c392a93b9ed226956e26dee00975946
7+
! leanprover-community/mathlib commit 3974a774a707e2e06046a14c0eaef4654584fada
88
! Please do not edit these lines, except to modify the commit id
99
! if you have ported upstream changes.
1010
-/

Mathlib/Data/MvPolynomial/Basic.lean

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro
55
66
! This file was ported from Lean 3 source module data.mv_polynomial.basic
7-
! leanprover-community/mathlib commit 2d5739b61641ee4e7e53eca5688a08f66f2e6a60
7+
! leanprover-community/mathlib commit 0b89934139d3be96f9dab477f10c20f9f93da580
88
! Please do not edit these lines, except to modify the commit id
99
! if you have ported upstream changes.
1010
-/
@@ -1148,7 +1148,11 @@ theorem eval_assoc {τ} (f : σ → MvPolynomial τ R) (g : τ → R) (p : MvPol
11481148
congr with a; simp
11491149
#align mv_polynomial.eval_assoc MvPolynomial.eval_assoc
11501150

1151-
-- Porting note: new theorem
1151+
@[simp]
1152+
theorem eval₂_id (p : MvPolynomial σ R) : eval₂ (RingHom.id _) g p = eval g p :=
1153+
rfl
1154+
#align mv_polynomial.eval₂_id MvPolynomial.eval₂_id
1155+
11521156
theorem eval_eval₂ [CommSemiring R] [CommSemiring S]
11531157
(f : R →+* MvPolynomial τ S) (g : σ → MvPolynomial τ S) (p : MvPolynomial σ R) :
11541158
eval x (eval₂ f g p) = eval₂ ((eval x).comp f) (fun s => eval x (g s)) p := by
@@ -1158,6 +1162,7 @@ theorem eval_eval₂ [CommSemiring R] [CommSemiring S]
11581162
simp [hp, hq]
11591163
· intro p n hp
11601164
simp [hp]
1165+
#align mv_polynomial.eval_eval₂ MvPolynomial.eval_eval₂
11611166

11621167
end Eval
11631168

@@ -1205,8 +1210,8 @@ theorem eval₂_eq_eval_map (g : σ → S₁) (p : MvPolynomial σ R) : p.eval
12051210

12061211
have h := eval₂_comp_left (eval₂Hom (RingHom.id S₁) g) (C.comp f) X p
12071212
-- porting note: the Lean 3 version of `h` was full of metavariables which
1208-
-- were later unified during `rw [h]`
1209-
dsimp at h
1213+
-- were later unified during `rw [h]`. Also needed to add `-eval₂_id`.
1214+
dsimp [-eval₂_id] at h
12101215
rw [h]
12111216
congr
12121217
· ext1 a
@@ -1215,12 +1220,6 @@ theorem eval₂_eq_eval_map (g : σ → S₁) (p : MvPolynomial σ R) : p.eval
12151220
simp only [comp_apply, eval₂_X]
12161221
#align mv_polynomial.eval₂_eq_eval_map MvPolynomial.eval₂_eq_eval_map
12171222

1218-
-- Porting note: new theorem
1219-
-- This probably belongs earlier, but it breaks the fragile proof of `eval₂_eq_eval_map`
1220-
@[simp]
1221-
theorem eval₂_id (p : MvPolynomial σ R) : eval₂ (RingHom.id _) g p = eval g p :=
1222-
rfl
1223-
12241223
theorem eval₂_comp_right {S₂} [CommSemiring S₂] (k : S₁ →+* S₂) (f : R →+* S₁) (g : σ → S₁) (p) :
12251224
k (eval₂ f g p) = eval₂ k (k ∘ g) (map f p) := by
12261225
apply MvPolynomial.induction_on p

Mathlib/Data/MvPolynomial/Funext.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Johan Commelin
55
66
! This file was ported from Lean 3 source module data.mv_polynomial.funext
7-
! leanprover-community/mathlib commit da01792ca4894d4f3a98d06b6c50455e5ed25da3
7+
! leanprover-community/mathlib commit 0b89934139d3be96f9dab477f10c20f9f93da580
88
! Please do not edit these lines, except to modify the commit id
99
! if you have ported upstream changes.
1010
-/
1111
import Mathlib.Data.Polynomial.RingDivision
1212
import Mathlib.Data.MvPolynomial.Rename
13-
import Mathlib.Data.MvPolynomial.Polynomial
1413
import Mathlib.RingTheory.Polynomial.Basic
14+
import Mathlib.Data.MvPolynomial.Polynomial
1515

1616
/-!
1717
## Function extensionality for multivariate polynomials

Mathlib/Topology/Category/Top/Limits/Basic.lean

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Patrick Massot, Scott Morrison, Mario Carneiro, Andrew Yang
55
66
! This file was ported from Lean 3 source module topology.category.Top.limits.basic
7-
! leanprover-community/mathlib commit 8195826f5c428fc283510bc67303dd4472d78498
7+
! leanprover-community/mathlib commit 178a32653e369dce2da68dc6b2694e385d484ef1
88
! Please do not edit these lines, except to modify the commit id
99
! if you have ported upstream changes.
1010
-/
@@ -219,3 +219,27 @@ instance forgetPreservesColimitsOfSize :
219219
instance forgetPreservesColimits : PreservesColimits (forget : TopCat.{u} ⥤ Type u) :=
220220
TopCat.forgetPreservesColimitsOfSize.{u, u}
221221
#align Top.forget_preserves_colimits TopCat.forgetPreservesColimits
222+
223+
/-- The terminal object of `Top` is `PUnit`. -/
224+
def isTerminalPunit : IsTerminal (TopCat.of PUnit.{u + 1}) :=
225+
haveI : ∀ X, Unique (X ⟶ TopCat.of PUnit.{u + 1}) := fun X =>
226+
⟨⟨⟨fun _ => PUnit.unit, by continuity⟩⟩, fun f => by ext; aesop⟩
227+
Limits.IsTerminal.ofUnique _
228+
#align Top.is_terminal_punit TopCat.isTerminalPunit
229+
230+
/-- The terminal object of `Top` is `PUnit`. -/
231+
def terminalIsoPunit : ⊤_ TopCat.{u} ≅ TopCat.of PUnit :=
232+
terminalIsTerminal.uniqueUpToIso isTerminalPunit
233+
#align Top.terminal_iso_punit TopCat.terminalIsoPunit
234+
235+
/-- The initial object of `Top` is `PEmpty`. -/
236+
def isInitialPempty : IsInitial (TopCat.of PEmpty.{u + 1}) :=
237+
haveI : ∀ X, Unique (TopCat.of PEmpty.{u + 1} ⟶ X) := fun X =>
238+
⟨⟨⟨fun x => x.elim, by continuity⟩⟩, fun f => by ext ⟨⟩⟩
239+
Limits.IsInitial.ofUnique _
240+
#align Top.is_initial_pempty TopCat.isInitialPempty
241+
242+
/-- The initial object of `Top` is `PEmpty`. -/
243+
def initialIsoPempty : ⊥_ TopCat.{u} ≅ TopCat.of PEmpty :=
244+
initialIsInitial.uniqueUpToIso isInitialPempty
245+
#align Top.initial_iso_pempty TopCat.initialIsoPempty

0 commit comments

Comments
 (0)