[GOAL]
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
n : ℕ
s : Set ℝ
x₀ : ℝ
⊢ taylorWithin f (n + 1) s x₀ =
    taylorWithin f n s x₀ +
      ↑(PolynomialModule.comp (Polynomial.X - ↑Polynomial.C x₀))
        (↑(PolynomialModule.single ℝ (n + 1)) (taylorCoeffWithin f (n + 1) s x₀))
[PROOFSTEP]
dsimp only [taylorWithin]
[GOAL]
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
n : ℕ
s : Set ℝ
x₀ : ℝ
⊢ ∑ k in Finset.range (n + 1 + 1),
      ↑(PolynomialModule.comp (Polynomial.X - ↑Polynomial.C x₀))
        (↑(PolynomialModule.single ℝ k) (taylorCoeffWithin f k s x₀)) =
    ∑ k in Finset.range (n + 1),
        ↑(PolynomialModule.comp (Polynomial.X - ↑Polynomial.C x₀))
          (↑(PolynomialModule.single ℝ k) (taylorCoeffWithin f k s x₀)) +
      ↑(PolynomialModule.comp (Polynomial.X - ↑Polynomial.C x₀))
        (↑(PolynomialModule.single ℝ (n + 1)) (taylorCoeffWithin f (n + 1) s x₀))
[PROOFSTEP]
rw [Finset.sum_range_succ]
[GOAL]
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
n : ℕ
s : Set ℝ
x₀ x : ℝ
⊢ taylorWithinEval f (n + 1) s x₀ x =
    taylorWithinEval f n s x₀ x + (((↑n + 1) * ↑n !)⁻¹ * (x - x₀) ^ (n + 1)) • iteratedDerivWithin (n + 1) f s x₀
[PROOFSTEP]
simp_rw [taylorWithinEval, taylorWithin_succ, LinearMap.map_add, PolynomialModule.comp_eval]
[GOAL]
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
n : ℕ
s : Set ℝ
x₀ x : ℝ
⊢ ↑(PolynomialModule.eval x) (taylorWithin f n s x₀) +
      ↑(PolynomialModule.eval (Polynomial.eval x (Polynomial.X - ↑Polynomial.C x₀)))
        (↑(PolynomialModule.single ℝ (n + 1)) (taylorCoeffWithin f (n + 1) s x₀)) =
    ↑(PolynomialModule.eval x) (taylorWithin f n s x₀) +
      (((↑n + 1) * ↑n !)⁻¹ * (x - x₀) ^ (n + 1)) • iteratedDerivWithin (n + 1) f s x₀
[PROOFSTEP]
congr
[GOAL]
case e_a
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
n : ℕ
s : Set ℝ
x₀ x : ℝ
⊢ ↑(PolynomialModule.eval (Polynomial.eval x (Polynomial.X - ↑Polynomial.C x₀)))
      (↑(PolynomialModule.single ℝ (n + 1)) (taylorCoeffWithin f (n + 1) s x₀)) =
    (((↑n + 1) * ↑n !)⁻¹ * (x - x₀) ^ (n + 1)) • iteratedDerivWithin (n + 1) f s x₀
[PROOFSTEP]
simp only [Polynomial.eval_sub, Polynomial.eval_X, Polynomial.eval_C, PolynomialModule.eval_single, mul_inv_rev]
[GOAL]
case e_a
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
n : ℕ
s : Set ℝ
x₀ x : ℝ
⊢ (x - x₀) ^ (n + 1) • taylorCoeffWithin f (n + 1) s x₀ =
    ((↑n !)⁻¹ * (↑n + 1)⁻¹ * (x - x₀) ^ (n + 1)) • iteratedDerivWithin (n + 1) f s x₀
[PROOFSTEP]
dsimp only [taylorCoeffWithin]
[GOAL]
case e_a
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
n : ℕ
s : Set ℝ
x₀ x : ℝ
⊢ (x - x₀) ^ (n + 1) • (↑(n + 1)!)⁻¹ • iteratedDerivWithin (n + 1) f s x₀ =
    ((↑n !)⁻¹ * (↑n + 1)⁻¹ * (x - x₀) ^ (n + 1)) • iteratedDerivWithin (n + 1) f s x₀
[PROOFSTEP]
rw [← mul_smul, mul_comm, Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, mul_inv_rev]
[GOAL]
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
s : Set ℝ
x₀ x : ℝ
⊢ taylorWithinEval f 0 s x₀ x = f x₀
[PROOFSTEP]
dsimp only [taylorWithinEval]
[GOAL]
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
s : Set ℝ
x₀ x : ℝ
⊢ ↑(PolynomialModule.eval x) (taylorWithin f 0 s x₀) = f x₀
[PROOFSTEP]
dsimp only [taylorWithin]
[GOAL]
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
s : Set ℝ
x₀ x : ℝ
⊢ ↑(PolynomialModule.eval x)
      (∑ k in Finset.range (0 + 1),
        ↑(PolynomialModule.comp (Polynomial.X - ↑Polynomial.C x₀))
          (↑(PolynomialModule.single ℝ k) (taylorCoeffWithin f k s x₀))) =
    f x₀
[PROOFSTEP]
dsimp only [taylorCoeffWithin]
[GOAL]
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
s : Set ℝ
x₀ x : ℝ
⊢ ↑(PolynomialModule.eval x)
      (∑ k in Finset.range (0 + 1),
        ↑(PolynomialModule.comp (Polynomial.X - ↑Polynomial.C x₀))
          (↑(PolynomialModule.single ℝ k) ((↑k !)⁻¹ • iteratedDerivWithin k f s x₀))) =
    f x₀
[PROOFSTEP]
simp
[GOAL]
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
n : ℕ
s : Set ℝ
x₀ : ℝ
⊢ taylorWithinEval f n s x₀ x₀ = f x₀
[PROOFSTEP]
induction' n with k hk
[GOAL]
case zero
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
s : Set ℝ
x₀ : ℝ
⊢ taylorWithinEval f Nat.zero s x₀ x₀ = f x₀
[PROOFSTEP]
exact taylor_within_zero_eval _ _ _ _
[GOAL]
case succ
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
s : Set ℝ
x₀ : ℝ
k : ℕ
hk : taylorWithinEval f k s x₀ x₀ = f x₀
⊢ taylorWithinEval f (Nat.succ k) s x₀ x₀ = f x₀
[PROOFSTEP]
simp [hk]
[GOAL]
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
n : ℕ
s : Set ℝ
x₀ x : ℝ
⊢ taylorWithinEval f n s x₀ x = ∑ k in Finset.range (n + 1), ((↑k !)⁻¹ * (x - x₀) ^ k) • iteratedDerivWithin k f s x₀
[PROOFSTEP]
induction' n with k hk
[GOAL]
case zero
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
s : Set ℝ
x₀ x : ℝ
⊢ taylorWithinEval f Nat.zero s x₀ x =
    ∑ k in Finset.range (Nat.zero + 1), ((↑k !)⁻¹ * (x - x₀) ^ k) • iteratedDerivWithin k f s x₀
[PROOFSTEP]
simp
[GOAL]
case succ
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
s : Set ℝ
x₀ x : ℝ
k : ℕ
hk : taylorWithinEval f k s x₀ x = ∑ k in Finset.range (k + 1), ((↑k !)⁻¹ * (x - x₀) ^ k) • iteratedDerivWithin k f s x₀
⊢ taylorWithinEval f (Nat.succ k) s x₀ x =
    ∑ k in Finset.range (Nat.succ k + 1), ((↑k !)⁻¹ * (x - x₀) ^ k) • iteratedDerivWithin k f s x₀
[PROOFSTEP]
rw [taylorWithinEval_succ, Finset.sum_range_succ, hk]
[GOAL]
case succ
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
s : Set ℝ
x₀ x : ℝ
k : ℕ
hk : taylorWithinEval f k s x₀ x = ∑ k in Finset.range (k + 1), ((↑k !)⁻¹ * (x - x₀) ^ k) • iteratedDerivWithin k f s x₀
⊢ ∑ k in Finset.range (k + 1), ((↑k !)⁻¹ * (x - x₀) ^ k) • iteratedDerivWithin k f s x₀ +
      (((↑k + 1) * ↑k !)⁻¹ * (x - x₀) ^ (k + 1)) • iteratedDerivWithin (k + 1) f s x₀ =
    ∑ x_1 in Finset.range (k + 1), ((↑x_1 !)⁻¹ * (x - x₀) ^ x_1) • iteratedDerivWithin x_1 f s x₀ +
      ((↑(k + 1)!)⁻¹ * (x - x₀) ^ (k + 1)) • iteratedDerivWithin (k + 1) f s x₀
[PROOFSTEP]
simp
[GOAL]
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
x : ℝ
n : ℕ
s : Set ℝ
hs : UniqueDiffOn ℝ s
hf : ContDiffOn ℝ (↑n) f s
⊢ ContinuousOn (fun t => taylorWithinEval f n s t x) s
[PROOFSTEP]
simp_rw [taylor_within_apply]
[GOAL]
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
x : ℝ
n : ℕ
s : Set ℝ
hs : UniqueDiffOn ℝ s
hf : ContDiffOn ℝ (↑n) f s
⊢ ContinuousOn (fun t => ∑ k in Finset.range (n + 1), ((↑k !)⁻¹ * (x - t) ^ k) • iteratedDerivWithin k f s t) s
[PROOFSTEP]
refine' continuousOn_finset_sum (Finset.range (n + 1)) fun i hi => _
[GOAL]
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
x : ℝ
n : ℕ
s : Set ℝ
hs : UniqueDiffOn ℝ s
hf : ContDiffOn ℝ (↑n) f s
i : ℕ
hi : i ∈ Finset.range (n + 1)
⊢ ContinuousOn (fun t => ((↑i !)⁻¹ * (x - t) ^ i) • iteratedDerivWithin i f s t) s
[PROOFSTEP]
refine' (continuousOn_const.mul ((continuousOn_const.sub continuousOn_id).pow _)).smul _
[GOAL]
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
x : ℝ
n : ℕ
s : Set ℝ
hs : UniqueDiffOn ℝ s
hf : ContDiffOn ℝ (↑n) f s
i : ℕ
hi : i ∈ Finset.range (n + 1)
⊢ ContinuousOn (fun t => iteratedDerivWithin i f s t) s
[PROOFSTEP]
rw [contDiffOn_iff_continuousOn_differentiableOn_deriv hs] at hf
[GOAL]
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
x : ℝ
n : ℕ
s : Set ℝ
hs : UniqueDiffOn ℝ s
hf :
  (∀ (m : ℕ), ↑m ≤ ↑n → ContinuousOn (iteratedDerivWithin m f s) s) ∧
    ∀ (m : ℕ), ↑m < ↑n → DifferentiableOn ℝ (iteratedDerivWithin m f s) s
i : ℕ
hi : i ∈ Finset.range (n + 1)
⊢ ContinuousOn (fun t => iteratedDerivWithin i f s t) s
[PROOFSTEP]
cases' hf with hf_left
[GOAL]
case intro
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
x : ℝ
n : ℕ
s : Set ℝ
hs : UniqueDiffOn ℝ s
i : ℕ
hi : i ∈ Finset.range (n + 1)
hf_left : ∀ (m : ℕ), ↑m ≤ ↑n → ContinuousOn (iteratedDerivWithin m f s) s
right✝ : ∀ (m : ℕ), ↑m < ↑n → DifferentiableOn ℝ (iteratedDerivWithin m f s) s
⊢ ContinuousOn (fun t => iteratedDerivWithin i f s t) s
[PROOFSTEP]
specialize hf_left i
[GOAL]
case intro
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
x : ℝ
n : ℕ
s : Set ℝ
hs : UniqueDiffOn ℝ s
i : ℕ
hi : i ∈ Finset.range (n + 1)
right✝ : ∀ (m : ℕ), ↑m < ↑n → DifferentiableOn ℝ (iteratedDerivWithin m f s) s
hf_left : ↑i ≤ ↑n → ContinuousOn (iteratedDerivWithin i f s) s
⊢ ContinuousOn (fun t => iteratedDerivWithin i f s t) s
[PROOFSTEP]
simp only [Finset.mem_range] at hi
[GOAL]
case intro
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
x : ℝ
n : ℕ
s : Set ℝ
hs : UniqueDiffOn ℝ s
i : ℕ
right✝ : ∀ (m : ℕ), ↑m < ↑n → DifferentiableOn ℝ (iteratedDerivWithin m f s) s
hf_left : ↑i ≤ ↑n → ContinuousOn (iteratedDerivWithin i f s) s
hi : i < n + 1
⊢ ContinuousOn (fun t => iteratedDerivWithin i f s t) s
[PROOFSTEP]
refine' hf_left _
[GOAL]
case intro
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
x : ℝ
n : ℕ
s : Set ℝ
hs : UniqueDiffOn ℝ s
i : ℕ
right✝ : ∀ (m : ℕ), ↑m < ↑n → DifferentiableOn ℝ (iteratedDerivWithin m f s) s
hf_left : ↑i ≤ ↑n → ContinuousOn (iteratedDerivWithin i f s) s
hi : i < n + 1
⊢ ↑i ≤ ↑n
[PROOFSTEP]
simp only [WithTop.coe_le_coe, Nat.cast_le, Nat.lt_succ_iff.mp hi]
[GOAL]
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
t x : ℝ
n : ℕ
⊢ HasDerivAt (fun y => (x - y) ^ (n + 1)) (-(↑n + 1) * (x - t) ^ n) t
[PROOFSTEP]
simp_rw [sub_eq_neg_add]
[GOAL]
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
t x : ℝ
n : ℕ
⊢ HasDerivAt (fun y => (-y + x) ^ (n + 1)) (-(↑n + 1) * (-t + x) ^ n) t
[PROOFSTEP]
rw [← neg_one_mul, mul_comm (-1 : ℝ), mul_assoc, mul_comm (-1 : ℝ), ← mul_assoc]
[GOAL]
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
t x : ℝ
n : ℕ
⊢ HasDerivAt (fun y => (-y + x) ^ (n + 1)) ((↑n + 1) * (-t + x) ^ n * -1) t
[PROOFSTEP]
convert HasDerivAt.pow (n + 1) ((hasDerivAt_id t).neg.add_const x)
[GOAL]
case h.e'_7.h.e'_5.h.e'_5
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
t x : ℝ
n : ℕ
⊢ ↑n + 1 = ↑(n + 1)
[PROOFSTEP]
simp only [Nat.cast_add, Nat.cast_one]
[GOAL]
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
x y : ℝ
k : ℕ
s t : Set ℝ
ht : UniqueDiffWithinAt ℝ t y
hs : s ∈ 𝓝[t] y
hf : DifferentiableWithinAt ℝ (iteratedDerivWithin (k + 1) f s) s y
⊢ HasDerivWithinAt (fun z => (((↑k + 1) * ↑k !)⁻¹ * (x - z) ^ (k + 1)) • iteratedDerivWithin (k + 1) f s z)
    ((((↑k + 1) * ↑k !)⁻¹ * (x - y) ^ (k + 1)) • iteratedDerivWithin (k + 2) f s y -
      ((↑k !)⁻¹ * (x - y) ^ k) • iteratedDerivWithin (k + 1) f s y)
    t y
[PROOFSTEP]
replace hf : HasDerivWithinAt (iteratedDerivWithin (k + 1) f s) (iteratedDerivWithin (k + 2) f s y) t y :=
  by
  convert (hf.mono_of_mem hs).hasDerivWithinAt using 1
  rw [iteratedDerivWithin_succ (ht.mono_nhds (nhdsWithin_le_iff.mpr hs))]
  exact (derivWithin_of_mem hs ht hf).symm
[GOAL]
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
x y : ℝ
k : ℕ
s t : Set ℝ
ht : UniqueDiffWithinAt ℝ t y
hs : s ∈ 𝓝[t] y
hf : DifferentiableWithinAt ℝ (iteratedDerivWithin (k + 1) f s) s y
⊢ HasDerivWithinAt (iteratedDerivWithin (k + 1) f s) (iteratedDerivWithin (k + 2) f s y) t y
[PROOFSTEP]
convert (hf.mono_of_mem hs).hasDerivWithinAt using 1
[GOAL]
case h.e'_7
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
x y : ℝ
k : ℕ
s t : Set ℝ
ht : UniqueDiffWithinAt ℝ t y
hs : s ∈ 𝓝[t] y
hf : DifferentiableWithinAt ℝ (iteratedDerivWithin (k + 1) f s) s y
⊢ iteratedDerivWithin (k + 2) f s y = derivWithin (iteratedDerivWithin (k + 1) f s) t y
[PROOFSTEP]
rw [iteratedDerivWithin_succ (ht.mono_nhds (nhdsWithin_le_iff.mpr hs))]
[GOAL]
case h.e'_7
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
x y : ℝ
k : ℕ
s t : Set ℝ
ht : UniqueDiffWithinAt ℝ t y
hs : s ∈ 𝓝[t] y
hf : DifferentiableWithinAt ℝ (iteratedDerivWithin (k + 1) f s) s y
⊢ derivWithin (iteratedDerivWithin (k + 1) f s) s y = derivWithin (iteratedDerivWithin (k + 1) f s) t y
[PROOFSTEP]
exact (derivWithin_of_mem hs ht hf).symm
[GOAL]
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
x y : ℝ
k : ℕ
s t : Set ℝ
ht : UniqueDiffWithinAt ℝ t y
hs : s ∈ 𝓝[t] y
hf : HasDerivWithinAt (iteratedDerivWithin (k + 1) f s) (iteratedDerivWithin (k + 2) f s y) t y
⊢ HasDerivWithinAt (fun z => (((↑k + 1) * ↑k !)⁻¹ * (x - z) ^ (k + 1)) • iteratedDerivWithin (k + 1) f s z)
    ((((↑k + 1) * ↑k !)⁻¹ * (x - y) ^ (k + 1)) • iteratedDerivWithin (k + 2) f s y -
      ((↑k !)⁻¹ * (x - y) ^ k) • iteratedDerivWithin (k + 1) f s y)
    t y
[PROOFSTEP]
have : HasDerivWithinAt (fun t => ((k + 1 : ℝ) * k !)⁻¹ * (x - t) ^ (k + 1)) (-((k ! : ℝ)⁻¹ * (x - y) ^ k)) t y := by
  -- Commuting the factors:
  have : -((k ! : ℝ)⁻¹ * (x - y) ^ k) = ((k + 1 : ℝ) * k !)⁻¹ * (-(k + 1) * (x - y) ^ k) :=
    by
    field_simp [k.factorial_ne_zero]
      -- Porting note: was `ring_nf`
    rw [mul_div_mul_right, ← neg_add_rev, neg_mul, neg_div, mul_div_cancel_left]
    · exact k.cast_add_one_ne_zero
    · simp [k.factorial_ne_zero]
  rw [this]
  exact (monomial_has_deriv_aux y x _).hasDerivWithinAt.const_mul _
[GOAL]
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
x y : ℝ
k : ℕ
s t : Set ℝ
ht : UniqueDiffWithinAt ℝ t y
hs : s ∈ 𝓝[t] y
hf : HasDerivWithinAt (iteratedDerivWithin (k + 1) f s) (iteratedDerivWithin (k + 2) f s y) t y
⊢ HasDerivWithinAt (fun t => ((↑k + 1) * ↑k !)⁻¹ * (x - t) ^ (k + 1)) (-((↑k !)⁻¹ * (x - y) ^ k)) t y
[PROOFSTEP]
have : -((k ! : ℝ)⁻¹ * (x - y) ^ k) = ((k + 1 : ℝ) * k !)⁻¹ * (-(k + 1) * (x - y) ^ k) :=
  by
  field_simp [k.factorial_ne_zero]
    -- Porting note: was `ring_nf`
  rw [mul_div_mul_right, ← neg_add_rev, neg_mul, neg_div, mul_div_cancel_left]
  · exact k.cast_add_one_ne_zero
  · simp [k.factorial_ne_zero]
[GOAL]
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
x y : ℝ
k : ℕ
s t : Set ℝ
ht : UniqueDiffWithinAt ℝ t y
hs : s ∈ 𝓝[t] y
hf : HasDerivWithinAt (iteratedDerivWithin (k + 1) f s) (iteratedDerivWithin (k + 2) f s y) t y
⊢ -((↑k !)⁻¹ * (x - y) ^ k) = ((↑k + 1) * ↑k !)⁻¹ * (-(↑k + 1) * (x - y) ^ k)
[PROOFSTEP]
field_simp [k.factorial_ne_zero]
  -- Porting note: was `ring_nf`
[GOAL]
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
x y : ℝ
k : ℕ
s t : Set ℝ
ht : UniqueDiffWithinAt ℝ t y
hs : s ∈ 𝓝[t] y
hf : HasDerivWithinAt (iteratedDerivWithin (k + 1) f s) (iteratedDerivWithin (k + 2) f s y) t y
⊢ -(x - y) ^ k = (-1 + -↑k) * (x - y) ^ k * ↑k ! / ((↑k + 1) * ↑k !)
[PROOFSTEP]
rw [mul_div_mul_right, ← neg_add_rev, neg_mul, neg_div, mul_div_cancel_left]
[GOAL]
case ha
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
x y : ℝ
k : ℕ
s t : Set ℝ
ht : UniqueDiffWithinAt ℝ t y
hs : s ∈ 𝓝[t] y
hf : HasDerivWithinAt (iteratedDerivWithin (k + 1) f s) (iteratedDerivWithin (k + 2) f s y) t y
⊢ ↑k + 1 ≠ 0
[PROOFSTEP]
exact k.cast_add_one_ne_zero
[GOAL]
case hc
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
x y : ℝ
k : ℕ
s t : Set ℝ
ht : UniqueDiffWithinAt ℝ t y
hs : s ∈ 𝓝[t] y
hf : HasDerivWithinAt (iteratedDerivWithin (k + 1) f s) (iteratedDerivWithin (k + 2) f s y) t y
⊢ ↑k ! ≠ 0
[PROOFSTEP]
simp [k.factorial_ne_zero]
[GOAL]
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
x y : ℝ
k : ℕ
s t : Set ℝ
ht : UniqueDiffWithinAt ℝ t y
hs : s ∈ 𝓝[t] y
hf : HasDerivWithinAt (iteratedDerivWithin (k + 1) f s) (iteratedDerivWithin (k + 2) f s y) t y
this : -((↑k !)⁻¹ * (x - y) ^ k) = ((↑k + 1) * ↑k !)⁻¹ * (-(↑k + 1) * (x - y) ^ k)
⊢ HasDerivWithinAt (fun t => ((↑k + 1) * ↑k !)⁻¹ * (x - t) ^ (k + 1)) (-((↑k !)⁻¹ * (x - y) ^ k)) t y
[PROOFSTEP]
rw [this]
[GOAL]
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
x y : ℝ
k : ℕ
s t : Set ℝ
ht : UniqueDiffWithinAt ℝ t y
hs : s ∈ 𝓝[t] y
hf : HasDerivWithinAt (iteratedDerivWithin (k + 1) f s) (iteratedDerivWithin (k + 2) f s y) t y
this : -((↑k !)⁻¹ * (x - y) ^ k) = ((↑k + 1) * ↑k !)⁻¹ * (-(↑k + 1) * (x - y) ^ k)
⊢ HasDerivWithinAt (fun t => ((↑k + 1) * ↑k !)⁻¹ * (x - t) ^ (k + 1)) (((↑k + 1) * ↑k !)⁻¹ * (-(↑k + 1) * (x - y) ^ k))
    t y
[PROOFSTEP]
exact (monomial_has_deriv_aux y x _).hasDerivWithinAt.const_mul _
[GOAL]
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
x y : ℝ
k : ℕ
s t : Set ℝ
ht : UniqueDiffWithinAt ℝ t y
hs : s ∈ 𝓝[t] y
hf : HasDerivWithinAt (iteratedDerivWithin (k + 1) f s) (iteratedDerivWithin (k + 2) f s y) t y
this : HasDerivWithinAt (fun t => ((↑k + 1) * ↑k !)⁻¹ * (x - t) ^ (k + 1)) (-((↑k !)⁻¹ * (x - y) ^ k)) t y
⊢ HasDerivWithinAt (fun z => (((↑k + 1) * ↑k !)⁻¹ * (x - z) ^ (k + 1)) • iteratedDerivWithin (k + 1) f s z)
    ((((↑k + 1) * ↑k !)⁻¹ * (x - y) ^ (k + 1)) • iteratedDerivWithin (k + 2) f s y -
      ((↑k !)⁻¹ * (x - y) ^ k) • iteratedDerivWithin (k + 1) f s y)
    t y
[PROOFSTEP]
convert this.smul hf using 1
[GOAL]
case h.e'_7
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
x y : ℝ
k : ℕ
s t : Set ℝ
ht : UniqueDiffWithinAt ℝ t y
hs : s ∈ 𝓝[t] y
hf : HasDerivWithinAt (iteratedDerivWithin (k + 1) f s) (iteratedDerivWithin (k + 2) f s y) t y
this : HasDerivWithinAt (fun t => ((↑k + 1) * ↑k !)⁻¹ * (x - t) ^ (k + 1)) (-((↑k !)⁻¹ * (x - y) ^ k)) t y
⊢ (((↑k + 1) * ↑k !)⁻¹ * (x - y) ^ (k + 1)) • iteratedDerivWithin (k + 2) f s y -
      ((↑k !)⁻¹ * (x - y) ^ k) • iteratedDerivWithin (k + 1) f s y =
    (((↑k + 1) * ↑k !)⁻¹ * (x - y) ^ (k + 1)) • iteratedDerivWithin (k + 2) f s y +
      -((↑k !)⁻¹ * (x - y) ^ k) • iteratedDerivWithin (k + 1) f s y
[PROOFSTEP]
field_simp [Nat.cast_add_one_ne_zero k, Nat.factorial_ne_zero k]
[GOAL]
case h.e'_7
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
x y : ℝ
k : ℕ
s t : Set ℝ
ht : UniqueDiffWithinAt ℝ t y
hs : s ∈ 𝓝[t] y
hf : HasDerivWithinAt (iteratedDerivWithin (k + 1) f s) (iteratedDerivWithin (k + 2) f s y) t y
this : HasDerivWithinAt (fun t => ((↑k + 1) * ↑k !)⁻¹ * (x - t) ^ (k + 1)) (-((↑k !)⁻¹ * (x - y) ^ k)) t y
⊢ ((x - y) ^ (k + 1) / ((↑k + 1) * ↑k !)) • iteratedDerivWithin (k + 2) f s y -
      ((x - y) ^ k / ↑k !) • iteratedDerivWithin (k + 1) f s y =
    ((x - y) ^ (k + 1) / ((↑k + 1) * ↑k !)) • iteratedDerivWithin (k + 2) f s y +
      (-(x - y) ^ k / ↑k !) • iteratedDerivWithin (k + 1) f s y
[PROOFSTEP]
rw [neg_div, neg_smul, sub_eq_add_neg]
[GOAL]
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
x y : ℝ
n : ℕ
s s' : Set ℝ
hs'_unique : UniqueDiffWithinAt ℝ s' y
hs_unique : UniqueDiffOn ℝ s
hs' : s' ∈ 𝓝[s] y
hy : y ∈ s'
h : s' ⊆ s
hf : ContDiffOn ℝ (↑n) f s
hf' : DifferentiableWithinAt ℝ (iteratedDerivWithin n f s) s y
⊢ HasDerivWithinAt (fun t => taylorWithinEval f n s t x) (((↑n !)⁻¹ * (x - y) ^ n) • iteratedDerivWithin (n + 1) f s y)
    s' y
[PROOFSTEP]
induction' n with k hk
[GOAL]
case zero
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
x y : ℝ
n : ℕ
s s' : Set ℝ
hs'_unique : UniqueDiffWithinAt ℝ s' y
hs_unique : UniqueDiffOn ℝ s
hs' : s' ∈ 𝓝[s] y
hy : y ∈ s'
h : s' ⊆ s
hf✝ : ContDiffOn ℝ (↑n) f s
hf'✝ : DifferentiableWithinAt ℝ (iteratedDerivWithin n f s) s y
hf : ContDiffOn ℝ (↑Nat.zero) f s
hf' : DifferentiableWithinAt ℝ (iteratedDerivWithin Nat.zero f s) s y
⊢ HasDerivWithinAt (fun t => taylorWithinEval f Nat.zero s t x)
    (((↑Nat.zero !)⁻¹ * (x - y) ^ Nat.zero) • iteratedDerivWithin (Nat.zero + 1) f s y) s' y
[PROOFSTEP]
simp only [taylor_within_zero_eval, Nat.factorial_zero, Nat.cast_one, inv_one, pow_zero, mul_one, zero_add, one_smul]
[GOAL]
case zero
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
x y : ℝ
n : ℕ
s s' : Set ℝ
hs'_unique : UniqueDiffWithinAt ℝ s' y
hs_unique : UniqueDiffOn ℝ s
hs' : s' ∈ 𝓝[s] y
hy : y ∈ s'
h : s' ⊆ s
hf✝ : ContDiffOn ℝ (↑n) f s
hf'✝ : DifferentiableWithinAt ℝ (iteratedDerivWithin n f s) s y
hf : ContDiffOn ℝ (↑Nat.zero) f s
hf' : DifferentiableWithinAt ℝ (iteratedDerivWithin Nat.zero f s) s y
⊢ HasDerivWithinAt (fun t => f t) (iteratedDerivWithin (Nat.zero + 1) f s y) s' y
[PROOFSTEP]
simp only [iteratedDerivWithin_zero] at hf'
[GOAL]
case zero
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
x y : ℝ
n : ℕ
s s' : Set ℝ
hs'_unique : UniqueDiffWithinAt ℝ s' y
hs_unique : UniqueDiffOn ℝ s
hs' : s' ∈ 𝓝[s] y
hy : y ∈ s'
h : s' ⊆ s
hf✝ : ContDiffOn ℝ (↑n) f s
hf'✝ : DifferentiableWithinAt ℝ (iteratedDerivWithin n f s) s y
hf : ContDiffOn ℝ (↑Nat.zero) f s
hf' : DifferentiableWithinAt ℝ f s y
⊢ HasDerivWithinAt (fun t => f t) (iteratedDerivWithin (Nat.zero + 1) f s y) s' y
[PROOFSTEP]
rw [iteratedDerivWithin_one (hs_unique _ (h hy))]
[GOAL]
case zero
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
x y : ℝ
n : ℕ
s s' : Set ℝ
hs'_unique : UniqueDiffWithinAt ℝ s' y
hs_unique : UniqueDiffOn ℝ s
hs' : s' ∈ 𝓝[s] y
hy : y ∈ s'
h : s' ⊆ s
hf✝ : ContDiffOn ℝ (↑n) f s
hf'✝ : DifferentiableWithinAt ℝ (iteratedDerivWithin n f s) s y
hf : ContDiffOn ℝ (↑Nat.zero) f s
hf' : DifferentiableWithinAt ℝ f s y
⊢ HasDerivWithinAt (fun t => f t) (derivWithin f s y) s' y
[PROOFSTEP]
norm_num
[GOAL]
case zero
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
x y : ℝ
n : ℕ
s s' : Set ℝ
hs'_unique : UniqueDiffWithinAt ℝ s' y
hs_unique : UniqueDiffOn ℝ s
hs' : s' ∈ 𝓝[s] y
hy : y ∈ s'
h : s' ⊆ s
hf✝ : ContDiffOn ℝ (↑n) f s
hf'✝ : DifferentiableWithinAt ℝ (iteratedDerivWithin n f s) s y
hf : ContDiffOn ℝ (↑Nat.zero) f s
hf' : DifferentiableWithinAt ℝ f s y
⊢ HasDerivWithinAt (fun t => f t) (derivWithin f s y) s' y
[PROOFSTEP]
exact hf'.hasDerivWithinAt.mono h
[GOAL]
case succ
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
x y : ℝ
n : ℕ
s s' : Set ℝ
hs'_unique : UniqueDiffWithinAt ℝ s' y
hs_unique : UniqueDiffOn ℝ s
hs' : s' ∈ 𝓝[s] y
hy : y ∈ s'
h : s' ⊆ s
hf✝ : ContDiffOn ℝ (↑n) f s
hf'✝ : DifferentiableWithinAt ℝ (iteratedDerivWithin n f s) s y
k : ℕ
hk :
  ContDiffOn ℝ (↑k) f s →
    DifferentiableWithinAt ℝ (iteratedDerivWithin k f s) s y →
      HasDerivWithinAt (fun t => taylorWithinEval f k s t x)
        (((↑k !)⁻¹ * (x - y) ^ k) • iteratedDerivWithin (k + 1) f s y) s' y
hf : ContDiffOn ℝ (↑(Nat.succ k)) f s
hf' : DifferentiableWithinAt ℝ (iteratedDerivWithin (Nat.succ k) f s) s y
⊢ HasDerivWithinAt (fun t => taylorWithinEval f (Nat.succ k) s t x)
    (((↑(Nat.succ k)!)⁻¹ * (x - y) ^ Nat.succ k) • iteratedDerivWithin (Nat.succ k + 1) f s y) s' y
[PROOFSTEP]
simp_rw [Nat.add_succ, taylorWithinEval_succ]
[GOAL]
case succ
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
x y : ℝ
n : ℕ
s s' : Set ℝ
hs'_unique : UniqueDiffWithinAt ℝ s' y
hs_unique : UniqueDiffOn ℝ s
hs' : s' ∈ 𝓝[s] y
hy : y ∈ s'
h : s' ⊆ s
hf✝ : ContDiffOn ℝ (↑n) f s
hf'✝ : DifferentiableWithinAt ℝ (iteratedDerivWithin n f s) s y
k : ℕ
hk :
  ContDiffOn ℝ (↑k) f s →
    DifferentiableWithinAt ℝ (iteratedDerivWithin k f s) s y →
      HasDerivWithinAt (fun t => taylorWithinEval f k s t x)
        (((↑k !)⁻¹ * (x - y) ^ k) • iteratedDerivWithin (k + 1) f s y) s' y
hf : ContDiffOn ℝ (↑(Nat.succ k)) f s
hf' : DifferentiableWithinAt ℝ (iteratedDerivWithin (Nat.succ k) f s) s y
⊢ HasDerivWithinAt
    (fun t =>
      taylorWithinEval f k s t x + (((↑k + 1) * ↑k !)⁻¹ * (x - t) ^ (k + 1)) • iteratedDerivWithin (k + 1) f s t)
    (((↑(Nat.succ k)!)⁻¹ * (x - y) ^ Nat.succ k) • iteratedDerivWithin (Nat.succ (Nat.succ k + 0)) f s y) s' y
[PROOFSTEP]
simp only [add_zero, Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one]
[GOAL]
case succ
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
x y : ℝ
n : ℕ
s s' : Set ℝ
hs'_unique : UniqueDiffWithinAt ℝ s' y
hs_unique : UniqueDiffOn ℝ s
hs' : s' ∈ 𝓝[s] y
hy : y ∈ s'
h : s' ⊆ s
hf✝ : ContDiffOn ℝ (↑n) f s
hf'✝ : DifferentiableWithinAt ℝ (iteratedDerivWithin n f s) s y
k : ℕ
hk :
  ContDiffOn ℝ (↑k) f s →
    DifferentiableWithinAt ℝ (iteratedDerivWithin k f s) s y →
      HasDerivWithinAt (fun t => taylorWithinEval f k s t x)
        (((↑k !)⁻¹ * (x - y) ^ k) • iteratedDerivWithin (k + 1) f s y) s' y
hf : ContDiffOn ℝ (↑(Nat.succ k)) f s
hf' : DifferentiableWithinAt ℝ (iteratedDerivWithin (Nat.succ k) f s) s y
⊢ HasDerivWithinAt
    (fun t =>
      taylorWithinEval f k s t x + (((↑k + 1) * ↑k !)⁻¹ * (x - t) ^ (k + 1)) • iteratedDerivWithin (k + 1) f s t)
    ((((↑k + 1) * ↑k !)⁻¹ * (x - y) ^ Nat.succ k) • iteratedDerivWithin (Nat.succ (Nat.succ k)) f s y) s' y
[PROOFSTEP]
have hdiff : DifferentiableOn ℝ (iteratedDerivWithin k f s) s' :=
  by
  have coe_lt_succ : (k : WithTop ℕ) < k.succ := Nat.cast_lt.2 k.lt_succ_self
  refine' DifferentiableOn.mono _ h
  exact hf.differentiableOn_iteratedDerivWithin coe_lt_succ hs_unique
[GOAL]
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
x y : ℝ
n : ℕ
s s' : Set ℝ
hs'_unique : UniqueDiffWithinAt ℝ s' y
hs_unique : UniqueDiffOn ℝ s
hs' : s' ∈ 𝓝[s] y
hy : y ∈ s'
h : s' ⊆ s
hf✝ : ContDiffOn ℝ (↑n) f s
hf'✝ : DifferentiableWithinAt ℝ (iteratedDerivWithin n f s) s y
k : ℕ
hk :
  ContDiffOn ℝ (↑k) f s →
    DifferentiableWithinAt ℝ (iteratedDerivWithin k f s) s y →
      HasDerivWithinAt (fun t => taylorWithinEval f k s t x)
        (((↑k !)⁻¹ * (x - y) ^ k) • iteratedDerivWithin (k + 1) f s y) s' y
hf : ContDiffOn ℝ (↑(Nat.succ k)) f s
hf' : DifferentiableWithinAt ℝ (iteratedDerivWithin (Nat.succ k) f s) s y
⊢ DifferentiableOn ℝ (iteratedDerivWithin k f s) s'
[PROOFSTEP]
have coe_lt_succ : (k : WithTop ℕ) < k.succ := Nat.cast_lt.2 k.lt_succ_self
[GOAL]
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
x y : ℝ
n : ℕ
s s' : Set ℝ
hs'_unique : UniqueDiffWithinAt ℝ s' y
hs_unique : UniqueDiffOn ℝ s
hs' : s' ∈ 𝓝[s] y
hy : y ∈ s'
h : s' ⊆ s
hf✝ : ContDiffOn ℝ (↑n) f s
hf'✝ : DifferentiableWithinAt ℝ (iteratedDerivWithin n f s) s y
k : ℕ
hk :
  ContDiffOn ℝ (↑k) f s →
    DifferentiableWithinAt ℝ (iteratedDerivWithin k f s) s y →
      HasDerivWithinAt (fun t => taylorWithinEval f k s t x)
        (((↑k !)⁻¹ * (x - y) ^ k) • iteratedDerivWithin (k + 1) f s y) s' y
hf : ContDiffOn ℝ (↑(Nat.succ k)) f s
hf' : DifferentiableWithinAt ℝ (iteratedDerivWithin (Nat.succ k) f s) s y
coe_lt_succ : ↑k < ↑(Nat.succ k)
⊢ DifferentiableOn ℝ (iteratedDerivWithin k f s) s'
[PROOFSTEP]
refine' DifferentiableOn.mono _ h
[GOAL]
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
x y : ℝ
n : ℕ
s s' : Set ℝ
hs'_unique : UniqueDiffWithinAt ℝ s' y
hs_unique : UniqueDiffOn ℝ s
hs' : s' ∈ 𝓝[s] y
hy : y ∈ s'
h : s' ⊆ s
hf✝ : ContDiffOn ℝ (↑n) f s
hf'✝ : DifferentiableWithinAt ℝ (iteratedDerivWithin n f s) s y
k : ℕ
hk :
  ContDiffOn ℝ (↑k) f s →
    DifferentiableWithinAt ℝ (iteratedDerivWithin k f s) s y →
      HasDerivWithinAt (fun t => taylorWithinEval f k s t x)
        (((↑k !)⁻¹ * (x - y) ^ k) • iteratedDerivWithin (k + 1) f s y) s' y
hf : ContDiffOn ℝ (↑(Nat.succ k)) f s
hf' : DifferentiableWithinAt ℝ (iteratedDerivWithin (Nat.succ k) f s) s y
coe_lt_succ : ↑k < ↑(Nat.succ k)
⊢ DifferentiableOn ℝ (iteratedDerivWithin k f s) s
[PROOFSTEP]
exact hf.differentiableOn_iteratedDerivWithin coe_lt_succ hs_unique
[GOAL]
case succ
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
x y : ℝ
n : ℕ
s s' : Set ℝ
hs'_unique : UniqueDiffWithinAt ℝ s' y
hs_unique : UniqueDiffOn ℝ s
hs' : s' ∈ 𝓝[s] y
hy : y ∈ s'
h : s' ⊆ s
hf✝ : ContDiffOn ℝ (↑n) f s
hf'✝ : DifferentiableWithinAt ℝ (iteratedDerivWithin n f s) s y
k : ℕ
hk :
  ContDiffOn ℝ (↑k) f s →
    DifferentiableWithinAt ℝ (iteratedDerivWithin k f s) s y →
      HasDerivWithinAt (fun t => taylorWithinEval f k s t x)
        (((↑k !)⁻¹ * (x - y) ^ k) • iteratedDerivWithin (k + 1) f s y) s' y
hf : ContDiffOn ℝ (↑(Nat.succ k)) f s
hf' : DifferentiableWithinAt ℝ (iteratedDerivWithin (Nat.succ k) f s) s y
hdiff : DifferentiableOn ℝ (iteratedDerivWithin k f s) s'
⊢ HasDerivWithinAt
    (fun t =>
      taylorWithinEval f k s t x + (((↑k + 1) * ↑k !)⁻¹ * (x - t) ^ (k + 1)) • iteratedDerivWithin (k + 1) f s t)
    ((((↑k + 1) * ↑k !)⁻¹ * (x - y) ^ Nat.succ k) • iteratedDerivWithin (Nat.succ (Nat.succ k)) f s y) s' y
[PROOFSTEP]
specialize hk hf.of_succ ((hdiff y hy).mono_of_mem hs')
[GOAL]
case succ
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
x y : ℝ
n : ℕ
s s' : Set ℝ
hs'_unique : UniqueDiffWithinAt ℝ s' y
hs_unique : UniqueDiffOn ℝ s
hs' : s' ∈ 𝓝[s] y
hy : y ∈ s'
h : s' ⊆ s
hf✝ : ContDiffOn ℝ (↑n) f s
hf'✝ : DifferentiableWithinAt ℝ (iteratedDerivWithin n f s) s y
k : ℕ
hf : ContDiffOn ℝ (↑(Nat.succ k)) f s
hf' : DifferentiableWithinAt ℝ (iteratedDerivWithin (Nat.succ k) f s) s y
hdiff : DifferentiableOn ℝ (iteratedDerivWithin k f s) s'
hk :
  HasDerivWithinAt (fun t => taylorWithinEval f k s t x) (((↑k !)⁻¹ * (x - y) ^ k) • iteratedDerivWithin (k + 1) f s y)
    s' y
⊢ HasDerivWithinAt
    (fun t =>
      taylorWithinEval f k s t x + (((↑k + 1) * ↑k !)⁻¹ * (x - t) ^ (k + 1)) • iteratedDerivWithin (k + 1) f s t)
    ((((↑k + 1) * ↑k !)⁻¹ * (x - y) ^ Nat.succ k) • iteratedDerivWithin (Nat.succ (Nat.succ k)) f s y) s' y
[PROOFSTEP]
convert hk.add (hasDerivWithinAt_taylor_coeff_within hs'_unique (nhdsWithin_mono _ h self_mem_nhdsWithin) hf') using 1
[GOAL]
case h.e'_7
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
x y : ℝ
n : ℕ
s s' : Set ℝ
hs'_unique : UniqueDiffWithinAt ℝ s' y
hs_unique : UniqueDiffOn ℝ s
hs' : s' ∈ 𝓝[s] y
hy : y ∈ s'
h : s' ⊆ s
hf✝ : ContDiffOn ℝ (↑n) f s
hf'✝ : DifferentiableWithinAt ℝ (iteratedDerivWithin n f s) s y
k : ℕ
hf : ContDiffOn ℝ (↑(Nat.succ k)) f s
hf' : DifferentiableWithinAt ℝ (iteratedDerivWithin (Nat.succ k) f s) s y
hdiff : DifferentiableOn ℝ (iteratedDerivWithin k f s) s'
hk :
  HasDerivWithinAt (fun t => taylorWithinEval f k s t x) (((↑k !)⁻¹ * (x - y) ^ k) • iteratedDerivWithin (k + 1) f s y)
    s' y
⊢ (((↑k + 1) * ↑k !)⁻¹ * (x - y) ^ Nat.succ k) • iteratedDerivWithin (Nat.succ (Nat.succ k)) f s y =
    ((↑k !)⁻¹ * (x - y) ^ k) • iteratedDerivWithin (k + 1) f s y +
      ((((↑k + 1) * ↑k !)⁻¹ * (x - y) ^ (k + 1)) • iteratedDerivWithin (k + 2) f s y -
        ((↑k !)⁻¹ * (x - y) ^ k) • iteratedDerivWithin (k + 1) f s y)
[PROOFSTEP]
exact (add_sub_cancel'_right _ _).symm
[GOAL]
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f g g' : ℝ → ℝ
x x₀ : ℝ
n : ℕ
hx : x₀ < x
hf : ContDiffOn ℝ (↑n) f (Icc x₀ x)
hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc x₀ x)) (Ioo x₀ x)
gcont : ContinuousOn g (Icc x₀ x)
gdiff : ∀ (x_1 : ℝ), x_1 ∈ Ioo x₀ x → HasDerivAt g (g' x_1) x_1
g'_ne : ∀ (x_1 : ℝ), x_1 ∈ Ioo x₀ x → g' x_1 ≠ 0
⊢ ∃ x' x_1,
    f x - taylorWithinEval f n (Icc x₀ x) x₀ x =
      ((x - x') ^ n / ↑n ! * (g x - g x₀) / g' x') • iteratedDerivWithin (n + 1) f (Icc x₀ x) x'
[PROOFSTEP]
rcases exists_ratio_hasDerivAt_eq_ratio_slope (fun t => taylorWithinEval f n (Icc x₀ x) t x)
    (fun t => ((n ! : ℝ)⁻¹ * (x - t) ^ n) • iteratedDerivWithin (n + 1) f (Icc x₀ x) t) hx
    (continuousOn_taylorWithinEval (uniqueDiffOn_Icc hx) hf)
    (fun _ hy => taylorWithinEval_hasDerivAt_Ioo x hx hy hf hf') g g' gcont gdiff with
  ⟨y, hy, h⟩
[GOAL]
case intro.intro
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f g g' : ℝ → ℝ
x x₀ : ℝ
n : ℕ
hx : x₀ < x
hf : ContDiffOn ℝ (↑n) f (Icc x₀ x)
hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc x₀ x)) (Ioo x₀ x)
gcont : ContinuousOn g (Icc x₀ x)
gdiff : ∀ (x_1 : ℝ), x_1 ∈ Ioo x₀ x → HasDerivAt g (g' x_1) x_1
g'_ne : ∀ (x_1 : ℝ), x_1 ∈ Ioo x₀ x → g' x_1 ≠ 0
y : ℝ
hy : y ∈ Ioo x₀ x
h :
  (g x - g x₀) * ((↑n !)⁻¹ * (x - y) ^ n) • iteratedDerivWithin (n + 1) f (Icc x₀ x) y =
    (taylorWithinEval f n (Icc x₀ x) x x - taylorWithinEval f n (Icc x₀ x) x₀ x) * g' y
⊢ ∃ x' x_1,
    f x - taylorWithinEval f n (Icc x₀ x) x₀ x =
      ((x - x') ^ n / ↑n ! * (g x - g x₀) / g' x') • iteratedDerivWithin (n + 1) f (Icc x₀ x) x'
[PROOFSTEP]
use y, hy
[GOAL]
case h
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f g g' : ℝ → ℝ
x x₀ : ℝ
n : ℕ
hx : x₀ < x
hf : ContDiffOn ℝ (↑n) f (Icc x₀ x)
hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc x₀ x)) (Ioo x₀ x)
gcont : ContinuousOn g (Icc x₀ x)
gdiff : ∀ (x_1 : ℝ), x_1 ∈ Ioo x₀ x → HasDerivAt g (g' x_1) x_1
g'_ne : ∀ (x_1 : ℝ), x_1 ∈ Ioo x₀ x → g' x_1 ≠ 0
y : ℝ
hy : y ∈ Ioo x₀ x
h :
  (g x - g x₀) * ((↑n !)⁻¹ * (x - y) ^ n) • iteratedDerivWithin (n + 1) f (Icc x₀ x) y =
    (taylorWithinEval f n (Icc x₀ x) x x - taylorWithinEval f n (Icc x₀ x) x₀ x) * g' y
⊢ f x - taylorWithinEval f n (Icc x₀ x) x₀ x =
    ((x - y) ^ n / ↑n ! * (g x - g x₀) / g' y) • iteratedDerivWithin (n + 1) f (Icc x₀ x) y
[PROOFSTEP]
simp only [taylorWithinEval_self] at h
[GOAL]
case h
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f g g' : ℝ → ℝ
x x₀ : ℝ
n : ℕ
hx : x₀ < x
hf : ContDiffOn ℝ (↑n) f (Icc x₀ x)
hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc x₀ x)) (Ioo x₀ x)
gcont : ContinuousOn g (Icc x₀ x)
gdiff : ∀ (x_1 : ℝ), x_1 ∈ Ioo x₀ x → HasDerivAt g (g' x_1) x_1
g'_ne : ∀ (x_1 : ℝ), x_1 ∈ Ioo x₀ x → g' x_1 ≠ 0
y : ℝ
hy : y ∈ Ioo x₀ x
h :
  (g x - g x₀) * ((↑n !)⁻¹ * (x - y) ^ n) • iteratedDerivWithin (n + 1) f (Icc x₀ x) y =
    (f x - taylorWithinEval f n (Icc x₀ x) x₀ x) * g' y
⊢ f x - taylorWithinEval f n (Icc x₀ x) x₀ x =
    ((x - y) ^ n / ↑n ! * (g x - g x₀) / g' y) • iteratedDerivWithin (n + 1) f (Icc x₀ x) y
[PROOFSTEP]
rw [mul_comm, ← div_left_inj' (g'_ne y hy), mul_div_cancel _ (g'_ne y hy)] at h
[GOAL]
case h
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f g g' : ℝ → ℝ
x x₀ : ℝ
n : ℕ
hx : x₀ < x
hf : ContDiffOn ℝ (↑n) f (Icc x₀ x)
hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc x₀ x)) (Ioo x₀ x)
gcont : ContinuousOn g (Icc x₀ x)
gdiff : ∀ (x_1 : ℝ), x_1 ∈ Ioo x₀ x → HasDerivAt g (g' x_1) x_1
g'_ne : ∀ (x_1 : ℝ), x_1 ∈ Ioo x₀ x → g' x_1 ≠ 0
y : ℝ
hy : y ∈ Ioo x₀ x
h :
  ((↑n !)⁻¹ * (x - y) ^ n) • iteratedDerivWithin (n + 1) f (Icc x₀ x) y * (g x - g x₀) / g' y =
    f x - taylorWithinEval f n (Icc x₀ x) x₀ x
⊢ f x - taylorWithinEval f n (Icc x₀ x) x₀ x =
    ((x - y) ^ n / ↑n ! * (g x - g x₀) / g' y) • iteratedDerivWithin (n + 1) f (Icc x₀ x) y
[PROOFSTEP]
rw [← h]
[GOAL]
case h
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f g g' : ℝ → ℝ
x x₀ : ℝ
n : ℕ
hx : x₀ < x
hf : ContDiffOn ℝ (↑n) f (Icc x₀ x)
hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc x₀ x)) (Ioo x₀ x)
gcont : ContinuousOn g (Icc x₀ x)
gdiff : ∀ (x_1 : ℝ), x_1 ∈ Ioo x₀ x → HasDerivAt g (g' x_1) x_1
g'_ne : ∀ (x_1 : ℝ), x_1 ∈ Ioo x₀ x → g' x_1 ≠ 0
y : ℝ
hy : y ∈ Ioo x₀ x
h :
  ((↑n !)⁻¹ * (x - y) ^ n) • iteratedDerivWithin (n + 1) f (Icc x₀ x) y * (g x - g x₀) / g' y =
    f x - taylorWithinEval f n (Icc x₀ x) x₀ x
⊢ ((↑n !)⁻¹ * (x - y) ^ n) • iteratedDerivWithin (n + 1) f (Icc x₀ x) y * (g x - g x₀) / g' y =
    ((x - y) ^ n / ↑n ! * (g x - g x₀) / g' y) • iteratedDerivWithin (n + 1) f (Icc x₀ x) y
[PROOFSTEP]
field_simp [g'_ne y hy, n.factorial_ne_zero]
[GOAL]
case h
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f g g' : ℝ → ℝ
x x₀ : ℝ
n : ℕ
hx : x₀ < x
hf : ContDiffOn ℝ (↑n) f (Icc x₀ x)
hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc x₀ x)) (Ioo x₀ x)
gcont : ContinuousOn g (Icc x₀ x)
gdiff : ∀ (x_1 : ℝ), x_1 ∈ Ioo x₀ x → HasDerivAt g (g' x_1) x_1
g'_ne : ∀ (x_1 : ℝ), x_1 ∈ Ioo x₀ x → g' x_1 ≠ 0
y : ℝ
hy : y ∈ Ioo x₀ x
h :
  ((↑n !)⁻¹ * (x - y) ^ n) • iteratedDerivWithin (n + 1) f (Icc x₀ x) y * (g x - g x₀) / g' y =
    f x - taylorWithinEval f n (Icc x₀ x) x₀ x
⊢ (x - y) ^ n * iteratedDerivWithin (n + 1) f (Icc x₀ x) y * (g x - g x₀) =
    (x - y) ^ n * (g x - g x₀) * iteratedDerivWithin (n + 1) f (Icc x₀ x) y
[PROOFSTEP]
ring
[GOAL]
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → ℝ
x x₀ : ℝ
n : ℕ
hx : x₀ < x
hf : ContDiffOn ℝ (↑n) f (Icc x₀ x)
hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc x₀ x)) (Ioo x₀ x)
⊢ ∃ x' x_1,
    f x - taylorWithinEval f n (Icc x₀ x) x₀ x =
      iteratedDerivWithin (n + 1) f (Icc x₀ x) x' * (x - x₀) ^ (n + 1) / ↑(n + 1)!
[PROOFSTEP]
have gcont : ContinuousOn (fun t : ℝ => (x - t) ^ (n + 1)) (Icc x₀ x) :=
  by
  refine' Continuous.continuousOn _
  exact
    (continuous_const.sub continuous_id').pow
      _
        -- Porting note: was `continuity`
[GOAL]
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → ℝ
x x₀ : ℝ
n : ℕ
hx : x₀ < x
hf : ContDiffOn ℝ (↑n) f (Icc x₀ x)
hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc x₀ x)) (Ioo x₀ x)
⊢ ContinuousOn (fun t => (x - t) ^ (n + 1)) (Icc x₀ x)
[PROOFSTEP]
refine' Continuous.continuousOn _
[GOAL]
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → ℝ
x x₀ : ℝ
n : ℕ
hx : x₀ < x
hf : ContDiffOn ℝ (↑n) f (Icc x₀ x)
hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc x₀ x)) (Ioo x₀ x)
⊢ Continuous fun t => (x - t) ^ (n + 1)
[PROOFSTEP]
exact
  (continuous_const.sub continuous_id').pow
    _
      -- Porting note: was `continuity`
[GOAL]
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → ℝ
x x₀ : ℝ
n : ℕ
hx : x₀ < x
hf : ContDiffOn ℝ (↑n) f (Icc x₀ x)
hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc x₀ x)) (Ioo x₀ x)
gcont : ContinuousOn (fun t => (x - t) ^ (n + 1)) (Icc x₀ x)
⊢ ∃ x' x_1,
    f x - taylorWithinEval f n (Icc x₀ x) x₀ x =
      iteratedDerivWithin (n + 1) f (Icc x₀ x) x' * (x - x₀) ^ (n + 1) / ↑(n + 1)!
[PROOFSTEP]
have xy_ne : ∀ y : ℝ, y ∈ Ioo x₀ x → (x - y) ^ n ≠ 0 :=
  by
  intro y hy
  refine' pow_ne_zero _ _
  rw [mem_Ioo] at hy
  rw [sub_ne_zero]
  exact hy.2.ne.symm
[GOAL]
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → ℝ
x x₀ : ℝ
n : ℕ
hx : x₀ < x
hf : ContDiffOn ℝ (↑n) f (Icc x₀ x)
hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc x₀ x)) (Ioo x₀ x)
gcont : ContinuousOn (fun t => (x - t) ^ (n + 1)) (Icc x₀ x)
⊢ ∀ (y : ℝ), y ∈ Ioo x₀ x → (x - y) ^ n ≠ 0
[PROOFSTEP]
intro y hy
[GOAL]
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → ℝ
x x₀ : ℝ
n : ℕ
hx : x₀ < x
hf : ContDiffOn ℝ (↑n) f (Icc x₀ x)
hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc x₀ x)) (Ioo x₀ x)
gcont : ContinuousOn (fun t => (x - t) ^ (n + 1)) (Icc x₀ x)
y : ℝ
hy : y ∈ Ioo x₀ x
⊢ (x - y) ^ n ≠ 0
[PROOFSTEP]
refine' pow_ne_zero _ _
[GOAL]
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → ℝ
x x₀ : ℝ
n : ℕ
hx : x₀ < x
hf : ContDiffOn ℝ (↑n) f (Icc x₀ x)
hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc x₀ x)) (Ioo x₀ x)
gcont : ContinuousOn (fun t => (x - t) ^ (n + 1)) (Icc x₀ x)
y : ℝ
hy : y ∈ Ioo x₀ x
⊢ x - y ≠ 0
[PROOFSTEP]
rw [mem_Ioo] at hy
[GOAL]
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → ℝ
x x₀ : ℝ
n : ℕ
hx : x₀ < x
hf : ContDiffOn ℝ (↑n) f (Icc x₀ x)
hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc x₀ x)) (Ioo x₀ x)
gcont : ContinuousOn (fun t => (x - t) ^ (n + 1)) (Icc x₀ x)
y : ℝ
hy : x₀ < y ∧ y < x
⊢ x - y ≠ 0
[PROOFSTEP]
rw [sub_ne_zero]
[GOAL]
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → ℝ
x x₀ : ℝ
n : ℕ
hx : x₀ < x
hf : ContDiffOn ℝ (↑n) f (Icc x₀ x)
hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc x₀ x)) (Ioo x₀ x)
gcont : ContinuousOn (fun t => (x - t) ^ (n + 1)) (Icc x₀ x)
y : ℝ
hy : x₀ < y ∧ y < x
⊢ x ≠ y
[PROOFSTEP]
exact hy.2.ne.symm
[GOAL]
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → ℝ
x x₀ : ℝ
n : ℕ
hx : x₀ < x
hf : ContDiffOn ℝ (↑n) f (Icc x₀ x)
hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc x₀ x)) (Ioo x₀ x)
gcont : ContinuousOn (fun t => (x - t) ^ (n + 1)) (Icc x₀ x)
xy_ne : ∀ (y : ℝ), y ∈ Ioo x₀ x → (x - y) ^ n ≠ 0
⊢ ∃ x' x_1,
    f x - taylorWithinEval f n (Icc x₀ x) x₀ x =
      iteratedDerivWithin (n + 1) f (Icc x₀ x) x' * (x - x₀) ^ (n + 1) / ↑(n + 1)!
[PROOFSTEP]
have hg' : ∀ y : ℝ, y ∈ Ioo x₀ x → -(↑n + 1) * (x - y) ^ n ≠ 0 := fun y hy =>
  mul_ne_zero (neg_ne_zero.mpr (Nat.cast_add_one_ne_zero n))
    (xy_ne y hy)
      -- We apply the general theorem with g(t) = (x - t)^(n+1)
[GOAL]
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → ℝ
x x₀ : ℝ
n : ℕ
hx : x₀ < x
hf : ContDiffOn ℝ (↑n) f (Icc x₀ x)
hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc x₀ x)) (Ioo x₀ x)
gcont : ContinuousOn (fun t => (x - t) ^ (n + 1)) (Icc x₀ x)
xy_ne : ∀ (y : ℝ), y ∈ Ioo x₀ x → (x - y) ^ n ≠ 0
hg' : ∀ (y : ℝ), y ∈ Ioo x₀ x → -(↑n + 1) * (x - y) ^ n ≠ 0
⊢ ∃ x' x_1,
    f x - taylorWithinEval f n (Icc x₀ x) x₀ x =
      iteratedDerivWithin (n + 1) f (Icc x₀ x) x' * (x - x₀) ^ (n + 1) / ↑(n + 1)!
[PROOFSTEP]
rcases taylor_mean_remainder hx hf hf' gcont (fun y _ => monomial_has_deriv_aux y x _) hg' with ⟨y, hy, h⟩
[GOAL]
case intro.intro
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → ℝ
x x₀ : ℝ
n : ℕ
hx : x₀ < x
hf : ContDiffOn ℝ (↑n) f (Icc x₀ x)
hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc x₀ x)) (Ioo x₀ x)
gcont : ContinuousOn (fun t => (x - t) ^ (n + 1)) (Icc x₀ x)
xy_ne : ∀ (y : ℝ), y ∈ Ioo x₀ x → (x - y) ^ n ≠ 0
hg' : ∀ (y : ℝ), y ∈ Ioo x₀ x → -(↑n + 1) * (x - y) ^ n ≠ 0
y : ℝ
hy : y ∈ Ioo x₀ x
h :
  f x - taylorWithinEval f n (Icc x₀ x) x₀ x =
    ((x - y) ^ n / ↑n ! * ((x - x) ^ (n + 1) - (x - x₀) ^ (n + 1)) / (-(↑n + 1) * (x - y) ^ n)) •
      iteratedDerivWithin (n + 1) f (Icc x₀ x) y
⊢ ∃ x' x_1,
    f x - taylorWithinEval f n (Icc x₀ x) x₀ x =
      iteratedDerivWithin (n + 1) f (Icc x₀ x) x' * (x - x₀) ^ (n + 1) / ↑(n + 1)!
[PROOFSTEP]
use y, hy
[GOAL]
case h
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → ℝ
x x₀ : ℝ
n : ℕ
hx : x₀ < x
hf : ContDiffOn ℝ (↑n) f (Icc x₀ x)
hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc x₀ x)) (Ioo x₀ x)
gcont : ContinuousOn (fun t => (x - t) ^ (n + 1)) (Icc x₀ x)
xy_ne : ∀ (y : ℝ), y ∈ Ioo x₀ x → (x - y) ^ n ≠ 0
hg' : ∀ (y : ℝ), y ∈ Ioo x₀ x → -(↑n + 1) * (x - y) ^ n ≠ 0
y : ℝ
hy : y ∈ Ioo x₀ x
h :
  f x - taylorWithinEval f n (Icc x₀ x) x₀ x =
    ((x - y) ^ n / ↑n ! * ((x - x) ^ (n + 1) - (x - x₀) ^ (n + 1)) / (-(↑n + 1) * (x - y) ^ n)) •
      iteratedDerivWithin (n + 1) f (Icc x₀ x) y
⊢ f x - taylorWithinEval f n (Icc x₀ x) x₀ x =
    iteratedDerivWithin (n + 1) f (Icc x₀ x) y * (x - x₀) ^ (n + 1) / ↑(n + 1)!
[PROOFSTEP]
simp only [sub_self, zero_pow', Ne.def, Nat.succ_ne_zero, not_false_iff, zero_sub, mul_neg] at h
[GOAL]
case h
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → ℝ
x x₀ : ℝ
n : ℕ
hx : x₀ < x
hf : ContDiffOn ℝ (↑n) f (Icc x₀ x)
hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc x₀ x)) (Ioo x₀ x)
gcont : ContinuousOn (fun t => (x - t) ^ (n + 1)) (Icc x₀ x)
xy_ne : ∀ (y : ℝ), y ∈ Ioo x₀ x → (x - y) ^ n ≠ 0
hg' : ∀ (y : ℝ), y ∈ Ioo x₀ x → -(↑n + 1) * (x - y) ^ n ≠ 0
y : ℝ
hy : y ∈ Ioo x₀ x
h :
  f x - taylorWithinEval f n (Icc x₀ x) x₀ x =
    (-((x - y) ^ n / ↑n ! * (x - x₀) ^ (n + 1)) / (-(↑n + 1) * (x - y) ^ n)) •
      iteratedDerivWithin (n + 1) f (Icc x₀ x) y
⊢ f x - taylorWithinEval f n (Icc x₀ x) x₀ x =
    iteratedDerivWithin (n + 1) f (Icc x₀ x) y * (x - x₀) ^ (n + 1) / ↑(n + 1)!
[PROOFSTEP]
rw [h, neg_div, ← div_neg, neg_mul, neg_neg]
[GOAL]
case h
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → ℝ
x x₀ : ℝ
n : ℕ
hx : x₀ < x
hf : ContDiffOn ℝ (↑n) f (Icc x₀ x)
hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc x₀ x)) (Ioo x₀ x)
gcont : ContinuousOn (fun t => (x - t) ^ (n + 1)) (Icc x₀ x)
xy_ne : ∀ (y : ℝ), y ∈ Ioo x₀ x → (x - y) ^ n ≠ 0
hg' : ∀ (y : ℝ), y ∈ Ioo x₀ x → -(↑n + 1) * (x - y) ^ n ≠ 0
y : ℝ
hy : y ∈ Ioo x₀ x
h :
  f x - taylorWithinEval f n (Icc x₀ x) x₀ x =
    (-((x - y) ^ n / ↑n ! * (x - x₀) ^ (n + 1)) / (-(↑n + 1) * (x - y) ^ n)) •
      iteratedDerivWithin (n + 1) f (Icc x₀ x) y
⊢ ((x - y) ^ n / ↑n ! * (x - x₀) ^ (n + 1) / ((↑n + 1) * (x - y) ^ n)) • iteratedDerivWithin (n + 1) f (Icc x₀ x) y =
    iteratedDerivWithin (n + 1) f (Icc x₀ x) y * (x - x₀) ^ (n + 1) / ↑(n + 1)!
[PROOFSTEP]
field_simp
  -- Porting note: was `ring`
[GOAL]
case h
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → ℝ
x x₀ : ℝ
n : ℕ
hx : x₀ < x
hf : ContDiffOn ℝ (↑n) f (Icc x₀ x)
hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc x₀ x)) (Ioo x₀ x)
gcont : ContinuousOn (fun t => (x - t) ^ (n + 1)) (Icc x₀ x)
xy_ne : ∀ (y : ℝ), y ∈ Ioo x₀ x → (x - y) ^ n ≠ 0
hg' : ∀ (y : ℝ), y ∈ Ioo x₀ x → -(↑n + 1) * (x - y) ^ n ≠ 0
y : ℝ
hy : y ∈ Ioo x₀ x
h :
  f x - taylorWithinEval f n (Icc x₀ x) x₀ x =
    (-((x - y) ^ n / ↑n ! * (x - x₀) ^ (n + 1)) / (-(↑n + 1) * (x - y) ^ n)) •
      iteratedDerivWithin (n + 1) f (Icc x₀ x) y
⊢ (x - y) ^ n * (x - x₀) ^ (n + 1) * iteratedDerivWithin (n + 1) f (Icc x₀ x) y / (↑n ! * ((↑n + 1) * (x - y) ^ n)) =
    iteratedDerivWithin (n + 1) f (Icc x₀ x) y * (x - x₀) ^ (n + 1) / ((↑n + 1) * ↑n !)
[PROOFSTEP]
conv_lhs =>
  arg 2
  rw [← mul_assoc, mul_comm]
[GOAL]
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → ℝ
x x₀ : ℝ
n : ℕ
hx : x₀ < x
hf : ContDiffOn ℝ (↑n) f (Icc x₀ x)
hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc x₀ x)) (Ioo x₀ x)
gcont : ContinuousOn (fun t => (x - t) ^ (n + 1)) (Icc x₀ x)
xy_ne : ∀ (y : ℝ), y ∈ Ioo x₀ x → (x - y) ^ n ≠ 0
hg' : ∀ (y : ℝ), y ∈ Ioo x₀ x → -(↑n + 1) * (x - y) ^ n ≠ 0
y : ℝ
hy : y ∈ Ioo x₀ x
h :
  f x - taylorWithinEval f n (Icc x₀ x) x₀ x =
    (-((x - y) ^ n / ↑n ! * (x - x₀) ^ (n + 1)) / (-(↑n + 1) * (x - y) ^ n)) •
      iteratedDerivWithin (n + 1) f (Icc x₀ x) y
| (x - y) ^ n * (x - x₀) ^ (n + 1) * iteratedDerivWithin (n + 1) f (Icc x₀ x) y / (↑n ! * ((↑n + 1) * (x - y) ^ n))
[PROOFSTEP]
  arg 2
  rw [← mul_assoc, mul_comm]
[GOAL]
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → ℝ
x x₀ : ℝ
n : ℕ
hx : x₀ < x
hf : ContDiffOn ℝ (↑n) f (Icc x₀ x)
hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc x₀ x)) (Ioo x₀ x)
gcont : ContinuousOn (fun t => (x - t) ^ (n + 1)) (Icc x₀ x)
xy_ne : ∀ (y : ℝ), y ∈ Ioo x₀ x → (x - y) ^ n ≠ 0
hg' : ∀ (y : ℝ), y ∈ Ioo x₀ x → -(↑n + 1) * (x - y) ^ n ≠ 0
y : ℝ
hy : y ∈ Ioo x₀ x
h :
  f x - taylorWithinEval f n (Icc x₀ x) x₀ x =
    (-((x - y) ^ n / ↑n ! * (x - x₀) ^ (n + 1)) / (-(↑n + 1) * (x - y) ^ n)) •
      iteratedDerivWithin (n + 1) f (Icc x₀ x) y
| (x - y) ^ n * (x - x₀) ^ (n + 1) * iteratedDerivWithin (n + 1) f (Icc x₀ x) y / (↑n ! * ((↑n + 1) * (x - y) ^ n))
[PROOFSTEP]
  arg 2
  rw [← mul_assoc, mul_comm]
[GOAL]
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → ℝ
x x₀ : ℝ
n : ℕ
hx : x₀ < x
hf : ContDiffOn ℝ (↑n) f (Icc x₀ x)
hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc x₀ x)) (Ioo x₀ x)
gcont : ContinuousOn (fun t => (x - t) ^ (n + 1)) (Icc x₀ x)
xy_ne : ∀ (y : ℝ), y ∈ Ioo x₀ x → (x - y) ^ n ≠ 0
hg' : ∀ (y : ℝ), y ∈ Ioo x₀ x → -(↑n + 1) * (x - y) ^ n ≠ 0
y : ℝ
hy : y ∈ Ioo x₀ x
h :
  f x - taylorWithinEval f n (Icc x₀ x) x₀ x =
    (-((x - y) ^ n / ↑n ! * (x - x₀) ^ (n + 1)) / (-(↑n + 1) * (x - y) ^ n)) •
      iteratedDerivWithin (n + 1) f (Icc x₀ x) y
| (x - y) ^ n * (x - x₀) ^ (n + 1) * iteratedDerivWithin (n + 1) f (Icc x₀ x) y / (↑n ! * ((↑n + 1) * (x - y) ^ n))
[PROOFSTEP]
arg 2
[GOAL]
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → ℝ
x x₀ : ℝ
n : ℕ
hx : x₀ < x
hf : ContDiffOn ℝ (↑n) f (Icc x₀ x)
hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc x₀ x)) (Ioo x₀ x)
gcont : ContinuousOn (fun t => (x - t) ^ (n + 1)) (Icc x₀ x)
xy_ne : ∀ (y : ℝ), y ∈ Ioo x₀ x → (x - y) ^ n ≠ 0
hg' : ∀ (y : ℝ), y ∈ Ioo x₀ x → -(↑n + 1) * (x - y) ^ n ≠ 0
y : ℝ
hy : y ∈ Ioo x₀ x
h :
  f x - taylorWithinEval f n (Icc x₀ x) x₀ x =
    (-((x - y) ^ n / ↑n ! * (x - x₀) ^ (n + 1)) / (-(↑n + 1) * (x - y) ^ n)) •
      iteratedDerivWithin (n + 1) f (Icc x₀ x) y
| ↑n ! * ((↑n + 1) * (x - y) ^ n)
[PROOFSTEP]
rw [← mul_assoc, mul_comm]
[GOAL]
case h
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → ℝ
x x₀ : ℝ
n : ℕ
hx : x₀ < x
hf : ContDiffOn ℝ (↑n) f (Icc x₀ x)
hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc x₀ x)) (Ioo x₀ x)
gcont : ContinuousOn (fun t => (x - t) ^ (n + 1)) (Icc x₀ x)
xy_ne : ∀ (y : ℝ), y ∈ Ioo x₀ x → (x - y) ^ n ≠ 0
hg' : ∀ (y : ℝ), y ∈ Ioo x₀ x → -(↑n + 1) * (x - y) ^ n ≠ 0
y : ℝ
hy : y ∈ Ioo x₀ x
h :
  f x - taylorWithinEval f n (Icc x₀ x) x₀ x =
    (-((x - y) ^ n / ↑n ! * (x - x₀) ^ (n + 1)) / (-(↑n + 1) * (x - y) ^ n)) •
      iteratedDerivWithin (n + 1) f (Icc x₀ x) y
⊢ (x - y) ^ n * (x - x₀) ^ (n + 1) * iteratedDerivWithin (n + 1) f (Icc x₀ x) y / ((x - y) ^ n * (↑n ! * (↑n + 1))) =
    iteratedDerivWithin (n + 1) f (Icc x₀ x) y * (x - x₀) ^ (n + 1) / ((↑n + 1) * ↑n !)
[PROOFSTEP]
rw [mul_assoc, mul_div_mul_left _ _ (xy_ne y hy)]
[GOAL]
case h
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → ℝ
x x₀ : ℝ
n : ℕ
hx : x₀ < x
hf : ContDiffOn ℝ (↑n) f (Icc x₀ x)
hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc x₀ x)) (Ioo x₀ x)
gcont : ContinuousOn (fun t => (x - t) ^ (n + 1)) (Icc x₀ x)
xy_ne : ∀ (y : ℝ), y ∈ Ioo x₀ x → (x - y) ^ n ≠ 0
hg' : ∀ (y : ℝ), y ∈ Ioo x₀ x → -(↑n + 1) * (x - y) ^ n ≠ 0
y : ℝ
hy : y ∈ Ioo x₀ x
h :
  f x - taylorWithinEval f n (Icc x₀ x) x₀ x =
    (-((x - y) ^ n / ↑n ! * (x - x₀) ^ (n + 1)) / (-(↑n + 1) * (x - y) ^ n)) •
      iteratedDerivWithin (n + 1) f (Icc x₀ x) y
⊢ (x - x₀) ^ (n + 1) * iteratedDerivWithin (n + 1) f (Icc x₀ x) y / (↑n ! * (↑n + 1)) =
    iteratedDerivWithin (n + 1) f (Icc x₀ x) y * (x - x₀) ^ (n + 1) / ((↑n + 1) * ↑n !)
[PROOFSTEP]
conv_lhs =>
  arg 2
  rw [mul_comm]
[GOAL]
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → ℝ
x x₀ : ℝ
n : ℕ
hx : x₀ < x
hf : ContDiffOn ℝ (↑n) f (Icc x₀ x)
hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc x₀ x)) (Ioo x₀ x)
gcont : ContinuousOn (fun t => (x - t) ^ (n + 1)) (Icc x₀ x)
xy_ne : ∀ (y : ℝ), y ∈ Ioo x₀ x → (x - y) ^ n ≠ 0
hg' : ∀ (y : ℝ), y ∈ Ioo x₀ x → -(↑n + 1) * (x - y) ^ n ≠ 0
y : ℝ
hy : y ∈ Ioo x₀ x
h :
  f x - taylorWithinEval f n (Icc x₀ x) x₀ x =
    (-((x - y) ^ n / ↑n ! * (x - x₀) ^ (n + 1)) / (-(↑n + 1) * (x - y) ^ n)) •
      iteratedDerivWithin (n + 1) f (Icc x₀ x) y
| (x - x₀) ^ (n + 1) * iteratedDerivWithin (n + 1) f (Icc x₀ x) y / (↑n ! * (↑n + 1))
[PROOFSTEP]
  arg 2
  rw [mul_comm]
[GOAL]
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → ℝ
x x₀ : ℝ
n : ℕ
hx : x₀ < x
hf : ContDiffOn ℝ (↑n) f (Icc x₀ x)
hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc x₀ x)) (Ioo x₀ x)
gcont : ContinuousOn (fun t => (x - t) ^ (n + 1)) (Icc x₀ x)
xy_ne : ∀ (y : ℝ), y ∈ Ioo x₀ x → (x - y) ^ n ≠ 0
hg' : ∀ (y : ℝ), y ∈ Ioo x₀ x → -(↑n + 1) * (x - y) ^ n ≠ 0
y : ℝ
hy : y ∈ Ioo x₀ x
h :
  f x - taylorWithinEval f n (Icc x₀ x) x₀ x =
    (-((x - y) ^ n / ↑n ! * (x - x₀) ^ (n + 1)) / (-(↑n + 1) * (x - y) ^ n)) •
      iteratedDerivWithin (n + 1) f (Icc x₀ x) y
| (x - x₀) ^ (n + 1) * iteratedDerivWithin (n + 1) f (Icc x₀ x) y / (↑n ! * (↑n + 1))
[PROOFSTEP]
  arg 2
  rw [mul_comm]
[GOAL]
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → ℝ
x x₀ : ℝ
n : ℕ
hx : x₀ < x
hf : ContDiffOn ℝ (↑n) f (Icc x₀ x)
hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc x₀ x)) (Ioo x₀ x)
gcont : ContinuousOn (fun t => (x - t) ^ (n + 1)) (Icc x₀ x)
xy_ne : ∀ (y : ℝ), y ∈ Ioo x₀ x → (x - y) ^ n ≠ 0
hg' : ∀ (y : ℝ), y ∈ Ioo x₀ x → -(↑n + 1) * (x - y) ^ n ≠ 0
y : ℝ
hy : y ∈ Ioo x₀ x
h :
  f x - taylorWithinEval f n (Icc x₀ x) x₀ x =
    (-((x - y) ^ n / ↑n ! * (x - x₀) ^ (n + 1)) / (-(↑n + 1) * (x - y) ^ n)) •
      iteratedDerivWithin (n + 1) f (Icc x₀ x) y
| (x - x₀) ^ (n + 1) * iteratedDerivWithin (n + 1) f (Icc x₀ x) y / (↑n ! * (↑n + 1))
[PROOFSTEP]
arg 2
[GOAL]
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → ℝ
x x₀ : ℝ
n : ℕ
hx : x₀ < x
hf : ContDiffOn ℝ (↑n) f (Icc x₀ x)
hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc x₀ x)) (Ioo x₀ x)
gcont : ContinuousOn (fun t => (x - t) ^ (n + 1)) (Icc x₀ x)
xy_ne : ∀ (y : ℝ), y ∈ Ioo x₀ x → (x - y) ^ n ≠ 0
hg' : ∀ (y : ℝ), y ∈ Ioo x₀ x → -(↑n + 1) * (x - y) ^ n ≠ 0
y : ℝ
hy : y ∈ Ioo x₀ x
h :
  f x - taylorWithinEval f n (Icc x₀ x) x₀ x =
    (-((x - y) ^ n / ↑n ! * (x - x₀) ^ (n + 1)) / (-(↑n + 1) * (x - y) ^ n)) •
      iteratedDerivWithin (n + 1) f (Icc x₀ x) y
| ↑n ! * (↑n + 1)
[PROOFSTEP]
rw [mul_comm]
[GOAL]
case h
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → ℝ
x x₀ : ℝ
n : ℕ
hx : x₀ < x
hf : ContDiffOn ℝ (↑n) f (Icc x₀ x)
hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc x₀ x)) (Ioo x₀ x)
gcont : ContinuousOn (fun t => (x - t) ^ (n + 1)) (Icc x₀ x)
xy_ne : ∀ (y : ℝ), y ∈ Ioo x₀ x → (x - y) ^ n ≠ 0
hg' : ∀ (y : ℝ), y ∈ Ioo x₀ x → -(↑n + 1) * (x - y) ^ n ≠ 0
y : ℝ
hy : y ∈ Ioo x₀ x
h :
  f x - taylorWithinEval f n (Icc x₀ x) x₀ x =
    (-((x - y) ^ n / ↑n ! * (x - x₀) ^ (n + 1)) / (-(↑n + 1) * (x - y) ^ n)) •
      iteratedDerivWithin (n + 1) f (Icc x₀ x) y
⊢ (x - x₀) ^ (n + 1) * iteratedDerivWithin (n + 1) f (Icc x₀ x) y / ((↑n + 1) * ↑n !) =
    iteratedDerivWithin (n + 1) f (Icc x₀ x) y * (x - x₀) ^ (n + 1) / ((↑n + 1) * ↑n !)
[PROOFSTEP]
nth_rw 1 [mul_comm]
[GOAL]
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → ℝ
x x₀ : ℝ
n : ℕ
hx : x₀ < x
hf : ContDiffOn ℝ (↑n) f (Icc x₀ x)
hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc x₀ x)) (Ioo x₀ x)
⊢ ∃ x' x_1,
    f x - taylorWithinEval f n (Icc x₀ x) x₀ x =
      iteratedDerivWithin (n + 1) f (Icc x₀ x) x' * (x - x') ^ n / ↑n ! * (x - x₀)
[PROOFSTEP]
have gcont : ContinuousOn id (Icc x₀ x) := Continuous.continuousOn (by continuity)
[GOAL]
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → ℝ
x x₀ : ℝ
n : ℕ
hx : x₀ < x
hf : ContDiffOn ℝ (↑n) f (Icc x₀ x)
hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc x₀ x)) (Ioo x₀ x)
⊢ Continuous id
[PROOFSTEP]
continuity
[GOAL]
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → ℝ
x x₀ : ℝ
n : ℕ
hx : x₀ < x
hf : ContDiffOn ℝ (↑n) f (Icc x₀ x)
hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc x₀ x)) (Ioo x₀ x)
gcont : ContinuousOn id (Icc x₀ x)
⊢ ∃ x' x_1,
    f x - taylorWithinEval f n (Icc x₀ x) x₀ x =
      iteratedDerivWithin (n + 1) f (Icc x₀ x) x' * (x - x') ^ n / ↑n ! * (x - x₀)
[PROOFSTEP]
have gdiff : ∀ x_1 : ℝ, x_1 ∈ Ioo x₀ x → HasDerivAt id ((fun _ : ℝ => (1 : ℝ)) x_1) x_1 := fun _ _ =>
  hasDerivAt_id
    _
      -- We apply the general theorem with g = id
[GOAL]
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → ℝ
x x₀ : ℝ
n : ℕ
hx : x₀ < x
hf : ContDiffOn ℝ (↑n) f (Icc x₀ x)
hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc x₀ x)) (Ioo x₀ x)
gcont : ContinuousOn id (Icc x₀ x)
gdiff : ∀ (x_1 : ℝ), x_1 ∈ Ioo x₀ x → HasDerivAt id ((fun x => 1) x_1) x_1
⊢ ∃ x' x_1,
    f x - taylorWithinEval f n (Icc x₀ x) x₀ x =
      iteratedDerivWithin (n + 1) f (Icc x₀ x) x' * (x - x') ^ n / ↑n ! * (x - x₀)
[PROOFSTEP]
rcases taylor_mean_remainder hx hf hf' gcont gdiff fun _ _ => by simp with ⟨y, hy, h⟩
[GOAL]
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → ℝ
x x₀ : ℝ
n : ℕ
hx : x₀ < x
hf : ContDiffOn ℝ (↑n) f (Icc x₀ x)
hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc x₀ x)) (Ioo x₀ x)
gcont : ContinuousOn id (Icc x₀ x)
gdiff : ∀ (x_1 : ℝ), x_1 ∈ Ioo x₀ x → HasDerivAt id ((fun x => 1) x_1) x_1
x✝¹ : ℝ
x✝ : x✝¹ ∈ Ioo x₀ x
⊢ (fun x => 1) x✝¹ ≠ 0
[PROOFSTEP]
simp
[GOAL]
case intro.intro
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → ℝ
x x₀ : ℝ
n : ℕ
hx : x₀ < x
hf : ContDiffOn ℝ (↑n) f (Icc x₀ x)
hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc x₀ x)) (Ioo x₀ x)
gcont : ContinuousOn id (Icc x₀ x)
gdiff : ∀ (x_1 : ℝ), x_1 ∈ Ioo x₀ x → HasDerivAt id ((fun x => 1) x_1) x_1
y : ℝ
hy : y ∈ Ioo x₀ x
h :
  f x - taylorWithinEval f n (Icc x₀ x) x₀ x =
    ((x - y) ^ n / ↑n ! * (id x - id x₀) / (fun x => 1) y) • iteratedDerivWithin (n + 1) f (Icc x₀ x) y
⊢ ∃ x' x_1,
    f x - taylorWithinEval f n (Icc x₀ x) x₀ x =
      iteratedDerivWithin (n + 1) f (Icc x₀ x) x' * (x - x') ^ n / ↑n ! * (x - x₀)
[PROOFSTEP]
use y, hy
[GOAL]
case h
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → ℝ
x x₀ : ℝ
n : ℕ
hx : x₀ < x
hf : ContDiffOn ℝ (↑n) f (Icc x₀ x)
hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc x₀ x)) (Ioo x₀ x)
gcont : ContinuousOn id (Icc x₀ x)
gdiff : ∀ (x_1 : ℝ), x_1 ∈ Ioo x₀ x → HasDerivAt id ((fun x => 1) x_1) x_1
y : ℝ
hy : y ∈ Ioo x₀ x
h :
  f x - taylorWithinEval f n (Icc x₀ x) x₀ x =
    ((x - y) ^ n / ↑n ! * (id x - id x₀) / (fun x => 1) y) • iteratedDerivWithin (n + 1) f (Icc x₀ x) y
⊢ f x - taylorWithinEval f n (Icc x₀ x) x₀ x =
    iteratedDerivWithin (n + 1) f (Icc x₀ x) y * (x - y) ^ n / ↑n ! * (x - x₀)
[PROOFSTEP]
rw [h]
[GOAL]
case h
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → ℝ
x x₀ : ℝ
n : ℕ
hx : x₀ < x
hf : ContDiffOn ℝ (↑n) f (Icc x₀ x)
hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc x₀ x)) (Ioo x₀ x)
gcont : ContinuousOn id (Icc x₀ x)
gdiff : ∀ (x_1 : ℝ), x_1 ∈ Ioo x₀ x → HasDerivAt id ((fun x => 1) x_1) x_1
y : ℝ
hy : y ∈ Ioo x₀ x
h :
  f x - taylorWithinEval f n (Icc x₀ x) x₀ x =
    ((x - y) ^ n / ↑n ! * (id x - id x₀) / (fun x => 1) y) • iteratedDerivWithin (n + 1) f (Icc x₀ x) y
⊢ ((x - y) ^ n / ↑n ! * (id x - id x₀) / (fun x => 1) y) • iteratedDerivWithin (n + 1) f (Icc x₀ x) y =
    iteratedDerivWithin (n + 1) f (Icc x₀ x) y * (x - y) ^ n / ↑n ! * (x - x₀)
[PROOFSTEP]
field_simp [n.factorial_ne_zero]
[GOAL]
case h
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → ℝ
x x₀ : ℝ
n : ℕ
hx : x₀ < x
hf : ContDiffOn ℝ (↑n) f (Icc x₀ x)
hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc x₀ x)) (Ioo x₀ x)
gcont : ContinuousOn id (Icc x₀ x)
gdiff : ∀ (x_1 : ℝ), x_1 ∈ Ioo x₀ x → HasDerivAt id ((fun x => 1) x_1) x_1
y : ℝ
hy : y ∈ Ioo x₀ x
h :
  f x - taylorWithinEval f n (Icc x₀ x) x₀ x =
    ((x - y) ^ n / ↑n ! * (id x - id x₀) / (fun x => 1) y) • iteratedDerivWithin (n + 1) f (Icc x₀ x) y
⊢ (x - y) ^ n * (x - x₀) * iteratedDerivWithin (n + 1) f (Icc x₀ x) y =
    iteratedDerivWithin (n + 1) f (Icc x₀ x) y * (x - y) ^ n * (x - x₀)
[PROOFSTEP]
ring
[GOAL]
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
a b C x : ℝ
n : ℕ
hab : a ≤ b
hf : ContDiffOn ℝ (↑n + 1) f (Icc a b)
hx : x ∈ Icc a b
hC : ∀ (y : ℝ), y ∈ Icc a b → ‖iteratedDerivWithin (n + 1) f (Icc a b) y‖ ≤ C
⊢ ‖f x - taylorWithinEval f n (Icc a b) a x‖ ≤ C * (x - a) ^ (n + 1) / ↑n !
[PROOFSTEP]
rcases eq_or_lt_of_le hab with (rfl | h)
[GOAL]
case inl
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
a C x : ℝ
n : ℕ
hab : a ≤ a
hf : ContDiffOn ℝ (↑n + 1) f (Icc a a)
hx : x ∈ Icc a a
hC : ∀ (y : ℝ), y ∈ Icc a a → ‖iteratedDerivWithin (n + 1) f (Icc a a) y‖ ≤ C
⊢ ‖f x - taylorWithinEval f n (Icc a a) a x‖ ≤ C * (x - a) ^ (n + 1) / ↑n !
[PROOFSTEP]
rw [Icc_self, mem_singleton_iff] at hx
[GOAL]
case inl
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
a C x : ℝ
n : ℕ
hab : a ≤ a
hf : ContDiffOn ℝ (↑n + 1) f (Icc a a)
hx : x = a
hC : ∀ (y : ℝ), y ∈ Icc a a → ‖iteratedDerivWithin (n + 1) f (Icc a a) y‖ ≤ C
⊢ ‖f x - taylorWithinEval f n (Icc a a) a x‖ ≤ C * (x - a) ^ (n + 1) / ↑n !
[PROOFSTEP]
simp [hx]
  -- The nth iterated derivative is differentiable
[GOAL]
case inr
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
a b C x : ℝ
n : ℕ
hab : a ≤ b
hf : ContDiffOn ℝ (↑n + 1) f (Icc a b)
hx : x ∈ Icc a b
hC : ∀ (y : ℝ), y ∈ Icc a b → ‖iteratedDerivWithin (n + 1) f (Icc a b) y‖ ≤ C
h : a < b
⊢ ‖f x - taylorWithinEval f n (Icc a b) a x‖ ≤ C * (x - a) ^ (n + 1) / ↑n !
[PROOFSTEP]
have hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc a b)) (Icc a b) :=
  hf.differentiableOn_iteratedDerivWithin (WithTop.coe_lt_coe.mpr n.lt_succ_self)
    (uniqueDiffOn_Icc h)
      -- We can uniformly bound the derivative of the Taylor polynomial
[GOAL]
case inr
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
a b C x : ℝ
n : ℕ
hab : a ≤ b
hf : ContDiffOn ℝ (↑n + 1) f (Icc a b)
hx : x ∈ Icc a b
hC : ∀ (y : ℝ), y ∈ Icc a b → ‖iteratedDerivWithin (n + 1) f (Icc a b) y‖ ≤ C
h : a < b
hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc a b)) (Icc a b)
⊢ ‖f x - taylorWithinEval f n (Icc a b) a x‖ ≤ C * (x - a) ^ (n + 1) / ↑n !
[PROOFSTEP]
have h' :
  ∀ (y : ℝ) (_ : y ∈ Ico a x),
    ‖((n ! : ℝ)⁻¹ * (x - y) ^ n) • iteratedDerivWithin (n + 1) f (Icc a b) y‖ ≤ (n ! : ℝ)⁻¹ * |x - a| ^ n * C :=
  by
  rintro y ⟨hay, hyx⟩
  rw [norm_smul, Real.norm_eq_abs]
    -- Estimate the iterated derivative by `C`
  refine'
    mul_le_mul _ (hC y ⟨hay, hyx.le.trans hx.2⟩) (by positivity)
      (by positivity)
        -- The rest is a trivial calculation
  rw [abs_mul, abs_pow, abs_inv, Nat.abs_cast]
    -- Porting note: was `mono* with 0 ≤ (n ! : ℝ)⁻¹; any_goals positivity; linarith [hx.1, hyx]`
  gcongr
  rw [abs_of_nonneg, abs_of_nonneg] <;>
    linarith
      -- Apply the mean value theorem for vector valued functions:
[GOAL]
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
a b C x : ℝ
n : ℕ
hab : a ≤ b
hf : ContDiffOn ℝ (↑n + 1) f (Icc a b)
hx : x ∈ Icc a b
hC : ∀ (y : ℝ), y ∈ Icc a b → ‖iteratedDerivWithin (n + 1) f (Icc a b) y‖ ≤ C
h : a < b
hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc a b)) (Icc a b)
⊢ ∀ (y : ℝ),
    y ∈ Ico a x → ‖((↑n !)⁻¹ * (x - y) ^ n) • iteratedDerivWithin (n + 1) f (Icc a b) y‖ ≤ (↑n !)⁻¹ * |x - a| ^ n * C
[PROOFSTEP]
rintro y ⟨hay, hyx⟩
[GOAL]
case intro
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
a b C x : ℝ
n : ℕ
hab : a ≤ b
hf : ContDiffOn ℝ (↑n + 1) f (Icc a b)
hx : x ∈ Icc a b
hC : ∀ (y : ℝ), y ∈ Icc a b → ‖iteratedDerivWithin (n + 1) f (Icc a b) y‖ ≤ C
h : a < b
hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc a b)) (Icc a b)
y : ℝ
hay : a ≤ y
hyx : y < x
⊢ ‖((↑n !)⁻¹ * (x - y) ^ n) • iteratedDerivWithin (n + 1) f (Icc a b) y‖ ≤ (↑n !)⁻¹ * |x - a| ^ n * C
[PROOFSTEP]
rw [norm_smul, Real.norm_eq_abs]
  -- Estimate the iterated derivative by `C`
[GOAL]
case intro
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
a b C x : ℝ
n : ℕ
hab : a ≤ b
hf : ContDiffOn ℝ (↑n + 1) f (Icc a b)
hx : x ∈ Icc a b
hC : ∀ (y : ℝ), y ∈ Icc a b → ‖iteratedDerivWithin (n + 1) f (Icc a b) y‖ ≤ C
h : a < b
hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc a b)) (Icc a b)
y : ℝ
hay : a ≤ y
hyx : y < x
⊢ |(↑n !)⁻¹ * (x - y) ^ n| * ‖iteratedDerivWithin (n + 1) f (Icc a b) y‖ ≤ (↑n !)⁻¹ * |x - a| ^ n * C
[PROOFSTEP]
refine'
  mul_le_mul _ (hC y ⟨hay, hyx.le.trans hx.2⟩) (by positivity)
    (by positivity)
      -- The rest is a trivial calculation
[GOAL]
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
a b C x : ℝ
n : ℕ
hab : a ≤ b
hf : ContDiffOn ℝ (↑n + 1) f (Icc a b)
hx : x ∈ Icc a b
hC : ∀ (y : ℝ), y ∈ Icc a b → ‖iteratedDerivWithin (n + 1) f (Icc a b) y‖ ≤ C
h : a < b
hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc a b)) (Icc a b)
y : ℝ
hay : a ≤ y
hyx : y < x
⊢ 0 ≤ ‖iteratedDerivWithin (n + 1) f (Icc a b) y‖
[PROOFSTEP]
positivity
[GOAL]
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
a b C x : ℝ
n : ℕ
hab : a ≤ b
hf : ContDiffOn ℝ (↑n + 1) f (Icc a b)
hx : x ∈ Icc a b
hC : ∀ (y : ℝ), y ∈ Icc a b → ‖iteratedDerivWithin (n + 1) f (Icc a b) y‖ ≤ C
h : a < b
hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc a b)) (Icc a b)
y : ℝ
hay : a ≤ y
hyx : y < x
⊢ 0 ≤ (↑n !)⁻¹ * |x - a| ^ n
[PROOFSTEP]
positivity
[GOAL]
case intro
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
a b C x : ℝ
n : ℕ
hab : a ≤ b
hf : ContDiffOn ℝ (↑n + 1) f (Icc a b)
hx : x ∈ Icc a b
hC : ∀ (y : ℝ), y ∈ Icc a b → ‖iteratedDerivWithin (n + 1) f (Icc a b) y‖ ≤ C
h : a < b
hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc a b)) (Icc a b)
y : ℝ
hay : a ≤ y
hyx : y < x
⊢ |(↑n !)⁻¹ * (x - y) ^ n| ≤ (↑n !)⁻¹ * |x - a| ^ n
[PROOFSTEP]
rw [abs_mul, abs_pow, abs_inv, Nat.abs_cast]
  -- Porting note: was `mono* with 0 ≤ (n ! : ℝ)⁻¹; any_goals positivity; linarith [hx.1, hyx]`
[GOAL]
case intro
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
a b C x : ℝ
n : ℕ
hab : a ≤ b
hf : ContDiffOn ℝ (↑n + 1) f (Icc a b)
hx : x ∈ Icc a b
hC : ∀ (y : ℝ), y ∈ Icc a b → ‖iteratedDerivWithin (n + 1) f (Icc a b) y‖ ≤ C
h : a < b
hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc a b)) (Icc a b)
y : ℝ
hay : a ≤ y
hyx : y < x
⊢ (↑n !)⁻¹ * |x - y| ^ n ≤ (↑n !)⁻¹ * |x - a| ^ n
[PROOFSTEP]
gcongr
[GOAL]
case intro.h.hab
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
a b C x : ℝ
n : ℕ
hab : a ≤ b
hf : ContDiffOn ℝ (↑n + 1) f (Icc a b)
hx : x ∈ Icc a b
hC : ∀ (y : ℝ), y ∈ Icc a b → ‖iteratedDerivWithin (n + 1) f (Icc a b) y‖ ≤ C
h : a < b
hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc a b)) (Icc a b)
y : ℝ
hay : a ≤ y
hyx : y < x
⊢ |x - y| ≤ |x - a|
[PROOFSTEP]
rw [abs_of_nonneg, abs_of_nonneg]
[GOAL]
case intro.h.hab
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
a b C x : ℝ
n : ℕ
hab : a ≤ b
hf : ContDiffOn ℝ (↑n + 1) f (Icc a b)
hx : x ∈ Icc a b
hC : ∀ (y : ℝ), y ∈ Icc a b → ‖iteratedDerivWithin (n + 1) f (Icc a b) y‖ ≤ C
h : a < b
hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc a b)) (Icc a b)
y : ℝ
hay : a ≤ y
hyx : y < x
⊢ x - y ≤ x - a
[PROOFSTEP]
linarith
  -- Apply the mean value theorem for vector valued functions:
[GOAL]
case intro.h.hab
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
a b C x : ℝ
n : ℕ
hab : a ≤ b
hf : ContDiffOn ℝ (↑n + 1) f (Icc a b)
hx : x ∈ Icc a b
hC : ∀ (y : ℝ), y ∈ Icc a b → ‖iteratedDerivWithin (n + 1) f (Icc a b) y‖ ≤ C
h : a < b
hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc a b)) (Icc a b)
y : ℝ
hay : a ≤ y
hyx : y < x
⊢ 0 ≤ x - a
[PROOFSTEP]
linarith
  -- Apply the mean value theorem for vector valued functions:
[GOAL]
case intro.h.hab
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
a b C x : ℝ
n : ℕ
hab : a ≤ b
hf : ContDiffOn ℝ (↑n + 1) f (Icc a b)
hx : x ∈ Icc a b
hC : ∀ (y : ℝ), y ∈ Icc a b → ‖iteratedDerivWithin (n + 1) f (Icc a b) y‖ ≤ C
h : a < b
hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc a b)) (Icc a b)
y : ℝ
hay : a ≤ y
hyx : y < x
⊢ 0 ≤ x - y
[PROOFSTEP]
linarith
  -- Apply the mean value theorem for vector valued functions:
[GOAL]
case inr
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
a b C x : ℝ
n : ℕ
hab : a ≤ b
hf : ContDiffOn ℝ (↑n + 1) f (Icc a b)
hx : x ∈ Icc a b
hC : ∀ (y : ℝ), y ∈ Icc a b → ‖iteratedDerivWithin (n + 1) f (Icc a b) y‖ ≤ C
h : a < b
hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc a b)) (Icc a b)
h' :
  ∀ (y : ℝ),
    y ∈ Ico a x → ‖((↑n !)⁻¹ * (x - y) ^ n) • iteratedDerivWithin (n + 1) f (Icc a b) y‖ ≤ (↑n !)⁻¹ * |x - a| ^ n * C
⊢ ‖f x - taylorWithinEval f n (Icc a b) a x‖ ≤ C * (x - a) ^ (n + 1) / ↑n !
[PROOFSTEP]
have A :
  ∀ t ∈ Icc a x,
    HasDerivWithinAt (fun y => taylorWithinEval f n (Icc a b) y x)
      (((↑n !)⁻¹ * (x - t) ^ n) • iteratedDerivWithin (n + 1) f (Icc a b) t) (Icc a x) t :=
  by
  intro t ht
  have I : Icc a x ⊆ Icc a b := Icc_subset_Icc_right hx.2
  exact (has_deriv_within_taylorWithinEval_at_Icc x h (I ht) hf.of_succ hf').mono I
[GOAL]
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
a b C x : ℝ
n : ℕ
hab : a ≤ b
hf : ContDiffOn ℝ (↑n + 1) f (Icc a b)
hx : x ∈ Icc a b
hC : ∀ (y : ℝ), y ∈ Icc a b → ‖iteratedDerivWithin (n + 1) f (Icc a b) y‖ ≤ C
h : a < b
hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc a b)) (Icc a b)
h' :
  ∀ (y : ℝ),
    y ∈ Ico a x → ‖((↑n !)⁻¹ * (x - y) ^ n) • iteratedDerivWithin (n + 1) f (Icc a b) y‖ ≤ (↑n !)⁻¹ * |x - a| ^ n * C
⊢ ∀ (t : ℝ),
    t ∈ Icc a x →
      HasDerivWithinAt (fun y => taylorWithinEval f n (Icc a b) y x)
        (((↑n !)⁻¹ * (x - t) ^ n) • iteratedDerivWithin (n + 1) f (Icc a b) t) (Icc a x) t
[PROOFSTEP]
intro t ht
[GOAL]
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
a b C x : ℝ
n : ℕ
hab : a ≤ b
hf : ContDiffOn ℝ (↑n + 1) f (Icc a b)
hx : x ∈ Icc a b
hC : ∀ (y : ℝ), y ∈ Icc a b → ‖iteratedDerivWithin (n + 1) f (Icc a b) y‖ ≤ C
h : a < b
hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc a b)) (Icc a b)
h' :
  ∀ (y : ℝ),
    y ∈ Ico a x → ‖((↑n !)⁻¹ * (x - y) ^ n) • iteratedDerivWithin (n + 1) f (Icc a b) y‖ ≤ (↑n !)⁻¹ * |x - a| ^ n * C
t : ℝ
ht : t ∈ Icc a x
⊢ HasDerivWithinAt (fun y => taylorWithinEval f n (Icc a b) y x)
    (((↑n !)⁻¹ * (x - t) ^ n) • iteratedDerivWithin (n + 1) f (Icc a b) t) (Icc a x) t
[PROOFSTEP]
have I : Icc a x ⊆ Icc a b := Icc_subset_Icc_right hx.2
[GOAL]
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
a b C x : ℝ
n : ℕ
hab : a ≤ b
hf : ContDiffOn ℝ (↑n + 1) f (Icc a b)
hx : x ∈ Icc a b
hC : ∀ (y : ℝ), y ∈ Icc a b → ‖iteratedDerivWithin (n + 1) f (Icc a b) y‖ ≤ C
h : a < b
hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc a b)) (Icc a b)
h' :
  ∀ (y : ℝ),
    y ∈ Ico a x → ‖((↑n !)⁻¹ * (x - y) ^ n) • iteratedDerivWithin (n + 1) f (Icc a b) y‖ ≤ (↑n !)⁻¹ * |x - a| ^ n * C
t : ℝ
ht : t ∈ Icc a x
I : Icc a x ⊆ Icc a b
⊢ HasDerivWithinAt (fun y => taylorWithinEval f n (Icc a b) y x)
    (((↑n !)⁻¹ * (x - t) ^ n) • iteratedDerivWithin (n + 1) f (Icc a b) t) (Icc a x) t
[PROOFSTEP]
exact (has_deriv_within_taylorWithinEval_at_Icc x h (I ht) hf.of_succ hf').mono I
[GOAL]
case inr
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
a b C x : ℝ
n : ℕ
hab : a ≤ b
hf : ContDiffOn ℝ (↑n + 1) f (Icc a b)
hx : x ∈ Icc a b
hC : ∀ (y : ℝ), y ∈ Icc a b → ‖iteratedDerivWithin (n + 1) f (Icc a b) y‖ ≤ C
h : a < b
hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc a b)) (Icc a b)
h' :
  ∀ (y : ℝ),
    y ∈ Ico a x → ‖((↑n !)⁻¹ * (x - y) ^ n) • iteratedDerivWithin (n + 1) f (Icc a b) y‖ ≤ (↑n !)⁻¹ * |x - a| ^ n * C
A :
  ∀ (t : ℝ),
    t ∈ Icc a x →
      HasDerivWithinAt (fun y => taylorWithinEval f n (Icc a b) y x)
        (((↑n !)⁻¹ * (x - t) ^ n) • iteratedDerivWithin (n + 1) f (Icc a b) t) (Icc a x) t
⊢ ‖f x - taylorWithinEval f n (Icc a b) a x‖ ≤ C * (x - a) ^ (n + 1) / ↑n !
[PROOFSTEP]
have := norm_image_sub_le_of_norm_deriv_le_segment' A h' x (right_mem_Icc.2 hx.1)
[GOAL]
case inr
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
a b C x : ℝ
n : ℕ
hab : a ≤ b
hf : ContDiffOn ℝ (↑n + 1) f (Icc a b)
hx : x ∈ Icc a b
hC : ∀ (y : ℝ), y ∈ Icc a b → ‖iteratedDerivWithin (n + 1) f (Icc a b) y‖ ≤ C
h : a < b
hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc a b)) (Icc a b)
h' :
  ∀ (y : ℝ),
    y ∈ Ico a x → ‖((↑n !)⁻¹ * (x - y) ^ n) • iteratedDerivWithin (n + 1) f (Icc a b) y‖ ≤ (↑n !)⁻¹ * |x - a| ^ n * C
A :
  ∀ (t : ℝ),
    t ∈ Icc a x →
      HasDerivWithinAt (fun y => taylorWithinEval f n (Icc a b) y x)
        (((↑n !)⁻¹ * (x - t) ^ n) • iteratedDerivWithin (n + 1) f (Icc a b) t) (Icc a x) t
this : ‖taylorWithinEval f n (Icc a b) x x - taylorWithinEval f n (Icc a b) a x‖ ≤ (↑n !)⁻¹ * |x - a| ^ n * C * (x - a)
⊢ ‖f x - taylorWithinEval f n (Icc a b) a x‖ ≤ C * (x - a) ^ (n + 1) / ↑n !
[PROOFSTEP]
simp only [taylorWithinEval_self] at this
[GOAL]
case inr
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
a b C x : ℝ
n : ℕ
hab : a ≤ b
hf : ContDiffOn ℝ (↑n + 1) f (Icc a b)
hx : x ∈ Icc a b
hC : ∀ (y : ℝ), y ∈ Icc a b → ‖iteratedDerivWithin (n + 1) f (Icc a b) y‖ ≤ C
h : a < b
hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc a b)) (Icc a b)
h' :
  ∀ (y : ℝ),
    y ∈ Ico a x → ‖((↑n !)⁻¹ * (x - y) ^ n) • iteratedDerivWithin (n + 1) f (Icc a b) y‖ ≤ (↑n !)⁻¹ * |x - a| ^ n * C
A :
  ∀ (t : ℝ),
    t ∈ Icc a x →
      HasDerivWithinAt (fun y => taylorWithinEval f n (Icc a b) y x)
        (((↑n !)⁻¹ * (x - t) ^ n) • iteratedDerivWithin (n + 1) f (Icc a b) t) (Icc a x) t
this : ‖f x - taylorWithinEval f n (Icc a b) a x‖ ≤ (↑n !)⁻¹ * |x - a| ^ n * C * (x - a)
⊢ ‖f x - taylorWithinEval f n (Icc a b) a x‖ ≤ C * (x - a) ^ (n + 1) / ↑n !
[PROOFSTEP]
refine'
  this.trans_eq
    _
      -- The rest is a trivial calculation
[GOAL]
case inr
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
a b C x : ℝ
n : ℕ
hab : a ≤ b
hf : ContDiffOn ℝ (↑n + 1) f (Icc a b)
hx : x ∈ Icc a b
hC : ∀ (y : ℝ), y ∈ Icc a b → ‖iteratedDerivWithin (n + 1) f (Icc a b) y‖ ≤ C
h : a < b
hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc a b)) (Icc a b)
h' :
  ∀ (y : ℝ),
    y ∈ Ico a x → ‖((↑n !)⁻¹ * (x - y) ^ n) • iteratedDerivWithin (n + 1) f (Icc a b) y‖ ≤ (↑n !)⁻¹ * |x - a| ^ n * C
A :
  ∀ (t : ℝ),
    t ∈ Icc a x →
      HasDerivWithinAt (fun y => taylorWithinEval f n (Icc a b) y x)
        (((↑n !)⁻¹ * (x - t) ^ n) • iteratedDerivWithin (n + 1) f (Icc a b) t) (Icc a x) t
this : ‖f x - taylorWithinEval f n (Icc a b) a x‖ ≤ (↑n !)⁻¹ * |x - a| ^ n * C * (x - a)
⊢ (↑n !)⁻¹ * |x - a| ^ n * C * (x - a) = C * (x - a) ^ (n + 1) / ↑n !
[PROOFSTEP]
rw [abs_of_nonneg (sub_nonneg.mpr hx.1)]
[GOAL]
case inr
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
a b C x : ℝ
n : ℕ
hab : a ≤ b
hf : ContDiffOn ℝ (↑n + 1) f (Icc a b)
hx : x ∈ Icc a b
hC : ∀ (y : ℝ), y ∈ Icc a b → ‖iteratedDerivWithin (n + 1) f (Icc a b) y‖ ≤ C
h : a < b
hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc a b)) (Icc a b)
h' :
  ∀ (y : ℝ),
    y ∈ Ico a x → ‖((↑n !)⁻¹ * (x - y) ^ n) • iteratedDerivWithin (n + 1) f (Icc a b) y‖ ≤ (↑n !)⁻¹ * |x - a| ^ n * C
A :
  ∀ (t : ℝ),
    t ∈ Icc a x →
      HasDerivWithinAt (fun y => taylorWithinEval f n (Icc a b) y x)
        (((↑n !)⁻¹ * (x - t) ^ n) • iteratedDerivWithin (n + 1) f (Icc a b) t) (Icc a x) t
this : ‖f x - taylorWithinEval f n (Icc a b) a x‖ ≤ (↑n !)⁻¹ * |x - a| ^ n * C * (x - a)
⊢ (↑n !)⁻¹ * (x - a) ^ n * C * (x - a) = C * (x - a) ^ (n + 1) / ↑n !
[PROOFSTEP]
ring
[GOAL]
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
a b : ℝ
n : ℕ
hab : a ≤ b
hf : ContDiffOn ℝ (↑n + 1) f (Icc a b)
⊢ ∃ C, ∀ (x : ℝ), x ∈ Icc a b → ‖f x - taylorWithinEval f n (Icc a b) a x‖ ≤ C * (x - a) ^ (n + 1)
[PROOFSTEP]
rcases eq_or_lt_of_le hab with (rfl | h)
[GOAL]
case inl
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
a : ℝ
n : ℕ
hab : a ≤ a
hf : ContDiffOn ℝ (↑n + 1) f (Icc a a)
⊢ ∃ C, ∀ (x : ℝ), x ∈ Icc a a → ‖f x - taylorWithinEval f n (Icc a a) a x‖ ≤ C * (x - a) ^ (n + 1)
[PROOFSTEP]
refine' ⟨0, fun x hx => _⟩
[GOAL]
case inl
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
a : ℝ
n : ℕ
hab : a ≤ a
hf : ContDiffOn ℝ (↑n + 1) f (Icc a a)
x : ℝ
hx : x ∈ Icc a a
⊢ ‖f x - taylorWithinEval f n (Icc a a) a x‖ ≤ 0 * (x - a) ^ (n + 1)
[PROOFSTEP]
have : x = a := by simpa [← le_antisymm_iff] using hx
[GOAL]
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
a : ℝ
n : ℕ
hab : a ≤ a
hf : ContDiffOn ℝ (↑n + 1) f (Icc a a)
x : ℝ
hx : x ∈ Icc a a
⊢ x = a
[PROOFSTEP]
simpa [← le_antisymm_iff] using hx
[GOAL]
case inl
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
a : ℝ
n : ℕ
hab : a ≤ a
hf : ContDiffOn ℝ (↑n + 1) f (Icc a a)
x : ℝ
hx : x ∈ Icc a a
this : x = a
⊢ ‖f x - taylorWithinEval f n (Icc a a) a x‖ ≤ 0 * (x - a) ^ (n + 1)
[PROOFSTEP]
simp [← this]
  -- We estimate by the supremum of the norm of the iterated derivative
[GOAL]
case inr
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
a b : ℝ
n : ℕ
hab : a ≤ b
hf : ContDiffOn ℝ (↑n + 1) f (Icc a b)
h : a < b
⊢ ∃ C, ∀ (x : ℝ), x ∈ Icc a b → ‖f x - taylorWithinEval f n (Icc a b) a x‖ ≤ C * (x - a) ^ (n + 1)
[PROOFSTEP]
let g : ℝ → ℝ := fun y => ‖iteratedDerivWithin (n + 1) f (Icc a b) y‖
[GOAL]
case inr
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
a b : ℝ
n : ℕ
hab : a ≤ b
hf : ContDiffOn ℝ (↑n + 1) f (Icc a b)
h : a < b
g : ℝ → ℝ := fun y => ‖iteratedDerivWithin (n + 1) f (Icc a b) y‖
⊢ ∃ C, ∀ (x : ℝ), x ∈ Icc a b → ‖f x - taylorWithinEval f n (Icc a b) a x‖ ≤ C * (x - a) ^ (n + 1)
[PROOFSTEP]
use SupSet.sSup (g '' Icc a b) / (n !)
[GOAL]
case h
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
a b : ℝ
n : ℕ
hab : a ≤ b
hf : ContDiffOn ℝ (↑n + 1) f (Icc a b)
h : a < b
g : ℝ → ℝ := fun y => ‖iteratedDerivWithin (n + 1) f (Icc a b) y‖
⊢ ∀ (x : ℝ), x ∈ Icc a b → ‖f x - taylorWithinEval f n (Icc a b) a x‖ ≤ sSup (g '' Icc a b) / ↑n ! * (x - a) ^ (n + 1)
[PROOFSTEP]
intro x hx
[GOAL]
case h
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
a b : ℝ
n : ℕ
hab : a ≤ b
hf : ContDiffOn ℝ (↑n + 1) f (Icc a b)
h : a < b
g : ℝ → ℝ := fun y => ‖iteratedDerivWithin (n + 1) f (Icc a b) y‖
x : ℝ
hx : x ∈ Icc a b
⊢ ‖f x - taylorWithinEval f n (Icc a b) a x‖ ≤ sSup (g '' Icc a b) / ↑n ! * (x - a) ^ (n + 1)
[PROOFSTEP]
rw [div_mul_eq_mul_div₀]
[GOAL]
case h
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
a b : ℝ
n : ℕ
hab : a ≤ b
hf : ContDiffOn ℝ (↑n + 1) f (Icc a b)
h : a < b
g : ℝ → ℝ := fun y => ‖iteratedDerivWithin (n + 1) f (Icc a b) y‖
x : ℝ
hx : x ∈ Icc a b
⊢ ‖f x - taylorWithinEval f n (Icc a b) a x‖ ≤ sSup (g '' Icc a b) * (x - a) ^ (n + 1) / ↑n !
[PROOFSTEP]
refine' taylor_mean_remainder_bound hab hf hx fun y => _
[GOAL]
case h
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
f : ℝ → E
a b : ℝ
n : ℕ
hab : a ≤ b
hf : ContDiffOn ℝ (↑n + 1) f (Icc a b)
h : a < b
g : ℝ → ℝ := fun y => ‖iteratedDerivWithin (n + 1) f (Icc a b) y‖
x : ℝ
hx : x ∈ Icc a b
y : ℝ
⊢ y ∈ Icc a b → ‖iteratedDerivWithin (n + 1) f (Icc a b) y‖ ≤ sSup (g '' Icc a b)
[PROOFSTEP]
exact (hf.continuousOn_iteratedDerivWithin rfl.le <| uniqueDiffOn_Icc h).norm.le_sSup_image_Icc


[GOAL]
n : ℕ
h : n ≠ 0
d m : ℕ
⊢ ((fun a => a + d) ∘ fun x => n • id x) m ≡ d [MOD n]
[PROOFSTEP]
simp [Nat.modEq_iff_dvd, ← sub_sub]
[GOAL]
d n : ℕ
h : d < n
⊢ ∃ᶠ (m : ℕ) in atTop, m % n = d
[PROOFSTEP]
simpa only [Nat.ModEq, mod_eq_of_lt h] using frequently_modEq h.ne_bot d
[GOAL]
⊢ ∃ᶠ (m : ℕ) in atTop, Even m
[PROOFSTEP]
simpa only [even_iff] using frequently_mod_eq zero_lt_two
[GOAL]
⊢ ∃ᶠ (m : ℕ) in atTop, Odd m
[PROOFSTEP]
simpa only [odd_iff] using frequently_mod_eq one_lt_two


[GOAL]
α : Type u_1
inst✝ : DivisionRing α
src✝² : DivisionSemiring αᵐᵒᵖ := divisionSemiring α
src✝¹ : Ring αᵐᵒᵖ := ring α
src✝ : RatCast αᵐᵒᵖ := ratCast α
a : ℤ
b : ℕ
hb : b ≠ 0
h : Nat.coprime (Int.natAbs a) b
⊢ unop ↑(Rat.mk' a b) = unop (↑a * (↑b)⁻¹)
[PROOFSTEP]
rw [unop_ratCast, Rat.cast_def, unop_mul, unop_inv, unop_natCast, unop_intCast, Int.commute_cast, div_eq_mul_inv]
[GOAL]
α : Type ?u.3697
inst✝ : DivisionRing α
src✝² : Ring αᵃᵒᵖ := ring α
src✝¹ : GroupWithZero αᵃᵒᵖ := groupWithZero α
src✝ : RatCast αᵃᵒᵖ := ratCast α
a : ℤ
b : ℕ
hb : b ≠ 0
h : Nat.coprime (Int.natAbs a) b
⊢ unop ↑(Rat.mk' a b) = unop (↑a * (↑b)⁻¹)
[PROOFSTEP]
rw [unop_ratCast, Rat.cast_def, unop_mul, unop_inv, unop_natCast, unop_intCast, div_eq_mul_inv]


[GOAL]
R : Type u_1
V : Type u_2
P : Type u_3
inst✝⁴ : DivisionRing R
inst✝³ : CharZero R
inst✝² : AddCommGroup V
inst✝¹ : Module R V
inst✝ : AddTorsor V P
a b : P
⊢ ↑(lineMap a b) (1 / 2) = midpoint R a b
[PROOFSTEP]
rw [one_div, lineMap_inv_two]
[GOAL]
k : Type u_1
V : Type u_2
P : Type u_3
inst✝⁴ : Field k
inst✝³ : CharZero k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AddTorsor V P
a b : P
⊢ ↑(homothety a (1 / 2)) b = midpoint k a b
[PROOFSTEP]
rw [one_div, homothety_inv_two]


[GOAL]
n k : ℕ
⊢ List.toFinset (factors (n ^ (k + 1))) = List.toFinset (factors n)
[PROOFSTEP]
rcases eq_or_ne n 0 with (rfl | hn)
[GOAL]
case inl
k : ℕ
⊢ List.toFinset (factors (0 ^ (k + 1))) = List.toFinset (factors 0)
[PROOFSTEP]
simp
[GOAL]
case inr
n k : ℕ
hn : n ≠ 0
⊢ List.toFinset (factors (n ^ (k + 1))) = List.toFinset (factors n)
[PROOFSTEP]
induction' k with k ih
[GOAL]
case inr.zero
n : ℕ
hn : n ≠ 0
⊢ List.toFinset (factors (n ^ (zero + 1))) = List.toFinset (factors n)
[PROOFSTEP]
simp
[GOAL]
case inr.succ
n : ℕ
hn : n ≠ 0
k : ℕ
ih : List.toFinset (factors (n ^ (k + 1))) = List.toFinset (factors n)
⊢ List.toFinset (factors (n ^ (succ k + 1))) = List.toFinset (factors n)
[PROOFSTEP]
rw [pow_succ', factors_mul_toFinset hn (pow_ne_zero _ hn), ih, Finset.union_idempotent]
[GOAL]
n k : ℕ
hk : k ≠ 0
⊢ List.toFinset (factors (n ^ k)) = List.toFinset (factors n)
[PROOFSTEP]
cases k
[GOAL]
case zero
n : ℕ
hk : zero ≠ 0
⊢ List.toFinset (factors (n ^ zero)) = List.toFinset (factors n)
[PROOFSTEP]
simp at hk
[GOAL]
case succ
n n✝ : ℕ
hk : succ n✝ ≠ 0
⊢ List.toFinset (factors (n ^ succ n✝)) = List.toFinset (factors n)
[PROOFSTEP]
rw [pow_succ_factors_toFinset]
[GOAL]
p k : ℕ
hk : k ≠ 0
hp : Prime p
⊢ List.toFinset (factors (p ^ k)) = {p}
[PROOFSTEP]
simp [pow_factors_toFinset p hk, factors_prime hp]


[GOAL]
α : Type u_1
inst✝ : OrderedSemiring α
x : ↑(Icc 0 1)
⊢ ↑x = 0 ↔ x = 0
[PROOFSTEP]
symm
[GOAL]
α : Type u_1
inst✝ : OrderedSemiring α
x : ↑(Icc 0 1)
⊢ x = 0 ↔ ↑x = 0
[PROOFSTEP]
exact Subtype.ext_iff
[GOAL]
α : Type u_1
inst✝ : OrderedSemiring α
x : ↑(Icc 0 1)
⊢ ↑x = 1 ↔ x = 1
[PROOFSTEP]
symm
[GOAL]
α : Type u_1
inst✝ : OrderedSemiring α
x : ↑(Icc 0 1)
⊢ x = 1 ↔ ↑x = 1
[PROOFSTEP]
exact Subtype.ext_iff
[GOAL]
α : Type u_1
inst✝¹ : OrderedSemiring α
β : Type u_2
inst✝ : OrderedRing β
t : β
ht : t ∈ Icc 0 1
⊢ 1 - t ∈ Icc 0 1
[PROOFSTEP]
rw [mem_Icc] at *
[GOAL]
α : Type u_1
inst✝¹ : OrderedSemiring α
β : Type u_2
inst✝ : OrderedRing β
t : β
ht : 0 ≤ t ∧ t ≤ 1
⊢ 0 ≤ 1 - t ∧ 1 - t ≤ 1
[PROOFSTEP]
exact ⟨sub_nonneg.2 ht.2, (sub_le_self_iff _).2 ht.1⟩
[GOAL]
α : Type u_1
inst✝¹ : OrderedSemiring α
β : Type u_2
inst✝ : OrderedRing β
x : ↑(Icc 0 1)
⊢ 0 ≤ 1 - ↑x
[PROOFSTEP]
simpa using x.2.2
[GOAL]
α : Type u_1
inst✝¹ : OrderedSemiring α
β : Type u_2
inst✝ : OrderedRing β
x : ↑(Icc 0 1)
⊢ 1 - ↑x ≤ 1
[PROOFSTEP]
simpa using x.2.1
[GOAL]
α : Type u_1
inst✝¹ : OrderedSemiring α
inst✝ : Nontrivial α
x : ↑(Ico 0 1)
⊢ ↑x = 0 ↔ x = 0
[PROOFSTEP]
symm
[GOAL]
α : Type u_1
inst✝¹ : OrderedSemiring α
inst✝ : Nontrivial α
x : ↑(Ico 0 1)
⊢ x = 0 ↔ ↑x = 0
[PROOFSTEP]
exact Subtype.ext_iff
[GOAL]
α : Type u_1
inst✝¹ : StrictOrderedSemiring α
inst✝ : Nontrivial α
x : ↑(Ioc 0 1)
⊢ ↑x = 1 ↔ x = 1
[PROOFSTEP]
symm
[GOAL]
α : Type u_1
inst✝¹ : StrictOrderedSemiring α
inst✝ : Nontrivial α
x : ↑(Ioc 0 1)
⊢ x = 1 ↔ ↑x = 1
[PROOFSTEP]
exact Subtype.ext_iff
[GOAL]
α : Type u_1
inst✝¹ : StrictOrderedSemiring α
β : Type u_2
inst✝ : OrderedRing β
t : β
ht : t ∈ Ioo 0 1
⊢ 1 - t ∈ Ioo 0 1
[PROOFSTEP]
rw [mem_Ioo] at *
[GOAL]
α : Type u_1
inst✝¹ : StrictOrderedSemiring α
β : Type u_2
inst✝ : OrderedRing β
t : β
ht : 0 < t ∧ t < 1
⊢ 0 < 1 - t ∧ 1 - t < 1
[PROOFSTEP]
refine' ⟨sub_pos.2 ht.2, _⟩
[GOAL]
α : Type u_1
inst✝¹ : StrictOrderedSemiring α
β : Type u_2
inst✝ : OrderedRing β
t : β
ht : 0 < t ∧ t < 1
⊢ 1 - t < 1
[PROOFSTEP]
exact lt_of_le_of_ne ((sub_le_self_iff 1).2 ht.1.le) (mt sub_eq_self.mp ht.1.ne')
[GOAL]
α : Type u_1
inst✝¹ : StrictOrderedSemiring α
β : Type u_2
inst✝ : OrderedRing β
x : ↑(Ioo 0 1)
⊢ 0 < 1 - ↑x
[PROOFSTEP]
simpa using x.2.2
[GOAL]
α : Type u_1
inst✝¹ : StrictOrderedSemiring α
β : Type u_2
inst✝ : OrderedRing β
x : ↑(Ioo 0 1)
⊢ 1 - ↑x < 1
[PROOFSTEP]
simpa using x.2.1


[GOAL]
x y : ℂ
⊢ SameRay ℝ x y ↔ x = 0 ∨ y = 0 ∨ arg x = arg y
[PROOFSTEP]
rcases eq_or_ne x 0 with (rfl | hx)
[GOAL]
case inl
y : ℂ
⊢ SameRay ℝ 0 y ↔ 0 = 0 ∨ y = 0 ∨ arg 0 = arg y
[PROOFSTEP]
simp
[GOAL]
case inr
x y : ℂ
hx : x ≠ 0
⊢ SameRay ℝ x y ↔ x = 0 ∨ y = 0 ∨ arg x = arg y
[PROOFSTEP]
rcases eq_or_ne y 0 with (rfl | hy)
[GOAL]
case inr.inl
x : ℂ
hx : x ≠ 0
⊢ SameRay ℝ x 0 ↔ x = 0 ∨ 0 = 0 ∨ arg x = arg 0
[PROOFSTEP]
simp
[GOAL]
case inr.inr
x y : ℂ
hx : x ≠ 0
hy : y ≠ 0
⊢ SameRay ℝ x y ↔ x = 0 ∨ y = 0 ∨ arg x = arg y
[PROOFSTEP]
simp only [hx, hy, false_or_iff, sameRay_iff_norm_smul_eq, arg_eq_arg_iff hx hy]
[GOAL]
case inr.inr
x y : ℂ
hx : x ≠ 0
hy : y ≠ 0
⊢ ‖x‖ • y = ‖y‖ • x ↔ ↑(↑abs y) / ↑(↑abs x) * x = y
[PROOFSTEP]
field_simp [hx, hy]
[GOAL]
case inr.inr
x y : ℂ
hx : x ≠ 0
hy : y ≠ 0
⊢ ↑(↑abs x) * y = ↑(↑abs y) * x ↔ ↑(↑abs y) * x = y * ↑(↑abs x)
[PROOFSTEP]
rw [mul_comm, eq_comm]
[GOAL]
x y : ℂ
⊢ SameRay ℝ x y ↔ arg (x / y) = 0
[PROOFSTEP]
rw [← Real.Angle.toReal_zero, ← arg_coe_angle_eq_iff_eq_toReal, sameRay_iff]
[GOAL]
x y : ℂ
⊢ x = 0 ∨ y = 0 ∨ arg x = arg y ↔ ↑(arg (x / y)) = 0
[PROOFSTEP]
by_cases hx : x = 0
[GOAL]
case pos
x y : ℂ
hx : x = 0
⊢ x = 0 ∨ y = 0 ∨ arg x = arg y ↔ ↑(arg (x / y)) = 0
[PROOFSTEP]
simp [hx]
[GOAL]
case neg
x y : ℂ
hx : ¬x = 0
⊢ x = 0 ∨ y = 0 ∨ arg x = arg y ↔ ↑(arg (x / y)) = 0
[PROOFSTEP]
by_cases hy : y = 0
[GOAL]
case pos
x y : ℂ
hx : ¬x = 0
hy : y = 0
⊢ x = 0 ∨ y = 0 ∨ arg x = arg y ↔ ↑(arg (x / y)) = 0
[PROOFSTEP]
simp [hy]
[GOAL]
case neg
x y : ℂ
hx : ¬x = 0
hy : ¬y = 0
⊢ x = 0 ∨ y = 0 ∨ arg x = arg y ↔ ↑(arg (x / y)) = 0
[PROOFSTEP]
simp [hx, hy, arg_div_coe_angle, sub_eq_zero]


[GOAL]
X : Type u_1
inst✝¹ : TopologicalSpace X
inst✝ : NormalSpace X
s t : Set X
hs : IsClosed s
ht : IsClosed t
hd : Disjoint s t
a b : ℝ
hle : a ≤ b
f : X →ᵇ ℝ
hfs : EqOn (↑f) 0 s
hft : EqOn (↑f) 1 t
hf01 : ∀ (x : X), ↑f x ∈ Icc 0 1
x : X
hx : x ∈ s
⊢ ↑(BoundedContinuousFunction.const X a + (b - a) • f) x = Function.const X a x
[PROOFSTEP]
simp [hfs hx]
[GOAL]
X : Type u_1
inst✝¹ : TopologicalSpace X
inst✝ : NormalSpace X
s t : Set X
hs : IsClosed s
ht : IsClosed t
hd : Disjoint s t
a b : ℝ
hle : a ≤ b
f : X →ᵇ ℝ
hfs : EqOn (↑f) 0 s
hft : EqOn (↑f) 1 t
hf01 : ∀ (x : X), ↑f x ∈ Icc 0 1
x : X
hx : x ∈ t
⊢ ↑(BoundedContinuousFunction.const X a + (b - a) • f) x = Function.const X b x
[PROOFSTEP]
simp [hft hx]
[GOAL]
X : Type u_1
inst✝¹ : TopologicalSpace X
inst✝ : NormalSpace X
s t : Set X
hs : IsClosed s
ht : IsClosed t
hd : Disjoint s t
a b : ℝ
hle : a ≤ b
f : X →ᵇ ℝ
hfs : EqOn (↑f) 0 s
hft : EqOn (↑f) 1 t
hf01 : ∀ (x : X), ↑f x ∈ Icc 0 1
x : X
⊢ a ≤ ↑(BoundedContinuousFunction.const X a + (b - a) • f) x
[PROOFSTEP]
dsimp
[GOAL]
X : Type u_1
inst✝¹ : TopologicalSpace X
inst✝ : NormalSpace X
s t : Set X
hs : IsClosed s
ht : IsClosed t
hd : Disjoint s t
a b : ℝ
hle : a ≤ b
f : X →ᵇ ℝ
hfs : EqOn (↑f) 0 s
hft : EqOn (↑f) 1 t
hf01 : ∀ (x : X), ↑f x ∈ Icc 0 1
x : X
⊢ a ≤ a + (b - a) * ↑f x
[PROOFSTEP]
nlinarith [(hf01 x).1]
[GOAL]
X : Type u_1
inst✝¹ : TopologicalSpace X
inst✝ : NormalSpace X
s t : Set X
hs : IsClosed s
ht : IsClosed t
hd : Disjoint s t
a b : ℝ
hle : a ≤ b
f : X →ᵇ ℝ
hfs : EqOn (↑f) 0 s
hft : EqOn (↑f) 1 t
hf01 : ∀ (x : X), ↑f x ∈ Icc 0 1
x : X
⊢ ↑(BoundedContinuousFunction.const X a + (b - a) • f) x ≤ b
[PROOFSTEP]
dsimp
[GOAL]
X : Type u_1
inst✝¹ : TopologicalSpace X
inst✝ : NormalSpace X
s t : Set X
hs : IsClosed s
ht : IsClosed t
hd : Disjoint s t
a b : ℝ
hle : a ≤ b
f : X →ᵇ ℝ
hfs : EqOn (↑f) 0 s
hft : EqOn (↑f) 1 t
hf01 : ∀ (x : X), ↑f x ∈ Icc 0 1
x : X
⊢ a + (b - a) * ↑f x ≤ b
[PROOFSTEP]
nlinarith [(hf01 x).2]


[GOAL]
α : Type u_1
β : Type u_2
γ : Type u_3
f : SingleObj α ⥤q SingleObj β
g : SingleObj β ⥤q SingleObj γ
⊢ ↑toPrefunctor.symm (f ⋙q g) = ↑toPrefunctor.symm g ∘ ↑toPrefunctor.symm f
[PROOFSTEP]
simp only [Equiv.symm_apply_eq, toPrefunctor_comp, Equiv.apply_symm_apply]
[GOAL]
α : Type u_1
β : Type u_2
γ : Type u_3
x : SingleObj α
p : Path (star α) x
⊢ listToPath (pathToList p) = Path.cast (_ : star α = star α) (_ : x = star α) p
[PROOFSTEP]
induction' p with y z p a ih
[GOAL]
case nil
α : Type u_1
β : Type u_2
γ : Type u_3
x : SingleObj α
⊢ listToPath (pathToList Path.nil) = Path.cast (_ : star α = star α) (_ : star α = star α) Path.nil
[PROOFSTEP]
rfl
[GOAL]
case cons
α : Type u_1
β : Type u_2
γ : Type u_3
x y z : SingleObj α
p : Path (star α) y
a : y ⟶ z
ih : listToPath (pathToList p) = Path.cast (_ : star α = star α) (_ : y = star α) p
⊢ listToPath (pathToList (Path.cons p a)) = Path.cast (_ : star α = star α) (_ : z = star α) (Path.cons p a)
[PROOFSTEP]
dsimp at *
[GOAL]
case cons
α : Type u_1
β : Type u_2
γ : Type u_3
x y z : SingleObj α
p : Path (star α) y
a : y ⟶ z
ih : listToPath (pathToList p) = p
⊢ Path.cons (listToPath (pathToList p)) a = Path.cons p a
[PROOFSTEP]
rw [ih]
[GOAL]
α : Type u_1
β : Type u_2
γ : Type u_3
l : List α
⊢ pathToList (listToPath l) = l
[PROOFSTEP]
induction' l with a l ih
[GOAL]
case nil
α : Type u_1
β : Type u_2
γ : Type u_3
⊢ pathToList (listToPath []) = []
[PROOFSTEP]
rfl
[GOAL]
case cons
α : Type u_1
β : Type u_2
γ : Type u_3
a : α
l : List α
ih : pathToList (listToPath l) = l
⊢ pathToList (listToPath (a :: l)) = a :: l
[PROOFSTEP]
change a :: pathToList (listToPath l) = a :: l
[GOAL]
case cons
α : Type u_1
β : Type u_2
γ : Type u_3
a : α
l : List α
ih : pathToList (listToPath l) = l
⊢ a :: pathToList (listToPath l) = a :: l
[PROOFSTEP]
rw [ih]


[GOAL]
M : Type u_1
N : Type u_2
G : Type u_3
H : Type u_4
F : Type u_5
inst✝ : Monoid F
c : F → M → M
h1 : c 1 = id
hmul : ∀ (f g : F), c (f * g) = c f ∘ c g
f : F
⊢ c (f ^ 0) = (c f)^[0]
[PROOFSTEP]
rw [pow_zero, h1]
[GOAL]
M : Type u_1
N : Type u_2
G : Type u_3
H : Type u_4
F : Type u_5
inst✝ : Monoid F
c : F → M → M
h1 : c 1 = id
hmul : ∀ (f g : F), c (f * g) = c f ∘ c g
f : F
⊢ id = (c f)^[0]
[PROOFSTEP]
rfl
[GOAL]
M : Type u_1
N : Type u_2
G : Type u_3
H : Type u_4
F : Type u_5
inst✝ : Monoid F
c : F → M → M
h1 : c 1 = id
hmul : ∀ (f g : F), c (f * g) = c f ∘ c g
f : F
n : ℕ
⊢ c (f ^ (n + 1)) = (c f)^[n + 1]
[PROOFSTEP]
rw [pow_succ, iterate_succ', hmul, hom_coe_pow c h1 hmul f n]
[GOAL]
M : Type u_1
N : Type u_2
G : Type u_3
H : Type u_4
inst✝¹ : Monoid G
a : G
n : ℕ
inst✝ : MulAction G H
b : H
⊢ (fun x => a • x)^[Nat.zero] b = a ^ Nat.zero • b
[PROOFSTEP]
rw [iterate_zero, id.def, pow_zero, one_smul]
[GOAL]
M : Type u_1
N : Type u_2
G : Type u_3
H : Type u_4
inst✝¹ : Monoid G
a : G
n✝ : ℕ
inst✝ : MulAction G H
b : H
n : ℕ
ih : (fun x => a • x)^[n] b = a ^ n • b
⊢ (fun x => a • x)^[Nat.succ n] b = a ^ Nat.succ n • b
[PROOFSTEP]
rw [iterate_succ', comp_apply, ih, pow_succ, mul_smul]
[GOAL]
M : Type u_1
N : Type u_2
G : Type u_3
H : Type u_4
inst✝ : Monoid G
a : G
n : ℕ
⊢ (fun x => x * a)^[n] 1 = a ^ n
[PROOFSTEP]
simp [mul_right_iterate]
[GOAL]
M : Type u_1
N : Type u_2
G : Type u_3
H : Type u_4
inst✝ : Semigroup G
a b c : G
h : SemiconjBy a b c
j : G
⊢ (fun x => a * x) ((fun x => b * x) j) = (fun x => c * x) ((fun x => a * x) j)
[PROOFSTEP]
dsimp only
[GOAL]
M : Type u_1
N : Type u_2
G : Type u_3
H : Type u_4
inst✝ : Semigroup G
a b c : G
h : SemiconjBy a b c
j : G
⊢ a * (b * j) = c * (a * j)
[PROOFSTEP]
rw [← mul_assoc, h.eq, mul_assoc]
[GOAL]
M : Type u_1
N : Type u_2
G : Type u_3
H : Type u_4
inst✝ : Semigroup G
a b c : G
h : SemiconjBy a b c
j : G
⊢ (fun x => x * a) ((fun x => x * c) j) = (fun x => x * b) ((fun x => x * a) j)
[PROOFSTEP]
simp_rw [mul_assoc, ← h.eq]


[GOAL]
R : Type u_1
M : Type u_2
N : Type u_3
ι : Type u_4
κ : Type u_5
inst✝⁴ : CommRing R
inst✝³ : AddCommGroup M
inst✝² : Module R M
inst✝¹ : AddCommGroup N
inst✝ : Module R N
b : Basis ι R M
c : Basis κ R N
i : ι
j : κ
⊢ ↑(tensorProduct b c) (i, j) = ↑b i ⊗ₜ[R] ↑c j
[PROOFSTEP]
simp [Basis.tensorProduct]
[GOAL]
R : Type u_1
M : Type u_2
N : Type u_3
ι : Type u_4
κ : Type u_5
inst✝⁴ : CommRing R
inst✝³ : AddCommGroup M
inst✝² : Module R M
inst✝¹ : AddCommGroup N
inst✝ : Module R N
b : Basis ι R M
c : Basis κ R N
i : ι × κ
⊢ ↑(tensorProduct b c) i = ↑b i.fst ⊗ₜ[R] ↑c i.snd
[PROOFSTEP]
simp [Basis.tensorProduct]
[GOAL]
R : Type u_1
M : Type u_2
N : Type u_3
ι : Type u_4
κ : Type u_5
inst✝⁴ : CommRing R
inst✝³ : AddCommGroup M
inst✝² : Module R M
inst✝¹ : AddCommGroup N
inst✝ : Module R N
b : Basis ι R M
c : Basis κ R N
m : M
n : N
i : ι
j : κ
⊢ ↑(↑(tensorProduct b c).repr (m ⊗ₜ[R] n)) (i, j) = ↑(↑b.repr m) i * ↑(↑c.repr n) j
[PROOFSTEP]
simp [Basis.tensorProduct]


[GOAL]
R : Type u_1
A : Type u_2
B : Type u_3
inst✝⁶ : CommSemiring R
inst✝⁵ : CommSemiring A
inst✝⁴ : Semiring B
inst✝³ : Algebra R A
inst✝² : Algebra A B
inst✝¹ : Algebra R B
inst✝ : IsScalarTower R A B
x : B
p : R[X]
⊢ ↑(aeval x) (map (algebraMap R A) p) = ↑(aeval x) p
[PROOFSTEP]
rw [aeval_def, aeval_def, eval₂_map, IsScalarTower.algebraMap_eq R A B]
[GOAL]
R : Type u_1
A : Type u_2
B : Type u_3
inst✝⁶ : CommSemiring R
inst✝⁵ : CommSemiring A
inst✝⁴ : Semiring B
inst✝³ : Algebra R A
inst✝² : Algebra A B
inst✝¹ : Algebra R B
inst✝ : IsScalarTower R A B
x : A
p : R[X]
⊢ ↑(aeval (↑(algebraMap A B) x)) p = ↑(algebraMap A B) (↑(aeval x) p)
[PROOFSTEP]
rw [aeval_def, aeval_def, hom_eval₂, ← IsScalarTower.algebraMap_eq]
[GOAL]
R : Type u_1
A : Type u_2
B : Type u_3
inst✝⁸ : CommSemiring R
inst✝⁷ : CommSemiring A
inst✝⁶ : Semiring B
inst✝⁵ : Algebra R A
inst✝⁴ : Algebra A B
inst✝³ : Algebra R B
inst✝² : IsScalarTower R A B
inst✝¹ : NoZeroSMulDivisors A B
inst✝ : Nontrivial B
x : A
p : R[X]
⊢ ↑(aeval (↑(algebraMap A B) x)) p = 0 ↔ ↑(aeval x) p = 0
[PROOFSTEP]
rw [aeval_algebraMap_apply, Algebra.algebraMap_eq_smul_one, smul_eq_zero, iff_false_intro (one_ne_zero' B),
  or_false_iff]
[GOAL]
R : Type u_1
A : Type u_2
B : Type u_3
inst✝⁶ : CommSemiring R
inst✝⁵ : CommSemiring A
inst✝⁴ : Semiring B
inst✝³ : Algebra R A
inst✝² : Algebra A B
inst✝¹ : Algebra R B
inst✝ : IsScalarTower R A B
x : A
p : R[X]
h : Function.Injective ↑(algebraMap A B)
⊢ ↑(aeval (↑(algebraMap A B) x)) p = 0 ↔ ↑(aeval x) p = 0
[PROOFSTEP]
rw [aeval_algebraMap_apply, ← (algebraMap A B).map_zero, h.eq_iff]


[GOAL]
z : ℂ
⊢ z ∈ circle ↔ ↑normSq z = 1
[PROOFSTEP]
simp [Complex.abs]
[GOAL]
z : { x // x ∈ circle }
⊢ ↑normSq ↑z = 1
[PROOFSTEP]
simp [normSq_eq_abs]
[GOAL]
z : { x // x ∈ circle }
⊢ ↑z⁻¹ = ↑(starRingEnd ℂ) ↑z
[PROOFSTEP]
rw [coe_inv_circle, inv_def, normSq_eq_of_mem_circle, inv_one, ofReal_one, mul_one]
[GOAL]
z : ℂ
hz : z ≠ 0
⊢ ↑Complex.abs (↑(starRingEnd ℂ) z / z) = 1
[PROOFSTEP]
rw [map_div₀, abs_conj, div_self]
[GOAL]
z : ℂ
hz : z ≠ 0
⊢ ↑Complex.abs z ≠ 0
[PROOFSTEP]
exact Complex.abs.ne_zero hz
[GOAL]
t : ℝ
⊢ exp (↑t * I) ∈ circle
[PROOFSTEP]
simp [exp_mul_I, abs_cos_add_sin_mul_I]
[GOAL]
⊢ ↑(↑expMapCircle 0) = ↑1
[PROOFSTEP]
rw [expMapCircle_apply, ofReal_zero, zero_mul, exp_zero, Submonoid.coe_one]
[GOAL]
x y : ℝ
⊢ ↑(↑expMapCircle (x + y)) = ↑(↑expMapCircle x * ↑expMapCircle y)
[PROOFSTEP]
simp only [expMapCircle_apply, Submonoid.coe_mul, ofReal_add, add_mul, Complex.exp_add]