l3lab/ntp-mathlib huggingface dataset:
/-- If `‖r‖ < 1`, then `∑' n : ℕ, n * r ^ n = r / (1 - r) ^ 2`, `HasSum` version. -/
theorem hasSum_coe_mul_geometric_of_norm_lt_1 {𝕜 : Type*} [NormedField 𝕜] [CompleteSpace 𝕜] {r : 𝕜}
    (hr : ‖r‖ < 1) : HasSum (fun n ↦ n * r ^ n : ℕ → 𝕜) (r / (1 - r) ^ 2) := by
  have A : Summable (fun n ↦ (n : 𝕜) * r ^ n : ℕ → 𝕜) := by
    

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
𝕜 : Type u_4
inst✝¹ : NormedField 𝕜
inst✝ : CompleteSpace 𝕜
r : 𝕜
hr : ‖r‖ < 1
⊢ Summable fun n => ↑n * r ^ n

Next tactic:
simpa only [pow_one] using summable_pow_mul_geometric_of_norm_lt_1 1 hr
/-- If `‖r‖ < 1`, then `∑' n : ℕ, n * r ^ n = r / (1 - r) ^ 2`, `HasSum` version. -/
theorem hasSum_coe_mul_geometric_of_norm_lt_1 {𝕜 : Type*} [NormedField 𝕜] [CompleteSpace 𝕜] {r : 𝕜}
    (hr : ‖r‖ < 1) : HasSum (fun n ↦ n * r ^ n : ℕ → 𝕜) (r / (1 - r) ^ 2) := by
  have A : Summable (fun n ↦ (n : 𝕜) * r ^ n : ℕ → 𝕜) := by
    simpa only [pow_one] using summable_pow_mul_geometric_of_norm_lt_1 1 hr
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
𝕜 : Type u_4
inst✝¹ : NormedField 𝕜
inst✝ : CompleteSpace 𝕜
r : 𝕜
hr : ‖r‖ < 1
A : Summable fun n => ↑n * r ^ n
⊢ HasSum (fun n => ↑n * r ^ n) (r / (1 - r) ^ 2)

Next tactic:
have B : HasSum (r ^ · : ℕ → 𝕜) (1 - r)⁻¹ := hasSum_geometric_of_norm_lt_1 hr
/-- If `‖r‖ < 1`, then `∑' n : ℕ, n * r ^ n = r / (1 - r) ^ 2`, `HasSum` version. -/
theorem hasSum_coe_mul_geometric_of_norm_lt_1 {𝕜 : Type*} [NormedField 𝕜] [CompleteSpace 𝕜] {r : 𝕜}
    (hr : ‖r‖ < 1) : HasSum (fun n ↦ n * r ^ n : ℕ → 𝕜) (r / (1 - r) ^ 2) := by
  have A : Summable (fun n ↦ (n : 𝕜) * r ^ n : ℕ → 𝕜) := by
    simpa only [pow_one] using summable_pow_mul_geometric_of_norm_lt_1 1 hr
  have B : HasSum (r ^ · : ℕ → 𝕜) (1 - r)⁻¹ := hasSum_geometric_of_norm_lt_1 hr
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
𝕜 : Type u_4
inst✝¹ : NormedField 𝕜
inst✝ : CompleteSpace 𝕜
r : 𝕜
hr : ‖r‖ < 1
A : Summable fun n => ↑n * r ^ n
B : HasSum (fun x => r ^ x) (1 - r)⁻¹
⊢ HasSum (fun n => ↑n * r ^ n) (r / (1 - r) ^ 2)

Next tactic:
refine' A.hasSum_iff.2 _
/-- If `‖r‖ < 1`, then `∑' n : ℕ, n * r ^ n = r / (1 - r) ^ 2`, `HasSum` version. -/
theorem hasSum_coe_mul_geometric_of_norm_lt_1 {𝕜 : Type*} [NormedField 𝕜] [CompleteSpace 𝕜] {r : 𝕜}
    (hr : ‖r‖ < 1) : HasSum (fun n ↦ n * r ^ n : ℕ → 𝕜) (r / (1 - r) ^ 2) := by
  have A : Summable (fun n ↦ (n : 𝕜) * r ^ n : ℕ → 𝕜) := by
    simpa only [pow_one] using summable_pow_mul_geometric_of_norm_lt_1 1 hr
  have B : HasSum (r ^ · : ℕ → 𝕜) (1 - r)⁻¹ := hasSum_geometric_of_norm_lt_1 hr
  refine' A.hasSum_iff.2 _
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
𝕜 : Type u_4
inst✝¹ : NormedField 𝕜
inst✝ : CompleteSpace 𝕜
r : 𝕜
hr : ‖r‖ < 1
A : Summable fun n => ↑n * r ^ n
B : HasSum (fun x => r ^ x) (1 - r)⁻¹
⊢ ∑' (b : ℕ), ↑b * r ^ b = r / (1 - r) ^ 2

Next tactic:
have hr' : r ≠ 1 := by
    rintro rfl
    simp [lt_irrefl] at hr
/-- If `‖r‖ < 1`, then `∑' n : ℕ, n * r ^ n = r / (1 - r) ^ 2`, `HasSum` version. -/
theorem hasSum_coe_mul_geometric_of_norm_lt_1 {𝕜 : Type*} [NormedField 𝕜] [CompleteSpace 𝕜] {r : 𝕜}
    (hr : ‖r‖ < 1) : HasSum (fun n ↦ n * r ^ n : ℕ → 𝕜) (r / (1 - r) ^ 2) := by
  have A : Summable (fun n ↦ (n : 𝕜) * r ^ n : ℕ → 𝕜) := by
    simpa only [pow_one] using summable_pow_mul_geometric_of_norm_lt_1 1 hr
  have B : HasSum (r ^ · : ℕ → 𝕜) (1 - r)⁻¹ := hasSum_geometric_of_norm_lt_1 hr
  refine' A.hasSum_iff.2 _
  have hr' : r ≠ 1 := by
    

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
𝕜 : Type u_4
inst✝¹ : NormedField 𝕜
inst✝ : CompleteSpace 𝕜
r : 𝕜
hr : ‖r‖ < 1
A : Summable fun n => ↑n * r ^ n
B : HasSum (fun x => r ^ x) (1 - r)⁻¹
⊢ r ≠ 1

Next tactic:
rintro rfl
/-- If `‖r‖ < 1`, then `∑' n : ℕ, n * r ^ n = r / (1 - r) ^ 2`, `HasSum` version. -/
theorem hasSum_coe_mul_geometric_of_norm_lt_1 {𝕜 : Type*} [NormedField 𝕜] [CompleteSpace 𝕜] {r : 𝕜}
    (hr : ‖r‖ < 1) : HasSum (fun n ↦ n * r ^ n : ℕ → 𝕜) (r / (1 - r) ^ 2) := by
  have A : Summable (fun n ↦ (n : 𝕜) * r ^ n : ℕ → 𝕜) := by
    simpa only [pow_one] using summable_pow_mul_geometric_of_norm_lt_1 1 hr
  have B : HasSum (r ^ · : ℕ → 𝕜) (1 - r)⁻¹ := hasSum_geometric_of_norm_lt_1 hr
  refine' A.hasSum_iff.2 _
  have hr' : r ≠ 1 := by
    rintro rfl
    

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
𝕜 : Type u_4
inst✝¹ : NormedField 𝕜
inst✝ : CompleteSpace 𝕜
hr : ‖1‖ < 1
A : Summable fun n => ↑n * 1 ^ n
B : HasSum (fun x => 1 ^ x) (1 - 1)⁻¹
⊢ False

Next tactic:
simp [lt_irrefl] at hr
/-- If `‖r‖ < 1`, then `∑' n : ℕ, n * r ^ n = r / (1 - r) ^ 2`, `HasSum` version. -/
theorem hasSum_coe_mul_geometric_of_norm_lt_1 {𝕜 : Type*} [NormedField 𝕜] [CompleteSpace 𝕜] {r : 𝕜}
    (hr : ‖r‖ < 1) : HasSum (fun n ↦ n * r ^ n : ℕ → 𝕜) (r / (1 - r) ^ 2) := by
  have A : Summable (fun n ↦ (n : 𝕜) * r ^ n : ℕ → 𝕜) := by
    simpa only [pow_one] using summable_pow_mul_geometric_of_norm_lt_1 1 hr
  have B : HasSum (r ^ · : ℕ → 𝕜) (1 - r)⁻¹ := hasSum_geometric_of_norm_lt_1 hr
  refine' A.hasSum_iff.2 _
  have hr' : r ≠ 1 := by
    rintro rfl
    simp [lt_irrefl] at hr
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
𝕜 : Type u_4
inst✝¹ : NormedField 𝕜
inst✝ : CompleteSpace 𝕜
r : 𝕜
hr : ‖r‖ < 1
A : Summable fun n => ↑n * r ^ n
B : HasSum (fun x => r ^ x) (1 - r)⁻¹
hr' : r ≠ 1
⊢ ∑' (b : ℕ), ↑b * r ^ b = r / (1 - r) ^ 2

Next tactic:
set s : 𝕜 := ∑' n : ℕ, n * r ^ n
/-- If `‖r‖ < 1`, then `∑' n : ℕ, n * r ^ n = r / (1 - r) ^ 2`, `HasSum` version. -/
theorem hasSum_coe_mul_geometric_of_norm_lt_1 {𝕜 : Type*} [NormedField 𝕜] [CompleteSpace 𝕜] {r : 𝕜}
    (hr : ‖r‖ < 1) : HasSum (fun n ↦ n * r ^ n : ℕ → 𝕜) (r / (1 - r) ^ 2) := by
  have A : Summable (fun n ↦ (n : 𝕜) * r ^ n : ℕ → 𝕜) := by
    simpa only [pow_one] using summable_pow_mul_geometric_of_norm_lt_1 1 hr
  have B : HasSum (r ^ · : ℕ → 𝕜) (1 - r)⁻¹ := hasSum_geometric_of_norm_lt_1 hr
  refine' A.hasSum_iff.2 _
  have hr' : r ≠ 1 := by
    rintro rfl
    simp [lt_irrefl] at hr
  set s : 𝕜 := ∑' n : ℕ, n * r ^ n
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
𝕜 : Type u_4
inst✝¹ : NormedField 𝕜
inst✝ : CompleteSpace 𝕜
r : 𝕜
hr : ‖r‖ < 1
A : Summable fun n => ↑n * r ^ n
B : HasSum (fun x => r ^ x) (1 - r)⁻¹
hr' : r ≠ 1
s : 𝕜 := ∑' (n : ℕ), ↑n * r ^ n
⊢ s = r / (1 - r) ^ 2

Next tactic:
calc
    s = (1 - r) * s / (1 - r) := (mul_div_cancel_left _ (sub_ne_zero.2 hr'.symm)).symm
    _ = (s - r * s) / (1 - r) := by rw [_root_.sub_mul, one_mul]
    _ = (((0 : ℕ) * r ^ 0 + ∑' n : ℕ, (n + 1 : ℕ) * r ^ (n + 1)) - r * s) / (1 - r) := by
      rw [← tsum_eq_zero_add A]
    _ = ((r * ∑' n : ℕ, (n + 1) * r ^ n) - r * s) / (1 - r) := by
      simp [_root_.pow_succ, mul_left_comm _ r, _root_.tsum_mul_left]
    _ = r / (1 - r) ^ 2 := by
      simp [add_mul, tsum_add A B.summable, mul_add, B.tsum_eq, ← div_eq_mul_inv, sq, div_div]
/-- If `‖r‖ < 1`, then `∑' n : ℕ, n * r ^ n = r / (1 - r) ^ 2`, `HasSum` version. -/
theorem hasSum_coe_mul_geometric_of_norm_lt_1 {𝕜 : Type*} [NormedField 𝕜] [CompleteSpace 𝕜] {r : 𝕜}
    (hr : ‖r‖ < 1) : HasSum (fun n ↦ n * r ^ n : ℕ → 𝕜) (r / (1 - r) ^ 2) := by
  have A : Summable (fun n ↦ (n : 𝕜) * r ^ n : ℕ → 𝕜) := by
    simpa only [pow_one] using summable_pow_mul_geometric_of_norm_lt_1 1 hr
  have B : HasSum (r ^ · : ℕ → 𝕜) (1 - r)⁻¹ := hasSum_geometric_of_norm_lt_1 hr
  refine' A.hasSum_iff.2 _
  have hr' : r ≠ 1 := by
    rintro rfl
    simp [lt_irrefl] at hr
  set s : 𝕜 := ∑' n : ℕ, n * r ^ n
  calc
    s = (1 - r) * s / (1 - r) := (mul_div_cancel_left _ (sub_ne_zero.2 hr'.symm)).symm
    _ = (s - r * s) / (1 - r) := by 

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
𝕜 : Type u_4
inst✝¹ : NormedField 𝕜
inst✝ : CompleteSpace 𝕜
r : 𝕜
hr : ‖r‖ < 1
A : Summable fun n => ↑n * r ^ n
B : HasSum (fun x => r ^ x) (1 - r)⁻¹
hr' : r ≠ 1
s : 𝕜 := ∑' (n : ℕ), ↑n * r ^ n
⊢ (1 - r) * s / (1 - r) = (s - r * s) / (1 - r)

Next tactic:
rw [_root_.sub_mul, one_mul]
/-- If `‖r‖ < 1`, then `∑' n : ℕ, n * r ^ n = r / (1 - r) ^ 2`, `HasSum` version. -/
theorem hasSum_coe_mul_geometric_of_norm_lt_1 {𝕜 : Type*} [NormedField 𝕜] [CompleteSpace 𝕜] {r : 𝕜}
    (hr : ‖r‖ < 1) : HasSum (fun n ↦ n * r ^ n : ℕ → 𝕜) (r / (1 - r) ^ 2) := by
  have A : Summable (fun n ↦ (n : 𝕜) * r ^ n : ℕ → 𝕜) := by
    simpa only [pow_one] using summable_pow_mul_geometric_of_norm_lt_1 1 hr
  have B : HasSum (r ^ · : ℕ → 𝕜) (1 - r)⁻¹ := hasSum_geometric_of_norm_lt_1 hr
  refine' A.hasSum_iff.2 _
  have hr' : r ≠ 1 := by
    rintro rfl
    simp [lt_irrefl] at hr
  set s : 𝕜 := ∑' n : ℕ, n * r ^ n
  calc
    s = (1 - r) * s / (1 - r) := (mul_div_cancel_left _ (sub_ne_zero.2 hr'.symm)).symm
    _ = (s - r * s) / (1 - r) := by rw [_root_.sub_mul, one_mul]
    _ = (((0 : ℕ) * r ^ 0 + ∑' n : ℕ, (n + 1 : ℕ) * r ^ (n + 1)) - r * s) / (1 - r) := by
      

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
𝕜 : Type u_4
inst✝¹ : NormedField 𝕜
inst✝ : CompleteSpace 𝕜
r : 𝕜
hr : ‖r‖ < 1
A : Summable fun n => ↑n * r ^ n
B : HasSum (fun x => r ^ x) (1 - r)⁻¹
hr' : r ≠ 1
s : 𝕜 := ∑' (n : ℕ), ↑n * r ^ n
⊢ (s - r * s) / (1 - r) = (↑0 * r ^ 0 + ∑' (n : ℕ), ↑(n + 1) * r ^ (n + 1) - r * s) / (1 - r)

Next tactic:
rw [← tsum_eq_zero_add A]
/-- If `‖r‖ < 1`, then `∑' n : ℕ, n * r ^ n = r / (1 - r) ^ 2`, `HasSum` version. -/
theorem hasSum_coe_mul_geometric_of_norm_lt_1 {𝕜 : Type*} [NormedField 𝕜] [CompleteSpace 𝕜] {r : 𝕜}
    (hr : ‖r‖ < 1) : HasSum (fun n ↦ n * r ^ n : ℕ → 𝕜) (r / (1 - r) ^ 2) := by
  have A : Summable (fun n ↦ (n : 𝕜) * r ^ n : ℕ → 𝕜) := by
    simpa only [pow_one] using summable_pow_mul_geometric_of_norm_lt_1 1 hr
  have B : HasSum (r ^ · : ℕ → 𝕜) (1 - r)⁻¹ := hasSum_geometric_of_norm_lt_1 hr
  refine' A.hasSum_iff.2 _
  have hr' : r ≠ 1 := by
    rintro rfl
    simp [lt_irrefl] at hr
  set s : 𝕜 := ∑' n : ℕ, n * r ^ n
  calc
    s = (1 - r) * s / (1 - r) := (mul_div_cancel_left _ (sub_ne_zero.2 hr'.symm)).symm
    _ = (s - r * s) / (1 - r) := by rw [_root_.sub_mul, one_mul]
    _ = (((0 : ℕ) * r ^ 0 + ∑' n : ℕ, (n + 1 : ℕ) * r ^ (n + 1)) - r * s) / (1 - r) := by
      rw [← tsum_eq_zero_add A]
    _ = ((r * ∑' n : ℕ, (n + 1) * r ^ n) - r * s) / (1 - r) := by
      

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
𝕜 : Type u_4
inst✝¹ : NormedField 𝕜
inst✝ : CompleteSpace 𝕜
r : 𝕜
hr : ‖r‖ < 1
A : Summable fun n => ↑n * r ^ n
B : HasSum (fun x => r ^ x) (1 - r)⁻¹
hr' : r ≠ 1
s : 𝕜 := ∑' (n : ℕ), ↑n * r ^ n
⊢ (↑0 * r ^ 0 + ∑' (n : ℕ), ↑(n + 1) * r ^ (n + 1) - r * s) / (1 - r) =
    (r * ∑' (n : ℕ), (↑n + 1) * r ^ n - r * s) / (1 - r)

Next tactic:
simp [_root_.pow_succ, mul_left_comm _ r, _root_.tsum_mul_left]
/-- If `‖r‖ < 1`, then `∑' n : ℕ, n * r ^ n = r / (1 - r) ^ 2`, `HasSum` version. -/
theorem hasSum_coe_mul_geometric_of_norm_lt_1 {𝕜 : Type*} [NormedField 𝕜] [CompleteSpace 𝕜] {r : 𝕜}
    (hr : ‖r‖ < 1) : HasSum (fun n ↦ n * r ^ n : ℕ → 𝕜) (r / (1 - r) ^ 2) := by
  have A : Summable (fun n ↦ (n : 𝕜) * r ^ n : ℕ → 𝕜) := by
    simpa only [pow_one] using summable_pow_mul_geometric_of_norm_lt_1 1 hr
  have B : HasSum (r ^ · : ℕ → 𝕜) (1 - r)⁻¹ := hasSum_geometric_of_norm_lt_1 hr
  refine' A.hasSum_iff.2 _
  have hr' : r ≠ 1 := by
    rintro rfl
    simp [lt_irrefl] at hr
  set s : 𝕜 := ∑' n : ℕ, n * r ^ n
  calc
    s = (1 - r) * s / (1 - r) := (mul_div_cancel_left _ (sub_ne_zero.2 hr'.symm)).symm
    _ = (s - r * s) / (1 - r) := by rw [_root_.sub_mul, one_mul]
    _ = (((0 : ℕ) * r ^ 0 + ∑' n : ℕ, (n + 1 : ℕ) * r ^ (n + 1)) - r * s) / (1 - r) := by
      rw [← tsum_eq_zero_add A]
    _ = ((r * ∑' n : ℕ, (n + 1) * r ^ n) - r * s) / (1 - r) := by
      simp [_root_.pow_succ, mul_left_comm _ r, _root_.tsum_mul_left]
    _ = r / (1 - r) ^ 2 := by
      

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
𝕜 : Type u_4
inst✝¹ : NormedField 𝕜
inst✝ : CompleteSpace 𝕜
r : 𝕜
hr : ‖r‖ < 1
A : Summable fun n => ↑n * r ^ n
B : HasSum (fun x => r ^ x) (1 - r)⁻¹
hr' : r ≠ 1
s : 𝕜 := ∑' (n : ℕ), ↑n * r ^ n
⊢ (r * ∑' (n : ℕ), (↑n + 1) * r ^ n - r * s) / (1 - r) = r / (1 - r) ^ 2

Next tactic:
simp [add_mul, tsum_add A B.summable, mul_add, B.tsum_eq, ← div_eq_mul_inv, sq, div_div]
nonrec theorem SeminormedAddCommGroup.cauchySeq_of_le_geometric {C : ℝ} {r : ℝ} (hr : r < 1)
    {u : ℕ → α} (h : ∀ n, ‖u n - u (n + 1)‖ ≤ C * r ^ n) : CauchySeq u :=
  cauchySeq_of_le_geometric r C hr (by 

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
inst✝ : SeminormedAddCommGroup α
r✝ C✝ : ℝ
f : ℕ → α
C r : ℝ
hr : r < 1
u : ℕ → α
h : ∀ (n : ℕ), ‖u n - u (n + 1)‖ ≤ C * r ^ n
⊢ ∀ (n : ℕ), dist (u n) (u (n + 1)) ≤ C * r ^ n

Next tactic:
simpa [dist_eq_norm] using h
theorem dist_partial_sum_le_of_le_geometric (hf : ∀ n, ‖f n‖ ≤ C * r ^ n) (n : ℕ) :
    dist (∑ i in range n, f i) (∑ i in range (n + 1), f i) ≤ C * r ^ n := by
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
inst✝ : SeminormedAddCommGroup α
r C : ℝ
f : ℕ → α
hf : ∀ (n : ℕ), ‖f n‖ ≤ C * r ^ n
n : ℕ
⊢ dist (∑ i in Finset.range n, f i) (∑ i in Finset.range (n + 1), f i) ≤ C * r ^ n

Next tactic:
rw [sum_range_succ, dist_eq_norm, ← norm_neg, neg_sub, add_sub_cancel']
theorem dist_partial_sum_le_of_le_geometric (hf : ∀ n, ‖f n‖ ≤ C * r ^ n) (n : ℕ) :
    dist (∑ i in range n, f i) (∑ i in range (n + 1), f i) ≤ C * r ^ n := by
  rw [sum_range_succ, dist_eq_norm, ← norm_neg, neg_sub, add_sub_cancel']
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
inst✝ : SeminormedAddCommGroup α
r C : ℝ
f : ℕ → α
hf : ∀ (n : ℕ), ‖f n‖ ≤ C * r ^ n
n : ℕ
⊢ ‖f n‖ ≤ C * r ^ n

Next tactic:
exact hf n
/-- If `‖f n‖ ≤ C * r ^ n` for all `n : ℕ` and some `r < 1`, then the partial sums of `f` are within
distance `C * r ^ n / (1 - r)` of the sum of the series. This lemma does not assume `0 ≤ r` or
`0 ≤ C`. -/
theorem norm_sub_le_of_geometric_bound_of_hasSum (hr : r < 1) (hf : ∀ n, ‖f n‖ ≤ C * r ^ n) {a : α}
    (ha : HasSum f a) (n : ℕ) : ‖(∑ x in Finset.range n, f x) - a‖ ≤ C * r ^ n / (1 - r) := by
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
inst✝ : SeminormedAddCommGroup α
r C : ℝ
f : ℕ → α
hr : r < 1
hf : ∀ (n : ℕ), ‖f n‖ ≤ C * r ^ n
a : α
ha : HasSum f a
n : ℕ
⊢ ‖∑ x in Finset.range n, f x - a‖ ≤ C * r ^ n / (1 - r)

Next tactic:
rw [← dist_eq_norm]
/-- If `‖f n‖ ≤ C * r ^ n` for all `n : ℕ` and some `r < 1`, then the partial sums of `f` are within
distance `C * r ^ n / (1 - r)` of the sum of the series. This lemma does not assume `0 ≤ r` or
`0 ≤ C`. -/
theorem norm_sub_le_of_geometric_bound_of_hasSum (hr : r < 1) (hf : ∀ n, ‖f n‖ ≤ C * r ^ n) {a : α}
    (ha : HasSum f a) (n : ℕ) : ‖(∑ x in Finset.range n, f x) - a‖ ≤ C * r ^ n / (1 - r) := by
  rw [← dist_eq_norm]
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
inst✝ : SeminormedAddCommGroup α
r C : ℝ
f : ℕ → α
hr : r < 1
hf : ∀ (n : ℕ), ‖f n‖ ≤ C * r ^ n
a : α
ha : HasSum f a
n : ℕ
⊢ dist (∑ x in Finset.range n, f x) a ≤ C * r ^ n / (1 - r)

Next tactic:
apply dist_le_of_le_geometric_of_tendsto r C hr (dist_partial_sum_le_of_le_geometric hf)
/-- If `‖f n‖ ≤ C * r ^ n` for all `n : ℕ` and some `r < 1`, then the partial sums of `f` are within
distance `C * r ^ n / (1 - r)` of the sum of the series. This lemma does not assume `0 ≤ r` or
`0 ≤ C`. -/
theorem norm_sub_le_of_geometric_bound_of_hasSum (hr : r < 1) (hf : ∀ n, ‖f n‖ ≤ C * r ^ n) {a : α}
    (ha : HasSum f a) (n : ℕ) : ‖(∑ x in Finset.range n, f x) - a‖ ≤ C * r ^ n / (1 - r) := by
  rw [← dist_eq_norm]
  apply dist_le_of_le_geometric_of_tendsto r C hr (dist_partial_sum_le_of_le_geometric hf)
  

Proof state:
case ha
α : Type u_1
β : Type u_2
ι : Type u_3
inst✝ : SeminormedAddCommGroup α
r C : ℝ
f : ℕ → α
hr : r < 1
hf : ∀ (n : ℕ), ‖f n‖ ≤ C * r ^ n
a : α
ha : HasSum f a
n : ℕ
⊢ Tendsto (fun n => ∑ i in Finset.range n, f i) atTop (𝓝 a)

Next tactic:
exact ha.tendsto_sum_nat
@[simp]
theorem dist_partial_sum (u : ℕ → α) (n : ℕ) :
    dist (∑ k in range (n + 1), u k) (∑ k in range n, u k) = ‖u n‖ := by
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
inst✝ : SeminormedAddCommGroup α
r C : ℝ
f u : ℕ → α
n : ℕ
⊢ dist (∑ k in Finset.range (n + 1), u k) (∑ k in Finset.range n, u k) = ‖u n‖

Next tactic:
simp [dist_eq_norm, sum_range_succ]
@[simp]
theorem dist_partial_sum' (u : ℕ → α) (n : ℕ) :
    dist (∑ k in range n, u k) (∑ k in range (n + 1), u k) = ‖u n‖ := by
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
inst✝ : SeminormedAddCommGroup α
r C : ℝ
f u : ℕ → α
n : ℕ
⊢ dist (∑ k in Finset.range n, u k) (∑ k in Finset.range (n + 1), u k) = ‖u n‖

Next tactic:
simp [dist_eq_norm', sum_range_succ]
theorem cauchy_series_of_le_geometric {C : ℝ} {u : ℕ → α} {r : ℝ} (hr : r < 1)
    (h : ∀ n, ‖u n‖ ≤ C * r ^ n) : CauchySeq fun n ↦ ∑ k in range n, u k :=
  cauchySeq_of_le_geometric r C hr (by 

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
inst✝ : SeminormedAddCommGroup α
r✝ C✝ : ℝ
f : ℕ → α
C : ℝ
u : ℕ → α
r : ℝ
hr : r < 1
h : ∀ (n : ℕ), ‖u n‖ ≤ C * r ^ n
⊢ ∀ (n : ℕ), dist (∑ k in Finset.range n, u k) (∑ k in Finset.range (n + 1), u k) ≤ C * r ^ n

Next tactic:
simp [h]
theorem NormedAddCommGroup.cauchy_series_of_le_geometric'' {C : ℝ} {u : ℕ → α} {N : ℕ} {r : ℝ}
    (hr₀ : 0 < r) (hr₁ : r < 1) (h : ∀ n ≥ N, ‖u n‖ ≤ C * r ^ n) :
    CauchySeq fun n ↦ ∑ k in range (n + 1), u k := by
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
inst✝ : SeminormedAddCommGroup α
r✝ C✝ : ℝ
f : ℕ → α
C : ℝ
u : ℕ → α
N : ℕ
r : ℝ
hr₀ : 0 < r
hr₁ : r < 1
h : ∀ n ≥ N, ‖u n‖ ≤ C * r ^ n
⊢ CauchySeq fun n => ∑ k in Finset.range (n + 1), u k

Next tactic:
set v : ℕ → α := fun n ↦ if n < N then 0 else u n
theorem NormedAddCommGroup.cauchy_series_of_le_geometric'' {C : ℝ} {u : ℕ → α} {N : ℕ} {r : ℝ}
    (hr₀ : 0 < r) (hr₁ : r < 1) (h : ∀ n ≥ N, ‖u n‖ ≤ C * r ^ n) :
    CauchySeq fun n ↦ ∑ k in range (n + 1), u k := by
  set v : ℕ → α := fun n ↦ if n < N then 0 else u n
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
inst✝ : SeminormedAddCommGroup α
r✝ C✝ : ℝ
f : ℕ → α
C : ℝ
u : ℕ → α
N : ℕ
r : ℝ
hr₀ : 0 < r
hr₁ : r < 1
h : ∀ n ≥ N, ‖u n‖ ≤ C * r ^ n
v : ℕ → α := fun n => if n < N then 0 else u n
⊢ CauchySeq fun n => ∑ k in Finset.range (n + 1), u k

Next tactic:
have hC : 0 ≤ C :=
    (zero_le_mul_right <| pow_pos hr₀ N).mp ((norm_nonneg _).trans <| h N <| le_refl N)
theorem NormedAddCommGroup.cauchy_series_of_le_geometric'' {C : ℝ} {u : ℕ → α} {N : ℕ} {r : ℝ}
    (hr₀ : 0 < r) (hr₁ : r < 1) (h : ∀ n ≥ N, ‖u n‖ ≤ C * r ^ n) :
    CauchySeq fun n ↦ ∑ k in range (n + 1), u k := by
  set v : ℕ → α := fun n ↦ if n < N then 0 else u n
  have hC : 0 ≤ C :=
    (zero_le_mul_right <| pow_pos hr₀ N).mp ((norm_nonneg _).trans <| h N <| le_refl N)
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
inst✝ : SeminormedAddCommGroup α
r✝ C✝ : ℝ
f : ℕ → α
C : ℝ
u : ℕ → α
N : ℕ
r : ℝ
hr₀ : 0 < r
hr₁ : r < 1
h : ∀ n ≥ N, ‖u n‖ ≤ C * r ^ n
v : ℕ → α := fun n => if n < N then 0 else u n
hC : 0 ≤ C
⊢ CauchySeq fun n => ∑ k in Finset.range (n + 1), u k

Next tactic:
have : ∀ n ≥ N, u n = v n := by
    intro n hn
    simp [hn, if_neg (not_lt.mpr hn)]
theorem NormedAddCommGroup.cauchy_series_of_le_geometric'' {C : ℝ} {u : ℕ → α} {N : ℕ} {r : ℝ}
    (hr₀ : 0 < r) (hr₁ : r < 1) (h : ∀ n ≥ N, ‖u n‖ ≤ C * r ^ n) :
    CauchySeq fun n ↦ ∑ k in range (n + 1), u k := by
  set v : ℕ → α := fun n ↦ if n < N then 0 else u n
  have hC : 0 ≤ C :=
    (zero_le_mul_right <| pow_pos hr₀ N).mp ((norm_nonneg _).trans <| h N <| le_refl N)
  have : ∀ n ≥ N, u n = v n := by
    

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
inst✝ : SeminormedAddCommGroup α
r✝ C✝ : ℝ
f : ℕ → α
C : ℝ
u : ℕ → α
N : ℕ
r : ℝ
hr₀ : 0 < r
hr₁ : r < 1
h : ∀ n ≥ N, ‖u n‖ ≤ C * r ^ n
v : ℕ → α := fun n => if n < N then 0 else u n
hC : 0 ≤ C
⊢ ∀ n ≥ N, u n = v n

Next tactic:
intro n hn
theorem NormedAddCommGroup.cauchy_series_of_le_geometric'' {C : ℝ} {u : ℕ → α} {N : ℕ} {r : ℝ}
    (hr₀ : 0 < r) (hr₁ : r < 1) (h : ∀ n ≥ N, ‖u n‖ ≤ C * r ^ n) :
    CauchySeq fun n ↦ ∑ k in range (n + 1), u k := by
  set v : ℕ → α := fun n ↦ if n < N then 0 else u n
  have hC : 0 ≤ C :=
    (zero_le_mul_right <| pow_pos hr₀ N).mp ((norm_nonneg _).trans <| h N <| le_refl N)
  have : ∀ n ≥ N, u n = v n := by
    intro n hn
    

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
inst✝ : SeminormedAddCommGroup α
r✝ C✝ : ℝ
f : ℕ → α
C : ℝ
u : ℕ → α
N : ℕ
r : ℝ
hr₀ : 0 < r
hr₁ : r < 1
h : ∀ n ≥ N, ‖u n‖ ≤ C * r ^ n
v : ℕ → α := fun n => if n < N then 0 else u n
hC : 0 ≤ C
n : ℕ
hn : n ≥ N
⊢ u n = v n

Next tactic:
simp [hn, if_neg (not_lt.mpr hn)]
theorem NormedAddCommGroup.cauchy_series_of_le_geometric'' {C : ℝ} {u : ℕ → α} {N : ℕ} {r : ℝ}
    (hr₀ : 0 < r) (hr₁ : r < 1) (h : ∀ n ≥ N, ‖u n‖ ≤ C * r ^ n) :
    CauchySeq fun n ↦ ∑ k in range (n + 1), u k := by
  set v : ℕ → α := fun n ↦ if n < N then 0 else u n
  have hC : 0 ≤ C :=
    (zero_le_mul_right <| pow_pos hr₀ N).mp ((norm_nonneg _).trans <| h N <| le_refl N)
  have : ∀ n ≥ N, u n = v n := by
    intro n hn
    simp [hn, if_neg (not_lt.mpr hn)]
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
inst✝ : SeminormedAddCommGroup α
r✝ C✝ : ℝ
f : ℕ → α
C : ℝ
u : ℕ → α
N : ℕ
r : ℝ
hr₀ : 0 < r
hr₁ : r < 1
h : ∀ n ≥ N, ‖u n‖ ≤ C * r ^ n
v : ℕ → α := fun n => if n < N then 0 else u n
hC : 0 ≤ C
this : ∀ n ≥ N, u n = v n
⊢ CauchySeq fun n => ∑ k in Finset.range (n + 1), u k

Next tactic:
refine'
    cauchySeq_sum_of_eventually_eq this (NormedAddCommGroup.cauchy_series_of_le_geometric' hr₁ _)
theorem NormedAddCommGroup.cauchy_series_of_le_geometric'' {C : ℝ} {u : ℕ → α} {N : ℕ} {r : ℝ}
    (hr₀ : 0 < r) (hr₁ : r < 1) (h : ∀ n ≥ N, ‖u n‖ ≤ C * r ^ n) :
    CauchySeq fun n ↦ ∑ k in range (n + 1), u k := by
  set v : ℕ → α := fun n ↦ if n < N then 0 else u n
  have hC : 0 ≤ C :=
    (zero_le_mul_right <| pow_pos hr₀ N).mp ((norm_nonneg _).trans <| h N <| le_refl N)
  have : ∀ n ≥ N, u n = v n := by
    intro n hn
    simp [hn, if_neg (not_lt.mpr hn)]
  refine'
    cauchySeq_sum_of_eventually_eq this (NormedAddCommGroup.cauchy_series_of_le_geometric' hr₁ _)
  · 

Proof state:
case refine'_1
α : Type u_1
β : Type u_2
ι : Type u_3
inst✝ : SeminormedAddCommGroup α
r✝ C✝ : ℝ
f : ℕ → α
C : ℝ
u : ℕ → α
N : ℕ
r : ℝ
hr₀ : 0 < r
hr₁ : r < 1
h : ∀ n ≥ N, ‖u n‖ ≤ C * r ^ n
v : ℕ → α := fun n => if n < N then 0 else u n
hC : 0 ≤ C
this : ∀ n ≥ N, u n = v n
⊢ ℝ

Next tactic:
exact C
theorem NormedAddCommGroup.cauchy_series_of_le_geometric'' {C : ℝ} {u : ℕ → α} {N : ℕ} {r : ℝ}
    (hr₀ : 0 < r) (hr₁ : r < 1) (h : ∀ n ≥ N, ‖u n‖ ≤ C * r ^ n) :
    CauchySeq fun n ↦ ∑ k in range (n + 1), u k := by
  set v : ℕ → α := fun n ↦ if n < N then 0 else u n
  have hC : 0 ≤ C :=
    (zero_le_mul_right <| pow_pos hr₀ N).mp ((norm_nonneg _).trans <| h N <| le_refl N)
  have : ∀ n ≥ N, u n = v n := by
    intro n hn
    simp [hn, if_neg (not_lt.mpr hn)]
  refine'
    cauchySeq_sum_of_eventually_eq this (NormedAddCommGroup.cauchy_series_of_le_geometric' hr₁ _)
  · exact C
  

Proof state:
case refine'_2
α : Type u_1
β : Type u_2
ι : Type u_3
inst✝ : SeminormedAddCommGroup α
r✝ C✝ : ℝ
f : ℕ → α
C : ℝ
u : ℕ → α
N : ℕ
r : ℝ
hr₀ : 0 < r
hr₁ : r < 1
h : ∀ n ≥ N, ‖u n‖ ≤ C * r ^ n
v : ℕ → α := fun n => if n < N then 0 else u n
hC : 0 ≤ C
this : ∀ n ≥ N, u n = v n
⊢ ∀ (n : ℕ), ‖v n‖ ≤ C * r ^ n

Next tactic:
intro n
theorem NormedAddCommGroup.cauchy_series_of_le_geometric'' {C : ℝ} {u : ℕ → α} {N : ℕ} {r : ℝ}
    (hr₀ : 0 < r) (hr₁ : r < 1) (h : ∀ n ≥ N, ‖u n‖ ≤ C * r ^ n) :
    CauchySeq fun n ↦ ∑ k in range (n + 1), u k := by
  set v : ℕ → α := fun n ↦ if n < N then 0 else u n
  have hC : 0 ≤ C :=
    (zero_le_mul_right <| pow_pos hr₀ N).mp ((norm_nonneg _).trans <| h N <| le_refl N)
  have : ∀ n ≥ N, u n = v n := by
    intro n hn
    simp [hn, if_neg (not_lt.mpr hn)]
  refine'
    cauchySeq_sum_of_eventually_eq this (NormedAddCommGroup.cauchy_series_of_le_geometric' hr₁ _)
  · exact C
  intro n
  

Proof state:
case refine'_2
α : Type u_1
β : Type u_2
ι : Type u_3
inst✝ : SeminormedAddCommGroup α
r✝ C✝ : ℝ
f : ℕ → α
C : ℝ
u : ℕ → α
N : ℕ
r : ℝ
hr₀ : 0 < r
hr₁ : r < 1
h : ∀ n ≥ N, ‖u n‖ ≤ C * r ^ n
v : ℕ → α := fun n => if n < N then 0 else u n
hC : 0 ≤ C
this : ∀ n ≥ N, u n = v n
n : ℕ
⊢ ‖v n‖ ≤ C * r ^ n

Next tactic:
simp only