l3lab/ntp-mathlib huggingface dataset:
private theorem sum_filter_pairs_eq_sum_filter_antidiagonal_powersetCard_sum (k : ℕ)
    (f : Finset σ × σ → MvPolynomial σ R) :
    (∑ t in filter (fun t ↦ card t.fst < k) (pairs σ k), f t) =
    ∑ a in (antidiagonal k).filter (fun a ↦ a.fst < k),
    ∑ A in powersetCard a.fst univ, (∑ j, f (A, j)) := by
  have equiv_i (a : ℕ × ℕ) (ha : a ∈ (antidiagonal k).filter (fun a ↦ a.fst < k)) :=
    sum_filter_pairs_eq_sum_powersetCard_mem_filter_antidiagonal_sum σ R k a ha f
  simp only [← sum_congr rfl equiv_i]
  have pdisj : Set.PairwiseDisjoint ((antidiagonal k).filter (fun a ↦ a.fst < k))
      (fun (a : ℕ × ℕ) ↦ (filter (fun t ↦ card t.fst = a.fst) (pairs σ k))) := by
    simp only [Set.PairwiseDisjoint, Disjoint, pairs, filter_filter, ne_eq, le_eq_subset,
      bot_eq_empty]
    intro x hx y hy xny s hs hs' a ha
    simp only [mem_univ, forall_true_left, Prod.forall] at hs hs'
    rw [ne_eq, antidiagonal_congr (mem_filter.mp hx).left (mem_filter.mp hy).left,
      ← (mem_filter.mp (hs ha)).right.right, ← (mem_filter.mp (hs' ha)).right.right] at xny
    exact (xny rfl).elim
  have hdisj := @sum_disjiUnion _ _ _ f _ ((antidiagonal k).filter (fun a ↦ a.fst < k))
    (fun (a : ℕ × ℕ) ↦ (filter (fun t ↦ card t.fst = a.fst) (pairs σ k))) pdisj
  have disj_equiv : disjiUnion ((antidiagonal k).filter (fun a ↦ a.fst < k))
      (fun a ↦ filter (fun t ↦ card t.fst = a.fst) (pairs σ k)) pdisj =
      filter (fun t ↦ card t.fst < k) (pairs σ k) := by
    ext a
    rw [mem_disjiUnion, mem_filter]
    

Proof state:
case a
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
f : Finset σ × σ → MvPolynomial σ R
equiv_i :
  ∀ a ∈ filter (fun a => a.1 < k) (antidiagonal k),
    ∑ t in filter (fun t => card t.1 = a.1) (MvPolynomial.NewtonIdentities.pairs σ k), f t =
      ∑ A in powersetCard a.1 univ, ∑ j : σ, f (A, j)
pdisj :
  Set.PairwiseDisjoint ↑(filter (fun a => a.1 < k) (antidiagonal k)) fun a =>
    filter (fun t => card t.1 = a.1) (MvPolynomial.NewtonIdentities.pairs σ k)
hdisj :
  ∑ x in
      disjiUnion (filter (fun a => a.1 < k) (antidiagonal k))
        (fun a => filter (fun t => card t.1 = a.1) (MvPolynomial.NewtonIdentities.pairs σ k)) pdisj,
      f x =
    ∑ i in filter (fun a => a.1 < k) (antidiagonal k),
      ∑ x in filter (fun t => card t.1 = i.1) (MvPolynomial.NewtonIdentities.pairs σ k), f x
a : Finset σ × σ
⊢ (∃ a_1 ∈ filter (fun a => a.1 < k) (antidiagonal k),
      a ∈ filter (fun t => card t.1 = a_1.1) (MvPolynomial.NewtonIdentities.pairs σ k)) ↔
    a ∈ MvPolynomial.NewtonIdentities.pairs σ k ∧ card a.1 < k

Next tactic:
refine' ⟨_, fun haf ↦ ⟨(card a.fst, k - card a.fst), _, _⟩⟩
private theorem sum_filter_pairs_eq_sum_filter_antidiagonal_powersetCard_sum (k : ℕ)
    (f : Finset σ × σ → MvPolynomial σ R) :
    (∑ t in filter (fun t ↦ card t.fst < k) (pairs σ k), f t) =
    ∑ a in (antidiagonal k).filter (fun a ↦ a.fst < k),
    ∑ A in powersetCard a.fst univ, (∑ j, f (A, j)) := by
  have equiv_i (a : ℕ × ℕ) (ha : a ∈ (antidiagonal k).filter (fun a ↦ a.fst < k)) :=
    sum_filter_pairs_eq_sum_powersetCard_mem_filter_antidiagonal_sum σ R k a ha f
  simp only [← sum_congr rfl equiv_i]
  have pdisj : Set.PairwiseDisjoint ((antidiagonal k).filter (fun a ↦ a.fst < k))
      (fun (a : ℕ × ℕ) ↦ (filter (fun t ↦ card t.fst = a.fst) (pairs σ k))) := by
    simp only [Set.PairwiseDisjoint, Disjoint, pairs, filter_filter, ne_eq, le_eq_subset,
      bot_eq_empty]
    intro x hx y hy xny s hs hs' a ha
    simp only [mem_univ, forall_true_left, Prod.forall] at hs hs'
    rw [ne_eq, antidiagonal_congr (mem_filter.mp hx).left (mem_filter.mp hy).left,
      ← (mem_filter.mp (hs ha)).right.right, ← (mem_filter.mp (hs' ha)).right.right] at xny
    exact (xny rfl).elim
  have hdisj := @sum_disjiUnion _ _ _ f _ ((antidiagonal k).filter (fun a ↦ a.fst < k))
    (fun (a : ℕ × ℕ) ↦ (filter (fun t ↦ card t.fst = a.fst) (pairs σ k))) pdisj
  have disj_equiv : disjiUnion ((antidiagonal k).filter (fun a ↦ a.fst < k))
      (fun a ↦ filter (fun t ↦ card t.fst = a.fst) (pairs σ k)) pdisj =
      filter (fun t ↦ card t.fst < k) (pairs σ k) := by
    ext a
    rw [mem_disjiUnion, mem_filter]
    refine' ⟨_, fun haf ↦ ⟨(card a.fst, k - card a.fst), _, _⟩⟩
    · 

Proof state:
case a.refine'_1
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
f : Finset σ × σ → MvPolynomial σ R
equiv_i :
  ∀ a ∈ filter (fun a => a.1 < k) (antidiagonal k),
    ∑ t in filter (fun t => card t.1 = a.1) (MvPolynomial.NewtonIdentities.pairs σ k), f t =
      ∑ A in powersetCard a.1 univ, ∑ j : σ, f (A, j)
pdisj :
  Set.PairwiseDisjoint ↑(filter (fun a => a.1 < k) (antidiagonal k)) fun a =>
    filter (fun t => card t.1 = a.1) (MvPolynomial.NewtonIdentities.pairs σ k)
hdisj :
  ∑ x in
      disjiUnion (filter (fun a => a.1 < k) (antidiagonal k))
        (fun a => filter (fun t => card t.1 = a.1) (MvPolynomial.NewtonIdentities.pairs σ k)) pdisj,
      f x =
    ∑ i in filter (fun a => a.1 < k) (antidiagonal k),
      ∑ x in filter (fun t => card t.1 = i.1) (MvPolynomial.NewtonIdentities.pairs σ k), f x
a : Finset σ × σ
⊢ (∃ a_1 ∈ filter (fun a => a.1 < k) (antidiagonal k),
      a ∈ filter (fun t => card t.1 = a_1.1) (MvPolynomial.NewtonIdentities.pairs σ k)) →
    a ∈ MvPolynomial.NewtonIdentities.pairs σ k ∧ card a.1 < k

Next tactic:
rintro ⟨n, hnk, ha⟩
private theorem sum_filter_pairs_eq_sum_filter_antidiagonal_powersetCard_sum (k : ℕ)
    (f : Finset σ × σ → MvPolynomial σ R) :
    (∑ t in filter (fun t ↦ card t.fst < k) (pairs σ k), f t) =
    ∑ a in (antidiagonal k).filter (fun a ↦ a.fst < k),
    ∑ A in powersetCard a.fst univ, (∑ j, f (A, j)) := by
  have equiv_i (a : ℕ × ℕ) (ha : a ∈ (antidiagonal k).filter (fun a ↦ a.fst < k)) :=
    sum_filter_pairs_eq_sum_powersetCard_mem_filter_antidiagonal_sum σ R k a ha f
  simp only [← sum_congr rfl equiv_i]
  have pdisj : Set.PairwiseDisjoint ((antidiagonal k).filter (fun a ↦ a.fst < k))
      (fun (a : ℕ × ℕ) ↦ (filter (fun t ↦ card t.fst = a.fst) (pairs σ k))) := by
    simp only [Set.PairwiseDisjoint, Disjoint, pairs, filter_filter, ne_eq, le_eq_subset,
      bot_eq_empty]
    intro x hx y hy xny s hs hs' a ha
    simp only [mem_univ, forall_true_left, Prod.forall] at hs hs'
    rw [ne_eq, antidiagonal_congr (mem_filter.mp hx).left (mem_filter.mp hy).left,
      ← (mem_filter.mp (hs ha)).right.right, ← (mem_filter.mp (hs' ha)).right.right] at xny
    exact (xny rfl).elim
  have hdisj := @sum_disjiUnion _ _ _ f _ ((antidiagonal k).filter (fun a ↦ a.fst < k))
    (fun (a : ℕ × ℕ) ↦ (filter (fun t ↦ card t.fst = a.fst) (pairs σ k))) pdisj
  have disj_equiv : disjiUnion ((antidiagonal k).filter (fun a ↦ a.fst < k))
      (fun a ↦ filter (fun t ↦ card t.fst = a.fst) (pairs σ k)) pdisj =
      filter (fun t ↦ card t.fst < k) (pairs σ k) := by
    ext a
    rw [mem_disjiUnion, mem_filter]
    refine' ⟨_, fun haf ↦ ⟨(card a.fst, k - card a.fst), _, _⟩⟩
    · rintro ⟨n, hnk, ha⟩
      

Proof state:
case a.refine'_1.intro.intro
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
f : Finset σ × σ → MvPolynomial σ R
equiv_i :
  ∀ a ∈ filter (fun a => a.1 < k) (antidiagonal k),
    ∑ t in filter (fun t => card t.1 = a.1) (MvPolynomial.NewtonIdentities.pairs σ k), f t =
      ∑ A in powersetCard a.1 univ, ∑ j : σ, f (A, j)
pdisj :
  Set.PairwiseDisjoint ↑(filter (fun a => a.1 < k) (antidiagonal k)) fun a =>
    filter (fun t => card t.1 = a.1) (MvPolynomial.NewtonIdentities.pairs σ k)
hdisj :
  ∑ x in
      disjiUnion (filter (fun a => a.1 < k) (antidiagonal k))
        (fun a => filter (fun t => card t.1 = a.1) (MvPolynomial.NewtonIdentities.pairs σ k)) pdisj,
      f x =
    ∑ i in filter (fun a => a.1 < k) (antidiagonal k),
      ∑ x in filter (fun t => card t.1 = i.1) (MvPolynomial.NewtonIdentities.pairs σ k), f x
a : Finset σ × σ
n : ℕ × ℕ
hnk : n ∈ filter (fun a => a.1 < k) (antidiagonal k)
ha : a ∈ filter (fun t => card t.1 = n.1) (MvPolynomial.NewtonIdentities.pairs σ k)
⊢ a ∈ MvPolynomial.NewtonIdentities.pairs σ k ∧ card a.1 < k

Next tactic:
have hnk' : n.fst ≤ k := by apply le_of_lt; aesop
private theorem sum_filter_pairs_eq_sum_filter_antidiagonal_powersetCard_sum (k : ℕ)
    (f : Finset σ × σ → MvPolynomial σ R) :
    (∑ t in filter (fun t ↦ card t.fst < k) (pairs σ k), f t) =
    ∑ a in (antidiagonal k).filter (fun a ↦ a.fst < k),
    ∑ A in powersetCard a.fst univ, (∑ j, f (A, j)) := by
  have equiv_i (a : ℕ × ℕ) (ha : a ∈ (antidiagonal k).filter (fun a ↦ a.fst < k)) :=
    sum_filter_pairs_eq_sum_powersetCard_mem_filter_antidiagonal_sum σ R k a ha f
  simp only [← sum_congr rfl equiv_i]
  have pdisj : Set.PairwiseDisjoint ((antidiagonal k).filter (fun a ↦ a.fst < k))
      (fun (a : ℕ × ℕ) ↦ (filter (fun t ↦ card t.fst = a.fst) (pairs σ k))) := by
    simp only [Set.PairwiseDisjoint, Disjoint, pairs, filter_filter, ne_eq, le_eq_subset,
      bot_eq_empty]
    intro x hx y hy xny s hs hs' a ha
    simp only [mem_univ, forall_true_left, Prod.forall] at hs hs'
    rw [ne_eq, antidiagonal_congr (mem_filter.mp hx).left (mem_filter.mp hy).left,
      ← (mem_filter.mp (hs ha)).right.right, ← (mem_filter.mp (hs' ha)).right.right] at xny
    exact (xny rfl).elim
  have hdisj := @sum_disjiUnion _ _ _ f _ ((antidiagonal k).filter (fun a ↦ a.fst < k))
    (fun (a : ℕ × ℕ) ↦ (filter (fun t ↦ card t.fst = a.fst) (pairs σ k))) pdisj
  have disj_equiv : disjiUnion ((antidiagonal k).filter (fun a ↦ a.fst < k))
      (fun a ↦ filter (fun t ↦ card t.fst = a.fst) (pairs σ k)) pdisj =
      filter (fun t ↦ card t.fst < k) (pairs σ k) := by
    ext a
    rw [mem_disjiUnion, mem_filter]
    refine' ⟨_, fun haf ↦ ⟨(card a.fst, k - card a.fst), _, _⟩⟩
    · rintro ⟨n, hnk, ha⟩
      have hnk' : n.fst ≤ k := by 

Proof state:
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
f : Finset σ × σ → MvPolynomial σ R
equiv_i :
  ∀ a ∈ filter (fun a => a.1 < k) (antidiagonal k),
    ∑ t in filter (fun t => card t.1 = a.1) (MvPolynomial.NewtonIdentities.pairs σ k), f t =
      ∑ A in powersetCard a.1 univ, ∑ j : σ, f (A, j)
pdisj :
  Set.PairwiseDisjoint ↑(filter (fun a => a.1 < k) (antidiagonal k)) fun a =>
    filter (fun t => card t.1 = a.1) (MvPolynomial.NewtonIdentities.pairs σ k)
hdisj :
  ∑ x in
      disjiUnion (filter (fun a => a.1 < k) (antidiagonal k))
        (fun a => filter (fun t => card t.1 = a.1) (MvPolynomial.NewtonIdentities.pairs σ k)) pdisj,
      f x =
    ∑ i in filter (fun a => a.1 < k) (antidiagonal k),
      ∑ x in filter (fun t => card t.1 = i.1) (MvPolynomial.NewtonIdentities.pairs σ k), f x
a : Finset σ × σ
n : ℕ × ℕ
hnk : n ∈ filter (fun a => a.1 < k) (antidiagonal k)
ha : a ∈ filter (fun t => card t.1 = n.1) (MvPolynomial.NewtonIdentities.pairs σ k)
⊢ n.1 ≤ k

Next tactic:
apply le_of_lt
private theorem sum_filter_pairs_eq_sum_filter_antidiagonal_powersetCard_sum (k : ℕ)
    (f : Finset σ × σ → MvPolynomial σ R) :
    (∑ t in filter (fun t ↦ card t.fst < k) (pairs σ k), f t) =
    ∑ a in (antidiagonal k).filter (fun a ↦ a.fst < k),
    ∑ A in powersetCard a.fst univ, (∑ j, f (A, j)) := by
  have equiv_i (a : ℕ × ℕ) (ha : a ∈ (antidiagonal k).filter (fun a ↦ a.fst < k)) :=
    sum_filter_pairs_eq_sum_powersetCard_mem_filter_antidiagonal_sum σ R k a ha f
  simp only [← sum_congr rfl equiv_i]
  have pdisj : Set.PairwiseDisjoint ((antidiagonal k).filter (fun a ↦ a.fst < k))
      (fun (a : ℕ × ℕ) ↦ (filter (fun t ↦ card t.fst = a.fst) (pairs σ k))) := by
    simp only [Set.PairwiseDisjoint, Disjoint, pairs, filter_filter, ne_eq, le_eq_subset,
      bot_eq_empty]
    intro x hx y hy xny s hs hs' a ha
    simp only [mem_univ, forall_true_left, Prod.forall] at hs hs'
    rw [ne_eq, antidiagonal_congr (mem_filter.mp hx).left (mem_filter.mp hy).left,
      ← (mem_filter.mp (hs ha)).right.right, ← (mem_filter.mp (hs' ha)).right.right] at xny
    exact (xny rfl).elim
  have hdisj := @sum_disjiUnion _ _ _ f _ ((antidiagonal k).filter (fun a ↦ a.fst < k))
    (fun (a : ℕ × ℕ) ↦ (filter (fun t ↦ card t.fst = a.fst) (pairs σ k))) pdisj
  have disj_equiv : disjiUnion ((antidiagonal k).filter (fun a ↦ a.fst < k))
      (fun a ↦ filter (fun t ↦ card t.fst = a.fst) (pairs σ k)) pdisj =
      filter (fun t ↦ card t.fst < k) (pairs σ k) := by
    ext a
    rw [mem_disjiUnion, mem_filter]
    refine' ⟨_, fun haf ↦ ⟨(card a.fst, k - card a.fst), _, _⟩⟩
    · rintro ⟨n, hnk, ha⟩
      have hnk' : n.fst ≤ k := by apply le_of_lt; 

Proof state:
case a
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
f : Finset σ × σ → MvPolynomial σ R
equiv_i :
  ∀ a ∈ filter (fun a => a.1 < k) (antidiagonal k),
    ∑ t in filter (fun t => card t.1 = a.1) (MvPolynomial.NewtonIdentities.pairs σ k), f t =
      ∑ A in powersetCard a.1 univ, ∑ j : σ, f (A, j)
pdisj :
  Set.PairwiseDisjoint ↑(filter (fun a => a.1 < k) (antidiagonal k)) fun a =>
    filter (fun t => card t.1 = a.1) (MvPolynomial.NewtonIdentities.pairs σ k)
hdisj :
  ∑ x in
      disjiUnion (filter (fun a => a.1 < k) (antidiagonal k))
        (fun a => filter (fun t => card t.1 = a.1) (MvPolynomial.NewtonIdentities.pairs σ k)) pdisj,
      f x =
    ∑ i in filter (fun a => a.1 < k) (antidiagonal k),
      ∑ x in filter (fun t => card t.1 = i.1) (MvPolynomial.NewtonIdentities.pairs σ k), f x
a : Finset σ × σ
n : ℕ × ℕ
hnk : n ∈ filter (fun a => a.1 < k) (antidiagonal k)
ha : a ∈ filter (fun t => card t.1 = n.1) (MvPolynomial.NewtonIdentities.pairs σ k)
⊢ n.1 < k

Next tactic:
aesop
private theorem sum_filter_pairs_eq_sum_filter_antidiagonal_powersetCard_sum (k : ℕ)
    (f : Finset σ × σ → MvPolynomial σ R) :
    (∑ t in filter (fun t ↦ card t.fst < k) (pairs σ k), f t) =
    ∑ a in (antidiagonal k).filter (fun a ↦ a.fst < k),
    ∑ A in powersetCard a.fst univ, (∑ j, f (A, j)) := by
  have equiv_i (a : ℕ × ℕ) (ha : a ∈ (antidiagonal k).filter (fun a ↦ a.fst < k)) :=
    sum_filter_pairs_eq_sum_powersetCard_mem_filter_antidiagonal_sum σ R k a ha f
  simp only [← sum_congr rfl equiv_i]
  have pdisj : Set.PairwiseDisjoint ((antidiagonal k).filter (fun a ↦ a.fst < k))
      (fun (a : ℕ × ℕ) ↦ (filter (fun t ↦ card t.fst = a.fst) (pairs σ k))) := by
    simp only [Set.PairwiseDisjoint, Disjoint, pairs, filter_filter, ne_eq, le_eq_subset,
      bot_eq_empty]
    intro x hx y hy xny s hs hs' a ha
    simp only [mem_univ, forall_true_left, Prod.forall] at hs hs'
    rw [ne_eq, antidiagonal_congr (mem_filter.mp hx).left (mem_filter.mp hy).left,
      ← (mem_filter.mp (hs ha)).right.right, ← (mem_filter.mp (hs' ha)).right.right] at xny
    exact (xny rfl).elim
  have hdisj := @sum_disjiUnion _ _ _ f _ ((antidiagonal k).filter (fun a ↦ a.fst < k))
    (fun (a : ℕ × ℕ) ↦ (filter (fun t ↦ card t.fst = a.fst) (pairs σ k))) pdisj
  have disj_equiv : disjiUnion ((antidiagonal k).filter (fun a ↦ a.fst < k))
      (fun a ↦ filter (fun t ↦ card t.fst = a.fst) (pairs σ k)) pdisj =
      filter (fun t ↦ card t.fst < k) (pairs σ k) := by
    ext a
    rw [mem_disjiUnion, mem_filter]
    refine' ⟨_, fun haf ↦ ⟨(card a.fst, k - card a.fst), _, _⟩⟩
    · rintro ⟨n, hnk, ha⟩
      have hnk' : n.fst ≤ k := by apply le_of_lt; aesop
      

Proof state:
case a.refine'_1.intro.intro
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
f : Finset σ × σ → MvPolynomial σ R
equiv_i :
  ∀ a ∈ filter (fun a => a.1 < k) (antidiagonal k),
    ∑ t in filter (fun t => card t.1 = a.1) (MvPolynomial.NewtonIdentities.pairs σ k), f t =
      ∑ A in powersetCard a.1 univ, ∑ j : σ, f (A, j)
pdisj :
  Set.PairwiseDisjoint ↑(filter (fun a => a.1 < k) (antidiagonal k)) fun a =>
    filter (fun t => card t.1 = a.1) (MvPolynomial.NewtonIdentities.pairs σ k)
hdisj :
  ∑ x in
      disjiUnion (filter (fun a => a.1 < k) (antidiagonal k))
        (fun a => filter (fun t => card t.1 = a.1) (MvPolynomial.NewtonIdentities.pairs σ k)) pdisj,
      f x =
    ∑ i in filter (fun a => a.1 < k) (antidiagonal k),
      ∑ x in filter (fun t => card t.1 = i.1) (MvPolynomial.NewtonIdentities.pairs σ k), f x
a : Finset σ × σ
n : ℕ × ℕ
hnk : n ∈ filter (fun a => a.1 < k) (antidiagonal k)
ha : a ∈ filter (fun t => card t.1 = n.1) (MvPolynomial.NewtonIdentities.pairs σ k)
hnk' : n.1 ≤ k
⊢ a ∈ MvPolynomial.NewtonIdentities.pairs σ k ∧ card a.1 < k

Next tactic:
aesop
private theorem sum_filter_pairs_eq_sum_filter_antidiagonal_powersetCard_sum (k : ℕ)
    (f : Finset σ × σ → MvPolynomial σ R) :
    (∑ t in filter (fun t ↦ card t.fst < k) (pairs σ k), f t) =
    ∑ a in (antidiagonal k).filter (fun a ↦ a.fst < k),
    ∑ A in powersetCard a.fst univ, (∑ j, f (A, j)) := by
  have equiv_i (a : ℕ × ℕ) (ha : a ∈ (antidiagonal k).filter (fun a ↦ a.fst < k)) :=
    sum_filter_pairs_eq_sum_powersetCard_mem_filter_antidiagonal_sum σ R k a ha f
  simp only [← sum_congr rfl equiv_i]
  have pdisj : Set.PairwiseDisjoint ((antidiagonal k).filter (fun a ↦ a.fst < k))
      (fun (a : ℕ × ℕ) ↦ (filter (fun t ↦ card t.fst = a.fst) (pairs σ k))) := by
    simp only [Set.PairwiseDisjoint, Disjoint, pairs, filter_filter, ne_eq, le_eq_subset,
      bot_eq_empty]
    intro x hx y hy xny s hs hs' a ha
    simp only [mem_univ, forall_true_left, Prod.forall] at hs hs'
    rw [ne_eq, antidiagonal_congr (mem_filter.mp hx).left (mem_filter.mp hy).left,
      ← (mem_filter.mp (hs ha)).right.right, ← (mem_filter.mp (hs' ha)).right.right] at xny
    exact (xny rfl).elim
  have hdisj := @sum_disjiUnion _ _ _ f _ ((antidiagonal k).filter (fun a ↦ a.fst < k))
    (fun (a : ℕ × ℕ) ↦ (filter (fun t ↦ card t.fst = a.fst) (pairs σ k))) pdisj
  have disj_equiv : disjiUnion ((antidiagonal k).filter (fun a ↦ a.fst < k))
      (fun a ↦ filter (fun t ↦ card t.fst = a.fst) (pairs σ k)) pdisj =
      filter (fun t ↦ card t.fst < k) (pairs σ k) := by
    ext a
    rw [mem_disjiUnion, mem_filter]
    refine' ⟨_, fun haf ↦ ⟨(card a.fst, k - card a.fst), _, _⟩⟩
    · rintro ⟨n, hnk, ha⟩
      have hnk' : n.fst ≤ k := by apply le_of_lt; aesop
      aesop
    · 

Proof state:
case a.refine'_2
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
f : Finset σ × σ → MvPolynomial σ R
equiv_i :
  ∀ a ∈ filter (fun a => a.1 < k) (antidiagonal k),
    ∑ t in filter (fun t => card t.1 = a.1) (MvPolynomial.NewtonIdentities.pairs σ k), f t =
      ∑ A in powersetCard a.1 univ, ∑ j : σ, f (A, j)
pdisj :
  Set.PairwiseDisjoint ↑(filter (fun a => a.1 < k) (antidiagonal k)) fun a =>
    filter (fun t => card t.1 = a.1) (MvPolynomial.NewtonIdentities.pairs σ k)
hdisj :
  ∑ x in
      disjiUnion (filter (fun a => a.1 < k) (antidiagonal k))
        (fun a => filter (fun t => card t.1 = a.1) (MvPolynomial.NewtonIdentities.pairs σ k)) pdisj,
      f x =
    ∑ i in filter (fun a => a.1 < k) (antidiagonal k),
      ∑ x in filter (fun t => card t.1 = i.1) (MvPolynomial.NewtonIdentities.pairs σ k), f x
a : Finset σ × σ
haf : a ∈ MvPolynomial.NewtonIdentities.pairs σ k ∧ card a.1 < k
⊢ (card a.1, k - card a.1) ∈ filter (fun a => a.1 < k) (antidiagonal k)

Next tactic:
simp_all only [mem_antidiagonal, mem_filter, mem_pairs, disjiUnion_eq_biUnion,
        add_tsub_cancel_of_le, and_true]
private theorem sum_filter_pairs_eq_sum_filter_antidiagonal_powersetCard_sum (k : ℕ)
    (f : Finset σ × σ → MvPolynomial σ R) :
    (∑ t in filter (fun t ↦ card t.fst < k) (pairs σ k), f t) =
    ∑ a in (antidiagonal k).filter (fun a ↦ a.fst < k),
    ∑ A in powersetCard a.fst univ, (∑ j, f (A, j)) := by
  have equiv_i (a : ℕ × ℕ) (ha : a ∈ (antidiagonal k).filter (fun a ↦ a.fst < k)) :=
    sum_filter_pairs_eq_sum_powersetCard_mem_filter_antidiagonal_sum σ R k a ha f
  simp only [← sum_congr rfl equiv_i]
  have pdisj : Set.PairwiseDisjoint ((antidiagonal k).filter (fun a ↦ a.fst < k))
      (fun (a : ℕ × ℕ) ↦ (filter (fun t ↦ card t.fst = a.fst) (pairs σ k))) := by
    simp only [Set.PairwiseDisjoint, Disjoint, pairs, filter_filter, ne_eq, le_eq_subset,
      bot_eq_empty]
    intro x hx y hy xny s hs hs' a ha
    simp only [mem_univ, forall_true_left, Prod.forall] at hs hs'
    rw [ne_eq, antidiagonal_congr (mem_filter.mp hx).left (mem_filter.mp hy).left,
      ← (mem_filter.mp (hs ha)).right.right, ← (mem_filter.mp (hs' ha)).right.right] at xny
    exact (xny rfl).elim
  have hdisj := @sum_disjiUnion _ _ _ f _ ((antidiagonal k).filter (fun a ↦ a.fst < k))
    (fun (a : ℕ × ℕ) ↦ (filter (fun t ↦ card t.fst = a.fst) (pairs σ k))) pdisj
  have disj_equiv : disjiUnion ((antidiagonal k).filter (fun a ↦ a.fst < k))
      (fun a ↦ filter (fun t ↦ card t.fst = a.fst) (pairs σ k)) pdisj =
      filter (fun t ↦ card t.fst < k) (pairs σ k) := by
    ext a
    rw [mem_disjiUnion, mem_filter]
    refine' ⟨_, fun haf ↦ ⟨(card a.fst, k - card a.fst), _, _⟩⟩
    · rintro ⟨n, hnk, ha⟩
      have hnk' : n.fst ≤ k := by apply le_of_lt; aesop
      aesop
    · simp_all only [mem_antidiagonal, mem_filter, mem_pairs, disjiUnion_eq_biUnion,
        add_tsub_cancel_of_le, and_true]
    · 

Proof state:
case a.refine'_3
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
f : Finset σ × σ → MvPolynomial σ R
equiv_i :
  ∀ a ∈ filter (fun a => a.1 < k) (antidiagonal k),
    ∑ t in filter (fun t => card t.1 = a.1) (MvPolynomial.NewtonIdentities.pairs σ k), f t =
      ∑ A in powersetCard a.1 univ, ∑ j : σ, f (A, j)
pdisj :
  Set.PairwiseDisjoint ↑(filter (fun a => a.1 < k) (antidiagonal k)) fun a =>
    filter (fun t => card t.1 = a.1) (MvPolynomial.NewtonIdentities.pairs σ k)
hdisj :
  ∑ x in
      disjiUnion (filter (fun a => a.1 < k) (antidiagonal k))
        (fun a => filter (fun t => card t.1 = a.1) (MvPolynomial.NewtonIdentities.pairs σ k)) pdisj,
      f x =
    ∑ i in filter (fun a => a.1 < k) (antidiagonal k),
      ∑ x in filter (fun t => card t.1 = i.1) (MvPolynomial.NewtonIdentities.pairs σ k), f x
a : Finset σ × σ
haf : a ∈ MvPolynomial.NewtonIdentities.pairs σ k ∧ card a.1 < k
⊢ a ∈ filter (fun t => card t.1 = (card a.1, k - card a.1).1) (MvPolynomial.NewtonIdentities.pairs σ k)

Next tactic:
simp_all only [mem_antidiagonal, mem_filter, mem_pairs, disjiUnion_eq_biUnion,
        implies_true, and_true]
private theorem disjoint_filter_pairs_lt_filter_pairs_eq (k : ℕ) :
    Disjoint (filter (fun t ↦ card t.fst < k) (pairs σ k))
    (filter (fun t ↦ card t.fst = k) (pairs σ k)) := by
  

Proof state:
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
⊢ Disjoint (filter (fun t => card t.1 < k) (MvPolynomial.NewtonIdentities.pairs σ k))
    (filter (fun t => card t.1 = k) (MvPolynomial.NewtonIdentities.pairs σ k))

Next tactic:
rw [disjoint_filter]
private theorem disjoint_filter_pairs_lt_filter_pairs_eq (k : ℕ) :
    Disjoint (filter (fun t ↦ card t.fst < k) (pairs σ k))
    (filter (fun t ↦ card t.fst = k) (pairs σ k)) := by
  rw [disjoint_filter]
  

Proof state:
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
⊢ ∀ x ∈ MvPolynomial.NewtonIdentities.pairs σ k, card x.1 < k → ¬card x.1 = k

Next tactic:
exact fun _ _ h1 h2 ↦ lt_irrefl _ (h2.symm.subst h1)
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
  

Proof state:
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
⊢ disjUnion (filter (fun t => card t.1 < k) (MvPolynomial.NewtonIdentities.pairs σ k))
      (filter (fun t => card t.1 = k) (MvPolynomial.NewtonIdentities.pairs σ k))
      (_ :
        Disjoint (filter (fun t => card t.1 < k) (MvPolynomial.NewtonIdentities.pairs σ k))
          (filter (fun t => card t.1 = k) (MvPolynomial.NewtonIdentities.pairs σ k))) =
    MvPolynomial.NewtonIdentities.pairs σ k

Next tactic:
simp only [disjUnion_eq_union, Finset.ext_iff, pairs, filter_filter, mem_filter]