l3lab/ntp-mathlib huggingface dataset:
theorem FormallySmooth.localization_base [FormallySmooth R Sₘ] : FormallySmooth Rₘ Sₘ := by
  constructor
  intro Q _ _ I e f
  letI := ((algebraMap Rₘ Q).comp (algebraMap R Rₘ)).toAlgebra
  letI : IsScalarTower R Rₘ Q := IsScalarTower.of_algebraMap_eq' rfl
  let f : Sₘ →ₐ[Rₘ] Q := by
    refine' { FormallySmooth.lift I ⟨2, e⟩ (f.restrictScalars R) with commutes' := _ }
    intro r
    change
      (RingHom.comp (FormallySmooth.lift I ⟨2, e⟩ (f.restrictScalars R) : Sₘ →+* Q)
            (algebraMap _ _))
          r =
        algebraMap _ _ r
    congr 1
    refine' IsLocalization.ringHom_ext M _
    rw [RingHom.comp_assoc, ← IsScalarTower.algebraMap_eq, ← IsScalarTower.algebraMap_eq,
      AlgHom.comp_algebraMap]
  

Proof state:
case comp_surjective
R S Rₘ Sₘ : Type u
inst✝¹⁵ : CommRing R
inst✝¹⁴ : CommRing S
inst✝¹³ : CommRing Rₘ
inst✝¹² : CommRing Sₘ
M : Submonoid R
inst✝¹¹ : Algebra R S
inst✝¹⁰ : Algebra R Sₘ
inst✝⁹ : Algebra S Sₘ
inst✝⁸ : Algebra R Rₘ
inst✝⁷ : Algebra Rₘ Sₘ
inst✝⁶ : IsScalarTower R Rₘ Sₘ
inst✝⁵ : IsScalarTower R S Sₘ
inst✝⁴ : IsLocalization M Rₘ
inst✝³ : IsLocalization (Submonoid.map (algebraMap R S) M) Sₘ
inst✝² : FormallySmooth R Sₘ
Q : Type u
inst✝¹ : CommRing Q
inst✝ : Algebra Rₘ Q
I : Ideal Q
e : I ^ 2 = ⊥
f✝ : Sₘ →ₐ[Rₘ] Q ⧸ I
this✝ : Algebra R Q := RingHom.toAlgebra (RingHom.comp (algebraMap Rₘ Q) (algebraMap R Rₘ))
this : IsScalarTower R Rₘ Q := IsScalarTower.of_algebraMap_eq' rfl
f : Sₘ →ₐ[Rₘ] Q :=
  let src := lift I (_ : ∃ n, I ^ n = 0) (AlgHom.restrictScalars R f✝);
  { toRingHom := ↑src,
    commutes' :=
      (_ :
        ∀ (r : Rₘ),
          (RingHom.comp (↑(lift I (_ : ∃ n, I ^ n = 0) (AlgHom.restrictScalars R f✝))) (algebraMap Rₘ Sₘ)) r =
            (algebraMap Rₘ Q) r) }
⊢ ∃ a, AlgHom.comp (Ideal.Quotient.mkₐ Rₘ I) a = f✝

Next tactic:
use f
theorem FormallySmooth.localization_base [FormallySmooth R Sₘ] : FormallySmooth Rₘ Sₘ := by
  constructor
  intro Q _ _ I e f
  letI := ((algebraMap Rₘ Q).comp (algebraMap R Rₘ)).toAlgebra
  letI : IsScalarTower R Rₘ Q := IsScalarTower.of_algebraMap_eq' rfl
  let f : Sₘ →ₐ[Rₘ] Q := by
    refine' { FormallySmooth.lift I ⟨2, e⟩ (f.restrictScalars R) with commutes' := _ }
    intro r
    change
      (RingHom.comp (FormallySmooth.lift I ⟨2, e⟩ (f.restrictScalars R) : Sₘ →+* Q)
            (algebraMap _ _))
          r =
        algebraMap _ _ r
    congr 1
    refine' IsLocalization.ringHom_ext M _
    rw [RingHom.comp_assoc, ← IsScalarTower.algebraMap_eq, ← IsScalarTower.algebraMap_eq,
      AlgHom.comp_algebraMap]
  use f
  

Proof state:
case h
R S Rₘ Sₘ : Type u
inst✝¹⁵ : CommRing R
inst✝¹⁴ : CommRing S
inst✝¹³ : CommRing Rₘ
inst✝¹² : CommRing Sₘ
M : Submonoid R
inst✝¹¹ : Algebra R S
inst✝¹⁰ : Algebra R Sₘ
inst✝⁹ : Algebra S Sₘ
inst✝⁸ : Algebra R Rₘ
inst✝⁷ : Algebra Rₘ Sₘ
inst✝⁶ : IsScalarTower R Rₘ Sₘ
inst✝⁵ : IsScalarTower R S Sₘ
inst✝⁴ : IsLocalization M Rₘ
inst✝³ : IsLocalization (Submonoid.map (algebraMap R S) M) Sₘ
inst✝² : FormallySmooth R Sₘ
Q : Type u
inst✝¹ : CommRing Q
inst✝ : Algebra Rₘ Q
I : Ideal Q
e : I ^ 2 = ⊥
f✝ : Sₘ →ₐ[Rₘ] Q ⧸ I
this✝ : Algebra R Q := RingHom.toAlgebra (RingHom.comp (algebraMap Rₘ Q) (algebraMap R Rₘ))
this : IsScalarTower R Rₘ Q := IsScalarTower.of_algebraMap_eq' rfl
f : Sₘ →ₐ[Rₘ] Q :=
  let src := lift I (_ : ∃ n, I ^ n = 0) (AlgHom.restrictScalars R f✝);
  { toRingHom := ↑src,
    commutes' :=
      (_ :
        ∀ (r : Rₘ),
          (RingHom.comp (↑(lift I (_ : ∃ n, I ^ n = 0) (AlgHom.restrictScalars R f✝))) (algebraMap Rₘ Sₘ)) r =
            (algebraMap Rₘ Q) r) }
⊢ AlgHom.comp (Ideal.Quotient.mkₐ Rₘ I) f = f✝

Next tactic:
ext
theorem FormallySmooth.localization_base [FormallySmooth R Sₘ] : FormallySmooth Rₘ Sₘ := by
  constructor
  intro Q _ _ I e f
  letI := ((algebraMap Rₘ Q).comp (algebraMap R Rₘ)).toAlgebra
  letI : IsScalarTower R Rₘ Q := IsScalarTower.of_algebraMap_eq' rfl
  let f : Sₘ →ₐ[Rₘ] Q := by
    refine' { FormallySmooth.lift I ⟨2, e⟩ (f.restrictScalars R) with commutes' := _ }
    intro r
    change
      (RingHom.comp (FormallySmooth.lift I ⟨2, e⟩ (f.restrictScalars R) : Sₘ →+* Q)
            (algebraMap _ _))
          r =
        algebraMap _ _ r
    congr 1
    refine' IsLocalization.ringHom_ext M _
    rw [RingHom.comp_assoc, ← IsScalarTower.algebraMap_eq, ← IsScalarTower.algebraMap_eq,
      AlgHom.comp_algebraMap]
  use f
  ext
  

Proof state:
case h.H
R S Rₘ Sₘ : Type u
inst✝¹⁵ : CommRing R
inst✝¹⁴ : CommRing S
inst✝¹³ : CommRing Rₘ
inst✝¹² : CommRing Sₘ
M : Submonoid R
inst✝¹¹ : Algebra R S
inst✝¹⁰ : Algebra R Sₘ
inst✝⁹ : Algebra S Sₘ
inst✝⁸ : Algebra R Rₘ
inst✝⁷ : Algebra Rₘ Sₘ
inst✝⁶ : IsScalarTower R Rₘ Sₘ
inst✝⁵ : IsScalarTower R S Sₘ
inst✝⁴ : IsLocalization M Rₘ
inst✝³ : IsLocalization (Submonoid.map (algebraMap R S) M) Sₘ
inst✝² : FormallySmooth R Sₘ
Q : Type u
inst✝¹ : CommRing Q
inst✝ : Algebra Rₘ Q
I : Ideal Q
e : I ^ 2 = ⊥
f✝ : Sₘ →ₐ[Rₘ] Q ⧸ I
this✝ : Algebra R Q := RingHom.toAlgebra (RingHom.comp (algebraMap Rₘ Q) (algebraMap R Rₘ))
this : IsScalarTower R Rₘ Q := IsScalarTower.of_algebraMap_eq' rfl
f : Sₘ →ₐ[Rₘ] Q :=
  let src := lift I (_ : ∃ n, I ^ n = 0) (AlgHom.restrictScalars R f✝);
  { toRingHom := ↑src,
    commutes' :=
      (_ :
        ∀ (r : Rₘ),
          (RingHom.comp (↑(lift I (_ : ∃ n, I ^ n = 0) (AlgHom.restrictScalars R f✝))) (algebraMap Rₘ Sₘ)) r =
            (algebraMap Rₘ Q) r) }
x✝ : Sₘ
⊢ (AlgHom.comp (Ideal.Quotient.mkₐ Rₘ I) f) x✝ = f✝ x✝

Next tactic:
simp
theorem FormallySmooth.localization_map [FormallySmooth R S] : FormallySmooth Rₘ Sₘ := by
  

Proof state:
R S Rₘ Sₘ : Type u
inst✝¹³ : CommRing R
inst✝¹² : CommRing S
inst✝¹¹ : CommRing Rₘ
inst✝¹⁰ : CommRing Sₘ
M : Submonoid R
inst✝⁹ : Algebra R S
inst✝⁸ : Algebra R Sₘ
inst✝⁷ : Algebra S Sₘ
inst✝⁶ : Algebra R Rₘ
inst✝⁵ : Algebra Rₘ Sₘ
inst✝⁴ : IsScalarTower R Rₘ Sₘ
inst✝³ : IsScalarTower R S Sₘ
inst✝² : IsLocalization M Rₘ
inst✝¹ : IsLocalization (Submonoid.map (algebraMap R S) M) Sₘ
inst✝ : FormallySmooth R S
⊢ FormallySmooth Rₘ Sₘ

Next tactic:
haveI : FormallySmooth S Sₘ := FormallySmooth.of_isLocalization (M.map (algebraMap R S))
theorem FormallySmooth.localization_map [FormallySmooth R S] : FormallySmooth Rₘ Sₘ := by
  haveI : FormallySmooth S Sₘ := FormallySmooth.of_isLocalization (M.map (algebraMap R S))
  

Proof state:
R S Rₘ Sₘ : Type u
inst✝¹³ : CommRing R
inst✝¹² : CommRing S
inst✝¹¹ : CommRing Rₘ
inst✝¹⁰ : CommRing Sₘ
M : Submonoid R
inst✝⁹ : Algebra R S
inst✝⁸ : Algebra R Sₘ
inst✝⁷ : Algebra S Sₘ
inst✝⁶ : Algebra R Rₘ
inst✝⁵ : Algebra Rₘ Sₘ
inst✝⁴ : IsScalarTower R Rₘ Sₘ
inst✝³ : IsScalarTower R S Sₘ
inst✝² : IsLocalization M Rₘ
inst✝¹ : IsLocalization (Submonoid.map (algebraMap R S) M) Sₘ
inst✝ : FormallySmooth R S
this : FormallySmooth S Sₘ
⊢ FormallySmooth Rₘ Sₘ

Next tactic:
haveI : FormallySmooth R Sₘ := FormallySmooth.comp R S Sₘ
theorem FormallySmooth.localization_map [FormallySmooth R S] : FormallySmooth Rₘ Sₘ := by
  haveI : FormallySmooth S Sₘ := FormallySmooth.of_isLocalization (M.map (algebraMap R S))
  haveI : FormallySmooth R Sₘ := FormallySmooth.comp R S Sₘ
  

Proof state:
R S Rₘ Sₘ : Type u
inst✝¹³ : CommRing R
inst✝¹² : CommRing S
inst✝¹¹ : CommRing Rₘ
inst✝¹⁰ : CommRing Sₘ
M : Submonoid R
inst✝⁹ : Algebra R S
inst✝⁸ : Algebra R Sₘ
inst✝⁷ : Algebra S Sₘ
inst✝⁶ : Algebra R Rₘ
inst✝⁵ : Algebra Rₘ Sₘ
inst✝⁴ : IsScalarTower R Rₘ Sₘ
inst✝³ : IsScalarTower R S Sₘ
inst✝² : IsLocalization M Rₘ
inst✝¹ : IsLocalization (Submonoid.map (algebraMap R S) M) Sₘ
inst✝ : FormallySmooth R S
this✝ : FormallySmooth S Sₘ
this : FormallySmooth R Sₘ
⊢ FormallySmooth Rₘ Sₘ

Next tactic:
exact FormallySmooth.localization_base M
theorem FormallyUnramified.localization_map [FormallyUnramified R S] :
    FormallyUnramified Rₘ Sₘ := by
  

Proof state:
R S Rₘ Sₘ : Type u
inst✝¹³ : CommRing R
inst✝¹² : CommRing S
inst✝¹¹ : CommRing Rₘ
inst✝¹⁰ : CommRing Sₘ
M : Submonoid R
inst✝⁹ : Algebra R S
inst✝⁸ : Algebra R Sₘ
inst✝⁷ : Algebra S Sₘ
inst✝⁶ : Algebra R Rₘ
inst✝⁵ : Algebra Rₘ Sₘ
inst✝⁴ : IsScalarTower R Rₘ Sₘ
inst✝³ : IsScalarTower R S Sₘ
inst✝² : IsLocalization M Rₘ
inst✝¹ : IsLocalization (Submonoid.map (algebraMap R S) M) Sₘ
inst✝ : FormallyUnramified R S
⊢ FormallyUnramified Rₘ Sₘ

Next tactic:
haveI : FormallyUnramified S Sₘ :=
    FormallyUnramified.of_isLocalization (M.map (algebraMap R S))
theorem FormallyUnramified.localization_map [FormallyUnramified R S] :
    FormallyUnramified Rₘ Sₘ := by
  haveI : FormallyUnramified S Sₘ :=
    FormallyUnramified.of_isLocalization (M.map (algebraMap R S))
  

Proof state:
R S Rₘ Sₘ : Type u
inst✝¹³ : CommRing R
inst✝¹² : CommRing S
inst✝¹¹ : CommRing Rₘ
inst✝¹⁰ : CommRing Sₘ
M : Submonoid R
inst✝⁹ : Algebra R S
inst✝⁸ : Algebra R Sₘ
inst✝⁷ : Algebra S Sₘ
inst✝⁶ : Algebra R Rₘ
inst✝⁵ : Algebra Rₘ Sₘ
inst✝⁴ : IsScalarTower R Rₘ Sₘ
inst✝³ : IsScalarTower R S Sₘ
inst✝² : IsLocalization M Rₘ
inst✝¹ : IsLocalization (Submonoid.map (algebraMap R S) M) Sₘ
inst✝ : FormallyUnramified R S
this : FormallyUnramified S Sₘ
⊢ FormallyUnramified Rₘ Sₘ

Next tactic:
haveI : FormallyUnramified R Sₘ := FormallyUnramified.comp R S Sₘ
theorem FormallyUnramified.localization_map [FormallyUnramified R S] :
    FormallyUnramified Rₘ Sₘ := by
  haveI : FormallyUnramified S Sₘ :=
    FormallyUnramified.of_isLocalization (M.map (algebraMap R S))
  haveI : FormallyUnramified R Sₘ := FormallyUnramified.comp R S Sₘ
  

Proof state:
R S Rₘ Sₘ : Type u
inst✝¹³ : CommRing R
inst✝¹² : CommRing S
inst✝¹¹ : CommRing Rₘ
inst✝¹⁰ : CommRing Sₘ
M : Submonoid R
inst✝⁹ : Algebra R S
inst✝⁸ : Algebra R Sₘ
inst✝⁷ : Algebra S Sₘ
inst✝⁶ : Algebra R Rₘ
inst✝⁵ : Algebra Rₘ Sₘ
inst✝⁴ : IsScalarTower R Rₘ Sₘ
inst✝³ : IsScalarTower R S Sₘ
inst✝² : IsLocalization M Rₘ
inst✝¹ : IsLocalization (Submonoid.map (algebraMap R S) M) Sₘ
inst✝ : FormallyUnramified R S
this✝ : FormallyUnramified S Sₘ
this : FormallyUnramified R Sₘ
⊢ FormallyUnramified Rₘ Sₘ

Next tactic:
exact FormallyUnramified.localization_base M
theorem FormallyEtale.localization_map [FormallyEtale R S] : FormallyEtale Rₘ Sₘ := by
  

Proof state:
R S Rₘ Sₘ : Type u
inst✝¹³ : CommRing R
inst✝¹² : CommRing S
inst✝¹¹ : CommRing Rₘ
inst✝¹⁰ : CommRing Sₘ
M : Submonoid R
inst✝⁹ : Algebra R S
inst✝⁸ : Algebra R Sₘ
inst✝⁷ : Algebra S Sₘ
inst✝⁶ : Algebra R Rₘ
inst✝⁵ : Algebra Rₘ Sₘ
inst✝⁴ : IsScalarTower R Rₘ Sₘ
inst✝³ : IsScalarTower R S Sₘ
inst✝² : IsLocalization M Rₘ
inst✝¹ : IsLocalization (Submonoid.map (algebraMap R S) M) Sₘ
inst✝ : FormallyEtale R S
⊢ FormallyEtale Rₘ Sₘ

Next tactic:
haveI : FormallyEtale S Sₘ := FormallyEtale.of_isLocalization (M.map (algebraMap R S))
theorem FormallyEtale.localization_map [FormallyEtale R S] : FormallyEtale Rₘ Sₘ := by
  haveI : FormallyEtale S Sₘ := FormallyEtale.of_isLocalization (M.map (algebraMap R S))
  

Proof state:
R S Rₘ Sₘ : Type u
inst✝¹³ : CommRing R
inst✝¹² : CommRing S
inst✝¹¹ : CommRing Rₘ
inst✝¹⁰ : CommRing Sₘ
M : Submonoid R
inst✝⁹ : Algebra R S
inst✝⁸ : Algebra R Sₘ
inst✝⁷ : Algebra S Sₘ
inst✝⁶ : Algebra R Rₘ
inst✝⁵ : Algebra Rₘ Sₘ
inst✝⁴ : IsScalarTower R Rₘ Sₘ
inst✝³ : IsScalarTower R S Sₘ
inst✝² : IsLocalization M Rₘ
inst✝¹ : IsLocalization (Submonoid.map (algebraMap R S) M) Sₘ
inst✝ : FormallyEtale R S
this : FormallyEtale S Sₘ
⊢ FormallyEtale Rₘ Sₘ

Next tactic:
haveI : FormallyEtale R Sₘ := FormallyEtale.comp R S Sₘ
theorem FormallyEtale.localization_map [FormallyEtale R S] : FormallyEtale Rₘ Sₘ := by
  haveI : FormallyEtale S Sₘ := FormallyEtale.of_isLocalization (M.map (algebraMap R S))
  haveI : FormallyEtale R Sₘ := FormallyEtale.comp R S Sₘ
  

Proof state:
R S Rₘ Sₘ : Type u
inst✝¹³ : CommRing R
inst✝¹² : CommRing S
inst✝¹¹ : CommRing Rₘ
inst✝¹⁰ : CommRing Sₘ
M : Submonoid R
inst✝⁹ : Algebra R S
inst✝⁸ : Algebra R Sₘ
inst✝⁷ : Algebra S Sₘ
inst✝⁶ : Algebra R Rₘ
inst✝⁵ : Algebra Rₘ Sₘ
inst✝⁴ : IsScalarTower R Rₘ Sₘ
inst✝³ : IsScalarTower R S Sₘ
inst✝² : IsLocalization M Rₘ
inst✝¹ : IsLocalization (Submonoid.map (algebraMap R S) M) Sₘ
inst✝ : FormallyEtale R S
this✝ : FormallyEtale S Sₘ
this : FormallyEtale R Sₘ
⊢ FormallyEtale Rₘ Sₘ

Next tactic:
exact FormallyEtale.localization_base M
/-- The natural isomorphism `shortComplexFunctor C c j ≅ shortComplexFunctor' C c i j k`
when `c.prev j = i` and `c.next j = k`. -/
@[simps!]
noncomputable def natIsoSc' (i j k : ι) (hi : c.prev j = i) (hk : c.next j = k) :
    shortComplexFunctor C c j ≅ shortComplexFunctor' C c i j k :=
  NatIso.ofComponents (fun K => ShortComplex.isoMk (K.XIsoOfEq hi) (Iso.refl _) (K.XIsoOfEq hk)
    (by 

Proof state:
C : Type u_1
inst✝¹ : Category.{?u.4947, u_1} C
inst✝ : HasZeroMorphisms C
ι : Type u_2
c : ComplexShape ι
i j k : ι
hi : ComplexShape.prev c j = i
hk : ComplexShape.next c j = k
K : HomologicalComplex C c
⊢ (XIsoOfEq K hi).hom ≫ ((shortComplexFunctor' C c i j k).obj K).f =
    ((shortComplexFunctor C c j).obj K).f ≫ (Iso.refl ((shortComplexFunctor C c j).obj K).X₂).hom

Next tactic:
aesop_cat
/-- The natural isomorphism `shortComplexFunctor C c j ≅ shortComplexFunctor' C c i j k`
when `c.prev j = i` and `c.next j = k`. -/
@[simps!]
noncomputable def natIsoSc' (i j k : ι) (hi : c.prev j = i) (hk : c.next j = k) :
    shortComplexFunctor C c j ≅ shortComplexFunctor' C c i j k :=
  NatIso.ofComponents (fun K => ShortComplex.isoMk (K.XIsoOfEq hi) (Iso.refl _) (K.XIsoOfEq hk)
    (by aesop_cat) (by 

Proof state:
C : Type u_1
inst✝¹ : Category.{?u.4947, u_1} C
inst✝ : HasZeroMorphisms C
ι : Type u_2
c : ComplexShape ι
i j k : ι
hi : ComplexShape.prev c j = i
hk : ComplexShape.next c j = k
K : HomologicalComplex C c
⊢ (Iso.refl ((shortComplexFunctor C c j).obj K).X₂).hom ≫ ((shortComplexFunctor' C c i j k).obj K).g =
    ((shortComplexFunctor C c j).obj K).g ≫ (XIsoOfEq K hk).hom

Next tactic:
aesop_cat
/-- The natural isomorphism `shortComplexFunctor C c j ≅ shortComplexFunctor' C c i j k`
when `c.prev j = i` and `c.next j = k`. -/
@[simps!]
noncomputable def natIsoSc' (i j k : ι) (hi : c.prev j = i) (hk : c.next j = k) :
    shortComplexFunctor C c j ≅ shortComplexFunctor' C c i j k :=
  NatIso.ofComponents (fun K => ShortComplex.isoMk (K.XIsoOfEq hi) (Iso.refl _) (K.XIsoOfEq hk)
    (by aesop_cat) (by aesop_cat)) (by 

Proof state:
C : Type u_1
inst✝¹ : Category.{?u.4947, u_1} C
inst✝ : HasZeroMorphisms C
ι : Type u_2
c : ComplexShape ι
i j k : ι
hi : ComplexShape.prev c j = i
hk : ComplexShape.next c j = k
⊢ ∀ {X Y : HomologicalComplex C c} (f : X ⟶ Y),
    (shortComplexFunctor C c j).map f ≫
        ((fun K => ShortComplex.isoMk (XIsoOfEq K hi) (Iso.refl ((shortComplexFunctor C c j).obj K).X₂) (XIsoOfEq K hk))
            Y).hom =
      ((fun K => ShortComplex.isoMk (XIsoOfEq K hi) (Iso.refl ((shortComplexFunctor C c j).obj K).X₂) (XIsoOfEq K hk))
            X).hom ≫
        (shortComplexFunctor' C c i j k).map f

Next tactic:
aesop_cat
/-- The morphism to `K.cycles i` that is induced by a "cycle", i.e. a morphism
to `K.X i` whose postcomposition with the differential is zero. -/
noncomputable def liftCycles {A : C} (k : A ⟶ K.X i) (j : ι) (hj : c.next i = j)
    (hk : k ≫ K.d i j = 0) : A ⟶ K.cycles i :=
  (K.sc i).liftCycles k (by 

Proof state:
C : Type u_1
inst✝² : Category.{?u.20172, u_1} C
inst✝¹ : HasZeroMorphisms C
ι : Type u_2
c : ComplexShape ι
K L M : HomologicalComplex C c
φ : K ⟶ L
ψ : L ⟶ M
i j✝ k✝ : ι
inst✝ : HasHomology K i
A : C
k : A ⟶ X K i
j : ι
hj : ComplexShape.next c i = j
hk : k ≫ d K i j = 0
⊢ k ≫ (sc K i).g = 0

Next tactic:
subst hj
/-- The morphism to `K.cycles i` that is induced by a "cycle", i.e. a morphism
to `K.X i` whose postcomposition with the differential is zero. -/
noncomputable def liftCycles {A : C} (k : A ⟶ K.X i) (j : ι) (hj : c.next i = j)
    (hk : k ≫ K.d i j = 0) : A ⟶ K.cycles i :=
  (K.sc i).liftCycles k (by subst hj; 

Proof state:
C : Type u_1
inst✝² : Category.{?u.20172, u_1} C
inst✝¹ : HasZeroMorphisms C
ι : Type u_2
c : ComplexShape ι
K L M : HomologicalComplex C c
φ : K ⟶ L
ψ : L ⟶ M
i j k✝ : ι
inst✝ : HasHomology K i
A : C
k : A ⟶ X K i
hk : k ≫ d K i (ComplexShape.next c i) = 0
⊢ k ≫ (sc K i).g = 0

Next tactic:
exact hk
@[reassoc (attr := simp)]
lemma liftCycles_i {A : C} (k : A ⟶ K.X i) (j : ι) (hj : c.next i = j)
    (hk : k ≫ K.d i j = 0) : K.liftCycles k j hj hk ≫ K.iCycles i = k := by
  

Proof state:
C : Type u_1
inst✝² : Category.{u_3, u_1} C
inst✝¹ : HasZeroMorphisms C
ι : Type u_2
c : ComplexShape ι
K L M : HomologicalComplex C c
φ : K ⟶ L
ψ : L ⟶ M
i j✝ k✝ : ι
inst✝ : HasHomology K i
A : C
k : A ⟶ X K i
j : ι
hj : ComplexShape.next c i = j
hk : k ≫ d K i j = 0
⊢ liftCycles K k j hj hk ≫ iCycles K i = k

Next tactic:
dsimp [liftCycles, iCycles]
@[reassoc (attr := simp)]
lemma liftCycles_i {A : C} (k : A ⟶ K.X i) (j : ι) (hj : c.next i = j)
    (hk : k ≫ K.d i j = 0) : K.liftCycles k j hj hk ≫ K.iCycles i = k := by
  dsimp [liftCycles, iCycles]
  

Proof state:
C : Type u_1
inst✝² : Category.{u_3, u_1} C
inst✝¹ : HasZeroMorphisms C
ι : Type u_2
c : ComplexShape ι
K L M : HomologicalComplex C c
φ : K ⟶ L
ψ : L ⟶ M
i j✝ k✝ : ι
inst✝ : HasHomology K i
A : C
k : A ⟶ X K i
j : ι
hj : ComplexShape.next c i = j
hk : k ≫ d K i j = 0
⊢ ShortComplex.liftCycles (sc K i) k (_ : k ≫ (sc K i).g = 0) ≫ ShortComplex.iCycles (sc K i) = k

Next tactic:
simp
@[reassoc (attr := simp)]
lemma iCycles_d : K.iCycles i ≫ K.d i j = 0 := by
  

Proof state:
C : Type u_1
inst✝² : Category.{u_3, u_1} C
inst✝¹ : HasZeroMorphisms C
ι : Type u_2
c : ComplexShape ι
K L M : HomologicalComplex C c
φ : K ⟶ L
ψ : L ⟶ M
i j k : ι
inst✝ : HasHomology K i
⊢ iCycles K i ≫ d K i j = 0

Next tactic:
by_cases hij : c.Rel i j
@[reassoc (attr := simp)]
lemma iCycles_d : K.iCycles i ≫ K.d i j = 0 := by
  by_cases hij : c.Rel i j
  · 

Proof state:
case pos
C : Type u_1
inst✝² : Category.{u_3, u_1} C
inst✝¹ : HasZeroMorphisms C
ι : Type u_2
c : ComplexShape ι
K L M : HomologicalComplex C c
φ : K ⟶ L
ψ : L ⟶ M
i j k : ι
inst✝ : HasHomology K i
hij : ComplexShape.Rel c i j
⊢ iCycles K i ≫ d K i j = 0

Next tactic:
obtain rfl := c.next_eq' hij
@[reassoc (attr := simp)]
lemma iCycles_d : K.iCycles i ≫ K.d i j = 0 := by
  by_cases hij : c.Rel i j
  · obtain rfl := c.next_eq' hij
    

Proof state:
case pos
C : Type u_1
inst✝² : Category.{u_3, u_1} C
inst✝¹ : HasZeroMorphisms C
ι : Type u_2
c : ComplexShape ι
K L M : HomologicalComplex C c
φ : K ⟶ L
ψ : L ⟶ M
i k : ι
inst✝ : HasHomology K i
hij : ComplexShape.Rel c i (ComplexShape.next c i)
⊢ iCycles K i ≫ d K i (ComplexShape.next c i) = 0

Next tactic:
exact (K.sc i).iCycles_g
@[reassoc (attr := simp)]
lemma iCycles_d : K.iCycles i ≫ K.d i j = 0 := by
  by_cases hij : c.Rel i j
  · obtain rfl := c.next_eq' hij
    exact (K.sc i).iCycles_g
  · 

Proof state:
case neg
C : Type u_1
inst✝² : Category.{u_3, u_1} C
inst✝¹ : HasZeroMorphisms C
ι : Type u_2
c : ComplexShape ι
K L M : HomologicalComplex C c
φ : K ⟶ L
ψ : L ⟶ M
i j k : ι
inst✝ : HasHomology K i
hij : ¬ComplexShape.Rel c i j
⊢ iCycles K i ≫ d K i j = 0

Next tactic:
rw [K.shape _ _ hij, comp_zero]
/-- `K.cycles i` is the kernel of `K.d i j` when `c.next i = j`. -/
noncomputable def cyclesIsKernel (hj : c.next i = j) :
    IsLimit (KernelFork.ofι (K.iCycles i) (K.iCycles_d i j)) := by
  

Proof state:
C : Type u_1
inst✝² : Category.{?u.25061, u_1} C
inst✝¹ : HasZeroMorphisms C
ι : Type u_2
c : ComplexShape ι
K L M : HomologicalComplex C c
φ : K ⟶ L
ψ : L ⟶ M
i j k : ι
inst✝ : HasHomology K i
hj : ComplexShape.next c i = j
⊢ IsLimit (KernelFork.ofι (iCycles K i) (_ : iCycles K i ≫ d K i j = 0))

Next tactic:
obtain rfl := hj
/-- `K.cycles i` is the kernel of `K.d i j` when `c.next i = j`. -/
noncomputable def cyclesIsKernel (hj : c.next i = j) :
    IsLimit (KernelFork.ofι (K.iCycles i) (K.iCycles_d i j)) := by
  obtain rfl := hj
  

Proof state:
C : Type u_1
inst✝² : Category.{?u.25061, u_1} C
inst✝¹ : HasZeroMorphisms C
ι : Type u_2
c : ComplexShape ι
K L M : HomologicalComplex C c
φ : K ⟶ L
ψ : L ⟶ M
i k : ι
inst✝ : HasHomology K i
⊢ IsLimit (KernelFork.ofι (iCycles K i) (_ : iCycles K i ≫ d K i (ComplexShape.next c i) = 0))

Next tactic:
exact (K.sc i).cyclesIsKernel
instance : Mono (K.iCycles i) := by
  

Proof state:
C : Type u_1
inst✝² : Category.{?u.27219, u_1} C
inst✝¹ : HasZeroMorphisms C
ι : Type u_2
c : ComplexShape ι
K L M : HomologicalComplex C c
φ : K ⟶ L
ψ : L ⟶ M
i j k : ι
inst✝ : HasHomology K i
⊢ Mono (iCycles K i)

Next tactic:
dsimp only [iCycles]
instance : Mono (K.iCycles i) := by
  dsimp only [iCycles]
  

Proof state:
C : Type u_1
inst✝² : Category.{?u.27219, u_1} C
inst✝¹ : HasZeroMorphisms C
ι : Type u_2
c : ComplexShape ι
K L M : HomologicalComplex C c
φ : K ⟶ L
ψ : L ⟶ M
i j k : ι
inst✝ : HasHomology K i
⊢ Mono (ShortComplex.iCycles (sc K i))

Next tactic:
infer_instance
instance : Epi (K.homologyπ i) := by
  

Proof state:
C : Type u_1
inst✝² : Category.{?u.27823, u_1} C
inst✝¹ : HasZeroMorphisms C
ι : Type u_2
c : ComplexShape ι
K L M : HomologicalComplex C c
φ : K ⟶ L
ψ : L ⟶ M
i j k : ι
inst✝ : HasHomology K i
⊢ Epi (homologyπ K i)

Next tactic:
dsimp only [homologyπ]
instance : Epi (K.homologyπ i) := by
  dsimp only [homologyπ]
  

Proof state:
C : Type u_1
inst✝² : Category.{?u.27823, u_1} C
inst✝¹ : HasZeroMorphisms C
ι : Type u_2
c : ComplexShape ι
K L M : HomologicalComplex C c
φ : K ⟶ L
ψ : L ⟶ M
i j k : ι
inst✝ : HasHomology K i
⊢ Epi (ShortComplex.homologyπ (sc K i))

Next tactic:
infer_instance
@[reassoc (attr := simp)]
lemma d_toCycles [K.HasHomology k] :
    K.d i j ≫ K.toCycles j k = 0 := by
  

Proof state:
C : Type u_1
inst✝³ : Category.{u_3, u_1} C
inst✝² : HasZeroMorphisms C
ι : Type u_2
c : ComplexShape ι
K L M : HomologicalComplex C c
φ : K ⟶ L
ψ : L ⟶ M
i j k : ι
inst✝¹ : HasHomology K i
inst✝ : HasHomology K k
⊢ d K i j ≫ toCycles K j k = 0

Next tactic:
simp only [← cancel_mono (K.iCycles k), assoc, toCycles_i, d_comp_d, zero_comp]
@[reassoc]
lemma comp_liftCycles {A' A : C} (k : A ⟶ K.X i) (j : ι) (hj : c.next i = j)
    (hk : k ≫ K.d i j = 0) (α : A' ⟶ A) :
    α ≫ K.liftCycles k j hj hk = K.liftCycles (α ≫ k) j hj (by 

Proof state:
C : Type u_1
inst✝² : Category.{?u.30124, u_1} C
inst✝¹ : HasZeroMorphisms C
ι : Type u_2
c : ComplexShape ι
K L M : HomologicalComplex C c
φ : K ⟶ L
ψ : L ⟶ M
i j✝ k✝ : ι
inst✝ : HasHomology K i
A' A : C
k : A ⟶ X K i
j : ι
hj : ComplexShape.next c i = j
hk : k ≫ d K i j = 0
α : A' ⟶ A
⊢ (α ≫ k) ≫ d K i j = 0

Next tactic:
rw [assoc, hk, comp_zero]
@[reassoc]
lemma comp_liftCycles {A' A : C} (k : A ⟶ K.X i) (j : ι) (hj : c.next i = j)
    (hk : k ≫ K.d i j = 0) (α : A' ⟶ A) :
    α ≫ K.liftCycles k j hj hk = K.liftCycles (α ≫ k) j hj (by rw [assoc, hk, comp_zero]) := by
  

Proof state:
C : Type u_1
inst✝² : Category.{u_3, u_1} C
inst✝¹ : HasZeroMorphisms C
ι : Type u_2
c : ComplexShape ι
K L M : HomologicalComplex C c
φ : K ⟶ L
ψ : L ⟶ M
i j✝ k✝ : ι
inst✝ : HasHomology K i
A' A : C
k : A ⟶ X K i
j : ι
hj : ComplexShape.next c i = j
hk : k ≫ d K i j = 0
α : A' ⟶ A
⊢ α ≫ liftCycles K k j hj hk = liftCycles K (α ≫ k) j hj (_ : (α ≫ k) ≫ d K i j = 0)

Next tactic:
simp only [← cancel_mono (K.iCycles i), assoc, liftCycles_i]
@[reassoc]
lemma liftCycles_homologyπ_eq_zero_of_boundary {A : C} (k : A ⟶ K.X i) (j : ι)
    (hj : c.next i = j) {i' : ι} (x : A ⟶ K.X i') (hx : k = x ≫ K.d i' i) :
    K.liftCycles k j hj (by 

Proof state:
C : Type u_1
inst✝² : Category.{?u.32464, u_1} C
inst✝¹ : HasZeroMorphisms C
ι : Type u_2
c : ComplexShape ι
K L M : HomologicalComplex C c
φ : K ⟶ L
ψ : L ⟶ M
i j✝ k✝ : ι
inst✝ : HasHomology K i
A : C
k : A ⟶ X K i
j : ι
hj : ComplexShape.next c i = j
i' : ι
x : A ⟶ X K i'
hx : k = x ≫ d K i' i
⊢ k ≫ d K i j = 0

Next tactic:
rw [hx, assoc, K.d_comp_d, comp_zero]
@[reassoc]
lemma liftCycles_homologyπ_eq_zero_of_boundary {A : C} (k : A ⟶ K.X i) (j : ι)
    (hj : c.next i = j) {i' : ι} (x : A ⟶ K.X i') (hx : k = x ≫ K.d i' i) :
    K.liftCycles k j hj (by rw [hx, assoc, K.d_comp_d, comp_zero]) ≫ K.homologyπ i = 0 := by
  

Proof state:
C : Type u_1
inst✝² : Category.{u_3, u_1} C
inst✝¹ : HasZeroMorphisms C
ι : Type u_2
c : ComplexShape ι
K L M : HomologicalComplex C c
φ : K ⟶ L
ψ : L ⟶ M
i j✝ k✝ : ι
inst✝ : HasHomology K i
A : C
k : A ⟶ X K i
j : ι
hj : ComplexShape.next c i = j
i' : ι
x : A ⟶ X K i'
hx : k = x ≫ d K i' i
⊢ liftCycles K k j hj (_ : k ≫ d K i j = 0) ≫ homologyπ K i = 0

Next tactic:
by_cases h : c.Rel i' i