source stringlengths 17 118 | lean4 stringlengths 0 335k |
|---|---|
.lake/packages/mathlib/Mathlib/Analysis/NormedSpace/Extr.lean | import Mathlib.Analysis.Normed.Module.Ray
import Mathlib.Topology.Order.LocalExtr
/-!
# (Local) maximums in a normed space
In this file we prove the following lemma, see `IsMaxFilter.norm_add_sameRay`. If `f : α → E` is
a function such that `norm ∘ f` has a maximum along a filter `l` at a point `c` and `y` is a vector
on the same ray as `f c`, then the function `fun x => ‖f x + y‖` has a maximum along `l` at `c`.
Then we specialize it to the case `y = f c` and to different special cases of `IsMaxFilter`:
`IsMaxOn`, `IsLocalMaxOn`, and `IsLocalMax`.
## Tags
local maximum, normed space
-/
variable {α X E : Type*} [SeminormedAddCommGroup E] [NormedSpace ℝ E] [TopologicalSpace X]
section
variable {f : α → E} {l : Filter α} {s : Set α} {c : α} {y : E}
/-- If `f : α → E` is a function such that `norm ∘ f` has a maximum along a filter `l` at a point
`c` and `y` is a vector on the same ray as `f c`, then the function `fun x => ‖f x + y‖` has
a maximum along `l` at `c`. -/
theorem IsMaxFilter.norm_add_sameRay (h : IsMaxFilter (norm ∘ f) l c) (hy : SameRay ℝ (f c) y) :
IsMaxFilter (fun x => ‖f x + y‖) l c :=
h.mono fun x hx => by dsimp at hx ⊢; grw [hy.norm_add, norm_add_le, hx]
/-- If `f : α → E` is a function such that `norm ∘ f` has a maximum along a filter `l` at a point
`c`, then the function `fun x => ‖f x + f c‖` has a maximum along `l` at `c`. -/
theorem IsMaxFilter.norm_add_self (h : IsMaxFilter (norm ∘ f) l c) :
IsMaxFilter (fun x => ‖f x + f c‖) l c :=
IsMaxFilter.norm_add_sameRay h SameRay.rfl
/-- If `f : α → E` is a function such that `norm ∘ f` has a maximum on a set `s` at a point `c` and
`y` is a vector on the same ray as `f c`, then the function `fun x => ‖f x + y‖` has a maximum
on `s` at `c`. -/
theorem IsMaxOn.norm_add_sameRay (h : IsMaxOn (norm ∘ f) s c) (hy : SameRay ℝ (f c) y) :
IsMaxOn (fun x => ‖f x + y‖) s c :=
IsMaxFilter.norm_add_sameRay h hy
/-- If `f : α → E` is a function such that `norm ∘ f` has a maximum on a set `s` at a point `c`,
then the function `fun x => ‖f x + f c‖` has a maximum on `s` at `c`. -/
theorem IsMaxOn.norm_add_self (h : IsMaxOn (norm ∘ f) s c) : IsMaxOn (fun x => ‖f x + f c‖) s c :=
IsMaxFilter.norm_add_self h
end
variable {f : X → E} {s : Set X} {c : X} {y : E}
/-- If `f : α → E` is a function such that `norm ∘ f` has a local maximum on a set `s` at a point
`c` and `y` is a vector on the same ray as `f c`, then the function `fun x => ‖f x + y‖` has a local
maximum on `s` at `c`. -/
theorem IsLocalMaxOn.norm_add_sameRay (h : IsLocalMaxOn (norm ∘ f) s c) (hy : SameRay ℝ (f c) y) :
IsLocalMaxOn (fun x => ‖f x + y‖) s c :=
IsMaxFilter.norm_add_sameRay h hy
/-- If `f : α → E` is a function such that `norm ∘ f` has a local maximum on a set `s` at a point
`c`, then the function `fun x => ‖f x + f c‖` has a local maximum on `s` at `c`. -/
theorem IsLocalMaxOn.norm_add_self (h : IsLocalMaxOn (norm ∘ f) s c) :
IsLocalMaxOn (fun x => ‖f x + f c‖) s c :=
IsMaxFilter.norm_add_self h
/-- If `f : α → E` is a function such that `norm ∘ f` has a local maximum at a point `c` and `y` is
a vector on the same ray as `f c`, then the function `fun x => ‖f x + y‖` has a local maximum
at `c`. -/
theorem IsLocalMax.norm_add_sameRay (h : IsLocalMax (norm ∘ f) c) (hy : SameRay ℝ (f c) y) :
IsLocalMax (fun x => ‖f x + y‖) c :=
IsMaxFilter.norm_add_sameRay h hy
/-- If `f : α → E` is a function such that `norm ∘ f` has a local maximum at a point `c`, then the
function `fun x => ‖f x + f c‖` has a local maximum at `c`. -/
theorem IsLocalMax.norm_add_self (h : IsLocalMax (norm ∘ f) c) :
IsLocalMax (fun x => ‖f x + f c‖) c :=
IsMaxFilter.norm_add_self h |
.lake/packages/mathlib/Mathlib/Analysis/NormedSpace/DualNumber.lean | import Mathlib.Analysis.Normed.Algebra.DualNumber
deprecated_module (since := "2025-09-02") |
.lake/packages/mathlib/Mathlib/Analysis/NormedSpace/Real.lean | import Mathlib.Analysis.Normed.Module.RCLike.Real
deprecated_module (since := "2025-09-02") |
.lake/packages/mathlib/Mathlib/Analysis/NormedSpace/Multilinear/Curry.lean | import Mathlib.Analysis.NormedSpace.Multilinear.Basic
import Mathlib.LinearAlgebra.Multilinear.Curry
/-!
# Currying and uncurrying continuous multilinear maps
We associate to a continuous multilinear map in `n+1` variables (i.e., based on `Fin n.succ`) two
curried functions, named `f.curryLeft` (which is a continuous linear map on `E 0` taking values
in continuous multilinear maps in `n` variables) and `f.curryRight` (which is a continuous
multilinear map in `n` variables taking values in continuous linear maps on `E (last n)`).
The inverse operations are called `uncurryLeft` and `uncurryRight`.
We also register continuous linear equiv versions of these correspondences, in
`continuousMultilinearCurryLeftEquiv` and `continuousMultilinearCurryRightEquiv`.
## Main results
* `ContinuousMultilinearMap.curryLeft`, `ContinuousLinearMap.uncurryLeft` and
`continuousMultilinearCurryLeftEquiv`
* `ContinuousMultilinearMap.curryRight`, `ContinuousMultilinearMap.uncurryRight` and
`continuousMultilinearCurryRightEquiv`.
* `ContinuousMultilinearMap.curryMid`, `ContinuousLinearMap.uncurryMid` and
`ContinuousMultilinearMap.curryMidEquiv`
-/
suppress_compilation
noncomputable section
open NNReal Finset Metric ContinuousMultilinearMap Fin Function
/-!
### Type variables
We use the following type variables in this file:
* `𝕜` : a `NontriviallyNormedField`;
* `ι`, `ι'` : finite index types with decidable equality;
* `E`, `E₁` : families of normed vector spaces over `𝕜` indexed by `i : ι`;
* `E'` : a family of normed vector spaces over `𝕜` indexed by `i' : ι'`;
* `Ei` : a family of normed vector spaces over `𝕜` indexed by `i : Fin (Nat.succ n)`;
* `G`, `G'` : normed vector spaces over `𝕜`.
-/
universe u v v' wE wE₁ wE' wEi wG wG'
variable {𝕜 : Type u} {ι : Type v} {ι' : Type v'} {n : ℕ} {E : ι → Type wE}
{Ei : Fin n.succ → Type wEi} {G : Type wG} {G' : Type wG'} [Fintype ι]
[Fintype ι'] [NontriviallyNormedField 𝕜] [∀ i, NormedAddCommGroup (E i)]
[∀ i, NormedSpace 𝕜 (E i)] [∀ i, NormedAddCommGroup (Ei i)] [∀ i, NormedSpace 𝕜 (Ei i)]
[NormedAddCommGroup G] [NormedSpace 𝕜 G] [NormedAddCommGroup G'] [NormedSpace 𝕜 G']
theorem ContinuousLinearMap.norm_map_removeNth_le {i : Fin (n + 1)}
(f : Ei i →L[𝕜] ContinuousMultilinearMap 𝕜 (fun j ↦ Ei (i.succAbove j)) G) (m : ∀ i, Ei i) :
‖f (m i) (i.removeNth m)‖ ≤ ‖f‖ * ∏ j, ‖m j‖ := by
rw [i.prod_univ_succAbove, ← mul_assoc]
exact (f (m i)).le_of_opNorm_le (f.le_opNorm _) _
theorem ContinuousLinearMap.norm_map_tail_le
(f : Ei 0 →L[𝕜] ContinuousMultilinearMap 𝕜 (fun i : Fin n => Ei i.succ) G) (m : ∀ i, Ei i) :
‖f (m 0) (tail m)‖ ≤ ‖f‖ * ∏ i, ‖m i‖ :=
ContinuousLinearMap.norm_map_removeNth_le (i := 0) f m
theorem ContinuousMultilinearMap.norm_map_init_le
(f : ContinuousMultilinearMap 𝕜 (fun i : Fin n => Ei <| castSucc i) (Ei (last n) →L[𝕜] G))
(m : ∀ i, Ei i) : ‖f (init m) (m (last n))‖ ≤ ‖f‖ * ∏ i, ‖m i‖ := by
rw [prod_univ_castSucc, ← mul_assoc]
exact (f (init m)).le_of_opNorm_le (f.le_opNorm _) _
theorem ContinuousMultilinearMap.norm_map_insertNth_le (f : ContinuousMultilinearMap 𝕜 Ei G)
{i : Fin (n + 1)} (x : Ei i) (m : ∀ j, Ei (i.succAbove j)) :
‖f (i.insertNth x m)‖ ≤ ‖f‖ * ‖x‖ * ∏ i, ‖m i‖ := by
simpa [i.prod_univ_succAbove, mul_assoc] using f.le_opNorm (i.insertNth x m)
theorem ContinuousMultilinearMap.norm_map_cons_le (f : ContinuousMultilinearMap 𝕜 Ei G) (x : Ei 0)
(m : ∀ i : Fin n, Ei i.succ) : ‖f (cons x m)‖ ≤ ‖f‖ * ‖x‖ * ∏ i, ‖m i‖ := by
simpa [prod_univ_succ, mul_assoc] using f.le_opNorm (cons x m)
theorem ContinuousMultilinearMap.norm_map_snoc_le (f : ContinuousMultilinearMap 𝕜 Ei G)
(m : ∀ i : Fin n, Ei <| castSucc i) (x : Ei (last n)) :
‖f (snoc m x)‖ ≤ (‖f‖ * ∏ i, ‖m i‖) * ‖x‖ := by
simpa [prod_univ_castSucc, mul_assoc] using f.le_opNorm (snoc m x)
/-! #### Left currying -/
/-- Given a continuous linear map `f` from `E 0` to continuous multilinear maps on `n` variables,
construct the corresponding continuous multilinear map on `n+1` variables obtained by concatenating
the variables, given by `m ↦ f (m 0) (tail m)` -/
def ContinuousLinearMap.uncurryLeft
(f : Ei 0 →L[𝕜] ContinuousMultilinearMap 𝕜 (fun i : Fin n => Ei i.succ) G) :
ContinuousMultilinearMap 𝕜 Ei G :=
(ContinuousMultilinearMap.toMultilinearMapLinear ∘ₗ f.toLinearMap).uncurryLeft.mkContinuous
‖f‖ fun m => by exact ContinuousLinearMap.norm_map_tail_le f m
@[simp]
theorem ContinuousLinearMap.uncurryLeft_apply
(f : Ei 0 →L[𝕜] ContinuousMultilinearMap 𝕜 (fun i : Fin n => Ei i.succ) G) (m : ∀ i, Ei i) :
f.uncurryLeft m = f (m 0) (tail m) :=
rfl
/-- Given a continuous multilinear map `f` in `n+1` variables, split the first variable to obtain
a continuous linear map into continuous multilinear maps in `n` variables, given by
`x ↦ (m ↦ f (cons x m))`. -/
def ContinuousMultilinearMap.curryLeft (f : ContinuousMultilinearMap 𝕜 Ei G) :
Ei 0 →L[𝕜] ContinuousMultilinearMap 𝕜 (fun i : Fin n => Ei i.succ) G :=
MultilinearMap.mkContinuousLinear f.toMultilinearMap.curryLeft ‖f‖ f.norm_map_cons_le
@[simp]
theorem ContinuousMultilinearMap.curryLeft_apply (f : ContinuousMultilinearMap 𝕜 Ei G) (x : Ei 0)
(m : ∀ i : Fin n, Ei i.succ) : f.curryLeft x m = f (cons x m) :=
rfl
@[simp]
theorem ContinuousLinearMap.curry_uncurryLeft
(f : Ei 0 →L[𝕜] ContinuousMultilinearMap 𝕜 (fun i : Fin n => Ei i.succ) G) :
f.uncurryLeft.curryLeft = f := by
ext m x
rw [ContinuousMultilinearMap.curryLeft_apply, ContinuousLinearMap.uncurryLeft_apply, tail_cons,
cons_zero]
@[simp]
theorem ContinuousMultilinearMap.uncurry_curryLeft (f : ContinuousMultilinearMap 𝕜 Ei G) :
f.curryLeft.uncurryLeft = f :=
ContinuousMultilinearMap.toMultilinearMap_injective <| f.toMultilinearMap.uncurry_curryLeft
variable (𝕜 Ei G)
/-- The space of continuous multilinear maps on `Π(i : Fin (n+1)), E i` is canonically isomorphic to
the space of continuous linear maps from `E 0` to the space of continuous multilinear maps on
`Π(i : Fin n), E i.succ`, by separating the first variable. We register this isomorphism in
`continuousMultilinearCurryLeftEquiv 𝕜 E E₂`. The algebraic version (without topology) is given
in `multilinearCurryLeftEquiv 𝕜 E E₂`.
The direct and inverse maps are given by `f.curryLeft` and `f.uncurryLeft`. Use these
unless you need the full framework of linear isometric equivs. -/
def continuousMultilinearCurryLeftEquiv :
ContinuousMultilinearMap 𝕜 Ei G ≃ₗᵢ[𝕜]
Ei 0 →L[𝕜] ContinuousMultilinearMap 𝕜 (fun i : Fin n => Ei i.succ) G :=
LinearIsometryEquiv.ofBounds
{ toFun := ContinuousMultilinearMap.curryLeft
map_add' := fun _ _ => rfl
map_smul' := fun _ _ => rfl
invFun := ContinuousLinearMap.uncurryLeft
left_inv := ContinuousMultilinearMap.uncurry_curryLeft
right_inv := ContinuousLinearMap.curry_uncurryLeft }
(fun f => by dsimp; exact MultilinearMap.mkContinuousLinear_norm_le _ (norm_nonneg f) _)
(fun f => by
simp only [LinearEquiv.coe_symm_mk]
exact MultilinearMap.mkContinuous_norm_le _ (norm_nonneg f) _)
variable {𝕜 Ei G}
@[simp]
theorem continuousMultilinearCurryLeftEquiv_apply
(f : ContinuousMultilinearMap 𝕜 Ei G) (x : Ei 0) (v : Π i : Fin n, Ei i.succ) :
continuousMultilinearCurryLeftEquiv 𝕜 Ei G f x v = f (cons x v) :=
rfl
@[simp]
theorem continuousMultilinearCurryLeftEquiv_symm_apply
(f : Ei 0 →L[𝕜] ContinuousMultilinearMap 𝕜 (fun i : Fin n => Ei i.succ) G) (v : Π i, Ei i) :
(continuousMultilinearCurryLeftEquiv 𝕜 Ei G).symm f v = f (v 0) (tail v) :=
rfl
@[simp]
theorem ContinuousMultilinearMap.curryLeft_norm (f : ContinuousMultilinearMap 𝕜 Ei G) :
‖f.curryLeft‖ = ‖f‖ :=
(continuousMultilinearCurryLeftEquiv 𝕜 Ei G).norm_map f
@[simp]
theorem ContinuousLinearMap.uncurryLeft_norm
(f : Ei 0 →L[𝕜] ContinuousMultilinearMap 𝕜 (fun i : Fin n => Ei i.succ) G) :
‖f.uncurryLeft‖ = ‖f‖ :=
(continuousMultilinearCurryLeftEquiv 𝕜 Ei G).symm.norm_map f
/-! #### Right currying -/
/-- Given a continuous linear map `f` from continuous multilinear maps on `n` variables to
continuous linear maps on `E 0`, construct the corresponding continuous multilinear map on `n+1`
variables obtained by concatenating the variables, given by `m ↦ f (init m) (m (last n))`. -/
def ContinuousMultilinearMap.uncurryRight
(f : ContinuousMultilinearMap 𝕜 (fun i : Fin n => Ei <| castSucc i) (Ei (last n) →L[𝕜] G)) :
ContinuousMultilinearMap 𝕜 Ei G :=
let f' : MultilinearMap 𝕜 (fun i : Fin n => Ei <| castSucc i) (Ei (last n) →ₗ[𝕜] G) :=
(ContinuousLinearMap.coeLM 𝕜).compMultilinearMap f.toMultilinearMap
f'.uncurryRight.mkContinuous ‖f‖ fun m => f.norm_map_init_le m
@[simp]
theorem ContinuousMultilinearMap.uncurryRight_apply
(f : ContinuousMultilinearMap 𝕜 (fun i : Fin n => Ei <| castSucc i) (Ei (last n) →L[𝕜] G))
(m : ∀ i, Ei i) : f.uncurryRight m = f (init m) (m (last n)) :=
rfl
/-- Given a continuous multilinear map `f` in `n+1` variables, split the last variable to obtain
a continuous multilinear map in `n` variables into continuous linear maps, given by
`m ↦ (x ↦ f (snoc m x))`. -/
def ContinuousMultilinearMap.curryRight (f : ContinuousMultilinearMap 𝕜 Ei G) :
ContinuousMultilinearMap 𝕜 (fun i : Fin n => Ei <| castSucc i) (Ei (last n) →L[𝕜] G) :=
let f' : MultilinearMap 𝕜 (fun i : Fin n => Ei <| castSucc i) (Ei (last n) →L[𝕜] G) :=
{ toFun := fun m =>
(f.toMultilinearMap.curryRight m).mkContinuous (‖f‖ * ∏ i, ‖m i‖) fun x =>
f.norm_map_snoc_le m x
map_update_add' := fun m i x y => by
ext
simp
map_update_smul' := fun m i c x => by
ext
simp }
f'.mkContinuous ‖f‖ fun m => by
simp only [f', MultilinearMap.coe_mk]
exact LinearMap.mkContinuous_norm_le _ (by positivity) _
@[simp]
theorem ContinuousMultilinearMap.curryRight_apply (f : ContinuousMultilinearMap 𝕜 Ei G)
(m : ∀ i : Fin n, Ei <| castSucc i) (x : Ei (last n)) : f.curryRight m x = f (snoc m x) :=
rfl
@[simp]
theorem ContinuousMultilinearMap.curry_uncurryRight
(f : ContinuousMultilinearMap 𝕜 (fun i : Fin n => Ei <| castSucc i) (Ei (last n) →L[𝕜] G)) :
f.uncurryRight.curryRight = f := by
ext m x
rw [ContinuousMultilinearMap.curryRight_apply, ContinuousMultilinearMap.uncurryRight_apply,
snoc_last, init_snoc]
@[simp]
theorem ContinuousMultilinearMap.uncurry_curryRight (f : ContinuousMultilinearMap 𝕜 Ei G) :
f.curryRight.uncurryRight = f := by
ext m
rw [uncurryRight_apply, curryRight_apply, snoc_init_self]
variable (𝕜 Ei G)
/--
The space of continuous multilinear maps on `Π(i : Fin (n+1)), Ei i` is canonically isomorphic to
the space of continuous multilinear maps on `Π(i : Fin n), Ei <| castSucc i` with values in the
space of continuous linear maps on `Ei (last n)`, by separating the last variable. We register this
isomorphism as a continuous linear equiv in `continuousMultilinearCurryRightEquiv 𝕜 Ei G`.
The algebraic version (without topology) is given in `multilinearCurryRightEquiv 𝕜 Ei G`.
The direct and inverse maps are given by `f.curryRight` and `f.uncurryRight`. Use these
unless you need the full framework of linear isometric equivs.
-/
def continuousMultilinearCurryRightEquiv :
ContinuousMultilinearMap 𝕜 Ei G ≃ₗᵢ[𝕜]
ContinuousMultilinearMap 𝕜 (fun i : Fin n => Ei <| castSucc i) (Ei (last n) →L[𝕜] G) :=
LinearIsometryEquiv.ofBounds
{ toFun := ContinuousMultilinearMap.curryRight
map_add' := fun _ _ => rfl
map_smul' := fun _ _ => rfl
invFun := ContinuousMultilinearMap.uncurryRight
left_inv := ContinuousMultilinearMap.uncurry_curryRight
right_inv := ContinuousMultilinearMap.curry_uncurryRight }
(fun f => by
simp only [curryRight, LinearEquiv.coe_mk, LinearMap.coe_mk, AddHom.coe_mk]
exact MultilinearMap.mkContinuous_norm_le _ (norm_nonneg f) _)
(fun f => by
simp only [uncurryRight, LinearEquiv.coe_symm_mk]
exact MultilinearMap.mkContinuous_norm_le _ (norm_nonneg f) _)
variable (n G')
/-- The space of continuous multilinear maps on `Π(i : Fin (n+1)), G` is canonically isomorphic to
the space of continuous multilinear maps on `Π(i : Fin n), G` with values in the space
of continuous linear maps on `G`, by separating the last variable. We register this
isomorphism as a continuous linear equiv in `continuousMultilinearCurryRightEquiv' 𝕜 n G G'`.
For a version allowing dependent types, see `continuousMultilinearCurryRightEquiv`. When there
are no dependent types, use the primed version as it helps Lean a lot for unification.
The direct and inverse maps are given by `f.curryRight` and `f.uncurryRight`. Use these
unless you need the full framework of linear isometric equivs. -/
def continuousMultilinearCurryRightEquiv' : (G [×n.succ]→L[𝕜] G') ≃ₗᵢ[𝕜] G [×n]→L[𝕜] G →L[𝕜] G' :=
continuousMultilinearCurryRightEquiv 𝕜 (fun _ => G) G'
variable {n 𝕜 G Ei G'}
@[simp]
theorem continuousMultilinearCurryRightEquiv_apply
(f : ContinuousMultilinearMap 𝕜 Ei G) (v : Π i : Fin n, Ei <| castSucc i) (x : Ei (last n)) :
continuousMultilinearCurryRightEquiv 𝕜 Ei G f v x = f (snoc v x) :=
rfl
@[simp]
theorem continuousMultilinearCurryRightEquiv_symm_apply
(f : ContinuousMultilinearMap 𝕜 (fun i : Fin n => Ei <| castSucc i) (Ei (last n) →L[𝕜] G))
(v : Π i, Ei i) :
(continuousMultilinearCurryRightEquiv 𝕜 Ei G).symm f v = f (init v) (v (last n)) :=
rfl
@[simp]
theorem continuousMultilinearCurryRightEquiv_apply'
(f : G [×n.succ]→L[𝕜] G') (v : Fin n → G) (x : G) :
continuousMultilinearCurryRightEquiv' 𝕜 n G G' f v x = f (snoc v x) :=
rfl
@[simp]
theorem continuousMultilinearCurryRightEquiv_symm_apply'
(f : G [×n]→L[𝕜] G →L[𝕜] G') (v : Fin (n + 1) → G) :
(continuousMultilinearCurryRightEquiv' 𝕜 n G G').symm f v = f (init v) (v (last n)) :=
rfl
@[simp]
theorem ContinuousMultilinearMap.curryRight_norm (f : ContinuousMultilinearMap 𝕜 Ei G) :
‖f.curryRight‖ = ‖f‖ :=
(continuousMultilinearCurryRightEquiv 𝕜 Ei G).norm_map f
@[simp]
theorem ContinuousMultilinearMap.uncurryRight_norm
(f : ContinuousMultilinearMap 𝕜 (fun i : Fin n => Ei <| castSucc i) (Ei (last n) →L[𝕜] G)) :
‖f.uncurryRight‖ = ‖f‖ :=
(continuousMultilinearCurryRightEquiv 𝕜 Ei G).symm.norm_map f
/-!
### Currying a variable in the middle
-/
/-- Given a continuous linear map from `M p` to the space of continuous multilinear maps
in `n` variables `M 0`, ..., `M n` with `M p` removed,
returns a continuous multilinear map in all `n + 1` variables. -/
@[simps! apply]
def ContinuousLinearMap.uncurryMid (p : Fin (n + 1))
(f : Ei p →L[𝕜] ContinuousMultilinearMap 𝕜 (fun i ↦ Ei (p.succAbove i)) G) :
ContinuousMultilinearMap 𝕜 Ei G :=
(ContinuousMultilinearMap.toMultilinearMapLinear ∘ₗ f.toLinearMap).uncurryMid p
|>.mkContinuous ‖f‖ fun m => by exact ContinuousLinearMap.norm_map_removeNth_le f m
/-- Interpret a continuous multilinear map in `n + 1` variables
as a continuous linear map in `p`th variable
with values in the continuous multilinear maps in the other variables. -/
def ContinuousMultilinearMap.curryMid (p : Fin (n + 1)) (f : ContinuousMultilinearMap 𝕜 Ei G) :
Ei p →L[𝕜] ContinuousMultilinearMap 𝕜 (fun i ↦ Ei (p.succAbove i)) G :=
MultilinearMap.mkContinuousLinear (f.toMultilinearMap.curryMid p) ‖f‖ f.norm_map_insertNth_le
@[simp]
theorem ContinuousMultilinearMap.curryMid_apply (p : Fin (n + 1))
(f : ContinuousMultilinearMap 𝕜 Ei G) (x : Ei p) (m : ∀ i, Ei (p.succAbove i)) :
f.curryMid p x m = f (p.insertNth x m) :=
rfl
@[simp]
theorem ContinuousLinearMap.curryMid_uncurryMid (p : Fin (n + 1))
(f : Ei p →L[𝕜] ContinuousMultilinearMap 𝕜 (fun i ↦ Ei (p.succAbove i)) G) :
(f.uncurryMid p).curryMid p = f := by ext; simp
@[simp]
theorem ContinuousMultilinearMap.uncurryMid_curryMid (p : Fin (n + 1))
(f : ContinuousMultilinearMap 𝕜 Ei G) : (f.curryMid p).uncurryMid p = f :=
ContinuousMultilinearMap.toMultilinearMap_injective <| f.toMultilinearMap.uncurryMid_curryMid p
variable (𝕜 Ei G)
/-- `ContinuousMultilinearMap.curryMid` as a linear isometry equivalence. -/
@[simps! apply symm_apply]
def ContinuousMultilinearMap.curryMidEquiv (p : Fin (n + 1)) :
ContinuousMultilinearMap 𝕜 Ei G ≃ₗᵢ[𝕜]
Ei p →L[𝕜] ContinuousMultilinearMap 𝕜 (fun i ↦ Ei (p.succAbove i)) G :=
LinearIsometryEquiv.ofBounds
{ toFun := ContinuousMultilinearMap.curryMid p
map_add' := fun _ _ => rfl
map_smul' := fun _ _ => rfl
invFun := ContinuousLinearMap.uncurryMid p
left_inv := ContinuousMultilinearMap.uncurryMid_curryMid p
right_inv := ContinuousLinearMap.curryMid_uncurryMid p }
(fun f => by dsimp; exact MultilinearMap.mkContinuousLinear_norm_le _ (norm_nonneg f) _)
(fun f => by
simp only [LinearEquiv.coe_symm_mk]
exact MultilinearMap.mkContinuous_norm_le _ (norm_nonneg f) _)
variable {𝕜 Ei G}
@[simp]
theorem ContinuousMultilinearMap.norm_curryMid (p : Fin (n + 1))
(f : ContinuousMultilinearMap 𝕜 Ei G) : ‖f.curryMid p‖ = ‖f‖ :=
(ContinuousMultilinearMap.curryMidEquiv 𝕜 Ei G p).norm_map f
@[simp]
theorem ContinuousLinearMap.norm_uncurryMid (p : Fin (n + 1))
(f : Ei p →L[𝕜] ContinuousMultilinearMap 𝕜 (fun i ↦ Ei (p.succAbove i)) G) :
‖f.uncurryMid p‖ = ‖f‖ :=
(ContinuousMultilinearMap.curryMidEquiv 𝕜 Ei G p).symm.norm_map f
/-!
#### Currying with `0` variables
The space of multilinear maps with `0` variables is trivial: such a multilinear map is just an
arbitrary constant (note that multilinear maps in `0` variables need not map `0` to `0`!).
Therefore, the space of continuous multilinear maps on `(Fin 0) → G` with values in `E₂` is
isomorphic (and even isometric) to `E₂`. As this is the zeroth step in the construction of iterated
derivatives, we register this isomorphism. -/
section
/-- Associating to a continuous multilinear map in `0` variables the unique value it takes. -/
def ContinuousMultilinearMap.curry0 (f : ContinuousMultilinearMap 𝕜 (fun _ : Fin 0 => G) G') :
G' :=
f 0
variable (𝕜 G) in
/-- Associating to an element `x` of a vector space `E₂` the continuous multilinear map in `0`
variables taking the (unique) value `x` -/
def ContinuousMultilinearMap.uncurry0 (x : G') : G [×0]→L[𝕜] G' :=
ContinuousMultilinearMap.constOfIsEmpty 𝕜 _ x
variable (𝕜) in
@[simp]
theorem ContinuousMultilinearMap.uncurry0_apply (x : G') (m : Fin 0 → G) :
ContinuousMultilinearMap.uncurry0 𝕜 G x m = x :=
rfl
@[simp]
theorem ContinuousMultilinearMap.curry0_apply (f : G [×0]→L[𝕜] G') : f.curry0 = f 0 :=
rfl
@[simp]
theorem ContinuousMultilinearMap.apply_zero_uncurry0 (f : G [×0]→L[𝕜] G') {x : Fin 0 → G} :
ContinuousMultilinearMap.uncurry0 𝕜 G (f x) = f := by
ext m
simp [Subsingleton.elim x m]
theorem ContinuousMultilinearMap.uncurry0_curry0 (f : G [×0]→L[𝕜] G') :
ContinuousMultilinearMap.uncurry0 𝕜 G f.curry0 = f := by simp
variable (𝕜 G) in
theorem ContinuousMultilinearMap.curry0_uncurry0 (x : G') :
(ContinuousMultilinearMap.uncurry0 𝕜 G x).curry0 = x :=
rfl
variable (𝕜 G) in
@[simp]
theorem ContinuousMultilinearMap.uncurry0_norm (x : G') :
‖ContinuousMultilinearMap.uncurry0 𝕜 G x‖ = ‖x‖ :=
norm_constOfIsEmpty _ _ _
@[simp]
theorem ContinuousMultilinearMap.fin0_apply_norm (f : G [×0]→L[𝕜] G') {x : Fin 0 → G} :
‖f x‖ = ‖f‖ := by
obtain rfl : x = 0 := Subsingleton.elim _ _
refine le_antisymm (by simpa using f.le_opNorm 0) ?_
have : ‖ContinuousMultilinearMap.uncurry0 𝕜 G f.curry0‖ ≤ ‖f.curry0‖ :=
ContinuousMultilinearMap.opNorm_le_bound (norm_nonneg _) fun m => by
simp [-ContinuousMultilinearMap.apply_zero_uncurry0]
simpa [-Matrix.zero_empty] using this
theorem ContinuousMultilinearMap.curry0_norm (f : G [×0]→L[𝕜] G') : ‖f.curry0‖ = ‖f‖ := by simp
variable (𝕜 G G')
/-- The continuous linear isomorphism between elements of a normed space, and continuous multilinear
maps in `0` variables with values in this normed space.
The direct and inverse maps are `uncurry0` and `curry0`. Use these unless you need the full
framework of linear isometric equivs. -/
def continuousMultilinearCurryFin0 : (G [×0]→L[𝕜] G') ≃ₗᵢ[𝕜] G' where
toFun f := ContinuousMultilinearMap.curry0 f
invFun f := ContinuousMultilinearMap.uncurry0 𝕜 G f
map_add' _ _ := rfl
map_smul' _ _ := rfl
left_inv := ContinuousMultilinearMap.uncurry0_curry0
right_inv := ContinuousMultilinearMap.curry0_uncurry0 𝕜 G
norm_map' := ContinuousMultilinearMap.curry0_norm
variable {𝕜 G G'}
@[simp]
theorem continuousMultilinearCurryFin0_apply (f : G [×0]→L[𝕜] G') :
continuousMultilinearCurryFin0 𝕜 G G' f = f 0 :=
rfl
@[simp]
theorem continuousMultilinearCurryFin0_symm_apply (x : G') (v : Fin 0 → G) :
(continuousMultilinearCurryFin0 𝕜 G G').symm x v = x :=
rfl
end
/-! #### With 1 variable -/
variable (𝕜 G G')
/-- Continuous multilinear maps from `G^1` to `G'` are isomorphic with continuous linear maps from
`G` to `G'`. -/
def continuousMultilinearCurryFin1 : (G [×1]→L[𝕜] G') ≃ₗᵢ[𝕜] G →L[𝕜] G' :=
(continuousMultilinearCurryRightEquiv 𝕜 (fun _ : Fin 1 => G) G').trans
(continuousMultilinearCurryFin0 𝕜 G (G →L[𝕜] G'))
variable {𝕜 G G'}
@[simp]
theorem continuousMultilinearCurryFin1_apply (f : G [×1]→L[𝕜] G') (x : G) :
continuousMultilinearCurryFin1 𝕜 G G' f x = f (Fin.snoc 0 x) :=
rfl
@[simp]
theorem continuousMultilinearCurryFin1_symm_apply (f : G →L[𝕜] G') (v : Fin 1 → G) :
(continuousMultilinearCurryFin1 𝕜 G G').symm f v = f (v 0) :=
rfl
namespace ContinuousMultilinearMap
variable (𝕜 G G')
@[simp]
theorem norm_domDomCongr (σ : ι ≃ ι') (f : ContinuousMultilinearMap 𝕜 (fun _ : ι => G) G') :
‖domDomCongr σ f‖ = ‖f‖ := by
simp only [norm_def, ← σ.prod_comp,
(σ.arrowCongr (Equiv.refl G)).surjective.forall, domDomCongr_apply, Equiv.arrowCongr_apply,
Equiv.coe_refl, comp_apply, Equiv.symm_apply_apply, id]
/-- An equivalence of the index set defines a linear isometric equivalence between the spaces
of multilinear maps. -/
def domDomCongrₗᵢ (σ : ι ≃ ι') :
ContinuousMultilinearMap 𝕜 (fun _ : ι => G) G' ≃ₗᵢ[𝕜]
ContinuousMultilinearMap 𝕜 (fun _ : ι' => G) G' :=
{ domDomCongrEquiv σ with
map_add' := fun _ _ => rfl
map_smul' := fun _ _ => rfl
norm_map' := norm_domDomCongr 𝕜 G G' σ }
variable {𝕜 G G'}
section
/-- A continuous multilinear map with variables indexed by `ι ⊕ ι'` defines a continuous
multilinear map with variables indexed by `ι` taking values in the space of continuous multilinear
maps with variables indexed by `ι'`. -/
def currySum (f : ContinuousMultilinearMap 𝕜 (fun _ : ι ⊕ ι' => G) G') :
ContinuousMultilinearMap 𝕜 (fun _ : ι => G) (ContinuousMultilinearMap 𝕜 (fun _ : ι' => G) G') :=
MultilinearMap.mkContinuousMultilinear (MultilinearMap.currySum f.toMultilinearMap) ‖f‖
fun m m' => by simpa [Fintype.prod_sum_type, mul_assoc] using f.le_opNorm (Sum.elim m m')
@[simp]
theorem currySum_apply (f : ContinuousMultilinearMap 𝕜 (fun _ : ι ⊕ ι' => G) G') (m : ι → G)
(m' : ι' → G) : f.currySum m m' = f (Sum.elim m m') :=
rfl
/-- A continuous multilinear map with variables indexed by `ι` taking values in the space of
continuous multilinear maps with variables indexed by `ι'` defines a continuous multilinear map with
variables indexed by `ι ⊕ ι'`. -/
def uncurrySum (f : ContinuousMultilinearMap 𝕜 (fun _ : ι => G)
(ContinuousMultilinearMap 𝕜 (fun _ : ι' => G) G')) :
ContinuousMultilinearMap 𝕜 (fun _ : ι ⊕ ι' => G) G' :=
MultilinearMap.mkContinuous
(toMultilinearMapLinear.compMultilinearMap f.toMultilinearMap).uncurrySum ‖f‖ fun m => by
simpa [Fintype.prod_sum_type, mul_assoc] using
(f (m ∘ Sum.inl)).le_of_opNorm_le (f.le_opNorm _) (m ∘ Sum.inr)
@[simp]
theorem uncurrySum_apply (f : ContinuousMultilinearMap 𝕜 (fun _ : ι => G)
(ContinuousMultilinearMap 𝕜 (fun _ : ι' => G) G'))
(m : ι ⊕ ι' → G) : f.uncurrySum m = f (m ∘ Sum.inl) (m ∘ Sum.inr) :=
rfl
variable (𝕜 ι ι' G G')
/-- Linear isometric equivalence between the space of continuous multilinear maps with variables
indexed by `ι ⊕ ι'` and the space of continuous multilinear maps with variables indexed by `ι`
taking values in the space of continuous multilinear maps with variables indexed by `ι'`.
The forward and inverse functions are `ContinuousMultilinearMap.currySum`
and `ContinuousMultilinearMap.uncurrySum`. Use this definition only if you need
some properties of `LinearIsometryEquiv`. -/
def currySumEquiv : ContinuousMultilinearMap 𝕜 (fun _ : ι ⊕ ι' => G) G' ≃ₗᵢ[𝕜]
ContinuousMultilinearMap 𝕜 (fun _ : ι => G) (ContinuousMultilinearMap 𝕜 (fun _ : ι' => G) G') :=
LinearIsometryEquiv.ofBounds
{ toFun := currySum
invFun := uncurrySum
map_add' := fun f g => by
ext
rfl
map_smul' := fun c f => by
ext
rfl
left_inv := fun f => by
ext m
exact congr_arg f (Sum.elim_comp_inl_inr m) }
(fun f => MultilinearMap.mkContinuousMultilinear_norm_le _ (norm_nonneg f) _) fun f => by
simp only [LinearEquiv.coe_symm_mk]
exact MultilinearMap.mkContinuous_norm_le _ (norm_nonneg f) _
end
section
variable (𝕜 G G') {k l : ℕ} {s : Finset (Fin n)}
/-- If `s : Finset (Fin n)` is a finite set of cardinality `k` and its complement has cardinality
`l`, then the space of continuous multilinear maps `G [×n]→L[𝕜] G'` of `n` variables is isomorphic
to the space of continuous multilinear maps `G [×k]→L[𝕜] G [×l]→L[𝕜] G'` of `k` variables taking
values in the space of continuous multilinear maps of `l` variables. -/
def curryFinFinset {k l n : ℕ} {s : Finset (Fin n)} (hk : #s = k) (hl : #sᶜ = l) :
(G [×n]→L[𝕜] G') ≃ₗᵢ[𝕜] G [×k]→L[𝕜] G [×l]→L[𝕜] G' :=
(domDomCongrₗᵢ 𝕜 G G' (finSumEquivOfFinset hk hl).symm).trans
(currySumEquiv 𝕜 (Fin k) (Fin l) G G')
variable {𝕜 G G'}
@[simp]
theorem curryFinFinset_apply (hk : #s = k) (hl : #sᶜ = l) (f : G [×n]→L[𝕜] G')
(mk : Fin k → G) (ml : Fin l → G) : curryFinFinset 𝕜 G G' hk hl f mk ml =
f fun i => Sum.elim mk ml ((finSumEquivOfFinset hk hl).symm i) :=
rfl
@[simp]
theorem curryFinFinset_symm_apply (hk : #s = k) (hl : #sᶜ = l)
(f : G [×k]→L[𝕜] G [×l]→L[𝕜] G') (m : Fin n → G) : (curryFinFinset 𝕜 G G' hk hl).symm f m =
f (fun i => m <| finSumEquivOfFinset hk hl (Sum.inl i)) fun i =>
m <| finSumEquivOfFinset hk hl (Sum.inr i) :=
rfl
theorem curryFinFinset_symm_apply_piecewise_const (hk : #s = k) (hl : #sᶜ = l)
(f : G [×k]→L[𝕜] G [×l]→L[𝕜] G') (x y : G) :
(curryFinFinset 𝕜 G G' hk hl).symm f (s.piecewise (fun _ => x) fun _ => y) =
f (fun _ => x) fun _ => y :=
MultilinearMap.curryFinFinset_symm_apply_piecewise_const hk hl _ x y
@[simp]
theorem curryFinFinset_symm_apply_const (hk : #s = k) (hl : #sᶜ = l)
(f : G [×k]→L[𝕜] G [×l]→L[𝕜] G') (x : G) :
((curryFinFinset 𝕜 G G' hk hl).symm f fun _ => x) = f (fun _ => x) fun _ => x :=
rfl
theorem curryFinFinset_apply_const (hk : #s = k) (hl : #sᶜ = l) (f : G [×n]→L[𝕜] G')
(x y : G) : (curryFinFinset 𝕜 G G' hk hl f (fun _ => x) fun _ => y) =
f (s.piecewise (fun _ => x) fun _ => y) := by
refine (curryFinFinset_symm_apply_piecewise_const hk hl _ _ _).symm.trans ?_
rw [LinearIsometryEquiv.symm_apply_apply]
end
end ContinuousMultilinearMap
namespace ContinuousLinearMap
variable {F G : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F]
[NormedAddCommGroup G] [NormedSpace 𝕜 G]
/-- Given a linear map into continuous multilinear maps
`B : G →L[𝕜] ContinuousMultilinearMap 𝕜 E F`, one cannot always uncurry it as `G` and `E` might
live in a different universe. However, one can always lift it to a continuous multilinear map
on `(G × (Π i, E i)) ^ (1 + n)`, which maps `(v_0, ..., v_n)` to `B (g_0) (u_1, ..., u_n)` where
`g_0` is the `G`-coordinate of `v_0` and `u_i` is the `E_i` coordinate of `v_i`. -/
noncomputable def continuousMultilinearMapOption (B : G →L[𝕜] ContinuousMultilinearMap 𝕜 E F) :
ContinuousMultilinearMap 𝕜 (fun (_ : Option ι) ↦ (G × (Π i, E i))) F :=
MultilinearMap.mkContinuous
{ toFun := fun p ↦ B (p none).1 (fun i ↦ (p i).2 i)
map_update_add' := by
intro inst v j x y
match j with
| none => simp
| some j =>
classical
have B z : (fun i ↦ (Function.update v (some j) z (some i)).2 i) =
Function.update (fun (i : ι) ↦ (v i).2 i) j (z.2 j) := by
ext i
rcases eq_or_ne i j with rfl | hij
· simp
· simp [hij]
simp [B]
map_update_smul' := by
intro inst v j c x
match j with
| none => simp
| some j =>
classical
have B z : (fun i ↦ (Function.update v (some j) z (some i)).2 i) =
Function.update (fun (i : ι) ↦ (v i).2 i) j (z.2 j) := by
ext i
rcases eq_or_ne i j with rfl | hij
· simp
· simp [hij]
simp [B] } (‖B‖) <| by
intro b
simp only [MultilinearMap.coe_mk, Fintype.prod_option]
apply (ContinuousMultilinearMap.le_opNorm _ _).trans
rw [← mul_assoc]
gcongr with i _
· apply (B.le_opNorm _).trans
gcongr
exact norm_fst_le _
· exact (norm_le_pi_norm _ _).trans (norm_snd_le _)
lemma continuousMultilinearMapOption_apply_eq_self (B : G →L[𝕜] ContinuousMultilinearMap 𝕜 E F)
(a : G) (v : Π i, E i) : B.continuousMultilinearMapOption (fun _ ↦ (a, v)) = B a v := rfl
end ContinuousLinearMap |
.lake/packages/mathlib/Mathlib/Analysis/NormedSpace/Multilinear/Basic.lean | import Mathlib.Analysis.Normed.Operator.NormedSpace
import Mathlib.Logic.Embedding.Basic
import Mathlib.Data.Fintype.CardEmbedding
import Mathlib.Topology.Algebra.MetricSpace.Lipschitz
import Mathlib.Topology.Algebra.Module.Multilinear.Topology
/-!
# Operator norm on the space of continuous multilinear maps
When `f` is a continuous multilinear map in finitely many variables, we define its norm `‖f‖` as the
smallest number such that `‖f m‖ ≤ ‖f‖ * ∏ i, ‖m i‖` for all `m`.
We show that it is indeed a norm, and prove its basic properties.
## Main results
Let `f` be a multilinear map in finitely many variables.
* `exists_bound_of_continuous` asserts that, if `f` is continuous, then there exists `C > 0`
with `‖f m‖ ≤ C * ∏ i, ‖m i‖` for all `m`.
* `continuous_of_bound`, conversely, asserts that this bound implies continuity.
* `mkContinuous` constructs the associated continuous multilinear map.
Let `f` be a continuous multilinear map in finitely many variables.
* `‖f‖` is its norm, i.e., the smallest number such that `‖f m‖ ≤ ‖f‖ * ∏ i, ‖m i‖` for
all `m`.
* `le_opNorm f m` asserts the fundamental inequality `‖f m‖ ≤ ‖f‖ * ∏ i, ‖m i‖`.
* `norm_image_sub_le f m₁ m₂` gives a control of the difference `f m₁ - f m₂` in terms of
`‖f‖` and `‖m₁ - m₂‖`.
## Implementation notes
We mostly follow the API (and the proofs) of `OperatorNorm.lean`, with the additional complexity
that we should deal with multilinear maps in several variables.
From the mathematical point of view, all the results follow from the results on operator norm in
one variable, by applying them to one variable after the other through currying. However, this
is only well defined when there is an order on the variables (for instance on `Fin n`) although
the final result is independent of the order. While everything could be done following this
approach, it turns out that direct proofs are easier and more efficient.
-/
suppress_compilation
noncomputable section
open scoped NNReal Topology Uniformity
open Finset Metric Function Filter
/-!
### Type variables
We use the following type variables in this file:
* `𝕜` : a `NontriviallyNormedField`;
* `ι`, `ι'` : finite index types with decidable equality;
* `E`, `E₁` : families of normed vector spaces over `𝕜` indexed by `i : ι`;
* `E'` : a family of normed vector spaces over `𝕜` indexed by `i' : ι'`;
* `Ei` : a family of normed vector spaces over `𝕜` indexed by `i : Fin (Nat.succ n)`;
* `G`, `G'` : normed vector spaces over `𝕜`.
-/
universe u v v' wE wE₁ wE' wG wG'
section continuous_eval
variable {𝕜 ι : Type*} {E : ι → Type*} {F : Type*}
[NormedField 𝕜] [Finite ι] [∀ i, SeminormedAddCommGroup (E i)] [∀ i, NormedSpace 𝕜 (E i)]
[TopologicalSpace F] [AddCommGroup F] [IsTopologicalAddGroup F] [Module 𝕜 F]
instance ContinuousMultilinearMap.instContinuousEval :
ContinuousEval (ContinuousMultilinearMap 𝕜 E F) (Π i, E i) F where
continuous_eval := by
cases nonempty_fintype ι
let _ := IsTopologicalAddGroup.rightUniformSpace F
have := isUniformAddGroup_of_addCommGroup (G := F)
refine (UniformOnFun.continuousOn_eval₂ fun m ↦ ?_).comp_continuous
(isEmbedding_toUniformOnFun.continuous.prodMap continuous_id) fun (f, x) ↦ f.cont.continuousAt
exact ⟨ball m 1, NormedSpace.isVonNBounded_of_isBounded _ isBounded_ball,
ball_mem_nhds _ one_pos⟩
namespace ContinuousLinearMap
variable {G : Type*} [AddCommGroup G] [TopologicalSpace G] [Module 𝕜 G] [ContinuousConstSMul 𝕜 F]
lemma continuous_uncurry_of_multilinear (f : G →L[𝕜] ContinuousMultilinearMap 𝕜 E F) :
Continuous (fun (p : G × (Π i, E i)) ↦ f p.1 p.2) := by
fun_prop
lemma continuousOn_uncurry_of_multilinear (f : G →L[𝕜] ContinuousMultilinearMap 𝕜 E F) {s} :
ContinuousOn (fun (p : G × (Π i, E i)) ↦ f p.1 p.2) s :=
f.continuous_uncurry_of_multilinear.continuousOn
lemma continuousAt_uncurry_of_multilinear (f : G →L[𝕜] ContinuousMultilinearMap 𝕜 E F) {x} :
ContinuousAt (fun (p : G × (Π i, E i)) ↦ f p.1 p.2) x :=
f.continuous_uncurry_of_multilinear.continuousAt
lemma continuousWithinAt_uncurry_of_multilinear (f : G →L[𝕜] ContinuousMultilinearMap 𝕜 E F) {s x} :
ContinuousWithinAt (fun (p : G × (Π i, E i)) ↦ f p.1 p.2) s x :=
f.continuous_uncurry_of_multilinear.continuousWithinAt
end ContinuousLinearMap
end continuous_eval
section Seminorm
variable {𝕜 : Type u} {ι : Type v} {ι' : Type v'} {E : ι → Type wE} {E₁ : ι → Type wE₁}
{E' : ι' → Type wE'} {G : Type wG} {G' : Type wG'}
[Fintype ι'] [NontriviallyNormedField 𝕜] [∀ i, SeminormedAddCommGroup (E i)]
[∀ i, NormedSpace 𝕜 (E i)] [∀ i, SeminormedAddCommGroup (E₁ i)] [∀ i, NormedSpace 𝕜 (E₁ i)]
[SeminormedAddCommGroup G] [NormedSpace 𝕜 G] [SeminormedAddCommGroup G'] [NormedSpace 𝕜 G']
/-!
### Continuity properties of multilinear maps
We relate continuity of multilinear maps to the inequality `‖f m‖ ≤ C * ∏ i, ‖m i‖`, in
both directions. Along the way, we prove useful bounds on the difference `‖f m₁ - f m₂‖`.
-/
namespace MultilinearMap
/-- If `f` is a continuous multilinear map on `E`
and `m` is an element of `∀ i, E i` such that one of the `m i` has norm `0`,
then `f m` has norm `0`.
Note that we cannot drop the continuity assumption because `f (m : Unit → E) = f (m ())`,
where the domain has zero norm and the codomain has a nonzero norm
does not satisfy this condition. -/
lemma norm_map_coord_zero (f : MultilinearMap 𝕜 E G) (hf : Continuous f)
{m : ∀ i, E i} {i : ι} (hi : ‖m i‖ = 0) : ‖f m‖ = 0 := by
classical
rw [← inseparable_zero_iff_norm] at hi ⊢
have : Inseparable (update m i 0) m := inseparable_pi.2 <|
(forall_update_iff m fun i a ↦ Inseparable a (m i)).2 ⟨hi.symm, fun _ _ ↦ rfl⟩
simpa only [map_update_zero] using this.symm.map hf
variable [Fintype ι]
/-- If a multilinear map in finitely many variables on seminormed spaces
sends vectors with a component of norm zero to vectors of norm zero
and satisfies the inequality `‖f m‖ ≤ C * ∏ i, ‖m i‖` on a shell `ε i / ‖c i‖ < ‖m i‖ < ε i`
for some positive numbers `ε i` and elements `c i : 𝕜`, `1 < ‖c i‖`,
then it satisfies this inequality for all `m`.
The first assumption is automatically satisfied on normed spaces, see `bound_of_shell` below.
For seminormed spaces, it follows from continuity of `f`, see next lemma,
see `bound_of_shell_of_continuous` below. -/
theorem bound_of_shell_of_norm_map_coord_zero (f : MultilinearMap 𝕜 E G)
(hf₀ : ∀ {m i}, ‖m i‖ = 0 → ‖f m‖ = 0)
{ε : ι → ℝ} {C : ℝ} (hε : ∀ i, 0 < ε i) {c : ι → 𝕜} (hc : ∀ i, 1 < ‖c i‖)
(hf : ∀ m : ∀ i, E i, (∀ i, ε i / ‖c i‖ ≤ ‖m i‖) → (∀ i, ‖m i‖ < ε i) → ‖f m‖ ≤ C * ∏ i, ‖m i‖)
(m : ∀ i, E i) : ‖f m‖ ≤ C * ∏ i, ‖m i‖ := by
by_cases! hm : ∃ i, ‖m i‖ = 0
· rcases hm with ⟨i, hi⟩
rw [hf₀ hi, prod_eq_zero (mem_univ i) hi, mul_zero]
choose δ hδ0 hδm_lt hle_δm _ using fun i => rescale_to_shell_semi_normed (hc i) (hε i) (hm i)
have hδ0 : 0 < ∏ i, ‖δ i‖ := prod_pos fun i _ => norm_pos_iff.2 (hδ0 i)
simpa [map_smul_univ, norm_smul, prod_mul_distrib, mul_left_comm C, hδ0] using
hf (fun i => δ i • m i) hle_δm hδm_lt
/-- If a continuous multilinear map in finitely many variables on normed spaces satisfies
the inequality `‖f m‖ ≤ C * ∏ i, ‖m i‖` on a shell `ε i / ‖c i‖ < ‖m i‖ < ε i` for some positive
numbers `ε i` and elements `c i : 𝕜`, `1 < ‖c i‖`, then it satisfies this inequality for all `m`. -/
theorem bound_of_shell_of_continuous (f : MultilinearMap 𝕜 E G) (hfc : Continuous f)
{ε : ι → ℝ} {C : ℝ} (hε : ∀ i, 0 < ε i) {c : ι → 𝕜} (hc : ∀ i, 1 < ‖c i‖)
(hf : ∀ m : ∀ i, E i, (∀ i, ε i / ‖c i‖ ≤ ‖m i‖) → (∀ i, ‖m i‖ < ε i) → ‖f m‖ ≤ C * ∏ i, ‖m i‖)
(m : ∀ i, E i) : ‖f m‖ ≤ C * ∏ i, ‖m i‖ :=
bound_of_shell_of_norm_map_coord_zero f (norm_map_coord_zero f hfc) hε hc hf m
/-- If a multilinear map in finitely many variables on normed spaces is continuous, then it
satisfies the inequality `‖f m‖ ≤ C * ∏ i, ‖m i‖`, for some `C` which can be chosen to be
positive. -/
theorem exists_bound_of_continuous (f : MultilinearMap 𝕜 E G) (hf : Continuous f) :
∃ C : ℝ, 0 < C ∧ ∀ m, ‖f m‖ ≤ C * ∏ i, ‖m i‖ := by
cases isEmpty_or_nonempty ι
· refine ⟨‖f 0‖ + 1, add_pos_of_nonneg_of_pos (norm_nonneg _) zero_lt_one, fun m => ?_⟩
obtain rfl : m = 0 := funext (IsEmpty.elim ‹_›)
simp [univ_eq_empty, zero_le_one]
obtain ⟨ε : ℝ, ε0 : 0 < ε, hε : ∀ m : ∀ i, E i, ‖m - 0‖ < ε → ‖f m - f 0‖ < 1⟩ :=
NormedAddCommGroup.tendsto_nhds_nhds.1 (hf.tendsto 0) 1 zero_lt_one
simp only [sub_zero, f.map_zero] at hε
rcases NormedField.exists_one_lt_norm 𝕜 with ⟨c, hc⟩
have : 0 < (‖c‖ / ε) ^ Fintype.card ι := pow_pos (div_pos (zero_lt_one.trans hc) ε0) _
refine ⟨_, this, ?_⟩
refine f.bound_of_shell_of_continuous hf (fun _ => ε0) (fun _ => hc) fun m hcm hm => ?_
refine (hε m ((pi_norm_lt_iff ε0).2 hm)).le.trans ?_
rw [← div_le_iff₀' this, one_div, ← inv_pow, inv_div, Fintype.card, ← prod_const]
gcongr
apply hcm
/-- If a multilinear map `f` satisfies a boundedness property around `0`,
one can deduce a bound on `f m₁ - f m₂` using the multilinearity.
Here, we give a precise but hard to use version.
See `norm_image_sub_le_of_bound` for a less precise but more usable version.
The bound reads
`‖f m - f m'‖ ≤
C * ‖m 1 - m' 1‖ * max ‖m 2‖ ‖m' 2‖ * max ‖m 3‖ ‖m' 3‖ * ... * max ‖m n‖ ‖m' n‖ + ...`,
where the other terms in the sum are the same products where `1` is replaced by any `i`. -/
theorem norm_image_sub_le_of_bound' [DecidableEq ι] (f : MultilinearMap 𝕜 E G) {C : ℝ} (hC : 0 ≤ C)
(H : ∀ m, ‖f m‖ ≤ C * ∏ i, ‖m i‖) (m₁ m₂ : ∀ i, E i) :
‖f m₁ - f m₂‖ ≤ C * ∑ i, ∏ j, if j = i then ‖m₁ i - m₂ i‖ else max ‖m₁ j‖ ‖m₂ j‖ := by
have A :
∀ s : Finset ι,
‖f m₁ - f (s.piecewise m₂ m₁)‖ ≤
C * ∑ i ∈ s, ∏ j, if j = i then ‖m₁ i - m₂ i‖ else max ‖m₁ j‖ ‖m₂ j‖ := fun s ↦ by
induction s using Finset.induction with
| empty => simp
| insert i s his Hrec =>
have I :
‖f (s.piecewise m₂ m₁) - f ((insert i s).piecewise m₂ m₁)‖ ≤
C * ∏ j, if j = i then ‖m₁ i - m₂ i‖ else max ‖m₁ j‖ ‖m₂ j‖ := by
have A : (insert i s).piecewise m₂ m₁ = Function.update (s.piecewise m₂ m₁) i (m₂ i) :=
s.piecewise_insert _ _ _
have B : s.piecewise m₂ m₁ = Function.update (s.piecewise m₂ m₁) i (m₁ i) := by
simp [his]
rw [B, A, ← f.map_update_sub]
apply le_trans (H _)
gcongr with j
by_cases h : j = i
· rw [h]
simp
· by_cases h' : j ∈ s <;> simp [h', h]
calc
‖f m₁ - f ((insert i s).piecewise m₂ m₁)‖ ≤
‖f m₁ - f (s.piecewise m₂ m₁)‖ +
‖f (s.piecewise m₂ m₁) - f ((insert i s).piecewise m₂ m₁)‖ := by
rw [← dist_eq_norm, ← dist_eq_norm, ← dist_eq_norm]
exact dist_triangle _ _ _
_ ≤ (C * ∑ i ∈ s, ∏ j, if j = i then ‖m₁ i - m₂ i‖ else max ‖m₁ j‖ ‖m₂ j‖) +
C * ∏ j, if j = i then ‖m₁ i - m₂ i‖ else max ‖m₁ j‖ ‖m₂ j‖ :=
(add_le_add Hrec I)
_ = C * ∑ i ∈ insert i s, ∏ j, if j = i then ‖m₁ i - m₂ i‖ else max ‖m₁ j‖ ‖m₂ j‖ := by
simp [his, add_comm, left_distrib]
convert A univ
simp
/-- If `f` satisfies a boundedness property around `0`, one can deduce a bound on `f m₁ - f m₂`
using the multilinearity. Here, we give a usable but not very precise version. See
`norm_image_sub_le_of_bound'` for a more precise but less usable version. The bound is
`‖f m - f m'‖ ≤ C * card ι * ‖m - m'‖ * (max ‖m‖ ‖m'‖) ^ (card ι - 1)`. -/
theorem norm_image_sub_le_of_bound (f : MultilinearMap 𝕜 E G)
{C : ℝ} (hC : 0 ≤ C) (H : ∀ m, ‖f m‖ ≤ C * ∏ i, ‖m i‖) (m₁ m₂ : ∀ i, E i) :
‖f m₁ - f m₂‖ ≤ C * Fintype.card ι * max ‖m₁‖ ‖m₂‖ ^ (Fintype.card ι - 1) * ‖m₁ - m₂‖ := by
classical
have A :
∀ i : ι,
∏ j, (if j = i then ‖m₁ i - m₂ i‖ else max ‖m₁ j‖ ‖m₂ j‖) ≤
‖m₁ - m₂‖ * max ‖m₁‖ ‖m₂‖ ^ (Fintype.card ι - 1) := by
intro i
calc
∏ j, (if j = i then ‖m₁ i - m₂ i‖ else max ‖m₁ j‖ ‖m₂ j‖) ≤
∏ j : ι, Function.update (fun _ => max ‖m₁‖ ‖m₂‖) i ‖m₁ - m₂‖ j := by
gcongr with j
rcases eq_or_ne j i with rfl | h
· simp only [ite_true, Function.update_self]
exact norm_le_pi_norm (m₁ - m₂) _
· simp [h, - le_sup_iff, - sup_le_iff, sup_le_sup, norm_le_pi_norm]
_ = ‖m₁ - m₂‖ * max ‖m₁‖ ‖m₂‖ ^ (Fintype.card ι - 1) := by
rw [prod_update_of_mem (Finset.mem_univ _)]
simp [card_univ_diff]
calc
‖f m₁ - f m₂‖ ≤ C * ∑ i, ∏ j, if j = i then ‖m₁ i - m₂ i‖ else max ‖m₁ j‖ ‖m₂ j‖ :=
f.norm_image_sub_le_of_bound' hC H m₁ m₂
_ ≤ C * ∑ _i, ‖m₁ - m₂‖ * max ‖m₁‖ ‖m₂‖ ^ (Fintype.card ι - 1) := by gcongr; apply A
_ = C * Fintype.card ι * max ‖m₁‖ ‖m₂‖ ^ (Fintype.card ι - 1) * ‖m₁ - m₂‖ := by
rw [sum_const, card_univ, nsmul_eq_mul]
ring
/-- If a multilinear map satisfies an inequality `‖f m‖ ≤ C * ∏ i, ‖m i‖`, then it is
continuous. -/
theorem continuous_of_bound (f : MultilinearMap 𝕜 E G) (C : ℝ) (H : ∀ m, ‖f m‖ ≤ C * ∏ i, ‖m i‖) :
Continuous f := by
let D := max C 1
have D_pos : 0 ≤ D := le_trans zero_le_one (le_max_right _ _)
replace H (m) : ‖f m‖ ≤ D * ∏ i, ‖m i‖ :=
(H m).trans (mul_le_mul_of_nonneg_right (le_max_left _ _) <| by positivity)
refine continuous_iff_continuousAt.2 fun m => ?_
refine
continuousAt_of_locally_lipschitz zero_lt_one
(D * Fintype.card ι * (‖m‖ + 1) ^ (Fintype.card ι - 1)) fun m' h' => ?_
rw [dist_eq_norm, dist_eq_norm]
have : max ‖m'‖ ‖m‖ ≤ ‖m‖ + 1 := by
simp [zero_le_one, norm_le_of_mem_closedBall (le_of_lt h')]
calc
‖f m' - f m‖ ≤ D * Fintype.card ι * max ‖m'‖ ‖m‖ ^ (Fintype.card ι - 1) * ‖m' - m‖ :=
f.norm_image_sub_le_of_bound D_pos H m' m
_ ≤ D * Fintype.card ι * (‖m‖ + 1) ^ (Fintype.card ι - 1) * ‖m' - m‖ := by gcongr
/-- Constructing a continuous multilinear map from a multilinear map satisfying a boundedness
condition. -/
def mkContinuous (f : MultilinearMap 𝕜 E G) (C : ℝ) (H : ∀ m, ‖f m‖ ≤ C * ∏ i, ‖m i‖) :
ContinuousMultilinearMap 𝕜 E G :=
{ f with cont := f.continuous_of_bound C H }
@[simp]
theorem coe_mkContinuous (f : MultilinearMap 𝕜 E G) (C : ℝ) (H : ∀ m, ‖f m‖ ≤ C * ∏ i, ‖m i‖) :
⇑(f.mkContinuous C H) = f :=
rfl
/-- Given a multilinear map in `n` variables, if one restricts it to `k` variables putting `z` on
the other coordinates, then the resulting restricted function satisfies an inequality
`‖f.restr v‖ ≤ C * ‖z‖^(n-k) * Π ‖v i‖` if the original function satisfies `‖f v‖ ≤ C * Π ‖v i‖`. -/
theorem restr_norm_le {k n : ℕ} (f : MultilinearMap 𝕜 (fun _ : Fin n => G) G')
(s : Finset (Fin n)) (hk : #s = k) (z : G) {C : ℝ} (H : ∀ m, ‖f m‖ ≤ C * ∏ i, ‖m i‖)
(v : Fin k → G) : ‖f.restr s hk z v‖ ≤ C * ‖z‖ ^ (n - k) * ∏ i, ‖v i‖ := by
rw [mul_right_comm, mul_assoc]
convert H _ using 2
simp only [apply_dite norm, Fintype.prod_dite, prod_const ‖z‖, Finset.card_univ,
Fintype.card_of_subtype sᶜ fun _ => mem_compl, card_compl, Fintype.card_fin, hk, ←
(s.orderIsoOfFin hk).symm.bijective.prod_comp fun x => ‖v x‖]
convert rfl
end MultilinearMap
/-!
### Continuous multilinear maps
We define the norm `‖f‖` of a continuous multilinear map `f` in finitely many variables as the
smallest number such that `‖f m‖ ≤ ‖f‖ * ∏ i, ‖m i‖` for all `m`. We show that this
defines a normed space structure on `ContinuousMultilinearMap 𝕜 E G`.
-/
namespace ContinuousMultilinearMap
variable [Fintype ι]
theorem bound (f : ContinuousMultilinearMap 𝕜 E G) :
∃ C : ℝ, 0 < C ∧ ∀ m, ‖f m‖ ≤ C * ∏ i, ‖m i‖ :=
f.toMultilinearMap.exists_bound_of_continuous f.2
open Real
/-- The operator norm of a continuous multilinear map is the inf of all its bounds. -/
def opNorm (f : ContinuousMultilinearMap 𝕜 E G) : ℝ :=
sInf { c | 0 ≤ (c : ℝ) ∧ ∀ m, ‖f m‖ ≤ c * ∏ i, ‖m i‖ }
instance hasOpNorm : Norm (ContinuousMultilinearMap 𝕜 E G) :=
⟨opNorm⟩
/-- An alias of `ContinuousMultilinearMap.hasOpNorm` with non-dependent types to help typeclass
search. -/
instance hasOpNorm' : Norm (ContinuousMultilinearMap 𝕜 (fun _ : ι => G) G') :=
ContinuousMultilinearMap.hasOpNorm
theorem norm_def (f : ContinuousMultilinearMap 𝕜 E G) :
‖f‖ = sInf { c | 0 ≤ (c : ℝ) ∧ ∀ m, ‖f m‖ ≤ c * ∏ i, ‖m i‖ } :=
rfl
-- So that invocations of `le_csInf` make sense: we show that the set of
-- bounds is nonempty and bounded below.
theorem bounds_nonempty {f : ContinuousMultilinearMap 𝕜 E G} :
∃ c, c ∈ { c | 0 ≤ c ∧ ∀ m, ‖f m‖ ≤ c * ∏ i, ‖m i‖ } :=
let ⟨M, hMp, hMb⟩ := f.bound
⟨M, le_of_lt hMp, hMb⟩
theorem bounds_bddBelow {f : ContinuousMultilinearMap 𝕜 E G} :
BddBelow { c | 0 ≤ c ∧ ∀ m, ‖f m‖ ≤ c * ∏ i, ‖m i‖ } :=
⟨0, fun _ ⟨hn, _⟩ => hn⟩
theorem isLeast_opNorm (f : ContinuousMultilinearMap 𝕜 E G) :
IsLeast {c : ℝ | 0 ≤ c ∧ ∀ m, ‖f m‖ ≤ c * ∏ i, ‖m i‖} ‖f‖ := by
refine IsClosed.isLeast_csInf ?_ bounds_nonempty bounds_bddBelow
simp only [Set.setOf_and, Set.setOf_forall]
exact isClosed_Ici.inter (isClosed_iInter fun m ↦
isClosed_le continuous_const (continuous_id.mul continuous_const))
theorem opNorm_nonneg (f : ContinuousMultilinearMap 𝕜 E G) : 0 ≤ ‖f‖ :=
Real.sInf_nonneg fun _ ⟨hx, _⟩ => hx
/-- The fundamental property of the operator norm of a continuous multilinear map:
`‖f m‖` is bounded by `‖f‖` times the product of the `‖m i‖`. -/
theorem le_opNorm (f : ContinuousMultilinearMap 𝕜 E G) (m : ∀ i, E i) :
‖f m‖ ≤ ‖f‖ * ∏ i, ‖m i‖ :=
f.isLeast_opNorm.1.2 m
theorem le_mul_prod_of_opNorm_le_of_le {f : ContinuousMultilinearMap 𝕜 E G}
{m : ∀ i, E i} {C : ℝ} {b : ι → ℝ} (hC : ‖f‖ ≤ C) (hm : ∀ i, ‖m i‖ ≤ b i) :
‖f m‖ ≤ C * ∏ i, b i :=
(f.le_opNorm m).trans <| by gcongr; exacts [f.opNorm_nonneg.trans hC, hm _]
theorem le_opNorm_mul_prod_of_le (f : ContinuousMultilinearMap 𝕜 E G)
{m : ∀ i, E i} {b : ι → ℝ} (hm : ∀ i, ‖m i‖ ≤ b i) : ‖f m‖ ≤ ‖f‖ * ∏ i, b i :=
le_mul_prod_of_opNorm_le_of_le le_rfl hm
theorem le_opNorm_mul_pow_card_of_le (f : ContinuousMultilinearMap 𝕜 E G) {m b} (hm : ‖m‖ ≤ b) :
‖f m‖ ≤ ‖f‖ * b ^ Fintype.card ι := by
simpa only [prod_const] using f.le_opNorm_mul_prod_of_le fun i => (norm_le_pi_norm m i).trans hm
theorem le_opNorm_mul_pow_of_le {n : ℕ} {Ei : Fin n → Type*} [∀ i, SeminormedAddCommGroup (Ei i)]
[∀ i, NormedSpace 𝕜 (Ei i)] (f : ContinuousMultilinearMap 𝕜 Ei G) {m : ∀ i, Ei i} {b : ℝ}
(hm : ‖m‖ ≤ b) : ‖f m‖ ≤ ‖f‖ * b ^ n := by
simpa only [Fintype.card_fin] using f.le_opNorm_mul_pow_card_of_le hm
theorem le_of_opNorm_le {f : ContinuousMultilinearMap 𝕜 E G} {C : ℝ} (h : ‖f‖ ≤ C) (m : ∀ i, E i) :
‖f m‖ ≤ C * ∏ i, ‖m i‖ :=
le_mul_prod_of_opNorm_le_of_le h fun _ ↦ le_rfl
theorem ratio_le_opNorm (f : ContinuousMultilinearMap 𝕜 E G) (m : ∀ i, E i) :
(‖f m‖ / ∏ i, ‖m i‖) ≤ ‖f‖ :=
div_le_of_le_mul₀ (by positivity) (opNorm_nonneg _) (f.le_opNorm m)
/-- The image of the unit ball under a continuous multilinear map is bounded. -/
theorem unit_le_opNorm (f : ContinuousMultilinearMap 𝕜 E G) {m : ∀ i, E i} (h : ‖m‖ ≤ 1) :
‖f m‖ ≤ ‖f‖ :=
(le_opNorm_mul_pow_card_of_le f h).trans <| by simp
/-- If one controls the norm of every `f x`, then one controls the norm of `f`. -/
theorem opNorm_le_bound {f : ContinuousMultilinearMap 𝕜 E G}
{M : ℝ} (hMp : 0 ≤ M) (hM : ∀ m, ‖f m‖ ≤ M * ∏ i, ‖m i‖) : ‖f‖ ≤ M :=
csInf_le bounds_bddBelow ⟨hMp, hM⟩
theorem opNorm_le_iff {f : ContinuousMultilinearMap 𝕜 E G} {C : ℝ} (hC : 0 ≤ C) :
‖f‖ ≤ C ↔ ∀ m, ‖f m‖ ≤ C * ∏ i, ‖m i‖ :=
⟨fun h _ ↦ le_of_opNorm_le h _, opNorm_le_bound hC⟩
/-- The operator norm satisfies the triangle inequality. -/
theorem opNorm_add_le (f g : ContinuousMultilinearMap 𝕜 E G) : ‖f + g‖ ≤ ‖f‖ + ‖g‖ :=
opNorm_le_bound (add_nonneg (opNorm_nonneg f) (opNorm_nonneg g)) fun x => by
rw [add_mul]
exact norm_add_le_of_le (le_opNorm _ _) (le_opNorm _ _)
theorem opNorm_zero : ‖(0 : ContinuousMultilinearMap 𝕜 E G)‖ = 0 :=
(opNorm_nonneg _).antisymm' <| opNorm_le_bound le_rfl fun m => by simp
section
variable {𝕜' : Type*} [NormedField 𝕜'] [NormedSpace 𝕜' G] [SMulCommClass 𝕜 𝕜' G]
theorem opNorm_smul_le (c : 𝕜') (f : ContinuousMultilinearMap 𝕜 E G) : ‖c • f‖ ≤ ‖c‖ * ‖f‖ :=
(c • f).opNorm_le_bound (mul_nonneg (norm_nonneg _) (opNorm_nonneg _)) fun m ↦ by
rw [smul_apply, norm_smul, mul_assoc]
exact mul_le_mul_of_nonneg_left (le_opNorm _ _) (norm_nonneg _)
variable (𝕜 E G) in
/-- Operator seminorm on the space of continuous multilinear maps, as `Seminorm`.
We use this seminorm
to define a `SeminormedAddCommGroup` structure on `ContinuousMultilinearMap 𝕜 E G`,
but we have to override the projection `UniformSpace`
so that it is definitionally equal to the one coming from the topologies on `E` and `G`. -/
protected def seminorm : Seminorm 𝕜 (ContinuousMultilinearMap 𝕜 E G) :=
.ofSMulLE norm opNorm_zero opNorm_add_le fun c f ↦ f.opNorm_smul_le c
private lemma uniformity_eq_seminorm :
𝓤 (ContinuousMultilinearMap 𝕜 E G) = ⨅ r > 0, 𝓟 {f | ‖f.1 - f.2‖ < r} := by
refine (ContinuousMultilinearMap.seminorm 𝕜 E G).uniformity_eq_of_hasBasis
(ContinuousMultilinearMap.hasBasis_nhds_zero_of_basis Metric.nhds_basis_closedBall)
?_ fun (s, r) ⟨hs, hr⟩ ↦ ?_
· rcases NormedField.exists_lt_norm 𝕜 1 with ⟨c, hc⟩
have hc₀ : 0 < ‖c‖ := one_pos.trans hc
simp only [hasBasis_nhds_zero.mem_iff, Prod.exists]
use 1, closedBall 0 ‖c‖, closedBall 0 1
suffices ∀ f : ContinuousMultilinearMap 𝕜 E G, (∀ x, ‖x‖ ≤ ‖c‖ → ‖f x‖ ≤ 1) → ‖f‖ ≤ 1 by
simpa [NormedSpace.isVonNBounded_closedBall, closedBall_mem_nhds, Set.subset_def, Set.MapsTo]
intro f hf
refine opNorm_le_bound (by positivity) <|
f.1.bound_of_shell_of_continuous f.2 (fun _ ↦ hc₀) (fun _ ↦ hc) fun x hcx hx ↦ ?_
calc
‖f x‖ ≤ 1 := hf _ <| (pi_norm_le_iff_of_nonneg (norm_nonneg c)).2 fun i ↦ (hx i).le
_ = ∏ i : ι, 1 := by simp
_ ≤ ∏ i, ‖x i‖ := by gcongr with i; simpa only [div_self hc₀.ne'] using hcx i
_ = 1 * ∏ i, ‖x i‖ := (one_mul _).symm
· rcases (NormedSpace.isVonNBounded_iff' _).1 hs with ⟨ε, hε⟩
rcases exists_pos_mul_lt hr (ε ^ Fintype.card ι) with ⟨δ, hδ₀, hδ⟩
refine ⟨δ, hδ₀, fun f hf x hx ↦ ?_⟩
simp only [Seminorm.mem_ball_zero, mem_closedBall_zero_iff] at hf ⊢
replace hf : ‖f‖ ≤ δ := hf.le
replace hx : ‖x‖ ≤ ε := hε x hx
calc
‖f x‖ ≤ ‖f‖ * ε ^ Fintype.card ι := le_opNorm_mul_pow_card_of_le f hx
_ ≤ δ * ε ^ Fintype.card ι := by have := (norm_nonneg x).trans hx; gcongr
_ ≤ r := (mul_comm _ _).trans_le hδ.le
instance instPseudoMetricSpace : PseudoMetricSpace (ContinuousMultilinearMap 𝕜 E G) :=
.replaceUniformity
(ContinuousMultilinearMap.seminorm 𝕜 E G).toSeminormedAddCommGroup.toPseudoMetricSpace
uniformity_eq_seminorm
/-- Continuous multilinear maps themselves form a seminormed space with respect to
the operator norm. -/
instance seminormedAddCommGroup :
SeminormedAddCommGroup (ContinuousMultilinearMap 𝕜 E G) := ⟨fun _ _ ↦ rfl⟩
/-- An alias of `ContinuousMultilinearMap.seminormedAddCommGroup` with non-dependent types to help
typeclass search. -/
instance seminormedAddCommGroup' :
SeminormedAddCommGroup (ContinuousMultilinearMap 𝕜 (fun _ : ι => G) G') :=
ContinuousMultilinearMap.seminormedAddCommGroup
instance normedSpace : NormedSpace 𝕜' (ContinuousMultilinearMap 𝕜 E G) :=
⟨fun c f => f.opNorm_smul_le c⟩
/-- An alias of `ContinuousMultilinearMap.normedSpace` with non-dependent types to help typeclass
search. -/
instance normedSpace' : NormedSpace 𝕜' (ContinuousMultilinearMap 𝕜 (fun _ : ι => G') G) :=
ContinuousMultilinearMap.normedSpace
/-- The fundamental property of the operator norm of a continuous multilinear map:
`‖f m‖` is bounded by `‖f‖` times the product of the `‖m i‖`, `nnnorm` version. -/
theorem le_opNNNorm (f : ContinuousMultilinearMap 𝕜 E G) (m : ∀ i, E i) :
‖f m‖₊ ≤ ‖f‖₊ * ∏ i, ‖m i‖₊ :=
NNReal.coe_le_coe.1 <| by
push_cast
exact f.le_opNorm m
theorem le_of_opNNNorm_le (f : ContinuousMultilinearMap 𝕜 E G)
{C : ℝ≥0} (h : ‖f‖₊ ≤ C) (m : ∀ i, E i) : ‖f m‖₊ ≤ C * ∏ i, ‖m i‖₊ :=
(f.le_opNNNorm m).trans <| mul_le_mul' h le_rfl
theorem opNNNorm_le_iff {f : ContinuousMultilinearMap 𝕜 E G} {C : ℝ≥0} :
‖f‖₊ ≤ C ↔ ∀ m, ‖f m‖₊ ≤ C * ∏ i, ‖m i‖₊ := by
simp only [← NNReal.coe_le_coe]; simp [opNorm_le_iff C.coe_nonneg, NNReal.coe_prod]
theorem isLeast_opNNNorm (f : ContinuousMultilinearMap 𝕜 E G) :
IsLeast {C : ℝ≥0 | ∀ m, ‖f m‖₊ ≤ C * ∏ i, ‖m i‖₊} ‖f‖₊ := by
simpa only [← opNNNorm_le_iff] using isLeast_Ici
theorem opNNNorm_prod (f : ContinuousMultilinearMap 𝕜 E G) (g : ContinuousMultilinearMap 𝕜 E G') :
‖f.prod g‖₊ = max ‖f‖₊ ‖g‖₊ :=
eq_of_forall_ge_iff fun _ ↦ by
simp only [opNNNorm_le_iff, prod_apply, Prod.nnnorm_def, max_le_iff, forall_and]
theorem opNorm_prod (f : ContinuousMultilinearMap 𝕜 E G) (g : ContinuousMultilinearMap 𝕜 E G') :
‖f.prod g‖ = max ‖f‖ ‖g‖ :=
congr_arg NNReal.toReal (opNNNorm_prod f g)
theorem opNNNorm_pi
[∀ i', SeminormedAddCommGroup (E' i')] [∀ i', NormedSpace 𝕜 (E' i')]
(f : ∀ i', ContinuousMultilinearMap 𝕜 E (E' i')) : ‖pi f‖₊ = ‖f‖₊ :=
eq_of_forall_ge_iff fun _ ↦ by simpa [opNNNorm_le_iff, pi_nnnorm_le_iff] using forall_swap
theorem opNorm_pi {ι' : Type v'} [Fintype ι'] {E' : ι' → Type wE'}
[∀ i', SeminormedAddCommGroup (E' i')] [∀ i', NormedSpace 𝕜 (E' i')]
(f : ∀ i', ContinuousMultilinearMap 𝕜 E (E' i')) :
‖pi f‖ = ‖f‖ :=
congr_arg NNReal.toReal (opNNNorm_pi f)
section
@[simp]
theorem norm_ofSubsingleton [Subsingleton ι] (i : ι) (f : G →L[𝕜] G') :
‖ofSubsingleton 𝕜 G G' i f‖ = ‖f‖ := by
letI : Unique ι := uniqueOfSubsingleton i
simp [norm_def, ContinuousLinearMap.norm_def, (Equiv.funUnique _ _).symm.surjective.forall]
@[simp]
theorem nnnorm_ofSubsingleton [Subsingleton ι] (i : ι) (f : G →L[𝕜] G') :
‖ofSubsingleton 𝕜 G G' i f‖₊ = ‖f‖₊ :=
NNReal.eq <| norm_ofSubsingleton i f
variable (𝕜 G)
/-- Linear isometry between continuous linear maps from `G` to `G'`
and continuous `1`-multilinear maps from `G` to `G'`. -/
@[simps apply symm_apply]
def ofSubsingletonₗᵢ [Subsingleton ι] (i : ι) :
(G →L[𝕜] G') ≃ₗᵢ[𝕜] ContinuousMultilinearMap 𝕜 (fun _ : ι ↦ G) G' :=
{ ofSubsingleton 𝕜 G G' i with
map_add' := fun _ _ ↦ rfl
map_smul' := fun _ _ ↦ rfl
norm_map' := norm_ofSubsingleton i }
theorem norm_ofSubsingleton_id_le [Subsingleton ι] (i : ι) :
‖ofSubsingleton 𝕜 G G i (.id _ _)‖ ≤ 1 := by
rw [norm_ofSubsingleton]
apply ContinuousLinearMap.norm_id_le
theorem nnnorm_ofSubsingleton_id_le [Subsingleton ι] (i : ι) :
‖ofSubsingleton 𝕜 G G i (.id _ _)‖₊ ≤ 1 :=
norm_ofSubsingleton_id_le _ _ _
variable {G} (E)
@[simp]
theorem norm_constOfIsEmpty [IsEmpty ι] (x : G) : ‖constOfIsEmpty 𝕜 E x‖ = ‖x‖ := by
apply le_antisymm
· refine opNorm_le_bound (norm_nonneg _) fun x => ?_
rw [Fintype.prod_empty, mul_one, constOfIsEmpty_apply]
· simpa using (constOfIsEmpty 𝕜 E x).le_opNorm 0
@[simp]
theorem nnnorm_constOfIsEmpty [IsEmpty ι] (x : G) : ‖constOfIsEmpty 𝕜 E x‖₊ = ‖x‖₊ :=
NNReal.eq <| norm_constOfIsEmpty _ _ _
end
section
variable (𝕜 E E' G G')
/-- `ContinuousMultilinearMap.prod` as a `LinearIsometryEquiv`. -/
@[simps]
def prodL :
ContinuousMultilinearMap 𝕜 E G × ContinuousMultilinearMap 𝕜 E G' ≃ₗᵢ[𝕜]
ContinuousMultilinearMap 𝕜 E (G × G') where
__ := prodEquiv
map_add' _ _ := rfl
map_smul' _ _ := rfl
norm_map' f := opNorm_prod f.1 f.2
/-- `ContinuousMultilinearMap.pi` as a `LinearIsometryEquiv`. -/
@[simps! apply symm_apply]
def piₗᵢ {ι' : Type v'} [Fintype ι'] {E' : ι' → Type wE'} [∀ i', NormedAddCommGroup (E' i')]
[∀ i', NormedSpace 𝕜 (E' i')] :
(Π i', ContinuousMultilinearMap 𝕜 E (E' i'))
≃ₗᵢ[𝕜] (ContinuousMultilinearMap 𝕜 E (Π i, E' i)) where
toLinearEquiv := piLinearEquiv
norm_map' := opNorm_pi
end
end
section RestrictScalars
variable {𝕜' : Type*} [NontriviallyNormedField 𝕜'] [NormedAlgebra 𝕜' 𝕜]
variable [NormedSpace 𝕜' G] [IsScalarTower 𝕜' 𝕜 G]
variable [∀ i, NormedSpace 𝕜' (E i)] [∀ i, IsScalarTower 𝕜' 𝕜 (E i)]
@[simp]
theorem norm_restrictScalars (f : ContinuousMultilinearMap 𝕜 E G) :
‖f.restrictScalars 𝕜'‖ = ‖f‖ :=
rfl
variable (𝕜')
/-- `ContinuousMultilinearMap.restrictScalars` as a `LinearIsometry`. -/
def restrictScalarsₗᵢ : ContinuousMultilinearMap 𝕜 E G →ₗᵢ[𝕜'] ContinuousMultilinearMap 𝕜' E G where
toFun := restrictScalars 𝕜'
map_add' _ _ := rfl
map_smul' _ _ := rfl
norm_map' _ := rfl
end RestrictScalars
/-- The difference `f m₁ - f m₂` is controlled in terms of `‖f‖` and `‖m₁ - m₂‖`, precise version.
For a less precise but more usable version, see `norm_image_sub_le`. The bound reads
`‖f m - f m'‖ ≤
‖f‖ * ‖m 1 - m' 1‖ * max ‖m 2‖ ‖m' 2‖ * max ‖m 3‖ ‖m' 3‖ * ... * max ‖m n‖ ‖m' n‖ + ...`,
where the other terms in the sum are the same products where `1` is replaced by any `i`. -/
theorem norm_image_sub_le' [DecidableEq ι] (f : ContinuousMultilinearMap 𝕜 E G) (m₁ m₂ : ∀ i, E i) :
‖f m₁ - f m₂‖ ≤ ‖f‖ * ∑ i, ∏ j, if j = i then ‖m₁ i - m₂ i‖ else max ‖m₁ j‖ ‖m₂ j‖ :=
f.toMultilinearMap.norm_image_sub_le_of_bound' (norm_nonneg _) f.le_opNorm _ _
/-- The difference `f m₁ - f m₂` is controlled in terms of `‖f‖` and `‖m₁ - m₂‖`, less precise
version. For a more precise but less usable version, see `norm_image_sub_le'`.
The bound is `‖f m - f m'‖ ≤ ‖f‖ * card ι * ‖m - m'‖ * (max ‖m‖ ‖m'‖) ^ (card ι - 1)`. -/
theorem norm_image_sub_le (f : ContinuousMultilinearMap 𝕜 E G) (m₁ m₂ : ∀ i, E i) :
‖f m₁ - f m₂‖ ≤ ‖f‖ * Fintype.card ι * max ‖m₁‖ ‖m₂‖ ^ (Fintype.card ι - 1) * ‖m₁ - m₂‖ :=
f.toMultilinearMap.norm_image_sub_le_of_bound (norm_nonneg _) f.le_opNorm _ _
end ContinuousMultilinearMap
variable [Fintype ι]
/-- If a continuous multilinear map is constructed from a multilinear map via the constructor
`mkContinuous`, then its norm is bounded by the bound given to the constructor if it is
nonnegative. -/
theorem MultilinearMap.mkContinuous_norm_le (f : MultilinearMap 𝕜 E G) {C : ℝ} (hC : 0 ≤ C)
(H : ∀ m, ‖f m‖ ≤ C * ∏ i, ‖m i‖) : ‖f.mkContinuous C H‖ ≤ C :=
ContinuousMultilinearMap.opNorm_le_bound hC fun m => H m
/-- If a continuous multilinear map is constructed from a multilinear map via the constructor
`mkContinuous`, then its norm is bounded by the bound given to the constructor if it is
nonnegative. -/
theorem MultilinearMap.mkContinuous_norm_le' (f : MultilinearMap 𝕜 E G) {C : ℝ}
(H : ∀ m, ‖f m‖ ≤ C * ∏ i, ‖m i‖) : ‖f.mkContinuous C H‖ ≤ max C 0 :=
ContinuousMultilinearMap.opNorm_le_bound (le_max_right _ _) fun m ↦ (H m).trans <|
mul_le_mul_of_nonneg_right (le_max_left _ _) <| by positivity
namespace ContinuousMultilinearMap
/-- Given a continuous multilinear map `f` on `n` variables (parameterized by `Fin n`) and a subset
`s` of `k` of these variables, one gets a new continuous multilinear map on `Fin k` by varying
these variables, and fixing the other ones equal to a given value `z`. It is denoted by
`f.restr s hk z`, where `hk` is a proof that the cardinality of `s` is `k`. The implicit
identification between `Fin k` and `s` that we use is the canonical (increasing) bijection. -/
def restr {k n : ℕ} (f : (G [×n]→L[𝕜] G' :)) (s : Finset (Fin n)) (hk : #s = k) (z : G) :
G [×k]→L[𝕜] G' :=
(f.toMultilinearMap.restr s hk z).mkContinuous (‖f‖ * ‖z‖ ^ (n - k)) fun _ =>
MultilinearMap.restr_norm_le _ _ _ _ f.le_opNorm _
theorem norm_restr {k n : ℕ} (f : G [×n]→L[𝕜] G') (s : Finset (Fin n)) (hk : #s = k) (z : G) :
‖f.restr s hk z‖ ≤ ‖f‖ * ‖z‖ ^ (n - k) := by
apply MultilinearMap.mkContinuous_norm_le
exact mul_nonneg (norm_nonneg _) (pow_nonneg (norm_nonneg _) _)
section
variable {A : Type*} [NormedCommRing A] [NormedAlgebra 𝕜 A]
@[simp]
theorem norm_mkPiAlgebra_le [Nonempty ι] : ‖ContinuousMultilinearMap.mkPiAlgebra 𝕜 ι A‖ ≤ 1 := by
refine opNorm_le_bound zero_le_one fun m => ?_
simp only [ContinuousMultilinearMap.mkPiAlgebra_apply, one_mul]
exact norm_prod_le' _ univ_nonempty _
theorem norm_mkPiAlgebra_of_empty [IsEmpty ι] :
‖ContinuousMultilinearMap.mkPiAlgebra 𝕜 ι A‖ = ‖(1 : A)‖ := by
apply le_antisymm
· apply opNorm_le_bound <;> simp
· convert ratio_le_opNorm (ContinuousMultilinearMap.mkPiAlgebra 𝕜 ι A) fun _ => 1
simp
@[simp]
theorem norm_mkPiAlgebra [NormOneClass A] : ‖ContinuousMultilinearMap.mkPiAlgebra 𝕜 ι A‖ = 1 := by
cases isEmpty_or_nonempty ι
· simp [norm_mkPiAlgebra_of_empty]
· refine le_antisymm norm_mkPiAlgebra_le ?_
convert ratio_le_opNorm (ContinuousMultilinearMap.mkPiAlgebra 𝕜 ι A) fun _ => 1
simp
end
section
variable {n : ℕ} {A : Type*} [SeminormedRing A] [NormedAlgebra 𝕜 A]
theorem norm_mkPiAlgebraFin_succ_le : ‖ContinuousMultilinearMap.mkPiAlgebraFin 𝕜 n.succ A‖ ≤ 1 := by
refine opNorm_le_bound zero_le_one fun m => ?_
simp only [ContinuousMultilinearMap.mkPiAlgebraFin_apply, one_mul, List.ofFn_eq_map,
Fin.prod_univ_def]
refine (List.norm_prod_le' ?_).trans_eq ?_
· rw [Ne, List.map_eq_nil_iff, List.finRange_eq_nil]
exact Nat.succ_ne_zero _
rw [List.map_map, Function.comp_def]
theorem norm_mkPiAlgebraFin_le_of_pos (hn : 0 < n) :
‖ContinuousMultilinearMap.mkPiAlgebraFin 𝕜 n A‖ ≤ 1 := by
obtain ⟨n, rfl⟩ := Nat.exists_eq_succ_of_ne_zero hn.ne'
exact norm_mkPiAlgebraFin_succ_le
theorem norm_mkPiAlgebraFin_zero : ‖ContinuousMultilinearMap.mkPiAlgebraFin 𝕜 0 A‖ = ‖(1 : A)‖ := by
refine le_antisymm ?_ ?_
· refine opNorm_le_bound (norm_nonneg (1 : A)) ?_
simp
· convert ratio_le_opNorm (ContinuousMultilinearMap.mkPiAlgebraFin 𝕜 0 A) fun _ => (1 : A)
simp
theorem norm_mkPiAlgebraFin_le :
‖ContinuousMultilinearMap.mkPiAlgebraFin 𝕜 n A‖ ≤ max 1 ‖(1 : A)‖ := by
cases n
· exact norm_mkPiAlgebraFin_zero.le.trans (le_max_right _ _)
· exact (norm_mkPiAlgebraFin_le_of_pos (Nat.zero_lt_succ _)).trans (le_max_left _ _)
@[simp]
theorem norm_mkPiAlgebraFin [NormOneClass A] :
‖ContinuousMultilinearMap.mkPiAlgebraFin 𝕜 n A‖ = 1 := by
cases n
· rw [norm_mkPiAlgebraFin_zero]
simp
· refine le_antisymm norm_mkPiAlgebraFin_succ_le ?_
refine le_of_eq_of_le ?_ <|
ratio_le_opNorm (ContinuousMultilinearMap.mkPiAlgebraFin 𝕜 (Nat.succ _) A) fun _ => 1
simp
end
@[simp]
theorem nnnorm_smulRight (f : ContinuousMultilinearMap 𝕜 E 𝕜) (z : G) :
‖f.smulRight z‖₊ = ‖f‖₊ * ‖z‖₊ := by
refine le_antisymm ?_ ?_
· refine opNNNorm_le_iff.2 fun m => (nnnorm_smul_le _ _).trans ?_
rw [mul_right_comm]
gcongr
exact le_opNNNorm _ _
· obtain hz | hz := eq_zero_or_pos ‖z‖₊
· simp [hz]
rw [← le_div_iff₀ hz, opNNNorm_le_iff]
intro m
rw [div_mul_eq_mul_div, le_div_iff₀ hz]
refine le_trans ?_ ((f.smulRight z).le_opNNNorm m)
rw [smulRight_apply, nnnorm_smul]
@[simp]
theorem norm_smulRight (f : ContinuousMultilinearMap 𝕜 E 𝕜) (z : G) :
‖f.smulRight z‖ = ‖f‖ * ‖z‖ :=
congr_arg NNReal.toReal (nnnorm_smulRight f z)
@[simp]
theorem norm_mkPiRing (z : G) : ‖ContinuousMultilinearMap.mkPiRing 𝕜 ι z‖ = ‖z‖ := by
rw [ContinuousMultilinearMap.mkPiRing, norm_smulRight, norm_mkPiAlgebra, one_mul]
variable (𝕜 E G) in
/-- Continuous bilinear map realizing `(f, z) ↦ f.smulRight z`. -/
def smulRightL : ContinuousMultilinearMap 𝕜 E 𝕜 →L[𝕜] G →L[𝕜] ContinuousMultilinearMap 𝕜 E G :=
LinearMap.mkContinuous₂
{ toFun := fun f ↦
{ toFun := fun z ↦ f.smulRight z
map_add' := fun x y ↦ by ext; simp
map_smul' := fun c x ↦ by ext; simp [smul_smul, mul_comm] }
map_add' := fun f g ↦ by ext; simp [add_smul]
map_smul' := fun c f ↦ by ext; simp [smul_smul] }
1 (fun f z ↦ by simp [norm_smulRight])
@[simp] lemma smulRightL_apply (f : ContinuousMultilinearMap 𝕜 E 𝕜) (z : G) :
smulRightL 𝕜 E G f z = f.smulRight z := rfl
lemma norm_smulRightL_le : ‖smulRightL 𝕜 E G‖ ≤ 1 :=
LinearMap.mkContinuous₂_norm_le _ zero_le_one _
variable (𝕜 ι G)
/-- Continuous multilinear maps on `𝕜^n` with values in `G` are in bijection with `G`, as such a
continuous multilinear map is completely determined by its value on the constant vector made of
ones. We register this bijection as a linear isometry in
`ContinuousMultilinearMap.piFieldEquiv`. -/
protected def piFieldEquiv : G ≃ₗᵢ[𝕜] ContinuousMultilinearMap 𝕜 (fun _ : ι => 𝕜) G where
toFun z := ContinuousMultilinearMap.mkPiRing 𝕜 ι z
invFun f := f fun _ => 1
map_add' z z' := by
ext
simp [smul_add]
map_smul' c z := by
ext
simp [smul_smul, mul_comm]
left_inv z := by simp
right_inv f := f.mkPiRing_apply_one_eq_self
norm_map' := norm_mkPiRing
end ContinuousMultilinearMap
open ContinuousMultilinearMap
namespace MultilinearMap
/-- Given a map `f : G →ₗ[𝕜] MultilinearMap 𝕜 E G'` and an estimate
`H : ∀ x m, ‖f x m‖ ≤ C * ‖x‖ * ∏ i, ‖m i‖`, construct a continuous linear
map from `G` to `ContinuousMultilinearMap 𝕜 E G'`.
In order to lift, e.g., a map `f : (MultilinearMap 𝕜 E G) →ₗ[𝕜] MultilinearMap 𝕜 E' G'`
to a map `(ContinuousMultilinearMap 𝕜 E G) →L[𝕜] ContinuousMultilinearMap 𝕜 E' G'`,
one can apply this construction to `f.comp ContinuousMultilinearMap.toMultilinearMapLinear`
which is a linear map from `ContinuousMultilinearMap 𝕜 E G` to `MultilinearMap 𝕜 E' G'`. -/
def mkContinuousLinear (f : G →ₗ[𝕜] MultilinearMap 𝕜 E G') (C : ℝ)
(H : ∀ x m, ‖f x m‖ ≤ C * ‖x‖ * ∏ i, ‖m i‖) : G →L[𝕜] ContinuousMultilinearMap 𝕜 E G' :=
LinearMap.mkContinuous
{ toFun := fun x => (f x).mkContinuous (C * ‖x‖) <| H x
map_add' := fun x y => by
ext1
simp
map_smul' := fun c x => by
ext1
simp }
(max C 0) fun x => by
simpa using ((f x).mkContinuous_norm_le' _).trans_eq <| by
rw [max_mul_of_nonneg _ _ (norm_nonneg x), zero_mul]
theorem mkContinuousLinear_norm_le' (f : G →ₗ[𝕜] MultilinearMap 𝕜 E G') (C : ℝ)
(H : ∀ x m, ‖f x m‖ ≤ C * ‖x‖ * ∏ i, ‖m i‖) : ‖mkContinuousLinear f C H‖ ≤ max C 0 := by
dsimp only [mkContinuousLinear]
exact LinearMap.mkContinuous_norm_le _ (le_max_right _ _) _
theorem mkContinuousLinear_norm_le (f : G →ₗ[𝕜] MultilinearMap 𝕜 E G') {C : ℝ} (hC : 0 ≤ C)
(H : ∀ x m, ‖f x m‖ ≤ C * ‖x‖ * ∏ i, ‖m i‖) : ‖mkContinuousLinear f C H‖ ≤ C :=
(mkContinuousLinear_norm_le' f C H).trans_eq (max_eq_left hC)
variable [∀ i, SeminormedAddCommGroup (E' i)] [∀ i, NormedSpace 𝕜 (E' i)]
/-- Given a map `f : MultilinearMap 𝕜 E (MultilinearMap 𝕜 E' G)` and an estimate
`H : ∀ m m', ‖f m m'‖ ≤ C * ∏ i, ‖m i‖ * ∏ i, ‖m' i‖`, upgrade all `MultilinearMap`s in the type to
`ContinuousMultilinearMap`s. -/
def mkContinuousMultilinear (f : MultilinearMap 𝕜 E (MultilinearMap 𝕜 E' G)) (C : ℝ)
(H : ∀ m₁ m₂, ‖f m₁ m₂‖ ≤ (C * ∏ i, ‖m₁ i‖) * ∏ i, ‖m₂ i‖) :
ContinuousMultilinearMap 𝕜 E (ContinuousMultilinearMap 𝕜 E' G) :=
mkContinuous
{ toFun := fun m => mkContinuous (f m) (C * ∏ i, ‖m i‖) <| H m
map_update_add' := fun m i x y => by
ext1
simp
map_update_smul' := fun m i c x => by
ext1
simp }
(max C 0) fun m => by
simp only [coe_mk]
refine ((f m).mkContinuous_norm_le' _).trans_eq ?_
rw [max_mul_of_nonneg, zero_mul]
positivity
@[simp]
theorem mkContinuousMultilinear_apply (f : MultilinearMap 𝕜 E (MultilinearMap 𝕜 E' G)) {C : ℝ}
(H : ∀ m₁ m₂, ‖f m₁ m₂‖ ≤ (C * ∏ i, ‖m₁ i‖) * ∏ i, ‖m₂ i‖) (m : ∀ i, E i) :
⇑(mkContinuousMultilinear f C H m) = f m :=
rfl
theorem mkContinuousMultilinear_norm_le' (f : MultilinearMap 𝕜 E (MultilinearMap 𝕜 E' G)) (C : ℝ)
(H : ∀ m₁ m₂, ‖f m₁ m₂‖ ≤ (C * ∏ i, ‖m₁ i‖) * ∏ i, ‖m₂ i‖) :
‖mkContinuousMultilinear f C H‖ ≤ max C 0 := by
dsimp only [mkContinuousMultilinear]
exact mkContinuous_norm_le _ (le_max_right _ _) _
theorem mkContinuousMultilinear_norm_le (f : MultilinearMap 𝕜 E (MultilinearMap 𝕜 E' G)) {C : ℝ}
(hC : 0 ≤ C) (H : ∀ m₁ m₂, ‖f m₁ m₂‖ ≤ (C * ∏ i, ‖m₁ i‖) * ∏ i, ‖m₂ i‖) :
‖mkContinuousMultilinear f C H‖ ≤ C :=
(mkContinuousMultilinear_norm_le' f C H).trans_eq (max_eq_left hC)
end MultilinearMap
namespace ContinuousLinearMap
theorem norm_compContinuousMultilinearMap_le (g : G →L[𝕜] G') (f : ContinuousMultilinearMap 𝕜 E G) :
‖g.compContinuousMultilinearMap f‖ ≤ ‖g‖ * ‖f‖ :=
ContinuousMultilinearMap.opNorm_le_bound (by positivity) fun m ↦
calc
‖g (f m)‖ ≤ ‖g‖ * (‖f‖ * ∏ i, ‖m i‖) := g.le_opNorm_of_le <| f.le_opNorm _
_ = _ := (mul_assoc _ _ _).symm
variable (𝕜 E G G')
/-- `ContinuousLinearMap.compContinuousMultilinearMap` as a bundled continuous bilinear map. -/
def compContinuousMultilinearMapL :
(G →L[𝕜] G') →L[𝕜] ContinuousMultilinearMap 𝕜 E G →L[𝕜] ContinuousMultilinearMap 𝕜 E G' :=
LinearMap.mkContinuous₂
(LinearMap.mk₂ 𝕜 compContinuousMultilinearMap (fun _ _ _ => rfl) (fun _ _ _ => rfl)
(fun f g₁ g₂ => by ext1; apply f.map_add)
(fun c f g => by ext1; simp))
1
fun f g => by rw [one_mul]; exact f.norm_compContinuousMultilinearMap_le g
variable {𝕜 G G'}
/-- `ContinuousLinearMap.compContinuousMultilinearMap` as a bundled
continuous linear equiv. -/
def _root_.ContinuousLinearEquiv.continuousMultilinearMapCongrRight (g : G ≃L[𝕜] G') :
ContinuousMultilinearMap 𝕜 E G ≃L[𝕜] ContinuousMultilinearMap 𝕜 E G' :=
{ compContinuousMultilinearMapL 𝕜 E G G' g.toContinuousLinearMap with
invFun := compContinuousMultilinearMapL 𝕜 E G' G g.symm.toContinuousLinearMap
left_inv := by
intro f
ext1 m
simp [compContinuousMultilinearMapL]
right_inv := by
intro f
ext1 m
simp [compContinuousMultilinearMapL]
continuous_invFun :=
(compContinuousMultilinearMapL 𝕜 E G' G g.symm.toContinuousLinearMap).continuous }
@[simp]
theorem _root_.ContinuousLinearEquiv.continuousMultilinearMapCongrRight_symm (g : G ≃L[𝕜] G') :
(g.continuousMultilinearMapCongrRight E).symm = g.symm.continuousMultilinearMapCongrRight E :=
rfl
variable {E}
@[simp]
theorem _root_.ContinuousLinearEquiv.continuousMultilinearMapCongrRight_apply (g : G ≃L[𝕜] G')
(f : ContinuousMultilinearMap 𝕜 E G) :
g.continuousMultilinearMapCongrRight E f = (g : G →L[𝕜] G').compContinuousMultilinearMap f :=
rfl
/-- Flip arguments in `f : G →L[𝕜] ContinuousMultilinearMap 𝕜 E G'` to get
`ContinuousMultilinearMap 𝕜 E (G →L[𝕜] G')` -/
@[simps! apply_apply]
def flipMultilinear (f : G →L[𝕜] ContinuousMultilinearMap 𝕜 E G') :
ContinuousMultilinearMap 𝕜 E (G →L[𝕜] G') :=
MultilinearMap.mkContinuous
{ toFun := fun m =>
LinearMap.mkContinuous
{ toFun := fun x => f x m
map_add' := fun x y => by simp only [map_add, ContinuousMultilinearMap.add_apply]
map_smul' := fun c x => by
simp only [ContinuousMultilinearMap.smul_apply, map_smul, RingHom.id_apply] }
(‖f‖ * ∏ i, ‖m i‖) fun x => by
rw [mul_right_comm]
exact (f x).le_of_opNorm_le (f.le_opNorm x) _
map_update_add' := fun m i x y => by
ext1
simp only [add_apply, ContinuousMultilinearMap.map_update_add, LinearMap.coe_mk,
LinearMap.mkContinuous_apply, AddHom.coe_mk]
map_update_smul' := fun m i c x => by
ext1
simp only [coe_smul', ContinuousMultilinearMap.map_update_smul, LinearMap.coe_mk,
LinearMap.mkContinuous_apply, Pi.smul_apply, AddHom.coe_mk] }
‖f‖ fun m => by
dsimp only [MultilinearMap.coe_mk]
exact LinearMap.mkContinuous_norm_le _ (by positivity) _
/-- Flip arguments in `f : ContinuousMultilinearMap 𝕜 E (G →L[𝕜] G')` to get
`G →L[𝕜] ContinuousMultilinearMap 𝕜 E G'` -/
@[simps! apply_apply]
def _root_.ContinuousMultilinearMap.flipLinear (f : ContinuousMultilinearMap 𝕜 E (G →L[𝕜] G')) :
G →L[𝕜] ContinuousMultilinearMap 𝕜 E G' :=
MultilinearMap.mkContinuousLinear
{ toFun x :=
{ toFun m := f m x
map_update_add' := by simp
map_update_smul' := by simp }
map_add' x y := by ext1; simp
map_smul' c x := by ext1; simp } ‖f‖ <| fun x m ↦ by
rw [LinearMap.coe_mk, AddHom.coe_mk, MultilinearMap.coe_mk, mul_right_comm]
apply ((f m).le_opNorm x).trans
gcongr
apply f.le_opNorm
@[simp] lemma flipLinear_flipMultilinear (f : G →L[𝕜] ContinuousMultilinearMap 𝕜 E G') :
f.flipMultilinear.flipLinear = f := rfl
@[simp] lemma _root_.ContinuousMultilinearMap.flipMultilinear_flipLinear
(f : ContinuousMultilinearMap 𝕜 E (G →L[𝕜] G')) :
f.flipLinear.flipMultilinear = f := rfl
variable (𝕜 E G G') in
/-- Flipping arguments gives a linear equivalence between `G →L[𝕜] ContinuousMultilinearMap 𝕜 E G'`
and `ContinuousMultilinearMap 𝕜 E (G →L[𝕜] G')` -/
def flipMultilinearEquivₗ : (G →L[𝕜] ContinuousMultilinearMap 𝕜 E G') ≃ₗ[𝕜]
(ContinuousMultilinearMap 𝕜 E (G →L[𝕜] G')) where
toFun f := f.flipMultilinear
invFun f := f.flipLinear
map_add' f g := by ext; simp
map_smul' c f := by ext; simp
left_inv f := rfl
right_inv f := rfl
variable (𝕜 E G G') in
/-- Flipping arguments gives a continuous linear equivalence between
`G →L[𝕜] ContinuousMultilinearMap 𝕜 E G'` and `ContinuousMultilinearMap 𝕜 E (G →L[𝕜] G')` -/
def flipMultilinearEquiv : (G →L[𝕜] ContinuousMultilinearMap 𝕜 E G') ≃L[𝕜]
ContinuousMultilinearMap 𝕜 E (G →L[𝕜] G') := by
refine (flipMultilinearEquivₗ 𝕜 E G G').toContinuousLinearEquivOfBounds 1 1 ?_ ?_
· intro f
suffices ‖f.flipMultilinear‖ ≤ ‖f‖ by simpa
apply MultilinearMap.mkContinuous_norm_le
positivity
· intro f
suffices ‖f.flipLinear‖ ≤ ‖f‖ by simpa
apply MultilinearMap.mkContinuousLinear_norm_le
positivity
@[simp] lemma coe_flipMultilinearEquiv :
(flipMultilinearEquiv 𝕜 E G G' : (G →L[𝕜] ContinuousMultilinearMap 𝕜 E G') →
(ContinuousMultilinearMap 𝕜 E (G →L[𝕜] G'))) = flipMultilinear := rfl
@[simp] lemma coe_symm_flipMultilinearEquiv :
((flipMultilinearEquiv 𝕜 E G G').symm : (ContinuousMultilinearMap 𝕜 E (G →L[𝕜] G')) →
(G →L[𝕜] ContinuousMultilinearMap 𝕜 E G')) = flipLinear := rfl
end ContinuousLinearMap
theorem LinearIsometry.norm_compContinuousMultilinearMap (g : G →ₗᵢ[𝕜] G')
(f : ContinuousMultilinearMap 𝕜 E G) :
‖g.toContinuousLinearMap.compContinuousMultilinearMap f‖ = ‖f‖ := by
simp only [ContinuousLinearMap.compContinuousMultilinearMap_coe,
LinearIsometry.coe_toContinuousLinearMap, LinearIsometry.norm_map,
ContinuousMultilinearMap.norm_def, Function.comp_apply]
namespace ContinuousMultilinearMap
theorem norm_compContinuousLinearMap_le (g : ContinuousMultilinearMap 𝕜 E₁ G)
(f : ∀ i, E i →L[𝕜] E₁ i) : ‖g.compContinuousLinearMap f‖ ≤ ‖g‖ * ∏ i, ‖f i‖ :=
opNorm_le_bound (by positivity) fun m =>
calc
‖g fun i => f i (m i)‖ ≤ ‖g‖ * ∏ i, ‖f i (m i)‖ := g.le_opNorm _
_ ≤ ‖g‖ * ∏ i, ‖f i‖ * ‖m i‖ := by gcongr with i; exact (f i).le_opNorm (m i)
_ = (‖g‖ * ∏ i, ‖f i‖) * ∏ i, ‖m i‖ := by rw [prod_mul_distrib, mul_assoc]
theorem norm_compContinuous_linearIsometry_le (g : ContinuousMultilinearMap 𝕜 E₁ G)
(f : ∀ i, E i →ₗᵢ[𝕜] E₁ i) :
‖g.compContinuousLinearMap fun i => (f i).toContinuousLinearMap‖ ≤ ‖g‖ := by
refine opNorm_le_bound (norm_nonneg _) fun m => ?_
apply (g.le_opNorm _).trans _
simp only [ContinuousLinearMap.coe_coe, LinearIsometry.coe_toContinuousLinearMap,
LinearIsometry.norm_map, le_rfl]
theorem norm_compContinuous_linearIsometryEquiv (g : ContinuousMultilinearMap 𝕜 E₁ G)
(f : ∀ i, E i ≃ₗᵢ[𝕜] E₁ i) :
‖g.compContinuousLinearMap fun i => (f i : E i →L[𝕜] E₁ i)‖ = ‖g‖ := by
apply le_antisymm (g.norm_compContinuous_linearIsometry_le fun i => (f i).toLinearIsometry)
have : g = (g.compContinuousLinearMap fun i => (f i : E i →L[𝕜] E₁ i)).compContinuousLinearMap
fun i => ((f i).symm : E₁ i →L[𝕜] E i) := by
ext1 m
simp only [compContinuousLinearMap_apply, LinearIsometryEquiv.coe_coe'',
LinearIsometryEquiv.apply_symm_apply]
conv_lhs => rw [this]
apply (g.compContinuousLinearMap fun i =>
(f i : E i →L[𝕜] E₁ i)).norm_compContinuous_linearIsometry_le
fun i => (f i).symm.toLinearIsometry
/-- `ContinuousMultilinearMap.compContinuousLinearMap` as a bundled continuous linear map.
This implementation fixes `f : Π i, E i →L[𝕜] E₁ i`.
Actually, the map is multilinear in `f`,
see `ContinuousMultilinearMap.compContinuousLinearMapContinuousMultilinear`.
For a version fixing `g` and varying `f`, see `compContinuousLinearMapLRight`. -/
def compContinuousLinearMapL (f : ∀ i, E i →L[𝕜] E₁ i) :
ContinuousMultilinearMap 𝕜 E₁ G →L[𝕜] ContinuousMultilinearMap 𝕜 E G :=
LinearMap.mkContinuous
{ toFun := fun g => g.compContinuousLinearMap f
map_add' := fun _ _ => rfl
map_smul' := fun _ _ => rfl }
(∏ i, ‖f i‖)
fun _ => (norm_compContinuousLinearMap_le _ _).trans_eq (mul_comm _ _)
@[simp]
theorem compContinuousLinearMapL_apply (g : ContinuousMultilinearMap 𝕜 E₁ G)
(f : ∀ i, E i →L[𝕜] E₁ i) : compContinuousLinearMapL f g = g.compContinuousLinearMap f :=
rfl
variable (G) in
theorem norm_compContinuousLinearMapL_le (f : ∀ i, E i →L[𝕜] E₁ i) :
‖compContinuousLinearMapL (G := G) f‖ ≤ ∏ i, ‖f i‖ :=
LinearMap.mkContinuous_norm_le _ (by positivity) _
/-- `ContinuousMultilinearMap.compContinuousLinearMap` as a bundled continuous linear map.
This implementation fixes `g : ContinuousMultilinearMap 𝕜 E₁ G`.
Actually, the map is linear in `g`,
see `ContinuousMultilinearMap.compContinuousLinearMapContinuousMultilinear`.
For a version fixing `f` and varying `g`, see `compContinuousLinearMapL`. -/
def compContinuousLinearMapLRight (g : ContinuousMultilinearMap 𝕜 E₁ G) :
ContinuousMultilinearMap 𝕜 (fun i ↦ E i →L[𝕜] E₁ i) (ContinuousMultilinearMap 𝕜 E G) :=
MultilinearMap.mkContinuous
{ toFun := fun f => g.compContinuousLinearMap f
map_update_add' := by
intro h f i f₁ f₂
ext x
simp only [compContinuousLinearMap_apply, add_apply]
convert g.map_update_add (fun j ↦ f j (x j)) i (f₁ (x i)) (f₂ (x i)) <;>
exact apply_update (fun (i : ι) (f : E i →L[𝕜] E₁ i) ↦ f (x i)) f i _ _
map_update_smul' := by
intro h f i a f₀
ext x
simp only [compContinuousLinearMap_apply, smul_apply]
convert g.map_update_smul (fun j ↦ f j (x j)) i a (f₀ (x i)) <;>
exact apply_update (fun (i : ι) (f : E i →L[𝕜] E₁ i) ↦ f (x i)) f i _ _ }
(‖g‖) (fun f ↦ by simp [norm_compContinuousLinearMap_le])
@[simp]
theorem compContinuousLinearMapLRight_apply (g : ContinuousMultilinearMap 𝕜 E₁ G)
(f : ∀ i, E i →L[𝕜] E₁ i) : compContinuousLinearMapLRight g f = g.compContinuousLinearMap f :=
rfl
variable (E) in
theorem norm_compContinuousLinearMapLRight_le (g : ContinuousMultilinearMap 𝕜 E₁ G) :
‖compContinuousLinearMapLRight (E := E) g‖ ≤ ‖g‖ :=
MultilinearMap.mkContinuous_norm_le _ (norm_nonneg _) _
variable (𝕜 E E₁ G)
open Function in
/-- If `f` is a collection of continuous linear maps, then the construction
`ContinuousMultilinearMap.compContinuousLinearMap`
sending a continuous multilinear map `g` to `g (f₁ ·, ..., fₙ ·)`
is continuous-linear in `g` and multilinear in `f₁, ..., fₙ`. -/
noncomputable def compContinuousLinearMapMultilinear :
MultilinearMap 𝕜 (fun i ↦ E i →L[𝕜] E₁ i)
((ContinuousMultilinearMap 𝕜 E₁ G) →L[𝕜] ContinuousMultilinearMap 𝕜 E G) where
toFun := compContinuousLinearMapL
map_update_add' f i f₁ f₂ := by
ext g x
change (g fun j ↦ update f i (f₁ + f₂) j <| x j) =
(g fun j ↦ update f i f₁ j <| x j) + g fun j ↦ update f i f₂ j (x j)
convert g.map_update_add (fun j ↦ f j (x j)) i (f₁ (x i)) (f₂ (x i)) <;>
exact apply_update (fun (i : ι) (f : E i →L[𝕜] E₁ i) ↦ f (x i)) f i _ _
map_update_smul' f i a f₀ := by
ext g x
change (g fun j ↦ update f i (a • f₀) j <| x j) = a • g fun j ↦ update f i f₀ j (x j)
convert g.map_update_smul (fun j ↦ f j (x j)) i a (f₀ (x i)) <;>
exact apply_update (fun (i : ι) (f : E i →L[𝕜] E₁ i) ↦ f (x i)) f i _ _
/-- If `f` is a collection of continuous linear maps, then the construction
`ContinuousMultilinearMap.compContinuousLinearMap`
sending a continuous multilinear map `g` to `g (f₁ ·, ..., fₙ ·)` is continuous-linear in `g` and
continuous-multilinear in `f₁, ..., fₙ`. -/
@[simps! apply_apply]
noncomputable def compContinuousLinearMapContinuousMultilinear :
ContinuousMultilinearMap 𝕜 (fun i ↦ E i →L[𝕜] E₁ i)
((ContinuousMultilinearMap 𝕜 E₁ G) →L[𝕜] ContinuousMultilinearMap 𝕜 E G) :=
MultilinearMap.mkContinuous (𝕜 := 𝕜) (E := fun i ↦ E i →L[𝕜] E₁ i)
(G := (ContinuousMultilinearMap 𝕜 E₁ G) →L[𝕜] ContinuousMultilinearMap 𝕜 E G)
(compContinuousLinearMapMultilinear 𝕜 E E₁ G) 1 fun f ↦ by
rw [one_mul]
apply norm_compContinuousLinearMapL_le
variable {𝕜 E E₁ G}
/-- Fréchet derivative of `compContinuousLinearMap f g` with respect to `g`.
The derivative with respect to `f` is given by `compContinuousLinearMapL`. -/
noncomputable def fderivCompContinuousLinearMap [DecidableEq ι]
(f : ContinuousMultilinearMap 𝕜 E₁ G) (g : ∀ i, E i →L[𝕜] E₁ i) :
(∀ i, E i →L[𝕜] E₁ i) →L[𝕜] ContinuousMultilinearMap 𝕜 E G :=
ContinuousLinearMap.apply _ _ f
|>.compContinuousMultilinearMap (compContinuousLinearMapContinuousMultilinear 𝕜 _ _ _)
|>.linearDeriv g
@[simp]
lemma fderivCompContinuousLinearMap_apply [DecidableEq ι]
(f : ContinuousMultilinearMap 𝕜 E₁ G) (g : ∀ i, E i →L[𝕜] E₁ i)
(dg : ∀ i, E i →L[𝕜] E₁ i) (v : ∀ i, E i) :
f.fderivCompContinuousLinearMap g dg v = ∑ i, f fun j ↦ (update g i (dg i) j) (v j) := by
simp [fderivCompContinuousLinearMap]
variable (G)
/-- `ContinuousMultilinearMap.compContinuousLinearMap` as a bundled continuous linear equiv,
given `f : Π i, E i ≃L[𝕜] E₁ i`. -/
def _root_.ContinuousLinearEquiv.continuousMultilinearMapCongrLeft (f : ∀ i, E i ≃L[𝕜] E₁ i) :
ContinuousMultilinearMap 𝕜 E₁ G ≃L[𝕜] ContinuousMultilinearMap 𝕜 E G :=
{ compContinuousLinearMapL fun i => (f i : E i →L[𝕜] E₁ i) with
invFun := compContinuousLinearMapL fun i => ((f i).symm : E₁ i →L[𝕜] E i)
continuous_toFun := (compContinuousLinearMapL fun i => (f i : E i →L[𝕜] E₁ i)).continuous
continuous_invFun :=
(compContinuousLinearMapL fun i => ((f i).symm : E₁ i →L[𝕜] E i)).continuous
left_inv := by
intro g
ext1 m
simp only [LinearMap.toFun_eq_coe, ContinuousLinearMap.coe_coe,
compContinuousLinearMapL_apply, compContinuousLinearMap_apply,
ContinuousLinearEquiv.coe_coe, ContinuousLinearEquiv.apply_symm_apply]
right_inv := by
intro g
ext1 m
simp only [compContinuousLinearMapL_apply, LinearMap.toFun_eq_coe,
ContinuousLinearMap.coe_coe, compContinuousLinearMap_apply, ContinuousLinearEquiv.coe_coe,
ContinuousLinearEquiv.symm_apply_apply] }
@[simp]
theorem _root_.ContinuousLinearEquiv.continuousMultilinearMapCongrLeft_symm
(f : ∀ i, E i ≃L[𝕜] E₁ i) :
(ContinuousLinearEquiv.continuousMultilinearMapCongrLeft G f).symm =
.continuousMultilinearMapCongrLeft G fun i : ι => (f i).symm :=
rfl
variable {G}
@[simp]
theorem _root_.ContinuousLinearEquiv.continuousMultilinearMapCongrLeft_apply
(g : ContinuousMultilinearMap 𝕜 E₁ G) (f : ∀ i, E i ≃L[𝕜] E₁ i) :
ContinuousLinearEquiv.continuousMultilinearMapCongrLeft G f g =
g.compContinuousLinearMap fun i => (f i : E i →L[𝕜] E₁ i) :=
rfl
/-- One of the components of the iterated derivative of a continuous multilinear map. Given a
bijection `e` between a type `α` (typically `Fin k`) and a subset `s` of `ι`, this component is a
continuous multilinear map of `k` vectors `v₁, ..., vₖ`, mapping them
to `f (x₁, (v_{e.symm 2})₂, x₃, ...)`, where at indices `i` in `s` one uses the `i`-th coordinate of
the vector `v_{e.symm i}` and otherwise one uses the `i`-th coordinate of a reference vector `x`.
This is continuous multilinear in the components of `x` outside of `s`, and in the `v_j`. -/
noncomputable def iteratedFDerivComponent {α : Type*} [Fintype α]
(f : ContinuousMultilinearMap 𝕜 E₁ G) {s : Set ι} (e : α ≃ s) [DecidablePred (· ∈ s)] :
ContinuousMultilinearMap 𝕜 (fun (i : {a : ι // a ∉ s}) ↦ E₁ i)
(ContinuousMultilinearMap 𝕜 (fun (_ : α) ↦ (∀ i, E₁ i)) G) :=
(f.toMultilinearMap.iteratedFDerivComponent e).mkContinuousMultilinear ‖f‖ <| by
intro x m
simp only [MultilinearMap.iteratedFDerivComponent, MultilinearMap.domDomRestrictₗ,
MultilinearMap.coe_mk, MultilinearMap.domDomRestrict_apply, coe_coe]
apply (f.le_opNorm _).trans _
classical
rw [← prod_compl_mul_prod s.toFinset, mul_assoc]
gcongr
· apply le_of_eq
have : ∀ x, x ∈ s.toFinsetᶜ ↔ (fun x ↦ x ∉ s) x := by simp
rw [prod_subtype _ this]
congr with i
simp [i.2]
· rw [prod_subtype _ (fun _ ↦ s.mem_toFinset), ← Equiv.prod_comp e.symm]
gcongr with i
simpa only [i.2, ↓reduceDIte, Subtype.coe_eta] using norm_le_pi_norm (m (e.symm i)) ↑i
@[simp] lemma iteratedFDerivComponent_apply {α : Type*} [Fintype α]
(f : ContinuousMultilinearMap 𝕜 E₁ G) {s : Set ι} (e : α ≃ s) [DecidablePred (· ∈ s)]
(v : ∀ i : {a : ι // a ∉ s}, E₁ i) (w : α → (∀ i, E₁ i)) :
f.iteratedFDerivComponent e v w =
f (fun j ↦ if h : j ∈ s then w (e.symm ⟨j, h⟩) j else v ⟨j, h⟩) := by
simp [iteratedFDerivComponent, MultilinearMap.iteratedFDerivComponent,
MultilinearMap.domDomRestrictₗ]
lemma norm_iteratedFDerivComponent_le {α : Type*} [Fintype α]
(f : ContinuousMultilinearMap 𝕜 E₁ G) {s : Set ι} (e : α ≃ s) [DecidablePred (· ∈ s)]
(x : (i : ι) → E₁ i) :
‖f.iteratedFDerivComponent e (x ·)‖ ≤ ‖f‖ * ‖x‖ ^ (Fintype.card ι - Fintype.card α) := calc
‖f.iteratedFDerivComponent e (fun i ↦ x i)‖
≤ ‖f.iteratedFDerivComponent e‖ * ∏ i : {a : ι // a ∉ s}, ‖x i‖ :=
ContinuousMultilinearMap.le_opNorm _ _
_ ≤ ‖f‖ * ∏ _i : {a : ι // a ∉ s}, ‖x‖ := by
gcongr
· exact MultilinearMap.mkContinuousMultilinear_norm_le _ (norm_nonneg _) _
· exact norm_le_pi_norm _ _
_ = ‖f‖ * ‖x‖ ^ (Fintype.card {a : ι // a ∉ s}) := by rw [prod_const, card_univ]
_ = ‖f‖ * ‖x‖ ^ (Fintype.card ι - Fintype.card α) := by simp [Fintype.card_congr e]
open Classical in
/-- The `k`-th iterated derivative of a continuous multilinear map `f` at the point `x`. It is a
continuous multilinear map of `k` vectors `v₁, ..., vₖ` (with the same type as `x`), mapping them
to `∑ f (x₁, (v_{i₁})₂, x₃, ...)`, where at each index `j` one uses either `xⱼ` or one
of the `(vᵢ)ⱼ`, and each `vᵢ` has to be used exactly once.
The sum is parameterized by the embeddings of `Fin k` in the index type `ι` (or, equivalently,
by the subsets `s` of `ι` of cardinality `k` and then the bijections between `Fin k` and `s`).
The fact that this is indeed the iterated Fréchet derivative is proved in
`ContinuousMultilinearMap.iteratedFDeriv_eq`.
-/
protected def iteratedFDeriv (f : ContinuousMultilinearMap 𝕜 E₁ G) (k : ℕ) (x : (i : ι) → E₁ i) :
ContinuousMultilinearMap 𝕜 (fun (_ : Fin k) ↦ (∀ i, E₁ i)) G :=
∑ e : Fin k ↪ ι, iteratedFDerivComponent f e.toEquivRange (Pi.compRightL 𝕜 _ Subtype.val x)
/-- Controlling the norm of `f.iteratedFDeriv` when `f` is continuous multilinear. For the same
bound on the iterated derivative of `f` in the calculus sense,
see `ContinuousMultilinearMap.norm_iteratedFDeriv_le`. -/
lemma norm_iteratedFDeriv_le' (f : ContinuousMultilinearMap 𝕜 E₁ G) (k : ℕ) (x : (i : ι) → E₁ i) :
‖f.iteratedFDeriv k x‖
≤ Nat.descFactorial (Fintype.card ι) k * ‖f‖ * ‖x‖ ^ (Fintype.card ι - k) := by
classical
calc ‖f.iteratedFDeriv k x‖
_ ≤ ∑ e : Fin k ↪ ι, ‖iteratedFDerivComponent f e.toEquivRange (fun i ↦ x i)‖ := norm_sum_le _ _
_ ≤ ∑ _ : Fin k ↪ ι, ‖f‖ * ‖x‖ ^ (Fintype.card ι - k) := by
gcongr with e _
simpa using norm_iteratedFDerivComponent_le f e.toEquivRange x
_ = Nat.descFactorial (Fintype.card ι) k * ‖f‖ * ‖x‖ ^ (Fintype.card ι - k) := by
simp [card_univ, mul_assoc]
end ContinuousMultilinearMap
end Seminorm
section Norm
namespace ContinuousMultilinearMap
/-! Results that are only true if the target space is a `NormedAddCommGroup` (and not just a
`SeminormedAddCommGroup`). -/
variable {𝕜 : Type u} {ι : Type v} {E : ι → Type wE} {G : Type wG} {G' : Type wG'} [Fintype ι]
[NontriviallyNormedField 𝕜] [∀ i, SeminormedAddCommGroup (E i)] [∀ i, NormedSpace 𝕜 (E i)]
[NormedAddCommGroup G] [NormedSpace 𝕜 G] [SeminormedAddCommGroup G'] [NormedSpace 𝕜 G']
/-- A continuous linear map is zero iff its norm vanishes. -/
theorem opNorm_zero_iff {f : ContinuousMultilinearMap 𝕜 E G} : ‖f‖ = 0 ↔ f = 0 := by
simp [← (opNorm_nonneg f).ge_iff_eq', opNorm_le_iff le_rfl, ContinuousMultilinearMap.ext_iff]
/-- Continuous multilinear maps themselves form a normed group with respect to
the operator norm. -/
instance normedAddCommGroup : NormedAddCommGroup (ContinuousMultilinearMap 𝕜 E G) :=
NormedAddCommGroup.ofSeparation fun _ ↦ opNorm_zero_iff.mp
/-- An alias of `ContinuousMultilinearMap.normedAddCommGroup` with non-dependent types to help
typeclass search. -/
instance normedAddCommGroup' :
NormedAddCommGroup (ContinuousMultilinearMap 𝕜 (fun _ : ι => G') G) :=
ContinuousMultilinearMap.normedAddCommGroup
variable (𝕜 G)
theorem norm_ofSubsingleton_id [Subsingleton ι] [Nontrivial G] (i : ι) :
‖ofSubsingleton 𝕜 G G i (.id _ _)‖ = 1 := by
simp
theorem nnnorm_ofSubsingleton_id [Subsingleton ι] [Nontrivial G] (i : ι) :
‖ofSubsingleton 𝕜 G G i (.id _ _)‖₊ = 1 :=
NNReal.eq <| norm_ofSubsingleton_id ..
end ContinuousMultilinearMap
end Norm
section Norm
/-! Results that are only true if the source is a `NormedAddCommGroup` (and not just a
`SeminormedAddCommGroup`). -/
variable {𝕜 : Type u} {ι : Type v} {E : ι → Type wE} {G : Type wG} [Fintype ι]
[NontriviallyNormedField 𝕜] [∀ i, NormedAddCommGroup (E i)] [∀ i, NormedSpace 𝕜 (E i)]
[SeminormedAddCommGroup G] [NormedSpace 𝕜 G]
namespace MultilinearMap
/-- If a multilinear map in finitely many variables on normed spaces satisfies the inequality
`‖f m‖ ≤ C * ∏ i, ‖m i‖` on a shell `ε i / ‖c i‖ < ‖m i‖ < ε i` for some positive numbers `ε i`
and elements `c i : 𝕜`, `1 < ‖c i‖`, then it satisfies this inequality for all `m`. -/
theorem bound_of_shell (f : MultilinearMap 𝕜 E G) {ε : ι → ℝ} {C : ℝ} {c : ι → 𝕜}
(hε : ∀ i, 0 < ε i) (hc : ∀ i, 1 < ‖c i‖)
(hf : ∀ m : ∀ i, E i, (∀ i, ε i / ‖c i‖ ≤ ‖m i‖) → (∀ i, ‖m i‖ < ε i) → ‖f m‖ ≤ C * ∏ i, ‖m i‖)
(m : ∀ i, E i) : ‖f m‖ ≤ C * ∏ i, ‖m i‖ :=
bound_of_shell_of_norm_map_coord_zero f
(fun h ↦ by rw [map_coord_zero f _ (norm_eq_zero.1 h), norm_zero]) hε hc hf m
end MultilinearMap
end Norm |
.lake/packages/mathlib/Mathlib/Analysis/NormedSpace/OperatorNorm/Bilinear.lean | import Mathlib.Analysis.Normed.Operator.Bilinear
deprecated_module (since := "2025-09-03") |
.lake/packages/mathlib/Mathlib/Analysis/NormedSpace/OperatorNorm/Asymptotics.lean | import Mathlib.Analysis.Normed.Operator.Asymptotics
deprecated_module (since := "2025-09-03") |
.lake/packages/mathlib/Mathlib/Analysis/NormedSpace/OperatorNorm/Prod.lean | import Mathlib.Analysis.Normed.Operator.Prod
deprecated_module (since := "2025-09-03") |
.lake/packages/mathlib/Mathlib/Analysis/NormedSpace/OperatorNorm/NNNorm.lean | import Mathlib.Analysis.Normed.Operator.NNNorm
deprecated_module (since := "2025-09-03") |
.lake/packages/mathlib/Mathlib/Analysis/NormedSpace/OperatorNorm/Mul.lean | import Mathlib.Analysis.Normed.Operator.Mul
deprecated_module (since := "2025-09-03") |
.lake/packages/mathlib/Mathlib/Analysis/NormedSpace/OperatorNorm/Basic.lean | import Mathlib.Analysis.Normed.Operator.Basic
deprecated_module (since := "2025-09-03") |
.lake/packages/mathlib/Mathlib/Analysis/NormedSpace/OperatorNorm/Completeness.lean | import Mathlib.Analysis.Normed.Operator.Completeness
deprecated_module (since := "2025-09-03") |
.lake/packages/mathlib/Mathlib/Analysis/NormedSpace/OperatorNorm/NormedSpace.lean | import Mathlib.Analysis.Normed.Operator.NormedSpace
deprecated_module (since := "2025-09-03") |
.lake/packages/mathlib/Mathlib/Analysis/NormedSpace/PiTensorProduct/ProjectiveSeminorm.lean | import Mathlib.Analysis.NormedSpace.Multilinear.Basic
import Mathlib.LinearAlgebra.PiTensorProduct
/-!
# Projective seminorm on the tensor of a finite family of normed spaces.
Let `𝕜` be a nontrivially normed field and `E` be a family of normed `𝕜`-vector spaces `Eᵢ`,
indexed by a finite type `ι`. We define a seminorm on `⨂[𝕜] i, Eᵢ`, which we call the
"projective seminorm". For `x` an element of `⨂[𝕜] i, Eᵢ`, its projective seminorm is the
infimum over all expressions of `x` as `∑ j, ⨂ₜ[𝕜] mⱼ i` (with the `mⱼ` ∈ `Π i, Eᵢ`)
of `∑ j, Π i, ‖mⱼ i‖`.
In particular, every norm `‖.‖` on `⨂[𝕜] i, Eᵢ` satisfying `‖⨂ₜ[𝕜] i, m i‖ ≤ Π i, ‖m i‖`
for every `m` in `Π i, Eᵢ` is bounded above by the projective seminorm.
## Main definitions
* `PiTensorProduct.projectiveSeminorm`: The projective seminorm on `⨂[𝕜] i, Eᵢ`.
## Main results
* `PiTensorProduct.norm_eval_le_projectiveSeminorm`: If `f` is a continuous multilinear map on
`E = Π i, Eᵢ` and `x` is in `⨂[𝕜] i, Eᵢ`, then `‖f.lift x‖ ≤ projectiveSeminorm x * ‖f‖`.
## TODO
* If the base field is `ℝ` or `ℂ` (or more generally if the injection of `Eᵢ` into its bidual is
an isometry for every `i`), then we have `projectiveSeminorm ⨂ₜ[𝕜] i, mᵢ = Π i, ‖mᵢ‖`.
* The functoriality.
-/
universe uι u𝕜 uE uF
variable {ι : Type uι} [Fintype ι]
variable {𝕜 : Type u𝕜} [NontriviallyNormedField 𝕜]
variable {E : ι → Type uE} [∀ i, SeminormedAddCommGroup (E i)]
open scoped TensorProduct
namespace PiTensorProduct
/-- A lift of the projective seminorm to `FreeAddMonoid (𝕜 × Π i, Eᵢ)`, useful to prove the
properties of `projectiveSeminorm`.
-/
def projectiveSeminormAux : FreeAddMonoid (𝕜 × Π i, E i) → ℝ :=
fun p => (p.toList.map (fun p ↦ ‖p.1‖ * ∏ i, ‖p.2 i‖)).sum
theorem projectiveSeminormAux_nonneg (p : FreeAddMonoid (𝕜 × Π i, E i)) :
0 ≤ projectiveSeminormAux p := by
simp only [projectiveSeminormAux]
refine List.sum_nonneg ?_
intro a
simp only [List.mem_map, Prod.exists, forall_exists_index,
and_imp]
intro x m _ h
rw [← h]
exact mul_nonneg (norm_nonneg _) (Finset.prod_nonneg (fun _ _ ↦ norm_nonneg _))
theorem projectiveSeminormAux_add_le (p q : FreeAddMonoid (𝕜 × Π i, E i)) :
projectiveSeminormAux (p + q) ≤ projectiveSeminormAux p + projectiveSeminormAux q := by
simp [projectiveSeminormAux]
theorem projectiveSeminormAux_smul (p : FreeAddMonoid (𝕜 × Π i, E i)) (a : 𝕜) :
projectiveSeminormAux (p.map (fun (y : 𝕜 × Π i, E i) ↦ (a * y.1, y.2))) =
‖a‖ * projectiveSeminormAux p := by
simp [projectiveSeminormAux, Function.comp_def, mul_assoc, List.sum_map_mul_left]
variable [∀ i, NormedSpace 𝕜 (E i)]
theorem bddBelow_projectiveSemiNormAux (x : ⨂[𝕜] i, E i) :
BddBelow (Set.range (fun (p : lifts x) ↦ projectiveSeminormAux p.1)) := by
existsi 0
rw [mem_lowerBounds]
simp only [Set.mem_range, Subtype.exists, exists_prop, forall_exists_index, and_imp,
forall_apply_eq_imp_iff₂]
exact fun p _ ↦ projectiveSeminormAux_nonneg p
/-- The projective seminorm on `⨂[𝕜] i, Eᵢ`. It sends an element `x` of `⨂[𝕜] i, Eᵢ` to the
infimum over all expressions of `x` as `∑ j, ⨂ₜ[𝕜] mⱼ i` (with the `mⱼ` ∈ `Π i, Eᵢ`)
of `∑ j, Π i, ‖mⱼ i‖`.
-/
noncomputable def projectiveSeminorm : Seminorm 𝕜 (⨂[𝕜] i, E i) := by
refine Seminorm.ofSMulLE (fun x ↦ iInf (fun (p : lifts x) ↦ projectiveSeminormAux p.1)) ?_ ?_ ?_
· refine le_antisymm ?_ ?_
· refine ciInf_le_of_le (bddBelow_projectiveSemiNormAux (0 : ⨂[𝕜] i, E i)) ⟨0, lifts_zero⟩ ?_
rfl
· letI : Nonempty (lifts 0) := ⟨0, lifts_zero (R := 𝕜) (s := E)⟩
exact le_ciInf (fun p ↦ projectiveSeminormAux_nonneg p.1)
· intro x y
letI := nonempty_subtype.mpr (nonempty_lifts x); letI := nonempty_subtype.mpr (nonempty_lifts y)
exact le_ciInf_add_ciInf (fun p q ↦ ciInf_le_of_le (bddBelow_projectiveSemiNormAux _)
⟨p.1 + q.1, lifts_add p.2 q.2⟩ (projectiveSeminormAux_add_le p.1 q.1))
· intro a x
letI := nonempty_subtype.mpr (nonempty_lifts x)
rw [Real.mul_iInf_of_nonneg (norm_nonneg _)]
refine le_ciInf ?_
intro p
rw [← projectiveSeminormAux_smul]
exact ciInf_le_of_le (bddBelow_projectiveSemiNormAux _)
⟨(p.1.map (fun y ↦ (a * y.1, y.2))), lifts_smul p.2 a⟩ (le_refl _)
theorem projectiveSeminorm_apply (x : ⨂[𝕜] i, E i) :
projectiveSeminorm x = iInf (fun (p : lifts x) ↦ projectiveSeminormAux p.1) := rfl
theorem projectiveSeminorm_tprod_le (m : Π i, E i) :
projectiveSeminorm (⨂ₜ[𝕜] i, m i) ≤ ∏ i, ‖m i‖ := by
rw [projectiveSeminorm_apply]
convert ciInf_le (bddBelow_projectiveSemiNormAux _) ⟨FreeAddMonoid.of ((1 : 𝕜), m), ?_⟩
· simp [projectiveSeminormAux]
· rw [mem_lifts_iff, FreeAddMonoid.toList_of,List.map_singleton, List.sum_singleton, one_smul]
theorem norm_eval_le_projectiveSeminorm (x : ⨂[𝕜] i, E i) (G : Type*) [SeminormedAddCommGroup G]
[NormedSpace 𝕜 G] (f : ContinuousMultilinearMap 𝕜 E G) :
‖lift f.toMultilinearMap x‖ ≤ projectiveSeminorm x * ‖f‖ := by
letI := nonempty_subtype.mpr (nonempty_lifts x)
rw [projectiveSeminorm_apply, Real.iInf_mul_of_nonneg (norm_nonneg _)]
unfold projectiveSeminormAux
refine le_ciInf ?_
intro ⟨p, hp⟩
rw [mem_lifts_iff] at hp
conv_lhs => rw [← hp, ← List.sum_map_hom, ← Multiset.sum_coe]
refine le_trans (norm_multiset_sum_le _) ?_
simp only [Multiset.map_coe, List.map_map, Multiset.sum_coe]
rw [mul_comm, ← smul_eq_mul, List.smul_sum]
refine List.Forall₂.sum_le_sum ?_
simp only [smul_eq_mul, List.map_map, List.forall₂_map_right_iff, Function.comp_apply,
List.forall₂_map_left_iff, map_smul, lift.tprod, ContinuousMultilinearMap.coe_coe,
List.forall₂_same, Prod.forall]
intro a m _
rw [norm_smul, ← mul_assoc, mul_comm ‖f‖ _, mul_assoc]
exact mul_le_mul_of_nonneg_left (f.le_opNorm _) (norm_nonneg _)
end PiTensorProduct |
.lake/packages/mathlib/Mathlib/Analysis/NormedSpace/PiTensorProduct/InjectiveSeminorm.lean | import Mathlib.Analysis.NormedSpace.PiTensorProduct.ProjectiveSeminorm
import Mathlib.LinearAlgebra.Isomorphisms
/-!
# Injective seminorm on the tensor of a finite family of normed spaces.
Let `𝕜` be a nontrivially normed field and `E` be a family of normed `𝕜`-vector spaces `Eᵢ`,
indexed by a finite type `ι`. We define a seminorm on `⨂[𝕜] i, Eᵢ`, which we call the
"injective seminorm". It is chosen to satisfy the following property: for every
normed `𝕜`-vector space `F`, the linear equivalence
`MultilinearMap 𝕜 E F ≃ₗ[𝕜] (⨂[𝕜] i, Eᵢ) →ₗ[𝕜] F`
expressing the universal property of the tensor product induces an isometric linear equivalence
`ContinuousMultilinearMap 𝕜 E F ≃ₗᵢ[𝕜] (⨂[𝕜] i, Eᵢ) →L[𝕜] F`.
The idea is the following: Every normed `𝕜`-vector space `F` defines a linear map
from `⨂[𝕜] i, Eᵢ` to `ContinuousMultilinearMap 𝕜 E F →ₗ[𝕜] F`, which sends `x` to the map
`f ↦ f.lift x`. Thanks to `PiTensorProduct.norm_eval_le_projectiveSeminorm`, this map lands in
`ContinuousMultilinearMap 𝕜 E F →L[𝕜] F`. As this last space has a natural operator (semi)norm,
we get an induced seminorm on `⨂[𝕜] i, Eᵢ`, which, by
`PiTensorProduct.norm_eval_le_projectiveSeminorm`, is bounded above by the projective seminorm
`PiTensorProduct.projectiveSeminorm`. We then take the `sup` of these seminorms as `F` varies;
as this family of seminorms is bounded, its `sup` has good properties.
In fact, we cannot take the `sup` over all normed spaces `F` because of set-theoretical issues,
so we only take spaces `F` in the same universe as `⨂[𝕜] i, Eᵢ`. We prove in
`norm_eval_le_injectiveSeminorm` that this gives the same result, because every multilinear map
from `E = Πᵢ Eᵢ` to `F` factors though a normed vector space in the same universe as
`⨂[𝕜] i, Eᵢ`.
We then prove the universal property and the functoriality of `⨂[𝕜] i, Eᵢ` as a normed vector
space.
## Main definitions
* `PiTensorProduct.toDualContinuousMultilinearMap`: The `𝕜`-linear map from
`⨂[𝕜] i, Eᵢ` to `ContinuousMultilinearMap 𝕜 E F →L[𝕜] F` sending `x` to the map
`f ↦ f x`.
* `PiTensorProduct.injectiveSeminorm`: The injective seminorm on `⨂[𝕜] i, Eᵢ`.
* `PiTensorProduct.liftEquiv`: The bijection between `ContinuousMultilinearMap 𝕜 E F`
and `(⨂[𝕜] i, Eᵢ) →L[𝕜] F`, as a continuous linear equivalence.
* `PiTensorProduct.liftIsometry`: The bijection between `ContinuousMultilinearMap 𝕜 E F`
and `(⨂[𝕜] i, Eᵢ) →L[𝕜] F`, as an isometric linear equivalence.
* `PiTensorProduct.tprodL`: The canonical continuous multilinear map from `E = Πᵢ Eᵢ`
to `⨂[𝕜] i, Eᵢ`.
* `PiTensorProduct.mapL`: The continuous linear map from `⨂[𝕜] i, Eᵢ` to `⨂[𝕜] i, E'ᵢ`
induced by a family of continuous linear maps `Eᵢ →L[𝕜] E'ᵢ`.
* `PiTensorProduct.mapLMultilinear`: The continuous multilinear map from
`Πᵢ (Eᵢ →L[𝕜] E'ᵢ)` to `(⨂[𝕜] i, Eᵢ) →L[𝕜] (⨂[𝕜] i, E'ᵢ)` sending a family
`f` to `PiTensorProduct.mapL f`.
## Main results
* `PiTensorProduct.norm_eval_le_injectiveSeminorm`: The main property of the injective seminorm
on `⨂[𝕜] i, Eᵢ`: for every `x` in `⨂[𝕜] i, Eᵢ` and every continuous multilinear map `f` from
`E = Πᵢ Eᵢ` to a normed space `F`, we have `‖f.lift x‖ ≤ ‖f‖ * injectiveSeminorm x `.
* `PiTensorProduct.mapL_opNorm`: If `f` is a family of continuous linear maps
`fᵢ : Eᵢ →L[𝕜] Fᵢ`, then `‖PiTensorProduct.mapL f‖ ≤ ∏ i, ‖fᵢ‖`.
* `PiTensorProduct.mapLMultilinear_opNorm` : If `F` is a normed vecteor space, then
`‖mapLMultilinear 𝕜 E F‖ ≤ 1`.
## TODO
* If all `Eᵢ` are separated and satisfy `SeparatingDual`, then the seminorm on
`⨂[𝕜] i, Eᵢ` is a norm. This uses the construction of a basis of the `PiTensorProduct`, hence
depends on PR https://github.com/leanprover-community/mathlib4/pull/11156.
It should probably go in a separate file.
* Adapt the remaining functoriality constructions/properties from `PiTensorProduct`.
-/
universe uι u𝕜 uE uF
variable {ι : Type uι} [Fintype ι]
variable {𝕜 : Type u𝕜} [NontriviallyNormedField 𝕜]
variable {E : ι → Type uE} [∀ i, SeminormedAddCommGroup (E i)] [∀ i, NormedSpace 𝕜 (E i)]
variable {F : Type uF} [SeminormedAddCommGroup F] [NormedSpace 𝕜 F]
open scoped TensorProduct
namespace PiTensorProduct
section seminorm
variable (F) in
/-- The linear map from `⨂[𝕜] i, Eᵢ` to `ContinuousMultilinearMap 𝕜 E F →L[𝕜] F` sending
`x` in `⨂[𝕜] i, Eᵢ` to the map `f ↦ f.lift x`.
-/
@[simps!]
noncomputable def toDualContinuousMultilinearMap : (⨂[𝕜] i, E i) →ₗ[𝕜]
ContinuousMultilinearMap 𝕜 E F →L[𝕜] F where
toFun x := LinearMap.mkContinuous
((LinearMap.flip (lift (R := 𝕜) (s := E) (E := F)).toLinearMap x) ∘ₗ
ContinuousMultilinearMap.toMultilinearMapLinear)
(projectiveSeminorm x)
(fun _ ↦ by simp only [LinearMap.coe_comp, Function.comp_apply,
ContinuousMultilinearMap.toMultilinearMapLinear_apply, LinearMap.flip_apply,
LinearEquiv.coe_coe]
exact norm_eval_le_projectiveSeminorm _ _ _)
map_add' x y := by
ext _
simp only [map_add, LinearMap.mkContinuous_apply, LinearMap.coe_comp, Function.comp_apply,
ContinuousMultilinearMap.toMultilinearMapLinear_apply, LinearMap.add_apply,
LinearMap.flip_apply, LinearEquiv.coe_coe, ContinuousLinearMap.add_apply]
map_smul' a x := by
ext _
simp only [map_smul, LinearMap.mkContinuous_apply, LinearMap.coe_comp, Function.comp_apply,
ContinuousMultilinearMap.toMultilinearMapLinear_apply, LinearMap.smul_apply,
LinearMap.flip_apply, LinearEquiv.coe_coe, RingHom.id_apply, ContinuousLinearMap.coe_smul',
Pi.smul_apply]
theorem toDualContinuousMultilinearMap_le_projectiveSeminorm (x : ⨂[𝕜] i, E i) :
‖toDualContinuousMultilinearMap F x‖ ≤ projectiveSeminorm x := by
simp only [toDualContinuousMultilinearMap, LinearMap.coe_mk, AddHom.coe_mk]
apply LinearMap.mkContinuous_norm_le _ (apply_nonneg _ _)
/-- The injective seminorm on `⨂[𝕜] i, Eᵢ`. Morally, it sends `x` in `⨂[𝕜] i, Eᵢ` to the
`sup` of the operator norms of the `PiTensorProduct.toDualContinuousMultilinearMap F x`, for all
normed vector spaces `F`. In fact, we only take in the same universe as `⨂[𝕜] i, Eᵢ`, and then
prove in `PiTensorProduct.norm_eval_le_injectiveSeminorm` that this gives the same result.
-/
noncomputable irreducible_def injectiveSeminorm : Seminorm 𝕜 (⨂[𝕜] i, E i) :=
sSup {p | ∃ (G : Type (max uι u𝕜 uE)) (_ : SeminormedAddCommGroup G)
(_ : NormedSpace 𝕜 G), p = Seminorm.comp (normSeminorm 𝕜 (ContinuousMultilinearMap 𝕜 E G →L[𝕜] G))
(toDualContinuousMultilinearMap G (𝕜 := 𝕜) (E := E))}
lemma dualSeminorms_bounded : BddAbove {p | ∃ (G : Type (max uι u𝕜 uE))
(_ : SeminormedAddCommGroup G) (_ : NormedSpace 𝕜 G),
p = Seminorm.comp (normSeminorm 𝕜 (ContinuousMultilinearMap 𝕜 E G →L[𝕜] G))
(toDualContinuousMultilinearMap G (𝕜 := 𝕜) (E := E))} := by
existsi projectiveSeminorm
rw [mem_upperBounds]
simp only [Set.mem_setOf_eq, forall_exists_index]
intro p G _ _ hp
rw [hp]
intro x
simp only [Seminorm.comp_apply, coe_normSeminorm]
exact toDualContinuousMultilinearMap_le_projectiveSeminorm _
theorem injectiveSeminorm_apply (x : ⨂[𝕜] i, E i) :
injectiveSeminorm x = ⨆ p : {p | ∃ (G : Type (max uι u𝕜 uE))
(_ : SeminormedAddCommGroup G) (_ : NormedSpace 𝕜 G), p = Seminorm.comp (normSeminorm 𝕜
(ContinuousMultilinearMap 𝕜 E G →L[𝕜] G))
(toDualContinuousMultilinearMap G (𝕜 := 𝕜) (E := E))}, p.1 x := by
simpa only [injectiveSeminorm, Set.coe_setOf, Set.mem_setOf_eq]
using Seminorm.sSup_apply dualSeminorms_bounded
theorem norm_eval_le_injectiveSeminorm (f : ContinuousMultilinearMap 𝕜 E F) (x : ⨂[𝕜] i, E i) :
‖lift f.toMultilinearMap x‖ ≤ ‖f‖ * injectiveSeminorm x := by
/- If `F` were in `Type (max uι u𝕜 uE)` (which is the type of `⨂[𝕜] i, E i`), then the
property that we want to prove would hold by definition of `injectiveSeminorm`. This is
not necessarily true, but we will show that there exists a normed vector space `G` in
`Type (max uι u𝕜 uE)` and an injective isometry from `G` to `F` such that `f` factors
through a continuous multilinear map `f'` from `E = Π i, E i` to `G`, to which we can apply
the definition of `injectiveSeminorm`. The desired inequality for `f` then follows
immediately.
The idea is very simple: the multilinear map `f` corresponds by `PiTensorProduct.lift`
to a linear map from `⨂[𝕜] i, E i` to `F`, say `l`. We want to take `G` to be the image of
`l`, with the norm induced from that of `F`; to make sure that we are in the correct universe,
it is actually more convenient to take `G` equal to the coimage of `l` (i.e. the quotient
of `⨂[𝕜] i, E i` by the kernel of `l`), which is canonically isomorphic to its image by
`LinearMap.quotKerEquivRange`. -/
set G := (⨂[𝕜] i, E i) ⧸ LinearMap.ker (lift f.toMultilinearMap)
set G' := LinearMap.range (lift f.toMultilinearMap)
set e := LinearMap.quotKerEquivRange (lift f.toMultilinearMap)
letI := SeminormedAddCommGroup.induced G G' e
letI := NormedSpace.induced 𝕜 G G' e
set f'₀ := lift.symm (e.symm.toLinearMap ∘ₗ LinearMap.rangeRestrict (lift f.toMultilinearMap))
have hf'₀ : ∀ (x : Π (i : ι), E i), ‖f'₀ x‖ ≤ ‖f‖ * ∏ i, ‖x i‖ := fun x ↦ by
change ‖e (f'₀ x)‖ ≤ _
simp only [lift_symm, LinearMap.compMultilinearMap_apply, LinearMap.coe_comp,
LinearEquiv.coe_coe, Function.comp_apply, LinearEquiv.apply_symm_apply, Submodule.coe_norm,
LinearMap.codRestrict_apply, lift.tprod, ContinuousMultilinearMap.coe_coe, e, f'₀]
exact f.le_opNorm x
set f' := MultilinearMap.mkContinuous f'₀ ‖f‖ hf'₀
have hnorm : ‖f'‖ ≤ ‖f‖ := (f'.opNorm_le_iff (norm_nonneg f)).mpr hf'₀
have heq : e (lift f'.toMultilinearMap x) = lift f.toMultilinearMap x := by
induction x using PiTensorProduct.induction_on with
| smul_tprod =>
simp only [lift_symm, map_smul, lift.tprod, ContinuousMultilinearMap.coe_coe,
MultilinearMap.coe_mkContinuous, LinearMap.compMultilinearMap_apply, LinearMap.coe_comp,
LinearEquiv.coe_coe, Function.comp_apply, LinearEquiv.apply_symm_apply, SetLike.val_smul,
LinearMap.codRestrict_apply, f', f'₀]
| add _ _ hx hy => simp only [map_add, Submodule.coe_add, hx, hy]
suffices h : ‖lift f'.toMultilinearMap x‖ ≤ ‖f'‖ * injectiveSeminorm x by
change ‖(e (lift f'.toMultilinearMap x)).1‖ ≤ _ at h
rw [heq] at h
exact le_trans h (mul_le_mul_of_nonneg_right hnorm (apply_nonneg _ _))
have hle : Seminorm.comp (normSeminorm 𝕜 (ContinuousMultilinearMap 𝕜 E G →L[𝕜] G))
(toDualContinuousMultilinearMap G (𝕜 := 𝕜) (E := E)) ≤ injectiveSeminorm := by
simp only [injectiveSeminorm]
refine le_csSup dualSeminorms_bounded ?_
rw [Set.mem_setOf]
existsi G, inferInstance, inferInstance
rfl
refine le_trans ?_ (mul_le_mul_of_nonneg_left (hle x) (norm_nonneg f'))
simp only [Seminorm.comp_apply, coe_normSeminorm, ← toDualContinuousMultilinearMap_apply_apply]
rw [mul_comm]
exact ContinuousLinearMap.le_opNorm _ _
theorem injectiveSeminorm_le_projectiveSeminorm :
injectiveSeminorm (𝕜 := 𝕜) (E := E) ≤ projectiveSeminorm := by
rw [injectiveSeminorm]
refine csSup_le ?_ ?_
· existsi 0
simp only [Set.mem_setOf_eq]
existsi PUnit, inferInstance, inferInstance
ext x
simp only [Seminorm.zero_apply, Seminorm.comp_apply, coe_normSeminorm]
rw [Subsingleton.elim (toDualContinuousMultilinearMap PUnit.{(max (max uE uι) u𝕜) + 1} x) 0,
norm_zero]
· intro p hp
simp only [Set.mem_setOf_eq] at hp
obtain ⟨G, _, _, h⟩ := hp
rw [h]; intro x; simp only [Seminorm.comp_apply, coe_normSeminorm]
exact toDualContinuousMultilinearMap_le_projectiveSeminorm _
theorem injectiveSeminorm_tprod_le (m : Π (i : ι), E i) :
injectiveSeminorm (⨂ₜ[𝕜] i, m i) ≤ ∏ i, ‖m i‖ :=
le_trans (injectiveSeminorm_le_projectiveSeminorm _) (projectiveSeminorm_tprod_le m)
noncomputable instance : SeminormedAddCommGroup (⨂[𝕜] i, E i) :=
AddGroupSeminorm.toSeminormedAddCommGroup injectiveSeminorm.toAddGroupSeminorm
noncomputable instance : NormedSpace 𝕜 (⨂[𝕜] i, E i) where
norm_smul_le a x := by
change injectiveSeminorm.toFun (a • x) ≤ _
rw [injectiveSeminorm.smul']
rfl
variable (𝕜 E F)
/-- The linear equivalence between `ContinuousMultilinearMap 𝕜 E F` and `(⨂[𝕜] i, Eᵢ) →L[𝕜] F`
induced by `PiTensorProduct.lift`, for every normed space `F`.
-/
@[simps]
noncomputable def liftEquiv : ContinuousMultilinearMap 𝕜 E F ≃ₗ[𝕜] (⨂[𝕜] i, E i) →L[𝕜] F where
toFun f := LinearMap.mkContinuous (lift f.toMultilinearMap) ‖f‖ fun x ↦
norm_eval_le_injectiveSeminorm f x
map_add' f g := by ext _; simp only [ContinuousMultilinearMap.toMultilinearMap_add, map_add,
LinearMap.mkContinuous_apply, LinearMap.add_apply, ContinuousLinearMap.add_apply]
map_smul' a f := by ext _; simp only [ContinuousMultilinearMap.toMultilinearMap_smul, map_smul,
LinearMap.mkContinuous_apply, LinearMap.smul_apply, RingHom.id_apply,
ContinuousLinearMap.coe_smul', Pi.smul_apply]
invFun l := MultilinearMap.mkContinuous (lift.symm l.toLinearMap) ‖l‖ fun x ↦ by
simp only [lift_symm, LinearMap.compMultilinearMap_apply, ContinuousLinearMap.coe_coe]
exact ContinuousLinearMap.le_opNorm_of_le _ (injectiveSeminorm_tprod_le x)
left_inv f := by ext x; simp only [LinearMap.mkContinuous_coe, LinearEquiv.symm_apply_apply,
MultilinearMap.coe_mkContinuous, ContinuousMultilinearMap.coe_coe]
right_inv l := by
rw [← ContinuousLinearMap.coe_inj]
apply PiTensorProduct.ext; ext m
simp only [lift_symm, LinearMap.mkContinuous_coe, LinearMap.compMultilinearMap_apply,
lift.tprod, ContinuousMultilinearMap.coe_coe, MultilinearMap.coe_mkContinuous,
ContinuousLinearMap.coe_coe]
/-- For a normed space `F`, we have constructed in `PiTensorProduct.liftEquiv` the canonical
linear equivalence between `ContinuousMultilinearMap 𝕜 E F` and `(⨂[𝕜] i, Eᵢ) →L[𝕜] F`
(induced by `PiTensorProduct.lift`). Here we give the upgrade of this equivalence to
an isometric linear equivalence; in particular, it is a continuous linear equivalence.
-/
noncomputable def liftIsometry : ContinuousMultilinearMap 𝕜 E F ≃ₗᵢ[𝕜] (⨂[𝕜] i, E i) →L[𝕜] F :=
{ liftEquiv 𝕜 E F with
norm_map' := by
intro f
refine le_antisymm ?_ ?_
· simp only [liftEquiv_apply]
exact LinearMap.mkContinuous_norm_le _ (norm_nonneg f) _
· conv_lhs => rw [← (liftEquiv 𝕜 E F).symm_apply_apply f]
rw [liftEquiv_symm_apply]
exact MultilinearMap.mkContinuous_norm_le _ (norm_nonneg _) _ }
variable {𝕜 E F}
@[simp]
theorem liftIsometry_apply_apply (f : ContinuousMultilinearMap 𝕜 E F) (x : ⨂[𝕜] i, E i) :
liftIsometry 𝕜 E F f x = lift f.toMultilinearMap x := by
simp only [liftIsometry, LinearIsometryEquiv.coe_mk, liftEquiv_apply,
LinearMap.mkContinuous_apply]
variable (𝕜) in
/-- The canonical continuous multilinear map from `E = Πᵢ Eᵢ` to `⨂[𝕜] i, Eᵢ`.
-/
@[simps!]
noncomputable def tprodL : ContinuousMultilinearMap 𝕜 E (⨂[𝕜] i, E i) :=
(liftIsometry 𝕜 E _).symm (ContinuousLinearMap.id 𝕜 _)
@[simp]
theorem tprodL_coe : (tprodL 𝕜).toMultilinearMap = tprod 𝕜 (s := E) := by
ext m
simp only [ContinuousMultilinearMap.coe_coe, tprodL_toFun]
@[simp]
theorem liftIsometry_symm_apply (l : (⨂[𝕜] i, E i) →L[𝕜] F) :
(liftIsometry 𝕜 E F).symm l = l.compContinuousMultilinearMap (tprodL 𝕜) := by
rfl
@[simp]
theorem liftIsometry_tprodL :
liftIsometry 𝕜 E _ (tprodL 𝕜) = ContinuousLinearMap.id 𝕜 (⨂[𝕜] i, E i) := by
ext _
simp only [liftIsometry_apply_apply, tprodL_coe, lift_tprod, LinearMap.id_coe, id_eq,
ContinuousLinearMap.coe_id']
end seminorm
section map
variable {E' E'' : ι → Type*}
variable [∀ i, SeminormedAddCommGroup (E' i)] [∀ i, NormedSpace 𝕜 (E' i)]
variable [∀ i, SeminormedAddCommGroup (E'' i)] [∀ i, NormedSpace 𝕜 (E'' i)]
variable (g : Π i, E' i →L[𝕜] E'' i) (f : Π i, E i →L[𝕜] E' i)
/--
Let `Eᵢ` and `E'ᵢ` be two families of normed `𝕜`-vector spaces.
Let `f` be a family of continuous `𝕜`-linear maps between `Eᵢ` and `E'ᵢ`, i.e.
`f : Πᵢ Eᵢ →L[𝕜] E'ᵢ`, then there is an induced continuous linear map
`⨂ᵢ Eᵢ → ⨂ᵢ E'ᵢ` by `⨂ aᵢ ↦ ⨂ fᵢ aᵢ`.
-/
noncomputable def mapL : (⨂[𝕜] i, E i) →L[𝕜] ⨂[𝕜] i, E' i :=
liftIsometry 𝕜 E _ <| (tprodL 𝕜).compContinuousLinearMap f
@[simp]
theorem mapL_coe : (mapL f).toLinearMap = map (fun i ↦ (f i).toLinearMap) := by
ext
simp only [mapL, LinearMap.compMultilinearMap_apply, ContinuousLinearMap.coe_coe,
liftIsometry_apply_apply, lift.tprod, ContinuousMultilinearMap.coe_coe,
ContinuousMultilinearMap.compContinuousLinearMap_apply, tprodL_toFun, map_tprod]
@[simp]
theorem mapL_apply (x : ⨂[𝕜] i, E i) : mapL f x = map (fun i ↦ (f i).toLinearMap) x := by
rfl
/-- Given submodules `pᵢ ⊆ Eᵢ`, this is the natural map: `⨂[𝕜] i, pᵢ → ⨂[𝕜] i, Eᵢ`.
This is the continuous version of `PiTensorProduct.mapIncl`.
-/
@[simp]
noncomputable def mapLIncl (p : Π i, Submodule 𝕜 (E i)) : (⨂[𝕜] i, p i) →L[𝕜] ⨂[𝕜] i, E i :=
mapL fun (i : ι) ↦ (p i).subtypeL
theorem mapL_comp : mapL (fun (i : ι) ↦ g i ∘L f i) = mapL g ∘L mapL f := by
apply ContinuousLinearMap.coe_injective
ext
simp only [mapL_coe, ContinuousLinearMap.coe_comp, LinearMap.compMultilinearMap_apply, map_tprod,
LinearMap.coe_comp, ContinuousLinearMap.coe_coe, Function.comp_apply]
theorem liftIsometry_comp_mapL (h : ContinuousMultilinearMap 𝕜 E' F) :
liftIsometry 𝕜 E' F h ∘L mapL f = liftIsometry 𝕜 E F (h.compContinuousLinearMap f) := by
apply ContinuousLinearMap.coe_injective
ext
simp only [ContinuousLinearMap.coe_comp, mapL_coe, LinearMap.compMultilinearMap_apply,
LinearMap.coe_comp, ContinuousLinearMap.coe_coe, Function.comp_apply, map_tprod,
liftIsometry_apply_apply, lift.tprod, ContinuousMultilinearMap.coe_coe,
ContinuousMultilinearMap.compContinuousLinearMap_apply]
@[simp]
theorem mapL_id : mapL (fun i ↦ ContinuousLinearMap.id 𝕜 (E i)) = ContinuousLinearMap.id _ _ := by
apply ContinuousLinearMap.coe_injective
ext
simp only [mapL_coe, ContinuousLinearMap.coe_id, map_id, LinearMap.compMultilinearMap_apply,
LinearMap.id_coe, id_eq]
@[simp]
theorem mapL_one : mapL (fun (i : ι) ↦ (1 : E i →L[𝕜] E i)) = 1 :=
mapL_id
theorem mapL_mul (f₁ f₂ : Π i, E i →L[𝕜] E i) :
mapL (fun i ↦ f₁ i * f₂ i) = mapL f₁ * mapL f₂ :=
mapL_comp f₁ f₂
/-- Upgrading `PiTensorProduct.mapL` to a `MonoidHom` when `E = E'`. -/
@[simps]
noncomputable def mapLMonoidHom : (Π i, E i →L[𝕜] E i) →* ((⨂[𝕜] i, E i) →L[𝕜] ⨂[𝕜] i, E i) where
toFun := mapL
map_one' := mapL_one
map_mul' := mapL_mul
@[simp]
protected theorem mapL_pow (f : Π i, E i →L[𝕜] E i) (n : ℕ) :
mapL (f ^ n) = mapL f ^ n := MonoidHom.map_pow mapLMonoidHom f n
-- We redeclare `ι` here, and later dependent arguments,
-- to avoid the `[Fintype ι]` assumption present throughout the rest of the file.
open Function in
private theorem mapL_add_smul_aux {ι : Type uι}
{E : ι → Type uE} [(i : ι) → SeminormedAddCommGroup (E i)] [(i : ι) → NormedSpace 𝕜 (E i)]
{E' : ι → Type u_1} [(i : ι) → SeminormedAddCommGroup (E' i)] [(i : ι) → NormedSpace 𝕜 (E' i)]
(f : (i : ι) → E i →L[𝕜] E' i)
[DecidableEq ι] (i : ι) (u : E i →L[𝕜] E' i) :
(fun j ↦ (update f i u j).toLinearMap) =
update (fun j ↦ (f j).toLinearMap) i u.toLinearMap := by
grind
open Function in
protected theorem mapL_add [DecidableEq ι] (i : ι) (u v : E i →L[𝕜] E' i) :
mapL (update f i (u + v)) = mapL (update f i u) + mapL (update f i v) := by
ext x
simp only [mapL_apply, mapL_add_smul_aux, ContinuousLinearMap.coe_add,
PiTensorProduct.map_update_add, LinearMap.add_apply, ContinuousLinearMap.add_apply]
open Function in
protected theorem mapL_smul [DecidableEq ι] (i : ι) (c : 𝕜) (u : E i →L[𝕜] E' i) :
mapL (update f i (c • u)) = c • mapL (update f i u) := by
ext x
simp only [mapL_apply, mapL_add_smul_aux, ContinuousLinearMap.coe_smul,
PiTensorProduct.map_update_smul, LinearMap.smul_apply, ContinuousLinearMap.coe_smul',
Pi.smul_apply]
theorem mapL_opNorm : ‖mapL f‖ ≤ ∏ i, ‖f i‖ := by
rw [ContinuousLinearMap.opNorm_le_iff (by positivity)]
intro x
rw [mapL, liftIsometry]
simp only [LinearIsometryEquiv.coe_mk, liftEquiv_apply, LinearMap.mkContinuous_apply]
refine le_trans (norm_eval_le_injectiveSeminorm _ _)
(mul_le_mul_of_nonneg_right ?_ (norm_nonneg x))
rw [ContinuousMultilinearMap.opNorm_le_iff (Finset.prod_nonneg (fun _ _ ↦ norm_nonneg _))]
intro m
simp only [ContinuousMultilinearMap.compContinuousLinearMap_apply]
refine le_trans (injectiveSeminorm_tprod_le (fun i ↦ (f i) (m i))) ?_
rw [← Finset.prod_mul_distrib]
exact Finset.prod_le_prod (fun _ _ ↦ norm_nonneg _) (fun _ _ ↦ ContinuousLinearMap.le_opNorm _ _ )
variable (𝕜 E E')
/-- The tensor of a family of linear maps from `Eᵢ` to `E'ᵢ`, as a continuous multilinear map of
the family.
-/
@[simps!]
noncomputable def mapLMultilinear : ContinuousMultilinearMap 𝕜 (fun (i : ι) ↦ E i →L[𝕜] E' i)
((⨂[𝕜] i, E i) →L[𝕜] ⨂[𝕜] i, E' i) :=
MultilinearMap.mkContinuous
{ toFun := mapL
map_update_smul' := fun _ _ _ _ ↦ PiTensorProduct.mapL_smul _ _ _ _
map_update_add' := fun _ _ _ _ ↦ PiTensorProduct.mapL_add _ _ _ _ }
1 (fun f ↦ by rw [one_mul]; exact mapL_opNorm f)
variable {𝕜 E E'}
theorem mapLMultilinear_opNorm : ‖mapLMultilinear 𝕜 E E'‖ ≤ 1 :=
MultilinearMap.mkContinuous_norm_le _ zero_le_one _
end map
end PiTensorProduct |
.lake/packages/mathlib/Mathlib/Analysis/NormedSpace/Alternating/Curry.lean | import Mathlib.LinearAlgebra.Alternating.Curry
import Mathlib.Analysis.NormedSpace.Alternating.Basic
import Mathlib.Analysis.NormedSpace.Multilinear.Curry
/-!
# Currying continuous alternating forms
In this file we define `ContinuousAlternatingMap.curryLeft`
which interprets a continuous alternating map in `n + 1` variables
as a continuous linear map in the 0th variable
taking values in the continuous alternating maps in `n` variables.
-/
variable {𝕜 E F G : Type*} [NontriviallyNormedField 𝕜]
[NormedAddCommGroup E] [NormedSpace 𝕜 E]
[NormedAddCommGroup F] [NormedSpace 𝕜 F]
[NormedAddCommGroup G] [NormedSpace 𝕜 G]
{n : ℕ}
namespace ContinuousAlternatingMap
/-- Given a continuous alternating map `f` in `n+1` variables, split the first variable to obtain
a continuous linear map into continuous alternating maps in `n` variables,
given by `x ↦ (m ↦ f (Matrix.vecCons x m))`.
It can be thought of as a map $Hom(\bigwedge^{n+1} M, N) \to Hom(M, Hom(\bigwedge^n M, N))$.
This is `ContinuousMultilinearMap.curryLeft` for `AlternatingMap`. See also
`ContinuousAlternatingMap.curryLeftLI`. -/
noncomputable def curryLeft (f : E [⋀^Fin (n + 1)]→L[𝕜] F) : E →L[𝕜] E [⋀^Fin n]→L[𝕜] F :=
AlternatingMap.mkContinuousLinear f.toAlternatingMap.curryLeft ‖f‖
f.toContinuousMultilinearMap.norm_map_cons_le
@[simp]
lemma toContinuousMultilinearMap_curryLeft (f : E [⋀^Fin (n + 1)]→L[𝕜] F) (x : E) :
(f.curryLeft x).toContinuousMultilinearMap = f.toContinuousMultilinearMap.curryLeft x :=
rfl
@[simp]
lemma toAlternatingMap_curryLeft (f : E [⋀^Fin (n + 1)]→L[𝕜] F) (x : E) :
(f.curryLeft x).toAlternatingMap = f.toAlternatingMap.curryLeft x :=
rfl
@[simp]
lemma norm_curryLeft (f : E [⋀^Fin (n + 1)]→L[𝕜] F) : ‖f.curryLeft‖ = ‖f‖ :=
f.toContinuousMultilinearMap.curryLeft_norm
@[simp]
theorem curryLeft_apply_apply (f : E [⋀^Fin (n + 1)]→L[𝕜] F) (x : E) (v : Fin n → E) :
curryLeft f x v = f (Matrix.vecCons x v) :=
rfl
@[simp]
theorem curryLeft_zero : curryLeft (0 : E [⋀^Fin (n + 1)]→L[𝕜] F) = 0 :=
rfl
@[simp]
theorem curryLeft_add (f g : E [⋀^Fin (n + 1)]→L[𝕜] F) :
curryLeft (f + g) = curryLeft f + curryLeft g :=
rfl
@[simp]
theorem curryLeft_smul (r : 𝕜) (f : E [⋀^Fin (n + 1)]→L[𝕜] F) :
curryLeft (r • f) = r • curryLeft f :=
rfl
/-- `ContinuousAlternatingMap.curryLeft` as a `LinearIsometry`. -/
@[simps]
noncomputable def curryLeftLI :
(E [⋀^Fin (n + 1)]→L[𝕜] F) →ₗᵢ[𝕜] (E →L[𝕜] E [⋀^Fin n]→L[𝕜] F) where
toFun f := f.curryLeft
map_add' := curryLeft_add
map_smul' := curryLeft_smul
norm_map' := norm_curryLeft
/-- Currying with the same element twice gives the zero map. -/
@[simp]
theorem curryLeft_same (f : E [⋀^Fin (n + 2)]→L[𝕜] F) (x : E) :
(f.curryLeft x).curryLeft x = 0 :=
ext fun _ ↦ f.map_eq_zero_of_eq _ (by simp) Fin.zero_ne_one
@[simp]
theorem curryLeft_compContinuousAlternatingMap (g : F →L[𝕜] G) (f : E [⋀^Fin (n + 1)]→L[𝕜] F)
(x : E) :
(g.compContinuousAlternatingMap f).curryLeft x =
g.compContinuousAlternatingMap (f.curryLeft x) :=
rfl
@[simp]
theorem curryLeft_compContinuousLinearMap (g : F [⋀^Fin (n + 1)]→L[𝕜] G) (f : E →L[𝕜] F) (x : E) :
(g.compContinuousLinearMap f).curryLeft x = (g.curryLeft (f x)).compContinuousLinearMap f :=
ext fun v ↦ congr_arg g <| funext fun i ↦ by cases i using Fin.cases <;> simp
end ContinuousAlternatingMap |
.lake/packages/mathlib/Mathlib/Analysis/NormedSpace/Alternating/Basic.lean | import Mathlib.Topology.Algebra.Module.Alternating.Topology
import Mathlib.Analysis.NormedSpace.Multilinear.Basic
/-!
# Operator norm on the space of continuous alternating maps
In this file we show that continuous alternating maps
from a seminormed space to a (semi)normed space form a (semi)normed space.
We also prove basic facts about this norm
and define bundled versions of some operations on continuous alternating maps.
Most proofs just invoke the corresponding fact about continuous multilinear maps.
-/
noncomputable section
open scoped BigOperators NNReal
open Finset Metric
/-!
### Type variables
We use the following type variables in this file:
* `𝕜` : a nontrivially normed field;
* `ι`: a finite index type;
* `E`, `F`, `G`: (semi)normed vector spaces over `𝕜`.
-/
/-- Applying a continuous alternating map to a vector is continuous
in the pair (map, vector).
Continuity in the vector holds by definition
and continuity in the map holds if both the domain and the codomain are topological vector spaces.
However, continuity in the pair (map, vector) needs the domain to be a locally bounded TVS.
We have no typeclass for a locally bounded TVS,
so we require it to be a seminormed space instead. -/
instance ContinuousAlternatingMap.instContinuousEval {𝕜 ι E F : Type*}
[NormedField 𝕜] [Finite ι] [SeminormedAddCommGroup E] [NormedSpace 𝕜 E]
[TopologicalSpace F] [AddCommGroup F] [IsTopologicalAddGroup F] [Module 𝕜 F] :
ContinuousEval (E [⋀^ι]→L[𝕜] F) (ι → E) F :=
.of_continuous_forget continuous_toContinuousMultilinearMap
section Seminorm
universe u wE wF wG v
variable {𝕜 : Type u} {n : ℕ} {E : Type wE} {F : Type wF} {G : Type wG} {ι : Type v}
[NontriviallyNormedField 𝕜]
[SeminormedAddCommGroup E] [NormedSpace 𝕜 E]
[SeminormedAddCommGroup F] [NormedSpace 𝕜 F]
[SeminormedAddCommGroup G] [NormedSpace 𝕜 G]
/-!
### Continuity properties of alternating maps
We relate continuity of alternating maps to the inequality `‖f m‖ ≤ C * ∏ i, ‖m i‖`, in
both directions. Along the way, we prove useful bounds on the difference `‖f m₁ - f m₂‖`.
-/
namespace AlternatingMap
/-- If `f` is a continuous alternating map on `E`
and `m` is an element of `ι → E` such that one of the `m i` has norm `0`, then `f m` has norm `0`.
Note that we cannot drop the continuity assumption.
Indeed, let `ℝ₀` be a copy or `ℝ` with zero norm and indiscrete topology.
Then `f : (Unit → ℝ₀) → ℝ` given by `f x = x ()`
sends vector `1` with zero norm to number `1` with nonzero norm. -/
theorem norm_map_coord_zero (f : E [⋀^ι]→ₗ[𝕜] F) (hf : Continuous f)
{m : ι → E} {i : ι} (hi : ‖m i‖ = 0) : ‖f m‖ = 0 :=
f.1.norm_map_coord_zero hf hi
variable [Fintype ι]
/-- If an alternating map in finitely many variables on seminormed spaces
sends vectors with a component of norm zero to vectors of norm zero
and satisfies the inequality `‖f m‖ ≤ C * ∏ i, ‖m i‖` on a shell `ε i / ‖c i‖ < ‖m i‖ < ε i`
for some positive numbers `ε i` and elements `c i : 𝕜`, `1 < ‖c i‖`,
then it satisfies this inequality for all `m`.
The first assumption is automatically satisfied on normed spaces, see `bound_of_shell` below.
For seminormed spaces, it follows from continuity of `f`,
see lemma `bound_of_shell_of_continuous` below. -/
theorem bound_of_shell_of_norm_map_coord_zero (f : E [⋀^ι]→ₗ[𝕜] F)
(hf₀ : ∀ {m i}, ‖m i‖ = 0 → ‖f m‖ = 0)
{ε : ι → ℝ} {C : ℝ} (hε : ∀ i, 0 < ε i) {c : ι → 𝕜} (hc : ∀ i, 1 < ‖c i‖)
(hf : ∀ m : ι → E, (∀ i, ε i / ‖c i‖ ≤ ‖m i‖) → (∀ i, ‖m i‖ < ε i) → ‖f m‖ ≤ C * ∏ i, ‖m i‖)
(m : ι → E) : ‖f m‖ ≤ C * ∏ i, ‖m i‖ :=
f.1.bound_of_shell_of_norm_map_coord_zero hf₀ hε hc hf m
/-- If a continuous alternating map in finitely many variables on normed spaces
satisfies the inequality `‖f m‖ ≤ C * ∏ i, ‖m i‖`
on a shell `ε / ‖c‖ < ‖m i‖ < ε` for some positive number `ε` and an elements `c : 𝕜`, `1 < ‖c‖`,
then it satisfies this inequality for all `m`.
If the domain is a Hausdorff space, then the continuity assumption is redundant,
see `bound_of_shell` below. -/
theorem bound_of_shell_of_continuous (f : E [⋀^ι]→ₗ[𝕜] F) (hfc : Continuous f)
{ε : ℝ} {C : ℝ} (hε : 0 < ε) {c : 𝕜} (hc : 1 < ‖c‖)
(hf : ∀ m : ι → E, (∀ i, ε / ‖c‖ ≤ ‖m i‖) → (∀ i, ‖m i‖ < ε) → ‖f m‖ ≤ C * ∏ i, ‖m i‖)
(m : ι → E) : ‖f m‖ ≤ C * ∏ i, ‖m i‖ :=
f.1.bound_of_shell_of_continuous hfc (fun _ ↦ hε) (fun _ ↦ hc) hf m
/-- If an alternating map in finitely many variables on a seminormed space is continuous,
then it satisfies the inequality `‖f m‖ ≤ C * ∏ i, ‖m i‖`,
for some `C` which can be chosen to be positive. -/
theorem exists_bound_of_continuous (f : E [⋀^ι]→ₗ[𝕜] F) (hf : Continuous f) :
∃ (C : ℝ), 0 < C ∧ (∀ m, ‖f m‖ ≤ C * ∏ i, ‖m i‖) :=
f.1.exists_bound_of_continuous hf
/-- If an alternating map `f` satisfies a boundedness property around `0`,
one can deduce a bound on `f m₁ - f m₂` using the multilinearity.
Here, we give a precise but hard to use version.
See `AlternatingMap.norm_image_sub_le_of_bound` for a less precise but more usable version.
The bound reads
`‖f m - f m'‖ ≤
C * ‖m 1 - m' 1‖ * max ‖m 2‖ ‖m' 2‖ * max ‖m 3‖ ‖m' 3‖ * ... * max ‖m n‖ ‖m' n‖ + ...`,
where the other terms in the sum are the same products where `1` is replaced by any `i`. -/
theorem norm_image_sub_le_of_bound' [DecidableEq ι] (f : E [⋀^ι]→ₗ[𝕜] F) {C : ℝ} (hC : 0 ≤ C)
(H : ∀ m, ‖f m‖ ≤ C * ∏ i, ‖m i‖) (m₁ m₂ : ι → E) :
‖f m₁ - f m₂‖ ≤ C * ∑ i, ∏ j, if j = i then ‖m₁ i - m₂ i‖ else max ‖m₁ j‖ ‖m₂ j‖ :=
f.toMultilinearMap.norm_image_sub_le_of_bound' hC H m₁ m₂
/-- If an alternating map `f` satisfies a boundedness property around `0`,
one can deduce a bound on `f m₁ - f m₂` using the multilinearity.
Here, we give a usable but not very precise version.
See `AlternatingMap.norm_image_sub_le_of_bound'` for a more precise but less usable version.
The bound is `‖f m - f m'‖ ≤ C * card ι * ‖m - m'‖ * (max ‖m‖ ‖m'‖) ^ (card ι - 1)`. -/
theorem norm_image_sub_le_of_bound (f : E [⋀^ι]→ₗ[𝕜] F) {C : ℝ} (hC : 0 ≤ C)
(H : ∀ m, ‖f m‖ ≤ C * ∏ i, ‖m i‖) (m₁ m₂ : ι → E) :
‖f m₁ - f m₂‖ ≤ C * (Fintype.card ι) * (max ‖m₁‖ ‖m₂‖) ^ (Fintype.card ι - 1) * ‖m₁ - m₂‖ :=
f.toMultilinearMap.norm_image_sub_le_of_bound hC H m₁ m₂
/-- If an alternating map satisfies an inequality `‖f m‖ ≤ C * ∏ i, ‖m i‖`,
then it is continuous. -/
theorem continuous_of_bound (f : E [⋀^ι]→ₗ[𝕜] F) (C : ℝ) (H : ∀ m, ‖f m‖ ≤ C * ∏ i, ‖m i‖) :
Continuous f :=
f.toMultilinearMap.continuous_of_bound C H
/-- Construct a continuous alternating map
from a alternating map satisfying a boundedness condition. -/
def mkContinuous (f : E [⋀^ι]→ₗ[𝕜] F) (C : ℝ) (H : ∀ m, ‖f m‖ ≤ C * ∏ i, ‖m i‖) : E [⋀^ι]→L[𝕜] F :=
{ f with cont := f.continuous_of_bound C H }
@[simp] theorem coe_mkContinuous (f : E [⋀^ι]→ₗ[𝕜] F) (C : ℝ) (H : ∀ m, ‖f m‖ ≤ C * ∏ i, ‖m i‖) :
(f.mkContinuous C H : (ι → E) → F) = f :=
rfl
end AlternatingMap
/-!
### Continuous alternating maps
We define the norm `‖f‖` of a continuous alternating map `f` in finitely many variables
as the smallest nonnegative number such that `‖f m‖ ≤ ‖f‖ * ∏ i, ‖m i‖` for all `m`.
We show that this defines a normed space structure on `E [⋀^ι]→L[𝕜] F`.
-/
namespace ContinuousAlternatingMap
variable [Fintype ι] {f : E [⋀^ι]→L[𝕜] F} {m : ι → E}
theorem bound (f : E [⋀^ι]→L[𝕜] F) : ∃ (C : ℝ), 0 < C ∧ (∀ m, ‖f m‖ ≤ C * ∏ i, ‖m i‖) :=
f.toContinuousMultilinearMap.bound
/-- Continuous alternating maps form a seminormed additive commutative group.
We override projection to `PseudoMetricSpace` to ensure that instances commute
in `with_reducible_and_instances`. -/
instance instSeminormedAddCommGroup : SeminormedAddCommGroup (E [⋀^ι]→L[𝕜] F) where
toPseudoMetricSpace := .induced toContinuousMultilinearMap inferInstance
__ := SeminormedAddCommGroup.induced _ _ (toMultilinearAddHom : E [⋀^ι]→L[𝕜] F →+ _)
norm f := ‖f.toContinuousMultilinearMap‖
@[simp] theorem norm_toContinuousMultilinearMap (f : E [⋀^ι]→L[𝕜] F) : ‖f.1‖ = ‖f‖ := rfl
@[simp] theorem nnnorm_toContinuousMultilinearMap (f : E [⋀^ι]→L[𝕜] F) : ‖f.1‖₊ = ‖f‖₊ := rfl
@[simp] theorem enorm_toContinuousMultilinearMap (f : E [⋀^ι]→L[𝕜] F) : ‖f.1‖ₑ = ‖f‖ₑ := rfl
/-- The inclusion of `E [⋀^ι]→L[𝕜] F` into `ContinuousMultilinearMap 𝕜 (fun _ : ι ↦ E) F`
as a linear isometry. -/
@[simps!]
def toContinuousMultilinearMapLI :
E [⋀^ι]→L[𝕜] F →ₗᵢ[𝕜] ContinuousMultilinearMap 𝕜 (fun _ : ι ↦ E) F where
toLinearMap := toContinuousMultilinearMapLinear
norm_map' _ := rfl
theorem norm_def (f : E [⋀^ι]→L[𝕜] F) :
‖f‖ = sInf {c : ℝ | 0 ≤ c ∧ ∀ m, ‖f m‖ ≤ c * ∏ i, ‖m i‖} :=
rfl
theorem bounds_nonempty :
∃ c, c ∈ {c | 0 ≤ c ∧ ∀ m, ‖f m‖ ≤ c * ∏ i, ‖m i‖} :=
ContinuousMultilinearMap.bounds_nonempty
theorem bounds_bddBelow {f : E [⋀^ι]→L[𝕜] F} :
BddBelow {c | 0 ≤ c ∧ ∀ m, ‖f m‖ ≤ c * ∏ i, ‖m i‖} :=
ContinuousMultilinearMap.bounds_bddBelow
theorem isLeast_opNorm (f : E [⋀^ι]→L[𝕜] F) :
IsLeast {c : ℝ | 0 ≤ c ∧ ∀ m, ‖f m‖ ≤ c * ∏ i, ‖m i‖} ‖f‖ :=
f.1.isLeast_opNorm
/-- The fundamental property of the operator norm of a continuous alternating map:
`‖f m‖` is bounded by `‖f‖` times the product of the `‖m i‖`. -/
theorem le_opNorm (f : E [⋀^ι]→L[𝕜] F) (m : ι → E) : ‖f m‖ ≤ ‖f‖ * ∏ i, ‖m i‖ := f.1.le_opNorm m
theorem le_mul_prod_of_opNorm_le_of_le
{m : ι → E} {C : ℝ} {b : ι → ℝ} (hC : ‖f‖ ≤ C) (hm : ∀ i, ‖m i‖ ≤ b i) :
‖f m‖ ≤ C * ∏ i, b i :=
f.1.le_mul_prod_of_opNorm_le_of_le hC hm
theorem le_opNorm_mul_prod_of_le (f : E [⋀^ι]→L[𝕜] F) {b : ι → ℝ} (hm : ∀ i, ‖m i‖ ≤ b i) :
‖f m‖ ≤ ‖f‖ * ∏ i, b i :=
f.1.le_opNorm_mul_prod_of_le hm
theorem le_opNorm_mul_pow_card_of_le (f : E [⋀^ι]→L[𝕜] F) {m b} (hm : ‖m‖ ≤ b) :
‖f m‖ ≤ ‖f‖ * b ^ Fintype.card ι :=
f.1.le_opNorm_mul_pow_card_of_le hm
theorem le_opNorm_mul_pow_of_le {n} (f : E [⋀^Fin n]→L[𝕜] F) {m b} (hm : ‖m‖ ≤ b) :
‖f m‖ ≤ ‖f‖ * b ^ n :=
f.1.le_opNorm_mul_pow_of_le hm
theorem le_of_opNorm_le {C : ℝ} (h : ‖f‖ ≤ C) (m : ι → E) : ‖f m‖ ≤ C * ∏ i, ‖m i‖ :=
f.1.le_of_opNorm_le h m
theorem ratio_le_opNorm (f : E [⋀^ι]→L[𝕜] F) (m : ι → E) : ‖f m‖ / ∏ i, ‖m i‖ ≤ ‖f‖ :=
f.1.ratio_le_opNorm m
/-- The image of the unit ball under a continuous alternating map is bounded. -/
theorem unit_le_opNorm (f : E [⋀^ι]→L[𝕜] F) (h : ‖m‖ ≤ 1) : ‖f m‖ ≤ ‖f‖ := f.1.unit_le_opNorm h
/-- If one controls the norm of every `f x`, then one controls the norm of `f`. -/
theorem opNorm_le_bound (f : E [⋀^ι]→L[𝕜] F) {M : ℝ} (hMp : 0 ≤ M)
(hM : ∀ m, ‖f m‖ ≤ M * ∏ i, ‖m i‖) : ‖f‖ ≤ M :=
f.1.opNorm_le_bound hMp hM
theorem opNorm_le_iff {C : ℝ} (hC : 0 ≤ C) : ‖f‖ ≤ C ↔ ∀ m, ‖f m‖ ≤ C * ∏ i, ‖m i‖ :=
f.1.opNorm_le_iff hC
/-- The fundamental property of the operator norm of a continuous alternating map:
`‖f m‖` is bounded by `‖f‖` times the product of the `‖m i‖`, `nnnorm` version. -/
theorem le_opNNNorm (f : E [⋀^ι]→L[𝕜] F) (m : ι → E) : ‖f m‖₊ ≤ ‖f‖₊ * ∏ i, ‖m i‖₊ :=
f.1.le_opNNNorm m
theorem le_of_opNNNorm_le {C : ℝ≥0} (h : ‖f‖₊ ≤ C) (m : ι → E) : ‖f m‖₊ ≤ C * ∏ i, ‖m i‖₊ :=
f.1.le_of_opNNNorm_le h m
theorem opNNNorm_le_iff {C : ℝ≥0} : ‖f‖₊ ≤ C ↔ ∀ m, ‖f m‖₊ ≤ C * ∏ i, ‖m i‖₊ :=
f.1.opNNNorm_le_iff
theorem isLeast_opNNNorm (f : E [⋀^ι]→L[𝕜] F) :
IsLeast {C : ℝ≥0 | ∀ m, ‖f m‖₊ ≤ C * ∏ i, ‖m i‖₊} ‖f‖₊ :=
f.1.isLeast_opNNNorm
theorem opNNNorm_prod (f : E [⋀^ι]→L[𝕜] F) (g : E [⋀^ι]→L[𝕜] G) :
‖f.prod g‖₊ = max (‖f‖₊) (‖g‖₊) :=
f.1.opNNNorm_prod g.1
theorem opNorm_prod (f : E [⋀^ι]→L[𝕜] F) (g : E [⋀^ι]→L[𝕜] G) : ‖f.prod g‖ = max (‖f‖) (‖g‖) :=
f.1.opNorm_prod g.1
theorem opNNNorm_pi {ι' : Type*} [Fintype ι'] {F : ι' → Type*} [∀ i', SeminormedAddCommGroup (F i')]
[∀ i', NormedSpace 𝕜 (F i')] (f : ∀ i', E [⋀^ι]→L[𝕜] F i') : ‖pi f‖₊ = ‖f‖₊ :=
ContinuousMultilinearMap.opNNNorm_pi fun i ↦ (f i).1
theorem opNorm_pi {ι' : Type*} [Fintype ι'] {F : ι' → Type*} [∀ i', SeminormedAddCommGroup (F i')]
[∀ i', NormedSpace 𝕜 (F i')] (f : ∀ i', E [⋀^ι]→L[𝕜] F i') : ‖pi f‖ = ‖f‖ :=
ContinuousMultilinearMap.opNorm_pi fun i ↦ (f i).1
instance instNormedSpace {𝕜' : Type*} [NormedField 𝕜'] [NormedSpace 𝕜' F] [SMulCommClass 𝕜 𝕜' F] :
NormedSpace 𝕜' (E [⋀^ι]→L[𝕜] F) :=
⟨fun c f ↦ f.1.opNorm_smul_le c⟩
section
@[simp] theorem norm_ofSubsingleton [Subsingleton ι] (i : ι) (f : E →L[𝕜] F) :
‖ofSubsingleton 𝕜 E F i f‖ = ‖f‖ :=
ContinuousMultilinearMap.norm_ofSubsingleton i f
@[simp] theorem nnnorm_ofSubsingleton [Subsingleton ι] (i : ι) (f : E →L[𝕜] F) :
‖ofSubsingleton 𝕜 E F i f‖₊ = ‖f‖₊ :=
NNReal.eq <| norm_ofSubsingleton i f
/-- `ContinuousAlternatingMap.ofSubsingleton` as a linear isometry. -/
@[simps +simpRhs]
def ofSubsingletonLIE [Subsingleton ι] (i : ι) : (E →L[𝕜] F) ≃ₗᵢ[𝕜] (E [⋀^ι]→L[𝕜] F) where
__ := ofSubsingleton 𝕜 E F i
map_add' _ _ := rfl
map_smul' _ _ := rfl
norm_map' := norm_ofSubsingleton i
theorem norm_ofSubsingleton_id_le [Subsingleton ι] (i : ι) :
‖ofSubsingleton 𝕜 E E i (.id _ _)‖ ≤ 1 :=
ContinuousMultilinearMap.norm_ofSubsingleton_id_le ..
theorem nnnorm_ofSubsingleton_id_le [Subsingleton ι] (i : ι) :
‖ofSubsingleton 𝕜 E E i (.id _ _)‖₊ ≤ 1 :=
ContinuousMultilinearMap.nnnorm_ofSubsingleton_id_le ..
variable (𝕜 E)
@[simp] theorem norm_constOfIsEmpty [IsEmpty ι] (x : F) : ‖constOfIsEmpty 𝕜 E ι x‖ = ‖x‖ :=
ContinuousMultilinearMap.norm_constOfIsEmpty _ _ _
@[simp] theorem nnnorm_constOfIsEmpty [IsEmpty ι] (x : F) : ‖constOfIsEmpty 𝕜 E ι x‖₊ = ‖x‖₊ :=
NNReal.eq <| norm_constOfIsEmpty _ _ _
variable (ι F) in
/-- `constOfIsEmpty` as a linear isometry equivalence. -/
@[simps]
def constOfIsEmptyLIE [IsEmpty ι] : F ≃ₗᵢ[𝕜] (E [⋀^ι]→L[𝕜] F) where
toFun := constOfIsEmpty _ _ _
invFun f := f 0
left_inv x := by simp
right_inv f := by ext x; simp [Subsingleton.allEq x 0]
map_add' f g := rfl
map_smul' c f := rfl
norm_map' := norm_constOfIsEmpty _ _
end
variable (𝕜 E F G) in
/-- `ContinuousAlternatingMap.prod` as a `LinearIsometryEquiv`. -/
@[simps]
def prodLIE : (E [⋀^ι]→L[𝕜] F) × (E [⋀^ι]→L[𝕜] G) ≃ₗᵢ[𝕜] (E [⋀^ι]→L[𝕜] (F × G)) where
toFun f := f.1.prod f.2
invFun f := ((ContinuousLinearMap.fst 𝕜 F G).compContinuousAlternatingMap f,
(ContinuousLinearMap.snd 𝕜 F G).compContinuousAlternatingMap f)
map_add' _ _ := rfl
map_smul' _ _ := rfl
norm_map' f := opNorm_prod f.1 f.2
variable (𝕜 E) in
/-- `ContinuousAlternatingMap.pi` as a `LinearIsometryEquiv`. -/
@[simps!]
def piLIE {ι' : Type*} [Fintype ι'] {F : ι' → Type*} [∀ i', SeminormedAddCommGroup (F i')]
[∀ i', NormedSpace 𝕜 (F i')] :
(∀ i', E [⋀^ι]→L[𝕜] F i') ≃ₗᵢ[𝕜] (E [⋀^ι]→L[𝕜] (∀ i, F i)) where
toLinearEquiv := piLinearEquiv
norm_map' := opNorm_pi
section restrictScalars
variable {𝕜' : Type*} [NontriviallyNormedField 𝕜'] [NormedAlgebra 𝕜' 𝕜]
variable [NormedSpace 𝕜' F] [IsScalarTower 𝕜' 𝕜 F]
variable [NormedSpace 𝕜' E] [IsScalarTower 𝕜' 𝕜 E]
@[simp] theorem norm_restrictScalars : ‖f.restrictScalars 𝕜'‖ = ‖f‖ := rfl
variable (𝕜')
/-- `ContinuousAlternatingMap.restrictScalars` as a `LinearIsometry`. -/
@[simps]
def restrictScalarsLI : E [⋀^ι]→L[𝕜] F →ₗᵢ[𝕜'] E [⋀^ι]→L[𝕜'] F where
toFun := restrictScalars 𝕜'
map_add' _ _ := rfl
map_smul' _ _ := rfl
norm_map' _ := rfl
variable {𝕜'}
end restrictScalars
/-- The difference `f m₁ - f m₂` is controlled in terms of `‖f‖` and `‖m₁ - m₂‖`, precise version.
For a less precise but more usable version, see `norm_image_sub_le`. The bound reads
`‖f m - f m'‖ ≤
‖f‖ * ‖m 1 - m' 1‖ * max ‖m 2‖ ‖m' 2‖ * max ‖m 3‖ ‖m' 3‖ * ... * max ‖m n‖ ‖m' n‖ + ...`,
where the other terms in the sum are the same products where `1` is replaced by any `i`. -/
theorem norm_image_sub_le' [DecidableEq ι] (f : E [⋀^ι]→L[𝕜] F) (m₁ m₂ : ι → E) :
‖f m₁ - f m₂‖ ≤ ‖f‖ * ∑ i, ∏ j, if j = i then ‖m₁ i - m₂ i‖ else max ‖m₁ j‖ ‖m₂ j‖ :=
f.1.norm_image_sub_le' m₁ m₂
/-- The difference `f m₁ - f m₂` is controlled in terms of `‖f‖` and `‖m₁ - m₂‖`,
less precise version.
For a more precise but less usable version, see `norm_image_sub_le'`.
The bound is `‖f m - f m'‖ ≤ ‖f‖ * card ι * ‖m - m'‖ * (max ‖m‖ ‖m'‖) ^ (card ι - 1)`. -/
theorem norm_image_sub_le (f : E [⋀^ι]→L[𝕜] F) (m₁ m₂ : ι → E) :
‖f m₁ - f m₂‖ ≤ ‖f‖ * (Fintype.card ι) * (max ‖m₁‖ ‖m₂‖) ^ (Fintype.card ι - 1) * ‖m₁ - m₂‖ :=
f.1.norm_image_sub_le m₁ m₂
end ContinuousAlternatingMap
variable [Fintype ι]
/-- If a continuous alternating map is constructed from a alternating map via the constructor
`mkContinuous`, then its norm is bounded by the bound given to the constructor if it is
nonnegative. -/
theorem AlternatingMap.mkContinuous_norm_le (f : E [⋀^ι]→ₗ[𝕜] F) {C : ℝ} (hC : 0 ≤ C)
(H : ∀ m, ‖f m‖ ≤ C * ∏ i, ‖m i‖) : ‖f.mkContinuous C H‖ ≤ C :=
f.toMultilinearMap.mkContinuous_norm_le hC H
/-- If a continuous alternating map is constructed from a alternating map via the constructor
`mk_continuous`, then its norm is bounded by the bound given to the constructor if it is
nonnegative. -/
theorem AlternatingMap.mkContinuous_norm_le' (f : E [⋀^ι]→ₗ[𝕜] F) {C : ℝ}
(H : ∀ m, ‖f m‖ ≤ C * ∏ i, ‖m i‖) : ‖f.mkContinuous C H‖ ≤ max C 0 :=
ContinuousMultilinearMap.opNorm_le_bound (le_max_right _ _) fun m ↦ (H m).trans <| by
gcongr
apply le_max_left
namespace ContinuousLinearMap
theorem norm_compContinuousAlternatingMap_le (g : F →L[𝕜] G) (f : E [⋀^ι]→L[𝕜] F) :
‖g.compContinuousAlternatingMap f‖ ≤ ‖g‖ * ‖f‖ :=
g.norm_compContinuousMultilinearMap_le f.1
variable (𝕜 E F G) in
/-- `ContinuousLinearMap.compContinuousAlternatingMap` as a bundled continuous bilinear map. -/
@[simps! apply_apply]
def compContinuousAlternatingMapCLM : (F →L[𝕜] G) →L[𝕜] (E [⋀^ι]→L[𝕜] F) →L[𝕜] (E [⋀^ι]→L[𝕜] G) :=
LinearMap.mkContinuous₂ (compContinuousAlternatingMapₗ 𝕜 E F G) 1 fun f g ↦ by
simpa using f.norm_compContinuousAlternatingMap_le g
/-- `ContinuousLinearMap.compContinuousAlternatingMap` as a bundled continuous linear equiv. -/
@[simps +simpRhs apply]
def _root_.ContinuousLinearEquiv.continuousAlternatingMapCongrRight (g : F ≃L[𝕜] G) :
(E [⋀^ι]→L[𝕜] F) ≃L[𝕜] (E [⋀^ι]→L[𝕜] G) where
__ := g.continuousAlternatingMapCongrRightEquiv
__ := compContinuousAlternatingMapCLM 𝕜 E F G g.toContinuousLinearMap
continuous_toFun :=
(compContinuousAlternatingMapCLM 𝕜 E F G g.toContinuousLinearMap).continuous
continuous_invFun :=
(compContinuousAlternatingMapCLM 𝕜 E G F g.symm.toContinuousLinearMap).continuous
@[simp]
theorem _root_.ContinuousLinearEquiv.continuousAlternatingMapCongrRight_symm (g : F ≃L[𝕜] G) :
(g.continuousAlternatingMapCongrRight (ι := ι) (E := E)).symm =
g.symm.continuousAlternatingMapCongrRight :=
rfl
/-- Flip arguments in `f : F →L[𝕜] E [⋀^ι]→L[𝕜] G` to get `⋀^ι⟮𝕜; E; F →L[𝕜] G⟯` -/
@[simps! apply_apply]
def flipAlternating (f : F →L[𝕜] (E [⋀^ι]→L[𝕜] G)) : E [⋀^ι]→L[𝕜] (F →L[𝕜] G) where
toContinuousMultilinearMap :=
((ContinuousAlternatingMap.toContinuousMultilinearMapCLM 𝕜).comp f).flipMultilinear
map_eq_zero_of_eq' v i j hv hne := by ext x; simp [(f x).map_eq_zero_of_eq v hv hne]
end ContinuousLinearMap
theorem LinearIsometry.norm_compContinuousAlternatingMap (g : F →ₗᵢ[𝕜] G) (f : E [⋀^ι]→L[𝕜] F) :
‖g.toContinuousLinearMap.compContinuousAlternatingMap f‖ = ‖f‖ :=
g.norm_compContinuousMultilinearMap f.1
open ContinuousAlternatingMap
section
theorem ContinuousAlternatingMap.norm_compContinuousLinearMap_le (f : F [⋀^ι]→L[𝕜] G)
(g : E →L[𝕜] F) : ‖f.compContinuousLinearMap g‖ ≤ ‖f‖ * (‖g‖ ^ Fintype.card ι) :=
(f.1.norm_compContinuousLinearMap_le _).trans_eq <| by simp
/-- Composition of a continuous alternating map and a continuous linear map
as a bundled continuous linear map. -/
def ContinuousAlternatingMap.compContinuousLinearMapCLM (f : E →L[𝕜] F) :
(F [⋀^ι]→L[𝕜] G) →L[𝕜] (E [⋀^ι]→L[𝕜] G) :=
LinearMap.mkContinuous
(ContinuousAlternatingMap.compContinuousLinearMapₗ f) (‖f‖ ^ Fintype.card ι) fun g ↦
(g.norm_compContinuousLinearMap_le f).trans_eq (mul_comm _ _)
/-- Given a continuous linear isomorphism between the domains,
generate a continuous linear isomorphism between the spaces of continuous alternating maps.
This is `ContinuousAlternatingMap.compContinuousLinearMap` as an equivalence,
and is the continuous version of `AlternatingMap.domLCongr`. -/
@[simps apply]
def ContinuousLinearEquiv.continuousAlternatingMapCongrLeft (f : E ≃L[𝕜] F) :
E [⋀^ι]→L[𝕜] G ≃L[𝕜] (F [⋀^ι]→L[𝕜] G) where
__ := f.continuousAlternatingMapCongrLeftEquiv
__ := ContinuousAlternatingMap.compContinuousLinearMapCLM (f.symm : F →L[𝕜] E)
toFun g := g.compContinuousLinearMap (f.symm : F →L[𝕜] E)
continuous_invFun :=
(ContinuousAlternatingMap.compContinuousLinearMapCLM (f : E →L[𝕜] F)).cont
continuous_toFun :=
(ContinuousAlternatingMap.compContinuousLinearMapCLM (f.symm : F →L[𝕜] E)).cont
variable
{E' : Type*} [NormedAddCommGroup E'] [NormedSpace 𝕜 E']
{F' : Type*} [NormedAddCommGroup F'] [NormedSpace 𝕜 F']
/-- Continuous linear equivalences between the domains and the codomains
generate a continuous linear equivalence between the spaces of continuous alternating maps. -/
@[simps! apply]
def ContinuousLinearEquiv.continuousAlternatingMapCongr (e : E ≃L[𝕜] E') (e' : F ≃L[𝕜] F') :
(E [⋀^ι]→L[𝕜] F) ≃L[𝕜] (E' [⋀^ι]→L[𝕜] F') :=
e.continuousAlternatingMapCongrLeft.trans <| e'.continuousAlternatingMapCongrRight
end
open ContinuousAlternatingMap
namespace AlternatingMap
/-- Given a map `f : F →ₗ[𝕜] E [⋀^ι]→ₗ[𝕜] G` and an estimate
`H : ∀ x m, ‖f x m‖ ≤ C * ‖x‖ * ∏ i, ‖m i‖`, construct a continuous linear
map from `F` to `E [⋀^ι]→L[𝕜] G`.
In order to lift, e.g., a map `f : (E [⋀^ι]→ₗ[𝕜] F) →ₗ[𝕜] E' [⋀^ι]→ₗ[𝕜] G`
to a map `(E [⋀^ι]→L[𝕜] F) →L[𝕜] E' [⋀^ι]→L[𝕜] G`,
one can apply this construction to `f.comp ContinuousAlternatingMap.toAlternatingMapLinear`
which is a linear map from `E [⋀^ι]→L[𝕜] F` to `E' [⋀^ι]→ₗ[𝕜] G`. -/
def mkContinuousLinear (f : F →ₗ[𝕜] E [⋀^ι]→ₗ[𝕜] G) (C : ℝ)
(H : ∀ x m, ‖f x m‖ ≤ C * ‖x‖ * ∏ i, ‖m i‖) : F →L[𝕜] E [⋀^ι]→L[𝕜] G :=
LinearMap.mkContinuous
{ toFun x := (f x).mkContinuous (C * ‖x‖) <| H x
map_add' x y := by ext1; simp
map_smul' c x := by ext1; simp }
(max C 0) fun x ↦ by
rw [LinearMap.coe_mk, AddHom.coe_mk]
exact (mkContinuous_norm_le' _ _).trans_eq <| by
rw [max_mul_of_nonneg _ _ (norm_nonneg x), zero_mul]
theorem mkContinuousLinear_norm_le_max (f : F →ₗ[𝕜] E [⋀^ι]→ₗ[𝕜] G) (C : ℝ)
(H : ∀ x m, ‖f x m‖ ≤ C * ‖x‖ * ∏ i, ‖m i‖) : ‖mkContinuousLinear f C H‖ ≤ max C 0 :=
LinearMap.mkContinuous_norm_le _ (le_max_right _ _) _
theorem mkContinuousLinear_norm_le (f : F →ₗ[𝕜] E [⋀^ι]→ₗ[𝕜] G) {C : ℝ} (hC : 0 ≤ C)
(H : ∀ x m, ‖f x m‖ ≤ C * ‖x‖ * ∏ i, ‖m i‖) : ‖mkContinuousLinear f C H‖ ≤ C :=
(mkContinuousLinear_norm_le_max f C H).trans_eq (max_eq_left hC)
variable {ι' : Type*} [Fintype ι']
/-- Given a map `f : E [⋀^ι]→ₗ[𝕜] (F [⋀^ι']→ₗ[𝕜] G)` and an estimate
`H : ∀ m m', ‖f m m'‖ ≤ C * ∏ i, ‖m i‖ * ∏ i, ‖m' i‖`, upgrade all `AlternatingMap`s in the type
to `ContinuousAlternatingMap`s. -/
def mkContinuousAlternating (f : E [⋀^ι]→ₗ[𝕜] (F [⋀^ι']→ₗ[𝕜] G))
(C : ℝ) (H : ∀ m₁ m₂, ‖f m₁ m₂‖ ≤ (C * ∏ i, ‖m₁ i‖) * ∏ i, ‖m₂ i‖) :
E [⋀^ι]→L[𝕜] (F [⋀^ι']→L[𝕜] G) :=
mkContinuous
{ toFun m := mkContinuous (f m) (C * ∏ i, ‖m i‖) <| H m
map_update_add' m i x y := by ext1; simp
map_update_smul' m i c x := by ext1; simp
map_eq_zero_of_eq' v i j hv hij := by
ext v'
have : f v = 0 := by simpa using f.map_eq_zero_of_eq' v i j hv hij
simp [this] }
(max C 0) fun m => by
simp only [coe_mk, MultilinearMap.coe_mk]
refine ((f m).mkContinuous_norm_le' _).trans_eq ?_
rw [max_mul_of_nonneg, zero_mul]
positivity
@[simp]
theorem mkContinuousAlternating_apply (f : E [⋀^ι]→ₗ[𝕜] (F [⋀^ι']→ₗ[𝕜] G)) {C : ℝ}
(H : ∀ m₁ m₂, ‖f m₁ m₂‖ ≤ (C * ∏ i, ‖m₁ i‖) * ∏ i, ‖m₂ i‖) (m : ι → E) :
⇑(mkContinuousAlternating f C H m) = f m :=
rfl
theorem mkContinuousAlternating_norm_le_max (f : E [⋀^ι]→ₗ[𝕜] (F [⋀^ι']→ₗ[𝕜] G)) {C : ℝ}
(H : ∀ m₁ m₂, ‖f m₁ m₂‖ ≤ (C * ∏ i, ‖m₁ i‖) * ∏ i, ‖m₂ i‖) :
‖mkContinuousAlternating f C H‖ ≤ max C 0 := by
dsimp only [mkContinuousAlternating]
exact mkContinuous_norm_le _ (le_max_right _ _) _
theorem mkContinuousAlternating_norm_le (f : E [⋀^ι]→ₗ[𝕜] (F [⋀^ι']→ₗ[𝕜] G)) {C : ℝ}
(hC : 0 ≤ C) (H : ∀ m₁ m₂, ‖f m₁ m₂‖ ≤ (C * ∏ i, ‖m₁ i‖) * ∏ i, ‖m₂ i‖) :
‖mkContinuousAlternating f C H‖ ≤ C :=
(mkContinuousAlternating_norm_le_max f H).trans_eq (max_eq_left hC)
end AlternatingMap
end Seminorm
section Norm
/-! Results that are only true if the target space is a `NormedAddCommGroup`
(and not just a `SeminormedAddCommGroup`). -/
universe u wE wF v
variable {𝕜 : Type u} {n : ℕ} {E : Type wE} {F : Type wF} {ι : Type v}
[Fintype ι]
[NontriviallyNormedField 𝕜]
[SeminormedAddCommGroup E] [NormedSpace 𝕜 E]
[NormedAddCommGroup F] [NormedSpace 𝕜 F]
namespace ContinuousAlternatingMap
/-- Continuous alternating maps themselves form a normed group with respect to the operator norm. -/
instance instNormedAddCommGroup : NormedAddCommGroup (E [⋀^ι]→L[𝕜] F) :=
NormedAddCommGroup.ofSeparation fun _f hf ↦
toContinuousMultilinearMap_injective <| norm_eq_zero.mp hf
variable (𝕜 F) in
theorem norm_ofSubsingleton_id [Subsingleton ι] [Nontrivial F] (i : ι) :
‖ofSubsingleton 𝕜 F F i (.id _ _)‖ = 1 :=
ContinuousMultilinearMap.norm_ofSubsingleton_id 𝕜 F i
variable (𝕜 F) in
theorem nnnorm_ofSubsingleton_id [Subsingleton ι] [Nontrivial F] (i : ι) :
‖ofSubsingleton 𝕜 F F i (.id _ _)‖₊ = 1 :=
NNReal.eq <| norm_ofSubsingleton_id ..
end ContinuousAlternatingMap
namespace AlternatingMap
/-- If an alternating map in finitely many variables on a normed space satisfies the inequality
`‖f m‖ ≤ C * ∏ i, ‖m i‖` on a shell `ε i / ‖c i‖ < ‖m i‖ < ε i` for some positive numbers `ε i`
and elements `c i : 𝕜`, `1 < ‖c i‖`, then it satisfies this inequality for all `m`. -/
theorem bound_of_shell (f : F [⋀^ι]→ₗ[𝕜] E) {ε : ι → ℝ} {C : ℝ} {c : ι → 𝕜}
(hε : ∀ i, 0 < ε i) (hc : ∀ i, 1 < ‖c i‖)
(hf : ∀ m : ι → F, (∀ i, ε i / ‖c i‖ ≤ ‖m i‖) → (∀ i, ‖m i‖ < ε i) → ‖f m‖ ≤ C * ∏ i, ‖m i‖)
(m : ι → F) : ‖f m‖ ≤ C * ∏ i, ‖m i‖ :=
f.1.bound_of_shell hε hc hf m
end AlternatingMap
end Norm |
.lake/packages/mathlib/Mathlib/Analysis/NormedSpace/Alternating/Uncurry/Fin.lean | import Mathlib.Analysis.NormedSpace.Alternating.Curry
import Mathlib.LinearAlgebra.Alternating.Uncurry.Fin
/-!
# Uncurrying continuous alternating maps
Given a continuous function `f` which is linear in the first argument
and is alternating form in the other `n` arguments,
this file defines a continuous alternating form `ContinuousAlternatingMap.alternatizeUncurryFin f`
in `n + 1` arguments.
This function is given by
```
ContinuousAlternatingMap.alternatizeUncurryFin f v =
∑ i : Fin (n + 1), (-1) ^ (i : ℕ) • f (v i) (removeNth i v)
```
Given a continuous alternating map `f` of `n + 1` arguments,
each term in the sum above written for `f.curryLeft` equals the original map,
thus `f.curryLeft.alternatizeUncurryFin = (n + 1) • f`.
We do not multiply the result of `alternatizeUncurryFin` by `(n + 1)⁻¹`
so that the construction works for `𝕜`-multilinear maps over any normed field `𝕜`,
not only a field of characteristic zero.
## Main results
- `ContinuousAlternatingMap.alternatizeUncurryFin_curryLeft`:
the round-trip formula for currying/uncurrying, see above.
- `ContinuousAlternatingMap.alternatizeUncurryFin_alternatizeUncurryFinLM_comp_of_symmetric`:
If `f` is a symmetric bilinear map taking values in the space of continuous alternating maps,
then the twice uncurried `f` is zero.
The latter theorem will be used
to prove that the second exterior derivative of a differential form is zero.
-/
open Fin Function
namespace ContinuousAlternatingMap
variable {𝕜 E F : Type*} [NontriviallyNormedField 𝕜]
[NormedAddCommGroup E] [NormedSpace 𝕜 E]
[NormedAddCommGroup F] [NormedSpace 𝕜 F]
{n : ℕ}
/-- If `f` is a continuous `(n + 1)`-multilinear alternating map, `x` is an element of the domain,
and `v` is an `n`-vector, then the value of `f` at `v` with `x` inserted at the `p`th place
equals `(-1) ^ p` times the value of `f` at `v` with `x` prepended. -/
theorem map_insertNth (f : E [⋀^Fin (n + 1)]→L[𝕜] F) (p : Fin (n + 1)) (x : E) (v : Fin n → E) :
f (p.insertNth x v) = (-1) ^ (p : ℕ) • f (Matrix.vecCons x v) :=
f.toAlternatingMap.map_insertNth p x v
theorem neg_one_pow_smul_map_insertNth (f : E [⋀^Fin (n + 1)]→L[𝕜] F) (p : Fin (n + 1)) (x : E)
(v : Fin n → E) : (-1) ^ (p : ℕ) • f (p.insertNth x v) = f (Matrix.vecCons x v) :=
f.toAlternatingMap.neg_one_pow_smul_map_insertNth p x v
/-- Let `v` be an `(n + 1)`-tuple with two equal elements `v i = v j`, `i ≠ j`.
Let `w i` (resp., `w j`) be the vector `v` with `i`th (resp., `j`th) element removed.
Then `(-1) ^ i • f (w i) + (-1) ^ j • f (w j) = 0`.
This follows from the fact that these two vectors differ by a permutation of sign `(-1) ^ (i + j)`.
These are the only two nonzero terms in the proof of `map_eq_zero_of_eq`
in the definition of `AlternatingMap.alternatizeUncurryFin`. -/
theorem neg_one_pow_smul_map_removeNth_add_eq_zero_of_eq (f : E [⋀^Fin n]→L[𝕜] F)
{v : Fin (n + 1) → E} {i j : Fin (n + 1)} (hvij : v i = v j) (hij : i ≠ j) :
(-1) ^ (i : ℕ) • f (i.removeNth v) + (-1) ^ (j : ℕ) • f (j.removeNth v) = 0 :=
f.toAlternatingMap.neg_one_pow_smul_map_removeNth_add_eq_zero_of_eq hvij hij
private def alternatizeUncurryFinCLM.aux :
(E →L[𝕜] E [⋀^Fin n]→L[𝕜] F) →ₗ[𝕜] E [⋀^Fin (n + 1)]→ₗ[𝕜] F :=
AlternatingMap.alternatizeUncurryFinLM ∘ₗ (toAlternatingMapLinear (R := 𝕜)).compRight (S := 𝕜) ∘ₗ
ContinuousLinearMap.coeLM 𝕜
private lemma alternatizeUncurryFinCLM.aux_apply (f : E →L[𝕜] E [⋀^Fin n]→L[𝕜] F)
(v : Fin (n + 1) → E) :
aux f v = ∑ i : Fin (n + 1), (-1) ^ (i : ℕ) • f (v i) (i.removeNth v) := by
simp [aux, AlternatingMap.alternatizeUncurryFin_apply]
variable (𝕜 E F) in
/-- `AlternaringMap.alternatizeUncurryFin` as a continuous linear map. -/
@[irreducible]
noncomputable def alternatizeUncurryFinCLM :
(E →L[𝕜] E [⋀^Fin n]→L[𝕜] F) →L[𝕜] E [⋀^Fin (n + 1)]→L[𝕜] F :=
AlternatingMap.mkContinuousLinear alternatizeUncurryFinCLM.aux (n + 1) fun f v ↦ calc
‖alternatizeUncurryFinCLM.aux f v‖ ≤ ∑ i : Fin (n + 1), ‖f‖ * ∏ i, ‖v i‖ := by
rw [alternatizeUncurryFinCLM.aux_apply]
refine norm_sum_le_of_le _ fun i hi ↦ ?_
rw [norm_isUnit_zsmul _ (.pow _ isUnit_one.neg), i.prod_univ_succAbove, ← mul_assoc]
apply (f (v i)).le_of_opNorm_le
apply f.le_opNorm
_ = (n + 1) * ‖f‖ * ∏ i, ‖v i‖ := by simp [mul_assoc]
lemma norm_alternatizeUncurryFinCLM_le : ‖alternatizeUncurryFinCLM (n := n) 𝕜 E F‖ ≤ n + 1 := by
rw [alternatizeUncurryFinCLM]
apply AlternatingMap.mkContinuousLinear_norm_le
positivity
/-- Given a continuous function which is linear in the first argument
and is alternating in the other `n` arguments,
build a continuous alternating form in `n + 1` arguments.
The function is given by
```
alternatizeUncurryFin f v = ∑ i : Fin (n + 1), (-1) ^ (i : ℕ) • f (v i) (removeNth i v)
```
Note that the round-trip with `curryLeft` multiplies the form by `n + 1`,
since we want to avoid division in this definition. -/
noncomputable def alternatizeUncurryFin (f : E →L[𝕜] E [⋀^Fin n]→L[𝕜] F) :
E [⋀^Fin (n + 1)]→L[𝕜] F :=
alternatizeUncurryFinCLM 𝕜 E F f
@[simp]
lemma alternatizeUncurryFinCLM_apply (f : E →L[𝕜] E [⋀^Fin n]→L[𝕜] F) :
alternatizeUncurryFinCLM 𝕜 E F f = alternatizeUncurryFin f :=
rfl
lemma norm_alternatizeUncurryFin_le (f : E →L[𝕜] E [⋀^Fin n]→L[𝕜] F) :
‖alternatizeUncurryFin f‖ ≤ (n + 1) * ‖f‖ :=
(alternatizeUncurryFinCLM 𝕜 E F).le_of_opNorm_le norm_alternatizeUncurryFinCLM_le f
theorem alternatizeUncurryFin_apply (f : E →L[𝕜] E [⋀^Fin n]→L[𝕜] F) (v : Fin (n + 1) → E) :
alternatizeUncurryFin f v = ∑ i : Fin (n + 1), (-1) ^ (i : ℕ) • f (v i) (removeNth i v) := by
rw [alternatizeUncurryFin, alternatizeUncurryFinCLM]
apply alternatizeUncurryFinCLM.aux_apply
lemma toAlternatingMap_alternatizeUncurryFin (f : E →L[𝕜] E [⋀^Fin n]→L[𝕜] F) :
(alternatizeUncurryFin f).toAlternatingMap =
.alternatizeUncurryFin (toAlternatingMapLinear ∘ₗ (f : E →ₗ[𝕜] E [⋀^Fin n]→L[𝕜] F)) := by
ext
simp [alternatizeUncurryFin_apply, AlternatingMap.alternatizeUncurryFin_apply]
@[simp]
theorem alternatizeUncurryFin_add (f g : E →L[𝕜] E [⋀^Fin n]→L[𝕜] F) :
alternatizeUncurryFin (f + g) = alternatizeUncurryFin f + alternatizeUncurryFin g :=
map_add (alternatizeUncurryFinCLM 𝕜 E F) f g
@[simp]
lemma alternatizeUncurryFin_curryLeft (f : E [⋀^Fin (n + 1)]→L[𝕜] F) :
alternatizeUncurryFin (curryLeft f) = (n + 1) • f := by
ext v
simp [alternatizeUncurryFin_apply, ← map_insertNth]
@[simp]
theorem alternatizeUncurryFin_smul {S : Type*} [Monoid S] [DistribMulAction S F]
[ContinuousConstSMul S F] [SMulCommClass 𝕜 S F] (c : S) (f : E →L[𝕜] E [⋀^Fin n]→L[𝕜] F) :
alternatizeUncurryFin (c • f) = c • alternatizeUncurryFin f := by
ext v
simp [alternatizeUncurryFin_apply, smul_comm _ c, Finset.smul_sum]
theorem alternatizeUncurryFin_constOfIsEmptyLIE_comp (f : E →L[𝕜] F) :
alternatizeUncurryFin (constOfIsEmptyLIE 𝕜 E F (Fin 0) ∘L f) =
ofSubsingleton _ _ _ (0 : Fin 1) f := by
ext
simp [alternatizeUncurryFin_apply]
/-- If `f` is a symmetric continuous bilinear map
taking values in the space of continuous alternating maps,
then the twice uncurried `f` is zero. -/
theorem alternatizeUncurryFin_alternatizeUncurryFinCLM_comp_of_symmetric
{f : E →L[𝕜] E →L[𝕜] E [⋀^Fin n]→L[𝕜] F}
(hf : ∀ x y, f x y = f y x) :
alternatizeUncurryFin (alternatizeUncurryFinCLM 𝕜 E F ∘L f) = 0 := by
apply toAlternatingMap_injective
rw [toAlternatingMap_zero,
← AlternatingMap.alternatizeUncurryFin_alternatizeUncurryFinLM_comp_of_symmetric
(f := f.toLinearMap₁₂.compr₂ toAlternatingMapLinear)
(fun x y ↦ congr($(hf x y) |>.toAlternatingMap))]
rw [toAlternatingMap_alternatizeUncurryFin]
congr 1
ext
simp [alternatizeUncurryFin_apply, AlternatingMap.alternatizeUncurryFin_apply]
end ContinuousAlternatingMap |
.lake/packages/mathlib/Mathlib/Analysis/LocallyConvex/AbsConvex.lean | import Mathlib.Analysis.LocallyConvex.BalancedCoreHull
import Mathlib.Analysis.Convex.TotallyBounded
import Mathlib.Analysis.LocallyConvex.Bounded
/-!
# Absolutely convex sets
A set `s` in an commutative monoid `E` is called absolutely convex or disked if it is convex and
balanced. The importance of absolutely convex sets comes from the fact that every locally convex
topological vector space has a basis consisting of absolutely convex sets.
## Main definitions
* `absConvexHull`: the absolutely convex hull of a set `s` is the smallest absolutely convex set
containing `s`;
* `closedAbsConvexHull`: the closed absolutely convex hull of a set `s` is the smallest absolutely
convex set containing `s`;
## Main statements
* `absConvexHull_eq_convexHull_balancedHull`: when the locally convex space is a module, the
absolutely convex hull of a set `s` equals the convex hull of the balanced hull of `s`;
* `convexHull_union_neg_eq_absConvexHull`: the convex hull of `s ∪ -s` is the absolutely convex hull
of `s`;
* `closedAbsConvexHull_closure_eq_closedAbsConvexHull` : the closed absolutely convex hull of the
closure of `s` equals the closed absolutely convex hull of `s`;
## Tags
disks, convex, balanced
-/
open NormedField Set
open NNReal Pointwise Topology
variable {𝕜 E : Type*}
section AbsolutelyConvex
variable (𝕜) [SeminormedRing 𝕜] [SMul 𝕜 E] [AddCommMonoid E] [PartialOrder 𝕜]
/-- A set is absolutely convex if it is balanced and convex. -/
def AbsConvex (s : Set E) : Prop := Balanced 𝕜 s ∧ Convex 𝕜 s
variable {𝕜}
theorem AbsConvex.empty : AbsConvex 𝕜 (∅ : Set E) := ⟨balanced_empty, convex_empty⟩
theorem AbsConvex.univ : AbsConvex 𝕜 (univ : Set E) := ⟨balanced_univ, convex_univ⟩
theorem AbsConvex.inter {s t : Set E} (hs : AbsConvex 𝕜 s) (ht : AbsConvex 𝕜 t) :
AbsConvex 𝕜 (s ∩ t) := ⟨hs.1.inter ht.1, hs.2.inter ht.2⟩
theorem AbsConvex.sInter {S : Set (Set E)} (h : ∀ s ∈ S, AbsConvex 𝕜 s) : AbsConvex 𝕜 (⋂₀ S) :=
⟨.sInter fun s hs => (h s hs).1, convex_sInter fun s hs => (h s hs).2⟩
theorem AbsConvex.iInter {ι : Sort*} {s : ι → Set E} (h : ∀ i, AbsConvex 𝕜 (s i)) :
AbsConvex 𝕜 (⋂ i, s i) :=
sInter_range s ▸ AbsConvex.sInter <| forall_mem_range.2 h
theorem AbsConvex.iInter₂ {ι : Sort*} {κ : ι → Sort*} {f : ∀ i, κ i → Set E}
(h : ∀ i j, AbsConvex 𝕜 (f i j)) : AbsConvex 𝕜 (⋂ (i) (j), f i j) :=
AbsConvex.iInter fun _ => (AbsConvex.iInter fun _ => h _ _)
variable (𝕜)
/-- The absolute convex hull of a set `s` is the minimal absolute convex set that includes `s`. -/
@[simps! isClosed]
def absConvexHull : ClosureOperator (Set E) :=
.ofCompletePred (AbsConvex 𝕜) fun _ ↦ .sInter
variable {𝕜} {s : Set E}
theorem subset_absConvexHull : s ⊆ absConvexHull 𝕜 s :=
(absConvexHull 𝕜).le_closure s
theorem absConvex_absConvexHull : AbsConvex 𝕜 (absConvexHull 𝕜 s) :=
(absConvexHull 𝕜).isClosed_closure s
theorem balanced_absConvexHull : Balanced 𝕜 (absConvexHull 𝕜 s) :=
absConvex_absConvexHull.1
theorem convex_absConvexHull : Convex 𝕜 (absConvexHull 𝕜 s) :=
absConvex_absConvexHull.2
variable (𝕜 s) in
theorem absConvexHull_eq_iInter :
absConvexHull 𝕜 s = ⋂ (t : Set E) (_ : s ⊆ t) (_ : AbsConvex 𝕜 t), t := by
simp [absConvexHull, iInter_subtype, iInter_and]
variable {t : Set E} {x : E}
theorem mem_absConvexHull_iff : x ∈ absConvexHull 𝕜 s ↔ ∀ t, s ⊆ t → AbsConvex 𝕜 t → x ∈ t := by
simp_rw [absConvexHull_eq_iInter, mem_iInter]
theorem absConvexHull_min : s ⊆ t → AbsConvex 𝕜 t → absConvexHull 𝕜 s ⊆ t :=
(absConvexHull 𝕜).closure_min
theorem AbsConvex.absConvexHull_subset_iff (ht : AbsConvex 𝕜 t) : absConvexHull 𝕜 s ⊆ t ↔ s ⊆ t :=
(show (absConvexHull 𝕜).IsClosed t from ht).closure_le_iff
@[mono, gcongr]
theorem absConvexHull_mono (hst : s ⊆ t) : absConvexHull 𝕜 s ⊆ absConvexHull 𝕜 t :=
(absConvexHull 𝕜).monotone hst
lemma absConvexHull_eq_self : absConvexHull 𝕜 s = s ↔ AbsConvex 𝕜 s :=
(absConvexHull 𝕜).isClosed_iff.symm
alias ⟨_, AbsConvex.absConvexHull_eq⟩ := absConvexHull_eq_self
@[simp]
theorem absConvexHull_univ : absConvexHull 𝕜 (univ : Set E) = univ :=
ClosureOperator.closure_top (absConvexHull 𝕜)
@[simp]
theorem absConvexHull_empty : absConvexHull 𝕜 (∅ : Set E) = ∅ :=
AbsConvex.empty.absConvexHull_eq
@[simp]
theorem absConvexHull_eq_empty : absConvexHull 𝕜 s = ∅ ↔ s = ∅ := by
constructor
· intro h
rw [← Set.subset_empty_iff, ← h]
exact subset_absConvexHull
· rintro rfl
exact absConvexHull_empty
@[simp]
theorem absConvexHull_nonempty : (absConvexHull 𝕜 s).Nonempty ↔ s.Nonempty := by
rw [nonempty_iff_ne_empty, nonempty_iff_ne_empty, Ne, Ne]
exact not_congr absConvexHull_eq_empty
protected alias ⟨_, Set.Nonempty.absConvexHull⟩ := absConvexHull_nonempty
variable [TopologicalSpace E]
theorem absConvex_closed_sInter {S : Set (Set E)} (h : ∀ s ∈ S, AbsConvex 𝕜 s ∧ IsClosed s) :
AbsConvex 𝕜 (⋂₀ S) ∧ IsClosed (⋂₀ S) :=
⟨AbsConvex.sInter (fun s hs => (h s hs).1), isClosed_sInter fun _ hs => (h _ hs).2⟩
variable (𝕜) in
/-- The absolutely convex closed hull of a set `s` is the minimal absolutely convex closed set that
includes `s`. -/
@[simps! isClosed]
def closedAbsConvexHull : ClosureOperator (Set E) :=
.ofCompletePred (fun s => AbsConvex 𝕜 s ∧ IsClosed s) fun _ ↦ absConvex_closed_sInter
theorem absConvex_convexClosedHull {s : Set E} :
AbsConvex 𝕜 (closedAbsConvexHull 𝕜 s) := ((closedAbsConvexHull 𝕜).isClosed_closure s).1
theorem isClosed_closedAbsConvexHull {s : Set E} :
IsClosed (closedAbsConvexHull 𝕜 s) := ((closedAbsConvexHull 𝕜).isClosed_closure s).2
theorem subset_closedAbsConvexHull {s : Set E} : s ⊆ closedAbsConvexHull 𝕜 s :=
(closedAbsConvexHull 𝕜).le_closure s
theorem closure_subset_closedAbsConvexHull {s : Set E} : closure s ⊆ closedAbsConvexHull 𝕜 s :=
closure_minimal subset_closedAbsConvexHull isClosed_closedAbsConvexHull
theorem closedAbsConvexHull_min {s t : Set E} (hst : s ⊆ t) (h_conv : AbsConvex 𝕜 t)
(h_closed : IsClosed t) : closedAbsConvexHull 𝕜 s ⊆ t :=
(closedAbsConvexHull 𝕜).closure_min hst ⟨h_conv, h_closed⟩
theorem absConvexHull_subset_closedAbsConvexHull {s : Set E} :
(absConvexHull 𝕜) s ⊆ (closedAbsConvexHull 𝕜) s :=
absConvexHull_min subset_closedAbsConvexHull absConvex_convexClosedHull
@[simp]
theorem closedAbsConvexHull_closure_eq_closedAbsConvexHull {s : Set E} :
closedAbsConvexHull 𝕜 (closure s) = closedAbsConvexHull 𝕜 s :=
subset_antisymm (by simpa using ((closedAbsConvexHull 𝕜).monotone
(closure_subset_closedAbsConvexHull (𝕜 := 𝕜) (E := E))))
((closedAbsConvexHull 𝕜).monotone subset_closure)
end AbsolutelyConvex
section NormedField
variable [NormedField 𝕜] [PartialOrder 𝕜]
[AddCommGroup E] [Module 𝕜 E] [TopologicalSpace E]
[IsTopologicalAddGroup E] [ContinuousSMul 𝕜 E]
theorem AbsConvex.closure {s : Set E} (hs : AbsConvex 𝕜 s) : AbsConvex 𝕜 (closure s) :=
⟨Balanced.closure hs.1, Convex.closure hs.2⟩
theorem closedAbsConvexHull_eq_closure_absConvexHull {s : Set E} :
closedAbsConvexHull 𝕜 s = closure (absConvexHull 𝕜 s) := subset_antisymm
(closedAbsConvexHull_min (subset_trans (subset_absConvexHull) subset_closure)
(AbsConvex.closure absConvex_absConvexHull) isClosed_closure)
(closure_minimal absConvexHull_subset_closedAbsConvexHull isClosed_closedAbsConvexHull)
end NormedField
section NontriviallyNormedField
variable (𝕜 E)
variable [NontriviallyNormedField 𝕜] [PartialOrder 𝕜] [AddCommGroup E] [Module 𝕜 E]
variable [TopologicalSpace E] [LocallyConvexSpace 𝕜 E] [ContinuousSMul 𝕜 E]
theorem nhds_hasBasis_absConvex :
(𝓝 (0 : E)).HasBasis (fun s : Set E => s ∈ 𝓝 (0 : E) ∧ AbsConvex 𝕜 s) id := by
refine
(LocallyConvexSpace.convex_basis_zero 𝕜 E).to_hasBasis (fun s hs => ?_) fun s hs =>
⟨s, ⟨hs.1, hs.2.2⟩, rfl.subset⟩
refine ⟨convexHull 𝕜 (balancedCore 𝕜 s), ?_, convexHull_min (balancedCore_subset s) hs.2⟩
refine ⟨Filter.mem_of_superset (balancedCore_mem_nhds_zero hs.1) (subset_convexHull 𝕜 _), ?_⟩
refine ⟨(balancedCore_balanced s).convexHull, ?_⟩
exact convex_convexHull 𝕜 (balancedCore 𝕜 s)
variable [IsTopologicalAddGroup E]
theorem nhds_hasBasis_absConvex_open [ZeroLEOneClass 𝕜] :
(𝓝 (0 : E)).HasBasis (fun s => (0 : E) ∈ s ∧ IsOpen s ∧ AbsConvex 𝕜 s) id := by
refine (nhds_hasBasis_absConvex 𝕜 E).to_hasBasis ?_ ?_
· rintro s ⟨hs_nhds, hs_balanced, hs_convex⟩
refine ⟨interior s, ?_, interior_subset⟩
exact
⟨mem_interior_iff_mem_nhds.mpr hs_nhds, isOpen_interior,
hs_balanced.interior (mem_interior_iff_mem_nhds.mpr hs_nhds), hs_convex.interior⟩
rintro s ⟨hs_zero, hs_open, hs_balanced, hs_convex⟩
exact ⟨s, ⟨hs_open.mem_nhds hs_zero, hs_balanced, hs_convex⟩, rfl.subset⟩
end NontriviallyNormedField
section
variable (𝕜) [NontriviallyNormedField 𝕜] [PartialOrder 𝕜]
variable [AddCommGroup E] [Module 𝕜 E]
theorem absConvexHull_add_subset {s t : Set E} :
absConvexHull 𝕜 (s + t) ⊆ absConvexHull 𝕜 s + absConvexHull 𝕜 t :=
absConvexHull_min (add_subset_add subset_absConvexHull subset_absConvexHull)
⟨Balanced.add balanced_absConvexHull balanced_absConvexHull,
Convex.add convex_absConvexHull convex_absConvexHull⟩
theorem absConvexHull_eq_convexHull_balancedHull {s : Set E} :
absConvexHull 𝕜 s = convexHull 𝕜 (balancedHull 𝕜 s) := le_antisymm
(absConvexHull_min
((subset_convexHull 𝕜 s).trans (convexHull_mono (subset_balancedHull 𝕜)))
⟨Balanced.convexHull (balancedHull.balanced s), convex_convexHull ..⟩)
(convexHull_min (balanced_absConvexHull.balancedHull_subset_of_subset subset_absConvexHull)
convex_absConvexHull)
/-- In general, equality doesn't hold here - e.g. consider `s := {(-1, 1), (1, 1)}` in `ℝ²`. -/
theorem balancedHull_convexHull_subseteq_absConvexHull {s : Set E} :
balancedHull 𝕜 (convexHull 𝕜 s) ⊆ absConvexHull 𝕜 s :=
balanced_absConvexHull.balancedHull_subset_of_subset
(convexHull_min subset_absConvexHull convex_absConvexHull)
end
section
variable [AddCommGroup E] [Module ℝ E]
lemma balancedHull_subset_convexHull_union_neg {s : Set E} :
balancedHull ℝ s ⊆ convexHull ℝ (s ∪ -s) := by
intro a ha
obtain ⟨r, hr, y, hy, rfl⟩ := mem_balancedHull_iff.1 ha
apply segment_subset_convexHull (mem_union_left (-s) hy) (mem_union_right _ (neg_mem_neg.mpr hy))
have : 0 ≤ 1 + r := neg_le_iff_add_nonneg'.mp (neg_le_of_abs_le hr)
have : 0 ≤ 1 - r := sub_nonneg.2 (le_of_abs_le hr)
refine ⟨(1 + r)/2, (1 - r)/2, by positivity, by positivity, by ring, ?_⟩
rw [smul_neg, ← sub_eq_add_neg, ← sub_smul]
apply congrFun (congrArg HSMul.hSMul _) y
ring_nf
@[simp]
theorem convexHull_union_neg_eq_absConvexHull {s : Set E} :
convexHull ℝ (s ∪ -s) = absConvexHull ℝ s := by
rw [absConvexHull_eq_convexHull_balancedHull]
exact le_antisymm (convexHull_mono (union_subset (subset_balancedHull ℝ)
(fun _ _ => by rw [mem_balancedHull_iff]; use -1; simp_all)))
(by
rw [← Convex.convexHull_eq (convex_convexHull ℝ (s ∪ -s))]
exact convexHull_mono balancedHull_subset_convexHull_union_neg)
variable (E 𝕜) {s : Set E}
variable [NontriviallyNormedField 𝕜] [PartialOrder 𝕜] [Module 𝕜 E] [SMulCommClass ℝ 𝕜 E]
variable [UniformSpace E] [IsUniformAddGroup E] [lcs : LocallyConvexSpace ℝ E] [ContinuousSMul ℝ E]
-- TVS II.25 Prop3
theorem totallyBounded_absConvexHull (hs : TotallyBounded s) :
TotallyBounded (absConvexHull ℝ s) := by
rw [← convexHull_union_neg_eq_absConvexHull]
apply totallyBounded_convexHull
rw [totallyBounded_union]
exact ⟨hs, totallyBounded_neg hs⟩
end
lemma zero_mem_absConvexHull {s : Set E} [SeminormedRing 𝕜] [PartialOrder 𝕜] [AddCommGroup E]
[Module 𝕜 E] [Nonempty s] : 0 ∈ absConvexHull 𝕜 s :=
balanced_absConvexHull.zero_mem (Nonempty.mono subset_absConvexHull Set.Nonempty.of_subtype)
/-- [Bourbaki, *Topological Vector Spaces*, III §1.6][bourbaki1987] -/
theorem isCompact_closedAbsConvexHull_of_totallyBounded {E : Type*} [AddCommGroup E] [Module ℝ E]
[UniformSpace E] [IsUniformAddGroup E] [ContinuousSMul ℝ E] [LocallyConvexSpace ℝ E]
[QuasiCompleteSpace ℝ E] {s : Set E} (ht : TotallyBounded s) :
IsCompact (closedAbsConvexHull ℝ s) := by
rw [closedAbsConvexHull_eq_closure_absConvexHull]
exact isCompact_closure_of_totallyBounded_quasiComplete (𝕜 := ℝ)
(totallyBounded_absConvexHull E ht) |
.lake/packages/mathlib/Mathlib/Analysis/LocallyConvex/WeakDual.lean | import Mathlib.Analysis.Normed.Field.Lemmas
import Mathlib.Analysis.LocallyConvex.WithSeminorms
import Mathlib.LinearAlgebra.Dual.Lemmas
import Mathlib.LinearAlgebra.Finsupp.Span
import Mathlib.Topology.Algebra.Module.WeakBilin
/-!
# Weak Dual in Topological Vector Spaces
We prove that the weak topology induced by a bilinear form `B : E →ₗ[𝕜] F →ₗ[𝕜] 𝕜` is locally
convex and we explicitly give a neighborhood basis in terms of the family of seminorms
`fun x => ‖B x y‖` for `y : F`.
## Main definitions
* `LinearMap.toSeminorm`: turn a linear form `f : E →ₗ[𝕜] 𝕜` into a seminorm `fun x => ‖f x‖`.
* `LinearMap.toSeminormFamily`: turn a bilinear form `B : E →ₗ[𝕜] F →ₗ[𝕜] 𝕜` into a map
`F → Seminorm 𝕜 E`.
## Main statements
* `LinearMap.hasBasis_weakBilin`: the seminorm balls of `B.toSeminormFamily` form a
neighborhood basis of `0` in the weak topology.
* `LinearMap.toSeminormFamily.withSeminorms`: the topology of a weak space is induced by the
family of seminorms `B.toSeminormFamily`.
* `WeakBilin.locallyConvexSpace`: a space endowed with a weak topology is locally convex.
## References
* [Bourbaki, *Topological Vector Spaces*][bourbaki1987]
* [Rudin, *Functional Analysis*][rudin1991]
## Tags
weak dual, seminorm
-/
variable {𝕜 E F : Type*}
open Topology
section BilinForm
namespace LinearMap
variable [NormedField 𝕜] [AddCommGroup E] [Module 𝕜 E] [AddCommGroup F] [Module 𝕜 F]
/-- Construct a seminorm from a linear form `f : E →ₗ[𝕜] 𝕜` over a normed field `𝕜` by
`fun x => ‖f x‖` -/
def toSeminorm (f : E →ₗ[𝕜] 𝕜) : Seminorm 𝕜 E :=
(normSeminorm 𝕜 𝕜).comp f
theorem coe_toSeminorm {f : E →ₗ[𝕜] 𝕜} : ⇑f.toSeminorm = fun x => ‖f x‖ :=
rfl
@[simp]
theorem toSeminorm_apply {f : E →ₗ[𝕜] 𝕜} {x : E} : f.toSeminorm x = ‖f x‖ :=
rfl
theorem toSeminorm_ball_zero {f : E →ₗ[𝕜] 𝕜} {r : ℝ} :
Seminorm.ball f.toSeminorm 0 r = { x : E | ‖f x‖ < r } := by
simp only [Seminorm.ball_zero_eq, toSeminorm_apply]
theorem toSeminorm_comp (f : F →ₗ[𝕜] 𝕜) (g : E →ₗ[𝕜] F) :
f.toSeminorm.comp g = (f.comp g).toSeminorm := by
ext
simp only [Seminorm.comp_apply, toSeminorm_apply, coe_comp, Function.comp_apply]
/-- Construct a family of seminorms from a bilinear form. -/
def toSeminormFamily (B : E →ₗ[𝕜] F →ₗ[𝕜] 𝕜) : SeminormFamily 𝕜 E F := fun y =>
(B.flip y).toSeminorm
@[simp]
theorem toSeminormFamily_apply {B : E →ₗ[𝕜] F →ₗ[𝕜] 𝕜} {x y} : (B.toSeminormFamily y) x = ‖B x y‖ :=
rfl
variable {ι 𝕜 E F : Type*}
open Topology TopologicalSpace
open scoped NNReal
section
section TopologicalRing
variable [Finite ι] [Field 𝕜] [t𝕜 : TopologicalSpace 𝕜] [IsTopologicalRing 𝕜]
[AddCommGroup E] [Module 𝕜 E] [T0Space 𝕜]
/- A linear functional `φ` can be expressed as a linear combination of linear functionals `f₁,…,fₙ`
if and only if `φ` is continuous with respect to the topology induced by `f₁,…,fₙ`. See
`LinearMap.mem_span_iff_continuous` for a result about arbitrary collections of linear functionals.
-/
theorem mem_span_iff_continuous_of_finite {f : ι → E →ₗ[𝕜] 𝕜} (φ : E →ₗ[𝕜] 𝕜) :
φ ∈ Submodule.span 𝕜 (Set.range f) ↔ Continuous[⨅ i, induced (f i) t𝕜, t𝕜] φ := by
let _ := ⨅ i, induced (f i) t𝕜
constructor
· exact Submodule.span_induction
(Set.forall_mem_range.mpr fun i ↦ continuous_iInf_dom continuous_induced_dom) continuous_zero
(fun _ _ _ _ ↦ .add) (fun c _ _ h ↦ h.const_smul c)
· intro φ_cont
refine mem_span_of_iInf_ker_le_ker fun x hx ↦ ?_
simp_rw [Submodule.mem_iInf, LinearMap.mem_ker] at hx ⊢
have : Inseparable x 0 := by
-- Maybe missing lemmas about `Inseparable`?
simp_rw [Inseparable, nhds_iInf, nhds_induced, hx, map_zero]
simpa only [map_zero] using (this.map φ_cont).eq
end TopologicalRing
section NontriviallyNormedField
variable [NontriviallyNormedField 𝕜] [AddCommGroup E] [Module 𝕜 E]
/- A linear functional `φ` is in the span of a collection of linear functionals if and only if `φ`
is continuous with respect to the topology induced by the collection of linear functionals. See
`LinearMap.mem_span_iff_continuous_of_finite` for a result about finite collections of linear
functionals. -/
theorem mem_span_iff_continuous {f : ι → E →ₗ[𝕜] 𝕜} (φ : E →ₗ[𝕜] 𝕜) :
φ ∈ Submodule.span 𝕜 (Set.range f) ↔
Continuous[⨅ i, induced (f i) inferInstance, inferInstance] φ := by
letI t𝕜 : TopologicalSpace 𝕜 := inferInstance
letI t₁ : TopologicalSpace E := ⨅ i, induced (f i) t𝕜
letI t₂ (s : Finset ι) : TopologicalSpace E := ⨅ i : s, induced (f i) t𝕜
suffices
Continuous[t₁, t𝕜] φ ↔ ∃ s : Finset ι, Continuous[t₂ s, t𝕜] φ by
simp_rw [this, ← mem_span_iff_continuous_of_finite, Submodule.span_range_eq_iSup,
iSup_subtype]
rw [Submodule.mem_iSup_iff_exists_finset]
have t₁_group : @IsTopologicalAddGroup E t₁ _ :=
topologicalAddGroup_iInf fun _ ↦ topologicalAddGroup_induced _
have t₂_group (s : Finset ι) : @IsTopologicalAddGroup E (t₂ s) _ :=
topologicalAddGroup_iInf fun _ ↦ topologicalAddGroup_induced _
have t₁_smul : @ContinuousSMul 𝕜 E _ _ t₁ :=
continuousSMul_iInf fun _ ↦ continuousSMul_induced _
have t₂_smul (s : Finset ι) : @ContinuousSMul 𝕜 E _ _ (t₂ s) :=
continuousSMul_iInf fun _ ↦ continuousSMul_induced _
simp_rw [Seminorm.continuous_iff_continuous_comp (norm_withSeminorms 𝕜 𝕜), forall_const]
conv in Continuous _ => rw [Seminorm.continuous_iff one_pos, nhds_iInf]
conv in Continuous _ =>
rw [letI := t₂ s; Seminorm.continuous_iff one_pos, nhds_iInf, iInf_subtype]
rw [Filter.mem_iInf_finite]
theorem mem_span_iff_bound {f : ι → E →ₗ[𝕜] 𝕜} (φ : E →ₗ[𝕜] 𝕜) :
φ ∈ Submodule.span 𝕜 (Set.range f) ↔
∃ s : Finset ι, ∃ c : ℝ≥0, φ.toSeminorm ≤
c • (s.sup fun i ↦ (f i).toSeminorm) := by
letI t𝕜 : TopologicalSpace 𝕜 := inferInstance
let t := ⨅ i, induced (f i) t𝕜
have : IsTopologicalAddGroup E := topologicalAddGroup_iInf fun _ ↦ topologicalAddGroup_induced _
have : WithSeminorms (fun i ↦ (f i).toSeminorm) := by
simp_rw [SeminormFamily.withSeminorms_iff_nhds_eq_iInf, nhds_iInf, nhds_induced, map_zero,
← comap_norm_nhds_zero (E := 𝕜), Filter.comap_comap]
rfl
rw [LinearMap.mem_span_iff_continuous]
constructor <;> intro H
· rw [Seminorm.continuous_iff_continuous_comp (norm_withSeminorms 𝕜 𝕜), forall_const] at H
rcases Seminorm.bound_of_continuous this _ H with ⟨s, C, -, hC⟩
exact ⟨s, C, hC⟩
· exact Seminorm.cont_withSeminorms_normedSpace _ this _ H
end NontriviallyNormedField
end
end LinearMap
end BilinForm
section Topology
variable [NormedField 𝕜] [AddCommGroup E] [Module 𝕜 E] [AddCommGroup F] [Module 𝕜 F]
theorem LinearMap.weakBilin_withSeminorms (B : E →ₗ[𝕜] F →ₗ[𝕜] 𝕜) :
WithSeminorms (LinearMap.toSeminormFamily B : F → Seminorm 𝕜 (WeakBilin B)) :=
let e : F ≃ (Σ _ : F, Fin 1) := .symm <| .sigmaUnique _ _
withSeminorms_induced (withSeminorms_pi (fun _ ↦ norm_withSeminorms 𝕜 𝕜))
(LinearMap.ltoFun 𝕜 F 𝕜 ∘ₗ B : (WeakBilin B) →ₗ[𝕜] (F → 𝕜)) |>.congr_equiv e
theorem LinearMap.hasBasis_weakBilin (B : E →ₗ[𝕜] F →ₗ[𝕜] 𝕜) :
(𝓝 (0 : WeakBilin B)).HasBasis B.toSeminormFamily.basisSets _root_.id :=
LinearMap.weakBilin_withSeminorms B |>.hasBasis
end Topology
section LocallyConvex
variable [NormedField 𝕜] [AddCommGroup E] [Module 𝕜 E] [AddCommGroup F] [Module 𝕜 F]
variable [NormedSpace ℝ 𝕜] [Module ℝ E] [IsScalarTower ℝ 𝕜 E]
instance WeakBilin.locallyConvexSpace {B : E →ₗ[𝕜] F →ₗ[𝕜] 𝕜} :
LocallyConvexSpace ℝ (WeakBilin B) :=
B.weakBilin_withSeminorms.toLocallyConvexSpace
end LocallyConvex |
.lake/packages/mathlib/Mathlib/Analysis/LocallyConvex/SeparatingDual.lean | import Mathlib.Algebra.Central.Defs
import Mathlib.Analysis.LocallyConvex.Separation
import Mathlib.Analysis.LocallyConvex.WithSeminorms
import Mathlib.LinearAlgebra.Dual.Lemmas
/-!
# Spaces with separating dual
We introduce a typeclass `SeparatingDual R V`, registering that the points of the topological
module `V` over `R` can be separated by continuous linear forms.
This property is satisfied for normed spaces over `ℝ` or `ℂ` (by the analytic Hahn-Banach theorem)
and for locally convex topological spaces over `ℝ` (by the geometric Hahn-Banach theorem).
We show in `SeparatingDual.exists_ne_zero` that given any non-zero vector in an `R`-module `V`
satisfying `SeparatingDual R V`, there exists a continuous linear functional whose value on `v` is
non-zero.
As a consequence of the existence of `SeparatingDual.exists_ne_zero`, a generalization of
Hahn-Banach beyond the normed setting, we show that if `V` and `W` are nontrivial topological vector
spaces over a topological field `R` that acts continuously on `W`, and if `SeparatingDual R V`,
there are nontrivial continuous `R`-linear operators between `V` and `W`. This is recorded in the
instance `SeparatingDual.instNontrivialContinuousLinearMapIdOfContinuousSMul`.
Under the assumption `SeparatingDual R V`, we show in
`SeparatingDual.exists_continuousLinearEquiv_apply_eq` that the group of continuous linear
equivalences acts transitively on the set of nonzero vectors.
-/
/-- When `E` is a topological module over a topological ring `R`, the class `SeparatingDual R E`
registers that continuous linear forms on `E` separate points of `E`. -/
@[mk_iff separatingDual_def]
class SeparatingDual (R V : Type*) [Ring R] [AddCommGroup V] [TopologicalSpace V]
[TopologicalSpace R] [Module R V] : Prop where
/-- Any nonzero vector can be mapped by a continuous linear map to a nonzero scalar. -/
exists_ne_zero' : ∀ (x : V), x ≠ 0 → ∃ f : StrongDual R V, f x ≠ 0
instance {E : Type*} [TopologicalSpace E] [AddCommGroup E] [IsTopologicalAddGroup E]
[Module ℝ E] [ContinuousSMul ℝ E] [LocallyConvexSpace ℝ E] [T1Space E] : SeparatingDual ℝ E :=
⟨fun x hx ↦ by
rcases geometric_hahn_banach_point_point hx.symm with ⟨f, hf⟩
simp only [map_zero] at hf
exact ⟨f, hf.ne'⟩⟩
instance {E 𝕜 : Type*} [RCLike 𝕜] [NormedAddCommGroup E] [NormedSpace 𝕜 E] : SeparatingDual 𝕜 E :=
⟨fun x hx ↦
let : NormedSpace ℝ E := RestrictScalars.normedSpace ℝ 𝕜 E
let : Module ℝ E := RestrictScalars.module ℝ 𝕜 E
have : IsScalarTower ℝ 𝕜 E := RestrictScalars.isScalarTower ℝ 𝕜 E
have : LocallyConvexSpace ℝ E := NormedSpace.toLocallyConvexSpace' 𝕜
RCLike.geometric_hahn_banach_point_point hx |>.imp fun f hf hf' ↦ by simp [hf'] at hf⟩
namespace SeparatingDual
section Ring
variable {R V : Type*} [Ring R] [AddCommGroup V] [TopologicalSpace V]
[TopologicalSpace R] [Module R V] [SeparatingDual R V]
lemma exists_ne_zero {x : V} (hx : x ≠ 0) :
∃ f : StrongDual R V, f x ≠ 0 :=
exists_ne_zero' x hx
theorem exists_separating_of_ne {x y : V} (h : x ≠ y) :
∃ f : StrongDual R V, f x ≠ f y := by
rcases exists_ne_zero (R := R) (sub_ne_zero_of_ne h) with ⟨f, hf⟩
exact ⟨f, by simpa [sub_ne_zero] using hf⟩
protected theorem t1Space [T1Space R] : T1Space V := by
apply t1Space_iff_exists_open.2 (fun x y hxy ↦ ?_)
rcases exists_separating_of_ne (R := R) hxy with ⟨f, hf⟩
exact ⟨f ⁻¹' {f y}ᶜ, isOpen_compl_singleton.preimage f.continuous, hf, by simp⟩
protected theorem t2Space [T2Space R] : T2Space V := by
apply (t2Space_iff _).2 (fun {x} {y} hxy ↦ ?_)
rcases exists_separating_of_ne (R := R) hxy with ⟨f, hf⟩
exact separated_by_continuous f.continuous hf
end Ring
section Field
variable {R V : Type*} [Field R] [AddCommGroup V] [TopologicalSpace R] [TopologicalSpace V]
[IsTopologicalRing R] [Module R V]
-- TODO (@alreadydone): this could generalize to CommRing R if we were to add a section
theorem _root_.separatingDual_iff_injective : SeparatingDual R V ↔
Function.Injective (ContinuousLinearMap.coeLM (R := R) R (M := V) (N₃ := R)).flip := by
simp_rw [separatingDual_def, Ne, injective_iff_map_eq_zero]
congrm ∀ v, ?_
rw [not_imp_comm, LinearMap.ext_iff]
push_neg; rfl
variable [SeparatingDual R V]
open Function
/-- Given a finite-dimensional subspace `W` of a space `V` with separating dual, any
linear functional on `W` extends to a continuous linear functional on `V`.
This is stated more generally for an injective linear map from `W` to `V`. -/
theorem dualMap_surjective_iff {W} [AddCommGroup W] [Module R W] [FiniteDimensional R W]
{f : W →ₗ[R] V} : Surjective (f.dualMap ∘ ContinuousLinearMap.toLinearMap) ↔ Injective f := by
constructor <;> intro hf
· exact LinearMap.dualMap_surjective_iff.mp hf.of_comp
have := (separatingDual_iff_injective.mp ‹_›).comp hf
rw [← LinearMap.coe_comp] at this
exact LinearMap.flip_surjective_iff₁.mpr this
variable (V) in
open ContinuousLinearMap in
/- As a consequence of the existence of non-zero linear maps, itself a consequence of Hahn-Banach
in the normed setting, we show that if `V` and `W` are nontrivial topological vector spaces over a
topological field `R` that acts continuously on `W`, and if `SeparatingDual R V`, there are
nontrivial continuous `R`-linear operators between `V` and `W`. -/
instance (W) [AddCommGroup W] [TopologicalSpace W] [Module R W] [Nontrivial W]
[ContinuousSMul R W] [Nontrivial V] : Nontrivial (V →L[R] W) := by
obtain ⟨v, hv⟩ := exists_ne (0 : V)
obtain ⟨w, hw⟩ := exists_ne (0 : W)
obtain ⟨ψ, hψ⟩ := exists_ne_zero (R := R) hv
exact ⟨ψ.smulRight w, 0, DFunLike.ne_iff.mpr ⟨v, by simp_all⟩⟩
lemma exists_eq_one {x : V} (hx : x ≠ 0) :
∃ f : StrongDual R V, f x = 1 := by
rcases exists_ne_zero (R := R) hx with ⟨f, hf⟩
exact ⟨(f x)⁻¹ • f, inv_mul_cancel₀ hf⟩
theorem exists_eq_one_ne_zero_of_ne_zero_pair {x y : V} (hx : x ≠ 0) (hy : y ≠ 0) :
∃ f : StrongDual R V, f x = 1 ∧ f y ≠ 0 := by
obtain ⟨u, ux⟩ : ∃ u : StrongDual R V, u x = 1 := exists_eq_one hx
rcases ne_or_eq (u y) 0 with uy|uy
· exact ⟨u, ux, uy⟩
obtain ⟨v, vy⟩ : ∃ v : StrongDual R V, v y = 1 := exists_eq_one hy
rcases ne_or_eq (v x) 0 with vx|vx
· exact ⟨(v x)⁻¹ • v, inv_mul_cancel₀ vx, show (v x)⁻¹ * v y ≠ 0 by simp [vx, vy]⟩
· exact ⟨u + v, by simp [ux, vx], by simp [uy, vy]⟩
variable [IsTopologicalAddGroup V]
/-- The center of continuous linear maps on a topological vector space
with separating dual is trivial, in other words, it is a central algebra. -/
instance _root_.Algebra.IsCentral.continuousLinearMap [ContinuousSMul R V] :
Algebra.IsCentral R (V →L[R] V) where
out T hT := by
have h' (f : StrongDual R V) (y v : V) : f (T v) • y = f v • T y := by
simpa using congr($(Subalgebra.mem_center_iff.mp hT <| f.smulRight y) v)
nontriviality V
obtain ⟨x, hx⟩ := exists_ne (0 : V)
obtain ⟨f, hf⟩ := exists_eq_one (R := R) hx
exact ⟨f (T x), ContinuousLinearMap.ext fun _ => by simp [h', hf]⟩
/-- In a topological vector space with separating dual, the group of continuous linear equivalences
acts transitively on the set of nonzero vectors: given two nonzero vectors `x` and `y`, there
exists `A : V ≃L[R] V` mapping `x` to `y`. -/
theorem exists_continuousLinearEquiv_apply_eq [ContinuousSMul R V]
{x y : V} (hx : x ≠ 0) (hy : y ≠ 0) :
∃ A : V ≃L[R] V, A x = y := by
obtain ⟨G, Gx, Gy⟩ : ∃ G : StrongDual R V, G x = 1 ∧ G y ≠ 0 :=
exists_eq_one_ne_zero_of_ne_zero_pair hx hy
let A : V ≃L[R] V :=
{ toFun := fun z ↦ z + G z • (y - x)
invFun := fun z ↦ z + ((G y) ⁻¹ * G z) • (x - y)
map_add' := fun a b ↦ by simp [add_smul]; abel
map_smul' := by simp [smul_smul]
left_inv := fun z ↦ by
simp only [RingHom.id_apply, smul_eq_mul,
-- Note: https://github.com/leanprover-community/mathlib4/pull/8386 had to change `map_smulₛₗ` into `map_smulₛₗ _`
map_add, map_smulₛₗ _, map_sub, Gx, mul_sub, mul_one, add_sub_cancel]
rw [mul_comm (G z), ← mul_assoc, inv_mul_cancel₀ Gy]
simp only [smul_sub, one_mul]
abel
right_inv := fun z ↦ by
-- Note: https://github.com/leanprover-community/mathlib4/pull/8386 had to change `map_smulₛₗ` into `map_smulₛₗ _`
simp only [map_add, map_smulₛₗ _, map_mul, map_inv₀, RingHom.id_apply, map_sub, Gx,
smul_eq_mul, mul_sub, mul_one]
rw [mul_comm _ (G y), ← mul_assoc, mul_inv_cancel₀ Gy]
simp only [smul_sub, one_mul, add_sub_cancel]
abel
continuous_toFun := continuous_id.add (G.continuous.smul continuous_const)
continuous_invFun :=
continuous_id.add ((continuous_const.mul G.continuous).smul continuous_const) }
exact ⟨A, show x + G x • (y - x) = y by simp [Gx]⟩
end Field
end SeparatingDual |
.lake/packages/mathlib/Mathlib/Analysis/LocallyConvex/Polar.lean | import Mathlib.Analysis.Normed.Module.Basic
import Mathlib.LinearAlgebra.SesquilinearForm.Basic
import Mathlib.Topology.Algebra.Module.WeakBilin
/-!
# Polar set
In this file we define the polar set. There are different notions of the polar, we will define the
*absolute polar*. The advantage over the real polar is that we can define the absolute polar for
any bilinear form `B : E →ₗ[𝕜] F →ₗ[𝕜] 𝕜`, where `𝕜` is a normed commutative ring and
`E` and `F` are modules over `𝕜`.
## Main definitions
* `LinearMap.polar`: The polar of a bilinear form `B : E →ₗ[𝕜] F →ₗ[𝕜] 𝕜`.
## Main statements
* `LinearMap.polar_eq_iInter`: The polar as an intersection.
* `LinearMap.subset_bipolar`: The polar is a subset of the bipolar.
* `LinearMap.polar_isClosed`: The polar is closed in the weak topology induced by `B.flip`.
## References
* [H. H. Schaefer, *Topological Vector Spaces*][schaefer1966]
## Tags
polar
-/
variable {𝕜 E F : Type*}
open Topology
namespace LinearMap
section NormedRing
variable [NormedCommRing 𝕜] [AddCommMonoid E] [AddCommMonoid F]
variable [Module 𝕜 E] [Module 𝕜 F]
variable (B : E →ₗ[𝕜] F →ₗ[𝕜] 𝕜)
/-- The (absolute) polar of `s : Set E` is given by the set of all `y : F` such that `‖B x y‖ ≤ 1`
for all `x ∈ s`. -/
def polar (s : Set E) : Set F :=
{ y : F | ∀ x ∈ s, ‖B x y‖ ≤ 1 }
theorem polar_mem_iff (s : Set E) (y : F) : y ∈ B.polar s ↔ ∀ x ∈ s, ‖B x y‖ ≤ 1 :=
Iff.rfl
theorem polar_mem (s : Set E) (y : F) (hy : y ∈ B.polar s) : ∀ x ∈ s, ‖B x y‖ ≤ 1 :=
hy
theorem polar_eq_biInter_preimage (s : Set E) :
B.polar s = ⋂ x ∈ s, ((B x) ⁻¹' Metric.closedBall (0 : 𝕜) 1) := by aesop
-- TODO: this theorem is abusing defeq between F and WeakBilin B.flip
theorem polar_isClosed (s : Set E) : IsClosed (X := WeakBilin B.flip) (B.polar s) := by
rw [polar_eq_biInter_preimage]
exact isClosed_biInter
fun _ _ ↦ Metric.isClosed_closedBall.preimage (WeakBilin.eval_continuous B.flip _)
@[simp]
theorem zero_mem_polar (s : Set E) : (0 : F) ∈ B.polar s := fun _ _ => by
simp only [map_zero, norm_zero, zero_le_one]
theorem polar_nonempty (s : Set E) : Set.Nonempty (B.polar s) := by
use 0
exact zero_mem_polar B s
theorem polar_eq_iInter {s : Set E} : B.polar s = ⋂ x ∈ s, { y : F | ‖B x y‖ ≤ 1 } := by
ext
simp only [polar_mem_iff, Set.mem_iInter, Set.mem_setOf_eq]
/-- The map `B.polar : Set E → Set F` forms an order-reversing Galois connection with
`B.flip.polar : Set F → Set E`. We use `OrderDual.toDual` and `OrderDual.ofDual` to express
that `polar` is order-reversing. -/
theorem polar_gc :
GaloisConnection (OrderDual.toDual ∘ B.polar) (B.flip.polar ∘ OrderDual.ofDual) := fun _ _ =>
⟨fun h _ hx _ hy => h hy _ hx, fun h _ hx _ hy => h hy _ hx⟩
@[simp]
theorem polar_iUnion {ι} {s : ι → Set E} : B.polar (⋃ i, s i) = ⋂ i, B.polar (s i) :=
B.polar_gc.l_iSup
@[simp]
theorem polar_union {s t : Set E} : B.polar (s ∪ t) = B.polar s ∩ B.polar t :=
B.polar_gc.l_sup
theorem polar_antitone : Antitone (B.polar : Set E → Set F) :=
B.polar_gc.monotone_l
@[simp]
theorem polar_empty : B.polar ∅ = Set.univ :=
B.polar_gc.l_bot
@[simp]
theorem polar_singleton {a : E} : B.polar {a} = { y | ‖B a y‖ ≤ 1 } := le_antisymm
(fun _ hy => hy _ rfl)
(fun y hy => (polar_mem_iff _ _ _).mp (fun _ hb => by rw [Set.mem_singleton_iff.mp hb]; exact hy))
theorem mem_polar_singleton {x : E} (y : F) : y ∈ B.polar {x} ↔ ‖B x y‖ ≤ 1 := by
simp only [polar_singleton, Set.mem_setOf_eq]
theorem polar_zero : B.polar ({0} : Set E) = Set.univ := by
simp only [polar_singleton, map_zero, zero_apply, norm_zero, zero_le_one, Set.setOf_true]
theorem subset_bipolar (s : Set E) : s ⊆ B.flip.polar (B.polar s) := fun x hx y hy => by
rw [B.flip_apply]
exact hy x hx
@[simp]
theorem tripolar_eq_polar (s : Set E) : B.polar (B.flip.polar (B.polar s)) = B.polar s :=
(B.polar_antitone (B.subset_bipolar s)).antisymm (subset_bipolar B.flip (B.polar s))
@[deprecated (since := "2025-10-06")] alias polar_weak_closed := polar_isClosed
theorem sInter_polar_finite_subset_eq_polar (s : Set E) :
⋂₀ (B.polar '' { F | F.Finite ∧ F ⊆ s }) = B.polar s := by
ext x
simp only [Set.sInter_image, Set.mem_setOf_eq, Set.mem_iInter, and_imp]
refine ⟨fun hx a ha ↦ ?_, fun hx F _ hF₂ => polar_antitone _ hF₂ hx⟩
simpa [mem_polar_singleton] using hx _ (Set.finite_singleton a) (Set.singleton_subset_iff.mpr ha)
end NormedRing
section NontriviallyNormedField
variable [NontriviallyNormedField 𝕜] [AddCommMonoid E] [AddCommMonoid F]
variable [Module 𝕜 E] [Module 𝕜 F]
variable (B : E →ₗ[𝕜] F →ₗ[𝕜] 𝕜)
theorem polar_univ (h : SeparatingRight B) : B.polar Set.univ = {(0 : F)} := by
rw [Set.eq_singleton_iff_unique_mem]
refine ⟨by simp only [zero_mem_polar], fun y hy => h _ fun x => ?_⟩
refine norm_le_zero_iff.mp (le_of_forall_gt_imp_ge_of_dense fun ε hε => ?_)
rcases NormedField.exists_norm_lt 𝕜 hε with ⟨c, hc, hcε⟩
calc
‖B x y‖ = ‖c‖ * ‖B (c⁻¹ • x) y‖ := by
rw [B.map_smul, LinearMap.smul_apply, Algebra.id.smul_eq_mul, norm_mul, norm_inv,
mul_inv_cancel_left₀ hc.ne']
_ ≤ ε * 1 := by gcongr; exact hy _ trivial
_ = ε := mul_one _
theorem polar_subMulAction {S : Type*} [SetLike S E] [SMulMemClass S 𝕜 E] (m : S) :
B.polar m = { y | ∀ x ∈ m, B x y = 0 } := by
ext y
constructor
· intro hy x hx
obtain ⟨r, hr⟩ := NormedField.exists_lt_norm 𝕜 ‖B x y‖⁻¹
contrapose! hr
rw [← one_div, le_div_iff₀ (norm_pos_iff.2 hr)]
simpa using hy _ (SMulMemClass.smul_mem r hx)
· intro h x hx
simp [h x hx]
/-- The polar of a set closed under scalar multiplication as a submodule -/
def polarSubmodule {S : Type*} [SetLike S E] [SMulMemClass S 𝕜 E] (m : S) : Submodule 𝕜 F :=
.copy (⨅ x ∈ m, LinearMap.ker (B x)) (B.polar m) <| by ext; simp [polar_subMulAction]
end NontriviallyNormedField
end LinearMap
namespace StrongDual
section
variable (R M : Type*) [SeminormedCommRing R] [TopologicalSpace M] [AddCommGroup M] [Module R M]
theorem dualPairing_separatingLeft : (topDualPairing R M).SeparatingLeft := by
rw [LinearMap.separatingLeft_iff_ker_eq_bot, LinearMap.ker_eq_bot]
exact ContinuousLinearMap.coe_injective
@[deprecated (since := "2025-08-12")] alias NormedSpace.dualPairing_separatingLeft :=
dualPairing_separatingLeft
end
section
/-- Given a subset `s` in a monoid `M` (over a commutative ring `R`), the polar `polar R s` is the
subset of `StrongDual R M` consisting of those functionals which evaluate to something of norm at
most one at all points `z ∈ s`. -/
def polar (R : Type*) [NormedCommRing R] {M : Type*} [AddCommMonoid M]
[TopologicalSpace M] [Module R M] : Set M → Set (StrongDual R M) :=
(topDualPairing R M).flip.polar
@[deprecated (since := "2025-08-12")] alias _root_.NormedSpace.polar := polar
/-- Given a subset `s` in a monoid `M` (over a field `𝕜`) closed under scalar multiplication,
the polar `polarSubmodule 𝕜 s` is the submodule of `StrongDual 𝕜 M` consisting of those functionals
which evaluate to zero at all points `z ∈ s`. -/
def polarSubmodule (𝕜 : Type*) [NontriviallyNormedField 𝕜] {M : Type*} [AddCommMonoid M]
[TopologicalSpace M] [Module 𝕜 M] {S : Type*} [SetLike S M] [SMulMemClass S 𝕜 M] (m : S) :
Submodule 𝕜 (StrongDual 𝕜 M) := (topDualPairing 𝕜 M).flip.polarSubmodule m
@[deprecated (since := "2025-08-12")] alias _root_.NormedSpace.polarSubmodule := polarSubmodule
variable (𝕜 : Type*) [NontriviallyNormedField 𝕜]
variable {E : Type*} [AddCommMonoid E] [TopologicalSpace E] [Module 𝕜 E]
lemma polarSubmodule_eq_polar (m : SubMulAction 𝕜 E) :
(polarSubmodule 𝕜 m : Set (StrongDual 𝕜 E)) = polar 𝕜 m := rfl
@[deprecated (since := "2025-08-12")] alias _root_.NormedSpace.polarSubmodule_eq_polar :=
polarSubmodule_eq_polar
theorem mem_polar_iff {x' : StrongDual 𝕜 E} (s : Set E) : x' ∈ polar 𝕜 s ↔ ∀ z ∈ s, ‖x' z‖ ≤ 1 :=
Iff.rfl
@[deprecated (since := "2025-08-12")] alias _root_.NormedSpace.mem_polar_iff := mem_polar_iff
lemma polarSubmodule_eq_setOf {S : Type*} [SetLike S E] [SMulMemClass S 𝕜 E] (m : S) :
polarSubmodule 𝕜 m = { y : StrongDual 𝕜 E | ∀ x ∈ m, y x = 0 } :=
(topDualPairing 𝕜 E).flip.polar_subMulAction _
@[deprecated (since := "2025-08-12")] alias _root_.NormedSpace.polarSubmodule_eq_setOf :=
polarSubmodule_eq_setOf
lemma mem_polarSubmodule {S : Type*} [SetLike S E] [SMulMemClass S 𝕜 E] (m : S)
(y : StrongDual 𝕜 E) : y ∈ polarSubmodule 𝕜 m ↔ ∀ x ∈ m, y x = 0 :=
propext_iff.mp congr($(polarSubmodule_eq_setOf 𝕜 m) y)
@[deprecated (since := "2025-08-12")] alias _root_.NormedSpace.mem_polarSubmodule :=
mem_polarSubmodule
@[simp]
theorem zero_mem_polar (s : Set E) : (0 : StrongDual 𝕜 E) ∈ polar 𝕜 s :=
LinearMap.zero_mem_polar _ s
@[deprecated (since := "2025-08-12")] alias _root_.NormedSpace.zero_mem_polar := zero_mem_polar
theorem polar_nonempty (s : Set E) : Set.Nonempty (polar 𝕜 s) :=
LinearMap.polar_nonempty _ _
@[deprecated (since := "2025-08-12")] alias _root_.NormedSpace.polar_nonempty := polar_nonempty
open Set
@[simp]
theorem polar_empty : polar 𝕜 (∅ : Set E) = Set.univ :=
LinearMap.polar_empty _
@[deprecated (since := "2025-08-12")] alias _root_.NormedSpace.polar_empty := polar_empty
@[simp]
theorem polar_singleton {a : E} : polar 𝕜 {a} = { x | ‖x a‖ ≤ 1 } := by
simp only [polar, LinearMap.polar_singleton, LinearMap.flip_apply, topDualPairing_apply]
@[deprecated (since := "2025-08-12")] alias _root_.NormedSpace.polar_singleton := polar_singleton
theorem mem_polar_singleton {a : E} (y : StrongDual 𝕜 E) : y ∈ polar 𝕜 {a} ↔ ‖y a‖ ≤ 1 := by
simp only [polar_singleton, mem_setOf_eq]
@[deprecated (since := "2025-08-12")] alias _root_.NormedSpace.mem_polar_singleton :=
mem_polar_singleton
theorem polar_zero : polar 𝕜 ({0} : Set E) = Set.univ :=
LinearMap.polar_zero _
@[deprecated (since := "2025-08-12")] alias _root_.NormedSpace.polar_zero := polar_zero
end
section
variable (𝕜 : Type*) [NontriviallyNormedField 𝕜]
variable {E : Type*} [AddCommGroup E] [TopologicalSpace E] [Module 𝕜 E]
open Set
@[simp]
theorem polar_univ : polar 𝕜 (univ : Set E) = {(0 : StrongDual 𝕜 E)} :=
(topDualPairing 𝕜 E).flip.polar_univ
(LinearMap.flip_separatingRight.mpr (dualPairing_separatingLeft 𝕜 E))
@[deprecated (since := "2025-08-12")] alias _root_.NormedSpace.polar_univ := polar_univ
end
end StrongDual |
.lake/packages/mathlib/Mathlib/Analysis/LocallyConvex/WeakOperatorTopology.lean | import Mathlib.Analysis.LocallyConvex.WithSeminorms
import Mathlib.Analysis.LocallyConvex.SeparatingDual
import Mathlib.Topology.Algebra.Module.StrongTopology
/-!
# The weak operator topology
This file defines a type copy of `E →L[𝕜] F` (where `E` and `F` are topological vector spaces)
which is endowed with the weak operator topology (WOT) rather than the topology of bounded
convergence (which is the usual one induced by the operator norm in the normed setting).
The WOT is defined as the coarsest topology such that the functional `fun A => y (A x)` is
continuous for any `x : E` and `y : StrongDual 𝕜 F`. Equivalently, a function `f` tends to
`A : E →WOT[𝕜] F` along filter `l` iff `y (f a x)` tends to `y (A x)` along the same filter.
Basic non-topological properties of `E →L[𝕜] F` (such as the module structure) are copied over to
the type copy.
We also prove that the WOT is induced by the family of seminorms `‖y (A x)‖` for `x : E` and
`y : StrongDual 𝕜 F`.
## Main declarations
* `ContinuousLinearMapWOT σ E F`: The type copy of `E →SL[σ] F` endowed with the weak operator
topology.
* `ContinuousLinearMapWOT.tendsto_iff_forall_dual_apply_tendsto`: a function `f` tends to
`A : E →WOT[𝕜] F` along filter `l` iff `y ((f a) x)` tends to `y (A x)` along the same filter.
* `ContinuousLinearMap.toWOT`: the inclusion map from `E →SL[σ] F` to the type copy
* `ContinuousLinearMap.continuous_toWOT`: the inclusion map is continuous, i.e. the WOT is coarser
than the norm topology.
* `ContinuousLinearMapWOT.withSeminorms`: the WOT is induced by the family of seminorms
`‖y (A x)‖` for `x : E` and `y : StrongDual 𝕜 F`.
## Notation
* The type copy of `E →L[𝕜] F` endowed with the weak operator topology is denoted by
`E →WOT[𝕜] F` and the copy of `E →SL[σ] F` is denoted by `E →SWOT[σ] F`.
* We locally use the notation `F⋆` for `StrongDual 𝕜 F`.
## Implementation notes
In most of the literature, the WOT is defined on maps between Banach spaces. Here, we only assume
that the domain and codomains are topological vector spaces over a normed field.
-/
open Topology
/-- The type copy of `E →L[𝕜] F` endowed with the weak operator topology, denoted as
`E →WOT[𝕜] F`. -/
@[irreducible]
def ContinuousLinearMapWOT {𝕜₁ 𝕜₂ : Type*} [Semiring 𝕜₁] [Semiring 𝕜₂] (σ : 𝕜₁ →+* 𝕜₂)
(E F : Type*) [AddCommGroup E]
[TopologicalSpace E] [Module 𝕜₁ E] [AddCommGroup F] [TopologicalSpace F] [Module 𝕜₂ F] :=
E →SL[σ] F
@[inherit_doc]
notation:25 E " →SWOT[" σ "] " F => ContinuousLinearMapWOT σ E F
@[inherit_doc]
notation:25 E " →WOT[" 𝕜 "] " F => ContinuousLinearMapWOT (RingHom.id 𝕜) E F
namespace ContinuousLinearMapWOT
variable {𝕜₁ 𝕜₂ : Type*} [NormedField 𝕜₁] [NormedField 𝕜₂]
{σ : 𝕜₁ →+* 𝕜₂}
{E F : Type*}
[AddCommGroup E] [TopologicalSpace E] [Module 𝕜₁ E]
[AddCommGroup F] [TopologicalSpace F] [Module 𝕜₂ F]
local notation X "⋆" => StrongDual 𝕜₂ X
/-!
### Basic properties common with `E →L[𝕜] F`
The section copies basic non-topological properties of `E →L[𝕜] F` over to `E →WOT[𝕜] F`, such as
the module structure, `FunLike`, etc.
-/
section Basic
/-
Warning : Due to the irreducibility of `ContinuousLinearMapWOT`, one has to be careful when
declaring instances with data. For example, adding
```
unseal ContinuousLinearMapWOT in
instance instAddCommMonoid [ContinuousAdd F] : AddCommMonoid (E →WOT[𝕜] F) :=
inferInstanceAs <| AddCommMonoid (E →L[𝕜] F)
```
would cause the following to fail :
```
example [IsTopologicalAddGroup F] :
(instAddCommMonoid : AddCommMonoid (E →WOT[𝕜] F)) =
instAddCommGroup.toAddCommMonoid := rfl
```
-/
unseal ContinuousLinearMapWOT in
instance instAddCommGroup [IsTopologicalAddGroup F] : AddCommGroup (E →SWOT[σ] F) :=
inferInstanceAs <| AddCommGroup (E →SL[σ] F)
unseal ContinuousLinearMapWOT in
instance instModule [IsTopologicalAddGroup F] [ContinuousConstSMul 𝕜₂ F] :
Module 𝕜₂ (E →SWOT[σ] F) :=
inferInstanceAs <| Module 𝕜₂ (E →SL[σ] F)
variable [IsTopologicalAddGroup F] [ContinuousConstSMul 𝕜₂ F]
variable (σ E F) in
unseal ContinuousLinearMapWOT in
/-- The linear equivalence that sends a continuous linear map to the type copy endowed with the
weak operator topology. -/
def _root_.ContinuousLinearMap.toWOT :
(E →SL[σ] F) ≃ₗ[𝕜₂] (E →SWOT[σ] F) :=
LinearEquiv.refl 𝕜₂ _
instance instFunLike : FunLike (E →SWOT[σ] F) E F where
coe f := ((ContinuousLinearMap.toWOT σ E F).symm f : E → F)
coe_injective' := by intro; simp
instance instContinuousLinearMapClass : ContinuousSemilinearMapClass (E →SWOT[σ] F) σ E F where
map_add f x y := by simp only [DFunLike.coe]; simp
map_smulₛₗ f r x := by simp only [DFunLike.coe]; simp
map_continuous f := ContinuousLinearMap.continuous ((ContinuousLinearMap.toWOT σ E F).symm f)
@[simp]
lemma _root_.ContinuousLinearMap.toWOT_apply {A : E →SL[σ] F} {x : E} :
((ContinuousLinearMap.toWOT σ E F) A) x = A x := rfl
unseal ContinuousLinearMapWOT in
lemma ext {A B : E →SWOT[σ] F} (h : ∀ x, A x = B x) : A = B := ContinuousLinearMap.ext h
unseal ContinuousLinearMapWOT in
lemma ext_iff {A B : E →SWOT[σ] F} : A = B ↔ ∀ x, A x = B x := ContinuousLinearMap.ext_iff
-- This `ext` lemma is set at a lower priority than the default of 1000, so that the
-- version with an inner product (`ContinuousLinearMapWOT.ext_inner`) takes precedence
-- in the case of Hilbert spaces.
@[ext 900]
lemma ext_dual [H : SeparatingDual 𝕜₂ F] {A B : E →SWOT[σ] F}
(h : ∀ x (y : F⋆), y (A x) = y (B x)) : A = B := by
simp_rw [ext_iff, ← (separatingDual_iff_injective.mp H).eq_iff, LinearMap.ext_iff]
exact h
@[simp] lemma zero_apply (x : E) : (0 : E →SWOT[σ] F) x = 0 := by simp only [DFunLike.coe]; rfl
unseal ContinuousLinearMapWOT in
@[simp] lemma add_apply {f g : E →SWOT[σ] F} (x : E) : (f + g) x = f x + g x := by
simp only [DFunLike.coe]; rfl
unseal ContinuousLinearMapWOT in
@[simp] lemma sub_apply {f g : E →SWOT[σ] F} (x : E) : (f - g) x = f x - g x := by
simp only [DFunLike.coe]; rfl
unseal ContinuousLinearMapWOT in
@[simp] lemma neg_apply {f : E →SWOT[σ] F} (x : E) : (-f) x = -(f x) := by
simp only [DFunLike.coe]; rfl
unseal ContinuousLinearMapWOT in
@[simp] lemma smul_apply {f : E →SWOT[σ] F} (c : 𝕜₂) (x : E) : (c • f) x = c • (f x) := by
simp only [DFunLike.coe]; rfl
end Basic
/-!
### The topology of `E →WOT[𝕜] F`
The section endows `E →WOT[𝕜] F` with the weak operator topology and shows the basic properties
of this topology. In particular, we show that it is a topological vector space.
-/
section Topology
variable [IsTopologicalAddGroup F] [ContinuousConstSMul 𝕜₂ F]
variable (σ E F) in
/-- The function that induces the topology on `E →WOT[𝕜] F`, namely the function that takes
an `A` and maps it to `fun ⟨x, y⟩ => y (A x)` in `E × F⋆ → 𝕜`, bundled as a linear map to make
it easier to prove that it is a TVS. -/
def inducingFn : (E →SWOT[σ] F) →ₗ[𝕜₂] (E × F⋆ → 𝕜₂) where
toFun := fun A ⟨x, y⟩ => y (A x)
map_add' := fun x y => by ext; simp
map_smul' := fun x y => by ext; simp
@[simp]
lemma inducingFn_apply {f : E →SWOT[σ] F} {x : E} {y : F⋆} :
inducingFn σ E F f (x, y) = y (f x) :=
rfl
/-- The weak operator topology is the coarsest topology such that `fun A => y (A x)` is
continuous for all `x, y`. -/
instance instTopologicalSpace : TopologicalSpace (E →SWOT[σ] F) :=
.induced (inducingFn _ _ _) Pi.topologicalSpace
@[fun_prop]
lemma continuous_inducingFn : Continuous (inducingFn σ E F) :=
continuous_induced_dom
lemma continuous_dual_apply (x : E) (y : F⋆) : Continuous fun (A : E →SWOT[σ] F) => y (A x) := by
refine (continuous_pi_iff.mp continuous_inducingFn) ⟨x, y⟩
@[fun_prop]
lemma continuous_of_dual_apply_continuous {α : Type*} [TopologicalSpace α] {g : α → E →SWOT[σ] F}
(h : ∀ x (y : F⋆), Continuous fun a => y (g a x)) : Continuous g :=
continuous_induced_rng.2 (continuous_pi_iff.mpr fun p => h p.1 p.2)
lemma isInducing_inducingFn : IsInducing (inducingFn σ E F) := ⟨rfl⟩
lemma isEmbedding_inducingFn [SeparatingDual 𝕜₂ F] : IsEmbedding (inducingFn σ E F) := by
refine Function.Injective.isEmbedding_induced fun A B hAB => ?_
rw [ContinuousLinearMapWOT.ext_dual_iff]
simpa [funext_iff] using hAB
open Filter in
/-- The defining property of the weak operator topology: a function `f` tends to
`A : E →WOT[𝕜] F` along filter `l` iff `y (f a x)` tends to `y (A x)` along the same filter. -/
lemma tendsto_iff_forall_dual_apply_tendsto {α : Type*} {l : Filter α} {f : α → E →SWOT[σ] F}
{A : E →SWOT[σ] F} :
Tendsto f l (𝓝 A) ↔ ∀ x (y : F⋆), Tendsto (fun a => y (f a x)) l (𝓝 (y (A x))) := by
simp [isInducing_inducingFn.tendsto_nhds_iff, tendsto_pi_nhds]
lemma le_nhds_iff_forall_dual_apply_le_nhds {l : Filter (E →SWOT[σ] F)} {A : E →SWOT[σ] F} :
l ≤ 𝓝 A ↔ ∀ x (y : F⋆), l.map (fun T => y (T x)) ≤ 𝓝 (y (A x)) :=
tendsto_iff_forall_dual_apply_tendsto (f := id)
instance instT3Space [SeparatingDual 𝕜₂ F] : T3Space (E →SWOT[σ] F) :=
isEmbedding_inducingFn.t3Space
instance instContinuousAdd : ContinuousAdd (E →SWOT[σ] F) := .induced (inducingFn σ E F)
instance instContinuousNeg : ContinuousNeg (E →SWOT[σ] F) := .induced (inducingFn σ E F)
instance instContinuousSMul : ContinuousSMul 𝕜₂ (E →SWOT[σ] F) := .induced (inducingFn σ E F)
#adaptation_note /-- 2025-03-29 https://github.com/leanprover/lean4/issues/7717 Needed to add this instance explicitly to avoid a
limitation with parent instance inference. TODO(kmill): fix this. -/
instance instIsTopologicalAddGroup : IsTopologicalAddGroup (E →SWOT[σ] F) where
toContinuousAdd := inferInstance
instance instUniformSpace : UniformSpace (E →SWOT[σ] F) := .comap (inducingFn σ E F) inferInstance
instance instIsUniformAddGroup : IsUniformAddGroup (E →SWOT[σ] F) := .comap (inducingFn σ E F)
end Topology
/-! ### The WOT is induced by a family of seminorms -/
section Seminorms
variable [IsTopologicalAddGroup F] [ContinuousConstSMul 𝕜₂ F]
/-- The family of seminorms that induce the weak operator topology, namely `‖y (A x)‖` for
all `x` and `y`. -/
def seminorm (x : E) (y : F⋆) : Seminorm 𝕜₂ (E →SWOT[σ] F) where
toFun A := ‖y (A x)‖
map_zero' := by simp
add_le' A B := by simpa using norm_add_le _ _
neg' A := by simp
smul' r A := by simp
variable (σ E F) in
/-- The family of seminorms that induce the weak operator topology, namely `‖y (A x)‖` for
all `x` and `y`. -/
def seminormFamily : SeminormFamily 𝕜₂ (E →SWOT[σ] F) (E × F⋆) :=
fun ⟨x, y⟩ => seminorm x y
lemma withSeminorms : WithSeminorms (seminormFamily σ E F) :=
let e : E × F⋆ ≃ (Σ _ : E × F⋆, Fin 1) := .symm <| .sigmaUnique _ _
isInducing_inducingFn.withSeminorms <| withSeminorms_pi (fun _ ↦ norm_withSeminorms 𝕜₂ 𝕜₂)
|>.congr_equiv e
lemma hasBasis_seminorms : (𝓝 (0 : E →SWOT[σ] F)).HasBasis (seminormFamily σ E F).basisSets id :=
withSeminorms.hasBasis
instance instLocallyConvexSpace [NormedSpace ℝ 𝕜₂] [Module ℝ (E →SWOT[σ] F)]
[IsScalarTower ℝ 𝕜₂ (E →SWOT[σ] F)] :
LocallyConvexSpace ℝ (E →SWOT[σ] F) :=
withSeminorms.toLocallyConvexSpace
end Seminorms
section toWOT_continuous
variable [IsTopologicalAddGroup F] [ContinuousConstSMul 𝕜₂ F] [ContinuousSMul 𝕜₁ E]
/-- The weak operator topology is coarser than the bounded convergence topology, i.e. the inclusion
map is continuous. -/
@[continuity, fun_prop]
lemma ContinuousLinearMap.continuous_toWOT :
Continuous (ContinuousLinearMap.toWOT σ E F) :=
ContinuousLinearMapWOT.continuous_of_dual_apply_continuous fun x y ↦
y.cont.comp <| continuous_eval_const x
/-- The inclusion map from `E →[𝕜] F` to `E →WOT[𝕜] F`, bundled as a continuous linear map. -/
def ContinuousLinearMap.toWOTCLM : (E →SL[σ] F) →L[𝕜₂] (E →SWOT[σ] F) :=
⟨LinearEquiv.toLinearMap (ContinuousLinearMap.toWOT σ E F), ContinuousLinearMap.continuous_toWOT⟩
end toWOT_continuous
end ContinuousLinearMapWOT |
.lake/packages/mathlib/Mathlib/Analysis/LocallyConvex/Barrelled.lean | import Mathlib.Analysis.LocallyConvex.WithSeminorms
import Mathlib.Topology.Semicontinuous
import Mathlib.Topology.Baire.Lemmas
/-!
# Barrelled spaces and the Banach-Steinhaus theorem / Uniform Boundedness Principle
This file defines barrelled spaces over a `NontriviallyNormedField`, and proves the
Banach-Steinhaus theorem for maps from a barrelled space to a space equipped with a family
of seminorms generating the topology (i.e. `WithSeminorms q` for some family of seminorms `q`).
The more standard Banach-Steinhaus theorem for normed spaces is then deduced from that in
`Mathlib/Analysis/Normed/Operator/BanachSteinhaus.lean`.
## Main definitions
* `BarrelledSpace`: a topological vector space `E` is said to be **barrelled** if all lower
semicontinuous seminorms on `E` are actually continuous. See the implementation details below for
more comments on this definition.
* `WithSeminorms.continuousLinearMapOfTendsto`: fix `E` a barrelled space and `F` a TVS
satisfying `WithSeminorms q` for some `q`. Given a sequence of continuous linear maps from
`E` to `F` that converges pointwise to a function `f : E → F`, this bundles `f` as a
continuous linear map using the Banach-Steinhaus theorem.
## Main theorems
* `BaireSpace.instBarrelledSpace`: any TVS that is also a `BaireSpace` is barrelled. In
particular, this applies to Banach spaces and Fréchet spaces.
* `WithSeminorms.banach_steinhaus`: the **Banach-Steinhaus** theorem, also called
**Uniform Boundedness Principle**. Fix `E` a barrelled space and `F` a TVS satisfying
`WithSeminorms q` for some `q`. Any family `𝓕 : ι → E →L[𝕜] F` of continuous linear maps
that is pointwise bounded is (uniformly) equicontinuous. Here, pointwise bounded means that
for all `k` and `x`, the family of real numbers `i ↦ q k (𝓕 i x)` is bounded above,
which is equivalent to requiring that `𝓕` is pointwise Von Neumann bounded
(see `WithSeminorms.image_isVonNBounded_iff_seminorm_bounded`).
## Implementation details
Barrelled spaces are defined in Bourbaki as locally convex spaces where barrels (aka closed
balanced absorbing convex sets) are neighborhoods of zero. One can then show that barrels in a
locally convex space are exactly closed unit balls of lower semicontinuous seminorms, hence that a
locally convex space is barrelled iff any lower semicontinuous seminorm is continuous.
The problem with this definition is the local convexity, which is essential to prove that the
barrel definition is equivalent to the seminorm definition, because we can essentially only
use `LocallyConvexSpace` over `ℝ` or `ℂ` (which is indeed the setup in which Bourbaki does most
of the theory). Since we can easily prove the normed space version over any
`NontriviallyNormedField`, this wouldn't make for a very satisfying "generalization".
Fortunately, it turns out that using the seminorm definition directly solves all problems,
since it is exactly what we need for the proof. One could then expect to need the barrel
characterization to prove that Baire TVS are barrelled, but the proof is actually easier to do
with the seminorm characterization!
## TODO
* define barrels and prove that a locally convex space is barrelled iff all barrels are
neighborhoods of zero.
## References
* [N. Bourbaki, *Topological Vector Spaces*][bourbaki1987]
## Tags
banach-steinhaus, uniform boundedness, equicontinuity
-/
open Filter Topology Set ContinuousLinearMap
section defs
/-- A topological vector space `E` is said to be **barrelled** if all lower semicontinuous
seminorms on `E` are actually continuous. This is not the usual definition for TVS over `ℝ` or `ℂ`,
but this has the big advantage of working and giving sensible results over *any*
`NontriviallyNormedField`. In particular, the Banach-Steinhaus theorem holds for maps between such
a space and any space whose topology is generated by a family of seminorms. -/
class BarrelledSpace (𝕜 E : Type*) [SeminormedRing 𝕜] [AddGroup E] [SMul 𝕜 E]
[TopologicalSpace E] : Prop where
/-- In a barrelled space, all lower semicontinuous seminorms on `E` are actually continuous. -/
continuous_of_lowerSemicontinuous : ∀ p : Seminorm 𝕜 E, LowerSemicontinuous p → Continuous p
theorem Seminorm.continuous_of_lowerSemicontinuous {𝕜 E : Type*} [AddGroup E] [SMul 𝕜 E]
[SeminormedRing 𝕜] [TopologicalSpace E] [BarrelledSpace 𝕜 E] (p : Seminorm 𝕜 E)
(hp : LowerSemicontinuous p) : Continuous p :=
BarrelledSpace.continuous_of_lowerSemicontinuous p hp
theorem Seminorm.continuous_iSup
{ι : Sort*} {𝕜 E : Type*} [NormedField 𝕜] [AddCommGroup E] [Module 𝕜 E]
[TopologicalSpace E] [BarrelledSpace 𝕜 E] (p : ι → Seminorm 𝕜 E)
(hp : ∀ i, Continuous (p i)) (bdd : BddAbove (range p)) :
Continuous (⨆ i, p i) := by
rw [← Seminorm.coe_iSup_eq bdd]
refine Seminorm.continuous_of_lowerSemicontinuous _ ?_
rw [Seminorm.coe_iSup_eq bdd]
rw [Seminorm.bddAbove_range_iff] at bdd
convert lowerSemicontinuous_ciSup (f := fun i x ↦ p i x) bdd (fun i ↦ (hp i).lowerSemicontinuous)
exact iSup_apply
end defs
section TVS_anyField
variable {α ι κ 𝕜₁ 𝕜₂ E F : Type*} [NontriviallyNormedField 𝕜₁]
[NontriviallyNormedField 𝕜₂] {σ₁₂ : 𝕜₁ →+* 𝕜₂} [RingHomIsometric σ₁₂]
[AddCommGroup E] [AddCommGroup F] [Module 𝕜₁ E] [Module 𝕜₂ F]
/-- Any TVS over a `NontriviallyNormedField` that is also a Baire space is barrelled. In
particular, this applies to Banach spaces and Fréchet spaces. -/
instance BaireSpace.instBarrelledSpace [TopologicalSpace E] [IsTopologicalAddGroup E]
[ContinuousConstSMul 𝕜₁ E] [BaireSpace E] :
BarrelledSpace 𝕜₁ E where
continuous_of_lowerSemicontinuous := by
-- Let `p` be a lower-semicontinuous seminorm on `E`.
intro p hp
-- Consider the family of all `p`-closed-balls with integer radius.
-- By lower semicontinuity, each of these closed balls is indeed closed...
have h₁ : ∀ n : ℕ, IsClosed (p.closedBall (0 : E) n) := fun n ↦ by
simpa [p.closedBall_zero_eq] using hp.isClosed_preimage n
-- ... and clearly they cover the whole space.
have h₂ : (⋃ n : ℕ, p.closedBall (0 : E) n) = univ :=
eq_univ_of_forall fun x ↦ mem_iUnion.mpr (exists_nat_ge <| p (x - 0))
-- Hence, one of them has nonempty interior. Let `n : ℕ` be its radius, and fix `x` an
-- interior point.
rcases nonempty_interior_of_iUnion_of_closed h₁ h₂ with ⟨n, ⟨x, hxn⟩⟩
-- To show that `p` is continuous, we will show that the `p`-closed-ball of
-- radius `2*n` is a neighborhood of zero.
refine Seminorm.continuous' (r := n + n) ?_
rw [p.closedBall_zero_eq] at hxn ⊢
have hxn' : p x ≤ n := by convert interior_subset hxn
-- By definition, we have `p x' ≤ n` for `x'` sufficiently close to `x`.
-- In other words, `p (x + y) ≤ n` for `y` sufficiently close to `0`.
rw [mem_interior_iff_mem_nhds, ← map_add_left_nhds_zero] at hxn
-- Hence, for `y` sufficiently close to `0`, we have
-- `p y = p (x + y - x) ≤ p (x + y) + p x ≤ 2*n`
filter_upwards [hxn] with y hy
calc p y = p (x + y - x) := by rw [add_sub_cancel_left]
_ ≤ p (x + y) + p x := map_sub_le_add _ _ _
_ ≤ n + n := add_le_add hy hxn'
namespace WithSeminorms
variable [UniformSpace E] [UniformSpace F] [IsUniformAddGroup E] [IsUniformAddGroup F]
[ContinuousSMul 𝕜₁ E] [BarrelledSpace 𝕜₁ E] {𝓕 : ι → E →SL[σ₁₂] F}
{q : SeminormFamily 𝕜₂ F κ} (hq : WithSeminorms q)
include hq
/-- The **Banach-Steinhaus** theorem, or **Uniform Boundedness Principle**, for maps from a
barrelled space to any space whose topology is generated by a family of seminorms. Use
`WithSeminorms.equicontinuous_TFAE` and `Seminorm.bound_of_continuous` to get explicit bounds on
the seminorms from equicontinuity. -/
protected theorem banach_steinhaus (H : ∀ k x, BddAbove (range fun i ↦ q k (𝓕 i x))) :
UniformEquicontinuous ((↑) ∘ 𝓕) := by
-- We just have to prove that `⊔ i, (q k) ∘ (𝓕 i)` is a (well-defined) continuous seminorm
-- for all `k`.
refine (hq.uniformEquicontinuous_iff_bddAbove_and_continuous_iSup (toLinearMap ∘ 𝓕)).mpr ?_
intro k
-- By assumption the supremum `⊔ i, q k (𝓕 i x)` is well-defined for all `x`, hence the
-- supremum `⊔ i, (q k) ∘ (𝓕 i)` is well defined in the lattice of seminorms.
have : BddAbove (range fun i ↦ (q k).comp (𝓕 i).toLinearMap) := by
rw [Seminorm.bddAbove_range_iff]
exact H k
-- By definition of the lattice structure on seminorms, `⊔ i, (q k) ∘ (𝓕 i)` is the *pointwise*
-- supremum of the continuous seminorms `(q k) ∘ (𝓕 i)`. Since `E` is barrelled, this supremum
-- is continuous.
exact ⟨this, Seminorm.continuous_iSup _
(fun i ↦ (hq.continuous_seminorm k).comp (𝓕 i).continuous) this⟩
variable [ContinuousSMul 𝕜₂ F]
/-- Given a sequence of continuous linear maps which converges pointwise and for which the
domain is barrelled, the Banach-Steinhaus theorem is used to guarantee that the limit map
is a *continuous* linear map as well.
This actually works for any *countably generated* filter instead of `atTop : Filter ℕ`,
but the proof ultimately goes back to sequences. -/
protected def continuousLinearMapOfTendsto (hq : WithSeminorms q)
[T2Space F] {l : Filter α} [l.IsCountablyGenerated]
[l.NeBot] (g : α → E →SL[σ₁₂] F) {f : E → F} (h : Tendsto (fun n x ↦ g n x) l (𝓝 f)) :
E →SL[σ₁₂] F where
toLinearMap := linearMapOfTendsto _ _ h
cont := by
-- Since the filter `l` is countably generated and nontrivial, we can find a sequence
-- `u : ℕ → α` that tends to `l`. By considering `g ∘ u` instead of `g`, we can thus assume
-- that `α = ℕ` and `l = atTop`
rcases l.exists_seq_tendsto with ⟨u, hu⟩
-- We claim that the limit is continuous because it's a limit of an equicontinuous family.
-- By the Banach-Steinhaus theorem, this equicontinuity will follow from pointwise boundedness.
refine (h.comp hu).continuous_of_equicontinuous (hq.banach_steinhaus ?_).equicontinuous
-- For `k` and `x` fixed, we need to show that `(i : ℕ) ↦ q k (g i x)` is bounded.
intro k x
-- This follows from the fact that this sequences converges (to `q k (f x)`) by hypothesis and
-- continuity of `q k`.
rw [tendsto_pi_nhds] at h
exact (((hq.continuous_seminorm k).tendsto _).comp <| (h x).comp hu).bddAbove_range
end WithSeminorms
end TVS_anyField |
.lake/packages/mathlib/Mathlib/Analysis/LocallyConvex/BalancedCoreHull.lean | import Mathlib.Analysis.LocallyConvex.Basic
/-!
# Balanced Core and Balanced Hull
## Main definitions
* `balancedCore`: The largest balanced subset of a set `s`.
* `balancedHull`: The smallest balanced superset of a set `s`.
## Main statements
* `balancedCore_eq_iInter`: Characterization of the balanced core as an intersection over subsets.
* `nhds_basis_closed_balanced`: The closed balanced sets form a basis of the neighborhood filter.
## Implementation details
The balanced core and hull are implemented differently: for the core we take the obvious definition
of the union over all balanced sets that are contained in `s`, whereas for the hull, we take the
union over `r • s`, for `r` the scalars with `‖r‖ ≤ 1`. We show that `balancedHull` has the
defining properties of a hull in `Balanced.balancedHull_subset_of_subset` and `subset_balancedHull`.
For the core we need slightly stronger assumptions to obtain a characterization as an intersection,
this is `balancedCore_eq_iInter`.
## References
* [Bourbaki, *Topological Vector Spaces*][bourbaki1987]
## Tags
balanced
-/
open Set Pointwise Topology Filter
variable {𝕜 E ι : Type*}
section balancedHull
section SeminormedRing
variable [SeminormedRing 𝕜]
section SMul
variable (𝕜) [SMul 𝕜 E] {s t : Set E} {x : E}
/-- The largest balanced subset of `s`. -/
def balancedCore (s : Set E) :=
⋃₀ { t : Set E | Balanced 𝕜 t ∧ t ⊆ s }
/-- Helper definition to prove `balanced_core_eq_iInter` -/
def balancedCoreAux (s : Set E) :=
⋂ (r : 𝕜) (_ : 1 ≤ ‖r‖), r • s
/-- The smallest balanced superset of `s`. -/
def balancedHull (s : Set E) :=
⋃ (r : 𝕜) (_ : ‖r‖ ≤ 1), r • s
variable {𝕜}
theorem balancedCore_subset (s : Set E) : balancedCore 𝕜 s ⊆ s :=
sUnion_subset fun _ ht => ht.2
theorem balancedCore_empty : balancedCore 𝕜 (∅ : Set E) = ∅ :=
eq_empty_of_subset_empty (balancedCore_subset _)
theorem mem_balancedCore_iff : x ∈ balancedCore 𝕜 s ↔ ∃ t, Balanced 𝕜 t ∧ t ⊆ s ∧ x ∈ t := by
simp_rw [balancedCore, mem_sUnion, mem_setOf_eq, and_assoc]
theorem smul_balancedCore_subset (s : Set E) {a : 𝕜} (ha : ‖a‖ ≤ 1) :
a • balancedCore 𝕜 s ⊆ balancedCore 𝕜 s := by
rintro x ⟨y, hy, rfl⟩
rw [mem_balancedCore_iff] at hy
rcases hy with ⟨t, ht1, ht2, hy⟩
exact ⟨t, ⟨ht1, ht2⟩, ht1 a ha (smul_mem_smul_set hy)⟩
theorem balancedCore_balanced (s : Set E) : Balanced 𝕜 (balancedCore 𝕜 s) := fun _ =>
smul_balancedCore_subset s
/-- The balanced core of `t` is maximal in the sense that it contains any balanced subset
`s` of `t`. -/
theorem Balanced.subset_balancedCore_of_subset (hs : Balanced 𝕜 s) (h : s ⊆ t) :
s ⊆ balancedCore 𝕜 t :=
subset_sUnion_of_mem ⟨hs, h⟩
lemma Balanced.balancedCore_eq (h : Balanced 𝕜 s) : balancedCore 𝕜 s = s :=
le_antisymm (balancedCore_subset _) (h.subset_balancedCore_of_subset subset_rfl)
theorem mem_balancedCoreAux_iff : x ∈ balancedCoreAux 𝕜 s ↔ ∀ r : 𝕜, 1 ≤ ‖r‖ → x ∈ r • s :=
mem_iInter₂
theorem mem_balancedHull_iff : x ∈ balancedHull 𝕜 s ↔ ∃ r : 𝕜, ‖r‖ ≤ 1 ∧ x ∈ r • s := by
simp [balancedHull]
/-- The balanced hull of `s` is minimal in the sense that it is contained in any balanced superset
`t` of `s`. -/
theorem Balanced.balancedHull_subset_of_subset (ht : Balanced 𝕜 t) (h : s ⊆ t) :
balancedHull 𝕜 s ⊆ t := by
intro x hx
obtain ⟨r, hr, y, hy, rfl⟩ := mem_balancedHull_iff.1 hx
exact ht.smul_mem hr (h hy)
@[mono, gcongr]
theorem balancedHull_mono (hst : s ⊆ t) : balancedHull 𝕜 s ⊆ balancedHull 𝕜 t := by
intro x hx
rw [mem_balancedHull_iff] at *
obtain ⟨r, hr₁, hr₂⟩ := hx
use r
exact ⟨hr₁, smul_set_mono hst hr₂⟩
end SMul
section Module
variable [AddCommGroup E] [Module 𝕜 E] {s : Set E}
theorem balancedCore_zero_mem (hs : (0 : E) ∈ s) : (0 : E) ∈ balancedCore 𝕜 s :=
mem_balancedCore_iff.2 ⟨0, balanced_zero, zero_subset.2 hs, Set.zero_mem_zero⟩
theorem balancedCore_nonempty_iff : (balancedCore 𝕜 s).Nonempty ↔ (0 : E) ∈ s :=
⟨fun h => zero_subset.1 <| (zero_smul_set h).superset.trans <|
(balancedCore_balanced s (0 : 𝕜) <| norm_zero.trans_le zero_le_one).trans <|
balancedCore_subset _,
fun h => ⟨0, balancedCore_zero_mem h⟩⟩
lemma Balanced.zero_mem (hs : Balanced 𝕜 s) (hs_nonempty : s.Nonempty) : (0 : E) ∈ s := by
rw [← hs.balancedCore_eq] at hs_nonempty
exact balancedCore_nonempty_iff.mp hs_nonempty
variable (𝕜) in
theorem subset_balancedHull [NormOneClass 𝕜] {s : Set E} : s ⊆ balancedHull 𝕜 s := fun _ hx =>
mem_balancedHull_iff.2 ⟨1, norm_one.le, _, hx, one_smul _ _⟩
theorem balancedHull.balanced (s : Set E) : Balanced 𝕜 (balancedHull 𝕜 s) := by
intro a ha
simp_rw [balancedHull, smul_set_iUnion₂, subset_def, mem_iUnion₂]
rintro x ⟨r, hr, hx⟩
rw [← smul_assoc] at hx
exact ⟨a • r, (norm_mul_le _ _).trans (mul_le_one₀ ha (norm_nonneg r) hr), hx⟩
open Balanced in
theorem balancedHull_add_subset [NormOneClass 𝕜] {t : Set E} :
balancedHull 𝕜 (s + t) ⊆ balancedHull 𝕜 s + balancedHull 𝕜 t :=
balancedHull_subset_of_subset (add (balancedHull.balanced _) (balancedHull.balanced _))
(add_subset_add (subset_balancedHull _) (subset_balancedHull _))
end Module
end SeminormedRing
section NormedField
variable [NormedDivisionRing 𝕜] [AddCommGroup E] [Module 𝕜 E] {s t : Set E}
@[simp]
theorem balancedCoreAux_empty : balancedCoreAux 𝕜 (∅ : Set E) = ∅ := by
simp_rw [balancedCoreAux, iInter₂_eq_empty_iff, smul_set_empty]
exact fun _ => ⟨1, norm_one.ge, notMem_empty _⟩
theorem balancedCoreAux_subset (s : Set E) : balancedCoreAux 𝕜 s ⊆ s := fun x hx => by
simpa only [one_smul] using mem_balancedCoreAux_iff.1 hx 1 norm_one.ge
theorem balancedCoreAux_balanced (h0 : (0 : E) ∈ balancedCoreAux 𝕜 s) :
Balanced 𝕜 (balancedCoreAux 𝕜 s) := by
rintro a ha x ⟨y, hy, rfl⟩
obtain rfl | h := eq_or_ne a 0
· simp_rw [zero_smul, h0]
rw [mem_balancedCoreAux_iff] at hy ⊢
intro r hr
have h'' : 1 ≤ ‖a⁻¹ • r‖ := by
rw [norm_smul, norm_inv]
exact one_le_mul_of_one_le_of_one_le ((one_le_inv₀ (norm_pos_iff.mpr h)).2 ha) hr
have h' := hy (a⁻¹ • r) h''
rwa [smul_assoc, mem_inv_smul_set_iff₀ h] at h'
theorem balancedCoreAux_maximal (h : t ⊆ s) (ht : Balanced 𝕜 t) : t ⊆ balancedCoreAux 𝕜 s := by
refine fun x hx => mem_balancedCoreAux_iff.2 fun r hr => ?_
rw [mem_smul_set_iff_inv_smul_mem₀ (norm_pos_iff.mp <| zero_lt_one.trans_le hr)]
refine h (ht.smul_mem ?_ hx)
rw [norm_inv]
exact inv_le_one_of_one_le₀ hr
theorem balancedCore_subset_balancedCoreAux : balancedCore 𝕜 s ⊆ balancedCoreAux 𝕜 s :=
balancedCoreAux_maximal (balancedCore_subset s) (balancedCore_balanced s)
theorem balancedCore_eq_iInter (hs : (0 : E) ∈ s) :
balancedCore 𝕜 s = ⋂ (r : 𝕜) (_ : 1 ≤ ‖r‖), r • s := by
refine balancedCore_subset_balancedCoreAux.antisymm ?_
refine (balancedCoreAux_balanced ?_).subset_balancedCore_of_subset (balancedCoreAux_subset s)
exact balancedCore_subset_balancedCoreAux (balancedCore_zero_mem hs)
theorem subset_balancedCore (ht : (0 : E) ∈ t) (hst : ∀ a : 𝕜, ‖a‖ ≤ 1 → a • s ⊆ t) :
s ⊆ balancedCore 𝕜 t := by
rw [balancedCore_eq_iInter ht]
refine subset_iInter₂ fun a ha ↦ ?_
rw [subset_smul_set_iff₀ (norm_pos_iff.mp <| zero_lt_one.trans_le ha)]
apply hst
rw [norm_inv]
exact inv_le_one_of_one_le₀ ha
end NormedField
end balancedHull
/-! ### Topological properties -/
section Topology
variable [NormedDivisionRing 𝕜] [AddCommGroup E] [Module 𝕜 E] [TopologicalSpace E]
[ContinuousSMul 𝕜 E] {U : Set E}
protected theorem IsClosed.balancedCore (hU : IsClosed U) : IsClosed (balancedCore 𝕜 U) := by
by_cases h : (0 : E) ∈ U
· rw [balancedCore_eq_iInter h]
refine isClosed_iInter fun a => ?_
refine isClosed_iInter fun ha => ?_
have ha' := lt_of_lt_of_le zero_lt_one ha
rw [norm_pos_iff] at ha'
exact isClosedMap_smul_of_ne_zero ha' U hU
· have : balancedCore 𝕜 U = ∅ := by
contrapose! h
exact balancedCore_nonempty_iff.mp h
rw [this]
exact isClosed_empty
-- We don't have a `NontriviallyNormedDivisionRing`, so we use a `NeBot` assumption instead
variable [NeBot (𝓝[≠] (0 : 𝕜))]
theorem balancedCore_mem_nhds_zero (hU : U ∈ 𝓝 (0 : E)) : balancedCore 𝕜 U ∈ 𝓝 (0 : E) := by
-- Getting neighborhoods of the origin for `0 : 𝕜` and `0 : E`
obtain ⟨r, V, hr, hV, hrVU⟩ : ∃ (r : ℝ) (V : Set E),
0 < r ∧ V ∈ 𝓝 (0 : E) ∧ ∀ (c : 𝕜) (y : E), ‖c‖ < r → y ∈ V → c • y ∈ U := by
have h : Filter.Tendsto (fun x : 𝕜 × E => x.fst • x.snd) (𝓝 (0, 0)) (𝓝 0) :=
continuous_smul.tendsto' (0, 0) _ (smul_zero _)
simpa only [← Prod.exists', ← Prod.forall', ← and_imp, ← and_assoc, exists_prop] using
h.basis_left (NormedAddCommGroup.nhds_zero_basis_norm_lt.prod_nhds (𝓝 _).basis_sets) U hU
obtain ⟨y, hyr, hy₀⟩ : ∃ y : 𝕜, ‖y‖ < r ∧ y ≠ 0 :=
Filter.nonempty_of_mem <|
(nhdsWithin_hasBasis NormedAddCommGroup.nhds_zero_basis_norm_lt {0}ᶜ).mem_of_mem hr
have : y • V ∈ 𝓝 (0 : E) := (set_smul_mem_nhds_zero_iff hy₀).mpr hV
-- It remains to show that `y • V ⊆ balancedCore 𝕜 U`
refine Filter.mem_of_superset this (subset_balancedCore (mem_of_mem_nhds hU) fun a ha => ?_)
rw [smul_smul]
rintro _ ⟨z, hz, rfl⟩
refine hrVU _ _ ?_ hz
rw [norm_mul, ← one_mul r]
exact mul_lt_mul' ha hyr (norm_nonneg y) one_pos
variable (𝕜 E)
theorem nhds_basis_balanced :
(𝓝 (0 : E)).HasBasis (fun s : Set E => s ∈ 𝓝 (0 : E) ∧ Balanced 𝕜 s) id :=
Filter.hasBasis_self.mpr fun s hs =>
⟨balancedCore 𝕜 s, balancedCore_mem_nhds_zero hs, balancedCore_balanced s,
balancedCore_subset s⟩
theorem nhds_basis_closed_balanced [RegularSpace E] :
(𝓝 (0 : E)).HasBasis (fun s : Set E => s ∈ 𝓝 (0 : E) ∧ IsClosed s ∧ Balanced 𝕜 s) id := by
refine
(closed_nhds_basis 0).to_hasBasis (fun s hs => ?_) fun s hs => ⟨s, ⟨hs.1, hs.2.1⟩, rfl.subset⟩
refine ⟨balancedCore 𝕜 s, ⟨balancedCore_mem_nhds_zero hs.1, ?_⟩, balancedCore_subset s⟩
exact ⟨hs.2.balancedCore, balancedCore_balanced s⟩
end Topology |
.lake/packages/mathlib/Mathlib/Analysis/LocallyConvex/Basic.lean | import Mathlib.Analysis.Convex.Hull
import Mathlib.Analysis.Normed.Module.Basic
import Mathlib.Topology.Bornology.Absorbs
/-!
# Local convexity
This file defines absorbent and balanced sets.
An absorbent set is one that "surrounds" the origin. The idea is made precise by requiring that any
point belongs to all large enough scalings of the set. This is the vector world analog of a
topological neighborhood of the origin.
A balanced set is one that is everywhere around the origin. This means that `a • s ⊆ s` for all `a`
of norm less than `1`.
## Main declarations
For a module over a normed ring:
* `Absorbs`: A set `s` absorbs a set `t` if all large scalings of `s` contain `t`.
* `Absorbent`: A set `s` is absorbent if every point eventually belongs to all large scalings of
`s`.
* `Balanced`: A set `s` is balanced if `a • s ⊆ s` for all `a` of norm less than `1`.
## Main Results
* `Absorbent.submodule_eq_top` shows that when the base field is nontrivially normed, an absorbent
submodule is actually the whole space. As an application, we show in
`Absorbent.subset_image_iff_surjective` that a linear function is surjective if and only if its
image contains an absorbent set.
## References
* [H. H. Schaefer, *Topological Vector Spaces*][schaefer1966]
## Tags
absorbent, balanced, locally convex, LCTVS
-/
open Set
open Pointwise Topology
variable {𝕜 𝕝 E F : Type*} {ι : Sort*} {κ : ι → Sort*}
section SeminormedRing
variable [SeminormedRing 𝕜]
section SMul
variable [SMul 𝕜 E] {s A B : Set E}
variable (𝕜) in
/-- A set `A` is balanced if `a • A` is contained in `A` whenever `a` has norm at most `1`. -/
def Balanced (A : Set E) :=
∀ a : 𝕜, ‖a‖ ≤ 1 → a • A ⊆ A
lemma absorbs_iff_norm : Absorbs 𝕜 A B ↔ ∃ r, ∀ c : 𝕜, r ≤ ‖c‖ → B ⊆ c • A :=
Filter.atTop_basis.cobounded_of_norm.eventually_iff.trans <| by simp only [true_and]; rfl
alias ⟨_, Absorbs.of_norm⟩ := absorbs_iff_norm
lemma Absorbs.exists_pos (h : Absorbs 𝕜 A B) : ∃ r > 0, ∀ c : 𝕜, r ≤ ‖c‖ → B ⊆ c • A :=
let ⟨r, hr₁, hr⟩ := (Filter.atTop_basis' 1).cobounded_of_norm.eventually_iff.1 h
⟨r, one_pos.trans_le hr₁, hr⟩
theorem balanced_iff_smul_mem : Balanced 𝕜 s ↔ ∀ ⦃a : 𝕜⦄, ‖a‖ ≤ 1 → ∀ ⦃x : E⦄, x ∈ s → a • x ∈ s :=
forall₂_congr fun _a _ha => smul_set_subset_iff
alias ⟨Balanced.smul_mem, _⟩ := balanced_iff_smul_mem
theorem balanced_iff_closedBall_smul : Balanced 𝕜 s ↔ Metric.closedBall (0 : 𝕜) 1 • s ⊆ s := by
simp [balanced_iff_smul_mem, smul_subset_iff]
@[simp]
theorem balanced_empty : Balanced 𝕜 (∅ : Set E) := fun _ _ => by rw [smul_set_empty]
@[simp]
theorem balanced_univ : Balanced 𝕜 (univ : Set E) := fun _a _ha => subset_univ _
theorem Balanced.union (hA : Balanced 𝕜 A) (hB : Balanced 𝕜 B) : Balanced 𝕜 (A ∪ B) := fun _a ha =>
smul_set_union.subset.trans <| union_subset_union (hA _ ha) <| hB _ ha
theorem Balanced.inter (hA : Balanced 𝕜 A) (hB : Balanced 𝕜 B) : Balanced 𝕜 (A ∩ B) := fun _a ha =>
smul_set_inter_subset.trans <| inter_subset_inter (hA _ ha) <| hB _ ha
theorem balanced_iUnion {f : ι → Set E} (h : ∀ i, Balanced 𝕜 (f i)) : Balanced 𝕜 (⋃ i, f i) :=
fun _a ha => (smul_set_iUnion _ _).subset.trans <| iUnion_mono fun _ => h _ _ ha
theorem balanced_iUnion₂ {f : ∀ i, κ i → Set E} (h : ∀ i j, Balanced 𝕜 (f i j)) :
Balanced 𝕜 (⋃ (i) (j), f i j) :=
balanced_iUnion fun _ => balanced_iUnion <| h _
theorem Balanced.sInter {S : Set (Set E)} (h : ∀ s ∈ S, Balanced 𝕜 s) : Balanced 𝕜 (⋂₀ S) :=
fun _ _ => (smul_set_sInter_subset ..).trans (fun _ _ => by aesop)
theorem balanced_iInter {f : ι → Set E} (h : ∀ i, Balanced 𝕜 (f i)) : Balanced 𝕜 (⋂ i, f i) :=
fun _a ha => (smul_set_iInter_subset _ _).trans <| iInter_mono fun _ => h _ _ ha
theorem balanced_iInter₂ {f : ∀ i, κ i → Set E} (h : ∀ i j, Balanced 𝕜 (f i j)) :
Balanced 𝕜 (⋂ (i) (j), f i j) :=
balanced_iInter fun _ => balanced_iInter <| h _
theorem Balanced.mulActionHom_preimage [SMul 𝕜 F] {s : Set F} (hs : Balanced 𝕜 s)
(f : E →[𝕜] F) : Balanced 𝕜 (f ⁻¹' s) := fun a ha x ⟨y,⟨hy₁,hy₂⟩⟩ => by
rw [mem_preimage, ← hy₂, map_smul]
exact hs a ha (smul_mem_smul_set hy₁)
variable [SMul 𝕝 E] [SMulCommClass 𝕜 𝕝 E]
theorem Balanced.smul (a : 𝕝) (hs : Balanced 𝕜 s) : Balanced 𝕜 (a • s) := fun _b hb =>
(smul_comm _ _ _).subset.trans <| smul_set_mono <| hs _ hb
end SMul
section Module
variable [AddCommGroup E] [Module 𝕜 E] {s t : Set E}
theorem Balanced.neg : Balanced 𝕜 s → Balanced 𝕜 (-s) :=
forall₂_imp fun _ _ h => (smul_set_neg _ _).subset.trans <| neg_subset_neg.2 h
@[simp]
theorem balanced_neg : Balanced 𝕜 (-s) ↔ Balanced 𝕜 s :=
⟨fun h ↦ neg_neg s ▸ h.neg, fun h ↦ h.neg⟩
theorem Balanced.neg_mem_iff [NormOneClass 𝕜] (h : Balanced 𝕜 s) {x : E} : -x ∈ s ↔ x ∈ s :=
⟨fun hx ↦ by simpa using h.smul_mem (a := -1) (by simp) hx,
fun hx ↦ by simpa using h.smul_mem (a := -1) (by simp) hx⟩
theorem Balanced.neg_eq [NormOneClass 𝕜] (h : Balanced 𝕜 s) : -s = s :=
Set.ext fun _ ↦ h.neg_mem_iff
theorem Balanced.add (hs : Balanced 𝕜 s) (ht : Balanced 𝕜 t) : Balanced 𝕜 (s + t) := fun _a ha =>
(smul_add _ _ _).subset.trans <| add_subset_add (hs _ ha) <| ht _ ha
theorem Balanced.sub (hs : Balanced 𝕜 s) (ht : Balanced 𝕜 t) : Balanced 𝕜 (s - t) := by
simp_rw [sub_eq_add_neg]
exact hs.add ht.neg
theorem balanced_zero : Balanced 𝕜 (0 : Set E) := fun _a _ha => (smul_zero _).subset
end Module
end SeminormedRing
section NormedDivisionRing
variable [NormedDivisionRing 𝕜] [AddCommGroup E] [Module 𝕜 E] {s t : Set E}
theorem absorbs_iff_eventually_nhdsNE_zero :
Absorbs 𝕜 s t ↔ ∀ᶠ c : 𝕜 in 𝓝[≠] 0, MapsTo (c • ·) t s := by
rw [absorbs_iff_eventually_cobounded_mapsTo, ← Filter.inv_cobounded₀]; rfl
alias ⟨Absorbs.eventually_nhdsNE_zero, _⟩ := absorbs_iff_eventually_nhdsNE_zero
theorem absorbent_iff_eventually_nhdsNE_zero :
Absorbent 𝕜 s ↔ ∀ x : E, ∀ᶠ c : 𝕜 in 𝓝[≠] 0, c • x ∈ s :=
forall_congr' fun x ↦ by simp only [absorbs_iff_eventually_nhdsNE_zero, mapsTo_singleton]
alias ⟨Absorbent.eventually_nhdsNE_zero, _⟩ := absorbent_iff_eventually_nhdsNE_zero
theorem absorbs_iff_eventually_nhds_zero (h₀ : 0 ∈ s) :
Absorbs 𝕜 s t ↔ ∀ᶠ c : 𝕜 in 𝓝 0, MapsTo (c • ·) t s := by
rw [← nhdsNE_sup_pure, Filter.eventually_sup, Filter.eventually_pure,
← absorbs_iff_eventually_nhdsNE_zero, and_iff_left]
intro x _
simpa only [zero_smul]
theorem Absorbs.eventually_nhds_zero (h : Absorbs 𝕜 s t) (h₀ : 0 ∈ s) :
∀ᶠ c : 𝕜 in 𝓝 0, MapsTo (c • ·) t s :=
(absorbs_iff_eventually_nhds_zero h₀).1 h
variable [NormedRing 𝕝] [Module 𝕜 𝕝] [NormSMulClass 𝕜 𝕝] [SMulWithZero 𝕝 E] [IsScalarTower 𝕜 𝕝 E]
{a b : 𝕜} {x : E}
/-- Scalar multiplication (by possibly different types) of a balanced set is monotone. -/
theorem Balanced.smul_mono (hs : Balanced 𝕝 s) {a : 𝕝} (h : ‖a‖ ≤ ‖b‖) : a • s ⊆ b • s := by
obtain rfl | hb := eq_or_ne b 0
· rw [norm_zero, norm_le_zero_iff] at h
simp only [h, ← image_smul, zero_smul, Subset.rfl]
· calc
a • s = b • (b⁻¹ • a) • s := by rw [smul_assoc, smul_inv_smul₀ hb]
_ ⊆ b • s := smul_set_mono <| hs _ <| by
rw [norm_smul, norm_inv, ← div_eq_inv_mul]
exact div_le_one_of_le₀ h (norm_nonneg _)
theorem Balanced.smul_mem_mono [SMulCommClass 𝕝 𝕜 E] (hs : Balanced 𝕝 s) {b : 𝕝}
(ha : a • x ∈ s) (hba : ‖b‖ ≤ ‖a‖) : b • x ∈ s := by
rcases eq_or_ne a 0 with rfl | ha₀
· simp_all
· calc
(a⁻¹ • b) • a • x ∈ s := by
refine hs.smul_mem ?_ ha
rw [norm_smul, norm_inv, ← div_eq_inv_mul]
exact div_le_one_of_le₀ hba (norm_nonneg _)
(a⁻¹ • b) • a • x = b • x := by rw [smul_comm, smul_assoc, smul_inv_smul₀ ha₀]
theorem Balanced.subset_smul (hs : Balanced 𝕜 s) (ha : 1 ≤ ‖a‖) : s ⊆ a • s := by
rw [← @norm_one 𝕜] at ha; simpa using hs.smul_mono ha
theorem Balanced.smul_congr (hs : Balanced 𝕜 s) (h : ‖a‖ = ‖b‖) : a • s = b • s :=
(hs.smul_mono h.le).antisymm (hs.smul_mono h.ge)
theorem Balanced.smul_eq (hs : Balanced 𝕜 s) (ha : ‖a‖ = 1) : a • s = s :=
(hs _ ha.le).antisymm <| hs.subset_smul ha.ge
/-- A balanced set absorbs itself. -/
theorem Balanced.absorbs_self (hs : Balanced 𝕜 s) : Absorbs 𝕜 s s :=
.of_norm ⟨1, fun _ => hs.subset_smul⟩
end NormedDivisionRing
section NormedField
variable [NormedField 𝕜] [AddCommGroup E] [Module 𝕜 E] {s A : Set E} {x : E} {a b : 𝕜}
theorem Balanced.smul_mem_iff (hs : Balanced 𝕜 s) (h : ‖a‖ = ‖b‖) : a • x ∈ s ↔ b • x ∈ s :=
⟨(hs.smul_mem_mono · h.ge), (hs.smul_mem_mono · h.le)⟩
variable [TopologicalSpace E] [ContinuousSMul 𝕜 E]
/-- Every neighbourhood of the origin is absorbent. -/
theorem absorbent_nhds_zero (hA : A ∈ 𝓝 (0 : E)) : Absorbent 𝕜 A :=
absorbent_iff_inv_smul.2 fun x ↦ Filter.tendsto_inv₀_cobounded.smul tendsto_const_nhds <| by
rwa [zero_smul]
/-- The union of `{0}` with the interior of a balanced set is balanced. -/
theorem Balanced.zero_insert_interior (hA : Balanced 𝕜 A) :
Balanced 𝕜 (insert 0 (interior A)) := by
intro a ha
obtain rfl | h := eq_or_ne a 0
· rw [zero_smul_set]
exacts [subset_union_left, ⟨0, Or.inl rfl⟩]
· rw [← image_smul, image_insert_eq, smul_zero]
apply insert_subset_insert
exact ((isOpenMap_smul₀ h).mapsTo_interior <| hA.smul_mem ha).image_subset
/-- The interior of a balanced set is balanced if it contains the origin. -/
protected theorem Balanced.interior (hA : Balanced 𝕜 A) (h : (0 : E) ∈ interior A) :
Balanced 𝕜 (interior A) := by
rw [← insert_eq_self.2 h]
exact hA.zero_insert_interior
protected theorem Balanced.closure (hA : Balanced 𝕜 A) : Balanced 𝕜 (closure A) := fun _a ha =>
(image_closure_subset_closure_image <| continuous_const_smul _).trans <|
closure_mono <| hA _ ha
end NormedField
section NontriviallyNormedField
variable [NontriviallyNormedField 𝕜] [AddCommGroup E] [Module 𝕜 E] {s : Set E}
variable [PartialOrder 𝕜] in
protected theorem Balanced.convexHull (hs : Balanced 𝕜 s) : Balanced 𝕜 (convexHull 𝕜 s) := by
suffices Convex 𝕜 { x | ∀ a : 𝕜, ‖a‖ ≤ 1 → a • x ∈ convexHull 𝕜 s } by
rw [balanced_iff_smul_mem] at hs ⊢
refine fun a ha x hx => convexHull_min ?_ this hx a ha
exact fun y hy a ha => subset_convexHull 𝕜 s (hs ha hy)
intro x hx y hy u v hu hv huv a ha
rw [smul_add, ← smul_comm u, ← smul_comm v]
exact convex_convexHull 𝕜 s (hx a ha) (hy a ha) hu hv huv
variable {S : Type*} [SetLike S E] [SMulMemClass S 𝕜 E]
theorem Absorbent.eq_univ_of_smulMemClass {V : S} (hV : Absorbent 𝕜 (V : Set E)) :
(V : Set E) = univ := by
rw [eq_univ_iff_forall]
intro x
obtain ⟨c, hc, hc'⟩ :=
((absorbent_iff_eventually_nhdsNE_zero.mp hV x).and eventually_mem_nhdsWithin).exists
rw [← inv_smul_smul₀ hc' x]
exact SMulMemClass.smul_mem c⁻¹ hc
theorem Absorbent.submodule_eq_top {V : Submodule 𝕜 E} (hV : Absorbent 𝕜 (V : Set E)) :
V = ⊤ := (StrictMono.apply_eq_top_iff (α := Submodule 𝕜 E) (β := Set E) (fun _ _ a_1 ↦ a_1)).mp
hV.eq_univ_of_smulMemClass
variable {F ℱ 𝕜₂ : Type*} [Semiring 𝕜₂] {σ : 𝕜₂ →+* 𝕜}
variable [AddCommGroup F] [Module 𝕜₂ F]
variable [FunLike ℱ F E] [SemilinearMapClass ℱ σ F E]
theorem Absorbent.subset_range_iff_surjective [RingHomSurjective σ] {f : ℱ} {s : Set E}
(hs_abs : Absorbent 𝕜 s) : s ⊆ LinearMap.range f ↔ (⇑f).Surjective :=
⟨fun hs_sub ↦ LinearMap.range_eq_top.mp ((hs_abs.mono hs_sub).submodule_eq_top), fun h a _ ↦ h a⟩
end NontriviallyNormedField
section Real
variable [AddCommGroup E] [Module ℝ E] {s : Set E}
theorem balanced_iff_neg_mem (hs : Convex ℝ s) : Balanced ℝ s ↔ ∀ ⦃x⦄, x ∈ s → -x ∈ s := by
refine ⟨fun h x => h.neg_mem_iff.2, fun h a ha => smul_set_subset_iff.2 fun x hx => ?_⟩
rw [Real.norm_eq_abs, abs_le] at ha
rw [show a = -((1 - a) / 2) + (a - -1) / 2 by ring, add_smul, neg_smul, ← smul_neg]
exact hs (h hx) hx (div_nonneg (sub_nonneg_of_le ha.2) zero_le_two)
(div_nonneg (sub_nonneg_of_le ha.1) zero_le_two) (by ring)
end Real |
.lake/packages/mathlib/Mathlib/Analysis/LocallyConvex/StrongTopology.lean | import Mathlib.Topology.Algebra.Module.StrongTopology
import Mathlib.Topology.Algebra.Module.LocallyConvex
/-!
# Local convexity of the strong topology
In this file we prove that the strong topology on `E →L[ℝ] F` is locally convex provided that `F` is
locally convex.
## References
* [N. Bourbaki, *Topological Vector Spaces*][bourbaki1987]
## TODO
* Characterization in terms of seminorms
## Tags
locally convex, bounded convergence
-/
open Topology UniformConvergence
variable {R 𝕜₁ 𝕜₂ E F : Type*}
variable [AddCommGroup E] [TopologicalSpace E] [AddCommGroup F] [TopologicalSpace F]
[IsTopologicalAddGroup F]
section General
namespace UniformConvergenceCLM
variable (R)
variable [Semiring R] [PartialOrder R]
variable [NormedField 𝕜₁] [NormedField 𝕜₂] [Module 𝕜₁ E] [Module 𝕜₂ F] {σ : 𝕜₁ →+* 𝕜₂}
variable [Module R F] [ContinuousConstSMul R F] [LocallyConvexSpace R F] [SMulCommClass 𝕜₂ R F]
theorem locallyConvexSpace (𝔖 : Set (Set E)) (h𝔖₁ : 𝔖.Nonempty)
(h𝔖₂ : DirectedOn (· ⊆ ·) 𝔖) :
LocallyConvexSpace R (UniformConvergenceCLM σ F 𝔖) := by
apply LocallyConvexSpace.ofBasisZero _ _ _ _
(UniformConvergenceCLM.hasBasis_nhds_zero_of_basis _ _ _ h𝔖₁ h𝔖₂
(LocallyConvexSpace.convex_basis_zero R F)) _
rintro ⟨S, V⟩ ⟨_, _, hVconvex⟩ f hf g hg a b ha hb hab x hx
exact hVconvex (hf x hx) (hg x hx) ha hb hab
end UniformConvergenceCLM
end General
section BoundedSets
namespace ContinuousLinearMap
variable [Semiring R] [PartialOrder R]
variable [NormedField 𝕜₁] [NormedField 𝕜₂] [Module 𝕜₁ E] [Module 𝕜₂ F] {σ : 𝕜₁ →+* 𝕜₂}
variable [Module R F] [ContinuousConstSMul R F] [LocallyConvexSpace R F] [SMulCommClass 𝕜₂ R F]
instance instLocallyConvexSpace : LocallyConvexSpace R (E →SL[σ] F) :=
UniformConvergenceCLM.locallyConvexSpace R _ ⟨∅, Bornology.isVonNBounded_empty 𝕜₁ E⟩
(directedOn_of_sup_mem fun _ _ => Bornology.IsVonNBounded.union)
end ContinuousLinearMap
end BoundedSets |
.lake/packages/mathlib/Mathlib/Analysis/LocallyConvex/ContinuousOfBounded.lean | import Mathlib.Analysis.LocallyConvex.Bounded
import Mathlib.Analysis.RCLike.Basic
/-!
# Continuity and Von Neumann boundedness
This file proves that for two topological vector spaces `E` and `F` over `ℝ` or `ℂ`,
if `E` is first countable, then every locally bounded linear map `E →ₛₗ[σ] F` is continuous
(this is `LinearMap.continuous_of_locally_bounded`).
We keep this file separate from `Analysis/LocallyConvex/Bounded` in order not to import
`Analysis/NormedSpace/RCLike` there, because defining the strong topology on the space of
continuous linear maps will require importing `Analysis/LocallyConvex/Bounded` in
`Analysis/NormedSpace/OperatorNorm`.
## References
* [Bourbaki, *Topological Vector Spaces*][bourbaki1987]
-/
open TopologicalSpace Bornology Filter Topology Pointwise
variable {𝕜 𝕜' E F : Type*}
variable [AddCommGroup E] [UniformSpace E] [IsUniformAddGroup E]
variable [AddCommGroup F] [UniformSpace F]
section NontriviallyNormedField
variable [IsUniformAddGroup F]
variable [NontriviallyNormedField 𝕜] [Module 𝕜 E] [Module 𝕜 F] [ContinuousSMul 𝕜 E]
/-- Construct a continuous linear map from a linear map `f : E →ₗ[𝕜] F` and the existence of a
neighborhood of zero that gets mapped into a bounded set in `F`. -/
def LinearMap.clmOfExistsBoundedImage (f : E →ₗ[𝕜] F)
(h : ∃ V ∈ 𝓝 (0 : E), Bornology.IsVonNBounded 𝕜 (f '' V)) : E →L[𝕜] F :=
⟨f, by
-- It suffices to show that `f` is continuous at `0`.
refine continuous_of_continuousAt_zero f ?_
rw [continuousAt_def, f.map_zero]
intro U hU
-- Continuity means that `U ∈ 𝓝 0` implies that `f ⁻¹' U ∈ 𝓝 0`.
rcases h with ⟨V, hV, h⟩
rcases (h hU).exists_pos with ⟨r, hr, h⟩
rcases NormedField.exists_lt_norm 𝕜 r with ⟨x, hx⟩
specialize h x hx.le
-- After unfolding all the definitions, we know that `f '' V ⊆ x • U`. We use this to show the
-- inclusion `x⁻¹ • V ⊆ f⁻¹' U`.
have x_ne := norm_pos_iff.mp (hr.trans hx)
have : x⁻¹ • V ⊆ f ⁻¹' U :=
calc
x⁻¹ • V ⊆ x⁻¹ • f ⁻¹' (f '' V) := Set.smul_set_mono (Set.subset_preimage_image (⇑f) V)
_ ⊆ x⁻¹ • f ⁻¹' (x • U) := Set.smul_set_mono (Set.preimage_mono h)
_ = f ⁻¹' (x⁻¹ • x • U) := by
ext
simp only [Set.mem_inv_smul_set_iff₀ x_ne, Set.mem_preimage, LinearMap.map_smul]
_ ⊆ f ⁻¹' U := by rw [inv_smul_smul₀ x_ne _]
-- Using this inclusion, it suffices to show that `x⁻¹ • V` is in `𝓝 0`, which is trivial.
refine mem_of_superset ?_ this
rwa [set_smul_mem_nhds_zero_iff (inv_ne_zero x_ne)]⟩
theorem LinearMap.clmOfExistsBoundedImage_coe {f : E →ₗ[𝕜] F}
{h : ∃ V ∈ 𝓝 (0 : E), Bornology.IsVonNBounded 𝕜 (f '' V)} :
(f.clmOfExistsBoundedImage h : E →ₗ[𝕜] F) = f :=
rfl
@[simp]
theorem LinearMap.clmOfExistsBoundedImage_apply {f : E →ₗ[𝕜] F}
{h : ∃ V ∈ 𝓝 (0 : E), Bornology.IsVonNBounded 𝕜 (f '' V)} {x : E} :
f.clmOfExistsBoundedImage h x = f x :=
rfl
end NontriviallyNormedField
section RCLike
open TopologicalSpace Bornology
variable [FirstCountableTopology E]
variable [RCLike 𝕜] [Module 𝕜 E] [ContinuousSMul 𝕜 E]
variable [RCLike 𝕜'] [Module 𝕜' F] [ContinuousSMul 𝕜' F]
variable {σ : 𝕜 →+* 𝕜'}
theorem LinearMap.continuousAt_zero_of_locally_bounded (f : E →ₛₗ[σ] F)
(hf : ∀ s, IsVonNBounded 𝕜 s → IsVonNBounded 𝕜' (f '' s)) : ContinuousAt f 0 := by
-- Assume that f is not continuous at 0
by_contra h
-- We use a decreasing balanced basis for 0 : E and a balanced basis for 0 : F
-- and reformulate non-continuity in terms of these bases
rcases (nhds_basis_balanced 𝕜 E).exists_antitone_subbasis with ⟨b, bE1, bE⟩
simp only [_root_.id] at bE
have bE' : (𝓝 (0 : E)).HasBasis (fun x : ℕ => x ≠ 0) fun n : ℕ => (n : 𝕜)⁻¹ • b n := by
refine bE.1.to_hasBasis ?_ ?_
· intro n _
use n + 1
simp only [Ne, Nat.succ_ne_zero, not_false_iff, Nat.cast_add, Nat.cast_one, true_and]
-- `b (n + 1) ⊆ b n` follows from `Antitone`.
have h : b (n + 1) ⊆ b n := bE.2 (by simp)
refine _root_.trans ?_ h
rintro y ⟨x, hx, hy⟩
-- Since `b (n + 1)` is balanced `(n+1)⁻¹ b (n + 1) ⊆ b (n + 1)`
rw [← hy]
refine (bE1 (n + 1)).2.smul_mem ?_ hx
have h' : 0 < (n : ℝ) + 1 := n.cast_add_one_pos
rw [norm_inv, ← Nat.cast_one, ← Nat.cast_add, RCLike.norm_natCast, Nat.cast_add,
Nat.cast_one, inv_le_comm₀ h' zero_lt_one]
simp
intro n hn
-- The converse direction follows from continuity of the scalar multiplication
have hcont : ContinuousAt (fun x : E => (n : 𝕜) • x) 0 :=
(continuous_const_smul (n : 𝕜)).continuousAt
simp only [ContinuousAt, smul_zero] at hcont
rw [bE.1.tendsto_left_iff] at hcont
rcases hcont (b n) (bE1 n).1 with ⟨i, _, hi⟩
refine ⟨i, trivial, fun x hx => ⟨(n : 𝕜) • x, hi hx, ?_⟩⟩
simp [← mul_smul, hn]
rw [ContinuousAt, map_zero, bE'.tendsto_iff (nhds_basis_balanced 𝕜' F)] at h
push_neg at h
rcases h with ⟨V, ⟨hV, -⟩, h⟩
simp only [_root_.id] at h
-- There exists `u : ℕ → E` such that for all `n : ℕ` we have `u n ∈ n⁻¹ • b n` and `f (u n) ∉ V`
choose! u hu hu' using h
-- The sequence `(fun n ↦ n • u n)` converges to `0`
have h_tendsto : Tendsto (fun n : ℕ => (n : 𝕜) • u n) atTop (𝓝 (0 : E)) := by
apply bE.tendsto
intro n
by_cases h : n = 0
· rw [h, Nat.cast_zero, zero_smul]
exact mem_of_mem_nhds (bE.1.mem_of_mem <| by trivial)
rcases hu n h with ⟨y, hy, hu1⟩
convert hy
rw [← hu1, ← mul_smul]
simp only [h, mul_inv_cancel₀, Ne, Nat.cast_eq_zero, not_false_iff, one_smul]
-- The image `(fun n ↦ n • u n)` is von Neumann bounded:
have h_bounded : IsVonNBounded 𝕜 (Set.range fun n : ℕ => (n : 𝕜) • u n) :=
h_tendsto.cauchySeq.totallyBounded_range.isVonNBounded 𝕜
-- Since `range u` is bounded, `V` absorbs it
rcases (hf _ h_bounded hV).exists_pos with ⟨r, hr, h'⟩
obtain ⟨n, hn⟩ := exists_nat_gt r
-- We now find a contradiction between `f (u n) ∉ V` and the absorbing property
have h1 : r ≤ ‖(n : 𝕜')‖ := by
rw [RCLike.norm_natCast]
exact hn.le
have hn' : 0 < ‖(n : 𝕜')‖ := lt_of_lt_of_le hr h1
rw [norm_pos_iff, Ne, Nat.cast_eq_zero] at hn'
have h'' : f (u n) ∈ V := by
simp only [Set.image_subset_iff] at h'
specialize h' (n : 𝕜') h1 (Set.mem_range_self n)
simp only [Set.mem_preimage, LinearMap.map_smulₛₗ, map_natCast] at h'
rcases h' with ⟨y, hy, h'⟩
apply_fun fun y : F => (n : 𝕜')⁻¹ • y at h'
simp only [hn', inv_smul_smul₀, Ne, Nat.cast_eq_zero, not_false_iff] at h'
rwa [← h']
exact hu' n hn' h''
/-- If `E` is first countable, then every locally bounded linear map `E →ₛₗ[σ] F` is continuous. -/
theorem LinearMap.continuous_of_locally_bounded [IsUniformAddGroup F] (f : E →ₛₗ[σ] F)
(hf : ∀ s, IsVonNBounded 𝕜 s → IsVonNBounded 𝕜' (f '' s)) : Continuous f :=
(uniformContinuous_of_continuousAt_zero f <| f.continuousAt_zero_of_locally_bounded hf).continuous
end RCLike |
.lake/packages/mathlib/Mathlib/Analysis/LocallyConvex/AbsConvexOpen.lean | import Mathlib.Analysis.LocallyConvex.AbsConvex
import Mathlib.Analysis.LocallyConvex.WithSeminorms
import Mathlib.Analysis.Convex.Gauge
/-!
# Absolutely convex open sets
A set `s` in a commutative monoid `E` equipped with a topology is said to be an absolutely convex
open set if it is absolutely convex and open. When `E` is a topological additive group, the topology
coincides with the topology induced by the family of seminorms arising as gauges of absolutely
convex open neighborhoods of zero.
## Main definitions
* `AbsConvexOpenSets`: sets which are absolutely convex and open
* `gaugeSeminormFamily`: the seminorm family induced by all open absolutely convex neighborhoods
of zero.
## Main statements
* `with_gaugeSeminormFamily`: the topology of a locally convex space is induced by the family
`gaugeSeminormFamily`.
-/
open NormedField Set
open NNReal Pointwise Topology
variable {𝕜 E : Type*}
section AbsolutelyConvexSets
variable [TopologicalSpace E] [AddCommMonoid E] [Zero E] [SeminormedRing 𝕜]
variable [SMul 𝕜 E]
variable (𝕜 E) [PartialOrder 𝕜]
/-- The type of absolutely convex open sets. -/
def AbsConvexOpenSets :=
{ s : Set E // (0 : E) ∈ s ∧ IsOpen s ∧ AbsConvex 𝕜 s }
noncomputable instance AbsConvexOpenSets.instCoeOut : CoeOut (AbsConvexOpenSets 𝕜 E) (Set E) :=
⟨Subtype.val⟩
namespace AbsConvexOpenSets
variable {𝕜 E}
theorem coe_zero_mem (s : AbsConvexOpenSets 𝕜 E) : (0 : E) ∈ (s : Set E) :=
s.2.1
theorem coe_isOpen (s : AbsConvexOpenSets 𝕜 E) : IsOpen (s : Set E) :=
s.2.2.1
theorem coe_nhds (s : AbsConvexOpenSets 𝕜 E) : (s : Set E) ∈ 𝓝 (0 : E) :=
s.coe_isOpen.mem_nhds s.coe_zero_mem
theorem coe_balanced (s : AbsConvexOpenSets 𝕜 E) : Balanced 𝕜 (s : Set E) :=
s.2.2.2.1
theorem coe_convex (s : AbsConvexOpenSets 𝕜 E) : Convex 𝕜 (s : Set E) :=
s.2.2.2.2
end AbsConvexOpenSets
instance AbsConvexOpenSets.instNonempty : Nonempty (AbsConvexOpenSets 𝕜 E) := by
rw [← exists_true_iff_nonempty]
dsimp only [AbsConvexOpenSets]
rw [Subtype.exists]
exact ⟨Set.univ, ⟨mem_univ 0, isOpen_univ, balanced_univ, convex_univ⟩, trivial⟩
end AbsolutelyConvexSets
variable [RCLike 𝕜]
variable [AddCommGroup E] [TopologicalSpace E]
variable [Module 𝕜 E] [Module ℝ E] [IsScalarTower ℝ 𝕜 E]
variable [ContinuousSMul ℝ E]
variable (𝕜 E)
open scoped ComplexOrder
/-- The family of seminorms defined by the gauges of absolute convex open sets. -/
noncomputable def gaugeSeminormFamily : SeminormFamily 𝕜 E (AbsConvexOpenSets 𝕜 E) := fun s =>
gaugeSeminorm s.coe_balanced (s.coe_convex.lift ℝ) (absorbent_nhds_zero s.coe_nhds)
variable {𝕜 E}
theorem gaugeSeminormFamily_ball (s : AbsConvexOpenSets 𝕜 E) :
(gaugeSeminormFamily 𝕜 E s).ball 0 1 = (s : Set E) := by
dsimp only [gaugeSeminormFamily]
rw [Seminorm.ball_zero_eq]
simp_rw [gaugeSeminorm_toFun]
exact gauge_lt_one_eq_self_of_isOpen (s.coe_convex.lift ℝ) s.coe_zero_mem s.coe_isOpen
variable [IsTopologicalAddGroup E] [ContinuousSMul 𝕜 E]
variable [LocallyConvexSpace 𝕜 E]
/-- The topology of a locally convex space is induced by the gauge seminorm family. -/
theorem with_gaugeSeminormFamily : WithSeminorms (gaugeSeminormFamily 𝕜 E) := by
refine SeminormFamily.withSeminorms_of_hasBasis _ ?_
refine (nhds_hasBasis_absConvex_open 𝕜 E).to_hasBasis (fun s hs => ?_) fun s hs => ?_
· refine ⟨s, ⟨?_, rfl.subset⟩⟩
convert (gaugeSeminormFamily _ _).basisSets_singleton_mem ⟨s, hs⟩ one_pos
rw [gaugeSeminormFamily_ball, Subtype.coe_mk]
refine ⟨s, ⟨?_, rfl.subset⟩⟩
rw [SeminormFamily.basisSets_iff] at hs
rcases hs with ⟨t, r, hr, rfl⟩
rw [Seminorm.ball_finset_sup_eq_iInter _ _ _ hr]
-- We have to show that the intersection contains zero, is open, balanced, and convex
refine
⟨mem_iInter₂.mpr fun _ _ => by simp [hr],
isOpen_biInter_finset fun S _ => ?_,
balanced_iInter₂ fun _ _ => Seminorm.balanced_ball_zero _ _,
convex_iInter₂ fun _ _ => (convex_of_nonneg_surjective_algebraMap _
(fun _ => RCLike.nonneg_iff_exists_ofReal.mp) (Seminorm.convex_ball _ _ _) ..)⟩
-- The only nontrivial part is to show that the ball is open
have hr' : r = ‖(r : 𝕜)‖ * 1 := by simp [abs_of_pos hr]
have hr'' : (r : 𝕜) ≠ 0 := by simp [hr.ne']
rw [hr', ← Seminorm.smul_ball_zero hr'', gaugeSeminormFamily_ball]
exact S.coe_isOpen.smul₀ hr'' |
.lake/packages/mathlib/Mathlib/Analysis/LocallyConvex/WithSeminorms.lean | import Mathlib.Analysis.LocallyConvex.Bounded
import Mathlib.Analysis.Seminorm
import Mathlib.Data.Real.Sqrt
import Mathlib.Topology.Algebra.Equicontinuity
import Mathlib.Topology.MetricSpace.Equicontinuity
import Mathlib.Topology.Algebra.FilterBasis
import Mathlib.Topology.Algebra.Module.LocallyConvex
/-!
# Topology induced by a family of seminorms
## Main definitions
* `SeminormFamily.basisSets`: The set of open seminorm balls for a family of seminorms.
* `SeminormFamily.moduleFilterBasis`: A module filter basis formed by the open balls.
* `Seminorm.IsBounded`: A linear map `f : E →ₗ[𝕜] F` is bounded iff every seminorm in `F` can be
bounded by a finite number of seminorms in `E`.
## Main statements
* `WithSeminorms.toLocallyConvexSpace`: A space equipped with a family of seminorms is locally
convex.
* `WithSeminorms.firstCountable`: A space is first countable if its topology is induced by a
countable family of seminorms.
## Continuity of semilinear maps
If `E` and `F` are topological vector space with the topology induced by a family of seminorms, then
we have a direct method to prove that a linear map is continuous:
* `Seminorm.continuous_from_bounded`: A bounded linear map `f : E →ₗ[𝕜] F` is continuous.
If the topology of a space `E` is induced by a family of seminorms, then we can characterize von
Neumann boundedness in terms of that seminorm family. Together with
`LinearMap.continuous_of_locally_bounded` this gives general criterion for continuity.
* `WithSeminorms.isVonNBounded_iff_finset_seminorm_bounded`
* `WithSeminorms.isVonNBounded_iff_seminorm_bounded`
* `WithSeminorms.image_isVonNBounded_iff_finset_seminorm_bounded`
* `WithSeminorms.image_isVonNBounded_iff_seminorm_bounded`
## Tags
seminorm, locally convex
-/
open NormedField Set Seminorm TopologicalSpace Filter List Bornology
open NNReal Pointwise Topology Uniformity
variable {R 𝕜 𝕜₂ 𝕝 𝕝₂ E F G ι ι' : Type*}
section FilterBasis
variable [SeminormedRing R] [AddCommGroup E] [Module R E]
variable (R E ι)
/-- An abbreviation for indexed families of seminorms. This is mainly to allow for dot-notation. -/
abbrev SeminormFamily :=
ι → Seminorm R E
variable {R E ι}
namespace SeminormFamily
/-- The sets of a filter basis for the neighborhood filter of 0. -/
def basisSets (p : SeminormFamily R E ι) : Set (Set E) :=
⋃ (s : Finset ι) (r) (_ : 0 < r), singleton (ball (s.sup p) (0 : E) r)
variable (p : SeminormFamily R E ι)
theorem basisSets_iff {U : Set E} :
U ∈ p.basisSets ↔ ∃ (i : Finset ι) (r : ℝ), 0 < r ∧ U = ball (i.sup p) 0 r := by
simp only [basisSets, mem_iUnion, exists_prop, mem_singleton_iff]
theorem basisSets_mem (i : Finset ι) {r : ℝ} (hr : 0 < r) : (i.sup p).ball 0 r ∈ p.basisSets :=
(basisSets_iff _).mpr ⟨i, _, hr, rfl⟩
theorem basisSets_singleton_mem (i : ι) {r : ℝ} (hr : 0 < r) : (p i).ball 0 r ∈ p.basisSets :=
(basisSets_iff _).mpr ⟨{i}, _, hr, by rw [Finset.sup_singleton]⟩
theorem basisSets_univ_mem : univ ∈ p.basisSets :=
(basisSets_iff _).mpr ⟨∅, _, one_pos, by
rw [Finset.sup_empty, Seminorm.bot_eq_zero, ball_zero' _ one_pos]⟩
theorem basisSets_nonempty : p.basisSets.Nonempty := by
refine nonempty_def.mpr ⟨univ, basisSets_univ_mem _⟩
theorem basisSets_intersect (U V : Set E) (hU : U ∈ p.basisSets) (hV : V ∈ p.basisSets) :
∃ z ∈ p.basisSets, z ⊆ U ∩ V := by
classical
rcases p.basisSets_iff.mp hU with ⟨s, r₁, hr₁, hU⟩
rcases p.basisSets_iff.mp hV with ⟨t, r₂, hr₂, hV⟩
use ((s ∪ t).sup p).ball 0 (min r₁ r₂)
refine ⟨p.basisSets_mem (s ∪ t) (lt_min_iff.mpr ⟨hr₁, hr₂⟩), ?_⟩
rw [hU, hV, ball_finset_sup_eq_iInter _ _ _ (lt_min_iff.mpr ⟨hr₁, hr₂⟩),
ball_finset_sup_eq_iInter _ _ _ hr₁, ball_finset_sup_eq_iInter _ _ _ hr₂]
exact
Set.subset_inter
(Set.iInter₂_mono' fun i hi =>
⟨i, Finset.subset_union_left hi, ball_mono <| min_le_left _ _⟩)
(Set.iInter₂_mono' fun i hi =>
⟨i, Finset.subset_union_right hi, ball_mono <| min_le_right _ _⟩)
theorem basisSets_zero (U) (hU : U ∈ p.basisSets) : (0 : E) ∈ U := by
rcases p.basisSets_iff.mp hU with ⟨ι', r, hr, hU⟩
rw [hU, mem_ball_zero, map_zero]
exact hr
theorem basisSets_add (U) (hU : U ∈ p.basisSets) :
∃ V ∈ p.basisSets, V + V ⊆ U := by
rcases p.basisSets_iff.mp hU with ⟨s, r, hr, hU⟩
use (s.sup p).ball 0 (r / 2)
refine ⟨p.basisSets_mem s (div_pos hr zero_lt_two), ?_⟩
refine Set.Subset.trans (ball_add_ball_subset (s.sup p) (r / 2) (r / 2) 0 0) ?_
rw [hU, add_zero, add_halves]
theorem basisSets_neg (U) (hU' : U ∈ p.basisSets) :
∃ V ∈ p.basisSets, V ⊆ (fun x : E => -x) ⁻¹' U := by
rcases p.basisSets_iff.mp hU' with ⟨s, r, _, hU⟩
rw [hU, neg_preimage, neg_ball (s.sup p), neg_zero]
exact ⟨U, hU', Eq.subset hU⟩
/-- The `addGroupFilterBasis` induced by the filter basis `Seminorm.basisSets`. -/
protected def addGroupFilterBasis : AddGroupFilterBasis E :=
addGroupFilterBasisOfComm p.basisSets p.basisSets_nonempty p.basisSets_intersect p.basisSets_zero
p.basisSets_add p.basisSets_neg
theorem basisSets_smul_right (v : E) (U : Set E) (hU : U ∈ p.basisSets) :
∀ᶠ x : R in 𝓝 0, x • v ∈ U := by
rcases p.basisSets_iff.mp hU with ⟨s, r, hr, hU⟩
rw [hU, Filter.eventually_iff]
simp_rw [(s.sup p).mem_ball_zero, map_smul_eq_mul]
by_cases! h : 0 < (s.sup p) v
· simp_rw [(lt_div_iff₀ h).symm]
rw [← _root_.ball_zero_eq]
exact Metric.ball_mem_nhds 0 (div_pos hr h)
simp_rw [le_antisymm h (apply_nonneg _ v), mul_zero, hr]
exact IsOpen.mem_nhds isOpen_univ (mem_univ 0)
theorem basisSets_smul (U) (hU : U ∈ p.basisSets) :
∃ V ∈ 𝓝 (0 : R), ∃ W ∈ p.addGroupFilterBasis.sets, V • W ⊆ U := by
rcases p.basisSets_iff.mp hU with ⟨s, r, hr, hU⟩
refine ⟨Metric.ball 0 √r, Metric.ball_mem_nhds 0 (Real.sqrt_pos.mpr hr), ?_⟩
refine ⟨(s.sup p).ball 0 √r, p.basisSets_mem s (Real.sqrt_pos.mpr hr), ?_⟩
refine Set.Subset.trans (ball_smul_ball (s.sup p) √r √r) ?_
rw [hU, Real.mul_self_sqrt (le_of_lt hr)]
variable [NormedField 𝕜] [AddCommGroup F] [Module 𝕜 F] (p : SeminormFamily 𝕜 F ι)
theorem basisSets_smul_left (x : 𝕜) (U : Set F) (hU : U ∈ p.basisSets) :
∃ V ∈ p.addGroupFilterBasis.sets, V ⊆ (fun y : F => x • y) ⁻¹' U := by
rcases p.basisSets_iff.mp hU with ⟨s, r, hr, hU⟩
rw [hU]
by_cases h : x ≠ 0
· rw [(s.sup p).smul_ball_preimage 0 r x h, smul_zero]
use (s.sup p).ball 0 (r / ‖x‖)
exact ⟨p.basisSets_mem s (div_pos hr (norm_pos_iff.mpr h)), Subset.rfl⟩
refine ⟨(s.sup p).ball 0 r, p.basisSets_mem s hr, ?_⟩
simp only [not_ne_iff.mp h, Set.subset_def, mem_ball_zero, hr, mem_univ, map_zero, imp_true_iff,
preimage_const_of_mem, zero_smul]
/-- The `moduleFilterBasis` induced by the filter basis `Seminorm.basisSets`. -/
protected def moduleFilterBasis : ModuleFilterBasis 𝕜 F where
toAddGroupFilterBasis := p.addGroupFilterBasis
smul' := p.basisSets_smul _
smul_left' := p.basisSets_smul_left
smul_right' := p.basisSets_smul_right
theorem filter_eq_iInf (p : SeminormFamily 𝕜 F ι) :
p.moduleFilterBasis.toFilterBasis.filter = ⨅ i, (𝓝 0).comap (p i) := by
refine le_antisymm (le_iInf fun i => ?_) ?_
· rw [p.moduleFilterBasis.toFilterBasis.hasBasis.le_basis_iff
(Metric.nhds_basis_ball.comap _)]
intro ε hε
refine ⟨(p i).ball 0 ε, ?_, ?_⟩
· rw [← (Finset.sup_singleton : _ = p i)]
exact p.basisSets_mem {i} hε
· rw [id, (p i).ball_zero_eq_preimage_ball]
· rw [p.moduleFilterBasis.toFilterBasis.hasBasis.ge_iff]
rintro U (hU : U ∈ p.basisSets)
rcases p.basisSets_iff.mp hU with ⟨s, r, hr, rfl⟩
rw [id, Seminorm.ball_finset_sup_eq_iInter _ _ _ hr, s.iInter_mem_sets]
exact fun i _ =>
Filter.mem_iInf_of_mem i
⟨Metric.ball 0 r, Metric.ball_mem_nhds 0 hr,
Eq.subset (p i).ball_zero_eq_preimage_ball.symm⟩
/-- If a family of seminorms is continuous, then their basis sets are neighborhoods of zero. -/
lemma basisSets_mem_nhds {𝕜 E ι : Type*} [NormedField 𝕜]
[AddCommGroup E] [Module 𝕜 E] [TopologicalSpace E] (p : SeminormFamily 𝕜 E ι)
(hp : ∀ i, Continuous (p i)) (U : Set E) (hU : U ∈ p.basisSets) : U ∈ 𝓝 (0 : E) := by
obtain ⟨s, r, hr, rfl⟩ := p.basisSets_iff.mp hU
clear hU
refine Seminorm.ball_mem_nhds ?_ hr
classical
induction s using Finset.induction_on with
| empty => simpa using continuous_zero
| insert a s _ hs =>
simp only [Finset.sup_insert, coe_sup]
exact Continuous.max (hp a) hs
end SeminormFamily
end FilterBasis
section Bounded
namespace Seminorm
variable [SeminormedRing 𝕜] [AddCommGroup E] [Module 𝕜 E]
variable [SeminormedRing 𝕜₂] [AddCommGroup F] [Module 𝕜₂ F]
variable {σ₁₂ : 𝕜 →+* 𝕜₂} [RingHomIsometric σ₁₂]
-- Todo: This should be phrased entirely in terms of the von Neumann bornology.
/-- The proposition that a linear map is bounded between spaces with families of seminorms. -/
def IsBounded (p : ι → Seminorm 𝕜 E) (q : ι' → Seminorm 𝕜₂ F) (f : E →ₛₗ[σ₁₂] F) : Prop :=
∀ i, ∃ s : Finset ι, ∃ C : ℝ≥0, (q i).comp f ≤ C • s.sup p
theorem isBounded_const (ι' : Type*) [Nonempty ι'] {p : ι → Seminorm 𝕜 E} {q : Seminorm 𝕜₂ F}
(f : E →ₛₗ[σ₁₂] F) :
IsBounded p (fun _ : ι' => q) f ↔ ∃ (s : Finset ι) (C : ℝ≥0), q.comp f ≤ C • s.sup p := by
simp only [IsBounded, forall_const]
theorem const_isBounded (ι : Type*) [Nonempty ι] {p : Seminorm 𝕜 E} {q : ι' → Seminorm 𝕜₂ F}
(f : E →ₛₗ[σ₁₂] F) : IsBounded (fun _ : ι => p) q f ↔ ∀ i, ∃ C : ℝ≥0, (q i).comp f ≤ C • p := by
constructor <;> intro h i
· rcases h i with ⟨s, C, h⟩
exact ⟨C, le_trans h (smul_le_smul (Finset.sup_le fun _ _ => le_rfl) le_rfl)⟩
use {Classical.arbitrary ι}
simp only [h, Finset.sup_singleton]
theorem isBounded_sup {p : ι → Seminorm 𝕜 E} {q : ι' → Seminorm 𝕜₂ F} {f : E →ₛₗ[σ₁₂] F}
(hf : IsBounded p q f) (s' : Finset ι') :
∃ (C : ℝ≥0) (s : Finset ι), (s'.sup q).comp f ≤ C • s.sup p := by
classical
obtain rfl | _ := s'.eq_empty_or_nonempty
· exact ⟨1, ∅, by simp [Seminorm.bot_eq_zero]⟩
choose fₛ fC hf using hf
use s'.card • s'.sup fC, Finset.biUnion s' fₛ
have hs : ∀ i : ι', i ∈ s' → (q i).comp f ≤ s'.sup fC • (Finset.biUnion s' fₛ).sup p := by
intro i hi
refine (hf i).trans (smul_le_smul ?_ (Finset.le_sup hi))
exact Finset.sup_mono (Finset.subset_biUnion_of_mem fₛ hi)
refine (comp_mono f (finset_sup_le_sum q s')).trans ?_
simp_rw [← pullback_apply, map_sum, pullback_apply]
refine (Finset.sum_le_sum hs).trans ?_
rw [Finset.sum_const, smul_assoc]
end Seminorm
end Bounded
section Topology
variable [NormedField 𝕜] [AddCommGroup E] [Module 𝕜 E]
/-- The proposition that the topology of `E` is induced by a family of seminorms `p`. -/
structure WithSeminorms (p : SeminormFamily 𝕜 E ι) [topology : TopologicalSpace E] : Prop where
topology_eq_withSeminorms : topology = p.moduleFilterBasis.topology
theorem WithSeminorms.withSeminorms_eq {p : SeminormFamily 𝕜 E ι} [t : TopologicalSpace E]
(hp : WithSeminorms p) : t = p.moduleFilterBasis.topology :=
hp.1
variable [TopologicalSpace E]
variable {p : SeminormFamily 𝕜 E ι}
theorem WithSeminorms.topologicalAddGroup (hp : WithSeminorms p) : IsTopologicalAddGroup E := by
rw [hp.withSeminorms_eq]
exact AddGroupFilterBasis.isTopologicalAddGroup _
theorem WithSeminorms.continuousSMul (hp : WithSeminorms p) : ContinuousSMul 𝕜 E := by
rw [hp.withSeminorms_eq]
exact ModuleFilterBasis.continuousSMul _
theorem WithSeminorms.hasBasis (hp : WithSeminorms p) :
(𝓝 (0 : E)).HasBasis (fun s : Set E => s ∈ p.basisSets) id := by
rw [congr_fun (congr_arg (@nhds E) hp.1) 0]
exact AddGroupFilterBasis.nhds_zero_hasBasis _
theorem WithSeminorms.hasBasis_zero_ball (hp : WithSeminorms p) :
(𝓝 (0 : E)).HasBasis
(fun sr : Finset ι × ℝ => 0 < sr.2) fun sr => (sr.1.sup p).ball 0 sr.2 := by
refine ⟨fun V => ?_⟩
simp only [hp.hasBasis.mem_iff, SeminormFamily.basisSets_iff, Prod.exists, id_eq]
grind
theorem WithSeminorms.hasBasis_ball (hp : WithSeminorms p) {x : E} :
(𝓝 (x : E)).HasBasis
(fun sr : Finset ι × ℝ => 0 < sr.2) fun sr => (sr.1.sup p).ball x sr.2 := by
have : IsTopologicalAddGroup E := hp.topologicalAddGroup
rw [← map_add_left_nhds_zero]
convert hp.hasBasis_zero_ball.map (x + ·) using 1
ext sr : 1
-- Porting note: extra type ascriptions needed on `0`
have : (sr.fst.sup p).ball (x +ᵥ (0 : E)) sr.snd = x +ᵥ (sr.fst.sup p).ball 0 sr.snd :=
Eq.symm (Seminorm.vadd_ball (sr.fst.sup p))
rwa [vadd_eq_add, add_zero] at this
/-- The `x`-neighbourhoods of a space whose topology is induced by a family of seminorms
are exactly the sets which contain seminorm balls around `x`. -/
theorem WithSeminorms.mem_nhds_iff (hp : WithSeminorms p) (x : E) (U : Set E) :
U ∈ 𝓝 x ↔ ∃ s : Finset ι, ∃ r > 0, (s.sup p).ball x r ⊆ U := by
rw [hp.hasBasis_ball.mem_iff, Prod.exists]
/-- The open sets of a space whose topology is induced by a family of seminorms
are exactly the sets which contain seminorm balls around all of their points. -/
theorem WithSeminorms.isOpen_iff_mem_balls (hp : WithSeminorms p) (U : Set E) :
IsOpen U ↔ ∀ x ∈ U, ∃ s : Finset ι, ∃ r > 0, (s.sup p).ball x r ⊆ U := by
simp_rw [← WithSeminorms.mem_nhds_iff hp _ U, isOpen_iff_mem_nhds]
/- Note that through the following lemmas, one also immediately has that separating families
of seminorms induce T₂ and T₃ topologies by `IsTopologicalAddGroup.t2Space`
and `IsTopologicalAddGroup.t3Space` -/
/-- A separating family of seminorms induces a T₁ topology. -/
theorem WithSeminorms.T1_of_separating (hp : WithSeminorms p)
(h : ∀ x, x ≠ 0 → ∃ i, p i x ≠ 0) : T1Space E := by
have := hp.topologicalAddGroup
refine IsTopologicalAddGroup.t1Space _ ?_
rw [← isOpen_compl_iff, hp.isOpen_iff_mem_balls]
rintro x (hx : x ≠ 0)
obtain ⟨i, pi_nonzero⟩ := h x hx
refine ⟨{i}, p i x, by positivity, subset_compl_singleton_iff.mpr ?_⟩
rw [Finset.sup_singleton, mem_ball, zero_sub, map_neg_eq_map, not_lt]
/-- A family of seminorms inducing a T₁ topology is separating. -/
theorem WithSeminorms.separating_of_T1 [T1Space E] (hp : WithSeminorms p) (x : E) (hx : x ≠ 0) :
∃ i, p i x ≠ 0 := by
have := ((t1Space_TFAE E).out 0 9).mp (inferInstanceAs <| T1Space E)
by_contra! h
refine hx (this ?_)
rw [hp.hasBasis_zero_ball.specializes_iff]
rintro ⟨s, r⟩ (hr : 0 < r)
simp only [ball_finset_sup_eq_iInter _ _ _ hr, mem_iInter₂, mem_ball_zero, h, hr, forall_true_iff]
/-- A family of seminorms is separating iff it induces a T₁ topology. -/
theorem WithSeminorms.separating_iff_T1 (hp : WithSeminorms p) :
(∀ x, x ≠ 0 → ∃ i, p i x ≠ 0) ↔ T1Space E := by
refine ⟨WithSeminorms.T1_of_separating hp, ?_⟩
intro
exact WithSeminorms.separating_of_T1 hp
end Topology
section Tendsto
variable [NormedField 𝕜] [AddCommGroup E] [Module 𝕜 E] [TopologicalSpace E]
variable {p : SeminormFamily 𝕜 E ι}
/-- Convergence along filters for `WithSeminorms`.
Variant with `Finset.sup`. -/
theorem WithSeminorms.tendsto_nhds' (hp : WithSeminorms p) (u : F → E) {f : Filter F} (y₀ : E) :
Filter.Tendsto u f (𝓝 y₀) ↔
∀ (s : Finset ι) (ε), 0 < ε → ∀ᶠ x in f, s.sup p (u x - y₀) < ε := by
simp [hp.hasBasis_ball.tendsto_right_iff]
/-- Convergence along filters for `WithSeminorms`. -/
theorem WithSeminorms.tendsto_nhds (hp : WithSeminorms p) (u : F → E) {f : Filter F} (y₀ : E) :
Filter.Tendsto u f (𝓝 y₀) ↔ ∀ i ε, 0 < ε → ∀ᶠ x in f, p i (u x - y₀) < ε := by
rw [hp.tendsto_nhds' u y₀]
exact
⟨fun h i => by simpa only [Finset.sup_singleton] using h {i}, fun h s ε hε =>
(s.eventually_all.2 fun i _ => h i ε hε).mono fun _ => finset_sup_apply_lt hε⟩
variable [SemilatticeSup F] [Nonempty F]
/-- Limit `→ ∞` for `WithSeminorms`. -/
theorem WithSeminorms.tendsto_nhds_atTop (hp : WithSeminorms p) (u : F → E) (y₀ : E) :
Filter.Tendsto u Filter.atTop (𝓝 y₀) ↔
∀ i ε, 0 < ε → ∃ x₀, ∀ x, x₀ ≤ x → p i (u x - y₀) < ε := by
rw [hp.tendsto_nhds u y₀]
exact forall₃_congr fun _ _ _ => Filter.eventually_atTop
end Tendsto
section IsTopologicalAddGroup
variable [NormedField 𝕜] [AddCommGroup E] [Module 𝕜 E]
section TopologicalSpace
variable [t : TopologicalSpace E]
theorem SeminormFamily.withSeminorms_of_nhds [IsTopologicalAddGroup E] (p : SeminormFamily 𝕜 E ι)
(h : 𝓝 (0 : E) = p.moduleFilterBasis.toFilterBasis.filter) : WithSeminorms p := by
refine
⟨IsTopologicalAddGroup.ext inferInstance p.addGroupFilterBasis.isTopologicalAddGroup ?_⟩
rw [AddGroupFilterBasis.nhds_zero_eq]
exact h
theorem SeminormFamily.withSeminorms_of_hasBasis [IsTopologicalAddGroup E]
(p : SeminormFamily 𝕜 E ι) (h : (𝓝 (0 : E)).HasBasis (fun s : Set E => s ∈ p.basisSets) id) :
WithSeminorms p :=
p.withSeminorms_of_nhds <|
Filter.HasBasis.eq_of_same_basis h p.addGroupFilterBasis.toFilterBasis.hasBasis
theorem SeminormFamily.withSeminorms_iff_nhds_eq_iInf [IsTopologicalAddGroup E]
(p : SeminormFamily 𝕜 E ι) : WithSeminorms p ↔ (𝓝 (0 : E)) = ⨅ i, (𝓝 0).comap (p i) := by
rw [← p.filter_eq_iInf]
refine ⟨fun h => ?_, p.withSeminorms_of_nhds⟩
rw [h.topology_eq_withSeminorms]
exact AddGroupFilterBasis.nhds_zero_eq _
/-- The topology induced by a family of seminorms is exactly the infimum of the ones induced by
each seminorm individually. We express this as a characterization of `WithSeminorms p`. -/
theorem SeminormFamily.withSeminorms_iff_topologicalSpace_eq_iInf [IsTopologicalAddGroup E]
(p : SeminormFamily 𝕜 E ι) :
WithSeminorms p ↔
t = ⨅ i, (p i).toSeminormedAddCommGroup.toUniformSpace.toTopologicalSpace := by
rw [p.withSeminorms_iff_nhds_eq_iInf,
IsTopologicalAddGroup.ext_iff inferInstance (topologicalAddGroup_iInf fun i => inferInstance),
nhds_iInf]
congrm _ = ⨅ i, ?_
exact @comap_norm_nhds_zero _ (p i).toSeminormedAddGroup
theorem WithSeminorms.continuous_seminorm {p : SeminormFamily 𝕜 E ι} (hp : WithSeminorms p)
(i : ι) : Continuous (p i) := by
have := hp.topologicalAddGroup
rw [p.withSeminorms_iff_topologicalSpace_eq_iInf.mp hp]
exact continuous_iInf_dom (@continuous_norm _ (p i).toSeminormedAddGroup)
end TopologicalSpace
/-- The uniform structure induced by a family of seminorms is exactly the infimum of the ones
induced by each seminorm individually. We express this as a characterization of
`WithSeminorms p`. -/
theorem SeminormFamily.withSeminorms_iff_uniformSpace_eq_iInf [u : UniformSpace E]
[IsUniformAddGroup E] (p : SeminormFamily 𝕜 E ι) :
WithSeminorms p ↔ u = ⨅ i, (p i).toSeminormedAddCommGroup.toUniformSpace := by
rw [p.withSeminorms_iff_nhds_eq_iInf,
IsUniformAddGroup.ext_iff inferInstance (isUniformAddGroup_iInf fun i => inferInstance),
UniformSpace.toTopologicalSpace_iInf, nhds_iInf]
congrm _ = ⨅ i, ?_
exact @comap_norm_nhds_zero _ (p i).toAddGroupSeminorm.toSeminormedAddGroup
end IsTopologicalAddGroup
section NormedSpace
/-- The topology of a `NormedSpace 𝕜 E` is induced by the seminorm `normSeminorm 𝕜 E`. -/
theorem norm_withSeminorms (𝕜 E) [NormedField 𝕜] [SeminormedAddCommGroup E] [NormedSpace 𝕜 E] :
WithSeminorms fun _ : Fin 1 => normSeminorm 𝕜 E := by
rw [SeminormFamily.withSeminorms_iff_nhds_eq_iInf, iInf_const, coe_normSeminorm,
comap_norm_nhds_zero]
end NormedSpace
section NontriviallyNormedField
variable [NontriviallyNormedField 𝕜] [AddCommGroup E] [Module 𝕜 E]
variable {p : SeminormFamily 𝕜 E ι}
variable [TopologicalSpace E]
theorem WithSeminorms.isVonNBounded_iff_finset_seminorm_bounded {s : Set E} (hp : WithSeminorms p) :
IsVonNBounded 𝕜 s ↔ ∀ I : Finset ι, ∃ r > 0, ∀ x ∈ s, I.sup p x < r := by
rw [hp.hasBasis.isVonNBounded_iff]
constructor
· intro h I
simp only [id] at h
specialize h ((I.sup p).ball 0 1) (p.basisSets_mem I zero_lt_one)
rcases h.exists_pos with ⟨r, hr, h⟩
obtain ⟨a, ha⟩ := NormedField.exists_lt_norm 𝕜 r
specialize h a (le_of_lt ha)
rw [Seminorm.smul_ball_zero (norm_pos_iff.1 <| hr.trans ha), mul_one] at h
refine ⟨‖a‖, lt_trans hr ha, ?_⟩
intro x hx
specialize h hx
exact (Finset.sup I p).mem_ball_zero.mp h
intro h s' hs'
rcases p.basisSets_iff.mp hs' with ⟨I, r, hr, hs'⟩
rw [id, hs']
rcases h I with ⟨r', _, h'⟩
simp_rw [← (I.sup p).mem_ball_zero] at h'
refine Absorbs.mono_right ?_ h'
exact (Finset.sup I p).ball_zero_absorbs_ball_zero hr
theorem WithSeminorms.image_isVonNBounded_iff_finset_seminorm_bounded (f : G → E) {s : Set G}
(hp : WithSeminorms p) :
IsVonNBounded 𝕜 (f '' s) ↔
∀ I : Finset ι, ∃ r > 0, ∀ x ∈ s, I.sup p (f x) < r := by
simp_rw [hp.isVonNBounded_iff_finset_seminorm_bounded, Set.forall_mem_image]
theorem WithSeminorms.isVonNBounded_iff_seminorm_bounded {s : Set E} (hp : WithSeminorms p) :
IsVonNBounded 𝕜 s ↔ ∀ i : ι, ∃ r > 0, ∀ x ∈ s, p i x < r := by
rw [hp.isVonNBounded_iff_finset_seminorm_bounded]
constructor
· intro hI i
convert hI {i}
rw [Finset.sup_singleton]
intro hi I
by_cases hI : I.Nonempty
· choose r hr h using hi
have h' : 0 < I.sup' hI r := by
rcases hI with ⟨i, hi⟩
exact lt_of_lt_of_le (hr i) (Finset.le_sup' r hi)
refine ⟨I.sup' hI r, h', fun x hx => finset_sup_apply_lt h' fun i hi => ?_⟩
refine lt_of_lt_of_le (h i x hx) ?_
simp only [Finset.le_sup'_iff]
exact ⟨i, hi, (Eq.refl _).le⟩
simp only [Finset.not_nonempty_iff_eq_empty.mp hI, Finset.sup_empty, coe_bot, Pi.zero_apply]
exact ⟨1, zero_lt_one, fun _ _ => zero_lt_one⟩
theorem WithSeminorms.image_isVonNBounded_iff_seminorm_bounded (f : G → E) {s : Set G}
(hp : WithSeminorms p) :
IsVonNBounded 𝕜 (f '' s) ↔ ∀ i : ι, ∃ r > 0, ∀ x ∈ s, p i (f x) < r := by
simp_rw [hp.isVonNBounded_iff_seminorm_bounded, Set.forall_mem_image]
/-- In a topological vector space, the topology is generated by a single seminorm `p` iff
the unit ball for this seminorm is a bounded neighborhood of `0`. -/
theorem withSeminorms_iff_mem_nhds_isVonNBounded [IsTopologicalAddGroup E]
[ContinuousConstSMul 𝕜 E] {p : Seminorm 𝕜 E} :
WithSeminorms (fun (_ : Fin 1) ↦ p) ↔ p.ball 0 1 ∈ 𝓝 0 ∧ IsVonNBounded 𝕜 (p.ball 0 1) := by
/- The nontrivial direction is from right to left. With `SeminormFamily.withSeminorms_of_nhds`,
we need to see that the neighborhoods of zero for the initial topology and for `p` coincide. -/
refine ⟨fun h ↦ ⟨?_, ?_⟩, ?_⟩
· apply (h.mem_nhds_iff _ _).2
exact ⟨Finset.univ, 1, zero_lt_one, by simp⟩
· apply h.isVonNBounded_iff_seminorm_bounded.2 (fun i ↦ ?_)
exact ⟨1, zero_lt_one, by simp⟩
rintro ⟨h, h'⟩
apply SeminormFamily.withSeminorms_of_nhds
ext s
refine ⟨fun hs ↦ ?_, fun hs ↦ ?_⟩
· /- Show that a neighborhood `s` of zero for the topology is a neighborhood for `p`, by using the
boundedess of `p.ball 0 1`: this ensures that, for some nonzero `c`, we have
`p.ball 0 1 ⊆ c • s`, and therefore `p.ball 0 (‖c‖⁻¹) ⊆ s`. -/
obtain ⟨c, hc, c_ne⟩ : ∃ (c : 𝕜), p.ball 0 1 ⊆ c • s ∧ c ≠ 0 :=
((h' hs).and (eventually_ne_cobounded 0)).exists
have : p.ball 0 (‖c⁻¹‖) ⊆ s := by
have : c • p.ball 0 (‖c⁻¹‖) ⊆ c • s := by
simpa [smul_ball_zero c_ne, ← norm_mul, c_ne] using hc
rwa [smul_set_subset_smul_set_iff₀ c_ne] at this
apply Filter.mem_of_superset _ this
apply FilterBasis.mem_filter_of_mem
change p.ball 0 (‖c⁻¹‖) ∈ SeminormFamily.basisSets (fun (i : Fin 1) ↦ p)
apply SeminormFamily.basisSets_singleton_mem _ 0
simpa using c_ne
· /- Show that a neighborhood `s` for `p` is a neighborhood for the topology, by using the
fact that `p.ball 0 1` is a neighborhood of `0`. Indeed, `s` contains a ball `p.ball 0 r`,
which contains `c • p.ball 0 1` for some nonzero `c`. The latter set is a neighborhood of zero
for the topology thanks to the topological vector space assumption. -/
rcases (FilterBasis.mem_filter_iff _).1 hs with ⟨t, ht, ts⟩
suffices t ∈ 𝓝 0 from Filter.mem_of_superset this ts
rcases (SeminormFamily.basisSets_iff _).1 ht with ⟨w, r, r_pos, hw⟩
rcases eq_or_ne w ∅ with rfl | w_ne
· simp only [ball, Finset.sup_empty, sub_zero, coe_bot, Pi.zero_apply, r_pos, setOf_true] at hw
simp [hw]
have : t = p.ball 0 r := by
have : w = Finset.univ := by
rcases Finset.nonempty_of_ne_empty w_ne with ⟨i, hi⟩
ext j
simp only [Subsingleton.elim j i, hi, Finset.mem_univ]
simpa only [this, Finset.univ_unique, Fin.default_eq_zero, Fin.isValue,
Finset.sup_singleton] using hw
rw [this]
obtain ⟨c, c_pos, hc⟩ : ∃ (c : 𝕜), 0 < ‖c‖ ∧ ‖c‖ < r := exists_norm_lt 𝕜 r_pos
have c_ne : c ≠ 0 := (by simpa using c_pos)
have : c • p.ball 0 1 ⊆ p.ball 0 r := by
rw [smul_ball_zero c_ne]
exact ball_mono (by simpa using hc.le)
apply Filter.mem_of_superset ?_ this
simpa using smul_mem_nhds_smul₀ c_ne h
end NontriviallyNormedField
-- TODO: the names in this section are not very predictable
section continuous_of_bounded
namespace Seminorm
variable [NontriviallyNormedField 𝕜] [AddCommGroup E] [Module 𝕜 E]
variable [NormedField 𝕝] [Module 𝕝 E]
variable [NormedField 𝕜₂] [AddCommGroup F] [Module 𝕜₂ F]
variable [NormedField 𝕝₂] [Module 𝕝₂ F]
variable {σ₁₂ : 𝕜 →+* 𝕜₂} [RingHomIsometric σ₁₂]
variable {τ₁₂ : 𝕝 →+* 𝕝₂} [RingHomIsometric τ₁₂]
theorem continuous_of_continuous_comp {q : SeminormFamily 𝕝₂ F ι'} [TopologicalSpace E]
[IsTopologicalAddGroup E] [TopologicalSpace F] (hq : WithSeminorms q)
(f : E →ₛₗ[τ₁₂] F) (hf : ∀ i, Continuous ((q i).comp f)) : Continuous f := by
have : IsTopologicalAddGroup F := hq.topologicalAddGroup
refine continuous_of_continuousAt_zero f ?_
simp_rw [ContinuousAt, f.map_zero, q.withSeminorms_iff_nhds_eq_iInf.mp hq, Filter.tendsto_iInf,
Filter.tendsto_comap_iff]
intro i
convert (hf i).continuousAt.tendsto
exact (map_zero _).symm
theorem continuous_iff_continuous_comp {q : SeminormFamily 𝕝₂ F ι'} [TopologicalSpace E]
[IsTopologicalAddGroup E] [TopologicalSpace F] (hq : WithSeminorms q) (f : E →ₛₗ[τ₁₂] F) :
Continuous f ↔ ∀ i, Continuous ((q i).comp f) :=
⟨fun h i => (hq.continuous_seminorm i).comp h, continuous_of_continuous_comp hq f⟩
theorem continuous_from_bounded {p : SeminormFamily 𝕝 E ι} {q : SeminormFamily 𝕝₂ F ι'}
{_ : TopologicalSpace E} (hp : WithSeminorms p) {_ : TopologicalSpace F} (hq : WithSeminorms q)
(f : E →ₛₗ[τ₁₂] F) (hf : Seminorm.IsBounded p q f) : Continuous f := by
have : IsTopologicalAddGroup E := hp.topologicalAddGroup
refine continuous_of_continuous_comp hq _ fun i => ?_
rcases hf i with ⟨s, C, hC⟩
rw [← Seminorm.finset_sup_smul] at hC
-- Note: we deduce continuouty of `s.sup (C • p)` from that of `∑ i ∈ s, C • p i`.
-- The reason is that there is no `continuous_finset_sup`, and even if it were we couldn't
-- really use it since `ℝ` is not an `OrderBot`.
refine Seminorm.continuous_of_le ?_ (hC.trans <| Seminorm.finset_sup_le_sum _ _)
change Continuous (fun x ↦ Seminorm.coeFnAddMonoidHom _ _ (∑ i ∈ s, C • p i) x)
simp_rw [map_sum, Finset.sum_apply]
exact (continuous_finset_sum _ fun i _ ↦ (hp.continuous_seminorm i).const_smul (C : ℝ))
theorem cont_withSeminorms_normedSpace (F) [SeminormedAddCommGroup F] [NormedSpace 𝕝₂ F]
[TopologicalSpace E] {p : ι → Seminorm 𝕝 E} (hp : WithSeminorms p)
(f : E →ₛₗ[τ₁₂] F) (hf : ∃ (s : Finset ι) (C : ℝ≥0), (normSeminorm 𝕝₂ F).comp f ≤ C • s.sup p) :
Continuous f := by
rw [← Seminorm.isBounded_const (Fin 1)] at hf
exact continuous_from_bounded hp (norm_withSeminorms 𝕝₂ F) f hf
theorem cont_normedSpace_to_withSeminorms (E) [SeminormedAddCommGroup E] [NormedSpace 𝕝 E]
[TopologicalSpace F] {q : ι → Seminorm 𝕝₂ F} (hq : WithSeminorms q)
(f : E →ₛₗ[τ₁₂] F) (hf : ∀ i : ι, ∃ C : ℝ≥0, (q i).comp f ≤ C • normSeminorm 𝕝 E) :
Continuous f := by
rw [← Seminorm.const_isBounded (Fin 1)] at hf
exact continuous_from_bounded (norm_withSeminorms 𝕝 E) hq f hf
/-- Let `E` and `F` be two topological vector spaces over a `NontriviallyNormedField`, and assume
that the topology of `F` is generated by some family of seminorms `q`. For a family `f` of linear
maps from `E` to `F`, the following are equivalent:
* `f` is equicontinuous at `0`.
* `f` is equicontinuous.
* `f` is uniformly equicontinuous.
* For each `q i`, the family of seminorms `k ↦ (q i) ∘ (f k)` is bounded by some continuous
seminorm `p` on `E`.
* For each `q i`, the seminorm `⊔ k, (q i) ∘ (f k)` is well-defined and continuous.
In particular, if you can determine all continuous seminorms on `E`, that gives you a complete
characterization of equicontinuity for linear maps from `E` to `F`. For example `E` and `F` are
both normed spaces, you get `NormedSpace.equicontinuous_TFAE`. -/
protected theorem _root_.WithSeminorms.equicontinuous_TFAE {κ : Type*}
{q : SeminormFamily 𝕜₂ F ι'} [UniformSpace E] [IsUniformAddGroup E] [u : UniformSpace F]
[hu : IsUniformAddGroup F] (hq : WithSeminorms q) [ContinuousSMul 𝕜 E]
(f : κ → E →ₛₗ[σ₁₂] F) : TFAE
[ EquicontinuousAt ((↑) ∘ f) 0,
Equicontinuous ((↑) ∘ f),
UniformEquicontinuous ((↑) ∘ f),
∀ i, ∃ p : Seminorm 𝕜 E, Continuous p ∧ ∀ k, (q i).comp (f k) ≤ p,
∀ i, BddAbove (range fun k ↦ (q i).comp (f k)) ∧ Continuous (⨆ k, (q i).comp (f k)) ] := by
-- We start by reducing to the case where the target is a seminormed space
rw [q.withSeminorms_iff_uniformSpace_eq_iInf.mp hq, uniformEquicontinuous_iInf_rng,
equicontinuous_iInf_rng, equicontinuousAt_iInf_rng]
refine forall_tfae [_, _, _, _, _] fun i ↦ ?_
let _ : SeminormedAddCommGroup F := (q i).toSeminormedAddCommGroup
clear u hu hq
-- Now we can prove the equivalence in this setting
simp only [List.map]
tfae_have 1 → 3 := uniformEquicontinuous_of_equicontinuousAt_zero f
tfae_have 3 → 2 := UniformEquicontinuous.equicontinuous
tfae_have 2 → 1 := fun H ↦ H 0
tfae_have 3 → 5
| H => by
have : ∀ᶠ x in 𝓝 0, ∀ k, q i (f k x) ≤ 1 := by
filter_upwards [Metric.equicontinuousAt_iff_right.mp (H.equicontinuous 0) 1 one_pos]
with x hx k
simpa using (hx k).le
have bdd : BddAbove (range fun k ↦ (q i).comp (f k)) :=
Seminorm.bddAbove_of_absorbent (absorbent_nhds_zero this)
(fun x hx ↦ ⟨1, forall_mem_range.mpr hx⟩)
rw [← Seminorm.coe_iSup_eq bdd]
refine ⟨bdd, Seminorm.continuous' (r := 1) ?_⟩
filter_upwards [this] with x hx
simpa only [closedBall_iSup bdd _ one_pos, mem_iInter, mem_closedBall_zero] using hx
tfae_have 5 → 4 := fun H ↦ ⟨⨆ k, (q i).comp (f k), Seminorm.coe_iSup_eq H.1 ▸ H.2, le_ciSup H.1⟩
tfae_have 4 → 1 -- This would work over any `NormedField`
| ⟨p, hp, hfp⟩ =>
Metric.equicontinuousAt_of_continuity_modulus p (map_zero p ▸ hp.tendsto 0) _ <|
Eventually.of_forall fun x k ↦ by simpa using hfp k x
tfae_finish
theorem _root_.WithSeminorms.uniformEquicontinuous_iff_exists_continuous_seminorm {κ : Type*}
{q : SeminormFamily 𝕜₂ F ι'} [UniformSpace E] [IsUniformAddGroup E] [u : UniformSpace F]
[IsUniformAddGroup F] (hq : WithSeminorms q) [ContinuousSMul 𝕜 E]
(f : κ → E →ₛₗ[σ₁₂] F) :
UniformEquicontinuous ((↑) ∘ f) ↔
∀ i, ∃ p : Seminorm 𝕜 E, Continuous p ∧ ∀ k, (q i).comp (f k) ≤ p :=
(hq.equicontinuous_TFAE f).out 2 3
theorem _root_.WithSeminorms.uniformEquicontinuous_iff_bddAbove_and_continuous_iSup {κ : Type*}
{q : SeminormFamily 𝕜₂ F ι'} [UniformSpace E] [IsUniformAddGroup E] [u : UniformSpace F]
[IsUniformAddGroup F] (hq : WithSeminorms q) [ContinuousSMul 𝕜 E]
(f : κ → E →ₛₗ[σ₁₂] F) :
UniformEquicontinuous ((↑) ∘ f) ↔ ∀ i,
BddAbove (range fun k ↦ (q i).comp (f k)) ∧
Continuous (⨆ k, (q i).comp (f k)) :=
(hq.equicontinuous_TFAE f).out 2 4
end Seminorm
section Congr
namespace WithSeminorms
variable [NormedField 𝕜] [AddCommGroup E] [Module 𝕜 E]
variable [SeminormedRing 𝕜₂] [AddCommGroup F] [Module 𝕜₂ F]
variable {σ₁₂ : 𝕜 →+* 𝕜₂} [RingHomIsometric σ₁₂]
/-- Two families of seminorms `p` and `q` on the same space generate the same topology
if each `p i` is bounded by some `C • Finset.sup s q` and vice-versa.
We formulate these boundedness assumptions as `Seminorm.IsBounded q p LinearMap.id` (and
vice-versa) to reuse the API. Furthermore, we don't actually state it as an equality of topologies
but as a way to deduce `WithSeminorms q` from `WithSeminorms p`, since this should be more
useful in practice. -/
protected theorem congr {p : SeminormFamily 𝕜 E ι} {q : SeminormFamily 𝕜 E ι'}
[t : TopologicalSpace E] (hp : WithSeminorms p) (hpq : Seminorm.IsBounded p q LinearMap.id)
(hqp : Seminorm.IsBounded q p LinearMap.id) : WithSeminorms q := by
constructor
rw [hp.topology_eq_withSeminorms]
clear hp t
refine le_antisymm ?_ ?_ <;>
rw [← continuous_id_iff_le] <;>
refine continuous_from_bounded (.mk (topology := _) rfl) (.mk (topology := _) rfl)
LinearMap.id (by assumption)
protected theorem finset_sups {p : SeminormFamily 𝕜 E ι} [TopologicalSpace E]
(hp : WithSeminorms p) : WithSeminorms (fun s : Finset ι ↦ s.sup p) := by
refine hp.congr ?_ ?_
· intro s
refine ⟨s, 1, ?_⟩
rw [one_smul]
rfl
· intro i
refine ⟨{{i}}, 1, ?_⟩
rw [Finset.sup_singleton, Finset.sup_singleton, one_smul]
rfl
protected theorem partial_sups [Preorder ι] [LocallyFiniteOrderBot ι] {p : SeminormFamily 𝕜 E ι}
[TopologicalSpace E] (hp : WithSeminorms p) : WithSeminorms (fun i ↦ (Finset.Iic i).sup p) := by
refine hp.congr ?_ ?_
· intro i
refine ⟨Finset.Iic i, 1, ?_⟩
rw [one_smul]
rfl
· intro i
refine ⟨{i}, 1, ?_⟩
rw [Finset.sup_singleton, one_smul]
exact (Finset.le_sup (Finset.mem_Iic.mpr le_rfl) : p i ≤ (Finset.Iic i).sup p)
protected theorem congr_equiv {p : SeminormFamily 𝕜 E ι} [t : TopologicalSpace E]
(hp : WithSeminorms p) (e : ι' ≃ ι) : WithSeminorms (p ∘ e) := by
refine hp.congr ?_ ?_ <;>
intro i <;>
[use {e i}, 1; use {e.symm i}, 1] <;>
simp
end WithSeminorms
end Congr
end continuous_of_bounded
section bounded_of_continuous
namespace Seminorm
variable [NontriviallyNormedField 𝕜] [AddCommGroup E] [Module 𝕜 E]
[SeminormedAddCommGroup F] [NormedSpace 𝕜 F]
{p : SeminormFamily 𝕜 E ι}
/-- In a semi-`NormedSpace`, a continuous seminorm is zero on elements of norm `0`. -/
lemma map_eq_zero_of_norm_eq_zero (q : Seminorm 𝕜 F)
(hq : Continuous q) {x : F} (hx : ‖x‖ = 0) : q x = 0 :=
(map_zero q) ▸
((specializes_iff_mem_closure.mpr <| mem_closure_zero_iff_norm.mpr hx).map hq).eq.symm
@[deprecated (since := "2025-11-15")] alias map_eq_zero_of_norm_zero := map_eq_zero_of_norm_eq_zero
/-- Let `F` be a semi-`NormedSpace` over a `NontriviallyNormedField`, and let `q` be a
seminorm on `F`. If `q` is continuous, then it is uniformly controlled by the norm, that is there
is some `C > 0` such that `∀ x, q x ≤ C * ‖x‖`.
The continuity ensures boundedness on a ball of some radius `ε`. The nontriviality of the
norm is then used to rescale any element into an element of norm in `[ε/C, ε[`, thus with a
controlled image by `q`. The control of `q` at the original element follows by rescaling. -/
lemma bound_of_continuous_normedSpace (q : Seminorm 𝕜 F)
(hq : Continuous q) : ∃ C, 0 < C ∧ (∀ x : F, q x ≤ C * ‖x‖) := by
have hq' : Tendsto q (𝓝 0) (𝓝 0) := map_zero q ▸ hq.tendsto 0
rcases NormedAddCommGroup.nhds_zero_basis_norm_lt.mem_iff.mp (hq' <| Iio_mem_nhds one_pos)
with ⟨ε, ε_pos, hε⟩
rcases NormedField.exists_one_lt_norm 𝕜 with ⟨c, hc⟩
have : 0 < ‖c‖ / ε := by positivity
refine ⟨‖c‖ / ε, this, fun x ↦ ?_⟩
by_cases hx : ‖x‖ = 0
· rw [hx, mul_zero]
exact le_of_eq (map_eq_zero_of_norm_eq_zero q hq hx)
· refine (normSeminorm 𝕜 F).bound_of_shell q ε_pos hc (fun x hle hlt ↦ ?_) hx
refine (le_of_lt <| show q x < _ from hε hlt).trans ?_
rwa [← div_le_iff₀' this, one_div_div]
/-- Let `E` be a topological vector space (over a `NontriviallyNormedField`) whose topology is
generated by some family of seminorms `p`, and let `q` be a seminorm on `E`. If `q` is continuous,
then it is uniformly controlled by *finitely many* seminorms of `p`, that is there
is some finset `s` of the index set and some `C > 0` such that `q ≤ C • s.sup p`. -/
lemma bound_of_continuous [t : TopologicalSpace E] (hp : WithSeminorms p)
(q : Seminorm 𝕜 E) (hq : Continuous q) :
∃ s : Finset ι, ∃ C : ℝ≥0, C ≠ 0 ∧ q ≤ C • s.sup p := by
-- The continuity of `q` gives us a finset `s` and a real `ε > 0`
-- such that `hε : (s.sup p).ball 0 ε ⊆ q.ball 0 1`.
rcases hp.hasBasis.mem_iff.mp (ball_mem_nhds hq one_pos) with ⟨V, hV, hε⟩
rcases p.basisSets_iff.mp hV with ⟨s, ε, ε_pos, rfl⟩
-- Now forget that `E` already had a topology and view it as the (semi)normed space
-- `(E, s.sup p)`.
clear hp hq t
let _ : SeminormedAddCommGroup E := (s.sup p).toSeminormedAddCommGroup
let _ : NormedSpace 𝕜 E := { norm_smul_le := fun a b ↦ le_of_eq (map_smul_eq_mul (s.sup p) a b) }
-- The inclusion `hε` tells us exactly that `q` is *still* continuous for this new topology
have : Continuous q :=
Seminorm.continuous (r := 1) (mem_of_superset (Metric.ball_mem_nhds _ ε_pos) hε)
-- Hence we can conclude by applying `bound_of_continuous_normedSpace`.
rcases bound_of_continuous_normedSpace q this with ⟨C, C_pos, hC⟩
exact ⟨s, ⟨C, C_pos.le⟩, fun H ↦ C_pos.ne.symm (congr_arg NNReal.toReal H), hC⟩
-- Note that the key ingredient for this proof is that, by scaling arguments hidden in
-- `Seminorm.continuous`, we only have to look at the `q`-ball of radius one, and the `s` we get
-- from that will automatically work for all other radii.
end Seminorm
end bounded_of_continuous
section LocallyConvexSpace
open LocallyConvexSpace
variable [NormedField 𝕜] [NormedSpace ℝ 𝕜] [AddCommGroup E] [Module 𝕜 E] [Module ℝ E]
[IsScalarTower ℝ 𝕜 E] [TopologicalSpace E]
theorem WithSeminorms.toLocallyConvexSpace {p : SeminormFamily 𝕜 E ι} (hp : WithSeminorms p) :
LocallyConvexSpace ℝ E := by
have := hp.topologicalAddGroup
apply ofBasisZero ℝ E id fun s => s ∈ p.basisSets
· rw [hp.1, AddGroupFilterBasis.nhds_eq _, AddGroupFilterBasis.N_zero]
exact FilterBasis.hasBasis _
· intro s hs
change s ∈ Set.iUnion _ at hs
simp_rw [Set.mem_iUnion, Set.mem_singleton_iff] at hs
rcases hs with ⟨I, r, _, rfl⟩
exact convex_ball _ _ _
end LocallyConvexSpace
section NormedSpace
variable (𝕜) [NormedField 𝕜] [NormedSpace ℝ 𝕜] [SeminormedAddCommGroup E]
/-- Not an instance since `𝕜` can't be inferred. See `NormedSpace.toLocallyConvexSpace` for a
slightly weaker instance version. -/
theorem NormedSpace.toLocallyConvexSpace' [NormedSpace 𝕜 E] [Module ℝ E] [IsScalarTower ℝ 𝕜 E] :
LocallyConvexSpace ℝ E :=
(norm_withSeminorms 𝕜 E).toLocallyConvexSpace
/-- See `NormedSpace.toLocallyConvexSpace'` for a slightly stronger version which is not an
instance. -/
instance NormedSpace.toLocallyConvexSpace [NormedSpace ℝ E] : LocallyConvexSpace ℝ E :=
NormedSpace.toLocallyConvexSpace' ℝ
end NormedSpace
section TopologicalConstructions
variable [NormedField 𝕜] [AddCommGroup E] [Module 𝕜 E]
variable [NormedField 𝕜₂] [AddCommGroup F] [Module 𝕜₂ F]
variable {σ₁₂ : 𝕜 →+* 𝕜₂} [RingHomIsometric σ₁₂]
/-- The family of seminorms obtained by composing each seminorm by a linear map. -/
def SeminormFamily.comp (q : SeminormFamily 𝕜₂ F ι) (f : E →ₛₗ[σ₁₂] F) : SeminormFamily 𝕜 E ι :=
fun i => (q i).comp f
theorem SeminormFamily.comp_apply (q : SeminormFamily 𝕜₂ F ι) (i : ι) (f : E →ₛₗ[σ₁₂] F) :
q.comp f i = (q i).comp f :=
rfl
theorem SeminormFamily.finset_sup_comp (q : SeminormFamily 𝕜₂ F ι) (s : Finset ι)
(f : E →ₛₗ[σ₁₂] F) : (s.sup q).comp f = s.sup (q.comp f) := by
ext x
rw [Seminorm.comp_apply, Seminorm.finset_sup_apply, Seminorm.finset_sup_apply]
rfl
variable [TopologicalSpace F]
theorem LinearMap.withSeminorms_induced {q : SeminormFamily 𝕜₂ F ι}
(hq : WithSeminorms q) (f : E →ₛₗ[σ₁₂] F) :
WithSeminorms (topology := induced f inferInstance) (q.comp f) := by
have := hq.topologicalAddGroup
let _ : TopologicalSpace E := induced f inferInstance
have : IsTopologicalAddGroup E := topologicalAddGroup_induced f
rw [(q.comp f).withSeminorms_iff_nhds_eq_iInf, nhds_induced, map_zero,
q.withSeminorms_iff_nhds_eq_iInf.mp hq, Filter.comap_iInf]
refine iInf_congr fun i => ?_
exact Filter.comap_comap
lemma Topology.IsInducing.withSeminorms {q : SeminormFamily 𝕜₂ F ι}
(hq : WithSeminorms q) [TopologicalSpace E] {f : E →ₛₗ[σ₁₂] F} (hf : IsInducing f) :
WithSeminorms (q.comp f) := by
rw [hf.eq_induced]
exact f.withSeminorms_induced hq
/-- (Disjoint) union of seminorm families. -/
protected def SeminormFamily.sigma {κ : ι → Type*} (p : (i : ι) → SeminormFamily 𝕜 E (κ i)) :
SeminormFamily 𝕜 E ((i : ι) × κ i) :=
fun ⟨i, k⟩ => p i k
theorem withSeminorms_iInf {κ : ι → Type*}
{p : (i : ι) → SeminormFamily 𝕜 E (κ i)} {t : ι → TopologicalSpace E}
(hp : ∀ i, WithSeminorms (topology := t i) (p i)) :
WithSeminorms (topology := ⨅ i, t i) (SeminormFamily.sigma p) := by
have : ∀ i, @IsTopologicalAddGroup E (t i) _ :=
fun i ↦ @WithSeminorms.topologicalAddGroup _ _ _ _ _ _ (t i) _ (hp i)
have : @IsTopologicalAddGroup E (⨅ i, t i) _ := topologicalAddGroup_iInf inferInstance
simp_rw [@SeminormFamily.withSeminorms_iff_topologicalSpace_eq_iInf _ _ _ _ _ _ _ (_)] at hp ⊢
rw [iInf_sigma]
exact iInf_congr hp
theorem withSeminorms_pi {κ : ι → Type*} {E : ι → Type*}
[∀ i, AddCommGroup (E i)] [∀ i, Module 𝕜 (E i)] [∀ i, TopologicalSpace (E i)]
{p : (i : ι) → SeminormFamily 𝕜 (E i) (κ i)}
(hp : ∀ i, WithSeminorms (p i)) :
WithSeminorms (SeminormFamily.sigma (fun i ↦ (p i).comp (LinearMap.proj i))) :=
withSeminorms_iInf fun i ↦ (LinearMap.proj i).withSeminorms_induced (hp i)
end TopologicalConstructions
section TopologicalProperties
variable [NontriviallyNormedField 𝕜] [AddCommGroup E] [Module 𝕜 E] [Countable ι]
variable {p : SeminormFamily 𝕜 E ι}
variable [TopologicalSpace E]
/-- If the topology of a space is induced by a countable family of seminorms, then the topology
is first countable. -/
theorem WithSeminorms.firstCountableTopology (hp : WithSeminorms p) :
FirstCountableTopology E := by
have := hp.topologicalAddGroup
let _ : UniformSpace E := IsTopologicalAddGroup.rightUniformSpace E
have : IsUniformAddGroup E := isUniformAddGroup_of_addCommGroup
have : (𝓝 (0 : E)).IsCountablyGenerated := by
rw [p.withSeminorms_iff_nhds_eq_iInf.mp hp]
exact Filter.iInf.isCountablyGenerated _
have : (uniformity E).IsCountablyGenerated := IsUniformAddGroup.uniformity_countably_generated
exact UniformSpace.firstCountableTopology E
end TopologicalProperties |
.lake/packages/mathlib/Mathlib/Analysis/LocallyConvex/Separation.lean | import Mathlib.Analysis.Convex.Cone.Extension
import Mathlib.Analysis.Convex.Gauge
import Mathlib.Analysis.RCLike.Extend
import Mathlib.Topology.Algebra.Module.FiniteDimension
import Mathlib.Topology.Algebra.Module.LocallyConvex
/-!
# Separation Hahn-Banach theorem
In this file we prove the geometric Hahn-Banach theorem. For any two disjoint convex sets, there
exists a continuous linear functional separating them, geometrically meaning that we can intercalate
a plane between them.
We provide many variations to stricten the result under more assumptions on the convex sets:
* `geometric_hahn_banach_open`: One set is open. Weak separation.
* `geometric_hahn_banach_open_point`, `geometric_hahn_banach_point_open`: One set is open, the
other is a singleton. Weak separation.
* `geometric_hahn_banach_open_open`: Both sets are open. Semistrict separation.
* `geometric_hahn_banach_compact_closed`, `geometric_hahn_banach_closed_compact`: One set is closed,
the other one is compact. Strict separation.
* `geometric_hahn_banach_point_closed`, `geometric_hahn_banach_closed_point`: One set is closed, the
other one is a singleton. Strict separation.
* `geometric_hahn_banach_point_point`: Both sets are singletons. Strict separation.
## TODO
* Eidelheit's theorem
* `Convex ℝ s → interior (closure s) ⊆ s`
-/
assert_not_exists ContinuousLinearMap.hasOpNorm
open Set
open Pointwise
variable {𝕜 E : Type*}
/-- Given a set `s` which is a convex neighbourhood of `0` and a point `x₀` outside of it, there is
a continuous linear functional `f` separating `x₀` and `s`, in the sense that it sends `x₀` to 1 and
all of `s` to values strictly below `1`. -/
theorem separate_convex_open_set [TopologicalSpace E] [AddCommGroup E] [IsTopologicalAddGroup E]
[Module ℝ E] [ContinuousSMul ℝ E] {s : Set E} (hs₀ : (0 : E) ∈ s) (hs₁ : Convex ℝ s)
(hs₂ : IsOpen s) {x₀ : E} (hx₀ : x₀ ∉ s) :
∃ f : StrongDual ℝ E, f x₀ = 1 ∧ ∀ x ∈ s, f x < 1 := by
let f : E →ₗ.[ℝ] ℝ := LinearPMap.mkSpanSingleton x₀ 1 (ne_of_mem_of_not_mem hs₀ hx₀).symm
have := exists_extension_of_le_sublinear f (gauge s) (fun c hc => gauge_smul_of_nonneg hc.le)
(gauge_add_le hs₁ <| absorbent_nhds_zero <| hs₂.mem_nhds hs₀) ?_
· obtain ⟨φ, hφ₁, hφ₂⟩ := this
have hφ₃ : φ x₀ = 1 := by
rw [← f.domain.coe_mk x₀ (Submodule.mem_span_singleton_self _), hφ₁,
LinearPMap.mkSpanSingleton'_apply_self]
have hφ₄ : ∀ x ∈ s, φ x < 1 := fun x hx =>
(hφ₂ x).trans_lt (gauge_lt_one_of_mem_of_isOpen hs₂ hx)
refine ⟨⟨φ, ?_⟩, hφ₃, hφ₄⟩
refine
φ.continuous_of_nonzero_on_open _ (hs₂.vadd (-x₀)) (Nonempty.vadd_set ⟨0, hs₀⟩)
(vadd_set_subset_iff.mpr fun x hx => ?_)
change φ (-x₀ + x) ≠ 0
rw [map_add, map_neg]
specialize hφ₄ x hx
linarith
rintro ⟨x, hx⟩
obtain ⟨y, rfl⟩ := Submodule.mem_span_singleton.1 hx
rw [LinearPMap.mkSpanSingleton'_apply]
simp only [mul_one, Algebra.id.smul_eq_mul]
obtain h | h := le_or_gt y 0
· exact h.trans (gauge_nonneg _)
· rw [gauge_smul_of_nonneg h.le, smul_eq_mul, le_mul_iff_one_le_right h]
exact
one_le_gauge_of_notMem (hs₁.starConvex hs₀)
(absorbent_nhds_zero <| hs₂.mem_nhds hs₀).absorbs hx₀
variable [TopologicalSpace E] [AddCommGroup E] [Module ℝ E]
{s t : Set E} {x y : E}
section
variable [IsTopologicalAddGroup E] [ContinuousSMul ℝ E]
/-- A version of the **Hahn-Banach theorem**: given disjoint convex sets `s`, `t` where `s` is open,
there is a continuous linear functional which separates them. -/
theorem geometric_hahn_banach_open (hs₁ : Convex ℝ s) (hs₂ : IsOpen s) (ht : Convex ℝ t)
(disj : Disjoint s t) :
∃ (f : StrongDual ℝ E) (u : ℝ), (∀ a ∈ s, f a < u) ∧ ∀ b ∈ t, u ≤ f b := by
obtain rfl | ⟨a₀, ha₀⟩ := s.eq_empty_or_nonempty
· exact ⟨0, 0, by simp, fun b _hb => le_rfl⟩
obtain rfl | ⟨b₀, hb₀⟩ := t.eq_empty_or_nonempty
· exact ⟨0, 1, fun a _ha => zero_lt_one, by simp⟩
let x₀ := b₀ - a₀
let C := x₀ +ᵥ (s - t)
have : (0 : E) ∈ C :=
⟨a₀ - b₀, sub_mem_sub ha₀ hb₀, by simp_rw [x₀, vadd_eq_add, sub_add_sub_cancel', sub_self]⟩
have : Convex ℝ C := (hs₁.sub ht).vadd _
have : x₀ ∉ C := by
intro hx₀
rw [← add_zero x₀] at hx₀
exact disj.zero_notMem_sub_set (vadd_mem_vadd_set_iff.1 hx₀)
obtain ⟨f, hf₁, hf₂⟩ := separate_convex_open_set ‹0 ∈ C› ‹_› (hs₂.sub_right.vadd _) ‹x₀ ∉ C›
have forall_le : ∀ a ∈ s, ∀ b ∈ t, f a ≤ f b := by
intro a ha b hb
have := hf₂ (x₀ + (a - b)) (vadd_mem_vadd_set <| sub_mem_sub ha hb)
simp only [f.map_add, f.map_sub, hf₁] at this
linarith
refine ⟨f, sInf (f '' t), image_subset_iff.1 (?_ : f '' s ⊆ Iio (sInf (f '' t))), fun b hb => ?_⟩
· rw [← interior_Iic]
refine interior_maximal (image_subset_iff.2 fun a ha => ?_) (f.isOpenMap_of_ne_zero ?_ _ hs₂)
· exact le_csInf (Nonempty.image _ ⟨_, hb₀⟩) (forall_mem_image.2 <| forall_le _ ha)
· rintro rfl
simp at hf₁
· exact csInf_le ⟨f a₀, forall_mem_image.2 <| forall_le _ ha₀⟩ (mem_image_of_mem _ hb)
theorem geometric_hahn_banach_open_point (hs₁ : Convex ℝ s) (hs₂ : IsOpen s) (disj : x ∉ s) :
∃ f : StrongDual ℝ E, ∀ a ∈ s, f a < f x :=
let ⟨f, _s, hs, hx⟩ :=
geometric_hahn_banach_open hs₁ hs₂ (convex_singleton x) (disjoint_singleton_right.2 disj)
⟨f, fun a ha => lt_of_lt_of_le (hs a ha) (hx x (mem_singleton _))⟩
theorem geometric_hahn_banach_point_open (ht₁ : Convex ℝ t) (ht₂ : IsOpen t) (disj : x ∉ t) :
∃ f : StrongDual ℝ E, ∀ b ∈ t, f x < f b :=
let ⟨f, hf⟩ := geometric_hahn_banach_open_point ht₁ ht₂ disj
⟨-f, by simpa⟩
theorem geometric_hahn_banach_open_open (hs₁ : Convex ℝ s) (hs₂ : IsOpen s) (ht₁ : Convex ℝ t)
(ht₃ : IsOpen t) (disj : Disjoint s t) :
∃ (f : StrongDual ℝ E) (u : ℝ), (∀ a ∈ s, f a < u) ∧ ∀ b ∈ t, u < f b := by
obtain rfl | ⟨a₀, ha₀⟩ := s.eq_empty_or_nonempty
· exact ⟨0, -1, by simp, fun b _hb => by simp⟩
obtain rfl | ⟨b₀, hb₀⟩ := t.eq_empty_or_nonempty
· exact ⟨0, 1, fun a _ha => by simp, by simp⟩
obtain ⟨f, s, hf₁, hf₂⟩ := geometric_hahn_banach_open hs₁ hs₂ ht₁ disj
refine ⟨f, s, hf₁, image_subset_iff.1 (?_ : f '' t ⊆ Ioi s)⟩
rw [← interior_Ici]
refine interior_maximal (image_subset_iff.2 hf₂) (f.isOpenMap_of_ne_zero ?_ _ ht₃)
rintro rfl
simp_rw [ContinuousLinearMap.zero_apply] at hf₁ hf₂
exact (hf₁ _ ha₀).not_ge (hf₂ _ hb₀)
variable [LocallyConvexSpace ℝ E]
/-- A version of the **Hahn-Banach theorem**: given disjoint convex sets `s`, `t` where `s` is
compact and `t` is closed, there is a continuous linear functional which strongly separates them. -/
theorem geometric_hahn_banach_compact_closed (hs₁ : Convex ℝ s) (hs₂ : IsCompact s)
(ht₁ : Convex ℝ t) (ht₂ : IsClosed t) (disj : Disjoint s t) :
∃ (f : StrongDual ℝ E) (u v : ℝ), (∀ a ∈ s, f a < u) ∧ u < v ∧ ∀ b ∈ t, v < f b := by
obtain rfl | hs := s.eq_empty_or_nonempty
· exact ⟨0, -2, -1, by simp⟩
obtain rfl | _ht := t.eq_empty_or_nonempty
· exact ⟨0, 1, 2, by simp⟩
obtain ⟨U, V, hU, hV, hU₁, hV₁, sU, tV, disj'⟩ := disj.exists_open_convexes hs₁ hs₂ ht₁ ht₂
obtain ⟨f, u, hf₁, hf₂⟩ := geometric_hahn_banach_open_open hU₁ hU hV₁ hV disj'
obtain ⟨x, hx₁, hx₂⟩ := hs₂.exists_isMaxOn hs f.continuous.continuousOn
have : f x < u := hf₁ x (sU hx₁)
exact
⟨f, (f x + u) / 2, u,
fun a ha => by have := hx₂ ha; dsimp at this; linarith,
by linarith,
fun b hb => hf₂ b (tV hb)⟩
/-- A version of the **Hahn-Banach theorem**: given disjoint convex sets `s`, `t` where `s` is
closed, and `t` is compact, there is a continuous linear functional which strongly separates them.
-/
theorem geometric_hahn_banach_closed_compact (hs₁ : Convex ℝ s) (hs₂ : IsClosed s)
(ht₁ : Convex ℝ t) (ht₂ : IsCompact t) (disj : Disjoint s t) :
∃ (f : StrongDual ℝ E) (u v : ℝ), (∀ a ∈ s, f a < u) ∧ u < v ∧ ∀ b ∈ t, v < f b :=
let ⟨f, s, t, hs, st, ht⟩ := geometric_hahn_banach_compact_closed ht₁ ht₂ hs₁ hs₂ disj.symm
⟨-f, -t, -s, by simpa using ht, by simpa using st, by simpa using hs⟩
theorem geometric_hahn_banach_point_closed (ht₁ : Convex ℝ t) (ht₂ : IsClosed t) (disj : x ∉ t) :
∃ (f : StrongDual ℝ E) (u : ℝ), f x < u ∧ ∀ b ∈ t, u < f b :=
let ⟨f, _u, v, ha, hst, hb⟩ :=
geometric_hahn_banach_compact_closed (convex_singleton x) isCompact_singleton ht₁ ht₂
(disjoint_singleton_left.2 disj)
⟨f, v, hst.trans' <| ha x <| mem_singleton _, hb⟩
theorem geometric_hahn_banach_closed_point (hs₁ : Convex ℝ s) (hs₂ : IsClosed s) (disj : x ∉ s) :
∃ (f : StrongDual ℝ E) (u : ℝ), (∀ a ∈ s, f a < u) ∧ u < f x :=
let ⟨f, s, _t, ha, hst, hb⟩ :=
geometric_hahn_banach_closed_compact hs₁ hs₂ (convex_singleton x) isCompact_singleton
(disjoint_singleton_right.2 disj)
⟨f, s, ha, hst.trans <| hb x <| mem_singleton _⟩
/-- See also `NormedSpace.eq_iff_forall_dual_eq`. -/
theorem geometric_hahn_banach_point_point [T1Space E] (hxy : x ≠ y) :
∃ f : StrongDual ℝ E, f x < f y := by
obtain ⟨f, s, t, hs, st, ht⟩ :=
geometric_hahn_banach_compact_closed (convex_singleton x) isCompact_singleton
(convex_singleton y) isClosed_singleton (disjoint_singleton.2 hxy)
exact ⟨f, by linarith [hs x rfl, ht y rfl]⟩
/-- A closed convex set is the intersection of the half-spaces containing it. -/
theorem iInter_halfSpaces_eq (hs₁ : Convex ℝ s) (hs₂ : IsClosed s) :
⋂ l : StrongDual ℝ E, { x | ∃ y ∈ s, l x ≤ l y } = s := by
rw [Set.iInter_setOf]
refine Set.Subset.antisymm (fun x hx => ?_) fun x hx l => ⟨x, hx, le_rfl⟩
by_contra h
obtain ⟨l, s, hlA, hl⟩ := geometric_hahn_banach_closed_point hs₁ hs₂ h
obtain ⟨y, hy, hxy⟩ := hx l
exact ((hxy.trans_lt (hlA y hy)).trans hl).not_ge le_rfl
end
namespace RCLike
variable [RCLike 𝕜] [Module 𝕜 E] [IsScalarTower ℝ 𝕜 E]
/-- Real linear extension of continuous extension of `LinearMap.extendTo𝕜'` -/
noncomputable def extendTo𝕜'ₗ [ContinuousConstSMul 𝕜 E] : StrongDual ℝ E →ₗ[ℝ] StrongDual 𝕜 E :=
letI to𝕜 (fr : StrongDual ℝ E) : StrongDual 𝕜 E :=
{ toLinearMap := LinearMap.extendTo𝕜' fr
cont := show Continuous fun x ↦ (fr x : 𝕜) - (I : 𝕜) * (fr ((I : 𝕜) • x) : 𝕜) by fun_prop }
have h fr x : to𝕜 fr x = ((fr x : 𝕜) - (I : 𝕜) * (fr ((I : 𝕜) • x) : 𝕜)) := rfl
{ toFun := to𝕜
map_add' := by intros; ext; simp [h]; ring
map_smul' := by intros; ext; simp [h, real_smul_eq_coe_mul]; ring }
@[simp]
lemma re_extendTo𝕜'ₗ [ContinuousConstSMul 𝕜 E] (g : StrongDual ℝ E) (x : E) :
re ((extendTo𝕜'ₗ g) x : 𝕜) = g x := by
have h g (x : E) : extendTo𝕜'ₗ g x = ((g x : 𝕜) - (I : 𝕜) * (g ((I : 𝕜) • x) : 𝕜)) := rfl
simp only [h, map_sub, ofReal_re, mul_re, I_re, zero_mul, ofReal_im, mul_zero,
sub_self, sub_zero]
variable [IsTopologicalAddGroup E] [ContinuousSMul 𝕜 E]
theorem separate_convex_open_set {s : Set E}
(hs₀ : (0 : E) ∈ s) (hs₁ : Convex ℝ s) (hs₂ : IsOpen s) {x₀ : E} (hx₀ : x₀ ∉ s) :
∃ f : StrongDual 𝕜 E, re (f x₀) = 1 ∧ ∀ x ∈ s, re (f x) < 1 := by
have := IsScalarTower.continuousSMul (M := ℝ) (α := E) 𝕜
obtain ⟨g, hg⟩ := _root_.separate_convex_open_set hs₀ hs₁ hs₂ hx₀
use extendTo𝕜'ₗ g
simp only [re_extendTo𝕜'ₗ]
exact hg
theorem geometric_hahn_banach_open (hs₁ : Convex ℝ s) (hs₂ : IsOpen s) (ht : Convex ℝ t)
(disj : Disjoint s t) : ∃ (f : StrongDual 𝕜 E) (u : ℝ), (∀ a ∈ s, re (f a) < u) ∧
∀ b ∈ t, u ≤ re (f b) := by
have := IsScalarTower.continuousSMul (M := ℝ) (α := E) 𝕜
obtain ⟨f, u, h⟩ := _root_.geometric_hahn_banach_open hs₁ hs₂ ht disj
use extendTo𝕜'ₗ f
simp only [re_extendTo𝕜'ₗ]
exact Exists.intro u h
theorem geometric_hahn_banach_open_point (hs₁ : Convex ℝ s) (hs₂ : IsOpen s) (disj : x ∉ s) :
∃ f : StrongDual 𝕜 E, ∀ a ∈ s, re (f a) < re (f x) := by
have := IsScalarTower.continuousSMul (M := ℝ) (α := E) 𝕜
obtain ⟨f, h⟩ := _root_.geometric_hahn_banach_open_point hs₁ hs₂ disj
use extendTo𝕜'ₗ f
simp only [re_extendTo𝕜'ₗ]
exact fun a a_1 ↦ h a a_1
theorem geometric_hahn_banach_point_open (ht₁ : Convex ℝ t) (ht₂ : IsOpen t) (disj : x ∉ t) :
∃ f : StrongDual 𝕜 E, ∀ b ∈ t, re (f x) < re (f b) :=
let ⟨f, hf⟩ := geometric_hahn_banach_open_point ht₁ ht₂ disj
⟨-f, by simpa⟩
theorem geometric_hahn_banach_open_open (hs₁ : Convex ℝ s) (hs₂ : IsOpen s)
(ht₁ : Convex ℝ t) (ht₃ : IsOpen t) (disj : Disjoint s t) :
∃ (f : StrongDual 𝕜 E) (u : ℝ), (∀ a ∈ s, re (f a) < u) ∧ ∀ b ∈ t, u < re (f b) := by
have := IsScalarTower.continuousSMul (M := ℝ) (α := E) 𝕜
obtain ⟨f, u, h⟩ := _root_.geometric_hahn_banach_open_open hs₁ hs₂ ht₁ ht₃ disj
use extendTo𝕜'ₗ f
simp only [re_extendTo𝕜'ₗ]
exact Exists.intro u h
variable [LocallyConvexSpace ℝ E]
theorem geometric_hahn_banach_compact_closed (hs₁ : Convex ℝ s) (hs₂ : IsCompact s)
(ht₁ : Convex ℝ t) (ht₂ : IsClosed t) (disj : Disjoint s t) :
∃ (f : StrongDual 𝕜 E) (u v : ℝ), (∀ a ∈ s, re (f a) < u) ∧ u < v ∧ ∀ b ∈ t, v < re (f b) := by
have := IsScalarTower.continuousSMul (M := ℝ) (α := E) 𝕜
obtain ⟨g, u, v, h1⟩ := _root_.geometric_hahn_banach_compact_closed hs₁ hs₂ ht₁ ht₂ disj
use extendTo𝕜'ₗ g
simp only [re_extendTo𝕜'ₗ, exists_and_left]
exact ⟨u, h1.1, v, h1.2⟩
theorem geometric_hahn_banach_closed_compact (hs₁ : Convex ℝ s) (hs₂ : IsClosed s)
(ht₁ : Convex ℝ t) (ht₂ : IsCompact t) (disj : Disjoint s t) :
∃ (f : StrongDual 𝕜 E) (u v : ℝ), (∀ a ∈ s, re (f a) < u) ∧ u < v ∧ ∀ b ∈ t, v < re (f b) :=
let ⟨f, s, t, hs, st, ht⟩ := geometric_hahn_banach_compact_closed ht₁ ht₂ hs₁ hs₂ disj.symm
⟨-f, -t, -s, by simpa using ht, by simpa using st, by simpa using hs⟩
theorem geometric_hahn_banach_point_closed (ht₁ : Convex ℝ t) (ht₂ : IsClosed t)
(disj : x ∉ t) : ∃ (f : StrongDual 𝕜 E) (u : ℝ), re (f x) < u ∧ ∀ b ∈ t, u < re (f b) :=
let ⟨f, _u, v, ha, hst, hb⟩ :=
geometric_hahn_banach_compact_closed (convex_singleton x) isCompact_singleton ht₁ ht₂
(disjoint_singleton_left.2 disj)
⟨f, v, hst.trans' <| ha x <| mem_singleton _, hb⟩
theorem geometric_hahn_banach_closed_point (hs₁ : Convex ℝ s) (hs₂ : IsClosed s)
(disj : x ∉ s) : ∃ (f : StrongDual 𝕜 E) (u : ℝ), (∀ a ∈ s, re (f a) < u) ∧ u < re (f x) :=
let ⟨f, s, _t, ha, hst, hb⟩ :=
geometric_hahn_banach_closed_compact hs₁ hs₂ (convex_singleton x) isCompact_singleton
(disjoint_singleton_right.2 disj)
⟨f, s, ha, hst.trans <| hb x <| mem_singleton _⟩
theorem geometric_hahn_banach_point_point [T1Space E] (hxy : x ≠ y) :
∃ f : StrongDual 𝕜 E, re (f x) < re (f y) := by
obtain ⟨f, s, t, hs, st, ht⟩ :=
geometric_hahn_banach_compact_closed (𝕜 := 𝕜) (convex_singleton x) isCompact_singleton
(convex_singleton y) isClosed_singleton (disjoint_singleton.2 hxy)
exact ⟨f, by linarith [hs x rfl, ht y rfl]⟩
theorem iInter_halfSpaces_eq (hs₁ : Convex ℝ s) (hs₂ : IsClosed s) :
⋂ l : StrongDual 𝕜 E, { x | ∃ y ∈ s, re (l x) ≤ re (l y) } = s := by
rw [Set.iInter_setOf]
refine Set.Subset.antisymm (fun x hx => ?_) fun x hx l => ⟨x, hx, le_rfl⟩
by_contra h
obtain ⟨l, s, hlA, hl⟩ := geometric_hahn_banach_closed_point (𝕜 := 𝕜) hs₁ hs₂ h
obtain ⟨y, hy, hxy⟩ := hx l
exact ((hxy.trans_lt (hlA y hy)).trans hl).false
end RCLike |
.lake/packages/mathlib/Mathlib/Analysis/LocallyConvex/Bounded.lean | import Mathlib.GroupTheory.GroupAction.Pointwise
import Mathlib.Analysis.LocallyConvex.Basic
import Mathlib.Analysis.LocallyConvex.BalancedCoreHull
import Mathlib.Analysis.Seminorm
import Mathlib.LinearAlgebra.Basis.VectorSpace
import Mathlib.Topology.Bornology.Basic
import Mathlib.Topology.Algebra.IsUniformGroup.Basic
import Mathlib.Topology.UniformSpace.Cauchy
/-!
# Von Neumann Boundedness
This file defines natural or von Neumann bounded sets and proves elementary properties.
## Main declarations
* `Bornology.IsVonNBounded`: A set `s` is von Neumann-bounded if every neighborhood of zero
absorbs `s`.
* `Bornology.vonNBornology`: The bornology made of the von Neumann-bounded sets.
## Main results
* `Bornology.IsVonNBounded.of_topologicalSpace_le`: A coarser topology admits more
von Neumann-bounded sets.
* `Bornology.IsVonNBounded.image`: A continuous linear image of a bounded set is bounded.
* `Bornology.isVonNBounded_iff_smul_tendsto_zero`: Given any sequence `ε` of scalars which tends
to `𝓝[≠] 0`, we have that a set `S` is bounded if and only if for any sequence `x : ℕ → S`,
`ε • x` tends to 0. This shows that bounded sets are completely determined by sequences, which is
the key fact for proving that sequential continuity implies continuity for linear maps defined on
a bornological space
## References
* [Bourbaki, *Topological Vector Spaces*][bourbaki1987]
-/
variable {𝕜 𝕜' E F ι : Type*}
open Set Filter Function
open scoped Topology Pointwise
namespace Bornology
section SeminormedRing
section Zero
variable (𝕜)
variable [SeminormedRing 𝕜] [SMul 𝕜 E] [Zero E]
variable [TopologicalSpace E]
/-- A set `s` is von Neumann bounded if every neighborhood of 0 absorbs `s`. -/
def IsVonNBounded (s : Set E) : Prop :=
∀ ⦃V⦄, V ∈ 𝓝 (0 : E) → Absorbs 𝕜 V s
variable (E)
@[simp]
theorem isVonNBounded_empty : IsVonNBounded 𝕜 (∅ : Set E) := fun _ _ => Absorbs.empty
variable {𝕜 E}
theorem isVonNBounded_iff (s : Set E) : IsVonNBounded 𝕜 s ↔ ∀ V ∈ 𝓝 (0 : E), Absorbs 𝕜 V s :=
Iff.rfl
theorem _root_.Filter.HasBasis.isVonNBounded_iff {q : ι → Prop} {s : ι → Set E} {A : Set E}
(h : (𝓝 (0 : E)).HasBasis q s) : IsVonNBounded 𝕜 A ↔ ∀ i, q i → Absorbs 𝕜 (s i) A := by
refine ⟨fun hA i hi => hA (h.mem_of_mem hi), fun hA V hV => ?_⟩
rcases h.mem_iff.mp hV with ⟨i, hi, hV⟩
exact (hA i hi).mono_left hV
/-- Subsets of bounded sets are bounded. -/
theorem IsVonNBounded.subset {s₁ s₂ : Set E} (h : s₁ ⊆ s₂) (hs₂ : IsVonNBounded 𝕜 s₂) :
IsVonNBounded 𝕜 s₁ := fun _ hV => (hs₂ hV).mono_right h
@[simp]
theorem isVonNBounded_union {s t : Set E} :
IsVonNBounded 𝕜 (s ∪ t) ↔ IsVonNBounded 𝕜 s ∧ IsVonNBounded 𝕜 t := by
simp only [IsVonNBounded, absorbs_union, forall_and]
/-- The union of two bounded sets is bounded. -/
theorem IsVonNBounded.union {s₁ s₂ : Set E} (hs₁ : IsVonNBounded 𝕜 s₁) (hs₂ : IsVonNBounded 𝕜 s₂) :
IsVonNBounded 𝕜 (s₁ ∪ s₂) := isVonNBounded_union.2 ⟨hs₁, hs₂⟩
@[nontriviality]
theorem IsVonNBounded.of_boundedSpace [BoundedSpace 𝕜] {s : Set E} : IsVonNBounded 𝕜 s := fun _ _ ↦
.of_boundedSpace
@[nontriviality]
theorem IsVonNBounded.of_subsingleton [Subsingleton E] {s : Set E} : IsVonNBounded 𝕜 s :=
fun U hU ↦ .of_forall fun c ↦ calc
s ⊆ univ := subset_univ s
_ = c • U := .symm <| Subsingleton.eq_univ_of_nonempty <| (Filter.nonempty_of_mem hU).image _
@[simp]
theorem isVonNBounded_iUnion {ι : Sort*} [Finite ι] {s : ι → Set E} :
IsVonNBounded 𝕜 (⋃ i, s i) ↔ ∀ i, IsVonNBounded 𝕜 (s i) := by
simp only [IsVonNBounded, absorbs_iUnion, @forall_swap ι]
theorem isVonNBounded_biUnion {ι : Type*} {I : Set ι} (hI : I.Finite) {s : ι → Set E} :
IsVonNBounded 𝕜 (⋃ i ∈ I, s i) ↔ ∀ i ∈ I, IsVonNBounded 𝕜 (s i) := by
have _ := hI.to_subtype
rw [biUnion_eq_iUnion, isVonNBounded_iUnion, Subtype.forall]
theorem isVonNBounded_sUnion {S : Set (Set E)} (hS : S.Finite) :
IsVonNBounded 𝕜 (⋃₀ S) ↔ ∀ s ∈ S, IsVonNBounded 𝕜 s := by
rw [sUnion_eq_biUnion, isVonNBounded_biUnion hS]
end Zero
section ContinuousAdd
variable [SeminormedRing 𝕜] [AddZeroClass E] [TopologicalSpace E] [ContinuousAdd E]
[DistribSMul 𝕜 E] {s t : Set E}
protected theorem IsVonNBounded.add (hs : IsVonNBounded 𝕜 s) (ht : IsVonNBounded 𝕜 t) :
IsVonNBounded 𝕜 (s + t) := fun U hU ↦ by
rcases exists_open_nhds_zero_add_subset hU with ⟨V, hVo, hV, hVU⟩
exact ((hs <| hVo.mem_nhds hV).add (ht <| hVo.mem_nhds hV)).mono_left hVU
end ContinuousAdd
section IsTopologicalAddGroup
variable [SeminormedRing 𝕜] [AddGroup E] [TopologicalSpace E] [IsTopologicalAddGroup E]
[DistribMulAction 𝕜 E] {s t : Set E}
protected theorem IsVonNBounded.neg (hs : IsVonNBounded 𝕜 s) : IsVonNBounded 𝕜 (-s) := fun U hU ↦ by
rw [← neg_neg U]
exact (hs <| neg_mem_nhds_zero _ hU).neg_neg
@[simp]
theorem isVonNBounded_neg : IsVonNBounded 𝕜 (-s) ↔ IsVonNBounded 𝕜 s :=
⟨fun h ↦ neg_neg s ▸ h.neg, fun h ↦ h.neg⟩
alias ⟨IsVonNBounded.of_neg, _⟩ := isVonNBounded_neg
protected theorem IsVonNBounded.sub (hs : IsVonNBounded 𝕜 s) (ht : IsVonNBounded 𝕜 t) :
IsVonNBounded 𝕜 (s - t) := by
rw [sub_eq_add_neg]
exact hs.add ht.neg
end IsTopologicalAddGroup
end SeminormedRing
section MultipleTopologies
variable [SeminormedRing 𝕜] [AddCommGroup E] [Module 𝕜 E]
/-- If a topology `t'` is coarser than `t`, then any set `s` that is bounded with respect to
`t` is bounded with respect to `t'`. -/
theorem IsVonNBounded.of_topologicalSpace_le {t t' : TopologicalSpace E} (h : t ≤ t') {s : Set E}
(hs : @IsVonNBounded 𝕜 E _ _ _ t s) : @IsVonNBounded 𝕜 E _ _ _ t' s := fun _ hV =>
hs <| (le_iff_nhds t t').mp h 0 hV
end MultipleTopologies
lemma isVonNBounded_iff_tendsto_smallSets_nhds {𝕜 E : Type*} [NormedDivisionRing 𝕜]
[AddCommGroup E] [Module 𝕜 E] [TopologicalSpace E] {S : Set E} :
IsVonNBounded 𝕜 S ↔ Tendsto (· • S : 𝕜 → Set E) (𝓝 0) (𝓝 0).smallSets := by
rw [tendsto_smallSets_iff]
refine forall₂_congr fun V hV ↦ ?_
simp only [absorbs_iff_eventually_nhds_zero (mem_of_mem_nhds hV), mapsTo_iff_image_subset,
image_smul]
alias ⟨IsVonNBounded.tendsto_smallSets_nhds, _⟩ := isVonNBounded_iff_tendsto_smallSets_nhds
lemma isVonNBounded_iff_absorbing_le {𝕜 E : Type*} [NormedDivisionRing 𝕜]
[AddCommGroup E] [Module 𝕜 E] [TopologicalSpace E] {S : Set E} :
IsVonNBounded 𝕜 S ↔ Filter.absorbing 𝕜 S ≤ 𝓝 0 :=
.rfl
lemma isVonNBounded_pi_iff {𝕜 ι : Type*} {E : ι → Type*} [NormedDivisionRing 𝕜]
[∀ i, AddCommGroup (E i)] [∀ i, Module 𝕜 (E i)] [∀ i, TopologicalSpace (E i)]
{S : Set (∀ i, E i)} : IsVonNBounded 𝕜 S ↔ ∀ i, IsVonNBounded 𝕜 (eval i '' S) := by
simp_rw [isVonNBounded_iff_tendsto_smallSets_nhds, nhds_pi, Filter.pi, smallSets_iInf,
smallSets_comap_eq_comap_image, tendsto_iInf, tendsto_comap_iff, Function.comp_def,
← image_smul, image_image, eval, Pi.smul_apply, Pi.zero_apply]
section Image
variable {𝕜₁ 𝕜₂ : Type*} [NormedDivisionRing 𝕜₁] [NormedDivisionRing 𝕜₂] [AddCommGroup E]
[Module 𝕜₁ E] [AddCommGroup F] [Module 𝕜₂ F] [TopologicalSpace E] [TopologicalSpace F]
/-- A continuous linear image of a bounded set is bounded. -/
protected theorem IsVonNBounded.image {σ : 𝕜₁ →+* 𝕜₂} [RingHomSurjective σ] [RingHomIsometric σ]
{s : Set E} (hs : IsVonNBounded 𝕜₁ s) (f : E →SL[σ] F) : IsVonNBounded 𝕜₂ (f '' s) := by
have : map σ (𝓝 0) = 𝓝 0 := by
rw [σ.isometry.isEmbedding.map_nhds_eq, σ.surjective.range_eq, nhdsWithin_univ, map_zero]
have hf₀ : Tendsto f (𝓝 0) (𝓝 0) := f.continuous.tendsto' 0 0 (map_zero f)
simp only [isVonNBounded_iff_tendsto_smallSets_nhds, ← this, tendsto_map'_iff] at hs ⊢
simpa only [comp_def, image_smul_setₛₗ] using hf₀.image_smallSets.comp hs
end Image
section sequence
theorem IsVonNBounded.smul_tendsto_zero [NormedField 𝕜]
[AddCommGroup E] [Module 𝕜 E] [TopologicalSpace E]
{S : Set E} {ε : ι → 𝕜} {x : ι → E} {l : Filter ι}
(hS : IsVonNBounded 𝕜 S) (hxS : ∀ᶠ n in l, x n ∈ S) (hε : Tendsto ε l (𝓝 0)) :
Tendsto (ε • x) l (𝓝 0) :=
(hS.tendsto_smallSets_nhds.comp hε).of_smallSets <| hxS.mono fun _ ↦ smul_mem_smul_set
variable [NontriviallyNormedField 𝕜]
[AddCommGroup E] [Module 𝕜 E] [TopologicalSpace E] [ContinuousSMul 𝕜 E]
theorem isVonNBounded_of_smul_tendsto_zero {ε : ι → 𝕜} {l : Filter ι} [l.NeBot]
(hε : ∀ᶠ n in l, ε n ≠ 0) {S : Set E}
(H : ∀ x : ι → E, (∀ n, x n ∈ S) → Tendsto (ε • x) l (𝓝 0)) : IsVonNBounded 𝕜 S := by
rw [(nhds_basis_balanced 𝕜 E).isVonNBounded_iff]
by_contra! H'
rcases H' with ⟨V, ⟨hV, hVb⟩, hVS⟩
have : ∀ᶠ n in l, ∃ x : S, ε n • (x : E) ∉ V := by
filter_upwards [hε] with n hn
rw [absorbs_iff_norm] at hVS
push_neg at hVS
rcases hVS ‖(ε n)⁻¹‖ with ⟨a, haε, haS⟩
rcases Set.not_subset.mp haS with ⟨x, hxS, hx⟩
refine ⟨⟨x, hxS⟩, fun hnx => ?_⟩
rw [← Set.mem_inv_smul_set_iff₀ hn] at hnx
exact hx (hVb.smul_mono haε hnx)
rcases this.choice with ⟨x, hx⟩
refine Filter.frequently_false l (Filter.Eventually.frequently ?_)
filter_upwards [hx,
(H (_ ∘ x) fun n => (x n).2).eventually (eventually_mem_set.mpr hV)] using fun n => id
/-- Given any sequence `ε` of scalars which tends to `𝓝[≠] 0`, we have that a set `S` is bounded
if and only if for any sequence `x : ℕ → S`, `ε • x` tends to 0. This actually works for any
indexing type `ι`, but in the special case `ι = ℕ` we get the important fact that convergent
sequences fully characterize bounded sets. -/
theorem isVonNBounded_iff_smul_tendsto_zero {ε : ι → 𝕜} {l : Filter ι} [l.NeBot]
(hε : Tendsto ε l (𝓝[≠] 0)) {S : Set E} :
IsVonNBounded 𝕜 S ↔ ∀ x : ι → E, (∀ n, x n ∈ S) → Tendsto (ε • x) l (𝓝 0) :=
⟨fun hS _ hxS => hS.smul_tendsto_zero (Eventually.of_forall hxS) (le_trans hε nhdsWithin_le_nhds),
isVonNBounded_of_smul_tendsto_zero (by exact hε self_mem_nhdsWithin)⟩
end sequence
/-- If a set is von Neumann bounded with respect to a smaller field,
then it is also von Neumann bounded with respect to a larger field.
See also `Bornology.IsVonNBounded.restrict_scalars` below. -/
theorem IsVonNBounded.extend_scalars [NontriviallyNormedField 𝕜]
{E : Type*} [AddCommGroup E] [Module 𝕜 E]
(𝕝 : Type*) [NontriviallyNormedField 𝕝] [NormedAlgebra 𝕜 𝕝]
[Module 𝕝 E] [TopologicalSpace E] [ContinuousSMul 𝕝 E] [IsScalarTower 𝕜 𝕝 E]
{s : Set E} (h : IsVonNBounded 𝕜 s) : IsVonNBounded 𝕝 s := by
obtain ⟨ε, hε, hε₀⟩ : ∃ ε : ℕ → 𝕜, Tendsto ε atTop (𝓝 0) ∧ ∀ᶠ n in atTop, ε n ≠ 0 := by
simpa only [tendsto_nhdsWithin_iff] using exists_seq_tendsto (𝓝[≠] (0 : 𝕜))
refine isVonNBounded_of_smul_tendsto_zero (ε := (ε · • 1)) (by simpa) fun x hx ↦ ?_
have := h.smul_tendsto_zero (.of_forall hx) hε
simpa only [Pi.smul_def', smul_one_smul]
section NormedField
variable [NormedField 𝕜] [AddCommGroup E] [Module 𝕜 E]
variable [TopologicalSpace E] [ContinuousSMul 𝕜 E]
/-- Singletons are bounded. -/
theorem isVonNBounded_singleton (x : E) : IsVonNBounded 𝕜 ({x} : Set E) := fun _ hV =>
(absorbent_nhds_zero hV).absorbs
@[simp]
theorem isVonNBounded_insert (x : E) {s : Set E} :
IsVonNBounded 𝕜 (insert x s) ↔ IsVonNBounded 𝕜 s := by
simp only [← singleton_union, isVonNBounded_union, isVonNBounded_singleton, true_and]
protected alias ⟨_, IsVonNBounded.insert⟩ := isVonNBounded_insert
/-- Finite sets are bounded. -/
theorem _root_.Set.Finite.isVonNBounded {s : Set E} (hs : s.Finite) :
IsVonNBounded 𝕜 s := fun _ hV ↦
(absorbent_nhds_zero hV).absorbs_finite hs
section ContinuousAdd
variable [ContinuousAdd E] {s t : Set E}
protected theorem IsVonNBounded.vadd (hs : IsVonNBounded 𝕜 s) (x : E) :
IsVonNBounded 𝕜 (x +ᵥ s) := by
rw [← singleton_vadd]
-- TODO: dot notation timeouts in the next line
exact IsVonNBounded.add (isVonNBounded_singleton x) hs
@[simp]
theorem isVonNBounded_vadd (x : E) : IsVonNBounded 𝕜 (x +ᵥ s) ↔ IsVonNBounded 𝕜 s :=
⟨fun h ↦ by simpa using h.vadd (-x), fun h ↦ h.vadd x⟩
theorem IsVonNBounded.of_add_right (hst : IsVonNBounded 𝕜 (s + t)) (hs : s.Nonempty) :
IsVonNBounded 𝕜 t :=
let ⟨x, hx⟩ := hs
(isVonNBounded_vadd x).mp <| hst.subset <| image_subset_image2_right hx
theorem IsVonNBounded.of_add_left (hst : IsVonNBounded 𝕜 (s + t)) (ht : t.Nonempty) :
IsVonNBounded 𝕜 s :=
((add_comm s t).subst hst).of_add_right ht
theorem isVonNBounded_add_of_nonempty (hs : s.Nonempty) (ht : t.Nonempty) :
IsVonNBounded 𝕜 (s + t) ↔ IsVonNBounded 𝕜 s ∧ IsVonNBounded 𝕜 t :=
⟨fun h ↦ ⟨h.of_add_left ht, h.of_add_right hs⟩, and_imp.2 IsVonNBounded.add⟩
theorem isVonNBounded_add :
IsVonNBounded 𝕜 (s + t) ↔ s = ∅ ∨ t = ∅ ∨ IsVonNBounded 𝕜 s ∧ IsVonNBounded 𝕜 t := by
rcases s.eq_empty_or_nonempty with rfl | hs; · simp
rcases t.eq_empty_or_nonempty with rfl | ht; · simp
simp [hs.ne_empty, ht.ne_empty, isVonNBounded_add_of_nonempty hs ht]
@[simp]
theorem isVonNBounded_add_self : IsVonNBounded 𝕜 (s + s) ↔ IsVonNBounded 𝕜 s := by
rcases s.eq_empty_or_nonempty with rfl | hs <;> simp [isVonNBounded_add_of_nonempty, *]
theorem IsVonNBounded.of_sub_left (hst : IsVonNBounded 𝕜 (s - t)) (ht : t.Nonempty) :
IsVonNBounded 𝕜 s :=
((sub_eq_add_neg s t).subst hst).of_add_left ht.neg
end ContinuousAdd
section IsTopologicalAddGroup
variable [IsTopologicalAddGroup E] {s t : Set E}
theorem IsVonNBounded.of_sub_right (hst : IsVonNBounded 𝕜 (s - t)) (hs : s.Nonempty) :
IsVonNBounded 𝕜 t :=
(((sub_eq_add_neg s t).subst hst).of_add_right hs).of_neg
theorem isVonNBounded_sub_of_nonempty (hs : s.Nonempty) (ht : t.Nonempty) :
IsVonNBounded 𝕜 (s - t) ↔ IsVonNBounded 𝕜 s ∧ IsVonNBounded 𝕜 t := by
simp [sub_eq_add_neg, isVonNBounded_add_of_nonempty, hs, ht]
theorem isVonNBounded_sub :
IsVonNBounded 𝕜 (s - t) ↔ s = ∅ ∨ t = ∅ ∨ IsVonNBounded 𝕜 s ∧ IsVonNBounded 𝕜 t := by
simp [sub_eq_add_neg, isVonNBounded_add]
end IsTopologicalAddGroup
/-- The union of all bounded set is the whole space. -/
theorem sUnion_isVonNBounded_eq_univ : ⋃₀ setOf (IsVonNBounded 𝕜) = (Set.univ : Set E) :=
Set.eq_univ_iff_forall.mpr fun x =>
Set.mem_sUnion.mpr ⟨{x}, isVonNBounded_singleton _, Set.mem_singleton _⟩
@[deprecated (since := "2025-11-14")]
alias isVonNBounded_covers := sUnion_isVonNBounded_eq_univ
variable (𝕜 E)
-- See note [reducible non-instances]
/-- The von Neumann bornology defined by the von Neumann bounded sets.
Note that this is not registered as an instance, in order to avoid diamonds with the
metric bornology. -/
abbrev vonNBornology : Bornology E :=
Bornology.ofBounded (setOf (IsVonNBounded 𝕜)) (isVonNBounded_empty 𝕜 E)
(fun _ hs _ ht => hs.subset ht) (fun _ hs _ => hs.union) isVonNBounded_singleton
variable {E}
@[simp]
theorem isBounded_iff_isVonNBounded {s : Set E} :
@IsBounded _ (vonNBornology 𝕜 E) s ↔ IsVonNBounded 𝕜 s :=
isBounded_ofBounded_iff _
end NormedField
end Bornology
section IsUniformAddGroup
variable (𝕜) [NormedField 𝕜] [AddCommGroup E] [Module 𝕜 E]
variable [UniformSpace E] [IsUniformAddGroup E] [ContinuousSMul 𝕜 E]
theorem TotallyBounded.isVonNBounded {s : Set E} (hs : TotallyBounded s) :
Bornology.IsVonNBounded 𝕜 s := by
if h : ∃ x : 𝕜, 1 < ‖x‖ then
letI : NontriviallyNormedField 𝕜 := ⟨h⟩
rw [totallyBounded_iff_subset_finite_iUnion_nhds_zero] at hs
intro U hU
have h : Filter.Tendsto (fun x : E × E => x.fst + x.snd) (𝓝 0) (𝓝 0) :=
continuous_add.tendsto' _ _ (zero_add _)
have h' := (nhds_basis_balanced 𝕜 E).prod (nhds_basis_balanced 𝕜 E)
simp_rw [← nhds_prod_eq, id] at h'
rcases h.basis_left h' U hU with ⟨x, hx, h''⟩
rcases hs x.snd hx.2.1 with ⟨t, ht, hs⟩
refine Absorbs.mono_right ?_ hs
rw [ht.absorbs_biUnion]
have hx_fstsnd : x.fst + x.snd ⊆ U := add_subset_iff.mpr fun z1 hz1 z2 hz2 ↦
h'' <| mk_mem_prod hz1 hz2
refine fun y _ => Absorbs.mono_left ?_ hx_fstsnd
-- TODO: with dot notation, Lean timeouts on the next line. Why?
exact Absorbent.vadd_absorbs (absorbent_nhds_zero hx.1.1) hx.2.2.absorbs_self
else
haveI : BoundedSpace 𝕜 := ⟨Metric.isBounded_iff.2 ⟨1, by simp_all [dist_eq_norm]⟩⟩
exact Bornology.IsVonNBounded.of_boundedSpace
end IsUniformAddGroup
variable (𝕜) in
theorem Filter.Tendsto.isVonNBounded_range [NormedField 𝕜] [AddCommGroup E] [Module 𝕜 E]
[TopologicalSpace E] [IsTopologicalAddGroup E] [ContinuousSMul 𝕜 E]
{f : ℕ → E} {x : E} (hf : Tendsto f atTop (𝓝 x)) : Bornology.IsVonNBounded 𝕜 (range f) :=
letI := IsTopologicalAddGroup.rightUniformSpace E
haveI := isUniformAddGroup_of_addCommGroup (G := E)
hf.cauchySeq.totallyBounded_range.isVonNBounded 𝕜
variable (𝕜) in
protected theorem Bornology.IsVonNBounded.restrict_scalars_of_nontrivial
[NormedField 𝕜] [NormedRing 𝕜'] [NormedAlgebra 𝕜 𝕜'] [Nontrivial 𝕜']
[Zero E] [TopologicalSpace E]
[SMul 𝕜 E] [MulAction 𝕜' E] [IsScalarTower 𝕜 𝕜' E] {s : Set E}
(h : IsVonNBounded 𝕜' s) : IsVonNBounded 𝕜 s := by
intro V hV
refine (h hV).restrict_scalars <| AntilipschitzWith.tendsto_cobounded (K := ‖(1 : 𝕜')‖₊⁻¹) ?_
refine AntilipschitzWith.of_le_mul_nndist fun x y ↦ ?_
rw [nndist_eq_nnnorm, nndist_eq_nnnorm, ← sub_smul, nnnorm_smul, ← div_eq_inv_mul,
mul_div_cancel_right₀ _ (nnnorm_ne_zero_iff.2 one_ne_zero)]
variable (𝕜) in
protected theorem Bornology.IsVonNBounded.restrict_scalars
[NormedField 𝕜] [NormedRing 𝕜'] [NormedAlgebra 𝕜 𝕜']
[Zero E] [TopologicalSpace E]
[SMul 𝕜 E] [MulActionWithZero 𝕜' E] [IsScalarTower 𝕜 𝕜' E] {s : Set E}
(h : IsVonNBounded 𝕜' s) : IsVonNBounded 𝕜 s :=
match subsingleton_or_nontrivial 𝕜' with
| .inl _ =>
have : Subsingleton E := MulActionWithZero.subsingleton 𝕜' E
IsVonNBounded.of_subsingleton
| .inr _ =>
h.restrict_scalars_of_nontrivial _
section VonNBornologyEqMetric
namespace NormedSpace
section NormedField
variable (𝕜)
variable [NormedField 𝕜] [SeminormedAddCommGroup E] [NormedSpace 𝕜 E]
theorem isVonNBounded_of_isBounded {s : Set E} (h : Bornology.IsBounded s) :
Bornology.IsVonNBounded 𝕜 s := by
rcases h.subset_ball 0 with ⟨r, hr⟩
rw [Metric.nhds_basis_ball.isVonNBounded_iff]
rw [← ball_normSeminorm 𝕜 E] at hr ⊢
exact fun ε hε ↦ ((normSeminorm 𝕜 E).ball_zero_absorbs_ball_zero hε).mono_right hr
variable (E)
theorem isVonNBounded_ball (r : ℝ) : Bornology.IsVonNBounded 𝕜 (Metric.ball (0 : E) r) :=
isVonNBounded_of_isBounded _ Metric.isBounded_ball
theorem isVonNBounded_closedBall (r : ℝ) :
Bornology.IsVonNBounded 𝕜 (Metric.closedBall (0 : E) r) :=
isVonNBounded_of_isBounded _ Metric.isBounded_closedBall
end NormedField
variable (𝕜)
variable [NontriviallyNormedField 𝕜] [SeminormedAddCommGroup E] [NormedSpace 𝕜 E]
theorem isVonNBounded_iff {s : Set E} : Bornology.IsVonNBounded 𝕜 s ↔ Bornology.IsBounded s := by
refine ⟨fun h ↦ ?_, isVonNBounded_of_isBounded _⟩
rcases (h (Metric.ball_mem_nhds 0 zero_lt_one)).exists_pos with ⟨ρ, hρ, hρball⟩
rcases NormedField.exists_lt_norm 𝕜 ρ with ⟨a, ha⟩
specialize hρball a ha.le
rw [← ball_normSeminorm 𝕜 E, Seminorm.smul_ball_zero (norm_pos_iff.1 <| hρ.trans ha),
ball_normSeminorm] at hρball
exact Metric.isBounded_ball.subset hρball
theorem isVonNBounded_iff' {s : Set E} :
Bornology.IsVonNBounded 𝕜 s ↔ ∃ r : ℝ, ∀ x ∈ s, ‖x‖ ≤ r := by
rw [NormedSpace.isVonNBounded_iff, isBounded_iff_forall_norm_le]
theorem image_isVonNBounded_iff {α : Type*} {f : α → E} {s : Set α} :
Bornology.IsVonNBounded 𝕜 (f '' s) ↔ ∃ r : ℝ, ∀ x ∈ s, ‖f x‖ ≤ r := by
simp_rw [isVonNBounded_iff', Set.forall_mem_image]
/-- In a normed space, the von Neumann bornology (`Bornology.vonNBornology`) is equal to the
metric bornology. -/
theorem vonNBornology_eq : Bornology.vonNBornology 𝕜 E = PseudoMetricSpace.toBornology := by
rw [Bornology.ext_iff_isBounded]
intro s
rw [Bornology.isBounded_iff_isVonNBounded]
exact isVonNBounded_iff _
theorem isBounded_iff_subset_smul_ball {s : Set E} :
Bornology.IsBounded s ↔ ∃ a : 𝕜, s ⊆ a • Metric.ball (0 : E) 1 := by
rw [← isVonNBounded_iff 𝕜]
constructor
· intro h
rcases (h (Metric.ball_mem_nhds 0 zero_lt_one)).exists_pos with ⟨ρ, _, hρball⟩
rcases NormedField.exists_lt_norm 𝕜 ρ with ⟨a, ha⟩
exact ⟨a, hρball a ha.le⟩
· rintro ⟨a, ha⟩
exact ((isVonNBounded_ball 𝕜 E 1).image (a • (1 : E →L[𝕜] E))).subset ha
theorem isBounded_iff_subset_smul_closedBall {s : Set E} :
Bornology.IsBounded s ↔ ∃ a : 𝕜, s ⊆ a • Metric.closedBall (0 : E) 1 := by
constructor
· rw [isBounded_iff_subset_smul_ball 𝕜]
exact Exists.imp fun a ha => ha.trans <| Set.smul_set_mono <| Metric.ball_subset_closedBall
· rw [← isVonNBounded_iff 𝕜]
rintro ⟨a, ha⟩
exact ((isVonNBounded_closedBall 𝕜 E 1).image (a • (1 : E →L[𝕜] E))).subset ha
end NormedSpace
end VonNBornologyEqMetric
section QuasiCompleteSpace
/-- A locally convex space is quasi-complete if every closed and von Neumann bounded set is
complete. -/
class QuasiCompleteSpace (𝕜 : Type*) (E : Type*) [Zero E] [UniformSpace E] [SeminormedRing 𝕜]
[SMul 𝕜 E] : Prop where
/-- A locally convex space is quasi-complete if every closed and von Neumann bounded set is
complete. -/
quasiComplete : ∀ ⦃s : Set E⦄, Bornology.IsVonNBounded 𝕜 s → IsClosed s → IsComplete s
variable {𝕜 : Type*} {E : Type*} [Zero E] [UniformSpace E] [SeminormedRing 𝕜] [SMul 𝕜 E]
/-- A complete space is quasi-complete with respect to any scalar ring. -/
instance [CompleteSpace E] : QuasiCompleteSpace 𝕜 E where
quasiComplete _ _ := IsClosed.isComplete
/-- [Bourbaki, *Topological Vector Spaces*, III §1.6][bourbaki1987] -/
theorem isCompact_closure_of_totallyBounded_quasiComplete {E : Type*} {𝕜 : Type*} [NormedField 𝕜]
[AddCommGroup E] [Module 𝕜 E] [UniformSpace E] [IsUniformAddGroup E] [ContinuousSMul 𝕜 E]
[QuasiCompleteSpace 𝕜 E] {s : Set E} (hs : TotallyBounded s) : IsCompact (closure s) :=
hs.closure.isCompact_of_isComplete
(QuasiCompleteSpace.quasiComplete (TotallyBounded.isVonNBounded 𝕜 (TotallyBounded.closure hs))
isClosed_closure)
end QuasiCompleteSpace |
.lake/packages/mathlib/Mathlib/Analysis/LocallyConvex/WeakSpace.lean | import Mathlib.Analysis.LocallyConvex.Separation
import Mathlib.LinearAlgebra.Dual.Defs
import Mathlib.Topology.Algebra.Module.WeakDual
/-! # Closures of convex sets in locally convex spaces
This file contains the standard result that if `E` is a vector space with two locally convex
topologies, then the closure of a convex set is the same in either topology, provided they have the
same collection of continuous linear functionals. In particular, the weak closure of a convex set
in a locally convex space coincides with the closure in the original topology.
Of course, we phrase this in terms of linear maps between locally convex spaces, rather than
creating two separate topologies on the same space.
-/
variable {𝕜 E F : Type*}
variable [RCLike 𝕜] [AddCommGroup E] [Module 𝕜 E] [AddCommGroup F] [Module 𝕜 F]
variable [Module ℝ E] [IsScalarTower ℝ 𝕜 E] [Module ℝ F] [IsScalarTower ℝ 𝕜 F]
variable [TopologicalSpace E] [IsTopologicalAddGroup E] [ContinuousSMul 𝕜 E]
[LocallyConvexSpace ℝ E]
variable [TopologicalSpace F] [IsTopologicalAddGroup F] [ContinuousSMul 𝕜 F]
[LocallyConvexSpace ℝ F]
variable (𝕜) in
/-- If `E` is a locally convex space over `𝕜` (with `RCLike 𝕜`), and `s : Set E` is `ℝ`-convex, then
the closure of `s` and the weak closure of `s` coincide. More precisely, the topological closure
commutes with `toWeakSpace 𝕜 E`.
This holds more generally for any linear equivalence `e : E ≃ₗ[𝕜] F` between locally convex spaces
such that precomposition with `e` and `e.symm` preserves continuity of linear functionals. See
`LinearEquiv.image_closure_of_convex`. -/
theorem Convex.toWeakSpace_closure {s : Set E} (hs : Convex ℝ s) :
(toWeakSpace 𝕜 E) '' (closure s) = closure (toWeakSpace 𝕜 E '' s) := by
refine le_antisymm (map_continuous <| toWeakSpaceCLM 𝕜 E).continuousOn.image_closure
(Set.compl_subset_compl.mp fun x hx ↦ ?_)
obtain ⟨x, -, rfl⟩ := (toWeakSpace 𝕜 E).toEquiv.image_compl (closure s) |>.symm.subset hx
have : ContinuousSMul ℝ E := IsScalarTower.continuousSMul 𝕜
obtain ⟨f, u, hus, hux⟩ := RCLike.geometric_hahn_banach_closed_point (𝕜 := 𝕜)
hs.closure isClosed_closure (by simpa using hx)
let f' : StrongDual 𝕜 (WeakSpace 𝕜 E) :=
{ toLinearMap := (f : E →ₗ[𝕜] 𝕜).comp ((toWeakSpace 𝕜 E).symm : WeakSpace 𝕜 E →ₗ[𝕜] E)
cont := WeakBilin.eval_continuous (topDualPairing 𝕜 E).flip _ }
have hux' : u < RCLike.reCLM.comp (f'.restrictScalars ℝ) (toWeakSpace 𝕜 E x) := by simpa [f']
have hus' : closure (toWeakSpace 𝕜 E '' s) ⊆
{y | RCLike.reCLM.comp (f'.restrictScalars ℝ) y ≤ u} := by
refine closure_minimal ?_ <| isClosed_le (by fun_prop) (by fun_prop)
rintro - ⟨y, hy, rfl⟩
simpa [f'] using (hus y <| subset_closure hy).le
exact (hux'.not_ge <| hus' ·)
open ComplexOrder in
theorem toWeakSpace_closedConvexHull_eq {s : Set E} :
(toWeakSpace 𝕜 E) '' (closedConvexHull 𝕜 s) = closedConvexHull 𝕜 (toWeakSpace 𝕜 E '' s) := by
rw [closedConvexHull_eq_closure_convexHull (𝕜 := 𝕜),
((convex_convexHull 𝕜 s).lift ℝ).toWeakSpace_closure _, closedConvexHull_eq_closure_convexHull]
congr
refine LinearMap.image_convexHull (toWeakSpace 𝕜 E).toLinearMap s
/-- If `e : E →ₗ[𝕜] F` is a linear map between locally convex spaces, and `f ∘ e` is continuous
for every continuous linear functional `f : StrongDual 𝕜 F`, then `e` commutes with the closure on
convex sets. -/
theorem LinearMap.image_closure_of_convex {s : Set E} (hs : Convex ℝ s) (e : E →ₗ[𝕜] F)
(he : ∀ f : StrongDual 𝕜 F, Continuous (e.dualMap f)) :
e '' (closure s) ⊆ closure (e '' s) := by
suffices he' : Continuous (toWeakSpace 𝕜 F <| e <| (toWeakSpace 𝕜 E).symm ·) by
have h_convex : Convex ℝ (e '' s) := hs.linear_image (F := F) e
rw [← Set.image_subset_image_iff (toWeakSpace 𝕜 F).injective, h_convex.toWeakSpace_closure 𝕜]
simpa only [Set.image_image, ← hs.toWeakSpace_closure 𝕜, LinearEquiv.symm_apply_apply]
using he'.continuousOn.image_closure (s := toWeakSpace 𝕜 E '' s)
exact WeakBilin.continuous_of_continuous_eval _ fun f ↦
WeakBilin.eval_continuous _ { toLinearMap := e.dualMap f : StrongDual 𝕜 E }
/-- If `e` is a linear isomorphism between two locally convex spaces, and `e` induces (via
precomposition) an isomorphism between their continuous duals, then `e` commutes with the closure
on convex sets.
The hypotheses hold automatically for `e := toWeakSpace 𝕜 E`, see `Convex.toWeakSpace_closure`. -/
theorem LinearEquiv.image_closure_of_convex {s : Set E} (hs : Convex ℝ s) (e : E ≃ₗ[𝕜] F)
(he₁ : ∀ f : StrongDual 𝕜 F, Continuous (e.dualMap f))
(he₂ : ∀ f : StrongDual 𝕜 E, Continuous (e.symm.dualMap f)) :
e '' (closure s) = closure (e '' s) := by
refine le_antisymm ((e : E →ₗ[𝕜] F).image_closure_of_convex hs he₁) ?_
simp only [Set.le_eq_subset, ← Set.image_subset_image_iff e.symm.injective]
simpa [Set.image_image]
using (e.symm : F →ₗ[𝕜] E).image_closure_of_convex (hs.linear_image (e : E →ₗ[𝕜] F)) he₂
/-- If `e` is a linear isomorphism between two locally convex spaces, and `e` induces (via
precomposition) an isomorphism between their continuous duals, then `e` commutes with the closure
on convex sets.
The hypotheses hold automatically for `e := toWeakSpace 𝕜 E`, see `Convex.toWeakSpace_closure`. -/
theorem LinearEquiv.image_closure_of_convex' {s : Set E} (hs : Convex ℝ s) (e : E ≃ₗ[𝕜] F)
(e_dual : StrongDual 𝕜 F ≃ StrongDual 𝕜 E)
(he : ∀ f : StrongDual 𝕜 F, (e_dual f : E →ₗ[𝕜] 𝕜) = e.dualMap f) :
e '' (closure s) = closure (e '' s) := by
have he' (f : StrongDual 𝕜 E) : (e_dual.symm f : F →ₗ[𝕜] 𝕜) = e.symm.dualMap f := by
simp only [DFunLike.ext'_iff, ContinuousLinearMap.coe_coe] at he ⊢
have (g : StrongDual 𝕜 E) : ⇑g = e_dual.symm g ∘ e := by
have := he _ ▸ congr(⇑$(e_dual.apply_symm_apply g)).symm
simpa
ext x
conv_rhs => rw [LinearEquiv.dualMap_apply, ContinuousLinearMap.coe_coe, this]
simp
refine e.image_closure_of_convex hs ?_ ?_
· simpa [← he] using fun f ↦ map_continuous (e_dual f)
· simpa [← he'] using fun f ↦ map_continuous (e_dual.symm f) |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/Rademacher.lean | import Mathlib.Analysis.Calculus.LineDeriv.Measurable
import Mathlib.Analysis.Normed.Module.FiniteDimension
import Mathlib.MeasureTheory.Measure.Lebesgue.EqHaar
import Mathlib.Analysis.BoundedVariation
import Mathlib.MeasureTheory.Group.Integral
import Mathlib.Analysis.Distribution.AEEqOfIntegralContDiff
import Mathlib.MeasureTheory.Measure.Haar.Disintegration
/-!
# Rademacher's theorem: a Lipschitz function is differentiable almost everywhere
This file proves Rademacher's theorem: a Lipschitz function between finite-dimensional real vector
spaces is differentiable almost everywhere with respect to the Lebesgue measure. This is the content
of `LipschitzWith.ae_differentiableAt`. Versions for functions which are Lipschitz on sets are also
given (see `LipschitzOnWith.ae_differentiableWithinAt`).
## Implementation
There are many proofs of Rademacher's theorem. We follow the one by Morrey, which is not the most
elementary but maybe the most elegant once necessary prerequisites are set up.
* Step 0: without loss of generality, one may assume that `f` is real-valued.
* Step 1: Since a one-dimensional Lipschitz function has bounded variation, it is differentiable
almost everywhere. With a Fubini argument, it follows that given any vector `v` then `f` is ae
differentiable in the direction of `v`. See `LipschitzWith.ae_lineDifferentiableAt`.
* Step 2: the line derivative `LineDeriv ℝ f x v` is ae linear in `v`. Morrey proves this by a
duality argument, integrating against a smooth compactly supported function `g`, passing the
derivative to `g` by integration by parts, and using the linearity of the derivative of `g`.
See `LipschitzWith.ae_lineDeriv_sum_eq`.
* Step 3: consider a countable dense set `s` of directions. Almost everywhere, the function `f`
is line-differentiable in all these directions and the line derivative is linear. Approximating
any direction by a direction in `s` and using the fact that `f` is Lipschitz to control the error,
it follows that `f` is Fréchet-differentiable at these points.
See `LipschitzWith.hasFDerivAt_of_hasLineDerivAt_of_closure`.
## References
* [Pertti Mattila, Geometry of sets and measures in Euclidean spaces, Theorem 7.3][Federer1996]
-/
open Filter MeasureTheory Measure Module Metric Set Asymptotics
open scoped NNReal ENNReal Topology
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
[MeasurableSpace E] [BorelSpace E]
{F : Type*} [NormedAddCommGroup F] [NormedSpace ℝ F] {C D : ℝ≥0} {f g : E → ℝ} {s : Set E}
{μ : Measure E}
namespace LipschitzWith
/-!
### Step 1: A Lipschitz function is ae differentiable in any given direction
This follows from the one-dimensional result that a Lipschitz function on `ℝ` has bounded
variation, and is therefore ae differentiable, together with a Fubini argument.
-/
theorem memLp_lineDeriv (hf : LipschitzWith C f) (v : E) :
MemLp (fun x ↦ lineDeriv ℝ f x v) ∞ μ :=
memLp_top_of_bound (aestronglyMeasurable_lineDeriv hf.continuous μ)
(C * ‖v‖) (.of_forall fun _x ↦ norm_lineDeriv_le_of_lipschitz ℝ hf)
variable [FiniteDimensional ℝ E] [IsAddHaarMeasure μ]
theorem ae_lineDifferentiableAt
(hf : LipschitzWith C f) (v : E) :
∀ᵐ p ∂μ, LineDifferentiableAt ℝ f p v := by
let L : ℝ →L[ℝ] E := ContinuousLinearMap.smulRight (1 : ℝ →L[ℝ] ℝ) v
suffices A : ∀ p, ∀ᵐ (t : ℝ) ∂volume, LineDifferentiableAt ℝ f (p + t • v) v from
ae_mem_of_ae_add_linearMap_mem L.toLinearMap volume μ
(measurableSet_lineDifferentiableAt hf.continuous) A
intro p
have : ∀ᵐ (s : ℝ), DifferentiableAt ℝ (fun t ↦ f (p + t • v)) s :=
(hf.comp ((LipschitzWith.const p).add L.lipschitz)).ae_differentiableAt_real
filter_upwards [this] with s hs
have h's : DifferentiableAt ℝ (fun t ↦ f (p + t • v)) (s + 0) := by simpa using hs
have : DifferentiableAt ℝ (fun t ↦ s + t) 0 := differentiableAt_id.const_add _
simp only [LineDifferentiableAt]
convert h's.comp 0 this with _ t
simp only [add_assoc, Function.comp_apply, add_smul]
theorem locallyIntegrable_lineDeriv (hf : LipschitzWith C f) (v : E) :
LocallyIntegrable (fun x ↦ lineDeriv ℝ f x v) μ :=
(hf.memLp_lineDeriv v).locallyIntegrable le_top
/-!
### Step 2: the ae line derivative is linear
Surprisingly, this is the hardest step. We prove it using an elegant but slightly sophisticated
argument by Morrey, with a distributional flavor: we integrate against a smooth function, and push
the derivative to the smooth function by integration by parts. As the derivative of a smooth
function is linear, this gives the result.
-/
theorem integral_inv_smul_sub_mul_tendsto_integral_lineDeriv_mul
(hf : LipschitzWith C f) (hg : Integrable g μ) (v : E) :
Tendsto (fun (t : ℝ) ↦ ∫ x, (t⁻¹ • (f (x + t • v) - f x)) * g x ∂μ) (𝓝[>] 0)
(𝓝 (∫ x, lineDeriv ℝ f x v * g x ∂μ)) := by
apply tendsto_integral_filter_of_dominated_convergence (fun x ↦ (C * ‖v‖) * ‖g x‖)
· filter_upwards with t
apply AEStronglyMeasurable.mul ?_ hg.aestronglyMeasurable
apply aestronglyMeasurable_const.smul
apply AEStronglyMeasurable.sub _ hf.continuous.measurable.aestronglyMeasurable
apply AEMeasurable.aestronglyMeasurable
exact hf.continuous.measurable.comp_aemeasurable' (aemeasurable_id'.add_const _)
· filter_upwards [self_mem_nhdsWithin] with t (ht : 0 < t)
filter_upwards with x
calc ‖t⁻¹ • (f (x + t • v) - f x) * g x‖
= (t⁻¹ * ‖f (x + t • v) - f x‖) * ‖g x‖ := by simp [norm_mul, ht.le]
_ ≤ (t⁻¹ * (C * ‖(x + t • v) - x‖)) * ‖g x‖ := by
gcongr; exact LipschitzWith.norm_sub_le hf (x + t • v) x
_ = (C * ‖v‖) *‖g x‖ := by simp [field, norm_smul, abs_of_nonneg ht.le]
· exact hg.norm.const_mul _
· filter_upwards [hf.ae_lineDifferentiableAt v] with x hx
exact hx.hasLineDerivAt.tendsto_slope_zero_right.mul tendsto_const_nhds
theorem integral_inv_smul_sub_mul_tendsto_integral_lineDeriv_mul'
(hf : LipschitzWith C f) (h'f : HasCompactSupport f) (hg : Continuous g) (v : E) :
Tendsto (fun (t : ℝ) ↦ ∫ x, (t⁻¹ • (f (x + t • v) - f x)) * g x ∂μ) (𝓝[>] 0)
(𝓝 (∫ x, lineDeriv ℝ f x v * g x ∂μ)) := by
let K := cthickening (‖v‖) (tsupport f)
have K_compact : IsCompact K := IsCompact.cthickening h'f
apply tendsto_integral_filter_of_dominated_convergence
(K.indicator (fun x ↦ (C * ‖v‖) * ‖g x‖))
· filter_upwards with t
apply AEStronglyMeasurable.mul ?_ hg.aestronglyMeasurable
apply aestronglyMeasurable_const.smul
apply AEStronglyMeasurable.sub _ hf.continuous.measurable.aestronglyMeasurable
apply AEMeasurable.aestronglyMeasurable
exact hf.continuous.measurable.comp_aemeasurable' (aemeasurable_id'.add_const _)
· filter_upwards [Ioc_mem_nhdsGT zero_lt_one] with t ht
have t_pos : 0 < t := ht.1
filter_upwards with x
by_cases hx : x ∈ K
· calc ‖t⁻¹ • (f (x + t • v) - f x) * g x‖
= (t⁻¹ * ‖f (x + t • v) - f x‖) * ‖g x‖ := by simp [norm_mul, t_pos.le]
_ ≤ (t⁻¹ * (C * ‖(x + t • v) - x‖)) * ‖g x‖ := by
gcongr; exact LipschitzWith.norm_sub_le hf (x + t • v) x
_ = (C * ‖v‖) *‖g x‖ := by simp [field, norm_smul, abs_of_nonneg t_pos.le]
_ = K.indicator (fun x ↦ (C * ‖v‖) * ‖g x‖) x := by rw [indicator_of_mem hx]
· have A : f x = 0 := by
rw [← Function.notMem_support]
contrapose! hx
exact self_subset_cthickening _ (subset_tsupport _ hx)
have B : f (x + t • v) = 0 := by
rw [← Function.notMem_support]
contrapose! hx
apply mem_cthickening_of_dist_le _ _ (‖v‖) (tsupport f) (subset_tsupport _ hx)
simp only [dist_eq_norm, sub_add_cancel_left, norm_neg, norm_smul, Real.norm_eq_abs,
abs_of_nonneg t_pos.le]
exact mul_le_of_le_one_left (norm_nonneg v) ht.2
simp only [B, A, _root_.sub_self, smul_eq_mul, mul_zero, zero_mul, norm_zero]
exact indicator_nonneg (fun y _hy ↦ by positivity) _
· rw [integrable_indicator_iff K_compact.measurableSet]
apply ContinuousOn.integrableOn_compact K_compact
exact (Continuous.mul continuous_const hg.norm).continuousOn
· filter_upwards [hf.ae_lineDifferentiableAt v] with x hx
exact hx.hasLineDerivAt.tendsto_slope_zero_right.mul tendsto_const_nhds
/-- Integration by parts formula for the line derivative of Lipschitz functions, assuming one of
them is compactly supported. -/
theorem integral_lineDeriv_mul_eq
(hf : LipschitzWith C f) (hg : LipschitzWith D g) (h'g : HasCompactSupport g) (v : E) :
∫ x, lineDeriv ℝ f x v * g x ∂μ = ∫ x, lineDeriv ℝ g x (-v) * f x ∂μ := by
/- Write down the line derivative as the limit of `(f (x + t v) - f x) / t` and
`(g (x - t v) - g x) / t`, and therefore the integrals as limits of the corresponding integrals
thanks to the dominated convergence theorem. At fixed positive `t`, the integrals coincide
(with the change of variables `y = x + t v`), so the limits also coincide. -/
have A : Tendsto (fun (t : ℝ) ↦ ∫ x, (t⁻¹ • (f (x + t • v) - f x)) * g x ∂μ) (𝓝[>] 0)
(𝓝 (∫ x, lineDeriv ℝ f x v * g x ∂μ)) :=
integral_inv_smul_sub_mul_tendsto_integral_lineDeriv_mul
hf (hg.continuous.integrable_of_hasCompactSupport h'g) v
have B : Tendsto (fun (t : ℝ) ↦ ∫ x, (t⁻¹ • (g (x + t • (-v)) - g x)) * f x ∂μ) (𝓝[>] 0)
(𝓝 (∫ x, lineDeriv ℝ g x (-v) * f x ∂μ)) :=
integral_inv_smul_sub_mul_tendsto_integral_lineDeriv_mul' hg h'g hf.continuous (-v)
suffices S1 : ∀ (t : ℝ), ∫ x, (t⁻¹ • (f (x + t • v) - f x)) * g x ∂μ =
∫ x, (t⁻¹ • (g (x + t • (-v)) - g x)) * f x ∂μ by
simp only [S1] at A; exact tendsto_nhds_unique A B
intro t
suffices S2 : ∫ x, (f (x + t • v) - f x) * g x ∂μ = ∫ x, f x * (g (x + t • (-v)) - g x) ∂μ by
simp only [smul_eq_mul, mul_assoc, integral_const_mul, S2, mul_comm (f _)]
have S3 : ∫ x, f (x + t • v) * g x ∂μ = ∫ x, f x * g (x + t • (-v)) ∂μ := by
rw [← integral_add_right_eq_self _ (t • (-v))]; simp
simp_rw [_root_.sub_mul, _root_.mul_sub]
rw [integral_sub, integral_sub, S3]
· apply Continuous.integrable_of_hasCompactSupport
· exact hf.continuous.mul (hg.continuous.comp (continuous_add_right _))
· exact (h'g.comp_homeomorph (Homeomorph.addRight (t • (-v)))).mul_left
· exact (hf.continuous.mul hg.continuous).integrable_of_hasCompactSupport h'g.mul_left
· apply Continuous.integrable_of_hasCompactSupport
· exact (hf.continuous.comp (continuous_add_right _)).mul hg.continuous
· exact h'g.mul_left
· exact (hf.continuous.mul hg.continuous).integrable_of_hasCompactSupport h'g.mul_left
/-- The line derivative of a Lipschitz function is almost everywhere linear with respect to fixed
coefficients. -/
theorem ae_lineDeriv_sum_eq
(hf : LipschitzWith C f) {ι : Type*} (s : Finset ι) (a : ι → ℝ) (v : ι → E) :
∀ᵐ x ∂μ, lineDeriv ℝ f x (∑ i ∈ s, a i • v i) = ∑ i ∈ s, a i • lineDeriv ℝ f x (v i) := by
/- Clever argument by Morrey: integrate against a smooth compactly supported function `g`, switch
the derivative to `g` by integration by parts, and use the linearity of the derivative of `g` to
conclude that the initial integrals coincide. -/
apply ae_eq_of_integral_contDiff_smul_eq (hf.locallyIntegrable_lineDeriv _)
(locallyIntegrable_finset_sum _ (fun i hi ↦ (hf.locallyIntegrable_lineDeriv (v i)).smul (a i)))
(fun g g_smooth g_comp ↦ ?_)
simp_rw [Finset.smul_sum]
have A : ∀ i ∈ s, Integrable (fun x ↦ g x • (a i • fun x ↦ lineDeriv ℝ f x (v i)) x) μ :=
fun i hi ↦ (g_smooth.continuous.integrable_of_hasCompactSupport g_comp).smul_of_top_left
((hf.memLp_lineDeriv (v i)).const_smul (a i))
rw [integral_finset_sum _ A]
suffices S1 : ∫ x, lineDeriv ℝ f x (∑ i ∈ s, a i • v i) * g x ∂μ
= ∑ i ∈ s, a i * ∫ x, lineDeriv ℝ f x (v i) * g x ∂μ by
dsimp only [smul_eq_mul, Pi.smul_apply]
simp_rw [← mul_assoc, mul_comm _ (a _), mul_assoc, integral_const_mul, mul_comm (g _), S1]
suffices S2 : ∫ x, (∑ i ∈ s, a i * fderiv ℝ g x (v i)) * f x ∂μ =
∑ i ∈ s, a i * ∫ x, fderiv ℝ g x (v i) * f x ∂μ by
obtain ⟨D, g_lip⟩ : ∃ D, LipschitzWith D g :=
ContDiff.lipschitzWith_of_hasCompactSupport g_comp g_smooth (mod_cast le_top)
simp_rw [integral_lineDeriv_mul_eq hf g_lip g_comp]
simp_rw [(g_smooth.differentiable (mod_cast le_top)).differentiableAt.lineDeriv_eq_fderiv]
simp only [map_neg, _root_.map_sum, map_smul, smul_eq_mul, neg_mul]
simp only [integral_neg, mul_neg, Finset.sum_neg_distrib, neg_inj]
exact S2
suffices B : ∀ i ∈ s, Integrable (fun x ↦ a i * (fderiv ℝ g x (v i) * f x)) μ by
simp_rw [Finset.sum_mul, mul_assoc, integral_finset_sum s B, integral_const_mul]
intro i _hi
let L : StrongDual ℝ E → ℝ := fun f ↦ f (v i)
change Integrable (fun x ↦ a i * ((L ∘ (fderiv ℝ g)) x * f x)) μ
refine (Continuous.integrable_of_hasCompactSupport ?_ ?_).const_mul _
· exact ((g_smooth.continuous_fderiv (mod_cast le_top)).clm_apply continuous_const).mul
hf.continuous
· exact ((g_comp.fderiv ℝ).comp_left rfl).mul_right
/-!
### Step 3: construct the derivative using the line derivatives along a basis
-/
theorem ae_exists_fderiv_of_countable
(hf : LipschitzWith C f) {s : Set E} (hs : s.Countable) :
∀ᵐ x ∂μ, ∃ (L : StrongDual ℝ E), ∀ v ∈ s, HasLineDerivAt ℝ f (L v) x v := by
have B := Basis.ofVectorSpace ℝ E
have I1 : ∀ᵐ (x : E) ∂μ, ∀ v ∈ s, lineDeriv ℝ f x (∑ i, (B.repr v i) • B i) =
∑ i, B.repr v i • lineDeriv ℝ f x (B i) :=
(ae_ball_iff hs).2 (fun v _ ↦ hf.ae_lineDeriv_sum_eq _ _ _)
have I2 : ∀ᵐ (x : E) ∂μ, ∀ v ∈ s, LineDifferentiableAt ℝ f x v :=
(ae_ball_iff hs).2 (fun v _ ↦ hf.ae_lineDifferentiableAt v)
filter_upwards [I1, I2] with x hx h'x
let L : StrongDual ℝ E :=
LinearMap.toContinuousLinearMap (B.constr ℝ (fun i ↦ lineDeriv ℝ f x (B i)))
refine ⟨L, fun v hv ↦ ?_⟩
have J : L v = lineDeriv ℝ f x v := by convert (hx v hv).symm <;> simp [L, B.sum_repr v]
simpa [J] using (h'x v hv).hasLineDerivAt
omit [MeasurableSpace E] in
/-- If a Lipschitz functions has line derivatives in a dense set of directions, all of them given by
a single continuous linear map `L`, then it admits `L` as Fréchet derivative. -/
theorem hasFDerivAt_of_hasLineDerivAt_of_closure
{f : E → F} (hf : LipschitzWith C f) {s : Set E} (hs : sphere 0 1 ⊆ closure s)
{L : E →L[ℝ] F} {x : E} (hL : ∀ v ∈ s, HasLineDerivAt ℝ f (L v) x v) :
HasFDerivAt f L x := by
rw [hasFDerivAt_iff_isLittleO_nhds_zero, isLittleO_iff]
intro ε εpos
obtain ⟨δ, δpos, hδ⟩ : ∃ δ, 0 < δ ∧ (C + ‖L‖ + 1) * δ = ε :=
⟨ε / (C + ‖L‖ + 1), by positivity, mul_div_cancel₀ ε (by positivity)⟩
obtain ⟨q, hqs, q_fin, hq⟩ : ∃ q, q ⊆ s ∧ q.Finite ∧ sphere 0 1 ⊆ ⋃ y ∈ q, ball y δ := by
have : sphere 0 1 ⊆ ⋃ y ∈ s, ball y δ := by
apply hs.trans (fun z hz ↦ ?_)
obtain ⟨y, ys, hy⟩ : ∃ y ∈ s, dist z y < δ := Metric.mem_closure_iff.1 hz δ δpos
exact mem_biUnion ys hy
exact (isCompact_sphere 0 1).elim_finite_subcover_image (fun y _hy ↦ isOpen_ball) this
have I : ∀ᶠ t in 𝓝 (0 : ℝ), ∀ v ∈ q, ‖f (x + t • v) - f x - t • L v‖ ≤ δ * ‖t‖ := by
apply (Finite.eventually_all q_fin).2 (fun v hv ↦ ?_)
apply Asymptotics.IsLittleO.def ?_ δpos
exact hasLineDerivAt_iff_isLittleO_nhds_zero.1 (hL v (hqs hv))
obtain ⟨r, r_pos, hr⟩ : ∃ (r : ℝ), 0 < r ∧ ∀ (t : ℝ), ‖t‖ < r →
∀ v ∈ q, ‖f (x + t • v) - f x - t • L v‖ ≤ δ * ‖t‖ := by
rcases Metric.mem_nhds_iff.1 I with ⟨r, r_pos, hr⟩
exact ⟨r, r_pos, fun t ht v hv ↦ hr (mem_ball_zero_iff.2 ht) v hv⟩
apply Metric.mem_nhds_iff.2 ⟨r, r_pos, fun v hv ↦ ?_⟩
rcases eq_or_ne v 0 with rfl | v_ne
· simp
obtain ⟨w, ρ, w_mem, hvw, hρ⟩ : ∃ w ρ, w ∈ sphere 0 1 ∧ v = ρ • w ∧ ρ = ‖v‖ := by
refine ⟨‖v‖⁻¹ • v, ‖v‖, by simp [norm_smul, inv_mul_cancel₀ (norm_ne_zero_iff.2 v_ne)], ?_, rfl⟩
simp [smul_smul, mul_inv_cancel₀ (norm_ne_zero_iff.2 v_ne)]
have norm_rho : ‖ρ‖ = ρ := by rw [hρ, norm_norm]
have rho_pos : 0 ≤ ρ := by simp [hρ]
obtain ⟨y, yq, hy⟩ : ∃ y ∈ q, ‖w - y‖ < δ := by simpa [← dist_eq_norm] using hq w_mem
have : ‖y - w‖ < δ := by rwa [norm_sub_rev]
calc ‖f (x + v) - f x - L v‖
= ‖f (x + ρ • w) - f x - ρ • L w‖ := by simp [hvw]
_ = ‖(f (x + ρ • w) - f (x + ρ • y)) + (ρ • L y - ρ • L w)
+ (f (x + ρ • y) - f x - ρ • L y)‖ := by congr; abel
_ ≤ ‖f (x + ρ • w) - f (x + ρ • y)‖ + ‖ρ • L y - ρ • L w‖
+ ‖f (x + ρ • y) - f x - ρ • L y‖ := norm_add₃_le
_ ≤ C * ‖(x + ρ • w) - (x + ρ • y)‖ + ρ * (‖L‖ * ‖y - w‖) + δ * ρ := by
gcongr
· exact hf.norm_sub_le _ _
· rw [← smul_sub, norm_smul, norm_rho]
gcongr
exact L.lipschitz.norm_sub_le _ _
· conv_rhs => rw [← norm_rho]
apply hr _ _ _ yq
simpa [norm_rho, hρ] using hv
_ ≤ C * (ρ * δ) + ρ * (‖L‖ * δ) + δ * ρ := by
simp only [add_sub_add_left_eq_sub, ← smul_sub, norm_smul, norm_rho]; gcongr
_ = ((C + ‖L‖ + 1) * δ) * ρ := by ring
_ = ε * ‖v‖ := by rw [hδ, hρ]
/-- A real-valued function on a finite-dimensional space which is Lipschitz is
differentiable almost everywere. Superseded by
`LipschitzWith.ae_differentiableAt` which works for functions taking value in any
finite-dimensional space. -/
theorem ae_differentiableAt_of_real (hf : LipschitzWith C f) :
∀ᵐ x ∂μ, DifferentiableAt ℝ f x := by
obtain ⟨s, s_count, s_dense⟩ : ∃ (s : Set E), s.Countable ∧ Dense s :=
TopologicalSpace.exists_countable_dense E
have hs : sphere 0 1 ⊆ closure s := by rw [s_dense.closure_eq]; exact subset_univ _
filter_upwards [hf.ae_exists_fderiv_of_countable s_count]
rintro x ⟨L, hL⟩
exact (hf.hasFDerivAt_of_hasLineDerivAt_of_closure hs hL).differentiableAt
end LipschitzWith
variable [FiniteDimensional ℝ E] [FiniteDimensional ℝ F] [IsAddHaarMeasure μ]
namespace LipschitzOnWith
/-- A real-valued function on a finite-dimensional space which is Lipschitz on a set is
differentiable almost everywere in this set. Superseded by
`LipschitzOnWith.ae_differentiableWithinAt_of_mem` which works for functions taking value in any
finite-dimensional space. -/
theorem ae_differentiableWithinAt_of_mem_of_real (hf : LipschitzOnWith C f s) :
∀ᵐ x ∂μ, x ∈ s → DifferentiableWithinAt ℝ f s x := by
obtain ⟨g, g_lip, hg⟩ : ∃ (g : E → ℝ), LipschitzWith C g ∧ EqOn f g s := hf.extend_real
filter_upwards [g_lip.ae_differentiableAt_of_real] with x hx xs
exact hx.differentiableWithinAt.congr hg (hg xs)
/-- A function on a finite-dimensional space which is Lipschitz on a set and taking values in a
product space is differentiable almost everywere in this set. Superseded by
`LipschitzOnWith.ae_differentiableWithinAt_of_mem` which works for functions taking value in any
finite-dimensional space. -/
theorem ae_differentiableWithinAt_of_mem_pi
{ι : Type*} [Fintype ι] {f : E → ι → ℝ} {s : Set E}
(hf : LipschitzOnWith C f s) : ∀ᵐ x ∂μ, x ∈ s → DifferentiableWithinAt ℝ f s x := by
have A : ∀ i : ι, LipschitzWith 1 (fun x : ι → ℝ ↦ x i) := fun i => LipschitzWith.eval i
have : ∀ i : ι, ∀ᵐ x ∂μ, x ∈ s → DifferentiableWithinAt ℝ (fun x : E ↦ f x i) s x := fun i ↦ by
apply ae_differentiableWithinAt_of_mem_of_real
exact LipschitzWith.comp_lipschitzOnWith (A i) hf
filter_upwards [ae_all_iff.2 this] with x hx xs
exact differentiableWithinAt_pi.2 (fun i ↦ hx i xs)
/-- *Rademacher's theorem*: a function between finite-dimensional real vector spaces which is
Lipschitz on a set is differentiable almost everywere in this set. -/
theorem ae_differentiableWithinAt_of_mem {f : E → F} (hf : LipschitzOnWith C f s) :
∀ᵐ x ∂μ, x ∈ s → DifferentiableWithinAt ℝ f s x := by
have A := (Basis.ofVectorSpace ℝ F).equivFun.toContinuousLinearEquiv
suffices H : ∀ᵐ x ∂μ, x ∈ s → DifferentiableWithinAt ℝ (A ∘ f) s x by
filter_upwards [H] with x hx xs
have : f = (A.symm ∘ A) ∘ f := by
simp only [ContinuousLinearEquiv.symm_comp_self, Function.id_comp]
rw [this]
exact A.symm.differentiableAt.comp_differentiableWithinAt x (hx xs)
apply ae_differentiableWithinAt_of_mem_pi
exact A.lipschitz.comp_lipschitzOnWith hf
/-- *Rademacher's theorem*: a function between finite-dimensional real vector spaces which is
Lipschitz on a set is differentiable almost everywere in this set. -/
theorem ae_differentiableWithinAt {f : E → F} (hf : LipschitzOnWith C f s)
(hs : MeasurableSet s) :
∀ᵐ x ∂(μ.restrict s), DifferentiableWithinAt ℝ f s x := by
rw [ae_restrict_iff' hs]
exact hf.ae_differentiableWithinAt_of_mem
end LipschitzOnWith
/-- *Rademacher's theorem*: a Lipschitz function between finite-dimensional real vector spaces is
differentiable almost everywhere. -/
theorem LipschitzWith.ae_differentiableAt {f : E → F} (h : LipschitzWith C f) :
∀ᵐ x ∂μ, DifferentiableAt ℝ f x := by
rw [← lipschitzOnWith_univ] at h
simpa [differentiableWithinAt_univ] using h.ae_differentiableWithinAt_of_mem
/-- In a real finite-dimensional normed vector space,
the norm is almost everywhere differentiable. -/
theorem ae_differentiableAt_norm :
∀ᵐ x ∂μ, DifferentiableAt ℝ (‖·‖) x := lipschitzWith_one_norm.ae_differentiableAt
omit [MeasurableSpace E] in
/-- In a real finite-dimensional normed vector space,
the set of points where the norm is differentiable at is dense. -/
theorem dense_differentiableAt_norm :
Dense {x : E | DifferentiableAt ℝ (‖·‖) x} :=
let _ : MeasurableSpace E := borel E
have _ : BorelSpace E := ⟨rfl⟩
let w := Basis.ofVectorSpace ℝ E
MeasureTheory.Measure.dense_of_ae (ae_differentiableAt_norm (μ := w.addHaar)) |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/UniformLimitsDeriv.lean | import Mathlib.Analysis.Calculus.MeanValue
import Mathlib.Analysis.Normed.Module.RCLike.Basic
import Mathlib.Order.Filter.Curry
/-!
# Swapping limits and derivatives via uniform convergence
The purpose of this file is to prove that the derivative of the pointwise limit of a sequence of
functions is the pointwise limit of the functions' derivatives when the derivatives converge
_uniformly_. The formal statement appears as `hasFDerivAt_of_tendstoLocallyUniformlyOn`.
## Main statements
* `uniformCauchySeqOnFilter_of_fderiv`: If
1. `f : ℕ → E → G` is a sequence of functions which have derivatives
`f' : ℕ → E → (E →L[𝕜] G)` on a neighborhood of `x`,
2. the functions `f` converge at `x`, and
3. the derivatives `f'` form a Cauchy sequence uniformly on a neighborhood of `x`,
then the `f` form a Cauchy sequence _uniformly_ on a neighborhood of `x`
* `hasFDerivAt_of_tendstoUniformlyOnFilter` : Suppose (1), (2), and (3) above are true. Let
`g` (resp. `g'`) be the limiting function of the `f` (resp. `g'`). Then `f'` is the derivative of
`g` on a neighborhood of `x`
* `hasFDerivAt_of_tendstoUniformlyOn`: An often-easier-to-use version of the above theorem when
*all* the derivatives exist and functions converge on a common open set and the derivatives
converge uniformly there.
Each of the above statements also has variations that support `deriv` instead of `fderiv`.
## Implementation notes
Our technique for proving the main result is the famous "`ε / 3` proof." In words, you can find it
explained, for instance, at [this StackExchange post](https://math.stackexchange.com/questions/214218/uniform-convergence-of-derivatives-tao-14-2-7).
The subtlety is that we want to prove that the difference quotients of the `g` converge to the `g'`.
That is, we want to prove something like:
```
∀ ε > 0, ∃ δ > 0, ∀ y ∈ B_δ(x), |y - x|⁻¹ * |(g y - g x) - g' x (y - x)| < ε.
```
To do so, we will need to introduce a pair of quantifiers
```lean
∀ ε > 0, ∃ N, ∀ n ≥ N, ∃ δ > 0, ∀ y ∈ B_δ(x), |y - x|⁻¹ * |(g y - g x) - g' x (y - x)| < ε.
```
So how do we write this in terms of filters? Well, the initial definition of the derivative is
```lean
tendsto (|y - x|⁻¹ * |(g y - g x) - g' x (y - x)|) (𝓝 x) (𝓝 0)
```
There are two ways we might introduce `n`. We could do:
```lean
∀ᶠ (n : ℕ) in atTop, Tendsto (|y - x|⁻¹ * |(g y - g x) - g' x (y - x)|) (𝓝 x) (𝓝 0)
```
but this is equivalent to the quantifier order `∃ N, ∀ n ≥ N, ∀ ε > 0, ∃ δ > 0, ∀ y ∈ B_δ(x)`,
which _implies_ our desired `∀ ∃ ∀ ∃ ∀` but is _not_ equivalent to it. On the other hand, we might
try
```lean
Tendsto (|y - x|⁻¹ * |(g y - g x) - g' x (y - x)|) (atTop ×ˢ 𝓝 x) (𝓝 0)
```
but this is equivalent to the quantifier order `∀ ε > 0, ∃ N, ∃ δ > 0, ∀ n ≥ N, ∀ y ∈ B_δ(x)`, which
again _implies_ our desired `∀ ∃ ∀ ∃ ∀` but is not equivalent to it.
So to get the quantifier order we want, we need to introduce a new filter construction, which we
call a "curried filter"
```lean
Tendsto (|y - x|⁻¹ * |(g y - g x) - g' x (y - x)|) (atTop.curry (𝓝 x)) (𝓝 0)
```
Then the above implications are `Filter.Tendsto.curry` and
`Filter.Tendsto.mono_left Filter.curry_le_prod`. We will use both of these deductions as part of
our proof.
We note that if you loosen the assumptions of the main theorem then the proof becomes quite a bit
easier. In particular, if you assume there is a common neighborhood `s` where all of the three
assumptions of `hasFDerivAt_of_tendstoUniformlyOnFilter` hold and that the `f'` are
continuous, then you can avoid the mean value theorem and much of the work around curried filters.
## Tags
uniform convergence, limits of derivatives
-/
open Filter
open scoped uniformity Filter Topology
section LimitsOfDerivatives
variable {ι : Type*} {l : Filter ι} {E : Type*} [NormedAddCommGroup E] {𝕜 : Type*}
[NontriviallyNormedField 𝕜] [IsRCLikeNormedField 𝕜]
[NormedSpace 𝕜 E] {G : Type*} [NormedAddCommGroup G] [NormedSpace 𝕜 G] {f : ι → E → G}
{g : E → G} {f' : ι → E → E →L[𝕜] G} {g' : E → E →L[𝕜] G} {x : E}
/-- If a sequence of functions real or complex functions are eventually differentiable on a
neighborhood of `x`, they are Cauchy _at_ `x`, and their derivatives
are a uniform Cauchy sequence in a neighborhood of `x`, then the functions form a uniform Cauchy
sequence in a neighborhood of `x`. -/
theorem uniformCauchySeqOnFilter_of_fderiv (hf' : UniformCauchySeqOnFilter f' l (𝓝 x))
(hf : ∀ᶠ n : ι × E in l ×ˢ 𝓝 x, HasFDerivAt (f n.1) (f' n.1 n.2) n.2)
(hfg : Cauchy (map (fun n => f n x) l)) : UniformCauchySeqOnFilter f l (𝓝 x) := by
letI : RCLike 𝕜 := IsRCLikeNormedField.rclike 𝕜
letI : NormedSpace ℝ E := NormedSpace.restrictScalars ℝ 𝕜 _
rw [SeminormedAddGroup.uniformCauchySeqOnFilter_iff_tendstoUniformlyOnFilter_zero] at hf' ⊢
suffices
TendstoUniformlyOnFilter (fun (n : ι × ι) (z : E) => f n.1 z - f n.2 z - (f n.1 x - f n.2 x)) 0
(l ×ˢ l) (𝓝 x) ∧
TendstoUniformlyOnFilter (fun (n : ι × ι) (_ : E) => f n.1 x - f n.2 x) 0 (l ×ˢ l) (𝓝 x) by
have := this.1.add this.2
rw [add_zero] at this
exact this.congr (by simp)
constructor
· -- This inequality follows from the mean value theorem. To apply it, we will need to shrink our
-- neighborhood to small enough ball
rw [Metric.tendstoUniformlyOnFilter_iff] at hf' ⊢
intro ε hε
have := (tendsto_swap4_prod.eventually (hf.prod_mk hf)).diag_of_prod_right
obtain ⟨a, b, c, d, e⟩ := eventually_prod_iff.1 ((hf' ε hε).and this)
obtain ⟨R, hR, hR'⟩ := Metric.nhds_basis_ball.eventually_iff.mp d
let r := min 1 R
have hr : 0 < r := by simp [r, hR]
have hr' : ∀ ⦃y : E⦄, y ∈ Metric.ball x r → c y := fun y hy =>
hR' (lt_of_lt_of_le (Metric.mem_ball.mp hy) (min_le_right _ _))
have hxy : ∀ y : E, y ∈ Metric.ball x r → ‖y - x‖ < 1 := by
intro y hy
rw [Metric.mem_ball, dist_eq_norm] at hy
exact lt_of_lt_of_le hy (min_le_left _ _)
have hxyε : ∀ y : E, y ∈ Metric.ball x r → ε * ‖y - x‖ < ε := by
intro y hy
exact (mul_lt_iff_lt_one_right hε.lt).mpr (hxy y hy)
-- With a small ball in hand, apply the mean value theorem
refine
eventually_prod_iff.mpr
⟨_, b, fun e : E => Metric.ball x r e,
eventually_mem_set.mpr (Metric.nhds_basis_ball.mem_of_mem hr), fun {n} hn {y} hy => ?_⟩
simp only [Pi.zero_apply, dist_zero_left] at e ⊢
refine lt_of_le_of_lt ?_ (hxyε y hy)
exact
Convex.norm_image_sub_le_of_norm_hasFDerivWithin_le
(fun y hy => ((e hn (hr' hy)).2.1.sub (e hn (hr' hy)).2.2).hasFDerivWithinAt)
(fun y hy => (e hn (hr' hy)).1.le) (convex_ball x r) (Metric.mem_ball_self hr) hy
· -- This is just `hfg` run through `eventually_prod_iff`
refine Metric.tendstoUniformlyOnFilter_iff.mpr fun ε hε => ?_
obtain ⟨t, ht, ht'⟩ := (Metric.cauchy_iff.mp hfg).2 ε hε
exact
eventually_prod_iff.mpr
⟨fun n : ι × ι => f n.1 x ∈ t ∧ f n.2 x ∈ t,
eventually_prod_iff.mpr ⟨_, ht, _, ht, fun {n} hn {n'} hn' => ⟨hn, hn'⟩⟩,
fun _ => True,
by simp,
fun {n} hn {y} _ => by simpa [norm_sub_rev, dist_eq_norm] using ht' _ hn.1 _ hn.2⟩
/-- A variant of the second fundamental theorem of calculus (FTC-2): If a sequence of functions
between real or complex normed spaces are differentiable on a ball centered at `x`, they
form a Cauchy sequence _at_ `x`, and their derivatives are Cauchy uniformly on the ball, then the
functions form a uniform Cauchy sequence on the ball.
NOTE: The fact that we work on a ball is typically all that is necessary to work with power series
and Dirichlet series (our primary use case). However, this can be generalized by replacing the ball
with any connected, bounded, open set and replacing uniform convergence with local uniform
convergence. See `cauchy_map_of_uniformCauchySeqOn_fderiv`.
-/
theorem uniformCauchySeqOn_ball_of_fderiv {r : ℝ} (hf' : UniformCauchySeqOn f' l (Metric.ball x r))
(hf : ∀ n : ι, ∀ y : E, y ∈ Metric.ball x r → HasFDerivAt (f n) (f' n y) y)
(hfg : Cauchy (map (fun n => f n x) l)) : UniformCauchySeqOn f l (Metric.ball x r) := by
letI : RCLike 𝕜 := IsRCLikeNormedField.rclike 𝕜
letI : NormedSpace ℝ E := NormedSpace.restrictScalars ℝ 𝕜 _
have : NeBot l := (cauchy_map_iff.1 hfg).1
rcases le_or_gt r 0 with (hr | hr)
· simp only [Metric.ball_eq_empty.2 hr, UniformCauchySeqOn, Set.mem_empty_iff_false,
IsEmpty.forall_iff, eventually_const, imp_true_iff]
rw [SeminormedAddGroup.uniformCauchySeqOn_iff_tendstoUniformlyOn_zero] at hf' ⊢
suffices
TendstoUniformlyOn (fun (n : ι × ι) (z : E) => f n.1 z - f n.2 z - (f n.1 x - f n.2 x)) 0
(l ×ˢ l) (Metric.ball x r) ∧
TendstoUniformlyOn (fun (n : ι × ι) (_ : E) => f n.1 x - f n.2 x) 0
(l ×ˢ l) (Metric.ball x r) by
have := this.1.add this.2
rw [add_zero] at this
refine this.congr ?_
filter_upwards with n z _ using (by simp)
constructor
· -- This inequality follows from the mean value theorem
rw [Metric.tendstoUniformlyOn_iff] at hf' ⊢
intro ε hε
obtain ⟨q, hqpos, hq⟩ : ∃ q : ℝ, 0 < q ∧ q * r < ε := by
simp_rw [mul_comm]
exact exists_pos_mul_lt hε.lt r
apply (hf' q hqpos.gt).mono
intro n hn y hy
simp_rw [dist_eq_norm, Pi.zero_apply, zero_sub, norm_neg] at hn ⊢
have mvt :=
Convex.norm_image_sub_le_of_norm_hasFDerivWithin_le
(fun z hz => ((hf n.1 z hz).sub (hf n.2 z hz)).hasFDerivWithinAt) (fun z hz => (hn z hz).le)
(convex_ball x r) (Metric.mem_ball_self hr) hy
refine lt_of_le_of_lt mvt ?_
have : q * ‖y - x‖ < q * r :=
mul_lt_mul' rfl.le (by simpa only [dist_eq_norm] using Metric.mem_ball.mp hy) (norm_nonneg _)
hqpos
exact this.trans hq
· -- This is just `hfg` run through `eventually_prod_iff`
refine Metric.tendstoUniformlyOn_iff.mpr fun ε hε => ?_
obtain ⟨t, ht, ht'⟩ := (Metric.cauchy_iff.mp hfg).2 ε hε
rw [eventually_prod_iff]
refine ⟨fun n => f n x ∈ t, ht, fun n => f n x ∈ t, ht, ?_⟩
intro n hn n' hn' z _
rw [dist_eq_norm, Pi.zero_apply, zero_sub, norm_neg, ← dist_eq_norm]
exact ht' _ hn _ hn'
/-- If a sequence of functions between real or complex normed spaces are differentiable on a
preconnected open set, they form a Cauchy sequence _at_ `x`, and their derivatives are Cauchy
uniformly on the set, then the functions form a Cauchy sequence at any point in the set. -/
theorem cauchy_map_of_uniformCauchySeqOn_fderiv {s : Set E} (hs : IsOpen s) (h's : IsPreconnected s)
(hf' : UniformCauchySeqOn f' l s) (hf : ∀ n : ι, ∀ y : E, y ∈ s → HasFDerivAt (f n) (f' n y) y)
{x₀ x : E} (hx₀ : x₀ ∈ s) (hx : x ∈ s) (hfg : Cauchy (map (fun n => f n x₀) l)) :
Cauchy (map (fun n => f n x) l) := by
have : NeBot l := (cauchy_map_iff.1 hfg).1
let t := { y | y ∈ s ∧ Cauchy (map (fun n => f n y) l) }
suffices H : s ⊆ t from (H hx).2
have A : ∀ x ε, x ∈ t → Metric.ball x ε ⊆ s → Metric.ball x ε ⊆ t := fun x ε xt hx y hy =>
⟨hx hy,
(uniformCauchySeqOn_ball_of_fderiv (hf'.mono hx) (fun n y hy => hf n y (hx hy))
xt.2).cauchy_map
hy⟩
have open_t : IsOpen t := by
rw [Metric.isOpen_iff]
intro x hx
rcases Metric.isOpen_iff.1 hs x hx.1 with ⟨ε, εpos, hε⟩
exact ⟨ε, εpos, A x ε hx hε⟩
have st_nonempty : (s ∩ t).Nonempty := ⟨x₀, hx₀, ⟨hx₀, hfg⟩⟩
suffices H : closure t ∩ s ⊆ t from h's.subset_of_closure_inter_subset open_t st_nonempty H
rintro x ⟨xt, xs⟩
obtain ⟨ε, εpos, hε⟩ : ∃ (ε : ℝ), ε > 0 ∧ Metric.ball x ε ⊆ s := Metric.isOpen_iff.1 hs x xs
obtain ⟨y, yt, hxy⟩ : ∃ (y : E), y ∈ t ∧ dist x y < ε / 2 :=
Metric.mem_closure_iff.1 xt _ (half_pos εpos)
have B : Metric.ball y (ε / 2) ⊆ Metric.ball x ε := by
apply Metric.ball_subset_ball'; rw [dist_comm]; linarith
exact A y (ε / 2) yt (B.trans hε) (Metric.mem_ball.2 hxy)
/-- If `f_n → g` pointwise and the derivatives `(f_n)' → h` _uniformly_ converge, then
in fact for a fixed `y`, the difference quotients `‖z - y‖⁻¹ • (f_n z - f_n y)` converge
_uniformly_ to `‖z - y‖⁻¹ • (g z - g y)` -/
theorem difference_quotients_converge_uniformly
{E : Type*} [NormedAddCommGroup E] {𝕜 : Type*} [RCLike 𝕜]
[NormedSpace 𝕜 E] {G : Type*} [NormedAddCommGroup G] [NormedSpace 𝕜 G] {f : ι → E → G}
{g : E → G} {f' : ι → E → E →L[𝕜] G} {g' : E → E →L[𝕜] G} {x : E}
(hf' : TendstoUniformlyOnFilter f' g' l (𝓝 x))
(hf : ∀ᶠ n : ι × E in l ×ˢ 𝓝 x, HasFDerivAt (f n.1) (f' n.1 n.2) n.2)
(hfg : ∀ᶠ y : E in 𝓝 x, Tendsto (fun n => f n y) l (𝓝 (g y))) :
TendstoUniformlyOnFilter (fun n : ι => fun y : E => (‖y - x‖⁻¹ : 𝕜) • (f n y - f n x))
(fun y : E => (‖y - x‖⁻¹ : 𝕜) • (g y - g x)) l (𝓝 x) := by
let A : NormedSpace ℝ E := NormedSpace.restrictScalars ℝ 𝕜 _
refine
UniformCauchySeqOnFilter.tendstoUniformlyOnFilter_of_tendsto ?_
((hfg.and (eventually_const.mpr hfg.self_of_nhds)).mono fun y hy =>
(hy.1.sub hy.2).const_smul _)
rw [SeminormedAddGroup.uniformCauchySeqOnFilter_iff_tendstoUniformlyOnFilter_zero]
rw [Metric.tendstoUniformlyOnFilter_iff]
have hfg' := hf'.uniformCauchySeqOnFilter
rw [SeminormedAddGroup.uniformCauchySeqOnFilter_iff_tendstoUniformlyOnFilter_zero] at hfg'
rw [Metric.tendstoUniformlyOnFilter_iff] at hfg'
intro ε hε
obtain ⟨q, hqpos, hqε⟩ := exists_pos_rat_lt hε
specialize hfg' (q : ℝ) (by simp [hqpos])
have := (tendsto_swap4_prod.eventually (hf.prod_mk hf)).diag_of_prod_right
obtain ⟨a, b, c, d, e⟩ := eventually_prod_iff.1 (hfg'.and this)
obtain ⟨r, hr, hr'⟩ := Metric.nhds_basis_ball.eventually_iff.mp d
rw [eventually_prod_iff]
refine
⟨_, b, fun e : E => Metric.ball x r e,
eventually_mem_set.mpr (Metric.nhds_basis_ball.mem_of_mem hr), fun {n} hn {y} hy => ?_⟩
simp only [Pi.zero_apply, dist_zero_left]
rw [← smul_sub, norm_smul, norm_inv, RCLike.norm_coe_norm]
refine lt_of_le_of_lt ?_ hqε
by_cases hyz' : x = y; · simp [hyz', hqpos.le]
have hyz : 0 < ‖y - x‖ := by rw [norm_pos_iff]; intro hy'; exact hyz' (eq_of_sub_eq_zero hy').symm
rw [inv_mul_le_iff₀ hyz, mul_comm, sub_sub_sub_comm]
simp only [Pi.zero_apply, dist_zero_left] at e
refine
Convex.norm_image_sub_le_of_norm_hasFDerivWithin_le
(fun y hy => ((e hn (hr' hy)).2.1.sub (e hn (hr' hy)).2.2).hasFDerivWithinAt)
(fun y hy => (e hn (hr' hy)).1.le) (convex_ball x r) (Metric.mem_ball_self hr) hy
/-- `(d/dx) lim_{n → ∞} f n x = lim_{n → ∞} f' n x` when the `f' n` converge
_uniformly_ to their limit at `x`.
In words the assumptions mean the following:
* `hf'`: The `f'` converge "uniformly at" `x` to `g'`. This does not mean that the `f' n` even
converge away from `x`!
* `hf`: For all `(y, n)` with `y` sufficiently close to `x` and `n` sufficiently large, `f' n` is
the derivative of `f n`
* `hfg`: The `f n` converge pointwise to `g` on a neighborhood of `x` -/
theorem hasFDerivAt_of_tendstoUniformlyOnFilter [NeBot l]
(hf' : TendstoUniformlyOnFilter f' g' l (𝓝 x))
(hf : ∀ᶠ n : ι × E in l ×ˢ 𝓝 x, HasFDerivAt (f n.1) (f' n.1 n.2) n.2)
(hfg : ∀ᶠ y in 𝓝 x, Tendsto (fun n => f n y) l (𝓝 (g y))) : HasFDerivAt g (g' x) x := by
letI : RCLike 𝕜 := IsRCLikeNormedField.rclike 𝕜
-- The proof strategy follows several steps:
-- 1. The quantifiers in the definition of the derivative are
-- `∀ ε > 0, ∃ δ > 0, ∀ y ∈ B_δ(x)`. We will introduce a quantifier in the middle:
-- `∀ ε > 0, ∃ N, ∀ n ≥ N, ∃ δ > 0, ∀ y ∈ B_δ(x)` which will allow us to introduce the
-- `f(') n`
-- 2. The order of the quantifiers `hfg` are opposite to what we need. We will be able to swap
-- the quantifiers using the uniform convergence assumption
rw [hasFDerivAt_iff_tendsto]
-- Introduce extra quantifier via curried filters
suffices
Tendsto (fun y : ι × E => ‖y.2 - x‖⁻¹ * ‖g y.2 - g x - (g' x) (y.2 - x)‖)
(l.curry (𝓝 x)) (𝓝 0) by
rw [Metric.tendsto_nhds] at this ⊢
intro ε hε
specialize this ε hε
rw [eventually_curry_iff] at this
simp only at this
exact (eventually_const.mp this).mono (by simp only [imp_self, forall_const])
-- With the new quantifier in hand, we can perform the famous `ε/3` proof. Specifically,
-- we will break up the limit (the difference functions minus the derivative go to 0) into 3:
-- * The difference functions of the `f n` converge *uniformly* to the difference functions
-- of the `g n`
-- * The `f' n` are the derivatives of the `f n`
-- * The `f' n` converge to `g'` at `x`
conv =>
congr
ext
rw [← abs_norm, ← abs_inv, ← @RCLike.norm_ofReal 𝕜 _ _, RCLike.ofReal_inv, ← norm_smul]
rw [← tendsto_zero_iff_norm_tendsto_zero]
have :
(fun a : ι × E => (‖a.2 - x‖⁻¹ : 𝕜) • (g a.2 - g x - (g' x) (a.2 - x))) =
((fun a : ι × E => (‖a.2 - x‖⁻¹ : 𝕜) • (g a.2 - g x - (f a.1 a.2 - f a.1 x))) +
fun a : ι × E =>
(‖a.2 - x‖⁻¹ : 𝕜) • (f a.1 a.2 - f a.1 x - ((f' a.1 x) a.2 - (f' a.1 x) x))) +
fun a : ι × E => (‖a.2 - x‖⁻¹ : 𝕜) • (f' a.1 x - g' x) (a.2 - x) := by
ext; simp only [Pi.add_apply]; rw [← smul_add, ← smul_add]; congr
simp only [map_sub, sub_add_sub_cancel, ContinuousLinearMap.coe_sub', Pi.sub_apply]
abel
simp_rw [this]
have : 𝓝 (0 : G) = 𝓝 (0 + 0 + 0) := by simp only [add_zero]
rw [this]
refine Tendsto.add (Tendsto.add ?_ ?_) ?_
· have := difference_quotients_converge_uniformly hf' hf hfg
rw [Metric.tendstoUniformlyOnFilter_iff] at this
rw [Metric.tendsto_nhds]
intro ε hε
apply ((this ε hε).filter_mono curry_le_prod).mono
intro n hn
rw [dist_eq_norm] at hn ⊢
convert hn using 2
module
· -- (Almost) the definition of the derivatives
rw [Metric.tendsto_nhds]
intro ε hε
rw [eventually_curry_iff]
refine hf.curry.mono fun n hn => ?_
have := hn.self_of_nhds
rw [hasFDerivAt_iff_tendsto, Metric.tendsto_nhds] at this
refine (this ε hε).mono fun y hy => ?_
rw [dist_eq_norm] at hy ⊢
simp only [sub_zero, map_sub, norm_mul, norm_inv, norm_norm] at hy ⊢
rw [norm_smul, norm_inv, RCLike.norm_coe_norm]
exact hy
· -- hfg' after specializing to `x` and applying the definition of the operator norm
refine Tendsto.mono_left ?_ curry_le_prod
have h1 : Tendsto (fun n : ι × E => g' n.2 - f' n.1 n.2) (l ×ˢ 𝓝 x) (𝓝 0) := by
rw [Metric.tendstoUniformlyOnFilter_iff] at hf'
exact Metric.tendsto_nhds.mpr fun ε hε => by simpa using hf' ε hε
have h2 : Tendsto (fun n : ι => g' x - f' n x) l (𝓝 0) := by
rw [Metric.tendsto_nhds] at h1 ⊢
exact fun ε hε => (h1 ε hε).curry.mono fun n hn => hn.self_of_nhds
refine squeeze_zero_norm ?_
(tendsto_zero_iff_norm_tendsto_zero.mp (tendsto_fst.comp (h2.prodMap tendsto_id)))
intro n
simp_rw [norm_smul, norm_inv, RCLike.norm_coe_norm]
by_cases hx : x = n.2; · simp [hx]
have hnx : 0 < ‖n.2 - x‖ := by
rw [norm_pos_iff]; intro hx'; exact hx (eq_of_sub_eq_zero hx').symm
rw [inv_mul_le_iff₀ hnx, mul_comm]
simp only [Function.comp_apply, Prod.map_apply']
rw [norm_sub_rev]
exact (f' n.1 x - g' x).le_opNorm (n.2 - x)
theorem hasFDerivAt_of_tendstoLocallyUniformlyOn [NeBot l] {s : Set E} (hs : IsOpen s)
(hf' : TendstoLocallyUniformlyOn f' g' l s) (hf : ∀ n, ∀ x ∈ s, HasFDerivAt (f n) (f' n x) x)
(hfg : ∀ x ∈ s, Tendsto (fun n => f n x) l (𝓝 (g x))) (hx : x ∈ s) :
HasFDerivAt g (g' x) x := by
have h1 : s ∈ 𝓝 x := hs.mem_nhds hx
have h3 : Set.univ ×ˢ s ∈ l ×ˢ 𝓝 x := by simp only [h1, prod_mem_prod_iff, univ_mem, and_self_iff]
have h4 : ∀ᶠ n : ι × E in l ×ˢ 𝓝 x, HasFDerivAt (f n.1) (f' n.1 n.2) n.2 :=
eventually_of_mem h3 fun ⟨n, z⟩ ⟨_, hz⟩ => hf n z hz
refine hasFDerivAt_of_tendstoUniformlyOnFilter ?_ h4 (eventually_of_mem h1 hfg)
simpa [IsOpen.nhdsWithin_eq hs hx] using tendstoLocallyUniformlyOn_iff_filter.mp hf' x hx
/-- A slight variant of `hasFDerivAt_of_tendstoLocallyUniformlyOn` with the assumption stated
in terms of `DifferentiableOn` rather than `HasFDerivAt`. This makes a few proofs nicer in
complex analysis where holomorphicity is assumed but the derivative is not known a priori. -/
theorem hasFDerivAt_of_tendsto_locally_uniformly_on' [NeBot l] {s : Set E} (hs : IsOpen s)
(hf' : TendstoLocallyUniformlyOn (fderiv 𝕜 ∘ f) g' l s) (hf : ∀ n, DifferentiableOn 𝕜 (f n) s)
(hfg : ∀ x ∈ s, Tendsto (fun n => f n x) l (𝓝 (g x))) (hx : x ∈ s) :
HasFDerivAt g (g' x) x := by
refine hasFDerivAt_of_tendstoLocallyUniformlyOn hs hf' (fun n z hz => ?_) hfg hx
exact ((hf n z hz).differentiableAt (hs.mem_nhds hz)).hasFDerivAt
/-- `(d/dx) lim_{n → ∞} f n x = lim_{n → ∞} f' n x` when the `f' n` converge
_uniformly_ to their limit on an open set containing `x`. -/
theorem hasFDerivAt_of_tendstoUniformlyOn [NeBot l] {s : Set E} (hs : IsOpen s)
(hf' : TendstoUniformlyOn f' g' l s)
(hf : ∀ n : ι, ∀ x : E, x ∈ s → HasFDerivAt (f n) (f' n x) x)
(hfg : ∀ x : E, x ∈ s → Tendsto (fun n => f n x) l (𝓝 (g x))) (hx : x ∈ s) :
HasFDerivAt g (g' x) x :=
hasFDerivAt_of_tendstoLocallyUniformlyOn hs hf'.tendstoLocallyUniformlyOn hf hfg hx
/-- `(d/dx) lim_{n → ∞} f n x = lim_{n → ∞} f' n x` when the `f' n` converge
_uniformly_ to their limit. -/
theorem hasFDerivAt_of_tendstoUniformly [NeBot l] (hf' : TendstoUniformly f' g' l)
(hf : ∀ n : ι, ∀ x : E, HasFDerivAt (f n) (f' n x) x)
(hfg : ∀ x : E, Tendsto (fun n => f n x) l (𝓝 (g x))) (x : E) : HasFDerivAt g (g' x) x := by
have hf : ∀ n : ι, ∀ x : E, x ∈ Set.univ → HasFDerivAt (f n) (f' n x) x := by simp [hf]
have hfg : ∀ x : E, x ∈ Set.univ → Tendsto (fun n => f n x) l (𝓝 (g x)) := by simp [hfg]
have hf' : TendstoUniformlyOn f' g' l Set.univ := by rwa [tendstoUniformlyOn_univ]
exact hasFDerivAt_of_tendstoUniformlyOn isOpen_univ hf' hf hfg (Set.mem_univ x)
end LimitsOfDerivatives
section deriv
/-! ### `deriv` versions of above theorems
In this section, we provide `deriv` equivalents of the `fderiv` lemmas in the previous section.
-/
variable {ι : Type*} {l : Filter ι} {𝕜 : Type*} [NontriviallyNormedField 𝕜]
{G : Type*} [NormedAddCommGroup G]
[NormedSpace 𝕜 G] {f : ι → 𝕜 → G} {g : 𝕜 → G} {f' : ι → 𝕜 → G} {g' : 𝕜 → G} {x : 𝕜}
/-- If our derivatives converge uniformly, then the Fréchet derivatives converge uniformly -/
theorem UniformCauchySeqOnFilter.one_smulRight {l' : Filter 𝕜}
(hf' : UniformCauchySeqOnFilter f' l l') :
UniformCauchySeqOnFilter (fun n => fun z => (1 : 𝕜 →L[𝕜] 𝕜).smulRight (f' n z)) l l' := by
-- The tricky part of this proof is that operator norms are written in terms of `≤` whereas
-- metrics are written in terms of `<`. So we need to shrink `ε` utilizing the archimedean
-- property of `ℝ`
rw [SeminormedAddGroup.uniformCauchySeqOnFilter_iff_tendstoUniformlyOnFilter_zero,
Metric.tendstoUniformlyOnFilter_iff] at hf' ⊢
intro ε hε
obtain ⟨q, hq, hq'⟩ := exists_between hε.lt
apply (hf' q hq).mono
intro n hn
refine lt_of_le_of_lt ?_ hq'
simp only [dist_eq_norm, Pi.zero_apply, zero_sub, norm_neg] at hn ⊢
refine ContinuousLinearMap.opNorm_le_bound _ hq.le ?_
intro z
simp only [ContinuousLinearMap.coe_sub', Pi.sub_apply, ContinuousLinearMap.smulRight_apply,
ContinuousLinearMap.one_apply]
rw [← smul_sub, norm_smul, mul_comm]
gcongr
variable [IsRCLikeNormedField 𝕜]
theorem uniformCauchySeqOnFilter_of_deriv (hf' : UniformCauchySeqOnFilter f' l (𝓝 x))
(hf : ∀ᶠ n : ι × 𝕜 in l ×ˢ 𝓝 x, HasDerivAt (f n.1) (f' n.1 n.2) n.2)
(hfg : Cauchy (map (fun n => f n x) l)) : UniformCauchySeqOnFilter f l (𝓝 x) := by
simp_rw [hasDerivAt_iff_hasFDerivAt] at hf
exact uniformCauchySeqOnFilter_of_fderiv hf'.one_smulRight hf hfg
theorem uniformCauchySeqOn_ball_of_deriv {r : ℝ} (hf' : UniformCauchySeqOn f' l (Metric.ball x r))
(hf : ∀ n : ι, ∀ y : 𝕜, y ∈ Metric.ball x r → HasDerivAt (f n) (f' n y) y)
(hfg : Cauchy (map (fun n => f n x) l)) : UniformCauchySeqOn f l (Metric.ball x r) := by
simp_rw [hasDerivAt_iff_hasFDerivAt] at hf
rw [uniformCauchySeqOn_iff_uniformCauchySeqOnFilter] at hf'
have hf' :
UniformCauchySeqOn (fun n => fun z => (1 : 𝕜 →L[𝕜] 𝕜).smulRight (f' n z)) l
(Metric.ball x r) := by
rw [uniformCauchySeqOn_iff_uniformCauchySeqOnFilter]
exact hf'.one_smulRight
exact uniformCauchySeqOn_ball_of_fderiv hf' hf hfg
theorem hasDerivAt_of_tendstoUniformlyOnFilter [NeBot l]
(hf' : TendstoUniformlyOnFilter f' g' l (𝓝 x))
(hf : ∀ᶠ n : ι × 𝕜 in l ×ˢ 𝓝 x, HasDerivAt (f n.1) (f' n.1 n.2) n.2)
(hfg : ∀ᶠ y in 𝓝 x, Tendsto (fun n => f n y) l (𝓝 (g y))) : HasDerivAt g (g' x) x := by
-- The first part of the proof rewrites `hf` and the goal to be functions so that Lean
-- can recognize them when we apply `hasFDerivAt_of_tendstoUniformlyOnFilter`
let F' n z := (1 : 𝕜 →L[𝕜] 𝕜).smulRight (f' n z)
let G' z := (1 : 𝕜 →L[𝕜] 𝕜).smulRight (g' z)
simp_rw [hasDerivAt_iff_hasFDerivAt] at hf ⊢
-- Now we need to rewrite hf' in terms of `ContinuousLinearMap`s. The tricky part is that
-- operator norms are written in terms of `≤` whereas metrics are written in terms of `<`. So we
-- need to shrink `ε` utilizing the archimedean property of `ℝ`
have hf' : TendstoUniformlyOnFilter F' G' l (𝓝 x) := by
rw [Metric.tendstoUniformlyOnFilter_iff] at hf' ⊢
intro ε hε
obtain ⟨q, hq, hq'⟩ := exists_between hε.lt
apply (hf' q hq).mono
intro n hn
refine lt_of_le_of_lt ?_ hq'
simp only [dist_eq_norm] at hn ⊢
refine ContinuousLinearMap.opNorm_le_bound _ hq.le ?_
intro z
simp only [F', G', ContinuousLinearMap.coe_sub', Pi.sub_apply,
ContinuousLinearMap.smulRight_apply, ContinuousLinearMap.one_apply]
rw [← smul_sub, norm_smul, mul_comm]
gcongr
exact hasFDerivAt_of_tendstoUniformlyOnFilter hf' hf hfg
theorem hasDerivAt_of_tendstoLocallyUniformlyOn [NeBot l] {s : Set 𝕜} (hs : IsOpen s)
(hf' : TendstoLocallyUniformlyOn f' g' l s)
(hf : ∀ᶠ n in l, ∀ x ∈ s, HasDerivAt (f n) (f' n x) x)
(hfg : ∀ x ∈ s, Tendsto (fun n => f n x) l (𝓝 (g x))) (hx : x ∈ s) : HasDerivAt g (g' x) x := by
have h1 : s ∈ 𝓝 x := hs.mem_nhds hx
have h2 : ∀ᶠ n : ι × 𝕜 in l ×ˢ 𝓝 x, HasDerivAt (f n.1) (f' n.1 n.2) n.2 :=
eventually_prod_iff.2 ⟨_, hf, fun x => x ∈ s, h1, fun {n} => id⟩
refine hasDerivAt_of_tendstoUniformlyOnFilter ?_ h2 (eventually_of_mem h1 hfg)
simpa [IsOpen.nhdsWithin_eq hs hx] using tendstoLocallyUniformlyOn_iff_filter.mp hf' x hx
/-- A slight variant of `hasDerivAt_of_tendstoLocallyUniformlyOn` with the assumption stated in
terms of `DifferentiableOn` rather than `HasDerivAt`. This makes a few proofs nicer in complex
analysis where holomorphicity is assumed but the derivative is not known a priori. -/
theorem hasDerivAt_of_tendsto_locally_uniformly_on' [NeBot l] {s : Set 𝕜} (hs : IsOpen s)
(hf' : TendstoLocallyUniformlyOn (deriv ∘ f) g' l s)
(hf : ∀ᶠ n in l, DifferentiableOn 𝕜 (f n) s)
(hfg : ∀ x ∈ s, Tendsto (fun n => f n x) l (𝓝 (g x))) (hx : x ∈ s) : HasDerivAt g (g' x) x := by
refine hasDerivAt_of_tendstoLocallyUniformlyOn hs hf' ?_ hfg hx
filter_upwards [hf] with n h z hz using ((h z hz).differentiableAt (hs.mem_nhds hz)).hasDerivAt
theorem hasDerivAt_of_tendstoUniformlyOn [NeBot l] {s : Set 𝕜} (hs : IsOpen s)
(hf' : TendstoUniformlyOn f' g' l s)
(hf : ∀ᶠ n in l, ∀ x : 𝕜, x ∈ s → HasDerivAt (f n) (f' n x) x)
(hfg : ∀ x : 𝕜, x ∈ s → Tendsto (fun n => f n x) l (𝓝 (g x))) (hx : x ∈ s) :
HasDerivAt g (g' x) x :=
hasDerivAt_of_tendstoLocallyUniformlyOn hs hf'.tendstoLocallyUniformlyOn hf hfg hx
theorem hasDerivAt_of_tendstoUniformly [NeBot l] (hf' : TendstoUniformly f' g' l)
(hf : ∀ᶠ n in l, ∀ x : 𝕜, HasDerivAt (f n) (f' n x) x)
(hfg : ∀ x : 𝕜, Tendsto (fun n => f n x) l (𝓝 (g x))) (x : 𝕜) : HasDerivAt g (g' x) x := by
have hf : ∀ᶠ n in l, ∀ x : 𝕜, x ∈ Set.univ → HasDerivAt (f n) (f' n x) x := by
filter_upwards [hf] with n h x _ using h x
have hfg : ∀ x : 𝕜, x ∈ Set.univ → Tendsto (fun n => f n x) l (𝓝 (g x)) := by simp [hfg]
have hf' : TendstoUniformlyOn f' g' l Set.univ := by rwa [tendstoUniformlyOn_univ]
exact hasDerivAt_of_tendstoUniformlyOn isOpen_univ hf' hf hfg (Set.mem_univ x)
end deriv |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/Implicit.lean | import Mathlib.Analysis.Calculus.InverseFunctionTheorem.FDeriv
import Mathlib.Analysis.Calculus.FDeriv.Add
import Mathlib.Analysis.Calculus.FDeriv.Prod
import Mathlib.Analysis.Normed.Module.Complemented
/-!
# Implicit function theorem
We prove three versions of the implicit function theorem. First we define a structure
`ImplicitFunctionData` that holds arguments for the most general version of the implicit function
theorem, see `ImplicitFunctionData.implicitFunction` and
`ImplicitFunctionData.implicitFunction_hasStrictFDerivAt`. This version allows a user to choose a
specific implicit function but provides only a little convenience over the inverse function theorem.
Then we define `HasStrictFDerivAt.implicitFunctionDataOfComplemented`: implicit function defined by
`f (g z y) = z`, where `f : E → F` is a function strictly differentiable at `a` such that its
derivative `f'` is surjective and has a `complemented` kernel.
Finally, if the codomain of `f` is a finite-dimensional space, then we can automatically prove
that the kernel of `f'` is complemented, hence the only assumptions are `HasStrictFDerivAt`
and `f'.range = ⊤`. This version is named `HasStrictFDerivAt.implicitFunction`.
## TODO
* Add a version for a function `f : E × F → G` such that $$\frac{\partial f}{\partial y}$$ is
invertible.
* Add a version for `f : 𝕜 × 𝕜 → 𝕜` proving `HasStrictDerivAt` and `deriv φ = ...`.
* Prove that in a real vector space the implicit function has the same smoothness as the original
one.
* If the original function is differentiable in a neighborhood, then the implicit function is
differentiable in a neighborhood as well. Current setup only proves differentiability at one
point for the implicit function constructed in this file (as opposed to an unspecified implicit
function). One of the ways to overcome this difficulty is to use uniqueness of the implicit
function in the general version of the theorem. Another way is to prove that *any* implicit
function satisfying some predicate is strictly differentiable.
## Tags
implicit function, inverse function
-/
noncomputable section
open scoped Topology
open Filter
open ContinuousLinearMap (fst snd smulRight ker_prod)
open ContinuousLinearEquiv (ofBijective)
open LinearMap (ker range)
/-!
### General version
Consider two functions `f : E → F` and `g : E → G` and a point `a` such that
* both functions are strictly differentiable at `a`;
* the derivatives are surjective;
* the kernels of the derivatives are complementary subspaces of `E`.
Note that the map `x ↦ (f x, g x)` has a bijective derivative, hence it is an open partial
homeomorphism between `E` and `F × G`. We use this fact to define a function `φ : F → G → E`
(see `ImplicitFunctionData.implicitFunction`) such that for `(y, z)` close enough to `(f a, g a)`
we have `f (φ y z) = y` and `g (φ y z) = z`.
We also prove a formula for $$\frac{\partial\varphi}{\partial z}.$$
Though this statement is almost symmetric with respect to `F`, `G`, we interpret it in the following
way. Consider a family of surfaces `{x | f x = y}`, `y ∈ 𝓝 (f a)`. Each of these surfaces is
parametrized by `φ y`.
There are many ways to choose a (differentiable) function `φ` such that `f (φ y z) = y` but the
extra condition `g (φ y z) = z` allows a user to select one of these functions. If we imagine
that the level surfaces `f = const` form a local horizontal foliation, then the choice of
`g` fixes a transverse foliation `g = const`, and `φ` is the inverse function of the projection
of `{x | f x = y}` along this transverse foliation.
This version of the theorem is used to prove the other versions and can be used if a user
needs to have a complete control over the choice of the implicit function.
-/
/-- Data for the general version of the implicit function theorem. It holds two functions
`f : E → F` and `g : E → G` (named `leftFun` and `rightFun`) and a point `a` (named `pt`) such that
* both functions are strictly differentiable at `a`;
* the derivatives are surjective;
* the kernels of the derivatives are complementary subspaces of `E`. -/
structure ImplicitFunctionData (𝕜 : Type*) [NontriviallyNormedField 𝕜] (E : Type*)
[NormedAddCommGroup E] [NormedSpace 𝕜 E] [CompleteSpace E] (F : Type*) [NormedAddCommGroup F]
[NormedSpace 𝕜 F] [CompleteSpace F] (G : Type*) [NormedAddCommGroup G] [NormedSpace 𝕜 G]
[CompleteSpace G] where
/-- Left function -/
leftFun : E → F
/-- Derivative of the left function -/
leftDeriv : E →L[𝕜] F
/-- Right function -/
rightFun : E → G
/-- Derivative of the right function -/
rightDeriv : E →L[𝕜] G
/-- The point at which `leftFun` and `rightFun` are strictly differentiable -/
pt : E
hasStrictFDerivAt_leftFun : HasStrictFDerivAt leftFun leftDeriv pt
hasStrictFDerivAt_rightFun : HasStrictFDerivAt rightFun rightDeriv pt
range_leftDeriv : range leftDeriv = ⊤
range_rightDeriv : range rightDeriv = ⊤
isCompl_ker : IsCompl (ker leftDeriv) (ker rightDeriv)
namespace ImplicitFunctionData
variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] {E : Type*} [NormedAddCommGroup E]
[NormedSpace 𝕜 E] [CompleteSpace E] {F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F]
[CompleteSpace F] {G : Type*} [NormedAddCommGroup G] [NormedSpace 𝕜 G] [CompleteSpace G]
(φ : ImplicitFunctionData 𝕜 E F G)
/-- The function given by `x ↦ (leftFun x, rightFun x)`. -/
def prodFun (x : E) : F × G :=
(φ.leftFun x, φ.rightFun x)
@[simp]
theorem prodFun_apply (x : E) : φ.prodFun x = (φ.leftFun x, φ.rightFun x) :=
rfl
protected theorem hasStrictFDerivAt :
HasStrictFDerivAt φ.prodFun
(φ.leftDeriv.equivProdOfSurjectiveOfIsCompl φ.rightDeriv φ.range_leftDeriv φ.range_rightDeriv
φ.isCompl_ker :
E →L[𝕜] F × G)
φ.pt :=
φ.hasStrictFDerivAt_leftFun.prodMk φ.hasStrictFDerivAt_rightFun
/-- Implicit function theorem. If `f : E → F` and `g : E → G` are two maps strictly differentiable
at `a`, their derivatives `f'`, `g'` are surjective, and the kernels of these derivatives are
complementary subspaces of `E`, then `x ↦ (f x, g x)` defines an open partial homeomorphism between
`E` and `F × G`. In particular, `{x | f x = f a}` is locally homeomorphic to `G`. -/
def toOpenPartialHomeomorph : OpenPartialHomeomorph E (F × G) :=
φ.hasStrictFDerivAt.toOpenPartialHomeomorph _
@[deprecated (since := "2025-08-29")] noncomputable
alias toPartialHomeomorph := toOpenPartialHomeomorph
/-- Implicit function theorem. If `f : E → F` and `g : E → G` are two maps strictly differentiable
at `a`, their derivatives `f'`, `g'` are surjective, and the kernels of these derivatives are
complementary subspaces of `E`, then `implicitFunction` is the unique (germ of a) map
`φ : F → G → E` such that `f (φ y z) = y` and `g (φ y z) = z`. -/
def implicitFunction : F → G → E :=
Function.curry <| φ.toOpenPartialHomeomorph.symm
@[simp]
theorem toOpenPartialHomeomorph_coe : ⇑φ.toOpenPartialHomeomorph = φ.prodFun :=
rfl
@[deprecated (since := "2025-08-29")] alias toPartialHomeomorph_coe := toOpenPartialHomeomorph_coe
theorem toOpenPartialHomeomorph_apply (x : E) :
φ.toOpenPartialHomeomorph x = (φ.leftFun x, φ.rightFun x) :=
rfl
@[deprecated (since := "2025-08-29")] alias
toPartialHomeomorph_apply := toOpenPartialHomeomorph_apply
theorem pt_mem_toOpenPartialHomeomorph_source : φ.pt ∈ φ.toOpenPartialHomeomorph.source :=
φ.hasStrictFDerivAt.mem_toOpenPartialHomeomorph_source
@[deprecated (since := "2025-08-29")] alias
pt_mem_toPartialHomeomorph_source := pt_mem_toOpenPartialHomeomorph_source
theorem map_pt_mem_toOpenPartialHomeomorph_target :
(φ.leftFun φ.pt, φ.rightFun φ.pt) ∈ φ.toOpenPartialHomeomorph.target :=
φ.toOpenPartialHomeomorph.map_source <| φ.pt_mem_toOpenPartialHomeomorph_source
@[deprecated (since := "2025-08-29")] alias
map_pt_mem_toPartialHomeomorph_target := map_pt_mem_toOpenPartialHomeomorph_target
theorem prod_map_implicitFunction :
∀ᶠ p : F × G in 𝓝 (φ.prodFun φ.pt), φ.prodFun (φ.implicitFunction p.1 p.2) = p :=
φ.hasStrictFDerivAt.eventually_right_inverse.mono fun ⟨_, _⟩ h => h
theorem left_map_implicitFunction :
∀ᶠ p : F × G in 𝓝 (φ.prodFun φ.pt), φ.leftFun (φ.implicitFunction p.1 p.2) = p.1 :=
φ.prod_map_implicitFunction.mono fun _ => congr_arg Prod.fst
theorem right_map_implicitFunction :
∀ᶠ p : F × G in 𝓝 (φ.prodFun φ.pt), φ.rightFun (φ.implicitFunction p.1 p.2) = p.2 :=
φ.prod_map_implicitFunction.mono fun _ => congr_arg Prod.snd
theorem implicitFunction_apply_image :
∀ᶠ x in 𝓝 φ.pt, φ.implicitFunction (φ.leftFun x) (φ.rightFun x) = x :=
φ.hasStrictFDerivAt.eventually_left_inverse
theorem map_nhds_eq : map φ.leftFun (𝓝 φ.pt) = 𝓝 (φ.leftFun φ.pt) :=
show map (Prod.fst ∘ φ.prodFun) (𝓝 φ.pt) = 𝓝 (φ.prodFun φ.pt).1 by
rw [← map_map, φ.hasStrictFDerivAt.map_nhds_eq_of_equiv, map_fst_nhds]
theorem implicitFunction_hasStrictFDerivAt (g'inv : G →L[𝕜] E)
(hg'inv : φ.rightDeriv.comp g'inv = ContinuousLinearMap.id 𝕜 G)
(hg'invf : φ.leftDeriv.comp g'inv = 0) :
HasStrictFDerivAt (φ.implicitFunction (φ.leftFun φ.pt)) g'inv (φ.rightFun φ.pt) := by
have := φ.hasStrictFDerivAt.to_localInverse
simp only [prodFun] at this
convert this.comp (φ.rightFun φ.pt)
((hasStrictFDerivAt_const _ _).prodMk (hasStrictFDerivAt_id _))
simp only [ContinuousLinearMap.ext_iff, ContinuousLinearMap.comp_apply] at hg'inv hg'invf ⊢
simp [ContinuousLinearEquiv.eq_symm_apply, *]
end ImplicitFunctionData
namespace HasStrictFDerivAt
section Complemented
/-!
### Case of a complemented kernel
In this section we prove the following version of the implicit function theorem. Consider a map
`f : E → F` and a point `a : E` such that `f` is strictly differentiable at `a`, its derivative `f'`
is surjective and the kernel of `f'` is a complemented subspace of `E` (i.e., it has a closed
complementary subspace). Then there exists a function `φ : F → ker f' → E` such that for `(y, z)`
close to `(f a, 0)` we have `f (φ y z) = y` and the derivative of `φ (f a)` at zero is the
embedding `ker f' → E`.
Note that a map with these properties is not unique. E.g., different choices of a subspace
complementary to `ker f'` lead to different maps `φ`.
-/
variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] {E : Type*} [NormedAddCommGroup E]
[NormedSpace 𝕜 E] [CompleteSpace E] {F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F]
[CompleteSpace F] {f : E → F} {f' : E →L[𝕜] F} {a : E}
section Defs
variable (f f')
/-- Data used to apply the generic implicit function theorem to the case of a strictly
differentiable map such that its derivative is surjective and has a complemented kernel. -/
@[simp]
def implicitFunctionDataOfComplemented (hf : HasStrictFDerivAt f f' a) (hf' : range f' = ⊤)
(hker : (ker f').ClosedComplemented) : ImplicitFunctionData 𝕜 E F (ker f') where
leftFun := f
leftDeriv := f'
rightFun x := Classical.choose hker (x - a)
rightDeriv := Classical.choose hker
pt := a
hasStrictFDerivAt_leftFun := hf
hasStrictFDerivAt_rightFun :=
(Classical.choose hker).hasStrictFDerivAt.comp a ((hasStrictFDerivAt_id a).sub_const a)
range_leftDeriv := hf'
range_rightDeriv := LinearMap.range_eq_of_proj (Classical.choose_spec hker)
isCompl_ker := LinearMap.isCompl_of_proj (Classical.choose_spec hker)
/-- An open partial homeomorphism between `E` and `F × f'.ker` sending level surfaces of `f`
to vertical subspaces. -/
def implicitToOpenPartialHomeomorphOfComplemented (hf : HasStrictFDerivAt f f' a)
(hf' : range f' = ⊤) (hker : (ker f').ClosedComplemented) :
OpenPartialHomeomorph E (F × ker f') :=
(implicitFunctionDataOfComplemented f f' hf hf' hker).toOpenPartialHomeomorph
@[deprecated (since := "2025-08-29")] noncomputable alias
implicitToPartialHomeomorphOfComplemented := implicitToOpenPartialHomeomorphOfComplemented
/-- Implicit function `g` defined by `f (g z y) = z`. -/
def implicitFunctionOfComplemented (hf : HasStrictFDerivAt f f' a) (hf' : range f' = ⊤)
(hker : (ker f').ClosedComplemented) : F → ker f' → E :=
(implicitFunctionDataOfComplemented f f' hf hf' hker).implicitFunction
end Defs
@[simp]
theorem implicitToOpenPartialHomeomorphOfComplemented_fst (hf : HasStrictFDerivAt f f' a)
(hf' : range f' = ⊤) (hker : (ker f').ClosedComplemented) (x : E) :
(hf.implicitToOpenPartialHomeomorphOfComplemented f f' hf' hker x).fst = f x :=
rfl
@[deprecated (since := "2025-08-29")] alias
implicitToPartialHomeomorphOfComplemented_fst := implicitToOpenPartialHomeomorphOfComplemented_fst
theorem implicitToOpenPartialHomeomorphOfComplemented_apply (hf : HasStrictFDerivAt f f' a)
(hf' : range f' = ⊤) (hker : (ker f').ClosedComplemented) (y : E) :
hf.implicitToOpenPartialHomeomorphOfComplemented f f' hf' hker y =
(f y, Classical.choose hker (y - a)) :=
rfl
@[deprecated (since := "2025-08-29")] alias implicitToPartialHomeomorphOfComplemented_apply :=
implicitToOpenPartialHomeomorphOfComplemented_apply
@[simp]
theorem implicitToOpenPartialHomeomorphOfComplemented_apply_ker (hf : HasStrictFDerivAt f f' a)
(hf' : range f' = ⊤) (hker : (ker f').ClosedComplemented) (y : ker f') :
hf.implicitToOpenPartialHomeomorphOfComplemented f f' hf' hker (y + a) = (f (y + a), y) := by
simp only [implicitToOpenPartialHomeomorphOfComplemented_apply, add_sub_cancel_right,
Classical.choose_spec hker]
@[deprecated (since := "2025-08-29")] alias implicitToPartialHomeomorphOfComplemented_apply_ker :=
implicitToOpenPartialHomeomorphOfComplemented_apply_ker
@[simp]
theorem implicitToOpenPartialHomeomorphOfComplemented_self (hf : HasStrictFDerivAt f f' a)
(hf' : range f' = ⊤) (hker : (ker f').ClosedComplemented) :
hf.implicitToOpenPartialHomeomorphOfComplemented f f' hf' hker a = (f a, 0) := by
simp [hf.implicitToOpenPartialHomeomorphOfComplemented_apply]
@[deprecated (since := "2025-08-29")] alias implicitToPartialHomeomorphOfComplemented_self :=
implicitToOpenPartialHomeomorphOfComplemented_self
theorem mem_implicitToOpenPartialHomeomorphOfComplemented_source (hf : HasStrictFDerivAt f f' a)
(hf' : range f' = ⊤) (hker : (ker f').ClosedComplemented) :
a ∈ (hf.implicitToOpenPartialHomeomorphOfComplemented f f' hf' hker).source :=
ImplicitFunctionData.pt_mem_toOpenPartialHomeomorph_source _
@[deprecated (since := "2025-08-29")] alias mem_implicitToPartialHomeomorphOfComplemented_source :=
mem_implicitToOpenPartialHomeomorphOfComplemented_source
theorem mem_implicitToOpenPartialHomeomorphOfComplemented_target (hf : HasStrictFDerivAt f f' a)
(hf' : range f' = ⊤) (hker : (ker f').ClosedComplemented) :
(f a, (0 : ker f')) ∈
(hf.implicitToOpenPartialHomeomorphOfComplemented f f' hf' hker).target := by
simpa only [implicitToOpenPartialHomeomorphOfComplemented_self] using
(hf.implicitToOpenPartialHomeomorphOfComplemented f f' hf' hker).map_source <|
hf.mem_implicitToOpenPartialHomeomorphOfComplemented_source hf' hker
@[deprecated (since := "2025-08-29")] alias mem_implicitToPartialHomeomorphOfComplemented_target :=
mem_implicitToOpenPartialHomeomorphOfComplemented_target
/-- `HasStrictFDerivAt.implicitFunctionOfComplemented` sends `(z, y)` to a point in `f ⁻¹' z`. -/
theorem map_implicitFunctionOfComplemented_eq (hf : HasStrictFDerivAt f f' a) (hf' : range f' = ⊤)
(hker : (ker f').ClosedComplemented) :
∀ᶠ p : F × ker f' in 𝓝 (f a, 0),
f (hf.implicitFunctionOfComplemented f f' hf' hker p.1 p.2) = p.1 :=
((hf.implicitToOpenPartialHomeomorphOfComplemented f f' hf' hker).eventually_right_inverse <|
hf.mem_implicitToOpenPartialHomeomorphOfComplemented_target hf' hker).mono
fun ⟨_, _⟩ h => congr_arg Prod.fst h
/-- Any point in some neighborhood of `a` can be represented as
`HasStrictFDerivAt.implicitFunctionOfComplemented` of some point. -/
theorem eq_implicitFunctionOfComplemented (hf : HasStrictFDerivAt f f' a) (hf' : range f' = ⊤)
(hker : (ker f').ClosedComplemented) :
∀ᶠ x in 𝓝 a, hf.implicitFunctionOfComplemented f f' hf' hker (f x)
(hf.implicitToOpenPartialHomeomorphOfComplemented f f' hf' hker x).snd = x :=
(implicitFunctionDataOfComplemented f f' hf hf' hker).implicitFunction_apply_image
@[simp]
theorem implicitFunctionOfComplemented_apply_image (hf : HasStrictFDerivAt f f' a)
(hf' : range f' = ⊤) (hker : (ker f').ClosedComplemented) :
hf.implicitFunctionOfComplemented f f' hf' hker (f a) 0 = a := by
simpa only [implicitToOpenPartialHomeomorphOfComplemented_self] using
(hf.implicitToOpenPartialHomeomorphOfComplemented f f' hf' hker).left_inv
(hf.mem_implicitToOpenPartialHomeomorphOfComplemented_source hf' hker)
theorem to_implicitFunctionOfComplemented (hf : HasStrictFDerivAt f f' a) (hf' : range f' = ⊤)
(hker : (ker f').ClosedComplemented) :
HasStrictFDerivAt (hf.implicitFunctionOfComplemented f f' hf' hker (f a))
(ker f').subtypeL 0 := by
convert (implicitFunctionDataOfComplemented f f' hf hf' hker).implicitFunction_hasStrictFDerivAt
(ker f').subtypeL _ _
swap
· ext
simp only [Classical.choose_spec hker, implicitFunctionDataOfComplemented,
ContinuousLinearMap.comp_apply, Submodule.coe_subtypeL', Submodule.coe_subtype,
ContinuousLinearMap.id_apply]
swap
· ext
simp only [ContinuousLinearMap.comp_apply, Submodule.coe_subtypeL', Submodule.coe_subtype,
LinearMap.map_coe_ker, ContinuousLinearMap.zero_apply]
simp only [implicitFunctionDataOfComplemented, map_sub, sub_self]
end Complemented
/-!
### Finite-dimensional case
In this section we prove the following version of the implicit function theorem. Consider a map
`f : E → F` from a Banach normed space to a finite-dimensional space.
Take a point `a : E` such that `f` is strictly differentiable at `a` and its derivative `f'`
is surjective. Then there exists a function `φ : F → ker f' → E` such that for `(y, z)`
close to `(f a, 0)` we have `f (φ y z) = y` and the derivative of `φ (f a)` at zero is the
embedding `ker f' → E`.
This version deduces that `ker f'` is a complemented subspace from the fact that `F` is a finite
dimensional space, then applies the previous version.
Note that a map with these properties is not unique. E.g., different choices of a subspace
complementary to `ker f'` lead to different maps `φ`.
-/
section FiniteDimensional
variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] [CompleteSpace 𝕜] {E : Type*}
[NormedAddCommGroup E] [NormedSpace 𝕜 E] [CompleteSpace E] {F : Type*} [NormedAddCommGroup F]
[NormedSpace 𝕜 F] [FiniteDimensional 𝕜 F] (f : E → F) (f' : E →L[𝕜] F) {a : E}
/-- Given a map `f : E → F` to a finite-dimensional space with a surjective derivative `f'`,
returns an open partial homeomorphism between `E` and `F × ker f'`. -/
def implicitToOpenPartialHomeomorph (hf : HasStrictFDerivAt f f' a) (hf' : range f' = ⊤) :
OpenPartialHomeomorph E (F × ker f') :=
haveI := FiniteDimensional.complete 𝕜 F
hf.implicitToOpenPartialHomeomorphOfComplemented f f' hf'
f'.ker_closedComplemented_of_finiteDimensional_range
@[deprecated (since := "2025-08-29")] noncomputable alias
implicitToPartialHomeomorph := implicitToOpenPartialHomeomorph
/-- Implicit function `g` defined by `f (g z y) = z`. -/
def implicitFunction (hf : HasStrictFDerivAt f f' a) (hf' : range f' = ⊤) : F → ker f' → E :=
Function.curry <| (hf.implicitToOpenPartialHomeomorph f f' hf').symm
variable {f f'}
@[simp]
theorem implicitToOpenPartialHomeomorph_fst (hf : HasStrictFDerivAt f f' a) (hf' : range f' = ⊤)
(x : E) : (hf.implicitToOpenPartialHomeomorph f f' hf' x).fst = f x :=
rfl
@[deprecated (since := "2025-08-29")] alias
implicitToPartialHomeomorph_fst := implicitToOpenPartialHomeomorph_fst
@[simp]
theorem implicitToOpenPartialHomeomorph_apply_ker (hf : HasStrictFDerivAt f f' a)
(hf' : range f' = ⊤) (y : ker f') :
hf.implicitToOpenPartialHomeomorph f f' hf' (y + a) = (f (y + a), y) :=
haveI := FiniteDimensional.complete 𝕜 F
implicitToOpenPartialHomeomorphOfComplemented_apply_ker ..
@[deprecated (since := "2025-08-29")] alias
implicitToPartialHomeomorph_apply_ker := implicitToOpenPartialHomeomorph_apply_ker
@[simp]
theorem implicitToOpenPartialHomeomorph_self (hf : HasStrictFDerivAt f f' a) (hf' : range f' = ⊤) :
hf.implicitToOpenPartialHomeomorph f f' hf' a = (f a, 0) :=
haveI := FiniteDimensional.complete 𝕜 F
implicitToOpenPartialHomeomorphOfComplemented_self ..
@[deprecated (since := "2025-08-29")] alias
implicitToPartialHomeomorph_self := implicitToOpenPartialHomeomorph_self
theorem mem_implicitToOpenPartialHomeomorph_source (hf : HasStrictFDerivAt f f' a)
(hf' : range f' = ⊤) : a ∈ (hf.implicitToOpenPartialHomeomorph f f' hf').source :=
haveI := FiniteDimensional.complete 𝕜 F
ImplicitFunctionData.pt_mem_toOpenPartialHomeomorph_source _
@[deprecated (since := "2025-08-29")] alias
mem_implicitToPartialHomeomorph_source := mem_implicitToOpenPartialHomeomorph_source
theorem mem_implicitToOpenPartialHomeomorph_target (hf : HasStrictFDerivAt f f' a)
(hf' : range f' = ⊤) :
(f a, (0 : ker f')) ∈ (hf.implicitToOpenPartialHomeomorph f f' hf').target :=
haveI := FiniteDimensional.complete 𝕜 F
mem_implicitToOpenPartialHomeomorphOfComplemented_target ..
@[deprecated (since := "2025-08-29")] alias
mem_implicitToPartialHomeomorph_target := mem_implicitToOpenPartialHomeomorph_target
theorem tendsto_implicitFunction (hf : HasStrictFDerivAt f f' a) (hf' : range f' = ⊤) {α : Type*}
{l : Filter α} {g₁ : α → F} {g₂ : α → ker f'} (h₁ : Tendsto g₁ l (𝓝 <| f a))
(h₂ : Tendsto g₂ l (𝓝 0)) :
Tendsto (fun t => hf.implicitFunction f f' hf' (g₁ t) (g₂ t)) l (𝓝 a) := by
refine ((hf.implicitToOpenPartialHomeomorph f f' hf').tendsto_symm
(hf.mem_implicitToOpenPartialHomeomorph_source hf')).comp ?_
rw [implicitToOpenPartialHomeomorph_self]
exact h₁.prodMk_nhds h₂
alias _root_.Filter.Tendsto.implicitFunction := tendsto_implicitFunction
/-- `HasStrictFDerivAt.implicitFunction` sends `(z, y)` to a point in `f ⁻¹' z`. -/
theorem map_implicitFunction_eq (hf : HasStrictFDerivAt f f' a) (hf' : range f' = ⊤) :
∀ᶠ p : F × ker f' in 𝓝 (f a, 0), f (hf.implicitFunction f f' hf' p.1 p.2) = p.1 :=
haveI := FiniteDimensional.complete 𝕜 F
map_implicitFunctionOfComplemented_eq ..
@[simp]
theorem implicitFunction_apply_image (hf : HasStrictFDerivAt f f' a) (hf' : range f' = ⊤) :
hf.implicitFunction f f' hf' (f a) 0 = a := by
haveI := FiniteDimensional.complete 𝕜 F
apply implicitFunctionOfComplemented_apply_image
/-- Any point in some neighborhood of `a` can be represented as `HasStrictFDerivAt.implicitFunction`
of some point. -/
theorem eq_implicitFunction (hf : HasStrictFDerivAt f f' a) (hf' : range f' = ⊤) :
∀ᶠ x in 𝓝 a,
hf.implicitFunction f f' hf' (f x) (hf.implicitToOpenPartialHomeomorph f f' hf' x).snd = x :=
haveI := FiniteDimensional.complete 𝕜 F
eq_implicitFunctionOfComplemented ..
theorem to_implicitFunction (hf : HasStrictFDerivAt f f' a) (hf' : range f' = ⊤) :
HasStrictFDerivAt (hf.implicitFunction f f' hf' (f a)) (ker f').subtypeL 0 :=
haveI := FiniteDimensional.complete 𝕜 F
to_implicitFunctionOfComplemented ..
end FiniteDimensional
end HasStrictFDerivAt |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/DSlope.lean | import Mathlib.Analysis.Calculus.Deriv.Slope
import Mathlib.Analysis.Calculus.Deriv.Comp
import Mathlib.Analysis.Calculus.FDeriv.Add
import Mathlib.Analysis.Calculus.FDeriv.Mul
/-!
# Slope of a differentiable function
Given a function `f : 𝕜 → E` from a nontrivially normed field to a normed space over this field,
`dslope f a b` is defined as `slope f a b = (b - a)⁻¹ • (f b - f a)` for `a ≠ b` and as `deriv f a`
for `a = b`.
In this file we define `dslope` and prove some basic lemmas about its continuity and
differentiability.
-/
open scoped Topology Filter
open Function Set Filter
variable {𝕜 E : Type*} [NontriviallyNormedField 𝕜] [NormedAddCommGroup E] [NormedSpace 𝕜 E]
open Classical in
/-- `dslope f a b` is defined as `slope f a b = (b - a)⁻¹ • (f b - f a)` for `a ≠ b` and
`deriv f a` for `a = b`. -/
noncomputable def dslope (f : 𝕜 → E) (a : 𝕜) : 𝕜 → E :=
update (slope f a) a (deriv f a)
@[simp]
theorem dslope_same (f : 𝕜 → E) (a : 𝕜) : dslope f a a = deriv f a := by
classical
exact update_self ..
variable {f : 𝕜 → E} {a b : 𝕜} {s : Set 𝕜}
theorem dslope_of_ne (f : 𝕜 → E) (h : b ≠ a) : dslope f a b = slope f a b := by
classical
exact update_of_ne h ..
theorem ContinuousLinearMap.dslope_comp {F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F]
(f : E →L[𝕜] F) (g : 𝕜 → E) (a b : 𝕜) (H : a = b → DifferentiableAt 𝕜 g a) :
dslope (f ∘ g) a b = f (dslope g a b) := by
rcases eq_or_ne b a with (rfl | hne)
· simp only [dslope_same]
exact (f.hasFDerivAt.comp_hasDerivAt b (H rfl).hasDerivAt).deriv
· simpa only [dslope_of_ne _ hne] using f.toLinearMap.slope_comp g a b
theorem eqOn_dslope_slope (f : 𝕜 → E) (a : 𝕜) : EqOn (dslope f a) (slope f a) {a}ᶜ := fun _ =>
dslope_of_ne f
theorem dslope_eventuallyEq_slope_of_ne (f : 𝕜 → E) (h : b ≠ a) : dslope f a =ᶠ[𝓝 b] slope f a :=
(eqOn_dslope_slope f a).eventuallyEq_of_mem (isOpen_ne.mem_nhds h)
theorem dslope_eventuallyEq_slope_nhdsNE (f : 𝕜 → E) : dslope f a =ᶠ[𝓝[≠] a] slope f a :=
(eqOn_dslope_slope f a).eventuallyEq_of_mem self_mem_nhdsWithin
@[simp]
theorem sub_smul_dslope (f : 𝕜 → E) (a b : 𝕜) : (b - a) • dslope f a b = f b - f a := by
rcases eq_or_ne b a with (rfl | hne) <;> simp [dslope_of_ne, *]
theorem dslope_sub_smul_of_ne (f : 𝕜 → E) (h : b ≠ a) :
dslope (fun x => (x - a) • f x) a b = f b := by
rw [dslope_of_ne _ h, slope_sub_smul _ h.symm]
theorem eqOn_dslope_sub_smul (f : 𝕜 → E) (a : 𝕜) :
EqOn (dslope (fun x => (x - a) • f x) a) f {a}ᶜ := fun _ => dslope_sub_smul_of_ne f
theorem dslope_sub_smul [DecidableEq 𝕜] (f : 𝕜 → E) (a : 𝕜) :
dslope (fun x => (x - a) • f x) a = update f a (deriv (fun x => (x - a) • f x) a) :=
eq_update_iff.2 ⟨dslope_same _ _, eqOn_dslope_sub_smul f a⟩
@[simp]
theorem continuousAt_dslope_same : ContinuousAt (dslope f a) a ↔ DifferentiableAt 𝕜 f a := by
simp only [dslope, continuousAt_update_same, ← hasDerivAt_deriv_iff, hasDerivAt_iff_tendsto_slope]
theorem ContinuousWithinAt.of_dslope (h : ContinuousWithinAt (dslope f a) s b) :
ContinuousWithinAt f s b := by
have : ContinuousWithinAt (fun x => (x - a) • dslope f a x + f a) s b :=
((continuousWithinAt_id.sub continuousWithinAt_const).smul h).add continuousWithinAt_const
simpa only [sub_smul_dslope, sub_add_cancel] using this
theorem ContinuousAt.of_dslope (h : ContinuousAt (dslope f a) b) : ContinuousAt f b :=
(continuousWithinAt_univ _ _).1 h.continuousWithinAt.of_dslope
theorem ContinuousOn.of_dslope (h : ContinuousOn (dslope f a) s) : ContinuousOn f s := fun x hx =>
(h x hx).of_dslope
theorem continuousWithinAt_dslope_of_ne (h : b ≠ a) :
ContinuousWithinAt (dslope f a) s b ↔ ContinuousWithinAt f s b := by
refine ⟨ContinuousWithinAt.of_dslope, fun hc => ?_⟩
classical
simp only [dslope, continuousWithinAt_update_of_ne h]
exact ((continuousWithinAt_id.sub continuousWithinAt_const).inv₀ (sub_ne_zero.2 h)).smul
(hc.sub continuousWithinAt_const)
theorem continuousAt_dslope_of_ne (h : b ≠ a) : ContinuousAt (dslope f a) b ↔ ContinuousAt f b := by
simp only [← continuousWithinAt_univ, continuousWithinAt_dslope_of_ne h]
theorem continuousOn_dslope (h : s ∈ 𝓝 a) :
ContinuousOn (dslope f a) s ↔ ContinuousOn f s ∧ DifferentiableAt 𝕜 f a := by
refine ⟨fun hc => ⟨hc.of_dslope, continuousAt_dslope_same.1 <| hc.continuousAt h⟩, ?_⟩
rintro ⟨hc, hd⟩ x hx
rcases eq_or_ne x a with (rfl | hne)
exacts [(continuousAt_dslope_same.2 hd).continuousWithinAt,
(continuousWithinAt_dslope_of_ne hne).2 (hc x hx)]
theorem DifferentiableWithinAt.of_dslope (h : DifferentiableWithinAt 𝕜 (dslope f a) s b) :
DifferentiableWithinAt 𝕜 f s b := by
simpa only [id, sub_smul_dslope f a, sub_add_cancel] using
((differentiableWithinAt_id.sub_const a).fun_smul h).add_const (f a)
theorem DifferentiableAt.of_dslope (h : DifferentiableAt 𝕜 (dslope f a) b) :
DifferentiableAt 𝕜 f b :=
differentiableWithinAt_univ.1 h.differentiableWithinAt.of_dslope
theorem DifferentiableOn.of_dslope (h : DifferentiableOn 𝕜 (dslope f a) s) :
DifferentiableOn 𝕜 f s := fun x hx => (h x hx).of_dslope
theorem differentiableWithinAt_dslope_of_ne (h : b ≠ a) :
DifferentiableWithinAt 𝕜 (dslope f a) s b ↔ DifferentiableWithinAt 𝕜 f s b := by
refine ⟨DifferentiableWithinAt.of_dslope, fun hd => ?_⟩
refine (((differentiableWithinAt_id.sub_const a).inv (sub_ne_zero.2 h)).smul
(hd.sub_const (f a))).congr_of_eventuallyEq ?_ (dslope_of_ne _ h)
refine (eqOn_dslope_slope _ _).eventuallyEq_of_mem ?_
exact mem_nhdsWithin_of_mem_nhds (isOpen_ne.mem_nhds h)
theorem differentiableOn_dslope_of_notMem (h : a ∉ s) :
DifferentiableOn 𝕜 (dslope f a) s ↔ DifferentiableOn 𝕜 f s :=
forall_congr' fun _ =>
forall_congr' fun hx => differentiableWithinAt_dslope_of_ne <| ne_of_mem_of_not_mem hx h
@[deprecated (since := "2025-05-24")]
alias differentiableOn_dslope_of_nmem := differentiableOn_dslope_of_notMem
theorem differentiableAt_dslope_of_ne (h : b ≠ a) :
DifferentiableAt 𝕜 (dslope f a) b ↔ DifferentiableAt 𝕜 f b := by
simp only [← differentiableWithinAt_univ, differentiableWithinAt_dslope_of_ne h] |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/ParametricIntervalIntegral.lean | import Mathlib.Analysis.Calculus.ParametricIntegral
import Mathlib.MeasureTheory.Integral.IntervalIntegral.Basic
/-!
# Derivatives of interval integrals depending on parameters
In this file we restate theorems about derivatives of integrals depending on parameters for interval
integrals. -/
open TopologicalSpace MeasureTheory Filter Metric
open scoped Topology Filter Interval
variable {𝕜 : Type*} [RCLike 𝕜] {μ : Measure ℝ} {E : Type*} [NormedAddCommGroup E]
[NormedSpace ℝ E] [NormedSpace 𝕜 E] {H : Type*} [NormedAddCommGroup H]
[NormedSpace 𝕜 H] {a b ε : ℝ} {bound : ℝ → ℝ}
namespace intervalIntegral
/-- Differentiation under integral of `x ↦ ∫ t in a..b, F x t` at a given point `x₀`, assuming
`F x₀` is integrable, `x ↦ F x a` is locally Lipschitz on a ball around `x₀` for ae `a`
(with a ball radius independent of `a`) with integrable Lipschitz bound, and `F x` is ae-measurable
for `x` in a possibly smaller neighborhood of `x₀`. -/
nonrec theorem hasFDerivAt_integral_of_dominated_loc_of_lip
{F : H → ℝ → E} {F' : ℝ → H →L[𝕜] E} {x₀ : H}
(ε_pos : 0 < ε) (hF_meas : ∀ᶠ x in 𝓝 x₀, AEStronglyMeasurable (F x) (μ.restrict (Ι a b)))
(hF_int : IntervalIntegrable (F x₀) μ a b)
(hF'_meas : AEStronglyMeasurable F' (μ.restrict (Ι a b)))
(h_lip : ∀ᵐ t ∂μ, t ∈ Ι a b →
LipschitzOnWith (Real.nnabs <| bound t) (fun x => F x t) (ball x₀ ε))
(bound_integrable : IntervalIntegrable bound μ a b)
(h_diff : ∀ᵐ t ∂μ, t ∈ Ι a b → HasFDerivAt (fun x => F x t) (F' t) x₀) :
IntervalIntegrable F' μ a b ∧
HasFDerivAt (fun x => ∫ t in a..b, F x t ∂μ) (∫ t in a..b, F' t ∂μ) x₀ := by
rw [← ae_restrict_iff' measurableSet_uIoc] at h_lip h_diff
simp only [intervalIntegrable_iff] at hF_int bound_integrable ⊢
simp only [intervalIntegral_eq_integral_uIoc]
have := hasFDerivAt_integral_of_dominated_loc_of_lip ε_pos hF_meas hF_int hF'_meas h_lip
bound_integrable h_diff
exact ⟨this.1, this.2.const_smul _⟩
/-- Differentiation under integral of `x ↦ ∫ F x a` at a given point `x₀`, assuming
`F x₀` is integrable, `x ↦ F x a` is differentiable on a ball around `x₀` for ae `a` with
derivative norm uniformly bounded by an integrable function (the ball radius is independent of `a`),
and `F x` is ae-measurable for `x` in a possibly smaller neighborhood of `x₀`. -/
nonrec theorem hasFDerivAt_integral_of_dominated_of_fderiv_le
{F : H → ℝ → E} {F' : H → ℝ → H →L[𝕜] E} {x₀ : H} (ε_pos : 0 < ε)
(hF_meas : ∀ᶠ x in 𝓝 x₀, AEStronglyMeasurable (F x) (μ.restrict (Ι a b)))
(hF_int : IntervalIntegrable (F x₀) μ a b)
(hF'_meas : AEStronglyMeasurable (F' x₀) (μ.restrict (Ι a b)))
(h_bound : ∀ᵐ t ∂μ, t ∈ Ι a b → ∀ x ∈ ball x₀ ε, ‖F' x t‖ ≤ bound t)
(bound_integrable : IntervalIntegrable bound μ a b)
(h_diff : ∀ᵐ t ∂μ, t ∈ Ι a b → ∀ x ∈ ball x₀ ε, HasFDerivAt (fun x => F x t) (F' x t) x) :
HasFDerivAt (fun x => ∫ t in a..b, F x t ∂μ) (∫ t in a..b, F' x₀ t ∂μ) x₀ := by
rw [← ae_restrict_iff' measurableSet_uIoc] at h_bound h_diff
simp only [intervalIntegrable_iff] at hF_int bound_integrable
simp only [intervalIntegral_eq_integral_uIoc]
exact (hasFDerivAt_integral_of_dominated_of_fderiv_le ε_pos hF_meas hF_int hF'_meas h_bound
bound_integrable h_diff).const_smul _
/-- Derivative under integral of `x ↦ ∫ F x a` at a given point `x₀ : 𝕜`, `𝕜 = ℝ` or `𝕜 = ℂ`,
assuming `F x₀` is integrable, `x ↦ F x a` is locally Lipschitz on a ball around `x₀` for ae `a`
(with ball radius independent of `a`) with integrable Lipschitz bound, and `F x` is
ae-measurable for `x` in a possibly smaller neighborhood of `x₀`. -/
nonrec theorem hasDerivAt_integral_of_dominated_loc_of_lip {F : 𝕜 → ℝ → E} {F' : ℝ → E} {x₀ : 𝕜}
(ε_pos : 0 < ε) (hF_meas : ∀ᶠ x in 𝓝 x₀, AEStronglyMeasurable (F x) (μ.restrict (Ι a b)))
(hF_int : IntervalIntegrable (F x₀) μ a b)
(hF'_meas : AEStronglyMeasurable F' (μ.restrict (Ι a b)))
(h_lipsch : ∀ᵐ t ∂μ, t ∈ Ι a b →
LipschitzOnWith (Real.nnabs <| bound t) (fun x => F x t) (ball x₀ ε))
(bound_integrable : IntervalIntegrable (bound : ℝ → ℝ) μ a b)
(h_diff : ∀ᵐ t ∂μ, t ∈ Ι a b → HasDerivAt (fun x => F x t) (F' t) x₀) :
IntervalIntegrable F' μ a b ∧
HasDerivAt (fun x => ∫ t in a..b, F x t ∂μ) (∫ t in a..b, F' t ∂μ) x₀ := by
rw [← ae_restrict_iff' measurableSet_uIoc] at h_lipsch h_diff
simp only [intervalIntegrable_iff] at hF_int bound_integrable ⊢
simp only [intervalIntegral_eq_integral_uIoc]
have := hasDerivAt_integral_of_dominated_loc_of_lip ε_pos hF_meas hF_int hF'_meas h_lipsch
bound_integrable h_diff
exact ⟨this.1, this.2.const_smul _⟩
/-- Derivative under integral of `x ↦ ∫ F x a` at a given point `x₀ : 𝕜`, `𝕜 = ℝ` or `𝕜 = ℂ`,
assuming `F x₀` is integrable, `x ↦ F x a` is differentiable on an interval around `x₀` for ae `a`
(with interval radius independent of `a`) with derivative uniformly bounded by an integrable
function, and `F x` is ae-measurable for `x` in a possibly smaller neighborhood of `x₀`. -/
nonrec theorem hasDerivAt_integral_of_dominated_loc_of_deriv_le
{F : 𝕜 → ℝ → E} {F' : 𝕜 → ℝ → E} {x₀ : 𝕜}
(ε_pos : 0 < ε) (hF_meas : ∀ᶠ x in 𝓝 x₀, AEStronglyMeasurable (F x) (μ.restrict (Ι a b)))
(hF_int : IntervalIntegrable (F x₀) μ a b)
(hF'_meas : AEStronglyMeasurable (F' x₀) (μ.restrict (Ι a b)))
(h_bound : ∀ᵐ t ∂μ, t ∈ Ι a b → ∀ x ∈ ball x₀ ε, ‖F' x t‖ ≤ bound t)
(bound_integrable : IntervalIntegrable bound μ a b)
(h_diff : ∀ᵐ t ∂μ, t ∈ Ι a b → ∀ x ∈ ball x₀ ε, HasDerivAt (fun x => F x t) (F' x t) x) :
IntervalIntegrable (F' x₀) μ a b ∧
HasDerivAt (fun x => ∫ t in a..b, F x t ∂μ) (∫ t in a..b, F' x₀ t ∂μ) x₀ := by
rw [← ae_restrict_iff' measurableSet_uIoc] at h_bound h_diff
simp only [intervalIntegrable_iff] at hF_int bound_integrable ⊢
simp only [intervalIntegral_eq_integral_uIoc]
have := hasDerivAt_integral_of_dominated_loc_of_deriv_le ε_pos hF_meas hF_int hF'_meas h_bound
bound_integrable h_diff
exact ⟨this.1, this.2.const_smul _⟩
end intervalIntegral |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/VectorField.lean | import Mathlib.Analysis.Calculus.FDeriv.Symmetric
/-!
# Vector fields in vector spaces
We study functions of the form `V : E → E` on a vector space, thinking of these as vector fields.
We define several notions in this context, with the aim to generalize them to vector fields on
manifolds.
Notably, we define the pullback of a vector field under a map, as
`VectorField.pullback 𝕜 f V x := (fderiv 𝕜 f x).inverse (V (f x))` (together with the same notion
within a set).
We also define the Lie bracket of two vector fields as
`VectorField.lieBracket 𝕜 V W x := fderiv 𝕜 W x (V x) - fderiv 𝕜 V x (W x)`
(together with the same notion within a set).
In addition to comprehensive API on these two notions, the main results are the following:
* `VectorField.pullback_lieBracket` states that the pullback of the Lie bracket
is the Lie bracket of the pullbacks, when the second derivative is symmetric.
* `VectorField.leibniz_identity_lieBracket` is the Leibniz
identity `[U, [V, W]] = [[U, V], W] + [V, [U, W]]`.
-/
open Set
open scoped Topology
noncomputable section
variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] {n : WithTop ℕ∞}
{E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E]
{F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F]
{G : Type*} [NormedAddCommGroup G] [NormedSpace 𝕜 G]
{V W V₁ W₁ : E → E} {s t : Set E} {x : E}
/-!
### The Lie bracket of vector fields in a vector space
We define the Lie bracket of two vector fields, and call it `lieBracket 𝕜 V W x`. We also define
a version localized to sets, `lieBracketWithin 𝕜 V W s x`. We copy the relevant API
of `fderivWithin` and `fderiv` for these notions to get a comprehensive API.
-/
namespace VectorField
variable (𝕜) in
/-- The Lie bracket `[V, W] (x)` of two vector fields at a point, defined as
`DW(x) (V x) - DV(x) (W x)`. -/
def lieBracket (V W : E → E) (x : E) : E :=
fderiv 𝕜 W x (V x) - fderiv 𝕜 V x (W x)
variable (𝕜) in
/-- The Lie bracket `[V, W] (x)` of two vector fields within a set at a point, defined as
`DW(x) (V x) - DV(x) (W x)` where the derivatives are taken inside `s`. -/
def lieBracketWithin (V W : E → E) (s : Set E) (x : E) : E :=
fderivWithin 𝕜 W s x (V x) - fderivWithin 𝕜 V s x (W x)
lemma lieBracket_eq :
lieBracket 𝕜 V W = fun x ↦ fderiv 𝕜 W x (V x) - fderiv 𝕜 V x (W x) := rfl
lemma lieBracketWithin_eq :
lieBracketWithin 𝕜 V W s =
fun x ↦ fderivWithin 𝕜 W s x (V x) - fderivWithin 𝕜 V s x (W x) := rfl
@[simp]
theorem lieBracketWithin_univ : lieBracketWithin 𝕜 V W univ = lieBracket 𝕜 V W := by
ext1 x
simp [lieBracketWithin, lieBracket]
lemma lieBracketWithin_eq_zero_of_eq_zero (hV : V x = 0) (hW : W x = 0) :
lieBracketWithin 𝕜 V W s x = 0 := by
simp [lieBracketWithin, hV, hW]
lemma lieBracket_eq_zero_of_eq_zero (hV : V x = 0) (hW : W x = 0) :
lieBracket 𝕜 V W x = 0 := by
simp [lieBracket, hV, hW]
lemma lieBracketWithin_swap : lieBracketWithin 𝕜 V W s = - lieBracketWithin 𝕜 W V s := by
ext x; simp [lieBracketWithin]
lemma lieBracket_swap : lieBracket 𝕜 V W x = - lieBracket 𝕜 W V x := by
simp [lieBracket]
@[simp] lemma lieBracketWithin_self : lieBracketWithin 𝕜 V V s = 0 := by
ext x; simp [lieBracketWithin]
@[simp] lemma lieBracket_self : lieBracket 𝕜 V V = 0 := by
ext x; simp [lieBracket]
lemma lieBracketWithin_const_smul_left {c : 𝕜} (hV : DifferentiableWithinAt 𝕜 V s x)
(hs : UniqueDiffWithinAt 𝕜 s x) :
lieBracketWithin 𝕜 (c • V) W s x =
c • lieBracketWithin 𝕜 V W s x := by
simp [lieBracketWithin, smul_sub, fderivWithin_const_smul hs hV]
lemma lieBracket_const_smul_left {c : 𝕜} (hV : DifferentiableAt 𝕜 V x) :
lieBracket 𝕜 (c • V) W x = c • lieBracket 𝕜 V W x := by
simp only [← differentiableWithinAt_univ, ← lieBracketWithin_univ] at hV ⊢
exact lieBracketWithin_const_smul_left hV uniqueDiffWithinAt_univ
lemma lieBracketWithin_const_smul_right {c : 𝕜} (hW : DifferentiableWithinAt 𝕜 W s x)
(hs : UniqueDiffWithinAt 𝕜 s x) :
lieBracketWithin 𝕜 V (c • W) s x =
c • lieBracketWithin 𝕜 V W s x := by
simp [lieBracketWithin, smul_sub, fderivWithin_const_smul hs hW]
lemma lieBracket_const_smul_right {c : 𝕜} (hW : DifferentiableAt 𝕜 W x) :
lieBracket 𝕜 V (c • W) x = c • lieBracket 𝕜 V W x := by
simp only [← differentiableWithinAt_univ, ← lieBracketWithin_univ] at hW ⊢
exact lieBracketWithin_const_smul_right hW uniqueDiffWithinAt_univ
/--
Product rule for Lie Brackets: given two vector fields `V W : E → E` and a function `f : E → 𝕜`,
we have `[V, f • W] = (df V) • W + f • [V, W]`
-/
lemma lieBracketWithin_smul_right {f : E → 𝕜} (hf : DifferentiableWithinAt 𝕜 f s x)
(hW : DifferentiableWithinAt 𝕜 W s x) (hs : UniqueDiffWithinAt 𝕜 s x) :
lieBracketWithin 𝕜 V (fun y ↦ f y • W y) s x =
(fderivWithin 𝕜 f s x) (V x) • (W x) + (f x) • lieBracketWithin 𝕜 V W s x := by
simp [lieBracketWithin, fderivWithin_fun_smul hs hf hW, map_smul, add_comm, smul_sub,
add_sub_assoc]
/--
Product rule for Lie Brackets: given two vector fields `V W : E → E` and a function `f : E → 𝕜`,
we have `[V, f • W] = (df V) • W + f • [V, W]`
-/
lemma lieBracket_smul_right {f : E → 𝕜} (hf : DifferentiableAt 𝕜 f x)
(hW : DifferentiableAt 𝕜 W x) :
lieBracket 𝕜 V (fun y ↦ f y • W y) x =
(fderiv 𝕜 f x) (V x) • (W x) + (f x) • lieBracket 𝕜 V W x := by
simp_rw [← differentiableWithinAt_univ, ← lieBracketWithin_univ, fderiv] at hW hf ⊢
exact lieBracketWithin_smul_right hf hW uniqueDiffWithinAt_univ
/--
Product rule for Lie Brackets: given two vector fields `V W : E → E` and a function `f : E → 𝕜`,
we have `[f • V, W] = - (df W) • V + f • [V, W]`
-/
lemma lieBracketWithin_smul_left {f : E → 𝕜} (hf : DifferentiableWithinAt 𝕜 f s x)
(hV : DifferentiableWithinAt 𝕜 V s x) (hs : UniqueDiffWithinAt 𝕜 s x) :
lieBracketWithin 𝕜 (fun y ↦ f y • V y) W s x =
- (fderivWithin 𝕜 f s x) (W x) • (V x) + (f x) • lieBracketWithin 𝕜 V W s x := by
rw [lieBracketWithin_swap, Pi.neg_apply, lieBracketWithin_smul_right hf hV hs,
lieBracketWithin_swap, add_comm]
simp
/--
Product rule for Lie Brackets: given two vector fields `V W : E → E` and a function `f : E → 𝕜`,
we have `[f • V, W] = - (df W) • V + f • [V, W]`
-/
lemma lieBracket_smul_left {f : E → 𝕜} (hf : DifferentiableAt 𝕜 f x)
(hV : DifferentiableAt 𝕜 V x) :
lieBracket 𝕜 (fun y ↦ f y • V y) W x =
- (fderiv 𝕜 f x) (W x) • (V x) + (f x) • lieBracket 𝕜 V W x := by
rw [lieBracket_swap, lieBracket_smul_right hf hV, lieBracket_swap, add_comm]
simp
@[deprecated (since := "2025-10-12")]
alias lieBracket_fmul_left := lieBracket_smul_left
lemma lieBracketWithin_add_left (hV : DifferentiableWithinAt 𝕜 V s x)
(hV₁ : DifferentiableWithinAt 𝕜 V₁ s x) (hs : UniqueDiffWithinAt 𝕜 s x) :
lieBracketWithin 𝕜 (V + V₁) W s x =
lieBracketWithin 𝕜 V W s x + lieBracketWithin 𝕜 V₁ W s x := by
simp only [lieBracketWithin, Pi.add_apply, map_add]
rw [fderivWithin_add hs hV hV₁, ContinuousLinearMap.add_apply]
abel
lemma lieBracket_add_left (hV : DifferentiableAt 𝕜 V x) (hV₁ : DifferentiableAt 𝕜 V₁ x) :
lieBracket 𝕜 (V + V₁) W x =
lieBracket 𝕜 V W x + lieBracket 𝕜 V₁ W x := by
simp only [lieBracket, Pi.add_apply, map_add]
rw [fderiv_add hV hV₁, ContinuousLinearMap.add_apply]
abel
/-- We have `[0, W] = 0` for all vector fields `W`: this depends on the junk value 0
if `W` is not differentiable. Version within a set. -/
@[simp]
lemma lieBracketWithin_zero_left : lieBracketWithin 𝕜 0 W s = 0 := by ext; simp [lieBracketWithin]
/-- We have `[W, 0] = 0` for all vector fields `W`: this depends on the junk value 0
if `W` is not differentiable. Version within a set. -/
@[simp]
lemma lieBracketWithin_zero_right : lieBracketWithin 𝕜 W 0 s = 0 := by ext; simp [lieBracketWithin]
/-- We have `[0, W] = 0` for all vector fields `W`: this depends on the junk value 0
if `W` is not differentiable. -/
@[simp]
lemma lieBracket_zero_left : lieBracket 𝕜 0 W = 0 := by simp [← lieBracketWithin_univ]
/-- We have `[W, 0] = 0` for all vector fields `W`: this depends on the junk value 0
if `W` is not differentiable. -/
@[simp]
lemma lieBracket_zero_right : lieBracket 𝕜 W 0 = 0 := by simp [← lieBracketWithin_univ]
lemma lieBracketWithin_add_right (hW : DifferentiableWithinAt 𝕜 W s x)
(hW₁ : DifferentiableWithinAt 𝕜 W₁ s x) (hs : UniqueDiffWithinAt 𝕜 s x) :
lieBracketWithin 𝕜 V (W + W₁) s x =
lieBracketWithin 𝕜 V W s x + lieBracketWithin 𝕜 V W₁ s x := by
simp only [lieBracketWithin, Pi.add_apply, map_add]
rw [fderivWithin_add hs hW hW₁, ContinuousLinearMap.add_apply]
abel
lemma lieBracket_add_right (hW : DifferentiableAt 𝕜 W x) (hW₁ : DifferentiableAt 𝕜 W₁ x) :
lieBracket 𝕜 V (W + W₁) x =
lieBracket 𝕜 V W x + lieBracket 𝕜 V W₁ x := by
simp only [lieBracket, Pi.add_apply, map_add]
rw [fderiv_add hW hW₁, ContinuousLinearMap.add_apply]
abel
/-- The differentiation operator along `[W, V]`
is the commutator of the differentiation operators along `W` and `V`. -/
lemma fderivWithin_apply_lieBracket_of_isSymmSndFDerivWithinAt {f : E → F}
(hf : ContDiffWithinAt 𝕜 2 f s x) (hsymm : IsSymmSndFDerivWithinAt 𝕜 f s x)
(hs : UniqueDiffOn 𝕜 s) (hxs : x ∈ s)
(hW : DifferentiableWithinAt 𝕜 W s x) (hV : DifferentiableWithinAt 𝕜 V s x) :
fderivWithin 𝕜 f s x (lieBracketWithin 𝕜 V W s x) =
fderivWithin 𝕜 (fun x ↦ fderivWithin 𝕜 f s x (W x)) s x (V x) -
fderivWithin 𝕜 (fun x ↦ fderivWithin 𝕜 f s x (V x)) s x (W x) := by
have H₀ : DifferentiableWithinAt 𝕜 (fderivWithin 𝕜 f s) s x :=
(hf.fderivWithin_right hs (by decide) hxs).differentiableWithinAt le_rfl
have H₁ : UniqueDiffWithinAt 𝕜 s x := hs x hxs
rw [fderivWithin_clm_apply, fderivWithin_clm_apply] <;> try assumption
simp [lieBracketWithin, hsymm (V _) (W _)]
/-- The differentiation operator along `[W, V]`
is the commutator of the differentiation operators along `W` and `V`. -/
lemma fderiv_apply_lieBracket_of_isSymmSndFDerivAt {f : E → F}
(hf : ContDiffAt 𝕜 2 f x) (hsymm : IsSymmSndFDerivAt 𝕜 f x)
(hW : DifferentiableAt 𝕜 W x) (hV : DifferentiableAt 𝕜 V x) :
fderiv 𝕜 f x (lieBracket 𝕜 V W x) =
fderiv 𝕜 (fun x ↦ fderiv 𝕜 f x (W x)) x (V x) -
fderiv 𝕜 (fun x ↦ fderiv 𝕜 f x (V x)) x (W x) := by
simp only [← fderivWithin_univ, ← lieBracketWithin_univ, ← contDiffWithinAt_univ,
← isSymmSndFDerivWithinAt_univ, ← differentiableWithinAt_univ] at *
exact fderivWithin_apply_lieBracket_of_isSymmSndFDerivWithinAt hf hsymm (by simp) (by simp)
hW hV
/-- The differentiation operator along `[W, V]`
is the commutator of the differentiation operators along `W` and `V`. -/
lemma fderivWithin_apply_lieBracket {f : E → F} {n : WithTop ℕ∞}
(hf : ContDiffWithinAt 𝕜 n f s x) (hn : minSmoothness 𝕜 2 ≤ n)
(hs : UniqueDiffOn 𝕜 s) (hxs' : x ∈ closure (interior s)) (hxs : x ∈ s)
(hW : DifferentiableWithinAt 𝕜 W s x) (hV : DifferentiableWithinAt 𝕜 V s x) :
fderivWithin 𝕜 f s x (lieBracketWithin 𝕜 V W s x) =
fderivWithin 𝕜 (fun x ↦ fderivWithin 𝕜 f s x (W x)) s x (V x) -
fderivWithin 𝕜 (fun x ↦ fderivWithin 𝕜 f s x (V x)) s x (W x) := by
apply fderivWithin_apply_lieBracket_of_isSymmSndFDerivWithinAt <;> try assumption
exacts [hf.of_le <| le_minSmoothness.trans hn, hf.isSymmSndFDerivWithinAt hn hs hxs' hxs]
/-- The differentiation operator along `[W, V]`
is the commutator of the differentiation operators along `W` and `V`. -/
lemma fderiv_apply_lieBracket {f : E → F} {n : WithTop ℕ∞}
(hf : ContDiffAt 𝕜 n f x) (hn : minSmoothness 𝕜 2 ≤ n)
(hW : DifferentiableAt 𝕜 W x) (hV : DifferentiableAt 𝕜 V x) :
fderiv 𝕜 f x (lieBracket 𝕜 V W x) =
fderiv 𝕜 (fun x ↦ fderiv 𝕜 f x (W x)) x (V x) -
fderiv 𝕜 (fun x ↦ fderiv 𝕜 f x (V x)) x (W x) := by
apply fderiv_apply_lieBracket_of_isSymmSndFDerivAt <;> try assumption
exacts [hf.of_le <| le_minSmoothness.trans hn, hf.isSymmSndFDerivAt hn]
lemma _root_.ContDiffWithinAt.lieBracketWithin_vectorField
{m n : WithTop ℕ∞} (hV : ContDiffWithinAt 𝕜 n V s x)
(hW : ContDiffWithinAt 𝕜 n W s x) (hs : UniqueDiffOn 𝕜 s) (hmn : m + 1 ≤ n) (hx : x ∈ s) :
ContDiffWithinAt 𝕜 m (lieBracketWithin 𝕜 V W s) s x := by
apply ContDiffWithinAt.sub
· exact ContDiffWithinAt.clm_apply (hW.fderivWithin_right hs hmn hx)
(hV.of_le (le_trans le_self_add hmn))
· exact ContDiffWithinAt.clm_apply (hV.fderivWithin_right hs hmn hx)
(hW.of_le (le_trans le_self_add hmn))
lemma _root_.ContDiffAt.lieBracket_vectorField {m n : WithTop ℕ∞} (hV : ContDiffAt 𝕜 n V x)
(hW : ContDiffAt 𝕜 n W x) (hmn : m + 1 ≤ n) :
ContDiffAt 𝕜 m (lieBracket 𝕜 V W) x := by
rw [← contDiffWithinAt_univ] at hV hW ⊢
simp_rw [← lieBracketWithin_univ]
exact hV.lieBracketWithin_vectorField hW uniqueDiffOn_univ hmn (mem_univ _)
lemma _root_.ContDiffOn.lieBracketWithin_vectorField {m n : WithTop ℕ∞} (hV : ContDiffOn 𝕜 n V s)
(hW : ContDiffOn 𝕜 n W s) (hs : UniqueDiffOn 𝕜 s) (hmn : m + 1 ≤ n) :
ContDiffOn 𝕜 m (lieBracketWithin 𝕜 V W s) s :=
fun x hx ↦ (hV x hx).lieBracketWithin_vectorField (hW x hx) hs hmn hx
lemma _root_.ContDiff.lieBracket_vectorField {m n : WithTop ℕ∞} (hV : ContDiff 𝕜 n V)
(hW : ContDiff 𝕜 n W) (hmn : m + 1 ≤ n) :
ContDiff 𝕜 m (lieBracket 𝕜 V W) :=
contDiff_iff_contDiffAt.2 (fun _ ↦ hV.contDiffAt.lieBracket_vectorField hW.contDiffAt hmn)
theorem lieBracketWithin_of_mem_nhdsWithin (st : t ∈ 𝓝[s] x) (hs : UniqueDiffWithinAt 𝕜 s x)
(hV : DifferentiableWithinAt 𝕜 V t x) (hW : DifferentiableWithinAt 𝕜 W t x) :
lieBracketWithin 𝕜 V W s x = lieBracketWithin 𝕜 V W t x := by
simp [lieBracketWithin, fderivWithin_of_mem_nhdsWithin st hs hV,
fderivWithin_of_mem_nhdsWithin st hs hW]
theorem lieBracketWithin_subset (st : s ⊆ t) (ht : UniqueDiffWithinAt 𝕜 s x)
(hV : DifferentiableWithinAt 𝕜 V t x) (hW : DifferentiableWithinAt 𝕜 W t x) :
lieBracketWithin 𝕜 V W s x = lieBracketWithin 𝕜 V W t x :=
lieBracketWithin_of_mem_nhdsWithin (nhdsWithin_mono _ st self_mem_nhdsWithin) ht hV hW
theorem lieBracketWithin_inter (ht : t ∈ 𝓝 x) :
lieBracketWithin 𝕜 V W (s ∩ t) x = lieBracketWithin 𝕜 V W s x := by
simp [lieBracketWithin, fderivWithin_inter, ht]
theorem lieBracketWithin_of_mem_nhds (h : s ∈ 𝓝 x) :
lieBracketWithin 𝕜 V W s x = lieBracket 𝕜 V W x := by
rw [← lieBracketWithin_univ, ← univ_inter s, lieBracketWithin_inter h]
theorem lieBracketWithin_of_isOpen (hs : IsOpen s) (hx : x ∈ s) :
lieBracketWithin 𝕜 V W s x = lieBracket 𝕜 V W x :=
lieBracketWithin_of_mem_nhds (hs.mem_nhds hx)
theorem lieBracketWithin_eq_lieBracket (hs : UniqueDiffWithinAt 𝕜 s x)
(hV : DifferentiableAt 𝕜 V x) (hW : DifferentiableAt 𝕜 W x) :
lieBracketWithin 𝕜 V W s x = lieBracket 𝕜 V W x := by
simp [lieBracketWithin, lieBracket, fderivWithin_eq_fderiv, hs, hV, hW]
/-- Variant of `lieBracketWithin_congr_set` where one requires the sets to coincide only in
the complement of a point. -/
theorem lieBracketWithin_congr_set' (y : E) (h : s =ᶠ[𝓝[{y}ᶜ] x] t) :
lieBracketWithin 𝕜 V W s x = lieBracketWithin 𝕜 V W t x := by
simp [lieBracketWithin, fderivWithin_congr_set' _ h]
theorem lieBracketWithin_congr_set (h : s =ᶠ[𝓝 x] t) :
lieBracketWithin 𝕜 V W s x = lieBracketWithin 𝕜 V W t x :=
lieBracketWithin_congr_set' x <| h.filter_mono inf_le_left
/-- Variant of `lieBracketWithin_eventually_congr_set` where one requires the sets to coincide only
in the complement of a point. -/
theorem lieBracketWithin_eventually_congr_set' (y : E) (h : s =ᶠ[𝓝[{y}ᶜ] x] t) :
lieBracketWithin 𝕜 V W s =ᶠ[𝓝 x] lieBracketWithin 𝕜 V W t :=
(eventually_nhds_nhdsWithin.2 h).mono fun _ => lieBracketWithin_congr_set' y
theorem lieBracketWithin_eventually_congr_set (h : s =ᶠ[𝓝 x] t) :
lieBracketWithin 𝕜 V W s =ᶠ[𝓝 x] lieBracketWithin 𝕜 V W t :=
lieBracketWithin_eventually_congr_set' x <| h.filter_mono inf_le_left
theorem _root_.DifferentiableWithinAt.lieBracketWithin_congr_mono
(hV : DifferentiableWithinAt 𝕜 V s x) (hVs : EqOn V₁ V t) (hVx : V₁ x = V x)
(hW : DifferentiableWithinAt 𝕜 W s x) (hWs : EqOn W₁ W t) (hWx : W₁ x = W x)
(hxt : UniqueDiffWithinAt 𝕜 t x) (h₁ : t ⊆ s) :
lieBracketWithin 𝕜 V₁ W₁ t x = lieBracketWithin 𝕜 V W s x := by
simp [lieBracketWithin, hV.fderivWithin_congr_mono, hW.fderivWithin_congr_mono, hVs, hVx,
hWs, hWx, hxt, h₁]
theorem _root_.Filter.EventuallyEq.lieBracketWithin_vectorField_eq
(hV : V₁ =ᶠ[𝓝[s] x] V) (hxV : V₁ x = V x) (hW : W₁ =ᶠ[𝓝[s] x] W) (hxW : W₁ x = W x) :
lieBracketWithin 𝕜 V₁ W₁ s x = lieBracketWithin 𝕜 V W s x := by
simp only [lieBracketWithin, hV.fderivWithin_eq hxV, hW.fderivWithin_eq hxW, hxV, hxW]
theorem _root_.Filter.EventuallyEq.lieBracketWithin_vectorField_eq_of_mem
(hV : V₁ =ᶠ[𝓝[s] x] V) (hW : W₁ =ᶠ[𝓝[s] x] W) (hx : x ∈ s) :
lieBracketWithin 𝕜 V₁ W₁ s x = lieBracketWithin 𝕜 V W s x :=
hV.lieBracketWithin_vectorField_eq (mem_of_mem_nhdsWithin hx hV :)
hW (mem_of_mem_nhdsWithin hx hW :)
/-- If vector fields coincide on a neighborhood of a point within a set, then the Lie brackets
also coincide on a neighborhood of this point within this set. Version where one considers the Lie
bracket within a subset. -/
theorem _root_.Filter.EventuallyEq.lieBracketWithin_vectorField'
(hV : V₁ =ᶠ[𝓝[s] x] V) (hW : W₁ =ᶠ[𝓝[s] x] W) (ht : t ⊆ s) :
lieBracketWithin 𝕜 V₁ W₁ t =ᶠ[𝓝[s] x] lieBracketWithin 𝕜 V W t := by
filter_upwards [hV.fderivWithin' ht (𝕜 := 𝕜), hW.fderivWithin' ht (𝕜 := 𝕜), hV, hW]
with x hV' hW' hV hW
simp [lieBracketWithin, hV', hW', hV, hW]
protected theorem _root_.Filter.EventuallyEq.lieBracketWithin_vectorField
(hV : V₁ =ᶠ[𝓝[s] x] V) (hW : W₁ =ᶠ[𝓝[s] x] W) :
lieBracketWithin 𝕜 V₁ W₁ s =ᶠ[𝓝[s] x] lieBracketWithin 𝕜 V W s :=
hV.lieBracketWithin_vectorField' hW Subset.rfl
protected theorem _root_.Filter.EventuallyEq.lieBracketWithin_vectorField_eq_of_insert
(hV : V₁ =ᶠ[𝓝[insert x s] x] V) (hW : W₁ =ᶠ[𝓝[insert x s] x] W) :
lieBracketWithin 𝕜 V₁ W₁ s x = lieBracketWithin 𝕜 V W s x := by
apply mem_of_mem_nhdsWithin (mem_insert x s) (hV.lieBracketWithin_vectorField' hW
(subset_insert x s))
theorem _root_.Filter.EventuallyEq.lieBracketWithin_vectorField_eq_nhds
(hV : V₁ =ᶠ[𝓝 x] V) (hW : W₁ =ᶠ[𝓝 x] W) :
lieBracketWithin 𝕜 V₁ W₁ s x = lieBracketWithin 𝕜 V W s x :=
(hV.filter_mono nhdsWithin_le_nhds).lieBracketWithin_vectorField_eq hV.self_of_nhds
(hW.filter_mono nhdsWithin_le_nhds) hW.self_of_nhds
theorem lieBracketWithin_congr
(hV : EqOn V₁ V s) (hVx : V₁ x = V x) (hW : EqOn W₁ W s) (hWx : W₁ x = W x) :
lieBracketWithin 𝕜 V₁ W₁ s x = lieBracketWithin 𝕜 V W s x :=
(hV.eventuallyEq.filter_mono inf_le_right).lieBracketWithin_vectorField_eq hVx
(hW.eventuallyEq.filter_mono inf_le_right) hWx
/-- Version of `lieBracketWithin_congr` in which one assumes that the point belongs to the
given set. -/
theorem lieBracketWithin_congr' (hV : EqOn V₁ V s) (hW : EqOn W₁ W s) (hx : x ∈ s) :
lieBracketWithin 𝕜 V₁ W₁ s x = lieBracketWithin 𝕜 V W s x :=
lieBracketWithin_congr hV (hV hx) hW (hW hx)
theorem _root_.Filter.EventuallyEq.lieBracket_vectorField_eq
(hV : V₁ =ᶠ[𝓝 x] V) (hW : W₁ =ᶠ[𝓝 x] W) :
lieBracket 𝕜 V₁ W₁ x = lieBracket 𝕜 V W x := by
rw [← lieBracketWithin_univ, ← lieBracketWithin_univ, hV.lieBracketWithin_vectorField_eq_nhds hW]
protected theorem _root_.Filter.EventuallyEq.lieBracket_vectorField
(hV : V₁ =ᶠ[𝓝 x] V) (hW : W₁ =ᶠ[𝓝 x] W) : lieBracket 𝕜 V₁ W₁ =ᶠ[𝓝 x] lieBracket 𝕜 V W := by
filter_upwards [hV.eventuallyEq_nhds, hW.eventuallyEq_nhds] with y hVy hWy
exact hVy.lieBracket_vectorField_eq hWy
/-- The Lie bracket of vector fields in vector spaces satisfies the Leibniz identity
`[U, [V, W]] = [[U, V], W] + [V, [U, W]]`. -/
lemma leibniz_identity_lieBracketWithin_of_isSymmSndFDerivWithinAt
{U V W : E → E} {s : Set E} {x : E} (hs : UniqueDiffOn 𝕜 s) (hx : x ∈ s)
(hU : ContDiffWithinAt 𝕜 2 U s x) (hV : ContDiffWithinAt 𝕜 2 V s x)
(hW : ContDiffWithinAt 𝕜 2 W s x)
(h'U : IsSymmSndFDerivWithinAt 𝕜 U s x) (h'V : IsSymmSndFDerivWithinAt 𝕜 V s x)
(h'W : IsSymmSndFDerivWithinAt 𝕜 W s x) :
lieBracketWithin 𝕜 U (lieBracketWithin 𝕜 V W s) s x =
lieBracketWithin 𝕜 (lieBracketWithin 𝕜 U V s) W s x
+ lieBracketWithin 𝕜 V (lieBracketWithin 𝕜 U W s) s x := by
simp only [lieBracketWithin_eq, map_sub]
have aux₁ {U V : E → E} (hU : ContDiffWithinAt 𝕜 2 U s x) (hV : ContDiffWithinAt 𝕜 2 V s x) :
DifferentiableWithinAt 𝕜 (fun x ↦ (fderivWithin 𝕜 V s x) (U x)) s x :=
have := hV.fderivWithin_right_apply (hU.of_le one_le_two) hs le_rfl hx
this.differentiableWithinAt le_rfl
have aux₂ {U V : E → E} (hU : ContDiffWithinAt 𝕜 2 U s x) (hV : ContDiffWithinAt 𝕜 2 V s x) :
fderivWithin 𝕜 (fun y ↦ (fderivWithin 𝕜 U s y) (V y)) s x =
(fderivWithin 𝕜 U s x).comp (fderivWithin 𝕜 V s x) +
(fderivWithin 𝕜 (fderivWithin 𝕜 U s) s x).flip (V x) := by
refine fderivWithin_clm_apply (hs x hx) ?_ (hV.differentiableWithinAt one_le_two)
exact (hU.fderivWithin_right hs le_rfl hx).differentiableWithinAt le_rfl
rw [fderivWithin_fun_sub (hs x hx) (aux₁ hV hW) (aux₁ hW hV)]
rw [fderivWithin_fun_sub (hs x hx) (aux₁ hU hV) (aux₁ hV hU)]
rw [fderivWithin_fun_sub (hs x hx) (aux₁ hU hW) (aux₁ hW hU)]
rw [aux₂ hW hV, aux₂ hV hW, aux₂ hV hU, aux₂ hU hV, aux₂ hW hU, aux₂ hU hW]
simp only [ContinuousLinearMap.coe_sub', Pi.sub_apply, ContinuousLinearMap.add_apply,
ContinuousLinearMap.coe_comp', Function.comp_apply, ContinuousLinearMap.flip_apply, h'V.eq,
h'U.eq, h'W.eq]
abel
/-- The Lie bracket of vector fields in vector spaces satisfies the Leibniz identity
`[U, [V, W]] = [[U, V], W] + [V, [U, W]]`. -/
lemma leibniz_identity_lieBracketWithin (hn : minSmoothness 𝕜 2 ≤ n)
{U V W : E → E} {s : Set E} {x : E}
(hs : UniqueDiffOn 𝕜 s) (h'x : x ∈ closure (interior s)) (hx : x ∈ s)
(hU : ContDiffWithinAt 𝕜 n U s x) (hV : ContDiffWithinAt 𝕜 n V s x)
(hW : ContDiffWithinAt 𝕜 n W s x) :
lieBracketWithin 𝕜 U (lieBracketWithin 𝕜 V W s) s x =
lieBracketWithin 𝕜 (lieBracketWithin 𝕜 U V s) W s x
+ lieBracketWithin 𝕜 V (lieBracketWithin 𝕜 U W s) s x := by
apply leibniz_identity_lieBracketWithin_of_isSymmSndFDerivWithinAt hs hx
(hU.of_le (le_minSmoothness.trans hn)) (hV.of_le (le_minSmoothness.trans hn))
(hW.of_le (le_minSmoothness.trans hn))
· exact hU.isSymmSndFDerivWithinAt hn hs h'x hx
· exact hV.isSymmSndFDerivWithinAt hn hs h'x hx
· exact hW.isSymmSndFDerivWithinAt hn hs h'x hx
/-- The Lie bracket of vector fields in vector spaces satisfies the Leibniz identity
`[U, [V, W]] = [[U, V], W] + [V, [U, W]]`. -/
lemma leibniz_identity_lieBracket (hn : minSmoothness 𝕜 2 ≤ n) {U V W : E → E} {x : E}
(hU : ContDiffAt 𝕜 n U x) (hV : ContDiffAt 𝕜 n V x) (hW : ContDiffAt 𝕜 n W x) :
lieBracket 𝕜 U (lieBracket 𝕜 V W) x =
lieBracket 𝕜 (lieBracket 𝕜 U V) W x + lieBracket 𝕜 V (lieBracket 𝕜 U W) x := by
simp only [← lieBracketWithin_univ, ← contDiffWithinAt_univ] at hU hV hW ⊢
exact leibniz_identity_lieBracketWithin hn uniqueDiffOn_univ (by simp) (mem_univ _) hU hV hW
/-!
### The pullback of vector fields in a vector space
-/
variable (𝕜) in
/-- The pullback of a vector field under a function, defined
as `(f^* V) (x) = Df(x)^{-1} (V (f x))`. If `Df(x)` is not invertible, we use the junk value `0`.
-/
def pullback (f : E → F) (V : F → F) (x : E) : E := (fderiv 𝕜 f x).inverse (V (f x))
variable (𝕜) in
/-- The pullback within a set of a vector field under a function, defined
as `(f^* V) (x) = Df(x)^{-1} (V (f x))` where `Df(x)` is the derivative of `f` within `s`.
If `Df(x)` is not invertible, we use the junk value `0`.
-/
def pullbackWithin (f : E → F) (V : F → F) (s : Set E) (x : E) : E :=
(fderivWithin 𝕜 f s x).inverse (V (f x))
lemma pullbackWithin_eq {f : E → F} {V : F → F} {s : Set E} :
pullbackWithin 𝕜 f V s = fun x ↦ (fderivWithin 𝕜 f s x).inverse (V (f x)) := rfl
lemma pullback_eq_of_fderiv_eq
{f : E → F} {M : E ≃L[𝕜] F} {x : E} (hf : M = fderiv 𝕜 f x) (V : F → F) :
pullback 𝕜 f V x = M.symm (V (f x)) := by
simp [pullback, ← hf]
lemma pullback_eq_of_not_isInvertible {f : E → F} {x : E}
(h : ¬(fderiv 𝕜 f x).IsInvertible) (V : F → F) :
pullback 𝕜 f V x = 0 := by
simp [pullback, h]
lemma pullbackWithin_eq_of_not_isInvertible {f : E → F} {x : E}
(h : ¬(fderivWithin 𝕜 f s x).IsInvertible) (V : F → F) :
pullbackWithin 𝕜 f V s x = 0 := by
simp [pullbackWithin, h]
lemma pullbackWithin_eq_of_fderivWithin_eq
{f : E → F} {M : E ≃L[𝕜] F} {x : E} (hf : M = fderivWithin 𝕜 f s x) (V : F → F) :
pullbackWithin 𝕜 f V s x = M.symm (V (f x)) := by
simp [pullbackWithin, ← hf]
@[simp] lemma pullbackWithin_univ {f : E → F} {V : F → F} :
pullbackWithin 𝕜 f V univ = pullback 𝕜 f V := by
ext x
simp [pullbackWithin, pullback]
open scoped Topology Filter
lemma fderiv_pullback (f : E → F) (V : F → F) (x : E) (h'f : (fderiv 𝕜 f x).IsInvertible) :
fderiv 𝕜 f x (pullback 𝕜 f V x) = V (f x) := by
rcases h'f with ⟨M, hM⟩
simp [pullback_eq_of_fderiv_eq hM, ← hM]
lemma fderivWithin_pullbackWithin {f : E → F} {V : F → F} {x : E}
(h'f : (fderivWithin 𝕜 f s x).IsInvertible) :
fderivWithin 𝕜 f s x (pullbackWithin 𝕜 f V s x) = V (f x) := by
rcases h'f with ⟨M, hM⟩
simp [pullbackWithin_eq_of_fderivWithin_eq hM, ← hM]
open Set
variable [CompleteSpace E]
/-- If a `C^2` map has an invertible derivative within a set at a point, then nearby derivatives
can be written as continuous linear equivs, which depend in a `C^1` way on the point, as well as
their inverse, and moreover one can compute the derivative of the inverse. -/
lemma _root_.exists_continuousLinearEquiv_fderivWithin_symm_eq
{f : E → F} {s : Set E} {x : E} (h'f : ContDiffWithinAt 𝕜 2 f s x)
(hf : (fderivWithin 𝕜 f s x).IsInvertible) (hs : UniqueDiffOn 𝕜 s) (hx : x ∈ s) :
∃ N : E → (E ≃L[𝕜] F), ContDiffWithinAt 𝕜 1 (fun y ↦ (N y : E →L[𝕜] F)) s x
∧ ContDiffWithinAt 𝕜 1 (fun y ↦ ((N y).symm : F →L[𝕜] E)) s x
∧ (∀ᶠ y in 𝓝[s] x, N y = fderivWithin 𝕜 f s y)
∧ ∀ v, fderivWithin 𝕜 (fun y ↦ ((N y).symm : F →L[𝕜] E)) s x v
= - (N x).symm ∘L ((fderivWithin 𝕜 (fderivWithin 𝕜 f s) s x v)) ∘L (N x).symm := by
classical
rcases hf with ⟨M, hM⟩
let U := {y | ∃ (N : E ≃L[𝕜] F), N = fderivWithin 𝕜 f s y}
have hU : U ∈ 𝓝[s] x := by
have I : range ((↑) : (E ≃L[𝕜] F) → E →L[𝕜] F) ∈ 𝓝 (fderivWithin 𝕜 f s x) := by
rw [← hM]
exact M.nhds
have : ContinuousWithinAt (fderivWithin 𝕜 f s) s x :=
(h'f.fderivWithin_right (m := 1) hs le_rfl hx).continuousWithinAt
exact this I
let N : E → (E ≃L[𝕜] F) := fun x ↦ if h : x ∈ U then h.choose else M
have eN : (fun y ↦ (N y : E →L[𝕜] F)) =ᶠ[𝓝[s] x] fun y ↦ fderivWithin 𝕜 f s y := by
filter_upwards [hU] with y hy
simpa only [hy, ↓reduceDIte, N] using Exists.choose_spec hy
have e'N : N x = fderivWithin 𝕜 f s x := by apply mem_of_mem_nhdsWithin hx eN
have hN : ContDiffWithinAt 𝕜 1 (fun y ↦ (N y : E →L[𝕜] F)) s x := by
have : ContDiffWithinAt 𝕜 1 (fun y ↦ fderivWithin 𝕜 f s y) s x :=
h'f.fderivWithin_right (m := 1) hs le_rfl hx
apply this.congr_of_eventuallyEq eN e'N
have hN' : ContDiffWithinAt 𝕜 1 (fun y ↦ ((N y).symm : F →L[𝕜] E)) s x := by
have : ContDiffWithinAt 𝕜 1 (ContinuousLinearMap.inverse ∘ (fun y ↦ (N y : E →L[𝕜] F))) s x :=
(contDiffAt_map_inverse (N x)).comp_contDiffWithinAt x hN
convert this with y
simp only [Function.comp_apply, ContinuousLinearMap.inverse_equiv]
refine ⟨N, hN, hN', eN, fun v ↦ ?_⟩
have A' y : ContinuousLinearMap.compL 𝕜 F E F (N y : E →L[𝕜] F) ((N y).symm : F →L[𝕜] E)
= ContinuousLinearMap.id 𝕜 F := by ext; simp
have : fderivWithin 𝕜 (fun y ↦ ContinuousLinearMap.compL 𝕜 F E F (N y : E →L[𝕜] F)
((N y).symm : F →L[𝕜] E)) s x v = 0 := by
simp [A', fderivWithin_const_apply]
have I : (N x : E →L[𝕜] F) ∘L (fderivWithin 𝕜 (fun y ↦ ((N y).symm : F →L[𝕜] E)) s x v) =
- (fderivWithin 𝕜 (fun y ↦ (N y : E →L[𝕜] F)) s x v) ∘L ((N x).symm : F →L[𝕜] E) := by
rw [ContinuousLinearMap.fderivWithin_of_bilinear _ (hN.differentiableWithinAt le_rfl)
(hN'.differentiableWithinAt le_rfl) (hs x hx)] at this
simpa [eq_neg_iff_add_eq_zero] using this
have B (M : F →L[𝕜] E) : M = ((N x).symm : F →L[𝕜] E) ∘L ((N x) ∘L M) := by
ext; simp
rw [B (fderivWithin 𝕜 (fun y ↦ ((N y).symm : F →L[𝕜] E)) s x v), I]
simp only [ContinuousLinearMap.comp_neg, eN.fderivWithin_eq e'N]
lemma DifferentiableWithinAt.pullbackWithin {f : E → F} {V : F → F} {s : Set E} {t : Set F} {x : E}
(hV : DifferentiableWithinAt 𝕜 V t (f x))
(hf : ContDiffWithinAt 𝕜 2 f s x) (hf' : (fderivWithin 𝕜 f s x).IsInvertible)
(hs : UniqueDiffOn 𝕜 s) (hx : x ∈ s) (hst : MapsTo f s t) :
DifferentiableWithinAt 𝕜 (pullbackWithin 𝕜 f V s) s x := by
rcases exists_continuousLinearEquiv_fderivWithin_symm_eq hf hf' hs hx
with ⟨M, -, M_symm_smooth, hM, -⟩
simp only [pullbackWithin_eq]
have : DifferentiableWithinAt 𝕜 (fun y ↦ ((M y).symm : F →L[𝕜] E) (V (f y))) s x := by
apply DifferentiableWithinAt.clm_apply
· exact M_symm_smooth.differentiableWithinAt le_rfl
· exact hV.comp _ (hf.differentiableWithinAt one_le_two) hst
apply this.congr_of_eventuallyEq
· filter_upwards [hM] with y hy using by simp [← hy]
· have hMx : M x = fderivWithin 𝕜 f s x := by apply mem_of_mem_nhdsWithin hx hM
simp [← hMx]
/-- If a `C^2` map has an invertible derivative at a point, then nearby derivatives can be written
as continuous linear equivs, which depend in a `C^1` way on the point, as well as their inverse, and
moreover one can compute the derivative of the inverse. -/
lemma _root_.exists_continuousLinearEquiv_fderiv_symm_eq
{f : E → F} {x : E} (h'f : ContDiffAt 𝕜 2 f x) (hf : (fderiv 𝕜 f x).IsInvertible) :
∃ N : E → (E ≃L[𝕜] F), ContDiffAt 𝕜 1 (fun y ↦ (N y : E →L[𝕜] F)) x
∧ ContDiffAt 𝕜 1 (fun y ↦ ((N y).symm : F →L[𝕜] E)) x
∧ (∀ᶠ y in 𝓝 x, N y = fderiv 𝕜 f y)
∧ ∀ v, fderiv 𝕜 (fun y ↦ ((N y).symm : F →L[𝕜] E)) x v
= - (N x).symm ∘L ((fderiv 𝕜 (fderiv 𝕜 f) x v)) ∘L (N x).symm := by
simp only [← fderivWithin_univ, ← contDiffWithinAt_univ, ← nhdsWithin_univ] at hf h'f ⊢
exact exists_continuousLinearEquiv_fderivWithin_symm_eq h'f hf uniqueDiffOn_univ (mem_univ _)
/-- The Lie bracket commutes with taking pullbacks. This requires the function to have symmetric
second derivative. Version in a complete space. One could also give a version avoiding
completeness but requiring that `f` is a local diffeo. -/
lemma pullbackWithin_lieBracketWithin_of_isSymmSndFDerivWithinAt
{f : E → F} {V W : F → F} {x : E} {t : Set F}
(hf : IsSymmSndFDerivWithinAt 𝕜 f s x) (h'f : ContDiffWithinAt 𝕜 2 f s x)
(hV : DifferentiableWithinAt 𝕜 V t (f x)) (hW : DifferentiableWithinAt 𝕜 W t (f x))
(hu : UniqueDiffOn 𝕜 s) (hx : x ∈ s) (hst : MapsTo f s t) :
pullbackWithin 𝕜 f (lieBracketWithin 𝕜 V W t) s x
= lieBracketWithin 𝕜 (pullbackWithin 𝕜 f V s) (pullbackWithin 𝕜 f W s) s x := by
by_cases h : (fderivWithin 𝕜 f s x).IsInvertible; swap
· simp [pullbackWithin_eq_of_not_isInvertible h, lieBracketWithin_eq]
rcases exists_continuousLinearEquiv_fderivWithin_symm_eq h'f h hu hx
with ⟨M, -, M_symm_smooth, hM, M_diff⟩
have hMx : M x = fderivWithin 𝕜 f s x := (mem_of_mem_nhdsWithin hx hM :)
have AV : fderivWithin 𝕜 (pullbackWithin 𝕜 f V s) s x =
fderivWithin 𝕜 (fun y ↦ ((M y).symm : F →L[𝕜] E) (V (f y))) s x := by
apply Filter.EventuallyEq.fderivWithin_eq_of_mem _ hx
filter_upwards [hM] with y hy using pullbackWithin_eq_of_fderivWithin_eq hy _
have AW : fderivWithin 𝕜 (pullbackWithin 𝕜 f W s) s x =
fderivWithin 𝕜 (fun y ↦ ((M y).symm : F →L[𝕜] E) (W (f y))) s x := by
apply Filter.EventuallyEq.fderivWithin_eq_of_mem _ hx
filter_upwards [hM] with y hy using pullbackWithin_eq_of_fderivWithin_eq hy _
have Af : DifferentiableWithinAt 𝕜 f s x := h'f.differentiableWithinAt one_le_two
simp only [lieBracketWithin_eq, pullbackWithin_eq_of_fderivWithin_eq hMx, map_sub, AV, AW]
rw [fderivWithin_clm_apply, fderivWithin_clm_apply]
· simp [fderivWithin_comp' x hW Af hst (hu x hx), ← hMx,
fderivWithin_comp' x hV Af hst (hu x hx), M_diff, hf.eq]
· exact hu x hx
· exact M_symm_smooth.differentiableWithinAt le_rfl
· exact hV.comp x Af hst
· exact hu x hx
· exact M_symm_smooth.differentiableWithinAt le_rfl
· exact hW.comp x Af hst
/-- The Lie bracket commutes with taking pullbacks. This requires the function to have symmetric
second derivative. Version in a complete space. One could also give a version avoiding
completeness but requiring that `f` is a local diffeo. Variant where unique differentiability and
the invariance property are only required in a smaller set `u`. -/
lemma pullbackWithin_lieBracketWithin_of_isSymmSndFDerivWithinAt_of_eventuallyEq
{f : E → F} {V W : F → F} {x : E} {t : Set F} {u : Set E}
(hf : IsSymmSndFDerivWithinAt 𝕜 f s x) (h'f : ContDiffWithinAt 𝕜 2 f s x)
(hV : DifferentiableWithinAt 𝕜 V t (f x)) (hW : DifferentiableWithinAt 𝕜 W t (f x))
(hu : UniqueDiffOn 𝕜 u) (hx : x ∈ u) (hst : MapsTo f u t) (hus : u =ᶠ[𝓝 x] s) :
pullbackWithin 𝕜 f (lieBracketWithin 𝕜 V W t) s x
= lieBracketWithin 𝕜 (pullbackWithin 𝕜 f V s) (pullbackWithin 𝕜 f W s) s x := calc
pullbackWithin 𝕜 f (lieBracketWithin 𝕜 V W t) s x
_ = pullbackWithin 𝕜 f (lieBracketWithin 𝕜 V W t) u x := by
simp only [pullbackWithin]
congr 2
exact fderivWithin_congr_set hus.symm
_ = lieBracketWithin 𝕜 (pullbackWithin 𝕜 f V u) (pullbackWithin 𝕜 f W u) u x :=
pullbackWithin_lieBracketWithin_of_isSymmSndFDerivWithinAt
(hf.congr_set hus.symm) (h'f.congr_set hus.symm) hV hW hu hx hst
_ = lieBracketWithin 𝕜 (pullbackWithin 𝕜 f V s) (pullbackWithin 𝕜 f W s) u x := by
apply Filter.EventuallyEq.lieBracketWithin_vectorField_eq_of_mem _ _ hx
· apply nhdsWithin_le_nhds
filter_upwards [fderivWithin_eventually_congr_set (𝕜 := 𝕜) (f := f) hus] with y hy
simp [pullbackWithin, hy]
· apply nhdsWithin_le_nhds
filter_upwards [fderivWithin_eventually_congr_set (𝕜 := 𝕜) (f := f) hus] with y hy
simp [pullbackWithin, hy]
_ = lieBracketWithin 𝕜 (pullbackWithin 𝕜 f V s) (pullbackWithin 𝕜 f W s) s x :=
lieBracketWithin_congr_set hus
/-- The Lie bracket commutes with taking pullbacks. This requires the function to have symmetric
second derivative. Version in a complete space. One could also give a version avoiding
completeness but requiring that `f` is a local diffeo. -/
lemma pullback_lieBracket_of_isSymmSndFDerivAt {f : E → F} {V W : F → F} {x : E}
(hf : IsSymmSndFDerivAt 𝕜 f x) (h'f : ContDiffAt 𝕜 2 f x)
(hV : DifferentiableAt 𝕜 V (f x)) (hW : DifferentiableAt 𝕜 W (f x)) :
pullback 𝕜 f (lieBracket 𝕜 V W) x = lieBracket 𝕜 (pullback 𝕜 f V) (pullback 𝕜 f W) x := by
simp only [← lieBracketWithin_univ, ← pullbackWithin_univ, ← isSymmSndFDerivWithinAt_univ,
← differentiableWithinAt_univ] at hf h'f hV hW ⊢
exact pullbackWithin_lieBracketWithin_of_isSymmSndFDerivWithinAt hf h'f hV hW uniqueDiffOn_univ
(mem_univ _) (mapsTo_univ _ _)
/-- The Lie bracket commutes with taking pullbacks. This requires the function to have symmetric
second derivative. Version in a complete space. One could also give a version avoiding
completeness but requiring that `f` is a local diffeo. -/
lemma pullbackWithin_lieBracketWithin
{f : E → F} {V W : F → F} {x : E} {t : Set F} (hn : minSmoothness 𝕜 2 ≤ n)
(h'f : ContDiffWithinAt 𝕜 n f s x)
(hV : DifferentiableWithinAt 𝕜 V t (f x)) (hW : DifferentiableWithinAt 𝕜 W t (f x))
(hu : UniqueDiffOn 𝕜 s) (hx : x ∈ s) (h'x : x ∈ closure (interior s)) (hst : MapsTo f s t) :
pullbackWithin 𝕜 f (lieBracketWithin 𝕜 V W t) s x
= lieBracketWithin 𝕜 (pullbackWithin 𝕜 f V s) (pullbackWithin 𝕜 f W s) s x :=
pullbackWithin_lieBracketWithin_of_isSymmSndFDerivWithinAt
(h'f.isSymmSndFDerivWithinAt hn hu h'x hx) (h'f.of_le (le_minSmoothness.trans hn)) hV hW hu hx hst
/-- The Lie bracket commutes with taking pullbacks. One could also give a version avoiding
completeness but requiring that `f` is a local diffeo. -/
lemma pullback_lieBracket (hn : minSmoothness 𝕜 2 ≤ n)
{f : E → F} {V W : F → F} {x : E} (h'f : ContDiffAt 𝕜 n f x)
(hV : DifferentiableAt 𝕜 V (f x)) (hW : DifferentiableAt 𝕜 W (f x)) :
pullback 𝕜 f (lieBracket 𝕜 V W) x = lieBracket 𝕜 (pullback 𝕜 f V) (pullback 𝕜 f W) x :=
pullback_lieBracket_of_isSymmSndFDerivAt (h'f.isSymmSndFDerivAt hn)
(h'f.of_le (le_minSmoothness.trans hn)) hV hW
end VectorField |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/Taylor.lean | import Mathlib.Algebra.EuclideanDomain.Basic
import Mathlib.Algebra.EuclideanDomain.Field
import Mathlib.Algebra.Polynomial.Module.Basic
import Mathlib.Analysis.Calculus.ContDiff.Basic
import Mathlib.Analysis.Calculus.Deriv.Pow
import Mathlib.Analysis.Calculus.IteratedDeriv.Defs
import Mathlib.Analysis.Calculus.MeanValue
import Mathlib.Analysis.Calculus.Deriv.MeanValue
/-!
# Taylor's theorem
This file defines the Taylor polynomial of a real function `f : ℝ → E`,
where `E` is a normed vector space over `ℝ` and proves Taylor's theorem,
which states that if `f` is sufficiently smooth, then
`f` can be approximated by the Taylor polynomial up to an explicit error term.
## Main definitions
* `taylorCoeffWithin`: the Taylor coefficient using `iteratedDerivWithin`
* `taylorWithin`: the Taylor polynomial using `iteratedDerivWithin`
## Main statements
* `taylor_tendsto`: Taylor's theorem as a limit
* `taylor_isLittleO`: Taylor's theorem using little-o notation
* `taylor_mean_remainder`: Taylor's theorem with the general form of the remainder term
* `taylor_mean_remainder_lagrange`: Taylor's theorem with the Lagrange remainder
* `taylor_mean_remainder_cauchy`: Taylor's theorem with the Cauchy remainder
* `exists_taylor_mean_remainder_bound`: Taylor's theorem for vector-valued functions with a
polynomial bound on the remainder
## TODO
* the integral form of the remainder
* Generalization to higher dimensions
## Tags
Taylor polynomial, Taylor's theorem
-/
open scoped Interval Topology Nat
open Set
variable {𝕜 E F : Type*}
variable [NormedAddCommGroup E] [NormedSpace ℝ E]
/-- The `k`th coefficient of the Taylor polynomial. -/
noncomputable def taylorCoeffWithin (f : ℝ → E) (k : ℕ) (s : Set ℝ) (x₀ : ℝ) : E :=
(k ! : ℝ)⁻¹ • iteratedDerivWithin k f s x₀
/-- The Taylor polynomial with derivatives inside of a set `s`.
The Taylor polynomial is given by
$$∑_{k=0}^n \frac{(x - x₀)^k}{k!} f^{(k)}(x₀),$$
where $f^{(k)}(x₀)$ denotes the iterated derivative in the set `s`. -/
noncomputable def taylorWithin (f : ℝ → E) (n : ℕ) (s : Set ℝ) (x₀ : ℝ) : PolynomialModule ℝ E :=
(Finset.range (n + 1)).sum fun k =>
PolynomialModule.comp (Polynomial.X - Polynomial.C x₀)
(PolynomialModule.single ℝ k (taylorCoeffWithin f k s x₀))
/-- The Taylor polynomial with derivatives inside of a set `s` considered as a function `ℝ → E` -/
noncomputable def taylorWithinEval (f : ℝ → E) (n : ℕ) (s : Set ℝ) (x₀ x : ℝ) : E :=
PolynomialModule.eval x (taylorWithin f n s x₀)
theorem taylorWithin_succ (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₀)) := by
dsimp only [taylorWithin]
rw [Finset.sum_range_succ]
@[simp]
theorem taylorWithinEval_succ (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₀ := by
simp_rw [taylorWithinEval, taylorWithin_succ, LinearMap.map_add, PolynomialModule.comp_eval]
congr
simp only [Polynomial.eval_sub, Polynomial.eval_X, Polynomial.eval_C,
PolynomialModule.eval_single, mul_inv_rev]
dsimp only [taylorCoeffWithin]
rw [← mul_smul, mul_comm, Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one,
mul_inv_rev]
/-- The Taylor polynomial of order zero evaluates to `f x`. -/
@[simp]
theorem taylor_within_zero_eval (f : ℝ → E) (s : Set ℝ) (x₀ x : ℝ) :
taylorWithinEval f 0 s x₀ x = f x₀ := by
dsimp only [taylorWithinEval]
dsimp only [taylorWithin]
dsimp only [taylorCoeffWithin]
simp
/-- Evaluating the Taylor polynomial at `x = x₀` yields `f x`. -/
@[simp]
theorem taylorWithinEval_self (f : ℝ → E) (n : ℕ) (s : Set ℝ) (x₀ : ℝ) :
taylorWithinEval f n s x₀ x₀ = f x₀ := by
induction n with
| zero => exact taylor_within_zero_eval _ _ _ _
| succ k hk => simp [hk]
theorem taylor_within_apply (f : ℝ → E) (n : ℕ) (s : Set ℝ) (x₀ x : ℝ) :
taylorWithinEval f n s x₀ x =
∑ k ∈ Finset.range (n + 1), ((k ! : ℝ)⁻¹ * (x - x₀) ^ k) • iteratedDerivWithin k f s x₀ := by
induction n with
| zero => simp
| succ k hk =>
rw [taylorWithinEval_succ, Finset.sum_range_succ, hk]
simp [Nat.factorial]
/-- If `f` is `n` times continuous differentiable on a set `s`, then the Taylor polynomial
`taylorWithinEval f n s x₀ x` is continuous in `x₀`. -/
theorem continuousOn_taylorWithinEval {f : ℝ → E} {x : ℝ} {n : ℕ} {s : Set ℝ}
(hs : UniqueDiffOn ℝ s) (hf : ContDiffOn ℝ n f s) :
ContinuousOn (fun t => taylorWithinEval f n s t x) s := by
simp_rw [taylor_within_apply]
refine continuousOn_finset_sum (Finset.range (n + 1)) fun i hi => ?_
refine (continuousOn_const.mul ((continuousOn_const.sub continuousOn_id).pow _)).smul ?_
rw [contDiffOn_nat_iff_continuousOn_differentiableOn_deriv hs] at hf
simp only [Finset.mem_range] at hi
refine hf.1 i ?_
simp only [Nat.lt_succ_iff.mp hi]
/-- Helper lemma for calculating the derivative of the monomial that appears in Taylor
expansions. -/
theorem monomial_has_deriv_aux (t x : ℝ) (n : ℕ) :
HasDerivAt (fun y => (x - y) ^ (n + 1)) (-(n + 1) * (x - t) ^ n) t := by
simp_rw [sub_eq_neg_add]
rw [← neg_one_mul, mul_comm (-1 : ℝ), mul_assoc, mul_comm (-1 : ℝ), ← mul_assoc]
convert ((hasDerivAt_id t).neg.add_const x).pow (n + 1)
simp only [Nat.cast_add, Nat.cast_one]
theorem hasDerivWithinAt_taylor_coeff_within {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 := by
replace hf :
HasDerivWithinAt (iteratedDerivWithin (k + 1) f s) (iteratedDerivWithin (k + 2) f s y) t y := by
convert (hf.mono_of_mem_nhdsWithin hs).hasDerivWithinAt using 1
rw [iteratedDerivWithin_succ]
exact (derivWithin_of_mem_nhdsWithin hs ht hf).symm
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
rw [this]
exact (monomial_has_deriv_aux y x _).hasDerivWithinAt.const_mul _
convert this.smul hf using 1
field_simp
module
/-- Calculate the derivative of the Taylor polynomial with respect to `x₀`.
Version for arbitrary sets -/
theorem hasDerivWithinAt_taylorWithinEval {f : ℝ → E} {x y : ℝ} {n : ℕ} {s s' : Set ℝ}
(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 := by
have hs'_unique : UniqueDiffWithinAt ℝ s' y :=
UniqueDiffWithinAt.mono_nhds (hs_unique _ (h hy)) (nhdsWithin_le_iff.mpr hs')
induction n with
| zero =>
simp only [taylor_within_zero_eval, Nat.factorial_zero, Nat.cast_one, inv_one, pow_zero,
mul_one, zero_add, one_smul]
simp only [iteratedDerivWithin_zero] at hf'
rw [iteratedDerivWithin_one]
exact hf'.hasDerivWithinAt.mono h
| succ k hk =>
simp_rw [Nat.add_succ, taylorWithinEval_succ]
simp only [add_zero, Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one]
have coe_lt_succ : (k : WithTop ℕ) < k.succ := Nat.cast_lt.2 k.lt_succ_self
have hdiff : DifferentiableOn ℝ (iteratedDerivWithin k f s) s' :=
(hf.differentiableOn_iteratedDerivWithin (mod_cast coe_lt_succ) hs_unique).mono h
specialize hk hf.of_succ ((hdiff y hy).mono_of_mem_nhdsWithin hs')
convert hk.add (hasDerivWithinAt_taylor_coeff_within hs'_unique
(nhdsWithin_mono _ h self_mem_nhdsWithin) hf') using 1
exact (add_sub_cancel _ _).symm
/-- Calculate the derivative of the Taylor polynomial with respect to `x₀`.
Version for open intervals -/
theorem taylorWithinEval_hasDerivAt_Ioo {f : ℝ → E} {a b t : ℝ} (x : ℝ) {n : ℕ} (hx : a < b)
(ht : t ∈ Ioo a b) (hf : ContDiffOn ℝ n f (Icc a b))
(hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc a b)) (Ioo a b)) :
HasDerivAt (fun y => taylorWithinEval f n (Icc a b) y x)
(((n ! : ℝ)⁻¹ * (x - t) ^ n) • iteratedDerivWithin (n + 1) f (Icc a b) t) t :=
have h_nhds : Ioo a b ∈ 𝓝 t := isOpen_Ioo.mem_nhds ht
have h_nhds' : Ioo a b ∈ 𝓝[Icc a b] t := nhdsWithin_le_nhds h_nhds
(hasDerivWithinAt_taylorWithinEval (uniqueDiffOn_Icc hx) h_nhds' ht
Ioo_subset_Icc_self hf <| (hf' t ht).mono_of_mem_nhdsWithin h_nhds').hasDerivAt h_nhds
/-- Calculate the derivative of the Taylor polynomial with respect to `x₀`.
Version for closed intervals -/
theorem hasDerivWithinAt_taylorWithinEval_at_Icc {f : ℝ → E} {a b t : ℝ} (x : ℝ) {n : ℕ}
(hx : a < b) (ht : t ∈ Icc a b) (hf : ContDiffOn ℝ n f (Icc a b))
(hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc a b)) (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 b) t :=
hasDerivWithinAt_taylorWithinEval (uniqueDiffOn_Icc hx)
self_mem_nhdsWithin ht rfl.subset hf (hf' t ht)
/-- Calculate the derivative of the Taylor polynomial with respect to `x`. -/
theorem hasDerivAt_taylorWithinEval_succ {x₀ x : ℝ} {s : Set ℝ} (f : ℝ → E) (n : ℕ) :
HasDerivAt (taylorWithinEval f (n + 1) s x₀)
(taylorWithinEval (derivWithin f s) n s x₀ x) x := by
change HasDerivAt (fun x ↦ taylorWithinEval f _ s x₀ x) _ _
simp_rw [taylor_within_apply]
have : ∀ (i : ℕ) {c : ℝ} {c' : E},
HasDerivAt (fun x ↦ (c * (x - x₀) ^ i) • c') ((c * (i * (x - x₀) ^ (i - 1) * 1)) • c') x :=
fun _ _ ↦ hasDerivAt_id _ |>.sub_const _ |>.pow _ |>.const_mul _ |>.smul_const _
apply HasDerivAt.fun_sum (fun i _ => this i) |>.congr_deriv
rw [Finset.sum_range_succ', Nat.cast_zero, zero_mul, zero_mul, mul_zero, zero_smul, add_zero]
apply Finset.sum_congr rfl
intro i _
rw [← iteratedDerivWithin_succ']
congr 1
simp [field, Nat.factorial_succ]
/-- **Taylor's theorem** using little-o notation. -/
theorem taylor_isLittleO {f : ℝ → E} {x₀ : ℝ} {n : ℕ} {s : Set ℝ}
(hs : Convex ℝ s) (hx₀s : x₀ ∈ s) (hf : ContDiffOn ℝ n f s) :
(fun x ↦ f x - taylorWithinEval f n s x₀ x) =o[𝓝[s] x₀] fun x ↦ (x - x₀) ^ n := by
induction n generalizing f with
| zero =>
simp only [taylor_within_zero_eval, pow_zero, Asymptotics.isLittleO_one_iff]
rw [tendsto_sub_nhds_zero_iff]
exact hf.continuousOn.continuousWithinAt hx₀s
| succ n h =>
rcases s.eq_singleton_or_nontrivial hx₀s with rfl | hs'
· simp
replace hs' := uniqueDiffOn_convex hs (hs.nontrivial_iff_nonempty_interior.1 hs')
simp only [Nat.cast_add, Nat.cast_one] at hf
convert Convex.isLittleO_pow_succ_real hs hx₀s ?_ (h (hf.derivWithin hs' le_rfl))
(f := fun x ↦ f x - taylorWithinEval f (n + 1) s x₀ x) using 1
· simp
· intro x hx
refine HasDerivWithinAt.sub ?_ (hasDerivAt_taylorWithinEval_succ f n).hasDerivWithinAt
exact (hf.differentiableOn le_add_self _ hx).hasDerivWithinAt
/-- **Taylor's theorem** as a limit. -/
theorem taylor_tendsto {f : ℝ → E} {x₀ : ℝ} {n : ℕ} {s : Set ℝ}
(hs : Convex ℝ s) (hx₀s : x₀ ∈ s) (hf : ContDiffOn ℝ n f s) :
Filter.Tendsto (fun x ↦ ((x - x₀) ^ n)⁻¹ • (f x - taylorWithinEval f n s x₀ x))
(𝓝[s] x₀) (𝓝 0) := by
have h_isLittleO := (taylor_isLittleO hs hx₀s hf).norm_norm
rw [Asymptotics.isLittleO_iff_tendsto] at h_isLittleO
· rw [tendsto_zero_iff_norm_tendsto_zero]
simpa [norm_smul, div_eq_inv_mul] using h_isLittleO
· simp only [norm_pow, Real.norm_eq_abs, pow_eq_zero_iff', abs_eq_zero, ne_eq, norm_eq_zero,
and_imp]
intro x hx
rw [sub_eq_zero] at hx
simp [hx]
/-- **Taylor's theorem** as a limit. -/
theorem Real.taylor_tendsto {f : ℝ → ℝ} {x₀ : ℝ} {n : ℕ} {s : Set ℝ}
(hs : Convex ℝ s) (hx₀s : x₀ ∈ s) (hf : ContDiffOn ℝ n f s) :
Filter.Tendsto (fun x ↦ (f x - taylorWithinEval f n s x₀ x) / (x - x₀) ^ n)
(𝓝[s] x₀) (𝓝 0) := by
convert _root_.taylor_tendsto hs hx₀s hf using 2 with x
simp [div_eq_inv_mul]
/-! ### Taylor's theorem with mean value type remainder estimate -/
/-- **Taylor's theorem** with the general mean value form of the remainder.
We assume that `f` is `n+1`-times continuously differentiable in the closed set `Icc x₀ x` and
`n+1`-times differentiable on the open set `Ioo x₀ x`, and `g` is a differentiable function on
`Ioo x₀ x` and continuous on `Icc x₀ x`. Then there exists an `x' ∈ Ioo x₀ x` such that
$$f(x) - (P_n f)(x₀, x) = \frac{(x - x')^n}{n!} \frac{g(x) - g(x₀)}{g' x'},$$
where $P_n f$ denotes the Taylor polynomial of degree $n$. -/
theorem taylor_mean_remainder {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' ∈ Ioo x₀ x, 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' := by
-- We apply the mean value theorem
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⟩
use y, hy
-- The rest is simplifications and trivial calculations
simp only [taylorWithinEval_self] at h
rw [mul_comm, ← div_left_inj' (g'_ne y hy), mul_div_cancel_right₀ _ (g'_ne y hy)] at h
rw [← h]
simp [field]
-- see https://github.com/leanprover-community/mathlib4/issues/29041
set_option linter.unusedSimpArgs false in
/-- **Taylor's theorem** with the Lagrange form of the remainder.
We assume that `f` is `n+1`-times continuously differentiable in the closed set `Icc x₀ x` and
`n+1`-times differentiable on the open set `Ioo x₀ x`. Then there exists an `x' ∈ Ioo x₀ x` such
that $$f(x) - (P_n f)(x₀, x) = \frac{f^{(n+1)}(x') (x - x₀)^{n+1}}{(n+1)!},$$
where $P_n f$ denotes the Taylor polynomial of degree $n$ and $f^{(n+1)}$ is the $n+1$-th iterated
derivative. -/
theorem taylor_mean_remainder_lagrange {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' ∈ Ioo x₀ x, f x - taylorWithinEval f n (Icc x₀ x) x₀ x =
iteratedDerivWithin (n + 1) f (Icc x₀ x) x' * (x - x₀) ^ (n + 1) / (n + 1)! := by
have gcont : ContinuousOn (fun t : ℝ => (x - t) ^ (n + 1)) (Icc x₀ x) := by fun_prop
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'
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)
rcases taylor_mean_remainder hx hf hf' gcont (fun y _ => monomial_has_deriv_aux y x _) hg' with
⟨y, hy, h⟩
use y, hy
simp only [sub_self, zero_pow, Ne, Nat.succ_ne_zero, not_false_iff, zero_sub, mul_neg] at h
rw [h, neg_div, ← div_neg, neg_mul, neg_neg]
simp [field, xy_ne y hy, Nat.factorial]
/-- A corollary of Taylor's theorem with the Lagrange form of the remainder. -/
lemma taylor_mean_remainder_lagrange_iteratedDeriv {f : ℝ → ℝ} {x x₀ : ℝ} {n : ℕ} (hx : x₀ < x)
(hf : ContDiffOn ℝ (n + 1) f (Icc x₀ x)) :
∃ x' ∈ Ioo x₀ x, f x - taylorWithinEval f n (Icc x₀ x) x₀ x =
iteratedDeriv (n + 1) f x' * (x - x₀) ^ (n + 1) / (n + 1)! := by
have hu : UniqueDiffOn ℝ (Icc x₀ x) := uniqueDiffOn_Icc hx
have hd : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc x₀ x)) (Icc x₀ x) := by
refine hf.differentiableOn_iteratedDerivWithin ?_ hu
norm_cast
simp
obtain ⟨x', h1, h2⟩ := taylor_mean_remainder_lagrange hx hf.of_succ (hd.mono Ioo_subset_Icc_self)
use x', h1
rw [h2, iteratedDeriv_eq_iteratedFDeriv, iteratedDerivWithin_eq_iteratedFDerivWithin,
iteratedFDerivWithin_eq_iteratedFDeriv hu _ ⟨le_of_lt h1.1, le_of_lt h1.2⟩]
exact hf.contDiffAt (Icc_mem_nhds_iff.2 h1)
/-- **Taylor's theorem** with the Cauchy form of the remainder.
We assume that `f` is `n+1`-times continuously differentiable on the closed set `Icc x₀ x` and
`n+1`-times differentiable on the open set `Ioo x₀ x`. Then there exists an `x' ∈ Ioo x₀ x` such
that $$f(x) - (P_n f)(x₀, x) = \frac{f^{(n+1)}(x') (x - x')^n (x-x₀)}{n!},$$
where $P_n f$ denotes the Taylor polynomial of degree $n$ and $f^{(n+1)}$ is the $n+1$-th iterated
derivative. -/
theorem taylor_mean_remainder_cauchy {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' ∈ Ioo x₀ x, f x - taylorWithinEval f n (Icc x₀ x) x₀ x =
iteratedDerivWithin (n + 1) f (Icc x₀ x) x' * (x - x') ^ n / n ! * (x - x₀) := by
have gcont : ContinuousOn id (Icc x₀ x) := by fun_prop
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
rcases taylor_mean_remainder hx hf hf' gcont gdiff fun _ _ => by simp with ⟨y, hy, h⟩
use y, hy
rw [h]
simp [field]
/-- **Taylor's theorem** with a polynomial bound on the remainder
We assume that `f` is `n+1`-times continuously differentiable on the closed set `Icc a b`.
The difference of `f` and its `n`-th Taylor polynomial can be estimated by
`C * (x - a)^(n+1) / n!` where `C` is a bound for the `n+1`-th iterated derivative of `f`. -/
theorem taylor_mean_remainder_bound {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 ∈ 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 ! := by
rcases eq_or_lt_of_le hab with (rfl | h)
· rw [Icc_self, mem_singleton_iff] at hx
simp [hx]
-- The nth iterated derivative is differentiable
have hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc a b)) (Icc a b) :=
hf.differentiableOn_iteratedDerivWithin (mod_cast n.lt_succ_self)
(uniqueDiffOn_Icc h)
-- We can uniformly bound the derivative of the Taylor polynomial
have h' : ∀ 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]
gcongr
· rw [abs_mul, abs_pow, abs_inv, Nat.abs_cast]
gcongr
exact sub_nonneg.2 hyx.le
-- Estimate the iterated derivative by `C`
· exact hC y ⟨hay, hyx.le.trans hx.2⟩
-- Apply the mean value theorem for vector-valued functions:
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 (hasDerivWithinAt_taylorWithinEval_at_Icc x h (I ht) hf.of_succ hf').mono I
have := norm_image_sub_le_of_norm_deriv_le_segment' A h' x (right_mem_Icc.2 hx.1)
simp only [taylorWithinEval_self] at this
refine this.trans_eq ?_
-- The rest is a trivial calculation
rw [abs_of_nonneg (sub_nonneg.mpr hx.1)]
ring
/-- **Taylor's theorem** with a polynomial bound on the remainder
We assume that `f` is `n+1`-times continuously differentiable on the closed set `Icc a b`.
There exists a constant `C` such that for all `x ∈ Icc a b` the difference of `f` and its `n`-th
Taylor polynomial can be estimated by `C * (x - a)^(n+1)`. -/
theorem exists_taylor_mean_remainder_bound {f : ℝ → E} {a b : ℝ} {n : ℕ} (hab : a ≤ b)
(hf : ContDiffOn ℝ (n + 1) f (Icc a b)) :
∃ C, ∀ x ∈ Icc a b, ‖f x - taylorWithinEval f n (Icc a b) a x‖ ≤ C * (x - a) ^ (n + 1) := by
rcases eq_or_lt_of_le hab with (rfl | h)
· refine ⟨0, fun x hx => ?_⟩
have : x = a := by simpa [← le_antisymm_iff] using hx
simp [← this]
-- We estimate by the supremum of the norm of the iterated derivative
let g : ℝ → ℝ := fun y => ‖iteratedDerivWithin (n + 1) f (Icc a b) y‖
use SupSet.sSup (g '' Icc a b) / (n !)
intro x hx
rw [div_mul_eq_mul_div₀]
refine taylor_mean_remainder_bound hab hf hx fun y => ?_
exact (hf.continuousOn_iteratedDerivWithin rfl.le <| uniqueDiffOn_Icc h).norm.le_sSup_image_Icc |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/LagrangeMultipliers.lean | import Mathlib.Analysis.Calculus.FDeriv.Prod
import Mathlib.Analysis.Calculus.InverseFunctionTheorem.FDeriv
import Mathlib.LinearAlgebra.Dual.Defs
/-!
# Lagrange multipliers
In this file we formalize the
[Lagrange multipliers](https://en.wikipedia.org/wiki/Lagrange_multiplier) method of solving
conditional extremum problems: if a function `φ` has a local extremum at `x₀` on the set
`f ⁻¹' {f x₀}`, `f x = (f₀ x, ..., fₙ₋₁ x)`, then the differentials of `fₖ` and `φ` are linearly
dependent. First we formulate a geometric version of this theorem which does not rely on the
target space being `ℝⁿ`, then restate it in terms of coordinates.
## TODO
Formalize Karush-Kuhn-Tucker theorem
## Tags
lagrange multiplier, local extremum
-/
open Filter Set
open scoped Topology Filter
variable {E F : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E]
[NormedAddCommGroup F] [NormedSpace ℝ F] [CompleteSpace F] {f : E → F} {φ : E → ℝ} {x₀ : E}
{f' : E →L[ℝ] F} {φ' : StrongDual ℝ E}
/-- Lagrange multipliers theorem: if `φ : E → ℝ` has a local extremum on the set `{x | f x = f x₀}`
at `x₀`, both `f : E → F` and `φ` are strictly differentiable at `x₀`, and the codomain of `f` is
a complete space, then the linear map `x ↦ (f' x, φ' x)` is not surjective. -/
theorem IsLocalExtrOn.range_ne_top_of_hasStrictFDerivAt
(hextr : IsLocalExtrOn φ {x | f x = f x₀} x₀) (hf' : HasStrictFDerivAt f f' x₀)
(hφ' : HasStrictFDerivAt φ φ' x₀) : LinearMap.range (f'.prod φ') ≠ ⊤ := by
intro htop
set fφ := fun x => (f x, φ x)
have A : map φ (𝓝[f ⁻¹' {f x₀}] x₀) = 𝓝 (φ x₀) := by
change map (Prod.snd ∘ fφ) (𝓝[fφ ⁻¹' {p | p.1 = f x₀}] x₀) = 𝓝 (φ x₀)
rw [← map_map, nhdsWithin, map_inf_principal_preimage,
(hf'.prodMk hφ').map_nhds_eq_of_surj htop]
exact map_snd_nhdsWithin _
exact hextr.not_nhds_le_map A.ge
/-- Lagrange multipliers theorem: if `φ : E → ℝ` has a local extremum on the set `{x | f x = f x₀}`
at `x₀`, both `f : E → F` and `φ` are strictly differentiable at `x₀`, and the codomain of `f` is
a complete space, then there exist `Λ : dual ℝ F` and `Λ₀ : ℝ` such that `(Λ, Λ₀) ≠ 0` and
`Λ (f' x) + Λ₀ • φ' x = 0` for all `x`. -/
theorem IsLocalExtrOn.exists_linear_map_of_hasStrictFDerivAt
(hextr : IsLocalExtrOn φ {x | f x = f x₀} x₀) (hf' : HasStrictFDerivAt f f' x₀)
(hφ' : HasStrictFDerivAt φ φ' x₀) :
∃ (Λ : Module.Dual ℝ F) (Λ₀ : ℝ), (Λ, Λ₀) ≠ 0 ∧ ∀ x, Λ (f' x) + Λ₀ • φ' x = 0 := by
rcases Submodule.exists_le_ker_of_lt_top _
(lt_top_iff_ne_top.2 <| hextr.range_ne_top_of_hasStrictFDerivAt hf' hφ') with
⟨Λ', h0, hΛ'⟩
set e : ((F →ₗ[ℝ] ℝ) × ℝ) ≃ₗ[ℝ] F × ℝ →ₗ[ℝ] ℝ :=
((LinearEquiv.refl ℝ (F →ₗ[ℝ] ℝ)).prodCongr (LinearMap.ringLmapEquivSelf ℝ ℝ ℝ).symm).trans
(LinearMap.coprodEquiv ℝ)
rcases e.surjective Λ' with ⟨⟨Λ, Λ₀⟩, rfl⟩
refine ⟨Λ, Λ₀, e.map_ne_zero_iff.1 h0, fun x => ?_⟩
convert LinearMap.congr_fun (LinearMap.range_le_ker_iff.1 hΛ') x using 1
-- squeezed `simp [mul_comm]` to speed up elaboration
simp only [e, smul_eq_mul, LinearEquiv.trans_apply, LinearEquiv.prodCongr_apply,
LinearEquiv.refl_apply, LinearMap.ringLmapEquivSelf_symm_apply, LinearMap.coprodEquiv_apply,
ContinuousLinearMap.coe_prod, LinearMap.coprod_comp_prod, LinearMap.add_apply,
LinearMap.coe_comp, ContinuousLinearMap.coe_coe, Function.comp_apply, LinearMap.coe_smulRight,
Module.End.one_apply, mul_comm]
/-- Lagrange multipliers theorem: if `φ : E → ℝ` has a local extremum on the set `{x | f x = f x₀}`
at `x₀`, and both `f : E → ℝ` and `φ` are strictly differentiable at `x₀`, then there exist
`a b : ℝ` such that `(a, b) ≠ 0` and `a • f' + b • φ' = 0`. -/
theorem IsLocalExtrOn.exists_multipliers_of_hasStrictFDerivAt_1d {f : E → ℝ} {f' : StrongDual ℝ E}
(hextr : IsLocalExtrOn φ {x | f x = f x₀} x₀) (hf' : HasStrictFDerivAt f f' x₀)
(hφ' : HasStrictFDerivAt φ φ' x₀) : ∃ a b : ℝ, (a, b) ≠ 0 ∧ a • f' + b • φ' = 0 := by
obtain ⟨Λ, Λ₀, hΛ, hfΛ⟩ := hextr.exists_linear_map_of_hasStrictFDerivAt hf' hφ'
refine ⟨Λ 1, Λ₀, ?_, ?_⟩
· contrapose! hΛ
simp only [Prod.mk_eq_zero] at hΛ ⊢
refine ⟨LinearMap.ext fun x => ?_, hΛ.2⟩
simpa [hΛ.1] using Λ.map_smul x 1
· ext x
have H₁ : Λ (f' x) = f' x * Λ 1 := by
simpa only [mul_one, Algebra.id.smul_eq_mul] using Λ.map_smul (f' x) 1
have H₂ : f' x * Λ 1 + Λ₀ * φ' x = 0 := by simpa only [Algebra.id.smul_eq_mul, H₁] using hfΛ x
simpa [mul_comm] using H₂
/-- Lagrange multipliers theorem, 1d version. Let `f : ι → E → ℝ` be a finite family of functions.
Suppose that `φ : E → ℝ` has a local extremum on the set `{x | ∀ i, f i x = f i x₀}` at `x₀`.
Suppose that all functions `f i` as well as `φ` are strictly differentiable at `x₀`.
Then the derivatives `f' i : E → L[ℝ] ℝ` and `φ' : StrongDual ℝ E` are linearly dependent:
there exist `Λ : ι → ℝ` and `Λ₀ : ℝ`, `(Λ, Λ₀) ≠ 0`, such that `∑ i, Λ i • f' i + Λ₀ • φ' = 0`.
See also `IsLocalExtrOn.linear_dependent_of_hasStrictFDerivAt` for a version that
states `¬LinearIndependent ℝ _` instead of existence of `Λ` and `Λ₀`. -/
theorem IsLocalExtrOn.exists_multipliers_of_hasStrictFDerivAt {ι : Type*} [Fintype ι]
{f : ι → E → ℝ} {f' : ι → StrongDual ℝ E} (hextr : IsLocalExtrOn φ {x | ∀ i, f i x = f i x₀} x₀)
(hf' : ∀ i, HasStrictFDerivAt (f i) (f' i) x₀) (hφ' : HasStrictFDerivAt φ φ' x₀) :
∃ (Λ : ι → ℝ) (Λ₀ : ℝ), (Λ, Λ₀) ≠ 0 ∧ (∑ i, Λ i • f' i) + Λ₀ • φ' = 0 := by
letI := Classical.decEq ι
replace hextr : IsLocalExtrOn φ {x | (fun i => f i x) = fun i => f i x₀} x₀ := by
simpa only [funext_iff] using hextr
rcases hextr.exists_linear_map_of_hasStrictFDerivAt (hasStrictFDerivAt_pi.2 fun i => hf' i)
hφ' with
⟨Λ, Λ₀, h0, hsum⟩
rcases (LinearEquiv.piRing ℝ ℝ ι ℝ).symm.surjective Λ with ⟨Λ, rfl⟩
refine ⟨Λ, Λ₀, ?_, ?_⟩
· simpa only [Ne, Prod.ext_iff, LinearEquiv.map_eq_zero_iff, Prod.fst_zero] using h0
· ext x; simpa [mul_comm] using hsum x
/-- Lagrange multipliers theorem. Let `f : ι → E → ℝ` be a finite family of functions.
Suppose that `φ : E → ℝ` has a local extremum on the set `{x | ∀ i, f i x = f i x₀}` at `x₀`.
Suppose that all functions `f i` as well as `φ` are strictly differentiable at `x₀`.
Then the derivatives `f' i : E → L[ℝ] ℝ` and `φ' : StrongDual ℝ E` are linearly dependent.
See also `IsLocalExtrOn.exists_multipliers_of_hasStrictFDerivAt` for a version that
that states existence of Lagrange multipliers `Λ` and `Λ₀` instead of using
`¬LinearIndependent ℝ _` -/
theorem IsLocalExtrOn.linear_dependent_of_hasStrictFDerivAt {ι : Type*} [Finite ι] {f : ι → E → ℝ}
{f' : ι → StrongDual ℝ E} (hextr : IsLocalExtrOn φ {x | ∀ i, f i x = f i x₀} x₀)
(hf' : ∀ i, HasStrictFDerivAt (f i) (f' i) x₀) (hφ' : HasStrictFDerivAt φ φ' x₀) :
¬LinearIndependent ℝ (Option.elim' φ' f' : Option ι → StrongDual ℝ E) := by
cases nonempty_fintype ι
rw [Fintype.linearIndependent_iff]; push_neg
rcases hextr.exists_multipliers_of_hasStrictFDerivAt hf' hφ' with ⟨Λ, Λ₀, hΛ, hΛf⟩
refine ⟨Option.elim' Λ₀ Λ, ?_, ?_⟩
· simpa [add_comm] using hΛf
· simpa only [funext_iff, not_and_or, or_comm, Option.exists, Prod.mk_eq_zero, Ne,
not_forall] using hΛ |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/ParametricIntegral.lean | import Mathlib.Analysis.Calculus.MeanValue
import Mathlib.MeasureTheory.Integral.DominatedConvergence
import Mathlib.MeasureTheory.Integral.Bochner.Set
import Mathlib.Analysis.LocallyConvex.SeparatingDual
/-!
# Derivatives of integrals depending on parameters
A parametric integral is a function with shape `f = fun x : H ↦ ∫ a : α, F x a ∂μ` for some
`F : H → α → E`, where `H` and `E` are normed spaces and `α` is a measured space with measure `μ`.
We already know from `continuous_of_dominated`
in `Mathlib/MeasureTheory/Integral/Bochner/Basic.lean` how
to guarantee that `f` is continuous using the dominated convergence theorem. In this file,
we want to express the derivative of `f` as the integral of the derivative of `F` with respect
to `x`.
## Main results
As explained above, all results express the derivative of a parametric integral as the integral of
a derivative. The variations come from the assumptions and from the different ways of expressing
derivative, especially Fréchet derivatives vs elementary derivative of function of one real
variable.
* `hasFDerivAt_integral_of_dominated_loc_of_lip`: this version assumes that
- `F x` is ae-measurable for x near `x₀`,
- `F x₀` is integrable,
- `fun x ↦ F x a` has derivative `F' a : H →L[ℝ] E` at `x₀` which is ae-measurable,
- `fun x ↦ F x a` is locally Lipschitz near `x₀` for almost every `a`,
with a Lipschitz bound which is integrable with respect to `a`.
A subtle point is that the "near x₀" in the last condition has to be uniform in `a`. This is
controlled by a positive number `ε`.
* `hasFDerivAt_integral_of_dominated_of_fderiv_le`: this version assumes `fun x ↦ F x a` has
derivative `F' x a` for `x` near `x₀` and `F' x` is bounded by an integrable function independent
from `x` near `x₀`.
`hasDerivAt_integral_of_dominated_loc_of_lip` and
`hasDerivAt_integral_of_dominated_loc_of_deriv_le` are versions of the above two results that
assume `H = ℝ` or `H = ℂ` and use the high-school derivative `deriv` instead of Fréchet derivative
`fderiv`.
We also provide versions of these theorems for set integrals.
## Tags
integral, derivative
-/
noncomputable section
open TopologicalSpace MeasureTheory Filter Metric
open scoped Topology Filter
variable {α : Type*} [MeasurableSpace α] {μ : Measure α} {𝕜 : Type*} [RCLike 𝕜] {E : Type*}
[NormedAddCommGroup E] [NormedSpace ℝ E] [NormedSpace 𝕜 E] {H : Type*}
[NormedAddCommGroup H] [NormedSpace 𝕜 H]
variable {F : H → α → E} {x₀ : H} {bound : α → ℝ} {ε : ℝ}
/-- Differentiation under integral of `x ↦ ∫ F x a` at a given point `x₀`, assuming `F x₀` is
integrable, `‖F x a - F x₀ a‖ ≤ bound a * ‖x - x₀‖` for `x` in a ball around `x₀` for ae `a` with
integrable Lipschitz bound `bound` (with a ball radius independent of `a`), and `F x` is
ae-measurable for `x` in the same ball. See `hasFDerivAt_integral_of_dominated_loc_of_lip` for a
slightly less general but usually more useful version. -/
theorem hasFDerivAt_integral_of_dominated_loc_of_lip' {F' : α → H →L[𝕜] E} (ε_pos : 0 < ε)
(hF_meas : ∀ x ∈ ball x₀ ε, AEStronglyMeasurable (F x) μ) (hF_int : Integrable (F x₀) μ)
(hF'_meas : AEStronglyMeasurable F' μ)
(h_lipsch : ∀ᵐ a ∂μ, ∀ x ∈ ball x₀ ε, ‖F x a - F x₀ a‖ ≤ bound a * ‖x - x₀‖)
(bound_integrable : Integrable (bound : α → ℝ) μ)
(h_diff : ∀ᵐ a ∂μ, HasFDerivAt (F · a) (F' a) x₀) :
Integrable F' μ ∧ HasFDerivAt (fun x ↦ ∫ a, F x a ∂μ) (∫ a, F' a ∂μ) x₀ := by
have x₀_in : x₀ ∈ ball x₀ ε := mem_ball_self ε_pos
have nneg : ∀ x, 0 ≤ ‖x - x₀‖⁻¹ := fun x ↦ inv_nonneg.mpr (norm_nonneg _)
set b : α → ℝ := fun a ↦ |bound a|
have b_int : Integrable b μ := bound_integrable.norm
have b_nonneg : ∀ a, 0 ≤ b a := fun a ↦ abs_nonneg _
replace h_lipsch : ∀ᵐ a ∂μ, ∀ x ∈ ball x₀ ε, ‖F x a - F x₀ a‖ ≤ b a * ‖x - x₀‖ :=
h_lipsch.mono fun a ha x hx ↦
(ha x hx).trans <| mul_le_mul_of_nonneg_right (le_abs_self _) (norm_nonneg _)
have hF_int' : ∀ x ∈ ball x₀ ε, Integrable (F x) μ := fun x x_in ↦ by
have : ∀ᵐ a ∂μ, ‖F x₀ a - F x a‖ ≤ ε * b a := by
simp only [norm_sub_rev (F x₀ _)]
refine h_lipsch.mono fun a ha ↦ (ha x x_in).trans ?_
rw [mul_comm ε]
rw [mem_ball, dist_eq_norm] at x_in
exact mul_le_mul_of_nonneg_left x_in.le (b_nonneg _)
exact integrable_of_norm_sub_le (hF_meas x x_in) hF_int
(bound_integrable.norm.const_mul ε) this
have hF'_int : Integrable F' μ :=
have : ∀ᵐ a ∂μ, ‖F' a‖ ≤ b a := by
apply (h_diff.and h_lipsch).mono
rintro a ⟨ha_diff, ha_lip⟩
exact ha_diff.le_of_lip' (b_nonneg a) (mem_of_superset (ball_mem_nhds _ ε_pos) <| ha_lip)
b_int.mono' hF'_meas this
refine ⟨hF'_int, ?_⟩
/- Discard the trivial case where `E` is not complete, as all integrals vanish. -/
by_cases hE : CompleteSpace E; swap
· rcases subsingleton_or_nontrivial H with hH|hH
· have : Subsingleton (H →L[𝕜] E) := inferInstance
convert hasFDerivAt_of_subsingleton _ x₀
· have : ¬(CompleteSpace (H →L[𝕜] E)) := by
simpa [SeparatingDual.completeSpace_continuousLinearMap_iff] using hE
simp only [integral, hE, ↓reduceDIte, this]
exact hasFDerivAt_const 0 x₀
have h_ball : ball x₀ ε ∈ 𝓝 x₀ := ball_mem_nhds x₀ ε_pos
have : ∀ᶠ x in 𝓝 x₀, ‖x - x₀‖⁻¹ * ‖((∫ a, F x a ∂μ) - ∫ a, F x₀ a ∂μ) - (∫ a, F' a ∂μ) (x - x₀)‖ =
‖∫ a, ‖x - x₀‖⁻¹ • (F x a - F x₀ a - F' a (x - x₀)) ∂μ‖ := by
apply mem_of_superset (ball_mem_nhds _ ε_pos)
intro x x_in; simp only
rw [Set.mem_setOf_eq, ← norm_smul_of_nonneg (nneg _), integral_smul, integral_sub, integral_sub,
← ContinuousLinearMap.integral_apply hF'_int]
exacts [hF_int' x x_in, hF_int, (hF_int' x x_in).sub hF_int,
hF'_int.apply_continuousLinearMap _]
rw [hasFDerivAt_iff_tendsto, tendsto_congr' this, ← tendsto_zero_iff_norm_tendsto_zero, ←
show (∫ a : α, ‖x₀ - x₀‖⁻¹ • (F x₀ a - F x₀ a - (F' a) (x₀ - x₀)) ∂μ) = 0 by simp]
apply tendsto_integral_filter_of_dominated_convergence
· filter_upwards [h_ball] with _ x_in
apply AEStronglyMeasurable.const_smul
exact ((hF_meas _ x_in).sub (hF_meas _ x₀_in)).sub (hF'_meas.apply_continuousLinearMap _)
· refine mem_of_superset h_ball fun x hx ↦ ?_
apply (h_diff.and h_lipsch).mono
on_goal 1 => rintro a ⟨-, ha_bound⟩
show ‖‖x - x₀‖⁻¹ • (F x a - F x₀ a - F' a (x - x₀))‖ ≤ b a + ‖F' a‖
replace ha_bound : ‖F x a - F x₀ a‖ ≤ b a * ‖x - x₀‖ := ha_bound x hx
calc
‖‖x - x₀‖⁻¹ • (F x a - F x₀ a - F' a (x - x₀))‖ =
‖‖x - x₀‖⁻¹ • (F x a - F x₀ a) - ‖x - x₀‖⁻¹ • F' a (x - x₀)‖ := by rw [smul_sub]
_ ≤ ‖‖x - x₀‖⁻¹ • (F x a - F x₀ a)‖ + ‖‖x - x₀‖⁻¹ • F' a (x - x₀)‖ := norm_sub_le _ _
_ = ‖x - x₀‖⁻¹ * ‖F x a - F x₀ a‖ + ‖x - x₀‖⁻¹ * ‖F' a (x - x₀)‖ := by
rw [norm_smul_of_nonneg, norm_smul_of_nonneg] <;> exact nneg _
_ ≤ ‖x - x₀‖⁻¹ * (b a * ‖x - x₀‖) + ‖x - x₀‖⁻¹ * (‖F' a‖ * ‖x - x₀‖) := by
gcongr; exact (F' a).le_opNorm _
_ ≤ b a + ‖F' a‖ := ?_
simp only [← div_eq_inv_mul]
apply_rules [add_le_add, div_le_of_le_mul₀] <;> first | rfl | positivity
· exact b_int.add hF'_int.norm
· apply h_diff.mono
intro a ha
suffices Tendsto (fun x ↦ ‖x - x₀‖⁻¹ • (F x a - F x₀ a - F' a (x - x₀))) (𝓝 x₀) (𝓝 0) by simpa
rw [tendsto_zero_iff_norm_tendsto_zero]
have : (fun x ↦ ‖x - x₀‖⁻¹ * ‖F x a - F x₀ a - F' a (x - x₀)‖) = fun x ↦
‖‖x - x₀‖⁻¹ • (F x a - F x₀ a - F' a (x - x₀))‖ := by
ext x
rw [norm_smul_of_nonneg (nneg _)]
rwa [hasFDerivAt_iff_tendsto, this] at ha
/-- Differentiation under integral of `x ↦ ∫ F x a` at a given point `x₀`, assuming
`F x₀` is integrable, `x ↦ F x a` is locally Lipschitz on a ball around `x₀` for ae `a`
(with a ball radius independent of `a`) with integrable Lipschitz bound, and `F x` is ae-measurable
for `x` in a possibly smaller neighborhood of `x₀`. -/
theorem hasFDerivAt_integral_of_dominated_loc_of_lip {F' : α → H →L[𝕜] E}
(ε_pos : 0 < ε) (hF_meas : ∀ᶠ x in 𝓝 x₀, AEStronglyMeasurable (F x) μ)
(hF_int : Integrable (F x₀) μ) (hF'_meas : AEStronglyMeasurable F' μ)
(h_lip : ∀ᵐ a ∂μ, LipschitzOnWith (Real.nnabs <| bound a) (F · a) (ball x₀ ε))
(bound_integrable : Integrable (bound : α → ℝ) μ)
(h_diff : ∀ᵐ a ∂μ, HasFDerivAt (F · a) (F' a) x₀) :
Integrable F' μ ∧ HasFDerivAt (fun x ↦ ∫ a, F x a ∂μ) (∫ a, F' a ∂μ) x₀ := by
obtain ⟨δ, δ_pos, hδ⟩ : ∃ δ > 0, ∀ x ∈ ball x₀ δ, AEStronglyMeasurable (F x) μ ∧ x ∈ ball x₀ ε :=
eventually_nhds_iff_ball.mp (hF_meas.and (ball_mem_nhds x₀ ε_pos))
choose hδ_meas hδε using hδ
replace h_lip : ∀ᵐ a : α ∂μ, ∀ x ∈ ball x₀ δ, ‖F x a - F x₀ a‖ ≤ |bound a| * ‖x - x₀‖ :=
h_lip.mono fun a lip x hx ↦ lip.norm_sub_le (hδε x hx) (mem_ball_self ε_pos)
replace bound_integrable := bound_integrable.norm
apply hasFDerivAt_integral_of_dominated_loc_of_lip' δ_pos <;> assumption
open scoped Interval in
/-- Differentiation under integral of `x ↦ ∫ x in a..b, F x t` at a given point `x₀ ∈ (a,b)`,
assuming `F x₀` is integrable on `(a,b)`, that `x ↦ F x t` is Lipschitz on a ball around `x₀`
for almost every `t` (with a ball radius independent of `t`) with integrable Lipschitz bound,
and `F x` is a.e.-measurable for `x` in a possibly smaller neighborhood of `x₀`. -/
theorem hasFDerivAt_integral_of_dominated_loc_of_lip_interval [NormedSpace ℝ H] {μ : Measure ℝ}
{F : H → ℝ → E} {F' : ℝ → H →L[ℝ] E} {a b : ℝ} {bound : ℝ → ℝ} (ε_pos : 0 < ε)
(hF_meas : ∀ᶠ x in 𝓝 x₀, AEStronglyMeasurable (F x) <| μ.restrict (Ι a b))
(hF_int : IntervalIntegrable (F x₀) μ a b)
(hF'_meas : AEStronglyMeasurable F' <| μ.restrict (Ι a b))
(h_lip : ∀ᵐ t ∂μ.restrict (Ι a b),
LipschitzOnWith (Real.nnabs <| bound t) (F · t) (ball x₀ ε))
(bound_integrable : IntervalIntegrable bound μ a b)
(h_diff : ∀ᵐ t ∂μ.restrict (Ι a b), HasFDerivAt (F · t) (F' t) x₀) :
IntervalIntegrable F' μ a b ∧
HasFDerivAt (fun x ↦ ∫ t in a..b, F x t ∂μ) (∫ t in a..b, F' t ∂μ) x₀ := by
simp_rw [AEStronglyMeasurable.aestronglyMeasurable_uIoc_iff, eventually_and] at hF_meas hF'_meas
rw [ae_restrict_uIoc_iff] at h_lip h_diff
have H₁ :=
hasFDerivAt_integral_of_dominated_loc_of_lip ε_pos hF_meas.1 hF_int.1 hF'_meas.1 h_lip.1
bound_integrable.1 h_diff.1
have H₂ :=
hasFDerivAt_integral_of_dominated_loc_of_lip ε_pos hF_meas.2 hF_int.2 hF'_meas.2 h_lip.2
bound_integrable.2 h_diff.2
exact ⟨⟨H₁.1, H₂.1⟩, H₁.2.sub H₂.2⟩
/-- Differentiation under integral of `x ↦ ∫ F x a` at a given point `x₀`, assuming
`F x₀` is integrable, `x ↦ F x a` is differentiable on a ball around `x₀` for ae `a` with
derivative norm uniformly bounded by an integrable function (the ball radius is independent of `a`),
and `F x` is ae-measurable for `x` in a possibly smaller neighborhood of `x₀`. -/
theorem hasFDerivAt_integral_of_dominated_of_fderiv_le {F' : H → α → H →L[𝕜] E} (ε_pos : 0 < ε)
(hF_meas : ∀ᶠ x in 𝓝 x₀, AEStronglyMeasurable (F x) μ) (hF_int : Integrable (F x₀) μ)
(hF'_meas : AEStronglyMeasurable (F' x₀) μ)
(h_bound : ∀ᵐ a ∂μ, ∀ x ∈ ball x₀ ε, ‖F' x a‖ ≤ bound a)
(bound_integrable : Integrable (bound : α → ℝ) μ)
(h_diff : ∀ᵐ a ∂μ, ∀ x ∈ ball x₀ ε, HasFDerivAt (F · a) (F' x a) x) :
HasFDerivAt (fun x ↦ ∫ a, F x a ∂μ) (∫ a, F' x₀ a ∂μ) x₀ := by
letI : NormedSpace ℝ H := NormedSpace.restrictScalars ℝ 𝕜 H
have x₀_in : x₀ ∈ ball x₀ ε := mem_ball_self ε_pos
have diff_x₀ : ∀ᵐ a ∂μ, HasFDerivAt (F · a) (F' x₀ a) x₀ :=
h_diff.mono fun a ha ↦ ha x₀ x₀_in
have : ∀ᵐ a ∂μ, LipschitzOnWith (Real.nnabs (bound a)) (F · a) (ball x₀ ε) := by
apply (h_diff.and h_bound).mono
rintro a ⟨ha_deriv, ha_bound⟩
refine (convex_ball _ _).lipschitzOnWith_of_nnnorm_hasFDerivWithin_le
(fun x x_in ↦ (ha_deriv x x_in).hasFDerivWithinAt) fun x x_in ↦ ?_
rw [← NNReal.coe_le_coe, coe_nnnorm, Real.coe_nnabs]
exact (ha_bound x x_in).trans (le_abs_self _)
exact (hasFDerivAt_integral_of_dominated_loc_of_lip ε_pos hF_meas hF_int hF'_meas this
bound_integrable diff_x₀).2
open scoped Interval in
/-- Differentiation under integral of `x ↦ ∫ x in a..b, F x a` at a given point `x₀`, assuming
`F x₀` is integrable on `(a,b)`, `x ↦ F x a` is differentiable on a ball around `x₀` for ae `a` with
derivative norm uniformly bounded by an integrable function (the ball radius is independent of `a`),
and `F x` is ae-measurable for `x` in a possibly smaller neighborhood of `x₀`. -/
theorem hasFDerivAt_integral_of_dominated_of_fderiv_le'' [NormedSpace ℝ H] {μ : Measure ℝ}
{F : H → ℝ → E} {F' : H → ℝ → H →L[ℝ] E} {a b : ℝ} {bound : ℝ → ℝ} (ε_pos : 0 < ε)
(hF_meas : ∀ᶠ x in 𝓝 x₀, AEStronglyMeasurable (F x) <| μ.restrict (Ι a b))
(hF_int : IntervalIntegrable (F x₀) μ a b)
(hF'_meas : AEStronglyMeasurable (F' x₀) <| μ.restrict (Ι a b))
(h_bound : ∀ᵐ t ∂μ.restrict (Ι a b), ∀ x ∈ ball x₀ ε, ‖F' x t‖ ≤ bound t)
(bound_integrable : IntervalIntegrable bound μ a b)
(h_diff : ∀ᵐ t ∂μ.restrict (Ι a b), ∀ x ∈ ball x₀ ε, HasFDerivAt (F · t) (F' x t) x) :
HasFDerivAt (fun x ↦ ∫ t in a..b, F x t ∂μ) (∫ t in a..b, F' x₀ t ∂μ) x₀ := by
rw [ae_restrict_uIoc_iff] at h_diff h_bound
simp_rw [AEStronglyMeasurable.aestronglyMeasurable_uIoc_iff, eventually_and] at hF_meas hF'_meas
exact
(hasFDerivAt_integral_of_dominated_of_fderiv_le ε_pos hF_meas.1 hF_int.1 hF'_meas.1 h_bound.1
bound_integrable.1 h_diff.1).sub
(hasFDerivAt_integral_of_dominated_of_fderiv_le ε_pos hF_meas.2 hF_int.2 hF'_meas.2 h_bound.2
bound_integrable.2 h_diff.2)
section
variable {F : 𝕜 → α → E} {x₀ : 𝕜}
/-- Derivative under integral of `x ↦ ∫ F x a` at a given point `x₀ : 𝕜`, `𝕜 = ℝ` or `𝕜 = ℂ`,
assuming `F x₀` is integrable, `x ↦ F x a` is locally Lipschitz on a ball around `x₀` for ae `a`
(with ball radius independent of `a`) with integrable Lipschitz bound, and `F x` is
ae-measurable for `x` in a possibly smaller neighborhood of `x₀`. -/
theorem hasDerivAt_integral_of_dominated_loc_of_lip {F' : α → E} (ε_pos : 0 < ε)
(hF_meas : ∀ᶠ x in 𝓝 x₀, AEStronglyMeasurable (F x) μ) (hF_int : Integrable (F x₀) μ)
(hF'_meas : AEStronglyMeasurable F' μ)
(h_lipsch : ∀ᵐ a ∂μ, LipschitzOnWith (Real.nnabs <| bound a) (F · a) (ball x₀ ε))
(bound_integrable : Integrable (bound : α → ℝ) μ)
(h_diff : ∀ᵐ a ∂μ, HasDerivAt (F · a) (F' a) x₀) :
Integrable F' μ ∧ HasDerivAt (fun x ↦ ∫ a, F x a ∂μ) (∫ a, F' a ∂μ) x₀ := by
set L : E →L[𝕜] 𝕜 →L[𝕜] E := ContinuousLinearMap.smulRightL 𝕜 𝕜 E 1
replace h_diff : ∀ᵐ a ∂μ, HasFDerivAt (F · a) (L (F' a)) x₀ :=
h_diff.mono fun x hx ↦ hx.hasFDerivAt
have hm : AEStronglyMeasurable (L ∘ F') μ := L.continuous.comp_aestronglyMeasurable hF'_meas
obtain ⟨hF'_int, key⟩ := hasFDerivAt_integral_of_dominated_loc_of_lip
ε_pos hF_meas hF_int hm h_lipsch bound_integrable h_diff
replace hF'_int : Integrable F' μ := by
rw [← integrable_norm_iff hm] at hF'_int
simpa only [L, (· ∘ ·), integrable_norm_iff, hF'_meas, one_mul, norm_one,
ContinuousLinearMap.comp_apply, ContinuousLinearMap.coe_restrict_scalarsL',
ContinuousLinearMap.norm_restrictScalars, ContinuousLinearMap.norm_smulRightL_apply] using
hF'_int
refine ⟨hF'_int, ?_⟩
by_cases hE : CompleteSpace E; swap
· simpa [integral, hE] using hasDerivAt_const x₀ 0
simp_rw [hasDerivAt_iff_hasFDerivAt] at h_diff ⊢
simpa only [(· ∘ ·), ContinuousLinearMap.integral_comp_comm _ hF'_int] using key
/-- Derivative under integral of `x ↦ ∫ F x a` at a given point `x₀ : ℝ`, assuming
`F x₀` is integrable, `x ↦ F x a` is differentiable on an interval around `x₀` for ae `a`
(with interval radius independent of `a`) with derivative uniformly bounded by an integrable
function, and `F x` is ae-measurable for `x` in a possibly smaller neighborhood of `x₀`. -/
theorem hasDerivAt_integral_of_dominated_loc_of_deriv_le (ε_pos : 0 < ε)
(hF_meas : ∀ᶠ x in 𝓝 x₀, AEStronglyMeasurable (F x) μ) (hF_int : Integrable (F x₀) μ)
{F' : 𝕜 → α → E} (hF'_meas : AEStronglyMeasurable (F' x₀) μ)
(h_bound : ∀ᵐ a ∂μ, ∀ x ∈ ball x₀ ε, ‖F' x a‖ ≤ bound a) (bound_integrable : Integrable bound μ)
(h_diff : ∀ᵐ a ∂μ, ∀ x ∈ ball x₀ ε, HasDerivAt (F · a) (F' x a) x) :
Integrable (F' x₀) μ ∧ HasDerivAt (fun n ↦ ∫ a, F n a ∂μ) (∫ a, F' x₀ a ∂μ) x₀ := by
have x₀_in : x₀ ∈ ball x₀ ε := mem_ball_self ε_pos
have diff_x₀ : ∀ᵐ a ∂μ, HasDerivAt (F · a) (F' x₀ a) x₀ :=
h_diff.mono fun a ha ↦ ha x₀ x₀_in
have : ∀ᵐ a ∂μ, LipschitzOnWith (Real.nnabs (bound a)) (fun x : 𝕜 ↦ F x a) (ball x₀ ε) := by
apply (h_diff.and h_bound).mono
rintro a ⟨ha_deriv, ha_bound⟩
refine (convex_ball _ _).lipschitzOnWith_of_nnnorm_hasDerivWithin_le
(fun x x_in ↦ (ha_deriv x x_in).hasDerivWithinAt) fun x x_in ↦ ?_
rw [← NNReal.coe_le_coe, coe_nnnorm, Real.coe_nnabs]
exact (ha_bound x x_in).trans (le_abs_self _)
exact
hasDerivAt_integral_of_dominated_loc_of_lip ε_pos hF_meas hF_int hF'_meas this bound_integrable
diff_x₀
end |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/DerivativeTest.lean | import Mathlib.Topology.Order.OrderClosedExtr
import Mathlib.Analysis.Calculus.Deriv.MeanValue
import Mathlib.Order.Interval.Set.Basic
import Mathlib.LinearAlgebra.AffineSpace.Ordered
/-!
# The First- and Second-Derivative Tests
We prove the first-derivative test from calculus, in the strong form given on [Wikipedia](https://en.wikipedia.org/wiki/Derivative_test#First-derivative_test).
The test is proved over the real numbers ℝ
using `monotoneOn_of_deriv_nonneg` from `Mathlib/Analysis/Calculus/Deriv/MeanValue.lean`.
We prove the second-derivative test using the first-derivative test.
Source: [Wikipedia](https://en.wikipedia.org/wiki/Derivative_test#Proof_of_the_second-derivative_test).
## Main results
* `isLocalMax_of_deriv_Ioo`: Suppose `f` is a real-valued function of a real variable
defined on some interval containing the point `a`.
Further suppose that `f` is continuous at `a` and differentiable on some open interval
containing `a`, except possibly at `a` itself.
If there exists a positive number `r > 0` such that for every `x` in `(a − r, a)`
we have `f′(x) ≥ 0`, and for every `x` in `(a, a + r)` we have `f′(x) ≤ 0`,
then `f` has a local maximum at `a`.
* `isLocalMin_of_deriv_Ioo`: The dual of `first_derivative_max`, for minima.
* `isLocalMax_of_deriv`: 1st derivative test for maxima using filters.
* `isLocalMin_of_deriv`: 1st derivative test for minima using filters.
* `isLocalMin_of_deriv_deriv_pos`: The second-derivative test, minimum version.
## Tags
derivative test, first-derivative test, second-derivative test, calculus
-/
open Set Topology
/-- The First-Derivative Test from calculus, maxima version.
Suppose `a < b < c`, `f : ℝ → ℝ` is continuous at `b`,
the derivative `f'` is nonnegative on `(a,b)`, and
the derivative `f'` is nonpositive on `(b,c)`. Then `f` has a local maximum at `a`. -/
lemma isLocalMax_of_deriv_Ioo {f : ℝ → ℝ} {a b c : ℝ} (g₀ : a < b) (g₁ : b < c)
(h : ContinuousAt f b)
(hd₀ : DifferentiableOn ℝ f (Ioo a b))
(hd₁ : DifferentiableOn ℝ f (Ioo b c))
(h₀ : ∀ x ∈ Ioo a b, 0 ≤ deriv f x)
(h₁ : ∀ x ∈ Ioo b c, deriv f x ≤ 0) : IsLocalMax f b :=
have hIoc : ContinuousOn f (Ioc a b) :=
Ioo_union_right g₀ ▸ hd₀.continuousOn.union_continuousAt (isOpen_Ioo (a := a) (b := b))
(by simp_all)
have hIco : ContinuousOn f (Ico b c) :=
Ioo_union_left g₁ ▸ hd₁.continuousOn.union_continuousAt (isOpen_Ioo (a := b) (b := c))
(by simp_all)
isLocalMax_of_mono_anti g₀ g₁
(monotoneOn_of_deriv_nonneg (convex_Ioc a b) hIoc (by simp_all) (by simp_all))
(antitoneOn_of_deriv_nonpos (convex_Ico b c) hIco (by simp_all) (by simp_all))
/-- The First-Derivative Test from calculus, minima version. -/
lemma isLocalMin_of_deriv_Ioo {f : ℝ → ℝ} {a b c : ℝ}
(g₀ : a < b) (g₁ : b < c) (h : ContinuousAt f b)
(hd₀ : DifferentiableOn ℝ f (Ioo a b)) (hd₁ : DifferentiableOn ℝ f (Ioo b c))
(h₀ : ∀ x ∈ Ioo a b, deriv f x ≤ 0)
(h₁ : ∀ x ∈ Ioo b c, 0 ≤ deriv f x) : IsLocalMin f b := by
have := isLocalMax_of_deriv_Ioo (f := -f) g₀ g₁
(by simp_all) hd₀.neg hd₁.neg
(fun x hx => deriv.neg (f := f) ▸ Left.nonneg_neg_iff.mpr <|h₀ x hx)
(fun x hx => deriv.neg (f := f) ▸ Left.neg_nonpos_iff.mpr <|h₁ x hx)
exact (neg_neg f) ▸ IsLocalMax.neg this
/-- The First-Derivative Test from calculus, maxima version,
expressed in terms of left and right filters. -/
lemma isLocalMax_of_deriv' {f : ℝ → ℝ} {b : ℝ} (h : ContinuousAt f b)
(hd₀ : ∀ᶠ x in 𝓝[<] b, DifferentiableAt ℝ f x) (hd₁ : ∀ᶠ x in 𝓝[>] b, DifferentiableAt ℝ f x)
(h₀ : ∀ᶠ x in 𝓝[<] b, 0 ≤ deriv f x) (h₁ : ∀ᶠ x in 𝓝[>] b, deriv f x ≤ 0) :
IsLocalMax f b := by
obtain ⟨a, ha⟩ := (nhdsLT_basis b).eventually_iff.mp <| hd₀.and h₀
obtain ⟨c, hc⟩ := (nhdsGT_basis b).eventually_iff.mp <| hd₁.and h₁
exact isLocalMax_of_deriv_Ioo ha.1 hc.1 h
(fun _ hx => (ha.2 hx).1.differentiableWithinAt)
(fun _ hx => (hc.2 hx).1.differentiableWithinAt)
(fun _ hx => (ha.2 hx).2) (fun x hx => (hc.2 hx).2)
/-- The First-Derivative Test from calculus, minima version,
expressed in terms of left and right filters. -/
lemma isLocalMin_of_deriv' {f : ℝ → ℝ} {b : ℝ} (h : ContinuousAt f b)
(hd₀ : ∀ᶠ x in 𝓝[<] b, DifferentiableAt ℝ f x) (hd₁ : ∀ᶠ x in 𝓝[>] b, DifferentiableAt ℝ f x)
(h₀ : ∀ᶠ x in 𝓝[<] b, deriv f x ≤ 0) (h₁ : ∀ᶠ x in 𝓝[>] b, deriv f x ≥ 0) :
IsLocalMin f b := by
obtain ⟨a, ha⟩ := (nhdsLT_basis b).eventually_iff.mp <| hd₀.and h₀
obtain ⟨c, hc⟩ := (nhdsGT_basis b).eventually_iff.mp <| hd₁.and h₁
exact isLocalMin_of_deriv_Ioo ha.1 hc.1 h
(fun _ hx => (ha.2 hx).1.differentiableWithinAt)
(fun _ hx => (hc.2 hx).1.differentiableWithinAt)
(fun _ hx => (ha.2 hx).2) (fun x hx => (hc.2 hx).2)
/-- The First Derivative test, maximum version. -/
theorem isLocalMax_of_deriv {f : ℝ → ℝ} {b : ℝ} (h : ContinuousAt f b)
(hd : ∀ᶠ x in 𝓝[≠] b, DifferentiableAt ℝ f x)
(h₀ : ∀ᶠ x in 𝓝[<] b, 0 ≤ deriv f x) (h₁ : ∀ᶠ x in 𝓝[>] b, deriv f x ≤ 0) :
IsLocalMax f b :=
isLocalMax_of_deriv' h (nhdsLT_le_nhdsNE _ (by tauto)) (nhdsGT_le_nhdsNE _ (by tauto)) h₀ h₁
/-- The First Derivative test, minimum version. -/
theorem isLocalMin_of_deriv {f : ℝ → ℝ} {b : ℝ} (h : ContinuousAt f b)
(hd : ∀ᶠ x in 𝓝[≠] b, DifferentiableAt ℝ f x)
(h₀ : ∀ᶠ x in 𝓝[<] b, deriv f x ≤ 0) (h₁ : ∀ᶠ x in 𝓝[>] b, 0 ≤ deriv f x) :
IsLocalMin f b :=
isLocalMin_of_deriv' h (nhdsLT_le_nhdsNE _ (by tauto)) (nhdsGT_le_nhdsNE _ (by tauto)) h₀ h₁
open Filter SignType
section SecondDeriv
variable {f : ℝ → ℝ} {x₀ : ℝ}
/-- If the derivative of `f` is positive at a root `x₀` of `f`, then locally the sign of `f x`
matches `x - x₀`. -/
lemma eventually_nhdsWithin_sign_eq_of_deriv_pos (hf : deriv f x₀ > 0) (hx : f x₀ = 0) :
∀ᶠ x in 𝓝 x₀, sign (f x) = sign (x - x₀) := by
rw [← nhdsNE_sup_pure x₀, eventually_sup]
refine ⟨?_, by simpa⟩
have h_tendsto := hasDerivAt_iff_tendsto_slope.mp
(differentiableAt_of_deriv_ne_zero <| ne_of_gt hf).hasDerivAt
filter_upwards [(h_tendsto.eventually <| eventually_gt_nhds hf),
self_mem_nhdsWithin] with x hx₀ hx₁
rw [mem_compl_iff, mem_singleton_iff, ← Ne.eq_def] at hx₁
obtain (hx' | hx') := hx₁.lt_or_gt
· rw [sign_neg (neg_of_slope_pos hx' hx₀ hx), sign_neg (sub_neg.mpr hx')]
· rw [sign_pos (pos_of_slope_pos hx' hx₀ hx), sign_pos (sub_pos.mpr hx')]
/-- If the derivative of `f` is negative at a root `x₀` of `f`, then locally the sign of `f x`
matches `x₀ - x`. -/
lemma eventually_nhdsWithin_sign_eq_of_deriv_neg (hf : deriv f x₀ < 0) (hx : f x₀ = 0) :
∀ᶠ x in 𝓝 x₀, sign (f x) = sign (x₀ - x) := by
simpa [Left.sign_neg, -neg_sub, ← neg_sub x₀] using
eventually_nhdsWithin_sign_eq_of_deriv_pos
(f := (-f ·)) (x₀ := x₀) (by simpa [deriv.neg]) (by simpa)
lemma deriv_neg_left_of_sign_deriv {f : ℝ → ℝ} {x₀ : ℝ}
(h₀ : ∀ᶠ (x : ℝ) in 𝓝[≠] x₀, sign (deriv f x) = sign (x - x₀)) :
∀ᶠ (b : ℝ) in 𝓝[<] x₀, deriv f b < 0 := by
filter_upwards [nhdsLT_le_nhdsNE _ h₀, self_mem_nhdsWithin] with x hx' (hx : x < x₀)
rwa [← sub_neg, ← sign_eq_neg_one_iff, ← hx', sign_eq_neg_one_iff] at hx
lemma deriv_neg_right_of_sign_deriv {f : ℝ → ℝ} {x₀ : ℝ}
(h₀ : ∀ᶠ (x : ℝ) in 𝓝[≠] x₀, sign (deriv f x) = sign (x₀ - x)) :
∀ᶠ (b : ℝ) in 𝓝[>] x₀, deriv f b < 0 := by
filter_upwards [nhdsGT_le_nhdsNE _ h₀, self_mem_nhdsWithin] with x hx' (hx : x₀ < x)
rwa [← sub_neg, ← sign_eq_neg_one_iff, ← hx', sign_eq_neg_one_iff] at hx
lemma deriv_pos_right_of_sign_deriv {f : ℝ → ℝ} {x₀ : ℝ}
(h₀ : ∀ᶠ (x : ℝ) in 𝓝[≠] x₀, sign (deriv f x) = sign (x - x₀)) :
∀ᶠ (b : ℝ) in 𝓝[>] x₀, deriv f b > 0 := by
filter_upwards [nhdsGT_le_nhdsNE _ h₀, self_mem_nhdsWithin] with x hx' (hx : x₀ < x)
rwa [← sub_pos, ← sign_eq_one_iff, ← hx', sign_eq_one_iff] at hx
lemma deriv_pos_left_of_sign_deriv {f : ℝ → ℝ} {x₀ : ℝ}
(h₀ : ∀ᶠ (x : ℝ) in 𝓝[≠] x₀, sign (deriv f x) = sign (x₀ - x)) :
∀ᶠ (b : ℝ) in 𝓝[<] x₀, deriv f b > 0 := by
filter_upwards [nhdsLT_le_nhdsNE _ h₀, self_mem_nhdsWithin] with x hx' (hx : x < x₀)
rwa [← sub_pos, ← sign_eq_one_iff, ← hx', sign_eq_one_iff] at hx
/-- The First Derivative test with a hypothesis on the sign of the derivative, maximum version. -/
theorem isLocalMax_of_sign_deriv {f : ℝ → ℝ} {x₀ : ℝ} (h : ContinuousAt f x₀)
(hf : ∀ᶠ x in 𝓝[≠] x₀, sign (deriv f x) = sign (x₀ - x)) :
IsLocalMax f x₀ := by
have hl := deriv_pos_left_of_sign_deriv hf
have hg := deriv_neg_right_of_sign_deriv hf
replace hf := (nhdsLT_sup_nhdsGT x₀) ▸
eventually_sup.mpr ⟨hl.mono fun x hx => hx.ne', hg.mono fun x hx => hx.ne⟩
exact isLocalMax_of_deriv h (hf.mono fun x hx ↦ differentiableAt_of_deriv_ne_zero hx)
(hl.mono fun _ => le_of_lt) (hg.mono fun _ => le_of_lt)
/-- The First Derivative test with a hypothesis on the sign of the derivative, minimum version. -/
theorem isLocalMin_of_sign_deriv {f : ℝ → ℝ} {x₀ : ℝ} (h : ContinuousAt f x₀)
(hf : ∀ᶠ x in 𝓝[≠] x₀, sign (deriv f x) = sign (x - x₀)) :
IsLocalMin f x₀ := by
refine neg_neg f ▸ (isLocalMax_of_sign_deriv (f := (-f ·)) h.neg ?foo |>.neg)
simpa [Left.sign_neg, -neg_sub, ← neg_sub _ x₀, deriv.neg]
/-- The Second-Derivative Test from calculus, minimum version.
Applies to functions like `x^2 + 1[x ≥ 0]` as well as twice differentiable
functions. -/
theorem isLocalMin_of_deriv_deriv_pos (hf : deriv (deriv f) x₀ > 0) (hd : deriv f x₀ = 0)
(hc : ContinuousAt f x₀) : IsLocalMin f x₀ :=
isLocalMin_of_sign_deriv hc <| nhdsWithin_le_nhds <|
eventually_nhdsWithin_sign_eq_of_deriv_pos hf hd
/-- The Second-Derivative Test from calculus, maximum version. -/
theorem isLocalMax_of_deriv_deriv_neg (hf : deriv (deriv f) x₀ < 0) (hd : deriv f x₀ = 0)
(hc : ContinuousAt f x₀) : IsLocalMax f x₀ := by
simpa using isLocalMin_of_deriv_deriv_pos (by simpa) (by simpa) hc.neg |>.neg
end SecondDeriv |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/Darboux.lean | import Mathlib.Analysis.Calculus.Deriv.Add
import Mathlib.Analysis.Calculus.Deriv.Mul
import Mathlib.Analysis.Calculus.LocalExtr.Basic
/-!
# Darboux's theorem
In this file we prove that the derivative of a differentiable function on an interval takes all
intermediate values. The proof is based on the
[Wikipedia](https://en.wikipedia.org/wiki/Darboux%27s_theorem_(analysis)) page about this theorem.
-/
open Filter Set
open scoped Topology
variable {a b : ℝ} {f f' : ℝ → ℝ}
/-- **Darboux's theorem**: if `a ≤ b` and `f' a < m < f' b`, then `f' c = m` for some
`c ∈ (a, b)`. -/
theorem exists_hasDerivWithinAt_eq_of_gt_of_lt (hab : a ≤ b)
(hf : ∀ x ∈ Icc a b, HasDerivWithinAt f (f' x) (Icc a b) x) {m : ℝ} (hma : f' a < m)
(hmb : m < f' b) : m ∈ f' '' Ioo a b := by
rcases hab.eq_or_lt with (rfl | hab')
· exact (lt_asymm hma hmb).elim
set g : ℝ → ℝ := fun x => f x - m * x
have hg : ∀ x ∈ Icc a b, HasDerivWithinAt g (f' x - m) (Icc a b) x := by
intro x hx
simpa using (hf x hx).sub ((hasDerivWithinAt_id x _).const_mul m)
obtain ⟨c, cmem, hc⟩ : ∃ c ∈ Icc a b, IsMinOn g (Icc a b) c :=
isCompact_Icc.exists_isMinOn (nonempty_Icc.2 <| hab) fun x hx => (hg x hx).continuousWithinAt
have cmem' : c ∈ Ioo a b := by
rcases cmem.1.eq_or_lt with (rfl | hac)
-- Show that `c` can't be equal to `a`
· refine absurd (sub_nonneg.1 <| nonneg_of_mul_nonneg_right ?_ (sub_pos.2 hab'))
(not_le_of_gt hma)
have : b - a ∈ posTangentConeAt (Icc a b) a :=
sub_mem_posTangentConeAt_of_segment_subset (segment_eq_Icc hab ▸ Subset.rfl)
simpa only [ContinuousLinearMap.smulRight_apply, ContinuousLinearMap.one_apply]
using hc.localize.hasFDerivWithinAt_nonneg (hg a (left_mem_Icc.2 hab)) this
rcases cmem.2.eq_or_lt' with (rfl | hcb)
-- Show that `c` can't be equal to `b`
· refine absurd (sub_nonpos.1 <| nonpos_of_mul_nonneg_right ?_ (sub_lt_zero.2 hab'))
(not_le_of_gt hmb)
have : a - b ∈ posTangentConeAt (Icc a b) b :=
sub_mem_posTangentConeAt_of_segment_subset (by rw [segment_symm, segment_eq_Icc hab])
simpa only [ContinuousLinearMap.smulRight_apply, ContinuousLinearMap.one_apply]
using hc.localize.hasFDerivWithinAt_nonneg (hg b (right_mem_Icc.2 hab)) this
exact ⟨hac, hcb⟩
use c, cmem'
rw [← sub_eq_zero]
have : Icc a b ∈ 𝓝 c := by rwa [← mem_interior_iff_mem_nhds, interior_Icc]
exact (hc.isLocalMin this).hasDerivAt_eq_zero ((hg c cmem).hasDerivAt this)
/-- **Darboux's theorem**: if `a ≤ b` and `f' b < m < f' a`, then `f' c = m` for some `c ∈ (a, b)`.
-/
theorem exists_hasDerivWithinAt_eq_of_lt_of_gt (hab : a ≤ b)
(hf : ∀ x ∈ Icc a b, HasDerivWithinAt f (f' x) (Icc a b) x) {m : ℝ} (hma : m < f' a)
(hmb : f' b < m) : m ∈ f' '' Ioo a b :=
let ⟨c, cmem, hc⟩ :=
exists_hasDerivWithinAt_eq_of_gt_of_lt hab (fun x hx => (hf x hx).neg) (neg_lt_neg hma)
(neg_lt_neg hmb)
⟨c, cmem, neg_injective hc⟩
/-- **Darboux's theorem**: the image of a `Set.OrdConnected` set under `f'` is a `Set.OrdConnected`
set, `HasDerivWithinAt` version. -/
theorem Set.OrdConnected.image_hasDerivWithinAt {s : Set ℝ} (hs : OrdConnected s)
(hf : ∀ x ∈ s, HasDerivWithinAt f (f' x) s x) : OrdConnected (f' '' s) := by
apply ordConnected_of_Ioo
rintro _ ⟨a, ha, rfl⟩ _ ⟨b, hb, rfl⟩ - m ⟨hma, hmb⟩
rcases le_total a b with hab | hab
· have : Icc a b ⊆ s := hs.out ha hb
rcases exists_hasDerivWithinAt_eq_of_gt_of_lt hab (fun x hx => (hf x <| this hx).mono this) hma
hmb with
⟨c, cmem, hc⟩
exact ⟨c, this <| Ioo_subset_Icc_self cmem, hc⟩
· have : Icc b a ⊆ s := hs.out hb ha
rcases exists_hasDerivWithinAt_eq_of_lt_of_gt hab (fun x hx => (hf x <| this hx).mono this) hmb
hma with
⟨c, cmem, hc⟩
exact ⟨c, this <| Ioo_subset_Icc_self cmem, hc⟩
/-- **Darboux's theorem**: the image of a `Set.OrdConnected` set under `f'` is a `Set.OrdConnected`
set, `derivWithin` version. -/
theorem Set.OrdConnected.image_derivWithin {s : Set ℝ} (hs : OrdConnected s)
(hf : DifferentiableOn ℝ f s) : OrdConnected (derivWithin f s '' s) :=
hs.image_hasDerivWithinAt fun x hx => (hf x hx).hasDerivWithinAt
/-- **Darboux's theorem**: the image of a `Set.OrdConnected` set under `f'` is a `Set.OrdConnected`
set, `deriv` version. -/
theorem Set.OrdConnected.image_deriv {s : Set ℝ} (hs : OrdConnected s)
(hf : ∀ x ∈ s, DifferentiableAt ℝ f x) : OrdConnected (deriv f '' s) :=
hs.image_hasDerivWithinAt fun x hx => (hf x hx).hasDerivAt.hasDerivWithinAt
/-- **Darboux's theorem**: the image of a convex set under `f'` is a convex set,
`HasDerivWithinAt` version. -/
theorem Convex.image_hasDerivWithinAt {s : Set ℝ} (hs : Convex ℝ s)
(hf : ∀ x ∈ s, HasDerivWithinAt f (f' x) s x) : Convex ℝ (f' '' s) :=
(hs.ordConnected.image_hasDerivWithinAt hf).convex
/-- **Darboux's theorem**: the image of a convex set under `f'` is a convex set,
`derivWithin` version. -/
theorem Convex.image_derivWithin {s : Set ℝ} (hs : Convex ℝ s) (hf : DifferentiableOn ℝ f s) :
Convex ℝ (derivWithin f s '' s) :=
(hs.ordConnected.image_derivWithin hf).convex
/-- **Darboux's theorem**: the image of a convex set under `f'` is a convex set,
`deriv` version. -/
theorem Convex.image_deriv {s : Set ℝ} (hs : Convex ℝ s) (hf : ∀ x ∈ s, DifferentiableAt ℝ f x) :
Convex ℝ (deriv f '' s) :=
(hs.ordConnected.image_deriv hf).convex
/-- **Darboux's theorem**: if `a ≤ b` and `f' a ≤ m ≤ f' b`, then `f' c = m` for some
`c ∈ [a, b]`. -/
theorem exists_hasDerivWithinAt_eq_of_ge_of_le (hab : a ≤ b)
(hf : ∀ x ∈ Icc a b, HasDerivWithinAt f (f' x) (Icc a b) x) {m : ℝ} (hma : f' a ≤ m)
(hmb : m ≤ f' b) : m ∈ f' '' Icc a b :=
(ordConnected_Icc.image_hasDerivWithinAt hf).out (mem_image_of_mem _ (left_mem_Icc.2 hab))
(mem_image_of_mem _ (right_mem_Icc.2 hab)) ⟨hma, hmb⟩
/-- **Darboux's theorem**: if `a ≤ b` and `f' b ≤ m ≤ f' a`, then `f' c = m` for some
`c ∈ [a, b]`. -/
theorem exists_hasDerivWithinAt_eq_of_le_of_ge (hab : a ≤ b)
(hf : ∀ x ∈ Icc a b, HasDerivWithinAt f (f' x) (Icc a b) x) {m : ℝ} (hma : f' a ≤ m)
(hmb : m ≤ f' b) : m ∈ f' '' Icc a b :=
(ordConnected_Icc.image_hasDerivWithinAt hf).out (mem_image_of_mem _ (left_mem_Icc.2 hab))
(mem_image_of_mem _ (right_mem_Icc.2 hab)) ⟨hma, hmb⟩
/-- If the derivative of a function is never equal to `m`, then either
it is always greater than `m`, or it is always less than `m`. -/
theorem hasDerivWithinAt_forall_lt_or_forall_gt_of_forall_ne {s : Set ℝ} (hs : Convex ℝ s)
(hf : ∀ x ∈ s, HasDerivWithinAt f (f' x) s x) {m : ℝ} (hf' : ∀ x ∈ s, f' x ≠ m) :
(∀ x ∈ s, f' x < m) ∨ ∀ x ∈ s, m < f' x := by
contrapose! hf'
rcases hf' with ⟨⟨b, hb, hmb⟩, ⟨a, ha, hma⟩⟩
exact (hs.ordConnected.image_hasDerivWithinAt hf).out (mem_image_of_mem f' ha)
(mem_image_of_mem f' hb) ⟨hma, hmb⟩ |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/LogDerivUniformlyOn.lean | import Mathlib.Analysis.Complex.LocallyUniformLimit
import Mathlib.Topology.Algebra.InfiniteSum.UniformOn
/-!
# The Logarithmic derivative of an infinite product
We show that if we have an infinite product of functions `f` that is locally uniformly convergent,
then the logarithmic derivative of the product is the sum of the logarithmic derivatives of the
individual functions.
-/
open Complex
theorem logDeriv_tprod_eq_tsum {ι : Type*} {s : Set ℂ} (hs : IsOpen s) {x : s} {f : ι → ℂ → ℂ}
(hf : ∀ i, f i x ≠ 0) (hd : ∀ i, DifferentiableOn ℂ (f i) s)
(hm : Summable fun i ↦ logDeriv (f i) x) (htend : MultipliableLocallyUniformlyOn f s)
(hnez : ∏' i, f i x ≠ 0) :
logDeriv (∏' i, f i ·) x = ∑' i, logDeriv (f i) x := by
rw [Eq.comm, ← hm.hasSum_iff]
refine logDeriv_tendsto hs x htend.hasProdLocallyUniformlyOn (.of_forall <| by fun_prop) hnez
|>.congr fun b ↦ ?_
rw [logDeriv_prod _ _ _ (fun i _ ↦ hf i)
(fun i _ ↦ (hd i x x.2).differentiableAt (hs.mem_nhds x.2))] |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/LogDeriv.lean | import Mathlib.Analysis.Calculus.Deriv.ZPow
import Mathlib.Analysis.Calculus.MeanValue
/-!
# Logarithmic Derivatives
We define the logarithmic derivative of a function `f` as `deriv f / f`. We then prove some basic
facts about this, including how it changes under multiplication and composition.
-/
noncomputable section
open Filter Function Set
open scoped Topology
variable {𝕜 𝕜' : Type*} [NontriviallyNormedField 𝕜] [NontriviallyNormedField 𝕜']
[NormedAlgebra 𝕜 𝕜']
/-- The logarithmic derivative of a function defined as `deriv f /f`. Note that it will be zero
at `x` if `f` is not DifferentiableAt `x`. -/
def logDeriv (f : 𝕜 → 𝕜') :=
deriv f / f
theorem logDeriv_apply (f : 𝕜 → 𝕜') (x : 𝕜) : logDeriv f x = deriv f x / f x := rfl
lemma logDeriv_eq_zero_of_not_differentiableAt (f : 𝕜 → 𝕜') (x : 𝕜) (h : ¬DifferentiableAt 𝕜 f x) :
logDeriv f x = 0 := by
simp only [logDeriv_apply, deriv_zero_of_not_differentiableAt h, zero_div]
@[simp]
theorem logDeriv_id (x : 𝕜) : logDeriv id x = 1 / x := by
simp [logDeriv_apply]
@[simp] theorem logDeriv_id' (x : 𝕜) : logDeriv (·) x = 1 / x := logDeriv_id x
@[simp]
theorem logDeriv_const (a : 𝕜') : logDeriv (fun _ : 𝕜 ↦ a) = 0 := by
ext
simp [logDeriv_apply]
theorem logDeriv_mul {f g : 𝕜 → 𝕜'} (x : 𝕜) (hf : f x ≠ 0) (hg : g x ≠ 0)
(hdf : DifferentiableAt 𝕜 f x) (hdg : DifferentiableAt 𝕜 g x) :
logDeriv (fun z => f z * g z) x = logDeriv f x + logDeriv g x := by
simp [field, logDeriv_apply, *]
theorem logDeriv_div {f g : 𝕜 → 𝕜'} (x : 𝕜) (hf : f x ≠ 0) (hg : g x ≠ 0)
(hdf : DifferentiableAt 𝕜 f x) (hdg : DifferentiableAt 𝕜 g x) :
logDeriv (fun z => f z / g z) x = logDeriv f x - logDeriv g x := by
simp [field, logDeriv_apply, *]
theorem logDeriv_mul_const {f : 𝕜 → 𝕜'} (x : 𝕜) (a : 𝕜') (ha : a ≠ 0) :
logDeriv (fun z => f z * a) x = logDeriv f x := by
simp only [logDeriv_apply, deriv_mul_const_field, mul_div_mul_right _ _ ha]
theorem logDeriv_const_mul {f : 𝕜 → 𝕜'} (x : 𝕜) (a : 𝕜') (ha : a ≠ 0) :
logDeriv (fun z => a * f z) x = logDeriv f x := by
simp only [logDeriv_apply, deriv_const_mul_field, mul_div_mul_left _ _ ha]
/-- The logarithmic derivative of a finite product is the sum of the logarithmic derivatives. -/
theorem logDeriv_prod {ι : Type*} (s : Finset ι) (f : ι → 𝕜 → 𝕜') (x : 𝕜) (hf : ∀ i ∈ s, f i x ≠ 0)
(hd : ∀ i ∈ s, DifferentiableAt 𝕜 (f i) x) :
logDeriv (∏ i ∈ s, f i ·) x = ∑ i ∈ s, logDeriv (f i) x := by
induction s using Finset.cons_induction with
| empty => simp
| cons a s ha ih =>
rw [Finset.forall_mem_cons] at hf hd
simp_rw [Finset.prod_cons, Finset.sum_cons]
rw [logDeriv_mul, ih hf.2 hd.2]
· exact hf.1
· simpa [Finset.prod_eq_zero_iff] using hf.2
· exact hd.1
· exact .fun_finset_prod hd.2
lemma logDeriv_fun_zpow {f : 𝕜 → 𝕜'} {x : 𝕜} (hdf : DifferentiableAt 𝕜 f x) (n : ℤ) :
logDeriv (f · ^ n) x = n * logDeriv f x := by
rcases eq_or_ne n 0 with rfl | hn; · simp
rcases eq_or_ne (f x) 0 with hf | hf
· simp [logDeriv_apply, zero_zpow, *]
· rw [logDeriv_apply, ← comp_def (·^n), deriv_comp _ (differentiableAt_zpow.2 <| .inl hf) hdf,
deriv_zpow, logDeriv_apply]
simp [field, zpow_sub_one₀ hf]
lemma logDeriv_fun_pow {f : 𝕜 → 𝕜'} {x : 𝕜} (hdf : DifferentiableAt 𝕜 f x) (n : ℕ) :
logDeriv (f · ^ n) x = n * logDeriv f x :=
mod_cast logDeriv_fun_zpow hdf n
@[simp]
lemma logDeriv_zpow (x : 𝕜) (n : ℤ) : logDeriv (· ^ n) x = n / x := by
rw [logDeriv_fun_zpow (by fun_prop), logDeriv_id', mul_one_div]
@[simp]
lemma logDeriv_pow (x : 𝕜) (n : ℕ) : logDeriv (· ^ n) x = n / x :=
mod_cast logDeriv_zpow x n
@[simp] lemma logDeriv_inv (x : 𝕜) : logDeriv (·⁻¹) x = -1 / x := by
simpa using logDeriv_zpow x (-1)
theorem logDeriv_comp {f : 𝕜' → 𝕜'} {g : 𝕜 → 𝕜'} {x : 𝕜} (hf : DifferentiableAt 𝕜' f (g x))
(hg : DifferentiableAt 𝕜 g x) : logDeriv (f ∘ g) x = logDeriv f (g x) * deriv g x := by
simp only [logDeriv, Pi.div_apply, deriv_comp _ hf hg, comp_apply]
ring
lemma logDeriv_eqOn_iff [IsRCLikeNormedField 𝕜] {f g : 𝕜 → 𝕜'} {s : Set 𝕜}
(hf : DifferentiableOn 𝕜 f s) (hg : DifferentiableOn 𝕜 g s)
(hs2 : IsOpen s) (hsc : IsPreconnected s) (hgn : ∀ x ∈ s, g x ≠ 0) (hfn : ∀ x ∈ s, f x ≠ 0) :
EqOn (logDeriv f) (logDeriv g) s ↔ ∃ z : 𝕜', z ≠ 0 ∧ EqOn f (z • g) s := by
rcases s.eq_empty_or_nonempty with rfl | ⟨t, ht⟩
· simpa using ⟨1, one_ne_zero⟩
· constructor
· refine fun h ↦ ⟨f t * (g t)⁻¹, by grind, fun y hy ↦ ?_⟩
have hderiv : s.EqOn (deriv (f * g⁻¹)) (deriv f * g⁻¹ - f * deriv g / g ^ 2) := by
intro z hz
rw [deriv_mul (hf.differentiableAt (hs2.mem_nhds hz)) ((hg.differentiableAt
(hs2.mem_nhds hz)).inv (hgn z hz))]
simp only [Pi.inv_apply, show g⁻¹ = (fun x => x⁻¹) ∘ g by rfl, deriv_inv, neg_mul,
deriv_comp z (differentiableAt_inv (hgn z hz)) (hg.differentiableAt (hs2.mem_nhds hz)),
mul_neg, Pi.sub_apply, Pi.mul_apply, comp_apply, Pi.div_apply, Pi.pow_apply]
ring
have hfg : EqOn (deriv (f * g⁻¹)) 0 s := hderiv.trans fun z hz ↦ by
simp only [Pi.sub_apply, Pi.mul_apply, Pi.inv_apply, Pi.div_apply, Pi.pow_apply,
Pi.zero_apply]
grind [logDeriv_apply, Pi.div_apply]
letI := IsRCLikeNormedField.rclike 𝕜
obtain ⟨a, ha⟩ := hs2.exists_is_const_of_deriv_eq_zero hsc (hf.mul (hg.inv hgn)) hfg
grind [Pi.mul_apply, Pi.inv_apply, Pi.smul_apply, smul_eq_mul]
· rintro ⟨z, hz0, hz⟩ x hx
simp [logDeriv_apply, hz.deriv hs2 hx, hz hx, deriv_const_smul _
(hg.differentiableAt (hs2.mem_nhds hx)), mul_div_mul_left (deriv g x) (g x) hz0] |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/Monotone.lean | import Mathlib.Analysis.Calculus.Deriv.Slope
import Mathlib.MeasureTheory.Covering.OneDim
import Mathlib.Order.Monotone.Extension
/-!
# Differentiability of monotone functions
We show that a monotone function `f : ℝ → ℝ` is differentiable almost everywhere, in
`Monotone.ae_differentiableAt`. (We also give a version for a function monotone on a set, in
`MonotoneOn.ae_differentiableWithinAt`.)
If the function `f` is continuous, this follows directly from general differentiation of measure
theorems. Let `μ` be the Stieltjes measure associated to `f`. Then, almost everywhere,
`μ [x, y] / Leb [x, y]` (resp. `μ [y, x] / Leb [y, x]`) converges to the Radon-Nikodym derivative
of `μ` with respect to Lebesgue when `y` tends to `x` in `(x, +∞)` (resp. `(-∞, x)`), by
`VitaliFamily.ae_tendsto_rnDeriv`. As `μ [x, y] = f y - f x` and `Leb [x, y] = y - x`, this
gives differentiability right away.
When `f` is only monotone, the same argument works up to small adjustments, as the associated
Stieltjes measure satisfies `μ [x, y] = f (y^+) - f (x^-)` (the right and left limits of `f` at `y`
and `x` respectively). One argues that `f (x^-) = f x` almost everywhere (in fact away from a
countable set), and moreover `f ((y - (y-x)^2)^+) ≤ f y ≤ f (y^+)`. This is enough to deduce the
limit of `(f y - f x) / (y - x)` by a lower and upper approximation argument from the known
behavior of `μ [x, y]`.
-/
open Set Filter Function Metric MeasureTheory MeasureTheory.Measure IsUnifLocDoublingMeasure
open scoped Topology
-- see https://github.com/leanprover-community/mathlib4/issues/29041
set_option linter.unusedSimpArgs false in
/-- If `(f y - f x) / (y - x)` converges to a limit as `y` tends to `x`, then the same goes if
`y` is shifted a little bit, i.e., `f (y + (y-x)^2) - f x) / (y - x)` converges to the same limit.
This lemma contains a slightly more general version of this statement (where one considers
convergence along some subfilter, typically `𝓝[<] x` or `𝓝[>] x`) tailored to the application
to almost everywhere differentiability of monotone functions. -/
theorem tendsto_apply_add_mul_sq_div_sub {f : ℝ → ℝ} {x a c d : ℝ} {l : Filter ℝ} (hl : l ≤ 𝓝[≠] x)
(hf : Tendsto (fun y => (f y - d) / (y - x)) l (𝓝 a))
(h' : Tendsto (fun y => y + c * (y - x) ^ 2) l l) :
Tendsto (fun y => (f (y + c * (y - x) ^ 2) - d) / (y - x)) l (𝓝 a) := by
have L : Tendsto (fun y => (y + c * (y - x) ^ 2 - x) / (y - x)) l (𝓝 1) := by
have : Tendsto (fun y => 1 + c * (y - x)) l (𝓝 (1 + c * (x - x))) := by
apply Tendsto.mono_left _ (hl.trans nhdsWithin_le_nhds)
exact ((tendsto_id.sub_const x).const_mul c).const_add 1
simp only [_root_.sub_self, add_zero, mul_zero] at this
apply Tendsto.congr' (Eventually.filter_mono hl _) this
filter_upwards [self_mem_nhdsWithin] with y hy
field_simp [sub_ne_zero.2 hy]
ring
have Z := (hf.comp h').mul L
rw [mul_one] at Z
apply Tendsto.congr' _ Z
have : ∀ᶠ y in l, y + c * (y - x) ^ 2 ≠ x := by apply Tendsto.mono_right h' hl self_mem_nhdsWithin
filter_upwards [this] with y hy
simp [field, sub_ne_zero.2 hy]
/-- A Stieltjes function is almost everywhere differentiable, with derivative equal to the
Radon-Nikodym derivative of the associated Stieltjes measure with respect to Lebesgue. -/
theorem StieltjesFunction.ae_hasDerivAt (f : StieltjesFunction) :
∀ᵐ x, HasDerivAt f (rnDeriv f.measure volume x).toReal x := by
/- Denote by `μ` the Stieltjes measure associated to `f`.
The general theorem `VitaliFamily.ae_tendsto_rnDeriv` ensures that `μ [x, y] / (y - x)` tends
to the Radon-Nikodym derivative as `y` tends to `x` from the right. As `μ [x,y] = f y - f (x^-)`
and `f (x^-) = f x` almost everywhere, this gives differentiability on the right.
On the left, `μ [y, x] / (x - y)` again tends to the Radon-Nikodym derivative.
As `μ [y, x] = f x - f (y^-)`, this is not exactly the right result, so one uses a sandwiching
argument to deduce the convergence for `(f x - f y) / (x - y)`. -/
filter_upwards [VitaliFamily.ae_tendsto_rnDeriv (vitaliFamily (volume : Measure ℝ) 1) f.measure,
rnDeriv_lt_top f.measure volume, f.countable_leftLim_ne.ae_notMem volume] with x hx h'x h''x
-- Limit on the right, following from differentiation of measures
have L1 :
Tendsto (fun y => (f y - f x) / (y - x)) (𝓝[>] x) (𝓝 (rnDeriv f.measure volume x).toReal) := by
apply Tendsto.congr' _
((ENNReal.tendsto_toReal h'x.ne).comp (hx.comp (Real.tendsto_Icc_vitaliFamily_right x)))
filter_upwards [self_mem_nhdsWithin]
rintro y (hxy : x < y)
simp only [comp_apply, StieltjesFunction.measure_Icc, Real.volume_Icc, Classical.not_not.1 h''x]
rw [← ENNReal.ofReal_div_of_pos (sub_pos.2 hxy), ENNReal.toReal_ofReal]
exact div_nonneg (sub_nonneg.2 (f.mono hxy.le)) (sub_pos.2 hxy).le
-- Limit on the left, following from differentiation of measures. Its form is not exactly the one
-- we need, due to the appearance of a left limit.
have L2 : Tendsto (fun y => (leftLim f y - f x) / (y - x)) (𝓝[<] x)
(𝓝 (rnDeriv f.measure volume x).toReal) := by
apply Tendsto.congr' _
((ENNReal.tendsto_toReal h'x.ne).comp (hx.comp (Real.tendsto_Icc_vitaliFamily_left x)))
filter_upwards [self_mem_nhdsWithin]
rintro y (hxy : y < x)
simp only [comp_apply, StieltjesFunction.measure_Icc, Real.volume_Icc]
rw [← ENNReal.ofReal_div_of_pos (sub_pos.2 hxy), ENNReal.toReal_ofReal, ← neg_neg (y - x),
div_neg, neg_div', neg_sub, neg_sub]
exact div_nonneg (sub_nonneg.2 (f.mono.leftLim_le hxy.le)) (sub_pos.2 hxy).le
-- Shifting a little bit the limit on the left, by `(y - x)^2`.
have L3 : Tendsto (fun y => (leftLim f (y + 1 * (y - x) ^ 2) - f x) / (y - x)) (𝓝[<] x)
(𝓝 (rnDeriv f.measure volume x).toReal) := by
apply tendsto_apply_add_mul_sq_div_sub (nhdsLT_le_nhdsNE x) L2
apply tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within
· apply Tendsto.mono_left _ nhdsWithin_le_nhds
have : Tendsto (fun y : ℝ => y + ↑1 * (y - x) ^ 2) (𝓝 x) (𝓝 (x + ↑1 * (x - x) ^ 2)) :=
tendsto_id.add (((tendsto_id.sub_const x).pow 2).const_mul ↑1)
simpa using this
· filter_upwards [Ioo_mem_nhdsLT <| show x - 1 < x by simp]
rintro y ⟨hy : x - 1 < y, h'y : y < x⟩
rw [mem_Iio]
nlinarith
-- Deduce the correct limit on the left, by sandwiching.
have L4 :
Tendsto (fun y => (f y - f x) / (y - x)) (𝓝[<] x) (𝓝 (rnDeriv f.measure volume x).toReal) := by
apply tendsto_of_tendsto_of_tendsto_of_le_of_le' L3 L2
· filter_upwards [self_mem_nhdsWithin]
rintro y (hy : y < x)
refine div_le_div_of_nonpos_of_le (by linarith) ((sub_le_sub_iff_right _).2 ?_)
apply f.mono.le_leftLim
have : ↑0 < (x - y) ^ 2 := sq_pos_of_pos (sub_pos.2 hy)
linarith
· filter_upwards [self_mem_nhdsWithin]
rintro y (hy : y < x)
refine div_le_div_of_nonpos_of_le (by linarith) ?_
simpa only [sub_le_sub_iff_right] using f.mono.leftLim_le (le_refl y)
-- prove the result by splitting into left and right limits.
rw [hasDerivAt_iff_tendsto_slope, slope_fun_def_field, ← nhdsLT_sup_nhdsGT, tendsto_sup]
exact ⟨L4, L1⟩
/-- A monotone function is almost everywhere differentiable, with derivative equal to the
Radon-Nikodym derivative of the associated Stieltjes measure with respect to Lebesgue. -/
theorem Monotone.ae_hasDerivAt {f : ℝ → ℝ} (hf : Monotone f) :
∀ᵐ x, HasDerivAt f (rnDeriv hf.stieltjesFunction.measure volume x).toReal x := by
/- We already know that the Stieltjes function associated to `f` (i.e., `g : x ↦ f (x^+)`) is
differentiable almost everywhere. We reduce to this statement by sandwiching values of `f` with
values of `g`, by shifting with `(y - x)^2` (which has no influence on the relevant
scale `y - x`.) -/
filter_upwards [hf.stieltjesFunction.ae_hasDerivAt,
hf.countable_not_continuousAt.ae_notMem volume] with x hx h'x
have A : hf.stieltjesFunction x = f x := by
rw [Classical.not_not, hf.continuousAt_iff_leftLim_eq_rightLim] at h'x
apply le_antisymm _ (hf.le_rightLim (le_refl _))
rw [← h'x]
exact hf.leftLim_le (le_refl _)
rw [hasDerivAt_iff_tendsto_slope, (nhdsLT_sup_nhdsGT x).symm, tendsto_sup,
slope_fun_def_field, A] at hx
-- prove differentiability on the right, by sandwiching with values of `g`
have L1 : Tendsto (fun y => (f y - f x) / (y - x)) (𝓝[>] x)
(𝓝 (rnDeriv hf.stieltjesFunction.measure volume x).toReal) := by
-- limit of a helper function, with a small shift compared to `g`
have : Tendsto (fun y => (hf.stieltjesFunction (y + -1 * (y - x) ^ 2) - f x) / (y - x)) (𝓝[>] x)
(𝓝 (rnDeriv hf.stieltjesFunction.measure volume x).toReal) := by
apply tendsto_apply_add_mul_sq_div_sub (nhdsGT_le_nhdsNE x) hx.2
apply tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within
· apply Tendsto.mono_left _ nhdsWithin_le_nhds
have : Tendsto (fun y : ℝ => y + -↑1 * (y - x) ^ 2) (𝓝 x) (𝓝 (x + -↑1 * (x - x) ^ 2)) :=
tendsto_id.add (((tendsto_id.sub_const x).pow 2).const_mul (-1))
simpa using this
· filter_upwards [Ioo_mem_nhdsGT <| show x < x + 1 by simp]
rintro y ⟨hy : x < y, h'y : y < x + 1⟩
rw [mem_Ioi]
nlinarith
-- apply the sandwiching argument, with the helper function and `g`
apply tendsto_of_tendsto_of_tendsto_of_le_of_le' this hx.2
· filter_upwards [self_mem_nhdsWithin] with y hy
rw [mem_Ioi, ← sub_pos] at hy
gcongr
exact hf.rightLim_le (by nlinarith)
· filter_upwards [self_mem_nhdsWithin] with y hy
rw [mem_Ioi, ← sub_pos] at hy
gcongr
exact hf.le_rightLim le_rfl
-- prove differentiability on the left, by sandwiching with values of `g`
have L2 : Tendsto (fun y => (f y - f x) / (y - x)) (𝓝[<] x)
(𝓝 (rnDeriv hf.stieltjesFunction.measure volume x).toReal) := by
-- limit of a helper function, with a small shift compared to `g`
have : Tendsto (fun y => (hf.stieltjesFunction (y + -1 * (y - x) ^ 2) - f x) / (y - x)) (𝓝[<] x)
(𝓝 (rnDeriv hf.stieltjesFunction.measure volume x).toReal) := by
apply tendsto_apply_add_mul_sq_div_sub (nhdsLT_le_nhdsNE x) hx.1
apply tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within
· apply Tendsto.mono_left _ nhdsWithin_le_nhds
have : Tendsto (fun y : ℝ => y + -↑1 * (y - x) ^ 2) (𝓝 x) (𝓝 (x + -↑1 * (x - x) ^ 2)) :=
tendsto_id.add (((tendsto_id.sub_const x).pow 2).const_mul (-1))
simpa using this
· filter_upwards [Ioo_mem_nhdsLT <| show x - 1 < x by simp]
rintro y hy
rw [mem_Ioo] at hy
rw [mem_Iio]
nlinarith
-- apply the sandwiching argument, with `g` and the helper function
apply tendsto_of_tendsto_of_tendsto_of_le_of_le' hx.1 this
· filter_upwards [self_mem_nhdsWithin]
rintro y hy
rw [mem_Iio, ← sub_neg] at hy
apply div_le_div_of_nonpos_of_le hy.le
exact (sub_le_sub_iff_right _).2 (hf.le_rightLim (le_refl _))
· filter_upwards [self_mem_nhdsWithin]
rintro y hy
rw [mem_Iio, ← sub_neg] at hy
have : 0 < (y - x) ^ 2 := sq_pos_of_neg hy
apply div_le_div_of_nonpos_of_le hy.le
exact (sub_le_sub_iff_right _).2 (hf.rightLim_le (by linarith))
-- conclude global differentiability
rw [hasDerivAt_iff_tendsto_slope, slope_fun_def_field, ← nhdsLT_sup_nhdsGT, tendsto_sup]
exact ⟨L2, L1⟩
/-- A monotone real function is differentiable Lebesgue-almost everywhere. -/
theorem Monotone.ae_differentiableAt {f : ℝ → ℝ} (hf : Monotone f) :
∀ᵐ x, DifferentiableAt ℝ f x := by
filter_upwards [hf.ae_hasDerivAt] with x hx using hx.differentiableAt
/-- A real function which is monotone on a set is differentiable Lebesgue-almost everywhere on
this set. This version does not assume that `s` is measurable. For a formulation with
`volume.restrict s` assuming that `s` is measurable, see `MonotoneOn.ae_differentiableWithinAt`.
-/
theorem MonotoneOn.ae_differentiableWithinAt_of_mem {f : ℝ → ℝ} {s : Set ℝ} (hf : MonotoneOn f s) :
∀ᵐ x, x ∈ s → DifferentiableWithinAt ℝ f s x := by
/- We use a global monotone extension of `f`, and argue that this extension is differentiable
almost everywhere. Such an extension need not exist (think of `1/x` on `(0, +∞)`), but it exists
if one restricts first the function to a compact interval `[a, b]`. -/
apply ae_of_mem_of_ae_of_mem_inter_Ioo
intro a b as bs _
obtain ⟨g, hg, gf⟩ : ∃ g : ℝ → ℝ, Monotone g ∧ EqOn f g (s ∩ Icc a b) :=
(hf.mono inter_subset_left).exists_monotone_extension
(hf.map_bddBelow inter_subset_left ⟨a, fun x hx => hx.2.1, as⟩)
(hf.map_bddAbove inter_subset_left ⟨b, fun x hx => hx.2.2, bs⟩)
filter_upwards [hg.ae_differentiableAt] with x hx
intro h'x
apply hx.differentiableWithinAt.congr_of_eventuallyEq _ (gf ⟨h'x.1, h'x.2.1.le, h'x.2.2.le⟩)
have : Ioo a b ∈ 𝓝[s] x := nhdsWithin_le_nhds (Ioo_mem_nhds h'x.2.1 h'x.2.2)
filter_upwards [self_mem_nhdsWithin, this] with y hy h'y
exact gf ⟨hy, h'y.1.le, h'y.2.le⟩
/-- A real function which is monotone on a set is differentiable Lebesgue-almost everywhere on
this set. This version assumes that `s` is measurable and uses `volume.restrict s`.
For a formulation without measurability assumption,
see `MonotoneOn.ae_differentiableWithinAt_of_mem`. -/
theorem MonotoneOn.ae_differentiableWithinAt {f : ℝ → ℝ} {s : Set ℝ} (hf : MonotoneOn f s)
(hs : MeasurableSet s) : ∀ᵐ x ∂volume.restrict s, DifferentiableWithinAt ℝ f s x := by
rw [ae_restrict_iff' hs]
exact hf.ae_differentiableWithinAt_of_mem |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/MeanValue.lean | import Mathlib.Analysis.Calculus.Deriv.AffineMap
import Mathlib.Analysis.Calculus.Deriv.Comp
import Mathlib.Analysis.Calculus.Deriv.Mul
import Mathlib.Analysis.Calculus.Deriv.Slope
import Mathlib.Analysis.Normed.Group.AddTorsor
import Mathlib.Analysis.Normed.Module.Convex
import Mathlib.Analysis.RCLike.Basic
import Mathlib.Topology.Instances.RealVectorSpace
import Mathlib.Topology.LocallyConstant.Basic
/-!
# The mean value inequality and equalities
In this file we prove the following facts:
* `Convex.norm_image_sub_le_of_norm_deriv_le` : if `f` is differentiable on a convex set `s`
and the norm of its derivative is bounded by `C`, then `f` is Lipschitz continuous on `s` with
constant `C`; also a variant in which what is bounded by `C` is the norm of the difference of the
derivative from a fixed linear map. This lemma and its versions are formulated using `RCLike`,
so they work both for real and complex derivatives.
* `image_le_of*`, `image_norm_le_of_*` : several similar lemmas deducing `f x ≤ B x` or
`‖f x‖ ≤ B x` from upper estimates on `f'` or `‖f'‖`, respectively. These lemmas differ by
their assumptions:
* `of_liminf_*` lemmas assume that limit inferior of some ratio is less than `B' x`;
* `of_deriv_right_*`, `of_norm_deriv_right_*` lemmas assume that the right derivative
or its norm is less than `B' x`;
* `of_*_lt_*` lemmas assume a strict inequality whenever `f x = B x` or `‖f x‖ = B x`;
* `of_*_le_*` lemmas assume a non-strict inequality everywhere on `[a, b)`;
* name of a lemma ends with `'` if (1) it assumes that `B` is continuous on `[a, b]`
and has a right derivative at every point of `[a, b)`, and (2) the lemma has
a counterpart assuming that `B` is differentiable everywhere on `ℝ`
* `norm_image_sub_le_*_segment` : if derivative of `f` on `[a, b]` is bounded above
by a constant `C`, then `‖f x - f a‖ ≤ C * ‖x - a‖`; several versions deal with
right derivative and derivative within `[a, b]` (`HasDerivWithinAt` or `derivWithin`).
* `Convex.is_const_of_fderivWithin_eq_zero` : if a function has derivative `0` on a convex set `s`,
then it is a constant on `s`.
* `hasStrictFDerivAt_of_hasFDerivAt_of_continuousAt` : a C^1 function over the reals is
strictly differentiable. (This is a corollary of the mean value inequality.)
-/
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] {F : Type*} [NormedAddCommGroup F]
[NormedSpace ℝ F]
open Metric Set Asymptotics ContinuousLinearMap Filter
open scoped Topology NNReal
/-! ### One-dimensional fencing inequalities -/
/-- General fencing theorem for continuous functions with an estimate on the derivative.
Let `f` and `B` be continuous functions on `[a, b]` such that
* `f a ≤ B a`;
* `B` has right derivative `B'` at every point of `[a, b)`;
* for each `x ∈ [a, b)` the right-side limit inferior of `(f z - f x) / (z - x)`
is bounded above by a function `f'`;
* we have `f' x < B' x` whenever `f x = B x`.
Then `f x ≤ B x` everywhere on `[a, b]`. -/
theorem image_le_of_liminf_slope_right_lt_deriv_boundary' {f f' : ℝ → ℝ} {a b : ℝ}
(hf : ContinuousOn f (Icc a b))
-- `hf'` actually says `liminf (f z - f x) / (z - x) ≤ f' x`
(hf' : ∀ x ∈ Ico a b, ∀ r, f' x < r → ∃ᶠ z in 𝓝[>] x, slope f x z < r)
{B B' : ℝ → ℝ} (ha : f a ≤ B a) (hB : ContinuousOn B (Icc a b))
(hB' : ∀ x ∈ Ico a b, HasDerivWithinAt B (B' x) (Ici x) x)
(bound : ∀ x ∈ Ico a b, f x = B x → f' x < B' x) : ∀ ⦃x⦄, x ∈ Icc a b → f x ≤ B x := by
change Icc a b ⊆ { x | f x ≤ B x }
set s := { x | f x ≤ B x } ∩ Icc a b
have A : ContinuousOn (fun x => (f x, B x)) (Icc a b) := hf.prodMk hB
have : IsClosed s := by
simp only [s, inter_comm]
exact A.preimage_isClosed_of_isClosed isClosed_Icc OrderClosedTopology.isClosed_le'
apply this.Icc_subset_of_forall_exists_gt ha
rintro x ⟨hxB : f x ≤ B x, xab⟩ y hy
rcases hxB.lt_or_eq with hxB | hxB
· -- If `f x < B x`, then all we need is continuity of both sides
refine nonempty_of_mem (inter_mem ?_ (Ioc_mem_nhdsGT hy))
have : ∀ᶠ x in 𝓝[Icc a b] x, f x < B x :=
A x (Ico_subset_Icc_self xab) (IsOpen.mem_nhds (isOpen_lt continuous_fst continuous_snd) hxB)
have : ∀ᶠ x in 𝓝[>] x, f x < B x := nhdsWithin_le_of_mem (Icc_mem_nhdsGT_of_mem xab) this
exact this.mono fun y => le_of_lt
· rcases exists_between (bound x xab hxB) with ⟨r, hfr, hrB⟩
specialize hf' x xab r hfr
have HB : ∀ᶠ z in 𝓝[>] x, r < slope B x z :=
(hasDerivWithinAt_iff_tendsto_slope' <| lt_irrefl x).1 (hB' x xab).Ioi_of_Ici
(Ioi_mem_nhds hrB)
obtain ⟨z, hfz, hzB, hz⟩ : ∃ z, slope f x z < r ∧ r < slope B x z ∧ z ∈ Ioc x y :=
hf'.and_eventually (HB.and (Ioc_mem_nhdsGT hy)) |>.exists
refine ⟨z, ?_, hz⟩
have := (hfz.trans hzB).le
rwa [slope_def_field, slope_def_field, div_le_div_iff_of_pos_right (sub_pos.2 hz.1), hxB,
sub_le_sub_iff_right] at this
/-- General fencing theorem for continuous functions with an estimate on the derivative.
Let `f` and `B` be continuous functions on `[a, b]` such that
* `f a ≤ B a`;
* `B` has derivative `B'` everywhere on `ℝ`;
* for each `x ∈ [a, b)` the right-side limit inferior of `(f z - f x) / (z - x)`
is bounded above by a function `f'`;
* we have `f' x < B' x` whenever `f x = B x`.
Then `f x ≤ B x` everywhere on `[a, b]`. -/
theorem image_le_of_liminf_slope_right_lt_deriv_boundary {f f' : ℝ → ℝ} {a b : ℝ}
(hf : ContinuousOn f (Icc a b))
-- `hf'` actually says `liminf (f z - f x) / (z - x) ≤ f' x`
(hf' : ∀ x ∈ Ico a b, ∀ r, f' x < r → ∃ᶠ z in 𝓝[>] x, slope f x z < r)
{B B' : ℝ → ℝ} (ha : f a ≤ B a) (hB : ∀ x, HasDerivAt B (B' x) x)
(bound : ∀ x ∈ Ico a b, f x = B x → f' x < B' x) : ∀ ⦃x⦄, x ∈ Icc a b → f x ≤ B x :=
image_le_of_liminf_slope_right_lt_deriv_boundary' hf hf' ha
(fun x _ => (hB x).continuousAt.continuousWithinAt) (fun x _ => (hB x).hasDerivWithinAt) bound
/-- General fencing theorem for continuous functions with an estimate on the derivative.
Let `f` and `B` be continuous functions on `[a, b]` such that
* `f a ≤ B a`;
* `B` has right derivative `B'` at every point of `[a, b)`;
* for each `x ∈ [a, b)` the right-side limit inferior of `(f z - f x) / (z - x)`
is bounded above by `B'`.
Then `f x ≤ B x` everywhere on `[a, b]`. -/
theorem image_le_of_liminf_slope_right_le_deriv_boundary {f : ℝ → ℝ} {a b : ℝ}
(hf : ContinuousOn f (Icc a b)) {B B' : ℝ → ℝ} (ha : f a ≤ B a) (hB : ContinuousOn B (Icc a b))
(hB' : ∀ x ∈ Ico a b, HasDerivWithinAt B (B' x) (Ici x) x)
-- `bound` actually says `liminf (f z - f x) / (z - x) ≤ B' x`
(bound : ∀ x ∈ Ico a b, ∀ r, B' x < r → ∃ᶠ z in 𝓝[>] x, slope f x z < r) :
∀ ⦃x⦄, x ∈ Icc a b → f x ≤ B x := by
have Hr : ∀ x ∈ Icc a b, ∀ r > 0, f x ≤ B x + r * (x - a) := fun x hx r hr => by
apply image_le_of_liminf_slope_right_lt_deriv_boundary' hf bound
· rwa [sub_self, mul_zero, add_zero]
· exact hB.add (continuousOn_const.mul (continuousOn_id.sub continuousOn_const))
· intro x hx
exact (hB' x hx).add (((hasDerivWithinAt_id x (Ici x)).sub_const a).const_mul r)
· intro x _ _
rw [mul_one]
exact (lt_add_iff_pos_right _).2 hr
exact hx
intro x hx
have : ContinuousWithinAt (fun r => B x + r * (x - a)) (Ioi 0) 0 :=
continuousWithinAt_const.add (continuousWithinAt_id.mul continuousWithinAt_const)
convert continuousWithinAt_const.closure_le _ this (Hr x hx) using 1 <;> simp
/-- General fencing theorem for continuous functions with an estimate on the derivative.
Let `f` and `B` be continuous functions on `[a, b]` such that
* `f a ≤ B a`;
* `B` has right derivative `B'` at every point of `[a, b)`;
* `f` has right derivative `f'` at every point of `[a, b)`;
* we have `f' x < B' x` whenever `f x = B x`.
Then `f x ≤ B x` everywhere on `[a, b]`. -/
theorem image_le_of_deriv_right_lt_deriv_boundary' {f f' : ℝ → ℝ} {a b : ℝ}
(hf : ContinuousOn f (Icc a b)) (hf' : ∀ x ∈ Ico a b, HasDerivWithinAt f (f' x) (Ici x) x)
{B B' : ℝ → ℝ} (ha : f a ≤ B a) (hB : ContinuousOn B (Icc a b))
(hB' : ∀ x ∈ Ico a b, HasDerivWithinAt B (B' x) (Ici x) x)
(bound : ∀ x ∈ Ico a b, f x = B x → f' x < B' x) : ∀ ⦃x⦄, x ∈ Icc a b → f x ≤ B x :=
image_le_of_liminf_slope_right_lt_deriv_boundary' hf
(fun x hx _ hr => (hf' x hx).liminf_right_slope_le hr) ha hB hB' bound
/-- General fencing theorem for continuous functions with an estimate on the derivative.
Let `f` and `B` be continuous functions on `[a, b]` such that
* `f a ≤ B a`;
* `B` has derivative `B'` everywhere on `ℝ`;
* `f` has right derivative `f'` at every point of `[a, b)`;
* we have `f' x < B' x` whenever `f x = B x`.
Then `f x ≤ B x` everywhere on `[a, b]`. -/
theorem image_le_of_deriv_right_lt_deriv_boundary {f f' : ℝ → ℝ} {a b : ℝ}
(hf : ContinuousOn f (Icc a b)) (hf' : ∀ x ∈ Ico a b, HasDerivWithinAt f (f' x) (Ici x) x)
{B B' : ℝ → ℝ} (ha : f a ≤ B a) (hB : ∀ x, HasDerivAt B (B' x) x)
(bound : ∀ x ∈ Ico a b, f x = B x → f' x < B' x) : ∀ ⦃x⦄, x ∈ Icc a b → f x ≤ B x :=
image_le_of_deriv_right_lt_deriv_boundary' hf hf' ha
(fun x _ => (hB x).continuousAt.continuousWithinAt) (fun x _ => (hB x).hasDerivWithinAt) bound
/-- General fencing theorem for continuous functions with an estimate on the derivative.
Let `f` and `B` be continuous functions on `[a, b]` such that
* `f a ≤ B a`;
* `B` has right derivative `B'` at every point of `[a, b)`;
* `f` has right derivative `f'` at every point of `[a, b)`;
* we have `f' x ≤ B' x` on `[a, b)`.
Then `f x ≤ B x` everywhere on `[a, b]`. -/
theorem image_le_of_deriv_right_le_deriv_boundary {f f' : ℝ → ℝ} {a b : ℝ}
(hf : ContinuousOn f (Icc a b)) (hf' : ∀ x ∈ Ico a b, HasDerivWithinAt f (f' x) (Ici x) x)
{B B' : ℝ → ℝ} (ha : f a ≤ B a) (hB : ContinuousOn B (Icc a b))
(hB' : ∀ x ∈ Ico a b, HasDerivWithinAt B (B' x) (Ici x) x)
(bound : ∀ x ∈ Ico a b, f' x ≤ B' x) : ∀ ⦃x⦄, x ∈ Icc a b → f x ≤ B x :=
image_le_of_liminf_slope_right_le_deriv_boundary hf ha hB hB' fun x hx _ hr =>
(hf' x hx).liminf_right_slope_le (lt_of_le_of_lt (bound x hx) hr)
/-! ### Vector-valued functions `f : ℝ → E` -/
section
variable {f : ℝ → E} {a b : ℝ}
/-- General fencing theorem for continuous functions with an estimate on the derivative.
Let `f` and `B` be continuous functions on `[a, b]` such that
* `‖f a‖ ≤ B a`;
* `B` has right derivative at every point of `[a, b)`;
* for each `x ∈ [a, b)` the right-side limit inferior of `(‖f z‖ - ‖f x‖) / (z - x)`
is bounded above by a function `f'`;
* we have `f' x < B' x` whenever `‖f x‖ = B x`.
Then `‖f x‖ ≤ B x` everywhere on `[a, b]`. -/
theorem image_norm_le_of_liminf_right_slope_norm_lt_deriv_boundary {E : Type*}
[NormedAddCommGroup E] {f : ℝ → E} {f' : ℝ → ℝ} (hf : ContinuousOn f (Icc a b))
-- `hf'` actually says `liminf (‖f z‖ - ‖f x‖) / (z - x) ≤ f' x`
(hf' : ∀ x ∈ Ico a b, ∀ r, f' x < r → ∃ᶠ z in 𝓝[>] x, slope (norm ∘ f) x z < r)
{B B' : ℝ → ℝ} (ha : ‖f a‖ ≤ B a) (hB : ContinuousOn B (Icc a b))
(hB' : ∀ x ∈ Ico a b, HasDerivWithinAt B (B' x) (Ici x) x)
(bound : ∀ x ∈ Ico a b, ‖f x‖ = B x → f' x < B' x) : ∀ ⦃x⦄, x ∈ Icc a b → ‖f x‖ ≤ B x :=
image_le_of_liminf_slope_right_lt_deriv_boundary' (continuous_norm.comp_continuousOn hf) hf' ha hB
hB' bound
/-- General fencing theorem for continuous functions with an estimate on the norm of the derivative.
Let `f` and `B` be continuous functions on `[a, b]` such that
* `‖f a‖ ≤ B a`;
* `f` and `B` have right derivatives `f'` and `B'` respectively at every point of `[a, b)`;
* the norm of `f'` is strictly less than `B'` whenever `‖f x‖ = B x`.
Then `‖f x‖ ≤ B x` everywhere on `[a, b]`. We use one-sided derivatives in the assumptions
to make this theorem work for piecewise differentiable functions.
-/
theorem image_norm_le_of_norm_deriv_right_lt_deriv_boundary' {f' : ℝ → E}
(hf : ContinuousOn f (Icc a b)) (hf' : ∀ x ∈ Ico a b, HasDerivWithinAt f (f' x) (Ici x) x)
{B B' : ℝ → ℝ} (ha : ‖f a‖ ≤ B a) (hB : ContinuousOn B (Icc a b))
(hB' : ∀ x ∈ Ico a b, HasDerivWithinAt B (B' x) (Ici x) x)
(bound : ∀ x ∈ Ico a b, ‖f x‖ = B x → ‖f' x‖ < B' x) : ∀ ⦃x⦄, x ∈ Icc a b → ‖f x‖ ≤ B x :=
image_norm_le_of_liminf_right_slope_norm_lt_deriv_boundary hf
(fun x hx _ hr => (hf' x hx).liminf_right_slope_norm_le hr) ha hB hB' bound
/-- General fencing theorem for continuous functions with an estimate on the norm of the derivative.
Let `f` and `B` be continuous functions on `[a, b]` such that
* `‖f a‖ ≤ B a`;
* `f` has right derivative `f'` at every point of `[a, b)`;
* `B` has derivative `B'` everywhere on `ℝ`;
* the norm of `f'` is strictly less than `B'` whenever `‖f x‖ = B x`.
Then `‖f x‖ ≤ B x` everywhere on `[a, b]`. We use one-sided derivatives in the assumptions
to make this theorem work for piecewise differentiable functions.
-/
theorem image_norm_le_of_norm_deriv_right_lt_deriv_boundary {f' : ℝ → E}
(hf : ContinuousOn f (Icc a b)) (hf' : ∀ x ∈ Ico a b, HasDerivWithinAt f (f' x) (Ici x) x)
{B B' : ℝ → ℝ} (ha : ‖f a‖ ≤ B a) (hB : ∀ x, HasDerivAt B (B' x) x)
(bound : ∀ x ∈ Ico a b, ‖f x‖ = B x → ‖f' x‖ < B' x) : ∀ ⦃x⦄, x ∈ Icc a b → ‖f x‖ ≤ B x :=
image_norm_le_of_norm_deriv_right_lt_deriv_boundary' hf hf' ha
(fun x _ => (hB x).continuousAt.continuousWithinAt) (fun x _ => (hB x).hasDerivWithinAt) bound
/-- General fencing theorem for continuous functions with an estimate on the norm of the derivative.
Let `f` and `B` be continuous functions on `[a, b]` such that
* `‖f a‖ ≤ B a`;
* `f` and `B` have right derivatives `f'` and `B'` respectively at every point of `[a, b)`;
* we have `‖f' x‖ ≤ B x` everywhere on `[a, b)`.
Then `‖f x‖ ≤ B x` everywhere on `[a, b]`. We use one-sided derivatives in the assumptions
to make this theorem work for piecewise differentiable functions.
-/
theorem image_norm_le_of_norm_deriv_right_le_deriv_boundary' {f' : ℝ → E}
(hf : ContinuousOn f (Icc a b)) (hf' : ∀ x ∈ Ico a b, HasDerivWithinAt f (f' x) (Ici x) x)
{B B' : ℝ → ℝ} (ha : ‖f a‖ ≤ B a) (hB : ContinuousOn B (Icc a b))
(hB' : ∀ x ∈ Ico a b, HasDerivWithinAt B (B' x) (Ici x) x)
(bound : ∀ x ∈ Ico a b, ‖f' x‖ ≤ B' x) : ∀ ⦃x⦄, x ∈ Icc a b → ‖f x‖ ≤ B x :=
image_le_of_liminf_slope_right_le_deriv_boundary (continuous_norm.comp_continuousOn hf) ha hB hB'
fun x hx _ hr => (hf' x hx).liminf_right_slope_norm_le ((bound x hx).trans_lt hr)
/-- General fencing theorem for continuous functions with an estimate on the norm of the derivative.
Let `f` and `B` be continuous functions on `[a, b]` such that
* `‖f a‖ ≤ B a`;
* `f` has right derivative `f'` at every point of `[a, b)`;
* `B` has derivative `B'` everywhere on `ℝ`;
* we have `‖f' x‖ ≤ B x` everywhere on `[a, b)`.
Then `‖f x‖ ≤ B x` everywhere on `[a, b]`. We use one-sided derivatives in the assumptions
to make this theorem work for piecewise differentiable functions.
-/
theorem image_norm_le_of_norm_deriv_right_le_deriv_boundary {f' : ℝ → E}
(hf : ContinuousOn f (Icc a b)) (hf' : ∀ x ∈ Ico a b, HasDerivWithinAt f (f' x) (Ici x) x)
{B B' : ℝ → ℝ} (ha : ‖f a‖ ≤ B a) (hB : ∀ x, HasDerivAt B (B' x) x)
(bound : ∀ x ∈ Ico a b, ‖f' x‖ ≤ B' x) : ∀ ⦃x⦄, x ∈ Icc a b → ‖f x‖ ≤ B x :=
image_norm_le_of_norm_deriv_right_le_deriv_boundary' hf hf' ha
(fun x _ => (hB x).continuousAt.continuousWithinAt) (fun x _ => (hB x).hasDerivWithinAt) bound
/-- A function on `[a, b]` with the norm of the right derivative bounded by `C`
satisfies `‖f x - f a‖ ≤ C * (x - a)`. -/
theorem norm_image_sub_le_of_norm_deriv_right_le_segment {f' : ℝ → E} {C : ℝ}
(hf : ContinuousOn f (Icc a b)) (hf' : ∀ x ∈ Ico a b, HasDerivWithinAt f (f' x) (Ici x) x)
(bound : ∀ x ∈ Ico a b, ‖f' x‖ ≤ C) : ∀ x ∈ Icc a b, ‖f x - f a‖ ≤ C * (x - a) := by
let g x := f x - f a
have hg : ContinuousOn g (Icc a b) := hf.sub continuousOn_const
have hg' : ∀ x ∈ Ico a b, HasDerivWithinAt g (f' x) (Ici x) x := by
intro x hx
simp [g, hf' x hx]
let B x := C * (x - a)
have hB : ∀ x, HasDerivAt B C x := by
intro x
simpa using (hasDerivAt_const x C).mul ((hasDerivAt_id x).sub (hasDerivAt_const x a))
convert image_norm_le_of_norm_deriv_right_le_deriv_boundary hg hg' _ hB bound
simp only [g, B]; rw [sub_self, norm_zero, sub_self, mul_zero]
/-- A function on `[a, b]` with the norm of the derivative within `[a, b]`
bounded by `C` satisfies `‖f x - f a‖ ≤ C * (x - a)`, `HasDerivWithinAt`
version. -/
theorem norm_image_sub_le_of_norm_deriv_le_segment' {f' : ℝ → E} {C : ℝ}
(hf : ∀ x ∈ Icc a b, HasDerivWithinAt f (f' x) (Icc a b) x)
(bound : ∀ x ∈ Ico a b, ‖f' x‖ ≤ C) : ∀ x ∈ Icc a b, ‖f x - f a‖ ≤ C * (x - a) := by
refine
norm_image_sub_le_of_norm_deriv_right_le_segment (fun x hx => (hf x hx).continuousWithinAt)
(fun x hx => ?_) bound
exact (hf x <| Ico_subset_Icc_self hx).mono_of_mem_nhdsWithin (Icc_mem_nhdsGE_of_mem hx)
/-- A function on `[a, b]` with the norm of the derivative within `[a, b]`
bounded by `C` satisfies `‖f x - f a‖ ≤ C * (x - a)`, `derivWithin`
version. -/
theorem norm_image_sub_le_of_norm_deriv_le_segment {C : ℝ} (hf : DifferentiableOn ℝ f (Icc a b))
(bound : ∀ x ∈ Ico a b, ‖derivWithin f (Icc a b) x‖ ≤ C) :
∀ x ∈ Icc a b, ‖f x - f a‖ ≤ C * (x - a) := by
refine norm_image_sub_le_of_norm_deriv_le_segment' ?_ bound
exact fun x hx => (hf x hx).hasDerivWithinAt
/-- A function on `[0, 1]` with the norm of the derivative within `[0, 1]`
bounded by `C` satisfies `‖f 1 - f 0‖ ≤ C`, `HasDerivWithinAt`
version. -/
theorem norm_image_sub_le_of_norm_deriv_le_segment_01' {f' : ℝ → E} {C : ℝ}
(hf : ∀ x ∈ Icc (0 : ℝ) 1, HasDerivWithinAt f (f' x) (Icc (0 : ℝ) 1) x)
(bound : ∀ x ∈ Ico (0 : ℝ) 1, ‖f' x‖ ≤ C) : ‖f 1 - f 0‖ ≤ C := by
simpa only [sub_zero, mul_one] using
norm_image_sub_le_of_norm_deriv_le_segment' hf bound 1 (right_mem_Icc.2 zero_le_one)
/-- A function on `[0, 1]` with the norm of the derivative within `[0, 1]`
bounded by `C` satisfies `‖f 1 - f 0‖ ≤ C`, `derivWithin` version. -/
theorem norm_image_sub_le_of_norm_deriv_le_segment_01 {C : ℝ}
(hf : DifferentiableOn ℝ f (Icc (0 : ℝ) 1))
(bound : ∀ x ∈ Ico (0 : ℝ) 1, ‖derivWithin f (Icc (0 : ℝ) 1) x‖ ≤ C) : ‖f 1 - f 0‖ ≤ C := by
simpa only [sub_zero, mul_one] using
norm_image_sub_le_of_norm_deriv_le_segment hf bound 1 (right_mem_Icc.2 zero_le_one)
theorem constant_of_has_deriv_right_zero (hcont : ContinuousOn f (Icc a b))
(hderiv : ∀ x ∈ Ico a b, HasDerivWithinAt f 0 (Ici x) x) : ∀ x ∈ Icc a b, f x = f a := by
have : ∀ x ∈ Icc a b, ‖f x - f a‖ ≤ 0 * (x - a) := fun x hx =>
norm_image_sub_le_of_norm_deriv_right_le_segment hcont hderiv (fun _ _ => norm_zero.le) x hx
simpa only [zero_mul, norm_le_zero_iff, sub_eq_zero] using this
theorem constant_of_derivWithin_zero (hdiff : DifferentiableOn ℝ f (Icc a b))
(hderiv : ∀ x ∈ Ico a b, derivWithin f (Icc a b) x = 0) : ∀ x ∈ Icc a b, f x = f a := by
have H : ∀ x ∈ Ico a b, ‖derivWithin f (Icc a b) x‖ ≤ 0 := by
simpa only [norm_le_zero_iff] using fun x hx => hderiv x hx
simpa only [zero_mul, norm_le_zero_iff, sub_eq_zero] using fun x hx =>
norm_image_sub_le_of_norm_deriv_le_segment hdiff H x hx
variable {f' g : ℝ → E}
/-- If two continuous functions on `[a, b]` have the same right derivative and are equal at `a`,
then they are equal everywhere on `[a, b]`. -/
theorem eq_of_has_deriv_right_eq (derivf : ∀ x ∈ Ico a b, HasDerivWithinAt f (f' x) (Ici x) x)
(derivg : ∀ x ∈ Ico a b, HasDerivWithinAt g (f' x) (Ici x) x) (fcont : ContinuousOn f (Icc a b))
(gcont : ContinuousOn g (Icc a b)) (hi : f a = g a) : ∀ y ∈ Icc a b, f y = g y := by
simp only [← @sub_eq_zero _ _ (f _)] at hi ⊢
exact hi ▸ constant_of_has_deriv_right_zero (fcont.sub gcont) fun y hy => by
simpa only [sub_self] using (derivf y hy).sub (derivg y hy)
/-- If two differentiable functions on `[a, b]` have the same derivative within `[a, b]` everywhere
on `[a, b)` and are equal at `a`, then they are equal everywhere on `[a, b]`. -/
theorem eq_of_derivWithin_eq (fdiff : DifferentiableOn ℝ f (Icc a b))
(gdiff : DifferentiableOn ℝ g (Icc a b))
(hderiv : EqOn (derivWithin f (Icc a b)) (derivWithin g (Icc a b)) (Ico a b)) (hi : f a = g a) :
∀ y ∈ Icc a b, f y = g y := by
have A : ∀ y ∈ Ico a b, HasDerivWithinAt f (derivWithin f (Icc a b) y) (Ici y) y := fun y hy =>
(fdiff y (mem_Icc_of_Ico hy)).hasDerivWithinAt.mono_of_mem_nhdsWithin
(Icc_mem_nhdsGE_of_mem hy)
have B : ∀ y ∈ Ico a b, HasDerivWithinAt g (derivWithin g (Icc a b) y) (Ici y) y := fun y hy =>
(gdiff y (mem_Icc_of_Ico hy)).hasDerivWithinAt.mono_of_mem_nhdsWithin
(Icc_mem_nhdsGE_of_mem hy)
exact eq_of_has_deriv_right_eq A (fun y hy => (hderiv hy).symm ▸ B y hy) fdiff.continuousOn
gdiff.continuousOn hi
end
/-!
### Vector-valued functions `f : E → G`
Theorems in this section work both for real and complex differentiable functions. We use assumptions
`[NontriviallyNormedField 𝕜] [IsRCLikeNormedField 𝕜] [NormedSpace 𝕜 E] [NormedSpace 𝕜 G]` to
achieve this result. For the domain `E` we also assume `[NormedSpace ℝ E]` to have a notion
of a `Convex` set. -/
section
namespace Convex
variable {𝕜 G : Type*} [NontriviallyNormedField 𝕜] [IsRCLikeNormedField 𝕜]
[NormedSpace 𝕜 E] [NormedAddCommGroup G] [NormedSpace 𝕜 G]
{f g : E → G} {C : ℝ} {s : Set E} {x y : E} {f' g' : E → E →L[𝕜] G} {φ : E →L[𝕜] G}
instance (priority := 100) : PathConnectedSpace 𝕜 := by
letI : RCLike 𝕜 := IsRCLikeNormedField.rclike 𝕜
infer_instance
/-- The mean value theorem on a convex set: if the derivative of a function is bounded by `C`, then
the function is `C`-Lipschitz. Version with `HasFDerivWithinAt`. -/
theorem norm_image_sub_le_of_norm_hasFDerivWithin_le
(hf : ∀ x ∈ s, HasFDerivWithinAt f (f' x) s x) (bound : ∀ x ∈ s, ‖f' x‖ ≤ C) (hs : Convex ℝ s)
(xs : x ∈ s) (ys : y ∈ s) : ‖f y - f x‖ ≤ C * ‖y - x‖ := by
letI : RCLike 𝕜 := IsRCLikeNormedField.rclike 𝕜
letI : NormedSpace ℝ G := RestrictScalars.normedSpace ℝ 𝕜 G
/- By composition with `AffineMap.lineMap x y`, we reduce to a statement for functions defined
on `[0,1]`, for which it is proved in `norm_image_sub_le_of_norm_deriv_le_segment`.
We just have to check the differentiability of the composition and bounds on its derivative,
which is straightforward but tedious for lack of automation. -/
set g := (AffineMap.lineMap x y : ℝ → E)
have segm : MapsTo g (Icc 0 1 : Set ℝ) s := hs.mapsTo_lineMap xs ys
have hD : ∀ t ∈ Icc (0 : ℝ) 1,
HasDerivWithinAt (f ∘ g) (f' (g t) (y - x)) (Icc 0 1) t := fun t ht => by
simpa using ((hf (g t) (segm ht)).restrictScalars ℝ).comp_hasDerivWithinAt _
AffineMap.hasDerivWithinAt_lineMap segm
have bound : ∀ t ∈ Ico (0 : ℝ) 1, ‖f' (g t) (y - x)‖ ≤ C * ‖y - x‖ := fun t ht =>
le_of_opNorm_le _ (bound _ <| segm <| Ico_subset_Icc_self ht) _
simpa [g] using norm_image_sub_le_of_norm_deriv_le_segment_01' hD bound
/-- The mean value theorem on a convex set: if the derivative of a function is bounded by `C` on
`s`, then the function is `C`-Lipschitz on `s`. Version with `HasFDerivWithinAt` and
`LipschitzOnWith`. -/
theorem lipschitzOnWith_of_nnnorm_hasFDerivWithin_le {C : ℝ≥0}
(hf : ∀ x ∈ s, HasFDerivWithinAt f (f' x) s x) (bound : ∀ x ∈ s, ‖f' x‖₊ ≤ C)
(hs : Convex ℝ s) : LipschitzOnWith C f s := by
rw [lipschitzOnWith_iff_norm_sub_le]
intro x x_in y y_in
exact hs.norm_image_sub_le_of_norm_hasFDerivWithin_le hf bound y_in x_in
/-- Let `s` be a convex set in a real normed vector space `E`, let `f : E → G` be a function
differentiable within `s` in a neighborhood of `x : E` with derivative `f'`. Suppose that `f'` is
continuous within `s` at `x`. Then for any number `K : ℝ≥0` larger than `‖f' x‖₊`, `f` is
`K`-Lipschitz on some neighborhood of `x` within `s`. See also
`Convex.exists_nhdsWithin_lipschitzOnWith_of_hasFDerivWithinAt` for a version that claims
existence of `K` instead of an explicit estimate. -/
theorem exists_nhdsWithin_lipschitzOnWith_of_hasFDerivWithinAt_of_nnnorm_lt (hs : Convex ℝ s)
{f : E → G} (hder : ∀ᶠ y in 𝓝[s] x, HasFDerivWithinAt f (f' y) s y)
(hcont : ContinuousWithinAt f' s x) (K : ℝ≥0) (hK : ‖f' x‖₊ < K) :
∃ t ∈ 𝓝[s] x, LipschitzOnWith K f t := by
obtain ⟨ε, ε0, hε⟩ : ∃ ε > 0,
ball x ε ∩ s ⊆ { y | HasFDerivWithinAt f (f' y) s y ∧ ‖f' y‖₊ < K } :=
mem_nhdsWithin_iff.1 (hder.and <| hcont.nnnorm.eventually (gt_mem_nhds hK))
rw [inter_comm] at hε
refine ⟨s ∩ ball x ε, inter_mem_nhdsWithin _ (ball_mem_nhds _ ε0), ?_⟩
exact
(hs.inter (convex_ball _ _)).lipschitzOnWith_of_nnnorm_hasFDerivWithin_le
(fun y hy => (hε hy).1.mono inter_subset_left) fun y hy => (hε hy).2.le
/-- Let `s` be a convex set in a real normed vector space `E`, let `f : E → G` be a function
differentiable within `s` in a neighborhood of `x : E` with derivative `f'`. Suppose that `f'` is
continuous within `s` at `x`. Then for any number `K : ℝ≥0` larger than `‖f' x‖₊`, `f` is Lipschitz
on some neighborhood of `x` within `s`. See also
`Convex.exists_nhdsWithin_lipschitzOnWith_of_hasFDerivWithinAt_of_nnnorm_lt` for a version
with an explicit estimate on the Lipschitz constant. -/
theorem exists_nhdsWithin_lipschitzOnWith_of_hasFDerivWithinAt (hs : Convex ℝ s) {f : E → G}
(hder : ∀ᶠ y in 𝓝[s] x, HasFDerivWithinAt f (f' y) s y) (hcont : ContinuousWithinAt f' s x) :
∃ K, ∃ t ∈ 𝓝[s] x, LipschitzOnWith K f t :=
(exists_gt _).imp <|
hs.exists_nhdsWithin_lipschitzOnWith_of_hasFDerivWithinAt_of_nnnorm_lt hder hcont
/-- The mean value theorem on a convex set: if the derivative of a function within this set is
bounded by `C`, then the function is `C`-Lipschitz. Version with `fderivWithin`. -/
theorem norm_image_sub_le_of_norm_fderivWithin_le (hf : DifferentiableOn 𝕜 f s)
(bound : ∀ x ∈ s, ‖fderivWithin 𝕜 f s x‖ ≤ C) (hs : Convex ℝ s) (xs : x ∈ s) (ys : y ∈ s) :
‖f y - f x‖ ≤ C * ‖y - x‖ :=
hs.norm_image_sub_le_of_norm_hasFDerivWithin_le (fun x hx => (hf x hx).hasFDerivWithinAt) bound
xs ys
/-- The mean value theorem on a convex set: if the derivative of a function is bounded by `C` on
`s`, then the function is `C`-Lipschitz on `s`. Version with `fderivWithin` and
`LipschitzOnWith`. -/
theorem lipschitzOnWith_of_nnnorm_fderivWithin_le {C : ℝ≥0} (hf : DifferentiableOn 𝕜 f s)
(bound : ∀ x ∈ s, ‖fderivWithin 𝕜 f s x‖₊ ≤ C) (hs : Convex ℝ s) : LipschitzOnWith C f s :=
hs.lipschitzOnWith_of_nnnorm_hasFDerivWithin_le (fun x hx => (hf x hx).hasFDerivWithinAt) bound
/-- The mean value theorem on a convex set: if the derivative of a function is bounded by `C`,
then the function is `C`-Lipschitz. Version with `fderiv`. -/
theorem norm_image_sub_le_of_norm_fderiv_le (hf : ∀ x ∈ s, DifferentiableAt 𝕜 f x)
(bound : ∀ x ∈ s, ‖fderiv 𝕜 f x‖ ≤ C) (hs : Convex ℝ s) (xs : x ∈ s) (ys : y ∈ s) :
‖f y - f x‖ ≤ C * ‖y - x‖ :=
hs.norm_image_sub_le_of_norm_hasFDerivWithin_le
(fun x hx => (hf x hx).hasFDerivAt.hasFDerivWithinAt) bound xs ys
/-- The mean value theorem on a convex set: if the derivative of a function is bounded by `C` on
`s`, then the function is `C`-Lipschitz on `s`. Version with `fderiv` and `LipschitzOnWith`. -/
theorem lipschitzOnWith_of_nnnorm_fderiv_le {C : ℝ≥0} (hf : ∀ x ∈ s, DifferentiableAt 𝕜 f x)
(bound : ∀ x ∈ s, ‖fderiv 𝕜 f x‖₊ ≤ C) (hs : Convex ℝ s) : LipschitzOnWith C f s :=
hs.lipschitzOnWith_of_nnnorm_hasFDerivWithin_le
(fun x hx => (hf x hx).hasFDerivAt.hasFDerivWithinAt) bound
/-- The mean value theorem: if the derivative of a function is bounded by `C`, then the function is
`C`-Lipschitz. Version with `fderiv` and `LipschitzWith`. -/
theorem _root_.lipschitzWith_of_nnnorm_fderiv_le
{E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E] {f : E → G}
{C : ℝ≥0} (hf : Differentiable 𝕜 f)
(bound : ∀ x, ‖fderiv 𝕜 f x‖₊ ≤ C) : LipschitzWith C f := by
letI : RCLike 𝕜 := IsRCLikeNormedField.rclike 𝕜
let A : NormedSpace ℝ E := RestrictScalars.normedSpace ℝ 𝕜 E
rw [← lipschitzOnWith_univ]
exact lipschitzOnWith_of_nnnorm_fderiv_le (fun x _ ↦ hf x) (fun x _ ↦ bound x) convex_univ
/-- Variant of the mean value inequality on a convex set, using a bound on the difference between
the derivative and a fixed linear map, rather than a bound on the derivative itself. Version with
`HasFDerivWithinAt`. -/
theorem norm_image_sub_le_of_norm_hasFDerivWithin_le'
(hf : ∀ x ∈ s, HasFDerivWithinAt f (f' x) s x) (bound : ∀ x ∈ s, ‖f' x - φ‖ ≤ C)
(hs : Convex ℝ s) (xs : x ∈ s) (ys : y ∈ s) : ‖f y - f x - φ (y - x)‖ ≤ C * ‖y - x‖ := by
/- We subtract `φ` to define a new function `g` for which `g' = 0`, for which the previous theorem
applies, `Convex.norm_image_sub_le_of_norm_hasFDerivWithin_le`. Then, we just need to glue
together the pieces, expressing back `f` in terms of `g`. -/
let g y := f y - φ y
have hg : ∀ x ∈ s, HasFDerivWithinAt g (f' x - φ) s x := fun x xs =>
(hf x xs).sub φ.hasFDerivWithinAt
calc
‖f y - f x - φ (y - x)‖ = ‖f y - f x - (φ y - φ x)‖ := by simp
_ = ‖f y - φ y - (f x - φ x)‖ := by congr 1; abel
_ = ‖g y - g x‖ := by simp [g]
_ ≤ C * ‖y - x‖ := Convex.norm_image_sub_le_of_norm_hasFDerivWithin_le hg bound hs xs ys
/-- Variant of the mean value inequality on a convex set. Version with `fderivWithin`. -/
theorem norm_image_sub_le_of_norm_fderivWithin_le' (hf : DifferentiableOn 𝕜 f s)
(bound : ∀ x ∈ s, ‖fderivWithin 𝕜 f s x - φ‖ ≤ C) (hs : Convex ℝ s) (xs : x ∈ s) (ys : y ∈ s) :
‖f y - f x - φ (y - x)‖ ≤ C * ‖y - x‖ :=
hs.norm_image_sub_le_of_norm_hasFDerivWithin_le' (fun x hx => (hf x hx).hasFDerivWithinAt) bound
xs ys
/-- Variant of the mean value inequality on a convex set. Version with `fderiv`. -/
theorem norm_image_sub_le_of_norm_fderiv_le' (hf : ∀ x ∈ s, DifferentiableAt 𝕜 f x)
(bound : ∀ x ∈ s, ‖fderiv 𝕜 f x - φ‖ ≤ C) (hs : Convex ℝ s) (xs : x ∈ s) (ys : y ∈ s) :
‖f y - f x - φ (y - x)‖ ≤ C * ‖y - x‖ :=
hs.norm_image_sub_le_of_norm_hasFDerivWithin_le'
(fun x hx => (hf x hx).hasFDerivAt.hasFDerivWithinAt) bound xs ys
/-- If a function has zero Fréchet derivative at every point of a convex set,
then it is a constant on this set. -/
theorem is_const_of_fderivWithin_eq_zero (hs : Convex ℝ s) (hf : DifferentiableOn 𝕜 f s)
(hf' : ∀ x ∈ s, fderivWithin 𝕜 f s x = 0) (hx : x ∈ s) (hy : y ∈ s) : f x = f y := by
have bound : ∀ x ∈ s, ‖fderivWithin 𝕜 f s x‖ ≤ 0 := fun x hx => by
simp only [hf' x hx, norm_zero, le_rfl]
simpa only [(dist_eq_norm _ _).symm, zero_mul, dist_le_zero, eq_comm] using
hs.norm_image_sub_le_of_norm_fderivWithin_le hf bound hx hy
theorem _root_.is_const_of_fderiv_eq_zero
{E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E] {f : E → G}
(hf : Differentiable 𝕜 f) (hf' : ∀ x, fderiv 𝕜 f x = 0)
(x y : E) : f x = f y := by
letI : RCLike 𝕜 := IsRCLikeNormedField.rclike 𝕜
let A : NormedSpace ℝ E := RestrictScalars.normedSpace ℝ 𝕜 E
exact convex_univ.is_const_of_fderivWithin_eq_zero hf.differentiableOn
(fun x _ => by rw [fderivWithin_univ]; exact hf' x) trivial trivial
/-- If two functions have equal Fréchet derivatives at every point of a convex set, and are equal at
one point in that set, then they are equal on that set. -/
theorem eqOn_of_fderivWithin_eq (hs : Convex ℝ s) (hf : DifferentiableOn 𝕜 f s)
(hg : DifferentiableOn 𝕜 g s) (hs' : UniqueDiffOn 𝕜 s)
(hf' : s.EqOn (fderivWithin 𝕜 f s) (fderivWithin 𝕜 g s)) (hx : x ∈ s) (hfgx : f x = g x) :
s.EqOn f g := fun y hy => by
suffices f x - g x = f y - g y by rwa [hfgx, sub_self, eq_comm, sub_eq_zero] at this
refine hs.is_const_of_fderivWithin_eq_zero (hf.sub hg) (fun z hz => ?_) hx hy
rw [fderivWithin_sub (hs' _ hz) (hf _ hz) (hg _ hz), sub_eq_zero, hf' hz]
/-- If `f` has zero derivative on an open set, then `f` is locally constant on `s`. -/
-- TODO: change the spelling once we have `IsLocallyConstantOn`.
theorem _root_.IsOpen.isOpen_inter_preimage_of_fderiv_eq_zero
(hs : IsOpen s) (hf : DifferentiableOn 𝕜 f s)
(hf' : s.EqOn (fderiv 𝕜 f) 0) (t : Set G) : IsOpen (s ∩ f ⁻¹' t) := by
refine Metric.isOpen_iff.mpr fun y ⟨hy, hy'⟩ ↦ ?_
obtain ⟨r, hr, h⟩ := Metric.isOpen_iff.mp hs y hy
refine ⟨r, hr, Set.subset_inter h fun x hx ↦ ?_⟩
have := (convex_ball y r).is_const_of_fderivWithin_eq_zero (hf.mono h) ?_ hx (mem_ball_self hr)
· simpa [this]
· intro z hz
simpa only [fderivWithin_of_isOpen Metric.isOpen_ball hz] using hf' (h hz)
theorem _root_.isLocallyConstant_of_fderiv_eq_zero (h₁ : Differentiable 𝕜 f)
(h₂ : ∀ x, fderiv 𝕜 f x = 0) : IsLocallyConstant f := by
simpa using isOpen_univ.isOpen_inter_preimage_of_fderiv_eq_zero h₁.differentiableOn fun _ _ ↦ h₂ _
/-- If `f` has zero derivative on a connected open set, then `f` is constant on `s`. -/
theorem _root_.IsOpen.exists_is_const_of_fderiv_eq_zero
(hs : IsOpen s) (hs' : IsPreconnected s) (hf : DifferentiableOn 𝕜 f s)
(hf' : s.EqOn (fderiv 𝕜 f) 0) : ∃ a, ∀ x ∈ s, f x = a := by
obtain (rfl | ⟨y, hy⟩) := s.eq_empty_or_nonempty
· exact ⟨0, by simp⟩
· refine ⟨f y, fun x hx ↦ ?_⟩
have h₁ := hs.isOpen_inter_preimage_of_fderiv_eq_zero hf hf' {f y}
have h₂ := hf.continuousOn.comp_continuous continuous_subtype_val (fun x ↦ x.2)
by_contra h₃
obtain ⟨t, ht, ht'⟩ := (isClosed_singleton (x := f y)).preimage h₂
have ht'' : ∀ a ∈ s, a ∈ t ↔ f a ≠ f y := by simpa [Set.ext_iff] using ht'
obtain ⟨z, H₁, H₂, H₃⟩ := hs' _ _ h₁ ht (fun x h ↦ by simp [h, ht'', eq_or_ne]) ⟨y, by simpa⟩
⟨x, by simp [ht'' _ hx, hx, h₃]⟩
exact (ht'' _ H₁).mp H₃ H₂.2
theorem _root_.IsOpen.is_const_of_fderiv_eq_zero
(hs : IsOpen s) (hs' : IsPreconnected s) (hf : DifferentiableOn 𝕜 f s)
(hf' : s.EqOn (fderiv 𝕜 f) 0) {x y : E} (hx : x ∈ s) (hy : y ∈ s) : f x = f y := by
obtain ⟨a, ha⟩ := hs.exists_is_const_of_fderiv_eq_zero hs' hf hf'
rw [ha x hx, ha y hy]
theorem _root_.IsOpen.exists_eq_add_of_fderiv_eq (hs : IsOpen s) (hs' : IsPreconnected s)
(hf : DifferentiableOn 𝕜 f s) (hg : DifferentiableOn 𝕜 g s)
(hf' : s.EqOn (fderiv 𝕜 f) (fderiv 𝕜 g)) : ∃ a, s.EqOn f (g · + a) := by
simp_rw [Set.EqOn, ← sub_eq_iff_eq_add']
refine hs.exists_is_const_of_fderiv_eq_zero hs' (hf.sub hg) fun x hx ↦ ?_
rw [fderiv_fun_sub (hf.differentiableAt (hs.mem_nhds hx)) (hg.differentiableAt (hs.mem_nhds hx)),
hf' hx, sub_self, Pi.zero_apply]
/-- If two functions have equal Fréchet derivatives at every point of a connected open set,
and are equal at one point in that set, then they are equal on that set. -/
theorem _root_.IsOpen.eqOn_of_fderiv_eq (hs : IsOpen s) (hs' : IsPreconnected s)
(hf : DifferentiableOn 𝕜 f s) (hg : DifferentiableOn 𝕜 g s)
(hf' : ∀ x ∈ s, fderiv 𝕜 f x = fderiv 𝕜 g x) (hx : x ∈ s) (hfgx : f x = g x) :
s.EqOn f g := by
obtain ⟨a, ha⟩ := hs.exists_eq_add_of_fderiv_eq hs' hf hg hf'
obtain rfl := left_eq_add.mp (hfgx.symm.trans (ha hx))
simpa using ha
theorem _root_.eq_of_fderiv_eq
{E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E] {f g : E → G}
(hf : Differentiable 𝕜 f) (hg : Differentiable 𝕜 g)
(hf' : ∀ x, fderiv 𝕜 f x = fderiv 𝕜 g x) (x : E) (hfgx : f x = g x) : f = g := by
letI : RCLike 𝕜 := IsRCLikeNormedField.rclike 𝕜
let A : NormedSpace ℝ E := RestrictScalars.normedSpace ℝ 𝕜 E
suffices Set.univ.EqOn f g from funext fun x => this <| mem_univ x
exact convex_univ.eqOn_of_fderivWithin_eq hf.differentiableOn hg.differentiableOn
uniqueDiffOn_univ (fun x _ => by simpa using hf' _) (mem_univ _) hfgx
lemma isLittleO_pow_succ {x₀ : E} {n : ℕ} (hs : Convex ℝ s) (hx₀s : x₀ ∈ s)
(hff' : ∀ x ∈ s, HasFDerivWithinAt f (f' x) s x) (hf' : f' =o[𝓝[s] x₀] fun x ↦ ‖x - x₀‖ ^ n) :
(fun x ↦ f x - f x₀) =o[𝓝[s] x₀] fun x ↦ ‖x - x₀‖ ^ (n + 1) := by
rw [Asymptotics.isLittleO_iff] at hf' ⊢
intro c hc
simp_rw [norm_pow, pow_succ, ← mul_assoc, norm_norm]
simp_rw [norm_pow, norm_norm] at hf'
have : ∀ᶠ x in 𝓝[s] x₀, segment ℝ x₀ x ⊆ s ∧ ∀ y ∈ segment ℝ x₀ x, ‖f' y‖ ≤ c * ‖x - x₀‖ ^ n := by
have h1 : ∀ᶠ x in 𝓝[s] x₀, x ∈ s := eventually_mem_nhdsWithin
filter_upwards [h1, hs.eventually_nhdsWithin_segment hx₀s (hf' hc)] with x hxs h
refine ⟨hs.segment_subset hx₀s hxs, fun y hy ↦ (h y hy).trans ?_⟩
gcongr
exact norm_sub_le_of_mem_segment hy
filter_upwards [this] with x ⟨h_segment, h⟩
convert (convex_segment x₀ x).norm_image_sub_le_of_norm_hasFDerivWithin_le
(f := fun x ↦ f x - f x₀) (y := x) (x := x₀) (s := segment ℝ x₀ x) ?_ h
(left_mem_segment ℝ x₀ x) (right_mem_segment ℝ x₀ x) using 1
· simp
· simp only [hasFDerivWithinAt_sub_const_iff]
exact fun x hx ↦ (hff' x (h_segment hx)).mono h_segment
theorem isLittleO_pow_succ_real {f f' : ℝ → E} {x₀ : ℝ} {n : ℕ} {s : Set ℝ}
(hs : Convex ℝ s) (hx₀s : x₀ ∈ s)
(hff' : ∀ x ∈ s, HasDerivWithinAt f (f' x) s x) (hf' : f' =o[𝓝[s] x₀] fun x ↦ (x - x₀) ^ n) :
(fun x ↦ f x - f x₀) =o[𝓝[s] x₀] fun x ↦ (x - x₀) ^ (n + 1) := by
have h := hs.isLittleO_pow_succ hx₀s hff' ?_ (n := n)
· rw [Asymptotics.isLittleO_iff] at h ⊢
simpa using h
· rw [Asymptotics.isLittleO_iff] at hf' ⊢
convert hf' using 4 with c hc x
simp
end Convex
namespace Convex
variable {𝕜 G : Type*} [RCLike 𝕜] [NormedAddCommGroup G] [NormedSpace 𝕜 G]
{f f' : 𝕜 → G} {s : Set 𝕜} {x y : 𝕜}
/-- The mean value theorem on a convex set in dimension 1: if the derivative of a function is
bounded by `C`, then the function is `C`-Lipschitz. Version with `HasDerivWithinAt`. -/
theorem norm_image_sub_le_of_norm_hasDerivWithin_le {C : ℝ}
(hf : ∀ x ∈ s, HasDerivWithinAt f (f' x) s x) (bound : ∀ x ∈ s, ‖f' x‖ ≤ C) (hs : Convex ℝ s)
(xs : x ∈ s) (ys : y ∈ s) : ‖f y - f x‖ ≤ C * ‖y - x‖ :=
Convex.norm_image_sub_le_of_norm_hasFDerivWithin_le (fun x hx => (hf x hx).hasFDerivWithinAt)
(fun x hx => le_trans (by simp) (bound x hx)) hs xs ys
/-- The mean value theorem on a convex set in dimension 1: if the derivative of a function is
bounded by `C` on `s`, then the function is `C`-Lipschitz on `s`.
Version with `HasDerivWithinAt` and `LipschitzOnWith`. -/
theorem lipschitzOnWith_of_nnnorm_hasDerivWithin_le {C : ℝ≥0} (hs : Convex ℝ s)
(hf : ∀ x ∈ s, HasDerivWithinAt f (f' x) s x) (bound : ∀ x ∈ s, ‖f' x‖₊ ≤ C) :
LipschitzOnWith C f s :=
Convex.lipschitzOnWith_of_nnnorm_hasFDerivWithin_le (fun x hx => (hf x hx).hasFDerivWithinAt)
(fun x hx => le_trans (by simp) (bound x hx)) hs
/-- The mean value theorem on a convex set in dimension 1: if the derivative of a function within
this set is bounded by `C`, then the function is `C`-Lipschitz. Version with `derivWithin` -/
theorem norm_image_sub_le_of_norm_derivWithin_le {C : ℝ} (hf : DifferentiableOn 𝕜 f s)
(bound : ∀ x ∈ s, ‖derivWithin f s x‖ ≤ C) (hs : Convex ℝ s) (xs : x ∈ s) (ys : y ∈ s) :
‖f y - f x‖ ≤ C * ‖y - x‖ :=
hs.norm_image_sub_le_of_norm_hasDerivWithin_le (fun x hx => (hf x hx).hasDerivWithinAt) bound xs
ys
/-- The mean value theorem on a convex set in dimension 1: if the derivative of a function is
bounded by `C` on `s`, then the function is `C`-Lipschitz on `s`.
Version with `derivWithin` and `LipschitzOnWith`. -/
theorem lipschitzOnWith_of_nnnorm_derivWithin_le {C : ℝ≥0} (hs : Convex ℝ s)
(hf : DifferentiableOn 𝕜 f s) (bound : ∀ x ∈ s, ‖derivWithin f s x‖₊ ≤ C) :
LipschitzOnWith C f s :=
hs.lipschitzOnWith_of_nnnorm_hasDerivWithin_le (fun x hx => (hf x hx).hasDerivWithinAt) bound
/-- The mean value theorem on a convex set in dimension 1: if the derivative of a function is
bounded by `C`, then the function is `C`-Lipschitz. Version with `deriv`. -/
theorem norm_image_sub_le_of_norm_deriv_le {C : ℝ} (hf : ∀ x ∈ s, DifferentiableAt 𝕜 f x)
(bound : ∀ x ∈ s, ‖deriv f x‖ ≤ C) (hs : Convex ℝ s) (xs : x ∈ s) (ys : y ∈ s) :
‖f y - f x‖ ≤ C * ‖y - x‖ :=
hs.norm_image_sub_le_of_norm_hasDerivWithin_le
(fun x hx => (hf x hx).hasDerivAt.hasDerivWithinAt) bound xs ys
/-- The mean value theorem on a convex set in dimension 1: if the derivative of a function is
bounded by `C` on `s`, then the function is `C`-Lipschitz on `s`.
Version with `deriv` and `LipschitzOnWith`. -/
theorem lipschitzOnWith_of_nnnorm_deriv_le {C : ℝ≥0} (hf : ∀ x ∈ s, DifferentiableAt 𝕜 f x)
(bound : ∀ x ∈ s, ‖deriv f x‖₊ ≤ C) (hs : Convex ℝ s) : LipschitzOnWith C f s :=
hs.lipschitzOnWith_of_nnnorm_hasDerivWithin_le
(fun x hx => (hf x hx).hasDerivAt.hasDerivWithinAt) bound
/-- The mean value theorem set in dimension 1: if the derivative of a function is bounded by `C`,
then the function is `C`-Lipschitz. Version with `deriv` and `LipschitzWith`. -/
theorem _root_.lipschitzWith_of_nnnorm_deriv_le {C : ℝ≥0} (hf : Differentiable 𝕜 f)
(bound : ∀ x, ‖deriv f x‖₊ ≤ C) : LipschitzWith C f :=
lipschitzOnWith_univ.1 <|
convex_univ.lipschitzOnWith_of_nnnorm_deriv_le (fun x _ => hf x) fun x _ => bound x
/-- If `f : 𝕜 → G`, `𝕜 = R` or `𝕜 = ℂ`, is differentiable everywhere and its derivative equal zero,
then it is a constant function. -/
theorem _root_.is_const_of_deriv_eq_zero (hf : Differentiable 𝕜 f) (hf' : ∀ x, deriv f x = 0)
(x y : 𝕜) : f x = f y :=
is_const_of_fderiv_eq_zero hf (fun z => by ext; simp [← deriv_fderiv, hf']) _ _
theorem _root_.IsOpen.isOpen_inter_preimage_of_deriv_eq_zero
(hs : IsOpen s) (hf : DifferentiableOn 𝕜 f s)
(hf' : s.EqOn (deriv f) 0) (t : Set G) : IsOpen (s ∩ f ⁻¹' t) :=
hs.isOpen_inter_preimage_of_fderiv_eq_zero hf
(fun x hx ↦ by ext; simp [← deriv_fderiv, hf' hx]) t
theorem _root_.IsOpen.exists_is_const_of_deriv_eq_zero
(hs : IsOpen s) (hs' : IsPreconnected s) (hf : DifferentiableOn 𝕜 f s)
(hf' : s.EqOn (deriv f) 0) : ∃ a, ∀ x ∈ s, f x = a :=
hs.exists_is_const_of_fderiv_eq_zero hs' hf (fun {x} hx ↦ by ext; simp [← deriv_fderiv, hf' hx])
theorem _root_.IsOpen.is_const_of_deriv_eq_zero
(hs : IsOpen s) (hs' : IsPreconnected s) (hf : DifferentiableOn 𝕜 f s)
(hf' : s.EqOn (deriv f) 0) {x y : 𝕜} (hx : x ∈ s) (hy : y ∈ s) : f x = f y :=
hs.is_const_of_fderiv_eq_zero hs' hf (fun a ha ↦ by ext; simp [← deriv_fderiv, hf' ha]) hx hy
theorem _root_.IsOpen.exists_eq_add_of_deriv_eq {f g : 𝕜 → G} (hs : IsOpen s)
(hs' : IsPreconnected s)
(hf : DifferentiableOn 𝕜 f s) (hg : DifferentiableOn 𝕜 g s)
(hf' : s.EqOn (deriv f) (deriv g)) : ∃ a, s.EqOn f (g · + a) :=
hs.exists_eq_add_of_fderiv_eq hs' hf hg (fun x hx ↦ by simp [← deriv_fderiv, hf' hx])
theorem _root_.IsOpen.eqOn_of_deriv_eq {f g : 𝕜 → G} (hs : IsOpen s)
(hs' : IsPreconnected s) (hf : DifferentiableOn 𝕜 f s) (hg : DifferentiableOn 𝕜 g s)
(hf' : s.EqOn (deriv f) (deriv g)) (hx : x ∈ s) (hfgx : f x = g x) :
s.EqOn f g :=
hs.eqOn_of_fderiv_eq hs' hf hg (fun _ hx ↦ ContinuousLinearMap.ext_ring (hf' hx)) hx hfgx
end Convex
end
section RCLike
/-!
### Vector-valued functions `f : E → F`. Strict differentiability.
A `C^1` function is strictly differentiable, when the field is `ℝ` or `ℂ`. This follows from the
mean value inequality on balls, which is a particular case of the above results after restricting
the scalars to `ℝ`. Note that it does not make sense to talk of a convex set over `ℂ`, but balls
make sense and are enough. Many formulations of the mean value inequality could be generalized to
balls over `ℝ` or `ℂ`. For now, we only include the ones that we need.
-/
variable {𝕜 : Type*} [RCLike 𝕜] {G : Type*} [NormedAddCommGroup G] [NormedSpace 𝕜 G] {H : Type*}
[NormedAddCommGroup H] [NormedSpace 𝕜 H] {f : G → H} {f' : G → G →L[𝕜] H} {x : G}
/-- Over the reals or the complexes, a continuously differentiable function is strictly
differentiable. -/
theorem hasStrictFDerivAt_of_hasFDerivAt_of_continuousAt
(hder : ∀ᶠ y in 𝓝 x, HasFDerivAt f (f' y) y) (hcont : ContinuousAt f' x) :
HasStrictFDerivAt f (f' x) x := by
-- turn little-o definition of strict_fderiv into an epsilon-delta statement
rw [hasStrictFDerivAt_iff_isLittleO, isLittleO_iff]
refine fun c hc => Metric.eventually_nhds_iff_ball.mpr ?_
-- the correct ε is the modulus of continuity of f'
rcases Metric.mem_nhds_iff.mp (inter_mem hder (hcont <| ball_mem_nhds _ hc)) with ⟨ε, ε0, hε⟩
refine ⟨ε, ε0, ?_⟩
-- simplify formulas involving the product E × E
rintro ⟨a, b⟩ h
rw [← ball_prod_same, prodMk_mem_set_prod_eq] at h
-- exploit the choice of ε as the modulus of continuity of f'
have hf' : ∀ x' ∈ ball x ε, ‖f' x' - f' x‖ ≤ c := fun x' H' => by
rw [← dist_eq_norm]
exact le_of_lt (hε H').2
-- apply mean value theorem
letI : NormedSpace ℝ G := RestrictScalars.normedSpace ℝ 𝕜 G
refine (convex_ball _ _).norm_image_sub_le_of_norm_hasFDerivWithin_le' ?_ hf' h.2 h.1
exact fun y hy => (hε hy).1.hasFDerivWithinAt
/-- Over the reals or the complexes, a continuously differentiable function is strictly
differentiable. -/
theorem hasStrictDerivAt_of_hasDerivAt_of_continuousAt {f f' : 𝕜 → G} {x : 𝕜}
(hder : ∀ᶠ y in 𝓝 x, HasDerivAt f (f' y) y) (hcont : ContinuousAt f' x) :
HasStrictDerivAt f (f' x) x :=
hasStrictFDerivAt_of_hasFDerivAt_of_continuousAt (hder.mono fun _ hy => hy.hasFDerivAt) <|
(smulRightL 𝕜 𝕜 G 1).continuous.continuousAt.comp hcont
end RCLike |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/SmoothSeries.lean | import Mathlib.Analysis.Calculus.ContDiff.Operations
import Mathlib.Analysis.Calculus.UniformLimitsDeriv
import Mathlib.Topology.Algebra.InfiniteSum.Module
import Mathlib.Analysis.Normed.Group.FunctionSeries
/-!
# Smoothness of series
We show that series of functions are differentiable, or smooth, when each individual
function in the series is and additionally suitable uniform summable bounds are satisfied.
More specifically,
* `differentiable_tsum` ensures that a series of differentiable functions is differentiable.
* `contDiff_tsum` ensures that a series of `C^n` functions is `C^n`.
We also give versions of these statements which are localized to a set.
-/
open Set Metric TopologicalSpace Function Asymptotics Filter
open scoped Topology NNReal
variable {α β 𝕜 E F : Type*} [NontriviallyNormedField 𝕜] [IsRCLikeNormedField 𝕜]
[NormedAddCommGroup E] [NormedSpace 𝕜 E] [NormedAddCommGroup F] [CompleteSpace F] {u : α → ℝ}
/-! ### Differentiability -/
variable [NormedSpace 𝕜 F]
variable {f : α → E → F} {f' : α → E → E →L[𝕜] F} {g : α → 𝕜 → F} {g' : α → 𝕜 → F} {v : ℕ → α → ℝ}
{s : Set E} {t : Set 𝕜} {x₀ x : E} {y₀ y : 𝕜} {N : ℕ∞}
/-- Consider a series of functions `∑' n, f n x` on a preconnected open set. If the series converges
at a point, and all functions in the series are differentiable with a summable bound on the
derivatives, then the series converges everywhere on the set. -/
theorem summable_of_summable_hasFDerivAt_of_isPreconnected (hu : Summable u) (hs : IsOpen s)
(h's : IsPreconnected s) (hf : ∀ n x, x ∈ s → HasFDerivAt (f n) (f' n x) x)
(hf' : ∀ n x, x ∈ s → ‖f' n x‖ ≤ u n) (hx₀ : x₀ ∈ s) (hf0 : Summable (f · x₀))
(hx : x ∈ s) : Summable fun n => f n x := by
haveI := Classical.decEq α
rw [summable_iff_cauchySeq_finset] at hf0 ⊢
have A : UniformCauchySeqOn (fun t : Finset α => fun x => ∑ i ∈ t, f' i x) atTop s :=
(tendstoUniformlyOn_tsum hu hf').uniformCauchySeqOn
refine cauchy_map_of_uniformCauchySeqOn_fderiv (f := fun t x ↦ ∑ i ∈ t, f i x)
hs h's A (fun t y hy => ?_) hx₀ hx hf0
exact HasFDerivAt.fun_sum fun i _ => hf i y hy
/-- Consider a series of functions `∑' n, f n x` on a preconnected open set. If the series converges
at a point, and all functions in the series are differentiable with a summable bound on the
derivatives, then the series converges everywhere on the set. -/
theorem summable_of_summable_hasDerivAt_of_isPreconnected (hu : Summable u) (ht : IsOpen t)
(h't : IsPreconnected t) (hg : ∀ n y, y ∈ t → HasDerivAt (g n) (g' n y) y)
(hg' : ∀ n y, y ∈ t → ‖g' n y‖ ≤ u n) (hy₀ : y₀ ∈ t) (hg0 : Summable (g · y₀))
(hy : y ∈ t) : Summable fun n => g n y := by
simp_rw [hasDerivAt_iff_hasFDerivAt] at hg
refine summable_of_summable_hasFDerivAt_of_isPreconnected hu ht h't hg ?_ hy₀ hg0 hy
simpa
/-- Consider a series of functions `∑' n, f n x` on a preconnected open set. If the series converges
at a point, and all functions in the series are differentiable with a summable bound on the
derivatives, then the series is differentiable on the set and its derivative is the sum of the
derivatives. -/
theorem hasFDerivAt_tsum_of_isPreconnected (hu : Summable u) (hs : IsOpen s)
(h's : IsPreconnected s) (hf : ∀ n x, x ∈ s → HasFDerivAt (f n) (f' n x) x)
(hf' : ∀ n x, x ∈ s → ‖f' n x‖ ≤ u n) (hx₀ : x₀ ∈ s) (hf0 : Summable fun n => f n x₀)
(hx : x ∈ s) : HasFDerivAt (fun y => ∑' n, f n y) (∑' n, f' n x) x := by
classical
have A :
∀ x : E, x ∈ s → Tendsto (fun t : Finset α => ∑ n ∈ t, f n x) atTop (𝓝 (∑' n, f n x)) := by
intro y hy
apply Summable.hasSum
exact summable_of_summable_hasFDerivAt_of_isPreconnected hu hs h's hf hf' hx₀ hf0 hy
refine hasFDerivAt_of_tendstoUniformlyOn hs (tendstoUniformlyOn_tsum hu hf')
(fun t y hy => ?_) A hx
exact HasFDerivAt.fun_sum fun n _ => hf n y hy
/-- Consider a series of functions `∑' n, f n x` on a preconnected open set. If the series converges
at a point, and all functions in the series are differentiable with a summable bound on the
derivatives, then the series is differentiable on the set and its derivative is the sum of the
derivatives. -/
theorem hasDerivAt_tsum_of_isPreconnected (hu : Summable u) (ht : IsOpen t)
(h't : IsPreconnected t) (hg : ∀ n y, y ∈ t → HasDerivAt (g n) (g' n y) y)
(hg' : ∀ n y, y ∈ t → ‖g' n y‖ ≤ u n) (hy₀ : y₀ ∈ t) (hg0 : Summable fun n => g n y₀)
(hy : y ∈ t) : HasDerivAt (fun z => ∑' n, g n z) (∑' n, g' n y) y := by
simp_rw [hasDerivAt_iff_hasFDerivAt] at hg ⊢
convert hasFDerivAt_tsum_of_isPreconnected hu ht h't hg ?_ hy₀ hg0 hy
· exact (ContinuousLinearMap.smulRightL 𝕜 𝕜 F 1).map_tsum <|
.of_norm_bounded hu fun n ↦ hg' n y hy
· simpa
/-- Consider a series of functions `∑' n, f n x`. If the series converges at a
point, and all functions in the series are differentiable with a summable bound on the derivatives,
then the series converges everywhere. -/
theorem summable_of_summable_hasFDerivAt (hu : Summable u)
(hf : ∀ n x, HasFDerivAt (f n) (f' n x) x) (hf' : ∀ n x, ‖f' n x‖ ≤ u n)
(hf0 : Summable fun n => f n x₀) (x : E) : Summable fun n => f n x := by
letI : RCLike 𝕜 := IsRCLikeNormedField.rclike 𝕜
let _ : NormedSpace ℝ E := NormedSpace.restrictScalars ℝ 𝕜 _
exact summable_of_summable_hasFDerivAt_of_isPreconnected hu isOpen_univ isPreconnected_univ
(fun n x _ => hf n x) (fun n x _ => hf' n x) (mem_univ _) hf0 (mem_univ _)
/-- Consider a series of functions `∑' n, f n x`. If the series converges at a
point, and all functions in the series are differentiable with a summable bound on the derivatives,
then the series converges everywhere. -/
theorem summable_of_summable_hasDerivAt (hu : Summable u)
(hg : ∀ n y, HasDerivAt (g n) (g' n y) y) (hg' : ∀ n y, ‖g' n y‖ ≤ u n)
(hg0 : Summable fun n => g n y₀) (y : 𝕜) : Summable fun n => g n y := by
exact summable_of_summable_hasDerivAt_of_isPreconnected hu isOpen_univ isPreconnected_univ
(fun n x _ => hg n x) (fun n x _ => hg' n x) (mem_univ _) hg0 (mem_univ _)
/-- Consider a series of functions `∑' n, f n x`. If the series converges at a
point, and all functions in the series are differentiable with a summable bound on the derivatives,
then the series is differentiable and its derivative is the sum of the derivatives. -/
theorem hasFDerivAt_tsum (hu : Summable u) (hf : ∀ n x, HasFDerivAt (f n) (f' n x) x)
(hf' : ∀ n x, ‖f' n x‖ ≤ u n) (hf0 : Summable fun n => f n x₀) (x : E) :
HasFDerivAt (fun y => ∑' n, f n y) (∑' n, f' n x) x := by
letI : RCLike 𝕜 := IsRCLikeNormedField.rclike 𝕜
let A : NormedSpace ℝ E := NormedSpace.restrictScalars ℝ 𝕜 _
exact hasFDerivAt_tsum_of_isPreconnected hu isOpen_univ isPreconnected_univ
(fun n x _ => hf n x) (fun n x _ => hf' n x) (mem_univ _) hf0 (mem_univ _)
/-- Consider a series of functions `∑' n, f n x`. If the series converges at a
point, and all functions in the series are differentiable with a summable bound on the derivatives,
then the series is differentiable and its derivative is the sum of the derivatives. -/
theorem hasDerivAt_tsum (hu : Summable u) (hg : ∀ n y, HasDerivAt (g n) (g' n y) y)
(hg' : ∀ n y, ‖g' n y‖ ≤ u n) (hg0 : Summable fun n => g n y₀) (y : 𝕜) :
HasDerivAt (fun z => ∑' n, g n z) (∑' n, g' n y) y := by
exact hasDerivAt_tsum_of_isPreconnected hu isOpen_univ isPreconnected_univ
(fun n y _ => hg n y) (fun n y _ => hg' n y) (mem_univ _) hg0 (mem_univ _)
/-- Consider a series of functions `∑' n, f n x`. If all functions in the series are differentiable
with a summable bound on the derivatives, then the series is differentiable.
Note that our assumptions do not ensure the pointwise convergence, but if there is no pointwise
convergence then the series is zero everywhere so the result still holds. -/
theorem differentiable_tsum (hu : Summable u) (hf : ∀ n x, HasFDerivAt (f n) (f' n x) x)
(hf' : ∀ n x, ‖f' n x‖ ≤ u n) : Differentiable 𝕜 fun y => ∑' n, f n y := by
by_cases! h : ∃ x₀, Summable fun n => f n x₀
· rcases h with ⟨x₀, hf0⟩
intro x
exact (hasFDerivAt_tsum hu hf hf' hf0 x).differentiableAt
· have : (fun x => ∑' n, f n x) = 0 := by ext1 x; exact tsum_eq_zero_of_not_summable (h x)
rw [this]
exact differentiable_const 0
/-- Consider a series of functions `∑' n, f n x`. If all functions in the series are differentiable
with a summable bound on the derivatives, then the series is differentiable.
Note that our assumptions do not ensure the pointwise convergence, but if there is no pointwise
convergence then the series is zero everywhere so the result still holds. -/
theorem differentiable_tsum' (hu : Summable u) (hg : ∀ n y, HasDerivAt (g n) (g' n y) y)
(hg' : ∀ n y, ‖g' n y‖ ≤ u n) : Differentiable 𝕜 fun z => ∑' n, g n z := by
simp_rw [hasDerivAt_iff_hasFDerivAt] at hg
refine differentiable_tsum hu hg ?_
simpa
theorem fderiv_tsum_apply (hu : Summable u) (hf : ∀ n, Differentiable 𝕜 (f n))
(hf' : ∀ n x, ‖fderiv 𝕜 (f n) x‖ ≤ u n) (hf0 : Summable fun n => f n x₀) (x : E) :
fderiv 𝕜 (fun y => ∑' n, f n y) x = ∑' n, fderiv 𝕜 (f n) x :=
(hasFDerivAt_tsum hu (fun n x => (hf n x).hasFDerivAt) hf' hf0 _).fderiv
theorem deriv_tsum_apply (hu : Summable u) (hg : ∀ n, Differentiable 𝕜 (g n))
(hg' : ∀ n y, ‖deriv (g n) y‖ ≤ u n) (hg0 : Summable fun n => g n y₀) (y : 𝕜) :
deriv (fun z => ∑' n, g n z) y = ∑' n, deriv (g n) y :=
(hasDerivAt_tsum hu (fun n y => (hg n y).hasDerivAt) hg' hg0 _).deriv
theorem fderiv_tsum (hu : Summable u) (hf : ∀ n, Differentiable 𝕜 (f n))
(hf' : ∀ n x, ‖fderiv 𝕜 (f n) x‖ ≤ u n) (hf0 : Summable fun n => f n x₀) :
(fderiv 𝕜 fun y => ∑' n, f n y) = fun x => ∑' n, fderiv 𝕜 (f n) x := by
ext1 x
exact fderiv_tsum_apply hu hf hf' hf0 x
theorem deriv_tsum (hu : Summable u) (hg : ∀ n, Differentiable 𝕜 (g n))
(hg' : ∀ n y, ‖deriv (g n) y‖ ≤ u n) (hg0 : Summable fun n => g n y₀) :
(deriv fun y => ∑' n, g n y) = fun y => ∑' n, deriv (g n) y := by
ext1 x
exact deriv_tsum_apply hu hg hg' hg0 x
/-! ### Higher smoothness -/
/-- Consider a series of `C^n` functions, with summable uniform bounds on the successive
derivatives. Then the iterated derivative of the sum is the sum of the iterated derivative. -/
theorem iteratedFDeriv_tsum (hf : ∀ i, ContDiff 𝕜 N (f i))
(hv : ∀ k : ℕ, (k : ℕ∞) ≤ N → Summable (v k))
(h'f : ∀ (k : ℕ) (i : α) (x : E), (k : ℕ∞) ≤ N → ‖iteratedFDeriv 𝕜 k (f i) x‖ ≤ v k i) {k : ℕ}
(hk : (k : ℕ∞) ≤ N) :
(iteratedFDeriv 𝕜 k fun y => ∑' n, f n y) = fun x => ∑' n, iteratedFDeriv 𝕜 k (f n) x := by
induction k with
| zero =>
ext1 x
simp_rw [iteratedFDeriv_zero_eq_comp]
exact (continuousMultilinearCurryFin0 𝕜 E F).symm.toContinuousLinearEquiv.map_tsum
| succ k IH =>
have h'k : (k : ℕ∞) < N := lt_of_lt_of_le (WithTop.coe_lt_coe.2 (Nat.lt_succ_self _)) hk
have A : Summable fun n => iteratedFDeriv 𝕜 k (f n) 0 :=
.of_norm_bounded (hv k h'k.le) fun n ↦ h'f k n 0 h'k.le
simp_rw [iteratedFDeriv_succ_eq_comp_left, IH h'k.le]
rw [fderiv_tsum (hv _ hk) (fun n => (hf n).differentiable_iteratedFDeriv
(mod_cast h'k)) _ A]
· ext1 x
exact (continuousMultilinearCurryLeftEquiv 𝕜
(fun _ : Fin (k + 1) => E) F).symm.toContinuousLinearEquiv.map_tsum
· intro n x
simpa only [iteratedFDeriv_succ_eq_comp_left, LinearIsometryEquiv.norm_map, comp_apply]
using h'f k.succ n x hk
/-- Consider a series of smooth functions, with summable uniform bounds on the successive
derivatives. Then the iterated derivative of the sum is the sum of the iterated derivative. -/
theorem iteratedFDeriv_tsum_apply (hf : ∀ i, ContDiff 𝕜 N (f i))
(hv : ∀ k : ℕ, (k : ℕ∞) ≤ N → Summable (v k))
(h'f : ∀ (k : ℕ) (i : α) (x : E), (k : ℕ∞) ≤ N → ‖iteratedFDeriv 𝕜 k (f i) x‖ ≤ v k i) {k : ℕ}
(hk : (k : ℕ∞) ≤ N) (x : E) :
iteratedFDeriv 𝕜 k (fun y => ∑' n, f n y) x = ∑' n, iteratedFDeriv 𝕜 k (f n) x := by
rw [iteratedFDeriv_tsum hf hv h'f hk]
/-- Consider a series of functions `∑' i, f i x`. Assume that each individual function `f i` is of
class `C^N`, and moreover there is a uniform summable upper bound on the `k`-th derivative
for each `k ≤ N`. Then the series is also `C^N`. -/
theorem contDiff_tsum (hf : ∀ i, ContDiff 𝕜 N (f i)) (hv : ∀ k : ℕ, (k : ℕ∞) ≤ N → Summable (v k))
(h'f : ∀ (k : ℕ) (i : α) (x : E), k ≤ N → ‖iteratedFDeriv 𝕜 k (f i) x‖ ≤ v k i) :
ContDiff 𝕜 N fun x => ∑' i, f i x := by
rw [contDiff_iff_continuous_differentiable]
constructor
· intro m hm
rw [iteratedFDeriv_tsum hf hv h'f hm]
refine continuous_tsum ?_ (hv m hm) ?_
· intro i
exact ContDiff.continuous_iteratedFDeriv (mod_cast hm) (hf i)
· intro n x
exact h'f _ _ _ hm
· intro m hm
have h'm : ((m + 1 : ℕ) : ℕ∞) ≤ N := by
simpa only [ENat.coe_add, ENat.coe_one] using Order.add_one_le_of_lt hm
rw [iteratedFDeriv_tsum hf hv h'f hm.le]
have A n x : HasFDerivAt (iteratedFDeriv 𝕜 m (f n)) (fderiv 𝕜 (iteratedFDeriv 𝕜 m (f n)) x) x :=
(ContDiff.differentiable_iteratedFDeriv (mod_cast hm)
(hf n)).differentiableAt.hasFDerivAt
refine differentiable_tsum (hv _ h'm) A fun n x => ?_
rw [fderiv_iteratedFDeriv, comp_apply, LinearIsometryEquiv.norm_map]
exact h'f _ _ _ h'm
/-- Consider a series of functions `∑' i, f i x`. Assume that each individual function `f i` is of
class `C^N`, and moreover there is a uniform summable upper bound on the `k`-th derivative
for each `k ≤ N` (except maybe for finitely many `i`s). Then the series is also `C^N`. -/
theorem contDiff_tsum_of_eventually (hf : ∀ i, ContDiff 𝕜 N (f i))
(hv : ∀ k : ℕ, k ≤ N → Summable (v k))
(h'f : ∀ k : ℕ, k ≤ N →
∀ᶠ i in (Filter.cofinite : Filter α), ∀ x : E, ‖iteratedFDeriv 𝕜 k (f i) x‖ ≤ v k i) :
ContDiff 𝕜 N fun x => ∑' i, f i x := by
classical
refine contDiff_iff_forall_nat_le.2 fun m hm => ?_
let t : Set α :=
{ i : α | ¬∀ k : ℕ, k ∈ Finset.range (m + 1) → ∀ x, ‖iteratedFDeriv 𝕜 k (f i) x‖ ≤ v k i }
have ht : Set.Finite t :=
haveI A :
∀ᶠ i in (Filter.cofinite : Filter α),
∀ k : ℕ, k ∈ Finset.range (m + 1) → ∀ x : E, ‖iteratedFDeriv 𝕜 k (f i) x‖ ≤ v k i := by
rw [eventually_all_finset]
intro i hi
apply h'f
simp only [Finset.mem_range_succ_iff] at hi
exact (WithTop.coe_le_coe.2 hi).trans hm
eventually_cofinite.2 A
let T : Finset α := ht.toFinset
have : (fun x => ∑' i, f i x) = (fun x => ∑ i ∈ T, f i x) +
fun x => ∑' i : { i // i ∉ T }, f i x := by
ext1 x
refine (Summable.sum_add_tsum_subtype_compl ?_ T).symm
refine .of_norm_bounded_eventually (hv 0 (zero_le _)) ?_
filter_upwards [h'f 0 (zero_le _)] with i hi
simpa only [norm_iteratedFDeriv_zero] using hi x
rw [this]
apply (ContDiff.sum fun i _ => (hf i).of_le (mod_cast hm)).add
have h'u : ∀ k : ℕ, (k : ℕ∞) ≤ m → Summable (v k ∘ ((↑) : { i // i ∉ T } → α)) := fun k hk =>
(hv k (hk.trans hm)).subtype _
refine contDiff_tsum (fun i => (hf i).of_le (mod_cast hm)) h'u ?_
rintro k ⟨i, hi⟩ x hk
simp only [t, T, Finite.mem_toFinset, mem_setOf_eq, Finset.mem_range, not_forall, not_le,
exists_prop, not_exists, not_and, not_lt] at hi
exact hi k (Nat.lt_succ_iff.2 (WithTop.coe_le_coe.1 hk)) x |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/FormalMultilinearSeries.lean | import Mathlib.Analysis.NormedSpace.Multilinear.Curry
/-!
# Formal multilinear series
In this file we define `FormalMultilinearSeries 𝕜 E F` to be a family of `n`-multilinear maps for
all `n`, designed to model the sequence of derivatives of a function. In other files we use this
notion to define `C^n` functions (called `contDiff` in `mathlib`) and analytic functions.
## Notation
We use the notation `E [×n]→L[𝕜] F` for the space of continuous multilinear maps on `E^n` with
values in `F`. This is the space in which the `n`-th derivative of a function from `E` to `F` lives.
## Tags
multilinear, formal series
-/
noncomputable section
open Set Fin Topology
universe u u' v w x y
variable {𝕜 : Type u} {𝕜' : Type u'} {E : Type v} {F : Type w} {G : Type x} {H : Type y}
section
variable [Semiring 𝕜]
[AddCommMonoid E] [Module 𝕜 E] [TopologicalSpace E] [ContinuousAdd E] [ContinuousConstSMul 𝕜 E]
[AddCommMonoid F] [Module 𝕜 F] [TopologicalSpace F] [ContinuousAdd F] [ContinuousConstSMul 𝕜 F]
[AddCommMonoid G] [Module 𝕜 G] [TopologicalSpace G] [ContinuousAdd G] [ContinuousConstSMul 𝕜 G]
[AddCommMonoid H] [Module 𝕜 H] [TopologicalSpace H] [ContinuousAdd H] [ContinuousConstSMul 𝕜 H]
/-- A formal multilinear series over a field `𝕜`, from `E` to `F`, is given by a family of
multilinear maps from `E^n` to `F` for all `n`. -/
@[nolint unusedArguments]
def FormalMultilinearSeries (𝕜 : Type*) (E : Type*) (F : Type*) [Semiring 𝕜] [AddCommMonoid E]
[Module 𝕜 E] [TopologicalSpace E] [ContinuousAdd E] [ContinuousConstSMul 𝕜 E]
[AddCommMonoid F] [Module 𝕜 F] [TopologicalSpace F] [ContinuousAdd F]
[ContinuousConstSMul 𝕜 F] :=
∀ n : ℕ, E[×n]→L[𝕜] F
deriving AddCommMonoid, Inhabited
section Module
instance (𝕜') [Semiring 𝕜'] [Module 𝕜' F] [ContinuousConstSMul 𝕜' F] [SMulCommClass 𝕜 𝕜' F] :
Module 𝕜' (FormalMultilinearSeries 𝕜 E F) :=
inferInstanceAs <| Module 𝕜' <| ∀ n : ℕ, E[×n]→L[𝕜] F
end Module
namespace FormalMultilinearSeries
@[simp]
theorem zero_apply (n : ℕ) : (0 : FormalMultilinearSeries 𝕜 E F) n = 0 := rfl
@[simp]
theorem add_apply (p q : FormalMultilinearSeries 𝕜 E F) (n : ℕ) : (p + q) n = p n + q n := rfl
@[simp]
theorem smul_apply [Semiring 𝕜'] [Module 𝕜' F] [ContinuousConstSMul 𝕜' F] [SMulCommClass 𝕜 𝕜' F]
(f : FormalMultilinearSeries 𝕜 E F) (n : ℕ) (a : 𝕜') : (a • f) n = a • f n := rfl
@[ext]
protected theorem ext {p q : FormalMultilinearSeries 𝕜 E F} (h : ∀ n, p n = q n) : p = q :=
funext h
protected theorem ne_iff {p q : FormalMultilinearSeries 𝕜 E F} : p ≠ q ↔ ∃ n, p n ≠ q n :=
Function.ne_iff
/-- Cartesian product of two formal multilinear series (with the same field `𝕜` and the same source
space, but possibly different target spaces). -/
def prod (p : FormalMultilinearSeries 𝕜 E F) (q : FormalMultilinearSeries 𝕜 E G) :
FormalMultilinearSeries 𝕜 E (F × G)
| n => (p n).prod (q n)
/-- Product of formal multilinear series (with the same field `𝕜` and the same source
space, but possibly different target spaces). -/
@[simp] def pi {ι : Type*} {F : ι → Type*}
[∀ i, AddCommGroup (F i)] [∀ i, Module 𝕜 (F i)] [∀ i, TopologicalSpace (F i)]
[∀ i, IsTopologicalAddGroup (F i)] [∀ i, ContinuousConstSMul 𝕜 (F i)]
(p : Π i, FormalMultilinearSeries 𝕜 E (F i)) :
FormalMultilinearSeries 𝕜 E (Π i, F i)
| n => ContinuousMultilinearMap.pi (fun i ↦ p i n)
/-- Killing the zeroth coefficient in a formal multilinear series -/
def removeZero (p : FormalMultilinearSeries 𝕜 E F) : FormalMultilinearSeries 𝕜 E F
| 0 => 0
| n + 1 => p (n + 1)
@[simp]
theorem removeZero_coeff_zero (p : FormalMultilinearSeries 𝕜 E F) : p.removeZero 0 = 0 :=
rfl
@[simp]
theorem removeZero_coeff_succ (p : FormalMultilinearSeries 𝕜 E F) (n : ℕ) :
p.removeZero (n + 1) = p (n + 1) :=
rfl
theorem removeZero_of_pos (p : FormalMultilinearSeries 𝕜 E F) {n : ℕ} (h : 0 < n) :
p.removeZero n = p n := by
rw [← Nat.succ_pred_eq_of_pos h]
rfl
/-- Convenience congruence lemma stating in a dependent setting that, if the arguments to a formal
multilinear series are equal, then the values are also equal. -/
theorem congr (p : FormalMultilinearSeries 𝕜 E F) {m n : ℕ} {v : Fin m → E} {w : Fin n → E}
(h1 : m = n) (h2 : ∀ (i : ℕ) (him : i < m) (hin : i < n), v ⟨i, him⟩ = w ⟨i, hin⟩) :
p m v = p n w := by
subst n
congr with ⟨i, hi⟩
exact h2 i hi hi
lemma congr_zero (p : FormalMultilinearSeries 𝕜 E F) {k l : ℕ} (h : k = l) (h' : p k = 0) :
p l = 0 := by
subst h; exact h'
/-- Composing each term `pₙ` in a formal multilinear series with `(u, ..., u)` where `u` is a fixed
continuous linear map, gives a new formal multilinear series `p.compContinuousLinearMap u`. -/
def compContinuousLinearMap (p : FormalMultilinearSeries 𝕜 F G) (u : E →L[𝕜] F) :
FormalMultilinearSeries 𝕜 E G := fun n => (p n).compContinuousLinearMap fun _ : Fin n => u
@[simp]
theorem compContinuousLinearMap_apply (p : FormalMultilinearSeries 𝕜 F G) (u : E →L[𝕜] F) (n : ℕ)
(v : Fin n → E) : (p.compContinuousLinearMap u) n v = p n (u ∘ v) :=
rfl
@[simp]
theorem compContinuousLinearMap_id (p : FormalMultilinearSeries 𝕜 E F) :
p.compContinuousLinearMap (.id _ _) = p :=
rfl
theorem compContinuousLinearMap_comp (p : FormalMultilinearSeries 𝕜 G H) (u₁ : F →L[𝕜] G)
(u₂ : E →L[𝕜] F) :
(p.compContinuousLinearMap u₁).compContinuousLinearMap u₂ =
p.compContinuousLinearMap (u₁.comp u₂) :=
rfl
variable (𝕜) [Semiring 𝕜'] [SMul 𝕜 𝕜']
variable [Module 𝕜' E] [ContinuousConstSMul 𝕜' E] [IsScalarTower 𝕜 𝕜' E]
variable [Module 𝕜' F] [ContinuousConstSMul 𝕜' F] [IsScalarTower 𝕜 𝕜' F]
/-- Reinterpret a formal `𝕜'`-multilinear series as a formal `𝕜`-multilinear series. -/
@[simp]
protected def restrictScalars (p : FormalMultilinearSeries 𝕜' E F) :
FormalMultilinearSeries 𝕜 E F := fun n => (p n).restrictScalars 𝕜
end FormalMultilinearSeries
end
namespace FormalMultilinearSeries
variable [Ring 𝕜] [AddCommGroup E] [Module 𝕜 E] [TopologicalSpace E] [IsTopologicalAddGroup E]
[ContinuousConstSMul 𝕜 E] [AddCommGroup F] [Module 𝕜 F] [TopologicalSpace F]
[IsTopologicalAddGroup F] [ContinuousConstSMul 𝕜 F]
instance : AddCommGroup (FormalMultilinearSeries 𝕜 E F) :=
inferInstanceAs <| AddCommGroup <| ∀ n : ℕ, E[×n]→L[𝕜] F
@[simp]
theorem neg_apply (f : FormalMultilinearSeries 𝕜 E F) (n : ℕ) : (-f) n = - f n := rfl
@[simp]
theorem sub_apply (f g : FormalMultilinearSeries 𝕜 E F) (n : ℕ) : (f - g) n = f n - g n := rfl
end FormalMultilinearSeries
namespace FormalMultilinearSeries
variable [NontriviallyNormedField 𝕜] [NormedAddCommGroup E] [NormedSpace 𝕜 E] [NormedAddCommGroup F]
[NormedSpace 𝕜 F]
variable (p : FormalMultilinearSeries 𝕜 E F)
/-- Forgetting the zeroth term in a formal multilinear series, and interpreting the following terms
as multilinear maps into `E →L[𝕜] F`. If `p` is the Taylor series (`HasFTaylorSeriesUpTo`) of a
function, then `p.shift` is the Taylor series of the derivative of the function. Note that the
`p.sum` of a Taylor series `p` does not give the original function; for a formal multilinear
series that sums to the derivative of `p.sum`, see `HasFPowerSeriesOnBall.fderiv`. -/
def shift : FormalMultilinearSeries 𝕜 E (E →L[𝕜] F) := fun n => (p n.succ).curryRight
/-- Adding a zeroth term to a formal multilinear series taking values in `E →L[𝕜] F`. This
corresponds to starting from a Taylor series (`HasFTaylorSeriesUpTo`) for the derivative of a
function, and building a Taylor series for the function itself. -/
def unshift (q : FormalMultilinearSeries 𝕜 E (E →L[𝕜] F)) (z : F) : FormalMultilinearSeries 𝕜 E F
| 0 => (continuousMultilinearCurryFin0 𝕜 E F).symm z
| n + 1 => (continuousMultilinearCurryRightEquiv' 𝕜 n E F).symm (q n)
theorem unshift_shift {p : FormalMultilinearSeries 𝕜 E (E →L[𝕜] F)} {z : F} :
(p.unshift z).shift = p := by
ext1 n
simp only [shift, Nat.succ_eq_add_one, unshift]
exact LinearIsometryEquiv.apply_symm_apply (continuousMultilinearCurryRightEquiv' 𝕜 n E F) (p n)
end FormalMultilinearSeries
section
variable [Semiring 𝕜] [AddCommMonoid E] [Module 𝕜 E] [TopologicalSpace E] [ContinuousAdd E]
[ContinuousConstSMul 𝕜 E] [AddCommMonoid F] [Module 𝕜 F] [TopologicalSpace F]
[ContinuousAdd F] [ContinuousConstSMul 𝕜 F] [AddCommMonoid G] [Module 𝕜 G]
[TopologicalSpace G] [ContinuousAdd G] [ContinuousConstSMul 𝕜 G]
namespace ContinuousLinearMap
/-- Composing each term `pₙ` in a formal multilinear series with a continuous linear map `f` on the
left gives a new formal multilinear series `f.compFormalMultilinearSeries p` whose general term
is `f ∘ pₙ`. -/
def compFormalMultilinearSeries (f : F →L[𝕜] G) (p : FormalMultilinearSeries 𝕜 E F) :
FormalMultilinearSeries 𝕜 E G := fun n => f.compContinuousMultilinearMap (p n)
@[simp]
theorem compFormalMultilinearSeries_apply (f : F →L[𝕜] G) (p : FormalMultilinearSeries 𝕜 E F)
(n : ℕ) : (f.compFormalMultilinearSeries p) n = f.compContinuousMultilinearMap (p n) :=
rfl
theorem compFormalMultilinearSeries_apply' (f : F →L[𝕜] G) (p : FormalMultilinearSeries 𝕜 E F)
(n : ℕ) (v : Fin n → E) : (f.compFormalMultilinearSeries p) n v = f (p n v) :=
rfl
end ContinuousLinearMap
namespace ContinuousMultilinearMap
variable {ι : Type*} {E : ι → Type*} [∀ i, AddCommGroup (E i)] [∀ i, Module 𝕜 (E i)]
[∀ i, TopologicalSpace (E i)] [∀ i, IsTopologicalAddGroup (E i)]
[∀ i, ContinuousConstSMul 𝕜 (E i)] [Fintype ι] (f : ContinuousMultilinearMap 𝕜 E F)
/-- Realize a ContinuousMultilinearMap on `∀ i : ι, E i` as the evaluation of a
FormalMultilinearSeries by choosing an arbitrary identification `ι ≃ Fin (Fintype.card ι)`. -/
noncomputable def toFormalMultilinearSeries : FormalMultilinearSeries 𝕜 (∀ i, E i) F :=
fun n ↦ if h : Fintype.card ι = n then
(f.compContinuousLinearMap .proj).domDomCongr (Fintype.equivFinOfCardEq h)
else 0
end ContinuousMultilinearMap
end
namespace FormalMultilinearSeries
section Order
variable [Semiring 𝕜] {n : ℕ} [AddCommMonoid E] [Module 𝕜 E] [TopologicalSpace E]
[ContinuousAdd E] [ContinuousConstSMul 𝕜 E] [AddCommMonoid F] [Module 𝕜 F]
[TopologicalSpace F] [ContinuousAdd F] [ContinuousConstSMul 𝕜 F]
{p : FormalMultilinearSeries 𝕜 E F}
/-- The index of the first non-zero coefficient in `p` (or `0` if all coefficients are zero). This
is the order of the isolated zero of an analytic function `f` at a point if `p` is the Taylor
series of `f` at that point. -/
noncomputable def order (p : FormalMultilinearSeries 𝕜 E F) : ℕ :=
sInf { n | p n ≠ 0 }
@[simp]
theorem order_zero : (0 : FormalMultilinearSeries 𝕜 E F).order = 0 := by simp [order]
theorem ne_zero_of_order_ne_zero (hp : p.order ≠ 0) : p ≠ 0 := fun h => by simp [h] at hp
theorem order_eq_find [DecidablePred fun n => p n ≠ 0] (hp : ∃ n, p n ≠ 0) :
p.order = Nat.find hp := by convert Nat.sInf_def hp
theorem order_eq_find' [DecidablePred fun n => p n ≠ 0] (hp : p ≠ 0) :
p.order = Nat.find (FormalMultilinearSeries.ne_iff.mp hp) :=
order_eq_find _
theorem order_eq_zero_iff' : p.order = 0 ↔ p = 0 ∨ p 0 ≠ 0 := by
simpa [order, Nat.sInf_eq_zero, FormalMultilinearSeries.ext_iff, eq_empty_iff_forall_notMem]
using or_comm
theorem order_eq_zero_iff (hp : p ≠ 0) : p.order = 0 ↔ p 0 ≠ 0 := by
simp [order_eq_zero_iff', hp]
theorem apply_order_ne_zero (hp : p ≠ 0) : p p.order ≠ 0 :=
Nat.sInf_mem (FormalMultilinearSeries.ne_iff.1 hp)
theorem apply_order_ne_zero' (hp : p.order ≠ 0) : p p.order ≠ 0 :=
apply_order_ne_zero (ne_zero_of_order_ne_zero hp)
theorem apply_eq_zero_of_lt_order (hp : n < p.order) : p n = 0 :=
by_contra <| Nat.notMem_of_lt_sInf hp
end Order
section Coef
variable [NontriviallyNormedField 𝕜] [NormedAddCommGroup E] [NormedSpace 𝕜 E]
{p : FormalMultilinearSeries 𝕜 𝕜 E} {f : 𝕜 → E} {n : ℕ} {z : 𝕜} {y : Fin n → 𝕜}
/-- The `n`th coefficient of `p` when seen as a power series. -/
def coeff (p : FormalMultilinearSeries 𝕜 𝕜 E) (n : ℕ) : E :=
p n 1
theorem mkPiRing_coeff_eq (p : FormalMultilinearSeries 𝕜 𝕜 E) (n : ℕ) :
ContinuousMultilinearMap.mkPiRing 𝕜 (Fin n) (p.coeff n) = p n :=
(p n).mkPiRing_apply_one_eq_self
@[simp]
theorem apply_eq_prod_smul_coeff : p n y = (∏ i, y i) • p.coeff n := by
convert (p n).toMultilinearMap.map_smul_univ y 1
simp only [Pi.one_apply, Algebra.id.smul_eq_mul, mul_one]
theorem coeff_eq_zero : p.coeff n = 0 ↔ p n = 0 := by
rw [← mkPiRing_coeff_eq p, ContinuousMultilinearMap.mkPiRing_eq_zero_iff]
theorem apply_eq_pow_smul_coeff : (p n fun _ => z) = z ^ n • p.coeff n := by simp
@[simp]
theorem norm_apply_eq_norm_coef : ‖p n‖ = ‖coeff p n‖ := by
rw [← mkPiRing_coeff_eq p, ContinuousMultilinearMap.norm_mkPiRing]
end Coef
section Fslope
variable [NontriviallyNormedField 𝕜] [NormedAddCommGroup E] [NormedSpace 𝕜 E]
{p : FormalMultilinearSeries 𝕜 𝕜 E} {n : ℕ}
/-- The formal counterpart of `dslope`, corresponding to the expansion of `(f z - f 0) / z`. If `f`
has `p` as a power series, then `dslope f` has `fslope p` as a power series. -/
noncomputable def fslope (p : FormalMultilinearSeries 𝕜 𝕜 E) : FormalMultilinearSeries 𝕜 𝕜 E :=
fun n => (p (n + 1)).curryLeft 1
@[simp]
theorem coeff_fslope : p.fslope.coeff n = p.coeff (n + 1) := by
simp only [fslope, coeff, ContinuousMultilinearMap.curryLeft_apply]
congr 1
exact Fin.cons_self_tail (fun _ => (1 : 𝕜))
@[simp]
theorem coeff_iterate_fslope (k n : ℕ) : (fslope^[k] p).coeff n = p.coeff (n + k) := by
induction k generalizing p with
| zero => rfl
| succ k ih => simp [ih, add_assoc]
end Fslope
end FormalMultilinearSeries
section Const
/-- The formal multilinear series where all terms of positive degree are equal to zero, and the term
of degree zero is `c`. It is the power series expansion of the constant function equal to `c`
everywhere. -/
def constFormalMultilinearSeries (𝕜 : Type*) [NontriviallyNormedField 𝕜] (E : Type*)
[NormedAddCommGroup E] [NormedSpace 𝕜 E] [ContinuousConstSMul 𝕜 E] [IsTopologicalAddGroup E]
{F : Type*} [NormedAddCommGroup F] [IsTopologicalAddGroup F] [NormedSpace 𝕜 F]
[ContinuousConstSMul 𝕜 F] (c : F) : FormalMultilinearSeries 𝕜 E F
| 0 => ContinuousMultilinearMap.uncurry0 _ _ c
| _ => 0
@[simp]
theorem constFormalMultilinearSeries_apply_zero [NontriviallyNormedField 𝕜] [NormedAddCommGroup E]
[NormedAddCommGroup F] [NormedSpace 𝕜 E] [NormedSpace 𝕜 F] {c : F} :
constFormalMultilinearSeries 𝕜 E c 0 = ContinuousMultilinearMap.uncurry0 _ _ c :=
rfl
@[simp]
theorem constFormalMultilinearSeries_apply_succ [NontriviallyNormedField 𝕜] [NormedAddCommGroup E]
[NormedAddCommGroup F] [NormedSpace 𝕜 E] [NormedSpace 𝕜 F] {c : F} {n : ℕ} :
constFormalMultilinearSeries 𝕜 E c (n + 1) = 0 :=
rfl
theorem constFormalMultilinearSeries_apply_of_nonzero [NontriviallyNormedField 𝕜]
[NormedAddCommGroup E] [NormedAddCommGroup F] [NormedSpace 𝕜 E] [NormedSpace 𝕜 F] {c : F}
{n : ℕ} (hn : n ≠ 0) : constFormalMultilinearSeries 𝕜 E c n = 0 :=
Nat.casesOn n (fun hn => (hn rfl).elim) (fun _ _ => rfl) hn
@[deprecated (since := "2025-06-23")]
alias constFormalMultilinearSeries_apply := constFormalMultilinearSeries_apply_of_nonzero
@[simp]
lemma constFormalMultilinearSeries_zero [NontriviallyNormedField 𝕜] [NormedAddCommGroup E]
[NormedAddCommGroup F] [NormedSpace 𝕜 E] [NormedSpace 𝕜 F] :
constFormalMultilinearSeries 𝕜 E (0 : F) = 0 := by
ext n x
simp only [FormalMultilinearSeries.zero_apply, ContinuousMultilinearMap.zero_apply,
constFormalMultilinearSeries]
induction n
· simp only [ContinuousMultilinearMap.uncurry0_apply]
· simp only [constFormalMultilinearSeries.match_1.eq_2, ContinuousMultilinearMap.zero_apply]
@[simp]
lemma compContinuousLinearMap_zero [NontriviallyNormedField 𝕜]
[NormedAddCommGroup E] [NormedSpace 𝕜 E]
[NormedAddCommGroup F] [NormedSpace 𝕜 F]
[NormedAddCommGroup G] [NormedSpace 𝕜 G]
(p : FormalMultilinearSeries 𝕜 F G) :
p.compContinuousLinearMap (0 : E →L[𝕜] F) = constFormalMultilinearSeries 𝕜 E (p 0 0) := by
ext n v
cases n with
| zero =>
simp only [FormalMultilinearSeries.compContinuousLinearMap_apply, Matrix.zero_empty,
constFormalMultilinearSeries_apply_zero, ContinuousMultilinearMap.uncurry0_apply]
congr
apply Subsingleton.allEq
| succ =>
simp [ContinuousLinearMap.coe_zero']
end Const
section Linear
variable [NontriviallyNormedField 𝕜]
[NormedAddCommGroup E] [NormedSpace 𝕜 E]
[NormedAddCommGroup F] [NormedSpace 𝕜 F]
namespace ContinuousLinearMap
/-- Formal power series of a continuous linear map `f : E →L[𝕜] F` at `x : E`:
`f y = f x + f (y - x)`. -/
def fpowerSeries (f : E →L[𝕜] F) (x : E) : FormalMultilinearSeries 𝕜 E F
| 0 => ContinuousMultilinearMap.uncurry0 𝕜 _ (f x)
| 1 => (continuousMultilinearCurryFin1 𝕜 E F).symm f
| _ => 0
@[simp]
theorem fpowerSeries_apply_zero (f : E →L[𝕜] F) (x : E) :
f.fpowerSeries x 0 = ContinuousMultilinearMap.uncurry0 𝕜 _ (f x) :=
rfl
@[simp]
theorem fpowerSeries_apply_one (f : E →L[𝕜] F) (x : E) :
f.fpowerSeries x 1 = (continuousMultilinearCurryFin1 𝕜 E F).symm f :=
rfl
@[simp]
theorem fpowerSeries_apply_add_two (f : E →L[𝕜] F) (x : E) (n : ℕ) : f.fpowerSeries x (n + 2) = 0 :=
rfl
end ContinuousLinearMap
end Linear |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/LHopital.lean | import Mathlib.Analysis.Calculus.Deriv.Inv
import Mathlib.Analysis.Calculus.Deriv.MeanValue
/-!
# L'Hôpital's rule for 0/0 indeterminate forms
In this file, we prove several forms of "L'Hôpital's rule" for computing 0/0
indeterminate forms. The proof of `HasDerivAt.lhopital_zero_right_on_Ioo`
is based on the one given in the corresponding
[Wikibooks](https://en.wikibooks.org/wiki/Calculus/L%27H%C3%B4pital%27s_Rule)
chapter, and all other statements are derived from this one by composing by
carefully chosen functions.
Note that the filter `f'/g'` tends to isn't required to be one of `𝓝 a`,
`atTop` or `atBot`. In fact, we give a slightly stronger statement by
allowing it to be any filter on `ℝ`.
Each statement is available in a `HasDerivAt` form and a `deriv` form, which
is denoted by each statement being in either the `HasDerivAt` or the `deriv`
namespace.
## Tags
L'Hôpital's rule, L'Hopital's rule
-/
open Filter Set
open scoped Filter Topology Pointwise
variable {a b : ℝ} {l : Filter ℝ} {f f' g g' : ℝ → ℝ}
/-!
## Interval-based versions
We start by proving statements where all conditions (derivability, `g' ≠ 0`) have
to be satisfied on an explicitly-provided interval.
-/
namespace HasDerivAt
theorem lhopital_zero_right_on_Ioo (hab : a < b) (hff' : ∀ x ∈ Ioo a b, HasDerivAt f (f' x) x)
(hgg' : ∀ x ∈ Ioo a b, HasDerivAt g (g' x) x) (hg' : ∀ x ∈ Ioo a b, g' x ≠ 0)
(hfa : Tendsto f (𝓝[>] a) (𝓝 0)) (hga : Tendsto g (𝓝[>] a) (𝓝 0))
(hdiv : Tendsto (fun x => f' x / g' x) (𝓝[>] a) l) :
Tendsto (fun x => f x / g x) (𝓝[>] a) l := by
have sub : ∀ x ∈ Ioo a b, Ioo a x ⊆ Ioo a b := fun x hx =>
Ioo_subset_Ioo (le_refl a) (le_of_lt hx.2)
have hg : ∀ x ∈ Ioo a b, g x ≠ 0 := by
intro x hx h
have : Tendsto g (𝓝[<] x) (𝓝 0) := by
rw [← h, ← nhdsWithin_Ioo_eq_nhdsLT hx.1]
exact ((hgg' x hx).continuousAt.continuousWithinAt.mono <| sub x hx).tendsto
obtain ⟨y, hyx, hy⟩ : ∃ c ∈ Ioo a x, g' c = 0 :=
exists_hasDerivAt_eq_zero' hx.1 hga this fun y hy => hgg' y <| sub x hx hy
exact hg' y (sub x hx hyx) hy
have : ∀ x ∈ Ioo a b, ∃ c ∈ Ioo a x, f x * g' c = g x * f' c := by
intro x hx
rw [← sub_zero (f x), ← sub_zero (g x)]
exact exists_ratio_hasDerivAt_eq_ratio_slope' g g' hx.1 f f' (fun y hy => hgg' y <| sub x hx hy)
(fun y hy => hff' y <| sub x hx hy) hga hfa
(tendsto_nhdsWithin_of_tendsto_nhds (hgg' x hx).continuousAt.tendsto)
(tendsto_nhdsWithin_of_tendsto_nhds (hff' x hx).continuousAt.tendsto)
choose! c hc using this
have : ∀ x ∈ Ioo a b, ((fun x' => f' x' / g' x') ∘ c) x = f x / g x := by grind
have cmp : ∀ x ∈ Ioo a b, a < c x ∧ c x < x := fun x hx => (hc x hx).1
rw [← nhdsWithin_Ioo_eq_nhdsGT hab]
apply tendsto_nhdsWithin_congr this
apply hdiv.comp
refine tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within _
(tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_const_nhds
(tendsto_nhdsWithin_of_tendsto_nhds tendsto_id) ?_ ?_) ?_
all_goals
apply eventually_nhdsWithin_of_forall
intro x hx
have := cmp x hx
try simp
linarith [this]
theorem lhopital_zero_right_on_Ico (hab : a < b) (hff' : ∀ x ∈ Ioo a b, HasDerivAt f (f' x) x)
(hgg' : ∀ x ∈ Ioo a b, HasDerivAt g (g' x) x) (hcf : ContinuousOn f (Ico a b))
(hcg : ContinuousOn g (Ico a b)) (hg' : ∀ x ∈ Ioo a b, g' x ≠ 0) (hfa : f a = 0) (hga : g a = 0)
(hdiv : Tendsto (fun x => f' x / g' x) (𝓝[>] a) l) :
Tendsto (fun x => f x / g x) (𝓝[>] a) l := by
refine lhopital_zero_right_on_Ioo hab hff' hgg' hg' ?_ ?_ hdiv
· rw [← hfa, ← nhdsWithin_Ioo_eq_nhdsGT hab]
exact ((hcf a <| left_mem_Ico.mpr hab).mono Ioo_subset_Ico_self).tendsto
· rw [← hga, ← nhdsWithin_Ioo_eq_nhdsGT hab]
exact ((hcg a <| left_mem_Ico.mpr hab).mono Ioo_subset_Ico_self).tendsto
theorem lhopital_zero_left_on_Ioo (hab : a < b) (hff' : ∀ x ∈ Ioo a b, HasDerivAt f (f' x) x)
(hgg' : ∀ x ∈ Ioo a b, HasDerivAt g (g' x) x) (hg' : ∀ x ∈ Ioo a b, g' x ≠ 0)
(hfb : Tendsto f (𝓝[<] b) (𝓝 0)) (hgb : Tendsto g (𝓝[<] b) (𝓝 0))
(hdiv : Tendsto (fun x => f' x / g' x) (𝓝[<] b) l) :
Tendsto (fun x => f x / g x) (𝓝[<] b) l := by
-- Here, we essentially compose by `Neg.neg`. The following is mostly technical details.
have hdnf : ∀ x ∈ -Ioo a b, HasDerivAt (f ∘ Neg.neg) (f' (-x) * -1) x := fun x hx =>
comp x (hff' (-x) hx) (hasDerivAt_neg x)
have hdng : ∀ x ∈ -Ioo a b, HasDerivAt (g ∘ Neg.neg) (g' (-x) * -1) x := fun x hx =>
comp x (hgg' (-x) hx) (hasDerivAt_neg x)
rw [neg_Ioo] at hdnf
rw [neg_Ioo] at hdng
have := lhopital_zero_right_on_Ioo (neg_lt_neg hab) hdnf hdng (by
intro x hx h
apply hg' _ (by rw [← neg_Ioo] at hx; exact hx)
rwa [mul_comm, ← neg_eq_neg_one_mul, neg_eq_zero] at h)
(hfb.comp tendsto_neg_nhdsGT_neg) (hgb.comp tendsto_neg_nhdsGT_neg)
(by
simp only [neg_div_neg_eq, mul_one, mul_neg]
exact hdiv.comp tendsto_neg_nhdsGT_neg)
have := this.comp tendsto_neg_nhdsLT
unfold Function.comp at this
simpa only [neg_neg]
theorem lhopital_zero_left_on_Ioc (hab : a < b) (hff' : ∀ x ∈ Ioo a b, HasDerivAt f (f' x) x)
(hgg' : ∀ x ∈ Ioo a b, HasDerivAt g (g' x) x) (hcf : ContinuousOn f (Ioc a b))
(hcg : ContinuousOn g (Ioc a b)) (hg' : ∀ x ∈ Ioo a b, g' x ≠ 0) (hfb : f b = 0) (hgb : g b = 0)
(hdiv : Tendsto (fun x => f' x / g' x) (𝓝[<] b) l) :
Tendsto (fun x => f x / g x) (𝓝[<] b) l := by
refine lhopital_zero_left_on_Ioo hab hff' hgg' hg' ?_ ?_ hdiv
· rw [← hfb, ← nhdsWithin_Ioo_eq_nhdsLT hab]
exact ((hcf b <| right_mem_Ioc.mpr hab).mono Ioo_subset_Ioc_self).tendsto
· rw [← hgb, ← nhdsWithin_Ioo_eq_nhdsLT hab]
exact ((hcg b <| right_mem_Ioc.mpr hab).mono Ioo_subset_Ioc_self).tendsto
theorem lhopital_zero_atTop_on_Ioi (hff' : ∀ x ∈ Ioi a, HasDerivAt f (f' x) x)
(hgg' : ∀ x ∈ Ioi a, HasDerivAt g (g' x) x) (hg' : ∀ x ∈ Ioi a, g' x ≠ 0)
(hftop : Tendsto f atTop (𝓝 0)) (hgtop : Tendsto g atTop (𝓝 0))
(hdiv : Tendsto (fun x => f' x / g' x) atTop l) : Tendsto (fun x => f x / g x) atTop l := by
obtain ⟨a', haa', ha'⟩ : ∃ a', a < a' ∧ 0 < a' := ⟨1 + max a 0,
⟨lt_of_le_of_lt (le_max_left a 0) (lt_one_add _),
lt_of_le_of_lt (le_max_right a 0) (lt_one_add _)⟩⟩
have fact1 : ∀ x : ℝ, x ∈ Ioo 0 a'⁻¹ → x ≠ 0 := fun _ hx => (ne_of_lt hx.1).symm
have fact2 (x) (hx : x ∈ Ioo 0 a'⁻¹) : a < x⁻¹ := lt_trans haa' ((lt_inv_comm₀ ha' hx.1).mpr hx.2)
have hdnf : ∀ x ∈ Ioo 0 a'⁻¹, HasDerivAt (f ∘ Inv.inv) (f' x⁻¹ * -(x ^ 2)⁻¹) x := fun x hx =>
comp x (hff' x⁻¹ <| fact2 x hx) (hasDerivAt_inv <| fact1 x hx)
have hdng : ∀ x ∈ Ioo 0 a'⁻¹, HasDerivAt (g ∘ Inv.inv) (g' x⁻¹ * -(x ^ 2)⁻¹) x := fun x hx =>
comp x (hgg' x⁻¹ <| fact2 x hx) (hasDerivAt_inv <| fact1 x hx)
have := lhopital_zero_right_on_Ioo (inv_pos.mpr ha') hdnf hdng
(by
intro x hx
refine mul_ne_zero ?_ (neg_ne_zero.mpr <| inv_ne_zero <| pow_ne_zero _ <| fact1 x hx)
exact hg' _ (fact2 x hx))
(hftop.comp tendsto_inv_nhdsGT_zero) (hgtop.comp tendsto_inv_nhdsGT_zero)
(by
refine (tendsto_congr' ?_).mp (hdiv.comp tendsto_inv_nhdsGT_zero)
filter_upwards [self_mem_nhdsWithin] with x (hx : 0 < x)
simp only [Function.comp_def]
rw [mul_div_mul_right]
exact neg_ne_zero.mpr (by positivity))
have := this.comp tendsto_inv_atTop_nhdsGT_zero
unfold Function.comp at this
simpa only [inv_inv]
theorem lhopital_zero_atBot_on_Iio (hff' : ∀ x ∈ Iio a, HasDerivAt f (f' x) x)
(hgg' : ∀ x ∈ Iio a, HasDerivAt g (g' x) x) (hg' : ∀ x ∈ Iio a, g' x ≠ 0)
(hfbot : Tendsto f atBot (𝓝 0)) (hgbot : Tendsto g atBot (𝓝 0))
(hdiv : Tendsto (fun x => f' x / g' x) atBot l) : Tendsto (fun x => f x / g x) atBot l := by
-- Here, we essentially compose by `Neg.neg`. The following is mostly technical details.
have hdnf : ∀ x ∈ -Iio a, HasDerivAt (f ∘ Neg.neg) (f' (-x) * -1) x := fun x hx =>
comp x (hff' (-x) hx) (hasDerivAt_neg x)
have hdng : ∀ x ∈ -Iio a, HasDerivAt (g ∘ Neg.neg) (g' (-x) * -1) x := fun x hx =>
comp x (hgg' (-x) hx) (hasDerivAt_neg x)
rw [neg_Iio] at hdnf
rw [neg_Iio] at hdng
have := lhopital_zero_atTop_on_Ioi hdnf hdng
(by
intro x hx h
apply hg' _ (by rw [← neg_Iio] at hx; exact hx)
rwa [mul_comm, ← neg_eq_neg_one_mul, neg_eq_zero] at h)
(hfbot.comp tendsto_neg_atTop_atBot) (hgbot.comp tendsto_neg_atTop_atBot)
(by
simp only [mul_one, mul_neg, neg_div_neg_eq]
exact (hdiv.comp tendsto_neg_atTop_atBot))
have := this.comp tendsto_neg_atBot_atTop
unfold Function.comp at this
simpa only [neg_neg]
end HasDerivAt
namespace deriv
theorem lhopital_zero_right_on_Ioo (hab : a < b) (hdf : DifferentiableOn ℝ f (Ioo a b))
(hg' : ∀ x ∈ Ioo a b, deriv g x ≠ 0) (hfa : Tendsto f (𝓝[>] a) (𝓝 0))
(hga : Tendsto g (𝓝[>] a) (𝓝 0))
(hdiv : Tendsto (fun x => (deriv f) x / (deriv g) x) (𝓝[>] a) l) :
Tendsto (fun x => f x / g x) (𝓝[>] a) l := by
have hdf : ∀ x ∈ Ioo a b, DifferentiableAt ℝ f x := fun x hx =>
(hdf x hx).differentiableAt (Ioo_mem_nhds hx.1 hx.2)
have hdg : ∀ x ∈ Ioo a b, DifferentiableAt ℝ g x := fun x hx =>
by_contradiction fun h => hg' x hx (deriv_zero_of_not_differentiableAt h)
exact HasDerivAt.lhopital_zero_right_on_Ioo hab (fun x hx => (hdf x hx).hasDerivAt)
(fun x hx => (hdg x hx).hasDerivAt) hg' hfa hga hdiv
theorem lhopital_zero_right_on_Ico (hab : a < b) (hdf : DifferentiableOn ℝ f (Ioo a b))
(hcf : ContinuousOn f (Ico a b)) (hcg : ContinuousOn g (Ico a b))
(hg' : ∀ x ∈ Ioo a b, (deriv g) x ≠ 0) (hfa : f a = 0) (hga : g a = 0)
(hdiv : Tendsto (fun x => (deriv f) x / (deriv g) x) (𝓝[>] a) l) :
Tendsto (fun x => f x / g x) (𝓝[>] a) l := by
refine lhopital_zero_right_on_Ioo hab hdf hg' ?_ ?_ hdiv
· rw [← hfa, ← nhdsWithin_Ioo_eq_nhdsGT hab]
exact ((hcf a <| left_mem_Ico.mpr hab).mono Ioo_subset_Ico_self).tendsto
· rw [← hga, ← nhdsWithin_Ioo_eq_nhdsGT hab]
exact ((hcg a <| left_mem_Ico.mpr hab).mono Ioo_subset_Ico_self).tendsto
theorem lhopital_zero_left_on_Ioo (hab : a < b) (hdf : DifferentiableOn ℝ f (Ioo a b))
(hg' : ∀ x ∈ Ioo a b, (deriv g) x ≠ 0) (hfb : Tendsto f (𝓝[<] b) (𝓝 0))
(hgb : Tendsto g (𝓝[<] b) (𝓝 0))
(hdiv : Tendsto (fun x => (deriv f) x / (deriv g) x) (𝓝[<] b) l) :
Tendsto (fun x => f x / g x) (𝓝[<] b) l := by
have hdf : ∀ x ∈ Ioo a b, DifferentiableAt ℝ f x := fun x hx =>
(hdf x hx).differentiableAt (Ioo_mem_nhds hx.1 hx.2)
have hdg : ∀ x ∈ Ioo a b, DifferentiableAt ℝ g x := fun x hx =>
by_contradiction fun h => hg' x hx (deriv_zero_of_not_differentiableAt h)
exact HasDerivAt.lhopital_zero_left_on_Ioo hab (fun x hx => (hdf x hx).hasDerivAt)
(fun x hx => (hdg x hx).hasDerivAt) hg' hfb hgb hdiv
theorem lhopital_zero_atTop_on_Ioi (hdf : DifferentiableOn ℝ f (Ioi a))
(hg' : ∀ x ∈ Ioi a, (deriv g) x ≠ 0) (hftop : Tendsto f atTop (𝓝 0))
(hgtop : Tendsto g atTop (𝓝 0)) (hdiv : Tendsto (fun x => (deriv f) x / (deriv g) x) atTop l) :
Tendsto (fun x => f x / g x) atTop l := by
have hdf : ∀ x ∈ Ioi a, DifferentiableAt ℝ f x := fun x hx =>
(hdf x hx).differentiableAt (Ioi_mem_nhds hx)
have hdg : ∀ x ∈ Ioi a, DifferentiableAt ℝ g x := fun x hx =>
by_contradiction fun h => hg' x hx (deriv_zero_of_not_differentiableAt h)
exact HasDerivAt.lhopital_zero_atTop_on_Ioi (fun x hx => (hdf x hx).hasDerivAt)
(fun x hx => (hdg x hx).hasDerivAt) hg' hftop hgtop hdiv
theorem lhopital_zero_atBot_on_Iio (hdf : DifferentiableOn ℝ f (Iio a))
(hg' : ∀ x ∈ Iio a, (deriv g) x ≠ 0) (hfbot : Tendsto f atBot (𝓝 0))
(hgbot : Tendsto g atBot (𝓝 0)) (hdiv : Tendsto (fun x => (deriv f) x / (deriv g) x) atBot l) :
Tendsto (fun x => f x / g x) atBot l := by
have hdf : ∀ x ∈ Iio a, DifferentiableAt ℝ f x := fun x hx =>
(hdf x hx).differentiableAt (Iio_mem_nhds hx)
have hdg : ∀ x ∈ Iio a, DifferentiableAt ℝ g x := fun x hx =>
by_contradiction fun h => hg' x hx (deriv_zero_of_not_differentiableAt h)
exact HasDerivAt.lhopital_zero_atBot_on_Iio (fun x hx => (hdf x hx).hasDerivAt)
(fun x hx => (hdg x hx).hasDerivAt) hg' hfbot hgbot hdiv
end deriv
/-!
## Generic versions
The following statements no longer any explicit interval, as they only require
conditions holding eventually.
-/
namespace HasDerivAt
/-- L'Hôpital's rule for approaching a real from the right, `HasDerivAt` version -/
theorem lhopital_zero_nhdsGT (hff' : ∀ᶠ x in 𝓝[>] a, HasDerivAt f (f' x) x)
(hgg' : ∀ᶠ x in 𝓝[>] a, HasDerivAt g (g' x) x) (hg' : ∀ᶠ x in 𝓝[>] a, g' x ≠ 0)
(hfa : Tendsto f (𝓝[>] a) (𝓝 0)) (hga : Tendsto g (𝓝[>] a) (𝓝 0))
(hdiv : Tendsto (fun x => f' x / g' x) (𝓝[>] a) l) :
Tendsto (fun x => f x / g x) (𝓝[>] a) l := by
rw [eventually_iff_exists_mem] at *
rcases hff' with ⟨s₁, hs₁, hff'⟩
rcases hgg' with ⟨s₂, hs₂, hgg'⟩
rcases hg' with ⟨s₃, hs₃, hg'⟩
let s := s₁ ∩ s₂ ∩ s₃
have hs : s ∈ 𝓝[>] a := inter_mem (inter_mem hs₁ hs₂) hs₃
rw [mem_nhdsGT_iff_exists_Ioo_subset] at hs
rcases hs with ⟨u, hau, hu⟩
refine lhopital_zero_right_on_Ioo hau ?_ ?_ ?_ hfa hga hdiv <;>
intro x hx <;> apply_assumption <;>
first | exact (hu hx).1.1 | exact (hu hx).1.2 | exact (hu hx).2
/-- L'Hôpital's rule for approaching a real from the left, `HasDerivAt` version -/
theorem lhopital_zero_nhdsLT (hff' : ∀ᶠ x in 𝓝[<] a, HasDerivAt f (f' x) x)
(hgg' : ∀ᶠ x in 𝓝[<] a, HasDerivAt g (g' x) x) (hg' : ∀ᶠ x in 𝓝[<] a, g' x ≠ 0)
(hfa : Tendsto f (𝓝[<] a) (𝓝 0)) (hga : Tendsto g (𝓝[<] a) (𝓝 0))
(hdiv : Tendsto (fun x => f' x / g' x) (𝓝[<] a) l) :
Tendsto (fun x => f x / g x) (𝓝[<] a) l := by
rw [eventually_iff_exists_mem] at *
rcases hff' with ⟨s₁, hs₁, hff'⟩
rcases hgg' with ⟨s₂, hs₂, hgg'⟩
rcases hg' with ⟨s₃, hs₃, hg'⟩
let s := s₁ ∩ s₂ ∩ s₃
have hs : s ∈ 𝓝[<] a := inter_mem (inter_mem hs₁ hs₂) hs₃
rw [mem_nhdsLT_iff_exists_Ioo_subset] at hs
rcases hs with ⟨l, hal, hl⟩
refine lhopital_zero_left_on_Ioo hal ?_ ?_ ?_ hfa hga hdiv <;> intro x hx <;> apply_assumption <;>
first | exact (hl hx).1.1| exact (hl hx).1.2| exact (hl hx).2
/-- L'Hôpital's rule for approaching a real, `HasDerivAt` version. This
does not require anything about the situation at `a` -/
theorem lhopital_zero_nhdsNE (hff' : ∀ᶠ x in 𝓝[≠] a, HasDerivAt f (f' x) x)
(hgg' : ∀ᶠ x in 𝓝[≠] a, HasDerivAt g (g' x) x) (hg' : ∀ᶠ x in 𝓝[≠] a, g' x ≠ 0)
(hfa : Tendsto f (𝓝[≠] a) (𝓝 0)) (hga : Tendsto g (𝓝[≠] a) (𝓝 0))
(hdiv : Tendsto (fun x => f' x / g' x) (𝓝[≠] a) l) :
Tendsto (fun x => f x / g x) (𝓝[≠] a) l := by
simp only [← Iio_union_Ioi, nhdsWithin_union, tendsto_sup, eventually_sup] at *
exact ⟨lhopital_zero_nhdsLT hff'.1 hgg'.1 hg'.1 hfa.1 hga.1 hdiv.1,
lhopital_zero_nhdsGT hff'.2 hgg'.2 hg'.2 hfa.2 hga.2 hdiv.2⟩
/-- **L'Hôpital's rule** for approaching a real, `HasDerivAt` version -/
theorem lhopital_zero_nhds (hff' : ∀ᶠ x in 𝓝 a, HasDerivAt f (f' x) x)
(hgg' : ∀ᶠ x in 𝓝 a, HasDerivAt g (g' x) x) (hg' : ∀ᶠ x in 𝓝 a, g' x ≠ 0)
(hfa : Tendsto f (𝓝 a) (𝓝 0)) (hga : Tendsto g (𝓝 a) (𝓝 0))
(hdiv : Tendsto (fun x => f' x / g' x) (𝓝 a) l) : Tendsto (fun x => f x / g x) (𝓝[≠] a) l := by
apply @lhopital_zero_nhdsNE _ _ _ f' _ g' <;>
(first | apply eventually_nhdsWithin_of_eventually_nhds |
apply tendsto_nhdsWithin_of_tendsto_nhds) <;> assumption
/-- L'Hôpital's rule for approaching +∞, `HasDerivAt` version -/
theorem lhopital_zero_atTop (hff' : ∀ᶠ x in atTop, HasDerivAt f (f' x) x)
(hgg' : ∀ᶠ x in atTop, HasDerivAt g (g' x) x) (hg' : ∀ᶠ x in atTop, g' x ≠ 0)
(hftop : Tendsto f atTop (𝓝 0)) (hgtop : Tendsto g atTop (𝓝 0))
(hdiv : Tendsto (fun x => f' x / g' x) atTop l) : Tendsto (fun x => f x / g x) atTop l := by
rw [eventually_iff_exists_mem] at *
rcases hff' with ⟨s₁, hs₁, hff'⟩
rcases hgg' with ⟨s₂, hs₂, hgg'⟩
rcases hg' with ⟨s₃, hs₃, hg'⟩
let s := s₁ ∩ s₂ ∩ s₃
have hs : s ∈ atTop := inter_mem (inter_mem hs₁ hs₂) hs₃
rw [mem_atTop_sets] at hs
rcases hs with ⟨l, hl⟩
have hl' : Ioi l ⊆ s := fun x hx => hl x (le_of_lt hx)
refine lhopital_zero_atTop_on_Ioi ?_ ?_ (fun x hx => hg' x <| (hl' hx).2) hftop hgtop hdiv <;>
intro x hx <;> apply_assumption <;> first | exact (hl' hx).1.1| exact (hl' hx).1.2
/-- L'Hôpital's rule for approaching -∞, `HasDerivAt` version -/
theorem lhopital_zero_atBot (hff' : ∀ᶠ x in atBot, HasDerivAt f (f' x) x)
(hgg' : ∀ᶠ x in atBot, HasDerivAt g (g' x) x) (hg' : ∀ᶠ x in atBot, g' x ≠ 0)
(hfbot : Tendsto f atBot (𝓝 0)) (hgbot : Tendsto g atBot (𝓝 0))
(hdiv : Tendsto (fun x => f' x / g' x) atBot l) : Tendsto (fun x => f x / g x) atBot l := by
rw [eventually_iff_exists_mem] at *
rcases hff' with ⟨s₁, hs₁, hff'⟩
rcases hgg' with ⟨s₂, hs₂, hgg'⟩
rcases hg' with ⟨s₃, hs₃, hg'⟩
let s := s₁ ∩ s₂ ∩ s₃
have hs : s ∈ atBot := inter_mem (inter_mem hs₁ hs₂) hs₃
rw [mem_atBot_sets] at hs
rcases hs with ⟨l, hl⟩
have hl' : Iio l ⊆ s := fun x hx => hl x (le_of_lt hx)
refine lhopital_zero_atBot_on_Iio ?_ ?_ (fun x hx => hg' x <| (hl' hx).2) hfbot hgbot hdiv <;>
intro x hx <;> apply_assumption <;> first | exact (hl' hx).1.1| exact (hl' hx).1.2
end HasDerivAt
namespace deriv
/-- **L'Hôpital's rule** for approaching a real from the right, `deriv` version -/
theorem lhopital_zero_nhdsGT (hdf : ∀ᶠ x in 𝓝[>] a, DifferentiableAt ℝ f x)
(hg' : ∀ᶠ x in 𝓝[>] a, deriv g x ≠ 0) (hfa : Tendsto f (𝓝[>] a) (𝓝 0))
(hga : Tendsto g (𝓝[>] a) (𝓝 0))
(hdiv : Tendsto (fun x => (deriv f) x / (deriv g) x) (𝓝[>] a) l) :
Tendsto (fun x => f x / g x) (𝓝[>] a) l := by
have hdg : ∀ᶠ x in 𝓝[>] a, DifferentiableAt ℝ g x :=
hg'.mono fun _ hg' => by_contradiction fun h => hg' (deriv_zero_of_not_differentiableAt h)
have hdf' : ∀ᶠ x in 𝓝[>] a, HasDerivAt f (deriv f x) x :=
hdf.mono fun _ => DifferentiableAt.hasDerivAt
have hdg' : ∀ᶠ x in 𝓝[>] a, HasDerivAt g (deriv g x) x :=
hdg.mono fun _ => DifferentiableAt.hasDerivAt
exact HasDerivAt.lhopital_zero_nhdsGT hdf' hdg' hg' hfa hga hdiv
/-- **L'Hôpital's rule** for approaching a real from the left, `deriv` version -/
theorem lhopital_zero_nhdsLT (hdf : ∀ᶠ x in 𝓝[<] a, DifferentiableAt ℝ f x)
(hg' : ∀ᶠ x in 𝓝[<] a, deriv g x ≠ 0) (hfa : Tendsto f (𝓝[<] a) (𝓝 0))
(hga : Tendsto g (𝓝[<] a) (𝓝 0))
(hdiv : Tendsto (fun x => (deriv f) x / (deriv g) x) (𝓝[<] a) l) :
Tendsto (fun x => f x / g x) (𝓝[<] a) l := by
have hdg : ∀ᶠ x in 𝓝[<] a, DifferentiableAt ℝ g x :=
hg'.mono fun _ hg' => by_contradiction fun h => hg' (deriv_zero_of_not_differentiableAt h)
have hdf' : ∀ᶠ x in 𝓝[<] a, HasDerivAt f (deriv f x) x :=
hdf.mono fun _ => DifferentiableAt.hasDerivAt
have hdg' : ∀ᶠ x in 𝓝[<] a, HasDerivAt g (deriv g x) x :=
hdg.mono fun _ => DifferentiableAt.hasDerivAt
exact HasDerivAt.lhopital_zero_nhdsLT hdf' hdg' hg' hfa hga hdiv
/-- **L'Hôpital's rule** for approaching a real, `deriv` version. This
does not require anything about the situation at `a` -/
theorem lhopital_zero_nhdsNE (hdf : ∀ᶠ x in 𝓝[≠] a, DifferentiableAt ℝ f x)
(hg' : ∀ᶠ x in 𝓝[≠] a, deriv g x ≠ 0) (hfa : Tendsto f (𝓝[≠] a) (𝓝 0))
(hga : Tendsto g (𝓝[≠] a) (𝓝 0))
(hdiv : Tendsto (fun x => (deriv f) x / (deriv g) x) (𝓝[≠] a) l) :
Tendsto (fun x => f x / g x) (𝓝[≠] a) l := by
simp only [← Iio_union_Ioi, nhdsWithin_union, tendsto_sup, eventually_sup] at *
exact ⟨lhopital_zero_nhdsLT hdf.1 hg'.1 hfa.1 hga.1 hdiv.1,
lhopital_zero_nhdsGT hdf.2 hg'.2 hfa.2 hga.2 hdiv.2⟩
/-- **L'Hôpital's rule** for approaching a real, `deriv` version -/
theorem lhopital_zero_nhds (hdf : ∀ᶠ x in 𝓝 a, DifferentiableAt ℝ f x)
(hg' : ∀ᶠ x in 𝓝 a, deriv g x ≠ 0) (hfa : Tendsto f (𝓝 a) (𝓝 0)) (hga : Tendsto g (𝓝 a) (𝓝 0))
(hdiv : Tendsto (fun x => (deriv f) x / (deriv g) x) (𝓝 a) l) :
Tendsto (fun x => f x / g x) (𝓝[≠] a) l := by
apply lhopital_zero_nhdsNE <;>
(first | apply eventually_nhdsWithin_of_eventually_nhds |
apply tendsto_nhdsWithin_of_tendsto_nhds) <;> assumption
/-- **L'Hôpital's rule** for approaching +∞, `deriv` version -/
theorem lhopital_zero_atTop (hdf : ∀ᶠ x : ℝ in atTop, DifferentiableAt ℝ f x)
(hg' : ∀ᶠ x : ℝ in atTop, deriv g x ≠ 0) (hftop : Tendsto f atTop (𝓝 0))
(hgtop : Tendsto g atTop (𝓝 0)) (hdiv : Tendsto (fun x => (deriv f) x / (deriv g) x) atTop l) :
Tendsto (fun x => f x / g x) atTop l := by
have hdg : ∀ᶠ x in atTop, DifferentiableAt ℝ g x := hg'.mp
(Eventually.of_forall fun _ hg' =>
by_contradiction fun h => hg' (deriv_zero_of_not_differentiableAt h))
have hdf' : ∀ᶠ x in atTop, HasDerivAt f (deriv f x) x :=
hdf.mono fun _ => DifferentiableAt.hasDerivAt
have hdg' : ∀ᶠ x in atTop, HasDerivAt g (deriv g x) x :=
hdg.mono fun _ => DifferentiableAt.hasDerivAt
exact HasDerivAt.lhopital_zero_atTop hdf' hdg' hg' hftop hgtop hdiv
/-- **L'Hôpital's rule** for approaching -∞, `deriv` version -/
theorem lhopital_zero_atBot (hdf : ∀ᶠ x : ℝ in atBot, DifferentiableAt ℝ f x)
(hg' : ∀ᶠ x : ℝ in atBot, deriv g x ≠ 0) (hfbot : Tendsto f atBot (𝓝 0))
(hgbot : Tendsto g atBot (𝓝 0)) (hdiv : Tendsto (fun x => (deriv f) x / (deriv g) x) atBot l) :
Tendsto (fun x => f x / g x) atBot l := by
have hdg : ∀ᶠ x in atBot, DifferentiableAt ℝ g x :=
hg'.mono fun _ hg' => by_contradiction fun h => hg' (deriv_zero_of_not_differentiableAt h)
have hdf' : ∀ᶠ x in atBot, HasDerivAt f (deriv f x) x :=
hdf.mono fun _ => DifferentiableAt.hasDerivAt
have hdg' : ∀ᶠ x in atBot, HasDerivAt g (deriv g x) x :=
hdg.mono fun _ => DifferentiableAt.hasDerivAt
exact HasDerivAt.lhopital_zero_atBot hdf' hdg' hg' hfbot hgbot hdiv
end deriv |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/DiffContOnCl.lean | import Mathlib.Analysis.Normed.Module.RCLike.Real
import Mathlib.Analysis.Calculus.FDeriv.Add
import Mathlib.Analysis.Calculus.FDeriv.Mul
/-!
# Functions differentiable on a domain and continuous on its closure
Many theorems in complex analysis assume that a function is complex differentiable on a domain and
is continuous on its closure. In this file we define a predicate `DiffContOnCl` that expresses
this property and prove basic facts about this predicate.
-/
open Set Filter Metric
open scoped Topology
variable (𝕜 : Type*) {E F G : Type*} [NontriviallyNormedField 𝕜] [NormedAddCommGroup E]
[NormedAddCommGroup F] [NormedSpace 𝕜 E] [NormedSpace 𝕜 F] [NormedAddCommGroup G]
[NormedSpace 𝕜 G] {f g : E → F} {s t : Set E} {x : E}
/-- A predicate saying that a function is differentiable on a set and is continuous on its
closure. This is a common assumption in complex analysis. -/
structure DiffContOnCl (f : E → F) (s : Set E) : Prop where
protected differentiableOn : DifferentiableOn 𝕜 f s
protected continuousOn : ContinuousOn f (closure s)
variable {𝕜}
theorem DifferentiableOn.diffContOnCl (h : DifferentiableOn 𝕜 f (closure s)) : DiffContOnCl 𝕜 f s :=
⟨h.mono subset_closure, h.continuousOn⟩
theorem Differentiable.diffContOnCl (h : Differentiable 𝕜 f) : DiffContOnCl 𝕜 f s :=
⟨h.differentiableOn, h.continuous.continuousOn⟩
theorem IsClosed.diffContOnCl_iff (hs : IsClosed s) : DiffContOnCl 𝕜 f s ↔ DifferentiableOn 𝕜 f s :=
⟨fun h => h.differentiableOn, fun h => ⟨h, hs.closure_eq.symm ▸ h.continuousOn⟩⟩
theorem diffContOnCl_univ : DiffContOnCl 𝕜 f univ ↔ Differentiable 𝕜 f :=
isClosed_univ.diffContOnCl_iff.trans differentiableOn_univ
theorem diffContOnCl_const {c : F} : DiffContOnCl 𝕜 (fun _ : E => c) s :=
⟨differentiableOn_const c, continuousOn_const⟩
namespace DiffContOnCl
theorem comp {g : G → E} {t : Set G} (hf : DiffContOnCl 𝕜 f s) (hg : DiffContOnCl 𝕜 g t)
(h : MapsTo g t s) : DiffContOnCl 𝕜 (f ∘ g) t :=
⟨hf.1.comp hg.1 h, hf.2.comp hg.2 <| h.closure_of_continuousOn hg.2⟩
theorem continuousOn_ball [NormedSpace ℝ E] {x : E} {r : ℝ} (h : DiffContOnCl 𝕜 f (ball x r)) :
ContinuousOn f (closedBall x r) := by
rcases eq_or_ne r 0 with (rfl | hr)
· rw [closedBall_zero]
exact continuousOn_singleton f x
· rw [← closure_ball x hr]
exact h.continuousOn
theorem mk_ball {x : E} {r : ℝ} (hd : DifferentiableOn 𝕜 f (ball x r))
(hc : ContinuousOn f (closedBall x r)) : DiffContOnCl 𝕜 f (ball x r) :=
⟨hd, hc.mono <| closure_ball_subset_closedBall⟩
protected theorem differentiableAt (h : DiffContOnCl 𝕜 f s) (hs : IsOpen s) (hx : x ∈ s) :
DifferentiableAt 𝕜 f x :=
h.differentiableOn.differentiableAt <| hs.mem_nhds hx
theorem differentiableAt' (h : DiffContOnCl 𝕜 f s) (hx : s ∈ 𝓝 x) : DifferentiableAt 𝕜 f x :=
h.differentiableOn.differentiableAt hx
protected theorem mono (h : DiffContOnCl 𝕜 f s) (ht : t ⊆ s) : DiffContOnCl 𝕜 f t :=
⟨h.differentiableOn.mono ht, h.continuousOn.mono (closure_mono ht)⟩
theorem add (hf : DiffContOnCl 𝕜 f s) (hg : DiffContOnCl 𝕜 g s) : DiffContOnCl 𝕜 (f + g) s :=
⟨hf.1.add hg.1, hf.2.add hg.2⟩
theorem add_const (hf : DiffContOnCl 𝕜 f s) (c : F) : DiffContOnCl 𝕜 (fun x => f x + c) s :=
hf.add diffContOnCl_const
theorem const_add (hf : DiffContOnCl 𝕜 f s) (c : F) : DiffContOnCl 𝕜 (fun x => c + f x) s :=
diffContOnCl_const.add hf
theorem neg (hf : DiffContOnCl 𝕜 f s) : DiffContOnCl 𝕜 (-f) s :=
⟨hf.1.neg, hf.2.neg⟩
theorem sub (hf : DiffContOnCl 𝕜 f s) (hg : DiffContOnCl 𝕜 g s) : DiffContOnCl 𝕜 (f - g) s :=
⟨hf.1.sub hg.1, hf.2.sub hg.2⟩
theorem sub_const (hf : DiffContOnCl 𝕜 f s) (c : F) : DiffContOnCl 𝕜 (fun x => f x - c) s :=
hf.sub diffContOnCl_const
theorem const_sub (hf : DiffContOnCl 𝕜 f s) (c : F) : DiffContOnCl 𝕜 (fun x => c - f x) s :=
diffContOnCl_const.sub hf
theorem const_smul {R : Type*} [Semiring R] [Module R F] [SMulCommClass 𝕜 R F]
[ContinuousConstSMul R F] (hf : DiffContOnCl 𝕜 f s) (c : R) : DiffContOnCl 𝕜 (c • f) s :=
⟨hf.1.const_smul c, hf.2.const_smul c⟩
theorem smul {𝕜' : Type*} [NontriviallyNormedField 𝕜'] [NormedAlgebra 𝕜 𝕜'] [NormedSpace 𝕜' F]
[IsScalarTower 𝕜 𝕜' F] {c : E → 𝕜'} {f : E → F} {s : Set E} (hc : DiffContOnCl 𝕜 c s)
(hf : DiffContOnCl 𝕜 f s) : DiffContOnCl 𝕜 (fun x => c x • f x) s :=
⟨hc.1.smul hf.1, hc.2.smul hf.2⟩
theorem smul_const {𝕜' : Type*} [NontriviallyNormedField 𝕜'] [NormedAlgebra 𝕜 𝕜']
[NormedSpace 𝕜' F] [IsScalarTower 𝕜 𝕜' F] {c : E → 𝕜'} {s : Set E} (hc : DiffContOnCl 𝕜 c s)
(y : F) : DiffContOnCl 𝕜 (fun x => c x • y) s :=
hc.smul diffContOnCl_const
theorem inv {f : E → 𝕜} (hf : DiffContOnCl 𝕜 f s) (h₀ : ∀ x ∈ closure s, f x ≠ 0) :
DiffContOnCl 𝕜 f⁻¹ s :=
⟨differentiableOn_inv.comp hf.1 fun _ hx => h₀ _ (subset_closure hx), hf.2.inv₀ h₀⟩
end DiffContOnCl
theorem Differentiable.comp_diffContOnCl {g : G → E} {t : Set G} (hf : Differentiable 𝕜 f)
(hg : DiffContOnCl 𝕜 g t) : DiffContOnCl 𝕜 (f ∘ g) t :=
hf.diffContOnCl.comp hg (mapsTo_image _ _)
theorem DifferentiableOn.diffContOnCl_ball {U : Set E} {c : E} {R : ℝ} (hf : DifferentiableOn 𝕜 f U)
(hc : closedBall c R ⊆ U) : DiffContOnCl 𝕜 f (ball c R) :=
DiffContOnCl.mk_ball (hf.mono (ball_subset_closedBall.trans hc)) (hf.continuousOn.mono hc) |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/TangentCone.lean | import Mathlib.Analysis.Calculus.TangentCone.Basic
import Mathlib.Analysis.Calculus.TangentCone.Defs
import Mathlib.Analysis.Calculus.TangentCone.DimOne
import Mathlib.Analysis.Calculus.TangentCone.Pi
import Mathlib.Analysis.Calculus.TangentCone.Prod
import Mathlib.Analysis.Calculus.TangentCone.ProperSpace
import Mathlib.Analysis.Calculus.TangentCone.Real
deprecated_module (since := "2025-11-06") |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/Gradient/Basic.lean | import Mathlib.Analysis.InnerProductSpace.Dual
import Mathlib.Analysis.Calculus.FDeriv.Basic
import Mathlib.Analysis.Calculus.Deriv.Basic
/-!
# Gradient
## Main Definitions
Let `f` be a function from a Hilbert Space `F` to `𝕜` (`𝕜` is `ℝ` or `ℂ`), `x` be a point in `F`
and `f'` be a vector in F. Then
`HasGradientWithinAt f f' s x`
says that `f` has a gradient `f'` at `x`, where the domain of interest
is restricted to `s`. We also have
`HasGradientAt f f' x := HasGradientWithinAt f f' x univ`
## Main results
This file develops the following aspects of the theory of gradients:
* definitions of gradients, both within a set and on the whole space.
* translating between `HasGradientAtFilter` and `HasFDerivAtFilter`,
`HasGradientWithinAt` and `HasFDerivWithinAt`, `HasGradientAt` and `HasFDerivAt`,
`gradient` and `fderiv`.
* uniqueness of gradients.
* translating between `HasGradientAtFilter` and `HasDerivAtFilter`,
`HasGradientAt` and `HasDerivAt`, `gradient` and `deriv` when `F = 𝕜`.
* the congruence of the gradient.
* the gradient of constant functions.
* the continuity of a function admitting a gradient.
-/
open Topology InnerProductSpace Function Set
noncomputable section
variable {𝕜 F : Type*} [RCLike 𝕜]
variable [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [CompleteSpace F]
variable {f : F → 𝕜} {f' x : F}
/-- A function `f` has the gradient `f'` as derivative along the filter `L` if
`f x' = f x + ⟨f', x' - x⟩ + o (x' - x)` when `x'` converges along the filter `L`. -/
def HasGradientAtFilter (f : F → 𝕜) (f' x : F) (L : Filter F) :=
HasFDerivAtFilter f (toDual 𝕜 F f') x L
/-- `f` has the gradient `f'` at the point `x` within the subset `s` if
`f x' = f x + ⟨f', x' - x⟩ + o (x' - x)` where `x'` converges to `x` inside `s`. -/
def HasGradientWithinAt (f : F → 𝕜) (f' : F) (s : Set F) (x : F) :=
HasGradientAtFilter f f' x (𝓝[s] x)
/-- `f` has the gradient `f'` at the point `x` if
`f x' = f x + ⟨f', x' - x⟩ + o (x' - x)` where `x'` converges to `x`. -/
def HasGradientAt (f : F → 𝕜) (f' x : F) :=
HasGradientAtFilter f f' x (𝓝 x)
/-- Gradient of `f` at the point `x` within the set `s`, if it exists. Zero otherwise.
If the derivative exists (i.e., `∃ f', HasGradientWithinAt f f' s x`), then
`f x' = f x + ⟨f', x' - x⟩ + o (x' - x)` where `x'` converges to `x` inside `s`. -/
def gradientWithin (f : F → 𝕜) (s : Set F) (x : F) : F :=
(toDual 𝕜 F).symm (fderivWithin 𝕜 f s x)
/-- Gradient of `f` at the point `x`, if it exists. Zero otherwise.
Denoted as `∇` within the Gradient namespace.
If the derivative exists (i.e., `∃ f', HasGradientAt f f' x`), then
`f x' = f x + ⟨f', x' - x⟩ + o (x' - x)` where `x'` converges to `x`. -/
def gradient (f : F → 𝕜) (x : F) : F :=
(toDual 𝕜 F).symm (fderiv 𝕜 f x)
@[inherit_doc]
scoped[Gradient] notation "∇" => gradient
local notation "⟪" x ", " y "⟫" => inner 𝕜 x y
open scoped Gradient
variable {s : Set F} {L : Filter F}
theorem hasGradientWithinAt_iff_hasFDerivWithinAt {s : Set F} :
HasGradientWithinAt f f' s x ↔ HasFDerivWithinAt f (toDual 𝕜 F f') s x :=
Iff.rfl
theorem hasFDerivWithinAt_iff_hasGradientWithinAt {frechet : StrongDual 𝕜 F} {s : Set F} :
HasFDerivWithinAt f frechet s x ↔ HasGradientWithinAt f ((toDual 𝕜 F).symm frechet) s x := by
rw [hasGradientWithinAt_iff_hasFDerivWithinAt, (toDual 𝕜 F).apply_symm_apply frechet]
theorem hasGradientAt_iff_hasFDerivAt :
HasGradientAt f f' x ↔ HasFDerivAt f (toDual 𝕜 F f') x :=
Iff.rfl
theorem hasFDerivAt_iff_hasGradientAt {frechet : StrongDual 𝕜 F} :
HasFDerivAt f frechet x ↔ HasGradientAt f ((toDual 𝕜 F).symm frechet) x := by
rw [hasGradientAt_iff_hasFDerivAt, (toDual 𝕜 F).apply_symm_apply frechet]
alias ⟨HasGradientWithinAt.hasFDerivWithinAt, _⟩ := hasGradientWithinAt_iff_hasFDerivWithinAt
alias ⟨HasFDerivWithinAt.hasGradientWithinAt, _⟩ := hasFDerivWithinAt_iff_hasGradientWithinAt
alias ⟨HasGradientAt.hasFDerivAt, _⟩ := hasGradientAt_iff_hasFDerivAt
alias ⟨HasFDerivAt.hasGradientAt, _⟩ := hasFDerivAt_iff_hasGradientAt
theorem gradient_eq_zero_of_not_differentiableAt (h : ¬DifferentiableAt 𝕜 f x) : ∇ f x = 0 := by
rw [gradient, fderiv_zero_of_not_differentiableAt h, map_zero]
theorem HasGradientAt.unique {gradf gradg : F}
(hf : HasGradientAt f gradf x) (hg : HasGradientAt f gradg x) :
gradf = gradg :=
(toDual 𝕜 F).injective (hf.hasFDerivAt.unique hg.hasFDerivAt)
theorem DifferentiableAt.hasGradientAt (h : DifferentiableAt 𝕜 f x) :
HasGradientAt f (∇ f x) x := by
rw [hasGradientAt_iff_hasFDerivAt, gradient, (toDual 𝕜 F).apply_symm_apply (fderiv 𝕜 f x)]
exact h.hasFDerivAt
theorem HasGradientAt.differentiableAt (h : HasGradientAt f f' x) :
DifferentiableAt 𝕜 f x :=
h.hasFDerivAt.differentiableAt
theorem DifferentiableWithinAt.hasGradientWithinAt (h : DifferentiableWithinAt 𝕜 f s x) :
HasGradientWithinAt f (gradientWithin f s x) s x := by
rw [hasGradientWithinAt_iff_hasFDerivWithinAt, gradientWithin,
(toDual 𝕜 F).apply_symm_apply (fderivWithin 𝕜 f s x)]
exact h.hasFDerivWithinAt
theorem HasGradientWithinAt.differentiableWithinAt (h : HasGradientWithinAt f f' s x) :
DifferentiableWithinAt 𝕜 f s x :=
h.hasFDerivWithinAt.differentiableWithinAt
@[simp]
theorem hasGradientWithinAt_univ : HasGradientWithinAt f f' univ x ↔ HasGradientAt f f' x := by
rw [hasGradientWithinAt_iff_hasFDerivWithinAt, hasGradientAt_iff_hasFDerivAt]
exact hasFDerivWithinAt_univ
theorem DifferentiableOn.hasGradientAt (h : DifferentiableOn 𝕜 f s) (hs : s ∈ 𝓝 x) :
HasGradientAt f (∇ f x) x :=
(h.hasFDerivAt hs).hasGradientAt
theorem HasGradientAt.gradient (h : HasGradientAt f f' x) : ∇ f x = f' :=
h.differentiableAt.hasGradientAt.unique h
theorem gradient_eq {f' : F → F} (h : ∀ x, HasGradientAt f (f' x) x) : ∇ f = f' :=
funext fun x => (h x).gradient
section OneDimension
variable {g : 𝕜 → 𝕜} {g' u : 𝕜} {L' : Filter 𝕜}
theorem HasGradientAtFilter.hasDerivAtFilter (h : HasGradientAtFilter g g' u L') :
HasDerivAtFilter g (starRingEnd 𝕜 g') u L' := by
tauto
theorem HasDerivAtFilter.hasGradientAtFilter (h : HasDerivAtFilter g g' u L') :
HasGradientAtFilter g (starRingEnd 𝕜 g') u L' := by
have : ContinuousLinearMap.smulRight (1 : 𝕜 →L[𝕜] 𝕜) g' = (toDual 𝕜 𝕜) (starRingEnd 𝕜 g') := by
ext; simp
rwa [HasGradientAtFilter, ← this]
theorem HasGradientAt.hasDerivAt (h : HasGradientAt g g' u) :
HasDerivAt g (starRingEnd 𝕜 g') u := by
rw [hasGradientAt_iff_hasFDerivAt, hasFDerivAt_iff_hasDerivAt] at h
simpa using h
theorem HasDerivAt.hasGradientAt (h : HasDerivAt g g' u) :
HasGradientAt g (starRingEnd 𝕜 g') u := by
rw [hasGradientAt_iff_hasFDerivAt, hasFDerivAt_iff_hasDerivAt]
simpa
theorem gradient_eq_deriv : ∇ g u = starRingEnd 𝕜 (deriv g u) := by
by_cases h : DifferentiableAt 𝕜 g u
· rw [h.hasGradientAt.hasDerivAt.deriv, RCLike.conj_conj]
· rw [gradient_eq_zero_of_not_differentiableAt h, deriv_zero_of_not_differentiableAt h, map_zero]
end OneDimension
section OneDimensionReal
variable {g : ℝ → ℝ} {g' u : ℝ} {L' : Filter ℝ}
theorem HasGradientAtFilter.hasDerivAtFilter' (h : HasGradientAtFilter g g' u L') :
HasDerivAtFilter g g' u L' := h.hasDerivAtFilter
theorem HasDerivAtFilter.hasGradientAtFilter' (h : HasDerivAtFilter g g' u L') :
HasGradientAtFilter g g' u L' := h.hasGradientAtFilter
theorem HasGradientAt.hasDerivAt' (h : HasGradientAt g g' u) :
HasDerivAt g g' u := h.hasDerivAt
theorem HasDerivAt.hasGradientAt' (h : HasDerivAt g g' u) :
HasGradientAt g g' u := h.hasGradientAt
theorem gradient_eq_deriv' : ∇ g u = deriv g u := gradient_eq_deriv
end OneDimensionReal
open Filter
section GradientProperties
theorem hasGradientAtFilter_iff_isLittleO :
HasGradientAtFilter f f' x L ↔
(fun x' : F => f x' - f x - ⟪f', x' - x⟫) =o[L] fun x' => x' - x :=
hasFDerivAtFilter_iff_isLittleO ..
theorem hasGradientWithinAt_iff_isLittleO :
HasGradientWithinAt f f' s x ↔
(fun x' : F => f x' - f x - ⟪f', x' - x⟫) =o[𝓝[s] x] fun x' => x' - x :=
hasGradientAtFilter_iff_isLittleO
theorem hasGradientWithinAt_iff_tendsto :
HasGradientWithinAt f f' s x ↔
Tendsto (fun x' => ‖x' - x‖⁻¹ * ‖f x' - f x - ⟪f', x' - x⟫‖) (𝓝[s] x) (𝓝 0) :=
hasFDerivAtFilter_iff_tendsto
theorem hasGradientAt_iff_isLittleO : HasGradientAt f f' x ↔
(fun x' : F => f x' - f x - ⟪f', x' - x⟫) =o[𝓝 x] fun x' => x' - x :=
hasGradientAtFilter_iff_isLittleO
theorem hasGradientAt_iff_tendsto :
HasGradientAt f f' x ↔
Tendsto (fun x' => ‖x' - x‖⁻¹ * ‖f x' - f x - ⟪f', x' - x⟫‖) (𝓝 x) (𝓝 0) :=
hasFDerivAtFilter_iff_tendsto
theorem HasGradientAtFilter.isBigO_sub (h : HasGradientAtFilter f f' x L) :
(fun x' => f x' - f x) =O[L] fun x' => x' - x :=
HasFDerivAtFilter.isBigO_sub h
theorem hasGradientWithinAt_congr_set' {s t : Set F} (y : F) (h : s =ᶠ[𝓝[{y}ᶜ] x] t) :
HasGradientWithinAt f f' s x ↔ HasGradientWithinAt f f' t x :=
hasFDerivWithinAt_congr_set' y h
theorem hasGradientWithinAt_congr_set {s t : Set F} (h : s =ᶠ[𝓝 x] t) :
HasGradientWithinAt f f' s x ↔ HasGradientWithinAt f f' t x :=
hasFDerivWithinAt_congr_set h
theorem hasGradientAt_iff_isLittleO_nhds_zero : HasGradientAt f f' x ↔
(fun h => f (x + h) - f x - ⟪f', h⟫) =o[𝓝 0] fun h => h :=
hasFDerivAt_iff_isLittleO_nhds_zero
end GradientProperties
section congr
/-! ### Congruence properties of the Gradient -/
variable {f₀ f₁ : F → 𝕜} {f₀' f₁' : F} {t : Set F}
theorem Filter.EventuallyEq.hasGradientAtFilter_iff (h₀ : f₀ =ᶠ[L] f₁) (hx : f₀ x = f₁ x)
(h₁ : f₀' = f₁') : HasGradientAtFilter f₀ f₀' x L ↔ HasGradientAtFilter f₁ f₁' x L :=
h₀.hasFDerivAtFilter_iff hx (by simp [h₁])
theorem HasGradientAtFilter.congr_of_eventuallyEq (h : HasGradientAtFilter f f' x L)
(hL : f₁ =ᶠ[L] f) (hx : f₁ x = f x) : HasGradientAtFilter f₁ f' x L := by
rwa [hL.hasGradientAtFilter_iff hx rfl]
theorem HasGradientWithinAt.congr_mono (h : HasGradientWithinAt f f' s x) (ht : ∀ x ∈ t, f₁ x = f x)
(hx : f₁ x = f x) (h₁ : t ⊆ s) : HasGradientWithinAt f₁ f' t x :=
HasFDerivWithinAt.congr_mono h ht hx h₁
theorem HasGradientWithinAt.congr (h : HasGradientWithinAt f f' s x) (hs : ∀ x ∈ s, f₁ x = f x)
(hx : f₁ x = f x) : HasGradientWithinAt f₁ f' s x :=
h.congr_mono hs hx (by tauto)
theorem HasGradientWithinAt.congr_of_mem (h : HasGradientWithinAt f f' s x)
(hs : ∀ x ∈ s, f₁ x = f x) (hx : x ∈ s) : HasGradientWithinAt f₁ f' s x :=
h.congr hs (hs _ hx)
theorem HasGradientWithinAt.congr_of_eventuallyEq (h : HasGradientWithinAt f f' s x)
(h₁ : f₁ =ᶠ[𝓝[s] x] f) (hx : f₁ x = f x) : HasGradientWithinAt f₁ f' s x :=
HasGradientAtFilter.congr_of_eventuallyEq h h₁ hx
theorem HasGradientWithinAt.congr_of_eventuallyEq_of_mem (h : HasGradientWithinAt f f' s x)
(h₁ : f₁ =ᶠ[𝓝[s] x] f) (hx : x ∈ s) : HasGradientWithinAt f₁ f' s x :=
h.congr_of_eventuallyEq h₁ (h₁.eq_of_nhdsWithin hx)
theorem HasGradientAt.congr_of_eventuallyEq (h : HasGradientAt f f' x) (h₁ : f₁ =ᶠ[𝓝 x] f) :
HasGradientAt f₁ f' x :=
HasGradientAtFilter.congr_of_eventuallyEq h h₁ (mem_of_mem_nhds h₁ :)
theorem Filter.EventuallyEq.gradient_eq (hL : f₁ =ᶠ[𝓝 x] f) : ∇ f₁ x = ∇ f x := by
unfold gradient
rwa [Filter.EventuallyEq.fderiv_eq]
protected theorem Filter.EventuallyEq.gradient (h : f₁ =ᶠ[𝓝 x] f) : ∇ f₁ =ᶠ[𝓝 x] ∇ f :=
h.eventuallyEq_nhds.mono fun _ h => h.gradient_eq
end congr
/-! ### The Gradient of constant functions -/
section Const
variable (c : 𝕜) (s x L)
theorem hasGradientAtFilter_const : HasGradientAtFilter (fun _ => c) 0 x L := by
rw [HasGradientAtFilter, map_zero]; apply hasFDerivAtFilter_const c x L
theorem hasGradientWithinAt_const : HasGradientWithinAt (fun _ => c) 0 s x :=
hasGradientAtFilter_const _ _ _
theorem hasGradientAt_const : HasGradientAt (fun _ => c) 0 x :=
hasGradientAtFilter_const _ _ _
theorem gradient_fun_const : ∇ (fun _ => c) x = 0 := by simp [gradient]
theorem gradient_const : ∇ (const F c) x = 0 := gradient_fun_const x c
@[simp]
theorem gradient_fun_const' : (∇ fun _ : F => c) = fun _ => 0 :=
funext fun x => gradient_const x c
@[simp]
theorem gradient_const' : ∇ (const F c) = 0 := gradient_fun_const' c
end Const
section Continuous
/-! ### Continuity of a function admitting a gradient -/
nonrec theorem HasGradientAtFilter.tendsto_nhds (hL : L ≤ 𝓝 x) (h : HasGradientAtFilter f f' x L) :
Tendsto f L (𝓝 (f x)) :=
h.tendsto_nhds hL
theorem HasGradientWithinAt.continuousWithinAt (h : HasGradientWithinAt f f' s x) :
ContinuousWithinAt f s x :=
HasGradientAtFilter.tendsto_nhds inf_le_left h
theorem HasGradientAt.continuousAt (h : HasGradientAt f f' x) : ContinuousAt f x :=
HasGradientAtFilter.tendsto_nhds le_rfl h
protected theorem HasGradientAt.continuousOn {f' : F → F} (h : ∀ x ∈ s, HasGradientAt f (f' x) x) :
ContinuousOn f s :=
fun x hx => (h x hx).continuousAt.continuousWithinAt
end Continuous |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/AddTorsor/AffineMap.lean | import Mathlib.Analysis.Calculus.ContDiff.Operations
import Mathlib.Topology.Algebra.ContinuousAffineMap
import Mathlib.Analysis.Normed.Group.AddTorsor
/-!
# Smooth affine maps
This file contains results about smoothness of affine maps.
## Main definitions:
* `ContinuousAffineMap.contDiff`: a continuous affine map is smooth
-/
namespace ContinuousAffineMap
variable {𝕜 V W : Type*} [NontriviallyNormedField 𝕜]
variable [NormedAddCommGroup V] [NormedSpace 𝕜 V]
variable [NormedAddCommGroup W] [NormedSpace 𝕜 W]
/-- A continuous affine map between normed vector spaces is smooth. -/
theorem contDiff {n : WithTop ℕ∞} (f : V →ᴬ[𝕜] W) : ContDiff 𝕜 n f := by
rw [f.decomp]
apply f.contLinear.contDiff.add
exact contDiff_const
theorem differentiable (f : V →ᴬ[𝕜] W) : Differentiable 𝕜 f :=
f.contDiff.differentiable le_rfl
theorem differentiableAt (f : V →ᴬ[𝕜] W) {x : V} : DifferentiableAt 𝕜 f x :=
f.differentiable x
theorem differentiableOn (f : V →ᴬ[𝕜] W) {s : Set V} : DifferentiableOn 𝕜 f s :=
f.differentiable.differentiableOn
theorem differentiableWithinAt (f : V →ᴬ[𝕜] W) {s : Set V} {x : V} :
DifferentiableWithinAt 𝕜 f s x :=
f.differentiableAt.differentiableWithinAt
@[simp] theorem fderiv (f : V →ᴬ[𝕜] W) {x : V} : fderiv 𝕜 f x = f.contLinear := by
conv_lhs => rw [f.decomp]
rw [fderiv_add f.contLinear.differentiableAt]; swap
· exact differentiableAt_const _
simp only [fderiv_const, Pi.zero_apply, add_zero, ContinuousLinearMap.fderiv]
end ContinuousAffineMap |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/AddTorsor/Coord.lean | import Mathlib.Analysis.Calculus.AddTorsor.AffineMap
import Mathlib.Analysis.Normed.Affine.AddTorsorBases
/-!
# Barycentric coordinates are smooth
-/
variable {ι 𝕜 E P : Type*} [NontriviallyNormedField 𝕜] [CompleteSpace 𝕜]
variable [NormedAddCommGroup E] [NormedSpace 𝕜 E]
variable [MetricSpace P] [NormedAddTorsor E P]
variable [FiniteDimensional 𝕜 E]
theorem smooth_barycentric_coord (b : AffineBasis ι 𝕜 E) (i : ι) : ContDiff 𝕜 ⊤ (b.coord i) :=
(⟨b.coord i, continuous_barycentric_coord b i⟩ : E →ᴬ[𝕜] 𝕜).contDiff |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/FDeriv/Pow.lean | import Mathlib.Analysis.Calculus.FDeriv.Mul
import Mathlib.Analysis.Calculus.FDeriv.Comp
/-!
# Fréchet Derivative of `f x ^ n`, `n : ℕ`
In this file we prove that the Fréchet derivative of `fun x => f x ^ n`,
where `n` is a natural number, is `n • f x ^ (n - 1)) • f'`.
Additionally, we prove the case for non-commutative rings (with primed names like `fderiv_pow'`),
where the result is instead `∑ i ∈ Finset.range n, f x ^ (n.pred - i) •> f' <• f x ^ i`.
For detailed documentation of the Fréchet derivative,
see the module docstring of `Mathlib/Analysis/Calculus/FDeriv/Basic.lean`.
## Keywords
derivative, power
-/
variable {𝕜 𝔸 E : Type*}
section NormedRing
variable [NontriviallyNormedField 𝕜] [NormedRing 𝔸] [NormedAddCommGroup E]
variable [NormedAlgebra 𝕜 𝔸] [NormedSpace 𝕜 E] {f : E → 𝔸} {f' : E →L[𝕜] 𝔸} {x : E} {s : Set E}
open scoped RightActions
private theorem aux (f : E → 𝔸) (f' : E →L[𝕜] 𝔸) (x : E) (n : ℕ) :
f x •> ∑ i ∈ Finset.range (n + 1), f x ^ ((n + 1).pred - i) •> f' <• f x ^ i
+ f' <• (f x ^ (n + 1)) =
∑ i ∈ Finset.range (n + 1 + 1), f x ^ ((n + 1 + 1).pred - i) •> f' <• f x ^ i := by
rw [Finset.sum_range_succ _ (n + 1), Finset.smul_sum]
simp only [Nat.pred_eq_sub_one, add_tsub_cancel_right, tsub_self, pow_zero, one_smul]
simp_rw [smul_comm (_ : 𝔸) (_ : 𝔸ᵐᵒᵖ), smul_smul, ← pow_succ']
congr! 5 with x hx
simp only [Finset.mem_range, Nat.lt_succ_iff] at hx
rw [tsub_add_eq_add_tsub hx]
theorem HasStrictFDerivAt.fun_pow' (h : HasStrictFDerivAt f f' x) (n : ℕ) :
HasStrictFDerivAt (fun x ↦ f x ^ n)
(∑ i ∈ Finset.range n, f x ^ (n.pred - i) •> f' <• f x ^ i) x :=
match n with
| 0 => by simpa using hasStrictFDerivAt_const 1 x
| 1 => by simpa using h
| n + 1 + 1 => by
have := h.mul' (h.fun_pow' (n + 1))
simp_rw [pow_succ' _ (n + 1)]
refine this.congr_fderiv <| aux _ _ _ _
theorem HasStrictFDerivAt.pow' (h : HasStrictFDerivAt f f' x) (n : ℕ) :
HasStrictFDerivAt (f ^ n)
(∑ i ∈ Finset.range n, f x ^ (n.pred - i) •> f' <• f x ^ i) x := h.fun_pow' n
theorem hasStrictFDerivAt_pow' (n : ℕ) {x : 𝔸} :
HasStrictFDerivAt (𝕜 := 𝕜) (fun x ↦ x ^ n)
(∑ i ∈ Finset.range n, x ^ (n.pred - i) •> ContinuousLinearMap.id 𝕜 _ <• x ^ i) x :=
hasStrictFDerivAt_id _ |>.pow' n
theorem HasFDerivWithinAt.fun_pow' (h : HasFDerivWithinAt f f' s x) (n : ℕ) :
HasFDerivWithinAt (fun x ↦ f x ^ n)
(∑ i ∈ Finset.range n, f x ^ (n.pred - i) •> f' <• f x ^ i) s x :=
match n with
| 0 => by simpa using hasFDerivWithinAt_const 1 x s
| 1 => by simpa using h
| n + 1 + 1 => by
have := h.mul' (h.fun_pow' (n + 1))
simp_rw [pow_succ' _ (n + 1)]
exact this.congr_fderiv <| aux _ _ _ _
theorem HasFDerivWithinAt.pow' (h : HasFDerivWithinAt f f' s x) (n : ℕ) :
HasFDerivWithinAt (f ^ n)
(∑ i ∈ Finset.range n, f x ^ (n.pred - i) •> f' <• f x ^ i) s x := h.fun_pow' n
theorem hasFDerivWithinAt_pow' (n : ℕ) {x : 𝔸} {s : Set 𝔸} :
HasFDerivWithinAt (𝕜 := 𝕜) (fun x ↦ x ^ n)
(∑ i ∈ Finset.range n, x ^ (n.pred - i) •> ContinuousLinearMap.id 𝕜 _ <• x ^ i) s x :=
hasFDerivWithinAt_id _ _ |>.pow' n
theorem HasFDerivAt.fun_pow' (h : HasFDerivAt f f' x) (n : ℕ) :
HasFDerivAt (fun x ↦ f x ^ n) (∑ i ∈ Finset.range n, f x ^ (n.pred - i) •> f' <• f x ^ i) x :=
match n with
| 0 => by simpa using hasFDerivAt_const 1 x
| 1 => by simpa using h
| n + 1 + 1 => by
have := h.mul' (h.fun_pow' (n + 1))
simp_rw [pow_succ' _ (n + 1)]
exact this.congr_fderiv <| aux _ _ _ _
theorem HasFDerivAt.pow' (h : HasFDerivAt f f' x) (n : ℕ) :
HasFDerivAt (f ^ n) (∑ i ∈ Finset.range n, f x ^ (n.pred - i) •> f' <• f x ^ i) x :=
h.fun_pow' n
theorem hasFDerivAt_pow' (n : ℕ) {x : 𝔸} :
HasFDerivAt (𝕜 := 𝕜) (fun x ↦ x ^ n)
(∑ i ∈ Finset.range n, x ^ (n.pred - i) •> ContinuousLinearMap.id 𝕜 _ <• x ^ i) x :=
hasFDerivAt_id _ |>.pow' n
@[fun_prop]
theorem DifferentiableWithinAt.fun_pow (hf : DifferentiableWithinAt 𝕜 f s x) (n : ℕ) :
DifferentiableWithinAt 𝕜 (fun x => f x ^ n) s x :=
let ⟨_, hf'⟩ := hf; ⟨_, hf'.pow' n⟩
@[fun_prop]
theorem DifferentiableWithinAt.pow (hf : DifferentiableWithinAt 𝕜 f s x) :
∀ n : ℕ, DifferentiableWithinAt 𝕜 (f ^ n) s x :=
hf.fun_pow
theorem differentiableWithinAt_pow (n : ℕ) {x : 𝔸} {s : Set 𝔸} :
DifferentiableWithinAt 𝕜 (fun x : 𝔸 => x ^ n) s x :=
differentiableWithinAt_id.pow _
@[simp, fun_prop]
theorem DifferentiableAt.fun_pow (hf : DifferentiableAt 𝕜 f x) (n : ℕ) :
DifferentiableAt 𝕜 (fun x => f x ^ n) x :=
differentiableWithinAt_univ.mp <| hf.differentiableWithinAt.pow n
@[simp, fun_prop]
theorem DifferentiableAt.pow (hf : DifferentiableAt 𝕜 f x) (n : ℕ) :
DifferentiableAt 𝕜 (f ^ n) x := hf.fun_pow n
theorem differentiableAt_pow (n : ℕ) {x : 𝔸} : DifferentiableAt 𝕜 (fun x : 𝔸 => x ^ n) x :=
differentiableAt_id.pow _
@[fun_prop]
theorem DifferentiableOn.fun_pow (hf : DifferentiableOn 𝕜 f s) (n : ℕ) :
DifferentiableOn 𝕜 (fun x => f x ^ n) s := fun x h => (hf x h).pow n
@[fun_prop]
theorem DifferentiableOn.pow (hf : DifferentiableOn 𝕜 f s) (n : ℕ) :
DifferentiableOn 𝕜 (f ^ n) s := hf.fun_pow n
theorem differentiableOn_pow (n : ℕ) {s : Set 𝔸} : DifferentiableOn 𝕜 (fun x : 𝔸 => x ^ n) s :=
differentiableOn_id.pow n
@[simp, fun_prop]
theorem Differentiable.fun_pow (hf : Differentiable 𝕜 f) (n : ℕ) :
Differentiable 𝕜 fun x => f x ^ n :=
fun x => (hf x).pow n
@[simp, fun_prop]
theorem Differentiable.pow (hf : Differentiable 𝕜 f) (n : ℕ) : Differentiable 𝕜 (f ^ n) :=
hf.fun_pow n
theorem differentiable_pow (n : ℕ) : Differentiable 𝕜 fun x : 𝔸 => x ^ n :=
differentiable_id.pow _
theorem fderiv_fun_pow' (n : ℕ) (hf : DifferentiableAt 𝕜 f x) :
fderiv 𝕜 (fun x ↦ f x ^ n) x
= (∑ i ∈ Finset.range n, f x ^ (n.pred - i) •> fderiv 𝕜 f x <• f x ^ i) :=
hf.hasFDerivAt.pow' n |>.fderiv
theorem fderiv_pow' (n : ℕ) (hf : DifferentiableAt 𝕜 f x) :
fderiv 𝕜 (f ^ n) x
= (∑ i ∈ Finset.range n, f x ^ (n.pred - i) •> fderiv 𝕜 f x <• f x ^ i) :=
fderiv_fun_pow' n hf
theorem fderiv_pow_ring' {x : 𝔸} (n : ℕ) :
fderiv 𝕜 (fun x : 𝔸 ↦ x ^ n) x
= (∑ i ∈ Finset.range n, x ^ (n.pred - i) •> .id _ _ <• x ^ i) := by
rw [fderiv_fun_pow' n differentiableAt_fun_id, fderiv_id']
theorem fderivWithin_fun_pow' (hxs : UniqueDiffWithinAt 𝕜 s x)
(n : ℕ) (hf : DifferentiableWithinAt 𝕜 f s x) :
fderivWithin 𝕜 (fun x ↦ f x ^ n) s x
= (∑ i ∈ Finset.range n, f x ^ (n.pred - i) •> fderivWithin 𝕜 f s x <• f x ^ i) :=
hf.hasFDerivWithinAt.pow' n |>.fderivWithin hxs
theorem fderivWithin_pow' (hxs : UniqueDiffWithinAt 𝕜 s x)
(n : ℕ) (hf : DifferentiableWithinAt 𝕜 f s x) :
fderivWithin 𝕜 (f ^ n) s x
= (∑ i ∈ Finset.range n, f x ^ (n.pred - i) •> fderivWithin 𝕜 f s x <• f x ^ i) :=
fderivWithin_fun_pow' hxs n hf
theorem fderivWithin_pow_ring' {s : Set 𝔸} {x : 𝔸} (n : ℕ) (hxs : UniqueDiffWithinAt 𝕜 s x) :
fderivWithin 𝕜 (fun x : 𝔸 ↦ x ^ n) s x
= (∑ i ∈ Finset.range n, x ^ (n.pred - i) •> .id _ _ <• x ^ i) := by
rw [fderivWithin_fun_pow' hxs n differentiableAt_fun_id.differentiableWithinAt,
fderivWithin_id' hxs]
end NormedRing
section NormedCommRing
variable [NontriviallyNormedField 𝕜] [NormedCommRing 𝔸] [NormedAddCommGroup E]
variable [NormedAlgebra 𝕜 𝔸] [NormedSpace 𝕜 E] {f : E → 𝔸} {f' : E →L[𝕜] 𝔸} {x : E} {s : Set E}
private theorem aux_sum_eq_pow (n : ℕ) :
∑ i ∈ Finset.range n, MulOpposite.op (f x ^ i) • f x ^ (n.pred - i) • f' =
(n • f x ^ (n - 1)) • f' := by
simp_rw [op_smul_eq_smul, smul_smul, ← pow_add, ← Finset.sum_smul]
rw [Finset.sum_eq_card_nsmul, Finset.card_range, smul_assoc]
intro a ha
congr
exact add_tsub_cancel_of_le (Nat.le_pred_of_lt <| Finset.mem_range.1 ha)
theorem HasStrictFDerivAt.pow (h : HasStrictFDerivAt f f' x) (n : ℕ) :
HasStrictFDerivAt (fun x ↦ f x ^ n) ((n • f x ^ (n - 1)) • f') x :=
h.pow' n |>.congr_fderiv <| aux_sum_eq_pow _
theorem hasStrictFDerivAt_pow (n : ℕ) {x : 𝔸} :
HasStrictFDerivAt (𝕜 := 𝕜)
(fun x : 𝔸 ↦ x ^ n) ((n • x ^ (n - 1)) • ContinuousLinearMap.id 𝕜 𝔸) x :=
hasStrictFDerivAt_id _ |>.pow n
theorem HasFDerivWithinAt.pow (h : HasFDerivWithinAt f f' s x) (n : ℕ) :
HasFDerivWithinAt (fun x ↦ f x ^ n) ((n • f x ^ (n - 1)) • f') s x :=
h.pow' n |>.congr_fderiv <| aux_sum_eq_pow _
theorem hasFDerivWithinAt_pow (n : ℕ) {x : 𝔸} {s : Set 𝔸} :
HasFDerivWithinAt (𝕜 := 𝕜)
(fun x : 𝔸 ↦ x ^ n) ((n • x ^ (n - 1)) • ContinuousLinearMap.id 𝕜 𝔸) s x :=
hasFDerivWithinAt_id _ _ |>.pow n
theorem HasFDerivAt.pow (h : HasFDerivAt f f' x) (n : ℕ) :
HasFDerivAt (fun x ↦ f x ^ n) ((n • f x ^ (n - 1)) • f') x :=
h.pow' n |>.congr_fderiv <| aux_sum_eq_pow _
theorem hasFDerivAt_pow (n : ℕ) {x : 𝔸} :
HasFDerivAt (𝕜 := 𝕜)
(fun x : 𝔸 ↦ x ^ n) ((n • x ^ (n - 1)) • ContinuousLinearMap.id 𝕜 𝔸) x :=
hasFDerivAt_id _ |>.pow n
theorem fderiv_fun_pow (n : ℕ) (hf : DifferentiableAt 𝕜 f x) :
fderiv 𝕜 (fun x ↦ f x ^ n) x = (n • f x ^ (n - 1)) • fderiv 𝕜 f x :=
hf.hasFDerivAt.pow n |>.fderiv
theorem fderiv_pow (n : ℕ) (hf : DifferentiableAt 𝕜 f x) :
fderiv 𝕜 (fun x ↦ f x ^ n) x = (n • f x ^ (n - 1)) • fderiv 𝕜 f x :=
fderiv_fun_pow n hf
theorem fderiv_pow_ring {x : 𝔸} (n : ℕ) :
fderiv 𝕜 (fun x : 𝔸 ↦ x ^ n) x = (n • x ^ (n - 1)) • .id _ _ := by
rw [fderiv_fun_pow n differentiableAt_fun_id, fderiv_id']
theorem fderivWithin_fun_pow (hxs : UniqueDiffWithinAt 𝕜 s x)
(n : ℕ) (hf : DifferentiableWithinAt 𝕜 f s x) :
fderivWithin 𝕜 (fun x ↦ f x ^ n) s x = (n • f x ^ (n - 1)) • fderivWithin 𝕜 f s x :=
hf.hasFDerivWithinAt.pow n |>.fderivWithin hxs
theorem fderivWithin_pow (hxs : UniqueDiffWithinAt 𝕜 s x)
(n : ℕ) (hf : DifferentiableWithinAt 𝕜 f s x) :
fderivWithin 𝕜 (f ^ n) s x = (n • f x ^ (n - 1)) • fderivWithin 𝕜 f s x :=
fderivWithin_fun_pow hxs n hf
theorem fderivWithin_pow_ring {s : Set 𝔸} {x : 𝔸} (n : ℕ) (hxs : UniqueDiffWithinAt 𝕜 s x) :
fderivWithin 𝕜 (fun x : 𝔸 ↦ x ^ n) s x = (n • x ^ (n - 1)) • .id _ _ := by
rw [fderivWithin_fun_pow hxs n differentiableAt_fun_id.differentiableWithinAt,
fderivWithin_id' hxs]
end NormedCommRing |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/FDeriv/Analytic.lean | import Mathlib.Analysis.Analytic.CPolynomial
import Mathlib.Analysis.Analytic.Inverse
import Mathlib.Analysis.Analytic.Within
import Mathlib.Analysis.Calculus.Deriv.Basic
import Mathlib.Analysis.Calculus.ContDiff.FTaylorSeries
import Mathlib.Analysis.Calculus.FDeriv.Add
import Mathlib.Analysis.Calculus.FDeriv.Prod
import Mathlib.Analysis.Normed.Module.Completion
/-!
# Fréchet derivatives of analytic functions.
A function expressible as a power series at a point has a Fréchet derivative there.
Also the special case in terms of `deriv` when the domain is 1-dimensional.
As an application, we show that continuous multilinear maps are smooth. We also compute their
iterated derivatives, in `ContinuousMultilinearMap.iteratedFDeriv_eq`.
## Main definitions and results
* `AnalyticAt.differentiableAt` : an analytic function at a point is differentiable there.
* `AnalyticOnNhd.fderiv` : in a complete space, if a function is analytic on a
neighborhood of a set `s`, so is its derivative.
* `AnalyticOnNhd.fderiv_of_isOpen` : if a function is analytic on a neighborhood of an
open set `s`, so is its derivative.
* `AnalyticOn.fderivWithin` : if a function is analytic on a set of unique differentiability,
so is its derivative within this set.
* `OpenPartialHomeomorph.analyticAt_symm` : if an open partial homeomorphism `f` is analytic at a
point `f.symm a`, with invertible derivative, then its inverse is analytic at `a`.
## Comments on completeness
Some theorems need a complete space, some don't, for the following reason.
(1) If a function is analytic at a point `x`, then it is differentiable there (with derivative given
by the first term in the power series). There is no issue of convergence here.
(2) If a function has a power series on a ball `B (x, r)`, there is no guarantee that the power
series for the derivative will converge at `y ≠ x`, if the space is not complete. So, to deduce
that `f` is differentiable at `y`, one needs completeness in general.
(3) However, if a function `f` has a power series on a ball `B (x, r)`, and is a priori known to be
differentiable at some point `y ≠ x`, then the power series for the derivative of `f` will
automatically converge at `y`, towards the given derivative: this follows from the facts that this
is true in the completion (thanks to the previous point) and that the map to the completion is
an embedding.
(4) Therefore, if one assumes `AnalyticOn 𝕜 f s` where `s` is an open set, then `f` is analytic
therefore differentiable at every point of `s`, by (1), so by (3) the power series for its
derivative converges on whole balls. Therefore, the derivative of `f` is also analytic on `s`. The
same holds if `s` is merely a set with unique differentials.
(5) However, this does not work for `AnalyticOnNhd 𝕜 f s`, as we don't get for free
differentiability at points in a neighborhood of `s`. Therefore, the theorem that deduces
`AnalyticOnNhd 𝕜 (fderiv 𝕜 f) s` from `AnalyticOnNhd 𝕜 f s` requires completeness of the space.
-/
open Filter Asymptotics Set
open scoped ENNReal Topology
universe u v
variable {𝕜 : Type*} [NontriviallyNormedField 𝕜]
variable {E : Type u} [NormedAddCommGroup E] [NormedSpace 𝕜 E]
variable {F : Type v} [NormedAddCommGroup F] [NormedSpace 𝕜 F]
section fderiv
variable {p : FormalMultilinearSeries 𝕜 E F} {r : ℝ≥0∞}
variable {f : E → F} {x : E} {s : Set E}
/-- A function which is analytic within a set is strictly differentiable there. Since we
don't have a predicate `HasStrictFDerivWithinAt`, we spell out what it would mean. -/
theorem HasFPowerSeriesWithinAt.hasStrictFDerivWithinAt (h : HasFPowerSeriesWithinAt f p s x) :
(fun y ↦ f y.1 - f y.2 - (continuousMultilinearCurryFin1 𝕜 E F (p 1)) (y.1 - y.2))
=o[𝓝[insert x s ×ˢ insert x s] (x, x)] fun y ↦ y.1 - y.2 := by
refine h.isBigO_image_sub_norm_mul_norm_sub.trans_isLittleO (IsLittleO.of_norm_right ?_)
refine isLittleO_iff_exists_eq_mul.2 ⟨fun y => ‖y - (x, x)‖, ?_, EventuallyEq.rfl⟩
apply Tendsto.mono_left _ nhdsWithin_le_nhds
refine (continuous_id.sub continuous_const).norm.tendsto' _ _ ?_
rw [_root_.id, sub_self, norm_zero]
theorem HasFPowerSeriesAt.hasStrictFDerivAt (h : HasFPowerSeriesAt f p x) :
HasStrictFDerivAt f (continuousMultilinearCurryFin1 𝕜 E F (p 1)) x := by
simpa only [hasStrictFDerivAt_iff_isLittleO, Set.insert_eq_of_mem, Set.mem_univ,
Set.univ_prod_univ, nhdsWithin_univ]
using (h.hasFPowerSeriesWithinAt (s := Set.univ)).hasStrictFDerivWithinAt
theorem HasFPowerSeriesWithinAt.hasFDerivWithinAt (h : HasFPowerSeriesWithinAt f p s x) :
HasFDerivWithinAt f (continuousMultilinearCurryFin1 𝕜 E F (p 1)) (insert x s) x := by
rw [HasFDerivWithinAt, hasFDerivAtFilter_iff_isLittleO, isLittleO_iff]
intro c hc
have : Tendsto (fun y ↦ (y, x)) (𝓝[insert x s] x) (𝓝[insert x s ×ˢ insert x s] (x, x)) := by
rw [nhdsWithin_prod_eq]
exact Tendsto.prodMk tendsto_id (tendsto_const_nhdsWithin (by simp))
exact this (isLittleO_iff.1 h.hasStrictFDerivWithinAt hc)
theorem HasFPowerSeriesAt.hasFDerivAt (h : HasFPowerSeriesAt f p x) :
HasFDerivAt f (continuousMultilinearCurryFin1 𝕜 E F (p 1)) x :=
h.hasStrictFDerivAt.hasFDerivAt
theorem HasFPowerSeriesWithinAt.differentiableWithinAt (h : HasFPowerSeriesWithinAt f p s x) :
DifferentiableWithinAt 𝕜 f (insert x s) x :=
h.hasFDerivWithinAt.differentiableWithinAt
theorem HasFPowerSeriesAt.differentiableAt (h : HasFPowerSeriesAt f p x) : DifferentiableAt 𝕜 f x :=
h.hasFDerivAt.differentiableAt
theorem AnalyticWithinAt.differentiableWithinAt (h : AnalyticWithinAt 𝕜 f s x) :
DifferentiableWithinAt 𝕜 f (insert x s) x := by
obtain ⟨p, hp⟩ := h
exact hp.differentiableWithinAt
@[fun_prop]
theorem AnalyticAt.differentiableAt : AnalyticAt 𝕜 f x → DifferentiableAt 𝕜 f x
| ⟨_, hp⟩ => hp.differentiableAt
theorem AnalyticAt.differentiableWithinAt (h : AnalyticAt 𝕜 f x) : DifferentiableWithinAt 𝕜 f s x :=
h.differentiableAt.differentiableWithinAt
theorem HasFPowerSeriesWithinAt.fderivWithin_eq
(h : HasFPowerSeriesWithinAt f p s x) (hu : UniqueDiffWithinAt 𝕜 (insert x s) x) :
fderivWithin 𝕜 f (insert x s) x = continuousMultilinearCurryFin1 𝕜 E F (p 1) :=
h.hasFDerivWithinAt.fderivWithin hu
theorem HasFPowerSeriesAt.fderiv_eq (h : HasFPowerSeriesAt f p x) :
fderiv 𝕜 f x = continuousMultilinearCurryFin1 𝕜 E F (p 1) :=
h.hasFDerivAt.fderiv
theorem AnalyticAt.hasStrictFDerivAt (h : AnalyticAt 𝕜 f x) :
HasStrictFDerivAt f (fderiv 𝕜 f x) x := by
rcases h with ⟨p, hp⟩
rw [hp.fderiv_eq]
exact hp.hasStrictFDerivAt
theorem HasFPowerSeriesWithinOnBall.differentiableOn [CompleteSpace F]
(h : HasFPowerSeriesWithinOnBall f p s x r) :
DifferentiableOn 𝕜 f (insert x s ∩ EMetric.ball x r) := by
intro y hy
have Z := (h.analyticWithinAt_of_mem hy).differentiableWithinAt
rcases eq_or_ne y x with rfl | hy
· exact Z.mono inter_subset_left
· apply (Z.mono (subset_insert _ _)).mono_of_mem_nhdsWithin
suffices s ∈ 𝓝[insert x s] y from nhdsWithin_mono _ inter_subset_left this
rw [nhdsWithin_insert_of_ne hy]
exact self_mem_nhdsWithin
theorem HasFPowerSeriesOnBall.differentiableOn [CompleteSpace F]
(h : HasFPowerSeriesOnBall f p x r) : DifferentiableOn 𝕜 f (EMetric.ball x r) := fun _ hy =>
(h.analyticAt_of_mem hy).differentiableWithinAt
theorem HasFPowerSeriesAt.eventually_differentiableAt
[CompleteSpace F] (hp : HasFPowerSeriesAt f p x) :
∀ᶠ z in 𝓝 x, DifferentiableAt 𝕜 f z := by
obtain ⟨r, hp⟩ := hp
exact hp.differentiableOn.eventually_differentiableAt (EMetric.ball_mem_nhds _ hp.r_pos)
theorem AnalyticOn.differentiableOn (h : AnalyticOn 𝕜 f s) : DifferentiableOn 𝕜 f s :=
fun y hy ↦ (h y hy).differentiableWithinAt.mono (by simp)
theorem AnalyticOnNhd.differentiableOn (h : AnalyticOnNhd 𝕜 f s) : DifferentiableOn 𝕜 f s :=
fun y hy ↦ (h y hy).differentiableWithinAt
theorem HasFPowerSeriesWithinOnBall.hasFDerivWithinAt [CompleteSpace F]
(h : HasFPowerSeriesWithinOnBall f p s x r)
{y : E} (hy : (‖y‖₊ : ℝ≥0∞) < r) (h'y : x + y ∈ insert x s) :
HasFDerivWithinAt f (continuousMultilinearCurryFin1 𝕜 E F (p.changeOrigin y 1))
(insert x s) (x + y) := by
rcases eq_or_ne y 0 with rfl | h''y
· convert (h.changeOrigin hy h'y).hasFPowerSeriesWithinAt.hasFDerivWithinAt
simp
· have Z := (h.changeOrigin hy h'y).hasFPowerSeriesWithinAt.hasFDerivWithinAt
apply (Z.mono (subset_insert _ _)).mono_of_mem_nhdsWithin
rw [nhdsWithin_insert_of_ne]
· exact self_mem_nhdsWithin
· simpa using h''y
theorem HasFPowerSeriesOnBall.hasFDerivAt [CompleteSpace F] (h : HasFPowerSeriesOnBall f p x r)
{y : E} (hy : (‖y‖₊ : ℝ≥0∞) < r) :
HasFDerivAt f (continuousMultilinearCurryFin1 𝕜 E F (p.changeOrigin y 1)) (x + y) :=
(h.changeOrigin hy).hasFPowerSeriesAt.hasFDerivAt
theorem HasFPowerSeriesWithinOnBall.fderivWithin_eq [CompleteSpace F]
(h : HasFPowerSeriesWithinOnBall f p s x r)
{y : E} (hy : (‖y‖₊ : ℝ≥0∞) < r) (h'y : x + y ∈ insert x s) (hu : UniqueDiffOn 𝕜 (insert x s)) :
fderivWithin 𝕜 f (insert x s) (x + y) =
continuousMultilinearCurryFin1 𝕜 E F (p.changeOrigin y 1) :=
(h.hasFDerivWithinAt hy h'y).fderivWithin (hu _ h'y)
theorem HasFPowerSeriesOnBall.fderiv_eq [CompleteSpace F] (h : HasFPowerSeriesOnBall f p x r)
{y : E} (hy : (‖y‖₊ : ℝ≥0∞) < r) :
fderiv 𝕜 f (x + y) = continuousMultilinearCurryFin1 𝕜 E F (p.changeOrigin y 1) :=
(h.hasFDerivAt hy).fderiv
/-- If a function has a power series on a ball, then so does its derivative. -/
protected theorem HasFPowerSeriesOnBall.fderiv [CompleteSpace F]
(h : HasFPowerSeriesOnBall f p x r) :
HasFPowerSeriesOnBall (fderiv 𝕜 f) p.derivSeries x r := by
refine .congr (f := fun z ↦ continuousMultilinearCurryFin1 𝕜 E F (p.changeOrigin (z - x) 1)) ?_
fun z hz ↦ ?_
· refine continuousMultilinearCurryFin1 𝕜 E F
|>.toContinuousLinearEquiv.toContinuousLinearMap.comp_hasFPowerSeriesOnBall ?_
simpa using ((p.hasFPowerSeriesOnBall_changeOrigin 1
(h.r_pos.trans_le h.r_le)).mono h.r_pos h.r_le).comp_sub x
dsimp only
rw [← h.fderiv_eq, add_sub_cancel]
simpa only [edist_eq_enorm_sub, EMetric.mem_ball] using hz
/-- If a function has a power series within a set on a ball, then so does its derivative. -/
protected theorem HasFPowerSeriesWithinOnBall.fderivWithin [CompleteSpace F]
(h : HasFPowerSeriesWithinOnBall f p s x r) (hu : UniqueDiffOn 𝕜 (insert x s)) :
HasFPowerSeriesWithinOnBall (fderivWithin 𝕜 f (insert x s)) p.derivSeries s x r := by
refine .congr' (f := fun z ↦ continuousMultilinearCurryFin1 𝕜 E F (p.changeOrigin (z - x) 1)) ?_
(fun z hz ↦ ?_)
· refine continuousMultilinearCurryFin1 𝕜 E F
|>.toContinuousLinearEquiv.toContinuousLinearMap.comp_hasFPowerSeriesWithinOnBall ?_
apply HasFPowerSeriesOnBall.hasFPowerSeriesWithinOnBall
simpa using ((p.hasFPowerSeriesOnBall_changeOrigin 1
(h.r_pos.trans_le h.r_le)).mono h.r_pos h.r_le).comp_sub x
· dsimp only
rw [← h.fderivWithin_eq _ _ hu, add_sub_cancel]
· simpa only [edist_eq_enorm_sub, EMetric.mem_ball] using hz.2
· simpa using hz.1
/-- If a function has a power series within a set on a ball, then so does its derivative. For a
version without completeness, but assuming that the function is analytic on the set `s`, see
`HasFPowerSeriesWithinOnBall.fderivWithin_of_mem_of_analyticOn`. -/
protected theorem HasFPowerSeriesWithinOnBall.fderivWithin_of_mem [CompleteSpace F]
(h : HasFPowerSeriesWithinOnBall f p s x r) (hu : UniqueDiffOn 𝕜 s) (hx : x ∈ s) :
HasFPowerSeriesWithinOnBall (fderivWithin 𝕜 f s) p.derivSeries s x r := by
have : insert x s = s := insert_eq_of_mem hx
rw [← this] at hu
convert h.fderivWithin hu
exact this.symm
/-- If a function is analytic on a set `s`, so is its Fréchet derivative. -/
@[fun_prop]
protected theorem AnalyticAt.fderiv [CompleteSpace F] (h : AnalyticAt 𝕜 f x) :
AnalyticAt 𝕜 (fderiv 𝕜 f) x := by
rcases h with ⟨p, r, hp⟩
exact hp.fderiv.analyticAt
/-- If a function is analytic on a set `s`, so is its Fréchet derivative. See also
`AnalyticOnNhd.fderiv_of_isOpen`, removing the completeness assumption but requiring the set
to be open. -/
protected theorem AnalyticOnNhd.fderiv [CompleteSpace F] (h : AnalyticOnNhd 𝕜 f s) :
AnalyticOnNhd 𝕜 (fderiv 𝕜 f) s :=
fun y hy ↦ AnalyticAt.fderiv (h y hy)
/-- If a function is analytic on a set `s`, so are its successive Fréchet derivative. See also
`AnalyticOnNhd.iteratedFDeriv_of_isOpen`, removing the completeness assumption but requiring the set
to be open. -/
protected theorem AnalyticOnNhd.iteratedFDeriv [CompleteSpace F] (h : AnalyticOnNhd 𝕜 f s) (n : ℕ) :
AnalyticOnNhd 𝕜 (iteratedFDeriv 𝕜 n f) s := by
induction n with
| zero =>
rw [iteratedFDeriv_zero_eq_comp]
exact ((continuousMultilinearCurryFin0 𝕜 E F).symm : F →L[𝕜] E[×0]→L[𝕜] F).comp_analyticOnNhd h
| succ n IH =>
rw [iteratedFDeriv_succ_eq_comp_left]
-- Porting note: for reasons that I do not understand at all, `?g` cannot be inlined.
convert ContinuousLinearMap.comp_analyticOnNhd ?g IH.fderiv
case g => exact ↑(continuousMultilinearCurryLeftEquiv 𝕜 (fun _ : Fin (n + 1) ↦ E) F).symm
simp
/-- If a function is analytic on a neighborhood of a set `s`, then it has a Taylor series given
by the sequence of its derivatives. Note that, if the function were just analytic on `s`, then
one would have to use instead the sequence of derivatives inside the set, as in
`AnalyticOn.hasFTaylorSeriesUpToOn`. -/
lemma AnalyticOnNhd.hasFTaylorSeriesUpToOn [CompleteSpace F]
(n : WithTop ℕ∞) (h : AnalyticOnNhd 𝕜 f s) :
HasFTaylorSeriesUpToOn n f (ftaylorSeries 𝕜 f) s := by
refine ⟨fun x _hx ↦ rfl, fun m _hm x hx ↦ ?_, fun m _hm x hx ↦ ?_⟩
· apply HasFDerivAt.hasFDerivWithinAt
exact ((h.iteratedFDeriv m x hx).differentiableAt).hasFDerivAt
· apply (DifferentiableAt.continuousAt (𝕜 := 𝕜) ?_).continuousWithinAt
exact (h.iteratedFDeriv m x hx).differentiableAt
lemma AnalyticWithinAt.exists_hasFTaylorSeriesUpToOn [CompleteSpace F]
(n : WithTop ℕ∞) (h : AnalyticWithinAt 𝕜 f s x) :
∃ u ∈ 𝓝[insert x s] x, ∃ (p : E → FormalMultilinearSeries 𝕜 E F),
HasFTaylorSeriesUpToOn n f p u ∧ ∀ i, AnalyticOn 𝕜 (fun x ↦ p x i) u := by
rcases h.exists_analyticAt with ⟨g, -, fg, hg⟩
rcases hg.exists_mem_nhds_analyticOnNhd with ⟨v, vx, hv⟩
refine ⟨insert x s ∩ v, inter_mem_nhdsWithin _ vx, ftaylorSeries 𝕜 g, ?_, fun i ↦ ?_⟩
· suffices HasFTaylorSeriesUpToOn n g (ftaylorSeries 𝕜 g) (insert x s ∩ v) from
this.congr (fun y hy ↦ fg hy.1)
exact AnalyticOnNhd.hasFTaylorSeriesUpToOn _ (hv.mono Set.inter_subset_right)
· exact (hv.iteratedFDeriv i).analyticOn.mono Set.inter_subset_right
/-- If a function has a power series `p` within a set of unique differentiability, inside a ball,
and is differentiable at a point, then the derivative series of `p` is summable at a point, with
sum the given differential. Note that this theorem does not require completeness of the space. -/
theorem HasFPowerSeriesWithinOnBall.hasSum_derivSeries_of_hasFDerivWithinAt
(h : HasFPowerSeriesWithinOnBall f p s x r)
{f' : E →L[𝕜] F}
{y : E} (hy : (‖y‖₊ : ℝ≥0∞) < r) (h'y : x + y ∈ insert x s)
(hf' : HasFDerivWithinAt f f' (insert x s) (x + y))
(hu : UniqueDiffOn 𝕜 (insert x s)) :
HasSum (fun n ↦ p.derivSeries n (fun _ ↦ y)) f' := by
/- In the completion of the space, the derivative series is summable, and its sum is a derivative
of the function. Therefore, by uniqueness of derivatives, its sum is the image of `f'` under
the canonical embedding. As this is an embedding, it means that there was also convergence in
the original space, to `f'`. -/
let F' := UniformSpace.Completion F
let a : F →L[𝕜] F' := UniformSpace.Completion.toComplL
let b : (E →L[𝕜] F) →ₗᵢ[𝕜] (E →L[𝕜] F') := UniformSpace.Completion.toComplₗᵢ.postcomp
rw [← b.isEmbedding.hasSum_iff]
have : HasFPowerSeriesWithinOnBall (a ∘ f) (a.compFormalMultilinearSeries p) s x r :=
a.comp_hasFPowerSeriesWithinOnBall h
have Z := (this.fderivWithin hu).hasSum h'y (by simpa [edist_zero_eq_enorm] using hy)
have : fderivWithin 𝕜 (a ∘ f) (insert x s) (x + y) = a ∘L f' := by
apply HasFDerivWithinAt.fderivWithin _ (hu _ h'y)
exact a.hasFDerivAt.comp_hasFDerivWithinAt (x + y) hf'
rw [this] at Z
convert Z with n
ext v
simp only [FormalMultilinearSeries.derivSeries, ContinuousLinearMap.coe_sum', Finset.sum_apply,
ContinuousLinearMap.compFormalMultilinearSeries_apply,
FormalMultilinearSeries.changeOriginSeries,
ContinuousLinearMap.compContinuousMultilinearMap_coe, ContinuousLinearEquiv.coe_coe,
LinearIsometryEquiv.coe_coe, Function.comp_apply, ContinuousMultilinearMap.sum_apply, map_sum]
rfl
/-- If a function has a power series within a set on a ball, then so does its derivative. Version
assuming that the function is analytic on `s`. For a version without this assumption but requiring
that `F` is complete, see `HasFPowerSeriesWithinOnBall.fderivWithin_of_mem`. -/
protected theorem HasFPowerSeriesWithinOnBall.fderivWithin_of_mem_of_analyticOn
(hr : HasFPowerSeriesWithinOnBall f p s x r)
(h : AnalyticOn 𝕜 f s) (hs : UniqueDiffOn 𝕜 s) (hx : x ∈ s) :
HasFPowerSeriesWithinOnBall (fderivWithin 𝕜 f s) p.derivSeries s x r := by
refine ⟨hr.r_le.trans p.radius_le_radius_derivSeries, hr.r_pos, fun {y} hy h'y ↦ ?_⟩
apply hr.hasSum_derivSeries_of_hasFDerivWithinAt (by simpa [edist_zero_eq_enorm] using h'y) hy
· rw [insert_eq_of_mem hx] at hy ⊢
apply DifferentiableWithinAt.hasFDerivWithinAt
exact h.differentiableOn _ hy
· rwa [insert_eq_of_mem hx]
/-- If a function is analytic within a set with unique differentials, then so is its derivative.
Note that this theorem does not require completeness of the space. -/
protected theorem AnalyticOn.fderivWithin (h : AnalyticOn 𝕜 f s) (hu : UniqueDiffOn 𝕜 s) :
AnalyticOn 𝕜 (fderivWithin 𝕜 f s) s := by
intro x hx
rcases h x hx with ⟨p, r, hr⟩
refine ⟨p.derivSeries, r, hr.fderivWithin_of_mem_of_analyticOn h hu hx⟩
/-- If a function is analytic on a set `s`, so are its successive Fréchet derivative within this
set. Note that this theorem does not require completeness of the space. -/
protected theorem AnalyticOn.iteratedFDerivWithin (h : AnalyticOn 𝕜 f s)
(hu : UniqueDiffOn 𝕜 s) (n : ℕ) :
AnalyticOn 𝕜 (iteratedFDerivWithin 𝕜 n f s) s := by
induction n with
| zero =>
rw [iteratedFDerivWithin_zero_eq_comp]
exact ((continuousMultilinearCurryFin0 𝕜 E F).symm : F →L[𝕜] E[×0]→L[𝕜] F)
|>.comp_analyticOn h
| succ n IH =>
rw [iteratedFDerivWithin_succ_eq_comp_left]
apply AnalyticOnNhd.comp_analyticOn _ (IH.fderivWithin hu) (mapsTo_univ _ _)
apply LinearIsometryEquiv.analyticOnNhd
protected 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 ↦ ?_⟩
· have := (h.iteratedFDerivWithin hu m x hx).differentiableWithinAt.hasFDerivWithinAt
rwa [insert_eq_of_mem hx] at this
· exact (h.iteratedFDerivWithin hu m x hx).continuousWithinAt
lemma AnalyticOn.exists_hasFTaylorSeriesUpToOn
(h : AnalyticOn 𝕜 f s) (hu : UniqueDiffOn 𝕜 s) :
∃ p : E → FormalMultilinearSeries 𝕜 E F,
HasFTaylorSeriesUpToOn ⊤ f p s ∧ ∀ i, AnalyticOn 𝕜 (fun x ↦ p x i) s :=
⟨ftaylorSeriesWithin 𝕜 f s, h.hasFTaylorSeriesUpToOn hu, h.iteratedFDerivWithin hu⟩
theorem AnalyticOnNhd.fderiv_of_isOpen (h : AnalyticOnNhd 𝕜 f s) (hs : IsOpen s) :
AnalyticOnNhd 𝕜 (fderiv 𝕜 f) s := by
rw [← hs.analyticOn_iff_analyticOnNhd] at h ⊢
exact (h.fderivWithin hs.uniqueDiffOn).congr (fun x hx ↦ (fderivWithin_of_isOpen hs hx).symm)
theorem AnalyticOnNhd.iteratedFDeriv_of_isOpen (h : AnalyticOnNhd 𝕜 f s) (hs : IsOpen s) (n : ℕ) :
AnalyticOnNhd 𝕜 (iteratedFDeriv 𝕜 n f) s := by
rw [← hs.analyticOn_iff_analyticOnNhd] at h ⊢
exact (h.iteratedFDerivWithin hs.uniqueDiffOn n).congr
(fun x hx ↦ (iteratedFDerivWithin_of_isOpen n hs hx).symm)
/-- If an open partial homeomorphism `f` is analytic at a point `a`, with invertible derivative,
then its inverse is analytic at `f a`. -/
theorem OpenPartialHomeomorph.analyticAt_symm' (f : OpenPartialHomeomorph E F) {a : E}
{i : E ≃L[𝕜] F} (h0 : a ∈ f.source) (h : AnalyticAt 𝕜 f a) (h' : fderiv 𝕜 f a = i) :
AnalyticAt 𝕜 f.symm (f a) := by
rcases h with ⟨p, hp⟩
have : p 1 = (continuousMultilinearCurryFin1 𝕜 E F).symm i := by simp [← h', hp.fderiv_eq]
exact (f.hasFPowerSeriesAt_symm h0 hp this).analyticAt
/-- If an open partial homeomorphism `f` is analytic at a point `f.symm a`, with invertible
derivative, then its inverse is analytic at `a`. -/
theorem OpenPartialHomeomorph.analyticAt_symm (f : OpenPartialHomeomorph E F) {a : F}
{i : E ≃L[𝕜] F} (h0 : a ∈ f.target) (h : AnalyticAt 𝕜 f (f.symm a))
(h' : fderiv 𝕜 f (f.symm a) = i) :
AnalyticAt 𝕜 f.symm a := by
have : a = f (f.symm a) := by simp [h0]
rw [this]
exact f.analyticAt_symm' (by simp [h0]) h h'
end fderiv
section deriv
variable {p : FormalMultilinearSeries 𝕜 𝕜 F} {r : ℝ≥0∞}
variable {f : 𝕜 → F} {x : 𝕜} {s : Set 𝕜}
protected theorem HasFPowerSeriesAt.hasStrictDerivAt (h : HasFPowerSeriesAt f p x) :
HasStrictDerivAt f (p 1 fun _ => 1) x :=
h.hasStrictFDerivAt.hasStrictDerivAt
protected theorem HasFPowerSeriesAt.hasDerivAt (h : HasFPowerSeriesAt f p x) :
HasDerivAt f (p 1 fun _ => 1) x :=
h.hasStrictDerivAt.hasDerivAt
protected theorem HasFPowerSeriesAt.deriv (h : HasFPowerSeriesAt f p x) :
deriv f x = p 1 fun _ => 1 :=
h.hasDerivAt.deriv
/-- If a function is analytic on a set `s` in a complete space, so is its derivative. -/
protected theorem AnalyticOnNhd.deriv [CompleteSpace F] (h : AnalyticOnNhd 𝕜 f s) :
AnalyticOnNhd 𝕜 (deriv f) s :=
(ContinuousLinearMap.apply 𝕜 F (1 : 𝕜)).comp_analyticOnNhd h.fderiv
/-- If a function is analytic on an open set `s`, so is its derivative. -/
theorem AnalyticOnNhd.deriv_of_isOpen (h : AnalyticOnNhd 𝕜 f s) (hs : IsOpen s) :
AnalyticOnNhd 𝕜 (deriv f) s :=
(ContinuousLinearMap.apply 𝕜 F (1 : 𝕜)).comp_analyticOnNhd (h.fderiv_of_isOpen hs)
/-- If a function is analytic on a set `s`, so are its successive derivatives. -/
theorem AnalyticOnNhd.iterated_deriv [CompleteSpace F] (h : AnalyticOnNhd 𝕜 f s) (n : ℕ) :
AnalyticOnNhd 𝕜 (deriv^[n] f) s := by
induction n with
| zero => exact h
| succ n IH => simpa only [Function.iterate_succ', Function.comp_apply] using IH.deriv
protected theorem AnalyticAt.deriv [CompleteSpace F] (h : AnalyticAt 𝕜 f x) :
AnalyticAt 𝕜 (deriv f) x := by
obtain ⟨r, hr, h⟩ := h.exists_ball_analyticOnNhd
exact h.deriv x (by simp [hr])
theorem AnalyticAt.iterated_deriv [CompleteSpace F] (h : AnalyticAt 𝕜 f x) (n : ℕ) :
AnalyticAt 𝕜 (deriv^[n] f) x := by
induction n with
| zero => exact h
| succ n IH => simpa only [Function.iterate_succ', Function.comp_apply] using IH.deriv
end deriv
section fderiv
variable {p : FormalMultilinearSeries 𝕜 E F} {r : ℝ≥0∞} {n : ℕ}
variable {f : E → F} {x : E} {s : Set E}
/-! The case of continuously polynomial functions. We get the same differentiability
results as for analytic functions, but without the assumptions that `F` is complete. -/
theorem HasFiniteFPowerSeriesOnBall.differentiableOn
(h : HasFiniteFPowerSeriesOnBall f p x n r) : DifferentiableOn 𝕜 f (EMetric.ball x r) :=
fun _ hy ↦ (h.cpolynomialAt_of_mem hy).analyticAt.differentiableWithinAt
theorem HasFiniteFPowerSeriesOnBall.hasStrictFDerivAt (h : HasFiniteFPowerSeriesOnBall f p x n r)
{y : E} (hy : (‖y‖₊ : ℝ≥0∞) < r) :
HasStrictFDerivAt f (continuousMultilinearCurryFin1 𝕜 E F (p.changeOrigin y 1)) (x + y) :=
(h.changeOrigin hy).toHasFPowerSeriesOnBall.hasFPowerSeriesAt.hasStrictFDerivAt
theorem HasFiniteFPowerSeriesOnBall.hasFDerivAt (h : HasFiniteFPowerSeriesOnBall f p x n r)
{y : E} (hy : (‖y‖₊ : ℝ≥0∞) < r) :
HasFDerivAt f (continuousMultilinearCurryFin1 𝕜 E F (p.changeOrigin y 1)) (x + y) :=
(h.hasStrictFDerivAt hy).hasFDerivAt
theorem HasFiniteFPowerSeriesOnBall.fderiv_eq (h : HasFiniteFPowerSeriesOnBall f p x n r)
{y : E} (hy : (‖y‖₊ : ℝ≥0∞) < r) :
fderiv 𝕜 f (x + y) = continuousMultilinearCurryFin1 𝕜 E F (p.changeOrigin y 1) :=
(h.hasFDerivAt hy).fderiv
/-- If a function has a finite power series on a ball, then so does its derivative. -/
protected theorem HasFiniteFPowerSeriesOnBall.fderiv
(h : HasFiniteFPowerSeriesOnBall f p x (n + 1) r) :
HasFiniteFPowerSeriesOnBall (fderiv 𝕜 f) p.derivSeries x n r := by
refine .congr (f := fun z ↦ continuousMultilinearCurryFin1 𝕜 E F (p.changeOrigin (z - x) 1)) ?_
fun z hz ↦ ?_
· refine continuousMultilinearCurryFin1 𝕜 E F
|>.toContinuousLinearEquiv.toContinuousLinearMap.comp_hasFiniteFPowerSeriesOnBall ?_
simpa using
((p.hasFiniteFPowerSeriesOnBall_changeOrigin 1 h.finite).mono h.r_pos le_top).comp_sub x
dsimp only
rw [← h.fderiv_eq, add_sub_cancel]
simpa only [edist_eq_enorm_sub, EMetric.mem_ball] using hz
/-- If a function has a finite power series on a ball, then so does its derivative.
This is a variant of `HasFiniteFPowerSeriesOnBall.fderiv` where the degree of `f` is `< n`
and not `< n + 1`. -/
theorem HasFiniteFPowerSeriesOnBall.fderiv' (h : HasFiniteFPowerSeriesOnBall f p x n r) :
HasFiniteFPowerSeriesOnBall (fderiv 𝕜 f) p.derivSeries x (n - 1) r := by
obtain rfl | hn := eq_or_ne n 0
· rw [zero_tsub]
refine HasFiniteFPowerSeriesOnBall.bound_zero_of_eq_zero (fun y hy ↦ ?_) h.r_pos fun n ↦ ?_
· rw [Filter.EventuallyEq.fderiv_eq (f := fun _ ↦ 0)]
· simp
· exact Filter.eventuallyEq_iff_exists_mem.mpr ⟨EMetric.ball x r,
EMetric.isOpen_ball.mem_nhds hy, fun z hz ↦ by rw [h.eq_zero_of_bound_zero z hz]⟩
· apply ContinuousMultilinearMap.ext; intro a
change (continuousMultilinearCurryFin1 𝕜 E F) (p.changeOriginSeries 1 n a) = 0
rw [p.changeOriginSeries_finite_of_finite h.finite 1 (Nat.zero_le _)]
exact map_zero _
· rw [← Nat.succ_pred hn] at h
exact h.fderiv
/-- If a function is polynomial on a set `s`, so is its Fréchet derivative. -/
theorem CPolynomialOn.fderiv (h : CPolynomialOn 𝕜 f s) :
CPolynomialOn 𝕜 (fderiv 𝕜 f) s := by
intro y hy
rcases h y hy with ⟨p, r, n, hp⟩
exact hp.fderiv'.cpolynomialAt
/-- If a function is polynomial on a set `s`, so are its successive Fréchet derivative. -/
theorem CPolynomialOn.iteratedFDeriv (h : CPolynomialOn 𝕜 f s) (n : ℕ) :
CPolynomialOn 𝕜 (iteratedFDeriv 𝕜 n f) s := by
induction n with
| zero =>
rw [iteratedFDeriv_zero_eq_comp]
exact ((continuousMultilinearCurryFin0 𝕜 E F).symm : F →L[𝕜] E[×0]→L[𝕜] F).comp_cpolynomialOn h
| succ n IH =>
rw [iteratedFDeriv_succ_eq_comp_left]
convert ContinuousLinearMap.comp_cpolynomialOn ?g IH.fderiv
case g => exact ↑(continuousMultilinearCurryLeftEquiv 𝕜 (fun _ : Fin (n + 1) ↦ E) F).symm
simp
end fderiv
section deriv
variable {p : FormalMultilinearSeries 𝕜 𝕜 F} {r : ℝ≥0∞}
variable {f : 𝕜 → F} {x : 𝕜} {s : Set 𝕜}
/-- If a function is polynomial on a set `s`, so is its derivative. -/
protected theorem CPolynomialOn.deriv (h : CPolynomialOn 𝕜 f s) : CPolynomialOn 𝕜 (deriv f) s :=
(ContinuousLinearMap.apply 𝕜 F (1 : 𝕜)).comp_cpolynomialOn h.fderiv
/-- If a function is polynomial on a set `s`, so are its successive derivatives. -/
theorem CPolynomialOn.iterated_deriv (h : CPolynomialOn 𝕜 f s) (n : ℕ) :
CPolynomialOn 𝕜 (deriv^[n] f) s := by
induction n with
| zero => exact h
| succ n IH => simpa only [Function.iterate_succ', Function.comp_apply] using IH.deriv
end deriv
namespace ContinuousMultilinearMap
variable {ι : Type*} {E : ι → Type*} [∀ i, NormedAddCommGroup (E i)] [∀ i, NormedSpace 𝕜 (E i)]
[Fintype ι] (f : ContinuousMultilinearMap 𝕜 E F)
open FormalMultilinearSeries
theorem changeOriginSeries_support {k l : ℕ} (h : k + l ≠ Fintype.card ι) :
f.toFormalMultilinearSeries.changeOriginSeries k l = 0 :=
Finset.sum_eq_zero fun _ _ ↦ by
simp_rw [FormalMultilinearSeries.changeOriginSeriesTerm,
toFormalMultilinearSeries, dif_neg h.symm, LinearIsometryEquiv.map_zero]
variable {n : WithTop ℕ∞} (x : ∀ i, E i)
open Finset in
theorem changeOrigin_toFormalMultilinearSeries [DecidableEq ι] :
continuousMultilinearCurryFin1 𝕜 (∀ i, E i) F (f.toFormalMultilinearSeries.changeOrigin x 1) =
f.linearDeriv x := by
ext y
rw [continuousMultilinearCurryFin1_apply, linearDeriv_apply,
changeOrigin, FormalMultilinearSeries.sum]
cases isEmpty_or_nonempty ι
· have (l : _) : 1 + l ≠ Fintype.card ι := by
rw [add_comm, Fintype.card_eq_zero]; exact Nat.succ_ne_zero _
simp_rw [Fintype.sum_empty, changeOriginSeries_support _ (this _), zero_apply _, tsum_zero]; rfl
rw [tsum_eq_single (Fintype.card ι - 1), changeOriginSeries]; swap
· intro m hm
rw [Ne, eq_tsub_iff_add_eq_of_le (by exact Fintype.card_pos), add_comm] at hm
rw [f.changeOriginSeries_support hm, zero_apply]
rw [sum_apply, ContinuousMultilinearMap.sum_apply, Fin.snoc_zero]
simp_rw [changeOriginSeriesTerm_apply]
refine (Fintype.sum_bijective (?_ ∘ Fintype.equivFinOfCardEq (Nat.add_sub_of_le
Fintype.card_pos).symm) (.comp ?_ <| Equiv.bijective _) _ _ fun i ↦ ?_).symm
· exact (⟨{·}ᶜ, by
rw [card_compl, Fintype.card_fin, Finset.card_singleton, Nat.add_sub_cancel_left]⟩)
· use fun _ _ ↦ (singleton_injective <| compl_injective <| Subtype.ext_iff.mp ·)
intro ⟨s, hs⟩
have h : #sᶜ = 1 := by rw [card_compl, hs, Fintype.card_fin, Nat.add_sub_cancel]
obtain ⟨a, ha⟩ := card_eq_one.mp h
exact ⟨a, Subtype.ext (compl_eq_comm.mp ha)⟩
rw [Function.comp_apply, Subtype.coe_mk, compl_singleton, piecewise_erase_univ,
toFormalMultilinearSeries, dif_pos (Nat.add_sub_of_le Fintype.card_pos).symm]
simp_rw [domDomCongr_apply, compContinuousLinearMap_apply, ContinuousLinearMap.proj_apply,
Function.update_apply, (Equiv.injective _).eq_iff, ite_apply]
congr
grind
protected theorem hasStrictFDerivAt [DecidableEq ι] : HasStrictFDerivAt f (f.linearDeriv x) x := by
rw [← changeOrigin_toFormalMultilinearSeries]
convert f.hasFiniteFPowerSeriesOnBall.hasStrictFDerivAt (y := x) ENNReal.coe_lt_top
rw [zero_add]
protected theorem hasFDerivAt [DecidableEq ι] : HasFDerivAt f (f.linearDeriv x) x :=
(f.hasStrictFDerivAt _).hasFDerivAt
protected theorem hasStrictFDerivAt_uncurry [DecidableEq ι]
(fa : ContinuousMultilinearMap 𝕜 E F × ∀ i, E i) :
HasStrictFDerivAt (fun fx : ContinuousMultilinearMap 𝕜 E F × ∀ i, E i ↦ fx.1 fx.2)
(apply 𝕜 E F fa.2 ∘L .fst _ _ _ + fa.1.linearDeriv fa.2 ∘L .snd _ _ _) fa := by
let f := ContinuousLinearMap.id 𝕜 (ContinuousMultilinearMap 𝕜 E F)
|>.continuousMultilinearMapOption
have Hf := (f.hasStrictFDerivAt (fun _ ↦ fa)).comp (f := fun fx _ ↦ fx) fa
(hasStrictFDerivAt_pi.2 fun _ ↦ hasStrictFDerivAt_id _)
convert Hf using 1
ext g
· suffices ∑ i, fa.1 (Function.update fa.2 i 0) =
∑ i, fa.1 fun j ↦ (Function.update (fun _ ↦ fa) (some i) (g, 0) (some j)).2 j by
simpa [f, ContinuousLinearMap.continuousMultilinearMapOption]
congr with i
congr with j
rcases eq_or_ne j i with rfl | hij <;> simp [*]
· suffices ∑ i, fa.1 (Function.update fa.2 i (g i)) =
∑ x, fa.1 fun i ↦ (Function.update (fun x ↦ fa) (some x) (0, g) (some i)).2 i by
simpa [f, ContinuousLinearMap.continuousMultilinearMapOption]
congr with i
congr with j
rcases eq_or_ne j i with rfl | hij <;> simp [*]
theorem _root_.HasStrictFDerivAt.continuousMultilinearMap_apply {G : Type*}
[NormedAddCommGroup G] [NormedSpace 𝕜 G] [DecidableEq ι] {x : G}
{f : G → ContinuousMultilinearMap 𝕜 E F} {g : ∀ i, G → E i}
{f' : G →L[𝕜] ContinuousMultilinearMap 𝕜 E F} {g' : ∀ i, G →L[𝕜] E i}
(hf : HasStrictFDerivAt f f' x) (hg : ∀ i, HasStrictFDerivAt (g i) (g' i) x) :
HasStrictFDerivAt (fun x ↦ f x (g · x))
(ContinuousMultilinearMap.apply 𝕜 E F (g · x) ∘L f' +
∑ i, (f x).toContinuousLinearMap (g · x) i ∘L g' i) x := by
convert ContinuousMultilinearMap.hasStrictFDerivAt_uncurry (f x, (g · x))
|>.comp x (hf.prodMk (hasStrictFDerivAt_pi.2 hg))
ext
simp
theorem _root_.HasFDerivWithinAt.continuousMultilinearMap_apply {G : Type*}
[NormedAddCommGroup G] [NormedSpace 𝕜 G] [DecidableEq ι] {s : Set G} {x : G}
{f : G → ContinuousMultilinearMap 𝕜 E F} {g : ∀ i, G → E i}
{f' : G →L[𝕜] ContinuousMultilinearMap 𝕜 E F} {g' : ∀ i, G →L[𝕜] E i}
(hf : HasFDerivWithinAt f f' s x) (hg : ∀ i, HasFDerivWithinAt (g i) (g' i) s x) :
HasFDerivWithinAt (fun x ↦ f x (g · x))
(ContinuousMultilinearMap.apply 𝕜 E F (g · x) ∘L f' +
∑ i, (f x).toContinuousLinearMap (g · x) i ∘L g' i) s x := by
convert ContinuousMultilinearMap.hasStrictFDerivAt_uncurry (f x, (g · x))
|>.hasFDerivAt.comp_hasFDerivWithinAt x (hf.prodMk (hasFDerivWithinAt_pi.2 hg))
ext
simp
theorem _root_.HasFDerivAt.continuousMultilinearMap_apply {G : Type*}
[NormedAddCommGroup G] [NormedSpace 𝕜 G] [DecidableEq ι] {x : G}
{f : G → ContinuousMultilinearMap 𝕜 E F} {g : ∀ i, G → E i}
{f' : G →L[𝕜] ContinuousMultilinearMap 𝕜 E F} {g' : ∀ i, G →L[𝕜] E i}
(hf : HasFDerivAt f f' x) (hg : ∀ i, HasFDerivAt (g i) (g' i) x) :
HasFDerivAt (fun x ↦ f x (g · x))
(ContinuousMultilinearMap.apply 𝕜 E F (g · x) ∘L f' +
∑ i, (f x).toContinuousLinearMap (g · x) i ∘L g' i) x := by
simp only [← hasFDerivWithinAt_univ] at *
exact hf.continuousMultilinearMap_apply hg
/-- Given `f` a multilinear map, then the derivative of `x ↦ f (g₁ x, ..., gₙ x)` at `x` applied
to a vector `v` is given by `∑ i, f (g₁ x, ..., g'ᵢ v, ..., gₙ x)`. Version inside a set. -/
theorem _root_.HasFDerivWithinAt.multilinear_comp
[DecidableEq ι] {G : Type*} [NormedAddCommGroup G] [NormedSpace 𝕜 G]
{g : ∀ i, G → E i} {g' : ∀ i, G →L[𝕜] E i} {s : Set G} {x : G}
(hg : ∀ i, HasFDerivWithinAt (g i) (g' i) s x) :
HasFDerivWithinAt (fun x ↦ f (fun i ↦ g i x))
((∑ i : ι, (f.toContinuousLinearMap (fun j ↦ g j x) i) ∘L (g' i))) s x := by
simpa using (hasFDerivWithinAt_const f x s).continuousMultilinearMap_apply hg
/-- Given `f` a multilinear map, then the derivative of `x ↦ f (g₁ x, ..., gₙ x)` at `x` applied
to a vector `v` is given by `∑ i, f (g₁ x, ..., g'ᵢ v, ..., gₙ x)`. -/
theorem _root_.HasFDerivAt.multilinear_comp
[DecidableEq ι] {G : Type*} [NormedAddCommGroup G] [NormedSpace 𝕜 G]
{g : ∀ i, G → E i} {g' : ∀ i, G →L[𝕜] E i} {x : G}
(hg : ∀ i, HasFDerivAt (g i) (g' i) x) :
HasFDerivAt (fun x ↦ f (fun i ↦ g i x))
((∑ i : ι, (f.toContinuousLinearMap (fun j ↦ g j x) i) ∘L (g' i))) x := by
simpa using (hasFDerivAt_const f x).continuousMultilinearMap_apply hg
/-- Technical lemma used in the proof of `hasFTaylorSeriesUpTo_iteratedFDeriv`, to compare sums
over embedding of `Fin k` and `Fin (k + 1)`. -/
private lemma _root_.Equiv.succ_embeddingFinSucc_fst_symm_apply {ι : Type*} [DecidableEq ι]
{n : ℕ} (e : Fin (n + 1) ↪ ι) {k : ι}
(h'k : k ∈ Set.range (Equiv.embeddingFinSucc n ι e).1) (hk : k ∈ Set.range e) :
Fin.succ ((Equiv.embeddingFinSucc n ι e).1.toEquivRange.symm ⟨k, h'k⟩)
= e.toEquivRange.symm ⟨k, hk⟩ := by
rcases hk with ⟨j, rfl⟩
have hj : j ≠ 0 := by
rintro rfl
simp at h'k
simp only [Function.Embedding.toEquivRange_symm_apply_self]
have : e j = (Equiv.embeddingFinSucc n ι e).1 (Fin.pred j hj) := by simp
simp_rw [this]
simp [-Equiv.embeddingFinSucc_fst]
/-- A continuous multilinear function `f` admits a Taylor series, whose successive terms are given
by `f.iteratedFDeriv n`. This is the point of the definition of `f.iteratedFDeriv`. -/
theorem hasFTaylorSeriesUpTo_iteratedFDeriv :
HasFTaylorSeriesUpTo ⊤ f (fun v n ↦ f.iteratedFDeriv n v) := by
classical
constructor
· simp [ContinuousMultilinearMap.iteratedFDeriv]
· rintro n - x
suffices H : curryLeft (f.iteratedFDeriv (Nat.succ n) x) = (∑ e : Fin n ↪ ι,
((iteratedFDerivComponent f e.toEquivRange).linearDeriv
(Pi.compRightL 𝕜 _ Subtype.val x)) ∘L (Pi.compRightL 𝕜 _ Subtype.val)) by
have A : HasFDerivAt (f.iteratedFDeriv n) (∑ e : Fin n ↪ ι,
((iteratedFDerivComponent f e.toEquivRange).linearDeriv (Pi.compRightL 𝕜 _ Subtype.val x))
∘L (Pi.compRightL 𝕜 _ Subtype.val)) x := by
apply HasFDerivAt.fun_sum (fun s _hs ↦ ?_)
exact (ContinuousMultilinearMap.hasFDerivAt _ _).comp x (ContinuousLinearMap.hasFDerivAt _)
rwa [← H] at A
ext v m
simp only [ContinuousMultilinearMap.iteratedFDeriv, curryLeft_apply, sum_apply,
iteratedFDerivComponent_apply, Finset.univ_sigma_univ,
Pi.compRightL_apply, ContinuousLinearMap.coe_sum', ContinuousLinearMap.coe_comp',
Finset.sum_apply, Function.comp_apply, linearDeriv_apply, Finset.sum_sigma']
rw [← (Equiv.embeddingFinSucc n ι).sum_comp]
congr with e
congr with k
by_cases hke : k ∈ Set.range e
· simp only [hke, ↓reduceDIte]
split_ifs with hkf
· simp only [← Equiv.succ_embeddingFinSucc_fst_symm_apply e hkf hke, Fin.cons_succ]
· obtain rfl : k = e 0 := by
rcases hke with ⟨j, rfl⟩
simpa using hkf
simp only [Function.Embedding.toEquivRange_symm_apply_self, Fin.cons_zero, Function.update,
Pi.compRightL_apply]
split_ifs with h
· congr!
· exfalso
apply h
simp_rw [← Equiv.embeddingFinSucc_snd e]
· have hkf : k ∉ Set.range (Equiv.embeddingFinSucc n ι e).1 := by
contrapose! hke
rw [Equiv.embeddingFinSucc_fst] at hke
exact Set.range_comp_subset_range _ _ hke
simp only [hke, hkf, ↓reduceDIte, Pi.compRightL,
ContinuousLinearMap.coe_mk', LinearMap.coe_mk, AddHom.coe_mk]
rw [Function.update_of_ne]
contrapose! hke
rw [show k = _ from Subtype.ext_iff.1 hke, Equiv.embeddingFinSucc_snd e]
exact Set.mem_range_self _
· rintro n -
apply continuous_finset_sum _ (fun e _ ↦ ?_)
exact (ContinuousMultilinearMap.coe_continuous _).comp (ContinuousLinearMap.continuous _)
theorem iteratedFDeriv_eq (n : ℕ) :
iteratedFDeriv 𝕜 n f = f.iteratedFDeriv n :=
funext fun x ↦ (f.hasFTaylorSeriesUpTo_iteratedFDeriv.eq_iteratedFDeriv (m := n) le_top x).symm
theorem norm_iteratedFDeriv_le (n : ℕ) (x : (i : ι) → E i) :
‖iteratedFDeriv 𝕜 n f x‖
≤ Nat.descFactorial (Fintype.card ι) n * ‖f‖ * ‖x‖ ^ (Fintype.card ι - n) := by
rw [f.iteratedFDeriv_eq]
exact f.norm_iteratedFDeriv_le' n x
end ContinuousMultilinearMap
namespace FormalMultilinearSeries
variable (p : FormalMultilinearSeries 𝕜 E F)
open Fintype ContinuousLinearMap in
theorem derivSeries_apply_diag (n : ℕ) (x : E) :
derivSeries p n (fun _ ↦ x) x = (n + 1) • p (n + 1) fun _ ↦ x := by
simp only [derivSeries, compFormalMultilinearSeries_apply, changeOriginSeries,
compContinuousMultilinearMap_coe, ContinuousLinearEquiv.coe_coe, LinearIsometryEquiv.coe_coe,
Function.comp_apply, ContinuousMultilinearMap.sum_apply, map_sum, coe_sum', Finset.sum_apply,
continuousMultilinearCurryFin1_apply, Matrix.zero_empty]
convert Finset.sum_const _
· rw [Fin.snoc_zero, changeOriginSeriesTerm_apply, Finset.piecewise_same, add_comm]
· rw [← card, card_subtype, ← Finset.powerset_univ, ← Finset.powersetCard_eq_filter,
Finset.card_powersetCard, ← card, card_fin, eq_comm, add_comm, Nat.choose_succ_self_right]
@[simp]
lemma derivSeries_coeff_one (p : FormalMultilinearSeries 𝕜 𝕜 F) (n : ℕ) :
p.derivSeries.coeff n 1 = (n + 1) • p.coeff (n + 1) :=
p.derivSeries_apply_diag _ _
end FormalMultilinearSeries
namespace HasFPowerSeriesOnBall
open FormalMultilinearSeries ENNReal Nat
variable {p : FormalMultilinearSeries 𝕜 E F} {f : E → F} {x : E} {r : ℝ≥0∞}
(h : HasFPowerSeriesOnBall f p x r) (y : E)
include h in
theorem iteratedFDeriv_zero_apply_diag : iteratedFDeriv 𝕜 0 f x = p 0 := by
ext
convert (h.hasSum <| EMetric.mem_ball_self h.r_pos).tsum_eq.symm
· rw [iteratedFDeriv_zero_apply, add_zero]
· rw [tsum_eq_single 0 fun n hn ↦ by haveI := NeZero.mk hn; exact (p n).map_zero]
exact congr(p 0 $(Subsingleton.elim _ _))
open ContinuousLinearMap
private theorem factorial_smul' {n : ℕ} : ∀ {F : Type max u v} [NormedAddCommGroup F]
[NormedSpace 𝕜 F] [CompleteSpace F] {p : FormalMultilinearSeries 𝕜 E F}
{f : E → F}, HasFPowerSeriesOnBall f p x r →
n ! • p n (fun _ ↦ y) = iteratedFDeriv 𝕜 n f x (fun _ ↦ y) := by
induction n with | zero => _ | succ n ih => _ <;> intro F _ _ _ p f h
· rw [factorial_zero, one_smul, h.iteratedFDeriv_zero_apply_diag]
· rw [factorial_succ, mul_comm, mul_smul, ← derivSeries_apply_diag,
← ContinuousLinearMap.smul_apply, ih h.fderiv, iteratedFDeriv_succ_apply_right]
rfl
variable [CompleteSpace F]
include h
/-- The iterated derivative of an analytic function, on vectors `(y, ..., y)`, is given by `n!`
times the `n`-th term in the power series. For a more general result giving the full iterated
derivative as a sum over the permutations of `Fin n`, see
`HasFPowerSeriesOnBall.iteratedFDeriv_eq_sum`. -/
theorem factorial_smul (n : ℕ) :
n ! • p n (fun _ ↦ y) = iteratedFDeriv 𝕜 n f x (fun _ ↦ y) := by
cases n
· rw [factorial_zero, one_smul, h.iteratedFDeriv_zero_apply_diag]
· rw [factorial_succ, mul_comm, mul_smul, ← derivSeries_apply_diag,
← ContinuousLinearMap.smul_apply, factorial_smul' _ h.fderiv, iteratedFDeriv_succ_apply_right]
rfl
theorem hasSum_iteratedFDeriv [CharZero 𝕜] {y : E} (hy : y ∈ EMetric.ball 0 r) :
HasSum (fun n ↦ (n ! : 𝕜)⁻¹ • iteratedFDeriv 𝕜 n f x fun _ ↦ y) (f (x + y)) := by
convert h.hasSum hy with n
rw [← h.factorial_smul y n, smul_comm, ← smul_assoc, nsmul_eq_mul,
mul_inv_cancel₀ <| cast_ne_zero.mpr n.factorial_ne_zero, one_smul]
end HasFPowerSeriesOnBall
/-!
### Derivative of a linear map into multilinear maps
-/
namespace ContinuousLinearMap
variable {ι : Type*} {G : ι → Type*} [∀ i, NormedAddCommGroup (G i)] [∀ i, NormedSpace 𝕜 (G i)]
[Fintype ι] {H : Type*} [NormedAddCommGroup H]
[NormedSpace 𝕜 H]
theorem hasFDerivAt_uncurry_of_multilinear [DecidableEq ι]
(f : E →L[𝕜] ContinuousMultilinearMap 𝕜 G F) (v : E × Π i, G i) :
HasFDerivAt (fun (p : E × Π i, G i) ↦ f p.1 p.2)
((f.flipMultilinear v.2) ∘L (.fst _ _ _) +
∑ i : ι, ((f v.1).toContinuousLinearMap v.2 i) ∘L (.proj _) ∘L (.snd _ _ _)) v :=
(f ∘L .fst 𝕜 E (∀ i, G i)).hasFDerivAt.continuousMultilinearMap_apply
(hasFDerivAt_pi'.mp (hasFDerivAt_snd (E := E) (F := ∀ i, G i)))
/-- Given `f` a linear map into multilinear maps, then the derivative
of `x ↦ f (a x) (b₁ x, ..., bₙ x)` at `x` applied to a vector `v` is given by
`f (a' v) (b₁ x, ...., bₙ x) + ∑ i, f a (b₁ x, ..., b'ᵢ v, ..., bₙ x)`. Version inside a set. -/
theorem _root_.HasFDerivWithinAt.linear_multilinear_comp
[DecidableEq ι] {a : H → E} {a' : H →L[𝕜] E}
{b : ∀ i, H → G i} {b' : ∀ i, H →L[𝕜] G i} {s : Set H} {x : H}
(ha : HasFDerivWithinAt a a' s x) (hb : ∀ i, HasFDerivWithinAt (b i) (b' i) s x)
(f : E →L[𝕜] ContinuousMultilinearMap 𝕜 G F) :
HasFDerivWithinAt (fun y ↦ f (a y) (fun i ↦ b i y))
((f.flipMultilinear (fun i ↦ b i x)) ∘L a' +
∑ i, ((f (a x)).toContinuousLinearMap (fun j ↦ b j x) i) ∘L (b' i)) s x :=
(f.hasFDerivAt.comp_hasFDerivWithinAt x ha).continuousMultilinearMap_apply hb
/-- Given `f` a linear map into multilinear maps, then the derivative
of `x ↦ f (a x) (b₁ x, ..., bₙ x)` at `x` applied to a vector `v` is given by
`f (a' v) (b₁ x, ...., bₙ x) + ∑ i, f a (b₁ x, ..., b'ᵢ v, ..., bₙ x)`. -/
theorem _root_.HasFDerivAt.linear_multilinear_comp [DecidableEq ι] {a : H → E} {a' : H →L[𝕜] E}
{b : ∀ i, H → G i} {b' : ∀ i, H →L[𝕜] G i} {x : H}
(ha : HasFDerivAt a a' x) (hb : ∀ i, HasFDerivAt (b i) (b' i) x)
(f : E →L[𝕜] ContinuousMultilinearMap 𝕜 G F) :
HasFDerivAt (fun y ↦ f (a y) (fun i ↦ b i y))
((f.flipMultilinear (fun i ↦ b i x)) ∘L a' +
∑ i, ((f (a x)).toContinuousLinearMap (fun j ↦ b j x) i) ∘L (b' i)) x :=
(f.hasFDerivAt.comp x ha).continuousMultilinearMap_apply hb
end ContinuousLinearMap |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/FDeriv/RestrictScalars.lean | import Mathlib.Analysis.Calculus.FDeriv.Basic
/-!
# The derivative of the scalar restriction of a linear map
For detailed documentation of the Fréchet derivative,
see the module docstring of `Analysis/Calculus/FDeriv/Basic.lean`.
This file contains the usual formulas (and existence assertions) for the derivative of
the scalar restriction of a linear map.
-/
open Filter Asymptotics ContinuousLinearMap Set Metric Topology NNReal ENNReal
noncomputable section
section RestrictScalars
/-!
### Restricting from `ℂ` to `ℝ`, or generally from `𝕜'` to `𝕜`
If a function is differentiable over `ℂ`, then it is differentiable over `ℝ`. In this paragraph,
we give variants of this statement, in the general situation where `ℂ` and `ℝ` are replaced
respectively by `𝕜'` and `𝕜` where `𝕜'` is a normed algebra over `𝕜`.
-/
variable (𝕜 : Type*) [NontriviallyNormedField 𝕜]
variable {𝕜' : Type*} [NontriviallyNormedField 𝕜'] [NormedAlgebra 𝕜 𝕜']
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E] [NormedSpace 𝕜' E]
variable [IsScalarTower 𝕜 𝕜' E]
variable {F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F] [NormedSpace 𝕜' F]
variable [IsScalarTower 𝕜 𝕜' F]
variable {f : E → F} {f' : E →L[𝕜'] F} {s : Set E} {x : E}
@[fun_prop]
theorem HasStrictFDerivAt.restrictScalars (h : HasStrictFDerivAt f f' x) :
HasStrictFDerivAt f (f'.restrictScalars 𝕜) x :=
.of_isLittleO h.isLittleO
theorem HasFDerivAtFilter.restrictScalars {L} (h : HasFDerivAtFilter f f' x L) :
HasFDerivAtFilter f (f'.restrictScalars 𝕜) x L :=
.of_isLittleO h.isLittleO
@[fun_prop]
theorem HasFDerivAt.restrictScalars (h : HasFDerivAt f f' x) :
HasFDerivAt f (f'.restrictScalars 𝕜) x :=
.of_isLittleO h.isLittleO
@[fun_prop]
theorem HasFDerivWithinAt.restrictScalars (h : HasFDerivWithinAt f f' s x) :
HasFDerivWithinAt f (f'.restrictScalars 𝕜) s x :=
.of_isLittleO h.isLittleO
@[fun_prop]
theorem DifferentiableAt.restrictScalars (h : DifferentiableAt 𝕜' f x) : DifferentiableAt 𝕜 f x :=
(h.hasFDerivAt.restrictScalars 𝕜).differentiableAt
@[fun_prop]
theorem DifferentiableWithinAt.restrictScalars (h : DifferentiableWithinAt 𝕜' f s x) :
DifferentiableWithinAt 𝕜 f s x :=
(h.hasFDerivWithinAt.restrictScalars 𝕜).differentiableWithinAt
@[fun_prop]
theorem DifferentiableOn.restrictScalars (h : DifferentiableOn 𝕜' f s) : DifferentiableOn 𝕜 f s :=
fun x hx => (h x hx).restrictScalars 𝕜
@[fun_prop]
theorem Differentiable.restrictScalars (h : Differentiable 𝕜' f) : Differentiable 𝕜 f := fun x =>
(h x).restrictScalars 𝕜
@[fun_prop]
theorem HasFDerivWithinAt.of_restrictScalars {g' : E →L[𝕜] F} (h : HasFDerivWithinAt f g' s x)
(H : f'.restrictScalars 𝕜 = g') : HasFDerivWithinAt f f' s x := by
rw [← H] at h
exact .of_isLittleO h.isLittleO
@[fun_prop]
theorem hasFDerivAt_of_restrictScalars {g' : E →L[𝕜] F} (h : HasFDerivAt f g' x)
(H : f'.restrictScalars 𝕜 = g') : HasFDerivAt f f' x := by
rw [← H] at h
exact .of_isLittleO h.isLittleO
theorem DifferentiableAt.fderiv_restrictScalars (h : DifferentiableAt 𝕜' f x) :
fderiv 𝕜 f x = (fderiv 𝕜' f x).restrictScalars 𝕜 :=
(h.hasFDerivAt.restrictScalars 𝕜).fderiv
theorem DifferentiableWithinAt.restrictScalars_fderivWithin (hf : DifferentiableWithinAt 𝕜' f s x)
(hs : UniqueDiffWithinAt 𝕜 s x) :
(fderivWithin 𝕜' f s x).restrictScalars 𝕜 = fderivWithin 𝕜 f s x :=
((hf.hasFDerivWithinAt.restrictScalars 𝕜).fderivWithin hs).symm
theorem differentiableWithinAt_iff_restrictScalars (hf : DifferentiableWithinAt 𝕜 f s x)
(hs : UniqueDiffWithinAt 𝕜 s x) : DifferentiableWithinAt 𝕜' f s x ↔
∃ g' : E →L[𝕜'] F, g'.restrictScalars 𝕜 = fderivWithin 𝕜 f s x := by
constructor
· rintro ⟨g', hg'⟩
exact ⟨g', hs.eq (hg'.restrictScalars 𝕜) hf.hasFDerivWithinAt⟩
· rintro ⟨f', hf'⟩
exact ⟨f', hf.hasFDerivWithinAt.of_restrictScalars 𝕜 hf'⟩
theorem differentiableAt_iff_restrictScalars (hf : DifferentiableAt 𝕜 f x) :
DifferentiableAt 𝕜' f x ↔ ∃ g' : E →L[𝕜'] F, g'.restrictScalars 𝕜 = fderiv 𝕜 f x := by
rw [← differentiableWithinAt_univ, ← fderivWithin_univ]
exact
differentiableWithinAt_iff_restrictScalars 𝕜 hf.differentiableWithinAt uniqueDiffWithinAt_univ
end RestrictScalars |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/FDeriv/Bilinear.lean | import Mathlib.Analysis.Calculus.FDeriv.Prod
/-!
# The derivative of bounded bilinear maps
For detailed documentation of the Fréchet derivative,
see the module docstring of `Mathlib/Analysis/Calculus/FDeriv/Basic.lean`.
This file contains the usual formulas (and existence assertions) for the derivative of
bounded bilinear maps.
-/
open Asymptotics Topology
noncomputable section
section
variable {𝕜 : Type*} [NontriviallyNormedField 𝕜]
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E]
variable {F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F]
variable {G : Type*} [NormedAddCommGroup G] [NormedSpace 𝕜 G]
variable {G' : Type*} [NormedAddCommGroup G'] [NormedSpace 𝕜 G']
section BilinearMap
/-! ### Derivative of a bounded bilinear map -/
variable {b : E × F → G} {u : Set (E × F)}
open NormedField
-- TODO: rewrite/golf using analytic functions?
@[fun_prop]
theorem IsBoundedBilinearMap.hasStrictFDerivAt (h : IsBoundedBilinearMap 𝕜 b) (p : E × F) :
HasStrictFDerivAt b (h.deriv p) p := by
simp only [hasStrictFDerivAt_iff_isLittleO]
simp only [← map_add_left_nhds_zero (p, p), isLittleO_map]
set T := (E × F) × E × F
calc
_ = fun x ↦ h.deriv (x.1 - x.2) (x.2.1, x.1.2) := by
ext ⟨⟨x₁, y₁⟩, ⟨x₂, y₂⟩⟩
rcases p with ⟨x, y⟩
simp only [map_sub, deriv_apply, Function.comp_apply, Prod.mk_add_mk, h.add_right, h.add_left,
Prod.mk_sub_mk, h.map_sub_left, h.map_sub_right, sub_add_sub_cancel]
abel
-- _ =O[𝓝 (0 : T)] fun x ↦ ‖x.1 - x.2‖ * ‖(x.2.1, x.1.2)‖ :=
-- h.toContinuousLinearMap.deriv₂.isBoundedBilinearMap.isBigO_comp
-- _ = o[𝓝 0] fun x ↦ ‖x.1 - x.2‖ * 1 := _
_ =o[𝓝 (0 : T)] fun x ↦ x.1 - x.2 := by
-- TODO : add 2 `calc` steps instead of the next 3 lines
refine h.toContinuousLinearMap.deriv₂.isBoundedBilinearMap.isBigO_comp.trans_isLittleO ?_
suffices (fun x : T ↦ ‖x.1 - x.2‖ * ‖(x.2.1, x.1.2)‖) =o[𝓝 0] fun x ↦ ‖x.1 - x.2‖ * 1 by
simpa only [mul_one, isLittleO_norm_right] using this
refine (isBigO_refl _ _).mul_isLittleO ((isLittleO_one_iff _).2 ?_)
-- TODO: `continuity` fails
exact (continuous_snd.fst.prodMk continuous_fst.snd).norm.tendsto' _ _ (by simp)
_ = _ := by simp [T, Function.comp_def]
@[fun_prop]
theorem IsBoundedBilinearMap.hasFDerivAt (h : IsBoundedBilinearMap 𝕜 b) (p : E × F) :
HasFDerivAt b (h.deriv p) p :=
(h.hasStrictFDerivAt p).hasFDerivAt
@[fun_prop]
theorem IsBoundedBilinearMap.hasFDerivWithinAt (h : IsBoundedBilinearMap 𝕜 b) (p : E × F) :
HasFDerivWithinAt b (h.deriv p) u p :=
(h.hasFDerivAt p).hasFDerivWithinAt
@[fun_prop]
theorem IsBoundedBilinearMap.differentiableAt (h : IsBoundedBilinearMap 𝕜 b) (p : E × F) :
DifferentiableAt 𝕜 b p :=
(h.hasFDerivAt p).differentiableAt
@[fun_prop]
theorem IsBoundedBilinearMap.differentiableWithinAt (h : IsBoundedBilinearMap 𝕜 b) (p : E × F) :
DifferentiableWithinAt 𝕜 b u p :=
(h.differentiableAt p).differentiableWithinAt
protected theorem IsBoundedBilinearMap.fderiv (h : IsBoundedBilinearMap 𝕜 b) (p : E × F) :
fderiv 𝕜 b p = h.deriv p :=
HasFDerivAt.fderiv (h.hasFDerivAt p)
protected theorem IsBoundedBilinearMap.fderivWithin (h : IsBoundedBilinearMap 𝕜 b) (p : E × F)
(hxs : UniqueDiffWithinAt 𝕜 u p) : fderivWithin 𝕜 b u p = h.deriv p := by
rw [DifferentiableAt.fderivWithin (h.differentiableAt p) hxs]
exact h.fderiv p
@[fun_prop]
theorem IsBoundedBilinearMap.differentiable (h : IsBoundedBilinearMap 𝕜 b) : Differentiable 𝕜 b :=
fun x => h.differentiableAt x
@[fun_prop]
theorem IsBoundedBilinearMap.differentiableOn (h : IsBoundedBilinearMap 𝕜 b) :
DifferentiableOn 𝕜 b u :=
h.differentiable.differentiableOn
variable (B : E →L[𝕜] F →L[𝕜] G)
@[fun_prop]
theorem ContinuousLinearMap.hasFDerivWithinAt_of_bilinear {f : G' → E} {g : G' → F}
{f' : G' →L[𝕜] E} {g' : G' →L[𝕜] F} {x : G'} {s : Set G'} (hf : HasFDerivWithinAt f f' s x)
(hg : HasFDerivWithinAt g g' s x) :
HasFDerivWithinAt (fun y => B (f y) (g y))
(B.precompR G' (f x) g' + B.precompL G' f' (g x)) s x := by
-- need `by exact` to deal with tricky unification
exact (B.isBoundedBilinearMap.hasFDerivAt (f x, g x)).comp_hasFDerivWithinAt x (hf.prodMk hg)
@[fun_prop]
theorem ContinuousLinearMap.hasFDerivAt_of_bilinear {f : G' → E} {g : G' → F} {f' : G' →L[𝕜] E}
{g' : G' →L[𝕜] F} {x : G'} (hf : HasFDerivAt f f' x) (hg : HasFDerivAt g g' x) :
HasFDerivAt (fun y => B (f y) (g y)) (B.precompR G' (f x) g' + B.precompL G' f' (g x)) x := by
-- need `by exact` to deal with tricky unification
exact (B.isBoundedBilinearMap.hasFDerivAt (f x, g x)).comp x (hf.prodMk hg)
@[fun_prop]
theorem ContinuousLinearMap.hasStrictFDerivAt_of_bilinear
{f : G' → E} {g : G' → F} {f' : G' →L[𝕜] E}
{g' : G' →L[𝕜] F} {x : G'} (hf : HasStrictFDerivAt f f' x) (hg : HasStrictFDerivAt g g' x) :
HasStrictFDerivAt (fun y => B (f y) (g y))
(B.precompR G' (f x) g' + B.precompL G' f' (g x)) x :=
(B.isBoundedBilinearMap.hasStrictFDerivAt (f x, g x)).comp x (hf.prodMk hg)
theorem ContinuousLinearMap.fderivWithin_of_bilinear {f : G' → E} {g : G' → F} {x : G'} {s : Set G'}
(hf : DifferentiableWithinAt 𝕜 f s x) (hg : DifferentiableWithinAt 𝕜 g s x)
(hs : UniqueDiffWithinAt 𝕜 s x) :
fderivWithin 𝕜 (fun y => B (f y) (g y)) s x =
B.precompR G' (f x) (fderivWithin 𝕜 g s x) + B.precompL G' (fderivWithin 𝕜 f s x) (g x) :=
(B.hasFDerivWithinAt_of_bilinear hf.hasFDerivWithinAt hg.hasFDerivWithinAt).fderivWithin hs
theorem ContinuousLinearMap.fderiv_of_bilinear {f : G' → E} {g : G' → F} {x : G'}
(hf : DifferentiableAt 𝕜 f x) (hg : DifferentiableAt 𝕜 g x) :
fderiv 𝕜 (fun y => B (f y) (g y)) x =
B.precompR G' (f x) (fderiv 𝕜 g x) + B.precompL G' (fderiv 𝕜 f x) (g x) :=
(B.hasFDerivAt_of_bilinear hf.hasFDerivAt hg.hasFDerivAt).fderiv
end BilinearMap
end |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/FDeriv/Comp.lean | import Mathlib.Analysis.Calculus.FDeriv.Basic
/-!
# The derivative of a composition (chain rule)
For detailed documentation of the Fréchet derivative,
see the module docstring of `Analysis/Calculus/FDeriv/Basic.lean`.
This file contains the usual formulas (and existence assertions) for the derivative of
composition of functions (the chain rule).
-/
open Filter Asymptotics ContinuousLinearMap Set Metric Topology NNReal ENNReal
noncomputable section
section
variable {𝕜 : Type*} [NontriviallyNormedField 𝕜]
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E]
variable {F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F]
variable {G : Type*} [NormedAddCommGroup G] [NormedSpace 𝕜 G]
variable {G' : Type*} [NormedAddCommGroup G'] [NormedSpace 𝕜 G']
variable {f g : E → F} {f' g' : E →L[𝕜] F} {x : E} {s : Set E} {L : Filter E}
section Composition
/-!
### Derivative of the composition of two functions
For composition lemmas, we put `x` explicit to help the elaborator, as otherwise Lean tends to
get confused since there are too many possibilities for composition. -/
variable (x)
theorem HasFDerivAtFilter.comp {g : F → G} {g' : F →L[𝕜] G} {L' : Filter F}
(hg : HasFDerivAtFilter g g' (f x) L') (hf : HasFDerivAtFilter f f' x L) (hL : Tendsto f L L') :
HasFDerivAtFilter (g ∘ f) (g'.comp f') x L := by
let eq₁ := (g'.isBigO_comp _ _).trans_isLittleO hf.isLittleO
let eq₂ := (hg.isLittleO.comp_tendsto hL).trans_isBigO hf.isBigO_sub
refine .of_isLittleO <| eq₂.triangle <| eq₁.congr_left fun x' => ?_
simp
/- A readable version of the previous theorem, a general form of the chain rule. -/
example {g : F → G} {g' : F →L[𝕜] G} (hg : HasFDerivAtFilter g g' (f x) (L.map f))
(hf : HasFDerivAtFilter f f' x L) : HasFDerivAtFilter (g ∘ f) (g'.comp f') x L := by
have :=
calc
(fun x' => g (f x') - g (f x) - g' (f x' - f x)) =o[L] fun x' => f x' - f x :=
hg.isLittleO.comp_tendsto le_rfl
_ =O[L] fun x' => x' - x := hf.isBigO_sub
refine .of_isLittleO <| this.triangle ?_
calc
(fun x' : E => g' (f x' - f x) - g'.comp f' (x' - x))
_ =ᶠ[L] fun x' => g' (f x' - f x - f' (x' - x)) := Eventually.of_forall fun x' => by simp
_ =O[L] fun x' => f x' - f x - f' (x' - x) := g'.isBigO_comp _ _
_ =o[L] fun x' => x' - x := hf.isLittleO
@[fun_prop]
theorem HasFDerivWithinAt.comp {g : F → G} {g' : F →L[𝕜] G} {t : Set F}
(hg : HasFDerivWithinAt g g' t (f x)) (hf : HasFDerivWithinAt f f' s x) (hst : MapsTo f s t) :
HasFDerivWithinAt (g ∘ f) (g'.comp f') s x :=
HasFDerivAtFilter.comp x hg hf <| hf.continuousWithinAt.tendsto_nhdsWithin hst
@[fun_prop]
theorem HasFDerivAt.comp_hasFDerivWithinAt {g : F → G} {g' : F →L[𝕜] G}
(hg : HasFDerivAt g g' (f x)) (hf : HasFDerivWithinAt f f' s x) :
HasFDerivWithinAt (g ∘ f) (g'.comp f') s x :=
hg.comp x hf hf.continuousWithinAt
@[fun_prop]
theorem HasFDerivWithinAt.comp_of_tendsto {g : F → G} {g' : F →L[𝕜] G} {t : Set F}
(hg : HasFDerivWithinAt g g' t (f x)) (hf : HasFDerivWithinAt f f' s x)
(hst : Tendsto f (𝓝[s] x) (𝓝[t] f x)) : HasFDerivWithinAt (g ∘ f) (g'.comp f') s x :=
HasFDerivAtFilter.comp x hg hf hst
theorem HasFDerivWithinAt.comp_hasFDerivAt {g : F → G} {g' : F →L[𝕜] G} {t : Set F}
(hg : HasFDerivWithinAt g g' t (f x)) (hf : HasFDerivAt f f' x)
(ht : ∀ᶠ x' in 𝓝 x, f x' ∈ t) : HasFDerivAt (g ∘ f) (g' ∘L f') x :=
HasFDerivAtFilter.comp x hg hf <| tendsto_nhdsWithin_iff.mpr ⟨hf.continuousAt, ht⟩
theorem HasFDerivWithinAt.comp_hasFDerivAt_of_eq {g : F → G} {g' : F →L[𝕜] G} {t : Set F} {y : F}
(hg : HasFDerivWithinAt g g' t y) (hf : HasFDerivAt f f' x)
(ht : ∀ᶠ x' in 𝓝 x, f x' ∈ t) (hy : y = f x) : HasFDerivAt (g ∘ f) (g' ∘L f') x := by
subst y; exact hg.comp_hasFDerivAt x hf ht
/-- The chain rule. -/
@[fun_prop]
theorem HasFDerivAt.comp {g : F → G} {g' : F →L[𝕜] G} (hg : HasFDerivAt g g' (f x))
(hf : HasFDerivAt f f' x) : HasFDerivAt (g ∘ f) (g'.comp f') x :=
HasFDerivAtFilter.comp x hg hf hf.continuousAt
@[fun_prop]
theorem DifferentiableWithinAt.comp {g : F → G} {t : Set F}
(hg : DifferentiableWithinAt 𝕜 g t (f x)) (hf : DifferentiableWithinAt 𝕜 f s x)
(h : MapsTo f s t) : DifferentiableWithinAt 𝕜 (g ∘ f) s x :=
(hg.hasFDerivWithinAt.comp x hf.hasFDerivWithinAt h).differentiableWithinAt
@[fun_prop]
theorem DifferentiableWithinAt.comp' {g : F → G} {t : Set F}
(hg : DifferentiableWithinAt 𝕜 g t (f x)) (hf : DifferentiableWithinAt 𝕜 f s x) :
DifferentiableWithinAt 𝕜 (g ∘ f) (s ∩ f ⁻¹' t) x :=
hg.comp x (hf.mono inter_subset_left) inter_subset_right
@[fun_prop]
theorem DifferentiableAt.fun_comp' {f : E → F} {g : F → G} (hg : DifferentiableAt 𝕜 g (f x))
(hf : DifferentiableAt 𝕜 f x) : DifferentiableAt 𝕜 (fun x ↦ g (f x)) x :=
(hg.hasFDerivAt.comp x hf.hasFDerivAt).differentiableAt
@[fun_prop]
theorem DifferentiableAt.comp {g : F → G} (hg : DifferentiableAt 𝕜 g (f x))
(hf : DifferentiableAt 𝕜 f x) : DifferentiableAt 𝕜 (g ∘ f) x :=
(hg.hasFDerivAt.comp x hf.hasFDerivAt).differentiableAt
@[fun_prop]
theorem DifferentiableAt.comp_differentiableWithinAt {g : F → G} (hg : DifferentiableAt 𝕜 g (f x))
(hf : DifferentiableWithinAt 𝕜 f s x) : DifferentiableWithinAt 𝕜 (g ∘ f) s x :=
hg.differentiableWithinAt.comp x hf (mapsTo_univ _ _)
theorem fderivWithin_comp {g : F → G} {t : Set F} (hg : DifferentiableWithinAt 𝕜 g t (f x))
(hf : DifferentiableWithinAt 𝕜 f s x) (h : MapsTo f s t) (hxs : UniqueDiffWithinAt 𝕜 s x) :
fderivWithin 𝕜 (g ∘ f) s x = (fderivWithin 𝕜 g t (f x)).comp (fderivWithin 𝕜 f s x) :=
(hg.hasFDerivWithinAt.comp x hf.hasFDerivWithinAt h).fderivWithin hxs
theorem fderivWithin_comp_of_eq {g : F → G} {t : Set F} {y : F}
(hg : DifferentiableWithinAt 𝕜 g t y) (hf : DifferentiableWithinAt 𝕜 f s x) (h : MapsTo f s t)
(hxs : UniqueDiffWithinAt 𝕜 s x) (hy : f x = y) :
fderivWithin 𝕜 (g ∘ f) s x = (fderivWithin 𝕜 g t (f x)).comp (fderivWithin 𝕜 f s x) := by
subst hy; exact fderivWithin_comp _ hg hf h hxs
/-- A variant for the derivative of a composition, written without `∘`. -/
theorem fderivWithin_comp' {g : F → G} {t : Set F} (hg : DifferentiableWithinAt 𝕜 g t (f x))
(hf : DifferentiableWithinAt 𝕜 f s x) (h : MapsTo f s t) (hxs : UniqueDiffWithinAt 𝕜 s x) :
fderivWithin 𝕜 (fun y ↦ g (f y)) s x
= (fderivWithin 𝕜 g t (f x)).comp (fderivWithin 𝕜 f s x) :=
fderivWithin_comp _ hg hf h hxs
/-- A variant for the derivative of a composition, written without `∘`. -/
theorem fderivWithin_comp_of_eq' {g : F → G} {t : Set F} {y : F}
(hg : DifferentiableWithinAt 𝕜 g t y) (hf : DifferentiableWithinAt 𝕜 f s x) (h : MapsTo f s t)
(hxs : UniqueDiffWithinAt 𝕜 s x) (hy : f x = y) :
fderivWithin 𝕜 (fun y ↦ g (f y)) s x
= (fderivWithin 𝕜 g t (f x)).comp (fderivWithin 𝕜 f s x) := by
subst hy; exact fderivWithin_comp _ hg hf h hxs
/-- A version of `fderivWithin_comp` that is useful to rewrite the composition of two derivatives
into a single derivative. This version always applies, but creates a new side-goal `f x = y`. -/
theorem fderivWithin_fderivWithin {g : F → G} {f : E → F} {x : E} {y : F} {s : Set E} {t : Set F}
(hg : DifferentiableWithinAt 𝕜 g t y) (hf : DifferentiableWithinAt 𝕜 f s x) (h : MapsTo f s t)
(hxs : UniqueDiffWithinAt 𝕜 s x) (hy : f x = y) (v : E) :
fderivWithin 𝕜 g t y (fderivWithin 𝕜 f s x v) = fderivWithin 𝕜 (g ∘ f) s x v := by
subst y
rw [fderivWithin_comp x hg hf h hxs, coe_comp', Function.comp_apply]
/-- Ternary version of `fderivWithin_comp`, with equality assumptions of basepoints added, in
order to apply more easily as a rewrite from right-to-left. -/
theorem fderivWithin_comp₃ {g' : G → G'} {g : F → G} {t : Set F} {u : Set G} {y : F} {y' : G}
(hg' : DifferentiableWithinAt 𝕜 g' u y') (hg : DifferentiableWithinAt 𝕜 g t y)
(hf : DifferentiableWithinAt 𝕜 f s x) (h2g : MapsTo g t u) (h2f : MapsTo f s t) (h3g : g y = y')
(h3f : f x = y) (hxs : UniqueDiffWithinAt 𝕜 s x) :
fderivWithin 𝕜 (g' ∘ g ∘ f) s x =
(fderivWithin 𝕜 g' u y').comp ((fderivWithin 𝕜 g t y).comp (fderivWithin 𝕜 f s x)) := by
substs h3g h3f
exact (hg'.hasFDerivWithinAt.comp x (hg.hasFDerivWithinAt.comp x hf.hasFDerivWithinAt h2f) <|
h2g.comp h2f).fderivWithin hxs
theorem fderiv_comp {g : F → G} (hg : DifferentiableAt 𝕜 g (f x)) (hf : DifferentiableAt 𝕜 f x) :
fderiv 𝕜 (g ∘ f) x = (fderiv 𝕜 g (f x)).comp (fderiv 𝕜 f x) :=
(hg.hasFDerivAt.comp x hf.hasFDerivAt).fderiv
/-- A variant for the derivative of a composition, written without `∘`. -/
theorem fderiv_comp' {g : F → G} (hg : DifferentiableAt 𝕜 g (f x)) (hf : DifferentiableAt 𝕜 f x) :
fderiv 𝕜 (fun y ↦ g (f y)) x = (fderiv 𝕜 g (f x)).comp (fderiv 𝕜 f x) :=
fderiv_comp x hg hf
theorem fderiv_comp_fderivWithin {g : F → G} (hg : DifferentiableAt 𝕜 g (f x))
(hf : DifferentiableWithinAt 𝕜 f s x) (hxs : UniqueDiffWithinAt 𝕜 s x) :
fderivWithin 𝕜 (g ∘ f) s x = (fderiv 𝕜 g (f x)).comp (fderivWithin 𝕜 f s x) :=
(hg.hasFDerivAt.comp_hasFDerivWithinAt x hf.hasFDerivWithinAt).fderivWithin hxs
@[fun_prop]
theorem DifferentiableOn.fun_comp {g : F → G} {t : Set F} (hg : DifferentiableOn 𝕜 g t)
(hf : DifferentiableOn 𝕜 f s) (st : MapsTo f s t) :
DifferentiableOn 𝕜 (fun x ↦ g (f x)) s :=
fun x hx => DifferentiableWithinAt.comp x (hg (f x) (st hx)) (hf x hx) st
@[fun_prop]
theorem DifferentiableOn.comp {g : F → G} {t : Set F} (hg : DifferentiableOn 𝕜 g t)
(hf : DifferentiableOn 𝕜 f s) (st : MapsTo f s t) : DifferentiableOn 𝕜 (g ∘ f) s :=
fun x hx => DifferentiableWithinAt.comp x (hg (f x) (st hx)) (hf x hx) st
@[fun_prop]
theorem Differentiable.fun_comp {g : F → G} (hg : Differentiable 𝕜 g) (hf : Differentiable 𝕜 f) :
Differentiable 𝕜 (fun x ↦ g (f x)) :=
fun x => DifferentiableAt.comp x (hg (f x)) (hf x)
@[fun_prop]
theorem Differentiable.comp {g : F → G} (hg : Differentiable 𝕜 g) (hf : Differentiable 𝕜 f) :
Differentiable 𝕜 (g ∘ f) :=
fun x => DifferentiableAt.comp x (hg (f x)) (hf x)
@[fun_prop]
theorem Differentiable.comp_differentiableOn {g : F → G} (hg : Differentiable 𝕜 g)
(hf : DifferentiableOn 𝕜 f s) : DifferentiableOn 𝕜 (g ∘ f) s :=
hg.differentiableOn.comp hf (mapsTo_univ _ _)
/-- The chain rule for derivatives in the sense of strict differentiability. -/
@[fun_prop]
protected theorem HasStrictFDerivAt.comp {g : F → G} {g' : F →L[𝕜] G}
(hg : HasStrictFDerivAt g g' (f x)) (hf : HasStrictFDerivAt f f' x) :
HasStrictFDerivAt (fun x => g (f x)) (g'.comp f') x :=
.of_isLittleO <|
((hg.isLittleO.comp_tendsto (hf.continuousAt.prodMap' hf.continuousAt)).trans_isBigO
hf.isBigO_sub).triangle <| by
simpa only [g'.map_sub, f'.coe_comp'] using (g'.isBigO_comp _ _).trans_isLittleO hf.isLittleO
@[fun_prop]
protected theorem Differentiable.iterate {f : E → E} (hf : Differentiable 𝕜 f) (n : ℕ) :
Differentiable 𝕜 f^[n] :=
Nat.recOn n differentiable_id fun _ ihn => ihn.comp hf
@[fun_prop]
protected theorem DifferentiableOn.iterate {f : E → E} (hf : DifferentiableOn 𝕜 f s)
(hs : MapsTo f s s) (n : ℕ) : DifferentiableOn 𝕜 f^[n] s :=
Nat.recOn n differentiableOn_id fun _ ihn => ihn.comp hf hs
variable {x}
protected theorem HasFDerivAtFilter.iterate {f : E → E} {f' : E →L[𝕜] E}
(hf : HasFDerivAtFilter f f' x L) (hL : Tendsto f L L) (hx : f x = x) (n : ℕ) :
HasFDerivAtFilter f^[n] (f' ^ n) x L := by
induction n with
| zero => exact hasFDerivAtFilter_id x L
| succ n ihn =>
rw [Function.iterate_succ, pow_succ]
rw [← hx] at ihn
exact ihn.comp x hf hL
@[fun_prop]
protected theorem HasFDerivAt.iterate {f : E → E} {f' : E →L[𝕜] E} (hf : HasFDerivAt f f' x)
(hx : f x = x) (n : ℕ) : HasFDerivAt f^[n] (f' ^ n) x := by
refine HasFDerivAtFilter.iterate hf ?_ hx n
convert hf.continuousAt.tendsto
exact hx.symm
@[fun_prop]
protected theorem HasFDerivWithinAt.iterate {f : E → E} {f' : E →L[𝕜] E}
(hf : HasFDerivWithinAt f f' s x) (hx : f x = x) (hs : MapsTo f s s) (n : ℕ) :
HasFDerivWithinAt f^[n] (f' ^ n) s x := by
refine HasFDerivAtFilter.iterate hf ?_ hx n
rw [nhdsWithin]
convert tendsto_inf.2 ⟨hf.continuousWithinAt, _⟩
exacts [hx.symm, (tendsto_principal_principal.2 hs).mono_left inf_le_right]
@[fun_prop]
protected theorem HasStrictFDerivAt.iterate {f : E → E} {f' : E →L[𝕜] E}
(hf : HasStrictFDerivAt f f' x) (hx : f x = x) (n : ℕ) :
HasStrictFDerivAt f^[n] (f' ^ n) x := by
induction n with
| zero => exact hasStrictFDerivAt_id x
| succ n ihn =>
rw [Function.iterate_succ, pow_succ]
rw [← hx] at ihn
exact ihn.comp x hf
@[fun_prop]
protected theorem DifferentiableAt.iterate {f : E → E} (hf : DifferentiableAt 𝕜 f x) (hx : f x = x)
(n : ℕ) : DifferentiableAt 𝕜 f^[n] x :=
(hf.hasFDerivAt.iterate hx n).differentiableAt
@[fun_prop]
protected theorem DifferentiableWithinAt.iterate {f : E → E} (hf : DifferentiableWithinAt 𝕜 f s x)
(hx : f x = x) (hs : MapsTo f s s) (n : ℕ) : DifferentiableWithinAt 𝕜 f^[n] s x :=
(hf.hasFDerivWithinAt.iterate hx hs n).differentiableWithinAt
end Composition
end |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/FDeriv/Add.lean | import Mathlib.Analysis.Calculus.FDeriv.Linear
import Mathlib.Analysis.Calculus.FDeriv.Comp
import Mathlib.Analysis.Calculus.FDeriv.Const
/-!
# Additive operations on derivatives
For detailed documentation of the Fréchet derivative,
see the module docstring of `Analysis/Calculus/FDeriv/Basic.lean`.
This file contains the usual formulas (and existence assertions) for the derivative of
* sum of finitely many functions
* multiplication of a function by a scalar constant
* negative of a function
* subtraction of two functions
-/
open Filter Asymptotics ContinuousLinearMap
noncomputable section
section
variable {𝕜 : Type*} [NontriviallyNormedField 𝕜]
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E]
variable {F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F]
variable {f g : E → F}
variable {f' g' : E →L[𝕜] F}
variable {x : E}
variable {s : Set E}
variable {L : Filter E}
section ConstSMul
variable {R : Type*} [Semiring R] [Module R F] [SMulCommClass 𝕜 R F] [ContinuousConstSMul R F]
/-! ### Derivative of a function multiplied by a constant -/
@[fun_prop]
theorem HasStrictFDerivAt.fun_const_smul (h : HasStrictFDerivAt f f' x) (c : R) :
HasStrictFDerivAt (fun x => c • f x) (c • f') x :=
(c • (1 : F →L[𝕜] F)).hasStrictFDerivAt.comp x h
@[fun_prop]
theorem HasStrictFDerivAt.const_smul (h : HasStrictFDerivAt f f' x) (c : R) :
HasStrictFDerivAt (c • f) (c • f') x :=
h.fun_const_smul c
theorem HasFDerivAtFilter.fun_const_smul (h : HasFDerivAtFilter f f' x L) (c : R) :
HasFDerivAtFilter (fun x => c • f x) (c • f') x L :=
(c • (1 : F →L[𝕜] F)).hasFDerivAtFilter.comp x h tendsto_map
theorem HasFDerivAtFilter.const_smul (h : HasFDerivAtFilter f f' x L) (c : R) :
HasFDerivAtFilter (c • f) (c • f') x L :=
h.fun_const_smul c
@[fun_prop]
nonrec theorem HasFDerivWithinAt.fun_const_smul (h : HasFDerivWithinAt f f' s x) (c : R) :
HasFDerivWithinAt (fun x => c • f x) (c • f') s x :=
h.const_smul c
@[fun_prop]
nonrec theorem HasFDerivWithinAt.const_smul (h : HasFDerivWithinAt f f' s x) (c : R) :
HasFDerivWithinAt (c • f) (c • f') s x :=
h.const_smul c
@[fun_prop]
nonrec theorem HasFDerivAt.fun_const_smul (h : HasFDerivAt f f' x) (c : R) :
HasFDerivAt (fun x => c • f x) (c • f') x :=
h.const_smul c
@[fun_prop]
nonrec theorem HasFDerivAt.const_smul (h : HasFDerivAt f f' x) (c : R) :
HasFDerivAt (c • f) (c • f') x :=
h.const_smul c
@[fun_prop]
theorem DifferentiableWithinAt.fun_const_smul (h : DifferentiableWithinAt 𝕜 f s x) (c : R) :
DifferentiableWithinAt 𝕜 (fun y => c • f y) s x :=
(h.hasFDerivWithinAt.const_smul c).differentiableWithinAt
@[fun_prop]
theorem DifferentiableWithinAt.const_smul (h : DifferentiableWithinAt 𝕜 f s x) (c : R) :
DifferentiableWithinAt 𝕜 (c • f) s x :=
h.fun_const_smul c
@[fun_prop]
theorem DifferentiableAt.fun_const_smul (h : DifferentiableAt 𝕜 f x) (c : R) :
DifferentiableAt 𝕜 (fun y => c • f y) x :=
(h.hasFDerivAt.const_smul c).differentiableAt
@[fun_prop]
theorem DifferentiableAt.const_smul (h : DifferentiableAt 𝕜 f x) (c : R) :
DifferentiableAt 𝕜 (c • f) x :=
(h.hasFDerivAt.const_smul c).differentiableAt
@[fun_prop]
theorem DifferentiableOn.fun_const_smul (h : DifferentiableOn 𝕜 f s) (c : R) :
DifferentiableOn 𝕜 (fun y => c • f y) s := fun x hx => (h x hx).const_smul c
@[fun_prop]
theorem DifferentiableOn.const_smul (h : DifferentiableOn 𝕜 f s) (c : R) :
DifferentiableOn 𝕜 (c • f) s := fun x hx => (h x hx).const_smul c
@[fun_prop]
theorem Differentiable.fun_const_smul (h : Differentiable 𝕜 f) (c : R) :
Differentiable 𝕜 fun y => c • f y := fun x => (h x).const_smul c
@[fun_prop]
theorem Differentiable.const_smul (h : Differentiable 𝕜 f) (c : R) :
Differentiable 𝕜 (c • f) := fun x => (h x).const_smul c
theorem fderivWithin_fun_const_smul (hxs : UniqueDiffWithinAt 𝕜 s x)
(h : DifferentiableWithinAt 𝕜 f s x) (c : R) :
fderivWithin 𝕜 (fun y => c • f y) s x = c • fderivWithin 𝕜 f s x :=
(h.hasFDerivWithinAt.const_smul c).fderivWithin hxs
theorem fderivWithin_const_smul (hxs : UniqueDiffWithinAt 𝕜 s x)
(h : DifferentiableWithinAt 𝕜 f s x) (c : R) :
fderivWithin 𝕜 (c • f) s x = c • fderivWithin 𝕜 f s x :=
fderivWithin_fun_const_smul hxs h c
/-- If `c` is invertible, `c • f` is differentiable at `x` within `s` if and only if `f` is. -/
lemma differentiableWithinAt_smul_iff (c : R) [Invertible c] :
DifferentiableWithinAt 𝕜 (c • f) s x ↔ DifferentiableWithinAt 𝕜 f s x := by
refine ⟨fun h ↦ ?_, fun h ↦ h.const_smul c⟩
apply (h.const_smul ⅟c).congr_of_eventuallyEq ?_ (by simp)
filter_upwards with x using by simp
/-- A version of `fderivWithin_const_smul` without differentiability hypothesis:
in return, the constant `c` must be invertible, i.e. if `R` is a field. -/
theorem fderivWithin_const_smul_of_invertible (c : R) [Invertible c]
(hs : UniqueDiffWithinAt 𝕜 s x) :
fderivWithin 𝕜 (c • f) s x = c • fderivWithin 𝕜 f s x := by
by_cases h : DifferentiableWithinAt 𝕜 f s x
· exact (h.hasFDerivWithinAt.const_smul c).fderivWithin hs
· obtain (rfl | hc) := eq_or_ne c 0
· simp
have : ¬DifferentiableWithinAt 𝕜 (c • f) s x := by
contrapose! h
exact (differentiableWithinAt_smul_iff c).mp h
simp [fderivWithin_zero_of_not_differentiableWithinAt h,
fderivWithin_zero_of_not_differentiableWithinAt this]
/-- Special case of `fderivWithin_const_smul_of_invertible` over a field: any constant is allowed -/
lemma fderivWithin_const_smul_of_field (c : 𝕜) (hs : UniqueDiffWithinAt 𝕜 s x) :
fderivWithin 𝕜 (c • f) s x = c • fderivWithin 𝕜 f s x := by
obtain (rfl | ha) := eq_or_ne c 0
· simp
· have : Invertible c := invertibleOfNonzero ha
ext x
simp [fderivWithin_const_smul_of_invertible c (f := f) hs]
@[deprecated (since := "2025-06-14")] alias fderivWithin_const_smul' := fderivWithin_const_smul
theorem fderiv_fun_const_smul (h : DifferentiableAt 𝕜 f x) (c : R) :
fderiv 𝕜 (fun y => c • f y) x = c • fderiv 𝕜 f x :=
(h.hasFDerivAt.const_smul c).fderiv
theorem fderiv_const_smul (h : DifferentiableAt 𝕜 f x) (c : R) :
fderiv 𝕜 (c • f) x = c • fderiv 𝕜 f x :=
(h.hasFDerivAt.const_smul c).fderiv
/-- If `c` is invertible, `c • f` is differentiable at `x` if and only if `f` is. -/
lemma differentiableAt_smul_iff (c : R) [Invertible c] :
DifferentiableAt 𝕜 (c • f) x ↔ DifferentiableAt 𝕜 f x := by
rw [← differentiableWithinAt_univ, differentiableWithinAt_smul_iff, differentiableWithinAt_univ]
/-- A version of `fderiv_const_smul` without differentiability hypothesis: in return, the constant
`c` must be invertible, i.e. if `R` is a field. -/
theorem fderiv_const_smul_of_invertible (c : R) [Invertible c] :
fderiv 𝕜 (c • f) x = c • fderiv 𝕜 f x := by
simp [← fderivWithin_univ, fderivWithin_const_smul_of_invertible c uniqueDiffWithinAt_univ]
/-- Special case of `fderiv_const_smul_of_invertible` over a field: any constant is allowed -/
lemma fderiv_const_smul_of_field (c : 𝕜) : fderiv 𝕜 (c • f) = c • fderiv 𝕜 f := by
simp_rw [← fderivWithin_univ]
ext x
simp [fderivWithin_const_smul_of_field c uniqueDiffWithinAt_univ]
@[deprecated (since := "2025-06-14")] alias fderiv_const_smul' := fderiv_const_smul
end ConstSMul
section Add
/-! ### Derivative of the sum of two functions -/
@[fun_prop]
nonrec theorem HasStrictFDerivAt.fun_add (hf : HasStrictFDerivAt f f' x)
(hg : HasStrictFDerivAt g g' x) : HasStrictFDerivAt (fun y => f y + g y) (f' + g') x :=
.of_isLittleO <| (hf.isLittleO.add hg.isLittleO).congr_left fun y => by
simp only [map_sub, add_apply]
abel
@[fun_prop]
nonrec theorem HasStrictFDerivAt.add (hf : HasStrictFDerivAt f f' x)
(hg : HasStrictFDerivAt g g' x) : HasStrictFDerivAt (f + g) (f' + g') x :=
hf.fun_add hg
theorem HasFDerivAtFilter.fun_add (hf : HasFDerivAtFilter f f' x L)
(hg : HasFDerivAtFilter g g' x L) : HasFDerivAtFilter (fun y => f y + g y) (f' + g') x L :=
.of_isLittleO <| (hf.isLittleO.add hg.isLittleO).congr_left fun _ => by
simp only [map_sub, add_apply]
abel
theorem HasFDerivAtFilter.add (hf : HasFDerivAtFilter f f' x L)
(hg : HasFDerivAtFilter g g' x L) : HasFDerivAtFilter (f + g) (f' + g') x L :=
hf.fun_add hg
@[fun_prop]
nonrec theorem HasFDerivWithinAt.fun_add (hf : HasFDerivWithinAt f f' s x)
(hg : HasFDerivWithinAt g g' s x) : HasFDerivWithinAt (fun y => f y + g y) (f' + g') s x :=
hf.add hg
@[fun_prop]
nonrec theorem HasFDerivWithinAt.add (hf : HasFDerivWithinAt f f' s x)
(hg : HasFDerivWithinAt g g' s x) : HasFDerivWithinAt (f + g) (f' + g') s x :=
hf.add hg
@[fun_prop]
nonrec theorem HasFDerivAt.fun_add (hf : HasFDerivAt f f' x) (hg : HasFDerivAt g g' x) :
HasFDerivAt (fun x => f x + g x) (f' + g') x :=
hf.add hg
@[fun_prop]
nonrec theorem HasFDerivAt.add (hf : HasFDerivAt f f' x) (hg : HasFDerivAt g g' x) :
HasFDerivAt (f + g) (f' + g') x :=
hf.add hg
@[fun_prop]
theorem DifferentiableWithinAt.fun_add (hf : DifferentiableWithinAt 𝕜 f s x)
(hg : DifferentiableWithinAt 𝕜 g s x) : DifferentiableWithinAt 𝕜 (fun y => f y + g y) s x :=
(hf.hasFDerivWithinAt.add hg.hasFDerivWithinAt).differentiableWithinAt
@[fun_prop]
theorem DifferentiableWithinAt.add (hf : DifferentiableWithinAt 𝕜 f s x)
(hg : DifferentiableWithinAt 𝕜 g s x) : DifferentiableWithinAt 𝕜 (f + g) s x :=
(hf.hasFDerivWithinAt.add hg.hasFDerivWithinAt).differentiableWithinAt
@[simp, fun_prop]
theorem DifferentiableAt.fun_add (hf : DifferentiableAt 𝕜 f x) (hg : DifferentiableAt 𝕜 g x) :
DifferentiableAt 𝕜 (fun y => f y + g y) x :=
(hf.hasFDerivAt.add hg.hasFDerivAt).differentiableAt
@[simp, fun_prop]
theorem DifferentiableAt.add (hf : DifferentiableAt 𝕜 f x) (hg : DifferentiableAt 𝕜 g x) :
DifferentiableAt 𝕜 (f + g) x :=
(hf.hasFDerivAt.add hg.hasFDerivAt).differentiableAt
@[fun_prop]
theorem DifferentiableOn.fun_add (hf : DifferentiableOn 𝕜 f s) (hg : DifferentiableOn 𝕜 g s) :
DifferentiableOn 𝕜 (fun y => f y + g y) s := fun x hx => (hf x hx).add (hg x hx)
@[fun_prop]
theorem DifferentiableOn.add (hf : DifferentiableOn 𝕜 f s) (hg : DifferentiableOn 𝕜 g s) :
DifferentiableOn 𝕜 (f + g) s := fun x hx => (hf x hx).add (hg x hx)
@[simp, fun_prop]
theorem Differentiable.fun_add (hf : Differentiable 𝕜 f) (hg : Differentiable 𝕜 g) :
Differentiable 𝕜 fun y => f y + g y := fun x => (hf x).add (hg x)
@[simp, fun_prop]
theorem Differentiable.add (hf : Differentiable 𝕜 f) (hg : Differentiable 𝕜 g) :
Differentiable 𝕜 (f + g) := fun x => (hf x).add (hg x)
theorem fderivWithin_fun_add (hxs : UniqueDiffWithinAt 𝕜 s x) (hf : DifferentiableWithinAt 𝕜 f s x)
(hg : DifferentiableWithinAt 𝕜 g s x) :
fderivWithin 𝕜 (fun y => f y + g y) s x = fderivWithin 𝕜 f s x + fderivWithin 𝕜 g s x :=
(hf.hasFDerivWithinAt.add hg.hasFDerivWithinAt).fderivWithin hxs
theorem fderivWithin_add (hxs : UniqueDiffWithinAt 𝕜 s x) (hf : DifferentiableWithinAt 𝕜 f s x)
(hg : DifferentiableWithinAt 𝕜 g s x) :
fderivWithin 𝕜 (f + g) s x = fderivWithin 𝕜 f s x + fderivWithin 𝕜 g s x :=
fderivWithin_fun_add hxs hf hg
@[deprecated (since := "2025-06-14")] alias fderivWithin_add' := fderivWithin_add
theorem fderiv_fun_add (hf : DifferentiableAt 𝕜 f x) (hg : DifferentiableAt 𝕜 g x) :
fderiv 𝕜 (fun y => f y + g y) x = fderiv 𝕜 f x + fderiv 𝕜 g x :=
(hf.hasFDerivAt.add hg.hasFDerivAt).fderiv
theorem fderiv_add (hf : DifferentiableAt 𝕜 f x) (hg : DifferentiableAt 𝕜 g x) :
fderiv 𝕜 (f + g) x = fderiv 𝕜 f x + fderiv 𝕜 g x :=
fderiv_fun_add hf hg
@[deprecated (since := "2025-06-14")] alias fderiv_add' := fderiv_add
@[simp]
theorem hasFDerivAtFilter_add_const_iff (c : F) :
HasFDerivAtFilter (f · + c) f' x L ↔ HasFDerivAtFilter f f' x L := by
simp [hasFDerivAtFilter_iff_isLittleOTVS]
alias ⟨_, HasFDerivAtFilter.add_const⟩ := hasFDerivAtFilter_add_const_iff
@[simp]
theorem hasStrictFDerivAt_add_const_iff (c : F) :
HasStrictFDerivAt (f · + c) f' x ↔ HasStrictFDerivAt f f' x := by
simp [hasStrictFDerivAt_iff_isLittleO]
@[fun_prop]
alias ⟨_, HasStrictFDerivAt.add_const⟩ := hasStrictFDerivAt_add_const_iff
@[simp]
theorem hasFDerivWithinAt_add_const_iff (c : F) :
HasFDerivWithinAt (f · + c) f' s x ↔ HasFDerivWithinAt f f' s x :=
hasFDerivAtFilter_add_const_iff c
@[fun_prop]
alias ⟨_, HasFDerivWithinAt.add_const⟩ := hasFDerivWithinAt_add_const_iff
@[simp]
theorem hasFDerivAt_add_const_iff (c : F) : HasFDerivAt (f · + c) f' x ↔ HasFDerivAt f f' x :=
hasFDerivAtFilter_add_const_iff c
@[fun_prop]
alias ⟨_, HasFDerivAt.add_const⟩ := hasFDerivAt_add_const_iff
@[simp]
theorem differentiableWithinAt_add_const_iff (c : F) :
DifferentiableWithinAt 𝕜 (fun y => f y + c) s x ↔ DifferentiableWithinAt 𝕜 f s x :=
exists_congr fun _ ↦ hasFDerivWithinAt_add_const_iff c
@[fun_prop]
alias ⟨_, DifferentiableWithinAt.add_const⟩ := differentiableWithinAt_add_const_iff
@[simp]
theorem differentiableAt_add_const_iff (c : F) :
DifferentiableAt 𝕜 (fun y => f y + c) x ↔ DifferentiableAt 𝕜 f x :=
exists_congr fun _ ↦ hasFDerivAt_add_const_iff c
@[fun_prop]
alias ⟨_, DifferentiableAt.add_const⟩ := differentiableAt_add_const_iff
@[simp]
theorem differentiableOn_add_const_iff (c : F) :
DifferentiableOn 𝕜 (fun y => f y + c) s ↔ DifferentiableOn 𝕜 f s :=
forall₂_congr fun _ _ ↦ differentiableWithinAt_add_const_iff c
@[fun_prop]
alias ⟨_, DifferentiableOn.add_const⟩ := differentiableOn_add_const_iff
@[simp]
theorem differentiable_add_const_iff (c : F) :
(Differentiable 𝕜 fun y => f y + c) ↔ Differentiable 𝕜 f :=
forall_congr' fun _ ↦ differentiableAt_add_const_iff c
@[fun_prop]
alias ⟨_, Differentiable.add_const⟩ := differentiable_add_const_iff
@[simp]
theorem fderivWithin_add_const (c : F) :
fderivWithin 𝕜 (fun y => f y + c) s x = fderivWithin 𝕜 f s x := by
classical simp [fderivWithin]
@[simp]
theorem fderiv_add_const (c : F) : fderiv 𝕜 (fun y => f y + c) x = fderiv 𝕜 f x := by
simp only [← fderivWithin_univ, fderivWithin_add_const]
@[simp]
theorem hasFDerivAtFilter_const_add_iff (c : F) :
HasFDerivAtFilter (c + f ·) f' x L ↔ HasFDerivAtFilter f f' x L := by
simpa only [add_comm] using hasFDerivAtFilter_add_const_iff c
alias ⟨_, HasFDerivAtFilter.const_add⟩ := hasFDerivAtFilter_const_add_iff
@[simp]
theorem hasStrictFDerivAt_const_add_iff (c : F) :
HasStrictFDerivAt (c + f ·) f' x ↔ HasStrictFDerivAt f f' x := by
simpa only [add_comm] using hasStrictFDerivAt_add_const_iff c
@[fun_prop]
alias ⟨_, HasStrictFDerivAt.const_add⟩ := hasStrictFDerivAt_const_add_iff
@[simp]
theorem hasFDerivWithinAt_const_add_iff (c : F) :
HasFDerivWithinAt (c + f ·) f' s x ↔ HasFDerivWithinAt f f' s x :=
hasFDerivAtFilter_const_add_iff c
@[fun_prop]
alias ⟨_, HasFDerivWithinAt.const_add⟩ := hasFDerivWithinAt_const_add_iff
@[simp]
theorem hasFDerivAt_const_add_iff (c : F) : HasFDerivAt (c + f ·) f' x ↔ HasFDerivAt f f' x :=
hasFDerivAtFilter_const_add_iff c
@[fun_prop]
alias ⟨_, HasFDerivAt.const_add⟩ := hasFDerivAt_const_add_iff
@[simp]
theorem differentiableWithinAt_const_add_iff (c : F) :
DifferentiableWithinAt 𝕜 (fun y => c + f y) s x ↔ DifferentiableWithinAt 𝕜 f s x :=
exists_congr fun _ ↦ hasFDerivWithinAt_const_add_iff c
@[fun_prop]
alias ⟨_, DifferentiableWithinAt.const_add⟩ := differentiableWithinAt_const_add_iff
@[simp]
theorem differentiableAt_const_add_iff (c : F) :
DifferentiableAt 𝕜 (fun y => c + f y) x ↔ DifferentiableAt 𝕜 f x :=
exists_congr fun _ ↦ hasFDerivAt_const_add_iff c
@[fun_prop]
alias ⟨_, DifferentiableAt.const_add⟩ := differentiableAt_const_add_iff
@[simp]
theorem differentiableOn_const_add_iff (c : F) :
DifferentiableOn 𝕜 (fun y => c + f y) s ↔ DifferentiableOn 𝕜 f s :=
forall₂_congr fun _ _ ↦ differentiableWithinAt_const_add_iff c
@[fun_prop]
alias ⟨_, DifferentiableOn.const_add⟩ := differentiableOn_const_add_iff
@[simp]
theorem differentiable_const_add_iff (c : F) :
(Differentiable 𝕜 fun y => c + f y) ↔ Differentiable 𝕜 f :=
forall_congr' fun _ ↦ differentiableAt_const_add_iff c
@[fun_prop]
alias ⟨_, Differentiable.const_add⟩ := differentiable_const_add_iff
@[simp]
theorem fderivWithin_const_add (c : F) :
fderivWithin 𝕜 (fun y => c + f y) s x = fderivWithin 𝕜 f s x := by
simpa only [add_comm] using fderivWithin_add_const c
@[simp]
theorem fderiv_const_add (c : F) : fderiv 𝕜 (fun y => c + f y) x = fderiv 𝕜 f x := by
simp only [add_comm c, fderiv_add_const]
end Add
section Sum
/-! ### Derivative of a finite sum of functions -/
variable {ι : Type*} {u : Finset ι} {A : ι → E → F} {A' : ι → E →L[𝕜] F}
@[fun_prop]
theorem HasStrictFDerivAt.fun_sum (h : ∀ i ∈ u, HasStrictFDerivAt (A i) (A' i) x) :
HasStrictFDerivAt (fun y => ∑ i ∈ u, A i y) (∑ i ∈ u, A' i) x := by
simp only [hasStrictFDerivAt_iff_isLittleO] at *
convert IsLittleO.sum h
simp [Finset.sum_sub_distrib, ContinuousLinearMap.sum_apply]
@[fun_prop]
theorem HasStrictFDerivAt.sum (h : ∀ i ∈ u, HasStrictFDerivAt (A i) (A' i) x) :
HasStrictFDerivAt (∑ i ∈ u, A i) (∑ i ∈ u, A' i) x := by
convert HasStrictFDerivAt.fun_sum h; simp
theorem HasFDerivAtFilter.fun_sum (h : ∀ i ∈ u, HasFDerivAtFilter (A i) (A' i) x L) :
HasFDerivAtFilter (fun y => ∑ i ∈ u, A i y) (∑ i ∈ u, A' i) x L := by
simp only [hasFDerivAtFilter_iff_isLittleO] at *
convert IsLittleO.sum h
simp [ContinuousLinearMap.sum_apply]
theorem HasFDerivAtFilter.sum (h : ∀ i ∈ u, HasFDerivAtFilter (A i) (A' i) x L) :
HasFDerivAtFilter (∑ i ∈ u, A i) (∑ i ∈ u, A' i) x L := by
convert HasFDerivAtFilter.fun_sum h; simp
@[fun_prop]
theorem HasFDerivWithinAt.fun_sum (h : ∀ i ∈ u, HasFDerivWithinAt (A i) (A' i) s x) :
HasFDerivWithinAt (fun y => ∑ i ∈ u, A i y) (∑ i ∈ u, A' i) s x :=
HasFDerivAtFilter.fun_sum h
@[fun_prop]
theorem HasFDerivWithinAt.sum (h : ∀ i ∈ u, HasFDerivWithinAt (A i) (A' i) s x) :
HasFDerivWithinAt (∑ i ∈ u, A i) (∑ i ∈ u, A' i) s x :=
HasFDerivAtFilter.sum h
@[fun_prop]
theorem HasFDerivAt.fun_sum (h : ∀ i ∈ u, HasFDerivAt (A i) (A' i) x) :
HasFDerivAt (fun y => ∑ i ∈ u, A i y) (∑ i ∈ u, A' i) x :=
HasFDerivAtFilter.fun_sum h
@[fun_prop]
theorem HasFDerivAt.sum (h : ∀ i ∈ u, HasFDerivAt (A i) (A' i) x) :
HasFDerivAt (∑ i ∈ u, A i) (∑ i ∈ u, A' i) x :=
HasFDerivAtFilter.sum h
@[fun_prop]
theorem DifferentiableWithinAt.fun_sum (h : ∀ i ∈ u, DifferentiableWithinAt 𝕜 (A i) s x) :
DifferentiableWithinAt 𝕜 (fun y => ∑ i ∈ u, A i y) s x :=
HasFDerivWithinAt.differentiableWithinAt <|
HasFDerivWithinAt.fun_sum fun i hi => (h i hi).hasFDerivWithinAt
@[fun_prop]
theorem DifferentiableWithinAt.sum (h : ∀ i ∈ u, DifferentiableWithinAt 𝕜 (A i) s x) :
DifferentiableWithinAt 𝕜 (∑ i ∈ u, A i) s x :=
HasFDerivWithinAt.differentiableWithinAt <|
HasFDerivWithinAt.sum fun i hi => (h i hi).hasFDerivWithinAt
@[simp, fun_prop]
theorem DifferentiableAt.fun_sum (h : ∀ i ∈ u, DifferentiableAt 𝕜 (A i) x) :
DifferentiableAt 𝕜 (fun y => ∑ i ∈ u, A i y) x :=
HasFDerivAt.differentiableAt <| HasFDerivAt.fun_sum fun i hi => (h i hi).hasFDerivAt
@[simp, fun_prop]
theorem DifferentiableAt.sum (h : ∀ i ∈ u, DifferentiableAt 𝕜 (A i) x) :
DifferentiableAt 𝕜 (∑ i ∈ u, A i) x :=
HasFDerivAt.differentiableAt <| HasFDerivAt.sum fun i hi => (h i hi).hasFDerivAt
@[fun_prop]
theorem DifferentiableOn.fun_sum (h : ∀ i ∈ u, DifferentiableOn 𝕜 (A i) s) :
DifferentiableOn 𝕜 (fun y => ∑ i ∈ u, A i y) s := fun x hx =>
DifferentiableWithinAt.fun_sum fun i hi => h i hi x hx
@[fun_prop]
theorem DifferentiableOn.sum (h : ∀ i ∈ u, DifferentiableOn 𝕜 (A i) s) :
DifferentiableOn 𝕜 (∑ i ∈ u, A i) s := fun x hx =>
DifferentiableWithinAt.sum fun i hi => h i hi x hx
@[simp, fun_prop]
theorem Differentiable.fun_sum (h : ∀ i ∈ u, Differentiable 𝕜 (A i)) :
Differentiable 𝕜 fun y => ∑ i ∈ u, A i y :=
fun x => DifferentiableAt.fun_sum fun i hi => h i hi x
@[simp, fun_prop]
theorem Differentiable.sum (h : ∀ i ∈ u, Differentiable 𝕜 (A i)) :
Differentiable 𝕜 (∑ i ∈ u, A i) := fun x => DifferentiableAt.sum fun i hi => h i hi x
theorem fderivWithin_fun_sum (hxs : UniqueDiffWithinAt 𝕜 s x)
(h : ∀ i ∈ u, DifferentiableWithinAt 𝕜 (A i) s x) :
fderivWithin 𝕜 (fun y => ∑ i ∈ u, A i y) s x = ∑ i ∈ u, fderivWithin 𝕜 (A i) s x :=
(HasFDerivWithinAt.fun_sum fun i hi => (h i hi).hasFDerivWithinAt).fderivWithin hxs
theorem fderivWithin_sum (hxs : UniqueDiffWithinAt 𝕜 s x)
(h : ∀ i ∈ u, DifferentiableWithinAt 𝕜 (A i) s x) :
fderivWithin 𝕜 (∑ i ∈ u, A i) s x = ∑ i ∈ u, fderivWithin 𝕜 (A i) s x :=
(HasFDerivWithinAt.sum fun i hi => (h i hi).hasFDerivWithinAt).fderivWithin hxs
theorem fderiv_fun_sum (h : ∀ i ∈ u, DifferentiableAt 𝕜 (A i) x) :
fderiv 𝕜 (fun y => ∑ i ∈ u, A i y) x = ∑ i ∈ u, fderiv 𝕜 (A i) x :=
(HasFDerivAt.fun_sum fun i hi => (h i hi).hasFDerivAt).fderiv
theorem fderiv_sum (h : ∀ i ∈ u, DifferentiableAt 𝕜 (A i) x) :
fderiv 𝕜 (∑ i ∈ u, A i) x = ∑ i ∈ u, fderiv 𝕜 (A i) x :=
(HasFDerivAt.sum fun i hi => (h i hi).hasFDerivAt).fderiv
end Sum
section Neg
/-! ### Derivative of the negative of a function -/
@[fun_prop]
theorem HasStrictFDerivAt.fun_neg (h : HasStrictFDerivAt f f' x) :
HasStrictFDerivAt (fun x => -f x) (-f') x :=
(-1 : F →L[𝕜] F).hasStrictFDerivAt.comp x h
@[fun_prop]
theorem HasStrictFDerivAt.neg (h : HasStrictFDerivAt f f' x) :
HasStrictFDerivAt (-f) (-f') x :=
(-1 : F →L[𝕜] F).hasStrictFDerivAt.comp x h
theorem HasFDerivAtFilter.fun_neg (h : HasFDerivAtFilter f f' x L) :
HasFDerivAtFilter (fun x => -f x) (-f') x L :=
(-1 : F →L[𝕜] F).hasFDerivAtFilter.comp x h tendsto_map
theorem HasFDerivAtFilter.neg (h : HasFDerivAtFilter f f' x L) :
HasFDerivAtFilter (-f) (-f') x L :=
(-1 : F →L[𝕜] F).hasFDerivAtFilter.comp x h tendsto_map
@[fun_prop]
nonrec theorem HasFDerivWithinAt.fun_neg (h : HasFDerivWithinAt f f' s x) :
HasFDerivWithinAt (fun x => -f x) (-f') s x :=
h.neg
@[fun_prop]
nonrec theorem HasFDerivWithinAt.neg (h : HasFDerivWithinAt f f' s x) :
HasFDerivWithinAt (-f) (-f') s x :=
h.neg
@[fun_prop]
nonrec theorem HasFDerivAt.fun_neg (h : HasFDerivAt f f' x) : HasFDerivAt (fun x => -f x) (-f') x :=
h.neg
@[fun_prop]
nonrec theorem HasFDerivAt.neg (h : HasFDerivAt f f' x) : HasFDerivAt (-f) (-f') x :=
h.neg
@[fun_prop]
theorem DifferentiableWithinAt.fun_neg (h : DifferentiableWithinAt 𝕜 f s x) :
DifferentiableWithinAt 𝕜 (fun y => -f y) s x :=
h.hasFDerivWithinAt.neg.differentiableWithinAt
@[fun_prop]
theorem DifferentiableWithinAt.neg (h : DifferentiableWithinAt 𝕜 f s x) :
DifferentiableWithinAt 𝕜 (-f) s x :=
h.hasFDerivWithinAt.neg.differentiableWithinAt
@[simp]
theorem differentiableWithinAt_fun_neg_iff :
DifferentiableWithinAt 𝕜 (fun y => -f y) s x ↔ DifferentiableWithinAt 𝕜 f s x :=
⟨fun h => by simpa only [neg_neg] using h.fun_neg, fun h => h.neg⟩
@[simp]
theorem differentiableWithinAt_neg_iff :
DifferentiableWithinAt 𝕜 (-f) s x ↔ DifferentiableWithinAt 𝕜 f s x :=
⟨fun h => by simpa only [neg_neg] using h.neg, fun h => h.neg⟩
@[fun_prop]
theorem DifferentiableAt.fun_neg (h : DifferentiableAt 𝕜 f x) :
DifferentiableAt 𝕜 (fun y => -f y) x :=
h.hasFDerivAt.neg.differentiableAt
@[fun_prop]
theorem DifferentiableAt.neg (h : DifferentiableAt 𝕜 f x) : DifferentiableAt 𝕜 (-f) x :=
h.hasFDerivAt.neg.differentiableAt
@[simp]
theorem differentiableAt_fun_neg_iff :
DifferentiableAt 𝕜 (fun y => -f y) x ↔ DifferentiableAt 𝕜 f x :=
⟨fun h => by simpa only [neg_neg] using h.fun_neg, fun h => h.neg⟩
@[simp]
theorem differentiableAt_neg_iff : DifferentiableAt 𝕜 (-f) x ↔ DifferentiableAt 𝕜 f x :=
⟨fun h => by simpa only [neg_neg] using h.neg, fun h => h.neg⟩
@[fun_prop]
theorem DifferentiableOn.fun_neg (h : DifferentiableOn 𝕜 f s) :
DifferentiableOn 𝕜 (fun y => -f y) s :=
fun x hx => (h x hx).neg
@[fun_prop]
theorem DifferentiableOn.neg (h : DifferentiableOn 𝕜 f s) : DifferentiableOn 𝕜 (-f) s :=
fun x hx => (h x hx).neg
@[simp]
theorem differentiableOn_fun_neg_iff :
DifferentiableOn 𝕜 (fun y => -f y) s ↔ DifferentiableOn 𝕜 f s :=
⟨fun h => by simpa only [neg_neg] using h.fun_neg, fun h => h.neg⟩
@[simp]
theorem differentiableOn_neg_iff : DifferentiableOn 𝕜 (-f) s ↔ DifferentiableOn 𝕜 f s :=
⟨fun h => by simpa only [neg_neg] using h.neg, fun h => h.neg⟩
@[fun_prop]
theorem Differentiable.fun_neg (h : Differentiable 𝕜 f) : Differentiable 𝕜 fun y => -f y := fun x =>
(h x).neg
@[fun_prop]
theorem Differentiable.neg (h : Differentiable 𝕜 f) : Differentiable 𝕜 (-f) := fun x =>
(h x).neg
@[simp]
theorem differentiable_fun_neg_iff : (Differentiable 𝕜 fun y => -f y) ↔ Differentiable 𝕜 f :=
⟨fun h => by simpa only [neg_neg] using h.fun_neg, fun h => h.neg⟩
@[simp]
theorem differentiable_neg_iff : Differentiable 𝕜 (-f) ↔ Differentiable 𝕜 f :=
⟨fun h => by simpa only [neg_neg] using h.neg, fun h => h.neg⟩
theorem fderivWithin_fun_neg (hxs : UniqueDiffWithinAt 𝕜 s x) :
fderivWithin 𝕜 (fun y => -f y) s x = -fderivWithin 𝕜 f s x := by
classical
by_cases h : DifferentiableWithinAt 𝕜 f s x
· exact h.hasFDerivWithinAt.neg.fderivWithin hxs
· rw [fderivWithin_zero_of_not_differentiableWithinAt h,
fderivWithin_zero_of_not_differentiableWithinAt, neg_zero]
simpa
theorem fderivWithin_neg (hxs : UniqueDiffWithinAt 𝕜 s x) :
fderivWithin 𝕜 (-f) s x = -fderivWithin 𝕜 f s x :=
fderivWithin_fun_neg hxs
@[deprecated (since := "2025-06-14")] alias fderivWithin_neg' := fderivWithin_neg
@[simp]
theorem fderiv_fun_neg : fderiv 𝕜 (fun y => -f y) x = -fderiv 𝕜 f x := by
simp only [← fderivWithin_univ, fderivWithin_fun_neg uniqueDiffWithinAt_univ]
/-- Version of `fderiv_neg` where the function is written `-f` instead of `fun y ↦ - f y`. -/
theorem fderiv_neg : fderiv 𝕜 (-f) x = -fderiv 𝕜 f x :=
fderiv_fun_neg
@[deprecated (since := "2025-06-14")] alias fderiv_neg' := fderiv_neg
end Neg
section Sub
/-! ### Derivative of the difference of two functions -/
@[fun_prop]
theorem HasStrictFDerivAt.fun_sub (hf : HasStrictFDerivAt f f' x) (hg : HasStrictFDerivAt g g' x) :
HasStrictFDerivAt (fun x => f x - g x) (f' - g') x := by
simpa only [sub_eq_add_neg] using hf.add hg.neg
@[fun_prop]
theorem HasStrictFDerivAt.sub (hf : HasStrictFDerivAt f f' x) (hg : HasStrictFDerivAt g g' x) :
HasStrictFDerivAt (f - g) (f' - g') x :=
hf.fun_sub hg
theorem HasFDerivAtFilter.fun_sub (hf : HasFDerivAtFilter f f' x L)
(hg : HasFDerivAtFilter g g' x L) :
HasFDerivAtFilter (fun x => f x - g x) (f' - g') x L := by
simpa only [sub_eq_add_neg] using hf.add hg.neg
theorem HasFDerivAtFilter.sub (hf : HasFDerivAtFilter f f' x L) (hg : HasFDerivAtFilter g g' x L) :
HasFDerivAtFilter (f - g) (f' - g') x L :=
hf.fun_sub hg
@[fun_prop]
nonrec theorem HasFDerivWithinAt.fun_sub (hf : HasFDerivWithinAt f f' s x)
(hg : HasFDerivWithinAt g g' s x) : HasFDerivWithinAt (fun x => f x - g x) (f' - g') s x :=
hf.sub hg
@[fun_prop]
nonrec theorem HasFDerivWithinAt.sub (hf : HasFDerivWithinAt f f' s x)
(hg : HasFDerivWithinAt g g' s x) : HasFDerivWithinAt (f - g) (f' - g') s x :=
hf.sub hg
@[fun_prop]
nonrec theorem HasFDerivAt.fun_sub (hf : HasFDerivAt f f' x) (hg : HasFDerivAt g g' x) :
HasFDerivAt (fun x => f x - g x) (f' - g') x :=
hf.sub hg
@[fun_prop]
nonrec theorem HasFDerivAt.sub (hf : HasFDerivAt f f' x) (hg : HasFDerivAt g g' x) :
HasFDerivAt (f - g) (f' - g') x :=
hf.sub hg
@[fun_prop]
theorem DifferentiableWithinAt.fun_sub (hf : DifferentiableWithinAt 𝕜 f s x)
(hg : DifferentiableWithinAt 𝕜 g s x) : DifferentiableWithinAt 𝕜 (fun y => f y - g y) s x :=
(hf.hasFDerivWithinAt.sub hg.hasFDerivWithinAt).differentiableWithinAt
@[fun_prop]
theorem DifferentiableWithinAt.sub (hf : DifferentiableWithinAt 𝕜 f s x)
(hg : DifferentiableWithinAt 𝕜 g s x) : DifferentiableWithinAt 𝕜 (f - g) s x :=
hf.fun_sub hg
@[simp, fun_prop]
theorem DifferentiableAt.fun_sub (hf : DifferentiableAt 𝕜 f x) (hg : DifferentiableAt 𝕜 g x) :
DifferentiableAt 𝕜 (fun y => f y - g y) x :=
(hf.hasFDerivAt.sub hg.hasFDerivAt).differentiableAt
@[simp, fun_prop]
theorem DifferentiableAt.sub (hf : DifferentiableAt 𝕜 f x) (hg : DifferentiableAt 𝕜 g x) :
DifferentiableAt 𝕜 (f - g) x :=
hf.fun_sub hg
@[simp]
lemma DifferentiableAt.fun_add_iff_left (hg : DifferentiableAt 𝕜 g x) :
DifferentiableAt 𝕜 (fun y => f y + g y) x ↔ DifferentiableAt 𝕜 f x := by
refine ⟨fun h ↦ ?_, fun hf ↦ hf.add hg⟩
simpa only [add_sub_cancel_right] using h.fun_sub hg
@[simp]
lemma DifferentiableAt.add_iff_left (hg : DifferentiableAt 𝕜 g x) :
DifferentiableAt 𝕜 (f + g) x ↔ DifferentiableAt 𝕜 f x :=
hg.fun_add_iff_left
@[simp]
lemma DifferentiableAt.fun_add_iff_right (hg : DifferentiableAt 𝕜 f x) :
DifferentiableAt 𝕜 (fun y => f y + g y) x ↔ DifferentiableAt 𝕜 g x := by
simp only [add_comm (f _), hg.fun_add_iff_left]
@[simp]
lemma DifferentiableAt.add_iff_right (hg : DifferentiableAt 𝕜 f x) :
DifferentiableAt 𝕜 (f + g) x ↔ DifferentiableAt 𝕜 g x :=
hg.fun_add_iff_right
@[simp]
lemma DifferentiableAt.fun_sub_iff_left (hg : DifferentiableAt 𝕜 g x) :
DifferentiableAt 𝕜 (fun y => f y - g y) x ↔ DifferentiableAt 𝕜 f x := by
simp only [sub_eq_add_neg, differentiableAt_fun_neg_iff, hg, fun_add_iff_left]
@[simp]
lemma DifferentiableAt.sub_iff_left (hg : DifferentiableAt 𝕜 g x) :
DifferentiableAt 𝕜 (f - g) x ↔ DifferentiableAt 𝕜 f x :=
hg.fun_sub_iff_left
@[simp]
lemma DifferentiableAt.fun_sub_iff_right (hg : DifferentiableAt 𝕜 f x) :
DifferentiableAt 𝕜 (fun y => f y - g y) x ↔ DifferentiableAt 𝕜 g x := by
simp only [sub_eq_add_neg, hg, fun_add_iff_right, differentiableAt_fun_neg_iff]
@[simp]
lemma DifferentiableAt.sub_iff_right (hg : DifferentiableAt 𝕜 f x) :
DifferentiableAt 𝕜 (f - g) x ↔ DifferentiableAt 𝕜 g x :=
hg.fun_sub_iff_right
@[fun_prop]
theorem DifferentiableOn.fun_sub (hf : DifferentiableOn 𝕜 f s) (hg : DifferentiableOn 𝕜 g s) :
DifferentiableOn 𝕜 (fun y => f y - g y) s := fun x hx => (hf x hx).sub (hg x hx)
@[fun_prop]
theorem DifferentiableOn.sub (hf : DifferentiableOn 𝕜 f s) (hg : DifferentiableOn 𝕜 g s) :
DifferentiableOn 𝕜 (f - g) s := fun x hx => (hf x hx).sub (hg x hx)
@[simp]
lemma DifferentiableOn.fun_add_iff_left (hg : DifferentiableOn 𝕜 g s) :
DifferentiableOn 𝕜 (fun y => f y + g y) s ↔ DifferentiableOn 𝕜 f s := by
refine ⟨fun h ↦ ?_, fun hf ↦ hf.add hg⟩
simpa only [add_sub_cancel_right] using h.fun_sub hg
@[simp]
lemma DifferentiableOn.add_iff_left (hg : DifferentiableOn 𝕜 g s) :
DifferentiableOn 𝕜 (f + g) s ↔ DifferentiableOn 𝕜 f s :=
hg.fun_add_iff_left
@[simp]
lemma DifferentiableOn.fun_add_iff_right (hg : DifferentiableOn 𝕜 f s) :
DifferentiableOn 𝕜 (fun y => f y + g y) s ↔ DifferentiableOn 𝕜 g s := by
simp only [add_comm (f _), hg.fun_add_iff_left]
@[simp]
lemma DifferentiableOn.add_iff_right (hg : DifferentiableOn 𝕜 f s) :
DifferentiableOn 𝕜 (f + g) s ↔ DifferentiableOn 𝕜 g s :=
hg.fun_add_iff_right
@[simp]
lemma DifferentiableOn.fun_sub_iff_left (hg : DifferentiableOn 𝕜 g s) :
DifferentiableOn 𝕜 (fun y => f y - g y) s ↔ DifferentiableOn 𝕜 f s := by
simp only [sub_eq_add_neg, differentiableOn_fun_neg_iff, hg, fun_add_iff_left]
@[simp]
lemma DifferentiableOn.sub_iff_left (hg : DifferentiableOn 𝕜 g s) :
DifferentiableOn 𝕜 (f - g) s ↔ DifferentiableOn 𝕜 f s :=
hg.fun_sub_iff_left
@[simp]
lemma DifferentiableOn.fun_sub_iff_right (hg : DifferentiableOn 𝕜 f s) :
DifferentiableOn 𝕜 (fun y => f y - g y) s ↔ DifferentiableOn 𝕜 g s := by
simp only [sub_eq_add_neg, differentiableOn_fun_neg_iff, hg, fun_add_iff_right]
@[simp]
lemma DifferentiableOn.sub_iff_right (hg : DifferentiableOn 𝕜 f s) :
DifferentiableOn 𝕜 (f - g) s ↔ DifferentiableOn 𝕜 g s :=
hg.fun_sub_iff_right
@[simp, fun_prop]
theorem Differentiable.fun_sub (hf : Differentiable 𝕜 f) (hg : Differentiable 𝕜 g) :
Differentiable 𝕜 fun y => f y - g y := fun x => (hf x).sub (hg x)
@[simp, fun_prop]
theorem Differentiable.sub (hf : Differentiable 𝕜 f) (hg : Differentiable 𝕜 g) :
Differentiable 𝕜 (f - g) := fun x => (hf x).sub (hg x)
@[simp]
lemma Differentiable.fun_add_iff_left (hg : Differentiable 𝕜 g) :
Differentiable 𝕜 (fun y => f y + g y) ↔ Differentiable 𝕜 f := by
refine ⟨fun h ↦ ?_, fun hf ↦ hf.add hg⟩
simpa only [add_sub_cancel_right] using h.fun_sub hg
@[simp]
lemma Differentiable.add_iff_left (hg : Differentiable 𝕜 g) :
Differentiable 𝕜 (f + g) ↔ Differentiable 𝕜 f :=
hg.fun_add_iff_left
@[simp]
lemma Differentiable.fun_add_iff_right (hg : Differentiable 𝕜 f) :
Differentiable 𝕜 (fun y => f y + g y) ↔ Differentiable 𝕜 g := by
simp only [add_comm (f _), hg.fun_add_iff_left]
@[simp]
lemma Differentiable.add_iff_right (hg : Differentiable 𝕜 f) :
Differentiable 𝕜 (f + g) ↔ Differentiable 𝕜 g :=
hg.fun_add_iff_right
@[simp]
lemma Differentiable.fun_sub_iff_left (hg : Differentiable 𝕜 g) :
Differentiable 𝕜 (fun y => f y - g y) ↔ Differentiable 𝕜 f := by
simp only [sub_eq_add_neg, differentiable_fun_neg_iff, hg, fun_add_iff_left]
@[simp]
lemma Differentiable.sub_iff_left (hg : Differentiable 𝕜 g) :
Differentiable 𝕜 (f - g) ↔ Differentiable 𝕜 f :=
hg.fun_sub_iff_left
@[simp]
lemma Differentiable.fun_sub_iff_right (hg : Differentiable 𝕜 f) :
Differentiable 𝕜 (fun y => f y - g y) ↔ Differentiable 𝕜 g := by
simp only [sub_eq_add_neg, differentiable_fun_neg_iff, hg, fun_add_iff_right]
@[simp]
lemma Differentiable.sub_iff_right (hg : Differentiable 𝕜 f) :
Differentiable 𝕜 (f - g) ↔ Differentiable 𝕜 g :=
hg.fun_sub_iff_right
theorem fderivWithin_fun_sub (hxs : UniqueDiffWithinAt 𝕜 s x) (hf : DifferentiableWithinAt 𝕜 f s x)
(hg : DifferentiableWithinAt 𝕜 g s x) :
fderivWithin 𝕜 (fun y => f y - g y) s x = fderivWithin 𝕜 f s x - fderivWithin 𝕜 g s x :=
(hf.hasFDerivWithinAt.sub hg.hasFDerivWithinAt).fderivWithin hxs
theorem fderivWithin_sub (hxs : UniqueDiffWithinAt 𝕜 s x) (hf : DifferentiableWithinAt 𝕜 f s x)
(hg : DifferentiableWithinAt 𝕜 g s x) :
fderivWithin 𝕜 (f - g) s x = fderivWithin 𝕜 f s x - fderivWithin 𝕜 g s x :=
fderivWithin_fun_sub hxs hf hg
@[deprecated (since := "2025-06-14")] alias fderivWithin_sub' := fderivWithin_sub
theorem fderiv_fun_sub (hf : DifferentiableAt 𝕜 f x) (hg : DifferentiableAt 𝕜 g x) :
fderiv 𝕜 (fun y => f y - g y) x = fderiv 𝕜 f x - fderiv 𝕜 g x :=
(hf.hasFDerivAt.sub hg.hasFDerivAt).fderiv
theorem fderiv_sub (hf : DifferentiableAt 𝕜 f x) (hg : DifferentiableAt 𝕜 g x) :
fderiv 𝕜 (f - g) x = fderiv 𝕜 f x - fderiv 𝕜 g x :=
fderiv_fun_sub hf hg
@[deprecated (since := "2025-06-14")] alias fderiv_sub' := fderiv_sub
@[simp]
theorem hasFDerivAtFilter_sub_const_iff (c : F) :
HasFDerivAtFilter (f · - c) f' x L ↔ HasFDerivAtFilter f f' x L := by
simp only [sub_eq_add_neg, hasFDerivAtFilter_add_const_iff]
alias ⟨_, HasFDerivAtFilter.sub_const⟩ := hasFDerivAtFilter_sub_const_iff
@[simp]
theorem hasStrictFDerivAt_sub_const_iff (c : F) :
HasStrictFDerivAt (f · - c) f' x ↔ HasStrictFDerivAt f f' x := by
simp only [sub_eq_add_neg, hasStrictFDerivAt_add_const_iff]
@[fun_prop]
alias ⟨_, HasStrictFDerivAt.sub_const⟩ := hasStrictFDerivAt_sub_const_iff
@[simp]
theorem hasFDerivWithinAt_sub_const_iff (c : F) :
HasFDerivWithinAt (f · - c) f' s x ↔ HasFDerivWithinAt f f' s x :=
hasFDerivAtFilter_sub_const_iff c
@[fun_prop]
alias ⟨_, HasFDerivWithinAt.sub_const⟩ := hasFDerivWithinAt_sub_const_iff
@[simp]
theorem hasFDerivAt_sub_const_iff (c : F) : HasFDerivAt (f · - c) f' x ↔ HasFDerivAt f f' x :=
hasFDerivAtFilter_sub_const_iff c
@[fun_prop]
alias ⟨_, HasFDerivAt.sub_const⟩ := hasFDerivAt_sub_const_iff
@[fun_prop]
theorem hasStrictFDerivAt_sub_const {x : F} (c : F) : HasStrictFDerivAt (· - c) (.id 𝕜 F) x :=
(hasStrictFDerivAt_id x).sub_const c
@[fun_prop]
theorem hasFDerivAt_sub_const {x : F} (c : F) : HasFDerivAt (· - c) (.id 𝕜 F) x :=
(hasFDerivAt_id x).sub_const c
@[fun_prop]
theorem DifferentiableWithinAt.sub_const (hf : DifferentiableWithinAt 𝕜 f s x) (c : F) :
DifferentiableWithinAt 𝕜 (fun y => f y - c) s x :=
(hf.hasFDerivWithinAt.sub_const c).differentiableWithinAt
@[simp]
theorem differentiableWithinAt_sub_const_iff (c : F) :
DifferentiableWithinAt 𝕜 (fun y => f y - c) s x ↔ DifferentiableWithinAt 𝕜 f s x := by
simp only [sub_eq_add_neg, differentiableWithinAt_add_const_iff]
@[fun_prop]
theorem DifferentiableAt.sub_const (hf : DifferentiableAt 𝕜 f x) (c : F) :
DifferentiableAt 𝕜 (fun y => f y - c) x :=
(hf.hasFDerivAt.sub_const c).differentiableAt
@[fun_prop]
theorem DifferentiableOn.sub_const (hf : DifferentiableOn 𝕜 f s) (c : F) :
DifferentiableOn 𝕜 (fun y => f y - c) s := fun x hx => (hf x hx).sub_const c
@[fun_prop]
theorem Differentiable.sub_const (hf : Differentiable 𝕜 f) (c : F) :
Differentiable 𝕜 fun y => f y - c := fun x => (hf x).sub_const c
theorem fderivWithin_sub_const (c : F) :
fderivWithin 𝕜 (fun y => f y - c) s x = fderivWithin 𝕜 f s x := by
simp only [sub_eq_add_neg, fderivWithin_add_const]
theorem fderiv_sub_const (c : F) : fderiv 𝕜 (fun y => f y - c) x = fderiv 𝕜 f x := by
simp only [sub_eq_add_neg, fderiv_add_const]
theorem HasFDerivAtFilter.const_sub (hf : HasFDerivAtFilter f f' x L) (c : F) :
HasFDerivAtFilter (fun x => c - f x) (-f') x L := by
simpa only [sub_eq_add_neg] using hf.neg.const_add c
@[fun_prop]
nonrec theorem HasStrictFDerivAt.const_sub (hf : HasStrictFDerivAt f f' x) (c : F) :
HasStrictFDerivAt (fun x => c - f x) (-f') x := by
simpa only [sub_eq_add_neg] using hf.neg.const_add c
@[fun_prop]
nonrec theorem HasFDerivWithinAt.const_sub (hf : HasFDerivWithinAt f f' s x) (c : F) :
HasFDerivWithinAt (fun x => c - f x) (-f') s x :=
hf.const_sub c
@[fun_prop]
nonrec theorem HasFDerivAt.const_sub (hf : HasFDerivAt f f' x) (c : F) :
HasFDerivAt (fun x => c - f x) (-f') x :=
hf.const_sub c
@[fun_prop]
theorem DifferentiableWithinAt.const_sub (hf : DifferentiableWithinAt 𝕜 f s x) (c : F) :
DifferentiableWithinAt 𝕜 (fun y => c - f y) s x :=
(hf.hasFDerivWithinAt.const_sub c).differentiableWithinAt
@[simp]
theorem differentiableWithinAt_const_sub_iff (c : F) :
DifferentiableWithinAt 𝕜 (fun y => c - f y) s x ↔ DifferentiableWithinAt 𝕜 f s x := by
simp [sub_eq_add_neg]
@[fun_prop]
theorem DifferentiableAt.const_sub (hf : DifferentiableAt 𝕜 f x) (c : F) :
DifferentiableAt 𝕜 (fun y => c - f y) x :=
(hf.hasFDerivAt.const_sub c).differentiableAt
@[fun_prop]
theorem DifferentiableOn.const_sub (hf : DifferentiableOn 𝕜 f s) (c : F) :
DifferentiableOn 𝕜 (fun y => c - f y) s := fun x hx => (hf x hx).const_sub c
@[fun_prop]
theorem Differentiable.const_sub (hf : Differentiable 𝕜 f) (c : F) :
Differentiable 𝕜 fun y => c - f y := fun x => (hf x).const_sub c
theorem fderivWithin_const_sub (hxs : UniqueDiffWithinAt 𝕜 s x) (c : F) :
fderivWithin 𝕜 (fun y => c - f y) s x = -fderivWithin 𝕜 f s x := by
simp only [sub_eq_add_neg, fderivWithin_const_add, fderivWithin_fun_neg, hxs]
theorem fderiv_const_sub (c : F) : fderiv 𝕜 (fun y => c - f y) x = -fderiv 𝕜 f x := by
simp only [← fderivWithin_univ, fderivWithin_const_sub uniqueDiffWithinAt_univ]
end Sub
section CompAdd
/-! ### Derivative of the composition with a translation -/
open scoped Pointwise Topology
theorem hasFDerivWithinAt_comp_add_left (a : E) :
HasFDerivWithinAt (fun x ↦ f (a + x)) f' s x ↔ HasFDerivWithinAt f f' (a +ᵥ s) (a + x) := by
have : map (a + ·) (𝓝[s] x) = 𝓝[a +ᵥ s] (a + x) := by
simp only [nhdsWithin, Filter.map_inf (add_right_injective a)]
simp [← Set.image_vadd]
simp [HasFDerivWithinAt, hasFDerivAtFilter_iff_isLittleOTVS, ← this, Function.comp_def]
theorem differentiableWithinAt_comp_add_left (a : E) :
DifferentiableWithinAt 𝕜 (fun x ↦ f (a + x)) s x ↔
DifferentiableWithinAt 𝕜 f (a +ᵥ s) (a + x) := by
simp [DifferentiableWithinAt, hasFDerivWithinAt_comp_add_left]
theorem fderivWithin_comp_add_left (a : E) :
fderivWithin 𝕜 (fun x ↦ f (a + x)) s x = fderivWithin 𝕜 f (a +ᵥ s) (a + x) := by
classical
simp only [fderivWithin, hasFDerivWithinAt_comp_add_left, differentiableWithinAt_comp_add_left]
theorem hasFDerivWithinAt_comp_add_right (a : E) :
HasFDerivWithinAt (fun x ↦ f (x + a)) f' s x ↔ HasFDerivWithinAt f f' (a +ᵥ s) (x + a) := by
simpa only [add_comm a] using hasFDerivWithinAt_comp_add_left a
theorem differentiableWithinAt_comp_add_right (a : E) :
DifferentiableWithinAt 𝕜 (fun x ↦ f (x + a)) s x ↔
DifferentiableWithinAt 𝕜 f (a +ᵥ s) (x + a) := by
simp [DifferentiableWithinAt, hasFDerivWithinAt_comp_add_right]
theorem fderivWithin_comp_add_right (a : E) :
fderivWithin 𝕜 (fun x ↦ f (x + a)) s x = fderivWithin 𝕜 f (a +ᵥ s) (x + a) := by
simp only [add_comm _ a, fderivWithin_comp_add_left]
theorem hasFDerivAt_comp_add_right (a : E) :
HasFDerivAt (fun x ↦ f (x + a)) f' x ↔ HasFDerivAt f f' (x + a) := by
simp [← hasFDerivWithinAt_univ, hasFDerivWithinAt_comp_add_right]
theorem differentiableAt_comp_add_right (a : E) :
DifferentiableAt 𝕜 (fun x ↦ f (x + a)) x ↔ DifferentiableAt 𝕜 f (x + a) := by
simp [DifferentiableAt, hasFDerivAt_comp_add_right]
theorem fderiv_comp_add_right (a : E) :
fderiv 𝕜 (fun x ↦ f (x + a)) x = fderiv 𝕜 f (x + a) := by
simp [← fderivWithin_univ, fderivWithin_comp_add_right]
theorem hasFDerivAt_comp_add_left (a : E) :
HasFDerivAt (fun x ↦ f (a + x)) f' x ↔ HasFDerivAt f f' (a + x) := by
simpa [add_comm a] using hasFDerivAt_comp_add_right a
theorem differentiableAt_comp_add_left (a : E) :
DifferentiableAt 𝕜 (fun x ↦ f (a + x)) x ↔ DifferentiableAt 𝕜 f (a + x) := by
simp [DifferentiableAt, hasFDerivAt_comp_add_left]
theorem fderiv_comp_add_left (a : E) :
fderiv 𝕜 (fun x ↦ f (a + x)) x = fderiv 𝕜 f (a + x) := by
simpa [add_comm a] using fderiv_comp_add_right a
theorem hasFDerivWithinAt_comp_sub (a : E) :
HasFDerivWithinAt (fun x ↦ f (x - a)) f' s x ↔ HasFDerivWithinAt f f' (-a +ᵥ s) (x - a) := by
simpa [sub_eq_add_neg] using hasFDerivWithinAt_comp_add_right (-a)
theorem differentiableWithinAt_comp_sub (a : E) :
DifferentiableWithinAt 𝕜 (fun x ↦ f (x - a)) s x ↔
DifferentiableWithinAt 𝕜 f (-a +ᵥ s) (x - a) := by
simp [DifferentiableWithinAt, hasFDerivWithinAt_comp_sub]
theorem fderivWithin_comp_sub (a : E) :
fderivWithin 𝕜 (fun x ↦ f (x - a)) s x = fderivWithin 𝕜 f (-a +ᵥ s) (x - a) := by
simpa [sub_eq_add_neg] using fderivWithin_comp_add_right (-a)
theorem hasFDerivAt_comp_sub (a : E) :
HasFDerivAt (fun x ↦ f (x - a)) f' x ↔ HasFDerivAt f f' (x - a) := by
simp [← hasFDerivWithinAt_univ, hasFDerivWithinAt_comp_sub]
theorem differentiableAt_comp_sub (a : E) :
DifferentiableAt 𝕜 (fun x ↦ f (x - a)) x ↔ DifferentiableAt 𝕜 f (x - a) := by
simp [DifferentiableAt, hasFDerivAt_comp_sub]
theorem fderiv_comp_sub (a : E) :
fderiv 𝕜 (fun x ↦ f (x - a)) x = fderiv 𝕜 f (x - a) := by
simp [← fderivWithin_univ, fderivWithin_comp_sub]
end CompAdd
end |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/FDeriv/Star.lean | import Mathlib.Analysis.Calculus.FDeriv.Linear
import Mathlib.Analysis.Calculus.FDeriv.Comp
import Mathlib.Analysis.Calculus.FDeriv.Equiv
import Mathlib.Analysis.CStarAlgebra.Basic
import Mathlib.Topology.Algebra.Module.Star
/-!
# Star operations on derivatives
This file contains the usual formulas (and existence assertions) for the Fréchet derivative of the
star operation. For detailed documentation of the Fréchet derivative, see the module docstring of
`Analysis/Calculus/FDeriv/Basic.lean`.
Most of the results in this file only apply when the field that the derivative is respect to has a
trivial star operation; which as should be expected rules out `𝕜 = ℂ`. The exceptions are
`HasFDerivAt.star_star` and `DifferentiableAt.star_star`, showing that `star ∘ f ∘ star` is
differentiable when `f` is (and giving a formula for its derivative).
-/
variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] [StarRing 𝕜]
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E]
variable {F : Type*} [NormedAddCommGroup F] [StarAddMonoid F] [NormedSpace 𝕜 F] [StarModule 𝕜 F]
[ContinuousStar F]
variable {f : E → F} {f' : E →L[𝕜] F} {x : E} {s : Set E} {L : Filter E}
section TrivialStar
variable [TrivialStar 𝕜]
@[fun_prop]
protected theorem HasStrictFDerivAt.star (h : HasStrictFDerivAt f f' x) :
HasStrictFDerivAt (fun x => star (f x)) (((starL' 𝕜 : F ≃L[𝕜] F) : F →L[𝕜] F) ∘L f') x :=
(starL' 𝕜 : F ≃L[𝕜] F).toContinuousLinearMap.hasStrictFDerivAt.comp x h
protected theorem HasFDerivAtFilter.star (h : HasFDerivAtFilter f f' x L) :
HasFDerivAtFilter (fun x => star (f x)) (((starL' 𝕜 : F ≃L[𝕜] F) : F →L[𝕜] F) ∘L f') x L :=
(starL' 𝕜 : F ≃L[𝕜] F).toContinuousLinearMap.hasFDerivAtFilter.comp x h Filter.tendsto_map
@[fun_prop]
protected nonrec theorem HasFDerivWithinAt.star (h : HasFDerivWithinAt f f' s x) :
HasFDerivWithinAt (fun x => star (f x)) (((starL' 𝕜 : F ≃L[𝕜] F) : F →L[𝕜] F) ∘L f') s x :=
h.star
@[fun_prop]
protected nonrec theorem HasFDerivAt.star (h : HasFDerivAt f f' x) :
HasFDerivAt (fun x => star (f x)) (((starL' 𝕜 : F ≃L[𝕜] F) : F →L[𝕜] F) ∘L f') x :=
h.star
@[fun_prop]
protected theorem DifferentiableWithinAt.star (h : DifferentiableWithinAt 𝕜 f s x) :
DifferentiableWithinAt 𝕜 (fun y => star (f y)) s x :=
h.hasFDerivWithinAt.star.differentiableWithinAt
@[simp]
theorem differentiableWithinAt_star_iff :
DifferentiableWithinAt 𝕜 (fun y => star (f y)) s x ↔ DifferentiableWithinAt 𝕜 f s x :=
(starL' 𝕜 : F ≃L[𝕜] F).comp_differentiableWithinAt_iff
@[fun_prop]
protected theorem DifferentiableAt.star (h : DifferentiableAt 𝕜 f x) :
DifferentiableAt 𝕜 (fun y => star (f y)) x :=
h.hasFDerivAt.star.differentiableAt
@[simp]
theorem differentiableAt_star_iff :
DifferentiableAt 𝕜 (fun y => star (f y)) x ↔ DifferentiableAt 𝕜 f x :=
(starL' 𝕜 : F ≃L[𝕜] F).comp_differentiableAt_iff
@[fun_prop]
protected theorem DifferentiableOn.star (h : DifferentiableOn 𝕜 f s) :
DifferentiableOn 𝕜 (fun y => star (f y)) s := fun x hx => (h x hx).star
@[simp]
theorem differentiableOn_star_iff :
DifferentiableOn 𝕜 (fun y => star (f y)) s ↔ DifferentiableOn 𝕜 f s :=
(starL' 𝕜 : F ≃L[𝕜] F).comp_differentiableOn_iff
@[fun_prop]
protected theorem Differentiable.star (h : Differentiable 𝕜 f) :
Differentiable 𝕜 fun y => star (f y) :=
fun x => (h x).star
@[simp]
theorem differentiable_star_iff : (Differentiable 𝕜 fun y => star (f y)) ↔ Differentiable 𝕜 f :=
(starL' 𝕜 : F ≃L[𝕜] F).comp_differentiable_iff
theorem fderivWithin_star (hxs : UniqueDiffWithinAt 𝕜 s x) :
fderivWithin 𝕜 (fun y => star (f y)) s x =
((starL' 𝕜 : F ≃L[𝕜] F) : F →L[𝕜] F) ∘L fderivWithin 𝕜 f s x :=
(starL' 𝕜 : F ≃L[𝕜] F).comp_fderivWithin hxs
@[simp]
theorem fderiv_star :
fderiv 𝕜 (fun y => star (f y)) x = ((starL' 𝕜 : F ≃L[𝕜] F) : F →L[𝕜] F) ∘L fderiv 𝕜 f x :=
(starL' 𝕜 : F ≃L[𝕜] F).comp_fderiv
end TrivialStar
section NontrivialStar
/-!
## Composing on the left and right with `star`
-/
variable [StarAddMonoid E] [StarModule 𝕜 E] [ContinuousStar E] [NormedStarGroup 𝕜]
/-- If `f` has derivative `f'` at `z`, then `star ∘ f ∘ star` has derivative `starL ∘ f' ∘ starL`
at `star z`. -/
@[fun_prop]
lemma HasFDerivAt.star_star {f : E → F} {z : E} {f' : E →L[𝕜] F} (hf : HasFDerivAt f f' z) :
HasFDerivAt (star ∘ f ∘ star)
((starL 𝕜).toContinuousLinearMap.comp <| f'.comp (starL 𝕜).toContinuousLinearMap) (star z) :=
.comp_semilinear (starL 𝕜).toContinuousLinearMap (starL 𝕜).toContinuousLinearMap
(by simpa using hf)
/-- If `f` is differentiable at `z`, then `star ∘ f ∘ star` is differentiable at `star z`. -/
@[fun_prop]
lemma DifferentiableAt.star_star {f : E → F} {z : E} (hf : DifferentiableAt 𝕜 f z) :
DifferentiableAt 𝕜 (star ∘ f ∘ star) (star z) :=
hf.hasFDerivAt.star_star.differentiableAt
end NontrivialStar |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/FDeriv/Norm.lean | import Mathlib.Analysis.Calculus.Deriv.Abs
import Mathlib.Analysis.Calculus.LineDeriv.Basic
/-!
# Differentiability of the norm in a real normed vector space
This file provides basic results about the differentiability of the norm in a real vector space.
Most are of the following kind: if the norm has some differentiability property
(`DifferentiableAt`, `ContDiffAt`, `HasStrictFDerivAt`, `HasFDerivAt`) at `x`, then so it has
at `t • x` when `t ≠ 0`.
## Main statements
* `ContDiffAt.contDiffAt_norm_smul`: If the norm is continuously differentiable up to order `n`
at `x`, then so it is at `t • x` when `t ≠ 0`.
* `differentiableAt_norm_smul`: If `t ≠ 0`, the norm is differentiable at `x` if and only if
it is at `t • x`.
* `HasFDerivAt.hasFDerivAt_norm_smul`: If the norm has a Fréchet derivative `f` at `x` and `t ≠ 0`,
then it has `(SignType t) • f` as a Fréchet derivative at `t · x`.
* `fderiv_norm_smul` : `fderiv ℝ (‖·‖) (t • x) = (SignType.sign t : ℝ) • (fderiv ℝ (‖·‖) x)`,
this holds without any differentiability assumptions.
* `DifferentiableAt.fderiv_norm_self`: if the norm is differentiable at `x`,
then `fderiv ℝ (‖·‖) x x = ‖x‖`.
* `norm_fderiv_norm`: if the norm is differentiable at `x` then the operator norm of its derivative
is `1` (on a non-trivial space).
## Tags
differentiability, norm
-/
open ContinuousLinearMap Filter NNReal Real Set
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
variable {n : WithTop ℕ∞} {f : StrongDual ℝ E} {x : E} {t : ℝ}
variable (E) in
theorem not_differentiableAt_norm_zero [Nontrivial E] :
¬DifferentiableAt ℝ (‖·‖) (0 : E) := by
obtain ⟨x, hx⟩ := NormedSpace.exists_lt_norm ℝ E 0
intro h
have : DifferentiableAt ℝ (fun t : ℝ ↦ ‖t • x‖) 0 := DifferentiableAt.comp _ (by simpa) (by simp)
have : DifferentiableAt ℝ (|·|) (0 : ℝ) := by
simp_rw [norm_smul, norm_eq_abs] at this
have aux : abs = fun t ↦ (1 / ‖x‖) * (|t| * ‖x‖) := by field_simp
rw [aux]
exact this.const_mul _
exact not_differentiableAt_abs_zero this
theorem ContDiffAt.contDiffAt_norm_smul (ht : t ≠ 0) (h : ContDiffAt ℝ n (‖·‖) x) :
ContDiffAt ℝ n (‖·‖) (t • x) := by
have h1 : ContDiffAt ℝ n (fun y ↦ t⁻¹ • y) (t • x) := (contDiff_const_smul t⁻¹).contDiffAt
have h2 : ContDiffAt ℝ n (fun y ↦ |t| * ‖y‖) x := h.const_smul |t|
conv at h2 => enter [4]; rw [← one_smul ℝ x, ← inv_mul_cancel₀ ht, mul_smul]
convert h2.comp (t • x) h1 using 1
ext y
simp only [Function.comp_apply]
rw [norm_smul, ← mul_assoc, norm_eq_abs, ← abs_mul, mul_inv_cancel₀ ht, abs_one, one_mul]
theorem contDiffAt_norm_smul_iff (ht : t ≠ 0) :
ContDiffAt ℝ n (‖·‖) x ↔ ContDiffAt ℝ n (‖·‖) (t • x) where
mp h := h.contDiffAt_norm_smul ht
mpr hd := by
convert hd.contDiffAt_norm_smul (inv_ne_zero ht)
rw [smul_smul, inv_mul_cancel₀ ht, one_smul]
theorem ContDiffAt.contDiffAt_norm_of_smul (h : ContDiffAt ℝ n (‖·‖) (t • x)) :
ContDiffAt ℝ n (‖·‖) x := by
rcases eq_bot_or_bot_lt n with rfl | hn
· apply contDiffAt_zero.2
exact ⟨univ, univ_mem, continuous_norm.continuousOn⟩
replace hn : 1 ≤ n := ENat.add_one_natCast_le_withTop_of_lt hn
obtain rfl | ht := eq_or_ne t 0
· by_cases! hE : Nontrivial E
· rw [zero_smul] at h
exact (mt (ContDiffAt.differentiableAt · (mod_cast hn)))
(not_differentiableAt_norm_zero E) h |>.elim
· rw [eq_const_of_subsingleton (‖·‖) 0]
exact contDiffAt_const
· exact contDiffAt_norm_smul_iff ht |>.2 h
theorem HasStrictFDerivAt.hasStrictFDerivAt_norm_smul
(ht : t ≠ 0) (h : HasStrictFDerivAt (‖·‖) f x) :
HasStrictFDerivAt (‖·‖) ((SignType.sign t : ℝ) • f) (t • x) := by
have h1 : HasStrictFDerivAt (fun y ↦ t⁻¹ • y) (t⁻¹ • ContinuousLinearMap.id ℝ E) (t • x) :=
hasStrictFDerivAt_id (t • x) |>.const_smul t⁻¹
have h2 : HasStrictFDerivAt (fun y ↦ |t| * ‖y‖) (|t| • f) x := h.const_smul |t|
conv at h2 => enter [3]; rw [← one_smul ℝ x, ← inv_mul_cancel₀ ht, mul_smul]
convert h2.comp (t • x) h1 with y
· rw [norm_smul, ← mul_assoc, norm_eq_abs, ← abs_mul, mul_inv_cancel₀ ht, abs_one, one_mul]
ext y
simp only [coe_smul', Pi.smul_apply, smul_eq_mul, comp_smulₛₗ, map_inv₀, RingHom.id_apply,
comp_id]
rw [eq_inv_mul_iff_mul_eq₀ ht, ← mul_assoc, self_mul_sign]
theorem HasStrictFDerivAt.hasStrictDerivAt_norm_smul_neg
(ht : t < 0) (h : HasStrictFDerivAt (‖·‖) f x) :
HasStrictFDerivAt (‖·‖) (-f) (t • x) := by
simpa [ht] using h.hasStrictFDerivAt_norm_smul ht.ne
theorem HasStrictFDerivAt.hasStrictDerivAt_norm_smul_pos
(ht : 0 < t) (h : HasStrictFDerivAt (‖·‖) f x) :
HasStrictFDerivAt (‖·‖) f (t • x) := by
simpa [ht] using h.hasStrictFDerivAt_norm_smul ht.ne'
theorem HasFDerivAt.hasFDerivAt_norm_smul
(ht : t ≠ 0) (h : HasFDerivAt (‖·‖) f x) :
HasFDerivAt (‖·‖) ((SignType.sign t : ℝ) • f) (t • x) := by
have h1 : HasFDerivAt (fun y ↦ t⁻¹ • y) (t⁻¹ • ContinuousLinearMap.id ℝ E) (t • x) :=
hasFDerivAt_id (t • x) |>.const_smul t⁻¹
have h2 : HasFDerivAt (fun y ↦ |t| * ‖y‖) (|t| • f) x := h.const_smul |t|
conv at h2 => enter [3]; rw [← one_smul ℝ x, ← inv_mul_cancel₀ ht, mul_smul]
convert h2.comp (t • x) h1 using 2 with y
· simp only [Function.comp_apply]
rw [norm_smul, ← mul_assoc, norm_eq_abs, ← abs_mul, mul_inv_cancel₀ ht, abs_one, one_mul]
· ext y
simp only [coe_smul', Pi.smul_apply, smul_eq_mul, comp_smulₛₗ, map_inv₀, RingHom.id_apply,
comp_id]
rw [eq_inv_mul_iff_mul_eq₀ ht, ← mul_assoc, self_mul_sign]
theorem HasFDerivAt.hasFDerivAt_norm_smul_neg
(ht : t < 0) (h : HasFDerivAt (‖·‖) f x) :
HasFDerivAt (‖·‖) (-f) (t • x) := by
simpa [ht] using h.hasFDerivAt_norm_smul ht.ne
theorem HasFDerivAt.hasFDerivAt_norm_smul_pos
(ht : 0 < t) (h : HasFDerivAt (‖·‖) f x) :
HasFDerivAt (‖·‖) f (t • x) := by
simpa [ht] using h.hasFDerivAt_norm_smul ht.ne'
theorem differentiableAt_norm_smul (ht : t ≠ 0) :
DifferentiableAt ℝ (‖·‖) x ↔ DifferentiableAt ℝ (‖·‖) (t • x) where
mp hd := (hd.hasFDerivAt.hasFDerivAt_norm_smul ht).differentiableAt
mpr hd := by
convert (hd.hasFDerivAt.hasFDerivAt_norm_smul (inv_ne_zero ht)).differentiableAt
rw [smul_smul, inv_mul_cancel₀ ht, one_smul]
theorem DifferentiableAt.differentiableAt_norm_of_smul (h : DifferentiableAt ℝ (‖·‖) (t • x)) :
DifferentiableAt ℝ (‖·‖) x := by
obtain rfl | ht := eq_or_ne t 0
· by_cases! hE : Nontrivial E
· rw [zero_smul] at h
exact not_differentiableAt_norm_zero E h |>.elim
· exact (hasFDerivAt_of_subsingleton _ _).differentiableAt
· exact differentiableAt_norm_smul ht |>.2 h
theorem DifferentiableAt.fderiv_norm_self {x : E} (h : DifferentiableAt ℝ (‖·‖) x) :
fderiv ℝ (‖·‖) x x = ‖x‖ := by
rw [← h.lineDeriv_eq_fderiv, lineDeriv]
have this (t : ℝ) : ‖x + t • x‖ = |1 + t| * ‖x‖ := by
rw [← norm_eq_abs, ← norm_smul, add_smul, one_smul]
simp_rw [this]
rw [deriv_mul_const]
· conv_lhs => enter [1, 1]; change _root_.abs ∘ (fun t ↦ 1 + t)
rw [deriv_comp, deriv_abs, deriv_const_add]
· simp
· exact differentiableAt_abs (by simp)
· exact differentiableAt_id.const_add _
· exact (differentiableAt_abs (by simp)).comp _ (differentiableAt_id.const_add _)
variable (x t) in
theorem fderiv_norm_smul :
fderiv ℝ (‖·‖) (t • x) = (SignType.sign t : ℝ) • (fderiv ℝ (‖·‖) x) := by
cases subsingleton_or_nontrivial E
· simp_rw [(hasFDerivAt_of_subsingleton _ _).fderiv, smul_zero]
· by_cases hd : DifferentiableAt ℝ (‖·‖) x
· obtain rfl | ht := eq_or_ne t 0
· simp only [zero_smul, _root_.sign_zero, SignType.coe_zero]
exact fderiv_zero_of_not_differentiableAt <| not_differentiableAt_norm_zero E
· rw [(hd.hasFDerivAt.hasFDerivAt_norm_smul ht).fderiv]
· rw [fderiv_zero_of_not_differentiableAt hd, fderiv_zero_of_not_differentiableAt]
· simp
· exact mt DifferentiableAt.differentiableAt_norm_of_smul hd
theorem fderiv_norm_smul_pos (ht : 0 < t) :
fderiv ℝ (‖·‖) (t • x) = fderiv ℝ (‖·‖) x := by
simp [fderiv_norm_smul, ht]
theorem fderiv_norm_smul_neg (ht : t < 0) :
fderiv ℝ (‖·‖) (t • x) = -fderiv ℝ (‖·‖) x := by
simp [fderiv_norm_smul, ht]
theorem norm_fderiv_norm [Nontrivial E] (h : DifferentiableAt ℝ (‖·‖) x) :
‖fderiv ℝ (‖·‖) x‖ = 1 := by
have : x ≠ 0 := fun hx ↦ not_differentiableAt_norm_zero E (hx ▸ h)
refine le_antisymm (NNReal.coe_one ▸ norm_fderiv_le_of_lipschitz ℝ lipschitzWith_one_norm) ?_
apply le_of_mul_le_mul_right _ (norm_pos_iff.2 this)
calc
1 * ‖x‖ = fderiv ℝ (‖·‖) x x := by rw [one_mul, h.fderiv_norm_self]
_ ≤ ‖fderiv ℝ (‖·‖) x x‖ := le_norm_self _
_ ≤ ‖fderiv ℝ (‖·‖) x‖ * ‖x‖ := le_opNorm _ _ |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/FDeriv/Prod.lean | import Mathlib.Analysis.Calculus.FDeriv.Comp
import Mathlib.Analysis.Calculus.FDeriv.Const
import Mathlib.Analysis.Calculus.FDeriv.Linear
/-!
# Derivative of the Cartesian product of functions
For detailed documentation of the Fréchet derivative,
see the module docstring of `Analysis/Calculus/FDeriv/Basic.lean`.
This file contains the usual formulas (and existence assertions) for the derivative of
Cartesian products of functions, and functions into Pi-types.
-/
open Filter Asymptotics ContinuousLinearMap Set Metric Topology NNReal ENNReal
noncomputable section
section
variable {𝕜 : Type*} [NontriviallyNormedField 𝕜]
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E]
variable {F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F]
variable {G : Type*} [NormedAddCommGroup G] [NormedSpace 𝕜 G]
variable {G' : Type*} [NormedAddCommGroup G'] [NormedSpace 𝕜 G']
variable {f f₀ f₁ g : E → F}
variable {f' f₀' f₁' g' : E →L[𝕜] F}
variable (e : E →L[𝕜] F)
variable {x : E}
variable {s t : Set E}
variable {L L₁ L₂ : Filter E}
section CartesianProduct
/-! ### Derivative of the Cartesian product of two functions -/
section Prod
variable {f₂ : E → G} {f₂' : E →L[𝕜] G}
protected theorem HasStrictFDerivAt.prodMk (hf₁ : HasStrictFDerivAt f₁ f₁' x)
(hf₂ : HasStrictFDerivAt f₂ f₂' x) :
HasStrictFDerivAt (fun x => (f₁ x, f₂ x)) (f₁'.prod f₂') x :=
.of_isLittleO <| hf₁.isLittleO.prod_left hf₂.isLittleO
theorem HasFDerivAtFilter.prodMk (hf₁ : HasFDerivAtFilter f₁ f₁' x L)
(hf₂ : HasFDerivAtFilter f₂ f₂' x L) :
HasFDerivAtFilter (fun x => (f₁ x, f₂ x)) (f₁'.prod f₂') x L :=
.of_isLittleO <| hf₁.isLittleO.prod_left hf₂.isLittleO
@[fun_prop]
nonrec theorem HasFDerivWithinAt.prodMk (hf₁ : HasFDerivWithinAt f₁ f₁' s x)
(hf₂ : HasFDerivWithinAt f₂ f₂' s x) :
HasFDerivWithinAt (fun x => (f₁ x, f₂ x)) (f₁'.prod f₂') s x :=
hf₁.prodMk hf₂
@[fun_prop]
nonrec theorem HasFDerivAt.prodMk (hf₁ : HasFDerivAt f₁ f₁' x) (hf₂ : HasFDerivAt f₂ f₂' x) :
HasFDerivAt (fun x => (f₁ x, f₂ x)) (f₁'.prod f₂') x :=
hf₁.prodMk hf₂
@[fun_prop]
theorem hasFDerivAt_prodMk_left (e₀ : E) (f₀ : F) :
HasFDerivAt (fun e : E => (e, f₀)) (inl 𝕜 E F) e₀ :=
(hasFDerivAt_id e₀).prodMk (hasFDerivAt_const f₀ e₀)
@[fun_prop]
theorem hasFDerivAt_prodMk_right (e₀ : E) (f₀ : F) :
HasFDerivAt (fun f : F => (e₀, f)) (inr 𝕜 E F) f₀ :=
(hasFDerivAt_const e₀ f₀).prodMk (hasFDerivAt_id f₀)
@[fun_prop]
theorem DifferentiableWithinAt.prodMk (hf₁ : DifferentiableWithinAt 𝕜 f₁ s x)
(hf₂ : DifferentiableWithinAt 𝕜 f₂ s x) :
DifferentiableWithinAt 𝕜 (fun x : E => (f₁ x, f₂ x)) s x :=
(hf₁.hasFDerivWithinAt.prodMk hf₂.hasFDerivWithinAt).differentiableWithinAt
@[simp, fun_prop]
theorem DifferentiableAt.prodMk (hf₁ : DifferentiableAt 𝕜 f₁ x) (hf₂ : DifferentiableAt 𝕜 f₂ x) :
DifferentiableAt 𝕜 (fun x : E => (f₁ x, f₂ x)) x :=
(hf₁.hasFDerivAt.prodMk hf₂.hasFDerivAt).differentiableAt
@[fun_prop]
theorem DifferentiableOn.prodMk (hf₁ : DifferentiableOn 𝕜 f₁ s) (hf₂ : DifferentiableOn 𝕜 f₂ s) :
DifferentiableOn 𝕜 (fun x : E => (f₁ x, f₂ x)) s := fun x hx => (hf₁ x hx).prodMk (hf₂ x hx)
@[simp, fun_prop]
theorem Differentiable.prodMk (hf₁ : Differentiable 𝕜 f₁) (hf₂ : Differentiable 𝕜 f₂) :
Differentiable 𝕜 fun x : E => (f₁ x, f₂ x) := fun x ↦
(hf₁ x).prodMk (hf₂ x)
theorem DifferentiableAt.fderiv_prodMk (hf₁ : DifferentiableAt 𝕜 f₁ x)
(hf₂ : DifferentiableAt 𝕜 f₂ x) :
fderiv 𝕜 (fun x : E => (f₁ x, f₂ x)) x = (fderiv 𝕜 f₁ x).prod (fderiv 𝕜 f₂ x) :=
(hf₁.hasFDerivAt.prodMk hf₂.hasFDerivAt).fderiv
theorem DifferentiableWithinAt.fderivWithin_prodMk (hf₁ : DifferentiableWithinAt 𝕜 f₁ s x)
(hf₂ : DifferentiableWithinAt 𝕜 f₂ s x) (hxs : UniqueDiffWithinAt 𝕜 s x) :
fderivWithin 𝕜 (fun x : E => (f₁ x, f₂ x)) s x =
(fderivWithin 𝕜 f₁ s x).prod (fderivWithin 𝕜 f₂ s x) :=
(hf₁.hasFDerivWithinAt.prodMk hf₂.hasFDerivWithinAt).fderivWithin hxs
end Prod
section Fst
variable {f₂ : E → F × G} {f₂' : E →L[𝕜] F × G} {p : E × F}
@[fun_prop]
theorem hasStrictFDerivAt_fst : HasStrictFDerivAt (@Prod.fst E F) (fst 𝕜 E F) p :=
(fst 𝕜 E F).hasStrictFDerivAt
@[fun_prop]
protected theorem HasStrictFDerivAt.fst (h : HasStrictFDerivAt f₂ f₂' x) :
HasStrictFDerivAt (fun x => (f₂ x).1) ((fst 𝕜 F G).comp f₂') x :=
hasStrictFDerivAt_fst.comp x h
theorem hasFDerivAtFilter_fst {L : Filter (E × F)} :
HasFDerivAtFilter (@Prod.fst E F) (fst 𝕜 E F) p L :=
(fst 𝕜 E F).hasFDerivAtFilter
protected theorem HasFDerivAtFilter.fst (h : HasFDerivAtFilter f₂ f₂' x L) :
HasFDerivAtFilter (fun x => (f₂ x).1) ((fst 𝕜 F G).comp f₂') x L :=
hasFDerivAtFilter_fst.comp x h tendsto_map
@[fun_prop]
theorem hasFDerivAt_fst : HasFDerivAt (@Prod.fst E F) (fst 𝕜 E F) p :=
hasFDerivAtFilter_fst
@[fun_prop]
protected nonrec theorem HasFDerivAt.fst (h : HasFDerivAt f₂ f₂' x) :
HasFDerivAt (fun x => (f₂ x).1) ((fst 𝕜 F G).comp f₂') x :=
h.fst
@[fun_prop]
theorem hasFDerivWithinAt_fst {s : Set (E × F)} :
HasFDerivWithinAt (@Prod.fst E F) (fst 𝕜 E F) s p :=
hasFDerivAtFilter_fst
@[fun_prop]
protected nonrec theorem HasFDerivWithinAt.fst (h : HasFDerivWithinAt f₂ f₂' s x) :
HasFDerivWithinAt (fun x => (f₂ x).1) ((fst 𝕜 F G).comp f₂') s x :=
h.fst
@[fun_prop]
theorem differentiableAt_fst : DifferentiableAt 𝕜 Prod.fst p :=
hasFDerivAt_fst.differentiableAt
@[simp, fun_prop]
protected theorem DifferentiableAt.fst (h : DifferentiableAt 𝕜 f₂ x) :
DifferentiableAt 𝕜 (fun x => (f₂ x).1) x :=
differentiableAt_fst.comp x h
@[fun_prop]
theorem differentiable_fst : Differentiable 𝕜 (Prod.fst : E × F → E) := fun _ =>
differentiableAt_fst
@[simp, fun_prop]
protected theorem Differentiable.fst (h : Differentiable 𝕜 f₂) :
Differentiable 𝕜 fun x => (f₂ x).1 :=
differentiable_fst.comp h
@[fun_prop]
theorem differentiableWithinAt_fst {s : Set (E × F)} : DifferentiableWithinAt 𝕜 Prod.fst s p :=
differentiableAt_fst.differentiableWithinAt
@[fun_prop]
protected theorem DifferentiableWithinAt.fst (h : DifferentiableWithinAt 𝕜 f₂ s x) :
DifferentiableWithinAt 𝕜 (fun x => (f₂ x).1) s x :=
differentiableAt_fst.comp_differentiableWithinAt x h
@[fun_prop]
theorem differentiableOn_fst {s : Set (E × F)} : DifferentiableOn 𝕜 Prod.fst s :=
differentiable_fst.differentiableOn
@[fun_prop]
protected theorem DifferentiableOn.fst (h : DifferentiableOn 𝕜 f₂ s) :
DifferentiableOn 𝕜 (fun x => (f₂ x).1) s :=
differentiable_fst.comp_differentiableOn h
theorem fderiv_fst : fderiv 𝕜 Prod.fst p = fst 𝕜 E F :=
hasFDerivAt_fst.fderiv
theorem fderiv.fst (h : DifferentiableAt 𝕜 f₂ x) :
fderiv 𝕜 (fun x => (f₂ x).1) x = (fst 𝕜 F G).comp (fderiv 𝕜 f₂ x) :=
h.hasFDerivAt.fst.fderiv
theorem fderivWithin_fst {s : Set (E × F)} (hs : UniqueDiffWithinAt 𝕜 s p) :
fderivWithin 𝕜 Prod.fst s p = fst 𝕜 E F :=
hasFDerivWithinAt_fst.fderivWithin hs
theorem fderivWithin.fst (hs : UniqueDiffWithinAt 𝕜 s x) (h : DifferentiableWithinAt 𝕜 f₂ s x) :
fderivWithin 𝕜 (fun x => (f₂ x).1) s x = (fst 𝕜 F G).comp (fderivWithin 𝕜 f₂ s x) :=
h.hasFDerivWithinAt.fst.fderivWithin hs
end Fst
section Snd
variable {f₂ : E → F × G} {f₂' : E →L[𝕜] F × G} {p : E × F}
@[fun_prop]
theorem hasStrictFDerivAt_snd : HasStrictFDerivAt (@Prod.snd E F) (snd 𝕜 E F) p :=
(snd 𝕜 E F).hasStrictFDerivAt
@[fun_prop]
protected theorem HasStrictFDerivAt.snd (h : HasStrictFDerivAt f₂ f₂' x) :
HasStrictFDerivAt (fun x => (f₂ x).2) ((snd 𝕜 F G).comp f₂') x :=
hasStrictFDerivAt_snd.comp x h
theorem hasFDerivAtFilter_snd {L : Filter (E × F)} :
HasFDerivAtFilter (@Prod.snd E F) (snd 𝕜 E F) p L :=
(snd 𝕜 E F).hasFDerivAtFilter
protected theorem HasFDerivAtFilter.snd (h : HasFDerivAtFilter f₂ f₂' x L) :
HasFDerivAtFilter (fun x => (f₂ x).2) ((snd 𝕜 F G).comp f₂') x L :=
hasFDerivAtFilter_snd.comp x h tendsto_map
@[fun_prop]
theorem hasFDerivAt_snd : HasFDerivAt (@Prod.snd E F) (snd 𝕜 E F) p :=
hasFDerivAtFilter_snd
@[fun_prop]
protected nonrec theorem HasFDerivAt.snd (h : HasFDerivAt f₂ f₂' x) :
HasFDerivAt (fun x => (f₂ x).2) ((snd 𝕜 F G).comp f₂') x :=
h.snd
@[fun_prop]
theorem hasFDerivWithinAt_snd {s : Set (E × F)} :
HasFDerivWithinAt (@Prod.snd E F) (snd 𝕜 E F) s p :=
hasFDerivAtFilter_snd
@[fun_prop]
protected nonrec theorem HasFDerivWithinAt.snd (h : HasFDerivWithinAt f₂ f₂' s x) :
HasFDerivWithinAt (fun x => (f₂ x).2) ((snd 𝕜 F G).comp f₂') s x :=
h.snd
@[fun_prop]
theorem differentiableAt_snd : DifferentiableAt 𝕜 Prod.snd p :=
hasFDerivAt_snd.differentiableAt
@[simp, fun_prop]
protected theorem DifferentiableAt.snd (h : DifferentiableAt 𝕜 f₂ x) :
DifferentiableAt 𝕜 (fun x => (f₂ x).2) x :=
differentiableAt_snd.comp x h
@[fun_prop]
theorem differentiable_snd : Differentiable 𝕜 (Prod.snd : E × F → F) := fun _ =>
differentiableAt_snd
@[simp, fun_prop]
protected theorem Differentiable.snd (h : Differentiable 𝕜 f₂) :
Differentiable 𝕜 fun x => (f₂ x).2 :=
differentiable_snd.comp h
@[fun_prop]
theorem differentiableWithinAt_snd {s : Set (E × F)} : DifferentiableWithinAt 𝕜 Prod.snd s p :=
differentiableAt_snd.differentiableWithinAt
@[fun_prop]
protected theorem DifferentiableWithinAt.snd (h : DifferentiableWithinAt 𝕜 f₂ s x) :
DifferentiableWithinAt 𝕜 (fun x => (f₂ x).2) s x :=
differentiableAt_snd.comp_differentiableWithinAt x h
@[fun_prop]
theorem differentiableOn_snd {s : Set (E × F)} : DifferentiableOn 𝕜 Prod.snd s :=
differentiable_snd.differentiableOn
@[fun_prop]
protected theorem DifferentiableOn.snd (h : DifferentiableOn 𝕜 f₂ s) :
DifferentiableOn 𝕜 (fun x => (f₂ x).2) s :=
differentiable_snd.comp_differentiableOn h
theorem fderiv_snd : fderiv 𝕜 Prod.snd p = snd 𝕜 E F :=
hasFDerivAt_snd.fderiv
theorem fderiv.snd (h : DifferentiableAt 𝕜 f₂ x) :
fderiv 𝕜 (fun x => (f₂ x).2) x = (snd 𝕜 F G).comp (fderiv 𝕜 f₂ x) :=
h.hasFDerivAt.snd.fderiv
theorem fderivWithin_snd {s : Set (E × F)} (hs : UniqueDiffWithinAt 𝕜 s p) :
fderivWithin 𝕜 Prod.snd s p = snd 𝕜 E F :=
hasFDerivWithinAt_snd.fderivWithin hs
theorem fderivWithin.snd (hs : UniqueDiffWithinAt 𝕜 s x) (h : DifferentiableWithinAt 𝕜 f₂ s x) :
fderivWithin 𝕜 (fun x => (f₂ x).2) s x = (snd 𝕜 F G).comp (fderivWithin 𝕜 f₂ s x) :=
h.hasFDerivWithinAt.snd.fderivWithin hs
end Snd
section prodMap
variable {f₂ : G → G'} {f₂' : G →L[𝕜] G'} {y : G} (p : E × G)
@[fun_prop]
protected theorem HasStrictFDerivAt.prodMap (hf : HasStrictFDerivAt f f' p.1)
(hf₂ : HasStrictFDerivAt f₂ f₂' p.2) : HasStrictFDerivAt (Prod.map f f₂) (f'.prodMap f₂') p :=
(hf.comp p hasStrictFDerivAt_fst).prodMk (hf₂.comp p hasStrictFDerivAt_snd)
@[fun_prop]
protected theorem HasFDerivWithinAt.prodMap {s : Set <| E × G}
(hf : HasFDerivWithinAt f f' (Prod.fst '' s) p.1)
(hf₂ : HasFDerivWithinAt f₂ f₂' (Prod.snd '' s) p.2) :
HasFDerivWithinAt (Prod.map f f₂) (f'.prodMap f₂') s p :=
(hf.comp _ hasFDerivWithinAt_fst mapsTo_fst_prod).prodMk
(hf₂.comp _ hasFDerivWithinAt_snd mapsTo_snd_prod) |>.mono (by grind)
@[fun_prop]
protected theorem HasFDerivAt.prodMap (hf : HasFDerivAt f f' p.1) (hf₂ : HasFDerivAt f₂ f₂' p.2) :
HasFDerivAt (Prod.map f f₂) (f'.prodMap f₂') p :=
(hf.comp p hasFDerivAt_fst).prodMk (hf₂.comp p hasFDerivAt_snd)
@[simp, fun_prop]
protected theorem DifferentiableAt.prodMap (hf : DifferentiableAt 𝕜 f p.1)
(hf₂ : DifferentiableAt 𝕜 f₂ p.2) : DifferentiableAt 𝕜 (fun p : E × G => (f p.1, f₂ p.2)) p :=
(hf.comp p differentiableAt_fst).prodMk (hf₂.comp p differentiableAt_snd)
end prodMap
section Pi
/-!
### Derivatives of functions `f : E → Π i, F' i`
In this section we formulate `has*FDeriv*_pi` theorems as `iff`s, and provide two versions of each
theorem:
* the version without `'` deals with `φ : Π i, E → F' i` and `φ' : Π i, E →L[𝕜] F' i`
and is designed to deduce differentiability of `fun x i ↦ φ i x` from differentiability
of each `φ i`;
* the version with `'` deals with `Φ : E → Π i, F' i` and `Φ' : E →L[𝕜] Π i, F' i`
and is designed to deduce differentiability of the components `fun x ↦ Φ x i` from
differentiability of `Φ`.
-/
variable {ι : Type*} [Fintype ι] {F' : ι → Type*} [∀ i, NormedAddCommGroup (F' i)]
[∀ i, NormedSpace 𝕜 (F' i)] {φ : ∀ i, E → F' i} {φ' : ∀ i, E →L[𝕜] F' i} {Φ : E → ∀ i, F' i}
{Φ' : E →L[𝕜] ∀ i, F' i}
@[simp]
theorem hasStrictFDerivAt_pi' :
HasStrictFDerivAt Φ Φ' x ↔ ∀ i, HasStrictFDerivAt (fun x => Φ x i) ((proj i).comp Φ') x := by
simp only [hasStrictFDerivAt_iff_isLittleO]
exact isLittleO_pi
@[fun_prop]
theorem hasStrictFDerivAt_pi'' (hφ : ∀ i, HasStrictFDerivAt (fun x => Φ x i) ((proj i).comp Φ') x) :
HasStrictFDerivAt Φ Φ' x := hasStrictFDerivAt_pi'.2 hφ
@[fun_prop]
theorem hasStrictFDerivAt_apply (i : ι) (f : ∀ i, F' i) :
HasStrictFDerivAt (𝕜 := 𝕜) (fun f : ∀ i, F' i => f i) (proj i) f := by
let id' := ContinuousLinearMap.id 𝕜 (∀ i, F' i)
have h := ((hasStrictFDerivAt_pi'
(Φ := fun (f : ∀ i, F' i) (i' : ι) => f i') (Φ' := id') (x := f))).1
have h' : comp (proj i) id' = proj i := by ext; simp [id']
rw [← h']; apply h; apply hasStrictFDerivAt_id
theorem hasStrictFDerivAt_pi :
HasStrictFDerivAt (fun x i => φ i x) (ContinuousLinearMap.pi φ') x ↔
∀ i, HasStrictFDerivAt (φ i) (φ' i) x :=
hasStrictFDerivAt_pi'
@[simp]
theorem hasFDerivAtFilter_pi' :
HasFDerivAtFilter Φ Φ' x L ↔
∀ i, HasFDerivAtFilter (fun x => Φ x i) ((proj i).comp Φ') x L := by
simp only [hasFDerivAtFilter_iff_isLittleO]
exact isLittleO_pi
theorem hasFDerivAtFilter_pi :
HasFDerivAtFilter (fun x i => φ i x) (ContinuousLinearMap.pi φ') x L ↔
∀ i, HasFDerivAtFilter (φ i) (φ' i) x L :=
hasFDerivAtFilter_pi'
@[simp]
theorem hasFDerivAt_pi' :
HasFDerivAt Φ Φ' x ↔ ∀ i, HasFDerivAt (fun x => Φ x i) ((proj i).comp Φ') x :=
hasFDerivAtFilter_pi'
@[fun_prop]
theorem hasFDerivAt_pi'' (hφ : ∀ i, HasFDerivAt (fun x => Φ x i) ((proj i).comp Φ') x) :
HasFDerivAt Φ Φ' x := hasFDerivAt_pi'.2 hφ
@[fun_prop]
theorem hasFDerivAt_apply (i : ι) (f : ∀ i, F' i) :
HasFDerivAt (𝕜 := 𝕜) (fun f : ∀ i, F' i => f i) (proj i) f := by
apply HasStrictFDerivAt.hasFDerivAt
apply hasStrictFDerivAt_apply
theorem hasFDerivAt_pi :
HasFDerivAt (fun x i => φ i x) (ContinuousLinearMap.pi φ') x ↔
∀ i, HasFDerivAt (φ i) (φ' i) x :=
hasFDerivAtFilter_pi
@[simp]
theorem hasFDerivWithinAt_pi' :
HasFDerivWithinAt Φ Φ' s x ↔ ∀ i, HasFDerivWithinAt (fun x => Φ x i) ((proj i).comp Φ') s x :=
hasFDerivAtFilter_pi'
@[fun_prop]
theorem hasFDerivWithinAt_pi''
(hφ : ∀ i, HasFDerivWithinAt (fun x => Φ x i) ((proj i).comp Φ') s x) :
HasFDerivWithinAt Φ Φ' s x := hasFDerivWithinAt_pi'.2 hφ
@[fun_prop]
theorem hasFDerivWithinAt_apply (i : ι) (f : ∀ i, F' i) (s' : Set (∀ i, F' i)) :
HasFDerivWithinAt (𝕜 := 𝕜) (fun f : ∀ i, F' i => f i) (proj i) s' f := by
let id' := ContinuousLinearMap.id 𝕜 (∀ i, F' i)
have h := ((hasFDerivWithinAt_pi'
(Φ := fun (f : ∀ i, F' i) (i' : ι) => f i') (Φ' := id') (x := f) (s := s'))).1
have h' : comp (proj i) id' = proj i := by rfl
rw [← h']; apply h; apply hasFDerivWithinAt_id
theorem hasFDerivWithinAt_pi :
HasFDerivWithinAt (fun x i => φ i x) (ContinuousLinearMap.pi φ') s x ↔
∀ i, HasFDerivWithinAt (φ i) (φ' i) s x :=
hasFDerivAtFilter_pi
@[simp]
theorem differentiableWithinAt_pi :
DifferentiableWithinAt 𝕜 Φ s x ↔ ∀ i, DifferentiableWithinAt 𝕜 (fun x => Φ x i) s x :=
⟨fun h i => (hasFDerivWithinAt_pi'.1 h.hasFDerivWithinAt i).differentiableWithinAt, fun h =>
(hasFDerivWithinAt_pi.2 fun i => (h i).hasFDerivWithinAt).differentiableWithinAt⟩
@[fun_prop]
theorem differentiableWithinAt_pi'' (hφ : ∀ i, DifferentiableWithinAt 𝕜 (fun x => Φ x i) s x) :
DifferentiableWithinAt 𝕜 Φ s x := differentiableWithinAt_pi.2 hφ
@[fun_prop]
theorem differentiableWithinAt_apply (i : ι) (f : ∀ i, F' i) (s' : Set (∀ i, F' i)) :
DifferentiableWithinAt (𝕜 := 𝕜) (fun f : ∀ i, F' i => f i) s' f := by
apply HasFDerivWithinAt.differentiableWithinAt
fun_prop
@[simp]
theorem differentiableAt_pi : DifferentiableAt 𝕜 Φ x ↔ ∀ i, DifferentiableAt 𝕜 (fun x => Φ x i) x :=
⟨fun h i => (hasFDerivAt_pi'.1 h.hasFDerivAt i).differentiableAt, fun h =>
(hasFDerivAt_pi.2 fun i => (h i).hasFDerivAt).differentiableAt⟩
@[fun_prop]
theorem differentiableAt_pi'' (hφ : ∀ i, DifferentiableAt 𝕜 (fun x => Φ x i) x) :
DifferentiableAt 𝕜 Φ x := differentiableAt_pi.2 hφ
@[fun_prop]
theorem differentiableAt_apply (i : ι) (f : ∀ i, F' i) :
DifferentiableAt (𝕜 := 𝕜) (fun f : ∀ i, F' i => f i) f := by
have h := ((differentiableAt_pi (𝕜 := 𝕜)
(Φ := fun (f : ∀ i, F' i) (i' : ι) => f i') (x := f))).1
apply h; apply differentiableAt_id
theorem differentiableOn_pi : DifferentiableOn 𝕜 Φ s ↔ ∀ i, DifferentiableOn 𝕜 (fun x => Φ x i) s :=
⟨fun h i x hx => differentiableWithinAt_pi.1 (h x hx) i, fun h x hx =>
differentiableWithinAt_pi.2 fun i => h i x hx⟩
@[fun_prop]
theorem differentiableOn_pi'' (hφ : ∀ i, DifferentiableOn 𝕜 (fun x => Φ x i) s) :
DifferentiableOn 𝕜 Φ s := differentiableOn_pi.2 hφ
@[fun_prop]
theorem differentiableOn_apply (i : ι) (s' : Set (∀ i, F' i)) :
DifferentiableOn (𝕜 := 𝕜) (fun f : ∀ i, F' i => f i) s' := by
have h := ((differentiableOn_pi (𝕜 := 𝕜)
(Φ := fun (f : ∀ i, F' i) (i' : ι) => f i') (s := s'))).1
apply h; apply differentiableOn_id
theorem differentiable_pi : Differentiable 𝕜 Φ ↔ ∀ i, Differentiable 𝕜 fun x => Φ x i :=
⟨fun h i x => differentiableAt_pi.1 (h x) i, fun h x => differentiableAt_pi.2 fun i => h i x⟩
@[fun_prop]
theorem differentiable_pi'' (hφ : ∀ i, Differentiable 𝕜 fun x => Φ x i) :
Differentiable 𝕜 Φ := differentiable_pi.2 hφ
@[fun_prop]
theorem differentiable_apply (i : ι) :
Differentiable (𝕜 := 𝕜) (fun f : ∀ i, F' i => f i) := by intro x; apply differentiableAt_apply
-- TODO: find out which version (`φ` or `Φ`) works better with `rw`/`simp`
theorem fderivWithin_pi (h : ∀ i, DifferentiableWithinAt 𝕜 (φ i) s x)
(hs : UniqueDiffWithinAt 𝕜 s x) :
fderivWithin 𝕜 (fun x i => φ i x) s x = pi fun i => fderivWithin 𝕜 (φ i) s x :=
(hasFDerivWithinAt_pi.2 fun i => (h i).hasFDerivWithinAt).fderivWithin hs
theorem fderiv_pi (h : ∀ i, DifferentiableAt 𝕜 (φ i) x) :
fderiv 𝕜 (fun x i => φ i x) x = pi fun i => fderiv 𝕜 (φ i) x :=
(hasFDerivAt_pi.2 fun i => (h i).hasFDerivAt).fderiv
end Pi
/-!
### Derivatives of tuples `f : E → Π i : Fin n.succ, F' i`
These can be used to prove results about functions of the form `fun x ↦ ![f x, g x, h x]`,
as `Matrix.vecCons` is defeq to `Fin.cons`.
-/
section PiFin
variable {n : Nat} {F' : Fin n.succ → Type*}
variable [∀ i, NormedAddCommGroup (F' i)] [∀ i, NormedSpace 𝕜 (F' i)]
variable {φ : E → F' 0} {φs : E → ∀ i, F' (Fin.succ i)}
theorem hasStrictFDerivAt_finCons {φ' : E →L[𝕜] Π i, F' i} :
HasStrictFDerivAt (fun x => Fin.cons (φ x) (φs x)) φ' x ↔
HasStrictFDerivAt φ (.proj 0 ∘L φ') x ∧
HasStrictFDerivAt φs (Pi.compRightL 𝕜 F' Fin.succ ∘L φ') x := by
rw [hasStrictFDerivAt_pi', Fin.forall_fin_succ, hasStrictFDerivAt_pi']
dsimp [ContinuousLinearMap.comp, LinearMap.comp, Function.comp_def]
simp only [Fin.cons_zero, Fin.cons_succ]
/-- A variant of `hasStrictFDerivAt_finCons` where the derivative variables are free on the RHS
instead. -/
theorem hasStrictFDerivAt_finCons'
{φ' : E →L[𝕜] F' 0} {φs' : E →L[𝕜] Π i, F' (Fin.succ i)} :
HasStrictFDerivAt (fun x => Fin.cons (φ x) (φs x)) (φ'.finCons φs') x ↔
HasStrictFDerivAt φ φ' x ∧ HasStrictFDerivAt φs φs' x :=
hasStrictFDerivAt_finCons
@[fun_prop]
theorem HasStrictFDerivAt.finCons
{φ' : E →L[𝕜] F' 0} {φs' : E →L[𝕜] Π i, F' (Fin.succ i)}
(h : HasStrictFDerivAt φ φ' x) (hs : HasStrictFDerivAt φs φs' x) :
HasStrictFDerivAt (fun x => Fin.cons (φ x) (φs x)) (φ'.finCons φs') x :=
hasStrictFDerivAt_finCons'.mpr ⟨h, hs⟩
theorem hasFDerivAtFilter_finCons
{φ' : E →L[𝕜] Π i, F' i} {l : Filter E} :
HasFDerivAtFilter (fun x => Fin.cons (φ x) (φs x)) φ' x l ↔
HasFDerivAtFilter φ (.proj 0 ∘L φ') x l ∧
HasFDerivAtFilter φs (Pi.compRightL 𝕜 F' Fin.succ ∘L φ') x l := by
rw [hasFDerivAtFilter_pi', Fin.forall_fin_succ, hasFDerivAtFilter_pi']
dsimp [ContinuousLinearMap.comp, LinearMap.comp, Function.comp_def]
simp only [Fin.cons_zero, Fin.cons_succ]
/-- A variant of `hasFDerivAtFilter_finCons` where the derivative variables are free on the RHS
instead. -/
theorem hasFDerivAtFilter_finCons'
{φ' : E →L[𝕜] F' 0} {φs' : E →L[𝕜] Π i, F' (Fin.succ i)} {l : Filter E} :
HasFDerivAtFilter (fun x => Fin.cons (φ x) (φs x)) (φ'.finCons φs') x l ↔
HasFDerivAtFilter φ φ' x l ∧ HasFDerivAtFilter φs φs' x l :=
hasFDerivAtFilter_finCons
theorem HasFDerivAtFilter.finCons
{φ' : E →L[𝕜] F' 0} {φs' : E →L[𝕜] Π i, F' (Fin.succ i)} {l : Filter E}
(h : HasFDerivAtFilter φ φ' x l) (hs : HasFDerivAtFilter φs φs' x l) :
HasFDerivAtFilter (fun x => Fin.cons (φ x) (φs x)) (φ'.finCons φs') x l :=
hasFDerivAtFilter_finCons'.mpr ⟨h, hs⟩
theorem hasFDerivAt_finCons
{φ' : E →L[𝕜] Π i, F' i} :
HasFDerivAt (fun x => Fin.cons (φ x) (φs x)) φ' x ↔
HasFDerivAt φ (.proj 0 ∘L φ') x ∧ HasFDerivAt φs (Pi.compRightL 𝕜 F' Fin.succ ∘L φ') x :=
hasFDerivAtFilter_finCons
/-- A variant of `hasFDerivAt_finCons` where the derivative variables are free on the RHS
instead. -/
theorem hasFDerivAt_finCons'
{φ' : E →L[𝕜] F' 0} {φs' : E →L[𝕜] Π i, F' (Fin.succ i)} :
HasFDerivAt (fun x => Fin.cons (φ x) (φs x)) (φ'.finCons φs') x ↔
HasFDerivAt φ φ' x ∧ HasFDerivAt φs φs' x :=
hasFDerivAt_finCons
@[fun_prop]
theorem HasFDerivAt.finCons
{φ' : E →L[𝕜] F' 0} {φs' : E →L[𝕜] Π i, F' (Fin.succ i)}
(h : HasFDerivAt φ φ' x) (hs : HasFDerivAt φs φs' x) :
HasFDerivAt (fun x => Fin.cons (φ x) (φs x)) (φ'.finCons φs') x :=
hasFDerivAt_finCons'.mpr ⟨h, hs⟩
theorem hasFDerivWithinAt_finCons
{φ' : E →L[𝕜] Π i, F' i} :
HasFDerivWithinAt (fun x => Fin.cons (φ x) (φs x)) φ' s x ↔
HasFDerivWithinAt φ (.proj 0 ∘L φ') s x ∧
HasFDerivWithinAt φs (Pi.compRightL 𝕜 F' Fin.succ ∘L φ') s x :=
hasFDerivAtFilter_finCons
/-- A variant of `hasFDerivWithinAt_finCons` where the derivative variables are free on the RHS
instead. -/
theorem hasFDerivWithinAt_finCons'
{φ' : E →L[𝕜] F' 0} {φs' : E →L[𝕜] Π i, F' (Fin.succ i)} :
HasFDerivWithinAt (fun x => Fin.cons (φ x) (φs x)) (φ'.finCons φs') s x ↔
HasFDerivWithinAt φ φ' s x ∧ HasFDerivWithinAt φs φs' s x :=
hasFDerivAtFilter_finCons
@[fun_prop]
theorem HasFDerivWithinAt.finCons
{φ' : E →L[𝕜] F' 0} {φs' : E →L[𝕜] Π i, F' (Fin.succ i)}
(h : HasFDerivWithinAt φ φ' s x) (hs : HasFDerivWithinAt φs φs' s x) :
HasFDerivWithinAt (fun x => Fin.cons (φ x) (φs x)) (φ'.finCons φs') s x :=
hasFDerivWithinAt_finCons'.mpr ⟨h, hs⟩
theorem differentiableWithinAt_finCons :
DifferentiableWithinAt 𝕜 (fun x => Fin.cons (φ x) (φs x)) s x ↔
DifferentiableWithinAt 𝕜 φ s x ∧ DifferentiableWithinAt 𝕜 φs s x := by
rw [differentiableWithinAt_pi, Fin.forall_fin_succ, differentiableWithinAt_pi]
simp only [Fin.cons_zero, Fin.cons_succ]
/-- A variant of `differentiableWithinAt_finCons` where the derivative variables are free on the RHS
instead. -/
theorem differentiableWithinAt_finCons' :
DifferentiableWithinAt 𝕜 (fun x => Fin.cons (φ x) (φs x)) s x ↔
DifferentiableWithinAt 𝕜 φ s x ∧ DifferentiableWithinAt 𝕜 φs s x :=
differentiableWithinAt_finCons
@[fun_prop]
theorem DifferentiableWithinAt.finCons
(h : DifferentiableWithinAt 𝕜 φ s x) (hs : DifferentiableWithinAt 𝕜 φs s x) :
DifferentiableWithinAt 𝕜 (fun x => Fin.cons (φ x) (φs x)) s x :=
differentiableWithinAt_finCons'.mpr ⟨h, hs⟩
theorem differentiableAt_finCons :
DifferentiableAt 𝕜 (fun x => Fin.cons (φ x) (φs x)) x ↔
DifferentiableAt 𝕜 φ x ∧ DifferentiableAt 𝕜 φs x := by
rw [differentiableAt_pi, Fin.forall_fin_succ, differentiableAt_pi]
simp only [Fin.cons_zero, Fin.cons_succ]
/-- A variant of `differentiableAt_finCons` where the derivative variables are free on the RHS
instead. -/
theorem differentiableAt_finCons' :
DifferentiableAt 𝕜 (fun x => Fin.cons (φ x) (φs x)) x ↔
DifferentiableAt 𝕜 φ x ∧ DifferentiableAt 𝕜 φs x :=
differentiableAt_finCons
@[fun_prop]
theorem DifferentiableAt.finCons
(h : DifferentiableAt 𝕜 φ x) (hs : DifferentiableAt 𝕜 φs x) :
DifferentiableAt 𝕜 (fun x => Fin.cons (φ x) (φs x)) x :=
differentiableAt_finCons'.mpr ⟨h, hs⟩
theorem differentiableOn_finCons :
DifferentiableOn 𝕜 (fun x => Fin.cons (φ x) (φs x)) s ↔
DifferentiableOn 𝕜 φ s ∧ DifferentiableOn 𝕜 φs s := by
rw [differentiableOn_pi, Fin.forall_fin_succ, differentiableOn_pi]
simp only [Fin.cons_zero, Fin.cons_succ]
/-- A variant of `differentiableOn_finCons` where the derivative variables are free on the RHS
instead. -/
theorem differentiableOn_finCons' :
DifferentiableOn 𝕜 (fun x => Fin.cons (φ x) (φs x)) s ↔
DifferentiableOn 𝕜 φ s ∧ DifferentiableOn 𝕜 φs s :=
differentiableOn_finCons
@[fun_prop]
theorem DifferentiableOn.finCons
(h : DifferentiableOn 𝕜 φ s) (hs : DifferentiableOn 𝕜 φs s) :
DifferentiableOn 𝕜 (fun x => Fin.cons (φ x) (φs x)) s :=
differentiableOn_finCons'.mpr ⟨h, hs⟩
theorem differentiable_finCons :
Differentiable 𝕜 (fun x => Fin.cons (φ x) (φs x)) ↔
Differentiable 𝕜 φ ∧ Differentiable 𝕜 φs := by
rw [differentiable_pi, Fin.forall_fin_succ, differentiable_pi]
simp only [Fin.cons_zero, Fin.cons_succ]
/-- A variant of `differentiable_finCons` where the derivative variables are free on the RHS
instead. -/
theorem differentiable_finCons' :
Differentiable 𝕜 (fun x => Fin.cons (φ x) (φs x)) ↔
Differentiable 𝕜 φ ∧ Differentiable 𝕜 φs :=
differentiable_finCons
@[fun_prop]
theorem Differentiable.finCons
(h : Differentiable 𝕜 φ) (hs : Differentiable 𝕜 φs) :
Differentiable 𝕜 (fun x => Fin.cons (φ x) (φs x)) :=
differentiable_finCons'.mpr ⟨h, hs⟩
-- TODO: write the `Fin.cons` versions of `fderivWithin_pi` and `fderiv_pi`
end PiFin
end CartesianProduct
end |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/FDeriv/Linear.lean | import Mathlib.Analysis.Calculus.FDeriv.Basic
import Mathlib.Analysis.Normed.Operator.BoundedLinearMaps
/-!
# The derivative of bounded linear maps
For detailed documentation of the Fréchet derivative,
see the module docstring of `Analysis/Calculus/FDeriv/Basic.lean`.
This file contains the usual formulas (and existence assertions) for the derivative of
bounded linear maps.
-/
open Asymptotics
section
variable {𝕜 : Type*} [NontriviallyNormedField 𝕜]
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E]
variable {F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F]
variable {f : E → F}
variable (e : E →L[𝕜] F)
variable {x : E}
variable {s : Set E}
variable {L : Filter E}
section ContinuousLinearMap
/-!
### Continuous linear maps
There are currently two variants of these in mathlib, the bundled version
(named `ContinuousLinearMap`, and denoted `E →L[𝕜] F`), and the unbundled version (with a
predicate `IsBoundedLinearMap`). We give statements for both versions. -/
@[fun_prop]
protected theorem ContinuousLinearMap.hasStrictFDerivAt {x : E} : HasStrictFDerivAt e e x :=
.of_isLittleOTVS <| (IsLittleOTVS.zero _ _).congr_left fun x => by
simp only [e.map_sub, sub_self, Pi.zero_apply]
protected theorem ContinuousLinearMap.hasFDerivAtFilter : HasFDerivAtFilter e e x L :=
.of_isLittleOTVS <| (IsLittleOTVS.zero _ _).congr_left fun x => by
simp only [e.map_sub, sub_self, Pi.zero_apply]
@[fun_prop]
protected theorem ContinuousLinearMap.hasFDerivWithinAt : HasFDerivWithinAt e e s x :=
e.hasFDerivAtFilter
@[fun_prop]
protected theorem ContinuousLinearMap.hasFDerivAt : HasFDerivAt e e x :=
e.hasFDerivAtFilter
@[simp, fun_prop]
protected theorem ContinuousLinearMap.differentiableAt : DifferentiableAt 𝕜 e x :=
e.hasFDerivAt.differentiableAt
@[fun_prop]
protected theorem ContinuousLinearMap.differentiableWithinAt : DifferentiableWithinAt 𝕜 e s x :=
e.differentiableAt.differentiableWithinAt
@[simp]
protected theorem ContinuousLinearMap.fderiv : fderiv 𝕜 e x = e :=
e.hasFDerivAt.fderiv
protected theorem ContinuousLinearMap.fderivWithin (hxs : UniqueDiffWithinAt 𝕜 s x) :
fderivWithin 𝕜 e s x = e := by
rw [DifferentiableAt.fderivWithin e.differentiableAt hxs]
exact e.fderiv
@[simp, fun_prop]
protected theorem ContinuousLinearMap.differentiable : Differentiable 𝕜 e := fun _ =>
e.differentiableAt
@[fun_prop]
protected theorem ContinuousLinearMap.differentiableOn : DifferentiableOn 𝕜 e s :=
e.differentiable.differentiableOn
theorem IsBoundedLinearMap.hasFDerivAtFilter (h : IsBoundedLinearMap 𝕜 f) :
HasFDerivAtFilter f h.toContinuousLinearMap x L :=
h.toContinuousLinearMap.hasFDerivAtFilter
@[fun_prop]
theorem IsBoundedLinearMap.hasFDerivWithinAt (h : IsBoundedLinearMap 𝕜 f) :
HasFDerivWithinAt f h.toContinuousLinearMap s x :=
h.hasFDerivAtFilter
@[fun_prop]
theorem IsBoundedLinearMap.hasFDerivAt (h : IsBoundedLinearMap 𝕜 f) :
HasFDerivAt f h.toContinuousLinearMap x :=
h.hasFDerivAtFilter
@[fun_prop]
theorem IsBoundedLinearMap.differentiableAt (h : IsBoundedLinearMap 𝕜 f) : DifferentiableAt 𝕜 f x :=
h.hasFDerivAt.differentiableAt
@[fun_prop]
theorem IsBoundedLinearMap.differentiableWithinAt (h : IsBoundedLinearMap 𝕜 f) :
DifferentiableWithinAt 𝕜 f s x :=
h.differentiableAt.differentiableWithinAt
theorem IsBoundedLinearMap.fderiv (h : IsBoundedLinearMap 𝕜 f) :
fderiv 𝕜 f x = h.toContinuousLinearMap :=
HasFDerivAt.fderiv h.hasFDerivAt
theorem IsBoundedLinearMap.fderivWithin (h : IsBoundedLinearMap 𝕜 f)
(hxs : UniqueDiffWithinAt 𝕜 s x) : fderivWithin 𝕜 f s x = h.toContinuousLinearMap := by
rw [DifferentiableAt.fderivWithin h.differentiableAt hxs]
exact h.fderiv
@[fun_prop]
theorem IsBoundedLinearMap.differentiable (h : IsBoundedLinearMap 𝕜 f) : Differentiable 𝕜 f :=
fun _ => h.differentiableAt
@[fun_prop]
theorem IsBoundedLinearMap.differentiableOn (h : IsBoundedLinearMap 𝕜 f) : DifferentiableOn 𝕜 f s :=
h.differentiable.differentiableOn
end ContinuousLinearMap
end |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/FDeriv/ContinuousMultilinearMap.lean | import Mathlib.Analysis.Calculus.FDeriv.Analytic
import Mathlib.Analysis.Calculus.FDeriv.CompCLM
/-!
# Derivatives of operations on continuous multilinear maps
In this file,
- `ι` is an index type (`Fin n` in many applications);
- `E`, `F i`, `G i`, `H`, are normed spaces for each `i : ι`;
- `f x` is a continuous multilinear map from `Π i, G i` to `H`, depending on a parameter `x : E`;
- for each `i : ι`, `g i x` is a continuous linear map `F i → G i`,
depending on a parameter `x : E`.
Given this data, for each `x` we can define a continuous multilinear map from `Π i, F i` to `H`
given by `(f x).compContinuousLinearMap (fun i ↦ g i x) v = f x (fun i ↦ g i x (v i))`.
As a map between functional spaces,
`ContinuousMultilinearMap.compContinuousLinearMap` is multilinear in `(f; g i)`.
Thus its derivative with respect to each map (`f` or `g i`)
is given by substituting `f'` or `g' i` instead of `f` or `g i`
in `(f x).compContinuousLinearMap (fun i ↦ g i x)`,
and the full differential is given by the sum of these terms.
In terms of bundled maps, the derivative with respect to `f`
is given by `ContinuousMultilinearMap.compContinuousLinearMapL`
and the sum of terms that represent the derivatives with respect to `g i`
is given by `ContinuousMultilinearMap.fderivCompContinuousLinearMap`.
All statements in the first section are claiming this, for various notions of differentiation.
The second section deduces the corresponding differentiability results when `ι` is finite.
-/
variable {𝕜 ι E : Type*} {F G : ι → Type*} {H : Type*}
[NontriviallyNormedField 𝕜]
[NormedAddCommGroup E] [NormedSpace 𝕜 E]
[∀ i, NormedAddCommGroup (F i)] [∀ i, NormedSpace 𝕜 (F i)]
[∀ i, NormedAddCommGroup (G i)] [∀ i, NormedSpace 𝕜 (G i)]
[NormedAddCommGroup H] [NormedSpace 𝕜 H]
{f : E → ContinuousMultilinearMap 𝕜 G H} {f' : E →L[𝕜] ContinuousMultilinearMap 𝕜 G H}
{g : ∀ i, E → F i →L[𝕜] G i} {g' : ∀ i, E →L[𝕜] F i →L[𝕜] G i}
{s : Set E} {x : E}
open ContinuousMultilinearMap
section HasFDerivAt
variable [Fintype ι] [DecidableEq ι]
theorem ContinuousMultilinearMap.hasStrictFDerivAt_compContinuousLinearMap
(fg : ContinuousMultilinearMap 𝕜 G H × ∀ i, F i →L[𝕜] G i) :
HasStrictFDerivAt
(fun fg : ContinuousMultilinearMap 𝕜 G H × ∀ i, F i →L[𝕜] G i ↦
fg.1.compContinuousLinearMap fg.2)
(compContinuousLinearMapL fg.2 ∘L .fst _ _ _ +
fg.1.fderivCompContinuousLinearMap fg.2 ∘L .snd _ _ _)
fg := by
have := (compContinuousLinearMapContinuousMultilinear 𝕜 F G H).hasStrictFDerivAt fg.2
convert this.comp fg hasStrictFDerivAt_snd |>.clm_apply hasStrictFDerivAt_fst
ext <;> simp [fderivCompContinuousLinearMap]
theorem HasStrictFDerivAt.continuousMultilinearMapCompContinuousLinearMap
(hf : HasStrictFDerivAt f f' x) (hg : ∀ i, HasStrictFDerivAt (g i) (g' i) x) :
HasStrictFDerivAt (fun x ↦ (f x).compContinuousLinearMap (g · x))
(compContinuousLinearMapL (g · x) ∘L f' +
(f x).fderivCompContinuousLinearMap (g · x) ∘L .pi g') x :=
hasStrictFDerivAt_compContinuousLinearMap (f x, (g · x))
|>.comp x (hf.prodMk (hasStrictFDerivAt_pi.2 hg))
theorem HasFDerivAt.continuousMultilinearMapCompContinuousLinearMap
(hf : HasFDerivAt f f' x) (hg : ∀ i, HasFDerivAt (g i) (g' i) x) :
HasFDerivAt (fun x ↦ (f x).compContinuousLinearMap (g · x))
(compContinuousLinearMapL (g · x) ∘L f' +
(f x).fderivCompContinuousLinearMap (g · x) ∘L .pi g') x := by
convert hasStrictFDerivAt_compContinuousLinearMap (f x, (g · x)) |>.hasFDerivAt
|>.comp x (hf.prodMk (hasFDerivAt_pi.2 hg))
theorem HasFDerivWithinAt.continuousMultilinearMapCompContinuousLinearMap
(hf : HasFDerivWithinAt f f' s x) (hg : ∀ i, HasFDerivWithinAt (g i) (g' i) s x) :
HasFDerivWithinAt (fun x ↦ (f x).compContinuousLinearMap (g · x))
(compContinuousLinearMapL (g · x) ∘L f' +
(f x).fderivCompContinuousLinearMap (g · x) ∘L .pi g') s x := by
convert hasStrictFDerivAt_compContinuousLinearMap (f x, (g · x)) |>.hasFDerivAt
|>.comp_hasFDerivWithinAt x (hf.prodMk (hasFDerivWithinAt_pi.2 hg))
theorem fderivWithin_continuousMultilinearMapCompContinuousLinearMap
(hf : DifferentiableWithinAt 𝕜 f s x) (hg : ∀ i, DifferentiableWithinAt 𝕜 (g i) s x)
(hs : UniqueDiffWithinAt 𝕜 s x) :
fderivWithin 𝕜 (fun x ↦ (f x).compContinuousLinearMap (g · x)) s x =
compContinuousLinearMapL (g · x) ∘L fderivWithin 𝕜 f s x +
(f x).fderivCompContinuousLinearMap (g · x) ∘L .pi fun i ↦ fderivWithin 𝕜 (g i) s x :=
hf.hasFDerivWithinAt.continuousMultilinearMapCompContinuousLinearMap
(fun i ↦ (hg i).hasFDerivWithinAt) |>.fderivWithin hs
theorem fderiv_continuousMultilinearMapCompContinuousLinearMap
(hf : DifferentiableAt 𝕜 f x) (hg : ∀ i, DifferentiableAt 𝕜 (g i) x) :
fderiv 𝕜 (fun x ↦ (f x).compContinuousLinearMap (g · x)) x =
compContinuousLinearMapL (g · x) ∘L fderiv 𝕜 f x +
(f x).fderivCompContinuousLinearMap (g · x) ∘L .pi fun i ↦ fderiv 𝕜 (g i) x :=
hf.hasFDerivAt.continuousMultilinearMapCompContinuousLinearMap
(fun i ↦ (hg i).hasFDerivAt) |>.fderiv
end HasFDerivAt
variable [Finite ι]
theorem DifferentiableWithinAt.continuousMultilinearMapCompContinuousLinearMap
(hf : DifferentiableWithinAt 𝕜 f s x) (hg : ∀ i, DifferentiableWithinAt 𝕜 (g i) s x) :
DifferentiableWithinAt 𝕜 (fun x ↦ (f x).compContinuousLinearMap (g · x)) s x := by
cases nonempty_fintype ι
classical
exact hf.hasFDerivWithinAt.continuousMultilinearMapCompContinuousLinearMap
(fun i ↦ (hg i).hasFDerivWithinAt) |>.differentiableWithinAt
theorem DifferentiableAt.continuousMultilinearMapCompContinuousLinearMap
(hf : DifferentiableAt 𝕜 f x) (hg : ∀ i, DifferentiableAt 𝕜 (g i) x) :
DifferentiableAt 𝕜 (fun x ↦ (f x).compContinuousLinearMap (g · x)) x := by
cases nonempty_fintype ι
classical
exact hf.hasFDerivAt.continuousMultilinearMapCompContinuousLinearMap
(fun i ↦ (hg i).hasFDerivAt) |>.differentiableAt
theorem DifferentiableOn.continuousMultilinearMapCompContinuousLinearMap
(hf : DifferentiableOn 𝕜 f s) (hg : ∀ i, DifferentiableOn 𝕜 (g i) s) :
DifferentiableOn 𝕜 (fun x ↦ (f x).compContinuousLinearMap (g · x)) s := fun x hx ↦
(hf x hx).continuousMultilinearMapCompContinuousLinearMap (hg · x hx)
theorem Differentiable.continuousMultilinearMapCompContinuousLinearMap
(hf : Differentiable 𝕜 f) (hg : ∀ i, Differentiable 𝕜 (g i)) :
Differentiable 𝕜 (fun x ↦ (f x).compContinuousLinearMap (g · x)) := fun x ↦
(hf x).continuousMultilinearMapCompContinuousLinearMap (hg · x) |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/FDeriv/Pi.lean | import Mathlib.Analysis.Calculus.FDeriv.Add
import Mathlib.Analysis.Calculus.FDeriv.Const
/-!
# Derivatives on pi-types.
-/
variable {𝕜 ι : Type*} [DecidableEq ι] [Fintype ι] [NontriviallyNormedField 𝕜]
variable {E : ι → Type*} [∀ i, NormedAddCommGroup (E i)] [∀ i, NormedSpace 𝕜 (E i)]
@[fun_prop]
theorem hasFDerivAt_update (x : ∀ i, E i) {i : ι} (y : E i) :
HasFDerivAt (Function.update x i) (.pi (Pi.single i (.id 𝕜 (E i)))) y := by
set l := (ContinuousLinearMap.pi (Pi.single i (.id 𝕜 (E i))))
have update_eq : Function.update x i = (fun _ ↦ x) + l ∘ (· - x i) := by
ext t j
dsimp [l, Pi.single, Function.update]
split_ifs with hji
· subst hji
simp
· simp
rw [update_eq]
convert (hasFDerivAt_const _ _).add (l.hasFDerivAt.comp y (hasFDerivAt_sub_const (x i)))
rw [zero_add, ContinuousLinearMap.comp_id]
@[fun_prop]
theorem hasFDerivAt_single {i : ι} (y : E i) :
HasFDerivAt (Pi.single i) (.pi (Pi.single i (.id 𝕜 (E i)))) y :=
hasFDerivAt_update 0 y
theorem fderiv_update (x : ∀ i, E i) {i : ι} (y : E i) :
fderiv 𝕜 (Function.update x i) y = .pi (Pi.single i (.id 𝕜 (E i))) :=
(hasFDerivAt_update x y).fderiv
theorem fderiv_single {i : ι} (y : E i) :
fderiv 𝕜 (Pi.single i) y = .pi (Pi.single i (.id 𝕜 (E i))) :=
fderiv_update 0 y |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/FDeriv/Mul.lean | import Mathlib.Analysis.Analytic.Constructions
import Mathlib.Analysis.Calculus.FDeriv.Analytic
import Mathlib.Analysis.Calculus.FDeriv.Bilinear
/-!
# Multiplicative operations on derivatives
For detailed documentation of the Fréchet derivative,
see the module docstring of `Mathlib/Analysis/Calculus/FDeriv/Basic.lean`.
This file contains the usual formulas (and existence assertions) for the derivative of
* multiplication of a function by a scalar function
* product of finitely many scalar functions
* taking the pointwise multiplicative inverse (i.e. `Inv.inv` or `Ring.inverse`) of a function
-/
open Asymptotics ContinuousLinearMap Topology
section
variable {𝕜 : Type*} [NontriviallyNormedField 𝕜]
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E]
variable {F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F]
variable {G : Type*} [NormedAddCommGroup G] [NormedSpace 𝕜 G]
variable {f : E → F}
variable {f' : E →L[𝕜] F}
variable {x : E}
variable {s : Set E}
section SMul
/-! ### Derivative of the product of a scalar-valued function and a vector-valued function
If `c` is a differentiable scalar-valued function and `f` is a differentiable vector-valued
function, then `fun x ↦ c x • f x` is differentiable as well. Lemmas in this section works for
function `c` taking values in the base field, as well as in a normed algebra over the base
field: e.g., they work for `c : E → ℂ` and `f : E → F` provided that `F` is a complex
normed vector space.
-/
variable {𝕜' : Type*} [NontriviallyNormedField 𝕜'] [NormedAlgebra 𝕜 𝕜'] [NormedSpace 𝕜' F]
[IsScalarTower 𝕜 𝕜' F]
variable {c : E → 𝕜'} {c' : E →L[𝕜] 𝕜'}
@[fun_prop]
theorem HasStrictFDerivAt.fun_smul (hc : HasStrictFDerivAt c c' x) (hf : HasStrictFDerivAt f f' x) :
HasStrictFDerivAt (fun y => c y • f y) (c x • f' + c'.smulRight (f x)) x :=
(isBoundedBilinearMap_smul.hasStrictFDerivAt (c x, f x)).comp x <| hc.prodMk hf
@[fun_prop]
theorem HasStrictFDerivAt.smul (hc : HasStrictFDerivAt c c' x) (hf : HasStrictFDerivAt f f' x) :
HasStrictFDerivAt (c • f) (c x • f' + c'.smulRight (f x)) x :=
(isBoundedBilinearMap_smul.hasStrictFDerivAt (c x, f x)).comp x <| hc.prodMk hf
@[fun_prop]
theorem HasFDerivWithinAt.fun_smul
(hc : HasFDerivWithinAt c c' s x) (hf : HasFDerivWithinAt f f' s x) :
HasFDerivWithinAt (fun y => c y • f y) (c x • f' + c'.smulRight (f x)) s x := by
-- `by exact` to solve unification issues.
exact (isBoundedBilinearMap_smul.hasFDerivAt (𝕜 := 𝕜) (c x, f x)).comp_hasFDerivWithinAt x <|
hc.prodMk hf
@[fun_prop]
theorem HasFDerivWithinAt.smul (hc : HasFDerivWithinAt c c' s x) (hf : HasFDerivWithinAt f f' s x) :
HasFDerivWithinAt (c • f) (c x • f' + c'.smulRight (f x)) s x :=
hc.fun_smul hf
@[fun_prop]
theorem HasFDerivAt.fun_smul (hc : HasFDerivAt c c' x) (hf : HasFDerivAt f f' x) :
HasFDerivAt (fun y => c y • f y) (c x • f' + c'.smulRight (f x)) x := by
-- `by exact` to solve unification issues.
exact (isBoundedBilinearMap_smul.hasFDerivAt (𝕜 := 𝕜) (c x, f x)).comp x <| hc.prodMk hf
@[fun_prop]
theorem HasFDerivAt.smul (hc : HasFDerivAt c c' x) (hf : HasFDerivAt f f' x) :
HasFDerivAt (c • f) (c x • f' + c'.smulRight (f x)) x :=
hc.fun_smul hf
@[fun_prop]
theorem DifferentiableWithinAt.fun_smul (hc : DifferentiableWithinAt 𝕜 c s x)
(hf : DifferentiableWithinAt 𝕜 f s x) : DifferentiableWithinAt 𝕜 (fun y => c y • f y) s x :=
(hc.hasFDerivWithinAt.smul hf.hasFDerivWithinAt).differentiableWithinAt
@[fun_prop]
theorem DifferentiableWithinAt.smul (hc : DifferentiableWithinAt 𝕜 c s x)
(hf : DifferentiableWithinAt 𝕜 f s x) : DifferentiableWithinAt 𝕜 (c • f) s x :=
(hc.hasFDerivWithinAt.smul hf.hasFDerivWithinAt).differentiableWithinAt
@[simp, fun_prop]
theorem DifferentiableAt.fun_smul (hc : DifferentiableAt 𝕜 c x) (hf : DifferentiableAt 𝕜 f x) :
DifferentiableAt 𝕜 (fun y => c y • f y) x :=
(hc.hasFDerivAt.smul hf.hasFDerivAt).differentiableAt
@[simp, fun_prop]
theorem DifferentiableAt.smul (hc : DifferentiableAt 𝕜 c x) (hf : DifferentiableAt 𝕜 f x) :
DifferentiableAt 𝕜 (c • f) x :=
(hc.hasFDerivAt.smul hf.hasFDerivAt).differentiableAt
@[fun_prop]
theorem DifferentiableOn.fun_smul (hc : DifferentiableOn 𝕜 c s) (hf : DifferentiableOn 𝕜 f s) :
DifferentiableOn 𝕜 (fun y => c y • f y) s := fun x hx => (hc x hx).smul (hf x hx)
@[fun_prop]
theorem DifferentiableOn.smul (hc : DifferentiableOn 𝕜 c s) (hf : DifferentiableOn 𝕜 f s) :
DifferentiableOn 𝕜 (c • f) s := fun x hx => (hc x hx).smul (hf x hx)
@[simp, fun_prop]
theorem Differentiable.fun_smul (hc : Differentiable 𝕜 c) (hf : Differentiable 𝕜 f) :
Differentiable 𝕜 fun y => c y • f y := fun x => (hc x).smul (hf x)
@[simp, fun_prop]
theorem Differentiable.smul (hc : Differentiable 𝕜 c) (hf : Differentiable 𝕜 f) :
Differentiable 𝕜 (c • f) := fun x => (hc x).smul (hf x)
theorem fderivWithin_fun_smul (hxs : UniqueDiffWithinAt 𝕜 s x) (hc : DifferentiableWithinAt 𝕜 c s x)
(hf : DifferentiableWithinAt 𝕜 f s x) :
fderivWithin 𝕜 (fun y => c y • f y) s x =
c x • fderivWithin 𝕜 f s x + (fderivWithin 𝕜 c s x).smulRight (f x) :=
(hc.hasFDerivWithinAt.smul hf.hasFDerivWithinAt).fderivWithin hxs
theorem fderivWithin_smul (hxs : UniqueDiffWithinAt 𝕜 s x) (hc : DifferentiableWithinAt 𝕜 c s x)
(hf : DifferentiableWithinAt 𝕜 f s x) :
fderivWithin 𝕜 (c • f) s x =
c x • fderivWithin 𝕜 f s x + (fderivWithin 𝕜 c s x).smulRight (f x) :=
(hc.hasFDerivWithinAt.smul hf.hasFDerivWithinAt).fderivWithin hxs
theorem fderiv_fun_smul (hc : DifferentiableAt 𝕜 c x) (hf : DifferentiableAt 𝕜 f x) :
fderiv 𝕜 (fun y => c y • f y) x = c x • fderiv 𝕜 f x + (fderiv 𝕜 c x).smulRight (f x) :=
(hc.hasFDerivAt.smul hf.hasFDerivAt).fderiv
theorem fderiv_smul (hc : DifferentiableAt 𝕜 c x) (hf : DifferentiableAt 𝕜 f x) :
fderiv 𝕜 (c • f) x = c x • fderiv 𝕜 f x + (fderiv 𝕜 c x).smulRight (f x) :=
(hc.hasFDerivAt.smul hf.hasFDerivAt).fderiv
@[fun_prop]
theorem HasStrictFDerivAt.smul_const (hc : HasStrictFDerivAt c c' x) (f : F) :
HasStrictFDerivAt (fun y => c y • f) (c'.smulRight f) x := by
simpa only [smul_zero, zero_add] using hc.smul (hasStrictFDerivAt_const f x)
@[fun_prop]
theorem HasFDerivWithinAt.smul_const (hc : HasFDerivWithinAt c c' s x) (f : F) :
HasFDerivWithinAt (fun y => c y • f) (c'.smulRight f) s x := by
simpa only [smul_zero, zero_add] using hc.smul (hasFDerivWithinAt_const f x s)
@[fun_prop]
theorem HasFDerivAt.smul_const (hc : HasFDerivAt c c' x) (f : F) :
HasFDerivAt (fun y => c y • f) (c'.smulRight f) x := by
simpa only [smul_zero, zero_add] using hc.smul (hasFDerivAt_const f x)
@[fun_prop]
theorem DifferentiableWithinAt.smul_const (hc : DifferentiableWithinAt 𝕜 c s x) (f : F) :
DifferentiableWithinAt 𝕜 (fun y => c y • f) s x :=
(hc.hasFDerivWithinAt.smul_const f).differentiableWithinAt
@[fun_prop]
theorem DifferentiableAt.smul_const (hc : DifferentiableAt 𝕜 c x) (f : F) :
DifferentiableAt 𝕜 (fun y => c y • f) x :=
(hc.hasFDerivAt.smul_const f).differentiableAt
@[fun_prop]
theorem DifferentiableOn.smul_const (hc : DifferentiableOn 𝕜 c s) (f : F) :
DifferentiableOn 𝕜 (fun y => c y • f) s := fun x hx => (hc x hx).smul_const f
@[fun_prop]
theorem Differentiable.smul_const (hc : Differentiable 𝕜 c) (f : F) :
Differentiable 𝕜 fun y => c y • f := fun x => (hc x).smul_const f
theorem fderivWithin_smul_const (hxs : UniqueDiffWithinAt 𝕜 s x)
(hc : DifferentiableWithinAt 𝕜 c s x) (f : F) :
fderivWithin 𝕜 (fun y => c y • f) s x = (fderivWithin 𝕜 c s x).smulRight f :=
(hc.hasFDerivWithinAt.smul_const f).fderivWithin hxs
theorem fderiv_smul_const (hc : DifferentiableAt 𝕜 c x) (f : F) :
fderiv 𝕜 (fun y => c y • f) x = (fderiv 𝕜 c x).smulRight f :=
(hc.hasFDerivAt.smul_const f).fderiv
end SMul
section Mul
/-! ### Derivative of the product of two functions -/
open scoped RightActions
variable {𝔸 𝔸' : Type*} [NormedRing 𝔸] [NormedCommRing 𝔸'] [NormedAlgebra 𝕜 𝔸] [NormedAlgebra 𝕜 𝔸']
{a b : E → 𝔸} {a' b' : E →L[𝕜] 𝔸} {c d : E → 𝔸'} {c' d' : E →L[𝕜] 𝔸'}
@[fun_prop]
theorem HasStrictFDerivAt.fun_mul' {x : E} (ha : HasStrictFDerivAt a a' x)
(hb : HasStrictFDerivAt b b' x) :
HasStrictFDerivAt (fun y => a y * b y) (a x • b' + a' <• b x) x :=
((ContinuousLinearMap.mul 𝕜 𝔸).isBoundedBilinearMap.hasStrictFDerivAt (a x, b x)).comp x
(ha.prodMk hb)
@[fun_prop]
theorem HasStrictFDerivAt.mul' {x : E} (ha : HasStrictFDerivAt a a' x)
(hb : HasStrictFDerivAt b b' x) :
HasStrictFDerivAt (a * b) (a x • b' + a' <• b x) x :=
((ContinuousLinearMap.mul 𝕜 𝔸).isBoundedBilinearMap.hasStrictFDerivAt (a x, b x)).comp x
(ha.prodMk hb)
@[fun_prop]
theorem HasStrictFDerivAt.fun_mul (hc : HasStrictFDerivAt c c' x) (hd : HasStrictFDerivAt d d' x) :
HasStrictFDerivAt (fun y => c y * d y) (c x • d' + d x • c') x := by
convert hc.mul' hd
ext z
apply mul_comm
@[fun_prop]
theorem HasStrictFDerivAt.mul (hc : HasStrictFDerivAt c c' x) (hd : HasStrictFDerivAt d d' x) :
HasStrictFDerivAt (c * d) (c x • d' + d x • c') x := by
convert hc.mul' hd
ext z
apply mul_comm
@[fun_prop]
theorem HasFDerivWithinAt.fun_mul'
(ha : HasFDerivWithinAt a a' s x) (hb : HasFDerivWithinAt b b' s x) :
HasFDerivWithinAt (fun y => a y * b y) (a x • b' + a' <• b x) s x := by
-- `by exact` to solve unification issues.
exact ((ContinuousLinearMap.mul 𝕜 𝔸).isBoundedBilinearMap.hasFDerivAt
(a x, b x)).comp_hasFDerivWithinAt x (ha.prodMk hb)
@[fun_prop]
theorem HasFDerivWithinAt.mul' (ha : HasFDerivWithinAt a a' s x) (hb : HasFDerivWithinAt b b' s x) :
HasFDerivWithinAt (a * b) (a x • b' + a' <• b x) s x :=
ha.fun_mul' hb
@[fun_prop]
theorem HasFDerivWithinAt.fun_mul
(hc : HasFDerivWithinAt c c' s x) (hd : HasFDerivWithinAt d d' s x) :
HasFDerivWithinAt (fun y => c y * d y) (c x • d' + d x • c') s x := by
convert hc.mul' hd
ext z
apply mul_comm
@[fun_prop]
theorem HasFDerivWithinAt.mul (hc : HasFDerivWithinAt c c' s x) (hd : HasFDerivWithinAt d d' s x) :
HasFDerivWithinAt (c * d) (c x • d' + d x • c') s x :=
hc.fun_mul hd
@[fun_prop]
theorem HasFDerivAt.fun_mul' (ha : HasFDerivAt a a' x) (hb : HasFDerivAt b b' x) :
HasFDerivAt (fun y => a y * b y) (a x • b' + a' <• b x) x := by
-- `by exact` to solve unification issues.
exact ((ContinuousLinearMap.mul 𝕜 𝔸).isBoundedBilinearMap.hasFDerivAt
(a x, b x)).comp x (ha.prodMk hb)
@[fun_prop]
theorem HasFDerivAt.mul' (ha : HasFDerivAt a a' x) (hb : HasFDerivAt b b' x) :
HasFDerivAt (a * b) (a x • b' + a' <• b x) x :=
ha.fun_mul' hb
@[fun_prop]
theorem HasFDerivAt.fun_mul (hc : HasFDerivAt c c' x) (hd : HasFDerivAt d d' x) :
HasFDerivAt (fun y => c y * d y) (c x • d' + d x • c') x := by
convert hc.mul' hd
ext z
apply mul_comm
@[fun_prop]
theorem HasFDerivAt.mul (hc : HasFDerivAt c c' x) (hd : HasFDerivAt d d' x) :
HasFDerivAt (c * d) (c x • d' + d x • c') x :=
hc.fun_mul hd
@[fun_prop]
theorem DifferentiableWithinAt.fun_mul (ha : DifferentiableWithinAt 𝕜 a s x)
(hb : DifferentiableWithinAt 𝕜 b s x) : DifferentiableWithinAt 𝕜 (fun y => a y * b y) s x :=
(ha.hasFDerivWithinAt.mul' hb.hasFDerivWithinAt).differentiableWithinAt
@[fun_prop]
theorem DifferentiableWithinAt.mul (ha : DifferentiableWithinAt 𝕜 a s x)
(hb : DifferentiableWithinAt 𝕜 b s x) : DifferentiableWithinAt 𝕜 (a * b) s x :=
(ha.hasFDerivWithinAt.mul' hb.hasFDerivWithinAt).differentiableWithinAt
@[simp, fun_prop]
theorem DifferentiableAt.fun_mul (ha : DifferentiableAt 𝕜 a x) (hb : DifferentiableAt 𝕜 b x) :
DifferentiableAt 𝕜 (fun y => a y * b y) x :=
(ha.hasFDerivAt.mul' hb.hasFDerivAt).differentiableAt
@[simp, fun_prop]
theorem DifferentiableAt.mul (ha : DifferentiableAt 𝕜 a x) (hb : DifferentiableAt 𝕜 b x) :
DifferentiableAt 𝕜 (a * b) x :=
(ha.hasFDerivAt.mul' hb.hasFDerivAt).differentiableAt
@[fun_prop]
theorem DifferentiableOn.fun_mul (ha : DifferentiableOn 𝕜 a s) (hb : DifferentiableOn 𝕜 b s) :
DifferentiableOn 𝕜 (fun y => a y * b y) s := fun x hx => (ha x hx).mul (hb x hx)
@[fun_prop]
theorem DifferentiableOn.mul (ha : DifferentiableOn 𝕜 a s) (hb : DifferentiableOn 𝕜 b s) :
DifferentiableOn 𝕜 (a * b) s := fun x hx => (ha x hx).mul (hb x hx)
@[simp, fun_prop]
theorem Differentiable.fun_mul (ha : Differentiable 𝕜 a) (hb : Differentiable 𝕜 b) :
Differentiable 𝕜 fun y => a y * b y := fun x => (ha x).mul (hb x)
@[simp, fun_prop]
theorem Differentiable.mul (ha : Differentiable 𝕜 a) (hb : Differentiable 𝕜 b) :
Differentiable 𝕜 (a * b) := fun x => (ha x).mul (hb x)
theorem fderivWithin_fun_mul' (hxs : UniqueDiffWithinAt 𝕜 s x) (ha : DifferentiableWithinAt 𝕜 a s x)
(hb : DifferentiableWithinAt 𝕜 b s x) :
fderivWithin 𝕜 (fun y => a y * b y) s x =
a x • fderivWithin 𝕜 b s x + fderivWithin 𝕜 a s x <• b x :=
(ha.hasFDerivWithinAt.mul' hb.hasFDerivWithinAt).fderivWithin hxs
theorem fderivWithin_mul' (hxs : UniqueDiffWithinAt 𝕜 s x) (ha : DifferentiableWithinAt 𝕜 a s x)
(hb : DifferentiableWithinAt 𝕜 b s x) :
fderivWithin 𝕜 (a * b) s x =
a x • fderivWithin 𝕜 b s x + fderivWithin 𝕜 a s x <• b x :=
(ha.hasFDerivWithinAt.mul' hb.hasFDerivWithinAt).fderivWithin hxs
theorem fderivWithin_fun_mul (hxs : UniqueDiffWithinAt 𝕜 s x) (hc : DifferentiableWithinAt 𝕜 c s x)
(hd : DifferentiableWithinAt 𝕜 d s x) :
fderivWithin 𝕜 (fun y => c y * d y) s x =
c x • fderivWithin 𝕜 d s x + d x • fderivWithin 𝕜 c s x :=
(hc.hasFDerivWithinAt.mul hd.hasFDerivWithinAt).fderivWithin hxs
theorem fderivWithin_mul (hxs : UniqueDiffWithinAt 𝕜 s x) (hc : DifferentiableWithinAt 𝕜 c s x)
(hd : DifferentiableWithinAt 𝕜 d s x) :
fderivWithin 𝕜 (c * d) s x =
c x • fderivWithin 𝕜 d s x + d x • fderivWithin 𝕜 c s x :=
(hc.hasFDerivWithinAt.mul hd.hasFDerivWithinAt).fderivWithin hxs
theorem fderiv_fun_mul' (ha : DifferentiableAt 𝕜 a x) (hb : DifferentiableAt 𝕜 b x) :
fderiv 𝕜 (fun y => a y * b y) x = a x • fderiv 𝕜 b x + fderiv 𝕜 a x <• b x :=
(ha.hasFDerivAt.mul' hb.hasFDerivAt).fderiv
theorem fderiv_mul' (ha : DifferentiableAt 𝕜 a x) (hb : DifferentiableAt 𝕜 b x) :
fderiv 𝕜 (a * b) x = a x • fderiv 𝕜 b x + fderiv 𝕜 a x <• b x :=
(ha.hasFDerivAt.mul' hb.hasFDerivAt).fderiv
theorem fderiv_fun_mul (hc : DifferentiableAt 𝕜 c x) (hd : DifferentiableAt 𝕜 d x) :
fderiv 𝕜 (fun y => c y * d y) x = c x • fderiv 𝕜 d x + d x • fderiv 𝕜 c x :=
(hc.hasFDerivAt.mul hd.hasFDerivAt).fderiv
theorem fderiv_mul (hc : DifferentiableAt 𝕜 c x) (hd : DifferentiableAt 𝕜 d x) :
fderiv 𝕜 (c * d) x = c x • fderiv 𝕜 d x + d x • fderiv 𝕜 c x :=
(hc.hasFDerivAt.mul hd.hasFDerivAt).fderiv
@[fun_prop]
theorem HasStrictFDerivAt.mul_const' (ha : HasStrictFDerivAt a a' x) (b : 𝔸) :
HasStrictFDerivAt (fun y => a y * b) (a' <• b) x :=
((ContinuousLinearMap.mul 𝕜 𝔸).flip b).hasStrictFDerivAt.comp x ha
@[fun_prop]
theorem HasStrictFDerivAt.mul_const (hc : HasStrictFDerivAt c c' x) (d : 𝔸') :
HasStrictFDerivAt (fun y => c y * d) (d • c') x := by
convert hc.mul_const' d
ext z
apply mul_comm
@[fun_prop]
theorem HasFDerivWithinAt.mul_const' (ha : HasFDerivWithinAt a a' s x) (b : 𝔸) :
HasFDerivWithinAt (fun y => a y * b) (a' <• b) s x :=
((ContinuousLinearMap.mul 𝕜 𝔸).flip b).hasFDerivAt.comp_hasFDerivWithinAt x ha
@[fun_prop]
theorem HasFDerivWithinAt.mul_const (hc : HasFDerivWithinAt c c' s x) (d : 𝔸') :
HasFDerivWithinAt (fun y => c y * d) (d • c') s x := by
convert hc.mul_const' d
ext z
apply mul_comm
@[fun_prop]
theorem HasFDerivAt.mul_const' (ha : HasFDerivAt a a' x) (b : 𝔸) :
HasFDerivAt (fun y => a y * b) (a' <• b) x :=
((ContinuousLinearMap.mul 𝕜 𝔸).flip b).hasFDerivAt.comp x ha
@[fun_prop]
theorem HasFDerivAt.mul_const (hc : HasFDerivAt c c' x) (d : 𝔸') :
HasFDerivAt (fun y => c y * d) (d • c') x := by
convert hc.mul_const' d
ext z
apply mul_comm
@[fun_prop]
theorem DifferentiableWithinAt.mul_const (ha : DifferentiableWithinAt 𝕜 a s x) (b : 𝔸) :
DifferentiableWithinAt 𝕜 (fun y => a y * b) s x :=
(ha.hasFDerivWithinAt.mul_const' b).differentiableWithinAt
@[fun_prop]
theorem DifferentiableAt.mul_const (ha : DifferentiableAt 𝕜 a x) (b : 𝔸) :
DifferentiableAt 𝕜 (fun y => a y * b) x :=
(ha.hasFDerivAt.mul_const' b).differentiableAt
@[fun_prop]
theorem DifferentiableOn.mul_const (ha : DifferentiableOn 𝕜 a s) (b : 𝔸) :
DifferentiableOn 𝕜 (fun y => a y * b) s := fun x hx => (ha x hx).mul_const b
@[fun_prop]
theorem Differentiable.mul_const (ha : Differentiable 𝕜 a) (b : 𝔸) :
Differentiable 𝕜 fun y => a y * b := fun x => (ha x).mul_const b
theorem fderivWithin_mul_const' (hxs : UniqueDiffWithinAt 𝕜 s x)
(ha : DifferentiableWithinAt 𝕜 a s x) (b : 𝔸) :
fderivWithin 𝕜 (fun y => a y * b) s x = fderivWithin 𝕜 a s x <• b :=
(ha.hasFDerivWithinAt.mul_const' b).fderivWithin hxs
theorem fderivWithin_mul_const (hxs : UniqueDiffWithinAt 𝕜 s x)
(hc : DifferentiableWithinAt 𝕜 c s x) (d : 𝔸') :
fderivWithin 𝕜 (fun y => c y * d) s x = d • fderivWithin 𝕜 c s x :=
(hc.hasFDerivWithinAt.mul_const d).fderivWithin hxs
theorem fderiv_mul_const' (ha : DifferentiableAt 𝕜 a x) (b : 𝔸) :
fderiv 𝕜 (fun y => a y * b) x = fderiv 𝕜 a x <• b :=
(ha.hasFDerivAt.mul_const' b).fderiv
theorem fderiv_mul_const (hc : DifferentiableAt 𝕜 c x) (d : 𝔸') :
fderiv 𝕜 (fun y => c y * d) x = d • fderiv 𝕜 c x :=
(hc.hasFDerivAt.mul_const d).fderiv
@[fun_prop]
theorem HasStrictFDerivAt.const_mul (ha : HasStrictFDerivAt a a' x) (b : 𝔸) :
HasStrictFDerivAt (fun y => b * a y) (b • a') x :=
((ContinuousLinearMap.mul 𝕜 𝔸) b).hasStrictFDerivAt.comp x ha
@[fun_prop]
theorem HasFDerivWithinAt.const_mul (ha : HasFDerivWithinAt a a' s x) (b : 𝔸) :
HasFDerivWithinAt (fun y => b * a y) (b • a') s x :=
((ContinuousLinearMap.mul 𝕜 𝔸) b).hasFDerivAt.comp_hasFDerivWithinAt x ha
@[fun_prop]
theorem HasFDerivAt.const_mul (ha : HasFDerivAt a a' x) (b : 𝔸) :
HasFDerivAt (fun y => b * a y) (b • a') x :=
((ContinuousLinearMap.mul 𝕜 𝔸) b).hasFDerivAt.comp x ha
@[fun_prop]
theorem DifferentiableWithinAt.const_mul (ha : DifferentiableWithinAt 𝕜 a s x) (b : 𝔸) :
DifferentiableWithinAt 𝕜 (fun y => b * a y) s x :=
(ha.hasFDerivWithinAt.const_mul b).differentiableWithinAt
@[fun_prop]
theorem DifferentiableAt.const_mul (ha : DifferentiableAt 𝕜 a x) (b : 𝔸) :
DifferentiableAt 𝕜 (fun y => b * a y) x :=
(ha.hasFDerivAt.const_mul b).differentiableAt
@[fun_prop]
theorem DifferentiableOn.const_mul (ha : DifferentiableOn 𝕜 a s) (b : 𝔸) :
DifferentiableOn 𝕜 (fun y => b * a y) s := fun x hx => (ha x hx).const_mul b
@[fun_prop]
theorem Differentiable.const_mul (ha : Differentiable 𝕜 a) (b : 𝔸) :
Differentiable 𝕜 fun y => b * a y := fun x => (ha x).const_mul b
theorem fderivWithin_const_mul (hxs : UniqueDiffWithinAt 𝕜 s x)
(ha : DifferentiableWithinAt 𝕜 a s x) (b : 𝔸) :
fderivWithin 𝕜 (fun y => b * a y) s x = b • fderivWithin 𝕜 a s x :=
(ha.hasFDerivWithinAt.const_mul b).fderivWithin hxs
theorem fderiv_const_mul (ha : DifferentiableAt 𝕜 a x) (b : 𝔸) :
fderiv 𝕜 (fun y => b * a y) x = b • fderiv 𝕜 a x :=
(ha.hasFDerivAt.const_mul b).fderiv
end Mul
section Prod
open scoped RightActions
/-! ### Derivative of a finite product of functions -/
variable {ι : Type*} {𝔸 𝔸' : Type*} [NormedRing 𝔸] [NormedCommRing 𝔸'] [NormedAlgebra 𝕜 𝔸]
[NormedAlgebra 𝕜 𝔸'] {u : Finset ι} {f : ι → E → 𝔸} {f' : ι → E →L[𝕜] 𝔸} {g : ι → E → 𝔸'}
{g' : ι → E →L[𝕜] 𝔸'}
@[fun_prop]
theorem hasStrictFDerivAt_list_prod' [Fintype ι] {l : List ι} {x : ι → 𝔸} :
HasStrictFDerivAt (𝕜 := 𝕜) (fun x ↦ (l.map x).prod)
(∑ i : Fin l.length, ((l.take i).map x).prod •
proj l[i] <• ((l.drop (.succ i)).map x).prod) x := by
induction l with
| nil => simp [hasStrictFDerivAt_const]
| cons a l IH =>
simp only [List.map_cons, List.prod_cons, ← proj_apply (R := 𝕜) (φ := fun _ : ι ↦ 𝔸) a]
exact .congr_fderiv (.mul' (ContinuousLinearMap.hasStrictFDerivAt _) IH)
(by ext; simp [Fin.sum_univ_succ, Finset.mul_sum, mul_assoc, add_comm])
@[fun_prop]
theorem hasStrictFDerivAt_list_prod_finRange' {n : ℕ} {x : Fin n → 𝔸} :
HasStrictFDerivAt (𝕜 := 𝕜) (fun x ↦ ((List.finRange n).map x).prod)
(∑ i : Fin n, (((List.finRange n).take i).map x).prod •
proj i <• (((List.finRange n).drop (.succ i)).map x).prod) x :=
hasStrictFDerivAt_list_prod'.congr_fderiv <|
Finset.sum_equiv (finCongr List.length_finRange) (by simp) (by simp)
@[fun_prop]
theorem hasStrictFDerivAt_list_prod_attach' {l : List ι} {x : {i // i ∈ l} → 𝔸} :
HasStrictFDerivAt (𝕜 := 𝕜) (fun x ↦ (l.attach.map x).prod)
(∑ i : Fin l.length, ((l.attach.take i).map x).prod •
proj l.attach[i.cast List.length_attach.symm] <•
((l.attach.drop (.succ i)).map x).prod) x := by
classical exact hasStrictFDerivAt_list_prod'.congr_fderiv <| Eq.symm <|
Finset.sum_equiv (finCongr List.length_attach.symm) (by simp) (by simp)
@[fun_prop]
theorem hasFDerivAt_list_prod' [Fintype ι] {l : List ι} {x : ι → 𝔸'} :
HasFDerivAt (𝕜 := 𝕜) (fun x ↦ (l.map x).prod)
(∑ i : Fin l.length, ((l.take i).map x).prod •
proj l[i] <• ((l.drop (.succ i)).map x).prod) x :=
hasStrictFDerivAt_list_prod'.hasFDerivAt
@[fun_prop]
theorem hasFDerivAt_list_prod_finRange' {n : ℕ} {x : Fin n → 𝔸} :
HasFDerivAt (𝕜 := 𝕜) (fun x ↦ ((List.finRange n).map x).prod)
(∑ i : Fin n, (((List.finRange n).take i).map x).prod •
proj i <• (((List.finRange n).drop (.succ i)).map x).prod) x :=
(hasStrictFDerivAt_list_prod_finRange').hasFDerivAt
@[fun_prop]
theorem hasFDerivAt_list_prod_attach' {l : List ι} {x : {i // i ∈ l} → 𝔸} :
HasFDerivAt (𝕜 := 𝕜) (fun x ↦ (l.attach.map x).prod)
(∑ i : Fin l.length, ((l.attach.take i).map x).prod •
(proj l.attach[i.cast List.length_attach.symm]) <•
((l.attach.drop (.succ i)).map x).prod) x := by
classical exact hasStrictFDerivAt_list_prod_attach'.hasFDerivAt
/--
Auxiliary lemma for `hasStrictFDerivAt_multiset_prod`.
For `NormedCommRing 𝔸'`, can rewrite as `Multiset` using `Multiset.prod_coe`.
-/
@[fun_prop]
theorem hasStrictFDerivAt_list_prod [DecidableEq ι] [Fintype ι] {l : List ι} {x : ι → 𝔸'} :
HasStrictFDerivAt (𝕜 := 𝕜) (fun x ↦ (l.map x).prod)
(l.map fun i ↦ ((l.erase i).map x).prod • proj i).sum x := by
refine hasStrictFDerivAt_list_prod'.congr_fderiv ?_
conv_rhs => arg 1; arg 2; rw [← List.finRange_map_get l]
simp only [List.map_map, ← List.sum_toFinset _ (List.nodup_finRange _), List.toFinset_finRange,
Function.comp_def, ((List.erase_getElem _).map _).prod_eq, List.eraseIdx_eq_take_drop_succ,
List.map_append, List.prod_append, List.get_eq_getElem, Fin.getElem_fin, Nat.succ_eq_add_one]
exact Finset.sum_congr rfl fun i _ ↦ by
ext; simp only [smul_apply, op_smul_eq_smul, smul_eq_mul]; ring
@[fun_prop]
theorem hasStrictFDerivAt_multiset_prod [DecidableEq ι] [Fintype ι] {u : Multiset ι} {x : ι → 𝔸'} :
HasStrictFDerivAt (𝕜 := 𝕜) (fun x ↦ (u.map x).prod)
(u.map (fun i ↦ ((u.erase i).map x).prod • proj i)).sum x :=
u.inductionOn fun l ↦ by simpa using hasStrictFDerivAt_list_prod
@[fun_prop]
theorem hasFDerivAt_multiset_prod [DecidableEq ι] [Fintype ι] {u : Multiset ι} {x : ι → 𝔸'} :
HasFDerivAt (𝕜 := 𝕜) (fun x ↦ (u.map x).prod)
(Multiset.sum (u.map (fun i ↦ ((u.erase i).map x).prod • proj i))) x :=
hasStrictFDerivAt_multiset_prod.hasFDerivAt
theorem hasStrictFDerivAt_finset_prod [DecidableEq ι] [Fintype ι] {x : ι → 𝔸'} :
HasStrictFDerivAt (𝕜 := 𝕜) (∏ i ∈ u, · i) (∑ i ∈ u, (∏ j ∈ u.erase i, x j) • proj i) x := by
simp only [Finset.sum_eq_multiset_sum, Finset.prod_eq_multiset_prod]
exact hasStrictFDerivAt_multiset_prod
theorem hasFDerivAt_finset_prod [DecidableEq ι] [Fintype ι] {x : ι → 𝔸'} :
HasFDerivAt (𝕜 := 𝕜) (∏ i ∈ u, · i) (∑ i ∈ u, (∏ j ∈ u.erase i, x j) • proj i) x :=
hasStrictFDerivAt_finset_prod.hasFDerivAt
section Comp
@[fun_prop]
theorem HasStrictFDerivAt.list_prod' {l : List ι} {x : E}
(h : ∀ i ∈ l, HasStrictFDerivAt (f i ·) (f' i) x) :
HasStrictFDerivAt (fun x ↦ (l.map (f · x)).prod)
(∑ i : Fin l.length, ((l.take i).map (f · x)).prod •
f' l[i] <• ((l.drop (.succ i)).map (f · x)).prod) x := by
simp_rw [Fin.getElem_fin, ← l.get_eq_getElem, ← List.finRange_map_get l, List.map_map]
-- After https://github.com/leanprover-community/mathlib4/issues/19108, we have to be optimistic with `:)`s; otherwise Lean decides it need to find
-- `NormedAddCommGroup (List 𝔸)` which is nonsense.
refine .congr_fderiv (hasStrictFDerivAt_list_prod_finRange'.comp x
(hasStrictFDerivAt_pi.mpr fun i ↦ h (l.get i) (List.getElem_mem ..)) :) ?_
ext m
simp_rw [List.map_take, List.map_drop, List.map_map, comp_apply, sum_apply, smul_apply,
proj_apply, pi_apply, Function.comp_def]
/--
Unlike `HasFDerivAt.finset_prod`, supports non-commutative multiply and duplicate elements.
-/
@[fun_prop]
theorem HasFDerivAt.list_prod' {l : List ι} {x : E}
(h : ∀ i ∈ l, HasFDerivAt (f i ·) (f' i) x) :
HasFDerivAt (fun x ↦ (l.map (f · x)).prod)
(∑ i : Fin l.length, ((l.take i).map (f · x)).prod •
f' l[i] <• ((l.drop (.succ i)).map (f · x)).prod) x := by
simp_rw [Fin.getElem_fin, ← l.get_eq_getElem, ← List.finRange_map_get l, List.map_map]
refine .congr_fderiv (hasFDerivAt_list_prod_finRange'.comp x
(hasFDerivAt_pi.mpr fun i ↦ h (l.get i) (l.get_mem i)) :) ?_
ext m
simp_rw [List.map_take, List.map_drop, List.map_map, comp_apply, sum_apply, smul_apply,
proj_apply, pi_apply, Function.comp_def]
@[fun_prop]
theorem HasFDerivWithinAt.list_prod' {l : List ι} {x : E}
(h : ∀ i ∈ l, HasFDerivWithinAt (f i ·) (f' i) s x) :
HasFDerivWithinAt (fun x ↦ (l.map (f · x)).prod)
(∑ i : Fin l.length, ((l.take i).map (f · x)).prod •
f' l[i] <• ((l.drop (.succ i)).map (f · x)).prod) s x := by
simp_rw [Fin.getElem_fin, ← l.get_eq_getElem, ← List.finRange_map_get l, List.map_map]
refine .congr_fderiv (hasFDerivAt_list_prod_finRange'.comp_hasFDerivWithinAt x
(hasFDerivWithinAt_pi.mpr fun i ↦ h (l.get i) (l.get_mem i)) :) ?_
ext m
simp_rw [List.map_take, List.map_drop, List.map_map, comp_apply, sum_apply, smul_apply,
proj_apply, pi_apply, Function.comp_def]
theorem fderiv_list_prod' {l : List ι} {x : E}
(h : ∀ i ∈ l, DifferentiableAt 𝕜 (f i ·) x) :
fderiv 𝕜 (fun x ↦ (l.map (f · x)).prod) x =
∑ i : Fin l.length, ((l.take i).map (f · x)).prod •
(fderiv 𝕜 (fun x ↦ f l[i] x) x) <• ((l.drop (.succ i)).map (f · x)).prod :=
(HasFDerivAt.list_prod' fun i hi ↦ (h i hi).hasFDerivAt).fderiv
theorem fderivWithin_list_prod' {l : List ι} {x : E}
(hxs : UniqueDiffWithinAt 𝕜 s x) (h : ∀ i ∈ l, DifferentiableWithinAt 𝕜 (f i ·) s x) :
fderivWithin 𝕜 (fun x ↦ (l.map (f · x)).prod) s x =
∑ i : Fin l.length, ((l.take i).map (f · x)).prod •
(fderivWithin 𝕜 (fun x ↦ f l[i] x) s x) <• ((l.drop (.succ i)).map (f · x)).prod :=
(HasFDerivWithinAt.list_prod' fun i hi ↦ (h i hi).hasFDerivWithinAt).fderivWithin hxs
@[fun_prop]
theorem HasStrictFDerivAt.multiset_prod [DecidableEq ι] {u : Multiset ι} {x : E}
(h : ∀ i ∈ u, HasStrictFDerivAt (g i ·) (g' i) x) :
HasStrictFDerivAt (fun x ↦ (u.map (g · x)).prod)
(u.map fun i ↦ ((u.erase i).map (g · x)).prod • g' i).sum x := by
simp only [← Multiset.attach_map_val u, Multiset.map_map]
exact .congr_fderiv
(hasStrictFDerivAt_multiset_prod.comp x <|
hasStrictFDerivAt_pi.mpr fun i ↦ h (Subtype.val i) i.prop :)
(by ext; simp [Finset.sum_multiset_map_count, u.erase_attach_map (g · x)])
/--
Unlike `HasFDerivAt.finset_prod`, supports duplicate elements.
-/
@[fun_prop]
theorem HasFDerivAt.multiset_prod [DecidableEq ι] {u : Multiset ι} {x : E}
(h : ∀ i ∈ u, HasFDerivAt (g i ·) (g' i) x) :
HasFDerivAt (fun x ↦ (u.map (g · x)).prod)
(u.map fun i ↦ ((u.erase i).map (g · x)).prod • g' i).sum x := by
simp only [← Multiset.attach_map_val u, Multiset.map_map]
exact .congr_fderiv
(hasFDerivAt_multiset_prod.comp x <| hasFDerivAt_pi.mpr fun i ↦ h (Subtype.val i) i.prop :)
(by ext; simp [Finset.sum_multiset_map_count, u.erase_attach_map (g · x)])
@[fun_prop]
theorem HasFDerivWithinAt.multiset_prod [DecidableEq ι] {u : Multiset ι} {x : E}
(h : ∀ i ∈ u, HasFDerivWithinAt (g i ·) (g' i) s x) :
HasFDerivWithinAt (fun x ↦ (u.map (g · x)).prod)
(u.map fun i ↦ ((u.erase i).map (g · x)).prod • g' i).sum s x := by
simp only [← Multiset.attach_map_val u, Multiset.map_map]
exact .congr_fderiv
(hasFDerivAt_multiset_prod.comp_hasFDerivWithinAt x <|
hasFDerivWithinAt_pi.mpr fun i ↦ h (Subtype.val i) i.prop :)
(by ext; simp [Finset.sum_multiset_map_count, u.erase_attach_map (g · x)])
theorem fderiv_multiset_prod [DecidableEq ι] {u : Multiset ι} {x : E}
(h : ∀ i ∈ u, DifferentiableAt 𝕜 (g i ·) x) :
fderiv 𝕜 (fun x ↦ (u.map (g · x)).prod) x =
(u.map fun i ↦ ((u.erase i).map (g · x)).prod • fderiv 𝕜 (g i) x).sum :=
(HasFDerivAt.multiset_prod fun i hi ↦ (h i hi).hasFDerivAt).fderiv
theorem fderivWithin_multiset_prod [DecidableEq ι] {u : Multiset ι} {x : E}
(hxs : UniqueDiffWithinAt 𝕜 s x) (h : ∀ i ∈ u, DifferentiableWithinAt 𝕜 (g i ·) s x) :
fderivWithin 𝕜 (fun x ↦ (u.map (g · x)).prod) s x =
(u.map fun i ↦ ((u.erase i).map (g · x)).prod • fderivWithin 𝕜 (g i) s x).sum :=
(HasFDerivWithinAt.multiset_prod fun i hi ↦ (h i hi).hasFDerivWithinAt).fderivWithin hxs
theorem HasStrictFDerivAt.finset_prod [DecidableEq ι] {x : E}
(hg : ∀ i ∈ u, HasStrictFDerivAt (g i) (g' i) x) :
HasStrictFDerivAt (∏ i ∈ u, g i ·) (∑ i ∈ u, (∏ j ∈ u.erase i, g j x) • g' i) x := by
simpa [← Finset.prod_attach u] using .congr_fderiv
(hasStrictFDerivAt_finset_prod.comp x <| hasStrictFDerivAt_pi.mpr fun i ↦ hg i i.prop)
(by ext; simp [Finset.prod_erase_attach (g · x), ← u.sum_attach])
theorem HasFDerivAt.finset_prod [DecidableEq ι] {x : E}
(hg : ∀ i ∈ u, HasFDerivAt (g i) (g' i) x) :
HasFDerivAt (∏ i ∈ u, g i ·) (∑ i ∈ u, (∏ j ∈ u.erase i, g j x) • g' i) x := by
simpa [← Finset.prod_attach u] using .congr_fderiv
(hasFDerivAt_finset_prod.comp x <| hasFDerivAt_pi.mpr fun i ↦ hg (Subtype.val i) i.prop :)
(by ext; simp [Finset.prod_erase_attach (g · x), ← u.sum_attach])
theorem HasFDerivWithinAt.finset_prod [DecidableEq ι] {x : E}
(hg : ∀ i ∈ u, HasFDerivWithinAt (g i) (g' i) s x) :
HasFDerivWithinAt (∏ i ∈ u, g i ·) (∑ i ∈ u, (∏ j ∈ u.erase i, g j x) • g' i) s x := by
simpa [← Finset.prod_attach u] using .congr_fderiv
(hasFDerivAt_finset_prod.comp_hasFDerivWithinAt x <|
hasFDerivWithinAt_pi.mpr fun i ↦ hg (Subtype.val i) i.prop :)
(by ext; simp [Finset.prod_erase_attach (g · x), ← u.sum_attach])
theorem fderiv_finset_prod [DecidableEq ι] {x : E} (hg : ∀ i ∈ u, DifferentiableAt 𝕜 (g i) x) :
fderiv 𝕜 (∏ i ∈ u, g i ·) x = ∑ i ∈ u, (∏ j ∈ u.erase i, (g j x)) • fderiv 𝕜 (g i) x :=
(HasFDerivAt.finset_prod fun i hi ↦ (hg i hi).hasFDerivAt).fderiv
theorem fderivWithin_finset_prod [DecidableEq ι] {x : E} (hxs : UniqueDiffWithinAt 𝕜 s x)
(hg : ∀ i ∈ u, DifferentiableWithinAt 𝕜 (g i) s x) :
fderivWithin 𝕜 (∏ i ∈ u, g i ·) s x =
∑ i ∈ u, (∏ j ∈ u.erase i, (g j x)) • fderivWithin 𝕜 (g i) s x :=
(HasFDerivWithinAt.finset_prod fun i hi ↦ (hg i hi).hasFDerivWithinAt).fderivWithin hxs
end Comp
end Prod
section AlgebraInverse
variable {R : Type*} [NormedRing R] [HasSummableGeomSeries R] [NormedAlgebra 𝕜 R]
open NormedRing ContinuousLinearMap Ring
/-- At an invertible element `x` of a normed algebra `R`, the Fréchet derivative of the inversion
operation is the linear map `fun t ↦ - x⁻¹ * t * x⁻¹`.
TODO (low prio): prove a version without assumption `[HasSummableGeomSeries R]` but within the set
of units. -/
@[fun_prop]
theorem hasFDerivAt_ringInverse (x : Rˣ) :
HasFDerivAt Ring.inverse (-mulLeftRight 𝕜 R ↑x⁻¹ ↑x⁻¹) x :=
have : (fun t : R => Ring.inverse (↑x + t) - ↑x⁻¹ + ↑x⁻¹ * t * ↑x⁻¹) =o[𝓝 0] id :=
(inverse_add_norm_diff_second_order x).trans_isLittleO (isLittleO_norm_pow_id one_lt_two)
by simpa [hasFDerivAt_iff_isLittleO_nhds_zero] using this
@[deprecated (since := "2025-04-22")] alias hasFDerivAt_ring_inverse := hasFDerivAt_ringInverse
@[fun_prop]
theorem differentiableAt_inverse {x : R} (hx : IsUnit x) :
DifferentiableAt 𝕜 (@Ring.inverse R _) x :=
let ⟨u, hu⟩ := hx; hu ▸ (hasFDerivAt_ringInverse u).differentiableAt
@[fun_prop]
theorem differentiableWithinAt_inverse {x : R} (hx : IsUnit x) (s : Set R) :
DifferentiableWithinAt 𝕜 (@Ring.inverse R _) s x :=
(differentiableAt_inverse hx).differentiableWithinAt
@[fun_prop]
theorem differentiableOn_inverse : DifferentiableOn 𝕜 (@Ring.inverse R _) {x | IsUnit x} :=
fun _x hx => differentiableWithinAt_inverse hx _
theorem fderiv_inverse (x : Rˣ) : fderiv 𝕜 (@Ring.inverse R _) x = -mulLeftRight 𝕜 R ↑x⁻¹ ↑x⁻¹ :=
(hasFDerivAt_ringInverse x).fderiv
theorem hasStrictFDerivAt_ringInverse (x : Rˣ) :
HasStrictFDerivAt Ring.inverse (-mulLeftRight 𝕜 R ↑x⁻¹ ↑x⁻¹) x := by
convert (analyticAt_inverse (𝕜 := 𝕜) x).hasStrictFDerivAt
exact (fderiv_inverse x).symm
@[deprecated (since := "2025-04-22")]
alias hasStrictFDerivAt_ring_inverse := hasStrictFDerivAt_ringInverse
variable {h : E → R} {z : E} {S : Set E}
@[fun_prop]
theorem DifferentiableWithinAt.inverse (hf : DifferentiableWithinAt 𝕜 h S z) (hz : IsUnit (h z)) :
DifferentiableWithinAt 𝕜 (fun x => Ring.inverse (h x)) S z :=
(differentiableAt_inverse hz).comp_differentiableWithinAt z hf
@[simp, fun_prop]
theorem DifferentiableAt.inverse (hf : DifferentiableAt 𝕜 h z) (hz : IsUnit (h z)) :
DifferentiableAt 𝕜 (fun x => Ring.inverse (h x)) z :=
(differentiableAt_inverse hz).comp z hf
@[fun_prop]
theorem DifferentiableOn.inverse (hf : DifferentiableOn 𝕜 h S) (hz : ∀ x ∈ S, IsUnit (h x)) :
DifferentiableOn 𝕜 (fun x => Ring.inverse (h x)) S := fun x h => (hf x h).inverse (hz x h)
@[simp, fun_prop]
theorem Differentiable.inverse (hf : Differentiable 𝕜 h) (hz : ∀ x, IsUnit (h x)) :
Differentiable 𝕜 fun x => Ring.inverse (h x) := fun x => (hf x).inverse (hz x)
end AlgebraInverse
/-! ### Derivative of the inverse in a division ring
Note that some lemmas are primed as they are expressed without commutativity, whereas their
counterparts in commutative fields involve simpler expressions, and are given in
`Mathlib/Analysis/Calculus/Deriv/Inv.lean`.
-/
section DivisionRingInverse
variable {R : Type*} [NormedDivisionRing R] [NormedAlgebra 𝕜 R]
open NormedRing ContinuousLinearMap Ring
/-- At an invertible element `x` of a normed division algebra `R`, the inversion is strictly
differentiable, with derivative the linear map `fun t ↦ - x⁻¹ * t * x⁻¹`. For a nicer formula in
the commutative case, see `hasStrictFDerivAt_inv`. -/
theorem hasStrictFDerivAt_inv' {x : R} (hx : x ≠ 0) :
HasStrictFDerivAt Inv.inv (-mulLeftRight 𝕜 R x⁻¹ x⁻¹) x := by
simpa using hasStrictFDerivAt_ringInverse (Units.mk0 _ hx)
/-- At an invertible element `x` of a normed division algebra `R`, the Fréchet derivative of the
inversion operation is the linear map `fun t ↦ - x⁻¹ * t * x⁻¹`. For a nicer formula in the
commutative case, see `hasFDerivAt_inv`. -/
@[fun_prop]
theorem hasFDerivAt_inv' {x : R} (hx : x ≠ 0) :
HasFDerivAt Inv.inv (-mulLeftRight 𝕜 R x⁻¹ x⁻¹) x := by
simpa using hasFDerivAt_ringInverse (Units.mk0 _ hx)
@[fun_prop]
theorem differentiableAt_inv {x : R} (hx : x ≠ 0) : DifferentiableAt 𝕜 Inv.inv x :=
(hasFDerivAt_inv' hx).differentiableAt
@[fun_prop]
theorem differentiableWithinAt_inv {x : R} (hx : x ≠ 0) (s : Set R) :
DifferentiableWithinAt 𝕜 (fun x => x⁻¹) s x :=
(differentiableAt_inv hx).differentiableWithinAt
@[fun_prop]
theorem differentiableOn_inv : DifferentiableOn 𝕜 (fun x : R => x⁻¹) {x | x ≠ 0} := fun _x hx =>
differentiableWithinAt_inv hx _
/-- Non-commutative version of `fderiv_inv` -/
theorem fderiv_inv' {x : R} (hx : x ≠ 0) : fderiv 𝕜 Inv.inv x = -mulLeftRight 𝕜 R x⁻¹ x⁻¹ :=
(hasFDerivAt_inv' hx).fderiv
/-- Non-commutative version of `fderivWithin_inv` -/
theorem fderivWithin_inv' {s : Set R} {x : R} (hx : x ≠ 0) (hxs : UniqueDiffWithinAt 𝕜 s x) :
fderivWithin 𝕜 (fun x => x⁻¹) s x = -mulLeftRight 𝕜 R x⁻¹ x⁻¹ := by
rw [DifferentiableAt.fderivWithin (differentiableAt_inv hx) hxs]
exact fderiv_inv' hx
variable {h : E → R} {z : E} {S : Set E}
@[fun_prop]
theorem DifferentiableWithinAt.fun_inv (hf : DifferentiableWithinAt 𝕜 h S z) (hz : h z ≠ 0) :
DifferentiableWithinAt 𝕜 (fun x => (h x)⁻¹) S z :=
(differentiableAt_inv hz).comp_differentiableWithinAt z hf
@[fun_prop]
theorem DifferentiableWithinAt.inv (hf : DifferentiableWithinAt 𝕜 h S z) (hz : h z ≠ 0) :
DifferentiableWithinAt 𝕜 (h⁻¹) S z :=
(differentiableAt_inv hz).comp_differentiableWithinAt z hf
@[simp, fun_prop]
theorem DifferentiableAt.fun_inv (hf : DifferentiableAt 𝕜 h z) (hz : h z ≠ 0) :
DifferentiableAt 𝕜 (fun x => (h x)⁻¹) z :=
(differentiableAt_inv hz).comp z hf
@[simp, fun_prop]
theorem DifferentiableAt.inv (hf : DifferentiableAt 𝕜 h z) (hz : h z ≠ 0) :
DifferentiableAt 𝕜 (h⁻¹) z :=
(differentiableAt_inv hz).comp z hf
@[fun_prop]
theorem DifferentiableOn.fun_inv (hf : DifferentiableOn 𝕜 h S) (hz : ∀ x ∈ S, h x ≠ 0) :
DifferentiableOn 𝕜 (fun x => (h x)⁻¹) S := fun x h => (hf x h).inv (hz x h)
@[fun_prop]
theorem DifferentiableOn.inv (hf : DifferentiableOn 𝕜 h S) (hz : ∀ x ∈ S, h x ≠ 0) :
DifferentiableOn 𝕜 (h⁻¹) S := fun x h => (hf x h).inv (hz x h)
@[simp, fun_prop]
theorem Differentiable.fun_inv (hf : Differentiable 𝕜 h) (hz : ∀ x, h x ≠ 0) :
Differentiable 𝕜 fun x => (h x)⁻¹ := fun x => (hf x).inv (hz x)
@[simp, fun_prop]
theorem Differentiable.inv (hf : Differentiable 𝕜 h) (hz : ∀ x, h x ≠ 0) :
Differentiable 𝕜 (h⁻¹) := fun x => (hf x).inv (hz x)
end DivisionRingInverse
end |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/FDeriv/Basic.lean | import Mathlib.Analysis.Asymptotics.Lemmas
import Mathlib.Analysis.Calculus.FDeriv.Defs
import Mathlib.Analysis.Normed.Operator.Asymptotics
import Mathlib.Analysis.Calculus.TangentCone.Basic
/-!
# The Fréchet derivative: basic properties
Let `E` and `F` be normed spaces, `f : E → F`, and `f' : E →L[𝕜] F` a
continuous 𝕜-linear map, where `𝕜` is a non-discrete normed field. Then
`HasFDerivWithinAt f f' s x`
says that `f` has derivative `f'` at `x`, where the domain of interest
is restricted to `s`. We also have
`HasFDerivAt f f' x := HasFDerivWithinAt f f' x univ`
Finally,
`HasStrictFDerivAt f f' x`
means that `f : E → F` has derivative `f' : E →L[𝕜] F` in the sense of strict differentiability,
i.e., `f y - f z - f'(y - z) = o(y - z)` as `y, z → x`. This notion is used in the inverse
function theorem, and is defined here only to avoid proving theorems like
`IsBoundedBilinearMap.hasFDerivAt` twice: first for `HasFDerivAt`, then for
`HasStrictFDerivAt`.
## Main results
This file builds on the bare-bones definition given in `Defs.lean` by establishing a variety of
relatively straightforward properties of the derivative.
Deeper properties are defined in other files in the folder `Analysis/Calculus/FDeriv/`, which
contain the usual formulas (and existence assertions) for the derivative of
* constants (`Const.lean`)
* bounded linear maps (`Linear.lean`)
* bounded bilinear maps (`Bilinear.lean`)
* sum of two functions (`Add.lean`)
* sum of finitely many functions (`Add.lean`)
* multiplication of a function by a scalar constant (`Add.lean`)
* negative of a function (`Add.lean`)
* subtraction of two functions (`Add.lean`)
* multiplication of a function by a scalar function (`Mul.lean`)
* multiplication of two scalar functions (`Mul.lean`)
* composition of functions (the chain rule) (`Comp.lean`)
* inverse function (`Mul.lean`)
(assuming that it exists; the inverse function theorem is in `../Inverse.lean`)
For most binary operations we also define `const_op` and `op_const` theorems for the cases when
the first or second argument is a constant. This makes writing chains of `HasDerivAt`'s easier,
and they more frequently lead to the desired result.
One can also interpret the derivative of a function `f : 𝕜 → E` as an element of `E` (by identifying
a linear function from `𝕜` to `E` with its value at `1`). Results on the Fréchet derivative are
translated to this more elementary point of view on the derivative in the file `Deriv.lean`. The
derivative of polynomials is handled there, as it is naturally one-dimensional.
The simplifier is set up to prove automatically that some functions are differentiable, or
differentiable at a point (but not differentiable on a set or within a set at a point, as checking
automatically that the good domains are mapped one to the other when using composition is not
something the simplifier can easily do). This means that one can write
`example (x : ℝ) : Differentiable ℝ (fun x ↦ sin (exp (3 + x^2)) - 5 * cos x) := by simp`.
If there are divisions, one needs to supply to the simplifier proofs that the denominators do
not vanish, as in
```lean
example (x : ℝ) (h : 1 + sin x ≠ 0) : DifferentiableAt ℝ (fun x ↦ exp x / (1 + sin x)) x := by
simp [h]
```
Of course, these examples only work once `exp`, `cos` and `sin` have been shown to be
differentiable, in `Mathlib/Analysis/SpecialFunctions/Trigonometric/Deriv.lean`.
The simplifier is not set up to compute the Fréchet derivative of maps (as these are in general
complicated multidimensional linear maps), but it will compute one-dimensional derivatives,
see `Deriv.lean`.
## Implementation details
For a discussion of the definitions and their rationale, see the file docstring of
`Mathlib.Analysis.Calculus.FDeriv.Defs`.
To make sure that the simplifier can prove automatically that functions are differentiable, we tag
many lemmas with the `simp` attribute, for instance those saying that the sum of differentiable
functions is differentiable, as well as their product, their Cartesian product, and so on. A notable
exception is the chain rule: we do not mark as a simp lemma the fact that, if `f` and `g` are
differentiable, then their composition also is: `simp` would always be able to match this lemma,
by taking `f` or `g` to be the identity. Instead, for every reasonable function (say, `exp`),
we add a lemma that if `f` is differentiable then so is `(fun x ↦ exp (f x))`. This means adding
some boilerplate lemmas, but these can also be useful in their own right.
Tests for this ability of the simplifier (with more examples) are provided in
`Tests/Differentiable.lean`.
## TODO
Generalize more results to topological vector spaces.
## Tags
derivative, differentiable, Fréchet, calculus
-/
open Filter Asymptotics ContinuousLinearMap Set Metric Topology NNReal ENNReal
noncomputable section
section
variable {𝕜 : Type*} [NontriviallyNormedField 𝕜]
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E]
variable {F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F]
variable {f f₀ f₁ g : E → F}
variable {f' f₀' f₁' g' : E →L[𝕜] F}
variable {x : E}
variable {s t : Set E}
variable {L L₁ L₂ : Filter E}
section DerivativeUniqueness
/- In this section, we discuss the uniqueness of the derivative.
We prove that the definitions `UniqueDiffWithinAt` and `UniqueDiffOn` indeed imply the
uniqueness of the derivative. -/
/-- If a function f has a derivative f' at x, a rescaled version of f around x converges to f',
i.e., `n (f (x + (1/n) v) - f x)` converges to `f' v`. More generally, if `c n` tends to infinity
and `c n * d n` tends to `v`, then `c n * (f (x + d n) - f x)` tends to `f' v`. This lemma expresses
this fact, for functions having a derivative within a set. Its specific formulation is useful for
tangent cone related discussions. -/
theorem HasFDerivWithinAt.lim (h : HasFDerivWithinAt f f' s x) {α : Type*} (l : Filter α)
{c : α → 𝕜} {d : α → E} {v : E} (dtop : ∀ᶠ n in l, x + d n ∈ s)
(clim : Tendsto (fun n => ‖c n‖) l atTop) (cdlim : Tendsto (fun n => c n • d n) l (𝓝 v)) :
Tendsto (fun n => c n • (f (x + d n) - f x)) l (𝓝 (f' v)) := by
have tendsto_arg : Tendsto (fun n => x + d n) l (𝓝[s] x) := by
conv in 𝓝[s] x => rw [← add_zero x]
rw [nhdsWithin, tendsto_inf]
constructor
· apply tendsto_const_nhds.add (tangentConeAt.lim_zero l clim cdlim)
· rwa [tendsto_principal]
have : (fun y => f y - f x - f' (y - x)) =o[𝓝[s] x] fun y => y - x := h.isLittleO
have : (fun n => f (x + d n) - f x - f' (x + d n - x)) =o[l] fun n => x + d n - x :=
this.comp_tendsto tendsto_arg
have : (fun n => f (x + d n) - f x - f' (d n)) =o[l] d := by simpa only [add_sub_cancel_left]
have : (fun n => c n • (f (x + d n) - f x - f' (d n))) =o[l] fun n => c n • d n :=
(isBigO_refl c l).smul_isLittleO this
have : (fun n => c n • (f (x + d n) - f x - f' (d n))) =o[l] fun _ => (1 : ℝ) :=
this.trans_isBigO (cdlim.isBigO_one ℝ)
have L1 : Tendsto (fun n => c n • (f (x + d n) - f x - f' (d n))) l (𝓝 0) :=
(isLittleO_one_iff ℝ).1 this
have L2 : Tendsto (fun n => f' (c n • d n)) l (𝓝 (f' v)) :=
Tendsto.comp f'.cont.continuousAt cdlim
have L3 :
Tendsto (fun n => c n • (f (x + d n) - f x - f' (d n)) + f' (c n • d n)) l (𝓝 (0 + f' v)) :=
L1.add L2
have :
(fun n => c n • (f (x + d n) - f x - f' (d n)) + f' (c n • d n)) = fun n =>
c n • (f (x + d n) - f x) := by
ext n
simp [smul_sub]
rwa [this, zero_add] at L3
/-- If `f'` and `f₁'` are two derivatives of `f` within `s` at `x`, then they are equal on the
tangent cone to `s` at `x` -/
theorem HasFDerivWithinAt.unique_on (hf : HasFDerivWithinAt f f' s x)
(hg : HasFDerivWithinAt f f₁' s x) : EqOn f' f₁' (tangentConeAt 𝕜 s x) :=
fun _ ⟨_, _, dtop, clim, cdlim⟩ =>
tendsto_nhds_unique (hf.lim atTop dtop clim cdlim) (hg.lim atTop dtop clim cdlim)
/-- `UniqueDiffWithinAt` achieves its goal: it implies the uniqueness of the derivative. -/
theorem UniqueDiffWithinAt.eq (H : UniqueDiffWithinAt 𝕜 s x) (hf : HasFDerivWithinAt f f' s x)
(hg : HasFDerivWithinAt f f₁' s x) : f' = f₁' :=
ContinuousLinearMap.ext_on H.1 (hf.unique_on hg)
theorem UniqueDiffOn.eq (H : UniqueDiffOn 𝕜 s) (hx : x ∈ s) (h : HasFDerivWithinAt f f' s x)
(h₁ : HasFDerivWithinAt f f₁' s x) : f' = f₁' :=
(H x hx).eq h h₁
end DerivativeUniqueness
section FDerivProperties
/-! ### Basic properties of the derivative -/
theorem hasFDerivAtFilter_iff_tendsto :
HasFDerivAtFilter f f' x L ↔
Tendsto (fun x' => ‖x' - x‖⁻¹ * ‖f x' - f x - f' (x' - x)‖) L (𝓝 0) := by
have h : ∀ x', ‖x' - x‖ = 0 → ‖f x' - f x - f' (x' - x)‖ = 0 := fun x' hx' => by
rw [sub_eq_zero.1 (norm_eq_zero.1 hx')]
simp
rw [hasFDerivAtFilter_iff_isLittleO, ← isLittleO_norm_left, ← isLittleO_norm_right,
isLittleO_iff_tendsto h]
exact tendsto_congr fun _ => div_eq_inv_mul _ _
theorem hasFDerivWithinAt_iff_tendsto :
HasFDerivWithinAt f f' s x ↔
Tendsto (fun x' => ‖x' - x‖⁻¹ * ‖f x' - f x - f' (x' - x)‖) (𝓝[s] x) (𝓝 0) :=
hasFDerivAtFilter_iff_tendsto
theorem hasFDerivAt_iff_tendsto :
HasFDerivAt f f' x ↔ Tendsto (fun x' => ‖x' - x‖⁻¹ * ‖f x' - f x - f' (x' - x)‖) (𝓝 x) (𝓝 0) :=
hasFDerivAtFilter_iff_tendsto
theorem hasFDerivAt_iff_isLittleO_nhds_zero :
HasFDerivAt f f' x ↔ (fun h : E => f (x + h) - f x - f' h) =o[𝓝 0] fun h => h := by
rw [HasFDerivAt, hasFDerivAtFilter_iff_isLittleO, ← map_add_left_nhds_zero x, isLittleO_map]
simp [Function.comp_def]
nonrec theorem HasFDerivAtFilter.mono (h : HasFDerivAtFilter f f' x L₂) (hst : L₁ ≤ L₂) :
HasFDerivAtFilter f f' x L₁ :=
.of_isLittleOTVS <| h.isLittleOTVS.mono hst
theorem HasFDerivWithinAt.mono_of_mem_nhdsWithin
(h : HasFDerivWithinAt f f' t x) (hst : t ∈ 𝓝[s] x) :
HasFDerivWithinAt f f' s x :=
h.mono <| nhdsWithin_le_iff.mpr hst
nonrec theorem HasFDerivWithinAt.mono (h : HasFDerivWithinAt f f' t x) (hst : s ⊆ t) :
HasFDerivWithinAt f f' s x :=
h.mono <| nhdsWithin_mono _ hst
theorem HasFDerivAt.hasFDerivAtFilter (h : HasFDerivAt f f' x) (hL : L ≤ 𝓝 x) :
HasFDerivAtFilter f f' x L :=
h.mono hL
@[fun_prop]
theorem HasFDerivAt.hasFDerivWithinAt (h : HasFDerivAt f f' x) : HasFDerivWithinAt f f' s x :=
h.hasFDerivAtFilter inf_le_left
@[fun_prop]
theorem HasFDerivWithinAt.differentiableWithinAt (h : HasFDerivWithinAt f f' s x) :
DifferentiableWithinAt 𝕜 f s x :=
⟨f', h⟩
@[fun_prop]
theorem HasFDerivAt.differentiableAt (h : HasFDerivAt f f' x) : DifferentiableAt 𝕜 f x :=
⟨f', h⟩
@[simp]
theorem hasFDerivWithinAt_univ : HasFDerivWithinAt f f' univ x ↔ HasFDerivAt f f' x := by
simp only [HasFDerivWithinAt, nhdsWithin_univ, HasFDerivAt]
alias ⟨HasFDerivWithinAt.hasFDerivAt_of_univ, _⟩ := hasFDerivWithinAt_univ
theorem differentiableWithinAt_univ :
DifferentiableWithinAt 𝕜 f univ x ↔ DifferentiableAt 𝕜 f x := by
simp only [DifferentiableWithinAt, hasFDerivWithinAt_univ, DifferentiableAt]
theorem fderiv_zero_of_not_differentiableAt (h : ¬DifferentiableAt 𝕜 f x) : fderiv 𝕜 f x = 0 := by
rw [fderiv, fderivWithin_zero_of_not_differentiableWithinAt]
rwa [differentiableWithinAt_univ]
theorem hasFDerivWithinAt_of_mem_nhds (h : s ∈ 𝓝 x) :
HasFDerivWithinAt f f' s x ↔ HasFDerivAt f f' x := by
rw [HasFDerivAt, HasFDerivWithinAt, nhdsWithin_eq_nhds.mpr h]
lemma hasFDerivWithinAt_of_isOpen (h : IsOpen s) (hx : x ∈ s) :
HasFDerivWithinAt f f' s x ↔ HasFDerivAt f f' x :=
hasFDerivWithinAt_of_mem_nhds (h.mem_nhds hx)
@[simp]
theorem hasFDerivWithinAt_insert {y : E} :
HasFDerivWithinAt f f' (insert y s) x ↔ HasFDerivWithinAt f f' s x := by
rcases eq_or_ne x y with (rfl | h)
· simp_rw [HasFDerivWithinAt, hasFDerivAtFilter_iff_isLittleOTVS]
apply isLittleOTVS_insert
simp only [sub_self, map_zero]
refine ⟨fun h => h.mono <| subset_insert y s, fun hf => hf.mono_of_mem_nhdsWithin ?_⟩
simp_rw [nhdsWithin_insert_of_ne h, self_mem_nhdsWithin]
alias ⟨HasFDerivWithinAt.of_insert, HasFDerivWithinAt.insert'⟩ := hasFDerivWithinAt_insert
protected theorem HasFDerivWithinAt.insert (h : HasFDerivWithinAt g g' s x) :
HasFDerivWithinAt g g' (insert x s) x :=
h.insert'
@[simp]
theorem hasFDerivWithinAt_diff_singleton (y : E) :
HasFDerivWithinAt f f' (s \ {y}) x ↔ HasFDerivWithinAt f f' s x := by
rw [← hasFDerivWithinAt_insert, insert_diff_singleton, hasFDerivWithinAt_insert]
@[simp]
protected theorem HasFDerivWithinAt.empty : HasFDerivWithinAt f f' ∅ x := by
simp [HasFDerivWithinAt, hasFDerivAtFilter_iff_isLittleOTVS]
@[simp]
protected theorem DifferentiableWithinAt.empty : DifferentiableWithinAt 𝕜 f ∅ x :=
⟨0, .empty⟩
theorem HasFDerivWithinAt.of_finite (h : s.Finite) : HasFDerivWithinAt f f' s x := by
induction s, h using Set.Finite.induction_on with
| empty => exact .empty
| insert _ _ ih => exact ih.insert'
theorem DifferentiableWithinAt.of_finite (h : s.Finite) : DifferentiableWithinAt 𝕜 f s x :=
⟨0, .of_finite h⟩
@[simp]
protected theorem HasFDerivWithinAt.singleton {y} : HasFDerivWithinAt f f' {x} y :=
.of_finite <| finite_singleton _
@[simp]
protected theorem DifferentiableWithinAt.singleton {y} : DifferentiableWithinAt 𝕜 f {x} y :=
⟨0, .singleton⟩
theorem HasFDerivWithinAt.of_subsingleton (h : s.Subsingleton) : HasFDerivWithinAt f f' s x :=
.of_finite h.finite
theorem DifferentiableWithinAt.of_subsingleton (h : s.Subsingleton) :
DifferentiableWithinAt 𝕜 f s x :=
.of_finite h.finite
theorem HasStrictFDerivAt.isBigO_sub (hf : HasStrictFDerivAt f f' x) :
(fun p : E × E => f p.1 - f p.2) =O[𝓝 (x, x)] fun p : E × E => p.1 - p.2 :=
hf.isLittleO.isBigO.congr_of_sub.2 (f'.isBigO_comp _ _)
theorem HasFDerivAtFilter.isBigO_sub (h : HasFDerivAtFilter f f' x L) :
(fun x' => f x' - f x) =O[L] fun x' => x' - x :=
h.isLittleO.isBigO.congr_of_sub.2 (f'.isBigO_sub _ _)
@[fun_prop]
protected theorem HasStrictFDerivAt.hasFDerivAt (hf : HasStrictFDerivAt f f' x) :
HasFDerivAt f f' x :=
.of_isLittleOTVS <| by
simpa only using hf.isLittleOTVS.comp_tendsto (tendsto_id.prodMk_nhds tendsto_const_nhds)
protected theorem HasStrictFDerivAt.differentiableAt (hf : HasStrictFDerivAt f f' x) :
DifferentiableAt 𝕜 f x :=
hf.hasFDerivAt.differentiableAt
/-- If `f` is strictly differentiable at `x` with derivative `f'` and `K > ‖f'‖₊`, then `f` is
`K`-Lipschitz in a neighborhood of `x`. -/
theorem HasStrictFDerivAt.exists_lipschitzOnWith_of_nnnorm_lt (hf : HasStrictFDerivAt f f' x)
(K : ℝ≥0) (hK : ‖f'‖₊ < K) : ∃ s ∈ 𝓝 x, LipschitzOnWith K f s := by
have := hf.isLittleO.add_isBigOWith (f'.isBigOWith_comp _ _) hK
simp only [sub_add_cancel, IsBigOWith] at this
rcases exists_nhds_square this with ⟨U, Uo, xU, hU⟩
exact
⟨U, Uo.mem_nhds xU, lipschitzOnWith_iff_norm_sub_le.2 fun x hx y hy => hU (mk_mem_prod hx hy)⟩
/-- If `f` is strictly differentiable at `x` with derivative `f'`, then `f` is Lipschitz in a
neighborhood of `x`. See also `HasStrictFDerivAt.exists_lipschitzOnWith_of_nnnorm_lt` for a
more precise statement. -/
theorem HasStrictFDerivAt.exists_lipschitzOnWith (hf : HasStrictFDerivAt f f' x) :
∃ K, ∃ s ∈ 𝓝 x, LipschitzOnWith K f s :=
(exists_gt _).imp hf.exists_lipschitzOnWith_of_nnnorm_lt
/-- Directional derivative agrees with `HasFDeriv`. -/
theorem HasFDerivAt.lim (hf : HasFDerivAt f f' x) (v : E) {α : Type*} {c : α → 𝕜} {l : Filter α}
(hc : Tendsto (fun n => ‖c n‖) l atTop) :
Tendsto (fun n => c n • (f (x + (c n)⁻¹ • v) - f x)) l (𝓝 (f' v)) := by
refine (hasFDerivWithinAt_univ.2 hf).lim _ univ_mem hc ?_
intro U hU
refine (eventually_ne_of_tendsto_norm_atTop hc (0 : 𝕜)).mono fun y hy => ?_
convert mem_of_mem_nhds hU
dsimp only
rw [← mul_smul, mul_inv_cancel₀ hy, one_smul]
theorem HasFDerivAt.unique (h₀ : HasFDerivAt f f₀' x) (h₁ : HasFDerivAt f f₁' x) : f₀' = f₁' := by
rw [← hasFDerivWithinAt_univ] at h₀ h₁
exact uniqueDiffWithinAt_univ.eq h₀ h₁
theorem hasFDerivWithinAt_inter' (h : t ∈ 𝓝[s] x) :
HasFDerivWithinAt f f' (s ∩ t) x ↔ HasFDerivWithinAt f f' s x := by
simp [HasFDerivWithinAt, nhdsWithin_restrict'' s h]
theorem hasFDerivWithinAt_inter (h : t ∈ 𝓝 x) :
HasFDerivWithinAt f f' (s ∩ t) x ↔ HasFDerivWithinAt f f' s x := by
simp [HasFDerivWithinAt, nhdsWithin_restrict' s h]
theorem HasFDerivWithinAt.union (hs : HasFDerivWithinAt f f' s x)
(ht : HasFDerivWithinAt f f' t x) : HasFDerivWithinAt f f' (s ∪ t) x := by
simp only [HasFDerivWithinAt, nhdsWithin_union]
exact .of_isLittleOTVS <| hs.isLittleOTVS.sup ht.isLittleOTVS
theorem HasFDerivWithinAt.hasFDerivAt (h : HasFDerivWithinAt f f' s x) (hs : s ∈ 𝓝 x) :
HasFDerivAt f f' x := by
rwa [← univ_inter s, hasFDerivWithinAt_inter hs, hasFDerivWithinAt_univ] at h
theorem DifferentiableWithinAt.differentiableAt (h : DifferentiableWithinAt 𝕜 f s x)
(hs : s ∈ 𝓝 x) : DifferentiableAt 𝕜 f x :=
h.imp fun _ hf' => hf'.hasFDerivAt hs
/-- If `x` is isolated in `s`, then `f` has any derivative at `x` within `s`,
as this statement is empty. -/
theorem HasFDerivWithinAt.of_not_accPt (h : ¬AccPt x (𝓟 s)) : HasFDerivWithinAt f f' s x := by
rw [accPt_principal_iff_nhdsWithin, not_neBot] at h
rw [← hasFDerivWithinAt_diff_singleton x, HasFDerivWithinAt, h,
hasFDerivAtFilter_iff_isLittleOTVS]
exact .bot
/-- If `x` is not in the closure of `s`, then `f` has any derivative at `x` within `s`,
as this statement is empty. -/
theorem HasFDerivWithinAt.of_notMem_closure (h : x ∉ closure s) : HasFDerivWithinAt f f' s x :=
.of_not_accPt (h ·.clusterPt.mem_closure)
@[deprecated (since := "2025-05-23")]
alias HasFDerivWithinAt.of_not_mem_closure := HasFDerivWithinAt.of_notMem_closure
theorem fderivWithin_zero_of_not_accPt (h : ¬AccPt x (𝓟 s)) : fderivWithin 𝕜 f s x = 0 := by
rw [fderivWithin, if_pos (.of_not_accPt h)]
theorem fderivWithin_zero_of_notMem_closure (h : x ∉ closure s) : fderivWithin 𝕜 f s x = 0 :=
fderivWithin_zero_of_not_accPt (h ·.clusterPt.mem_closure)
@[deprecated (since := "2025-05-24")]
alias fderivWithin_zero_of_nmem_closure := fderivWithin_zero_of_notMem_closure
theorem DifferentiableWithinAt.hasFDerivWithinAt (h : DifferentiableWithinAt 𝕜 f s x) :
HasFDerivWithinAt f (fderivWithin 𝕜 f s x) s x := by
simp only [fderivWithin, dif_pos h]
split_ifs with h₀
exacts [h₀, Classical.choose_spec h]
theorem DifferentiableAt.hasFDerivAt (h : DifferentiableAt 𝕜 f x) :
HasFDerivAt f (fderiv 𝕜 f x) x := by
rw [fderiv, ← hasFDerivWithinAt_univ]
rw [← differentiableWithinAt_univ] at h
exact h.hasFDerivWithinAt
theorem DifferentiableOn.hasFDerivAt (h : DifferentiableOn 𝕜 f s) (hs : s ∈ 𝓝 x) :
HasFDerivAt f (fderiv 𝕜 f x) x :=
((h x (mem_of_mem_nhds hs)).differentiableAt hs).hasFDerivAt
theorem DifferentiableOn.differentiableAt (h : DifferentiableOn 𝕜 f s) (hs : s ∈ 𝓝 x) :
DifferentiableAt 𝕜 f x :=
(h.hasFDerivAt hs).differentiableAt
theorem DifferentiableOn.eventually_differentiableAt (h : DifferentiableOn 𝕜 f s) (hs : s ∈ 𝓝 x) :
∀ᶠ y in 𝓝 x, DifferentiableAt 𝕜 f y :=
(eventually_eventually_nhds.2 hs).mono fun _ => h.differentiableAt
protected theorem HasFDerivAt.fderiv (h : HasFDerivAt f f' x) : fderiv 𝕜 f x = f' := by
ext
rw [h.unique h.differentiableAt.hasFDerivAt]
theorem fderiv_eq {f' : E → E →L[𝕜] F} (h : ∀ x, HasFDerivAt f (f' x) x) : fderiv 𝕜 f = f' :=
funext fun x => (h x).fderiv
protected theorem HasFDerivWithinAt.fderivWithin (h : HasFDerivWithinAt f f' s x)
(hxs : UniqueDiffWithinAt 𝕜 s x) : fderivWithin 𝕜 f s x = f' :=
(hxs.eq h h.differentiableWithinAt.hasFDerivWithinAt).symm
theorem DifferentiableWithinAt.mono (h : DifferentiableWithinAt 𝕜 f t x) (st : s ⊆ t) :
DifferentiableWithinAt 𝕜 f s x := by
rcases h with ⟨f', hf'⟩
exact ⟨f', hf'.mono st⟩
theorem DifferentiableWithinAt.mono_of_mem_nhdsWithin
(h : DifferentiableWithinAt 𝕜 f s x) {t : Set E} (hst : s ∈ 𝓝[t] x) :
DifferentiableWithinAt 𝕜 f t x :=
(h.hasFDerivWithinAt.mono_of_mem_nhdsWithin hst).differentiableWithinAt
theorem DifferentiableWithinAt.congr_nhds (h : DifferentiableWithinAt 𝕜 f s x) {t : Set E}
(hst : 𝓝[s] x = 𝓝[t] x) : DifferentiableWithinAt 𝕜 f t x :=
h.mono_of_mem_nhdsWithin <| hst ▸ self_mem_nhdsWithin
theorem differentiableWithinAt_congr_nhds {t : Set E} (hst : 𝓝[s] x = 𝓝[t] x) :
DifferentiableWithinAt 𝕜 f s x ↔ DifferentiableWithinAt 𝕜 f t x :=
⟨fun h => h.congr_nhds hst, fun h => h.congr_nhds hst.symm⟩
theorem differentiableWithinAt_inter (ht : t ∈ 𝓝 x) :
DifferentiableWithinAt 𝕜 f (s ∩ t) x ↔ DifferentiableWithinAt 𝕜 f s x := by
simp only [DifferentiableWithinAt, hasFDerivWithinAt_inter ht]
theorem differentiableWithinAt_inter' (ht : t ∈ 𝓝[s] x) :
DifferentiableWithinAt 𝕜 f (s ∩ t) x ↔ DifferentiableWithinAt 𝕜 f s x := by
simp only [DifferentiableWithinAt, hasFDerivWithinAt_inter' ht]
theorem differentiableWithinAt_insert_self :
DifferentiableWithinAt 𝕜 f (insert x s) x ↔ DifferentiableWithinAt 𝕜 f s x :=
⟨fun h ↦ h.mono (subset_insert x s), fun h ↦ h.hasFDerivWithinAt.insert.differentiableWithinAt⟩
theorem differentiableWithinAt_insert {y : E} :
DifferentiableWithinAt 𝕜 f (insert y s) x ↔ DifferentiableWithinAt 𝕜 f s x := by
rcases eq_or_ne x y with (rfl | h)
· exact differentiableWithinAt_insert_self
apply differentiableWithinAt_congr_nhds
exact nhdsWithin_insert_of_ne h
alias ⟨DifferentiableWithinAt.of_insert, DifferentiableWithinAt.insert'⟩ :=
differentiableWithinAt_insert
protected theorem DifferentiableWithinAt.insert (h : DifferentiableWithinAt 𝕜 f s x) :
DifferentiableWithinAt 𝕜 f (insert x s) x :=
h.insert'
theorem DifferentiableAt.differentiableWithinAt (h : DifferentiableAt 𝕜 f x) :
DifferentiableWithinAt 𝕜 f s x :=
(differentiableWithinAt_univ.2 h).mono (subset_univ _)
@[fun_prop]
theorem Differentiable.differentiableAt (h : Differentiable 𝕜 f) : DifferentiableAt 𝕜 f x :=
h x
protected theorem DifferentiableAt.fderivWithin (h : DifferentiableAt 𝕜 f x)
(hxs : UniqueDiffWithinAt 𝕜 s x) : fderivWithin 𝕜 f s x = fderiv 𝕜 f x :=
h.hasFDerivAt.hasFDerivWithinAt.fderivWithin hxs
theorem DifferentiableOn.mono (h : DifferentiableOn 𝕜 f t) (st : s ⊆ t) : DifferentiableOn 𝕜 f s :=
fun x hx => (h x (st hx)).mono st
theorem differentiableOn_univ : DifferentiableOn 𝕜 f univ ↔ Differentiable 𝕜 f := by
simp only [DifferentiableOn, Differentiable, differentiableWithinAt_univ, mem_univ,
forall_true_left]
@[fun_prop]
theorem Differentiable.differentiableOn (h : Differentiable 𝕜 f) : DifferentiableOn 𝕜 f s :=
(differentiableOn_univ.2 h).mono (subset_univ _)
theorem differentiableOn_of_locally_differentiableOn
(h : ∀ x ∈ s, ∃ u, IsOpen u ∧ x ∈ u ∧ DifferentiableOn 𝕜 f (s ∩ u)) :
DifferentiableOn 𝕜 f s := by
intro x xs
rcases h x xs with ⟨t, t_open, xt, ht⟩
exact (differentiableWithinAt_inter (IsOpen.mem_nhds t_open xt)).1 (ht x ⟨xs, xt⟩)
theorem fderivWithin_of_mem_nhdsWithin (st : t ∈ 𝓝[s] x) (ht : UniqueDiffWithinAt 𝕜 s x)
(h : DifferentiableWithinAt 𝕜 f t x) : fderivWithin 𝕜 f s x = fderivWithin 𝕜 f t x :=
((DifferentiableWithinAt.hasFDerivWithinAt h).mono_of_mem_nhdsWithin st).fderivWithin ht
theorem fderivWithin_subset (st : s ⊆ t) (ht : UniqueDiffWithinAt 𝕜 s x)
(h : DifferentiableWithinAt 𝕜 f t x) : fderivWithin 𝕜 f s x = fderivWithin 𝕜 f t x :=
fderivWithin_of_mem_nhdsWithin (nhdsWithin_mono _ st self_mem_nhdsWithin) ht h
theorem fderivWithin_inter (ht : t ∈ 𝓝 x) : fderivWithin 𝕜 f (s ∩ t) x = fderivWithin 𝕜 f s x := by
classical
simp [fderivWithin, hasFDerivWithinAt_inter ht, DifferentiableWithinAt]
theorem fderivWithin_of_mem_nhds (h : s ∈ 𝓝 x) : fderivWithin 𝕜 f s x = fderiv 𝕜 f x := by
rw [← fderivWithin_univ, ← univ_inter s, fderivWithin_inter h]
theorem fderivWithin_of_isOpen (hs : IsOpen s) (hx : x ∈ s) : fderivWithin 𝕜 f s x = fderiv 𝕜 f x :=
fderivWithin_of_mem_nhds (hs.mem_nhds hx)
theorem fderivWithin_eq_fderiv (hs : UniqueDiffWithinAt 𝕜 s x) (h : DifferentiableAt 𝕜 f x) :
fderivWithin 𝕜 f s x = fderiv 𝕜 f x := by
rw [← fderivWithin_univ]
exact fderivWithin_subset (subset_univ _) hs h.differentiableWithinAt
theorem fderiv_mem_iff {f : E → F} {s : Set (E →L[𝕜] F)} {x : E} : fderiv 𝕜 f x ∈ s ↔
DifferentiableAt 𝕜 f x ∧ fderiv 𝕜 f x ∈ s ∨ ¬DifferentiableAt 𝕜 f x ∧ (0 : E →L[𝕜] F) ∈ s := by
by_cases hx : DifferentiableAt 𝕜 f x <;> simp [fderiv_zero_of_not_differentiableAt, *]
theorem fderivWithin_mem_iff {f : E → F} {t : Set E} {s : Set (E →L[𝕜] F)} {x : E} :
fderivWithin 𝕜 f t x ∈ s ↔
DifferentiableWithinAt 𝕜 f t x ∧ fderivWithin 𝕜 f t x ∈ s ∨
¬DifferentiableWithinAt 𝕜 f t x ∧ (0 : E →L[𝕜] F) ∈ s := by
by_cases hx : DifferentiableWithinAt 𝕜 f t x <;>
simp [fderivWithin_zero_of_not_differentiableWithinAt, *]
theorem Asymptotics.IsBigO.hasFDerivWithinAt {s : Set E} {x₀ : E} {n : ℕ}
(h : f =O[𝓝[s] x₀] fun x => ‖x - x₀‖ ^ n) (hx₀ : x₀ ∈ s) (hn : 1 < n) :
HasFDerivWithinAt f (0 : E →L[𝕜] F) s x₀ := by
simp_rw [HasFDerivWithinAt, hasFDerivAtFilter_iff_isLittleO,
h.eq_zero_of_norm_pow_within hx₀ hn.ne_bot, zero_apply, sub_zero,
h.trans_isLittleO ((isLittleO_pow_sub_sub x₀ hn).mono nhdsWithin_le_nhds)]
theorem Asymptotics.IsBigO.hasFDerivAt {x₀ : E} {n : ℕ} (h : f =O[𝓝 x₀] fun x => ‖x - x₀‖ ^ n)
(hn : 1 < n) : HasFDerivAt f (0 : E →L[𝕜] F) x₀ := by
rw [← nhdsWithin_univ] at h
exact (h.hasFDerivWithinAt (mem_univ _) hn).hasFDerivAt_of_univ
nonrec theorem HasFDerivWithinAt.isBigO_sub {f : E → F} {s : Set E} {x₀ : E} {f' : E →L[𝕜] F}
(h : HasFDerivWithinAt f f' s x₀) : (f · - f x₀) =O[𝓝[s] x₀] (· - x₀) :=
h.isBigO_sub
lemma DifferentiableWithinAt.isBigO_sub {f : E → F} {s : Set E} {x₀ : E}
(h : DifferentiableWithinAt 𝕜 f s x₀) : (f · - f x₀) =O[𝓝[s] x₀] (· - x₀) :=
h.hasFDerivWithinAt.isBigO_sub
nonrec theorem HasFDerivAt.isBigO_sub {f : E → F} {x₀ : E} {f' : E →L[𝕜] F}
(h : HasFDerivAt f f' x₀) : (f · - f x₀) =O[𝓝 x₀] (· - x₀) :=
h.isBigO_sub
nonrec theorem DifferentiableAt.isBigO_sub {f : E → F} {x₀ : E} (h : DifferentiableAt 𝕜 f x₀) :
(f · - f x₀) =O[𝓝 x₀] (· - x₀) :=
h.hasFDerivAt.isBigO_sub
end FDerivProperties
/-! ### Being differentiable on a union of open sets can be tested on each set -/
section differentiableOn_union
/-- If a function is differentiable on two open sets, it is also differentiable on their union. -/
lemma DifferentiableOn.union_of_isOpen
(hf : DifferentiableOn 𝕜 f s) (hf' : DifferentiableOn 𝕜 f t)
(hs : IsOpen s) (ht : IsOpen t) :
DifferentiableOn 𝕜 f (s ∪ t) := by
intro x hx
obtain (hx | hx) := hx
· exact (hf x hx).differentiableAt (hs.mem_nhds hx) |>.differentiableWithinAt
· exact (hf' x hx).differentiableAt (ht.mem_nhds hx) |>.differentiableWithinAt
/-- A function is differentiable on two open sets iff it is differentiable on their union. -/
lemma differentiableOn_union_iff_of_isOpen (hs : IsOpen s) (ht : IsOpen t) :
DifferentiableOn 𝕜 f (s ∪ t) ↔ DifferentiableOn 𝕜 f s ∧ DifferentiableOn 𝕜 f t :=
⟨fun h ↦ ⟨h.mono subset_union_left, h.mono subset_union_right⟩,
fun ⟨hfs, hft⟩ ↦ DifferentiableOn.union_of_isOpen hfs hft hs ht⟩
lemma differentiable_of_differentiableOn_union_of_isOpen (hf : DifferentiableOn 𝕜 f s)
(hf' : DifferentiableOn 𝕜 f t) (hst : s ∪ t = univ) (hs : IsOpen s) (ht : IsOpen t) :
Differentiable 𝕜 f := by
rw [← differentiableOn_univ, ← hst]
exact hf.union_of_isOpen hf' hs ht
/-- If a function is differentiable on open sets `s i`, it is differentiable on their union. -/
lemma DifferentiableOn.iUnion_of_isOpen {ι : Type*} {s : ι → Set E}
(hf : ∀ i : ι, DifferentiableOn 𝕜 f (s i)) (hs : ∀ i, IsOpen (s i)) :
DifferentiableOn 𝕜 f (⋃ i, s i) := by
rintro x ⟨si, ⟨i, rfl⟩, hxsi⟩
exact (hf i).differentiableAt ((hs i).mem_nhds hxsi) |>.differentiableWithinAt
/-- A function is differentiable on a union of open sets `s i`
iff it is differentiable on each `s i`. -/
lemma differentiableOn_iUnion_iff_of_isOpen {ι : Type*} {s : ι → Set E}
(hs : ∀ i, IsOpen (s i)) :
DifferentiableOn 𝕜 f (⋃ i, s i) ↔ ∀ i : ι, DifferentiableOn 𝕜 f (s i) :=
⟨fun h i ↦ h.mono <| subset_iUnion_of_subset i fun _ a ↦ a,
fun h ↦ DifferentiableOn.iUnion_of_isOpen h hs⟩
lemma differentiable_of_differentiableOn_iUnion_of_isOpen {ι : Type*} {s : ι → Set E}
(hf : ∀ i : ι, DifferentiableOn 𝕜 f (s i))
(hs : ∀ i, IsOpen (s i)) (hs' : ⋃ i, s i = univ) :
Differentiable 𝕜 f := by
rw [← differentiableOn_univ, ← hs']
exact DifferentiableOn.iUnion_of_isOpen hf hs
end differentiableOn_union
section Continuous
/-! ### Deducing continuity from differentiability -/
theorem HasFDerivAtFilter.tendsto_nhds (hL : L ≤ 𝓝 x) (h : HasFDerivAtFilter f f' x L) :
Tendsto f L (𝓝 (f x)) := by
have : Tendsto (fun x' => f x' - f x) L (𝓝 0) := by
refine h.isBigO_sub.trans_tendsto (Tendsto.mono_left ?_ hL)
rw [← sub_self x]
exact tendsto_id.sub tendsto_const_nhds
have := this.add (tendsto_const_nhds (x := f x))
rw [zero_add (f x)] at this
exact this.congr (by simp only [sub_add_cancel, forall_const])
theorem HasFDerivWithinAt.continuousWithinAt (h : HasFDerivWithinAt f f' s x) :
ContinuousWithinAt f s x :=
HasFDerivAtFilter.tendsto_nhds inf_le_left h
theorem HasFDerivAt.continuousAt (h : HasFDerivAt f f' x) : ContinuousAt f x :=
HasFDerivAtFilter.tendsto_nhds le_rfl h
@[fun_prop]
theorem DifferentiableWithinAt.continuousWithinAt (h : DifferentiableWithinAt 𝕜 f s x) :
ContinuousWithinAt f s x :=
let ⟨_, hf'⟩ := h
hf'.continuousWithinAt
@[fun_prop]
theorem DifferentiableAt.continuousAt (h : DifferentiableAt 𝕜 f x) : ContinuousAt f x :=
let ⟨_, hf'⟩ := h
hf'.continuousAt
@[fun_prop]
theorem DifferentiableOn.continuousOn (h : DifferentiableOn 𝕜 f s) : ContinuousOn f s := fun x hx =>
(h x hx).continuousWithinAt
@[fun_prop]
theorem Differentiable.continuous (h : Differentiable 𝕜 f) : Continuous f :=
continuous_iff_continuousAt.2 fun x => (h x).continuousAt
protected theorem HasStrictFDerivAt.continuousAt (hf : HasStrictFDerivAt f f' x) :
ContinuousAt f x :=
hf.hasFDerivAt.continuousAt
theorem HasStrictFDerivAt.isBigO_sub_rev {f' : E ≃L[𝕜] F}
(hf : HasStrictFDerivAt f (f' : E →L[𝕜] F) x) :
(fun p : E × E => p.1 - p.2) =O[𝓝 (x, x)] fun p : E × E => f p.1 - f p.2 :=
((f'.isBigO_comp_rev _ _).trans
(hf.isLittleO.trans_isBigO (f'.isBigO_comp_rev _ _)).right_isBigO_add).congr
(fun _ => rfl) fun _ => sub_add_cancel _ _
theorem HasFDerivAtFilter.isBigO_sub_rev (hf : HasFDerivAtFilter f f' x L) {C}
(hf' : AntilipschitzWith C f') : (fun x' => x' - x) =O[L] fun x' => f x' - f x :=
have : (fun x' => x' - x) =O[L] fun x' => f' (x' - x) :=
isBigO_iff.2 ⟨C, Eventually.of_forall fun _ => ZeroHomClass.bound_of_antilipschitz f' hf' _⟩
(this.trans (hf.isLittleO.trans_isBigO this).right_isBigO_add).congr (fun _ => rfl) fun _ =>
sub_add_cancel _ _
end Continuous
section id
/-! ### Derivative of the identity -/
@[fun_prop]
theorem hasStrictFDerivAt_id (x : E) : HasStrictFDerivAt id (.id 𝕜 E) x :=
.of_isLittleOTVS <| (IsLittleOTVS.zero _ _).congr_left <| by simp
theorem hasFDerivAtFilter_id (x : E) (L : Filter E) : HasFDerivAtFilter id (.id 𝕜 E) x L :=
.of_isLittleOTVS <| (IsLittleOTVS.zero _ _).congr_left <| by simp
@[fun_prop]
theorem hasFDerivWithinAt_id (x : E) (s : Set E) : HasFDerivWithinAt id (.id 𝕜 E) s x :=
hasFDerivAtFilter_id _ _
@[fun_prop]
theorem hasFDerivAt_id (x : E) : HasFDerivAt id (.id 𝕜 E) x :=
hasFDerivAtFilter_id _ _
@[simp, fun_prop]
theorem differentiableAt_id : DifferentiableAt 𝕜 id x :=
(hasFDerivAt_id x).differentiableAt
/-- Variant with `fun x => x` rather than `id` -/
@[simp, fun_prop]
theorem differentiableAt_fun_id : DifferentiableAt 𝕜 (fun x => x) x :=
(hasFDerivAt_id x).differentiableAt
@[deprecated (since := "2025-06-25")] alias differentiableAt_id' := differentiableAt_fun_id
@[fun_prop]
theorem differentiableWithinAt_id : DifferentiableWithinAt 𝕜 id s x :=
differentiableAt_id.differentiableWithinAt
/-- Variant with `fun x => x` rather than `id` -/
@[fun_prop]
theorem differentiableWithinAt_id' : DifferentiableWithinAt 𝕜 (fun x => x) s x :=
differentiableWithinAt_id
@[simp, fun_prop]
theorem differentiable_id : Differentiable 𝕜 (id : E → E) := fun _ => differentiableAt_id
/-- Variant with `fun x => x` rather than `id` -/
@[simp, fun_prop]
theorem differentiable_fun_id : Differentiable 𝕜 fun x : E => x := fun _ => differentiableAt_id
@[deprecated (since := "2025-06-25")] alias differentiable_id' := differentiable_fun_id
@[fun_prop]
theorem differentiableOn_id : DifferentiableOn 𝕜 id s :=
differentiable_id.differentiableOn
@[simp]
theorem fderiv_id : fderiv 𝕜 id x = .id 𝕜 E :=
HasFDerivAt.fderiv (hasFDerivAt_id x)
@[simp]
theorem fderiv_id' : fderiv 𝕜 (fun x : E => x) x = ContinuousLinearMap.id 𝕜 E :=
fderiv_id
theorem fderivWithin_id (hxs : UniqueDiffWithinAt 𝕜 s x) : fderivWithin 𝕜 id s x = .id 𝕜 E := by
rw [DifferentiableAt.fderivWithin differentiableAt_id hxs]
exact fderiv_id
theorem fderivWithin_id' (hxs : UniqueDiffWithinAt 𝕜 s x) :
fderivWithin 𝕜 (fun x : E => x) s x = ContinuousLinearMap.id 𝕜 E :=
fderivWithin_id hxs
end id
section MeanValue
/-- Converse to the mean value inequality: if `f` is differentiable at `x₀` and `C`-lipschitz
on a neighborhood of `x₀` then its derivative at `x₀` has norm bounded by `C`. This version
only assumes that `‖f x - f x₀‖ ≤ C * ‖x - x₀‖` in a neighborhood of `x`. -/
theorem HasFDerivAt.le_of_lip' {f : E → F} {f' : E →L[𝕜] F} {x₀ : E} (hf : HasFDerivAt f f' x₀)
{C : ℝ} (hC₀ : 0 ≤ C) (hlip : ∀ᶠ x in 𝓝 x₀, ‖f x - f x₀‖ ≤ C * ‖x - x₀‖) : ‖f'‖ ≤ C := by
refine le_of_forall_pos_le_add fun ε ε0 => opNorm_le_of_nhds_zero ?_ ?_
· exact add_nonneg hC₀ ε0.le
rw [← map_add_left_nhds_zero x₀, eventually_map] at hlip
filter_upwards [isLittleO_iff.1 (hasFDerivAt_iff_isLittleO_nhds_zero.1 hf) ε0, hlip] with y hy hyC
rw [add_sub_cancel_left] at hyC
calc
‖f' y‖ ≤ ‖f (x₀ + y) - f x₀‖ + ‖f (x₀ + y) - f x₀ - f' y‖ := norm_le_insert _ _
_ ≤ C * ‖y‖ + ε * ‖y‖ := add_le_add hyC hy
_ = (C + ε) * ‖y‖ := (add_mul _ _ _).symm
/-- Converse to the mean value inequality: if `f` is differentiable at `x₀` and `C`-lipschitz
on a neighborhood of `x₀` then its derivative at `x₀` has norm bounded by `C`. -/
theorem HasFDerivAt.le_of_lipschitzOn
{f : E → F} {f' : E →L[𝕜] F} {x₀ : E} (hf : HasFDerivAt f f' x₀)
{s : Set E} (hs : s ∈ 𝓝 x₀) {C : ℝ≥0} (hlip : LipschitzOnWith C f s) : ‖f'‖ ≤ C := by
refine hf.le_of_lip' C.coe_nonneg ?_
filter_upwards [hs] with x hx using hlip.norm_sub_le hx (mem_of_mem_nhds hs)
/-- Converse to the mean value inequality: if `f` is differentiable at `x₀` and `C`-lipschitz
then its derivative at `x₀` has norm bounded by `C`. -/
theorem HasFDerivAt.le_of_lipschitz {f : E → F} {f' : E →L[𝕜] F} {x₀ : E} (hf : HasFDerivAt f f' x₀)
{C : ℝ≥0} (hlip : LipschitzWith C f) : ‖f'‖ ≤ C :=
hf.le_of_lipschitzOn univ_mem (lipschitzOnWith_univ.2 hlip)
variable (𝕜)
/-- Converse to the mean value inequality: if `f` is `C`-lipschitz
on a neighborhood of `x₀` then its derivative at `x₀` has norm bounded by `C`. This version
only assumes that `‖f x - f x₀‖ ≤ C * ‖x - x₀‖` in a neighborhood of `x`. -/
theorem norm_fderiv_le_of_lip' {f : E → F} {x₀ : E}
{C : ℝ} (hC₀ : 0 ≤ C) (hlip : ∀ᶠ x in 𝓝 x₀, ‖f x - f x₀‖ ≤ C * ‖x - x₀‖) :
‖fderiv 𝕜 f x₀‖ ≤ C := by
by_cases hf : DifferentiableAt 𝕜 f x₀
· exact hf.hasFDerivAt.le_of_lip' hC₀ hlip
· rw [fderiv_zero_of_not_differentiableAt hf]
simp [hC₀]
/-- Converse to the mean value inequality: if `f` is `C`-lipschitz
on a neighborhood of `x₀` then its derivative at `x₀` has norm bounded by `C`.
Version using `fderiv`. -/
theorem norm_fderiv_le_of_lipschitzOn {f : E → F} {x₀ : E} {s : Set E} (hs : s ∈ 𝓝 x₀)
{C : ℝ≥0} (hlip : LipschitzOnWith C f s) : ‖fderiv 𝕜 f x₀‖ ≤ C := by
refine norm_fderiv_le_of_lip' 𝕜 C.coe_nonneg ?_
filter_upwards [hs] with x hx using hlip.norm_sub_le hx (mem_of_mem_nhds hs)
/-- Converse to the mean value inequality: if `f` is `C`-lipschitz then
its derivative at `x₀` has norm bounded by `C`.
Version using `fderiv`. -/
theorem norm_fderiv_le_of_lipschitz {f : E → F} {x₀ : E}
{C : ℝ≥0} (hlip : LipschitzWith C f) : ‖fderiv 𝕜 f x₀‖ ≤ C :=
norm_fderiv_le_of_lipschitzOn 𝕜 univ_mem (lipschitzOnWith_univ.2 hlip)
end MeanValue
end
section Semilinear
/-!
## Results involving semilinear maps
-/
variable {𝕜 V V' W W' : Type*} [NontriviallyNormedField 𝕜] {σ σ' : RingHom 𝕜 𝕜}
[NormedAddCommGroup V] [NormedSpace 𝕜 V] [NormedAddCommGroup V'] [NormedSpace 𝕜 V']
[NormedAddCommGroup W] [NormedSpace 𝕜 W] [NormedAddCommGroup W'] [NormedSpace 𝕜 W']
[RingHomIsometric σ] [RingHomInvPair σ σ'] (L : W →SL[σ] W') (R : V' →SL[σ'] V)
/-- If `L` and `R` are semilinear maps whose composite is linear, and `f` has Fréchet derivative
`f'` at `R z`, then `L ∘ f ∘ R` has Fréchet derivative `L ∘ f' ∘ R` at `z`. -/
lemma HasFDerivAt.comp_semilinear {f : V → W} {z : V'} {f' : V →L[𝕜] W}
(hf : HasFDerivAt f f' (R z)) : HasFDerivAt (L ∘ f ∘ R) (L.comp (f'.comp R)) z := by
have : RingHomIsometric σ' := .inv σ
rw [hasFDerivAt_iff_isLittleO_nhds_zero] at ⊢ hf
have := hf.comp_tendsto (R.map_zero ▸ R.continuous.continuousAt.tendsto)
simpa using ((L.isBigO_comp _ _).trans_isLittleO this).trans_isBigO (R.isBigO_id _)
/-- If `L` and `R` are semilinear maps whose composite is linear, and `f` is differentiable at
`R z`, then `L ∘ f ∘ R` is differentiable at `z`. -/
lemma DifferentiableAt.comp_semilinear₂ {f : V → W} {z : V'} (hf : DifferentiableAt 𝕜 f (R z)) :
DifferentiableAt 𝕜 (L ∘ f ∘ R) z := by
simpa using (hf.hasFDerivAt.comp_semilinear L R).differentiableAt
end Semilinear |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/FDeriv/Congr.lean | import Mathlib.Analysis.Calculus.FDeriv.Basic
/-!
# The Fréchet derivative: congruence properties
Lemmas about congruence properties of the Fréchet derivative under change of function, set, etc.
## Tags
derivative, differentiable, Fréchet, calculus
-/
open Filter Asymptotics ContinuousLinearMap Set Metric Topology NNReal ENNReal
noncomputable section
section
variable {𝕜 : Type*} [NontriviallyNormedField 𝕜]
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E]
variable {F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F]
variable {f f₀ f₁ g : E → F}
variable {f' f₀' f₁' g' : E →L[𝕜] F}
variable {x : E}
variable {s t : Set E}
variable {L L₁ L₂ : Filter E}
section congr
/-! ### congr properties of the derivative -/
theorem hasFDerivWithinAt_congr_set' (y : E) (h : s =ᶠ[𝓝[{y}ᶜ] x] t) :
HasFDerivWithinAt f f' s x ↔ HasFDerivWithinAt f f' t x :=
calc
HasFDerivWithinAt f f' s x ↔ HasFDerivWithinAt f f' (s \ {y}) x :=
(hasFDerivWithinAt_diff_singleton _).symm
_ ↔ HasFDerivWithinAt f f' (t \ {y}) x := by
suffices 𝓝[s \ {y}] x = 𝓝[t \ {y}] x by simp only [HasFDerivWithinAt, this]
simpa only [set_eventuallyEq_iff_inf_principal, ← nhdsWithin_inter', diff_eq,
inter_comm] using h
_ ↔ HasFDerivWithinAt f f' t x := hasFDerivWithinAt_diff_singleton _
theorem hasFDerivWithinAt_congr_set (h : s =ᶠ[𝓝 x] t) :
HasFDerivWithinAt f f' s x ↔ HasFDerivWithinAt f f' t x :=
hasFDerivWithinAt_congr_set' x <| h.filter_mono inf_le_left
theorem differentiableWithinAt_congr_set' (y : E) (h : s =ᶠ[𝓝[{y}ᶜ] x] t) :
DifferentiableWithinAt 𝕜 f s x ↔ DifferentiableWithinAt 𝕜 f t x :=
exists_congr fun _ => hasFDerivWithinAt_congr_set' _ h
theorem differentiableWithinAt_congr_set (h : s =ᶠ[𝓝 x] t) :
DifferentiableWithinAt 𝕜 f s x ↔ DifferentiableWithinAt 𝕜 f t x :=
exists_congr fun _ => hasFDerivWithinAt_congr_set h
theorem fderivWithin_congr_set' (y : E) (h : s =ᶠ[𝓝[{y}ᶜ] x] t) :
fderivWithin 𝕜 f s x = fderivWithin 𝕜 f t x := by
classical
simp only [fderivWithin, differentiableWithinAt_congr_set' _ h, hasFDerivWithinAt_congr_set' _ h]
theorem fderivWithin_congr_set (h : s =ᶠ[𝓝 x] t) : fderivWithin 𝕜 f s x = fderivWithin 𝕜 f t x :=
fderivWithin_congr_set' x <| h.filter_mono inf_le_left
theorem fderivWithin_eventually_congr_set' (y : E) (h : s =ᶠ[𝓝[{y}ᶜ] x] t) :
fderivWithin 𝕜 f s =ᶠ[𝓝 x] fderivWithin 𝕜 f t :=
(eventually_nhds_nhdsWithin.2 h).mono fun _ => fderivWithin_congr_set' y
theorem fderivWithin_eventually_congr_set (h : s =ᶠ[𝓝 x] t) :
fderivWithin 𝕜 f s =ᶠ[𝓝 x] fderivWithin 𝕜 f t :=
fderivWithin_eventually_congr_set' x <| h.filter_mono inf_le_left
theorem Filter.EventuallyEq.hasStrictFDerivAt_iff (h : f₀ =ᶠ[𝓝 x] f₁) (h' : ∀ y, f₀' y = f₁' y) :
HasStrictFDerivAt f₀ f₀' x ↔ HasStrictFDerivAt f₁ f₁' x := by
rw [hasStrictFDerivAt_iff_isLittleOTVS, hasStrictFDerivAt_iff_isLittleOTVS]
refine isLittleOTVS_congr ((h.prodMk_nhds h).mono ?_) .rfl
rintro p ⟨hp₁, hp₂⟩
simp only [*]
theorem HasStrictFDerivAt.congr_fderiv (h : HasStrictFDerivAt f f' x) (h' : f' = g') :
HasStrictFDerivAt f g' x :=
h' ▸ h
theorem HasFDerivAt.congr_fderiv (h : HasFDerivAt f f' x) (h' : f' = g') : HasFDerivAt f g' x :=
h' ▸ h
theorem HasFDerivWithinAt.congr_fderiv (h : HasFDerivWithinAt f f' s x) (h' : f' = g') :
HasFDerivWithinAt f g' s x :=
h' ▸ h
theorem HasStrictFDerivAt.congr_of_eventuallyEq (h : HasStrictFDerivAt f f' x)
(h₁ : f =ᶠ[𝓝 x] f₁) : HasStrictFDerivAt f₁ f' x :=
(h₁.hasStrictFDerivAt_iff fun _ => rfl).1 h
theorem Filter.EventuallyEq.hasFDerivAtFilter_iff (h₀ : f₀ =ᶠ[L] f₁) (hx : f₀ x = f₁ x)
(h₁ : ∀ x, f₀' x = f₁' x) : HasFDerivAtFilter f₀ f₀' x L ↔ HasFDerivAtFilter f₁ f₁' x L := by
simp only [hasFDerivAtFilter_iff_isLittleOTVS]
exact isLittleOTVS_congr (h₀.mono fun y hy => by simp only [hy, h₁, hx]) .rfl
theorem HasFDerivAtFilter.congr_of_eventuallyEq (h : HasFDerivAtFilter f f' x L) (hL : f₁ =ᶠ[L] f)
(hx : f₁ x = f x) : HasFDerivAtFilter f₁ f' x L :=
(hL.hasFDerivAtFilter_iff hx fun _ => rfl).2 h
theorem Filter.EventuallyEq.hasFDerivAt_iff (h : f₀ =ᶠ[𝓝 x] f₁) :
HasFDerivAt f₀ f' x ↔ HasFDerivAt f₁ f' x :=
h.hasFDerivAtFilter_iff h.eq_of_nhds fun _ => _root_.rfl
theorem Filter.EventuallyEq.differentiableAt_iff (h : f₀ =ᶠ[𝓝 x] f₁) :
DifferentiableAt 𝕜 f₀ x ↔ DifferentiableAt 𝕜 f₁ x :=
exists_congr fun _ => h.hasFDerivAt_iff
theorem Filter.EventuallyEq.hasFDerivWithinAt_iff (h : f₀ =ᶠ[𝓝[s] x] f₁) (hx : f₀ x = f₁ x) :
HasFDerivWithinAt f₀ f' s x ↔ HasFDerivWithinAt f₁ f' s x :=
h.hasFDerivAtFilter_iff hx fun _ => _root_.rfl
theorem Filter.EventuallyEq.hasFDerivWithinAt_iff_of_mem (h : f₀ =ᶠ[𝓝[s] x] f₁) (hx : x ∈ s) :
HasFDerivWithinAt f₀ f' s x ↔ HasFDerivWithinAt f₁ f' s x :=
h.hasFDerivWithinAt_iff (h.eq_of_nhdsWithin hx)
theorem Filter.EventuallyEq.differentiableWithinAt_iff (h : f₀ =ᶠ[𝓝[s] x] f₁) (hx : f₀ x = f₁ x) :
DifferentiableWithinAt 𝕜 f₀ s x ↔ DifferentiableWithinAt 𝕜 f₁ s x :=
exists_congr fun _ => h.hasFDerivWithinAt_iff hx
theorem Filter.EventuallyEq.differentiableWithinAt_iff_of_mem (h : f₀ =ᶠ[𝓝[s] x] f₁) (hx : x ∈ s) :
DifferentiableWithinAt 𝕜 f₀ s x ↔ DifferentiableWithinAt 𝕜 f₁ s x :=
h.differentiableWithinAt_iff (h.eq_of_nhdsWithin hx)
theorem HasFDerivWithinAt.congr_mono (h : HasFDerivWithinAt f f' s x) (ht : EqOn f₁ f t)
(hx : f₁ x = f x) (h₁ : t ⊆ s) : HasFDerivWithinAt f₁ f' t x :=
HasFDerivAtFilter.congr_of_eventuallyEq (h.mono h₁) (Filter.mem_inf_of_right ht) hx
theorem HasFDerivWithinAt.congr (h : HasFDerivWithinAt f f' s x) (hs : EqOn f₁ f s)
(hx : f₁ x = f x) : HasFDerivWithinAt f₁ f' s x :=
h.congr_mono hs hx (Subset.refl _)
theorem HasFDerivWithinAt.congr' (h : HasFDerivWithinAt f f' s x) (hs : EqOn f₁ f s) (hx : x ∈ s) :
HasFDerivWithinAt f₁ f' s x :=
h.congr hs (hs hx)
theorem HasFDerivWithinAt.congr_of_eventuallyEq (h : HasFDerivWithinAt f f' s x)
(h₁ : f₁ =ᶠ[𝓝[s] x] f) (hx : f₁ x = f x) : HasFDerivWithinAt f₁ f' s x :=
HasFDerivAtFilter.congr_of_eventuallyEq h h₁ hx
theorem HasFDerivAt.congr_of_eventuallyEq (h : HasFDerivAt f f' x) (h₁ : f₁ =ᶠ[𝓝 x] f) :
HasFDerivAt f₁ f' x :=
HasFDerivAtFilter.congr_of_eventuallyEq h h₁ (mem_of_mem_nhds h₁ :)
theorem DifferentiableWithinAt.congr_mono (h : DifferentiableWithinAt 𝕜 f s x) (ht : EqOn f₁ f t)
(hx : f₁ x = f x) (h₁ : t ⊆ s) : DifferentiableWithinAt 𝕜 f₁ t x :=
(HasFDerivWithinAt.congr_mono h.hasFDerivWithinAt ht hx h₁).differentiableWithinAt
theorem DifferentiableWithinAt.congr (h : DifferentiableWithinAt 𝕜 f s x) (ht : ∀ x ∈ s, f₁ x = f x)
(hx : f₁ x = f x) : DifferentiableWithinAt 𝕜 f₁ s x :=
DifferentiableWithinAt.congr_mono h ht hx (Subset.refl _)
theorem DifferentiableWithinAt.congr_of_eventuallyEq (h : DifferentiableWithinAt 𝕜 f s x)
(h₁ : f₁ =ᶠ[𝓝[s] x] f) (hx : f₁ x = f x) : DifferentiableWithinAt 𝕜 f₁ s x :=
(h.hasFDerivWithinAt.congr_of_eventuallyEq h₁ hx).differentiableWithinAt
theorem DifferentiableWithinAt.congr_of_eventuallyEq_of_mem (h : DifferentiableWithinAt 𝕜 f s x)
(h₁ : f₁ =ᶠ[𝓝[s] x] f) (hx : x ∈ s) : DifferentiableWithinAt 𝕜 f₁ s x :=
h.congr_of_eventuallyEq h₁ (mem_of_mem_nhdsWithin hx h₁ :)
theorem DifferentiableWithinAt.congr_of_eventuallyEq_insert (h : DifferentiableWithinAt 𝕜 f s x)
(h₁ : f₁ =ᶠ[𝓝[insert x s] x] f) : DifferentiableWithinAt 𝕜 f₁ s x :=
(h.insert.congr_of_eventuallyEq_of_mem h₁ (mem_insert _ _)).of_insert
theorem DifferentiableOn.congr_mono (h : DifferentiableOn 𝕜 f s) (h' : ∀ x ∈ t, f₁ x = f x)
(h₁ : t ⊆ s) : DifferentiableOn 𝕜 f₁ t := fun x hx => (h x (h₁ hx)).congr_mono h' (h' x hx) h₁
theorem DifferentiableOn.congr (h : DifferentiableOn 𝕜 f s) (h' : ∀ x ∈ s, f₁ x = f x) :
DifferentiableOn 𝕜 f₁ s := fun x hx => (h x hx).congr h' (h' x hx)
theorem differentiableOn_congr (h' : ∀ x ∈ s, f₁ x = f x) :
DifferentiableOn 𝕜 f₁ s ↔ DifferentiableOn 𝕜 f s :=
⟨fun h => DifferentiableOn.congr h fun y hy => (h' y hy).symm, fun h =>
DifferentiableOn.congr h h'⟩
theorem DifferentiableAt.congr_of_eventuallyEq (h : DifferentiableAt 𝕜 f x) (hL : f₁ =ᶠ[𝓝 x] f) :
DifferentiableAt 𝕜 f₁ x :=
hL.differentiableAt_iff.2 h
theorem DifferentiableWithinAt.fderivWithin_congr_mono (h : DifferentiableWithinAt 𝕜 f s x)
(hs : EqOn f₁ f t) (hx : f₁ x = f x) (hxt : UniqueDiffWithinAt 𝕜 t x) (h₁ : t ⊆ s) :
fderivWithin 𝕜 f₁ t x = fderivWithin 𝕜 f s x :=
(HasFDerivWithinAt.congr_mono h.hasFDerivWithinAt hs hx h₁).fderivWithin hxt
theorem Filter.EventuallyEq.fderivWithin_eq (hs : f₁ =ᶠ[𝓝[s] x] f) (hx : f₁ x = f x) :
fderivWithin 𝕜 f₁ s x = fderivWithin 𝕜 f s x := by
classical
simp only [fderivWithin, DifferentiableWithinAt, hs.hasFDerivWithinAt_iff hx]
theorem Filter.EventuallyEq.fderivWithin_eq_of_mem (hs : f₁ =ᶠ[𝓝[s] x] f) (hx : x ∈ s) :
fderivWithin 𝕜 f₁ s x = fderivWithin 𝕜 f s x :=
hs.fderivWithin_eq (mem_of_mem_nhdsWithin hx hs :)
theorem Filter.EventuallyEq.fderivWithin_eq_of_insert (hs : f₁ =ᶠ[𝓝[insert x s] x] f) :
fderivWithin 𝕜 f₁ s x = fderivWithin 𝕜 f s x := by
apply Filter.EventuallyEq.fderivWithin_eq (nhdsWithin_mono _ (subset_insert x s) hs)
exact (mem_of_mem_nhdsWithin (mem_insert x s) hs :)
theorem Filter.EventuallyEq.fderivWithin' (hs : f₁ =ᶠ[𝓝[s] x] f) (ht : t ⊆ s) :
fderivWithin 𝕜 f₁ t =ᶠ[𝓝[s] x] fderivWithin 𝕜 f t :=
(eventually_eventually_nhdsWithin.2 hs).mp <|
eventually_mem_nhdsWithin.mono fun _y hys hs =>
EventuallyEq.fderivWithin_eq (hs.filter_mono <| nhdsWithin_mono _ ht)
(hs.self_of_nhdsWithin hys)
protected theorem Filter.EventuallyEq.fderivWithin (hs : f₁ =ᶠ[𝓝[s] x] f) :
fderivWithin 𝕜 f₁ s =ᶠ[𝓝[s] x] fderivWithin 𝕜 f s :=
hs.fderivWithin' Subset.rfl
theorem Filter.EventuallyEq.fderivWithin_eq_of_nhds (h : f₁ =ᶠ[𝓝 x] f) :
fderivWithin 𝕜 f₁ s x = fderivWithin 𝕜 f s x :=
(h.filter_mono nhdsWithin_le_nhds).fderivWithin_eq h.self_of_nhds
@[deprecated (since := "2025-05-20")]
alias Filter.EventuallyEq.fderivWithin_eq_nhds := Filter.EventuallyEq.fderivWithin_eq_of_nhds
theorem fderivWithin_congr (hs : EqOn f₁ f s) (hx : f₁ x = f x) :
fderivWithin 𝕜 f₁ s x = fderivWithin 𝕜 f s x :=
(hs.eventuallyEq.filter_mono inf_le_right).fderivWithin_eq hx
theorem fderivWithin_congr' (hs : EqOn f₁ f s) (hx : x ∈ s) :
fderivWithin 𝕜 f₁ s x = fderivWithin 𝕜 f s x :=
fderivWithin_congr hs (hs hx)
theorem Filter.EventuallyEq.fderiv_eq (h : f₁ =ᶠ[𝓝 x] f) : fderiv 𝕜 f₁ x = fderiv 𝕜 f x := by
rw [← fderivWithin_univ, ← fderivWithin_univ, h.fderivWithin_eq_of_nhds]
protected theorem Filter.EventuallyEq.fderiv (h : f₁ =ᶠ[𝓝 x] f) : fderiv 𝕜 f₁ =ᶠ[𝓝 x] fderiv 𝕜 f :=
h.eventuallyEq_nhds.mono fun _ h => h.fderiv_eq
end congr
end |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/FDeriv/Defs.lean | import Mathlib.Analysis.Asymptotics.TVS
/-!
# The Fréchet derivative: definition
Let `E` and `F` be normed spaces, `f : E → F`, and `f' : E →L[𝕜] F` a
continuous 𝕜-linear map, where `𝕜` is a non-discrete normed field. Then
`HasFDerivWithinAt f f' s x`
says that `f` has derivative `f'` at `x`, where the domain of interest
is restricted to `s`. We also have
`HasFDerivAt f f' x := HasFDerivWithinAt f f' x univ`
Finally,
`HasStrictFDerivAt f f' x`
means that `f : E → F` has derivative `f' : E →L[𝕜] F` in the sense of strict differentiability,
i.e., `f y - f z - f'(y - z) = o(y - z)` as `y, z → x`. This notion is used in the inverse
function theorem, and is defined here only to avoid proving theorems like
`IsBoundedBilinearMap.hasFDerivAt` twice: first for `HasFDerivAt`, then for
`HasStrictFDerivAt`.
This file `Defs.lean` is intended to just contain the definitions and the bare minimum of
supporting lemmas; a much wider range of elementary properties are proved in the file `Basic.lean`.
Other files in the folder `Analysis/Calculus/FDeriv/` contain the usual formulas
(and existence assertions) for the derivative of
* constants (`Const.lean`)
* the identity
* bounded linear maps (`Linear.lean`)
* bounded bilinear maps (`Bilinear.lean`)
* sum of two functions (`Add.lean`)
* sum of finitely many functions (`Add.lean`)
* multiplication of a function by a scalar constant (`Add.lean`)
* negative of a function (`Add.lean`)
* subtraction of two functions (`Add.lean`)
* multiplication of a function by a scalar function (`Mul.lean`)
* multiplication of two scalar functions (`Mul.lean`)
* composition of functions (the chain rule) (`Comp.lean`)
* inverse function (`Mul.lean`)
(assuming that it exists; the inverse function theorem is in `../Inverse.lean`)
## Implementation details
The derivative is defined in terms of the `IsLittleOTVS` relation to ensure the definition does not
ingrain a choice of norm, and is then quickly translated to the more convenient `IsLittleO` in the
subsequent theorems. It is also characterized in terms of the `Tendsto` relation.
We also introduce predicates `DifferentiableWithinAt 𝕜 f s x` (where `𝕜` is the base field,
`f` the function to be differentiated, `x` the point at which the derivative is asserted to exist,
and `s` the set along which the derivative is defined), as well as `DifferentiableAt 𝕜 f x`,
`DifferentiableOn 𝕜 f s` and `Differentiable 𝕜 f` to express the existence of a derivative.
To be able to compute with derivatives, we write `fderivWithin 𝕜 f s x` and `fderiv 𝕜 f x`
for some choice of a derivative if it exists, and the zero function otherwise. This choice only
behaves well along sets for which the derivative is unique, i.e., those for which the tangent
directions span a dense subset of the whole space. The predicates `UniqueDiffWithinAt s x` and
`UniqueDiffOn s`, defined in `TangentCone.lean` express this property. We prove that indeed
they imply the uniqueness of the derivative. This is satisfied for open subsets, and in particular
for `univ`. This uniqueness only holds when the field is non-discrete, which we request at the very
beginning: otherwise, a derivative can be defined, but it has no interesting properties whatsoever.
## TODO
Generalize more results to topological vector spaces.
## Tags
derivative, differentiable, Fréchet, calculus
-/
open Filter Asymptotics ContinuousLinearMap Set Metric Topology NNReal ENNReal
variable {𝕜 : Type*} [NontriviallyNormedField 𝕜]
noncomputable section TVS
/-!
## Definitions valid in an arbitrary topological vector space
-/
variable {E : Type*} [AddCommGroup E] [Module 𝕜 E] [TopologicalSpace E]
variable {F : Type*} [AddCommGroup F] [Module 𝕜 F] [TopologicalSpace F]
/-- A function `f` has the continuous linear map `f'` as derivative along the filter `L` if
`f x' = f x + f' (x' - x) + o (x' - x)` when `x'` converges along the filter `L`. This definition
is designed to be specialized for `L = 𝓝 x` (in `HasFDerivAt`), giving rise to the usual notion
of Fréchet derivative, and for `L = 𝓝[s] x` (in `HasFDerivWithinAt`), giving rise to
the notion of Fréchet derivative along the set `s`. -/
@[mk_iff hasFDerivAtFilter_iff_isLittleOTVS]
structure HasFDerivAtFilter (f : E → F) (f' : E →L[𝕜] F) (x : E) (L : Filter E) : Prop where
of_isLittleOTVS ::
isLittleOTVS : (fun x' => f x' - f x - f' (x' - x)) =o[𝕜; L] (fun x' => x' - x)
/-- A function `f` has the continuous linear map `f'` as derivative at `x` within a set `s` if
`f x' = f x + f' (x' - x) + o (x' - x)` when `x'` tends to `x` inside `s`. -/
@[fun_prop]
def HasFDerivWithinAt (f : E → F) (f' : E →L[𝕜] F) (s : Set E) (x : E) :=
HasFDerivAtFilter f f' x (𝓝[s] x)
/-- A function `f` has the continuous linear map `f'` as derivative at `x` if
`f x' = f x + f' (x' - x) + o (x' - x)` when `x'` tends to `x`. -/
@[fun_prop]
def HasFDerivAt (f : E → F) (f' : E →L[𝕜] F) (x : E) :=
HasFDerivAtFilter f f' x (𝓝 x)
/-- A function `f` has derivative `f'` at `a` in the sense of *strict differentiability*
if `f x - f y - f' (x - y) = o(x - y)` as `x, y → a`. This form of differentiability is required,
e.g., by the inverse function theorem. Any `C^1` function on a vector space over `ℝ` is strictly
differentiable but this definition works, e.g., for vector spaces over `p`-adic numbers. -/
@[fun_prop, mk_iff hasStrictFDerivAt_iff_isLittleOTVS]
structure HasStrictFDerivAt (f : E → F) (f' : E →L[𝕜] F) (x : E) where
of_isLittleOTVS ::
isLittleOTVS :
(fun p : E × E => f p.1 - f p.2 - f' (p.1 - p.2))
=o[𝕜; 𝓝 (x, x)] (fun p : E × E => p.1 - p.2)
variable (𝕜)
/-- A function `f` is differentiable at a point `x` within a set `s` if it admits a derivative
there (possibly non-unique). -/
@[fun_prop]
def DifferentiableWithinAt (f : E → F) (s : Set E) (x : E) :=
∃ f' : E →L[𝕜] F, HasFDerivWithinAt f f' s x
/-- A function `f` is differentiable at a point `x` if it admits a derivative there (possibly
non-unique). -/
@[fun_prop]
def DifferentiableAt (f : E → F) (x : E) :=
∃ f' : E →L[𝕜] F, HasFDerivAt f f' x
open scoped Classical in
/-- If `f` has a derivative at `x` within `s`, then `fderivWithin 𝕜 f s x` is such a derivative.
Otherwise, it is set to `0`. We also set it to be zero, if zero is one of possible derivatives. -/
irreducible_def fderivWithin (f : E → F) (s : Set E) (x : E) : E →L[𝕜] F :=
if HasFDerivWithinAt f (0 : E →L[𝕜] F) s x
then 0
else if h : DifferentiableWithinAt 𝕜 f s x
then Classical.choose h
else 0
/-- If `f` has a derivative at `x`, then `fderiv 𝕜 f x` is such a derivative. Otherwise, it is
set to `0`. -/
irreducible_def fderiv (f : E → F) (x : E) : E →L[𝕜] F :=
fderivWithin 𝕜 f univ x
/-- `DifferentiableOn 𝕜 f s` means that `f` is differentiable within `s` at any point of `s`. -/
@[fun_prop]
def DifferentiableOn (f : E → F) (s : Set E) :=
∀ x ∈ s, DifferentiableWithinAt 𝕜 f s x
/-- `Differentiable 𝕜 f` means that `f` is differentiable at any point. -/
@[fun_prop]
def Differentiable (f : E → F) :=
∀ x, DifferentiableAt 𝕜 f x
variable {𝕜}
variable {f f₀ f₁ g : E → F}
variable {f' f₀' f₁' g' : E →L[𝕜] F}
variable {x : E}
variable {s t : Set E}
variable {L L₁ L₂ : Filter E}
theorem fderivWithin_zero_of_not_differentiableWithinAt (h : ¬DifferentiableWithinAt 𝕜 f s x) :
fderivWithin 𝕜 f s x = 0 := by
simp [fderivWithin, h]
@[simp]
theorem fderivWithin_univ : fderivWithin 𝕜 f univ = fderiv 𝕜 f := by
ext
rw [fderiv]
end TVS
section Normed
/-!
## Reformulations for seminormed spaces
-/
variable {E : Type*} [SeminormedAddCommGroup E] [NormedSpace 𝕜 E]
variable {F : Type*} [SeminormedAddCommGroup F] [NormedSpace 𝕜 F]
variable {f : E → F} {f' : E →L[𝕜] F} {x : E}
theorem hasFDerivAtFilter_iff_isLittleO {L : Filter E} :
HasFDerivAtFilter f f' x L ↔ (fun x' => f x' - f x - f' (x' - x)) =o[L] fun x' => x' - x :=
(hasFDerivAtFilter_iff_isLittleOTVS ..).trans isLittleOTVS_iff_isLittleO
alias ⟨HasFDerivAtFilter.isLittleO, HasFDerivAtFilter.of_isLittleO⟩ :=
hasFDerivAtFilter_iff_isLittleO
theorem hasStrictFDerivAt_iff_isLittleO :
HasStrictFDerivAt f f' x ↔
(fun p : E × E => f p.1 - f p.2 - f' (p.1 - p.2)) =o[𝓝 (x, x)] fun p : E × E => p.1 - p.2 :=
(hasStrictFDerivAt_iff_isLittleOTVS ..).trans isLittleOTVS_iff_isLittleO
alias ⟨HasStrictFDerivAt.isLittleO, HasStrictFDerivAt.of_isLittleO⟩ :=
hasStrictFDerivAt_iff_isLittleO
end Normed |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/FDeriv/Const.lean | import Mathlib.Analysis.Calculus.FDeriv.Congr
/-!
# Fréchet derivative of constant functions
This file contains the usual formulas (and existence assertions) for the derivative of constant
functions, including various special cases such as the functions `0`, `1`, `Nat.cast n`,
`Int.cast z`, and other numerals.
## Tags
derivative, differentiable, Fréchet, calculus
-/
open Filter Asymptotics ContinuousLinearMap Set Metric Topology NNReal ENNReal
noncomputable section
variable {𝕜 : Type*} [NontriviallyNormedField 𝕜]
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E]
variable {F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F]
variable {f : E → F} {x : E} {s : Set E}
section Const
@[fun_prop]
theorem hasStrictFDerivAt_const (c : F) (x : E) :
HasStrictFDerivAt (fun _ => c) (0 : E →L[𝕜] F) x :=
.of_isLittleOTVS <| (IsLittleOTVS.zero _ _).congr_left fun _ => by
simp only [zero_apply, sub_self, Pi.zero_apply]
@[fun_prop]
theorem hasStrictFDerivAt_zero (x : E) :
HasStrictFDerivAt (0 : E → F) (0 : E →L[𝕜] F) x := hasStrictFDerivAt_const _ _
@[fun_prop]
theorem hasStrictFDerivAt_one [One F] (x : E) :
HasStrictFDerivAt (1 : E → F) (0 : E →L[𝕜] F) x := hasStrictFDerivAt_const _ _
@[fun_prop]
theorem hasStrictFDerivAt_natCast [NatCast F] (n : ℕ) (x : E) :
HasStrictFDerivAt (n : E → F) (0 : E →L[𝕜] F) x := hasStrictFDerivAt_const _ _
@[fun_prop]
theorem hasStrictFDerivAt_intCast [IntCast F] (z : ℤ) (x : E) :
HasStrictFDerivAt (z : E → F) (0 : E →L[𝕜] F) x := hasStrictFDerivAt_const _ _
@[fun_prop]
theorem hasStrictFDerivAt_ofNat (n : ℕ) [OfNat F n] (x : E) :
HasStrictFDerivAt (ofNat(n) : E → F) (0 : E →L[𝕜] F) x := hasStrictFDerivAt_const _ _
theorem hasFDerivAtFilter_const (c : F) (x : E) (L : Filter E) :
HasFDerivAtFilter (fun _ => c) (0 : E →L[𝕜] F) x L :=
.of_isLittleOTVS <| (IsLittleOTVS.zero _ _).congr_left fun _ => by
simp only [zero_apply, sub_self, Pi.zero_apply]
theorem hasFDerivAtFilter_zero (x : E) (L : Filter E) :
HasFDerivAtFilter (0 : E → F) (0 : E →L[𝕜] F) x L := hasFDerivAtFilter_const _ _ _
theorem hasFDerivAtFilter_one [One F] (x : E) (L : Filter E) :
HasFDerivAtFilter (1 : E → F) (0 : E →L[𝕜] F) x L := hasFDerivAtFilter_const _ _ _
theorem hasFDerivAtFilter_natCast [NatCast F] (n : ℕ) (x : E) (L : Filter E) :
HasFDerivAtFilter (n : E → F) (0 : E →L[𝕜] F) x L :=
hasFDerivAtFilter_const _ _ _
theorem hasFDerivAtFilter_intCast [IntCast F] (z : ℤ) (x : E) (L : Filter E) :
HasFDerivAtFilter (z : E → F) (0 : E →L[𝕜] F) x L :=
hasFDerivAtFilter_const _ _ _
theorem hasFDerivAtFilter_ofNat (n : ℕ) [OfNat F n] (x : E) (L : Filter E) :
HasFDerivAtFilter (ofNat(n) : E → F) (0 : E →L[𝕜] F) x L :=
hasFDerivAtFilter_const _ _ _
@[fun_prop]
theorem hasFDerivWithinAt_const (c : F) (x : E) (s : Set E) :
HasFDerivWithinAt (fun _ => c) (0 : E →L[𝕜] F) s x :=
hasFDerivAtFilter_const _ _ _
@[fun_prop]
theorem hasFDerivWithinAt_zero (x : E) (s : Set E) :
HasFDerivWithinAt (0 : E → F) (0 : E →L[𝕜] F) s x := hasFDerivWithinAt_const _ _ _
@[fun_prop]
theorem hasFDerivWithinAt_one [One F] (x : E) (s : Set E) :
HasFDerivWithinAt (1 : E → F) (0 : E →L[𝕜] F) s x := hasFDerivWithinAt_const _ _ _
@[fun_prop]
theorem hasFDerivWithinAt_natCast [NatCast F] (n : ℕ) (x : E) (s : Set E) :
HasFDerivWithinAt (n : E → F) (0 : E →L[𝕜] F) s x :=
hasFDerivWithinAt_const _ _ _
@[fun_prop]
theorem hasFDerivWithinAt_intCast [IntCast F] (z : ℤ) (x : E) (s : Set E) :
HasFDerivWithinAt (z : E → F) (0 : E →L[𝕜] F) s x :=
hasFDerivWithinAt_const _ _ _
@[fun_prop]
theorem hasFDerivWithinAt_ofNat (n : ℕ) [OfNat F n] (x : E) (s : Set E) :
HasFDerivWithinAt (ofNat(n) : E → F) (0 : E →L[𝕜] F) s x :=
hasFDerivWithinAt_const _ _ _
@[fun_prop]
theorem hasFDerivAt_const (c : F) (x : E) : HasFDerivAt (fun _ => c) (0 : E →L[𝕜] F) x :=
hasFDerivAtFilter_const _ _ _
@[fun_prop]
theorem hasFDerivAt_zero (x : E) :
HasFDerivAt (0 : E → F) (0 : E →L[𝕜] F) x := hasFDerivAt_const _ _
@[fun_prop]
theorem hasFDerivAt_one [One F] (x : E) :
HasFDerivAt (1 : E → F) (0 : E →L[𝕜] F) x := hasFDerivAt_const _ _
@[fun_prop]
theorem hasFDerivAt_natCast [NatCast F] (n : ℕ) (x : E) :
HasFDerivAt (n : E → F) (0 : E →L[𝕜] F) x := hasFDerivAt_const _ _
@[fun_prop]
theorem hasFDerivAt_intCast [IntCast F] (z : ℤ) (x : E) :
HasFDerivAt (z : E → F) (0 : E →L[𝕜] F) x := hasFDerivAt_const _ _
@[fun_prop]
theorem hasFDerivAt_ofNat (n : ℕ) [OfNat F n] (x : E) :
HasFDerivAt (ofNat(n) : E → F) (0 : E →L[𝕜] F) x := hasFDerivAt_const _ _
@[simp, fun_prop]
theorem differentiableAt_const (c : F) : DifferentiableAt 𝕜 (fun _ => c) x :=
⟨0, hasFDerivAt_const c x⟩
@[simp, fun_prop]
theorem differentiableAt_zero (x : E) :
DifferentiableAt 𝕜 (0 : E → F) x := differentiableAt_const _
@[simp, fun_prop]
theorem differentiableAt_one [One F] (x : E) :
DifferentiableAt 𝕜 (1 : E → F) x := differentiableAt_const _
@[simp, fun_prop]
theorem differentiableAt_natCast [NatCast F] (n : ℕ) (x : E) :
DifferentiableAt 𝕜 (n : E → F) x := differentiableAt_const _
@[simp, fun_prop]
theorem differentiableAt_intCast [IntCast F] (z : ℤ) (x : E) :
DifferentiableAt 𝕜 (z : E → F) x := differentiableAt_const _
@[simp low, fun_prop]
theorem differentiableAt_ofNat (n : ℕ) [OfNat F n] (x : E) :
DifferentiableAt 𝕜 (ofNat(n) : E → F) x := differentiableAt_const _
@[fun_prop]
theorem differentiableWithinAt_const (c : F) : DifferentiableWithinAt 𝕜 (fun _ => c) s x :=
DifferentiableAt.differentiableWithinAt (differentiableAt_const _)
@[fun_prop]
theorem differentiableWithinAt_zero :
DifferentiableWithinAt 𝕜 (0 : E → F) s x := differentiableWithinAt_const _
@[fun_prop]
theorem differentiableWithinAt_one [One F] :
DifferentiableWithinAt 𝕜 (1 : E → F) s x := differentiableWithinAt_const _
@[fun_prop]
theorem differentiableWithinAt_natCast [NatCast F] (n : ℕ) :
DifferentiableWithinAt 𝕜 (n : E → F) s x := differentiableWithinAt_const _
@[fun_prop]
theorem differentiableWithinAt_intCast [IntCast F] (z : ℤ) :
DifferentiableWithinAt 𝕜 (z : E → F) s x := differentiableWithinAt_const _
@[fun_prop]
theorem differentiableWithinAt_ofNat (n : ℕ) [OfNat F n] :
DifferentiableWithinAt 𝕜 (ofNat(n) : E → F) s x := differentiableWithinAt_const _
theorem fderivWithin_const_apply (c : F) : fderivWithin 𝕜 (fun _ => c) s x = 0 := by
rw [fderivWithin, if_pos]
apply hasFDerivWithinAt_const
@[simp]
theorem fderivWithin_fun_const (c : F) : fderivWithin 𝕜 (fun _ ↦ c) s = 0 := by
ext
rw [fderivWithin_const_apply, Pi.zero_apply]
@[simp]
theorem fderivWithin_const (c : F) : fderivWithin 𝕜 (Function.const E c) s = 0 :=
fderivWithin_fun_const c
@[simp]
theorem fderivWithin_zero : fderivWithin 𝕜 (0 : E → F) s = 0 := fderivWithin_const _
@[simp]
theorem fderivWithin_one [One F] : fderivWithin 𝕜 (1 : E → F) s = 0 := fderivWithin_const _
@[simp]
theorem fderivWithin_natCast [NatCast F] (n : ℕ) : fderivWithin 𝕜 (n : E → F) s = 0 :=
fderivWithin_const _
@[simp]
theorem fderivWithin_intCast [IntCast F] (z : ℤ) : fderivWithin 𝕜 (z : E → F) s = 0 :=
fderivWithin_const _
@[simp low]
theorem fderivWithin_ofNat (n : ℕ) [OfNat F n] : fderivWithin 𝕜 (ofNat(n) : E → F) s = 0 :=
fderivWithin_const _
theorem fderiv_const_apply (c : F) : fderiv 𝕜 (fun _ => c) x = 0 :=
(hasFDerivAt_const c x).fderiv
@[simp]
theorem fderiv_fun_const (c : F) : fderiv 𝕜 (fun _ : E => c) = 0 := by
rw [← fderivWithin_univ, fderivWithin_fun_const]
@[simp]
theorem fderiv_const (c : F) : fderiv 𝕜 (Function.const E c) = 0 :=
fderiv_fun_const c
@[simp]
theorem fderiv_zero : fderiv 𝕜 (0 : E → F) = 0 := fderiv_const _
@[simp]
theorem fderiv_one [One F] : fderiv 𝕜 (1 : E → F) = 0 := fderiv_const _
@[simp]
theorem fderiv_natCast [NatCast F] (n : ℕ) : fderiv 𝕜 (n : E → F) = 0 := fderiv_const _
@[simp]
theorem fderiv_intCast [IntCast F] (z : ℤ) : fderiv 𝕜 (z : E → F) = 0 := fderiv_const _
@[simp low]
theorem fderiv_ofNat (n : ℕ) [OfNat F n] : fderiv 𝕜 (ofNat(n) : E → F) = 0 := fderiv_const _
@[simp, fun_prop]
theorem differentiable_const (c : F) : Differentiable 𝕜 fun _ : E => c := fun _ =>
differentiableAt_const _
@[simp, fun_prop]
theorem differentiable_zero :
Differentiable 𝕜 (0 : E → F) := differentiable_const _
@[simp, fun_prop]
theorem differentiable_one [One F] :
Differentiable 𝕜 (1 : E → F) := differentiable_const _
@[simp, fun_prop]
theorem differentiable_natCast [NatCast F] (n : ℕ) :
Differentiable 𝕜 (n : E → F) := differentiable_const _
@[simp, fun_prop]
theorem differentiable_intCast [IntCast F] (z : ℤ) :
Differentiable 𝕜 (z : E → F) := differentiable_const _
@[simp low, fun_prop]
theorem differentiable_ofNat (n : ℕ) [OfNat F n] :
Differentiable 𝕜 (ofNat(n) : E → F) := differentiable_const _
@[simp, fun_prop]
theorem differentiableOn_const (c : F) : DifferentiableOn 𝕜 (fun _ => c) s :=
(differentiable_const _).differentiableOn
@[simp, fun_prop]
theorem differentiableOn_zero :
DifferentiableOn 𝕜 (0 : E → F) s := differentiableOn_const _
@[simp, fun_prop]
theorem differentiableOn_one [One F] :
DifferentiableOn 𝕜 (1 : E → F) s := differentiableOn_const _
@[simp, fun_prop]
theorem differentiableOn_natCast [NatCast F] (n : ℕ) :
DifferentiableOn 𝕜 (n : E → F) s := differentiableOn_const _
@[simp, fun_prop]
theorem differentiableOn_intCast [IntCast F] (z : ℤ) :
DifferentiableOn 𝕜 (z : E → F) s := differentiableOn_const _
@[simp low, fun_prop]
theorem differentiableOn_ofNat (n : ℕ) [OfNat F n] :
DifferentiableOn 𝕜 (ofNat(n) : E → F) s := differentiableOn_const _
@[fun_prop]
theorem hasFDerivWithinAt_singleton (f : E → F) (x : E) :
HasFDerivWithinAt f (0 : E →L[𝕜] F) {x} x := by
simp only [HasFDerivWithinAt, nhdsWithin_singleton, hasFDerivAtFilter_iff_isLittleO,
isLittleO_pure, ContinuousLinearMap.zero_apply, sub_self]
@[fun_prop]
theorem hasFDerivAt_of_subsingleton [h : Subsingleton E] (f : E → F) (x : E) :
HasFDerivAt f (0 : E →L[𝕜] F) x := by
rw [← hasFDerivWithinAt_univ, subsingleton_univ.eq_singleton_of_mem (mem_univ x)]
exact hasFDerivWithinAt_singleton f x
@[fun_prop]
theorem differentiableOn_empty : DifferentiableOn 𝕜 f ∅ := fun _ => False.elim
@[fun_prop]
theorem differentiableOn_singleton : DifferentiableOn 𝕜 f {x} :=
forall_eq.2 (hasFDerivWithinAt_singleton f x).differentiableWithinAt
@[fun_prop]
theorem Set.Subsingleton.differentiableOn (hs : s.Subsingleton) : DifferentiableOn 𝕜 f s :=
hs.induction_on differentiableOn_empty fun _ => differentiableOn_singleton
theorem hasFDerivAt_zero_of_eventually_const (c : F) (hf : f =ᶠ[𝓝 x] fun _ => c) :
HasFDerivAt f (0 : E →L[𝕜] F) x :=
(hasFDerivAt_const _ _).congr_of_eventuallyEq hf
end Const
theorem differentiableWithinAt_of_isInvertible_fderivWithin
(hf : (fderivWithin 𝕜 f s x).IsInvertible) : DifferentiableWithinAt 𝕜 f s x := by
contrapose hf
rw [fderivWithin_zero_of_not_differentiableWithinAt hf]
contrapose! hf
rcases isInvertible_zero_iff.1 hf with ⟨hE, hF⟩
exact (hasFDerivAt_of_subsingleton _ _).differentiableAt.differentiableWithinAt
theorem differentiableAt_of_isInvertible_fderiv
(hf : (fderiv 𝕜 f x).IsInvertible) : DifferentiableAt 𝕜 f x := by
simp only [← differentiableWithinAt_univ, ← fderivWithin_univ] at hf ⊢
exact differentiableWithinAt_of_isInvertible_fderivWithin hf
/-! ### Support of derivatives -/
section Support
open Function
variable (𝕜 : Type*) {E F : Type*} [NontriviallyNormedField 𝕜] [NormedAddCommGroup E]
[NormedSpace 𝕜 E] [NormedAddCommGroup F] [NormedSpace 𝕜 F] {f : E → F} {x : E}
theorem HasStrictFDerivAt.of_notMem_tsupport (h : x ∉ tsupport f) :
HasStrictFDerivAt f (0 : E →L[𝕜] F) x := by
rw [notMem_tsupport_iff_eventuallyEq] at h
exact (hasStrictFDerivAt_const (0 : F) x).congr_of_eventuallyEq h.symm
@[deprecated (since := "2025-05-24")]
alias HasStrictFDerivAt.of_nmem_tsupport := HasStrictFDerivAt.of_notMem_tsupport
theorem HasFDerivAt.of_notMem_tsupport (h : x ∉ tsupport f) :
HasFDerivAt f (0 : E →L[𝕜] F) x :=
(HasStrictFDerivAt.of_notMem_tsupport 𝕜 h).hasFDerivAt
@[deprecated (since := "2025-05-24")]
alias HasFDerivAt.of_nmem_tsupport := HasFDerivAt.of_notMem_tsupport
theorem HasFDerivWithinAt.of_notMem_tsupport {s : Set E} {x : E} (h : x ∉ tsupport f) :
HasFDerivWithinAt f (0 : E →L[𝕜] F) s x :=
(HasFDerivAt.of_notMem_tsupport 𝕜 h).hasFDerivWithinAt
@[deprecated (since := "2025-05-23")]
alias HasFDerivWithinAt.of_not_mem_tsupport := HasFDerivWithinAt.of_notMem_tsupport
theorem fderiv_of_notMem_tsupport (h : x ∉ tsupport f) : fderiv 𝕜 f x = 0 :=
(HasFDerivAt.of_notMem_tsupport 𝕜 h).fderiv
@[deprecated (since := "2025-05-23")] alias fderiv_of_not_mem_tsupport := fderiv_of_notMem_tsupport
theorem support_fderiv_subset : support (fderiv 𝕜 f) ⊆ tsupport f := fun x ↦ by
rw [← not_imp_not, notMem_support]
exact fderiv_of_notMem_tsupport _
theorem tsupport_fderiv_subset : tsupport (fderiv 𝕜 f) ⊆ tsupport f :=
closure_minimal (support_fderiv_subset 𝕜) isClosed_closure
protected theorem HasCompactSupport.fderiv (hf : HasCompactSupport f) :
HasCompactSupport (fderiv 𝕜 f) :=
hf.mono' <| support_fderiv_subset 𝕜
protected theorem HasCompactSupport.fderiv_apply (hf : HasCompactSupport f) (v : E) :
HasCompactSupport (fderiv 𝕜 f · v) :=
hf.fderiv 𝕜 |>.comp_left (g := fun L : E →L[𝕜] F ↦ L v) rfl
end Support
end |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/FDeriv/Measurable.lean | import Mathlib.Analysis.Calculus.Deriv.Basic
import Mathlib.Analysis.Calculus.Deriv.Slope
import Mathlib.Analysis.Normed.Operator.BoundedLinearMaps
import Mathlib.Analysis.Normed.Module.FiniteDimension
import Mathlib.MeasureTheory.Constructions.BorelSpace.ContinuousLinearMap
import Mathlib.MeasureTheory.Function.StronglyMeasurable.AEStronglyMeasurable
/-!
# Derivative is measurable
In this file we prove that the derivative of any function with complete codomain is a measurable
function. Namely, we prove:
* `measurableSet_of_differentiableAt`: the set `{x | DifferentiableAt 𝕜 f x}` is measurable;
* `measurable_fderiv`: the function `fderiv 𝕜 f` is measurable;
* `measurable_fderiv_apply_const`: for a fixed vector `y`, the function `fun x ↦ fderiv 𝕜 f x y`
is measurable;
* `measurable_deriv`: the function `deriv f` is measurable (for `f : 𝕜 → F`).
We also show the same results for the right derivative on the real line
(see `measurable_derivWithin_Ici` and `measurable_derivWithin_Ioi`), following the same
proof strategy.
We also prove measurability statements for functions depending on a parameter: for `f : α → E → F`,
we show the measurability of `(p : α × E) ↦ fderiv 𝕜 (f p.1) p.2`. This requires additional
assumptions. We give versions of the above statements (appending `with_param` to their names) when
`f` is continuous and `E` is locally compact.
## Implementation
We give a proof that avoids second-countability issues, by expressing the differentiability set
as a function of open sets in the following way. Define `A (L, r, ε)` to be the set of points
where, on a ball of radius roughly `r` around `x`, the function is uniformly approximated by the
linear map `L`, up to `ε r`. It is an open set.
Let also `B (L, r, s, ε) = A (L, r, ε) ∩ A (L, s, ε)`: we require that at two possibly different
scales `r` and `s`, the function is well approximated by the linear map `L`. It is also open.
We claim that the differentiability set of `f` is exactly
`D = ⋂ ε > 0, ⋃ δ > 0, ⋂ r, s < δ, ⋃ L, B (L, r, s, ε)`.
In other words, for any `ε > 0`, we require that there is a size `δ` such that, for any two scales
below this size, the function is well approximated by a linear map, common to the two scales.
The set `⋃ L, B (L, r, s, ε)` is open, as a union of open sets. Converting the intersections and
unions to countable ones (using real numbers of the form `2 ^ (-n)`), it follows that the
differentiability set is measurable.
To prove the claim, there are two inclusions. One is trivial: if the function is differentiable
at `x`, then `x` belongs to `D` (just take `L` to be the derivative, and use that the
differentiability exactly says that the map is well approximated by `L`). This is proved in
`mem_A_of_differentiable` and `differentiable_set_subset_D`.
For the other direction, the difficulty is that `L` in the union may depend on `ε, r, s`. The key
point is that, in fact, it doesn't depend too much on them. First, if `x` belongs both to
`A (L, r, ε)` and `A (L', r, ε)`, then `L` and `L'` have to be close on a shell, and thus
`‖L - L'‖` is bounded by `ε` (see `norm_sub_le_of_mem_A`). Assume now `x ∈ D`. If one has two maps
`L` and `L'` such that `x` belongs to `A (L, r, ε)` and to `A (L', r', ε')`, one deduces that `L` is
close to `L'` by arguing as follows. Consider another scale `s` smaller than `r` and `r'`. Take a
linear map `L₁` that approximates `f` around `x` both at scales `r` and `s` w.r.t. `ε` (it exists as
`x` belongs to `D`). Take also `L₂` that approximates `f` around `x` both at scales `r'` and `s`
w.r.t. `ε'`. Then `L₁` is close to `L` (as they are close on a shell of radius `r`), and `L₂` is
close to `L₁` (as they are close on a shell of radius `s`), and `L'` is close to `L₂` (as they are
close on a shell of radius `r'`). It follows that `L` is close to `L'`, as we claimed.
It follows that the different approximating linear maps that show up form a Cauchy sequence when
`ε` tends to `0`. When the target space is complete, this sequence converges, to a limit `f'`.
With the same kind of arguments, one checks that `f` is differentiable with derivative `f'`.
To show that the derivative itself is measurable, add in the definition of `B` and `D` a set
`K` of continuous linear maps to which `L` should belong. Then, when `K` is complete, the set `D K`
is exactly the set of points where `f` is differentiable with a derivative in `K`.
## Tags
derivative, measurable function, Borel σ-algebra
-/
noncomputable section
open Set Metric Asymptotics Filter ContinuousLinearMap MeasureTheory TopologicalSpace
open scoped Topology
namespace ContinuousLinearMap
variable {𝕜 E F : Type*} [NontriviallyNormedField 𝕜] [NormedAddCommGroup E] [NormedSpace 𝕜 E]
[NormedAddCommGroup F] [NormedSpace 𝕜 F]
theorem measurable_apply₂ [MeasurableSpace E] [OpensMeasurableSpace E]
[SecondCountableTopologyEither (E →L[𝕜] F) E]
[MeasurableSpace F] [BorelSpace F] : Measurable fun p : (E →L[𝕜] F) × E => p.1 p.2 :=
isBoundedBilinearMap_apply.continuous.measurable
end ContinuousLinearMap
section fderiv
variable {𝕜 : Type*} [NontriviallyNormedField 𝕜]
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E]
variable {F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F]
variable {f : E → F} (K : Set (E →L[𝕜] F))
namespace FDerivMeasurableAux
/-- The set `A f L r ε` is the set of points `x` around which the function `f` is well approximated
at scale `r` by the linear map `L`, up to an error `ε`. We tweak the definition to make sure that
this is an open set. -/
def A (f : E → F) (L : E →L[𝕜] F) (r ε : ℝ) : Set E :=
{ x | ∃ r' ∈ Ioc (r / 2) r, ∀ y ∈ ball x r', ∀ z ∈ ball x r', ‖f z - f y - L (z - y)‖ < ε * r }
/-- The set `B f K r s ε` is the set of points `x` around which there exists a continuous linear map
`L` belonging to `K` (a given set of continuous linear maps) that approximates well the
function `f` (up to an error `ε`), simultaneously at scales `r` and `s`. -/
def B (f : E → F) (K : Set (E →L[𝕜] F)) (r s ε : ℝ) : Set E :=
⋃ L ∈ K, A f L r ε ∩ A f L s ε
/-- The set `D f K` is a complicated set constructed using countable intersections and unions. Its
main use is that, when `K` is complete, it is exactly the set of points where `f` is differentiable,
with a derivative in `K`. -/
def D (f : E → F) (K : Set (E →L[𝕜] F)) : Set E :=
⋂ e : ℕ, ⋃ n : ℕ, ⋂ (p ≥ n) (q ≥ n), B f K ((1 / 2) ^ p) ((1 / 2) ^ q) ((1 / 2) ^ e)
theorem isOpen_A (L : E →L[𝕜] F) (r ε : ℝ) : IsOpen (A f L r ε) := by
rw [Metric.isOpen_iff]
rintro x ⟨r', r'_mem, hr'⟩
obtain ⟨s, s_gt, s_lt⟩ : ∃ s : ℝ, r / 2 < s ∧ s < r' := exists_between r'_mem.1
have : s ∈ Ioc (r / 2) r := ⟨s_gt, le_of_lt (s_lt.trans_le r'_mem.2)⟩
refine ⟨r' - s, by linarith, fun x' hx' => ⟨s, this, ?_⟩⟩
have B : ball x' s ⊆ ball x r' := ball_subset (le_of_lt hx')
intro y hy z hz
exact hr' y (B hy) z (B hz)
theorem isOpen_B {K : Set (E →L[𝕜] F)} {r s ε : ℝ} : IsOpen (B f K r s ε) := by
simp [B, isOpen_biUnion, IsOpen.inter, isOpen_A]
theorem A_mono (L : E →L[𝕜] F) (r : ℝ) {ε δ : ℝ} (h : ε ≤ δ) : A f L r ε ⊆ A f L r δ := by
rintro x ⟨r', r'r, hr'⟩
refine ⟨r', r'r, fun y hy z hz => (hr' y hy z hz).trans_le (mul_le_mul_of_nonneg_right h ?_)⟩
linarith [mem_ball.1 hy, r'r.2, @dist_nonneg _ _ y x]
theorem le_of_mem_A {r ε : ℝ} {L : E →L[𝕜] F} {x : E} (hx : x ∈ A f L r ε) {y z : E}
(hy : y ∈ closedBall x (r / 2)) (hz : z ∈ closedBall x (r / 2)) :
‖f z - f y - L (z - y)‖ ≤ ε * r := by
rcases hx with ⟨r', r'mem, hr'⟩
apply le_of_lt
exact hr' _ ((mem_closedBall.1 hy).trans_lt r'mem.1) _ ((mem_closedBall.1 hz).trans_lt r'mem.1)
theorem mem_A_of_differentiable {ε : ℝ} (hε : 0 < ε) {x : E} (hx : DifferentiableAt 𝕜 f x) :
∃ R > 0, ∀ r ∈ Ioo (0 : ℝ) R, x ∈ A f (fderiv 𝕜 f x) r ε := by
let δ := (ε / 2) / 2
obtain ⟨R, R_pos, hR⟩ :
∃ R > 0, ∀ y ∈ ball x R, ‖f y - f x - fderiv 𝕜 f x (y - x)‖ ≤ δ * ‖y - x‖ :=
eventually_nhds_iff_ball.1 <| hx.hasFDerivAt.isLittleO.bound <| by positivity
refine ⟨R, R_pos, fun r hr => ?_⟩
have : r ∈ Ioc (r / 2) r := right_mem_Ioc.2 <| half_lt_self hr.1
refine ⟨r, this, fun y hy z hz => ?_⟩
calc
‖f z - f y - (fderiv 𝕜 f x) (z - y)‖ =
‖f z - f x - (fderiv 𝕜 f x) (z - x) - (f y - f x - (fderiv 𝕜 f x) (y - x))‖ := by
simp only [map_sub]; abel_nf
_ ≤ ‖f z - f x - (fderiv 𝕜 f x) (z - x)‖ + ‖f y - f x - (fderiv 𝕜 f x) (y - x)‖ :=
norm_sub_le _ _
_ ≤ δ * ‖z - x‖ + δ * ‖y - x‖ :=
add_le_add (hR _ (ball_subset_ball hr.2.le hz)) (hR _ (ball_subset_ball hr.2.le hy))
_ ≤ δ * r + δ * r := by rw [mem_ball_iff_norm] at hz hy; gcongr
_ = (ε / 2) * r := by ring
_ < ε * r := by gcongr; exacts [hr.1, half_lt_self hε]
theorem norm_sub_le_of_mem_A {c : 𝕜} (hc : 1 < ‖c‖) {r ε : ℝ} (hε : 0 < ε) (hr : 0 < r) {x : E}
{L₁ L₂ : E →L[𝕜] F} (h₁ : x ∈ A f L₁ r ε) (h₂ : x ∈ A f L₂ r ε) : ‖L₁ - L₂‖ ≤ 4 * ‖c‖ * ε := by
refine opNorm_le_of_shell (half_pos hr) (by positivity) hc ?_
intro y ley ylt
rw [div_div, div_le_iff₀' (by positivity)] at ley
calc
‖(L₁ - L₂) y‖ = ‖f (x + y) - f x - L₂ (x + y - x) - (f (x + y) - f x - L₁ (x + y - x))‖ := by
simp
_ ≤ ‖f (x + y) - f x - L₂ (x + y - x)‖ + ‖f (x + y) - f x - L₁ (x + y - x)‖ := norm_sub_le _ _
_ ≤ ε * r + ε * r := by
apply add_le_add
· apply le_of_mem_A h₂
· simp only [le_of_lt (half_pos hr), mem_closedBall, dist_self]
· simp only [dist_eq_norm, add_sub_cancel_left, mem_closedBall, ylt.le]
· apply le_of_mem_A h₁
· simp only [le_of_lt (half_pos hr), mem_closedBall, dist_self]
· simp only [dist_eq_norm, add_sub_cancel_left, mem_closedBall, ylt.le]
_ = 2 * ε * r := by ring
_ ≤ 2 * ε * (2 * ‖c‖ * ‖y‖) := by gcongr
_ = 4 * ‖c‖ * ε * ‖y‖ := by ring
/-- Easy inclusion: a differentiability point with derivative in `K` belongs to `D f K`. -/
theorem differentiable_set_subset_D :
{ x | DifferentiableAt 𝕜 f x ∧ fderiv 𝕜 f x ∈ K } ⊆ D f K := by
intro x hx
rw [D, mem_iInter]
intro e
have : (0 : ℝ) < (1 / 2) ^ e := by positivity
rcases mem_A_of_differentiable this hx.1 with ⟨R, R_pos, hR⟩
obtain ⟨n, hn⟩ : ∃ n : ℕ, (1 / 2) ^ n < R :=
exists_pow_lt_of_lt_one R_pos (by norm_num : (1 : ℝ) / 2 < 1)
simp only [mem_iUnion, mem_iInter, B, mem_inter_iff]
refine ⟨n, fun p hp q hq => ⟨fderiv 𝕜 f x, hx.2, ⟨?_, ?_⟩⟩⟩ <;>
· refine hR _ ⟨by positivity, lt_of_le_of_lt ?_ hn⟩
exact pow_le_pow_of_le_one (by norm_num) (by norm_num) (by assumption)
/-- Harder inclusion: at a point in `D f K`, the function `f` has a derivative, in `K`. -/
theorem D_subset_differentiable_set {K : Set (E →L[𝕜] F)} (hK : IsComplete K) :
D f K ⊆ { x | DifferentiableAt 𝕜 f x ∧ fderiv 𝕜 f x ∈ K } := by
have P : ∀ {n : ℕ}, (0 : ℝ) < (1 / 2) ^ n := fun {n} => pow_pos (by norm_num) n
rcases NormedField.exists_one_lt_norm 𝕜 with ⟨c, hc⟩
intro x hx
have :
∀ e : ℕ, ∃ n : ℕ, ∀ p q, n ≤ p → n ≤ q →
∃ L ∈ K, x ∈ A f L ((1 / 2) ^ p) ((1 / 2) ^ e) ∩ A f L ((1 / 2) ^ q) ((1 / 2) ^ e) := by
intro e
have := mem_iInter.1 hx e
rcases mem_iUnion.1 this with ⟨n, hn⟩
refine ⟨n, fun p q hp hq => ?_⟩
simp only [mem_iInter] at hn
rcases mem_iUnion.1 (hn p hp q hq) with ⟨L, hL⟩
exact ⟨L, exists_prop.mp <| mem_iUnion.1 hL⟩
/- Recast the assumptions: for each `e`, there exist `n e` and linear maps `L e p q` in `K`
such that, for `p, q ≥ n e`, then `f` is well approximated by `L e p q` at scale `2 ^ (-p)` and
`2 ^ (-q)`, with an error `2 ^ (-e)`. -/
choose! n L hn using this
/- All the operators `L e p q` that show up are close to each other. To prove this, we argue
that `L e p q` is close to `L e p r` (where `r` is large enough), as both approximate `f` at
scale `2 ^(- p)`. And `L e p r` is close to `L e' p' r` as both approximate `f` at scale
`2 ^ (- r)`. And `L e' p' r` is close to `L e' p' q'` as both approximate `f` at scale
`2 ^ (- p')`. -/
have M :
∀ e p q e' p' q',
n e ≤ p →
n e ≤ q →
n e' ≤ p' → n e' ≤ q' → e ≤ e' → ‖L e p q - L e' p' q'‖ ≤ 12 * ‖c‖ * (1 / 2) ^ e := by
intro e p q e' p' q' hp hq hp' hq' he'
let r := max (n e) (n e')
have I : ((1 : ℝ) / 2) ^ e' ≤ (1 / 2) ^ e :=
pow_le_pow_of_le_one (by norm_num) (by norm_num) he'
have J1 : ‖L e p q - L e p r‖ ≤ 4 * ‖c‖ * (1 / 2) ^ e := by
have I1 : x ∈ A f (L e p q) ((1 / 2) ^ p) ((1 / 2) ^ e) := (hn e p q hp hq).2.1
have I2 : x ∈ A f (L e p r) ((1 / 2) ^ p) ((1 / 2) ^ e) := (hn e p r hp (le_max_left _ _)).2.1
exact norm_sub_le_of_mem_A hc P P I1 I2
have J2 : ‖L e p r - L e' p' r‖ ≤ 4 * ‖c‖ * (1 / 2) ^ e := by
have I1 : x ∈ A f (L e p r) ((1 / 2) ^ r) ((1 / 2) ^ e) := (hn e p r hp (le_max_left _ _)).2.2
have I2 : x ∈ A f (L e' p' r) ((1 / 2) ^ r) ((1 / 2) ^ e') :=
(hn e' p' r hp' (le_max_right _ _)).2.2
exact norm_sub_le_of_mem_A hc P P I1 (A_mono _ _ I I2)
have J3 : ‖L e' p' r - L e' p' q'‖ ≤ 4 * ‖c‖ * (1 / 2) ^ e := by
have I1 : x ∈ A f (L e' p' r) ((1 / 2) ^ p') ((1 / 2) ^ e') :=
(hn e' p' r hp' (le_max_right _ _)).2.1
have I2 : x ∈ A f (L e' p' q') ((1 / 2) ^ p') ((1 / 2) ^ e') := (hn e' p' q' hp' hq').2.1
exact norm_sub_le_of_mem_A hc P P (A_mono _ _ I I1) (A_mono _ _ I I2)
calc
‖L e p q - L e' p' q'‖ =
‖L e p q - L e p r + (L e p r - L e' p' r) + (L e' p' r - L e' p' q')‖ := by
congr 1; abel
_ ≤ ‖L e p q - L e p r‖ + ‖L e p r - L e' p' r‖ + ‖L e' p' r - L e' p' q'‖ :=
norm_add₃_le
_ ≤ 4 * ‖c‖ * (1 / 2) ^ e + 4 * ‖c‖ * (1 / 2) ^ e + 4 * ‖c‖ * (1 / 2) ^ e := by gcongr
_ = 12 * ‖c‖ * (1 / 2) ^ e := by ring
/- For definiteness, use `L0 e = L e (n e) (n e)`, to have a single sequence. We claim that this
is a Cauchy sequence. -/
let L0 : ℕ → E →L[𝕜] F := fun e => L e (n e) (n e)
have : CauchySeq L0 := by
rw [Metric.cauchySeq_iff']
intro ε εpos
obtain ⟨e, he⟩ : ∃ e : ℕ, (1 / 2) ^ e < ε / (12 * ‖c‖) :=
exists_pow_lt_of_lt_one (by positivity) (by norm_num)
refine ⟨e, fun e' he' => ?_⟩
rw [dist_comm, dist_eq_norm]
calc
‖L0 e - L0 e'‖ ≤ 12 * ‖c‖ * (1 / 2) ^ e := M _ _ _ _ _ _ le_rfl le_rfl le_rfl le_rfl he'
_ < 12 * ‖c‖ * (ε / (12 * ‖c‖)) := by gcongr
_ = ε := by field
-- As it is Cauchy, the sequence `L0` converges, to a limit `f'` in `K`.
obtain ⟨f', f'K, hf'⟩ : ∃ f' ∈ K, Tendsto L0 atTop (𝓝 f') :=
cauchySeq_tendsto_of_isComplete hK (fun e => (hn e (n e) (n e) le_rfl le_rfl).1) this
have Lf' : ∀ e p, n e ≤ p → ‖L e (n e) p - f'‖ ≤ 12 * ‖c‖ * (1 / 2) ^ e := by
intro e p hp
apply le_of_tendsto (tendsto_const_nhds.sub hf').norm
rw [eventually_atTop]
exact ⟨e, fun e' he' => M _ _ _ _ _ _ le_rfl hp le_rfl le_rfl he'⟩
-- Let us show that `f` has derivative `f'` at `x`.
have : HasFDerivAt f f' x := by
simp only [hasFDerivAt_iff_isLittleO_nhds_zero, isLittleO_iff]
/- to get an approximation with a precision `ε`, we will replace `f` with `L e (n e) m` for
some large enough `e` (yielding a small error by uniform approximation). As one can vary `m`,
this makes it possible to cover all scales, and thus to obtain a good linear approximation in
the whole ball of radius `(1/2)^(n e)`. -/
intro ε εpos
have pos : 0 < 4 + 12 * ‖c‖ := by positivity
obtain ⟨e, he⟩ : ∃ e : ℕ, (1 / 2) ^ e < ε / (4 + 12 * ‖c‖) :=
exists_pow_lt_of_lt_one (div_pos εpos pos) (by norm_num)
rw [eventually_nhds_iff_ball]
refine ⟨(1 / 2) ^ (n e + 1), P, fun y hy => ?_⟩
-- We need to show that `f (x + y) - f x - f' y` is small. For this, we will work at scale
-- `k` where `k` is chosen with `‖y‖ ∼ 2 ^ (-k)`.
by_cases y_pos : y = 0
· simp [y_pos]
have yzero : 0 < ‖y‖ := norm_pos_iff.mpr y_pos
have y_lt : ‖y‖ < (1 / 2) ^ (n e + 1) := by simpa using mem_ball_iff_norm.1 hy
have yone : ‖y‖ ≤ 1 := le_trans y_lt.le (pow_le_one₀ (by norm_num) (by norm_num))
-- define the scale `k`.
obtain ⟨k, hk, h'k⟩ : ∃ k : ℕ, (1 / 2) ^ (k + 1) < ‖y‖ ∧ ‖y‖ ≤ (1 / 2) ^ k :=
exists_nat_pow_near_of_lt_one yzero yone (by norm_num : (0 : ℝ) < 1 / 2)
(by norm_num : (1 : ℝ) / 2 < 1)
-- the scale is large enough (as `y` is small enough)
have k_gt : n e < k := by
have : ((1 : ℝ) / 2) ^ (k + 1) < (1 / 2) ^ (n e + 1) := lt_trans hk y_lt
rw [pow_lt_pow_iff_right_of_lt_one₀ (by norm_num : (0 : ℝ) < 1 / 2) (by norm_num)] at this
omega
set m := k - 1
have m_ge : n e ≤ m := Nat.le_sub_one_of_lt k_gt
have km : k = m + 1 := (Nat.succ_pred_eq_of_pos (lt_of_le_of_lt (zero_le _) k_gt)).symm
rw [km] at hk h'k
-- `f` is well approximated by `L e (n e) k` at the relevant scale
-- (in fact, we use `m = k - 1` instead of `k` because of the precise definition of `A`).
have J1 : ‖f (x + y) - f x - L e (n e) m (x + y - x)‖ ≤ (1 / 2) ^ e * (1 / 2) ^ m := by
apply le_of_mem_A (hn e (n e) m le_rfl m_ge).2.2
· simp only [mem_closedBall, dist_self]
positivity
· simpa only [dist_eq_norm, add_sub_cancel_left, mem_closedBall, pow_succ, mul_one_div] using
h'k
have J2 : ‖f (x + y) - f x - L e (n e) m y‖ ≤ 4 * (1 / 2) ^ e * ‖y‖ :=
calc
‖f (x + y) - f x - L e (n e) m y‖ ≤ (1 / 2) ^ e * (1 / 2) ^ m := by
simpa only [add_sub_cancel_left] using J1
_ = 4 * (1 / 2) ^ e * (1 / 2) ^ (m + 2) := by ring
_ ≤ 4 * (1 / 2) ^ e * ‖y‖ := by gcongr
-- use the previous estimates to see that `f (x + y) - f x - f' y` is small.
calc
‖f (x + y) - f x - f' y‖ = ‖f (x + y) - f x - L e (n e) m y + (L e (n e) m - f') y‖ :=
congr_arg _ (by simp)
_ ≤ 4 * (1 / 2) ^ e * ‖y‖ + 12 * ‖c‖ * (1 / 2) ^ e * ‖y‖ :=
norm_add_le_of_le J2 <| (le_opNorm _ _).trans <| by gcongr; exact Lf' _ _ m_ge
_ = (4 + 12 * ‖c‖) * ‖y‖ * (1 / 2) ^ e := by ring
_ ≤ (4 + 12 * ‖c‖) * ‖y‖ * (ε / (4 + 12 * ‖c‖)) := by gcongr
_ = ε * ‖y‖ := by field
rw [← this.fderiv] at f'K
exact ⟨this.differentiableAt, f'K⟩
theorem differentiable_set_eq_D (hK : IsComplete K) :
{ x | DifferentiableAt 𝕜 f x ∧ fderiv 𝕜 f x ∈ K } = D f K :=
Subset.antisymm (differentiable_set_subset_D _) (D_subset_differentiable_set hK)
end FDerivMeasurableAux
open FDerivMeasurableAux
variable [MeasurableSpace E] [OpensMeasurableSpace E]
variable (𝕜 f)
/-- The set of differentiability points of a function, with derivative in a given complete set,
is Borel-measurable. -/
theorem measurableSet_of_differentiableAt_of_isComplete {K : Set (E →L[𝕜] F)} (hK : IsComplete K) :
MeasurableSet { x | DifferentiableAt 𝕜 f x ∧ fderiv 𝕜 f x ∈ K } := by
simp only [D, differentiable_set_eq_D K hK]
aesop
(add safe apply [MeasurableSet.iUnion, MeasurableSet.iInter, isOpen_B])
(add unsafe IsOpen.measurableSet)
variable [CompleteSpace F]
/-- The set of differentiability points of a function taking values in a complete space is
Borel-measurable. -/
theorem measurableSet_of_differentiableAt : MeasurableSet { x | DifferentiableAt 𝕜 f x } := by
have : IsComplete (univ : Set (E →L[𝕜] F)) := complete_univ
convert measurableSet_of_differentiableAt_of_isComplete 𝕜 f this
simp
@[measurability, fun_prop]
theorem measurable_fderiv : Measurable (fderiv 𝕜 f) := by
refine measurable_of_isClosed fun s hs => ?_
have :
fderiv 𝕜 f ⁻¹' s =
{ x | DifferentiableAt 𝕜 f x ∧ fderiv 𝕜 f x ∈ s } ∪
{ x | ¬DifferentiableAt 𝕜 f x } ∩ { _x | (0 : E →L[𝕜] F) ∈ s } :=
Set.ext fun x => mem_preimage.trans fderiv_mem_iff
rw [this]
exact
(measurableSet_of_differentiableAt_of_isComplete _ _ hs.isComplete).union
((measurableSet_of_differentiableAt _ _).compl.inter (MeasurableSet.const _))
@[measurability, fun_prop]
theorem measurable_fderiv_apply_const [MeasurableSpace F] [BorelSpace F] (y : E) :
Measurable fun x => fderiv 𝕜 f x y :=
(ContinuousLinearMap.measurable_apply y).comp (measurable_fderiv 𝕜 f)
variable {𝕜}
@[measurability, fun_prop]
theorem measurable_deriv [MeasurableSpace 𝕜] [OpensMeasurableSpace 𝕜] [MeasurableSpace F]
[BorelSpace F] (f : 𝕜 → F) : Measurable (deriv f) := by
simpa only [fderiv_deriv] using measurable_fderiv_apply_const 𝕜 f 1
theorem stronglyMeasurable_deriv [MeasurableSpace 𝕜] [OpensMeasurableSpace 𝕜]
[h : SecondCountableTopologyEither 𝕜 F] (f : 𝕜 → F) : StronglyMeasurable (deriv f) := by
borelize F
rcases h.out with h𝕜|hF
· exact stronglyMeasurable_iff_measurable_separable.2
⟨measurable_deriv f, isSeparable_range_deriv _⟩
· exact (measurable_deriv f).stronglyMeasurable
theorem aemeasurable_deriv [MeasurableSpace 𝕜] [OpensMeasurableSpace 𝕜] [MeasurableSpace F]
[BorelSpace F] (f : 𝕜 → F) (μ : Measure 𝕜) : AEMeasurable (deriv f) μ :=
(measurable_deriv f).aemeasurable
theorem aestronglyMeasurable_deriv [MeasurableSpace 𝕜] [OpensMeasurableSpace 𝕜]
[SecondCountableTopologyEither 𝕜 F] (f : 𝕜 → F) (μ : Measure 𝕜) :
AEStronglyMeasurable (deriv f) μ :=
(stronglyMeasurable_deriv f).aestronglyMeasurable
end fderiv
section RightDeriv
variable {F : Type*} [NormedAddCommGroup F] [NormedSpace ℝ F]
variable {f : ℝ → F} (K : Set F)
namespace RightDerivMeasurableAux
/-- The set `A f L r ε` is the set of points `x` around which the function `f` is well approximated
at scale `r` by the linear map `h ↦ h • L`, up to an error `ε`. We tweak the definition to
make sure that this is open on the right. -/
def A (f : ℝ → F) (L : F) (r ε : ℝ) : Set ℝ :=
{ x | ∃ r' ∈ Ioc (r / 2) r, ∀ᵉ (y ∈ Icc x (x + r')) (z ∈ Icc x (x + r')),
‖f z - f y - (z - y) • L‖ ≤ ε * r }
/-- The set `B f K r s ε` is the set of points `x` around which there exists a vector
`L` belonging to `K` (a given set of vectors) such that `h • L` approximates well `f (x + h)`
(up to an error `ε`), simultaneously at scales `r` and `s`. -/
def B (f : ℝ → F) (K : Set F) (r s ε : ℝ) : Set ℝ :=
⋃ L ∈ K, A f L r ε ∩ A f L s ε
/-- The set `D f K` is a complicated set constructed using countable intersections and unions. Its
main use is that, when `K` is complete, it is exactly the set of points where `f` is differentiable,
with a derivative in `K`. -/
def D (f : ℝ → F) (K : Set F) : Set ℝ :=
⋂ e : ℕ, ⋃ n : ℕ, ⋂ (p ≥ n) (q ≥ n), B f K ((1 / 2) ^ p) ((1 / 2) ^ q) ((1 / 2) ^ e)
theorem A_mem_nhdsGT {L : F} {r ε x : ℝ} (hx : x ∈ A f L r ε) : A f L r ε ∈ 𝓝[>] x := by
rcases hx with ⟨r', rr', hr'⟩
obtain ⟨s, s_gt, s_lt⟩ : ∃ s : ℝ, r / 2 < s ∧ s < r' := exists_between rr'.1
have : s ∈ Ioc (r / 2) r := ⟨s_gt, le_of_lt (s_lt.trans_le rr'.2)⟩
filter_upwards [Ioo_mem_nhdsGT <| show x < x + r' - s by linarith] with x' hx'
use s, this
have A : Icc x' (x' + s) ⊆ Icc x (x + r') := by
apply Icc_subset_Icc hx'.1.le
linarith [hx'.2]
intro y hy z hz
exact hr' y (A hy) z (A hz)
theorem B_mem_nhdsGT {K : Set F} {r s ε x : ℝ} (hx : x ∈ B f K r s ε) :
B f K r s ε ∈ 𝓝[>] x := by
obtain ⟨L, LK, hL₁, hL₂⟩ : ∃ L : F, L ∈ K ∧ x ∈ A f L r ε ∧ x ∈ A f L s ε := by
simpa only [B, mem_iUnion, mem_inter_iff, exists_prop] using hx
filter_upwards [A_mem_nhdsGT hL₁, A_mem_nhdsGT hL₂] with y hy₁ hy₂
simp only [B, mem_iUnion, mem_inter_iff, exists_prop]
exact ⟨L, LK, hy₁, hy₂⟩
theorem measurableSet_B {K : Set F} {r s ε : ℝ} : MeasurableSet (B f K r s ε) :=
.of_mem_nhdsGT fun _ hx => B_mem_nhdsGT hx
theorem A_mono (L : F) (r : ℝ) {ε δ : ℝ} (h : ε ≤ δ) : A f L r ε ⊆ A f L r δ := by
rintro x ⟨r', r'r, hr'⟩
refine ⟨r', r'r, fun y hy z hz => (hr' y hy z hz).trans (mul_le_mul_of_nonneg_right h ?_)⟩
linarith [hy.1, hy.2, r'r.2]
theorem le_of_mem_A {r ε : ℝ} {L : F} {x : ℝ} (hx : x ∈ A f L r ε) {y z : ℝ}
(hy : y ∈ Icc x (x + r / 2)) (hz : z ∈ Icc x (x + r / 2)) :
‖f z - f y - (z - y) • L‖ ≤ ε * r := by
rcases hx with ⟨r', r'mem, hr'⟩
have A : x + r / 2 ≤ x + r' := by linarith [r'mem.1]
exact hr' _ ((Icc_subset_Icc le_rfl A) hy) _ ((Icc_subset_Icc le_rfl A) hz)
theorem mem_A_of_differentiable {ε : ℝ} (hε : 0 < ε) {x : ℝ}
(hx : DifferentiableWithinAt ℝ f (Ici x) x) :
∃ R > 0, ∀ r ∈ Ioo (0 : ℝ) R, x ∈ A f (derivWithin f (Ici x) x) r ε := by
have := hx.hasDerivWithinAt
simp_rw [hasDerivWithinAt_iff_isLittleO, isLittleO_iff] at this
rcases mem_nhdsGE_iff_exists_Ico_subset.1 (this (half_pos hε)) with ⟨m, xm, hm⟩
refine ⟨m - x, by linarith [show x < m from xm], fun r hr => ?_⟩
have : r ∈ Ioc (r / 2) r := ⟨half_lt_self hr.1, le_rfl⟩
refine ⟨r, this, fun y hy z hz => ?_⟩
calc
‖f z - f y - (z - y) • derivWithin f (Ici x) x‖ =
‖f z - f x - (z - x) • derivWithin f (Ici x) x -
(f y - f x - (y - x) • derivWithin f (Ici x) x)‖ := by
congr 1; simp only [sub_smul]; abel
_ ≤
‖f z - f x - (z - x) • derivWithin f (Ici x) x‖ +
‖f y - f x - (y - x) • derivWithin f (Ici x) x‖ :=
(norm_sub_le _ _)
_ ≤ ε / 2 * ‖z - x‖ + ε / 2 * ‖y - x‖ :=
(add_le_add (hm ⟨hz.1, hz.2.trans_lt (by linarith [hr.2])⟩)
(hm ⟨hy.1, hy.2.trans_lt (by linarith [hr.2])⟩))
_ ≤ ε / 2 * r + ε / 2 * r := by
gcongr
· rw [Real.norm_of_nonneg] <;> linarith [hz.1, hz.2]
· rw [Real.norm_of_nonneg] <;> linarith [hy.1, hy.2]
_ = ε * r := by ring
theorem norm_sub_le_of_mem_A {r x : ℝ} (hr : 0 < r) (ε : ℝ) {L₁ L₂ : F} (h₁ : x ∈ A f L₁ r ε)
(h₂ : x ∈ A f L₂ r ε) : ‖L₁ - L₂‖ ≤ 4 * ε := by
suffices H : ‖(r / 2) • (L₁ - L₂)‖ ≤ r / 2 * (4 * ε) by
rwa [norm_smul, Real.norm_of_nonneg (half_pos hr).le, mul_le_mul_iff_right₀ (half_pos hr)] at H
calc
‖(r / 2) • (L₁ - L₂)‖ =
‖f (x + r / 2) - f x - (x + r / 2 - x) • L₂ -
(f (x + r / 2) - f x - (x + r / 2 - x) • L₁)‖ := by
simp [smul_sub]
_ ≤ ‖f (x + r / 2) - f x - (x + r / 2 - x) • L₂‖ +
‖f (x + r / 2) - f x - (x + r / 2 - x) • L₁‖ :=
norm_sub_le _ _
_ ≤ ε * r + ε * r := by
apply add_le_add
· apply le_of_mem_A h₂ <;> simp [(half_pos hr).le]
· apply le_of_mem_A h₁ <;> simp [(half_pos hr).le]
_ = r / 2 * (4 * ε) := by ring
/-- Easy inclusion: a differentiability point with derivative in `K` belongs to `D f K`. -/
theorem differentiable_set_subset_D :
{ x | DifferentiableWithinAt ℝ f (Ici x) x ∧ derivWithin f (Ici x) x ∈ K } ⊆ D f K := by
intro x hx
rw [D, mem_iInter]
intro e
have : (0 : ℝ) < (1 / 2) ^ e := pow_pos (by norm_num) _
rcases mem_A_of_differentiable this hx.1 with ⟨R, R_pos, hR⟩
obtain ⟨n, hn⟩ : ∃ n : ℕ, (1 / 2) ^ n < R :=
exists_pow_lt_of_lt_one R_pos (by norm_num : (1 : ℝ) / 2 < 1)
simp only [mem_iUnion, mem_iInter, B, mem_inter_iff]
refine ⟨n, fun p hp q hq => ⟨derivWithin f (Ici x) x, hx.2, ⟨?_, ?_⟩⟩⟩ <;>
· refine hR _ ⟨pow_pos (by norm_num) _, lt_of_le_of_lt ?_ hn⟩
exact pow_le_pow_of_le_one (by norm_num) (by norm_num) (by assumption)
/-- Harder inclusion: at a point in `D f K`, the function `f` has a derivative, in `K`. -/
theorem D_subset_differentiable_set {K : Set F} (hK : IsComplete K) :
D f K ⊆ { x | DifferentiableWithinAt ℝ f (Ici x) x ∧ derivWithin f (Ici x) x ∈ K } := by
have P : ∀ {n : ℕ}, (0 : ℝ) < (1 / 2) ^ n := fun {n} => pow_pos (by norm_num) n
intro x hx
have :
∀ e : ℕ, ∃ n : ℕ, ∀ p q, n ≤ p → n ≤ q →
∃ L ∈ K, x ∈ A f L ((1 / 2) ^ p) ((1 / 2) ^ e) ∩ A f L ((1 / 2) ^ q) ((1 / 2) ^ e) := by
intro e
have := mem_iInter.1 hx e
rcases mem_iUnion.1 this with ⟨n, hn⟩
refine ⟨n, fun p q hp hq => ?_⟩
simp only [mem_iInter] at hn
rcases mem_iUnion.1 (hn p hp q hq) with ⟨L, hL⟩
exact ⟨L, exists_prop.mp <| mem_iUnion.1 hL⟩
/- Recast the assumptions: for each `e`, there exist `n e` and linear maps `L e p q` in `K`
such that, for `p, q ≥ n e`, then `f` is well approximated by `L e p q` at scale `2 ^ (-p)` and
`2 ^ (-q)`, with an error `2 ^ (-e)`. -/
choose! n L hn using this
/- All the operators `L e p q` that show up are close to each other. To prove this, we argue
that `L e p q` is close to `L e p r` (where `r` is large enough), as both approximate `f` at
scale `2 ^(- p)`. And `L e p r` is close to `L e' p' r` as both approximate `f` at scale
`2 ^ (- r)`. And `L e' p' r` is close to `L e' p' q'` as both approximate `f` at scale
`2 ^ (- p')`. -/
have M :
∀ e p q e' p' q',
n e ≤ p →
n e ≤ q → n e' ≤ p' → n e' ≤ q' → e ≤ e' → ‖L e p q - L e' p' q'‖ ≤ 12 * (1 / 2) ^ e := by
intro e p q e' p' q' hp hq hp' hq' he'
let r := max (n e) (n e')
have I : ((1 : ℝ) / 2) ^ e' ≤ (1 / 2) ^ e :=
pow_le_pow_of_le_one (by norm_num) (by norm_num) he'
have J1 : ‖L e p q - L e p r‖ ≤ 4 * (1 / 2) ^ e := by
have I1 : x ∈ A f (L e p q) ((1 / 2) ^ p) ((1 / 2) ^ e) := (hn e p q hp hq).2.1
have I2 : x ∈ A f (L e p r) ((1 / 2) ^ p) ((1 / 2) ^ e) := (hn e p r hp (le_max_left _ _)).2.1
exact norm_sub_le_of_mem_A P _ I1 I2
have J2 : ‖L e p r - L e' p' r‖ ≤ 4 * (1 / 2) ^ e := by
have I1 : x ∈ A f (L e p r) ((1 / 2) ^ r) ((1 / 2) ^ e) := (hn e p r hp (le_max_left _ _)).2.2
have I2 : x ∈ A f (L e' p' r) ((1 / 2) ^ r) ((1 / 2) ^ e') :=
(hn e' p' r hp' (le_max_right _ _)).2.2
exact norm_sub_le_of_mem_A P _ I1 (A_mono _ _ I I2)
have J3 : ‖L e' p' r - L e' p' q'‖ ≤ 4 * (1 / 2) ^ e := by
have I1 : x ∈ A f (L e' p' r) ((1 / 2) ^ p') ((1 / 2) ^ e') :=
(hn e' p' r hp' (le_max_right _ _)).2.1
have I2 : x ∈ A f (L e' p' q') ((1 / 2) ^ p') ((1 / 2) ^ e') := (hn e' p' q' hp' hq').2.1
exact norm_sub_le_of_mem_A P _ (A_mono _ _ I I1) (A_mono _ _ I I2)
calc
‖L e p q - L e' p' q'‖ =
‖L e p q - L e p r + (L e p r - L e' p' r) + (L e' p' r - L e' p' q')‖ := by
congr 1; abel
_ ≤ ‖L e p q - L e p r‖ + ‖L e p r - L e' p' r‖ + ‖L e' p' r - L e' p' q'‖ := by
grw [norm_add_le, norm_add_le]
_ ≤ 4 * (1 / 2) ^ e + 4 * (1 / 2) ^ e + 4 * (1 / 2) ^ e := by gcongr
_ = 12 * (1 / 2) ^ e := by ring
/- For definiteness, use `L0 e = L e (n e) (n e)`, to have a single sequence. We claim that this
is a Cauchy sequence. -/
let L0 : ℕ → F := fun e => L e (n e) (n e)
have : CauchySeq L0 := by
rw [Metric.cauchySeq_iff']
intro ε εpos
obtain ⟨e, he⟩ : ∃ e : ℕ, (1 / 2) ^ e < ε / 12 :=
exists_pow_lt_of_lt_one (div_pos εpos (by norm_num)) (by norm_num)
refine ⟨e, fun e' he' => ?_⟩
rw [dist_comm, dist_eq_norm]
calc
‖L0 e - L0 e'‖ ≤ 12 * (1 / 2) ^ e := M _ _ _ _ _ _ le_rfl le_rfl le_rfl le_rfl he'
_ < 12 * (ε / 12) := mul_lt_mul' le_rfl he (le_of_lt P) (by norm_num)
_ = ε := by ring -- As it is Cauchy, the sequence `L0` converges, to a limit `f'` in `K`.
obtain ⟨f', f'K, hf'⟩ : ∃ f' ∈ K, Tendsto L0 atTop (𝓝 f') :=
cauchySeq_tendsto_of_isComplete hK (fun e => (hn e (n e) (n e) le_rfl le_rfl).1) this
have Lf' : ∀ e p, n e ≤ p → ‖L e (n e) p - f'‖ ≤ 12 * (1 / 2) ^ e := by
intro e p hp
apply le_of_tendsto (tendsto_const_nhds.sub hf').norm
rw [eventually_atTop]
exact ⟨e, fun e' he' => M _ _ _ _ _ _ le_rfl hp le_rfl le_rfl he'⟩
-- Let us show that `f` has right derivative `f'` at `x`.
have : HasDerivWithinAt f f' (Ici x) x := by
simp only [hasDerivWithinAt_iff_isLittleO, isLittleO_iff]
/- to get an approximation with a precision `ε`, we will replace `f` with `L e (n e) m` for
some large enough `e` (yielding a small error by uniform approximation). As one can vary `m`,
this makes it possible to cover all scales, and thus to obtain a good linear approximation in
the whole interval of length `(1/2)^(n e)`. -/
intro ε εpos
obtain ⟨e, he⟩ : ∃ e : ℕ, (1 / 2) ^ e < ε / 16 :=
exists_pow_lt_of_lt_one (div_pos εpos (by norm_num)) (by norm_num)
filter_upwards [Icc_mem_nhdsGE <| show x < x + (1 / 2) ^ (n e + 1) by simp] with y hy
-- We need to show that `f y - f x - f' (y - x)` is small. For this, we will work at scale
-- `k` where `k` is chosen with `‖y - x‖ ∼ 2 ^ (-k)`.
rcases eq_or_lt_of_le hy.1 with (rfl | xy)
· simp only [sub_self, zero_smul, norm_zero, mul_zero, le_rfl]
have yzero : 0 < y - x := sub_pos.2 xy
have y_le : y - x ≤ (1 / 2) ^ (n e + 1) := by linarith [hy.2]
have yone : y - x ≤ 1 := le_trans y_le (pow_le_one₀ (by norm_num) (by norm_num))
-- define the scale `k`.
obtain ⟨k, hk, h'k⟩ : ∃ k : ℕ, (1 / 2) ^ (k + 1) < y - x ∧ y - x ≤ (1 / 2) ^ k :=
exists_nat_pow_near_of_lt_one yzero yone (by norm_num : (0 : ℝ) < 1 / 2)
(by norm_num : (1 : ℝ) / 2 < 1)
-- the scale is large enough (as `y - x` is small enough)
have k_gt : n e < k := by
have : ((1 : ℝ) / 2) ^ (k + 1) < (1 / 2) ^ (n e + 1) := lt_of_lt_of_le hk y_le
rw [pow_lt_pow_iff_right_of_lt_one₀ (by norm_num : (0 : ℝ) < 1 / 2) (by norm_num)] at this
omega
set m := k - 1
have m_ge : n e ≤ m := Nat.le_sub_one_of_lt k_gt
have km : k = m + 1 := (Nat.succ_pred_eq_of_pos (lt_of_le_of_lt (zero_le _) k_gt)).symm
rw [km] at hk h'k
-- `f` is well approximated by `L e (n e) k` at the relevant scale
-- (in fact, we use `m = k - 1` instead of `k` because of the precise definition of `A`).
have J : ‖f y - f x - (y - x) • L e (n e) m‖ ≤ 4 * (1 / 2) ^ e * ‖y - x‖ :=
calc
‖f y - f x - (y - x) • L e (n e) m‖ ≤ (1 / 2) ^ e * (1 / 2) ^ m := by
apply le_of_mem_A (hn e (n e) m le_rfl m_ge).2.2
· simp only [one_div, inv_pow, left_mem_Icc, le_add_iff_nonneg_right]
positivity
· simp only [pow_add, tsub_le_iff_left] at h'k
simpa only [hy.1, mem_Icc, true_and, one_div, pow_one] using h'k
_ = 4 * (1 / 2) ^ e * (1 / 2) ^ (m + 2) := by ring
_ ≤ 4 * (1 / 2) ^ e * (y - x) := by gcongr
_ = 4 * (1 / 2) ^ e * ‖y - x‖ := by rw [Real.norm_of_nonneg yzero.le]
calc
‖f y - f x - (y - x) • f'‖ =
‖f y - f x - (y - x) • L e (n e) m + (y - x) • (L e (n e) m - f')‖ := by
simp only [smul_sub, sub_add_sub_cancel]
_ ≤ 4 * (1 / 2) ^ e * ‖y - x‖ + ‖y - x‖ * (12 * (1 / 2) ^ e) :=
norm_add_le_of_le J <| by rw [norm_smul]; gcongr; exact Lf' _ _ m_ge
_ = 16 * ‖y - x‖ * (1 / 2) ^ e := by ring
_ ≤ 16 * ‖y - x‖ * (ε / 16) := by gcongr
_ = ε * ‖y - x‖ := by ring
-- Conclusion of the proof
rw [← this.derivWithin (uniqueDiffOn_Ici x x Set.left_mem_Ici)] at f'K
exact ⟨this.differentiableWithinAt, f'K⟩
theorem differentiable_set_eq_D (hK : IsComplete K) :
{ x | DifferentiableWithinAt ℝ f (Ici x) x ∧ derivWithin f (Ici x) x ∈ K } = D f K :=
Subset.antisymm (differentiable_set_subset_D _) (D_subset_differentiable_set hK)
end RightDerivMeasurableAux
open RightDerivMeasurableAux
variable (f)
/-- The set of right differentiability points of a function, with derivative in a given complete
set, is Borel-measurable. -/
theorem measurableSet_of_differentiableWithinAt_Ici_of_isComplete {K : Set F} (hK : IsComplete K) :
MeasurableSet { x | DifferentiableWithinAt ℝ f (Ici x) x ∧ derivWithin f (Ici x) x ∈ K } := by
-- simp [differentiable_set_eq_d K hK, D, measurableSet_b, MeasurableSet.iInter,
-- MeasurableSet.iUnion]
simp only [differentiable_set_eq_D K hK, D]
repeat apply_rules [MeasurableSet.iUnion, MeasurableSet.iInter] <;> intro
exact measurableSet_B
variable [CompleteSpace F]
/-- The set of right differentiability points of a function taking values in a complete space is
Borel-measurable. -/
theorem measurableSet_of_differentiableWithinAt_Ici :
MeasurableSet { x | DifferentiableWithinAt ℝ f (Ici x) x } := by
have : IsComplete (univ : Set F) := complete_univ
convert measurableSet_of_differentiableWithinAt_Ici_of_isComplete f this
simp
@[measurability, fun_prop]
theorem measurable_derivWithin_Ici [MeasurableSpace F] [BorelSpace F] :
Measurable fun x => derivWithin f (Ici x) x := by
refine measurable_of_isClosed fun s hs => ?_
have :
(fun x => derivWithin f (Ici x) x) ⁻¹' s =
{ x | DifferentiableWithinAt ℝ f (Ici x) x ∧ derivWithin f (Ici x) x ∈ s } ∪
{ x | ¬DifferentiableWithinAt ℝ f (Ici x) x } ∩ { _x | (0 : F) ∈ s } :=
Set.ext fun x => mem_preimage.trans derivWithin_mem_iff
rw [this]
exact
(measurableSet_of_differentiableWithinAt_Ici_of_isComplete _ hs.isComplete).union
((measurableSet_of_differentiableWithinAt_Ici _).compl.inter (MeasurableSet.const _))
theorem stronglyMeasurable_derivWithin_Ici :
StronglyMeasurable (fun x ↦ derivWithin f (Ici x) x) := by
borelize F
apply stronglyMeasurable_iff_measurable_separable.2 ⟨measurable_derivWithin_Ici f, ?_⟩
obtain ⟨t, t_count, ht⟩ : ∃ t : Set ℝ, t.Countable ∧ Dense t := exists_countable_dense ℝ
suffices H : range (fun x ↦ derivWithin f (Ici x) x) ⊆ closure (Submodule.span ℝ (f '' t)) from
IsSeparable.mono (t_count.image f).isSeparable.span.closure H
rintro - ⟨x, rfl⟩
suffices H' : range (fun y ↦ derivWithin f (Ici x) y) ⊆ closure (Submodule.span ℝ (f '' t)) from
H' (mem_range_self _)
apply range_derivWithin_subset_closure_span_image
calc Ici x
= closure (Ioi x ∩ closure t) := by simp [dense_iff_closure_eq.1 ht]
_ ⊆ closure (closure (Ioi x ∩ t)) := by
apply closure_mono
simpa [inter_comm] using (isOpen_Ioi (a := x)).closure_inter (s := t)
_ ⊆ closure (Ici x ∩ t) := by
rw [closure_closure]
exact closure_mono (inter_subset_inter_left _ Ioi_subset_Ici_self)
theorem aemeasurable_derivWithin_Ici [MeasurableSpace F] [BorelSpace F] (μ : Measure ℝ) :
AEMeasurable (fun x => derivWithin f (Ici x) x) μ :=
(measurable_derivWithin_Ici f).aemeasurable
theorem aestronglyMeasurable_derivWithin_Ici (μ : Measure ℝ) :
AEStronglyMeasurable (fun x => derivWithin f (Ici x) x) μ :=
(stronglyMeasurable_derivWithin_Ici f).aestronglyMeasurable
/-- The set of right differentiability points of a function taking values in a complete space is
Borel-measurable. -/
theorem measurableSet_of_differentiableWithinAt_Ioi :
MeasurableSet { x | DifferentiableWithinAt ℝ f (Ioi x) x } := by
simpa [differentiableWithinAt_Ioi_iff_Ici] using measurableSet_of_differentiableWithinAt_Ici f
@[measurability, fun_prop]
theorem measurable_derivWithin_Ioi [MeasurableSpace F] [BorelSpace F] :
Measurable fun x => derivWithin f (Ioi x) x := by
simpa [derivWithin_Ioi_eq_Ici] using measurable_derivWithin_Ici f
theorem stronglyMeasurable_derivWithin_Ioi :
StronglyMeasurable (fun x ↦ derivWithin f (Ioi x) x) := by
simpa [derivWithin_Ioi_eq_Ici] using stronglyMeasurable_derivWithin_Ici f
theorem aemeasurable_derivWithin_Ioi [MeasurableSpace F] [BorelSpace F] (μ : Measure ℝ) :
AEMeasurable (fun x => derivWithin f (Ioi x) x) μ :=
(measurable_derivWithin_Ioi f).aemeasurable
theorem aestronglyMeasurable_derivWithin_Ioi (μ : Measure ℝ) :
AEStronglyMeasurable (fun x => derivWithin f (Ioi x) x) μ :=
(stronglyMeasurable_derivWithin_Ioi f).aestronglyMeasurable
end RightDeriv
section WithParam
/- In this section, we prove the measurability of the derivative in a context with parameters:
given `f : α → E → F`, we want to show that `p ↦ fderiv 𝕜 (f p.1) p.2` is measurable. Contrary
to the previous sections, some assumptions are needed for this: if `f p.1` depends arbitrarily on
`p.1`, this is obviously false. We require that `f` is continuous and `E` is locally compact --
then the proofs in the previous sections adapt readily, as the set `A` defined above is open, so
that the differentiability set `D` is measurable. -/
variable {𝕜 : Type*} [NontriviallyNormedField 𝕜]
{E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E] [LocallyCompactSpace E]
{F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F]
{α : Type*} [TopologicalSpace α]
{f : α → E → F}
namespace FDerivMeasurableAux
open Uniformity
lemma isOpen_A_with_param {r s : ℝ} (hf : Continuous f.uncurry) (L : E →L[𝕜] F) :
IsOpen {p : α × E | p.2 ∈ A (f p.1) L r s} := by
have : ProperSpace E := .of_locallyCompactSpace 𝕜
simp only [A, mem_Ioc, mem_ball, map_sub, mem_setOf_eq]
apply isOpen_iff_mem_nhds.2
rintro ⟨a, x⟩ ⟨r', ⟨Irr', Ir'r⟩, hr⟩
rcases exists_between Irr' with ⟨t, hrt, htr'⟩
rcases exists_between hrt with ⟨t', hrt', ht't⟩
obtain ⟨b, b_lt, hb⟩ : ∃ b, b < s * r ∧ ∀ y ∈ closedBall x t, ∀ z ∈ closedBall x t,
‖f a z - f a y - (L z - L y)‖ ≤ b := by
have B : Continuous (fun (p : E × E) ↦ ‖f a p.2 - f a p.1 - (L p.2 - L p.1)‖) := by fun_prop
have C : (closedBall x t ×ˢ closedBall x t).Nonempty := by simp; linarith
rcases ((isCompact_closedBall x t).prod (isCompact_closedBall x t)).exists_isMaxOn
C B.continuousOn with ⟨p, pt, hp⟩
simp only [mem_prod, mem_closedBall] at pt
refine ⟨‖f a p.2 - f a p.1 - (L p.2 - L p.1)‖,
hr p.1 (pt.1.trans_lt htr') p.2 (pt.2.trans_lt htr'), fun y hy z hz ↦ ?_⟩
have D : (y, z) ∈ closedBall x t ×ˢ closedBall x t := mem_prod.2 ⟨hy, hz⟩
exact hp D
obtain ⟨ε, εpos, hε⟩ : ∃ ε, 0 < ε ∧ b + 2 * ε < s * r :=
⟨(s * r - b) / 3, by linarith, by linarith⟩
obtain ⟨u, u_open, au, hu⟩ : ∃ u, IsOpen u ∧ a ∈ u ∧ ∀ (p : α × E),
p.1 ∈ u → p.2 ∈ closedBall x t → dist (f.uncurry p) (f.uncurry (a, p.2)) < ε := by
have C : Continuous (fun (p : α × E) ↦ f a p.2) := by fun_prop
have D : ({a} ×ˢ closedBall x t).EqOn f.uncurry (fun p ↦ f a p.2) := by
rintro ⟨b, y⟩ ⟨hb, -⟩
simp only [mem_singleton_iff] at hb
simp [hb]
obtain ⟨v, v_open, sub_v, hv⟩ : ∃ v, IsOpen v ∧ {a} ×ˢ closedBall x t ⊆ v ∧
∀ p ∈ v, dist (Function.uncurry f p) (f a p.2) < ε :=
Uniform.exists_is_open_mem_uniformity_of_forall_mem_eq (s := {a} ×ˢ closedBall x t)
(fun p _ ↦ hf.continuousAt) (fun p _ ↦ C.continuousAt) D (dist_mem_uniformity εpos)
obtain ⟨w, w', w_open, -, sub_w, sub_w', hww'⟩ : ∃ (w : Set α) (w' : Set E),
IsOpen w ∧ IsOpen w' ∧ {a} ⊆ w ∧ closedBall x t ⊆ w' ∧ w ×ˢ w' ⊆ v :=
generalized_tube_lemma isCompact_singleton (isCompact_closedBall x t) v_open sub_v
refine ⟨w, w_open, sub_w rfl, ?_⟩
rintro ⟨b, y⟩ h hby
exact hv _ (hww' ⟨h, sub_w' hby⟩)
have : u ×ˢ ball x (t - t') ∈ 𝓝 (a, x) :=
prod_mem_nhds (u_open.mem_nhds au) (ball_mem_nhds _ (sub_pos.2 ht't))
filter_upwards [this]
rintro ⟨a', x'⟩ ha'x'
simp only [mem_prod, mem_ball] at ha'x'
refine ⟨t', ⟨hrt', ht't.le.trans (htr'.le.trans Ir'r)⟩, fun y hy z hz ↦ ?_⟩
have dyx : dist y x ≤ t := by linarith [dist_triangle y x' x]
have dzx : dist z x ≤ t := by linarith [dist_triangle z x' x]
calc
‖f a' z - f a' y - (L z - L y)‖ =
‖(f a' z - f a z) + (f a y - f a' y) + (f a z - f a y - (L z - L y))‖ := by congr; abel
_ ≤ ‖f a' z - f a z‖ + ‖f a y - f a' y‖ + ‖f a z - f a y - (L z - L y)‖ := norm_add₃_le
_ ≤ ε + ε + b := by
gcongr
· rw [← dist_eq_norm]
change dist (f.uncurry (a', z)) (f.uncurry (a, z)) ≤ ε
apply (hu _ _ _).le
· exact ha'x'.1
· simp [dzx]
· rw [← dist_eq_norm']
change dist (f.uncurry (a', y)) (f.uncurry (a, y)) ≤ ε
apply (hu _ _ _).le
· exact ha'x'.1
· simp [dyx]
· simp [hb, dyx, dzx]
_ < s * r := by linarith
lemma isOpen_B_with_param {r s t : ℝ} (hf : Continuous f.uncurry) (K : Set (E →L[𝕜] F)) :
IsOpen {p : α × E | p.2 ∈ B (f p.1) K r s t} := by
suffices H : IsOpen (⋃ L ∈ K,
{p : α × E | p.2 ∈ A (f p.1) L r t ∧ p.2 ∈ A (f p.1) L s t}) by
convert H; ext p; simp [B]
refine isOpen_biUnion (fun L _ ↦ ?_)
exact (isOpen_A_with_param hf L).inter (isOpen_A_with_param hf L)
end FDerivMeasurableAux
open FDerivMeasurableAux
variable [MeasurableSpace α] [OpensMeasurableSpace α] [MeasurableSpace E] [OpensMeasurableSpace E]
theorem measurableSet_of_differentiableAt_of_isComplete_with_param
(hf : Continuous f.uncurry) {K : Set (E →L[𝕜] F)} (hK : IsComplete K) :
MeasurableSet {p : α × E | DifferentiableAt 𝕜 (f p.1) p.2 ∧ fderiv 𝕜 (f p.1) p.2 ∈ K} := by
have : {p : α × E | DifferentiableAt 𝕜 (f p.1) p.2 ∧ fderiv 𝕜 (f p.1) p.2 ∈ K}
= {p : α × E | p.2 ∈ D (f p.1) K} := by simp [← differentiable_set_eq_D K hK]
rw [this]
simp only [D, mem_iInter, mem_iUnion]
simp only [setOf_forall, setOf_exists]
refine MeasurableSet.iInter (fun _ ↦ ?_)
refine MeasurableSet.iUnion (fun _ ↦ ?_)
refine MeasurableSet.iInter (fun _ ↦ ?_)
refine MeasurableSet.iInter (fun _ ↦ ?_)
refine MeasurableSet.iInter (fun _ ↦ ?_)
refine MeasurableSet.iInter (fun _ ↦ ?_)
have : ProperSpace E := .of_locallyCompactSpace 𝕜
exact (isOpen_B_with_param hf K).measurableSet
variable (𝕜)
variable [CompleteSpace F]
/-- The set of differentiability points of a continuous function depending on a parameter taking
values in a complete space is Borel-measurable. -/
theorem measurableSet_of_differentiableAt_with_param (hf : Continuous f.uncurry) :
MeasurableSet {p : α × E | DifferentiableAt 𝕜 (f p.1) p.2} := by
have : IsComplete (univ : Set (E →L[𝕜] F)) := complete_univ
convert measurableSet_of_differentiableAt_of_isComplete_with_param hf this
simp
theorem measurable_fderiv_with_param (hf : Continuous f.uncurry) :
Measurable (fun (p : α × E) ↦ fderiv 𝕜 (f p.1) p.2) := by
refine measurable_of_isClosed (fun s hs ↦ ?_)
have :
(fun (p : α × E) ↦ fderiv 𝕜 (f p.1) p.2) ⁻¹' s =
{p | DifferentiableAt 𝕜 (f p.1) p.2 ∧ fderiv 𝕜 (f p.1) p.2 ∈ s } ∪
{ p | ¬DifferentiableAt 𝕜 (f p.1) p.2} ∩ { _p | (0 : E →L[𝕜] F) ∈ s} :=
Set.ext (fun x ↦ mem_preimage.trans fderiv_mem_iff)
rw [this]
exact
(measurableSet_of_differentiableAt_of_isComplete_with_param hf hs.isComplete).union
((measurableSet_of_differentiableAt_with_param _ hf).compl.inter (MeasurableSet.const _))
theorem measurable_fderiv_apply_const_with_param [MeasurableSpace F] [BorelSpace F]
(hf : Continuous f.uncurry) (y : E) :
Measurable (fun (p : α × E) ↦ fderiv 𝕜 (f p.1) p.2 y) :=
(ContinuousLinearMap.measurable_apply y).comp (measurable_fderiv_with_param 𝕜 hf)
variable {𝕜}
theorem measurable_deriv_with_param [LocallyCompactSpace 𝕜] [MeasurableSpace 𝕜]
[OpensMeasurableSpace 𝕜] [MeasurableSpace F]
[BorelSpace F] {f : α → 𝕜 → F} (hf : Continuous f.uncurry) :
Measurable (fun (p : α × 𝕜) ↦ deriv (f p.1) p.2) := by
simpa only [fderiv_deriv] using measurable_fderiv_apply_const_with_param 𝕜 hf 1
theorem stronglyMeasurable_deriv_with_param [LocallyCompactSpace 𝕜] [MeasurableSpace 𝕜]
[OpensMeasurableSpace 𝕜] [h : SecondCountableTopologyEither α F]
{f : α → 𝕜 → F} (hf : Continuous f.uncurry) :
StronglyMeasurable (fun (p : α × 𝕜) ↦ deriv (f p.1) p.2) := by
borelize F
rcases h.out with hα|hF
· have : ProperSpace 𝕜 := .of_locallyCompactSpace 𝕜
apply stronglyMeasurable_iff_measurable_separable.2 ⟨measurable_deriv_with_param hf, ?_⟩
have : range (fun (p : α × 𝕜) ↦ deriv (f p.1) p.2)
⊆ closure (Submodule.span 𝕜 (range f.uncurry)) := by
rintro - ⟨p, rfl⟩
have A : deriv (f p.1) p.2 ∈ closure (Submodule.span 𝕜 (range (f p.1))) := by
rw [← image_univ]
apply range_deriv_subset_closure_span_image _ dense_univ (mem_range_self _)
have B : range (f p.1) ⊆ range (f.uncurry) := by
rintro - ⟨x, rfl⟩
exact mem_range_self (p.1, x)
exact closure_mono (Submodule.span_mono B) A
exact (isSeparable_range hf).span.closure.mono this
· exact (measurable_deriv_with_param hf).stronglyMeasurable
theorem aemeasurable_deriv_with_param [LocallyCompactSpace 𝕜] [MeasurableSpace 𝕜]
[OpensMeasurableSpace 𝕜] [MeasurableSpace F]
[BorelSpace F] {f : α → 𝕜 → F} (hf : Continuous f.uncurry) (μ : Measure (α × 𝕜)) :
AEMeasurable (fun (p : α × 𝕜) ↦ deriv (f p.1) p.2) μ :=
(measurable_deriv_with_param hf).aemeasurable
theorem aestronglyMeasurable_deriv_with_param [LocallyCompactSpace 𝕜] [MeasurableSpace 𝕜]
[OpensMeasurableSpace 𝕜] [SecondCountableTopologyEither α F]
{f : α → 𝕜 → F} (hf : Continuous f.uncurry) (μ : Measure (α × 𝕜)) :
AEStronglyMeasurable (fun (p : α × 𝕜) ↦ deriv (f p.1) p.2) μ :=
(stronglyMeasurable_deriv_with_param hf).aestronglyMeasurable
end WithParam |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/FDeriv/CompCLM.lean | import Mathlib.Analysis.Calculus.FDeriv.Bilinear
import Mathlib.Analysis.NormedSpace.Alternating.Basic
/-!
# Multiplicative operations on derivatives
For detailed documentation of the Fréchet derivative,
see the module docstring of `Mathlib/Analysis/Calculus/FDeriv/Basic.lean`.
This file contains the usual formulas (and existence assertions) for the derivative of
* composition of continuous linear maps
* application of continuous (multi)linear maps to a constant
-/
open Asymptotics ContinuousLinearMap Topology
section
variable {𝕜 : Type*} [NontriviallyNormedField 𝕜]
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E]
variable {F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F]
variable {G : Type*} [NormedAddCommGroup G] [NormedSpace 𝕜 G]
variable {f : E → F}
variable {f' : E →L[𝕜] F}
variable {x : E}
variable {s : Set E}
section CLMCompApply
/-! ### Derivative of the pointwise composition/application of continuous linear maps -/
variable {H : Type*} [NormedAddCommGroup H] [NormedSpace 𝕜 H] {c : E → G →L[𝕜] H}
{c' : E →L[𝕜] G →L[𝕜] H} {d : E → F →L[𝕜] G} {d' : E →L[𝕜] F →L[𝕜] G} {u : E → G} {u' : E →L[𝕜] G}
@[fun_prop]
theorem HasStrictFDerivAt.clm_comp (hc : HasStrictFDerivAt c c' x) (hd : HasStrictFDerivAt d d' x) :
HasStrictFDerivAt (fun y => (c y).comp (d y))
((compL 𝕜 F G H (c x)).comp d' + ((compL 𝕜 F G H).flip (d x)).comp c') x :=
(isBoundedBilinearMap_comp.hasStrictFDerivAt (c x, d x)).comp x (hc.prodMk hd)
@[fun_prop]
theorem HasFDerivWithinAt.clm_comp (hc : HasFDerivWithinAt c c' s x)
(hd : HasFDerivWithinAt d d' s x) :
HasFDerivWithinAt (fun y => (c y).comp (d y))
((compL 𝕜 F G H (c x)).comp d' + ((compL 𝕜 F G H).flip (d x)).comp c') s x := by
-- `by exact` to solve unification issues.
exact (isBoundedBilinearMap_comp.hasFDerivAt (c x, d x)).comp_hasFDerivWithinAt x (hc.prodMk hd)
@[fun_prop]
theorem HasFDerivAt.clm_comp (hc : HasFDerivAt c c' x) (hd : HasFDerivAt d d' x) :
HasFDerivAt (fun y => (c y).comp (d y))
((compL 𝕜 F G H (c x)).comp d' + ((compL 𝕜 F G H).flip (d x)).comp c') x := by
-- `by exact` to solve unification issues.
exact (isBoundedBilinearMap_comp.hasFDerivAt (c x, d x)).comp x <| hc.prodMk hd
@[fun_prop]
theorem DifferentiableWithinAt.clm_comp (hc : DifferentiableWithinAt 𝕜 c s x)
(hd : DifferentiableWithinAt 𝕜 d s x) :
DifferentiableWithinAt 𝕜 (fun y => (c y).comp (d y)) s x :=
(hc.hasFDerivWithinAt.clm_comp hd.hasFDerivWithinAt).differentiableWithinAt
@[fun_prop]
theorem DifferentiableAt.clm_comp (hc : DifferentiableAt 𝕜 c x) (hd : DifferentiableAt 𝕜 d x) :
DifferentiableAt 𝕜 (fun y => (c y).comp (d y)) x :=
(hc.hasFDerivAt.clm_comp hd.hasFDerivAt).differentiableAt
@[fun_prop]
theorem DifferentiableOn.clm_comp (hc : DifferentiableOn 𝕜 c s) (hd : DifferentiableOn 𝕜 d s) :
DifferentiableOn 𝕜 (fun y => (c y).comp (d y)) s := fun x hx => (hc x hx).clm_comp (hd x hx)
@[fun_prop]
theorem Differentiable.clm_comp (hc : Differentiable 𝕜 c) (hd : Differentiable 𝕜 d) :
Differentiable 𝕜 fun y => (c y).comp (d y) := fun x => (hc x).clm_comp (hd x)
theorem fderivWithin_clm_comp (hxs : UniqueDiffWithinAt 𝕜 s x) (hc : DifferentiableWithinAt 𝕜 c s x)
(hd : DifferentiableWithinAt 𝕜 d s x) :
fderivWithin 𝕜 (fun y => (c y).comp (d y)) s x =
(compL 𝕜 F G H (c x)).comp (fderivWithin 𝕜 d s x) +
((compL 𝕜 F G H).flip (d x)).comp (fderivWithin 𝕜 c s x) :=
(hc.hasFDerivWithinAt.clm_comp hd.hasFDerivWithinAt).fderivWithin hxs
theorem fderiv_clm_comp (hc : DifferentiableAt 𝕜 c x) (hd : DifferentiableAt 𝕜 d x) :
fderiv 𝕜 (fun y => (c y).comp (d y)) x =
(compL 𝕜 F G H (c x)).comp (fderiv 𝕜 d x) +
((compL 𝕜 F G H).flip (d x)).comp (fderiv 𝕜 c x) :=
(hc.hasFDerivAt.clm_comp hd.hasFDerivAt).fderiv
@[fun_prop]
theorem HasStrictFDerivAt.clm_apply (hc : HasStrictFDerivAt c c' x)
(hu : HasStrictFDerivAt u u' x) :
HasStrictFDerivAt (fun y => (c y) (u y)) ((c x).comp u' + c'.flip (u x)) x :=
(isBoundedBilinearMap_apply.hasStrictFDerivAt (c x, u x)).comp x (hc.prodMk hu)
@[fun_prop]
theorem HasFDerivWithinAt.clm_apply (hc : HasFDerivWithinAt c c' s x)
(hu : HasFDerivWithinAt u u' s x) :
HasFDerivWithinAt (fun y => (c y) (u y)) ((c x).comp u' + c'.flip (u x)) s x := by
-- `by exact` to solve unification issues.
exact (isBoundedBilinearMap_apply.hasFDerivAt (c x, u x)).comp_hasFDerivWithinAt x
(hc.prodMk hu)
@[fun_prop]
theorem HasFDerivAt.clm_apply (hc : HasFDerivAt c c' x) (hu : HasFDerivAt u u' x) :
HasFDerivAt (fun y => (c y) (u y)) ((c x).comp u' + c'.flip (u x)) x := by
-- `by exact` to solve unification issues.
exact (isBoundedBilinearMap_apply.hasFDerivAt (c x, u x)).comp x (hc.prodMk hu)
@[fun_prop]
theorem DifferentiableWithinAt.clm_apply (hc : DifferentiableWithinAt 𝕜 c s x)
(hu : DifferentiableWithinAt 𝕜 u s x) : DifferentiableWithinAt 𝕜 (fun y => (c y) (u y)) s x :=
(hc.hasFDerivWithinAt.clm_apply hu.hasFDerivWithinAt).differentiableWithinAt
@[fun_prop]
theorem DifferentiableAt.clm_apply (hc : DifferentiableAt 𝕜 c x) (hu : DifferentiableAt 𝕜 u x) :
DifferentiableAt 𝕜 (fun y => (c y) (u y)) x :=
(hc.hasFDerivAt.clm_apply hu.hasFDerivAt).differentiableAt
@[fun_prop]
theorem DifferentiableOn.clm_apply (hc : DifferentiableOn 𝕜 c s) (hu : DifferentiableOn 𝕜 u s) :
DifferentiableOn 𝕜 (fun y => (c y) (u y)) s := fun x hx => (hc x hx).clm_apply (hu x hx)
@[fun_prop]
theorem Differentiable.clm_apply (hc : Differentiable 𝕜 c) (hu : Differentiable 𝕜 u) :
Differentiable 𝕜 fun y => (c y) (u y) := fun x => (hc x).clm_apply (hu x)
theorem fderivWithin_clm_apply (hxs : UniqueDiffWithinAt 𝕜 s x)
(hc : DifferentiableWithinAt 𝕜 c s x) (hu : DifferentiableWithinAt 𝕜 u s x) :
fderivWithin 𝕜 (fun y => (c y) (u y)) s x =
(c x).comp (fderivWithin 𝕜 u s x) + (fderivWithin 𝕜 c s x).flip (u x) :=
(hc.hasFDerivWithinAt.clm_apply hu.hasFDerivWithinAt).fderivWithin hxs
theorem fderiv_clm_apply (hc : DifferentiableAt 𝕜 c x) (hu : DifferentiableAt 𝕜 u x) :
fderiv 𝕜 (fun y => (c y) (u y)) x = (c x).comp (fderiv 𝕜 u x) + (fderiv 𝕜 c x).flip (u x) :=
(hc.hasFDerivAt.clm_apply hu.hasFDerivAt).fderiv
end CLMCompApply
section ContinuousMultilinearApplyConst
/-! ### Derivative of the application of continuous multilinear maps to a constant -/
variable {ι : Type*} [Fintype ι]
{M : ι → Type*} [∀ i, NormedAddCommGroup (M i)] [∀ i, NormedSpace 𝕜 (M i)]
{H : Type*} [NormedAddCommGroup H] [NormedSpace 𝕜 H]
{c : E → ContinuousMultilinearMap 𝕜 M H}
{c' : E →L[𝕜] ContinuousMultilinearMap 𝕜 M H}
@[fun_prop]
theorem HasStrictFDerivAt.continuousMultilinear_apply_const (hc : HasStrictFDerivAt c c' x)
(u : ∀ i, M i) : HasStrictFDerivAt (fun y ↦ (c y) u) (c'.flipMultilinear u) x :=
(ContinuousMultilinearMap.apply 𝕜 M H u).hasStrictFDerivAt.comp x hc
@[fun_prop]
theorem HasFDerivWithinAt.continuousMultilinear_apply_const (hc : HasFDerivWithinAt c c' s x)
(u : ∀ i, M i) :
HasFDerivWithinAt (fun y ↦ (c y) u) (c'.flipMultilinear u) s x :=
(ContinuousMultilinearMap.apply 𝕜 M H u).hasFDerivAt.comp_hasFDerivWithinAt x hc
@[fun_prop]
theorem HasFDerivAt.continuousMultilinear_apply_const (hc : HasFDerivAt c c' x) (u : ∀ i, M i) :
HasFDerivAt (fun y ↦ (c y) u) (c'.flipMultilinear u) x :=
(ContinuousMultilinearMap.apply 𝕜 M H u).hasFDerivAt.comp x hc
@[fun_prop]
theorem DifferentiableWithinAt.continuousMultilinear_apply_const
(hc : DifferentiableWithinAt 𝕜 c s x) (u : ∀ i, M i) :
DifferentiableWithinAt 𝕜 (fun y ↦ (c y) u) s x :=
(hc.hasFDerivWithinAt.continuousMultilinear_apply_const u).differentiableWithinAt
@[fun_prop]
theorem DifferentiableAt.continuousMultilinear_apply_const (hc : DifferentiableAt 𝕜 c x)
(u : ∀ i, M i) :
DifferentiableAt 𝕜 (fun y ↦ (c y) u) x :=
(hc.hasFDerivAt.continuousMultilinear_apply_const u).differentiableAt
@[fun_prop]
theorem DifferentiableOn.continuousMultilinear_apply_const (hc : DifferentiableOn 𝕜 c s)
(u : ∀ i, M i) : DifferentiableOn 𝕜 (fun y ↦ (c y) u) s :=
fun x hx ↦ (hc x hx).continuousMultilinear_apply_const u
@[fun_prop]
theorem Differentiable.continuousMultilinear_apply_const (hc : Differentiable 𝕜 c) (u : ∀ i, M i) :
Differentiable 𝕜 fun y ↦ (c y) u := fun x ↦ (hc x).continuousMultilinear_apply_const u
theorem fderivWithin_continuousMultilinear_apply_const (hxs : UniqueDiffWithinAt 𝕜 s x)
(hc : DifferentiableWithinAt 𝕜 c s x) (u : ∀ i, M i) :
fderivWithin 𝕜 (fun y ↦ (c y) u) s x = ((fderivWithin 𝕜 c s x).flipMultilinear u) :=
(hc.hasFDerivWithinAt.continuousMultilinear_apply_const u).fderivWithin hxs
theorem fderiv_continuousMultilinear_apply_const (hc : DifferentiableAt 𝕜 c x) (u : ∀ i, M i) :
(fderiv 𝕜 (fun y ↦ (c y) u) x) = (fderiv 𝕜 c x).flipMultilinear u :=
(hc.hasFDerivAt.continuousMultilinear_apply_const u).fderiv
/-- Application of a `ContinuousMultilinearMap` to a constant commutes with `fderivWithin`. -/
theorem fderivWithin_continuousMultilinear_apply_const_apply (hxs : UniqueDiffWithinAt 𝕜 s x)
(hc : DifferentiableWithinAt 𝕜 c s x) (u : ∀ i, M i) (m : E) :
(fderivWithin 𝕜 (fun y ↦ (c y) u) s x) m = (fderivWithin 𝕜 c s x) m u := by
simp [fderivWithin_continuousMultilinear_apply_const hxs hc]
/-- Application of a `ContinuousMultilinearMap` to a constant commutes with `fderiv`. -/
theorem fderiv_continuousMultilinear_apply_const_apply (hc : DifferentiableAt 𝕜 c x)
(u : ∀ i, M i) (m : E) :
(fderiv 𝕜 (fun y ↦ (c y) u) x) m = (fderiv 𝕜 c x) m u := by
simp [fderiv_continuousMultilinear_apply_const hc]
end ContinuousMultilinearApplyConst
section ContinuousAlternatingMapApplyConst
/-!
### Derivative of the application of continuous alternating maps to a constant
Given a differentiable family of continuous alternating maps `c : E → F [⋀^ι]→L[𝕜] G`
and a tuple of vectors `u : ι → F`,
the derivative of `c x u` as a function of `x` is given by `fun m ↦ c' m u`,
where `c'` is the derivative of `c` at `x`.
-/
variable {ι : Type*} [Fintype ι] {c : E → F [⋀^ι]→L[𝕜] G} {c' : E →L[𝕜] (F [⋀^ι]→L[𝕜] G)}
@[fun_prop]
theorem HasStrictFDerivAt.continuousAlternatingMap_apply_const (hc : HasStrictFDerivAt c c' x)
(u : ι → F) : HasStrictFDerivAt (c · u) (c'.flipAlternating u) x :=
(ContinuousAlternatingMap.apply 𝕜 F G u).hasStrictFDerivAt.comp x hc
@[fun_prop]
theorem HasFDerivWithinAt.continuousAlternatingMap_apply_const (hc : HasFDerivWithinAt c c' s x)
(u : ι → F) :
HasFDerivWithinAt (c · u) (c'.flipAlternating u) s x :=
(ContinuousAlternatingMap.apply 𝕜 F G u).hasFDerivAt.comp_hasFDerivWithinAt x hc
@[fun_prop]
theorem HasFDerivAt.continuousAlternatingMap_apply_const (hc : HasFDerivAt c c' x) (u : ι → F) :
HasFDerivAt (fun y ↦ (c y) u) (c'.flipAlternating u) x :=
(ContinuousAlternatingMap.apply 𝕜 F G u).hasFDerivAt.comp x hc
@[fun_prop]
theorem DifferentiableWithinAt.continuousAlternatingMap_apply_const
(hc : DifferentiableWithinAt 𝕜 c s x) (u : ι → F) :
DifferentiableWithinAt 𝕜 (fun y ↦ (c y) u) s x :=
(hc.hasFDerivWithinAt.continuousAlternatingMap_apply_const u).differentiableWithinAt
@[fun_prop]
theorem DifferentiableAt.continuousAlternatingMap_apply_const (hc : DifferentiableAt 𝕜 c x)
(u : ι → F) :
DifferentiableAt 𝕜 (fun y ↦ (c y) u) x :=
(hc.hasFDerivAt.continuousAlternatingMap_apply_const u).differentiableAt
@[fun_prop]
theorem DifferentiableOn.continuousAlternatingMap_apply_const (hc : DifferentiableOn 𝕜 c s)
(u : ι → F) : DifferentiableOn 𝕜 (fun y ↦ (c y) u) s :=
fun x hx ↦ (hc x hx).continuousAlternatingMap_apply_const u
@[fun_prop]
theorem Differentiable.continuousAlternatingMap_apply_const (hc : Differentiable 𝕜 c) (u : ι → F) :
Differentiable 𝕜 fun y ↦ (c y) u := fun x ↦ (hc x).continuousAlternatingMap_apply_const u
theorem fderivWithin_continuousAlternatingMap_apply_const (hxs : UniqueDiffWithinAt 𝕜 s x)
(hc : DifferentiableWithinAt 𝕜 c s x) (u : ι → F) :
fderivWithin 𝕜 (fun y ↦ (c y) u) s x = ((fderivWithin 𝕜 c s x).flipAlternating u) :=
(hc.hasFDerivWithinAt.continuousAlternatingMap_apply_const u).fderivWithin hxs
theorem fderiv_continuousAlternatingMap_apply_const (hc : DifferentiableAt 𝕜 c x) (u : ι → F) :
(fderiv 𝕜 (fun y ↦ (c y) u) x) = (fderiv 𝕜 c x).flipAlternating u :=
(hc.hasFDerivAt.continuousAlternatingMap_apply_const u).fderiv
/-- Application of a `ContinuousAlternatingMap` to a constant commutes with `fderivWithin`. -/
theorem fderivWithin_continuousAlternatingMap_apply_const_apply (hxs : UniqueDiffWithinAt 𝕜 s x)
(hc : DifferentiableWithinAt 𝕜 c s x) (u : ι → F) (m : E) :
(fderivWithin 𝕜 (fun y ↦ (c y) u) s x) m = (fderivWithin 𝕜 c s x) m u := by
simp [fderivWithin_continuousAlternatingMap_apply_const hxs hc]
/-- Application of a `ContinuousAlternatingMap` to a constant commutes with `fderiv`. -/
theorem fderiv_continuousAlternatingMap_apply_const_apply (hc : DifferentiableAt 𝕜 c x)
(u : ι → F) (m : E) :
(fderiv 𝕜 (fun y ↦ (c y) u) x) m = (fderiv 𝕜 c x) m u := by
simp [fderiv_continuousAlternatingMap_apply_const hc]
end ContinuousAlternatingMapApplyConst
end |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/FDeriv/Equiv.lean | import Mathlib.Analysis.Asymptotics.AsymptoticEquivalent
import Mathlib.Analysis.Calculus.FDeriv.Comp
import Mathlib.Analysis.Calculus.FDeriv.Const
import Mathlib.Analysis.Calculus.FDeriv.Linear
/-!
# The derivative of a linear equivalence
For detailed documentation of the Fréchet derivative,
see the module docstring of `Analysis/Calculus/FDeriv/Basic.lean`.
This file contains the usual formulas (and existence assertions) for the derivative of
continuous linear equivalences.
We also prove the usual formula for the derivative of the inverse function, assuming it exists.
The inverse function theorem is in `Mathlib/Analysis/Calculus/InverseFunctionTheorem/FDeriv.lean`.
-/
open Filter Asymptotics ContinuousLinearMap Set Metric Topology NNReal ENNReal
noncomputable section
section
variable {𝕜 : Type*} [NontriviallyNormedField 𝕜]
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E]
variable {F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F]
variable {G : Type*} [NormedAddCommGroup G] [NormedSpace 𝕜 G]
variable {G' : Type*} [NormedAddCommGroup G'] [NormedSpace 𝕜 G']
variable {f : E → F} {f' : E →L[𝕜] F} {x : E} {s : Set E} {c : F}
namespace ContinuousLinearEquiv
/-! ### Differentiability of linear equivs, and invariance of differentiability -/
variable (iso : E ≃L[𝕜] F)
@[fun_prop]
protected theorem hasStrictFDerivAt : HasStrictFDerivAt iso (iso : E →L[𝕜] F) x :=
iso.toContinuousLinearMap.hasStrictFDerivAt
@[fun_prop]
protected theorem hasFDerivWithinAt : HasFDerivWithinAt iso (iso : E →L[𝕜] F) s x :=
iso.toContinuousLinearMap.hasFDerivWithinAt
@[fun_prop]
protected theorem hasFDerivAt : HasFDerivAt iso (iso : E →L[𝕜] F) x :=
iso.toContinuousLinearMap.hasFDerivAtFilter
@[fun_prop]
protected theorem differentiableAt : DifferentiableAt 𝕜 iso x :=
iso.hasFDerivAt.differentiableAt
@[fun_prop]
protected theorem differentiableWithinAt : DifferentiableWithinAt 𝕜 iso s x :=
iso.differentiableAt.differentiableWithinAt
protected theorem fderiv : fderiv 𝕜 iso x = iso :=
iso.hasFDerivAt.fderiv
protected theorem fderivWithin (hxs : UniqueDiffWithinAt 𝕜 s x) : fderivWithin 𝕜 iso s x = iso :=
iso.toContinuousLinearMap.fderivWithin hxs
@[fun_prop]
protected theorem differentiable : Differentiable 𝕜 iso := fun _ => iso.differentiableAt
@[fun_prop]
protected theorem differentiableOn : DifferentiableOn 𝕜 iso s :=
iso.differentiable.differentiableOn
theorem comp_differentiableWithinAt_iff {f : G → E} {s : Set G} {x : G} :
DifferentiableWithinAt 𝕜 (iso ∘ f) s x ↔ DifferentiableWithinAt 𝕜 f s x := by
refine ⟨fun H => ?_, fun H => iso.differentiable.differentiableAt.comp_differentiableWithinAt x H⟩
have : DifferentiableWithinAt 𝕜 (iso.symm ∘ iso ∘ f) s x :=
iso.symm.differentiable.differentiableAt.comp_differentiableWithinAt x H
rwa [← Function.comp_assoc iso.symm iso f, iso.symm_comp_self] at this
theorem comp_differentiableAt_iff {f : G → E} {x : G} :
DifferentiableAt 𝕜 (iso ∘ f) x ↔ DifferentiableAt 𝕜 f x := by
rw [← differentiableWithinAt_univ, ← differentiableWithinAt_univ,
iso.comp_differentiableWithinAt_iff]
theorem comp_differentiableOn_iff {f : G → E} {s : Set G} :
DifferentiableOn 𝕜 (iso ∘ f) s ↔ DifferentiableOn 𝕜 f s := by
rw [DifferentiableOn, DifferentiableOn]
simp only [iso.comp_differentiableWithinAt_iff]
theorem comp_differentiable_iff {f : G → E} : Differentiable 𝕜 (iso ∘ f) ↔ Differentiable 𝕜 f := by
rw [← differentiableOn_univ, ← differentiableOn_univ]
exact iso.comp_differentiableOn_iff
theorem comp_hasFDerivWithinAt_iff {f : G → E} {s : Set G} {x : G} {f' : G →L[𝕜] E} :
HasFDerivWithinAt (iso ∘ f) ((iso : E →L[𝕜] F).comp f') s x ↔ HasFDerivWithinAt f f' s x := by
refine ⟨fun H => ?_, fun H => iso.hasFDerivAt.comp_hasFDerivWithinAt x H⟩
simpa [Function.comp_def, ← ContinuousLinearMap.comp_assoc]
using iso.symm.hasFDerivAt.comp_hasFDerivWithinAt x H
theorem comp_hasStrictFDerivAt_iff {f : G → E} {x : G} {f' : G →L[𝕜] E} :
HasStrictFDerivAt (iso ∘ f) ((iso : E →L[𝕜] F).comp f') x ↔ HasStrictFDerivAt f f' x := by
refine ⟨fun H => ?_, fun H => iso.hasStrictFDerivAt.comp x H⟩
convert iso.symm.hasStrictFDerivAt.comp x H using 1 <;>
ext z <;> apply (iso.symm_apply_apply _).symm
theorem comp_hasFDerivAt_iff {f : G → E} {x : G} {f' : G →L[𝕜] E} :
HasFDerivAt (iso ∘ f) ((iso : E →L[𝕜] F).comp f') x ↔ HasFDerivAt f f' x := by
simp_rw [← hasFDerivWithinAt_univ, iso.comp_hasFDerivWithinAt_iff]
theorem comp_hasFDerivWithinAt_iff' {f : G → E} {s : Set G} {x : G} {f' : G →L[𝕜] F} :
HasFDerivWithinAt (iso ∘ f) f' s x ↔
HasFDerivWithinAt f ((iso.symm : F →L[𝕜] E).comp f') s x := by
rw [← iso.comp_hasFDerivWithinAt_iff, ← ContinuousLinearMap.comp_assoc, iso.coe_comp_coe_symm,
ContinuousLinearMap.id_comp]
theorem comp_hasFDerivAt_iff' {f : G → E} {x : G} {f' : G →L[𝕜] F} :
HasFDerivAt (iso ∘ f) f' x ↔ HasFDerivAt f ((iso.symm : F →L[𝕜] E).comp f') x := by
simp_rw [← hasFDerivWithinAt_univ, iso.comp_hasFDerivWithinAt_iff']
theorem comp_fderivWithin {f : G → E} {s : Set G} {x : G} (hxs : UniqueDiffWithinAt 𝕜 s x) :
fderivWithin 𝕜 (iso ∘ f) s x = (iso : E →L[𝕜] F).comp (fderivWithin 𝕜 f s x) := by
by_cases h : DifferentiableWithinAt 𝕜 f s x
· rw [fderiv_comp_fderivWithin x iso.differentiableAt h hxs, iso.fderiv]
· have : ¬DifferentiableWithinAt 𝕜 (iso ∘ f) s x := mt iso.comp_differentiableWithinAt_iff.1 h
rw [fderivWithin_zero_of_not_differentiableWithinAt h,
fderivWithin_zero_of_not_differentiableWithinAt this, ContinuousLinearMap.comp_zero]
theorem comp_fderiv {f : G → E} {x : G} :
fderiv 𝕜 (iso ∘ f) x = (iso : E →L[𝕜] F).comp (fderiv 𝕜 f x) := by
rw [← fderivWithin_univ, ← fderivWithin_univ]
exact iso.comp_fderivWithin uniqueDiffWithinAt_univ
lemma _root_.fderivWithin_continuousLinearEquiv_comp (L : G ≃L[𝕜] G') (f : E → (F →L[𝕜] G))
(hs : UniqueDiffWithinAt 𝕜 s x) :
fderivWithin 𝕜 (fun x ↦ (L : G →L[𝕜] G').comp (f x)) s x =
(((ContinuousLinearEquiv.refl 𝕜 F).arrowCongr L)) ∘L (fderivWithin 𝕜 f s x) := by
change fderivWithin 𝕜 (((ContinuousLinearEquiv.refl 𝕜 F).arrowCongr L) ∘ f) s x = _
rw [ContinuousLinearEquiv.comp_fderivWithin _ hs]
lemma _root_.fderiv_continuousLinearEquiv_comp (L : G ≃L[𝕜] G') (f : E → (F →L[𝕜] G)) (x : E) :
fderiv 𝕜 (fun x ↦ (L : G →L[𝕜] G').comp (f x)) x =
(((ContinuousLinearEquiv.refl 𝕜 F).arrowCongr L)) ∘L (fderiv 𝕜 f x) := by
change fderiv 𝕜 (((ContinuousLinearEquiv.refl 𝕜 F).arrowCongr L) ∘ f) x = _
rw [ContinuousLinearEquiv.comp_fderiv]
lemma _root_.fderiv_continuousLinearEquiv_comp' (L : G ≃L[𝕜] G') (f : E → (F →L[𝕜] G)) :
fderiv 𝕜 (fun x ↦ (L : G →L[𝕜] G').comp (f x)) =
fun x ↦ (((ContinuousLinearEquiv.refl 𝕜 F).arrowCongr L)) ∘L (fderiv 𝕜 f x) := by
ext x : 1
exact fderiv_continuousLinearEquiv_comp L f x
theorem comp_right_differentiableWithinAt_iff {f : F → G} {s : Set F} {x : E} :
DifferentiableWithinAt 𝕜 (f ∘ iso) (iso ⁻¹' s) x ↔ DifferentiableWithinAt 𝕜 f s (iso x) := by
refine ⟨fun H => ?_, fun H => H.comp x iso.differentiableWithinAt (mapsTo_preimage _ s)⟩
have : DifferentiableWithinAt 𝕜 ((f ∘ iso) ∘ iso.symm) s (iso x) := by
rw [← iso.symm_apply_apply x] at H
apply H.comp (iso x) iso.symm.differentiableWithinAt
intro y hy
simpa only [mem_preimage, apply_symm_apply] using hy
rwa [Function.comp_assoc, iso.self_comp_symm] at this
theorem comp_right_differentiableAt_iff {f : F → G} {x : E} :
DifferentiableAt 𝕜 (f ∘ iso) x ↔ DifferentiableAt 𝕜 f (iso x) := by
simp only [← differentiableWithinAt_univ, ← iso.comp_right_differentiableWithinAt_iff,
preimage_univ]
theorem comp_right_differentiableOn_iff {f : F → G} {s : Set F} :
DifferentiableOn 𝕜 (f ∘ iso) (iso ⁻¹' s) ↔ DifferentiableOn 𝕜 f s := by
refine ⟨fun H y hy => ?_, fun H y hy => iso.comp_right_differentiableWithinAt_iff.2 (H _ hy)⟩
rw [← iso.apply_symm_apply y, ← comp_right_differentiableWithinAt_iff]
apply H
simpa only [mem_preimage, apply_symm_apply] using hy
theorem comp_right_differentiable_iff {f : F → G} :
Differentiable 𝕜 (f ∘ iso) ↔ Differentiable 𝕜 f := by
simp only [← differentiableOn_univ, ← iso.comp_right_differentiableOn_iff, preimage_univ]
theorem comp_right_hasFDerivWithinAt_iff {f : F → G} {s : Set F} {x : E} {f' : F →L[𝕜] G} :
HasFDerivWithinAt (f ∘ iso) (f'.comp (iso : E →L[𝕜] F)) (iso ⁻¹' s) x ↔
HasFDerivWithinAt f f' s (iso x) := by
refine ⟨fun H => ?_, fun H => H.comp x iso.hasFDerivWithinAt (mapsTo_preimage _ s)⟩
rw [← iso.symm_apply_apply x] at H
have A : f = (f ∘ iso) ∘ iso.symm := by
rw [Function.comp_assoc, iso.self_comp_symm]
rfl
have B : f' = (f'.comp (iso : E →L[𝕜] F)).comp (iso.symm : F →L[𝕜] E) := by
rw [ContinuousLinearMap.comp_assoc, iso.coe_comp_coe_symm, ContinuousLinearMap.comp_id]
rw [A, B]
apply H.comp (iso x) iso.symm.hasFDerivWithinAt
intro y hy
simpa only [mem_preimage, apply_symm_apply] using hy
theorem comp_right_hasFDerivAt_iff {f : F → G} {x : E} {f' : F →L[𝕜] G} :
HasFDerivAt (f ∘ iso) (f'.comp (iso : E →L[𝕜] F)) x ↔ HasFDerivAt f f' (iso x) := by
simp only [← hasFDerivWithinAt_univ, ← comp_right_hasFDerivWithinAt_iff, preimage_univ]
theorem comp_right_hasFDerivWithinAt_iff' {f : F → G} {s : Set F} {x : E} {f' : E →L[𝕜] G} :
HasFDerivWithinAt (f ∘ iso) f' (iso ⁻¹' s) x ↔
HasFDerivWithinAt f (f'.comp (iso.symm : F →L[𝕜] E)) s (iso x) := by
rw [← iso.comp_right_hasFDerivWithinAt_iff, ContinuousLinearMap.comp_assoc,
iso.coe_symm_comp_coe, ContinuousLinearMap.comp_id]
theorem comp_right_hasFDerivAt_iff' {f : F → G} {x : E} {f' : E →L[𝕜] G} :
HasFDerivAt (f ∘ iso) f' x ↔ HasFDerivAt f (f'.comp (iso.symm : F →L[𝕜] E)) (iso x) := by
simp only [← hasFDerivWithinAt_univ, ← iso.comp_right_hasFDerivWithinAt_iff', preimage_univ]
theorem comp_right_fderivWithin {f : F → G} {s : Set F} {x : E}
(hxs : UniqueDiffWithinAt 𝕜 (iso ⁻¹' s) x) :
fderivWithin 𝕜 (f ∘ iso) (iso ⁻¹' s) x =
(fderivWithin 𝕜 f s (iso x)).comp (iso : E →L[𝕜] F) := by
by_cases h : DifferentiableWithinAt 𝕜 f s (iso x)
· exact (iso.comp_right_hasFDerivWithinAt_iff.2 h.hasFDerivWithinAt).fderivWithin hxs
· have : ¬DifferentiableWithinAt 𝕜 (f ∘ iso) (iso ⁻¹' s) x := by
intro h'
exact h (iso.comp_right_differentiableWithinAt_iff.1 h')
rw [fderivWithin_zero_of_not_differentiableWithinAt h,
fderivWithin_zero_of_not_differentiableWithinAt this, ContinuousLinearMap.zero_comp]
theorem comp_right_fderiv {f : F → G} {x : E} :
fderiv 𝕜 (f ∘ iso) x = (fderiv 𝕜 f (iso x)).comp (iso : E →L[𝕜] F) := by
rw [← fderivWithin_univ, ← fderivWithin_univ, ← iso.comp_right_fderivWithin, preimage_univ]
exact uniqueDiffWithinAt_univ
end ContinuousLinearEquiv
namespace LinearIsometryEquiv
/-! ### Differentiability of linear isometry equivs, and invariance of differentiability -/
variable (iso : E ≃ₗᵢ[𝕜] F)
@[fun_prop]
protected theorem hasStrictFDerivAt : HasStrictFDerivAt iso (iso : E →L[𝕜] F) x :=
(iso : E ≃L[𝕜] F).hasStrictFDerivAt
@[fun_prop]
protected theorem hasFDerivWithinAt : HasFDerivWithinAt iso (iso : E →L[𝕜] F) s x :=
(iso : E ≃L[𝕜] F).hasFDerivWithinAt
@[fun_prop]
protected theorem hasFDerivAt : HasFDerivAt iso (iso : E →L[𝕜] F) x :=
(iso : E ≃L[𝕜] F).hasFDerivAt
@[fun_prop]
protected theorem differentiableAt : DifferentiableAt 𝕜 iso x :=
iso.hasFDerivAt.differentiableAt
@[fun_prop]
protected theorem differentiableWithinAt : DifferentiableWithinAt 𝕜 iso s x :=
iso.differentiableAt.differentiableWithinAt
protected theorem fderiv : fderiv 𝕜 iso x = iso :=
iso.hasFDerivAt.fderiv
protected theorem fderivWithin (hxs : UniqueDiffWithinAt 𝕜 s x) : fderivWithin 𝕜 iso s x = iso :=
(iso : E ≃L[𝕜] F).fderivWithin hxs
@[fun_prop]
protected theorem differentiable : Differentiable 𝕜 iso := fun _ => iso.differentiableAt
@[fun_prop]
protected theorem differentiableOn : DifferentiableOn 𝕜 iso s :=
iso.differentiable.differentiableOn
theorem comp_differentiableWithinAt_iff {f : G → E} {s : Set G} {x : G} :
DifferentiableWithinAt 𝕜 (iso ∘ f) s x ↔ DifferentiableWithinAt 𝕜 f s x :=
(iso : E ≃L[𝕜] F).comp_differentiableWithinAt_iff
theorem comp_differentiableAt_iff {f : G → E} {x : G} :
DifferentiableAt 𝕜 (iso ∘ f) x ↔ DifferentiableAt 𝕜 f x :=
(iso : E ≃L[𝕜] F).comp_differentiableAt_iff
theorem comp_differentiableOn_iff {f : G → E} {s : Set G} :
DifferentiableOn 𝕜 (iso ∘ f) s ↔ DifferentiableOn 𝕜 f s :=
(iso : E ≃L[𝕜] F).comp_differentiableOn_iff
theorem comp_differentiable_iff {f : G → E} : Differentiable 𝕜 (iso ∘ f) ↔ Differentiable 𝕜 f :=
(iso : E ≃L[𝕜] F).comp_differentiable_iff
theorem comp_hasFDerivWithinAt_iff {f : G → E} {s : Set G} {x : G} {f' : G →L[𝕜] E} :
HasFDerivWithinAt (iso ∘ f) ((iso : E →L[𝕜] F).comp f') s x ↔ HasFDerivWithinAt f f' s x :=
(iso : E ≃L[𝕜] F).comp_hasFDerivWithinAt_iff
theorem comp_hasStrictFDerivAt_iff {f : G → E} {x : G} {f' : G →L[𝕜] E} :
HasStrictFDerivAt (iso ∘ f) ((iso : E →L[𝕜] F).comp f') x ↔ HasStrictFDerivAt f f' x :=
(iso : E ≃L[𝕜] F).comp_hasStrictFDerivAt_iff
theorem comp_hasFDerivAt_iff {f : G → E} {x : G} {f' : G →L[𝕜] E} :
HasFDerivAt (iso ∘ f) ((iso : E →L[𝕜] F).comp f') x ↔ HasFDerivAt f f' x :=
(iso : E ≃L[𝕜] F).comp_hasFDerivAt_iff
theorem comp_hasFDerivWithinAt_iff' {f : G → E} {s : Set G} {x : G} {f' : G →L[𝕜] F} :
HasFDerivWithinAt (iso ∘ f) f' s x ↔ HasFDerivWithinAt f ((iso.symm : F →L[𝕜] E).comp f') s x :=
(iso : E ≃L[𝕜] F).comp_hasFDerivWithinAt_iff'
theorem comp_hasFDerivAt_iff' {f : G → E} {x : G} {f' : G →L[𝕜] F} :
HasFDerivAt (iso ∘ f) f' x ↔ HasFDerivAt f ((iso.symm : F →L[𝕜] E).comp f') x :=
(iso : E ≃L[𝕜] F).comp_hasFDerivAt_iff'
theorem comp_fderivWithin {f : G → E} {s : Set G} {x : G} (hxs : UniqueDiffWithinAt 𝕜 s x) :
fderivWithin 𝕜 (iso ∘ f) s x = (iso : E →L[𝕜] F).comp (fderivWithin 𝕜 f s x) :=
(iso : E ≃L[𝕜] F).comp_fderivWithin hxs
theorem comp_fderiv {f : G → E} {x : G} :
fderiv 𝕜 (iso ∘ f) x = (iso : E →L[𝕜] F).comp (fderiv 𝕜 f x) :=
(iso : E ≃L[𝕜] F).comp_fderiv
theorem comp_fderiv' {f : G → E} :
fderiv 𝕜 (iso ∘ f) = fun x ↦ (iso : E →L[𝕜] F).comp (fderiv 𝕜 f x) := by
ext x : 1
exact LinearIsometryEquiv.comp_fderiv iso
end LinearIsometryEquiv
/-- If `f (g y) = y` for `y` in a neighborhood of `a` within `t`,
`g` maps a neighborhood of `a` within `t` to a neighborhood of `g a` within `s`,
and `f` has an invertible derivative `f'` at `g a` within `s`,
then `g` has the derivative `f'⁻¹` at `a` within `t`.
This is one of the easy parts of the inverse function theorem: it assumes that we already have an
inverse function. -/
theorem HasFDerivWithinAt.of_local_left_inverse {g : F → E} {f' : E ≃L[𝕜] F} {a : F} {t : Set F}
(hg : Tendsto g (𝓝[t] a) (𝓝[s] (g a))) (hf : HasFDerivWithinAt f (f' : E →L[𝕜] F) s (g a))
(ha : a ∈ t) (hfg : ∀ᶠ y in 𝓝[t] a, f (g y) = y) :
HasFDerivWithinAt g (f'.symm : F →L[𝕜] E) t a := by
have : (fun x : F => g x - g a - f'.symm (x - a)) =O[𝓝[t] a]
fun x : F => f' (g x - g a) - (x - a) :=
((f'.symm : F →L[𝕜] E).isBigO_comp _ _).congr (fun x ↦ by simp) fun _ ↦ rfl
refine .of_isLittleO <| this.trans_isLittleO ?_
clear this
refine ((hf.isLittleO.comp_tendsto hg).symm.congr' (hfg.mono ?_) .rfl).trans_isBigO ?_
· intro p hp
simp [hp, hfg.self_of_nhdsWithin ha]
· refine ((hf.isBigO_sub_rev f'.antilipschitz).comp_tendsto hg).congr'
(Eventually.of_forall fun _ => rfl) (hfg.mono ?_)
rintro p hp
simp only [(· ∘ ·), hp, hfg.self_of_nhdsWithin ha]
/-- If `f (g y) = y` for `y` in some neighborhood of `a`, `g` is continuous at `a`, and `f` has an
invertible derivative `f'` at `g a` in the strict sense, then `g` has the derivative `f'⁻¹` at `a`
in the strict sense.
This is one of the easy parts of the inverse function theorem: it assumes that we already have an
inverse function. -/
theorem HasStrictFDerivAt.of_local_left_inverse {f : E → F} {f' : E ≃L[𝕜] F} {g : F → E} {a : F}
(hg : ContinuousAt g a) (hf : HasStrictFDerivAt f (f' : E →L[𝕜] F) (g a))
(hfg : ∀ᶠ y in 𝓝 a, f (g y) = y) : HasStrictFDerivAt g (f'.symm : F →L[𝕜] E) a := by
replace hg := hg.prodMap' hg
replace hfg := hfg.prodMk_nhds hfg
have :
(fun p : F × F => g p.1 - g p.2 - f'.symm (p.1 - p.2)) =O[𝓝 (a, a)] fun p : F × F =>
f' (g p.1 - g p.2) - (p.1 - p.2) := by
refine ((f'.symm : F →L[𝕜] E).isBigO_comp _ _).congr (fun x => ?_) fun _ => rfl
simp
refine .of_isLittleO <| this.trans_isLittleO ?_
clear this
refine ((hf.isLittleO.comp_tendsto hg).symm.congr'
(hfg.mono ?_) (Eventually.of_forall fun _ => rfl)).trans_isBigO ?_
· rintro p ⟨hp1, hp2⟩
simp [hp1, hp2]
· refine (hf.isBigO_sub_rev.comp_tendsto hg).congr' (Eventually.of_forall fun _ => rfl)
(hfg.mono ?_)
rintro p ⟨hp1, hp2⟩
simp only [(· ∘ ·), hp1, hp2, Prod.map]
/-- If `f (g y) = y` for `y` in some neighborhood of `a`, `g` is continuous at `a`, and `f` has an
invertible derivative `f'` at `g a`, then `g` has the derivative `f'⁻¹` at `a`.
This is one of the easy parts of the inverse function theorem: it assumes that we already have
an inverse function. -/
theorem HasFDerivAt.of_local_left_inverse {f : E → F} {f' : E ≃L[𝕜] F} {g : F → E} {a : F}
(hg : ContinuousAt g a) (hf : HasFDerivAt f (f' : E →L[𝕜] F) (g a))
(hfg : ∀ᶠ y in 𝓝 a, f (g y) = y) : HasFDerivAt g (f'.symm : F →L[𝕜] E) a := by
simp only [← hasFDerivWithinAt_univ, ← nhdsWithin_univ] at hf hfg ⊢
exact hf.of_local_left_inverse (.inf hg (by simp)) (mem_univ _) hfg
/-- If `f` is an open partial homeomorphism defined on a neighbourhood of `f.symm a`, and `f` has an
invertible derivative `f'` in the sense of strict differentiability at `f.symm a`, then `f.symm` has
the derivative `f'⁻¹` at `a`.
This is one of the easy parts of the inverse function theorem: it assumes that we already have
an inverse function. -/
theorem OpenPartialHomeomorph.hasStrictFDerivAt_symm (f : OpenPartialHomeomorph E F)
{f' : E ≃L[𝕜] F} {a : F} (ha : a ∈ f.target)
(htff' : HasStrictFDerivAt f (f' : E →L[𝕜] F) (f.symm a)) :
HasStrictFDerivAt f.symm (f'.symm : F →L[𝕜] E) a :=
htff'.of_local_left_inverse (f.symm.continuousAt ha) (f.eventually_right_inverse ha)
/-- If `f` is an open partial homeomorphism defined on a neighbourhood of `f.symm a`, and `f` has an
invertible derivative `f'` at `f.symm a`, then `f.symm` has the derivative `f'⁻¹` at `a`.
This is one of the easy parts of the inverse function theorem: it assumes that we already have
an inverse function. -/
theorem OpenPartialHomeomorph.hasFDerivAt_symm (f : OpenPartialHomeomorph E F) {f' : E ≃L[𝕜] F}
{a : F} (ha : a ∈ f.target) (htff' : HasFDerivAt f (f' : E →L[𝕜] F) (f.symm a)) :
HasFDerivAt f.symm (f'.symm : F →L[𝕜] E) a :=
htff'.of_local_left_inverse (f.symm.continuousAt ha) (f.eventually_right_inverse ha)
theorem HasFDerivWithinAt.eventually_ne (h : HasFDerivWithinAt f f' s x)
(hf' : ∃ C, ∀ z, ‖z‖ ≤ C * ‖f' z‖) : ∀ᶠ z in 𝓝[s \ {x}] x, f z ≠ c := by
rcases eq_or_ne (f x) c with rfl | hc
· rw [nhdsWithin, diff_eq, ← inf_principal, ← inf_assoc, eventually_inf_principal]
have A : (fun z => z - x) =O[𝓝[s] x] fun z => f' (z - x) :=
isBigO_iff.2 <| hf'.imp fun C hC => Eventually.of_forall fun z => hC _
have : (fun z => f z - f x) ~[𝓝[s] x] fun z => f' (z - x) := h.isLittleO.trans_isBigO A
simpa [not_imp_not, sub_eq_zero] using (A.trans this.isBigO_symm).eq_zero_imp
· exact (h.continuousWithinAt.eventually_ne hc).filter_mono <| by gcongr; apply diff_subset
theorem HasFDerivAt.eventually_ne (h : HasFDerivAt f f' x) (hf' : ∃ C, ∀ z, ‖z‖ ≤ C * ‖f' z‖) :
∀ᶠ z in 𝓝[≠] x, f z ≠ c := by
simpa only [compl_eq_univ_diff] using (hasFDerivWithinAt_univ.2 h).eventually_ne hf'
end
section
/-
In the special case of a normed space over the reals,
we can use scalar multiplication in the `tendsto` characterization
of the Fréchet derivative.
-/
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
variable {F : Type*} [NormedAddCommGroup F] [NormedSpace ℝ F]
variable {f : E → F} {f' : E →L[ℝ] F} {x : E}
theorem has_fderiv_at_filter_real_equiv {L : Filter E} :
Tendsto (fun x' : E => ‖x' - x‖⁻¹ * ‖f x' - f x - f' (x' - x)‖) L (𝓝 0) ↔
Tendsto (fun x' : E => ‖x' - x‖⁻¹ • (f x' - f x - f' (x' - x))) L (𝓝 0) := by
symm
rw [tendsto_iff_norm_sub_tendsto_zero]
refine tendsto_congr fun x' => ?_
simp [norm_smul]
theorem HasFDerivAt.lim_real (hf : HasFDerivAt f f' x) (v : E) :
Tendsto (fun c : ℝ => c • (f (x + c⁻¹ • v) - f x)) atTop (𝓝 (f' v)) := by
apply hf.lim v
rw [tendsto_atTop_atTop]
exact fun b => ⟨b, fun a ha => le_trans ha (le_abs_self _)⟩
end
open scoped Pointwise
section TangentCone
variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] {E : Type*} [NormedAddCommGroup E]
[NormedSpace 𝕜 E] {F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F] {f : E → F} {s : Set E}
{f' : E →L[𝕜] F} {x : E}
/-- The image of a tangent cone under the differential of a map is included in the tangent cone to
the image. -/
theorem HasFDerivWithinAt.mapsTo_tangent_cone (h : HasFDerivWithinAt f f' s x) :
MapsTo f' (tangentConeAt 𝕜 s x) (tangentConeAt 𝕜 (f '' s) (f x)) := by
rintro v ⟨c, d, dtop, clim, cdlim⟩
refine
⟨c, fun n => f (x + d n) - f x, mem_of_superset dtop ?_, clim, h.lim atTop dtop clim cdlim⟩
simp +contextual [-mem_image, mem_image_of_mem]
/-- If a set has the unique differentiability property at a point x, then the image of this set
under a map with onto derivative has also the unique differentiability property at the image point.
-/
theorem HasFDerivWithinAt.uniqueDiffWithinAt (h : HasFDerivWithinAt f f' s x)
(hs : UniqueDiffWithinAt 𝕜 s x) (h' : DenseRange f') : UniqueDiffWithinAt 𝕜 (f '' s) (f x) := by
refine ⟨h'.dense_of_mapsTo f'.continuous hs.1 ?_, h.continuousWithinAt.mem_closure_image hs.2⟩
change
Submodule.span 𝕜 (tangentConeAt 𝕜 s x) ≤
(Submodule.span 𝕜 (tangentConeAt 𝕜 (f '' s) (f x))).comap f'
rw [Submodule.span_le]
exact h.mapsTo_tangent_cone.mono Subset.rfl Submodule.subset_span
theorem UniqueDiffOn.image {f' : E → E →L[𝕜] F} (hs : UniqueDiffOn 𝕜 s)
(hf' : ∀ x ∈ s, HasFDerivWithinAt f (f' x) s x) (hd : ∀ x ∈ s, DenseRange (f' x)) :
UniqueDiffOn 𝕜 (f '' s) :=
forall_mem_image.2 fun x hx => (hf' x hx).uniqueDiffWithinAt (hs x hx) (hd x hx)
theorem HasFDerivWithinAt.uniqueDiffWithinAt_of_continuousLinearEquiv (e' : E ≃L[𝕜] F)
(h : HasFDerivWithinAt f (e' : E →L[𝕜] F) s x) (hs : UniqueDiffWithinAt 𝕜 s x) :
UniqueDiffWithinAt 𝕜 (f '' s) (f x) :=
h.uniqueDiffWithinAt hs e'.surjective.denseRange
theorem ContinuousLinearEquiv.uniqueDiffOn_image (e : E ≃L[𝕜] F) (h : UniqueDiffOn 𝕜 s) :
UniqueDiffOn 𝕜 (e '' s) :=
h.image (fun _ _ => e.hasFDerivWithinAt) fun _ _ => e.surjective.denseRange
@[simp]
theorem ContinuousLinearEquiv.uniqueDiffOn_image_iff (e : E ≃L[𝕜] F) :
UniqueDiffOn 𝕜 (e '' s) ↔ UniqueDiffOn 𝕜 s :=
⟨fun h => e.symm_image_image s ▸ e.symm.uniqueDiffOn_image h, e.uniqueDiffOn_image⟩
@[simp]
theorem ContinuousLinearEquiv.uniqueDiffOn_preimage_iff (e : F ≃L[𝕜] E) :
UniqueDiffOn 𝕜 (e ⁻¹' s) ↔ UniqueDiffOn 𝕜 s := by
rw [← e.image_symm_eq_preimage, e.symm.uniqueDiffOn_image_iff]
protected theorem UniqueDiffWithinAt.smul (h : UniqueDiffWithinAt 𝕜 s x) {c : 𝕜} (hc : c ≠ 0) :
UniqueDiffWithinAt 𝕜 (c • s) (c • x) :=
(ContinuousLinearEquiv.smulLeft <| Units.mk0 c hc).hasFDerivWithinAt
|>.uniqueDiffWithinAt_of_continuousLinearEquiv _ h
protected theorem UniqueDiffWithinAt.smul_iff {c : 𝕜} (hc : c ≠ 0) :
UniqueDiffWithinAt 𝕜 (c • s) (c • x) ↔ UniqueDiffWithinAt 𝕜 s x :=
⟨fun h ↦ by simpa [hc] using h.smul (inv_ne_zero hc), (.smul · hc)⟩
end TangentCone
section SMulLeft
variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] {E : Type*} [NormedAddCommGroup E]
[NormedSpace 𝕜 E] {F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F] {f : E → F} {s : Set E}
{f' : E →L[𝕜] F} {x : E}
theorem fderivWithin_const_smul_field {R : Type*} [DivisionRing R] [Module R F]
[SMulCommClass 𝕜 R F] [ContinuousConstSMul R F] (c : R) (hs : UniqueDiffWithinAt 𝕜 s x) :
fderivWithin 𝕜 (c • f) s x = c • fderivWithin 𝕜 f s x := by
rcases eq_or_ne c 0 with rfl | hc
· simp
· lift c to Rˣ using IsUnit.mk0 _ hc
have : SMulCommClass Rˣ 𝕜 F := .symm _ _ _
exact (ContinuousLinearEquiv.smulLeft c).comp_fderivWithin hs
theorem hasFDerivWithinAt_comp_smul_smul_iff {c : 𝕜} :
HasFDerivWithinAt (f <| c • ·) (c • f') s x ↔ HasFDerivWithinAt f f' (c • s) (c • x) := by
rcases eq_or_ne c 0 with rfl | hc
· simp [hasFDerivWithinAt_const, HasFDerivWithinAt.of_subsingleton (subsingleton_zero_smul_set _)]
· lift c to 𝕜ˣ using IsUnit.mk0 c hc
have A : f'.comp ((ContinuousLinearEquiv.smulLeft c : E ≃L[𝕜] E) : E →L[𝕜] E) = c • f' := by
ext; simp
rw [← Units.smul_def c x, ← ContinuousLinearEquiv.smulLeft_apply_apply (R₁ := 𝕜),
← ContinuousLinearEquiv.comp_right_hasFDerivWithinAt_iff, A]
simp [Function.comp_def, ← Units.smul_def, ← preimage_smul_inv, preimage_preimage]
theorem hasFDerivWithinAt_comp_smul_iff_smul {c : 𝕜} (hc : c ≠ 0) :
HasFDerivWithinAt (f <| c • ·) f' s x ↔ HasFDerivWithinAt (c • f) f' (c • s) (c • x) := by
simp only [← hasFDerivWithinAt_comp_smul_smul_iff, Pi.smul_apply]
lift c to 𝕜ˣ using IsUnit.mk0 c hc
exact (ContinuousLinearEquiv.smulLeft c).comp_hasFDerivWithinAt_iff.symm
theorem fderivWithin_comp_smul_eq_fderivWithin_smul (c : 𝕜) :
fderivWithin 𝕜 (f <| c • ·) s x = fderivWithin 𝕜 (c • f) (c • s) (c • x) := by
rcases eq_or_ne c 0 with rfl | hc
· simp
· classical
simp only [fderivWithin, DifferentiableWithinAt, hasFDerivWithinAt_comp_smul_iff_smul hc]
theorem fderivWithin_comp_smul (c : 𝕜) (hs : UniqueDiffWithinAt 𝕜 s x) :
fderivWithin 𝕜 (f <| c • ·) s x = c • fderivWithin 𝕜 f (c • s) (c • x) := by
rcases eq_or_ne c 0 with rfl | hc
· simp
· rw [fderivWithin_comp_smul_eq_fderivWithin_smul, fderivWithin_const_smul_field]
exact hs.smul hc
theorem fderiv_comp_smul (c : 𝕜) : fderiv 𝕜 (f <| c • ·) x = c • fderiv 𝕜 f (c • x) := by
rw [← fderivWithin_univ, fderivWithin_comp_smul _ uniqueDiffWithinAt_univ]
rcases eq_or_ne c 0 with rfl | hc <;> simp [smul_set_univ₀, *]
end SMulLeft |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/FDeriv/WithLp.lean | import Mathlib.Analysis.Calculus.FDeriv.Prod
import Mathlib.Analysis.Calculus.FDeriv.Equiv
import Mathlib.Analysis.Normed.Lp.PiLp
/-!
# Derivatives on `WithLp`
-/
open ContinuousLinearMap PiLp WithLp
section PiLp
variable {𝕜 ι : Type*} {E : ι → Type*} {H : Type*}
variable [NontriviallyNormedField 𝕜] [NormedAddCommGroup H] [∀ i, NormedAddCommGroup (E i)]
[∀ i, NormedSpace 𝕜 (E i)] [NormedSpace 𝕜 H] [Fintype ι] (p) [Fact (1 ≤ p)]
{f : H → PiLp p E} {f' : H →L[𝕜] PiLp p E} {t : Set H} {y : H}
theorem differentiableWithinAt_piLp :
DifferentiableWithinAt 𝕜 f t y ↔ ∀ i, DifferentiableWithinAt 𝕜 (fun x => f x i) t y := by
rw [← (PiLp.continuousLinearEquiv p 𝕜 E).comp_differentiableWithinAt_iff,
differentiableWithinAt_pi]
rfl
theorem differentiableAt_piLp :
DifferentiableAt 𝕜 f y ↔ ∀ i, DifferentiableAt 𝕜 (fun x => f x i) y := by
rw [← (PiLp.continuousLinearEquiv p 𝕜 E).comp_differentiableAt_iff, differentiableAt_pi]
rfl
theorem differentiableOn_piLp :
DifferentiableOn 𝕜 f t ↔ ∀ i, DifferentiableOn 𝕜 (fun x => f x i) t := by
rw [← (PiLp.continuousLinearEquiv p 𝕜 E).comp_differentiableOn_iff, differentiableOn_pi]
rfl
theorem differentiable_piLp : Differentiable 𝕜 f ↔ ∀ i, Differentiable 𝕜 fun x => f x i := by
rw [← (PiLp.continuousLinearEquiv p 𝕜 E).comp_differentiable_iff, differentiable_pi]
rfl
theorem hasStrictFDerivAt_piLp :
HasStrictFDerivAt f f' y ↔
∀ i, HasStrictFDerivAt (fun x => f x i) (PiLp.proj _ _ i ∘L f') y := by
rw [← (PiLp.continuousLinearEquiv p 𝕜 E).comp_hasStrictFDerivAt_iff, hasStrictFDerivAt_pi']
rfl
theorem hasFDerivWithinAt_piLp :
HasFDerivWithinAt f f' t y ↔
∀ i, HasFDerivWithinAt (fun x => f x i) (PiLp.proj _ _ i ∘L f') t y := by
rw [← (PiLp.continuousLinearEquiv p 𝕜 E).comp_hasFDerivWithinAt_iff, hasFDerivWithinAt_pi']
rfl
namespace PiLp
theorem hasStrictFDerivAt_ofLp (f : PiLp p E) :
HasStrictFDerivAt ofLp (continuousLinearEquiv p 𝕜 _).toContinuousLinearMap f :=
.of_isLittleO <| (Asymptotics.isLittleO_zero _ _).congr_left fun _ => (sub_self _).symm
@[deprecated hasStrictFDerivAt_ofLp (since := "2025-05-07")]
theorem hasStrictFDerivAt_equiv (f : PiLp p E) :
HasStrictFDerivAt (WithLp.equiv p _)
(continuousLinearEquiv p 𝕜 _).toContinuousLinearMap f :=
hasStrictFDerivAt_ofLp _ f
theorem hasStrictFDerivAt_toLp (f : ∀ i, E i) :
HasStrictFDerivAt (toLp p) (continuousLinearEquiv p 𝕜 _).symm.toContinuousLinearMap f :=
.of_isLittleO <| (Asymptotics.isLittleO_zero _ _).congr_left fun _ => (sub_self _).symm
@[deprecated hasStrictFDerivAt_toLp (since := "2025-05-07")]
theorem hasStrictFDerivAt_equiv_symm (f : ∀ i, E i) :
HasStrictFDerivAt (WithLp.equiv p _).symm
(continuousLinearEquiv p 𝕜 _).symm.toContinuousLinearMap f :=
hasStrictFDerivAt_toLp _ f
nonrec theorem hasStrictFDerivAt_apply (f : PiLp p E) (i : ι) :
HasStrictFDerivAt (𝕜 := 𝕜) (fun f : PiLp p E => f i) (proj p E i) f :=
(hasStrictFDerivAt_apply i f).comp f (hasStrictFDerivAt_ofLp (𝕜 := 𝕜) p f)
theorem hasFDerivAt_ofLp (f : PiLp p E) :
HasFDerivAt ofLp (continuousLinearEquiv p 𝕜 _).toContinuousLinearMap f :=
(hasStrictFDerivAt_ofLp p f).hasFDerivAt
@[deprecated hasFDerivAt_ofLp (since := "2025-05-07")]
theorem hasFDerivAt_equiv (f : PiLp p E) :
HasFDerivAt (WithLp.equiv _ _) (continuousLinearEquiv p 𝕜 _).toContinuousLinearMap f :=
hasFDerivAt_ofLp _ f
theorem hasFDerivAt_toLp (f : ∀ i, E i) :
HasFDerivAt (toLp p) (continuousLinearEquiv p 𝕜 _).symm.toContinuousLinearMap f :=
(hasStrictFDerivAt_toLp p f).hasFDerivAt
@[deprecated hasFDerivAt_toLp (since := "2025-05-07")]
theorem hasFDerivAt_equiv_symm (f : ∀ i, E i) :
HasFDerivAt (WithLp.equiv _ _).symm
(continuousLinearEquiv p 𝕜 _).symm.toContinuousLinearMap f :=
hasFDerivAt_toLp _ f
nonrec theorem hasFDerivAt_apply (f : PiLp p E) (i : ι) :
HasFDerivAt (𝕜 := 𝕜) (fun f : PiLp p E => f i) (proj p E i) f :=
(hasStrictFDerivAt_apply p f i).hasFDerivAt
end PiLp
end PiLp |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/FDeriv/Symmetric.lean | import Mathlib.Analysis.Analytic.IteratedFDeriv
import Mathlib.Analysis.Calculus.Deriv.Pow
import Mathlib.Analysis.Calculus.MeanValue
import Mathlib.Analysis.Calculus.ContDiff.Basic
/-!
# Symmetry of the second derivative
We show that, over the reals, the second derivative is symmetric.
The most precise result is `Convex.second_derivative_within_at_symmetric`. It asserts that,
if a function is differentiable inside a convex set `s` with nonempty interior, and has a second
derivative within `s` at a point `x`, then this second derivative at `x` is symmetric. Note that
this result does not require continuity of the first derivative.
The following particular cases of this statement are especially relevant:
`second_derivative_symmetric_of_eventually` asserts that, if a function is differentiable on a
neighborhood of `x`, and has a second derivative at `x`, then this second derivative is symmetric.
`second_derivative_symmetric` asserts that, if a function is differentiable, and has a second
derivative at `x`, then this second derivative is symmetric.
There statements are given over `ℝ` or `ℂ`, the general version being deduced from the real
version. We also give statements in terms of `fderiv` and `fderivWithin`, called respectively
`ContDiffAt.isSymmSndFDerivAt` and `ContDiffWithinAt.isSymmSndFDerivWithinAt` (the latter
requiring that the point under consideration is accumulated by points in the interior of the set).
These are written using ad hoc predicates `IsSymmSndFDerivAt` and `IsSymmSndFDerivWithinAt`, which
increase readability of statements in differential geometry where they show up a lot.
We also deduce statements over an arbitrary field, requiring that the function is `C^2` if the field
is `ℝ` or `ℂ`, and analytic otherwise. Formally, we assume that the function is `C^n`
with `minSmoothness 𝕜 2 ≤ n`, where `minSmoothness 𝕜 i` is `i` if `𝕜` is `ℝ` or `ℂ`,
and `ω` otherwise.
## Implementation note
For the proof, we obtain an asymptotic expansion to order two of `f (x + v + w) - f (x + v)`, by
using the mean value inequality applied to a suitable function along the
segment `[x + v, x + v + w]`. This expansion involves `f'' ⬝ w` as we move along a segment directed
by `w` (see `Convex.taylor_approx_two_segment`).
Consider the alternate sum `f (x + v + w) + f x - f (x + v) - f (x + w)`, corresponding to the
values of `f` along a rectangle based at `x` with sides `v` and `w`. One can write it using the two
sides directed by `w`, as `(f (x + v + w) - f (x + v)) - (f (x + w) - f x)`. Together with the
previous asymptotic expansion, one deduces that it equals `f'' v w + o(1)` when `v, w` tends to `0`.
Exchanging the roles of `v` and `w`, one instead gets an asymptotic expansion `f'' w v`, from which
the equality `f'' v w = f'' w v` follows.
In our most general statement, we only assume that `f` is differentiable inside a convex set `s`, so
a few modifications have to be made. Since we don't assume continuity of `f` at `x`, we consider
instead the rectangle based at `x + v + w` with sides `v` and `w`,
in `Convex.isLittleO_alternate_sum_square`, but the argument is essentially the same. It only works
when `v` and `w` both point towards the interior of `s`, to make sure that all the sides of the
rectangle are contained in `s` by convexity. The general case follows by linearity, though.
-/
open Asymptotics Set Filter
open scoped Topology ContDiff
section General
variable {𝕜 : Type*} [NontriviallyNormedField 𝕜]
{E F : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E] [NormedAddCommGroup F]
[NormedSpace 𝕜 F] {s t : Set E} {f : E → F} {x : E}
variable (𝕜) in
/-- Definition recording that a function has a symmetric second derivative within a set at
a point. This is automatic in most cases of interest (open sets over real or complex vector fields,
or general case for analytic functions), but we can express theorems of calculus using this
as a general assumption, and then specialize to these situations. -/
def IsSymmSndFDerivWithinAt (f : E → F) (s : Set E) (x : E) : Prop :=
∀ v w, fderivWithin 𝕜 (fderivWithin 𝕜 f s) s x v w = fderivWithin 𝕜 (fderivWithin 𝕜 f s) s x w v
variable (𝕜) in
/-- Definition recording that a function has a symmetric second derivative at
a point. This is automatic in most cases of interest (open sets over real or complex vector fields,
or general case for analytic functions), but we can express theorems of calculus using this
as a general assumption, and then specialize to these situations. -/
def IsSymmSndFDerivAt (f : E → F) (x : E) : Prop :=
∀ v w, fderiv 𝕜 (fderiv 𝕜 f) x v w = fderiv 𝕜 (fderiv 𝕜 f) x w v
protected lemma IsSymmSndFDerivWithinAt.eq (h : IsSymmSndFDerivWithinAt 𝕜 f s x) (v w : E) :
fderivWithin 𝕜 (fderivWithin 𝕜 f s) s x v w = fderivWithin 𝕜 (fderivWithin 𝕜 f s) s x w v :=
h v w
protected lemma IsSymmSndFDerivAt.eq
(h : IsSymmSndFDerivAt 𝕜 f x) (v w : E) :
fderiv 𝕜 (fderiv 𝕜 f) x v w = fderiv 𝕜 (fderiv 𝕜 f) x w v :=
h v w
lemma fderivWithin_fderivWithin_eq_of_mem_nhdsWithin (h : t ∈ 𝓝[s] x)
(hf : ContDiffWithinAt 𝕜 2 f t x) (hs : UniqueDiffOn 𝕜 s) (ht : UniqueDiffOn 𝕜 t) (hx : x ∈ s) :
fderivWithin 𝕜 (fderivWithin 𝕜 f s) s x = fderivWithin 𝕜 (fderivWithin 𝕜 f t) t x := by
have A : ∀ᶠ y in 𝓝[s] x, fderivWithin 𝕜 f s y = fderivWithin 𝕜 f t y := by
have : ∀ᶠ y in 𝓝[s] x, ContDiffWithinAt 𝕜 2 f t y :=
nhdsWithin_le_iff.2 h (nhdsWithin_mono _ (subset_insert x t) (hf.eventually (by simp)))
filter_upwards [self_mem_nhdsWithin, this, eventually_eventually_nhdsWithin.2 h]
with y hy h'y h''y
exact fderivWithin_of_mem_nhdsWithin h''y (hs y hy) (h'y.differentiableWithinAt one_le_two)
have : fderivWithin 𝕜 (fderivWithin 𝕜 f s) s x = fderivWithin 𝕜 (fderivWithin 𝕜 f t) s x := by
apply Filter.EventuallyEq.fderivWithin_eq A
exact fderivWithin_of_mem_nhdsWithin h (hs x hx) (hf.differentiableWithinAt one_le_two)
rw [this]
apply fderivWithin_of_mem_nhdsWithin h (hs x hx)
exact (hf.fderivWithin_right (m := 1) ht le_rfl
(mem_of_mem_nhdsWithin hx h)).differentiableWithinAt le_rfl
lemma fderivWithin_fderivWithin_eq_of_eventuallyEq (h : s =ᶠ[𝓝 x] t) :
fderivWithin 𝕜 (fderivWithin 𝕜 f s) s x = fderivWithin 𝕜 (fderivWithin 𝕜 f t) t x := calc
fderivWithin 𝕜 (fderivWithin 𝕜 f s) s x
= fderivWithin 𝕜 (fderivWithin 𝕜 f t) s x :=
(fderivWithin_eventually_congr_set h).fderivWithin_eq_of_nhds
_ = fderivWithin 𝕜 (fderivWithin 𝕜 f t) t x := fderivWithin_congr_set h
lemma fderivWithin_fderivWithin_eq_of_mem_nhds {f : E → F} {x : E} {s : Set E}
(h : s ∈ 𝓝 x) :
fderivWithin 𝕜 (fderivWithin 𝕜 f s) s x = fderiv 𝕜 (fderiv 𝕜 f) x := by
simp only [← fderivWithin_univ]
apply fderivWithin_fderivWithin_eq_of_eventuallyEq
simp [h]
@[simp] lemma isSymmSndFDerivWithinAt_univ :
IsSymmSndFDerivWithinAt 𝕜 f univ x ↔ IsSymmSndFDerivAt 𝕜 f x := by
simp [IsSymmSndFDerivWithinAt, IsSymmSndFDerivAt]
theorem IsSymmSndFDerivWithinAt.mono_of_mem_nhdsWithin (h : IsSymmSndFDerivWithinAt 𝕜 f t x)
(hst : t ∈ 𝓝[s] x) (hf : ContDiffWithinAt 𝕜 2 f t x)
(hs : UniqueDiffOn 𝕜 s) (ht : UniqueDiffOn 𝕜 t) (hx : x ∈ s) :
IsSymmSndFDerivWithinAt 𝕜 f s x := by
intro v w
rw [fderivWithin_fderivWithin_eq_of_mem_nhdsWithin hst hf hs ht hx]
exact h v w
theorem IsSymmSndFDerivWithinAt.congr_set (h : IsSymmSndFDerivWithinAt 𝕜 f s x)
(hst : s =ᶠ[𝓝 x] t) : IsSymmSndFDerivWithinAt 𝕜 f t x := by
intro v w
rw [fderivWithin_fderivWithin_eq_of_eventuallyEq hst.symm]
exact h v w
theorem isSymmSndFDerivWithinAt_congr_set (hst : s =ᶠ[𝓝 x] t) :
IsSymmSndFDerivWithinAt 𝕜 f s x ↔ IsSymmSndFDerivWithinAt 𝕜 f t x :=
⟨fun h ↦ h.congr_set hst, fun h ↦ h.congr_set hst.symm⟩
theorem IsSymmSndFDerivAt.isSymmSndFDerivWithinAt (h : IsSymmSndFDerivAt 𝕜 f x)
(hf : ContDiffAt 𝕜 2 f x) (hs : UniqueDiffOn 𝕜 s) (hx : x ∈ s) :
IsSymmSndFDerivWithinAt 𝕜 f s x := by
simp only [← isSymmSndFDerivWithinAt_univ, ← contDiffWithinAt_univ] at h hf
exact h.mono_of_mem_nhdsWithin univ_mem hf hs uniqueDiffOn_univ hx
theorem isSymmSndFDerivWithinAt_iff_iteratedFDerivWithin (hs : UniqueDiffOn 𝕜 s) (hx : x ∈ s) :
IsSymmSndFDerivWithinAt 𝕜 f s x ↔
(iteratedFDerivWithin 𝕜 2 f s x).domDomCongr Fin.revPerm =
iteratedFDerivWithin 𝕜 2 f s x := by
simp_rw [IsSymmSndFDerivWithinAt, ContinuousMultilinearMap.ext_iff, Fin.forall_fin_succ_pi,
Fin.forall_fin_zero_pi]
simp [iteratedFDerivWithin_two_apply f hs hx, eq_comm]
theorem isSymmSndFDerivAt_iff_iteratedFDeriv :
IsSymmSndFDerivAt 𝕜 f x ↔
(iteratedFDeriv 𝕜 2 f x).domDomCongr Fin.revPerm = iteratedFDeriv 𝕜 2 f x := by
simp only [← isSymmSndFDerivWithinAt_univ, ← iteratedFDerivWithin_univ]
exact isSymmSndFDerivWithinAt_iff_iteratedFDerivWithin uniqueDiffOn_univ (mem_univ _)
theorem IsSymmSndFDerivWithinAt.iteratedFDerivWithin_cons {x v w : E}
{hf : IsSymmSndFDerivWithinAt 𝕜 f s x} (hs : UniqueDiffOn 𝕜 s) (hx : x ∈ s) :
iteratedFDerivWithin 𝕜 2 f s x ![v, w] = iteratedFDerivWithin 𝕜 2 f s x ![w, v] := by
simp_rw [isSymmSndFDerivWithinAt_iff_iteratedFDerivWithin hs hx, ContinuousMultilinearMap.ext_iff,
ContinuousMultilinearMap.domDomCongr_apply] at hf
convert hf ![w, v] using 2
ext i
fin_cases i <;> simp
theorem IsSymmSndFDerivAt.iteratedFDeriv_cons {x v w : E} {hf : IsSymmSndFDerivAt 𝕜 f x} :
iteratedFDeriv 𝕜 2 f x ![v, w] = iteratedFDeriv 𝕜 2 f x ![w, v] := by
simp only [← isSymmSndFDerivWithinAt_univ, ← iteratedFDerivWithin_univ] at *
exact hf.iteratedFDerivWithin_cons uniqueDiffOn_univ (mem_univ _)
/-- If a function is analytic within a set at a point, then its second derivative is symmetric. -/
theorem ContDiffWithinAt.isSymmSndFDerivWithinAt_of_omega (hf : ContDiffWithinAt 𝕜 ω f s x)
(hs : UniqueDiffOn 𝕜 s) (hx : x ∈ s) :
IsSymmSndFDerivWithinAt 𝕜 f s x := by
rw [isSymmSndFDerivWithinAt_iff_iteratedFDerivWithin hs hx]
exact hf.domDomCongr_iteratedFDerivWithin hs hx _
/-- If a function is analytic at a point, then its second derivative is symmetric. -/
theorem ContDiffAt.isSymmSndFDerivAt_of_omega (hf : ContDiffAt 𝕜 ω f x) :
IsSymmSndFDerivAt 𝕜 f x := by
simp only [← isSymmSndFDerivWithinAt_univ, ← contDiffWithinAt_univ] at hf ⊢
exact hf.isSymmSndFDerivWithinAt_of_omega uniqueDiffOn_univ (mem_univ _)
end General
section Real
variable {E F : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [NormedAddCommGroup F]
[NormedSpace ℝ F] {s : Set E} (s_conv : Convex ℝ s) {f : E → F} {f' : E → E →L[ℝ] F}
{f'' : E →L[ℝ] E →L[ℝ] F} (hf : ∀ x ∈ interior s, HasFDerivAt f (f' x) x) {x : E} (xs : x ∈ s)
(hx : HasFDerivWithinAt f' f'' (interior s) x)
section
include s_conv hf xs hx
/-- Assume that `f` is differentiable inside a convex set `s`, and that its derivative `f'` is
differentiable at a point `x`. Then, given two vectors `v` and `w` pointing inside `s`, one can
Taylor-expand to order two the function `f` on the segment `[x + h v, x + h (v + w)]`, giving a
bilinear estimate for `f (x + hv + hw) - f (x + hv)` in terms of `f' w` and of `f'' ⬝ w`, up to
`o(h^2)`.
This is a technical statement used to show that the second derivative is symmetric. -/
theorem Convex.taylor_approx_two_segment {v w : E} (hv : x + v ∈ interior s)
(hw : x + v + w ∈ interior s) :
(fun h : ℝ => f (x + h • v + h • w)
- f (x + h • v) - h • f' x w - h ^ 2 • f'' v w - (h ^ 2 / 2) • f'' w w) =o[𝓝[>] 0]
fun h => h ^ 2 := by
-- it suffices to check that the expression is bounded by `ε * ((‖v‖ + ‖w‖) * ‖w‖) * h^2` for
-- small enough `h`, for any positive `ε`.
refine IsLittleO.trans_isBigO
(isLittleO_iff.2 fun ε εpos => ?_) (isBigO_const_mul_self ((‖v‖ + ‖w‖) * ‖w‖) _ _)
-- consider a ball of radius `δ` around `x` in which the Taylor approximation for `f''` is
-- good up to `δ`.
rw [HasFDerivWithinAt, hasFDerivAtFilter_iff_isLittleO, isLittleO_iff] at hx
rcases Metric.mem_nhdsWithin_iff.1 (hx εpos) with ⟨δ, δpos, sδ⟩
have E1 : ∀ᶠ h in 𝓝[>] (0 : ℝ), h * (‖v‖ + ‖w‖) < δ := by
have : Filter.Tendsto (fun h => h * (‖v‖ + ‖w‖)) (𝓝[>] (0 : ℝ)) (𝓝 (0 * (‖v‖ + ‖w‖))) :=
(continuous_id.mul continuous_const).continuousWithinAt
apply (tendsto_order.1 this).2 δ
simpa only [zero_mul] using δpos
have E2 : ∀ᶠ h in 𝓝[>] (0 : ℝ), (h : ℝ) < 1 :=
mem_nhdsWithin_of_mem_nhds <| Iio_mem_nhds zero_lt_one
filter_upwards [E1, E2, self_mem_nhdsWithin] with h hδ h_lt_1 hpos
-- we consider `h` small enough that all points under consideration belong to this ball,
-- and also with `0 < h < 1`.
replace hpos : 0 < h := hpos
have xt_mem : ∀ t ∈ Icc (0 : ℝ) 1, x + h • v + (t * h) • w ∈ interior s := by
intro t ht
have : x + h • v ∈ interior s := s_conv.add_smul_mem_interior xs hv ⟨hpos, h_lt_1.le⟩
rw [← smul_smul]
apply s_conv.interior.add_smul_mem this _ ht
rw [add_assoc] at hw
convert s_conv.add_smul_mem_interior xs hw ⟨hpos, h_lt_1.le⟩ using 1
module
-- define a function `g` on `[0,1]` (identified with `[v, v + w]`) such that `g 1 - g 0` is the
-- quantity to be estimated. We will check that its derivative is given by an explicit
-- expression `g'`, that we can bound. Then the desired bound for `g 1 - g 0` follows from the
-- mean value inequality.
let g t :=
f (x + h • v + (t * h) • w) - (t * h) • f' x w - (t * h ^ 2) • f'' v w -
((t * h) ^ 2 / 2) • f'' w w
set g' := fun t =>
f' (x + h • v + (t * h) • w) (h • w) - h • f' x w - h ^ 2 • f'' v w - (t * h ^ 2) • f'' w w
with hg'
-- check that `g'` is the derivative of `g`, by a straightforward computation
have g_deriv : ∀ t ∈ Icc (0 : ℝ) 1, HasDerivWithinAt g (g' t) (Icc 0 1) t := by
intro t ht
apply_rules [HasDerivWithinAt.sub, HasDerivWithinAt.add]
· refine (hf _ ?_).comp_hasDerivWithinAt _ ?_
· exact xt_mem t ht
apply_rules [HasDerivAt.hasDerivWithinAt, HasDerivAt.const_add, HasDerivAt.smul_const,
hasDerivAt_mul_const]
· apply_rules [HasDerivAt.hasDerivWithinAt, HasDerivAt.smul_const, hasDerivAt_mul_const]
· apply_rules [HasDerivAt.hasDerivWithinAt, HasDerivAt.smul_const, hasDerivAt_mul_const]
· suffices H : HasDerivWithinAt (fun u => ((u * h) ^ 2 / 2) • f'' w w)
((((2 : ℕ) : ℝ) * (t * h) ^ (2 - 1) * (1 * h) / 2) • f'' w w) (Icc 0 1) t by
convert H using 2
ring
apply_rules [HasDerivAt.hasDerivWithinAt, HasDerivAt.smul_const, hasDerivAt_id',
HasDerivAt.pow, HasDerivAt.mul_const]
-- check that `g'` is uniformly bounded, with a suitable bound `ε * ((‖v‖ + ‖w‖) * ‖w‖) * h^2`.
have g'_bound : ∀ t ∈ Ico (0 : ℝ) 1, ‖g' t‖ ≤ ε * ((‖v‖ + ‖w‖) * ‖w‖) * h ^ 2 := by
intro t ht
have I : ‖h • v + (t * h) • w‖ ≤ h * (‖v‖ + ‖w‖) :=
calc
‖h • v + (t * h) • w‖ ≤ ‖h • v‖ + ‖(t * h) • w‖ := norm_add_le _ _
_ = h * ‖v‖ + t * (h * ‖w‖) := by
simp only [norm_smul, Real.norm_eq_abs, hpos.le, abs_of_nonneg, abs_mul, ht.left,
mul_assoc]
_ ≤ h * ‖v‖ + 1 * (h * ‖w‖) := by gcongr; exact ht.2.le
_ = h * (‖v‖ + ‖w‖) := by ring
calc
‖g' t‖ = ‖(f' (x + h • v + (t * h) • w) - f' x - f'' (h • v + (t * h) • w)) (h • w)‖ := by
rw [hg']
congrm ‖?_‖
simp only [ContinuousLinearMap.sub_apply, ContinuousLinearMap.add_apply,
ContinuousLinearMap.smul_apply, map_add, map_smul]
module
_ ≤ ‖f' (x + h • v + (t * h) • w) - f' x - f'' (h • v + (t * h) • w)‖ * ‖h • w‖ :=
(ContinuousLinearMap.le_opNorm _ _)
_ ≤ ε * ‖h • v + (t * h) • w‖ * ‖h • w‖ := by
gcongr
have H : x + h • v + (t * h) • w ∈ Metric.ball x δ ∩ interior s := by
refine ⟨?_, xt_mem t ⟨ht.1, ht.2.le⟩⟩
rw [add_assoc, add_mem_ball_iff_norm]
exact I.trans_lt hδ
simpa only [mem_setOf_eq, add_assoc x, add_sub_cancel_left] using sδ H
_ ≤ ε * (‖h • v‖ + ‖h • w‖) * ‖h • w‖ := by
gcongr
apply (norm_add_le _ _).trans
gcongr
simp only [norm_smul, Real.norm_eq_abs, abs_mul, abs_of_nonneg, ht.1, hpos.le, mul_assoc]
exact mul_le_of_le_one_left (by positivity) ht.2.le
_ = ε * ((‖v‖ + ‖w‖) * ‖w‖) * h ^ 2 := by
simp only [norm_smul, Real.norm_eq_abs, abs_of_nonneg, hpos.le]; ring
-- conclude using the mean value inequality
have I : ‖g 1 - g 0‖ ≤ ε * ((‖v‖ + ‖w‖) * ‖w‖) * h ^ 2 := by
simpa only [mul_one, sub_zero] using
norm_image_sub_le_of_norm_deriv_le_segment' g_deriv g'_bound 1 (right_mem_Icc.2 zero_le_one)
convert I using 1
· congr 1
simp only [g, add_zero, one_mul, zero_div, zero_mul, sub_zero,
zero_smul, Ne, not_false_iff, zero_pow, reduceCtorEq]
abel
· simp (discharger := positivity) only [Real.norm_eq_abs, abs_of_nonneg]
ring
/-- One can get `f'' v w` as the limit of `h ^ (-2)` times the alternate sum of the values of `f`
along the vertices of a quadrilateral with sides `h v` and `h w` based at `x`.
In a setting where `f` is not guaranteed to be continuous at `f`, we can still
get this if we use a quadrilateral based at `h v + h w`. -/
theorem Convex.isLittleO_alternate_sum_square {v w : E} (h4v : x + (4 : ℝ) • v ∈ interior s)
(h4w : x + (4 : ℝ) • w ∈ interior s) :
(fun h : ℝ => f (x + h • (2 • v + 2 • w)) + f (x + h • (v + w))
- f (x + h • (2 • v + w)) - f (x + h • (v + 2 • w)) - h ^ 2 • f'' v w) =o[𝓝[>] 0]
fun h => h ^ 2 := by
have A : (1 : ℝ) / 2 ∈ Ioc (0 : ℝ) 1 := ⟨by simp, by norm_num⟩
have B : (1 : ℝ) / 2 ∈ Icc (0 : ℝ) 1 := ⟨by simp, by norm_num⟩
have h2v2w : x + (2 : ℝ) • v + (2 : ℝ) • w ∈ interior s := by
convert s_conv.interior.add_smul_sub_mem h4v h4w B using 1
module
have h2vww : x + (2 • v + w) + w ∈ interior s := by
convert h2v2w using 1
module
have h2v : x + (2 : ℝ) • v ∈ interior s := by
convert s_conv.add_smul_sub_mem_interior xs h4v A using 1
module
have h2w : x + (2 : ℝ) • w ∈ interior s := by
convert s_conv.add_smul_sub_mem_interior xs h4w A using 1
module
have hvw : x + (v + w) ∈ interior s := by
convert s_conv.add_smul_sub_mem_interior xs h2v2w A using 1
module
have h2vw : x + (2 • v + w) ∈ interior s := by
convert s_conv.interior.add_smul_sub_mem h2v h2v2w B using 1
module
have hvww : x + (v + w) + w ∈ interior s := by
convert s_conv.interior.add_smul_sub_mem h2w h2v2w B using 1
module
have TA1 := s_conv.taylor_approx_two_segment hf xs hx h2vw h2vww
have TA2 := s_conv.taylor_approx_two_segment hf xs hx hvw hvww
convert TA1.sub TA2 using 1
ext h
simp only [two_smul, smul_add, ← add_assoc, ContinuousLinearMap.map_add,
ContinuousLinearMap.add_apply]
abel
/-- Assume that `f` is differentiable inside a convex set `s`, and that its derivative `f'` is
differentiable at a point `x`. Then, given two vectors `v` and `w` pointing inside `s`, one
has `f'' v w = f'' w v`. Superseded by `Convex.second_derivative_within_at_symmetric`, which
removes the assumption that `v` and `w` point inside `s`. -/
theorem Convex.second_derivative_within_at_symmetric_of_mem_interior {v w : E}
(h4v : x + (4 : ℝ) • v ∈ interior s) (h4w : x + (4 : ℝ) • w ∈ interior s) :
f'' w v = f'' v w := by
have A : (fun h : ℝ => h ^ 2 • (f'' w v - f'' v w)) =o[𝓝[>] 0] fun h => h ^ 2 := by
convert (s_conv.isLittleO_alternate_sum_square hf xs hx h4v h4w).sub
(s_conv.isLittleO_alternate_sum_square hf xs hx h4w h4v) using 1
ext h
simp only [add_comm, smul_add, smul_sub]
abel
have B : (fun _ : ℝ => f'' w v - f'' v w) =o[𝓝[>] 0] fun _ => (1 : ℝ) := by
have : (fun h : ℝ => 1 / h ^ 2) =O[𝓝[>] 0] fun h => 1 / h ^ 2 := isBigO_refl _ _
have C := this.smul_isLittleO A
apply C.congr' _ _
· filter_upwards [self_mem_nhdsWithin]
intro h (hpos : 0 < h)
match_scalars <;> field
· filter_upwards [self_mem_nhdsWithin] with h (hpos : 0 < h)
simp [field]
simpa only [sub_eq_zero] using isLittleO_const_const_iff.1 B
end
/-- If a function is differentiable inside a convex set with nonempty interior, and has a second
derivative at a point of this convex set, then this second derivative is symmetric. -/
theorem Convex.second_derivative_within_at_symmetric {s : Set E} (s_conv : Convex ℝ s)
(hne : (interior s).Nonempty) {f : E → F} {f' : E → E →L[ℝ] F} {f'' : E →L[ℝ] E →L[ℝ] F}
(hf : ∀ x ∈ interior s, HasFDerivAt f (f' x) x) {x : E} (xs : x ∈ s)
(hx : HasFDerivWithinAt f' f'' (interior s) x) (v w : E) : f'' v w = f'' w v := by
/- we work around a point `x + 4 z` in the interior of `s`. For any vector `m`,
then `x + 4 (z + t m)` also belongs to the interior of `s` for small enough `t`. This means that
we will be able to apply `second_derivative_within_at_symmetric_of_mem_interior` to show
that `f''` is symmetric, after cancelling all the contributions due to `z`. -/
rcases hne with ⟨y, hy⟩
obtain ⟨z, hz⟩ : ∃ z, z = ((1 : ℝ) / 4) • (y - x) := ⟨((1 : ℝ) / 4) • (y - x), rfl⟩
have A : ∀ m : E, Filter.Tendsto (fun t : ℝ => x + (4 : ℝ) • (z + t • m)) (𝓝 0) (𝓝 y) := by
intro m
have : x + (4 : ℝ) • (z + (0 : ℝ) • m) = y := by simp [hz]
rw [← this]
refine tendsto_const_nhds.add <| tendsto_const_nhds.smul <| tendsto_const_nhds.add ?_
exact continuousAt_id.smul continuousAt_const
have B : ∀ m : E, ∀ᶠ t in 𝓝[>] (0 : ℝ), x + (4 : ℝ) • (z + t • m) ∈ interior s := by
intro m
apply nhdsWithin_le_nhds
apply A m
rw [mem_interior_iff_mem_nhds] at hy
exact interior_mem_nhds.2 hy
-- we choose `t m > 0` such that `x + 4 (z + (t m) m)` belongs to the interior of `s`, for any
-- vector `m`.
choose t ts tpos using fun m => ((B m).and self_mem_nhdsWithin).exists
-- applying `second_derivative_within_at_symmetric_of_mem_interior` to the vectors `z`
-- and `z + (t m) m`, we deduce that `f'' m z = f'' z m` for all `m`.
have C : ∀ m : E, f'' m z = f'' z m := by
intro m
have : f'' (z + t m • m) (z + t 0 • (0 : E)) = f'' (z + t 0 • (0 : E)) (z + t m • m) :=
s_conv.second_derivative_within_at_symmetric_of_mem_interior hf xs hx (ts 0) (ts m)
simp only [ContinuousLinearMap.map_add, ContinuousLinearMap.map_smul, add_right_inj,
ContinuousLinearMap.add_apply, Pi.smul_apply, ContinuousLinearMap.coe_smul', add_zero,
smul_zero] at this
exact smul_right_injective F (tpos m).ne' this
-- applying `second_derivative_within_at_symmetric_of_mem_interior` to the vectors `z + (t v) v`
-- and `z + (t w) w`, we deduce that `f'' v w = f'' w v`. Cross terms involving `z` can be
-- eliminated thanks to the fact proved above that `f'' m z = f'' z m`.
have : f'' (z + t v • v) (z + t w • w) = f'' (z + t w • w) (z + t v • v) :=
s_conv.second_derivative_within_at_symmetric_of_mem_interior hf xs hx (ts w) (ts v)
simp only [ContinuousLinearMap.map_add, ContinuousLinearMap.map_smul, smul_smul,
ContinuousLinearMap.add_apply, Pi.smul_apply, ContinuousLinearMap.coe_smul', C] at this
have : (t v * t w) • (f'' v) w = (t v * t w) • (f'' w) v := by
linear_combination (norm := module) this
apply smul_right_injective F _ this
simp [(tpos v).ne', (tpos w).ne']
/-- If a function is differentiable around `x`, and has two derivatives at `x`, then the second
derivative is symmetric. Version over `ℝ`. See `second_derivative_symmetric_of_eventually` for a
version over `ℝ` or `ℂ`. -/
theorem second_derivative_symmetric_of_eventually_of_real {f : E → F} {f' : E → E →L[ℝ] F}
{f'' : E →L[ℝ] E →L[ℝ] F} (hf : ∀ᶠ y in 𝓝 x, HasFDerivAt f (f' y) y) (hx : HasFDerivAt f' f'' x)
(v w : E) : f'' v w = f'' w v := by
rcases Metric.mem_nhds_iff.1 hf with ⟨ε, εpos, hε⟩
have A : (interior (Metric.ball x ε)).Nonempty := by
rwa [Metric.isOpen_ball.interior_eq, Metric.nonempty_ball]
exact
Convex.second_derivative_within_at_symmetric (convex_ball x ε) A
(fun y hy => hε (interior_subset hy)) (Metric.mem_ball_self εpos) hx.hasFDerivWithinAt v w
end Real
section IsRCLikeNormedField
variable {𝕜 : Type*} [NontriviallyNormedField 𝕜]
{E F : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E] [NormedAddCommGroup F]
[NormedSpace 𝕜 F] {s : Set E} {f : E → F} {x : E}
theorem second_derivative_symmetric_of_eventually [IsRCLikeNormedField 𝕜]
{f' : E → E →L[𝕜] F} {x : E}
{f'' : E →L[𝕜] E →L[𝕜] F} (hf : ∀ᶠ y in 𝓝 x, HasFDerivAt f (f' y) y)
(hx : HasFDerivAt f' f'' x) (v w : E) : f'' v w = f'' w v := by
let _ := IsRCLikeNormedField.rclike 𝕜
let _ : NormedSpace ℝ E := NormedSpace.restrictScalars ℝ 𝕜 E
let _ : NormedSpace ℝ F := NormedSpace.restrictScalars ℝ 𝕜 F
let _ : LinearMap.CompatibleSMul E F ℝ 𝕜 := LinearMap.IsScalarTower.compatibleSMul
let _ : LinearMap.CompatibleSMul E (E →L[𝕜] F) ℝ 𝕜 := LinearMap.IsScalarTower.compatibleSMul
let f'R : E → E →L[ℝ] F := fun x ↦ (f' x).restrictScalars ℝ
have hfR : ∀ᶠ y in 𝓝 x, HasFDerivAt f (f'R y) y := by
filter_upwards [hf] with y hy using HasFDerivAt.restrictScalars ℝ hy
let f''Rl : E →ₗ[ℝ] E →ₗ[ℝ] F :=
{ toFun := fun x ↦
{ toFun := fun y ↦ f'' x y
map_add' := by simp
map_smul' := by simp }
map_add' := by intros; ext; simp
map_smul' := by intros; ext; simp }
let f''R : E →L[ℝ] E →L[ℝ] F := by
refine LinearMap.mkContinuous₂ f''Rl (‖f''‖) (fun x y ↦ ?_)
simp only [LinearMap.coe_mk, AddHom.coe_mk, f''Rl]
exact ContinuousLinearMap.le_opNorm₂ f'' x y
have : HasFDerivAt f'R f''R x := by
simp only [hasFDerivAt_iff_tendsto] at hx ⊢
exact hx
change f''R v w = f''R w v
exact second_derivative_symmetric_of_eventually_of_real hfR this v w
/-- If a function is differentiable, and has two derivatives at `x`, then the second
derivative is symmetric. -/
theorem second_derivative_symmetric [IsRCLikeNormedField 𝕜]
{f' : E → E →L[𝕜] F} {f'' : E →L[𝕜] E →L[𝕜] F} {x : E}
(hf : ∀ y, HasFDerivAt f (f' y) y) (hx : HasFDerivAt f' f'' x) (v w : E) : f'' v w = f'' w v :=
second_derivative_symmetric_of_eventually (Filter.Eventually.of_forall hf) hx v w
open scoped Classical in
variable (𝕜) in
/-- `minSmoothness 𝕜 n` is the minimal smoothness exponent larger than or equal to `n` for which
one can do serious calculus in `𝕜`. If `𝕜` is `ℝ` or `ℂ`, this is just `n`. Otherwise,
this is `ω` as only analytic functions are well behaved on `ℚₚ`, say. -/
noncomputable irreducible_def minSmoothness (n : WithTop ℕ∞) :=
if IsRCLikeNormedField 𝕜 then n else ω
@[simp] lemma minSmoothness_of_isRCLikeNormedField [h : IsRCLikeNormedField 𝕜] {n : WithTop ℕ∞} :
minSmoothness 𝕜 n = n := by
simp [minSmoothness, h]
lemma le_minSmoothness {n : WithTop ℕ∞} : n ≤ minSmoothness 𝕜 n := by
simp only [minSmoothness]
split_ifs <;> simp
lemma minSmoothness_add {n m : WithTop ℕ∞} : minSmoothness 𝕜 (n + m) = minSmoothness 𝕜 n + m := by
simp only [minSmoothness]
split_ifs <;> simp
lemma minSmoothness_monotone : Monotone (minSmoothness 𝕜) := by
intro m n hmn
simp only [minSmoothness]
split_ifs <;> simp [hmn]
@[simp] lemma minSmoothness_eq_infty {n : WithTop ℕ∞} :
minSmoothness 𝕜 n = ∞ ↔ (n = ∞ ∧ IsRCLikeNormedField 𝕜) := by
simp only [minSmoothness]
split_ifs with h <;> simp [h]
/-- If `minSmoothness 𝕜 m ≤ n` for some (finite) integer `m`, then one can
find `n' ∈ [minSmoothness 𝕜 m, n]` which is not `∞`: over `ℝ` or `ℂ`, just take `m`, and otherwise
just take `ω`. The interest of this technical lemma is that, if a function is `C^{n'}` at a point
for `n' ≠ ∞`, then it is `C^{n'}` on a neighborhood of the point (this property fails only
in `C^∞` smoothness, see `ContDiffWithinAt.contDiffOn`). -/
lemma exist_minSmoothness_le_ne_infty {n : WithTop ℕ∞} {m : ℕ} (hm : minSmoothness 𝕜 m ≤ n) :
∃ n', minSmoothness 𝕜 m ≤ n' ∧ n' ≤ n ∧ n' ≠ ∞ := by
simp only [minSmoothness] at hm ⊢
split_ifs with h
· simp only [h, ↓reduceIte] at hm
exact ⟨m, le_rfl, hm, by simp⟩
· simp only [h, ↓reduceIte, top_le_iff] at hm
refine ⟨ω, le_rfl, by simp [hm], by simp⟩
/-- If a function is `C^2` at a point, then its second derivative there is symmetric. Over a field
different from `ℝ` or `ℂ`, we should require that the function is analytic. -/
theorem ContDiffAt.isSymmSndFDerivAt {n : WithTop ℕ∞}
(hf : ContDiffAt 𝕜 n f x) (hn : minSmoothness 𝕜 2 ≤ n) : IsSymmSndFDerivAt 𝕜 f x := by
by_cases h : IsRCLikeNormedField 𝕜
-- First deal with the `ℝ` or `ℂ` case, where `C^2` is enough.
· intro v w
apply second_derivative_symmetric_of_eventually (f := f) (f' := fderiv 𝕜 f) (x := x)
· obtain ⟨u, hu, h'u⟩ : ∃ u ∈ 𝓝 x, ContDiffOn 𝕜 2 f u :=
(hf.of_le hn).contDiffOn (m := 2) le_minSmoothness (by simp)
rcases mem_nhds_iff.1 hu with ⟨v, vu, v_open, xv⟩
filter_upwards [v_open.mem_nhds xv] with y hy
have : DifferentiableAt 𝕜 f y := by
have := (h'u.mono vu y hy).contDiffAt (v_open.mem_nhds hy)
exact this.differentiableAt one_le_two
exact DifferentiableAt.hasFDerivAt this
· have : DifferentiableAt 𝕜 (fderiv 𝕜 f) x := by
apply ContDiffAt.differentiableAt _ le_rfl
exact hf.fderiv_right (le_minSmoothness.trans hn)
exact DifferentiableAt.hasFDerivAt this
-- then deal with the case of an arbitrary field, with analytic functions.
· simp only [minSmoothness, h, ↓reduceIte, top_le_iff] at hn
apply ContDiffAt.isSymmSndFDerivAt_of_omega
simpa [hn] using hf
/-- If a function is `C^2` within a set at a point, and accumulated by points in the interior
of the set, then its second derivative there is symmetric. Over a field
different from `ℝ` or `ℂ`, we should require that the function is analytic. -/
theorem ContDiffWithinAt.isSymmSndFDerivWithinAt {n : WithTop ℕ∞}
(hf : ContDiffWithinAt 𝕜 n f s x) (hn : minSmoothness 𝕜 2 ≤ n)
(hs : UniqueDiffOn 𝕜 s) (hx : x ∈ closure (interior s)) (h'x : x ∈ s) :
IsSymmSndFDerivWithinAt 𝕜 f s x := by
/- We argue that, at interior points, the second derivative is symmetric, and moreover by
continuity it converges to the second derivative at `x`. Therefore, the latter is also
symmetric. -/
obtain ⟨m, hm, hmn, m_ne⟩ := exist_minSmoothness_le_ne_infty hn
rcases (hf.of_le hmn).contDiffOn' le_rfl (by simp [m_ne]) with ⟨u, u_open, xu, hu⟩
simp only [insert_eq_of_mem h'x] at hu
have h'u : UniqueDiffOn 𝕜 (s ∩ u) := hs.inter u_open
obtain ⟨y, hy, y_lim⟩ : ∃ y, (∀ (n : ℕ), y n ∈ interior s) ∧ Tendsto y atTop (𝓝 x) :=
mem_closure_iff_seq_limit.1 hx
have L : ∀ᶠ k in atTop, y k ∈ u := y_lim (u_open.mem_nhds xu)
have I : ∀ᶠ k in atTop, IsSymmSndFDerivWithinAt 𝕜 f s (y k) := by
filter_upwards [L] with k hk
have s_mem : s ∈ 𝓝 (y k) := by
apply mem_of_superset (isOpen_interior.mem_nhds (hy k))
exact interior_subset
have : IsSymmSndFDerivAt 𝕜 f (y k) := by
apply ContDiffAt.isSymmSndFDerivAt _ (n := m) hm
apply (hu (y k) ⟨(interior_subset (hy k)), hk⟩).contDiffAt
exact inter_mem s_mem (u_open.mem_nhds hk)
intro v w
rw [fderivWithin_fderivWithin_eq_of_mem_nhds s_mem]
exact this v w
have A : ContinuousOn (fderivWithin 𝕜 (fderivWithin 𝕜 f s) s) (s ∩ u) := by
have : ContinuousOn (fderivWithin 𝕜 (fderivWithin 𝕜 f (s ∩ u)) (s ∩ u)) (s ∩ u) :=
((hu.fderivWithin h'u (m := 1) (le_minSmoothness.trans hm)).fderivWithin h'u
(m := 0) le_rfl).continuousOn
apply this.congr
intro y hy
apply fderivWithin_fderivWithin_eq_of_eventuallyEq
filter_upwards [u_open.mem_nhds hy.2] with z hz
change (z ∈ s) = (z ∈ s ∩ u)
simp_all
have B : Tendsto (fun k ↦ fderivWithin 𝕜 (fderivWithin 𝕜 f s) s (y k)) atTop
(𝓝 (fderivWithin 𝕜 (fderivWithin 𝕜 f s) s x)) := by
have : Tendsto y atTop (𝓝[s ∩ u] x) := by
apply tendsto_nhdsWithin_iff.2 ⟨y_lim, ?_⟩
filter_upwards [L] with k hk using ⟨interior_subset (hy k), hk⟩
exact (A x ⟨h'x, xu⟩ ).tendsto.comp this
have C (v w : E) : Tendsto (fun k ↦ fderivWithin 𝕜 (fderivWithin 𝕜 f s) s (y k) v w) atTop
(𝓝 (fderivWithin 𝕜 (fderivWithin 𝕜 f s) s x v w)) := by
have : Continuous (fun (A : E →L[𝕜] E →L[𝕜] F) ↦ A v w) := by fun_prop
exact (this.tendsto _).comp B
have C' (v w : E) : Tendsto (fun k ↦ fderivWithin 𝕜 (fderivWithin 𝕜 f s) s (y k) w v) atTop
(𝓝 (fderivWithin 𝕜 (fderivWithin 𝕜 f s) s x v w)) := by
apply (C v w).congr'
filter_upwards [I] with k hk using hk v w
intro v w
exact tendsto_nhds_unique (C v w) (C' w v)
end IsRCLikeNormedField |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/FDeriv/Extend.lean | import Mathlib.Analysis.Calculus.MeanValue
/-!
# Extending differentiability to the boundary
We investigate how differentiable functions inside a set extend to differentiable functions
on the boundary. For this, it suffices that the function and its derivative admit limits there.
A general version of this statement is given in `hasFDerivWithinAt_closure_of_tendsto_fderiv`.
One-dimensional versions, in which one wants to obtain differentiability at the left endpoint or
the right endpoint of an interval, are given in `hasDerivWithinAt_Ici_of_tendsto_deriv` and
`hasDerivWithinAt_Iic_of_tendsto_deriv`. These versions are formulated in terms of the
one-dimensional derivative `deriv ℝ f`.
-/
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] {F : Type*} [NormedAddCommGroup F]
[NormedSpace ℝ F]
open Filter Set Metric ContinuousLinearMap
open scoped Topology
/-- If a function `f` is differentiable in a convex open set and continuous on its closure, and its
derivative converges to a limit `f'` at a point on the boundary, then `f` is differentiable there
with derivative `f'`. -/
theorem hasFDerivWithinAt_closure_of_tendsto_fderiv {f : E → F} {s : Set E} {x : E} {f' : E →L[ℝ] F}
(f_diff : DifferentiableOn ℝ f s) (s_conv : Convex ℝ s) (s_open : IsOpen s)
(f_cont : ∀ y ∈ closure s, ContinuousWithinAt f s y)
(h : Tendsto (fun y => fderiv ℝ f y) (𝓝[s] x) (𝓝 f')) :
HasFDerivWithinAt f f' (closure s) x := by
classical
-- one can assume without loss of generality that `x` belongs to the closure of `s`, as the
-- statement is empty otherwise
by_cases! hx : x ∉ closure s
· rw [← closure_closure] at hx; exact HasFDerivWithinAt.of_notMem_closure hx
rw [HasFDerivWithinAt, hasFDerivAtFilter_iff_isLittleO, Asymptotics.isLittleO_iff]
/- One needs to show that `‖f y - f x - f' (y - x)‖ ≤ ε ‖y - x‖` for `y` close to `x` in
`closure s`, where `ε` is an arbitrary positive constant. By continuity of the functions, it
suffices to prove this for nearby points inside `s`. In a neighborhood of `x`, the derivative
of `f` is arbitrarily close to `f'` by assumption. The mean value inequality completes the
proof. -/
intro ε ε_pos
obtain ⟨δ, δ_pos, hδ⟩ : ∃ δ > 0, ∀ y ∈ s, dist y x < δ → ‖fderiv ℝ f y - f'‖ < ε := by
simpa [dist_zero_right] using tendsto_nhdsWithin_nhds.1 h ε ε_pos
set B := ball x δ
suffices ∀ y ∈ B ∩ closure s, ‖f y - f x - (f' y - f' x)‖ ≤ ε * ‖y - x‖ from
mem_nhdsWithin_iff.2 ⟨δ, δ_pos, fun y hy => by simpa using this y hy⟩
suffices
∀ p : E × E,
p ∈ closure ((B ∩ s) ×ˢ (B ∩ s)) → ‖f p.2 - f p.1 - (f' p.2 - f' p.1)‖ ≤ ε * ‖p.2 - p.1‖ by
rw [closure_prod_eq] at this
intro y y_in
apply this ⟨x, y⟩
have : B ∩ closure s ⊆ closure (B ∩ s) := isOpen_ball.inter_closure
exact ⟨this ⟨mem_ball_self δ_pos, hx⟩, this y_in⟩
have key : ∀ p : E × E, p ∈ (B ∩ s) ×ˢ (B ∩ s) →
‖f p.2 - f p.1 - (f' p.2 - f' p.1)‖ ≤ ε * ‖p.2 - p.1‖ := by
rintro ⟨u, v⟩ ⟨u_in, v_in⟩
have conv : Convex ℝ (B ∩ s) := (convex_ball _ _).inter s_conv
have diff : DifferentiableOn ℝ f (B ∩ s) := f_diff.mono inter_subset_right
have bound : ∀ z ∈ B ∩ s, ‖fderivWithin ℝ f (B ∩ s) z - f'‖ ≤ ε := by
intro z z_in
have h := hδ z
have : fderivWithin ℝ f (B ∩ s) z = fderiv ℝ f z := by
have op : IsOpen (B ∩ s) := isOpen_ball.inter s_open
rw [DifferentiableAt.fderivWithin _ (op.uniqueDiffOn z z_in)]
exact (diff z z_in).differentiableAt (IsOpen.mem_nhds op z_in)
rw [← this] at h
exact le_of_lt (h z_in.2 z_in.1)
simpa using conv.norm_image_sub_le_of_norm_fderivWithin_le' diff bound u_in v_in
rintro ⟨u, v⟩ uv_in
have f_cont' : ∀ y ∈ closure s, ContinuousWithinAt (f - ⇑f') s y := by
intro y y_in
exact Tendsto.sub (f_cont y y_in) f'.cont.continuousWithinAt
refine ContinuousWithinAt.closure_le uv_in ?_ ?_ key
all_goals
-- common start for both continuity proofs
have : (B ∩ s) ×ˢ (B ∩ s) ⊆ s ×ˢ s := by gcongr <;> exact inter_subset_right
obtain ⟨u_in, v_in⟩ : u ∈ closure s ∧ v ∈ closure s := by
simpa [closure_prod_eq] using closure_mono this uv_in
apply ContinuousWithinAt.mono _ this
simp only [ContinuousWithinAt]
· rw [nhdsWithin_prod_eq]
have : ∀ u v, f v - f u - (f' v - f' u) = f v - f' v - (f u - f' u) := by intros; abel
simp only [this]
exact
Tendsto.comp continuous_norm.continuousAt
((Tendsto.comp (f_cont' v v_in) tendsto_snd).sub <|
Tendsto.comp (f_cont' u u_in) tendsto_fst)
· apply tendsto_nhdsWithin_of_tendsto_nhds
rw [nhds_prod_eq]
exact
tendsto_const_nhds.mul
(Tendsto.comp continuous_norm.continuousAt <| tendsto_snd.sub tendsto_fst)
/-- If a function is differentiable on the right of a point `a : ℝ`, continuous at `a`, and
its derivative also converges at `a`, then `f` is differentiable on the right at `a`. -/
theorem hasDerivWithinAt_Ici_of_tendsto_deriv {s : Set ℝ} {e : E} {a : ℝ} {f : ℝ → E}
(f_diff : DifferentiableOn ℝ f s) (f_lim : ContinuousWithinAt f s a) (hs : s ∈ 𝓝[>] a)
(f_lim' : Tendsto (fun x => deriv f x) (𝓝[>] a) (𝓝 e)) : HasDerivWithinAt f e (Ici a) a := by
/- This is a specialization of `hasFDerivWithinAt_closure_of_tendsto_fderiv`. To be in the
setting of this theorem, we need to work on an open interval with closure contained in
`s ∪ {a}`, that we call `t = (a, b)`. Then, we check all the assumptions of this theorem and
we apply it. -/
obtain ⟨b, ab : a < b, sab : Ioc a b ⊆ s⟩ := mem_nhdsGT_iff_exists_Ioc_subset.1 hs
let t := Ioo a b
have ts : t ⊆ s := Subset.trans Ioo_subset_Ioc_self sab
have t_diff : DifferentiableOn ℝ f t := f_diff.mono ts
have t_conv : Convex ℝ t := convex_Ioo a b
have t_open : IsOpen t := isOpen_Ioo
have t_closure : closure t = Icc a b := closure_Ioo ab.ne
have t_cont : ∀ y ∈ closure t, ContinuousWithinAt f t y := by
rw [t_closure]
intro y hy
by_cases h : y = a
· rw [h]; exact f_lim.mono ts
· have : y ∈ s := sab ⟨lt_of_le_of_ne hy.1 (Ne.symm h), hy.2⟩
exact (f_diff.continuousOn y this).mono ts
have t_diff' : Tendsto (fun x => fderiv ℝ f x) (𝓝[t] a) (𝓝 (smulRight (1 : ℝ →L[ℝ] ℝ) e)) := by
simp only [deriv_fderiv.symm]
exact Tendsto.comp
(isBoundedBilinearMap_smulRight : IsBoundedBilinearMap ℝ _).continuous_right.continuousAt
(tendsto_nhdsWithin_mono_left Ioo_subset_Ioi_self f_lim')
-- now we can apply `hasFDerivWithinAt_closure_of_tendsto_fderiv`
have : HasDerivWithinAt f e (Icc a b) a := by
rw [hasDerivWithinAt_iff_hasFDerivWithinAt, ← t_closure]
exact hasFDerivWithinAt_closure_of_tendsto_fderiv t_diff t_conv t_open t_cont t_diff'
exact this.mono_of_mem_nhdsWithin (Icc_mem_nhdsGE ab)
/-- If a function is differentiable on the left of a point `a : ℝ`, continuous at `a`, and
its derivative also converges at `a`, then `f` is differentiable on the left at `a`. -/
theorem hasDerivWithinAt_Iic_of_tendsto_deriv {s : Set ℝ} {e : E} {a : ℝ}
{f : ℝ → E} (f_diff : DifferentiableOn ℝ f s) (f_lim : ContinuousWithinAt f s a)
(hs : s ∈ 𝓝[<] a) (f_lim' : Tendsto (fun x => deriv f x) (𝓝[<] a) (𝓝 e)) :
HasDerivWithinAt f e (Iic a) a := by
/- This is a specialization of `hasFDerivWithinAt_closure_of_tendsto_fderiv`. To be in the
setting of this theorem, we need to work on an open interval with closure contained in
`s ∪ {a}`, that we call `t = (b, a)`. Then, we check all the assumptions of this theorem and we
apply it. -/
obtain ⟨b, ba, sab⟩ : ∃ b ∈ Iio a, Ico b a ⊆ s := mem_nhdsLT_iff_exists_Ico_subset.1 hs
let t := Ioo b a
have ts : t ⊆ s := Subset.trans Ioo_subset_Ico_self sab
have t_diff : DifferentiableOn ℝ f t := f_diff.mono ts
have t_conv : Convex ℝ t := convex_Ioo b a
have t_open : IsOpen t := isOpen_Ioo
have t_closure : closure t = Icc b a := closure_Ioo (ne_of_lt ba)
have t_cont : ∀ y ∈ closure t, ContinuousWithinAt f t y := by
rw [t_closure]
intro y hy
by_cases h : y = a
· rw [h]; exact f_lim.mono ts
· have : y ∈ s := sab ⟨hy.1, lt_of_le_of_ne hy.2 h⟩
exact (f_diff.continuousOn y this).mono ts
have t_diff' : Tendsto (fun x => fderiv ℝ f x) (𝓝[t] a) (𝓝 (smulRight (1 : ℝ →L[ℝ] ℝ) e)) := by
simp only [deriv_fderiv.symm]
exact Tendsto.comp
(isBoundedBilinearMap_smulRight : IsBoundedBilinearMap ℝ _).continuous_right.continuousAt
(tendsto_nhdsWithin_mono_left Ioo_subset_Iio_self f_lim')
-- now we can apply `hasFDerivWithinAt_closure_of_tendsto_fderiv`
have : HasDerivWithinAt f e (Icc b a) a := by
rw [hasDerivWithinAt_iff_hasFDerivWithinAt, ← t_closure]
exact hasFDerivWithinAt_closure_of_tendsto_fderiv t_diff t_conv t_open t_cont t_diff'
exact this.mono_of_mem_nhdsWithin (Icc_mem_nhdsLE ba)
/-- If a real function `f` has a derivative `g` everywhere but at a point, and `f` and `g` are
continuous at this point, then `g` is also the derivative of `f` at this point. -/
theorem hasDerivAt_of_hasDerivAt_of_ne {f g : ℝ → E} {x : ℝ}
(f_diff : ∀ y ≠ x, HasDerivAt f (g y) y) (hf : ContinuousAt f x)
(hg : ContinuousAt g x) : HasDerivAt f (g x) x := by
have A : HasDerivWithinAt f (g x) (Ici x) x := by
have diff : DifferentiableOn ℝ f (Ioi x) := fun y hy =>
(f_diff y (ne_of_gt hy)).differentiableAt.differentiableWithinAt
-- next line is the nontrivial bit of this proof, appealing to differentiability
-- extension results.
apply
hasDerivWithinAt_Ici_of_tendsto_deriv diff hf.continuousWithinAt
self_mem_nhdsWithin
have : Tendsto g (𝓝[>] x) (𝓝 (g x)) := tendsto_inf_left hg
apply this.congr' _
apply mem_of_superset self_mem_nhdsWithin fun y hy => _
intro y hy
exact (f_diff y (ne_of_gt hy)).deriv.symm
have B : HasDerivWithinAt f (g x) (Iic x) x := by
have diff : DifferentiableOn ℝ f (Iio x) := fun y hy =>
(f_diff y (ne_of_lt hy)).differentiableAt.differentiableWithinAt
-- next line is the nontrivial bit of this proof, appealing to differentiability
-- extension results.
apply
hasDerivWithinAt_Iic_of_tendsto_deriv diff hf.continuousWithinAt
self_mem_nhdsWithin
have : Tendsto g (𝓝[<] x) (𝓝 (g x)) := tendsto_inf_left hg
apply this.congr' _
apply mem_of_superset self_mem_nhdsWithin fun y hy => _
intro y hy
exact (f_diff y (ne_of_lt hy)).deriv.symm
simpa using B.union A
/-- If a real function `f` has a derivative `g` everywhere but at a point, and `f` and `g` are
continuous at this point, then `g` is the derivative of `f` everywhere. -/
theorem hasDerivAt_of_hasDerivAt_of_ne' {f g : ℝ → E} {x : ℝ}
(f_diff : ∀ y ≠ x, HasDerivAt f (g y) y) (hf : ContinuousAt f x)
(hg : ContinuousAt g x) (y : ℝ) : HasDerivAt f (g y) y := by
rcases eq_or_ne y x with (rfl | hne)
· exact hasDerivAt_of_hasDerivAt_of_ne f_diff hf hg
· exact f_diff y hne |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/DifferentialForm/Basic.lean | import Mathlib.Analysis.NormedSpace.Alternating.Uncurry.Fin
import Mathlib.Analysis.Calculus.FDeriv.Symmetric
import Mathlib.Analysis.Calculus.FDeriv.CompCLM
/-!
# Exterior derivative of a differential form on a normed space
In this file we define the exterior derivative of a differential form on a normed space.
Under certain smoothness assumptions, we prove that this operation is linear in the form
and the second exterior derivative of a form is zero.
We represent a differential `n`-form on `E` taking values in `F` as `E → E [⋀^Fin n]→L[𝕜] F`.
## Implementation notes
There are a few competing definitions of the exterior derivative of a differential form
that differ from each other by a normalization factor.
We use the following one:
$$
dω(x; v_0, \dots, v_n) = \sum_{i=0}^n (-1)^i D_x ω(x; v_0, \dots, \widehat{v_i}, \dots, v_n) · v_i
$$
where $$\widehat{v_i}$$ means that we omit this element of the tuple, see `extDeriv_apply`.
## TODO
- Introduce notation for:
- an unbundled `n`-form on a normed space;
- a bundled `C^r`-smooth `n`-form on a normed space;
- same for manifolds (not defined yet).
- Introduce bundled `C^r`-smooth `n`-forms on normed spaces and manifolds.
- Discuss the future API and the use cases that need to be covered on Zulip.
- Introduce new types & notation, copy the API.
- Add shorter and more readable definitions (or abbreviations?)
for `0`-forms (`constOfIsEmpty`) and `1`-forms (`ofSubsingleton`),
sync with the API for `ContinuousMultilinearMap`.
-/
open Filter ContinuousAlternatingMap Set
open scoped Topology
variable {𝕜 E F : Type*}
[NontriviallyNormedField 𝕜]
[NormedAddCommGroup E] [NormedSpace 𝕜 E]
[NormedAddCommGroup F] [NormedSpace 𝕜 F]
{n m k : ℕ} {r : WithTop ℕ∞}
{ω ω₁ ω₂ : E → E [⋀^Fin n]→L[𝕜] F} {s t : Set E} {x : E}
/-- Exterior derivative of a differential form.
There are a few competing definitions of the exterior derivative of a differential form
that differ from each other by a normalization factor.
We use the following one:
$$
dω(x; v_0, \dots, v_n) = \sum_{i=0}^n (-1)^i D_x ω(x; v_0, \dots, \widehat{v_i}, \dots, v_n) · v_i
$$
where $$\widehat{v_i}$$ means that we omit this element of the tuple, see `extDeriv_apply`.
-/
noncomputable def extDeriv (ω : E → E [⋀^Fin n]→L[𝕜] F) (x : E) : E [⋀^Fin (n + 1)]→L[𝕜] F :=
.alternatizeUncurryFin (fderiv 𝕜 ω x)
/-- Exterior derivative of a differential form within a set.
There are a few competing definitions of the exterior derivative of a differential form
that differ from each other by a normalization factor.
We use the following one:
$$
dω(x; v_0, \dots, v_n) = \sum_{i=0}^n (-1)^i D_x ω(x; v_0, \dots, \widehat{v_i}, \dots, v_n) · v_i
$$
where $$\widehat{v_i}$$ means that we omit this element of the tuple, see `extDerivWithin_apply`.
-/
noncomputable def extDerivWithin (ω : E → E [⋀^Fin n]→L[𝕜] F) (s : Set E) (x : E) :
E [⋀^Fin (n + 1)]→L[𝕜] F :=
.alternatizeUncurryFin (fderivWithin 𝕜 ω s x)
@[simp]
theorem extDerivWithin_univ (ω : E → E [⋀^Fin n]→L[𝕜] F) :
extDerivWithin ω univ = extDeriv ω := by
ext1 x
rw [extDerivWithin, extDeriv, fderivWithin_univ]
theorem extDerivWithin_add (hsx : UniqueDiffWithinAt 𝕜 s x)
(hω₁ : DifferentiableWithinAt 𝕜 ω₁ s x) (hω₂ : DifferentiableWithinAt 𝕜 ω₂ s x) :
extDerivWithin (ω₁ + ω₂) s x = extDerivWithin ω₁ s x + extDerivWithin ω₂ s x := by
simp [extDerivWithin, fderivWithin_add hsx hω₁ hω₂, alternatizeUncurryFin_add]
theorem extDerivWithin_fun_add (hsx : UniqueDiffWithinAt 𝕜 s x)
(hω₁ : DifferentiableWithinAt 𝕜 ω₁ s x) (hω₂ : DifferentiableWithinAt 𝕜 ω₂ s x) :
extDerivWithin (fun x ↦ ω₁ x + ω₂ x) s x = extDerivWithin ω₁ s x + extDerivWithin ω₂ s x :=
extDerivWithin_add hsx hω₁ hω₂
theorem extDeriv_add (hω₁ : DifferentiableAt 𝕜 ω₁ x) (hω₂ : DifferentiableAt 𝕜 ω₂ x) :
extDeriv (ω₁ + ω₂) x = extDeriv ω₁ x + extDeriv ω₂ x := by
simp [← extDerivWithin_univ, extDerivWithin_add, *, DifferentiableAt.differentiableWithinAt]
theorem extDeriv_fun_add (hω₁ : DifferentiableAt 𝕜 ω₁ x) (hω₂ : DifferentiableAt 𝕜 ω₂ x) :
extDeriv (fun x ↦ ω₁ x + ω₂ x) x = extDeriv ω₁ x + extDeriv ω₂ x :=
extDeriv_add hω₁ hω₂
theorem extDerivWithin_smul (c : 𝕜) (ω : E → E [⋀^Fin n]→L[𝕜] F) (hsx : UniqueDiffWithinAt 𝕜 s x) :
extDerivWithin (c • ω) s x = c • extDerivWithin ω s x := by
simp [extDerivWithin, fderivWithin_const_smul_of_field, hsx, alternatizeUncurryFin_smul]
theorem extDerivWithin_fun_smul (c : 𝕜) (ω : E → E [⋀^Fin n]→L[𝕜] F)
(hsx : UniqueDiffWithinAt 𝕜 s x) :
extDerivWithin (fun x ↦ c • ω x) s x = c • extDerivWithin ω s x :=
extDerivWithin_smul c ω hsx
theorem extDeriv_smul (c : 𝕜) (ω : E → E [⋀^Fin n]→L[𝕜] F) :
extDeriv (c • ω) x = c • extDeriv ω x := by
simp [← extDerivWithin_univ, extDerivWithin_smul]
theorem extDeriv_fun_smul (c : 𝕜) (ω : E → E [⋀^Fin n]→L[𝕜] F) :
extDeriv (c • ω) x = c • extDeriv ω x :=
extDeriv_smul c ω
/-- The exterior derivative of a `0`-form given by a function `f` within a set
is the 1-form given by the derivative of `f` within the set. -/
theorem extDerivWithin_constOfIsEmpty (f : E → F) (hs : UniqueDiffWithinAt 𝕜 s x) :
extDerivWithin (fun x ↦ constOfIsEmpty 𝕜 E (Fin 0) (f x)) s x =
.ofSubsingleton _ _ _ (0 : Fin 1) (fderivWithin 𝕜 f s x) := by
simp only [extDerivWithin, ← constOfIsEmptyLIE_apply, ← Function.comp_def _ f,
(constOfIsEmptyLIE 𝕜 E F (Fin 0)).comp_fderivWithin hs,
alternatizeUncurryFin_constOfIsEmptyLIE_comp]
/-- The exterior derivative of a `0`-form given by a function `f`
is the 1-form given by the derivative of `f`. -/
theorem extDeriv_constOfIsEmpty (f : E → F) (x : E) :
extDeriv (fun x ↦ constOfIsEmpty 𝕜 E (Fin 0) (f x)) x =
.ofSubsingleton _ _ _ (0 : Fin 1) (fderiv 𝕜 f x) := by
simp [← extDerivWithin_univ, extDerivWithin_constOfIsEmpty, fderivWithin_univ]
theorem Filter.EventuallyEq.extDerivWithin_eq (hs : ω₁ =ᶠ[𝓝[s] x] ω₂) (hx : ω₁ x = ω₂ x) :
extDerivWithin ω₁ s x = extDerivWithin ω₂ s x := by
simp only [extDerivWithin, alternatizeUncurryFin, hs.fderivWithin_eq hx]
theorem Filter.EventuallyEq.extDerivWithin_eq_of_mem (hs : ω₁ =ᶠ[𝓝[s] x] ω₂) (hx : x ∈ s) :
extDerivWithin ω₁ s x = extDerivWithin ω₂ s x :=
hs.extDerivWithin_eq (mem_of_mem_nhdsWithin hx hs :)
theorem Filter.EventuallyEq.extDerivWithin_eq_of_insert (hs : ω₁ =ᶠ[𝓝[insert x s] x] ω₂) :
extDerivWithin ω₁ s x = extDerivWithin ω₂ s x := by
apply Filter.EventuallyEq.extDerivWithin_eq (nhdsWithin_mono _ (subset_insert x s) hs)
exact (mem_of_mem_nhdsWithin (mem_insert x s) hs :)
theorem Filter.EventuallyEq.extDerivWithin' (hs : ω₁ =ᶠ[𝓝[s] x] ω₂) (ht : t ⊆ s) :
extDerivWithin ω₁ t =ᶠ[𝓝[s] x] extDerivWithin ω₂ t :=
(eventually_eventually_nhdsWithin.2 hs).mp <| eventually_mem_nhdsWithin.mono fun _y hys hs =>
EventuallyEq.extDerivWithin_eq (hs.filter_mono <| nhdsWithin_mono _ ht)
(hs.self_of_nhdsWithin hys)
protected theorem Filter.EventuallyEq.extDerivWithin (hs : ω₁ =ᶠ[𝓝[s] x] ω₂) :
extDerivWithin ω₁ s =ᶠ[𝓝[s] x] extDerivWithin ω₂ s :=
hs.extDerivWithin' .rfl
theorem Filter.EventuallyEq.extDerivWithin_eq_nhds (h : ω₁ =ᶠ[𝓝 x] ω₂) :
extDerivWithin ω₁ s x = extDerivWithin ω₂ s x :=
(h.filter_mono nhdsWithin_le_nhds).extDerivWithin_eq h.self_of_nhds
theorem extDerivWithin_congr (hs : EqOn ω₁ ω₂ s) (hx : ω₁ x = ω₂ x) :
extDerivWithin ω₁ s x = extDerivWithin ω₂ s x :=
(hs.eventuallyEq.filter_mono inf_le_right).extDerivWithin_eq hx
theorem extDerivWithin_congr' (hs : EqOn ω₁ ω₂ s) (hx : x ∈ s) :
extDerivWithin ω₁ s x = extDerivWithin ω₂ s x :=
extDerivWithin_congr hs (hs hx)
protected theorem Filter.EventuallyEq.extDeriv (h : ω₁ =ᶠ[𝓝 x] ω₂) :
extDeriv ω₁ =ᶠ[𝓝 x] extDeriv ω₂ := by
simp only [← nhdsWithin_univ, ← extDerivWithin_univ] at *
exact h.extDerivWithin
theorem Filter.EventuallyEq.extDeriv_eq (h : ω₁ =ᶠ[𝓝 x] ω₂) : extDeriv ω₁ x = extDeriv ω₂ x :=
h.extDeriv.self_of_nhds
theorem extDerivWithin_apply (h : DifferentiableWithinAt 𝕜 ω s x) (hs : UniqueDiffWithinAt 𝕜 s x)
(v : Fin (n + 1) → E) :
extDerivWithin ω s x v =
∑ i, (-1) ^ i.val • fderivWithin 𝕜 (ω · (i.removeNth v)) s x (v i) := by
simp [extDerivWithin, ContinuousAlternatingMap.alternatizeUncurryFin_apply,
fderivWithin_continuousAlternatingMap_apply_const_apply, *]
theorem extDeriv_apply (h : DifferentiableAt 𝕜 ω x) (v : Fin (n + 1) → E) :
extDeriv ω x v = ∑ i, (-1) ^ i.val • fderiv 𝕜 (ω · (i.removeNth v)) x (v i) := by
simp [← extDerivWithin_univ, extDerivWithin_apply h.differentiableWithinAt]
/-- The second exterior derivative of a sufficiently smooth differential form is zero. -/
theorem extDerivWithin_extDerivWithin_apply (hω : ContDiffWithinAt 𝕜 r ω s x)
(hr : minSmoothness 𝕜 2 ≤ r) (hs : UniqueDiffOn 𝕜 s) (hx : x ∈ closure (interior s))
(h'x : x ∈ s) : extDerivWithin (extDerivWithin ω s) s x = 0 := calc
extDerivWithin (extDerivWithin ω s) s x
= alternatizeUncurryFin (fderivWithin 𝕜 (fun y ↦
alternatizeUncurryFin (fderivWithin 𝕜 ω s y)) s x) := rfl
_ = alternatizeUncurryFin (alternatizeUncurryFinCLM _ _ _ ∘L
fderivWithin 𝕜 (fderivWithin 𝕜 ω s) s x) := by
congr 1
have : DifferentiableWithinAt 𝕜 (fderivWithin 𝕜 ω s) s x := by
refine (hω.fderivWithin_right hs ?_ h'x).differentiableWithinAt le_rfl
exact le_minSmoothness.trans hr
exact alternatizeUncurryFinCLM _ _ _ |>.hasFDerivAt.comp_hasFDerivWithinAt x
this.hasFDerivWithinAt |>.fderivWithin (hs.uniqueDiffWithinAt h'x)
_ = 0 := alternatizeUncurryFin_alternatizeUncurryFinCLM_comp_of_symmetric <|
hω.isSymmSndFDerivWithinAt hr hs hx h'x
/-- The second exterior derivative of a sufficiently smooth differential form is zero. -/
theorem extDerivWithin_extDerivWithin_eqOn (hω : ContDiffOn 𝕜 r ω s) (hr : minSmoothness 𝕜 2 ≤ r)
(hs : UniqueDiffOn 𝕜 s) :
EqOn (extDerivWithin (extDerivWithin ω s) s) 0 (s ∩ closure (interior s)) := by
rintro x ⟨h'x, hx⟩
exact extDerivWithin_extDerivWithin_apply (hω.contDiffWithinAt h'x) hr hs hx h'x
/-- The second exterior derivative of a sufficiently smooth differential form is zero. -/
theorem extDeriv_extDeriv_apply (hω : ContDiffAt 𝕜 r ω x) (hr : minSmoothness 𝕜 2 ≤ r) :
extDeriv (extDeriv ω) x = 0 := by
simp only [← extDerivWithin_univ]
apply extDerivWithin_extDerivWithin_apply (s := univ) hω.contDiffWithinAt hr <;> simp
/-- The second exterior derivative of a sufficiently smooth differential form is zero. -/
theorem extDeriv_extDeriv (h : ContDiff 𝕜 r ω) (hr : minSmoothness 𝕜 2 ≤ r) :
extDeriv (extDeriv ω) = 0 :=
funext fun _ ↦ extDeriv_extDeriv_apply h.contDiffAt hr |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/IteratedDeriv/Lemmas.lean | import Mathlib.Analysis.Calculus.ContDiff.Operations
import Mathlib.Analysis.Calculus.Deriv.Mul
import Mathlib.Analysis.Calculus.Deriv.Shift
import Mathlib.Analysis.Calculus.IteratedDeriv.Defs
/-!
# One-dimensional iterated derivatives
This file contains a number of further results on `iteratedDerivWithin` that need more imports
than are available in `Mathlib/Analysis/Calculus/IteratedDeriv/Defs.lean`.
-/
section one_dimensional
variable
{𝕜 : Type*} [NontriviallyNormedField 𝕜]
{F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F]
{R : Type*} [Semiring R] [Module R F] [SMulCommClass 𝕜 R F] [ContinuousConstSMul R F]
{n : ℕ} {x : 𝕜} {s : Set 𝕜} (hx : x ∈ s) (h : UniqueDiffOn 𝕜 s) {f g : 𝕜 → F}
section
theorem iteratedDerivWithin_congr (hfg : Set.EqOn f g s) :
Set.EqOn (iteratedDerivWithin n f s) (iteratedDerivWithin n g s) s := by
induction n generalizing f g with
| zero => rwa [iteratedDerivWithin_zero]
| succ n IH =>
intro y hy
rw [iteratedDerivWithin_succ, iteratedDerivWithin_succ]
exact derivWithin_congr (IH hfg) (IH hfg hy)
include h hx in
theorem iteratedDerivWithin_add
(hf : ContDiffWithinAt 𝕜 n f s x) (hg : ContDiffWithinAt 𝕜 n g s x) :
iteratedDerivWithin n (f + g) s x =
iteratedDerivWithin n f s x + iteratedDerivWithin n g s x := by
simp_rw [iteratedDerivWithin, iteratedFDerivWithin_add_apply hf hg h hx,
ContinuousMultilinearMap.add_apply]
include h hx in
theorem iteratedDerivWithin_fun_add
(hf : ContDiffWithinAt 𝕜 n f s x) (hg : ContDiffWithinAt 𝕜 n g s x) :
iteratedDerivWithin n (fun z ↦ f z + g z) s x =
iteratedDerivWithin n f s x + iteratedDerivWithin n g s x := by
simpa using iteratedDerivWithin_add hx h hf hg
theorem iteratedDerivWithin_const_add (hn : 0 < n) (c : F) :
iteratedDerivWithin n (fun z => c + f z) s x = iteratedDerivWithin n f s x := by
obtain ⟨n, rfl⟩ := n.exists_eq_succ_of_ne_zero hn.ne'
rw [iteratedDerivWithin_succ', iteratedDerivWithin_succ']
congr 1 with y
exact derivWithin_const_add _
theorem iteratedDerivWithin_const_sub (hn : 0 < n) (c : F) :
iteratedDerivWithin n (fun z => c - f z) s x = iteratedDerivWithin n (fun z => -f z) s x := by
obtain ⟨n, rfl⟩ := n.exists_eq_succ_of_ne_zero hn.ne'
rw [iteratedDerivWithin_succ', iteratedDerivWithin_succ']
congr 1 with y
rw [derivWithin.fun_neg]
exact derivWithin_const_sub _
include h hx in
theorem iteratedDerivWithin_const_smul (c : R) (hf : ContDiffWithinAt 𝕜 n f s x) :
iteratedDerivWithin n (c • f) s x = c • iteratedDerivWithin n f s x := by
simp_rw [iteratedDerivWithin]
rw [iteratedFDerivWithin_const_smul_apply hf h hx]
simp only [ContinuousMultilinearMap.smul_apply]
include h hx in
theorem iteratedDerivWithin_const_mul (c : 𝕜) {f : 𝕜 → 𝕜} (hf : ContDiffWithinAt 𝕜 n f s x) :
iteratedDerivWithin n (fun z => c * f z) s x = c * iteratedDerivWithin n f s x := by
simpa using iteratedDerivWithin_const_smul (F := 𝕜) hx h c hf
variable (f) in
omit h hx in
theorem iteratedDerivWithin_neg :
iteratedDerivWithin n (-f) s x = -iteratedDerivWithin n f s x := by
induction n generalizing x with
| zero => simp
| succ n IH =>
simp only [iteratedDerivWithin_succ]
rw [← derivWithin.neg]
congr with y
exact IH
variable (f) in
theorem iteratedDerivWithin_fun_neg :
iteratedDerivWithin n (fun z => -f z) s x = -iteratedDerivWithin n f s x :=
iteratedDerivWithin_neg f
@[deprecated (since := "2025-06-24")] alias iteratedDerivWithin_neg' := iteratedDerivWithin_fun_neg
include h hx
theorem iteratedDerivWithin_sub
(hf : ContDiffWithinAt 𝕜 n f s x) (hg : ContDiffWithinAt 𝕜 n g s x) :
iteratedDerivWithin n (f - g) s x =
iteratedDerivWithin n f s x - iteratedDerivWithin n g s x := by
rw [sub_eq_add_neg, sub_eq_add_neg, Pi.neg_def, iteratedDerivWithin_add hx h hf hg.neg,
iteratedDerivWithin_fun_neg]
theorem iteratedDerivWithin_comp_const_smul (hf : ContDiffOn 𝕜 n f s) (c : 𝕜)
(hs : Set.MapsTo (c * ·) s s) :
iteratedDerivWithin n (fun x => f (c * x)) s x = c ^ n • iteratedDerivWithin n f s (c * x) := by
induction n generalizing x with
| zero => simp
| succ n ih =>
have hcx : c * x ∈ s := hs hx
have h₀ : s.EqOn
(iteratedDerivWithin n (fun x ↦ f (c * x)) s)
(fun x => c ^ n • iteratedDerivWithin n f s (c * x)) :=
fun x hx => ih hx hf.of_succ
have h₁ : DifferentiableWithinAt 𝕜 (iteratedDerivWithin n f s) s (c * x) :=
hf.differentiableOn_iteratedDerivWithin (Nat.cast_lt.mpr n.lt_succ_self) h _ hcx
have h₂ : DifferentiableWithinAt 𝕜 (fun x => iteratedDerivWithin n f s (c * x)) s x := by
rw [← Function.comp_def]
apply DifferentiableWithinAt.comp
· exact hf.differentiableOn_iteratedDerivWithin (Nat.cast_lt.mpr n.lt_succ_self) h _ hcx
· exact differentiableWithinAt_id'.const_mul _
· exact hs
rw [iteratedDerivWithin_succ, derivWithin_congr h₀ (ih hx hf.of_succ),
derivWithin_fun_const_smul (c ^ n) h₂, iteratedDerivWithin_succ,
← Function.comp_def,
derivWithin.scomp x h₁ (differentiableWithinAt_id'.const_mul _) hs,
derivWithin_const_mul _ differentiableWithinAt_id', derivWithin_id' _ _ (h _ hx),
smul_smul, mul_one, pow_succ]
end
lemma iteratedDeriv_add (hf : ContDiffAt 𝕜 n f x) (hg : ContDiffAt 𝕜 n g x) :
iteratedDeriv n (f + g) x = iteratedDeriv n f x + iteratedDeriv n g x := by
simpa only [iteratedDerivWithin_univ] using
iteratedDerivWithin_add (Set.mem_univ _) uniqueDiffOn_univ hf hg
theorem iteratedDeriv_const_add (hn : 0 < n) (c : F) :
iteratedDeriv n (fun z => c + f z) x = iteratedDeriv n f x := by
simpa only [← iteratedDerivWithin_univ] using iteratedDerivWithin_const_add hn c
theorem iteratedDeriv_const_sub (hn : 0 < n) (c : F) :
iteratedDeriv n (fun z => c - f z) x = iteratedDeriv n (-f) x := by
simpa only [← iteratedDerivWithin_univ] using iteratedDerivWithin_const_sub hn c
lemma iteratedDeriv_fun_neg (n : ℕ) (f : 𝕜 → F) (a : 𝕜) :
iteratedDeriv n (fun x ↦ -(f x)) a = -(iteratedDeriv n f a) := by
simpa only [← iteratedDerivWithin_univ] using iteratedDerivWithin_neg f
lemma iteratedDeriv_neg (n : ℕ) (f : 𝕜 → F) (a : 𝕜) :
iteratedDeriv n (-f) a = -(iteratedDeriv n f a) := by
simpa only [← iteratedDerivWithin_univ] using iteratedDerivWithin_neg f
lemma iteratedDeriv_sub (hf : ContDiffAt 𝕜 n f x) (hg : ContDiffAt 𝕜 n g x) :
iteratedDeriv n (f - g) x = iteratedDeriv n f x - iteratedDeriv n g x := by
simpa only [iteratedDerivWithin_univ] using
iteratedDerivWithin_sub (Set.mem_univ _) uniqueDiffOn_univ hf hg
theorem iteratedDeriv_const_smul {n : ℕ} {f : 𝕜 → F} (h : ContDiffAt 𝕜 n f x) (c : 𝕜) :
iteratedDeriv n (c • f) x = c • iteratedDeriv n f x := by
simpa only [iteratedDerivWithin_univ] using
iteratedDerivWithin_const_smul (Set.mem_univ x) uniqueDiffOn_univ
c (contDiffWithinAt_univ.mpr h)
theorem iteratedDeriv_const_mul {n : ℕ} {f : 𝕜 → 𝕜} (h : ContDiffAt 𝕜 n f x) (c : 𝕜) :
iteratedDeriv n (fun z => c * f z) x = c * iteratedDeriv n f x := by
simpa only [iteratedDerivWithin_univ] using
iteratedDerivWithin_const_mul (Set.mem_univ x) uniqueDiffOn_univ
c (contDiffWithinAt_univ.mpr h)
theorem iteratedDeriv_comp_const_smul {n : ℕ} {f : 𝕜 → F} (h : ContDiff 𝕜 n f) (c : 𝕜) :
iteratedDeriv n (fun x => f (c * x)) = fun x => c ^ n • iteratedDeriv n f (c * x) := by
funext x
simpa only [iteratedDerivWithin_univ] using
iteratedDerivWithin_comp_const_smul (Set.mem_univ x) uniqueDiffOn_univ (contDiffOn_univ.mpr h)
c (Set.mapsTo_univ _ _)
theorem iteratedDeriv_comp_const_mul {n : ℕ} {f : 𝕜 → 𝕜} (h : ContDiff 𝕜 n f) (c : 𝕜) :
iteratedDeriv n (fun x => f (c * x)) = fun x => c ^ n * iteratedDeriv n f (c * x) := by
simpa only [smul_eq_mul] using iteratedDeriv_comp_const_smul h c
lemma iteratedDeriv_comp_neg (n : ℕ) (f : 𝕜 → F) (a : 𝕜) :
iteratedDeriv n (fun x ↦ f (-x)) a = (-1 : 𝕜) ^ n • iteratedDeriv n f (-a) := by
induction n generalizing a with
| zero => simp only [iteratedDeriv_zero, pow_zero, one_smul]
| succ n ih =>
have ih' : iteratedDeriv n (fun x ↦ f (-x)) = fun x ↦ (-1 : 𝕜) ^ n • iteratedDeriv n f (-x) :=
funext ih
rw [iteratedDeriv_succ, iteratedDeriv_succ, ih', pow_succ', neg_mul, one_mul,
deriv_comp_neg (f := fun x ↦ (-1 : 𝕜) ^ n • iteratedDeriv n f x), deriv_fun_const_smul',
neg_smul]
open Topology in
lemma Filter.EventuallyEq.iteratedDeriv_eq (n : ℕ) {f g : 𝕜 → F} {x : 𝕜} (hfg : f =ᶠ[𝓝 x] g) :
iteratedDeriv n f x = iteratedDeriv n g x := by
simp only [← iteratedDerivWithin_univ, iteratedDerivWithin_eq_iteratedFDerivWithin]
rw [(hfg.filter_mono nhdsWithin_le_nhds).iteratedFDerivWithin_eq hfg.eq_of_nhds n]
lemma Set.EqOn.iteratedDeriv_of_isOpen (hfg : Set.EqOn f g s) (hs : IsOpen s) (n : ℕ) :
Set.EqOn (iteratedDeriv n f) (iteratedDeriv n g) s := by
refine fun x hx ↦ Filter.EventuallyEq.iteratedDeriv_eq n ?_
filter_upwards [IsOpen.mem_nhds hs hx] with a ha
exact hfg ha
end one_dimensional
/-!
### Invariance of iterated derivatives under translation
-/
section shift_invariance
variable {𝕜 F} [NontriviallyNormedField 𝕜] [NormedAddCommGroup F] [NormedSpace 𝕜 F]
/-- The iterated derivative commutes with shifting the function by a constant on the left. -/
lemma iteratedDeriv_comp_const_add (n : ℕ) (f : 𝕜 → F) (s : 𝕜) :
iteratedDeriv n (fun z ↦ f (s + z)) = fun t ↦ iteratedDeriv n f (s + t) := by
induction n with
| zero => simp only [iteratedDeriv_zero]
| succ n IH =>
simpa only [iteratedDeriv_succ, IH] using funext <| deriv_comp_const_add _ s
/-- The iterated derivative commutes with shifting the function by a constant on the right. -/
lemma iteratedDeriv_comp_add_const (n : ℕ) (f : 𝕜 → F) (s : 𝕜) :
iteratedDeriv n (fun z ↦ f (z + s)) = fun t ↦ iteratedDeriv n f (t + s) := by
induction n with
| zero => simp only [iteratedDeriv_zero]
| succ n IH =>
simpa only [iteratedDeriv_succ, IH] using funext <| deriv_comp_add_const _ s
end shift_invariance |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/IteratedDeriv/FaaDiBruno.lean | import Mathlib.Analysis.Calculus.ContDiff.Basic
import Mathlib.Analysis.Calculus.IteratedDeriv.Defs
/-!
# Iterated derivatives of compositions
In this file we specialize Faà di Bruno's formula to one-dimensional domain
to deduce formulae for `iteratedDerivWithin k (g ∘ f) s x` for `k = 2` and `k = 3`.
We use
- `vcomp` for lemmas about the composition of `g : E → F` with `f : 𝕜 → E`;
- `scomp` for lemmas about the composition of `g : 𝕜 → E` with `f : 𝕜 → 𝕜`;
- `comp` for lemmas about the composition of `g : 𝕜 → 𝕜` with `f : 𝕜 → 𝕜`.
## TODO
- What `UniqueDiffOn` assumptions can be discarded?
- In case of dimension 1 (and, more generally, in case of symmetric iterated derivatives),
some terms are equal.
Add versions of Faà di Bruno's formula that take the symmetries into account.
- Can we generalize `scomp`/`comp` to `f : 𝕜 → 𝕜'`,
where `𝕜'` is a normed algebra over `𝕜`? E.g., `𝕜 = ℝ`, `𝕜' = ℂ`.
Before starting to work on these TODOs, please contact Yury Kudryashov
who may have partial progress towards some of them.
-/
open Function Set
open scoped ContDiff
section vcomp
variable {𝕜 E F : Type*} [NontriviallyNormedField 𝕜]
[NormedAddCommGroup E] [NormedSpace 𝕜 E] [NormedAddCommGroup F] [NormedSpace 𝕜 F]
{g : E → F} {f : 𝕜 → E} {s : Set 𝕜} {t : Set E} {x : 𝕜} {n : WithTop ℕ∞} {i : ℕ}
theorem iteratedDerivWithin_vcomp_eq_sum_orderedFinpartition
(hg : ContDiffWithinAt 𝕜 n g t (f x)) (hf : ContDiffWithinAt 𝕜 n f s x)
(ht : UniqueDiffOn 𝕜 t) (hs : UniqueDiffOn 𝕜 s) (hx : x ∈ s) (hst : MapsTo f s t) (hi : i ≤ n) :
iteratedDerivWithin i (g ∘ f) s x =
∑ c : OrderedFinpartition i, iteratedFDerivWithin 𝕜 c.length g t (f x) fun j ↦
iteratedDerivWithin (c.partSize j) f s x := by
simp only [iteratedDerivWithin, iteratedFDerivWithin_comp hg hf ht hs hx hst hi]
simp [FormalMultilinearSeries.taylorComp, ftaylorSeriesWithin,
OrderedFinpartition.applyOrderedFinpartition_apply, comp_def]
theorem iteratedDeriv_vcomp_eq_sum_orderedFinpartition
(hg : ContDiffAt 𝕜 n g (f x)) (hf : ContDiffAt 𝕜 n f x) (hi : i ≤ n) :
iteratedDeriv i (g ∘ f) x =
∑ c : OrderedFinpartition i, iteratedFDeriv 𝕜 c.length g (f x) fun j ↦
iteratedDeriv (c.partSize j) f x := by
simp only [← iteratedDerivWithin_univ, ← iteratedFDerivWithin_univ]
exact iteratedDerivWithin_vcomp_eq_sum_orderedFinpartition hg hf uniqueDiffOn_univ
uniqueDiffOn_univ (mem_univ x) (mapsTo_univ f _) hi
theorem iteratedDerivWithin_vcomp_two
(hg : ContDiffWithinAt 𝕜 2 g t (f x)) (hf : ContDiffWithinAt 𝕜 2 f s x)
(ht : UniqueDiffOn 𝕜 t) (hs : UniqueDiffOn 𝕜 s) (hx : x ∈ s) (hst : MapsTo f s t) :
iteratedDerivWithin 2 (g ∘ f) s x =
iteratedFDerivWithin 𝕜 2 g t (f x) (fun _ ↦ derivWithin f s x) +
fderivWithin 𝕜 g t (f x) (iteratedDerivWithin 2 f s x) := by
rw [iteratedDerivWithin_vcomp_eq_sum_orderedFinpartition hg hf ht hs hx hst le_rfl]
simp only [← (OrderedFinpartition.extendEquiv 1).sum_comp, Fintype.sum_sigma, Fintype.sum_unique,
OrderedFinpartition.default_eq, OrderedFinpartition.atomic_length, Fintype.sum_option]
have : (Fin.cons 1 (fun _ ↦ 1) : Fin 2 → ℕ) = fun _ ↦ 1 :=
funext <| Fin.forall_fin_two.mpr ⟨rfl, rfl⟩
simp [OrderedFinpartition.extendEquiv, OrderedFinpartition.extend,
OrderedFinpartition.extendLeft, OrderedFinpartition.extendMiddle, ht _ (hst hx),
OrderedFinpartition.atomic, this]
theorem iteratedDeriv_vcomp_two (hg : ContDiffAt 𝕜 2 g (f x)) (hf : ContDiffAt 𝕜 2 f x) :
iteratedDeriv 2 (g ∘ f) x =
iteratedFDeriv 𝕜 2 g (f x) (fun _ ↦ deriv f x) + fderiv 𝕜 g (f x) (iteratedDeriv 2 f x) := by
simp only [← iteratedDerivWithin_univ, ← iteratedFDerivWithin_univ,
← derivWithin_univ, ← fderivWithin_univ]
exact iteratedDerivWithin_vcomp_two hg hf uniqueDiffOn_univ
uniqueDiffOn_univ (mem_univ x) (mapsTo_univ f _)
theorem iteratedDerivWithin_vcomp_three
(hg : ContDiffWithinAt 𝕜 3 g t (f x)) (hf : ContDiffWithinAt 𝕜 3 f s x)
(ht : UniqueDiffOn 𝕜 t) (hs : UniqueDiffOn 𝕜 s) (hx : x ∈ s) (hst : MapsTo f s t) :
iteratedDerivWithin 3 (g ∘ f) s x =
iteratedFDerivWithin 𝕜 3 g t (f x) (fun _ ↦ derivWithin f s x) +
iteratedFDerivWithin 𝕜 2 g t (f x) ![iteratedDerivWithin 2 f s x, derivWithin f s x] +
2 • iteratedFDerivWithin 𝕜 2 g t (f x) ![derivWithin f s x, iteratedDerivWithin 2 f s x] +
fderivWithin 𝕜 g t (f x) (iteratedDerivWithin 3 f s x) := by
rw [iteratedDerivWithin_vcomp_eq_sum_orderedFinpartition hg hf ht hs hx hst le_rfl]
simp only [← (OrderedFinpartition.extendEquiv 1).sum_comp,
← (OrderedFinpartition.extendEquiv 2).sum_comp, Fintype.sum_sigma,
Fintype.sum_option, Nat.reduceAdd, OrderedFinpartition.extendEquiv_apply,
OrderedFinpartition.extend_none, OrderedFinpartition.extend_some,
OrderedFinpartition.extendMiddle_length, OrderedFinpartition.default_eq, Fintype.sum_unique,
OrderedFinpartition.atomic_length, OrderedFinpartition.extendLeft_length, Fin.sum_univ_two]
simp? [add_assoc, two_smul, iteratedFDerivWithin_one_apply (ht _ <| hst hx)] says
simp only [OrderedFinpartition.extendLeft_partSize, OrderedFinpartition.extendLeft_length,
OrderedFinpartition.atomic_length, Nat.reduceAdd, OrderedFinpartition.atomic_partSize,
Fin.isValue, OrderedFinpartition.extendMiddle_partSize, Fin.cons_zero, Fin.update_cons_zero,
Fin.cons_one, Fin.default_eq_zero, OrderedFinpartition.extendMiddle_length, Fin.cons_update,
Fin.succ_zero_eq_one, update_self, update_idem,
iteratedFDerivWithin_one_apply (ht _ <| hst hx), add_assoc, two_smul]
have (j : _) : (Fin.cons 1 (Fin.cons 1 fun _ ↦ 1) : Fin 3 → ℕ) j = 1 := by
fin_cases j <;> rfl
congr <;> ext x <;> fin_cases x <;> simp [this]
theorem iteratedDeriv_vcomp_three (hg : ContDiffAt 𝕜 3 g (f x)) (hf : ContDiffAt 𝕜 3 f x) :
iteratedDeriv 3 (g ∘ f) x =
iteratedFDeriv 𝕜 3 g (f x) (fun _ ↦ deriv f x) +
iteratedFDeriv 𝕜 2 g (f x) ![iteratedDeriv 2 f x, deriv f x] +
2 • iteratedFDeriv 𝕜 2 g (f x) ![deriv f x, iteratedDeriv 2 f x] +
fderiv 𝕜 g (f x) (iteratedDeriv 3 f x) := by
simp only [← iteratedDerivWithin_univ, ← iteratedFDerivWithin_univ,
← derivWithin_univ, ← fderivWithin_univ]
exact iteratedDerivWithin_vcomp_three hg hf uniqueDiffOn_univ
uniqueDiffOn_univ (mem_univ x) (mapsTo_univ f _)
end vcomp
section scomp
variable {𝕜 E : Type*} [NontriviallyNormedField 𝕜] [NormedAddCommGroup E] [NormedSpace 𝕜 E]
{g : 𝕜 → E} {f : 𝕜 → 𝕜} {s : Set 𝕜} {t : Set 𝕜} {x : 𝕜} {n : WithTop ℕ∞} {i : ℕ}
theorem iteratedDerivWithin_scomp_eq_sum_orderedFinpartition
(hg : ContDiffWithinAt 𝕜 n g t (f x)) (hf : ContDiffWithinAt 𝕜 n f s x)
(ht : UniqueDiffOn 𝕜 t) (hs : UniqueDiffOn 𝕜 s) (hx : x ∈ s) (hst : MapsTo f s t) (hi : i ≤ n) :
iteratedDerivWithin i (g ∘ f) s x =
∑ c : OrderedFinpartition i,
(∏ j, iteratedDerivWithin (c.partSize j) f s x) •
iteratedDerivWithin c.length g t (f x) := by
rw [iteratedDerivWithin_vcomp_eq_sum_orderedFinpartition hg hf ht hs hx hst hi]
simp only [iteratedFDerivWithin_apply_eq_iteratedDerivWithin_mul_prod]
theorem iteratedDeriv_scomp_eq_sum_orderedFinpartition
(hg : ContDiffAt 𝕜 n g (f x)) (hf : ContDiffAt 𝕜 n f x) (hi : i ≤ n) :
iteratedDeriv i (g ∘ f) x =
∑ c : OrderedFinpartition i,
(∏ j, iteratedDeriv (c.partSize j) f x) • iteratedDeriv c.length g (f x) := by
rw [iteratedDeriv_vcomp_eq_sum_orderedFinpartition hg hf hi]
simp only [iteratedFDeriv_apply_eq_iteratedDeriv_mul_prod]
theorem iteratedDerivWithin_scomp_two
(hg : ContDiffWithinAt 𝕜 2 g t (f x)) (hf : ContDiffWithinAt 𝕜 2 f s x)
(ht : UniqueDiffOn 𝕜 t) (hs : UniqueDiffOn 𝕜 s) (hx : x ∈ s) (hst : MapsTo f s t) :
iteratedDerivWithin 2 (g ∘ f) s x =
derivWithin f s x ^ 2 • iteratedDerivWithin 2 g t (f x) +
iteratedDerivWithin 2 f s x • derivWithin g t (f x) := by
rw [iteratedDerivWithin_vcomp_two hg hf ht hs hx hst]
simp [← derivWithin_fderivWithin, iteratedFDerivWithin_apply_eq_iteratedDerivWithin_mul_prod]
theorem iteratedDeriv_scomp_two (hg : ContDiffAt 𝕜 2 g (f x)) (hf : ContDiffAt 𝕜 2 f x) :
iteratedDeriv 2 (g ∘ f) x
= deriv f x ^ 2 • iteratedDeriv 2 g (f x) + iteratedDeriv 2 f x • deriv g (f x) := by
simp only [← iteratedDerivWithin_univ, ← derivWithin_univ]
exact iteratedDerivWithin_scomp_two hg hf uniqueDiffOn_univ uniqueDiffOn_univ (mem_univ _)
(mapsTo_univ _ _)
theorem iteratedDerivWithin_scomp_three
(hg : ContDiffWithinAt 𝕜 3 g t (f x)) (hf : ContDiffWithinAt 𝕜 3 f s x)
(ht : UniqueDiffOn 𝕜 t) (hs : UniqueDiffOn 𝕜 s) (hx : x ∈ s) (hst : MapsTo f s t) :
iteratedDerivWithin 3 (g ∘ f) s x =
derivWithin f s x ^ 3 • iteratedDerivWithin 3 g t (f x) +
3 • iteratedDerivWithin 2 f s x • derivWithin f s x • iteratedDerivWithin 2 g t (f x) +
iteratedDerivWithin 3 f s x • derivWithin g t (f x) := by
rw [iteratedDerivWithin_vcomp_three hg hf ht hs hx hst]
simp [← derivWithin_fderivWithin, mul_smul, smul_comm (iteratedDerivWithin 2 f s x),
iteratedFDerivWithin_apply_eq_iteratedDerivWithin_mul_prod]
abel
theorem iteratedDeriv_scomp_three (hg : ContDiffAt 𝕜 3 g (f x)) (hf : ContDiffAt 𝕜 3 f x) :
iteratedDeriv 3 (g ∘ f) x =
deriv f x ^ 3 • iteratedDeriv 3 g (f x) +
3 • iteratedDeriv 2 f x • deriv f x • iteratedDeriv 2 g (f x) +
iteratedDeriv 3 f x • deriv g (f x) := by
simp only [← iteratedDerivWithin_univ, ← derivWithin_univ]
exact iteratedDerivWithin_scomp_three hg hf uniqueDiffOn_univ uniqueDiffOn_univ (mem_univ _)
(mapsTo_univ _ _)
end scomp
section comp
variable {𝕜 : Type*} [NontriviallyNormedField 𝕜]
{g f : 𝕜 → 𝕜} {s t : Set 𝕜} {x : 𝕜} {n : WithTop ℕ∞} {i : ℕ}
theorem iteratedDerivWithin_comp_eq_sum_orderedFinpartition
(hg : ContDiffWithinAt 𝕜 n g t (f x)) (hf : ContDiffWithinAt 𝕜 n f s x)
(ht : UniqueDiffOn 𝕜 t) (hs : UniqueDiffOn 𝕜 s) (hx : x ∈ s) (hst : MapsTo f s t) (hi : i ≤ n) :
iteratedDerivWithin i (g ∘ f) s x =
∑ c : OrderedFinpartition i,
iteratedDerivWithin c.length g t (f x) * ∏ j, iteratedDerivWithin (c.partSize j) f s x := by
rw [iteratedDerivWithin_scomp_eq_sum_orderedFinpartition hg hf ht hs hx hst hi]
simp only [smul_eq_mul, mul_comm]
theorem iteratedDeriv_comp_eq_sum_orderedFinpartition
(hg : ContDiffAt 𝕜 n g (f x)) (hf : ContDiffAt 𝕜 n f x) (hi : i ≤ n) :
iteratedDeriv i (g ∘ f) x =
∑ c : OrderedFinpartition i,
iteratedDeriv c.length g (f x) * ∏ j, iteratedDeriv (c.partSize j) f x := by
rw [iteratedDeriv_scomp_eq_sum_orderedFinpartition hg hf hi]
simp only [smul_eq_mul, mul_comm]
theorem iteratedDerivWithin_comp_two
(hg : ContDiffWithinAt 𝕜 2 g t (f x)) (hf : ContDiffWithinAt 𝕜 2 f s x)
(ht : UniqueDiffOn 𝕜 t) (hs : UniqueDiffOn 𝕜 s) (hx : x ∈ s) (hst : MapsTo f s t) :
iteratedDerivWithin 2 (g ∘ f) s x =
iteratedDerivWithin 2 g t (f x) * derivWithin f s x ^ 2 +
derivWithin g t (f x) * iteratedDerivWithin 2 f s x := by
rw [iteratedDerivWithin_scomp_two hg hf ht hs hx hst]
simp only [smul_eq_mul, mul_comm]
theorem iteratedDeriv_comp_two (hg : ContDiffAt 𝕜 2 g (f x)) (hf : ContDiffAt 𝕜 2 f x) :
iteratedDeriv 2 (g ∘ f) x =
iteratedDeriv 2 g (f x) * deriv f x ^ 2 + deriv g (f x) * iteratedDeriv 2 f x := by
simp only [← iteratedDerivWithin_univ, ← derivWithin_univ]
exact iteratedDerivWithin_comp_two hg hf uniqueDiffOn_univ uniqueDiffOn_univ (mem_univ _)
(mapsTo_univ _ _)
theorem iteratedDerivWithin_comp_three
(hg : ContDiffWithinAt 𝕜 3 g t (f x)) (hf : ContDiffWithinAt 𝕜 3 f s x)
(ht : UniqueDiffOn 𝕜 t) (hs : UniqueDiffOn 𝕜 s) (hx : x ∈ s) (hst : MapsTo f s t) :
iteratedDerivWithin 3 (g ∘ f) s x =
iteratedDerivWithin 3 g t (f x) * derivWithin f s x ^ 3 +
3 * iteratedDerivWithin 2 g t (f x) * iteratedDerivWithin 2 f s x * derivWithin f s x +
derivWithin g t (f x) * iteratedDerivWithin 3 f s x := by
rw [iteratedDerivWithin_scomp_three hg hf ht hs hx hst]
simp only [nsmul_eq_mul, smul_eq_mul, Nat.cast_ofNat]
ring
theorem iteratedDeriv_comp_three (hg : ContDiffAt 𝕜 3 g (f x)) (hf : ContDiffAt 𝕜 3 f x) :
iteratedDeriv 3 (g ∘ f) x =
iteratedDeriv 3 g (f x) * deriv f x ^ 3 +
3 * iteratedDeriv 2 g (f x) * iteratedDeriv 2 f x * deriv f x +
deriv g (f x) * iteratedDeriv 3 f x := by
simp only [← iteratedDerivWithin_univ, ← derivWithin_univ]
exact iteratedDerivWithin_comp_three hg hf uniqueDiffOn_univ uniqueDiffOn_univ (mem_univ _)
(mapsTo_univ _ _)
end comp |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/IteratedDeriv/Defs.lean | import Mathlib.Analysis.Calculus.Deriv.Basic
import Mathlib.Analysis.Calculus.ContDiff.Defs
/-!
# One-dimensional iterated derivatives
We define the `n`-th derivative of a function `f : 𝕜 → F` as a function
`iteratedDeriv n f : 𝕜 → F`, as well as a version on domains `iteratedDerivWithin n f s : 𝕜 → F`,
and prove their basic properties.
## Main definitions and results
Let `𝕜` be a nontrivially normed field, and `F` a normed vector space over `𝕜`. Let `f : 𝕜 → F`.
* `iteratedDeriv n f` is the `n`-th derivative of `f`, seen as a function from `𝕜` to `F`.
It is defined as the `n`-th Fréchet derivative (which is a multilinear map) applied to the
vector `(1, ..., 1)`, to take advantage of all the existing framework, but we show that it
coincides with the naive iterative definition.
* `iteratedDeriv_eq_iterate` states that the `n`-th derivative of `f` is obtained by starting
from `f` and differentiating it `n` times.
* `iteratedDerivWithin n f s` is the `n`-th derivative of `f` within the domain `s`. It only
behaves well when `s` has the unique derivative property.
* `iteratedDerivWithin_eq_iterate` states that the `n`-th derivative of `f` in the domain `s` is
obtained by starting from `f` and differentiating it `n` times within `s`. This only holds when
`s` has the unique derivative property.
## Implementation details
The results are deduced from the corresponding results for the more general (multilinear) iterated
Fréchet derivative. For this, we write `iteratedDeriv n f` as the composition of
`iteratedFDeriv 𝕜 n f` and a continuous linear equiv. As continuous linear equivs respect
differentiability and commute with differentiation, this makes it possible to prove readily that
the derivative of the `n`-th derivative is the `n+1`-th derivative in `iteratedDerivWithin_succ`,
by translating the corresponding result `iteratedFDerivWithin_succ_apply_left` for the
iterated Fréchet derivative.
-/
noncomputable section
open scoped Topology
open Filter Asymptotics Set
variable {𝕜 : Type*} [NontriviallyNormedField 𝕜]
variable {F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F]
/-- The `n`-th iterated derivative of a function from `𝕜` to `F`, as a function from `𝕜` to `F`. -/
def iteratedDeriv (n : ℕ) (f : 𝕜 → F) (x : 𝕜) : F :=
(iteratedFDeriv 𝕜 n f x : (Fin n → 𝕜) → F) fun _ : Fin n => 1
/-- The `n`-th iterated derivative of a function from `𝕜` to `F` within a set `s`, as a function
from `𝕜` to `F`. -/
def iteratedDerivWithin (n : ℕ) (f : 𝕜 → F) (s : Set 𝕜) (x : 𝕜) : F :=
(iteratedFDerivWithin 𝕜 n f s x : (Fin n → 𝕜) → F) fun _ : Fin n => 1
variable {n : ℕ} {f : 𝕜 → F} {s : Set 𝕜} {x : 𝕜}
theorem iteratedDerivWithin_univ : iteratedDerivWithin n f univ = iteratedDeriv n f := by
ext x
rw [iteratedDerivWithin, iteratedDeriv, iteratedFDerivWithin_univ]
theorem iteratedDerivWithin_eq_iteratedDeriv (hs : UniqueDiffOn 𝕜 s) (h : ContDiffAt 𝕜 n f x)
(hx : x ∈ s) : iteratedDerivWithin n f s x = iteratedDeriv n f x := by
rw [iteratedDerivWithin, iteratedDeriv, iteratedFDerivWithin_eq_iteratedFDeriv hs h hx]
/-! ### Properties of the iterated derivative within a set -/
theorem iteratedDerivWithin_eq_iteratedFDerivWithin : iteratedDerivWithin n f s x =
(iteratedFDerivWithin 𝕜 n f s x : (Fin n → 𝕜) → F) fun _ : Fin n => 1 :=
rfl
/-- Write the iterated derivative as the composition of a continuous linear equiv and the iterated
Fréchet derivative -/
theorem iteratedDerivWithin_eq_equiv_comp : iteratedDerivWithin n f s =
(ContinuousMultilinearMap.piFieldEquiv 𝕜 (Fin n) F).symm ∘ iteratedFDerivWithin 𝕜 n f s := by
ext x; rfl
/-- Write the iterated Fréchet derivative as the composition of a continuous linear equiv and the
iterated derivative. -/
theorem iteratedFDerivWithin_eq_equiv_comp :
iteratedFDerivWithin 𝕜 n f s =
ContinuousMultilinearMap.piFieldEquiv 𝕜 (Fin n) F ∘ iteratedDerivWithin n f s := by
rw [iteratedDerivWithin_eq_equiv_comp, ← Function.comp_assoc, LinearIsometryEquiv.self_comp_symm,
Function.id_comp]
/-- The `n`-th Fréchet derivative applied to a vector `(m 0, ..., m (n-1))` is the derivative
multiplied by the product of the `m i`s. -/
theorem iteratedFDerivWithin_apply_eq_iteratedDerivWithin_mul_prod {m : Fin n → 𝕜} :
(iteratedFDerivWithin 𝕜 n f s x : (Fin n → 𝕜) → F) m =
(∏ i, m i) • iteratedDerivWithin n f s x := by
rw [iteratedDerivWithin_eq_iteratedFDerivWithin, ← ContinuousMultilinearMap.map_smul_univ]
simp
theorem norm_iteratedFDerivWithin_eq_norm_iteratedDerivWithin :
‖iteratedFDerivWithin 𝕜 n f s x‖ = ‖iteratedDerivWithin n f s x‖ := by
rw [iteratedDerivWithin_eq_equiv_comp, Function.comp_apply, LinearIsometryEquiv.norm_map]
@[simp]
theorem iteratedDerivWithin_zero : iteratedDerivWithin 0 f s = f := by
ext x
simp [iteratedDerivWithin]
@[simp]
theorem iteratedDerivWithin_one :
iteratedDerivWithin 1 f s = derivWithin f s := by
ext x
by_cases hsx : AccPt x (𝓟 s)
· simp only [iteratedDerivWithin, iteratedFDerivWithin_one_apply hsx.uniqueDiffWithinAt,
derivWithin]
· simp [derivWithin_zero_of_not_accPt hsx, iteratedDerivWithin, iteratedFDerivWithin,
fderivWithin_zero_of_not_accPt hsx]
/-- If the first `n` derivatives within a set of a function are continuous, and its first `n-1`
derivatives are differentiable, then the function is `C^n`. This is not an equivalence in general,
but this is an equivalence when the set has unique derivatives, see
`contDiffOn_iff_continuousOn_differentiableOn_deriv`. -/
theorem contDiffOn_of_continuousOn_differentiableOn_deriv {n : ℕ∞}
(Hcont : ∀ m : ℕ, (m : ℕ∞) ≤ n → ContinuousOn (fun x => iteratedDerivWithin m f s x) s)
(Hdiff : ∀ m : ℕ, (m : ℕ∞) < n → DifferentiableOn 𝕜 (fun x => iteratedDerivWithin m f s x) s) :
ContDiffOn 𝕜 n f s := by
apply contDiffOn_of_continuousOn_differentiableOn
· simpa only [iteratedFDerivWithin_eq_equiv_comp, LinearIsometryEquiv.comp_continuousOn_iff]
· simpa only [iteratedFDerivWithin_eq_equiv_comp, LinearIsometryEquiv.comp_differentiableOn_iff]
/-- To check that a function is `n` times continuously differentiable, it suffices to check that its
first `n` derivatives are differentiable. This is slightly too strong as the condition we
require on the `n`-th derivative is differentiability instead of continuity, but it has the
advantage of avoiding the discussion of continuity in the proof (and for `n = ∞` this is optimal).
-/
theorem contDiffOn_of_differentiableOn_deriv {n : ℕ∞}
(h : ∀ m : ℕ, (m : ℕ∞) ≤ n → DifferentiableOn 𝕜 (iteratedDerivWithin m f s) s) :
ContDiffOn 𝕜 n f s := by
apply contDiffOn_of_differentiableOn
simpa only [iteratedFDerivWithin_eq_equiv_comp, LinearIsometryEquiv.comp_differentiableOn_iff]
/-- On a set with unique derivatives, a `C^n` function has derivatives up to `n` which are
continuous. -/
theorem ContDiffOn.continuousOn_iteratedDerivWithin
{n : WithTop ℕ∞} {m : ℕ} (h : ContDiffOn 𝕜 n f s)
(hmn : m ≤ n) (hs : UniqueDiffOn 𝕜 s) : ContinuousOn (iteratedDerivWithin m f s) s := by
simpa only [iteratedDerivWithin_eq_equiv_comp, LinearIsometryEquiv.comp_continuousOn_iff] using
h.continuousOn_iteratedFDerivWithin hmn hs
theorem ContDiffWithinAt.differentiableWithinAt_iteratedDerivWithin {n : WithTop ℕ∞} {m : ℕ}
(h : ContDiffWithinAt 𝕜 n f s x) (hmn : m < n) (hs : UniqueDiffOn 𝕜 (insert x s)) :
DifferentiableWithinAt 𝕜 (iteratedDerivWithin m f s) s x := by
simpa only [iteratedDerivWithin_eq_equiv_comp,
LinearIsometryEquiv.comp_differentiableWithinAt_iff] using
h.differentiableWithinAt_iteratedFDerivWithin hmn hs
/-- On a set with unique derivatives, a `C^n` function has derivatives less than `n` which are
differentiable. -/
theorem ContDiffOn.differentiableOn_iteratedDerivWithin {n : WithTop ℕ∞} {m : ℕ}
(h : ContDiffOn 𝕜 n f s) (hmn : m < n) (hs : UniqueDiffOn 𝕜 s) :
DifferentiableOn 𝕜 (iteratedDerivWithin m f s) s := fun x hx =>
(h x hx).differentiableWithinAt_iteratedDerivWithin hmn <| by rwa [insert_eq_of_mem hx]
/-- The property of being `C^n`, initially defined in terms of the Fréchet derivative, can be
reformulated in terms of the one-dimensional derivative on sets with unique derivatives. -/
theorem contDiffOn_iff_continuousOn_differentiableOn_deriv {n : ℕ∞} (hs : UniqueDiffOn 𝕜 s) :
ContDiffOn 𝕜 n f s ↔ (∀ m : ℕ, (m : ℕ∞) ≤ n → ContinuousOn (iteratedDerivWithin m f s) s) ∧
∀ m : ℕ, (m : ℕ∞) < n → DifferentiableOn 𝕜 (iteratedDerivWithin m f s) s := by
simp only [contDiffOn_iff_continuousOn_differentiableOn hs, iteratedFDerivWithin_eq_equiv_comp,
LinearIsometryEquiv.comp_continuousOn_iff, LinearIsometryEquiv.comp_differentiableOn_iff]
/-- The property of being `C^n`, initially defined in terms of the Fréchet derivative, can be
reformulated in terms of the one-dimensional derivative on sets with unique derivatives. -/
theorem contDiffOn_nat_iff_continuousOn_differentiableOn_deriv {n : ℕ} (hs : UniqueDiffOn 𝕜 s) :
ContDiffOn 𝕜 n f s ↔ (∀ m : ℕ, m ≤ n → ContinuousOn (iteratedDerivWithin m f s) s) ∧
∀ m : ℕ, m < n → DifferentiableOn 𝕜 (iteratedDerivWithin m f s) s := by
rw [show n = ((n : ℕ∞) : WithTop ℕ∞) from rfl,
contDiffOn_iff_continuousOn_differentiableOn_deriv hs]
simp
/-- The `n+1`-th iterated derivative within a set with unique derivatives can be obtained by
differentiating the `n`-th iterated derivative. -/
theorem iteratedDerivWithin_succ {x : 𝕜} :
iteratedDerivWithin (n + 1) f s x = derivWithin (iteratedDerivWithin n f s) s x := by
by_cases hxs : AccPt x (𝓟 s)
· rw [iteratedDerivWithin_eq_iteratedFDerivWithin, iteratedFDerivWithin_succ_apply_left,
iteratedFDerivWithin_eq_equiv_comp,
LinearIsometryEquiv.comp_fderivWithin _ hxs.uniqueDiffWithinAt, derivWithin]
change ((ContinuousMultilinearMap.mkPiRing 𝕜 (Fin n) ((fderivWithin 𝕜
(iteratedDerivWithin n f s) s x : 𝕜 → F) 1) : (Fin n → 𝕜) → F) fun _ : Fin n => 1) =
(fderivWithin 𝕜 (iteratedDerivWithin n f s) s x : 𝕜 → F) 1
simp
· simp [derivWithin_zero_of_not_accPt hxs, iteratedDerivWithin, iteratedFDerivWithin,
fderivWithin_zero_of_not_accPt hxs]
/-- The `n`-th iterated derivative within a set with unique derivatives can be obtained by
iterating `n` times the differentiation operation. -/
theorem iteratedDerivWithin_eq_iterate {x : 𝕜} :
iteratedDerivWithin n f s x = (fun g : 𝕜 → F => derivWithin g s)^[n] f x := by
induction n generalizing x with
| zero => simp
| succ n IH =>
rw [iteratedDerivWithin_succ, Function.iterate_succ']
exact derivWithin_congr (fun y hy => IH) IH
/-- The `n+1`-th iterated derivative within a set with unique derivatives can be obtained by
taking the `n`-th derivative of the derivative. -/
theorem iteratedDerivWithin_succ' {x : 𝕜} :
iteratedDerivWithin (n + 1) f s x = (iteratedDerivWithin n (derivWithin f s) s) x := by
rw [iteratedDerivWithin_eq_iterate, iteratedDerivWithin_eq_iterate]; rfl
/-! ### Properties of the iterated derivative on the whole space -/
theorem iteratedDeriv_eq_iteratedFDeriv :
iteratedDeriv n f x = (iteratedFDeriv 𝕜 n f x : (Fin n → 𝕜) → F) fun _ : Fin n => 1 :=
rfl
/-- Write the iterated derivative as the composition of a continuous linear equiv and the iterated
Fréchet derivative -/
theorem iteratedDeriv_eq_equiv_comp : iteratedDeriv n f =
(ContinuousMultilinearMap.piFieldEquiv 𝕜 (Fin n) F).symm ∘ iteratedFDeriv 𝕜 n f := by
ext x; rfl
/-- Write the iterated Fréchet derivative as the composition of a continuous linear equiv and the
iterated derivative. -/
theorem iteratedFDeriv_eq_equiv_comp : iteratedFDeriv 𝕜 n f =
ContinuousMultilinearMap.piFieldEquiv 𝕜 (Fin n) F ∘ iteratedDeriv n f := by
rw [iteratedDeriv_eq_equiv_comp, ← Function.comp_assoc, LinearIsometryEquiv.self_comp_symm,
Function.id_comp]
/-- The `n`-th Fréchet derivative applied to a vector `(m 0, ..., m (n-1))` is the derivative
multiplied by the product of the `m i`s. -/
theorem iteratedFDeriv_apply_eq_iteratedDeriv_mul_prod {m : Fin n → 𝕜} :
(iteratedFDeriv 𝕜 n f x : (Fin n → 𝕜) → F) m = (∏ i, m i) • iteratedDeriv n f x := by
rw [iteratedDeriv_eq_iteratedFDeriv, ← ContinuousMultilinearMap.map_smul_univ]; simp
theorem norm_iteratedFDeriv_eq_norm_iteratedDeriv :
‖iteratedFDeriv 𝕜 n f x‖ = ‖iteratedDeriv n f x‖ := by
rw [iteratedDeriv_eq_equiv_comp, Function.comp_apply, LinearIsometryEquiv.norm_map]
@[simp]
theorem iteratedDeriv_zero : iteratedDeriv 0 f = f := by ext x; simp [iteratedDeriv]
@[simp]
theorem iteratedDeriv_one : iteratedDeriv 1 f = deriv f := by ext x; simp [iteratedDeriv]
/-- The property of being `C^n`, initially defined in terms of the Fréchet derivative, can be
reformulated in terms of the one-dimensional derivative. -/
theorem contDiff_iff_iteratedDeriv {n : ℕ∞} : ContDiff 𝕜 n f ↔
(∀ m : ℕ, (m : ℕ∞) ≤ n → Continuous (iteratedDeriv m f)) ∧
∀ m : ℕ, (m : ℕ∞) < n → Differentiable 𝕜 (iteratedDeriv m f) := by
simp only [contDiff_iff_continuous_differentiable, iteratedFDeriv_eq_equiv_comp,
LinearIsometryEquiv.comp_continuous_iff, LinearIsometryEquiv.comp_differentiable_iff]
/-- The property of being `C^n`, initially defined in terms of the Fréchet derivative, can be
reformulated in terms of the one-dimensional derivative. -/
theorem contDiff_nat_iff_iteratedDeriv {n : ℕ} : ContDiff 𝕜 n f ↔
(∀ m : ℕ, m ≤ n → Continuous (iteratedDeriv m f)) ∧
∀ m : ℕ, m < n → Differentiable 𝕜 (iteratedDeriv m f) := by
rw [← WithTop.coe_natCast, contDiff_iff_iteratedDeriv]
simp
/-- To check that a function is `n` times continuously differentiable, it suffices to check that its
first `n` derivatives are differentiable. This is slightly too strong as the condition we
require on the `n`-th derivative is differentiability instead of continuity, but it has the
advantage of avoiding the discussion of continuity in the proof (and for `n = ∞` this is optimal).
-/
theorem contDiff_of_differentiable_iteratedDeriv {n : ℕ∞}
(h : ∀ m : ℕ, (m : ℕ∞) ≤ n → Differentiable 𝕜 (iteratedDeriv m f)) : ContDiff 𝕜 n f :=
contDiff_iff_iteratedDeriv.2 ⟨fun m hm => (h m hm).continuous, fun m hm => h m (le_of_lt hm)⟩
theorem ContDiff.continuous_iteratedDeriv {n : WithTop ℕ∞} (m : ℕ) (h : ContDiff 𝕜 n f)
(hmn : m ≤ n) : Continuous (iteratedDeriv m f) :=
(contDiff_iff_iteratedDeriv.1 (h.of_le hmn)).1 m le_rfl
@[fun_prop]
theorem ContDiff.continuous_iteratedDeriv' (m : ℕ) (h : ContDiff 𝕜 m f) :
Continuous (iteratedDeriv m f) :=
ContDiff.continuous_iteratedDeriv m h (le_refl _)
theorem ContDiff.differentiable_iteratedDeriv {n : WithTop ℕ∞} (m : ℕ) (h : ContDiff 𝕜 n f)
(hmn : m < n) : Differentiable 𝕜 (iteratedDeriv m f) :=
(contDiff_iff_iteratedDeriv.1 (h.of_le (ENat.add_one_natCast_le_withTop_of_lt hmn))).2 m
(mod_cast (lt_add_one m))
@[fun_prop]
theorem ContDiff.differentiable_iteratedDeriv' (m : ℕ) (h : ContDiff 𝕜 (m + 1) f) :
Differentiable 𝕜 (iteratedDeriv m f) :=
h.differentiable_iteratedDeriv m (Nat.cast_lt.mpr m.lt_succ_self)
/-- The `n+1`-th iterated derivative can be obtained by differentiating the `n`-th
iterated derivative. -/
theorem iteratedDeriv_succ : iteratedDeriv (n + 1) f = deriv (iteratedDeriv n f) := by
ext x
rw [← iteratedDerivWithin_univ, ← iteratedDerivWithin_univ, ← derivWithin_univ]
exact iteratedDerivWithin_succ
/-- The `n`-th iterated derivative can be obtained by iterating `n` times the
differentiation operation. -/
theorem iteratedDeriv_eq_iterate : iteratedDeriv n f = deriv^[n] f := by
ext x
rw [← iteratedDerivWithin_univ]
convert iteratedDerivWithin_eq_iterate (F := F)
simp [derivWithin_univ]
theorem iteratedDerivWithin_of_isOpen (hs : IsOpen s) :
Set.EqOn (iteratedDerivWithin n f s) (iteratedDeriv n f) s := by
intro x hx
simp_rw [iteratedDerivWithin, iteratedDeriv,iteratedFDerivWithin_of_isOpen n hs hx]
theorem iteratedDerivWithin_congr_right_of_isOpen (f : 𝕜 → F) (n : ℕ) {s t : Set 𝕜} (hs : IsOpen s)
(ht : IsOpen t) : (s ∩ t).EqOn (iteratedDerivWithin n f s) (iteratedDerivWithin n f t) := by
intro r hr
rw [iteratedDerivWithin_of_isOpen hs hr.1, iteratedDerivWithin_of_isOpen ht hr.2]
theorem iteratedDerivWithin_of_isOpen_eq_iterate (hs : IsOpen s) :
EqOn (iteratedDerivWithin n f s) (deriv^[n] f) s := by
apply Set.EqOn.trans (iteratedDerivWithin_of_isOpen hs)
rw [iteratedDeriv_eq_iterate]
exact Set.eqOn_refl _ _
/-- The `n+1`-th iterated derivative can be obtained by taking the `n`-th derivative of the
derivative. -/
theorem iteratedDeriv_succ' : iteratedDeriv (n + 1) f = iteratedDeriv n (deriv f) := by
rw [iteratedDeriv_eq_iterate, iteratedDeriv_eq_iterate, Function.iterate_succ_apply]
lemma AnalyticAt.hasFPowerSeriesAt {𝕜 : Type*} [NontriviallyNormedField 𝕜] [CompleteSpace 𝕜]
[CharZero 𝕜] {f : 𝕜 → 𝕜} {x : 𝕜} (h : AnalyticAt 𝕜 f x) :
HasFPowerSeriesAt f
(FormalMultilinearSeries.ofScalars 𝕜 (fun n ↦ iteratedDeriv n f x / n.factorial)) x := by
obtain ⟨p, hp⟩ := h
convert hp
obtain ⟨r, hpr⟩ := hp
ext n
have h_fact_smul := hpr.factorial_smul 1
simp only [FormalMultilinearSeries.apply_eq_prod_smul_coeff, Finset.prod_const, Finset.card_univ,
Fintype.card_fin, smul_eq_mul, nsmul_eq_mul, one_pow, one_mul] at h_fact_smul
simp only [FormalMultilinearSeries.apply_eq_prod_smul_coeff,
FormalMultilinearSeries.coeff_ofScalars, smul_eq_mul, mul_eq_mul_left_iff]
left
rw [div_eq_iff, mul_comm, h_fact_smul, ← iteratedDeriv_eq_iteratedFDeriv]
norm_cast
positivity |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/IteratedDeriv/WithinZpow.lean | import Mathlib.Analysis.Calculus.IteratedDeriv.Defs
import Mathlib.Analysis.Calculus.Deriv.ZPow
/-!
# Derivatives of `x ^ m`, `m : ℤ` within an open set
In this file we prove theorems about iterated derivatives of `x ^ m`, `m : ℤ` within an open set.
## Keywords
iterated, derivative, power, open set
-/
open scoped Nat
variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] {s : Set 𝕜}
theorem iteratedDerivWithin_zpow (m : ℤ) (k : ℕ) (hs : IsOpen s) :
s.EqOn (iteratedDerivWithin k (fun y ↦ y ^ m) s)
(fun y ↦ (∏ i ∈ Finset.range k, ((m : 𝕜) - i)) * y ^ (m - k)) := by
apply Set.EqOn.trans (iteratedDerivWithin_of_isOpen_eq_iterate hs)
intro t ht
simp
theorem iteratedDerivWithin_one_div (k : ℕ) (hs : IsOpen s) :
s.EqOn (iteratedDerivWithin k (fun y ↦ 1 / y) s)
(fun y ↦ (-1) ^ k * (k !) * (y ^ (-1 - k : ℤ))) := by
apply Set.EqOn.trans (iteratedDerivWithin_of_isOpen_eq_iterate hs)
intro t ht
simp |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/IteratedDeriv/ConvergenceOnBall.lean | import Mathlib.Analysis.Analytic.Uniqueness
import Mathlib.Analysis.Calculus.IteratedDeriv.Defs
import Mathlib.Analysis.NormedSpace.Connected
import Mathlib.Analysis.RCLike.Basic
/-!
# Taylor series converges to function on whole ball
In this file we prove that if a function `f` is analytic on the ball of convergence of its Taylor
series, then the series converges to `f` on this ball.
-/
variable {𝕜 : Type*} [RCLike 𝕜] {f : 𝕜 → 𝕜} {x : 𝕜}
/-- If `f` is analytic on `Bᵣ(x₀)` and its Taylor series converges on this ball, then it converges
to `f`. -/
theorem AnalyticOn.hasFPowerSeriesOnSubball
{r : ENNReal} (hr_pos : 0 < r) (h : AnalyticOn 𝕜 f (EMetric.ball x r)) :
letI p := FormalMultilinearSeries.ofScalars 𝕜 (fun n ↦ iteratedDeriv n f x / n.factorial);
r ≤ p.radius → HasFPowerSeriesOnBall f p x r := by
rw [EMetric.isOpen_ball.analyticOn_iff_analyticOnNhd] at h
intro hr
set p := FormalMultilinearSeries.ofScalars 𝕜 (fun n ↦ iteratedDeriv n f x / n.factorial)
let g (t : 𝕜) := p.sum (t - x)
have hg : HasFPowerSeriesOnBall g p x p.radius := by
simpa using (p.hasFPowerSeriesOnBall (by order)).comp_sub x
have hg' : AnalyticOnNhd 𝕜 g (EMetric.ball x p.radius) := by
simpa using p.analyticOnNhd.comp_sub x
replace hg' : AnalyticOnNhd 𝕜 g (EMetric.ball x r) := hg'.mono (EMetric.ball_subset_ball hr)
apply h.eqOn_of_preconnected_of_eventuallyEq at hg'
apply (hg.mono hr_pos hr).congr
symm
apply hg' (Metric.isConnected_eball hr_pos).isPreconnected (show x ∈ EMetric.ball x r by simpa) ?_
have hf : AnalyticAt 𝕜 f x := h _ (by simp [hr_pos])
apply AnalyticAt.hasFPowerSeriesAt at hf
unfold Filter.EventuallyEq Filter.Eventually
rw [EMetric.mem_nhds_iff]
obtain ⟨ε, hf⟩ := hf
exact ⟨ε, hf.r_pos, hf.unique (hg.mono hf.r_pos hf.r_le)⟩
/-- If `f` is analytic on the ball of convergence of its Taylor series, then the series converges
to `f` on this ball. This is a stronger version of `AnalyticAt.hasFPowerSeriesAt` that requires
the assumption `RCLike 𝕜`.
For example, over the `p`-adic numbers, the indicator function of the unit ball is
analytic everywhere, but it agrees with the sum of its Taylor series only on this unit ball. -/
theorem AnalyticOn.hasFPowerSeriesOnBall :
letI p := FormalMultilinearSeries.ofScalars 𝕜 (fun n ↦ iteratedDeriv n f x / n.factorial);
0 < p.radius → AnalyticOn 𝕜 f (EMetric.ball x p.radius) →
HasFPowerSeriesOnBall f p x p.radius := by
intro hr hs
exact hs.hasFPowerSeriesOnSubball hr le_rfl |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/ContDiff/FTaylorSeries.lean | import Mathlib.Analysis.Calculus.FDeriv.Add
import Mathlib.Analysis.Calculus.FDeriv.Equiv
import Mathlib.Analysis.Calculus.FormalMultilinearSeries
import Mathlib.Data.ENat.Lattice
/-!
# Iterated derivatives of a function
In this file, we define iteratively the `n+1`-th derivative of a function as the
derivative of the `n`-th derivative. It is called `iteratedFDeriv 𝕜 n f x` where `𝕜` is the
field, `n` is the number of iterations, `f` is the function and `x` is the point, and it is given
as an `n`-multilinear map. We also define a version `iteratedFDerivWithin` relative to a domain.
Note that, in domains, there may be several choices of possible derivative, so we make some
arbitrary choice in the definition.
We also define a predicate `HasFTaylorSeriesUpTo` (and its localized version
`HasFTaylorSeriesUpToOn`), saying that a sequence of multilinear maps is *a* sequence of
derivatives of `f`. Contrary to `iteratedFDerivWithin`, it accommodates well the
non-uniqueness of derivatives.
## Main definitions and results
Let `f : E → F` be a map between normed vector spaces over a nontrivially normed field `𝕜`.
* `HasFTaylorSeriesUpTo n f p`: expresses that the formal multilinear series `p` is a sequence
of iterated derivatives of `f`, up to the `n`-th term (where `n` is a natural number or `∞`).
* `HasFTaylorSeriesUpToOn n f p s`: same thing, but inside a set `s`. The notion of derivative
is now taken inside `s`. In particular, derivatives don't have to be unique.
* `iteratedFDerivWithin 𝕜 n f s x` is an `n`-th derivative of `f` over the field `𝕜` on the
set `s` at the point `x`. It is a continuous multilinear map from `E^n` to `F`, defined as a
derivative within `s` of `iteratedFDerivWithin 𝕜 (n-1) f s` if one exists, and `0` otherwise.
* `iteratedFDeriv 𝕜 n f x` is the `n`-th derivative of `f` over the field `𝕜` at the point `x`.
It is a continuous multilinear map from `E^n` to `F`, defined as a derivative of
`iteratedFDeriv 𝕜 (n-1) f` if one exists, and `0` otherwise.
### Side of the composition, and universe issues
With a naïve direct definition, the `n`-th derivative of a function belongs to the space
`E →L[𝕜] (E →L[𝕜] (E ... F)...)))` where there are n iterations of `E →L[𝕜]`. This space
may also be seen as the space of continuous multilinear functions on `n` copies of `E` with
values in `F`, by uncurrying. This is the point of view that is usually adopted in textbooks,
and that we also use. This means that the definition and the first proofs are slightly involved,
as one has to keep track of the uncurrying operation. The uncurrying can be done from the
left or from the right, amounting to defining the `n+1`-th derivative either as the derivative of
the `n`-th derivative, or as the `n`-th derivative of the derivative.
For proofs, it would be more convenient to use the latter approach (from the right),
as it means to prove things at the `n+1`-th step we only need to understand well enough the
derivative in `E →L[𝕜] F` (contrary to the approach from the left, where one would need to know
enough on the `n`-th derivative to deduce things on the `n+1`-th derivative).
However, the definition from the right leads to a universe polymorphism problem: if we define
`iteratedFDeriv 𝕜 (n + 1) f x = iteratedFDeriv 𝕜 n (fderiv 𝕜 f) x` by induction, we need to
generalize over all spaces (as `f` and `fderiv 𝕜 f` don't take values in the same space). It is
only possible to generalize over all spaces in some fixed universe in an inductive definition.
For `f : E → F`, then `fderiv 𝕜 f` is a map `E → (E →L[𝕜] F)`. Therefore, the definition will only
work if `F` and `E →L[𝕜] F` are in the same universe.
This issue does not appear with the definition from the left, where one does not need to generalize
over all spaces. Therefore, we use the definition from the left. This means some proofs later on
become a little bit more complicated: to prove that a function is `C^n`, the most efficient approach
is to exhibit a formula for its `n`-th derivative and prove it is continuous (contrary to the
inductive approach where one would prove smoothness statements without giving a formula for the
derivative). In the end, this approach is still satisfactory as it is good to have formulas for the
iterated derivatives in various constructions.
One point where this explicit approach is particularly delicate is in the proof of smoothness of a
composition: there is a formula for the `n`-th derivative of a composition (Faà di Bruno's formula),
but it is very complicated, while the inductive proof is very simple. The inductive proof would
be good enough for `C^n` functions with `n ∈ ℕ ∪ {∞}` (modulo polymorphism issues, i.e., one would
need to first prove inductively the result when all spaces belong to the same universe, and then
prove the general result by lifting all the spaces to a common universe). However, it would not
work for `C^ω` functions. Therefore, we give the proof based on Faà di Bruno's formula, which is
more complicated but more general.
### Variables management
The textbook definitions and proofs use various identifications and abuse of notations, for instance
when saying that the natural space in which the derivative lives, i.e.,
`E →L[𝕜] (E →L[𝕜] ( ... →L[𝕜] F))`, is the same as a space of multilinear maps. When doing things
formally, we need to provide explicit maps for these identifications, and chase some diagrams to see
everything is compatible with the identifications. In particular, one needs to check that taking the
derivative and then doing the identification, or first doing the identification and then taking the
derivative, gives the same result. The key point for this is that taking the derivative commutes
with continuous linear equivalences. Therefore, we need to implement all our identifications with
continuous linear equivs.
## Notation
We use the notation `E [×n]→L[𝕜] F` for the space of continuous multilinear maps on `E^n` with
values in `F`. This is the space in which the `n`-th derivative of a function from `E` to `F` lives.
In this file, we denote `⊤ : ℕ∞` with `∞`.
-/
noncomputable section
open ENat NNReal Topology Filter Set Fin Filter Function
/-- Smoothness exponent for analytic functions. -/
scoped [ContDiff] notation3 "ω" => (⊤ : WithTop ℕ∞)
/-- Smoothness exponent for infinitely differentiable functions. -/
scoped [ContDiff] notation3 "∞" => ((⊤ : ℕ∞) : WithTop ℕ∞)
open scoped ContDiff Pointwise
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 N : WithTop ℕ∞}
{p : E → FormalMultilinearSeries 𝕜 E F}
/-! ### Functions with a Taylor series on a domain -/
/-- `HasFTaylorSeriesUpToOn n f p s` registers the fact that `p 0 = f` and `p (m+1)` is a
derivative of `p m` for `m < n`, and is continuous for `m ≤ n`. This is a predicate analogous to
`HasFDerivWithinAt` but for higher-order derivatives.
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 : 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
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
rw [← h.zero_eq x hx]
exact (p x 0).uncurry0_curry0.symm
/-- If two functions coincide on a set `s`, then a Taylor series for the first one is as well a
Taylor series for the second one. -/
theorem HasFTaylorSeriesUpToOn.congr (h : HasFTaylorSeriesUpToOn n f p s)
(h₁ : ∀ x ∈ s, f₁ x = f x) : HasFTaylorSeriesUpToOn n f₁ p s := by
refine ⟨fun x hx => ?_, h.fderivWithin, h.cont⟩
rw [h₁ x hx]
exact h.zero_eq x hx
theorem HasFTaylorSeriesUpToOn.congr_series {q} (hp : HasFTaylorSeriesUpToOn n f p s)
(hpq : ∀ m : ℕ, m ≤ n → EqOn (p · m) (q · m) s) :
HasFTaylorSeriesUpToOn n f q s where
zero_eq x hx := by simp only [← (hpq 0 (zero_le n) hx), hp.zero_eq x hx]
fderivWithin m hm x hx := by
refine ((hp.fderivWithin m hm x hx).congr' (hpq m hm.le).symm hx).congr_fderiv ?_
refine congrArg _ (hpq (m + 1) ?_ hx)
exact ENat.add_one_natCast_le_withTop_of_lt hm
cont m hm := (hp.cont m hm).congr (hpq m hm).symm
theorem HasFTaylorSeriesUpToOn.mono (h : HasFTaylorSeriesUpToOn n f p s) {t : Set E} (hst : t ⊆ s) :
HasFTaylorSeriesUpToOn n f p t :=
⟨fun x hx => h.zero_eq x (hst hx), fun m hm x hx => (h.fderivWithin m hm x (hst hx)).mono hst,
fun m hm => (h.cont m hm).mono hst⟩
theorem HasFTaylorSeriesUpToOn.of_le (h : HasFTaylorSeriesUpToOn n f p s) (hmn : m ≤ n) :
HasFTaylorSeriesUpToOn m f p s :=
⟨h.zero_eq, fun k hk x hx => h.fderivWithin k (lt_of_lt_of_le hk hmn) x hx, fun k hk =>
h.cont k (le_trans hk hmn)⟩
theorem HasFTaylorSeriesUpToOn.continuousOn (h : HasFTaylorSeriesUpToOn n f p s) :
ContinuousOn f s := by
have := (h.cont 0 bot_le).congr fun x hx => (h.zero_eq' hx).symm
rwa [← (continuousMultilinearCurryFin0 𝕜 E F).symm.comp_continuousOn_iff]
theorem hasFTaylorSeriesUpToOn_zero_iff :
HasFTaylorSeriesUpToOn 0 f p s ↔ ContinuousOn f s ∧ ∀ x ∈ s, (p x 0).curry0 = f x := by
refine ⟨fun H => ⟨H.continuousOn, H.zero_eq⟩, fun H =>
⟨H.2, fun m hm => False.elim (not_le.2 hm bot_le), fun m hm ↦ ?_⟩⟩
obtain rfl : m = 0 := mod_cast hm.antisymm (zero_le _)
have : EqOn (p · 0) ((continuousMultilinearCurryFin0 𝕜 E F).symm ∘ f) s := fun x hx ↦
(continuousMultilinearCurryFin0 𝕜 E F).eq_symm_apply.2 (H.2 x hx)
rw [continuousOn_congr this, LinearIsometryEquiv.comp_continuousOn_iff]
exact H.1
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
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 (by norm_cast; cutsat)
· intro m _
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' (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 := by
-- Everything except for the continuity is trivial:
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⟩⟩
/-- If a function has a Taylor series at order at least `1`, then the term of order `1` of this
series is a derivative of `f`. -/
theorem HasFTaylorSeriesUpToOn.hasFDerivWithinAt (h : HasFTaylorSeriesUpToOn n f p s) (hn : 1 ≤ n)
(hx : x ∈ s) : HasFDerivWithinAt f (continuousMultilinearCurryFin1 𝕜 E F (p x 1)) s x := by
have A : ∀ y ∈ s, f y = (continuousMultilinearCurryFin0 𝕜 E F) (p y 0) := fun y hy ↦
(h.zero_eq y hy).symm
suffices H : HasFDerivWithinAt (continuousMultilinearCurryFin0 𝕜 E F ∘ (p · 0))
(continuousMultilinearCurryFin1 𝕜 E F (p x 1)) s x from H.congr A (A x hx)
rw [LinearIsometryEquiv.comp_hasFDerivWithinAt_iff']
have : ((0 : ℕ) : ℕ∞) < n := zero_lt_one.trans_le hn
convert h.fderivWithin _ this x hx
ext y v
change (p x 1) (snoc 0 y) = (p x 1) (cons y v)
congr with i
rw [Unique.eq_default (α := Fin 1) i]
rfl
theorem HasFTaylorSeriesUpToOn.differentiableOn (h : HasFTaylorSeriesUpToOn n f p s) (hn : 1 ≤ n) :
DifferentiableOn 𝕜 f s := fun _x hx => (h.hasFDerivWithinAt hn hx).differentiableWithinAt
/-- If a function has a Taylor series at order at least `1` on a neighborhood of `x`, then the term
of order `1` of this series is a derivative of `f` at `x`. -/
theorem HasFTaylorSeriesUpToOn.hasFDerivAt (h : HasFTaylorSeriesUpToOn n f p s) (hn : 1 ≤ n)
(hx : s ∈ 𝓝 x) : HasFDerivAt f (continuousMultilinearCurryFin1 𝕜 E F (p x 1)) x :=
(h.hasFDerivWithinAt hn (mem_of_mem_nhds hx)).hasFDerivAt hx
/-- If a function has a Taylor series at order at least `1` on a neighborhood of `x`, then
in a neighborhood of `x`, the term of order `1` of this series is a derivative of `f`. -/
theorem HasFTaylorSeriesUpToOn.eventually_hasFDerivAt (h : HasFTaylorSeriesUpToOn n f p s)
(hn : 1 ≤ n) (hx : s ∈ 𝓝 x) :
∀ᶠ y in 𝓝 x, HasFDerivAt f (continuousMultilinearCurryFin1 𝕜 E F (p y 1)) y :=
(eventually_eventually_nhds.2 hx).mono fun _y hy => h.hasFDerivAt hn hy
/-- If a function has a Taylor series at order at least `1` on a neighborhood of `x`, then
it is differentiable at `x`. -/
theorem HasFTaylorSeriesUpToOn.differentiableAt (h : HasFTaylorSeriesUpToOn n f p s) (hn : 1 ≤ n)
(hx : s ∈ 𝓝 x) : DifferentiableAt 𝕜 f x :=
(h.hasFDerivAt hn hx).differentiableAt
/-- `p` is a Taylor series of `f` up to `n+1` if and only if `p` is a Taylor series up to `n`, and
`p (n + 1)` is a derivative of `p n`. -/
theorem hasFTaylorSeriesUpToOn_succ_iff_left {n : ℕ} :
HasFTaylorSeriesUpToOn (n + 1) f p s ↔
HasFTaylorSeriesUpToOn n f p s ∧
(∀ 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 (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 (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 (mod_cast h')
· have : m = n + 1 := le_antisymm (mod_cast hm) (not_le.1 h')
rw [this]
exact h.2.2
theorem HasFTaylorSeriesUpToOn.shift_of_succ
{n : ℕ} (H : HasFTaylorSeriesUpToOn (n + 1 : ℕ) f p s) :
(HasFTaylorSeriesUpToOn n (fun x => continuousMultilinearCurryFin1 𝕜 E F (p x 1))
(fun x => (p x).shift)) s := by
constructor
· intro x _
rfl
· 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))
(p x m.succ.succ).curryRight.curryLeft s x
rw [(continuousMultilinearCurryRightEquiv' 𝕜 m E F).comp_hasFDerivWithinAt_iff']
convert H.fderivWithin _ A x hx
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 : WithTop ℕ∞) ≤ n)
suffices A : ContinuousOn (p · (m + 1)) s from
(continuousMultilinearCurryRightEquiv' 𝕜 m E F).continuous.comp_continuousOn A
refine H.cont _ ?_
rw [Nat.cast_le] at hm ⊢
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`. 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) ∧
HasFTaylorSeriesUpToOn n (fun x => continuousMultilinearCurryFin1 𝕜 E F (p x 1))
(fun x => (p x).shift) s := by
constructor
· intro H
refine ⟨H.zero_eq, H.fderivWithin 0 (Nat.cast_lt.2 (Nat.succ_pos n)), ?_⟩
exact H.shift_of_succ
· rintro ⟨Hzero_eq, Hfderiv_zero, Htaylor⟩
constructor
· exact Hzero_eq
· intro m (hm : (m : WithTop ℕ∞) < n.succ) x (hx : x ∈ s)
rcases m with - | m
· exact Hfderiv_zero x hx
· have A : (m : WithTop ℕ∞) < n := by
rw [Nat.cast_lt] at hm ⊢
exact Nat.lt_of_succ_lt_succ hm
have :
HasFDerivWithinAt (𝕜 := 𝕜) (continuousMultilinearCurryRightEquiv' 𝕜 m E F ∘ (p · m.succ))
((p x).shift m.succ).curryLeft s x := Htaylor.fderivWithin _ A x hx
rw [LinearIsometryEquiv.comp_hasFDerivWithinAt_iff'
(f' := ((p x).shift m.succ).curryLeft)] at this
convert this
ext y v
change
(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 : WithTop ℕ∞) ≤ n.succ)
rcases m with - | m
· have : DifferentiableOn 𝕜 (fun x => p x 0) s := fun x hx =>
(Hfderiv_zero x hx).differentiableWithinAt
exact this.continuousOn
· refine (continuousMultilinearCurryRightEquiv' 𝕜 m E F).comp_continuousOn_iff.mp ?_
refine Htaylor.cont _ ?_
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 -/
variable (𝕜)
/-- The `n`-th derivative of a function along a set, defined inductively by saying that the `n+1`-th
derivative of `f` is the derivative of the `n`-th derivative of `f` along this set, together with
an uncurrying step to see it as a multilinear map in `n+1` variables..
-/
noncomputable def iteratedFDerivWithin (n : ℕ) (f : E → F) (s : Set E) : E → E[×n]→L[𝕜] F :=
Nat.recOn n (fun x => ContinuousMultilinearMap.uncurry0 𝕜 E (f x)) fun _ rec x =>
ContinuousLinearMap.uncurryLeft (fderivWithin 𝕜 rec s x)
/-- Formal Taylor series associated to a function within a set. -/
def ftaylorSeriesWithin (f : E → F) (s : Set E) (x : E) : FormalMultilinearSeries 𝕜 E F := fun n =>
iteratedFDerivWithin 𝕜 n f s x
variable {𝕜}
@[simp]
theorem iteratedFDerivWithin_zero_apply (m : Fin 0 → E) :
(iteratedFDerivWithin 𝕜 0 f s x : (Fin 0 → E) → F) m = f x :=
rfl
theorem iteratedFDerivWithin_zero_eq_comp :
iteratedFDerivWithin 𝕜 0 f s = (continuousMultilinearCurryFin0 𝕜 E F).symm ∘ f :=
rfl
@[simp]
theorem dist_iteratedFDerivWithin_zero (f : E → F) (s : Set E) (x : E)
(g : E → F) (t : Set E) (y : E) :
dist (iteratedFDerivWithin 𝕜 0 f s x) (iteratedFDerivWithin 𝕜 0 g t y) = dist (f x) (g y) := by
simp only [iteratedFDerivWithin_zero_eq_comp, comp_apply, LinearIsometryEquiv.dist_map]
@[simp]
theorem norm_iteratedFDerivWithin_zero : ‖iteratedFDerivWithin 𝕜 0 f s x‖ = ‖f x‖ := by
rw [iteratedFDerivWithin_zero_eq_comp, comp_apply, LinearIsometryEquiv.norm_map]
theorem iteratedFDerivWithin_succ_apply_left {n : ℕ} (m : Fin (n + 1) → E) :
(iteratedFDerivWithin 𝕜 (n + 1) f s x : (Fin (n + 1) → E) → F) m =
(fderivWithin 𝕜 (iteratedFDerivWithin 𝕜 n f s) s x : E → E[×n]→L[𝕜] F) (m 0) (tail m) :=
rfl
/-- Writing explicitly the `n+1`-th derivative as the composition of a currying linear equiv,
and the derivative of the `n`-th derivative. -/
theorem iteratedFDerivWithin_succ_eq_comp_left {n : ℕ} :
iteratedFDerivWithin 𝕜 (n + 1) f s =
(continuousMultilinearCurryLeftEquiv 𝕜 (fun _ : Fin (n + 1) => E) F).symm ∘
fderivWithin 𝕜 (iteratedFDerivWithin 𝕜 n f s) s :=
rfl
theorem fderivWithin_iteratedFDerivWithin {s : Set E} {n : ℕ} :
fderivWithin 𝕜 (iteratedFDerivWithin 𝕜 n f s) s =
(continuousMultilinearCurryLeftEquiv 𝕜 (fun _ : Fin (n + 1) => E) F) ∘
iteratedFDerivWithin 𝕜 (n + 1) f s :=
rfl
theorem norm_fderivWithin_iteratedFDerivWithin {n : ℕ} :
‖fderivWithin 𝕜 (iteratedFDerivWithin 𝕜 n f s) s x‖ =
‖iteratedFDerivWithin 𝕜 (n + 1) f s x‖ := by
rw [iteratedFDerivWithin_succ_eq_comp_left, comp_apply, LinearIsometryEquiv.norm_map]
@[simp]
theorem dist_iteratedFDerivWithin_one (f g : E → F) {y}
(hsx : UniqueDiffWithinAt 𝕜 s x) (hyt : UniqueDiffWithinAt 𝕜 t y) :
dist (iteratedFDerivWithin 𝕜 1 f s x) (iteratedFDerivWithin 𝕜 1 g t y)
= dist (fderivWithin 𝕜 f s x) (fderivWithin 𝕜 g t y) := by
simp only [iteratedFDerivWithin_succ_eq_comp_left, comp_apply,
LinearIsometryEquiv.dist_map, iteratedFDerivWithin_zero_eq_comp,
LinearIsometryEquiv.comp_fderivWithin, hsx, hyt]
apply (continuousMultilinearCurryFin0 𝕜 E F).symm.toLinearIsometry.postcomp.dist_map
@[simp]
theorem norm_iteratedFDerivWithin_one (f : E → F) (h : UniqueDiffWithinAt 𝕜 s x) :
‖iteratedFDerivWithin 𝕜 1 f s x‖ = ‖fderivWithin 𝕜 f s x‖ := by
simp only [← norm_fderivWithin_iteratedFDerivWithin,
iteratedFDerivWithin_zero_eq_comp, LinearIsometryEquiv.comp_fderivWithin _ h]
apply (continuousMultilinearCurryFin0 𝕜 E F).symm.toLinearIsometry.norm_toContinuousLinearMap_comp
theorem iteratedFDerivWithin_succ_apply_right {n : ℕ} (hs : UniqueDiffOn 𝕜 s) (hx : x ∈ s)
(m : Fin (n + 1) → E) :
(iteratedFDerivWithin 𝕜 (n + 1) f s x : (Fin (n + 1) → E) → F) m =
iteratedFDerivWithin 𝕜 n (fun y => fderivWithin 𝕜 f s y) s x (init m) (m (last n)) := by
induction n generalizing x with
| zero =>
rw [iteratedFDerivWithin_succ_eq_comp_left, iteratedFDerivWithin_zero_eq_comp,
iteratedFDerivWithin_zero_apply, Function.comp_apply,
LinearIsometryEquiv.comp_fderivWithin _ (hs x hx)]
simp
| succ n IH =>
let I := (continuousMultilinearCurryRightEquiv' 𝕜 n E F).symm
have A : ∀ y ∈ s, iteratedFDerivWithin 𝕜 n.succ f s y =
(I ∘ iteratedFDerivWithin 𝕜 n (fun y => fderivWithin 𝕜 f s y) s) y := fun y hy ↦ by
ext m
simp [IH hy m, I]
calc
(iteratedFDerivWithin 𝕜 (n + 2) f s x : (Fin (n + 2) → E) → F) m =
(fderivWithin 𝕜 (iteratedFDerivWithin 𝕜 n.succ f s) s x : E → E[×n + 1]→L[𝕜] F) (m 0)
(tail m) := by
simp [iteratedFDerivWithin_succ_eq_comp_left]
_ = (fderivWithin 𝕜 (I ∘ iteratedFDerivWithin 𝕜 n (fderivWithin 𝕜 f s) s) s x :
E → E[×n + 1]→L[𝕜] F) (m 0) (tail m) := by
rw [fderivWithin_congr A (A x hx)]
_ = (I ∘ fderivWithin 𝕜 (iteratedFDerivWithin 𝕜 n (fderivWithin 𝕜 f s) s) s x :
E → E[×n + 1]→L[𝕜] F) (m 0) (tail m) := by
simp [LinearIsometryEquiv.comp_fderivWithin _ (hs x hx)]
_ = (fderivWithin 𝕜 (iteratedFDerivWithin 𝕜 n (fun y => fderivWithin 𝕜 f s y) s) s x :
E → E[×n]→L[𝕜] E →L[𝕜] F) (m 0) (init (tail m)) ((tail m) (last n)) := by
simp [I]
_ = iteratedFDerivWithin 𝕜 (Nat.succ n) (fun y => fderivWithin 𝕜 f s y) s x (init m)
(m (last (n + 1))) := by
rw [iteratedFDerivWithin_succ_apply_left, tail_init_eq_init_tail]
simp [init, tail]
/-- Writing explicitly the `n+1`-th derivative as the composition of a currying linear equiv,
and the `n`-th derivative of the derivative. -/
theorem iteratedFDerivWithin_succ_eq_comp_right {n : ℕ} (hs : UniqueDiffOn 𝕜 s) (hx : x ∈ s) :
iteratedFDerivWithin 𝕜 (n + 1) f s x =
((continuousMultilinearCurryRightEquiv' 𝕜 n E F).symm ∘
iteratedFDerivWithin 𝕜 n (fun y => fderivWithin 𝕜 f s y) s)
x := by
ext m; simp [iteratedFDerivWithin_succ_apply_right hs hx]
theorem norm_iteratedFDerivWithin_fderivWithin {n : ℕ} (hs : UniqueDiffOn 𝕜 s) (hx : x ∈ s) :
‖iteratedFDerivWithin 𝕜 n (fderivWithin 𝕜 f s) s x‖ =
‖iteratedFDerivWithin 𝕜 (n + 1) f s x‖ := by
rw [iteratedFDerivWithin_succ_eq_comp_right hs hx, comp_apply, LinearIsometryEquiv.norm_map]
@[simp]
theorem iteratedFDerivWithin_one_apply (h : UniqueDiffWithinAt 𝕜 s x) (m : Fin 1 → E) :
iteratedFDerivWithin 𝕜 1 f s x m = fderivWithin 𝕜 f s x (m 0) := by
simp [iteratedFDerivWithin_succ_apply_left, iteratedFDerivWithin_zero_eq_comp,
(continuousMultilinearCurryFin0 𝕜 E F).symm.comp_fderivWithin h]
/-- On a set of unique differentiability, the second derivative is obtained by taking the
derivative of the derivative. -/
lemma iteratedFDerivWithin_two_apply (f : E → F) {z : E} (hs : UniqueDiffOn 𝕜 s) (hz : z ∈ s)
(m : Fin 2 → E) :
iteratedFDerivWithin 𝕜 2 f s z m = fderivWithin 𝕜 (fderivWithin 𝕜 f s) s z (m 0) (m 1) := by
simp only [iteratedFDerivWithin_succ_apply_right hs hz]
rfl
/-- On a set of unique differentiability, the second derivative is obtained by taking the
derivative of the derivative. -/
lemma iteratedFDerivWithin_two_apply' (f : E → F) {z : E} (hs : UniqueDiffOn 𝕜 s) (hz : z ∈ s)
(v w : E) :
iteratedFDerivWithin 𝕜 2 f s z ![v, w] = fderivWithin 𝕜 (fderivWithin 𝕜 f s) s z v w :=
iteratedFDerivWithin_two_apply f hs hz _
theorem Filter.EventuallyEq.iteratedFDerivWithin' (h : f₁ =ᶠ[𝓝[s] x] f) (ht : t ⊆ s) (n : ℕ) :
iteratedFDerivWithin 𝕜 n f₁ t =ᶠ[𝓝[s] x] iteratedFDerivWithin 𝕜 n f t := by
induction n with
| zero => exact h.mono fun y hy => DFunLike.ext _ _ fun _ => hy
| succ n ihn =>
have : fderivWithin 𝕜 _ t =ᶠ[𝓝[s] x] fderivWithin 𝕜 _ t := ihn.fderivWithin' ht
refine this.mono fun y hy => ?_
simp only [iteratedFDerivWithin_succ_eq_comp_left, hy, (· ∘ ·)]
protected theorem Filter.EventuallyEq.iteratedFDerivWithin (h : f₁ =ᶠ[𝓝[s] x] f) (n : ℕ) :
iteratedFDerivWithin 𝕜 n f₁ s =ᶠ[𝓝[s] x] iteratedFDerivWithin 𝕜 n f s :=
h.iteratedFDerivWithin' Subset.rfl n
/-- If two functions coincide in a neighborhood of `x` within a set `s` and at `x`, then their
iterated differentials within this set at `x` coincide. -/
theorem Filter.EventuallyEq.iteratedFDerivWithin_eq (h : f₁ =ᶠ[𝓝[s] x] f) (hx : f₁ x = f x)
(n : ℕ) : iteratedFDerivWithin 𝕜 n f₁ s x = iteratedFDerivWithin 𝕜 n f s x :=
have : f₁ =ᶠ[𝓝[insert x s] x] f := by simpa [EventuallyEq, hx]
(this.iteratedFDerivWithin' (subset_insert _ _) n).self_of_nhdsWithin (mem_insert _ _)
/-- If two functions coincide on a set `s`, then their iterated differentials within this set
coincide. See also `Filter.EventuallyEq.iteratedFDerivWithin_eq` and
`Filter.EventuallyEq.iteratedFDerivWithin`. -/
theorem iteratedFDerivWithin_congr (hs : EqOn f₁ f s) (hx : x ∈ s) (n : ℕ) :
iteratedFDerivWithin 𝕜 n f₁ s x = iteratedFDerivWithin 𝕜 n f s x :=
(hs.eventuallyEq.filter_mono inf_le_right).iteratedFDerivWithin_eq (hs hx) _
/-- If two functions coincide on a set `s`, then their iterated differentials within this set
coincide. See also `Filter.EventuallyEq.iteratedFDerivWithin_eq` and
`Filter.EventuallyEq.iteratedFDerivWithin`. -/
protected theorem Set.EqOn.iteratedFDerivWithin (hs : EqOn f₁ f s) (n : ℕ) :
EqOn (iteratedFDerivWithin 𝕜 n f₁ s) (iteratedFDerivWithin 𝕜 n f s) s := fun _x hx =>
iteratedFDerivWithin_congr hs hx n
theorem iteratedFDerivWithin_eventually_congr_set' (y : E) (h : s =ᶠ[𝓝[{y}ᶜ] x] t) (n : ℕ) :
iteratedFDerivWithin 𝕜 n f s =ᶠ[𝓝 x] iteratedFDerivWithin 𝕜 n f t := by
induction n generalizing x with
| zero => rfl
| succ n ihn =>
refine (eventually_nhds_nhdsWithin.2 h).mono fun y hy => ?_
simp only [iteratedFDerivWithin_succ_eq_comp_left, (· ∘ ·)]
rw [(ihn hy).fderivWithin_eq_of_nhds, fderivWithin_congr_set' _ hy]
theorem iteratedFDerivWithin_eventually_congr_set (h : s =ᶠ[𝓝 x] t) (n : ℕ) :
iteratedFDerivWithin 𝕜 n f s =ᶠ[𝓝 x] iteratedFDerivWithin 𝕜 n f t :=
iteratedFDerivWithin_eventually_congr_set' x (h.filter_mono inf_le_left) n
/-- If two sets coincide in a punctured neighborhood of `x`,
then the corresponding iterated derivatives are equal.
Note that we also allow to puncture the neighborhood of `x` at `y`.
If `y ≠ x`, then this is a no-op. -/
theorem iteratedFDerivWithin_congr_set' {y} (h : s =ᶠ[𝓝[{y}ᶜ] x] t) (n : ℕ) :
iteratedFDerivWithin 𝕜 n f s x = iteratedFDerivWithin 𝕜 n f t x :=
(iteratedFDerivWithin_eventually_congr_set' y h n).self_of_nhds
@[simp]
theorem iteratedFDerivWithin_insert {n y} :
iteratedFDerivWithin 𝕜 n f (insert x s) y = iteratedFDerivWithin 𝕜 n f s y :=
iteratedFDerivWithin_congr_set' (y := x)
(eventually_mem_nhdsWithin.mono <| by intros; simp_all).set_eq _
theorem iteratedFDerivWithin_congr_set (h : s =ᶠ[𝓝 x] t) (n : ℕ) :
iteratedFDerivWithin 𝕜 n f s x = iteratedFDerivWithin 𝕜 n f t x :=
(iteratedFDerivWithin_eventually_congr_set h n).self_of_nhds
@[simp]
theorem ftaylorSeriesWithin_insert :
ftaylorSeriesWithin 𝕜 f (insert x s) = ftaylorSeriesWithin 𝕜 f s := by
ext y n : 2
apply iteratedFDerivWithin_insert
/-- The iterated differential within a set `s` at a point `x` is not modified if one intersects
`s` with a neighborhood of `x` within `s`. -/
theorem iteratedFDerivWithin_inter' {n : ℕ} (hu : u ∈ 𝓝[s] x) :
iteratedFDerivWithin 𝕜 n f (s ∩ u) x = iteratedFDerivWithin 𝕜 n f s x :=
iteratedFDerivWithin_congr_set (nhdsWithin_eq_iff_eventuallyEq.1 <| nhdsWithin_inter_of_mem' hu) _
/-- The iterated differential within a set `s` at a point `x` is not modified if one intersects
`s` with a neighborhood of `x`. -/
theorem iteratedFDerivWithin_inter {n : ℕ} (hu : u ∈ 𝓝 x) :
iteratedFDerivWithin 𝕜 n f (s ∩ u) x = iteratedFDerivWithin 𝕜 n f s x :=
iteratedFDerivWithin_inter' (mem_nhdsWithin_of_mem_nhds hu)
/-- The iterated differential within a set `s` at a point `x` is not modified if one intersects
`s` with an open set containing `x`. -/
theorem iteratedFDerivWithin_inter_open {n : ℕ} (hu : IsOpen u) (hx : x ∈ u) :
iteratedFDerivWithin 𝕜 n f (s ∩ u) x = iteratedFDerivWithin 𝕜 n f s x :=
iteratedFDerivWithin_inter (hu.mem_nhds hx)
/-- 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)
(hx : x ∈ s) : p x m = iteratedFDerivWithin 𝕜 m f s x := by
induction m generalizing x with
| zero => rw [h.zero_eq' hx, iteratedFDerivWithin_zero_eq_comp, comp_apply]
| succ m IH =>
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 :=
(h.fderivWithin m A x hx).congr (fun y hy => (IH (le_of_lt A) hy).symm)
(IH (le_of_lt A) hx).symm
rw [iteratedFDerivWithin_succ_eq_comp_left, Function.comp_apply, this.fderivWithin (hs x hx)]
exact (ContinuousMultilinearMap.uncurry_curryLeft _).symm
/-- The iterated derivative commutes with shifting the function by a constant on the left. -/
lemma iteratedFDerivWithin_comp_add_left' (n : ℕ) (a : E) :
iteratedFDerivWithin 𝕜 n (fun z ↦ f (a + z)) s =
fun x ↦ iteratedFDerivWithin 𝕜 n f (a +ᵥ s) (a + x) := by
induction n with
| zero => simp [iteratedFDerivWithin]
| succ n IH =>
ext v
rw [iteratedFDerivWithin_succ_eq_comp_left, iteratedFDerivWithin_succ_eq_comp_left]
simp only [Nat.succ_eq_add_one, IH, comp_apply, continuousMultilinearCurryLeftEquiv_symm_apply]
congr 2
rw [fderivWithin_comp_add_left]
/-- The iterated derivative commutes with shifting the function by a constant on the left. -/
lemma iteratedFDerivWithin_comp_add_left (n : ℕ) (a : E) (x : E) :
iteratedFDerivWithin 𝕜 n (fun z ↦ f (a + z)) s x =
iteratedFDerivWithin 𝕜 n f (a +ᵥ s) (a + x) := by
simp [iteratedFDerivWithin_comp_add_left']
/-- The iterated derivative commutes with shifting the function by a constant on the right. -/
lemma iteratedFDerivWithin_comp_add_right' (n : ℕ) (a : E) :
iteratedFDerivWithin 𝕜 n (fun z ↦ f (z + a)) s =
fun x ↦ iteratedFDerivWithin 𝕜 n f (a +ᵥ s) (x + a) := by
simpa [add_comm a] using iteratedFDerivWithin_comp_add_left' n a
/-- The iterated derivative commutes with shifting the function by a constant on the right. -/
lemma iteratedFDerivWithin_comp_add_right (n : ℕ) (a : E) (x : E) :
iteratedFDerivWithin 𝕜 n (fun z ↦ f (z + a)) s x =
iteratedFDerivWithin 𝕜 n f (a +ᵥ s) (x + a) := by
simp [iteratedFDerivWithin_comp_add_right']
/-- The iterated derivative commutes with subtracting a constant. -/
lemma iteratedFDerivWithin_comp_sub' (n : ℕ) (a : E) :
iteratedFDerivWithin 𝕜 n (fun z ↦ f (z - a)) s =
fun x ↦ iteratedFDerivWithin 𝕜 n f (-a +ᵥ s) (x - a) := by
simpa [sub_eq_add_neg] using iteratedFDerivWithin_comp_add_right' n (-a)
/-- The iterated derivative commutes with subtracting a constant. -/
lemma iteratedFDerivWithin_comp_sub (n : ℕ) (a : E) :
iteratedFDerivWithin 𝕜 n (fun z ↦ f (z - a)) s x =
iteratedFDerivWithin 𝕜 n f (-a +ᵥ s) (x - a) := by
simp [iteratedFDerivWithin_comp_sub']
/-! ### Functions with a Taylor series on the whole space -/
/-- `HasFTaylorSeriesUpTo n f p` registers the fact that `p 0 = f` and `p (m+1)` is a
derivative of `p m` for `m < n`, and is continuous for `m ≤ n`. This is a predicate analogous to
`HasFDerivAt` but for higher-order derivatives.
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 : 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
theorem HasFTaylorSeriesUpTo.zero_eq' (h : HasFTaylorSeriesUpTo n f p) (x : E) :
p x 0 = (continuousMultilinearCurryFin0 𝕜 E F).symm (f x) := by
rw [← h.zero_eq x]
exact (p x 0).uncurry0_curry0.symm
theorem hasFTaylorSeriesUpToOn_univ_iff :
HasFTaylorSeriesUpToOn n f p univ ↔ HasFTaylorSeriesUpTo n f p := by
constructor
· intro H
constructor
· exact fun x => H.zero_eq x (mem_univ x)
· intro m hm x
rw [← hasFDerivWithinAt_univ]
exact H.fderivWithin m hm x (mem_univ x)
· intro m hm
rw [← continuousOn_univ]
exact H.cont m hm
· intro H
constructor
· exact fun x _ => H.zero_eq x
· intro m hm x _
rw [hasFDerivWithinAt_univ]
exact H.fderiv m hm x
· intro m hm
rw [continuousOn_univ]
exact H.cont m hm
theorem HasFTaylorSeriesUpTo.hasFTaylorSeriesUpToOn (h : HasFTaylorSeriesUpTo n f p) (s : Set E) :
HasFTaylorSeriesUpToOn n f p s :=
(hasFTaylorSeriesUpToOn_univ_iff.2 h).mono (subset_univ _)
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
theorem HasFTaylorSeriesUpTo.continuous (h : HasFTaylorSeriesUpTo n f p) : Continuous f := by
rw [← hasFTaylorSeriesUpToOn_univ_iff] at h
rw [← continuousOn_univ]
exact h.continuousOn
theorem hasFTaylorSeriesUpTo_zero_iff :
HasFTaylorSeriesUpTo 0 f p ↔ Continuous f ∧ ∀ x, (p x 0).curry0 = f x := by
simp [hasFTaylorSeriesUpToOn_univ_iff.symm, continuousOn_univ,
hasFTaylorSeriesUpToOn_zero_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' (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' 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
series is a derivative of `f`. -/
theorem HasFTaylorSeriesUpTo.hasFDerivAt (h : HasFTaylorSeriesUpTo n f p) (hn : 1 ≤ n) (x : E) :
HasFDerivAt f (continuousMultilinearCurryFin1 𝕜 E F (p x 1)) x := by
rw [← hasFDerivWithinAt_univ]
exact (hasFTaylorSeriesUpToOn_univ_iff.2 h).hasFDerivWithinAt hn (mem_univ _)
theorem HasFTaylorSeriesUpTo.differentiable (h : HasFTaylorSeriesUpTo n f p) (hn : 1 ≤ n) :
Differentiable 𝕜 f := fun x => (h.hasFDerivAt hn x).differentiableAt
/-- `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_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_nat_iff_right, ← hasFTaylorSeriesUpToOn_univ_iff, mem_univ,
forall_true_left, hasFDerivWithinAt_univ]
/-! ### Iterated derivative -/
variable (𝕜)
/-- The `n`-th derivative of a function, as a multilinear map, defined inductively. -/
noncomputable def iteratedFDeriv (n : ℕ) (f : E → F) : E → E[×n]→L[𝕜] F :=
Nat.recOn n (fun x => ContinuousMultilinearMap.uncurry0 𝕜 E (f x)) fun _ rec x =>
ContinuousLinearMap.uncurryLeft (fderiv 𝕜 rec x)
/-- Formal Taylor series associated to a function. -/
def ftaylorSeries (f : E → F) (x : E) : FormalMultilinearSeries 𝕜 E F := fun n =>
iteratedFDeriv 𝕜 n f x
variable {𝕜}
@[simp]
theorem iteratedFDeriv_zero_apply (m : Fin 0 → E) :
(iteratedFDeriv 𝕜 0 f x : (Fin 0 → E) → F) m = f x :=
rfl
theorem iteratedFDeriv_zero_eq_comp :
iteratedFDeriv 𝕜 0 f = (continuousMultilinearCurryFin0 𝕜 E F).symm ∘ f :=
rfl
@[simp]
theorem norm_iteratedFDeriv_zero : ‖iteratedFDeriv 𝕜 0 f x‖ = ‖f x‖ := by
rw [iteratedFDeriv_zero_eq_comp, comp_apply, LinearIsometryEquiv.norm_map]
theorem iteratedFDerivWithin_zero_eq : iteratedFDerivWithin 𝕜 0 f s = iteratedFDeriv 𝕜 0 f := rfl
theorem iteratedFDeriv_succ_apply_left {n : ℕ} (m : Fin (n + 1) → E) :
(iteratedFDeriv 𝕜 (n + 1) f x : (Fin (n + 1) → E) → F) m =
(fderiv 𝕜 (iteratedFDeriv 𝕜 n f) x : E → E[×n]→L[𝕜] F) (m 0) (tail m) :=
rfl
/-- Writing explicitly the `n+1`-th derivative as the composition of a currying linear equiv,
and the derivative of the `n`-th derivative. -/
theorem iteratedFDeriv_succ_eq_comp_left {n : ℕ} :
iteratedFDeriv 𝕜 (n + 1) f =
(continuousMultilinearCurryLeftEquiv 𝕜 (fun _ : Fin (n + 1) => E) F).symm ∘
fderiv 𝕜 (iteratedFDeriv 𝕜 n f) :=
rfl
/-- Writing explicitly the derivative of the `n`-th derivative as the composition of a currying
linear equiv, and the `n + 1`-th derivative. -/
theorem fderiv_iteratedFDeriv {n : ℕ} :
fderiv 𝕜 (iteratedFDeriv 𝕜 n f) =
continuousMultilinearCurryLeftEquiv 𝕜 (fun _ : Fin (n + 1) => E) F ∘
iteratedFDeriv 𝕜 (n + 1) f :=
rfl
theorem tsupport_iteratedFDeriv_subset (n : ℕ) : tsupport (iteratedFDeriv 𝕜 n f) ⊆ tsupport f := by
induction n with
| zero =>
rw [iteratedFDeriv_zero_eq_comp]
exact closure_minimal ((support_comp_subset (LinearIsometryEquiv.map_zero _) _).trans
subset_closure) isClosed_closure
| succ n IH =>
rw [iteratedFDeriv_succ_eq_comp_left]
exact closure_minimal ((support_comp_subset (LinearIsometryEquiv.map_zero _) _).trans
((support_fderiv_subset 𝕜).trans IH)) isClosed_closure
theorem support_iteratedFDeriv_subset (n : ℕ) : support (iteratedFDeriv 𝕜 n f) ⊆ tsupport f :=
subset_closure.trans (tsupport_iteratedFDeriv_subset n)
theorem HasCompactSupport.iteratedFDeriv (hf : HasCompactSupport f) (n : ℕ) :
HasCompactSupport (iteratedFDeriv 𝕜 n f) :=
hf.of_isClosed_subset isClosed_closure (tsupport_iteratedFDeriv_subset n)
theorem norm_fderiv_iteratedFDeriv {n : ℕ} :
‖fderiv 𝕜 (iteratedFDeriv 𝕜 n f) x‖ = ‖iteratedFDeriv 𝕜 (n + 1) f x‖ := by
rw [iteratedFDeriv_succ_eq_comp_left, comp_apply, LinearIsometryEquiv.norm_map]
theorem iteratedFDerivWithin_univ {n : ℕ} :
iteratedFDerivWithin 𝕜 n f univ = iteratedFDeriv 𝕜 n f := by
induction n with
| zero => ext x; simp
| succ n IH =>
ext x m
rw [iteratedFDeriv_succ_apply_left, iteratedFDerivWithin_succ_apply_left, IH, fderivWithin_univ]
variable (𝕜) in
/-- If two functions agree in a neighborhood, then so do their iterated derivatives. -/
theorem Filter.EventuallyEq.iteratedFDeriv
{f₁ f₂ : E → F} {x : E} (h : f₁ =ᶠ[𝓝 x] f₂) (n : ℕ) :
iteratedFDeriv 𝕜 n f₁ =ᶠ[𝓝 x] iteratedFDeriv 𝕜 n f₂ := by
simp_all [← nhdsWithin_univ, ← iteratedFDerivWithin_univ,
Filter.EventuallyEq.iteratedFDerivWithin]
theorem HasFTaylorSeriesUpTo.eq_iteratedFDeriv
(h : HasFTaylorSeriesUpTo n f p) {m : ℕ} (hmn : m ≤ n) (x : E) :
p x m = iteratedFDeriv 𝕜 m f x := by
rw [← iteratedFDerivWithin_univ]
rw [← hasFTaylorSeriesUpToOn_univ_iff] at h
exact h.eq_iteratedFDerivWithin_of_uniqueDiffOn hmn uniqueDiffOn_univ (mem_univ _)
/-- In an open set, the iterated derivative within this set coincides with the global iterated
derivative. -/
theorem iteratedFDerivWithin_of_isOpen (n : ℕ) (hs : IsOpen s) :
EqOn (iteratedFDerivWithin 𝕜 n f s) (iteratedFDeriv 𝕜 n f) s := by
induction n with
| zero =>
intro x _
ext1
simp only [iteratedFDerivWithin_zero_apply, iteratedFDeriv_zero_apply]
| succ n IH =>
intro x hx
rw [iteratedFDeriv_succ_eq_comp_left, iteratedFDerivWithin_succ_eq_comp_left]
dsimp
congr 1
rw [fderivWithin_of_isOpen hs hx]
apply Filter.EventuallyEq.fderiv_eq
filter_upwards [hs.mem_nhds hx]
exact IH
theorem ftaylorSeriesWithin_univ : ftaylorSeriesWithin 𝕜 f univ = ftaylorSeries 𝕜 f := by
ext1 x; ext1 n
change iteratedFDerivWithin 𝕜 n f univ x = iteratedFDeriv 𝕜 n f x
rw [iteratedFDerivWithin_univ]
theorem iteratedFDeriv_succ_apply_right {n : ℕ} (m : Fin (n + 1) → E) :
(iteratedFDeriv 𝕜 (n + 1) f x : (Fin (n + 1) → E) → F) m =
iteratedFDeriv 𝕜 n (fun y => fderiv 𝕜 f y) x (init m) (m (last n)) := by
rw [← iteratedFDerivWithin_univ, ← iteratedFDerivWithin_univ, ← fderivWithin_univ]
exact iteratedFDerivWithin_succ_apply_right uniqueDiffOn_univ (mem_univ _) _
/-- Writing explicitly the `n+1`-th derivative as the composition of a currying linear equiv,
and the `n`-th derivative of the derivative. -/
theorem iteratedFDeriv_succ_eq_comp_right {n : ℕ} :
iteratedFDeriv 𝕜 (n + 1) f x =
((continuousMultilinearCurryRightEquiv' 𝕜 n E F).symm ∘
iteratedFDeriv 𝕜 n fun y => fderiv 𝕜 f y) x := by
ext m
rw [iteratedFDeriv_succ_apply_right, comp_apply, continuousMultilinearCurryRightEquiv_symm_apply']
theorem norm_iteratedFDeriv_fderiv {n : ℕ} :
‖iteratedFDeriv 𝕜 n (fderiv 𝕜 f) x‖ = ‖iteratedFDeriv 𝕜 (n + 1) f x‖ := by
rw [iteratedFDeriv_succ_eq_comp_right, comp_apply, LinearIsometryEquiv.norm_map]
@[simp]
theorem iteratedFDeriv_one_apply (m : Fin 1 → E) :
iteratedFDeriv 𝕜 1 f x m = fderiv 𝕜 f x (m 0) := by
rw [iteratedFDeriv_succ_apply_right, iteratedFDeriv_zero_apply, last_zero]
lemma iteratedFDeriv_two_apply (f : E → F) (z : E) (m : Fin 2 → E) :
iteratedFDeriv 𝕜 2 f z m = fderiv 𝕜 (fderiv 𝕜 f) z (m 0) (m 1) := by
simp [iteratedFDeriv_succ_apply_right, init]
/-- The iterated derivative commutes with shifting the function by a constant on the left. -/
lemma iteratedFDeriv_comp_add_left' (n : ℕ) (a : E) :
iteratedFDeriv 𝕜 n (fun z ↦ f (a + z)) = fun x ↦ iteratedFDeriv 𝕜 n f (a + x) := by
simpa [← iteratedFDerivWithin_univ] using iteratedFDerivWithin_comp_add_left' n a (s := univ)
/-- The iterated derivative commutes with shifting the function by a constant on the left. -/
lemma iteratedFDeriv_comp_add_left (n : ℕ) (a : E) (x : E) :
iteratedFDeriv 𝕜 n (fun z ↦ f (a + z)) x = iteratedFDeriv 𝕜 n f (a + x) := by
simp [iteratedFDeriv_comp_add_left']
/-- The iterated derivative commutes with shifting the function by a constant on the right. -/
lemma iteratedFDeriv_comp_add_right' (n : ℕ) (a : E) :
iteratedFDeriv 𝕜 n (fun z ↦ f (z + a)) = fun x ↦ iteratedFDeriv 𝕜 n f (x + a) := by
simpa [add_comm a] using iteratedFDeriv_comp_add_left' n a
/-- The iterated derivative commutes with shifting the function by a constant on the right. -/
lemma iteratedFDeriv_comp_add_right (n : ℕ) (a : E) (x : E) :
iteratedFDeriv 𝕜 n (fun z ↦ f (z + a)) x = iteratedFDeriv 𝕜 n f (x + a) := by
simp [iteratedFDeriv_comp_add_right']
/-- The iterated derivative commutes with subtracting a constant. -/
lemma iteratedFDeriv_comp_sub' (n : ℕ) (a : E) :
iteratedFDeriv 𝕜 n (fun z ↦ f (z - a)) = fun x ↦ iteratedFDeriv 𝕜 n f (x - a) := by
simpa [sub_eq_add_neg] using iteratedFDeriv_comp_add_right' n (-a)
/-- The iterated derivative commutes with subtracting a constant. -/
lemma iteratedFDeriv_comp_sub (n : ℕ) (a : E) (x : E) :
iteratedFDeriv 𝕜 n (fun z ↦ f (z - a)) x = iteratedFDeriv 𝕜 n f (x - a) := by
simp [iteratedFDeriv_comp_sub'] |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/ContDiff/RCLike.lean | import Mathlib.Analysis.Calculus.ContDiff.Defs
import Mathlib.Analysis.Calculus.MeanValue
/-!
# Higher differentiability over `ℝ` or `ℂ`
-/
noncomputable section
open Set Fin Filter Function
open scoped NNReal Topology
section Real
/-!
### Results over `ℝ` or `ℂ`
The results in this section rely on the Mean Value Theorem, and therefore hold only over `ℝ` (and
its extension fields such as `ℂ`).
-/
variable {n : WithTop ℕ∞} {𝕂 : Type*} [RCLike 𝕂] {E' : Type*} [NormedAddCommGroup E']
[NormedSpace 𝕂 E'] {F' : Type*} [NormedAddCommGroup F'] [NormedSpace 𝕂 F']
/-- 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 {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) <|
(continuousMultilinearCurryFin1 𝕂 E' F').continuousAt.comp <| (hf.cont 1 hn).continuousAt hs
/-- If a function is `C^n` with `1 ≤ n` around a point, and its derivative at that point is given to
us as `f'`, then `f'` is also a strict derivative. -/
theorem ContDiffAt.hasStrictFDerivAt' {f : E' → F'} {f' : E' →L[𝕂] F'} {x : E'}
(hf : ContDiffAt 𝕂 n f x) (hf' : HasFDerivAt f f' x) (hn : 1 ≤ n) :
HasStrictFDerivAt f f' x := by
rcases hf.of_le hn 1 le_rfl with ⟨u, H, p, hp⟩
simp only [nhdsWithin_univ, mem_univ, insert_eq_of_mem] at H
have := hp.hasStrictFDerivAt le_rfl H
rwa [hf'.unique this.hasFDerivAt]
/-- If a function is `C^n` with `1 ≤ n` around a point, and its derivative at that point is given to
us as `f'`, then `f'` is also a strict derivative. -/
theorem ContDiffAt.hasStrictDerivAt' {f : 𝕂 → F'} {f' : F'} {x : 𝕂} (hf : ContDiffAt 𝕂 n f x)
(hf' : HasDerivAt f f' x) (hn : 1 ≤ n) : HasStrictDerivAt f f' x :=
hf.hasStrictFDerivAt' hf' hn
/-- If a function is `C^n` with `1 ≤ n` around a point, then the derivative of `f` at this point
is also a strict derivative. -/
theorem ContDiffAt.hasStrictFDerivAt {f : E' → F'} {x : E'} (hf : ContDiffAt 𝕂 n f x) (hn : 1 ≤ n) :
HasStrictFDerivAt f (fderiv 𝕂 f x) x :=
hf.hasStrictFDerivAt' (hf.differentiableAt hn).hasFDerivAt hn
/-- If a function is `C^n` with `1 ≤ n` around a point, then the derivative of `f` at this point
is also a strict derivative. -/
theorem ContDiffAt.hasStrictDerivAt {f : 𝕂 → F'} {x : 𝕂} (hf : ContDiffAt 𝕂 n f x) (hn : 1 ≤ n) :
HasStrictDerivAt f (deriv f x) x :=
(hf.hasStrictFDerivAt hn).hasStrictDerivAt
/-- If a function is `C^n` with `1 ≤ n`, then the derivative of `f` is also a strict derivative. -/
theorem ContDiff.hasStrictFDerivAt {f : E' → F'} {x : E'} (hf : ContDiff 𝕂 n f) (hn : 1 ≤ n) :
HasStrictFDerivAt f (fderiv 𝕂 f x) x :=
hf.contDiffAt.hasStrictFDerivAt hn
/-- If a function is `C^n` with `1 ≤ n`, then the derivative of `f` is also a strict derivative. -/
theorem ContDiff.hasStrictDerivAt {f : 𝕂 → F'} {x : 𝕂} (hf : ContDiff 𝕂 n f) (hn : 1 ≤ n) :
HasStrictDerivAt f (deriv f x) x :=
hf.contDiffAt.hasStrictDerivAt hn
/-- If `f` has a formal Taylor series `p` up to order `1` on `{x} ∪ s`, where `s` is a convex set,
and `‖p x 1‖₊ < K`, then `f` is `K`-Lipschitz in a neighborhood of `x` within `s`. -/
theorem HasFTaylorSeriesUpToOn.exists_lipschitzOnWith_of_nnnorm_lt {E F : Type*}
[NormedAddCommGroup E] [NormedSpace ℝ E] [NormedAddCommGroup F] [NormedSpace ℝ F] {f : E → F}
{p : E → FormalMultilinearSeries ℝ E F} {s : Set E} {x : E}
(hf : HasFTaylorSeriesUpToOn 1 f p (insert x s)) (hs : Convex ℝ s) (K : ℝ≥0)
(hK : ‖p x 1‖₊ < K) : ∃ t ∈ 𝓝[s] x, LipschitzOnWith K f t := by
set f' := fun y => continuousMultilinearCurryFin1 ℝ E F (p y 1)
have hder : ∀ y ∈ s, HasFDerivWithinAt f (f' y) s y := fun y hy =>
(hf.hasFDerivWithinAt le_rfl (subset_insert x s hy)).mono (subset_insert x s)
have hcont : ContinuousWithinAt f' s x :=
(continuousMultilinearCurryFin1 ℝ E F).continuousAt.comp_continuousWithinAt
((hf.cont _ le_rfl _ (mem_insert _ _)).mono (subset_insert x s))
replace hK : ‖f' x‖₊ < K := by simpa only [f', LinearIsometryEquiv.nnnorm_map]
exact
hs.exists_nhdsWithin_lipschitzOnWith_of_hasFDerivWithinAt_of_nnnorm_lt
(eventually_nhdsWithin_iff.2 <| Eventually.of_forall hder) hcont K hK
/-- If `f` has a formal Taylor series `p` up to order `1` on `{x} ∪ s`, where `s` is a convex set,
then `f` is Lipschitz in a neighborhood of `x` within `s`. -/
theorem HasFTaylorSeriesUpToOn.exists_lipschitzOnWith {E F : Type*} [NormedAddCommGroup E]
[NormedSpace ℝ E] [NormedAddCommGroup F] [NormedSpace ℝ F] {f : E → F}
{p : E → FormalMultilinearSeries ℝ E F} {s : Set E} {x : E}
(hf : HasFTaylorSeriesUpToOn 1 f p (insert x s)) (hs : Convex ℝ s) :
∃ K, ∃ t ∈ 𝓝[s] x, LipschitzOnWith K f t :=
(exists_gt _).imp <| hf.exists_lipschitzOnWith_of_nnnorm_lt hs
/-- If `f` is `C^1` within a convex set `s` at `x`, then it is Lipschitz on a neighborhood of `x`
within `s`. -/
theorem ContDiffWithinAt.exists_lipschitzOnWith {E F : Type*} [NormedAddCommGroup E]
[NormedSpace ℝ E] [NormedAddCommGroup F] [NormedSpace ℝ F] {f : E → F} {s : Set E} {x : E}
(hf : ContDiffWithinAt ℝ 1 f s x) (hs : Convex ℝ s) :
∃ K : ℝ≥0, ∃ t ∈ 𝓝[s] x, LipschitzOnWith K f t := by
rcases hf 1 le_rfl with ⟨t, hst, p, hp⟩
rcases Metric.mem_nhdsWithin_iff.mp hst with ⟨ε, ε0, hε⟩
replace hp : HasFTaylorSeriesUpToOn 1 f p (Metric.ball x ε ∩ insert x s) := hp.mono hε
clear hst hε t
rw [← insert_eq_of_mem (Metric.mem_ball_self ε0), ← insert_inter_distrib] at hp
rcases hp.exists_lipschitzOnWith ((convex_ball _ _).inter hs) with ⟨K, t, hst, hft⟩
rw [inter_comm, ← nhdsWithin_restrict' _ (Metric.ball_mem_nhds _ ε0)] at hst
exact ⟨K, t, hst, hft⟩
/-- If `f` is `C^1` at `x` and `K > ‖fderiv 𝕂 f x‖`, then `f` is `K`-Lipschitz in a neighborhood of
`x`. -/
theorem ContDiffAt.exists_lipschitzOnWith_of_nnnorm_lt {f : E' → F'} {x : E'}
(hf : ContDiffAt 𝕂 1 f x) (K : ℝ≥0) (hK : ‖fderiv 𝕂 f x‖₊ < K) :
∃ t ∈ 𝓝 x, LipschitzOnWith K f t :=
(hf.hasStrictFDerivAt le_rfl).exists_lipschitzOnWith_of_nnnorm_lt K hK
/-- If `f` is `C^1` at `x`, then `f` is Lipschitz in a neighborhood of `x`. -/
theorem ContDiffAt.exists_lipschitzOnWith {f : E' → F'} {x : E'} (hf : ContDiffAt 𝕂 1 f x) :
∃ K, ∃ t ∈ 𝓝 x, LipschitzOnWith K f t :=
(hf.hasStrictFDerivAt le_rfl).exists_lipschitzOnWith
/-- If `f` is `C^1`, it is locally Lipschitz. -/
lemma ContDiff.locallyLipschitz {f : E' → F'} (hf : ContDiff 𝕂 1 f) : LocallyLipschitz f := by
intro x
rcases hf.contDiffAt.exists_lipschitzOnWith with ⟨K, t, ht, hf⟩
use K, t
/-- A `C^1` function with compact support is Lipschitz. -/
theorem ContDiff.lipschitzWith_of_hasCompactSupport {f : E' → F'}
(hf : HasCompactSupport f) (h'f : ContDiff 𝕂 n f) (hn : 1 ≤ n) :
∃ C, LipschitzWith C f := by
obtain ⟨C, hC⟩ := (hf.fderiv 𝕂).exists_bound_of_continuous (h'f.continuous_fderiv hn)
refine ⟨⟨max C 0, le_max_right _ _⟩, ?_⟩
apply lipschitzWith_of_nnnorm_fderiv_le (h'f.differentiable hn) (fun x ↦ ?_)
simp [← NNReal.coe_le_coe, hC x]
end Real |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/ContDiff/RestrictScalars.lean | import Mathlib.Analysis.Calculus.ContDiff.Defs
import Mathlib.Analysis.Calculus.FDeriv.RestrictScalars
/-!
### Restricting Scalars in Iterated Fréchet Derivatives
This file establishes standard theorems on restriction of scalars for iterated Fréchet derivatives,
comparing iterated derivatives with respect to a field `𝕜'` to iterated derivatives with respect to
a subfield `𝕜 ⊆ 𝕜'`. The results are analogous to those found in
`Mathlib.Analysis.Calculus.FDeriv.RestrictScalars`.
-/
variable
{𝕜 𝕜' : Type*} [NontriviallyNormedField 𝕜] [NontriviallyNormedField 𝕜'] [NormedAlgebra 𝕜 𝕜']
{E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E] [NormedSpace 𝕜' E] [IsScalarTower 𝕜 𝕜' E]
{F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F] [NormedSpace 𝕜' F] [IsScalarTower 𝕜 𝕜' F]
{x : E} {f : E → F} {n : ℕ} {s : Set E}
open ContinuousMultilinearMap Topology
/-- Derivation rule for compositions of scalar restriction with continuous multilinear maps. -/
lemma fderivWithin_restrictScalars_comp
{φ : E → (ContinuousMultilinearMap 𝕜' (fun _ : Fin n ↦ E) F)}
(h : DifferentiableWithinAt 𝕜' φ s x) (hs : UniqueDiffWithinAt 𝕜 s x) :
fderivWithin 𝕜 ((restrictScalars 𝕜) ∘ φ) s x
= (restrictScalars 𝕜) ∘ ((fderivWithin 𝕜' φ s x).restrictScalars 𝕜) := by
simp only [← restrictScalarsLinear_apply]
rw [fderiv_comp_fderivWithin _ (by fun_prop) (h.restrictScalars 𝕜) hs, ContinuousLinearMap.fderiv]
ext a b
simp [h.restrictScalars_fderivWithin 𝕜 hs]
/--
If `f` is `n` times continuously differentiable at `x` within `s`, then the `n`th iterated Fréchet
derivative within `s` with respect to `𝕜` equals scalar restriction of the `n`th iterated Fréchet
derivative within `s` with respect to `𝕜'`.
-/
theorem ContDiffWithinAt.restrictScalars_iteratedFDerivWithin_eventuallyEq
(h : ContDiffWithinAt 𝕜' n f s x) (hs : UniqueDiffOn 𝕜 s) (hx : x ∈ s) :
(restrictScalars 𝕜) ∘ (iteratedFDerivWithin 𝕜' n f s)
=ᶠ[𝓝[s] x] iteratedFDerivWithin 𝕜 n f s := by
induction n with
| zero =>
filter_upwards with a
ext m
simp
| succ n hn =>
have t₀ := h.of_le (Nat.cast_le.mpr (n.le_add_right 1))
have t₁ : ∀ᶠ (y : E) in 𝓝[s] x, ContDiffWithinAt 𝕜' (↑(n + 1)) f s y := by
nth_rw 2 [← s.insert_eq_of_mem hx]
apply h.eventually (by simp)
filter_upwards [eventually_eventually_nhdsWithin.2 (hn t₀), t₁,
eventually_mem_nhdsWithin (a := x) (s := s)] with a h₁a h₃a h₄a
rw [← Filter.EventuallyEq] at h₁a
ext m
simp only [Function.comp_apply, coe_restrictScalars, iteratedFDerivWithin_succ_apply_left]
rw [← (h₁a.fderivWithin' (by tauto)).eq_of_nhdsWithin h₄a,
fderivWithin_restrictScalars_comp]
· simp
· apply h₃a.differentiableWithinAt_iteratedFDerivWithin
· rw [Nat.cast_lt]
simp
· have : UniqueDiffOn 𝕜' s := hs.mono_field
simpa [s.insert_eq_of_mem h₄a]
apply hs a h₄a
/--
If `f` is `n` times continuously differentiable at `x`, then the `n`th iterated Fréchet derivative
with respect to `𝕜` equals scalar restriction of the `n`th iterated Fréchet derivative with respect
to `𝕜'`.
-/
theorem ContDiffAt.restrictScalars_iteratedFDeriv_eventuallyEq (h : ContDiffAt 𝕜' n f x) :
(restrictScalars 𝕜) ∘ (iteratedFDeriv 𝕜' n f) =ᶠ[𝓝 x] iteratedFDeriv 𝕜 n f := by
have h' : ContDiffWithinAt 𝕜' n f Set.univ x := h
convert (h'.restrictScalars_iteratedFDerivWithin_eventuallyEq _ trivial)
<;> simp [iteratedFDerivWithin_univ.symm, uniqueDiffOn_univ]
/--
If `f` is `n` times continuously differentiable at `x`, then the `n`th iterated Fréchet derivative
with respect to `𝕜` equals scalar restriction of the `n`th iterated Fréchet derivative with respect
to `𝕜'`.
-/
theorem ContDiffAt.restrictScalars_iteratedFDeriv (h : ContDiffAt 𝕜' n f x) :
((restrictScalars 𝕜) ∘ iteratedFDeriv 𝕜' n f) x = iteratedFDeriv 𝕜 n f x :=
h.restrictScalars_iteratedFDeriv_eventuallyEq.eq_of_nhds |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/ContDiff/FaaDiBruno.lean | import Mathlib.Data.Finite.Card
import Mathlib.Analysis.Analytic.Within
import Mathlib.Analysis.Calculus.FDeriv.Analytic
import Mathlib.Analysis.Calculus.ContDiff.FTaylorSeries
/-!
# Faa di Bruno formula
The Faa di Bruno formula gives the iterated derivative of `g ∘ f` in terms of those of
`g` and `f`. It is expressed in terms of partitions `I` of `{0, ..., n-1}`. For such a
partition, denote by `k` its number of parts, write the parts as `I₀, ..., Iₖ₋₁` ordered so
that `max I₀ < ... < max Iₖ₋₁`, and let `iₘ` be the number of elements of `Iₘ`. Then
`D^n (g ∘ f) (x) (v₀, ..., vₙ₋₁) =
∑_{I partition of {0, ..., n-1}}
D^k g (f x) (D^{i₀} f (x) (v_{I₀}), ..., D^{iₖ₋₁} f (x) (v_{Iₖ₋₁}))`
where by `v_{Iₘ}` we mean the vectors `vᵢ` with indices in `Iₘ`, i.e., the composition of `v`
with the increasing embedding of `Fin iₘ` into `Fin n` with range `Iₘ`.
For instance, for `n = 2`, there are 2 partitions of `{0, 1}`, given by `{0}, {1}` and `{0, 1}`,
and therefore
`D^2(g ∘ f) (x) (v₀, v₁) = D^2 g (f x) (Df (x) v₀, Df (x) v₁) + Dg (f x) (D^2f (x) (v₀, v₁))`.
The formula is straightforward to prove by induction, as differentiating
`D^k g (f x) (D^{i₀} f (x) (v_{I₀}), ..., D^{iₖ₋₁} f (x) (v_{Iₖ₋₁}))` gives a sum
with `k + 1` terms where one differentiates either `D^k g (f x)`, or one of the `D^{iₘ} f (x)`,
amounting to adding to the partition `I` either a new atom `{-1}` to its left, or extending `Iₘ`
by adding `-1` to it. In this way, one obtains bijectively all partitions of `{-1, ..., n}`,
and the proof can go on (up to relabelling).
The main difficulty is to write things down in a precise language, namely to write
`D^k g (f x) (D^{i₀} f (x) (v_{I₀}), ..., D^{iₖ₋₁} f (x) (v_{Iₖ₋₁}))` as a continuous multilinear
map of the `vᵢ`. For this, instead of working with partitions of `{0, ..., n-1}` and ordering their
parts, we work with partitions in which the ordering is part of the data -- this is equivalent,
but much more convenient to implement. We call these `OrderedFinpartition n`.
Note that the implementation of `OrderedFinpartition` is very specific to the Faa di Bruno formula:
as testified by the formula above, what matters is really the embedding of the parts in `Fin n`,
and moreover the parts have to be ordered by `max I₀ < ... < max Iₖ₋₁` for the formula to hold
in the general case where the iterated differential might not be symmetric. The defeqs with respect
to `Fin.cons` are also important when doing the induction. For this reason, we do not expect this
class to be useful beyond the Faa di Bruno formula, which is why it is in this file instead
of a dedicated file in the `Combinatorics` folder.
## Main results
Given `c : OrderedFinpartition n` and two formal multilinear series `q` and `p`, we
define `c.compAlongOrderedFinpartition q p` as an `n`-multilinear map given by the formula above,
i.e., `(v₁, ..., vₙ) ↦ qₖ (p_{i₁} (v_{I₁}), ..., p_{iₖ} (v_{Iₖ}))`.
Then, we define `q.taylorComp p` as a formal multilinear series whose `n`-th term is
the sum of `c.compAlongOrderedFinpartition q p` over all ordered finpartitions of size `n`.
Finally, we prove in `HasFTaylorSeriesUptoOn.comp` that, 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`.
## Implementation
A first technical difficulty is to implement the extension process of `OrderedFinpartition`
corresponding to adding a new atom, or appending an atom to an existing part, and defining the
associated increasing parameterizations that show up in the definition
of `compAlongOrderedFinpartition`.
Then, one has to show that the ordered finpartitions thus
obtained give exactly all ordered finpartitions of order `n+1`. For this, we define the inverse
process (shrinking a finpartition of `n+1` by erasing `0`, either as an atom or from the part
that contains it), and we show that these processes are inverse to each other, yielding an
equivalence between `(c : OrderedFinpartition n) × Option (Fin c.length)`
and `OrderedFinpartition (n + 1)`. This equivalence shows up prominently in the inductive proof
of Faa di Bruno formula to identify the sums that show up.
-/
noncomputable section
open Set Fin Filter Function
variable {𝕜 : Type*} [NontriviallyNormedField 𝕜]
{E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E]
{F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F]
{G : Type*} [NormedAddCommGroup G] [NormedSpace 𝕜 G]
{s : Set E} {t : Set F}
{q : F → FormalMultilinearSeries 𝕜 F G} {p : E → FormalMultilinearSeries 𝕜 E F}
/-- A partition of `Fin n` into finitely many nonempty subsets, given by the increasing
parameterization of these subsets. We order the subsets by increasing greatest element.
This definition is tailored-made for the Faa di Bruno formula, and probably not useful elsewhere,
because of the specific parameterization by `Fin n` and the peculiar ordering. -/
@[ext]
structure OrderedFinpartition (n : ℕ) where
/-- The number of parts in the partition -/
length : ℕ
/-- The size of each part -/
partSize : Fin length → ℕ
partSize_pos : ∀ m, 0 < partSize m
/-- The increasing parameterization of each part -/
emb : ∀ m, (Fin (partSize m)) → Fin n
emb_strictMono : ∀ m, StrictMono (emb m)
/-- The parts are ordered by increasing greatest element. -/
parts_strictMono :
StrictMono fun m ↦ emb m ⟨partSize m - 1, Nat.sub_one_lt_of_lt (partSize_pos m)⟩
/-- The parts are disjoint -/
disjoint : PairwiseDisjoint univ fun m ↦ range (emb m)
/-- The parts cover everything -/
cover x : ∃ m, x ∈ range (emb m)
deriving DecidableEq
namespace OrderedFinpartition
/-! ### Basic API for ordered finpartitions -/
/-- The ordered finpartition of `Fin n` into singletons. -/
@[simps -fullyApplied]
def atomic (n : ℕ) : OrderedFinpartition n where
length := n
partSize _ := 1
partSize_pos _ := _root_.zero_lt_one
emb m _ := m
emb_strictMono _ := Subsingleton.strictMono _
parts_strictMono := strictMono_id
disjoint _ _ _ _ h := by simpa using h
cover m := by simp
variable {n : ℕ} (c : OrderedFinpartition n)
instance : Inhabited (OrderedFinpartition n) := ⟨atomic n⟩
@[simp]
theorem default_eq : (default : OrderedFinpartition n) = atomic n := rfl
lemma length_le : c.length ≤ n := by
simpa only [Fintype.card_fin] using Fintype.card_le_of_injective _ c.parts_strictMono.injective
lemma partSize_le (m : Fin c.length) : c.partSize m ≤ n := by
simpa only [Fintype.card_fin] using Fintype.card_le_of_injective _ (c.emb_strictMono m).injective
/-- Embedding of ordered finpartitions in a sigma type. The sigma type on the right is quite big,
but this is enough to get finiteness of ordered finpartitions. -/
def embSigma (n : ℕ) : OrderedFinpartition n →
(Σ (l : Fin (n + 1)), Σ (p : Fin l → Fin (n + 1)), Π (i : Fin l), (Fin (p i) → Fin n)) :=
fun c ↦ ⟨⟨c.length, Order.lt_add_one_iff.mpr c.length_le⟩,
fun m ↦ ⟨c.partSize m, Order.lt_add_one_iff.mpr (c.partSize_le m)⟩, fun j ↦ c.emb j⟩
lemma injective_embSigma (n : ℕ) : Injective (embSigma n) := by
rintro ⟨plength, psize, -, pemb, -, -, -, -⟩ ⟨qlength, qsize, -, qemb, -, -, -, -⟩
intro hpq
simp_all only [Sigma.mk.inj_iff, true_and, mk.injEq, Fin.mk.injEq, embSigma]
have : plength = qlength := hpq.1
subst this
simp_all only [Sigma.mk.inj_iff, heq_eq_eq, true_and, and_true]
ext i
exact mk.inj_iff.mp (congr_fun hpq.1 i)
/- The best proof would probably to establish the bijection with Finpartitions, but we opt
for a direct argument, embedding `OrderedPartition n` in a type which is obviously finite. -/
noncomputable instance : Fintype (OrderedFinpartition n) :=
Fintype.ofInjective _ (injective_embSigma n)
instance instUniqueZero : Unique (OrderedFinpartition 0) := by
have : Subsingleton (OrderedFinpartition 0) :=
Fintype.card_le_one_iff_subsingleton.mp (Fintype.card_le_of_injective _ (injective_embSigma 0))
exact Unique.mk' (OrderedFinpartition 0)
lemma exists_inverse {n : ℕ} (c : OrderedFinpartition n) (j : Fin n) :
∃ p : Σ m, Fin (c.partSize m), c.emb p.1 p.2 = j := by
rcases c.cover j with ⟨m, r, hmr⟩
exact ⟨⟨m, r⟩, hmr⟩
lemma emb_injective : Injective (fun (p : Σ m, Fin (c.partSize m)) ↦ c.emb p.1 p.2) := by
rintro ⟨m, r⟩ ⟨m', r'⟩ (h : c.emb m r = c.emb m' r')
have : m = m' := by
contrapose! h
have A : Disjoint (range (c.emb m)) (range (c.emb m')) :=
c.disjoint (mem_univ m) (mem_univ m') h
apply disjoint_iff_forall_ne.1 A (mem_range_self r) (mem_range_self r')
subst this
simpa using (c.emb_strictMono m).injective h
lemma emb_ne_emb_of_ne {i j : Fin c.length} {a : Fin (c.partSize i)} {b : Fin (c.partSize j)}
(h : i ≠ j) : c.emb i a ≠ c.emb j b :=
c.emb_injective.ne (a₁ := ⟨i, a⟩) (a₂ := ⟨j, b⟩) (by simp [h])
/-- Given `j : Fin n`, the index of the part to which it belongs. -/
noncomputable def index (j : Fin n) : Fin c.length :=
(c.exists_inverse j).choose.1
/-- The inverse of `c.emb` for `c : OrderedFinpartition`. It maps `j : Fin n` to the point in
`Fin (c.partSize (c.index j))` which is mapped back to `j` by `c.emb (c.index j)`. -/
noncomputable def invEmbedding (j : Fin n) :
Fin (c.partSize (c.index j)) := (c.exists_inverse j).choose.2
@[simp] lemma emb_invEmbedding (j : Fin n) :
c.emb (c.index j) (c.invEmbedding j) = j :=
(c.exists_inverse j).choose_spec
/-- An ordered finpartition gives an equivalence between `Fin n` and the disjoint union of the
parts, each of them parameterized by `Fin (c.partSize i)`. -/
noncomputable def equivSigma : ((i : Fin c.length) × Fin (c.partSize i)) ≃ Fin n where
toFun p := c.emb p.1 p.2
invFun i := ⟨c.index i, c.invEmbedding i⟩
right_inv _ := by simp
left_inv _ := by apply c.emb_injective; simp
@[to_additive] lemma prod_sigma_eq_prod {α : Type*} [CommMonoid α] (v : Fin n → α) :
∏ (m : Fin c.length), ∏ (r : Fin (c.partSize m)), v (c.emb m r) = ∏ i, v i := by
rw [Finset.prod_sigma']
exact Fintype.prod_equiv c.equivSigma _ _ (fun p ↦ rfl)
lemma length_pos (h : 0 < n) : 0 < c.length := Nat.zero_lt_of_lt (c.index ⟨0, h⟩).2
lemma neZero_length [NeZero n] (c : OrderedFinpartition n) : NeZero c.length :=
⟨(c.length_pos pos').ne'⟩
lemma neZero_partSize (c : OrderedFinpartition n) (i : Fin c.length) : NeZero (c.partSize i) :=
.of_pos (c.partSize_pos i)
attribute [local instance] neZero_length neZero_partSize
instance instUniqueOne : Unique (OrderedFinpartition 1) where
uniq c := by
have h₁ : c.length = 1 := le_antisymm c.length_le (c.length_pos Nat.zero_lt_one)
have h₂ (i) : c.partSize i = 1 := le_antisymm (c.partSize_le _) (c.partSize_pos _)
have h₃ (i j) : c.emb i j = 0 := Subsingleton.elim _ _
rcases c with ⟨length, partSize, _, emb, _, _, _, _⟩
subst h₁
obtain rfl : partSize = fun _ ↦ 1 := funext h₂
simpa [OrderedFinpartition.ext_iff, funext_iff, Fin.forall_fin_one] using h₃ _ _
lemma emb_zero [NeZero n] : c.emb (c.index 0) 0 = 0 := by
apply le_antisymm _ (Fin.zero_le _)
conv_rhs => rw [← c.emb_invEmbedding 0]
apply (c.emb_strictMono _).monotone (Fin.zero_le _)
lemma partSize_eq_one_of_range_emb_eq_singleton
(c : OrderedFinpartition n) {i : Fin c.length} {j : Fin n}
(hc : range (c.emb i) = {j}) :
c.partSize i = 1 := by
have : Fintype.card (range (c.emb i)) = Fintype.card (Fin (c.partSize i)) :=
card_range_of_injective (c.emb_strictMono i).injective
simpa [hc] using this.symm
/-- If the left-most part is not `{0}`, then the part containing `0` has at least two elements:
either because it's the left-most part, and then it's not just `0` by assumption, or because it's
not the left-most part and then, by increasingness of maximal elements in parts, it contains
a positive element. -/
lemma one_lt_partSize_index_zero (c : OrderedFinpartition (n + 1)) (hc : range (c.emb 0) ≠ {0}) :
1 < c.partSize (c.index 0) := by
have : c.partSize (c.index 0) = Nat.card (range (c.emb (c.index 0))) := by
rw [Nat.card_range_of_injective (c.emb_strictMono _).injective]; simp
rw [this]
rcases eq_or_ne (c.index 0) 0 with h | h
· rw [← h] at hc
have : {0} ⊂ range (c.emb (c.index 0)) := by
apply ssubset_of_subset_of_ne ?_ hc.symm
simpa only [singleton_subset_iff, mem_range] using ⟨0, emb_zero c⟩
simpa using Set.Finite.card_lt_card (finite_range _) this
· apply one_lt_two.trans_le
have : {c.emb (c.index 0) 0,
c.emb (c.index 0) ⟨c.partSize (c.index 0) - 1, Nat.sub_one_lt_of_lt (c.partSize_pos _)⟩}
⊆ range (c.emb (c.index 0)) := by simp [insert_subset]
simp only [emb_zero] at this
convert Nat.card_mono Subtype.finite this
simp only [Nat.card_eq_fintype_card, Fintype.card_ofFinset, toFinset_singleton]
apply (Finset.card_pair ?_).symm
exact ((Fin.zero_le _).trans_lt (c.parts_strictMono ((pos_iff_ne_zero' (c.index 0)).mpr h))).ne
/-!
### Extending and shrinking ordered finpartitions
We show how an ordered finpartition can be extended to the left, either by adding a new atomic
part (in `extendLeft`) or adding the new element to an existing part (in `extendMiddle`).
Conversely, one can shrink a finpartition by deleting the element to the left, with a different
behavior if it was an atomic part (in `eraseLeft`, in which case the number of parts decreases by
one) or if it belonged to a non-atomic part (in `eraseMiddle`, in which case the number of parts
stays the same).
These operations are inverse to each other, giving rise to an equivalence between
`((c : OrderedFinpartition n) × Option (Fin c.length))` and `OrderedFinpartition (n + 1)`
called `OrderedFinPartition.extendEquiv`.
-/
/-- Extend an ordered partition of `n` entries, by adding a new singleton part to the left. -/
@[simps -fullyApplied length partSize]
def extendLeft (c : OrderedFinpartition n) : OrderedFinpartition (n + 1) where
length := c.length + 1
partSize := Fin.cons 1 c.partSize
partSize_pos := Fin.cases (by simp) (by simp [c.partSize_pos])
emb := Fin.cases (fun _ ↦ 0) (fun m ↦ Fin.succ ∘ c.emb m)
emb_strictMono := by
refine Fin.cases ?_ (fun i ↦ ?_)
· exact @Subsingleton.strictMono _ _ _ _ (by simp; infer_instance) _
· exact strictMono_succ.comp (c.emb_strictMono i)
parts_strictMono i j hij := by
induction j using Fin.induction with
| zero => simp at hij
| succ j => induction i using Fin.induction with
| zero => simp
| succ i =>
simp only [cons_succ, cases_succ, comp_apply, succ_lt_succ_iff]
exact c.parts_strictMono (by simpa using hij)
disjoint i hi j hj hij := by
wlog h : j < i generalizing i j
· exact .symm
(this j (mem_univ j) i (mem_univ i) hij.symm (lt_of_le_of_ne (le_of_not_gt h) hij))
induction i using Fin.induction with
| zero => simp at h
| succ i =>
induction j using Fin.induction with
| zero =>
simp only [onFun, cases_succ, cases_zero]
apply Set.disjoint_iff_forall_ne.2
simp only [mem_range, comp_apply, exists_prop', cons_zero, ne_eq, and_imp,
Nonempty.forall, forall_const, forall_eq', forall_exists_index, forall_apply_eq_imp_iff]
exact fun _ ↦ succ_ne_zero _
| succ j =>
simp only [onFun, cases_succ]
apply Set.disjoint_iff_forall_ne.2
simp only [mem_range, comp_apply, ne_eq, forall_exists_index, forall_apply_eq_imp_iff,
succ_inj]
intro a b
apply c.emb_ne_emb_of_ne (by simpa using hij)
cover := by
refine Fin.cases ?_ (fun i ↦ ?_)
· simp only [mem_range]
exact ⟨0, ⟨0, by simp⟩, by simp⟩
· simp only [mem_range]
exact ⟨Fin.succ (c.index i), Fin.cast (by simp) (c.invEmbedding i), by simp⟩
@[simp] lemma range_extendLeft_zero (c : OrderedFinpartition n) :
range (c.extendLeft.emb 0) = {0} := by
simp only [extendLeft, cases_zero]
apply @range_const _ _ (by simp; infer_instance)
/-- Extend an ordered partition of `n` entries, by adding to the `i`-th part a new point to the
left. -/
@[simps -fullyApplied length partSize]
def extendMiddle (c : OrderedFinpartition n) (k : Fin c.length) : OrderedFinpartition (n + 1) where
length := c.length
partSize := update c.partSize k (c.partSize k + 1)
partSize_pos m := by
rcases eq_or_ne m k with rfl | hm
· simp
· simpa [hm] using c.partSize_pos m
emb := by
intro m
by_cases h : m = k
· have : update c.partSize k (c.partSize k + 1) m = c.partSize k + 1 := by rw [h]; simp
exact Fin.cases 0 (succ ∘ c.emb k) ∘ Fin.cast this
· have : update c.partSize k (c.partSize k + 1) m = c.partSize m := by simp [h]
exact succ ∘ c.emb m ∘ Fin.cast this
emb_strictMono := by
intro m
rcases eq_or_ne m k with rfl | hm
· suffices ∀ (a' b' : Fin (c.partSize m + 1)), a' < b' →
(cases (motive := fun _ ↦ Fin (n + 1)) 0 (succ ∘ c.emb m)) a' <
(cases (motive := fun _ ↦ Fin (n + 1)) 0 (succ ∘ c.emb m)) b' by
simp only [↓reduceDIte]
intro a b hab
exact this _ _ hab
intro a' b' h'
induction b' using Fin.induction with
| zero => simp at h'
| succ b =>
induction a' using Fin.induction with
| zero => simp
| succ a' =>
simp only [cases_succ, comp_apply, succ_lt_succ_iff]
exact c.emb_strictMono m (by simpa using h')
· simp only [hm, ↓reduceDIte]
exact strictMono_succ.comp ((c.emb_strictMono m).comp (by exact fun ⦃a b⦄ h ↦ h))
parts_strictMono := by
convert strictMono_succ.comp c.parts_strictMono with m
rcases eq_or_ne m k with rfl | hm
· simp only [↓reduceDIte, update_self, add_tsub_cancel_right, comp_apply, cast_mk]
let a : Fin (c.partSize m + 1) := ⟨c.partSize m, lt_add_one (c.partSize m)⟩
let b : Fin (c.partSize m) := ⟨c.partSize m - 1, Nat.sub_one_lt_of_lt (c.partSize_pos m)⟩
change (cases (motive := fun _ ↦ Fin (n + 1)) 0 (succ ∘ c.emb m)) a = succ (c.emb m b)
have : a = succ b := by
simpa [a, b, succ] using (Nat.sub_eq_iff_eq_add (c.partSize_pos m)).mp rfl
simp [this]
· simp [hm]
disjoint i hi j hj hij := by
wlog h : i ≠ k generalizing i j
· apply Disjoint.symm
(this j (mem_univ j) i (mem_univ i) hij.symm ?_)
simp only [ne_eq, Decidable.not_not] at h
simpa [h] using hij.symm
rcases eq_or_ne j k with rfl | hj
· simp only [onFun, ↓reduceDIte]
suffices ∀ (a' : Fin (c.partSize i)) (b' : Fin (c.partSize j + 1)),
succ (c.emb i a') ≠ cases (motive := fun _ ↦ Fin (n + 1)) 0 (succ ∘ c.emb j) b' by
apply Set.disjoint_iff_forall_ne.2
simp only [hij, ↓reduceDIte, mem_range, comp_apply, ne_eq, forall_exists_index,
forall_apply_eq_imp_iff]
intro a b
apply this
intro a' b'
induction b' using Fin.induction with
| zero => simp
| succ b' =>
simp only [cases_succ, comp_apply, ne_eq, succ_inj]
apply c.emb_ne_emb_of_ne hij
· simp only [onFun, h, ↓reduceDIte, hj]
apply Set.disjoint_iff_forall_ne.2
simp only [mem_range, comp_apply, ne_eq, forall_exists_index, forall_apply_eq_imp_iff,
succ_inj]
intro a b
apply c.emb_ne_emb_of_ne hij
cover := by
refine Fin.cases ?_ (fun i ↦ ?_)
· simp only [mem_range]
exact ⟨k, ⟨0, by simp⟩, by simp⟩
· simp only [mem_range]
rcases eq_or_ne (c.index i) k with rfl | hi
· have A : update c.partSize (c.index i) (c.partSize (c.index i) + 1) (c.index i) =
c.partSize (c.index i) + 1 := by simp
exact ⟨c.index i, (succ (c.invEmbedding i)).cast A.symm, by simp⟩
· have A : update c.partSize k (c.partSize k + 1) (c.index i) = c.partSize (c.index i) := by
simp [hi]
exact ⟨c.index i, (c.invEmbedding i).cast A.symm, by simp [hi]⟩
lemma index_extendMiddle_zero (c : OrderedFinpartition n) (i : Fin c.length) :
(c.extendMiddle i).index 0 = i := by
have : (c.extendMiddle i).emb i 0 = 0 := by simp [extendMiddle]
conv_rhs at this => rw [← (c.extendMiddle i).emb_invEmbedding 0]
contrapose! this
exact (c.extendMiddle i).emb_ne_emb_of_ne (Ne.symm this)
lemma range_emb_extendMiddle_ne_singleton_zero (c : OrderedFinpartition n) (i j : Fin c.length) :
range ((c.extendMiddle i).emb j) ≠ {0} := by
intro h
rcases eq_or_ne j i with rfl | hij
· have : Fin.succ (c.emb j 0) ∈ ({0} : Set (Fin n.succ)) := by
rw [← h]
simp only [Nat.succ_eq_add_one, mem_range]
have A : (c.extendMiddle j).partSize j = c.partSize j + 1 := by simp [extendMiddle]
refine ⟨Fin.cast A.symm (succ 0), ?_⟩
simp only [extendMiddle, ↓reduceDIte, comp_apply, Fin.cast_cast, cast_eq_self, cases_succ]
simp only [mem_singleton_iff] at this
exact Fin.succ_ne_zero _ this
· have : (c.extendMiddle i).emb j 0 ∈ range ((c.extendMiddle i).emb j) :=
mem_range_self 0
rw [h] at this
simp only [extendMiddle, hij, ↓reduceDIte, comp_apply, cast_zero, mem_singleton_iff] at this
exact Fin.succ_ne_zero _ this
/-- Extend an ordered partition of `n` entries, by adding singleton to the left or appending it
to one of the existing part. -/
def extend (c : OrderedFinpartition n) (i : Option (Fin c.length)) : OrderedFinpartition (n + 1) :=
match i with
| none => c.extendLeft
| some i => c.extendMiddle i
@[simp] lemma extend_none (c : OrderedFinpartition n) : c.extend none = c.extendLeft := rfl
@[simp]
lemma extend_some (c : OrderedFinpartition n) (i : Fin c.length) : c.extend i = c.extendMiddle i :=
rfl
/-- Given an ordered finpartition of `n+1`, with a leftmost atom equal to `{0}`, remove this
atom to form an ordered finpartition of `n`. -/
def eraseLeft (c : OrderedFinpartition (n + 1)) (hc : range (c.emb 0) = {0}) :
OrderedFinpartition n where
length := c.length - 1
partSize := by
have : c.length - 1 + 1 = c.length := Nat.sub_add_cancel (c.length_pos (Nat.zero_lt_succ n))
exact fun i ↦ c.partSize (Fin.cast this (succ i))
partSize_pos i := c.partSize_pos _
emb i j := by
have : c.length - 1 + 1 = c.length := Nat.sub_add_cancel (c.length_pos (Nat.zero_lt_succ n))
refine Fin.pred (c.emb (Fin.cast this (succ i)) j) ?_
have := c.disjoint (mem_univ (Fin.cast this (succ i))) (mem_univ 0) (ne_of_beq_false rfl)
exact Set.disjoint_iff_forall_ne.1 this (by simp) (by simp only [mem_singleton_iff, hc])
emb_strictMono i a b hab := by
simp only [pred_lt_pred_iff, Nat.succ_eq_add_one]
apply c.emb_strictMono _ hab
parts_strictMono := by
intro i j hij
simp only [pred_lt_pred_iff, Nat.succ_eq_add_one]
apply c.parts_strictMono (cast_strictMono _ (strictMono_succ hij))
disjoint i _ j _ hij := by
apply Set.disjoint_iff_forall_ne.2
simp only [mem_range, ne_eq, forall_exists_index, forall_apply_eq_imp_iff, pred_inj]
intro a b
exact c.emb_ne_emb_of_ne ((cast_injective _).ne (by simpa using hij))
cover x := by
simp only [mem_range]
obtain ⟨i, j, hij⟩ : ∃ (i : Fin c.length), ∃ (j : Fin (c.partSize i)), c.emb i j = succ x :=
⟨c.index (succ x), c.invEmbedding (succ x), by simp⟩
have A : c.length = c.length - 1 + 1 :=
(Nat.sub_add_cancel (c.length_pos (Nat.zero_lt_succ n))).symm
have i_ne : i ≠ 0 := by
intro h
have : succ x ∈ range (c.emb i) := by rw [← hij]; apply mem_range_self
rw [h, hc, mem_singleton_iff] at this
exact Fin.succ_ne_zero _ this
refine ⟨pred (Fin.cast A i) (by simpa using i_ne), Fin.cast (by simp) j, ?_⟩
have : x = pred (succ x) (succ_ne_zero x) := rfl
rw [this]
congr
rw [← hij]
congr 1
· simp
· simp [Fin.heq_ext_iff]
/-- Given an ordered finpartition of `n+1`, with a leftmost atom different from `{0}`, remove `{0}`
from the atom that contains it, to form an ordered finpartition of `n`. -/
def eraseMiddle (c : OrderedFinpartition (n + 1)) (hc : range (c.emb 0) ≠ {0}) :
OrderedFinpartition n where
length := c.length
partSize := update c.partSize (c.index 0) (c.partSize (c.index 0) - 1)
partSize_pos i := by
rcases eq_or_ne i (c.index 0) with rfl | hi
· simpa using c.one_lt_partSize_index_zero hc
· simp only [ne_eq, hi, not_false_eq_true, update_of_ne]
exact c.partSize_pos i
emb i j := by
by_cases h : i = c.index 0
· refine Fin.pred (c.emb i (Fin.cast ?_ (succ j))) ?_
· rw [h]
simpa using Nat.sub_add_cancel (c.partSize_pos (c.index 0))
· have : 0 ≤ c.emb i 0 := Fin.zero_le _
exact (this.trans_lt (c.emb_strictMono _ (succ_pos _))).ne'
· refine Fin.pred (c.emb i (Fin.cast ?_ j)) ?_
· simp [h]
· conv_rhs => rw [← c.emb_invEmbedding 0]
exact c.emb_ne_emb_of_ne h
emb_strictMono i a b hab := by
rcases eq_or_ne i (c.index 0) with rfl | hi
· simp only [↓reduceDIte, Nat.succ_eq_add_one, pred_lt_pred_iff]
exact (c.emb_strictMono _).comp (cast_strictMono _) (by simpa using hab)
· simp only [hi, ↓reduceDIte, pred_lt_pred_iff, Nat.succ_eq_add_one]
exact (c.emb_strictMono _).comp (cast_strictMono _) hab
parts_strictMono i j hij := by
simp only [Fin.lt_iff_val_lt_val]
rw [← Nat.add_lt_add_iff_right (k := 1)]
convert Fin.lt_iff_val_lt_val.1 (c.parts_strictMono hij)
· rcases eq_or_ne i (c.index 0) with rfl | hi
· simp only [↓reduceDIte, update_self, succ_mk, cast_mk, coe_pred]
have A := c.one_lt_partSize_index_zero hc
rw [Nat.sub_add_cancel]
· congr; omega
· rw [Order.one_le_iff_pos]
conv_lhs => rw [show (0 : ℕ) = c.emb (c.index 0) 0 by simp [emb_zero]]
rw [← lt_iff_val_lt_val]
apply c.emb_strictMono
simp [lt_iff_val_lt_val]
· simp only [hi, ↓reduceDIte, ne_eq, not_false_eq_true, update_of_ne, cast_mk, coe_pred]
apply Nat.sub_add_cancel
have : c.emb i ⟨c.partSize i - 1, Nat.sub_one_lt_of_lt (c.partSize_pos i)⟩
≠ c.emb (c.index 0) 0 := c.emb_ne_emb_of_ne hi
simp only [c.emb_zero, ne_eq, ← val_eq_val, val_zero] at this
omega
· rcases eq_or_ne j (c.index 0) with rfl | hj
· simp only [↓reduceDIte, update_self, succ_mk, cast_mk, coe_pred]
have A := c.one_lt_partSize_index_zero hc
rw [Nat.sub_add_cancel]
· congr; omega
· rw [Order.one_le_iff_pos]
conv_lhs => rw [show (0 : ℕ) = c.emb (c.index 0) 0 by simp [emb_zero]]
rw [← lt_iff_val_lt_val]
apply c.emb_strictMono
simp [lt_iff_val_lt_val]
· simp only [hj, ↓reduceDIte, ne_eq, not_false_eq_true, update_of_ne, cast_mk, coe_pred]
apply Nat.sub_add_cancel
have : c.emb j ⟨c.partSize j - 1, Nat.sub_one_lt_of_lt (c.partSize_pos j)⟩
≠ c.emb (c.index 0) 0 := c.emb_ne_emb_of_ne hj
simp only [c.emb_zero, ne_eq, ← val_eq_val, val_zero] at this
omega
disjoint i _ j _ hij := by
wlog h : i ≠ c.index 0 generalizing i j
· apply Disjoint.symm
(this j (mem_univ j) i (mem_univ i) hij.symm ?_)
simp only [ne_eq, Decidable.not_not] at h
simpa [h] using hij.symm
rcases eq_or_ne j (c.index 0) with rfl | hj
· simp only [onFun, hij, ↓reduceDIte]
apply Set.disjoint_iff_forall_ne.2
simp only [mem_range, ne_eq, forall_exists_index, forall_apply_eq_imp_iff, pred_inj]
intro a b
exact c.emb_ne_emb_of_ne hij
· simp only [onFun, h, ↓reduceDIte, hj]
apply Set.disjoint_iff_forall_ne.2
simp only [mem_range, ne_eq, forall_exists_index, forall_apply_eq_imp_iff, pred_inj]
intro a b
exact c.emb_ne_emb_of_ne hij
cover x := by
simp only [mem_range]
obtain ⟨i, j, hij⟩ : ∃ (i : Fin c.length), ∃ (j : Fin (c.partSize i)), c.emb i j = succ x :=
⟨c.index (succ x), c.invEmbedding (succ x), by simp⟩
rcases eq_or_ne i (c.index 0) with rfl | hi
· refine ⟨c.index 0, ?_⟩
have j_ne : j ≠ 0 := by
rintro rfl
simp only [c.emb_zero] at hij
exact (Fin.succ_ne_zero _).symm hij
have je_ne' : (j : ℕ) ≠ 0 := by simpa
simp only [↓reduceDIte]
have A : c.partSize (c.index 0) - 1 + 1 = c.partSize (c.index 0) :=
Nat.sub_add_cancel (c.partSize_pos _)
have B : update c.partSize (c.index 0) (c.partSize (c.index 0) - 1) (c.index 0) =
c.partSize (c.index 0) - 1 := by simp
refine ⟨Fin.cast B.symm (pred (Fin.cast A.symm j) ?_), ?_⟩
· simpa using j_ne
· have : x = pred (succ x) (succ_ne_zero x) := rfl
rw [this]
simp only [pred_inj, ← hij]
congr 1
rw [← val_eq_val]
simp only [coe_cast, val_succ, coe_pred]
omega
· have A : update c.partSize (c.index 0) (c.partSize (c.index 0) - 1) i = c.partSize i := by
simp [hi]
exact ⟨i, Fin.cast A.symm j, by simp [hi, hij]⟩
open Classical in
/-- Extending the ordered partitions of `Fin n` bijects with the ordered partitions
of `Fin (n+1)`. -/
@[simps apply]
def extendEquiv (n : ℕ) :
((c : OrderedFinpartition n) × Option (Fin c.length)) ≃ OrderedFinpartition (n + 1) where
toFun c := c.1.extend c.2
invFun c := if h : range (c.emb 0) = {0} then ⟨c.eraseLeft h, none⟩ else
⟨c.eraseMiddle h, some (c.index 0)⟩
left_inv := by
rintro ⟨c, o⟩
match o with
| none =>
simp only [extend, range_extendLeft_zero, ↓reduceDIte, Sigma.mk.inj_iff, heq_eq_eq,
and_true]
rfl
| some i =>
simp only [extend, range_emb_extendMiddle_ne_singleton_zero, ↓reduceDIte,
Sigma.mk.inj_iff, heq_eq_eq, and_true, eraseMiddle,
index_extendMiddle_zero]
ext
· rfl
· simp only [heq_eq_eq, index_extendMiddle_zero]
ext j
rcases eq_or_ne i j with rfl | hij
· simp [extendMiddle]
· simp [hij.symm, extendMiddle]
· refine HEq.symm (hfunext rfl ?_)
simp only [heq_eq_eq, forall_eq']
intro a
rcases eq_or_ne a i with rfl | hij
· refine (Fin.heq_fun_iff ?_).mpr ?_
· rw [index_extendMiddle_zero]
simp [extendMiddle]
· simp [extendMiddle]
· refine (Fin.heq_fun_iff ?_).mpr ?_
· rw [index_extendMiddle_zero]
simp [extendMiddle]
· simp [extendMiddle, hij]
right_inv c := by
by_cases h : range (c.emb 0) = {0}
· have A : c.length - 1 + 1 = c.length := Nat.sub_add_cancel (c.length_pos (Nat.zero_lt_succ n))
dsimp only
rw [dif_pos h]
simp only [extend, extendLeft, eraseLeft]
ext
· exact A
· refine (Fin.heq_fun_iff A).mpr (fun i ↦ ?_)
induction i using Fin.induction with
| zero => change 1 = c.partSize 0; simp [c.partSize_eq_one_of_range_emb_eq_singleton h]
| succ i => simp only [cons_succ, val_succ]; rfl
· refine hfunext (congrArg Fin A) ?_
simp only
intro i i' h'
have : i' = Fin.cast A i := eq_of_val_eq (by apply val_eq_val_of_heq h'.symm)
subst this
refine (Fin.heq_fun_iff ?_).mpr ?_
· induction i using Fin.induction with
| zero => simp [c.partSize_eq_one_of_range_emb_eq_singleton h]
| succ i => simp
· intro j
induction i using Fin.induction with
| zero =>
simp only [cases_zero, cast_zero, val_eq_zero]
exact (apply_eq_of_range_eq_singleton h _).symm
| succ i => simp
· dsimp only
rw [dif_neg h]
have B : c.partSize (c.index 0) - 1 + 1 = c.partSize (c.index 0) :=
Nat.sub_add_cancel (c.partSize_pos (c.index 0))
simp only [extend, extendMiddle, eraseMiddle, ↓reduceDIte]
ext
· rfl
· simp only [update_self, update_idem, heq_eq_eq, update_eq_self_iff, B]
· refine hfunext rfl ?_
simp only [heq_eq_eq, forall_eq']
intro i
refine ((Fin.heq_fun_iff ?_).mpr ?_).symm
· simp only [update_self, B, update_idem, update_eq_self]
· intro j
rcases eq_or_ne i (c.index 0) with rfl | hi
· simp only [↓reduceDIte, comp_apply]
rcases eq_or_ne j 0 with rfl | hj
· simpa using c.emb_zero
· let j' := Fin.pred (j.cast B.symm) (by simpa using hj)
have : j = (succ j').cast B := by simp [j']
simp only [this, coe_cast, val_succ, cast_mk, cases_succ', comp_apply, succ_mk,
succ_pred]
rfl
· simp [hi]
/-! ### Applying ordered finpartitions to multilinear maps -/
/-- Given a formal multilinear series `p`, an ordered partition `c` of `n` and the index `i` of a
block of `c`, we may define a function on `Fin n → E` by picking the variables in the `i`-th block
of `n`, and applying the corresponding coefficient of `p` to these variables. This function is
called `p.applyOrderedFinpartition c v i` for `v : Fin n → E` and `i : Fin c.k`. -/
def applyOrderedFinpartition (p : ∀ (i : Fin c.length), E [×c.partSize i]→L[𝕜] F) :
(Fin n → E) → Fin c.length → F :=
fun v m ↦ p m (v ∘ c.emb m)
lemma applyOrderedFinpartition_apply (p : ∀ (i : Fin c.length), E [×c.partSize i]→L[𝕜] F)
(v : Fin n → E) :
c.applyOrderedFinpartition p v = (fun m ↦ p m (v ∘ c.emb m)) := rfl
theorem norm_applyOrderedFinpartition_le (p : ∀ (i : Fin c.length), E [×c.partSize i]→L[𝕜] F)
(v : Fin n → E) (m : Fin c.length) :
‖c.applyOrderedFinpartition p v m‖ ≤ ‖p m‖ * ∏ i : Fin (c.partSize m), ‖v (c.emb m i)‖ :=
(p m).le_opNorm _
/-- Technical lemma stating how `c.applyOrderedFinpartition` commutes with updating variables. This
will be the key point to show that functions constructed from `applyOrderedFinpartition` retain
multilinearity. -/
theorem applyOrderedFinpartition_update_right
(p : ∀ (i : Fin c.length), E [×c.partSize i]→L[𝕜] F)
(j : Fin n) (v : Fin n → E) (z : E) :
c.applyOrderedFinpartition p (update v j z) =
update (c.applyOrderedFinpartition p v) (c.index j)
(p (c.index j)
(Function.update (v ∘ c.emb (c.index j)) (c.invEmbedding j) z)) := by
ext m
by_cases h : m = c.index j
· rw [h]
simp only [applyOrderedFinpartition, update_self]
congr
rw [← Function.update_comp_eq_of_injective]
· simp
· exact (c.emb_strictMono (c.index j)).injective
· simp only [applyOrderedFinpartition, ne_eq, h, not_false_eq_true,
update_of_ne]
congr 1
apply Function.update_comp_eq_of_notMem_range
have A : Disjoint (range (c.emb m)) (range (c.emb (c.index j))) :=
c.disjoint (mem_univ m) (mem_univ (c.index j)) h
have : j ∈ range (c.emb (c.index j)) := mem_range.2 ⟨c.invEmbedding j, by simp⟩
exact Set.disjoint_right.1 A this
theorem applyOrderedFinpartition_update_left (p : ∀ (i : Fin c.length), E [×c.partSize i]→L[𝕜] F)
(m : Fin c.length) (v : Fin n → E) (q : E [×c.partSize m]→L[𝕜] F) :
c.applyOrderedFinpartition (update p m q) v
= update (c.applyOrderedFinpartition p v) m (q (v ∘ c.emb m)) := by
ext d
by_cases h : d = m
· rw [h]
simp [applyOrderedFinpartition]
· simp [h, applyOrderedFinpartition]
/-- Given a an ordered finite partition `c` of `n`, a continuous multilinear map `f` in `c.length`
variables, and for each `m` a continuous multilinear map `p m` in `c.partSize m` variables,
one can form a continuous multilinear map in `n`
variables by applying `p m` to each part of the partition, and then
applying `f` to the resulting vector. It is called `c.compAlongOrderedFinpartition f p`. -/
def compAlongOrderedFinpartition (f : F [×c.length]→L[𝕜] G) (p : ∀ i, E [×c.partSize i]→L[𝕜] F) :
E[×n]→L[𝕜] G where
toMultilinearMap :=
MultilinearMap.mk' (fun v ↦ f (c.applyOrderedFinpartition p v))
(fun v i x y ↦ by
simp only [applyOrderedFinpartition_update_right,
ContinuousMultilinearMap.map_update_add])
(fun v i c x ↦ by
simp only [applyOrderedFinpartition_update_right,
ContinuousMultilinearMap.map_update_smul])
cont := by
apply f.cont.comp
change Continuous (fun v m ↦ p m (v ∘ c.emb m))
fun_prop
@[simp] lemma compAlongOrderFinpartition_apply (f : F [×c.length]→L[𝕜] G)
(p : ∀ i, E [×c.partSize i]→L[𝕜] F) (v : Fin n → E) :
c.compAlongOrderedFinpartition f p v = f (c.applyOrderedFinpartition p v) := rfl
theorem norm_compAlongOrderedFinpartition_le (f : F [×c.length]→L[𝕜] G)
(p : ∀ i, E [×c.partSize i]→L[𝕜] F) :
‖c.compAlongOrderedFinpartition f p‖ ≤ ‖f‖ * ∏ i, ‖p i‖ := by
refine ContinuousMultilinearMap.opNorm_le_bound (by positivity) fun v ↦ ?_
rw [compAlongOrderFinpartition_apply, mul_assoc, ← c.prod_sigma_eq_prod,
← Finset.prod_mul_distrib]
exact f.le_opNorm_mul_prod_of_le <| c.norm_applyOrderedFinpartition_le _ _
/-- Bundled version of `compAlongOrderedFinpartition`, depending linearly on `f`
and multilinearly on `p`. -/
@[simps! apply_apply]
def compAlongOrderedFinpartitionₗ :
(F [×c.length]→L[𝕜] G) →ₗ[𝕜]
MultilinearMap 𝕜 (fun i : Fin c.length ↦ E[×c.partSize i]→L[𝕜] F) (E[×n]→L[𝕜] G) where
toFun f :=
MultilinearMap.mk' (fun p ↦ c.compAlongOrderedFinpartition f p)
(fun p m q q' ↦ by
ext v
simp [applyOrderedFinpartition_update_left])
(fun p m a q ↦ by
ext v
simp [applyOrderedFinpartition_update_left])
map_add' _ _ := rfl
map_smul' _ _ := rfl
variable (𝕜 E F G) in
/-- Bundled version of `compAlongOrderedFinpartition`, depending continuously linearly on `f`
and continuously multilinearly on `p`. -/
noncomputable def compAlongOrderedFinpartitionL :
(F [×c.length]→L[𝕜] G) →L[𝕜]
ContinuousMultilinearMap 𝕜 (fun i ↦ E[×c.partSize i]→L[𝕜] F) (E[×n]→L[𝕜] G) := by
refine MultilinearMap.mkContinuousLinear c.compAlongOrderedFinpartitionₗ 1 fun f p ↦ ?_
simp only [one_mul, compAlongOrderedFinpartitionₗ_apply_apply]
apply norm_compAlongOrderedFinpartition_le
@[simp] lemma compAlongOrderedFinpartitionL_apply (f : F [×c.length]→L[𝕜] G)
(p : ∀ (i : Fin c.length), E [×c.partSize i]→L[𝕜] F) :
c.compAlongOrderedFinpartitionL 𝕜 E F G f p = c.compAlongOrderedFinpartition f p := rfl
theorem norm_compAlongOrderedFinpartitionL_le :
‖c.compAlongOrderedFinpartitionL 𝕜 E F G‖ ≤ 1 :=
MultilinearMap.mkContinuousLinear_norm_le _ zero_le_one _
end OrderedFinpartition
/-! ### The Faa di Bruno formula -/
namespace FormalMultilinearSeries
/-- Given two formal multilinear series `q` and `p` and a composition `c` of `n`, one may
form a continuous multilinear map in `n` variables by applying the right coefficient of `p` to each
block of the composition, and then applying `q c.length` to the resulting vector. It is
called `q.compAlongComposition p c`. -/
def compAlongOrderedFinpartition {n : ℕ} (q : FormalMultilinearSeries 𝕜 F G)
(p : FormalMultilinearSeries 𝕜 E F) (c : OrderedFinpartition n) :
E [×n]→L[𝕜] G :=
c.compAlongOrderedFinpartition (q c.length) (fun m ↦ p (c.partSize m))
@[simp]
theorem compAlongOrderedFinpartition_apply {n : ℕ} (q : FormalMultilinearSeries 𝕜 F G)
(p : FormalMultilinearSeries 𝕜 E F) (c : OrderedFinpartition n) (v : Fin n → E) :
(q.compAlongOrderedFinpartition p c) v =
q c.length (c.applyOrderedFinpartition (fun m ↦ (p (c.partSize m))) v) :=
rfl
/-- Taylor formal composition of two formal multilinear series. The `n`-th coefficient in the
composition is defined to be the sum of `q.compAlongOrderedFinpartition p c` over all
ordered partitions of `n`.
In other words, this term (as a multilinear function applied to `v₀, ..., vₙ₋₁`) is
`∑'_{k} ∑'_{I₀ ⊔ ... ⊔ Iₖ₋₁ = {0, ..., n-1}} qₖ (p_{i₀} (...), ..., p_{iₖ₋₁} (...))`, where
`iₘ` is the size of `Iₘ` and one puts all variables of `Iₘ` as arguments to `p_{iₘ}`, in
increasing order. The sets `I₀, ..., Iₖ₋₁` are ordered so that `max I₀ < max I₁ < ... < max Iₖ₋₁`.
This definition is chosen so that the `n`-th derivative of `g ∘ f` is the Taylor composition of
the iterated derivatives of `g` and of `f`.
Not to be confused with another notion of composition for formal multilinear series, called just
`FormalMultilinearSeries.comp`, appearing in the composition of analytic functions.
-/
protected noncomputable def taylorComp
(q : FormalMultilinearSeries 𝕜 F G) (p : FormalMultilinearSeries 𝕜 E F) :
FormalMultilinearSeries 𝕜 E G :=
fun n ↦ ∑ c : OrderedFinpartition n, q.compAlongOrderedFinpartition p c
end FormalMultilinearSeries
theorem analyticOn_taylorComp
(hq : ∀ (n : ℕ), AnalyticOn 𝕜 (fun x ↦ q x n) t)
(hp : ∀ n, AnalyticOn 𝕜 (fun x ↦ p x n) s) {f : E → F}
(hf : AnalyticOn 𝕜 f s) (h : MapsTo f s t) (n : ℕ) :
AnalyticOn 𝕜 (fun x ↦ (q (f x)).taylorComp (p x) n) s := by
apply Finset.analyticOn_fun_sum _ (fun c _ ↦ ?_)
let B := c.compAlongOrderedFinpartitionL 𝕜 E F G
change AnalyticOn 𝕜
((fun p ↦ B p.1 p.2) ∘ (fun x ↦ (q (f x) c.length, fun m ↦ p x (c.partSize m)))) s
apply B.analyticOnNhd_uncurry_of_multilinear.comp_analyticOn ?_ (mapsTo_univ _ _)
apply AnalyticOn.prod
· exact (hq c.length).comp hf h
· exact AnalyticOn.pi (fun i ↦ hp _)
open OrderedFinpartition
/-- Composing two formal multilinear series `q` and `p` along an ordered partition extended by a
new atom to the left corresponds to applying `p 1` on the first coordinates, and the initial
ordered partition on the other coordinates.
This is one of the terms that appears when differentiating in the Faa di Bruno
formula, going from step `m` to step `m + 1`. -/
private lemma faaDiBruno_aux1 {m : ℕ} (q : FormalMultilinearSeries 𝕜 F G)
(p : FormalMultilinearSeries 𝕜 E F) (c : OrderedFinpartition m) :
(q.compAlongOrderedFinpartition p (c.extend none)).curryLeft =
((c.compAlongOrderedFinpartitionL 𝕜 E F G).flipMultilinear fun i ↦ p (c.partSize i)).comp
((q (c.length + 1)).curryLeft.comp ((continuousMultilinearCurryFin1 𝕜 E F) (p 1))) := by
ext e v
simp only [Nat.succ_eq_add_one, OrderedFinpartition.extend, extendLeft,
ContinuousMultilinearMap.curryLeft_apply,
FormalMultilinearSeries.compAlongOrderedFinpartition_apply, applyOrderedFinpartition_apply,
ContinuousLinearMap.coe_comp', comp_apply, continuousMultilinearCurryFin1_apply,
Matrix.zero_empty, ContinuousLinearMap.flipMultilinear_apply_apply,
compAlongOrderedFinpartitionL_apply, compAlongOrderFinpartition_apply]
congr
ext j
exact Fin.cases rfl (fun i ↦ rfl) j
/-- Composing a formal multilinear series with an ordered partition extended by adding a left point
to an already existing atom of index `i` corresponds to updating the `i`th block,
using `p (c.partSize i + 1)` instead of `p (c.partSize i)` there.
This is one of the terms that appears when differentiating in the Faa di Bruno
formula, going from step `m` to step `m + 1`. -/
private lemma faaDiBruno_aux2 {m : ℕ} (q : FormalMultilinearSeries 𝕜 F G)
(p : FormalMultilinearSeries 𝕜 E F) (c : OrderedFinpartition m) (i : Fin c.length) :
(q.compAlongOrderedFinpartition p (c.extend (some i))).curryLeft =
((c.compAlongOrderedFinpartitionL 𝕜 E F G (q c.length)).toContinuousLinearMap
(fun i ↦ p (c.partSize i)) i).comp (p (c.partSize i + 1)).curryLeft := by
ext e v
simp? [OrderedFinpartition.extend, extendMiddle, applyOrderedFinpartition_apply] says
simp only [Nat.succ_eq_add_one, OrderedFinpartition.extend, extendMiddle,
ContinuousMultilinearMap.curryLeft_apply,
FormalMultilinearSeries.compAlongOrderedFinpartition_apply, applyOrderedFinpartition_apply,
ContinuousLinearMap.coe_comp', comp_apply,
ContinuousMultilinearMap.toContinuousLinearMap_apply, compAlongOrderedFinpartitionL_apply,
compAlongOrderFinpartition_apply]
congr
ext j
rcases eq_or_ne j i with rfl | hij
· simp only [↓reduceDIte, update_self, ContinuousMultilinearMap.curryLeft_apply,
Nat.succ_eq_add_one]
apply FormalMultilinearSeries.congr _ (by simp)
intro a ha h'a
match a with
| 0 => simp
| a + 1 => simp [cons]
· simp only [hij, ↓reduceDIte, ne_eq, not_false_eq_true, update_of_ne]
apply FormalMultilinearSeries.congr _ (by simp [hij])
simp
/-- *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 : 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
is a sum, that one can differentiate term by term. Each term is a linear map into continuous
multilinear maps, applied to parts of `p` and `q`. One knows how to differentiate such a map,
thanks to `HasFDerivWithinAt.linear_multilinear_comp`. The terms that show up are matched, using
`faaDiBruno_aux1` and `faaDiBruno_aux2`, with terms of the same form at order `m+1`. Then, one
needs to check that one gets each term once and exactly once, which is given by the bijection
`OrderedFinpartition.extendEquiv m`. -/
classical
constructor
· intro x hx
simp [FormalMultilinearSeries.taylorComp, default, HasFTaylorSeriesUpToOn.zero_eq' hg (h hx)]
· intro m hm x hx
have A (c : OrderedFinpartition m) :
HasFDerivWithinAt (fun x ↦ (q (f x)).compAlongOrderedFinpartition (p x) c)
(∑ i : Option (Fin c.length),
((q (f x)).compAlongOrderedFinpartition (p x) (c.extend i)).curryLeft) s x := by
let B := c.compAlongOrderedFinpartitionL 𝕜 E F G
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 : 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 :=
hf.fderivWithin (c.partSize i) ((cp i).trans_lt hm) x hx
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 (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 [B, Nat.succ_eq_add_one, Fintype.sum_option, comp_apply, faaDiBruno_aux1,
faaDiBruno_aux2]
have B : HasFDerivWithinAt (fun x ↦ (q (f x)).taylorComp (p x) m)
(∑ c : OrderedFinpartition m, ∑ i : Option (Fin c.length),
((q (f x)).compAlongOrderedFinpartition (p x) (c.extend i)).curryLeft) s x :=
HasFDerivWithinAt.fun_sum (fun c _ ↦ A c)
suffices ∑ c : OrderedFinpartition m, ∑ i : Option (Fin c.length),
((q (f x)).compAlongOrderedFinpartition (p x) (c.extend i)) =
(q (f x)).taylorComp (p x) (m + 1) by
rw [← this]
convert B
ext v
simp only [Nat.succ_eq_add_one, Fintype.sum_option, ContinuousMultilinearMap.curryLeft_apply,
ContinuousMultilinearMap.sum_apply, ContinuousMultilinearMap.add_apply,
FormalMultilinearSeries.compAlongOrderedFinpartition_apply, ContinuousLinearMap.coe_sum',
Finset.sum_apply, ContinuousLinearMap.add_apply]
rw [Finset.sum_sigma']
exact Fintype.sum_equiv (OrderedFinpartition.extendEquiv m) _ _ (fun p ↦ rfl)
· intro m hm
apply continuousOn_finset_sum _ (fun c _ ↦ ?_)
let B := c.compAlongOrderedFinpartitionL 𝕜 E F G
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.prodMk ?_ ?_)
· 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 : WithTop ℕ∞) ≤ m := by
exact_mod_cast OrderedFinpartition.partSize_le c i
exact hf.cont _ (this.trans hm) |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/ContDiff/Basic.lean | import Mathlib.Analysis.Calculus.ContDiff.Defs
import Mathlib.Analysis.Calculus.ContDiff.FaaDiBruno
import Mathlib.Analysis.Calculus.FDeriv.Add
import Mathlib.Analysis.Calculus.FDeriv.CompCLM
/-!
# Higher differentiability of composition
We prove that the composition of `C^n` functions is `C^n`.
We also expand the API around `C^n` functions.
## Main results
* `ContDiff.comp` states that the composition of two `C^n` functions is `C^n`.
Similar results are given for `C^n` functions on domains.
## Notation
We use the notation `E [×n]→L[𝕜] F` for the space of continuous multilinear maps on `E^n` with
values in `F`. This is the space in which the `n`-th derivative of a function from `E` to `F` lives.
In this file, we denote `(⊤ : ℕ∞) : WithTop ℕ∞` with `∞` and `⊤ : WithTop ℕ∞` with `ω`.
## Tags
derivative, differentiability, higher derivative, `C^n`, multilinear, Taylor series, formal series
-/
noncomputable section
open scoped NNReal Nat ContDiff
universe u uE uF uG
attribute [local instance 1001]
NormedAddCommGroup.toAddCommGroup AddCommGroup.toAddCommMonoid
open Set Fin Filter Function
open scoped Topology
variable {𝕜 : Type*} [NontriviallyNormedField 𝕜]
{E : Type uE} [NormedAddCommGroup E] [NormedSpace 𝕜 E] {F : Type uF}
[NormedAddCommGroup F] [NormedSpace 𝕜 F] {G : Type uG} [NormedAddCommGroup G] [NormedSpace 𝕜 G]
{X : Type*} [NormedAddCommGroup X] [NormedSpace 𝕜 X] {s t : Set E} {f : E → F}
{g : F → G} {x x₀ : E} {b : E × F → G} {m n : WithTop ℕ∞} {p : E → FormalMultilinearSeries 𝕜 E F}
/-! ### Constants -/
section constants
theorem iteratedFDerivWithin_succ_const (n : ℕ) (c : F) :
iteratedFDerivWithin 𝕜 (n + 1) (fun _ : E ↦ c) s = 0 := by
induction n with
| zero =>
ext1
simp [iteratedFDerivWithin_succ_eq_comp_left, iteratedFDerivWithin_zero_eq_comp, comp_def]
| succ n IH =>
rw [iteratedFDerivWithin_succ_eq_comp_left, IH]
simp only [Pi.zero_def, comp_def, fderivWithin_fun_const, map_zero]
@[simp]
theorem iteratedFDerivWithin_zero_fun {i : ℕ} :
iteratedFDerivWithin 𝕜 i (fun _ : E ↦ (0 : F)) s = 0 := by
cases i with
| zero => ext; simp
| succ i => apply iteratedFDerivWithin_succ_const
@[simp]
theorem iteratedFDeriv_zero_fun {n : ℕ} : (iteratedFDeriv 𝕜 n fun _ : E ↦ (0 : F)) = 0 :=
funext fun x ↦ by simp only [← iteratedFDerivWithin_univ, iteratedFDerivWithin_zero_fun]
theorem contDiff_zero_fun : ContDiff 𝕜 n fun _ : E => (0 : F) :=
analyticOnNhd_const.contDiff
/-- Constants are `C^∞`. -/
@[fun_prop]
theorem contDiff_const {c : F} : ContDiff 𝕜 n fun _ : E => c :=
analyticOnNhd_const.contDiff
@[fun_prop]
theorem contDiffOn_const {c : F} {s : Set E} : ContDiffOn 𝕜 n (fun _ : E => c) s :=
contDiff_const.contDiffOn
@[fun_prop]
theorem contDiffAt_const {c : F} : ContDiffAt 𝕜 n (fun _ : E => c) x :=
contDiff_const.contDiffAt
@[fun_prop]
theorem contDiffWithinAt_const {c : F} : ContDiffWithinAt 𝕜 n (fun _ : E => c) s x :=
contDiffAt_const.contDiffWithinAt
@[nontriviality]
theorem contDiff_of_subsingleton [Subsingleton F] : ContDiff 𝕜 n f := by
rw [Subsingleton.elim f fun _ => 0]; exact contDiff_const
@[nontriviality]
theorem contDiffAt_of_subsingleton [Subsingleton F] : ContDiffAt 𝕜 n f x := by
rw [Subsingleton.elim f fun _ => 0]; exact contDiffAt_const
@[nontriviality]
theorem contDiffWithinAt_of_subsingleton [Subsingleton F] : ContDiffWithinAt 𝕜 n f s x := by
rw [Subsingleton.elim f fun _ => 0]; exact contDiffWithinAt_const
@[nontriviality]
theorem contDiffOn_of_subsingleton [Subsingleton F] : ContDiffOn 𝕜 n f s := by
rw [Subsingleton.elim f fun _ => 0]; exact contDiffOn_const
theorem iteratedFDerivWithin_const_of_ne {n : ℕ} (hn : n ≠ 0) (c : F) (s : Set E) :
iteratedFDerivWithin 𝕜 n (fun _ : E ↦ c) s = 0 := by
cases n with
| zero => contradiction
| succ n => exact iteratedFDerivWithin_succ_const n c
theorem iteratedFDeriv_const_of_ne {n : ℕ} (hn : n ≠ 0) (c : F) :
(iteratedFDeriv 𝕜 n fun _ : E ↦ c) = 0 := by
simp only [← iteratedFDerivWithin_univ, iteratedFDerivWithin_const_of_ne hn]
theorem iteratedFDeriv_succ_const (n : ℕ) (c : F) :
(iteratedFDeriv 𝕜 (n + 1) fun _ : E ↦ c) = 0 :=
iteratedFDeriv_const_of_ne (by simp) _
theorem contDiffWithinAt_singleton : ContDiffWithinAt 𝕜 n f {x} x :=
(contDiffWithinAt_const (c := f x)).congr (by simp) rfl
end constants
/-! ### Smoothness of linear functions -/
section linear
/-- Unbundled bounded linear functions are `C^n`. -/
theorem IsBoundedLinearMap.contDiff (hf : IsBoundedLinearMap 𝕜 f) : ContDiff 𝕜 n f :=
(ContinuousLinearMap.analyticOnNhd hf.toContinuousLinearMap univ).contDiff
@[fun_prop]
theorem ContinuousLinearMap.contDiff (f : E →L[𝕜] F) : ContDiff 𝕜 n f :=
f.isBoundedLinearMap.contDiff
@[fun_prop]
theorem ContinuousLinearEquiv.contDiff (f : E ≃L[𝕜] F) : ContDiff 𝕜 n f :=
(f : E →L[𝕜] F).contDiff
@[fun_prop]
theorem LinearIsometry.contDiff (f : E →ₗᵢ[𝕜] F) : ContDiff 𝕜 n f :=
f.toContinuousLinearMap.contDiff
@[fun_prop]
theorem LinearIsometryEquiv.contDiff (f : E ≃ₗᵢ[𝕜] F) : ContDiff 𝕜 n f :=
(f : E →L[𝕜] F).contDiff
/-- The identity is `C^n`. -/
theorem contDiff_id : ContDiff 𝕜 n (id : E → E) :=
IsBoundedLinearMap.id.contDiff
@[fun_prop]
theorem contDiff_fun_id : ContDiff 𝕜 n (fun x : E => x) :=
IsBoundedLinearMap.id.contDiff
theorem contDiffWithinAt_id {s x} : ContDiffWithinAt 𝕜 n (id : E → E) s x :=
contDiff_id.contDiffWithinAt
@[fun_prop]
theorem contDiffWithinAt_fun_id {s x} : ContDiffWithinAt 𝕜 n (fun x : E => x) s x :=
contDiff_id.contDiffWithinAt
theorem contDiffAt_id {x} : ContDiffAt 𝕜 n (id : E → E) x :=
contDiff_id.contDiffAt
@[fun_prop]
theorem contDiffAt_fun_id {x} : ContDiffAt 𝕜 n (fun x : E => x) x :=
contDiff_id.contDiffAt
theorem contDiffOn_id {s} : ContDiffOn 𝕜 n (id : E → E) s :=
contDiff_id.contDiffOn
@[fun_prop]
theorem contDiffOn_fun_id {s} : ContDiffOn 𝕜 n (fun x : E => x) s :=
contDiff_id.contDiffOn
/-- Bilinear functions are `C^n`. -/
theorem IsBoundedBilinearMap.contDiff (hb : IsBoundedBilinearMap 𝕜 b) : ContDiff 𝕜 n b :=
(hb.toContinuousLinearMap.analyticOnNhd_bilinear _).contDiff
/-- 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 {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)
fderivWithin m hm x hx := (ContinuousLinearMap.compContinuousMultilinearMapL 𝕜
(fun _ : Fin m => E) F G g).hasFDerivAt.comp_hasFDerivWithinAt x (hf.fderivWithin m hm x hx)
cont m hm := (ContinuousLinearMap.compContinuousMultilinearMapL 𝕜
(fun _ : Fin m => E) F G g).continuous.comp_continuousOn (hf.cont m hm)
/-- Composition by continuous linear maps on the left preserves `C^n` functions in a domain
at a point. -/
theorem ContDiffWithinAt.continuousLinearMap_comp (g : F →L[𝕜] G)
(hf : ContDiffWithinAt 𝕜 n f s x) : ContDiffWithinAt 𝕜 n (g ∘ f) s x := by
match n with
| ω =>
obtain ⟨u, hu, p, hp, h'p⟩ := hf
refine ⟨u, hu, _, hp.continuousLinearMap_comp g, fun i ↦ ?_⟩
change AnalyticOn 𝕜
(fun x ↦ (ContinuousLinearMap.compContinuousMultilinearMapL 𝕜
(fun _ : Fin i ↦ E) F G g) (p x i)) u
apply AnalyticOnNhd.comp_analyticOn _ (h'p i) (Set.mapsTo_univ _ _)
exact ContinuousLinearMap.analyticOnNhd _ _
| (n : ℕ∞) =>
intro m hm
rcases hf m hm with ⟨u, hu, p, hp⟩
exact ⟨u, hu, _, hp.continuousLinearMap_comp g⟩
/-- Composition by continuous linear maps on the left preserves `C^n` functions in a domain
at a point. -/
theorem ContDiffAt.continuousLinearMap_comp (g : F →L[𝕜] G) (hf : ContDiffAt 𝕜 n f x) :
ContDiffAt 𝕜 n (g ∘ f) x :=
ContDiffWithinAt.continuousLinearMap_comp g hf
/-- Composition by continuous linear maps on the left preserves `C^n` functions on domains. -/
theorem ContDiffOn.continuousLinearMap_comp (g : F →L[𝕜] G) (hf : ContDiffOn 𝕜 n f s) :
ContDiffOn 𝕜 n (g ∘ f) s := fun x hx => (hf x hx).continuousLinearMap_comp g
/-- Composition by continuous linear maps on the left preserves `C^n` functions. -/
theorem ContDiff.continuousLinearMap_comp {f : E → F} (g : F →L[𝕜] G) (hf : ContDiff 𝕜 n f) :
ContDiff 𝕜 n fun x => g (f x) :=
contDiffOn_univ.1 <| ContDiffOn.continuousLinearMap_comp _ (contDiffOn_univ.2 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 : ContDiffWithinAt 𝕜 n f s x) (hs : UniqueDiffOn 𝕜 s) (hx : x ∈ s) {i : ℕ} (hi : i ≤ n) :
iteratedFDerivWithin 𝕜 i (g ∘ f) s x =
g.compContinuousMultilinearMap (iteratedFDerivWithin 𝕜 i f s x) := by
rcases hf.contDiffOn' hi (by simp) with ⟨U, hU, hxU, hfU⟩
rw [← iteratedFDerivWithin_inter_open hU hxU, ← iteratedFDerivWithin_inter_open (f := f) hU hxU]
rw [insert_eq_of_mem hx] at hfU
exact .symm <| (hfU.ftaylorSeriesWithin (hs.inter hU)).continuousLinearMap_comp g
|>.eq_iteratedFDerivWithin_of_uniqueDiffOn le_rfl (hs.inter hU) ⟨hx, hxU⟩
/-- 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 : ContDiffAt 𝕜 n f x) {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.contDiffWithinAt uniqueDiffOn_univ (mem_univ x) hi
/-- The iterated derivative within a set of the composition with a linear equiv on the left is
obtained by applying the linear equiv to the iterated derivative. This is true without
differentiability assumptions. -/
theorem ContinuousLinearEquiv.iteratedFDerivWithin_comp_left (g : F ≃L[𝕜] G) (f : E → F)
(hs : UniqueDiffOn 𝕜 s) (hx : x ∈ s) (i : ℕ) :
iteratedFDerivWithin 𝕜 i (g ∘ f) s x =
(g : F →L[𝕜] G).compContinuousMultilinearMap (iteratedFDerivWithin 𝕜 i f s x) := by
induction i generalizing x with ext1 m
| zero =>
simp only [iteratedFDerivWithin_zero_apply, comp_apply,
ContinuousLinearMap.compContinuousMultilinearMap_coe, coe_coe]
| succ i IH =>
rw [iteratedFDerivWithin_succ_apply_left]
have Z : fderivWithin 𝕜 (iteratedFDerivWithin 𝕜 i (g ∘ f) s) s x =
fderivWithin 𝕜 (g.continuousMultilinearMapCongrRight (fun _ : Fin i => E) ∘
iteratedFDerivWithin 𝕜 i f s) s x :=
fderivWithin_congr' (@IH) hx
simp_rw [Z]
rw [(g.continuousMultilinearMapCongrRight fun _ : Fin i => E).comp_fderivWithin (hs x hx)]
simp only [ContinuousLinearMap.coe_comp', ContinuousLinearEquiv.coe_coe, comp_apply,
ContinuousLinearEquiv.continuousMultilinearMapCongrRight_apply,
ContinuousLinearMap.compContinuousMultilinearMap_coe, EmbeddingLike.apply_eq_iff_eq]
rw [iteratedFDerivWithin_succ_apply_left]
/-- Iterated derivatives commute with left composition by continuous linear equivalences. -/
theorem ContinuousLinearEquiv.iteratedFDeriv_comp_left {f : E → F} {x : E} (g : F ≃L[𝕜] G) {i : ℕ} :
iteratedFDeriv 𝕜 i (g ∘ f) x =
g.toContinuousLinearMap.compContinuousMultilinearMap (iteratedFDeriv 𝕜 i f x) := by
simp only [← iteratedFDerivWithin_univ]
apply g.iteratedFDerivWithin_comp_left f uniqueDiffOn_univ trivial
/-- 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 : ContDiffWithinAt 𝕜 n f s x) (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 =
g.toContinuousLinearMap.compContinuousMultilinearMap (iteratedFDerivWithin 𝕜 i f s x) :=
g.toContinuousLinearMap.iteratedFDerivWithin_comp_left hf hs hx hi
rw [this]
apply LinearIsometry.norm_compContinuousMultilinearMap
/-- 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 : ContDiffAt 𝕜 n f x) {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.contDiffWithinAt uniqueDiffOn_univ (mem_univ x) hi
/-- Composition with a linear isometry equiv on the left preserves the norm of the iterated
derivative within a set. -/
theorem LinearIsometryEquiv.norm_iteratedFDerivWithin_comp_left (g : F ≃ₗᵢ[𝕜] G) (f : E → F)
(hs : UniqueDiffOn 𝕜 s) (hx : x ∈ s) (i : ℕ) :
‖iteratedFDerivWithin 𝕜 i (g ∘ f) s x‖ = ‖iteratedFDerivWithin 𝕜 i f s x‖ := by
have :
iteratedFDerivWithin 𝕜 i (g ∘ f) s x =
(g : F →L[𝕜] G).compContinuousMultilinearMap (iteratedFDerivWithin 𝕜 i f s x) :=
g.toContinuousLinearEquiv.iteratedFDerivWithin_comp_left f hs hx i
rw [this]
apply LinearIsometry.norm_compContinuousMultilinearMap g.toLinearIsometry
/-- Composition with a linear isometry equiv on the left preserves the norm of the iterated
derivative. -/
theorem LinearIsometryEquiv.norm_iteratedFDeriv_comp_left (g : F ≃ₗᵢ[𝕜] G) (f : E → F) (x : E)
(i : ℕ) : ‖iteratedFDeriv 𝕜 i (g ∘ f) x‖ = ‖iteratedFDeriv 𝕜 i f x‖ := by
rw [← iteratedFDerivWithin_univ, ← iteratedFDerivWithin_univ]
apply g.norm_iteratedFDerivWithin_comp_left f uniqueDiffOn_univ (mem_univ x) i
/-- Composition by continuous linear equivs on the left respects higher differentiability at a
point in a domain. -/
theorem ContinuousLinearEquiv.comp_contDiffWithinAt_iff (e : F ≃L[𝕜] G) :
ContDiffWithinAt 𝕜 n (e ∘ f) s x ↔ ContDiffWithinAt 𝕜 n f s x :=
⟨fun H => by
simpa only [Function.comp_def, e.symm.coe_coe, e.symm_apply_apply] using
H.continuousLinearMap_comp (e.symm : G →L[𝕜] F),
fun H => H.continuousLinearMap_comp (e : F →L[𝕜] G)⟩
/-- Composition by continuous linear equivs on the left respects higher differentiability at a
point. -/
theorem ContinuousLinearEquiv.comp_contDiffAt_iff (e : F ≃L[𝕜] G) :
ContDiffAt 𝕜 n (e ∘ f) x ↔ ContDiffAt 𝕜 n f x := by
simp only [← contDiffWithinAt_univ, e.comp_contDiffWithinAt_iff]
/-- Composition by continuous linear equivs on the left respects higher differentiability on
domains. -/
theorem ContinuousLinearEquiv.comp_contDiffOn_iff (e : F ≃L[𝕜] G) :
ContDiffOn 𝕜 n (e ∘ f) s ↔ ContDiffOn 𝕜 n f s := by
simp [ContDiffOn, e.comp_contDiffWithinAt_iff]
/-- Composition by continuous linear equivs on the left respects higher differentiability. -/
theorem ContinuousLinearEquiv.comp_contDiff_iff (e : F ≃L[𝕜] G) :
ContDiff 𝕜 n (e ∘ f) ↔ ContDiff 𝕜 n f := by
simp only [← contDiffOn_univ, e.comp_contDiffOn_iff]
/-- 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) :
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
have hA : ∀ m, IsBoundedLinearMap 𝕜 (A m) := fun m =>
isBoundedLinearMap_continuousMultilinearMap_comp_linear g
constructor
· intro x hx
simp only [(hf.zero_eq (g x) hx).symm, Function.comp_apply]
change (p (g x) 0 fun _ : Fin 0 => g 0) = p (g x) 0 0
rw [ContinuousLinearMap.map_zero]
rfl
· intro m hm x hx
convert (hA m).hasFDerivAt.comp_hasFDerivWithinAt x
((hf.fderivWithin m hm (g x) hx).comp x g.hasFDerivWithinAt (Subset.refl _))
ext y v
change p (g x) (Nat.succ m) (g ∘ cons y v) = p (g x) m.succ (cons (g y) (g ∘ v))
rw [comp_cons]
· intro m hm
exact (hA m).continuous.comp_continuousOn <| (hf.cont m hm).comp g.continuous.continuousOn <|
Subset.refl _
/-- Composition by continuous linear maps on the right preserves `C^n` functions at a point on
a domain. -/
theorem ContDiffWithinAt.comp_continuousLinearMap {x : G} (g : G →L[𝕜] E)
(hf : ContDiffWithinAt 𝕜 n f s (g x)) : ContDiffWithinAt 𝕜 n (f ∘ g) (g ⁻¹' s) x := by
match n with
| ω =>
obtain ⟨u, hu, p, hp, h'p⟩ := hf
refine ⟨g ⁻¹' u, ?_, _, hp.compContinuousLinearMap g, ?_⟩
· refine g.continuous.continuousWithinAt.tendsto_nhdsWithin ?_ hu
exact (mapsTo_singleton.2 <| mem_singleton _).union_union (mapsTo_preimage _ _)
· intro i
change AnalyticOn 𝕜 (fun x ↦
ContinuousMultilinearMap.compContinuousLinearMapL (fun _ ↦ g) (p (g x) i)) (⇑g ⁻¹' u)
apply AnalyticOn.comp _ _ (Set.mapsTo_univ _ _)
· exact ContinuousLinearMap.analyticOn _ _
· exact (h'p i).comp (g.analyticOn _) (mapsTo_preimage _ _)
| (n : ℕ∞) =>
intro m hm
rcases hf m hm with ⟨u, hu, p, hp⟩
refine ⟨g ⁻¹' u, ?_, _, hp.compContinuousLinearMap g⟩
refine g.continuous.continuousWithinAt.tendsto_nhdsWithin ?_ hu
exact (mapsTo_singleton.2 <| mem_singleton _).union_union (mapsTo_preimage _ _)
/-- Composition by continuous linear maps on the right preserves `C^n` functions on domains. -/
theorem ContDiffOn.comp_continuousLinearMap (hf : ContDiffOn 𝕜 n f s) (g : G →L[𝕜] E) :
ContDiffOn 𝕜 n (f ∘ g) (g ⁻¹' s) := fun x hx => (hf (g x) hx).comp_continuousLinearMap g
/-- Composition by continuous linear maps on the right preserves `C^n` functions. -/
theorem ContDiff.comp_continuousLinearMap {f : E → F} {g : G →L[𝕜] E} (hf : ContDiff 𝕜 n f) :
ContDiff 𝕜 n (f ∘ g) :=
contDiffOn_univ.1 <| ContDiffOn.comp_continuousLinearMap (contDiffOn_univ.2 hf) _
/-- The iterated derivative within a set of the composition with a linear map on the right is
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) :
iteratedFDerivWithin 𝕜 i (f ∘ g) (g ⁻¹' s) x =
(iteratedFDerivWithin 𝕜 i f s (g x)).compContinuousLinearMap fun _ => g :=
((((hf.of_le hi).ftaylorSeriesWithin hs).compContinuousLinearMap
g).eq_iteratedFDerivWithin_of_uniqueDiffOn le_rfl 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. -/
theorem ContinuousLinearEquiv.iteratedFDerivWithin_comp_right (g : G ≃L[𝕜] E) (f : E → F)
(hs : UniqueDiffOn 𝕜 s) {x : G} (hx : g x ∈ s) (i : ℕ) :
iteratedFDerivWithin 𝕜 i (f ∘ g) (g ⁻¹' s) x =
(iteratedFDerivWithin 𝕜 i f s (g x)).compContinuousLinearMap fun _ => g := by
induction i generalizing x with ext1 m
| zero =>
simp only [iteratedFDerivWithin_zero_apply, comp_apply,
ContinuousMultilinearMap.compContinuousLinearMap_apply]
| succ i IH =>
simp only [ContinuousMultilinearMap.compContinuousLinearMap_apply,
ContinuousLinearEquiv.coe_coe, iteratedFDerivWithin_succ_apply_left]
have : fderivWithin 𝕜 (iteratedFDerivWithin 𝕜 i (f ∘ g) (g ⁻¹' s)) (g ⁻¹' s) x =
fderivWithin 𝕜
(ContinuousLinearEquiv.continuousMultilinearMapCongrLeft _ (fun _x : Fin i => g) ∘
(iteratedFDerivWithin 𝕜 i f s ∘ g)) (g ⁻¹' s) x :=
fderivWithin_congr' (@IH) hx
rw [this, ContinuousLinearEquiv.comp_fderivWithin _ (g.uniqueDiffOn_preimage_iff.2 hs x hx)]
simp only [ContinuousLinearMap.coe_comp', ContinuousLinearEquiv.coe_coe, comp_apply,
ContinuousLinearEquiv.continuousMultilinearMapCongrLeft_apply,
ContinuousMultilinearMap.compContinuousLinearMap_apply]
rw [ContinuousLinearEquiv.comp_right_fderivWithin _ (g.uniqueDiffOn_preimage_iff.2 hs x hx),
ContinuousLinearMap.coe_comp', coe_coe, comp_apply, tail_def, tail_def]
/-- 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) :
iteratedFDeriv 𝕜 i (f ∘ g) x =
(iteratedFDeriv 𝕜 i f (g x)).compContinuousLinearMap fun _ => g := by
simp only [← iteratedFDerivWithin_univ]
exact g.iteratedFDerivWithin_comp_right hf.contDiffOn uniqueDiffOn_univ uniqueDiffOn_univ
(mem_univ _) hi
/-- Composition with a linear isometry on the right preserves the norm of the iterated derivative
within a set. -/
theorem LinearIsometryEquiv.norm_iteratedFDerivWithin_comp_right (g : G ≃ₗᵢ[𝕜] E) (f : E → F)
(hs : UniqueDiffOn 𝕜 s) {x : G} (hx : g x ∈ s) (i : ℕ) :
‖iteratedFDerivWithin 𝕜 i (f ∘ g) (g ⁻¹' s) x‖ = ‖iteratedFDerivWithin 𝕜 i f s (g x)‖ := by
have : iteratedFDerivWithin 𝕜 i (f ∘ g) (g ⁻¹' s) x =
(iteratedFDerivWithin 𝕜 i f s (g x)).compContinuousLinearMap fun _ => g :=
g.toContinuousLinearEquiv.iteratedFDerivWithin_comp_right f hs hx i
rw [this, ContinuousMultilinearMap.norm_compContinuous_linearIsometryEquiv]
/-- Composition with a linear isometry on the right preserves the norm of the iterated derivative
within a set. -/
theorem LinearIsometryEquiv.norm_iteratedFDeriv_comp_right (g : G ≃ₗᵢ[𝕜] E) (f : E → F) (x : G)
(i : ℕ) : ‖iteratedFDeriv 𝕜 i (f ∘ g) x‖ = ‖iteratedFDeriv 𝕜 i f (g x)‖ := by
simp only [← iteratedFDerivWithin_univ]
apply g.norm_iteratedFDerivWithin_comp_right f uniqueDiffOn_univ (mem_univ (g x)) i
/-- Composition by continuous linear equivs on the right respects higher differentiability at a
point in a domain. -/
theorem ContinuousLinearEquiv.contDiffWithinAt_comp_iff (e : G ≃L[𝕜] E) :
ContDiffWithinAt 𝕜 n (f ∘ e) (e ⁻¹' s) (e.symm x) ↔ ContDiffWithinAt 𝕜 n f s x := by
constructor
· intro H
simpa [← preimage_comp, Function.comp_def] using H.comp_continuousLinearMap (e.symm : E →L[𝕜] G)
· intro H
rw [← e.apply_symm_apply x, ← e.coe_coe] at H
exact H.comp_continuousLinearMap _
/-- Composition by continuous linear equivs on the right respects higher differentiability at a
point. -/
theorem ContinuousLinearEquiv.contDiffAt_comp_iff (e : G ≃L[𝕜] E) :
ContDiffAt 𝕜 n (f ∘ e) (e.symm x) ↔ ContDiffAt 𝕜 n f x := by
rw [← contDiffWithinAt_univ, ← contDiffWithinAt_univ, ← preimage_univ]
exact e.contDiffWithinAt_comp_iff
/-- Composition by continuous linear equivs on the right respects higher differentiability on
domains. -/
theorem ContinuousLinearEquiv.contDiffOn_comp_iff (e : G ≃L[𝕜] E) :
ContDiffOn 𝕜 n (f ∘ e) (e ⁻¹' s) ↔ ContDiffOn 𝕜 n f s :=
⟨fun H => by simpa [Function.comp_def] using H.comp_continuousLinearMap (e.symm : E →L[𝕜] G),
fun H => H.comp_continuousLinearMap (e : G →L[𝕜] E)⟩
/-- Composition by continuous linear equivs on the right respects higher differentiability. -/
theorem ContinuousLinearEquiv.contDiff_comp_iff (e : G ≃L[𝕜] E) :
ContDiff 𝕜 n (f ∘ e) ↔ ContDiff 𝕜 n f := by
rw [← contDiffOn_univ, ← contDiffOn_univ, ← preimage_univ]
exact e.contDiffOn_comp_iff
end linear
/-! ### The Cartesian product of two C^n functions is C^n. -/
section prod
/-- 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.prodMk {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
constructor
· intro x hx; rw [← hf.zero_eq x hx, ← hg.zero_eq x hx]; rfl
· intro m hm x hx
convert (L m).hasFDerivAt.comp_hasFDerivWithinAt x
((hf.fderivWithin m hm x hx).prodMk (hg.fderivWithin m hm x hx))
· intro m hm
exact (L m).continuous.comp_continuousOn ((hf.cont m hm).prodMk (hg.cont m hm))
/-- The Cartesian product of `C^n` functions at a point in a domain is `C^n`. -/
@[fun_prop]
theorem ContDiffWithinAt.prodMk {s : Set E} {f : E → F} {g : E → G}
(hf : ContDiffWithinAt 𝕜 n f s x) (hg : ContDiffWithinAt 𝕜 n g s x) :
ContDiffWithinAt 𝕜 n (fun x : E => (f x, g x)) s x := by
match n with
| ω =>
obtain ⟨u, hu, p, hp, h'p⟩ := hf
obtain ⟨v, hv, q, hq, h'q⟩ := hg
refine ⟨u ∩ v, Filter.inter_mem hu hv, _,
(hp.mono inter_subset_left).prodMk (hq.mono inter_subset_right), fun i ↦ ?_⟩
change AnalyticOn 𝕜 (fun x ↦ ContinuousMultilinearMap.prodL _ _ _ _ (p x i, q x i)) (u ∩ v)
apply (LinearIsometryEquiv.analyticOnNhd _ _).comp_analyticOn _ (Set.mapsTo_univ _ _)
exact ((h'p i).mono inter_subset_left).prod ((h'q i).mono inter_subset_right)
| (n : ℕ∞) =>
intro m hm
rcases hf m hm with ⟨u, hu, p, hp⟩
rcases hg m hm with ⟨v, hv, q, hq⟩
exact ⟨u ∩ v, Filter.inter_mem hu hv, _,
(hp.mono inter_subset_left).prodMk (hq.mono inter_subset_right)⟩
/-- The Cartesian product of `C^n` functions on domains is `C^n`. -/
@[fun_prop]
theorem ContDiffOn.prodMk {s : Set E} {f : E → F} {g : E → G} (hf : ContDiffOn 𝕜 n f s)
(hg : ContDiffOn 𝕜 n g s) : ContDiffOn 𝕜 n (fun x : E => (f x, g x)) s := fun x hx =>
(hf x hx).prodMk (hg x hx)
/-- The Cartesian product of `C^n` functions at a point is `C^n`. -/
@[fun_prop]
theorem ContDiffAt.prodMk {f : E → F} {g : E → G} (hf : ContDiffAt 𝕜 n f x)
(hg : ContDiffAt 𝕜 n g x) : ContDiffAt 𝕜 n (fun x : E => (f x, g x)) x :=
contDiffWithinAt_univ.1 <| hf.contDiffWithinAt.prodMk hg.contDiffWithinAt
/-- The Cartesian product of `C^n` functions is `C^n`. -/
@[fun_prop]
theorem ContDiff.prodMk {f : E → F} {g : E → G} (hf : ContDiff 𝕜 n f) (hg : ContDiff 𝕜 n g) :
ContDiff 𝕜 n fun x : E => (f x, g x) :=
contDiffOn_univ.1 <| hf.contDiffOn.prodMk hg.contDiffOn
end prod
/-! ### Being `C^k` on a union of open sets can be tested on each set -/
section contDiffOn_union
/-- If a function is `C^k` on two open sets, it is also `C^n` on their union. -/
lemma ContDiffOn.union_of_isOpen (hf : ContDiffOn 𝕜 n f s) (hf' : ContDiffOn 𝕜 n f t)
(hs : IsOpen s) (ht : IsOpen t) :
ContDiffOn 𝕜 n f (s ∪ t) := by
rintro x (hx | hx)
· exact (hf x hx).contDiffAt (hs.mem_nhds hx) |>.contDiffWithinAt
· exact (hf' x hx).contDiffAt (ht.mem_nhds hx) |>.contDiffWithinAt
/-- A function is `C^k` on two open sets iff it is `C^k` on their union. -/
lemma contDiffOn_union_iff_of_isOpen (hs : IsOpen s) (ht : IsOpen t) :
ContDiffOn 𝕜 n f (s ∪ t) ↔ ContDiffOn 𝕜 n f s ∧ ContDiffOn 𝕜 n f t :=
⟨fun h ↦ ⟨h.mono subset_union_left, h.mono subset_union_right⟩,
fun ⟨hfs, hft⟩ ↦ ContDiffOn.union_of_isOpen hfs hft hs ht⟩
lemma contDiff_of_contDiffOn_union_of_isOpen (hf : ContDiffOn 𝕜 n f s)
(hf' : ContDiffOn 𝕜 n f t) (hst : s ∪ t = univ) (hs : IsOpen s) (ht : IsOpen t) :
ContDiff 𝕜 n f := by
rw [← contDiffOn_univ, ← hst]
exact hf.union_of_isOpen hf' hs ht
/-- If a function is `C^k` on open sets `s i`, it is `C^k` on their union -/
lemma ContDiffOn.iUnion_of_isOpen {ι : Type*} {s : ι → Set E}
(hf : ∀ i : ι, ContDiffOn 𝕜 n f (s i)) (hs : ∀ i, IsOpen (s i)) :
ContDiffOn 𝕜 n f (⋃ i, s i) := by
rintro x ⟨si, ⟨i, rfl⟩, hxsi⟩
exact (hf i).contDiffAt ((hs i).mem_nhds hxsi) |>.contDiffWithinAt
/-- A function is `C^k` on a union of open sets `s i` iff it is `C^k` on each `s i`. -/
lemma contDiffOn_iUnion_iff_of_isOpen {ι : Type*} {s : ι → Set E}
(hs : ∀ i, IsOpen (s i)) :
ContDiffOn 𝕜 n f (⋃ i, s i) ↔ ∀ i : ι, ContDiffOn 𝕜 n f (s i) :=
⟨fun h i ↦ h.mono <| subset_iUnion_of_subset i fun _ a ↦ a,
fun h ↦ ContDiffOn.iUnion_of_isOpen h hs⟩
lemma contDiff_of_contDiffOn_iUnion_of_isOpen {ι : Type*} {s : ι → Set E}
(hf : ∀ i : ι, ContDiffOn 𝕜 n f (s i)) (hs : ∀ i, IsOpen (s i)) (hs' : ⋃ i, s i = univ) :
ContDiff 𝕜 n f := by
rw [← contDiffOn_univ, ← hs']
exact ContDiffOn.iUnion_of_isOpen hf hs
end contDiffOn_union
section comp
/-!
### Composition of `C^n` functions
We show that the composition of `C^n` functions is `C^n`. One way to do this would be to
use the following simple inductive proof. Assume it is done for `n`.
Then, to check it for `n+1`, one needs to check that the derivative of `g ∘ f` is `C^n`, i.e.,
that `Dg(f x) ⬝ Df(x)` is `C^n`. The term `Dg (f x)` is the composition of two `C^n` functions, so
it is `C^n` by the inductive assumption. The term `Df(x)` is also `C^n`. Then, the matrix
multiplication is the application of a bilinear map (which is `C^∞`, and therefore `C^n`) to
`x ↦ (Dg(f x), Df x)`. As the composition of two `C^n` maps, it is again `C^n`, and we are done.
There are two difficulties in this proof.
The first one is that it is an induction over all Banach
spaces. In Lean, this is only possible if they belong to a fixed universe. One could formalize this
by first proving the statement in this case, and then extending the result to general universes
by embedding all the spaces we consider in a common universe through `ULift`.
The second one is that it does not work cleanly for analytic maps: for this case, we need to
exhibit a whole sequence of derivatives which are all analytic, not just finitely many of them, so
an induction is never enough at a finite step.
Both these difficulties can be overcome with some cost. However, we choose a different path: we
write down an explicit formula for the `n`-th derivative of `g ∘ f` in terms of derivatives of
`g` and `f` (this is the formula of Faa-Di Bruno) and use this formula to get a suitable Taylor
expansion for `g ∘ f`. Writing down the formula of Faa-Di Bruno is not easy as the formula is quite
intricate, but it is also useful for other purposes and once available it makes the proof here
essentially trivial.
-/
/-- The composition of `C^n` functions at points in domains is `C^n`. -/
theorem ContDiffWithinAt.comp {s : Set E} {t : Set F} {g : F → G} {f : E → F} (x : E)
(hg : ContDiffWithinAt 𝕜 n g t (f x)) (hf : ContDiffWithinAt 𝕜 n f s x) (st : MapsTo f s t) :
ContDiffWithinAt 𝕜 n (g ∘ f) s x := by
match n with
| ω =>
have h'f : ContDiffWithinAt 𝕜 ω f s x := hf
obtain ⟨u, hu, p, hp, h'p⟩ := h'f
obtain ⟨v, hv, q, hq, h'q⟩ := hg
let w := insert x s ∩ (u ∩ f ⁻¹' v)
have wv : w ⊆ f ⁻¹' v := fun y hy => hy.2.2
have wu : w ⊆ u := fun y hy => hy.2.1
refine ⟨w, ?_, fun y ↦ (q (f y)).taylorComp (p y), hq.comp (hp.mono wu) wv, ?_⟩
· apply inter_mem self_mem_nhdsWithin (inter_mem hu ?_)
apply (continuousWithinAt_insert_self.2 hf.continuousWithinAt).preimage_mem_nhdsWithin'
apply nhdsWithin_mono _ _ hv
simp only [image_insert_eq]
apply insert_subset_insert
exact image_subset_iff.mpr st
· have : AnalyticOn 𝕜 f w := by
have : AnalyticOn 𝕜 (fun y ↦ (continuousMultilinearCurryFin0 𝕜 E F).symm (f y)) w :=
((h'p 0).mono wu).congr fun y hy ↦ (hp.zero_eq' (wu hy)).symm
have : AnalyticOn 𝕜 (fun y ↦ (continuousMultilinearCurryFin0 𝕜 E F)
((continuousMultilinearCurryFin0 𝕜 E F).symm (f y))) w :=
AnalyticOnNhd.comp_analyticOn (LinearIsometryEquiv.analyticOnNhd _ _ ) this
(mapsTo_univ _ _)
simpa using this
exact analyticOn_taylorComp h'q (fun n ↦ (h'p n).mono wu) this wv
| (n : ℕ∞) =>
intro m hm
rcases hf m hm with ⟨u, hu, p, hp⟩
rcases hg m hm with ⟨v, hv, q, hq⟩
let w := insert x s ∩ (u ∩ f ⁻¹' v)
have wv : w ⊆ f ⁻¹' v := fun y hy => hy.2.2
have wu : w ⊆ u := fun y hy => hy.2.1
refine ⟨w, ?_, fun y ↦ (q (f y)).taylorComp (p y), hq.comp (hp.mono wu) wv⟩
apply inter_mem self_mem_nhdsWithin (inter_mem hu ?_)
apply (continuousWithinAt_insert_self.2 hf.continuousWithinAt).preimage_mem_nhdsWithin'
apply nhdsWithin_mono _ _ hv
simp only [image_insert_eq]
apply insert_subset_insert
exact image_subset_iff.mpr st
/-- The composition of `C^n` functions on domains is `C^n`. -/
theorem ContDiffOn.comp {s : Set E} {t : Set F} {g : F → G} {f : E → F} (hg : ContDiffOn 𝕜 n g t)
(hf : ContDiffOn 𝕜 n f s) (st : MapsTo f s t) : ContDiffOn 𝕜 n (g ∘ f) s :=
fun x hx ↦ ContDiffWithinAt.comp x (hg (f x) (st hx)) (hf x hx) st
/-- The composition of `C^n` functions on domains is `C^n`. -/
theorem ContDiffOn.comp_inter
{s : Set E} {t : Set F} {g : F → G} {f : E → F} (hg : ContDiffOn 𝕜 n g t)
(hf : ContDiffOn 𝕜 n f s) : ContDiffOn 𝕜 n (g ∘ f) (s ∩ f ⁻¹' t) :=
hg.comp (hf.mono inter_subset_left) inter_subset_right
/-- The composition of a `C^n` function on a domain with a `C^n` function is `C^n`. -/
theorem ContDiff.comp_contDiffOn {s : Set E} {g : F → G} {f : E → F} (hg : ContDiff 𝕜 n g)
(hf : ContDiffOn 𝕜 n f s) : ContDiffOn 𝕜 n (g ∘ f) s :=
(contDiffOn_univ.2 hg).comp hf (mapsTo_univ _ _)
@[fun_prop]
theorem ContDiff.fun_comp_contDiffOn {s : Set E} {g : F → G} {f : E → F} (hg : ContDiff 𝕜 n g)
(hf : ContDiffOn 𝕜 n f s) : ContDiffOn 𝕜 n (fun x => g (f x)) s :=
(contDiffOn_univ.2 hg).comp hf (mapsTo_univ _ _)
theorem ContDiffOn.comp_contDiff {s : Set F} {g : F → G} {f : E → F} (hg : ContDiffOn 𝕜 n g s)
(hf : ContDiff 𝕜 n f) (hs : ∀ x, f x ∈ s) : ContDiff 𝕜 n (g ∘ f) := by
rw [← contDiffOn_univ] at *
exact hg.comp hf fun x _ => hs x
theorem ContDiffOn.image_comp_contDiff {s : Set E} {g : F → G} {f : E → F}
(hg : ContDiffOn 𝕜 n g (f '' s)) (hf : ContDiff 𝕜 n f) : ContDiffOn 𝕜 n (g ∘ f) s :=
hg.comp hf.contDiffOn (s.mapsTo_image f)
/-- The composition of `C^n` functions is `C^n`. -/
theorem ContDiff.comp {g : F → G} {f : E → F} (hg : ContDiff 𝕜 n g) (hf : ContDiff 𝕜 n f) :
ContDiff 𝕜 n (g ∘ f) :=
contDiffOn_univ.1 <| ContDiffOn.comp (contDiffOn_univ.2 hg) (contDiffOn_univ.2 hf) (subset_univ _)
@[fun_prop]
theorem ContDiff.fun_comp {g : F → G} {f : E → F} (hg : ContDiff 𝕜 n g) (hf : ContDiff 𝕜 n f) :
ContDiff 𝕜 n (fun x => g (f x)) := hg.comp hf
/-- The composition of `C^n` functions at points in domains is `C^n`. -/
theorem ContDiffWithinAt.comp_of_eq {s : Set E} {t : Set F} {g : F → G} {f : E → F} {y : F} (x : E)
(hg : ContDiffWithinAt 𝕜 n g t y) (hf : ContDiffWithinAt 𝕜 n f s x) (st : MapsTo f s t)
(hy : f x = y) :
ContDiffWithinAt 𝕜 n (g ∘ f) s x := by
subst hy; exact hg.comp x hf st
/-- The composition of `C^n` functions at points in domains is `C^n`,
with a weaker condition on `s` and `t`. -/
theorem ContDiffWithinAt.comp_of_mem_nhdsWithin_image
{s : Set E} {t : Set F} {g : F → G} {f : E → F} (x : E)
(hg : ContDiffWithinAt 𝕜 n g t (f x)) (hf : ContDiffWithinAt 𝕜 n f s x)
(hs : t ∈ 𝓝[f '' s] f x) : ContDiffWithinAt 𝕜 n (g ∘ f) s x :=
(hg.mono_of_mem_nhdsWithin hs).comp x hf (subset_preimage_image f s)
/-- The composition of `C^n` functions at points in domains is `C^n`,
with a weaker condition on `s` and `t`. -/
theorem ContDiffWithinAt.comp_of_mem_nhdsWithin_image_of_eq
{s : Set E} {t : Set F} {g : F → G} {f : E → F} {y : F} (x : E)
(hg : ContDiffWithinAt 𝕜 n g t y) (hf : ContDiffWithinAt 𝕜 n f s x)
(hs : t ∈ 𝓝[f '' s] f x) (hy : f x = y) : ContDiffWithinAt 𝕜 n (g ∘ f) s x := by
subst hy; exact hg.comp_of_mem_nhdsWithin_image x hf hs
/-- The composition of `C^n` functions at points in domains is `C^n`. -/
theorem ContDiffWithinAt.comp_inter {s : Set E} {t : Set F} {g : F → G} {f : E → F} (x : E)
(hg : ContDiffWithinAt 𝕜 n g t (f x)) (hf : ContDiffWithinAt 𝕜 n f s x) :
ContDiffWithinAt 𝕜 n (g ∘ f) (s ∩ f ⁻¹' t) x :=
hg.comp x (hf.mono inter_subset_left) inter_subset_right
/-- The composition of `C^n` functions at points in domains is `C^n`. -/
theorem ContDiffWithinAt.comp_inter_of_eq {s : Set E} {t : Set F} {g : F → G} {f : E → F} {y : F}
(x : E) (hg : ContDiffWithinAt 𝕜 n g t y) (hf : ContDiffWithinAt 𝕜 n f s x) (hy : f x = y) :
ContDiffWithinAt 𝕜 n (g ∘ f) (s ∩ f ⁻¹' t) x := by
subst hy; exact hg.comp_inter x hf
/-- The composition of `C^n` functions at points in domains is `C^n`,
with a weaker condition on `s` and `t`. -/
theorem ContDiffWithinAt.comp_of_preimage_mem_nhdsWithin
{s : Set E} {t : Set F} {g : F → G} {f : E → F} (x : E)
(hg : ContDiffWithinAt 𝕜 n g t (f x)) (hf : ContDiffWithinAt 𝕜 n f s x)
(hs : f ⁻¹' t ∈ 𝓝[s] x) : ContDiffWithinAt 𝕜 n (g ∘ f) s x :=
(hg.comp_inter x hf).mono_of_mem_nhdsWithin (inter_mem self_mem_nhdsWithin hs)
/-- The composition of `C^n` functions at points in domains is `C^n`,
with a weaker condition on `s` and `t`. -/
theorem ContDiffWithinAt.comp_of_preimage_mem_nhdsWithin_of_eq
{s : Set E} {t : Set F} {g : F → G} {f : E → F} {y : F} (x : E)
(hg : ContDiffWithinAt 𝕜 n g t y) (hf : ContDiffWithinAt 𝕜 n f s x)
(hs : f ⁻¹' t ∈ 𝓝[s] x) (hy : f x = y) : ContDiffWithinAt 𝕜 n (g ∘ f) s x := by
subst hy; exact hg.comp_of_preimage_mem_nhdsWithin x hf hs
theorem ContDiffAt.comp_contDiffWithinAt (x : E) (hg : ContDiffAt 𝕜 n g (f x))
(hf : ContDiffWithinAt 𝕜 n f s x) : ContDiffWithinAt 𝕜 n (g ∘ f) s x :=
hg.comp x hf (mapsTo_univ _ _)
theorem ContDiffAt.comp_contDiffWithinAt_of_eq {y : F} (x : E) (hg : ContDiffAt 𝕜 n g y)
(hf : ContDiffWithinAt 𝕜 n f s x) (hy : f x = y) : ContDiffWithinAt 𝕜 n (g ∘ f) s x := by
subst hy; exact hg.comp_contDiffWithinAt x hf
/-- The composition of `C^n` functions at points is `C^n`. -/
nonrec theorem ContDiffAt.comp (x : E) (hg : ContDiffAt 𝕜 n g (f x)) (hf : ContDiffAt 𝕜 n f x) :
ContDiffAt 𝕜 n (g ∘ f) x :=
hg.comp x hf (mapsTo_univ _ _)
@[fun_prop]
theorem ContDiffAt.fun_comp (x : E) (hg : ContDiffAt 𝕜 n g (f x)) (hf : ContDiffAt 𝕜 n f x) :
ContDiffAt 𝕜 n (fun x => g (f x)) x := hg.comp x hf
theorem ContDiff.comp_contDiffWithinAt {g : F → G} {f : E → F} (h : ContDiff 𝕜 n g)
(hf : ContDiffWithinAt 𝕜 n f t x) : ContDiffWithinAt 𝕜 n (g ∘ f) t x :=
haveI : ContDiffWithinAt 𝕜 n g univ (f x) := h.contDiffAt.contDiffWithinAt
this.comp x hf (subset_univ _)
theorem ContDiff.comp_contDiffAt {g : F → G} {f : E → F} (x : E) (hg : ContDiff 𝕜 n g)
(hf : ContDiffAt 𝕜 n f x) : ContDiffAt 𝕜 n (g ∘ f) x :=
hg.comp_contDiffWithinAt hf
theorem iteratedFDerivWithin_comp_of_eventually_mem {t : Set F}
(hg : ContDiffWithinAt 𝕜 n g t (f x)) (hf : ContDiffWithinAt 𝕜 n f s x)
(ht : UniqueDiffOn 𝕜 t) (hs : UniqueDiffOn 𝕜 s) (hxs : x ∈ s) (hst : ∀ᶠ y in 𝓝[s] x, f y ∈ t)
{i : ℕ} (hi : i ≤ n) :
iteratedFDerivWithin 𝕜 i (g ∘ f) s x =
(ftaylorSeriesWithin 𝕜 g t (f x)).taylorComp (ftaylorSeriesWithin 𝕜 f s x) i := by
obtain ⟨u, hxu, huo, hfu, hgu⟩ : ∃ u, x ∈ u ∧ IsOpen u ∧
HasFTaylorSeriesUpToOn i f (ftaylorSeriesWithin 𝕜 f s) (s ∩ u) ∧
HasFTaylorSeriesUpToOn i g (ftaylorSeriesWithin 𝕜 g t) (f '' (s ∩ u)) := by
have hxt : f x ∈ t := hst.self_of_nhdsWithin hxs
have hf_tendsto : Tendsto f (𝓝[s] x) (𝓝[t] (f x)) :=
tendsto_nhdsWithin_iff.mpr ⟨hf.continuousWithinAt, hst⟩
have H₁ : ∀ᶠ u in (𝓝[s] x).smallSets,
HasFTaylorSeriesUpToOn i f (ftaylorSeriesWithin 𝕜 f s) u :=
hf.eventually_hasFTaylorSeriesUpToOn hs hxs hi
have H₂ : ∀ᶠ u in (𝓝[s] x).smallSets,
HasFTaylorSeriesUpToOn i g (ftaylorSeriesWithin 𝕜 g t) (f '' u) :=
hf_tendsto.image_smallSets.eventually (hg.eventually_hasFTaylorSeriesUpToOn ht hxt hi)
rcases (nhdsWithin_basis_open _ _).smallSets.eventually_iff.mp (H₁.and H₂)
with ⟨u, ⟨hxu, huo⟩, hu⟩
exact ⟨u, hxu, huo, hu (by simp [inter_comm])⟩
exact .symm <| (hgu.comp hfu (mapsTo_image _ _)).eq_iteratedFDerivWithin_of_uniqueDiffOn le_rfl
(hs.inter huo) ⟨hxs, hxu⟩ |>.trans <| iteratedFDerivWithin_inter_open huo hxu
theorem iteratedFDerivWithin_comp {t : Set F} (hg : ContDiffWithinAt 𝕜 n g t (f x))
(hf : ContDiffWithinAt 𝕜 n f s x) (ht : UniqueDiffOn 𝕜 t) (hs : UniqueDiffOn 𝕜 s)
(hx : x ∈ s) (hst : MapsTo f s t) {i : ℕ} (hi : i ≤ n) :
iteratedFDerivWithin 𝕜 i (g ∘ f) s x =
(ftaylorSeriesWithin 𝕜 g t (f x)).taylorComp (ftaylorSeriesWithin 𝕜 f s x) i :=
iteratedFDerivWithin_comp_of_eventually_mem hg hf ht hs hx (eventually_mem_nhdsWithin.mono hst) hi
theorem iteratedFDeriv_comp (hg : ContDiffAt 𝕜 n g (f x)) (hf : ContDiffAt 𝕜 n f x)
{i : ℕ} (hi : i ≤ n) :
iteratedFDeriv 𝕜 i (g ∘ f) x =
(ftaylorSeries 𝕜 g (f x)).taylorComp (ftaylorSeries 𝕜 f x) i := by
simp only [← iteratedFDerivWithin_univ, ← ftaylorSeriesWithin_univ]
exact iteratedFDerivWithin_comp hg.contDiffWithinAt hf.contDiffWithinAt
uniqueDiffOn_univ uniqueDiffOn_univ (mem_univ _) (mapsTo_univ _ _) hi
end comp
/-!
### Smoothness of projections
-/
/-- The first projection in a product is `C^∞`. -/
@[fun_prop]
theorem contDiff_fst : ContDiff 𝕜 n (Prod.fst : E × F → E) :=
IsBoundedLinearMap.contDiff IsBoundedLinearMap.fst
/-- Postcomposing `f` with `Prod.fst` is `C^n` -/
@[fun_prop]
theorem ContDiff.fst {f : E → F × G} (hf : ContDiff 𝕜 n f) : ContDiff 𝕜 n fun x => (f x).1 :=
contDiff_fst.comp hf
/-- Precomposing `f` with `Prod.fst` is `C^n` -/
theorem ContDiff.fst' {f : E → G} (hf : ContDiff 𝕜 n f) : ContDiff 𝕜 n fun x : E × F => f x.1 :=
hf.comp contDiff_fst
/-- The first projection on a domain in a product is `C^∞`. -/
@[fun_prop]
theorem contDiffOn_fst {s : Set (E × F)} : ContDiffOn 𝕜 n (Prod.fst : E × F → E) s :=
ContDiff.contDiffOn contDiff_fst
@[fun_prop]
theorem ContDiffOn.fst {f : E → F × G} {s : Set E} (hf : ContDiffOn 𝕜 n f s) :
ContDiffOn 𝕜 n (fun x => (f x).1) s :=
contDiff_fst.comp_contDiffOn hf
/-- The first projection at a point in a product is `C^∞`. -/
@[fun_prop]
theorem contDiffAt_fst {p : E × F} : ContDiffAt 𝕜 n (Prod.fst : E × F → E) p :=
contDiff_fst.contDiffAt
/-- Postcomposing `f` with `Prod.fst` is `C^n` at `(x, y)` -/
@[fun_prop]
theorem ContDiffAt.fst {f : E → F × G} {x : E} (hf : ContDiffAt 𝕜 n f x) :
ContDiffAt 𝕜 n (fun x => (f x).1) x :=
contDiffAt_fst.comp x hf
/-- Precomposing `f` with `Prod.fst` is `C^n` at `(x, y)` -/
theorem ContDiffAt.fst' {f : E → G} {x : E} {y : F} (hf : ContDiffAt 𝕜 n f x) :
ContDiffAt 𝕜 n (fun x : E × F => f x.1) (x, y) :=
ContDiffAt.comp (x, y) hf contDiffAt_fst
/-- Precomposing `f` with `Prod.fst` is `C^n` at `x : E × F` -/
theorem ContDiffAt.fst'' {f : E → G} {x : E × F} (hf : ContDiffAt 𝕜 n f x.1) :
ContDiffAt 𝕜 n (fun x : E × F => f x.1) x :=
hf.comp x contDiffAt_fst
/-- The first projection within a domain at a point in a product is `C^∞`. -/
@[fun_prop]
theorem contDiffWithinAt_fst {s : Set (E × F)} {p : E × F} :
ContDiffWithinAt 𝕜 n (Prod.fst : E × F → E) s p :=
contDiff_fst.contDiffWithinAt
/-- The second projection in a product is `C^∞`. -/
@[fun_prop]
theorem contDiff_snd : ContDiff 𝕜 n (Prod.snd : E × F → F) :=
IsBoundedLinearMap.contDiff IsBoundedLinearMap.snd
/-- Postcomposing `f` with `Prod.snd` is `C^n` -/
@[fun_prop]
theorem ContDiff.snd {f : E → F × G} (hf : ContDiff 𝕜 n f) : ContDiff 𝕜 n fun x => (f x).2 :=
contDiff_snd.comp hf
/-- Precomposing `f` with `Prod.snd` is `C^n` -/
theorem ContDiff.snd' {f : F → G} (hf : ContDiff 𝕜 n f) : ContDiff 𝕜 n fun x : E × F => f x.2 :=
hf.comp contDiff_snd
/-- The second projection on a domain in a product is `C^∞`. -/
@[fun_prop]
theorem contDiffOn_snd {s : Set (E × F)} : ContDiffOn 𝕜 n (Prod.snd : E × F → F) s :=
ContDiff.contDiffOn contDiff_snd
@[fun_prop]
theorem ContDiffOn.snd {f : E → F × G} {s : Set E} (hf : ContDiffOn 𝕜 n f s) :
ContDiffOn 𝕜 n (fun x => (f x).2) s :=
contDiff_snd.comp_contDiffOn hf
/-- The second projection at a point in a product is `C^∞`. -/
@[fun_prop]
theorem contDiffAt_snd {p : E × F} : ContDiffAt 𝕜 n (Prod.snd : E × F → F) p :=
contDiff_snd.contDiffAt
/-- Postcomposing `f` with `Prod.snd` is `C^n` at `x` -/
@[fun_prop]
theorem ContDiffAt.snd {f : E → F × G} {x : E} (hf : ContDiffAt 𝕜 n f x) :
ContDiffAt 𝕜 n (fun x => (f x).2) x :=
contDiffAt_snd.comp x hf
/-- Precomposing `f` with `Prod.snd` is `C^n` at `(x, y)` -/
theorem ContDiffAt.snd' {f : F → G} {x : E} {y : F} (hf : ContDiffAt 𝕜 n f y) :
ContDiffAt 𝕜 n (fun x : E × F => f x.2) (x, y) :=
ContDiffAt.comp (x, y) hf contDiffAt_snd
/-- Precomposing `f` with `Prod.snd` is `C^n` at `x : E × F` -/
theorem ContDiffAt.snd'' {f : F → G} {x : E × F} (hf : ContDiffAt 𝕜 n f x.2) :
ContDiffAt 𝕜 n (fun x : E × F => f x.2) x :=
hf.comp x contDiffAt_snd
/-- The second projection within a domain at a point in a product is `C^∞`. -/
@[fun_prop]
theorem contDiffWithinAt_snd {s : Set (E × F)} {p : E × F} :
ContDiffWithinAt 𝕜 n (Prod.snd : E × F → F) s p :=
contDiff_snd.contDiffWithinAt
section NAry
variable {E₁ E₂ E₃ : Type*}
variable [NormedAddCommGroup E₁] [NormedAddCommGroup E₂] [NormedAddCommGroup E₃]
[NormedSpace 𝕜 E₁] [NormedSpace 𝕜 E₂] [NormedSpace 𝕜 E₃]
theorem ContDiff.comp₂ {g : E₁ × E₂ → G} {f₁ : F → E₁} {f₂ : F → E₂} (hg : ContDiff 𝕜 n g)
(hf₁ : ContDiff 𝕜 n f₁) (hf₂ : ContDiff 𝕜 n f₂) : ContDiff 𝕜 n fun x => g (f₁ x, f₂ x) :=
hg.comp <| hf₁.prodMk hf₂
theorem ContDiffAt.comp₂ {g : E₁ × E₂ → G} {f₁ : F → E₁} {f₂ : F → E₂} {x : F}
(hg : ContDiffAt 𝕜 n g (f₁ x, f₂ x))
(hf₁ : ContDiffAt 𝕜 n f₁ x) (hf₂ : ContDiffAt 𝕜 n f₂ x) :
ContDiffAt 𝕜 n (fun x => g (f₁ x, f₂ x)) x :=
hg.comp x (hf₁.prodMk hf₂)
theorem ContDiffAt.comp₂_contDiffWithinAt {g : E₁ × E₂ → G} {f₁ : F → E₁} {f₂ : F → E₂}
{s : Set F} {x : F} (hg : ContDiffAt 𝕜 n g (f₁ x, f₂ x))
(hf₁ : ContDiffWithinAt 𝕜 n f₁ s x) (hf₂ : ContDiffWithinAt 𝕜 n f₂ s x) :
ContDiffWithinAt 𝕜 n (fun x => g (f₁ x, f₂ x)) s x :=
hg.comp_contDiffWithinAt x (hf₁.prodMk hf₂)
theorem ContDiff.comp₂_contDiffAt {g : E₁ × E₂ → G} {f₁ : F → E₁} {f₂ : F → E₂} {x : F}
(hg : ContDiff 𝕜 n g) (hf₁ : ContDiffAt 𝕜 n f₁ x) (hf₂ : ContDiffAt 𝕜 n f₂ x) :
ContDiffAt 𝕜 n (fun x => g (f₁ x, f₂ x)) x :=
hg.contDiffAt.comp₂ hf₁ hf₂
theorem ContDiff.comp₂_contDiffWithinAt {g : E₁ × E₂ → G} {f₁ : F → E₁} {f₂ : F → E₂}
{s : Set F} {x : F} (hg : ContDiff 𝕜 n g)
(hf₁ : ContDiffWithinAt 𝕜 n f₁ s x) (hf₂ : ContDiffWithinAt 𝕜 n f₂ s x) :
ContDiffWithinAt 𝕜 n (fun x => g (f₁ x, f₂ x)) s x :=
hg.contDiffAt.comp_contDiffWithinAt x (hf₁.prodMk hf₂)
theorem ContDiff.comp₂_contDiffOn {g : E₁ × E₂ → G} {f₁ : F → E₁} {f₂ : F → E₂} {s : Set F}
(hg : ContDiff 𝕜 n g) (hf₁ : ContDiffOn 𝕜 n f₁ s) (hf₂ : ContDiffOn 𝕜 n f₂ s) :
ContDiffOn 𝕜 n (fun x => g (f₁ x, f₂ x)) s :=
hg.comp_contDiffOn <| hf₁.prodMk hf₂
theorem ContDiff.comp₃ {g : E₁ × E₂ × E₃ → G} {f₁ : F → E₁} {f₂ : F → E₂} {f₃ : F → E₃}
(hg : ContDiff 𝕜 n g) (hf₁ : ContDiff 𝕜 n f₁) (hf₂ : ContDiff 𝕜 n f₂) (hf₃ : ContDiff 𝕜 n f₃) :
ContDiff 𝕜 n fun x => g (f₁ x, f₂ x, f₃ x) :=
hg.comp₂ hf₁ <| hf₂.prodMk hf₃
theorem ContDiff.comp₃_contDiffOn {g : E₁ × E₂ × E₃ → G} {f₁ : F → E₁} {f₂ : F → E₂} {f₃ : F → E₃}
{s : Set F} (hg : ContDiff 𝕜 n g) (hf₁ : ContDiffOn 𝕜 n f₁ s) (hf₂ : ContDiffOn 𝕜 n f₂ s)
(hf₃ : ContDiffOn 𝕜 n f₃ s) : ContDiffOn 𝕜 n (fun x => g (f₁ x, f₂ x, f₃ x)) s :=
hg.comp₂_contDiffOn hf₁ <| hf₂.prodMk hf₃
end NAry
section SpecificBilinearMaps
@[fun_prop]
theorem ContDiff.clm_comp {g : X → F →L[𝕜] G} {f : X → E →L[𝕜] F} (hg : ContDiff 𝕜 n g)
(hf : ContDiff 𝕜 n f) : ContDiff 𝕜 n fun x => (g x).comp (f x) :=
isBoundedBilinearMap_comp.contDiff.comp₂ (g := fun p => p.1.comp p.2) hg hf
@[fun_prop]
theorem ContDiffOn.clm_comp {g : X → F →L[𝕜] G} {f : X → E →L[𝕜] F} {s : Set X}
(hg : ContDiffOn 𝕜 n g s) (hf : ContDiffOn 𝕜 n f s) :
ContDiffOn 𝕜 n (fun x => (g x).comp (f x)) s :=
(isBoundedBilinearMap_comp (E := E) (F := F) (G := G)).contDiff.comp₂_contDiffOn hg hf
@[fun_prop]
theorem ContDiffAt.clm_comp {g : X → F →L[𝕜] G} {f : X → E →L[𝕜] F} {x : X}
(hg : ContDiffAt 𝕜 n g x) (hf : ContDiffAt 𝕜 n f x) :
ContDiffAt 𝕜 n (fun x => (g x).comp (f x)) x :=
(isBoundedBilinearMap_comp (E := E) (G := G)).contDiff.comp₂_contDiffAt hg hf
@[fun_prop]
theorem ContDiffWithinAt.clm_comp {g : X → F →L[𝕜] G} {f : X → E →L[𝕜] F} {s : Set X} {x : X}
(hg : ContDiffWithinAt 𝕜 n g s x) (hf : ContDiffWithinAt 𝕜 n f s x) :
ContDiffWithinAt 𝕜 n (fun x => (g x).comp (f x)) s x :=
(isBoundedBilinearMap_comp (E := E) (G := G)).contDiff.comp₂_contDiffWithinAt hg hf
@[fun_prop]
theorem ContDiff.clm_apply {f : E → F →L[𝕜] G} {g : E → F} (hf : ContDiff 𝕜 n f)
(hg : ContDiff 𝕜 n g) : ContDiff 𝕜 n fun x => (f x) (g x) :=
isBoundedBilinearMap_apply.contDiff.comp₂ hf hg
@[fun_prop]
theorem ContDiffOn.clm_apply {f : E → F →L[𝕜] G} {g : E → F} (hf : ContDiffOn 𝕜 n f s)
(hg : ContDiffOn 𝕜 n g s) : ContDiffOn 𝕜 n (fun x => (f x) (g x)) s :=
isBoundedBilinearMap_apply.contDiff.comp₂_contDiffOn hf hg
@[fun_prop]
theorem ContDiffAt.clm_apply {f : E → F →L[𝕜] G} {g : E → F} (hf : ContDiffAt 𝕜 n f x)
(hg : ContDiffAt 𝕜 n g x) : ContDiffAt 𝕜 n (fun x => (f x) (g x)) x :=
isBoundedBilinearMap_apply.contDiff.comp₂_contDiffAt hf hg
@[fun_prop]
theorem ContDiffWithinAt.clm_apply {f : E → F →L[𝕜] G} {g : E → F}
(hf : ContDiffWithinAt 𝕜 n f s x) (hg : ContDiffWithinAt 𝕜 n g s x) :
ContDiffWithinAt 𝕜 n (fun x => (f x) (g x)) s x :=
isBoundedBilinearMap_apply.contDiff.comp₂_contDiffWithinAt hf hg
@[fun_prop]
theorem ContDiff.smulRight {f : E → StrongDual 𝕜 F} {g : E → G} (hf : ContDiff 𝕜 n f)
(hg : ContDiff 𝕜 n g) : ContDiff 𝕜 n fun x => (f x).smulRight (g x) :=
isBoundedBilinearMap_smulRight.contDiff.comp₂ (g := fun p => p.1.smulRight p.2) hf hg
@[fun_prop]
theorem ContDiffOn.smulRight {f : E → StrongDual 𝕜 F} {g : E → G} (hf : ContDiffOn 𝕜 n f s)
(hg : ContDiffOn 𝕜 n g s) : ContDiffOn 𝕜 n (fun x => (f x).smulRight (g x)) s :=
(isBoundedBilinearMap_smulRight (E := F)).contDiff.comp₂_contDiffOn hf hg
@[fun_prop]
theorem ContDiffAt.smulRight {f : E → StrongDual 𝕜 F} {g : E → G} (hf : ContDiffAt 𝕜 n f x)
(hg : ContDiffAt 𝕜 n g x) : ContDiffAt 𝕜 n (fun x => (f x).smulRight (g x)) x :=
(isBoundedBilinearMap_smulRight (E := F)).contDiff.comp₂_contDiffAt hf hg
@[fun_prop]
theorem ContDiffWithinAt.smulRight {f : E → StrongDual 𝕜 F} {g : E → G}
(hf : ContDiffWithinAt 𝕜 n f s x) (hg : ContDiffWithinAt 𝕜 n g s x) :
ContDiffWithinAt 𝕜 n (fun x => (f x).smulRight (g x)) s x :=
(isBoundedBilinearMap_smulRight (E := F)).contDiff.comp₂_contDiffWithinAt hf hg
end SpecificBilinearMaps
section ClmApplyConst
/-- Application of a `ContinuousLinearMap` to a constant commutes with `iteratedFDerivWithin`. -/
theorem iteratedFDerivWithin_clm_apply_const_apply
{s : Set E} (hs : UniqueDiffOn 𝕜 s) {c : E → F →L[𝕜] G}
(hc : ContDiffOn 𝕜 n c s) {i : ℕ} (hi : i ≤ n) {x : E} (hx : x ∈ s) {u : F} {m : Fin i → E} :
(iteratedFDerivWithin 𝕜 i (fun y ↦ (c y) u) s x) m = (iteratedFDerivWithin 𝕜 i c s x) m u := by
induction i generalizing x with
| zero => simp
| succ i ih =>
replace hi : (i : WithTop ℕ∞) < n := lt_of_lt_of_le (by norm_cast; simp) hi
have h_deriv_apply : DifferentiableOn 𝕜 (iteratedFDerivWithin 𝕜 i (fun y ↦ (c y) u) s) s :=
(hc.clm_apply contDiffOn_const).differentiableOn_iteratedFDerivWithin hi hs
have h_deriv : DifferentiableOn 𝕜 (iteratedFDerivWithin 𝕜 i c s) s :=
hc.differentiableOn_iteratedFDerivWithin hi hs
simp only [iteratedFDerivWithin_succ_apply_left]
rw [← fderivWithin_continuousMultilinear_apply_const_apply (hs x hx) (h_deriv_apply x hx)]
rw [fderivWithin_congr' (fun x hx ↦ ih hi.le hx) hx]
rw [fderivWithin_clm_apply (hs x hx) (h_deriv.continuousMultilinear_apply_const _ x hx)
(differentiableWithinAt_const u)]
rw [fderivWithin_const_apply]
simp only [ContinuousLinearMap.flip_apply, ContinuousLinearMap.comp_zero, zero_add]
rw [fderivWithin_continuousMultilinear_apply_const_apply (hs x hx) (h_deriv x hx)]
/-- Application of a `ContinuousLinearMap` to a constant commutes with `iteratedFDeriv`. -/
theorem iteratedFDeriv_clm_apply_const_apply
{c : E → F →L[𝕜] G} (hc : ContDiff 𝕜 n c)
{i : ℕ} (hi : i ≤ n) {x : E} {u : F} {m : Fin i → E} :
(iteratedFDeriv 𝕜 i (fun y ↦ (c y) u) x) m = (iteratedFDeriv 𝕜 i c x) m u := by
simp only [← iteratedFDerivWithin_univ]
exact iteratedFDerivWithin_clm_apply_const_apply uniqueDiffOn_univ hc.contDiffOn hi (mem_univ _)
end ClmApplyConst
/-- The natural equivalence `(E × F) × G ≃ E × (F × G)` is smooth.
Warning: if you think you need this lemma, it is likely that you can simplify your proof by
reformulating the lemma that you're applying next using the tips in
Note [continuity lemma statement]
-/
theorem contDiff_prodAssoc {n : WithTop ℕ∞} : ContDiff 𝕜 n <| Equiv.prodAssoc E F G :=
(LinearIsometryEquiv.prodAssoc 𝕜 E F G).contDiff
/-- The natural equivalence `E × (F × G) ≃ (E × F) × G` is smooth.
Warning: see remarks attached to `contDiff_prodAssoc`
-/
theorem contDiff_prodAssoc_symm {n : WithTop ℕ∞} : ContDiff 𝕜 n <| (Equiv.prodAssoc E F G).symm :=
(LinearIsometryEquiv.prodAssoc 𝕜 E F G).symm.contDiff
/-! ### Bundled derivatives are smooth -/
section bundled
/-- One direction of `contDiffWithinAt_succ_iff_hasFDerivWithinAt`, but where all derivatives are
taken within the same set. Version for partial derivatives / functions with parameters. If `f x` is
a `C^n+1` family of functions and `g x` is a `C^n` family of points, then the derivative of `f x` at
`g x` depends in a `C^n` way on `x`. We give a general version of this fact relative to sets which
may not have unique derivatives, in the following form. If `f : E × F → G` is `C^n+1` at
`(x₀, g(x₀))` in `(s ∪ {x₀}) × t ⊆ E × F` and `g : E → F` is `C^n` at `x₀` within some set `s ⊆ E`,
then there is a function `f' : E → F →L[𝕜] G` that is `C^n` at `x₀` within `s` such that for all `x`
sufficiently close to `x₀` within `s ∪ {x₀}` the function `y ↦ f x y` has derivative `f' x` at `g x`
within `t ⊆ F`. For convenience, we return an explicit set of `x`'s where this holds that is a
subset of `s ∪ {x₀}`. We need one additional condition, namely that `t` is a neighborhood of
`g(x₀)` within `g '' s`. -/
theorem ContDiffWithinAt.hasFDerivWithinAt_nhds {f : E → F → G} {g : E → F} {t : Set F} (hn : n ≠ ∞)
{x₀ : E} (hf : ContDiffWithinAt 𝕜 (n + 1) (uncurry f) (insert x₀ s ×ˢ t) (x₀, g x₀))
(hg : ContDiffWithinAt 𝕜 n g s x₀) (hgt : t ∈ 𝓝[g '' s] g x₀) :
∃ v ∈ 𝓝[insert x₀ s] x₀, v ⊆ insert x₀ s ∧ ∃ f' : E → F →L[𝕜] G,
(∀ x ∈ v, HasFDerivWithinAt (f x) (f' x) t (g x)) ∧
ContDiffWithinAt 𝕜 n (fun x => f' x) s x₀ := by
have hst : insert x₀ s ×ˢ t ∈ 𝓝[(fun x => (x, g x)) '' s] (x₀, g x₀) := by
refine nhdsWithin_mono _ ?_ (nhdsWithin_prod self_mem_nhdsWithin hgt)
simp_rw [image_subset_iff, mk_preimage_prod, preimage_id', subset_inter_iff, subset_insert,
true_and, subset_preimage_image]
obtain ⟨v, hv, hvs, f_an, f', hvf', hf'⟩ :=
(contDiffWithinAt_succ_iff_hasFDerivWithinAt' hn).mp hf
refine
⟨(fun z => (z, g z)) ⁻¹' v ∩ insert x₀ s, ?_, inter_subset_right, fun z =>
(f' (z, g z)).comp (ContinuousLinearMap.inr 𝕜 E F), ?_, ?_⟩
· refine inter_mem ?_ self_mem_nhdsWithin
have := mem_of_mem_nhdsWithin (mem_insert _ _) hv
refine mem_nhdsWithin_insert.mpr ⟨this, ?_⟩
refine (continuousWithinAt_id.prodMk hg.continuousWithinAt).preimage_mem_nhdsWithin' ?_
rw [← nhdsWithin_le_iff] at hst hv ⊢
exact (hst.trans <| nhdsWithin_mono _ <| subset_insert _ _).trans hv
· intro z hz
have := hvf' (z, g z) hz.1
refine this.comp _ (hasFDerivAt_prodMk_right _ _).hasFDerivWithinAt ?_
exact mapsTo_iff_image_subset.mpr (image_prodMk_subset_prod_right hz.2)
· exact (hf'.continuousLinearMap_comp <| (ContinuousLinearMap.compL 𝕜 F (E × F) G).flip
(ContinuousLinearMap.inr 𝕜 E F)).comp_of_mem_nhdsWithin_image x₀
(contDiffWithinAt_id.prodMk hg) hst
/-- The most general lemma stating that `x ↦ fderivWithin 𝕜 (f x) t (g x)` is `C^n`
at a point within a set.
To show that `x ↦ D_yf(x,y)g(x)` (taken within `t`) is `C^m` at `x₀` within `s`, we require that
* `f` is `C^n` at `(x₀, g(x₀))` within `(s ∪ {x₀}) × t` for `n ≥ m+1`.
* `g` is `C^m` at `x₀` within `s`;
* Derivatives are unique at `g(x)` within `t` for `x` sufficiently close to `x₀` within `s ∪ {x₀}`;
* `t` is a neighborhood of `g(x₀)` within `g '' s`; -/
theorem ContDiffWithinAt.fderivWithin'' {f : E → F → G} {g : E → F} {t : Set F}
(hf : ContDiffWithinAt 𝕜 n (Function.uncurry f) (insert x₀ s ×ˢ t) (x₀, g x₀))
(hg : ContDiffWithinAt 𝕜 m g s x₀)
(ht : ∀ᶠ x in 𝓝[insert x₀ s] x₀, UniqueDiffWithinAt 𝕜 t (g x)) (hmn : m + 1 ≤ n)
(hgt : t ∈ 𝓝[g '' s] g x₀) :
ContDiffWithinAt 𝕜 m (fun x => fderivWithin 𝕜 (f x) t (g x)) s x₀ := by
have : ∀ k : ℕ, k ≤ m → ContDiffWithinAt 𝕜 k (fun x => fderivWithin 𝕜 (f x) t (g x)) s x₀ := by
intro k hkm
obtain ⟨v, hv, -, f', hvf', hf'⟩ :=
(hf.of_le <| by grw [hkm, hmn]).hasFDerivWithinAt_nhds (by simp) (hg.of_le hkm) hgt
refine hf'.congr_of_eventuallyEq_insert ?_
filter_upwards [hv, ht]
exact fun y hy h2y => (hvf' y hy).fderivWithin h2y
match m with
| ω =>
obtain rfl : n = ω := by simpa using hmn
obtain ⟨v, hv, -, f', hvf', hf'⟩ := hf.hasFDerivWithinAt_nhds (by simp) hg hgt
refine hf'.congr_of_eventuallyEq_insert ?_
filter_upwards [hv, ht]
exact fun y hy h2y => (hvf' y hy).fderivWithin h2y
| ∞ =>
rw [contDiffWithinAt_infty]
exact fun k ↦ this k (by exact_mod_cast le_top)
| (m : ℕ) => exact this _ le_rfl
/-- A special case of `ContDiffWithinAt.fderivWithin''` where we require that `s ⊆ g⁻¹(t)`. -/
theorem ContDiffWithinAt.fderivWithin' {f : E → F → G} {g : E → F} {t : Set F}
(hf : ContDiffWithinAt 𝕜 n (Function.uncurry f) (insert x₀ s ×ˢ t) (x₀, g x₀))
(hg : ContDiffWithinAt 𝕜 m g s x₀)
(ht : ∀ᶠ x in 𝓝[insert x₀ s] x₀, UniqueDiffWithinAt 𝕜 t (g x)) (hmn : m + 1 ≤ n)
(hst : s ⊆ g ⁻¹' t) : ContDiffWithinAt 𝕜 m (fun x => fderivWithin 𝕜 (f x) t (g x)) s x₀ :=
hf.fderivWithin'' hg ht hmn <| mem_of_superset self_mem_nhdsWithin <| image_subset_iff.mpr hst
/-- A special case of `ContDiffWithinAt.fderivWithin'` where we require that `x₀ ∈ s` and there
are unique derivatives everywhere within `t`. -/
protected theorem ContDiffWithinAt.fderivWithin {f : E → F → G} {g : E → F} {t : Set F}
(hf : ContDiffWithinAt 𝕜 n (Function.uncurry f) (s ×ˢ t) (x₀, g x₀))
(hg : ContDiffWithinAt 𝕜 m g s x₀) (ht : UniqueDiffOn 𝕜 t) (hmn : m + 1 ≤ n) (hx₀ : x₀ ∈ s)
(hst : s ⊆ g ⁻¹' t) : ContDiffWithinAt 𝕜 m (fun x => fderivWithin 𝕜 (f x) t (g x)) s x₀ := by
rw [← insert_eq_self.mpr hx₀] at hf
refine hf.fderivWithin' hg ?_ hmn hst
rw [insert_eq_self.mpr hx₀]
exact eventually_of_mem self_mem_nhdsWithin fun x hx => ht _ (hst hx)
/-- `x ↦ fderivWithin 𝕜 (f x) t (g x) (k x)` is smooth at a point within a set. -/
theorem ContDiffWithinAt.fderivWithin_apply {f : E → F → G} {g k : E → F} {t : Set F}
(hf : ContDiffWithinAt 𝕜 n (Function.uncurry f) (s ×ˢ t) (x₀, g x₀))
(hg : ContDiffWithinAt 𝕜 m g s x₀) (hk : ContDiffWithinAt 𝕜 m k s x₀) (ht : UniqueDiffOn 𝕜 t)
(hmn : m + 1 ≤ n) (hx₀ : x₀ ∈ s) (hst : s ⊆ g ⁻¹' t) :
ContDiffWithinAt 𝕜 m (fun x => fderivWithin 𝕜 (f x) t (g x) (k x)) s x₀ :=
(contDiff_fst.clm_apply contDiff_snd).contDiffAt.comp_contDiffWithinAt x₀
((hf.fderivWithin hg ht hmn hx₀ hst).prodMk hk)
/-- `fderivWithin 𝕜 f s` is smooth at `x₀` within `s`. -/
theorem ContDiffWithinAt.fderivWithin_right (hf : ContDiffWithinAt 𝕜 n f s x₀)
(hs : UniqueDiffOn 𝕜 s) (hmn : m + 1 ≤ n) (hx₀s : x₀ ∈ s) :
ContDiffWithinAt 𝕜 m (fderivWithin 𝕜 f s) s x₀ :=
ContDiffWithinAt.fderivWithin
(ContDiffWithinAt.comp (x₀, x₀) hf contDiffWithinAt_snd <| prod_subset_preimage_snd s s)
contDiffWithinAt_id hs hmn hx₀s (by rw [preimage_id'])
/-- `x ↦ fderivWithin 𝕜 f s x (k x)` is smooth at `x₀` within `s`. -/
theorem ContDiffWithinAt.fderivWithin_right_apply
{f : F → G} {k : F → F} {s : Set F} {x₀ : F}
(hf : ContDiffWithinAt 𝕜 n f s x₀) (hk : ContDiffWithinAt 𝕜 m k s x₀)
(hs : UniqueDiffOn 𝕜 s) (hmn : m + 1 ≤ n) (hx₀s : x₀ ∈ s) :
ContDiffWithinAt 𝕜 m (fun x => fderivWithin 𝕜 f s x (k x)) s x₀ :=
ContDiffWithinAt.fderivWithin_apply
(ContDiffWithinAt.comp (x₀, x₀) hf contDiffWithinAt_snd <| prod_subset_preimage_snd s s)
contDiffWithinAt_id hk hs hmn hx₀s (by rw [preimage_id'])
-- TODO: can we make a version of `ContDiffWithinAt.fderivWithin` for iterated derivatives?
theorem ContDiffWithinAt.iteratedFDerivWithin_right {i : ℕ} (hf : ContDiffWithinAt 𝕜 n f s x₀)
(hs : UniqueDiffOn 𝕜 s) (hmn : m + i ≤ n) (hx₀s : x₀ ∈ s) :
ContDiffWithinAt 𝕜 m (iteratedFDerivWithin 𝕜 i f s) s x₀ := by
induction i generalizing m with
| zero =>
simp only [CharP.cast_eq_zero, add_zero] at hmn
exact (hf.of_le hmn).continuousLinearMap_comp
((continuousMultilinearCurryFin0 𝕜 E F).symm : _ →L[𝕜] E [×0]→L[𝕜] F)
| succ i hi =>
rw [Nat.cast_succ, add_comm _ 1, ← add_assoc] at hmn
exact ((hi hmn).fderivWithin_right hs le_rfl hx₀s).continuousLinearMap_comp
((continuousMultilinearCurryLeftEquiv 𝕜 (fun _ : Fin (i+1) ↦ E) F).symm :
_ →L[𝕜] E [×(i+1)]→L[𝕜] F)
/-- `x ↦ fderiv 𝕜 (f x) (g x)` is smooth at `x₀`. -/
protected theorem ContDiffAt.fderiv {f : E → F → G} {g : E → F}
(hf : ContDiffAt 𝕜 n (Function.uncurry f) (x₀, g x₀)) (hg : ContDiffAt 𝕜 m g x₀)
(hmn : m + 1 ≤ n) : ContDiffAt 𝕜 m (fun x => fderiv 𝕜 (f x) (g x)) x₀ := by
simp_rw [← fderivWithin_univ]
refine (ContDiffWithinAt.fderivWithin hf.contDiffWithinAt hg.contDiffWithinAt uniqueDiffOn_univ
hmn (mem_univ x₀) ?_).contDiffAt univ_mem
rw [preimage_univ]
@[fun_prop]
protected theorem ContDiffAt.fderiv_succ {f : E → F → G} {g : E → F}
(hf : ContDiffAt 𝕜 (m + 1) (Function.uncurry f) (x₀, g x₀)) (hg : ContDiffAt 𝕜 m g x₀) :
ContDiffAt 𝕜 m (fun x => fderiv 𝕜 (f x) (g x)) x₀ :=
ContDiffAt.fderiv hf hg (le_refl _)
/-- `fderiv 𝕜 f` is smooth at `x₀`. -/
theorem ContDiffAt.fderiv_right (hf : ContDiffAt 𝕜 n f x₀) (hmn : m + 1 ≤ n) :
ContDiffAt 𝕜 m (fderiv 𝕜 f) x₀ :=
ContDiffAt.fderiv (ContDiffAt.comp (x₀, x₀) hf contDiffAt_snd) contDiffAt_id hmn
theorem ContDiffAt.fderiv_right_succ (hf : ContDiffAt 𝕜 (n + 1) f x₀) :
ContDiffAt 𝕜 n (fderiv 𝕜 f) x₀ :=
ContDiffAt.fderiv (ContDiffAt.comp (x₀, x₀) hf contDiffAt_snd) contDiffAt_id (le_refl (n + 1))
theorem ContDiffAt.iteratedFDeriv_right {i : ℕ} (hf : ContDiffAt 𝕜 n f x₀)
(hmn : m + i ≤ n) : ContDiffAt 𝕜 m (iteratedFDeriv 𝕜 i f) x₀ := by
rw [← iteratedFDerivWithin_univ, ← contDiffWithinAt_univ] at *
exact hf.iteratedFDerivWithin_right uniqueDiffOn_univ hmn trivial
/-- `x ↦ fderiv 𝕜 (f x) (g x)` is smooth. -/
protected theorem ContDiff.fderiv {f : E → F → G} {g : E → F}
(hf : ContDiff 𝕜 m <| Function.uncurry f) (hg : ContDiff 𝕜 n g) (hnm : n + 1 ≤ m) :
ContDiff 𝕜 n fun x => fderiv 𝕜 (f x) (g x) :=
contDiff_iff_contDiffAt.mpr fun _ => hf.contDiffAt.fderiv hg.contDiffAt hnm
@[fun_prop]
protected theorem ContDiff.fderiv_succ {f : E → F → G} {g : E → F}
(hf : ContDiff 𝕜 (n + 1) <| Function.uncurry f) (hg : ContDiff 𝕜 n g) :
ContDiff 𝕜 n fun x => fderiv 𝕜 (f x) (g x) :=
contDiff_iff_contDiffAt.mpr fun _ => hf.contDiffAt.fderiv hg.contDiffAt (le_refl (n + 1))
/-- `fderiv 𝕜 f` is smooth. -/
theorem ContDiff.fderiv_right (hf : ContDiff 𝕜 n f) (hmn : m + 1 ≤ n) :
ContDiff 𝕜 m (fderiv 𝕜 f) :=
contDiff_iff_contDiffAt.mpr fun _x => hf.contDiffAt.fderiv_right hmn
theorem ContDiff.iteratedFDeriv_right {i : ℕ} (hf : ContDiff 𝕜 n f)
(hmn : m + i ≤ n) : ContDiff 𝕜 m (iteratedFDeriv 𝕜 i f) :=
contDiff_iff_contDiffAt.mpr fun _x => hf.contDiffAt.iteratedFDeriv_right hmn
@[fun_prop]
theorem ContDiff.iteratedFDeriv_right' {i : ℕ} (hf : ContDiff 𝕜 (m + i) f) :
ContDiff 𝕜 m (iteratedFDeriv 𝕜 i f) :=
contDiff_iff_contDiffAt.mpr fun _x => hf.contDiffAt.iteratedFDeriv_right (le_refl _)
/-- `x ↦ fderiv 𝕜 (f x) (g x)` is continuous. -/
theorem Continuous.fderiv {f : E → F → G} {g : E → F}
(hf : ContDiff 𝕜 n <| Function.uncurry f) (hg : Continuous g) (hn : 1 ≤ n) :
Continuous fun x => fderiv 𝕜 (f x) (g x) :=
(hf.fderiv (contDiff_zero.mpr hg) hn).continuous
@[fun_prop]
theorem Continuous.fderiv_one {f : E → F → G} {g : E → F}
(hf : ContDiff 𝕜 1 <| Function.uncurry f) (hg : Continuous g) :
Continuous fun x => _root_.fderiv 𝕜 (f x) (g x) :=
(hf.fderiv (contDiff_zero.mpr hg) (le_refl 1)).continuous
@[fun_prop]
protected theorem Differentiable.fderiv_two {f : E → F → G} {g : E → F}
(hf : ContDiff 𝕜 2 <| Function.uncurry f) (hg : ContDiff 𝕜 1 g) :
Differentiable 𝕜 fun x => fderiv 𝕜 (f x) (g x) :=
ContDiff.differentiable
(contDiff_iff_contDiffAt.mpr fun _ => hf.contDiffAt.fderiv hg.contDiffAt (le_refl 2))
(le_refl 1)
/-- `x ↦ fderiv 𝕜 (f x) (g x) (k x)` is smooth. -/
theorem ContDiff.fderiv_apply {f : E → F → G} {g k : E → F}
(hf : ContDiff 𝕜 m <| Function.uncurry f) (hg : ContDiff 𝕜 n g) (hk : ContDiff 𝕜 n k)
(hnm : n + 1 ≤ m) : ContDiff 𝕜 n fun x => fderiv 𝕜 (f x) (g x) (k x) :=
(hf.fderiv hg hnm).clm_apply hk
/-- The bundled derivative of a `C^{n+1}` function is `C^n`. -/
theorem contDiffOn_fderivWithin_apply {s : Set E} {f : E → F} (hf : ContDiffOn 𝕜 n f s)
(hs : UniqueDiffOn 𝕜 s) (hmn : m + 1 ≤ n) :
ContDiffOn 𝕜 m (fun p : E × E => (fderivWithin 𝕜 f s p.1 : E →L[𝕜] F) p.2) (s ×ˢ univ) :=
((hf.fderivWithin hs hmn).comp contDiffOn_fst (prod_subset_preimage_fst _ _)).clm_apply
contDiffOn_snd
/-- If a function is at least `C^1`, its bundled derivative (mapping `(x, v)` to `Df(x) v`) is
continuous. -/
theorem ContDiffOn.continuousOn_fderivWithin_apply (hf : ContDiffOn 𝕜 n f s) (hs : UniqueDiffOn 𝕜 s)
(hn : 1 ≤ n) :
ContinuousOn (fun p : E × E => (fderivWithin 𝕜 f s p.1 : E → F) p.2) (s ×ˢ univ) :=
(contDiffOn_fderivWithin_apply (m := 0) hf hs hn).continuousOn
/-- The bundled derivative of a `C^{n+1}` function is `C^n`. -/
theorem ContDiff.contDiff_fderiv_apply {f : E → F} (hf : ContDiff 𝕜 n f) (hmn : m + 1 ≤ n) :
ContDiff 𝕜 m fun p : E × E => (fderiv 𝕜 f p.1 : E →L[𝕜] F) p.2 := by
rw [← contDiffOn_univ] at hf ⊢
rw [← fderivWithin_univ, ← univ_prod_univ]
exact contDiffOn_fderivWithin_apply hf uniqueDiffOn_univ hmn
end bundled
section deriv
/-!
### One dimension
All results up to now have been expressed in terms of the general Fréchet derivative `fderiv`. For
maps defined on the field, the one-dimensional derivative `deriv` is often easier to use. In this
paragraph, we reformulate some higher smoothness results in terms of `deriv`.
-/
variable {f₂ : 𝕜 → F} {s₂ : Set 𝕜}
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 (hs : UniqueDiffOn 𝕜 s₂) :
ContDiffOn 𝕜 (n + 1) f₂ s₂ ↔
DifferentiableOn 𝕜 f₂ s₂ ∧ (n = ω → AnalyticOn 𝕜 f₂ s₂) ∧
ContDiffOn 𝕜 n (derivWithin f₂ s₂) s₂ := by
rw [contDiffOn_succ_iff_fderivWithin hs, and_congr_right_iff]
intro _
constructor
· rintro ⟨h', h⟩
refine ⟨h', ?_⟩
have : derivWithin f₂ s₂ = (fun u : 𝕜 →L[𝕜] F => u 1) ∘ fderivWithin 𝕜 f₂ s₂ := by
ext x; rfl
simp_rw [this]
apply ContDiff.comp_contDiffOn _ h
exact (isBoundedBilinearMap_apply.isBoundedLinearMap_left _).contDiff
· rintro ⟨h', h⟩
refine ⟨h', ?_⟩
have : fderivWithin 𝕜 f₂ s₂ = smulRight (1 : 𝕜 →L[𝕜] 𝕜) ∘ derivWithin f₂ s₂ := by
ext x; simp [derivWithin]
simp only [this]
apply ContDiff.comp_contDiffOn _ h
have : IsBoundedBilinearMap 𝕜 fun _ : (𝕜 →L[𝕜] 𝕜) × F => _ := isBoundedBilinearMap_smulRight
exact (this.isBoundedLinearMap_right _).contDiff
theorem contDiffOn_infty_iff_derivWithin (hs : UniqueDiffOn 𝕜 s₂) :
ContDiffOn 𝕜 ∞ f₂ s₂ ↔ DifferentiableOn 𝕜 f₂ s₂ ∧ ContDiffOn 𝕜 ∞ (derivWithin f₂ s₂) s₂ := by
rw [show ∞ = ∞ + 1 by rfl, contDiffOn_succ_iff_derivWithin hs]
simp
/-- 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 (hs : IsOpen s₂) :
ContDiffOn 𝕜 (n + 1) f₂ s₂ ↔
DifferentiableOn 𝕜 f₂ s₂ ∧ (n = ω → AnalyticOn 𝕜 f₂ s₂) ∧
ContDiffOn 𝕜 n (deriv f₂) s₂ := by
rw [contDiffOn_succ_iff_derivWithin hs.uniqueDiffOn]
exact Iff.rfl.and (Iff.rfl.and (contDiffOn_congr fun _ => derivWithin_of_isOpen hs))
theorem contDiffOn_infty_iff_deriv_of_isOpen (hs : IsOpen s₂) :
ContDiffOn 𝕜 ∞ f₂ s₂ ↔ DifferentiableOn 𝕜 f₂ s₂ ∧ ContDiffOn 𝕜 ∞ (deriv f₂) s₂ := by
rw [show ∞ = ∞ + 1 by rfl, contDiffOn_succ_iff_deriv_of_isOpen hs]
simp
protected theorem ContDiffOn.derivWithin (hf : ContDiffOn 𝕜 n f₂ s₂) (hs : UniqueDiffOn 𝕜 s₂)
(hmn : m + 1 ≤ n) : ContDiffOn 𝕜 m (derivWithin f₂ s₂) s₂ :=
((contDiffOn_succ_iff_derivWithin hs).1 (hf.of_le hmn)).2.2
theorem ContDiffOn.deriv_of_isOpen (hf : ContDiffOn 𝕜 n f₂ s₂) (hs : IsOpen s₂) (hmn : m + 1 ≤ n) :
ContDiffOn 𝕜 m (deriv f₂) s₂ :=
(hf.derivWithin hs.uniqueDiffOn hmn).congr fun _ hx => (derivWithin_of_isOpen hs hx).symm
theorem ContDiffOn.continuousOn_derivWithin (h : ContDiffOn 𝕜 n f₂ s₂) (hs : UniqueDiffOn 𝕜 s₂)
(hn : 1 ≤ n) : ContinuousOn (derivWithin f₂ s₂) s₂ := by
rw [show (1 : WithTop ℕ∞) = 0 + 1 from rfl] at hn
exact ((contDiffOn_succ_iff_derivWithin hs).1 (h.of_le hn)).2.2.continuousOn
theorem ContDiffOn.continuousOn_deriv_of_isOpen (h : ContDiffOn 𝕜 n f₂ s₂) (hs : IsOpen s₂)
(hn : 1 ≤ n) : ContinuousOn (deriv f₂) s₂ := by
rw [show (1 : WithTop ℕ∞) = 0 + 1 from rfl] at hn
exact ((contDiffOn_succ_iff_deriv_of_isOpen hs).1 (h.of_le hn)).2.2.continuousOn
/-- 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 :
ContDiff 𝕜 (n + 1) f₂ ↔ Differentiable 𝕜 f₂ ∧ (n = ω → AnalyticOn 𝕜 f₂ univ) ∧
ContDiff 𝕜 n (deriv f₂) := by
simp only [← contDiffOn_univ, contDiffOn_succ_iff_deriv_of_isOpen, isOpen_univ,
differentiableOn_univ]
theorem contDiff_one_iff_deriv :
ContDiff 𝕜 1 f₂ ↔ Differentiable 𝕜 f₂ ∧ Continuous (deriv f₂) := by
rw [show (1 : WithTop ℕ∞) = 0 + 1 from rfl, contDiff_succ_iff_deriv]
simp
theorem contDiff_infty_iff_deriv :
ContDiff 𝕜 ∞ f₂ ↔ Differentiable 𝕜 f₂ ∧ ContDiff 𝕜 ∞ (deriv f₂) := by
rw [show (∞ : WithTop ℕ∞) = ∞ + 1 from rfl, contDiff_succ_iff_deriv]
simp
theorem ContDiff.continuous_deriv (h : ContDiff 𝕜 n f₂) (hn : 1 ≤ n) : Continuous (deriv f₂) := by
rw [show (1 : WithTop ℕ∞) = 0 + 1 from rfl] at hn
exact (contDiff_succ_iff_deriv.mp (h.of_le hn)).2.2.continuous
@[fun_prop]
theorem ContDiff.continuous_deriv_one (h : ContDiff 𝕜 1 f₂) : Continuous (deriv f₂) :=
ContDiff.continuous_deriv h (le_refl 1)
@[fun_prop]
theorem ContDiff.differentiable_deriv_two (h : ContDiff 𝕜 2 f₂) : Differentiable 𝕜 (deriv f₂) := by
unfold deriv; fun_prop
@[fun_prop]
theorem ContDiff.deriv' (h : ContDiff 𝕜 (n + 1) f₂) : ContDiff 𝕜 n (deriv f₂) := by
unfold deriv; fun_prop
@[fun_prop]
theorem ContDiff.iterate_deriv :
∀ (n : ℕ) {f₂ : 𝕜 → F}, ContDiff 𝕜 ∞ f₂ → ContDiff 𝕜 ∞ (deriv^[n] f₂)
| 0, _, hf => hf
| n + 1, _, hf => ContDiff.iterate_deriv n (contDiff_infty_iff_deriv.mp hf).2
@[fun_prop]
theorem ContDiff.iterate_deriv' (n : ℕ) :
∀ (k : ℕ) {f₂ : 𝕜 → F}, ContDiff 𝕜 (n + k : ℕ) f₂ → ContDiff 𝕜 n (deriv^[k] f₂)
| 0, _, hf => hf
| k + 1, _, hf => ContDiff.iterate_deriv' _ k (contDiff_succ_iff_deriv.mp hf).2.2
end deriv |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/ContDiff/FiniteDimension.lean | import Mathlib.Analysis.Calculus.ContDiff.Operations
import Mathlib.Analysis.Normed.Module.FiniteDimension
/-!
# Higher differentiability in finite dimensions.
-/
noncomputable section
universe uD uE uF
variable {𝕜 : Type*} [NontriviallyNormedField 𝕜]
{D : Type uD} [NormedAddCommGroup D] [NormedSpace 𝕜 D]
{E : Type uE} [NormedAddCommGroup E] [NormedSpace 𝕜 E]
{F : Type uF} [NormedAddCommGroup F] [NormedSpace 𝕜 F]
{n : WithTop ℕ∞} {f : D → E} {s : Set D}
/-! ### Finite-dimensional results -/
section FiniteDimensional
open Function Module
open scoped ContDiff
variable [CompleteSpace 𝕜]
/-- A family of continuous linear maps is `C^n` on `s` if all its applications are. -/
theorem contDiffOn_clm_apply {f : D → E →L[𝕜] F} {s : Set D} [FiniteDimensional 𝕜 E] :
ContDiffOn 𝕜 n f s ↔ ∀ y, ContDiffOn 𝕜 n (fun x => f x y) s := by
refine ⟨fun h y => h.clm_apply contDiffOn_const, fun h => ?_⟩
let d := finrank 𝕜 E
have hd : d = finrank 𝕜 (Fin d → 𝕜) := (finrank_fin_fun 𝕜).symm
let e₁ := ContinuousLinearEquiv.ofFinrankEq hd
let e₂ := (e₁.arrowCongr (1 : F ≃L[𝕜] F)).trans (ContinuousLinearEquiv.piRing (Fin d))
rw [← id_comp f, ← e₂.symm_comp_self]
exact e₂.symm.contDiff.comp_contDiffOn (contDiffOn_pi.mpr fun i => h _)
theorem contDiff_clm_apply_iff {f : D → E →L[𝕜] F} [FiniteDimensional 𝕜 E] :
ContDiff 𝕜 n f ↔ ∀ y, ContDiff 𝕜 n fun x => f x y := by
simp_rw [← contDiffOn_univ, contDiffOn_clm_apply]
/-- This is a useful lemma to prove that a certain operation preserves functions being `C^n`.
When you do induction on `n`, this gives a useful characterization of a function being `C^(n+1)`,
assuming you have already computed the derivative. The advantage of this version over
`contDiff_succ_iff_fderiv` is that both occurrences of `ContDiff` are for functions with the same
domain and codomain (`D` and `E`). This is not the case for `contDiff_succ_iff_fderiv`, which
often requires an inconvenient need to generalize `F`, which results in universe issues
(see the discussion in the section of `ContDiff.comp`).
This lemma avoids these universe issues, but only applies for finite-dimensional `D`. -/
theorem contDiff_succ_iff_fderiv_apply [FiniteDimensional 𝕜 D] :
ContDiff 𝕜 (n + 1) f ↔ Differentiable 𝕜 f ∧
(n = ω → AnalyticOnNhd 𝕜 f Set.univ) ∧ ∀ 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]
(hf : DifferentiableOn 𝕜 f s) (h'f : n = ω → AnalyticOn 𝕜 f s)
(h : ∀ y, ContDiffOn 𝕜 n (fun x => fderivWithin 𝕜 f s x y) s) :
ContDiffOn 𝕜 (n + 1) f s :=
contDiffOn_succ_of_fderivWithin hf h'f <| contDiffOn_clm_apply.mpr h
theorem contDiffOn_succ_iff_fderiv_apply [FiniteDimensional 𝕜 D] (hs : UniqueDiffOn 𝕜 s) :
ContDiffOn 𝕜 (n + 1) f s ↔
DifferentiableOn 𝕜 f s ∧ (n = ω → AnalyticOn 𝕜 f s) ∧
∀ y, ContDiffOn 𝕜 n (fun x => fderivWithin 𝕜 f s x y) s := by
rw [contDiffOn_succ_iff_fderivWithin hs, contDiffOn_clm_apply]
end FiniteDimensional |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/ContDiff/Operations.lean | import Mathlib.Analysis.Calculus.ContDiff.Basic
import Mathlib.Analysis.Calculus.Deriv.Inverse
/-!
# Higher differentiability of usual operations
We prove that the usual operations (addition, multiplication, difference, composition, and
so on) preserve `C^n` functions.
## Notation
We use the notation `E [×n]→L[𝕜] F` for the space of continuous multilinear maps on `E^n` with
values in `F`. This is the space in which the `n`-th derivative of a function from `E` to `F` lives.
In this file, we denote `(⊤ : ℕ∞) : WithTop ℕ∞` with `∞` and `⊤ : WithTop ℕ∞` with `ω`.
## Tags
derivative, differentiability, higher derivative, `C^n`, multilinear, Taylor series, formal series
-/
open scoped NNReal Nat ContDiff
universe u uE uF uG
attribute [local instance 1001]
NormedAddCommGroup.toAddCommGroup AddCommGroup.toAddCommMonoid
open Set Fin Filter Function
open scoped Topology
variable {𝕜 : Type*} [NontriviallyNormedField 𝕜]
{E : Type uE} [NormedAddCommGroup E] [NormedSpace 𝕜 E] {F : Type uF}
[NormedAddCommGroup F] [NormedSpace 𝕜 F] {G : Type uG} [NormedAddCommGroup G] [NormedSpace 𝕜 G]
{X : Type*} [NormedAddCommGroup X] [NormedSpace 𝕜 X] {s t : Set E} {f : E → F}
{g : F → G} {x x₀ : E} {b : E × F → G} {m n : WithTop ℕ∞} {p : E → FormalMultilinearSeries 𝕜 E F}
/-!
### Smoothness of functions `f : E → Π i, F' i`
-/
section Pi
variable {ι ι' : Type*} [Fintype ι] [Fintype ι'] {F' : ι → Type*} [∀ i, NormedAddCommGroup (F' 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 {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
set pr := @ContinuousLinearMap.proj 𝕜 _ ι F' _ _ _
set L : ∀ m : ℕ, (∀ i, E[×m]→L[𝕜] F' i) ≃ₗᵢ[𝕜] E[×m]→L[𝕜] ∀ i, F' i := fun m =>
ContinuousMultilinearMap.piₗᵢ _ _
refine ⟨fun h i => ?_, fun h => ⟨fun x hx => ?_, ?_, ?_⟩⟩
· exact h.continuousLinearMap_comp (pr i)
· ext1 i
exact (h i).zero_eq x hx
· intro m hm x hx
exact (L m).hasFDerivAt.comp_hasFDerivWithinAt x <|
hasFDerivWithinAt_pi.2 fun i => (h i).fderivWithin m hm x hx
· intro m hm
exact (L m).continuous.comp_continuousOn <| continuousOn_pi.2 fun i => (h i).cont m hm
@[simp]
theorem hasFTaylorSeriesUpToOn_pi' {n : WithTop ℕ∞} :
HasFTaylorSeriesUpToOn n Φ P' s ↔
∀ i, HasFTaylorSeriesUpToOn n (fun x => Φ x i)
(fun x m => (@ContinuousLinearMap.proj 𝕜 _ ι F' _ _ _ i).compContinuousMultilinearMap
(P' x m)) s := by
convert hasFTaylorSeriesUpToOn_pi (𝕜 := 𝕜) (φ := fun i x ↦ Φ x i); ext; rfl
theorem contDiffWithinAt_pi :
ContDiffWithinAt 𝕜 n Φ s x ↔ ∀ i, ContDiffWithinAt 𝕜 n (fun x => Φ x i) s x := by
set pr := @ContinuousLinearMap.proj 𝕜 _ ι F' _ _ _
refine ⟨fun h i => h.continuousLinearMap_comp (pr i), fun h ↦ ?_⟩
match n with
| ω =>
choose u hux p hp h'p using h
refine ⟨⋂ i, u i, Filter.iInter_mem.2 hux, _,
hasFTaylorSeriesUpToOn_pi.2 fun i => (hp i).mono <| iInter_subset _ _, fun m ↦ ?_⟩
set L : (∀ i, E[×m]→L[𝕜] F' i) ≃ₗᵢ[𝕜] E[×m]→L[𝕜] ∀ i, F' i :=
ContinuousMultilinearMap.piₗᵢ _ _
change AnalyticOn 𝕜 (fun x ↦ L (fun i ↦ p i x m)) (⋂ i, u i)
apply (L.analyticOnNhd univ).comp_analyticOn ?_ (mapsTo_univ _ _)
exact AnalyticOn.pi (fun i ↦ (h'p i m).mono (iInter_subset _ _))
| (n : ℕ∞) =>
intro m hm
choose u hux p hp using fun i => h i m hm
exact ⟨⋂ i, u i, Filter.iInter_mem.2 hux, _,
hasFTaylorSeriesUpToOn_pi.2 fun i => (hp i).mono <| iInter_subset _ _⟩
theorem contDiffOn_pi : ContDiffOn 𝕜 n Φ s ↔ ∀ i, ContDiffOn 𝕜 n (fun x => Φ x i) s :=
⟨fun h _ x hx => contDiffWithinAt_pi.1 (h x hx) _, fun h x hx =>
contDiffWithinAt_pi.2 fun i => h i x hx⟩
theorem contDiffAt_pi : ContDiffAt 𝕜 n Φ x ↔ ∀ i, ContDiffAt 𝕜 n (fun x => Φ x i) x :=
contDiffWithinAt_pi
theorem contDiff_pi : ContDiff 𝕜 n Φ ↔ ∀ i, ContDiff 𝕜 n fun x => Φ x i := by
simp only [← contDiffOn_univ, contDiffOn_pi]
@[fun_prop]
theorem contDiff_pi' (hΦ : ∀ i, ContDiff 𝕜 n fun x => Φ x i) : ContDiff 𝕜 n Φ :=
contDiff_pi.2 hΦ
@[fun_prop]
theorem contDiffOn_pi' (hΦ : ∀ i, ContDiffOn 𝕜 n (fun x => Φ x i) s) : ContDiffOn 𝕜 n Φ s :=
contDiffOn_pi.2 hΦ
@[fun_prop]
theorem contDiffAt_pi' (hΦ : ∀ i, ContDiffAt 𝕜 n (fun x => Φ x i) x) : ContDiffAt 𝕜 n Φ x :=
contDiffAt_pi.2 hΦ
theorem contDiff_update [DecidableEq ι] (k : WithTop ℕ∞) (x : ∀ i, F' i) (i : ι) :
ContDiff 𝕜 k (update x i) := by
rw [contDiff_pi]
intro j
dsimp [Function.update]
split_ifs with h
· subst h
exact contDiff_id
· exact contDiff_const
variable (F') in
theorem contDiff_single [DecidableEq ι] (k : WithTop ℕ∞) (i : ι) :
ContDiff 𝕜 k (Pi.single i : F' i → ∀ i, F' i) :=
contDiff_update k 0 i
variable (𝕜 E)
@[fun_prop]
theorem contDiff_apply (i : ι) : ContDiff 𝕜 n fun f : ι → E => f i :=
contDiff_pi.mp contDiff_id i
@[fun_prop]
theorem contDiffAt_apply (i : ι) (f : ι → E) : ContDiffAt 𝕜 n (fun f : ι → E => f i) f :=
(contDiff_apply 𝕜 E i).contDiffAt
@[fun_prop]
theorem contDiffOn_apply (i : ι) (s : Set (ι → E)) : ContDiffOn 𝕜 n (fun f : ι → E => f i) s :=
(contDiff_apply 𝕜 E i).contDiffOn
theorem contDiff_apply_apply (i : ι) (j : ι') : ContDiff 𝕜 n fun f : ι → ι' → E => f i j :=
contDiff_pi.mp (contDiff_apply 𝕜 (ι' → E) i) j
end Pi
/-! ### Sum of two functions -/
section Add
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
exact HasFTaylorSeriesUpToOn.continuousLinearMap_comp
(ContinuousLinearMap.fst 𝕜 F F + .snd 𝕜 F F) (hf.prodMk hg)
-- The sum is smooth.
@[fun_prop]
theorem contDiff_add : ContDiff 𝕜 n fun p : F × F => p.1 + p.2 :=
(IsBoundedLinearMap.fst.add IsBoundedLinearMap.snd).contDiff
/-- The sum of two `C^n` functions within a set at a point is `C^n` within this set
at this point. -/
@[fun_prop]
theorem ContDiffWithinAt.add {s : Set E} {f g : E → F} (hf : ContDiffWithinAt 𝕜 n f s x)
(hg : ContDiffWithinAt 𝕜 n g s x) : ContDiffWithinAt 𝕜 n (fun x => f x + g x) s x :=
contDiff_add.contDiffWithinAt.comp x (hf.prodMk hg) subset_preimage_univ
/-- The sum of two `C^n` functions at a point is `C^n` at this point. -/
@[fun_prop]
theorem ContDiffAt.add {f g : E → F} (hf : ContDiffAt 𝕜 n f x) (hg : ContDiffAt 𝕜 n g x) :
ContDiffAt 𝕜 n (fun x => f x + g x) x := by
rw [← contDiffWithinAt_univ] at *; exact hf.add hg
/-- The sum of two `C^n`functions is `C^n`. -/
@[fun_prop]
theorem ContDiff.add {f g : E → F} (hf : ContDiff 𝕜 n f) (hg : ContDiff 𝕜 n g) :
ContDiff 𝕜 n fun x => f x + g x :=
contDiff_add.comp (hf.prodMk hg)
/-- The sum of two `C^n` functions on a domain is `C^n`. -/
@[fun_prop]
theorem ContDiffOn.add {s : Set E} {f g : E → F} (hf : ContDiffOn 𝕜 n f s)
(hg : ContDiffOn 𝕜 n g s) : ContDiffOn 𝕜 n (fun x => f x + g x) s := fun x hx =>
(hf x hx).add (hg x hx)
variable {i : ℕ}
/-- The iterated derivative of the sum of two functions is the sum of the iterated derivatives.
See also `iteratedFDerivWithin_add_apply'`, which uses the spelling `(fun x ↦ f x + g x)`
instead of `f + g`. -/
theorem iteratedFDerivWithin_add_apply {f g : E → F} (hf : ContDiffWithinAt 𝕜 i f s x)
(hg : ContDiffWithinAt 𝕜 i g s x) (hu : UniqueDiffOn 𝕜 s) (hx : x ∈ s) :
iteratedFDerivWithin 𝕜 i (f + g) s x =
iteratedFDerivWithin 𝕜 i f s x + iteratedFDerivWithin 𝕜 i g s x := by
have := (hf.eventually (by simp)).and (hg.eventually (by simp))
obtain ⟨t, ht, hxt, h⟩ := mem_nhdsWithin.mp this
have hft : ContDiffOn 𝕜 i f (s ∩ t) := fun a ha ↦ (h (by simp_all)).1.mono inter_subset_left
have hgt : ContDiffOn 𝕜 i g (s ∩ t) := fun a ha ↦ (h (by simp_all)).2.mono inter_subset_left
have hut : UniqueDiffOn 𝕜 (s ∩ t) := hu.inter ht
have H : ↑(s ∩ t) =ᶠ[𝓝 x] s :=
inter_eventuallyEq_left.mpr (eventually_of_mem (ht.mem_nhds hxt) (fun _ h _ ↦ h))
rw [← iteratedFDerivWithin_congr_set H, ← iteratedFDerivWithin_congr_set H,
← iteratedFDerivWithin_congr_set H]
exact .symm (((hft.ftaylorSeriesWithin hut).add
(hgt.ftaylorSeriesWithin hut)).eq_iteratedFDerivWithin_of_uniqueDiffOn le_rfl hut ⟨hx, hxt⟩)
/-- The iterated derivative of the sum of two functions is the sum of the iterated derivatives.
This is the same as `iteratedFDerivWithin_add_apply`, but using the spelling `(fun x ↦ f x + g x)`
instead of `f + g`, which can be handy for some rewrites.
TODO: use one form consistently. -/
theorem iteratedFDerivWithin_add_apply' {f g : E → F} (hf : ContDiffWithinAt 𝕜 i f s x)
(hg : ContDiffWithinAt 𝕜 i g s x) (hu : UniqueDiffOn 𝕜 s) (hx : x ∈ s) :
iteratedFDerivWithin 𝕜 i (fun x => f x + g x) s x =
iteratedFDerivWithin 𝕜 i f s x + iteratedFDerivWithin 𝕜 i g s x :=
iteratedFDerivWithin_add_apply hf hg hu hx
theorem iteratedFDeriv_add_apply {i : ℕ} {f g : E → F}
(hf : ContDiffAt 𝕜 i f x) (hg : ContDiffAt 𝕜 i g x) :
iteratedFDeriv 𝕜 i (f + g) x = iteratedFDeriv 𝕜 i f x + iteratedFDeriv 𝕜 i g x := by
simp_rw [← iteratedFDerivWithin_univ]
exact iteratedFDerivWithin_add_apply hf hg uniqueDiffOn_univ (Set.mem_univ _)
theorem iteratedFDeriv_add_apply' {i : ℕ} {f g : E → F} (hf : ContDiffAt 𝕜 i f x)
(hg : ContDiffAt 𝕜 i g x) :
iteratedFDeriv 𝕜 i (fun x => f x + g x) x = iteratedFDeriv 𝕜 i f x + iteratedFDeriv 𝕜 i g x :=
iteratedFDeriv_add_apply hf hg
theorem iteratedFDeriv_add {i : ℕ} {f g : E → F} (hf : ContDiff 𝕜 i f) (hg : ContDiff 𝕜 i g) :
iteratedFDeriv 𝕜 i (f + g) = iteratedFDeriv 𝕜 i f + iteratedFDeriv 𝕜 i g :=
funext fun _ ↦ iteratedFDeriv_add_apply (ContDiff.contDiffAt hf) (ContDiff.contDiffAt hg)
end Add
/-! ### Negative -/
section Neg
-- The negative is smooth.
@[fun_prop]
theorem contDiff_neg : ContDiff 𝕜 n fun p : F => -p :=
IsBoundedLinearMap.id.neg.contDiff
/-- The negative of a `C^n` function within a domain at a point is `C^n` within this domain at
this point. -/
@[fun_prop]
theorem ContDiffWithinAt.neg {s : Set E} {f : E → F} (hf : ContDiffWithinAt 𝕜 n f s x) :
ContDiffWithinAt 𝕜 n (fun x => -f x) s x :=
contDiff_neg.contDiffWithinAt.comp x hf subset_preimage_univ
/-- The negative of a `C^n` function at a point is `C^n` at this point. -/
@[fun_prop]
theorem ContDiffAt.neg {f : E → F} (hf : ContDiffAt 𝕜 n f x) :
ContDiffAt 𝕜 n (fun x => -f x) x := by rw [← contDiffWithinAt_univ] at *; exact hf.neg
/-- The negative of a `C^n`function is `C^n`. -/
@[fun_prop]
theorem ContDiff.neg {f : E → F} (hf : ContDiff 𝕜 n f) : ContDiff 𝕜 n fun x => -f x :=
contDiff_neg.comp hf
/-- The negative of a `C^n` function on a domain is `C^n`. -/
@[fun_prop]
theorem ContDiffOn.neg {s : Set E} {f : E → F} (hf : ContDiffOn 𝕜 n f s) :
ContDiffOn 𝕜 n (fun x => -f x) s := fun x hx => (hf x hx).neg
variable {i : ℕ}
-- TODO: define `Neg` instance on `ContinuousLinearEquiv`,
-- prove it from `ContinuousLinearEquiv.iteratedFDerivWithin_comp_left`
theorem iteratedFDerivWithin_neg_apply {f : E → F} (hu : UniqueDiffOn 𝕜 s) (hx : x ∈ s) :
iteratedFDerivWithin 𝕜 i (-f) s x = -iteratedFDerivWithin 𝕜 i f s x := by
induction i generalizing x with ext h
| zero => simp
| succ i hi =>
calc
iteratedFDerivWithin 𝕜 (i + 1) (-f) s x h =
fderivWithin 𝕜 (iteratedFDerivWithin 𝕜 i (-f) s) s x (h 0) (Fin.tail h) :=
iteratedFDerivWithin_succ_apply_left _
_ = fderivWithin 𝕜 (-iteratedFDerivWithin 𝕜 i f s) s x (h 0) (Fin.tail h) := by
rw [fderivWithin_congr' (@hi) hx, Pi.neg_def]
_ = -(fderivWithin 𝕜 (iteratedFDerivWithin 𝕜 i f s) s) x (h 0) (Fin.tail h) := by
rw [fderivWithin_neg (hu x hx), ContinuousLinearMap.neg_apply,
ContinuousMultilinearMap.neg_apply]
_ = -(iteratedFDerivWithin 𝕜 (i + 1) f s) x h := by
rw [iteratedFDerivWithin_succ_apply_left]
theorem iteratedFDeriv_neg_apply {i : ℕ} {f : E → F} :
iteratedFDeriv 𝕜 i (-f) x = -iteratedFDeriv 𝕜 i f x := by
simp_rw [← iteratedFDerivWithin_univ]
exact iteratedFDerivWithin_neg_apply uniqueDiffOn_univ (Set.mem_univ _)
theorem iteratedFDeriv_neg {i : ℕ} {f : E → F} :
iteratedFDeriv 𝕜 i (-f) = -iteratedFDeriv 𝕜 i f :=
funext fun _ ↦ iteratedFDeriv_neg_apply
end Neg
/-! ### Subtraction -/
/-- The difference of two `C^n` functions within a set at a point is `C^n` within this set
at this point. -/
@[fun_prop]
theorem ContDiffWithinAt.sub {s : Set E} {f g : E → F} (hf : ContDiffWithinAt 𝕜 n f s x)
(hg : ContDiffWithinAt 𝕜 n g s x) : ContDiffWithinAt 𝕜 n (fun x => f x - g x) s x := by
simpa only [sub_eq_add_neg] using hf.add hg.neg
/-- The difference of two `C^n` functions at a point is `C^n` at this point. -/
@[fun_prop]
theorem ContDiffAt.sub {f g : E → F} (hf : ContDiffAt 𝕜 n f x) (hg : ContDiffAt 𝕜 n g x) :
ContDiffAt 𝕜 n (fun x => f x - g x) x := by simpa only [sub_eq_add_neg] using hf.add hg.neg
/-- The difference of two `C^n` functions on a domain is `C^n`. -/
@[fun_prop]
theorem ContDiffOn.sub {s : Set E} {f g : E → F} (hf : ContDiffOn 𝕜 n f s)
(hg : ContDiffOn 𝕜 n g s) : ContDiffOn 𝕜 n (fun x => f x - g x) s := by
simpa only [sub_eq_add_neg] using hf.add hg.neg
/-- The difference of two `C^n` functions is `C^n`. -/
@[fun_prop]
theorem ContDiff.sub {f g : E → F} (hf : ContDiff 𝕜 n f) (hg : ContDiff 𝕜 n g) :
ContDiff 𝕜 n fun x => f x - g x := by simpa only [sub_eq_add_neg] using hf.add hg.neg
/-! ### Sum of finitely many functions -/
@[fun_prop]
theorem ContDiffWithinAt.sum {ι : Type*} {f : ι → E → F} {s : Finset ι} {t : Set E} {x : E}
(h : ∀ i ∈ s, ContDiffWithinAt 𝕜 n (fun x => f i x) t x) :
ContDiffWithinAt 𝕜 n (fun x => ∑ i ∈ s, f i x) t x := by
classical
induction s using Finset.induction_on with
| empty => simp [contDiffWithinAt_const]
| insert i s is IH =>
simp only [is, Finset.sum_insert, not_false_iff]
exact (h _ (Finset.mem_insert_self i s)).add
(IH fun j hj => h _ (Finset.mem_insert_of_mem hj))
@[fun_prop]
theorem ContDiffAt.sum {ι : Type*} {f : ι → E → F} {s : Finset ι} {x : E}
(h : ∀ i ∈ s, ContDiffAt 𝕜 n (fun x => f i x) x) :
ContDiffAt 𝕜 n (fun x => ∑ i ∈ s, f i x) x := by
rw [← contDiffWithinAt_univ] at *; exact ContDiffWithinAt.sum h
@[fun_prop]
theorem ContDiffOn.sum {ι : Type*} {f : ι → E → F} {s : Finset ι} {t : Set E}
(h : ∀ i ∈ s, ContDiffOn 𝕜 n (fun x => f i x) t) :
ContDiffOn 𝕜 n (fun x => ∑ i ∈ s, f i x) t := fun x hx =>
ContDiffWithinAt.sum fun i hi => h i hi x hx
@[fun_prop]
theorem ContDiff.sum {ι : Type*} {f : ι → E → F} {s : Finset ι}
(h : ∀ i ∈ s, ContDiff 𝕜 n fun x => f i x) : ContDiff 𝕜 n fun x => ∑ i ∈ s, f i x := by
simp only [← contDiffOn_univ] at *; exact ContDiffOn.sum h
theorem iteratedFDerivWithin_sum_apply {ι : Type*} {f : ι → E → F} {u : Finset ι} {i : ℕ} {x : E}
(hs : UniqueDiffOn 𝕜 s) (hx : x ∈ s) (h : ∀ j ∈ u, ContDiffWithinAt 𝕜 i (f j) s x) :
iteratedFDerivWithin 𝕜 i (∑ j ∈ u, f j ·) s x =
∑ j ∈ u, iteratedFDerivWithin 𝕜 i (f j) s x := by
induction u using Finset.cons_induction with
| empty => simp
| cons a u ha IH =>
simp only [Finset.mem_cons, forall_eq_or_imp] at h
simp only [Finset.sum_cons]
rw [iteratedFDerivWithin_add_apply' h.1 (ContDiffWithinAt.sum h.2) hs hx, IH h.2]
theorem iteratedFDeriv_sum {ι : Type*} {f : ι → E → F} {u : Finset ι} {i : ℕ}
(h : ∀ j ∈ u, ContDiff 𝕜 i (f j)) :
iteratedFDeriv 𝕜 i (∑ j ∈ u, f j ·) = ∑ j ∈ u, iteratedFDeriv 𝕜 i (f j) :=
funext fun x ↦ by simpa [iteratedFDerivWithin_univ] using
iteratedFDerivWithin_sum_apply uniqueDiffOn_univ (mem_univ x) (h · · |>.contDiffWithinAt)
/-! ### Product of two functions -/
section MulProd
variable {𝔸 𝔸' ι 𝕜' : Type*} [NormedRing 𝔸] [NormedAlgebra 𝕜 𝔸] [NormedCommRing 𝔸']
[NormedAlgebra 𝕜 𝔸'] [NormedField 𝕜'] [NormedAlgebra 𝕜 𝕜']
-- The product is smooth.
@[fun_prop]
theorem contDiff_mul : ContDiff 𝕜 n fun p : 𝔸 × 𝔸 => p.1 * p.2 :=
(ContinuousLinearMap.mul 𝕜 𝔸).isBoundedBilinearMap.contDiff
/-- The product of two `C^n` functions within a set at a point is `C^n` within this set
at this point. -/
@[fun_prop]
theorem ContDiffWithinAt.mul {s : Set E} {f g : E → 𝔸} (hf : ContDiffWithinAt 𝕜 n f s x)
(hg : ContDiffWithinAt 𝕜 n g s x) : ContDiffWithinAt 𝕜 n (fun x => f x * g x) s x :=
contDiff_mul.comp_contDiffWithinAt (hf.prodMk hg)
/-- The product of two `C^n` functions at a point is `C^n` at this point. -/
@[fun_prop]
nonrec theorem ContDiffAt.mul {f g : E → 𝔸} (hf : ContDiffAt 𝕜 n f x) (hg : ContDiffAt 𝕜 n g x) :
ContDiffAt 𝕜 n (fun x => f x * g x) x :=
hf.mul hg
/-- The product of two `C^n` functions on a domain is `C^n`. -/
@[fun_prop]
theorem ContDiffOn.mul {f g : E → 𝔸} (hf : ContDiffOn 𝕜 n f s) (hg : ContDiffOn 𝕜 n g s) :
ContDiffOn 𝕜 n (fun x => f x * g x) s := fun x hx => (hf x hx).mul (hg x hx)
/-- The product of two `C^n`functions is `C^n`. -/
@[fun_prop]
theorem ContDiff.mul {f g : E → 𝔸} (hf : ContDiff 𝕜 n f) (hg : ContDiff 𝕜 n g) :
ContDiff 𝕜 n fun x => f x * g x :=
contDiff_mul.comp (hf.prodMk hg)
@[fun_prop]
theorem contDiffWithinAt_prod' {t : Finset ι} {f : ι → E → 𝔸'}
(h : ∀ i ∈ t, ContDiffWithinAt 𝕜 n (f i) s x) : ContDiffWithinAt 𝕜 n (∏ i ∈ t, f i) s x :=
Finset.prod_induction f (fun f => ContDiffWithinAt 𝕜 n f s x) (fun _ _ => ContDiffWithinAt.mul)
(contDiffWithinAt_const (c := 1)) h
@[fun_prop]
theorem contDiffWithinAt_prod {t : Finset ι} {f : ι → E → 𝔸'}
(h : ∀ i ∈ t, ContDiffWithinAt 𝕜 n (f i) s x) :
ContDiffWithinAt 𝕜 n (fun y => ∏ i ∈ t, f i y) s x := by
simpa only [← Finset.prod_apply] using contDiffWithinAt_prod' h
@[fun_prop]
theorem contDiffAt_prod' {t : Finset ι} {f : ι → E → 𝔸'} (h : ∀ i ∈ t, ContDiffAt 𝕜 n (f i) x) :
ContDiffAt 𝕜 n (∏ i ∈ t, f i) x :=
contDiffWithinAt_prod' h
@[fun_prop]
theorem contDiffAt_prod {t : Finset ι} {f : ι → E → 𝔸'} (h : ∀ i ∈ t, ContDiffAt 𝕜 n (f i) x) :
ContDiffAt 𝕜 n (fun y => ∏ i ∈ t, f i y) x :=
contDiffWithinAt_prod h
@[fun_prop]
theorem contDiffOn_prod' {t : Finset ι} {f : ι → E → 𝔸'} (h : ∀ i ∈ t, ContDiffOn 𝕜 n (f i) s) :
ContDiffOn 𝕜 n (∏ i ∈ t, f i) s := fun x hx => contDiffWithinAt_prod' fun i hi => h i hi x hx
@[fun_prop]
theorem contDiffOn_prod {t : Finset ι} {f : ι → E → 𝔸'} (h : ∀ i ∈ t, ContDiffOn 𝕜 n (f i) s) :
ContDiffOn 𝕜 n (fun y => ∏ i ∈ t, f i y) s := fun x hx =>
contDiffWithinAt_prod fun i hi => h i hi x hx
@[fun_prop]
theorem contDiff_prod' {t : Finset ι} {f : ι → E → 𝔸'} (h : ∀ i ∈ t, ContDiff 𝕜 n (f i)) :
ContDiff 𝕜 n (∏ i ∈ t, f i) :=
contDiff_iff_contDiffAt.mpr fun _ => contDiffAt_prod' fun i hi => (h i hi).contDiffAt
@[fun_prop]
theorem contDiff_prod {t : Finset ι} {f : ι → E → 𝔸'} (h : ∀ i ∈ t, ContDiff 𝕜 n (f i)) :
ContDiff 𝕜 n fun y => ∏ i ∈ t, f i y :=
contDiff_iff_contDiffAt.mpr fun _ => contDiffAt_prod fun i hi => (h i hi).contDiffAt
@[fun_prop]
theorem ContDiff.pow {f : E → 𝔸} (hf : ContDiff 𝕜 n f) : ∀ m : ℕ, ContDiff 𝕜 n fun x => f x ^ m
| 0 => by simpa using contDiff_const
| m + 1 => by simpa [pow_succ] using (hf.pow m).mul hf
@[fun_prop]
theorem ContDiffWithinAt.pow {f : E → 𝔸} (hf : ContDiffWithinAt 𝕜 n f s x) (m : ℕ) :
ContDiffWithinAt 𝕜 n (fun y => f y ^ m) s x :=
(contDiff_id.pow m).comp_contDiffWithinAt hf
@[fun_prop]
nonrec theorem ContDiffAt.pow {f : E → 𝔸} (hf : ContDiffAt 𝕜 n f x) (m : ℕ) :
ContDiffAt 𝕜 n (fun y => f y ^ m) x :=
hf.pow m
@[fun_prop]
theorem ContDiffOn.pow {f : E → 𝔸} (hf : ContDiffOn 𝕜 n f s) (m : ℕ) :
ContDiffOn 𝕜 n (fun y => f y ^ m) s := fun y hy => (hf y hy).pow m
@[fun_prop]
theorem ContDiffWithinAt.div_const {f : E → 𝕜'} {n} (hf : ContDiffWithinAt 𝕜 n f s x) (c : 𝕜') :
ContDiffWithinAt 𝕜 n (fun x => f x / c) s x := by
simpa only [div_eq_mul_inv] using hf.mul contDiffWithinAt_const
@[fun_prop]
nonrec theorem ContDiffAt.div_const {f : E → 𝕜'} {n} (hf : ContDiffAt 𝕜 n f x) (c : 𝕜') :
ContDiffAt 𝕜 n (fun x => f x / c) x :=
hf.div_const c
@[fun_prop]
theorem ContDiffOn.div_const {f : E → 𝕜'} {n} (hf : ContDiffOn 𝕜 n f s) (c : 𝕜') :
ContDiffOn 𝕜 n (fun x => f x / c) s := fun x hx => (hf x hx).div_const c
@[fun_prop]
theorem ContDiff.div_const {f : E → 𝕜'} {n} (hf : ContDiff 𝕜 n f) (c : 𝕜') :
ContDiff 𝕜 n fun x => f x / c := by simpa only [div_eq_mul_inv] using hf.mul contDiff_const
end MulProd
/-! ### Scalar multiplication -/
section SMul
-- The scalar multiplication is smooth.
@[fun_prop]
theorem contDiff_smul : ContDiff 𝕜 n fun p : 𝕜 × F => p.1 • p.2 :=
isBoundedBilinearMap_smul.contDiff
/-- The scalar multiplication of two `C^n` functions within a set at a point is `C^n` within this
set at this point. -/
@[fun_prop]
theorem ContDiffWithinAt.smul {s : Set E} {f : E → 𝕜} {g : E → F} (hf : ContDiffWithinAt 𝕜 n f s x)
(hg : ContDiffWithinAt 𝕜 n g s x) : ContDiffWithinAt 𝕜 n (fun x => f x • g x) s x :=
contDiff_smul.contDiffWithinAt.comp x (hf.prodMk hg) subset_preimage_univ
/-- The scalar multiplication of two `C^n` functions at a point is `C^n` at this point. -/
@[fun_prop]
theorem ContDiffAt.smul {f : E → 𝕜} {g : E → F} (hf : ContDiffAt 𝕜 n f x)
(hg : ContDiffAt 𝕜 n g x) : ContDiffAt 𝕜 n (fun x => f x • g x) x := by
rw [← contDiffWithinAt_univ] at *; exact hf.smul hg
/-- The scalar multiplication of two `C^n` functions is `C^n`. -/
@[fun_prop]
theorem ContDiff.smul {f : E → 𝕜} {g : E → F} (hf : ContDiff 𝕜 n f) (hg : ContDiff 𝕜 n g) :
ContDiff 𝕜 n fun x => f x • g x :=
contDiff_smul.comp (hf.prodMk hg)
/-- The scalar multiplication of two `C^n` functions on a domain is `C^n`. -/
@[fun_prop]
theorem ContDiffOn.smul {s : Set E} {f : E → 𝕜} {g : E → F} (hf : ContDiffOn 𝕜 n f s)
(hg : ContDiffOn 𝕜 n g s) : ContDiffOn 𝕜 n (fun x => f x • g x) s := fun x hx =>
(hf x hx).smul (hg x hx)
end SMul
/-! ### Constant scalar multiplication
TODO: generalize results in this section.
1. It should be possible to assume `[Monoid R] [DistribMulAction R F] [SMulCommClass 𝕜 R F]`.
2. If `c` is a unit (or `R` is a group), then one can drop `ContDiff*` assumptions in some
lemmas.
-/
section ConstSMul
variable {R : Type*} [Semiring R] [Module R F] [SMulCommClass 𝕜 R F]
variable [ContinuousConstSMul R F]
-- The scalar multiplication with a constant is smooth.
@[fun_prop]
theorem contDiff_const_smul (c : R) : ContDiff 𝕜 n fun p : F => c • p :=
(c • ContinuousLinearMap.id 𝕜 F).contDiff
/-- The scalar multiplication of a constant and a `C^n` function within a set at a point is `C^n`
within this set at this point. -/
@[fun_prop]
theorem ContDiffWithinAt.const_smul {s : Set E} {f : E → F} {x : E} (c : R)
(hf : ContDiffWithinAt 𝕜 n f s x) : ContDiffWithinAt 𝕜 n (fun y => c • f y) s x :=
(contDiff_const_smul c).contDiffAt.comp_contDiffWithinAt x hf
/-- The scalar multiplication of a constant and a `C^n` function at a point is `C^n` at this
point. -/
@[fun_prop]
theorem ContDiffAt.const_smul {f : E → F} {x : E} (c : R) (hf : ContDiffAt 𝕜 n f x) :
ContDiffAt 𝕜 n (fun y => c • f y) x := by
rw [← contDiffWithinAt_univ] at *; exact hf.const_smul c
/-- The scalar multiplication of a constant and a `C^n` function is `C^n`. -/
@[fun_prop]
theorem ContDiff.const_smul {f : E → F} (c : R) (hf : ContDiff 𝕜 n f) :
ContDiff 𝕜 n fun y => c • f y :=
(contDiff_const_smul c).comp hf
/-- The scalar multiplication of a constant and a `C^n` on a domain is `C^n`. -/
@[fun_prop]
theorem ContDiffOn.const_smul {s : Set E} {f : E → F} (c : R) (hf : ContDiffOn 𝕜 n f s) :
ContDiffOn 𝕜 n (fun y => c • f y) s := fun x hx => (hf x hx).const_smul c
variable {i : ℕ} {a : R}
theorem iteratedFDerivWithin_const_smul_apply (hf : ContDiffWithinAt 𝕜 i f s x)
(hu : UniqueDiffOn 𝕜 s) (hx : x ∈ s) :
iteratedFDerivWithin 𝕜 i (a • f) s x = a • iteratedFDerivWithin 𝕜 i f s x :=
(a • (1 : F →L[𝕜] F)).iteratedFDerivWithin_comp_left hf hu hx le_rfl
theorem iteratedFDeriv_const_smul_apply (hf : ContDiffAt 𝕜 i f x) :
iteratedFDeriv 𝕜 i (a • f) x = a • iteratedFDeriv 𝕜 i f x :=
(a • (1 : F →L[𝕜] F)).iteratedFDeriv_comp_left hf le_rfl
theorem iteratedFDeriv_const_smul_apply' (hf : ContDiffAt 𝕜 i f x) :
iteratedFDeriv 𝕜 i (fun x ↦ a • f x) x = a • iteratedFDeriv 𝕜 i f x :=
iteratedFDeriv_const_smul_apply hf
end ConstSMul
/-! ### Cartesian product of two functions -/
section prodMap
variable {E' : Type*} [NormedAddCommGroup E'] [NormedSpace 𝕜 E']
variable {F' : Type*} [NormedAddCommGroup F'] [NormedSpace 𝕜 F']
/-- The product map of two `C^n` functions within a set at a point is `C^n`
within the product set at the product point. -/
@[fun_prop]
theorem ContDiffWithinAt.prodMap' {s : Set E} {t : Set E'} {f : E → F} {g : E' → F'} {p : E × E'}
(hf : ContDiffWithinAt 𝕜 n f s p.1) (hg : ContDiffWithinAt 𝕜 n g t p.2) :
ContDiffWithinAt 𝕜 n (Prod.map f g) (s ×ˢ t) p :=
(hf.comp p contDiffWithinAt_fst (prod_subset_preimage_fst _ _)).prodMk
(hg.comp p contDiffWithinAt_snd (prod_subset_preimage_snd _ _))
@[fun_prop]
theorem ContDiffWithinAt.prodMap {s : Set E} {t : Set E'} {f : E → F} {g : E' → F'} {x : E} {y : E'}
(hf : ContDiffWithinAt 𝕜 n f s x) (hg : ContDiffWithinAt 𝕜 n g t y) :
ContDiffWithinAt 𝕜 n (Prod.map f g) (s ×ˢ t) (x, y) :=
ContDiffWithinAt.prodMap' hf hg
/-- The product map of two `C^n` functions on a set is `C^n` on the product set. -/
@[fun_prop]
theorem ContDiffOn.prodMap {E' : Type*} [NormedAddCommGroup E'] [NormedSpace 𝕜 E'] {F' : Type*}
[NormedAddCommGroup F'] [NormedSpace 𝕜 F'] {s : Set E} {t : Set E'} {f : E → F} {g : E' → F'}
(hf : ContDiffOn 𝕜 n f s) (hg : ContDiffOn 𝕜 n g t) : ContDiffOn 𝕜 n (Prod.map f g) (s ×ˢ t) :=
(hf.comp contDiffOn_fst (prod_subset_preimage_fst _ _)).prodMk
(hg.comp contDiffOn_snd (prod_subset_preimage_snd _ _))
/-- The product map of two `C^n` functions within a set at a point is `C^n`
within the product set at the product point. -/
@[fun_prop]
theorem ContDiffAt.prodMap {f : E → F} {g : E' → F'} {x : E} {y : E'} (hf : ContDiffAt 𝕜 n f x)
(hg : ContDiffAt 𝕜 n g y) : ContDiffAt 𝕜 n (Prod.map f g) (x, y) := by
rw [ContDiffAt] at *
simpa only [univ_prod_univ] using hf.prodMap hg
/-- The product map of two `C^n` functions within a set at a point is `C^n`
within the product set at the product point. -/
@[fun_prop]
theorem ContDiffAt.prodMap' {f : E → F} {g : E' → F'} {p : E × E'} (hf : ContDiffAt 𝕜 n f p.1)
(hg : ContDiffAt 𝕜 n g p.2) : ContDiffAt 𝕜 n (Prod.map f g) p :=
hf.prodMap hg
/-- The product map of two `C^n` functions is `C^n`. -/
@[fun_prop]
theorem ContDiff.prodMap {f : E → F} {g : E' → F'} (hf : ContDiff 𝕜 n f) (hg : ContDiff 𝕜 n g) :
ContDiff 𝕜 n (Prod.map f g) := by
rw [contDiff_iff_contDiffAt] at *
exact fun ⟨x, y⟩ => (hf x).prodMap (hg y)
@[fun_prop]
theorem contDiff_prodMk_left (f₀ : F) : ContDiff 𝕜 n fun e : E => (e, f₀) :=
contDiff_id.prodMk contDiff_const
@[fun_prop]
theorem contDiff_prodMk_right (e₀ : E) : ContDiff 𝕜 n fun f : F => (e₀, f) :=
contDiff_const.prodMk contDiff_id
end prodMap
/-!
### Inversion in a complete normed algebra (or more generally with summable geometric series)
-/
section AlgebraInverse
variable (𝕜)
variable {R : Type*} [NormedRing R] [NormedAlgebra 𝕜 R]
open NormedRing ContinuousLinearMap Ring
/-- In a complete normed algebra, the operation of inversion is `C^n`, for all `n`, at each
invertible element, as it is analytic. -/
@[fun_prop]
theorem contDiffAt_ringInverse [HasSummableGeomSeries R] (x : Rˣ) :
ContDiffAt 𝕜 n Ring.inverse (x : R) := by
have := AnalyticOnNhd.contDiffOn (analyticOnNhd_inverse (𝕜 := 𝕜) (A := R)) (n := n)
Units.isOpen.uniqueDiffOn x x.isUnit
exact this.contDiffAt (Units.isOpen.mem_nhds x.isUnit)
@[deprecated (since := "2025-04-22")] alias contDiffAt_ring_inverse := contDiffAt_ringInverse
variable {𝕜' : Type*} [NormedField 𝕜'] [NormedAlgebra 𝕜 𝕜']
@[fun_prop]
theorem contDiffAt_inv {x : 𝕜'} (hx : x ≠ 0) {n} : ContDiffAt 𝕜 n Inv.inv x := by
simpa only [Ring.inverse_eq_inv'] using contDiffAt_ringInverse 𝕜 (Units.mk0 x hx)
@[fun_prop]
theorem contDiffOn_inv {n} : ContDiffOn 𝕜 n (Inv.inv : 𝕜' → 𝕜') {0}ᶜ := fun _ hx =>
(contDiffAt_inv 𝕜 hx).contDiffWithinAt
variable {𝕜}
@[fun_prop]
theorem ContDiffWithinAt.inv {f : E → 𝕜'} {n} (hf : ContDiffWithinAt 𝕜 n f s x) (hx : f x ≠ 0) :
ContDiffWithinAt 𝕜 n (fun x => (f x)⁻¹) s x :=
(contDiffAt_inv 𝕜 hx).comp_contDiffWithinAt x hf
@[fun_prop]
theorem ContDiffOn.inv {f : E → 𝕜'} (hf : ContDiffOn 𝕜 n f s) (h : ∀ x ∈ s, f x ≠ 0) :
ContDiffOn 𝕜 n (fun x => (f x)⁻¹) s := fun x hx => (hf.contDiffWithinAt hx).inv (h x hx)
@[fun_prop]
nonrec theorem ContDiffAt.inv {f : E → 𝕜'} (hf : ContDiffAt 𝕜 n f x) (hx : f x ≠ 0) :
ContDiffAt 𝕜 n (fun x => (f x)⁻¹) x :=
hf.inv hx
@[fun_prop]
theorem ContDiff.inv {f : E → 𝕜'} (hf : ContDiff 𝕜 n f) (h : ∀ x, f x ≠ 0) :
ContDiff 𝕜 n fun x => (f x)⁻¹ := by
rw [contDiff_iff_contDiffAt]; exact fun x => hf.contDiffAt.inv (h x)
-- TODO: generalize to `f g : E → 𝕜'`
@[fun_prop]
theorem ContDiffWithinAt.div {f g : E → 𝕜} {n} (hf : ContDiffWithinAt 𝕜 n f s x)
(hg : ContDiffWithinAt 𝕜 n g s x) (hx : g x ≠ 0) :
ContDiffWithinAt 𝕜 n (fun x => f x / g x) s x := by
simpa only [div_eq_mul_inv] using hf.mul (hg.inv hx)
@[fun_prop]
theorem ContDiffOn.div {f g : E → 𝕜} {n} (hf : ContDiffOn 𝕜 n f s)
(hg : ContDiffOn 𝕜 n g s) (h₀ : ∀ x ∈ s, g x ≠ 0) : ContDiffOn 𝕜 n (f / g) s := fun x hx =>
(hf x hx).div (hg x hx) (h₀ x hx)
@[fun_prop]
theorem ContDiffOn.fun_div {f g : E → 𝕜} {n} (hf : ContDiffOn 𝕜 n f s)
(hg : ContDiffOn 𝕜 n g s) (h₀ : ∀ x ∈ s, g x ≠ 0) : ContDiffOn 𝕜 n (fun x => f x / g x) s :=
ContDiffOn.div hf hg h₀
@[fun_prop]
nonrec theorem ContDiffAt.div {f g : E → 𝕜} {n} (hf : ContDiffAt 𝕜 n f x)
(hg : ContDiffAt 𝕜 n g x) (hx : g x ≠ 0) : ContDiffAt 𝕜 n (fun x => f x / g x) x :=
hf.div hg hx
@[fun_prop]
theorem ContDiff.div {f g : E → 𝕜} {n} (hf : ContDiff 𝕜 n f) (hg : ContDiff 𝕜 n g)
(h0 : ∀ x, g x ≠ 0) : ContDiff 𝕜 n fun x => f x / g x := by
simp only [contDiff_iff_contDiffAt] at *
exact fun x => (hf x).div (hg x) (h0 x)
end AlgebraInverse
/-! ### Inversion of continuous linear maps between Banach spaces -/
section MapInverse
open ContinuousLinearMap
/-- At a continuous linear equivalence `e : E ≃L[𝕜] F` between Banach spaces, the operation of
inversion is `C^n`, for all `n`. -/
@[fun_prop]
theorem contDiffAt_map_inverse [CompleteSpace E] (e : E ≃L[𝕜] F) :
ContDiffAt 𝕜 n inverse (e : E →L[𝕜] F) := by
nontriviality E
-- first, we use the lemma `inverse_eq_ringInverse` to rewrite in terms of `Ring.inverse` in the
-- ring `E →L[𝕜] E`
let O₁ : (E →L[𝕜] E) → F →L[𝕜] E := fun f => f.comp (e.symm : F →L[𝕜] E)
let O₂ : (E →L[𝕜] F) → E →L[𝕜] E := fun f => (e.symm : F →L[𝕜] E).comp f
have : ContinuousLinearMap.inverse = O₁ ∘ Ring.inverse ∘ O₂ := funext (inverse_eq_ringInverse e)
rw [this]
-- `O₁` and `O₂` are `ContDiff`,
-- so we reduce to proving that `Ring.inverse` is `ContDiff`
have h₁ : ContDiff 𝕜 n O₁ := contDiff_id.clm_comp contDiff_const
have h₂ : ContDiff 𝕜 n O₂ := contDiff_const.clm_comp contDiff_id
refine h₁.contDiffAt.comp _ (ContDiffAt.comp _ ?_ h₂.contDiffAt)
convert contDiffAt_ringInverse 𝕜 (1 : (E →L[𝕜] E)ˣ)
simp [O₂, one_def]
/-- At an invertible map `e : M →L[R] M₂` between Banach spaces, the operation of
inversion is `C^n`, for all `n`. -/
theorem ContinuousLinearMap.IsInvertible.contDiffAt_map_inverse [CompleteSpace E] {e : E →L[𝕜] F}
(he : e.IsInvertible) : ContDiffAt 𝕜 n inverse e := by
rcases he with ⟨M, rfl⟩
exact _root_.contDiffAt_map_inverse M
end MapInverse
section FunctionInverse
open ContinuousLinearMap
/-- If `f` is a local homeomorphism and the point `a` is in its target,
and if `f` is `n` times continuously differentiable at `f.symm a`,
and if the derivative at `f.symm a` is a continuous linear equivalence,
then `f.symm` is `n` times continuously differentiable at the point `a`.
This is one of the easy parts of the inverse function theorem: it assumes that we already have
an inverse function. -/
theorem OpenPartialHomeomorph.contDiffAt_symm [CompleteSpace E] (f : OpenPartialHomeomorph E F)
{f₀' : E ≃L[𝕜] F} {a : F} (ha : a ∈ f.target)
(hf₀' : HasFDerivAt f (f₀' : E →L[𝕜] F) (f.symm a)) (hf : ContDiffAt 𝕜 n f (f.symm a)) :
ContDiffAt 𝕜 n f.symm a := by
match n with
| ω =>
apply AnalyticAt.contDiffAt
exact f.analyticAt_symm ha hf.analyticAt hf₀'.fderiv
| (n : ℕ∞) =>
-- We prove this by induction on `n`
induction n using ENat.nat_induction with
| zero =>
apply contDiffAt_zero.2
exact ⟨f.target, IsOpen.mem_nhds f.open_target ha, f.continuousOn_invFun⟩
| succ n IH =>
obtain ⟨f', ⟨u, hu, hff'⟩, hf'⟩ := contDiffAt_succ_iff_hasFDerivAt.mp hf
apply contDiffAt_succ_iff_hasFDerivAt.2
-- 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₀'
-- This follows by a bootstrapping formula expressing the derivative as a
-- function of `f` itself
refine ⟨inverse ∘ f' ∘ f.symm, ?_, ?_⟩
· -- We first check that the derivative of `f` is that formula
have h_nhds : { y : E | ∃ e : E ≃L[𝕜] F, ↑e = f' y } ∈ 𝓝 (f.symm a) := by
have hf₀' := f₀'.nhds
rw [← eq_f₀'] at hf₀'
exact hf'.continuousAt.preimage_mem_nhds hf₀'
obtain ⟨t, htu, ht, htf⟩ := mem_nhds_iff.mp (Filter.inter_mem hu h_nhds)
use f.target ∩ f.symm ⁻¹' t
refine ⟨IsOpen.mem_nhds ?_ ?_, ?_⟩
· exact f.isOpen_inter_preimage_symm ht
· exact mem_inter ha (mem_preimage.mpr htf)
intro x hx
obtain ⟨hxu, e, he⟩ := htu hx.2
have h_deriv : HasFDerivAt f (e : E →L[𝕜] F) (f.symm x) := by
rw [he]
exact hff' (f.symm x) hxu
convert f.hasFDerivAt_symm hx.1 h_deriv
simp [← he]
· -- Then we check that the formula, being a composition of `ContDiff` pieces, is
-- itself `ContDiff`
have h_deriv₁ : ContDiffAt 𝕜 n inverse (f' (f.symm a)) := by
rw [eq_f₀']
exact contDiffAt_map_inverse _
have h_deriv₂ : ContDiffAt 𝕜 n f.symm a := by
refine IH (hf.of_le ?_)
norm_cast
exact Nat.le_succ n
exact (h_deriv₁.comp _ hf').comp _ h_deriv₂
| top Itop => exact contDiffAt_infty.mpr fun n ↦ Itop n (contDiffAt_infty.mp hf n)
/-- If `f` is an `n` times continuously differentiable homeomorphism,
and if the derivative of `f` at each point is a continuous linear equivalence,
then `f.symm` is `n` times continuously differentiable.
This is one of the easy parts of the inverse function theorem: it assumes that we already have
an inverse function. -/
theorem Homeomorph.contDiff_symm [CompleteSpace E] (f : E ≃ₜ F) {f₀' : E → E ≃L[𝕜] F}
(hf₀' : ∀ a, HasFDerivAt f (f₀' a : E →L[𝕜] F) a) (hf : ContDiff 𝕜 n (f : E → F)) :
ContDiff 𝕜 n (f.symm : F → E) :=
contDiff_iff_contDiffAt.2 fun x =>
f.toOpenPartialHomeomorph.contDiffAt_symm (mem_univ x) (hf₀' _) hf.contDiffAt
/-- Let `f` be a local homeomorphism of a nontrivially normed field, let `a` be a point in its
target. if `f` is `n` times continuously differentiable at `f.symm a`, and if the derivative at
`f.symm a` is nonzero, then `f.symm` is `n` times continuously differentiable at the point `a`.
This is one of the easy parts of the inverse function theorem: it assumes that we already have
an inverse function. -/
theorem OpenPartialHomeomorph.contDiffAt_symm_deriv [CompleteSpace 𝕜]
(f : OpenPartialHomeomorph 𝕜 𝕜) {f₀' a : 𝕜} (h₀ : f₀' ≠ 0) (ha : a ∈ f.target)
(hf₀' : HasDerivAt f f₀' (f.symm a)) (hf : ContDiffAt 𝕜 n f (f.symm a)) :
ContDiffAt 𝕜 n f.symm a :=
f.contDiffAt_symm ha (hf₀'.hasFDerivAt_equiv h₀) hf
/-- Let `f` be an `n` times continuously differentiable homeomorphism of a nontrivially normed
field. Suppose that the derivative of `f` is never equal to zero. Then `f.symm` is `n` times
continuously differentiable.
This is one of the easy parts of the inverse function theorem: it assumes that we already have
an inverse function. -/
theorem Homeomorph.contDiff_symm_deriv [CompleteSpace 𝕜] (f : 𝕜 ≃ₜ 𝕜) {f' : 𝕜 → 𝕜}
(h₀ : ∀ x, f' x ≠ 0) (hf' : ∀ x, HasDerivAt f (f' x) x) (hf : ContDiff 𝕜 n (f : 𝕜 → 𝕜)) :
ContDiff 𝕜 n (f.symm : 𝕜 → 𝕜) :=
contDiff_iff_contDiffAt.2 fun x =>
f.toOpenPartialHomeomorph.contDiffAt_symm_deriv (h₀ _) (mem_univ x) (hf' _) hf.contDiffAt
namespace OpenPartialHomeomorph
variable (𝕜)
/-- Restrict an open partial homeomorphism to the subsets of the source and target
that consist of points `x ∈ f.source`, `y = f x ∈ f.target`
such that `f` is `C^n` at `x` and `f.symm` is `C^n` at `y`.
Note that `n` is a natural number or `ω`, but not `∞`,
because the set of points of `C^∞`-smoothness of `f` is not guaranteed to be open. -/
@[simps! apply symm_apply source target]
def restrContDiff (f : OpenPartialHomeomorph E F) (n : WithTop ℕ∞) (hn : n ≠ ∞) :
OpenPartialHomeomorph E F :=
haveI H : f.IsImage {x | ContDiffAt 𝕜 n f x ∧ ContDiffAt 𝕜 n f.symm (f x)}
{y | ContDiffAt 𝕜 n f.symm y ∧ ContDiffAt 𝕜 n f (f.symm y)} := fun x hx ↦ by
simp [hx, and_comm]
H.restr <| isOpen_iff_mem_nhds.2 fun _ ⟨hxs, hxf, hxf'⟩ ↦
inter_mem (f.open_source.mem_nhds hxs) <| (hxf.eventually hn).and <|
f.continuousAt hxs (hxf'.eventually hn)
lemma contDiffOn_restrContDiff_source (f : OpenPartialHomeomorph E F) {n : WithTop ℕ∞}
(hn : n ≠ ∞) : ContDiffOn 𝕜 n f (f.restrContDiff 𝕜 n hn).source :=
fun _x hx ↦ hx.2.1.contDiffWithinAt
lemma contDiffOn_restrContDiff_target (f : OpenPartialHomeomorph E F) {n : WithTop ℕ∞}
(hn : n ≠ ∞) : ContDiffOn 𝕜 n f.symm (f.restrContDiff 𝕜 n hn).target :=
fun _x hx ↦ hx.2.1.contDiffWithinAt
end OpenPartialHomeomorph
end FunctionInverse
section RestrictScalars
/-!
### Restricting from `ℂ` to `ℝ`, or generally from `𝕜'` to `𝕜`
If a function is `n` times continuously differentiable over `ℂ`, then it is `n` times continuously
differentiable over `ℝ`. In this paragraph, we give variants of this statement, in the general
situation where `ℂ` and `ℝ` are replaced respectively by `𝕜'` and `𝕜` where `𝕜'` is a normed algebra
over `𝕜`.
-/
variable (𝕜)
variable {𝕜' : Type*} [NontriviallyNormedField 𝕜'] [NormedAlgebra 𝕜 𝕜']
variable [NormedSpace 𝕜' E] [IsScalarTower 𝕜 𝕜' E]
variable [NormedSpace 𝕜' F] [IsScalarTower 𝕜 𝕜' F]
variable {p' : E → FormalMultilinearSeries 𝕜' E F}
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 :=
((ContinuousMultilinearMap.restrictScalarsLinear 𝕜).hasFDerivAt.comp_hasFDerivWithinAt x <|
(h.fderivWithin m hm x hx).restrictScalars 𝕜 :)
cont m hm := ContinuousMultilinearMap.continuous_restrictScalars.comp_continuousOn (h.cont m hm)
theorem ContDiffWithinAt.restrict_scalars (h : ContDiffWithinAt 𝕜' n f s x) :
ContDiffWithinAt 𝕜 n f s x := by
match n with
| ω =>
obtain ⟨u, u_mem, p', hp', Hp'⟩ := h
refine ⟨u, u_mem, _, hp'.restrictScalars _, fun i ↦ ?_⟩
change AnalyticOn 𝕜 (fun x ↦ ContinuousMultilinearMap.restrictScalarsLinear 𝕜 (p' x i)) u
apply AnalyticOnNhd.comp_analyticOn _ (Hp' i).restrictScalars (Set.mapsTo_univ _ _)
exact ContinuousLinearMap.analyticOnNhd _ _
| (n : ℕ∞) =>
intro m hm
rcases h m hm with ⟨u, u_mem, p', hp'⟩
exact ⟨u, u_mem, _, hp'.restrictScalars _⟩
theorem ContDiffOn.restrict_scalars (h : ContDiffOn 𝕜' n f s) : ContDiffOn 𝕜 n f s := fun x hx =>
(h x hx).restrict_scalars _
theorem ContDiffAt.restrict_scalars (h : ContDiffAt 𝕜' n f x) : ContDiffAt 𝕜 n f x :=
contDiffWithinAt_univ.1 <| h.contDiffWithinAt.restrict_scalars _
theorem ContDiff.restrict_scalars (h : ContDiff 𝕜' n f) : ContDiff 𝕜 n f :=
contDiff_iff_contDiffAt.2 fun _ => h.contDiffAt.restrict_scalars _
end RestrictScalars |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/ContDiff/Defs.lean | import Mathlib.Analysis.Analytic.Within
import Mathlib.Analysis.Calculus.FDeriv.Analytic
import Mathlib.Analysis.Calculus.ContDiff.FTaylorSeries
/-!
# Higher differentiability
A function is `C^1` on a domain if it is differentiable there, and its derivative is continuous.
By induction, it is `C^n` if it is `C^{n-1}` and its (n-1)-th derivative is `C^1` there or,
equivalently, if it is `C^1` and its derivative is `C^{n-1}`.
It is `C^∞` if it is `C^n` for all n.
Finally, it is `C^ω` if it is analytic (as well as all its derivative, which is automatic if the
space is complete).
We formalize these notions with predicates `ContDiffWithinAt`, `ContDiffAt`, `ContDiffOn` and
`ContDiff` saying that the function is `C^n` within a set at a point, at a point, on a set
and on the whole space respectively.
To avoid the issue of choice when choosing a derivative in sets where the derivative is not
necessarily unique, `ContDiffOn` is not defined directly in terms of the
regularity of the specific choice `iteratedFDerivWithin 𝕜 n f s` inside `s`, but in terms of the
existence of a nice sequence of derivatives, expressed with a predicate
`HasFTaylorSeriesUpToOn` defined in the file `FTaylorSeries`.
We prove basic properties of these notions.
## Main definitions and results
Let `f : E → F` be a map between normed vector spaces over a nontrivially normed field `𝕜`.
* `ContDiff 𝕜 n f`: expresses that `f` is `C^n`, i.e., it admits a Taylor series up to
rank `n`.
* `ContDiffOn 𝕜 n f s`: expresses that `f` is `C^n` in `s`.
* `ContDiffAt 𝕜 n f x`: expresses that `f` is `C^n` around `x`.
* `ContDiffWithinAt 𝕜 n f s x`: expresses that `f` is `C^n` around `x` within the set `s`.
In sets of unique differentiability, `ContDiffOn 𝕜 n f s` can be expressed in terms of the
properties of `iteratedFDerivWithin 𝕜 m f s` for `m ≤ n`. In the whole space,
`ContDiff 𝕜 n f` can be expressed in terms of the properties of `iteratedFDeriv 𝕜 m f`
for `m ≤ n`.
## Implementation notes
The definitions in this file are designed to work on any field `𝕜`. They are sometimes slightly more
complicated than the naive definitions one would guess from the intuition over the real or complex
numbers, but they are designed to circumvent the lack of gluing properties and partitions of unity
in general. In the usual situations, they coincide with the usual definitions.
### Definition of `C^n` functions in domains
One could define `C^n` functions in a domain `s` by fixing an arbitrary choice of derivatives (this
is what we do with `iteratedFDerivWithin`) and requiring that all these derivatives up to `n` are
continuous. If the derivative is not unique, this could lead to strange behavior like two `C^n`
functions `f` and `g` on `s` whose sum is not `C^n`. A better definition is thus to say that a
function is `C^n` inside `s` if it admits a sequence of derivatives up to `n` inside `s`.
This definition still has the problem that a function which is locally `C^n` would not need to
be `C^n`, as different choices of sequences of derivatives around different points might possibly
not be glued together to give a globally defined sequence of derivatives. (Note that this issue
cannot happen over the real numbers, thanks to partitions of unity, but the behavior over a general
field is not so clear, and we want a definition for general fields). Also, there are locality
problems for the order parameter: one could image a function which, for each `n`, has a nice
sequence of derivatives up to order `n`, but they do not coincide for varying `n` and can therefore
not be glued to give rise to an infinite sequence of derivatives. This would give a function
which is `C^n` for all `n`, but not `C^∞`. We solve this issue by putting locality conditions
in space and order in our definition of `ContDiffWithinAt` and `ContDiffOn`.
The resulting definition is slightly more complicated to work with (in fact not so much), but it
gives rise to completely satisfactory theorems.
For instance, with this definition, a real function which is `C^m` (but not better) on `(-1/m, 1/m)`
for each natural `m` is by definition `C^∞` at `0`.
There is another issue with the definition of `ContDiffWithinAt 𝕜 n f s x`. We can
require the existence and good behavior of derivatives up to order `n` on a neighborhood of `x`
within `s`. However, this does not imply continuity or differentiability within `s` of the function
at `x` when `x` does not belong to `s`. Therefore, we require such existence and good behavior on
a neighborhood of `x` within `s ∪ {x}` (which appears as `insert x s` in this file).
## Notation
We use the notation `E [×n]→L[𝕜] F` for the space of continuous multilinear maps on `E^n` with
values in `F`. This is the space in which the `n`-th derivative of a function from `E` to `F` lives.
In this file, we denote `(⊤ : ℕ∞) : WithTop ℕ∞` with `∞`, and `⊤ : WithTop ℕ∞` with `ω`. To
avoid ambiguities with the two tops, the theorem names use either `infty` or `omega`.
These notations are scoped in `ContDiff`.
## Tags
derivative, differentiability, higher derivative, `C^n`, multilinear, Taylor series, formal series
-/
noncomputable section
open Set Fin Filter Function
open scoped NNReal Topology ContDiff
universe u uE uF uG uX
variable {𝕜 : Type u} [NontriviallyNormedField 𝕜] {E : Type uE} [NormedAddCommGroup E]
[NormedSpace 𝕜 E] {F : Type uF} [NormedAddCommGroup F] [NormedSpace 𝕜 F] {G : Type uG}
[NormedAddCommGroup G] [NormedSpace 𝕜 G] {X : Type uX} [NormedAddCommGroup X] [NormedSpace 𝕜 X]
{s s₁ t u : Set E} {f f₁ : E → F} {g : F → G} {x x₀ : E} {c : F} {m n : WithTop ℕ∞}
{p : E → FormalMultilinearSeries 𝕜 E F}
/-! ### Smooth functions within a set around a point -/
variable (𝕜) in
/-- A function is continuously differentiable up to order `n` within a set `s` at a point `x` if
it admits continuous derivatives up to order `n` in a neighborhood of `x` in `s ∪ {x}`.
For `n = ∞`, we only require that this holds up to any finite order (where the neighborhood may
depend on the finite order we consider).
For `n = ω`, we require the function to be analytic within `s` at `x`. The precise definition we
give (all the derivatives should be analytic) is more involved to work around issues when the space
is not complete, but it is equivalent when the space is complete.
For instance, a real function which is `C^m` on `(-1/m, 1/m)` for each natural `m`, but not
better, is `C^∞` at `0` within `univ`.
-/
@[fun_prop]
def ContDiffWithinAt (n : WithTop ℕ∞) (f : E → F) (s : Set E) (x : E) : Prop :=
match n with
| ω => ∃ u ∈ 𝓝[insert x s] x, ∃ p : E → FormalMultilinearSeries 𝕜 E F,
HasFTaylorSeriesUpToOn ω f p u ∧ ∀ i, AnalyticOn 𝕜 (fun x ↦ p x i) u
| (n : ℕ∞) => ∀ m : ℕ, m ≤ n → ∃ u ∈ 𝓝[insert x s] x,
∃ p : E → FormalMultilinearSeries 𝕜 E F, HasFTaylorSeriesUpToOn m f p u
lemma HasFTaylorSeriesUpToOn.analyticOn
(hf : HasFTaylorSeriesUpToOn ω f p s) (h : AnalyticOn 𝕜 (fun x ↦ p x 0) s) :
AnalyticOn 𝕜 f s := by
have : AnalyticOn 𝕜 (fun x ↦ (continuousMultilinearCurryFin0 𝕜 E F) (p x 0)) s :=
(LinearIsometryEquiv.analyticOnNhd _ _ ).comp_analyticOn
h (Set.mapsTo_univ _ _)
exact this.congr (fun y hy ↦ (hf.zero_eq _ hy).symm)
lemma ContDiffWithinAt.analyticOn (h : ContDiffWithinAt 𝕜 ω f s x) :
∃ u ∈ 𝓝[insert x s] x, AnalyticOn 𝕜 f u := by
obtain ⟨u, hu, p, hp, h'p⟩ := h
exact ⟨u, hu, hp.analyticOn (h'p 0)⟩
lemma ContDiffWithinAt.analyticWithinAt (h : ContDiffWithinAt 𝕜 ω f s x) :
AnalyticWithinAt 𝕜 f s x := by
obtain ⟨u, hu, hf⟩ := h.analyticOn
have xu : x ∈ u := mem_of_mem_nhdsWithin (by simp) hu
exact (hf x xu).mono_of_mem_nhdsWithin (nhdsWithin_mono _ (subset_insert _ _) hu)
theorem contDiffWithinAt_omega_iff_analyticWithinAt [CompleteSpace F] :
ContDiffWithinAt 𝕜 ω f s x ↔ AnalyticWithinAt 𝕜 f s x := by
refine ⟨fun h ↦ h.analyticWithinAt, fun h ↦ ?_⟩
obtain ⟨u, hu, p, hp, h'p⟩ := h.exists_hasFTaylorSeriesUpToOn ω
exact ⟨u, hu, p, hp.of_le le_top, fun i ↦ h'p i⟩
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 (mod_cast hm)⟩⟩
/-- When `n` is either a natural number or `ω`, one can characterize the property of being `C^n`
as the existence of a neighborhood on which there is a Taylor series up to order `n`,
requiring in addition that its terms are analytic in the `ω` case. -/
lemma contDiffWithinAt_iff_of_ne_infty (hn : n ≠ ∞) :
ContDiffWithinAt 𝕜 n f s x ↔ ∃ u ∈ 𝓝[insert x s] x,
∃ p : E → FormalMultilinearSeries 𝕜 E F, HasFTaylorSeriesUpToOn n f p u ∧
(n = ω → ∀ i, AnalyticOn 𝕜 (fun x ↦ p x i) u) := by
match n with
| ω => simp [ContDiffWithinAt]
| ∞ => simp at hn
| (n : ℕ) => simp [contDiffWithinAt_nat]
@[fun_prop]
theorem ContDiffWithinAt.of_le (h : ContDiffWithinAt 𝕜 n f s x) (hmn : m ≤ n) :
ContDiffWithinAt 𝕜 m f s x := by
match n with
| ω => match m with
| ω => exact h
| (m : ℕ∞) =>
intro k _
obtain ⟨u, hu, p, hp, -⟩ := h
exact ⟨u, hu, p, hp.of_le le_top⟩
| (n : ℕ∞) => match m with
| ω => simp at hmn
| (m : ℕ∞) => exact fun k hk ↦ h k (le_trans hk (mod_cast hmn))
/-- In a complete space, a function which is analytic within a set at a point is also `C^ω` there.
Note that the same statement for `AnalyticOn` does not require completeness, see
`AnalyticOn.contDiffOn`. -/
theorem AnalyticWithinAt.contDiffWithinAt [CompleteSpace F] (h : AnalyticWithinAt 𝕜 f s x) :
ContDiffWithinAt 𝕜 n f s x :=
(contDiffWithinAt_omega_iff_analyticWithinAt.2 h).of_le le_top
theorem contDiffWithinAt_iff_forall_nat_le {n : ℕ∞} :
ContDiffWithinAt 𝕜 n f s x ↔ ∀ m : ℕ, ↑m ≤ n → ContDiffWithinAt 𝕜 m f s x :=
⟨fun H _ hm => H.of_le (mod_cast hm), fun H m hm => H m hm _ le_rfl⟩
theorem contDiffWithinAt_infty :
ContDiffWithinAt 𝕜 ∞ f s x ↔ ∀ n : ℕ, ContDiffWithinAt 𝕜 n f s x :=
contDiffWithinAt_iff_forall_nat_le.trans <| by simp only [forall_prop_of_true, le_top]
theorem ContDiffWithinAt.continuousWithinAt (h : ContDiffWithinAt 𝕜 n f s x) :
ContinuousWithinAt f s x := by
have := h.of_le (zero_le _)
simp only [ContDiffWithinAt, nonpos_iff_eq_zero, Nat.cast_eq_zero, forall_eq, CharP.cast_eq_zero]
at this
rcases this with ⟨u, hu, p, H⟩
rw [mem_nhdsWithin_insert] at hu
exact (H.continuousOn.continuousWithinAt hu.1).mono_of_mem_nhdsWithin hu.2
theorem ContDiffWithinAt.congr_of_eventuallyEq (h : ContDiffWithinAt 𝕜 n f s x)
(h₁ : f₁ =ᶠ[𝓝[s] x] f) (hx : f₁ x = f x) : ContDiffWithinAt 𝕜 n f₁ s x := by
match n with
| ω =>
obtain ⟨u, hu, p, H, H'⟩ := h
exact ⟨{x ∈ u | f₁ x = f x}, Filter.inter_mem hu (mem_nhdsWithin_insert.2 ⟨hx, h₁⟩), p,
(H.mono (sep_subset _ _)).congr fun _ ↦ And.right,
fun i ↦ (H' i).mono (sep_subset _ _)⟩
| (n : ℕ∞) =>
intro m hm
let ⟨u, hu, p, H⟩ := h m hm
exact ⟨{ x ∈ u | f₁ x = f x }, Filter.inter_mem hu (mem_nhdsWithin_insert.2 ⟨hx, h₁⟩), p,
(H.mono (sep_subset _ _)).congr fun _ ↦ And.right⟩
theorem Filter.EventuallyEq.congr_contDiffWithinAt (h₁ : f₁ =ᶠ[𝓝[s] x] f) (hx : f₁ x = f x) :
ContDiffWithinAt 𝕜 n f₁ s x ↔ ContDiffWithinAt 𝕜 n f s x :=
⟨fun H ↦ H.congr_of_eventuallyEq h₁.symm hx.symm, fun H ↦ H.congr_of_eventuallyEq h₁ hx⟩
theorem ContDiffWithinAt.congr_of_eventuallyEq_insert (h : ContDiffWithinAt 𝕜 n f s x)
(h₁ : f₁ =ᶠ[𝓝[insert x s] x] f) : ContDiffWithinAt 𝕜 n f₁ s x :=
h.congr_of_eventuallyEq (nhdsWithin_mono x (subset_insert x s) h₁)
(mem_of_mem_nhdsWithin (mem_insert x s) h₁ :)
theorem Filter.EventuallyEq.congr_contDiffWithinAt_of_insert (h₁ : f₁ =ᶠ[𝓝[insert x s] x] f) :
ContDiffWithinAt 𝕜 n f₁ s x ↔ ContDiffWithinAt 𝕜 n f s x :=
⟨fun H ↦ H.congr_of_eventuallyEq_insert h₁.symm, fun H ↦ H.congr_of_eventuallyEq_insert h₁⟩
theorem ContDiffWithinAt.congr_of_eventuallyEq_of_mem (h : ContDiffWithinAt 𝕜 n f s x)
(h₁ : f₁ =ᶠ[𝓝[s] x] f) (hx : x ∈ s) : ContDiffWithinAt 𝕜 n f₁ s x :=
h.congr_of_eventuallyEq h₁ <| h₁.self_of_nhdsWithin hx
theorem Filter.EventuallyEq.congr_contDiffWithinAt_of_mem (h₁ : f₁ =ᶠ[𝓝[s] x] f) (hx : x ∈ s) :
ContDiffWithinAt 𝕜 n f₁ s x ↔ ContDiffWithinAt 𝕜 n f s x :=
⟨fun H ↦ H.congr_of_eventuallyEq_of_mem h₁.symm hx, fun H ↦ H.congr_of_eventuallyEq_of_mem h₁ hx⟩
theorem ContDiffWithinAt.congr (h : ContDiffWithinAt 𝕜 n f s x) (h₁ : ∀ y ∈ s, f₁ y = f y)
(hx : f₁ x = f x) : ContDiffWithinAt 𝕜 n f₁ s x :=
h.congr_of_eventuallyEq (Filter.eventuallyEq_of_mem self_mem_nhdsWithin h₁) hx
theorem contDiffWithinAt_congr (h₁ : ∀ y ∈ s, f₁ y = f y) (hx : f₁ x = f x) :
ContDiffWithinAt 𝕜 n f₁ s x ↔ ContDiffWithinAt 𝕜 n f s x :=
⟨fun h' ↦ h'.congr (fun x hx ↦ (h₁ x hx).symm) hx.symm, fun h' ↦ h'.congr h₁ hx⟩
theorem ContDiffWithinAt.congr_of_mem (h : ContDiffWithinAt 𝕜 n f s x) (h₁ : ∀ y ∈ s, f₁ y = f y)
(hx : x ∈ s) : ContDiffWithinAt 𝕜 n f₁ s x :=
h.congr h₁ (h₁ _ hx)
theorem contDiffWithinAt_congr_of_mem (h₁ : ∀ y ∈ s, f₁ y = f y) (hx : x ∈ s) :
ContDiffWithinAt 𝕜 n f₁ s x ↔ ContDiffWithinAt 𝕜 n f s x :=
contDiffWithinAt_congr h₁ (h₁ x hx)
theorem ContDiffWithinAt.congr_of_insert (h : ContDiffWithinAt 𝕜 n f s x)
(h₁ : ∀ y ∈ insert x s, f₁ y = f y) : ContDiffWithinAt 𝕜 n f₁ s x :=
h.congr (fun y hy ↦ h₁ y (mem_insert_of_mem _ hy)) (h₁ x (mem_insert _ _))
theorem contDiffWithinAt_congr_of_insert (h₁ : ∀ y ∈ insert x s, f₁ y = f y) :
ContDiffWithinAt 𝕜 n f₁ s x ↔ ContDiffWithinAt 𝕜 n f s x :=
contDiffWithinAt_congr (fun y hy ↦ h₁ y (mem_insert_of_mem _ hy)) (h₁ x (mem_insert _ _))
theorem ContDiffWithinAt.mono_of_mem_nhdsWithin (h : ContDiffWithinAt 𝕜 n f s x) {t : Set E}
(hst : s ∈ 𝓝[t] x) : ContDiffWithinAt 𝕜 n f t x := by
match n with
| ω =>
obtain ⟨u, hu, p, H, H'⟩ := h
exact ⟨u, nhdsWithin_le_of_mem (insert_mem_nhdsWithin_insert hst) hu, p, H, H'⟩
| (n : ℕ∞) =>
intro m hm
rcases h m hm with ⟨u, hu, p, H⟩
exact ⟨u, nhdsWithin_le_of_mem (insert_mem_nhdsWithin_insert hst) hu, p, H⟩
theorem ContDiffWithinAt.mono (h : ContDiffWithinAt 𝕜 n f s x) {t : Set E} (hst : t ⊆ s) :
ContDiffWithinAt 𝕜 n f t x :=
h.mono_of_mem_nhdsWithin <| Filter.mem_of_superset self_mem_nhdsWithin hst
theorem ContDiffWithinAt.congr_mono
(h : ContDiffWithinAt 𝕜 n f s x) (h' : EqOn f₁ f s₁) (h₁ : s₁ ⊆ s) (hx : f₁ x = f x) :
ContDiffWithinAt 𝕜 n f₁ s₁ x :=
(h.mono h₁).congr h' hx
theorem ContDiffWithinAt.congr_set (h : ContDiffWithinAt 𝕜 n f s x) {t : Set E}
(hst : s =ᶠ[𝓝 x] t) : ContDiffWithinAt 𝕜 n f t x := by
rw [← nhdsWithin_eq_iff_eventuallyEq] at hst
apply h.mono_of_mem_nhdsWithin <| hst ▸ self_mem_nhdsWithin
theorem contDiffWithinAt_congr_set {t : Set E} (hst : s =ᶠ[𝓝 x] t) :
ContDiffWithinAt 𝕜 n f s x ↔ ContDiffWithinAt 𝕜 n f t x :=
⟨fun h => h.congr_set hst, fun h => h.congr_set hst.symm⟩
theorem contDiffWithinAt_inter' (h : t ∈ 𝓝[s] x) :
ContDiffWithinAt 𝕜 n f (s ∩ t) x ↔ ContDiffWithinAt 𝕜 n f s x :=
contDiffWithinAt_congr_set (mem_nhdsWithin_iff_eventuallyEq.1 h).symm
theorem contDiffWithinAt_inter (h : t ∈ 𝓝 x) :
ContDiffWithinAt 𝕜 n f (s ∩ t) x ↔ ContDiffWithinAt 𝕜 n f s x :=
contDiffWithinAt_inter' (mem_nhdsWithin_of_mem_nhds h)
theorem contDiffWithinAt_insert_self :
ContDiffWithinAt 𝕜 n f (insert x s) x ↔ ContDiffWithinAt 𝕜 n f s x := by
match n with
| ω => simp [ContDiffWithinAt]
| (n : ℕ∞) => simp_rw [ContDiffWithinAt, insert_idem]
theorem contDiffWithinAt_insert {y : E} :
ContDiffWithinAt 𝕜 n f (insert y s) x ↔ ContDiffWithinAt 𝕜 n f s x := by
rcases eq_or_ne x y with (rfl | hx)
· exact contDiffWithinAt_insert_self
refine ⟨fun h ↦ h.mono (subset_insert _ _), fun h ↦ ?_⟩
apply h.mono_of_mem_nhdsWithin
simp [nhdsWithin_insert_of_ne hx, self_mem_nhdsWithin]
alias ⟨ContDiffWithinAt.of_insert, ContDiffWithinAt.insert'⟩ := contDiffWithinAt_insert
protected theorem ContDiffWithinAt.insert (h : ContDiffWithinAt 𝕜 n f s x) :
ContDiffWithinAt 𝕜 n f (insert x s) x :=
h.insert'
theorem contDiffWithinAt_diff_singleton {y : E} :
ContDiffWithinAt 𝕜 n f (s \ {y}) x ↔ ContDiffWithinAt 𝕜 n f s x := by
rw [← contDiffWithinAt_insert, insert_diff_singleton, contDiffWithinAt_insert]
/-- If a function is `C^n` within a set at a point, with `n ≥ 1`, then it is differentiable
within this set at this point. -/
theorem ContDiffWithinAt.differentiableWithinAt' (h : ContDiffWithinAt 𝕜 n f s x) (hn : 1 ≤ n) :
DifferentiableWithinAt 𝕜 f (insert x s) x := by
rcases contDiffWithinAt_nat.1 (h.of_le hn) with ⟨u, hu, p, H⟩
rcases mem_nhdsWithin.1 hu with ⟨t, t_open, xt, tu⟩
rw [inter_comm] at tu
exact (differentiableWithinAt_inter (IsOpen.mem_nhds t_open xt)).1 <|
((H.mono tu).differentiableOn le_rfl) x ⟨mem_insert x s, xt⟩
theorem ContDiffWithinAt.differentiableWithinAt (h : ContDiffWithinAt 𝕜 n f s x) (hn : 1 ≤ n) :
DifferentiableWithinAt 𝕜 f s x :=
(h.differentiableWithinAt' hn).mono (subset_insert x s)
/-- A function is `C^(n + 1)` on a domain iff locally, it has a derivative which is `C^n`
(and moreover the function is analytic when `n = ω`). -/
theorem contDiffWithinAt_succ_iff_hasFDerivWithinAt (hn : n ≠ ∞) :
ContDiffWithinAt 𝕜 (n + 1) f s x ↔ ∃ u ∈ 𝓝[insert x s] x, (n = ω → AnalyticOn 𝕜 f u) ∧
∃ f' : E → E →L[𝕜] F,
(∀ x ∈ u, HasFDerivWithinAt f (f' x) u x) ∧ ContDiffWithinAt 𝕜 n f' u x := by
have h'n : n + 1 ≠ ∞ := by simpa using hn
constructor
· intro h
rcases (contDiffWithinAt_iff_of_ne_infty h'n).1 h with ⟨u, hu, p, Hp, H'p⟩
refine ⟨u, hu, ?_, fun y => (continuousMultilinearCurryFin1 𝕜 E F) (p y 1),
fun y hy => Hp.hasFDerivWithinAt le_add_self hy, ?_⟩
· rintro rfl
exact Hp.analyticOn (H'p rfl 0)
apply (contDiffWithinAt_iff_of_ne_infty hn).2
refine ⟨u, ?_, fun y : E => (p y).shift, ?_⟩
· 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
refine ⟨Hp.2.2, ?_⟩
rintro rfl i
change AnalyticOn 𝕜
(fun x ↦ (continuousMultilinearCurryRightEquiv' 𝕜 i E F) (p x (i + 1))) u
apply (LinearIsometryEquiv.analyticOnNhd _ _).comp_analyticOn
?_ (Set.mapsTo_univ _ _)
exact H'p rfl _
· rintro ⟨u, hu, hf, f', f'_eq_deriv, Hf'⟩
rw [contDiffWithinAt_iff_of_ne_infty h'n]
rcases (contDiffWithinAt_iff_of_ne_infty hn).1 Hf' with ⟨v, hv, p', Hp', p'_an⟩
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]
refine ⟨fun y _ => rfl, fun y hy => ?_, ?_⟩
· change
HasFDerivWithinAt (fun z => (continuousMultilinearCurryFin0 𝕜 E F).symm (f z))
(FormalMultilinearSeries.unshift (p' y) (f y) 1).curryLeft (v ∩ u) y
rw [← Function.comp_def _ f, LinearIsometryEquiv.comp_hasFDerivWithinAt_iff']
convert (f'_eq_deriv y hy.2).mono inter_subset_right
rw [← Hp'.zero_eq y hy.1]
ext z
change ((p' y 0) (init (@cons 0 (fun _ => E) z 0))) (@cons 0 (fun _ => E) z 0 (last 0)) =
((p' y 0) 0) z
congr
norm_num [eq_iff_true_of_subsingleton]
· convert (Hp'.mono inter_subset_left).congr fun x hx => Hp'.zero_eq x hx.1 using 1
· ext x y
change p' x 0 (init (@snoc 0 (fun _ : Fin 1 => E) 0 y)) y = p' x 0 0 y
rw [init_snoc]
· ext x k v y
change p' x k (init (@snoc k (fun _ : Fin k.succ => E) v y))
(@snoc k (fun _ : Fin k.succ => E) v y (last k)) = p' x k v y
rw [snoc_last, init_snoc]
· intro h i
simp only [WithTop.add_eq_top, WithTop.one_ne_top, or_false] at h
match i with
| 0 =>
simp only [FormalMultilinearSeries.unshift]
apply AnalyticOnNhd.comp_analyticOn _ ((hf h).mono inter_subset_right)
(Set.mapsTo_univ _ _)
exact LinearIsometryEquiv.analyticOnNhd _ _
| i + 1 =>
simp only [FormalMultilinearSeries.unshift, Nat.succ_eq_add_one]
apply AnalyticOnNhd.comp_analyticOn _ ((p'_an h i).mono inter_subset_left)
(Set.mapsTo_univ _ _)
exact LinearIsometryEquiv.analyticOnNhd _ _
/-- A version of `contDiffWithinAt_succ_iff_hasFDerivWithinAt` where all derivatives
are taken within the same set. -/
theorem contDiffWithinAt_succ_iff_hasFDerivWithinAt' (hn : n ≠ ∞) :
ContDiffWithinAt 𝕜 (n + 1) f s x ↔
∃ u ∈ 𝓝[insert x s] x, u ⊆ insert x s ∧ (n = ω → AnalyticOn 𝕜 f u) ∧
∃ f' : E → E →L[𝕜] F,
(∀ x ∈ u, HasFDerivWithinAt f (f' x) s x) ∧ ContDiffWithinAt 𝕜 n f' s x := by
refine ⟨fun hf => ?_, ?_⟩
· obtain ⟨u, hu, f_an, f', huf', hf'⟩ := (contDiffWithinAt_succ_iff_hasFDerivWithinAt hn).mp hf
obtain ⟨w, hw, hxw, hwu⟩ := mem_nhdsWithin.mp hu
rw [inter_comm] at hwu
refine ⟨insert x s ∩ w, inter_mem_nhdsWithin _ (hw.mem_nhds hxw), inter_subset_left, ?_, f',
fun y hy => ?_, ?_⟩
· intro h
apply (f_an h).mono hwu
· refine ((huf' y <| hwu hy).mono hwu).mono_of_mem_nhdsWithin ?_
refine mem_of_superset ?_ (inter_subset_inter_left _ (subset_insert _ _))
exact inter_mem_nhdsWithin _ (hw.mem_nhds hy.2)
· exact hf'.mono_of_mem_nhdsWithin (nhdsWithin_mono _ (subset_insert _ _) hu)
· rw [← contDiffWithinAt_insert, contDiffWithinAt_succ_iff_hasFDerivWithinAt hn,
insert_eq_of_mem (mem_insert _ _)]
rintro ⟨u, hu, hus, f_an, f', huf', hf'⟩
exact ⟨u, hu, f_an, f', fun y hy => (huf' y hy).insert'.mono hus, hf'.insert.mono hus⟩
/-! ### Smooth functions within a set -/
variable (𝕜) in
/-- A function is continuously differentiable up to `n` on `s` if, for any point `x` in `s`, it
admits continuous derivatives up to order `n` on a neighborhood of `x` in `s`.
For `n = ∞`, we only require that this holds up to any finite order (where the neighborhood may
depend on the finite order we consider).
-/
@[fun_prop]
def ContDiffOn (n : WithTop ℕ∞) (f : E → F) (s : Set E) : Prop :=
∀ x ∈ s, ContDiffWithinAt 𝕜 n f s x
theorem HasFTaylorSeriesUpToOn.contDiffOn {n : ℕ∞} {f' : E → FormalMultilinearSeries 𝕜 E F}
(hf : HasFTaylorSeriesUpToOn n f f' s) : ContDiffOn 𝕜 n f s := by
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 (mod_cast hm)⟩
theorem ContDiffOn.contDiffWithinAt (h : ContDiffOn 𝕜 n f s) (hx : x ∈ s) :
ContDiffWithinAt 𝕜 n f s x :=
h x hx
@[fun_prop]
theorem ContDiffOn.of_le (h : ContDiffOn 𝕜 n f s) (hmn : m ≤ n) : ContDiffOn 𝕜 m f s := fun x hx =>
(h x hx).of_le hmn
theorem ContDiffWithinAt.contDiffOn' (hm : m ≤ n) (h' : m = ∞ → n = ω)
(h : ContDiffWithinAt 𝕜 n f s x) :
∃ u, IsOpen u ∧ x ∈ u ∧ ContDiffOn 𝕜 m f (insert x s ∩ u) := by
rcases eq_or_ne n ω with rfl | hn
· obtain ⟨t, ht, p, hp, h'p⟩ := h
rcases mem_nhdsWithin.1 ht with ⟨u, huo, hxu, hut⟩
rw [inter_comm] at hut
refine ⟨u, huo, hxu, ?_⟩
suffices ContDiffOn 𝕜 ω f (insert x s ∩ u) from this.of_le le_top
intro y hy
refine ⟨insert x s ∩ u, ?_, p, hp.mono hut, fun i ↦ (h'p i).mono hut⟩
simp only [insert_eq_of_mem, hy, self_mem_nhdsWithin]
· match m with
| ω => simp [hn] at hm
| ∞ => exact (hn (h' rfl)).elim
| (m : ℕ) =>
rcases contDiffWithinAt_nat.1 (h.of_le hm) with ⟨t, ht, p, hp⟩
rcases mem_nhdsWithin.1 ht with ⟨u, huo, hxu, hut⟩
rw [inter_comm] at hut
exact ⟨u, huo, hxu, (hp.mono hut).contDiffOn⟩
theorem ContDiffWithinAt.contDiffOn (hm : m ≤ n) (h' : m = ∞ → n = ω)
(h : ContDiffWithinAt 𝕜 n f s x) :
∃ u ∈ 𝓝[insert x s] x, u ⊆ insert x s ∧ ContDiffOn 𝕜 m f u := by
obtain ⟨_u, uo, xu, h⟩ := h.contDiffOn' hm h'
exact ⟨_, inter_mem_nhdsWithin _ (uo.mem_nhds xu), inter_subset_left, h⟩
theorem ContDiffOn.analyticOn (h : ContDiffOn 𝕜 ω f s) : AnalyticOn 𝕜 f s :=
fun x hx ↦ (h x hx).analyticWithinAt
/-- A function is `C^n` within a set at a point, for `n : ℕ`, if and only if it is `C^n` on
a neighborhood of this point. -/
theorem contDiffWithinAt_iff_contDiffOn_nhds (hn : n ≠ ∞) :
ContDiffWithinAt 𝕜 n f s x ↔ ∃ u ∈ 𝓝[insert x s] x, ContDiffOn 𝕜 n f u := by
refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩
· rcases h.contDiffOn le_rfl (by simp [hn]) with ⟨u, hu, h'u⟩
exact ⟨u, hu, h'u.2⟩
· rcases h with ⟨u, u_mem, hu⟩
have : x ∈ u := mem_of_mem_nhdsWithin (mem_insert x s) u_mem
exact (hu x this).mono_of_mem_nhdsWithin (nhdsWithin_mono _ (subset_insert x s) u_mem)
protected theorem ContDiffWithinAt.eventually (h : ContDiffWithinAt 𝕜 n f s x) (hn : n ≠ ∞) :
∀ᶠ y in 𝓝[insert x s] x, ContDiffWithinAt 𝕜 n f s y := by
rcases h.contDiffOn le_rfl (by simp [hn]) with ⟨u, hu, _, hd⟩
have : ∀ᶠ y : E in 𝓝[insert x s] x, u ∈ 𝓝[insert x s] y ∧ y ∈ u :=
(eventually_eventually_nhdsWithin.2 hu).and hu
refine this.mono fun y hy => (hd y hy.2).mono_of_mem_nhdsWithin ?_
exact nhdsWithin_mono y (subset_insert _ _) hy.1
theorem ContDiffOn.of_succ (h : ContDiffOn 𝕜 (n + 1) f s) : ContDiffOn 𝕜 n f s :=
h.of_le le_self_add
theorem ContDiffOn.one_of_succ (h : ContDiffOn 𝕜 (n + 1) f s) : ContDiffOn 𝕜 1 f s :=
h.of_le le_add_self
theorem contDiffOn_iff_forall_nat_le {n : ℕ∞} :
ContDiffOn 𝕜 n f s ↔ ∀ m : ℕ, ↑m ≤ n → ContDiffOn 𝕜 m f s :=
⟨fun H _ hm => H.of_le (mod_cast hm), fun H x hx m hm => H m hm x hx m le_rfl⟩
theorem contDiffOn_infty : ContDiffOn 𝕜 ∞ f s ↔ ∀ n : ℕ, ContDiffOn 𝕜 n f s :=
contDiffOn_iff_forall_nat_le.trans <| by simp only [le_top, forall_prop_of_true]
theorem contDiffOn_all_iff_nat :
(∀ (n : ℕ∞), ContDiffOn 𝕜 n f s) ↔ ∀ n : ℕ, ContDiffOn 𝕜 n f s := by
refine ⟨fun H n => H n, ?_⟩
rintro H (_ | n)
exacts [contDiffOn_infty.2 H, H n]
theorem ContDiffOn.continuousOn (h : ContDiffOn 𝕜 n f s) : ContinuousOn f s := fun x hx =>
(h x hx).continuousWithinAt
@[fun_prop]
theorem ContDiffOn.continuousOn_zero (h : ContDiffOn 𝕜 0 f s) : ContinuousOn f s := fun x hx =>
(h x hx).continuousWithinAt
theorem ContDiffOn.congr (h : ContDiffOn 𝕜 n f s) (h₁ : ∀ x ∈ s, f₁ x = f x) :
ContDiffOn 𝕜 n f₁ s := fun x hx => (h x hx).congr h₁ (h₁ x hx)
theorem contDiffOn_congr (h₁ : ∀ x ∈ s, f₁ x = f x) : ContDiffOn 𝕜 n f₁ s ↔ ContDiffOn 𝕜 n f s :=
⟨fun H => H.congr fun x hx => (h₁ x hx).symm, fun H => H.congr h₁⟩
theorem ContDiffOn.mono (h : ContDiffOn 𝕜 n f s) {t : Set E} (hst : t ⊆ s) : ContDiffOn 𝕜 n f t :=
fun x hx => (h x (hst hx)).mono hst
theorem ContDiffOn.congr_mono (hf : ContDiffOn 𝕜 n f s) (h₁ : ∀ x ∈ s₁, f₁ x = f x) (hs : s₁ ⊆ s) :
ContDiffOn 𝕜 n f₁ s₁ :=
(hf.mono hs).congr h₁
/-- If a function is `C^n` on a set with `n ≥ 1`, then it is differentiable there. -/
theorem ContDiffOn.differentiableOn (h : ContDiffOn 𝕜 n f s) (hn : 1 ≤ n) :
DifferentiableOn 𝕜 f s := fun x hx => (h x hx).differentiableWithinAt hn
@[fun_prop]
theorem ContDiffOn.differentiableOn_one (h : ContDiffOn 𝕜 1 f s) :
DifferentiableOn 𝕜 f s := fun x hx => (h x hx).differentiableWithinAt (le_refl 1)
/-- If a function is `C^n` around each point in a set, then it is `C^n` on the set. -/
theorem contDiffOn_of_locally_contDiffOn
(h : ∀ x ∈ s, ∃ u, IsOpen u ∧ x ∈ u ∧ ContDiffOn 𝕜 n f (s ∩ u)) : ContDiffOn 𝕜 n f s := by
intro x xs
rcases h x xs with ⟨u, u_open, xu, hu⟩
apply (contDiffWithinAt_inter _).1 (hu x ⟨xs, xu⟩)
exact IsOpen.mem_nhds u_open xu
/-- A function is `C^(n + 1)` on a domain iff locally, it has a derivative which is `C^n`. -/
theorem contDiffOn_succ_iff_hasFDerivWithinAt (hn : n ≠ ∞) :
ContDiffOn 𝕜 (n + 1) f s ↔
∀ x ∈ s, ∃ u ∈ 𝓝[insert x s] x, (n = ω → AnalyticOn 𝕜 f u) ∧ ∃ f' : E → E →L[𝕜] F,
(∀ x ∈ u, HasFDerivWithinAt f (f' x) u x) ∧ ContDiffOn 𝕜 n f' u := by
constructor
· intro h x hx
rcases (contDiffWithinAt_succ_iff_hasFDerivWithinAt hn).1 (h x hx) with
⟨u, hu, f_an, f', hf', Hf'⟩
rcases Hf'.contDiffOn le_rfl (by simp [hn]) with ⟨v, vu, v'u, hv⟩
rw [insert_eq_of_mem hx] at hu ⊢
have xu : x ∈ u := mem_of_mem_nhdsWithin hx hu
rw [insert_eq_of_mem xu] at vu v'u
exact ⟨v, nhdsWithin_le_of_mem hu vu, fun h ↦ (f_an h).mono v'u, f',
fun y hy ↦ (hf' y (v'u hy)).mono v'u, hv⟩
· intro h x hx
rw [contDiffWithinAt_succ_iff_hasFDerivWithinAt hn]
rcases h x hx with ⟨u, u_nhbd, f_an, f', hu, hf'⟩
have : x ∈ u := mem_of_mem_nhdsWithin (mem_insert _ _) u_nhbd
exact ⟨u, u_nhbd, f_an, f', hu, hf' x this⟩
/-! ### Iterated derivative within a set -/
@[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 : 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]
exact ⟨by rwa [insert_eq_of_mem hx], fun x _ => by simp [ftaylorSeriesWithin]⟩
theorem contDiffWithinAt_zero (hx : x ∈ s) :
ContDiffWithinAt 𝕜 0 f s x ↔ ∃ u ∈ 𝓝[s] x, ContinuousOn f (s ∩ u) := by
constructor
· intro h
obtain ⟨u, H, p, hp⟩ := h 0 le_rfl
refine ⟨u, ?_, ?_⟩
· simpa [hx] using H
· simp only [Nat.cast_zero, hasFTaylorSeriesUpToOn_zero_iff] at hp
exact hp.1.mono inter_subset_right
· rintro ⟨u, H, hu⟩
rw [← contDiffWithinAt_inter' H]
have h' : x ∈ s ∩ u := ⟨hx, mem_of_mem_nhdsWithin hx H⟩
exact (contDiffOn_zero.mpr hu).contDiffWithinAt h'
/-- When a function is `C^n` in a set `s` of unique differentiability, it admits
`ftaylorSeriesWithin 𝕜 f s` as a Taylor series up to order `n` in `s`. -/
protected theorem ContDiffOn.ftaylorSeriesWithin
(h : ContDiffOn 𝕜 n f s) (hs : UniqueDiffOn 𝕜 s) :
HasFTaylorSeriesUpToOn n f (ftaylorSeriesWithin 𝕜 f s) s := by
constructor
· intro x _
simp only [ftaylorSeriesWithin, ContinuousMultilinearMap.curry0_apply,
iteratedFDerivWithin_zero_apply]
· intro m hm x hx
have : (m + 1 : ℕ) ≤ n := ENat.add_one_natCast_le_withTop_of_lt hm
rcases (h x hx).of_le this _ le_rfl 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
have : p x m.succ = ftaylorSeriesWithin 𝕜 f s x m.succ := by
change p x m.succ = iteratedFDerivWithin 𝕜 m.succ f s x
rw [← iteratedFDerivWithin_inter_open o_open xo]
exact (Hp.mono ho).eq_iteratedFDerivWithin_of_uniqueDiffOn le_rfl (hs.inter o_open) ⟨hx, xo⟩
rw [← this, ← hasFDerivWithinAt_inter (IsOpen.mem_nhds o_open xo)]
have A : ∀ y ∈ s ∩ o, p y m = ftaylorSeriesWithin 𝕜 f s y m := by
rintro y ⟨hy, yo⟩
change p y m = iteratedFDerivWithin 𝕜 m f s y
rw [← iteratedFDerivWithin_inter_open o_open yo]
exact
(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 (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).of_le hm _ le_rfl 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
refine ⟨o, o_open, xo, ?_⟩
have A : ∀ y ∈ s ∩ o, p y m = ftaylorSeriesWithin 𝕜 f s y m := by
rintro y ⟨hy, yo⟩
change p y m = iteratedFDerivWithin 𝕜 m f s y
rw [← iteratedFDerivWithin_inter_open o_open yo]
exact (Hp.mono ho).eq_iteratedFDerivWithin_of_uniqueDiffOn le_rfl (hs.inter o_open) ⟨hy, yo⟩
exact ((Hp.mono ho).cont m le_rfl).congr fun y hy => (A y hy).symm
theorem iteratedFDerivWithin_subset {n : ℕ} (st : s ⊆ t) (hs : UniqueDiffOn 𝕜 s)
(ht : UniqueDiffOn 𝕜 t) (h : ContDiffOn 𝕜 n f t) (hx : x ∈ s) :
iteratedFDerivWithin 𝕜 n f s x = iteratedFDerivWithin 𝕜 n f t x :=
(((h.ftaylorSeriesWithin ht).mono st).eq_iteratedFDerivWithin_of_uniqueDiffOn le_rfl hs hx).symm
theorem ContDiffWithinAt.eventually_hasFTaylorSeriesUpToOn {f : E → F} {s : Set E} {a : E}
(h : ContDiffWithinAt 𝕜 n f s a) (hs : UniqueDiffOn 𝕜 s) (ha : a ∈ s) {m : ℕ} (hm : m ≤ n) :
∀ᶠ t in (𝓝[s] a).smallSets, HasFTaylorSeriesUpToOn m f (ftaylorSeriesWithin 𝕜 f s) t := by
rcases h.contDiffOn' hm (by simp) with ⟨U, hUo, haU, hfU⟩
have : ∀ᶠ t in (𝓝[s] a).smallSets, t ⊆ s ∩ U := by
rw [eventually_smallSets_subset]
exact inter_mem_nhdsWithin _ <| hUo.mem_nhds haU
refine this.mono fun t ht ↦ .mono ?_ ht
rw [insert_eq_of_mem ha] at hfU
refine (hfU.ftaylorSeriesWithin (hs.inter hUo)).congr_series fun k hk x hx ↦ ?_
exact iteratedFDerivWithin_inter_open hUo hx.2
/-- On a set with unique differentiability, an analytic function is automatically `C^ω`, as its
successive derivatives are also analytic. This does not require completeness of the space. See
also `AnalyticOn.contDiffOn_of_completeSpace`. -/
theorem AnalyticOn.contDiffOn (h : AnalyticOn 𝕜 f s) (hs : UniqueDiffOn 𝕜 s) :
ContDiffOn 𝕜 n f s := by
suffices ContDiffOn 𝕜 ω f s from this.of_le le_top
rcases h.exists_hasFTaylorSeriesUpToOn hs with ⟨p, hp⟩
intro x hx
refine ⟨s, ?_, p, hp⟩
rw [insert_eq_of_mem hx]
exact self_mem_nhdsWithin
/-- On a set with unique differentiability, an analytic function is automatically `C^ω`, as its
successive derivatives are also analytic. This does not require completeness of the space. See
also `AnalyticOnNhd.contDiffOn_of_completeSpace`. -/
theorem AnalyticOnNhd.contDiffOn (h : AnalyticOnNhd 𝕜 f s) (hs : UniqueDiffOn 𝕜 s) :
ContDiffOn 𝕜 n f s := h.analyticOn.contDiffOn hs
/-- An analytic function is automatically `C^ω` in a complete space -/
theorem AnalyticOn.contDiffOn_of_completeSpace [CompleteSpace F] (h : AnalyticOn 𝕜 f s) :
ContDiffOn 𝕜 n f s :=
fun x hx ↦ (h x hx).contDiffWithinAt
/-- An analytic function is automatically `C^ω` in a complete space -/
theorem AnalyticOnNhd.contDiffOn_of_completeSpace [CompleteSpace F] (h : AnalyticOnNhd 𝕜 f s) :
ContDiffOn 𝕜 n f s :=
h.analyticOn.contDiffOn_of_completeSpace
theorem contDiffOn_of_continuousOn_differentiableOn {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
rw [insert_eq_of_mem hx]
refine ⟨s, self_mem_nhdsWithin, ftaylorSeriesWithin 𝕜 f s, ?_⟩
constructor
· intro y _
simp only [ftaylorSeriesWithin, ContinuousMultilinearMap.curry0_apply,
iteratedFDerivWithin_zero_apply]
· intro k hk y hy
convert (Hdiff k (lt_of_lt_of_le (mod_cast hk) (mod_cast hm)) y hy).hasFDerivWithinAt
· intro k hk
exact Hcont k (le_trans (mod_cast hk) (mod_cast hm))
theorem contDiffOn_of_differentiableOn {n : ℕ∞}
(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_of_analyticOn_iteratedFDerivWithin
(h : ∀ m, AnalyticOn 𝕜 (iteratedFDerivWithin 𝕜 m f s) s) :
ContDiffOn 𝕜 n f s := by
suffices ContDiffOn 𝕜 ω f s from this.of_le le_top
intro x hx
refine ⟨insert x s, self_mem_nhdsWithin, ftaylorSeriesWithin 𝕜 f s, ?_, ?_⟩
· rw [insert_eq_of_mem hx]
constructor
· intro y _
simp only [ftaylorSeriesWithin, ContinuousMultilinearMap.curry0_apply,
iteratedFDerivWithin_zero_apply]
· intro k _ y hy
exact ((h k).differentiableOn y hy).hasFDerivWithinAt
· intro k _
exact (h k).continuousOn
· intro i
rw [insert_eq_of_mem hx]
exact h i
theorem contDiffOn_omega_iff_analyticOn (hs : UniqueDiffOn 𝕜 s) :
ContDiffOn 𝕜 ω f s ↔ AnalyticOn 𝕜 f s :=
⟨fun h m ↦ h.analyticOn m, fun h ↦ h.contDiffOn hs⟩
theorem ContDiffOn.continuousOn_iteratedFDerivWithin {m : ℕ} (h : ContDiffOn 𝕜 n f s)
(hmn : m ≤ n) (hs : UniqueDiffOn 𝕜 s) : ContinuousOn (iteratedFDerivWithin 𝕜 m f s) s :=
((h.of_le hmn).ftaylorSeriesWithin hs).cont m le_rfl
theorem ContDiffOn.differentiableOn_iteratedFDerivWithin {m : ℕ} (h : ContDiffOn 𝕜 n f s)
(hmn : m < n) (hs : UniqueDiffOn 𝕜 s) :
DifferentiableOn 𝕜 (iteratedFDerivWithin 𝕜 m f s) s := by
intro x hx
have : (m + 1 : ℕ) ≤ n := ENat.add_one_natCast_le_withTop_of_lt hmn
apply (((h.of_le this).ftaylorSeriesWithin hs).fderivWithin m ?_ x hx).differentiableWithinAt
exact_mod_cast lt_add_one m
theorem ContDiffWithinAt.differentiableWithinAt_iteratedFDerivWithin {m : ℕ}
(h : ContDiffWithinAt 𝕜 n f s x) (hmn : m < n) (hs : UniqueDiffOn 𝕜 (insert x s)) :
DifferentiableWithinAt 𝕜 (iteratedFDerivWithin 𝕜 m f s) s x := by
have : (m + 1 : WithTop ℕ∞) ≠ ∞ := Ne.symm (ne_of_beq_false rfl)
rcases h.contDiffOn' (ENat.add_one_natCast_le_withTop_of_lt hmn) (by simp [this])
with ⟨u, uo, xu, hu⟩
set t := insert x s ∩ u
have A : t =ᶠ[𝓝[≠] x] s := by
simp only [set_eventuallyEq_iff_inf_principal, ← nhdsWithin_inter']
rw [← inter_assoc, nhdsWithin_inter_of_mem', ← diff_eq_compl_inter, insert_diff_of_mem,
diff_eq_compl_inter]
exacts [rfl, mem_nhdsWithin_of_mem_nhds (uo.mem_nhds xu)]
have B : iteratedFDerivWithin 𝕜 m f s =ᶠ[𝓝 x] iteratedFDerivWithin 𝕜 m f t :=
iteratedFDerivWithin_eventually_congr_set' _ A.symm _
have C : DifferentiableWithinAt 𝕜 (iteratedFDerivWithin 𝕜 m f t) t x :=
hu.differentiableOn_iteratedFDerivWithin (Nat.cast_lt.2 m.lt_succ_self) (hs.inter uo) x
⟨mem_insert _ _, xu⟩
rw [differentiableWithinAt_congr_set' _ A] at C
exact C.congr_of_eventuallyEq (B.filter_mono inf_le_left) B.self_of_nhds
theorem contDiffOn_iff_continuousOn_differentiableOn {n : ℕ∞} (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 :=
⟨fun h => ⟨fun _m hm => h.continuousOn_iteratedFDerivWithin (mod_cast hm) hs,
fun _m hm => h.differentiableOn_iteratedFDerivWithin (mod_cast hm) hs⟩,
fun h => contDiffOn_of_continuousOn_differentiableOn h.1 h.2⟩
theorem contDiffOn_nat_iff_continuousOn_differentiableOn {n : ℕ} (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 := by
rw [← WithTop.coe_natCast, contDiffOn_iff_continuousOn_differentiableOn hs]
simp
theorem contDiffOn_succ_of_fderivWithin (hf : DifferentiableOn 𝕜 f s)
(h' : n = ω → AnalyticOn 𝕜 f s)
(h : ContDiffOn 𝕜 n (fun y => fderivWithin 𝕜 f s y) s) : ContDiffOn 𝕜 (n + 1) f s := by
rcases eq_or_ne n ∞ with rfl | hn
· rw [ENat.coe_top_add_one, contDiffOn_infty]
intro m x hx
apply ContDiffWithinAt.of_le _ (show (m : WithTop ℕ∞) ≤ m + 1 from le_self_add)
rw [contDiffWithinAt_succ_iff_hasFDerivWithinAt (by simp),
insert_eq_of_mem hx]
exact ⟨s, self_mem_nhdsWithin, (by simp), fderivWithin 𝕜 f s,
fun y hy => (hf y hy).hasFDerivWithinAt, (h x hx).of_le (mod_cast le_top)⟩
· intro x hx
rw [contDiffWithinAt_succ_iff_hasFDerivWithinAt hn,
insert_eq_of_mem hx]
exact ⟨s, self_mem_nhdsWithin, h', fderivWithin 𝕜 f s,
fun y hy => (hf y hy).hasFDerivWithinAt, h x hx⟩
theorem contDiffOn_of_analyticOn_of_fderivWithin (hf : AnalyticOn 𝕜 f s)
(h : ContDiffOn 𝕜 ω (fun y ↦ fderivWithin 𝕜 f s y) s) : ContDiffOn 𝕜 n f s := by
suffices ContDiffOn 𝕜 (ω + 1) f s from this.of_le le_top
exact contDiffOn_succ_of_fderivWithin hf.differentiableOn (fun _ ↦ hf) h
/-- 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 (hs : UniqueDiffOn 𝕜 s) :
ContDiffOn 𝕜 (n + 1) f s ↔
DifferentiableOn 𝕜 f s ∧ (n = ω → AnalyticOn 𝕜 f s) ∧
ContDiffOn 𝕜 n (fderivWithin 𝕜 f s) s := by
refine ⟨fun H => ?_, fun h => contDiffOn_succ_of_fderivWithin h.1 h.2.1 h.2.2⟩
refine ⟨H.differentiableOn le_add_self, ?_, fun x hx => ?_⟩
· rintro rfl
exact H.analyticOn
have A (m : ℕ) (hm : m ≤ n) : ContDiffWithinAt 𝕜 m (fun y => fderivWithin 𝕜 f s y) s x := by
rcases (contDiffWithinAt_succ_iff_hasFDerivWithinAt (n := m) (ne_of_beq_false rfl)).1
(H.of_le (by gcongr) x hx) with ⟨u, hu, -, f', hff', hf'⟩
rcases mem_nhdsWithin.1 hu with ⟨o, o_open, xo, ho⟩
rw [inter_comm, insert_eq_of_mem hx] at ho
have := hf'.mono ho
rw [contDiffWithinAt_inter' (mem_nhdsWithin_of_mem_nhds (IsOpen.mem_nhds o_open xo))] at this
apply this.congr_of_eventuallyEq_of_mem _ hx
have : o ∩ s ∈ 𝓝[s] x := mem_nhdsWithin.2 ⟨o, o_open, xo, Subset.refl _⟩
rw [inter_comm] at this
refine Filter.eventuallyEq_of_mem this fun y hy => ?_
have A : fderivWithin 𝕜 f (s ∩ o) y = f' y :=
((hff' y (ho hy)).mono ho).fderivWithin (hs.inter o_open y hy)
rwa [fderivWithin_inter (o_open.mem_nhds hy.2)] at A
match n with
| ω => exact (H.analyticOn.fderivWithin hs).contDiffOn hs (n := ω) x hx
| ∞ => exact contDiffWithinAt_infty.2 (fun m ↦ A m (mod_cast le_top))
| (n : ℕ) => exact A n le_rfl
theorem contDiffOn_succ_iff_hasFDerivWithinAt_of_uniqueDiffOn (hs : UniqueDiffOn 𝕜 s) :
ContDiffOn 𝕜 (n + 1) f s ↔ (n = ω → AnalyticOn 𝕜 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 => ⟨h.2.1, fderivWithin 𝕜 f s, h.2.2,
fun x hx => (h.1 x hx).hasFDerivWithinAt⟩, fun ⟨f_an, h⟩ => ?_⟩
rcases h with ⟨f', h1, h2⟩
refine ⟨fun x hx => (h2 x hx).differentiableWithinAt, f_an, fun x hx => ?_⟩
exact (h1 x hx).congr_of_mem (fun y hy => (h2 y hy).fderivWithin (hs y hy)) hx
theorem contDiffOn_infty_iff_fderivWithin (hs : UniqueDiffOn 𝕜 s) :
ContDiffOn 𝕜 ∞ f s ↔ DifferentiableOn 𝕜 f s ∧ ContDiffOn 𝕜 ∞ (fderivWithin 𝕜 f s) s := by
rw [← ENat.coe_top_add_one, contDiffOn_succ_iff_fderivWithin hs]
simp
/-- 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 (hs : IsOpen s) :
ContDiffOn 𝕜 (n + 1) f s ↔
DifferentiableOn 𝕜 f s ∧ (n = ω → AnalyticOn 𝕜 f s) ∧
ContDiffOn 𝕜 n (fderiv 𝕜 f) s := by
rw [contDiffOn_succ_iff_fderivWithin hs.uniqueDiffOn,
contDiffOn_congr fun x hx ↦ fderivWithin_of_isOpen hs hx]
theorem contDiffOn_infty_iff_fderiv_of_isOpen (hs : IsOpen s) :
ContDiffOn 𝕜 ∞ f s ↔ DifferentiableOn 𝕜 f s ∧ ContDiffOn 𝕜 ∞ (fderiv 𝕜 f) s := by
rw [← ENat.coe_top_add_one, contDiffOn_succ_iff_fderiv_of_isOpen hs]
simp
protected theorem ContDiffOn.fderivWithin (hf : ContDiffOn 𝕜 n f s) (hs : UniqueDiffOn 𝕜 s)
(hmn : m + 1 ≤ n) : ContDiffOn 𝕜 m (fderivWithin 𝕜 f s) s :=
((contDiffOn_succ_iff_fderivWithin hs).1 (hf.of_le hmn)).2.2
theorem ContDiffOn.fderiv_of_isOpen (hf : ContDiffOn 𝕜 n f s) (hs : IsOpen s) (hmn : m + 1 ≤ n) :
ContDiffOn 𝕜 m (fderiv 𝕜 f) s :=
(hf.fderivWithin hs.uniqueDiffOn hmn).congr fun _ hx => (fderivWithin_of_isOpen hs hx).symm
theorem ContDiffOn.continuousOn_fderivWithin (h : ContDiffOn 𝕜 n f s) (hs : UniqueDiffOn 𝕜 s)
(hn : 1 ≤ n) : ContinuousOn (fderivWithin 𝕜 f s) s :=
((contDiffOn_succ_iff_fderivWithin hs).1
(h.of_le (show 0 + (1 : WithTop ℕ∞) ≤ n from hn))).2.2.continuousOn
theorem ContDiffOn.continuousOn_fderiv_of_isOpen (h : ContDiffOn 𝕜 n f s) (hs : IsOpen s)
(hn : 1 ≤ n) : ContinuousOn (fderiv 𝕜 f) s :=
((contDiffOn_succ_iff_fderiv_of_isOpen hs).1
(h.of_le (show 0 + (1 : WithTop ℕ∞) ≤ n from hn))).2.2.continuousOn
/-! ### Smooth functions at a point -/
variable (𝕜) in
/-- A function is continuously differentiable up to `n` at a point `x` if, for any integer `k ≤ n`,
there is a neighborhood of `x` where `f` admits derivatives up to order `n`, which are continuous.
-/
@[fun_prop]
def ContDiffAt (n : WithTop ℕ∞) (f : E → F) (x : E) : Prop :=
ContDiffWithinAt 𝕜 n f univ x
theorem contDiffWithinAt_univ : ContDiffWithinAt 𝕜 n f univ x ↔ ContDiffAt 𝕜 n f x :=
Iff.rfl
theorem contDiffAt_infty : ContDiffAt 𝕜 ∞ f x ↔ ∀ n : ℕ, ContDiffAt 𝕜 n f x := by
simp [← contDiffWithinAt_univ, contDiffWithinAt_infty]
@[fun_prop]
theorem ContDiffAt.contDiffWithinAt (h : ContDiffAt 𝕜 n f x) : ContDiffWithinAt 𝕜 n f s x :=
h.mono (subset_univ _)
@[fun_prop]
theorem ContDiffWithinAt.contDiffAt (h : ContDiffWithinAt 𝕜 n f s x) (hx : s ∈ 𝓝 x) :
ContDiffAt 𝕜 n f x := by rwa [ContDiffAt, ← contDiffWithinAt_inter hx, univ_inter]
theorem contDiffWithinAt_iff_contDiffAt (h : s ∈ 𝓝 x) :
ContDiffWithinAt 𝕜 n f s x ↔ ContDiffAt 𝕜 n f x := by
rw [← univ_inter s, contDiffWithinAt_inter h, contDiffWithinAt_univ]
theorem IsOpen.contDiffOn_iff (hs : IsOpen s) :
ContDiffOn 𝕜 n f s ↔ ∀ ⦃a⦄, a ∈ s → ContDiffAt 𝕜 n f a :=
forall₂_congr fun _ => contDiffWithinAt_iff_contDiffAt ∘ hs.mem_nhds
@[fun_prop]
theorem ContDiffOn.contDiffAt (h : ContDiffOn 𝕜 n f s) (hx : s ∈ 𝓝 x) :
ContDiffAt 𝕜 n f x :=
(h _ (mem_of_mem_nhds hx)).contDiffAt hx
theorem ContDiffAt.congr_of_eventuallyEq (h : ContDiffAt 𝕜 n f x) (hg : f₁ =ᶠ[𝓝 x] f) :
ContDiffAt 𝕜 n f₁ x :=
h.congr_of_eventuallyEq_of_mem (by rwa [nhdsWithin_univ]) (mem_univ x)
theorem ContDiffAt.of_le (h : ContDiffAt 𝕜 n f x) (hmn : m ≤ n) : ContDiffAt 𝕜 m f x :=
ContDiffWithinAt.of_le h hmn
@[fun_prop]
theorem ContDiffAt.continuousAt (h : ContDiffAt 𝕜 n f x) : ContinuousAt f x := by
simpa [continuousWithinAt_univ] using h.continuousWithinAt
theorem ContDiffAt.analyticAt (h : ContDiffAt 𝕜 ω f x) : AnalyticAt 𝕜 f x := by
rw [← contDiffWithinAt_univ] at h
rw [← analyticWithinAt_univ]
exact h.analyticWithinAt
/-- In a complete space, a function which is analytic at a point is also `C^ω` there.
Note that the same statement for `AnalyticOn` does not require completeness, see
`AnalyticOn.contDiffOn`. -/
theorem AnalyticAt.contDiffAt [CompleteSpace F] (h : AnalyticAt 𝕜 f x) :
ContDiffAt 𝕜 n f x := by
rw [← contDiffWithinAt_univ]
rw [← analyticWithinAt_univ] at h
exact h.contDiffWithinAt
@[simp]
theorem contDiffWithinAt_compl_self :
ContDiffWithinAt 𝕜 n f {x}ᶜ x ↔ ContDiffAt 𝕜 n f x := by
rw [compl_eq_univ_diff, contDiffWithinAt_diff_singleton, contDiffWithinAt_univ]
/-- If a function is `C^n` with `n ≥ 1` at a point, then it is differentiable there. -/
theorem ContDiffAt.differentiableAt (h : ContDiffAt 𝕜 n f x) (hn : 1 ≤ n) :
DifferentiableAt 𝕜 f x := by
simpa [hn, differentiableWithinAt_univ] using h.differentiableWithinAt
theorem ContDiffAt.differentiableAt_iteratedFDeriv
{f : E → F} {n : WithTop ℕ∞} {m : ℕ} {x : E} (h : ContDiffAt 𝕜 n f x) (hmn : ↑m < n) :
DifferentiableAt 𝕜 (iteratedFDeriv 𝕜 m f) x := by
rw [← differentiableWithinAt_univ]
convert (h.differentiableWithinAt_iteratedFDerivWithin hmn (by simp [uniqueDiffOn_univ]))
exact iteratedFDerivWithin_univ.symm
@[fun_prop]
theorem ContDiffAt.differentiableAt_one (h : ContDiffAt 𝕜 1 f x) :
DifferentiableAt 𝕜 f x := by
simpa [(le_refl 1), differentiableWithinAt_univ] using h.differentiableWithinAt
nonrec lemma ContDiffAt.contDiffOn (h : ContDiffAt 𝕜 n f x) (hm : m ≤ n) (h' : m = ∞ → n = ω) :
∃ u ∈ 𝓝 x, ContDiffOn 𝕜 m f u := by
simpa [nhdsWithin_univ] using h.contDiffOn hm h'
/-- 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 ↔ ∃ 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 (by simp)]
simp only [nhdsWithin_univ, mem_univ, insert_eq_of_mem]
constructor
· rintro ⟨u, H, -, f', h_fderiv, h_cont_diff⟩
rcases mem_nhds_iff.mp H with ⟨t, htu, ht, hxt⟩
refine ⟨f', ⟨t, ?_⟩, h_cont_diff.contDiffAt H⟩
refine ⟨mem_nhds_iff.mpr ⟨t, Subset.rfl, ht, hxt⟩, ?_⟩
intro y hyt
refine (h_fderiv y (htu hyt)).hasFDerivAt ?_
exact mem_nhds_iff.mpr ⟨t, htu, ht, hyt⟩
· rintro ⟨f', ⟨u, H, h_fderiv⟩, h_cont_diff⟩
refine ⟨u, H, by simp, f', fun x hxu ↦ ?_, h_cont_diff.contDiffWithinAt⟩
exact (h_fderiv x hxu).hasFDerivWithinAt
protected theorem ContDiffAt.eventually (h : ContDiffAt 𝕜 n f x) (h' : n ≠ ∞) :
∀ᶠ y in 𝓝 x, ContDiffAt 𝕜 n f y := by
simpa [nhdsWithin_univ] using ContDiffWithinAt.eventually h h'
theorem iteratedFDerivWithin_eq_iteratedFDeriv {n : ℕ}
(hs : UniqueDiffOn 𝕜 s) (h : ContDiffAt 𝕜 n f x) (hx : x ∈ s) :
iteratedFDerivWithin 𝕜 n f s x = iteratedFDeriv 𝕜 n f x := by
rw [← iteratedFDerivWithin_univ]
rcases h.contDiffOn' le_rfl (by simp) with ⟨u, u_open, xu, hu⟩
rw [← iteratedFDerivWithin_inter_open u_open xu,
← iteratedFDerivWithin_inter_open u_open xu (s := univ)]
apply iteratedFDerivWithin_subset
· exact inter_subset_inter_left _ (subset_univ _)
· exact hs.inter u_open
· apply uniqueDiffOn_univ.inter u_open
· simpa using hu
· exact ⟨hx, xu⟩
/-! ### Smooth functions -/
variable (𝕜) in
/-- A function is continuously differentiable up to `n` if it admits derivatives up to
order `n`, which are continuous. Contrary to the case of definitions in domains (where derivatives
might not be unique) we do not need to localize the definition in space or time.
-/
@[fun_prop]
def ContDiff (n : WithTop ℕ∞) (f : E → F) : Prop :=
match n with
| ω => ∃ p : E → FormalMultilinearSeries 𝕜 E F, HasFTaylorSeriesUpTo ⊤ f p
∧ ∀ i, AnalyticOnNhd 𝕜 (fun x ↦ p x i) univ
| (n : ℕ∞) => ∃ p : E → FormalMultilinearSeries 𝕜 E F, HasFTaylorSeriesUpTo n f p
/-- If `f` has a Taylor series up to `n`, then it is `C^n`. -/
theorem HasFTaylorSeriesUpTo.contDiff {n : ℕ∞} {f' : E → FormalMultilinearSeries 𝕜 E F}
(hf : HasFTaylorSeriesUpTo n f f') : ContDiff 𝕜 n f :=
⟨f', hf⟩
@[simp, fun_prop] theorem contDiffOn_empty : ContDiffOn 𝕜 n f ∅ := fun _x hx ↦ hx.elim
theorem contDiffOn_univ : ContDiffOn 𝕜 n f univ ↔ ContDiff 𝕜 n f := by
match n with
| ω =>
constructor
· intro H
use ftaylorSeriesWithin 𝕜 f univ
rw [← hasFTaylorSeriesUpToOn_univ_iff]
refine ⟨H.ftaylorSeriesWithin uniqueDiffOn_univ, fun i ↦ ?_⟩
rw [← analyticOn_univ]
exact H.analyticOn.iteratedFDerivWithin uniqueDiffOn_univ _
· rintro ⟨p, hp, h'p⟩ x _
exact ⟨univ, Filter.univ_sets _, p, (hp.hasFTaylorSeriesUpToOn univ).of_le le_top,
fun i ↦ (h'p i).analyticOn⟩
| (n : ℕ∞) =>
constructor
· intro H
use ftaylorSeriesWithin 𝕜 f univ
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 (mod_cast hm)⟩
theorem contDiff_iff_contDiffAt : ContDiff 𝕜 n f ↔ ∀ x, ContDiffAt 𝕜 n f x := by
simp [← contDiffOn_univ, ContDiffOn, ContDiffAt]
@[fun_prop]
theorem ContDiff.contDiffAt (h : ContDiff 𝕜 n f) : ContDiffAt 𝕜 n f x :=
contDiff_iff_contDiffAt.1 h x
@[fun_prop]
theorem ContDiff.contDiffWithinAt (h : ContDiff 𝕜 n f) : ContDiffWithinAt 𝕜 n f s x :=
h.contDiffAt.contDiffWithinAt
theorem contDiff_infty : ContDiff 𝕜 ∞ f ↔ ∀ n : ℕ, ContDiff 𝕜 n f := by
simp [contDiffOn_univ.symm, contDiffOn_infty]
theorem contDiff_all_iff_nat : (∀ n : ℕ∞, ContDiff 𝕜 n f) ↔ ∀ n : ℕ, ContDiff 𝕜 n f := by
simp only [← contDiffOn_univ, contDiffOn_all_iff_nat]
@[fun_prop]
theorem ContDiff.contDiffOn (h : ContDiff 𝕜 n f) : ContDiffOn 𝕜 n f s :=
(contDiffOn_univ.2 h).mono (subset_univ _)
@[simp]
theorem contDiff_zero : ContDiff 𝕜 0 f ↔ Continuous f := by
rw [← contDiffOn_univ, ← continuousOn_univ]
exact contDiffOn_zero
theorem contDiffAt_zero : ContDiffAt 𝕜 0 f x ↔ ∃ u ∈ 𝓝 x, ContinuousOn f u := by
rw [← contDiffWithinAt_univ]; simp [contDiffWithinAt_zero, nhdsWithin_univ]
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
rw [show (1 : WithTop ℕ∞) = (0 : ℕ) + 1 from rfl]
simp_rw [contDiffAt_succ_iff_hasFDerivAt, show ((0 : ℕ) : WithTop ℕ∞) = 0 from rfl,
contDiffAt_zero, exists_mem_and_iff antitone_bforall antitone_continuousOn, and_comm]
@[fun_prop]
theorem ContDiff.of_le (h : ContDiff 𝕜 n f) (hmn : m ≤ n) : ContDiff 𝕜 m f :=
contDiffOn_univ.1 <| (contDiffOn_univ.2 h).of_le hmn
theorem ContDiff.of_succ (h : ContDiff 𝕜 (n + 1) f) : ContDiff 𝕜 n f :=
h.of_le le_self_add
theorem ContDiff.one_of_succ (h : ContDiff 𝕜 (n + 1) f) : ContDiff 𝕜 1 f := by
apply h.of_le le_add_self
theorem ContDiff.continuous (h : ContDiff 𝕜 n f) : Continuous f :=
contDiff_zero.1 (h.of_le bot_le)
@[fun_prop]
theorem ContDiff.continuous_zero (h : ContDiff 𝕜 0 f) : Continuous f :=
contDiff_zero.1 (h.of_le bot_le)
/-- If a function is `C^n` with `n ≥ 1`, then it is differentiable. -/
theorem ContDiff.differentiable (h : ContDiff 𝕜 n f) (hn : 1 ≤ n) : Differentiable 𝕜 f :=
differentiableOn_univ.1 <| (contDiffOn_univ.2 h).differentiableOn hn
@[fun_prop]
theorem ContDiff.differentiable_one (h : ContDiff 𝕜 1 f) : Differentiable 𝕜 f :=
differentiableOn_univ.1 <| (contDiffOn_univ.2 h).differentiableOn (le_refl 1)
theorem contDiff_iff_forall_nat_le {n : ℕ∞} :
ContDiff 𝕜 n f ↔ ∀ m : ℕ, ↑m ≤ n → ContDiff 𝕜 m f := by
simp_rw [← contDiffOn_univ]; exact contDiffOn_iff_forall_nat_le
/-- A function is `C^(n+1)` iff it has a `C^n` derivative. -/
theorem contDiff_succ_iff_hasFDerivAt {n : ℕ} :
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, Set.mem_univ, forall_true_left,
contDiffOn_succ_iff_hasFDerivWithinAt_of_uniqueDiffOn uniqueDiffOn_univ,
WithTop.natCast_ne_top, analyticOn_univ, false_implies, true_and]
theorem contDiff_one_iff_hasFDerivAt : ContDiff 𝕜 1 f ↔
∃ f' : E → E →L[𝕜] F, Continuous f' ∧ ∀ x, HasFDerivAt f (f' x) x := by
convert contDiff_succ_iff_hasFDerivAt using 4; simp
theorem AnalyticOn.contDiff (hf : AnalyticOn 𝕜 f univ) : ContDiff 𝕜 n f := by
rw [← contDiffOn_univ]
exact hf.contDiffOn (n := n) uniqueDiffOn_univ
theorem AnalyticOnNhd.contDiff (hf : AnalyticOnNhd 𝕜 f univ) : ContDiff 𝕜 n f :=
hf.analyticOn.contDiff
theorem ContDiff.analyticOnNhd (h : ContDiff 𝕜 ω f) : AnalyticOnNhd 𝕜 f s := by
rw [← contDiffOn_univ] at h
have := h.analyticOn
rw [analyticOn_univ] at this
exact this.mono (subset_univ _)
theorem contDiff_omega_iff_analyticOnNhd :
ContDiff 𝕜 ω f ↔ AnalyticOnNhd 𝕜 f univ :=
⟨fun h ↦ h.analyticOnNhd, fun h ↦ h.contDiff⟩
/-! ### Iterated derivative -/
/-- When a function is `C^n`, it admits `ftaylorSeries 𝕜 f` as a Taylor series up
to order `n` in `s`. -/
theorem ContDiff.ftaylorSeries (hf : ContDiff 𝕜 n f) :
HasFTaylorSeriesUpTo n f (ftaylorSeries 𝕜 f) := by
simp only [← contDiffOn_univ, ← hasFTaylorSeriesUpToOn_univ_iff, ← ftaylorSeriesWithin_univ]
at hf ⊢
exact ContDiffOn.ftaylorSeriesWithin hf uniqueDiffOn_univ
/-- For `n : ℕ∞`, a function is `C^n` iff it admits `ftaylorSeries 𝕜 f`
as a Taylor series up to order `n`. -/
theorem contDiff_iff_ftaylorSeries {n : ℕ∞} :
ContDiff 𝕜 n f ↔ HasFTaylorSeriesUpTo n f (ftaylorSeries 𝕜 f) := by
constructor
· rw [← contDiffOn_univ, ← hasFTaylorSeriesUpToOn_univ_iff, ← ftaylorSeriesWithin_univ]
exact fun h ↦ ContDiffOn.ftaylorSeriesWithin h uniqueDiffOn_univ
· exact fun h ↦ ⟨ftaylorSeries 𝕜 f, h⟩
theorem contDiff_iff_continuous_differentiable {n : ℕ∞} :
ContDiff 𝕜 n f ↔
(∀ 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, continuousOn_univ, differentiableOn_univ.symm,
iteratedFDerivWithin_univ, contDiffOn_iff_continuousOn_differentiableOn uniqueDiffOn_univ]
theorem contDiff_nat_iff_continuous_differentiable {n : ℕ} :
ContDiff 𝕜 n f ↔
(∀ m : ℕ, m ≤ n → Continuous fun x => iteratedFDeriv 𝕜 m f x) ∧
∀ m : ℕ, m < n → Differentiable 𝕜 fun x => iteratedFDeriv 𝕜 m f x := by
rw [← WithTop.coe_natCast, contDiff_iff_continuous_differentiable]
simp
/-- 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) :
Continuous fun x => iteratedFDeriv 𝕜 m f x :=
(contDiff_iff_continuous_differentiable.mp (hf.of_le hm)).1 m le_rfl
@[fun_prop]
theorem ContDiff.continuous_iteratedFDeriv' {m : ℕ} (hf : ContDiff 𝕜 m f) :
Continuous fun x => iteratedFDeriv 𝕜 m f x :=
(contDiff_iff_continuous_differentiable.mp hf).1 m le_rfl
/-- 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) :
Differentiable 𝕜 fun x => iteratedFDeriv 𝕜 m f x :=
(contDiff_iff_continuous_differentiable.mp
(hf.of_le (ENat.add_one_natCast_le_withTop_of_lt hm))).2 m (mod_cast lt_add_one m)
theorem contDiff_of_differentiable_iteratedFDeriv {n : ℕ∞}
(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 :
ContDiff 𝕜 (n + 1) f ↔ Differentiable 𝕜 f ∧ (n = ω → AnalyticOnNhd 𝕜 f univ) ∧
ContDiff 𝕜 n (fderiv 𝕜 f) := by
simp only [← contDiffOn_univ, ← differentiableOn_univ, ← fderivWithin_univ,
contDiffOn_succ_iff_fderivWithin uniqueDiffOn_univ, analyticOn_univ]
theorem contDiff_one_iff_fderiv :
ContDiff 𝕜 1 f ↔ Differentiable 𝕜 f ∧ Continuous (fderiv 𝕜 f) := by
rw [← zero_add 1, contDiff_succ_iff_fderiv]
simp
theorem contDiff_infty_iff_fderiv :
ContDiff 𝕜 ∞ f ↔ Differentiable 𝕜 f ∧ ContDiff 𝕜 ∞ (fderiv 𝕜 f) := by
rw [← ENat.coe_top_add_one, contDiff_succ_iff_fderiv]
simp
theorem ContDiff.continuous_fderiv (h : ContDiff 𝕜 n f) (hn : 1 ≤ n) :
Continuous (fderiv 𝕜 f) :=
(contDiff_one_iff_fderiv.1 (h.of_le hn)).2
/-- If a function is at least `C^1`, its bundled derivative (mapping `(x, v)` to `Df(x) v`) is
continuous. -/
theorem ContDiff.continuous_fderiv_apply (h : ContDiff 𝕜 n f) (hn : 1 ≤ n) :
Continuous fun p : E × E => (fderiv 𝕜 f p.1 : E → F) p.2 :=
have A : Continuous fun q : (E →L[𝕜] F) × E => q.1 q.2 := isBoundedBilinearMap_apply.continuous
have B : Continuous fun p : E × E => (fderiv 𝕜 f p.1, p.2) :=
((h.continuous_fderiv hn).comp continuous_fst).prodMk continuous_snd
A.comp B |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/ContDiff/WithLp.lean | import Mathlib.Analysis.Calculus.ContDiff.Operations
import Mathlib.Analysis.Normed.Lp.PiLp
/-!
# Derivatives on `WithLp`
-/
open scoped ENNReal
section PiLp
open ContinuousLinearMap WithLp
variable {𝕜 ι : Type*} {E : ι → Type*} {H : Type*}
variable [NontriviallyNormedField 𝕜] [NormedAddCommGroup H] [∀ i, NormedAddCommGroup (E i)]
[∀ i, NormedSpace 𝕜 (E i)] [NormedSpace 𝕜 H] [Fintype ι] (p) [Fact (1 ≤ p)]
{n : WithTop ℕ∞} {f : H → PiLp p E} {f' : H →L[𝕜] PiLp p E} {t : Set H} {y : H}
theorem contDiffWithinAt_piLp :
ContDiffWithinAt 𝕜 n f t y ↔ ∀ i, ContDiffWithinAt 𝕜 n (fun x => f x i) t y := by
rw [← (PiLp.continuousLinearEquiv p 𝕜 E).comp_contDiffWithinAt_iff, contDiffWithinAt_pi]
rfl
@[fun_prop]
theorem contDiffWithinAt_piLp' (hf : ∀ i, ContDiffWithinAt 𝕜 n (fun x => f x i) t y) :
ContDiffWithinAt 𝕜 n f t y :=
(contDiffWithinAt_piLp p).2 hf
@[fun_prop]
theorem contDiffWithinAt_piLp_apply {i : ι} {t : Set (PiLp p E)} {y : PiLp p E} :
ContDiffWithinAt 𝕜 n (fun f : PiLp p E => f i) t y :=
(contDiffWithinAt_piLp p).1 contDiffWithinAt_id i
theorem contDiffAt_piLp :
ContDiffAt 𝕜 n f y ↔ ∀ i, ContDiffAt 𝕜 n (fun x => f x i) y := by
rw [← (PiLp.continuousLinearEquiv p 𝕜 E).comp_contDiffAt_iff, contDiffAt_pi]
rfl
@[fun_prop]
theorem contDiffAt_piLp' (hf : ∀ i, ContDiffAt 𝕜 n (fun x => f x i) y) :
ContDiffAt 𝕜 n f y :=
(contDiffAt_piLp p).2 hf
@[fun_prop]
theorem contDiffAt_piLp_apply {i : ι} {y : PiLp p E} :
ContDiffAt 𝕜 n (fun f : PiLp p E => f i) y :=
(contDiffAt_piLp p).1 contDiffAt_id i
theorem contDiffOn_piLp :
ContDiffOn 𝕜 n f t ↔ ∀ i, ContDiffOn 𝕜 n (fun x => f x i) t := by
rw [← (PiLp.continuousLinearEquiv p 𝕜 E).comp_contDiffOn_iff, contDiffOn_pi]
rfl
@[fun_prop]
theorem contDiffOn_piLp' (hf : ∀ i, ContDiffOn 𝕜 n (fun x => f x i) t) :
ContDiffOn 𝕜 n f t :=
(contDiffOn_piLp p).2 hf
@[fun_prop]
theorem contDiffOn_piLp_apply {i : ι} {t : Set (PiLp p E)} :
ContDiffOn 𝕜 n (fun f : PiLp p E => f i) t :=
(contDiffOn_piLp p).1 contDiffOn_id i
theorem contDiff_piLp : ContDiff 𝕜 n f ↔ ∀ i, ContDiff 𝕜 n fun x => f x i := by
rw [← (PiLp.continuousLinearEquiv p 𝕜 E).comp_contDiff_iff, contDiff_pi]
rfl
@[fun_prop]
theorem contDiff_piLp' (hf : ∀ i, ContDiff 𝕜 n (fun x => f x i)) :
ContDiff 𝕜 n f :=
(contDiff_piLp p).2 hf
@[fun_prop]
theorem contDiff_piLp_apply {i : ι} :
ContDiff 𝕜 n (fun f : PiLp p E => f i) :=
(contDiff_piLp p).1 contDiff_id i
variable {p}
lemma PiLp.contDiff_ofLp : ContDiff 𝕜 n (@ofLp p (Π i, E i)) :=
(continuousLinearEquiv p 𝕜 E).contDiff
lemma PiLp.contDiff_toLp : ContDiff 𝕜 n (@toLp p (Π i, E i)) :=
(continuousLinearEquiv p 𝕜 E).symm.contDiff
end PiLp
namespace WithLp
variable {𝕜 E F : Type*} [NontriviallyNormedField 𝕜] [NormedAddCommGroup E] [NormedAddCommGroup F]
[NormedSpace 𝕜 E] [NormedSpace 𝕜 F] {p : ℝ≥0∞} [Fact (1 ≤ p)] {n : WithTop ℕ∞}
lemma contDiff_ofLp : ContDiff 𝕜 n (@ofLp p (E × F)) :=
(prodContinuousLinearEquiv p 𝕜 E F).contDiff
lemma contDiff_toLp : ContDiff 𝕜 n (@toLp p (E × F)) :=
(prodContinuousLinearEquiv p 𝕜 E F).symm.contDiff
end WithLp |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/ContDiff/CPolynomial.lean | import Mathlib.Analysis.Calculus.FDeriv.Analytic
import Mathlib.Analysis.Calculus.ContDiff.Defs
/-!
# Higher smoothness of continuously polynomial functions
We prove that continuously polynomial functions are `C^∞`. In particular, this is the case
of continuous multilinear maps.
-/
open Filter Asymptotics
open scoped ENNReal
universe u v
variable {𝕜 : Type*} [NontriviallyNormedField 𝕜]
variable {E : Type u} [NormedAddCommGroup E] [NormedSpace 𝕜 E]
variable {F : Type v} [NormedAddCommGroup F] [NormedSpace 𝕜 F]
section fderiv
variable {p : FormalMultilinearSeries 𝕜 E F} {r : ℝ≥0∞} {n : ℕ}
variable {f : E → F} {x : E} {s : Set E}
/-- A polynomial function is infinitely differentiable. -/
theorem CPolynomialOn.contDiffOn (h : CPolynomialOn 𝕜 f s) {n : WithTop ℕ∞} :
ContDiffOn 𝕜 n f s := by
let t := { x | CPolynomialAt 𝕜 f x }
suffices ContDiffOn 𝕜 n f t from this.mono h
suffices AnalyticOnNhd 𝕜 f t by
have t_open : IsOpen t := isOpen_cpolynomialAt 𝕜 f
exact AnalyticOnNhd.contDiffOn this t_open.uniqueDiffOn
have H : CPolynomialOn 𝕜 f t := fun _x hx ↦ hx
exact H.analyticOnNhd
theorem CPolynomialAt.contDiffAt (h : CPolynomialAt 𝕜 f x) {n : WithTop ℕ∞} :
ContDiffAt 𝕜 n f x :=
let ⟨_, hs, hf⟩ := h.exists_mem_nhds_cpolynomialOn
hf.contDiffOn.contDiffAt hs
end fderiv
namespace ContinuousMultilinearMap
variable {ι : Type*} {E : ι → Type*} [∀ i, NormedAddCommGroup (E i)] [∀ i, NormedSpace 𝕜 (E i)]
[Fintype ι] (f : ContinuousMultilinearMap 𝕜 E F) {n : WithTop ℕ∞} {x : Π i, E i}
open FormalMultilinearSeries
lemma contDiffAt : ContDiffAt 𝕜 n f x := f.cpolynomialAt.contDiffAt
lemma contDiff : ContDiff 𝕜 n f := contDiff_iff_contDiffAt.mpr (fun _ ↦ f.contDiffAt)
end ContinuousMultilinearMap |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/ContDiff/Bounds.lean | import Mathlib.Analysis.Calculus.ContDiff.Operations
import Mathlib.Data.Finset.Sym
import Mathlib.Data.Nat.Choose.Cast
import Mathlib.Data.Nat.Choose.Multinomial
/-!
# Bounds on higher derivatives
`norm_iteratedFDeriv_comp_le` gives the bound `n! * C * D ^ n` for the `n`-th derivative
of `g ∘ f` assuming that the derivatives of `g` are bounded by `C` and the `i`-th
derivative of `f` is bounded by `D ^ i`.
-/
noncomputable section
open scoped NNReal Nat
universe u uD uE uF uG
open Set Fin Filter Function
variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] {D : Type uD} [NormedAddCommGroup D]
[NormedSpace 𝕜 D] {E : Type uE} [NormedAddCommGroup E] [NormedSpace 𝕜 E] {F : Type uF}
[NormedAddCommGroup F] [NormedSpace 𝕜 F] {G : Type uG} [NormedAddCommGroup G] [NormedSpace 𝕜 G]
{s s₁ t u : Set E}
/-!## Quantitative bounds -/
/-- Bounding the norm of the iterated derivative of `B (f x) (g x)` within a set in terms of the
iterated derivatives of `f` and `g` when `B` is bilinear. This lemma is an auxiliary version
assuming all spaces live in the same universe, to enable an induction. Use instead
`ContinuousLinearMap.norm_iteratedFDerivWithin_le_of_bilinear` that removes this assumption. -/
theorem ContinuousLinearMap.norm_iteratedFDerivWithin_le_of_bilinear_aux {Du Eu Fu Gu : Type u}
[NormedAddCommGroup Du] [NormedSpace 𝕜 Du] [NormedAddCommGroup Eu] [NormedSpace 𝕜 Eu]
[NormedAddCommGroup Fu] [NormedSpace 𝕜 Fu] [NormedAddCommGroup Gu] [NormedSpace 𝕜 Gu]
(B : Eu →L[𝕜] Fu →L[𝕜] Gu) {f : Du → Eu} {g : Du → Fu} {n : ℕ} {s : Set Du} {x : Du}
(hf : ContDiffOn 𝕜 n f s) (hg : ContDiffOn 𝕜 n g s) (hs : UniqueDiffOn 𝕜 s) (hx : x ∈ s) :
‖iteratedFDerivWithin 𝕜 n (fun y => B (f y) (g y)) s x‖ ≤
‖B‖ * ∑ i ∈ Finset.range (n + 1), (n.choose i : ℝ) * ‖iteratedFDerivWithin 𝕜 i f s x‖ *
‖iteratedFDerivWithin 𝕜 (n - i) g s x‖ := by
/- We argue by induction on `n`. The bound is trivial for `n = 0`. For `n + 1`, we write
the `(n+1)`-th derivative as the `n`-th derivative of the derivative `B f g' + B f' g`,
and apply the inductive assumption to each of those two terms. For this induction to make sense,
the spaces of linear maps that appear in the induction should be in the same universe as the
original spaces, which explains why we assume in the lemma that all spaces live in the same
universe. -/
induction n generalizing Eu Fu Gu with
| zero =>
simp only [norm_iteratedFDerivWithin_zero, zero_add, Finset.range_one,
Finset.sum_singleton, Nat.choose_self, Nat.cast_one, one_mul, Nat.sub_zero, ← mul_assoc]
apply B.le_opNorm₂
| succ n IH =>
have In : (n : WithTop ℕ∞) + 1 ≤ n.succ := by simp only [Nat.cast_succ, le_refl]
have I1 :
‖iteratedFDerivWithin 𝕜 n (fun y : Du => B.precompR Du (f y) (fderivWithin 𝕜 g s y)) s x‖ ≤
‖B‖ * ∑ i ∈ Finset.range (n + 1), n.choose i * ‖iteratedFDerivWithin 𝕜 i f s x‖ *
‖iteratedFDerivWithin 𝕜 (n + 1 - i) g s x‖ := by
calc
‖iteratedFDerivWithin 𝕜 n (fun y : Du => B.precompR Du (f y) (fderivWithin 𝕜 g s y)) s x‖ ≤
‖B.precompR Du‖ * ∑ i ∈ Finset.range (n + 1),
n.choose i * ‖iteratedFDerivWithin 𝕜 i f s x‖ *
‖iteratedFDerivWithin 𝕜 (n - i) (fderivWithin 𝕜 g s) s x‖ :=
IH _ (hf.of_le (Nat.cast_le.2 (Nat.le_succ n))) (hg.fderivWithin hs In)
_ ≤ ‖B‖ * ∑ i ∈ Finset.range (n + 1), n.choose i * ‖iteratedFDerivWithin 𝕜 i f s x‖ *
‖iteratedFDerivWithin 𝕜 (n - i) (fderivWithin 𝕜 g s) s x‖ := by
gcongr; exact B.norm_precompR_le Du
_ = _ := by
congr 1
apply Finset.sum_congr rfl fun i hi => ?_
rw [Nat.succ_sub (Nat.lt_succ_iff.1 (Finset.mem_range.1 hi)),
← norm_iteratedFDerivWithin_fderivWithin hs hx]
have I2 :
‖iteratedFDerivWithin 𝕜 n (fun y : Du => B.precompL Du (fderivWithin 𝕜 f s y) (g y)) s x‖ ≤
‖B‖ * ∑ i ∈ Finset.range (n + 1), n.choose i * ‖iteratedFDerivWithin 𝕜 (i + 1) f s x‖ *
‖iteratedFDerivWithin 𝕜 (n - i) g s x‖ :=
calc
‖iteratedFDerivWithin 𝕜 n (fun y : Du => B.precompL Du (fderivWithin 𝕜 f s y) (g y)) s x‖ ≤
‖B.precompL Du‖ * ∑ i ∈ Finset.range (n + 1),
n.choose i * ‖iteratedFDerivWithin 𝕜 i (fderivWithin 𝕜 f s) s x‖ *
‖iteratedFDerivWithin 𝕜 (n - i) g s x‖ :=
IH _ (hf.fderivWithin hs In) (hg.of_le (Nat.cast_le.2 (Nat.le_succ n)))
_ ≤ ‖B‖ * ∑ i ∈ Finset.range (n + 1),
n.choose i * ‖iteratedFDerivWithin 𝕜 i (fderivWithin 𝕜 f s) s x‖ *
‖iteratedFDerivWithin 𝕜 (n - i) g s x‖ := by
gcongr; exact B.norm_precompL_le Du
_ = _ := by
congr 1
apply Finset.sum_congr rfl fun i _ => ?_
rw [← norm_iteratedFDerivWithin_fderivWithin hs hx]
have J : iteratedFDerivWithin 𝕜 n
(fun y : Du => fderivWithin 𝕜 (fun y : Du => B (f y) (g y)) s y) s x =
iteratedFDerivWithin 𝕜 n (fun y => B.precompR Du (f y)
(fderivWithin 𝕜 g s y) + B.precompL Du (fderivWithin 𝕜 f s y) (g y)) s x := by
apply iteratedFDerivWithin_congr (fun y hy => ?_) hx
have L : (1 : WithTop ℕ∞) ≤ n.succ := by
simpa only [ENat.coe_one, Nat.one_le_cast] using Nat.succ_pos n
exact B.fderivWithin_of_bilinear (hf.differentiableOn L y hy) (hg.differentiableOn L y hy)
(hs y hy)
rw [← norm_iteratedFDerivWithin_fderivWithin hs hx, J]
have A : ContDiffOn 𝕜 n (fun y => B.precompR Du (f y) (fderivWithin 𝕜 g s y)) s :=
(B.precompR Du).isBoundedBilinearMap.contDiff.comp₂_contDiffOn
(hf.of_le (Nat.cast_le.2 (Nat.le_succ n))) (hg.fderivWithin hs In)
have A' : ContDiffOn 𝕜 n (fun y => B.precompL Du (fderivWithin 𝕜 f s y) (g y)) s :=
(B.precompL Du).isBoundedBilinearMap.contDiff.comp₂_contDiffOn (hf.fderivWithin hs In)
(hg.of_le (Nat.cast_le.2 (Nat.le_succ n)))
rw [iteratedFDerivWithin_add_apply' (A.contDiffWithinAt hx) (A'.contDiffWithinAt hx) hs hx]
apply (norm_add_le _ _).trans ((add_le_add I1 I2).trans (le_of_eq ?_))
simp_rw [← mul_add, mul_assoc]
congr 1
exact (Finset.sum_choose_succ_mul
(fun i j => ‖iteratedFDerivWithin 𝕜 i f s x‖ * ‖iteratedFDerivWithin 𝕜 j g s x‖) n).symm
/-- Bounding the norm of the iterated derivative of `B (f x) (g x)` within a set in terms of the
iterated derivatives of `f` and `g` when `B` is bilinear:
`‖D^n (x ↦ B (f x) (g x))‖ ≤ ‖B‖ ∑_{k ≤ n} n.choose k ‖D^k f‖ ‖D^{n-k} g‖` -/
theorem ContinuousLinearMap.norm_iteratedFDerivWithin_le_of_bilinear (B : E →L[𝕜] F →L[𝕜] G)
{f : D → E} {g : D → F} {N : WithTop ℕ∞} {s : Set D} {x : D} (hf : ContDiffOn 𝕜 N f s)
(hg : ContDiffOn 𝕜 N g s) (hs : UniqueDiffOn 𝕜 s) (hx : x ∈ s) {n : ℕ} (hn : n ≤ N) :
‖iteratedFDerivWithin 𝕜 n (fun y => B (f y) (g y)) s x‖ ≤
‖B‖ * ∑ i ∈ Finset.range (n + 1), (n.choose i : ℝ) * ‖iteratedFDerivWithin 𝕜 i f s x‖ *
‖iteratedFDerivWithin 𝕜 (n - i) g s x‖ := by
/- We reduce the bound to the case where all spaces live in the same universe (in which we
already have proved the result), by using linear isometries between the spaces and their `ULift`
to a common universe. These linear isometries preserve the norm of the iterated derivative. -/
let Du : Type max uD uE uF uG := ULift.{max uE uF uG, uD} D
let Eu : Type max uD uE uF uG := ULift.{max uD uF uG, uE} E
let Fu : Type max uD uE uF uG := ULift.{max uD uE uG, uF} F
let Gu : Type max uD uE uF uG := ULift.{max uD uE uF, uG} G
have isoD : Du ≃ₗᵢ[𝕜] D := LinearIsometryEquiv.ulift 𝕜 D
have isoE : Eu ≃ₗᵢ[𝕜] E := LinearIsometryEquiv.ulift 𝕜 E
have isoF : Fu ≃ₗᵢ[𝕜] F := LinearIsometryEquiv.ulift 𝕜 F
have isoG : Gu ≃ₗᵢ[𝕜] G := LinearIsometryEquiv.ulift 𝕜 G
-- lift `f` and `g` to versions `fu` and `gu` on the lifted spaces.
let fu : Du → Eu := isoE.symm ∘ f ∘ isoD
let gu : Du → Fu := isoF.symm ∘ g ∘ isoD
-- lift the bilinear map `B` to a bilinear map `Bu` on the lifted spaces.
let Bu₀ : Eu →L[𝕜] Fu →L[𝕜] G := ((B.comp (isoE : Eu →L[𝕜] E)).flip.comp (isoF : Fu →L[𝕜] F)).flip
let Bu : Eu →L[𝕜] Fu →L[𝕜] Gu :=
ContinuousLinearMap.compL 𝕜 Eu (Fu →L[𝕜] G) (Fu →L[𝕜] Gu)
(ContinuousLinearMap.compL 𝕜 Fu G Gu (isoG.symm : G →L[𝕜] Gu)) Bu₀
have hBu : Bu = ContinuousLinearMap.compL 𝕜 Eu (Fu →L[𝕜] G) (Fu →L[𝕜] Gu)
(ContinuousLinearMap.compL 𝕜 Fu G Gu (isoG.symm : G →L[𝕜] Gu)) Bu₀ := rfl
have Bu_eq : (fun y => Bu (fu y) (gu y)) = isoG.symm ∘ (fun y => B (f y) (g y)) ∘ isoD := by
ext1 y
simp [Du, Eu, Fu, Gu, hBu, Bu₀, fu, gu]
-- All norms are preserved by the lifting process.
have Bu_le : ‖Bu‖ ≤ ‖B‖ := by
refine ContinuousLinearMap.opNorm_le_bound _ (norm_nonneg B) fun y => ?_
refine ContinuousLinearMap.opNorm_le_bound _ (by positivity) fun x => ?_
simp only [Eu, Fu, Gu, hBu, Bu₀, compL_apply, coe_comp', Function.comp_apply,
ContinuousLinearEquiv.coe_coe, LinearIsometryEquiv.coe_coe, flip_apply,
LinearIsometryEquiv.norm_map]
calc
‖B (isoE y) (isoF x)‖ ≤ ‖B (isoE y)‖ * ‖isoF x‖ := ContinuousLinearMap.le_opNorm _ _
_ ≤ ‖B‖ * ‖isoE y‖ * ‖isoF x‖ := by gcongr; apply ContinuousLinearMap.le_opNorm
_ = ‖B‖ * ‖y‖ * ‖x‖ := by simp only [LinearIsometryEquiv.norm_map]
let su := isoD ⁻¹' s
have hsu : UniqueDiffOn 𝕜 su := isoD.toContinuousLinearEquiv.uniqueDiffOn_preimage_iff.2 hs
let xu := isoD.symm x
have hxu : xu ∈ su := by
simpa only [xu, su, Set.mem_preimage, LinearIsometryEquiv.apply_symm_apply] using hx
have xu_x : isoD xu = x := by simp only [xu, LinearIsometryEquiv.apply_symm_apply]
have hfu : ContDiffOn 𝕜 n fu su :=
isoE.symm.contDiff.comp_contDiffOn
((hf.of_le hn).comp_continuousLinearMap (isoD : Du →L[𝕜] D))
have hgu : ContDiffOn 𝕜 n gu su :=
isoF.symm.contDiff.comp_contDiffOn
((hg.of_le hn).comp_continuousLinearMap (isoD : Du →L[𝕜] D))
have Nfu : ∀ i, ‖iteratedFDerivWithin 𝕜 i fu su xu‖ = ‖iteratedFDerivWithin 𝕜 i f s x‖ := by
intro i
rw [LinearIsometryEquiv.norm_iteratedFDerivWithin_comp_left _ _ hsu hxu]
rw [LinearIsometryEquiv.norm_iteratedFDerivWithin_comp_right _ _ hs, xu_x]
rwa [← xu_x] at hx
have Ngu : ∀ i, ‖iteratedFDerivWithin 𝕜 i gu su xu‖ = ‖iteratedFDerivWithin 𝕜 i g s x‖ := by
intro i
rw [LinearIsometryEquiv.norm_iteratedFDerivWithin_comp_left _ _ hsu hxu]
rw [LinearIsometryEquiv.norm_iteratedFDerivWithin_comp_right _ _ hs, xu_x]
rwa [← xu_x] at hx
have NBu :
‖iteratedFDerivWithin 𝕜 n (fun y => Bu (fu y) (gu y)) su xu‖ =
‖iteratedFDerivWithin 𝕜 n (fun y => B (f y) (g y)) s x‖ := by
rw [Bu_eq]
rw [LinearIsometryEquiv.norm_iteratedFDerivWithin_comp_left _ _ hsu hxu]
rw [LinearIsometryEquiv.norm_iteratedFDerivWithin_comp_right _ _ hs, xu_x]
rwa [← xu_x] at hx
-- state the bound for the lifted objects, and deduce the original bound from it.
have : ‖iteratedFDerivWithin 𝕜 n (fun y => Bu (fu y) (gu y)) su xu‖ ≤
‖Bu‖ * ∑ i ∈ Finset.range (n + 1), (n.choose i : ℝ) * ‖iteratedFDerivWithin 𝕜 i fu su xu‖ *
‖iteratedFDerivWithin 𝕜 (n - i) gu su xu‖ :=
Bu.norm_iteratedFDerivWithin_le_of_bilinear_aux hfu hgu hsu hxu
simp only [Nfu, Ngu, NBu] at this
exact this.trans <| by gcongr
/-- Bounding the norm of the iterated derivative of `B (f x) (g x)` in terms of the
iterated derivatives of `f` and `g` when `B` is bilinear:
`‖D^n (x ↦ B (f x) (g x))‖ ≤ ‖B‖ ∑_{k ≤ n} n.choose k ‖D^k f‖ ‖D^{n-k} g‖` -/
theorem ContinuousLinearMap.norm_iteratedFDeriv_le_of_bilinear (B : E →L[𝕜] F →L[𝕜] G) {f : D → E}
{g : D → F} {N : WithTop ℕ∞} (hf : ContDiff 𝕜 N f) (hg : ContDiff 𝕜 N g) (x : D) {n : ℕ}
(hn : n ≤ N) :
‖iteratedFDeriv 𝕜 n (fun y => B (f y) (g y)) x‖ ≤ ‖B‖ * ∑ i ∈ Finset.range (n + 1),
(n.choose i : ℝ) * ‖iteratedFDeriv 𝕜 i f x‖ * ‖iteratedFDeriv 𝕜 (n - i) g x‖ := by
simp_rw [← iteratedFDerivWithin_univ]
exact B.norm_iteratedFDerivWithin_le_of_bilinear hf.contDiffOn hg.contDiffOn uniqueDiffOn_univ
(mem_univ x) hn
/-- Bounding the norm of the iterated derivative of `B (f x) (g x)` within a set in terms of the
iterated derivatives of `f` and `g` when `B` is bilinear of norm at most `1`:
`‖D^n (x ↦ B (f x) (g x))‖ ≤ ∑_{k ≤ n} n.choose k ‖D^k f‖ ‖D^{n-k} g‖` -/
theorem ContinuousLinearMap.norm_iteratedFDerivWithin_le_of_bilinear_of_le_one
(B : E →L[𝕜] F →L[𝕜] G) {f : D → E} {g : D → F} {N : WithTop ℕ∞} {s : Set D} {x : D}
(hf : ContDiffOn 𝕜 N f s) (hg : ContDiffOn 𝕜 N g s) (hs : UniqueDiffOn 𝕜 s) (hx : x ∈ s) {n : ℕ}
(hn : n ≤ N) (hB : ‖B‖ ≤ 1) : ‖iteratedFDerivWithin 𝕜 n (fun y => B (f y) (g y)) s x‖ ≤
∑ i ∈ Finset.range (n + 1), (n.choose i : ℝ) * ‖iteratedFDerivWithin 𝕜 i f s x‖ *
‖iteratedFDerivWithin 𝕜 (n - i) g s x‖ := by
apply (B.norm_iteratedFDerivWithin_le_of_bilinear hf hg hs hx hn).trans
exact mul_le_of_le_one_left (by positivity) hB
/-- Bounding the norm of the iterated derivative of `B (f x) (g x)` in terms of the
iterated derivatives of `f` and `g` when `B` is bilinear of norm at most `1`:
`‖D^n (x ↦ B (f x) (g x))‖ ≤ ∑_{k ≤ n} n.choose k ‖D^k f‖ ‖D^{n-k} g‖` -/
theorem ContinuousLinearMap.norm_iteratedFDeriv_le_of_bilinear_of_le_one (B : E →L[𝕜] F →L[𝕜] G)
{f : D → E} {g : D → F} {N : WithTop ℕ∞} (hf : ContDiff 𝕜 N f) (hg : ContDiff 𝕜 N g)
(x : D) {n : ℕ} (hn : n ≤ N) (hB : ‖B‖ ≤ 1) :
‖iteratedFDeriv 𝕜 n (fun y => B (f y) (g y)) x‖ ≤
∑ i ∈ Finset.range (n + 1),
(n.choose i : ℝ) * ‖iteratedFDeriv 𝕜 i f x‖ * ‖iteratedFDeriv 𝕜 (n - i) g x‖ := by
simp_rw [← iteratedFDerivWithin_univ]
exact B.norm_iteratedFDerivWithin_le_of_bilinear_of_le_one hf.contDiffOn hg.contDiffOn
uniqueDiffOn_univ (mem_univ x) hn hB
section
variable {𝕜' : Type*} [NormedField 𝕜'] [NormedAlgebra 𝕜 𝕜'] [NormedSpace 𝕜' F]
[IsScalarTower 𝕜 𝕜' F]
theorem norm_iteratedFDerivWithin_smul_le {f : E → 𝕜'} {g : E → F} {N : WithTop ℕ∞}
(hf : ContDiffOn 𝕜 N f s) (hg : ContDiffOn 𝕜 N g s) (hs : UniqueDiffOn 𝕜 s) {x : E} (hx : x ∈ s)
{n : ℕ} (hn : n ≤ N) : ‖iteratedFDerivWithin 𝕜 n (fun y => f y • g y) s x‖ ≤
∑ i ∈ Finset.range (n + 1), (n.choose i : ℝ) * ‖iteratedFDerivWithin 𝕜 i f s x‖ *
‖iteratedFDerivWithin 𝕜 (n - i) g s x‖ :=
(ContinuousLinearMap.lsmul 𝕜 𝕜' :
𝕜' →L[𝕜] F →L[𝕜] F).norm_iteratedFDerivWithin_le_of_bilinear_of_le_one
hf hg hs hx hn ContinuousLinearMap.opNorm_lsmul_le
theorem norm_iteratedFDeriv_smul_le {f : E → 𝕜'} {g : E → F} {N : WithTop ℕ∞} (hf : ContDiff 𝕜 N f)
(hg : ContDiff 𝕜 N g) (x : E) {n : ℕ} (hn : n ≤ N) :
‖iteratedFDeriv 𝕜 n (fun y => f y • g y) x‖ ≤ ∑ i ∈ Finset.range (n + 1),
(n.choose i : ℝ) * ‖iteratedFDeriv 𝕜 i f x‖ * ‖iteratedFDeriv 𝕜 (n - i) g x‖ :=
(ContinuousLinearMap.lsmul 𝕜 𝕜' : 𝕜' →L[𝕜] F →L[𝕜] F).norm_iteratedFDeriv_le_of_bilinear_of_le_one
hf hg x hn ContinuousLinearMap.opNorm_lsmul_le
end
section
variable {ι : Type*} {A : Type*} [NormedRing A] [NormedAlgebra 𝕜 A] {A' : Type*} [NormedCommRing A']
[NormedAlgebra 𝕜 A']
theorem norm_iteratedFDerivWithin_mul_le {f : E → A} {g : E → A} {N : WithTop ℕ∞}
(hf : ContDiffOn 𝕜 N f s) (hg : ContDiffOn 𝕜 N g s) (hs : UniqueDiffOn 𝕜 s)
{x : E} (hx : x ∈ s) {n : ℕ} (hn : n ≤ N) :
‖iteratedFDerivWithin 𝕜 n (fun y => f y * g y) s x‖ ≤
∑ i ∈ Finset.range (n + 1), (n.choose i : ℝ) * ‖iteratedFDerivWithin 𝕜 i f s x‖ *
‖iteratedFDerivWithin 𝕜 (n - i) g s x‖ :=
(ContinuousLinearMap.mul 𝕜 A :
A →L[𝕜] A →L[𝕜] A).norm_iteratedFDerivWithin_le_of_bilinear_of_le_one
hf hg hs hx hn (ContinuousLinearMap.opNorm_mul_le _ _)
theorem norm_iteratedFDeriv_mul_le {f : E → A} {g : E → A} {N : WithTop ℕ∞} (hf : ContDiff 𝕜 N f)
(hg : ContDiff 𝕜 N g) (x : E) {n : ℕ} (hn : n ≤ N) :
‖iteratedFDeriv 𝕜 n (fun y => f y * g y) x‖ ≤ ∑ i ∈ Finset.range (n + 1),
(n.choose i : ℝ) * ‖iteratedFDeriv 𝕜 i f x‖ * ‖iteratedFDeriv 𝕜 (n - i) g x‖ := by
simp_rw [← iteratedFDerivWithin_univ]
exact norm_iteratedFDerivWithin_mul_le
hf.contDiffOn hg.contDiffOn uniqueDiffOn_univ (mem_univ x) hn
-- TODO: Add `norm_iteratedFDeriv[Within]_list_prod_le` for non-commutative `NormedRing A`.
theorem norm_iteratedFDerivWithin_prod_le [DecidableEq ι] [NormOneClass A'] {u : Finset ι}
{f : ι → E → A'} {N : WithTop ℕ∞} (hf : ∀ i ∈ u, ContDiffOn 𝕜 N (f i) s)
(hs : UniqueDiffOn 𝕜 s) {x : E} (hx : x ∈ s) {n : ℕ} (hn : n ≤ N) :
‖iteratedFDerivWithin 𝕜 n (∏ j ∈ u, f j ·) s x‖ ≤
∑ p ∈ u.sym n, (p : Multiset ι).multinomial *
∏ j ∈ u, ‖iteratedFDerivWithin 𝕜 (Multiset.count j p) (f j) s x‖ := by
induction u using Finset.induction generalizing n with
| empty =>
cases n with
| zero => simp [Sym.eq_nil_of_card_zero]
| succ n => simp [iteratedFDerivWithin_succ_const]
| insert i u hi IH =>
conv => lhs; simp only [Finset.prod_insert hi]
simp only [Finset.mem_insert, forall_eq_or_imp] at hf
refine le_trans (norm_iteratedFDerivWithin_mul_le hf.1 (contDiffOn_prod hf.2) hs hx hn) ?_
rw [← Finset.sum_coe_sort (Finset.sym _ _)]
rw [Finset.sum_equiv (Finset.symInsertEquiv hi) (t := Finset.univ)
(g := (fun v ↦ v.multinomial *
∏ j ∈ insert i u, ‖iteratedFDerivWithin 𝕜 (v.count j) (f j) s x‖) ∘
Sym.toMultiset ∘ Subtype.val ∘ (Finset.symInsertEquiv hi).symm)
(by simp) (by simp only [← comp_apply (g := Finset.symInsertEquiv hi), comp_assoc]; simp)]
rw [← Finset.univ_sigma_univ, Finset.sum_sigma, Finset.sum_range]
simp only [comp_apply, Finset.symInsertEquiv_symm_apply_coe]
refine Finset.sum_le_sum ?_
intro m _
specialize IH hf.2 (n := n - m) (le_trans (by exact_mod_cast n.sub_le m) hn)
grw [IH]
rw [Finset.mul_sum, ← Finset.sum_coe_sort]
refine Finset.sum_le_sum ?_
simp only [Finset.mem_univ, forall_true_left, Subtype.forall, Finset.mem_sym_iff]
intro p hp
refine le_of_eq ?_
rw [Finset.prod_insert hi]
have hip : i ∉ p := mt (hp i) hi
rw [Sym.count_coe_fill_self_of_notMem hip, Sym.multinomial_coe_fill_of_notMem hip]
suffices ∏ j ∈ u, ‖iteratedFDerivWithin 𝕜 (Multiset.count j p) (f j) s x‖ =
∏ j ∈ u, ‖iteratedFDerivWithin 𝕜 (Multiset.count j (Sym.fill i m p)) (f j) s x‖ by
rw [this, Nat.cast_mul]
ring
refine Finset.prod_congr rfl ?_
intro j hj
have hji : j ≠ i := mt (· ▸ hj) hi
rw [Sym.count_coe_fill_of_ne hji]
theorem norm_iteratedFDeriv_prod_le [DecidableEq ι] [NormOneClass A'] {u : Finset ι}
{f : ι → E → A'} {N : WithTop ℕ∞} (hf : ∀ i ∈ u, ContDiff 𝕜 N (f i)) {x : E} {n : ℕ}
(hn : n ≤ N) :
‖iteratedFDeriv 𝕜 n (∏ j ∈ u, f j ·) x‖ ≤
∑ p ∈ u.sym n, (p : Multiset ι).multinomial *
∏ j ∈ u, ‖iteratedFDeriv 𝕜 ((p : Multiset ι).count j) (f j) x‖ := by
simpa [iteratedFDerivWithin_univ] using
norm_iteratedFDerivWithin_prod_le (fun i hi ↦ (hf i hi).contDiffOn) uniqueDiffOn_univ
(mem_univ x) hn
end
/-- If the derivatives within a set of `g` at `f x` are bounded by `C`, and the `i`-th derivative
within a set of `f` at `x` is bounded by `D^i` for all `1 ≤ i ≤ n`, then the `n`-th derivative
of `g ∘ f` is bounded by `n! * C * D^n`.
This lemma proves this estimate assuming additionally that two of the spaces live in the same
universe, to make an induction possible. Use instead `norm_iteratedFDerivWithin_comp_le` that
removes this assumption. -/
theorem norm_iteratedFDerivWithin_comp_le_aux {Fu Gu : Type u} [NormedAddCommGroup Fu]
[NormedSpace 𝕜 Fu] [NormedAddCommGroup Gu] [NormedSpace 𝕜 Gu] {g : Fu → Gu} {f : E → Fu} {n : ℕ}
{s : Set E} {t : Set Fu} {x : E} (hg : ContDiffOn 𝕜 n g t) (hf : ContDiffOn 𝕜 n f s)
(ht : UniqueDiffOn 𝕜 t) (hs : UniqueDiffOn 𝕜 s) (hst : MapsTo f s t) (hx : x ∈ s) {C : ℝ}
{D : ℝ} (hC : ∀ i, i ≤ n → ‖iteratedFDerivWithin 𝕜 i g t (f x)‖ ≤ C)
(hD : ∀ i, 1 ≤ i → i ≤ n → ‖iteratedFDerivWithin 𝕜 i f s x‖ ≤ D ^ i) :
‖iteratedFDerivWithin 𝕜 n (g ∘ f) s x‖ ≤ n ! * C * D ^ n := by
/- We argue by induction on `n`, using that `D^(n+1) (g ∘ f) = D^n (g ' ∘ f ⬝ f')`. The successive
derivatives of `g' ∘ f` are controlled thanks to the inductive assumption, and those of `f'` are
controlled by assumption.
As composition of linear maps is a bilinear map, one may use
`ContinuousLinearMap.norm_iteratedFDeriv_le_of_bilinear_of_le_one` to get from these a bound
on `D^n (g ' ∘ f ⬝ f')`. -/
induction n using Nat.case_strong_induction_on generalizing Gu with
| hz =>
simpa [norm_iteratedFDerivWithin_zero, Nat.factorial_zero, algebraMap.coe_one, one_mul,
pow_zero, mul_one, comp_apply] using hC 0 le_rfl
| hi n IH =>
have M : (n : WithTop ℕ∞) < n.succ := Nat.cast_lt.2 n.lt_succ_self
have Cnonneg : 0 ≤ C := (norm_nonneg _).trans (hC 0 bot_le)
have Dnonneg : 0 ≤ D := by
have : 1 ≤ n + 1 := by simp only [le_add_iff_nonneg_left, zero_le']
simpa only [pow_one] using (norm_nonneg _).trans (hD 1 le_rfl this)
-- use the inductive assumption to bound the derivatives of `g' ∘ f`.
have I : ∀ i ∈ Finset.range (n + 1),
‖iteratedFDerivWithin 𝕜 i (fderivWithin 𝕜 g t ∘ f) s x‖ ≤ i ! * C * D ^ i := by
intro i hi
simp only [Finset.mem_range_succ_iff] at hi
apply IH i hi
· apply hg.fderivWithin ht
grw [Nat.cast_succ, hi]
· apply hf.of_le (Nat.cast_le.2 (hi.trans n.le_succ))
· intro j hj
have : ‖iteratedFDerivWithin 𝕜 j (fderivWithin 𝕜 g t) t (f x)‖ =
‖iteratedFDerivWithin 𝕜 (j + 1) g t (f x)‖ := by
rw [iteratedFDerivWithin_succ_eq_comp_right ht (hst hx), comp_apply,
LinearIsometryEquiv.norm_map]
rw [this]
exact hC (j + 1) (add_le_add (hj.trans hi) le_rfl)
· intro j hj h'j
exact hD j hj (h'j.trans (hi.trans n.le_succ))
-- reformulate `hD` as a bound for the derivatives of `f'`.
have J : ∀ i, ‖iteratedFDerivWithin 𝕜 (n - i) (fderivWithin 𝕜 f s) s x‖ ≤ D ^ (n - i + 1) := by
intro i
have : ‖iteratedFDerivWithin 𝕜 (n - i) (fderivWithin 𝕜 f s) s x‖ =
‖iteratedFDerivWithin 𝕜 (n - i + 1) f s x‖ := by
rw [iteratedFDerivWithin_succ_eq_comp_right hs hx, comp_apply, LinearIsometryEquiv.norm_map]
rw [this]
apply hD
· simp only [le_add_iff_nonneg_left, zero_le']
· apply Nat.succ_le_succ tsub_le_self
-- Now put these together: first, notice that we have to bound `D^n (g' ∘ f ⬝ f')`.
calc
‖iteratedFDerivWithin 𝕜 (n + 1) (g ∘ f) s x‖ =
‖iteratedFDerivWithin 𝕜 n (fun y : E => fderivWithin 𝕜 (g ∘ f) s y) s x‖ := by
rw [iteratedFDerivWithin_succ_eq_comp_right hs hx, comp_apply,
LinearIsometryEquiv.norm_map]
_ = ‖iteratedFDerivWithin 𝕜 n (fun y : E => ContinuousLinearMap.compL 𝕜 E Fu Gu
(fderivWithin 𝕜 g t (f y)) (fderivWithin 𝕜 f s y)) s x‖ := by
have L : (1 : WithTop ℕ∞) ≤ n.succ := by
simpa only [ENat.coe_one, Nat.one_le_cast] using n.succ_pos
congr 1
refine iteratedFDerivWithin_congr (fun y hy => ?_) hx _
apply fderivWithin_comp _ _ _ hst (hs y hy)
· exact hg.differentiableOn L _ (hst hy)
· exact hf.differentiableOn L _ hy
-- bound it using the fact that the composition of linear maps is a bilinear operation,
-- for which we have bounds for the`n`-th derivative.
_ ≤ ∑ i ∈ Finset.range (n + 1),
(n.choose i : ℝ) * ‖iteratedFDerivWithin 𝕜 i (fderivWithin 𝕜 g t ∘ f) s x‖ *
‖iteratedFDerivWithin 𝕜 (n - i) (fderivWithin 𝕜 f s) s x‖ := by
have A : ContDiffOn 𝕜 n (fderivWithin 𝕜 g t ∘ f) s := by
apply ContDiffOn.comp _ (hf.of_le M.le) hst
apply hg.fderivWithin ht
simp only [Nat.cast_succ, le_refl]
have B : ContDiffOn 𝕜 n (fderivWithin 𝕜 f s) s := by
apply hf.fderivWithin hs
simp only [Nat.cast_succ, le_refl]
exact (ContinuousLinearMap.compL 𝕜 E Fu Gu).norm_iteratedFDerivWithin_le_of_bilinear_of_le_one
A B hs hx le_rfl (ContinuousLinearMap.norm_compL_le 𝕜 E Fu Gu)
-- bound each of the terms using the estimates on previous derivatives (that use the inductive
-- assumption for `g' ∘ f`).
_ ≤ ∑ i ∈ Finset.range (n + 1), (n.choose i : ℝ) * (i ! * C * D ^ i) * D ^ (n - i + 1) := by
gcongr with i hi
· exact I i hi
· exact J i
-- We are left with trivial algebraic manipulations to see that this is smaller than
-- the claimed bound.
_ = ∑ i ∈ Finset.range (n + 1),
(n ! : ℝ) * ((i ! : ℝ)⁻¹ * i !) * C * (D ^ i * D ^ (n - i + 1)) * ((n - i)! : ℝ)⁻¹ := by
congr! 1 with i hi
simp only [Nat.cast_choose ℝ (Finset.mem_range_succ_iff.1 hi), div_eq_inv_mul, mul_inv]
ring
_ = ∑ i ∈ Finset.range (n + 1), (n ! : ℝ) * 1 * C * D ^ (n + 1) * ((n - i)! : ℝ)⁻¹ := by
congr! with i hi
· exact inv_mul_cancel₀ (by positivity)
· rw [← pow_add]
congr 1
rw [Nat.add_succ, Nat.succ_inj]
exact Nat.add_sub_of_le (Finset.mem_range_succ_iff.1 hi)
_ ≤ ∑ i ∈ Finset.range (n + 1), (n ! : ℝ) * 1 * C * D ^ (n + 1) * 1 := by
gcongr with i
apply inv_le_one_of_one_le₀
simpa only [Nat.one_le_cast] using (n - i).factorial_pos
_ = (n + 1)! * C * D ^ (n + 1) := by
simp only [mul_assoc, mul_one, Finset.sum_const, Finset.card_range, nsmul_eq_mul,
Nat.factorial_succ, Nat.cast_mul]
/-- If the derivatives within a set of `g` at `f x` are bounded by `C`, and the `i`-th derivative
within a set of `f` at `x` is bounded by `D^i` for all `1 ≤ i ≤ n`, then the `n`-th derivative
of `g ∘ f` is bounded by `n! * C * D^n`. -/
theorem norm_iteratedFDerivWithin_comp_le {g : F → G} {f : E → F} {n : ℕ} {s : Set E} {t : Set F}
{x : E} {N : WithTop ℕ∞} (hg : ContDiffOn 𝕜 N g t) (hf : ContDiffOn 𝕜 N f s) (hn : n ≤ N)
(ht : UniqueDiffOn 𝕜 t) (hs : UniqueDiffOn 𝕜 s) (hst : MapsTo f s t) (hx : x ∈ s) {C : ℝ}
{D : ℝ} (hC : ∀ i, i ≤ n → ‖iteratedFDerivWithin 𝕜 i g t (f x)‖ ≤ C)
(hD : ∀ i, 1 ≤ i → i ≤ n → ‖iteratedFDerivWithin 𝕜 i f s x‖ ≤ D ^ i) :
‖iteratedFDerivWithin 𝕜 n (g ∘ f) s x‖ ≤ n ! * C * D ^ n := by
/- We reduce the bound to the case where all spaces live in the same universe (in which we
already have proved the result), by using linear isometries between the spaces and their `ULift`
to a common universe. These linear isometries preserve the norm of the iterated derivative. -/
let Fu : Type max uF uG := ULift.{uG, uF} F
let Gu : Type max uF uG := ULift.{uF, uG} G
have isoF : Fu ≃ₗᵢ[𝕜] F := LinearIsometryEquiv.ulift 𝕜 F
have isoG : Gu ≃ₗᵢ[𝕜] G := LinearIsometryEquiv.ulift 𝕜 G
-- lift `f` and `g` to versions `fu` and `gu` on the lifted spaces.
let fu : E → Fu := isoF.symm ∘ f
let gu : Fu → Gu := isoG.symm ∘ g ∘ isoF
let tu := isoF ⁻¹' t
have htu : UniqueDiffOn 𝕜 tu := isoF.toContinuousLinearEquiv.uniqueDiffOn_preimage_iff.2 ht
have hstu : MapsTo fu s tu := fun y hy ↦ by
simpa only [fu, tu, mem_preimage, comp_apply, LinearIsometryEquiv.apply_symm_apply] using hst hy
have Ffu : isoF (fu x) = f x := by
simp only [fu, comp_apply, LinearIsometryEquiv.apply_symm_apply]
-- All norms are preserved by the lifting process.
have hfu : ContDiffOn 𝕜 n fu s := isoF.symm.contDiff.comp_contDiffOn (hf.of_le hn)
have hgu : ContDiffOn 𝕜 n gu tu :=
isoG.symm.contDiff.comp_contDiffOn
((hg.of_le hn).comp_continuousLinearMap (isoF : Fu →L[𝕜] F))
have Nfu : ∀ i, ‖iteratedFDerivWithin 𝕜 i fu s x‖ = ‖iteratedFDerivWithin 𝕜 i f s x‖ := fun i ↦ by
rw [LinearIsometryEquiv.norm_iteratedFDerivWithin_comp_left _ _ hs hx]
simp_rw [← Nfu] at hD
have Ngu : ∀ i,
‖iteratedFDerivWithin 𝕜 i gu tu (fu x)‖ = ‖iteratedFDerivWithin 𝕜 i g t (f x)‖ := fun i ↦ by
rw [LinearIsometryEquiv.norm_iteratedFDerivWithin_comp_left _ _ htu (hstu hx)]
rw [LinearIsometryEquiv.norm_iteratedFDerivWithin_comp_right _ _ ht, Ffu]
rw [Ffu]
exact hst hx
simp_rw [← Ngu] at hC
have Nfgu :
‖iteratedFDerivWithin 𝕜 n (g ∘ f) s x‖ = ‖iteratedFDerivWithin 𝕜 n (gu ∘ fu) s x‖ := by
have : gu ∘ fu = isoG.symm ∘ g ∘ f := by
ext x
simp only [fu, gu, comp_apply,
LinearIsometryEquiv.apply_symm_apply]
rw [this, LinearIsometryEquiv.norm_iteratedFDerivWithin_comp_left _ _ hs hx]
-- deduce the required bound from the one for `gu ∘ fu`.
rw [Nfgu]
exact norm_iteratedFDerivWithin_comp_le_aux hgu hfu htu hs hstu hx hC hD
/-- If the derivatives of `g` at `f x` are bounded by `C`, and the `i`-th derivative
of `f` at `x` is bounded by `D^i` for all `1 ≤ i ≤ n`, then the `n`-th derivative
of `g ∘ f` is bounded by `n! * C * D^n`.
Version with the iterated derivative of `g` only bounded on the range of `f`. -/
theorem norm_iteratedFDeriv_comp_le' {g : F → G} {f : E → F} {n : ℕ} {N : WithTop ℕ∞}
{t : Set F} (ht : Set.range f ⊆ t) (ht' : UniqueDiffOn 𝕜 t)
(hg : ContDiffOn 𝕜 N g t) (hf : ContDiff 𝕜 N f) (hn : n ≤ N) (x : E) {C : ℝ} {D : ℝ}
(hC : ∀ i, i ≤ n → ‖iteratedFDerivWithin 𝕜 i g t (f x)‖ ≤ C)
(hD : ∀ i, 1 ≤ i → i ≤ n → ‖iteratedFDeriv 𝕜 i f x‖ ≤ D ^ i) :
‖iteratedFDeriv 𝕜 n (g ∘ f) x‖ ≤ n ! * C * D ^ n := by
simp_rw [← iteratedFDerivWithin_univ] at hD ⊢
exact norm_iteratedFDerivWithin_comp_le hg hf.contDiffOn hn ht' uniqueDiffOn_univ
(by simp [mapsTo_iff_subset_preimage, ht]) (mem_univ x) hC hD
/-- If the derivatives of `g` at `f x` are bounded by `C`, and the `i`-th derivative
of `f` at `x` is bounded by `D^i` for all `1 ≤ i ≤ n`, then the `n`-th derivative
of `g ∘ f` is bounded by `n! * C * D^n`. -/
theorem norm_iteratedFDeriv_comp_le {g : F → G} {f : E → F} {n : ℕ} {N : WithTop ℕ∞}
(hg : ContDiff 𝕜 N g) (hf : ContDiff 𝕜 N f) (hn : n ≤ N) (x : E) {C : ℝ} {D : ℝ}
(hC : ∀ i, i ≤ n → ‖iteratedFDeriv 𝕜 i g (f x)‖ ≤ C)
(hD : ∀ i, 1 ≤ i → i ≤ n → ‖iteratedFDeriv 𝕜 i f x‖ ≤ D ^ i) :
‖iteratedFDeriv 𝕜 n (g ∘ f) x‖ ≤ n ! * C * D ^ n := by
simp_rw [← iteratedFDerivWithin_univ] at hC
exact norm_iteratedFDeriv_comp_le' (subset_univ _) uniqueDiffOn_univ hg.contDiffOn hf hn x hC hD
section Apply
theorem norm_iteratedFDerivWithin_clm_apply {f : E → F →L[𝕜] G} {g : E → F} {s : Set E} {x : E}
{N : WithTop ℕ∞} {n : ℕ} (hf : ContDiffOn 𝕜 N f s) (hg : ContDiffOn 𝕜 N g s)
(hs : UniqueDiffOn 𝕜 s) (hx : x ∈ s) (hn : n ≤ N) :
‖iteratedFDerivWithin 𝕜 n (fun y => (f y) (g y)) s x‖ ≤
∑ i ∈ Finset.range (n + 1), ↑(n.choose i) * ‖iteratedFDerivWithin 𝕜 i f s x‖ *
‖iteratedFDerivWithin 𝕜 (n - i) g s x‖ := by
let B : (F →L[𝕜] G) →L[𝕜] F →L[𝕜] G := ContinuousLinearMap.flip (ContinuousLinearMap.apply 𝕜 G)
have hB : ‖B‖ ≤ 1 := by
simp only [B, ContinuousLinearMap.opNorm_flip, ContinuousLinearMap.apply]
refine ContinuousLinearMap.opNorm_le_bound _ zero_le_one fun f => ?_
simp only [ContinuousLinearMap.coe_id', id, one_mul]
rfl
exact B.norm_iteratedFDerivWithin_le_of_bilinear_of_le_one hf hg hs hx hn hB
theorem norm_iteratedFDeriv_clm_apply {f : E → F →L[𝕜] G} {g : E → F} {N : WithTop ℕ∞} {n : ℕ}
(hf : ContDiff 𝕜 N f) (hg : ContDiff 𝕜 N g) (x : E) (hn : n ≤ N) :
‖iteratedFDeriv 𝕜 n (fun y : E => (f y) (g y)) x‖ ≤ ∑ i ∈ Finset.range (n + 1),
↑(n.choose i) * ‖iteratedFDeriv 𝕜 i f x‖ * ‖iteratedFDeriv 𝕜 (n - i) g x‖ := by
simp only [← iteratedFDerivWithin_univ]
exact norm_iteratedFDerivWithin_clm_apply hf.contDiffOn hg.contDiffOn uniqueDiffOn_univ
(Set.mem_univ x) hn
theorem norm_iteratedFDerivWithin_clm_apply_const {f : E → F →L[𝕜] G} {c : F} {s : Set E} {x : E}
{N : WithTop ℕ∞} {n : ℕ} (hf : ContDiffWithinAt 𝕜 N f s x) (hs : UniqueDiffOn 𝕜 s)
(hx : x ∈ s) (hn : n ≤ N) :
‖iteratedFDerivWithin 𝕜 n (fun y : E => (f y) c) s x‖ ≤
‖c‖ * ‖iteratedFDerivWithin 𝕜 n f s x‖ := by
let g : (F →L[𝕜] G) →L[𝕜] G := ContinuousLinearMap.apply 𝕜 G c
have h := g.norm_compContinuousMultilinearMap_le (iteratedFDerivWithin 𝕜 n f s x)
rw [← g.iteratedFDerivWithin_comp_left hf hs hx hn] at h
refine h.trans ?_
gcongr
refine g.opNorm_le_bound (norm_nonneg _) fun f => ?_
rw [ContinuousLinearMap.apply_apply, mul_comm]
exact f.le_opNorm c
theorem norm_iteratedFDeriv_clm_apply_const {f : E → F →L[𝕜] G} {c : F} {x : E}
{N : WithTop ℕ∞} {n : ℕ} (hf : ContDiffAt 𝕜 N f x) (hn : n ≤ N) :
‖iteratedFDeriv 𝕜 n (fun y : E => (f y) c) x‖ ≤ ‖c‖ * ‖iteratedFDeriv 𝕜 n f x‖ := by
simp only [← iteratedFDerivWithin_univ]
exact norm_iteratedFDerivWithin_clm_apply_const hf.contDiffWithinAt uniqueDiffOn_univ
(Set.mem_univ x) hn
end Apply |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/Conformal/InnerProduct.lean | import Mathlib.Analysis.Calculus.Conformal.NormedSpace
import Mathlib.Analysis.InnerProductSpace.ConformalLinearMap
/-!
# Conformal maps between inner product spaces
A function between inner product spaces which has a derivative at `x`
is conformal at `x` iff the derivative preserves inner products up to a scalar multiple.
-/
noncomputable section
variable {E F : Type*}
variable [NormedAddCommGroup E] [NormedAddCommGroup F]
variable [InnerProductSpace ℝ E] [InnerProductSpace ℝ F]
open RealInnerProductSpace
/-- A real differentiable map `f` is conformal at point `x` if and only if its
differential `fderiv ℝ f x` at that point scales every inner product by a positive scalar. -/
theorem conformalAt_iff' {f : E → F} {x : E} : ConformalAt f x ↔
∃ c : ℝ, 0 < c ∧ ∀ u v : E, ⟪fderiv ℝ f x u, fderiv ℝ f x v⟫ = c * ⟪u, v⟫ := by
rw [conformalAt_iff_isConformalMap_fderiv, isConformalMap_iff]
/-- A real differentiable map `f` is conformal at point `x` if and only if its
differential `f'` at that point scales every inner product by a positive scalar. -/
theorem conformalAt_iff {f : E → F} {x : E} {f' : E →L[ℝ] F} (h : HasFDerivAt f f' x) :
ConformalAt f x ↔ ∃ c : ℝ, 0 < c ∧ ∀ u v : E, ⟪f' u, f' v⟫ = c * ⟪u, v⟫ := by
simp only [conformalAt_iff', h.fderiv]
/-- The conformal factor of a conformal map at some point `x`. Some authors refer to this function
as the characteristic function of the conformal map. -/
def conformalFactorAt {f : E → F} {x : E} (h : ConformalAt f x) : ℝ :=
Classical.choose (conformalAt_iff'.mp h)
theorem conformalFactorAt_pos {f : E → F} {x : E} (h : ConformalAt f x) : 0 < conformalFactorAt h :=
(Classical.choose_spec <| conformalAt_iff'.mp h).1
theorem conformalFactorAt_inner_eq_mul_inner' {f : E → F} {x : E} (h : ConformalAt f x) (u v : E) :
⟪(fderiv ℝ f x) u, (fderiv ℝ f x) v⟫ = (conformalFactorAt h : ℝ) * ⟪u, v⟫ :=
(Classical.choose_spec <| conformalAt_iff'.mp h).2 u v
theorem conformalFactorAt_inner_eq_mul_inner {f : E → F} {x : E} {f' : E →L[ℝ] F}
(h : HasFDerivAt f f' x) (H : ConformalAt f x) (u v : E) :
⟪f' u, f' v⟫ = (conformalFactorAt H : ℝ) * ⟪u, v⟫ :=
H.differentiableAt.hasFDerivAt.unique h ▸ conformalFactorAt_inner_eq_mul_inner' H u v |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/Conformal/NormedSpace.lean | import Mathlib.Analysis.Calculus.FDeriv.Add
import Mathlib.Analysis.Calculus.FDeriv.Const
import Mathlib.Analysis.Normed.Operator.Conformal
/-!
# Conformal Maps
A continuous linear map between real normed spaces `X` and `Y` is `ConformalAt` some point `x`
if it is real differentiable at that point and its differential is a conformal linear map.
## Main definitions
* `ConformalAt`: the main definition of conformal maps
* `Conformal`: maps that are conformal at every point
## Main results
* The conformality of the composition of two conformal maps, the identity map
and multiplications by nonzero constants
* `conformalAt_iff_isConformalMap_fderiv`: an equivalent definition of the conformality of a map
In `Analysis.Calculus.Conformal.InnerProduct`:
* `conformalAt_iff`: an equivalent definition of the conformality of a map
In `Geometry.Euclidean.Angle.Unoriented.Conformal`:
* `ConformalAt.preserves_angle`: if a map is conformal at `x`, then its differential preserves
all angles at `x`
## Tags
conformal
## Warning
The definition of conformality in this file does NOT require the maps to be orientation-preserving.
Maps such as the complex conjugate are considered to be conformal.
-/
noncomputable section
variable {X Y Z : Type*} [NormedAddCommGroup X] [NormedAddCommGroup Y] [NormedAddCommGroup Z]
[NormedSpace ℝ X] [NormedSpace ℝ Y] [NormedSpace ℝ Z]
section LocConformality
open LinearIsometry ContinuousLinearMap
/-- A map `f` is said to be conformal if it has a conformal differential `f'`. -/
def ConformalAt (f : X → Y) (x : X) :=
∃ f' : X →L[ℝ] Y, HasFDerivAt f f' x ∧ IsConformalMap f'
theorem conformalAt_id (x : X) : ConformalAt _root_.id x :=
⟨.id ℝ X, hasFDerivAt_id _, isConformalMap_id⟩
theorem conformalAt_const_smul {c : ℝ} (h : c ≠ 0) (x : X) : ConformalAt (fun x' : X => c • x') x :=
⟨c • ContinuousLinearMap.id ℝ X, (hasFDerivAt_id x).const_smul c, isConformalMap_const_smul h⟩
@[nontriviality]
theorem Subsingleton.conformalAt [Subsingleton X] (f : X → Y) (x : X) : ConformalAt f x :=
⟨0, hasFDerivAt_of_subsingleton _ _, isConformalMap_of_subsingleton _⟩
/-- A function is a conformal map if and only if its differential is a conformal linear map -/
theorem conformalAt_iff_isConformalMap_fderiv {f : X → Y} {x : X} :
ConformalAt f x ↔ IsConformalMap (fderiv ℝ f x) := by
constructor
· rintro ⟨f', hf, hf'⟩
rwa [hf.fderiv]
· intro H
by_cases h : DifferentiableAt ℝ f x
· exact ⟨fderiv ℝ f x, h.hasFDerivAt, H⟩
· nontriviality X
exact absurd (fderiv_zero_of_not_differentiableAt h) H.ne_zero
namespace ConformalAt
theorem differentiableAt {f : X → Y} {x : X} (h : ConformalAt f x) : DifferentiableAt ℝ f x :=
let ⟨_, h₁, _⟩ := h
h₁.differentiableAt
theorem congr {f g : X → Y} {x : X} {u : Set X} (hx : x ∈ u) (hu : IsOpen u) (hf : ConformalAt f x)
(h : ∀ x : X, x ∈ u → g x = f x) : ConformalAt g x :=
let ⟨f', hfderiv, hf'⟩ := hf
⟨f', hfderiv.congr_of_eventuallyEq ((hu.eventually_mem hx).mono h), hf'⟩
theorem comp {f : X → Y} {g : Y → Z} (x : X) (hg : ConformalAt g (f x)) (hf : ConformalAt f x) :
ConformalAt (g ∘ f) x := by
rcases hf with ⟨f', hf₁, cf⟩
rcases hg with ⟨g', hg₁, cg⟩
exact ⟨g'.comp f', hg₁.comp x hf₁, cg.comp cf⟩
theorem const_smul {f : X → Y} {x : X} {c : ℝ} (hc : c ≠ 0) (hf : ConformalAt f x) :
ConformalAt (c • f) x :=
(conformalAt_const_smul hc <| f x).comp x hf
end ConformalAt
end LocConformality
section GlobalConformality
/-- A map `f` is conformal if it's conformal at every point. -/
def Conformal (f : X → Y) :=
∀ x : X, ConformalAt f x
theorem conformal_id : Conformal (id : X → X) := fun x => conformalAt_id x
theorem conformal_const_smul {c : ℝ} (h : c ≠ 0) : Conformal fun x : X => c • x := fun x =>
conformalAt_const_smul h x
namespace Conformal
theorem conformalAt {f : X → Y} (h : Conformal f) (x : X) : ConformalAt f x :=
h x
theorem differentiable {f : X → Y} (h : Conformal f) : Differentiable ℝ f := fun x =>
(h x).differentiableAt
theorem comp {f : X → Y} {g : Y → Z} (hf : Conformal f) (hg : Conformal g) : Conformal (g ∘ f) :=
fun x => (hg <| f x).comp x (hf x)
theorem const_smul {f : X → Y} (hf : Conformal f) {c : ℝ} (hc : c ≠ 0) : Conformal (c • f) :=
fun x => (hf x).const_smul hc
end Conformal
end GlobalConformality |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/LineDeriv/QuadraticMap.lean | import Mathlib.Analysis.Calculus.LineDeriv.Basic
import Mathlib.Analysis.Calculus.Deriv.Mul
import Mathlib.LinearAlgebra.QuadraticForm.Basic
/-!
# Quadratic forms are line (Gateaux) differentiable
In this file we prove that a quadratic form is line differentiable,
with the line derivative given by the polar bilinear form.
Note that this statement does not need topology on the domain.
In particular, it applies to discontinuous quadratic forms on infinite-dimensional spaces.
-/
variable {𝕜 E F : Type*} [NontriviallyNormedField 𝕜] [AddCommGroup E] [Module 𝕜 E]
[NormedAddCommGroup F] [NormedSpace 𝕜 F]
namespace QuadraticMap
theorem hasLineDerivAt (f : QuadraticMap 𝕜 E F) (a b : E) :
HasLineDerivAt 𝕜 f (polar f a b) a b := by
simpa [HasLineDerivAt, QuadraticMap.map_add, f.map_smul] using
((hasDerivAt_const (0 : 𝕜) (f a)).add <|
((hasDerivAt_id 0).mul (hasDerivAt_id 0)).smul (hasDerivAt_const 0 (f b))).add
((hasDerivAt_id 0).smul (hasDerivAt_const 0 (polar f a b)))
theorem lineDifferentiableAt (f : QuadraticMap 𝕜 E F) (a b : E) : LineDifferentiableAt 𝕜 f a b :=
(f.hasLineDerivAt a b).lineDifferentiableAt
@[simp]
protected theorem lineDeriv (f : QuadraticMap 𝕜 E F) : lineDeriv 𝕜 f = polar f := by
ext a b
exact (f.hasLineDerivAt a b).lineDeriv
end QuadraticMap |
.lake/packages/mathlib/Mathlib/Analysis/Calculus/LineDeriv/IntegrationByParts.lean | import Mathlib.Analysis.Calculus.LineDeriv.Basic
import Mathlib.MeasureTheory.Integral.IntegralEqImproper
/-!
# Integration by parts for line derivatives
Let `f, g : E → ℝ` be two differentiable functions on a real vector space endowed with a Haar
measure. Then `∫ f * g' = - ∫ f' * g`, where `f'` and `g'` denote the derivatives of `f` and `g`
in a given direction `v`, provided that `f * g`, `f' * g` and `f * g'` are all integrable.
In this file, we prove this theorem as well as more general versions where the multiplication is
replaced by a general continuous bilinear form, giving versions both for the line derivative and
the Fréchet derivative. These results are derived from the one-dimensional version and a Fubini
argument.
## Main statements
* `integral_bilinear_hasLineDerivAt_right_eq_neg_left_of_integrable`: integration by parts
in terms of line derivatives, with `HasLineDerivAt` assumptions and general bilinear form.
* `integral_bilinear_hasFDerivAt_right_eq_neg_left_of_integrable`: integration by parts
in terms of Fréchet derivatives, with `HasFDerivAt` assumptions and general bilinear form.
* `integral_bilinear_fderiv_right_eq_neg_left_of_integrable`: integration by parts
in terms of Fréchet derivatives, written with `fderiv` assumptions and general bilinear form.
* `integral_smul_fderiv_eq_neg_fderiv_smul_of_integrable`: integration by parts for scalar
action, in terms of Fréchet derivatives, written with `fderiv` assumptions.
* `integral_mul_fderiv_eq_neg_fderiv_mul_of_integrable`: integration by parts for scalar
multiplication, in terms of Fréchet derivatives, written with `fderiv` assumptions.
## Implementation notes
A standard set of assumptions for integration by parts in a finite-dimensional real vector
space (without boundary term) is that the functions tend to zero at infinity and have integrable
derivatives. In this file, we instead assume that the functions are integrable and have integrable
derivatives. These sets of assumptions are not directly comparable (an integrable function with
integrable derivative does *not* have to tend to zero at infinity). The one we use is geared
towards applications to Fourier transforms.
TODO: prove similar theorems assuming that the functions tend to zero at infinity and have
integrable derivatives.
-/
open MeasureTheory Measure Module Topology
variable {E F G W : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [NormedAddCommGroup F]
[NormedSpace ℝ F] [NormedAddCommGroup G] [NormedSpace ℝ G] [NormedAddCommGroup W]
[NormedSpace ℝ W] [MeasurableSpace E] {μ : Measure E}
lemma integral_bilinear_hasLineDerivAt_right_eq_neg_left_of_integrable_aux1 [SigmaFinite μ]
{f f' : E × ℝ → F} {g g' : E × ℝ → G} {B : F →L[ℝ] G →L[ℝ] W}
(hf'g : Integrable (fun x ↦ B (f' x) (g x)) (μ.prod volume))
(hfg' : Integrable (fun x ↦ B (f x) (g' x)) (μ.prod volume))
(hfg : Integrable (fun x ↦ B (f x) (g x)) (μ.prod volume))
(hf : ∀ x, HasLineDerivAt ℝ f (f' x) x (0, 1)) (hg : ∀ x, HasLineDerivAt ℝ g (g' x) x (0, 1)) :
∫ x, B (f x) (g' x) ∂(μ.prod volume) = - ∫ x, B (f' x) (g x) ∂(μ.prod volume) := calc
∫ x, B (f x) (g' x) ∂(μ.prod volume)
= ∫ x, (∫ t, B (f (x, t)) (g' (x, t))) ∂μ := integral_prod _ hfg'
_ = ∫ x, (- ∫ t, B (f' (x, t)) (g (x, t))) ∂μ := by
apply integral_congr_ae
filter_upwards [hf'g.prod_right_ae, hfg'.prod_right_ae, hfg.prod_right_ae]
with x hf'gx hfg'x hfgx
apply integral_bilinear_hasDerivAt_right_eq_neg_left_of_integrable ?_ ?_ hfg'x hf'gx hfgx
· intro t
convert (hf (x, t)).scomp_of_eq t ((hasDerivAt_id t).add (hasDerivAt_const t (-t))) (by simp)
<;> simp
· intro t
convert (hg (x, t)).scomp_of_eq t ((hasDerivAt_id t).add (hasDerivAt_const t (-t))) (by simp)
<;> simp
_ = - ∫ x, B (f' x) (g x) ∂(μ.prod volume) := by rw [integral_neg, integral_prod _ hf'g]
variable [BorelSpace E]
lemma integral_bilinear_hasLineDerivAt_right_eq_neg_left_of_integrable_aux2
[FiniteDimensional ℝ E] {μ : Measure (E × ℝ)} [IsAddHaarMeasure μ]
{f f' : E × ℝ → F} {g g' : E × ℝ → G} {B : F →L[ℝ] G →L[ℝ] W}
(hf'g : Integrable (fun x ↦ B (f' x) (g x)) μ)
(hfg' : Integrable (fun x ↦ B (f x) (g' x)) μ)
(hfg : Integrable (fun x ↦ B (f x) (g x)) μ)
(hf : ∀ x, HasLineDerivAt ℝ f (f' x) x (0, 1)) (hg : ∀ x, HasLineDerivAt ℝ g (g' x) x (0, 1)) :
∫ x, B (f x) (g' x) ∂μ = - ∫ x, B (f' x) (g x) ∂μ := by
let ν : Measure E := addHaar
have A : ν.prod volume = (addHaarScalarFactor (ν.prod volume) μ) • μ :=
isAddLeftInvariant_eq_smul _ _
have Hf'g : Integrable (fun x ↦ B (f' x) (g x)) (ν.prod volume) := by
rw [A]; exact hf'g.smul_measure_nnreal
have Hfg' : Integrable (fun x ↦ B (f x) (g' x)) (ν.prod volume) := by
rw [A]; exact hfg'.smul_measure_nnreal
have Hfg : Integrable (fun x ↦ B (f x) (g x)) (ν.prod volume) := by
rw [A]; exact hfg.smul_measure_nnreal
rw [isAddLeftInvariant_eq_smul μ (ν.prod volume)]
simp [integral_bilinear_hasLineDerivAt_right_eq_neg_left_of_integrable_aux1 Hf'g Hfg' Hfg hf hg]
variable [FiniteDimensional ℝ E] [IsAddHaarMeasure μ]
/-- **Integration by parts for line derivatives**
Version with a general bilinear form `B`.
If `B f g` is integrable, as well as `B f' g` and `B f g'` where `f'` and `g'` are derivatives
of `f` and `g` in a given direction `v`, then `∫ B f g' = - ∫ B f' g`. -/
theorem integral_bilinear_hasLineDerivAt_right_eq_neg_left_of_integrable
{f f' : E → F} {g g' : E → G} {v : E} {B : F →L[ℝ] G →L[ℝ] W}
(hf'g : Integrable (fun x ↦ B (f' x) (g x)) μ) (hfg' : Integrable (fun x ↦ B (f x) (g' x)) μ)
(hfg : Integrable (fun x ↦ B (f x) (g x)) μ)
(hf : ∀ x, HasLineDerivAt ℝ f (f' x) x v) (hg : ∀ x, HasLineDerivAt ℝ g (g' x) x v) :
∫ x, B (f x) (g' x) ∂μ = - ∫ x, B (f' x) (g x) ∂μ := by
by_cases hW : CompleteSpace W; swap
· simp [integral, hW]
rcases eq_or_ne v 0 with rfl | hv
· have Hf' x : f' x = 0 := by
simpa [(hasLineDerivAt_zero (f := f) (x := x)).lineDeriv] using (hf x).lineDeriv.symm
have Hg' x : g' x = 0 := by
simpa [(hasLineDerivAt_zero (f := g) (x := x)).lineDeriv] using (hg x).lineDeriv.symm
simp [Hf', Hg']
have : Nontrivial E := nontrivial_iff.2 ⟨v, 0, hv⟩
let n := finrank ℝ E
let E' := Fin (n - 1) → ℝ
obtain ⟨L, hL⟩ : ∃ L : E ≃L[ℝ] (E' × ℝ), L v = (0, 1) := by
have : finrank ℝ (E' × ℝ) = n := by simpa [this, E'] using Nat.sub_add_cancel finrank_pos
have L₀ : E ≃L[ℝ] (E' × ℝ) := (ContinuousLinearEquiv.ofFinrankEq this).symm
obtain ⟨M, hM⟩ : ∃ M : (E' × ℝ) ≃L[ℝ] (E' × ℝ), M (L₀ v) = (0, 1) := by
apply SeparatingDual.exists_continuousLinearEquiv_apply_eq
· simpa using hv
· simp
exact ⟨L₀.trans M, by simp [hM]⟩
let ν := Measure.map L μ
suffices H : ∫ (x : E' × ℝ), (B (f (L.symm x))) (g' (L.symm x)) ∂ν =
-∫ (x : E' × ℝ), (B (f' (L.symm x))) (g (L.symm x)) ∂ν by
have : μ = Measure.map L.symm ν := by
simp [ν, Measure.map_map L.symm.continuous.measurable L.continuous.measurable]
have hL : IsClosedEmbedding L.symm := L.symm.toHomeomorph.isClosedEmbedding
simpa [this, hL.integral_map] using H
have L_emb : MeasurableEmbedding L := L.toHomeomorph.measurableEmbedding
apply integral_bilinear_hasLineDerivAt_right_eq_neg_left_of_integrable_aux2
· simpa [ν, L_emb.integrable_map_iff, Function.comp_def] using hf'g
· simpa [ν, L_emb.integrable_map_iff, Function.comp_def] using hfg'
· simpa [ν, L_emb.integrable_map_iff, Function.comp_def] using hfg
· intro x
have : f = (f ∘ L.symm) ∘ (L : E →ₗ[ℝ] (E' × ℝ)) := by ext y; simp
specialize hf (L.symm x)
rw [this] at hf
convert hf.of_comp using 1
· simp
· simp [← hL]
· intro x
have : g = (g ∘ L.symm) ∘ (L : E →ₗ[ℝ] (E' × ℝ)) := by ext y; simp
specialize hg (L.symm x)
rw [this] at hg
convert hg.of_comp using 1
· simp
· simp [← hL]
/-- **Integration by parts for Fréchet derivatives**
Version with a general bilinear form `B`.
If `B f g` is integrable, as well as `B f' g` and `B f g'` where `f'` and `g'` are derivatives
of `f` and `g` in a given direction `v`, then `∫ B f g' = - ∫ B f' g`. -/
theorem integral_bilinear_hasFDerivAt_right_eq_neg_left_of_integrable
{f : E → F} {f' : E → (E →L[ℝ] F)}
{g : E → G} {g' : E → (E →L[ℝ] G)} {v : E} {B : F →L[ℝ] G →L[ℝ] W}
(hf'g : Integrable (fun x ↦ B (f' x v) (g x)) μ)
(hfg' : Integrable (fun x ↦ B (f x) (g' x v)) μ)
(hfg : Integrable (fun x ↦ B (f x) (g x)) μ)
(hf : ∀ x, HasFDerivAt f (f' x) x) (hg : ∀ x, HasFDerivAt g (g' x) x) :
∫ x, B (f x) (g' x v) ∂μ = - ∫ x, B (f' x v) (g x) ∂μ :=
integral_bilinear_hasLineDerivAt_right_eq_neg_left_of_integrable hf'g hfg' hfg
(fun x ↦ (hf x).hasLineDerivAt v) (fun x ↦ (hg x).hasLineDerivAt v)
/-- **Integration by parts for Fréchet derivatives**
Version with a general bilinear form `B`.
If `B f g` is integrable, as well as `B f' g` and `B f g'` where `f'` and `g'` are the derivatives
of `f` and `g` in a given direction `v`, then `∫ B f g' = - ∫ B f' g`. -/
theorem integral_bilinear_fderiv_right_eq_neg_left_of_integrable
{f : E → F} {g : E → G} {v : E} {B : F →L[ℝ] G →L[ℝ] W}
(hf'g : Integrable (fun x ↦ B (fderiv ℝ f x v) (g x)) μ)
(hfg' : Integrable (fun x ↦ B (f x) (fderiv ℝ g x v)) μ)
(hfg : Integrable (fun x ↦ B (f x) (g x)) μ)
(hf : Differentiable ℝ f) (hg : Differentiable ℝ g) :
∫ x, B (f x) (fderiv ℝ g x v) ∂μ = - ∫ x, B (fderiv ℝ f x v) (g x) ∂μ :=
integral_bilinear_hasFDerivAt_right_eq_neg_left_of_integrable hf'g hfg' hfg
(fun x ↦ (hf x).hasFDerivAt) (fun x ↦ (hg x).hasFDerivAt)
variable {𝕜 : Type*} [NormedField 𝕜] [NormedAlgebra ℝ 𝕜]
[NormedSpace 𝕜 G] [IsScalarTower ℝ 𝕜 G]
/-- **Integration by parts for Fréchet derivatives**
Version with a scalar function: `∫ f • g' = - ∫ f' • g` when `f • g'` and `f' • g` and `f • g`
are integrable, where `f'` and `g'` are the derivatives of `f` and `g` in a given direction `v`. -/
theorem integral_smul_fderiv_eq_neg_fderiv_smul_of_integrable
{f : E → 𝕜} {g : E → G} {v : E}
(hf'g : Integrable (fun x ↦ fderiv ℝ f x v • g x) μ)
(hfg' : Integrable (fun x ↦ f x • fderiv ℝ g x v) μ)
(hfg : Integrable (fun x ↦ f x • g x) μ)
(hf : Differentiable ℝ f) (hg : Differentiable ℝ g) :
∫ x, f x • fderiv ℝ g x v ∂μ = - ∫ x, fderiv ℝ f x v • g x ∂μ :=
integral_bilinear_fderiv_right_eq_neg_left_of_integrable
(B := ContinuousLinearMap.lsmul ℝ 𝕜) hf'g hfg' hfg hf hg
/-- **Integration by parts for Fréchet derivatives**
Version with two scalar functions: `∫ f * g' = - ∫ f' * g` when `f * g'` and `f' * g` and `f * g`
are integrable, where `f'` and `g'` are the derivatives of `f` and `g` in a given direction `v`. -/
theorem integral_mul_fderiv_eq_neg_fderiv_mul_of_integrable
{f : E → 𝕜} {g : E → 𝕜} {v : E}
(hf'g : Integrable (fun x ↦ fderiv ℝ f x v * g x) μ)
(hfg' : Integrable (fun x ↦ f x * fderiv ℝ g x v) μ)
(hfg : Integrable (fun x ↦ f x * g x) μ)
(hf : Differentiable ℝ f) (hg : Differentiable ℝ g) :
∫ x, f x * fderiv ℝ g x v ∂μ = - ∫ x, fderiv ℝ f x v * g x ∂μ :=
integral_bilinear_fderiv_right_eq_neg_left_of_integrable
(B := ContinuousLinearMap.mul ℝ 𝕜) hf'g hfg' hfg hf hg |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.