File: Mathlib/CategoryTheory/Idempotents/Karoubi.lean

full_name: CategoryTheory.Idempotents.Karoubi.p
code: /-- In a preadditive category `C`, when an object `X` decomposes as `X ≅ P ⨿ Q`, one may
consider `P` as a direct factor of `X` and up to unique isomorphism, it is determined by the
obvious idempotent `X ⟶ P ⟶ X` which is the projection onto `P` with kernel `Q`. More generally,
one may define a formal direct factor of an object `X : C` : it consists of an idempotent
`p : X ⟶ X` which is thought as the "formal image" of `p`. The type `Karoubi C` shall be the
type of the objects of the karoubi envelope of `C`. It makes sense for any category `C`. -/
structure Karoubi where
  /-- an object of the underlying category -/
  X : C
  /-- an endomorphism of the object -/
  p : X ⟶ X
  /-- the condition that the given endomorphism is an idempotent -/
  idem : p ≫ p = p := by aesop_cat
goal: self.X ⟶ self.X

full_name: CategoryTheory.Idempotents.Karoubi.X
code: /-- In a preadditive category `C`, when an object `X` decomposes as `X ≅ P ⨿ Q`, one may
consider `P` as a direct factor of `X` and up to unique isomorphism, it is determined by the
obvious idempotent `X ⟶ P ⟶ X` which is the projection onto `P` with kernel `Q`. More generally,
one may define a formal direct factor of an object `X : C` : it consists of an idempotent
`p : X ⟶ X` which is thought as the "formal image" of `p`. The type `Karoubi C` shall be the
type of the objects of the karoubi envelope of `C`. It makes sense for any category `C`. -/
structure Karoubi where
  /-- an object of the underlying category -/
  X : C
  /-- an endomorphism of the object -/
  p : X ⟶ X
  /-- the condition that the given endomorphism is an idempotent -/
  idem : p ≫ p = p := by aesop_cat
goal: C

full_name: CategoryTheory.Idempotents.Karoubi
code: /-- In a preadditive category `C`, when an object `X` decomposes as `X ≅ P ⨿ Q`, one may
consider `P` as a direct factor of `X` and up to unique isomorphism, it is determined by the
obvious idempotent `X ⟶ P ⟶ X` which is the projection onto `P` with kernel `Q`. More generally,
one may define a formal direct factor of an object `X : C` : it consists of an idempotent
`p : X ⟶ X` which is thought as the "formal image" of `p`. The type `Karoubi C` shall be the
type of the objects of the karoubi envelope of `C`. It makes sense for any category `C`. -/
structure Karoubi where
  /-- an object of the underlying category -/
  X : C
  /-- an endomorphism of the object -/
  p : X ⟶ X
  /-- the condition that the given endomorphism is an idempotent -/
  idem : p ≫ p = p := by aesop_cat
goal: Type (max u_1 u_2)

full_name: CategoryTheory.Idempotents.Karoubi.idem
code: /-- In a preadditive category `C`, when an object `X` decomposes as `X ≅ P ⨿ Q`, one may
consider `P` as a direct factor of `X` and up to unique isomorphism, it is determined by the
obvious idempotent `X ⟶ P ⟶ X` which is the projection onto `P` with kernel `Q`. More generally,
one may define a formal direct factor of an object `X : C` : it consists of an idempotent
`p : X ⟶ X` which is thought as the "formal image" of `p`. The type `Karoubi C` shall be the
type of the objects of the karoubi envelope of `C`. It makes sense for any category `C`. -/
structure Karoubi where
  /-- an object of the underlying category -/
  X : C
  /-- an endomorphism of the object -/
  p : X ⟶ X
  /-- the condition that the given endomorphism is an idempotent -/
  idem : p ≫ p = p := by aesop_cat
goal: CategoryTheory.CategoryStruct.comp self.p self.p = self.p

full_name: CategoryTheory.Idempotents.Karoubi.ext
code: @[ext]
theorem ext {P Q : Karoubi C} (h_X : P.X = Q.X) (h_p : P.p ≫ eqToHom h_X = eqToHom h_X ≫ Q.p) :
    P = Q 
goal: P = Q

full_name: CategoryTheory.Idempotents.Karoubi.Hom.comm
code: /-- A morphism `P ⟶ Q` in the category `Karoubi C` is a morphism in the underlying category
`C` which satisfies a relation, which in the preadditive case, expresses that it induces a
map between the corresponding "formal direct factors" and that it vanishes on the complement
formal direct factor. -/
@[ext]
structure Hom (P Q : Karoubi C) where
  /-- a morphism between the underlying objects -/
  f : P.X ⟶ Q.X
  /-- compatibility of the given morphism with the given idempotents -/
  comm : f = P.p ≫ f ≫ Q.p := by aesop_cat
goal: self.f = CategoryTheory.CategoryStruct.comp P.p (CategoryTheory.CategoryStruct.comp self.f Q.p)

full_name: CategoryTheory.Idempotents.Karoubi.Hom
code: /-- A morphism `P ⟶ Q` in the category `Karoubi C` is a morphism in the underlying category
`C` which satisfies a relation, which in the preadditive case, expresses that it induces a
map between the corresponding "formal direct factors" and that it vanishes on the complement
formal direct factor. -/
@[ext]
structure Hom (P Q : Karoubi C) where
  /-- a morphism between the underlying objects -/
  f : P.X ⟶ Q.X
  /-- compatibility of the given morphism with the given idempotents -/
  comm : f = P.p ≫ f ≫ Q.p := by aesop_cat
goal: Type u_2

full_name: CategoryTheory.Idempotents.Karoubi.Hom.f
code: /-- A morphism `P ⟶ Q` in the category `Karoubi C` is a morphism in the underlying category
`C` which satisfies a relation, which in the preadditive case, expresses that it induces a
map between the corresponding "formal direct factors" and that it vanishes on the complement
formal direct factor. -/
@[ext]
structure Hom (P Q : Karoubi C) where
  /-- a morphism between the underlying objects -/
  f : P.X ⟶ Q.X
  /-- compatibility of the given morphism with the given idempotents -/
  comm : f = P.p ≫ f ≫ Q.p := by aesop_cat
goal: P.X ⟶ Q.X

full_name: CategoryTheory.Idempotents.Karoubi.instInhabitedHomOfPreadditive
code: instance [Preadditive C] (P Q : Karoubi C) : Inhabited (Hom P Q) 
goal: Inhabited (P.Hom Q)

full_name: CategoryTheory.Idempotents.Karoubi.p_comp
code: @[reassoc (attr := simp)]
theorem p_comp {P Q : Karoubi C} (f : Hom P Q) : P.p ≫ f.f = f.f 
goal: CategoryTheory.CategoryStruct.comp P.p f.f = f.f

full_name: CategoryTheory.Idempotents.Karoubi.comp_p
code: @[reassoc (attr := simp)]
theorem comp_p {P Q : Karoubi C} (f : Hom P Q) : f.f ≫ Q.p = f.f 
goal: CategoryTheory.CategoryStruct.comp f.f Q.p = f.f

full_name: CategoryTheory.Idempotents.Karoubi.p_comm
code: @[reassoc]
theorem p_comm {P Q : Karoubi C} (f : Hom P Q) : P.p ≫ f.f = f.f ≫ Q.p 
goal: CategoryTheory.CategoryStruct.comp P.p f.f = CategoryTheory.CategoryStruct.comp f.f Q.p

full_name: CategoryTheory.Idempotents.Karoubi.comp_proof
code: theorem comp_proof {P Q R : Karoubi C} (g : Hom Q R) (f : Hom P Q) :
    f.f ≫ g.f = P.p ≫ (f.f ≫ g.f) ≫ R.p 
goal: CategoryTheory.CategoryStruct.comp f.f g.f =
  CategoryTheory.CategoryStruct.comp P.p
    (CategoryTheory.CategoryStruct.comp (CategoryTheory.CategoryStruct.comp f.f g.f) R.p)

full_name: CategoryTheory.Idempotents.Karoubi.instCategory
code: /-- The category structure on the karoubi envelope of a category. -/
instance : Category (Karoubi C) 
goal: CategoryTheory.Category.{u_2, max u_2 u_1} (CategoryTheory.Idempotents.Karoubi C)

full_name: CategoryTheory.Idempotents.Karoubi.hom_ext_iff
code: @[simp]
theorem hom_ext_iff {P Q : Karoubi C} {f g : P ⟶ Q} : f = g ↔ f.f = g.f 
goal: f = g ↔ f.f = g.f

full_name: CategoryTheory.Idempotents.Karoubi.hom_ext
code: @[ext]
theorem hom_ext {P Q : Karoubi C} (f g : P ⟶ Q) (h : f.f = g.f) : f = g 
goal: f = g

full_name: CategoryTheory.Idempotents.Karoubi.comp_f
code: @[simp]
theorem comp_f {P Q R : Karoubi C} (f : P ⟶ Q) (g : Q ⟶ R) : (f ≫ g).f = f.f ≫ g.f 
goal: (CategoryTheory.CategoryStruct.comp f g).f = CategoryTheory.CategoryStruct.comp f.f g.f

full_name: CategoryTheory.Idempotents.Karoubi.id_f
code: @[simp]
theorem id_f {P : Karoubi C} : Hom.f (𝟙 P) = P.p 
goal: (CategoryTheory.CategoryStruct.id P).f = P.p

full_name: CategoryTheory.Idempotents.Karoubi.id_eq
code: @[deprecated (since := "2024-07-15")]
theorem id_eq {P : Karoubi C} : 𝟙 P = ⟨P.p, by repeat' rw [P.idem]⟩ 
goal: CategoryTheory.CategoryStruct.id P = { f := P.p, comm := ⋯ }

full_name: CategoryTheory.Idempotents.Karoubi.coe
code: /-- It is possible to coerce an object of `C` into an object of `Karoubi C`.
See also the functor `toKaroubi`. -/
instance coe : CoeTC C (Karoubi C) 
goal: CoeTC C (CategoryTheory.Idempotents.Karoubi C)

full_name: CategoryTheory.Idempotents.Karoubi.coe_X
code: theorem coe_X (X : C) : (X : Karoubi C).X = X 
goal: { X := X, p := CategoryTheory.CategoryStruct.id X, idem := ⋯ }.X = X

full_name: CategoryTheory.Idempotents.Karoubi.coe_p
code: @[simp]
theorem coe_p (X : C) : (X : Karoubi C).p = 𝟙 X 
goal: { X := X, p := CategoryTheory.CategoryStruct.id X, idem := ⋯ }.p = CategoryTheory.CategoryStruct.id X

full_name: CategoryTheory.Idempotents.Karoubi.eqToHom_f
code: @[simp]
theorem eqToHom_f {P Q : Karoubi C} (h : P = Q) :
    Karoubi.Hom.f (eqToHom h) = P.p ≫ eqToHom (congr_arg Karoubi.X h) 
goal: (CategoryTheory.eqToHom h).f = CategoryTheory.CategoryStruct.comp P.p (CategoryTheory.eqToHom ⋯)

full_name: CategoryTheory.Idempotents.toKaroubi_obj_p
code: /-- The obvious fully faithful functor `toKaroubi` sends an object `X : C` to the obvious
formal direct factor of `X` given by `𝟙 X`. -/
@[simps]
def toKaroubi : C ⥤ Karoubi C 
goal: ((CategoryTheory.Idempotents.toKaroubi C).obj X).p = CategoryTheory.CategoryStruct.id X

full_name: CategoryTheory.Idempotents.toKaroubi_map_f
code: /-- The obvious fully faithful functor `toKaroubi` sends an object `X : C` to the obvious
formal direct factor of `X` given by `𝟙 X`. -/
@[simps]
def toKaroubi : C ⥤ Karoubi C 
goal: ∀ {X Y : C} (f : X ⟶ Y), ((CategoryTheory.Idempotents.toKaroubi C).map f).f = f

full_name: CategoryTheory.Idempotents.toKaroubi_obj_X
code: /-- The obvious fully faithful functor `toKaroubi` sends an object `X : C` to the obvious
formal direct factor of `X` given by `𝟙 X`. -/
@[simps]
def toKaroubi : C ⥤ Karoubi C 
goal: ((CategoryTheory.Idempotents.toKaroubi C).obj X).X = X

full_name: CategoryTheory.Idempotents.toKaroubi
code: /-- The obvious fully faithful functor `toKaroubi` sends an object `X : C` to the obvious
formal direct factor of `X` given by `𝟙 X`. -/
@[simps]
def toKaroubi : C ⥤ Karoubi C 
goal: CategoryTheory.Functor C (CategoryTheory.Idempotents.Karoubi C)

full_name: CategoryTheory.Idempotents.instFullKaroubiToKaroubi
code: instance : (toKaroubi C).Full 
goal: (CategoryTheory.Idempotents.toKaroubi C).Full

full_name: CategoryTheory.Idempotents.instFaithfulKaroubiToKaroubi
code: instance : (toKaroubi C).Faithful 
goal: (CategoryTheory.Idempotents.toKaroubi C).Faithful

full_name: CategoryTheory.Idempotents.instAdd
code: @[simps add]
instance instAdd [Preadditive C] {P Q : Karoubi C} : Add (P ⟶ Q) 
goal: Add (P ⟶ Q)

full_name: CategoryTheory.Idempotents.instAdd_add
code: @[simps add]
instance instAdd [Preadditive C] {P Q : Karoubi C} : Add (P ⟶ Q) 
goal: f + g = { f := f.f + g.f, comm := ⋯ }

full_name: CategoryTheory.Idempotents.instNeg
code: @[simps neg]
instance instNeg [Preadditive C] {P Q : Karoubi C} : Neg (P ⟶ Q) 
goal: Neg (P ⟶ Q)

full_name: CategoryTheory.Idempotents.instNeg_neg
code: @[simps neg]
instance instNeg [Preadditive C] {P Q : Karoubi C} : Neg (P ⟶ Q) 
goal: -f = { f := -f.f, comm := ⋯ }

full_name: CategoryTheory.Idempotents.instZero_zero
code: @[simps zero]
instance instZero [Preadditive C] {P Q : Karoubi C} : Zero (P ⟶ Q) 
goal: 0 = { f := 0, comm := ⋯ }

full_name: CategoryTheory.Idempotents.instZero
code: @[simps zero]
instance instZero [Preadditive C] {P Q : Karoubi C} : Zero (P ⟶ Q) 
goal: Zero (P ⟶ Q)

full_name: CategoryTheory.Idempotents.instAddCommGroupHom
code: instance instAddCommGroupHom [Preadditive C] {P Q : Karoubi C} : AddCommGroup (P ⟶ Q) 
goal: AddCommGroup (P ⟶ Q)

full_name: CategoryTheory.Idempotents.Karoubi.hom_eq_zero_iff
code: theorem hom_eq_zero_iff [Preadditive C] {P Q : Karoubi C} {f : P ⟶ Q} : f = 0 ↔ f.f = 0 
goal: f = 0 ↔ f.f = 0

full_name: CategoryTheory.Idempotents.Karoubi.inclusionHom_apply
code: /-- The map sending `f : P ⟶ Q` to `f.f : P.X ⟶ Q.X` is additive. -/
@[simps]
def inclusionHom [Preadditive C] (P Q : Karoubi C) : AddMonoidHom (P ⟶ Q) (P.X ⟶ Q.X) 
goal: (P.inclusionHom Q) f = f.f

full_name: CategoryTheory.Idempotents.Karoubi.inclusionHom
code: /-- The map sending `f : P ⟶ Q` to `f.f : P.X ⟶ Q.X` is additive. -/
@[simps]
def inclusionHom [Preadditive C] (P Q : Karoubi C) : AddMonoidHom (P ⟶ Q) (P.X ⟶ Q.X) 
goal: (P ⟶ Q) →+ (P.X ⟶ Q.X)

full_name: CategoryTheory.Idempotents.Karoubi.sum_hom
code: @[simp]
theorem sum_hom [Preadditive C] {P Q : Karoubi C} {α : Type*} (s : Finset α) (f : α → (P ⟶ Q)) :
    (∑ x ∈ s, f x).f = ∑ x ∈ s, (f x).f 
goal: (∑ x ∈ s, f x).f = ∑ x ∈ s, (f x).f

full_name: CategoryTheory.Idempotents.instPreadditiveKaroubi
code: /-- The category `Karoubi C` is preadditive if `C` is. -/
instance [Preadditive C] : Preadditive (Karoubi C) 
goal: CategoryTheory.Preadditive (CategoryTheory.Idempotents.Karoubi C)

full_name: CategoryTheory.Idempotents.instAdditiveKaroubiToKaroubi
code: instance [Preadditive C] : Functor.Additive (toKaroubi C) 
goal: (CategoryTheory.Idempotents.toKaroubi C).Additive

full_name: CategoryTheory.Idempotents.instIsIdempotentCompleteKaroubi
code: instance : IsIdempotentComplete (Karoubi C) 
goal: CategoryTheory.IsIdempotentComplete (CategoryTheory.Idempotents.Karoubi C)

full_name: CategoryTheory.Idempotents.instEssSurjKaroubiToKaroubiOfIsIdempotentComplete
code: instance [IsIdempotentComplete C] : (toKaroubi C).EssSurj 
goal: (CategoryTheory.Idempotents.toKaroubi C).EssSurj

full_name: CategoryTheory.Idempotents.toKaroubi_isEquivalence
code: /-- If `C` is idempotent complete, the functor `toKaroubi : C ⥤ Karoubi C` is an equivalence. -/
instance toKaroubi_isEquivalence [IsIdempotentComplete C] : (toKaroubi C).IsEquivalence 
goal: (CategoryTheory.Idempotents.toKaroubi C).IsEquivalence

full_name: CategoryTheory.Idempotents.toKaroubiEquivalence
code: /-- The equivalence `C ≅ Karoubi C` when `C` is idempotent complete. -/
def toKaroubiEquivalence [IsIdempotentComplete C] : C ≌ Karoubi C 
goal: C ≌ CategoryTheory.Idempotents.Karoubi C

full_name: CategoryTheory.Idempotents.toKaroubiEquivalence_functor_additive
code: instance toKaroubiEquivalence_functor_additive [Preadditive C] [IsIdempotentComplete C] :
    (toKaroubiEquivalence C).functor.Additive 
goal: (CategoryTheory.Idempotents.toKaroubiEquivalence C).functor.Additive

full_name: CategoryTheory.Idempotents.Karoubi.decompId_i
code: /-- The split mono which appears in the factorisation `decompId P`. -/
@[simps]
def decompId_i (P : Karoubi C) : P ⟶ P.X 
goal: P ⟶ { X := P.X, p := CategoryTheory.CategoryStruct.id P.X, idem := ⋯ }

full_name: CategoryTheory.Idempotents.Karoubi.decompId_i_f
code: /-- The split mono which appears in the factorisation `decompId P`. -/
@[simps]
def decompId_i (P : Karoubi C) : P ⟶ P.X 
goal: P.decompId_i.f = P.p

full_name: CategoryTheory.Idempotents.Karoubi.decompId_p
code: /-- The split epi which appears in the factorisation `decompId P`. -/
@[simps]
def decompId_p (P : Karoubi C) : (P.X : Karoubi C) ⟶ P 
goal: { X := P.X, p := CategoryTheory.CategoryStruct.id P.X, idem := ⋯ } ⟶ P

full_name: CategoryTheory.Idempotents.Karoubi.decompId_p_f
code: /-- The split epi which appears in the factorisation `decompId P`. -/
@[simps]
def decompId_p (P : Karoubi C) : (P.X : Karoubi C) ⟶ P 
goal: P.decompId_p.f = P.p

full_name: CategoryTheory.Idempotents.Karoubi.decompId
code: /-- The formal direct factor of `P.X` given by the idempotent `P.p` in the category `C`
is actually a direct factor in the category `Karoubi C`. -/
@[reassoc]
theorem decompId (P : Karoubi C) : 𝟙 P = decompId_i P ≫ decompId_p P 
goal: CategoryTheory.CategoryStruct.id P = CategoryTheory.CategoryStruct.comp P.decompId_i P.decompId_p

full_name: CategoryTheory.Idempotents.Karoubi.decomp_p
code: theorem decomp_p (P : Karoubi C) : (toKaroubi C).map P.p = decompId_p P ≫ decompId_i P 
goal: (CategoryTheory.Idempotents.toKaroubi C).map P.p = CategoryTheory.CategoryStruct.comp P.decompId_p P.decompId_i

full_name: CategoryTheory.Idempotents.Karoubi.decompId_i_toKaroubi
code: theorem decompId_i_toKaroubi (X : C) : decompId_i ((toKaroubi C).obj X) = 𝟙 _ 
goal: ((CategoryTheory.Idempotents.toKaroubi C).obj X).decompId_i =
  CategoryTheory.CategoryStruct.id ((CategoryTheory.Idempotents.toKaroubi C).obj X)

full_name: CategoryTheory.Idempotents.Karoubi.decompId_p_toKaroubi
code: theorem decompId_p_toKaroubi (X : C) : decompId_p ((toKaroubi C).obj X) = 𝟙 _ 
goal: ((CategoryTheory.Idempotents.toKaroubi C).obj X).decompId_p =
  CategoryTheory.CategoryStruct.id
    { X := ((CategoryTheory.Idempotents.toKaroubi C).obj X).X,
      p := CategoryTheory.CategoryStruct.id ((CategoryTheory.Idempotents.toKaroubi C).obj X).X, idem := ⋯ }

full_name: CategoryTheory.Idempotents.Karoubi.decompId_i_naturality
code: theorem decompId_i_naturality {P Q : Karoubi C} (f : P ⟶ Q) :
    f ≫ decompId_i Q = decompId_i P ≫ (by exact Hom.mk f.f (by simp)) 
goal: CategoryTheory.CategoryStruct.comp f Q.decompId_i =
  CategoryTheory.CategoryStruct.comp P.decompId_i { f := f.f, comm := ⋯ }

full_name: CategoryTheory.Idempotents.Karoubi.decompId_p_naturality
code: theorem decompId_p_naturality {P Q : Karoubi C} (f : P ⟶ Q) :
    decompId_p P ≫ f = (by exact Hom.mk f.f (by simp)) ≫ decompId_p Q 
goal: CategoryTheory.CategoryStruct.comp P.decompId_p f =
  CategoryTheory.CategoryStruct.comp { f := f.f, comm := ⋯ } Q.decompId_p

full_name: CategoryTheory.Idempotents.Karoubi.zsmul_hom
code: @[simp]
theorem zsmul_hom [Preadditive C] {P Q : Karoubi C} (n : ℤ) (f : P ⟶ Q) : (n • f).f = n • f.f 
goal: (n • f).f = n • f.f