l3lab/ntp-mathlib huggingface dataset:
theorem abs_exp_sub_one_le {x : ℂ} (hx : abs x ≤ 1) : abs (exp x - 1) ≤ 2 * abs x :=
  calc
    abs (exp x - 1) = abs (exp x - ∑ m in range 1, x ^ m / m.factorial) := by simp [sum_range_succ]
    _ ≤ abs x ^ 1 * ((Nat.succ 1 : ℝ) * ((Nat.factorial 1) * (1 : ℕ) : ℝ)⁻¹) :=
      (exp_bound hx (by decide))
    _ = 2 * abs x := by 

Proof state:
x : ℂ
hx : abs x ≤ 1
⊢ abs x ^ 1 * (↑(Nat.succ 1) * (↑(Nat.factorial 1) * ↑1)⁻¹) = 2 * abs x

Next tactic:
simp [two_mul, mul_two, mul_add, mul_comm, add_mul, Nat.factorial]
theorem abs_exp_sub_one_sub_id_le {x : ℂ} (hx : abs x ≤ 1) : abs (exp x - 1 - x) ≤ abs x ^ 2 :=
  calc
    abs (exp x - 1 - x) = abs (exp x - ∑ m in range 2, x ^ m / m.factorial) := by
      

Proof state:
x : ℂ
hx : abs x ≤ 1
⊢ abs (cexp x - 1 - x) = abs (cexp x - ∑ m in range 2, x ^ m / ↑(Nat.factorial m))

Next tactic:
simp [sub_eq_add_neg, sum_range_succ_comm, add_assoc, Nat.factorial]
theorem abs_exp_sub_one_sub_id_le {x : ℂ} (hx : abs x ≤ 1) : abs (exp x - 1 - x) ≤ abs x ^ 2 :=
  calc
    abs (exp x - 1 - x) = abs (exp x - ∑ m in range 2, x ^ m / m.factorial) := by
      simp [sub_eq_add_neg, sum_range_succ_comm, add_assoc, Nat.factorial]
    _ ≤ abs x ^ 2 * ((Nat.succ 2 : ℝ) * (Nat.factorial 2 * (2 : ℕ) : ℝ)⁻¹) :=
      (exp_bound hx (by 

Proof state:
x : ℂ
hx : abs x ≤ 1
⊢ 0 < 2

Next tactic:
decide
theorem abs_exp_sub_one_sub_id_le {x : ℂ} (hx : abs x ≤ 1) : abs (exp x - 1 - x) ≤ abs x ^ 2 :=
  calc
    abs (exp x - 1 - x) = abs (exp x - ∑ m in range 2, x ^ m / m.factorial) := by
      simp [sub_eq_add_neg, sum_range_succ_comm, add_assoc, Nat.factorial]
    _ ≤ abs x ^ 2 * ((Nat.succ 2 : ℝ) * (Nat.factorial 2 * (2 : ℕ) : ℝ)⁻¹) :=
      (exp_bound hx (by decide))
    _ ≤ abs x ^ 2 * 1 := by 

Proof state:
x : ℂ
hx : abs x ≤ 1
⊢ abs x ^ 2 * (↑(Nat.succ 2) * (↑(Nat.factorial 2) * ↑2)⁻¹) ≤ abs x ^ 2 * 1

Next tactic:
gcongr
theorem abs_exp_sub_one_sub_id_le {x : ℂ} (hx : abs x ≤ 1) : abs (exp x - 1 - x) ≤ abs x ^ 2 :=
  calc
    abs (exp x - 1 - x) = abs (exp x - ∑ m in range 2, x ^ m / m.factorial) := by
      simp [sub_eq_add_neg, sum_range_succ_comm, add_assoc, Nat.factorial]
    _ ≤ abs x ^ 2 * ((Nat.succ 2 : ℝ) * (Nat.factorial 2 * (2 : ℕ) : ℝ)⁻¹) :=
      (exp_bound hx (by decide))
    _ ≤ abs x ^ 2 * 1 := by gcongr; 

Proof state:
case h
x : ℂ
hx : abs x ≤ 1
⊢ ↑(Nat.succ 2) * (↑(Nat.factorial 2) * ↑2)⁻¹ ≤ 1

Next tactic:
norm_num [Nat.factorial]
theorem abs_exp_sub_one_sub_id_le {x : ℂ} (hx : abs x ≤ 1) : abs (exp x - 1 - x) ≤ abs x ^ 2 :=
  calc
    abs (exp x - 1 - x) = abs (exp x - ∑ m in range 2, x ^ m / m.factorial) := by
      simp [sub_eq_add_neg, sum_range_succ_comm, add_assoc, Nat.factorial]
    _ ≤ abs x ^ 2 * ((Nat.succ 2 : ℝ) * (Nat.factorial 2 * (2 : ℕ) : ℝ)⁻¹) :=
      (exp_bound hx (by decide))
    _ ≤ abs x ^ 2 * 1 := by gcongr; norm_num [Nat.factorial]
    _ = abs x ^ 2 := by 

Proof state:
x : ℂ
hx : abs x ≤ 1
⊢ abs x ^ 2 * 1 = abs x ^ 2

Next tactic:
rw [mul_one]
nonrec theorem exp_bound {x : ℝ} (hx : |x| ≤ 1) {n : ℕ} (hn : 0 < n) :
    |exp x - ∑ m in range n, x ^ m / m.factorial| ≤ |x| ^ n * (n.succ / (n.factorial * n)) := by
  

Proof state:
x : ℝ
hx : abs' x ≤ 1
n : ℕ
hn : 0 < n
⊢ abs' (rexp x - ∑ m in range n, x ^ m / ↑(Nat.factorial m)) ≤ abs' x ^ n * (↑(Nat.succ n) / (↑(Nat.factorial n) * ↑n))

Next tactic:
have hxc : Complex.abs x ≤ 1 := mod_cast hx
nonrec theorem exp_bound {x : ℝ} (hx : |x| ≤ 1) {n : ℕ} (hn : 0 < n) :
    |exp x - ∑ m in range n, x ^ m / m.factorial| ≤ |x| ^ n * (n.succ / (n.factorial * n)) := by
  have hxc : Complex.abs x ≤ 1 := mod_cast hx
  

Proof state:
x : ℝ
hx : abs' x ≤ 1
n : ℕ
hn : 0 < n
hxc : Complex.abs ↑x ≤ 1
⊢ abs' (rexp x - ∑ m in range n, x ^ m / ↑(Nat.factorial m)) ≤ abs' x ^ n * (↑(Nat.succ n) / (↑(Nat.factorial n) * ↑n))

Next tactic:
convert exp_bound hxc hn using 2
nonrec theorem exp_bound {x : ℝ} (hx : |x| ≤ 1) {n : ℕ} (hn : 0 < n) :
    |exp x - ∑ m in range n, x ^ m / m.factorial| ≤ |x| ^ n * (n.succ / (n.factorial * n)) := by
  have hxc : Complex.abs x ≤ 1 := mod_cast hx
  convert exp_bound hxc hn using 2 <;>
  --Porting note: was `norm_cast`
  

Proof state:
case h.e'_3
x : ℝ
hx : abs' x ≤ 1
n : ℕ
hn : 0 < n
hxc : Complex.abs ↑x ≤ 1
⊢ abs' (rexp x - ∑ m in range n, x ^ m / ↑(Nat.factorial m)) =
    Complex.abs (cexp ↑x - ∑ m in range n, ↑x ^ m / ↑(Nat.factorial m))

Next tactic:
simp only [← abs_ofReal, ← ofReal_sub, ← ofReal_exp, ← ofReal_sum, ← ofReal_pow,
    ← ofReal_div, ← ofReal_nat_cast]
nonrec theorem exp_bound {x : ℝ} (hx : |x| ≤ 1) {n : ℕ} (hn : 0 < n) :
    |exp x - ∑ m in range n, x ^ m / m.factorial| ≤ |x| ^ n * (n.succ / (n.factorial * n)) := by
  have hxc : Complex.abs x ≤ 1 := mod_cast hx
  convert exp_bound hxc hn using 2 <;>
  --Porting note: was `norm_cast`
  

Proof state:
case h.e'_4.h.e'_5
x : ℝ
hx : abs' x ≤ 1
n : ℕ
hn : 0 < n
hxc : Complex.abs ↑x ≤ 1
⊢ abs' x ^ n = Complex.abs ↑x ^ n

Next tactic:
simp only [← abs_ofReal, ← ofReal_sub, ← ofReal_exp, ← ofReal_sum, ← ofReal_pow,
    ← ofReal_div, ← ofReal_nat_cast]
theorem exp_bound' {x : ℝ} (h1 : 0 ≤ x) (h2 : x ≤ 1) {n : ℕ} (hn : 0 < n) :
    Real.exp x ≤ (∑ m in Finset.range n, x ^ m / m.factorial) +
      x ^ n * (n + 1) / (n.factorial * n) := by
  

Proof state:
x : ℝ
h1 : 0 ≤ x
h2 : x ≤ 1
n : ℕ
hn : 0 < n
⊢ rexp x ≤ ∑ m in range n, x ^ m / ↑(Nat.factorial m) + x ^ n * (↑n + 1) / (↑(Nat.factorial n) * ↑n)

Next tactic:
have h3 : |x| = x := by simpa
theorem exp_bound' {x : ℝ} (h1 : 0 ≤ x) (h2 : x ≤ 1) {n : ℕ} (hn : 0 < n) :
    Real.exp x ≤ (∑ m in Finset.range n, x ^ m / m.factorial) +
      x ^ n * (n + 1) / (n.factorial * n) := by
  have h3 : |x| = x := by 

Proof state:
x : ℝ
h1 : 0 ≤ x
h2 : x ≤ 1
n : ℕ
hn : 0 < n
⊢ abs' x = x

Next tactic:
simpa
theorem exp_bound' {x : ℝ} (h1 : 0 ≤ x) (h2 : x ≤ 1) {n : ℕ} (hn : 0 < n) :
    Real.exp x ≤ (∑ m in Finset.range n, x ^ m / m.factorial) +
      x ^ n * (n + 1) / (n.factorial * n) := by
  have h3 : |x| = x := by simpa
  

Proof state:
x : ℝ
h1 : 0 ≤ x
h2 : x ≤ 1
n : ℕ
hn : 0 < n
h3 : abs' x = x
⊢ rexp x ≤ ∑ m in range n, x ^ m / ↑(Nat.factorial m) + x ^ n * (↑n + 1) / (↑(Nat.factorial n) * ↑n)

Next tactic:
have h4 : |x| ≤ 1 := by rwa [h3]
theorem exp_bound' {x : ℝ} (h1 : 0 ≤ x) (h2 : x ≤ 1) {n : ℕ} (hn : 0 < n) :
    Real.exp x ≤ (∑ m in Finset.range n, x ^ m / m.factorial) +
      x ^ n * (n + 1) / (n.factorial * n) := by
  have h3 : |x| = x := by simpa
  have h4 : |x| ≤ 1 := by 

Proof state:
x : ℝ
h1 : 0 ≤ x
h2 : x ≤ 1
n : ℕ
hn : 0 < n
h3 : abs' x = x
⊢ abs' x ≤ 1

Next tactic:
rwa [h3]
theorem exp_bound' {x : ℝ} (h1 : 0 ≤ x) (h2 : x ≤ 1) {n : ℕ} (hn : 0 < n) :
    Real.exp x ≤ (∑ m in Finset.range n, x ^ m / m.factorial) +
      x ^ n * (n + 1) / (n.factorial * n) := by
  have h3 : |x| = x := by simpa
  have h4 : |x| ≤ 1 := by rwa [h3]
  

Proof state:
x : ℝ
h1 : 0 ≤ x
h2 : x ≤ 1
n : ℕ
hn : 0 < n
h3 : abs' x = x
h4 : abs' x ≤ 1
⊢ rexp x ≤ ∑ m in range n, x ^ m / ↑(Nat.factorial m) + x ^ n * (↑n + 1) / (↑(Nat.factorial n) * ↑n)

Next tactic:
have h' := Real.exp_bound h4 hn
theorem exp_bound' {x : ℝ} (h1 : 0 ≤ x) (h2 : x ≤ 1) {n : ℕ} (hn : 0 < n) :
    Real.exp x ≤ (∑ m in Finset.range n, x ^ m / m.factorial) +
      x ^ n * (n + 1) / (n.factorial * n) := by
  have h3 : |x| = x := by simpa
  have h4 : |x| ≤ 1 := by rwa [h3]
  have h' := Real.exp_bound h4 hn
  

Proof state:
x : ℝ
h1 : 0 ≤ x
h2 : x ≤ 1
n : ℕ
hn : 0 < n
h3 : abs' x = x
h4 : abs' x ≤ 1
h' :
  abs' (rexp x - ∑ m in range n, x ^ m / ↑(Nat.factorial m)) ≤ abs' x ^ n * (↑(Nat.succ n) / (↑(Nat.factorial n) * ↑n))
⊢ rexp x ≤ ∑ m in range n, x ^ m / ↑(Nat.factorial m) + x ^ n * (↑n + 1) / (↑(Nat.factorial n) * ↑n)

Next tactic:
rw [h3] at h'
theorem exp_bound' {x : ℝ} (h1 : 0 ≤ x) (h2 : x ≤ 1) {n : ℕ} (hn : 0 < n) :
    Real.exp x ≤ (∑ m in Finset.range n, x ^ m / m.factorial) +
      x ^ n * (n + 1) / (n.factorial * n) := by
  have h3 : |x| = x := by simpa
  have h4 : |x| ≤ 1 := by rwa [h3]
  have h' := Real.exp_bound h4 hn
  rw [h3] at h'
  

Proof state:
x : ℝ
h1 : 0 ≤ x
h2 : x ≤ 1
n : ℕ
hn : 0 < n
h3 : abs' x = x
h4 : abs' x ≤ 1
h' : abs' (rexp x - ∑ m in range n, x ^ m / ↑(Nat.factorial m)) ≤ x ^ n * (↑(Nat.succ n) / (↑(Nat.factorial n) * ↑n))
⊢ rexp x ≤ ∑ m in range n, x ^ m / ↑(Nat.factorial m) + x ^ n * (↑n + 1) / (↑(Nat.factorial n) * ↑n)

Next tactic:
have h'' := (abs_sub_le_iff.1 h').1
theorem exp_bound' {x : ℝ} (h1 : 0 ≤ x) (h2 : x ≤ 1) {n : ℕ} (hn : 0 < n) :
    Real.exp x ≤ (∑ m in Finset.range n, x ^ m / m.factorial) +
      x ^ n * (n + 1) / (n.factorial * n) := by
  have h3 : |x| = x := by simpa
  have h4 : |x| ≤ 1 := by rwa [h3]
  have h' := Real.exp_bound h4 hn
  rw [h3] at h'
  have h'' := (abs_sub_le_iff.1 h').1
  

Proof state:
x : ℝ
h1 : 0 ≤ x
h2 : x ≤ 1
n : ℕ
hn : 0 < n
h3 : abs' x = x
h4 : abs' x ≤ 1
h' : abs' (rexp x - ∑ m in range n, x ^ m / ↑(Nat.factorial m)) ≤ x ^ n * (↑(Nat.succ n) / (↑(Nat.factorial n) * ↑n))
h'' : rexp x - ∑ m in range n, x ^ m / ↑(Nat.factorial m) ≤ x ^ n * (↑(Nat.succ n) / (↑(Nat.factorial n) * ↑n))
⊢ rexp x ≤ ∑ m in range n, x ^ m / ↑(Nat.factorial m) + x ^ n * (↑n + 1) / (↑(Nat.factorial n) * ↑n)

Next tactic:
have t := sub_le_iff_le_add'.1 h''
theorem exp_bound' {x : ℝ} (h1 : 0 ≤ x) (h2 : x ≤ 1) {n : ℕ} (hn : 0 < n) :
    Real.exp x ≤ (∑ m in Finset.range n, x ^ m / m.factorial) +
      x ^ n * (n + 1) / (n.factorial * n) := by
  have h3 : |x| = x := by simpa
  have h4 : |x| ≤ 1 := by rwa [h3]
  have h' := Real.exp_bound h4 hn
  rw [h3] at h'
  have h'' := (abs_sub_le_iff.1 h').1
  have t := sub_le_iff_le_add'.1 h''
  

Proof state:
x : ℝ
h1 : 0 ≤ x
h2 : x ≤ 1
n : ℕ
hn : 0 < n
h3 : abs' x = x
h4 : abs' x ≤ 1
h' : abs' (rexp x - ∑ m in range n, x ^ m / ↑(Nat.factorial m)) ≤ x ^ n * (↑(Nat.succ n) / (↑(Nat.factorial n) * ↑n))
h'' : rexp x - ∑ m in range n, x ^ m / ↑(Nat.factorial m) ≤ x ^ n * (↑(Nat.succ n) / (↑(Nat.factorial n) * ↑n))
t : rexp x ≤ ∑ m in range n, x ^ m / ↑(Nat.factorial m) + x ^ n * (↑(Nat.succ n) / (↑(Nat.factorial n) * ↑n))
⊢ rexp x ≤ ∑ m in range n, x ^ m / ↑(Nat.factorial m) + x ^ n * (↑n + 1) / (↑(Nat.factorial n) * ↑n)

Next tactic:
simpa [mul_div_assoc] using t
theorem abs_exp_sub_one_le {x : ℝ} (hx : |x| ≤ 1) : |exp x - 1| ≤ 2 * |x| := by
  

Proof state:
x : ℝ
hx : abs' x ≤ 1
⊢ abs' (rexp x - 1) ≤ 2 * abs' x

Next tactic:
have : abs' x ≤ 1 := mod_cast hx
theorem abs_exp_sub_one_le {x : ℝ} (hx : |x| ≤ 1) : |exp x - 1| ≤ 2 * |x| := by
  have : abs' x ≤ 1 := mod_cast hx
  --Porting note: was
  --exact_mod_cast Complex.abs_exp_sub_one_le (x := x) this
  

Proof state:
x : ℝ
hx this : abs' x ≤ 1
⊢ abs' (rexp x - 1) ≤ 2 * abs' x

Next tactic:
have := Complex.abs_exp_sub_one_le (x := x) (by simpa using this)
theorem abs_exp_sub_one_le {x : ℝ} (hx : |x| ≤ 1) : |exp x - 1| ≤ 2 * |x| := by
  have : abs' x ≤ 1 := mod_cast hx
  --Porting note: was
  --exact_mod_cast Complex.abs_exp_sub_one_le (x := x) this
  have := Complex.abs_exp_sub_one_le (x := x) (by 

Proof state:
x : ℝ
hx this : abs' x ≤ 1
⊢ Complex.abs ↑x ≤ 1

Next tactic:
simpa using this
theorem abs_exp_sub_one_le {x : ℝ} (hx : |x| ≤ 1) : |exp x - 1| ≤ 2 * |x| := by
  have : abs' x ≤ 1 := mod_cast hx
  --Porting note: was
  --exact_mod_cast Complex.abs_exp_sub_one_le (x := x) this
  have := Complex.abs_exp_sub_one_le (x := x) (by simpa using this)
  

Proof state:
x : ℝ
hx this✝ : abs' x ≤ 1
this : Complex.abs (cexp ↑x - 1) ≤ 2 * Complex.abs ↑x
⊢ abs' (rexp x - 1) ≤ 2 * abs' x

Next tactic:
rw [← ofReal_exp, ← ofReal_one, ← ofReal_sub, abs_ofReal, abs_ofReal] at this
theorem abs_exp_sub_one_le {x : ℝ} (hx : |x| ≤ 1) : |exp x - 1| ≤ 2 * |x| := by
  have : abs' x ≤ 1 := mod_cast hx
  --Porting note: was
  --exact_mod_cast Complex.abs_exp_sub_one_le (x := x) this
  have := Complex.abs_exp_sub_one_le (x := x) (by simpa using this)
  rw [← ofReal_exp, ← ofReal_one, ← ofReal_sub, abs_ofReal, abs_ofReal] at this
  

Proof state:
x : ℝ
hx this✝ : abs' x ≤ 1
this : abs' (rexp x - 1) ≤ 2 * abs' x
⊢ abs' (rexp x - 1) ≤ 2 * abs' x

Next tactic:
exact this
theorem abs_exp_sub_one_sub_id_le {x : ℝ} (hx : |x| ≤ 1) : |exp x - 1 - x| ≤ x ^ 2 := by
  

Proof state:
x : ℝ
hx : abs' x ≤ 1
⊢ abs' (rexp x - 1 - x) ≤ x ^ 2

Next tactic:
rw [← _root_.sq_abs]
theorem abs_exp_sub_one_sub_id_le {x : ℝ} (hx : |x| ≤ 1) : |exp x - 1 - x| ≤ x ^ 2 := by
  rw [← _root_.sq_abs]
  --Porting note: was
  -- exact_mod_cast Complex.abs_exp_sub_one_sub_id_le this
  

Proof state:
x : ℝ
hx : abs' x ≤ 1
⊢ abs' (rexp x - 1 - x) ≤ abs' x ^ 2

Next tactic:
have : Complex.abs x ≤ 1 := mod_cast hx
theorem abs_exp_sub_one_sub_id_le {x : ℝ} (hx : |x| ≤ 1) : |exp x - 1 - x| ≤ x ^ 2 := by
  rw [← _root_.sq_abs]
  --Porting note: was
  -- exact_mod_cast Complex.abs_exp_sub_one_sub_id_le this
  have : Complex.abs x ≤ 1 := mod_cast hx
  

Proof state:
x : ℝ
hx : abs' x ≤ 1
this : Complex.abs ↑x ≤ 1
⊢ abs' (rexp x - 1 - x) ≤ abs' x ^ 2

Next tactic:
have := Complex.abs_exp_sub_one_sub_id_le this
theorem abs_exp_sub_one_sub_id_le {x : ℝ} (hx : |x| ≤ 1) : |exp x - 1 - x| ≤ x ^ 2 := by
  rw [← _root_.sq_abs]
  --Porting note: was
  -- exact_mod_cast Complex.abs_exp_sub_one_sub_id_le this
  have : Complex.abs x ≤ 1 := mod_cast hx
  have := Complex.abs_exp_sub_one_sub_id_le this
  

Proof state:
x : ℝ
hx : abs' x ≤ 1
this✝ : Complex.abs ↑x ≤ 1
this : Complex.abs (cexp ↑x - 1 - ↑x) ≤ Complex.abs ↑x ^ 2
⊢ abs' (rexp x - 1 - x) ≤ abs' x ^ 2

Next tactic:
rw [← ofReal_one, ← ofReal_exp, ← ofReal_sub, ← ofReal_sub, abs_ofReal, abs_ofReal] at this
theorem abs_exp_sub_one_sub_id_le {x : ℝ} (hx : |x| ≤ 1) : |exp x - 1 - x| ≤ x ^ 2 := by
  rw [← _root_.sq_abs]
  --Porting note: was
  -- exact_mod_cast Complex.abs_exp_sub_one_sub_id_le this
  have : Complex.abs x ≤ 1 := mod_cast hx
  have := Complex.abs_exp_sub_one_sub_id_le this
  rw [← ofReal_one, ← ofReal_exp, ← ofReal_sub, ← ofReal_sub, abs_ofReal, abs_ofReal] at this
  

Proof state:
x : ℝ
hx : abs' x ≤ 1
this✝ : Complex.abs ↑x ≤ 1
this : abs' (rexp x - 1 - x) ≤ abs' x ^ 2
⊢ abs' (rexp x - 1 - x) ≤ abs' x ^ 2

Next tactic:
exact this
@[simp]
theorem expNear_zero (x r) : expNear 0 x r = r := by 

Proof state:
x r : ℝ
⊢ expNear 0 x r = r

Next tactic:
simp [expNear]
@[simp]
theorem expNear_succ (n x r) : expNear (n + 1) x r = expNear n x (1 + x / (n + 1) * r) := by
  

Proof state:
n : ℕ
x r : ℝ
⊢ expNear (n + 1) x r = expNear n x (1 + x / (↑n + 1) * r)

Next tactic:
simp [expNear, range_succ, mul_add, add_left_comm, add_assoc, pow_succ, div_eq_mul_inv,
      mul_inv, Nat.factorial]
@[simp]
theorem expNear_succ (n x r) : expNear (n + 1) x r = expNear n x (1 + x / (n + 1) * r) := by
  simp [expNear, range_succ, mul_add, add_left_comm, add_assoc, pow_succ, div_eq_mul_inv,
      mul_inv, Nat.factorial]
  

Proof state:
n : ℕ
x r : ℝ
⊢ x * x ^ n * ((↑(Nat.factorial n))⁻¹ * (↑n + 1)⁻¹) * r = x ^ n * (↑(Nat.factorial n))⁻¹ * (x * (↑n + 1)⁻¹ * r)

Next tactic:
ac_rfl
theorem expNear_sub (n x r₁ r₂) : expNear n x r₁ -
    expNear n x r₂ = x ^ n / n.factorial * (r₁ - r₂) := by
  

Proof state:
n : ℕ
x r₁ r₂ : ℝ
⊢ expNear n x r₁ - expNear n x r₂ = x ^ n / ↑(Nat.factorial n) * (r₁ - r₂)

Next tactic:
simp [expNear, mul_sub]
theorem exp_approx_end (n m : ℕ) (x : ℝ) (e₁ : n + 1 = m) (h : |x| ≤ 1) :
    |exp x - expNear m x 0| ≤ |x| ^ m / m.factorial * ((m + 1) / m) := by
  

Proof state:
n m : ℕ
x : ℝ
e₁ : n + 1 = m
h : abs' x ≤ 1
⊢ abs' (rexp x - expNear m x 0) ≤ abs' x ^ m / ↑(Nat.factorial m) * ((↑m + 1) / ↑m)

Next tactic:
simp only [expNear, mul_zero, add_zero]
theorem exp_approx_end (n m : ℕ) (x : ℝ) (e₁ : n + 1 = m) (h : |x| ≤ 1) :
    |exp x - expNear m x 0| ≤ |x| ^ m / m.factorial * ((m + 1) / m) := by
  simp only [expNear, mul_zero, add_zero]
  

Proof state:
n m : ℕ
x : ℝ
e₁ : n + 1 = m
h : abs' x ≤ 1
⊢ abs' (rexp x - ∑ m in range m, x ^ m / ↑(Nat.factorial m)) ≤ abs' x ^ m / ↑(Nat.factorial m) * ((↑m + 1) / ↑m)

Next tactic:
convert exp_bound (n := m) h ?_ using 1
theorem exp_approx_end (n m : ℕ) (x : ℝ) (e₁ : n + 1 = m) (h : |x| ≤ 1) :
    |exp x - expNear m x 0| ≤ |x| ^ m / m.factorial * ((m + 1) / m) := by
  simp only [expNear, mul_zero, add_zero]
  convert exp_bound (n := m) h ?_ using 1
  

Proof state:
case h.e'_4
n m : ℕ
x : ℝ
e₁ : n + 1 = m
h : abs' x ≤ 1
⊢ abs' x ^ m / ↑(Nat.factorial m) * ((↑m + 1) / ↑m) = abs' x ^ m * (↑(Nat.succ m) / (↑(Nat.factorial m) * ↑m))
n m : ℕ x : ℝ e₁ : n + 1 = m h : abs' x ≤ 1 ⊢ 0 < m

Next tactic:
field_simp [mul_comm]
theorem exp_approx_end (n m : ℕ) (x : ℝ) (e₁ : n + 1 = m) (h : |x| ≤ 1) :
    |exp x - expNear m x 0| ≤ |x| ^ m / m.factorial * ((m + 1) / m) := by
  simp only [expNear, mul_zero, add_zero]
  convert exp_bound (n := m) h ?_ using 1
  field_simp [mul_comm]
  

Proof state:
n m : ℕ
x : ℝ
e₁ : n + 1 = m
h : abs' x ≤ 1
⊢ 0 < m

Next tactic:
linarith
theorem exp_approx_succ {n} {x a₁ b₁ : ℝ} (m : ℕ) (e₁ : n + 1 = m) (a₂ b₂ : ℝ)
    (e : |1 + x / m * a₂ - a₁| ≤ b₁ - |x| / m * b₂)
    (h : |exp x - expNear m x a₂| ≤ |x| ^ m / m.factorial * b₂) :
    |exp x - expNear n x a₁| ≤ |x| ^ n / n.factorial * b₁ := by
  

Proof state:
n : ℕ
x a₁ b₁ : ℝ
m : ℕ
e₁ : n + 1 = m
a₂ b₂ : ℝ
e : abs' (1 + x / ↑m * a₂ - a₁) ≤ b₁ - abs' x / ↑m * b₂
h : abs' (rexp x - expNear m x a₂) ≤ abs' x ^ m / ↑(Nat.factorial m) * b₂
⊢ abs' (rexp x - expNear n x a₁) ≤ abs' x ^ n / ↑(Nat.factorial n) * b₁

Next tactic:
refine' (abs_sub_le _ _ _).trans ((add_le_add_right h _).trans _)
theorem exp_approx_succ {n} {x a₁ b₁ : ℝ} (m : ℕ) (e₁ : n + 1 = m) (a₂ b₂ : ℝ)
    (e : |1 + x / m * a₂ - a₁| ≤ b₁ - |x| / m * b₂)
    (h : |exp x - expNear m x a₂| ≤ |x| ^ m / m.factorial * b₂) :
    |exp x - expNear n x a₁| ≤ |x| ^ n / n.factorial * b₁ := by
  refine' (abs_sub_le _ _ _).trans ((add_le_add_right h _).trans _)
  

Proof state:
n : ℕ
x a₁ b₁ : ℝ
m : ℕ
e₁ : n + 1 = m
a₂ b₂ : ℝ
e : abs' (1 + x / ↑m * a₂ - a₁) ≤ b₁ - abs' x / ↑m * b₂
h : abs' (rexp x - expNear m x a₂) ≤ abs' x ^ m / ↑(Nat.factorial m) * b₂
⊢ abs' x ^ m / ↑(Nat.factorial m) * b₂ + abs' (expNear m x a₂ - expNear n x a₁) ≤ abs' x ^ n / ↑(Nat.factorial n) * b₁

Next tactic:
subst e₁
theorem exp_approx_succ {n} {x a₁ b₁ : ℝ} (m : ℕ) (e₁ : n + 1 = m) (a₂ b₂ : ℝ)
    (e : |1 + x / m * a₂ - a₁| ≤ b₁ - |x| / m * b₂)
    (h : |exp x - expNear m x a₂| ≤ |x| ^ m / m.factorial * b₂) :
    |exp x - expNear n x a₁| ≤ |x| ^ n / n.factorial * b₁ := by
  refine' (abs_sub_le _ _ _).trans ((add_le_add_right h _).trans _)
  subst e₁; 

Proof state:
n : ℕ
x a₁ b₁ a₂ b₂ : ℝ
e : abs' (1 + x / ↑(n + 1) * a₂ - a₁) ≤ b₁ - abs' x / ↑(n + 1) * b₂
h : abs' (rexp x - expNear (n + 1) x a₂) ≤ abs' x ^ (n + 1) / ↑(Nat.factorial (n + 1)) * b₂
⊢ abs' x ^ (n + 1) / ↑(Nat.factorial (n + 1)) * b₂ + abs' (expNear (n + 1) x a₂ - expNear n x a₁) ≤
    abs' x ^ n / ↑(Nat.factorial n) * b₁

Next tactic:
rw [expNear_succ, expNear_sub, abs_mul]
theorem exp_approx_succ {n} {x a₁ b₁ : ℝ} (m : ℕ) (e₁ : n + 1 = m) (a₂ b₂ : ℝ)
    (e : |1 + x / m * a₂ - a₁| ≤ b₁ - |x| / m * b₂)
    (h : |exp x - expNear m x a₂| ≤ |x| ^ m / m.factorial * b₂) :
    |exp x - expNear n x a₁| ≤ |x| ^ n / n.factorial * b₁ := by
  refine' (abs_sub_le _ _ _).trans ((add_le_add_right h _).trans _)
  subst e₁; rw [expNear_succ, expNear_sub, abs_mul]
  

Proof state:
n : ℕ
x a₁ b₁ a₂ b₂ : ℝ
e : abs' (1 + x / ↑(n + 1) * a₂ - a₁) ≤ b₁ - abs' x / ↑(n + 1) * b₂
h : abs' (rexp x - expNear (n + 1) x a₂) ≤ abs' x ^ (n + 1) / ↑(Nat.factorial (n + 1)) * b₂
⊢ abs' x ^ (n + 1) / ↑(Nat.factorial (n + 1)) * b₂ +
      abs' (x ^ n / ↑(Nat.factorial n)) * abs' (1 + x / (↑n + 1) * a₂ - a₁) ≤
    abs' x ^ n / ↑(Nat.factorial n) * b₁

Next tactic:
convert mul_le_mul_of_nonneg_left (a := abs' x ^ n / ↑(Nat.factorial n))
      (le_sub_iff_add_le'.1 e) ?_ using 1
theorem exp_approx_succ {n} {x a₁ b₁ : ℝ} (m : ℕ) (e₁ : n + 1 = m) (a₂ b₂ : ℝ)
    (e : |1 + x / m * a₂ - a₁| ≤ b₁ - |x| / m * b₂)
    (h : |exp x - expNear m x a₂| ≤ |x| ^ m / m.factorial * b₂) :
    |exp x - expNear n x a₁| ≤ |x| ^ n / n.factorial * b₁ := by
  refine' (abs_sub_le _ _ _).trans ((add_le_add_right h _).trans _)
  subst e₁; rw [expNear_succ, expNear_sub, abs_mul]
  convert mul_le_mul_of_nonneg_left (a := abs' x ^ n / ↑(Nat.factorial n))
      (le_sub_iff_add_le'.1 e) ?_ using 1
  · 

Proof state:
case h.e'_3
n : ℕ
x a₁ b₁ a₂ b₂ : ℝ
e : abs' (1 + x / ↑(n + 1) * a₂ - a₁) ≤ b₁ - abs' x / ↑(n + 1) * b₂
h : abs' (rexp x - expNear (n + 1) x a₂) ≤ abs' x ^ (n + 1) / ↑(Nat.factorial (n + 1)) * b₂
⊢ abs' x ^ (n + 1) / ↑(Nat.factorial (n + 1)) * b₂ +
      abs' (x ^ n / ↑(Nat.factorial n)) * abs' (1 + x / (↑n + 1) * a₂ - a₁) =
    abs' x ^ n / ↑(Nat.factorial n) * (abs' x / ↑(n + 1) * b₂ + abs' (1 + x / ↑(n + 1) * a₂ - a₁))

Next tactic:
simp [mul_add, pow_succ', div_eq_mul_inv, abs_mul, abs_inv, ← pow_abs, mul_inv, Nat.factorial]
theorem exp_approx_succ {n} {x a₁ b₁ : ℝ} (m : ℕ) (e₁ : n + 1 = m) (a₂ b₂ : ℝ)
    (e : |1 + x / m * a₂ - a₁| ≤ b₁ - |x| / m * b₂)
    (h : |exp x - expNear m x a₂| ≤ |x| ^ m / m.factorial * b₂) :
    |exp x - expNear n x a₁| ≤ |x| ^ n / n.factorial * b₁ := by
  refine' (abs_sub_le _ _ _).trans ((add_le_add_right h _).trans _)
  subst e₁; rw [expNear_succ, expNear_sub, abs_mul]
  convert mul_le_mul_of_nonneg_left (a := abs' x ^ n / ↑(Nat.factorial n))
      (le_sub_iff_add_le'.1 e) ?_ using 1
  · simp [mul_add, pow_succ', div_eq_mul_inv, abs_mul, abs_inv, ← pow_abs, mul_inv, Nat.factorial]
    

Proof state:
case h.e'_3
n : ℕ
x a₁ b₁ a₂ b₂ : ℝ
e : abs' (1 + x / ↑(n + 1) * a₂ - a₁) ≤ b₁ - abs' x / ↑(n + 1) * b₂
h : abs' (rexp x - expNear (n + 1) x a₂) ≤ abs' x ^ (n + 1) / ↑(Nat.factorial (n + 1)) * b₂
⊢ abs' x ^ n * abs' x * ((↑(Nat.factorial n))⁻¹ * (↑n + 1)⁻¹) * b₂ =
    abs' x ^ n * (↑(Nat.factorial n))⁻¹ * (abs' x * (↑n + 1)⁻¹ * b₂)

Next tactic:
ac_rfl
theorem exp_approx_succ {n} {x a₁ b₁ : ℝ} (m : ℕ) (e₁ : n + 1 = m) (a₂ b₂ : ℝ)
    (e : |1 + x / m * a₂ - a₁| ≤ b₁ - |x| / m * b₂)
    (h : |exp x - expNear m x a₂| ≤ |x| ^ m / m.factorial * b₂) :
    |exp x - expNear n x a₁| ≤ |x| ^ n / n.factorial * b₁ := by
  refine' (abs_sub_le _ _ _).trans ((add_le_add_right h _).trans _)
  subst e₁; rw [expNear_succ, expNear_sub, abs_mul]
  convert mul_le_mul_of_nonneg_left (a := abs' x ^ n / ↑(Nat.factorial n))
      (le_sub_iff_add_le'.1 e) ?_ using 1
  · simp [mul_add, pow_succ', div_eq_mul_inv, abs_mul, abs_inv, ← pow_abs, mul_inv, Nat.factorial]
    ac_rfl
  · 

Proof state:
n : ℕ
x a₁ b₁ a₂ b₂ : ℝ
e : abs' (1 + x / ↑(n + 1) * a₂ - a₁) ≤ b₁ - abs' x / ↑(n + 1) * b₂
h : abs' (rexp x - expNear (n + 1) x a₂) ≤ abs' x ^ (n + 1) / ↑(Nat.factorial (n + 1)) * b₂
⊢ 0 ≤ abs' x ^ n / ↑(Nat.factorial n)

Next tactic:
simp [div_nonneg, abs_nonneg]
theorem exp_approx_end' {n} {x a b : ℝ} (m : ℕ) (e₁ : n + 1 = m) (rm : ℝ) (er : ↑m = rm)
    (h : |x| ≤ 1) (e : |1 - a| ≤ b - |x| / rm * ((rm + 1) / rm)) :
    |exp x - expNear n x a| ≤ |x| ^ n / n.factorial * b := by
  

Proof state:
n : ℕ
x a b : ℝ
m : ℕ
e₁ : n + 1 = m
rm : ℝ
er : ↑m = rm
h : abs' x ≤ 1
e : abs' (1 - a) ≤ b - abs' x / rm * ((rm + 1) / rm)
⊢ abs' (rexp x - expNear n x a) ≤ abs' x ^ n / ↑(Nat.factorial n) * b

Next tactic:
subst er
theorem exp_approx_end' {n} {x a b : ℝ} (m : ℕ) (e₁ : n + 1 = m) (rm : ℝ) (er : ↑m = rm)
    (h : |x| ≤ 1) (e : |1 - a| ≤ b - |x| / rm * ((rm + 1) / rm)) :
    |exp x - expNear n x a| ≤ |x| ^ n / n.factorial * b := by
  subst er
  

Proof state:
n : ℕ
x a b : ℝ
m : ℕ
e₁ : n + 1 = m
h : abs' x ≤ 1
e : abs' (1 - a) ≤ b - abs' x / ↑m * ((↑m + 1) / ↑m)
⊢ abs' (rexp x - expNear n x a) ≤ abs' x ^ n / ↑(Nat.factorial n) * b

Next tactic:
exact exp_approx_succ _ e₁ _ _ (by simpa using e) (exp_approx_end _ _ _ e₁ h)
theorem exp_approx_end' {n} {x a b : ℝ} (m : ℕ) (e₁ : n + 1 = m) (rm : ℝ) (er : ↑m = rm)
    (h : |x| ≤ 1) (e : |1 - a| ≤ b - |x| / rm * ((rm + 1) / rm)) :
    |exp x - expNear n x a| ≤ |x| ^ n / n.factorial * b := by
  subst er
  exact exp_approx_succ _ e₁ _ _ (by 

Proof state:
n : ℕ
x a b : ℝ
m : ℕ
e₁ : n + 1 = m
h : abs' x ≤ 1
e : abs' (1 - a) ≤ b - abs' x / ↑m * ((↑m + 1) / ↑m)
⊢ abs' (1 + x / ↑m * 0 - a) ≤ b - abs' x / ↑m * ((↑m + 1) / ↑m)

Next tactic:
simpa using e
theorem exp_1_approx_succ_eq {n} {a₁ b₁ : ℝ} {m : ℕ} (en : n + 1 = m) {rm : ℝ} (er : ↑m = rm)
    (h : |exp 1 - expNear m 1 ((a₁ - 1) * rm)| ≤ |1| ^ m / m.factorial * (b₁ * rm)) :
    |exp 1 - expNear n 1 a₁| ≤ |1| ^ n / n.factorial * b₁ := by
  

Proof state:
n : ℕ
a₁ b₁ : ℝ
m : ℕ
en : n + 1 = m
rm : ℝ
er : ↑m = rm
h : abs' (rexp 1 - expNear m 1 ((a₁ - 1) * rm)) ≤ abs' 1 ^ m / ↑(Nat.factorial m) * (b₁ * rm)
⊢ abs' (rexp 1 - expNear n 1 a₁) ≤ abs' 1 ^ n / ↑(Nat.factorial n) * b₁

Next tactic:
subst er