[GOAL]
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
t : Finset σ × σ
⊢ t ∈ MvPolynomial.NewtonIdentities.pairs σ k ↔ card t.fst ≤ k ∧ (card t.fst = k → t.snd ∈ t.fst)
[PROOFSTEP]
simp [pairs]
[GOAL]
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
t : Finset σ × σ
⊢ MvPolynomial.NewtonIdentities.pairMap σ t ≠ t
[PROOFSTEP]
rw [pairMap]
[GOAL]
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
t : Finset σ × σ
⊢ (if h : t.snd ∈ t.fst then (erase t.fst t.snd, t.snd) else (cons t.snd t.fst h, t.snd)) ≠ t
[PROOFSTEP]
split_ifs with h1
[GOAL]
case pos
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
t : Finset σ × σ
h1 : t.snd ∈ t.fst
⊢ (erase t.fst t.snd, t.snd) ≠ t
case neg
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
t : Finset σ × σ
h1 : ¬t.snd ∈ t.fst
⊢ (cons t.snd t.fst h1, t.snd) ≠ t
[PROOFSTEP]
all_goals by_contra ht; rw [← ht] at h1 ; simp_all
[GOAL]
case pos
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
t : Finset σ × σ
h1 : t.snd ∈ t.fst
⊢ (erase t.fst t.snd, t.snd) ≠ t
[PROOFSTEP]
by_contra ht
[GOAL]
case pos
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
t : Finset σ × σ
h1 : t.snd ∈ t.fst
ht : (erase t.fst t.snd, t.snd) = t
⊢ False
[PROOFSTEP]
rw [← ht] at h1 
[GOAL]
case pos
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
t : Finset σ × σ
h1 : (erase t.fst t.snd, t.snd).snd ∈ (erase t.fst t.snd, t.snd).fst
ht : (erase t.fst t.snd, t.snd) = t
⊢ False
[PROOFSTEP]
simp_all
[GOAL]
case neg
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
t : Finset σ × σ
h1 : ¬t.snd ∈ t.fst
⊢ (cons t.snd t.fst h1, t.snd) ≠ t
[PROOFSTEP]
by_contra ht
[GOAL]
case neg
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
t : Finset σ × σ
h1 : ¬t.snd ∈ t.fst
ht : (cons t.snd t.fst h1, t.snd) = t
⊢ False
[PROOFSTEP]
rw [← ht] at h1 
[GOAL]
case neg
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
t : Finset σ × σ
h1✝ : ¬t.snd ∈ t.fst
h1 : ¬(cons t.snd t.fst h1✝, t.snd).snd ∈ (cons t.snd t.fst h1✝, t.snd).fst
ht : (cons t.snd t.fst h1✝, t.snd) = t
⊢ False
[PROOFSTEP]
simp_all
[GOAL]
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
t : Finset σ × σ
h : t.snd ∈ t.fst
⊢ MvPolynomial.NewtonIdentities.pairMap σ t = (erase t.fst t.snd, t.snd)
[PROOFSTEP]
simp [pairMap, h]
[GOAL]
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
t : Finset σ × σ
h : ¬t.snd ∈ t.fst
⊢ MvPolynomial.NewtonIdentities.pairMap σ t = (cons t.snd t.fst h, t.snd)
[PROOFSTEP]
simp [pairMap, h]
[GOAL]
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
t : Finset σ × σ
h : t ∈ MvPolynomial.NewtonIdentities.pairs σ k
⊢ MvPolynomial.NewtonIdentities.pairMap σ t ∈ MvPolynomial.NewtonIdentities.pairs σ k
[PROOFSTEP]
rw [mem_pairs] at h ⊢
[GOAL]
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
t : Finset σ × σ
h : card t.fst ≤ k ∧ (card t.fst = k → t.snd ∈ t.fst)
⊢ card (MvPolynomial.NewtonIdentities.pairMap σ t).fst ≤ k ∧
    (card (MvPolynomial.NewtonIdentities.pairMap σ t).fst = k →
      (MvPolynomial.NewtonIdentities.pairMap σ t).snd ∈ (MvPolynomial.NewtonIdentities.pairMap σ t).fst)
[PROOFSTEP]
rcases(em (t.snd ∈ t.fst)) with h1 | h1
[GOAL]
case inl
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
t : Finset σ × σ
h : card t.fst ≤ k ∧ (card t.fst = k → t.snd ∈ t.fst)
h1 : t.snd ∈ t.fst
⊢ card (MvPolynomial.NewtonIdentities.pairMap σ t).fst ≤ k ∧
    (card (MvPolynomial.NewtonIdentities.pairMap σ t).fst = k →
      (MvPolynomial.NewtonIdentities.pairMap σ t).snd ∈ (MvPolynomial.NewtonIdentities.pairMap σ t).fst)
[PROOFSTEP]
rw [pairMap_of_snd_mem_fst σ h1]
[GOAL]
case inl
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
t : Finset σ × σ
h : card t.fst ≤ k ∧ (card t.fst = k → t.snd ∈ t.fst)
h1 : t.snd ∈ t.fst
⊢ card (erase t.fst t.snd, t.snd).fst ≤ k ∧
    (card (erase t.fst t.snd, t.snd).fst = k → (erase t.fst t.snd, t.snd).snd ∈ (erase t.fst t.snd, t.snd).fst)
[PROOFSTEP]
simp only [h1, implies_true, and_true] at h 
[GOAL]
case inl
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
t : Finset σ × σ
h1 : t.snd ∈ t.fst
h : card t.fst ≤ k
⊢ card (erase t.fst t.snd, t.snd).fst ≤ k ∧
    (card (erase t.fst t.snd, t.snd).fst = k → (erase t.fst t.snd, t.snd).snd ∈ (erase t.fst t.snd, t.snd).fst)
[PROOFSTEP]
simp only [card_erase_of_mem h1, tsub_le_iff_right, mem_erase, ne_eq, h1]
[GOAL]
case inl
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
t : Finset σ × σ
h1 : t.snd ∈ t.fst
h : card t.fst ≤ k
⊢ card t.fst ≤ k + 1 ∧ (card t.fst - 1 = k → False)
[PROOFSTEP]
refine ⟨le_step h, ?_⟩
[GOAL]
case inl
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
t : Finset σ × σ
h1 : t.snd ∈ t.fst
h : card t.fst ≤ k
⊢ card t.fst - 1 = k → False
[PROOFSTEP]
by_contra h2
[GOAL]
case inl
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
t : Finset σ × σ
h1 : t.snd ∈ t.fst
h : card t.fst ≤ k
h2 : card t.fst - 1 = k
⊢ False
[PROOFSTEP]
rw [← h2] at h 
[GOAL]
case inl
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
t : Finset σ × σ
h1 : t.snd ∈ t.fst
h : card t.fst ≤ card t.fst - 1
h2 : card t.fst - 1 = k
⊢ False
[PROOFSTEP]
exact not_le_of_lt (sub_lt (card_pos.mpr ⟨t.snd, h1⟩) zero_lt_one) h
[GOAL]
case inr
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
t : Finset σ × σ
h : card t.fst ≤ k ∧ (card t.fst = k → t.snd ∈ t.fst)
h1 : ¬t.snd ∈ t.fst
⊢ card (MvPolynomial.NewtonIdentities.pairMap σ t).fst ≤ k ∧
    (card (MvPolynomial.NewtonIdentities.pairMap σ t).fst = k →
      (MvPolynomial.NewtonIdentities.pairMap σ t).snd ∈ (MvPolynomial.NewtonIdentities.pairMap σ t).fst)
[PROOFSTEP]
rw [pairMap_of_snd_nmem_fst σ h1]
[GOAL]
case inr
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
t : Finset σ × σ
h : card t.fst ≤ k ∧ (card t.fst = k → t.snd ∈ t.fst)
h1 : ¬t.snd ∈ t.fst
⊢ card (cons t.snd t.fst h1, t.snd).fst ≤ k ∧
    (card (cons t.snd t.fst h1, t.snd).fst = k → (cons t.snd t.fst h1, t.snd).snd ∈ (cons t.snd t.fst h1, t.snd).fst)
[PROOFSTEP]
simp only [h1] at h 
[GOAL]
case inr
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
t : Finset σ × σ
h1 : ¬t.snd ∈ t.fst
h : card t.fst ≤ k ∧ (card t.fst = k → False)
⊢ card (cons t.snd t.fst h1, t.snd).fst ≤ k ∧
    (card (cons t.snd t.fst h1, t.snd).fst = k → (cons t.snd t.fst h1, t.snd).snd ∈ (cons t.snd t.fst h1, t.snd).fst)
[PROOFSTEP]
simp only [card_cons, mem_cons, true_or, implies_true, and_true]
[GOAL]
case inr
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
t : Finset σ × σ
h1 : ¬t.snd ∈ t.fst
h : card t.fst ≤ k ∧ (card t.fst = k → False)
⊢ card t.fst + 1 ≤ k
[PROOFSTEP]
exact (le_iff_eq_or_lt.mp h.left).resolve_left h.right
[GOAL]
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
⊢ Function.Involutive (MvPolynomial.NewtonIdentities.pairMap σ)
[PROOFSTEP]
intro t
[GOAL]
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
t : Finset σ × σ
⊢ MvPolynomial.NewtonIdentities.pairMap σ (MvPolynomial.NewtonIdentities.pairMap σ t) = t
[PROOFSTEP]
rw [pairMap, pairMap]
[GOAL]
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
t : Finset σ × σ
⊢ (if h :
        (if h : t.snd ∈ t.fst then (erase t.fst t.snd, t.snd) else (cons t.snd t.fst h, t.snd)).snd ∈
          (if h : t.snd ∈ t.fst then (erase t.fst t.snd, t.snd) else (cons t.snd t.fst h, t.snd)).fst then
      (erase (if h : t.snd ∈ t.fst then (erase t.fst t.snd, t.snd) else (cons t.snd t.fst h, t.snd)).fst
          (if h : t.snd ∈ t.fst then (erase t.fst t.snd, t.snd) else (cons t.snd t.fst h, t.snd)).snd,
        (if h : t.snd ∈ t.fst then (erase t.fst t.snd, t.snd) else (cons t.snd t.fst h, t.snd)).snd)
    else
      (cons (if h : t.snd ∈ t.fst then (erase t.fst t.snd, t.snd) else (cons t.snd t.fst h, t.snd)).snd
          (if h : t.snd ∈ t.fst then (erase t.fst t.snd, t.snd) else (cons t.snd t.fst h, t.snd)).fst h,
        (if h : t.snd ∈ t.fst then (erase t.fst t.snd, t.snd) else (cons t.snd t.fst h, t.snd)).snd)) =
    t
[PROOFSTEP]
split_ifs with h1 h2 h3
[GOAL]
case pos
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
t : Finset σ × σ
h1 : t.snd ∈ t.fst
h2 : (erase t.fst t.snd, t.snd).snd ∈ (erase t.fst t.snd, t.snd).fst
⊢ (erase (erase t.fst t.snd, t.snd).fst (erase t.fst t.snd, t.snd).snd, (erase t.fst t.snd, t.snd).snd) = t
[PROOFSTEP]
simp at h2 
[GOAL]
case neg
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
t : Finset σ × σ
h1 : t.snd ∈ t.fst
h2 : ¬(erase t.fst t.snd, t.snd).snd ∈ (erase t.fst t.snd, t.snd).fst
⊢ (cons (erase t.fst t.snd, t.snd).snd (erase t.fst t.snd, t.snd).fst
        (_ : ¬(erase t.fst t.snd, t.snd).snd ∈ (erase t.fst t.snd, t.snd).fst),
      (erase t.fst t.snd, t.snd).snd) =
    t
[PROOFSTEP]
simp [insert_erase h1]
[GOAL]
case pos
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
t : Finset σ × σ
h1 : ¬t.snd ∈ t.fst
h3 : (cons t.snd t.fst h1, t.snd).snd ∈ (cons t.snd t.fst h1, t.snd).fst
⊢ (erase (cons t.snd t.fst h1, t.snd).fst (cons t.snd t.fst h1, t.snd).snd, (cons t.snd t.fst h1, t.snd).snd) = t
[PROOFSTEP]
simp_all
[GOAL]
case neg
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
t : Finset σ × σ
h1 : ¬t.snd ∈ t.fst
h3 : ¬(cons t.snd t.fst h1, t.snd).snd ∈ (cons t.snd t.fst h1, t.snd).fst
⊢ (cons (cons t.snd t.fst h1, t.snd).snd (cons t.snd t.fst h1, t.snd).fst
        (_ : ¬(cons t.snd t.fst h1, t.snd).snd ∈ (cons t.snd t.fst h1, t.snd).fst),
      (cons t.snd t.fst h1, t.snd).snd) =
    t
[PROOFSTEP]
simp at h3 
[GOAL]
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
t : Finset σ × σ
h : t ∈ MvPolynomial.NewtonIdentities.pairs σ k
⊢ MvPolynomial.NewtonIdentities.weight σ R k t +
      MvPolynomial.NewtonIdentities.weight σ R k (MvPolynomial.NewtonIdentities.pairMap σ t) =
    0
[PROOFSTEP]
rw [weight, weight]
[GOAL]
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
t : Finset σ × σ
h : t ∈ MvPolynomial.NewtonIdentities.pairs σ k
⊢ (-1) ^ card t.fst * ((∏ a in t.fst, X a) * X t.snd ^ (k - card t.fst)) +
      (-1) ^ card (MvPolynomial.NewtonIdentities.pairMap σ t).fst *
        ((∏ a in (MvPolynomial.NewtonIdentities.pairMap σ t).fst, X a) *
          X (MvPolynomial.NewtonIdentities.pairMap σ t).snd ^
            (k - card (MvPolynomial.NewtonIdentities.pairMap σ t).fst)) =
    0
[PROOFSTEP]
rw [mem_pairs] at h 
[GOAL]
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
t : Finset σ × σ
h : card t.fst ≤ k ∧ (card t.fst = k → t.snd ∈ t.fst)
⊢ (-1) ^ card t.fst * ((∏ a in t.fst, X a) * X t.snd ^ (k - card t.fst)) +
      (-1) ^ card (MvPolynomial.NewtonIdentities.pairMap σ t).fst *
        ((∏ a in (MvPolynomial.NewtonIdentities.pairMap σ t).fst, X a) *
          X (MvPolynomial.NewtonIdentities.pairMap σ t).snd ^
            (k - card (MvPolynomial.NewtonIdentities.pairMap σ t).fst)) =
    0
[PROOFSTEP]
have h2 (n : ℕ) : -(-1 : MvPolynomial σ R) ^ n = (-1) ^ (n + 1) := by
  rw [← neg_one_mul ((-1 : MvPolynomial σ R) ^ n), pow_add, pow_one, mul_comm]
[GOAL]
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
t : Finset σ × σ
h : card t.fst ≤ k ∧ (card t.fst = k → t.snd ∈ t.fst)
n : ℕ
⊢ -(-1) ^ n = (-1) ^ (n + 1)
[PROOFSTEP]
rw [← neg_one_mul ((-1 : MvPolynomial σ R) ^ n), pow_add, pow_one, mul_comm]
[GOAL]
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
t : Finset σ × σ
h : card t.fst ≤ k ∧ (card t.fst = k → t.snd ∈ t.fst)
h2 : ∀ (n : ℕ), -(-1) ^ n = (-1) ^ (n + 1)
⊢ (-1) ^ card t.fst * ((∏ a in t.fst, X a) * X t.snd ^ (k - card t.fst)) +
      (-1) ^ card (MvPolynomial.NewtonIdentities.pairMap σ t).fst *
        ((∏ a in (MvPolynomial.NewtonIdentities.pairMap σ t).fst, X a) *
          X (MvPolynomial.NewtonIdentities.pairMap σ t).snd ^
            (k - card (MvPolynomial.NewtonIdentities.pairMap σ t).fst)) =
    0
[PROOFSTEP]
rcases(em (t.snd ∈ t.fst)) with h1 | h1
[GOAL]
case inl
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
t : Finset σ × σ
h : card t.fst ≤ k ∧ (card t.fst = k → t.snd ∈ t.fst)
h2 : ∀ (n : ℕ), -(-1) ^ n = (-1) ^ (n + 1)
h1 : t.snd ∈ t.fst
⊢ (-1) ^ card t.fst * ((∏ a in t.fst, X a) * X t.snd ^ (k - card t.fst)) +
      (-1) ^ card (MvPolynomial.NewtonIdentities.pairMap σ t).fst *
        ((∏ a in (MvPolynomial.NewtonIdentities.pairMap σ t).fst, X a) *
          X (MvPolynomial.NewtonIdentities.pairMap σ t).snd ^
            (k - card (MvPolynomial.NewtonIdentities.pairMap σ t).fst)) =
    0
[PROOFSTEP]
rw [pairMap_of_snd_mem_fst σ h1]
[GOAL]
case inl
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
t : Finset σ × σ
h : card t.fst ≤ k ∧ (card t.fst = k → t.snd ∈ t.fst)
h2 : ∀ (n : ℕ), -(-1) ^ n = (-1) ^ (n + 1)
h1 : t.snd ∈ t.fst
⊢ (-1) ^ card t.fst * ((∏ a in t.fst, X a) * X t.snd ^ (k - card t.fst)) +
      (-1) ^ card (erase t.fst t.snd, t.snd).fst *
        ((∏ a in (erase t.fst t.snd, t.snd).fst, X a) *
          X (erase t.fst t.snd, t.snd).snd ^ (k - card (erase t.fst t.snd, t.snd).fst)) =
    0
[PROOFSTEP]
simp only [← prod_erase_mul t.fst (fun j ↦ (X j : MvPolynomial σ R)) h1, mul_assoc (∏ a in erase t.fst t.snd, X a),
  card_erase_of_mem h1]
[GOAL]
case inl
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
t : Finset σ × σ
h : card t.fst ≤ k ∧ (card t.fst = k → t.snd ∈ t.fst)
h2 : ∀ (n : ℕ), -(-1) ^ n = (-1) ^ (n + 1)
h1 : t.snd ∈ t.fst
⊢ (-1) ^ card t.fst * ((∏ a in erase t.fst t.snd, X a) * (X t.snd * X t.snd ^ (k - card t.fst))) +
      (-1) ^ (card t.fst - 1) * ((∏ a in erase t.fst t.snd, X a) * X t.snd ^ (k - (card t.fst - 1))) =
    0
[PROOFSTEP]
nth_rewrite 1 [← pow_one (X t.snd)]
[GOAL]
case inl
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
t : Finset σ × σ
h : card t.fst ≤ k ∧ (card t.fst = k → t.snd ∈ t.fst)
h2 : ∀ (n : ℕ), -(-1) ^ n = (-1) ^ (n + 1)
h1 : t.snd ∈ t.fst
⊢ (-1) ^ card t.fst * ((∏ a in erase t.fst t.snd, X a) * (X t.snd ^ 1 * X t.snd ^ (k - card t.fst))) +
      (-1) ^ (card t.fst - 1) * ((∏ a in erase t.fst t.snd, X a) * X t.snd ^ (k - (card t.fst - 1))) =
    0
[PROOFSTEP]
simp only [← pow_add, add_comm]
[GOAL]
case inl
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
t : Finset σ × σ
h : card t.fst ≤ k ∧ (card t.fst = k → t.snd ∈ t.fst)
h2 : ∀ (n : ℕ), -(-1) ^ n = (-1) ^ (n + 1)
h1 : t.snd ∈ t.fst
⊢ (-1) ^ card t.fst * ((∏ a in erase t.fst t.snd, X a) * X t.snd ^ (k - card t.fst + 1)) +
      (-1) ^ (card t.fst - 1) * ((∏ a in erase t.fst t.snd, X a) * X t.snd ^ (k - (card t.fst - 1))) =
    0
[PROOFSTEP]
have h3 : 1 ≤ card t.fst := lt_iff_add_one_le.mp (card_pos.mpr ⟨t.snd, h1⟩)
[GOAL]
case inl
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
t : Finset σ × σ
h : card t.fst ≤ k ∧ (card t.fst = k → t.snd ∈ t.fst)
h2 : ∀ (n : ℕ), -(-1) ^ n = (-1) ^ (n + 1)
h1 : t.snd ∈ t.fst
h3 : 1 ≤ card t.fst
⊢ (-1) ^ card t.fst * ((∏ a in erase t.fst t.snd, X a) * X t.snd ^ (k - card t.fst + 1)) +
      (-1) ^ (card t.fst - 1) * ((∏ a in erase t.fst t.snd, X a) * X t.snd ^ (k - (card t.fst - 1))) =
    0
[PROOFSTEP]
rw [← tsub_tsub_assoc h.left h3, ← neg_neg ((-1 : MvPolynomial σ R) ^ (card t.fst - 1)), h2 (card t.fst - 1),
  Nat.sub_add_cancel h3]
[GOAL]
case inl
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
t : Finset σ × σ
h : card t.fst ≤ k ∧ (card t.fst = k → t.snd ∈ t.fst)
h2 : ∀ (n : ℕ), -(-1) ^ n = (-1) ^ (n + 1)
h1 : t.snd ∈ t.fst
h3 : 1 ≤ card t.fst
⊢ (-1) ^ card t.fst * ((∏ a in erase t.fst t.snd, X a) * X t.snd ^ (k - (card t.fst - 1))) +
      -(-1) ^ card t.fst * ((∏ a in erase t.fst t.snd, X a) * X t.snd ^ (k - (card t.fst - 1))) =
    0
[PROOFSTEP]
simp
[GOAL]
case inr
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
t : Finset σ × σ
h : card t.fst ≤ k ∧ (card t.fst = k → t.snd ∈ t.fst)
h2 : ∀ (n : ℕ), -(-1) ^ n = (-1) ^ (n + 1)
h1 : ¬t.snd ∈ t.fst
⊢ (-1) ^ card t.fst * ((∏ a in t.fst, X a) * X t.snd ^ (k - card t.fst)) +
      (-1) ^ card (MvPolynomial.NewtonIdentities.pairMap σ t).fst *
        ((∏ a in (MvPolynomial.NewtonIdentities.pairMap σ t).fst, X a) *
          X (MvPolynomial.NewtonIdentities.pairMap σ t).snd ^
            (k - card (MvPolynomial.NewtonIdentities.pairMap σ t).fst)) =
    0
[PROOFSTEP]
rw [pairMap_of_snd_nmem_fst σ h1]
[GOAL]
case inr
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
t : Finset σ × σ
h : card t.fst ≤ k ∧ (card t.fst = k → t.snd ∈ t.fst)
h2 : ∀ (n : ℕ), -(-1) ^ n = (-1) ^ (n + 1)
h1 : ¬t.snd ∈ t.fst
⊢ (-1) ^ card t.fst * ((∏ a in t.fst, X a) * X t.snd ^ (k - card t.fst)) +
      (-1) ^ card (cons t.snd t.fst h1, t.snd).fst *
        ((∏ a in (cons t.snd t.fst h1, t.snd).fst, X a) *
          X (cons t.snd t.fst h1, t.snd).snd ^ (k - card (cons t.snd t.fst h1, t.snd).fst)) =
    0
[PROOFSTEP]
simp only [mul_comm, mul_assoc (∏ a in t.fst, X a), card_cons, prod_cons]
[GOAL]
case inr
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
t : Finset σ × σ
h : card t.fst ≤ k ∧ (card t.fst = k → t.snd ∈ t.fst)
h2 : ∀ (n : ℕ), -(-1) ^ n = (-1) ^ (n + 1)
h1 : ¬t.snd ∈ t.fst
⊢ (∏ a in t.fst, X a) * (X t.snd ^ (k - card t.fst) * (-1) ^ card t.fst) +
      (∏ a in t.fst, X a) * (X t.snd * X t.snd ^ (k - (card t.fst + 1)) * (-1) ^ (card t.fst + 1)) =
    0
[PROOFSTEP]
nth_rewrite 2 [← pow_one (X t.snd)]
[GOAL]
case inr
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
t : Finset σ × σ
h : card t.fst ≤ k ∧ (card t.fst = k → t.snd ∈ t.fst)
h2 : ∀ (n : ℕ), -(-1) ^ n = (-1) ^ (n + 1)
h1 : ¬t.snd ∈ t.fst
⊢ (∏ a in t.fst, X a) * (X t.snd ^ (k - card t.fst) * (-1) ^ card t.fst) +
      (∏ a in t.fst, X a) * (X t.snd ^ 1 * X t.snd ^ (k - (card t.fst + 1)) * (-1) ^ (card t.fst + 1)) =
    0
[PROOFSTEP]
simp only [← pow_add, ← Nat.add_sub_assoc (Nat.lt_of_le_of_ne h.left (mt h.right h1)), add_comm]
[GOAL]
case inr
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
t : Finset σ × σ
h : card t.fst ≤ k ∧ (card t.fst = k → t.snd ∈ t.fst)
h2 : ∀ (n : ℕ), -(-1) ^ n = (-1) ^ (n + 1)
h1 : ¬t.snd ∈ t.fst
⊢ (∏ a in t.fst, X a) * (X t.snd ^ (k - card t.fst) * (-1) ^ card t.fst) +
      (∏ a in t.fst, X a) * (X t.snd ^ (k + 1 - succ (card t.fst)) * (-1) ^ (card t.fst + 1)) =
    0
[PROOFSTEP]
rw [← neg_neg ((-1 : MvPolynomial σ R) ^ card t.fst), h2]
[GOAL]
case inr
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
t : Finset σ × σ
h : card t.fst ≤ k ∧ (card t.fst = k → t.snd ∈ t.fst)
h2 : ∀ (n : ℕ), -(-1) ^ n = (-1) ^ (n + 1)
h1 : ¬t.snd ∈ t.fst
⊢ (∏ a in t.fst, X a) * (X t.snd ^ (k - card t.fst) * -(-1) ^ (card t.fst + 1)) +
      (∏ a in t.fst, X a) * (X t.snd ^ (k + 1 - succ (card t.fst)) * (-1) ^ (card t.fst + 1)) =
    0
[PROOFSTEP]
simp
[GOAL]
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
f : Finset σ × σ → MvPolynomial σ R
⊢ ∑ t in filter (fun t => card t.fst = k) (MvPolynomial.NewtonIdentities.pairs σ k), f t =
    ∑ A in powersetLen k univ, ∑ j in A, f (A, j)
[PROOFSTEP]
apply sum_finset_product
[GOAL]
case h
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
f : Finset σ × σ → MvPolynomial σ R
⊢ ∀ (p : Finset σ × σ),
    p ∈ filter (fun t => card t.fst = k) (MvPolynomial.NewtonIdentities.pairs σ k) ↔
      p.fst ∈ powersetLen k univ ∧ p.snd ∈ p.fst
[PROOFSTEP]
aesop
[GOAL]
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
a : ℕ × ℕ
ha : a ∈ filter (fun a => a.fst < k) (antidiagonal k)
f : Finset σ × σ → MvPolynomial σ R
⊢ ∑ t in filter (fun t => card t.fst = a.fst) (MvPolynomial.NewtonIdentities.pairs σ k), f t =
    ∑ A in powersetLen a.fst univ, ∑ j : σ, f (A, j)
[PROOFSTEP]
apply sum_finset_product
[GOAL]
case h
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
a : ℕ × ℕ
ha : a ∈ filter (fun a => a.fst < k) (antidiagonal k)
f : Finset σ × σ → MvPolynomial σ R
⊢ ∀ (p : Finset σ × σ),
    p ∈ filter (fun t => card t.fst = a.fst) (MvPolynomial.NewtonIdentities.pairs σ k) ↔
      p.fst ∈ powersetLen a.fst univ ∧ p.snd ∈ univ
[PROOFSTEP]
simp only [mem_filter, mem_powerset_len_univ_iff, mem_univ, and_true, and_iff_right_iff_imp]
[GOAL]
case h
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
a : ℕ × ℕ
ha : a ∈ filter (fun a => a.fst < k) (antidiagonal k)
f : Finset σ × σ → MvPolynomial σ R
⊢ ∀ (p : Finset σ × σ), card p.fst = a.fst → p ∈ MvPolynomial.NewtonIdentities.pairs σ k
[PROOFSTEP]
rintro p hp
[GOAL]
case h
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
a : ℕ × ℕ
ha : a ∈ filter (fun a => a.fst < k) (antidiagonal k)
f : Finset σ × σ → MvPolynomial σ R
p : Finset σ × σ
hp : card p.fst = a.fst
⊢ p ∈ MvPolynomial.NewtonIdentities.pairs σ k
[PROOFSTEP]
have : card p.fst ≤ k := by apply le_of_lt; aesop
[GOAL]
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
a : ℕ × ℕ
ha : a ∈ filter (fun a => a.fst < k) (antidiagonal k)
f : Finset σ × σ → MvPolynomial σ R
p : Finset σ × σ
hp : card p.fst = a.fst
⊢ card p.fst ≤ k
[PROOFSTEP]
apply le_of_lt
[GOAL]
case a
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
a : ℕ × ℕ
ha : a ∈ filter (fun a => a.fst < k) (antidiagonal k)
f : Finset σ × σ → MvPolynomial σ R
p : Finset σ × σ
hp : card p.fst = a.fst
⊢ card p.fst < k
[PROOFSTEP]
aesop
[GOAL]
case h
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
a : ℕ × ℕ
ha : a ∈ filter (fun a => a.fst < k) (antidiagonal k)
f : Finset σ × σ → MvPolynomial σ R
p : Finset σ × σ
hp : card p.fst = a.fst
this : card p.fst ≤ k
⊢ p ∈ MvPolynomial.NewtonIdentities.pairs σ k
[PROOFSTEP]
aesop
[GOAL]
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
f : Finset σ × σ → MvPolynomial σ R
⊢ ∑ t in filter (fun t => card t.fst < k) (MvPolynomial.NewtonIdentities.pairs σ k), f t =
    ∑ a in filter (fun a => a.fst < k) (antidiagonal k), ∑ A in powersetLen a.fst univ, ∑ j : σ, f (A, j)
[PROOFSTEP]
have equiv_i (a : ℕ × ℕ) (ha : a ∈ (antidiagonal k).filter (fun a ↦ a.fst < k)) :=
  sum_filter_pairs_eq_sum_powersetLen_mem_filter_antidiagonal_sum σ R k a ha f
[GOAL]
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
f : Finset σ × σ → MvPolynomial σ R
equiv_i :
  ∀ (a : ℕ × ℕ),
    a ∈ filter (fun a => a.fst < k) (antidiagonal k) →
      ∑ t in filter (fun t => card t.fst = a.fst) (MvPolynomial.NewtonIdentities.pairs σ k), f t =
        ∑ A in powersetLen a.fst univ, ∑ j : σ, f (A, j)
⊢ ∑ t in filter (fun t => card t.fst < k) (MvPolynomial.NewtonIdentities.pairs σ k), f t =
    ∑ a in filter (fun a => a.fst < k) (antidiagonal k), ∑ A in powersetLen a.fst univ, ∑ j : σ, f (A, j)
[PROOFSTEP]
simp only [← sum_congr rfl equiv_i]
[GOAL]
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
f : Finset σ × σ → MvPolynomial σ R
equiv_i :
  ∀ (a : ℕ × ℕ),
    a ∈ filter (fun a => a.fst < k) (antidiagonal k) →
      ∑ t in filter (fun t => card t.fst = a.fst) (MvPolynomial.NewtonIdentities.pairs σ k), f t =
        ∑ A in powersetLen a.fst univ, ∑ j : σ, f (A, j)
⊢ ∑ t in filter (fun t => card t.fst < k) (MvPolynomial.NewtonIdentities.pairs σ k), f t =
    ∑ x in filter (fun a => a.fst < k) (antidiagonal k),
      ∑ t in filter (fun t => card t.fst = x.fst) (MvPolynomial.NewtonIdentities.pairs σ k), f t
[PROOFSTEP]
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
[GOAL]
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
f : Finset σ × σ → MvPolynomial σ R
equiv_i :
  ∀ (a : ℕ × ℕ),
    a ∈ filter (fun a => a.fst < k) (antidiagonal k) →
      ∑ t in filter (fun t => card t.fst = a.fst) (MvPolynomial.NewtonIdentities.pairs σ k), f t =
        ∑ A in powersetLen a.fst univ, ∑ j : σ, f (A, j)
⊢ Set.PairwiseDisjoint ↑(filter (fun a => a.fst < k) (antidiagonal k)) fun a =>
    filter (fun t => card t.fst = a.fst) (MvPolynomial.NewtonIdentities.pairs σ k)
[PROOFSTEP]
simp only [Set.PairwiseDisjoint, Disjoint, pairs, filter_filter, ne_eq, le_eq_subset, bot_eq_empty]
[GOAL]
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
f : Finset σ × σ → MvPolynomial σ R
equiv_i :
  ∀ (a : ℕ × ℕ),
    a ∈ filter (fun a => a.fst < k) (antidiagonal k) →
      ∑ t in filter (fun t => card t.fst = a.fst) (MvPolynomial.NewtonIdentities.pairs σ k), f t =
        ∑ A in powersetLen a.fst univ, ∑ j : σ, f (A, j)
⊢ Set.Pairwise (↑(filter (fun a => a.fst < k) (antidiagonal k)))
    ((fun a b => ∀ ⦃x : Finset (Finset σ × σ)⦄, x ⊆ a → x ⊆ b → x ⊆ ∅) on fun a =>
      filter (fun a_1 => (card a_1.fst ≤ k ∧ (card a_1.fst = k → a_1.snd ∈ a_1.fst)) ∧ card a_1.fst = a.fst) univ)
[PROOFSTEP]
intro x hx y hy xny s hs hs' a ha
[GOAL]
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
f : Finset σ × σ → MvPolynomial σ R
equiv_i :
  ∀ (a : ℕ × ℕ),
    a ∈ filter (fun a => a.fst < k) (antidiagonal k) →
      ∑ t in filter (fun t => card t.fst = a.fst) (MvPolynomial.NewtonIdentities.pairs σ k), f t =
        ∑ A in powersetLen a.fst univ, ∑ j : σ, f (A, j)
x : ℕ × ℕ
hx : x ∈ ↑(filter (fun a => a.fst < k) (antidiagonal k))
y : ℕ × ℕ
hy : y ∈ ↑(filter (fun a => a.fst < k) (antidiagonal k))
xny : x ≠ y
s : Finset (Finset σ × σ)
hs :
  s ⊆
    (fun a =>
        filter (fun a_1 => (card a_1.fst ≤ k ∧ (card a_1.fst = k → a_1.snd ∈ a_1.fst)) ∧ card a_1.fst = a.fst) univ)
      x
hs' :
  s ⊆
    (fun a =>
        filter (fun a_1 => (card a_1.fst ≤ k ∧ (card a_1.fst = k → a_1.snd ∈ a_1.fst)) ∧ card a_1.fst = a.fst) univ)
      y
a : Finset σ × σ
ha : a ∈ s
⊢ a ∈ ∅
[PROOFSTEP]
simp only [mem_univ, forall_true_left, Prod.forall] at hs hs' 
[GOAL]
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
f : Finset σ × σ → MvPolynomial σ R
equiv_i :
  ∀ (a : ℕ × ℕ),
    a ∈ filter (fun a => a.fst < k) (antidiagonal k) →
      ∑ t in filter (fun t => card t.fst = a.fst) (MvPolynomial.NewtonIdentities.pairs σ k), f t =
        ∑ A in powersetLen a.fst univ, ∑ j : σ, f (A, j)
x : ℕ × ℕ
hx : x ∈ ↑(filter (fun a => a.fst < k) (antidiagonal k))
y : ℕ × ℕ
hy : y ∈ ↑(filter (fun a => a.fst < k) (antidiagonal k))
xny : x ≠ y
s : Finset (Finset σ × σ)
hs : s ⊆ filter (fun a => (card a.fst ≤ k ∧ (card a.fst = k → a.snd ∈ a.fst)) ∧ card a.fst = x.fst) univ
hs' : s ⊆ filter (fun a => (card a.fst ≤ k ∧ (card a.fst = k → a.snd ∈ a.fst)) ∧ card a.fst = y.fst) univ
a : Finset σ × σ
ha : a ∈ s
⊢ a ∈ ∅
[PROOFSTEP]
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 
[GOAL]
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
f : Finset σ × σ → MvPolynomial σ R
equiv_i :
  ∀ (a : ℕ × ℕ),
    a ∈ filter (fun a => a.fst < k) (antidiagonal k) →
      ∑ t in filter (fun t => card t.fst = a.fst) (MvPolynomial.NewtonIdentities.pairs σ k), f t =
        ∑ A in powersetLen a.fst univ, ∑ j : σ, f (A, j)
x : ℕ × ℕ
hx : x ∈ ↑(filter (fun a => a.fst < k) (antidiagonal k))
y : ℕ × ℕ
hy : y ∈ ↑(filter (fun a => a.fst < k) (antidiagonal k))
s : Finset (Finset σ × σ)
hs : s ⊆ filter (fun a => (card a.fst ≤ k ∧ (card a.fst = k → a.snd ∈ a.fst)) ∧ card a.fst = x.fst) univ
hs' : s ⊆ filter (fun a => (card a.fst ≤ k ∧ (card a.fst = k → a.snd ∈ a.fst)) ∧ card a.fst = y.fst) univ
a : Finset σ × σ
xny : ¬card a.fst = card a.fst
ha : a ∈ s
⊢ a ∈ ∅
[PROOFSTEP]
exact (xny rfl).elim
[GOAL]
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
f : Finset σ × σ → MvPolynomial σ R
equiv_i :
  ∀ (a : ℕ × ℕ),
    a ∈ filter (fun a => a.fst < k) (antidiagonal k) →
      ∑ t in filter (fun t => card t.fst = a.fst) (MvPolynomial.NewtonIdentities.pairs σ k), f t =
        ∑ A in powersetLen a.fst univ, ∑ j : σ, f (A, j)
pdisj :
  Set.PairwiseDisjoint ↑(filter (fun a => a.fst < k) (antidiagonal k)) fun a =>
    filter (fun t => card t.fst = a.fst) (MvPolynomial.NewtonIdentities.pairs σ k)
⊢ ∑ t in filter (fun t => card t.fst < k) (MvPolynomial.NewtonIdentities.pairs σ k), f t =
    ∑ x in filter (fun a => a.fst < k) (antidiagonal k),
      ∑ t in filter (fun t => card t.fst = x.fst) (MvPolynomial.NewtonIdentities.pairs σ k), f t
[PROOFSTEP]
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
[GOAL]
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
f : Finset σ × σ → MvPolynomial σ R
equiv_i :
  ∀ (a : ℕ × ℕ),
    a ∈ filter (fun a => a.fst < k) (antidiagonal k) →
      ∑ t in filter (fun t => card t.fst = a.fst) (MvPolynomial.NewtonIdentities.pairs σ k), f t =
        ∑ A in powersetLen a.fst univ, ∑ j : σ, f (A, j)
pdisj :
  Set.PairwiseDisjoint ↑(filter (fun a => a.fst < k) (antidiagonal k)) fun a =>
    filter (fun t => card t.fst = a.fst) (MvPolynomial.NewtonIdentities.pairs σ k)
hdisj :
  ∑ x in
      disjiUnion (filter (fun a => a.fst < k) (antidiagonal k))
        (fun a => filter (fun t => card t.fst = a.fst) (MvPolynomial.NewtonIdentities.pairs σ k)) pdisj,
      f x =
    ∑ i in filter (fun a => a.fst < k) (antidiagonal k),
      ∑ x in filter (fun t => card t.fst = i.fst) (MvPolynomial.NewtonIdentities.pairs σ k), f x
⊢ ∑ t in filter (fun t => card t.fst < k) (MvPolynomial.NewtonIdentities.pairs σ k), f t =
    ∑ x in filter (fun a => a.fst < k) (antidiagonal k),
      ∑ t in filter (fun t => card t.fst = x.fst) (MvPolynomial.NewtonIdentities.pairs σ k), f t
[PROOFSTEP]
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]
  · simp_all only [mem_antidiagonal, mem_filter, mem_pairs, disjiUnion_eq_biUnion, implies_true]
[GOAL]
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
f : Finset σ × σ → MvPolynomial σ R
equiv_i :
  ∀ (a : ℕ × ℕ),
    a ∈ filter (fun a => a.fst < k) (antidiagonal k) →
      ∑ t in filter (fun t => card t.fst = a.fst) (MvPolynomial.NewtonIdentities.pairs σ k), f t =
        ∑ A in powersetLen a.fst univ, ∑ j : σ, f (A, j)
pdisj :
  Set.PairwiseDisjoint ↑(filter (fun a => a.fst < k) (antidiagonal k)) fun a =>
    filter (fun t => card t.fst = a.fst) (MvPolynomial.NewtonIdentities.pairs σ k)
hdisj :
  ∑ x in
      disjiUnion (filter (fun a => a.fst < k) (antidiagonal k))
        (fun a => filter (fun t => card t.fst = a.fst) (MvPolynomial.NewtonIdentities.pairs σ k)) pdisj,
      f x =
    ∑ i in filter (fun a => a.fst < k) (antidiagonal k),
      ∑ x in filter (fun t => card t.fst = i.fst) (MvPolynomial.NewtonIdentities.pairs σ k), f x
⊢ disjiUnion (filter (fun a => a.fst < k) (antidiagonal k))
      (fun a => filter (fun t => card t.fst = a.fst) (MvPolynomial.NewtonIdentities.pairs σ k)) pdisj =
    filter (fun t => card t.fst < k) (MvPolynomial.NewtonIdentities.pairs σ k)
[PROOFSTEP]
ext a
[GOAL]
case a
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
f : Finset σ × σ → MvPolynomial σ R
equiv_i :
  ∀ (a : ℕ × ℕ),
    a ∈ filter (fun a => a.fst < k) (antidiagonal k) →
      ∑ t in filter (fun t => card t.fst = a.fst) (MvPolynomial.NewtonIdentities.pairs σ k), f t =
        ∑ A in powersetLen a.fst univ, ∑ j : σ, f (A, j)
pdisj :
  Set.PairwiseDisjoint ↑(filter (fun a => a.fst < k) (antidiagonal k)) fun a =>
    filter (fun t => card t.fst = a.fst) (MvPolynomial.NewtonIdentities.pairs σ k)
hdisj :
  ∑ x in
      disjiUnion (filter (fun a => a.fst < k) (antidiagonal k))
        (fun a => filter (fun t => card t.fst = a.fst) (MvPolynomial.NewtonIdentities.pairs σ k)) pdisj,
      f x =
    ∑ i in filter (fun a => a.fst < k) (antidiagonal k),
      ∑ x in filter (fun t => card t.fst = i.fst) (MvPolynomial.NewtonIdentities.pairs σ k), f x
a : Finset σ × σ
⊢ a ∈
      disjiUnion (filter (fun a => a.fst < k) (antidiagonal k))
        (fun a => filter (fun t => card t.fst = a.fst) (MvPolynomial.NewtonIdentities.pairs σ k)) pdisj ↔
    a ∈ filter (fun t => card t.fst < k) (MvPolynomial.NewtonIdentities.pairs σ k)
[PROOFSTEP]
rw [mem_disjiUnion, mem_filter]
[GOAL]
case a
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
f : Finset σ × σ → MvPolynomial σ R
equiv_i :
  ∀ (a : ℕ × ℕ),
    a ∈ filter (fun a => a.fst < k) (antidiagonal k) →
      ∑ t in filter (fun t => card t.fst = a.fst) (MvPolynomial.NewtonIdentities.pairs σ k), f t =
        ∑ A in powersetLen a.fst univ, ∑ j : σ, f (A, j)
pdisj :
  Set.PairwiseDisjoint ↑(filter (fun a => a.fst < k) (antidiagonal k)) fun a =>
    filter (fun t => card t.fst = a.fst) (MvPolynomial.NewtonIdentities.pairs σ k)
hdisj :
  ∑ x in
      disjiUnion (filter (fun a => a.fst < k) (antidiagonal k))
        (fun a => filter (fun t => card t.fst = a.fst) (MvPolynomial.NewtonIdentities.pairs σ k)) pdisj,
      f x =
    ∑ i in filter (fun a => a.fst < k) (antidiagonal k),
      ∑ x in filter (fun t => card t.fst = i.fst) (MvPolynomial.NewtonIdentities.pairs σ k), f x
a : Finset σ × σ
⊢ (∃ a_1,
      a_1 ∈ filter (fun a => a.fst < k) (antidiagonal k) ∧
        a ∈ filter (fun t => card t.fst = a_1.fst) (MvPolynomial.NewtonIdentities.pairs σ k)) ↔
    a ∈ MvPolynomial.NewtonIdentities.pairs σ k ∧ card a.fst < k
[PROOFSTEP]
refine' ⟨_, fun haf ↦ ⟨(card a.fst, k - card a.fst), _, _⟩⟩
[GOAL]
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 : ℕ × ℕ),
    a ∈ filter (fun a => a.fst < k) (antidiagonal k) →
      ∑ t in filter (fun t => card t.fst = a.fst) (MvPolynomial.NewtonIdentities.pairs σ k), f t =
        ∑ A in powersetLen a.fst univ, ∑ j : σ, f (A, j)
pdisj :
  Set.PairwiseDisjoint ↑(filter (fun a => a.fst < k) (antidiagonal k)) fun a =>
    filter (fun t => card t.fst = a.fst) (MvPolynomial.NewtonIdentities.pairs σ k)
hdisj :
  ∑ x in
      disjiUnion (filter (fun a => a.fst < k) (antidiagonal k))
        (fun a => filter (fun t => card t.fst = a.fst) (MvPolynomial.NewtonIdentities.pairs σ k)) pdisj,
      f x =
    ∑ i in filter (fun a => a.fst < k) (antidiagonal k),
      ∑ x in filter (fun t => card t.fst = i.fst) (MvPolynomial.NewtonIdentities.pairs σ k), f x
a : Finset σ × σ
⊢ (∃ a_1,
      a_1 ∈ filter (fun a => a.fst < k) (antidiagonal k) ∧
        a ∈ filter (fun t => card t.fst = a_1.fst) (MvPolynomial.NewtonIdentities.pairs σ k)) →
    a ∈ MvPolynomial.NewtonIdentities.pairs σ k ∧ card a.fst < k
[PROOFSTEP]
rintro ⟨n, hnk, ha⟩
[GOAL]
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 : ℕ × ℕ),
    a ∈ filter (fun a => a.fst < k) (antidiagonal k) →
      ∑ t in filter (fun t => card t.fst = a.fst) (MvPolynomial.NewtonIdentities.pairs σ k), f t =
        ∑ A in powersetLen a.fst univ, ∑ j : σ, f (A, j)
pdisj :
  Set.PairwiseDisjoint ↑(filter (fun a => a.fst < k) (antidiagonal k)) fun a =>
    filter (fun t => card t.fst = a.fst) (MvPolynomial.NewtonIdentities.pairs σ k)
hdisj :
  ∑ x in
      disjiUnion (filter (fun a => a.fst < k) (antidiagonal k))
        (fun a => filter (fun t => card t.fst = a.fst) (MvPolynomial.NewtonIdentities.pairs σ k)) pdisj,
      f x =
    ∑ i in filter (fun a => a.fst < k) (antidiagonal k),
      ∑ x in filter (fun t => card t.fst = i.fst) (MvPolynomial.NewtonIdentities.pairs σ k), f x
a : Finset σ × σ
n : ℕ × ℕ
hnk : n ∈ filter (fun a => a.fst < k) (antidiagonal k)
ha : a ∈ filter (fun t => card t.fst = n.fst) (MvPolynomial.NewtonIdentities.pairs σ k)
⊢ a ∈ MvPolynomial.NewtonIdentities.pairs σ k ∧ card a.fst < k
[PROOFSTEP]
have hnk' : n.fst ≤ k := by apply le_of_lt; aesop
[GOAL]
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
f : Finset σ × σ → MvPolynomial σ R
equiv_i :
  ∀ (a : ℕ × ℕ),
    a ∈ filter (fun a => a.fst < k) (antidiagonal k) →
      ∑ t in filter (fun t => card t.fst = a.fst) (MvPolynomial.NewtonIdentities.pairs σ k), f t =
        ∑ A in powersetLen a.fst univ, ∑ j : σ, f (A, j)
pdisj :
  Set.PairwiseDisjoint ↑(filter (fun a => a.fst < k) (antidiagonal k)) fun a =>
    filter (fun t => card t.fst = a.fst) (MvPolynomial.NewtonIdentities.pairs σ k)
hdisj :
  ∑ x in
      disjiUnion (filter (fun a => a.fst < k) (antidiagonal k))
        (fun a => filter (fun t => card t.fst = a.fst) (MvPolynomial.NewtonIdentities.pairs σ k)) pdisj,
      f x =
    ∑ i in filter (fun a => a.fst < k) (antidiagonal k),
      ∑ x in filter (fun t => card t.fst = i.fst) (MvPolynomial.NewtonIdentities.pairs σ k), f x
a : Finset σ × σ
n : ℕ × ℕ
hnk : n ∈ filter (fun a => a.fst < k) (antidiagonal k)
ha : a ∈ filter (fun t => card t.fst = n.fst) (MvPolynomial.NewtonIdentities.pairs σ k)
⊢ n.fst ≤ k
[PROOFSTEP]
apply le_of_lt
[GOAL]
case a
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
f : Finset σ × σ → MvPolynomial σ R
equiv_i :
  ∀ (a : ℕ × ℕ),
    a ∈ filter (fun a => a.fst < k) (antidiagonal k) →
      ∑ t in filter (fun t => card t.fst = a.fst) (MvPolynomial.NewtonIdentities.pairs σ k), f t =
        ∑ A in powersetLen a.fst univ, ∑ j : σ, f (A, j)
pdisj :
  Set.PairwiseDisjoint ↑(filter (fun a => a.fst < k) (antidiagonal k)) fun a =>
    filter (fun t => card t.fst = a.fst) (MvPolynomial.NewtonIdentities.pairs σ k)
hdisj :
  ∑ x in
      disjiUnion (filter (fun a => a.fst < k) (antidiagonal k))
        (fun a => filter (fun t => card t.fst = a.fst) (MvPolynomial.NewtonIdentities.pairs σ k)) pdisj,
      f x =
    ∑ i in filter (fun a => a.fst < k) (antidiagonal k),
      ∑ x in filter (fun t => card t.fst = i.fst) (MvPolynomial.NewtonIdentities.pairs σ k), f x
a : Finset σ × σ
n : ℕ × ℕ
hnk : n ∈ filter (fun a => a.fst < k) (antidiagonal k)
ha : a ∈ filter (fun t => card t.fst = n.fst) (MvPolynomial.NewtonIdentities.pairs σ k)
⊢ n.fst < k
[PROOFSTEP]
aesop
[GOAL]
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 : ℕ × ℕ),
    a ∈ filter (fun a => a.fst < k) (antidiagonal k) →
      ∑ t in filter (fun t => card t.fst = a.fst) (MvPolynomial.NewtonIdentities.pairs σ k), f t =
        ∑ A in powersetLen a.fst univ, ∑ j : σ, f (A, j)
pdisj :
  Set.PairwiseDisjoint ↑(filter (fun a => a.fst < k) (antidiagonal k)) fun a =>
    filter (fun t => card t.fst = a.fst) (MvPolynomial.NewtonIdentities.pairs σ k)
hdisj :
  ∑ x in
      disjiUnion (filter (fun a => a.fst < k) (antidiagonal k))
        (fun a => filter (fun t => card t.fst = a.fst) (MvPolynomial.NewtonIdentities.pairs σ k)) pdisj,
      f x =
    ∑ i in filter (fun a => a.fst < k) (antidiagonal k),
      ∑ x in filter (fun t => card t.fst = i.fst) (MvPolynomial.NewtonIdentities.pairs σ k), f x
a : Finset σ × σ
n : ℕ × ℕ
hnk : n ∈ filter (fun a => a.fst < k) (antidiagonal k)
ha : a ∈ filter (fun t => card t.fst = n.fst) (MvPolynomial.NewtonIdentities.pairs σ k)
hnk' : n.fst ≤ k
⊢ a ∈ MvPolynomial.NewtonIdentities.pairs σ k ∧ card a.fst < k
[PROOFSTEP]
aesop
[GOAL]
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 : ℕ × ℕ),
    a ∈ filter (fun a => a.fst < k) (antidiagonal k) →
      ∑ t in filter (fun t => card t.fst = a.fst) (MvPolynomial.NewtonIdentities.pairs σ k), f t =
        ∑ A in powersetLen a.fst univ, ∑ j : σ, f (A, j)
pdisj :
  Set.PairwiseDisjoint ↑(filter (fun a => a.fst < k) (antidiagonal k)) fun a =>
    filter (fun t => card t.fst = a.fst) (MvPolynomial.NewtonIdentities.pairs σ k)
hdisj :
  ∑ x in
      disjiUnion (filter (fun a => a.fst < k) (antidiagonal k))
        (fun a => filter (fun t => card t.fst = a.fst) (MvPolynomial.NewtonIdentities.pairs σ k)) pdisj,
      f x =
    ∑ i in filter (fun a => a.fst < k) (antidiagonal k),
      ∑ x in filter (fun t => card t.fst = i.fst) (MvPolynomial.NewtonIdentities.pairs σ k), f x
a : Finset σ × σ
haf : a ∈ MvPolynomial.NewtonIdentities.pairs σ k ∧ card a.fst < k
⊢ (card a.fst, k - card a.fst) ∈ filter (fun a => a.fst < k) (antidiagonal k)
[PROOFSTEP]
simp_all only [mem_antidiagonal, mem_filter, mem_pairs, disjiUnion_eq_biUnion, add_tsub_cancel_of_le]
[GOAL]
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 : ℕ × ℕ),
    a ∈ filter (fun a => a.fst < k) (antidiagonal k) →
      ∑ t in filter (fun t => card t.fst = a.fst) (MvPolynomial.NewtonIdentities.pairs σ k), f t =
        ∑ A in powersetLen a.fst univ, ∑ j : σ, f (A, j)
pdisj :
  Set.PairwiseDisjoint ↑(filter (fun a => a.fst < k) (antidiagonal k)) fun a =>
    filter (fun t => card t.fst = a.fst) (MvPolynomial.NewtonIdentities.pairs σ k)
hdisj :
  ∑ x in
      disjiUnion (filter (fun a => a.fst < k) (antidiagonal k))
        (fun a => filter (fun t => card t.fst = a.fst) (MvPolynomial.NewtonIdentities.pairs σ k)) pdisj,
      f x =
    ∑ i in filter (fun a => a.fst < k) (antidiagonal k),
      ∑ x in filter (fun t => card t.fst = i.fst) (MvPolynomial.NewtonIdentities.pairs σ k), f x
a : Finset σ × σ
haf : a ∈ MvPolynomial.NewtonIdentities.pairs σ k ∧ card a.fst < k
⊢ a ∈ filter (fun t => card t.fst = (card a.fst, k - card a.fst).fst) (MvPolynomial.NewtonIdentities.pairs σ k)
[PROOFSTEP]
simp_all only [mem_antidiagonal, mem_filter, mem_pairs, disjiUnion_eq_biUnion, implies_true]
[GOAL]
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
f : Finset σ × σ → MvPolynomial σ R
equiv_i :
  ∀ (a : ℕ × ℕ),
    a ∈ filter (fun a => a.fst < k) (antidiagonal k) →
      ∑ t in filter (fun t => card t.fst = a.fst) (MvPolynomial.NewtonIdentities.pairs σ k), f t =
        ∑ A in powersetLen a.fst univ, ∑ j : σ, f (A, j)
pdisj :
  Set.PairwiseDisjoint ↑(filter (fun a => a.fst < k) (antidiagonal k)) fun a =>
    filter (fun t => card t.fst = a.fst) (MvPolynomial.NewtonIdentities.pairs σ k)
hdisj :
  ∑ x in
      disjiUnion (filter (fun a => a.fst < k) (antidiagonal k))
        (fun a => filter (fun t => card t.fst = a.fst) (MvPolynomial.NewtonIdentities.pairs σ k)) pdisj,
      f x =
    ∑ i in filter (fun a => a.fst < k) (antidiagonal k),
      ∑ x in filter (fun t => card t.fst = i.fst) (MvPolynomial.NewtonIdentities.pairs σ k), f x
disj_equiv :
  disjiUnion (filter (fun a => a.fst < k) (antidiagonal k))
      (fun a => filter (fun t => card t.fst = a.fst) (MvPolynomial.NewtonIdentities.pairs σ k)) pdisj =
    filter (fun t => card t.fst < k) (MvPolynomial.NewtonIdentities.pairs σ k)
⊢ ∑ t in filter (fun t => card t.fst < k) (MvPolynomial.NewtonIdentities.pairs σ k), f t =
    ∑ x in filter (fun a => a.fst < k) (antidiagonal k),
      ∑ t in filter (fun t => card t.fst = x.fst) (MvPolynomial.NewtonIdentities.pairs σ k), f t
[PROOFSTEP]
simp only [← hdisj, disj_equiv]
[GOAL]
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
⊢ Disjoint (filter (fun t => card t.fst < k) (MvPolynomial.NewtonIdentities.pairs σ k))
    (filter (fun t => card t.fst = k) (MvPolynomial.NewtonIdentities.pairs σ k))
[PROOFSTEP]
rw [disjoint_filter]
[GOAL]
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
⊢ ∀ (x : Finset σ × σ), x ∈ MvPolynomial.NewtonIdentities.pairs σ k → card x.fst < k → ¬card x.fst = k
[PROOFSTEP]
exact fun _ _ h1 h2 ↦ lt_irrefl _ (h2.symm.subst h1)
[GOAL]
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
⊢ disjUnion (filter (fun t => card t.fst < k) (MvPolynomial.NewtonIdentities.pairs σ k))
      (filter (fun t => card t.fst = k) (MvPolynomial.NewtonIdentities.pairs σ k))
      (_ :
        Disjoint (filter (fun t => card t.fst < k) (MvPolynomial.NewtonIdentities.pairs σ k))
          (filter (fun t => card t.fst = k) (MvPolynomial.NewtonIdentities.pairs σ k))) =
    MvPolynomial.NewtonIdentities.pairs σ k
[PROOFSTEP]
simp only [disjUnion_eq_union, Finset.ext_iff, pairs, filter_filter, mem_filter]
[GOAL]
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
⊢ ∀ (a : Finset σ × σ),
    a ∈
        filter (fun a => (card a.fst ≤ k ∧ (card a.fst = k → a.snd ∈ a.fst)) ∧ card a.fst < k) univ ∪
          filter (fun a => (card a.fst ≤ k ∧ (card a.fst = k → a.snd ∈ a.fst)) ∧ card a.fst = k) univ ↔
      a ∈ univ ∧ card a.fst ≤ k ∧ (card a.fst = k → a.snd ∈ a.fst)
[PROOFSTEP]
intro a
[GOAL]
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
a : Finset σ × σ
⊢ a ∈
      filter (fun a => (card a.fst ≤ k ∧ (card a.fst = k → a.snd ∈ a.fst)) ∧ card a.fst < k) univ ∪
        filter (fun a => (card a.fst ≤ k ∧ (card a.fst = k → a.snd ∈ a.fst)) ∧ card a.fst = k) univ ↔
    a ∈ univ ∧ card a.fst ≤ k ∧ (card a.fst = k → a.snd ∈ a.fst)
[PROOFSTEP]
rw [← filter_or, mem_filter]
[GOAL]
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
a : Finset σ × σ
⊢ a ∈ univ ∧
      ((card a.fst ≤ k ∧ (card a.fst = k → a.snd ∈ a.fst)) ∧ card a.fst < k ∨
        (card a.fst ≤ k ∧ (card a.fst = k → a.snd ∈ a.fst)) ∧ card a.fst = k) ↔
    a ∈ univ ∧ card a.fst ≤ k ∧ (card a.fst = k → a.snd ∈ a.fst)
[PROOFSTEP]
refine' ⟨fun ha ↦ by tauto, fun ha ↦ _⟩
[GOAL]
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
a : Finset σ × σ
ha :
  a ∈ univ ∧
    ((card a.fst ≤ k ∧ (card a.fst = k → a.snd ∈ a.fst)) ∧ card a.fst < k ∨
      (card a.fst ≤ k ∧ (card a.fst = k → a.snd ∈ a.fst)) ∧ card a.fst = k)
⊢ a ∈ univ ∧ card a.fst ≤ k ∧ (card a.fst = k → a.snd ∈ a.fst)
[PROOFSTEP]
tauto
[GOAL]
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
a : Finset σ × σ
ha : a ∈ univ ∧ card a.fst ≤ k ∧ (card a.fst = k → a.snd ∈ a.fst)
⊢ a ∈ univ ∧
    ((card a.fst ≤ k ∧ (card a.fst = k → a.snd ∈ a.fst)) ∧ card a.fst < k ∨
      (card a.fst ≤ k ∧ (card a.fst = k → a.snd ∈ a.fst)) ∧ card a.fst = k)
[PROOFSTEP]
have hacard := le_iff_lt_or_eq.mp ha.2.1
[GOAL]
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
a : Finset σ × σ
ha : a ∈ univ ∧ card a.fst ≤ k ∧ (card a.fst = k → a.snd ∈ a.fst)
hacard : card a.fst < k ∨ card a.fst = k
⊢ a ∈ univ ∧
    ((card a.fst ≤ k ∧ (card a.fst = k → a.snd ∈ a.fst)) ∧ card a.fst < k ∨
      (card a.fst ≤ k ∧ (card a.fst = k → a.snd ∈ a.fst)) ∧ card a.fst = k)
[PROOFSTEP]
tauto
[GOAL]
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
A : Finset σ
h : A ∈ powersetLen k univ
⊢ ∑ j in A, MvPolynomial.NewtonIdentities.weight σ R k (A, j) = ↑k * (-1) ^ k * ∏ i in A, X i
[PROOFSTEP]
simp [weight, mem_powerset_len_univ_iff.mp h, mul_assoc]
[GOAL]
σ : 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.fst = k) (MvPolynomial.NewtonIdentities.pairs σ k),
        MvPolynomial.NewtonIdentities.weight σ R k t
[PROOFSTEP]
rw [esymm, sum_filter_pairs_eq_sum_powersetLen_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]
[GOAL]
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
a : ℕ × ℕ
ha : a ∈ antidiagonal k
⊢ ∑ A in powersetLen a.fst univ, ∑ j : σ, MvPolynomial.NewtonIdentities.weight σ R k (A, j) =
    (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd
[PROOFSTEP]
simp only [esymm, psum_def, weight, ← mul_assoc, mul_sum]
[GOAL]
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
a : ℕ × ℕ
ha : a ∈ antidiagonal k
⊢ ∑ x in powersetLen a.fst univ, ∑ x_1 : σ, ((-1) ^ card x * ∏ a in x, X a) * X x_1 ^ (k - card x) =
    ∑ x : σ, (∑ x in powersetLen a.fst univ, (-1) ^ a.fst * ∏ a in x, X a) * X x ^ a.snd
[PROOFSTEP]
rw [sum_comm]
[GOAL]
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
a : ℕ × ℕ
ha : a ∈ antidiagonal k
⊢ ∑ y : σ, ∑ x in powersetLen a.fst univ, ((-1) ^ card x * ∏ a in x, X a) * X y ^ (k - card x) =
    ∑ x : σ, (∑ x in powersetLen a.fst univ, (-1) ^ a.fst * ∏ a in x, X a) * X x ^ a.snd
[PROOFSTEP]
refine' sum_congr rfl fun x _ ↦ _
[GOAL]
σ : 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 powersetLen a.fst univ, ((-1) ^ card x_1 * ∏ a in x_1, X a) * X x ^ (k - card x_1) =
    (∑ x in powersetLen a.fst univ, (-1) ^ a.fst * ∏ a in x, X a) * X x ^ a.snd
[PROOFSTEP]
rw [sum_mul]
[GOAL]
σ : 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 powersetLen a.fst univ, ((-1) ^ card x_1 * ∏ a in x_1, X a) * X x ^ (k - card x_1) =
    ∑ x_1 in powersetLen a.fst univ, ((-1) ^ a.fst * ∏ a in x_1, X a) * X x ^ a.snd
[PROOFSTEP]
refine' sum_congr rfl fun s hs ↦ _
[GOAL]
σ : 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 ∈ powersetLen a.fst univ
⊢ ((-1) ^ card s * ∏ a in s, X a) * X x ^ (k - card s) = ((-1) ^ a.fst * ∏ a in s, X a) * X x ^ a.snd
[PROOFSTEP]
rw [mem_powerset_len_univ_iff.mp hs, ← mem_antidiagonal.mp ha, add_sub_self_left]
[GOAL]
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
⊢ ∑ a in filter (fun a => a.fst < k) (antidiagonal k), (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd =
    ∑ t in filter (fun t => card t.fst < k) (MvPolynomial.NewtonIdentities.pairs σ k),
      MvPolynomial.NewtonIdentities.weight σ R k t
[PROOFSTEP]
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_powersetLen_sum σ R k]
[GOAL]
σ : 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.fst < k) (antidiagonal k), (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd
[PROOFSTEP]
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)]
[GOAL]
σ : 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.fst < k) (MvPolynomial.NewtonIdentities.pairs σ k),
          MvPolynomial.NewtonIdentities.weight σ R k t +
      -1 * (-1) ^ k *
        ∑ t in filter (fun t => card t.fst = k) (MvPolynomial.NewtonIdentities.pairs σ k),
          MvPolynomial.NewtonIdentities.weight σ R k t =
    0
[PROOFSTEP]
nth_rw 2 [← pow_one (-1 : MvPolynomial σ R)]
[GOAL]
σ : 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.fst < k) (MvPolynomial.NewtonIdentities.pairs σ k),
          MvPolynomial.NewtonIdentities.weight σ R k t +
      (-1) ^ 1 * (-1) ^ k *
        ∑ t in filter (fun t => card t.fst = k) (MvPolynomial.NewtonIdentities.pairs σ k),
          MvPolynomial.NewtonIdentities.weight σ R k t =
    0
[PROOFSTEP]
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]
[GOAL]
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
⊢ ∑ a in antidiagonal (Fintype.card σ), (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd = 0
[PROOFSTEP]
let k := Fintype.card σ
[GOAL]
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ := Fintype.card σ
⊢ ∑ a in antidiagonal (Fintype.card σ), (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd = 0
[PROOFSTEP]
suffices :
  (-1 : MvPolynomial σ R) ^ (k + 1) * ∑ a in antidiagonal k, (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd = 0
[GOAL]
σ : 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.fst * esymm σ R a.fst * psum σ R a.snd = 0
⊢ ∑ a in antidiagonal (Fintype.card σ), (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd = 0
[PROOFSTEP]
simpa using this
[GOAL]
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.fst * esymm σ R a.fst * psum σ R a.snd = 0
[PROOFSTEP]
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)]
[GOAL]
σ : 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.fst ∈ Set.Ioo 0 k) (antidiagonal k), (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd
[PROOFSTEP]
simp only [Set.Ioo, Set.mem_setOf_eq, and_comm]
[GOAL]
σ : 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.fst < k ∧ 0 < a.fst) (antidiagonal k), (-1) ^ x.fst * esymm σ R x.fst * psum σ R x.snd
[PROOFSTEP]
have hesymm := mul_esymm_eq_sum σ R k
[GOAL]
σ : 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.fst < k) (antidiagonal k), (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd
⊢ psum σ R k =
    (-1) ^ (k + 1) * ↑k * esymm σ R k -
      ∑ x in filter (fun a => a.fst < k ∧ 0 < a.fst) (antidiagonal k), (-1) ^ x.fst * esymm σ R x.fst * psum σ R x.snd
[PROOFSTEP]
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 
[GOAL]
σ : 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.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
          (-1) ^ x.fst * esymm σ R x.fst * psum σ R x.snd +
        ∑ x in filter (fun x => ¬0 < x.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
          (-1) ^ x.fst * esymm σ R x.fst * psum σ R x.snd)
⊢ psum σ R k =
    (-1) ^ (k + 1) * ↑k * esymm σ R k -
      ∑ x in filter (fun a => a.fst < k ∧ 0 < a.fst) (antidiagonal k), (-1) ^ x.fst * esymm σ R x.fst * psum σ R x.snd
[PROOFSTEP]
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
[GOAL]
σ : 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.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
          (-1) ^ x.fst * esymm σ R x.fst * psum σ R x.snd +
        ∑ x in filter (fun x => ¬0 < x.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
          (-1) ^ x.fst * esymm σ R x.fst * psum σ R x.snd)
sub_both_sides :
  (fun x =>
        x -
          (-1) ^ (k + 1) *
            ∑ a in filter (fun a => 0 < a.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
              (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd)
      (↑k * esymm σ R k) =
    (fun x =>
        x -
          (-1) ^ (k + 1) *
            ∑ a in filter (fun a => 0 < a.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
              (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd)
      ((-1) ^ (k + 1) *
        (∑ x in filter (fun a => 0 < a.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
            (-1) ^ x.fst * esymm σ R x.fst * psum σ R x.snd +
          ∑ x in filter (fun x => ¬0 < x.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
            (-1) ^ x.fst * esymm σ R x.fst * psum σ R x.snd))
⊢ psum σ R k =
    (-1) ^ (k + 1) * ↑k * esymm σ R k -
      ∑ x in filter (fun a => a.fst < k ∧ 0 < a.fst) (antidiagonal k), (-1) ^ x.fst * esymm σ R x.fst * psum σ R x.snd
[PROOFSTEP]
simp only [left_distrib, add_sub_cancel'] at sub_both_sides 
[GOAL]
σ : 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.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
          (-1) ^ x.fst * esymm σ R x.fst * psum σ R x.snd +
        ∑ x in filter (fun x => ¬0 < x.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
          (-1) ^ x.fst * esymm σ R x.fst * psum σ R x.snd)
sub_both_sides :
  ↑k * esymm σ R k -
      (-1) ^ (k + 1) *
        ∑ a in filter (fun a => 0 < a.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
          (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd =
    (-1) ^ (k + 1) *
      ∑ a in filter (fun x => ¬0 < x.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
        (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd
⊢ psum σ R k =
    (-1) ^ (k + 1) * ↑k * esymm σ R k -
      ∑ x in filter (fun a => a.fst < k ∧ 0 < a.fst) (antidiagonal k), (-1) ^ x.fst * esymm σ R x.fst * psum σ R x.snd
[PROOFSTEP]
have sub_both_sides := congrArg ((-1 : MvPolynomial σ R) ^ (k + 1) * ·) sub_both_sides
[GOAL]
σ : 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.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
          (-1) ^ x.fst * esymm σ R x.fst * psum σ R x.snd +
        ∑ x in filter (fun x => ¬0 < x.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
          (-1) ^ x.fst * esymm σ R x.fst * psum σ R x.snd)
sub_both_sides✝ :
  ↑k * esymm σ R k -
      (-1) ^ (k + 1) *
        ∑ a in filter (fun a => 0 < a.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
          (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd =
    (-1) ^ (k + 1) *
      ∑ a in filter (fun x => ¬0 < x.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
        (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd
sub_both_sides :
  (fun x => (-1) ^ (k + 1) * x)
      (↑k * esymm σ R k -
        (-1) ^ (k + 1) *
          ∑ a in filter (fun a => 0 < a.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
            (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd) =
    (fun x => (-1) ^ (k + 1) * x)
      ((-1) ^ (k + 1) *
        ∑ a in filter (fun x => ¬0 < x.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
          (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd)
⊢ psum σ R k =
    (-1) ^ (k + 1) * ↑k * esymm σ R k -
      ∑ x in filter (fun a => a.fst < k ∧ 0 < a.fst) (antidiagonal k), (-1) ^ x.fst * esymm σ R x.fst * psum σ R x.snd
[PROOFSTEP]
simp only [mul_sub_left_distrib, ← mul_assoc, ← pow_add, Even.neg_one_pow ⟨k + 1, rfl⟩, one_mul, not_le, lt_one_iff,
  filter_filter (fun a : ℕ × ℕ ↦ a.fst < k) (fun a ↦ ¬0 < a.fst)] at sub_both_sides 
[GOAL]
σ : 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.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
          (-1) ^ x.fst * esymm σ R x.fst * psum σ R x.snd +
        ∑ x in filter (fun x => ¬0 < x.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
          (-1) ^ x.fst * esymm σ R x.fst * psum σ R x.snd)
sub_both_sides✝ :
  ↑k * esymm σ R k -
      (-1) ^ (k + 1) *
        ∑ a in filter (fun a => 0 < a.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
          (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd =
    (-1) ^ (k + 1) *
      ∑ a in filter (fun x => ¬0 < x.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
        (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd
sub_both_sides :
  (-1) ^ (k + 1) * ↑k * esymm σ R k -
      ∑ a in filter (fun a => 0 < a.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
        (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd =
    ∑ a in filter (fun a => a.fst < k ∧ ¬0 < a.fst) (antidiagonal k), (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd
⊢ psum σ R k =
    (-1) ^ (k + 1) * ↑k * esymm σ R k -
      ∑ x in filter (fun a => a.fst < k ∧ 0 < a.fst) (antidiagonal k), (-1) ^ x.fst * esymm σ R x.fst * psum σ R x.snd
[PROOFSTEP]
have : filter (fun a ↦ a.fst < k ∧ ¬0 < a.fst) (antidiagonal k) = {(0, k)} :=
  by
  ext a
  rw [mem_filter, mem_antidiagonal, mem_singleton]
  refine' ⟨_, fun ha ↦ by aesop⟩
  rintro ⟨ha, ⟨_, ha0⟩⟩
  rw [← ha, Nat.eq_zero_of_nonpos a.fst ha0, zero_add, ← Nat.eq_zero_of_nonpos a.fst ha0]
[GOAL]
σ : 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.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
          (-1) ^ x.fst * esymm σ R x.fst * psum σ R x.snd +
        ∑ x in filter (fun x => ¬0 < x.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
          (-1) ^ x.fst * esymm σ R x.fst * psum σ R x.snd)
sub_both_sides✝ :
  ↑k * esymm σ R k -
      (-1) ^ (k + 1) *
        ∑ a in filter (fun a => 0 < a.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
          (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd =
    (-1) ^ (k + 1) *
      ∑ a in filter (fun x => ¬0 < x.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
        (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd
sub_both_sides :
  (-1) ^ (k + 1) * ↑k * esymm σ R k -
      ∑ a in filter (fun a => 0 < a.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
        (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd =
    ∑ a in filter (fun a => a.fst < k ∧ ¬0 < a.fst) (antidiagonal k), (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd
⊢ filter (fun a => a.fst < k ∧ ¬0 < a.fst) (antidiagonal k) = {(0, k)}
[PROOFSTEP]
ext a
[GOAL]
case a
σ : 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.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
          (-1) ^ x.fst * esymm σ R x.fst * psum σ R x.snd +
        ∑ x in filter (fun x => ¬0 < x.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
          (-1) ^ x.fst * esymm σ R x.fst * psum σ R x.snd)
sub_both_sides✝ :
  ↑k * esymm σ R k -
      (-1) ^ (k + 1) *
        ∑ a in filter (fun a => 0 < a.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
          (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd =
    (-1) ^ (k + 1) *
      ∑ a in filter (fun x => ¬0 < x.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
        (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd
sub_both_sides :
  (-1) ^ (k + 1) * ↑k * esymm σ R k -
      ∑ a in filter (fun a => 0 < a.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
        (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd =
    ∑ a in filter (fun a => a.fst < k ∧ ¬0 < a.fst) (antidiagonal k), (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd
a : ℕ × ℕ
⊢ a ∈ filter (fun a => a.fst < k ∧ ¬0 < a.fst) (antidiagonal k) ↔ a ∈ {(0, k)}
[PROOFSTEP]
rw [mem_filter, mem_antidiagonal, mem_singleton]
[GOAL]
case a
σ : 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.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
          (-1) ^ x.fst * esymm σ R x.fst * psum σ R x.snd +
        ∑ x in filter (fun x => ¬0 < x.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
          (-1) ^ x.fst * esymm σ R x.fst * psum σ R x.snd)
sub_both_sides✝ :
  ↑k * esymm σ R k -
      (-1) ^ (k + 1) *
        ∑ a in filter (fun a => 0 < a.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
          (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd =
    (-1) ^ (k + 1) *
      ∑ a in filter (fun x => ¬0 < x.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
        (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd
sub_both_sides :
  (-1) ^ (k + 1) * ↑k * esymm σ R k -
      ∑ a in filter (fun a => 0 < a.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
        (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd =
    ∑ a in filter (fun a => a.fst < k ∧ ¬0 < a.fst) (antidiagonal k), (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd
a : ℕ × ℕ
⊢ a.fst + a.snd = k ∧ a.fst < k ∧ ¬0 < a.fst ↔ a = (0, k)
[PROOFSTEP]
refine' ⟨_, fun ha ↦ by aesop⟩
[GOAL]
σ : 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.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
          (-1) ^ x.fst * esymm σ R x.fst * psum σ R x.snd +
        ∑ x in filter (fun x => ¬0 < x.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
          (-1) ^ x.fst * esymm σ R x.fst * psum σ R x.snd)
sub_both_sides✝ :
  ↑k * esymm σ R k -
      (-1) ^ (k + 1) *
        ∑ a in filter (fun a => 0 < a.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
          (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd =
    (-1) ^ (k + 1) *
      ∑ a in filter (fun x => ¬0 < x.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
        (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd
sub_both_sides :
  (-1) ^ (k + 1) * ↑k * esymm σ R k -
      ∑ a in filter (fun a => 0 < a.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
        (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd =
    ∑ a in filter (fun a => a.fst < k ∧ ¬0 < a.fst) (antidiagonal k), (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd
a : ℕ × ℕ
ha : a = (0, k)
⊢ a.fst + a.snd = k ∧ a.fst < k ∧ ¬0 < a.fst
[PROOFSTEP]
aesop
[GOAL]
case a
σ : 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.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
          (-1) ^ x.fst * esymm σ R x.fst * psum σ R x.snd +
        ∑ x in filter (fun x => ¬0 < x.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
          (-1) ^ x.fst * esymm σ R x.fst * psum σ R x.snd)
sub_both_sides✝ :
  ↑k * esymm σ R k -
      (-1) ^ (k + 1) *
        ∑ a in filter (fun a => 0 < a.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
          (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd =
    (-1) ^ (k + 1) *
      ∑ a in filter (fun x => ¬0 < x.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
        (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd
sub_both_sides :
  (-1) ^ (k + 1) * ↑k * esymm σ R k -
      ∑ a in filter (fun a => 0 < a.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
        (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd =
    ∑ a in filter (fun a => a.fst < k ∧ ¬0 < a.fst) (antidiagonal k), (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd
a : ℕ × ℕ
⊢ a.fst + a.snd = k ∧ a.fst < k ∧ ¬0 < a.fst → a = (0, k)
[PROOFSTEP]
rintro ⟨ha, ⟨_, ha0⟩⟩
[GOAL]
case a.intro.intro
σ : 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.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
          (-1) ^ x.fst * esymm σ R x.fst * psum σ R x.snd +
        ∑ x in filter (fun x => ¬0 < x.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
          (-1) ^ x.fst * esymm σ R x.fst * psum σ R x.snd)
sub_both_sides✝ :
  ↑k * esymm σ R k -
      (-1) ^ (k + 1) *
        ∑ a in filter (fun a => 0 < a.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
          (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd =
    (-1) ^ (k + 1) *
      ∑ a in filter (fun x => ¬0 < x.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
        (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd
sub_both_sides :
  (-1) ^ (k + 1) * ↑k * esymm σ R k -
      ∑ a in filter (fun a => 0 < a.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
        (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd =
    ∑ a in filter (fun a => a.fst < k ∧ ¬0 < a.fst) (antidiagonal k), (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd
a : ℕ × ℕ
ha : a.fst + a.snd = k
left✝ : a.fst < k
ha0 : ¬0 < a.fst
⊢ a = (0, k)
[PROOFSTEP]
rw [← ha, Nat.eq_zero_of_nonpos a.fst ha0, zero_add, ← Nat.eq_zero_of_nonpos a.fst ha0]
[GOAL]
σ : 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.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
          (-1) ^ x.fst * esymm σ R x.fst * psum σ R x.snd +
        ∑ x in filter (fun x => ¬0 < x.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
          (-1) ^ x.fst * esymm σ R x.fst * psum σ R x.snd)
sub_both_sides✝ :
  ↑k * esymm σ R k -
      (-1) ^ (k + 1) *
        ∑ a in filter (fun a => 0 < a.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
          (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd =
    (-1) ^ (k + 1) *
      ∑ a in filter (fun x => ¬0 < x.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
        (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd
sub_both_sides :
  (-1) ^ (k + 1) * ↑k * esymm σ R k -
      ∑ a in filter (fun a => 0 < a.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
        (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd =
    ∑ a in filter (fun a => a.fst < k ∧ ¬0 < a.fst) (antidiagonal k), (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd
this : filter (fun a => a.fst < k ∧ ¬0 < a.fst) (antidiagonal k) = {(0, k)}
⊢ psum σ R k =
    (-1) ^ (k + 1) * ↑k * esymm σ R k -
      ∑ x in filter (fun a => a.fst < k ∧ 0 < a.fst) (antidiagonal k), (-1) ^ x.fst * esymm σ R x.fst * psum σ R x.snd
[PROOFSTEP]
rw [this, sum_singleton] at sub_both_sides 
[GOAL]
σ : 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.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
          (-1) ^ x.fst * esymm σ R x.fst * psum σ R x.snd +
        ∑ x in filter (fun x => ¬0 < x.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
          (-1) ^ x.fst * esymm σ R x.fst * psum σ R x.snd)
sub_both_sides✝ :
  ↑k * esymm σ R k -
      (-1) ^ (k + 1) *
        ∑ a in filter (fun a => 0 < a.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
          (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd =
    (-1) ^ (k + 1) *
      ∑ a in filter (fun x => ¬0 < x.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
        (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd
sub_both_sides :
  (-1) ^ (k + 1) * ↑k * esymm σ R k -
      ∑ a in filter (fun a => 0 < a.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
        (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd =
    (-1) ^ (0, k).fst * esymm σ R (0, k).fst * psum σ R (0, k).snd
this : filter (fun a => a.fst < k ∧ ¬0 < a.fst) (antidiagonal k) = {(0, k)}
⊢ psum σ R k =
    (-1) ^ (k + 1) * ↑k * esymm σ R k -
      ∑ x in filter (fun a => a.fst < k ∧ 0 < a.fst) (antidiagonal k), (-1) ^ x.fst * esymm σ R x.fst * psum σ R x.snd
[PROOFSTEP]
simp only [_root_.pow_zero, esymm_zero, mul_one, one_mul, filter_filter] at sub_both_sides 
[GOAL]
σ : 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.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
          (-1) ^ x.fst * esymm σ R x.fst * psum σ R x.snd +
        ∑ x in filter (fun x => ¬0 < x.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
          (-1) ^ x.fst * esymm σ R x.fst * psum σ R x.snd)
sub_both_sides✝ :
  ↑k * esymm σ R k -
      (-1) ^ (k + 1) *
        ∑ a in filter (fun a => 0 < a.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
          (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd =
    (-1) ^ (k + 1) *
      ∑ a in filter (fun x => ¬0 < x.fst) (filter (fun a => a.fst < k) (antidiagonal k)),
        (-1) ^ a.fst * esymm σ R a.fst * psum σ R a.snd
this : filter (fun a => a.fst < k ∧ ¬0 < a.fst) (antidiagonal k) = {(0, k)}
sub_both_sides :
  (-1) ^ (k + 1) * ↑k * esymm σ R k -
      ∑ x in filter (fun a => a.fst < k ∧ 0 < a.fst) (antidiagonal k), (-1) ^ x.fst * esymm σ R x.fst * psum σ R x.snd =
    psum σ R k
⊢ psum σ R k =
    (-1) ^ (k + 1) * ↑k * esymm σ R k -
      ∑ x in filter (fun a => a.fst < k ∧ 0 < a.fst) (antidiagonal k), (-1) ^ x.fst * esymm σ R x.fst * psum σ R x.snd
[PROOFSTEP]
exact sub_both_sides.symm
