l3lab/ntp-mathlib huggingface dataset:
/-- The sum over the complement of a finset tends to `0` when the finset grows to cover the whole
space. This does not need a summability assumption, as otherwise all sums are zero. -/
theorem tendsto_tsum_compl_atTop_zero {α : Type*} {f : α → ℝ≥0∞} (hf : ∑' x, f x ≠ ∞) :
    Tendsto (fun s : Finset α => ∑' b : { x // x ∉ s }, f b) atTop (𝓝 0) := by
  lift f to α → ℝ≥0 using ENNReal.ne_top_of_tsum_ne_top hf
  convert ENNReal.tendsto_coe.2 (NNReal.tendsto_tsum_compl_atTop_zero f)
  rw [ENNReal.coe_tsum]
  

Proof state:
case h.e'_3.h
α✝ : Type u_1
β : Type u_2
γ : Type u_3
a b c d : ℝ≥0∞
r p q : ℝ≥0
x y z ε ε₁ ε₂ : ℝ≥0∞
s : Set ℝ≥0∞
f✝ g : α✝ → ℝ≥0∞
α : Type u_4
f : α → ℝ≥0
hf : ∑' (x : α), (fun i => ↑(f i)) x ≠ ⊤
x✝ : Finset α
⊢ Summable fun b => f ↑b

Next tactic:
exact NNReal.summable_comp_injective (tsum_coe_ne_top_iff_summable.1 hf) Subtype.coe_injective
theorem tsum_sub {f : ℕ → ℝ≥0∞} {g : ℕ → ℝ≥0∞} (h₁ : ∑' i, g i ≠ ∞) (h₂ : g ≤ f) :
    ∑' i, (f i - g i) = ∑' i, f i - ∑' i, g i :=
  have : ∀ i, f i - g i + g i = f i := fun i => tsub_add_cancel_of_le (h₂ i)
  ENNReal.eq_sub_of_add_eq h₁ <| by 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
a b c d : ℝ≥0∞
r p q : ℝ≥0
x y z ε ε₁ ε₂ : ℝ≥0∞
s : Set ℝ≥0∞
f✝ g✝ : α → ℝ≥0∞
f g : ℕ → ℝ≥0∞
h₁ : ∑' (i : ℕ), g i ≠ ⊤
h₂ : g ≤ f
this : ∀ (i : ℕ), f i - g i + g i = f i
⊢ ∑' (i : ℕ), (f i - g i) + ∑' (i : ℕ), g i = ∑' (i : ℕ), f i

Next tactic:
simp only [← ENNReal.tsum_add, this]
theorem tsum_le_tsum_comp_of_surjective {f : α → β} (hf : Surjective f) (g : β → ℝ≥0∞) :
    ∑' y, g y ≤ ∑' x, g (f x) :=
  calc ∑' y, g y = ∑' y, g (f (surjInv hf y)) := by 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
a b c d : ℝ≥0∞
r p q : ℝ≥0
x y z ε ε₁ ε₂ : ℝ≥0∞
s : Set ℝ≥0∞
f✝ g✝ : α → ℝ≥0∞
f : α → β
hf : Surjective f
g : β → ℝ≥0∞
⊢ ∑' (y : β), g y = ∑' (y : β), g (f (surjInv hf y))

Next tactic:
simp only [surjInv_eq hf]
theorem tsum_biUnion_le_tsum {ι : Type*} (f : α → ℝ≥0∞) (s : Set ι) (t : ι → Set α) :
    ∑' x : ⋃ i ∈ s , t i, f x ≤ ∑' i : s, ∑' x : t i, f x :=
  calc ∑' x : ⋃ i ∈ s, t i, f x = ∑' x : ⋃ i : s, t i, f x := tsum_congr_set_coe _ <| by 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
a b c d : ℝ≥0∞
r p q : ℝ≥0
x y z ε ε₁ ε₂ : ℝ≥0∞
s✝ : Set ℝ≥0∞
f✝ g : α → ℝ≥0∞
ι : Type u_4
f : α → ℝ≥0∞
s : Set ι
t : ι → Set α
⊢ ⋃ i ∈ s, t i = ⋃ i, t ↑i

Next tactic:
simp
theorem tsum_iUnion_le {ι : Type*} [Fintype ι] (f : α → ℝ≥0∞) (t : ι → Set α) :
    ∑' x : ⋃ i, t i, f x ≤ ∑ i, ∑' x : t i, f x := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
a b c d : ℝ≥0∞
r p q : ℝ≥0
x y z ε ε₁ ε₂ : ℝ≥0∞
s : Set ℝ≥0∞
f✝ g : α → ℝ≥0∞
ι : Type u_4
inst✝ : Fintype ι
f : α → ℝ≥0∞
t : ι → Set α
⊢ ∑' (x : ↑(⋃ i, t i)), f ↑x ≤ ∑ i : ι, ∑' (x : ↑(t i)), f ↑x

Next tactic:
rw [← tsum_fintype]
theorem tsum_iUnion_le {ι : Type*} [Fintype ι] (f : α → ℝ≥0∞) (t : ι → Set α) :
    ∑' x : ⋃ i, t i, f x ≤ ∑ i, ∑' x : t i, f x := by
  rw [← tsum_fintype]
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
a b c d : ℝ≥0∞
r p q : ℝ≥0
x y z ε ε₁ ε₂ : ℝ≥0∞
s : Set ℝ≥0∞
f✝ g : α → ℝ≥0∞
ι : Type u_4
inst✝ : Fintype ι
f : α → ℝ≥0∞
t : ι → Set α
⊢ ∑' (x : ↑(⋃ i, t i)), f ↑x ≤ ∑' (b : ι) (x : ↑(t b)), f ↑x

Next tactic:
exact tsum_iUnion_le_tsum f t
theorem tsum_union_le (f : α → ℝ≥0∞) (s t : Set α) :
    ∑' x : ↑(s ∪ t), f x ≤ ∑' x : s, f x + ∑' x : t, f x :=
  calc ∑' x : ↑(s ∪ t), f x = ∑' x : ⋃ b, cond b s t, f x := tsum_congr_set_coe _ union_eq_iUnion
  _ ≤ _ := by 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
a b c d : ℝ≥0∞
r p q : ℝ≥0
x y z ε ε₁ ε₂ : ℝ≥0∞
s✝ : Set ℝ≥0∞
f✝ g f : α → ℝ≥0∞
s t : Set α
⊢ ∑' (x : ↑(⋃ b, bif b then s else t)), f ↑x ≤ ∑' (x : ↑s), f ↑x + ∑' (x : ↑t), f ↑x

Next tactic:
simpa using tsum_iUnion_le f (cond · s t)
theorem tsum_add_one_eq_top {f : ℕ → ℝ≥0∞} (hf : ∑' n, f n = ∞) (hf0 : f 0 ≠ ∞) :
    ∑' n, f (n + 1) = ∞ := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
a b c d : ℝ≥0∞
r p q : ℝ≥0
x y z ε ε₁ ε₂ : ℝ≥0∞
s : Set ℝ≥0∞
f✝ g : α → ℝ≥0∞
f : ℕ → ℝ≥0∞
hf : ∑' (n : ℕ), f n = ⊤
hf0 : f 0 ≠ ⊤
⊢ ∑' (n : ℕ), f (n + 1) = ⊤

Next tactic:
rw [tsum_eq_zero_add' ENNReal.summable, add_eq_top] at hf
theorem tsum_add_one_eq_top {f : ℕ → ℝ≥0∞} (hf : ∑' n, f n = ∞) (hf0 : f 0 ≠ ∞) :
    ∑' n, f (n + 1) = ∞ := by
  rw [tsum_eq_zero_add' ENNReal.summable, add_eq_top] at hf
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
a b c d : ℝ≥0∞
r p q : ℝ≥0
x y z ε ε₁ ε₂ : ℝ≥0∞
s : Set ℝ≥0∞
f✝ g : α → ℝ≥0∞
f : ℕ → ℝ≥0∞
hf : f 0 = ⊤ ∨ ∑' (b : ℕ), f (b + 1) = ⊤
hf0 : f 0 ≠ ⊤
⊢ ∑' (n : ℕ), f (n + 1) = ⊤

Next tactic:
exact hf.resolve_left hf0
/-- A sum of extended nonnegative reals which is finite can have only finitely many terms
above any positive threshold.-/
theorem finite_const_le_of_tsum_ne_top {ι : Type*} {a : ι → ℝ≥0∞} (tsum_ne_top : ∑' i, a i ≠ ∞)
    {ε : ℝ≥0∞} (ε_ne_zero : ε ≠ 0) : { i : ι | ε ≤ a i }.Finite := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
a✝ b c d : ℝ≥0∞
r p q : ℝ≥0
x y z ε✝ ε₁ ε₂ : ℝ≥0∞
s : Set ℝ≥0∞
f g : α → ℝ≥0∞
ι : Type u_4
a : ι → ℝ≥0∞
tsum_ne_top : ∑' (i : ι), a i ≠ ⊤
ε : ℝ≥0∞
ε_ne_zero : ε ≠ 0
⊢ Set.Finite {i | ε ≤ a i}

Next tactic:
by_contra h
/-- A sum of extended nonnegative reals which is finite can have only finitely many terms
above any positive threshold.-/
theorem finite_const_le_of_tsum_ne_top {ι : Type*} {a : ι → ℝ≥0∞} (tsum_ne_top : ∑' i, a i ≠ ∞)
    {ε : ℝ≥0∞} (ε_ne_zero : ε ≠ 0) : { i : ι | ε ≤ a i }.Finite := by
  by_contra h
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
a✝ b c d : ℝ≥0∞
r p q : ℝ≥0
x y z ε✝ ε₁ ε₂ : ℝ≥0∞
s : Set ℝ≥0∞
f g : α → ℝ≥0∞
ι : Type u_4
a : ι → ℝ≥0∞
tsum_ne_top : ∑' (i : ι), a i ≠ ⊤
ε : ℝ≥0∞
ε_ne_zero : ε ≠ 0
h : ¬Set.Finite {i | ε ≤ a i}
⊢ False

Next tactic:
have := Infinite.to_subtype h
/-- A sum of extended nonnegative reals which is finite can have only finitely many terms
above any positive threshold.-/
theorem finite_const_le_of_tsum_ne_top {ι : Type*} {a : ι → ℝ≥0∞} (tsum_ne_top : ∑' i, a i ≠ ∞)
    {ε : ℝ≥0∞} (ε_ne_zero : ε ≠ 0) : { i : ι | ε ≤ a i }.Finite := by
  by_contra h
  have := Infinite.to_subtype h
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
a✝ b c d : ℝ≥0∞
r p q : ℝ≥0
x y z ε✝ ε₁ ε₂ : ℝ≥0∞
s : Set ℝ≥0∞
f g : α → ℝ≥0∞
ι : Type u_4
a : ι → ℝ≥0∞
tsum_ne_top : ∑' (i : ι), a i ≠ ⊤
ε : ℝ≥0∞
ε_ne_zero : ε ≠ 0
h : ¬Set.Finite {i | ε ≤ a i}
this : Infinite ↑{i | ε ≤ a i}
⊢ False

Next tactic:
refine tsum_ne_top (top_unique ?_)
/-- A sum of extended nonnegative reals which is finite can have only finitely many terms
above any positive threshold.-/
theorem finite_const_le_of_tsum_ne_top {ι : Type*} {a : ι → ℝ≥0∞} (tsum_ne_top : ∑' i, a i ≠ ∞)
    {ε : ℝ≥0∞} (ε_ne_zero : ε ≠ 0) : { i : ι | ε ≤ a i }.Finite := by
  by_contra h
  have := Infinite.to_subtype h
  refine tsum_ne_top (top_unique ?_)
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
a✝ b c d : ℝ≥0∞
r p q : ℝ≥0
x y z ε✝ ε₁ ε₂ : ℝ≥0∞
s : Set ℝ≥0∞
f g : α → ℝ≥0∞
ι : Type u_4
a : ι → ℝ≥0∞
tsum_ne_top : ∑' (i : ι), a i ≠ ⊤
ε : ℝ≥0∞
ε_ne_zero : ε ≠ 0
h : ¬Set.Finite {i | ε ≤ a i}
this : Infinite ↑{i | ε ≤ a i}
⊢ ⊤ ≤ ∑' (i : ι), a i

Next tactic:
calc ⊤ = ∑' _ : { i | ε ≤ a i }, ε := (tsum_const_eq_top_of_ne_zero ε_ne_zero).symm
  _ ≤ ∑' i, a i := tsum_le_tsum_of_inj (↑) Subtype.val_injective (fun _ _ => zero_le _)
    (fun i => i.2) ENNReal.summable ENNReal.summable
/-- Markov's inequality for `Finset.card` and `tsum` in `ℝ≥0∞`. -/
theorem finset_card_const_le_le_of_tsum_le {ι : Type*} {a : ι → ℝ≥0∞} {c : ℝ≥0∞} (c_ne_top : c ≠ ∞)
    (tsum_le_c : ∑' i, a i ≤ c) {ε : ℝ≥0∞} (ε_ne_zero : ε ≠ 0) :
    ∃ hf : { i : ι | ε ≤ a i }.Finite, ↑hf.toFinset.card ≤ c / ε := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
a✝ b c✝ d : ℝ≥0∞
r p q : ℝ≥0
x y z ε✝ ε₁ ε₂ : ℝ≥0∞
s : Set ℝ≥0∞
f g : α → ℝ≥0∞
ι : Type u_4
a : ι → ℝ≥0∞
c : ℝ≥0∞
c_ne_top : c ≠ ⊤
tsum_le_c : ∑' (i : ι), a i ≤ c
ε : ℝ≥0∞
ε_ne_zero : ε ≠ 0
⊢ ∃ (hf : Set.Finite {i | ε ≤ a i}), ↑(Finset.card (Finite.toFinset hf)) ≤ c / ε

Next tactic:
have hf : { i : ι | ε ≤ a i }.Finite :=
    finite_const_le_of_tsum_ne_top (ne_top_of_le_ne_top c_ne_top tsum_le_c) ε_ne_zero
/-- Markov's inequality for `Finset.card` and `tsum` in `ℝ≥0∞`. -/
theorem finset_card_const_le_le_of_tsum_le {ι : Type*} {a : ι → ℝ≥0∞} {c : ℝ≥0∞} (c_ne_top : c ≠ ∞)
    (tsum_le_c : ∑' i, a i ≤ c) {ε : ℝ≥0∞} (ε_ne_zero : ε ≠ 0) :
    ∃ hf : { i : ι | ε ≤ a i }.Finite, ↑hf.toFinset.card ≤ c / ε := by
  have hf : { i : ι | ε ≤ a i }.Finite :=
    finite_const_le_of_tsum_ne_top (ne_top_of_le_ne_top c_ne_top tsum_le_c) ε_ne_zero
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
a✝ b c✝ d : ℝ≥0∞
r p q : ℝ≥0
x y z ε✝ ε₁ ε₂ : ℝ≥0∞
s : Set ℝ≥0∞
f g : α → ℝ≥0∞
ι : Type u_4
a : ι → ℝ≥0∞
c : ℝ≥0∞
c_ne_top : c ≠ ⊤
tsum_le_c : ∑' (i : ι), a i ≤ c
ε : ℝ≥0∞
ε_ne_zero : ε ≠ 0
hf : Set.Finite {i | ε ≤ a i}
⊢ ∃ (hf : Set.Finite {i | ε ≤ a i}), ↑(Finset.card (Finite.toFinset hf)) ≤ c / ε

Next tactic:
refine ⟨hf, (ENNReal.le_div_iff_mul_le (.inl ε_ne_zero) (.inr c_ne_top)).2 ?_⟩
/-- Markov's inequality for `Finset.card` and `tsum` in `ℝ≥0∞`. -/
theorem finset_card_const_le_le_of_tsum_le {ι : Type*} {a : ι → ℝ≥0∞} {c : ℝ≥0∞} (c_ne_top : c ≠ ∞)
    (tsum_le_c : ∑' i, a i ≤ c) {ε : ℝ≥0∞} (ε_ne_zero : ε ≠ 0) :
    ∃ hf : { i : ι | ε ≤ a i }.Finite, ↑hf.toFinset.card ≤ c / ε := by
  have hf : { i : ι | ε ≤ a i }.Finite :=
    finite_const_le_of_tsum_ne_top (ne_top_of_le_ne_top c_ne_top tsum_le_c) ε_ne_zero
  refine ⟨hf, (ENNReal.le_div_iff_mul_le (.inl ε_ne_zero) (.inr c_ne_top)).2 ?_⟩
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
a✝ b c✝ d : ℝ≥0∞
r p q : ℝ≥0
x y z ε✝ ε₁ ε₂ : ℝ≥0∞
s : Set ℝ≥0∞
f g : α → ℝ≥0∞
ι : Type u_4
a : ι → ℝ≥0∞
c : ℝ≥0∞
c_ne_top : c ≠ ⊤
tsum_le_c : ∑' (i : ι), a i ≤ c
ε : ℝ≥0∞
ε_ne_zero : ε ≠ 0
hf : Set.Finite {i | ε ≤ a i}
⊢ ↑(Finset.card (Finite.toFinset hf)) * ε ≤ c

Next tactic:
calc ↑hf.toFinset.card * ε = ∑ _i in hf.toFinset, ε := by rw [Finset.sum_const, nsmul_eq_mul]
    _ ≤ ∑ i in hf.toFinset, a i := Finset.sum_le_sum fun i => hf.mem_toFinset.1
    _ ≤ ∑' i, a i := ENNReal.sum_le_tsum _
    _ ≤ c := tsum_le_c
/-- Markov's inequality for `Finset.card` and `tsum` in `ℝ≥0∞`. -/
theorem finset_card_const_le_le_of_tsum_le {ι : Type*} {a : ι → ℝ≥0∞} {c : ℝ≥0∞} (c_ne_top : c ≠ ∞)
    (tsum_le_c : ∑' i, a i ≤ c) {ε : ℝ≥0∞} (ε_ne_zero : ε ≠ 0) :
    ∃ hf : { i : ι | ε ≤ a i }.Finite, ↑hf.toFinset.card ≤ c / ε := by
  have hf : { i : ι | ε ≤ a i }.Finite :=
    finite_const_le_of_tsum_ne_top (ne_top_of_le_ne_top c_ne_top tsum_le_c) ε_ne_zero
  refine ⟨hf, (ENNReal.le_div_iff_mul_le (.inl ε_ne_zero) (.inr c_ne_top)).2 ?_⟩
  calc ↑hf.toFinset.card * ε = ∑ _i in hf.toFinset, ε := by 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
a✝ b c✝ d : ℝ≥0∞
r p q : ℝ≥0
x y z ε✝ ε₁ ε₂ : ℝ≥0∞
s : Set ℝ≥0∞
f g : α → ℝ≥0∞
ι : Type u_4
a : ι → ℝ≥0∞
c : ℝ≥0∞
c_ne_top : c ≠ ⊤
tsum_le_c : ∑' (i : ι), a i ≤ c
ε : ℝ≥0∞
ε_ne_zero : ε ≠ 0
hf : Set.Finite {i | ε ≤ a i}
⊢ ↑(Finset.card (Finite.toFinset hf)) * ε = ∑ _i in Finite.toFinset hf, ε

Next tactic:
rw [Finset.sum_const, nsmul_eq_mul]
theorem tendsto_toReal_iff {ι} {fi : Filter ι} {f : ι → ℝ≥0∞} (hf : ∀ i, f i ≠ ∞) {x : ℝ≥0∞}
    (hx : x ≠ ∞) : Tendsto (fun n => (f n).toReal) fi (𝓝 x.toReal) ↔ Tendsto f fi (𝓝 x) := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
a b c d : ℝ≥0∞
r p q : ℝ≥0
x✝ y z ε ε₁ ε₂ : ℝ≥0∞
s : Set ℝ≥0∞
ι : Type u_4
fi : Filter ι
f : ι → ℝ≥0∞
hf : ∀ (i : ι), f i ≠ ⊤
x : ℝ≥0∞
hx : x ≠ ⊤
⊢ Tendsto (fun n => ENNReal.toReal (f n)) fi (𝓝 (ENNReal.toReal x)) ↔ Tendsto f fi (𝓝 x)

Next tactic:
lift f to ι → ℝ≥0 using hf
theorem tendsto_toReal_iff {ι} {fi : Filter ι} {f : ι → ℝ≥0∞} (hf : ∀ i, f i ≠ ∞) {x : ℝ≥0∞}
    (hx : x ≠ ∞) : Tendsto (fun n => (f n).toReal) fi (𝓝 x.toReal) ↔ Tendsto f fi (𝓝 x) := by
  lift f to ι → ℝ≥0 using hf
  

Proof state:
case intro
α : Type u_1
β : Type u_2
γ : Type u_3
a b c d : ℝ≥0∞
r p q : ℝ≥0
x✝ y z ε ε₁ ε₂ : ℝ≥0∞
s : Set ℝ≥0∞
ι : Type u_4
fi : Filter ι
x : ℝ≥0∞
hx : x ≠ ⊤
f : ι → ℝ≥0
⊢ Tendsto (fun n => ENNReal.toReal ((fun i => ↑(f i)) n)) fi (𝓝 (ENNReal.toReal x)) ↔ Tendsto (fun i => ↑(f i)) fi (𝓝 x)

Next tactic:
lift x to ℝ≥0 using hx
theorem tendsto_toReal_iff {ι} {fi : Filter ι} {f : ι → ℝ≥0∞} (hf : ∀ i, f i ≠ ∞) {x : ℝ≥0∞}
    (hx : x ≠ ∞) : Tendsto (fun n => (f n).toReal) fi (𝓝 x.toReal) ↔ Tendsto f fi (𝓝 x) := by
  lift f to ι → ℝ≥0 using hf
  lift x to ℝ≥0 using hx
  

Proof state:
case intro.intro
α : Type u_1
β : Type u_2
γ : Type u_3
a b c d : ℝ≥0∞
r p q : ℝ≥0
x✝ y z ε ε₁ ε₂ : ℝ≥0∞
s : Set ℝ≥0∞
ι : Type u_4
fi : Filter ι
f : ι → ℝ≥0
x : ℝ≥0
⊢ Tendsto (fun n => ENNReal.toReal ((fun i => ↑(f i)) n)) fi (𝓝 (ENNReal.toReal ↑x)) ↔
    Tendsto (fun i => ↑(f i)) fi (𝓝 ↑x)

Next tactic:
simp [tendsto_coe]
theorem tsum_coe_ne_top_iff_summable_coe {f : α → ℝ≥0} :
    (∑' a, (f a : ℝ≥0∞)) ≠ ∞ ↔ Summable fun a => (f a : ℝ) := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
a b c d : ℝ≥0∞
r p q : ℝ≥0
x y z ε ε₁ ε₂ : ℝ≥0∞
s : Set ℝ≥0∞
f : α → ℝ≥0
⊢ ∑' (a : α), ↑(f a) ≠ ⊤ ↔ Summable fun a => ↑(f a)

Next tactic:
rw [NNReal.summable_coe]
theorem tsum_coe_ne_top_iff_summable_coe {f : α → ℝ≥0} :
    (∑' a, (f a : ℝ≥0∞)) ≠ ∞ ↔ Summable fun a => (f a : ℝ) := by
  rw [NNReal.summable_coe]
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
a b c d : ℝ≥0∞
r p q : ℝ≥0
x y z ε ε₁ ε₂ : ℝ≥0∞
s : Set ℝ≥0∞
f : α → ℝ≥0
⊢ ∑' (a : α), ↑(f a) ≠ ⊤ ↔ Summable fun a => f a

Next tactic:
exact tsum_coe_ne_top_iff_summable
theorem hasSum_toReal {f : α → ℝ≥0∞} (hsum : ∑' x, f x ≠ ∞) :
    HasSum (fun x => (f x).toReal) (∑' x, (f x).toReal) := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
a b c d : ℝ≥0∞
r p q : ℝ≥0
x y z ε ε₁ ε₂ : ℝ≥0∞
s : Set ℝ≥0∞
f : α → ℝ≥0∞
hsum : ∑' (x : α), f x ≠ ⊤
⊢ HasSum (fun x => ENNReal.toReal (f x)) (∑' (x : α), ENNReal.toReal (f x))

Next tactic:
lift f to α → ℝ≥0 using ENNReal.ne_top_of_tsum_ne_top hsum
theorem hasSum_toReal {f : α → ℝ≥0∞} (hsum : ∑' x, f x ≠ ∞) :
    HasSum (fun x => (f x).toReal) (∑' x, (f x).toReal) := by
  lift f to α → ℝ≥0 using ENNReal.ne_top_of_tsum_ne_top hsum
  

Proof state:
case intro
α : Type u_1
β : Type u_2
γ : Type u_3
a b c d : ℝ≥0∞
r p q : ℝ≥0
x y z ε ε₁ ε₂ : ℝ≥0∞
s : Set ℝ≥0∞
f : α → ℝ≥0
hsum : ∑' (x : α), (fun i => ↑(f i)) x ≠ ⊤
⊢ HasSum (fun x => ENNReal.toReal ((fun i => ↑(f i)) x)) (∑' (x : α), ENNReal.toReal ((fun i => ↑(f i)) x))

Next tactic:
simp only [coe_toReal, ← NNReal.coe_tsum, NNReal.hasSum_coe]
theorem hasSum_toReal {f : α → ℝ≥0∞} (hsum : ∑' x, f x ≠ ∞) :
    HasSum (fun x => (f x).toReal) (∑' x, (f x).toReal) := by
  lift f to α → ℝ≥0 using ENNReal.ne_top_of_tsum_ne_top hsum
  simp only [coe_toReal, ← NNReal.coe_tsum, NNReal.hasSum_coe]
  

Proof state:
case intro
α : Type u_1
β : Type u_2
γ : Type u_3
a b c d : ℝ≥0∞
r p q : ℝ≥0
x y z ε ε₁ ε₂ : ℝ≥0∞
s : Set ℝ≥0∞
f : α → ℝ≥0
hsum : ∑' (x : α), (fun i => ↑(f i)) x ≠ ⊤
⊢ HasSum (fun a => f a) (∑' (a : α), f a)

Next tactic:
exact (tsum_coe_ne_top_iff_summable.1 hsum).hasSum
theorem tsum_eq_toNNReal_tsum {f : β → ℝ≥0} : ∑' b, f b = (∑' b, (f b : ℝ≥0∞)).toNNReal := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
f : β → ℝ≥0
⊢ ∑' (b : β), f b = ENNReal.toNNReal (∑' (b : β), ↑(f b))

Next tactic:
by_cases h : Summable f
theorem tsum_eq_toNNReal_tsum {f : β → ℝ≥0} : ∑' b, f b = (∑' b, (f b : ℝ≥0∞)).toNNReal := by
  by_cases h : Summable f
  · 

Proof state:
case pos
α : Type u_1
β : Type u_2
γ : Type u_3
f : β → ℝ≥0
h : Summable f
⊢ ∑' (b : β), f b = ENNReal.toNNReal (∑' (b : β), ↑(f b))

Next tactic:
rw [← ENNReal.coe_tsum h, ENNReal.toNNReal_coe]
theorem tsum_eq_toNNReal_tsum {f : β → ℝ≥0} : ∑' b, f b = (∑' b, (f b : ℝ≥0∞)).toNNReal := by
  by_cases h : Summable f
  · rw [← ENNReal.coe_tsum h, ENNReal.toNNReal_coe]
  · 

Proof state:
case neg
α : Type u_1
β : Type u_2
γ : Type u_3
f : β → ℝ≥0
h : ¬Summable f
⊢ ∑' (b : β), f b = ENNReal.toNNReal (∑' (b : β), ↑(f b))

Next tactic:
have A := tsum_eq_zero_of_not_summable h
theorem tsum_eq_toNNReal_tsum {f : β → ℝ≥0} : ∑' b, f b = (∑' b, (f b : ℝ≥0∞)).toNNReal := by
  by_cases h : Summable f
  · rw [← ENNReal.coe_tsum h, ENNReal.toNNReal_coe]
  · have A := tsum_eq_zero_of_not_summable h
    

Proof state:
case neg
α : Type u_1
β : Type u_2
γ : Type u_3
f : β → ℝ≥0
h : ¬Summable f
A : ∑' (b : β), f b = 0
⊢ ∑' (b : β), f b = ENNReal.toNNReal (∑' (b : β), ↑(f b))

Next tactic:
simp only [← ENNReal.tsum_coe_ne_top_iff_summable, Classical.not_not] at h
theorem tsum_eq_toNNReal_tsum {f : β → ℝ≥0} : ∑' b, f b = (∑' b, (f b : ℝ≥0∞)).toNNReal := by
  by_cases h : Summable f
  · rw [← ENNReal.coe_tsum h, ENNReal.toNNReal_coe]
  · have A := tsum_eq_zero_of_not_summable h
    simp only [← ENNReal.tsum_coe_ne_top_iff_summable, Classical.not_not] at h
    

Proof state:
case neg
α : Type u_1
β : Type u_2
γ : Type u_3
f : β → ℝ≥0
A : ∑' (b : β), f b = 0
h : ∑' (b : β), ↑(f b) = ⊤
⊢ ∑' (b : β), f b = ENNReal.toNNReal (∑' (b : β), ↑(f b))

Next tactic:
simp only [h, ENNReal.top_toNNReal, A]
/-- Comparison test of convergence of `ℝ≥0`-valued series. -/
theorem exists_le_hasSum_of_le {f g : β → ℝ≥0} {r : ℝ≥0} (hgf : ∀ b, g b ≤ f b) (hfr : HasSum f r) :
    ∃ p ≤ r, HasSum g p :=
  have : (∑' b, (g b : ℝ≥0∞)) ≤ r := by
    

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
f g : β → ℝ≥0
r : ℝ≥0
hgf : ∀ (b : β), g b ≤ f b
hfr : HasSum f r
⊢ ∑' (b : β), ↑(g b) ≤ ↑r

Next tactic:
refine hasSum_le (fun b => ?_) ENNReal.summable.hasSum (ENNReal.hasSum_coe.2 hfr)
/-- Comparison test of convergence of `ℝ≥0`-valued series. -/
theorem exists_le_hasSum_of_le {f g : β → ℝ≥0} {r : ℝ≥0} (hgf : ∀ b, g b ≤ f b) (hfr : HasSum f r) :
    ∃ p ≤ r, HasSum g p :=
  have : (∑' b, (g b : ℝ≥0∞)) ≤ r := by
    refine hasSum_le (fun b => ?_) ENNReal.summable.hasSum (ENNReal.hasSum_coe.2 hfr)
    

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
f g : β → ℝ≥0
r : ℝ≥0
hgf : ∀ (b : β), g b ≤ f b
hfr : HasSum f r
b : β
⊢ ↑(g b) ≤ ↑(f b)

Next tactic:
exact ENNReal.coe_le_coe.2 (hgf _)
/-- Summable non-negative functions have countable support -/
theorem _root_.Summable.countable_support_nnreal (f : α → ℝ≥0) (h : Summable f) :
    f.support.Countable := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
f : α → ℝ≥0
h : Summable f
⊢ Set.Countable (support f)

Next tactic:
rw [← NNReal.summable_coe] at h
/-- Summable non-negative functions have countable support -/
theorem _root_.Summable.countable_support_nnreal (f : α → ℝ≥0) (h : Summable f) :
    f.support.Countable := by
  rw [← NNReal.summable_coe] at h
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
f : α → ℝ≥0
h : Summable fun a => ↑(f a)
⊢ Set.Countable (support f)

Next tactic:
simpa [support] using h.countable_support
/-- A series of non-negative real numbers converges to `r` in the sense of `HasSum` if and only if
the sequence of partial sum converges to `r`. -/
theorem hasSum_iff_tendsto_nat {f : ℕ → ℝ≥0} {r : ℝ≥0} :
    HasSum f r ↔ Tendsto (fun n : ℕ => ∑ i in Finset.range n, f i) atTop (𝓝 r) := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
f : ℕ → ℝ≥0
r : ℝ≥0
⊢ HasSum f r ↔ Tendsto (fun n => ∑ i in Finset.range n, f i) atTop (𝓝 r)

Next tactic:
rw [← ENNReal.hasSum_coe, ENNReal.hasSum_iff_tendsto_nat]
/-- A series of non-negative real numbers converges to `r` in the sense of `HasSum` if and only if
the sequence of partial sum converges to `r`. -/
theorem hasSum_iff_tendsto_nat {f : ℕ → ℝ≥0} {r : ℝ≥0} :
    HasSum f r ↔ Tendsto (fun n : ℕ => ∑ i in Finset.range n, f i) atTop (𝓝 r) := by
  rw [← ENNReal.hasSum_coe, ENNReal.hasSum_iff_tendsto_nat]
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
f : ℕ → ℝ≥0
r : ℝ≥0
⊢ Tendsto (fun n => ∑ i in Finset.range n, ↑(f i)) atTop (𝓝 ↑r) ↔
    Tendsto (fun n => ∑ i in Finset.range n, f i) atTop (𝓝 r)

Next tactic:
simp only [← ENNReal.coe_finset_sum]
/-- A series of non-negative real numbers converges to `r` in the sense of `HasSum` if and only if
the sequence of partial sum converges to `r`. -/
theorem hasSum_iff_tendsto_nat {f : ℕ → ℝ≥0} {r : ℝ≥0} :
    HasSum f r ↔ Tendsto (fun n : ℕ => ∑ i in Finset.range n, f i) atTop (𝓝 r) := by
  rw [← ENNReal.hasSum_coe, ENNReal.hasSum_iff_tendsto_nat]
  simp only [← ENNReal.coe_finset_sum]
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
f : ℕ → ℝ≥0
r : ℝ≥0
⊢ Tendsto (fun n => ↑(∑ a in Finset.range n, f a)) atTop (𝓝 ↑r) ↔
    Tendsto (fun n => ∑ a in Finset.range n, f a) atTop (𝓝 r)

Next tactic:
exact ENNReal.tendsto_coe
theorem not_summable_iff_tendsto_nat_atTop {f : ℕ → ℝ≥0} :
    ¬Summable f ↔ Tendsto (fun n : ℕ => ∑ i in Finset.range n, f i) atTop atTop := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
f : ℕ → ℝ≥0
⊢ ¬Summable f ↔ Tendsto (fun n => ∑ i in Finset.range n, f i) atTop atTop

Next tactic:
constructor
theorem not_summable_iff_tendsto_nat_atTop {f : ℕ → ℝ≥0} :
    ¬Summable f ↔ Tendsto (fun n : ℕ => ∑ i in Finset.range n, f i) atTop atTop := by
  constructor
  · 

Proof state:
case mp
α : Type u_1
β : Type u_2
γ : Type u_3
f : ℕ → ℝ≥0
⊢ ¬Summable f → Tendsto (fun n => ∑ i in Finset.range n, f i) atTop atTop

Next tactic:
intro h
theorem not_summable_iff_tendsto_nat_atTop {f : ℕ → ℝ≥0} :
    ¬Summable f ↔ Tendsto (fun n : ℕ => ∑ i in Finset.range n, f i) atTop atTop := by
  constructor
  · intro h
    

Proof state:
case mp
α : Type u_1
β : Type u_2
γ : Type u_3
f : ℕ → ℝ≥0
h : ¬Summable f
⊢ Tendsto (fun n => ∑ i in Finset.range n, f i) atTop atTop

Next tactic:
refine' ((tendsto_of_monotone _).resolve_right h).comp _
theorem not_summable_iff_tendsto_nat_atTop {f : ℕ → ℝ≥0} :
    ¬Summable f ↔ Tendsto (fun n : ℕ => ∑ i in Finset.range n, f i) atTop atTop := by
  constructor
  · intro h
    refine' ((tendsto_of_monotone _).resolve_right h).comp _
    

Proof state:
case mp.refine'_1
α : Type u_1
β : Type u_2
γ : Type u_3
f : ℕ → ℝ≥0
h : ¬Summable f
⊢ Monotone fun s => ∑ b in s, f b
case mp.refine'_2
α : Type u_1
β : Type u_2
γ : Type u_3
f : ℕ → ℝ≥0
h : ¬Summable f
⊢ Tendsto (fun n => Finset.range n) atTop atTop

Next tactic:
exacts [Finset.sum_mono_set _, tendsto_finset_range]
theorem not_summable_iff_tendsto_nat_atTop {f : ℕ → ℝ≥0} :
    ¬Summable f ↔ Tendsto (fun n : ℕ => ∑ i in Finset.range n, f i) atTop atTop := by
  constructor
  · intro h
    refine' ((tendsto_of_monotone _).resolve_right h).comp _
    exacts [Finset.sum_mono_set _, tendsto_finset_range]
  · 

Proof state:
case mpr
α : Type u_1
β : Type u_2
γ : Type u_3
f : ℕ → ℝ≥0
⊢ Tendsto (fun n => ∑ i in Finset.range n, f i) atTop atTop → ¬Summable f

Next tactic:
rintro hnat ⟨r, hr⟩
theorem not_summable_iff_tendsto_nat_atTop {f : ℕ → ℝ≥0} :
    ¬Summable f ↔ Tendsto (fun n : ℕ => ∑ i in Finset.range n, f i) atTop atTop := by
  constructor
  · intro h
    refine' ((tendsto_of_monotone _).resolve_right h).comp _
    exacts [Finset.sum_mono_set _, tendsto_finset_range]
  · rintro hnat ⟨r, hr⟩
    

Proof state:
case mpr.intro
α : Type u_1
β : Type u_2
γ : Type u_3
f : ℕ → ℝ≥0
hnat : Tendsto (fun n => ∑ i in Finset.range n, f i) atTop atTop
r : ℝ≥0
hr : HasSum f r
⊢ False

Next tactic:
exact not_tendsto_nhds_of_tendsto_atTop hnat _ (hasSum_iff_tendsto_nat.1 hr)
theorem summable_iff_not_tendsto_nat_atTop {f : ℕ → ℝ≥0} :
    Summable f ↔ ¬Tendsto (fun n : ℕ => ∑ i in Finset.range n, f i) atTop atTop := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
f : ℕ → ℝ≥0
⊢ Summable f ↔ ¬Tendsto (fun n => ∑ i in Finset.range n, f i) atTop atTop

Next tactic:
rw [← not_iff_not, Classical.not_not, not_summable_iff_tendsto_nat_atTop]
theorem summable_of_sum_range_le {f : ℕ → ℝ≥0} {c : ℝ≥0}
    (h : ∀ n, ∑ i in Finset.range n, f i ≤ c) : Summable f := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
f : ℕ → ℝ≥0
c : ℝ≥0
h : ∀ (n : ℕ), ∑ i in Finset.range n, f i ≤ c
⊢ Summable f

Next tactic:
refine summable_iff_not_tendsto_nat_atTop.2 fun H => ?_
theorem summable_of_sum_range_le {f : ℕ → ℝ≥0} {c : ℝ≥0}
    (h : ∀ n, ∑ i in Finset.range n, f i ≤ c) : Summable f := by
  refine summable_iff_not_tendsto_nat_atTop.2 fun H => ?_
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
f : ℕ → ℝ≥0
c : ℝ≥0
h : ∀ (n : ℕ), ∑ i in Finset.range n, f i ≤ c
H : Tendsto (fun n => ∑ i in Finset.range n, f i) atTop atTop
⊢ False

Next tactic:
rcases exists_lt_of_tendsto_atTop H 0 c with ⟨n, -, hn⟩