l3lab/ntp-mathlib huggingface dataset:
theorem geom_sum_Ico_le_of_lt_one [LinearOrderedField α] {x : α} (hx : 0 ≤ x) (h'x : x < 1)
    {m n : ℕ} : ∑ i in Ico m n, x ^ i ≤ x ^ m / (1 - x) := by
  

Proof state:
α : Type u
inst✝ : LinearOrderedField α
x : α
hx : 0 ≤ x
h'x : x < 1
m n : ℕ
⊢ ∑ i in Ico m n, x ^ i ≤ x ^ m / (1 - x)

Next tactic:
rcases le_or_lt m n with (hmn | hmn)
theorem geom_sum_Ico_le_of_lt_one [LinearOrderedField α] {x : α} (hx : 0 ≤ x) (h'x : x < 1)
    {m n : ℕ} : ∑ i in Ico m n, x ^ i ≤ x ^ m / (1 - x) := by
  rcases le_or_lt m n with (hmn | hmn)
  · 

Proof state:
case inl
α : Type u
inst✝ : LinearOrderedField α
x : α
hx : 0 ≤ x
h'x : x < 1
m n : ℕ
hmn : m ≤ n
⊢ ∑ i in Ico m n, x ^ i ≤ x ^ m / (1 - x)

Next tactic:
rw [geom_sum_Ico' h'x.ne hmn]
theorem geom_sum_Ico_le_of_lt_one [LinearOrderedField α] {x : α} (hx : 0 ≤ x) (h'x : x < 1)
    {m n : ℕ} : ∑ i in Ico m n, x ^ i ≤ x ^ m / (1 - x) := by
  rcases le_or_lt m n with (hmn | hmn)
  · rw [geom_sum_Ico' h'x.ne hmn]
    

Proof state:
case inl
α : Type u
inst✝ : LinearOrderedField α
x : α
hx : 0 ≤ x
h'x : x < 1
m n : ℕ
hmn : m ≤ n
⊢ (x ^ m - x ^ n) / (1 - x) ≤ x ^ m / (1 - x)

Next tactic:
apply div_le_div (pow_nonneg hx _) _ (sub_pos.2 h'x) le_rfl
theorem geom_sum_Ico_le_of_lt_one [LinearOrderedField α] {x : α} (hx : 0 ≤ x) (h'x : x < 1)
    {m n : ℕ} : ∑ i in Ico m n, x ^ i ≤ x ^ m / (1 - x) := by
  rcases le_or_lt m n with (hmn | hmn)
  · rw [geom_sum_Ico' h'x.ne hmn]
    apply div_le_div (pow_nonneg hx _) _ (sub_pos.2 h'x) le_rfl
    

Proof state:
α : Type u
inst✝ : LinearOrderedField α
x : α
hx : 0 ≤ x
h'x : x < 1
m n : ℕ
hmn : m ≤ n
⊢ x ^ m - x ^ n ≤ x ^ m

Next tactic:
simpa using pow_nonneg hx _
theorem geom_sum_Ico_le_of_lt_one [LinearOrderedField α] {x : α} (hx : 0 ≤ x) (h'x : x < 1)
    {m n : ℕ} : ∑ i in Ico m n, x ^ i ≤ x ^ m / (1 - x) := by
  rcases le_or_lt m n with (hmn | hmn)
  · rw [geom_sum_Ico' h'x.ne hmn]
    apply div_le_div (pow_nonneg hx _) _ (sub_pos.2 h'x) le_rfl
    simpa using pow_nonneg hx _
  · 

Proof state:
case inr
α : Type u
inst✝ : LinearOrderedField α
x : α
hx : 0 ≤ x
h'x : x < 1
m n : ℕ
hmn : n < m
⊢ ∑ i in Ico m n, x ^ i ≤ x ^ m / (1 - x)

Next tactic:
rw [Ico_eq_empty, sum_empty]
theorem geom_sum_Ico_le_of_lt_one [LinearOrderedField α] {x : α} (hx : 0 ≤ x) (h'x : x < 1)
    {m n : ℕ} : ∑ i in Ico m n, x ^ i ≤ x ^ m / (1 - x) := by
  rcases le_or_lt m n with (hmn | hmn)
  · rw [geom_sum_Ico' h'x.ne hmn]
    apply div_le_div (pow_nonneg hx _) _ (sub_pos.2 h'x) le_rfl
    simpa using pow_nonneg hx _
  · rw [Ico_eq_empty, sum_empty]
    · 

Proof state:
case inr
α : Type u
inst✝ : LinearOrderedField α
x : α
hx : 0 ≤ x
h'x : x < 1
m n : ℕ
hmn : n < m
⊢ 0 ≤ x ^ m / (1 - x)

Next tactic:
apply div_nonneg (pow_nonneg hx _)
theorem geom_sum_Ico_le_of_lt_one [LinearOrderedField α] {x : α} (hx : 0 ≤ x) (h'x : x < 1)
    {m n : ℕ} : ∑ i in Ico m n, x ^ i ≤ x ^ m / (1 - x) := by
  rcases le_or_lt m n with (hmn | hmn)
  · rw [geom_sum_Ico' h'x.ne hmn]
    apply div_le_div (pow_nonneg hx _) _ (sub_pos.2 h'x) le_rfl
    simpa using pow_nonneg hx _
  · rw [Ico_eq_empty, sum_empty]
    · apply div_nonneg (pow_nonneg hx _)
      

Proof state:
case inr
α : Type u
inst✝ : LinearOrderedField α
x : α
hx : 0 ≤ x
h'x : x < 1
m n : ℕ
hmn : n < m
⊢ 0 ≤ 1 - x

Next tactic:
simpa using h'x.le
theorem geom_sum_Ico_le_of_lt_one [LinearOrderedField α] {x : α} (hx : 0 ≤ x) (h'x : x < 1)
    {m n : ℕ} : ∑ i in Ico m n, x ^ i ≤ x ^ m / (1 - x) := by
  rcases le_or_lt m n with (hmn | hmn)
  · rw [geom_sum_Ico' h'x.ne hmn]
    apply div_le_div (pow_nonneg hx _) _ (sub_pos.2 h'x) le_rfl
    simpa using pow_nonneg hx _
  · rw [Ico_eq_empty, sum_empty]
    · apply div_nonneg (pow_nonneg hx _)
      simpa using h'x.le
    · 

Proof state:
case inr
α : Type u
inst✝ : LinearOrderedField α
x : α
hx : 0 ≤ x
h'x : x < 1
m n : ℕ
hmn : n < m
⊢ ¬m < n

Next tactic:
simpa using hmn.le
theorem geom_sum_inv [DivisionRing α] {x : α} (hx1 : x ≠ 1) (hx0 : x ≠ 0) (n : ℕ) :
    ∑ i in range n, x⁻¹ ^ i = (x - 1)⁻¹ * (x - x⁻¹ ^ n * x) := by
  

Proof state:
α : Type u
inst✝ : DivisionRing α
x : α
hx1 : x ≠ 1
hx0 : x ≠ 0
n : ℕ
⊢ ∑ i in range n, x⁻¹ ^ i = (x - 1)⁻¹ * (x - x⁻¹ ^ n * x)

Next tactic:
have h₁ : x⁻¹ ≠ 1 := by rwa [inv_eq_one_div, Ne.def, div_eq_iff_mul_eq hx0, one_mul]
theorem geom_sum_inv [DivisionRing α] {x : α} (hx1 : x ≠ 1) (hx0 : x ≠ 0) (n : ℕ) :
    ∑ i in range n, x⁻¹ ^ i = (x - 1)⁻¹ * (x - x⁻¹ ^ n * x) := by
  have h₁ : x⁻¹ ≠ 1 := by 

Proof state:
α : Type u
inst✝ : DivisionRing α
x : α
hx1 : x ≠ 1
hx0 : x ≠ 0
n : ℕ
⊢ x⁻¹ ≠ 1

Next tactic:
rwa [inv_eq_one_div, Ne.def, div_eq_iff_mul_eq hx0, one_mul]
theorem geom_sum_inv [DivisionRing α] {x : α} (hx1 : x ≠ 1) (hx0 : x ≠ 0) (n : ℕ) :
    ∑ i in range n, x⁻¹ ^ i = (x - 1)⁻¹ * (x - x⁻¹ ^ n * x) := by
  have h₁ : x⁻¹ ≠ 1 := by rwa [inv_eq_one_div, Ne.def, div_eq_iff_mul_eq hx0, one_mul]
  

Proof state:
α : Type u
inst✝ : DivisionRing α
x : α
hx1 : x ≠ 1
hx0 : x ≠ 0
n : ℕ
h₁ : x⁻¹ ≠ 1
⊢ ∑ i in range n, x⁻¹ ^ i = (x - 1)⁻¹ * (x - x⁻¹ ^ n * x)

Next tactic:
have h₂ : x⁻¹ - 1 ≠ 0 := mt sub_eq_zero.1 h₁
theorem geom_sum_inv [DivisionRing α] {x : α} (hx1 : x ≠ 1) (hx0 : x ≠ 0) (n : ℕ) :
    ∑ i in range n, x⁻¹ ^ i = (x - 1)⁻¹ * (x - x⁻¹ ^ n * x) := by
  have h₁ : x⁻¹ ≠ 1 := by rwa [inv_eq_one_div, Ne.def, div_eq_iff_mul_eq hx0, one_mul]
  have h₂ : x⁻¹ - 1 ≠ 0 := mt sub_eq_zero.1 h₁
  

Proof state:
α : Type u
inst✝ : DivisionRing α
x : α
hx1 : x ≠ 1
hx0 : x ≠ 0
n : ℕ
h₁ : x⁻¹ ≠ 1
h₂ : x⁻¹ - 1 ≠ 0
⊢ ∑ i in range n, x⁻¹ ^ i = (x - 1)⁻¹ * (x - x⁻¹ ^ n * x)

Next tactic:
have h₃ : x - 1 ≠ 0 := mt sub_eq_zero.1 hx1
theorem geom_sum_inv [DivisionRing α] {x : α} (hx1 : x ≠ 1) (hx0 : x ≠ 0) (n : ℕ) :
    ∑ i in range n, x⁻¹ ^ i = (x - 1)⁻¹ * (x - x⁻¹ ^ n * x) := by
  have h₁ : x⁻¹ ≠ 1 := by rwa [inv_eq_one_div, Ne.def, div_eq_iff_mul_eq hx0, one_mul]
  have h₂ : x⁻¹ - 1 ≠ 0 := mt sub_eq_zero.1 h₁
  have h₃ : x - 1 ≠ 0 := mt sub_eq_zero.1 hx1
  

Proof state:
α : Type u
inst✝ : DivisionRing α
x : α
hx1 : x ≠ 1
hx0 : x ≠ 0
n : ℕ
h₁ : x⁻¹ ≠ 1
h₂ : x⁻¹ - 1 ≠ 0
h₃ : x - 1 ≠ 0
⊢ ∑ i in range n, x⁻¹ ^ i = (x - 1)⁻¹ * (x - x⁻¹ ^ n * x)

Next tactic:
have h₄ : x * (x ^ n)⁻¹ = (x ^ n)⁻¹ * x :=
    Nat.recOn n (by simp) fun n h => by
      rw [pow_succ, mul_inv_rev, ← mul_assoc, h, mul_assoc, mul_inv_cancel hx0, mul_assoc,
        inv_mul_cancel hx0]
theorem geom_sum_inv [DivisionRing α] {x : α} (hx1 : x ≠ 1) (hx0 : x ≠ 0) (n : ℕ) :
    ∑ i in range n, x⁻¹ ^ i = (x - 1)⁻¹ * (x - x⁻¹ ^ n * x) := by
  have h₁ : x⁻¹ ≠ 1 := by rwa [inv_eq_one_div, Ne.def, div_eq_iff_mul_eq hx0, one_mul]
  have h₂ : x⁻¹ - 1 ≠ 0 := mt sub_eq_zero.1 h₁
  have h₃ : x - 1 ≠ 0 := mt sub_eq_zero.1 hx1
  have h₄ : x * (x ^ n)⁻¹ = (x ^ n)⁻¹ * x :=
    Nat.recOn n (by 

Proof state:
α : Type u
inst✝ : DivisionRing α
x : α
hx1 : x ≠ 1
hx0 : x ≠ 0
n : ℕ
h₁ : x⁻¹ ≠ 1
h₂ : x⁻¹ - 1 ≠ 0
h₃ : x - 1 ≠ 0
⊢ x * (x ^ Nat.zero)⁻¹ = (x ^ Nat.zero)⁻¹ * x

Next tactic:
simp
theorem geom_sum_inv [DivisionRing α] {x : α} (hx1 : x ≠ 1) (hx0 : x ≠ 0) (n : ℕ) :
    ∑ i in range n, x⁻¹ ^ i = (x - 1)⁻¹ * (x - x⁻¹ ^ n * x) := by
  have h₁ : x⁻¹ ≠ 1 := by rwa [inv_eq_one_div, Ne.def, div_eq_iff_mul_eq hx0, one_mul]
  have h₂ : x⁻¹ - 1 ≠ 0 := mt sub_eq_zero.1 h₁
  have h₃ : x - 1 ≠ 0 := mt sub_eq_zero.1 hx1
  have h₄ : x * (x ^ n)⁻¹ = (x ^ n)⁻¹ * x :=
    Nat.recOn n (by simp) fun n h => by
      

Proof state:
α : Type u
inst✝ : DivisionRing α
x : α
hx1 : x ≠ 1
hx0 : x ≠ 0
n✝ : ℕ
h₁ : x⁻¹ ≠ 1
h₂ : x⁻¹ - 1 ≠ 0
h₃ : x - 1 ≠ 0
n : ℕ
h : x * (x ^ n)⁻¹ = (x ^ n)⁻¹ * x
⊢ x * (x ^ Nat.succ n)⁻¹ = (x ^ Nat.succ n)⁻¹ * x

Next tactic:
rw [pow_succ, mul_inv_rev, ← mul_assoc, h, mul_assoc, mul_inv_cancel hx0, mul_assoc,
        inv_mul_cancel hx0]
theorem geom_sum_inv [DivisionRing α] {x : α} (hx1 : x ≠ 1) (hx0 : x ≠ 0) (n : ℕ) :
    ∑ i in range n, x⁻¹ ^ i = (x - 1)⁻¹ * (x - x⁻¹ ^ n * x) := by
  have h₁ : x⁻¹ ≠ 1 := by rwa [inv_eq_one_div, Ne.def, div_eq_iff_mul_eq hx0, one_mul]
  have h₂ : x⁻¹ - 1 ≠ 0 := mt sub_eq_zero.1 h₁
  have h₃ : x - 1 ≠ 0 := mt sub_eq_zero.1 hx1
  have h₄ : x * (x ^ n)⁻¹ = (x ^ n)⁻¹ * x :=
    Nat.recOn n (by simp) fun n h => by
      rw [pow_succ, mul_inv_rev, ← mul_assoc, h, mul_assoc, mul_inv_cancel hx0, mul_assoc,
        inv_mul_cancel hx0]
  

Proof state:
α : Type u
inst✝ : DivisionRing α
x : α
hx1 : x ≠ 1
hx0 : x ≠ 0
n : ℕ
h₁ : x⁻¹ ≠ 1
h₂ : x⁻¹ - 1 ≠ 0
h₃ : x - 1 ≠ 0
h₄ : x * (x ^ n)⁻¹ = (x ^ n)⁻¹ * x
⊢ ∑ i in range n, x⁻¹ ^ i = (x - 1)⁻¹ * (x - x⁻¹ ^ n * x)

Next tactic:
rw [geom_sum_eq h₁, div_eq_iff_mul_eq h₂, ← mul_right_inj' h₃, ← mul_assoc, ← mul_assoc,
    mul_inv_cancel h₃]
theorem geom_sum_inv [DivisionRing α] {x : α} (hx1 : x ≠ 1) (hx0 : x ≠ 0) (n : ℕ) :
    ∑ i in range n, x⁻¹ ^ i = (x - 1)⁻¹ * (x - x⁻¹ ^ n * x) := by
  have h₁ : x⁻¹ ≠ 1 := by rwa [inv_eq_one_div, Ne.def, div_eq_iff_mul_eq hx0, one_mul]
  have h₂ : x⁻¹ - 1 ≠ 0 := mt sub_eq_zero.1 h₁
  have h₃ : x - 1 ≠ 0 := mt sub_eq_zero.1 hx1
  have h₄ : x * (x ^ n)⁻¹ = (x ^ n)⁻¹ * x :=
    Nat.recOn n (by simp) fun n h => by
      rw [pow_succ, mul_inv_rev, ← mul_assoc, h, mul_assoc, mul_inv_cancel hx0, mul_assoc,
        inv_mul_cancel hx0]
  rw [geom_sum_eq h₁, div_eq_iff_mul_eq h₂, ← mul_right_inj' h₃, ← mul_assoc, ← mul_assoc,
    mul_inv_cancel h₃]
  

Proof state:
α : Type u
inst✝ : DivisionRing α
x : α
hx1 : x ≠ 1
hx0 : x ≠ 0
n : ℕ
h₁ : x⁻¹ ≠ 1
h₂ : x⁻¹ - 1 ≠ 0
h₃ : x - 1 ≠ 0
h₄ : x * (x ^ n)⁻¹ = (x ^ n)⁻¹ * x
⊢ 1 * (x - x⁻¹ ^ n * x) * (x⁻¹ - 1) = (x - 1) * (x⁻¹ ^ n - 1)

Next tactic:
simp [mul_add, add_mul, mul_inv_cancel hx0, mul_assoc, h₄, sub_eq_add_neg, add_comm,
    add_left_comm]
theorem geom_sum_inv [DivisionRing α] {x : α} (hx1 : x ≠ 1) (hx0 : x ≠ 0) (n : ℕ) :
    ∑ i in range n, x⁻¹ ^ i = (x - 1)⁻¹ * (x - x⁻¹ ^ n * x) := by
  have h₁ : x⁻¹ ≠ 1 := by rwa [inv_eq_one_div, Ne.def, div_eq_iff_mul_eq hx0, one_mul]
  have h₂ : x⁻¹ - 1 ≠ 0 := mt sub_eq_zero.1 h₁
  have h₃ : x - 1 ≠ 0 := mt sub_eq_zero.1 hx1
  have h₄ : x * (x ^ n)⁻¹ = (x ^ n)⁻¹ * x :=
    Nat.recOn n (by simp) fun n h => by
      rw [pow_succ, mul_inv_rev, ← mul_assoc, h, mul_assoc, mul_inv_cancel hx0, mul_assoc,
        inv_mul_cancel hx0]
  rw [geom_sum_eq h₁, div_eq_iff_mul_eq h₂, ← mul_right_inj' h₃, ← mul_assoc, ← mul_assoc,
    mul_inv_cancel h₃]
  simp [mul_add, add_mul, mul_inv_cancel hx0, mul_assoc, h₄, sub_eq_add_neg, add_comm,
    add_left_comm]
  

Proof state:
α : Type u
inst✝ : DivisionRing α
x : α
hx1 : x ≠ 1
hx0 : x ≠ 0
n : ℕ
h₁ : x⁻¹ ≠ 1
h₂ : x⁻¹ - 1 ≠ 0
h₃ : x - 1 ≠ 0
h₄ : x * (x ^ n)⁻¹ = (x ^ n)⁻¹ * x
⊢ (x ^ n)⁻¹ * x + -x + (-(x ^ n)⁻¹ + 1) = -x + ((x ^ n)⁻¹ * x + -(x ^ n)⁻¹ + 1)

Next tactic:
rw [add_comm _ (-x), add_assoc, add_assoc _ _ 1]
theorem RingHom.map_geom_sum [Semiring α] [Semiring β] (x : α) (n : ℕ) (f : α →+* β) :
    f (∑ i in range n, x ^ i) = ∑ i in range n, f x ^ i := by 

Proof state:
α : Type u
β : Type u_1
inst✝¹ : Semiring α
inst✝ : Semiring β
x : α
n : ℕ
f : α →+* β
⊢ f (∑ i in range n, x ^ i) = ∑ i in range n, f x ^ i

Next tactic:
simp [f.map_sum]
theorem RingHom.map_geom_sum₂ [Semiring α] [Semiring β] (x y : α) (n : ℕ) (f : α →+* β) :
    f (∑ i in range n, x ^ i * y ^ (n - 1 - i)) = ∑ i in range n, f x ^ i * f y ^ (n - 1 - i) := by
  

Proof state:
α : Type u
β : Type u_1
inst✝¹ : Semiring α
inst✝ : Semiring β
x y : α
n : ℕ
f : α →+* β
⊢ f (∑ i in range n, x ^ i * y ^ (n - 1 - i)) = ∑ i in range n, f x ^ i * f y ^ (n - 1 - i)

Next tactic:
simp [f.map_sum]
theorem Nat.pred_mul_geom_sum_le (a b n : ℕ) :
    ((b - 1) * ∑ i in range n.succ, a / b ^ i) ≤ a * b - a / b ^ n :=
  calc
    ((b - 1) * ∑ i in range n.succ, a / b ^ i) =
    (∑ i in range n, a / b ^ (i + 1) * b) + a * b - ((∑ i in range n, a / b ^ i) + a / b ^ n) := by
      

Proof state:
α : Type u
β : Type u_1
a b n : ℕ
⊢ (b - 1) * ∑ i in range (succ n), a / b ^ i =
    ∑ i in range n, a / b ^ (i + 1) * b + a * b - (∑ i in range n, a / b ^ i + a / b ^ n)

Next tactic:
rw [tsub_mul, mul_comm, sum_mul, one_mul, sum_range_succ', sum_range_succ, pow_zero,
        Nat.div_one]
theorem Nat.pred_mul_geom_sum_le (a b n : ℕ) :
    ((b - 1) * ∑ i in range n.succ, a / b ^ i) ≤ a * b - a / b ^ n :=
  calc
    ((b - 1) * ∑ i in range n.succ, a / b ^ i) =
    (∑ i in range n, a / b ^ (i + 1) * b) + a * b - ((∑ i in range n, a / b ^ i) + a / b ^ n) := by
      rw [tsub_mul, mul_comm, sum_mul, one_mul, sum_range_succ', sum_range_succ, pow_zero,
        Nat.div_one]
    _ ≤ (∑ i in range n, a / b ^ i) + a * b - ((∑ i in range n, a / b ^ i) + a / b ^ n) := by
      

Proof state:
α : Type u
β : Type u_1
a b n : ℕ
⊢ ∑ i in range n, a / b ^ (i + 1) * b + a * b - (∑ i in range n, a / b ^ i + a / b ^ n) ≤
    ∑ i in range n, a / b ^ i + a * b - (∑ i in range n, a / b ^ i + a / b ^ n)

Next tactic:
refine' tsub_le_tsub_right (add_le_add_right (sum_le_sum fun i _ => _) _) _
theorem Nat.pred_mul_geom_sum_le (a b n : ℕ) :
    ((b - 1) * ∑ i in range n.succ, a / b ^ i) ≤ a * b - a / b ^ n :=
  calc
    ((b - 1) * ∑ i in range n.succ, a / b ^ i) =
    (∑ i in range n, a / b ^ (i + 1) * b) + a * b - ((∑ i in range n, a / b ^ i) + a / b ^ n) := by
      rw [tsub_mul, mul_comm, sum_mul, one_mul, sum_range_succ', sum_range_succ, pow_zero,
        Nat.div_one]
    _ ≤ (∑ i in range n, a / b ^ i) + a * b - ((∑ i in range n, a / b ^ i) + a / b ^ n) := by
      refine' tsub_le_tsub_right (add_le_add_right (sum_le_sum fun i _ => _) _) _
      

Proof state:
α : Type u
β : Type u_1
a b n i : ℕ
x✝ : i ∈ range n
⊢ a / b ^ (i + 1) * b ≤ a / b ^ i

Next tactic:
rw [pow_succ', mul_comm b]
theorem Nat.pred_mul_geom_sum_le (a b n : ℕ) :
    ((b - 1) * ∑ i in range n.succ, a / b ^ i) ≤ a * b - a / b ^ n :=
  calc
    ((b - 1) * ∑ i in range n.succ, a / b ^ i) =
    (∑ i in range n, a / b ^ (i + 1) * b) + a * b - ((∑ i in range n, a / b ^ i) + a / b ^ n) := by
      rw [tsub_mul, mul_comm, sum_mul, one_mul, sum_range_succ', sum_range_succ, pow_zero,
        Nat.div_one]
    _ ≤ (∑ i in range n, a / b ^ i) + a * b - ((∑ i in range n, a / b ^ i) + a / b ^ n) := by
      refine' tsub_le_tsub_right (add_le_add_right (sum_le_sum fun i _ => _) _) _
      rw [pow_succ', mul_comm b]
      

Proof state:
α : Type u
β : Type u_1
a b n i : ℕ
x✝ : i ∈ range n
⊢ a / (b ^ i * b) * b ≤ a / b ^ i

Next tactic:
rw [← Nat.div_div_eq_div_mul]
theorem Nat.pred_mul_geom_sum_le (a b n : ℕ) :
    ((b - 1) * ∑ i in range n.succ, a / b ^ i) ≤ a * b - a / b ^ n :=
  calc
    ((b - 1) * ∑ i in range n.succ, a / b ^ i) =
    (∑ i in range n, a / b ^ (i + 1) * b) + a * b - ((∑ i in range n, a / b ^ i) + a / b ^ n) := by
      rw [tsub_mul, mul_comm, sum_mul, one_mul, sum_range_succ', sum_range_succ, pow_zero,
        Nat.div_one]
    _ ≤ (∑ i in range n, a / b ^ i) + a * b - ((∑ i in range n, a / b ^ i) + a / b ^ n) := by
      refine' tsub_le_tsub_right (add_le_add_right (sum_le_sum fun i _ => _) _) _
      rw [pow_succ', mul_comm b]
      rw [← Nat.div_div_eq_div_mul]
      

Proof state:
α : Type u
β : Type u_1
a b n i : ℕ
x✝ : i ∈ range n
⊢ a / b ^ i / b * b ≤ a / b ^ i

Next tactic:
exact Nat.div_mul_le_self _ _
theorem Nat.geom_sum_le {b : ℕ} (hb : 2 ≤ b) (a n : ℕ) :
    ∑ i in range n, a / b ^ i ≤ a * b / (b - 1) := by
  

Proof state:
α : Type u
β : Type u_1
b : ℕ
hb : 2 ≤ b
a n : ℕ
⊢ ∑ i in range n, a / b ^ i ≤ a * b / (b - 1)

Next tactic:
refine' (Nat.le_div_iff_mul_le <| tsub_pos_of_lt hb).2 _
theorem Nat.geom_sum_le {b : ℕ} (hb : 2 ≤ b) (a n : ℕ) :
    ∑ i in range n, a / b ^ i ≤ a * b / (b - 1) := by
  refine' (Nat.le_div_iff_mul_le <| tsub_pos_of_lt hb).2 _
  

Proof state:
α : Type u
β : Type u_1
b : ℕ
hb : 2 ≤ b
a n : ℕ
⊢ (∑ i in range n, a / b ^ i) * (b - 1) ≤ a * b

Next tactic:
cases' n with n
theorem Nat.geom_sum_le {b : ℕ} (hb : 2 ≤ b) (a n : ℕ) :
    ∑ i in range n, a / b ^ i ≤ a * b / (b - 1) := by
  refine' (Nat.le_div_iff_mul_le <| tsub_pos_of_lt hb).2 _
  cases' n with n
  · 

Proof state:
case zero
α : Type u
β : Type u_1
b : ℕ
hb : 2 ≤ b
a : ℕ
⊢ (∑ i in range zero, a / b ^ i) * (b - 1) ≤ a * b

Next tactic:
rw [sum_range_zero, zero_mul]
theorem Nat.geom_sum_le {b : ℕ} (hb : 2 ≤ b) (a n : ℕ) :
    ∑ i in range n, a / b ^ i ≤ a * b / (b - 1) := by
  refine' (Nat.le_div_iff_mul_le <| tsub_pos_of_lt hb).2 _
  cases' n with n
  · rw [sum_range_zero, zero_mul]
    

Proof state:
case zero
α : Type u
β : Type u_1
b : ℕ
hb : 2 ≤ b
a : ℕ
⊢ 0 ≤ a * b

Next tactic:
exact Nat.zero_le _
theorem Nat.geom_sum_le {b : ℕ} (hb : 2 ≤ b) (a n : ℕ) :
    ∑ i in range n, a / b ^ i ≤ a * b / (b - 1) := by
  refine' (Nat.le_div_iff_mul_le <| tsub_pos_of_lt hb).2 _
  cases' n with n
  · rw [sum_range_zero, zero_mul]
    exact Nat.zero_le _
  

Proof state:
case succ
α : Type u
β : Type u_1
b : ℕ
hb : 2 ≤ b
a n : ℕ
⊢ (∑ i in range (succ n), a / b ^ i) * (b - 1) ≤ a * b

Next tactic:
rw [mul_comm]
theorem Nat.geom_sum_le {b : ℕ} (hb : 2 ≤ b) (a n : ℕ) :
    ∑ i in range n, a / b ^ i ≤ a * b / (b - 1) := by
  refine' (Nat.le_div_iff_mul_le <| tsub_pos_of_lt hb).2 _
  cases' n with n
  · rw [sum_range_zero, zero_mul]
    exact Nat.zero_le _
  rw [mul_comm]
  

Proof state:
case succ
α : Type u
β : Type u_1
b : ℕ
hb : 2 ≤ b
a n : ℕ
⊢ (b - 1) * ∑ i in range (succ n), a / b ^ i ≤ a * b

Next tactic:
exact (Nat.pred_mul_geom_sum_le a b n).trans tsub_le_self
theorem Nat.geom_sum_Ico_le {b : ℕ} (hb : 2 ≤ b) (a n : ℕ) :
    ∑ i in Ico 1 n, a / b ^ i ≤ a / (b - 1) := by
  

Proof state:
α : Type u
β : Type u_1
b : ℕ
hb : 2 ≤ b
a n : ℕ
⊢ ∑ i in Ico 1 n, a / b ^ i ≤ a / (b - 1)

Next tactic:
cases' n with n
theorem Nat.geom_sum_Ico_le {b : ℕ} (hb : 2 ≤ b) (a n : ℕ) :
    ∑ i in Ico 1 n, a / b ^ i ≤ a / (b - 1) := by
  cases' n with n
  · 

Proof state:
case zero
α : Type u
β : Type u_1
b : ℕ
hb : 2 ≤ b
a : ℕ
⊢ ∑ i in Ico 1 zero, a / b ^ i ≤ a / (b - 1)

Next tactic:
rw [zero_eq, Ico_eq_empty_of_le (zero_le_one' ℕ), sum_empty]
theorem Nat.geom_sum_Ico_le {b : ℕ} (hb : 2 ≤ b) (a n : ℕ) :
    ∑ i in Ico 1 n, a / b ^ i ≤ a / (b - 1) := by
  cases' n with n
  · rw [zero_eq, Ico_eq_empty_of_le (zero_le_one' ℕ), sum_empty]
    

Proof state:
case zero
α : Type u
β : Type u_1
b : ℕ
hb : 2 ≤ b
a : ℕ
⊢ 0 ≤ a / (b - 1)

Next tactic:
exact Nat.zero_le _
theorem Nat.geom_sum_Ico_le {b : ℕ} (hb : 2 ≤ b) (a n : ℕ) :
    ∑ i in Ico 1 n, a / b ^ i ≤ a / (b - 1) := by
  cases' n with n
  · rw [zero_eq, Ico_eq_empty_of_le (zero_le_one' ℕ), sum_empty]
    exact Nat.zero_le _
  

Proof state:
case succ
α : Type u
β : Type u_1
b : ℕ
hb : 2 ≤ b
a n : ℕ
⊢ ∑ i in Ico 1 (succ n), a / b ^ i ≤ a / (b - 1)

Next tactic:
rw [← add_le_add_iff_left a]
theorem Nat.geom_sum_Ico_le {b : ℕ} (hb : 2 ≤ b) (a n : ℕ) :
    ∑ i in Ico 1 n, a / b ^ i ≤ a / (b - 1) := by
  cases' n with n
  · rw [zero_eq, Ico_eq_empty_of_le (zero_le_one' ℕ), sum_empty]
    exact Nat.zero_le _
  rw [← add_le_add_iff_left a]
  

Proof state:
case succ
α : Type u
β : Type u_1
b : ℕ
hb : 2 ≤ b
a n : ℕ
⊢ a + ∑ i in Ico 1 (succ n), a / b ^ i ≤ a + a / (b - 1)

Next tactic:
calc
    (a + ∑ i : ℕ in Ico 1 n.succ, a / b ^ i) = a / b ^ 0 + ∑ i : ℕ in Ico 1 n.succ, a / b ^ i := by
      rw [pow_zero, Nat.div_one]
    _ = ∑ i in range n.succ, a / b ^ i := by
      rw [range_eq_Ico, ← Nat.Ico_insert_succ_left (Nat.succ_pos _), sum_insert]
      exact fun h => zero_lt_one.not_le (mem_Ico.1 h).1
    _ ≤ a * b / (b - 1) := Nat.geom_sum_le hb a _
    _ = (a * 1 + a * (b - 1)) / (b - 1) := by
      rw [← mul_add, add_tsub_cancel_of_le (one_le_two.trans hb)]
    _ = a + a / (b - 1) := by rw [mul_one, Nat.add_mul_div_right _ _ (tsub_pos_of_lt hb), add_comm]
theorem Nat.geom_sum_Ico_le {b : ℕ} (hb : 2 ≤ b) (a n : ℕ) :
    ∑ i in Ico 1 n, a / b ^ i ≤ a / (b - 1) := by
  cases' n with n
  · rw [zero_eq, Ico_eq_empty_of_le (zero_le_one' ℕ), sum_empty]
    exact Nat.zero_le _
  rw [← add_le_add_iff_left a]
  calc
    (a + ∑ i : ℕ in Ico 1 n.succ, a / b ^ i) = a / b ^ 0 + ∑ i : ℕ in Ico 1 n.succ, a / b ^ i := by
      

Proof state:
α : Type u
β : Type u_1
b : ℕ
hb : 2 ≤ b
a n : ℕ
⊢ a + ∑ i in Ico 1 (succ n), a / b ^ i = a / b ^ 0 + ∑ i in Ico 1 (succ n), a / b ^ i

Next tactic:
rw [pow_zero, Nat.div_one]
theorem Nat.geom_sum_Ico_le {b : ℕ} (hb : 2 ≤ b) (a n : ℕ) :
    ∑ i in Ico 1 n, a / b ^ i ≤ a / (b - 1) := by
  cases' n with n
  · rw [zero_eq, Ico_eq_empty_of_le (zero_le_one' ℕ), sum_empty]
    exact Nat.zero_le _
  rw [← add_le_add_iff_left a]
  calc
    (a + ∑ i : ℕ in Ico 1 n.succ, a / b ^ i) = a / b ^ 0 + ∑ i : ℕ in Ico 1 n.succ, a / b ^ i := by
      rw [pow_zero, Nat.div_one]
    _ = ∑ i in range n.succ, a / b ^ i := by
      

Proof state:
α : Type u
β : Type u_1
b : ℕ
hb : 2 ≤ b
a n : ℕ
⊢ a / b ^ 0 + ∑ i in Ico 1 (succ n), a / b ^ i = ∑ i in range (succ n), a / b ^ i

Next tactic:
rw [range_eq_Ico, ← Nat.Ico_insert_succ_left (Nat.succ_pos _), sum_insert]
theorem Nat.geom_sum_Ico_le {b : ℕ} (hb : 2 ≤ b) (a n : ℕ) :
    ∑ i in Ico 1 n, a / b ^ i ≤ a / (b - 1) := by
  cases' n with n
  · rw [zero_eq, Ico_eq_empty_of_le (zero_le_one' ℕ), sum_empty]
    exact Nat.zero_le _
  rw [← add_le_add_iff_left a]
  calc
    (a + ∑ i : ℕ in Ico 1 n.succ, a / b ^ i) = a / b ^ 0 + ∑ i : ℕ in Ico 1 n.succ, a / b ^ i := by
      rw [pow_zero, Nat.div_one]
    _ = ∑ i in range n.succ, a / b ^ i := by
      rw [range_eq_Ico, ← Nat.Ico_insert_succ_left (Nat.succ_pos _), sum_insert]
      

Proof state:
α : Type u
β : Type u_1
b : ℕ
hb : 2 ≤ b
a n : ℕ
⊢ 0 ∉ Ico (succ 0) (succ n)

Next tactic:
exact fun h => zero_lt_one.not_le (mem_Ico.1 h).1
theorem Nat.geom_sum_Ico_le {b : ℕ} (hb : 2 ≤ b) (a n : ℕ) :
    ∑ i in Ico 1 n, a / b ^ i ≤ a / (b - 1) := by
  cases' n with n
  · rw [zero_eq, Ico_eq_empty_of_le (zero_le_one' ℕ), sum_empty]
    exact Nat.zero_le _
  rw [← add_le_add_iff_left a]
  calc
    (a + ∑ i : ℕ in Ico 1 n.succ, a / b ^ i) = a / b ^ 0 + ∑ i : ℕ in Ico 1 n.succ, a / b ^ i := by
      rw [pow_zero, Nat.div_one]
    _ = ∑ i in range n.succ, a / b ^ i := by
      rw [range_eq_Ico, ← Nat.Ico_insert_succ_left (Nat.succ_pos _), sum_insert]
      exact fun h => zero_lt_one.not_le (mem_Ico.1 h).1
    _ ≤ a * b / (b - 1) := Nat.geom_sum_le hb a _
    _ = (a * 1 + a * (b - 1)) / (b - 1) := by
      

Proof state:
α : Type u
β : Type u_1
b : ℕ
hb : 2 ≤ b
a n : ℕ
⊢ a * b / (b - 1) = (a * 1 + a * (b - 1)) / (b - 1)

Next tactic:
rw [← mul_add, add_tsub_cancel_of_le (one_le_two.trans hb)]
theorem Nat.geom_sum_Ico_le {b : ℕ} (hb : 2 ≤ b) (a n : ℕ) :
    ∑ i in Ico 1 n, a / b ^ i ≤ a / (b - 1) := by
  cases' n with n
  · rw [zero_eq, Ico_eq_empty_of_le (zero_le_one' ℕ), sum_empty]
    exact Nat.zero_le _
  rw [← add_le_add_iff_left a]
  calc
    (a + ∑ i : ℕ in Ico 1 n.succ, a / b ^ i) = a / b ^ 0 + ∑ i : ℕ in Ico 1 n.succ, a / b ^ i := by
      rw [pow_zero, Nat.div_one]
    _ = ∑ i in range n.succ, a / b ^ i := by
      rw [range_eq_Ico, ← Nat.Ico_insert_succ_left (Nat.succ_pos _), sum_insert]
      exact fun h => zero_lt_one.not_le (mem_Ico.1 h).1
    _ ≤ a * b / (b - 1) := Nat.geom_sum_le hb a _
    _ = (a * 1 + a * (b - 1)) / (b - 1) := by
      rw [← mul_add, add_tsub_cancel_of_le (one_le_two.trans hb)]
    _ = a + a / (b - 1) := by 

Proof state:
α : Type u
β : Type u_1
b : ℕ
hb : 2 ≤ b
a n : ℕ
⊢ (a * 1 + a * (b - 1)) / (b - 1) = a + a / (b - 1)

Next tactic:
rw [mul_one, Nat.add_mul_div_right _ _ (tsub_pos_of_lt hb), add_comm]
theorem geom_sum_pos [StrictOrderedSemiring α] (hx : 0 ≤ x) (hn : n ≠ 0) :
    0 < ∑ i in range n, x ^ i :=
  sum_pos' (fun k _ => pow_nonneg hx _) ⟨0, mem_range.2 hn.bot_lt, by 

Proof state:
α : Type u
β : Type u_1
n : ℕ
x : α
inst✝ : StrictOrderedSemiring α
hx : 0 ≤ x
hn : n ≠ 0
⊢ 0 < x ^ 0

Next tactic:
simp
theorem geom_sum_pos_and_lt_one [StrictOrderedRing α] (hx : x < 0) (hx' : 0 < x + 1) (hn : 1 < n) :
    (0 < ∑ i in range n, x ^ i) ∧ ∑ i in range n, x ^ i < 1 := by
  

Proof state:
α : Type u
β : Type u_1
n : ℕ
x : α
inst✝ : StrictOrderedRing α
hx : x < 0
hx' : 0 < x + 1
hn : 1 < n
⊢ 0 < ∑ i in range n, x ^ i ∧ ∑ i in range n, x ^ i < 1

Next tactic:
refine' Nat.le_induction _ _ n (show 2 ≤ n from hn)
theorem geom_sum_pos_and_lt_one [StrictOrderedRing α] (hx : x < 0) (hx' : 0 < x + 1) (hn : 1 < n) :
    (0 < ∑ i in range n, x ^ i) ∧ ∑ i in range n, x ^ i < 1 := by
  refine' Nat.le_induction _ _ n (show 2 ≤ n from hn)
  · 

Proof state:
case refine'_1
α : Type u
β : Type u_1
n : ℕ
x : α
inst✝ : StrictOrderedRing α
hx : x < 0
hx' : 0 < x + 1
hn : 1 < n
⊢ 0 < ∑ i in range 2, x ^ i ∧ ∑ i in range 2, x ^ i < 1

Next tactic:
rw [geom_sum_two]