l3lab/ntp-mathlib huggingface dataset:
/-- You can compute a sum over an encodably type by summing over the natural numbers and
  taking a supremum. This is useful for outer measures. -/
theorem tsum_iSup_decode₂ [CompleteLattice β] (m : β → α) (m0 : m ⊥ = 0) (s : γ → β) :
    ∑' i : ℕ, m (⨆ b ∈ decode₂ γ i, s b) = ∑' b : γ, m (s b) := by
  have H : ∀ n, m (⨆ b ∈ decode₂ γ n, s b) ≠ 0 → (decode₂ γ n).isSome := by
    intro n h
    generalize decode₂ γ n = foo at *
    cases' foo with b
    · refine' (h <| by simp [m0]).elim
    · exact rfl
  symm
  refine' tsum_eq_tsum_of_ne_zero_bij (fun a => Option.get _ (H a.1 a.2)) _ _ _
  · dsimp only []
    rintro ⟨m, hm⟩ ⟨n, hn⟩ e
    have := mem_decode₂.1 (Option.get_mem (H n hn))
    rwa [← e, mem_decode₂.1 (Option.get_mem (H m hm))] at this
  · intro b h
    refine' ⟨⟨encode b, _⟩, _⟩
    · simp only [mem_support, encodek₂] at h ⊢
      convert h
      simp [Set.ext_iff, encodek₂]
    · exact Option.get_of_mem _ (encodek₂ _)
  · rintro ⟨n, h⟩
    dsimp only [Subtype.coe_mk]
    trans
    swap
    rw [show decode₂ γ n = _ from Option.get_mem (H n h)]
    

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
inst✝⁴ : AddCommMonoid α
inst✝³ : TopologicalSpace α
f g : β → α
a a₁ a₂ : α
inst✝² : T2Space α
inst✝¹ : Encodable γ
inst✝ : CompleteLattice β
m : β → α
m0 : m ⊥ = 0
s : γ → β
H : ∀ (n : ℕ), m (⨆ b ∈ decode₂ γ n, s b) ≠ 0 → Option.isSome (decode₂ γ n) = true
n : ℕ
h : n ∈ support fun i => m (⨆ b ∈ decode₂ γ i, s b)
⊢ m (s (Option.get (decode₂ γ n) (_ : Option.isSome (decode₂ γ n) = true))) =
    m (⨆ b ∈ some (Option.get (decode₂ γ n) (_ : Option.isSome (decode₂ γ n) = true)), s b)

Next tactic:
congr
/-- You can compute a sum over an encodably type by summing over the natural numbers and
  taking a supremum. This is useful for outer measures. -/
theorem tsum_iSup_decode₂ [CompleteLattice β] (m : β → α) (m0 : m ⊥ = 0) (s : γ → β) :
    ∑' i : ℕ, m (⨆ b ∈ decode₂ γ i, s b) = ∑' b : γ, m (s b) := by
  have H : ∀ n, m (⨆ b ∈ decode₂ γ n, s b) ≠ 0 → (decode₂ γ n).isSome := by
    intro n h
    generalize decode₂ γ n = foo at *
    cases' foo with b
    · refine' (h <| by simp [m0]).elim
    · exact rfl
  symm
  refine' tsum_eq_tsum_of_ne_zero_bij (fun a => Option.get _ (H a.1 a.2)) _ _ _
  · dsimp only []
    rintro ⟨m, hm⟩ ⟨n, hn⟩ e
    have := mem_decode₂.1 (Option.get_mem (H n hn))
    rwa [← e, mem_decode₂.1 (Option.get_mem (H m hm))] at this
  · intro b h
    refine' ⟨⟨encode b, _⟩, _⟩
    · simp only [mem_support, encodek₂] at h ⊢
      convert h
      simp [Set.ext_iff, encodek₂]
    · exact Option.get_of_mem _ (encodek₂ _)
  · rintro ⟨n, h⟩
    dsimp only [Subtype.coe_mk]
    trans
    swap
    rw [show decode₂ γ n = _ from Option.get_mem (H n h)]
    congr
    

Proof state:
case e_a
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
inst✝⁴ : AddCommMonoid α
inst✝³ : TopologicalSpace α
f g : β → α
a a₁ a₂ : α
inst✝² : T2Space α
inst✝¹ : Encodable γ
inst✝ : CompleteLattice β
m : β → α
m0 : m ⊥ = 0
s : γ → β
H : ∀ (n : ℕ), m (⨆ b ∈ decode₂ γ n, s b) ≠ 0 → Option.isSome (decode₂ γ n) = true
n : ℕ
h : n ∈ support fun i => m (⨆ b ∈ decode₂ γ i, s b)
⊢ s (Option.get (decode₂ γ n) (_ : Option.isSome (decode₂ γ n) = true)) =
    ⨆ b ∈ some (Option.get (decode₂ γ n) (_ : Option.isSome (decode₂ γ n) = true)), s b

Next tactic:
simp [ext_iff, -Option.some_get]
/-- If a function is countably sub-additive then it is sub-additive on countable types -/
theorem rel_iSup_tsum [CompleteLattice β] (m : β → α) (m0 : m ⊥ = 0) (R : α → α → Prop)
    (m_iSup : ∀ s : ℕ → β, R (m (⨆ i, s i)) (∑' i, m (s i))) (s : γ → β) :
    R (m (⨆ b : γ, s b)) (∑' b : γ, m (s b)) := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
inst✝⁴ : AddCommMonoid α
inst✝³ : TopologicalSpace α
f g : β → α
a a₁ a₂ : α
inst✝² : T2Space α
inst✝¹ : Countable γ
inst✝ : CompleteLattice β
m : β → α
m0 : m ⊥ = 0
R : α → α → Prop
m_iSup : ∀ (s : ℕ → β), R (m (⨆ i, s i)) (∑' (i : ℕ), m (s i))
s : γ → β
⊢ R (m (⨆ b, s b)) (∑' (b : γ), m (s b))

Next tactic:
cases nonempty_encodable γ
/-- If a function is countably sub-additive then it is sub-additive on countable types -/
theorem rel_iSup_tsum [CompleteLattice β] (m : β → α) (m0 : m ⊥ = 0) (R : α → α → Prop)
    (m_iSup : ∀ s : ℕ → β, R (m (⨆ i, s i)) (∑' i, m (s i))) (s : γ → β) :
    R (m (⨆ b : γ, s b)) (∑' b : γ, m (s b)) := by
  cases nonempty_encodable γ
  

Proof state:
case intro
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
inst✝⁴ : AddCommMonoid α
inst✝³ : TopologicalSpace α
f g : β → α
a a₁ a₂ : α
inst✝² : T2Space α
inst✝¹ : Countable γ
inst✝ : CompleteLattice β
m : β → α
m0 : m ⊥ = 0
R : α → α → Prop
m_iSup : ∀ (s : ℕ → β), R (m (⨆ i, s i)) (∑' (i : ℕ), m (s i))
s : γ → β
val✝ : Encodable γ
⊢ R (m (⨆ b, s b)) (∑' (b : γ), m (s b))

Next tactic:
rw [← iSup_decode₂, ← tsum_iSup_decode₂ _ m0 s]
/-- If a function is countably sub-additive then it is sub-additive on countable types -/
theorem rel_iSup_tsum [CompleteLattice β] (m : β → α) (m0 : m ⊥ = 0) (R : α → α → Prop)
    (m_iSup : ∀ s : ℕ → β, R (m (⨆ i, s i)) (∑' i, m (s i))) (s : γ → β) :
    R (m (⨆ b : γ, s b)) (∑' b : γ, m (s b)) := by
  cases nonempty_encodable γ
  rw [← iSup_decode₂, ← tsum_iSup_decode₂ _ m0 s]
  

Proof state:
case intro
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
inst✝⁴ : AddCommMonoid α
inst✝³ : TopologicalSpace α
f g : β → α
a a₁ a₂ : α
inst✝² : T2Space α
inst✝¹ : Countable γ
inst✝ : CompleteLattice β
m : β → α
m0 : m ⊥ = 0
R : α → α → Prop
m_iSup : ∀ (s : ℕ → β), R (m (⨆ i, s i)) (∑' (i : ℕ), m (s i))
s : γ → β
val✝ : Encodable γ
⊢ R (m (⨆ i, ⨆ b ∈ decode₂ γ i, s b)) (∑' (i : ℕ), m (⨆ b ∈ decode₂ γ i, s b))

Next tactic:
exact m_iSup _
/-- If a function is countably sub-additive then it is sub-additive on finite sets -/
theorem rel_iSup_sum [CompleteLattice β] (m : β → α) (m0 : m ⊥ = 0) (R : α → α → Prop)
    (m_iSup : ∀ s : ℕ → β, R (m (⨆ i, s i)) (∑' i, m (s i))) (s : δ → β) (t : Finset δ) :
    R (m (⨆ d ∈ t, s d)) (∑ d in t, m (s d)) := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
inst✝⁴ : AddCommMonoid α
inst✝³ : TopologicalSpace α
f g : β → α
a a₁ a₂ : α
inst✝² : T2Space α
inst✝¹ : Countable γ
inst✝ : CompleteLattice β
m : β → α
m0 : m ⊥ = 0
R : α → α → Prop
m_iSup : ∀ (s : ℕ → β), R (m (⨆ i, s i)) (∑' (i : ℕ), m (s i))
s : δ → β
t : Finset δ
⊢ R (m (⨆ d ∈ t, s d)) (∑ d in t, m (s d))

Next tactic:
rw [iSup_subtype', ← Finset.tsum_subtype]
/-- If a function is countably sub-additive then it is sub-additive on finite sets -/
theorem rel_iSup_sum [CompleteLattice β] (m : β → α) (m0 : m ⊥ = 0) (R : α → α → Prop)
    (m_iSup : ∀ s : ℕ → β, R (m (⨆ i, s i)) (∑' i, m (s i))) (s : δ → β) (t : Finset δ) :
    R (m (⨆ d ∈ t, s d)) (∑ d in t, m (s d)) := by
  rw [iSup_subtype', ← Finset.tsum_subtype]
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
inst✝⁴ : AddCommMonoid α
inst✝³ : TopologicalSpace α
f g : β → α
a a₁ a₂ : α
inst✝² : T2Space α
inst✝¹ : Countable γ
inst✝ : CompleteLattice β
m : β → α
m0 : m ⊥ = 0
R : α → α → Prop
m_iSup : ∀ (s : ℕ → β), R (m (⨆ i, s i)) (∑' (i : ℕ), m (s i))
s : δ → β
t : Finset δ
⊢ R (m (⨆ x, s ↑x)) (∑' (x : { x // x ∈ t }), m (s ↑x))

Next tactic:
exact rel_iSup_tsum m m0 R m_iSup _
/-- If a function is countably sub-additive then it is binary sub-additive -/
theorem rel_sup_add [CompleteLattice β] (m : β → α) (m0 : m ⊥ = 0) (R : α → α → Prop)
    (m_iSup : ∀ s : ℕ → β, R (m (⨆ i, s i)) (∑' i, m (s i))) (s₁ s₂ : β) :
    R (m (s₁ ⊔ s₂)) (m s₁ + m s₂) := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
inst✝⁴ : AddCommMonoid α
inst✝³ : TopologicalSpace α
f g : β → α
a a₁ a₂ : α
inst✝² : T2Space α
inst✝¹ : Countable γ
inst✝ : CompleteLattice β
m : β → α
m0 : m ⊥ = 0
R : α → α → Prop
m_iSup : ∀ (s : ℕ → β), R (m (⨆ i, s i)) (∑' (i : ℕ), m (s i))
s₁ s₂ : β
⊢ R (m (s₁ ⊔ s₂)) (m s₁ + m s₂)

Next tactic:
convert rel_iSup_tsum m m0 R m_iSup fun b => cond b s₁ s₂
/-- If a function is countably sub-additive then it is binary sub-additive -/
theorem rel_sup_add [CompleteLattice β] (m : β → α) (m0 : m ⊥ = 0) (R : α → α → Prop)
    (m_iSup : ∀ s : ℕ → β, R (m (⨆ i, s i)) (∑' i, m (s i))) (s₁ s₂ : β) :
    R (m (s₁ ⊔ s₂)) (m s₁ + m s₂) := by
  convert rel_iSup_tsum m m0 R m_iSup fun b => cond b s₁ s₂
  · 

Proof state:
case h.e'_1.h.e'_1
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
inst✝⁴ : AddCommMonoid α
inst✝³ : TopologicalSpace α
f g : β → α
a a₁ a₂ : α
inst✝² : T2Space α
inst✝¹ : Countable γ
inst✝ : CompleteLattice β
m : β → α
m0 : m ⊥ = 0
R : α → α → Prop
m_iSup : ∀ (s : ℕ → β), R (m (⨆ i, s i)) (∑' (i : ℕ), m (s i))
s₁ s₂ : β
⊢ s₁ ⊔ s₂ = ⨆ b, bif b then s₁ else s₂

Next tactic:
simp only [iSup_bool_eq, cond]
/-- If a function is countably sub-additive then it is binary sub-additive -/
theorem rel_sup_add [CompleteLattice β] (m : β → α) (m0 : m ⊥ = 0) (R : α → α → Prop)
    (m_iSup : ∀ s : ℕ → β, R (m (⨆ i, s i)) (∑' i, m (s i))) (s₁ s₂ : β) :
    R (m (s₁ ⊔ s₂)) (m s₁ + m s₂) := by
  convert rel_iSup_tsum m m0 R m_iSup fun b => cond b s₁ s₂
  · simp only [iSup_bool_eq, cond]
  · 

Proof state:
case h.e'_2
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
inst✝⁴ : AddCommMonoid α
inst✝³ : TopologicalSpace α
f g : β → α
a a₁ a₂ : α
inst✝² : T2Space α
inst✝¹ : Countable γ
inst✝ : CompleteLattice β
m : β → α
m0 : m ⊥ = 0
R : α → α → Prop
m_iSup : ∀ (s : ℕ → β), R (m (⨆ i, s i)) (∑' (i : ℕ), m (s i))
s₁ s₂ : β
⊢ m s₁ + m s₂ = ∑' (b : Bool), m (bif b then s₁ else s₂)

Next tactic:
rw [tsum_fintype, Fintype.sum_bool, cond, cond]
theorem HasSum.neg (h : HasSum f a) : HasSum (fun b => -f b) (-a) := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
inst✝² : AddCommGroup α
inst✝¹ : TopologicalSpace α
inst✝ : TopologicalAddGroup α
f g : β → α
a a₁ a₂ : α
h : HasSum f a
⊢ HasSum (fun b => -f b) (-a)

Next tactic:
simpa only using h.map (-AddMonoidHom.id α) continuous_neg
theorem Summable.of_neg (hf : Summable fun b => -f b) : Summable f := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
inst✝² : AddCommGroup α
inst✝¹ : TopologicalSpace α
inst✝ : TopologicalAddGroup α
f g : β → α
a a₁ a₂ : α
hf : Summable fun b => -f b
⊢ Summable f

Next tactic:
simpa only [neg_neg] using hf.neg
theorem HasSum.sub (hf : HasSum f a₁) (hg : HasSum g a₂) :
    HasSum (fun b => f b - g b) (a₁ - a₂) := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
inst✝² : AddCommGroup α
inst✝¹ : TopologicalSpace α
inst✝ : TopologicalAddGroup α
f g : β → α
a a₁ a₂ : α
hf : HasSum f a₁
hg : HasSum g a₂
⊢ HasSum (fun b => f b - g b) (a₁ - a₂)

Next tactic:
simp only [sub_eq_add_neg]
theorem HasSum.sub (hf : HasSum f a₁) (hg : HasSum g a₂) :
    HasSum (fun b => f b - g b) (a₁ - a₂) := by
  simp only [sub_eq_add_neg]
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
inst✝² : AddCommGroup α
inst✝¹ : TopologicalSpace α
inst✝ : TopologicalAddGroup α
f g : β → α
a a₁ a₂ : α
hf : HasSum f a₁
hg : HasSum g a₂
⊢ HasSum (fun b => f b + -g b) (a₁ + -a₂)

Next tactic:
exact hf.add hg.neg
theorem Summable.trans_sub (hg : Summable g) (hfg : Summable fun b => f b - g b) : Summable f := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
inst✝² : AddCommGroup α
inst✝¹ : TopologicalSpace α
inst✝ : TopologicalAddGroup α
f g : β → α
a a₁ a₂ : α
hg : Summable g
hfg : Summable fun b => f b - g b
⊢ Summable f

Next tactic:
simpa only [sub_add_cancel] using hfg.add hg
theorem summable_iff_of_summable_sub (hfg : Summable fun b => f b - g b) :
    Summable f ↔ Summable g :=
  ⟨fun hf => hf.trans_sub <| by 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
inst✝² : AddCommGroup α
inst✝¹ : TopologicalSpace α
inst✝ : TopologicalAddGroup α
f g : β → α
a a₁ a₂ : α
hfg : Summable fun b => f b - g b
hf : Summable f
⊢ Summable fun b => g b - f b

Next tactic:
simpa only [neg_sub] using hfg.neg
theorem HasSum.update (hf : HasSum f a₁) (b : β) [DecidableEq β] (a : α) :
    HasSum (update f b a) (a - f b + a₁) := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
inst✝³ : AddCommGroup α
inst✝² : TopologicalSpace α
inst✝¹ : TopologicalAddGroup α
f g : β → α
a✝ a₁ a₂ : α
hf : HasSum f a₁
b : β
inst✝ : DecidableEq β
a : α
⊢ HasSum (Function.update f b a) (a - f b + a₁)

Next tactic:
convert (hasSum_ite_eq b (a - f b)).add hf
theorem HasSum.update (hf : HasSum f a₁) (b : β) [DecidableEq β] (a : α) :
    HasSum (update f b a) (a - f b + a₁) := by
  convert (hasSum_ite_eq b (a - f b)).add hf
  

Proof state:
case h.e'_5.h
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
inst✝³ : AddCommGroup α
inst✝² : TopologicalSpace α
inst✝¹ : TopologicalAddGroup α
f g : β → α
a✝ a₁ a₂ : α
hf : HasSum f a₁
b : β
inst✝ : DecidableEq β
a : α
x✝ : β
⊢ Function.update f b a x✝ = (if x✝ = b then a - f b else 0) + f x✝

Next tactic:
rename_i b'
theorem HasSum.update (hf : HasSum f a₁) (b : β) [DecidableEq β] (a : α) :
    HasSum (update f b a) (a - f b + a₁) := by
  convert (hasSum_ite_eq b (a - f b)).add hf
  rename_i b'
  

Proof state:
case h.e'_5.h
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
inst✝³ : AddCommGroup α
inst✝² : TopologicalSpace α
inst✝¹ : TopologicalAddGroup α
f g : β → α
a✝ a₁ a₂ : α
hf : HasSum f a₁
b : β
inst✝ : DecidableEq β
a : α
b' : β
⊢ Function.update f b a b' = (if b' = b then a - f b else 0) + f b'

Next tactic:
by_cases h : b' = b
theorem HasSum.update (hf : HasSum f a₁) (b : β) [DecidableEq β] (a : α) :
    HasSum (update f b a) (a - f b + a₁) := by
  convert (hasSum_ite_eq b (a - f b)).add hf
  rename_i b'
  by_cases h : b' = b
  · 

Proof state:
case pos
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
inst✝³ : AddCommGroup α
inst✝² : TopologicalSpace α
inst✝¹ : TopologicalAddGroup α
f g : β → α
a✝ a₁ a₂ : α
hf : HasSum f a₁
b : β
inst✝ : DecidableEq β
a : α
b' : β
h : b' = b
⊢ Function.update f b a b' = (if b' = b then a - f b else 0) + f b'

Next tactic:
rw [h, update_same]
theorem HasSum.update (hf : HasSum f a₁) (b : β) [DecidableEq β] (a : α) :
    HasSum (update f b a) (a - f b + a₁) := by
  convert (hasSum_ite_eq b (a - f b)).add hf
  rename_i b'
  by_cases h : b' = b
  · rw [h, update_same]
    

Proof state:
case pos
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
inst✝³ : AddCommGroup α
inst✝² : TopologicalSpace α
inst✝¹ : TopologicalAddGroup α
f g : β → α
a✝ a₁ a₂ : α
hf : HasSum f a₁
b : β
inst✝ : DecidableEq β
a : α
b' : β
h : b' = b
⊢ a = (if b = b then a - f b else 0) + f b

Next tactic:
simp [eq_self_iff_true, if_true, sub_add_cancel]
theorem HasSum.update (hf : HasSum f a₁) (b : β) [DecidableEq β] (a : α) :
    HasSum (update f b a) (a - f b + a₁) := by
  convert (hasSum_ite_eq b (a - f b)).add hf
  rename_i b'
  by_cases h : b' = b
  · rw [h, update_same]
    simp [eq_self_iff_true, if_true, sub_add_cancel]
  · 

Proof state:
case neg
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
inst✝³ : AddCommGroup α
inst✝² : TopologicalSpace α
inst✝¹ : TopologicalAddGroup α
f g : β → α
a✝ a₁ a₂ : α
hf : HasSum f a₁
b : β
inst✝ : DecidableEq β
a : α
b' : β
h : ¬b' = b
⊢ Function.update f b a b' = (if b' = b then a - f b else 0) + f b'

Next tactic:
simp only [h, update_noteq, if_false, Ne.def, zero_add, not_false_iff]
theorem HasSum.hasSum_compl_iff {s : Set β} (hf : HasSum (f ∘ (↑) : s → α) a₁) :
    HasSum (f ∘ (↑) : ↑sᶜ → α) a₂ ↔ HasSum f (a₁ + a₂) := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
inst✝² : AddCommGroup α
inst✝¹ : TopologicalSpace α
inst✝ : TopologicalAddGroup α
f g : β → α
a a₁ a₂ : α
s : Set β
hf : HasSum (f ∘ Subtype.val) a₁
⊢ HasSum (f ∘ Subtype.val) a₂ ↔ HasSum f (a₁ + a₂)

Next tactic:
refine' ⟨fun h => hf.add_compl h, fun h => _⟩
theorem HasSum.hasSum_compl_iff {s : Set β} (hf : HasSum (f ∘ (↑) : s → α) a₁) :
    HasSum (f ∘ (↑) : ↑sᶜ → α) a₂ ↔ HasSum f (a₁ + a₂) := by
  refine' ⟨fun h => hf.add_compl h, fun h => _⟩
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
inst✝² : AddCommGroup α
inst✝¹ : TopologicalSpace α
inst✝ : TopologicalAddGroup α
f g : β → α
a a₁ a₂ : α
s : Set β
hf : HasSum (f ∘ Subtype.val) a₁
h : HasSum f (a₁ + a₂)
⊢ HasSum (f ∘ Subtype.val) a₂

Next tactic:
rw [hasSum_subtype_iff_indicator] at hf ⊢
theorem HasSum.hasSum_compl_iff {s : Set β} (hf : HasSum (f ∘ (↑) : s → α) a₁) :
    HasSum (f ∘ (↑) : ↑sᶜ → α) a₂ ↔ HasSum f (a₁ + a₂) := by
  refine' ⟨fun h => hf.add_compl h, fun h => _⟩
  rw [hasSum_subtype_iff_indicator] at hf ⊢
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
inst✝² : AddCommGroup α
inst✝¹ : TopologicalSpace α
inst✝ : TopologicalAddGroup α
f g : β → α
a a₁ a₂ : α
s : Set β
hf : HasSum (Set.indicator s f) a₁
h : HasSum f (a₁ + a₂)
⊢ HasSum (Set.indicator sᶜ f) a₂

Next tactic:
rw [Set.indicator_compl]
theorem HasSum.hasSum_compl_iff {s : Set β} (hf : HasSum (f ∘ (↑) : s → α) a₁) :
    HasSum (f ∘ (↑) : ↑sᶜ → α) a₂ ↔ HasSum f (a₁ + a₂) := by
  refine' ⟨fun h => hf.add_compl h, fun h => _⟩
  rw [hasSum_subtype_iff_indicator] at hf ⊢
  rw [Set.indicator_compl]
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
inst✝² : AddCommGroup α
inst✝¹ : TopologicalSpace α
inst✝ : TopologicalAddGroup α
f g : β → α
a a₁ a₂ : α
s : Set β
hf : HasSum (Set.indicator s f) a₁
h : HasSum f (a₁ + a₂)
⊢ HasSum (f - Set.indicator s f) a₂

Next tactic:
simpa only [add_sub_cancel'] using h.sub hf
theorem HasSum.hasSum_iff_compl {s : Set β} (hf : HasSum (f ∘ (↑) : s → α) a₁) :
    HasSum f a₂ ↔ HasSum (f ∘ (↑) : ↑sᶜ → α) (a₂ - a₁) :=
  Iff.symm <| hf.hasSum_compl_iff.trans <| by 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
inst✝² : AddCommGroup α
inst✝¹ : TopologicalSpace α
inst✝ : TopologicalAddGroup α
f g : β → α
a a₁ a₂ : α
s : Set β
hf : HasSum (f ∘ Subtype.val) a₁
⊢ HasSum f (a₁ + (a₂ - a₁)) ↔ HasSum f a₂

Next tactic:
rw [add_sub_cancel'_right]
protected theorem Finset.hasSum_compl_iff (s : Finset β) :
    HasSum (fun x : { x // x ∉ s } => f x) a ↔ HasSum f (a + ∑ i in s, f i) :=
  (s.hasSum f).hasSum_compl_iff.trans <| by 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
inst✝² : AddCommGroup α
inst✝¹ : TopologicalSpace α
inst✝ : TopologicalAddGroup α
f g : β → α
a a₁ a₂ : α
s : Finset β
⊢ HasSum f (∑ b in s, f b + a) ↔ HasSum f (a + ∑ i in s, f i)

Next tactic:
rw [add_comm]
theorem hasSum_ite_sub_hasSum [DecidableEq β] (hf : HasSum f a) (b : β) :
    HasSum (fun n => ite (n = b) 0 (f n)) (a - f b) := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
inst✝³ : AddCommGroup α
inst✝² : TopologicalSpace α
inst✝¹ : TopologicalAddGroup α
f g : β → α
a a₁ a₂ : α
inst✝ : DecidableEq β
hf : HasSum f a
b : β
⊢ HasSum (fun n => if n = b then 0 else f n) (a - f b)

Next tactic:
convert hf.update b 0 using 1
theorem hasSum_ite_sub_hasSum [DecidableEq β] (hf : HasSum f a) (b : β) :
    HasSum (fun n => ite (n = b) 0 (f n)) (a - f b) := by
  convert hf.update b 0 using 1
  · 

Proof state:
case h.e'_5
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
inst✝³ : AddCommGroup α
inst✝² : TopologicalSpace α
inst✝¹ : TopologicalAddGroup α
f g : β → α
a a₁ a₂ : α
inst✝ : DecidableEq β
hf : HasSum f a
b : β
⊢ (fun n => if n = b then 0 else f n) = update f b 0

Next tactic:
ext n
theorem hasSum_ite_sub_hasSum [DecidableEq β] (hf : HasSum f a) (b : β) :
    HasSum (fun n => ite (n = b) 0 (f n)) (a - f b) := by
  convert hf.update b 0 using 1
  · ext n
    

Proof state:
case h.e'_5.h
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
inst✝³ : AddCommGroup α
inst✝² : TopologicalSpace α
inst✝¹ : TopologicalAddGroup α
f g : β → α
a a₁ a₂ : α
inst✝ : DecidableEq β
hf : HasSum f a
b n : β
⊢ (if n = b then 0 else f n) = update f b 0 n

Next tactic:
rw [Function.update_apply]
theorem hasSum_ite_sub_hasSum [DecidableEq β] (hf : HasSum f a) (b : β) :
    HasSum (fun n => ite (n = b) 0 (f n)) (a - f b) := by
  convert hf.update b 0 using 1
  · ext n
    rw [Function.update_apply]
  · 

Proof state:
case h.e'_6
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
inst✝³ : AddCommGroup α
inst✝² : TopologicalSpace α
inst✝¹ : TopologicalAddGroup α
f g : β → α
a a₁ a₂ : α
inst✝ : DecidableEq β
hf : HasSum f a
b : β
⊢ a - f b = 0 - f b + a

Next tactic:
rw [sub_add_eq_add_sub, zero_add]
theorem tsum_neg : ∑' b, -f b = -∑' b, f b := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
inst✝³ : AddCommGroup α
inst✝² : TopologicalSpace α
inst✝¹ : TopologicalAddGroup α
f g : β → α
a a₁ a₂ : α
inst✝ : T2Space α
⊢ ∑' (b : β), -f b = -∑' (b : β), f b

Next tactic:
by_cases hf : Summable f
theorem tsum_neg : ∑' b, -f b = -∑' b, f b := by
  by_cases hf : Summable f
  · 

Proof state:
case pos
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
inst✝³ : AddCommGroup α
inst✝² : TopologicalSpace α
inst✝¹ : TopologicalAddGroup α
f g : β → α
a a₁ a₂ : α
inst✝ : T2Space α
hf : Summable f
⊢ ∑' (b : β), -f b = -∑' (b : β), f b

Next tactic:
exact hf.hasSum.neg.tsum_eq
theorem tsum_neg : ∑' b, -f b = -∑' b, f b := by
  by_cases hf : Summable f
  · exact hf.hasSum.neg.tsum_eq
  · 

Proof state:
case neg
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
inst✝³ : AddCommGroup α
inst✝² : TopologicalSpace α
inst✝¹ : TopologicalAddGroup α
f g : β → α
a a₁ a₂ : α
inst✝ : T2Space α
hf : ¬Summable f
⊢ ∑' (b : β), -f b = -∑' (b : β), f b

Next tactic:
simp [tsum_eq_zero_of_not_summable hf, tsum_eq_zero_of_not_summable (mt Summable.of_neg hf)]
/-- Let `f : β → α` be a sequence with summable series and let `b ∈ β` be an index.
Lemma `tsum_eq_add_tsum_ite` writes `Σ f n` as the sum of `f b` plus the series of the
remaining terms. -/
theorem tsum_eq_add_tsum_ite [DecidableEq β] (hf : Summable f) (b : β) :
    ∑' n, f n = f b + ∑' n, ite (n = b) 0 (f n) := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
inst✝⁴ : AddCommGroup α
inst✝³ : TopologicalSpace α
inst✝² : TopologicalAddGroup α
f g : β → α
a a₁ a₂ : α
inst✝¹ : T2Space α
inst✝ : DecidableEq β
hf : Summable f
b : β
⊢ ∑' (n : β), f n = f b + ∑' (n : β), if n = b then 0 else f n

Next tactic:
rw [(hasSum_ite_sub_hasSum hf.hasSum b).tsum_eq]
/-- Let `f : β → α` be a sequence with summable series and let `b ∈ β` be an index.
Lemma `tsum_eq_add_tsum_ite` writes `Σ f n` as the sum of `f b` plus the series of the
remaining terms. -/
theorem tsum_eq_add_tsum_ite [DecidableEq β] (hf : Summable f) (b : β) :
    ∑' n, f n = f b + ∑' n, ite (n = b) 0 (f n) := by
  rw [(hasSum_ite_sub_hasSum hf.hasSum b).tsum_eq]
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
inst✝⁴ : AddCommGroup α
inst✝³ : TopologicalSpace α
inst✝² : TopologicalAddGroup α
f g : β → α
a a₁ a₂ : α
inst✝¹ : T2Space α
inst✝ : DecidableEq β
hf : Summable f
b : β
⊢ ∑' (n : β), f n = f b + (∑' (b : β), f b - f b)

Next tactic:
exact (add_sub_cancel'_right _ _).symm
theorem hasSum_nat_add_iff {f : ℕ → α} (k : ℕ) {a : α} :
    HasSum (fun n => f (n + k)) a ↔ HasSum f (a + ∑ i in range k, f i) := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
inst✝² : AddCommGroup α
inst✝¹ : TopologicalSpace α
inst✝ : TopologicalAddGroup α
f✝ g : β → α
a✝ a₁ a₂ : α
f : ℕ → α
k : ℕ
a : α
⊢ HasSum (fun n => f (n + k)) a ↔ HasSum f (a + ∑ i in range k, f i)

Next tactic:
refine' Iff.trans _ (range k).hasSum_compl_iff
theorem hasSum_nat_add_iff {f : ℕ → α} (k : ℕ) {a : α} :
    HasSum (fun n => f (n + k)) a ↔ HasSum f (a + ∑ i in range k, f i) := by
  refine' Iff.trans _ (range k).hasSum_compl_iff
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
inst✝² : AddCommGroup α
inst✝¹ : TopologicalSpace α
inst✝ : TopologicalAddGroup α
f✝ g : β → α
a✝ a₁ a₂ : α
f : ℕ → α
k : ℕ
a : α
⊢ HasSum (fun n => f (n + k)) a ↔ HasSum (fun x => f ↑x) a

Next tactic:
rw [← (notMemRangeEquiv k).symm.hasSum_iff]
theorem hasSum_nat_add_iff {f : ℕ → α} (k : ℕ) {a : α} :
    HasSum (fun n => f (n + k)) a ↔ HasSum f (a + ∑ i in range k, f i) := by
  refine' Iff.trans _ (range k).hasSum_compl_iff
  rw [← (notMemRangeEquiv k).symm.hasSum_iff]
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : Type u_4
inst✝² : AddCommGroup α
inst✝¹ : TopologicalSpace α
inst✝ : TopologicalAddGroup α
f✝ g : β → α
a✝ a₁ a₂ : α
f : ℕ → α
k : ℕ
a : α
⊢ HasSum (fun n => f (n + k)) a ↔ HasSum ((fun x => f ↑x) ∘ ⇑(notMemRangeEquiv k).symm) a

Next tactic:
rfl