l3lab/ntp-mathlib huggingface dataset:
private theorem disjUnion_filter_pairs_eq_pairs (k : ℕ) :
    disjUnion (filter (fun t ↦ card t.fst < k) (pairs σ k))
    (filter (fun t ↦ card t.fst = k) (pairs σ k)) (disjoint_filter_pairs_lt_filter_pairs_eq σ k) =
    pairs σ k := by
  simp only [disjUnion_eq_union, Finset.ext_iff, pairs, filter_filter, mem_filter]
  

Proof state:
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
⊢ ∀ (a : Finset σ × σ),
    a ∈
        filter (fun a => (card a.1 ≤ k ∧ (card a.1 = k → a.2 ∈ a.1)) ∧ card a.1 < k) univ ∪
          filter (fun a => (card a.1 ≤ k ∧ (card a.1 = k → a.2 ∈ a.1)) ∧ card a.1 = k) univ ↔
      a ∈ univ ∧ card a.1 ≤ k ∧ (card a.1 = k → a.2 ∈ a.1)

Next tactic:
intro a
private theorem disjUnion_filter_pairs_eq_pairs (k : ℕ) :
    disjUnion (filter (fun t ↦ card t.fst < k) (pairs σ k))
    (filter (fun t ↦ card t.fst = k) (pairs σ k)) (disjoint_filter_pairs_lt_filter_pairs_eq σ k) =
    pairs σ k := by
  simp only [disjUnion_eq_union, Finset.ext_iff, pairs, filter_filter, mem_filter]
  intro a
  

Proof state:
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
a : Finset σ × σ
⊢ a ∈
      filter (fun a => (card a.1 ≤ k ∧ (card a.1 = k → a.2 ∈ a.1)) ∧ card a.1 < k) univ ∪
        filter (fun a => (card a.1 ≤ k ∧ (card a.1 = k → a.2 ∈ a.1)) ∧ card a.1 = k) univ ↔
    a ∈ univ ∧ card a.1 ≤ k ∧ (card a.1 = k → a.2 ∈ a.1)

Next tactic:
rw [← filter_or, mem_filter]
private theorem disjUnion_filter_pairs_eq_pairs (k : ℕ) :
    disjUnion (filter (fun t ↦ card t.fst < k) (pairs σ k))
    (filter (fun t ↦ card t.fst = k) (pairs σ k)) (disjoint_filter_pairs_lt_filter_pairs_eq σ k) =
    pairs σ k := by
  simp only [disjUnion_eq_union, Finset.ext_iff, pairs, filter_filter, mem_filter]
  intro a
  rw [← filter_or, mem_filter]
  

Proof state:
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
a : Finset σ × σ
⊢ a ∈ univ ∧
      ((card a.1 ≤ k ∧ (card a.1 = k → a.2 ∈ a.1)) ∧ card a.1 < k ∨
        (card a.1 ≤ k ∧ (card a.1 = k → a.2 ∈ a.1)) ∧ card a.1 = k) ↔
    a ∈ univ ∧ card a.1 ≤ k ∧ (card a.1 = k → a.2 ∈ a.1)

Next tactic:
refine' ⟨fun ha ↦ by tauto, fun ha ↦ _⟩
private theorem disjUnion_filter_pairs_eq_pairs (k : ℕ) :
    disjUnion (filter (fun t ↦ card t.fst < k) (pairs σ k))
    (filter (fun t ↦ card t.fst = k) (pairs σ k)) (disjoint_filter_pairs_lt_filter_pairs_eq σ k) =
    pairs σ k := by
  simp only [disjUnion_eq_union, Finset.ext_iff, pairs, filter_filter, mem_filter]
  intro a
  rw [← filter_or, mem_filter]
  refine' ⟨fun ha ↦ by 

Proof state:
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
a : Finset σ × σ
ha :
  a ∈ univ ∧
    ((card a.1 ≤ k ∧ (card a.1 = k → a.2 ∈ a.1)) ∧ card a.1 < k ∨
      (card a.1 ≤ k ∧ (card a.1 = k → a.2 ∈ a.1)) ∧ card a.1 = k)
⊢ a ∈ univ ∧ card a.1 ≤ k ∧ (card a.1 = k → a.2 ∈ a.1)

Next tactic:
tauto
private theorem disjUnion_filter_pairs_eq_pairs (k : ℕ) :
    disjUnion (filter (fun t ↦ card t.fst < k) (pairs σ k))
    (filter (fun t ↦ card t.fst = k) (pairs σ k)) (disjoint_filter_pairs_lt_filter_pairs_eq σ k) =
    pairs σ k := by
  simp only [disjUnion_eq_union, Finset.ext_iff, pairs, filter_filter, mem_filter]
  intro a
  rw [← filter_or, mem_filter]
  refine' ⟨fun ha ↦ by tauto, fun ha ↦ _⟩
  

Proof state:
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
a : Finset σ × σ
ha : a ∈ univ ∧ card a.1 ≤ k ∧ (card a.1 = k → a.2 ∈ a.1)
⊢ a ∈ univ ∧
    ((card a.1 ≤ k ∧ (card a.1 = k → a.2 ∈ a.1)) ∧ card a.1 < k ∨
      (card a.1 ≤ k ∧ (card a.1 = k → a.2 ∈ a.1)) ∧ card a.1 = k)

Next tactic:
have hacard := le_iff_lt_or_eq.mp ha.2.1
private theorem disjUnion_filter_pairs_eq_pairs (k : ℕ) :
    disjUnion (filter (fun t ↦ card t.fst < k) (pairs σ k))
    (filter (fun t ↦ card t.fst = k) (pairs σ k)) (disjoint_filter_pairs_lt_filter_pairs_eq σ k) =
    pairs σ k := by
  simp only [disjUnion_eq_union, Finset.ext_iff, pairs, filter_filter, mem_filter]
  intro a
  rw [← filter_or, mem_filter]
  refine' ⟨fun ha ↦ by tauto, fun ha ↦ _⟩
  have hacard := le_iff_lt_or_eq.mp ha.2.1
  

Proof state:
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
a : Finset σ × σ
ha : a ∈ univ ∧ card a.1 ≤ k ∧ (card a.1 = k → a.2 ∈ a.1)
hacard : card a.1 < k ∨ card a.1 = k
⊢ a ∈ univ ∧
    ((card a.1 ≤ k ∧ (card a.1 = k → a.2 ∈ a.1)) ∧ card a.1 < k ∨
      (card a.1 ≤ k ∧ (card a.1 = k → a.2 ∈ a.1)) ∧ card a.1 = k)

Next tactic:
tauto
private theorem esymm_summand_to_weight (k : ℕ) (A : Finset σ) (h : A ∈ powersetCard k univ) :
    ∑ j in A, weight σ R k (A, j) = k * (-1) ^ k * (∏ i in A, X i : MvPolynomial σ R) := by
  

Proof state:
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
A : Finset σ
h : A ∈ powersetCard k univ
⊢ ∑ j in A, MvPolynomial.NewtonIdentities.weight σ R k (A, j) = ↑k * (-1) ^ k * ∏ i in A, X i

Next tactic:
simp [weight, mem_powersetCard_univ.mp h, mul_assoc]
private theorem esymm_to_weight (k : ℕ) : k * esymm σ R k =
    (-1) ^ k * ∑ t in filter (fun t ↦ card t.fst = k) (pairs σ k), weight σ R k t := by
  

Proof state:
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
⊢ ↑k * esymm σ R k =
    (-1) ^ k *
      ∑ t in filter (fun t => card t.1 = k) (MvPolynomial.NewtonIdentities.pairs σ k),
        MvPolynomial.NewtonIdentities.weight σ R k t

Next tactic:
rw [esymm, sum_filter_pairs_eq_sum_powersetCard_sum σ R k (fun t ↦ weight σ R k t),
    sum_congr rfl (esymm_summand_to_weight σ R k), mul_comm (k : MvPolynomial σ R) ((-1) ^ k),
    ← mul_sum, ← mul_assoc, ← mul_assoc, ← pow_add, Even.neg_one_pow ⟨k, rfl⟩, one_mul]
private theorem esymm_mul_psum_summand_to_weight (k : ℕ) (a : ℕ × ℕ) (ha : a ∈ antidiagonal k) :
    ∑ A in powersetCard a.fst univ, ∑ j, weight σ R k (A, j) =
    (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd := by
  

Proof state:
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
a : ℕ × ℕ
ha : a ∈ antidiagonal k
⊢ ∑ A in powersetCard a.1 univ, ∑ j : σ, MvPolynomial.NewtonIdentities.weight σ R k (A, j) =
    (-1) ^ a.1 * esymm σ R a.1 * psum σ R a.2

Next tactic:
simp only [esymm, psum_def, weight, ← mul_assoc, mul_sum]
private theorem esymm_mul_psum_summand_to_weight (k : ℕ) (a : ℕ × ℕ) (ha : a ∈ antidiagonal k) :
    ∑ A in powersetCard a.fst univ, ∑ j, weight σ R k (A, j) =
    (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd := by
  simp only [esymm, psum_def, weight, ← mul_assoc, mul_sum]
  

Proof state:
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
a : ℕ × ℕ
ha : a ∈ antidiagonal k
⊢ ∑ x in powersetCard a.1 univ, ∑ x_1 : σ, ((-1) ^ card x * ∏ a in x, X a) * X x_1 ^ (k - card x) =
    ∑ x : σ, (∑ x in powersetCard a.1 univ, (-1) ^ a.1 * ∏ a in x, X a) * X x ^ a.2

Next tactic:
rw [sum_comm]
private theorem esymm_mul_psum_summand_to_weight (k : ℕ) (a : ℕ × ℕ) (ha : a ∈ antidiagonal k) :
    ∑ A in powersetCard a.fst univ, ∑ j, weight σ R k (A, j) =
    (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd := by
  simp only [esymm, psum_def, weight, ← mul_assoc, mul_sum]
  rw [sum_comm]
  

Proof state:
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
a : ℕ × ℕ
ha : a ∈ antidiagonal k
⊢ ∑ y : σ, ∑ x in powersetCard a.1 univ, ((-1) ^ card x * ∏ a in x, X a) * X y ^ (k - card x) =
    ∑ x : σ, (∑ x in powersetCard a.1 univ, (-1) ^ a.1 * ∏ a in x, X a) * X x ^ a.2

Next tactic:
refine' sum_congr rfl fun x _ ↦ _
private theorem esymm_mul_psum_summand_to_weight (k : ℕ) (a : ℕ × ℕ) (ha : a ∈ antidiagonal k) :
    ∑ A in powersetCard a.fst univ, ∑ j, weight σ R k (A, j) =
    (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd := by
  simp only [esymm, psum_def, weight, ← mul_assoc, mul_sum]
  rw [sum_comm]
  refine' sum_congr rfl fun x _ ↦ _
  

Proof state:
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
a : ℕ × ℕ
ha : a ∈ antidiagonal k
x : σ
x✝ : x ∈ univ
⊢ ∑ x_1 in powersetCard a.1 univ, ((-1) ^ card x_1 * ∏ a in x_1, X a) * X x ^ (k - card x_1) =
    (∑ x in powersetCard a.1 univ, (-1) ^ a.1 * ∏ a in x, X a) * X x ^ a.2

Next tactic:
rw [sum_mul]
private theorem esymm_mul_psum_summand_to_weight (k : ℕ) (a : ℕ × ℕ) (ha : a ∈ antidiagonal k) :
    ∑ A in powersetCard a.fst univ, ∑ j, weight σ R k (A, j) =
    (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd := by
  simp only [esymm, psum_def, weight, ← mul_assoc, mul_sum]
  rw [sum_comm]
  refine' sum_congr rfl fun x _ ↦ _
  rw [sum_mul]
  

Proof state:
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
a : ℕ × ℕ
ha : a ∈ antidiagonal k
x : σ
x✝ : x ∈ univ
⊢ ∑ x_1 in powersetCard a.1 univ, ((-1) ^ card x_1 * ∏ a in x_1, X a) * X x ^ (k - card x_1) =
    ∑ x_1 in powersetCard a.1 univ, ((-1) ^ a.1 * ∏ a in x_1, X a) * X x ^ a.2

Next tactic:
refine' sum_congr rfl fun s hs ↦ _
private theorem esymm_mul_psum_summand_to_weight (k : ℕ) (a : ℕ × ℕ) (ha : a ∈ antidiagonal k) :
    ∑ A in powersetCard a.fst univ, ∑ j, weight σ R k (A, j) =
    (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd := by
  simp only [esymm, psum_def, weight, ← mul_assoc, mul_sum]
  rw [sum_comm]
  refine' sum_congr rfl fun x _ ↦ _
  rw [sum_mul]
  refine' sum_congr rfl fun s hs ↦ _
  

Proof state:
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
a : ℕ × ℕ
ha : a ∈ antidiagonal k
x : σ
x✝ : x ∈ univ
s : Finset σ
hs : s ∈ powersetCard a.1 univ
⊢ ((-1) ^ card s * ∏ a in s, X a) * X x ^ (k - card s) = ((-1) ^ a.1 * ∏ a in s, X a) * X x ^ a.2

Next tactic:
rw [mem_powersetCard_univ.mp hs, ← mem_antidiagonal.mp ha, add_sub_self_left]
private theorem esymm_mul_psum_to_weight (k : ℕ) :
    ∑ a in (antidiagonal k).filter (fun a ↦ a.fst < k),
    (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd =
    ∑ t in filter (fun t ↦ card t.fst < k) (pairs σ k), weight σ R k t := by
  

Proof state:
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
⊢ ∑ a in filter (fun a => a.1 < k) (antidiagonal k), (-1) ^ a.1 * esymm σ R a.1 * psum σ R a.2 =
    ∑ t in filter (fun t => card t.1 < k) (MvPolynomial.NewtonIdentities.pairs σ k),
      MvPolynomial.NewtonIdentities.weight σ R k t

Next tactic:
rw [← sum_congr rfl (fun a ha ↦ esymm_mul_psum_summand_to_weight σ R k a (mem_filter.mp ha).left),
    sum_filter_pairs_eq_sum_filter_antidiagonal_powersetCard_sum σ R k]
/-- **Newton's identities** give a recurrence relation for the kth elementary symmetric polynomial
in terms of lower degree elementary symmetric polynomials and power sums. -/
theorem mul_esymm_eq_sum (k : ℕ) : k * esymm σ R k =
    (-1) ^ (k + 1) * ∑ a in (antidiagonal k).filter (fun a ↦ a.fst < k),
    (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd := by
  

Proof state:
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
⊢ ↑k * esymm σ R k =
    (-1) ^ (k + 1) * ∑ a in filter (fun a => a.1 < k) (antidiagonal k), (-1) ^ a.1 * esymm σ R a.1 * psum σ R a.2

Next tactic:
rw [NewtonIdentities.esymm_to_weight σ R k, NewtonIdentities.esymm_mul_psum_to_weight σ R k,
    eq_comm, ← sub_eq_zero, sub_eq_add_neg, neg_mul_eq_neg_mul,
    neg_eq_neg_one_mul ((-1 : MvPolynomial σ R) ^ k)]
/-- **Newton's identities** give a recurrence relation for the kth elementary symmetric polynomial
in terms of lower degree elementary symmetric polynomials and power sums. -/
theorem mul_esymm_eq_sum (k : ℕ) : k * esymm σ R k =
    (-1) ^ (k + 1) * ∑ a in (antidiagonal k).filter (fun a ↦ a.fst < k),
    (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd := by
  rw [NewtonIdentities.esymm_to_weight σ R k, NewtonIdentities.esymm_mul_psum_to_weight σ R k,
    eq_comm, ← sub_eq_zero, sub_eq_add_neg, neg_mul_eq_neg_mul,
    neg_eq_neg_one_mul ((-1 : MvPolynomial σ R) ^ k)]
  

Proof state:
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
⊢ (-1) ^ (k + 1) *
        ∑ t in filter (fun t => card t.1 < k) (MvPolynomial.NewtonIdentities.pairs σ k),
          MvPolynomial.NewtonIdentities.weight σ R k t +
      -1 * (-1) ^ k *
        ∑ t in filter (fun t => card t.1 = k) (MvPolynomial.NewtonIdentities.pairs σ k),
          MvPolynomial.NewtonIdentities.weight σ R k t =
    0

Next tactic:
nth_rw 2 [← pow_one (-1 : MvPolynomial σ R)]
/-- **Newton's identities** give a recurrence relation for the kth elementary symmetric polynomial
in terms of lower degree elementary symmetric polynomials and power sums. -/
theorem mul_esymm_eq_sum (k : ℕ) : k * esymm σ R k =
    (-1) ^ (k + 1) * ∑ a in (antidiagonal k).filter (fun a ↦ a.fst < k),
    (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd := by
  rw [NewtonIdentities.esymm_to_weight σ R k, NewtonIdentities.esymm_mul_psum_to_weight σ R k,
    eq_comm, ← sub_eq_zero, sub_eq_add_neg, neg_mul_eq_neg_mul,
    neg_eq_neg_one_mul ((-1 : MvPolynomial σ R) ^ k)]
  nth_rw 2 [← pow_one (-1 : MvPolynomial σ R)]
  

Proof state:
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
⊢ (-1) ^ (k + 1) *
        ∑ t in filter (fun t => card t.1 < k) (MvPolynomial.NewtonIdentities.pairs σ k),
          MvPolynomial.NewtonIdentities.weight σ R k t +
      (-1) ^ 1 * (-1) ^ k *
        ∑ t in filter (fun t => card t.1 = k) (MvPolynomial.NewtonIdentities.pairs σ k),
          MvPolynomial.NewtonIdentities.weight σ R k t =
    0

Next tactic:
rw [← pow_add, add_comm 1 k, ← left_distrib,
    ← sum_disjUnion (NewtonIdentities.disjoint_filter_pairs_lt_filter_pairs_eq σ k),
    NewtonIdentities.disjUnion_filter_pairs_eq_pairs σ k, NewtonIdentities.weight_sum σ R k,
    neg_one_pow_mul_eq_zero_iff.mpr rfl]
theorem sum_antidiagonal_card_esymm_psum_eq_zero :
    ∑ a in antidiagonal (Fintype.card σ), (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd = 0 := by
  

Proof state:
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
⊢ ∑ a in antidiagonal (Fintype.card σ), (-1) ^ a.1 * esymm σ R a.1 * psum σ R a.2 = 0

Next tactic:
let k := Fintype.card σ
theorem sum_antidiagonal_card_esymm_psum_eq_zero :
    ∑ a in antidiagonal (Fintype.card σ), (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd = 0 := by
  let k := Fintype.card σ
  

Proof state:
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ := Fintype.card σ
⊢ ∑ a in antidiagonal (Fintype.card σ), (-1) ^ a.1 * esymm σ R a.1 * psum σ R a.2 = 0

Next tactic:
suffices : (-1 : MvPolynomial σ R) ^ (k + 1) *
    ∑ a in antidiagonal k, (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd = 0
theorem sum_antidiagonal_card_esymm_psum_eq_zero :
    ∑ a in antidiagonal (Fintype.card σ), (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd = 0 := by
  let k := Fintype.card σ
  suffices : (-1 : MvPolynomial σ R) ^ (k + 1) *
    ∑ a in antidiagonal k, (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd = 0
  · 

Proof state:
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ := Fintype.card σ
this : (-1) ^ (k + 1) * ∑ a in antidiagonal k, (-1) ^ a.1 * esymm σ R a.1 * psum σ R a.2 = 0
⊢ ∑ a in antidiagonal (Fintype.card σ), (-1) ^ a.1 * esymm σ R a.1 * psum σ R a.2 = 0

Next tactic:
simpa using this
theorem sum_antidiagonal_card_esymm_psum_eq_zero :
    ∑ a in antidiagonal (Fintype.card σ), (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd = 0 := by
  let k := Fintype.card σ
  suffices : (-1 : MvPolynomial σ R) ^ (k + 1) *
    ∑ a in antidiagonal k, (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd = 0
  · simpa using this
  

Proof state:
case this
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ := Fintype.card σ
⊢ (-1) ^ (k + 1) * ∑ a in antidiagonal k, (-1) ^ a.1 * esymm σ R a.1 * psum σ R a.2 = 0

Next tactic:
simp [← sum_filter_add_sum_filter_not (antidiagonal k) (fun a ↦ a.fst < k), ← mul_esymm_eq_sum,
    mul_add, ← mul_assoc, ← pow_add, mul_comm ↑k (esymm σ R k)]
/-- A version of Newton's identities which may be more useful in the case that we know the values of
the elementary symmetric polynomials and would like to calculate the values of the power sums. -/
theorem psum_eq_mul_esymm_sub_sum (k : ℕ) (h : 0 < k) : psum σ R k =
    (-1) ^ (k + 1) * k * esymm σ R k -
    ∑ a in (antidiagonal k).filter (fun a ↦ a.fst ∈ Set.Ioo 0 k),
    (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd := by
  

Proof state:
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
h : 0 < k
⊢ psum σ R k =
    (-1) ^ (k + 1) * ↑k * esymm σ R k -
      ∑ a in filter (fun a => a.1 ∈ Set.Ioo 0 k) (antidiagonal k), (-1) ^ a.1 * esymm σ R a.1 * psum σ R a.2

Next tactic:
simp only [Set.Ioo, Set.mem_setOf_eq, and_comm]
/-- A version of Newton's identities which may be more useful in the case that we know the values of
the elementary symmetric polynomials and would like to calculate the values of the power sums. -/
theorem psum_eq_mul_esymm_sub_sum (k : ℕ) (h : 0 < k) : psum σ R k =
    (-1) ^ (k + 1) * k * esymm σ R k -
    ∑ a in (antidiagonal k).filter (fun a ↦ a.fst ∈ Set.Ioo 0 k),
    (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd := by
  simp only [Set.Ioo, Set.mem_setOf_eq, and_comm]
  

Proof state:
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
h : 0 < k
⊢ psum σ R k =
    (-1) ^ (k + 1) * ↑k * esymm σ R k -
      ∑ x in filter (fun a => a.1 < k ∧ 0 < a.1) (antidiagonal k), (-1) ^ x.1 * esymm σ R x.1 * psum σ R x.2

Next tactic:
have hesymm := mul_esymm_eq_sum σ R k
/-- A version of Newton's identities which may be more useful in the case that we know the values of
the elementary symmetric polynomials and would like to calculate the values of the power sums. -/
theorem psum_eq_mul_esymm_sub_sum (k : ℕ) (h : 0 < k) : psum σ R k =
    (-1) ^ (k + 1) * k * esymm σ R k -
    ∑ a in (antidiagonal k).filter (fun a ↦ a.fst ∈ Set.Ioo 0 k),
    (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd := by
  simp only [Set.Ioo, Set.mem_setOf_eq, and_comm]
  have hesymm := mul_esymm_eq_sum σ R k
  

Proof state:
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
h : 0 < k
hesymm :
  ↑k * esymm σ R k =
    (-1) ^ (k + 1) * ∑ a in filter (fun a => a.1 < k) (antidiagonal k), (-1) ^ a.1 * esymm σ R a.1 * psum σ R a.2
⊢ psum σ R k =
    (-1) ^ (k + 1) * ↑k * esymm σ R k -
      ∑ x in filter (fun a => a.1 < k ∧ 0 < a.1) (antidiagonal k), (-1) ^ x.1 * esymm σ R x.1 * psum σ R x.2

Next tactic:
rw [← (sum_filter_add_sum_filter_not ((antidiagonal k).filter (fun a ↦ a.fst < k))
    (fun a ↦ 0 < a.fst) (fun a ↦ (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd))] at hesymm
/-- A version of Newton's identities which may be more useful in the case that we know the values of
the elementary symmetric polynomials and would like to calculate the values of the power sums. -/
theorem psum_eq_mul_esymm_sub_sum (k : ℕ) (h : 0 < k) : psum σ R k =
    (-1) ^ (k + 1) * k * esymm σ R k -
    ∑ a in (antidiagonal k).filter (fun a ↦ a.fst ∈ Set.Ioo 0 k),
    (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd := by
  simp only [Set.Ioo, Set.mem_setOf_eq, and_comm]
  have hesymm := mul_esymm_eq_sum σ R k
  rw [← (sum_filter_add_sum_filter_not ((antidiagonal k).filter (fun a ↦ a.fst < k))
    (fun a ↦ 0 < a.fst) (fun a ↦ (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd))] at hesymm
  

Proof state:
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
h : 0 < k
hesymm :
  ↑k * esymm σ R k =
    (-1) ^ (k + 1) *
      (∑ x in filter (fun a => 0 < a.1) (filter (fun a => a.1 < k) (antidiagonal k)),
          (-1) ^ x.1 * esymm σ R x.1 * psum σ R x.2 +
        ∑ x in filter (fun x => ¬0 < x.1) (filter (fun a => a.1 < k) (antidiagonal k)),
          (-1) ^ x.1 * esymm σ R x.1 * psum σ R x.2)
⊢ psum σ R k =
    (-1) ^ (k + 1) * ↑k * esymm σ R k -
      ∑ x in filter (fun a => a.1 < k ∧ 0 < a.1) (antidiagonal k), (-1) ^ x.1 * esymm σ R x.1 * psum σ R x.2

Next tactic:
have sub_both_sides := congrArg (· - (-1 : MvPolynomial σ R) ^ (k + 1) *
    ∑ a in ((antidiagonal k).filter (fun a ↦ a.fst < k)).filter (fun a ↦ 0 < a.fst),
    (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd) hesymm
/-- A version of Newton's identities which may be more useful in the case that we know the values of
the elementary symmetric polynomials and would like to calculate the values of the power sums. -/
theorem psum_eq_mul_esymm_sub_sum (k : ℕ) (h : 0 < k) : psum σ R k =
    (-1) ^ (k + 1) * k * esymm σ R k -
    ∑ a in (antidiagonal k).filter (fun a ↦ a.fst ∈ Set.Ioo 0 k),
    (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd := by
  simp only [Set.Ioo, Set.mem_setOf_eq, and_comm]
  have hesymm := mul_esymm_eq_sum σ R k
  rw [← (sum_filter_add_sum_filter_not ((antidiagonal k).filter (fun a ↦ a.fst < k))
    (fun a ↦ 0 < a.fst) (fun a ↦ (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd))] at hesymm
  have sub_both_sides := congrArg (· - (-1 : MvPolynomial σ R) ^ (k + 1) *
    ∑ a in ((antidiagonal k).filter (fun a ↦ a.fst < k)).filter (fun a ↦ 0 < a.fst),
    (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd) hesymm
  

Proof state:
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
h : 0 < k
hesymm :
  ↑k * esymm σ R k =
    (-1) ^ (k + 1) *
      (∑ x in filter (fun a => 0 < a.1) (filter (fun a => a.1 < k) (antidiagonal k)),
          (-1) ^ x.1 * esymm σ R x.1 * psum σ R x.2 +
        ∑ x in filter (fun x => ¬0 < x.1) (filter (fun a => a.1 < k) (antidiagonal k)),
          (-1) ^ x.1 * esymm σ R x.1 * psum σ R x.2)
sub_both_sides :
  (fun x =>
        x -
          (-1) ^ (k + 1) *
            ∑ a in filter (fun a => 0 < a.1) (filter (fun a => a.1 < k) (antidiagonal k)),
              (-1) ^ a.1 * esymm σ R a.1 * psum σ R a.2)
      (↑k * esymm σ R k) =
    (fun x =>
        x -
          (-1) ^ (k + 1) *
            ∑ a in filter (fun a => 0 < a.1) (filter (fun a => a.1 < k) (antidiagonal k)),
              (-1) ^ a.1 * esymm σ R a.1 * psum σ R a.2)
      ((-1) ^ (k + 1) *
        (∑ x in filter (fun a => 0 < a.1) (filter (fun a => a.1 < k) (antidiagonal k)),
            (-1) ^ x.1 * esymm σ R x.1 * psum σ R x.2 +
          ∑ x in filter (fun x => ¬0 < x.1) (filter (fun a => a.1 < k) (antidiagonal k)),
            (-1) ^ x.1 * esymm σ R x.1 * psum σ R x.2))
⊢ psum σ R k =
    (-1) ^ (k + 1) * ↑k * esymm σ R k -
      ∑ x in filter (fun a => a.1 < k ∧ 0 < a.1) (antidiagonal k), (-1) ^ x.1 * esymm σ R x.1 * psum σ R x.2

Next tactic:
simp only [left_distrib, add_sub_cancel'] at sub_both_sides