l3lab/ntp-mathlib huggingface dataset:
/-- A family with only finitely many nonzero elements is summable. -/
def ofFinsupp (f : α →₀ HahnSeries Γ R) : SummableFamily Γ R α where
  toFun := f
  isPwo_iUnion_support' := by
    apply (f.support.isPwo_bUnion.2 fun a _ => (f a).isPwo_support).mono
    refine' Set.iUnion_subset_iff.2 fun a g hg => _
    have haf : a ∈ f.support := by
      rw [Finsupp.mem_support_iff, ← support_nonempty_iff]
      exact ⟨g, hg⟩
    exact Set.mem_biUnion haf hg
  finite_co_support' g := by
    

Proof state:
Γ : Type u_1
R : Type u_2
inst✝¹ : PartialOrder Γ
inst✝ : AddCommMonoid R
α : Type u_3
f : α →₀ HahnSeries Γ R
g : Γ
⊢ Set.Finite {a | coeff (f a) g ≠ 0}

Next tactic:
refine' f.support.finite_toSet.subset fun a ha => _
/-- A family with only finitely many nonzero elements is summable. -/
def ofFinsupp (f : α →₀ HahnSeries Γ R) : SummableFamily Γ R α where
  toFun := f
  isPwo_iUnion_support' := by
    apply (f.support.isPwo_bUnion.2 fun a _ => (f a).isPwo_support).mono
    refine' Set.iUnion_subset_iff.2 fun a g hg => _
    have haf : a ∈ f.support := by
      rw [Finsupp.mem_support_iff, ← support_nonempty_iff]
      exact ⟨g, hg⟩
    exact Set.mem_biUnion haf hg
  finite_co_support' g := by
    refine' f.support.finite_toSet.subset fun a ha => _
    

Proof state:
Γ : Type u_1
R : Type u_2
inst✝¹ : PartialOrder Γ
inst✝ : AddCommMonoid R
α : Type u_3
f : α →₀ HahnSeries Γ R
g : Γ
a : α
ha : a ∈ {a | coeff (f a) g ≠ 0}
⊢ a ∈ ↑f.support

Next tactic:
simp only [coeff.addMonoidHom_apply, mem_coe, Finsupp.mem_support_iff, Ne.def,
      Function.mem_support]
/-- A family with only finitely many nonzero elements is summable. -/
def ofFinsupp (f : α →₀ HahnSeries Γ R) : SummableFamily Γ R α where
  toFun := f
  isPwo_iUnion_support' := by
    apply (f.support.isPwo_bUnion.2 fun a _ => (f a).isPwo_support).mono
    refine' Set.iUnion_subset_iff.2 fun a g hg => _
    have haf : a ∈ f.support := by
      rw [Finsupp.mem_support_iff, ← support_nonempty_iff]
      exact ⟨g, hg⟩
    exact Set.mem_biUnion haf hg
  finite_co_support' g := by
    refine' f.support.finite_toSet.subset fun a ha => _
    simp only [coeff.addMonoidHom_apply, mem_coe, Finsupp.mem_support_iff, Ne.def,
      Function.mem_support]
    

Proof state:
Γ : Type u_1
R : Type u_2
inst✝¹ : PartialOrder Γ
inst✝ : AddCommMonoid R
α : Type u_3
f : α →₀ HahnSeries Γ R
g : Γ
a : α
ha : a ∈ {a | coeff (f a) g ≠ 0}
⊢ ¬f a = 0

Next tactic:
contrapose! ha
/-- A family with only finitely many nonzero elements is summable. -/
def ofFinsupp (f : α →₀ HahnSeries Γ R) : SummableFamily Γ R α where
  toFun := f
  isPwo_iUnion_support' := by
    apply (f.support.isPwo_bUnion.2 fun a _ => (f a).isPwo_support).mono
    refine' Set.iUnion_subset_iff.2 fun a g hg => _
    have haf : a ∈ f.support := by
      rw [Finsupp.mem_support_iff, ← support_nonempty_iff]
      exact ⟨g, hg⟩
    exact Set.mem_biUnion haf hg
  finite_co_support' g := by
    refine' f.support.finite_toSet.subset fun a ha => _
    simp only [coeff.addMonoidHom_apply, mem_coe, Finsupp.mem_support_iff, Ne.def,
      Function.mem_support]
    contrapose! ha
    

Proof state:
Γ : Type u_1
R : Type u_2
inst✝¹ : PartialOrder Γ
inst✝ : AddCommMonoid R
α : Type u_3
f : α →₀ HahnSeries Γ R
g : Γ
a : α
ha : f a = 0
⊢ a ∉ {a | coeff (f a) g ≠ 0}

Next tactic:
simp [ha]
@[simp]
theorem hsum_ofFinsupp {f : α →₀ HahnSeries Γ R} : (ofFinsupp f).hsum = f.sum fun _ => id := by
  

Proof state:
Γ : Type u_1
R : Type u_2
inst✝¹ : PartialOrder Γ
inst✝ : AddCommMonoid R
α : Type u_3
f : α →₀ HahnSeries Γ R
⊢ hsum (ofFinsupp f) = Finsupp.sum f fun x => id

Next tactic:
ext g
@[simp]
theorem hsum_ofFinsupp {f : α →₀ HahnSeries Γ R} : (ofFinsupp f).hsum = f.sum fun _ => id := by
  ext g
  

Proof state:
case coeff.h
Γ : Type u_1
R : Type u_2
inst✝¹ : PartialOrder Γ
inst✝ : AddCommMonoid R
α : Type u_3
f : α →₀ HahnSeries Γ R
g : Γ
⊢ coeff (hsum (ofFinsupp f)) g = coeff (Finsupp.sum f fun x => id) g

Next tactic:
simp only [hsum_coeff, coe_ofFinsupp, Finsupp.sum, Ne.def]
@[simp]
theorem hsum_ofFinsupp {f : α →₀ HahnSeries Γ R} : (ofFinsupp f).hsum = f.sum fun _ => id := by
  ext g
  simp only [hsum_coeff, coe_ofFinsupp, Finsupp.sum, Ne.def]
  

Proof state:
case coeff.h
Γ : Type u_1
R : Type u_2
inst✝¹ : PartialOrder Γ
inst✝ : AddCommMonoid R
α : Type u_3
f : α →₀ HahnSeries Γ R
g : Γ
⊢ ∑ᶠ (i : α), coeff (f i) g = coeff (∑ x in f.support, id (f x)) g

Next tactic:
simp_rw [← coeff.addMonoidHom_apply, id.def]
@[simp]
theorem hsum_ofFinsupp {f : α →₀ HahnSeries Γ R} : (ofFinsupp f).hsum = f.sum fun _ => id := by
  ext g
  simp only [hsum_coeff, coe_ofFinsupp, Finsupp.sum, Ne.def]
  simp_rw [← coeff.addMonoidHom_apply, id.def]
  

Proof state:
case coeff.h
Γ : Type u_1
R : Type u_2
inst✝¹ : PartialOrder Γ
inst✝ : AddCommMonoid R
α : Type u_3
f : α →₀ HahnSeries Γ R
g : Γ
⊢ ∑ᶠ (i : α), (coeff.addMonoidHom g) (f i) = (coeff.addMonoidHom g) (∑ x in f.support, f x)

Next tactic:
rw [map_sum, finsum_eq_sum_of_support_subset]
@[simp]
theorem hsum_ofFinsupp {f : α →₀ HahnSeries Γ R} : (ofFinsupp f).hsum = f.sum fun _ => id := by
  ext g
  simp only [hsum_coeff, coe_ofFinsupp, Finsupp.sum, Ne.def]
  simp_rw [← coeff.addMonoidHom_apply, id.def]
  rw [map_sum, finsum_eq_sum_of_support_subset]
  

Proof state:
case coeff.h.h
Γ : Type u_1
R : Type u_2
inst✝¹ : PartialOrder Γ
inst✝ : AddCommMonoid R
α : Type u_3
f : α →₀ HahnSeries Γ R
g : Γ
⊢ (Function.support fun i => (coeff.addMonoidHom g) (f i)) ⊆ ↑f.support

Next tactic:
intro x h
@[simp]
theorem hsum_ofFinsupp {f : α →₀ HahnSeries Γ R} : (ofFinsupp f).hsum = f.sum fun _ => id := by
  ext g
  simp only [hsum_coeff, coe_ofFinsupp, Finsupp.sum, Ne.def]
  simp_rw [← coeff.addMonoidHom_apply, id.def]
  rw [map_sum, finsum_eq_sum_of_support_subset]
  intro x h
  

Proof state:
case coeff.h.h
Γ : Type u_1
R : Type u_2
inst✝¹ : PartialOrder Γ
inst✝ : AddCommMonoid R
α : Type u_3
f : α →₀ HahnSeries Γ R
g : Γ
x : α
h : x ∈ Function.support fun i => (coeff.addMonoidHom g) (f i)
⊢ x ∈ ↑f.support

Next tactic:
simp only [coeff.addMonoidHom_apply, mem_coe, Finsupp.mem_support_iff, Ne.def]
@[simp]
theorem hsum_ofFinsupp {f : α →₀ HahnSeries Γ R} : (ofFinsupp f).hsum = f.sum fun _ => id := by
  ext g
  simp only [hsum_coeff, coe_ofFinsupp, Finsupp.sum, Ne.def]
  simp_rw [← coeff.addMonoidHom_apply, id.def]
  rw [map_sum, finsum_eq_sum_of_support_subset]
  intro x h
  simp only [coeff.addMonoidHom_apply, mem_coe, Finsupp.mem_support_iff, Ne.def]
  

Proof state:
case coeff.h.h
Γ : Type u_1
R : Type u_2
inst✝¹ : PartialOrder Γ
inst✝ : AddCommMonoid R
α : Type u_3
f : α →₀ HahnSeries Γ R
g : Γ
x : α
h : x ∈ Function.support fun i => (coeff.addMonoidHom g) (f i)
⊢ ¬f x = 0

Next tactic:
contrapose! h
@[simp]
theorem hsum_ofFinsupp {f : α →₀ HahnSeries Γ R} : (ofFinsupp f).hsum = f.sum fun _ => id := by
  ext g
  simp only [hsum_coeff, coe_ofFinsupp, Finsupp.sum, Ne.def]
  simp_rw [← coeff.addMonoidHom_apply, id.def]
  rw [map_sum, finsum_eq_sum_of_support_subset]
  intro x h
  simp only [coeff.addMonoidHom_apply, mem_coe, Finsupp.mem_support_iff, Ne.def]
  contrapose! h
  

Proof state:
case coeff.h.h
Γ : Type u_1
R : Type u_2
inst✝¹ : PartialOrder Γ
inst✝ : AddCommMonoid R
α : Type u_3
f : α →₀ HahnSeries Γ R
g : Γ
x : α
h : f x = 0
⊢ x ∉ Function.support fun i => (coeff.addMonoidHom g) (f i)

Next tactic:
simp [h]
/-- A summable family can be reindexed by an embedding without changing its sum. -/
def embDomain (s : SummableFamily Γ R α) (f : α ↪ β) : SummableFamily Γ R β where
  toFun b := if h : b ∈ Set.range f then s (Classical.choose h) else 0
  isPwo_iUnion_support' := by
    

Proof state:
Γ : Type u_1
R : Type u_2
inst✝¹ : PartialOrder Γ
inst✝ : AddCommMonoid R
α : Type u_3
β : Type u_4
s : SummableFamily Γ R α
f : α ↪ β
⊢ Set.IsPwo (⋃ a, support ((fun b => if h : b ∈ Set.range ⇑f then s (Classical.choose h) else 0) a))

Next tactic:
refine' s.isPwo_iUnion_support.mono (Set.iUnion_subset fun b g h => _)
/-- A summable family can be reindexed by an embedding without changing its sum. -/
def embDomain (s : SummableFamily Γ R α) (f : α ↪ β) : SummableFamily Γ R β where
  toFun b := if h : b ∈ Set.range f then s (Classical.choose h) else 0
  isPwo_iUnion_support' := by
    refine' s.isPwo_iUnion_support.mono (Set.iUnion_subset fun b g h => _)
    

Proof state:
Γ : Type u_1
R : Type u_2
inst✝¹ : PartialOrder Γ
inst✝ : AddCommMonoid R
α : Type u_3
β : Type u_4
s : SummableFamily Γ R α
f : α ↪ β
b : β
g : Γ
h : g ∈ support ((fun b => if h : b ∈ Set.range ⇑f then s (Classical.choose h) else 0) b)
⊢ g ∈ ⋃ a, support (s a)

Next tactic:
by_cases hb : b ∈ Set.range f
/-- A summable family can be reindexed by an embedding without changing its sum. -/
def embDomain (s : SummableFamily Γ R α) (f : α ↪ β) : SummableFamily Γ R β where
  toFun b := if h : b ∈ Set.range f then s (Classical.choose h) else 0
  isPwo_iUnion_support' := by
    refine' s.isPwo_iUnion_support.mono (Set.iUnion_subset fun b g h => _)
    by_cases hb : b ∈ Set.range f
    · 

Proof state:
case pos
Γ : Type u_1
R : Type u_2
inst✝¹ : PartialOrder Γ
inst✝ : AddCommMonoid R
α : Type u_3
β : Type u_4
s : SummableFamily Γ R α
f : α ↪ β
b : β
g : Γ
h : g ∈ support ((fun b => if h : b ∈ Set.range ⇑f then s (Classical.choose h) else 0) b)
hb : b ∈ Set.range ⇑f
⊢ g ∈ ⋃ a, support (s a)

Next tactic:
dsimp only at h
/-- A summable family can be reindexed by an embedding without changing its sum. -/
def embDomain (s : SummableFamily Γ R α) (f : α ↪ β) : SummableFamily Γ R β where
  toFun b := if h : b ∈ Set.range f then s (Classical.choose h) else 0
  isPwo_iUnion_support' := by
    refine' s.isPwo_iUnion_support.mono (Set.iUnion_subset fun b g h => _)
    by_cases hb : b ∈ Set.range f
    · dsimp only at h
      

Proof state:
case pos
Γ : Type u_1
R : Type u_2
inst✝¹ : PartialOrder Γ
inst✝ : AddCommMonoid R
α : Type u_3
β : Type u_4
s : SummableFamily Γ R α
f : α ↪ β
b : β
g : Γ
h : g ∈ support (if h : b ∈ Set.range ⇑f then s (Classical.choose h) else 0)
hb : b ∈ Set.range ⇑f
⊢ g ∈ ⋃ a, support (s a)

Next tactic:
rw [dif_pos hb] at h
/-- A summable family can be reindexed by an embedding without changing its sum. -/
def embDomain (s : SummableFamily Γ R α) (f : α ↪ β) : SummableFamily Γ R β where
  toFun b := if h : b ∈ Set.range f then s (Classical.choose h) else 0
  isPwo_iUnion_support' := by
    refine' s.isPwo_iUnion_support.mono (Set.iUnion_subset fun b g h => _)
    by_cases hb : b ∈ Set.range f
    · dsimp only at h
      rw [dif_pos hb] at h
      

Proof state:
case pos
Γ : Type u_1
R : Type u_2
inst✝¹ : PartialOrder Γ
inst✝ : AddCommMonoid R
α : Type u_3
β : Type u_4
s : SummableFamily Γ R α
f : α ↪ β
b : β
g : Γ
hb : b ∈ Set.range ⇑f
h : g ∈ support (s (Classical.choose hb))
⊢ g ∈ ⋃ a, support (s a)

Next tactic:
exact Set.mem_iUnion.2 ⟨Classical.choose hb, h⟩
/-- A summable family can be reindexed by an embedding without changing its sum. -/
def embDomain (s : SummableFamily Γ R α) (f : α ↪ β) : SummableFamily Γ R β where
  toFun b := if h : b ∈ Set.range f then s (Classical.choose h) else 0
  isPwo_iUnion_support' := by
    refine' s.isPwo_iUnion_support.mono (Set.iUnion_subset fun b g h => _)
    by_cases hb : b ∈ Set.range f
    · dsimp only at h
      rw [dif_pos hb] at h
      exact Set.mem_iUnion.2 ⟨Classical.choose hb, h⟩
    · 

Proof state:
case neg
Γ : Type u_1
R : Type u_2
inst✝¹ : PartialOrder Γ
inst✝ : AddCommMonoid R
α : Type u_3
β : Type u_4
s : SummableFamily Γ R α
f : α ↪ β
b : β
g : Γ
h : g ∈ support ((fun b => if h : b ∈ Set.range ⇑f then s (Classical.choose h) else 0) b)
hb : b ∉ Set.range ⇑f
⊢ g ∈ ⋃ a, support (s a)

Next tactic:
contrapose! h
/-- A summable family can be reindexed by an embedding without changing its sum. -/
def embDomain (s : SummableFamily Γ R α) (f : α ↪ β) : SummableFamily Γ R β where
  toFun b := if h : b ∈ Set.range f then s (Classical.choose h) else 0
  isPwo_iUnion_support' := by
    refine' s.isPwo_iUnion_support.mono (Set.iUnion_subset fun b g h => _)
    by_cases hb : b ∈ Set.range f
    · dsimp only at h
      rw [dif_pos hb] at h
      exact Set.mem_iUnion.2 ⟨Classical.choose hb, h⟩
    · contrapose! h
      

Proof state:
case neg
Γ : Type u_1
R : Type u_2
inst✝¹ : PartialOrder Γ
inst✝ : AddCommMonoid R
α : Type u_3
β : Type u_4
s : SummableFamily Γ R α
f : α ↪ β
b : β
g : Γ
hb : b ∉ Set.range ⇑f
h : g ∉ ⋃ a, support (s a)
⊢ g ∉ support (if h : b ∈ Set.range ⇑f then s (Classical.choose h) else 0)

Next tactic:
rw [dif_neg hb]
/-- A summable family can be reindexed by an embedding without changing its sum. -/
def embDomain (s : SummableFamily Γ R α) (f : α ↪ β) : SummableFamily Γ R β where
  toFun b := if h : b ∈ Set.range f then s (Classical.choose h) else 0
  isPwo_iUnion_support' := by
    refine' s.isPwo_iUnion_support.mono (Set.iUnion_subset fun b g h => _)
    by_cases hb : b ∈ Set.range f
    · dsimp only at h
      rw [dif_pos hb] at h
      exact Set.mem_iUnion.2 ⟨Classical.choose hb, h⟩
    · contrapose! h
      rw [dif_neg hb]
      

Proof state:
case neg
Γ : Type u_1
R : Type u_2
inst✝¹ : PartialOrder Γ
inst✝ : AddCommMonoid R
α : Type u_3
β : Type u_4
s : SummableFamily Γ R α
f : α ↪ β
b : β
g : Γ
hb : b ∉ Set.range ⇑f
h : g ∉ ⋃ a, support (s a)
⊢ g ∉ support 0

Next tactic:
simp
/-- A summable family can be reindexed by an embedding without changing its sum. -/
def embDomain (s : SummableFamily Γ R α) (f : α ↪ β) : SummableFamily Γ R β where
  toFun b := if h : b ∈ Set.range f then s (Classical.choose h) else 0
  isPwo_iUnion_support' := by
    refine' s.isPwo_iUnion_support.mono (Set.iUnion_subset fun b g h => _)
    by_cases hb : b ∈ Set.range f
    · dsimp only at h
      rw [dif_pos hb] at h
      exact Set.mem_iUnion.2 ⟨Classical.choose hb, h⟩
    · contrapose! h
      rw [dif_neg hb]
      simp
  finite_co_support' g :=
    ((s.finite_co_support g).image f).subset
      (by
        

Proof state:
Γ : Type u_1
R : Type u_2
inst✝¹ : PartialOrder Γ
inst✝ : AddCommMonoid R
α : Type u_3
β : Type u_4
s : SummableFamily Γ R α
f : α ↪ β
g : Γ
⊢ {a | coeff ((fun b => if h : b ∈ Set.range ⇑f then s (Classical.choose h) else 0) a) g ≠ 0} ⊆
    ⇑f '' Function.support fun a => coeff (s a) g

Next tactic:
intro b h
/-- A summable family can be reindexed by an embedding without changing its sum. -/
def embDomain (s : SummableFamily Γ R α) (f : α ↪ β) : SummableFamily Γ R β where
  toFun b := if h : b ∈ Set.range f then s (Classical.choose h) else 0
  isPwo_iUnion_support' := by
    refine' s.isPwo_iUnion_support.mono (Set.iUnion_subset fun b g h => _)
    by_cases hb : b ∈ Set.range f
    · dsimp only at h
      rw [dif_pos hb] at h
      exact Set.mem_iUnion.2 ⟨Classical.choose hb, h⟩
    · contrapose! h
      rw [dif_neg hb]
      simp
  finite_co_support' g :=
    ((s.finite_co_support g).image f).subset
      (by
        intro b h
        

Proof state:
Γ : Type u_1
R : Type u_2
inst✝¹ : PartialOrder Γ
inst✝ : AddCommMonoid R
α : Type u_3
β : Type u_4
s : SummableFamily Γ R α
f : α ↪ β
g : Γ
b : β
h : b ∈ {a | coeff ((fun b => if h : b ∈ Set.range ⇑f then s (Classical.choose h) else 0) a) g ≠ 0}
⊢ b ∈ ⇑f '' Function.support fun a => coeff (s a) g

Next tactic:
by_cases hb : b ∈ Set.range f
/-- A summable family can be reindexed by an embedding without changing its sum. -/
def embDomain (s : SummableFamily Γ R α) (f : α ↪ β) : SummableFamily Γ R β where
  toFun b := if h : b ∈ Set.range f then s (Classical.choose h) else 0
  isPwo_iUnion_support' := by
    refine' s.isPwo_iUnion_support.mono (Set.iUnion_subset fun b g h => _)
    by_cases hb : b ∈ Set.range f
    · dsimp only at h
      rw [dif_pos hb] at h
      exact Set.mem_iUnion.2 ⟨Classical.choose hb, h⟩
    · contrapose! h
      rw [dif_neg hb]
      simp
  finite_co_support' g :=
    ((s.finite_co_support g).image f).subset
      (by
        intro b h
        by_cases hb : b ∈ Set.range f
        · 

Proof state:
case pos
Γ : Type u_1
R : Type u_2
inst✝¹ : PartialOrder Γ
inst✝ : AddCommMonoid R
α : Type u_3
β : Type u_4
s : SummableFamily Γ R α
f : α ↪ β
g : Γ
b : β
h : b ∈ {a | coeff ((fun b => if h : b ∈ Set.range ⇑f then s (Classical.choose h) else 0) a) g ≠ 0}
hb : b ∈ Set.range ⇑f
⊢ b ∈ ⇑f '' Function.support fun a => coeff (s a) g

Next tactic:
simp only [Ne.def, Set.mem_setOf_eq, dif_pos hb] at h
/-- A summable family can be reindexed by an embedding without changing its sum. -/
def embDomain (s : SummableFamily Γ R α) (f : α ↪ β) : SummableFamily Γ R β where
  toFun b := if h : b ∈ Set.range f then s (Classical.choose h) else 0
  isPwo_iUnion_support' := by
    refine' s.isPwo_iUnion_support.mono (Set.iUnion_subset fun b g h => _)
    by_cases hb : b ∈ Set.range f
    · dsimp only at h
      rw [dif_pos hb] at h
      exact Set.mem_iUnion.2 ⟨Classical.choose hb, h⟩
    · contrapose! h
      rw [dif_neg hb]
      simp
  finite_co_support' g :=
    ((s.finite_co_support g).image f).subset
      (by
        intro b h
        by_cases hb : b ∈ Set.range f
        · simp only [Ne.def, Set.mem_setOf_eq, dif_pos hb] at h
          

Proof state:
case pos
Γ : Type u_1
R : Type u_2
inst✝¹ : PartialOrder Γ
inst✝ : AddCommMonoid R
α : Type u_3
β : Type u_4
s : SummableFamily Γ R α
f : α ↪ β
g : Γ
b : β
hb : b ∈ Set.range ⇑f
h : ¬coeff (s (Classical.choose hb)) g = 0
⊢ b ∈ ⇑f '' Function.support fun a => coeff (s a) g

Next tactic:
exact ⟨Classical.choose hb, h, Classical.choose_spec hb⟩
/-- A summable family can be reindexed by an embedding without changing its sum. -/
def embDomain (s : SummableFamily Γ R α) (f : α ↪ β) : SummableFamily Γ R β where
  toFun b := if h : b ∈ Set.range f then s (Classical.choose h) else 0
  isPwo_iUnion_support' := by
    refine' s.isPwo_iUnion_support.mono (Set.iUnion_subset fun b g h => _)
    by_cases hb : b ∈ Set.range f
    · dsimp only at h
      rw [dif_pos hb] at h
      exact Set.mem_iUnion.2 ⟨Classical.choose hb, h⟩
    · contrapose! h
      rw [dif_neg hb]
      simp
  finite_co_support' g :=
    ((s.finite_co_support g).image f).subset
      (by
        intro b h
        by_cases hb : b ∈ Set.range f
        · simp only [Ne.def, Set.mem_setOf_eq, dif_pos hb] at h
          exact ⟨Classical.choose hb, h, Classical.choose_spec hb⟩
        · 

Proof state:
case neg
Γ : Type u_1
R : Type u_2
inst✝¹ : PartialOrder Γ
inst✝ : AddCommMonoid R
α : Type u_3
β : Type u_4
s : SummableFamily Γ R α
f : α ↪ β
g : Γ
b : β
h : b ∈ {a | coeff ((fun b => if h : b ∈ Set.range ⇑f then s (Classical.choose h) else 0) a) g ≠ 0}
hb : b ∉ Set.range ⇑f
⊢ b ∈ ⇑f '' Function.support fun a => coeff (s a) g

Next tactic:
contrapose! h
/-- A summable family can be reindexed by an embedding without changing its sum. -/
def embDomain (s : SummableFamily Γ R α) (f : α ↪ β) : SummableFamily Γ R β where
  toFun b := if h : b ∈ Set.range f then s (Classical.choose h) else 0
  isPwo_iUnion_support' := by
    refine' s.isPwo_iUnion_support.mono (Set.iUnion_subset fun b g h => _)
    by_cases hb : b ∈ Set.range f
    · dsimp only at h
      rw [dif_pos hb] at h
      exact Set.mem_iUnion.2 ⟨Classical.choose hb, h⟩
    · contrapose! h
      rw [dif_neg hb]
      simp
  finite_co_support' g :=
    ((s.finite_co_support g).image f).subset
      (by
        intro b h
        by_cases hb : b ∈ Set.range f
        · simp only [Ne.def, Set.mem_setOf_eq, dif_pos hb] at h
          exact ⟨Classical.choose hb, h, Classical.choose_spec hb⟩
        · contrapose! h
          

Proof state:
case neg
Γ : Type u_1
R : Type u_2
inst✝¹ : PartialOrder Γ
inst✝ : AddCommMonoid R
α : Type u_3
β : Type u_4
s : SummableFamily Γ R α
f : α ↪ β
g : Γ
b : β
hb : b ∉ Set.range ⇑f
h : b ∉ ⇑f '' Function.support fun a => coeff (s a) g
⊢ b ∉ {a | coeff (if h : a ∈ Set.range ⇑f then s (Classical.choose h) else 0) g ≠ 0}

Next tactic:
simp only [Ne.def, Set.mem_setOf_eq, dif_neg hb, Classical.not_not, zero_coeff]
@[simp]
theorem embDomain_image : s.embDomain f (f a) = s a := by
  

Proof state:
Γ : Type u_1
R : Type u_2
inst✝¹ : PartialOrder Γ
inst✝ : AddCommMonoid R
α : Type u_3
β : Type u_4
s : SummableFamily Γ R α
f : α ↪ β
a : α
b : β
⊢ (embDomain s f) (f a) = s a

Next tactic:
rw [embDomain_apply, dif_pos (Set.mem_range_self a)]
@[simp]
theorem embDomain_image : s.embDomain f (f a) = s a := by
  rw [embDomain_apply, dif_pos (Set.mem_range_self a)]
  

Proof state:
Γ : Type u_1
R : Type u_2
inst✝¹ : PartialOrder Γ
inst✝ : AddCommMonoid R
α : Type u_3
β : Type u_4
s : SummableFamily Γ R α
f : α ↪ β
a : α
b : β
⊢ s (Classical.choose (_ : f a ∈ Set.range ⇑f)) = s a

Next tactic:
exact congr rfl (f.injective (Classical.choose_spec (Set.mem_range_self a)))
@[simp]
theorem embDomain_notin_range (h : b ∉ Set.range f) : s.embDomain f b = 0 := by
  

Proof state:
Γ : Type u_1
R : Type u_2
inst✝¹ : PartialOrder Γ
inst✝ : AddCommMonoid R
α : Type u_3
β : Type u_4
s : SummableFamily Γ R α
f : α ↪ β
a : α
b : β
h : b ∉ Set.range ⇑f
⊢ (embDomain s f) b = 0

Next tactic:
rw [embDomain_apply, dif_neg h]
@[simp]
theorem hsum_embDomain : (s.embDomain f).hsum = s.hsum := by
  

Proof state:
Γ : Type u_1
R : Type u_2
inst✝¹ : PartialOrder Γ
inst✝ : AddCommMonoid R
α : Type u_3
β : Type u_4
s : SummableFamily Γ R α
f : α ↪ β
a : α
b : β
⊢ hsum (embDomain s f) = hsum s

Next tactic:
ext g
@[simp]
theorem hsum_embDomain : (s.embDomain f).hsum = s.hsum := by
  ext g
  

Proof state:
case coeff.h
Γ : Type u_1
R : Type u_2
inst✝¹ : PartialOrder Γ
inst✝ : AddCommMonoid R
α : Type u_3
β : Type u_4
s : SummableFamily Γ R α
f : α ↪ β
a : α
b : β
g : Γ
⊢ coeff (hsum (embDomain s f)) g = coeff (hsum s) g

Next tactic:
simp only [hsum_coeff, embDomain_apply, apply_dite HahnSeries.coeff, dite_apply, zero_coeff]
@[simp]
theorem hsum_embDomain : (s.embDomain f).hsum = s.hsum := by
  ext g
  simp only [hsum_coeff, embDomain_apply, apply_dite HahnSeries.coeff, dite_apply, zero_coeff]
  

Proof state:
case coeff.h
Γ : Type u_1
R : Type u_2
inst✝¹ : PartialOrder Γ
inst✝ : AddCommMonoid R
α : Type u_3
β : Type u_4
s : SummableFamily Γ R α
f : α ↪ β
a : α
b : β
g : Γ
⊢ (∑ᶠ (i : β), if h : i ∈ Set.range ⇑f then coeff (s (Classical.choose (_ : i ∈ Set.range ⇑f))) g else 0) =
    ∑ᶠ (i : α), coeff (s i) g

Next tactic:
exact finsum_emb_domain f fun a => (s a).coeff g
/-- The powers of an element of positive valuation form a summable family. -/
def powers (x : HahnSeries Γ R) (hx : 0 < addVal Γ R x) : SummableFamily Γ R ℕ where
  toFun n := x ^ n
  isPwo_iUnion_support' := isPwo_iUnion_support_powers hx
  finite_co_support' g := by
    

Proof state:
Γ : Type u_1
R : Type u_2
inst✝² : LinearOrderedCancelAddCommMonoid Γ
inst✝¹ : CommRing R
inst✝ : IsDomain R
x : HahnSeries Γ R
hx : 0 < (addVal Γ R) x
g : Γ
⊢ Set.Finite {a | coeff ((fun n => x ^ n) a) g ≠ 0}

Next tactic:
have hpwo := isPwo_iUnion_support_powers hx
/-- The powers of an element of positive valuation form a summable family. -/
def powers (x : HahnSeries Γ R) (hx : 0 < addVal Γ R x) : SummableFamily Γ R ℕ where
  toFun n := x ^ n
  isPwo_iUnion_support' := isPwo_iUnion_support_powers hx
  finite_co_support' g := by
    have hpwo := isPwo_iUnion_support_powers hx
    

Proof state:
Γ : Type u_1
R : Type u_2
inst✝² : LinearOrderedCancelAddCommMonoid Γ
inst✝¹ : CommRing R
inst✝ : IsDomain R
x : HahnSeries Γ R
hx : 0 < (addVal Γ R) x
g : Γ
hpwo : Set.IsPwo (⋃ n, support (x ^ n))
⊢ Set.Finite {a | coeff ((fun n => x ^ n) a) g ≠ 0}

Next tactic:
by_cases hg : g ∈ ⋃ n : ℕ, { g | (x ^ n).coeff g ≠ 0 }
/-- The powers of an element of positive valuation form a summable family. -/
def powers (x : HahnSeries Γ R) (hx : 0 < addVal Γ R x) : SummableFamily Γ R ℕ where
  toFun n := x ^ n
  isPwo_iUnion_support' := isPwo_iUnion_support_powers hx
  finite_co_support' g := by
    have hpwo := isPwo_iUnion_support_powers hx
    by_cases hg : g ∈ ⋃ n : ℕ, { g | (x ^ n).coeff g ≠ 0 }
    

Proof state:
case pos
Γ : Type u_1
R : Type u_2
inst✝² : LinearOrderedCancelAddCommMonoid Γ
inst✝¹ : CommRing R
inst✝ : IsDomain R
x : HahnSeries Γ R
hx : 0 < (addVal Γ R) x
g : Γ
hpwo : Set.IsPwo (⋃ n, support (x ^ n))
hg : g ∈ ⋃ n, {g | coeff (x ^ n) g ≠ 0}
⊢ Set.Finite {a | coeff ((fun n => x ^ n) a) g ≠ 0}
case neg
Γ : Type u_1
R : Type u_2
inst✝² : LinearOrderedCancelAddCommMonoid Γ
inst✝¹ : CommRing R
inst✝ : IsDomain R
x : HahnSeries Γ R
hx : 0 < (addVal Γ R) x
g : Γ
hpwo : Set.IsPwo (⋃ n, support (x ^ n))
hg : g ∉ ⋃ n, {g | coeff (x ^ n) g ≠ 0}
⊢ Set.Finite {a | coeff ((fun n => x ^ n) a) g ≠ 0}

Next tactic:
swap