diff --git a/Mathlib/Analysis/Calculus/ContDiff/Basic.lean b/Mathlib/Analysis/Calculus/ContDiff/Basic.lean index 05d77c24f110e..52ac217ea8cf2 100644 --- a/Mathlib/Analysis/Calculus/ContDiff/Basic.lean +++ b/Mathlib/Analysis/Calculus/ContDiff/Basic.lean @@ -187,7 +187,7 @@ theorem IsBoundedBilinearMap.contDiff (hb : IsBoundedBilinearMap π•œ b) : ContD /-- If `f` admits a Taylor series `p` in a set `s`, and `g` is linear, then `g ∘ f` admits a Taylor series whose `k`-th term is given by `g ∘ (p k)`. -/ -theorem HasFTaylorSeriesUpToOn.continuousLinearMap_comp (g : F β†’L[π•œ] G) +theorem HasFTaylorSeriesUpToOn.continuousLinearMap_comp {n : WithTop β„•βˆž} (g : F β†’L[π•œ] G) (hf : HasFTaylorSeriesUpToOn n f p s) : HasFTaylorSeriesUpToOn n (g ∘ f) (fun x k => g.compContinuousMultilinearMap (p x k)) s where zero_eq x hx := congr_arg g (hf.zero_eq x hx) @@ -221,16 +221,16 @@ theorem ContDiff.continuousLinearMap_comp {f : E β†’ F} (g : F β†’L[π•œ] G) (hf /-- The iterated derivative within a set of the composition with a linear map on the left is obtained by applying the linear map to the iterated derivative. -/ theorem ContinuousLinearMap.iteratedFDerivWithin_comp_left {f : E β†’ F} (g : F β†’L[π•œ] G) - (hf : ContDiffOn π•œ n f s) (hs : UniqueDiffOn π•œ s) (hx : x ∈ s) {i : β„•} (hi : (i : β„•βˆž) ≀ n) : + (hf : ContDiffOn π•œ n f s) (hs : UniqueDiffOn π•œ s) (hx : x ∈ s) {i : β„•} (hi : i ≀ n) : iteratedFDerivWithin π•œ i (g ∘ f) s x = g.compContinuousMultilinearMap (iteratedFDerivWithin π•œ i f s x) := (((hf.ftaylorSeriesWithin hs).continuousLinearMap_comp g).eq_iteratedFDerivWithin_of_uniqueDiffOn - hi hs hx).symm + (mod_cast hi) hs hx).symm /-- The iterated derivative of the composition with a linear map on the left is obtained by applying the linear map to the iterated derivative. -/ theorem ContinuousLinearMap.iteratedFDeriv_comp_left {f : E β†’ F} (g : F β†’L[π•œ] G) - (hf : ContDiff π•œ n f) (x : E) {i : β„•} (hi : (i : β„•βˆž) ≀ n) : + (hf : ContDiff π•œ n f) (x : E) {i : β„•} (hi : i ≀ n) : iteratedFDeriv π•œ i (g ∘ f) x = g.compContinuousMultilinearMap (iteratedFDeriv π•œ i f x) := by simp only [← iteratedFDerivWithin_univ] exact g.iteratedFDerivWithin_comp_left hf.contDiffOn uniqueDiffOn_univ (mem_univ x) hi @@ -262,7 +262,7 @@ theorem ContinuousLinearEquiv.iteratedFDerivWithin_comp_left (g : F ≃L[π•œ] G /-- Composition with a linear isometry on the left preserves the norm of the iterated derivative within a set. -/ theorem LinearIsometry.norm_iteratedFDerivWithin_comp_left {f : E β†’ F} (g : F β†’β‚—α΅’[π•œ] G) - (hf : ContDiffOn π•œ n f s) (hs : UniqueDiffOn π•œ s) (hx : x ∈ s) {i : β„•} (hi : (i : β„•βˆž) ≀ n) : + (hf : ContDiffOn π•œ n f s) (hs : UniqueDiffOn π•œ s) (hx : x ∈ s) {i : β„•} (hi : i ≀ n) : β€–iteratedFDerivWithin π•œ i (g ∘ f) s xβ€– = β€–iteratedFDerivWithin π•œ i f s xβ€– := by have : iteratedFDerivWithin π•œ i (g ∘ f) s x = @@ -274,7 +274,7 @@ theorem LinearIsometry.norm_iteratedFDerivWithin_comp_left {f : E β†’ F} (g : F /-- Composition with a linear isometry on the left preserves the norm of the iterated derivative. -/ theorem LinearIsometry.norm_iteratedFDeriv_comp_left {f : E β†’ F} (g : F β†’β‚—α΅’[π•œ] G) - (hf : ContDiff π•œ n f) (x : E) {i : β„•} (hi : (i : β„•βˆž) ≀ n) : + (hf : ContDiff π•œ n f) (x : E) {i : β„•} (hi : i ≀ n) : β€–iteratedFDeriv π•œ i (g ∘ f) xβ€– = β€–iteratedFDeriv π•œ i f xβ€– := by simp only [← iteratedFDerivWithin_univ] exact g.norm_iteratedFDerivWithin_comp_left hf.contDiffOn uniqueDiffOn_univ (mem_univ x) hi @@ -326,8 +326,8 @@ theorem ContinuousLinearEquiv.comp_contDiff_iff (e : F ≃L[π•œ] G) : /-- If `f` admits a Taylor series `p` in a set `s`, and `g` is linear, then `f ∘ g` admits a Taylor series in `g ⁻¹' s`, whose `k`-th term is given by `p k (g v₁, ..., g vβ‚–)` . -/ -theorem HasFTaylorSeriesUpToOn.compContinuousLinearMap (hf : HasFTaylorSeriesUpToOn n f p s) - (g : G β†’L[π•œ] E) : +theorem HasFTaylorSeriesUpToOn.compContinuousLinearMap {n : WithTop β„•βˆž} + (hf : HasFTaylorSeriesUpToOn n f p s) (g : G β†’L[π•œ] E) : HasFTaylorSeriesUpToOn n (f ∘ g) (fun x k => (p (g x) k).compContinuousLinearMap fun _ => g) (g ⁻¹' s) := by let A : βˆ€ m : β„•, (E[Γ—m]β†’L[π•œ] F) β†’ G[Γ—m]β†’L[π•œ] F := fun m h => h.compContinuousLinearMap fun _ => g @@ -372,11 +372,11 @@ theorem ContDiff.comp_continuousLinearMap {f : E β†’ F} {g : G β†’L[π•œ] E} (hf obtained by composing the iterated derivative with the linear map. -/ theorem ContinuousLinearMap.iteratedFDerivWithin_comp_right {f : E β†’ F} (g : G β†’L[π•œ] E) (hf : ContDiffOn π•œ n f s) (hs : UniqueDiffOn π•œ s) (h's : UniqueDiffOn π•œ (g ⁻¹' s)) {x : G} - (hx : g x ∈ s) {i : β„•} (hi : (i : β„•βˆž) ≀ n) : + (hx : g x ∈ s) {i : β„•} (hi : i ≀ n) : iteratedFDerivWithin π•œ i (f ∘ g) (g ⁻¹' s) x = (iteratedFDerivWithin π•œ i f s (g x)).compContinuousLinearMap fun _ => g := (((hf.ftaylorSeriesWithin hs).compContinuousLinearMap g).eq_iteratedFDerivWithin_of_uniqueDiffOn - hi h's hx).symm + (mod_cast hi) h's hx).symm /-- The iterated derivative within a set of the composition with a linear equiv on the right is obtained by composing the iterated derivative with the linear equiv. -/ @@ -406,7 +406,7 @@ theorem ContinuousLinearEquiv.iteratedFDerivWithin_comp_right (g : G ≃L[π•œ] /-- The iterated derivative of the composition with a linear map on the right is obtained by composing the iterated derivative with the linear map. -/ theorem ContinuousLinearMap.iteratedFDeriv_comp_right (g : G β†’L[π•œ] E) {f : E β†’ F} - (hf : ContDiff π•œ n f) (x : G) {i : β„•} (hi : (i : β„•βˆž) ≀ n) : + (hf : ContDiff π•œ n f) (x : G) {i : β„•} (hi : i ≀ n) : iteratedFDeriv π•œ i (f ∘ g) x = (iteratedFDeriv π•œ i f (g x)).compContinuousLinearMap fun _ => g := by simp only [← iteratedFDerivWithin_univ] @@ -463,7 +463,8 @@ theorem ContinuousLinearEquiv.contDiff_comp_iff (e : G ≃L[π•œ] E) : /-- If two functions `f` and `g` admit Taylor series `p` and `q` in a set `s`, then the cartesian product of `f` and `g` admits the cartesian product of `p` and `q` as a Taylor series. -/ -theorem HasFTaylorSeriesUpToOn.prod (hf : HasFTaylorSeriesUpToOn n f p s) {g : E β†’ G} +theorem HasFTaylorSeriesUpToOn.prod {n : WithTop β„•βˆž} + (hf : HasFTaylorSeriesUpToOn n f p s) {g : E β†’ G} {q : E β†’ FormalMultilinearSeries π•œ E G} (hg : HasFTaylorSeriesUpToOn n g q s) : HasFTaylorSeriesUpToOn n (fun y => (f y, g y)) (fun y k => (p y k).prod (q y k)) s := by set L := fun m => ContinuousMultilinearMap.prodL π•œ (fun _ : Fin m => E) F G @@ -1131,7 +1132,7 @@ variable {ΞΉ ΞΉ' : Type*} [Fintype ΞΉ] [Fintype ΞΉ'] {F' : ΞΉ β†’ Type*} [βˆ€ i, [βˆ€ i, NormedSpace π•œ (F' i)] {Ο† : βˆ€ i, E β†’ F' i} {p' : βˆ€ i, E β†’ FormalMultilinearSeries π•œ E (F' i)} {Ξ¦ : E β†’ βˆ€ i, F' i} {P' : E β†’ FormalMultilinearSeries π•œ E (βˆ€ i, F' i)} -theorem hasFTaylorSeriesUpToOn_pi : +theorem hasFTaylorSeriesUpToOn_pi {n : WithTop β„•βˆž} : HasFTaylorSeriesUpToOn n (fun x i => Ο† i x) (fun x m => ContinuousMultilinearMap.pi fun i => p' i x m) s ↔ βˆ€ i, HasFTaylorSeriesUpToOn n (Ο† i) (p' i) s := by @@ -1150,7 +1151,7 @@ theorem hasFTaylorSeriesUpToOn_pi : exact (L m).continuous.comp_continuousOn <| continuousOn_pi.2 fun i => (h i).cont m hm @[simp] -theorem hasFTaylorSeriesUpToOn_pi' : +theorem hasFTaylorSeriesUpToOn_pi' {n : WithTop β„•βˆž} : HasFTaylorSeriesUpToOn n Ξ¦ P' s ↔ βˆ€ i, HasFTaylorSeriesUpToOn n (fun x => Ξ¦ x i) (fun x m => (@ContinuousLinearMap.proj π•œ _ ΞΉ F' _ _ _ i).compContinuousMultilinearMap @@ -1204,7 +1205,7 @@ end Pi section Add -theorem HasFTaylorSeriesUpToOn.add {q g} (hf : HasFTaylorSeriesUpToOn n f p s) +theorem HasFTaylorSeriesUpToOn.add {n : WithTop β„•βˆž} {q g} (hf : HasFTaylorSeriesUpToOn n f p s) (hg : HasFTaylorSeriesUpToOn n g q s) : HasFTaylorSeriesUpToOn n (f + g) (p + q) s := by convert HasFTaylorSeriesUpToOn.continuousLinearMap_comp (ContinuousLinearMap.fst π•œ F F + .snd π•œ F F) (hf.prod hg) @@ -1641,12 +1642,13 @@ theorem contDiffAt_ring_inverse [CompleteSpace R] (x : RΛ£) : refine ⟨{ y : R | IsUnit y }, ?_, ?_⟩ Β· simpa [nhdsWithin_univ] using x.nhds Β· use ftaylorSeriesWithin π•œ inverse univ - rw [le_antisymm hm bot_le, hasFTaylorSeriesUpToOn_zero_iff] + have : (m : WithTop β„•βˆž) = 0 := by exact_mod_cast le_antisymm hm bot_le + rw [this, hasFTaylorSeriesUpToOn_zero_iff] constructor Β· rintro _ ⟨x', rfl⟩ exact (inverse_continuousAt x').continuousWithinAt Β· simp [ftaylorSeriesWithin] - Β· rw [contDiffAt_succ_iff_hasFDerivAt] + Β· rw [show (n.succ : β„•βˆž) = n + 1 from rfl, contDiffAt_succ_iff_hasFDerivAt] refine ⟨fun x : R => -mulLeftRight π•œ R (inverse x) (inverse x), ?_, ?_⟩ Β· refine ⟨{ y : R | IsUnit y }, x.nhds, ?_⟩ rintro _ ⟨y, rfl⟩ @@ -1752,7 +1754,7 @@ theorem PartialHomeomorph.contDiffAt_symm [CompleteSpace E] (f : PartialHomeomor Β· rw [contDiffAt_zero] exact ⟨f.target, IsOpen.mem_nhds f.open_target ha, f.continuousOn_invFun⟩ Β· obtain ⟨f', ⟨u, hu, hff'⟩, hf'⟩ := contDiffAt_succ_iff_hasFDerivAt.mp hf - rw [contDiffAt_succ_iff_hasFDerivAt] + rw [show (n.succ : β„•βˆž) = n + 1 from rfl, contDiffAt_succ_iff_hasFDerivAt] -- For showing `n.succ` times continuous differentiability (the main inductive step), it -- suffices to produce the derivative and show that it is `n` times continuously differentiable have eq_fβ‚€' : f' (f.symm a) = fβ‚€' := (hff' (f.symm a) (mem_of_mem_nhds hu)).unique hfβ‚€' @@ -1871,7 +1873,7 @@ open ContinuousLinearMap (smulRight) /-- A function is `C^(n + 1)` on a domain with unique derivatives if and only if it is differentiable there, and its derivative (formulated with `derivWithin`) is `C^n`. -/ theorem contDiffOn_succ_iff_derivWithin {n : β„•} (hs : UniqueDiffOn π•œ sβ‚‚) : - ContDiffOn π•œ (n + 1 : β„•) fβ‚‚ sβ‚‚ ↔ + ContDiffOn π•œ (n + 1) fβ‚‚ sβ‚‚ ↔ DifferentiableOn π•œ fβ‚‚ sβ‚‚ ∧ ContDiffOn π•œ n (derivWithin fβ‚‚ sβ‚‚) sβ‚‚ := by rw [contDiffOn_succ_iff_fderivWithin hs, and_congr_right_iff] intro _ @@ -1893,7 +1895,7 @@ theorem contDiffOn_succ_iff_derivWithin {n : β„•} (hs : UniqueDiffOn π•œ sβ‚‚) /-- A function is `C^(n + 1)` on an open domain if and only if it is differentiable there, and its derivative (formulated with `deriv`) is `C^n`. -/ theorem contDiffOn_succ_iff_deriv_of_isOpen {n : β„•} (hs : IsOpen sβ‚‚) : - ContDiffOn π•œ (n + 1 : β„•) fβ‚‚ sβ‚‚ ↔ DifferentiableOn π•œ fβ‚‚ sβ‚‚ ∧ ContDiffOn π•œ n (deriv fβ‚‚) sβ‚‚ := by + ContDiffOn π•œ (n + 1) fβ‚‚ sβ‚‚ ↔ DifferentiableOn π•œ fβ‚‚ sβ‚‚ ∧ ContDiffOn π•œ n (deriv fβ‚‚) sβ‚‚ := by rw [contDiffOn_succ_iff_derivWithin hs.uniqueDiffOn] exact Iff.rfl.and (contDiffOn_congr fun _ => derivWithin_of_isOpen hs) @@ -1944,7 +1946,7 @@ theorem ContDiffOn.continuousOn_deriv_of_isOpen (h : ContDiffOn π•œ n fβ‚‚ sβ‚‚ /-- A function is `C^(n + 1)` if and only if it is differentiable, and its derivative (formulated in terms of `deriv`) is `C^n`. -/ theorem contDiff_succ_iff_deriv {n : β„•} : - ContDiff π•œ (n + 1 : β„•) fβ‚‚ ↔ Differentiable π•œ fβ‚‚ ∧ ContDiff π•œ n (deriv fβ‚‚) := by + ContDiff π•œ (n + 1) fβ‚‚ ↔ Differentiable π•œ fβ‚‚ ∧ ContDiff π•œ n (deriv fβ‚‚) := by simp only [← contDiffOn_univ, contDiffOn_succ_iff_deriv_of_isOpen, isOpen_univ, differentiableOn_univ] @@ -1992,7 +1994,8 @@ variable [NormedSpace π•œ' E] [IsScalarTower π•œ π•œ' E] variable [NormedSpace π•œ' F] [IsScalarTower π•œ π•œ' F] variable {p' : E β†’ FormalMultilinearSeries π•œ' E F} -theorem HasFTaylorSeriesUpToOn.restrictScalars (h : HasFTaylorSeriesUpToOn n f p' s) : +theorem HasFTaylorSeriesUpToOn.restrictScalars {n : WithTop β„•βˆž} + (h : HasFTaylorSeriesUpToOn n f p' s) : HasFTaylorSeriesUpToOn n f (fun x => (p' x).restrictScalars π•œ) s where zero_eq x hx := h.zero_eq x hx fderivWithin m hm x hx := by @@ -2017,4 +2020,4 @@ theorem ContDiff.restrict_scalars (h : ContDiff π•œ' n f) : ContDiff π•œ n f : end RestrictScalars -set_option linter.style.longFile 2100 +set_option linter.style.longFile 2200 diff --git a/Mathlib/Analysis/Calculus/ContDiff/Defs.lean b/Mathlib/Analysis/Calculus/ContDiff/Defs.lean index c7f8b24aa799b..968b9b7d7d1c3 100644 --- a/Mathlib/Analysis/Calculus/ContDiff/Defs.lean +++ b/Mathlib/Analysis/Calculus/ContDiff/Defs.lean @@ -124,7 +124,7 @@ For instance, a real function which is `C^m` on `(-1/m, 1/m)` for each natural ` better, is `C^∞` at `0` within `univ`. -/ def ContDiffWithinAt (n : β„•βˆž) (f : E β†’ F) (s : Set E) (x : E) : Prop := - βˆ€ m : β„•, (m : β„•βˆž) ≀ n β†’ βˆƒ u ∈ 𝓝[insert x s] x, + βˆ€ m : β„•, m ≀ n β†’ βˆƒ u ∈ 𝓝[insert x s] x, βˆƒ p : E β†’ FormalMultilinearSeries π•œ E F, HasFTaylorSeriesUpToOn m f p u variable {π•œ} @@ -132,7 +132,7 @@ variable {π•œ} theorem contDiffWithinAt_nat {n : β„•} : ContDiffWithinAt π•œ n f s x ↔ βˆƒ u ∈ 𝓝[insert x s] x, βˆƒ p : E β†’ FormalMultilinearSeries π•œ E F, HasFTaylorSeriesUpToOn n f p u := - ⟨fun H => H n le_rfl, fun ⟨u, hu, p, hp⟩ _m hm => ⟨u, hu, p, hp.of_le hm⟩⟩ + ⟨fun H => H n le_rfl, fun ⟨u, hu, p, hp⟩ _m hm => ⟨u, hu, p, hp.of_le (mod_cast hm)⟩⟩ theorem ContDiffWithinAt.of_le (h : ContDiffWithinAt π•œ n f s x) (hmn : m ≀ n) : ContDiffWithinAt π•œ m f s x := fun k hk => h k (le_trans hk hmn) @@ -290,30 +290,32 @@ theorem ContDiffWithinAt.differentiableWithinAt (h : ContDiffWithinAt π•œ n f s /-- A function is `C^(n + 1)` on a domain iff locally, it has a derivative which is `C^n`. -/ theorem contDiffWithinAt_succ_iff_hasFDerivWithinAt {n : β„•} : - ContDiffWithinAt π•œ (n + 1 : β„•) f s x ↔ βˆƒ u ∈ 𝓝[insert x s] x, βˆƒ f' : E β†’ E β†’L[π•œ] F, + ContDiffWithinAt π•œ (n + 1) f s x ↔ βˆƒ u ∈ 𝓝[insert x s] x, βˆƒ f' : E β†’ E β†’L[π•œ] F, (βˆ€ x ∈ u, HasFDerivWithinAt f (f' x) u x) ∧ ContDiffWithinAt π•œ n f' u x := by constructor Β· intro h rcases h n.succ le_rfl with ⟨u, hu, p, Hp⟩ refine ⟨u, hu, fun y => (continuousMultilinearCurryFin1 π•œ E F) (p y 1), fun y hy => - Hp.hasFDerivWithinAt (WithTop.coe_le_coe.2 (Nat.le_add_left 1 n)) hy, ?_⟩ + Hp.hasFDerivWithinAt (mod_cast (Nat.le_add_left 1 n)) hy, ?_⟩ intro m hm refine ⟨u, ?_, fun y : E => (p y).shift, ?_⟩ Β· -- Porting note: without the explicit argument Lean is not sure of the type. convert @self_mem_nhdsWithin _ _ x u have : x ∈ insert x s := by simp exact insert_eq_of_mem (mem_of_mem_nhdsWithin this hu) - Β· rw [hasFTaylorSeriesUpToOn_succ_iff_right] at Hp - exact Hp.2.2.of_le hm + Β· rw [show ((n.succ : β„•) : WithTop β„•βˆž) = n + 1 from rfl, + hasFTaylorSeriesUpToOn_succ_iff_right] at Hp + exact Hp.2.2.of_le (mod_cast hm) Β· rintro ⟨u, hu, f', f'_eq_deriv, Hf'⟩ - rw [contDiffWithinAt_nat] + rw [show (n : β„•βˆž) + 1 = (n + 1 : β„•) from rfl, contDiffWithinAt_nat] rcases Hf' n le_rfl with ⟨v, hv, p', Hp'⟩ refine ⟨v ∩ u, ?_, fun x => (p' x).unshift (f x), ?_⟩ Β· apply Filter.inter_mem _ hu apply nhdsWithin_le_of_mem hu exact nhdsWithin_mono _ (subset_insert x u) hv - Β· rw [hasFTaylorSeriesUpToOn_succ_iff_right] + Β· rw [show ((n.succ : β„•) : WithTop β„•βˆž) = n + 1 from rfl, + hasFTaylorSeriesUpToOn_succ_iff_right] refine ⟨fun y _ => rfl, fun y hy => ?_, ?_⟩ Β· change HasFDerivWithinAt (fun z => (continuousMultilinearCurryFin0 π•œ E F).symm (f z)) @@ -340,7 +342,7 @@ theorem contDiffWithinAt_succ_iff_hasFDerivWithinAt {n : β„•} : /-- A version of `contDiffWithinAt_succ_iff_hasFDerivWithinAt` where all derivatives are taken within the same set. -/ theorem contDiffWithinAt_succ_iff_hasFDerivWithinAt' {n : β„•} : - ContDiffWithinAt π•œ (n + 1 : β„•) f s x ↔ + ContDiffWithinAt π•œ (n + 1) f s x ↔ βˆƒ u ∈ 𝓝[insert x s] x, u βŠ† insert x s ∧ βˆƒ f' : E β†’ E β†’L[π•œ] F, (βˆ€ x ∈ u, HasFDerivWithinAt f (f' x) s x) ∧ ContDiffWithinAt π•œ n f' s x := by refine ⟨fun hf => ?_, ?_⟩ @@ -378,13 +380,13 @@ theorem HasFTaylorSeriesUpToOn.contDiffOn {f' : E β†’ FormalMultilinearSeries intro x hx m hm use s simp only [Set.insert_eq_of_mem hx, self_mem_nhdsWithin, true_and] - exact ⟨f', hf.of_le hm⟩ + exact ⟨f', hf.of_le (mod_cast hm)⟩ theorem ContDiffOn.contDiffWithinAt (h : ContDiffOn π•œ n f s) (hx : x ∈ s) : ContDiffWithinAt π•œ n f s x := h x hx -theorem ContDiffWithinAt.contDiffOn' {m : β„•} (hm : (m : β„•βˆž) ≀ n) +theorem ContDiffWithinAt.contDiffOn' {m : β„•} (hm : m ≀ n) (h : ContDiffWithinAt π•œ n f s x) : βˆƒ u, IsOpen u ∧ x ∈ u ∧ ContDiffOn π•œ m f (insert x s ∩ u) := by rcases h m hm with ⟨t, ht, p, hp⟩ @@ -392,7 +394,7 @@ theorem ContDiffWithinAt.contDiffOn' {m : β„•} (hm : (m : β„•βˆž) ≀ n) rw [inter_comm] at hut exact ⟨u, huo, hxu, (hp.mono hut).contDiffOn⟩ -theorem ContDiffWithinAt.contDiffOn {m : β„•} (hm : (m : β„•βˆž) ≀ n) (h : ContDiffWithinAt π•œ n f s x) : +theorem ContDiffWithinAt.contDiffOn {m : β„•} (hm : m ≀ n) (h : ContDiffWithinAt π•œ n f s x) : βˆƒ u ∈ 𝓝[insert x s] x, u βŠ† insert x s ∧ ContDiffOn π•œ m f u := let ⟨_u, uo, xu, h⟩ := h.contDiffOn' hm ⟨_, inter_mem_nhdsWithin _ (uo.mem_nhds xu), inter_subset_left, h⟩ @@ -466,7 +468,7 @@ theorem contDiffOn_of_locally_contDiffOn /-- A function is `C^(n + 1)` on a domain iff locally, it has a derivative which is `C^n`. -/ theorem contDiffOn_succ_iff_hasFDerivWithinAt {n : β„•} : - ContDiffOn π•œ (n + 1 : β„•) f s ↔ + ContDiffOn π•œ (n + 1) f s ↔ βˆ€ x ∈ s, βˆƒ u ∈ 𝓝[insert x s] x, βˆƒ f' : E β†’ E β†’L[π•œ] F, (βˆ€ x ∈ u, HasFDerivWithinAt f (f' x) u x) ∧ ContDiffOn π•œ n f' u := by constructor @@ -474,10 +476,11 @@ theorem contDiffOn_succ_iff_hasFDerivWithinAt {n : β„•} : rcases (h x hx) n.succ le_rfl with ⟨u, hu, p, Hp⟩ refine ⟨u, hu, fun y => (continuousMultilinearCurryFin1 π•œ E F) (p y 1), fun y hy => - Hp.hasFDerivWithinAt (WithTop.coe_le_coe.2 (Nat.le_add_left 1 n)) hy, ?_⟩ - rw [hasFTaylorSeriesUpToOn_succ_iff_right] at Hp + Hp.hasFDerivWithinAt (mod_cast (Nat.le_add_left 1 n)) hy, ?_⟩ + rw [show (n.succ : WithTop β„•βˆž) = (n : β„•) + 1 from rfl, + hasFTaylorSeriesUpToOn_succ_iff_right] at Hp intro z hz m hm - refine ⟨u, ?_, fun x : E => (p x).shift, Hp.2.2.of_le hm⟩ + refine ⟨u, ?_, fun x : E => (p x).shift, Hp.2.2.of_le (mod_cast hm)⟩ -- Porting note: without the explicit arguments `convert` can not determine the type. convert @self_mem_nhdsWithin _ _ z u exact insert_eq_of_mem hz @@ -490,7 +493,7 @@ theorem contDiffOn_succ_iff_hasFDerivWithinAt {n : β„•} : @[simp] theorem contDiffOn_zero : ContDiffOn π•œ 0 f s ↔ ContinuousOn f s := by refine ⟨fun H => H.continuousOn, fun H => fun x hx m hm ↦ ?_⟩ - have : (m : β„•βˆž) = 0 := le_antisymm hm bot_le + have : (m : WithTop β„•βˆž) = 0 := le_antisymm (mod_cast hm) bot_le rw [this] refine ⟨insert x s, self_mem_nhdsWithin, ftaylorSeriesWithin π•œ f s, ?_⟩ rw [hasFTaylorSeriesUpToOn_zero_iff] @@ -519,7 +522,8 @@ protected theorem ContDiffOn.ftaylorSeriesWithin (h : ContDiffOn π•œ n f s) (hs simp only [ftaylorSeriesWithin, ContinuousMultilinearMap.curry0_apply, iteratedFDerivWithin_zero_apply] Β· intro m hm x hx - rcases (h x hx) m.succ (Order.add_one_le_of_lt hm) with ⟨u, hu, p, Hp⟩ + have : m < n := mod_cast hm + rcases (h x hx) m.succ (Order.add_one_le_of_lt this) with ⟨u, hu, p, Hp⟩ rw [insert_eq_of_mem hx] at hu rcases mem_nhdsWithin.1 hu with ⟨o, o_open, xo, ho⟩ rw [inter_comm] at ho @@ -533,15 +537,15 @@ protected theorem ContDiffOn.ftaylorSeriesWithin (h : ContDiffOn π•œ n f s) (hs change p y m = iteratedFDerivWithin π•œ m f s y rw [← iteratedFDerivWithin_inter_open o_open yo] exact - (Hp.mono ho).eq_iteratedFDerivWithin_of_uniqueDiffOn (WithTop.coe_le_coe.2 (Nat.le_succ m)) + (Hp.mono ho).eq_iteratedFDerivWithin_of_uniqueDiffOn (mod_cast Nat.le_succ m) (hs.inter o_open) ⟨hy, yo⟩ exact - ((Hp.mono ho).fderivWithin m (WithTop.coe_lt_coe.2 (lt_add_one m)) x ⟨hx, xo⟩).congr + ((Hp.mono ho).fderivWithin m (mod_cast lt_add_one m) x ⟨hx, xo⟩).congr (fun y hy => (A y hy).symm) (A x ⟨hx, xo⟩).symm Β· intro m hm apply continuousOn_of_locally_continuousOn intro x hx - rcases h x hx m hm with ⟨u, hu, p, Hp⟩ + rcases h x hx m (mod_cast hm) with ⟨u, hu, p, Hp⟩ rcases mem_nhdsWithin.1 hu with ⟨o, o_open, xo, ho⟩ rw [insert_eq_of_mem hx] at ho rw [inter_comm] at ho @@ -554,8 +558,8 @@ protected theorem ContDiffOn.ftaylorSeriesWithin (h : ContDiffOn π•œ n f s) (hs exact ((Hp.mono ho).cont m le_rfl).congr fun y hy => (A y hy).symm theorem contDiffOn_of_continuousOn_differentiableOn - (Hcont : βˆ€ m : β„•, (m : β„•βˆž) ≀ n β†’ ContinuousOn (fun x => iteratedFDerivWithin π•œ m f s x) s) - (Hdiff : βˆ€ m : β„•, (m : β„•βˆž) < n β†’ + (Hcont : βˆ€ m : β„•, m ≀ n β†’ ContinuousOn (fun x => iteratedFDerivWithin π•œ m f s x) s) + (Hdiff : βˆ€ m : β„•, m < n β†’ DifferentiableOn π•œ (fun x => iteratedFDerivWithin π•œ m f s x) s) : ContDiffOn π•œ n f s := by intro x hx m hm @@ -566,27 +570,27 @@ theorem contDiffOn_of_continuousOn_differentiableOn simp only [ftaylorSeriesWithin, ContinuousMultilinearMap.curry0_apply, iteratedFDerivWithin_zero_apply] Β· intro k hk y hy - convert (Hdiff k (lt_of_lt_of_le hk hm) y hy).hasFDerivWithinAt + convert (Hdiff k (lt_of_lt_of_le (mod_cast hk) hm) y hy).hasFDerivWithinAt Β· intro k hk - exact Hcont k (le_trans hk hm) + exact Hcont k (le_trans (mod_cast hk) hm) theorem contDiffOn_of_differentiableOn - (h : βˆ€ m : β„•, (m : β„•βˆž) ≀ n β†’ DifferentiableOn π•œ (iteratedFDerivWithin π•œ m f s) s) : + (h : βˆ€ m : β„•, m ≀ n β†’ DifferentiableOn π•œ (iteratedFDerivWithin π•œ m f s) s) : ContDiffOn π•œ n f s := contDiffOn_of_continuousOn_differentiableOn (fun m hm => (h m hm).continuousOn) fun m hm => h m (le_of_lt hm) theorem ContDiffOn.continuousOn_iteratedFDerivWithin {m : β„•} (h : ContDiffOn π•œ n f s) - (hmn : (m : β„•βˆž) ≀ n) (hs : UniqueDiffOn π•œ s) : ContinuousOn (iteratedFDerivWithin π•œ m f s) s := - (h.ftaylorSeriesWithin hs).cont m hmn + (hmn : m ≀ n) (hs : UniqueDiffOn π•œ s) : ContinuousOn (iteratedFDerivWithin π•œ m f s) s := + (h.ftaylorSeriesWithin hs).cont m (mod_cast hmn) theorem ContDiffOn.differentiableOn_iteratedFDerivWithin {m : β„•} (h : ContDiffOn π•œ n f s) - (hmn : (m : β„•βˆž) < n) (hs : UniqueDiffOn π•œ s) : + (hmn : m < n) (hs : UniqueDiffOn π•œ s) : DifferentiableOn π•œ (iteratedFDerivWithin π•œ m f s) s := fun x hx => - ((h.ftaylorSeriesWithin hs).fderivWithin m hmn x hx).differentiableWithinAt + ((h.ftaylorSeriesWithin hs).fderivWithin m (mod_cast hmn) x hx).differentiableWithinAt theorem ContDiffWithinAt.differentiableWithinAt_iteratedFDerivWithin {m : β„•} - (h : ContDiffWithinAt π•œ n f s x) (hmn : (m : β„•βˆž) < n) (hs : UniqueDiffOn π•œ (insert x s)) : + (h : ContDiffWithinAt π•œ n f s x) (hmn : m < n) (hs : UniqueDiffOn π•œ (insert x s)) : DifferentiableWithinAt π•œ (iteratedFDerivWithin π•œ m f s) s x := by rcases h.contDiffOn' (Order.add_one_le_of_lt hmn) with ⟨u, uo, xu, hu⟩ set t := insert x s ∩ u @@ -605,14 +609,14 @@ theorem ContDiffWithinAt.differentiableWithinAt_iteratedFDerivWithin {m : β„•} theorem contDiffOn_iff_continuousOn_differentiableOn (hs : UniqueDiffOn π•œ s) : ContDiffOn π•œ n f s ↔ - (βˆ€ m : β„•, (m : β„•βˆž) ≀ n β†’ ContinuousOn (fun x => iteratedFDerivWithin π•œ m f s x) s) ∧ - βˆ€ m : β„•, (m : β„•βˆž) < n β†’ DifferentiableOn π•œ (fun x => iteratedFDerivWithin π•œ m f s x) s := + (βˆ€ m : β„•, m ≀ n β†’ ContinuousOn (fun x => iteratedFDerivWithin π•œ m f s x) s) ∧ + βˆ€ m : β„•, m < n β†’ DifferentiableOn π•œ (fun x => iteratedFDerivWithin π•œ m f s x) s := ⟨fun h => ⟨fun _m hm => h.continuousOn_iteratedFDerivWithin hm hs, fun _m hm => h.differentiableOn_iteratedFDerivWithin hm hs⟩, fun h => contDiffOn_of_continuousOn_differentiableOn h.1 h.2⟩ theorem contDiffOn_succ_of_fderivWithin {n : β„•} (hf : DifferentiableOn π•œ f s) - (h : ContDiffOn π•œ n (fun y => fderivWithin π•œ f s y) s) : ContDiffOn π•œ (n + 1 : β„•) f s := by + (h : ContDiffOn π•œ n (fun y => fderivWithin π•œ f s y) s) : ContDiffOn π•œ (n + 1) f s := by intro x hx rw [contDiffWithinAt_succ_iff_hasFDerivWithinAt, insert_eq_of_mem hx] exact @@ -621,7 +625,7 @@ theorem contDiffOn_succ_of_fderivWithin {n : β„•} (hf : DifferentiableOn π•œ f /-- A function is `C^(n + 1)` on a domain with unique derivatives if and only if it is differentiable there, and its derivative (expressed with `fderivWithin`) is `C^n`. -/ theorem contDiffOn_succ_iff_fderivWithin {n : β„•} (hs : UniqueDiffOn π•œ s) : - ContDiffOn π•œ (n + 1 : β„•) f s ↔ + ContDiffOn π•œ (n + 1) f s ↔ DifferentiableOn π•œ f s ∧ ContDiffOn π•œ n (fun y => fderivWithin π•œ f s y) s := by refine ⟨fun H => ?_, fun h => contDiffOn_succ_of_fderivWithin h.1 h.2⟩ refine ⟨H.differentiableOn (WithTop.coe_le_coe.2 (Nat.le_add_left 1 n)), fun x hx => ?_⟩ @@ -639,7 +643,7 @@ theorem contDiffOn_succ_iff_fderivWithin {n : β„•} (hs : UniqueDiffOn π•œ s) : rwa [fderivWithin_inter (o_open.mem_nhds hy.2)] at A theorem contDiffOn_succ_iff_hasFDerivWithin {n : β„•} (hs : UniqueDiffOn π•œ s) : - ContDiffOn π•œ (n + 1 : β„•) f s ↔ + ContDiffOn π•œ (n + 1) f s ↔ βˆƒ f' : E β†’ E β†’L[π•œ] F, ContDiffOn π•œ n f' s ∧ βˆ€ x, x ∈ s β†’ HasFDerivWithinAt f (f' x) s x := by rw [contDiffOn_succ_iff_fderivWithin hs] refine ⟨fun h => ⟨fderivWithin π•œ f s, h.2, fun x hx => (h.1 x hx).hasFDerivWithinAt⟩, fun h => ?_⟩ @@ -650,7 +654,7 @@ theorem contDiffOn_succ_iff_hasFDerivWithin {n : β„•} (hs : UniqueDiffOn π•œ s) /-- A function is `C^(n + 1)` on an open domain if and only if it is differentiable there, and its derivative (expressed with `fderiv`) is `C^n`. -/ theorem contDiffOn_succ_iff_fderiv_of_isOpen {n : β„•} (hs : IsOpen s) : - ContDiffOn π•œ (n + 1 : β„•) f s ↔ + ContDiffOn π•œ (n + 1) f s ↔ DifferentiableOn π•œ f s ∧ ContDiffOn π•œ n (fun y => fderiv π•œ f y) s := by rw [contDiffOn_succ_iff_fderivWithin hs.uniqueDiffOn] exact Iff.rfl.and (contDiffOn_congr fun x hx ↦ fderivWithin_of_isOpen hs hx) @@ -762,7 +766,7 @@ nonrec lemma ContDiffAt.contDiffOn {m : β„•} (h : ContDiffAt π•œ n f x) (hm : m /-- A function is `C^(n + 1)` at a point iff locally, it has a derivative which is `C^n`. -/ theorem contDiffAt_succ_iff_hasFDerivAt {n : β„•} : - ContDiffAt π•œ (n + 1 : β„•) f x ↔ + ContDiffAt π•œ (n + 1) f x ↔ βˆƒ f' : E β†’ E β†’L[π•œ] F, (βˆƒ u ∈ 𝓝 x, βˆ€ x ∈ u, HasFDerivAt f (f' x) x) ∧ ContDiffAt π•œ n f' x := by rw [← contDiffWithinAt_univ, contDiffWithinAt_succ_iff_hasFDerivWithinAt] simp only [nhdsWithin_univ, exists_prop, mem_univ, insert_eq_of_mem] @@ -808,7 +812,8 @@ theorem contDiffOn_univ : ContDiffOn π•œ n f univ ↔ ContDiff π•œ n f := by rw [← hasFTaylorSeriesUpToOn_univ_iff] exact H.ftaylorSeriesWithin uniqueDiffOn_univ Β· rintro ⟨p, hp⟩ x _ m hm - exact ⟨univ, Filter.univ_sets _, p, (hp.hasFTaylorSeriesUpToOn univ).of_le hm⟩ + exact ⟨univ, Filter.univ_sets _, p, (hp.hasFTaylorSeriesUpToOn univ).of_le + (mod_cast hm)⟩ theorem contDiff_iff_contDiffAt : ContDiff π•œ n f ↔ βˆ€ x, ContDiffAt π•œ n f x := by simp [← contDiffOn_univ, ContDiffOn, ContDiffAt] @@ -839,8 +844,8 @@ theorem contDiffAt_zero : ContDiffAt π•œ 0 f x ↔ βˆƒ u ∈ 𝓝 x, Continuous theorem contDiffAt_one_iff : ContDiffAt π•œ 1 f x ↔ βˆƒ f' : E β†’ E β†’L[π•œ] F, βˆƒ u ∈ 𝓝 x, ContinuousOn f' u ∧ βˆ€ x ∈ u, HasFDerivAt f (f' x) x := by - simp_rw [show (1 : β„•βˆž) = (0 + 1 : β„•) from (zero_add 1).symm, contDiffAt_succ_iff_hasFDerivAt, - show ((0 : β„•) : β„•βˆž) = 0 from rfl, contDiffAt_zero, + rw [show (1 : β„•βˆž) = (0 : β„•) + 1 from rfl, contDiffAt_succ_iff_hasFDerivAt] + simp_rw [show ((0 : β„•) : β„•βˆž) = 0 from rfl, contDiffAt_zero, exists_mem_and_iff antitone_bforall antitone_continuousOn, and_comm] theorem ContDiff.of_le (h : ContDiff π•œ n f) (hmn : m ≀ n) : ContDiff π•œ m f := @@ -864,7 +869,7 @@ theorem contDiff_iff_forall_nat_le : ContDiff π•œ n f ↔ βˆ€ m : β„•, ↑m ≀ /-- A function is `C^(n+1)` iff it has a `C^n` derivative. -/ theorem contDiff_succ_iff_hasFDerivAt {n : β„•} : - ContDiff π•œ (n + 1 : β„•) f ↔ + ContDiff π•œ (n + 1) f ↔ βˆƒ f' : E β†’ E β†’L[π•œ] F, ContDiff π•œ n f' ∧ βˆ€ x, HasFDerivAt f (f' x) x := by simp only [← contDiffOn_univ, ← hasFDerivWithinAt_univ, contDiffOn_succ_iff_hasFDerivWithin uniqueDiffOn_univ, Set.mem_univ, forall_true_left] @@ -884,30 +889,30 @@ theorem contDiff_iff_ftaylorSeries : theorem contDiff_iff_continuous_differentiable : ContDiff π•œ n f ↔ - (βˆ€ m : β„•, (m : β„•βˆž) ≀ n β†’ Continuous fun x => iteratedFDeriv π•œ m f x) ∧ - βˆ€ m : β„•, (m : β„•βˆž) < n β†’ Differentiable π•œ fun x => iteratedFDeriv π•œ m f x := by + (βˆ€ m : β„•, m ≀ n β†’ Continuous fun x => iteratedFDeriv π•œ m f x) ∧ + βˆ€ m : β„•, m < n β†’ Differentiable π•œ fun x => iteratedFDeriv π•œ m f x := by simp [contDiffOn_univ.symm, continuous_iff_continuousOn_univ, differentiableOn_univ.symm, iteratedFDerivWithin_univ, contDiffOn_iff_continuousOn_differentiableOn uniqueDiffOn_univ] /-- If `f` is `C^n` then its `m`-times iterated derivative is continuous for `m ≀ n`. -/ -theorem ContDiff.continuous_iteratedFDeriv {m : β„•} (hm : (m : β„•βˆž) ≀ n) (hf : ContDiff π•œ n f) : +theorem ContDiff.continuous_iteratedFDeriv {m : β„•} (hm : m ≀ n) (hf : ContDiff π•œ n f) : Continuous fun x => iteratedFDeriv π•œ m f x := (contDiff_iff_continuous_differentiable.mp hf).1 m hm /-- If `f` is `C^n` then its `m`-times iterated derivative is differentiable for `m < n`. -/ -theorem ContDiff.differentiable_iteratedFDeriv {m : β„•} (hm : (m : β„•βˆž) < n) (hf : ContDiff π•œ n f) : +theorem ContDiff.differentiable_iteratedFDeriv {m : β„•} (hm : m < n) (hf : ContDiff π•œ n f) : Differentiable π•œ fun x => iteratedFDeriv π•œ m f x := (contDiff_iff_continuous_differentiable.mp hf).2 m hm theorem contDiff_of_differentiable_iteratedFDeriv - (h : βˆ€ m : β„•, (m : β„•βˆž) ≀ n β†’ Differentiable π•œ (iteratedFDeriv π•œ m f)) : ContDiff π•œ n f := + (h : βˆ€ m : β„•, m ≀ n β†’ Differentiable π•œ (iteratedFDeriv π•œ m f)) : ContDiff π•œ n f := contDiff_iff_continuous_differentiable.2 ⟨fun m hm => (h m hm).continuous, fun m hm => h m (le_of_lt hm)⟩ /-- A function is `C^(n + 1)` if and only if it is differentiable, and its derivative (formulated in terms of `fderiv`) is `C^n`. -/ theorem contDiff_succ_iff_fderiv {n : β„•} : - ContDiff π•œ (n + 1 : β„•) f ↔ Differentiable π•œ f ∧ ContDiff π•œ n fun y => fderiv π•œ f y := by + ContDiff π•œ (n + 1) f ↔ Differentiable π•œ f ∧ ContDiff π•œ n fun y => fderiv π•œ f y := by simp only [← contDiffOn_univ, ← differentiableOn_univ, ← fderivWithin_univ, contDiffOn_succ_iff_fderivWithin uniqueDiffOn_univ] diff --git a/Mathlib/Analysis/Calculus/ContDiff/FTaylorSeries.lean b/Mathlib/Analysis/Calculus/ContDiff/FTaylorSeries.lean index 149c86f2c306e..abdac0002a6e2 100644 --- a/Mathlib/Analysis/Calculus/ContDiff/FTaylorSeries.lean +++ b/Mathlib/Analysis/Calculus/ContDiff/FTaylorSeries.lean @@ -99,7 +99,7 @@ In this file, we denote `⊀ : β„•βˆž` with `∞`. noncomputable section open scoped Classical -open NNReal Topology Filter +open ENat NNReal Topology Filter local notation "∞" => (⊀ : β„•βˆž) @@ -115,7 +115,8 @@ universe u uE uF variable {π•œ : Type u} [NontriviallyNormedField π•œ] {E : Type uE} [NormedAddCommGroup E] [NormedSpace π•œ E] {F : Type uF} [NormedAddCommGroup F] [NormedSpace π•œ F] - {s t u : Set E} {f f₁ : E β†’ F} {x : E} {m n : β„•βˆž} {p : E β†’ FormalMultilinearSeries π•œ E F} + {s t u : Set E} {f f₁ : E β†’ F} {x : E} {m n N : WithTop β„•βˆž} + {p : E β†’ FormalMultilinearSeries π•œ E F} /-! ### Functions with a Taylor series on a domain -/ @@ -125,12 +126,12 @@ derivative of `p m` for `m < n`, and is continuous for `m ≀ n`. This is a pred Notice that `p` does not sum up to `f` on the diagonal (`FormalMultilinearSeries.sum`), even if `f` is analytic and `n = ∞`: an additional `1/m!` factor on the `m`th term is necessary for that. -/ -structure HasFTaylorSeriesUpToOn (n : β„•βˆž) (f : E β†’ F) (p : E β†’ FormalMultilinearSeries π•œ E F) - (s : Set E) : Prop where +structure HasFTaylorSeriesUpToOn + (n : WithTop β„•βˆž) (f : E β†’ F) (p : E β†’ FormalMultilinearSeries π•œ E F) (s : Set E) : Prop where zero_eq : βˆ€ x ∈ s, (p x 0).curry0 = f x protected fderivWithin : βˆ€ m : β„•, (m : β„•βˆž) < n β†’ βˆ€ x ∈ s, HasFDerivWithinAt (p Β· m) (p x m.succ).curryLeft s x - cont : βˆ€ m : β„•, (m : β„•βˆž) ≀ n β†’ ContinuousOn (p Β· m) s + cont : βˆ€ m : β„•, m ≀ n β†’ ContinuousOn (p Β· m) s theorem HasFTaylorSeriesUpToOn.zero_eq' (h : HasFTaylorSeriesUpToOn n f p s) {x : E} (hx : x ∈ s) : p x 0 = (continuousMultilinearCurryFin0 π•œ E F).symm (f x) := by @@ -170,26 +171,31 @@ theorem hasFTaylorSeriesUpToOn_zero_iff : rw [continuousOn_congr this, LinearIsometryEquiv.comp_continuousOn_iff] exact H.1 -theorem hasFTaylorSeriesUpToOn_top_iff : - HasFTaylorSeriesUpToOn ∞ f p s ↔ βˆ€ n : β„•, HasFTaylorSeriesUpToOn n f p s := by +theorem hasFTaylorSeriesUpToOn_top_iff_add (hN : ∞ ≀ N) (k : β„•) : + HasFTaylorSeriesUpToOn N f p s ↔ βˆ€ n : β„•, HasFTaylorSeriesUpToOn (n + k : β„•) f p s := by constructor - Β· intro H n; exact H.of_le le_top + Β· intro H n + apply H.of_le (natCast_le_of_coe_top_le_withTop hN _) Β· intro H constructor Β· exact (H 0).zero_eq Β· intro m _ - apply (H m.succ).fderivWithin m (WithTop.coe_lt_coe.2 (lt_add_one m)) + apply (H m.succ).fderivWithin m (by norm_cast; omega) Β· intro m _ - apply (H m).cont m le_rfl + apply (H m).cont m (by simp) + +theorem hasFTaylorSeriesUpToOn_top_iff (hN : ∞ ≀ N) : + HasFTaylorSeriesUpToOn N f p s ↔ βˆ€ n : β„•, HasFTaylorSeriesUpToOn n f p s := by + simpa using hasFTaylorSeriesUpToOn_top_iff_add hN 0 /-- In the case that `n = ∞` we don't need the continuity assumption in `HasFTaylorSeriesUpToOn`. -/ -theorem hasFTaylorSeriesUpToOn_top_iff' : - HasFTaylorSeriesUpToOn ∞ f p s ↔ +theorem hasFTaylorSeriesUpToOn_top_iff' (hN : ∞ ≀ N) : + HasFTaylorSeriesUpToOn N f p s ↔ (βˆ€ x ∈ s, (p x 0).curry0 = f x) ∧ - βˆ€ m : β„•, βˆ€ x ∈ s, HasFDerivWithinAt (fun y => p y m) (p x m.succ).curryLeft s x := + βˆ€ m : β„•, βˆ€ x ∈ s, HasFDerivWithinAt (fun y => p y m) (p x m.succ).curryLeft s x := by -- Everything except for the continuity is trivial: - ⟨fun h => ⟨h.1, fun m => h.2 m (WithTop.coe_lt_top m)⟩, fun h => + refine ⟨fun h => ⟨h.1, fun m => h.2 m (natCast_lt_of_coe_top_le_withTop hN _)⟩, fun h => ⟨h.1, fun m _ => h.2 m, fun m _ x hx => -- The continuity follows from the existence of a derivative: (h.2 m x hx).continuousWithinAt⟩⟩ @@ -241,21 +247,21 @@ theorem hasFTaylorSeriesUpToOn_succ_iff_left {n : β„•} : (βˆ€ x ∈ s, HasFDerivWithinAt (fun y => p y n) (p x n.succ).curryLeft s x) ∧ ContinuousOn (fun x => p x (n + 1)) s := by constructor - Β· exact fun h ↦ ⟨h.of_le (WithTop.coe_le_coe.2 (Nat.le_succ n)), - h.fderivWithin _ (WithTop.coe_lt_coe.2 (lt_add_one n)), h.cont (n + 1) le_rfl⟩ + Β· exact fun h ↦ ⟨h.of_le (mod_cast Nat.le_succ n), + h.fderivWithin _ (mod_cast lt_add_one n), h.cont (n + 1) le_rfl⟩ Β· intro h constructor Β· exact h.1.zero_eq Β· intro m hm by_cases h' : m < n - Β· exact h.1.fderivWithin m (WithTop.coe_lt_coe.2 h') - Β· have : m = n := Nat.eq_of_lt_succ_of_not_lt (WithTop.coe_lt_coe.1 hm) h' + Β· exact h.1.fderivWithin m (mod_cast h') + Β· have : m = n := Nat.eq_of_lt_succ_of_not_lt (mod_cast hm) h' rw [this] exact h.2.1 Β· intro m hm by_cases h' : m ≀ n - Β· apply h.1.cont m (WithTop.coe_le_coe.2 h') - Β· have : m = n + 1 := le_antisymm (WithTop.coe_le_coe.1 hm) (not_le.1 h') + Β· apply h.1.cont m (mod_cast h') + Β· have : m = n + 1 := le_antisymm (mod_cast hm) (not_le.1 h') rw [this] exact h.2.2 @@ -273,8 +279,8 @@ theorem HasFTaylorSeriesUpToOn.shift_of_succ constructor Β· intro x _ rfl - Β· intro m (hm : (m : β„•βˆž) < n) x (hx : x ∈ s) - have A : (m.succ : β„•βˆž) < n.succ := by + Β· intro m (hm : (m : WithTop β„•βˆž) < n) x (hx : x ∈ s) + have A : (m.succ : WithTop β„•βˆž) < n.succ := by rw [Nat.cast_lt] at hm ⊒ exact Nat.succ_lt_succ hm change HasFDerivWithinAt (continuousMultilinearCurryRightEquiv' π•œ m E F ∘ (p Β· m.succ)) @@ -284,7 +290,7 @@ theorem HasFTaylorSeriesUpToOn.shift_of_succ ext y v change p x (m + 2) (snoc (cons y (init v)) (v (last _))) = p x (m + 2) (cons y v) rw [← cons_snoc_eq_snoc_cons, snoc_init_self] - Β· intro m (hm : (m : β„•βˆž) ≀ n) + Β· intro m (hm : (m : WithTop β„•βˆž) ≀ n) suffices A : ContinuousOn (p Β· (m + 1)) s from (continuousMultilinearCurryRightEquiv' π•œ m E F).continuous.comp_continuousOn A refine H.cont _ ?_ @@ -292,8 +298,8 @@ theorem HasFTaylorSeriesUpToOn.shift_of_succ exact Nat.succ_le_succ hm /-- `p` is a Taylor series of `f` up to `n+1` if and only if `p.shift` is a Taylor series up to `n` -for `p 1`, which is a derivative of `f`. -/ -theorem hasFTaylorSeriesUpToOn_succ_iff_right {n : β„•} : +for `p 1`, which is a derivative of `f`. Version for `n : β„•`. -/ +theorem hasFTaylorSeriesUpToOn_succ_nat_iff_right {n : β„•} : HasFTaylorSeriesUpToOn (n + 1 : β„•) f p s ↔ (βˆ€ x ∈ s, (p x 0).curry0 = f x) ∧ (βˆ€ x ∈ s, HasFDerivWithinAt (fun y => p y 0) (p x 1).curryLeft s x) ∧ @@ -306,10 +312,10 @@ theorem hasFTaylorSeriesUpToOn_succ_iff_right {n : β„•} : Β· rintro ⟨Hzero_eq, Hfderiv_zero, Htaylor⟩ constructor Β· exact Hzero_eq - Β· intro m (hm : (m : β„•βˆž) < n.succ) x (hx : x ∈ s) + Β· intro m (hm : (m : WithTop β„•βˆž) < n.succ) x (hx : x ∈ s) cases' m with m Β· exact Hfderiv_zero x hx - Β· have A : (m : β„•βˆž) < n := by + Β· have A : (m : WithTop β„•βˆž) < n := by rw [Nat.cast_lt] at hm ⊒ exact Nat.lt_of_succ_lt_succ hm have : @@ -322,7 +328,7 @@ theorem hasFTaylorSeriesUpToOn_succ_iff_right {n : β„•} : (p x (Nat.succ (Nat.succ m))) (cons y v) = (p x m.succ.succ) (snoc (cons y (init v)) (v (last _))) rw [← cons_snoc_eq_snoc_cons, snoc_init_self] - Β· intro m (hm : (m : β„•βˆž) ≀ n.succ) + Β· intro m (hm : (m : WithTop β„•βˆž) ≀ n.succ) cases' m with m Β· have : DifferentiableOn π•œ (fun x => p x 0) s := fun x hx => (Hfderiv_zero x hx).differentiableWithinAt @@ -332,6 +338,37 @@ theorem hasFTaylorSeriesUpToOn_succ_iff_right {n : β„•} : rw [Nat.cast_le] at hm ⊒ exact Nat.lt_succ_iff.mp hm +/-- `p` is a Taylor series of `f` up to `⊀` if and only if `p.shift` is a Taylor series up to `⊀` +for `p 1`, which is a derivative of `f`. -/ +theorem hasFTaylorSeriesUpToOn_top_iff_right (hN : ∞ ≀ N) : + HasFTaylorSeriesUpToOn N f p s ↔ + (βˆ€ x ∈ s, (p x 0).curry0 = f x) ∧ + (βˆ€ x ∈ s, HasFDerivWithinAt (fun y => p y 0) (p x 1).curryLeft s x) ∧ + HasFTaylorSeriesUpToOn N (fun x => continuousMultilinearCurryFin1 π•œ E F (p x 1)) + (fun x => (p x).shift) s := by + refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩ + Β· rw [hasFTaylorSeriesUpToOn_top_iff_add hN 1] at h + rw [hasFTaylorSeriesUpToOn_top_iff hN] + exact ⟨(hasFTaylorSeriesUpToOn_succ_nat_iff_right.1 (h 1)).1, + (hasFTaylorSeriesUpToOn_succ_nat_iff_right.1 (h 1)).2.1, + fun n ↦ (hasFTaylorSeriesUpToOn_succ_nat_iff_right.1 (h n)).2.2⟩ + Β· apply (hasFTaylorSeriesUpToOn_top_iff_add hN 1).2 (fun n ↦ ?_) + rw [hasFTaylorSeriesUpToOn_succ_nat_iff_right] + exact ⟨h.1, h.2.1, (h.2.2).of_le (m := n) (natCast_le_of_coe_top_le_withTop hN n)⟩ + +/-- `p` is a Taylor series of `f` up to `n+1` if and only if `p.shift` is a Taylor series up to `n` +for `p 1`, which is a derivative of `f`. Version for `n : WithTop β„•βˆž`. -/ +theorem hasFTaylorSeriesUpToOn_succ_iff_right : + HasFTaylorSeriesUpToOn (n + 1) f p s ↔ + (βˆ€ x ∈ s, (p x 0).curry0 = f x) ∧ + (βˆ€ x ∈ s, HasFDerivWithinAt (fun y => p y 0) (p x 1).curryLeft s x) ∧ + HasFTaylorSeriesUpToOn n (fun x => continuousMultilinearCurryFin1 π•œ E F (p x 1)) + (fun x => (p x).shift) s := by + match n with + | ⊀ => exact hasFTaylorSeriesUpToOn_top_iff_right (by simp) + | (⊀ : β„•βˆž) => exact hasFTaylorSeriesUpToOn_top_iff_right (by simp) + | (n : β„•) => exact hasFTaylorSeriesUpToOn_succ_nat_iff_right + /-! ### Iterated derivative within a set -/ @@ -537,11 +574,11 @@ theorem iteratedFDerivWithin_inter_open {n : β„•} (hu : IsOpen u) (hx : x ∈ u) /-- On a set with unique differentiability, any choice of iterated differential has to coincide with the one we have chosen in `iteratedFDerivWithin π•œ m f s`. -/ theorem HasFTaylorSeriesUpToOn.eq_iteratedFDerivWithin_of_uniqueDiffOn - (h : HasFTaylorSeriesUpToOn n f p s) {m : β„•} (hmn : (m : β„•βˆž) ≀ n) (hs : UniqueDiffOn π•œ s) + (h : HasFTaylorSeriesUpToOn n f p s) {m : β„•} (hmn : m ≀ n) (hs : UniqueDiffOn π•œ s) (hx : x ∈ s) : p x m = iteratedFDerivWithin π•œ m f s x := by induction' m with m IH generalizing x Β· rw [h.zero_eq' hx, iteratedFDerivWithin_zero_eq_comp]; rfl - Β· have A : (m : β„•βˆž) < n := lt_of_lt_of_le (WithTop.coe_lt_coe.2 (lt_add_one m)) hmn + Β· have A : (m : β„•βˆž) < n := lt_of_lt_of_le (mod_cast lt_add_one m) hmn have : HasFDerivWithinAt (fun y : E => iteratedFDerivWithin π•œ m f s y) (ContinuousMultilinearMap.curryLeft (p x (Nat.succ m))) s x := @@ -563,11 +600,11 @@ derivative of `p m` for `m < n`, and is continuous for `m ≀ n`. This is a pred Notice that `p` does not sum up to `f` on the diagonal (`FormalMultilinearSeries.sum`), even if `f` is analytic and `n = ∞`: an addition `1/m!` factor on the `m`th term is necessary for that. -/ -structure HasFTaylorSeriesUpTo (n : β„•βˆž) (f : E β†’ F) (p : E β†’ FormalMultilinearSeries π•œ E F) : - Prop where +structure HasFTaylorSeriesUpTo + (n : WithTop β„•βˆž) (f : E β†’ F) (p : E β†’ FormalMultilinearSeries π•œ E F) : Prop where zero_eq : βˆ€ x, (p x 0).curry0 = f x - fderiv : βˆ€ m : β„•, (m : β„•βˆž) < n β†’ βˆ€ x, HasFDerivAt (fun y => p y m) (p x m.succ).curryLeft x - cont : βˆ€ m : β„•, (m : β„•βˆž) ≀ n β†’ Continuous fun x => p x m + fderiv : βˆ€ m : β„•, m < n β†’ βˆ€ x, HasFDerivAt (fun y => p y m) (p x m.succ).curryLeft x + cont : βˆ€ m : β„•, m ≀ n β†’ Continuous fun x => p x m theorem HasFTaylorSeriesUpTo.zero_eq' (h : HasFTaylorSeriesUpTo n f p) (x : E) : p x 0 = (continuousMultilinearCurryFin0 π•œ E F).symm (f x) := by @@ -600,10 +637,13 @@ theorem HasFTaylorSeriesUpTo.hasFTaylorSeriesUpToOn (h : HasFTaylorSeriesUpTo n HasFTaylorSeriesUpToOn n f p s := (hasFTaylorSeriesUpToOn_univ_iff.2 h).mono (subset_univ _) -theorem HasFTaylorSeriesUpTo.ofLe (h : HasFTaylorSeriesUpTo n f p) (hmn : m ≀ n) : +theorem HasFTaylorSeriesUpTo.of_le (h : HasFTaylorSeriesUpTo n f p) (hmn : m ≀ n) : HasFTaylorSeriesUpTo m f p := by rw [← hasFTaylorSeriesUpToOn_univ_iff] at h ⊒; exact h.of_le hmn +@[deprecated (since := "2024-11-07")] +alias HasFTaylorSeriesUpTo.ofLe := HasFTaylorSeriesUpTo.of_le + theorem HasFTaylorSeriesUpTo.continuous (h : HasFTaylorSeriesUpTo n f p) : Continuous f := by rw [← hasFTaylorSeriesUpToOn_univ_iff] at h rw [continuous_iff_continuousOn_univ] @@ -614,17 +654,17 @@ theorem hasFTaylorSeriesUpTo_zero_iff : simp [hasFTaylorSeriesUpToOn_univ_iff.symm, continuous_iff_continuousOn_univ, hasFTaylorSeriesUpToOn_zero_iff] -theorem hasFTaylorSeriesUpTo_top_iff : - HasFTaylorSeriesUpTo ∞ f p ↔ βˆ€ n : β„•, HasFTaylorSeriesUpTo n f p := by - simp only [← hasFTaylorSeriesUpToOn_univ_iff, hasFTaylorSeriesUpToOn_top_iff] +theorem hasFTaylorSeriesUpTo_top_iff (hN : ∞ ≀ N) : + HasFTaylorSeriesUpTo N f p ↔ βˆ€ n : β„•, HasFTaylorSeriesUpTo n f p := by + simp only [← hasFTaylorSeriesUpToOn_univ_iff, hasFTaylorSeriesUpToOn_top_iff hN] /-- In the case that `n = ∞` we don't need the continuity assumption in `HasFTaylorSeriesUpTo`. -/ -theorem hasFTaylorSeriesUpTo_top_iff' : - HasFTaylorSeriesUpTo ∞ f p ↔ +theorem hasFTaylorSeriesUpTo_top_iff' (hN : ∞ ≀ N) : + HasFTaylorSeriesUpTo N f p ↔ (βˆ€ x, (p x 0).curry0 = f x) ∧ βˆ€ (m : β„•) (x), HasFDerivAt (fun y => p y m) (p x m.succ).curryLeft x := by - simp only [← hasFTaylorSeriesUpToOn_univ_iff, hasFTaylorSeriesUpToOn_top_iff', mem_univ, + simp only [← hasFTaylorSeriesUpToOn_univ_iff, hasFTaylorSeriesUpToOn_top_iff' hN, mem_univ, forall_true_left, hasFDerivWithinAt_univ] /-- If a function has a Taylor series at order at least `1`, then the term of order `1` of this @@ -639,15 +679,17 @@ theorem HasFTaylorSeriesUpTo.differentiable (h : HasFTaylorSeriesUpTo n f p) (hn /-- `p` is a Taylor series of `f` up to `n+1` if and only if `p.shift` is a Taylor series up to `n` for `p 1`, which is a derivative of `f`. -/ -theorem hasFTaylorSeriesUpTo_succ_iff_right {n : β„•} : +theorem hasFTaylorSeriesUpTo_succ_nat_iff_right {n : β„•} : HasFTaylorSeriesUpTo (n + 1 : β„•) f p ↔ (βˆ€ x, (p x 0).curry0 = f x) ∧ (βˆ€ x, HasFDerivAt (fun y => p y 0) (p x 1).curryLeft x) ∧ HasFTaylorSeriesUpTo n (fun x => continuousMultilinearCurryFin1 π•œ E F (p x 1)) fun x => (p x).shift := by - simp only [hasFTaylorSeriesUpToOn_succ_iff_right, ← hasFTaylorSeriesUpToOn_univ_iff, mem_univ, + simp only [hasFTaylorSeriesUpToOn_succ_nat_iff_right, ← hasFTaylorSeriesUpToOn_univ_iff, mem_univ, forall_true_left, hasFDerivWithinAt_univ] +@[deprecated (since := "2024-11-07")] +alias hasFTaylorSeriesUpTo_succ_iff_right := hasFTaylorSeriesUpTo_succ_nat_iff_right /-! ### Iterated derivative -/ diff --git a/Mathlib/Analysis/Calculus/ContDiff/FaaDiBruno.lean b/Mathlib/Analysis/Calculus/ContDiff/FaaDiBruno.lean index 1c2e5249d4f46..582c9ca4fec35 100644 --- a/Mathlib/Analysis/Calculus/ContDiff/FaaDiBruno.lean +++ b/Mathlib/Analysis/Calculus/ContDiff/FaaDiBruno.lean @@ -917,7 +917,7 @@ private lemma faaDiBruno_aux2 {m : β„•} (q : FormalMultilinearSeries π•œ F G) /-- *Faa di Bruno* formula: If two functions `g` and `f` have Taylor series up to `n` given by `q` and `p`, then `g ∘ f` also has a Taylor series, given by `q.taylorComp p`. -/ -theorem HasFTaylorSeriesUpToOn.comp {n : β„•βˆž} {g : F β†’ G} {f : E β†’ F} +theorem HasFTaylorSeriesUpToOn.comp {n : WithTop β„•βˆž} {g : F β†’ G} {f : E β†’ F} (hg : HasFTaylorSeriesUpToOn n g q t) (hf : HasFTaylorSeriesUpToOn n f p s) (h : MapsTo f s t) : HasFTaylorSeriesUpToOn n (g ∘ f) (fun x ↦ (q (f x)).taylorComp (p x)) s := by /- One has to check that the `m+1`-th term is the derivative of the `m`-th term. The `m`-th term @@ -940,8 +940,8 @@ theorem HasFTaylorSeriesUpToOn.comp {n : β„•βˆž} {g : F β†’ G} {f : E β†’ F} change HasFDerivWithinAt (fun y ↦ B (q (f y) c.length) (fun i ↦ p y (c.partSize i))) (βˆ‘ i : Option (Fin c.length), ((q (f x)).compAlongOrderedFinpartition (p x) (c.extend i)).curryLeft) s x - have cm : (c.length : β„•βˆž) ≀ m := by exact_mod_cast OrderedFinpartition.length_le c - have cp i : (c.partSize i : β„•βˆž) ≀ m := by + have cm : (c.length : WithTop β„•βˆž) ≀ m := mod_cast OrderedFinpartition.length_le c + have cp i : (c.partSize i : WithTop β„•βˆž) ≀ m := by exact_mod_cast OrderedFinpartition.partSize_le c i have I i : HasFDerivWithinAt (fun x ↦ p x (c.partSize i)) (p x (c.partSize i).succ).curryLeft s x := @@ -949,7 +949,8 @@ theorem HasFTaylorSeriesUpToOn.comp {n : β„•βˆž} {g : F β†’ G} {f : E β†’ F} have J : HasFDerivWithinAt (fun x ↦ q x c.length) (q (f x) c.length.succ).curryLeft t (f x) := hg.fderivWithin c.length (cm.trans_lt hm) (f x) (h hx) have K : HasFDerivWithinAt f ((continuousMultilinearCurryFin1 π•œ E F) (p x 1)) s x := - hf.hasFDerivWithinAt (le_trans le_add_self (Order.add_one_le_of_lt hm)) hx + hf.hasFDerivWithinAt (le_trans (mod_cast Nat.le_add_left 1 m) + (ENat.add_one_natCast_le_withTop_of_lt hm)) hx convert HasFDerivWithinAt.linear_multilinear_comp (J.comp x K h) I B simp only [Nat.succ_eq_add_one, Fintype.sum_option, comp_apply, faaDiBruno_aux1, faaDiBruno_aux2] @@ -975,8 +976,9 @@ theorem HasFTaylorSeriesUpToOn.comp {n : β„•βˆž} {g : F β†’ G} {f : E β†’ F} change ContinuousOn ((fun p ↦ B p.1 p.2) ∘ (fun x ↦ (q (f x) c.length, fun i ↦ p x (c.partSize i)))) s apply B.continuous_uncurry_of_multilinear.comp_continuousOn (ContinuousOn.prod ?_ ?_) - Β· have : (c.length : β„•βˆž) ≀ m := by exact_mod_cast OrderedFinpartition.length_le c + Β· have : (c.length : WithTop β„•βˆž) ≀ m := mod_cast OrderedFinpartition.length_le c exact (hg.cont c.length (this.trans hm)).comp hf.continuousOn h Β· apply continuousOn_pi.2 (fun i ↦ ?_) - have : (c.partSize i : β„•βˆž) ≀ m := by exact_mod_cast OrderedFinpartition.partSize_le c i + have : (c.partSize i : WithTop β„•βˆž) ≀ m := by + exact_mod_cast OrderedFinpartition.partSize_le c i exact hf.cont _ (this.trans hm) diff --git a/Mathlib/Analysis/Calculus/ContDiff/FiniteDimension.lean b/Mathlib/Analysis/Calculus/ContDiff/FiniteDimension.lean index e5d673c7ffac0..555d81bb107e4 100644 --- a/Mathlib/Analysis/Calculus/ContDiff/FiniteDimension.lean +++ b/Mathlib/Analysis/Calculus/ContDiff/FiniteDimension.lean @@ -54,17 +54,17 @@ often requires an inconvenient need to generalize `F`, which results in universe This lemma avoids these universe issues, but only applies for finite dimensional `E`. -/ theorem contDiff_succ_iff_fderiv_apply [FiniteDimensional π•œ D] {n : β„•} {f : D β†’ E} : - ContDiff π•œ (n + 1 : β„•) f ↔ Differentiable π•œ f ∧ βˆ€ y, ContDiff π•œ n fun x => fderiv π•œ f x y := by + ContDiff π•œ (n + 1) f ↔ Differentiable π•œ f ∧ βˆ€ y, ContDiff π•œ n fun x => fderiv π•œ f x y := by rw [contDiff_succ_iff_fderiv, contDiff_clm_apply_iff] theorem contDiffOn_succ_of_fderiv_apply [FiniteDimensional π•œ D] {n : β„•} {f : D β†’ E} {s : Set D} (hf : DifferentiableOn π•œ f s) (h : βˆ€ y, ContDiffOn π•œ n (fun x => fderivWithin π•œ f s x y) s) : - ContDiffOn π•œ (n + 1 : β„•) f s := + ContDiffOn π•œ (n + 1) f s := contDiffOn_succ_of_fderivWithin hf <| contDiffOn_clm_apply.mpr h theorem contDiffOn_succ_iff_fderiv_apply [FiniteDimensional π•œ D] {n : β„•} {f : D β†’ E} {s : Set D} (hs : UniqueDiffOn π•œ s) : - ContDiffOn π•œ (n + 1 : β„•) f s ↔ + ContDiffOn π•œ (n + 1) f s ↔ DifferentiableOn π•œ f s ∧ βˆ€ y, ContDiffOn π•œ n (fun x => fderivWithin π•œ f s x y) s := by rw [contDiffOn_succ_iff_fderivWithin hs, contDiffOn_clm_apply] diff --git a/Mathlib/Analysis/Calculus/ContDiff/RCLike.lean b/Mathlib/Analysis/Calculus/ContDiff/RCLike.lean index d9f341edf671a..5f8fdba324bcb 100644 --- a/Mathlib/Analysis/Calculus/ContDiff/RCLike.lean +++ b/Mathlib/Analysis/Calculus/ContDiff/RCLike.lean @@ -29,7 +29,8 @@ variable {n : β„•βˆž} {𝕂 : Type*} [RCLike 𝕂] {E' : Type*} [NormedAddCommGr /-- If a function has a Taylor series at order at least 1, then at points in the interior of the domain of definition, the term of order 1 of this series is a strict derivative of `f`. -/ -theorem HasFTaylorSeriesUpToOn.hasStrictFDerivAt {s : Set E'} {f : E' β†’ F'} {x : E'} +theorem HasFTaylorSeriesUpToOn.hasStrictFDerivAt {n : WithTop β„•βˆž} + {s : Set E'} {f : E' β†’ F'} {x : E'} {p : E' β†’ FormalMultilinearSeries 𝕂 E' F'} (hf : HasFTaylorSeriesUpToOn n f p s) (hn : 1 ≀ n) (hs : s ∈ 𝓝 x) : HasStrictFDerivAt f ((continuousMultilinearCurryFin1 𝕂 E' F') (p x 1)) x := hasStrictFDerivAt_of_hasFDerivAt_of_continuousAt (hf.eventually_hasFDerivAt hn hs) <| diff --git a/Mathlib/Analysis/Calculus/FDeriv/Analytic.lean b/Mathlib/Analysis/Calculus/FDeriv/Analytic.lean index 76c137c4bab78..055c8cb25720e 100644 --- a/Mathlib/Analysis/Calculus/FDeriv/Analytic.lean +++ b/Mathlib/Analysis/Calculus/FDeriv/Analytic.lean @@ -382,7 +382,7 @@ protected theorem AnalyticOn.iteratedFDerivWithin (h : AnalyticOn π•œ f s) apply AnalyticOnNhd.comp_analyticOn _ (IH.fderivWithin hu) (mapsTo_univ _ _) apply LinearIsometryEquiv.analyticOnNhd -lemma AnalyticOn.hasFTaylorSeriesUpToOn {n : β„•βˆž} +lemma AnalyticOn.hasFTaylorSeriesUpToOn {n : WithTop β„•βˆž} (h : AnalyticOn π•œ f s) (hu : UniqueDiffOn π•œ s) : HasFTaylorSeriesUpToOn n f (ftaylorSeriesWithin π•œ f s) s := by refine ⟨fun x _hx ↦ rfl, fun m _hm x hx ↦ ?_, fun m _hm x hx ↦ ?_⟩ diff --git a/Mathlib/Analysis/Convolution.lean b/Mathlib/Analysis/Convolution.lean index a50566576f0f1..e3a80a3cd256e 100644 --- a/Mathlib/Analysis/Convolution.lean +++ b/Mathlib/Analysis/Convolution.lean @@ -1187,7 +1187,8 @@ theorem contDiffOn_convolution_right_with_param_aux {G : Type uP} {E' : Type uP} have A : βˆ€ qβ‚€ : P Γ— G, qβ‚€.1 ∈ s β†’ HasFDerivAt (fun q : P Γ— G => (f ⋆[L, ΞΌ] g q.1) q.2) (f' qβ‚€.1 qβ‚€.2) qβ‚€ := hasFDerivAt_convolution_right_with_param L hs hk hgs hf hg.one_of_succ - rw [contDiffOn_succ_iff_fderiv_of_isOpen (hs.prod (@isOpen_univ G _))] at hg ⊒ + rw [show ((n + 1 : β„•) : β„•βˆž) = n + 1 from rfl, + contDiffOn_succ_iff_fderiv_of_isOpen (hs.prod (@isOpen_univ G _))] at hg ⊒ constructor Β· rintro ⟨p, x⟩ ⟨hp, -⟩ exact (A (p, x) hp).differentiableAt.differentiableWithinAt diff --git a/Mathlib/Analysis/Fourier/FourierTransformDeriv.lean b/Mathlib/Analysis/Fourier/FourierTransformDeriv.lean index 7a53f32811c4c..5b882dad07252 100644 --- a/Mathlib/Analysis/Fourier/FourierTransformDeriv.lean +++ b/Mathlib/Analysis/Fourier/FourierTransformDeriv.lean @@ -440,7 +440,7 @@ lemma integrable_fourierPowSMulRight {n : β„•} (hf : Integrable (fun v ↦ β€–v filter_upwards with v exact (norm_fourierPowSMulRight_le L f v n).trans (le_of_eq (by ring)) -lemma hasFTaylorSeriesUpTo_fourierIntegral {N : β„•βˆž} +lemma hasFTaylorSeriesUpTo_fourierIntegral {N : WithTop β„•βˆž} (hf : βˆ€ (n : β„•), n ≀ N β†’ Integrable (fun v ↦ β€–vβ€–^n * β€–f vβ€–) ΞΌ) (h'f : AEStronglyMeasurable f ΞΌ) : HasFTaylorSeriesUpTo N (fourierIntegral 𝐞 ΞΌ L.toLinearMapβ‚‚ f) @@ -455,7 +455,8 @@ lemma hasFTaylorSeriesUpTo_fourierIntegral {N : β„•βˆž} have I₁ : Integrable (fun v ↦ fourierPowSMulRight L f v n) ΞΌ := integrable_fourierPowSMulRight L (hf n hn.le) h'f have Iβ‚‚ : Integrable (fun v ↦ β€–vβ€– * β€–fourierPowSMulRight L f v nβ€–) ΞΌ := by - apply ((hf (n+1) (Order.add_one_le_of_lt hn)).const_mul ((2 * Ο€ * β€–Lβ€–) ^ n)).mono' + apply ((hf (n+1) (ENat.add_one_natCast_le_withTop_of_lt hn)).const_mul + ((2 * Ο€ * β€–Lβ€–) ^ n)).mono' (continuous_norm.aestronglyMeasurable.mul (h'f.fourierPowSMulRight L n).norm) filter_upwards with v simp only [Pi.mul_apply, norm_mul, norm_norm] @@ -465,7 +466,7 @@ lemma hasFTaylorSeriesUpTo_fourierIntegral {N : β„•βˆž} gcongr; apply norm_fourierPowSMulRight_le _ = (2 * Ο€ * β€–Lβ€–) ^ n * (β€–vβ€– ^ (n + 1) * β€–f vβ€–) := by rw [pow_succ]; ring have I₃ : Integrable (fun v ↦ fourierPowSMulRight L f v (n + 1)) ΞΌ := - integrable_fourierPowSMulRight L (hf (n + 1) (Order.add_one_le_of_lt hn)) h'f + integrable_fourierPowSMulRight L (hf (n + 1) (ENat.add_one_natCast_le_withTop_of_lt hn)) h'f have Iβ‚„ : Integrable (fun v ↦ fourierSMulRight L (fun v ↦ fourierPowSMulRight L f v n) v) ΞΌ := by apply (Iβ‚‚.const_mul ((2 * Ο€ * β€–Lβ€–))).mono' (h'f.fourierPowSMulRight L n).fourierSMulRight @@ -488,12 +489,22 @@ lemma hasFTaylorSeriesUpTo_fourierIntegral {N : β„•βˆž} apply fourierIntegral_continuous Real.continuous_fourierChar (by apply L.continuousβ‚‚) exact integrable_fourierPowSMulRight L (hf n hn) h'f +/-- Variant of `hasFTaylorSeriesUpTo_fourierIntegral` in which the smoothness index is restricted +to `β„•βˆž` (and so are the inequalities in the assumption `hf`). Avoids normcasting in some +applications. -/ +lemma hasFTaylorSeriesUpTo_fourierIntegral' {N : β„•βˆž} + (hf : βˆ€ (n : β„•), n ≀ N β†’ Integrable (fun v ↦ β€–vβ€–^n * β€–f vβ€–) ΞΌ) + (h'f : AEStronglyMeasurable f ΞΌ) : + HasFTaylorSeriesUpTo N (fourierIntegral 𝐞 ΞΌ L.toLinearMapβ‚‚ f) + (fun w n ↦ fourierIntegral 𝐞 ΞΌ L.toLinearMapβ‚‚ (fun v ↦ fourierPowSMulRight L f v n) w) := + hasFTaylorSeriesUpTo_fourierIntegral _ (fun n hn ↦ hf n (mod_cast hn)) h'f + /-- If `β€–vβ€–^n * β€–f vβ€–` is integrable for all `n ≀ N`, then the Fourier transform of `f` is `C^N`. -/ theorem contDiff_fourierIntegral {N : β„•βˆž} (hf : βˆ€ (n : β„•), n ≀ N β†’ Integrable (fun v ↦ β€–vβ€–^n * β€–f vβ€–) ΞΌ) : ContDiff ℝ N (fourierIntegral 𝐞 ΞΌ L.toLinearMapβ‚‚ f) := by by_cases h'f : Integrable f ΞΌ - Β· exact (hasFTaylorSeriesUpTo_fourierIntegral L hf h'f.1).contDiff + Β· exact (hasFTaylorSeriesUpTo_fourierIntegral' L hf h'f.1).contDiff Β· have : fourierIntegral 𝐞 ΞΌ L.toLinearMapβ‚‚ f = 0 := by ext w; simp [fourierIntegral, integral, h'f] simpa [this] using contDiff_const @@ -507,7 +518,8 @@ lemma iteratedFDeriv_fourierIntegral {N : β„•βˆž} iteratedFDeriv ℝ n (fourierIntegral 𝐞 ΞΌ L.toLinearMapβ‚‚ f) = fourierIntegral 𝐞 ΞΌ L.toLinearMapβ‚‚ (fun v ↦ fourierPowSMulRight L f v n) := by ext w : 1 - exact ((hasFTaylorSeriesUpTo_fourierIntegral L hf h'f).eq_iteratedFDeriv hn w).symm + exact ((hasFTaylorSeriesUpTo_fourierIntegral' L hf h'f).eq_iteratedFDeriv + (mod_cast hn) w).symm end SecondCountableTopology diff --git a/Mathlib/Analysis/SpecialFunctions/Pow/Deriv.lean b/Mathlib/Analysis/SpecialFunctions/Pow/Deriv.lean index 6a56975c150b0..d05eed644c71c 100644 --- a/Mathlib/Analysis/SpecialFunctions/Pow/Deriv.lean +++ b/Mathlib/Analysis/SpecialFunctions/Pow/Deriv.lean @@ -368,7 +368,7 @@ theorem contDiff_rpow_const_of_le {p : ℝ} {n : β„•} (h : ↑n ≀ p) : Β· exact contDiff_zero.2 (continuous_id.rpow_const fun x => Or.inr <| by simpa using h) Β· have h1 : 1 ≀ p := le_trans (by simp) h rw [Nat.cast_succ, ← le_sub_iff_add_le] at h - rw [contDiff_succ_iff_deriv, deriv_rpow_const' h1] + rw [show ((n + 1 : β„•) : β„•βˆž) = n + 1 from rfl, contDiff_succ_iff_deriv, deriv_rpow_const' h1] exact ⟨differentiable_rpow_const h1, contDiff_const.mul (ihn h)⟩ theorem contDiffAt_rpow_const_of_le {x p : ℝ} {n : β„•} (h : ↑n ≀ p) : diff --git a/Mathlib/Data/ENat/Basic.lean b/Mathlib/Data/ENat/Basic.lean index 2c4dde0e12e6a..663a5824cbe31 100644 --- a/Mathlib/Data/ENat/Basic.lean +++ b/Mathlib/Data/ENat/Basic.lean @@ -269,6 +269,15 @@ theorem nat_induction {P : β„•βˆž β†’ Prop} (a : β„•βˆž) (h0 : P 0) (hsuc : βˆ€ Β· exact htop A Β· exact A _ +lemma add_one_pos : 0 < n + 1 := + succ_def n β–Έ Order.bot_lt_succ n + +lemma add_lt_add_iff_right {k : β„•βˆž} (h : k β‰  ⊀) : n + k < m + k ↔ n < m := + WithTop.add_lt_add_iff_right h + +lemma add_lt_add_iff_left {k : β„•βˆž} (h : k β‰  ⊀) : k + n < k + m ↔ n < m := + WithTop.add_lt_add_iff_left h + protected lemma exists_nat_gt {n : β„•βˆž} (hn : n β‰  ⊀) : βˆƒ m : β„•, n < m := by lift n to β„• using hn obtain ⟨m, hm⟩ := exists_gt n @@ -286,6 +295,8 @@ protected lemma le_sub_of_add_le_left (ha : a β‰  ⊀) : a + b ≀ c β†’ b ≀ c protected lemma sub_sub_cancel (h : a β‰  ⊀) (h2 : b ≀ a) : a - (a - b) = b := (addLECancellable_of_ne_top <| ne_top_of_le_ne_top h tsub_le_self).tsub_tsub_cancel_of_le h2 +section withTop_enat + lemma add_one_natCast_le_withTop_of_lt {m : β„•} {n : WithTop β„•βˆž} (h : m < n) : (m + 1 : β„•) ≀ n := by match n with | ⊀ => exact le_top @@ -294,9 +305,10 @@ lemma add_one_natCast_le_withTop_of_lt {m : β„•} {n : WithTop β„•βˆž} (h : m < n @[simp] lemma coe_top_add_one : ((⊀ : β„•βˆž) : WithTop β„•βˆž) + 1 = (⊀ : β„•βˆž) := rfl -@[simp] lemma add_one_eq_coe_top_iff : n + 1 = (⊀ : β„•βˆž) ↔ n = (⊀ : β„•βˆž) := by +@[simp] lemma add_one_eq_coe_top_iff {n : WithTop β„•βˆž} : n + 1 = (⊀ : β„•βˆž) ↔ n = (⊀ : β„•βˆž) := by match n with | ⊀ => exact Iff.rfl + | (⊀ : β„•βˆž) => simp | (n : β„•) => norm_cast; simp only [coe_ne_top, iff_false, ne_eq] @[simp] lemma natCast_ne_coe_top (n : β„•) : (n : WithTop β„•βˆž) β‰  (⊀ : β„•βˆž) := nofun @@ -308,13 +320,12 @@ lemma one_le_iff_ne_zero_withTop {n : WithTop β„•βˆž} : 1 ≀ n ↔ n β‰  0 := ⟨fun h ↦ (zero_lt_one.trans_le h).ne', fun h ↦ add_one_natCast_le_withTop_of_lt (pos_iff_ne_zero.mpr h)⟩ -lemma add_one_pos : 0 < n + 1 := - succ_def n β–Έ Order.bot_lt_succ n +lemma natCast_le_of_coe_top_le_withTop {N : WithTop β„•βˆž} (hN : (⊀ : β„•βˆž) ≀ N) (n : β„•) : n ≀ N := + le_trans (mod_cast le_top) hN -lemma add_lt_add_iff_right {k : β„•βˆž} (h : k β‰  ⊀) : n + k < m + k ↔ n < m := - WithTop.add_lt_add_iff_right h +lemma natCast_lt_of_coe_top_le_withTop {N : WithTop β„•βˆž} (hN : (⊀ : β„•βˆž) ≀ N) (n : β„•) : n < N := + lt_of_lt_of_le (mod_cast lt_add_one n) (natCast_le_of_coe_top_le_withTop hN (n + 1)) -lemma add_lt_add_iff_left {k : β„•βˆž} (h : k β‰  ⊀) : k + n < k + m ↔ n < m := - WithTop.add_lt_add_iff_left h +end withTop_enat end ENat