algebra.category.Module.colimitsMathlib.Algebra.Category.ModuleCat.Colimits

This file has been ported!

Changes since the initial port

The following section lists changes to this file in mathlib3 and mathlib4 that occured after the initial port. Most recent changes are shown first. Hovering over a commit will show all commits associated with the same mathlib3 commit.

Changes in mathlib3

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(last sync)

Changes in mathlib3port

mathlib3
mathlib3port
Diff
@@ -3,7 +3,7 @@ Copyright (c) 2019 Scott Morrison. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Scott Morrison
 -/
-import Algebra.Category.Module.Basic
+import Algebra.Category.ModuleCat.Basic
 import CategoryTheory.ConcreteCategory.Elementwise
 
 #align_import algebra.category.Module.colimits from "leanprover-community/mathlib"@"c20927220ef87bb4962ba08bf6da2ce3cf50a6dd"
Diff
@@ -396,11 +396,11 @@ instance hasColimits_moduleCat : HasColimits (ModuleCat.{max v u} R)
 #align Module.colimits.has_colimits_Module ModuleCat.Colimits.hasColimits_moduleCat
 
 instance hasColimitsOfSize_moduleCat : HasColimitsOfSize.{v} (ModuleCat.{max v u} R) :=
-  hasColimitsOfSize_shrink _
+  hasColimitsOfSizeShrink _
 #align Module.colimits.has_colimits_of_size_Module ModuleCat.Colimits.hasColimitsOfSize_moduleCat
 
 instance hasColimitsOfSize_zero_moduleCat : HasColimitsOfSize.{0} (ModuleCat.{max v u} R) :=
-  @hasColimitsOfSize_shrink.{0} (ModuleCat.{max v u} R) _ ModuleCat.Colimits.hasColimits_moduleCat
+  @hasColimitsOfSizeShrink.{0} (ModuleCat.{max v u} R) _ ModuleCat.Colimits.hasColimits_moduleCat
 #align Module.colimits.has_colimits_of_size_zero_Module ModuleCat.Colimits.hasColimitsOfSize_zero_moduleCat
 
 -- We manually add a `has_colimits` instance with universe parameters swapped, for otherwise
Diff
@@ -3,8 +3,8 @@ Copyright (c) 2019 Scott Morrison. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Scott Morrison
 -/
-import Mathbin.Algebra.Category.Module.Basic
-import Mathbin.CategoryTheory.ConcreteCategory.Elementwise
+import Algebra.Category.Module.Basic
+import CategoryTheory.ConcreteCategory.Elementwise
 
 #align_import algebra.category.Module.colimits from "leanprover-community/mathlib"@"c20927220ef87bb4962ba08bf6da2ce3cf50a6dd"
 
Diff
@@ -47,7 +47,6 @@ and the identifications given by the morphisms in the diagram.
 
 variable {J : Type w} [Category.{v} J] (F : J ⥤ ModuleCat.{max u v w} R)
 
-#print ModuleCat.Colimits.Prequotient /-
 /-- An inductive type representing all module expressions (without relations)
 on a collection of types indexed by the objects of `J`.
 -/
@@ -60,14 +59,12 @@ inductive Prequotient-- There's always `of`
   | add : prequotient → prequotient → prequotient
   | smul : R → prequotient → prequotient
 #align Module.colimits.prequotient ModuleCat.Colimits.Prequotient
--/
 
 instance : Inhabited (Prequotient F) :=
   ⟨Prequotient.zero⟩
 
 open Prequotient
 
-#print ModuleCat.Colimits.Relation /-
 /-- The relation on `prequotient` saying when two expressions are equal
 because of the module laws, or
 because one element is mapped to another by a morphism in the diagram.
@@ -113,9 +110,7 @@ inductive Relation : Prequotient F → Prequotient F → Prop-- Make it an equiv
   | add_smul : ∀ s t x, relation (smul (s + t) x) (add (smul s x) (smul t x))
   | zero_smul : ∀ x, relation (smul 0 x) zero
 #align Module.colimits.relation ModuleCat.Colimits.Relation
--/
 
-#print ModuleCat.Colimits.colimitSetoid /-
 /-- The setoid corresponding to module expressions modulo module relations and identifications.
 -/
 def colimitSetoid : Setoid (Prequotient F)
@@ -123,18 +118,15 @@ def colimitSetoid : Setoid (Prequotient F)
   R := Relation F
   iseqv := ⟨Relation.refl, Relation.symm, Relation.trans⟩
 #align Module.colimits.colimit_setoid ModuleCat.Colimits.colimitSetoid
--/
 
 attribute [instance] colimit_setoid
 
-#print ModuleCat.Colimits.ColimitType /-
 /-- The underlying type of the colimit of a diagram in `Module R`.
 -/
 def ColimitType : Type max u v w :=
   Quotient (colimitSetoid F)
 deriving Inhabited
 #align Module.colimits.colimit_type ModuleCat.Colimits.ColimitType
--/
 
 instance : AddCommGroup (ColimitType F)
     where
@@ -242,50 +234,37 @@ instance : Module R (ColimitType F)
     apply relation.zero_smul
     rfl
 
-#print ModuleCat.Colimits.quot_zero /-
 @[simp]
 theorem quot_zero : Quot.mk Setoid.r zero = (0 : ColimitType F) :=
   rfl
 #align Module.colimits.quot_zero ModuleCat.Colimits.quot_zero
--/
 
-#print ModuleCat.Colimits.quot_neg /-
 @[simp]
 theorem quot_neg (x) : Quot.mk Setoid.r (neg x) = (-Quot.mk Setoid.r x : ColimitType F) :=
   rfl
 #align Module.colimits.quot_neg ModuleCat.Colimits.quot_neg
--/
 
-#print ModuleCat.Colimits.quot_add /-
 @[simp]
 theorem quot_add (x y) :
     Quot.mk Setoid.r (add x y) = (Quot.mk Setoid.r x + Quot.mk Setoid.r y : ColimitType F) :=
   rfl
 #align Module.colimits.quot_add ModuleCat.Colimits.quot_add
--/
 
-#print ModuleCat.Colimits.quot_smul /-
 @[simp]
 theorem quot_smul (s x) : Quot.mk Setoid.r (smul s x) = (s • Quot.mk Setoid.r x : ColimitType F) :=
   rfl
 #align Module.colimits.quot_smul ModuleCat.Colimits.quot_smul
--/
 
-#print ModuleCat.Colimits.colimit /-
 /-- The bundled module giving the colimit of a diagram. -/
 def colimit : ModuleCat R :=
   ModuleCat.of R (ColimitType F)
 #align Module.colimits.colimit ModuleCat.Colimits.colimit
--/
 
-#print ModuleCat.Colimits.coconeFun /-
 /-- The function from a given module in the diagram to the colimit module. -/
 def coconeFun (j : J) (x : F.obj j) : ColimitType F :=
   Quot.mk _ (of j x)
 #align Module.colimits.cocone_fun ModuleCat.Colimits.coconeFun
--/
 
-#print ModuleCat.Colimits.coconeMorphism /-
 /-- The group homomorphism from a given module in the diagram to the colimit module. -/
 def coconeMorphism (j : J) : F.obj j ⟶ colimit F
     where
@@ -293,9 +272,7 @@ def coconeMorphism (j : J) : F.obj j ⟶ colimit F
   map_smul' := by intros; apply Quot.sound; apply relation.smul
   map_add' := by intros <;> apply Quot.sound <;> apply relation.add
 #align Module.colimits.cocone_morphism ModuleCat.Colimits.coconeMorphism
--/
 
-#print ModuleCat.Colimits.cocone_naturality /-
 @[simp]
 theorem cocone_naturality {j j' : J} (f : j ⟶ j') :
     F.map f ≫ coconeMorphism F j' = coconeMorphism F j :=
@@ -304,25 +281,19 @@ theorem cocone_naturality {j j' : J} (f : j ⟶ j') :
   apply Quot.sound
   apply Relation.Map
 #align Module.colimits.cocone_naturality ModuleCat.Colimits.cocone_naturality
--/
 
-#print ModuleCat.Colimits.cocone_naturality_components /-
 @[simp]
 theorem cocone_naturality_components (j j' : J) (f : j ⟶ j') (x : F.obj j) :
     (coconeMorphism F j') (F.map f x) = (coconeMorphism F j) x := by rw [← cocone_naturality F f];
   rfl
 #align Module.colimits.cocone_naturality_components ModuleCat.Colimits.cocone_naturality_components
--/
 
-#print ModuleCat.Colimits.colimitCocone /-
 /-- The cocone over the proposed colimit module. -/
 def colimitCocone : Cocone F where
   pt := colimit F
   ι := { app := coconeMorphism F }
 #align Module.colimits.colimit_cocone ModuleCat.Colimits.colimitCocone
--/
 
-#print ModuleCat.Colimits.descFunLift /-
 /-- The function from the free module on the diagram to the cone point of any other cocone. -/
 @[simp]
 def descFunLift (s : Cocone F) : Prequotient F → s.pt
@@ -332,9 +303,7 @@ def descFunLift (s : Cocone F) : Prequotient F → s.pt
   | add x y => desc_fun_lift x + desc_fun_lift y
   | smul s x => s • desc_fun_lift x
 #align Module.colimits.desc_fun_lift ModuleCat.Colimits.descFunLift
--/
 
-#print ModuleCat.Colimits.descFun /-
 /-- The function from the colimit module to the cone point of any other cocone. -/
 def descFun (s : Cocone F) : ColimitType F → s.pt :=
   by
@@ -389,9 +358,7 @@ def descFun (s : Cocone F) : ColimitType F → s.pt :=
     -- zero_smul
     · rw [zero_smul]
 #align Module.colimits.desc_fun ModuleCat.Colimits.descFun
--/
 
-#print ModuleCat.Colimits.descMorphism /-
 /-- The group homomorphism from the colimit module to the cone point of any other cocone. -/
 def descMorphism (s : Cocone F) : colimit F ⟶ s.pt
     where
@@ -399,9 +366,7 @@ def descMorphism (s : Cocone F) : colimit F ⟶ s.pt
   map_smul' s x := by induction x <;> rfl
   map_add' x y := by induction x <;> induction y <;> rfl
 #align Module.colimits.desc_morphism ModuleCat.Colimits.descMorphism
--/
 
-#print ModuleCat.Colimits.colimitCoconeIsColimit /-
 /-- Evidence that the proposed colimit is the colimit. -/
 def colimitCoconeIsColimit : IsColimit (colimitCocone F)
     where
@@ -420,9 +385,7 @@ def colimitCoconeIsColimit : IsColimit (colimitCocone F)
     · simp [*]
     rfl
 #align Module.colimits.colimit_cocone_is_colimit ModuleCat.Colimits.colimitCoconeIsColimit
--/
 
-#print ModuleCat.Colimits.hasColimits_moduleCat /-
 instance hasColimits_moduleCat : HasColimits (ModuleCat.{max v u} R)
     where HasColimitsOfShape J 𝒥 :=
     {
@@ -431,19 +394,14 @@ instance hasColimits_moduleCat : HasColimits (ModuleCat.{max v u} R)
           { Cocone := colimit_cocone F
             IsColimit := colimit_cocone_is_colimit F } }
 #align Module.colimits.has_colimits_Module ModuleCat.Colimits.hasColimits_moduleCat
--/
 
-#print ModuleCat.Colimits.hasColimitsOfSize_moduleCat /-
 instance hasColimitsOfSize_moduleCat : HasColimitsOfSize.{v} (ModuleCat.{max v u} R) :=
   hasColimitsOfSize_shrink _
 #align Module.colimits.has_colimits_of_size_Module ModuleCat.Colimits.hasColimitsOfSize_moduleCat
--/
 
-#print ModuleCat.Colimits.hasColimitsOfSize_zero_moduleCat /-
 instance hasColimitsOfSize_zero_moduleCat : HasColimitsOfSize.{0} (ModuleCat.{max v u} R) :=
   @hasColimitsOfSize_shrink.{0} (ModuleCat.{max v u} R) _ ModuleCat.Colimits.hasColimits_moduleCat
 #align Module.colimits.has_colimits_of_size_zero_Module ModuleCat.Colimits.hasColimitsOfSize_zero_moduleCat
--/
 
 -- We manually add a `has_colimits` instance with universe parameters swapped, for otherwise
 -- the instance is not found by typeclass search.
Diff
@@ -214,7 +214,7 @@ instance : Module R (ColimitType F)
     apply Quot.sound
     apply relation.one_smul
     rfl
-  mul_smul s t x := by
+  hMul_smul s t x := by
     induction x
     dsimp
     apply Quot.sound
Diff
@@ -2,15 +2,12 @@
 Copyright (c) 2019 Scott Morrison. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Scott Morrison
-
-! This file was ported from Lean 3 source module algebra.category.Module.colimits
-! leanprover-community/mathlib commit c20927220ef87bb4962ba08bf6da2ce3cf50a6dd
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathbin.Algebra.Category.Module.Basic
 import Mathbin.CategoryTheory.ConcreteCategory.Elementwise
 
+#align_import algebra.category.Module.colimits from "leanprover-community/mathlib"@"c20927220ef87bb4962ba08bf6da2ce3cf50a6dd"
+
 /-!
 # The category of R-modules has all colimits.
 
Diff
@@ -245,26 +245,34 @@ instance : Module R (ColimitType F)
     apply relation.zero_smul
     rfl
 
+#print ModuleCat.Colimits.quot_zero /-
 @[simp]
 theorem quot_zero : Quot.mk Setoid.r zero = (0 : ColimitType F) :=
   rfl
 #align Module.colimits.quot_zero ModuleCat.Colimits.quot_zero
+-/
 
+#print ModuleCat.Colimits.quot_neg /-
 @[simp]
 theorem quot_neg (x) : Quot.mk Setoid.r (neg x) = (-Quot.mk Setoid.r x : ColimitType F) :=
   rfl
 #align Module.colimits.quot_neg ModuleCat.Colimits.quot_neg
+-/
 
+#print ModuleCat.Colimits.quot_add /-
 @[simp]
 theorem quot_add (x y) :
     Quot.mk Setoid.r (add x y) = (Quot.mk Setoid.r x + Quot.mk Setoid.r y : ColimitType F) :=
   rfl
 #align Module.colimits.quot_add ModuleCat.Colimits.quot_add
+-/
 
+#print ModuleCat.Colimits.quot_smul /-
 @[simp]
 theorem quot_smul (s x) : Quot.mk Setoid.r (smul s x) = (s • Quot.mk Setoid.r x : ColimitType F) :=
   rfl
 #align Module.colimits.quot_smul ModuleCat.Colimits.quot_smul
+-/
 
 #print ModuleCat.Colimits.colimit /-
 /-- The bundled module giving the colimit of a diagram. -/
@@ -273,11 +281,14 @@ def colimit : ModuleCat R :=
 #align Module.colimits.colimit ModuleCat.Colimits.colimit
 -/
 
+#print ModuleCat.Colimits.coconeFun /-
 /-- The function from a given module in the diagram to the colimit module. -/
 def coconeFun (j : J) (x : F.obj j) : ColimitType F :=
   Quot.mk _ (of j x)
 #align Module.colimits.cocone_fun ModuleCat.Colimits.coconeFun
+-/
 
+#print ModuleCat.Colimits.coconeMorphism /-
 /-- The group homomorphism from a given module in the diagram to the colimit module. -/
 def coconeMorphism (j : J) : F.obj j ⟶ colimit F
     where
@@ -285,7 +296,9 @@ def coconeMorphism (j : J) : F.obj j ⟶ colimit F
   map_smul' := by intros; apply Quot.sound; apply relation.smul
   map_add' := by intros <;> apply Quot.sound <;> apply relation.add
 #align Module.colimits.cocone_morphism ModuleCat.Colimits.coconeMorphism
+-/
 
+#print ModuleCat.Colimits.cocone_naturality /-
 @[simp]
 theorem cocone_naturality {j j' : J} (f : j ⟶ j') :
     F.map f ≫ coconeMorphism F j' = coconeMorphism F j :=
@@ -294,12 +307,15 @@ theorem cocone_naturality {j j' : J} (f : j ⟶ j') :
   apply Quot.sound
   apply Relation.Map
 #align Module.colimits.cocone_naturality ModuleCat.Colimits.cocone_naturality
+-/
 
+#print ModuleCat.Colimits.cocone_naturality_components /-
 @[simp]
 theorem cocone_naturality_components (j j' : J) (f : j ⟶ j') (x : F.obj j) :
     (coconeMorphism F j') (F.map f x) = (coconeMorphism F j) x := by rw [← cocone_naturality F f];
   rfl
 #align Module.colimits.cocone_naturality_components ModuleCat.Colimits.cocone_naturality_components
+-/
 
 #print ModuleCat.Colimits.colimitCocone /-
 /-- The cocone over the proposed colimit module. -/
@@ -426,9 +442,11 @@ instance hasColimitsOfSize_moduleCat : HasColimitsOfSize.{v} (ModuleCat.{max v u
 #align Module.colimits.has_colimits_of_size_Module ModuleCat.Colimits.hasColimitsOfSize_moduleCat
 -/
 
+#print ModuleCat.Colimits.hasColimitsOfSize_zero_moduleCat /-
 instance hasColimitsOfSize_zero_moduleCat : HasColimitsOfSize.{0} (ModuleCat.{max v u} R) :=
   @hasColimitsOfSize_shrink.{0} (ModuleCat.{max v u} R) _ ModuleCat.Colimits.hasColimits_moduleCat
 #align Module.colimits.has_colimits_of_size_zero_Module ModuleCat.Colimits.hasColimitsOfSize_zero_moduleCat
+-/
 
 -- We manually add a `has_colimits` instance with universe parameters swapped, for otherwise
 -- the instance is not found by typeclass search.
Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Scott Morrison
 
 ! This file was ported from Lean 3 source module algebra.category.Module.colimits
-! leanprover-community/mathlib commit 5a684ce82399d820475609907c6ef8dba5b1b97c
+! leanprover-community/mathlib commit c20927220ef87bb4962ba08bf6da2ce3cf50a6dd
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -14,6 +14,9 @@ import Mathbin.CategoryTheory.ConcreteCategory.Elementwise
 /-!
 # The category of R-modules has all colimits.
 
+> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
+> Any changes to this file require a corresponding PR to mathlib4.
+
 This file uses a "pre-automated" approach, just as for `Mon/colimits.lean`.
 
 Note that finite colimits can already be obtained from the instance `abelian (Module R)`.
Diff
@@ -47,6 +47,7 @@ and the identifications given by the morphisms in the diagram.
 
 variable {J : Type w} [Category.{v} J] (F : J ⥤ ModuleCat.{max u v w} R)
 
+#print ModuleCat.Colimits.Prequotient /-
 /-- An inductive type representing all module expressions (without relations)
 on a collection of types indexed by the objects of `J`.
 -/
@@ -59,12 +60,14 @@ inductive Prequotient-- There's always `of`
   | add : prequotient → prequotient → prequotient
   | smul : R → prequotient → prequotient
 #align Module.colimits.prequotient ModuleCat.Colimits.Prequotient
+-/
 
 instance : Inhabited (Prequotient F) :=
   ⟨Prequotient.zero⟩
 
 open Prequotient
 
+#print ModuleCat.Colimits.Relation /-
 /-- The relation on `prequotient` saying when two expressions are equal
 because of the module laws, or
 because one element is mapped to another by a morphism in the diagram.
@@ -110,7 +113,9 @@ inductive Relation : Prequotient F → Prequotient F → Prop-- Make it an equiv
   | add_smul : ∀ s t x, relation (smul (s + t) x) (add (smul s x) (smul t x))
   | zero_smul : ∀ x, relation (smul 0 x) zero
 #align Module.colimits.relation ModuleCat.Colimits.Relation
+-/
 
+#print ModuleCat.Colimits.colimitSetoid /-
 /-- The setoid corresponding to module expressions modulo module relations and identifications.
 -/
 def colimitSetoid : Setoid (Prequotient F)
@@ -118,15 +123,18 @@ def colimitSetoid : Setoid (Prequotient F)
   R := Relation F
   iseqv := ⟨Relation.refl, Relation.symm, Relation.trans⟩
 #align Module.colimits.colimit_setoid ModuleCat.Colimits.colimitSetoid
+-/
 
 attribute [instance] colimit_setoid
 
+#print ModuleCat.Colimits.ColimitType /-
 /-- The underlying type of the colimit of a diagram in `Module R`.
 -/
 def ColimitType : Type max u v w :=
   Quotient (colimitSetoid F)
 deriving Inhabited
 #align Module.colimits.colimit_type ModuleCat.Colimits.ColimitType
+-/
 
 instance : AddCommGroup (ColimitType F)
     where
@@ -255,10 +263,12 @@ theorem quot_smul (s x) : Quot.mk Setoid.r (smul s x) = (s • Quot.mk Setoid.r
   rfl
 #align Module.colimits.quot_smul ModuleCat.Colimits.quot_smul
 
+#print ModuleCat.Colimits.colimit /-
 /-- The bundled module giving the colimit of a diagram. -/
 def colimit : ModuleCat R :=
   ModuleCat.of R (ColimitType F)
 #align Module.colimits.colimit ModuleCat.Colimits.colimit
+-/
 
 /-- The function from a given module in the diagram to the colimit module. -/
 def coconeFun (j : J) (x : F.obj j) : ColimitType F :=
@@ -288,12 +298,15 @@ theorem cocone_naturality_components (j j' : J) (f : j ⟶ j') (x : F.obj j) :
   rfl
 #align Module.colimits.cocone_naturality_components ModuleCat.Colimits.cocone_naturality_components
 
+#print ModuleCat.Colimits.colimitCocone /-
 /-- The cocone over the proposed colimit module. -/
 def colimitCocone : Cocone F where
   pt := colimit F
   ι := { app := coconeMorphism F }
 #align Module.colimits.colimit_cocone ModuleCat.Colimits.colimitCocone
+-/
 
+#print ModuleCat.Colimits.descFunLift /-
 /-- The function from the free module on the diagram to the cone point of any other cocone. -/
 @[simp]
 def descFunLift (s : Cocone F) : Prequotient F → s.pt
@@ -303,7 +316,9 @@ def descFunLift (s : Cocone F) : Prequotient F → s.pt
   | add x y => desc_fun_lift x + desc_fun_lift y
   | smul s x => s • desc_fun_lift x
 #align Module.colimits.desc_fun_lift ModuleCat.Colimits.descFunLift
+-/
 
+#print ModuleCat.Colimits.descFun /-
 /-- The function from the colimit module to the cone point of any other cocone. -/
 def descFun (s : Cocone F) : ColimitType F → s.pt :=
   by
@@ -358,7 +373,9 @@ def descFun (s : Cocone F) : ColimitType F → s.pt :=
     -- zero_smul
     · rw [zero_smul]
 #align Module.colimits.desc_fun ModuleCat.Colimits.descFun
+-/
 
+#print ModuleCat.Colimits.descMorphism /-
 /-- The group homomorphism from the colimit module to the cone point of any other cocone. -/
 def descMorphism (s : Cocone F) : colimit F ⟶ s.pt
     where
@@ -366,7 +383,9 @@ def descMorphism (s : Cocone F) : colimit F ⟶ s.pt
   map_smul' s x := by induction x <;> rfl
   map_add' x y := by induction x <;> induction y <;> rfl
 #align Module.colimits.desc_morphism ModuleCat.Colimits.descMorphism
+-/
 
+#print ModuleCat.Colimits.colimitCoconeIsColimit /-
 /-- Evidence that the proposed colimit is the colimit. -/
 def colimitCoconeIsColimit : IsColimit (colimitCocone F)
     where
@@ -385,7 +404,9 @@ def colimitCoconeIsColimit : IsColimit (colimitCocone F)
     · simp [*]
     rfl
 #align Module.colimits.colimit_cocone_is_colimit ModuleCat.Colimits.colimitCoconeIsColimit
+-/
 
+#print ModuleCat.Colimits.hasColimits_moduleCat /-
 instance hasColimits_moduleCat : HasColimits (ModuleCat.{max v u} R)
     where HasColimitsOfShape J 𝒥 :=
     {
@@ -394,10 +415,13 @@ instance hasColimits_moduleCat : HasColimits (ModuleCat.{max v u} R)
           { Cocone := colimit_cocone F
             IsColimit := colimit_cocone_is_colimit F } }
 #align Module.colimits.has_colimits_Module ModuleCat.Colimits.hasColimits_moduleCat
+-/
 
+#print ModuleCat.Colimits.hasColimitsOfSize_moduleCat /-
 instance hasColimitsOfSize_moduleCat : HasColimitsOfSize.{v} (ModuleCat.{max v u} R) :=
   hasColimitsOfSize_shrink _
 #align Module.colimits.has_colimits_of_size_Module ModuleCat.Colimits.hasColimitsOfSize_moduleCat
+-/
 
 instance hasColimitsOfSize_zero_moduleCat : HasColimitsOfSize.{0} (ModuleCat.{max v u} R) :=
   @hasColimitsOfSize_shrink.{0} (ModuleCat.{max v u} R) _ ModuleCat.Colimits.hasColimits_moduleCat
Diff
@@ -124,7 +124,8 @@ attribute [instance] colimit_setoid
 /-- The underlying type of the colimit of a diagram in `Module R`.
 -/
 def ColimitType : Type max u v w :=
-  Quotient (colimitSetoid F)deriving Inhabited
+  Quotient (colimitSetoid F)
+deriving Inhabited
 #align Module.colimits.colimit_type ModuleCat.Colimits.ColimitType
 
 instance : AddCommGroup (ColimitType F)
@@ -268,7 +269,7 @@ def coconeFun (j : J) (x : F.obj j) : ColimitType F :=
 def coconeMorphism (j : J) : F.obj j ⟶ colimit F
     where
   toFun := coconeFun F j
-  map_smul' := by intros ; apply Quot.sound; apply relation.smul
+  map_smul' := by intros; apply Quot.sound; apply relation.smul
   map_add' := by intros <;> apply Quot.sound <;> apply relation.add
 #align Module.colimits.cocone_morphism ModuleCat.Colimits.coconeMorphism
 
Diff
@@ -268,10 +268,7 @@ def coconeFun (j : J) (x : F.obj j) : ColimitType F :=
 def coconeMorphism (j : J) : F.obj j ⟶ colimit F
     where
   toFun := coconeFun F j
-  map_smul' := by
-    intros
-    apply Quot.sound
-    apply relation.smul
+  map_smul' := by intros ; apply Quot.sound; apply relation.smul
   map_add' := by intros <;> apply Quot.sound <;> apply relation.add
 #align Module.colimits.cocone_morphism ModuleCat.Colimits.coconeMorphism
 
@@ -286,9 +283,7 @@ theorem cocone_naturality {j j' : J} (f : j ⟶ j') :
 
 @[simp]
 theorem cocone_naturality_components (j j' : J) (f : j ⟶ j') (x : F.obj j) :
-    (coconeMorphism F j') (F.map f x) = (coconeMorphism F j) x :=
-  by
-  rw [← cocone_naturality F f]
+    (coconeMorphism F j') (F.map f x) = (coconeMorphism F j) x := by rw [← cocone_naturality F f];
   rfl
 #align Module.colimits.cocone_naturality_components ModuleCat.Colimits.cocone_naturality_components
 
Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Scott Morrison
 
 ! This file was ported from Lean 3 source module algebra.category.Module.colimits
-! leanprover-community/mathlib commit 70fd9563a21e7b963887c9360bd29b2393e6225a
+! leanprover-community/mathlib commit 5a684ce82399d820475609907c6ef8dba5b1b97c
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -399,6 +399,14 @@ instance hasColimits_moduleCat : HasColimits (ModuleCat.{max v u} R)
             IsColimit := colimit_cocone_is_colimit F } }
 #align Module.colimits.has_colimits_Module ModuleCat.Colimits.hasColimits_moduleCat
 
+instance hasColimitsOfSize_moduleCat : HasColimitsOfSize.{v} (ModuleCat.{max v u} R) :=
+  hasColimitsOfSize_shrink _
+#align Module.colimits.has_colimits_of_size_Module ModuleCat.Colimits.hasColimitsOfSize_moduleCat
+
+instance hasColimitsOfSize_zero_moduleCat : HasColimitsOfSize.{0} (ModuleCat.{max v u} R) :=
+  @hasColimitsOfSize_shrink.{0} (ModuleCat.{max v u} R) _ ModuleCat.Colimits.hasColimits_moduleCat
+#align Module.colimits.has_colimits_of_size_zero_Module ModuleCat.Colimits.hasColimitsOfSize_zero_moduleCat
+
 -- We manually add a `has_colimits` instance with universe parameters swapped, for otherwise
 -- the instance is not found by typeclass search.
 instance hasColimits_Module' (R : Type u) [Ring R] : HasColimits (ModuleCat.{max u v} R) :=
Diff
@@ -294,13 +294,13 @@ theorem cocone_naturality_components (j j' : J) (f : j ⟶ j') (x : F.obj j) :
 
 /-- The cocone over the proposed colimit module. -/
 def colimitCocone : Cocone F where
-  x := colimit F
+  pt := colimit F
   ι := { app := coconeMorphism F }
 #align Module.colimits.colimit_cocone ModuleCat.Colimits.colimitCocone
 
 /-- The function from the free module on the diagram to the cone point of any other cocone. -/
 @[simp]
-def descFunLift (s : Cocone F) : Prequotient F → s.x
+def descFunLift (s : Cocone F) : Prequotient F → s.pt
   | of j x => (s.ι.app j) x
   | zero => 0
   | neg x => -desc_fun_lift x
@@ -309,7 +309,7 @@ def descFunLift (s : Cocone F) : Prequotient F → s.x
 #align Module.colimits.desc_fun_lift ModuleCat.Colimits.descFunLift
 
 /-- The function from the colimit module to the cone point of any other cocone. -/
-def descFun (s : Cocone F) : ColimitType F → s.x :=
+def descFun (s : Cocone F) : ColimitType F → s.pt :=
   by
   fapply Quot.lift
   · exact desc_fun_lift F s
@@ -364,7 +364,7 @@ def descFun (s : Cocone F) : ColimitType F → s.x :=
 #align Module.colimits.desc_fun ModuleCat.Colimits.descFun
 
 /-- The group homomorphism from the colimit module to the cone point of any other cocone. -/
-def descMorphism (s : Cocone F) : colimit F ⟶ s.x
+def descMorphism (s : Cocone F) : colimit F ⟶ s.pt
     where
   toFun := descFun F s
   map_smul' s x := by induction x <;> rfl
Diff
@@ -375,7 +375,7 @@ def descMorphism (s : Cocone F) : colimit F ⟶ s.x
 def colimitCoconeIsColimit : IsColimit (colimitCocone F)
     where
   desc s := descMorphism F s
-  uniq' s m w := by
+  uniq s m w := by
     ext
     induction x
     induction x

Changes in mathlib4

mathlib3
mathlib4
Revert "chore: revert #7703 (#7710)"

This reverts commit f3695eb2.

Diff
@@ -61,7 +61,8 @@ noncomputable def colimitCocone : Cocone F where
   ι :=
     { app := fun j => homMk (colimit.ι (F ⋙ forget₂ _ AddCommGroupCat)  j) (fun r => by
         dsimp
-        rw [mkOfSMul_smul]
+        -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
+        erw [mkOfSMul_smul]
         simp)
       naturality := fun i j f => by
         apply (forget₂ _ AddCommGroupCat).map_injective
@@ -77,7 +78,8 @@ noncomputable def isColimitColimitCocone : IsColimit (colimitCocone F) where
     intro j
     dsimp
     rw [colimit.ι_desc_assoc]
-    rw [mkOfSMul_smul]
+    -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
+    erw [mkOfSMul_smul]
     dsimp
     simp only [ι_colimMap_assoc, Functor.comp_obj, forget₂_obj, colimit.ι_desc,
       Functor.mapCocone_pt, Functor.mapCocone_ι_app, forget₂_map]
chore: revert #7703 (#7710)

This reverts commit 26eb2b0a.

Diff
@@ -61,8 +61,7 @@ noncomputable def colimitCocone : Cocone F where
   ι :=
     { app := fun j => homMk (colimit.ι (F ⋙ forget₂ _ AddCommGroupCat)  j) (fun r => by
         dsimp
-        -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
-        erw [mkOfSMul_smul]
+        rw [mkOfSMul_smul]
         simp)
       naturality := fun i j f => by
         apply (forget₂ _ AddCommGroupCat).map_injective
@@ -78,8 +77,7 @@ noncomputable def isColimitColimitCocone : IsColimit (colimitCocone F) where
     intro j
     dsimp
     rw [colimit.ι_desc_assoc]
-    -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
-    erw [mkOfSMul_smul]
+    rw [mkOfSMul_smul]
     dsimp
     simp only [ι_colimMap_assoc, Functor.comp_obj, forget₂_obj, colimit.ι_desc,
       Functor.mapCocone_pt, Functor.mapCocone_ι_app, forget₂_map]
chore: bump toolchain to v4.2.0-rc2 (#7703)

This includes all the changes from #7606.

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -61,7 +61,8 @@ noncomputable def colimitCocone : Cocone F where
   ι :=
     { app := fun j => homMk (colimit.ι (F ⋙ forget₂ _ AddCommGroupCat)  j) (fun r => by
         dsimp
-        rw [mkOfSMul_smul]
+        -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
+        erw [mkOfSMul_smul]
         simp)
       naturality := fun i j f => by
         apply (forget₂ _ AddCommGroupCat).map_injective
@@ -77,7 +78,8 @@ noncomputable def isColimitColimitCocone : IsColimit (colimitCocone F) where
     intro j
     dsimp
     rw [colimit.ι_desc_assoc]
-    rw [mkOfSMul_smul]
+    -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
+    erw [mkOfSMul_smul]
     dsimp
     simp only [ι_colimMap_assoc, Functor.comp_obj, forget₂_obj, colimit.ι_desc,
       Functor.mapCocone_pt, Functor.mapCocone_ι_app, forget₂_map]
refactor: colimits in ModuleCat (#6925)

This PR refactors the construction of colimits of modules in order to prove that the forgetful functor to abelian groups preserves colimits.

Diff
@@ -1,355 +1,127 @@
 /-
 Copyright (c) 2019 Scott Morrison. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
-Authors: Scott Morrison
+Authors: Scott Morrison, Joël Riou
 -/
 import Mathlib.Algebra.Category.ModuleCat.Basic
 import Mathlib.CategoryTheory.ConcreteCategory.Elementwise
+import Mathlib.Algebra.Category.GroupCat.Colimits
 
 #align_import algebra.category.Module.colimits from "leanprover-community/mathlib"@"5a684ce82399d820475609907c6ef8dba5b1b97c"
 
 /-!
 # The category of R-modules has all colimits.
 
-This file uses a "pre-automated" approach, just as for `Mathlib.Algebra.Category.MonCat.Colimits`.
+From the existence of colimits in `AddCommGroupCat`, we deduce the existence of colimits
+in `ModuleCat R`. This way, we get for free that the functor
+`forget₂ (ModuleCat R) AddCommGroupCat` commutes with colimits.
 
 Note that finite colimits can already be obtained from the instance `Abelian (Module R)`.
 
 TODO:
-In fact, in `Module R` there is a much nicer model of colimits as quotients
-of finitely supported functions, and we really should implement this as well (or instead).
+In fact, in `ModuleCat R` there is a much nicer model of colimits as quotients
+of finitely supported functions, and we really should implement this as well.
 -/
 
+universe w' w u v
+
+open CategoryTheory Category Limits
+
+variable {R : Type w} [Ring R]
+
+namespace ModuleCat
+
+variable {J : Type u} [Category.{v} J] (F : J ⥤ ModuleCat.{w'} R)
+
+namespace HasColimit
+
+variable [HasColimit (F ⋙ forget₂ _ AddCommGroupCat)]
+
+/-- The induced scalar multiplication on
+`colimit (F ⋙ forget₂ _ AddCommGroupCat)`. -/
+@[simps]
+noncomputable def coconePointSMul :
+    R →+* End (colimit (F ⋙ forget₂ _ AddCommGroupCat)) where
+  toFun r := colimMap
+    { app := fun j => (F.obj j).smul r
+      naturality := fun X Y f => smul_naturality _ _ }
+  map_zero' := colimit.hom_ext (by simp)
+  map_one' := colimit.hom_ext (by simp)
+  map_add' r s := colimit.hom_ext (fun j => by
+    simp only [Functor.comp_obj, forget₂_obj, map_add, ι_colimMap]
+    rw [Preadditive.add_comp, Preadditive.comp_add]
+    simp only [ι_colimMap, Functor.comp_obj, forget₂_obj])
+  map_mul' r s := colimit.hom_ext (fun j => by simp)
+
+/-- The cocone for `F` constructed from the colimit of
+`(F ⋙ forget₂ (ModuleCat R) AddCommGroupCat)`. -/
+@[simps]
+noncomputable def colimitCocone : Cocone F where
+  pt := mkOfSMul (coconePointSMul F)
+  ι :=
+    { app := fun j => homMk (colimit.ι (F ⋙ forget₂ _ AddCommGroupCat)  j) (fun r => by
+        dsimp
+        rw [mkOfSMul_smul]
+        simp)
+      naturality := fun i j f => by
+        apply (forget₂ _ AddCommGroupCat).map_injective
+        simp only [Functor.map_comp, forget₂_map_homMk]
+        dsimp
+        erw [colimit.w (F ⋙ forget₂ _ AddCommGroupCat), comp_id] }
+
+/-- The cocone for `F` constructed from the colimit of
+`(F ⋙ forget₂ (ModuleCat R) AddCommGroupCat)` is a colimit cocone. -/
+noncomputable def isColimitColimitCocone : IsColimit (colimitCocone F) where
+  desc s := homMk (colimit.desc _ ((forget₂ _ AddCommGroupCat).mapCocone s)) (fun r => by
+    apply colimit.hom_ext
+    intro j
+    dsimp
+    rw [colimit.ι_desc_assoc]
+    rw [mkOfSMul_smul]
+    dsimp
+    simp only [ι_colimMap_assoc, Functor.comp_obj, forget₂_obj, colimit.ι_desc,
+      Functor.mapCocone_pt, Functor.mapCocone_ι_app, forget₂_map]
+    exact smul_naturality (s.ι.app j) r)
+  fac s j := by
+    apply (forget₂ _ AddCommGroupCat).map_injective
+    exact colimit.ι_desc ((forget₂ _ AddCommGroupCat).mapCocone s) j
+  uniq s m hm := by
+    apply (forget₂ _ AddCommGroupCat).map_injective
+    apply colimit.hom_ext
+    intro j
+    erw [colimit.ι_desc ((forget₂ _ AddCommGroupCat).mapCocone s) j]
+    dsimp
+    rw [← hm]
+    rfl
 
-universe u v w
+instance : HasColimit F := ⟨_, isColimitColimitCocone F⟩
 
-open CategoryTheory
+noncomputable instance : PreservesColimit F (forget₂ _ AddCommGroupCat) :=
+  preservesColimitOfPreservesColimitCocone (isColimitColimitCocone F) (colimit.isColimit _)
 
-open CategoryTheory.Limits
+end HasColimit
 
-variable {R : Type u} [Ring R]
+variable (J R)
 
--- [ROBOT VOICE]:
--- You should pretend for now that this file was automatically generated.
--- It follows the same template as colimits in Mon.
-namespace ModuleCat.Colimits
-
-/-!
-We build the colimit of a diagram in `Module` by constructing the
-free group on the disjoint union of all the abelian groups in the diagram,
-then taking the quotient by the abelian group laws within each abelian group,
-and the identifications given by the morphisms in the diagram.
--/
+instance hasColimitsOfShape [HasColimitsOfShape J AddCommGroupCat.{w'}] :
+    HasColimitsOfShape J (ModuleCat.{w'} R) where
 
+instance hasColimitsOfSize [HasColimitsOfSize.{v, u} AddCommGroupCat.{w'}] :
+    HasColimitsOfSize.{v, u} (ModuleCat.{w'} R) where
 
-variable {J : Type w} [Category.{v} J] (F : J ⥤ ModuleCat.{max u v w} R)
+noncomputable instance forget₂PreservesColimitsOfShape
+    [HasColimitsOfShape J AddCommGroupCat.{w'}] :
+    PreservesColimitsOfShape J (forget₂ (ModuleCat.{w'} R) AddCommGroupCat) where
 
-/-- An inductive type representing all module expressions (without relations)
-on a collection of types indexed by the objects of `J`.
--/
-inductive Prequotient
-  -- There's always `of`
-  | of : ∀ (j : J) (_ : F.obj j), Prequotient
-  -- Then one generator for each operation
-  | zero : Prequotient
-  | neg : Prequotient → Prequotient
-  | add : Prequotient → Prequotient → Prequotient
-  | smul : R → Prequotient → Prequotient
-set_option linter.uppercaseLean3 false in
-#align Module.colimits.prequotient ModuleCat.Colimits.Prequotient
-
-instance : Inhabited (Prequotient F) :=
-  ⟨Prequotient.zero⟩
-
-open Prequotient
-
-/-- The relation on `Prequotient` saying when two expressions are equal
-because of the module laws, or
-because one element is mapped to another by a morphism in the diagram.
--/
-inductive Relation : Prequotient F → Prequotient F → Prop
-  -- Make it an equivalence relation:
-  | refl : ∀ x, Relation x x
-  | symm : ∀ (x y) (_ : Relation x y), Relation y x
-  | trans : ∀ (x y z) (_ : Relation x y) (_ : Relation y z), Relation x z
-  -- There's always a `map` Relation
-  | map : ∀ (j j' : J) (f : j ⟶ j') (x : F.obj j),
-    Relation (Prequotient.of j' (F.map f x)) (Prequotient.of j x)
-  -- Then one Relation per operation, describing the interaction with `of`
-  | zero : ∀ j, Relation (Prequotient.of j 0) zero
-  | neg : ∀ (j) (x : F.obj j),
-    Relation (Prequotient.of j (-x)) (neg (Prequotient.of j x))
-  | add : ∀ (j) (x y : F.obj j),
-    Relation (Prequotient.of j (x + y)) (add (Prequotient.of j x) (Prequotient.of j y))
-  | smul : ∀ (j) (s) (x : F.obj j),
-    Relation (Prequotient.of j (s • x)) (smul s (Prequotient.of j x))
-  -- Then one Relation per argument of each operation
-  | neg_1 : ∀ (x x') (_ : Relation x x'), Relation (neg x) (neg x')
-  | add_1 : ∀ (x x' y) (_ : Relation x x'), Relation (add x y) (add x' y)
-  | add_2 : ∀ (x y y') (_ : Relation y y'), Relation (add x y) (add x y')
-  | smul_1 : ∀ (s) (x x') (_ : Relation x x'), Relation (smul s x) (smul s x')
-  -- And one Relation per axiom
-  | zero_add : ∀ x, Relation (add zero x) x
-  | add_zero : ∀ x, Relation (add x zero) x
-  | add_left_neg : ∀ x, Relation (add (neg x) x) zero
-  | add_comm : ∀ x y, Relation (add x y) (add y x)
-  | add_assoc : ∀ x y z, Relation (add (add x y) z) (add x (add y z))
-  | one_smul : ∀ x, Relation (smul 1 x) x
-  | mul_smul : ∀ s t x, Relation (smul (s * t) x) (smul s (smul t x))
-  | smul_add : ∀ s x y, Relation (smul s (add x y)) (add (smul s x) (smul s y))
-  | smul_zero : ∀ s, Relation (smul s zero) zero
-  | add_smul : ∀ s t x, Relation (smul (s + t) x) (add (smul s x) (smul t x))
-  | zero_smul : ∀ x, Relation (smul 0 x) zero
-set_option linter.uppercaseLean3 false in
-#align Module.colimits.relation ModuleCat.Colimits.Relation
-
-/-- The setoid corresponding to module expressions modulo module relations and identifications.
--/
-def colimitSetoid : Setoid (Prequotient F) where
-  r := Relation F
-  iseqv := ⟨Relation.refl, Relation.symm _ _, Relation.trans _ _ _⟩
-set_option linter.uppercaseLean3 false in
-#align Module.colimits.colimit_setoid ModuleCat.Colimits.colimitSetoid
+noncomputable instance forget₂PreservesColimitsOfSize
+    [HasColimitsOfSize.{u, v} AddCommGroupCat.{w'}] :
+    PreservesColimitsOfSize.{u, v} (forget₂ (ModuleCat.{w'} R) AddCommGroupCat) where
 
-attribute [instance] colimitSetoid
+noncomputable instance
+    [HasColimitsOfSize.{u, v} AddCommGroupCatMax.{w, w'}] :
+    PreservesColimitsOfSize.{u, v} (forget₂ (ModuleCatMax.{w, w'} R) AddCommGroupCat) where
 
-/-- The underlying type of the colimit of a diagram in `Module R`.
--/
-def ColimitType : Type max u v w :=
-  Quotient (colimitSetoid F)
-set_option linter.uppercaseLean3 false in
-#align Module.colimits.colimit_type ModuleCat.Colimits.ColimitType
-
-instance : Inhabited (ColimitType F) := ⟨Quot.mk _ <| .zero⟩
-
-instance : AddCommGroup (ColimitType F) where
-  zero := Quotient.mk _ zero
-  neg := Quotient.map neg Relation.neg_1
-  add := Quotient.map₂ add <| fun x x' rx y y' ry =>
-    Setoid.trans (Relation.add_1 _ _ y rx) (Relation.add_2 x' _ _ ry)
-  zero_add := Quotient.ind <| fun _ => Quotient.sound <| Relation.zero_add _
-  add_zero := Quotient.ind <| fun _ => Quotient.sound <| Relation.add_zero _
-  add_left_neg := Quotient.ind <| fun _ => Quotient.sound <| Relation.add_left_neg _
-  add_comm := Quotient.ind₂ <| fun _ _ => Quotient.sound <| Relation.add_comm _ _
-  add_assoc := Quotient.ind <| fun _ => Quotient.ind₂ <| fun _ _ =>
-    Quotient.sound <| Relation.add_assoc _ _ _
-
-instance : Module R (ColimitType F) where
-  smul s := Quotient.map (smul s) <| Relation.smul_1 s
-  one_smul := Quotient.ind <| fun _ => Quotient.sound <| Relation.one_smul _
-  mul_smul _s _r := Quotient.ind <| fun _ => Quotient.sound <| Relation.mul_smul _ _ _
-  smul_add _s := Quotient.ind₂ <| fun _ _ => Quotient.sound <| Relation.smul_add _ _ _
-  smul_zero _s := Quotient.sound <| Relation.smul_zero _
-  add_smul _s _t := Quotient.ind <| fun _ => Quotient.sound <| Relation.add_smul _ _ _
-  zero_smul := Quotient.ind <| fun _ => Quotient.sound <| Relation.zero_smul _
-
-@[simp]
-theorem quot_zero : Quot.mk Setoid.r zero = (0 : ColimitType F) :=
-  rfl
-set_option linter.uppercaseLean3 false in
-#align Module.colimits.quot_zero ModuleCat.Colimits.quot_zero
-
-def ColimitType.mk {F : J ⥤ ModuleCat R} (x : Prequotient F) : ColimitType F := Quot.mk Setoid.r x
-
-@[simp]
-theorem quot_neg (x) : Quot.mk Setoid.r (neg x) = (-ColimitType.mk x : ColimitType F) :=
-  rfl
-set_option linter.uppercaseLean3 false in
-#align Module.colimits.quot_neg ModuleCat.Colimits.quot_neg
-
-@[simp]
-theorem quot_add (x y) :
-    Quot.mk Setoid.r (add x y) = (ColimitType.mk x + ColimitType.mk y : ColimitType F) :=
-  rfl
-set_option linter.uppercaseLean3 false in
-#align Module.colimits.quot_add ModuleCat.Colimits.quot_add
-
-@[simp]
-theorem quot_smul (s x) : Quot.mk Setoid.r (smul s x) = (s • ColimitType.mk x : ColimitType F) :=
-  rfl
-set_option linter.uppercaseLean3 false in
-#align Module.colimits.quot_smul ModuleCat.Colimits.quot_smul
-
-/-- The bundled module giving the colimit of a diagram. -/
-def colimit : ModuleCat R :=
-  ModuleCat.of R (ColimitType F)
-set_option linter.uppercaseLean3 false in
-#align Module.colimits.colimit ModuleCat.Colimits.colimit
-
-/-- The function from a given module in the diagram to the colimit module. -/
-def coconeFun (j : J) (x : F.obj j) : ColimitType F :=
-  Quot.mk _ (Prequotient.of j x)
-set_option linter.uppercaseLean3 false in
-#align Module.colimits.cocone_fun ModuleCat.Colimits.coconeFun
-
-/-- The group homomorphism from a given module in the diagram to the colimit module. -/
-def coconeMorphism (j : J) : F.obj j ⟶ colimit F where
-  toFun := coconeFun F j
-  map_smul' := by intros; apply Quot.sound; apply Relation.smul
-  map_add' := by intros; apply Quot.sound; apply Relation.add
-set_option linter.uppercaseLean3 false in
-#align Module.colimits.cocone_morphism ModuleCat.Colimits.coconeMorphism
-
-@[simp]
-theorem cocone_naturality {j j' : J} (f : j ⟶ j') :
-    F.map f ≫ coconeMorphism F j' = coconeMorphism F j := by
-  ext
-  apply Quot.sound
-  apply ModuleCat.Colimits.Relation.map
-set_option linter.uppercaseLean3 false in
-#align Module.colimits.cocone_naturality ModuleCat.Colimits.cocone_naturality
-
-@[simp]
-theorem cocone_naturality_components (j j' : J) (f : j ⟶ j') (x : F.obj j) :
-    (coconeMorphism F j') (F.map f x) = (coconeMorphism F j) x := by
-  rw [← cocone_naturality F f]
-  rfl
-set_option linter.uppercaseLean3 false in
-#align Module.colimits.cocone_naturality_components ModuleCat.Colimits.cocone_naturality_components
-
-/-- The cocone over the proposed colimit module. -/
-def colimitCocone : Cocone F where
-  pt := colimit F
-  ι := { app := coconeMorphism F }
-set_option linter.uppercaseLean3 false in
-#align Module.colimits.colimit_cocone ModuleCat.Colimits.colimitCocone
-
-/-- The function from the free module on the diagram to the cone point of any other cocone. -/
-@[simp]
-def descFunLift (s : Cocone F) : Prequotient F → s.pt
-  | Prequotient.of j x => (s.ι.app j) x
-  | zero => 0
-  | neg x => -descFunLift _ x
-  | add x y => descFunLift _ x + descFunLift _ y
-  | smul s x => s • descFunLift _ x
-set_option linter.uppercaseLean3 false in
-#align Module.colimits.desc_fun_lift ModuleCat.Colimits.descFunLift
-
-/-- The function from the colimit module to the cone point of any other cocone. -/
-def descFun (s : Cocone F) : ColimitType F → s.pt := by
-  fapply Quot.lift
-  · exact descFunLift F s
-  · intro x y r
-    induction' r with h₁ r_x r_y r_h r_ih r_x r_y r_z r_h r_k r_ih_h r_ih_k r_j r_j' r_f r_x j j x
-      j x y j s x u v r r_ih u v w r r_ih u v w r r_ih s u v r r_ih <;> try dsimp
-    -- refl
-    -- · rfl -- porting note: `dsimp` (above) now closes this
-    -- symm
-    · exact r_ih.symm
-    -- trans
-    · exact Eq.trans r_ih_h r_ih_k
-    -- map
-    · exact s.w_apply r_f r_x -- porting note: `simp` failed
-    -- zero
-    · simp
-    -- neg
-    · simp
-    -- add
-    · simp
-    -- smul,
-    · simp
-    -- neg_1
-    · rw [r_ih]
-    -- add_1
-    · rw [r_ih]
-    -- add_2
-    · rw [r_ih]
-    -- smul_1
-    · rw [r_ih]
-    -- zero_add
-    · rw [zero_add]
-    -- add_zero
-    · rw [add_zero]
-    -- add_left_neg
-    · rw [add_left_neg]
-    -- add_comm
-    · rw [add_comm]
-    -- add_assoc
-    · rw [add_assoc]
-    -- one_smul
-    · rw [one_smul]
-    -- mul_smul
-    · rw [mul_smul]
-    -- smul_add
-    · rw [smul_add]
-    -- smul_zero
-    · rw [smul_zero]
-    -- add_smul
-    · rw [add_smul]
-    -- zero_smul
-    · rw [zero_smul]
-set_option linter.uppercaseLean3 false in
-#align Module.colimits.desc_fun ModuleCat.Colimits.descFun
-
-/-- The group homomorphism from the colimit module to the cone point of any other cocone. -/
-def descMorphism (s : Cocone F) : colimit F ⟶ s.pt where
-  toFun := descFun F s
-  map_smul' s x := by rcases x; rfl
-  map_add' x y := by rcases x; rcases y; rfl
-set_option linter.uppercaseLean3 false in
-#align Module.colimits.desc_morphism ModuleCat.Colimits.descMorphism
-
-/-- Evidence that the proposed colimit is the colimit. -/
-def colimitCoconeIsColimit : IsColimit (colimitCocone F) where
-  desc s := descMorphism F s
-  uniq s m w := by
-    ext x
-    -- porting note: was `induction x` but now need `Quot.rec` with explicit `motive`
-    refine Quot.rec (motive := fun x ↦ m x = _) (fun x ↦ ?_) (fun x_a x_b x_p ↦ ?_) x
-    dsimp
-    induction' x with x_j x_x
-    · have w' :=
-        congr_fun (congr_arg (fun f : F.obj x_j ⟶ s.pt => (f : F.obj x_j → s.pt)) (w x_j)) x_x
-      simp only at w'
-      erw [w']
-      rfl
-    · rw [quot_zero, map_zero] -- porting note: was `simp` but `map_zero` won't fire
-      rfl
-    · simpa
-    · rw [quot_add, map_add, map_add]  -- porting note: this was closed by `simp [*]`
-      congr 1
-    · rw [quot_smul, map_smul, map_smul]  -- porting note: this was closed by `simp [*]`
-      congr 1
-    · rfl -- porting note: this wasn't here
-set_option linter.uppercaseLean3 false in
-#align Module.colimits.colimit_cocone_is_colimit ModuleCat.Colimits.colimitCoconeIsColimit
-
-instance hasColimits_moduleCat : HasColimits (ModuleCatMax.{v, u, u} R)
-    where has_colimits_of_shape _ _ :=
-    { has_colimit := fun F =>
-        HasColimit.mk
-          { cocone := colimitCocone F
-            isColimit := colimitCoconeIsColimit F } }
-set_option linter.uppercaseLean3 false in
-#align Module.colimits.has_colimits_Module ModuleCat.Colimits.hasColimits_moduleCat
-
-instance hasColimitsOfSize_moduleCat : HasColimitsOfSize.{v, v} (ModuleCatMax.{v, u, u} R) :=
-  hasColimitsOfSize_shrink.{v, v, u, u} _
-set_option linter.uppercaseLean3 false in
-#align Module.colimits.has_colimits_of_size_Module ModuleCat.Colimits.hasColimitsOfSize_moduleCat
-
-instance hasColimitsOfSize_zero_moduleCat : HasColimitsOfSize.{0, 0} (ModuleCatMax.{v, u, u} R) :=
-  -- Porting note: had to specify further universes.
-  hasColimitsOfSize_shrink.{0, 0, v, v} (ModuleCatMax.{v, u, u} R)
-set_option linter.uppercaseLean3 false in
-#align Module.colimits.has_colimits_of_size_zero_Module ModuleCat.Colimits.hasColimitsOfSize_zero_moduleCat
-
--- Porting note: in mathlib3 it was helpful to add to more instances with specialised universes.
--- However in Lean 4 they *break*, rather than *enable*, the examples below.
-
--- -- We manually add a `has_colimits` instance with universe parameters swapped, for otherwise
--- -- the instance is not found by typeclass search.
--- instance hasColimits_Module' (R : Type u) [Ring R] : HasColimits (ModuleCatMax.{u, v, u} R) :=
---   ModuleCat.Colimits.hasColimits_moduleCat.{u, v}
--- set_option linter.uppercaseLean3 false in
--- #align Module.colimits.has_colimits_Module' ModuleCat.Colimits.hasColimits_Module'
-
--- -- We manually add a `has_colimits` instance with equal universe parameters, for otherwise
--- -- the instance is not found by typeclass search.
--- instance hasColimits_Module'' (R : Type u) [Ring R] : HasColimits (ModuleCat.{u} R) :=
---   ModuleCat.Colimits.hasColimits_moduleCat.{u, u}
--- set_option linter.uppercaseLean3 false in
--- #align Module.colimits.has_colimits_Module'' ModuleCat.Colimits.hasColimits_Module''
+instance : HasFiniteColimits (ModuleCat.{w'} R) := inferInstance
 
 -- Sanity checks, just to make sure typeclass search can find the instances we want.
 example (R : Type u) [Ring R] : HasColimits (ModuleCatMax.{v, u} R) :=
@@ -361,4 +133,13 @@ example (R : Type u) [Ring R] : HasColimits (ModuleCatMax.{u, v} R) :=
 example (R : Type u) [Ring R] : HasColimits (ModuleCat.{u} R) :=
   inferInstance
 
-end ModuleCat.Colimits
+example (R : Type u) [Ring R] : HasCoequalizers (ModuleCat.{u} R) := by
+  infer_instance
+
+-- for some reason, this instance is not found automatically later on
+instance : HasCoequalizers (ModuleCat.{v} R) where
+
+noncomputable example (R : Type u) [Ring R] :
+  PreservesColimits (forget₂ (ModuleCat.{u} R) AddCommGroupCat) := inferInstance
+
+end ModuleCat
chore(Algebra/Category/*/Colimits): golf (#6265)

Found while doing a larger refactor. This doesn't change any defeqs, and the new proofs make it obvious that there's nothing interesting going on here.

Diff
@@ -123,79 +123,25 @@ set_option linter.uppercaseLean3 false in
 instance : Inhabited (ColimitType F) := ⟨Quot.mk _ <| .zero⟩
 
 instance : AddCommGroup (ColimitType F) where
-  zero := Quot.mk _ zero
-  neg := Quot.lift (fun t => Quot.mk _ <| neg t) <| fun x x' r => by
-    apply Quot.sound
-    exact Relation.neg_1 _ _ r
-  add := fun x y => Quot.liftOn₂ x y (fun x' y' => Quot.mk _ <| add x' y')
-    (by
-      intro u v w r
-      dsimp
-      apply Quot.sound
-      exact Relation.add_2 _ _ _ r)
-    (by
-      intro u v w r
-      dsimp
-      apply Quot.sound
-      exact Relation.add_1 _ _ _ r)
-  zero_add x := by
-    rcases x
-    dsimp
-    apply Quot.sound
-    apply Relation.zero_add
-  add_zero x := by
-    rcases x
-    dsimp
-    apply Quot.sound
-    apply Relation.add_zero
-  add_left_neg x := by
-    rcases x
-    dsimp
-    apply Quot.sound
-    apply Relation.add_left_neg
-  add_comm := by
-    rintro ⟨x⟩ ⟨y⟩
-    apply Quot.sound
-    apply Relation.add_comm
-  add_assoc := by
-    rintro ⟨x⟩ ⟨y⟩ ⟨z⟩
-    apply Quot.sound
-    apply Relation.add_assoc
+  zero := Quotient.mk _ zero
+  neg := Quotient.map neg Relation.neg_1
+  add := Quotient.map₂ add <| fun x x' rx y y' ry =>
+    Setoid.trans (Relation.add_1 _ _ y rx) (Relation.add_2 x' _ _ ry)
+  zero_add := Quotient.ind <| fun _ => Quotient.sound <| Relation.zero_add _
+  add_zero := Quotient.ind <| fun _ => Quotient.sound <| Relation.add_zero _
+  add_left_neg := Quotient.ind <| fun _ => Quotient.sound <| Relation.add_left_neg _
+  add_comm := Quotient.ind₂ <| fun _ _ => Quotient.sound <| Relation.add_comm _ _
+  add_assoc := Quotient.ind <| fun _ => Quotient.ind₂ <| fun _ _ =>
+    Quotient.sound <| Relation.add_assoc _ _ _
 
 instance : Module R (ColimitType F) where
-  smul s := by
-    fapply @Quot.lift
-    · intro x
-      exact Quot.mk _ (smul s x)
-    · intro x x' r
-      apply Quot.sound
-      exact Relation.smul_1 s _ _ r
-  one_smul x := by
-    rcases x
-    dsimp
-    apply Quot.sound
-    apply Relation.one_smul
-  mul_smul s t x := by
-    rcases x
-    dsimp
-    apply Quot.sound
-    apply Relation.mul_smul
-  smul_add s := by
-    rintro ⟨x⟩ ⟨y⟩
-    dsimp
-    apply Quot.sound
-    apply Relation.smul_add
-  smul_zero s := by apply Quot.sound; apply Relation.smul_zero
-  add_smul s t := by
-    rintro ⟨x⟩
-    dsimp
-    apply Quot.sound
-    apply Relation.add_smul
-  zero_smul := by
-    rintro ⟨x⟩
-    dsimp
-    apply Quot.sound
-    apply Relation.zero_smul
+  smul s := Quotient.map (smul s) <| Relation.smul_1 s
+  one_smul := Quotient.ind <| fun _ => Quotient.sound <| Relation.one_smul _
+  mul_smul _s _r := Quotient.ind <| fun _ => Quotient.sound <| Relation.mul_smul _ _ _
+  smul_add _s := Quotient.ind₂ <| fun _ _ => Quotient.sound <| Relation.smul_add _ _ _
+  smul_zero _s := Quotient.sound <| Relation.smul_zero _
+  add_smul _s _t := Quotient.ind <| fun _ => Quotient.sound <| Relation.add_smul _ _ _
+  zero_smul := Quotient.ind <| fun _ => Quotient.sound <| Relation.zero_smul _
 
 @[simp]
 theorem quot_zero : Quot.mk Setoid.r zero = (0 : ColimitType F) :=
chore: script to replace headers with #align_import statements (#5979)

Open in Gitpod

Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -2,15 +2,12 @@
 Copyright (c) 2019 Scott Morrison. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Scott Morrison
-
-! This file was ported from Lean 3 source module algebra.category.Module.colimits
-! leanprover-community/mathlib commit 5a684ce82399d820475609907c6ef8dba5b1b97c
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathlib.Algebra.Category.ModuleCat.Basic
 import Mathlib.CategoryTheory.ConcreteCategory.Elementwise
 
+#align_import algebra.category.Module.colimits from "leanprover-community/mathlib"@"5a684ce82399d820475609907c6ef8dba5b1b97c"
+
 /-!
 # The category of R-modules has all colimits.
 
chore: remove occurrences of semicolon after space (#5713)

This is the second half of the changes originally in #5699, removing all occurrences of ; after a space and implementing a linter rule to enforce it.

In most cases this 2-character substring has a space after it, so the following command was run first:

find . -type f -name "*.lean" -exec sed -i -E 's/ ; /; /g' {} \;

The remaining cases were few enough in number that they were done manually.

Diff
@@ -242,8 +242,8 @@ set_option linter.uppercaseLean3 false in
 /-- The group homomorphism from a given module in the diagram to the colimit module. -/
 def coconeMorphism (j : J) : F.obj j ⟶ colimit F where
   toFun := coconeFun F j
-  map_smul' := by intros ; apply Quot.sound ; apply Relation.smul
-  map_add' := by intros ; apply Quot.sound ; apply Relation.add
+  map_smul' := by intros; apply Quot.sound; apply Relation.smul
+  map_add' := by intros; apply Quot.sound; apply Relation.add
 set_option linter.uppercaseLean3 false in
 #align Module.colimits.cocone_morphism ModuleCat.Colimits.coconeMorphism
 
@@ -341,8 +341,8 @@ set_option linter.uppercaseLean3 false in
 /-- The group homomorphism from the colimit module to the cone point of any other cocone. -/
 def descMorphism (s : Cocone F) : colimit F ⟶ s.pt where
   toFun := descFun F s
-  map_smul' s x := by rcases x ; rfl
-  map_add' x y := by rcases x ; rcases y ; rfl
+  map_smul' s x := by rcases x; rfl
+  map_add' x y := by rcases x; rcases y; rfl
 set_option linter.uppercaseLean3 false in
 #align Module.colimits.desc_morphism ModuleCat.Colimits.descMorphism
 
chore: cleanup some simp-related porting notes (#4954)

I was looking on https://github.com/leanprover-community/mathlib4/pull/4933 to see what simp related porting notes I could improve after https://github.com/leanprover/lean4/pull/2266 lands in Lean 4. Mostly things I found could be cleaned up in any case, and so I've moved those into this PR.

There is lots more work to do diagnosing all the simp-related porting notes!

Co-authored-by: Scott Morrison <scott.morrison@anu.edu.au>

Diff
@@ -14,9 +14,9 @@ import Mathlib.CategoryTheory.ConcreteCategory.Elementwise
 /-!
 # The category of R-modules has all colimits.
 
-This file uses a "pre-automated" approach, just as for `Mon/colimits.lean`.
+This file uses a "pre-automated" approach, just as for `Mathlib.Algebra.Category.MonCat.Colimits`.
 
-Note that finite colimits can already be obtained from the instance `abelian (Module R)`.
+Note that finite colimits can already be obtained from the instance `Abelian (Module R)`.
 
 TODO:
 In fact, in `Module R` there is a much nicer model of colimits as quotients
@@ -362,8 +362,7 @@ def colimitCoconeIsColimit : IsColimit (colimitCocone F) where
       rfl
     · rw [quot_zero, map_zero] -- porting note: was `simp` but `map_zero` won't fire
       rfl
-    · rw [quot_neg, map_neg, map_neg, neg_inj] -- porting note: this was closed by `simp [*]`
-      assumption
+    · simpa
     · rw [quot_add, map_add, map_add]  -- porting note: this was closed by `simp [*]`
       congr 1
     · rw [quot_smul, map_smul, map_smul]  -- porting note: this was closed by `simp [*]`
feat: port Algebra.Category.Module.Colimits (#4282)

Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Dependencies 8 + 446

447 files ported (98.2%)
177336 lines ported (98.3%)
Show graph

The unported dependencies are