l3lab/ntp-mathlib huggingface dataset:
lemma δ_neg_one_cochain (z : Cochain F G (-1)) :
    δ (-1) 0 z = Cochain.ofHom (Homotopy.nullHomotopicMap'
      (fun i j hij => z.v i j (by dsimp at hij; rw [← hij, add_neg_cancel_right]))) := by
  ext p
  rw [δ_v (-1) 0 (neg_add_self 1) _ p p (add_zero p) (p-1) (p+1) rfl rfl]
  simp only [neg_add_self, one_smul, Cochain.ofHom_v, Int.negOnePow_zero]
  rw [Homotopy.nullHomotopicMap'_f (show (ComplexShape.up ℤ).Rel (p-1) p by simp)
    (show (ComplexShape.up ℤ).Rel p (p+1) by 

Proof state:
C : Type u
inst✝³ : Category.{v, u} C
inst✝² : Preadditive C
R : Type u_1
inst✝¹ : Ring R
inst✝ : Linear R C
F G K L : CochainComplex C ℤ
n m : ℤ
z : Cochain F G (-1)
p : ℤ
⊢ ComplexShape.Rel (ComplexShape.up ℤ) p (p + 1)

Next tactic:
simp
lemma δ_neg_one_cochain (z : Cochain F G (-1)) :
    δ (-1) 0 z = Cochain.ofHom (Homotopy.nullHomotopicMap'
      (fun i j hij => z.v i j (by dsimp at hij; rw [← hij, add_neg_cancel_right]))) := by
  ext p
  rw [δ_v (-1) 0 (neg_add_self 1) _ p p (add_zero p) (p-1) (p+1) rfl rfl]
  simp only [neg_add_self, one_smul, Cochain.ofHom_v, Int.negOnePow_zero]
  rw [Homotopy.nullHomotopicMap'_f (show (ComplexShape.up ℤ).Rel (p-1) p by simp)
    (show (ComplexShape.up ℤ).Rel p (p+1) by simp)]
  

Proof state:
case h
C : Type u
inst✝³ : Category.{v, u} C
inst✝² : Preadditive C
R : Type u_1
inst✝¹ : Ring R
inst✝ : Linear R C
F G K L : CochainComplex C ℤ
n m : ℤ
z : Cochain F G (-1)
p : ℤ
⊢ z.v p (p - 1) (_ : p + -1 = p - 1) ≫ HomologicalComplex.d G (p - 1) p +
      HomologicalComplex.d F p (p + 1) ≫ z.v (p + 1) p (_ : p + 1 + -1 = p) =
    HomologicalComplex.d F p (p + 1) ≫ z.v (p + 1) p (_ : p + 1 + -1 = p) +
      z.v p (p - 1) (_ : p + -1 = p - 1) ≫ HomologicalComplex.d G (p - 1) p

Next tactic:
abel
/-- The cochain complex of homomorphisms between two cochain complexes `F` and `G`.
In degree `n : ℤ`, it consists of the abelian group `HomComplex.Cochain F G n`. -/
@[simps! X d_apply]
def HomComplex : CochainComplex AddCommGroupCat ℤ where
  X i := AddCommGroupCat.of (Cochain F G i)
  d i j := AddCommGroupCat.ofHom (δ_hom ℤ F G i j)
  shape _ _ hij := by 

Proof state:
C : Type u
inst✝³ : Category.{v, u} C
inst✝² : Preadditive C
R : Type u_1
inst✝¹ : Ring R
inst✝ : Linear R C
F G K L : CochainComplex C ℤ
n m x✝¹ x✝ : ℤ
hij : ¬ComplexShape.Rel (ComplexShape.up ℤ) x✝¹ x✝
⊢ (fun i j => AddCommGroupCat.ofHom ↑(δ_hom ℤ F G i j)) x✝¹ x✝ = 0

Next tactic:
ext
/-- The cochain complex of homomorphisms between two cochain complexes `F` and `G`.
In degree `n : ℤ`, it consists of the abelian group `HomComplex.Cochain F G n`. -/
@[simps! X d_apply]
def HomComplex : CochainComplex AddCommGroupCat ℤ where
  X i := AddCommGroupCat.of (Cochain F G i)
  d i j := AddCommGroupCat.ofHom (δ_hom ℤ F G i j)
  shape _ _ hij := by ext; 

Proof state:
case w
C : Type u
inst✝³ : Category.{v, u} C
inst✝² : Preadditive C
R : Type u_1
inst✝¹ : Ring R
inst✝ : Linear R C
F G K L : CochainComplex C ℤ
n m x✝² x✝¹ : ℤ
hij : ¬ComplexShape.Rel (ComplexShape.up ℤ) x✝² x✝¹
x✝ : ↑(AddCommGroupCat.of (Cochain F G x✝²))
⊢ ((fun i j => AddCommGroupCat.ofHom ↑(δ_hom ℤ F G i j)) x✝² x✝¹) x✝ = 0 x✝

Next tactic:
apply δ_shape _ _ hij
/-- The cochain complex of homomorphisms between two cochain complexes `F` and `G`.
In degree `n : ℤ`, it consists of the abelian group `HomComplex.Cochain F G n`. -/
@[simps! X d_apply]
def HomComplex : CochainComplex AddCommGroupCat ℤ where
  X i := AddCommGroupCat.of (Cochain F G i)
  d i j := AddCommGroupCat.ofHom (δ_hom ℤ F G i j)
  shape _ _ hij := by ext; apply δ_shape _ _ hij
  d_comp_d' _ _ _ _ _  := by 

Proof state:
C : Type u
inst✝³ : Category.{v, u} C
inst✝² : Preadditive C
R : Type u_1
inst✝¹ : Ring R
inst✝ : Linear R C
F G K L : CochainComplex C ℤ
n m x✝⁴ x✝³ x✝² : ℤ
x✝¹ : ComplexShape.Rel (ComplexShape.up ℤ) x✝⁴ x✝³
x✝ : ComplexShape.Rel (ComplexShape.up ℤ) x✝³ x✝²
⊢ (fun i j => AddCommGroupCat.ofHom ↑(δ_hom ℤ F G i j)) x✝⁴ x✝³ ≫
      (fun i j => AddCommGroupCat.ofHom ↑(δ_hom ℤ F G i j)) x✝³ x✝² =
    0

Next tactic:
ext
/-- The cochain complex of homomorphisms between two cochain complexes `F` and `G`.
In degree `n : ℤ`, it consists of the abelian group `HomComplex.Cochain F G n`. -/
@[simps! X d_apply]
def HomComplex : CochainComplex AddCommGroupCat ℤ where
  X i := AddCommGroupCat.of (Cochain F G i)
  d i j := AddCommGroupCat.ofHom (δ_hom ℤ F G i j)
  shape _ _ hij := by ext; apply δ_shape _ _ hij
  d_comp_d' _ _ _ _ _  := by ext; 

Proof state:
case w
C : Type u
inst✝³ : Category.{v, u} C
inst✝² : Preadditive C
R : Type u_1
inst✝¹ : Ring R
inst✝ : Linear R C
F G K L : CochainComplex C ℤ
n m x✝⁵ x✝⁴ x✝³ : ℤ
x✝² : ComplexShape.Rel (ComplexShape.up ℤ) x✝⁵ x✝⁴
x✝¹ : ComplexShape.Rel (ComplexShape.up ℤ) x✝⁴ x✝³
x✝ : ↑((fun i => AddCommGroupCat.of (Cochain F G i)) x✝⁵)
⊢ ((fun i j => AddCommGroupCat.ofHom ↑(δ_hom ℤ F G i j)) x✝⁵ x✝⁴ ≫
        (fun i j => AddCommGroupCat.ofHom ↑(δ_hom ℤ F G i j)) x✝⁴ x✝³)
      x✝ =
    0 x✝

Next tactic:
apply δ_δ
instance : AddCommGroup (Cocycle F G n) := by
  

Proof state:
C : Type u
inst✝³ : Category.{v, u} C
inst✝² : Preadditive C
R : Type u_1
inst✝¹ : Ring R
inst✝ : Linear R C
F G K L : CochainComplex C ℤ
n m : ℤ
⊢ AddCommGroup (Cocycle F G n)

Next tactic:
dsimp only [Cocycle]
instance : AddCommGroup (Cocycle F G n) := by
  dsimp only [Cocycle]
  

Proof state:
C : Type u
inst✝³ : Category.{v, u} C
inst✝² : Preadditive C
R : Type u_1
inst✝¹ : Ring R
inst✝ : Linear R C
F G K L : CochainComplex C ℤ
n m : ℤ
⊢ AddCommGroup ↥(cocycle F G n)

Next tactic:
infer_instance
lemma mem_iff (hnm : n + 1 = m) (z : Cochain F G n) :
    z ∈ cocycle F G n ↔ δ n m z = 0 := by 

Proof state:
C : Type u
inst✝³ : Category.{v, u} C
inst✝² : Preadditive C
R : Type u_1
inst✝¹ : Ring R
inst✝ : Linear R C
F G K L : CochainComplex C ℤ
n m : ℤ
hnm : n + 1 = m
z : Cochain F G n
⊢ z ∈ cocycle F G n ↔ δ n m z = 0

Next tactic:
subst hnm
lemma mem_iff (hnm : n + 1 = m) (z : Cochain F G n) :
    z ∈ cocycle F G n ↔ δ n m z = 0 := by subst hnm; 

Proof state:
C : Type u
inst✝³ : Category.{v, u} C
inst✝² : Preadditive C
R : Type u_1
inst✝¹ : Ring R
inst✝ : Linear R C
F G K L : CochainComplex C ℤ
n : ℤ
z : Cochain F G n
⊢ z ∈ cocycle F G n ↔ δ n (n + 1) z = 0

Next tactic:
rfl
instance : SMul R (Cocycle F G n) where
  smul r z := ⟨r • z.1, by
    

Proof state:
C : Type u
inst✝³ : Category.{v, u} C
inst✝² : Preadditive C
R : Type u_1
inst✝¹ : Ring R
inst✝ : Linear R C
F G K L : CochainComplex C ℤ
n m : ℤ
r : R
z : Cocycle F G n
⊢ r • ↑z ∈ cocycle F G n

Next tactic:
have hz := z.2
instance : SMul R (Cocycle F G n) where
  smul r z := ⟨r • z.1, by
    have hz := z.2
    

Proof state:
C : Type u
inst✝³ : Category.{v, u} C
inst✝² : Preadditive C
R : Type u_1
inst✝¹ : Ring R
inst✝ : Linear R C
F G K L : CochainComplex C ℤ
n m : ℤ
r : R
z : Cocycle F G n
hz : ↑z ∈ cocycle F G n
⊢ r • ↑z ∈ cocycle F G n

Next tactic:
rw [mem_iff n (n + 1) rfl] at hz ⊢
instance : SMul R (Cocycle F G n) where
  smul r z := ⟨r • z.1, by
    have hz := z.2
    rw [mem_iff n (n + 1) rfl] at hz ⊢
    

Proof state:
C : Type u
inst✝³ : Category.{v, u} C
inst✝² : Preadditive C
R : Type u_1
inst✝¹ : Ring R
inst✝ : Linear R C
F G K L : CochainComplex C ℤ
n m : ℤ
r : R
z : Cocycle F G n
hz : δ n (n + 1) ↑z = 0
⊢ δ n (n + 1) (r • ↑z) = 0

Next tactic:
simp only [δ_smul, hz, smul_zero]
@[simp]
lemma coe_zero : (↑(0 : Cocycle F G n) : Cochain F G n) = 0 := by 

Proof state:
C : Type u
inst✝³ : Category.{v, u} C
inst✝² : Preadditive C
R : Type u_1
inst✝¹ : Ring R
inst✝ : Linear R C
F G K L : CochainComplex C ℤ
n m : ℤ
⊢ ↑0 = 0

Next tactic:
rfl
instance : Module R (Cocycle F G n) where
  one_smul _ := by 

Proof state:
C : Type u
inst✝³ : Category.{v, u} C
inst✝² : Preadditive C
R : Type u_1
inst✝¹ : Ring R
inst✝ : Linear R C
F G K L : CochainComplex C ℤ
n m : ℤ
x✝ : Cocycle F G n
⊢ 1 • x✝ = x✝

Next tactic:
aesop
instance : Module R (Cocycle F G n) where
  one_smul _ := by aesop
  mul_smul _ _ _ := by 

Proof state:
C : Type u
inst✝³ : Category.{v, u} C
inst✝² : Preadditive C
R : Type u_1
inst✝¹ : Ring R
inst✝ : Linear R C
F G K L : CochainComplex C ℤ
n m : ℤ
x✝² x✝¹ : R
x✝ : Cocycle F G n
⊢ (x✝² * x✝¹) • x✝ = x✝² • x✝¹ • x✝

Next tactic:
ext
instance : Module R (Cocycle F G n) where
  one_smul _ := by aesop
  mul_smul _ _ _ := by ext; 

Proof state:
case h.h
C : Type u
inst✝³ : Category.{v, u} C
inst✝² : Preadditive C
R : Type u_1
inst✝¹ : Ring R
inst✝ : Linear R C
F G K L : CochainComplex C ℤ
n m : ℤ
x✝² x✝¹ : R
x✝ : Cocycle F G n
p✝ q✝ : ℤ
hpq✝ : p✝ + n = q✝
⊢ (↑((x✝² * x✝¹) • x✝)).v p✝ q✝ hpq✝ = (↑(x✝² • x✝¹ • x✝)).v p✝ q✝ hpq✝

Next tactic:
dsimp
instance : Module R (Cocycle F G n) where
  one_smul _ := by aesop
  mul_smul _ _ _ := by ext; dsimp; 

Proof state:
case h.h
C : Type u
inst✝³ : Category.{v, u} C
inst✝² : Preadditive C
R : Type u_1
inst✝¹ : Ring R
inst✝ : Linear R C
F G K L : CochainComplex C ℤ
n m : ℤ
x✝² x✝¹ : R
x✝ : Cocycle F G n
p✝ q✝ : ℤ
hpq✝ : p✝ + n = q✝
⊢ (x✝² * x✝¹) • (↑x✝).v p✝ q✝ hpq✝ = x✝² • x✝¹ • (↑x✝).v p✝ q✝ hpq✝

Next tactic:
rw [smul_smul]
instance : Module R (Cocycle F G n) where
  one_smul _ := by aesop
  mul_smul _ _ _ := by ext; dsimp; rw [smul_smul]
  smul_zero _ := by 

Proof state:
C : Type u
inst✝³ : Category.{v, u} C
inst✝² : Preadditive C
R : Type u_1
inst✝¹ : Ring R
inst✝ : Linear R C
F G K L : CochainComplex C ℤ
n m : ℤ
x✝ : R
⊢ x✝ • 0 = 0

Next tactic:
aesop
instance : Module R (Cocycle F G n) where
  one_smul _ := by aesop
  mul_smul _ _ _ := by ext; dsimp; rw [smul_smul]
  smul_zero _ := by aesop
  smul_add _ _ _ := by 

Proof state:
C : Type u
inst✝³ : Category.{v, u} C
inst✝² : Preadditive C
R : Type u_1
inst✝¹ : Ring R
inst✝ : Linear R C
F G K L : CochainComplex C ℤ
n m : ℤ
x✝² : R
x✝¹ x✝ : Cocycle F G n
⊢ x✝² • (x✝¹ + x✝) = x✝² • x✝¹ + x✝² • x✝

Next tactic:
aesop
instance : Module R (Cocycle F G n) where
  one_smul _ := by aesop
  mul_smul _ _ _ := by ext; dsimp; rw [smul_smul]
  smul_zero _ := by aesop
  smul_add _ _ _ := by aesop
  add_smul _ _ _ := by 

Proof state:
C : Type u
inst✝³ : Category.{v, u} C
inst✝² : Preadditive C
R : Type u_1
inst✝¹ : Ring R
inst✝ : Linear R C
F G K L : CochainComplex C ℤ
n m : ℤ
x✝² x✝¹ : R
x✝ : Cocycle F G n
⊢ (x✝² + x✝¹) • x✝ = x✝² • x✝ + x✝¹ • x✝

Next tactic:
ext
instance : Module R (Cocycle F G n) where
  one_smul _ := by aesop
  mul_smul _ _ _ := by ext; dsimp; rw [smul_smul]
  smul_zero _ := by aesop
  smul_add _ _ _ := by aesop
  add_smul _ _ _ := by ext; 

Proof state:
case h.h
C : Type u
inst✝³ : Category.{v, u} C
inst✝² : Preadditive C
R : Type u_1
inst✝¹ : Ring R
inst✝ : Linear R C
F G K L : CochainComplex C ℤ
n m : ℤ
x✝² x✝¹ : R
x✝ : Cocycle F G n
p✝ q✝ : ℤ
hpq✝ : p✝ + n = q✝
⊢ (↑((x✝² + x✝¹) • x✝)).v p✝ q✝ hpq✝ = (↑(x✝² • x✝ + x✝¹ • x✝)).v p✝ q✝ hpq✝

Next tactic:
dsimp
instance : Module R (Cocycle F G n) where
  one_smul _ := by aesop
  mul_smul _ _ _ := by ext; dsimp; rw [smul_smul]
  smul_zero _ := by aesop
  smul_add _ _ _ := by aesop
  add_smul _ _ _ := by ext; dsimp; 

Proof state:
case h.h
C : Type u
inst✝³ : Category.{v, u} C
inst✝² : Preadditive C
R : Type u_1
inst✝¹ : Ring R
inst✝ : Linear R C
F G K L : CochainComplex C ℤ
n m : ℤ
x✝² x✝¹ : R
x✝ : Cocycle F G n
p✝ q✝ : ℤ
hpq✝ : p✝ + n = q✝
⊢ (x✝² + x✝¹) • (↑x✝).v p✝ q✝ hpq✝ = x✝² • (↑x✝).v p✝ q✝ hpq✝ + x✝¹ • (↑x✝).v p✝ q✝ hpq✝

Next tactic:
rw [add_smul]
instance : Module R (Cocycle F G n) where
  one_smul _ := by aesop
  mul_smul _ _ _ := by ext; dsimp; rw [smul_smul]
  smul_zero _ := by aesop
  smul_add _ _ _ := by aesop
  add_smul _ _ _ := by ext; dsimp; rw [add_smul]
  zero_smul := by 

Proof state:
C : Type u
inst✝³ : Category.{v, u} C
inst✝² : Preadditive C
R : Type u_1
inst✝¹ : Ring R
inst✝ : Linear R C
F G K L : CochainComplex C ℤ
n m : ℤ
⊢ ∀ (x : Cocycle F G n), 0 • x = 0

Next tactic:
aesop
/-- Constructor for `Cocycle F G n`, taking as inputs `z : Cochain F G n`, an integer
`m : ℤ` such that `n + 1 = m`, and the relation `δ n m z = 0`. -/
@[simps]
def mk (z : Cochain F G n) (m : ℤ) (hnm : n + 1 = m) (h : δ n m z = 0) : Cocycle F G n :=
  ⟨z, by 

Proof state:
C : Type u
inst✝³ : Category.{v, u} C
inst✝² : Preadditive C
R : Type u_1
inst✝¹ : Ring R
inst✝ : Linear R C
F G K L : CochainComplex C ℤ
n m✝ : ℤ
z : Cochain F G n
m : ℤ
hnm : n + 1 = m
h : δ n m z = 0
⊢ z ∈ cocycle F G n

Next tactic:
simpa only [mem_iff n m hnm z] using h
@[simp]
lemma δ_eq_zero {n : ℤ} (z : Cocycle F G n) (m : ℤ) : δ n m (z : Cochain F G n) = 0 := by
  

Proof state:
C : Type u
inst✝³ : Category.{v, u} C
inst✝² : Preadditive C
R : Type u_1
inst✝¹ : Ring R
inst✝ : Linear R C
F G K L : CochainComplex C ℤ
n✝ m✝ n : ℤ
z : Cocycle F G n
m : ℤ
⊢ δ n m ↑z = 0

Next tactic:
by_cases h : n + 1 = m
@[simp]
lemma δ_eq_zero {n : ℤ} (z : Cocycle F G n) (m : ℤ) : δ n m (z : Cochain F G n) = 0 := by
  by_cases h : n + 1 = m
  · 

Proof state:
case pos
C : Type u
inst✝³ : Category.{v, u} C
inst✝² : Preadditive C
R : Type u_1
inst✝¹ : Ring R
inst✝ : Linear R C
F G K L : CochainComplex C ℤ
n✝ m✝ n : ℤ
z : Cocycle F G n
m : ℤ
h : n + 1 = m
⊢ δ n m ↑z = 0

Next tactic:
rw [← mem_iff n m h]
@[simp]
lemma δ_eq_zero {n : ℤ} (z : Cocycle F G n) (m : ℤ) : δ n m (z : Cochain F G n) = 0 := by
  by_cases h : n + 1 = m
  · rw [← mem_iff n m h]
    

Proof state:
case pos
C : Type u
inst✝³ : Category.{v, u} C
inst✝² : Preadditive C
R : Type u_1
inst✝¹ : Ring R
inst✝ : Linear R C
F G K L : CochainComplex C ℤ
n✝ m✝ n : ℤ
z : Cocycle F G n
m : ℤ
h : n + 1 = m
⊢ ↑z ∈ cocycle F G n

Next tactic:
exact z.2
@[simp]
lemma δ_eq_zero {n : ℤ} (z : Cocycle F G n) (m : ℤ) : δ n m (z : Cochain F G n) = 0 := by
  by_cases h : n + 1 = m
  · rw [← mem_iff n m h]
    exact z.2
  · 

Proof state:
case neg
C : Type u
inst✝³ : Category.{v, u} C
inst✝² : Preadditive C
R : Type u_1
inst✝¹ : Ring R
inst✝ : Linear R C
F G K L : CochainComplex C ℤ
n✝ m✝ n : ℤ
z : Cocycle F G n
m : ℤ
h : ¬n + 1 = m
⊢ δ n m ↑z = 0

Next tactic:
exact δ_shape n m h _
/-- The `0`-cocycle associated to a morphism in `CochainComplex C ℤ`. -/
@[simps!]
def ofHom (φ : F ⟶ G) : Cocycle F G 0 := mk (Cochain.ofHom φ) 1 (zero_add 1) (by 

Proof state:
C : Type u
inst✝³ : Category.{v, u} C
inst✝² : Preadditive C
R : Type u_1
inst✝¹ : Ring R
inst✝ : Linear R C
F G K L : CochainComplex C ℤ
n m : ℤ
φ : F ⟶ G
⊢ δ 0 1 (Cochain.ofHom φ) = 0

Next tactic:
simp
/-- The morphism in `CochainComplex C ℤ` associated to a `0`-cocycle. -/
@[simps]
def homOf (z : Cocycle F G 0) : F ⟶ G where
  f i := (z : Cochain _ _ _).v i i (add_zero i)
  comm' := by
    

Proof state:
C : Type u
inst✝³ : Category.{v, u} C
inst✝² : Preadditive C
R : Type u_1
inst✝¹ : Ring R
inst✝ : Linear R C
F G K L : CochainComplex C ℤ
n m : ℤ
z : Cocycle F G 0
⊢ ∀ (i j : ℤ),
    ComplexShape.Rel (ComplexShape.up ℤ) i j →
      (fun i => (↑z).v i i (_ : i + 0 = i)) i ≫ HomologicalComplex.d G i j =
        HomologicalComplex.d F i j ≫ (fun i => (↑z).v i i (_ : i + 0 = i)) j

Next tactic:
rintro i j rfl
/-- The morphism in `CochainComplex C ℤ` associated to a `0`-cocycle. -/
@[simps]
def homOf (z : Cocycle F G 0) : F ⟶ G where
  f i := (z : Cochain _ _ _).v i i (add_zero i)
  comm' := by
    rintro i j rfl
    

Proof state:
C : Type u
inst✝³ : Category.{v, u} C
inst✝² : Preadditive C
R : Type u_1
inst✝¹ : Ring R
inst✝ : Linear R C
F G K L : CochainComplex C ℤ
n m : ℤ
z : Cocycle F G 0
i : ℤ
⊢ (fun i => (↑z).v i i (_ : i + 0 = i)) i ≫ HomologicalComplex.d G i (i + 1) =
    HomologicalComplex.d F i (i + 1) ≫ (fun i => (↑z).v i i (_ : i + 0 = i)) (i + 1)

Next tactic:
rcases z with ⟨z, hz⟩
/-- The morphism in `CochainComplex C ℤ` associated to a `0`-cocycle. -/
@[simps]
def homOf (z : Cocycle F G 0) : F ⟶ G where
  f i := (z : Cochain _ _ _).v i i (add_zero i)
  comm' := by
    rintro i j rfl
    rcases z with ⟨z, hz⟩
    

Proof state:
case mk
C : Type u
inst✝³ : Category.{v, u} C
inst✝² : Preadditive C
R : Type u_1
inst✝¹ : Ring R
inst✝ : Linear R C
F G K L : CochainComplex C ℤ
n m i : ℤ
z : Cochain F G 0
hz : z ∈ cocycle F G 0
⊢ (fun i => (↑{ val := z, property := hz }).v i i (_ : i + 0 = i)) i ≫ HomologicalComplex.d G i (i + 1) =
    HomologicalComplex.d F i (i + 1) ≫ (fun i => (↑{ val := z, property := hz }).v i i (_ : i + 0 = i)) (i + 1)

Next tactic:
dsimp
/-- The morphism in `CochainComplex C ℤ` associated to a `0`-cocycle. -/
@[simps]
def homOf (z : Cocycle F G 0) : F ⟶ G where
  f i := (z : Cochain _ _ _).v i i (add_zero i)
  comm' := by
    rintro i j rfl
    rcases z with ⟨z, hz⟩
    dsimp
    

Proof state:
case mk
C : Type u
inst✝³ : Category.{v, u} C
inst✝² : Preadditive C
R : Type u_1
inst✝¹ : Ring R
inst✝ : Linear R C
F G K L : CochainComplex C ℤ
n m i : ℤ
z : Cochain F G 0
hz : z ∈ cocycle F G 0
⊢ z.v i i (_ : i + 0 = i) ≫ HomologicalComplex.d G i (i + 1) =
    HomologicalComplex.d F i (i + 1) ≫ z.v (i + 1) (i + 1) (_ : i + 1 + 0 = i + 1)

Next tactic:
rw [mem_iff 0 1 (zero_add 1)] at hz
/-- The morphism in `CochainComplex C ℤ` associated to a `0`-cocycle. -/
@[simps]
def homOf (z : Cocycle F G 0) : F ⟶ G where
  f i := (z : Cochain _ _ _).v i i (add_zero i)
  comm' := by
    rintro i j rfl
    rcases z with ⟨z, hz⟩
    dsimp
    rw [mem_iff 0 1 (zero_add 1)] at hz
    

Proof state:
case mk
C : Type u
inst✝³ : Category.{v, u} C
inst✝² : Preadditive C
R : Type u_1
inst✝¹ : Ring R
inst✝ : Linear R C
F G K L : CochainComplex C ℤ
n m i : ℤ
z : Cochain F G 0
hz : δ 0 1 z = 0
⊢ z.v i i (_ : i + 0 = i) ≫ HomologicalComplex.d G i (i + 1) =
    HomologicalComplex.d F i (i + 1) ≫ z.v (i + 1) (i + 1) (_ : i + 1 + 0 = i + 1)

Next tactic:
simpa only [δ_zero_cochain_v, Cochain.zero_v, sub_eq_zero]
      using Cochain.congr_v hz i (i + 1) rfl
@[simp]
lemma homOf_ofHom_eq_self (φ : F ⟶ G) : homOf (ofHom φ) = φ := by 

Proof state:
C : Type u
inst✝³ : Category.{v, u} C
inst✝² : Preadditive C
R : Type u_1
inst✝¹ : Ring R
inst✝ : Linear R C
F G K L : CochainComplex C ℤ
n m : ℤ
φ : F ⟶ G
⊢ homOf (ofHom φ) = φ

Next tactic:
aesop_cat
@[simp]
lemma ofHom_homOf_eq_self (z : Cocycle F G 0) : ofHom (homOf z) = z := by 

Proof state:
C : Type u
inst✝³ : Category.{v, u} C
inst✝² : Preadditive C
R : Type u_1
inst✝¹ : Ring R
inst✝ : Linear R C
F G K L : CochainComplex C ℤ
n m : ℤ
z : Cocycle F G 0
⊢ ofHom (homOf z) = z

Next tactic:
aesop_cat
@[simp]
lemma cochain_ofHom_homOf_eq_coe (z : Cocycle F G 0) :
    Cochain.ofHom (homOf z) = (z : Cochain F G 0) := by
  

Proof state:
C : Type u
inst✝³ : Category.{v, u} C
inst✝² : Preadditive C
R : Type u_1
inst✝¹ : Ring R
inst✝ : Linear R C
F G K L : CochainComplex C ℤ
n m : ℤ
z : Cocycle F G 0
⊢ Cochain.ofHom (homOf z) = ↑z

Next tactic:
simpa only [ext_iff] using ofHom_homOf_eq_self z
/-- The additive equivalence between morphisms in `CochainComplex C ℤ` and `0`-cocycles. -/
@[simps]
def equivHom : (F ⟶ G) ≃+ Cocycle F G 0 where
  toFun := ofHom
  invFun := homOf
  left_inv := homOf_ofHom_eq_self
  right_inv := ofHom_homOf_eq_self
  map_add' := by 

Proof state:
C : Type u
inst✝³ : Category.{v, u} C
inst✝² : Preadditive C
R : Type u_1
inst✝¹ : Ring R
inst✝ : Linear R C
F G K L : CochainComplex C ℤ
n m : ℤ
⊢ ∀ (x y : F ⟶ G),
    Equiv.toFun
        { toFun := ofHom, invFun := homOf, left_inv := (_ : ∀ (φ : F ⟶ G), homOf (ofHom φ) = φ),
          right_inv := (_ : ∀ (z : Cocycle F G 0), ofHom (homOf z) = z) }
        (x + y) =
      Equiv.toFun
          { toFun := ofHom, invFun := homOf, left_inv := (_ : ∀ (φ : F ⟶ G), homOf (ofHom φ) = φ),
            right_inv := (_ : ∀ (z : Cocycle F G 0), ofHom (homOf z) = z) }
          x +
        Equiv.toFun
          { toFun := ofHom, invFun := homOf, left_inv := (_ : ∀ (φ : F ⟶ G), homOf (ofHom φ) = φ),
            right_inv := (_ : ∀ (z : Cocycle F G 0), ofHom (homOf z) = z) }
          y

Next tactic:
aesop_cat
/-- The `1`-cocycle given by the differential on a cochain complex. -/
@[simps!]
def diff : Cocycle K K 1 :=
  Cocycle.mk (Cochain.diff K) 2 rfl (by
    

Proof state:
C : Type u
inst✝³ : Category.{v, u} C
inst✝² : Preadditive C
R : Type u_1
inst✝¹ : Ring R
inst✝ : Linear R C
F G K L : CochainComplex C ℤ
n m : ℤ
⊢ δ 1 2 (Cochain.diff K) = 0

Next tactic:
ext p q hpq
/-- The `1`-cocycle given by the differential on a cochain complex. -/
@[simps!]
def diff : Cocycle K K 1 :=
  Cocycle.mk (Cochain.diff K) 2 rfl (by
    ext p q hpq
    

Proof state:
case h
C : Type u
inst✝³ : Category.{v, u} C
inst✝² : Preadditive C
R : Type u_1
inst✝¹ : Ring R
inst✝ : Linear R C
F G K L : CochainComplex C ℤ
n m p q : ℤ
hpq : p + 2 = q
⊢ (δ 1 2 (Cochain.diff K)).v p q hpq = 0.v p q hpq

Next tactic:
simp only [Cochain.zero_v, δ_v 1 2 rfl _ p q hpq _ _ rfl rfl, Cochain.diff_v,
      HomologicalComplex.d_comp_d, smul_zero, add_zero]
/-- Given two morphisms of complexes `φ₁ φ₂ : F ⟶ G`, the datum of an homotopy between `φ₁` and
`φ₂` is equivalent to the datum of a `1`-cochain `z` such that `δ (-1) 0 z` is the difference
of the zero cochains associated to `φ₂` and `φ₁`. -/
@[simps]
def equivHomotopy (φ₁ φ₂ : F ⟶ G) :
    Homotopy φ₁ φ₂ ≃
      { z : Cochain F G (-1) // Cochain.ofHom φ₁ = δ (-1) 0 z + Cochain.ofHom φ₂ } where
  toFun ho := ⟨Cochain.ofHomotopy ho, by 

Proof state:
C : Type u
inst✝³ : Category.{v, u} C
inst✝² : Preadditive C
R : Type u_1
inst✝¹ : Ring R
inst✝ : Linear R C
F G K L : CochainComplex C ℤ
n m : ℤ
φ₁ φ₂ : F ⟶ G
ho : Homotopy φ₁ φ₂
⊢ ofHom φ₁ = δ (-1) 0 (ofHomotopy ho) + ofHom φ₂

Next tactic:
simp only [δ_ofHomotopy, sub_add_cancel]
/-- Given two morphisms of complexes `φ₁ φ₂ : F ⟶ G`, the datum of an homotopy between `φ₁` and
`φ₂` is equivalent to the datum of a `1`-cochain `z` such that `δ (-1) 0 z` is the difference
of the zero cochains associated to `φ₂` and `φ₁`. -/
@[simps]
def equivHomotopy (φ₁ φ₂ : F ⟶ G) :
    Homotopy φ₁ φ₂ ≃
      { z : Cochain F G (-1) // Cochain.ofHom φ₁ = δ (-1) 0 z + Cochain.ofHom φ₂ } where
  toFun ho := ⟨Cochain.ofHomotopy ho, by simp only [δ_ofHomotopy, sub_add_cancel]⟩
  invFun z :=
    { hom := fun i j => if hij : i + (-1) = j then z.1.v i j hij else 0
      zero := fun i j (hij : j + 1 ≠ i) => dif_neg (fun _ => hij (by 

Proof state:
C : Type u
inst✝³ : Category.{v, u} C
inst✝² : Preadditive C
R : Type u_1
inst✝¹ : Ring R
inst✝ : Linear R C
F G K L : CochainComplex C ℤ
n m : ℤ
φ₁ φ₂ : F ⟶ G
z : { z // ofHom φ₁ = δ (-1) 0 z + ofHom φ₂ }
i j : ℤ
hij : j + 1 ≠ i
x✝ : i + -1 = j
⊢ j + 1 = i

Next tactic:
linarith
/-- Given two morphisms of complexes `φ₁ φ₂ : F ⟶ G`, the datum of an homotopy between `φ₁` and
`φ₂` is equivalent to the datum of a `1`-cochain `z` such that `δ (-1) 0 z` is the difference
of the zero cochains associated to `φ₂` and `φ₁`. -/
@[simps]
def equivHomotopy (φ₁ φ₂ : F ⟶ G) :
    Homotopy φ₁ φ₂ ≃
      { z : Cochain F G (-1) // Cochain.ofHom φ₁ = δ (-1) 0 z + Cochain.ofHom φ₂ } where
  toFun ho := ⟨Cochain.ofHomotopy ho, by simp only [δ_ofHomotopy, sub_add_cancel]⟩
  invFun z :=
    { hom := fun i j => if hij : i + (-1) = j then z.1.v i j hij else 0
      zero := fun i j (hij : j + 1 ≠ i) => dif_neg (fun _ => hij (by linarith))
      comm := fun p => by
        

Proof state:
C : Type u
inst✝³ : Category.{v, u} C
inst✝² : Preadditive C
R : Type u_1
inst✝¹ : Ring R
inst✝ : Linear R C
F G K L : CochainComplex C ℤ
n m : ℤ
φ₁ φ₂ : F ⟶ G
z : { z // ofHom φ₁ = δ (-1) 0 z + ofHom φ₂ }
p : ℤ
⊢ HomologicalComplex.Hom.f φ₁ p =
    (((dNext p) fun i j => if hij : i + -1 = j then (↑z).v i j hij else 0) +
        (prevD p) fun i j => if hij : i + -1 = j then (↑z).v i j hij else 0) +
      HomologicalComplex.Hom.f φ₂ p

Next tactic:
have eq := Cochain.congr_v z.2 p p (add_zero p)