l3lab/ntp-mathlib huggingface dataset:
theorem add_comm {X Y : C} (a b : X ⟶ Y) : a + b = b + a := by
  rw [add_def]
  conv_lhs => rw [← neg_neg a]
  rw [neg_def, neg_def, neg_def, sub_sub_sub]
  conv_lhs =>
    congr
    

Proof state:
case a
C : Type u
inst✝¹ : Category.{v, u} C
inst✝ : NonPreadditiveAbelian C
X Y : C
a b : X ⟶ Y
| 0 - 0
case a C : Type u inst✝¹ : Category.{v, u} C inst✝ : NonPreadditiveAbelian C X Y : C a b : X ⟶ Y | 0 - a - b

Next tactic:
next => skip
theorem add_comm {X Y : C} (a b : X ⟶ Y) : a + b = b + a := by
  rw [add_def]
  conv_lhs => rw [← neg_neg a]
  rw [neg_def, neg_def, neg_def, sub_sub_sub]
  conv_lhs =>
    congr
    next => 

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
inst✝ : NonPreadditiveAbelian C
X Y : C
a b : X ⟶ Y
| 0 - 0

Next tactic:
skip
theorem add_comm {X Y : C} (a b : X ⟶ Y) : a + b = b + a := by
  rw [add_def]
  conv_lhs => rw [← neg_neg a]
  rw [neg_def, neg_def, neg_def, sub_sub_sub]
  conv_lhs =>
    congr
    next => skip
    

Proof state:
case a
C : Type u
inst✝¹ : Category.{v, u} C
inst✝ : NonPreadditiveAbelian C
X Y : C
a b : X ⟶ Y
| 0 - a - b

Next tactic:
rw [← neg_def, neg_sub]
theorem add_comm {X Y : C} (a b : X ⟶ Y) : a + b = b + a := by
  rw [add_def]
  conv_lhs => rw [← neg_neg a]
  rw [neg_def, neg_def, neg_def, sub_sub_sub]
  conv_lhs =>
    congr
    next => skip
    rw [← neg_def, neg_sub]
  

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
inst✝ : NonPreadditiveAbelian C
X Y : C
a b : X ⟶ Y
⊢ 0 - 0 - (-b - a) = b + a

Next tactic:
rw [sub_sub_sub, add_def, ← neg_def, neg_neg b, neg_def]
theorem add_neg {X Y : C} (a b : X ⟶ Y) : a + -b = a - b := by 

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
inst✝ : NonPreadditiveAbelian C
X Y : C
a b : X ⟶ Y
⊢ a + -b = a - b

Next tactic:
rw [add_def, neg_neg]
theorem add_neg_self {X Y : C} (a : X ⟶ Y) : a + -a = 0 := by 

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
inst✝ : NonPreadditiveAbelian C
X Y : C
a : X ⟶ Y
⊢ a + -a = 0

Next tactic:
rw [add_neg, sub_self]
theorem neg_add_self {X Y : C} (a : X ⟶ Y) : -a + a = 0 := by 

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
inst✝ : NonPreadditiveAbelian C
X Y : C
a : X ⟶ Y
⊢ -a + a = 0

Next tactic:
rw [add_comm, add_neg_self]
theorem neg_sub' {X Y : C} (a b : X ⟶ Y) : -(a - b) = -a + b := by
  

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
inst✝ : NonPreadditiveAbelian C
X Y : C
a b : X ⟶ Y
⊢ -(a - b) = -a + b

Next tactic:
rw [neg_def, neg_def]
theorem neg_sub' {X Y : C} (a b : X ⟶ Y) : -(a - b) = -a + b := by
  rw [neg_def, neg_def]
  

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
inst✝ : NonPreadditiveAbelian C
X Y : C
a b : X ⟶ Y
⊢ 0 - (a - b) = 0 - a + b

Next tactic:
conv_lhs => rw [← sub_self (0 : X ⟶ Y)]
theorem neg_sub' {X Y : C} (a b : X ⟶ Y) : -(a - b) = -a + b := by
  rw [neg_def, neg_def]
  conv_lhs => 

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
inst✝ : NonPreadditiveAbelian C
X Y : C
a b : X ⟶ Y
| 0 - (a - b)

Next tactic:
rw [← sub_self (0 : X ⟶ Y)]
theorem neg_sub' {X Y : C} (a b : X ⟶ Y) : -(a - b) = -a + b := by
  rw [neg_def, neg_def]
  conv_lhs => rw [← sub_self (0 : X ⟶ Y)]
  

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
inst✝ : NonPreadditiveAbelian C
X Y : C
a b : X ⟶ Y
⊢ 0 - 0 - (a - b) = 0 - a + b

Next tactic:
rw [sub_sub_sub, add_def, neg_def]
theorem neg_add {X Y : C} (a b : X ⟶ Y) : -(a + b) = -a - b := by 

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
inst✝ : NonPreadditiveAbelian C
X Y : C
a b : X ⟶ Y
⊢ -(a + b) = -a - b

Next tactic:
rw [add_def, neg_sub', add_neg]
theorem sub_add {X Y : C} (a b c : X ⟶ Y) : a - b + c = a - (b - c) := by
  

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
inst✝ : NonPreadditiveAbelian C
X Y : C
a b c : X ⟶ Y
⊢ a - b + c = a - (b - c)

Next tactic:
rw [add_def, neg_def, sub_sub_sub, sub_zero]
theorem add_assoc {X Y : C} (a b c : X ⟶ Y) : a + b + c = a + (b + c) := by
  

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
inst✝ : NonPreadditiveAbelian C
X Y : C
a b c : X ⟶ Y
⊢ a + b + c = a + (b + c)

Next tactic:
conv_lhs =>
    congr; rw [add_def]
theorem add_assoc {X Y : C} (a b c : X ⟶ Y) : a + b + c = a + (b + c) := by
  conv_lhs =>
    

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
inst✝ : NonPreadditiveAbelian C
X Y : C
a b c : X ⟶ Y
| a + b + c

Next tactic:
congr; rw [add_def]
theorem add_assoc {X Y : C} (a b c : X ⟶ Y) : a + b + c = a + (b + c) := by
  conv_lhs =>
    

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
inst✝ : NonPreadditiveAbelian C
X Y : C
a b c : X ⟶ Y
| a + b + c

Next tactic:
congr
theorem add_assoc {X Y : C} (a b c : X ⟶ Y) : a + b + c = a + (b + c) := by
  conv_lhs =>
    congr; 

Proof state:
case a
C : Type u
inst✝¹ : Category.{v, u} C
inst✝ : NonPreadditiveAbelian C
X Y : C
a b c : X ⟶ Y
| a + b
case a C : Type u inst✝¹ : Category.{v, u} C inst✝ : NonPreadditiveAbelian C X Y : C a b c : X ⟶ Y | c

Next tactic:
rw [add_def]
theorem add_assoc {X Y : C} (a b c : X ⟶ Y) : a + b + c = a + (b + c) := by
  conv_lhs =>
    congr; rw [add_def]
  

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
inst✝ : NonPreadditiveAbelian C
X Y : C
a b c : X ⟶ Y
⊢ a - -b + c = a + (b + c)

Next tactic:
rw [sub_add, ← add_neg, neg_sub', neg_neg]
theorem add_zero {X Y : C} (a : X ⟶ Y) : a + 0 = a := by 

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
inst✝ : NonPreadditiveAbelian C
X Y : C
a : X ⟶ Y
⊢ a + 0 = a

Next tactic:
rw [add_def, neg_def, sub_self, sub_zero]
theorem comp_sub {X Y Z : C} (f : X ⟶ Y) (g h : Y ⟶ Z) : f ≫ (g - h) = f ≫ g - f ≫ h := by
  

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
inst✝ : NonPreadditiveAbelian C
X Y Z : C
f : X ⟶ Y
g h : Y ⟶ Z
⊢ f ≫ (g - h) = f ≫ g - f ≫ h

Next tactic:
rw [sub_def, ← Category.assoc, prod.comp_lift, sub_def]
theorem sub_comp {X Y Z : C} (f g : X ⟶ Y) (h : Y ⟶ Z) : (f - g) ≫ h = f ≫ h - g ≫ h := by
  

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
inst✝ : NonPreadditiveAbelian C
X Y Z : C
f g : X ⟶ Y
h : Y ⟶ Z
⊢ (f - g) ≫ h = f ≫ h - g ≫ h

Next tactic:
rw [sub_def, Category.assoc, σ_comp, ← Category.assoc, prod.lift_map, sub_def]
theorem comp_add (X Y Z : C) (f : X ⟶ Y) (g h : Y ⟶ Z) : f ≫ (g + h) = f ≫ g + f ≫ h := by
  

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
inst✝ : NonPreadditiveAbelian C
X Y Z : C
f : X ⟶ Y
g h : Y ⟶ Z
⊢ f ≫ (g + h) = f ≫ g + f ≫ h

Next tactic:
rw [add_def, comp_sub, neg_def, comp_sub, comp_zero, add_def, neg_def]
theorem add_comp (X Y Z : C) (f g : X ⟶ Y) (h : Y ⟶ Z) : (f + g) ≫ h = f ≫ h + g ≫ h := by
  

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
inst✝ : NonPreadditiveAbelian C
X Y Z : C
f g : X ⟶ Y
h : Y ⟶ Z
⊢ (f + g) ≫ h = f ≫ h + g ≫ h

Next tactic:
rw [add_def, sub_comp, neg_def, sub_comp, zero_comp, add_def, neg_def]
/-- Entries of the incidence matrix can be computed given additional decidable instances. -/
theorem incMatrix_apply' [Zero R] [One R] [DecidableEq α] [DecidableRel G.Adj] {a : α}
    {e : Sym2 α} : G.incMatrix R a e = if e ∈ G.incidenceSet a then 1 else 0 := by
  

Proof state:
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝³ : Zero R
inst✝² : One R
inst✝¹ : DecidableEq α
inst✝ : DecidableRel G.Adj
a : α
e : Sym2 α
⊢ incMatrix R G a e = if e ∈ incidenceSet G a then 1 else 0

Next tactic:
unfold incMatrix Set.indicator
/-- Entries of the incidence matrix can be computed given additional decidable instances. -/
theorem incMatrix_apply' [Zero R] [One R] [DecidableEq α] [DecidableRel G.Adj] {a : α}
    {e : Sym2 α} : G.incMatrix R a e = if e ∈ G.incidenceSet a then 1 else 0 := by
  unfold incMatrix Set.indicator
  

Proof state:
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝³ : Zero R
inst✝² : One R
inst✝¹ : DecidableEq α
inst✝ : DecidableRel G.Adj
a : α
e : Sym2 α
⊢ (if e ∈ incidenceSet G a then OfNat.ofNat 1 e else 0) = if e ∈ incidenceSet G a then 1 else 0

Next tactic:
convert rfl
theorem incMatrix_apply_mul_incMatrix_apply : G.incMatrix R a e * G.incMatrix R b e =
    (G.incidenceSet a ∩ G.incidenceSet b).indicator 1 e := by
  

Proof state:
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝ : MulZeroOneClass R
a b : α
e : Sym2 α
⊢ incMatrix R G a e * incMatrix R G b e = Set.indicator (incidenceSet G a ∩ incidenceSet G b) 1 e

Next tactic:
classical simp only [incMatrix, Set.indicator_apply, ite_zero_mul_ite_zero, Pi.one_apply, mul_one,
    Set.mem_inter_iff]
theorem incMatrix_apply_mul_incMatrix_apply : G.incMatrix R a e * G.incMatrix R b e =
    (G.incidenceSet a ∩ G.incidenceSet b).indicator 1 e := by
  classical 

Proof state:
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝ : MulZeroOneClass R
a b : α
e : Sym2 α
⊢ incMatrix R G a e * incMatrix R G b e = Set.indicator (incidenceSet G a ∩ incidenceSet G b) 1 e

Next tactic:
simp only [incMatrix, Set.indicator_apply, ite_zero_mul_ite_zero, Pi.one_apply, mul_one,
    Set.mem_inter_iff]
theorem incMatrix_apply_mul_incMatrix_apply_of_not_adj (hab : a ≠ b) (h : ¬G.Adj a b) :
    G.incMatrix R a e * G.incMatrix R b e = 0 := by
  

Proof state:
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝ : MulZeroOneClass R
a b : α
e : Sym2 α
hab : a ≠ b
h : ¬Adj G a b
⊢ incMatrix R G a e * incMatrix R G b e = 0

Next tactic:
rw [incMatrix_apply_mul_incMatrix_apply, Set.indicator_of_not_mem]
theorem incMatrix_apply_mul_incMatrix_apply_of_not_adj (hab : a ≠ b) (h : ¬G.Adj a b) :
    G.incMatrix R a e * G.incMatrix R b e = 0 := by
  rw [incMatrix_apply_mul_incMatrix_apply, Set.indicator_of_not_mem]
  

Proof state:
case h
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝ : MulZeroOneClass R
a b : α
e : Sym2 α
hab : a ≠ b
h : ¬Adj G a b
⊢ e ∉ incidenceSet G a ∩ incidenceSet G b

Next tactic:
rw [G.incidenceSet_inter_incidenceSet_of_not_adj h hab]
theorem incMatrix_apply_mul_incMatrix_apply_of_not_adj (hab : a ≠ b) (h : ¬G.Adj a b) :
    G.incMatrix R a e * G.incMatrix R b e = 0 := by
  rw [incMatrix_apply_mul_incMatrix_apply, Set.indicator_of_not_mem]
  rw [G.incidenceSet_inter_incidenceSet_of_not_adj h hab]
  

Proof state:
case h
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝ : MulZeroOneClass R
a b : α
e : Sym2 α
hab : a ≠ b
h : ¬Adj G a b
⊢ e ∉ ∅

Next tactic:
exact Set.not_mem_empty e
theorem incMatrix_of_not_mem_incidenceSet (h : e ∉ G.incidenceSet a) : G.incMatrix R a e = 0 := by
  

Proof state:
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝ : MulZeroOneClass R
a b : α
e : Sym2 α
h : e ∉ incidenceSet G a
⊢ incMatrix R G a e = 0

Next tactic:
rw [incMatrix_apply, Set.indicator_of_not_mem h]
theorem incMatrix_of_mem_incidenceSet (h : e ∈ G.incidenceSet a) : G.incMatrix R a e = 1 := by
  

Proof state:
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝ : MulZeroOneClass R
a b : α
e : Sym2 α
h : e ∈ incidenceSet G a
⊢ incMatrix R G a e = 1

Next tactic:
rw [incMatrix_apply, Set.indicator_of_mem h, Pi.one_apply]
theorem incMatrix_apply_eq_zero_iff : G.incMatrix R a e = 0 ↔ e ∉ G.incidenceSet a := by
  

Proof state:
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝¹ : MulZeroOneClass R
a b : α
e : Sym2 α
inst✝ : Nontrivial R
⊢ incMatrix R G a e = 0 ↔ e ∉ incidenceSet G a

Next tactic:
simp only [incMatrix_apply, Set.indicator_apply_eq_zero, Pi.one_apply, one_ne_zero]
theorem incMatrix_apply_eq_one_iff : G.incMatrix R a e = 1 ↔ e ∈ G.incidenceSet a := by
  -- Porting note: was `convert one_ne_zero.ite_eq_left_iff; infer_instance`
  

Proof state:
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝¹ : MulZeroOneClass R
a b : α
e : Sym2 α
inst✝ : Nontrivial R
⊢ incMatrix R G a e = 1 ↔ e ∈ incidenceSet G a

Next tactic:
unfold incMatrix Set.indicator
theorem incMatrix_apply_eq_one_iff : G.incMatrix R a e = 1 ↔ e ∈ G.incidenceSet a := by
  -- Porting note: was `convert one_ne_zero.ite_eq_left_iff; infer_instance`
  unfold incMatrix Set.indicator
  

Proof state:
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝¹ : MulZeroOneClass R
a b : α
e : Sym2 α
inst✝ : Nontrivial R
⊢ (if e ∈ incidenceSet G a then OfNat.ofNat 1 e else 0) = 1 ↔ e ∈ incidenceSet G a

Next tactic:
simp only [Pi.one_apply]
theorem incMatrix_apply_eq_one_iff : G.incMatrix R a e = 1 ↔ e ∈ G.incidenceSet a := by
  -- Porting note: was `convert one_ne_zero.ite_eq_left_iff; infer_instance`
  unfold incMatrix Set.indicator
  simp only [Pi.one_apply]
  

Proof state:
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝¹ : MulZeroOneClass R
a b : α
e : Sym2 α
inst✝ : Nontrivial R
⊢ (if e ∈ incidenceSet G a then 1 else 0) = 1 ↔ e ∈ incidenceSet G a

Next tactic:
apply Iff.intro
theorem incMatrix_apply_eq_one_iff : G.incMatrix R a e = 1 ↔ e ∈ G.incidenceSet a := by
  -- Porting note: was `convert one_ne_zero.ite_eq_left_iff; infer_instance`
  unfold incMatrix Set.indicator
  simp only [Pi.one_apply]
  apply Iff.intro <;> 

Proof state:
case mp
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝¹ : MulZeroOneClass R
a b : α
e : Sym2 α
inst✝ : Nontrivial R
⊢ (if e ∈ incidenceSet G a then 1 else 0) = 1 → e ∈ incidenceSet G a

Next tactic:
intro h
theorem incMatrix_apply_eq_one_iff : G.incMatrix R a e = 1 ↔ e ∈ G.incidenceSet a := by
  -- Porting note: was `convert one_ne_zero.ite_eq_left_iff; infer_instance`
  unfold incMatrix Set.indicator
  simp only [Pi.one_apply]
  apply Iff.intro <;> 

Proof state:
case mpr
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝¹ : MulZeroOneClass R
a b : α
e : Sym2 α
inst✝ : Nontrivial R
⊢ e ∈ incidenceSet G a → (if e ∈ incidenceSet G a then 1 else 0) = 1

Next tactic:
intro h
theorem incMatrix_apply_eq_one_iff : G.incMatrix R a e = 1 ↔ e ∈ G.incidenceSet a := by
  -- Porting note: was `convert one_ne_zero.ite_eq_left_iff; infer_instance`
  unfold incMatrix Set.indicator
  simp only [Pi.one_apply]
  apply Iff.intro <;> intro h
  · 

Proof state:
case mp
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝¹ : MulZeroOneClass R
a b : α
e : Sym2 α
inst✝ : Nontrivial R
h : (if e ∈ incidenceSet G a then 1 else 0) = 1
⊢ e ∈ incidenceSet G a

Next tactic:
split at h
theorem incMatrix_apply_eq_one_iff : G.incMatrix R a e = 1 ↔ e ∈ G.incidenceSet a := by
  -- Porting note: was `convert one_ne_zero.ite_eq_left_iff; infer_instance`
  unfold incMatrix Set.indicator
  simp only [Pi.one_apply]
  apply Iff.intro <;> intro h
  · split at h <;> 

Proof state:
case mp.inl
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝¹ : MulZeroOneClass R
a b : α
e : Sym2 α
inst✝ : Nontrivial R
h✝ : e ∈ incidenceSet G a
h : 1 = 1
⊢ e ∈ incidenceSet G a

Next tactic:
simp_all only [zero_ne_one]
theorem incMatrix_apply_eq_one_iff : G.incMatrix R a e = 1 ↔ e ∈ G.incidenceSet a := by
  -- Porting note: was `convert one_ne_zero.ite_eq_left_iff; infer_instance`
  unfold incMatrix Set.indicator
  simp only [Pi.one_apply]
  apply Iff.intro <;> intro h
  · split at h <;> 

Proof state:
case mp.inr
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝¹ : MulZeroOneClass R
a b : α
e : Sym2 α
inst✝ : Nontrivial R
h✝ : e ∉ incidenceSet G a
h : 0 = 1
⊢ e ∈ incidenceSet G a

Next tactic:
simp_all only [zero_ne_one]
theorem incMatrix_apply_eq_one_iff : G.incMatrix R a e = 1 ↔ e ∈ G.incidenceSet a := by
  -- Porting note: was `convert one_ne_zero.ite_eq_left_iff; infer_instance`
  unfold incMatrix Set.indicator
  simp only [Pi.one_apply]
  apply Iff.intro <;> intro h
  · split at h <;> simp_all only [zero_ne_one]
  · 

Proof state:
case mpr
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝¹ : MulZeroOneClass R
a b : α
e : Sym2 α
inst✝ : Nontrivial R
h : e ∈ incidenceSet G a
⊢ (if e ∈ incidenceSet G a then 1 else 0) = 1

Next tactic:
simp_all only [ite_true]
theorem sum_incMatrix_apply [DecidableEq α] [DecidableRel G.Adj] :
    ∑ e, G.incMatrix R a e = G.degree a := by
  

Proof state:
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝³ : Fintype α
inst✝² : NonAssocSemiring R
a b : α
e : Sym2 α
inst✝¹ : DecidableEq α
inst✝ : DecidableRel G.Adj
⊢ ∑ e : Sym2 α, incMatrix R G a e = ↑(degree G a)

Next tactic:
simp [incMatrix_apply', sum_boole, Set.filter_mem_univ_eq_toFinset]
theorem incMatrix_mul_transpose_diag [DecidableEq α] [DecidableRel G.Adj] :
    (G.incMatrix R * (G.incMatrix R)ᵀ) a a = G.degree a := by
  

Proof state:
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝³ : Fintype α
inst✝² : NonAssocSemiring R
a b : α
e : Sym2 α
inst✝¹ : DecidableEq α
inst✝ : DecidableRel G.Adj
⊢ (incMatrix R G * (incMatrix R G)ᵀ) a a = ↑(degree G a)

Next tactic:
rw [← sum_incMatrix_apply]
theorem incMatrix_mul_transpose_diag [DecidableEq α] [DecidableRel G.Adj] :
    (G.incMatrix R * (G.incMatrix R)ᵀ) a a = G.degree a := by
  rw [← sum_incMatrix_apply]
  

Proof state:
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝³ : Fintype α
inst✝² : NonAssocSemiring R
a b : α
e : Sym2 α
inst✝¹ : DecidableEq α
inst✝ : DecidableRel G.Adj
⊢ (incMatrix R G * (incMatrix R G)ᵀ) a a = ∑ e : Sym2 α, incMatrix R G a e

Next tactic:
simp only [mul_apply, incMatrix_apply', transpose_apply, mul_ite, mul_one, mul_zero]
theorem incMatrix_mul_transpose_diag [DecidableEq α] [DecidableRel G.Adj] :
    (G.incMatrix R * (G.incMatrix R)ᵀ) a a = G.degree a := by
  rw [← sum_incMatrix_apply]
  simp only [mul_apply, incMatrix_apply', transpose_apply, mul_ite, mul_one, mul_zero]
  

Proof state:
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝³ : Fintype α
inst✝² : NonAssocSemiring R
a b : α
e : Sym2 α
inst✝¹ : DecidableEq α
inst✝ : DecidableRel G.Adj
⊢ (∑ x : Sym2 α, if x ∈ incidenceSet G a then if x ∈ incidenceSet G a then 1 else 0 else 0) =
    ∑ x : Sym2 α, if x ∈ incidenceSet G a then 1 else 0

Next tactic:
simp_all only [ite_true, sum_boole]
theorem sum_incMatrix_apply_of_mem_edgeSet :
    e ∈ G.edgeSet → ∑ a, G.incMatrix R a e = 2 := by
  

Proof state:
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝¹ : Fintype α
inst✝ : NonAssocSemiring R
a b : α
e : Sym2 α
⊢ e ∈ edgeSet G → ∑ a : α, incMatrix R G a e = 2

Next tactic:
classical
    refine' e.ind _
    intro a b h
    rw [mem_edgeSet] at h
    rw [← Nat.cast_two, ← card_doubleton h.ne]
    simp only [incMatrix_apply', sum_boole, mk'_mem_incidenceSet_iff, h, true_and_iff]
    congr 2
    ext e
    simp only [mem_filter, mem_univ, true_and_iff, mem_insert, mem_singleton]
theorem sum_incMatrix_apply_of_mem_edgeSet :
    e ∈ G.edgeSet → ∑ a, G.incMatrix R a e = 2 := by
  classical
    

Proof state:
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝¹ : Fintype α
inst✝ : NonAssocSemiring R
a b : α
e : Sym2 α
⊢ e ∈ edgeSet G → ∑ a : α, incMatrix R G a e = 2

Next tactic:
refine' e.ind _
theorem sum_incMatrix_apply_of_mem_edgeSet :
    e ∈ G.edgeSet → ∑ a, G.incMatrix R a e = 2 := by
  classical
    refine' e.ind _
    

Proof state:
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝¹ : Fintype α
inst✝ : NonAssocSemiring R
a b : α
e : Sym2 α
⊢ ∀ (x y : α), ⟦(x, y)⟧ ∈ edgeSet G → ∑ a : α, incMatrix R G a ⟦(x, y)⟧ = 2

Next tactic:
intro a b h
theorem sum_incMatrix_apply_of_mem_edgeSet :
    e ∈ G.edgeSet → ∑ a, G.incMatrix R a e = 2 := by
  classical
    refine' e.ind _
    intro a b h
    

Proof state:
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝¹ : Fintype α
inst✝ : NonAssocSemiring R
a✝ b✝ : α
e : Sym2 α
a b : α
h : ⟦(a, b)⟧ ∈ edgeSet G
⊢ ∑ a_1 : α, incMatrix R G a_1 ⟦(a, b)⟧ = 2

Next tactic:
rw [mem_edgeSet] at h
theorem sum_incMatrix_apply_of_mem_edgeSet :
    e ∈ G.edgeSet → ∑ a, G.incMatrix R a e = 2 := by
  classical
    refine' e.ind _
    intro a b h
    rw [mem_edgeSet] at h
    

Proof state:
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝¹ : Fintype α
inst✝ : NonAssocSemiring R
a✝ b✝ : α
e : Sym2 α
a b : α
h : Adj G a b
⊢ ∑ a_1 : α, incMatrix R G a_1 ⟦(a, b)⟧ = 2

Next tactic:
rw [← Nat.cast_two, ← card_doubleton h.ne]
theorem sum_incMatrix_apply_of_mem_edgeSet :
    e ∈ G.edgeSet → ∑ a, G.incMatrix R a e = 2 := by
  classical
    refine' e.ind _
    intro a b h
    rw [mem_edgeSet] at h
    rw [← Nat.cast_two, ← card_doubleton h.ne]
    

Proof state:
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝¹ : Fintype α
inst✝ : NonAssocSemiring R
a✝ b✝ : α
e : Sym2 α
a b : α
h : Adj G a b
⊢ ∑ a_1 : α, incMatrix R G a_1 ⟦(a, b)⟧ = ↑(card {a, b})

Next tactic:
simp only [incMatrix_apply', sum_boole, mk'_mem_incidenceSet_iff, h, true_and_iff]
theorem sum_incMatrix_apply_of_mem_edgeSet :
    e ∈ G.edgeSet → ∑ a, G.incMatrix R a e = 2 := by
  classical
    refine' e.ind _
    intro a b h
    rw [mem_edgeSet] at h
    rw [← Nat.cast_two, ← card_doubleton h.ne]
    simp only [incMatrix_apply', sum_boole, mk'_mem_incidenceSet_iff, h, true_and_iff]
    

Proof state:
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝¹ : Fintype α
inst✝ : NonAssocSemiring R
a✝ b✝ : α
e : Sym2 α
a b : α
h : Adj G a b
⊢ ↑(card (filter (fun x => x = a ∨ x = b) univ)) = ↑(card {a, b})

Next tactic:
congr 2
theorem sum_incMatrix_apply_of_mem_edgeSet :
    e ∈ G.edgeSet → ∑ a, G.incMatrix R a e = 2 := by
  classical
    refine' e.ind _
    intro a b h
    rw [mem_edgeSet] at h
    rw [← Nat.cast_two, ← card_doubleton h.ne]
    simp only [incMatrix_apply', sum_boole, mk'_mem_incidenceSet_iff, h, true_and_iff]
    congr 2
    

Proof state:
case e_a.e_s
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝¹ : Fintype α
inst✝ : NonAssocSemiring R
a✝ b✝ : α
e : Sym2 α
a b : α
h : Adj G a b
⊢ filter (fun x => x = a ∨ x = b) univ = {a, b}

Next tactic:
ext e
theorem sum_incMatrix_apply_of_mem_edgeSet :
    e ∈ G.edgeSet → ∑ a, G.incMatrix R a e = 2 := by
  classical
    refine' e.ind _
    intro a b h
    rw [mem_edgeSet] at h
    rw [← Nat.cast_two, ← card_doubleton h.ne]
    simp only [incMatrix_apply', sum_boole, mk'_mem_incidenceSet_iff, h, true_and_iff]
    congr 2
    ext e
    

Proof state:
case e_a.e_s.a
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝¹ : Fintype α
inst✝ : NonAssocSemiring R
a✝ b✝ : α
e✝ : Sym2 α
a b : α
h : Adj G a b
e : α
⊢ e ∈ filter (fun x => x = a ∨ x = b) univ ↔ e ∈ {a, b}

Next tactic:
simp only [mem_filter, mem_univ, true_and_iff, mem_insert, mem_singleton]
theorem incMatrix_transpose_mul_diag [DecidableRel G.Adj] :
    ((G.incMatrix R)ᵀ * G.incMatrix R) e e = if e ∈ G.edgeSet then 2 else 0 := by
  

Proof state:
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝² : Fintype α
inst✝¹ : NonAssocSemiring R
a b : α
e : Sym2 α
inst✝ : DecidableRel G.Adj
⊢ ((incMatrix R G)ᵀ * incMatrix R G) e e = if e ∈ edgeSet G then 2 else 0

Next tactic:
classical
    simp only [Matrix.mul_apply, incMatrix_apply', transpose_apply, ite_zero_mul_ite_zero, one_mul,
      sum_boole, and_self_iff]
    split_ifs with h
    · revert h
      refine' e.ind _
      intro v w h
      rw [← Nat.cast_two, ← card_doubleton (G.ne_of_adj h)]
      simp only [mk'_mem_incidenceSet_iff, G.mem_edgeSet.mp h, true_and, mem_univ, forall_true_left,
        forall_eq_or_imp, forall_eq, and_self, mem_singleton, ne_eq]
      congr 2
      ext u
      simp
    · revert h
      refine' e.ind _
      intro v w h
      simp [mk'_mem_incidenceSet_iff, G.mem_edgeSet.not.mp h]
theorem incMatrix_transpose_mul_diag [DecidableRel G.Adj] :
    ((G.incMatrix R)ᵀ * G.incMatrix R) e e = if e ∈ G.edgeSet then 2 else 0 := by
  classical
    

Proof state:
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝² : Fintype α
inst✝¹ : NonAssocSemiring R
a b : α
e : Sym2 α
inst✝ : DecidableRel G.Adj
⊢ ((incMatrix R G)ᵀ * incMatrix R G) e e = if e ∈ edgeSet G then 2 else 0

Next tactic:
simp only [Matrix.mul_apply, incMatrix_apply', transpose_apply, ite_zero_mul_ite_zero, one_mul,
      sum_boole, and_self_iff]
theorem incMatrix_transpose_mul_diag [DecidableRel G.Adj] :
    ((G.incMatrix R)ᵀ * G.incMatrix R) e e = if e ∈ G.edgeSet then 2 else 0 := by
  classical
    simp only [Matrix.mul_apply, incMatrix_apply', transpose_apply, ite_zero_mul_ite_zero, one_mul,
      sum_boole, and_self_iff]
    

Proof state:
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝² : Fintype α
inst✝¹ : NonAssocSemiring R
a b : α
e : Sym2 α
inst✝ : DecidableRel G.Adj
⊢ ↑(card (filter (fun x => e ∈ incidenceSet G x) univ)) = if e ∈ edgeSet G then 2 else 0

Next tactic:
split_ifs with h
theorem incMatrix_transpose_mul_diag [DecidableRel G.Adj] :
    ((G.incMatrix R)ᵀ * G.incMatrix R) e e = if e ∈ G.edgeSet then 2 else 0 := by
  classical
    simp only [Matrix.mul_apply, incMatrix_apply', transpose_apply, ite_zero_mul_ite_zero, one_mul,
      sum_boole, and_self_iff]
    split_ifs with h
    · 

Proof state:
case pos
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝² : Fintype α
inst✝¹ : NonAssocSemiring R
a b : α
e : Sym2 α
inst✝ : DecidableRel G.Adj
h : e ∈ edgeSet G
⊢ ↑(card (filter (fun x => e ∈ incidenceSet G x) univ)) = 2

Next tactic:
revert h