l3lab/ntp-mathlib huggingface dataset:
theorem geom_sum_alternating_of_lt_neg_one [StrictOrderedRing α] (hx : x + 1 < 0) (hn : 1 < n) :
    if Even n then (∑ i in range n, x ^ i) < 0 else 1 < ∑ i in range n, x ^ i := by
  have hx0 : x < 0 := ((le_add_iff_nonneg_right _).2 zero_le_one).trans_lt hx
  refine' Nat.le_induction _ _ n (show 2 ≤ n from hn)
  · simp only [geom_sum_two, lt_add_iff_pos_left, ite_true, gt_iff_lt, hx, even_two]
  clear hn
  intro n _ ihn
  simp only [Nat.even_add_one, geom_sum_succ]
  by_cases hn' : Even n
  · rw [if_pos hn'] at ihn
    rw [if_neg, lt_add_iff_pos_left]
    exact mul_pos_of_neg_of_neg hx0 ihn
    exact not_not_intro hn'
  · rw [if_neg hn'] at ihn
    rw [if_pos]
    swap
    · exact hn'
    have := add_lt_add_right (mul_lt_mul_of_neg_left ihn hx0) 1
    rw [mul_one] at this
    

Proof state:
case neg
α : Type u
β : Type u_1
n✝ : ℕ
x : α
inst✝ : StrictOrderedRing α
hx : x + 1 < 0
hx0 : x < 0
n : ℕ
hn✝ : 2 ≤ n
ihn : 1 < ∑ i in range n, x ^ i
hn' : ¬Even n
this : x * ∑ i in range n, x ^ i + 1 < x + 1
⊢ x * ∑ i in range n, x ^ i + 1 < 0

Next tactic:
exact this.trans hx
theorem geom_sum_pos' [LinearOrderedRing α] (hx : 0 < x + 1) (hn : n ≠ 0) :
    0 < ∑ i in range n, x ^ i := by
  

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

Next tactic:
obtain _ | _ | n := n
theorem geom_sum_pos' [LinearOrderedRing α] (hx : 0 < x + 1) (hn : n ≠ 0) :
    0 < ∑ i in range n, x ^ i := by
  obtain _ | _ | n := n
  · 

Proof state:
case zero
α : Type u
β : Type u_1
x : α
inst✝ : LinearOrderedRing α
hx : 0 < x + 1
hn : Nat.zero ≠ 0
⊢ 0 < ∑ i in range Nat.zero, x ^ i

Next tactic:
cases hn rfl
theorem geom_sum_pos' [LinearOrderedRing α] (hx : 0 < x + 1) (hn : n ≠ 0) :
    0 < ∑ i in range n, x ^ i := by
  obtain _ | _ | n := n
  · cases hn rfl
  · 

Proof state:
case succ.zero
α : Type u
β : Type u_1
x : α
inst✝ : LinearOrderedRing α
hx : 0 < x + 1
hn : Nat.succ Nat.zero ≠ 0
⊢ 0 < ∑ i in range (Nat.succ Nat.zero), x ^ i

Next tactic:
simp only [Nat.zero_eq, ← Nat.one_eq_succ_zero, range_one, sum_singleton, pow_zero, zero_lt_one]
theorem geom_sum_pos' [LinearOrderedRing α] (hx : 0 < x + 1) (hn : n ≠ 0) :
    0 < ∑ i in range n, x ^ i := by
  obtain _ | _ | n := n
  · cases hn rfl
  · simp only [Nat.zero_eq, ← Nat.one_eq_succ_zero, range_one, sum_singleton, pow_zero, zero_lt_one]
  

Proof state:
case succ.succ
α : Type u
β : Type u_1
x : α
inst✝ : LinearOrderedRing α
hx : 0 < x + 1
n : ℕ
hn : Nat.succ (Nat.succ n) ≠ 0
⊢ 0 < ∑ i in range (Nat.succ (Nat.succ n)), x ^ i

Next tactic:
obtain hx' | hx' := lt_or_le x 0
theorem geom_sum_pos' [LinearOrderedRing α] (hx : 0 < x + 1) (hn : n ≠ 0) :
    0 < ∑ i in range n, x ^ i := by
  obtain _ | _ | n := n
  · cases hn rfl
  · simp only [Nat.zero_eq, ← Nat.one_eq_succ_zero, range_one, sum_singleton, pow_zero, zero_lt_one]
  obtain hx' | hx' := lt_or_le x 0
  · 

Proof state:
case succ.succ.inl
α : Type u
β : Type u_1
x : α
inst✝ : LinearOrderedRing α
hx : 0 < x + 1
n : ℕ
hn : Nat.succ (Nat.succ n) ≠ 0
hx' : x < 0
⊢ 0 < ∑ i in range (Nat.succ (Nat.succ n)), x ^ i

Next tactic:
exact (geom_sum_pos_and_lt_one hx' hx n.one_lt_succ_succ).1
theorem geom_sum_pos' [LinearOrderedRing α] (hx : 0 < x + 1) (hn : n ≠ 0) :
    0 < ∑ i in range n, x ^ i := by
  obtain _ | _ | n := n
  · cases hn rfl
  · simp only [Nat.zero_eq, ← Nat.one_eq_succ_zero, range_one, sum_singleton, pow_zero, zero_lt_one]
  obtain hx' | hx' := lt_or_le x 0
  · exact (geom_sum_pos_and_lt_one hx' hx n.one_lt_succ_succ).1
  · 

Proof state:
case succ.succ.inr
α : Type u
β : Type u_1
x : α
inst✝ : LinearOrderedRing α
hx : 0 < x + 1
n : ℕ
hn : Nat.succ (Nat.succ n) ≠ 0
hx' : 0 ≤ x
⊢ 0 < ∑ i in range (Nat.succ (Nat.succ n)), x ^ i

Next tactic:
exact geom_sum_pos hx' (by simp only [Nat.succ_ne_zero, Ne.def, not_false_iff])
theorem geom_sum_pos' [LinearOrderedRing α] (hx : 0 < x + 1) (hn : n ≠ 0) :
    0 < ∑ i in range n, x ^ i := by
  obtain _ | _ | n := n
  · cases hn rfl
  · simp only [Nat.zero_eq, ← Nat.one_eq_succ_zero, range_one, sum_singleton, pow_zero, zero_lt_one]
  obtain hx' | hx' := lt_or_le x 0
  · exact (geom_sum_pos_and_lt_one hx' hx n.one_lt_succ_succ).1
  · exact geom_sum_pos hx' (by 

Proof state:
α : Type u
β : Type u_1
x : α
inst✝ : LinearOrderedRing α
hx : 0 < x + 1
n : ℕ
hn : Nat.succ (Nat.succ n) ≠ 0
hx' : 0 ≤ x
⊢ Nat.succ (Nat.succ n) ≠ 0

Next tactic:
simp only [Nat.succ_ne_zero, Ne.def, not_false_iff]
theorem Odd.geom_sum_pos [LinearOrderedRing α] (h : Odd n) : 0 < ∑ i in range n, x ^ i := by
  

Proof state:
α : Type u
β : Type u_1
n : ℕ
x : α
inst✝ : LinearOrderedRing α
h : Odd n
⊢ 0 < ∑ i in range n, x ^ i

Next tactic:
rcases n with (_ | _ | k)
theorem Odd.geom_sum_pos [LinearOrderedRing α] (h : Odd n) : 0 < ∑ i in range n, x ^ i := by
  rcases n with (_ | _ | k)
  · 

Proof state:
case zero
α : Type u
β : Type u_1
x : α
inst✝ : LinearOrderedRing α
h : Odd Nat.zero
⊢ 0 < ∑ i in range Nat.zero, x ^ i

Next tactic:
exact ((show ¬Odd 0 by decide) h).elim
theorem Odd.geom_sum_pos [LinearOrderedRing α] (h : Odd n) : 0 < ∑ i in range n, x ^ i := by
  rcases n with (_ | _ | k)
  · exact ((show ¬Odd 0 by 

Proof state:
α : Type u
β : Type u_1
x : α
inst✝ : LinearOrderedRing α
h : Odd Nat.zero
⊢ ¬Odd 0

Next tactic:
decide
theorem Odd.geom_sum_pos [LinearOrderedRing α] (h : Odd n) : 0 < ∑ i in range n, x ^ i := by
  rcases n with (_ | _ | k)
  · exact ((show ¬Odd 0 by decide) h).elim
  · 

Proof state:
case succ.zero
α : Type u
β : Type u_1
x : α
inst✝ : LinearOrderedRing α
h : Odd (Nat.succ Nat.zero)
⊢ 0 < ∑ i in range (Nat.succ Nat.zero), x ^ i

Next tactic:
simp only [Nat.zero_eq, ← Nat.one_eq_succ_zero, geom_sum_one, zero_lt_one]
theorem Odd.geom_sum_pos [LinearOrderedRing α] (h : Odd n) : 0 < ∑ i in range n, x ^ i := by
  rcases n with (_ | _ | k)
  · exact ((show ¬Odd 0 by decide) h).elim
  · simp only [Nat.zero_eq, ← Nat.one_eq_succ_zero, geom_sum_one, zero_lt_one]
  

Proof state:
case succ.succ
α : Type u
β : Type u_1
x : α
inst✝ : LinearOrderedRing α
k : ℕ
h : Odd (Nat.succ (Nat.succ k))
⊢ 0 < ∑ i in range (Nat.succ (Nat.succ k)), x ^ i

Next tactic:
rw [Nat.odd_iff_not_even] at h
theorem Odd.geom_sum_pos [LinearOrderedRing α] (h : Odd n) : 0 < ∑ i in range n, x ^ i := by
  rcases n with (_ | _ | k)
  · exact ((show ¬Odd 0 by decide) h).elim
  · simp only [Nat.zero_eq, ← Nat.one_eq_succ_zero, geom_sum_one, zero_lt_one]
  rw [Nat.odd_iff_not_even] at h
  

Proof state:
case succ.succ
α : Type u
β : Type u_1
x : α
inst✝ : LinearOrderedRing α
k : ℕ
h : ¬Even (Nat.succ (Nat.succ k))
⊢ 0 < ∑ i in range (Nat.succ (Nat.succ k)), x ^ i

Next tactic:
rcases lt_trichotomy (x + 1) 0 with (hx | hx | hx)
theorem Odd.geom_sum_pos [LinearOrderedRing α] (h : Odd n) : 0 < ∑ i in range n, x ^ i := by
  rcases n with (_ | _ | k)
  · exact ((show ¬Odd 0 by decide) h).elim
  · simp only [Nat.zero_eq, ← Nat.one_eq_succ_zero, geom_sum_one, zero_lt_one]
  rw [Nat.odd_iff_not_even] at h
  rcases lt_trichotomy (x + 1) 0 with (hx | hx | hx)
  · 

Proof state:
case succ.succ.inl
α : Type u
β : Type u_1
x : α
inst✝ : LinearOrderedRing α
k : ℕ
h : ¬Even (Nat.succ (Nat.succ k))
hx : x + 1 < 0
⊢ 0 < ∑ i in range (Nat.succ (Nat.succ k)), x ^ i

Next tactic:
have := geom_sum_alternating_of_lt_neg_one hx k.one_lt_succ_succ
theorem Odd.geom_sum_pos [LinearOrderedRing α] (h : Odd n) : 0 < ∑ i in range n, x ^ i := by
  rcases n with (_ | _ | k)
  · exact ((show ¬Odd 0 by decide) h).elim
  · simp only [Nat.zero_eq, ← Nat.one_eq_succ_zero, geom_sum_one, zero_lt_one]
  rw [Nat.odd_iff_not_even] at h
  rcases lt_trichotomy (x + 1) 0 with (hx | hx | hx)
  · have := geom_sum_alternating_of_lt_neg_one hx k.one_lt_succ_succ
    

Proof state:
case succ.succ.inl
α : Type u
β : Type u_1
x : α
inst✝ : LinearOrderedRing α
k : ℕ
h : ¬Even (Nat.succ (Nat.succ k))
hx : x + 1 < 0
this :
  if Even (Nat.succ (Nat.succ k)) then ∑ i in range (Nat.succ (Nat.succ k)), x ^ i < 0
  else 1 < ∑ i in range (Nat.succ (Nat.succ k)), x ^ i
⊢ 0 < ∑ i in range (Nat.succ (Nat.succ k)), x ^ i

Next tactic:
simp only [h, if_false] at this
theorem Odd.geom_sum_pos [LinearOrderedRing α] (h : Odd n) : 0 < ∑ i in range n, x ^ i := by
  rcases n with (_ | _ | k)
  · exact ((show ¬Odd 0 by decide) h).elim
  · simp only [Nat.zero_eq, ← Nat.one_eq_succ_zero, geom_sum_one, zero_lt_one]
  rw [Nat.odd_iff_not_even] at h
  rcases lt_trichotomy (x + 1) 0 with (hx | hx | hx)
  · have := geom_sum_alternating_of_lt_neg_one hx k.one_lt_succ_succ
    simp only [h, if_false] at this
    

Proof state:
case succ.succ.inl
α : Type u
β : Type u_1
x : α
inst✝ : LinearOrderedRing α
k : ℕ
h : ¬Even (Nat.succ (Nat.succ k))
hx : x + 1 < 0
this : 1 < ∑ i in range (Nat.succ (Nat.succ k)), x ^ i
⊢ 0 < ∑ i in range (Nat.succ (Nat.succ k)), x ^ i

Next tactic:
exact zero_lt_one.trans this
theorem Odd.geom_sum_pos [LinearOrderedRing α] (h : Odd n) : 0 < ∑ i in range n, x ^ i := by
  rcases n with (_ | _ | k)
  · exact ((show ¬Odd 0 by decide) h).elim
  · simp only [Nat.zero_eq, ← Nat.one_eq_succ_zero, geom_sum_one, zero_lt_one]
  rw [Nat.odd_iff_not_even] at h
  rcases lt_trichotomy (x + 1) 0 with (hx | hx | hx)
  · have := geom_sum_alternating_of_lt_neg_one hx k.one_lt_succ_succ
    simp only [h, if_false] at this
    exact zero_lt_one.trans this
  · 

Proof state:
case succ.succ.inr.inl
α : Type u
β : Type u_1
x : α
inst✝ : LinearOrderedRing α
k : ℕ
h : ¬Even (Nat.succ (Nat.succ k))
hx : x + 1 = 0
⊢ 0 < ∑ i in range (Nat.succ (Nat.succ k)), x ^ i

Next tactic:
simp only [eq_neg_of_add_eq_zero_left hx, h, neg_one_geom_sum, if_false, zero_lt_one]
theorem Odd.geom_sum_pos [LinearOrderedRing α] (h : Odd n) : 0 < ∑ i in range n, x ^ i := by
  rcases n with (_ | _ | k)
  · exact ((show ¬Odd 0 by decide) h).elim
  · simp only [Nat.zero_eq, ← Nat.one_eq_succ_zero, geom_sum_one, zero_lt_one]
  rw [Nat.odd_iff_not_even] at h
  rcases lt_trichotomy (x + 1) 0 with (hx | hx | hx)
  · have := geom_sum_alternating_of_lt_neg_one hx k.one_lt_succ_succ
    simp only [h, if_false] at this
    exact zero_lt_one.trans this
  · simp only [eq_neg_of_add_eq_zero_left hx, h, neg_one_geom_sum, if_false, zero_lt_one]
  · 

Proof state:
case succ.succ.inr.inr
α : Type u
β : Type u_1
x : α
inst✝ : LinearOrderedRing α
k : ℕ
h : ¬Even (Nat.succ (Nat.succ k))
hx : 0 < x + 1
⊢ 0 < ∑ i in range (Nat.succ (Nat.succ k)), x ^ i

Next tactic:
exact geom_sum_pos' hx k.succ.succ_ne_zero
theorem geom_sum_pos_iff [LinearOrderedRing α] (hn : n ≠ 0) :
    (0 < ∑ i in range n, x ^ i) ↔ Odd n ∨ 0 < x + 1 := by
  

Proof state:
α : Type u
β : Type u_1
n : ℕ
x : α
inst✝ : LinearOrderedRing α
hn : n ≠ 0
⊢ 0 < ∑ i in range n, x ^ i ↔ Odd n ∨ 0 < x + 1

Next tactic:
refine' ⟨fun h => _, _⟩
theorem geom_sum_pos_iff [LinearOrderedRing α] (hn : n ≠ 0) :
    (0 < ∑ i in range n, x ^ i) ↔ Odd n ∨ 0 < x + 1 := by
  refine' ⟨fun h => _, _⟩
  · 

Proof state:
case refine'_1
α : Type u
β : Type u_1
n : ℕ
x : α
inst✝ : LinearOrderedRing α
hn : n ≠ 0
h : 0 < ∑ i in range n, x ^ i
⊢ Odd n ∨ 0 < x + 1

Next tactic:
rw [or_iff_not_imp_left, ← not_le, ← Nat.even_iff_not_odd]
theorem geom_sum_pos_iff [LinearOrderedRing α] (hn : n ≠ 0) :
    (0 < ∑ i in range n, x ^ i) ↔ Odd n ∨ 0 < x + 1 := by
  refine' ⟨fun h => _, _⟩
  · rw [or_iff_not_imp_left, ← not_le, ← Nat.even_iff_not_odd]
    

Proof state:
case refine'_1
α : Type u
β : Type u_1
n : ℕ
x : α
inst✝ : LinearOrderedRing α
hn : n ≠ 0
h : 0 < ∑ i in range n, x ^ i
⊢ Even n → ¬x + 1 ≤ 0

Next tactic:
refine' fun hn hx => h.not_le _
theorem geom_sum_pos_iff [LinearOrderedRing α] (hn : n ≠ 0) :
    (0 < ∑ i in range n, x ^ i) ↔ Odd n ∨ 0 < x + 1 := by
  refine' ⟨fun h => _, _⟩
  · rw [or_iff_not_imp_left, ← not_le, ← Nat.even_iff_not_odd]
    refine' fun hn hx => h.not_le _
    

Proof state:
case refine'_1
α : Type u
β : Type u_1
n : ℕ
x : α
inst✝ : LinearOrderedRing α
hn✝ : n ≠ 0
h : 0 < ∑ i in range n, x ^ i
hn : Even n
hx : x + 1 ≤ 0
⊢ ∑ i in range n, x ^ i ≤ 0

Next tactic:
simpa [if_pos hn] using geom_sum_alternating_of_le_neg_one hx n
theorem geom_sum_pos_iff [LinearOrderedRing α] (hn : n ≠ 0) :
    (0 < ∑ i in range n, x ^ i) ↔ Odd n ∨ 0 < x + 1 := by
  refine' ⟨fun h => _, _⟩
  · rw [or_iff_not_imp_left, ← not_le, ← Nat.even_iff_not_odd]
    refine' fun hn hx => h.not_le _
    simpa [if_pos hn] using geom_sum_alternating_of_le_neg_one hx n
  · 

Proof state:
case refine'_2
α : Type u
β : Type u_1
n : ℕ
x : α
inst✝ : LinearOrderedRing α
hn : n ≠ 0
⊢ Odd n ∨ 0 < x + 1 → 0 < ∑ i in range n, x ^ i

Next tactic:
rintro (hn | hx')
theorem geom_sum_pos_iff [LinearOrderedRing α] (hn : n ≠ 0) :
    (0 < ∑ i in range n, x ^ i) ↔ Odd n ∨ 0 < x + 1 := by
  refine' ⟨fun h => _, _⟩
  · rw [or_iff_not_imp_left, ← not_le, ← Nat.even_iff_not_odd]
    refine' fun hn hx => h.not_le _
    simpa [if_pos hn] using geom_sum_alternating_of_le_neg_one hx n
  · rintro (hn | hx')
    · 

Proof state:
case refine'_2.inl
α : Type u
β : Type u_1
n : ℕ
x : α
inst✝ : LinearOrderedRing α
hn✝ : n ≠ 0
hn : Odd n
⊢ 0 < ∑ i in range n, x ^ i

Next tactic:
exact hn.geom_sum_pos
theorem geom_sum_pos_iff [LinearOrderedRing α] (hn : n ≠ 0) :
    (0 < ∑ i in range n, x ^ i) ↔ Odd n ∨ 0 < x + 1 := by
  refine' ⟨fun h => _, _⟩
  · rw [or_iff_not_imp_left, ← not_le, ← Nat.even_iff_not_odd]
    refine' fun hn hx => h.not_le _
    simpa [if_pos hn] using geom_sum_alternating_of_le_neg_one hx n
  · rintro (hn | hx')
    · exact hn.geom_sum_pos
    · 

Proof state:
case refine'_2.inr
α : Type u
β : Type u_1
n : ℕ
x : α
inst✝ : LinearOrderedRing α
hn : n ≠ 0
hx' : 0 < x + 1
⊢ 0 < ∑ i in range n, x ^ i

Next tactic:
exact geom_sum_pos' hx' hn
theorem geom_sum_ne_zero [LinearOrderedRing α] (hx : x ≠ -1) (hn : n ≠ 0) :
    ∑ i in range n, x ^ i ≠ 0 := by
  

Proof state:
α : Type u
β : Type u_1
n : ℕ
x : α
inst✝ : LinearOrderedRing α
hx : x ≠ -1
hn : n ≠ 0
⊢ ∑ i in range n, x ^ i ≠ 0

Next tactic:
obtain _ | _ | n := n
theorem geom_sum_ne_zero [LinearOrderedRing α] (hx : x ≠ -1) (hn : n ≠ 0) :
    ∑ i in range n, x ^ i ≠ 0 := by
  obtain _ | _ | n := n
  · 

Proof state:
case zero
α : Type u
β : Type u_1
x : α
inst✝ : LinearOrderedRing α
hx : x ≠ -1
hn : Nat.zero ≠ 0
⊢ ∑ i in range Nat.zero, x ^ i ≠ 0

Next tactic:
cases hn rfl
theorem geom_sum_ne_zero [LinearOrderedRing α] (hx : x ≠ -1) (hn : n ≠ 0) :
    ∑ i in range n, x ^ i ≠ 0 := by
  obtain _ | _ | n := n
  · cases hn rfl
  · 

Proof state:
case succ.zero
α : Type u
β : Type u_1
x : α
inst✝ : LinearOrderedRing α
hx : x ≠ -1
hn : Nat.succ Nat.zero ≠ 0
⊢ ∑ i in range (Nat.succ Nat.zero), x ^ i ≠ 0

Next tactic:
simp only [Nat.zero_eq, ← Nat.one_eq_succ_zero, range_one, sum_singleton, pow_zero, ne_eq,
      one_ne_zero, not_false_iff]
theorem geom_sum_ne_zero [LinearOrderedRing α] (hx : x ≠ -1) (hn : n ≠ 0) :
    ∑ i in range n, x ^ i ≠ 0 := by
  obtain _ | _ | n := n
  · cases hn rfl
  · simp only [Nat.zero_eq, ← Nat.one_eq_succ_zero, range_one, sum_singleton, pow_zero, ne_eq,
      one_ne_zero, not_false_iff]
  

Proof state:
case succ.succ
α : Type u
β : Type u_1
x : α
inst✝ : LinearOrderedRing α
hx : x ≠ -1
n : ℕ
hn : Nat.succ (Nat.succ n) ≠ 0
⊢ ∑ i in range (Nat.succ (Nat.succ n)), x ^ i ≠ 0

Next tactic:
rw [Ne.def, eq_neg_iff_add_eq_zero, ← Ne.def] at hx
theorem geom_sum_ne_zero [LinearOrderedRing α] (hx : x ≠ -1) (hn : n ≠ 0) :
    ∑ i in range n, x ^ i ≠ 0 := by
  obtain _ | _ | n := n
  · cases hn rfl
  · simp only [Nat.zero_eq, ← Nat.one_eq_succ_zero, range_one, sum_singleton, pow_zero, ne_eq,
      one_ne_zero, not_false_iff]
  rw [Ne.def, eq_neg_iff_add_eq_zero, ← Ne.def] at hx
  

Proof state:
case succ.succ
α : Type u
β : Type u_1
x : α
inst✝ : LinearOrderedRing α
hx : x + 1 ≠ 0
n : ℕ
hn : Nat.succ (Nat.succ n) ≠ 0
⊢ ∑ i in range (Nat.succ (Nat.succ n)), x ^ i ≠ 0

Next tactic:
obtain h | h := hx.lt_or_lt
theorem geom_sum_ne_zero [LinearOrderedRing α] (hx : x ≠ -1) (hn : n ≠ 0) :
    ∑ i in range n, x ^ i ≠ 0 := by
  obtain _ | _ | n := n
  · cases hn rfl
  · simp only [Nat.zero_eq, ← Nat.one_eq_succ_zero, range_one, sum_singleton, pow_zero, ne_eq,
      one_ne_zero, not_false_iff]
  rw [Ne.def, eq_neg_iff_add_eq_zero, ← Ne.def] at hx
  obtain h | h := hx.lt_or_lt
  · 

Proof state:
case succ.succ.inl
α : Type u
β : Type u_1
x : α
inst✝ : LinearOrderedRing α
hx : x + 1 ≠ 0
n : ℕ
hn : Nat.succ (Nat.succ n) ≠ 0
h : x + 1 < 0
⊢ ∑ i in range (Nat.succ (Nat.succ n)), x ^ i ≠ 0

Next tactic:
have := geom_sum_alternating_of_lt_neg_one h n.one_lt_succ_succ
theorem geom_sum_ne_zero [LinearOrderedRing α] (hx : x ≠ -1) (hn : n ≠ 0) :
    ∑ i in range n, x ^ i ≠ 0 := by
  obtain _ | _ | n := n
  · cases hn rfl
  · simp only [Nat.zero_eq, ← Nat.one_eq_succ_zero, range_one, sum_singleton, pow_zero, ne_eq,
      one_ne_zero, not_false_iff]
  rw [Ne.def, eq_neg_iff_add_eq_zero, ← Ne.def] at hx
  obtain h | h := hx.lt_or_lt
  · have := geom_sum_alternating_of_lt_neg_one h n.one_lt_succ_succ
    

Proof state:
case succ.succ.inl
α : Type u
β : Type u_1
x : α
inst✝ : LinearOrderedRing α
hx : x + 1 ≠ 0
n : ℕ
hn : Nat.succ (Nat.succ n) ≠ 0
h : x + 1 < 0
this :
  if Even (Nat.succ (Nat.succ n)) then ∑ i in range (Nat.succ (Nat.succ n)), x ^ i < 0
  else 1 < ∑ i in range (Nat.succ (Nat.succ n)), x ^ i
⊢ ∑ i in range (Nat.succ (Nat.succ n)), x ^ i ≠ 0

Next tactic:
split_ifs at this
theorem geom_sum_ne_zero [LinearOrderedRing α] (hx : x ≠ -1) (hn : n ≠ 0) :
    ∑ i in range n, x ^ i ≠ 0 := by
  obtain _ | _ | n := n
  · cases hn rfl
  · simp only [Nat.zero_eq, ← Nat.one_eq_succ_zero, range_one, sum_singleton, pow_zero, ne_eq,
      one_ne_zero, not_false_iff]
  rw [Ne.def, eq_neg_iff_add_eq_zero, ← Ne.def] at hx
  obtain h | h := hx.lt_or_lt
  · have := geom_sum_alternating_of_lt_neg_one h n.one_lt_succ_succ
    split_ifs at this
    · 

Proof state:
case pos
α : Type u
β : Type u_1
x : α
inst✝ : LinearOrderedRing α
hx : x + 1 ≠ 0
n : ℕ
hn : Nat.succ (Nat.succ n) ≠ 0
h : x + 1 < 0
h✝ : Even (Nat.succ (Nat.succ n))
this : ∑ i in range (Nat.succ (Nat.succ n)), x ^ i < 0
⊢ ∑ i in range (Nat.succ (Nat.succ n)), x ^ i ≠ 0

Next tactic:
exact this.ne
theorem geom_sum_ne_zero [LinearOrderedRing α] (hx : x ≠ -1) (hn : n ≠ 0) :
    ∑ i in range n, x ^ i ≠ 0 := by
  obtain _ | _ | n := n
  · cases hn rfl
  · simp only [Nat.zero_eq, ← Nat.one_eq_succ_zero, range_one, sum_singleton, pow_zero, ne_eq,
      one_ne_zero, not_false_iff]
  rw [Ne.def, eq_neg_iff_add_eq_zero, ← Ne.def] at hx
  obtain h | h := hx.lt_or_lt
  · have := geom_sum_alternating_of_lt_neg_one h n.one_lt_succ_succ
    split_ifs at this
    · exact this.ne
    · 

Proof state:
case neg
α : Type u
β : Type u_1
x : α
inst✝ : LinearOrderedRing α
hx : x + 1 ≠ 0
n : ℕ
hn : Nat.succ (Nat.succ n) ≠ 0
h : x + 1 < 0
h✝ : ¬Even (Nat.succ (Nat.succ n))
this : 1 < ∑ i in range (Nat.succ (Nat.succ n)), x ^ i
⊢ ∑ i in range (Nat.succ (Nat.succ n)), x ^ i ≠ 0

Next tactic:
exact (zero_lt_one.trans this).ne'
theorem geom_sum_ne_zero [LinearOrderedRing α] (hx : x ≠ -1) (hn : n ≠ 0) :
    ∑ i in range n, x ^ i ≠ 0 := by
  obtain _ | _ | n := n
  · cases hn rfl
  · simp only [Nat.zero_eq, ← Nat.one_eq_succ_zero, range_one, sum_singleton, pow_zero, ne_eq,
      one_ne_zero, not_false_iff]
  rw [Ne.def, eq_neg_iff_add_eq_zero, ← Ne.def] at hx
  obtain h | h := hx.lt_or_lt
  · have := geom_sum_alternating_of_lt_neg_one h n.one_lt_succ_succ
    split_ifs at this
    · exact this.ne
    · exact (zero_lt_one.trans this).ne'
  · 

Proof state:
case succ.succ.inr
α : Type u
β : Type u_1
x : α
inst✝ : LinearOrderedRing α
hx : x + 1 ≠ 0
n : ℕ
hn : Nat.succ (Nat.succ n) ≠ 0
h : 0 < x + 1
⊢ ∑ i in range (Nat.succ (Nat.succ n)), x ^ i ≠ 0

Next tactic:
exact (geom_sum_pos' h n.succ.succ_ne_zero).ne'
theorem geom_sum_eq_zero_iff_neg_one [LinearOrderedRing α] (hn : n ≠ 0) :
    ∑ i in range n, x ^ i = 0 ↔ x = -1 ∧ Even n := by
  

Proof state:
α : Type u
β : Type u_1
n : ℕ
x : α
inst✝ : LinearOrderedRing α
hn : n ≠ 0
⊢ ∑ i in range n, x ^ i = 0 ↔ x = -1 ∧ Even n

Next tactic:
refine' ⟨fun h => _, @fun ⟨h, hn⟩ => by simp only [h, hn, neg_one_geom_sum, if_true]⟩
theorem geom_sum_eq_zero_iff_neg_one [LinearOrderedRing α] (hn : n ≠ 0) :
    ∑ i in range n, x ^ i = 0 ↔ x = -1 ∧ Even n := by
  refine' ⟨fun h => _, @fun ⟨h, hn⟩ => by 

Proof state:
α : Type u
β : Type u_1
n : ℕ
x : α
inst✝ : LinearOrderedRing α
hn✝ : n ≠ 0
x✝ : x = -1 ∧ Even n
h : x = -1
hn : Even n
⊢ ∑ i in range n, x ^ i = 0

Next tactic:
simp only [h, hn, neg_one_geom_sum, if_true]
theorem geom_sum_eq_zero_iff_neg_one [LinearOrderedRing α] (hn : n ≠ 0) :
    ∑ i in range n, x ^ i = 0 ↔ x = -1 ∧ Even n := by
  refine' ⟨fun h => _, @fun ⟨h, hn⟩ => by simp only [h, hn, neg_one_geom_sum, if_true]⟩
  

Proof state:
α : Type u
β : Type u_1
n : ℕ
x : α
inst✝ : LinearOrderedRing α
hn : n ≠ 0
h : ∑ i in range n, x ^ i = 0
⊢ x = -1 ∧ Even n

Next tactic:
contrapose! h
theorem geom_sum_eq_zero_iff_neg_one [LinearOrderedRing α] (hn : n ≠ 0) :
    ∑ i in range n, x ^ i = 0 ↔ x = -1 ∧ Even n := by
  refine' ⟨fun h => _, @fun ⟨h, hn⟩ => by simp only [h, hn, neg_one_geom_sum, if_true]⟩
  contrapose! h
  

Proof state:
α : Type u
β : Type u_1
n : ℕ
x : α
inst✝ : LinearOrderedRing α
hn : n ≠ 0
h : x = -1 → ¬Even n
⊢ ∑ i in range n, x ^ i ≠ 0

Next tactic:
have hx := eq_or_ne x (-1)
theorem geom_sum_eq_zero_iff_neg_one [LinearOrderedRing α] (hn : n ≠ 0) :
    ∑ i in range n, x ^ i = 0 ↔ x = -1 ∧ Even n := by
  refine' ⟨fun h => _, @fun ⟨h, hn⟩ => by simp only [h, hn, neg_one_geom_sum, if_true]⟩
  contrapose! h
  have hx := eq_or_ne x (-1)
  

Proof state:
α : Type u
β : Type u_1
n : ℕ
x : α
inst✝ : LinearOrderedRing α
hn : n ≠ 0
h : x = -1 → ¬Even n
hx : x = -1 ∨ x ≠ -1
⊢ ∑ i in range n, x ^ i ≠ 0

Next tactic:
cases' hx with hx hx
theorem geom_sum_eq_zero_iff_neg_one [LinearOrderedRing α] (hn : n ≠ 0) :
    ∑ i in range n, x ^ i = 0 ↔ x = -1 ∧ Even n := by
  refine' ⟨fun h => _, @fun ⟨h, hn⟩ => by simp only [h, hn, neg_one_geom_sum, if_true]⟩
  contrapose! h
  have hx := eq_or_ne x (-1)
  cases' hx with hx hx
  · 

Proof state:
case inl
α : Type u
β : Type u_1
n : ℕ
x : α
inst✝ : LinearOrderedRing α
hn : n ≠ 0
h : x = -1 → ¬Even n
hx : x = -1
⊢ ∑ i in range n, x ^ i ≠ 0

Next tactic:
rw [hx, neg_one_geom_sum]
theorem geom_sum_eq_zero_iff_neg_one [LinearOrderedRing α] (hn : n ≠ 0) :
    ∑ i in range n, x ^ i = 0 ↔ x = -1 ∧ Even n := by
  refine' ⟨fun h => _, @fun ⟨h, hn⟩ => by simp only [h, hn, neg_one_geom_sum, if_true]⟩
  contrapose! h
  have hx := eq_or_ne x (-1)
  cases' hx with hx hx
  · rw [hx, neg_one_geom_sum]
    

Proof state:
case inl
α : Type u
β : Type u_1
n : ℕ
x : α
inst✝ : LinearOrderedRing α
hn : n ≠ 0
h : x = -1 → ¬Even n
hx : x = -1
⊢ (if Even n then 0 else 1) ≠ 0

Next tactic:
simp only [h hx, ite_false, ne_eq, one_ne_zero, not_false_eq_true]
theorem geom_sum_eq_zero_iff_neg_one [LinearOrderedRing α] (hn : n ≠ 0) :
    ∑ i in range n, x ^ i = 0 ↔ x = -1 ∧ Even n := by
  refine' ⟨fun h => _, @fun ⟨h, hn⟩ => by simp only [h, hn, neg_one_geom_sum, if_true]⟩
  contrapose! h
  have hx := eq_or_ne x (-1)
  cases' hx with hx hx
  · rw [hx, neg_one_geom_sum]
    simp only [h hx, ite_false, ne_eq, one_ne_zero, not_false_eq_true]
  · 

Proof state:
case inr
α : Type u
β : Type u_1
n : ℕ
x : α
inst✝ : LinearOrderedRing α
hn : n ≠ 0
h : x = -1 → ¬Even n
hx : x ≠ -1
⊢ ∑ i in range n, x ^ i ≠ 0

Next tactic:
exact geom_sum_ne_zero hx hn
theorem geom_sum_neg_iff [LinearOrderedRing α] (hn : n ≠ 0) :
    ∑ i in range n, x ^ i < 0 ↔ Even n ∧ x + 1 < 0 := by
  

Proof state:
α : Type u
β : Type u_1
n : ℕ
x : α
inst✝ : LinearOrderedRing α
hn : n ≠ 0
⊢ ∑ i in range n, x ^ i < 0 ↔ Even n ∧ x + 1 < 0

Next tactic:
rw [← not_iff_not, not_lt, le_iff_lt_or_eq, eq_comm,
    or_congr (geom_sum_pos_iff hn) (geom_sum_eq_zero_iff_neg_one hn), Nat.odd_iff_not_even, ←
    add_eq_zero_iff_eq_neg, not_and, not_lt, le_iff_lt_or_eq, eq_comm, ← imp_iff_not_or, or_comm,
    and_comm, Decidable.and_or_imp, or_comm]
/-- If all the elements of a finset of naturals are less than `n`, then the sum of their powers of
`m ≥ 2` is less than `m ^ n`. -/
lemma Nat.geomSum_eq (hm : 2 ≤ m) (n : ℕ) :
    ∑ k in range n, m ^ k = (m ^ n - 1) / (m - 1) := by
  

Proof state:
α : Type u
β : Type u_1
m n✝ : ℕ
s : Finset ℕ
hm : 2 ≤ m
n : ℕ
⊢ ∑ k in range n, m ^ k = (m ^ n - 1) / (m - 1)

Next tactic:
refine (Nat.div_eq_of_eq_mul_left (tsub_pos_iff_lt.2 hm) $ tsub_eq_of_eq_add ?_).symm