l3lab/ntp-mathlib huggingface dataset:
/-- The additive valuation on `HahnSeries Γ R`, returning the smallest index at which
  a Hahn Series has a nonzero coefficient, or `⊤` for the 0 series.  -/
def addVal : AddValuation (HahnSeries Γ R) (WithTop Γ) :=
  AddValuation.of (fun x => if x = (0 : HahnSeries Γ R) then (⊤ : WithTop Γ) else x.order)
    (if_pos rfl) ((if_neg one_ne_zero).trans (by simp [order_of_ne]))
    (fun x y => by
      by_cases hx : x = 0
      · by_cases hy : y = 0 <;> · simp [hx, hy]
      · by_cases hy : y = 0
        · simp [hx, hy]
        · simp only [hx, hy, support_nonempty_iff, if_neg, not_false_iff, isWf_support]
          by_cases hxy : x + y = 0
          · simp [hxy]
          rw [if_neg hxy, ← WithTop.coe_min, WithTop.coe_le_coe]
          exact min_order_le_order_add hxy)
    fun x y => by
    by_cases hx : x = 0
    · simp [hx]
    by_cases hy : y = 0
    · simp [hy]
    

Proof state:
case neg
Γ : Type u_1
R : Type u_2
inst✝² : LinearOrderedCancelAddCommMonoid Γ
inst✝¹ : Ring R
inst✝ : IsDomain R
x y : HahnSeries Γ R
hx : ¬x = 0
hy : ¬y = 0
⊢ (fun x => if x = 0 then ⊤ else ↑(order x)) (x * y) =
    (fun x => if x = 0 then ⊤ else ↑(order x)) x + (fun x => if x = 0 then ⊤ else ↑(order x)) y

Next tactic:
dsimp only
/-- The additive valuation on `HahnSeries Γ R`, returning the smallest index at which
  a Hahn Series has a nonzero coefficient, or `⊤` for the 0 series.  -/
def addVal : AddValuation (HahnSeries Γ R) (WithTop Γ) :=
  AddValuation.of (fun x => if x = (0 : HahnSeries Γ R) then (⊤ : WithTop Γ) else x.order)
    (if_pos rfl) ((if_neg one_ne_zero).trans (by simp [order_of_ne]))
    (fun x y => by
      by_cases hx : x = 0
      · by_cases hy : y = 0 <;> · simp [hx, hy]
      · by_cases hy : y = 0
        · simp [hx, hy]
        · simp only [hx, hy, support_nonempty_iff, if_neg, not_false_iff, isWf_support]
          by_cases hxy : x + y = 0
          · simp [hxy]
          rw [if_neg hxy, ← WithTop.coe_min, WithTop.coe_le_coe]
          exact min_order_le_order_add hxy)
    fun x y => by
    by_cases hx : x = 0
    · simp [hx]
    by_cases hy : y = 0
    · simp [hy]
    dsimp only
    

Proof state:
case neg
Γ : Type u_1
R : Type u_2
inst✝² : LinearOrderedCancelAddCommMonoid Γ
inst✝¹ : Ring R
inst✝ : IsDomain R
x y : HahnSeries Γ R
hx : ¬x = 0
hy : ¬y = 0
⊢ (if x * y = 0 then ⊤ else ↑(order (x * y))) = (if x = 0 then ⊤ else ↑(order x)) + if y = 0 then ⊤ else ↑(order y)

Next tactic:
rw [if_neg hx, if_neg hy, if_neg (mul_ne_zero hx hy), ← WithTop.coe_add, WithTop.coe_eq_coe,
      order_mul hx hy]
theorem addVal_le_of_coeff_ne_zero {x : HahnSeries Γ R} {g : Γ} (h : x.coeff g ≠ 0) :
    addVal Γ R x ≤ g := by
  

Proof state:
Γ : Type u_1
R : Type u_2
inst✝² : LinearOrderedCancelAddCommMonoid Γ
inst✝¹ : Ring R
inst✝ : IsDomain R
x : HahnSeries Γ R
g : Γ
h : coeff x g ≠ 0
⊢ (addVal Γ R) x ≤ ↑g

Next tactic:
rw [addVal_apply_of_ne (ne_zero_of_coeff_ne_zero h), WithTop.coe_le_coe]
theorem addVal_le_of_coeff_ne_zero {x : HahnSeries Γ R} {g : Γ} (h : x.coeff g ≠ 0) :
    addVal Γ R x ≤ g := by
  rw [addVal_apply_of_ne (ne_zero_of_coeff_ne_zero h), WithTop.coe_le_coe]
  

Proof state:
Γ : Type u_1
R : Type u_2
inst✝² : LinearOrderedCancelAddCommMonoid Γ
inst✝¹ : Ring R
inst✝ : IsDomain R
x : HahnSeries Γ R
g : Γ
h : coeff x g ≠ 0
⊢ order x ≤ g

Next tactic:
exact order_le_of_coeff_ne_zero h
theorem isPwo_iUnion_support_powers [LinearOrderedCancelAddCommMonoid Γ] [Ring R] [IsDomain R]
    {x : HahnSeries Γ R} (hx : 0 < addVal Γ R x) : (⋃ n : ℕ, (x ^ n).support).IsPwo := by
  

Proof state:
Γ : Type u_1
R : Type u_2
inst✝² : LinearOrderedCancelAddCommMonoid Γ
inst✝¹ : Ring R
inst✝ : IsDomain R
x : HahnSeries Γ R
hx : 0 < (addVal Γ R) x
⊢ Set.IsPwo (⋃ n, support (x ^ n))

Next tactic:
apply (x.isWf_support.isPwo.addSubmonoid_closure _).mono _
theorem isPwo_iUnion_support_powers [LinearOrderedCancelAddCommMonoid Γ] [Ring R] [IsDomain R]
    {x : HahnSeries Γ R} (hx : 0 < addVal Γ R x) : (⋃ n : ℕ, (x ^ n).support).IsPwo := by
  apply (x.isWf_support.isPwo.addSubmonoid_closure _).mono _
  · 

Proof state:
Γ : Type u_1
R : Type u_2
inst✝² : LinearOrderedCancelAddCommMonoid Γ
inst✝¹ : Ring R
inst✝ : IsDomain R
x : HahnSeries Γ R
hx : 0 < (addVal Γ R) x
⊢ ∀ x_1 ∈ support x, 0 ≤ x_1

Next tactic:
exact fun g hg => WithTop.coe_le_coe.1 (le_trans (le_of_lt hx) (addVal_le_of_coeff_ne_zero hg))
theorem isPwo_iUnion_support_powers [LinearOrderedCancelAddCommMonoid Γ] [Ring R] [IsDomain R]
    {x : HahnSeries Γ R} (hx : 0 < addVal Γ R x) : (⋃ n : ℕ, (x ^ n).support).IsPwo := by
  apply (x.isWf_support.isPwo.addSubmonoid_closure _).mono _
  · exact fun g hg => WithTop.coe_le_coe.1 (le_trans (le_of_lt hx) (addVal_le_of_coeff_ne_zero hg))
  

Proof state:
Γ : Type u_1
R : Type u_2
inst✝² : LinearOrderedCancelAddCommMonoid Γ
inst✝¹ : Ring R
inst✝ : IsDomain R
x : HahnSeries Γ R
hx : 0 < (addVal Γ R) x
⊢ ⋃ n, support (x ^ n) ⊆ ↑(AddSubmonoid.closure (support x))

Next tactic:
refine' Set.iUnion_subset fun n => _
theorem isPwo_iUnion_support_powers [LinearOrderedCancelAddCommMonoid Γ] [Ring R] [IsDomain R]
    {x : HahnSeries Γ R} (hx : 0 < addVal Γ R x) : (⋃ n : ℕ, (x ^ n).support).IsPwo := by
  apply (x.isWf_support.isPwo.addSubmonoid_closure _).mono _
  · exact fun g hg => WithTop.coe_le_coe.1 (le_trans (le_of_lt hx) (addVal_le_of_coeff_ne_zero hg))
  refine' Set.iUnion_subset fun n => _
  

Proof state:
Γ : Type u_1
R : Type u_2
inst✝² : LinearOrderedCancelAddCommMonoid Γ
inst✝¹ : Ring R
inst✝ : IsDomain R
x : HahnSeries Γ R
hx : 0 < (addVal Γ R) x
n : ℕ
⊢ support (x ^ n) ⊆ ↑(AddSubmonoid.closure (support x))

Next tactic:
induction' n with n ih
theorem isPwo_iUnion_support_powers [LinearOrderedCancelAddCommMonoid Γ] [Ring R] [IsDomain R]
    {x : HahnSeries Γ R} (hx : 0 < addVal Γ R x) : (⋃ n : ℕ, (x ^ n).support).IsPwo := by
  apply (x.isWf_support.isPwo.addSubmonoid_closure _).mono _
  · exact fun g hg => WithTop.coe_le_coe.1 (le_trans (le_of_lt hx) (addVal_le_of_coeff_ne_zero hg))
  refine' Set.iUnion_subset fun n => _
  induction' n with n ih <;> 

Proof state:
case zero
Γ : Type u_1
R : Type u_2
inst✝² : LinearOrderedCancelAddCommMonoid Γ
inst✝¹ : Ring R
inst✝ : IsDomain R
x : HahnSeries Γ R
hx : 0 < (addVal Γ R) x
⊢ support (x ^ Nat.zero) ⊆ ↑(AddSubmonoid.closure (support x))

Next tactic:
intro g hn
theorem isPwo_iUnion_support_powers [LinearOrderedCancelAddCommMonoid Γ] [Ring R] [IsDomain R]
    {x : HahnSeries Γ R} (hx : 0 < addVal Γ R x) : (⋃ n : ℕ, (x ^ n).support).IsPwo := by
  apply (x.isWf_support.isPwo.addSubmonoid_closure _).mono _
  · exact fun g hg => WithTop.coe_le_coe.1 (le_trans (le_of_lt hx) (addVal_le_of_coeff_ne_zero hg))
  refine' Set.iUnion_subset fun n => _
  induction' n with n ih <;> 

Proof state:
case succ
Γ : Type u_1
R : Type u_2
inst✝² : LinearOrderedCancelAddCommMonoid Γ
inst✝¹ : Ring R
inst✝ : IsDomain R
x : HahnSeries Γ R
hx : 0 < (addVal Γ R) x
n : ℕ
ih : support (x ^ n) ⊆ ↑(AddSubmonoid.closure (support x))
⊢ support (x ^ Nat.succ n) ⊆ ↑(AddSubmonoid.closure (support x))

Next tactic:
intro g hn
theorem isPwo_iUnion_support_powers [LinearOrderedCancelAddCommMonoid Γ] [Ring R] [IsDomain R]
    {x : HahnSeries Γ R} (hx : 0 < addVal Γ R x) : (⋃ n : ℕ, (x ^ n).support).IsPwo := by
  apply (x.isWf_support.isPwo.addSubmonoid_closure _).mono _
  · exact fun g hg => WithTop.coe_le_coe.1 (le_trans (le_of_lt hx) (addVal_le_of_coeff_ne_zero hg))
  refine' Set.iUnion_subset fun n => _
  induction' n with n ih <;> intro g hn
  · 

Proof state:
case zero
Γ : Type u_1
R : Type u_2
inst✝² : LinearOrderedCancelAddCommMonoid Γ
inst✝¹ : Ring R
inst✝ : IsDomain R
x : HahnSeries Γ R
hx : 0 < (addVal Γ R) x
g : Γ
hn : g ∈ support (x ^ Nat.zero)
⊢ g ∈ ↑(AddSubmonoid.closure (support x))

Next tactic:
simp only [Nat.zero_eq, pow_zero, support_one, Set.mem_singleton_iff] at hn
theorem isPwo_iUnion_support_powers [LinearOrderedCancelAddCommMonoid Γ] [Ring R] [IsDomain R]
    {x : HahnSeries Γ R} (hx : 0 < addVal Γ R x) : (⋃ n : ℕ, (x ^ n).support).IsPwo := by
  apply (x.isWf_support.isPwo.addSubmonoid_closure _).mono _
  · exact fun g hg => WithTop.coe_le_coe.1 (le_trans (le_of_lt hx) (addVal_le_of_coeff_ne_zero hg))
  refine' Set.iUnion_subset fun n => _
  induction' n with n ih <;> intro g hn
  · simp only [Nat.zero_eq, pow_zero, support_one, Set.mem_singleton_iff] at hn
    

Proof state:
case zero
Γ : Type u_1
R : Type u_2
inst✝² : LinearOrderedCancelAddCommMonoid Γ
inst✝¹ : Ring R
inst✝ : IsDomain R
x : HahnSeries Γ R
hx : 0 < (addVal Γ R) x
g : Γ
hn : g = 0
⊢ g ∈ ↑(AddSubmonoid.closure (support x))

Next tactic:
rw [hn, SetLike.mem_coe]
theorem isPwo_iUnion_support_powers [LinearOrderedCancelAddCommMonoid Γ] [Ring R] [IsDomain R]
    {x : HahnSeries Γ R} (hx : 0 < addVal Γ R x) : (⋃ n : ℕ, (x ^ n).support).IsPwo := by
  apply (x.isWf_support.isPwo.addSubmonoid_closure _).mono _
  · exact fun g hg => WithTop.coe_le_coe.1 (le_trans (le_of_lt hx) (addVal_le_of_coeff_ne_zero hg))
  refine' Set.iUnion_subset fun n => _
  induction' n with n ih <;> intro g hn
  · simp only [Nat.zero_eq, pow_zero, support_one, Set.mem_singleton_iff] at hn
    rw [hn, SetLike.mem_coe]
    

Proof state:
case zero
Γ : Type u_1
R : Type u_2
inst✝² : LinearOrderedCancelAddCommMonoid Γ
inst✝¹ : Ring R
inst✝ : IsDomain R
x : HahnSeries Γ R
hx : 0 < (addVal Γ R) x
g : Γ
hn : g = 0
⊢ 0 ∈ AddSubmonoid.closure (support x)

Next tactic:
exact AddSubmonoid.zero_mem _
theorem isPwo_iUnion_support_powers [LinearOrderedCancelAddCommMonoid Γ] [Ring R] [IsDomain R]
    {x : HahnSeries Γ R} (hx : 0 < addVal Γ R x) : (⋃ n : ℕ, (x ^ n).support).IsPwo := by
  apply (x.isWf_support.isPwo.addSubmonoid_closure _).mono _
  · exact fun g hg => WithTop.coe_le_coe.1 (le_trans (le_of_lt hx) (addVal_le_of_coeff_ne_zero hg))
  refine' Set.iUnion_subset fun n => _
  induction' n with n ih <;> intro g hn
  · simp only [Nat.zero_eq, pow_zero, support_one, Set.mem_singleton_iff] at hn
    rw [hn, SetLike.mem_coe]
    exact AddSubmonoid.zero_mem _
  · 

Proof state:
case succ
Γ : Type u_1
R : Type u_2
inst✝² : LinearOrderedCancelAddCommMonoid Γ
inst✝¹ : Ring R
inst✝ : IsDomain R
x : HahnSeries Γ R
hx : 0 < (addVal Γ R) x
n : ℕ
ih : support (x ^ n) ⊆ ↑(AddSubmonoid.closure (support x))
g : Γ
hn : g ∈ support (x ^ Nat.succ n)
⊢ g ∈ ↑(AddSubmonoid.closure (support x))

Next tactic:
obtain ⟨i, j, hi, hj, rfl⟩ := support_mul_subset_add_support hn
theorem isPwo_iUnion_support_powers [LinearOrderedCancelAddCommMonoid Γ] [Ring R] [IsDomain R]
    {x : HahnSeries Γ R} (hx : 0 < addVal Γ R x) : (⋃ n : ℕ, (x ^ n).support).IsPwo := by
  apply (x.isWf_support.isPwo.addSubmonoid_closure _).mono _
  · exact fun g hg => WithTop.coe_le_coe.1 (le_trans (le_of_lt hx) (addVal_le_of_coeff_ne_zero hg))
  refine' Set.iUnion_subset fun n => _
  induction' n with n ih <;> intro g hn
  · simp only [Nat.zero_eq, pow_zero, support_one, Set.mem_singleton_iff] at hn
    rw [hn, SetLike.mem_coe]
    exact AddSubmonoid.zero_mem _
  · obtain ⟨i, j, hi, hj, rfl⟩ := support_mul_subset_add_support hn
    

Proof state:
case succ.intro.intro.intro.intro
Γ : Type u_1
R : Type u_2
inst✝² : LinearOrderedCancelAddCommMonoid Γ
inst✝¹ : Ring R
inst✝ : IsDomain R
x : HahnSeries Γ R
hx : 0 < (addVal Γ R) x
n : ℕ
ih : support (x ^ n) ⊆ ↑(AddSubmonoid.closure (support x))
i j : Γ
hi : i ∈ support x
hj : j ∈ support (npowRec n x)
hn : (fun x x_1 => x + x_1) i j ∈ support (x ^ Nat.succ n)
⊢ (fun x x_1 => x + x_1) i j ∈ ↑(AddSubmonoid.closure (support x))

Next tactic:
exact SetLike.mem_coe.2 (AddSubmonoid.add_mem _ (AddSubmonoid.subset_closure hi) (ih hj))
instance : Add (SummableFamily Γ R α) :=
  ⟨fun x y =>
    { toFun := x + y
      isPwo_iUnion_support' :=
        (x.isPwo_iUnion_support.union y.isPwo_iUnion_support).mono
          (by
            

Proof state:
Γ : Type u_1
R : Type u_2
inst✝¹ : PartialOrder Γ
inst✝ : AddCommMonoid R
α : Type u_3
x y : SummableFamily Γ R α
⊢ ⋃ a, support ((⇑x + ⇑y) a) ⊆ (⋃ a, support (x a)) ∪ ⋃ a, support (y a)

Next tactic:
rw [← Set.iUnion_union_distrib]
instance : Add (SummableFamily Γ R α) :=
  ⟨fun x y =>
    { toFun := x + y
      isPwo_iUnion_support' :=
        (x.isPwo_iUnion_support.union y.isPwo_iUnion_support).mono
          (by
            rw [← Set.iUnion_union_distrib]
            

Proof state:
Γ : Type u_1
R : Type u_2
inst✝¹ : PartialOrder Γ
inst✝ : AddCommMonoid R
α : Type u_3
x y : SummableFamily Γ R α
⊢ ⋃ a, support ((⇑x + ⇑y) a) ⊆ ⋃ i, support (x i) ∪ support (y i)

Next tactic:
exact Set.iUnion_mono fun a => support_add_subset
instance : Add (SummableFamily Γ R α) :=
  ⟨fun x y =>
    { toFun := x + y
      isPwo_iUnion_support' :=
        (x.isPwo_iUnion_support.union y.isPwo_iUnion_support).mono
          (by
            rw [← Set.iUnion_union_distrib]
            exact Set.iUnion_mono fun a => support_add_subset)
      finite_co_support' := fun g =>
        ((x.finite_co_support g).union (y.finite_co_support g)).subset
          (by
            

Proof state:
Γ : Type u_1
R : Type u_2
inst✝¹ : PartialOrder Γ
inst✝ : AddCommMonoid R
α : Type u_3
x y : SummableFamily Γ R α
g : Γ
⊢ {a | coeff ((⇑x + ⇑y) a) g ≠ 0} ⊆ (Function.support fun a => coeff (x a) g) ∪ Function.support fun a => coeff (y a) g

Next tactic:
intro a ha
instance : Add (SummableFamily Γ R α) :=
  ⟨fun x y =>
    { toFun := x + y
      isPwo_iUnion_support' :=
        (x.isPwo_iUnion_support.union y.isPwo_iUnion_support).mono
          (by
            rw [← Set.iUnion_union_distrib]
            exact Set.iUnion_mono fun a => support_add_subset)
      finite_co_support' := fun g =>
        ((x.finite_co_support g).union (y.finite_co_support g)).subset
          (by
            intro a ha
            

Proof state:
Γ : Type u_1
R : Type u_2
inst✝¹ : PartialOrder Γ
inst✝ : AddCommMonoid R
α : Type u_3
x y : SummableFamily Γ R α
g : Γ
a : α
ha : a ∈ {a | coeff ((⇑x + ⇑y) a) g ≠ 0}
⊢ a ∈ (Function.support fun a => coeff (x a) g) ∪ Function.support fun a => coeff (y a) g

Next tactic:
change (x a).coeff g + (y a).coeff g ≠ 0 at ha
instance : Add (SummableFamily Γ R α) :=
  ⟨fun x y =>
    { toFun := x + y
      isPwo_iUnion_support' :=
        (x.isPwo_iUnion_support.union y.isPwo_iUnion_support).mono
          (by
            rw [← Set.iUnion_union_distrib]
            exact Set.iUnion_mono fun a => support_add_subset)
      finite_co_support' := fun g =>
        ((x.finite_co_support g).union (y.finite_co_support g)).subset
          (by
            intro a ha
            change (x a).coeff g + (y a).coeff g ≠ 0 at ha
            

Proof state:
Γ : Type u_1
R : Type u_2
inst✝¹ : PartialOrder Γ
inst✝ : AddCommMonoid R
α : Type u_3
x y : SummableFamily Γ R α
g : Γ
a : α
ha : coeff (x a) g + coeff (y a) g ≠ 0
⊢ a ∈ (Function.support fun a => coeff (x a) g) ∪ Function.support fun a => coeff (y a) g

Next tactic:
rw [Set.mem_union, Function.mem_support, Function.mem_support]
instance : Add (SummableFamily Γ R α) :=
  ⟨fun x y =>
    { toFun := x + y
      isPwo_iUnion_support' :=
        (x.isPwo_iUnion_support.union y.isPwo_iUnion_support).mono
          (by
            rw [← Set.iUnion_union_distrib]
            exact Set.iUnion_mono fun a => support_add_subset)
      finite_co_support' := fun g =>
        ((x.finite_co_support g).union (y.finite_co_support g)).subset
          (by
            intro a ha
            change (x a).coeff g + (y a).coeff g ≠ 0 at ha
            rw [Set.mem_union, Function.mem_support, Function.mem_support]
            

Proof state:
Γ : Type u_1
R : Type u_2
inst✝¹ : PartialOrder Γ
inst✝ : AddCommMonoid R
α : Type u_3
x y : SummableFamily Γ R α
g : Γ
a : α
ha : coeff (x a) g + coeff (y a) g ≠ 0
⊢ coeff (x a) g ≠ 0 ∨ coeff (y a) g ≠ 0

Next tactic:
contrapose! ha
instance : Add (SummableFamily Γ R α) :=
  ⟨fun x y =>
    { toFun := x + y
      isPwo_iUnion_support' :=
        (x.isPwo_iUnion_support.union y.isPwo_iUnion_support).mono
          (by
            rw [← Set.iUnion_union_distrib]
            exact Set.iUnion_mono fun a => support_add_subset)
      finite_co_support' := fun g =>
        ((x.finite_co_support g).union (y.finite_co_support g)).subset
          (by
            intro a ha
            change (x a).coeff g + (y a).coeff g ≠ 0 at ha
            rw [Set.mem_union, Function.mem_support, Function.mem_support]
            contrapose! ha
            

Proof state:
Γ : Type u_1
R : Type u_2
inst✝¹ : PartialOrder Γ
inst✝ : AddCommMonoid R
α : Type u_3
x y : SummableFamily Γ R α
g : Γ
a : α
ha : coeff (x a) g = 0 ∧ coeff (y a) g = 0
⊢ coeff (x a) g + coeff (y a) g = 0

Next tactic:
rw [ha.1, ha.2, add_zero]
instance : Zero (SummableFamily Γ R α) :=
  ⟨⟨0, by 

Proof state:
Γ : Type u_1
R : Type u_2
inst✝¹ : PartialOrder Γ
inst✝ : AddCommMonoid R
α : Type u_3
⊢ Set.IsPwo (⋃ a, support (OfNat.ofNat 0 a))

Next tactic:
simp
instance : Zero (SummableFamily Γ R α) :=
  ⟨⟨0, by simp, by 

Proof state:
Γ : Type u_1
R : Type u_2
inst✝¹ : PartialOrder Γ
inst✝ : AddCommMonoid R
α : Type u_3
⊢ ∀ (g : Γ), Set.Finite {a | coeff (OfNat.ofNat 0 a) g ≠ 0}

Next tactic:
simp
instance : AddCommMonoid (SummableFamily Γ R α) where
  add := (· + ·)
  zero := 0
  zero_add s := by
    ext
    apply zero_add
  add_zero s := by
    ext
    apply add_zero
  add_comm s t := by
    ext
    apply add_comm
  add_assoc r s t := by
    

Proof state:
Γ : Type u_1
R : Type u_2
inst✝¹ : PartialOrder Γ
inst✝ : AddCommMonoid R
α : Type u_3
r s t : SummableFamily Γ R α
⊢ r + s + t = r + (s + t)

Next tactic:
ext
instance : AddCommMonoid (SummableFamily Γ R α) where
  add := (· + ·)
  zero := 0
  zero_add s := by
    ext
    apply zero_add
  add_zero s := by
    ext
    apply add_zero
  add_comm s t := by
    ext
    apply add_comm
  add_assoc r s t := by
    ext
    

Proof state:
case h.coeff.h
Γ : Type u_1
R : Type u_2
inst✝¹ : PartialOrder Γ
inst✝ : AddCommMonoid R
α : Type u_3
r s t : SummableFamily Γ R α
a✝ : α
x✝ : Γ
⊢ coeff ((r + s + t) a✝) x✝ = coeff ((r + (s + t)) a✝) x✝

Next tactic:
apply add_assoc
instance : AddCommMonoid (SummableFamily Γ R α) where
  add := (· + ·)
  zero := 0
  zero_add s := by
    

Proof state:
Γ : Type u_1
R : Type u_2
inst✝¹ : PartialOrder Γ
inst✝ : AddCommMonoid R
α : Type u_3
s : SummableFamily Γ R α
⊢ 0 + s = s

Next tactic:
ext
instance : AddCommMonoid (SummableFamily Γ R α) where
  add := (· + ·)
  zero := 0
  zero_add s := by
    ext
    

Proof state:
case h.coeff.h
Γ : Type u_1
R : Type u_2
inst✝¹ : PartialOrder Γ
inst✝ : AddCommMonoid R
α : Type u_3
s : SummableFamily Γ R α
a✝ : α
x✝ : Γ
⊢ coeff ((0 + s) a✝) x✝ = coeff (s a✝) x✝

Next tactic:
apply zero_add
instance : AddCommMonoid (SummableFamily Γ R α) where
  add := (· + ·)
  zero := 0
  zero_add s := by
    ext
    apply zero_add
  add_zero s := by
    

Proof state:
Γ : Type u_1
R : Type u_2
inst✝¹ : PartialOrder Γ
inst✝ : AddCommMonoid R
α : Type u_3
s : SummableFamily Γ R α
⊢ s + 0 = s

Next tactic:
ext
instance : AddCommMonoid (SummableFamily Γ R α) where
  add := (· + ·)
  zero := 0
  zero_add s := by
    ext
    apply zero_add
  add_zero s := by
    ext
    

Proof state:
case h.coeff.h
Γ : Type u_1
R : Type u_2
inst✝¹ : PartialOrder Γ
inst✝ : AddCommMonoid R
α : Type u_3
s : SummableFamily Γ R α
a✝ : α
x✝ : Γ
⊢ coeff ((s + 0) a✝) x✝ = coeff (s a✝) x✝

Next tactic:
apply add_zero
instance : AddCommMonoid (SummableFamily Γ R α) where
  add := (· + ·)
  zero := 0
  zero_add s := by
    ext
    apply zero_add
  add_zero s := by
    ext
    apply add_zero
  add_comm s t := by
    

Proof state:
Γ : Type u_1
R : Type u_2
inst✝¹ : PartialOrder Γ
inst✝ : AddCommMonoid R
α : Type u_3
s t : SummableFamily Γ R α
⊢ s + t = t + s

Next tactic:
ext
instance : AddCommMonoid (SummableFamily Γ R α) where
  add := (· + ·)
  zero := 0
  zero_add s := by
    ext
    apply zero_add
  add_zero s := by
    ext
    apply add_zero
  add_comm s t := by
    ext
    

Proof state:
case h.coeff.h
Γ : Type u_1
R : Type u_2
inst✝¹ : PartialOrder Γ
inst✝ : AddCommMonoid R
α : Type u_3
s t : SummableFamily Γ R α
a✝ : α
x✝ : Γ
⊢ coeff ((s + t) a✝) x✝ = coeff ((t + s) a✝) x✝

Next tactic:
apply add_comm
/-- The infinite sum of a `SummableFamily` of Hahn series. -/
def hsum (s : SummableFamily Γ R α) : HahnSeries Γ R where
  coeff g := ∑ᶠ i, (s i).coeff g
  isPwo_support' :=
    s.isPwo_iUnion_support.mono fun g => by
      

Proof state:
Γ : Type u_1
R : Type u_2
inst✝¹ : PartialOrder Γ
inst✝ : AddCommMonoid R
α : Type u_3
s : SummableFamily Γ R α
g : Γ
⊢ (g ∈ Function.support fun g => ∑ᶠ (i : α), coeff (s i) g) → g ∈ ⋃ a, support (s a)

Next tactic:
contrapose
/-- The infinite sum of a `SummableFamily` of Hahn series. -/
def hsum (s : SummableFamily Γ R α) : HahnSeries Γ R where
  coeff g := ∑ᶠ i, (s i).coeff g
  isPwo_support' :=
    s.isPwo_iUnion_support.mono fun g => by
      contrapose
      

Proof state:
Γ : Type u_1
R : Type u_2
inst✝¹ : PartialOrder Γ
inst✝ : AddCommMonoid R
α : Type u_3
s : SummableFamily Γ R α
g : Γ
⊢ g ∉ ⋃ a, support (s a) → g ∉ Function.support fun g => ∑ᶠ (i : α), coeff (s i) g

Next tactic:
rw [Set.mem_iUnion, not_exists, Function.mem_support, Classical.not_not]
/-- The infinite sum of a `SummableFamily` of Hahn series. -/
def hsum (s : SummableFamily Γ R α) : HahnSeries Γ R where
  coeff g := ∑ᶠ i, (s i).coeff g
  isPwo_support' :=
    s.isPwo_iUnion_support.mono fun g => by
      contrapose
      rw [Set.mem_iUnion, not_exists, Function.mem_support, Classical.not_not]
      

Proof state:
Γ : Type u_1
R : Type u_2
inst✝¹ : PartialOrder Γ
inst✝ : AddCommMonoid R
α : Type u_3
s : SummableFamily Γ R α
g : Γ
⊢ (∀ (x : α), g ∉ support (s x)) → ∑ᶠ (i : α), coeff (s i) g = 0

Next tactic:
simp_rw [mem_support, Classical.not_not]
/-- The infinite sum of a `SummableFamily` of Hahn series. -/
def hsum (s : SummableFamily Γ R α) : HahnSeries Γ R where
  coeff g := ∑ᶠ i, (s i).coeff g
  isPwo_support' :=
    s.isPwo_iUnion_support.mono fun g => by
      contrapose
      rw [Set.mem_iUnion, not_exists, Function.mem_support, Classical.not_not]
      simp_rw [mem_support, Classical.not_not]
      

Proof state:
Γ : Type u_1
R : Type u_2
inst✝¹ : PartialOrder Γ
inst✝ : AddCommMonoid R
α : Type u_3
s : SummableFamily Γ R α
g : Γ
⊢ (∀ (x : α), coeff (s x) g = 0) → ∑ᶠ (i : α), coeff (s i) g = 0

Next tactic:
intro h
/-- The infinite sum of a `SummableFamily` of Hahn series. -/
def hsum (s : SummableFamily Γ R α) : HahnSeries Γ R where
  coeff g := ∑ᶠ i, (s i).coeff g
  isPwo_support' :=
    s.isPwo_iUnion_support.mono fun g => by
      contrapose
      rw [Set.mem_iUnion, not_exists, Function.mem_support, Classical.not_not]
      simp_rw [mem_support, Classical.not_not]
      intro h
      

Proof state:
Γ : Type u_1
R : Type u_2
inst✝¹ : PartialOrder Γ
inst✝ : AddCommMonoid R
α : Type u_3
s : SummableFamily Γ R α
g : Γ
h : ∀ (x : α), coeff (s x) g = 0
⊢ ∑ᶠ (i : α), coeff (s i) g = 0

Next tactic:
rw [finsum_congr h, finsum_zero]
theorem support_hsum_subset {s : SummableFamily Γ R α} : s.hsum.support ⊆ ⋃ a : α, (s a).support :=
  fun g hg => by
  

Proof state:
Γ : Type u_1
R : Type u_2
inst✝¹ : PartialOrder Γ
inst✝ : AddCommMonoid R
α : Type u_3
s : SummableFamily Γ R α
g : Γ
hg : g ∈ support (hsum s)
⊢ g ∈ ⋃ a, support (s a)

Next tactic:
rw [mem_support, hsum_coeff, finsum_eq_sum _ (s.finite_co_support _)] at hg
theorem support_hsum_subset {s : SummableFamily Γ R α} : s.hsum.support ⊆ ⋃ a : α, (s a).support :=
  fun g hg => by
  rw [mem_support, hsum_coeff, finsum_eq_sum _ (s.finite_co_support _)] at hg
  

Proof state:
Γ : Type u_1
R : Type u_2
inst✝¹ : PartialOrder Γ
inst✝ : AddCommMonoid R
α : Type u_3
s : SummableFamily Γ R α
g : Γ
hg : ∑ i in Set.Finite.toFinset (_ : Set.Finite (Function.support fun a => coeff (s a) g)), coeff (s i) g ≠ 0
⊢ g ∈ ⋃ a, support (s a)

Next tactic:
obtain ⟨a, _, h2⟩ := exists_ne_zero_of_sum_ne_zero hg