l3lab/ntp-mathlib huggingface dataset:
/-- [Stacks: Lemma 0052 (3)](https://stacks.math.columbia.edu/tag/0052) -/
theorem NoetherianSpace.exists_open_ne_empty_le_irreducibleComponent [NoetherianSpace α]
    (Z : Set α) (H : Z ∈ irreducibleComponents α) :
    ∃ o : Set α, IsOpen o ∧ o ≠ ∅ ∧ o ≤ Z := by
  classical

  let ι : Set (Set α) := irreducibleComponents α \ {Z}
  have hι : ι.Finite := (NoetherianSpace.finite_irreducibleComponents (α := α)).subset
    (Set.diff_subset _ _)
  have hι' : Finite ι := by rwa [Set.finite_coe_iff]

  let U := Z \ ⋃ (x : ι), x
  have hU0 : U ≠ ∅ := λ r ↦ by
    obtain ⟨Z', hZ'⟩ := isIrreducible_iff_sUnion_closed.mp H.1 hι.toFinset
      (λ z hz ↦ by
        simp only [Set.Finite.mem_toFinset, Set.mem_diff, Set.mem_singleton_iff] at hz
        exact isClosed_of_mem_irreducibleComponents _ hz.1)
      (by
        rw [Set.Finite.coe_toFinset, Set.sUnion_eq_iUnion]
        rw [Set.diff_eq_empty] at r
        exact r)
    simp only [Set.Finite.mem_toFinset, Set.mem_diff, Set.mem_singleton_iff] at hZ'
    exact hZ'.1.2 $ le_antisymm (H.2 hZ'.1.1.1 hZ'.2) hZ'.2

  have hU1 : U = (⋃ (x : ι), x.1) ᶜ
  · rw [Set.compl_eq_univ_diff]
    refine le_antisymm (Set.diff_subset_diff le_top $ subset_refl _) ?_
    rw [← Set.compl_eq_univ_diff]
    refine Set.compl_subset_iff_union.mpr (le_antisymm le_top ?_)
    rw [Set.union_comm, ← Set.sUnion_eq_iUnion, ← Set.sUnion_insert]
    rintro a -
    by_cases h : a ∈ U
    · exact ⟨U, Set.mem_insert _ _, h⟩
    · rw [Set.mem_diff, Decidable.not_and, not_not, Set.mem_iUnion] at h
      rcases h with (h|⟨i, hi⟩)
      · refine ⟨irreducibleComponent a, Or.inr ?_, mem_irreducibleComponent⟩
        simp only [Set.mem_diff, Set.mem_singleton_iff]
        refine ⟨irreducibleComponent_mem_irreducibleComponents _, ?_⟩
        rintro rfl
        refine h mem_irreducibleComponent
      · exact ⟨i, Or.inr i.2, hi⟩

  refine ⟨U, hU1 ▸ isOpen_compl_iff.mpr ?_, hU0, sdiff_le⟩
  

Proof state:
α : Type u_1
β : Type u_2
inst✝² : TopologicalSpace α
inst✝¹ : TopologicalSpace β
inst✝ : NoetherianSpace α
Z : Set α
H : Z ∈ irreducibleComponents α
ι : Set (Set α) := irreducibleComponents α \ {Z}
hι : Set.Finite ι
hι' : Finite ↑ι
U : Set α := Z \ ⋃ x, ↑x
hU0 : U ≠ ∅
hU1 : U = (⋃ x, ↑x)ᶜ
⊢ IsClosed (⋃ x, ↑x)

Next tactic:
exact isClosed_iUnion_of_finite λ i ↦ isClosed_of_mem_irreducibleComponents i.1 i.2.1
@[simp]
private lemma mem_pairs (k : ℕ) (t : Finset σ × σ) :
    t ∈ pairs σ k ↔ card t.fst ≤ k ∧ (card t.fst = k → t.snd ∈ t.fst) := by
  

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

Next tactic:
simp [pairs]
private lemma pairMap_ne_self (t : Finset σ × σ) : pairMap σ t ≠ t := by
  

Proof state:
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
t : Finset σ × σ
⊢ MvPolynomial.NewtonIdentities.pairMap σ t ≠ t

Next tactic:
rw [pairMap]
private lemma pairMap_ne_self (t : Finset σ × σ) : pairMap σ t ≠ t := by
  rw [pairMap]
  

Proof state:
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
t : Finset σ × σ
⊢ (if h : t.2 ∈ t.1 then (erase t.1 t.2, t.2) else (cons t.2 t.1 h, t.2)) ≠ t

Next tactic:
split_ifs with h1
private lemma pairMap_ne_self (t : Finset σ × σ) : pairMap σ t ≠ t := by
  rw [pairMap]
  split_ifs with h1
  

Proof state:
case pos
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
t : Finset σ × σ
h1 : t.2 ∈ t.1
⊢ (erase t.1 t.2, t.2) ≠ t
case neg
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
t : Finset σ × σ
h1 : t.2 ∉ t.1
⊢ (cons t.2 t.1 h1, t.2) ≠ t

Next tactic:
all_goals by_contra ht; rw [← ht] at h1; simp_all
private lemma pairMap_ne_self (t : Finset σ × σ) : pairMap σ t ≠ t := by
  rw [pairMap]
  split_ifs with h1
  all_goals 

Proof state:
case pos
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
t : Finset σ × σ
h1 : t.2 ∈ t.1
⊢ (erase t.1 t.2, t.2) ≠ t

Next tactic:
by_contra ht
private lemma pairMap_ne_self (t : Finset σ × σ) : pairMap σ t ≠ t := by
  rw [pairMap]
  split_ifs with h1
  all_goals by_contra ht; 

Proof state:
case pos
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
t : Finset σ × σ
h1 : t.2 ∈ t.1
ht : (erase t.1 t.2, t.2) = t
⊢ False

Next tactic:
rw [← ht] at h1
private lemma pairMap_ne_self (t : Finset σ × σ) : pairMap σ t ≠ t := by
  rw [pairMap]
  split_ifs with h1
  all_goals by_contra ht; rw [← ht] at h1; 

Proof state:
case pos
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
t : Finset σ × σ
h1 : (erase t.1 t.2, t.2).2 ∈ (erase t.1 t.2, t.2).1
ht : (erase t.1 t.2, t.2) = t
⊢ False

Next tactic:
simp_all
private lemma pairMap_ne_self (t : Finset σ × σ) : pairMap σ t ≠ t := by
  rw [pairMap]
  split_ifs with h1
  all_goals 

Proof state:
case neg
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
t : Finset σ × σ
h1 : t.2 ∉ t.1
⊢ (cons t.2 t.1 h1, t.2) ≠ t

Next tactic:
by_contra ht
private lemma pairMap_ne_self (t : Finset σ × σ) : pairMap σ t ≠ t := by
  rw [pairMap]
  split_ifs with h1
  all_goals by_contra ht; 

Proof state:
case neg
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
t : Finset σ × σ
h1 : t.2 ∉ t.1
ht : (cons t.2 t.1 h1, t.2) = t
⊢ False

Next tactic:
rw [← ht] at h1
private lemma pairMap_ne_self (t : Finset σ × σ) : pairMap σ t ≠ t := by
  rw [pairMap]
  split_ifs with h1
  all_goals by_contra ht; rw [← ht] at h1; 

Proof state:
case neg
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
t : Finset σ × σ
h1✝ : t.2 ∉ t.1
h1 : (cons t.2 t.1 h1✝, t.2).2 ∉ (cons t.2 t.1 h1✝, t.2).1
ht : (cons t.2 t.1 h1✝, t.2) = t
⊢ False

Next tactic:
simp_all
private lemma pairMap_of_snd_mem_fst {t : Finset σ × σ} (h : t.snd ∈ t.fst) :
    pairMap σ t = (t.fst.erase t.snd, t.snd) := by
  

Proof state:
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
t : Finset σ × σ
h : t.2 ∈ t.1
⊢ MvPolynomial.NewtonIdentities.pairMap σ t = (erase t.1 t.2, t.2)

Next tactic:
simp [pairMap, h]
private lemma pairMap_of_snd_nmem_fst {t : Finset σ × σ} (h : t.snd ∉ t.fst) :
    pairMap σ t = (t.fst.cons t.snd h, t.snd) := by
  

Proof state:
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
t : Finset σ × σ
h : t.2 ∉ t.1
⊢ MvPolynomial.NewtonIdentities.pairMap σ t = (cons t.2 t.1 h, t.2)

Next tactic:
simp [pairMap, h]
private theorem pairMap_mem_pairs {k : ℕ} (t : Finset σ × σ) (h : t ∈ pairs σ k) :
    pairMap σ t ∈ pairs σ k := by
  

Proof state:
σ : 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

Next tactic:
rw [mem_pairs] at h ⊢
private theorem pairMap_mem_pairs {k : ℕ} (t : Finset σ × σ) (h : t ∈ pairs σ k) :
    pairMap σ t ∈ pairs σ k := by
  rw [mem_pairs] at h ⊢
  

Proof state:
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
t : Finset σ × σ
h : card t.1 ≤ k ∧ (card t.1 = k → t.2 ∈ t.1)
⊢ card (MvPolynomial.NewtonIdentities.pairMap σ t).1 ≤ k ∧
    (card (MvPolynomial.NewtonIdentities.pairMap σ t).1 = k →
      (MvPolynomial.NewtonIdentities.pairMap σ t).2 ∈ (MvPolynomial.NewtonIdentities.pairMap σ t).1)

Next tactic:
rcases (em (t.snd ∈ t.fst)) with h1 | h1
private theorem pairMap_mem_pairs {k : ℕ} (t : Finset σ × σ) (h : t ∈ pairs σ k) :
    pairMap σ t ∈ pairs σ k := by
  rw [mem_pairs] at h ⊢
  rcases (em (t.snd ∈ t.fst)) with h1 | h1
  · 

Proof state:
case inl
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
t : Finset σ × σ
h : card t.1 ≤ k ∧ (card t.1 = k → t.2 ∈ t.1)
h1 : t.2 ∈ t.1
⊢ card (MvPolynomial.NewtonIdentities.pairMap σ t).1 ≤ k ∧
    (card (MvPolynomial.NewtonIdentities.pairMap σ t).1 = k →
      (MvPolynomial.NewtonIdentities.pairMap σ t).2 ∈ (MvPolynomial.NewtonIdentities.pairMap σ t).1)

Next tactic:
rw [pairMap_of_snd_mem_fst σ h1]
private theorem pairMap_mem_pairs {k : ℕ} (t : Finset σ × σ) (h : t ∈ pairs σ k) :
    pairMap σ t ∈ pairs σ k := by
  rw [mem_pairs] at h ⊢
  rcases (em (t.snd ∈ t.fst)) with h1 | h1
  · rw [pairMap_of_snd_mem_fst σ h1]
    

Proof state:
case inl
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
t : Finset σ × σ
h : card t.1 ≤ k ∧ (card t.1 = k → t.2 ∈ t.1)
h1 : t.2 ∈ t.1
⊢ card (erase t.1 t.2, t.2).1 ≤ k ∧ (card (erase t.1 t.2, t.2).1 = k → (erase t.1 t.2, t.2).2 ∈ (erase t.1 t.2, t.2).1)

Next tactic:
simp only [h1, implies_true, and_true] at h
private theorem pairMap_mem_pairs {k : ℕ} (t : Finset σ × σ) (h : t ∈ pairs σ k) :
    pairMap σ t ∈ pairs σ k := by
  rw [mem_pairs] at h ⊢
  rcases (em (t.snd ∈ t.fst)) with h1 | h1
  · rw [pairMap_of_snd_mem_fst σ h1]
    simp only [h1, implies_true, and_true] at h
    

Proof state:
case inl
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
t : Finset σ × σ
h1 : t.2 ∈ t.1
h : card t.1 ≤ k
⊢ card (erase t.1 t.2, t.2).1 ≤ k ∧ (card (erase t.1 t.2, t.2).1 = k → (erase t.1 t.2, t.2).2 ∈ (erase t.1 t.2, t.2).1)

Next tactic:
simp only [card_erase_of_mem h1, tsub_le_iff_right, mem_erase, ne_eq, h1]
private theorem pairMap_mem_pairs {k : ℕ} (t : Finset σ × σ) (h : t ∈ pairs σ k) :
    pairMap σ t ∈ pairs σ k := by
  rw [mem_pairs] at h ⊢
  rcases (em (t.snd ∈ t.fst)) with h1 | h1
  · rw [pairMap_of_snd_mem_fst σ h1]
    simp only [h1, implies_true, and_true] at h
    simp only [card_erase_of_mem h1, tsub_le_iff_right, mem_erase, ne_eq, h1]
    

Proof state:
case inl
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
t : Finset σ × σ
h1 : t.2 ∈ t.1
h : card t.1 ≤ k
⊢ card t.1 ≤ k + 1 ∧ (card t.1 - 1 = k → ¬True ∧ True)

Next tactic:
refine ⟨le_step h, ?_⟩
private theorem pairMap_mem_pairs {k : ℕ} (t : Finset σ × σ) (h : t ∈ pairs σ k) :
    pairMap σ t ∈ pairs σ k := by
  rw [mem_pairs] at h ⊢
  rcases (em (t.snd ∈ t.fst)) with h1 | h1
  · rw [pairMap_of_snd_mem_fst σ h1]
    simp only [h1, implies_true, and_true] at h
    simp only [card_erase_of_mem h1, tsub_le_iff_right, mem_erase, ne_eq, h1]
    refine ⟨le_step h, ?_⟩
    

Proof state:
case inl
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
t : Finset σ × σ
h1 : t.2 ∈ t.1
h : card t.1 ≤ k
⊢ card t.1 - 1 = k → ¬True ∧ True

Next tactic:
by_contra h2
private theorem pairMap_mem_pairs {k : ℕ} (t : Finset σ × σ) (h : t ∈ pairs σ k) :
    pairMap σ t ∈ pairs σ k := by
  rw [mem_pairs] at h ⊢
  rcases (em (t.snd ∈ t.fst)) with h1 | h1
  · rw [pairMap_of_snd_mem_fst σ h1]
    simp only [h1, implies_true, and_true] at h
    simp only [card_erase_of_mem h1, tsub_le_iff_right, mem_erase, ne_eq, h1]
    refine ⟨le_step h, ?_⟩
    by_contra h2
    

Proof state:
case inl
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
t : Finset σ × σ
h1 : t.2 ∈ t.1
h : card t.1 ≤ k
h2 : ¬(card t.1 - 1 = k → ¬True ∧ True)
⊢ False

Next tactic:
simp only [not_true_eq_false, and_true, not_forall, not_false_eq_true, exists_prop] at h2
private theorem pairMap_mem_pairs {k : ℕ} (t : Finset σ × σ) (h : t ∈ pairs σ k) :
    pairMap σ t ∈ pairs σ k := by
  rw [mem_pairs] at h ⊢
  rcases (em (t.snd ∈ t.fst)) with h1 | h1
  · rw [pairMap_of_snd_mem_fst σ h1]
    simp only [h1, implies_true, and_true] at h
    simp only [card_erase_of_mem h1, tsub_le_iff_right, mem_erase, ne_eq, h1]
    refine ⟨le_step h, ?_⟩
    by_contra h2
    simp only [not_true_eq_false, and_true, not_forall, not_false_eq_true, exists_prop] at h2
    

Proof state:
case inl
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
t : Finset σ × σ
h1 : t.2 ∈ t.1
h : card t.1 ≤ k
h2 : card t.1 - 1 = k
⊢ False

Next tactic:
rw [← h2] at h
private theorem pairMap_mem_pairs {k : ℕ} (t : Finset σ × σ) (h : t ∈ pairs σ k) :
    pairMap σ t ∈ pairs σ k := by
  rw [mem_pairs] at h ⊢
  rcases (em (t.snd ∈ t.fst)) with h1 | h1
  · rw [pairMap_of_snd_mem_fst σ h1]
    simp only [h1, implies_true, and_true] at h
    simp only [card_erase_of_mem h1, tsub_le_iff_right, mem_erase, ne_eq, h1]
    refine ⟨le_step h, ?_⟩
    by_contra h2
    simp only [not_true_eq_false, and_true, not_forall, not_false_eq_true, exists_prop] at h2
    rw [← h2] at h
    

Proof state:
case inl
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
t : Finset σ × σ
h1 : t.2 ∈ t.1
h : card t.1 ≤ card t.1 - 1
h2 : card t.1 - 1 = k
⊢ False

Next tactic:
exact not_le_of_lt (sub_lt (card_pos.mpr ⟨t.snd, h1⟩) zero_lt_one) h
private theorem pairMap_mem_pairs {k : ℕ} (t : Finset σ × σ) (h : t ∈ pairs σ k) :
    pairMap σ t ∈ pairs σ k := by
  rw [mem_pairs] at h ⊢
  rcases (em (t.snd ∈ t.fst)) with h1 | h1
  · rw [pairMap_of_snd_mem_fst σ h1]
    simp only [h1, implies_true, and_true] at h
    simp only [card_erase_of_mem h1, tsub_le_iff_right, mem_erase, ne_eq, h1]
    refine ⟨le_step h, ?_⟩
    by_contra h2
    simp only [not_true_eq_false, and_true, not_forall, not_false_eq_true, exists_prop] at h2
    rw [← h2] at h
    exact not_le_of_lt (sub_lt (card_pos.mpr ⟨t.snd, h1⟩) zero_lt_one) h
  · 

Proof state:
case inr
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
t : Finset σ × σ
h : card t.1 ≤ k ∧ (card t.1 = k → t.2 ∈ t.1)
h1 : t.2 ∉ t.1
⊢ card (MvPolynomial.NewtonIdentities.pairMap σ t).1 ≤ k ∧
    (card (MvPolynomial.NewtonIdentities.pairMap σ t).1 = k →
      (MvPolynomial.NewtonIdentities.pairMap σ t).2 ∈ (MvPolynomial.NewtonIdentities.pairMap σ t).1)

Next tactic:
rw [pairMap_of_snd_nmem_fst σ h1]
private theorem pairMap_mem_pairs {k : ℕ} (t : Finset σ × σ) (h : t ∈ pairs σ k) :
    pairMap σ t ∈ pairs σ k := by
  rw [mem_pairs] at h ⊢
  rcases (em (t.snd ∈ t.fst)) with h1 | h1
  · rw [pairMap_of_snd_mem_fst σ h1]
    simp only [h1, implies_true, and_true] at h
    simp only [card_erase_of_mem h1, tsub_le_iff_right, mem_erase, ne_eq, h1]
    refine ⟨le_step h, ?_⟩
    by_contra h2
    simp only [not_true_eq_false, and_true, not_forall, not_false_eq_true, exists_prop] at h2
    rw [← h2] at h
    exact not_le_of_lt (sub_lt (card_pos.mpr ⟨t.snd, h1⟩) zero_lt_one) h
  · rw [pairMap_of_snd_nmem_fst σ h1]
    

Proof state:
case inr
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
t : Finset σ × σ
h : card t.1 ≤ k ∧ (card t.1 = k → t.2 ∈ t.1)
h1 : t.2 ∉ t.1
⊢ card (cons t.2 t.1 h1, t.2).1 ≤ k ∧
    (card (cons t.2 t.1 h1, t.2).1 = k → (cons t.2 t.1 h1, t.2).2 ∈ (cons t.2 t.1 h1, t.2).1)

Next tactic:
simp only [h1] at h
private theorem pairMap_mem_pairs {k : ℕ} (t : Finset σ × σ) (h : t ∈ pairs σ k) :
    pairMap σ t ∈ pairs σ k := by
  rw [mem_pairs] at h ⊢
  rcases (em (t.snd ∈ t.fst)) with h1 | h1
  · rw [pairMap_of_snd_mem_fst σ h1]
    simp only [h1, implies_true, and_true] at h
    simp only [card_erase_of_mem h1, tsub_le_iff_right, mem_erase, ne_eq, h1]
    refine ⟨le_step h, ?_⟩
    by_contra h2
    simp only [not_true_eq_false, and_true, not_forall, not_false_eq_true, exists_prop] at h2
    rw [← h2] at h
    exact not_le_of_lt (sub_lt (card_pos.mpr ⟨t.snd, h1⟩) zero_lt_one) h
  · rw [pairMap_of_snd_nmem_fst σ h1]
    simp only [h1] at h
    

Proof state:
case inr
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
t : Finset σ × σ
h1 : t.2 ∉ t.1
h : card t.1 ≤ k ∧ (card t.1 = k → False)
⊢ card (cons t.2 t.1 h1, t.2).1 ≤ k ∧
    (card (cons t.2 t.1 h1, t.2).1 = k → (cons t.2 t.1 h1, t.2).2 ∈ (cons t.2 t.1 h1, t.2).1)

Next tactic:
simp only [card_cons, mem_cons, true_or, implies_true, and_true]
private theorem pairMap_mem_pairs {k : ℕ} (t : Finset σ × σ) (h : t ∈ pairs σ k) :
    pairMap σ t ∈ pairs σ k := by
  rw [mem_pairs] at h ⊢
  rcases (em (t.snd ∈ t.fst)) with h1 | h1
  · rw [pairMap_of_snd_mem_fst σ h1]
    simp only [h1, implies_true, and_true] at h
    simp only [card_erase_of_mem h1, tsub_le_iff_right, mem_erase, ne_eq, h1]
    refine ⟨le_step h, ?_⟩
    by_contra h2
    simp only [not_true_eq_false, and_true, not_forall, not_false_eq_true, exists_prop] at h2
    rw [← h2] at h
    exact not_le_of_lt (sub_lt (card_pos.mpr ⟨t.snd, h1⟩) zero_lt_one) h
  · rw [pairMap_of_snd_nmem_fst σ h1]
    simp only [h1] at h
    simp only [card_cons, mem_cons, true_or, implies_true, and_true]
    

Proof state:
case inr
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
t : Finset σ × σ
h1 : t.2 ∉ t.1
h : card t.1 ≤ k ∧ (card t.1 = k → False)
⊢ card t.1 + 1 ≤ k

Next tactic:
exact (le_iff_eq_or_lt.mp h.left).resolve_left h.right
@[simp]
private theorem pairMap_involutive : (pairMap σ).Involutive := by
  

Proof state:
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
⊢ Function.Involutive (MvPolynomial.NewtonIdentities.pairMap σ)

Next tactic:
intro t
@[simp]
private theorem pairMap_involutive : (pairMap σ).Involutive := by
  intro t
  

Proof state:
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
t : Finset σ × σ
⊢ MvPolynomial.NewtonIdentities.pairMap σ (MvPolynomial.NewtonIdentities.pairMap σ t) = t

Next tactic:
rw [pairMap, pairMap]
@[simp]
private theorem pairMap_involutive : (pairMap σ).Involutive := by
  intro t
  rw [pairMap, pairMap]
  

Proof state:
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
t : Finset σ × σ
⊢ (if h :
        (if h : t.2 ∈ t.1 then (erase t.1 t.2, t.2) else (cons t.2 t.1 h, t.2)).2 ∈
          (if h : t.2 ∈ t.1 then (erase t.1 t.2, t.2) else (cons t.2 t.1 h, t.2)).1 then
      (erase (if h : t.2 ∈ t.1 then (erase t.1 t.2, t.2) else (cons t.2 t.1 h, t.2)).1
          (if h : t.2 ∈ t.1 then (erase t.1 t.2, t.2) else (cons t.2 t.1 h, t.2)).2,
        (if h : t.2 ∈ t.1 then (erase t.1 t.2, t.2) else (cons t.2 t.1 h, t.2)).2)
    else
      (cons (if h : t.2 ∈ t.1 then (erase t.1 t.2, t.2) else (cons t.2 t.1 h, t.2)).2
          (if h : t.2 ∈ t.1 then (erase t.1 t.2, t.2) else (cons t.2 t.1 h, t.2)).1 h,
        (if h : t.2 ∈ t.1 then (erase t.1 t.2, t.2) else (cons t.2 t.1 h, t.2)).2)) =
    t

Next tactic:
split_ifs with h1 h2 h3
@[simp]
private theorem pairMap_involutive : (pairMap σ).Involutive := by
  intro t
  rw [pairMap, pairMap]
  split_ifs with h1 h2 h3
  · 

Proof state:
case pos
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
t : Finset σ × σ
h1 : t.2 ∈ t.1
h2 : (erase t.1 t.2, t.2).2 ∈ (erase t.1 t.2, t.2).1
⊢ (erase (erase t.1 t.2, t.2).1 (erase t.1 t.2, t.2).2, (erase t.1 t.2, t.2).2) = t

Next tactic:
simp at h2
@[simp]
private theorem pairMap_involutive : (pairMap σ).Involutive := by
  intro t
  rw [pairMap, pairMap]
  split_ifs with h1 h2 h3
  · simp at h2
  · 

Proof state:
case neg
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
t : Finset σ × σ
h1 : t.2 ∈ t.1
h2 : (erase t.1 t.2, t.2).2 ∉ (erase t.1 t.2, t.2).1
⊢ (cons (erase t.1 t.2, t.2).2 (erase t.1 t.2, t.2).1 (_ : (erase t.1 t.2, t.2).2 ∉ (erase t.1 t.2, t.2).1),
      (erase t.1 t.2, t.2).2) =
    t

Next tactic:
simp [insert_erase h1]
@[simp]
private theorem pairMap_involutive : (pairMap σ).Involutive := by
  intro t
  rw [pairMap, pairMap]
  split_ifs with h1 h2 h3
  · simp at h2
  · simp [insert_erase h1]
  · 

Proof state:
case pos
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
t : Finset σ × σ
h1 : t.2 ∉ t.1
h3 : (cons t.2 t.1 h1, t.2).2 ∈ (cons t.2 t.1 h1, t.2).1
⊢ (erase (cons t.2 t.1 h1, t.2).1 (cons t.2 t.1 h1, t.2).2, (cons t.2 t.1 h1, t.2).2) = t

Next tactic:
simp_all
@[simp]
private theorem pairMap_involutive : (pairMap σ).Involutive := by
  intro t
  rw [pairMap, pairMap]
  split_ifs with h1 h2 h3
  · simp at h2
  · simp [insert_erase h1]
  · simp_all
  · 

Proof state:
case neg
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
t : Finset σ × σ
h1 : t.2 ∉ t.1
h3 : (cons t.2 t.1 h1, t.2).2 ∉ (cons t.2 t.1 h1, t.2).1
⊢ (cons (cons t.2 t.1 h1, t.2).2 (cons t.2 t.1 h1, t.2).1 (_ : (cons t.2 t.1 h1, t.2).2 ∉ (cons t.2 t.1 h1, t.2).1),
      (cons t.2 t.1 h1, t.2).2) =
    t

Next tactic:
simp at h3
private theorem weight_add_weight_pairMap {k : ℕ} (t : Finset σ × σ) (h : t ∈ pairs σ k) :
    weight σ R k t + weight σ R k (pairMap σ t) = 0 := by
  

Proof state:
σ : 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

Next tactic:
rw [weight, weight]
private theorem weight_add_weight_pairMap {k : ℕ} (t : Finset σ × σ) (h : t ∈ pairs σ k) :
    weight σ R k t + weight σ R k (pairMap σ t) = 0 := by
  rw [weight, weight]
  

Proof state:
σ : 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.1 * ((∏ a in t.1, X a) * X t.2 ^ (k - card t.1)) +
      (-1) ^ card (MvPolynomial.NewtonIdentities.pairMap σ t).1 *
        ((∏ a in (MvPolynomial.NewtonIdentities.pairMap σ t).1, X a) *
          X (MvPolynomial.NewtonIdentities.pairMap σ t).2 ^ (k - card (MvPolynomial.NewtonIdentities.pairMap σ t).1)) =
    0

Next tactic:
rw [mem_pairs] at h
private theorem weight_add_weight_pairMap {k : ℕ} (t : Finset σ × σ) (h : t ∈ pairs σ k) :
    weight σ R k t + weight σ R k (pairMap σ t) = 0 := by
  rw [weight, weight]
  rw [mem_pairs] at h
  

Proof state:
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
t : Finset σ × σ
h : card t.1 ≤ k ∧ (card t.1 = k → t.2 ∈ t.1)
⊢ (-1) ^ card t.1 * ((∏ a in t.1, X a) * X t.2 ^ (k - card t.1)) +
      (-1) ^ card (MvPolynomial.NewtonIdentities.pairMap σ t).1 *
        ((∏ a in (MvPolynomial.NewtonIdentities.pairMap σ t).1, X a) *
          X (MvPolynomial.NewtonIdentities.pairMap σ t).2 ^ (k - card (MvPolynomial.NewtonIdentities.pairMap σ t).1)) =
    0

Next tactic:
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]
private theorem weight_add_weight_pairMap {k : ℕ} (t : Finset σ × σ) (h : t ∈ pairs σ k) :
    weight σ R k t + weight σ R k (pairMap σ t) = 0 := by
  rw [weight, weight]
  rw [mem_pairs] at h
  have h2 (n : ℕ) : -(-1 : MvPolynomial σ R) ^ n = (-1) ^ (n + 1) := by
    

Proof state:
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
t : Finset σ × σ
h : card t.1 ≤ k ∧ (card t.1 = k → t.2 ∈ t.1)
n : ℕ
⊢ -(-1) ^ n = (-1) ^ (n + 1)

Next tactic:
rw [← neg_one_mul ((-1 : MvPolynomial σ R) ^ n), pow_add, pow_one, mul_comm]
private theorem weight_add_weight_pairMap {k : ℕ} (t : Finset σ × σ) (h : t ∈ pairs σ k) :
    weight σ R k t + weight σ R k (pairMap σ t) = 0 := by
  rw [weight, weight]
  rw [mem_pairs] at h
  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]
  

Proof state:
σ : Type u_1
inst✝² : Fintype σ
inst✝¹ : DecidableEq σ
R : Type u_2
inst✝ : CommRing R
k : ℕ
t : Finset σ × σ
h : card t.1 ≤ k ∧ (card t.1 = k → t.2 ∈ t.1)
h2 : ∀ (n : ℕ), -(-1) ^ n = (-1) ^ (n + 1)
⊢ (-1) ^ card t.1 * ((∏ a in t.1, X a) * X t.2 ^ (k - card t.1)) +
      (-1) ^ card (MvPolynomial.NewtonIdentities.pairMap σ t).1 *
        ((∏ a in (MvPolynomial.NewtonIdentities.pairMap σ t).1, X a) *
          X (MvPolynomial.NewtonIdentities.pairMap σ t).2 ^ (k - card (MvPolynomial.NewtonIdentities.pairMap σ t).1)) =
    0

Next tactic:
rcases (em (t.snd ∈ t.fst)) with h1 | h1