source
stringlengths
17
118
lean4
stringlengths
0
335k
.lake/packages/mathlib/Mathlib/Analysis/Calculus/LineDeriv/Basic.lean
import Mathlib.Analysis.Calculus.Deriv.Comp import Mathlib.Analysis.Calculus.Deriv.Add import Mathlib.Analysis.Calculus.Deriv.Mul import Mathlib.Analysis.Calculus.Deriv.Slope /-! # Line derivatives We define the line derivative of a function `f : E → F`, at a point `x : E` along a vector `v : E`, as the element `f' : F` such that `f (x + t • v) = f x + t • f' + o (t)` as `t` tends to `0` in the scalar field `š•œ`, if it exists. It is denoted by `lineDeriv š•œ f x v`. This notion is generally less well behaved than the full FrĆ©chet derivative (for instance, the composition of functions which are line-differentiable is not line-differentiable in general). The FrĆ©chet derivative should therefore be favored over this one in general, although the line derivative may sometimes prove handy. The line derivative in direction `v` is also called the Gateaux derivative in direction `v`, although the term "Gateaux derivative" is sometimes reserved for the situation where there is such a derivative in all directions, for the map `v ↦ lineDeriv š•œ f x v` (which doesn't have to be linear in general). ## Main definition and results We mimic the definitions and statements for the FrĆ©chet derivative and the one-dimensional derivative. We define in particular the following objects: * `LineDifferentiableWithinAt š•œ f s x v` * `LineDifferentiableAt š•œ f x v` * `HasLineDerivWithinAt š•œ f f' s x v` * `HasLineDerivAt š•œ f s x v` * `lineDerivWithin š•œ f s x v` * `lineDeriv š•œ f x v` and develop about them a basic API inspired by the one for the FrĆ©chet derivative. We depart from the FrĆ©chet derivative in two places, as the dependence of the following predicates on the direction would make them barely usable: * We do not define an analogue of the predicate `UniqueDiffOn`; * We do not define `LineDifferentiableOn` nor `LineDifferentiable`. -/ noncomputable section open scoped Topology Filter ENNReal NNReal open Filter Asymptotics Set variable {š•œ : Type*} [NontriviallyNormedField š•œ] variable {F : Type*} [NormedAddCommGroup F] [NormedSpace š•œ F] section Module /-! Results that do not rely on a topological structure on `E` -/ variable (š•œ) variable {E : Type*} [AddCommGroup E] [Module š•œ E] /-- `f` has the derivative `f'` at the point `x` along the direction `v` in the set `s`. That is, `f (x + t v) = f x + t • f' + o (t)` when `t` tends to `0` and `x + t v ∈ s`. Note that this definition is less well behaved than the total FrĆ©chet derivative, which should generally be favored over this one. -/ def HasLineDerivWithinAt (f : E → F) (f' : F) (s : Set E) (x : E) (v : E) := HasDerivWithinAt (fun t ↦ f (x + t • v)) f' ((fun t ↦ x + t • v) ⁻¹' s) (0 : š•œ) /-- `f` has the derivative `f'` at the point `x` along the direction `v`. That is, `f (x + t v) = f x + t • f' + o (t)` when `t` tends to `0`. Note that this definition is less well behaved than the total FrĆ©chet derivative, which should generally be favored over this one. -/ def HasLineDerivAt (f : E → F) (f' : F) (x : E) (v : E) := HasDerivAt (fun t ↦ f (x + t • v)) f' (0 : š•œ) /-- `f` is line-differentiable at the point `x` in the direction `v` in the set `s` if there exists `f'` such that `f (x + t v) = f x + t • f' + o (t)` when `t` tends to `0` and `x + t v ∈ s`. -/ def LineDifferentiableWithinAt (f : E → F) (s : Set E) (x : E) (v : E) : Prop := DifferentiableWithinAt š•œ (fun t ↦ f (x + t • v)) ((fun t ↦ x + t • v) ⁻¹' s) (0 : š•œ) /-- `f` is line-differentiable at the point `x` in the direction `v` if there exists `f'` such that `f (x + t v) = f x + t • f' + o (t)` when `t` tends to `0`. -/ def LineDifferentiableAt (f : E → F) (x : E) (v : E) : Prop := DifferentiableAt š•œ (fun t ↦ f (x + t • v)) (0 : š•œ) /-- Line derivative of `f` at the point `x` in the direction `v` within the set `s`, if it exists. Zero otherwise. If the line derivative exists (i.e., `∃ f', HasLineDerivWithinAt š•œ f f' s x v`), then `f (x + t v) = f x + t lineDerivWithin š•œ f s x v + o (t)` when `t` tends to `0` and `x + t v ∈ s`. -/ def lineDerivWithin (f : E → F) (s : Set E) (x : E) (v : E) : F := derivWithin (fun t ↦ f (x + t • v)) ((fun t ↦ x + t • v) ⁻¹' s) (0 : š•œ) /-- Line derivative of `f` at the point `x` in the direction `v`, if it exists. Zero otherwise. If the line derivative exists (i.e., `∃ f', HasLineDerivAt š•œ f f' x v`), then `f (x + t v) = f x + t lineDeriv š•œ f x v + o (t)` when `t` tends to `0`. -/ def lineDeriv (f : E → F) (x : E) (v : E) : F := deriv (fun t ↦ f (x + t • v)) (0 : š•œ) variable {š•œ} variable {f f₁ : E → F} {f' fā‚€' f₁' : F} {s t : Set E} {x v : E} lemma HasLineDerivWithinAt.mono (hf : HasLineDerivWithinAt š•œ f f' s x v) (hst : t āŠ† s) : HasLineDerivWithinAt š•œ f f' t x v := HasDerivWithinAt.mono hf (preimage_mono hst) lemma HasLineDerivAt.hasLineDerivWithinAt (hf : HasLineDerivAt š•œ f f' x v) (s : Set E) : HasLineDerivWithinAt š•œ f f' s x v := HasDerivAt.hasDerivWithinAt hf lemma HasLineDerivWithinAt.lineDifferentiableWithinAt (hf : HasLineDerivWithinAt š•œ f f' s x v) : LineDifferentiableWithinAt š•œ f s x v := HasDerivWithinAt.differentiableWithinAt hf theorem HasLineDerivAt.lineDifferentiableAt (hf : HasLineDerivAt š•œ f f' x v) : LineDifferentiableAt š•œ f x v := HasDerivAt.differentiableAt hf theorem LineDifferentiableWithinAt.hasLineDerivWithinAt (h : LineDifferentiableWithinAt š•œ f s x v) : HasLineDerivWithinAt š•œ f (lineDerivWithin š•œ f s x v) s x v := DifferentiableWithinAt.hasDerivWithinAt h theorem LineDifferentiableAt.hasLineDerivAt (h : LineDifferentiableAt š•œ f x v) : HasLineDerivAt š•œ f (lineDeriv š•œ f x v) x v := DifferentiableAt.hasDerivAt h @[simp] lemma hasLineDerivWithinAt_univ : HasLineDerivWithinAt š•œ f f' univ x v ↔ HasLineDerivAt š•œ f f' x v := by simp only [HasLineDerivWithinAt, HasLineDerivAt, preimage_univ, hasDerivWithinAt_univ] theorem lineDerivWithin_zero_of_not_lineDifferentiableWithinAt (h : ¬LineDifferentiableWithinAt š•œ f s x v) : lineDerivWithin š•œ f s x v = 0 := derivWithin_zero_of_not_differentiableWithinAt h theorem lineDeriv_zero_of_not_lineDifferentiableAt (h : ¬LineDifferentiableAt š•œ f x v) : lineDeriv š•œ f x v = 0 := deriv_zero_of_not_differentiableAt h theorem hasLineDerivAt_iff_isLittleO_nhds_zero : HasLineDerivAt š•œ f f' x v ↔ (fun t : š•œ => f (x + t • v) - f x - t • f') =o[š“ 0] fun t => t := by simp only [HasLineDerivAt, hasDerivAt_iff_isLittleO_nhds_zero, zero_add, zero_smul, add_zero] theorem HasLineDerivAt.unique (hā‚€ : HasLineDerivAt š•œ f fā‚€' x v) (h₁ : HasLineDerivAt š•œ f f₁' x v) : fā‚€' = f₁' := HasDerivAt.unique hā‚€ h₁ protected theorem HasLineDerivAt.lineDeriv (h : HasLineDerivAt š•œ f f' x v) : lineDeriv š•œ f x v = f' := by rw [h.unique h.lineDifferentiableAt.hasLineDerivAt] theorem lineDifferentiableWithinAt_univ : LineDifferentiableWithinAt š•œ f univ x v ↔ LineDifferentiableAt š•œ f x v := by simp only [LineDifferentiableWithinAt, LineDifferentiableAt, preimage_univ, differentiableWithinAt_univ] theorem LineDifferentiableAt.lineDifferentiableWithinAt (h : LineDifferentiableAt š•œ f x v) : LineDifferentiableWithinAt š•œ f s x v := (differentiableWithinAt_univ.2 h).mono (subset_univ _) @[simp] theorem lineDerivWithin_univ : lineDerivWithin š•œ f univ x v = lineDeriv š•œ f x v := by simp [lineDerivWithin, lineDeriv] theorem LineDifferentiableWithinAt.mono (h : LineDifferentiableWithinAt š•œ f t x v) (st : s āŠ† t) : LineDifferentiableWithinAt š•œ f s x v := (h.hasLineDerivWithinAt.mono st).lineDifferentiableWithinAt theorem HasLineDerivWithinAt.congr_mono (h : HasLineDerivWithinAt š•œ f f' s x v) (ht : EqOn f₁ f t) (hx : f₁ x = f x) (h₁ : t āŠ† s) : HasLineDerivWithinAt š•œ f₁ f' t x v := HasDerivWithinAt.congr_mono h (fun _ hy ↦ ht hy) (by simpa using hx) (preimage_mono h₁) theorem HasLineDerivWithinAt.congr (h : HasLineDerivWithinAt š•œ f f' s x v) (hs : EqOn f₁ f s) (hx : f₁ x = f x) : HasLineDerivWithinAt š•œ f₁ f' s x v := h.congr_mono hs hx (Subset.refl _) theorem HasLineDerivWithinAt.congr' (h : HasLineDerivWithinAt š•œ f f' s x v) (hs : EqOn f₁ f s) (hx : x ∈ s) : HasLineDerivWithinAt š•œ f₁ f' s x v := h.congr hs (hs hx) theorem LineDifferentiableWithinAt.congr_mono (h : LineDifferentiableWithinAt š•œ f s x v) (ht : EqOn f₁ f t) (hx : f₁ x = f x) (h₁ : t āŠ† s) : LineDifferentiableWithinAt š•œ f₁ t x v := (HasLineDerivWithinAt.congr_mono h.hasLineDerivWithinAt ht hx h₁).differentiableWithinAt theorem LineDifferentiableWithinAt.congr (h : LineDifferentiableWithinAt š•œ f s x v) (ht : āˆ€ x ∈ s, f₁ x = f x) (hx : f₁ x = f x) : LineDifferentiableWithinAt š•œ f₁ s x v := LineDifferentiableWithinAt.congr_mono h ht hx (Subset.refl _) theorem lineDerivWithin_congr (hs : EqOn f₁ f s) (hx : f₁ x = f x) : lineDerivWithin š•œ f₁ s x v = lineDerivWithin š•œ f s x v := derivWithin_congr (fun _ hy ↦ hs hy) (by simpa using hx) theorem lineDerivWithin_congr' (hs : EqOn f₁ f s) (hx : x ∈ s) : lineDerivWithin š•œ f₁ s x v = lineDerivWithin š•œ f s x v := lineDerivWithin_congr hs (hs hx) theorem hasLineDerivAt_iff_tendsto_slope_zero : HasLineDerivAt š•œ f f' x v ↔ Tendsto (fun (t : š•œ) ↦ t⁻¹ • (f (x + t • v) - f x)) (š“[≠] 0) (š“ f') := by simp only [HasLineDerivAt, hasDerivAt_iff_tendsto_slope_zero, zero_add, zero_smul, add_zero] alias ⟨HasLineDerivAt.tendsto_slope_zero, _⟩ := hasLineDerivAt_iff_tendsto_slope_zero theorem HasLineDerivAt.tendsto_slope_zero_right [Preorder š•œ] (h : HasLineDerivAt š•œ f f' x v) : Tendsto (fun (t : š•œ) ↦ t⁻¹ • (f (x + t • v) - f x)) (š“[>] 0) (š“ f') := h.tendsto_slope_zero.mono_left (nhdsGT_le_nhdsNE 0) theorem HasLineDerivAt.tendsto_slope_zero_left [Preorder š•œ] (h : HasLineDerivAt š•œ f f' x v) : Tendsto (fun (t : š•œ) ↦ t⁻¹ • (f (x + t • v) - f x)) (š“[<] 0) (š“ f') := h.tendsto_slope_zero.mono_left (nhdsLT_le_nhdsNE 0) theorem HasLineDerivWithinAt.hasLineDerivAt' (h : HasLineDerivWithinAt š•œ f f' s x v) (hs : āˆ€į¶  t : š•œ in š“ 0, x + t • v ∈ s) : HasLineDerivAt š•œ f f' x v := h.hasDerivAt hs end Module section NormedSpace /-! Results that need a normed space structure on `E` -/ variable {E : Type*} [NormedAddCommGroup E] [NormedSpace š•œ E] {f fā‚€ f₁ : E → F} {f' : F} {s t : Set E} {x v : E} {L : E →L[š•œ] F} theorem HasLineDerivWithinAt.mono_of_mem_nhdsWithin (h : HasLineDerivWithinAt š•œ f f' t x v) (hst : t ∈ š“[s] x) : HasLineDerivWithinAt š•œ f f' s x v := by apply HasDerivWithinAt.mono_of_mem_nhdsWithin h apply ContinuousWithinAt.preimage_mem_nhdsWithin'' _ hst (by simp) apply Continuous.continuousWithinAt; fun_prop theorem HasLineDerivWithinAt.hasLineDerivAt (h : HasLineDerivWithinAt š•œ f f' s x v) (hs : s ∈ š“ x) : HasLineDerivAt š•œ f f' x v := h.hasLineDerivAt' <| (Continuous.tendsto' (by fun_prop) 0 _ (by simp)).eventually hs theorem LineDifferentiableWithinAt.lineDifferentiableAt (h : LineDifferentiableWithinAt š•œ f s x v) (hs : s ∈ š“ x) : LineDifferentiableAt š•œ f x v := (h.hasLineDerivWithinAt.hasLineDerivAt hs).lineDifferentiableAt lemma HasFDerivWithinAt.hasLineDerivWithinAt (hf : HasFDerivWithinAt f L s x) (v : E) : HasLineDerivWithinAt š•œ f (L v) s x v := by let F := fun (t : š•œ) ↦ x + t • v rw [show x = F (0 : š•œ) by simp [F]] at hf have A : HasDerivWithinAt F (0 + (1 : š•œ) • v) (F ⁻¹' s) 0 := ((hasDerivAt_const (0 : š•œ) x).add ((hasDerivAt_id' (0 : š•œ)).smul_const v)).hasDerivWithinAt simp only [one_smul, zero_add] at A exact hf.comp_hasDerivWithinAt (x := (0 : š•œ)) A (mapsTo_preimage F s) lemma HasFDerivAt.hasLineDerivAt (hf : HasFDerivAt f L x) (v : E) : HasLineDerivAt š•œ f (L v) x v := by rw [← hasLineDerivWithinAt_univ] exact hf.hasFDerivWithinAt.hasLineDerivWithinAt v lemma DifferentiableAt.lineDeriv_eq_fderiv (hf : DifferentiableAt š•œ f x) : lineDeriv š•œ f x v = fderiv š•œ f x v := (hf.hasFDerivAt.hasLineDerivAt v).lineDeriv theorem LineDifferentiableWithinAt.mono_of_mem_nhdsWithin (h : LineDifferentiableWithinAt š•œ f s x v) (hst : s ∈ š“[t] x) : LineDifferentiableWithinAt š•œ f t x v := (h.hasLineDerivWithinAt.mono_of_mem_nhdsWithin hst).lineDifferentiableWithinAt theorem lineDerivWithin_of_mem_nhds (h : s ∈ š“ x) : lineDerivWithin š•œ f s x v = lineDeriv š•œ f x v := by apply derivWithin_of_mem_nhds apply (Continuous.continuousAt _).preimage_mem_nhds (by simpa using h) fun_prop theorem lineDerivWithin_of_isOpen (hs : IsOpen s) (hx : x ∈ s) : lineDerivWithin š•œ f s x v = lineDeriv š•œ f x v := lineDerivWithin_of_mem_nhds (hs.mem_nhds hx) theorem hasLineDerivWithinAt_congr_set (h : s =į¶ [š“ x] t) : HasLineDerivWithinAt š•œ f f' s x v ↔ HasLineDerivWithinAt š•œ f f' t x v := by apply hasDerivWithinAt_congr_set let F := fun (t : š•œ) ↦ x + t • v have B : ContinuousAt F 0 := by apply Continuous.continuousAt; fun_prop have : s =į¶ [š“ (F 0)] t := by convert h; simp [F] exact B.preimage_mem_nhds this theorem lineDifferentiableWithinAt_congr_set (h : s =į¶ [š“ x] t) : LineDifferentiableWithinAt š•œ f s x v ↔ LineDifferentiableWithinAt š•œ f t x v := ⟨fun h' ↦ ((hasLineDerivWithinAt_congr_set h).1 h'.hasLineDerivWithinAt).lineDifferentiableWithinAt, fun h' ↦ ((hasLineDerivWithinAt_congr_set h.symm).1 h'.hasLineDerivWithinAt).lineDifferentiableWithinAt⟩ theorem lineDerivWithin_congr_set (h : s =į¶ [š“ x] t) : lineDerivWithin š•œ f s x v = lineDerivWithin š•œ f t x v := by apply derivWithin_congr_set let F := fun (t : š•œ) ↦ x + t • v have B : ContinuousAt F 0 := by apply Continuous.continuousAt; fun_prop have : s =į¶ [š“ (F 0)] t := by convert h; simp [F] exact B.preimage_mem_nhds this theorem Filter.EventuallyEq.hasLineDerivAt_iff (h : fā‚€ =į¶ [š“ x] f₁) : HasLineDerivAt š•œ fā‚€ f' x v ↔ HasLineDerivAt š•œ f₁ f' x v := by apply hasDerivAt_iff let F := fun (t : š•œ) ↦ x + t • v have B : ContinuousAt F 0 := by apply Continuous.continuousAt; fun_prop have : fā‚€ =į¶ [š“ (F 0)] f₁ := by convert h; simp [F] exact B.preimage_mem_nhds this theorem Filter.EventuallyEq.lineDifferentiableAt_iff (h : fā‚€ =į¶ [š“ x] f₁) : LineDifferentiableAt š•œ fā‚€ x v ↔ LineDifferentiableAt š•œ f₁ x v := ⟨fun h' ↦ (h.hasLineDerivAt_iff.1 h'.hasLineDerivAt).lineDifferentiableAt, fun h' ↦ (h.hasLineDerivAt_iff.2 h'.hasLineDerivAt).lineDifferentiableAt⟩ theorem Filter.EventuallyEq.hasLineDerivWithinAt_iff (h : fā‚€ =į¶ [š“[s] x] f₁) (hx : fā‚€ x = f₁ x) : HasLineDerivWithinAt š•œ fā‚€ f' s x v ↔ HasLineDerivWithinAt š•œ f₁ f' s x v := by apply hasDerivWithinAt_iff Ā· have A : Continuous (fun (t : š•œ) ↦ x + t • v) := by fun_prop exact A.continuousWithinAt.preimage_mem_nhdsWithin'' h (by simp) Ā· simpa using hx theorem Filter.EventuallyEq.hasLineDerivWithinAt_iff_of_mem (h : fā‚€ =į¶ [š“[s] x] f₁) (hx : x ∈ s) : HasLineDerivWithinAt š•œ fā‚€ f' s x v ↔ HasLineDerivWithinAt š•œ f₁ f' s x v := h.hasLineDerivWithinAt_iff (h.eq_of_nhdsWithin hx) theorem Filter.EventuallyEq.lineDifferentiableWithinAt_iff (h : fā‚€ =į¶ [š“[s] x] f₁) (hx : fā‚€ x = f₁ x) : LineDifferentiableWithinAt š•œ fā‚€ s x v ↔ LineDifferentiableWithinAt š•œ f₁ s x v := ⟨fun h' ↦ ((h.hasLineDerivWithinAt_iff hx).1 h'.hasLineDerivWithinAt).lineDifferentiableWithinAt, fun h' ↦ ((h.hasLineDerivWithinAt_iff hx).2 h'.hasLineDerivWithinAt).lineDifferentiableWithinAt⟩ theorem Filter.EventuallyEq.lineDifferentiableWithinAt_iff_of_mem (h : fā‚€ =į¶ [š“[s] x] f₁) (hx : x ∈ s) : LineDifferentiableWithinAt š•œ fā‚€ s x v ↔ LineDifferentiableWithinAt š•œ f₁ s x v := h.lineDifferentiableWithinAt_iff (h.eq_of_nhdsWithin hx) lemma HasLineDerivWithinAt.congr_of_eventuallyEq (hf : HasLineDerivWithinAt š•œ f f' s x v) (h'f : f₁ =į¶ [š“[s] x] f) (hx : f₁ x = f x) : HasLineDerivWithinAt š•œ f₁ f' s x v := h'f.symm.hasLineDerivWithinAt_iff hx.symm |>.mp hf theorem HasLineDerivAt.congr_of_eventuallyEq (h : HasLineDerivAt š•œ f f' x v) (h₁ : f₁ =į¶ [š“ x] f) : HasLineDerivAt š•œ f₁ f' x v := (EventuallyEq.hasLineDerivAt_iff h₁.symm).mp h theorem LineDifferentiableWithinAt.congr_of_eventuallyEq (h : LineDifferentiableWithinAt š•œ f s x v) (h₁ : f₁ =į¶ [š“[s] x] f) (hx : f₁ x = f x) : LineDifferentiableWithinAt š•œ f₁ s x v := (h.hasLineDerivWithinAt.congr_of_eventuallyEq h₁ hx).differentiableWithinAt theorem LineDifferentiableAt.congr_of_eventuallyEq (h : LineDifferentiableAt š•œ f x v) (hL : f₁ =į¶ [š“ x] f) : LineDifferentiableAt š•œ f₁ x v := hL.symm.lineDifferentiableAt_iff.mp h theorem Filter.EventuallyEq.lineDerivWithin_eq (hs : f₁ =į¶ [š“[s] x] f) (hx : f₁ x = f x) : lineDerivWithin š•œ f₁ s x v = lineDerivWithin š•œ f s x v := by apply derivWithin_eq ?_ (by simpa using hx) have A : Continuous (fun (t : š•œ) ↦ x + t • v) := by fun_prop exact A.continuousWithinAt.preimage_mem_nhdsWithin'' hs (by simp) theorem Filter.EventuallyEq.lineDerivWithin_eq_nhds (h : f₁ =į¶ [š“ x] f) : lineDerivWithin š•œ f₁ s x v = lineDerivWithin š•œ f s x v := (h.filter_mono nhdsWithin_le_nhds).lineDerivWithin_eq h.self_of_nhds theorem Filter.EventuallyEq.lineDeriv_eq (h : f₁ =į¶ [š“ x] f) : lineDeriv š•œ f₁ x v = lineDeriv š•œ f x v := by rw [← lineDerivWithin_univ, ← lineDerivWithin_univ, h.lineDerivWithin_eq_nhds] /-- Converse to the mean value inequality: if `f` is line differentiable at `xā‚€` and `C`-lipschitz on a neighborhood of `xā‚€` then its line derivative at `xā‚€` in the direction `v` has norm bounded by `C * ‖v‖`. This version only assumes that `‖f x - f x₀‖ ≤ C * ‖x - x₀‖` in a neighborhood of `x`. -/ theorem HasLineDerivAt.le_of_lip' {f : E → F} {f' : F} {xā‚€ : E} (hf : HasLineDerivAt š•œ f f' xā‚€ v) {C : ā„} (hCā‚€ : 0 ≤ C) (hlip : āˆ€į¶  x in š“ xā‚€, ‖f x - f x₀‖ ≤ C * ‖x - x₀‖) : ‖f'‖ ≤ C * ‖v‖ := by apply HasDerivAt.le_of_lip' hf (by positivity) have A : Continuous (fun (t : š•œ) ↦ xā‚€ + t • v) := by fun_prop have : āˆ€į¶  x in š“ (xā‚€ + (0 : š•œ) • v), ‖f x - f x₀‖ ≤ C * ‖x - x₀‖ := by simpa using hlip filter_upwards [(A.continuousAt (x := 0)).preimage_mem_nhds this] with t ht simp only [preimage_setOf_eq, add_sub_cancel_left, norm_smul, mem_setOf_eq, mul_comm (‖t‖)] at ht simpa [mul_assoc] using ht /-- Converse to the mean value inequality: if `f` is line differentiable at `xā‚€` and `C`-lipschitz on a neighborhood of `xā‚€` then its line derivative at `xā‚€` in the direction `v` has norm bounded by `C * ‖v‖`. This version only assumes that `‖f x - f x₀‖ ≤ C * ‖x - x₀‖` in a neighborhood of `x`. -/ theorem HasLineDerivAt.le_of_lipschitzOn {f : E → F} {f' : F} {xā‚€ : E} (hf : HasLineDerivAt š•œ f f' xā‚€ v) {s : Set E} (hs : s ∈ š“ xā‚€) {C : ā„ā‰„0} (hlip : LipschitzOnWith C f s) : ‖f'‖ ≤ C * ‖v‖ := 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 line differentiable at `xā‚€` and `C`-lipschitz then its line derivative at `xā‚€` in the direction `v` has norm bounded by `C * ‖v‖`. -/ theorem HasLineDerivAt.le_of_lipschitz {f : E → F} {f' : F} {xā‚€ : E} (hf : HasLineDerivAt š•œ f f' xā‚€ v) {C : ā„ā‰„0} (hlip : LipschitzWith C f) : ‖f'‖ ≤ C * ‖v‖ := 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 line derivative at `xā‚€` in the direction `v` has norm bounded by `C * ‖v‖`. This version only assumes that `‖f x - f x₀‖ ≤ C * ‖x - x₀‖` in a neighborhood of `x`. Version using `lineDeriv`. -/ theorem norm_lineDeriv_le_of_lip' {f : E → F} {xā‚€ : E} {C : ā„} (hCā‚€ : 0 ≤ C) (hlip : āˆ€į¶  x in š“ xā‚€, ‖f x - f x₀‖ ≤ C * ‖x - x₀‖) : ‖lineDeriv š•œ f xā‚€ v‖ ≤ C * ‖v‖ := by apply norm_deriv_le_of_lip' (by positivity) have A : Continuous (fun (t : š•œ) ↦ xā‚€ + t • v) := by fun_prop have : āˆ€į¶  x in š“ (xā‚€ + (0 : š•œ) • v), ‖f x - f x₀‖ ≤ C * ‖x - x₀‖ := by simpa using hlip filter_upwards [(A.continuousAt (x := 0)).preimage_mem_nhds this] with t ht simp only [preimage_setOf_eq, add_sub_cancel_left, norm_smul, mem_setOf_eq, mul_comm (‖t‖)] at ht simpa [mul_assoc] using ht /-- Converse to the mean value inequality: if `f` is `C`-lipschitz on a neighborhood of `xā‚€` then its line derivative at `xā‚€` in the direction `v` has norm bounded by `C * ‖v‖`. Version using `lineDeriv`. -/ theorem norm_lineDeriv_le_of_lipschitzOn {f : E → F} {xā‚€ : E} {s : Set E} (hs : s ∈ š“ xā‚€) {C : ā„ā‰„0} (hlip : LipschitzOnWith C f s) : ‖lineDeriv š•œ f xā‚€ v‖ ≤ C * ‖v‖ := by refine norm_lineDeriv_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 line derivative at `xā‚€` in the direction `v` has norm bounded by `C * ‖v‖`. Version using `lineDeriv`. -/ theorem norm_lineDeriv_le_of_lipschitz {f : E → F} {xā‚€ : E} {C : ā„ā‰„0} (hlip : LipschitzWith C f) : ‖lineDeriv š•œ f xā‚€ v‖ ≤ C * ‖v‖ := norm_lineDeriv_le_of_lipschitzOn š•œ univ_mem (lipschitzOnWith_univ.2 hlip) variable {š•œ} end NormedSpace section Zero variable {E : Type*} [AddCommGroup E] [Module š•œ E] {f : E → F} {s : Set E} {x : E} theorem hasLineDerivWithinAt_zero : HasLineDerivWithinAt š•œ f 0 s x 0 := by simp [HasLineDerivWithinAt, hasDerivWithinAt_const] theorem hasLineDerivAt_zero : HasLineDerivAt š•œ f 0 x 0 := by simp [HasLineDerivAt, hasDerivAt_const] theorem lineDifferentiableWithinAt_zero : LineDifferentiableWithinAt š•œ f s x 0 := hasLineDerivWithinAt_zero.lineDifferentiableWithinAt theorem lineDifferentiableAt_zero : LineDifferentiableAt š•œ f x 0 := hasLineDerivAt_zero.lineDifferentiableAt theorem lineDeriv_zero : lineDeriv š•œ f x 0 = 0 := hasLineDerivAt_zero.lineDeriv end Zero section CompRight variable {E : Type*} [AddCommGroup E] [Module š•œ E] {E' : Type*} [AddCommGroup E'] [Module š•œ E'] {f : E → F} {f' : F} {x : E'} {L : E' →ₗ[š•œ] E} theorem HasLineDerivAt.of_comp {v : E'} (hf : HasLineDerivAt š•œ (f ∘ L) f' x v) : HasLineDerivAt š•œ f f' (L x) (L v) := by simpa [HasLineDerivAt] using hf theorem LineDifferentiableAt.of_comp {v : E'} (hf : LineDifferentiableAt š•œ (f ∘ L) x v) : LineDifferentiableAt š•œ f (L x) (L v) := hf.hasLineDerivAt.of_comp.lineDifferentiableAt end CompRight section SMul variable {E : Type*} [AddCommGroup E] [Module š•œ E] {f : E → F} {s : Set E} {x v : E} {f' : F} theorem HasLineDerivWithinAt.smul (h : HasLineDerivWithinAt š•œ f f' s x v) (c : š•œ) : HasLineDerivWithinAt š•œ f (c • f') s x (c • v) := by simp only [HasLineDerivWithinAt] at h ⊢ let g := fun (t : š•œ) ↦ c • t let s' := (fun (t : š•œ) ↦ x + t • v) ⁻¹' s have A : HasDerivAt g c 0 := by simpa using (hasDerivAt_id (0 : š•œ)).const_smul c have B : HasDerivWithinAt (fun t ↦ f (x + t • v)) f' s' (g 0) := by simpa [g] using h have Z := B.scomp (0 : š•œ) A.hasDerivWithinAt (mapsTo_preimage g s') simp only [g, s', Function.comp_def, smul_eq_mul, mul_comm c, ← smul_smul] at Z convert Z ext t simp [← smul_smul] theorem hasLineDerivWithinAt_smul_iff {c : š•œ} (hc : c ≠ 0) : HasLineDerivWithinAt š•œ f (c • f') s x (c • v) ↔ HasLineDerivWithinAt š•œ f f' s x v := ⟨fun h ↦ by simpa [smul_smul, inv_mul_cancelā‚€ hc] using h.smul (c ⁻¹), fun h ↦ h.smul c⟩ theorem HasLineDerivAt.smul (h : HasLineDerivAt š•œ f f' x v) (c : š•œ) : HasLineDerivAt š•œ f (c • f') x (c • v) := by simp only [← hasLineDerivWithinAt_univ] at h ⊢ exact HasLineDerivWithinAt.smul h c theorem hasLineDerivAt_smul_iff {c : š•œ} (hc : c ≠ 0) : HasLineDerivAt š•œ f (c • f') x (c • v) ↔ HasLineDerivAt š•œ f f' x v := ⟨fun h ↦ by simpa [smul_smul, inv_mul_cancelā‚€ hc] using h.smul (c ⁻¹), fun h ↦ h.smul c⟩ theorem LineDifferentiableWithinAt.smul (h : LineDifferentiableWithinAt š•œ f s x v) (c : š•œ) : LineDifferentiableWithinAt š•œ f s x (c • v) := (h.hasLineDerivWithinAt.smul c).lineDifferentiableWithinAt theorem lineDifferentiableWithinAt_smul_iff {c : š•œ} (hc : c ≠ 0) : LineDifferentiableWithinAt š•œ f s x (c • v) ↔ LineDifferentiableWithinAt š•œ f s x v := ⟨fun h ↦ by simpa [smul_smul, inv_mul_cancelā‚€ hc] using h.smul (c ⁻¹), fun h ↦ h.smul c⟩ theorem LineDifferentiableAt.smul (h : LineDifferentiableAt š•œ f x v) (c : š•œ) : LineDifferentiableAt š•œ f x (c • v) := (h.hasLineDerivAt.smul c).lineDifferentiableAt theorem lineDifferentiableAt_smul_iff {c : š•œ} (hc : c ≠ 0) : LineDifferentiableAt š•œ f x (c • v) ↔ LineDifferentiableAt š•œ f x v := ⟨fun h ↦ by simpa [smul_smul, inv_mul_cancelā‚€ hc] using h.smul (c ⁻¹), fun h ↦ h.smul c⟩ theorem lineDeriv_smul {c : š•œ} : lineDeriv š•œ f x (c • v) = c • lineDeriv š•œ f x v := by rcases eq_or_ne c 0 with rfl | hc Ā· simp [lineDeriv_zero] by_cases H : LineDifferentiableAt š•œ f x v Ā· exact (H.hasLineDerivAt.smul c).lineDeriv Ā· have H' : ¬ (LineDifferentiableAt š•œ f x (c • v)) := by simpa [lineDifferentiableAt_smul_iff hc] using H simp [lineDeriv_zero_of_not_lineDifferentiableAt, H, H'] theorem lineDeriv_neg : lineDeriv š•œ f x (-v) = - lineDeriv š•œ f x v := by rw [← neg_one_smul (R := š•œ) v, lineDeriv_smul, neg_one_smul] end SMul
.lake/packages/mathlib/Mathlib/Analysis/Calculus/LineDeriv/Measurable.lean
import Mathlib.Analysis.Calculus.LineDeriv.Basic import Mathlib.Analysis.Calculus.FDeriv.Measurable /-! # Measurability of the line derivative We prove in `measurable_lineDeriv` that the line derivative of a function (with respect to a locally compact scalar field) is measurable, provided the function is continuous. In `measurable_lineDeriv_uncurry`, assuming additionally that the source space is second countable, we show that `(x, v) ↦ lineDeriv š•œ f x v` is also measurable. An assumption such as continuity is necessary, as otherwise one could alternate in a non-measurable way between differentiable and non-differentiable functions along the various lines directed by `v`. -/ open MeasureTheory variable {š•œ : Type*} [NontriviallyNormedField š•œ] [LocallyCompactSpace š•œ] {E : Type*} [NormedAddCommGroup E] [NormedSpace š•œ E] [MeasurableSpace E] [OpensMeasurableSpace E] {F : Type*} [NormedAddCommGroup F] [NormedSpace š•œ F] [CompleteSpace F] {f : E → F} {v : E} /-! Measurability of the line derivative `lineDeriv š•œ f x v` with respect to a fixed direction `v`. -/ theorem measurableSet_lineDifferentiableAt (hf : Continuous f) : MeasurableSet {x : E | LineDifferentiableAt š•œ f x v} := by borelize š•œ let g : E → š•œ → F := fun x t ↦ f (x + t • v) have hg : Continuous g.uncurry := by fun_prop exact measurable_prodMk_right (measurableSet_of_differentiableAt_with_param š•œ hg) theorem measurable_lineDeriv [MeasurableSpace F] [BorelSpace F] (hf : Continuous f) : Measurable (fun x ↦ lineDeriv š•œ f x v) := by borelize š•œ let g : E → š•œ → F := fun x t ↦ f (x + t • v) have hg : Continuous g.uncurry := by fun_prop exact (measurable_deriv_with_param hg).comp measurable_prodMk_right theorem stronglyMeasurable_lineDeriv [SecondCountableTopologyEither E F] (hf : Continuous f) : StronglyMeasurable (fun x ↦ lineDeriv š•œ f x v) := by borelize š•œ let g : E → š•œ → F := fun x t ↦ f (x + t • v) have hg : Continuous g.uncurry := by fun_prop exact (stronglyMeasurable_deriv_with_param hg).comp_measurable measurable_prodMk_right theorem aemeasurable_lineDeriv [MeasurableSpace F] [BorelSpace F] (hf : Continuous f) (μ : Measure E) : AEMeasurable (fun x ↦ lineDeriv š•œ f x v) μ := (measurable_lineDeriv hf).aemeasurable theorem aestronglyMeasurable_lineDeriv [SecondCountableTopologyEither E F] (hf : Continuous f) (μ : Measure E) : AEStronglyMeasurable (fun x ↦ lineDeriv š•œ f x v) μ := (stronglyMeasurable_lineDeriv hf).aestronglyMeasurable /-! Measurability of the line derivative `lineDeriv š•œ f x v` when varying both `x` and `v`. For this, we need an additional second countability assumption on `E` to make sure that open sets are measurable in `E Ɨ E`. -/ variable [SecondCountableTopology E] theorem measurableSet_lineDifferentiableAt_uncurry (hf : Continuous f) : MeasurableSet {p : E Ɨ E | LineDifferentiableAt š•œ f p.1 p.2} := by borelize š•œ let g : (E Ɨ E) → š•œ → F := fun p t ↦ f (p.1 + t • p.2) have : Continuous g.uncurry := hf.comp <| (continuous_fst.comp continuous_fst).add <| continuous_snd.smul (continuous_snd.comp continuous_fst) have M_meas : MeasurableSet {q : (E Ɨ E) Ɨ š•œ | DifferentiableAt š•œ (g q.1) q.2} := measurableSet_of_differentiableAt_with_param š•œ this exact measurable_prodMk_right M_meas theorem measurable_lineDeriv_uncurry [MeasurableSpace F] [BorelSpace F] (hf : Continuous f) : Measurable (fun (p : E Ɨ E) ↦ lineDeriv š•œ f p.1 p.2) := by borelize š•œ let g : (E Ɨ E) → š•œ → F := fun p t ↦ f (p.1 + t • p.2) have : Continuous g.uncurry := hf.comp <| (continuous_fst.comp continuous_fst).add <| continuous_snd.smul (continuous_snd.comp continuous_fst) exact (measurable_deriv_with_param this).comp measurable_prodMk_right theorem stronglyMeasurable_lineDeriv_uncurry (hf : Continuous f) : StronglyMeasurable (fun (p : E Ɨ E) ↦ lineDeriv š•œ f p.1 p.2) := by borelize š•œ let g : (E Ɨ E) → š•œ → F := fun p t ↦ f (p.1 + t • p.2) have : Continuous g.uncurry := hf.comp <| (continuous_fst.comp continuous_fst).add <| continuous_snd.smul (continuous_snd.comp continuous_fst) exact (stronglyMeasurable_deriv_with_param this).comp_measurable measurable_prodMk_right theorem aemeasurable_lineDeriv_uncurry [MeasurableSpace F] [BorelSpace F] (hf : Continuous f) (μ : Measure (E Ɨ E)) : AEMeasurable (fun (p : E Ɨ E) ↦ lineDeriv š•œ f p.1 p.2) μ := (measurable_lineDeriv_uncurry hf).aemeasurable theorem aestronglyMeasurable_lineDeriv_uncurry (hf : Continuous f) (μ : Measure (E Ɨ E)) : AEStronglyMeasurable (fun (p : E Ɨ E) ↦ lineDeriv š•œ f p.1 p.2) μ := (stronglyMeasurable_lineDeriv_uncurry hf).aestronglyMeasurable
.lake/packages/mathlib/Mathlib/Analysis/Calculus/BumpFunction/Normed.lean
import Mathlib.Analysis.Calculus.BumpFunction.Basic import Mathlib.MeasureTheory.Integral.Bochner.ContinuousLinearMap import Mathlib.MeasureTheory.Measure.Lebesgue.EqHaar /-! # Normed bump function In this file we define `ContDiffBump.normed f μ` to be the bump function `f` normalized so that `∫ x, f.normed μ x āˆ‚Ī¼ = 1` and prove some properties of this function. -/ noncomputable section open Function Filter Set Metric MeasureTheory Module Measure open scoped Topology namespace ContDiffBump variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ā„ E] [HasContDiffBump E] [MeasurableSpace E] {c : E} (f : ContDiffBump c) {x : E} {n : ā„•āˆž} {μ : Measure E} /-- A bump function normed so that `∫ x, f.normed μ x āˆ‚Ī¼ = 1`. -/ protected def normed (μ : Measure E) : E → ā„ := fun x => f x / ∫ x, f x āˆ‚Ī¼ theorem normed_def {μ : Measure E} (x : E) : f.normed μ x = f x / ∫ x, f x āˆ‚Ī¼ := rfl theorem nonneg_normed (x : E) : 0 ≤ f.normed μ x := div_nonneg f.nonneg <| integral_nonneg f.nonneg' theorem contDiff_normed {n : ā„•āˆž} : ContDiff ā„ n (f.normed μ) := f.contDiff.div_const _ theorem continuous_normed : Continuous (f.normed μ) := f.continuous.div_const _ theorem normed_sub (x : E) : f.normed μ (c - x) = f.normed μ (c + x) := by simp_rw [f.normed_def, f.sub] theorem normed_neg (f : ContDiffBump (0 : E)) (x : E) : f.normed μ (-x) = f.normed μ x := by simp_rw [f.normed_def, f.neg] variable [BorelSpace E] [FiniteDimensional ā„ E] [IsLocallyFiniteMeasure μ] protected theorem integrable : Integrable f μ := f.continuous.integrable_of_hasCompactSupport f.hasCompactSupport protected theorem integrable_normed : Integrable (f.normed μ) μ := f.integrable.div_const _ section variable [μ.IsOpenPosMeasure] theorem integral_pos : 0 < ∫ x, f x āˆ‚Ī¼ := by refine (integral_pos_iff_support_of_nonneg f.nonneg' f.integrable).mpr ?_ rw [f.support_eq] exact measure_ball_pos μ c f.rOut_pos theorem integral_normed : ∫ x, f.normed μ x āˆ‚Ī¼ = 1 := by simp_rw [ContDiffBump.normed, div_eq_mul_inv, mul_comm (f _), ← smul_eq_mul, integral_smul] exact inv_mul_cancelā‚€ f.integral_pos.ne' theorem support_normed_eq : Function.support (f.normed μ) = Metric.ball c f.rOut := by unfold ContDiffBump.normed rw [support_div, f.support_eq, support_const f.integral_pos.ne', inter_univ] theorem tsupport_normed_eq : tsupport (f.normed μ) = Metric.closedBall c f.rOut := by rw [tsupport, f.support_normed_eq, closure_ball _ f.rOut_pos.ne'] theorem hasCompactSupport_normed : HasCompactSupport (f.normed μ) := by simp only [HasCompactSupport, f.tsupport_normed_eq (μ := μ), isCompact_closedBall] theorem tendsto_support_normed_smallSets {ι} {φ : ι → ContDiffBump c} {l : Filter ι} (hφ : Tendsto (fun i => (φ i).rOut) l (š“ 0)) : Tendsto (fun i => Function.support fun x => (φ i).normed μ x) l (š“ c).smallSets := by simp_rw [NormedAddCommGroup.tendsto_nhds_zero, Real.norm_eq_abs, abs_eq_self.mpr (φ _).rOut_pos.le] at hφ rw [nhds_basis_ball.smallSets.tendsto_right_iff] refine fun ε hε ↦ (hφ ε hε).mono fun i hi ↦ ?_ rw [(φ i).support_normed_eq] exact ball_subset_ball hi.le variable (μ) theorem integral_normed_smul {X} [NormedAddCommGroup X] [NormedSpace ā„ X] [CompleteSpace X] (z : X) : ∫ x, f.normed μ x • z āˆ‚Ī¼ = z := by simp_rw [integral_smul_const, f.integral_normed (μ := μ), one_smul] end variable (μ) theorem measure_closedBall_le_integral : μ.real (closedBall c f.rIn) ≤ ∫ x, f x āˆ‚Ī¼ := by calc μ.real (closedBall c f.rIn) = ∫ x in closedBall c f.rIn, 1 āˆ‚Ī¼ := by simp _ = ∫ x in closedBall c f.rIn, f x āˆ‚Ī¼ := setIntegral_congr_fun measurableSet_closedBall (fun x hx ↦ (one_of_mem_closedBall f hx).symm) _ ≤ ∫ x, f x āˆ‚Ī¼ := setIntegral_le_integral f.integrable (Eventually.of_forall (fun x ↦ f.nonneg)) theorem normed_le_div_measure_closedBall_rIn [μ.IsOpenPosMeasure] (x : E) : f.normed μ x ≤ 1 / μ.real (closedBall c f.rIn) := by rw [normed_def] gcongr Ā· exact ENNReal.toReal_pos (measure_closedBall_pos _ _ f.rIn_pos).ne' measure_closedBall_lt_top.ne Ā· exact f.le_one Ā· exact f.measure_closedBall_le_integral μ theorem integral_le_measure_closedBall : ∫ x, f x āˆ‚Ī¼ ≤ μ.real (closedBall c f.rOut) := by calc ∫ x, f x āˆ‚Ī¼ = ∫ x in closedBall c f.rOut, f x āˆ‚Ī¼ := by apply (setIntegral_eq_integral_of_forall_compl_eq_zero (fun x hx ↦ ?_)).symm apply f.zero_of_le_dist (le_of_lt _) simpa using hx _ ≤ ∫ x in closedBall c f.rOut, 1 āˆ‚Ī¼ := by apply setIntegral_mono f.integrable.integrableOn _ (fun x ↦ f.le_one) simp [measure_closedBall_lt_top] _ = μ.real (closedBall c f.rOut) := by simp theorem measure_closedBall_div_le_integral [IsAddHaarMeasure μ] (K : ā„) (h : f.rOut ≤ K * f.rIn) : μ.real (closedBall c f.rOut) / K ^ finrank ā„ E ≤ ∫ x, f x āˆ‚Ī¼ := by have K_pos : 0 < K := by simpa [f.rIn_pos, not_lt.2 f.rIn_pos.le] using mul_pos_iff.1 (f.rOut_pos.trans_le h) apply le_trans _ (f.measure_closedBall_le_integral μ) rw [div_le_iffā‚€ (pow_pos K_pos _), addHaar_real_closedBall' _ _ f.rIn_pos.le, addHaar_real_closedBall' _ _ f.rOut_pos.le, mul_assoc, mul_comm _ (K ^ _), ← mul_assoc, ← mul_pow, mul_comm _ K] gcongr exact f.rOut_pos.le theorem normed_le_div_measure_closedBall_rOut [IsAddHaarMeasure μ] (K : ā„) (h : f.rOut ≤ K * f.rIn) (x : E) : f.normed μ x ≤ K ^ finrank ā„ E / μ.real (closedBall c f.rOut) := by have K_pos : 0 < K := by simpa [f.rIn_pos, not_lt.2 f.rIn_pos.le] using mul_pos_iff.1 (f.rOut_pos.trans_le h) have : f x / ∫ y, f y āˆ‚Ī¼ ≤ 1 / ∫ y, f y āˆ‚Ī¼ := by gcongr Ā· exact f.integral_pos.le Ā· exact f.le_one apply this.trans rw [div_le_div_iffā‚€ f.integral_pos, one_mul, ← div_le_iffā‚€' (pow_pos K_pos _)] Ā· exact f.measure_closedBall_div_le_integral μ K h Ā· exact ENNReal.toReal_pos (measure_closedBall_pos _ _ f.rOut_pos).ne' measure_closedBall_lt_top.ne end ContDiffBump
.lake/packages/mathlib/Mathlib/Analysis/Calculus/BumpFunction/Convolution.lean
import Mathlib.Analysis.Convolution import Mathlib.Analysis.Calculus.BumpFunction.FiniteDimension import Mathlib.Analysis.Calculus.BumpFunction.Normed import Mathlib.MeasureTheory.Integral.Average import Mathlib.MeasureTheory.Covering.Differentiation import Mathlib.MeasureTheory.Covering.BesicovitchVectorSpace import Mathlib.MeasureTheory.Measure.Haar.Unique /-! # Convolution with a bump function In this file we prove lemmas about convolutions `(φ.normed μ ⋆[lsmul ā„ ā„, μ] g) xā‚€`, where `φ : ContDiffBump 0` is a smooth bump function. We prove that this convolution is equal to `g xā‚€` if `g` is a constant on `Metric.ball xā‚€ φ.rOut`. We also provide estimates in the case if `g x` is close to `g xā‚€` on this ball. ## Main results - `ContDiffBump.convolution_tendsto_right_of_continuous`: Let `g` be a continuous function; let `φ i` be a family of `ContDiffBump 0` functions with. If `(φ i).rOut` tends to zero along a filter `l`, then `((φ i).normed μ ⋆[lsmul ā„ ā„, μ] g) xā‚€` tends to `g xā‚€` along the same filter. - `ContDiffBump.convolution_tendsto_right`: generalization of the above lemma. - `ContDiffBump.ae_convolution_tendsto_right_of_locallyIntegrable`: let `g` be a locally integrable function. Then the convolution of `g` with a family of bump functions with support tending to `0` converges almost everywhere to `g`. ## Keywords convolution, smooth function, bump function -/ universe uG uE' open ContinuousLinearMap Metric MeasureTheory Filter Function Measure Set open scoped Convolution Topology namespace ContDiffBump variable {G : Type uG} {E' : Type uE'} [NormedAddCommGroup E'] {g : G → E'} [MeasurableSpace G] {μ : MeasureTheory.Measure G} [NormedSpace ā„ E'] [NormedAddCommGroup G] [NormedSpace ā„ G] [CompleteSpace E'] {φ : ContDiffBump (0 : G)} {xā‚€ : G} /-- If `φ` is a bump function, compute `(φ ⋆ g) xā‚€` if `g` is constant on `Metric.ball xā‚€ φ.rOut`. -/ theorem convolution_eq_right [HasContDiffBump G] {xā‚€ : G} (hg : āˆ€ x ∈ ball xā‚€ φ.rOut, g x = g xā‚€) : (φ ⋆[lsmul ā„ ā„, μ] g : G → E') xā‚€ = integral μ φ • g xā‚€ := by simp_rw [convolution_eq_right' _ φ.support_eq.subset hg, lsmul_apply, integral_smul_const] variable [BorelSpace G] [FiniteDimensional ā„ G] /-- If `φ` is a normed bump function, compute `φ ⋆ g` if `g` is constant on `Metric.ball xā‚€ φ.rOut`. -/ theorem normed_convolution_eq_right [IsLocallyFiniteMeasure μ] [μ.IsOpenPosMeasure] {xā‚€ : G} (hg : āˆ€ x ∈ ball xā‚€ φ.rOut, g x = g xā‚€) : (φ.normed μ ⋆[lsmul ā„ ā„, μ] g : G → E') xā‚€ = g xā‚€ := by rw [convolution_eq_right' _ φ.support_normed_eq.subset hg] exact integral_normed_smul φ μ (g xā‚€) variable [μ.IsAddHaarMeasure] /-- If `φ` is a normed bump function, approximate `(φ ⋆ g) xā‚€` if `g` is near `g xā‚€` on a ball with radius `φ.rOut` around `xā‚€`. -/ theorem dist_normed_convolution_le {xā‚€ : G} {ε : ā„} (hmg : AEStronglyMeasurable g μ) (hg : āˆ€ x ∈ ball xā‚€ φ.rOut, dist (g x) (g xā‚€) ≤ ε) : dist ((φ.normed μ ⋆[lsmul ā„ ā„, μ] g : G → E') xā‚€) (g xā‚€) ≤ ε := dist_convolution_le (by simp_rw [← dist_self (g xā‚€), hg xā‚€ (mem_ball_self φ.rOut_pos)]) φ.support_normed_eq.subset φ.nonneg_normed φ.integral_normed hmg hg /-- `(φ i ⋆ g i) (k i)` tends to `zā‚€` as `i` tends to some filter `l` if * `φ` is a sequence of normed bump functions such that `(φ i).rOut` tends to `0` as `i` tends to `l`; * `g i` is `μ`-a.e. strongly measurable as `i` tends to `l`; * `g i x` tends to `zā‚€` as `(i, x)` tends to `l Ć—Ė¢ š“ xā‚€`; * `k i` tends to `xā‚€`. -/ nonrec theorem convolution_tendsto_right {ι} {φ : ι → ContDiffBump (0 : G)} {g : ι → G → E'} {k : ι → G} {xā‚€ : G} {zā‚€ : E'} {l : Filter ι} (hφ : Tendsto (fun i => (φ i).rOut) l (š“ 0)) (hig : āˆ€į¶  i in l, AEStronglyMeasurable (g i) μ) (hcg : Tendsto (uncurry g) (l Ć—Ė¢ š“ xā‚€) (š“ zā‚€)) (hk : Tendsto k l (š“ xā‚€)) : Tendsto (fun i => ((φ i).normed μ ⋆[lsmul ā„ ā„, μ] g i) (k i)) l (š“ zā‚€) := convolution_tendsto_right (Eventually.of_forall fun i => (φ i).nonneg_normed) (Eventually.of_forall fun i => (φ i).integral_normed) (tendsto_support_normed_smallSets hφ) hig hcg hk /-- Special case of `ContDiffBump.convolution_tendsto_right` where `g` is continuous, and the limit is taken only in the first function. -/ theorem convolution_tendsto_right_of_continuous {ι} {φ : ι → ContDiffBump (0 : G)} {l : Filter ι} (hφ : Tendsto (fun i => (φ i).rOut) l (š“ 0)) (hg : Continuous g) (xā‚€ : G) : Tendsto (fun i => ((φ i).normed μ ⋆[lsmul ā„ ā„, μ] g) xā‚€) l (š“ (g xā‚€)) := convolution_tendsto_right hφ (Eventually.of_forall fun _ => hg.aestronglyMeasurable) ((hg.tendsto xā‚€).comp tendsto_snd) tendsto_const_nhds /-- If a function `g` is locally integrable, then the convolution `φ i * g` converges almost everywhere to `g` if `φ i` is a sequence of bump functions with support tending to `0`, provided that the ratio between the inner and outer radii of `φ i` remains bounded. -/ theorem ae_convolution_tendsto_right_of_locallyIntegrable {ι} {φ : ι → ContDiffBump (0 : G)} {l : Filter ι} {K : ā„} (hφ : Tendsto (fun i ↦ (φ i).rOut) l (š“ 0)) (h'φ : āˆ€į¶  i in l, (φ i).rOut ≤ K * (φ i).rIn) (hg : LocallyIntegrable g μ) : āˆ€įµ xā‚€ āˆ‚Ī¼, Tendsto (fun i ↦ ((φ i).normed μ ⋆[lsmul ā„ ā„, μ] g) xā‚€) l (š“ (g xā‚€)) := by -- By Lebesgue differentiation theorem, the average of `g` on a small ball converges -- almost everywhere to the value of `g` as the radius shrinks to zero. -- We will see that this set of points satisfies the desired conclusion. filter_upwards [(Besicovitch.vitaliFamily μ).ae_tendsto_average_norm_sub hg] with xā‚€ hā‚€ simp only [convolution_eq_swap, lsmul_apply] have hφ' : Tendsto (fun i ↦ (φ i).rOut) l (š“[>] 0) := tendsto_nhdsWithin_iff.2 ⟨hφ, Eventually.of_forall (fun i ↦ (φ i).rOut_pos)⟩ have := (hā‚€.comp (Besicovitch.tendsto_filterAt μ xā‚€)).comp hφ' simp only at this apply tendsto_integral_smul_of_tendsto_average_norm_sub (K ^ (Module.finrank ā„ G)) this Ā· filter_upwards with i using hg.integrableOn_isCompact (isCompact_closedBall _ _) Ā· apply tendsto_const_nhds.congr (fun i ↦ ?_) rw [← integral_neg_eq_self] simp only [sub_neg_eq_add, integral_add_left_eq_self, integral_normed] Ā· filter_upwards with i change support ((ContDiffBump.normed (φ i) μ) ∘ (fun y ↦ xā‚€ - y)) āŠ† closedBall xā‚€ (φ i).rOut simp only [support_comp_eq_preimage, support_normed_eq] intro x hx simp only [mem_preimage, mem_ball, dist_zero_right] at hx simpa [dist_eq_norm_sub'] using hx.le Ā· filter_upwards [h'φ] with i hi x rw [abs_of_nonneg (nonneg_normed _ _), addHaar_real_closedBall_center] exact (φ i).normed_le_div_measure_closedBall_rOut _ _ hi _ end ContDiffBump
.lake/packages/mathlib/Mathlib/Analysis/Calculus/BumpFunction/Basic.lean
import Mathlib.Analysis.Calculus.ContDiff.Operations import Mathlib.Analysis.Normed.Module.FiniteDimension /-! # Infinitely smooth "bump" functions A smooth bump function is an infinitely smooth function `f : E → ā„` supported on a ball that is equal to `1` on a ball of smaller radius. These functions have many uses in real analysis. E.g., - they can be used to construct a smooth partition of unity which is a very useful tool; - they can be used to approximate a continuous function by infinitely smooth functions. There are two classes of spaces where bump functions are guaranteed to exist: inner product spaces and finite-dimensional spaces. In this file we define a typeclass `HasContDiffBump` saying that a normed space has a family of smooth bump functions with certain properties. We also define a structure `ContDiffBump` that holds the center and radii of the balls from above. An element `f : ContDiffBump c` can be coerced to a function which is an infinitely smooth function such that - `f` is equal to `1` in `Metric.closedBall c f.rIn`; - `support f = Metric.ball c f.rOut`; - `0 ≤ f x ≤ 1` for all `x`. ## Main Definitions - `ContDiffBump (c : E)`: a structure holding data needed to construct an infinitely smooth bump function. - `ContDiffBumpBase (E : Type*)`: a family of infinitely smooth bump functions that can be used to construct coercion of a `ContDiffBump (c : E)` to a function. - `HasContDiffBump (E : Type*)`: a typeclass saying that `E` has a `ContDiffBumpBase`. Two instances of this typeclass (for inner product spaces and for finite-dimensional spaces) are provided elsewhere. ## Keywords smooth function, smooth bump function -/ noncomputable section open Function Set Filter open scoped Topology Filter ContDiff variable {E X : Type*} /-- `f : ContDiffBump c`, where `c` is a point in a normed vector space, is a bundled smooth function such that - `f` is equal to `1` in `Metric.closedBall c f.rIn`; - `support f = Metric.ball c f.rOut`; - `0 ≤ f x ≤ 1` for all `x`. The structure `ContDiffBump` contains the data required to construct the function: real numbers `rIn`, `rOut`, and proofs of `0 < rIn < rOut`. The function itself is available through `CoeFun` when the space is nice enough, i.e., satisfies the `HasContDiffBump` typeclass. -/ structure ContDiffBump (c : E) where /-- real numbers `0 < rIn < rOut` -/ (rIn rOut : ā„) rIn_pos : 0 < rIn rIn_lt_rOut : rIn < rOut /-- The base function from which one will construct a family of bump functions. One could add more properties if they are useful and satisfied in the examples of inner product spaces and finite-dimensional vector spaces, notably derivative norm control in terms of `R - 1`. TODO: do we ever need `f x = 1 ↔ ‖x‖ ≤ 1`? -/ structure ContDiffBumpBase (E : Type*) [NormedAddCommGroup E] [NormedSpace ā„ E] where /-- The function underlying this family of bump functions -/ toFun : ā„ → E → ā„ mem_Icc : āˆ€ (R : ā„) (x : E), toFun R x ∈ Icc (0 : ā„) 1 symmetric : āˆ€ (R : ā„) (x : E), toFun R (-x) = toFun R x smooth : ContDiffOn ā„ āˆž (uncurry toFun) (Ioi (1 : ā„) Ć—Ė¢ (univ : Set E)) eq_one : āˆ€ R : ā„, 1 < R → āˆ€ x : E, ‖x‖ ≤ 1 → toFun R x = 1 support : āˆ€ R : ā„, 1 < R → Function.support (toFun R) = Metric.ball (0 : E) R /-- A class registering that a real vector space admits bump functions. This will be instantiated first for inner product spaces, and then for finite-dimensional normed spaces. We use a specific class instead of `Nonempty (ContDiffBumpBase E)` for performance reasons. -/ class HasContDiffBump (E : Type*) [NormedAddCommGroup E] [NormedSpace ā„ E] : Prop where out : Nonempty (ContDiffBumpBase E) /-- In a space with `C^āˆž` bump functions, register some function that will be used as a basis to construct bump functions of arbitrary size around any point. -/ def someContDiffBumpBase (E : Type*) [NormedAddCommGroup E] [NormedSpace ā„ E] [hb : HasContDiffBump E] : ContDiffBumpBase E := Nonempty.some hb.out namespace ContDiffBump theorem rOut_pos {c : E} (f : ContDiffBump c) : 0 < f.rOut := f.rIn_pos.trans f.rIn_lt_rOut theorem one_lt_rOut_div_rIn {c : E} (f : ContDiffBump c) : 1 < f.rOut / f.rIn := by rw [one_lt_div f.rIn_pos] exact f.rIn_lt_rOut instance (c : E) : Inhabited (ContDiffBump c) := ⟨⟨1, 2, zero_lt_one, one_lt_two⟩⟩ variable [NormedAddCommGroup E] [NormedSpace ā„ E] [NormedAddCommGroup X] [NormedSpace ā„ X] [HasContDiffBump E] {c : E} (f : ContDiffBump c) {x : E} {n : ā„•āˆž} /-- The function defined by `f : ContDiffBump c`. Use automatic coercion to function instead. -/ @[coe] def toFun {c : E} (f : ContDiffBump c) : E → ā„ := (someContDiffBumpBase E).toFun (f.rOut / f.rIn) ∘ fun x ↦ (f.rIn⁻¹ • (x - c)) instance : CoeFun (ContDiffBump c) fun _ => E → ā„ := ⟨toFun⟩ protected theorem apply (x : E) : f x = (someContDiffBumpBase E).toFun (f.rOut / f.rIn) (f.rIn⁻¹ • (x - c)) := rfl protected theorem sub (x : E) : f (c - x) = f (c + x) := by simp [f.apply, ContDiffBumpBase.symmetric] protected theorem neg (f : ContDiffBump (0 : E)) (x : E) : f (-x) = f x := by simp_rw [← zero_sub, f.sub, zero_add] open Metric theorem one_of_mem_closedBall (hx : x ∈ closedBall c f.rIn) : f x = 1 := by apply ContDiffBumpBase.eq_one _ _ f.one_lt_rOut_div_rIn simpa only [norm_smul, Real.norm_eq_abs, abs_inv, abs_of_nonneg f.rIn_pos.le, ← div_eq_inv_mul, div_le_one f.rIn_pos] using mem_closedBall_iff_norm.1 hx theorem nonneg : 0 ≤ f x := (ContDiffBumpBase.mem_Icc (someContDiffBumpBase E) _ _).1 /-- A version of `ContDiffBump.nonneg` with `x` explicit -/ theorem nonneg' (x : E) : 0 ≤ f x := f.nonneg theorem le_one : f x ≤ 1 := (ContDiffBumpBase.mem_Icc (someContDiffBumpBase E) _ _).2 theorem support_eq : Function.support f = Metric.ball c f.rOut := by simp only [toFun, support_comp_eq_preimage, ContDiffBumpBase.support _ _ f.one_lt_rOut_div_rIn] ext x simp only [mem_ball_iff_norm, sub_zero, norm_smul, mem_preimage, Real.norm_eq_abs, abs_inv, abs_of_pos f.rIn_pos, ← div_eq_inv_mul, div_lt_div_iff_of_pos_right f.rIn_pos] theorem tsupport_eq : tsupport f = closedBall c f.rOut := by simp_rw [tsupport, f.support_eq, closure_ball _ f.rOut_pos.ne'] theorem pos_of_mem_ball (hx : x ∈ ball c f.rOut) : 0 < f x := f.nonneg.lt_of_ne' <| by rwa [← support_eq, mem_support] at hx theorem zero_of_le_dist (hx : f.rOut ≤ dist x c) : f x = 0 := by rwa [← notMem_support, support_eq, mem_ball, not_lt] protected theorem hasCompactSupport [FiniteDimensional ā„ E] : HasCompactSupport f := by simp_rw [HasCompactSupport, f.tsupport_eq, isCompact_closedBall] theorem eventuallyEq_one_of_mem_ball (h : x ∈ ball c f.rIn) : f =į¶ [š“ x] 1 := mem_of_superset (closedBall_mem_nhds_of_mem h) fun _ ↦ f.one_of_mem_closedBall theorem eventuallyEq_one : f =į¶ [š“ c] 1 := f.eventuallyEq_one_of_mem_ball (mem_ball_self f.rIn_pos) /-- `ContDiffBump` is `š’žāæ` in all its arguments. -/ protected theorem _root_.ContDiffWithinAt.contDiffBump {c g : X → E} {s : Set X} {f : āˆ€ x, ContDiffBump (c x)} {x : X} (hc : ContDiffWithinAt ā„ n c s x) (hr : ContDiffWithinAt ā„ n (fun x => (f x).rIn) s x) (hR : ContDiffWithinAt ā„ n (fun x => (f x).rOut) s x) (hg : ContDiffWithinAt ā„ n g s x) : ContDiffWithinAt ā„ n (fun x => f x (g x)) s x := by change ContDiffWithinAt ā„ n (uncurry (someContDiffBumpBase E).toFun ∘ fun x : X => ((f x).rOut / (f x).rIn, (f x).rIn⁻¹ • (g x - c x))) s x refine (((someContDiffBumpBase E).smooth.contDiffAt ?_).of_le (mod_cast le_top)).comp_contDiffWithinAt x ?_ Ā· exact prod_mem_nhds (Ioi_mem_nhds (f x).one_lt_rOut_div_rIn) univ_mem Ā· exact (hR.div hr (f x).rIn_pos.ne').prodMk ((hr.inv (f x).rIn_pos.ne').smul (hg.sub hc)) /-- `ContDiffBump` is `š’žāæ` in all its arguments. -/ protected nonrec theorem _root_.ContDiffAt.contDiffBump {c g : X → E} {f : āˆ€ x, ContDiffBump (c x)} {x : X} (hc : ContDiffAt ā„ n c x) (hr : ContDiffAt ā„ n (fun x => (f x).rIn) x) (hR : ContDiffAt ā„ n (fun x => (f x).rOut) x) (hg : ContDiffAt ā„ n g x) : ContDiffAt ā„ n (fun x => f x (g x)) x := hc.contDiffBump hr hR hg theorem _root_.ContDiff.contDiffBump {c g : X → E} {f : āˆ€ x, ContDiffBump (c x)} (hc : ContDiff ā„ n c) (hr : ContDiff ā„ n fun x => (f x).rIn) (hR : ContDiff ā„ n fun x => (f x).rOut) (hg : ContDiff ā„ n g) : ContDiff ā„ n fun x => f x (g x) := by rw [contDiff_iff_contDiffAt] at * exact fun x => (hc x).contDiffBump (hr x) (hR x) (hg x) protected theorem contDiff : ContDiff ā„ n f := contDiff_const.contDiffBump contDiff_const contDiff_const contDiff_id protected theorem contDiffAt : ContDiffAt ā„ n f x := f.contDiff.contDiffAt protected theorem contDiffWithinAt {s : Set E} : ContDiffWithinAt ā„ n f s x := f.contDiffAt.contDiffWithinAt protected theorem continuous : Continuous f := contDiff_zero.mp f.contDiff end ContDiffBump
.lake/packages/mathlib/Mathlib/Analysis/Calculus/BumpFunction/FiniteDimension.lean
import Mathlib.Analysis.Calculus.SmoothSeries import Mathlib.Analysis.Calculus.BumpFunction.InnerProduct import Mathlib.Analysis.Convolution import Mathlib.Analysis.InnerProductSpace.EuclideanDist import Mathlib.Data.Set.Pointwise.Support import Mathlib.MeasureTheory.Measure.Haar.NormedSpace import Mathlib.MeasureTheory.Measure.Haar.Unique /-! # Bump functions in finite-dimensional vector spaces Let `E` be a finite-dimensional real normed vector space. We show that any open set `s` in `E` is exactly the support of a smooth function taking values in `[0, 1]`, in `IsOpen.exists_smooth_support_eq`. Then we use this construction to construct bump functions with nice behavior, by convolving the indicator function of `closedBall 0 1` with a function as above with `s = ball 0 D`. -/ noncomputable section open Set Metric TopologicalSpace Function Asymptotics MeasureTheory Module ContinuousLinearMap Filter MeasureTheory.Measure Bornology open scoped Pointwise Topology NNReal Convolution ContDiff variable {E : Type*} [NormedAddCommGroup E] section variable [NormedSpace ā„ E] [FiniteDimensional ā„ E] /-- If a set `s` is a neighborhood of `x`, then there exists a smooth function `f` taking values in `[0, 1]`, supported in `s` and with `f x = 1`. -/ theorem exists_smooth_tsupport_subset {s : Set E} {x : E} (hs : s ∈ š“ x) : ∃ f : E → ā„, tsupport f āŠ† s ∧ HasCompactSupport f ∧ ContDiff ā„ āˆž f ∧ range f āŠ† Icc 0 1 ∧ f x = 1 := by obtain ⟨d : ā„, d_pos : 0 < d, hd : Euclidean.closedBall x d āŠ† s⟩ := Euclidean.nhds_basis_closedBall.mem_iff.1 hs let c : ContDiffBump (toEuclidean x) := { rIn := d / 2 rOut := d rIn_pos := half_pos d_pos rIn_lt_rOut := half_lt_self d_pos } let f : E → ā„ := c ∘ toEuclidean have f_supp : f.support āŠ† Euclidean.ball x d := by intro y hy have : toEuclidean y ∈ Function.support c := by simpa only [Function.mem_support, Function.comp_apply, Ne] using hy rwa [c.support_eq] at this have f_tsupp : tsupport f āŠ† Euclidean.closedBall x d := by rw [tsupport, ← Euclidean.closure_ball _ d_pos.ne'] exact closure_mono f_supp refine ⟨f, f_tsupp.trans hd, ?_, ?_, ?_, ?_⟩ Ā· refine isCompact_of_isClosed_isBounded isClosed_closure ?_ have : IsBounded (Euclidean.closedBall x d) := Euclidean.isCompact_closedBall.isBounded refine this.subset (Euclidean.isClosed_closedBall.closure_subset_iff.2 ?_) exact f_supp.trans Euclidean.ball_subset_closedBall Ā· apply c.contDiff.comp exact ContinuousLinearEquiv.contDiff _ Ā· rintro t ⟨y, rfl⟩ exact ⟨c.nonneg, c.le_one⟩ Ā· apply c.one_of_mem_closedBall apply mem_closedBall_self exact (half_pos d_pos).le /-- Given an open set `s` in a finite-dimensional real normed vector space, there exists a smooth function with values in `[0, 1]` whose support is exactly `s`. -/ theorem IsOpen.exists_smooth_support_eq {s : Set E} (hs : IsOpen s) : ∃ f : E → ā„, f.support = s ∧ ContDiff ā„ āˆž f ∧ Set.range f āŠ† Set.Icc 0 1 := by /- For any given point `x` in `s`, one can construct a smooth function with support in `s` and nonzero at `x`. By second-countability, it follows that we may cover `s` with the supports of countably many such functions, say `g i`. Then `āˆ‘ i, r i • g i` will be the desired function if `r i` is a sequence of positive numbers tending quickly enough to zero. Indeed, this ensures that, for any `k ≤ i`, the `k`-th derivative of `r i • g i` is bounded by a prescribed (summable) sequence `u i`. From this, the summability of the series and of its successive derivatives follows. -/ rcases eq_empty_or_nonempty s with (rfl | h's) Ā· exact ⟨fun _ => 0, Function.support_zero, contDiff_const, by simp only [range_const, singleton_subset_iff, left_mem_Icc, zero_le_one]⟩ let ι := { f : E → ā„ // f.support āŠ† s ∧ HasCompactSupport f ∧ ContDiff ā„ āˆž f ∧ range f āŠ† Icc 0 1 } obtain ⟨T, T_count, hT⟩ : ∃ T : Set ι, T.Countable ∧ ā‹ƒ f ∈ T, support (f : E → ā„) = s := by have : ā‹ƒ f : ι, (f : E → ā„).support = s := by refine Subset.antisymm (iUnion_subset fun f => f.2.1) ?_ intro x hx rcases exists_smooth_tsupport_subset (hs.mem_nhds hx) with ⟨f, hf⟩ let g : ι := ⟨f, (subset_tsupport f).trans hf.1, hf.2.1, hf.2.2.1, hf.2.2.2.1⟩ have : x ∈ support (g : E → ā„) := by simp only [g, hf.2.2.2.2, mem_support, Ne, one_ne_zero, not_false_iff] exact mem_iUnion_of_mem _ this simp_rw [← this] apply isOpen_iUnion_countable rintro ⟨f, hf⟩ exact hf.2.2.1.continuous.isOpen_support obtain ⟨g0, hg⟩ : ∃ g0 : ā„• → ι, T = range g0 := by apply Countable.exists_eq_range T_count rcases eq_empty_or_nonempty T with (rfl | hT) Ā· simp only [← hT, mem_empty_iff_false, iUnion_of_empty, iUnion_empty, Set.not_nonempty_empty] at h's Ā· exact hT let g : ā„• → E → ā„ := fun n => (g0 n).1 have g_s : āˆ€ n, support (g n) āŠ† s := fun n => (g0 n).2.1 have s_g : āˆ€ x ∈ s, ∃ n, x ∈ support (g n) := fun x hx ↦ by rw [← hT] at hx obtain ⟨i, iT, hi⟩ : ∃ i ∈ T, x ∈ support (i : E → ā„) := by simpa only [mem_iUnion, exists_prop] using hx grind have g_smooth : āˆ€ n, ContDiff ā„ āˆž (g n) := fun n => (g0 n).2.2.2.1 have g_comp_supp : āˆ€ n, HasCompactSupport (g n) := fun n => (g0 n).2.2.1 have g_nonneg : āˆ€ n x, 0 ≤ g n x := fun n x => ((g0 n).2.2.2.2 (mem_range_self x)).1 obtain ⟨Γ, Ī“pos, c, Ī“c, c_lt⟩ : ∃ Ī“ : ā„• → ā„ā‰„0, (āˆ€ i : ā„•, 0 < Ī“ i) ∧ ∃ c : NNReal, HasSum Ī“ c ∧ c < 1 := NNReal.exists_pos_sum_of_countable one_ne_zero ā„• have : āˆ€ n : ā„•, ∃ r : ā„, 0 < r ∧ āˆ€ i ≤ n, āˆ€ x, ‖iteratedFDeriv ā„ i (r • g n) x‖ ≤ Ī“ n := by intro n have : āˆ€ i, ∃ R, āˆ€ x, ‖iteratedFDeriv ā„ i (fun x => g n x) x‖ ≤ R := by intro i have : BddAbove (range fun x => ‖iteratedFDeriv ā„ i (fun x : E => g n x) x‖) := by apply ((g_smooth n).continuous_iteratedFDeriv (mod_cast le_top)).norm.bddAbove_range_of_hasCompactSupport apply HasCompactSupport.comp_left _ norm_zero apply (g_comp_supp n).iteratedFDeriv rcases this with ⟨R, hR⟩ exact ⟨R, fun x => hR (mem_range_self _)⟩ choose R hR using this let M := max (((Finset.range (n + 1)).image R).max' (by simp)) 1 have Ī“npos : 0 < Ī“ n := Ī“pos n have IR : āˆ€ i ≤ n, R i ≤ M := by intro i hi refine le_trans ?_ (le_max_left _ _) apply Finset.le_max' apply Finset.mem_image_of_mem simp only [Finset.mem_range] omega refine ⟨M⁻¹ * Ī“ n, by positivity, fun i hi x => ?_⟩ calc ‖iteratedFDeriv ā„ i ((M⁻¹ * Ī“ n) • g n) x‖ = ‖(M⁻¹ * Ī“ n) • iteratedFDeriv ā„ i (g n) x‖ := by rw [iteratedFDeriv_const_smul_apply] exact (g_smooth n).contDiffAt.of_le (mod_cast le_top) _ = M⁻¹ * Ī“ n * ‖iteratedFDeriv ā„ i (g n) x‖ := by rw [norm_smul _ (iteratedFDeriv ā„ i (g n) x), Real.norm_of_nonneg]; positivity _ ≤ M⁻¹ * Ī“ n * M := by gcongr; exact (hR i x).trans (IR i hi) _ = Ī“ n := by simp [field] choose r rpos hr using this have S : āˆ€ x, Summable fun n => (r n • g n) x := fun x ↦ by refine .of_nnnorm_bounded Ī“c.summable fun n => ?_ rw [← NNReal.coe_le_coe, coe_nnnorm] simpa only [norm_iteratedFDeriv_zero] using hr n 0 (zero_le n) x refine ⟨fun x => āˆ‘' n, (r n • g n) x, ?_, ?_, ?_⟩ Ā· apply Subset.antisymm Ā· intro x hx simp only [Pi.smul_apply, Algebra.id.smul_eq_mul, mem_support, Ne] at hx contrapose! hx have : āˆ€ n, g n x = 0 := by intro n contrapose! hx exact g_s n hx simp only [this, mul_zero, tsum_zero] Ā· intro x hx obtain ⟨n, hn⟩ : ∃ n, x ∈ support (g n) := s_g x hx have I : 0 < r n * g n x := mul_pos (rpos n) (lt_of_le_of_ne (g_nonneg n x) (Ne.symm hn)) exact ne_of_gt ((S x).tsum_pos (fun i => mul_nonneg (rpos i).le (g_nonneg i x)) n I) Ā· refine contDiff_tsum_of_eventually (fun n => (g_smooth n).const_smul (r n)) (fun k _ => (NNReal.hasSum_coe.2 Ī“c).summable) ?_ intro i _ simp only [Nat.cofinite_eq_atTop, Filter.eventually_atTop] exact ⟨i, fun n hn x => hr _ _ hn _⟩ Ā· rintro - ⟨y, rfl⟩ refine ⟨tsum_nonneg fun n => mul_nonneg (rpos n).le (g_nonneg n y), le_trans ?_ c_lt.le⟩ have A : HasSum (fun n => (Ī“ n : ā„)) c := NNReal.hasSum_coe.2 Ī“c simp only [Pi.smul_apply, smul_eq_mul, NNReal.val_eq_coe, ← A.tsum_eq] apply Summable.tsum_le_tsum _ (S y) A.summable intro n apply (le_abs_self _).trans simpa only [norm_iteratedFDeriv_zero] using hr n 0 (zero_le n) y end section namespace ExistsContDiffBumpBase /-- An auxiliary function to construct partitions of unity on finite-dimensional real vector spaces. It is the characteristic function of the closed unit ball. -/ def φ : E → ā„ := (closedBall (0 : E) 1).indicator fun _ => (1 : ā„) variable [NormedSpace ā„ E] [FiniteDimensional ā„ E] section HelperDefinitions variable (E) theorem u_exists : ∃ u : E → ā„, ContDiff ā„ āˆž u ∧ (āˆ€ x, u x ∈ Icc (0 : ā„) 1) ∧ support u = ball 0 1 ∧ āˆ€ x, u (-x) = u x := by have A : IsOpen (ball (0 : E) 1) := isOpen_ball obtain ⟨f, f_support, f_smooth, f_range⟩ : ∃ f : E → ā„, f.support = ball (0 : E) 1 ∧ ContDiff ā„ āˆž f ∧ Set.range f āŠ† Set.Icc 0 1 := A.exists_smooth_support_eq have B : āˆ€ x, f x ∈ Icc (0 : ā„) 1 := fun x => f_range (mem_range_self x) refine ⟨fun x => (f x + f (-x)) / 2, ?_, ?_, ?_, ?_⟩ Ā· exact (f_smooth.add (f_smooth.comp contDiff_neg)).div_const _ Ā· intro x simp only [mem_Icc] constructor Ā· linarith [(B x).1, (B (-x)).1] Ā· linarith [(B x).2, (B (-x)).2] Ā· refine support_eq_iff.2 ⟨fun x hx => ?_, fun x hx => ?_⟩ Ā· apply ne_of_gt have : 0 < f x := by apply lt_of_le_of_ne (B x).1 (Ne.symm _) rwa [← f_support] at hx linarith [(B (-x)).1] Ā· have I1 : x āˆ‰ support f := by rwa [f_support] have I2 : -x āˆ‰ support f := by rw [f_support] simpa using hx simp only [mem_support, Classical.not_not] at I1 I2 simp only [I1, I2, add_zero, zero_div] Ā· intro x; simp only [add_comm, neg_neg] variable {E} in /-- An auxiliary function to construct partitions of unity on finite-dimensional real vector spaces, which is smooth, symmetric, and with support equal to the unit ball. -/ def u (x : E) : ā„ := Classical.choose (u_exists E) x theorem u_smooth : ContDiff ā„ āˆž (u : E → ā„) := (Classical.choose_spec (u_exists E)).1 theorem u_continuous : Continuous (u : E → ā„) := (u_smooth E).continuous theorem u_support : support (u : E → ā„) = ball 0 1 := (Classical.choose_spec (u_exists E)).2.2.1 theorem u_compact_support : HasCompactSupport (u : E → ā„) := by rw [hasCompactSupport_def, u_support, closure_ball (0 : E) one_ne_zero] exact isCompact_closedBall _ _ variable {E} theorem u_nonneg (x : E) : 0 ≤ u x := ((Classical.choose_spec (u_exists E)).2.1 x).1 theorem u_le_one (x : E) : u x ≤ 1 := ((Classical.choose_spec (u_exists E)).2.1 x).2 theorem u_neg (x : E) : u (-x) = u x := (Classical.choose_spec (u_exists E)).2.2.2 x variable [MeasurableSpace E] [BorelSpace E] local notation "μ" => MeasureTheory.Measure.addHaar variable (E) in theorem u_int_pos : 0 < ∫ x : E, u x āˆ‚Ī¼ := by refine (integral_pos_iff_support_of_nonneg u_nonneg ?_).mpr ?_ Ā· exact (u_continuous E).integrable_of_hasCompactSupport (u_compact_support E) Ā· rw [u_support]; exact measure_ball_pos _ _ zero_lt_one /-- An auxiliary function to construct partitions of unity on finite-dimensional real vector spaces, which is smooth, symmetric, with support equal to the ball of radius `D` and integral `1`. -/ def w (D : ā„) (x : E) : ā„ := ((∫ x : E, u x āˆ‚Ī¼) * |D| ^ finrank ā„ E)⁻¹ • u (D⁻¹ • x) theorem w_def (D : ā„) : (w D : E → ā„) = fun x => ((∫ x : E, u x āˆ‚Ī¼) * |D| ^ finrank ā„ E)⁻¹ • u (D⁻¹ • x) := by ext1 x; rfl theorem w_nonneg (D : ā„) (x : E) : 0 ≤ w D x := by apply mul_nonneg _ (u_nonneg _) apply inv_nonneg.2 apply mul_nonneg (u_int_pos E).le norm_cast apply pow_nonneg (abs_nonneg D) theorem w_mul_φ_nonneg (D : ā„) (x y : E) : 0 ≤ w D y * φ (x - y) := mul_nonneg (w_nonneg D y) (indicator_nonneg (by simp only [zero_le_one, imp_true_iff]) _) variable (E) -- see https://github.com/leanprover-community/mathlib4/issues/29041 set_option linter.unusedSimpArgs false in theorem w_integral {D : ā„} (Dpos : 0 < D) : ∫ x : E, w D x āˆ‚Ī¼ = 1 := by simp_rw [w, integral_smul] rw [integral_comp_inv_smul_of_nonneg μ (u : E → ā„) Dpos.le, abs_of_nonneg Dpos.le, mul_comm] simp [field, (u_int_pos E).ne'] theorem w_support {D : ā„} (Dpos : 0 < D) : support (w D : E → ā„) = ball 0 D := by have B : D • ball (0 : E) 1 = ball 0 D := by rw [smul_unitBall Dpos.ne', Real.norm_of_nonneg Dpos.le] have C : D ^ finrank ā„ E ≠ 0 := by norm_cast exact pow_ne_zero _ Dpos.ne' simp only [w_def, Algebra.id.smul_eq_mul, support_mul, support_inv, univ_inter, support_comp_inv_smulā‚€ Dpos.ne', u_support, B, support_const (u_int_pos E).ne', support_const C, abs_of_nonneg Dpos.le] theorem w_compact_support {D : ā„} (Dpos : 0 < D) : HasCompactSupport (w D : E → ā„) := by rw [hasCompactSupport_def, w_support E Dpos, closure_ball (0 : E) Dpos.ne'] exact isCompact_closedBall _ _ variable {E} /-- An auxiliary function to construct partitions of unity on finite-dimensional real vector spaces. It is the convolution between a smooth function of integral `1` supported in the ball of radius `D`, with the indicator function of the closed unit ball. Therefore, it is smooth, equal to `1` on the ball of radius `1 - D`, with support equal to the ball of radius `1 + D`. -/ def y (D : ā„) : E → ā„ := w D ⋆[lsmul ā„ ā„, μ] φ theorem y_neg (D : ā„) (x : E) : y D (-x) = y D x := by apply convolution_neg_of_neg_eq Ā· filter_upwards with x simp only [w_def, mul_inv_rev, smul_neg, u_neg, smul_eq_mul] Ā· filter_upwards with x simp only [φ, indicator, mem_closedBall, dist_zero_right, norm_neg] theorem y_eq_one_of_mem_closedBall {D : ā„} {x : E} (Dpos : 0 < D) (hx : x ∈ closedBall (0 : E) (1 - D)) : y D x = 1 := by change (w D ⋆[lsmul ā„ ā„, μ] φ) x = 1 have B : āˆ€ y : E, y ∈ ball x D → φ y = 1 := by have C : ball x D āŠ† ball 0 1 := by apply ball_subset_ball' simp only [mem_closedBall] at hx linarith only [hx] intro y hy simp only [φ, indicator, mem_closedBall, ite_eq_left_iff, not_le, zero_ne_one] intro h'y linarith only [mem_ball.1 (C hy), h'y] have Bx : φ x = 1 := B _ (mem_ball_self Dpos) have B' : āˆ€ y, y ∈ ball x D → φ y = φ x := by rw [Bx]; exact B rw [convolution_eq_right' _ (le_of_eq (w_support E Dpos)) B'] simp only [lsmul_apply, Algebra.id.smul_eq_mul, integral_mul_const, w_integral E Dpos, Bx, one_mul] theorem y_eq_zero_of_notMem_ball {D : ā„} {x : E} (Dpos : 0 < D) (hx : x āˆ‰ ball (0 : E) (1 + D)) : y D x = 0 := by change (w D ⋆[lsmul ā„ ā„, μ] φ) x = 0 have B : āˆ€ y, y ∈ ball x D → φ y = 0 := by intro y hy simp only [φ, indicator, mem_closedBall_zero_iff, ite_eq_right_iff, one_ne_zero] intro h'y have C : ball y D āŠ† ball 0 (1 + D) := by apply ball_subset_ball' rw [← dist_zero_right] at h'y linarith only [h'y] exact hx (C (mem_ball_comm.1 hy)) have Bx : φ x = 0 := B _ (mem_ball_self Dpos) have B' : āˆ€ y, y ∈ ball x D → φ y = φ x := by rw [Bx]; exact B rw [convolution_eq_right' _ (le_of_eq (w_support E Dpos)) B'] simp only [lsmul_apply, Algebra.id.smul_eq_mul, Bx, mul_zero, integral_const] @[deprecated (since := "2025-05-23")] alias y_eq_zero_of_not_mem_ball := y_eq_zero_of_notMem_ball theorem y_nonneg (D : ā„) (x : E) : 0 ≤ y D x := integral_nonneg (w_mul_φ_nonneg D x) theorem y_le_one {D : ā„} (x : E) (Dpos : 0 < D) : y D x ≤ 1 := by have A : (w D ⋆[lsmul ā„ ā„, μ] φ) x ≤ (w D ⋆[lsmul ā„ ā„, μ] 1) x := by apply convolution_mono_right_of_nonneg _ (w_nonneg D) (indicator_le_self' fun x _ => zero_le_one) fun _ => zero_le_one refine ((w_compact_support E Dpos).convolutionExists_left _ ?_ (locallyIntegrable_const (1 : ā„)) x).integrable exact continuous_const.mul ((u_continuous E).comp (continuous_id.const_smul _)) have B : (w D ⋆[lsmul ā„ ā„, μ] fun _ => (1 : ā„)) x = 1 := by simp only [convolution, mul_one, lsmul_apply, Algebra.id.smul_eq_mul, w_integral E Dpos] exact A.trans (le_of_eq B) theorem y_pos_of_mem_ball {D : ā„} {x : E} (Dpos : 0 < D) (D_lt_one : D < 1) (hx : x ∈ ball (0 : E) (1 + D)) : 0 < y D x := by simp only [mem_ball_zero_iff] at hx refine (integral_pos_iff_support_of_nonneg (w_mul_φ_nonneg D x) ?_).2 ?_ Ā· have F_comp : HasCompactSupport (w D) := w_compact_support E Dpos have B : LocallyIntegrable (φ : E → ā„) μ := (locallyIntegrable_const _).indicator measurableSet_closedBall have C : Continuous (w D : E → ā„) := continuous_const.mul ((u_continuous E).comp (continuous_id.const_smul _)) exact (F_comp.convolutionExists_left (lsmul ā„ ā„ : ā„ →L[ā„] ā„ →L[ā„] ā„) C B x).integrable Ā· set z := (D / (1 + D)) • x with hz have B : 0 < 1 + D := by linarith have C : ball z (D * (1 + D - ‖x‖) / (1 + D)) āŠ† support fun y : E => w D y * φ (x - y) := by intro y hy simp only [support_mul, w_support E Dpos] simp only [φ, mem_inter_iff, mem_support, Ne, indicator_apply_eq_zero, mem_closedBall_zero_iff, one_ne_zero, not_forall, not_false_iff, exists_prop, and_true] constructor Ā· apply ball_subset_ball' _ hy simp only [hz, norm_smul, abs_of_nonneg Dpos.le, abs_of_nonneg B.le, dist_zero_right, Real.norm_eq_abs, abs_div] field_simp linarith only Ā· have ID : ‖D / (1 + D) - 1‖ = 1 / (1 + D) := by rw [Real.norm_of_nonpos] Ā· field Ā· field_simp linarith only rw [← mem_closedBall_iff_norm'] apply closedBall_subset_closedBall' _ (ball_subset_closedBall hy) rw [← one_smul ā„ x, dist_eq_norm, hz, ← sub_smul, one_smul, norm_smul, ID] field_simp nlinarith only [hx, D_lt_one] apply lt_of_lt_of_le _ (measure_mono C) apply measure_ball_pos exact div_pos (mul_pos Dpos (by linarith only [hx])) B variable (E) theorem y_smooth : ContDiffOn ā„ āˆž (uncurry y) (Ioo (0 : ā„) 1 Ć—Ė¢ (univ : Set E)) := by have hs : IsOpen (Ioo (0 : ā„) (1 : ā„)) := isOpen_Ioo have hk : IsCompact (closedBall (0 : E) 1) := ProperSpace.isCompact_closedBall _ _ refine contDiffOn_convolution_left_with_param (lsmul ā„ ā„) hs hk ?_ ?_ ?_ Ā· rintro p x hp hx simp only [w, mul_inv_rev, Algebra.id.smul_eq_mul, mul_eq_zero, inv_eq_zero] right contrapose! hx have : p⁻¹ • x ∈ support u := mem_support.2 hx simp only [u_support, norm_smul, mem_ball_zero_iff, Real.norm_eq_abs, abs_inv, abs_of_nonneg hp.1.le, ← div_eq_inv_mul, div_lt_one hp.1] at this rw [mem_closedBall_zero_iff] exact this.le.trans hp.2.le Ā· exact (locallyIntegrable_const _).indicator measurableSet_closedBall Ā· apply ContDiffOn.mul Ā· norm_cast refine (contDiffOn_const.mul ?_).inv fun x hx => ne_of_gt (mul_pos (u_int_pos E) (pow_pos (abs_pos_of_pos hx.1.1) (finrank ā„ E))) apply ContDiffOn.pow simp_rw [← Real.norm_eq_abs] apply ContDiffOn.norm ā„ Ā· exact contDiffOn_fst Ā· intro x hx; exact ne_of_gt hx.1.1 Ā· apply (u_smooth E).comp_contDiffOn exact ContDiffOn.smul (contDiffOn_fst.inv fun x hx => ne_of_gt hx.1.1) contDiffOn_snd theorem y_support {D : ā„} (Dpos : 0 < D) (D_lt_one : D < 1) : support (y D : E → ā„) = ball (0 : E) (1 + D) := support_eq_iff.2 ⟨fun _ hx => (y_pos_of_mem_ball Dpos D_lt_one hx).ne', fun _ hx => y_eq_zero_of_notMem_ball Dpos hx⟩ variable {E} end HelperDefinitions instance (priority := 100) {E : Type*} [NormedAddCommGroup E] [NormedSpace ā„ E] [FiniteDimensional ā„ E] : HasContDiffBump E := by refine ⟨⟨?_⟩⟩ borelize E have IR : āˆ€ R : ā„, 1 < R → 0 < (R - 1) / (R + 1) := by intro R hR; apply div_pos <;> linarith exact { toFun := fun R x => if 1 < R then y ((R - 1) / (R + 1)) (((R + 1) / 2)⁻¹ • x) else 0 mem_Icc := fun R x => by simp only [mem_Icc] split_ifs with h Ā· refine ⟨y_nonneg _ _, y_le_one _ (IR R h)⟩ Ā· simp only [le_refl, zero_le_one, and_self] symmetric := fun R x => by split_ifs Ā· simp only [y_neg, smul_neg] Ā· rfl smooth := by suffices ContDiffOn ā„ āˆž (uncurry y ∘ fun p : ā„ Ɨ E => ((p.1 - 1) / (p.1 + 1), ((p.1 + 1) / 2)⁻¹ • p.2)) (Ioi 1 Ć—Ė¢ univ) by apply this.congr rintro ⟨R, x⟩ ⟨hR : 1 < R, _⟩ simp only [hR, uncurry_apply_pair, if_true, Function.comp_apply] apply (y_smooth E).comp Ā· apply ContDiffOn.prodMk Ā· refine (contDiffOn_fst.sub contDiffOn_const).div (contDiffOn_fst.add contDiffOn_const) ?_ rintro ⟨R, x⟩ ⟨hR : 1 < R, _⟩ apply ne_of_gt dsimp only linarith Ā· apply ContDiffOn.smul _ contDiffOn_snd refine ((contDiffOn_fst.add contDiffOn_const).div_const _).inv ?_ rintro ⟨R, x⟩ ⟨hR : 1 < R, _⟩ apply ne_of_gt dsimp only linarith Ā· rintro ⟨R, x⟩ ⟨hR : 1 < R, _⟩ have A : 0 < (R - 1) / (R + 1) := by apply div_pos <;> linarith have B : (R - 1) / (R + 1) < 1 := by apply (div_lt_one _).2 <;> linarith simp only [prodMk_mem_set_prod_eq, mem_Ioo, mem_univ, and_true, A, B] eq_one := fun R hR x hx => by have A : 0 < R + 1 := by linarith simp only [hR, if_true] apply y_eq_one_of_mem_closedBall (IR R hR) simp only [norm_smul, inv_div, mem_closedBall_zero_iff, Real.norm_eq_abs, abs_div, abs_two, abs_of_nonneg A.le] calc 2 / (R + 1) * ‖x‖ ≤ 2 / (R + 1) := mul_le_of_le_one_right (by positivity) hx _ = 1 - (R - 1) / (R + 1) := by field support := fun R hR => by have A : 0 < (R + 1) / 2 := by linarith have C : (R - 1) / (R + 1) < 1 := by apply (div_lt_one _).2 <;> linarith simp only [hR, if_true, support_comp_inv_smulā‚€ A.ne', y_support _ (IR R hR) C, _root_.smul_ball A.ne', Real.norm_of_nonneg A.le, smul_zero] refine congr (congr_arg ball (Eq.refl 0)) ?_ field } end ExistsContDiffBumpBase end
.lake/packages/mathlib/Mathlib/Analysis/Calculus/BumpFunction/InnerProduct.lean
import Mathlib.Analysis.Calculus.BumpFunction.Basic import Mathlib.Analysis.InnerProductSpace.Calculus import Mathlib.Analysis.SpecialFunctions.SmoothTransition /-! # Smooth bump functions in inner product spaces In this file we prove that a real inner product space has smooth bump functions, see `hasContDiffBump_of_innerProductSpace`. ## Keywords smooth function, bump function, inner product space -/ open Function Real open scoped Topology variable (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ā„ E] /-- A base bump function in an inner product space. This construction works in any space with a norm smooth away from zero but we do not have a typeclass for this. -/ noncomputable def ContDiffBumpBase.ofInnerProductSpace : ContDiffBumpBase E where toFun R x := smoothTransition ((R - ‖x‖) / (R - 1)) mem_Icc _ _ := ⟨smoothTransition.nonneg _, smoothTransition.le_one _⟩ symmetric _ _ := by simp only [norm_neg] smooth := by rintro ⟨R, x⟩ ⟨hR : 1 < R, -⟩ apply ContDiffAt.contDiffWithinAt rw [← sub_pos] at hR rcases eq_or_ne x 0 with rfl | hx Ā· have A : ContinuousAt (fun p : ā„ Ɨ E ↦ (p.1 - ‖p.2‖) / (p.1 - 1)) (R, 0) := (continuousAt_fst.sub continuousAt_snd.norm).div (continuousAt_fst.sub continuousAt_const) hR.ne' have B : āˆ€į¶  p in š“ (R, (0 : E)), 1 ≤ (p.1 - ‖p.2‖) / (p.1 - 1) := A.eventually <| le_mem_nhds <| (one_lt_div hR).2 <| sub_lt_sub_left (by simp) _ refine (contDiffAt_const (c := 1)).congr_of_eventuallyEq <| B.mono fun _ ↦ smoothTransition.one_of_one_le Ā· refine smoothTransition.contDiffAt.comp _ (ContDiffAt.div ?_ ?_ hR.ne') Ā· exact contDiffAt_fst.sub (contDiffAt_snd.norm ā„ hx) Ā· exact contDiffAt_fst.sub contDiffAt_const eq_one _ hR _ hx := smoothTransition.one_of_one_le <| (one_le_div <| sub_pos.2 hR).2 <| sub_le_sub_left hx _ support R hR := by ext x rw [mem_support, Ne, smoothTransition.zero_iff_nonpos, not_le, mem_ball_zero_iff] simp [hR] /-- Any inner product space has smooth bump functions. -/ instance (priority := 100) hasContDiffBump_of_innerProductSpace : HasContDiffBump E := ⟨⟨.ofInnerProductSpace E⟩⟩
.lake/packages/mathlib/Mathlib/Analysis/Calculus/BumpFunction/SmoothApprox.lean
import Mathlib.Analysis.Calculus.BumpFunction.Convolution import Mathlib.Analysis.Calculus.BumpFunction.FiniteDimension /-! # Density of smooth functions in the space of continuous functions In this file we prove that smooth functions are dense in the set of continuous functions from a real finite-dimensional vector space to a Banach space, see `ContinuousMap.dense_setOf_contDiff`. We also prove several unbundled versions of this statement. The heavy part of the proof is done upstream in `ContDiffBump.dist_normed_convolution_le` and `HasCompactSupport.contDiff_convolution_left`. Here we wrap these results removing measure-related arguments from the assumptions. -/ variable {E F : Type*} [NormedAddCommGroup E] [NormedSpace ā„ E] [FiniteDimensional ā„ E] [NormedAddCommGroup F] [NormedSpace ā„ F] [CompleteSpace F] {f : E → F} {ε : ā„} open scoped ContDiff unitInterval Topology open Function Set Metric MeasureTheory theorem MeasureTheory.LocallyIntegrable.exists_contDiff_dist_le_of_forall_mem_ball_dist_le [MeasurableSpace E] [BorelSpace E] {μ : Measure E} [μ.IsAddHaarMeasure] (hf : LocallyIntegrable f μ) (hε : 0 < ε) : ∃ g : E → F, ContDiff ā„ āˆž g ∧ āˆ€ a, āˆ€ Ī“, (āˆ€ x ∈ ball a ε, dist (f x) (f a) ≤ Ī“) → dist (g a) (f a) ≤ Ī“ := by set φ : ContDiffBump (0 : E) := ⟨ε / 2, ε, half_pos hε, half_lt_self hε⟩ refine ⟨_, ?_, fun a Ī“ ↦ φ.dist_normed_convolution_le hf.aestronglyMeasurable⟩ exact φ.hasCompactSupport_normed.contDiff_convolution_left _ φ.contDiff_normed hf theorem Continuous.exists_contDiff_dist_le_of_forall_mem_ball_dist_le (hf : Continuous f) (hε : 0 < ε) : ∃ g : E → F, ContDiff ā„ āˆž g ∧ āˆ€ a, āˆ€ Ī“, (āˆ€ x ∈ ball a ε, dist (f x) (f a) ≤ Ī“) → dist (g a) (f a) ≤ Ī“ := by borelize E exact (hf.locallyIntegrable (μ := .addHaar)).exists_contDiff_dist_le_of_forall_mem_ball_dist_le hε theorem UniformContinuous.exists_contDiff_dist_le (hf : UniformContinuous f) (hε : 0 < ε) : ∃ g : E → F, ContDiff ā„ āˆž g ∧ āˆ€ a, dist (g a) (f a) < ε := by rcases Metric.uniformContinuous_iff.mp hf (ε / 2) (half_pos hε) with ⟨Γ, hĪ“, hfΓ⟩ rcases hf.continuous.exists_contDiff_dist_le_of_forall_mem_ball_dist_le hĪ“ with ⟨g, hgc, hg⟩ exact ⟨g, hgc, fun a ↦ (hg a _ fun _ h ↦ (hfĪ“ h).le).trans_lt (half_lt_self hε)⟩ /-- Infinitely smooth functions are dense in the space of continuous functions. -/ theorem ContinuousMap.dense_setOf_contDiff : Dense {f : C(E, F) | ContDiff ā„ āˆž f} := by intro f rw [mem_closure_iff_nhds_basis (nhds_basis_uniformity uniformity_basis_dist.compactConvergenceUniformity)] simp only [Prod.forall, mem_setOf_eq, and_imp] intro K ε hK hε have : UniformContinuousOn f (cthickening 1 K) := hK.cthickening.uniformContinuousOn_of_continuous <| by fun_prop rcases Metric.uniformContinuousOn_iff.mp this (ε / 2) (half_pos hε) with ⟨Γ, hĪ“, hfΓ⟩ rcases (map_continuous f).exists_contDiff_dist_le_of_forall_mem_ball_dist_le (lt_min one_pos hĪ“) with ⟨g, hgc, hg⟩ refine ⟨⟨g, hgc.continuous⟩, hgc, fun x hx ↦ (hg _ _ fun y hy ↦ ?_).trans_lt (half_lt_self hε)⟩ rw [mem_ball, lt_min_iff] at hy exact hfĪ“ _ (mem_cthickening_of_dist_le _ x _ _ hx hy.1.le) _ (self_subset_cthickening _ hx) hy.2 |>.le
.lake/packages/mathlib/Mathlib/Analysis/Calculus/Deriv/Pow.lean
import Mathlib.Analysis.Calculus.FDeriv.Pow /-! # 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 `deriv_pow'`), where the result is instead `āˆ‘ i ∈ Finset.range n, f x ^ (n.pred - i) * f' * f x ^ i`. For a more detailed overview of one-dimensional derivatives in mathlib, see the module docstring of `Mathlib/Analysis/Calculus/Deriv/Basic.lean`. ## Keywords derivative, power -/ variable {š•œ š”ø : Type*} section NormedRing variable [NontriviallyNormedField š•œ] [NormedRing š”ø] variable [NormedAlgebra š•œ š”ø] {f : š•œ → š”ø} {f' : š”ø} {x : š•œ} {s : Set š•œ} nonrec theorem HasStrictDerivAt.fun_pow' (h : HasStrictDerivAt f f' x) (n : ā„•) : HasStrictDerivAt (fun x ↦ f x ^ n) (āˆ‘ i ∈ Finset.range n, f x ^ (n.pred - i) * f' * f x ^ i) x := by unfold HasStrictDerivAt convert h.pow' n ext simp nonrec theorem HasStrictDerivAt.pow' (h : HasStrictDerivAt f f' x) (n : ā„•) : HasStrictDerivAt (f ^ n) (āˆ‘ i ∈ Finset.range n, f x ^ (n.pred - i) * f' * f x ^ i) x := h.fun_pow' n nonrec theorem HasDerivWithinAt.fun_pow' (h : HasDerivWithinAt f f' s x) (n : ā„•) : HasDerivWithinAt (fun x ↦ f x ^ n) (āˆ‘ i ∈ Finset.range n, f x ^ (n.pred - i) * f' * f x ^ i) s x := by simpa using h.hasFDerivWithinAt.pow' n |>.hasDerivWithinAt nonrec theorem HasDerivWithinAt.pow' (h : HasDerivWithinAt f f' s x) (n : ā„•) : HasDerivWithinAt (f ^ n) (āˆ‘ i ∈ Finset.range n, f x ^ (n.pred - i) * f' * f x ^ i) s x := h.fun_pow' n theorem HasDerivAt.fun_pow' (h : HasDerivAt f f' x) (n : ā„•) : HasDerivAt (fun x ↦ f x ^ n) (āˆ‘ i ∈ Finset.range n, f x ^ (n.pred - i) * f' * f x ^ i) x := by simpa using h.hasFDerivAt.pow' n |>.hasDerivAt theorem HasDerivAt.pow' (h : HasDerivAt f f' x) (n : ā„•) : HasDerivAt (f ^ n) (āˆ‘ i ∈ Finset.range n, f x ^ (n.pred - i) * f' * f x ^ i) x := h.fun_pow' n @[simp low] theorem derivWithin_fun_pow' (h : DifferentiableWithinAt š•œ f s x) (n : ā„•) : derivWithin (fun x => f x ^ n) s x = āˆ‘ i ∈ Finset.range n, f x ^ (n.pred - i) * derivWithin f s x * f x ^ i := by by_cases hsx : UniqueDiffWithinAt š•œ s x Ā· exact (h.hasDerivWithinAt.pow' n).derivWithin hsx Ā· simp [derivWithin_zero_of_not_uniqueDiffWithinAt hsx] @[simp low] theorem derivWithin_pow' (h : DifferentiableWithinAt š•œ f s x) (n : ā„•) : derivWithin (f ^ n) s x = āˆ‘ i ∈ Finset.range n, f x ^ (n.pred - i) * derivWithin f s x * f x ^ i := derivWithin_fun_pow' h n @[simp low] theorem deriv_fun_pow' (h : DifferentiableAt š•œ f x) (n : ā„•) : deriv (fun x => f x ^ n) x = āˆ‘ i ∈ Finset.range n, f x ^ (n.pred - i) * deriv f x * f x ^ i := (h.hasDerivAt.pow' n).deriv @[simp low] theorem deriv_pow' (h : DifferentiableAt š•œ f x) (n : ā„•) : deriv (f ^ n) x = āˆ‘ i ∈ Finset.range n, f x ^ (n.pred - i) * deriv f x * f x ^ i := deriv_fun_pow' h n end NormedRing section NormedCommRing variable [NontriviallyNormedField š•œ] [NormedCommRing š”ø] variable [NormedAlgebra š•œ š”ø] {f : š•œ → š”ø} {f' : š”ø} {x : š•œ} {s : Set š•œ} open scoped RightActions nonrec theorem HasStrictDerivAt.fun_pow (h : HasStrictDerivAt f f' x) (n : ā„•) : HasStrictDerivAt (fun x ↦ f x ^ n) (n * f x ^ (n - 1) * f') x := by unfold HasStrictDerivAt convert h.pow n ext simp [mul_assoc] nonrec theorem HasStrictDerivAt.pow (h : HasStrictDerivAt f f' x) (n : ā„•) : HasStrictDerivAt (f ^ n) (n * f x ^ (n - 1) * f') x := h.fun_pow n nonrec theorem HasDerivWithinAt.fun_pow (h : HasDerivWithinAt f f' s x) (n : ā„•) : HasDerivWithinAt (fun x ↦ f x ^ n) (n * f x ^ (n - 1) * f') s x := by simpa using h.hasFDerivWithinAt.pow n |>.hasDerivWithinAt nonrec theorem HasDerivWithinAt.pow (h : HasDerivWithinAt f f' s x) (n : ā„•) : HasDerivWithinAt (f ^ n) (n * f x ^ (n - 1) * f') s x := h.fun_pow n theorem HasDerivAt.fun_pow (h : HasDerivAt f f' x) (n : ā„•) : HasDerivAt (fun x ↦ f x ^ n) (n * f x ^ (n - 1) * f') x := by simpa using h.hasFDerivAt.pow n |>.hasDerivAt theorem HasDerivAt.pow (h : HasDerivAt f f' x) (n : ā„•) : HasDerivAt (f ^ n) (n * f x ^ (n - 1) * f') x := h.fun_pow n @[simp] theorem derivWithin_fun_pow (h : DifferentiableWithinAt š•œ f s x) (n : ā„•) : derivWithin (fun x => f x ^ n) s x = n * f x ^ (n - 1) * derivWithin f s x := by by_cases hsx : UniqueDiffWithinAt š•œ s x Ā· exact (h.hasDerivWithinAt.pow n).derivWithin hsx Ā· simp [derivWithin_zero_of_not_uniqueDiffWithinAt hsx] @[simp] theorem derivWithin_pow (h : DifferentiableWithinAt š•œ f s x) (n : ā„•) : derivWithin (f ^ n) s x = n * f x ^ (n - 1) * derivWithin f s x := derivWithin_fun_pow h n @[simp] theorem deriv_fun_pow (h : DifferentiableAt š•œ f x) (n : ā„•) : deriv (fun x => f x ^ n) x = n * f x ^ (n - 1) * deriv f x := (h.hasDerivAt.pow n).deriv @[simp] theorem deriv_pow (h : DifferentiableAt š•œ f x) (n : ā„•) : deriv (f ^ n) x = n * f x ^ (n - 1) * deriv f x := deriv_fun_pow h n end NormedCommRing section NontriviallyNormedField variable [NontriviallyNormedField š•œ] {x : š•œ} {s : Set š•œ} {c : š•œ → š•œ} @[deprecated deriv_fun_pow (since := "2025-07-16")] theorem deriv_fun_pow'' {c : š•œ → š•œ} (n : ā„•) (hc : DifferentiableAt š•œ c x) : deriv (fun x => c x ^ n) x = (n : š•œ) * c x ^ (n - 1) * deriv c x := deriv_fun_pow hc n @[deprecated deriv_pow (since := "2025-07-16")] theorem deriv_pow'' {c : š•œ → š•œ} (n : ā„•) (hc : DifferentiableAt š•œ c x) : deriv (c ^ n) x = (n : š•œ) * c x ^ (n - 1) * deriv c x := deriv_pow hc n theorem hasStrictDerivAt_pow (n : ā„•) (x : š•œ) : HasStrictDerivAt (fun x : š•œ ↦ x ^ n) (n * x ^ (n - 1)) x := by simpa using (hasStrictDerivAt_id x).pow n theorem hasDerivWithinAt_pow (n : ā„•) (x : š•œ) : HasDerivWithinAt (fun x : š•œ ↦ x ^ n) (n * x ^ (n - 1)) s x := by simpa using (hasDerivWithinAt_id x s).pow n theorem hasDerivAt_pow (n : ā„•) (x : š•œ) : HasDerivAt (fun x : š•œ => x ^ n) ((n : š•œ) * x ^ (n - 1)) x := by simpa using (hasStrictDerivAt_pow n x).hasDerivAt theorem derivWithin_pow_field (h : UniqueDiffWithinAt š•œ s x) (n : ā„•) : derivWithin (fun x => x ^ n) s x = (n : š•œ) * x ^ (n - 1) := by rw [derivWithin_fun_pow (differentiableWithinAt_id' (s := s)) n, derivWithin_id' _ _ h, mul_one] theorem deriv_pow_field (n : ā„•) : deriv (fun x => x ^ n) x = (n : š•œ) * x ^ (n - 1) := by simp end NontriviallyNormedField
.lake/packages/mathlib/Mathlib/Analysis/Calculus/Deriv/Inverse.lean
import Mathlib.Analysis.Calculus.Deriv.Comp import Mathlib.Analysis.Calculus.FDeriv.Equiv /-! # Inverse function theorem - the easy half In this file we prove that `g' (f x) = (f' x)⁻¹` provided that `f` is strictly differentiable at `x`, `f' x ≠ 0`, and `g` is a local left inverse of `f` that is continuous at `f x`. This is the easy half of the inverse function theorem: the harder half states that `g` exists. For a more detailed overview of one-dimensional derivatives in mathlib, see the module docstring of `Analysis/Calculus/Deriv/Basic`. ## Keywords derivative, inverse function -/ universe u v open scoped Topology open Filter Set variable {š•œ : Type u} [NontriviallyNormedField š•œ] variable {F : Type v} [NormedAddCommGroup F] [NormedSpace š•œ F] variable {f : š•œ → F} variable {f' : F} variable {s : Set š•œ} {x : š•œ} {c : F} theorem HasStrictDerivAt.hasStrictFDerivAt_equiv {f : š•œ → š•œ} {f' x : š•œ} (hf : HasStrictDerivAt f f' x) (hf' : f' ≠ 0) : HasStrictFDerivAt f (ContinuousLinearEquiv.unitsEquivAut š•œ (Units.mk0 f' hf') : š•œ →L[š•œ] š•œ) x := hf theorem HasDerivAt.hasFDerivAt_equiv {f : š•œ → š•œ} {f' x : š•œ} (hf : HasDerivAt f f' x) (hf' : f' ≠ 0) : HasFDerivAt f (ContinuousLinearEquiv.unitsEquivAut š•œ (Units.mk0 f' hf') : š•œ →L[š•œ] š•œ) x := hf /-- 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 HasStrictDerivAt.of_local_left_inverse {f g : š•œ → š•œ} {f' a : š•œ} (hg : ContinuousAt g a) (hf : HasStrictDerivAt f f' (g a)) (hf' : f' ≠ 0) (hfg : āˆ€į¶  y in š“ a, f (g y) = y) : HasStrictDerivAt g f'⁻¹ a := (hf.hasStrictFDerivAt_equiv hf').of_local_left_inverse hg hfg /-- If `f` is an open partial homeomorphism defined on a neighbourhood of `f.symm a`, and `f` has a nonzero derivative `f'` at `f.symm a` in the strict sense, then `f.symm` 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 OpenPartialHomeomorph.hasStrictDerivAt_symm (f : OpenPartialHomeomorph š•œ š•œ) {a f' : š•œ} (ha : a ∈ f.target) (hf' : f' ≠ 0) (htff' : HasStrictDerivAt f f' (f.symm a)) : HasStrictDerivAt f.symm f'⁻¹ a := htff'.of_local_left_inverse (f.symm.continuousAt ha) hf' (f.eventually_right_inverse 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`, 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 HasDerivAt.of_local_left_inverse {f g : š•œ → š•œ} {f' a : š•œ} (hg : ContinuousAt g a) (hf : HasDerivAt f f' (g a)) (hf' : f' ≠ 0) (hfg : āˆ€į¶  y in š“ a, f (g y) = y) : HasDerivAt g f'⁻¹ a := (hf.hasFDerivAt_equiv hf').of_local_left_inverse hg hfg /-- If `f` is an open partial homeomorphism defined on a neighbourhood of `f.symm a`, and `f` has a nonzero 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.hasDerivAt_symm (f : OpenPartialHomeomorph š•œ š•œ) {a f' : š•œ} (ha : a ∈ f.target) (hf' : f' ≠ 0) (htff' : HasDerivAt f f' (f.symm a)) : HasDerivAt f.symm f'⁻¹ a := htff'.of_local_left_inverse (f.symm.continuousAt ha) hf' (f.eventually_right_inverse ha) theorem HasDerivWithinAt.eventually_ne (h : HasDerivWithinAt f f' s x) (hf' : f' ≠ 0) : āˆ€į¶  z in š“[s \ {x}] x, f z ≠ c := h.hasFDerivWithinAt.eventually_ne āŸØā€–f'‖⁻¹, fun z => by simp [norm_smul]; field_simp; rfl⟩ theorem HasDerivAt.eventually_ne (h : HasDerivAt f f' x) (hf' : f' ≠ 0) : āˆ€į¶  z in š“[≠] x, f z ≠ c := by simpa only [compl_eq_univ_diff] using (hasDerivWithinAt_univ.2 h).eventually_ne hf' theorem HasDerivAt.tendsto_nhdsNE (h : HasDerivAt f f' x) (hf' : f' ≠ 0) : Tendsto f (š“[≠] x) (š“[≠] f x) := tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within _ h.continuousAt.continuousWithinAt (h.eventually_ne hf') /-- If a function is equal to a constant at a set of points that accumulates to `x` in `s`, then its derivative within `s` at `x` equals zero, either because it has derivative zero or because it isn't differentiable at this point. -/ theorem derivWithin_zero_of_frequently_const {c} (h : ∃ᶠ y in š“[s \ {x}] x, f y = c) : derivWithin f s x = 0 := by by_cases hf : DifferentiableWithinAt š•œ f s x Ā· contrapose h rw [not_frequently] exact hf.hasDerivWithinAt.eventually_ne h Ā· exact derivWithin_zero_of_not_differentiableWithinAt hf /-- If a function is equal to a constant at a set of points that accumulates to `x`, then its derivative at `x` equals zero, either because it has derivative zero or because it isn't differentiable at this point. -/ theorem deriv_zero_of_frequently_const {c} (h : ∃ᶠ y in š“[≠] x, f y = c) : deriv f x = 0 := by rw [← derivWithin_univ, derivWithin_zero_of_frequently_const] rwa [← compl_eq_univ_diff] theorem not_differentiableWithinAt_of_local_left_inverse_hasDerivWithinAt_zero {f g : š•œ → š•œ} {a : š•œ} {s t : Set š•œ} (ha : a ∈ s) (hsu : UniqueDiffWithinAt š•œ s a) (hf : HasDerivWithinAt f 0 t (g a)) (hst : MapsTo g s t) (hfg : f ∘ g =į¶ [š“[s] a] id) : ¬DifferentiableWithinAt š•œ g s a := by intro hg have := (hf.comp a hg.hasDerivWithinAt hst).congr_of_eventuallyEq_of_mem hfg.symm ha simpa using hsu.eq_deriv _ this (hasDerivWithinAt_id _ _) theorem not_differentiableAt_of_local_left_inverse_hasDerivAt_zero {f g : š•œ → š•œ} {a : š•œ} (hf : HasDerivAt f 0 (g a)) (hfg : f ∘ g =į¶ [š“ a] id) : ¬DifferentiableAt š•œ g a := by intro hg have := (hf.comp a hg.hasDerivAt).congr_of_eventuallyEq hfg.symm simpa using this.unique (hasDerivAt_id a)
.lake/packages/mathlib/Mathlib/Analysis/Calculus/Deriv/Comp.lean
import Mathlib.Analysis.Calculus.Deriv.Basic import Mathlib.Analysis.Calculus.FDeriv.Comp import Mathlib.Analysis.Calculus.FDeriv.RestrictScalars /-! # One-dimensional derivatives of compositions of functions In this file we prove the chain rule for the following cases: * `HasDerivAt.comp` etc: `f : š•œ' → š•œ'` composed with `g : š•œ → š•œ'`; * `HasDerivAt.scomp` etc: `f : š•œ' → E` composed with `g : š•œ → š•œ'`; * `HasFDerivAt.comp_hasDerivAt` etc: `f : E → F` composed with `g : š•œ → E`; Here `š•œ` is the base normed field, `E` and `F` are normed spaces over `š•œ` and `š•œ'` is an algebra over `š•œ` (e.g., `š•œ'=š•œ` or `š•œ=ā„`, `š•œ'=ā„‚`). We also give versions with the `of_eq` suffix, which require an equality proof instead of definitional equality of the different points used in the composition. These versions are often more flexible to use. For a more detailed overview of one-dimensional derivatives in mathlib, see the module docstring of `analysis/calculus/deriv/basic`. ## Keywords derivative, chain rule -/ universe u v w open scoped Topology Filter ENNReal open Filter Asymptotics Set open ContinuousLinearMap (smulRight smulRight_one_eq_iff) variable {š•œ : Type u} [NontriviallyNormedField š•œ] variable {F : Type v} [NormedAddCommGroup F] [NormedSpace š•œ F] variable {E : Type w} [NormedAddCommGroup E] [NormedSpace š•œ E] variable {f : š•œ → F} variable {f' : F} variable {x : š•œ} variable {s : Set š•œ} variable {L : Filter š•œ} section Composition /-! ### Derivative of the composition of a vector function and a scalar function We use `scomp` in lemmas on composition of vector-valued and scalar-valued functions, and `comp` in lemmas on composition of scalar-valued functions, in analogy for `smul` and `mul` (and also because the `comp` version with the shorter name will show up much more often in applications). The formula for the derivative involves `smul` in `scomp` lemmas, which can be reduced to usual multiplication in `comp` lemmas. -/ /- 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 {š•œ' : Type*} [NontriviallyNormedField š•œ'] [NormedAlgebra š•œ š•œ'] [NormedSpace š•œ' F] [IsScalarTower š•œ š•œ' F] {s' t' : Set š•œ'} {h : š•œ → š•œ'} {hā‚‚ : š•œ' → š•œ'} {h' hā‚‚' : š•œ'} {g₁ : š•œ' → F} {g₁' : F} {L' : Filter š•œ'} {y : š•œ'} (x) theorem HasDerivAtFilter.scomp (hg : HasDerivAtFilter g₁ g₁' (h x) L') (hh : HasDerivAtFilter h h' x L) (hL : Tendsto h L L') : HasDerivAtFilter (g₁ ∘ h) (h' • g₁') x L := by simpa using ((hg.restrictScalars š•œ).comp x hh hL).hasDerivAtFilter theorem HasDerivAtFilter.scomp_of_eq (hg : HasDerivAtFilter g₁ g₁' y L') (hh : HasDerivAtFilter h h' x L) (hy : y = h x) (hL : Tendsto h L L') : HasDerivAtFilter (g₁ ∘ h) (h' • g₁') x L := by rw [hy] at hg; exact hg.scomp x hh hL theorem HasDerivWithinAt.scomp_hasDerivAt (hg : HasDerivWithinAt g₁ g₁' s' (h x)) (hh : HasDerivAt h h' x) (hs : āˆ€ x, h x ∈ s') : HasDerivAt (g₁ ∘ h) (h' • g₁') x := hg.scomp x hh <| tendsto_inf.2 ⟨hh.continuousAt, tendsto_principal.2 <| Eventually.of_forall hs⟩ theorem HasDerivWithinAt.scomp_hasDerivAt_of_eq (hg : HasDerivWithinAt g₁ g₁' s' y) (hh : HasDerivAt h h' x) (hs : āˆ€ x, h x ∈ s') (hy : y = h x) : HasDerivAt (g₁ ∘ h) (h' • g₁') x := by rw [hy] at hg; exact hg.scomp_hasDerivAt x hh hs nonrec theorem HasDerivWithinAt.scomp (hg : HasDerivWithinAt g₁ g₁' t' (h x)) (hh : HasDerivWithinAt h h' s x) (hst : MapsTo h s t') : HasDerivWithinAt (g₁ ∘ h) (h' • g₁') s x := hg.scomp x hh <| hh.continuousWithinAt.tendsto_nhdsWithin hst theorem HasDerivWithinAt.scomp_of_eq (hg : HasDerivWithinAt g₁ g₁' t' y) (hh : HasDerivWithinAt h h' s x) (hst : MapsTo h s t') (hy : y = h x) : HasDerivWithinAt (g₁ ∘ h) (h' • g₁') s x := by rw [hy] at hg; exact hg.scomp x hh hst /-- The chain rule. -/ nonrec theorem HasDerivAt.scomp (hg : HasDerivAt g₁ g₁' (h x)) (hh : HasDerivAt h h' x) : HasDerivAt (g₁ ∘ h) (h' • g₁') x := hg.scomp x hh hh.continuousAt /-- The chain rule. -/ theorem HasDerivAt.scomp_of_eq (hg : HasDerivAt g₁ g₁' y) (hh : HasDerivAt h h' x) (hy : y = h x) : HasDerivAt (g₁ ∘ h) (h' • g₁') x := by rw [hy] at hg; exact hg.scomp x hh theorem HasStrictDerivAt.scomp (hg : HasStrictDerivAt g₁ g₁' (h x)) (hh : HasStrictDerivAt h h' x) : HasStrictDerivAt (g₁ ∘ h) (h' • g₁') x := by simpa using ((hg.restrictScalars š•œ).comp x hh).hasStrictDerivAt theorem HasStrictDerivAt.scomp_of_eq (hg : HasStrictDerivAt g₁ g₁' y) (hh : HasStrictDerivAt h h' x) (hy : y = h x) : HasStrictDerivAt (g₁ ∘ h) (h' • g₁') x := by rw [hy] at hg; exact hg.scomp x hh theorem HasDerivAt.scomp_hasDerivWithinAt (hg : HasDerivAt g₁ g₁' (h x)) (hh : HasDerivWithinAt h h' s x) : HasDerivWithinAt (g₁ ∘ h) (h' • g₁') s x := HasDerivWithinAt.scomp x hg.hasDerivWithinAt hh (mapsTo_univ _ _) theorem HasDerivAt.scomp_hasDerivWithinAt_of_eq (hg : HasDerivAt g₁ g₁' y) (hh : HasDerivWithinAt h h' s x) (hy : y = h x) : HasDerivWithinAt (g₁ ∘ h) (h' • g₁') s x := by rw [hy] at hg; exact hg.scomp_hasDerivWithinAt x hh theorem derivWithin.scomp (hg : DifferentiableWithinAt š•œ' g₁ t' (h x)) (hh : DifferentiableWithinAt š•œ h s x) (hs : MapsTo h s t') : derivWithin (g₁ ∘ h) s x = derivWithin h s x • derivWithin g₁ t' (h x) := by by_cases hsx : UniqueDiffWithinAt š•œ s x Ā· exact (HasDerivWithinAt.scomp x hg.hasDerivWithinAt hh.hasDerivWithinAt hs).derivWithin hsx Ā· simp [derivWithin_zero_of_not_uniqueDiffWithinAt hsx] theorem derivWithin.scomp_of_eq (hg : DifferentiableWithinAt š•œ' g₁ t' y) (hh : DifferentiableWithinAt š•œ h s x) (hs : MapsTo h s t') (hy : y = h x) : derivWithin (g₁ ∘ h) s x = derivWithin h s x • derivWithin g₁ t' (h x) := by rw [hy] at hg; exact derivWithin.scomp x hg hh hs theorem deriv.scomp (hg : DifferentiableAt š•œ' g₁ (h x)) (hh : DifferentiableAt š•œ h x) : deriv (g₁ ∘ h) x = deriv h x • deriv g₁ (h x) := (HasDerivAt.scomp x hg.hasDerivAt hh.hasDerivAt).deriv theorem deriv.scomp_of_eq (hg : DifferentiableAt š•œ' g₁ y) (hh : DifferentiableAt š•œ h x) (hy : y = h x) : deriv (g₁ ∘ h) x = deriv h x • deriv g₁ (h x) := by rw [hy] at hg; exact deriv.scomp x hg hh /-! ### Derivative of the composition of a scalar and vector functions -/ theorem HasDerivAtFilter.comp_hasFDerivAtFilter {f : E → š•œ'} {f' : E →L[š•œ] š•œ'} (x) {L'' : Filter E} (hhā‚‚ : HasDerivAtFilter hā‚‚ hā‚‚' (f x) L') (hf : HasFDerivAtFilter f f' x L'') (hL : Tendsto f L'' L') : HasFDerivAtFilter (hā‚‚ ∘ f) (hā‚‚' • f') x L'' := by convert (hhā‚‚.restrictScalars š•œ).comp x hf hL ext x simp [mul_comm] theorem HasDerivAtFilter.comp_hasFDerivAtFilter_of_eq {f : E → š•œ'} {f' : E →L[š•œ] š•œ'} (x) {L'' : Filter E} (hhā‚‚ : HasDerivAtFilter hā‚‚ hā‚‚' y L') (hf : HasFDerivAtFilter f f' x L'') (hL : Tendsto f L'' L') (hy : y = f x) : HasFDerivAtFilter (hā‚‚ ∘ f) (hā‚‚' • f') x L'' := by rw [hy] at hhā‚‚; exact hhā‚‚.comp_hasFDerivAtFilter x hf hL theorem HasStrictDerivAt.comp_hasStrictFDerivAt {f : E → š•œ'} {f' : E →L[š•œ] š•œ'} (x) (hh : HasStrictDerivAt hā‚‚ hā‚‚' (f x)) (hf : HasStrictFDerivAt f f' x) : HasStrictFDerivAt (hā‚‚ ∘ f) (hā‚‚' • f') x := by rw [HasStrictDerivAt] at hh convert (hh.restrictScalars š•œ).comp x hf ext x simp [mul_comm] theorem HasStrictDerivAt.comp_hasStrictFDerivAt_of_eq {f : E → š•œ'} {f' : E →L[š•œ] š•œ'} (x) (hh : HasStrictDerivAt hā‚‚ hā‚‚' y) (hf : HasStrictFDerivAt f f' x) (hy : y = f x) : HasStrictFDerivAt (hā‚‚ ∘ f) (hā‚‚' • f') x := by rw [hy] at hh; exact hh.comp_hasStrictFDerivAt x hf theorem HasDerivAt.comp_hasFDerivAt {f : E → š•œ'} {f' : E →L[š•œ] š•œ'} (x) (hh : HasDerivAt hā‚‚ hā‚‚' (f x)) (hf : HasFDerivAt f f' x) : HasFDerivAt (hā‚‚ ∘ f) (hā‚‚' • f') x := hh.comp_hasFDerivAtFilter x hf hf.continuousAt theorem HasDerivAt.comp_hasFDerivAt_of_eq {f : E → š•œ'} {f' : E →L[š•œ] š•œ'} (x) (hh : HasDerivAt hā‚‚ hā‚‚' y) (hf : HasFDerivAt f f' x) (hy : y = f x) : HasFDerivAt (hā‚‚ ∘ f) (hā‚‚' • f') x := by rw [hy] at hh; exact hh.comp_hasFDerivAt x hf theorem HasDerivAt.comp_hasFDerivWithinAt {f : E → š•œ'} {f' : E →L[š•œ] š•œ'} {s} (x) (hh : HasDerivAt hā‚‚ hā‚‚' (f x)) (hf : HasFDerivWithinAt f f' s x) : HasFDerivWithinAt (hā‚‚ ∘ f) (hā‚‚' • f') s x := hh.comp_hasFDerivAtFilter x hf hf.continuousWithinAt theorem HasDerivAt.comp_hasFDerivWithinAt_of_eq {f : E → š•œ'} {f' : E →L[š•œ] š•œ'} {s} (x) (hh : HasDerivAt hā‚‚ hā‚‚' y) (hf : HasFDerivWithinAt f f' s x) (hy : y = f x) : HasFDerivWithinAt (hā‚‚ ∘ f) (hā‚‚' • f') s x := by rw [hy] at hh; exact hh.comp_hasFDerivWithinAt x hf theorem HasDerivWithinAt.comp_hasFDerivWithinAt {f : E → š•œ'} {f' : E →L[š•œ] š•œ'} {s t} (x) (hh : HasDerivWithinAt hā‚‚ hā‚‚' t (f x)) (hf : HasFDerivWithinAt f f' s x) (hst : MapsTo f s t) : HasFDerivWithinAt (hā‚‚ ∘ f) (hā‚‚' • f') s x := hh.comp_hasFDerivAtFilter x hf <| hf.continuousWithinAt.tendsto_nhdsWithin hst theorem HasDerivWithinAt.comp_hasFDerivWithinAt_of_eq {f : E → š•œ'} {f' : E →L[š•œ] š•œ'} {s t} (x) (hh : HasDerivWithinAt hā‚‚ hā‚‚' t y) (hf : HasFDerivWithinAt f f' s x) (hst : MapsTo f s t) (hy : y = f x) : HasFDerivWithinAt (hā‚‚ ∘ f) (hā‚‚' • f') s x := by rw [hy] at hh; exact hh.comp_hasFDerivWithinAt x hf hst theorem HasDerivWithinAt.comp_hasFDerivAt {f : E → š•œ'} {f' : E →L[š•œ] š•œ'} {t} (x) (hh : HasDerivWithinAt hā‚‚ hā‚‚' t (f x)) (hf : HasFDerivAt f f' x) (ht : āˆ€į¶  x' in š“ x, f x' ∈ t) : HasFDerivAt (hā‚‚ ∘ f) (hā‚‚' • f') x := hh.comp_hasFDerivAtFilter x hf <| tendsto_nhdsWithin_iff.mpr ⟨hf.continuousAt, ht⟩ theorem HasDerivWithinAt.comp_hasFDerivAt_of_eq {f : E → š•œ'} {f' : E →L[š•œ] š•œ'} {t} (x) (hh : HasDerivWithinAt hā‚‚ hā‚‚' t y) (hf : HasFDerivAt f f' x) (ht : āˆ€į¶  x' in š“ x, f x' ∈ t) (hy : y = f x) : HasFDerivAt (hā‚‚ ∘ f) (hā‚‚' • f') x := by subst y; exact hh.comp_hasFDerivAt x hf ht /-! ### Derivative of the composition of two scalar functions -/ theorem HasDerivAtFilter.comp (hhā‚‚ : HasDerivAtFilter hā‚‚ hā‚‚' (h x) L') (hh : HasDerivAtFilter h h' x L) (hL : Tendsto h L L') : HasDerivAtFilter (hā‚‚ ∘ h) (hā‚‚' * h') x L := by rw [mul_comm] exact hhā‚‚.scomp x hh hL theorem HasDerivAtFilter.comp_of_eq (hhā‚‚ : HasDerivAtFilter hā‚‚ hā‚‚' y L') (hh : HasDerivAtFilter h h' x L) (hL : Tendsto h L L') (hy : y = h x) : HasDerivAtFilter (hā‚‚ ∘ h) (hā‚‚' * h') x L := by rw [hy] at hhā‚‚; exact hhā‚‚.comp x hh hL theorem HasDerivWithinAt.comp (hhā‚‚ : HasDerivWithinAt hā‚‚ hā‚‚' s' (h x)) (hh : HasDerivWithinAt h h' s x) (hst : MapsTo h s s') : HasDerivWithinAt (hā‚‚ ∘ h) (hā‚‚' * h') s x := by rw [mul_comm] exact hhā‚‚.scomp x hh hst theorem HasDerivWithinAt.comp_of_eq (hhā‚‚ : HasDerivWithinAt hā‚‚ hā‚‚' s' y) (hh : HasDerivWithinAt h h' s x) (hst : MapsTo h s s') (hy : y = h x) : HasDerivWithinAt (hā‚‚ ∘ h) (hā‚‚' * h') s x := by rw [hy] at hhā‚‚; exact hhā‚‚.comp x hh hst /-- The chain rule. Note that the function `hā‚‚` is a function on an algebra. If you are looking for the chain rule with `hā‚‚` taking values in a vector space, use `HasDerivAt.scomp`. -/ nonrec theorem HasDerivAt.comp (hhā‚‚ : HasDerivAt hā‚‚ hā‚‚' (h x)) (hh : HasDerivAt h h' x) : HasDerivAt (hā‚‚ ∘ h) (hā‚‚' * h') x := hhā‚‚.comp x hh hh.continuousAt /-- The chain rule. Note that the function `hā‚‚` is a function on an algebra. If you are looking for the chain rule with `hā‚‚` taking values in a vector space, use `HasDerivAt.scomp_of_eq`. -/ theorem HasDerivAt.comp_of_eq (hhā‚‚ : HasDerivAt hā‚‚ hā‚‚' y) (hh : HasDerivAt h h' x) (hy : y = h x) : HasDerivAt (hā‚‚ ∘ h) (hā‚‚' * h') x := by rw [hy] at hhā‚‚; exact hhā‚‚.comp x hh theorem HasStrictDerivAt.comp (hhā‚‚ : HasStrictDerivAt hā‚‚ hā‚‚' (h x)) (hh : HasStrictDerivAt h h' x) : HasStrictDerivAt (hā‚‚ ∘ h) (hā‚‚' * h') x := by rw [mul_comm] exact hhā‚‚.scomp x hh theorem HasStrictDerivAt.comp_of_eq (hhā‚‚ : HasStrictDerivAt hā‚‚ hā‚‚' y) (hh : HasStrictDerivAt h h' x) (hy : y = h x) : HasStrictDerivAt (hā‚‚ ∘ h) (hā‚‚' * h') x := by rw [hy] at hhā‚‚; exact hhā‚‚.comp x hh theorem HasDerivAt.comp_hasDerivWithinAt (hhā‚‚ : HasDerivAt hā‚‚ hā‚‚' (h x)) (hh : HasDerivWithinAt h h' s x) : HasDerivWithinAt (hā‚‚ ∘ h) (hā‚‚' * h') s x := hhā‚‚.hasDerivWithinAt.comp x hh (mapsTo_univ _ _) theorem HasDerivAt.comp_hasDerivWithinAt_of_eq (hhā‚‚ : HasDerivAt hā‚‚ hā‚‚' y) (hh : HasDerivWithinAt h h' s x) (hy : y = h x) : HasDerivWithinAt (hā‚‚ ∘ h) (hā‚‚' * h') s x := by rw [hy] at hhā‚‚; exact hhā‚‚.comp_hasDerivWithinAt x hh theorem HasDerivWithinAt.comp_hasDerivAt {t} (hhā‚‚ : HasDerivWithinAt hā‚‚ hā‚‚' t (h x)) (hh : HasDerivAt h h' x) (ht : āˆ€į¶  x' in š“ x, h x' ∈ t) : HasDerivAt (hā‚‚ ∘ h) (hā‚‚' * h') x := HasDerivAtFilter.comp x hhā‚‚ hh <| tendsto_nhdsWithin_iff.mpr ⟨hh.continuousAt, ht⟩ theorem HasDerivWithinAt.comp_hasDerivAt_of_eq {t} (hhā‚‚ : HasDerivWithinAt hā‚‚ hā‚‚' t y) (hh : HasDerivAt h h' x) (ht : āˆ€į¶  x' in š“ x, h x' ∈ t) (hy : y = h x) : HasDerivAt (hā‚‚ ∘ h) (hā‚‚' * h') x := by subst y; exact hhā‚‚.comp_hasDerivAt x hh ht theorem derivWithin_comp (hhā‚‚ : DifferentiableWithinAt š•œ' hā‚‚ s' (h x)) (hh : DifferentiableWithinAt š•œ h s x) (hs : MapsTo h s s') : derivWithin (hā‚‚ ∘ h) s x = derivWithin hā‚‚ s' (h x) * derivWithin h s x := by by_cases hsx : UniqueDiffWithinAt š•œ s x Ā· exact (hhā‚‚.hasDerivWithinAt.comp x hh.hasDerivWithinAt hs).derivWithin hsx Ā· simp [derivWithin_zero_of_not_uniqueDiffWithinAt hsx] theorem derivWithin_comp_of_eq (hhā‚‚ : DifferentiableWithinAt š•œ' hā‚‚ s' y) (hh : DifferentiableWithinAt š•œ h s x) (hs : MapsTo h s s') (hy : h x = y) : derivWithin (hā‚‚ ∘ h) s x = derivWithin hā‚‚ s' (h x) * derivWithin h s x := by subst hy; exact derivWithin_comp x hhā‚‚ hh hs theorem deriv_comp (hhā‚‚ : DifferentiableAt š•œ' hā‚‚ (h x)) (hh : DifferentiableAt š•œ h x) : deriv (hā‚‚ ∘ h) x = deriv hā‚‚ (h x) * deriv h x := (hhā‚‚.hasDerivAt.comp x hh.hasDerivAt).deriv theorem deriv_comp_of_eq (hhā‚‚ : DifferentiableAt š•œ' hā‚‚ y) (hh : DifferentiableAt š•œ h x) (hy : h x = y) : deriv (hā‚‚ ∘ h) x = deriv hā‚‚ (h x) * deriv h x := by subst hy; exact deriv_comp x hhā‚‚ hh protected nonrec theorem HasDerivAtFilter.iterate {f : š•œ → š•œ} {f' : š•œ} (hf : HasDerivAtFilter f f' x L) (hL : Tendsto f L L) (hx : f x = x) (n : ā„•) : HasDerivAtFilter f^[n] (f' ^ n) x L := by have := hf.iterate hL hx n rwa [ContinuousLinearMap.smulRight_one_pow] at this protected nonrec theorem HasDerivAt.iterate {f : š•œ → š•œ} {f' : š•œ} (hf : HasDerivAt f f' x) (hx : f x = x) (n : ā„•) : HasDerivAt f^[n] (f' ^ n) x := hf.iterate _ (have := hf.tendsto_nhds le_rfl; by rwa [hx] at this) hx n protected theorem HasDerivWithinAt.iterate {f : š•œ → š•œ} {f' : š•œ} (hf : HasDerivWithinAt f f' s x) (hx : f x = x) (hs : MapsTo f s s) (n : ā„•) : HasDerivWithinAt f^[n] (f' ^ n) s x := by have := HasFDerivWithinAt.iterate hf hx hs n rwa [ContinuousLinearMap.smulRight_one_pow] at this protected nonrec theorem HasStrictDerivAt.iterate {f : š•œ → š•œ} {f' : š•œ} (hf : HasStrictDerivAt f f' x) (hx : f x = x) (n : ā„•) : HasStrictDerivAt f^[n] (f' ^ n) x := by have := hf.iterate hx n rwa [ContinuousLinearMap.smulRight_one_pow] at this end Composition section CompositionVector /-! ### Derivative of the composition of a function between vector spaces and a function on `š•œ` -/ open ContinuousLinearMap variable {l : F → E} {l' : F →L[š•œ] E} {y : F} variable (x) /-- The composition `l ∘ f` where `l : F → E` and `f : š•œ → F`, has a derivative within a set equal to the FrĆ©chet derivative of `l` applied to the derivative of `f`. -/ theorem HasFDerivWithinAt.comp_hasDerivWithinAt {t : Set F} (hl : HasFDerivWithinAt l l' t (f x)) (hf : HasDerivWithinAt f f' s x) (hst : MapsTo f s t) : HasDerivWithinAt (l ∘ f) (l' f') s x := by simpa only [one_apply, one_smul, smulRight_apply, coe_comp', (Ā· ∘ Ā·)] using (hl.comp x hf.hasFDerivWithinAt hst).hasDerivWithinAt /-- The composition `l ∘ f` where `l : F → E` and `f : š•œ → F`, has a derivative within a set equal to the FrĆ©chet derivative of `l` applied to the derivative of `f`. -/ theorem HasFDerivWithinAt.comp_hasDerivWithinAt_of_eq {t : Set F} (hl : HasFDerivWithinAt l l' t y) (hf : HasDerivWithinAt f f' s x) (hst : MapsTo f s t) (hy : y = f x) : HasDerivWithinAt (l ∘ f) (l' f') s x := by rw [hy] at hl; exact hl.comp_hasDerivWithinAt x hf hst theorem HasFDerivWithinAt.comp_hasDerivAt {t : Set F} (hl : HasFDerivWithinAt l l' t (f x)) (hf : HasDerivAt f f' x) (ht : āˆ€į¶  x' in š“ x, f x' ∈ t) : HasDerivAt (l ∘ f) (l' f') x := by simpa only [one_apply, one_smul, smulRight_apply, coe_comp', (Ā· ∘ Ā·)] using (hl.comp_hasFDerivAt x hf.hasFDerivAt ht).hasDerivAt theorem HasFDerivWithinAt.comp_hasDerivAt_of_eq {t : Set F} (hl : HasFDerivWithinAt l l' t y) (hf : HasDerivAt f f' x) (ht : āˆ€į¶  x' in š“ x, f x' ∈ t) (hy : y = f x) : HasDerivAt (l ∘ f) (l' f') x := by subst y; exact hl.comp_hasDerivAt x hf ht theorem HasFDerivAt.comp_hasDerivWithinAt (hl : HasFDerivAt l l' (f x)) (hf : HasDerivWithinAt f f' s x) : HasDerivWithinAt (l ∘ f) (l' f') s x := hl.hasFDerivWithinAt.comp_hasDerivWithinAt x hf (mapsTo_univ _ _) theorem HasFDerivAt.comp_hasDerivWithinAt_of_eq (hl : HasFDerivAt l l' y) (hf : HasDerivWithinAt f f' s x) (hy : y = f x) : HasDerivWithinAt (l ∘ f) (l' f') s x := by rw [hy] at hl; exact hl.comp_hasDerivWithinAt x hf /-- The composition `l ∘ f` where `l : F → E` and `f : š•œ → F`, has a derivative equal to the FrĆ©chet derivative of `l` applied to the derivative of `f`. -/ theorem HasFDerivAt.comp_hasDerivAt (hl : HasFDerivAt l l' (f x)) (hf : HasDerivAt f f' x) : HasDerivAt (l ∘ f) (l' f') x := hasDerivWithinAt_univ.mp <| hl.comp_hasDerivWithinAt x hf.hasDerivWithinAt /-- The composition `l ∘ f` where `l : F → E` and `f : š•œ → F`, has a derivative equal to the FrĆ©chet derivative of `l` applied to the derivative of `f`. -/ theorem HasFDerivAt.comp_hasDerivAt_of_eq (hl : HasFDerivAt l l' y) (hf : HasDerivAt f f' x) (hy : y = f x) : HasDerivAt (l ∘ f) (l' f') x := by rw [hy] at hl; exact hl.comp_hasDerivAt x hf theorem HasStrictFDerivAt.comp_hasStrictDerivAt (hl : HasStrictFDerivAt l l' (f x)) (hf : HasStrictDerivAt f f' x) : HasStrictDerivAt (l ∘ f) (l' f') x := by simpa only [one_apply, one_smul, smulRight_apply, coe_comp', (Ā· ∘ Ā·)] using (hl.comp x hf.hasStrictFDerivAt).hasStrictDerivAt theorem HasStrictFDerivAt.comp_hasStrictDerivAt_of_eq (hl : HasStrictFDerivAt l l' y) (hf : HasStrictDerivAt f f' x) (hy : y = f x) : HasStrictDerivAt (l ∘ f) (l' f') x := by rw [hy] at hl; exact hl.comp_hasStrictDerivAt x hf theorem fderivWithin_comp_derivWithin {t : Set F} (hl : DifferentiableWithinAt š•œ l t (f x)) (hf : DifferentiableWithinAt š•œ f s x) (hs : MapsTo f s t) : derivWithin (l ∘ f) s x = (fderivWithin š•œ l t (f x) : F → E) (derivWithin f s x) := by by_cases hsx : UniqueDiffWithinAt š•œ s x Ā· exact (hl.hasFDerivWithinAt.comp_hasDerivWithinAt x hf.hasDerivWithinAt hs).derivWithin hsx Ā· simp [derivWithin_zero_of_not_uniqueDiffWithinAt hsx] theorem fderivWithin_comp_derivWithin_of_eq {t : Set F} (hl : DifferentiableWithinAt š•œ l t y) (hf : DifferentiableWithinAt š•œ f s x) (hs : MapsTo f s t) (hy : y = f x) : derivWithin (l ∘ f) s x = (fderivWithin š•œ l t (f x) : F → E) (derivWithin f s x) := by rw [hy] at hl; exact fderivWithin_comp_derivWithin x hl hf hs theorem fderiv_comp_deriv (hl : DifferentiableAt š•œ l (f x)) (hf : DifferentiableAt š•œ f x) : deriv (l ∘ f) x = (fderiv š•œ l (f x) : F → E) (deriv f x) := (hl.hasFDerivAt.comp_hasDerivAt x hf.hasDerivAt).deriv theorem fderiv_comp_deriv_of_eq (hl : DifferentiableAt š•œ l y) (hf : DifferentiableAt š•œ f x) (hy : y = f x) : deriv (l ∘ f) x = (fderiv š•œ l (f x) : F → E) (deriv f x) := by rw [hy] at hl; exact fderiv_comp_deriv x hl hf end CompositionVector
.lake/packages/mathlib/Mathlib/Analysis/Calculus/Deriv/Support.lean
import Mathlib.Analysis.Calculus.Deriv.Basic /-! # Support of the derivative of a function In this file we prove that the (topological) support of a function includes the support of its derivative. As a corollary, we show that the derivative of a function with compact support has compact support. ## Keywords derivative, support -/ universe u v variable {š•œ : Type u} [NontriviallyNormedField š•œ] variable {E : Type v} [NormedAddCommGroup E] [NormedSpace š•œ E] variable {f : š•œ → E} /-! ### Support of derivatives -/ section Support open Function theorem support_deriv_subset : support (deriv f) āŠ† tsupport f := by intro x rw [← not_imp_not] intro h2x rw [notMem_tsupport_iff_eventuallyEq] at h2x exact notMem_support.mpr (h2x.deriv_eq.trans (deriv_const x 0)) protected theorem HasCompactSupport.deriv (hf : HasCompactSupport f) : HasCompactSupport (deriv f) := hf.mono' support_deriv_subset end Support
.lake/packages/mathlib/Mathlib/Analysis/Calculus/Deriv/Add.lean
import Mathlib.Analysis.Calculus.Deriv.Basic import Mathlib.Analysis.Calculus.FDeriv.Add /-! # One-dimensional derivatives of sums etc In this file we prove formulas about derivatives of `f + g`, `-f`, `f - g`, and `āˆ‘ i, f i x` for functions from the base field to a normed space over this field. For a more detailed overview of one-dimensional derivatives in mathlib, see the module docstring of `Analysis/Calculus/Deriv/Basic`. ## Keywords derivative -/ universe u v w open scoped Topology Filter ENNReal open Asymptotics Set variable {š•œ : Type u} [NontriviallyNormedField š•œ] variable {F : Type v} [NormedAddCommGroup F] [NormedSpace š•œ F] variable {f g : š•œ → F} variable {f' g' : F} variable {x : š•œ} {s : Set š•œ} {L : Filter š•œ} section Add /-! ### Derivative of the sum of two functions -/ nonrec theorem HasDerivAtFilter.fun_add (hf : HasDerivAtFilter f f' x L) (hg : HasDerivAtFilter g g' x L) : HasDerivAtFilter (fun y ↦ f y + g y) (f' + g') x L := by simpa using (hf.add hg).hasDerivAtFilter nonrec theorem HasDerivAtFilter.add (hf : HasDerivAtFilter f f' x L) (hg : HasDerivAtFilter g g' x L) : HasDerivAtFilter (f + g) (f' + g') x L := by simpa using (hf.add hg).hasDerivAtFilter nonrec theorem HasStrictDerivAt.fun_add (hf : HasStrictDerivAt f f' x) (hg : HasStrictDerivAt g g' x) : HasStrictDerivAt (fun y ↦ f y + g y) (f' + g') x := by simpa using (hf.add hg).hasStrictDerivAt nonrec theorem HasStrictDerivAt.add (hf : HasStrictDerivAt f f' x) (hg : HasStrictDerivAt g g' x) : HasStrictDerivAt (f + g) (f' + g') x := by simpa using (hf.add hg).hasStrictDerivAt nonrec theorem HasDerivWithinAt.fun_add (hf : HasDerivWithinAt f f' s x) (hg : HasDerivWithinAt g g' s x) : HasDerivWithinAt (fun y ↦ f y + g y) (f' + g') s x := hf.add hg nonrec theorem HasDerivWithinAt.add (hf : HasDerivWithinAt f f' s x) (hg : HasDerivWithinAt g g' s x) : HasDerivWithinAt (f + g) (f' + g') s x := hf.add hg nonrec theorem HasDerivAt.fun_add (hf : HasDerivAt f f' x) (hg : HasDerivAt g g' x) : HasDerivAt (fun x ↦ f x + g x) (f' + g') x := hf.add hg nonrec theorem HasDerivAt.add (hf : HasDerivAt f f' x) (hg : HasDerivAt g g' x) : HasDerivAt (f + g) (f' + g') x := hf.add hg theorem derivWithin_fun_add (hf : DifferentiableWithinAt š•œ f s x) (hg : DifferentiableWithinAt š•œ g s x) : derivWithin (fun y ↦ f y + g y) s x = derivWithin f s x + derivWithin g s x := by by_cases hsx : UniqueDiffWithinAt š•œ s x Ā· exact (hf.hasDerivWithinAt.add hg.hasDerivWithinAt).derivWithin hsx Ā· simp [derivWithin_zero_of_not_uniqueDiffWithinAt hsx] theorem derivWithin_add (hf : DifferentiableWithinAt š•œ f s x) (hg : DifferentiableWithinAt š•œ g s x) : derivWithin (f + g) s x = derivWithin f s x + derivWithin g s x := derivWithin_fun_add hf hg @[simp] theorem deriv_fun_add (hf : DifferentiableAt š•œ f x) (hg : DifferentiableAt š•œ g x) : deriv (fun y ↦ f y + g y) x = deriv f x + deriv g x := (hf.hasDerivAt.add hg.hasDerivAt).deriv @[simp] theorem deriv_add (hf : DifferentiableAt š•œ f x) (hg : DifferentiableAt š•œ g x) : deriv (f + g) x = deriv f x + deriv g x := (hf.hasDerivAt.add hg.hasDerivAt).deriv @[simp] theorem hasDerivAtFilter_add_const_iff (c : F) : HasDerivAtFilter (f Ā· + c) f' x L ↔ HasDerivAtFilter f f' x L := hasFDerivAtFilter_add_const_iff c alias ⟨_, HasDerivAtFilter.add_const⟩ := hasDerivAtFilter_add_const_iff @[simp] theorem hasStrictDerivAt_add_const_iff (c : F) : HasStrictDerivAt (f Ā· + c) f' x ↔ HasStrictDerivAt f f' x := hasStrictFDerivAt_add_const_iff c alias ⟨_, HasStrictDerivAt.add_const⟩ := hasStrictDerivAt_add_const_iff @[simp] theorem hasDerivWithinAt_add_const_iff (c : F) : HasDerivWithinAt (f Ā· + c) f' s x ↔ HasDerivWithinAt f f' s x := hasDerivAtFilter_add_const_iff c alias ⟨_, HasDerivWithinAt.add_const⟩ := hasDerivWithinAt_add_const_iff @[simp] theorem hasDerivAt_add_const_iff (c : F) : HasDerivAt (f Ā· + c) f' x ↔ HasDerivAt f f' x := hasDerivAtFilter_add_const_iff c alias ⟨_, HasDerivAt.add_const⟩ := hasDerivAt_add_const_iff theorem derivWithin_add_const (c : F) : derivWithin (fun y ↦ f y + c) s x = derivWithin f s x := by simp only [derivWithin, fderivWithin_add_const] theorem deriv_add_const (c : F) : deriv (fun y ↦ f y + c) x = deriv f x := by simp only [deriv, fderiv_add_const] @[simp] theorem deriv_add_const' (c : F) : (deriv fun y ↦ f y + c) = deriv f := funext fun _ ↦ deriv_add_const c theorem hasDerivAtFilter_const_add_iff (c : F) : HasDerivAtFilter (c + f Ā·) f' x L ↔ HasDerivAtFilter f f' x L := hasFDerivAtFilter_const_add_iff c alias ⟨_, HasDerivAtFilter.const_add⟩ := hasDerivAtFilter_const_add_iff @[simp] theorem hasStrictDerivAt_const_add_iff (c : F) : HasStrictDerivAt (c + f Ā·) f' x ↔ HasStrictDerivAt f f' x := hasStrictFDerivAt_const_add_iff c alias ⟨_, HasStrictDerivAt.const_add⟩ := hasStrictDerivAt_const_add_iff @[simp] theorem hasDerivWithinAt_const_add_iff (c : F) : HasDerivWithinAt (c + f Ā·) f' s x ↔ HasDerivWithinAt f f' s x := hasDerivAtFilter_const_add_iff c alias ⟨_, HasDerivWithinAt.const_add⟩ := hasDerivWithinAt_const_add_iff @[simp] theorem hasDerivAt_const_add_iff (c : F) : HasDerivAt (c + f Ā·) f' x ↔ HasDerivAt f f' x := hasDerivAtFilter_const_add_iff c alias ⟨_, HasDerivAt.const_add⟩ := hasDerivAt_const_add_iff theorem derivWithin_const_add (c : F) : derivWithin (c + f Ā·) s x = derivWithin f s x := by simp only [derivWithin, fderivWithin_const_add] @[simp] theorem derivWithin_const_add_fun (c : F) : derivWithin (c + f Ā·) = derivWithin f := by ext apply derivWithin_const_add theorem deriv_const_add (c : F) : deriv (c + f Ā·) x = deriv f x := by simp only [deriv, fderiv_const_add] @[simp] theorem deriv_const_add' (c : F) : (deriv (c + f Ā·)) = deriv f := funext fun _ ↦ deriv_const_add c @[deprecated (since := "2025-10-06")] alias differentiableAt_comp_const_add := differentiableAt_comp_add_left lemma differentiableAt_comp_add_const {a b : š•œ} : DifferentiableAt š•œ (fun x ↦ f (x + b)) a ↔ DifferentiableAt š•œ f (a + b) := by grind [add_comm, differentiableAt_comp_add_left] lemma differentiableAt_iff_comp_const_add {a b : š•œ} : DifferentiableAt š•œ f a ↔ DifferentiableAt š•œ (fun x ↦ f (b + x)) (-b + a) := by simp [differentiableAt_comp_add_left] lemma differentiableAt_iff_comp_add_const {a b : š•œ} : DifferentiableAt š•œ f a ↔ DifferentiableAt š•œ (fun x ↦ f (x + b)) (a - b) := by simp [differentiableAt_comp_add_const] end Add section Sum /-! ### Derivative of a finite sum of functions -/ variable {ι : Type*} {u : Finset ι} {A : ι → š•œ → F} {A' : ι → F} theorem HasDerivAtFilter.fun_sum (h : āˆ€ i ∈ u, HasDerivAtFilter (A i) (A' i) x L) : HasDerivAtFilter (fun y ↦ āˆ‘ i ∈ u, A i y) (āˆ‘ i ∈ u, A' i) x L := by simpa using (HasFDerivAtFilter.fun_sum h).hasDerivAtFilter theorem HasDerivAtFilter.sum (h : āˆ€ i ∈ u, HasDerivAtFilter (A i) (A' i) x L) : HasDerivAtFilter (āˆ‘ i ∈ u, A i) (āˆ‘ i ∈ u, A' i) x L := by convert HasDerivAtFilter.fun_sum h simp theorem HasStrictDerivAt.fun_sum (h : āˆ€ i ∈ u, HasStrictDerivAt (A i) (A' i) x) : HasStrictDerivAt (fun y ↦ āˆ‘ i ∈ u, A i y) (āˆ‘ i ∈ u, A' i) x := by simpa using (HasStrictFDerivAt.fun_sum h).hasStrictDerivAt theorem HasStrictDerivAt.sum (h : āˆ€ i ∈ u, HasStrictDerivAt (A i) (A' i) x) : HasStrictDerivAt (āˆ‘ i ∈ u, A i) (āˆ‘ i ∈ u, A' i) x := by simpa using (HasStrictFDerivAt.sum h).hasStrictDerivAt theorem HasDerivWithinAt.fun_sum (h : āˆ€ i ∈ u, HasDerivWithinAt (A i) (A' i) s x) : HasDerivWithinAt (fun y ↦ āˆ‘ i ∈ u, A i y) (āˆ‘ i ∈ u, A' i) s x := HasDerivAtFilter.fun_sum h theorem HasDerivWithinAt.sum (h : āˆ€ i ∈ u, HasDerivWithinAt (A i) (A' i) s x) : HasDerivWithinAt (āˆ‘ i ∈ u, A i) (āˆ‘ i ∈ u, A' i) s x := HasDerivAtFilter.sum h theorem HasDerivAt.fun_sum (h : āˆ€ i ∈ u, HasDerivAt (A i) (A' i) x) : HasDerivAt (fun y ↦ āˆ‘ i ∈ u, A i y) (āˆ‘ i ∈ u, A' i) x := HasDerivAtFilter.fun_sum h theorem HasDerivAt.sum (h : āˆ€ i ∈ u, HasDerivAt (A i) (A' i) x) : HasDerivAt (āˆ‘ i ∈ u, A i) (āˆ‘ i ∈ u, A' i) x := HasDerivAtFilter.sum h theorem derivWithin_fun_sum (h : āˆ€ i ∈ u, DifferentiableWithinAt š•œ (A i) s x) : derivWithin (fun y ↦ āˆ‘ i ∈ u, A i y) s x = āˆ‘ i ∈ u, derivWithin (A i) s x := by by_cases hsx : UniqueDiffWithinAt š•œ s x Ā· exact (HasDerivWithinAt.fun_sum fun i hi ↦ (h i hi).hasDerivWithinAt).derivWithin hsx Ā· simp [derivWithin_zero_of_not_uniqueDiffWithinAt hsx] theorem derivWithin_sum (h : āˆ€ i ∈ u, DifferentiableWithinAt š•œ (A i) s x) : derivWithin (āˆ‘ i ∈ u, A i) s x = āˆ‘ i ∈ u, derivWithin (A i) s x := by by_cases hsx : UniqueDiffWithinAt š•œ s x Ā· exact (HasDerivWithinAt.sum fun i hi ↦ (h i hi).hasDerivWithinAt).derivWithin hsx Ā· simp [derivWithin_zero_of_not_uniqueDiffWithinAt hsx] @[simp] theorem deriv_fun_sum (h : āˆ€ i ∈ u, DifferentiableAt š•œ (A i) x) : deriv (fun y ↦ āˆ‘ i ∈ u, A i y) x = āˆ‘ i ∈ u, deriv (A i) x := (HasDerivAt.fun_sum fun i hi ↦ (h i hi).hasDerivAt).deriv @[simp] theorem deriv_sum (h : āˆ€ i ∈ u, DifferentiableAt š•œ (A i) x) : deriv (āˆ‘ i ∈ u, A i) x = āˆ‘ i ∈ u, deriv (A i) x := (HasDerivAt.sum fun i hi ↦ (h i hi).hasDerivAt).deriv end Sum section Neg /-! ### Derivative of the negative of a function -/ nonrec theorem HasDerivAtFilter.fun_neg (h : HasDerivAtFilter f f' x L) : HasDerivAtFilter (fun x ↦ -f x) (-f') x L := by simpa using h.neg.hasDerivAtFilter nonrec theorem HasDerivAtFilter.neg (h : HasDerivAtFilter f f' x L) : HasDerivAtFilter (-f) (-f') x L := by simpa using h.neg.hasDerivAtFilter nonrec theorem HasDerivWithinAt.fun_neg (h : HasDerivWithinAt f f' s x) : HasDerivWithinAt (fun x ↦ -f x) (-f') s x := h.neg nonrec theorem HasDerivWithinAt.neg (h : HasDerivWithinAt f f' s x) : HasDerivWithinAt (-f) (-f') s x := h.neg nonrec theorem HasDerivAt.fun_neg (h : HasDerivAt f f' x) : HasDerivAt (fun x ↦ -f x) (-f') x := h.neg nonrec theorem HasDerivAt.neg (h : HasDerivAt f f' x) : HasDerivAt (-f) (-f') x := h.neg nonrec theorem HasStrictDerivAt.fun_neg (h : HasStrictDerivAt f f' x) : HasStrictDerivAt (fun x ↦ -f x) (-f') x := by simpa using h.neg.hasStrictDerivAt nonrec theorem HasStrictDerivAt.neg (h : HasStrictDerivAt f f' x) : HasStrictDerivAt (-f) (-f') x := by simpa using h.neg.hasStrictDerivAt theorem derivWithin.fun_neg : derivWithin (fun y ↦ -f y) s x = -derivWithin f s x := by by_cases hsx : UniqueDiffWithinAt š•œ s x Ā· simp only [derivWithin, fderivWithin_fun_neg hsx, ContinuousLinearMap.neg_apply] Ā· simp [derivWithin_zero_of_not_uniqueDiffWithinAt hsx] theorem derivWithin.neg : derivWithin (-f) s x = -derivWithin f s x := derivWithin.fun_neg theorem deriv.fun_neg : deriv (fun y ↦ -f y) x = -deriv f x := by simp only [deriv, fderiv_fun_neg, ContinuousLinearMap.neg_apply] theorem deriv.neg : deriv (-f) x = -deriv f x := deriv.fun_neg @[simp] theorem deriv.fun_neg' : (deriv fun y ↦ -f y) = fun x ↦ -deriv f x := funext fun _ ↦ deriv.fun_neg @[simp] theorem deriv.neg' : (deriv (-f)) = fun x ↦ -deriv f x := deriv.fun_neg' end Neg section Neg2 /-! ### Derivative of the negation function (i.e `Neg.neg`) -/ variable (s x L) theorem hasDerivAtFilter_neg : HasDerivAtFilter Neg.neg (-1) x L := HasDerivAtFilter.neg <| hasDerivAtFilter_id _ _ theorem hasDerivWithinAt_neg : HasDerivWithinAt Neg.neg (-1) s x := hasDerivAtFilter_neg _ _ theorem hasDerivAt_neg : HasDerivAt Neg.neg (-1) x := hasDerivAtFilter_neg _ _ theorem hasDerivAt_neg' : HasDerivAt (fun x ↦ -x) (-1) x := hasDerivAtFilter_neg _ _ theorem hasStrictDerivAt_neg : HasStrictDerivAt Neg.neg (-1) x := HasStrictDerivAt.neg <| hasStrictDerivAt_id _ theorem deriv_neg : deriv Neg.neg x = -1 := HasDerivAt.deriv (hasDerivAt_neg x) @[simp] theorem deriv_neg' : deriv (Neg.neg : š•œ → š•œ) = fun _ ↦ -1 := funext deriv_neg @[simp] theorem deriv_neg'' : deriv (fun x : š•œ ↦ -x) x = -1 := deriv_neg x theorem derivWithin_neg (hxs : UniqueDiffWithinAt š•œ s x) : derivWithin Neg.neg s x = -1 := (hasDerivWithinAt_neg x s).derivWithin hxs theorem differentiable_neg : Differentiable š•œ (Neg.neg : š•œ → š•œ) := Differentiable.neg differentiable_id theorem differentiableOn_neg : DifferentiableOn š•œ (Neg.neg : š•œ → š•œ) s := DifferentiableOn.neg differentiableOn_id lemma differentiableAt_comp_neg {a : š•œ} : DifferentiableAt š•œ (fun x ↦ f (-x)) a ↔ DifferentiableAt š•œ f (-a) := by refine ⟨fun H ↦ ?_, fun H ↦ H.comp a differentiable_neg.differentiableAt⟩ convert ((neg_neg a).symm ā–ø H).comp (-a) differentiable_neg.differentiableAt ext simp only [Function.comp_apply, neg_neg] lemma differentiableAt_iff_comp_neg {a : š•œ} : DifferentiableAt š•œ f a ↔ DifferentiableAt š•œ (fun x ↦ f (-x)) (-a) := by simp_rw [← differentiableAt_comp_neg, neg_neg] end Neg2 section Sub /-! ### Derivative of the difference of two functions -/ theorem HasDerivAtFilter.fun_sub (hf : HasDerivAtFilter f f' x L) (hg : HasDerivAtFilter g g' x L) : HasDerivAtFilter (fun x ↦ f x - g x) (f' - g') x L := by simpa only [sub_eq_add_neg] using hf.add hg.neg theorem HasDerivAtFilter.sub (hf : HasDerivAtFilter f f' x L) (hg : HasDerivAtFilter g g' x L) : HasDerivAtFilter (f - g) (f' - g') x L := by simpa only [sub_eq_add_neg] using hf.add hg.neg nonrec theorem HasDerivWithinAt.fun_sub (hf : HasDerivWithinAt f f' s x) (hg : HasDerivWithinAt g g' s x) : HasDerivWithinAt (fun x ↦ f x - g x) (f' - g') s x := hf.sub hg nonrec theorem HasDerivWithinAt.sub (hf : HasDerivWithinAt f f' s x) (hg : HasDerivWithinAt g g' s x) : HasDerivWithinAt (f - g) (f' - g') s x := hf.sub hg nonrec theorem HasDerivAt.fun_sub (hf : HasDerivAt f f' x) (hg : HasDerivAt g g' x) : HasDerivAt (fun x ↦ f x - g x) (f' - g') x := hf.sub hg nonrec theorem HasDerivAt.sub (hf : HasDerivAt f f' x) (hg : HasDerivAt g g' x) : HasDerivAt (f - g) (f' - g') x := hf.sub hg theorem HasStrictDerivAt.fun_sub (hf : HasStrictDerivAt f f' x) (hg : HasStrictDerivAt g g' x) : HasStrictDerivAt (fun x ↦ f x - g x) (f' - g') x := by simpa only [sub_eq_add_neg] using hf.add hg.neg theorem HasStrictDerivAt.sub (hf : HasStrictDerivAt f f' x) (hg : HasStrictDerivAt g g' x) : HasStrictDerivAt (f - g) (f' - g') x := by simpa only [sub_eq_add_neg] using hf.add hg.neg theorem derivWithin_fun_sub (hf : DifferentiableWithinAt š•œ f s x) (hg : DifferentiableWithinAt š•œ g s x) : derivWithin (fun y ↦ f y - g y) s x = derivWithin f s x - derivWithin g s x := by simp only [sub_eq_add_neg, derivWithin_fun_add hf hg.fun_neg, derivWithin.fun_neg] theorem derivWithin_sub (hf : DifferentiableWithinAt š•œ f s x) (hg : DifferentiableWithinAt š•œ g s x) : derivWithin (f - g) s x = derivWithin f s x - derivWithin g s x := derivWithin_fun_sub hf hg @[simp] theorem deriv_fun_sub (hf : DifferentiableAt š•œ f x) (hg : DifferentiableAt š•œ g x) : deriv (fun y ↦ f y - g y) x = deriv f x - deriv g x := (hf.hasDerivAt.sub hg.hasDerivAt).deriv @[simp] theorem deriv_sub (hf : DifferentiableAt š•œ f x) (hg : DifferentiableAt š•œ g x) : deriv (f - g) x = deriv f x - deriv g x := (hf.hasDerivAt.sub hg.hasDerivAt).deriv @[simp] theorem hasDerivAtFilter_sub_const_iff (c : F) : HasDerivAtFilter (fun x ↦ f x - c) f' x L ↔ HasDerivAtFilter f f' x L := hasFDerivAtFilter_sub_const_iff c alias ⟨_, HasDerivAtFilter.sub_const⟩ := hasDerivAtFilter_sub_const_iff @[simp] theorem hasDerivWithinAt_sub_const_iff (c : F) : HasDerivWithinAt (f Ā· - c) f' s x ↔ HasDerivWithinAt f f' s x := hasDerivAtFilter_sub_const_iff c alias ⟨_, HasDerivWithinAt.sub_const⟩ := hasDerivWithinAt_sub_const_iff @[simp] theorem hasDerivAt_sub_const_iff (c : F) : HasDerivAt (f Ā· - c) f' x ↔ HasDerivAt f f' x := hasDerivAtFilter_sub_const_iff c alias ⟨_, HasDerivAt.sub_const⟩ := hasDerivAt_sub_const_iff theorem derivWithin_sub_const (c : F) : derivWithin (fun y ↦ f y - c) s x = derivWithin f s x := by simp only [derivWithin, fderivWithin_sub_const] @[simp] theorem derivWithin_sub_const_fun (c : F) : derivWithin (f Ā· - c) = derivWithin f := by ext apply derivWithin_sub_const theorem deriv_sub_const (c : F) : deriv (fun y ↦ f y - c) x = deriv f x := by simp only [deriv, fderiv_sub_const] @[simp] theorem deriv_sub_const_fun (c : F) : deriv (f Ā· - c) = deriv f := by ext apply deriv_sub_const theorem HasDerivAtFilter.const_sub (c : F) (hf : HasDerivAtFilter f f' x L) : HasDerivAtFilter (fun x ↦ c - f x) (-f') x L := by simpa only [sub_eq_add_neg] using hf.neg.const_add c nonrec theorem HasDerivWithinAt.const_sub (c : F) (hf : HasDerivWithinAt f f' s x) : HasDerivWithinAt (fun x ↦ c - f x) (-f') s x := hf.const_sub c theorem HasStrictDerivAt.const_sub (c : F) (hf : HasStrictDerivAt f f' x) : HasStrictDerivAt (fun x ↦ c - f x) (-f') x := by simpa only [sub_eq_add_neg] using hf.neg.const_add c nonrec theorem HasDerivAt.const_sub (c : F) (hf : HasDerivAt f f' x) : HasDerivAt (fun x ↦ c - f x) (-f') x := hf.const_sub c theorem derivWithin_const_sub (c : F) : derivWithin (fun y ↦ c - f y) s x = -derivWithin f s x := by simp [sub_eq_add_neg, derivWithin.fun_neg] theorem deriv_const_sub (c : F) : deriv (fun y ↦ c - f y) x = -deriv f x := by simp only [← derivWithin_univ, derivWithin_const_sub] lemma differentiableAt_comp_sub_const {a b : š•œ} : DifferentiableAt š•œ (fun x ↦ f (x - b)) a ↔ DifferentiableAt š•œ f (a - b) := by simp [sub_eq_add_neg, differentiableAt_comp_add_const] lemma differentiableAt_comp_const_sub {a b : š•œ} : DifferentiableAt š•œ (fun x ↦ f (b - x)) a ↔ DifferentiableAt š•œ f (b - a) := by refine ⟨fun H ↦ ?_, fun H ↦ H.comp a (differentiable_id.const_sub _).differentiableAt⟩ convert ((sub_sub_cancel _ a).symm ā–ø H).comp (b - a) (differentiable_id.const_sub _).differentiableAt ext simp lemma differentiableAt_iff_comp_sub_const {a b : š•œ} : DifferentiableAt š•œ f a ↔ DifferentiableAt š•œ (fun x ↦ f (x - b)) (a + b) := by simp [sub_eq_add_neg, differentiableAt_comp_add_const] lemma differentiableAt_iff_comp_const_sub {a b : š•œ} : DifferentiableAt š•œ f a ↔ DifferentiableAt š•œ (fun x ↦ f (b - x)) (b - a) := by simp [differentiableAt_comp_const_sub] end Sub
.lake/packages/mathlib/Mathlib/Analysis/Calculus/Deriv/Star.lean
import Mathlib.Analysis.Calculus.Deriv.Basic import Mathlib.Analysis.Calculus.FDeriv.Star /-! # Star operations on derivatives This file contains the usual formulas (and existence assertions) for the derivative of the star operation. 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 `HasDerivAt.conj_conj` and `DifferentiableAt.conj_conj`, showing that `conj ∘ f ∘ conj` is differentiable when `f` is (and giving a formula for its derivative). -/ universe u v w variable {š•œ : Type u} [NontriviallyNormedField š•œ] [StarRing š•œ] {F : Type v} [NormedAddCommGroup F] [NormedSpace š•œ F] [StarAddMonoid F] [StarModule š•œ F] [ContinuousStar F] {f : š•œ → F} {f' : F} {x : š•œ} /-! ### Derivative of `x ↦ star x` -/ section TrivialStar variable [TrivialStar š•œ] {s : Set š•œ} {L : Filter š•œ} protected nonrec theorem HasDerivAtFilter.star (h : HasDerivAtFilter f f' x L) : HasDerivAtFilter (fun x => star (f x)) (star f') x L := by simpa using h.star.hasDerivAtFilter protected nonrec theorem HasDerivWithinAt.star (h : HasDerivWithinAt f f' s x) : HasDerivWithinAt (fun x => star (f x)) (star f') s x := h.star protected nonrec theorem HasDerivAt.star (h : HasDerivAt f f' x) : HasDerivAt (fun x => star (f x)) (star f') x := h.star protected nonrec theorem HasStrictDerivAt.star (h : HasStrictDerivAt f f' x) : HasStrictDerivAt (fun x => star (f x)) (star f') x := by simpa using h.star.hasStrictDerivAt protected theorem derivWithin.star : derivWithin (fun y => star (f y)) s x = star (derivWithin f s x) := by by_cases hxs : UniqueDiffWithinAt š•œ s x Ā· exact DFunLike.congr_fun (fderivWithin_star hxs) _ Ā· simp [derivWithin_zero_of_not_uniqueDiffWithinAt hxs] protected theorem deriv.star : deriv (fun y => star (f y)) x = star (deriv f x) := DFunLike.congr_fun fderiv_star _ @[simp] protected theorem deriv.star' : (deriv fun y => star (f y)) = fun x => star (deriv f x) := funext fun _ => deriv.star end TrivialStar section NontrivialStar variable [NormedStarGroup š•œ] open scoped ComplexConjugate /-- If `f` has derivative `f'` at `z`, then `star ∘ f ∘ conj` has derivative `conj f'` at `conj z`. -/ lemma HasDerivAt.star_conj {f : š•œ → F} {f' : F} (hf : HasDerivAt f f' x) : HasDerivAt (star ∘ f ∘ conj) (star f') (conj x) := by rw [hasDerivAt_iff_hasFDerivAt] convert hf.hasFDerivAt.star_star ext simp /-- If `f` has derivative `f'` at `z`, then `conj ∘ f ∘ conj` has derivative `conj f'` at `conj z`. -/ lemma HasDerivAt.conj_conj {f : š•œ → š•œ} {f' : š•œ} (hf : HasDerivAt f f' x) : HasDerivAt (conj ∘ f ∘ conj) (conj f') (conj x) := hf.star_conj /-- If `f` is differentiable at `conj z`, then `conj ∘ f ∘ conj` is differentiable at `z`. -/ lemma DifferentiableAt.conj_conj {f : š•œ → š•œ} (hf : DifferentiableAt š•œ f x) : DifferentiableAt š•œ (conj ∘ f ∘ conj) (conj x) := hf.star_star end NontrivialStar
.lake/packages/mathlib/Mathlib/Analysis/Calculus/Deriv/Prod.lean
import Mathlib.Analysis.Calculus.Deriv.Basic import Mathlib.Analysis.Calculus.FDeriv.Prod /-! # Derivatives of functions taking values in product types In this file we prove lemmas about derivatives of functions `f : š•œ → E Ɨ F` and of functions `f : š•œ → (Ī  i, E i)`. For a more detailed overview of one-dimensional derivatives in mathlib, see the module docstring of `Mathlib/Analysis/Calculus/Deriv/Basic.lean`. ## Keywords derivative -/ universe u v w open Topology Filter Asymptotics Set variable {š•œ : Type u} [NontriviallyNormedField š•œ] variable {F : Type v} [NormedAddCommGroup F] [NormedSpace š•œ F] variable {f₁ : š•œ → F} {f₁' : F} {x : š•œ} {s : Set š•œ} {L : Filter š•œ} section CartesianProduct /-! ### Derivative of the Cartesian product of two functions -/ variable {G : Type w} [NormedAddCommGroup G] [NormedSpace š•œ G] variable {fā‚‚ : š•œ → G} {fā‚‚' : G} nonrec theorem HasDerivAtFilter.prodMk (hf₁ : HasDerivAtFilter f₁ f₁' x L) (hfā‚‚ : HasDerivAtFilter fā‚‚ fā‚‚' x L) : HasDerivAtFilter (fun x => (f₁ x, fā‚‚ x)) (f₁', fā‚‚') x L := hf₁.prodMk hfā‚‚ nonrec theorem HasDerivWithinAt.prodMk (hf₁ : HasDerivWithinAt f₁ f₁' s x) (hfā‚‚ : HasDerivWithinAt fā‚‚ fā‚‚' s x) : HasDerivWithinAt (fun x => (f₁ x, fā‚‚ x)) (f₁', fā‚‚') s x := hf₁.prodMk hfā‚‚ nonrec theorem HasDerivAt.prodMk (hf₁ : HasDerivAt f₁ f₁' x) (hfā‚‚ : HasDerivAt fā‚‚ fā‚‚' x) : HasDerivAt (fun x => (f₁ x, fā‚‚ x)) (f₁', fā‚‚') x := hf₁.prodMk hfā‚‚ nonrec theorem HasStrictDerivAt.prodMk (hf₁ : HasStrictDerivAt f₁ f₁' x) (hfā‚‚ : HasStrictDerivAt fā‚‚ fā‚‚' x) : HasStrictDerivAt (fun x => (f₁ x, fā‚‚ x)) (f₁', fā‚‚') x := hf₁.prodMk hfā‚‚ end CartesianProduct section Pi /-! ### Derivatives of functions `f : š•œ → Ī  i, E i` -/ variable {ι : Type*} [Fintype ι] {E' : ι → Type*} [āˆ€ i, NormedAddCommGroup (E' i)] [āˆ€ i, NormedSpace š•œ (E' i)] {φ : š•œ → āˆ€ i, E' i} {φ' : āˆ€ i, E' i} @[simp] theorem hasStrictDerivAt_pi : HasStrictDerivAt φ φ' x ↔ āˆ€ i, HasStrictDerivAt (fun x => φ x i) (φ' i) x := hasStrictFDerivAt_pi' @[simp] theorem hasDerivAtFilter_pi : HasDerivAtFilter φ φ' x L ↔ āˆ€ i, HasDerivAtFilter (fun x => φ x i) (φ' i) x L := hasFDerivAtFilter_pi' theorem hasDerivAt_pi : HasDerivAt φ φ' x ↔ āˆ€ i, HasDerivAt (fun x => φ x i) (φ' i) x := hasDerivAtFilter_pi theorem hasDerivWithinAt_pi : HasDerivWithinAt φ φ' s x ↔ āˆ€ i, HasDerivWithinAt (fun x => φ x i) (φ' i) s x := hasDerivAtFilter_pi theorem derivWithin_pi (h : āˆ€ i, DifferentiableWithinAt š•œ (fun x => φ x i) s x) : derivWithin φ s x = fun i => derivWithin (fun x => φ x i) s x := by by_cases hsx : UniqueDiffWithinAt š•œ s x Ā· exact (hasDerivWithinAt_pi.2 fun i => (h i).hasDerivWithinAt).derivWithin hsx Ā· simp only [derivWithin_zero_of_not_uniqueDiffWithinAt hsx, Pi.zero_def] theorem deriv_pi (h : āˆ€ i, DifferentiableAt š•œ (fun x => φ x i) x) : deriv φ x = fun i => deriv (fun x => φ x i) x := (hasDerivAt_pi.2 fun i => (h i).hasDerivAt).deriv end Pi /-! ### Derivatives of tuples `f : š•œ → Ī  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 {φ : š•œ → F' 0} {φs : š•œ → āˆ€ i, F' (Fin.succ i)} theorem hasStrictDerivAt_finCons {φ' : Ī  i, F' i} : HasStrictDerivAt (fun x => Fin.cons (φ x) (φs x)) φ' x ↔ HasStrictDerivAt φ (φ' 0) x ∧ HasStrictDerivAt φs (fun i => φ' i.succ) x := hasStrictFDerivAt_finCons /-- A variant of `hasStrictDerivAt_finCons` where the derivative variables are free on the RHS instead. -/ theorem hasStrictDerivAt_finCons' {φ' : F' 0} {φs' : Ī  i, F' (Fin.succ i)} : HasStrictDerivAt (fun x => Fin.cons (φ x) (φs x)) (Fin.cons φ' φs') x ↔ HasStrictDerivAt φ φ' x ∧ HasStrictDerivAt φs φs' x := hasStrictDerivAt_finCons theorem HasStrictDerivAt.finCons {φ' : F' 0} {φs' : Ī  i, F' (Fin.succ i)} (h : HasStrictDerivAt φ φ' x) (hs : HasStrictDerivAt φs φs' x) : HasStrictDerivAt (fun x => Fin.cons (φ x) (φs x)) (Fin.cons φ' φs') x := hasStrictDerivAt_finCons'.mpr ⟨h, hs⟩ theorem hasDerivAtFilter_finCons {φ' : Ī  i, F' i} {l : Filter š•œ} : HasDerivAtFilter (fun x => Fin.cons (φ x) (φs x)) φ' x l ↔ HasDerivAtFilter φ (φ' 0) x l ∧ HasDerivAtFilter φs (fun i => φ' i.succ) x l := hasFDerivAtFilter_finCons /-- A variant of `hasDerivAtFilter_finCons` where the derivative variables are free on the RHS instead. -/ theorem hasDerivAtFilter_finCons' {φ' : F' 0} {φs' : Ī  i, F' (Fin.succ i)} {l : Filter š•œ} : HasDerivAtFilter (fun x => Fin.cons (φ x) (φs x)) (Fin.cons φ' φs') x l ↔ HasDerivAtFilter φ φ' x l ∧ HasDerivAtFilter φs φs' x l := hasDerivAtFilter_finCons theorem HasDerivAtFilter.finCons {φ' : F' 0} {φs' : Ī  i, F' (Fin.succ i)} {l : Filter š•œ} (h : HasDerivAtFilter φ φ' x l) (hs : HasDerivAtFilter φs φs' x l) : HasDerivAtFilter (fun x => Fin.cons (φ x) (φs x)) (Fin.cons φ' φs') x l := hasDerivAtFilter_finCons'.mpr ⟨h, hs⟩ theorem hasDerivAt_finCons {φ' : Ī  i, F' i} : HasDerivAt (fun x => Fin.cons (φ x) (φs x)) φ' x ↔ HasDerivAt φ (φ' 0) x ∧ HasDerivAt φs (fun i => φ' i.succ) x := hasDerivAtFilter_finCons /-- A variant of `hasDerivAt_finCons` where the derivative variables are free on the RHS instead. -/ theorem hasDerivAt_finCons' {φ' : F' 0} {φs' : Ī  i, F' (Fin.succ i)} : HasDerivAt (fun x => Fin.cons (φ x) (φs x)) (Fin.cons φ' φs') x ↔ HasDerivAt φ φ' x ∧ HasDerivAt φs φs' x := hasDerivAt_finCons theorem HasDerivAt.finCons {φ' : F' 0} {φs' : Ī  i, F' (Fin.succ i)} (h : HasDerivAt φ φ' x) (hs : HasDerivAt φs φs' x) : HasDerivAt (fun x => Fin.cons (φ x) (φs x)) (Fin.cons φ' φs') x := hasDerivAt_finCons'.mpr ⟨h, hs⟩ theorem hasDerivWithinAt_finCons {φ' : Ī  i, F' i} : HasDerivWithinAt (fun x => Fin.cons (φ x) (φs x)) φ' s x ↔ HasDerivWithinAt φ (φ' 0) s x ∧ HasDerivWithinAt φs (fun i => φ' i.succ) s x := hasDerivAtFilter_finCons /-- A variant of `hasDerivWithinAt_finCons` where the derivative variables are free on the RHS instead. -/ theorem hasDerivWithinAt_finCons' {φ' : F' 0} {φs' : Ī  i, F' (Fin.succ i)} : HasDerivWithinAt (fun x => Fin.cons (φ x) (φs x)) (Fin.cons φ' φs') s x ↔ HasDerivWithinAt φ φ' s x ∧ HasDerivWithinAt φs φs' s x := hasDerivAtFilter_finCons theorem HasDerivWithinAt.finCons {φ' : F' 0} {φs' : Ī  i, F' (Fin.succ i)} (h : HasDerivWithinAt φ φ' s x) (hs : HasDerivWithinAt φs φs' s x) : HasDerivWithinAt (fun x => Fin.cons (φ x) (φs x)) (Fin.cons φ' φs') s x := hasDerivWithinAt_finCons'.mpr ⟨h, hs⟩ -- TODO: write the `Fin.cons` versions of `derivWithin_pi` and `deriv_pi` end PiFin
.lake/packages/mathlib/Mathlib/Analysis/Calculus/Deriv/AffineMap.lean
import Mathlib.Analysis.Calculus.Deriv.Add import Mathlib.Analysis.Calculus.Deriv.Linear import Mathlib.LinearAlgebra.AffineSpace.AffineMap /-! # Derivatives of affine maps In this file we prove formulas for one-dimensional derivatives of affine maps `f : š•œ ā†’įµƒ[š•œ] E`. We also specialise some of these results to `AffineMap.lineMap` because it is useful to transfer MVT from dimension 1 to a domain in higher dimension. ## TODO Add theorems about `deriv`s and `fderiv`s of `ContinuousAffineMap`s once they will be ported to Mathlib 4. ## Keywords affine map, derivative, differentiability -/ variable {š•œ : Type*} [NontriviallyNormedField š•œ] {E : Type*} [NormedAddCommGroup E] [NormedSpace š•œ E] (f : š•œ ā†’įµƒ[š•œ] E) {a b : E} {L : Filter š•œ} {s : Set š•œ} {x : š•œ} namespace AffineMap theorem hasStrictDerivAt : HasStrictDerivAt f (f.linear 1) x := by rw [f.decomp] exact f.linear.hasStrictDerivAt.add_const (f 0) theorem hasDerivAtFilter : HasDerivAtFilter f (f.linear 1) x L := by rw [f.decomp] exact f.linear.hasDerivAtFilter.add_const (f 0) theorem hasDerivWithinAt : HasDerivWithinAt f (f.linear 1) s x := f.hasDerivAtFilter theorem hasDerivAt : HasDerivAt f (f.linear 1) x := f.hasDerivAtFilter protected theorem derivWithin (hs : UniqueDiffWithinAt š•œ s x) : derivWithin f s x = f.linear 1 := f.hasDerivWithinAt.derivWithin hs @[simp] protected theorem deriv : deriv f x = f.linear 1 := f.hasDerivAt.deriv protected theorem differentiableAt : DifferentiableAt š•œ f x := f.hasDerivAt.differentiableAt protected theorem differentiable : Differentiable š•œ f := fun _ ↦ f.differentiableAt protected theorem differentiableWithinAt : DifferentiableWithinAt š•œ f s x := f.differentiableAt.differentiableWithinAt protected theorem differentiableOn : DifferentiableOn š•œ f s := fun _ _ ↦ f.differentiableWithinAt /-! ### Line map In this section we specialize some lemmas to `AffineMap.lineMap` because this map is very useful to deduce higher-dimensional lemmas from one-dimensional versions. -/ theorem hasStrictDerivAt_lineMap : HasStrictDerivAt (lineMap a b) (b - a) x := by simpa using (lineMap a b : š•œ ā†’įµƒ[š•œ] E).hasStrictDerivAt theorem hasDerivAt_lineMap : HasDerivAt (lineMap a b) (b - a) x := hasStrictDerivAt_lineMap.hasDerivAt theorem hasDerivWithinAt_lineMap : HasDerivWithinAt (lineMap a b) (b - a) s x := hasDerivAt_lineMap.hasDerivWithinAt end AffineMap
.lake/packages/mathlib/Mathlib/Analysis/Calculus/Deriv/Linear.lean
import Mathlib.Analysis.Calculus.Deriv.Basic import Mathlib.Analysis.Calculus.FDeriv.Linear /-! # Derivatives of continuous linear maps from the base field In this file we prove that `f : š•œ →L[š•œ] E` (or `f : š•œ →ₗ[š•œ] E`) has derivative `f 1`. For a more detailed overview of one-dimensional derivatives in mathlib, see the module docstring of `Analysis/Calculus/Deriv/Basic`. ## Keywords derivative, linear map -/ universe u v w open Topology Filter open Filter Asymptotics Set variable {š•œ : Type u} [NontriviallyNormedField š•œ] variable {F : Type v} [NormedAddCommGroup F] [NormedSpace š•œ F] variable {E : Type w} [NormedAddCommGroup E] [NormedSpace š•œ E] variable {x : š•œ} variable {s : Set š•œ} variable {L : Filter š•œ} section ContinuousLinearMap /-! ### Derivative of continuous linear maps -/ variable (e : š•œ →L[š•œ] F) protected theorem ContinuousLinearMap.hasDerivAtFilter : HasDerivAtFilter e (e 1) x L := e.hasFDerivAtFilter.hasDerivAtFilter protected theorem ContinuousLinearMap.hasStrictDerivAt : HasStrictDerivAt e (e 1) x := e.hasStrictFDerivAt.hasStrictDerivAt protected theorem ContinuousLinearMap.hasDerivAt : HasDerivAt e (e 1) x := e.hasDerivAtFilter protected theorem ContinuousLinearMap.hasDerivWithinAt : HasDerivWithinAt e (e 1) s x := e.hasDerivAtFilter @[simp] protected theorem ContinuousLinearMap.deriv : deriv e x = e 1 := e.hasDerivAt.deriv protected theorem ContinuousLinearMap.derivWithin (hxs : UniqueDiffWithinAt š•œ s x) : derivWithin e s x = e 1 := e.hasDerivWithinAt.derivWithin hxs end ContinuousLinearMap section LinearMap /-! ### Derivative of bundled linear maps -/ variable (e : š•œ →ₗ[š•œ] F) protected theorem LinearMap.hasDerivAtFilter : HasDerivAtFilter e (e 1) x L := e.toContinuousLinearMap₁.hasDerivAtFilter protected theorem LinearMap.hasStrictDerivAt : HasStrictDerivAt e (e 1) x := e.toContinuousLinearMap₁.hasStrictDerivAt protected theorem LinearMap.hasDerivAt : HasDerivAt e (e 1) x := e.hasDerivAtFilter protected theorem LinearMap.hasDerivWithinAt : HasDerivWithinAt e (e 1) s x := e.hasDerivAtFilter @[simp] protected theorem LinearMap.deriv : deriv e x = e 1 := e.hasDerivAt.deriv protected theorem LinearMap.derivWithin (hxs : UniqueDiffWithinAt š•œ s x) : derivWithin e s x = e 1 := e.hasDerivWithinAt.derivWithin hxs end LinearMap
.lake/packages/mathlib/Mathlib/Analysis/Calculus/Deriv/Pi.lean
import Mathlib.Analysis.Calculus.FDeriv.Pi import Mathlib.Analysis.Calculus.Deriv.Basic /-! # One-dimensional derivatives on pi-types. -/ variable {š•œ ι : Type*} [DecidableEq ι] [Fintype ι] [NontriviallyNormedField š•œ] theorem hasDerivAt_update (x : ι → š•œ) (i : ι) (y : š•œ) : HasDerivAt (Function.update x i) (Pi.single i (1 : š•œ)) y := by convert (hasFDerivAt_update x y).hasDerivAt ext z j rw [Pi.single, Function.update_apply] split_ifs with h Ā· simp [h] Ā· simp [Pi.single_eq_of_ne h] theorem hasDerivAt_single (i : ι) (y : š•œ) : HasDerivAt (Pi.single (M := fun _ ↦ š•œ) i) (Pi.single i (1 : š•œ)) y := hasDerivAt_update 0 i y theorem deriv_update (x : ι → š•œ) (i : ι) (y : š•œ) : deriv (Function.update x i) y = Pi.single i (1 : š•œ) := (hasDerivAt_update x i y).deriv theorem deriv_single (i : ι) (y : š•œ) : deriv (Pi.single (M := fun _ ↦ š•œ) i) y = Pi.single i (1 : š•œ) := deriv_update 0 i y
.lake/packages/mathlib/Mathlib/Analysis/Calculus/Deriv/Mul.lean
import Mathlib.Analysis.Calculus.Deriv.Basic import Mathlib.Analysis.Calculus.FDeriv.Mul import Mathlib.Analysis.Calculus.FDeriv.Add import Mathlib.Analysis.Calculus.FDeriv.CompCLM /-! # Derivative of `f x * g x` In this file we prove formulas for `(f x * g x)'` and `(f x • g x)'`. For a more detailed overview of one-dimensional derivatives in mathlib, see the module docstring of `Analysis/Calculus/Deriv/Basic`. ## Keywords derivative, multiplication -/ universe u v w noncomputable section open scoped Topology Filter ENNReal open Filter Asymptotics Set open ContinuousLinearMap (smulRight smulRight_one_eq_iff) variable {š•œ : Type u} [NontriviallyNormedField š•œ] variable {F : Type v} [NormedAddCommGroup F] [NormedSpace š•œ F] variable {E : Type w} [NormedAddCommGroup E] [NormedSpace š•œ E] variable {G : Type*} [NormedAddCommGroup G] [NormedSpace š•œ G] variable {f : š•œ → F} variable {f' : F} variable {x : š•œ} variable {s : Set š•œ} variable {L : Filter š•œ} /-! ### Derivative of bilinear maps -/ namespace ContinuousLinearMap variable {B : E →L[š•œ] F →L[š•œ] G} {u : š•œ → E} {v : š•œ → F} {u' : E} {v' : F} theorem hasDerivWithinAt_of_bilinear (hu : HasDerivWithinAt u u' s x) (hv : HasDerivWithinAt v v' s x) : HasDerivWithinAt (fun x ↦ B (u x) (v x)) (B (u x) v' + B u' (v x)) s x := by simpa using (B.hasFDerivWithinAt_of_bilinear hu.hasFDerivWithinAt hv.hasFDerivWithinAt).hasDerivWithinAt theorem hasDerivAt_of_bilinear (hu : HasDerivAt u u' x) (hv : HasDerivAt v v' x) : HasDerivAt (fun x ↦ B (u x) (v x)) (B (u x) v' + B u' (v x)) x := by simpa using (B.hasFDerivAt_of_bilinear hu.hasFDerivAt hv.hasFDerivAt).hasDerivAt theorem hasStrictDerivAt_of_bilinear (hu : HasStrictDerivAt u u' x) (hv : HasStrictDerivAt v v' x) : HasStrictDerivAt (fun x ↦ B (u x) (v x)) (B (u x) v' + B u' (v x)) x := by simpa using (B.hasStrictFDerivAt_of_bilinear hu.hasStrictFDerivAt hv.hasStrictFDerivAt).hasStrictDerivAt theorem derivWithin_of_bilinear (hu : DifferentiableWithinAt š•œ u s x) (hv : DifferentiableWithinAt š•œ v s x) : derivWithin (fun y => B (u y) (v y)) s x = B (u x) (derivWithin v s x) + B (derivWithin u s x) (v x) := by by_cases hsx : UniqueDiffWithinAt š•œ s x Ā· exact (B.hasDerivWithinAt_of_bilinear hu.hasDerivWithinAt hv.hasDerivWithinAt).derivWithin hsx Ā· simp [derivWithin_zero_of_not_uniqueDiffWithinAt hsx] theorem deriv_of_bilinear (hu : DifferentiableAt š•œ u x) (hv : DifferentiableAt š•œ v x) : deriv (fun y => B (u y) (v y)) x = B (u x) (deriv v x) + B (deriv u x) (v x) := (B.hasDerivAt_of_bilinear hu.hasDerivAt hv.hasDerivAt).deriv end ContinuousLinearMap section SMul /-! ### Derivative of the multiplication of a scalar function and a vector function -/ variable {š•œ' : Type*} [NontriviallyNormedField š•œ'] [NormedAlgebra š•œ š•œ'] [NormedSpace š•œ' F] [IsScalarTower š•œ š•œ' F] {c : š•œ → š•œ'} {c' : š•œ'} theorem HasDerivWithinAt.fun_smul (hc : HasDerivWithinAt c c' s x) (hf : HasDerivWithinAt f f' s x) : HasDerivWithinAt (fun y => c y • f y) (c x • f' + c' • f x) s x := by simpa using (HasFDerivWithinAt.smul hc hf).hasDerivWithinAt theorem HasDerivWithinAt.smul (hc : HasDerivWithinAt c c' s x) (hf : HasDerivWithinAt f f' s x) : HasDerivWithinAt (c • f) (c x • f' + c' • f x) s x := by simpa using (HasFDerivWithinAt.smul hc hf).hasDerivWithinAt theorem HasDerivAt.fun_smul (hc : HasDerivAt c c' x) (hf : HasDerivAt f f' x) : HasDerivAt (fun y => c y • f y) (c x • f' + c' • f x) x := by rw [← hasDerivWithinAt_univ] at * exact hc.smul hf theorem HasDerivAt.smul (hc : HasDerivAt c c' x) (hf : HasDerivAt f f' x) : HasDerivAt (c • f) (c x • f' + c' • f x) x := hc.fun_smul hf nonrec theorem HasStrictDerivAt.fun_smul (hc : HasStrictDerivAt c c' x) (hf : HasStrictDerivAt f f' x) : HasStrictDerivAt (fun y => c y • f y) (c x • f' + c' • f x) x := by simpa using (hc.smul hf).hasStrictDerivAt nonrec theorem HasStrictDerivAt.smul (hc : HasStrictDerivAt c c' x) (hf : HasStrictDerivAt f f' x) : HasStrictDerivAt (c • f) (c x • f' + c' • f x) x := by simpa using (hc.smul hf).hasStrictDerivAt theorem derivWithin_fun_smul (hc : DifferentiableWithinAt š•œ c s x) (hf : DifferentiableWithinAt š•œ f s x) : derivWithin (fun y => c y • f y) s x = c x • derivWithin f s x + derivWithin c s x • f x := by by_cases hsx : UniqueDiffWithinAt š•œ s x Ā· exact (hc.hasDerivWithinAt.smul hf.hasDerivWithinAt).derivWithin hsx Ā· simp [derivWithin_zero_of_not_uniqueDiffWithinAt hsx] theorem derivWithin_smul (hc : DifferentiableWithinAt š•œ c s x) (hf : DifferentiableWithinAt š•œ f s x) : derivWithin (c • f) s x = c x • derivWithin f s x + derivWithin c s x • f x := derivWithin_fun_smul hc hf theorem deriv_fun_smul (hc : DifferentiableAt š•œ c x) (hf : DifferentiableAt š•œ f x) : deriv (fun y => c y • f y) x = c x • deriv f x + deriv c x • f x := (hc.hasDerivAt.smul hf.hasDerivAt).deriv theorem deriv_smul (hc : DifferentiableAt š•œ c x) (hf : DifferentiableAt š•œ f x) : deriv (c • f) x = c x • deriv f x + deriv c x • f x := (hc.hasDerivAt.smul hf.hasDerivAt).deriv theorem HasStrictDerivAt.smul_const (hc : HasStrictDerivAt c c' x) (f : F) : HasStrictDerivAt (fun y => c y • f) (c' • f) x := by have := hc.smul (hasStrictDerivAt_const x f) rwa [smul_zero, zero_add] at this theorem HasDerivWithinAt.smul_const (hc : HasDerivWithinAt c c' s x) (f : F) : HasDerivWithinAt (fun y => c y • f) (c' • f) s x := by have := hc.smul (hasDerivWithinAt_const x s f) rwa [smul_zero, zero_add] at this theorem HasDerivAt.smul_const (hc : HasDerivAt c c' x) (f : F) : HasDerivAt (fun y => c y • f) (c' • f) x := by rw [← hasDerivWithinAt_univ] at * exact hc.smul_const f theorem derivWithin_smul_const (hc : DifferentiableWithinAt š•œ c s x) (f : F) : derivWithin (fun y => c y • f) s x = derivWithin c s x • f := by by_cases hsx : UniqueDiffWithinAt š•œ s x Ā· exact (hc.hasDerivWithinAt.smul_const f).derivWithin hsx Ā· simp [derivWithin_zero_of_not_uniqueDiffWithinAt hsx] theorem deriv_smul_const (hc : DifferentiableAt š•œ c x) (f : F) : deriv (fun y => c y • f) x = deriv c x • f := (hc.hasDerivAt.smul_const f).deriv end SMul section ConstSMul variable {R : Type*} [Semiring R] [Module R F] [SMulCommClass š•œ R F] [ContinuousConstSMul R F] nonrec theorem HasStrictDerivAt.fun_const_smul (c : R) (hf : HasStrictDerivAt f f' x) : HasStrictDerivAt (fun y => c • f y) (c • f') x := by simpa using (hf.const_smul c).hasStrictDerivAt nonrec theorem HasStrictDerivAt.const_smul (c : R) (hf : HasStrictDerivAt f f' x) : HasStrictDerivAt (c • f) (c • f') x := by simpa using (hf.const_smul c).hasStrictDerivAt nonrec theorem HasDerivAtFilter.fun_const_smul (c : R) (hf : HasDerivAtFilter f f' x L) : HasDerivAtFilter (fun y => c • f y) (c • f') x L := by simpa using (hf.const_smul c).hasDerivAtFilter nonrec theorem HasDerivAtFilter.const_smul (c : R) (hf : HasDerivAtFilter f f' x L) : HasDerivAtFilter (c • f) (c • f') x L := by simpa using (hf.const_smul c).hasDerivAtFilter nonrec theorem HasDerivWithinAt.fun_const_smul (c : R) (hf : HasDerivWithinAt f f' s x) : HasDerivWithinAt (fun y => c • f y) (c • f') s x := hf.const_smul c nonrec theorem HasDerivWithinAt.const_smul (c : R) (hf : HasDerivWithinAt f f' s x) : HasDerivWithinAt (c • f) (c • f') s x := hf.const_smul c nonrec theorem HasDerivAt.fun_const_smul (c : R) (hf : HasDerivAt f f' x) : HasDerivAt (fun y => c • f y) (c • f') x := hf.const_smul c nonrec theorem HasDerivAt.const_smul (c : R) (hf : HasDerivAt f f' x) : HasDerivAt (c • f) (c • f') x := hf.const_smul c theorem derivWithin_fun_const_smul (c : R) (hf : DifferentiableWithinAt š•œ f s x) : derivWithin (fun y => c • f y) s x = c • derivWithin f s x := by by_cases hsx : UniqueDiffWithinAt š•œ s x Ā· exact (hf.hasDerivWithinAt.const_smul c).derivWithin hsx Ā· simp [derivWithin_zero_of_not_uniqueDiffWithinAt hsx] theorem derivWithin_const_smul (c : R) (hf : DifferentiableWithinAt š•œ f s x) : derivWithin (c • f) s x = c • derivWithin f s x := derivWithin_fun_const_smul c hf /-- A variant of `derivWithin_fun_const_smul` without differentiability assumption when the scalar multiplication is by field elements. -/ lemma derivWithin_fun_const_smul' {f : š•œ → F} {x : š•œ} {R : Type*} [Field R] [Module R F] [SMulCommClass š•œ R F] [ContinuousConstSMul R F] (c : R) : derivWithin (fun y ↦ c • f y) s x = c • derivWithin f s x := by by_cases hsx : UniqueDiffWithinAt š•œ s x Ā· simp [← fderivWithin_derivWithin, ← Pi.smul_def, fderivWithin_const_smul_field c hsx] Ā· simp [derivWithin_zero_of_not_uniqueDiffWithinAt hsx] /-- A variant of `derivWithin_const_smul` without differentiability assumption when the scalar multiplication is by field elements. -/ lemma derivWithin_const_smul' {f : š•œ → F} {x : š•œ} {R : Type*} [Field R] [Module R F] [SMulCommClass š•œ R F] [ContinuousConstSMul R F] (c : R) : derivWithin (c • f) s x = c • derivWithin f s x := derivWithin_fun_const_smul' c theorem deriv_fun_const_smul (c : R) (hf : DifferentiableAt š•œ f x) : deriv (fun y => c • f y) x = c • deriv f x := (hf.hasDerivAt.const_smul c).deriv theorem deriv_const_smul (c : R) (hf : DifferentiableAt š•œ f x) : deriv (c • f) x = c • deriv f x := (hf.hasDerivAt.const_smul c).deriv /-- A variant of `deriv_const_smul` without differentiability assumption when the scalar multiplication is by field elements. -/ lemma deriv_fun_const_smul' {f : š•œ → F} {x : š•œ} {R : Type*} [Field R] [Module R F] [SMulCommClass š•œ R F] [ContinuousConstSMul R F] (c : R) : deriv (fun y ↦ c • f y) x = c • deriv f x := by simp only [← derivWithin_univ, derivWithin_fun_const_smul'] /-- A variant of `deriv_const_smul` without differentiability assumption when the scalar multiplication is by field elements. -/ lemma deriv_const_smul' {f : š•œ → F} {x : š•œ} {R : Type*} [Field R] [Module R F] [SMulCommClass š•œ R F] [ContinuousConstSMul R F] (c : R) : deriv (c • f) x = c • deriv f x := by simp only [← derivWithin_univ, derivWithin_const_smul'] end ConstSMul section Mul /-! ### Derivative of the multiplication of two functions -/ variable {š•œ' š”ø : Type*} [NormedField š•œ'] [NormedRing š”ø] [NormedAlgebra š•œ š•œ'] [NormedAlgebra š•œ š”ø] {c d : š•œ → š”ø} {c' d' : š”ø} {u v : š•œ → š•œ'} theorem HasDerivWithinAt.fun_mul (hc : HasDerivWithinAt c c' s x) (hd : HasDerivWithinAt d d' s x) : HasDerivWithinAt (fun y => c y * d y) (c' * d x + c x * d') s x := by have := (HasFDerivWithinAt.mul' hc hd).hasDerivWithinAt rwa [ContinuousLinearMap.add_apply, ContinuousLinearMap.smul_apply, ContinuousLinearMap.smulRight_apply, ContinuousLinearMap.smul_apply, ContinuousLinearMap.smulRight_apply, ContinuousLinearMap.one_apply, one_smul, one_smul, add_comm] at this theorem HasDerivWithinAt.mul (hc : HasDerivWithinAt c c' s x) (hd : HasDerivWithinAt d d' s x) : HasDerivWithinAt (c * d) (c' * d x + c x * d') s x := hc.fun_mul hd theorem HasDerivAt.fun_mul (hc : HasDerivAt c c' x) (hd : HasDerivAt d d' x) : HasDerivAt (fun y => c y * d y) (c' * d x + c x * d') x := by rw [← hasDerivWithinAt_univ] at * exact hc.mul hd theorem HasDerivAt.mul (hc : HasDerivAt c c' x) (hd : HasDerivAt d d' x) : HasDerivAt (c * d) (c' * d x + c x * d') x := hc.fun_mul hd theorem HasStrictDerivAt.fun_mul (hc : HasStrictDerivAt c c' x) (hd : HasStrictDerivAt d d' x) : HasStrictDerivAt (fun y => c y * d y) (c' * d x + c x * d') x := by have := (HasStrictFDerivAt.mul' hc hd).hasStrictDerivAt rwa [ContinuousLinearMap.add_apply, ContinuousLinearMap.smul_apply, ContinuousLinearMap.smulRight_apply, ContinuousLinearMap.smul_apply, ContinuousLinearMap.smulRight_apply, ContinuousLinearMap.one_apply, one_smul, one_smul, add_comm] at this theorem HasStrictDerivAt.mul (hc : HasStrictDerivAt c c' x) (hd : HasStrictDerivAt d d' x) : HasStrictDerivAt (c * d) (c' * d x + c x * d') x := hc.fun_mul hd theorem derivWithin_fun_mul (hc : DifferentiableWithinAt š•œ c s x) (hd : DifferentiableWithinAt š•œ d s x) : derivWithin (fun y => c y * d y) s x = derivWithin c s x * d x + c x * derivWithin d s x := by by_cases hsx : UniqueDiffWithinAt š•œ s x Ā· exact (hc.hasDerivWithinAt.mul hd.hasDerivWithinAt).derivWithin hsx Ā· simp [derivWithin_zero_of_not_uniqueDiffWithinAt hsx] theorem derivWithin_mul (hc : DifferentiableWithinAt š•œ c s x) (hd : DifferentiableWithinAt š•œ d s x) : derivWithin (c * d) s x = derivWithin c s x * d x + c x * derivWithin d s x := derivWithin_fun_mul hc hd @[simp] theorem deriv_fun_mul (hc : DifferentiableAt š•œ c x) (hd : DifferentiableAt š•œ d x) : deriv (fun y => c y * d y) x = deriv c x * d x + c x * deriv d x := (hc.hasDerivAt.mul hd.hasDerivAt).deriv @[simp] theorem deriv_mul (hc : DifferentiableAt š•œ c x) (hd : DifferentiableAt š•œ d x) : deriv (c * d) x = deriv c x * d x + c x * deriv d x := (hc.hasDerivAt.mul hd.hasDerivAt).deriv theorem HasDerivWithinAt.mul_const (hc : HasDerivWithinAt c c' s x) (d : š”ø) : HasDerivWithinAt (fun y => c y * d) (c' * d) s x := by convert hc.mul (hasDerivWithinAt_const x s d) using 1 rw [mul_zero, add_zero] theorem HasDerivAt.mul_const (hc : HasDerivAt c c' x) (d : š”ø) : HasDerivAt (fun y => c y * d) (c' * d) x := by rw [← hasDerivWithinAt_univ] at * exact hc.mul_const d theorem hasDerivAt_mul_const (c : š•œ) : HasDerivAt (fun x => x * c) c x := by simpa only [one_mul] using (hasDerivAt_id' x).mul_const c theorem HasStrictDerivAt.mul_const (hc : HasStrictDerivAt c c' x) (d : š”ø) : HasStrictDerivAt (fun y => c y * d) (c' * d) x := by convert hc.mul (hasStrictDerivAt_const x d) using 1 rw [mul_zero, add_zero] theorem derivWithin_mul_const (hc : DifferentiableWithinAt š•œ c s x) (d : š”ø) : derivWithin (fun y => c y * d) s x = derivWithin c s x * d := by by_cases hsx : UniqueDiffWithinAt š•œ s x Ā· exact (hc.hasDerivWithinAt.mul_const d).derivWithin hsx Ā· simp [derivWithin_zero_of_not_uniqueDiffWithinAt hsx] lemma derivWithin_mul_const_field (u : š•œ') : derivWithin (fun y => v y * u) s x = derivWithin v s x * u := by by_cases hv : DifferentiableWithinAt š•œ v s x Ā· rw [derivWithin_mul_const hv u] by_cases hu : u = 0 Ā· simp [hu] rw [derivWithin_zero_of_not_differentiableWithinAt hv, zero_mul, derivWithin_zero_of_not_differentiableWithinAt] have : v = fun x ↦ (v x * u) * u⁻¹ := by ext; simp [hu] exact fun h_diff ↦ hv <| this ā–ø h_diff.mul_const _ theorem deriv_mul_const (hc : DifferentiableAt š•œ c x) (d : š”ø) : deriv (fun y => c y * d) x = deriv c x * d := (hc.hasDerivAt.mul_const d).deriv theorem deriv_mul_const_field (v : š•œ') : deriv (fun y => u y * v) x = deriv u x * v := by by_cases hu : DifferentiableAt š•œ u x Ā· exact deriv_mul_const hu v Ā· rw [deriv_zero_of_not_differentiableAt hu, zero_mul] rcases eq_or_ne v 0 with (rfl | hd) Ā· simp only [mul_zero, deriv_const] Ā· refine deriv_zero_of_not_differentiableAt (mt (fun H => ?_) hu) simpa only [mul_inv_cancel_rightā‚€ hd] using H.mul_const v⁻¹ @[simp] theorem deriv_mul_const_field' (v : š•œ') : (deriv fun x => u x * v) = fun x => deriv u x * v := funext fun _ => deriv_mul_const_field v theorem HasDerivWithinAt.const_mul (c : š”ø) (hd : HasDerivWithinAt d d' s x) : HasDerivWithinAt (fun y => c * d y) (c * d') s x := by convert (hasDerivWithinAt_const x s c).mul hd using 1 rw [zero_mul, zero_add] theorem HasDerivAt.const_mul (c : š”ø) (hd : HasDerivAt d d' x) : HasDerivAt (fun y => c * d y) (c * d') x := by rw [← hasDerivWithinAt_univ] at * exact hd.const_mul c theorem HasStrictDerivAt.const_mul (c : š”ø) (hd : HasStrictDerivAt d d' x) : HasStrictDerivAt (fun y => c * d y) (c * d') x := by convert (hasStrictDerivAt_const _ _).mul hd using 1 rw [zero_mul, zero_add] theorem derivWithin_const_mul (c : š”ø) (hd : DifferentiableWithinAt š•œ d s x) : derivWithin (fun y => c * d y) s x = c * derivWithin d s x := by by_cases hsx : UniqueDiffWithinAt š•œ s x Ā· exact (hd.hasDerivWithinAt.const_mul c).derivWithin hsx Ā· simp [derivWithin_zero_of_not_uniqueDiffWithinAt hsx] lemma derivWithin_const_mul_field (u : š•œ') : derivWithin (fun y => u * v y) s x = u * derivWithin v s x := by simp_rw [mul_comm u] exact derivWithin_mul_const_field u theorem deriv_const_mul (c : š”ø) (hd : DifferentiableAt š•œ d x) : deriv (fun y => c * d y) x = c * deriv d x := (hd.hasDerivAt.const_mul c).deriv theorem deriv_const_mul_field (u : š•œ') : deriv (fun y => u * v y) x = u * deriv v x := by simp only [mul_comm u, deriv_mul_const_field] @[simp] theorem deriv_const_mul_field' (u : š•œ') : (deriv fun x => u * v x) = fun x => u * deriv v x := funext fun _ => deriv_const_mul_field u end Mul section Prod section HasDeriv variable {ι : Type*} [DecidableEq ι] {š”ø' : Type*} [NormedCommRing š”ø'] [NormedAlgebra š•œ š”ø'] {u : Finset ι} {f : ι → š•œ → š”ø'} {f' : ι → š”ø'} theorem HasDerivAt.fun_finset_prod (hf : āˆ€ i ∈ u, HasDerivAt (f i) (f' i) x) : HasDerivAt (āˆ i ∈ u, f i Ā·) (āˆ‘ i ∈ u, (āˆ j ∈ u.erase i, f j x) • f' i) x := by simpa [ContinuousLinearMap.sum_apply, ContinuousLinearMap.smul_apply] using (HasFDerivAt.finset_prod (fun i hi ↦ (hf i hi).hasFDerivAt)).hasDerivAt theorem HasDerivAt.finset_prod (hf : āˆ€ i ∈ u, HasDerivAt (f i) (f' i) x) : HasDerivAt (āˆ i ∈ u, f i) (āˆ‘ i ∈ u, (āˆ j ∈ u.erase i, f j x) • f' i) x := by convert HasDerivAt.fun_finset_prod hf; simp theorem HasDerivWithinAt.fun_finset_prod (hf : āˆ€ i ∈ u, HasDerivWithinAt (f i) (f' i) s x) : HasDerivWithinAt (āˆ i ∈ u, f i Ā·) (āˆ‘ i ∈ u, (āˆ j ∈ u.erase i, f j x) • f' i) s x := by simpa [ContinuousLinearMap.sum_apply, ContinuousLinearMap.smul_apply] using (HasFDerivWithinAt.finset_prod (fun i hi ↦ (hf i hi).hasFDerivWithinAt)).hasDerivWithinAt theorem HasDerivWithinAt.finset_prod (hf : āˆ€ i ∈ u, HasDerivWithinAt (f i) (f' i) s x) : HasDerivWithinAt (āˆ i ∈ u, f i) (āˆ‘ i ∈ u, (āˆ j ∈ u.erase i, f j x) • f' i) s x := by convert HasDerivWithinAt.fun_finset_prod hf; simp theorem HasStrictDerivAt.fun_finset_prod (hf : āˆ€ i ∈ u, HasStrictDerivAt (f i) (f' i) x) : HasStrictDerivAt (āˆ i ∈ u, f i Ā·) (āˆ‘ i ∈ u, (āˆ j ∈ u.erase i, f j x) • f' i) x := by simpa [ContinuousLinearMap.sum_apply, ContinuousLinearMap.smul_apply] using (HasStrictFDerivAt.finset_prod (fun i hi ↦ (hf i hi).hasStrictFDerivAt)).hasStrictDerivAt theorem HasStrictDerivAt.finset_prod (hf : āˆ€ i ∈ u, HasStrictDerivAt (f i) (f' i) x) : HasStrictDerivAt (āˆ i ∈ u, f i) (āˆ‘ i ∈ u, (āˆ j ∈ u.erase i, f j x) • f' i) x := by convert HasStrictDerivAt.fun_finset_prod hf; simp theorem deriv_fun_finset_prod (hf : āˆ€ i ∈ u, DifferentiableAt š•œ (f i) x) : deriv (āˆ i ∈ u, f i Ā·) x = āˆ‘ i ∈ u, (āˆ j ∈ u.erase i, f j x) • deriv (f i) x := (HasDerivAt.fun_finset_prod fun i hi ↦ (hf i hi).hasDerivAt).deriv theorem deriv_finset_prod (hf : āˆ€ i ∈ u, DifferentiableAt š•œ (f i) x) : deriv (āˆ i ∈ u, f i) x = āˆ‘ i ∈ u, (āˆ j ∈ u.erase i, f j x) • deriv (f i) x := (HasDerivAt.finset_prod fun i hi ↦ (hf i hi).hasDerivAt).deriv theorem derivWithin_fun_finset_prod (hf : āˆ€ i ∈ u, DifferentiableWithinAt š•œ (f i) s x) : derivWithin (āˆ i ∈ u, f i Ā·) s x = āˆ‘ i ∈ u, (āˆ j ∈ u.erase i, f j x) • derivWithin (f i) s x := by by_cases hsx : UniqueDiffWithinAt š•œ s x Ā· exact (HasDerivWithinAt.fun_finset_prod fun i hi ↦ (hf i hi).hasDerivWithinAt).derivWithin hsx Ā· simp [derivWithin_zero_of_not_uniqueDiffWithinAt hsx] theorem derivWithin_finset_prod (hf : āˆ€ i ∈ u, DifferentiableWithinAt š•œ (f i) s x) : derivWithin (āˆ i ∈ u, f i) s x = āˆ‘ i ∈ u, (āˆ j ∈ u.erase i, f j x) • derivWithin (f i) s x := by convert derivWithin_fun_finset_prod hf; simp end HasDeriv variable {ι : Type*} {š”ø' : Type*} [NormedCommRing š”ø'] [NormedAlgebra š•œ š”ø'] {u : Finset ι} {f : ι → š•œ → š”ø'} @[fun_prop] theorem DifferentiableAt.fun_finset_prod (hd : āˆ€ i ∈ u, DifferentiableAt š•œ (f i) x) : DifferentiableAt š•œ (āˆ i ∈ u, f i Ā·) x := by classical exact (HasDerivAt.fun_finset_prod (fun i hi ↦ DifferentiableAt.hasDerivAt (hd i hi))).differentiableAt @[fun_prop] theorem DifferentiableAt.finset_prod (hd : āˆ€ i ∈ u, DifferentiableAt š•œ (f i) x) : DifferentiableAt š•œ (āˆ i ∈ u, f i) x := by convert DifferentiableAt.fun_finset_prod hd; simp @[fun_prop] theorem DifferentiableWithinAt.fun_finset_prod (hd : āˆ€ i ∈ u, DifferentiableWithinAt š•œ (f i) s x) : DifferentiableWithinAt š•œ (āˆ i ∈ u, f i Ā·) s x := by classical exact (HasDerivWithinAt.fun_finset_prod (fun i hi ↦ DifferentiableWithinAt.hasDerivWithinAt (hd i hi))).differentiableWithinAt @[fun_prop] theorem DifferentiableWithinAt.finset_prod (hd : āˆ€ i ∈ u, DifferentiableWithinAt š•œ (f i) s x) : DifferentiableWithinAt š•œ (āˆ i ∈ u, f i) s x := by convert DifferentiableWithinAt.fun_finset_prod hd; simp @[fun_prop] theorem DifferentiableOn.fun_finset_prod (hd : āˆ€ i ∈ u, DifferentiableOn š•œ (f i) s) : DifferentiableOn š•œ (āˆ i ∈ u, f i Ā·) s := fun x hx ↦ .fun_finset_prod (fun i hi ↦ hd i hi x hx) @[fun_prop] theorem DifferentiableOn.finset_prod (hd : āˆ€ i ∈ u, DifferentiableOn š•œ (f i) s) : DifferentiableOn š•œ (āˆ i ∈ u, f i) s := fun x hx ↦ .finset_prod (fun i hi ↦ hd i hi x hx) @[fun_prop] theorem Differentiable.fun_finset_prod (hd : āˆ€ i ∈ u, Differentiable š•œ (f i)) : Differentiable š•œ (āˆ i ∈ u, f i Ā·) := fun x ↦ .fun_finset_prod (fun i hi ↦ hd i hi x) @[fun_prop] theorem Differentiable.finset_prod (hd : āˆ€ i ∈ u, Differentiable š•œ (f i)) : Differentiable š•œ (āˆ i ∈ u, f i) := fun x ↦ .finset_prod (fun i hi ↦ hd i hi x) end Prod section Div variable {š•œ' : Type*} [NontriviallyNormedField š•œ'] [NormedAlgebra š•œ š•œ'] {c : š•œ → š•œ'} {c' : š•œ'} theorem HasDerivAt.div_const (hc : HasDerivAt c c' x) (d : š•œ') : HasDerivAt (fun x => c x / d) (c' / d) x := by simpa only [div_eq_mul_inv] using hc.mul_const d⁻¹ theorem HasDerivWithinAt.div_const (hc : HasDerivWithinAt c c' s x) (d : š•œ') : HasDerivWithinAt (fun x => c x / d) (c' / d) s x := by simpa only [div_eq_mul_inv] using hc.mul_const d⁻¹ theorem HasStrictDerivAt.div_const (hc : HasStrictDerivAt c c' x) (d : š•œ') : HasStrictDerivAt (fun x => c x / d) (c' / d) x := by simpa only [div_eq_mul_inv] using hc.mul_const d⁻¹ @[fun_prop] theorem DifferentiableWithinAt.div_const (hc : DifferentiableWithinAt š•œ c s x) (d : š•œ') : DifferentiableWithinAt š•œ (fun x => c x / d) s x := (hc.hasDerivWithinAt.div_const _).differentiableWithinAt @[simp, fun_prop] theorem DifferentiableAt.div_const (hc : DifferentiableAt š•œ c x) (d : š•œ') : DifferentiableAt š•œ (fun x => c x / d) x := (hc.hasDerivAt.div_const _).differentiableAt @[fun_prop] theorem DifferentiableOn.div_const (hc : DifferentiableOn š•œ c s) (d : š•œ') : DifferentiableOn š•œ (fun x => c x / d) s := fun x hx => (hc x hx).div_const d @[simp, fun_prop] theorem Differentiable.div_const (hc : Differentiable š•œ c) (d : š•œ') : Differentiable š•œ fun x => c x / d := fun x => (hc x).div_const d theorem derivWithin_div_const (hc : DifferentiableWithinAt š•œ c s x) (d : š•œ') : derivWithin (fun x => c x / d) s x = derivWithin c s x / d := by simp [div_eq_inv_mul, derivWithin_const_mul, hc] @[simp] theorem deriv_div_const (d : š•œ') : deriv (fun x => c x / d) x = deriv c x / d := by simp only [div_eq_mul_inv, deriv_mul_const_field] end Div section CLMCompApply /-! ### Derivative of the pointwise composition/application of continuous linear maps -/ open ContinuousLinearMap variable {G : Type*} [NormedAddCommGroup G] [NormedSpace š•œ G] {c : š•œ → F →L[š•œ] G} {c' : F →L[š•œ] G} {d : š•œ → E →L[š•œ] F} {d' : E →L[š•œ] F} {u : š•œ → F} {u' : F} theorem HasStrictDerivAt.clm_comp (hc : HasStrictDerivAt c c' x) (hd : HasStrictDerivAt d d' x) : HasStrictDerivAt (fun y => (c y).comp (d y)) (c'.comp (d x) + (c x).comp d') x := by have := (hc.hasStrictFDerivAt.clm_comp hd.hasStrictFDerivAt).hasStrictDerivAt rwa [add_apply, comp_apply, comp_apply, smulRight_apply, smulRight_apply, one_apply, one_smul, one_smul, add_comm] at this theorem HasDerivWithinAt.clm_comp (hc : HasDerivWithinAt c c' s x) (hd : HasDerivWithinAt d d' s x) : HasDerivWithinAt (fun y => (c y).comp (d y)) (c'.comp (d x) + (c x).comp d') s x := by have := (hc.hasFDerivWithinAt.clm_comp hd.hasFDerivWithinAt).hasDerivWithinAt rwa [add_apply, comp_apply, comp_apply, smulRight_apply, smulRight_apply, one_apply, one_smul, one_smul, add_comm] at this theorem HasDerivAt.clm_comp (hc : HasDerivAt c c' x) (hd : HasDerivAt d d' x) : HasDerivAt (fun y => (c y).comp (d y)) (c'.comp (d x) + (c x).comp d') x := by rw [← hasDerivWithinAt_univ] at * exact hc.clm_comp hd theorem derivWithin_clm_comp (hc : DifferentiableWithinAt š•œ c s x) (hd : DifferentiableWithinAt š•œ d s x) : derivWithin (fun y => (c y).comp (d y)) s x = (derivWithin c s x).comp (d x) + (c x).comp (derivWithin d s x) := by by_cases hsx : UniqueDiffWithinAt š•œ s x Ā· exact (hc.hasDerivWithinAt.clm_comp hd.hasDerivWithinAt).derivWithin hsx Ā· simp [derivWithin_zero_of_not_uniqueDiffWithinAt hsx] theorem deriv_clm_comp (hc : DifferentiableAt š•œ c x) (hd : DifferentiableAt š•œ d x) : deriv (fun y => (c y).comp (d y)) x = (deriv c x).comp (d x) + (c x).comp (deriv d x) := (hc.hasDerivAt.clm_comp hd.hasDerivAt).deriv theorem HasStrictDerivAt.clm_apply (hc : HasStrictDerivAt c c' x) (hu : HasStrictDerivAt u u' x) : HasStrictDerivAt (fun y => (c y) (u y)) (c' (u x) + c x u') x := by have := (hc.hasStrictFDerivAt.clm_apply hu.hasStrictFDerivAt).hasStrictDerivAt rwa [add_apply, comp_apply, flip_apply, smulRight_apply, smulRight_apply, one_apply, one_smul, one_smul, add_comm] at this theorem HasDerivWithinAt.clm_apply (hc : HasDerivWithinAt c c' s x) (hu : HasDerivWithinAt u u' s x) : HasDerivWithinAt (fun y => (c y) (u y)) (c' (u x) + c x u') s x := by have := (hc.hasFDerivWithinAt.clm_apply hu.hasFDerivWithinAt).hasDerivWithinAt rwa [add_apply, comp_apply, flip_apply, smulRight_apply, smulRight_apply, one_apply, one_smul, one_smul, add_comm] at this theorem HasDerivAt.clm_apply (hc : HasDerivAt c c' x) (hu : HasDerivAt u u' x) : HasDerivAt (fun y => (c y) (u y)) (c' (u x) + c x u') x := by have := (hc.hasFDerivAt.clm_apply hu.hasFDerivAt).hasDerivAt rwa [add_apply, comp_apply, flip_apply, smulRight_apply, smulRight_apply, one_apply, one_smul, one_smul, add_comm] at this theorem derivWithin_clm_apply (hc : DifferentiableWithinAt š•œ c s x) (hu : DifferentiableWithinAt š•œ u s x) : derivWithin (fun y => (c y) (u y)) s x = derivWithin c s x (u x) + c x (derivWithin u s x) := by by_cases hsx : UniqueDiffWithinAt š•œ s x Ā· exact (hc.hasDerivWithinAt.clm_apply hu.hasDerivWithinAt).derivWithin hsx Ā· simp [derivWithin_zero_of_not_uniqueDiffWithinAt hsx] theorem deriv_clm_apply (hc : DifferentiableAt š•œ c x) (hu : DifferentiableAt š•œ u x) : deriv (fun y => (c y) (u y)) x = deriv c x (u x) + c x (deriv u x) := (hc.hasDerivAt.clm_apply hu.hasDerivAt).deriv end CLMCompApply
.lake/packages/mathlib/Mathlib/Analysis/Calculus/Deriv/Basic.lean
import Mathlib.Analysis.Calculus.FDeriv.Const import Mathlib.Analysis.Normed.Operator.NormedSpace import Mathlib.Analysis.Calculus.TangentCone.DimOne import Mathlib.Analysis.Calculus.TangentCone.Real /-! # One-dimensional derivatives This file defines the derivative of a function `f : š•œ → F` where `š•œ` is a normed field and `F` is a normed space over this field. The derivative of such a function `f` at a point `x` is given by an element `f' : F`. The theory is developed analogously to the [FrĆ©chet derivatives](./fderiv.html). We first introduce predicates defined in terms of the corresponding predicates for FrĆ©chet derivatives: - `HasDerivAtFilter f f' x L` states that the function `f` has the derivative `f'` at the point `x` as `x` goes along the filter `L`. - `HasDerivWithinAt f f' s x` states that the function `f` has the derivative `f'` at the point `x` within the subset `s`. - `HasDerivAt f f' x` states that the function `f` has the derivative `f'` at the point `x`. - `HasStrictDerivAt f f' x` states that the function `f` has the derivative `f'` at the point `x` in the sense of strict differentiability, i.e., `f y - f z = (y - z) • f' + o (y - z)` as `y, z → x`. For the last two notions we also define a functional version: - `derivWithin f s x` is a derivative of `f` at `x` within `s`. If the derivative does not exist, then `derivWithin f s x` equals zero. - `deriv f x` is a derivative of `f` at `x`. If the derivative does not exist, then `deriv f x` equals zero. The theorems `fderivWithin_derivWithin` and `fderiv_deriv` show that the one-dimensional derivatives coincide with the general FrĆ©chet derivatives. We also show the existence and compute the derivatives of: - constants - the identity function - linear maps (in `Linear.lean`) - addition (in `Add.lean`) - sum of finitely many functions (in `Add.lean`) - negation (in `Add.lean`) - subtraction (in `Add.lean`) - star (in `Star.lean`) - multiplication of two functions in `š•œ → š•œ` (in `Mul.lean`) - multiplication of a function in `š•œ → š•œ` and of a function in `š•œ → E` (in `Mul.lean`) - powers of a function (in `Pow.lean` and `ZPow.lean`) - inverse `x → x⁻¹` (in `Inv.lean`) - division (in `Inv.lean`) - composition of a function in `š•œ → F` with a function in `š•œ → š•œ` (in `Comp.lean`) - composition of a function in `F → E` with a function in `š•œ → F` (in `Comp.lean`) - inverse function (assuming that it exists; the inverse function theorem is in `Inverse.lean`) - polynomials (in `Polynomial.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. We set up the simplifier so that it can compute the derivative of simple functions. For instance, ```lean example (x : ā„) : deriv (fun x ↦ cos (sin x) * exp x) x = (cos (sin x) - sin (sin x) * cos x) * exp x := by simp; ring ``` The relationship between the derivative of a function and its definition from a standard undergraduate course as the limit of the slope `(f y - f x) / (y - x)` as `y` tends to `š“[≠] x` is developed in the file `Slope.lean`. ## Implementation notes Most of the theorems are direct restatements of the corresponding theorems for FrĆ©chet derivatives. The strategy to construct simp lemmas that give the simplifier the possibility to compute derivatives is the same as the one for differentiability statements, as explained in `FDeriv/Basic.lean`. See the explanations there. -/ universe u v w noncomputable section open scoped Topology ENNReal NNReal open Filter Asymptotics Set open ContinuousLinearMap (smulRight smulRight_one_eq_iff) section TVS variable {š•œ : Type u} [NontriviallyNormedField š•œ] variable {F : Type v} [AddCommGroup F] [Module š•œ F] [TopologicalSpace F] section variable [ContinuousSMul š•œ F] /-- `f` has the derivative `f'` at the point `x` as `x` goes along the filter `L`. That is, `f x' = f x + (x' - x) • f' + o(x' - x)` where `x'` converges along the filter `L`. -/ def HasDerivAtFilter (f : š•œ → F) (f' : F) (x : š•œ) (L : Filter š•œ) := HasFDerivAtFilter f (smulRight (1 : š•œ →L[š•œ] š•œ) f') x L /-- `f` has the derivative `f'` at the point `x` within the subset `s`. That is, `f x' = f x + (x' - x) • f' + o(x' - x)` where `x'` converges to `x` inside `s`. -/ def HasDerivWithinAt (f : š•œ → F) (f' : F) (s : Set š•œ) (x : š•œ) := HasDerivAtFilter f f' x (š“[s] x) /-- `f` has the derivative `f'` at the point `x`. That is, `f x' = f x + (x' - x) • f' + o(x' - x)` where `x'` converges to `x`. -/ def HasDerivAt (f : š•œ → F) (f' : F) (x : š•œ) := HasDerivAtFilter f f' x (š“ x) /-- `f` has the derivative `f'` at the point `x` in the sense of strict differentiability. That is, `f y - f z = (y - z) • f' + o(y - z)` as `y, z → x`. -/ def HasStrictDerivAt (f : š•œ → F) (f' : F) (x : š•œ) := HasStrictFDerivAt f (smulRight (1 : š•œ →L[š•œ] š•œ) f') x end /-- Derivative of `f` at the point `x` within the set `s`, if it exists. Zero otherwise. If the derivative exists (i.e., `∃ f', HasDerivWithinAt f f' s x`), then `f x' = f x + (x' - x) • derivWithin f s x + o(x' - x)` where `x'` converges to `x` inside `s`. -/ def derivWithin (f : š•œ → F) (s : Set š•œ) (x : š•œ) := fderivWithin š•œ f s x 1 /-- Derivative of `f` at the point `x`, if it exists. Zero otherwise. If the derivative exists (i.e., `∃ f', HasDerivAt f f' x`), then `f x' = f x + (x' - x) • deriv f x + o(x' - x)` where `x'` converges to `x`. -/ def deriv (f : š•œ → F) (x : š•œ) := fderiv š•œ f x 1 variable {f fā‚€ f₁ : š•œ → F} variable {f' fā‚€' f₁' g' : F} variable {x : š•œ} variable {s t : Set š•œ} variable {L L₁ Lā‚‚ : Filter š•œ} section variable [ContinuousSMul š•œ F] /-- Expressing `HasFDerivAtFilter f f' x L` in terms of `HasDerivAtFilter` -/ theorem hasFDerivAtFilter_iff_hasDerivAtFilter {f' : š•œ →L[š•œ] F} : HasFDerivAtFilter f f' x L ↔ HasDerivAtFilter f (f' 1) x L := by simp [HasDerivAtFilter] theorem HasFDerivAtFilter.hasDerivAtFilter {f' : š•œ →L[š•œ] F} : HasFDerivAtFilter f f' x L → HasDerivAtFilter f (f' 1) x L := hasFDerivAtFilter_iff_hasDerivAtFilter.mp /-- Expressing `HasFDerivWithinAt f f' s x` in terms of `HasDerivWithinAt` -/ theorem hasFDerivWithinAt_iff_hasDerivWithinAt {f' : š•œ →L[š•œ] F} : HasFDerivWithinAt f f' s x ↔ HasDerivWithinAt f (f' 1) s x := hasFDerivAtFilter_iff_hasDerivAtFilter /-- Expressing `HasDerivWithinAt f f' s x` in terms of `HasFDerivWithinAt` -/ theorem hasDerivWithinAt_iff_hasFDerivWithinAt {f' : F} : HasDerivWithinAt f f' s x ↔ HasFDerivWithinAt f (smulRight (1 : š•œ →L[š•œ] š•œ) f') s x := Iff.rfl theorem HasFDerivWithinAt.hasDerivWithinAt {f' : š•œ →L[š•œ] F} : HasFDerivWithinAt f f' s x → HasDerivWithinAt f (f' 1) s x := hasFDerivWithinAt_iff_hasDerivWithinAt.mp theorem HasDerivWithinAt.hasFDerivWithinAt {f' : F} : HasDerivWithinAt f f' s x → HasFDerivWithinAt f (smulRight (1 : š•œ →L[š•œ] š•œ) f') s x := hasDerivWithinAt_iff_hasFDerivWithinAt.mp /-- Expressing `HasFDerivAt f f' x` in terms of `HasDerivAt` -/ theorem hasFDerivAt_iff_hasDerivAt {f' : š•œ →L[š•œ] F} : HasFDerivAt f f' x ↔ HasDerivAt f (f' 1) x := hasFDerivAtFilter_iff_hasDerivAtFilter theorem HasFDerivAt.hasDerivAt {f' : š•œ →L[š•œ] F} : HasFDerivAt f f' x → HasDerivAt f (f' 1) x := hasFDerivAt_iff_hasDerivAt.mp theorem hasStrictFDerivAt_iff_hasStrictDerivAt {f' : š•œ →L[š•œ] F} : HasStrictFDerivAt f f' x ↔ HasStrictDerivAt f (f' 1) x := by simp [HasStrictDerivAt] protected theorem HasStrictFDerivAt.hasStrictDerivAt {f' : š•œ →L[š•œ] F} : HasStrictFDerivAt f f' x → HasStrictDerivAt f (f' 1) x := hasStrictFDerivAt_iff_hasStrictDerivAt.mp theorem hasStrictDerivAt_iff_hasStrictFDerivAt : HasStrictDerivAt f f' x ↔ HasStrictFDerivAt f (smulRight (1 : š•œ →L[š•œ] š•œ) f') x := Iff.rfl alias ⟨HasStrictDerivAt.hasStrictFDerivAt, _⟩ := hasStrictDerivAt_iff_hasStrictFDerivAt /-- Expressing `HasDerivAt f f' x` in terms of `HasFDerivAt` -/ theorem hasDerivAt_iff_hasFDerivAt {f' : F} : HasDerivAt f f' x ↔ HasFDerivAt f (smulRight (1 : š•œ →L[š•œ] š•œ) f') x := Iff.rfl alias ⟨HasDerivAt.hasFDerivAt, _⟩ := hasDerivAt_iff_hasFDerivAt end theorem derivWithin_zero_of_not_differentiableWithinAt (h : ¬DifferentiableWithinAt š•œ f s x) : derivWithin f s x = 0 := by unfold derivWithin rw [fderivWithin_zero_of_not_differentiableWithinAt h] simp theorem differentiableWithinAt_of_derivWithin_ne_zero (h : derivWithin f s x ≠ 0) : DifferentiableWithinAt š•œ f s x := not_imp_comm.1 derivWithin_zero_of_not_differentiableWithinAt h end TVS variable {š•œ : Type u} [NontriviallyNormedField š•œ] variable {F : Type v} [NormedAddCommGroup F] [NormedSpace š•œ F] variable {f fā‚€ f₁ : š•œ → F} variable {f' fā‚€' f₁' g' : F} variable {x : š•œ} variable {s t : Set š•œ} variable {L L₁ Lā‚‚ : Filter š•œ} theorem derivWithin_zero_of_not_accPt (h : ¬AccPt x (š“Ÿ s)) : derivWithin f s x = 0 := by rw [derivWithin, fderivWithin_zero_of_not_accPt h, ContinuousLinearMap.zero_apply] theorem derivWithin_zero_of_not_uniqueDiffWithinAt (h : ¬UniqueDiffWithinAt š•œ s x) : derivWithin f s x = 0 := derivWithin_zero_of_not_accPt <| mt AccPt.uniqueDiffWithinAt h theorem derivWithin_zero_of_notMem_closure (h : x āˆ‰ closure s) : derivWithin f s x = 0 := by rw [derivWithin, fderivWithin_zero_of_notMem_closure h, ContinuousLinearMap.zero_apply] @[deprecated (since := "2025-05-24")] alias derivWithin_zero_of_nmem_closure := derivWithin_zero_of_notMem_closure theorem deriv_zero_of_not_differentiableAt (h : ¬DifferentiableAt š•œ f x) : deriv f x = 0 := by unfold deriv rw [fderiv_zero_of_not_differentiableAt h] simp theorem differentiableAt_of_deriv_ne_zero (h : deriv f x ≠ 0) : DifferentiableAt š•œ f x := not_imp_comm.1 deriv_zero_of_not_differentiableAt h theorem UniqueDiffWithinAt.eq_deriv (s : Set š•œ) (H : UniqueDiffWithinAt š•œ s x) (h : HasDerivWithinAt f f' s x) (h₁ : HasDerivWithinAt f f₁' s x) : f' = f₁' := smulRight_one_eq_iff.mp <| UniqueDiffWithinAt.eq H h h₁ theorem hasDerivAtFilter_iff_isLittleO : HasDerivAtFilter f f' x L ↔ (fun x' : š•œ => f x' - f x - (x' - x) • f') =o[L] fun x' => x' - x := hasFDerivAtFilter_iff_isLittleO .. theorem hasDerivAtFilter_iff_tendsto : HasDerivAtFilter f f' x L ↔ Tendsto (fun x' : š•œ => ‖x' - x‖⁻¹ * ‖f x' - f x - (x' - x) • f'‖) L (š“ 0) := hasFDerivAtFilter_iff_tendsto theorem hasDerivWithinAt_iff_isLittleO : HasDerivWithinAt f f' s x ↔ (fun x' : š•œ => f x' - f x - (x' - x) • f') =o[š“[s] x] fun x' => x' - x := hasFDerivAtFilter_iff_isLittleO .. theorem hasDerivWithinAt_iff_tendsto : HasDerivWithinAt f f' s x ↔ Tendsto (fun x' => ‖x' - x‖⁻¹ * ‖f x' - f x - (x' - x) • f'‖) (š“[s] x) (š“ 0) := hasFDerivAtFilter_iff_tendsto theorem hasDerivAt_iff_isLittleO : HasDerivAt f f' x ↔ (fun x' : š•œ => f x' - f x - (x' - x) • f') =o[š“ x] fun x' => x' - x := hasFDerivAtFilter_iff_isLittleO .. theorem hasDerivAt_iff_tendsto : HasDerivAt f f' x ↔ Tendsto (fun x' => ‖x' - x‖⁻¹ * ‖f x' - f x - (x' - x) • f'‖) (š“ x) (š“ 0) := hasFDerivAtFilter_iff_tendsto theorem HasDerivAtFilter.isBigO_sub (h : HasDerivAtFilter f f' x L) : (fun x' => f x' - f x) =O[L] fun x' => x' - x := HasFDerivAtFilter.isBigO_sub h nonrec theorem HasDerivAtFilter.isBigO_sub_rev (hf : HasDerivAtFilter f f' x L) (hf' : f' ≠ 0) : (fun x' => x' - x) =O[L] fun x' => f x' - f x := suffices AntilipschitzWith ‖f'ā€–ā‚Šā»Ā¹ (smulRight (1 : š•œ →L[š•œ] š•œ) f') from hf.isBigO_sub_rev this AddMonoidHomClass.antilipschitz_of_bound (smulRight (1 : š•œ →L[š•œ] š•œ) f') fun x => by simp [norm_smul, ← div_eq_inv_mul, mul_div_cancel_rightā‚€ _ (mt norm_eq_zero.1 hf')] theorem HasStrictDerivAt.hasDerivAt (h : HasStrictDerivAt f f' x) : HasDerivAt f f' x := h.hasFDerivAt theorem hasDerivWithinAt_congr_set' {s t : Set š•œ} (y : š•œ) (h : s =į¶ [š“[{y}ᶜ] x] t) : HasDerivWithinAt f f' s x ↔ HasDerivWithinAt f f' t x := hasFDerivWithinAt_congr_set' y h theorem hasDerivWithinAt_congr_set {s t : Set š•œ} (h : s =į¶ [š“ x] t) : HasDerivWithinAt f f' s x ↔ HasDerivWithinAt f f' t x := hasFDerivWithinAt_congr_set h alias ⟨HasDerivWithinAt.congr_set, _⟩ := hasDerivWithinAt_congr_set @[simp] theorem hasDerivWithinAt_diff_singleton : HasDerivWithinAt f f' (s \ {x}) x ↔ HasDerivWithinAt f f' s x := hasFDerivWithinAt_diff_singleton _ @[simp] theorem hasDerivWithinAt_Ioi_iff_Ici [PartialOrder š•œ] : HasDerivWithinAt f f' (Ioi x) x ↔ HasDerivWithinAt f f' (Ici x) x := by rw [← Ici_diff_left, hasDerivWithinAt_diff_singleton] alias ⟨HasDerivWithinAt.Ici_of_Ioi, HasDerivWithinAt.Ioi_of_Ici⟩ := hasDerivWithinAt_Ioi_iff_Ici @[simp] theorem hasDerivWithinAt_Iio_iff_Iic [PartialOrder š•œ] : HasDerivWithinAt f f' (Iio x) x ↔ HasDerivWithinAt f f' (Iic x) x := by rw [← Iic_diff_right, hasDerivWithinAt_diff_singleton] alias ⟨HasDerivWithinAt.Iic_of_Iio, HasDerivWithinAt.Iio_of_Iic⟩ := hasDerivWithinAt_Iio_iff_Iic theorem HasDerivWithinAt.Ioi_iff_Ioo [LinearOrder š•œ] [OrderClosedTopology š•œ] {x y : š•œ} (h : x < y) : HasDerivWithinAt f f' (Ioo x y) x ↔ HasDerivWithinAt f f' (Ioi x) x := hasFDerivWithinAt_inter <| Iio_mem_nhds h alias ⟨HasDerivWithinAt.Ioi_of_Ioo, HasDerivWithinAt.Ioo_of_Ioi⟩ := HasDerivWithinAt.Ioi_iff_Ioo theorem hasDerivAt_iff_isLittleO_nhds_zero : HasDerivAt f f' x ↔ (fun h => f (x + h) - f x - h • f') =o[š“ 0] fun h => h := hasFDerivAt_iff_isLittleO_nhds_zero theorem HasDerivAtFilter.mono (h : HasDerivAtFilter f f' x Lā‚‚) (hst : L₁ ≤ Lā‚‚) : HasDerivAtFilter f f' x L₁ := HasFDerivAtFilter.mono h hst theorem HasDerivWithinAt.mono (h : HasDerivWithinAt f f' t x) (hst : s āŠ† t) : HasDerivWithinAt f f' s x := HasFDerivWithinAt.mono h hst theorem HasDerivWithinAt.mono_of_mem_nhdsWithin (h : HasDerivWithinAt f f' t x) (hst : t ∈ š“[s] x) : HasDerivWithinAt f f' s x := HasFDerivWithinAt.mono_of_mem_nhdsWithin h hst theorem HasDerivAt.hasDerivAtFilter (h : HasDerivAt f f' x) (hL : L ≤ š“ x) : HasDerivAtFilter f f' x L := HasFDerivAt.hasFDerivAtFilter h hL theorem HasDerivAt.hasDerivWithinAt (h : HasDerivAt f f' x) : HasDerivWithinAt f f' s x := HasFDerivAt.hasFDerivWithinAt h theorem HasDerivWithinAt.differentiableWithinAt (h : HasDerivWithinAt f f' s x) : DifferentiableWithinAt š•œ f s x := HasFDerivWithinAt.differentiableWithinAt h theorem HasDerivAt.differentiableAt (h : HasDerivAt f f' x) : DifferentiableAt š•œ f x := HasFDerivAt.differentiableAt h @[simp] theorem hasDerivWithinAt_univ : HasDerivWithinAt f f' univ x ↔ HasDerivAt f f' x := hasFDerivWithinAt_univ theorem HasDerivAt.unique (hā‚€ : HasDerivAt f fā‚€' x) (h₁ : HasDerivAt f f₁' x) : fā‚€' = f₁' := smulRight_one_eq_iff.mp <| hā‚€.hasFDerivAt.unique h₁ theorem hasDerivWithinAt_inter' (h : t ∈ š“[s] x) : HasDerivWithinAt f f' (s ∩ t) x ↔ HasDerivWithinAt f f' s x := hasFDerivWithinAt_inter' h theorem hasDerivWithinAt_inter (h : t ∈ š“ x) : HasDerivWithinAt f f' (s ∩ t) x ↔ HasDerivWithinAt f f' s x := hasFDerivWithinAt_inter h theorem HasDerivWithinAt.union (hs : HasDerivWithinAt f f' s x) (ht : HasDerivWithinAt f f' t x) : HasDerivWithinAt f f' (s ∪ t) x := hs.hasFDerivWithinAt.union ht.hasFDerivWithinAt theorem HasDerivWithinAt.hasDerivAt (h : HasDerivWithinAt f f' s x) (hs : s ∈ š“ x) : HasDerivAt f f' x := HasFDerivWithinAt.hasFDerivAt h hs theorem DifferentiableWithinAt.hasDerivWithinAt (h : DifferentiableWithinAt š•œ f s x) : HasDerivWithinAt f (derivWithin f s x) s x := h.hasFDerivWithinAt.hasDerivWithinAt theorem DifferentiableAt.hasDerivAt (h : DifferentiableAt š•œ f x) : HasDerivAt f (deriv f x) x := h.hasFDerivAt.hasDerivAt @[simp] theorem hasDerivAt_deriv_iff : HasDerivAt f (deriv f x) x ↔ DifferentiableAt š•œ f x := ⟨fun h => h.differentiableAt, fun h => h.hasDerivAt⟩ @[simp] theorem hasDerivWithinAt_derivWithin_iff : HasDerivWithinAt f (derivWithin f s x) s x ↔ DifferentiableWithinAt š•œ f s x := ⟨fun h => h.differentiableWithinAt, fun h => h.hasDerivWithinAt⟩ theorem DifferentiableOn.hasDerivAt (h : DifferentiableOn š•œ f s) (hs : s ∈ š“ x) : HasDerivAt f (deriv f x) x := (h.hasFDerivAt hs).hasDerivAt theorem HasDerivAt.deriv (h : HasDerivAt f f' x) : deriv f x = f' := h.differentiableAt.hasDerivAt.unique h theorem deriv_eq {f' : š•œ → F} (h : āˆ€ x, HasDerivAt f (f' x) x) : deriv f = f' := funext fun x => (h x).deriv theorem HasDerivWithinAt.derivWithin (h : HasDerivWithinAt f f' s x) (hxs : UniqueDiffWithinAt š•œ s x) : derivWithin f s x = f' := hxs.eq_deriv _ h.differentiableWithinAt.hasDerivWithinAt h theorem fderivWithin_derivWithin : (fderivWithin š•œ f s x : š•œ → F) 1 = derivWithin f s x := rfl theorem derivWithin_fderivWithin : smulRight (1 : š•œ →L[š•œ] š•œ) (derivWithin f s x) = fderivWithin š•œ f s x := by simp [derivWithin] theorem norm_derivWithin_eq_norm_fderivWithin : ‖derivWithin f s x‖ = ‖fderivWithin š•œ f s x‖ := by simp [← derivWithin_fderivWithin] theorem fderiv_deriv : (fderiv š•œ f x : š•œ → F) 1 = deriv f x := rfl @[simp] theorem fderiv_eq_smul_deriv (y : š•œ) : (fderiv š•œ f x : š•œ → F) y = y • deriv f x := by rw [← fderiv_deriv, ← ContinuousLinearMap.map_smul] simp only [smul_eq_mul, mul_one] theorem deriv_fderiv : smulRight (1 : š•œ →L[š•œ] š•œ) (deriv f x) = fderiv š•œ f x := by simp only [deriv, ContinuousLinearMap.smulRight_one_one] lemma fderiv_eq_deriv_mul {f : š•œ → š•œ} {x y : š•œ} : (fderiv š•œ f x : š•œ → š•œ) y = (deriv f x) * y := by simp [mul_comm] theorem norm_deriv_eq_norm_fderiv : ‖deriv f x‖ = ‖fderiv š•œ f x‖ := by simp [← deriv_fderiv] theorem DifferentiableAt.derivWithin (h : DifferentiableAt š•œ f x) (hxs : UniqueDiffWithinAt š•œ s x) : derivWithin f s x = deriv f x := by unfold _root_.derivWithin deriv rw [h.fderivWithin hxs] theorem HasDerivWithinAt.deriv_eq_zero (hd : HasDerivWithinAt f 0 s x) (H : UniqueDiffWithinAt š•œ s x) : deriv f x = 0 := (em' (DifferentiableAt š•œ f x)).elim deriv_zero_of_not_differentiableAt fun h => H.eq_deriv _ h.hasDerivAt.hasDerivWithinAt hd theorem derivWithin_of_mem_nhdsWithin (st : t ∈ š“[s] x) (ht : UniqueDiffWithinAt š•œ s x) (h : DifferentiableWithinAt š•œ f t x) : derivWithin f s x = derivWithin f t x := ((DifferentiableWithinAt.hasDerivWithinAt h).mono_of_mem_nhdsWithin st).derivWithin ht theorem derivWithin_subset (st : s āŠ† t) (ht : UniqueDiffWithinAt š•œ s x) (h : DifferentiableWithinAt š•œ f t x) : derivWithin f s x = derivWithin f t x := ((DifferentiableWithinAt.hasDerivWithinAt h).mono st).derivWithin ht theorem derivWithin_congr_set' (y : š•œ) (h : s =į¶ [š“[{y}ᶜ] x] t) : derivWithin f s x = derivWithin f t x := by simp only [derivWithin, fderivWithin_congr_set' y h] theorem derivWithin_congr_set (h : s =į¶ [š“ x] t) : derivWithin f s x = derivWithin f t x := by simp only [derivWithin, fderivWithin_congr_set h] @[simp] theorem derivWithin_univ : derivWithin f univ = deriv f := by ext unfold derivWithin deriv rw [fderivWithin_univ] theorem derivWithin_inter (ht : t ∈ š“ x) : derivWithin f (s ∩ t) x = derivWithin f s x := by unfold derivWithin rw [fderivWithin_inter ht] theorem derivWithin_of_mem_nhds (h : s ∈ š“ x) : derivWithin f s x = deriv f x := by simp only [derivWithin, deriv, fderivWithin_of_mem_nhds h] theorem derivWithin_of_isOpen (hs : IsOpen s) (hx : x ∈ s) : derivWithin f s x = deriv f x := derivWithin_of_mem_nhds (hs.mem_nhds hx) lemma deriv_eqOn {f' : š•œ → F} (hs : IsOpen s) (hf' : āˆ€ x ∈ s, HasDerivWithinAt f (f' x) s x) : s.EqOn (deriv f) f' := fun x hx ↦ by rw [← derivWithin_of_isOpen hs hx, (hf' _ hx).derivWithin <| hs.uniqueDiffWithinAt hx] theorem deriv_mem_iff {f : š•œ → F} {s : Set F} {x : š•œ} : deriv f x ∈ s ↔ DifferentiableAt š•œ f x ∧ deriv f x ∈ s ∨ ¬DifferentiableAt š•œ f x ∧ (0 : F) ∈ s := by by_cases hx : DifferentiableAt š•œ f x <;> simp [deriv_zero_of_not_differentiableAt, *] theorem derivWithin_mem_iff {f : š•œ → F} {t : Set š•œ} {s : Set F} {x : š•œ} : derivWithin f t x ∈ s ↔ DifferentiableWithinAt š•œ f t x ∧ derivWithin f t x ∈ s ∨ ¬DifferentiableWithinAt š•œ f t x ∧ (0 : F) ∈ s := by by_cases hx : DifferentiableWithinAt š•œ f t x <;> simp [derivWithin_zero_of_not_differentiableWithinAt, *] theorem differentiableWithinAt_Ioi_iff_Ici [PartialOrder š•œ] : DifferentiableWithinAt š•œ f (Ioi x) x ↔ DifferentiableWithinAt š•œ f (Ici x) x := ⟨fun h => h.hasDerivWithinAt.Ici_of_Ioi.differentiableWithinAt, fun h => h.hasDerivWithinAt.Ioi_of_Ici.differentiableWithinAt⟩ -- Golfed while splitting the file theorem derivWithin_Ioi_eq_Ici {E : Type*} [NormedAddCommGroup E] [NormedSpace ā„ E] (f : ā„ → E) (x : ā„) : derivWithin f (Ioi x) x = derivWithin f (Ici x) x := by by_cases H : DifferentiableWithinAt ā„ f (Ioi x) x Ā· have A := H.hasDerivWithinAt.Ici_of_Ioi have B := (differentiableWithinAt_Ioi_iff_Ici.1 H).hasDerivWithinAt simpa using (uniqueDiffOn_Ici x).eq left_mem_Ici A B Ā· rw [derivWithin_zero_of_not_differentiableWithinAt H, derivWithin_zero_of_not_differentiableWithinAt] rwa [differentiableWithinAt_Ioi_iff_Ici] at H section congr /-! ### Congruence properties of derivatives -/ theorem Filter.EventuallyEq.hasDerivAtFilter_iff (hā‚€ : fā‚€ =į¶ [L] f₁) (hx : fā‚€ x = f₁ x) (h₁ : fā‚€' = f₁') : HasDerivAtFilter fā‚€ fā‚€' x L ↔ HasDerivAtFilter f₁ f₁' x L := hā‚€.hasFDerivAtFilter_iff hx (by simp [h₁]) theorem HasDerivAtFilter.congr_of_eventuallyEq (h : HasDerivAtFilter f f' x L) (hL : f₁ =į¶ [L] f) (hx : f₁ x = f x) : HasDerivAtFilter f₁ f' x L := by rwa [hL.hasDerivAtFilter_iff hx rfl] theorem HasDerivWithinAt.congr_mono (h : HasDerivWithinAt f f' s x) (ht : āˆ€ x ∈ t, f₁ x = f x) (hx : f₁ x = f x) (h₁ : t āŠ† s) : HasDerivWithinAt f₁ f' t x := HasFDerivWithinAt.congr_mono h ht hx h₁ theorem HasDerivWithinAt.congr (h : HasDerivWithinAt f f' s x) (hs : āˆ€ x ∈ s, f₁ x = f x) (hx : f₁ x = f x) : HasDerivWithinAt f₁ f' s x := h.congr_mono hs hx (Subset.refl _) theorem HasDerivWithinAt.congr_of_mem (h : HasDerivWithinAt f f' s x) (hs : āˆ€ x ∈ s, f₁ x = f x) (hx : x ∈ s) : HasDerivWithinAt f₁ f' s x := h.congr hs (hs _ hx) theorem HasDerivWithinAt.congr_of_eventuallyEq (h : HasDerivWithinAt f f' s x) (h₁ : f₁ =į¶ [š“[s] x] f) (hx : f₁ x = f x) : HasDerivWithinAt f₁ f' s x := HasDerivAtFilter.congr_of_eventuallyEq h h₁ hx theorem Filter.EventuallyEq.hasDerivWithinAt_iff (h₁ : f₁ =į¶ [š“[s] x] f) (hx : f₁ x = f x) : HasDerivWithinAt f₁ f' s x ↔ HasDerivWithinAt f f' s x := ⟨fun h' ↦ h'.congr_of_eventuallyEq h₁.symm hx.symm, fun h' ↦ h'.congr_of_eventuallyEq h₁ hx⟩ theorem HasDerivWithinAt.congr_of_eventuallyEq_of_mem (h : HasDerivWithinAt f f' s x) (h₁ : f₁ =į¶ [š“[s] x] f) (hx : x ∈ s) : HasDerivWithinAt f₁ f' s x := h.congr_of_eventuallyEq h₁ (h₁.eq_of_nhdsWithin hx) theorem Filter.EventuallyEq.hasDerivWithinAt_iff_of_mem (h₁ : f₁ =į¶ [š“[s] x] f) (hx : x ∈ s) : HasDerivWithinAt f₁ f' s x ↔ HasDerivWithinAt f 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 HasStrictDerivAt.congr_deriv (h : HasStrictDerivAt f f' x) (h' : f' = g') : HasStrictDerivAt f g' x := h.congr_fderiv <| congr_arg _ h' theorem HasDerivAt.congr_deriv (h : HasDerivAt f f' x) (h' : f' = g') : HasDerivAt f g' x := HasFDerivAt.congr_fderiv h <| congr_arg _ h' theorem HasDerivWithinAt.congr_deriv (h : HasDerivWithinAt f f' s x) (h' : f' = g') : HasDerivWithinAt f g' s x := HasFDerivWithinAt.congr_fderiv h <| congr_arg _ h' theorem HasDerivAt.congr_of_eventuallyEq (h : HasDerivAt f f' x) (h₁ : f₁ =į¶ [š“ x] f) : HasDerivAt f₁ f' x := HasDerivAtFilter.congr_of_eventuallyEq h h₁ (mem_of_mem_nhds h₁ :) theorem Filter.EventuallyEq.hasDerivAt_iff (h : fā‚€ =į¶ [š“ x] f₁) : HasDerivAt fā‚€ f' x ↔ HasDerivAt f₁ f' x := ⟨fun h' ↦ h'.congr_of_eventuallyEq h.symm, fun h' ↦ h'.congr_of_eventuallyEq h⟩ theorem Filter.EventuallyEq.derivWithin_eq (hs : f₁ =į¶ [š“[s] x] f) (hx : f₁ x = f x) : derivWithin f₁ s x = derivWithin f s x := by unfold derivWithin rw [hs.fderivWithin_eq hx] theorem Filter.EventuallyEq.derivWithin_eq_of_mem (hs : f₁ =į¶ [š“[s] x] f) (hx : x ∈ s) : derivWithin f₁ s x = derivWithin f s x := hs.derivWithin_eq <| hs.self_of_nhdsWithin hx theorem Filter.EventuallyEq.derivWithin_eq_of_nhds (hs : f₁ =į¶ [š“ x] f) : derivWithin f₁ s x = derivWithin f s x := (hs.filter_mono nhdsWithin_le_nhds).derivWithin_eq hs.self_of_nhds theorem derivWithin_congr (hs : EqOn f₁ f s) (hx : f₁ x = f x) : derivWithin f₁ s x = derivWithin f s x := by unfold derivWithin rw [fderivWithin_congr hs hx] lemma Set.EqOn.deriv {f g : š•œ → F} {s : Set š•œ} (hfg : s.EqOn f g) (hs : IsOpen s) : s.EqOn (deriv f) (deriv g) := by intro x hx rw [← derivWithin_of_isOpen hs hx, ← derivWithin_of_isOpen hs hx] exact derivWithin_congr hfg (hfg hx) theorem Filter.EventuallyEq.deriv_eq (hL : f₁ =į¶ [š“ x] f) : deriv f₁ x = deriv f x := by unfold deriv rwa [Filter.EventuallyEq.fderiv_eq] protected theorem Filter.EventuallyEq.deriv (h : f₁ =į¶ [š“ x] f) : deriv f₁ =į¶ [š“ x] deriv f := h.eventuallyEq_nhds.mono fun _ h => h.deriv_eq end congr section id /-! ### Derivative of the identity -/ variable (s x L) theorem hasDerivAtFilter_id : HasDerivAtFilter id 1 x L := (hasFDerivAtFilter_id x L).hasDerivAtFilter theorem hasDerivWithinAt_id : HasDerivWithinAt id 1 s x := hasDerivAtFilter_id _ _ theorem hasDerivAt_id : HasDerivAt id 1 x := hasDerivAtFilter_id _ _ theorem hasDerivAt_id' : HasDerivAt (fun x : š•œ => x) 1 x := hasDerivAtFilter_id _ _ theorem hasStrictDerivAt_id : HasStrictDerivAt id 1 x := (hasStrictFDerivAt_id x).hasStrictDerivAt theorem deriv_id : deriv id x = 1 := HasDerivAt.deriv (hasDerivAt_id x) @[simp] theorem deriv_id' : deriv (@id š•œ) = fun _ => 1 := funext deriv_id /-- Variant with `fun x => x` rather than `id` -/ @[simp] theorem deriv_id'' : (deriv fun x : š•œ => x) = fun _ => 1 := deriv_id' theorem derivWithin_id (hxs : UniqueDiffWithinAt š•œ s x) : derivWithin id s x = 1 := (hasDerivWithinAt_id x s).derivWithin hxs /-- Variant with `fun x => x` rather than `id` -/ theorem derivWithin_id' (hxs : UniqueDiffWithinAt š•œ s x) : derivWithin (fun x => x) s x = 1 := derivWithin_id x s hxs end id section Const /-! ### Derivative of constant functions This include the constant functions `0`, `1`, `Nat.cast n`, `Int.cast z`, and other numerals. -/ variable (c : F) (s x L) theorem hasDerivAtFilter_const : HasDerivAtFilter (fun _ => c) 0 x L := (hasFDerivAtFilter_const c x L).hasDerivAtFilter theorem hasDerivAtFilter_zero : HasDerivAtFilter (0 : š•œ → F) 0 x L := hasDerivAtFilter_const _ _ _ theorem hasDerivAtFilter_one [One F] : HasDerivAtFilter (1 : š•œ → F) 0 x L := hasDerivAtFilter_const _ _ _ theorem hasDerivAtFilter_natCast [NatCast F] (n : ā„•) : HasDerivAtFilter (n : š•œ → F) 0 x L := hasDerivAtFilter_const _ _ _ theorem hasDerivAtFilter_intCast [IntCast F] (z : ℤ) : HasDerivAtFilter (z : š•œ → F) 0 x L := hasDerivAtFilter_const _ _ _ theorem hasDerivAtFilter_ofNat (n : ā„•) [OfNat F n] : HasDerivAtFilter (ofNat(n) : š•œ → F) 0 x L := hasDerivAtFilter_const _ _ _ theorem hasStrictDerivAt_const : HasStrictDerivAt (fun _ => c) 0 x := (hasStrictFDerivAt_const c x).hasStrictDerivAt theorem hasStrictDerivAt_zero : HasStrictDerivAt (0 : š•œ → F) 0 x := hasStrictDerivAt_const _ _ theorem hasStrictDerivAt_one [One F] : HasStrictDerivAt (1 : š•œ → F) 0 x := hasStrictDerivAt_const _ _ theorem hasStrictDerivAt_natCast [NatCast F] (n : ā„•) : HasStrictDerivAt (n : š•œ → F) 0 x := hasStrictDerivAt_const _ _ theorem hasStrictDerivAt_intCast [IntCast F] (z : ℤ) : HasStrictDerivAt (z : š•œ → F) 0 x := hasStrictDerivAt_const _ _ theorem HasStrictDerivAt_ofNat (n : ā„•) [OfNat F n] : HasStrictDerivAt (ofNat(n) : š•œ → F) 0 x := hasStrictDerivAt_const _ _ theorem hasDerivWithinAt_const : HasDerivWithinAt (fun _ => c) 0 s x := hasDerivAtFilter_const _ _ _ theorem hasDerivWithinAt_zero : HasDerivWithinAt (0 : š•œ → F) 0 s x := hasDerivAtFilter_zero _ _ theorem hasDerivWithinAt_one [One F] : HasDerivWithinAt (1 : š•œ → F) 0 s x := hasDerivWithinAt_const _ _ _ theorem hasDerivWithinAt_natCast [NatCast F] (n : ā„•) : HasDerivWithinAt (n : š•œ → F) 0 s x := hasDerivWithinAt_const _ _ _ theorem hasDerivWithinAt_intCast [IntCast F] (z : ℤ) : HasDerivWithinAt (z : š•œ → F) 0 s x := hasDerivWithinAt_const _ _ _ theorem hasDerivWithinAt_ofNat (n : ā„•) [OfNat F n] : HasDerivWithinAt (ofNat(n) : š•œ → F) 0 s x := hasDerivWithinAt_const _ _ _ theorem hasDerivAt_const : HasDerivAt (fun _ => c) 0 x := hasDerivAtFilter_const _ _ _ theorem hasDerivAt_zero : HasDerivAt (0 : š•œ → F) 0 x := hasDerivAtFilter_zero _ _ theorem hasDerivAt_one [One F] : HasDerivAt (1 : š•œ → F) 0 x := hasDerivAt_const _ _ theorem hasDerivAt_natCast [NatCast F] (n : ā„•) : HasDerivAt (n : š•œ → F) 0 x := hasDerivAt_const _ _ theorem hasDerivAt_intCast [IntCast F] (z : ℤ) : HasDerivAt (z : š•œ → F) 0 x := hasDerivAt_const _ _ theorem hasDerivAt_ofNat (n : ā„•) [OfNat F n] : HasDerivAt (ofNat(n) : š•œ → F) 0 x := hasDerivAt_const _ _ theorem deriv_const : deriv (fun _ => c) x = 0 := HasDerivAt.deriv (hasDerivAt_const x c) @[simp] theorem deriv_const' : (deriv fun _ : š•œ => c) = fun _ => 0 := funext fun x => deriv_const x c @[simp] theorem deriv_zero : deriv (0 : š•œ → F) = 0 := funext fun _ => deriv_const _ _ @[simp] theorem deriv_one [One F] : deriv (1 : š•œ → F) = 0 := funext fun _ => deriv_const _ _ @[simp] theorem deriv_natCast [NatCast F] (n : ā„•) : deriv (n : š•œ → F) = 0 := funext fun _ => deriv_const _ _ @[simp] theorem deriv_intCast [IntCast F] (z : ℤ) : deriv (z : š•œ → F) = 0 := funext fun _ => deriv_const _ _ @[simp low] theorem deriv_ofNat (n : ā„•) [OfNat F n] : deriv (ofNat(n) : š•œ → F) = 0 := funext fun _ => deriv_const _ _ @[simp] theorem derivWithin_fun_const : derivWithin (fun _ => c) s = 0 := by ext; simp [derivWithin] @[simp] theorem derivWithin_const : derivWithin (Function.const š•œ c) s = 0 := derivWithin_fun_const _ _ @[simp] theorem derivWithin_zero : derivWithin (0 : š•œ → F) s = 0 := derivWithin_const _ _ @[simp] theorem derivWithin_one [One F] : derivWithin (1 : š•œ → F) s = 0 := derivWithin_const _ _ @[simp] theorem derivWithin_natCast [NatCast F] (n : ā„•) : derivWithin (n : š•œ → F) s = 0 := derivWithin_const _ _ @[simp] theorem derivWithin_intCast [IntCast F] (z : ℤ) : derivWithin (z : š•œ → F) s = 0 := derivWithin_const _ _ @[simp low] theorem derivWithin_ofNat (n : ā„•) [OfNat F n] : derivWithin (ofNat(n) : š•œ → F) s = 0 := derivWithin_const _ _ end Const section Continuous /-! ### Continuity of a function admitting a derivative -/ nonrec theorem HasDerivAtFilter.tendsto_nhds (hL : L ≤ š“ x) (h : HasDerivAtFilter f f' x L) : Tendsto f L (š“ (f x)) := h.tendsto_nhds hL theorem HasDerivWithinAt.continuousWithinAt (h : HasDerivWithinAt f f' s x) : ContinuousWithinAt f s x := HasDerivAtFilter.tendsto_nhds inf_le_left h theorem HasDerivAt.continuousAt (h : HasDerivAt f f' x) : ContinuousAt f x := HasDerivAtFilter.tendsto_nhds le_rfl h theorem HasDerivWithinAt.continuousOn {f f' : š•œ → F} (h : āˆ€ x ∈ s, HasDerivWithinAt f (f' x) s x) : ContinuousOn f s := fun x hx => (h x hx).continuousWithinAt protected theorem HasDerivAt.continuousOn {f f' : š•œ → F} (hderiv : āˆ€ x ∈ s, HasDerivAt f (f' x) x) : ContinuousOn f s := fun x hx => (hderiv x hx).continuousAt.continuousWithinAt end Continuous 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 HasDerivAt.le_of_lip' {f : š•œ → F} {f' : F} {xā‚€ : š•œ} (hf : HasDerivAt f f' xā‚€) {C : ā„} (hCā‚€ : 0 ≤ C) (hlip : āˆ€į¶  x in š“ xā‚€, ‖f x - f x₀‖ ≤ C * ‖x - x₀‖) : ‖f'‖ ≤ C := by simpa using HasFDerivAt.le_of_lip' hf.hasFDerivAt hCā‚€ hlip /-- 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 HasDerivAt.le_of_lipschitzOn {f : š•œ → F} {f' : F} {xā‚€ : š•œ} (hf : HasDerivAt f f' xā‚€) {s : Set š•œ} (hs : s ∈ š“ xā‚€) {C : ā„ā‰„0} (hlip : LipschitzOnWith C f s) : ‖f'‖ ≤ C := by simpa using HasFDerivAt.le_of_lipschitzOn hf.hasFDerivAt hs hlip /-- 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 HasDerivAt.le_of_lipschitz {f : š•œ → F} {f' : F} {xā‚€ : š•œ} (hf : HasDerivAt f f' xā‚€) {C : ā„ā‰„0} (hlip : LipschitzWith C f) : ‖f'‖ ≤ C := by simpa using HasFDerivAt.le_of_lipschitz hf.hasFDerivAt hlip /-- 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_deriv_le_of_lip' {f : š•œ → F} {xā‚€ : š•œ} {C : ā„} (hCā‚€ : 0 ≤ C) (hlip : āˆ€į¶  x in š“ xā‚€, ‖f x - f x₀‖ ≤ C * ‖x - x₀‖) : ‖deriv f x₀‖ ≤ C := by simpa [norm_deriv_eq_norm_fderiv] using norm_fderiv_le_of_lip' š•œ hCā‚€ hlip /-- 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 `deriv`. -/ theorem norm_deriv_le_of_lipschitzOn {f : š•œ → F} {xā‚€ : š•œ} {s : Set š•œ} (hs : s ∈ š“ xā‚€) {C : ā„ā‰„0} (hlip : LipschitzOnWith C f s) : ‖deriv f x₀‖ ≤ C := by simpa [norm_deriv_eq_norm_fderiv] using norm_fderiv_le_of_lipschitzOn š•œ hs hlip /-- Converse to the mean value inequality: if `f` is `C`-lipschitz then its derivative at `xā‚€` has norm bounded by `C`. Version using `deriv`. -/ theorem norm_deriv_le_of_lipschitz {f : š•œ → F} {xā‚€ : š•œ} {C : ā„ā‰„0} (hlip : LipschitzWith C f) : ‖deriv f x₀‖ ≤ C := by simpa [norm_deriv_eq_norm_fderiv] using norm_fderiv_le_of_lipschitz š•œ hlip end MeanValue section Semilinear variable {σ σ' : RingHom š•œ š•œ} [RingHomIsometric σ] [RingHomInvPair σ σ'] {F' : Type*} [NormedAddCommGroup F'] [NormedSpace š•œ F'] (L : F →SL[σ] F') variable (σ') /-- If `L` is a `σ`-semilinear map, and `f` has FrĆ©chet derivative `f'` at `x`, then `L ∘ f ∘ σ⁻¹` has FrĆ©chet derivative `L ∘ f'` at `σ x`. -/ lemma HasDerivAt.comp_semilinear (hf : HasDerivAt f f' x) : HasDerivAt (L ∘ f ∘ σ') (L f') (σ x) := by have : RingHomIsometric σ' := .inv σ let R : š•œ →SL[σ'] š•œ := ⟨σ'.toSemilinearMap, σ'.isometry.continuous⟩ have hR (k : š•œ) : R k = σ' k := rfl rw [hasDerivAt_iff_hasFDerivAt] convert HasFDerivAt.comp_semilinear L R (f' := (1 : š•œ →L[š•œ] š•œ).smulRight f') ?_ Ā· ext simp [R] Ā· rwa [← hasDerivAt_iff_hasFDerivAt, hR, RingHomInvPair.comp_apply_eq] /-- If `f` is differentiable at `x`, and `L` is `σ`-semilinear, then `L ∘ f ∘ σ⁻¹` is differentiable at `σ x`. -/ lemma DifferentiableAt.comp_semilinear₁ (hf : DifferentiableAt š•œ f x) : DifferentiableAt š•œ (L ∘ f ∘ σ') (σ x) := (hf.hasDerivAt.comp_semilinear σ' L).differentiableAt variable (σ) {f : š•œ → š•œ} {f' : š•œ} /-- If `f` has derivative `f'` at `x`, and `σ, σ'` are mutually inverse normed-ring automorphisms, then `σ ∘ f ∘ σ'` has derivative `σ f'` at `σ x`. -/ lemma HasDerivAt.comp_ringHom (hf : HasDerivAt f f' x) : HasDerivAt (σ ∘ f ∘ σ') (σ f') (σ x) := hf.comp_semilinear σ' ⟨σ.toSemilinearMap, σ.isometry.continuous⟩ /-- If `f` is differentiable at `x`, and `L` is `σ`-semilinear, then `L ∘ f ∘ σ⁻¹` is differentiable at `σ x`. -/ lemma DifferentiableAt.comp_ringHom (hf : DifferentiableAt š•œ f x) : DifferentiableAt š•œ (σ ∘ f ∘ σ') (σ x) := (hf.hasDerivAt.comp_ringHom σ σ').differentiableAt end Semilinear
.lake/packages/mathlib/Mathlib/Analysis/Calculus/Deriv/Slope.lean
import Mathlib.Analysis.Calculus.Deriv.Add import Mathlib.LinearAlgebra.AffineSpace.Slope import Mathlib.Topology.Algebra.Module.PerfectSpace /-! # Derivative as the limit of the slope In this file we relate the derivative of a function with its definition from a standard undergraduate course as the limit of the slope `(f y - f x) / (y - x)` as `y` tends to `š“[≠] x`. Since we are talking about functions taking values in a normed space instead of the base field, we use `slope f x y = (y - x)⁻¹ • (f y - f x)` instead of division. We also prove some estimates on the upper/lower limits of the slope in terms of the derivative. For a more detailed overview of one-dimensional derivatives in mathlib, see the module docstring of `analysis/calculus/deriv/basic`. ## Keywords derivative, slope -/ universe u v open scoped Topology open Filter TopologicalSpace Set section NormedField variable {š•œ : Type u} [NontriviallyNormedField š•œ] variable {F : Type v} [NormedAddCommGroup F] [NormedSpace š•œ F] variable {f : š•œ → F} variable {f' : F} variable {x : š•œ} variable {s : Set š•œ} /-- If the domain has dimension one, then FrĆ©chet derivative is equivalent to the classical definition with a limit. In this version we have to take the limit along the subset `{x}ᶜ`, because for `y=x` the slope equals zero due to the convention `0⁻¹=0`. -/ theorem hasDerivAtFilter_iff_tendsto_slope {x : š•œ} {L : Filter š•œ} : HasDerivAtFilter f f' x L ↔ Tendsto (slope f x) (L āŠ“ š“Ÿ {x}ᶜ) (š“ f') := calc HasDerivAtFilter f f' x L ↔ Tendsto (fun y ↦ slope f x y - (y - x)⁻¹ • (y - x) • f') L (š“ 0) := by simp only [hasDerivAtFilter_iff_tendsto, ← norm_inv, ← norm_smul, ← tendsto_zero_iff_norm_tendsto_zero, slope_def_module, smul_sub] _ ↔ Tendsto (fun y ↦ slope f x y - (y - x)⁻¹ • (y - x) • f') (L āŠ“ š“Ÿ {x}ᶜ) (š“ 0) := .symm <| tendsto_inf_principal_nhds_iff_of_forall_eq <| by simp _ ↔ Tendsto (fun y ↦ slope f x y - f') (L āŠ“ š“Ÿ {x}ᶜ) (š“ 0) := tendsto_congr' <| by refine (EqOn.eventuallyEq fun y hy ↦ ?_).filter_mono inf_le_right rw [inv_smul_smulā‚€ (sub_ne_zero.2 hy) f'] _ ↔ Tendsto (slope f x) (L āŠ“ š“Ÿ {x}ᶜ) (š“ f') := by rw [← nhds_translation_sub f', tendsto_comap_iff]; rfl theorem hasDerivWithinAt_iff_tendsto_slope : HasDerivWithinAt f f' s x ↔ Tendsto (slope f x) (š“[s \ {x}] x) (š“ f') := by simp only [HasDerivWithinAt, nhdsWithin, diff_eq, ← inf_assoc, inf_principal.symm] exact hasDerivAtFilter_iff_tendsto_slope theorem hasDerivWithinAt_iff_tendsto_slope' (hs : x āˆ‰ s) : HasDerivWithinAt f f' s x ↔ Tendsto (slope f x) (š“[s] x) (š“ f') := by rw [hasDerivWithinAt_iff_tendsto_slope, diff_singleton_eq_self hs] theorem hasDerivAt_iff_tendsto_slope : HasDerivAt f f' x ↔ Tendsto (slope f x) (š“[≠] x) (š“ f') := hasDerivAtFilter_iff_tendsto_slope alias ⟨HasDerivAt.tendsto_slope, _⟩ := hasDerivAt_iff_tendsto_slope theorem hasDerivAt_iff_tendsto_slope_left_right [LinearOrder š•œ] : HasDerivAt f f' x ↔ Tendsto (slope f x) (š“[<] x) (š“ f') ∧ Tendsto (slope f x) (š“[>] x) (š“ f') := by simp [hasDerivAt_iff_tendsto_slope, ← Iio_union_Ioi, nhdsWithin_union] theorem hasDerivAt_iff_tendsto_slope_zero : HasDerivAt f f' x ↔ Tendsto (fun t ↦ t⁻¹ • (f (x + t) - f x)) (š“[≠] 0) (š“ f') := by have : š“[≠] x = Filter.map (fun t ↦ x + t) (š“[≠] 0) := by simp [nhdsWithin, map_add_left_nhds_zero x, Filter.map_inf, add_right_injective x] simp [hasDerivAt_iff_tendsto_slope, this, slope, Function.comp_def] alias ⟨HasDerivAt.tendsto_slope_zero, _⟩ := hasDerivAt_iff_tendsto_slope_zero theorem HasDerivAt.tendsto_slope_zero_right [Preorder š•œ] (h : HasDerivAt f f' x) : Tendsto (fun t ↦ t⁻¹ • (f (x + t) - f x)) (š“[>] 0) (š“ f') := h.tendsto_slope_zero.mono_left (nhdsGT_le_nhdsNE 0) theorem HasDerivAt.tendsto_slope_zero_left [Preorder š•œ] (h : HasDerivAt f f' x) : Tendsto (fun t ↦ t⁻¹ • (f (x + t) - f x)) (š“[<] 0) (š“ f') := h.tendsto_slope_zero.mono_left (nhdsLT_le_nhdsNE 0) /-- Given a set `t` such that `s ∩ t` is dense in `s`, then the range of `derivWithin f s` is contained in the closure of the submodule spanned by the image of `t`. -/ theorem range_derivWithin_subset_closure_span_image (f : š•œ → F) {s t : Set š•œ} (h : s āŠ† closure (s ∩ t)) : range (derivWithin f s) āŠ† closure (Submodule.span š•œ (f '' t)) := by rintro - ⟨x, rfl⟩ by_cases H : UniqueDiffWithinAt š•œ s x; swap Ā· simpa [derivWithin_zero_of_not_uniqueDiffWithinAt H] using subset_closure (zero_mem _) by_cases H' : DifferentiableWithinAt š•œ f s x; swap Ā· rw [derivWithin_zero_of_not_differentiableWithinAt H'] exact subset_closure (zero_mem _) have I : (š“[(s ∩ t) \ {x}] x).NeBot := by rw [← accPt_principal_iff_nhdsWithin, ← uniqueDiffWithinAt_iff_accPt] exact H.mono_closure h have : Tendsto (slope f x) (š“[(s ∩ t) \ {x}] x) (š“ (derivWithin f s x)) := by apply Tendsto.mono_left (hasDerivWithinAt_iff_tendsto_slope.1 H'.hasDerivWithinAt) rw [inter_comm, inter_diff_assoc] exact nhdsWithin_mono _ inter_subset_right rw [← closure_closure, ← Submodule.topologicalClosure_coe] apply mem_closure_of_tendsto this filter_upwards [self_mem_nhdsWithin] with y hy simp only [slope, vsub_eq_sub, SetLike.mem_coe] refine Submodule.smul_mem _ _ (Submodule.sub_mem _ ?_ ?_) Ā· apply Submodule.le_topologicalClosure apply Submodule.subset_span exact mem_image_of_mem _ hy.1.2 Ā· apply Submodule.closure_subset_topologicalClosure_span suffices A : f x ∈ closure (f '' (s ∩ t)) from closure_mono (image_mono inter_subset_right) A apply ContinuousWithinAt.mem_closure_image Ā· apply H'.continuousWithinAt.mono inter_subset_left rw [mem_closure_iff_nhdsWithin_neBot] exact I.mono (nhdsWithin_mono _ diff_subset) /-- Given a dense set `t`, then the range of `deriv f` is contained in the closure of the submodule spanned by the image of `t`. -/ theorem range_deriv_subset_closure_span_image (f : š•œ → F) {t : Set š•œ} (h : Dense t) : range (deriv f) āŠ† closure (Submodule.span š•œ (f '' t)) := by rw [← derivWithin_univ] apply range_derivWithin_subset_closure_span_image simp [dense_iff_closure_eq.1 h] theorem isSeparable_range_derivWithin [SeparableSpace š•œ] (f : š•œ → F) (s : Set š•œ) : IsSeparable (range (derivWithin f s)) := by obtain ⟨t, ts, t_count, ht⟩ : ∃ t, t āŠ† s ∧ Set.Countable t ∧ s āŠ† closure t := (IsSeparable.of_separableSpace s).exists_countable_dense_subset have : s āŠ† closure (s ∩ t) := by rwa [inter_eq_self_of_subset_right ts] apply IsSeparable.mono _ (range_derivWithin_subset_closure_span_image f this) exact (Countable.image t_count f).isSeparable.span.closure theorem isSeparable_range_deriv [SeparableSpace š•œ] (f : š•œ → F) : IsSeparable (range (deriv f)) := by rw [← derivWithin_univ] exact isSeparable_range_derivWithin _ _ lemma HasDerivAt.continuousAt_div [DecidableEq š•œ] {f : š•œ → š•œ} {c a : š•œ} (hf : HasDerivAt f a c) : ContinuousAt (Function.update (fun x ↦ (f x - f c) / (x - c)) c a) c := by rw [← slope_fun_def_field] exact continuousAt_update_same.mpr <| hasDerivAt_iff_tendsto_slope.mp hf section Order variable [LinearOrder š•œ] [IsStrictOrderedRing š•œ] [OrderTopology š•œ] {g : š•œ → š•œ} {g' : š•œ} /-- If a monotone function has a derivative within a set at a non-isolated point, then this derivative is nonnegative. -/ lemma HasDerivWithinAt.nonneg_of_monotoneOn (hx : AccPt x (š“Ÿ s)) (hd : HasDerivWithinAt g g' s x) (hg : MonotoneOn g s) : 0 ≤ g' := by have : (š“[s \ {x}] x).NeBot := accPt_principal_iff_nhdsWithin.mp hx have h'g : MonotoneOn g (insert x s) := hg.insert_of_continuousWithinAt hx.clusterPt hd.continuousWithinAt have : Tendsto (slope g x) (š“[s \ {x}] x) (š“ g') := hasDerivWithinAt_iff_tendsto_slope.mp hd apply ge_of_tendsto this filter_upwards [self_mem_nhdsWithin] with y hy simp only [mem_diff, mem_singleton_iff] at hy exact h'g.slope_nonneg (by simp) (by simp [hy]) /-- The derivative within a set of a monotone function is nonnegative. -/ lemma MonotoneOn.derivWithin_nonneg (hg : MonotoneOn g s) : 0 ≤ derivWithin g s x := by by_cases hd : DifferentiableWithinAt š•œ g s x; swap Ā· simp [derivWithin_zero_of_not_differentiableWithinAt hd] by_cases hx : AccPt x (š“Ÿ s); swap Ā· simp [derivWithin_zero_of_not_accPt hx] exact hd.hasDerivWithinAt.nonneg_of_monotoneOn hx hg /-- If a monotone function has a derivative, then this derivative is nonnegative. -/ lemma HasDerivAt.nonneg_of_monotone (hd : HasDerivAt g g' x) (hg : Monotone g) : 0 ≤ g' := by rw [← hasDerivWithinAt_univ] at hd apply hd.nonneg_of_monotoneOn _ (hg.monotoneOn _) exact PerfectSpace.univ_preperfect _ (mem_univ _) /-- The derivative of a monotone function is nonnegative. -/ lemma Monotone.deriv_nonneg (hg : Monotone g) : 0 ≤ deriv g x := by rw [← derivWithin_univ] exact (hg.monotoneOn univ).derivWithin_nonneg /-- If an antitone function has a derivative within a set at a non-isolated point, then this derivative is nonpositive. -/ lemma HasDerivWithinAt.nonpos_of_antitoneOn (hx : AccPt x (š“Ÿ s)) (hd : HasDerivWithinAt g g' s x) (hg : AntitoneOn g s) : g' ≤ 0 := by have : MonotoneOn (-g) s := fun x hx y hy hxy ↦ by simpa using hg hx hy hxy simpa using hd.neg.nonneg_of_monotoneOn hx this /-- The derivative within a set of an antitone function is nonpositive. -/ lemma AntitoneOn.derivWithin_nonpos (hg : AntitoneOn g s) : derivWithin g s x ≤ 0 := by simpa [derivWithin.fun_neg] using hg.neg.derivWithin_nonneg /-- If an antitone function has a derivative, then this derivative is nonpositive. -/ lemma HasDerivAt.nonpos_of_antitone (hd : HasDerivAt g g' x) (hg : Antitone g) : g' ≤ 0 := by rw [← hasDerivWithinAt_univ] at hd apply hd.nonpos_of_antitoneOn _ (hg.antitoneOn _) exact PerfectSpace.univ_preperfect _ (mem_univ _) /-- The derivative of an antitone function is nonpositive. -/ lemma Antitone.deriv_nonpos (hg : Antitone g) : deriv g x ≤ 0 := by rw [← derivWithin_univ] exact (hg.antitoneOn univ).derivWithin_nonpos end Order end NormedField /-! ### Upper estimates on liminf and limsup -/ section Real variable {f : ā„ → ā„} {f' : ā„} {s : Set ā„} {x : ā„} {r : ā„} theorem HasDerivWithinAt.limsup_slope_le (hf : HasDerivWithinAt f f' s x) (hr : f' < r) : āˆ€į¶  z in š“[s \ {x}] x, slope f x z < r := hasDerivWithinAt_iff_tendsto_slope.1 hf (IsOpen.mem_nhds isOpen_Iio hr) theorem HasDerivWithinAt.limsup_slope_le' (hf : HasDerivWithinAt f f' s x) (hs : x āˆ‰ s) (hr : f' < r) : āˆ€į¶  z in š“[s] x, slope f x z < r := (hasDerivWithinAt_iff_tendsto_slope' hs).1 hf (IsOpen.mem_nhds isOpen_Iio hr) theorem HasDerivWithinAt.liminf_right_slope_le (hf : HasDerivWithinAt f f' (Ici x) x) (hr : f' < r) : ∃ᶠ z in š“[>] x, slope f x z < r := (hf.Ioi_of_Ici.limsup_slope_le' (lt_irrefl x) hr).frequently end Real section RealSpace open Metric variable {E : Type u} [NormedAddCommGroup E] [NormedSpace ā„ E] {f : ā„ → E} {f' : E} {s : Set ā„} {x r : ā„} /-- If `f` has derivative `f'` within `s` at `x`, then for any `r > ‖f'‖` the ratio `‖f z - f x‖ / ‖z - x‖` is less than `r` in some neighborhood of `x` within `s`. In other words, the limit superior of this ratio as `z` tends to `x` along `s` is less than or equal to `‖f'‖`. -/ theorem HasDerivWithinAt.limsup_norm_slope_le (hf : HasDerivWithinAt f f' s x) (hr : ‖f'‖ < r) : āˆ€į¶  z in š“[s] x, ‖z - x‖⁻¹ * ‖f z - f x‖ < r := by have hrā‚€ : 0 < r := lt_of_le_of_lt (norm_nonneg f') hr have A : āˆ€į¶  z in š“[s \ {x}] x, ‖(z - x)⁻¹ • (f z - f x)‖ ∈ Iio r := (hasDerivWithinAt_iff_tendsto_slope.1 hf).norm (IsOpen.mem_nhds isOpen_Iio hr) have B : āˆ€į¶  z in š“[{x}] x, ‖(z - x)⁻¹ • (f z - f x)‖ ∈ Iio r := mem_of_superset self_mem_nhdsWithin (singleton_subset_iff.2 <| by simp [hrā‚€]) have C := mem_sup.2 ⟨A, B⟩ rw [← nhdsWithin_union, diff_union_self, nhdsWithin_union, mem_sup] at C filter_upwards [C.1] simp only [norm_smul, mem_Iio, norm_inv] exact fun _ => id /-- If `f` has derivative `f'` within `s` at `x`, then for any `r > ‖f'‖` the ratio `(‖f z‖ - ‖f x‖) / ‖z - x‖` is less than `r` in some neighborhood of `x` within `s`. In other words, the limit superior of this ratio as `z` tends to `x` along `s` is less than or equal to `‖f'‖`. This lemma is a weaker version of `HasDerivWithinAt.limsup_norm_slope_le` where `‖f z‖ - ‖f x‖` is replaced by `‖f z - f x‖`. -/ theorem HasDerivWithinAt.limsup_slope_norm_le (hf : HasDerivWithinAt f f' s x) (hr : ‖f'‖ < r) : āˆ€į¶  z in š“[s] x, ‖z - x‖⁻¹ * (‖f z‖ - ‖f x‖) < r := by apply (hf.limsup_norm_slope_le hr).mono intro z hz refine lt_of_le_of_lt (mul_le_mul_of_nonneg_left (norm_sub_norm_le _ _) ?_) hz exact inv_nonneg.2 (norm_nonneg _) /-- If `f` has derivative `f'` within `(x, +āˆž)` at `x`, then for any `r > ‖f'‖` the ratio `‖f z - f x‖ / ‖z - x‖` is frequently less than `r` as `z → x+0`. In other words, the limit inferior of this ratio as `z` tends to `x+0` is less than or equal to `‖f'‖`. See also `HasDerivWithinAt.limsup_norm_slope_le` for a stronger version using limit superior and any set `s`. -/ theorem HasDerivWithinAt.liminf_right_norm_slope_le (hf : HasDerivWithinAt f f' (Ici x) x) (hr : ‖f'‖ < r) : ∃ᶠ z in š“[>] x, ‖z - x‖⁻¹ * ‖f z - f x‖ < r := (hf.Ioi_of_Ici.limsup_norm_slope_le hr).frequently /-- If `f` has derivative `f'` within `(x, +āˆž)` at `x`, then for any `r > ‖f'‖` the ratio `(‖f z‖ - ‖f x‖) / (z - x)` is frequently less than `r` as `z → x+0`. In other words, the limit inferior of this ratio as `z` tends to `x+0` is less than or equal to `‖f'‖`. See also * `HasDerivWithinAt.limsup_norm_slope_le` for a stronger version using limit superior and any set `s`; * `HasDerivWithinAt.liminf_right_norm_slope_le` for a stronger version using `‖f z - f xp‖` instead of `‖f z‖ - ‖f x‖`. -/ theorem HasDerivWithinAt.liminf_right_slope_norm_le (hf : HasDerivWithinAt f f' (Ici x) x) (hr : ‖f'‖ < r) : ∃ᶠ z in š“[>] x, (z - x)⁻¹ * (‖f z‖ - ‖f x‖) < r := by have := (hf.Ioi_of_Ici.limsup_slope_norm_le hr).frequently refine this.mp (Eventually.mono self_mem_nhdsWithin fun z hxz hz ↦ ?_) rwa [Real.norm_eq_abs, abs_of_pos (sub_pos_of_lt hxz)] at hz end RealSpace
.lake/packages/mathlib/Mathlib/Analysis/Calculus/Deriv/ZPow.lean
import Mathlib.Analysis.Calculus.Deriv.Pow import Mathlib.Analysis.Calculus.Deriv.Inv import Mathlib.Analysis.Calculus.Deriv.Shift /-! # Derivatives of `x ^ m`, `m : ℤ` In this file we prove theorems about (iterated) derivatives of `x ^ m`, `m : ℤ`. For a more detailed overview of one-dimensional derivatives in mathlib, see the module docstring of `analysis/calculus/deriv/basic`. ## Keywords derivative, power -/ universe u v w open Topology Filter Asymptotics Set open scoped Nat variable {š•œ : Type u} [NontriviallyNormedField š•œ] variable {E : Type v} [NormedAddCommGroup E] [NormedSpace š•œ E] variable {x : š•œ} variable {s : Set š•œ} variable {m : ℤ} /-! ### Derivative of `x ↦ x^m` for `m : ℤ` -/ theorem hasStrictDerivAt_zpow (m : ℤ) (x : š•œ) (h : x ≠ 0 ∨ 0 ≤ m) : HasStrictDerivAt (fun x => x ^ m) ((m : š•œ) * x ^ (m - 1)) x := by have : āˆ€ m : ℤ, 0 < m → HasStrictDerivAt (Ā· ^ m) ((m : š•œ) * x ^ (m - 1)) x := fun m hm ↦ by lift m to ā„• using hm.le simp only [zpow_natCast, Int.cast_natCast] convert hasStrictDerivAt_pow m x using 2 rw [← Int.ofNat_one, ← Int.ofNat_sub, zpow_natCast] norm_cast at hm rcases lt_trichotomy m 0 with (hm | hm | hm) Ā· have hx : x ≠ 0 := h.resolve_right hm.not_ge have := (hasStrictDerivAt_inv ?_).scomp _ (this (-m) (neg_pos.2 hm)) <;> [skip; exact zpow_ne_zero _ hx] simp only [Function.comp_def, zpow_neg, inv_inv, smul_eq_mul] at this convert this using 1 rw [sq, mul_inv, inv_inv, Int.cast_neg, neg_mul, neg_mul_neg, ← zpow_addā‚€ hx, mul_assoc, ← zpow_addā‚€ hx] congr abel Ā· simp only [hm, zpow_zero, Int.cast_zero, zero_mul, hasStrictDerivAt_const] Ā· exact this m hm theorem hasDerivAt_zpow (m : ℤ) (x : š•œ) (h : x ≠ 0 ∨ 0 ≤ m) : HasDerivAt (fun x => x ^ m) ((m : š•œ) * x ^ (m - 1)) x := (hasStrictDerivAt_zpow m x h).hasDerivAt theorem hasDerivWithinAt_zpow (m : ℤ) (x : š•œ) (h : x ≠ 0 ∨ 0 ≤ m) (s : Set š•œ) : HasDerivWithinAt (fun x => x ^ m) ((m : š•œ) * x ^ (m - 1)) s x := (hasDerivAt_zpow m x h).hasDerivWithinAt theorem differentiableAt_zpow : DifferentiableAt š•œ (fun x => x ^ m) x ↔ x ≠ 0 ∨ 0 ≤ m := ⟨fun H => NormedField.continuousAt_zpow.1 H.continuousAt, fun H => (hasDerivAt_zpow m x H).differentiableAt⟩ theorem differentiableWithinAt_zpow (m : ℤ) (x : š•œ) (h : x ≠ 0 ∨ 0 ≤ m) : DifferentiableWithinAt š•œ (fun x => x ^ m) s x := (differentiableAt_zpow.mpr h).differentiableWithinAt theorem differentiableOn_zpow (m : ℤ) (s : Set š•œ) (h : (0 : š•œ) āˆ‰ s ∨ 0 ≤ m) : DifferentiableOn š•œ (fun x => x ^ m) s := fun x hxs => differentiableWithinAt_zpow m x <| h.imp_left <| ne_of_mem_of_not_mem hxs theorem deriv_zpow (m : ℤ) (x : š•œ) : deriv (fun x => x ^ m) x = m * x ^ (m - 1) := by by_cases H : x ≠ 0 ∨ 0 ≤ m Ā· exact (hasDerivAt_zpow m x H).deriv Ā· rw [deriv_zero_of_not_differentiableAt (mt differentiableAt_zpow.1 H)] push_neg at H rcases H with ⟨rfl, hm⟩ rw [zero_zpow _ ((sub_one_lt _).trans hm).ne, mul_zero] @[simp] theorem deriv_zpow' (m : ℤ) : (deriv fun x : š•œ => x ^ m) = fun x => (m : š•œ) * x ^ (m - 1) := funext <| deriv_zpow m theorem derivWithin_zpow (hxs : UniqueDiffWithinAt š•œ s x) (h : x ≠ 0 ∨ 0 ≤ m) : derivWithin (fun x => x ^ m) s x = (m : š•œ) * x ^ (m - 1) := (hasDerivWithinAt_zpow m x h s).derivWithin hxs @[simp] theorem iter_deriv_zpow' (m : ℤ) (k : ā„•) : (deriv^[k] fun x : š•œ => x ^ m) = fun x => (āˆ i ∈ Finset.range k, ((m : š•œ) - i)) * x ^ (m - k) := by induction k with | zero => simp only [one_mul, Int.ofNat_zero, id, sub_zero, Finset.prod_range_zero, Function.iterate_zero] | succ k ihk => simp only [Function.iterate_succ_apply', ihk, deriv_const_mul_field', deriv_zpow', Finset.prod_range_succ, Int.natCast_succ, ← sub_sub, Int.cast_sub, Int.cast_natCast, mul_assoc] theorem iter_deriv_zpow (m : ℤ) (x : š•œ) (k : ā„•) : deriv^[k] (fun y => y ^ m) x = (āˆ i ∈ Finset.range k, ((m : š•œ) - i)) * x ^ (m - k) := congr_fun (iter_deriv_zpow' m k) x theorem iter_deriv_pow (n : ā„•) (x : š•œ) (k : ā„•) : deriv^[k] (fun x : š•œ => x ^ n) x = (āˆ i ∈ Finset.range k, ((n : š•œ) - i)) * x ^ (n - k) := by simp only [← zpow_natCast, iter_deriv_zpow, Int.cast_natCast] rcases le_or_gt k n with hkn | hnk Ā· rw [Int.ofNat_sub hkn] Ā· have : (āˆ i ∈ Finset.range k, (n - i : š•œ)) = 0 := Finset.prod_eq_zero (Finset.mem_range.2 hnk) (sub_self _) simp only [this, zero_mul] @[simp] theorem iter_deriv_pow' (n k : ā„•) : (deriv^[k] fun x : š•œ => x ^ n) = fun x => (āˆ i ∈ Finset.range k, ((n : š•œ) - i)) * x ^ (n - k) := funext fun x => iter_deriv_pow n x k theorem iter_deriv_inv (k : ā„•) (x : š•œ) : deriv^[k] Inv.inv x = (-1) ^ k * k ! * x ^ (-1 - k : ℤ) := calc deriv^[k] Inv.inv x = deriv^[k] (Ā· ^ (-1 : ℤ)) x := by simp _ = (āˆ i ∈ Finset.range k, (-1 - i : š•œ)) * x ^ (-1 - k : ℤ) := mod_cast iter_deriv_zpow (-1) x k _ = (-1) ^ k * k ! * x ^ (-1 - k : ℤ) := by simp only [← neg_add', Finset.prod_neg, ← Finset.prod_Ico_id_eq_factorial, Finset.prod_Ico_eq_prod_range] simp @[simp] theorem iter_deriv_inv' (k : ā„•) : deriv^[k] Inv.inv = fun x : š•œ => (-1) ^ k * k ! * x ^ (-1 - k : ℤ) := funext (iter_deriv_inv k) open Nat Function in theorem iter_deriv_inv_linear (k : ā„•) (c d : š•œ) : deriv^[k] (fun x ↦ (c * x + d)⁻¹) = (fun x : š•œ ↦ (-1) ^ k * k ! * c ^ k * (c * x + d) ^ (-1 - k : ℤ)) := by induction k with | zero => simp | succ k ihk => rw [factorial_succ, add_comm k 1, iterate_add_apply, ihk] ext z simp only [Int.reduceNeg, iterate_one, deriv_const_mul_field', cast_add, cast_one] by_cases hd : c = 0 Ā· simp [hd] Ā· have := deriv_comp_add_const (fun x ↦ (c * x) ^ (-1 - k : ℤ)) (d / c) z have h0 : (fun x ↦ (c * (x + d / c)) ^ (-1 - (k : ℤ))) = (fun x ↦ (c * x + d) ^ (-1 - (k : ℤ))) := by ext y field_simp rw [h0, deriv_comp_mul_left c (fun x ↦ (x) ^ (-1 - k : ℤ)) (z + d / c)] at this simp [this] field_simp ring_nf theorem iter_deriv_inv_linear_sub (k : ā„•) (c d : š•œ) : deriv^[k] (fun x ↦ (c * x - d)⁻¹) = (fun x : š•œ ↦ (-1) ^ k * k ! * c ^ k * (c * x - d) ^ (-1 - k : ℤ)) := by simpa [sub_eq_add_neg] using iter_deriv_inv_linear k c (-d) variable {f : E → š•œ} {t : Set E} {a : E} theorem DifferentiableWithinAt.zpow (hf : DifferentiableWithinAt š•œ f t a) (h : f a ≠ 0 ∨ 0 ≤ m) : DifferentiableWithinAt š•œ (fun x => f x ^ m) t a := (differentiableAt_zpow.2 h).comp_differentiableWithinAt a hf theorem DifferentiableAt.zpow (hf : DifferentiableAt š•œ f a) (h : f a ≠ 0 ∨ 0 ≤ m) : DifferentiableAt š•œ (fun x => f x ^ m) a := (differentiableAt_zpow.2 h).comp a hf theorem DifferentiableOn.zpow (hf : DifferentiableOn š•œ f t) (h : (āˆ€ x ∈ t, f x ≠ 0) ∨ 0 ≤ m) : DifferentiableOn š•œ (fun x => f x ^ m) t := fun x hx => (hf x hx).zpow <| h.imp_left fun h => h x hx theorem Differentiable.zpow (hf : Differentiable š•œ f) (h : (āˆ€ x, f x ≠ 0) ∨ 0 ≤ m) : Differentiable š•œ fun x => f x ^ m := fun x => (hf x).zpow <| h.imp_left fun h => h x
.lake/packages/mathlib/Mathlib/Analysis/Calculus/Deriv/CompMul.lean
import Mathlib.Analysis.Calculus.FDeriv.Equiv import Mathlib.Analysis.Calculus.Deriv.Mul /-! # Derivative of `x ↦ f (cx)` In this file we prove that the derivative of `fun x ↦ f (c * x)` equals `c` times the derivative of `f` evaluated at `c * x`. Since Mathlib uses `0` as the fallback value for the derivatives whenever they are undefined, the theorems in this file require neither differentiability of `f`, nor assumptions like `UniqueDiffWithinAt š•œ s x`. -/ open Set open scoped Pointwise variable {š•œ E : Type*} [NontriviallyNormedField š•œ] [NormedAddCommGroup E] [NormedSpace š•œ E] {c : š•œ} {f : š•œ → E} {f' : E} {s : Set š•œ} {x : š•œ} theorem hasDerivWithinAt_comp_mul_left_smul_iff : HasDerivWithinAt (f <| c * Ā·) (c • f') s x ↔ HasDerivWithinAt f f' (c • s) (c * x) := by simp only [hasDerivWithinAt_iff_hasFDerivWithinAt, ← smul_eq_mul, ← hasFDerivWithinAt_comp_smul_smul_iff] simp only [ContinuousLinearMap.one_smulRight_eq_toSpanSingleton, ContinuousLinearMap.toSpanSingleton_smul] variable (c f s x) in theorem derivWithin_comp_mul_left : derivWithin (f <| c * Ā·) s x = c • derivWithin f (c • s) (c * x) := by simp only [← smul_eq_mul] rw [← derivWithin_const_smul', derivWithin, derivWithin, fderivWithin_comp_smul_eq_fderivWithin_smul, Pi.smul_def] variable (c f x) in theorem deriv_comp_mul_left : deriv (f <| c * Ā·) x = c • deriv f (c * x) := by simp only [← smul_eq_mul, deriv, fderiv_comp_smul, ContinuousLinearMap.smul_apply]
.lake/packages/mathlib/Mathlib/Analysis/Calculus/Deriv/Polynomial.lean
import Mathlib.Algebra.Polynomial.AlgebraMap import Mathlib.Algebra.Polynomial.Derivative import Mathlib.Analysis.Calculus.Deriv.Mul import Mathlib.Analysis.Calculus.Deriv.Pow import Mathlib.Analysis.Calculus.Deriv.Add /-! # Derivatives of polynomials In this file we prove that derivatives of polynomials in the analysis sense agree with their derivatives in the algebraic sense. For a more detailed overview of one-dimensional derivatives in mathlib, see the module docstring of `analysis/calculus/deriv/basic`. ## TODO * Add results about multivariable polynomials. * Generalize some (most?) results to an algebra over the base field. ## Keywords derivative, polynomial -/ universe u open scoped Polynomial open ContinuousLinearMap (smulRight) variable {š•œ : Type u} [NontriviallyNormedField š•œ] {x : š•œ} {s : Set š•œ} namespace Polynomial /-! ### Derivative of a polynomial -/ variable {R : Type*} [CommSemiring R] [Algebra R š•œ] variable (p : š•œ[X]) (q : R[X]) /-- The derivative (in the analysis sense) of a polynomial `p` is given by `p.derivative`. -/ protected theorem hasStrictDerivAt (x : š•œ) : HasStrictDerivAt (fun x => p.eval x) (p.derivative.eval x) x := by induction p using Polynomial.induction_on' with | add p q hp hq => simpa using hp.add hq | monomial n a => simpa [mul_assoc, derivative_monomial] using (hasStrictDerivAt_pow n x).const_mul a protected theorem hasStrictDerivAt_aeval (x : š•œ) : HasStrictDerivAt (fun x => aeval x q) (aeval x (derivative q)) x := by simpa only [aeval_def, evalā‚‚_eq_eval_map, derivative_map] using (q.map (algebraMap R š•œ)).hasStrictDerivAt x /-- The derivative (in the analysis sense) of a polynomial `p` is given by `p.derivative`. -/ protected theorem hasDerivAt (x : š•œ) : HasDerivAt (fun x => p.eval x) (p.derivative.eval x) x := (p.hasStrictDerivAt x).hasDerivAt protected theorem hasDerivAt_aeval (x : š•œ) : HasDerivAt (fun x => aeval x q) (aeval x (derivative q)) x := (q.hasStrictDerivAt_aeval x).hasDerivAt protected theorem hasDerivWithinAt (x : š•œ) (s : Set š•œ) : HasDerivWithinAt (fun x => p.eval x) (p.derivative.eval x) s x := (p.hasDerivAt x).hasDerivWithinAt protected theorem hasDerivWithinAt_aeval (x : š•œ) (s : Set š•œ) : HasDerivWithinAt (fun x => aeval x q) (aeval x (derivative q)) s x := (q.hasDerivAt_aeval x).hasDerivWithinAt protected theorem differentiableAt : DifferentiableAt š•œ (fun x => p.eval x) x := (p.hasDerivAt x).differentiableAt protected theorem differentiableAt_aeval : DifferentiableAt š•œ (fun x => aeval x q) x := (q.hasDerivAt_aeval x).differentiableAt protected theorem differentiableWithinAt : DifferentiableWithinAt š•œ (fun x => p.eval x) s x := p.differentiableAt.differentiableWithinAt protected theorem differentiableWithinAt_aeval : DifferentiableWithinAt š•œ (fun x => aeval x q) s x := q.differentiableAt_aeval.differentiableWithinAt @[fun_prop] protected theorem differentiable : Differentiable š•œ fun x => p.eval x := fun _ => p.differentiableAt protected theorem differentiable_aeval : Differentiable š•œ fun x : š•œ => aeval x q := fun _ => q.differentiableAt_aeval protected theorem differentiableOn : DifferentiableOn š•œ (fun x => p.eval x) s := p.differentiable.differentiableOn protected theorem differentiableOn_aeval : DifferentiableOn š•œ (fun x => aeval x q) s := q.differentiable_aeval.differentiableOn @[simp] protected theorem deriv : deriv (fun x => p.eval x) x = p.derivative.eval x := (p.hasDerivAt x).deriv @[simp] protected theorem deriv_aeval : deriv (fun x => aeval x q) x = aeval x (derivative q) := (q.hasDerivAt_aeval x).deriv protected theorem derivWithin (hxs : UniqueDiffWithinAt š•œ s x) : derivWithin (fun x => p.eval x) s x = p.derivative.eval x := by rw [DifferentiableAt.derivWithin p.differentiableAt hxs] exact p.deriv protected theorem derivWithin_aeval (hxs : UniqueDiffWithinAt š•œ s x) : derivWithin (fun x => aeval x q) s x = aeval x (derivative q) := by simpa only [aeval_def, evalā‚‚_eq_eval_map, derivative_map] using (q.map (algebraMap R š•œ)).derivWithin hxs protected theorem hasFDerivAt (x : š•œ) : HasFDerivAt (fun x => p.eval x) (smulRight (1 : š•œ →L[š•œ] š•œ) (p.derivative.eval x)) x := p.hasDerivAt x protected theorem hasFDerivAt_aeval (x : š•œ) : HasFDerivAt (fun x => aeval x q) (smulRight (1 : š•œ →L[š•œ] š•œ) (aeval x (derivative q))) x := q.hasDerivAt_aeval x protected theorem hasFDerivWithinAt (x : š•œ) : HasFDerivWithinAt (fun x => p.eval x) (smulRight (1 : š•œ →L[š•œ] š•œ) (p.derivative.eval x)) s x := (p.hasFDerivAt x).hasFDerivWithinAt protected theorem hasFDerivWithinAt_aeval (x : š•œ) : HasFDerivWithinAt (fun x => aeval x q) (smulRight (1 : š•œ →L[š•œ] š•œ) (aeval x (derivative q))) s x := (q.hasFDerivAt_aeval x).hasFDerivWithinAt @[simp] protected theorem fderiv : fderiv š•œ (fun x => p.eval x) x = smulRight (1 : š•œ →L[š•œ] š•œ) (p.derivative.eval x) := (p.hasFDerivAt x).fderiv @[simp] protected theorem fderiv_aeval : fderiv š•œ (fun x => aeval x q) x = smulRight (1 : š•œ →L[š•œ] š•œ) (aeval x (derivative q)) := (q.hasFDerivAt_aeval x).fderiv protected theorem fderivWithin (hxs : UniqueDiffWithinAt š•œ s x) : fderivWithin š•œ (fun x => p.eval x) s x = smulRight (1 : š•œ →L[š•œ] š•œ) (p.derivative.eval x) := (p.hasFDerivWithinAt x).fderivWithin hxs protected theorem fderivWithin_aeval (hxs : UniqueDiffWithinAt š•œ s x) : fderivWithin š•œ (fun x => aeval x q) s x = smulRight (1 : š•œ →L[š•œ] š•œ) (aeval x (derivative q)) := (q.hasFDerivWithinAt_aeval x).fderivWithin hxs end Polynomial
.lake/packages/mathlib/Mathlib/Analysis/Calculus/Deriv/Shift.lean
import Mathlib.Analysis.Calculus.Deriv.Add import Mathlib.Analysis.Calculus.Deriv.Comp import Mathlib.Analysis.Calculus.Deriv.CompMul /-! ### Invariance of the derivative under translation We show that if a function `f` has derivative `f'` at a point `a + x`, then `f (a + Ā·)` has derivative `f'` at `x`. Similarly for `x + a`. -/ open scoped Pointwise variable {š•œ F : Type*} [NontriviallyNormedField š•œ] [NormedAddCommGroup F] [NormedSpace š•œ F] {f : š•œ → F} {f' : F} /-- Translation in the domain does not change the derivative. -/ lemma HasDerivAt.comp_const_add (a x : š•œ) (hf : HasDerivAt f f' (a + x)) : HasDerivAt (fun x ↦ f (a + x)) f' x := by simpa [Function.comp_def] using HasDerivAt.scomp (š•œ := š•œ) x hf <| hasDerivAt_id' x |>.const_add a /-- Translation in the domain does not change the derivative. -/ lemma HasDerivAt.comp_add_const (x a : š•œ) (hf : HasDerivAt f f' (x + a)) : HasDerivAt (fun x ↦ f (x + a)) f' x := by simpa [Function.comp_def] using HasDerivAt.scomp (š•œ := š•œ) x hf <| hasDerivAt_id' x |>.add_const a /-- Translation in the domain does not change the derivative. -/ lemma HasDerivAt.comp_const_sub (a x : š•œ) (hf : HasDerivAt f f' (a - x)) : HasDerivAt (fun x ↦ f (a - x)) (-f') x := by simpa [Function.comp_def] using HasDerivAt.scomp (š•œ := š•œ) x hf <| hasDerivAt_id' x |>.const_sub a /-- Translation in the domain does not change the derivative. -/ lemma HasDerivAt.comp_sub_const (x a : š•œ) (hf : HasDerivAt f f' (x - a)) : HasDerivAt (fun x ↦ f (x - a)) f' x := by simpa [Function.comp_def] using HasDerivAt.scomp (š•œ := š•œ) x hf <| hasDerivAt_id' x |>.sub_const a variable (f) variable (a : š•œ) (s : Set š•œ) (x : š•œ) lemma derivWithin_comp_neg : derivWithin (f <| -Ā·) s x = -derivWithin f (-s) (-x) := by simpa using derivWithin_comp_mul_left (-1) f s x /-- The derivative of `x ↦ f (-x)` at `a` is the negative of the derivative of `f` at `-a`. -/ lemma deriv_comp_neg : deriv (fun x ↦ f (-x)) x = -deriv f (-x) := by simpa using deriv_comp_mul_left (-1) f x /-- Translation in the domain does not change the derivative. -/ lemma derivWithin_comp_const_add : derivWithin (f <| a + Ā·) s x = derivWithin f (a +ᵄ s) (a + x) := by simp only [derivWithin, fderivWithin_comp_add_left] /-- Translation in the domain does not change the derivative. -/ lemma deriv_comp_const_add : deriv (fun x ↦ f (a + x)) x = deriv f (a + x) := by simp only [deriv, fderiv_comp_add_left] /-- Translation in the domain does not change the derivative. -/ lemma derivWithin_comp_add_const : derivWithin (f <| Ā· + a) s x = derivWithin f (a +ᵄ s) (x + a) := by simp only [derivWithin, fderivWithin_comp_add_right] /-- Translation in the domain does not change the derivative. -/ lemma deriv_comp_add_const : deriv (fun x ↦ f (x + a)) x = deriv f (x + a) := by simpa [add_comm] using deriv_comp_const_add f a x lemma derivWithin_comp_const_sub : derivWithin (f <| a - Ā·) s x = -derivWithin f (a +ᵄ -s) (a - x) := by simp only [sub_eq_add_neg] rw [derivWithin_comp_neg (f <| a + Ā·), derivWithin_comp_const_add] lemma deriv_comp_const_sub : deriv (fun x ↦ f (a - x)) x = -deriv f (a - x) := by simp_rw [sub_eq_add_neg, deriv_comp_neg (f <| a + Ā·), deriv_comp_const_add] lemma derivWithin_comp_sub_const : derivWithin (fun x ↦ f (x - a)) s x = derivWithin f (-a +ᵄ s) (x - a) := by simp_rw [sub_eq_add_neg, derivWithin_comp_add_const] lemma deriv_comp_sub_const : deriv (fun x ↦ f (x - a)) x = deriv f (x - a) := by simp_rw [sub_eq_add_neg, deriv_comp_add_const]
.lake/packages/mathlib/Mathlib/Analysis/Calculus/Deriv/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.Calculus.LocalExtr.Rolle import Mathlib.Analysis.Normed.Group.AddTorsor import Mathlib.Analysis.RCLike.Basic /-! # Mean value theorem In this file we prove Cauchy's and Lagrange's mean value theorems, and deduce some corollaries. Cauchy's mean value theorem says that for two functions `f` and `g` that are continuous on `[a, b]` and are differentiable on `(a, b)`, there exists a point `c ∈ (a, b)` such that `f' c / g' c = (f b - f a) / (g b - g a)`. We formulate this theorem with both sides multiplied by the denominators, see `exists_ratio_hasDerivAt_eq_ratio_slope`, in order to avoid auxiliary conditions like `g' c ≠ 0`. Lagrange's mean value theorem, see `exists_hasDerivAt_eq_slope`, says that for a function `f` that is continuous on `[a, b]` and is differentiable on `(a, b)`, there exists a point `c ∈ (a, b)` such that `f' c = (f b - f a) / (b - a)`. Lagrange's MVT implies that `(f b - f a) / (b - a) > C` provided that `f' c > C` for all `c ∈ (a, b)`, see `mul_sub_lt_image_sub_of_lt_deriv`, and other theorems for `>` / `≄` / `<` / `≤`. In case `C = 0`, we deduce that a function with a positive derivative is strictly monotone, see `strictMonoOn_of_deriv_pos` and nearby theorems for other types of monotonicity. We also prove that a real function whose derivative tends to infinity from the right at a point is not differentiable on the right at that point, and similarly differentiability on the left. ## Main results * `exists_ratio_hasDerivAt_eq_ratio_slope` and `exists_ratio_deriv_eq_ratio_slope` : Cauchy's Mean Value Theorem. * `exists_hasDerivAt_eq_slope` and `exists_deriv_eq_slope` : Lagrange's Mean Value Theorem. * `domain_mvt` : Lagrange's Mean Value Theorem, applied to a segment in a convex domain. * `Convex.image_sub_lt_mul_sub_of_deriv_lt`, `Convex.mul_sub_lt_image_sub_of_lt_deriv`, `Convex.image_sub_le_mul_sub_of_deriv_le`, `Convex.mul_sub_le_image_sub_of_le_deriv`, if `āˆ€ x, C (</≤/>/≄) (f' x)`, then `C * (y - x) (</≤/>/≄) (f y - f x)` whenever `x < y`. * `monotoneOn_of_deriv_nonneg`, `antitoneOn_of_deriv_nonpos`, `strictMono_of_deriv_pos`, `strictAnti_of_deriv_neg` : if the derivative of a function is non-negative/non-positive/positive/negative, then the function is monotone/antitone/strictly monotone/strictly monotonically decreasing. * `convexOn_of_deriv`, `convexOn_of_deriv2_nonneg` : if the derivative of a function is increasing or its second derivative is nonnegative, then the original function is convex. -/ open Set Function Filter open scoped Topology /-! ### Functions `[a, b] → ā„`. -/ section Interval -- Declare all variables here to make sure they come in a correct order variable (f f' : ā„ → ā„) {a b : ā„} (hab : a < b) (hfc : ContinuousOn f (Icc a b)) (hff' : āˆ€ x ∈ Ioo a b, HasDerivAt f (f' x) x) (hfd : DifferentiableOn ā„ f (Ioo a b)) (g g' : ā„ → ā„) (hgc : ContinuousOn g (Icc a b)) (hgg' : āˆ€ x ∈ Ioo a b, HasDerivAt g (g' x) x) (hgd : DifferentiableOn ā„ g (Ioo a b)) include hab hfc hff' hgc hgg' in /-- Cauchy's **Mean Value Theorem**, `HasDerivAt` version. -/ theorem exists_ratio_hasDerivAt_eq_ratio_slope : ∃ c ∈ Ioo a b, (g b - g a) * f' c = (f b - f a) * g' c := by let h x := (g b - g a) * f x - (f b - f a) * g x have hI : h a = h b := by simp only [h]; ring let h' x := (g b - g a) * f' x - (f b - f a) * g' x have hhh' : āˆ€ x ∈ Ioo a b, HasDerivAt h (h' x) x := fun x hx => ((hff' x hx).const_mul (g b - g a)).sub ((hgg' x hx).const_mul (f b - f a)) have hhc : ContinuousOn h (Icc a b) := (continuousOn_const.mul hfc).sub (continuousOn_const.mul hgc) rcases exists_hasDerivAt_eq_zero hab hhc hI hhh' with ⟨c, cmem, hc⟩ exact ⟨c, cmem, sub_eq_zero.1 hc⟩ include hab in /-- Cauchy's **Mean Value Theorem**, extended `HasDerivAt` version. -/ theorem exists_ratio_hasDerivAt_eq_ratio_slope' {lfa lga lfb lgb : ā„} (hff' : āˆ€ x ∈ Ioo a b, HasDerivAt f (f' x) x) (hgg' : āˆ€ x ∈ Ioo a b, HasDerivAt g (g' x) x) (hfa : Tendsto f (š“[>] a) (š“ lfa)) (hga : Tendsto g (š“[>] a) (š“ lga)) (hfb : Tendsto f (š“[<] b) (š“ lfb)) (hgb : Tendsto g (š“[<] b) (š“ lgb)) : ∃ c ∈ Ioo a b, (lgb - lga) * f' c = (lfb - lfa) * g' c := by let h x := (lgb - lga) * f x - (lfb - lfa) * g x have hha : Tendsto h (š“[>] a) (š“ <| lgb * lfa - lfb * lga) := by have : Tendsto h (š“[>] a) (š“ <| (lgb - lga) * lfa - (lfb - lfa) * lga) := (tendsto_const_nhds.mul hfa).sub (tendsto_const_nhds.mul hga) convert this using 2 ring have hhb : Tendsto h (š“[<] b) (š“ <| lgb * lfa - lfb * lga) := by have : Tendsto h (š“[<] b) (š“ <| (lgb - lga) * lfb - (lfb - lfa) * lgb) := (tendsto_const_nhds.mul hfb).sub (tendsto_const_nhds.mul hgb) convert this using 2 ring let h' x := (lgb - lga) * f' x - (lfb - lfa) * g' x have hhh' : āˆ€ x ∈ Ioo a b, HasDerivAt h (h' x) x := by intro x hx exact ((hff' x hx).const_mul _).sub ((hgg' x hx).const_mul _) rcases exists_hasDerivAt_eq_zero' hab hha hhb hhh' with ⟨c, cmem, hc⟩ exact ⟨c, cmem, sub_eq_zero.1 hc⟩ include hab hfc hff' in /-- Lagrange's Mean Value Theorem, `HasDerivAt` version -/ theorem exists_hasDerivAt_eq_slope : ∃ c ∈ Ioo a b, f' c = (f b - f a) / (b - a) := by obtain ⟨c, cmem, hc⟩ : ∃ c ∈ Ioo a b, (b - a) * f' c = (f b - f a) * 1 := exists_ratio_hasDerivAt_eq_ratio_slope f f' hab hfc hff' id 1 continuousOn_id fun x _ => hasDerivAt_id x use c, cmem rwa [mul_one, mul_comm, ← eq_div_iff (sub_ne_zero.2 hab.ne')] at hc include hab hfc hgc hgd hfd in /-- Cauchy's Mean Value Theorem, `deriv` version. -/ theorem exists_ratio_deriv_eq_ratio_slope : ∃ c ∈ Ioo a b, (g b - g a) * deriv f c = (f b - f a) * deriv g c := exists_ratio_hasDerivAt_eq_ratio_slope f (deriv f) hab hfc (fun x hx => ((hfd x hx).differentiableAt <| IsOpen.mem_nhds isOpen_Ioo hx).hasDerivAt) g (deriv g) hgc fun x hx => ((hgd x hx).differentiableAt <| IsOpen.mem_nhds isOpen_Ioo hx).hasDerivAt include hab in /-- Cauchy's Mean Value Theorem, extended `deriv` version. -/ theorem exists_ratio_deriv_eq_ratio_slope' {lfa lga lfb lgb : ā„} (hdf : DifferentiableOn ā„ f <| Ioo a b) (hdg : DifferentiableOn ā„ g <| Ioo a b) (hfa : Tendsto f (š“[>] a) (š“ lfa)) (hga : Tendsto g (š“[>] a) (š“ lga)) (hfb : Tendsto f (š“[<] b) (š“ lfb)) (hgb : Tendsto g (š“[<] b) (š“ lgb)) : ∃ c ∈ Ioo a b, (lgb - lga) * deriv f c = (lfb - lfa) * deriv g c := exists_ratio_hasDerivAt_eq_ratio_slope' _ _ hab _ _ (fun x hx => ((hdf x hx).differentiableAt <| Ioo_mem_nhds hx.1 hx.2).hasDerivAt) (fun x hx => ((hdg x hx).differentiableAt <| Ioo_mem_nhds hx.1 hx.2).hasDerivAt) hfa hga hfb hgb include hab hfc hfd in /-- Lagrange's **Mean Value Theorem**, `deriv` version. -/ theorem exists_deriv_eq_slope : ∃ c ∈ Ioo a b, deriv f c = (f b - f a) / (b - a) := exists_hasDerivAt_eq_slope f (deriv f) hab hfc fun x hx => ((hfd x hx).differentiableAt <| IsOpen.mem_nhds isOpen_Ioo hx).hasDerivAt include hab hfc hfd in /-- Lagrange's **Mean Value Theorem**, `deriv` version. -/ theorem exists_deriv_eq_slope' : ∃ c ∈ Ioo a b, deriv f c = slope f a b := by rw [slope_def_field] exact exists_deriv_eq_slope f hab hfc hfd /-- A real function whose derivative tends to infinity from the right at a point is not differentiable on the right at that point. -/ theorem not_differentiableWithinAt_of_deriv_tendsto_atTop_Ioi (f : ā„ → ā„) {a : ā„} (hf : Tendsto (deriv f) (š“[>] a) atTop) : ¬ DifferentiableWithinAt ā„ f (Ioi a) a := by replace hf : Tendsto (derivWithin f (Ioi a)) (š“[>] a) atTop := by refine hf.congr' ?_ filter_upwards [eventually_mem_nhdsWithin] with x hx have : Ioi a ∈ š“ x := by simp [← mem_interior_iff_mem_nhds, hx] exact (derivWithin_of_mem_nhds this).symm by_cases hcont_at_a : ContinuousWithinAt f (Ici a) a case neg => intro hcontra have := hcontra.continuousWithinAt rw [← ContinuousWithinAt.diff_iff this] at hcont_at_a simp at hcont_at_a case pos => intro hdiff replace hdiff := hdiff.hasDerivWithinAt rw [hasDerivWithinAt_iff_tendsto_slope, Set.diff_singleton_eq_self notMem_Ioi_self] at hdiff have hā‚€ : āˆ€į¶  b in š“[>] a, āˆ€ x ∈ Ioc a b, max (derivWithin f (Ioi a) a + 1) 0 < derivWithin f (Ioi a) x := by rw [(nhdsGT_basis a).eventually_iff] rw [(nhdsGT_basis a).tendsto_left_iff] at hf obtain ⟨b, hab, hb⟩ := hf (Ioi (max (derivWithin f (Ioi a) a + 1) 0)) (Ioi_mem_atTop _) refine ⟨b, hab, fun x hx z hz => ?_⟩ simp only [MapsTo, mem_Ioo, mem_Ioi, and_imp] at hb exact hb hz.1 <| hz.2.trans_lt hx.2 have h₁ : āˆ€į¶  b in š“[>] a, slope f a b < derivWithin f (Ioi a) a + 1 := by rw [(nhds_basis_Ioo _).tendsto_right_iff] at hdiff specialize hdiff ⟨derivWithin f (Ioi a) a - 1, derivWithin f (Ioi a) a + 1⟩ <| by simp filter_upwards [hdiff] with z hz using hz.2 have hcontra : āˆ€į¶  _ in š“[>] a, False := by filter_upwards [hā‚€, h₁, eventually_mem_nhdsWithin] with b hb hslope (hab : a < b) have hdiff' : DifferentiableOn ā„ f (Ioc a b) := fun z hz => by refine DifferentiableWithinAt.mono (t := Ioi a) ?_ Ioc_subset_Ioi_self have : derivWithin f (Ioi a) z ≠ 0 := ne_of_gt <| by simp_all only [and_imp, mem_Ioc, max_lt_iff] exact differentiableWithinAt_of_derivWithin_ne_zero this have hcont_Ioc : āˆ€ z ∈ Ioc a b, ContinuousWithinAt f (Icc a b) z := by intro z hz'' refine (hdiff'.continuousOn z hz'').mono_of_mem_nhdsWithin ?_ have hfinal : š“[Ioc a b] z = š“[Icc a b] z := by refine nhdsWithin_eq_nhdsWithin' (s := Ioi a) (Ioi_mem_nhds hz''.1) ?_ simp only [Ioc_inter_Ioi, le_refl, sup_of_le_left] ext y exact ⟨fun h => ⟨mem_Icc_of_Ioc h, mem_of_mem_inter_left h⟩, fun ⟨H1, H2⟩ => ⟨H2, H1.2⟩⟩ rw [← hfinal] exact self_mem_nhdsWithin have hcont : ContinuousOn f (Icc a b) := by intro z hz by_cases hz' : z = a Ā· rw [hz'] exact hcont_at_a.mono Icc_subset_Ici_self Ā· exact hcont_Ioc z ⟨lt_of_le_of_ne hz.1 (Ne.symm hz'), hz.2⟩ obtain ⟨x, hx₁, hxā‚‚āŸ© := exists_deriv_eq_slope' f hab hcont (hdiff'.mono (Ioo_subset_Ioc_self)) specialize hb x ⟨hx₁.1, le_of_lt hx₁.2⟩ replace hxā‚‚ : derivWithin f (Ioi a) x = slope f a b := by have : Ioi a ∈ š“ x := by simp [← mem_interior_iff_mem_nhds, hx₁.1] rwa [derivWithin_of_mem_nhds this] rw [hxā‚‚, max_lt_iff] at hb linarith simp [Filter.eventually_false_iff_eq_bot, ← notMem_closure_iff_nhdsWithin_eq_bot] at hcontra /-- A real function whose derivative tends to minus infinity from the right at a point is not differentiable on the right at that point -/ theorem not_differentiableWithinAt_of_deriv_tendsto_atBot_Ioi (f : ā„ → ā„) {a : ā„} (hf : Tendsto (deriv f) (š“[>] a) atBot) : ¬ DifferentiableWithinAt ā„ f (Ioi a) a := by intro h have hf' : Tendsto (deriv (-f)) (š“[>] a) atTop := by rw [deriv.neg'] exact tendsto_neg_atBot_atTop.comp hf exact not_differentiableWithinAt_of_deriv_tendsto_atTop_Ioi (-f) hf' h.neg /-- A real function whose derivative tends to minus infinity from the left at a point is not differentiable on the left at that point -/ theorem not_differentiableWithinAt_of_deriv_tendsto_atBot_Iio (f : ā„ → ā„) {a : ā„} (hf : Tendsto (deriv f) (š“[<] a) atBot) : ¬ DifferentiableWithinAt ā„ f (Iio a) a := by let f' := f ∘ Neg.neg have hderiv : deriv f' =į¶ [š“[>] (-a)] -(deriv f ∘ Neg.neg) := by rw [atBot_basis.tendsto_right_iff] at hf specialize hf (-1) trivial rw [(nhdsLT_basis a).eventually_iff] at hf rw [EventuallyEq, (nhdsGT_basis (-a)).eventually_iff] obtain ⟨b, hb₁, hbā‚‚āŸ© := hf refine ⟨-b, by linarith, fun x hx => ?_⟩ simp only [Pi.neg_apply, Function.comp_apply] suffices deriv f' x = deriv f (-x) * deriv (Neg.neg : ā„ → ā„) x by simpa using this refine deriv_comp x (differentiableAt_of_deriv_ne_zero ?_) (by fun_prop) rw [mem_Ioo] at hx have h₁ : -x ∈ Ioo b a := ⟨by linarith, by linarith⟩ have hā‚‚ : deriv f (-x) ≤ -1 := hbā‚‚ h₁ exact ne_of_lt (by linarith) have hmain : ¬ DifferentiableWithinAt ā„ f' (Ioi (-a)) (-a) := by refine not_differentiableWithinAt_of_deriv_tendsto_atTop_Ioi f' <| Tendsto.congr' hderiv.symm ?_ refine Tendsto.comp (g := -deriv f) ?_ tendsto_neg_nhdsGT_neg exact Tendsto.comp (g := Neg.neg) tendsto_neg_atBot_atTop hf intro h have : DifferentiableWithinAt ā„ f' (Ioi (-a)) (-a) := by refine DifferentiableWithinAt.comp (g := f) (f := Neg.neg) (t := Iio a) (-a) ?_ ?_ ?_ Ā· simp [h] Ā· fun_prop Ā· intro x simp [neg_lt] exact hmain this /-- A real function whose derivative tends to infinity from the left at a point is not differentiable on the left at that point -/ theorem not_differentiableWithinAt_of_deriv_tendsto_atTop_Iio (f : ā„ → ā„) {a : ā„} (hf : Tendsto (deriv f) (š“[<] a) atTop) : ¬ DifferentiableWithinAt ā„ f (Iio a) a := by intro h have hf' : Tendsto (deriv (-f)) (š“[<] a) atBot := by rw [deriv.neg'] exact tendsto_neg_atTop_atBot.comp hf exact not_differentiableWithinAt_of_deriv_tendsto_atBot_Iio (-f) hf' h.neg end Interval /-- Let `f` be a function continuous on a convex (or, equivalently, connected) subset `D` of the real line. If `f` is differentiable on the interior of `D` and `C < f'`, then `f` grows faster than `C * x` on `D`, i.e., `C * (y - x) < f y - f x` whenever `x, y ∈ D`, `x < y`. -/ theorem Convex.mul_sub_lt_image_sub_of_lt_deriv {D : Set ā„} (hD : Convex ā„ D) {f : ā„ → ā„} (hf : ContinuousOn f D) (hf' : DifferentiableOn ā„ f (interior D)) {C} (hf'_gt : āˆ€ x ∈ interior D, C < deriv f x) : āˆ€įµ‰ (x ∈ D) (y ∈ D), x < y → C * (y - x) < f y - f x := by intro x hx y hy hxy have hxyD : Icc x y āŠ† D := hD.ordConnected.out hx hy have hxyD' : Ioo x y āŠ† interior D := subset_sUnion_of_mem ⟨isOpen_Ioo, Ioo_subset_Icc_self.trans hxyD⟩ obtain ⟨a, a_mem, ha⟩ : ∃ a ∈ Ioo x y, deriv f a = (f y - f x) / (y - x) := exists_deriv_eq_slope f hxy (hf.mono hxyD) (hf'.mono hxyD') have : C < (f y - f x) / (y - x) := ha ā–ø hf'_gt _ (hxyD' a_mem) exact (lt_div_iffā‚€ (sub_pos.2 hxy)).1 this /-- Let `f : ā„ → ā„` be a differentiable function. If `C < f'`, then `f` grows faster than `C * x`, i.e., `C * (y - x) < f y - f x` whenever `x < y`. -/ theorem mul_sub_lt_image_sub_of_lt_deriv {f : ā„ → ā„} (hf : Differentiable ā„ f) {C} (hf'_gt : āˆ€ x, C < deriv f x) ⦃x y⦄ (hxy : x < y) : C * (y - x) < f y - f x := convex_univ.mul_sub_lt_image_sub_of_lt_deriv hf.continuous.continuousOn hf.differentiableOn (fun x _ => hf'_gt x) x trivial y trivial hxy /-- Let `f` be a function continuous on a convex (or, equivalently, connected) subset `D` of the real line. If `f` is differentiable on the interior of `D` and `C ≤ f'`, then `f` grows at least as fast as `C * x` on `D`, i.e., `C * (y - x) ≤ f y - f x` whenever `x, y ∈ D`, `x ≤ y`. -/ theorem Convex.mul_sub_le_image_sub_of_le_deriv {D : Set ā„} (hD : Convex ā„ D) {f : ā„ → ā„} (hf : ContinuousOn f D) (hf' : DifferentiableOn ā„ f (interior D)) {C} (hf'_ge : āˆ€ x ∈ interior D, C ≤ deriv f x) : āˆ€įµ‰ (x ∈ D) (y ∈ D), x ≤ y → C * (y - x) ≤ f y - f x := by intro x hx y hy hxy rcases eq_or_lt_of_le hxy with hxy' | hxy' Ā· rw [hxy', sub_self, sub_self, mul_zero] have hxyD : Icc x y āŠ† D := hD.ordConnected.out hx hy have hxyD' : Ioo x y āŠ† interior D := subset_sUnion_of_mem ⟨isOpen_Ioo, Ioo_subset_Icc_self.trans hxyD⟩ obtain ⟨a, a_mem, ha⟩ : ∃ a ∈ Ioo x y, deriv f a = (f y - f x) / (y - x) := exists_deriv_eq_slope f hxy' (hf.mono hxyD) (hf'.mono hxyD') have : C ≤ (f y - f x) / (y - x) := ha ā–ø hf'_ge _ (hxyD' a_mem) exact (le_div_iffā‚€ (sub_pos.2 hxy')).1 this /-- Let `f : ā„ → ā„` be a differentiable function. If `C ≤ f'`, then `f` grows at least as fast as `C * x`, i.e., `C * (y - x) ≤ f y - f x` whenever `x ≤ y`. -/ theorem mul_sub_le_image_sub_of_le_deriv {f : ā„ → ā„} (hf : Differentiable ā„ f) {C} (hf'_ge : āˆ€ x, C ≤ deriv f x) ⦃x y⦄ (hxy : x ≤ y) : C * (y - x) ≤ f y - f x := convex_univ.mul_sub_le_image_sub_of_le_deriv hf.continuous.continuousOn hf.differentiableOn (fun x _ => hf'_ge x) x trivial y trivial hxy /-- Let `f` be a function continuous on a convex (or, equivalently, connected) subset `D` of the real line. If `f` is differentiable on the interior of `D` and `f' < C`, then `f` grows slower than `C * x` on `D`, i.e., `f y - f x < C * (y - x)` whenever `x, y ∈ D`, `x < y`. -/ theorem Convex.image_sub_lt_mul_sub_of_deriv_lt {D : Set ā„} (hD : Convex ā„ D) {f : ā„ → ā„} (hf : ContinuousOn f D) (hf' : DifferentiableOn ā„ f (interior D)) {C} (lt_hf' : āˆ€ x ∈ interior D, deriv f x < C) (x : ā„) (hx : x ∈ D) (y : ā„) (hy : y ∈ D) (hxy : x < y) : f y - f x < C * (y - x) := have hf'_gt : āˆ€ x ∈ interior D, -C < deriv (fun y => -f y) x := fun x hx => by rw [deriv.fun_neg, neg_lt_neg_iff] exact lt_hf' x hx by linarith [hD.mul_sub_lt_image_sub_of_lt_deriv hf.neg hf'.neg hf'_gt x hx y hy hxy] /-- Let `f : ā„ → ā„` be a differentiable function. If `f' < C`, then `f` grows slower than `C * x` on `D`, i.e., `f y - f x < C * (y - x)` whenever `x < y`. -/ theorem image_sub_lt_mul_sub_of_deriv_lt {f : ā„ → ā„} (hf : Differentiable ā„ f) {C} (lt_hf' : āˆ€ x, deriv f x < C) ⦃x y⦄ (hxy : x < y) : f y - f x < C * (y - x) := convex_univ.image_sub_lt_mul_sub_of_deriv_lt hf.continuous.continuousOn hf.differentiableOn (fun x _ => lt_hf' x) x trivial y trivial hxy /-- Let `f` be a function continuous on a convex (or, equivalently, connected) subset `D` of the real line. If `f` is differentiable on the interior of `D` and `f' ≤ C`, then `f` grows at most as fast as `C * x` on `D`, i.e., `f y - f x ≤ C * (y - x)` whenever `x, y ∈ D`, `x ≤ y`. -/ theorem Convex.image_sub_le_mul_sub_of_deriv_le {D : Set ā„} (hD : Convex ā„ D) {f : ā„ → ā„} (hf : ContinuousOn f D) (hf' : DifferentiableOn ā„ f (interior D)) {C} (le_hf' : āˆ€ x ∈ interior D, deriv f x ≤ C) (x : ā„) (hx : x ∈ D) (y : ā„) (hy : y ∈ D) (hxy : x ≤ y) : f y - f x ≤ C * (y - x) := have hf'_ge : āˆ€ x ∈ interior D, -C ≤ deriv (fun y => -f y) x := fun x hx => by rw [deriv.fun_neg, neg_le_neg_iff] exact le_hf' x hx by linarith [hD.mul_sub_le_image_sub_of_le_deriv hf.neg hf'.neg hf'_ge x hx y hy hxy] /-- Let `f : ā„ → ā„` be a differentiable function. If `f' ≤ C`, then `f` grows at most as fast as `C * x`, i.e., `f y - f x ≤ C * (y - x)` whenever `x ≤ y`. -/ theorem image_sub_le_mul_sub_of_deriv_le {f : ā„ → ā„} (hf : Differentiable ā„ f) {C} (le_hf' : āˆ€ x, deriv f x ≤ C) ⦃x y⦄ (hxy : x ≤ y) : f y - f x ≤ C * (y - x) := convex_univ.image_sub_le_mul_sub_of_deriv_le hf.continuous.continuousOn hf.differentiableOn (fun x _ => le_hf' x) x trivial y trivial hxy /-- Let `f` be a function continuous on a convex (or, equivalently, connected) subset `D` of the real line. If `f` is differentiable on the interior of `D` and `f'` is positive, then `f` is a strictly monotone function on `D`. Note that we don't require differentiability explicitly as it already implied by the derivative being strictly positive. -/ theorem strictMonoOn_of_deriv_pos {D : Set ā„} (hD : Convex ā„ D) {f : ā„ → ā„} (hf : ContinuousOn f D) (hf' : āˆ€ x ∈ interior D, 0 < deriv f x) : StrictMonoOn f D := by intro x hx y hy have : DifferentiableOn ā„ f (interior D) := fun z hz => (differentiableAt_of_deriv_ne_zero (hf' z hz).ne').differentiableWithinAt simpa only [zero_mul, sub_pos] using hD.mul_sub_lt_image_sub_of_lt_deriv hf this hf' x hx y hy /-- Let `f : ā„ → ā„` be a differentiable function. If `f'` is positive, then `f` is a strictly monotone function. Note that we don't require differentiability explicitly as it already implied by the derivative being strictly positive. -/ theorem strictMono_of_deriv_pos {f : ā„ → ā„} (hf' : āˆ€ x, 0 < deriv f x) : StrictMono f := strictMonoOn_univ.1 <| strictMonoOn_of_deriv_pos convex_univ (fun z _ => (differentiableAt_of_deriv_ne_zero (hf' z).ne').differentiableWithinAt.continuousWithinAt) fun x _ => hf' x /-- Let `f` be a function continuous on a convex (or, equivalently, connected) subset `D` of the real line. If `f` is differentiable on the interior of `D` and `f'` is strictly positive, then `f` is a strictly monotone function on `D`. -/ lemma strictMonoOn_of_hasDerivWithinAt_pos {D : Set ā„} (hD : Convex ā„ D) {f f' : ā„ → ā„} (hf : ContinuousOn f D) (hf' : āˆ€ x ∈ interior D, HasDerivWithinAt f (f' x) (interior D) x) (hf'ā‚€ : āˆ€ x ∈ interior D, 0 < f' x) : StrictMonoOn f D := strictMonoOn_of_deriv_pos hD hf fun x hx ↦ by rw [deriv_eqOn isOpen_interior hf' hx]; exact hf'ā‚€ _ hx /-- Let `f : ā„ → ā„` be a differentiable function. If `f'` is strictly positive, then `f` is a strictly monotone function. -/ lemma strictMono_of_hasDerivAt_pos {f f' : ā„ → ā„} (hf : āˆ€ x, HasDerivAt f (f' x) x) (hf' : āˆ€ x, 0 < f' x) : StrictMono f := strictMono_of_deriv_pos fun x ↦ by rw [(hf _).deriv]; exact hf' _ /-- Let `f` be a function continuous on a convex (or, equivalently, connected) subset `D` of the real line. If `f` is differentiable on the interior of `D` and `f'` is nonnegative, then `f` is a monotone function on `D`. -/ theorem monotoneOn_of_deriv_nonneg {D : Set ā„} (hD : Convex ā„ D) {f : ā„ → ā„} (hf : ContinuousOn f D) (hf' : DifferentiableOn ā„ f (interior D)) (hf'_nonneg : āˆ€ x ∈ interior D, 0 ≤ deriv f x) : MonotoneOn f D := fun x hx y hy hxy => by simpa only [zero_mul, sub_nonneg] using hD.mul_sub_le_image_sub_of_le_deriv hf hf' hf'_nonneg x hx y hy hxy /-- Let `f : ā„ → ā„` be a differentiable function. If `f'` is nonnegative, then `f` is a monotone function. -/ theorem monotone_of_deriv_nonneg {f : ā„ → ā„} (hf : Differentiable ā„ f) (hf' : āˆ€ x, 0 ≤ deriv f x) : Monotone f := monotoneOn_univ.1 <| monotoneOn_of_deriv_nonneg convex_univ hf.continuous.continuousOn hf.differentiableOn fun x _ => hf' x /-- Let `f` be a function continuous on a convex (or, equivalently, connected) subset `D` of the real line. If `f` is differentiable on the interior of `D` and `f'` is nonnegative, then `f` is a monotone function on `D`. -/ lemma monotoneOn_of_hasDerivWithinAt_nonneg {D : Set ā„} (hD : Convex ā„ D) {f f' : ā„ → ā„} (hf : ContinuousOn f D) (hf' : āˆ€ x ∈ interior D, HasDerivWithinAt f (f' x) (interior D) x) (hf'ā‚€ : āˆ€ x ∈ interior D, 0 ≤ f' x) : MonotoneOn f D := monotoneOn_of_deriv_nonneg hD hf (fun _ hx ↦ (hf' _ hx).differentiableWithinAt) fun x hx ↦ by rw [deriv_eqOn isOpen_interior hf' hx]; exact hf'ā‚€ _ hx /-- Let `f : ā„ → ā„` be a differentiable function. If `f'` is nonnegative, then `f` is a monotone function. -/ lemma monotone_of_hasDerivAt_nonneg {f f' : ā„ → ā„} (hf : āˆ€ x, HasDerivAt f (f' x) x) (hf' : 0 ≤ f') : Monotone f := monotone_of_deriv_nonneg (fun _ ↦ (hf _).differentiableAt) fun x ↦ by rw [(hf _).deriv]; exact hf' _ /-- Let `f` be a function continuous on a convex (or, equivalently, connected) subset `D` of the real line. If `f` is differentiable on the interior of `D` and `f'` is negative, then `f` is a strictly antitone function on `D`. -/ theorem strictAntiOn_of_deriv_neg {D : Set ā„} (hD : Convex ā„ D) {f : ā„ → ā„} (hf : ContinuousOn f D) (hf' : āˆ€ x ∈ interior D, deriv f x < 0) : StrictAntiOn f D := fun x hx y => by simpa only [zero_mul, sub_lt_zero] using hD.image_sub_lt_mul_sub_of_deriv_lt hf (fun z hz => (differentiableAt_of_deriv_ne_zero (hf' z hz).ne).differentiableWithinAt) hf' x hx y /-- Let `f : ā„ → ā„` be a differentiable function. If `f'` is negative, then `f` is a strictly antitone function. Note that we don't require differentiability explicitly as it already implied by the derivative being strictly negative. -/ theorem strictAnti_of_deriv_neg {f : ā„ → ā„} (hf' : āˆ€ x, deriv f x < 0) : StrictAnti f := strictAntiOn_univ.1 <| strictAntiOn_of_deriv_neg convex_univ (fun z _ => (differentiableAt_of_deriv_ne_zero (hf' z).ne).differentiableWithinAt.continuousWithinAt) fun x _ => hf' x /-- Let `f` be a function continuous on a convex (or, equivalently, connected) subset `D` of the real line. If `f` is differentiable on the interior of `D` and `f'` is strictly positive, then `f` is a strictly monotone function on `D`. -/ lemma strictAntiOn_of_hasDerivWithinAt_neg {D : Set ā„} (hD : Convex ā„ D) {f f' : ā„ → ā„} (hf : ContinuousOn f D) (hf' : āˆ€ x ∈ interior D, HasDerivWithinAt f (f' x) (interior D) x) (hf'ā‚€ : āˆ€ x ∈ interior D, f' x < 0) : StrictAntiOn f D := strictAntiOn_of_deriv_neg hD hf fun x hx ↦ by rw [deriv_eqOn isOpen_interior hf' hx]; exact hf'ā‚€ _ hx /-- Let `f : ā„ → ā„` be a differentiable function. If `f'` is strictly positive, then `f` is a strictly monotone function. -/ lemma strictAnti_of_hasDerivAt_neg {f f' : ā„ → ā„} (hf : āˆ€ x, HasDerivAt f (f' x) x) (hf' : āˆ€ x, f' x < 0) : StrictAnti f := strictAnti_of_deriv_neg fun x ↦ by rw [(hf _).deriv]; exact hf' _ /-- Let `f` be a function continuous on a convex (or, equivalently, connected) subset `D` of the real line. If `f` is differentiable on the interior of `D` and `f'` is nonpositive, then `f` is an antitone function on `D`. -/ theorem antitoneOn_of_deriv_nonpos {D : Set ā„} (hD : Convex ā„ D) {f : ā„ → ā„} (hf : ContinuousOn f D) (hf' : DifferentiableOn ā„ f (interior D)) (hf'_nonpos : āˆ€ x ∈ interior D, deriv f x ≤ 0) : AntitoneOn f D := fun x hx y hy hxy => by simpa only [zero_mul, sub_nonpos] using hD.image_sub_le_mul_sub_of_deriv_le hf hf' hf'_nonpos x hx y hy hxy /-- Let `f : ā„ → ā„` be a differentiable function. If `f'` is nonpositive, then `f` is an antitone function. -/ theorem antitone_of_deriv_nonpos {f : ā„ → ā„} (hf : Differentiable ā„ f) (hf' : āˆ€ x, deriv f x ≤ 0) : Antitone f := antitoneOn_univ.1 <| antitoneOn_of_deriv_nonpos convex_univ hf.continuous.continuousOn hf.differentiableOn fun x _ => hf' x /-- Let `f` be a function continuous on a convex (or, equivalently, connected) subset `D` of the real line. If `f` is differentiable on the interior of `D` and `f'` is nonpositive, then `f` is an antitone function on `D`. -/ lemma antitoneOn_of_hasDerivWithinAt_nonpos {D : Set ā„} (hD : Convex ā„ D) {f f' : ā„ → ā„} (hf : ContinuousOn f D) (hf' : āˆ€ x ∈ interior D, HasDerivWithinAt f (f' x) (interior D) x) (hf'ā‚€ : āˆ€ x ∈ interior D, f' x ≤ 0) : AntitoneOn f D := antitoneOn_of_deriv_nonpos hD hf (fun _ hx ↦ (hf' _ hx).differentiableWithinAt) fun x hx ↦ by rw [deriv_eqOn isOpen_interior hf' hx]; exact hf'ā‚€ _ hx /-- Let `f : ā„ → ā„` be a differentiable function. If `f'` is nonpositive, then `f` is an antitone function. -/ lemma antitone_of_hasDerivAt_nonpos {f f' : ā„ → ā„} (hf : āˆ€ x, HasDerivAt f (f' x) x) (hf' : f' ≤ 0) : Antitone f := antitone_of_deriv_nonpos (fun _ ↦ (hf _).differentiableAt) fun x ↦ by rw [(hf _).deriv]; exact hf' _ /-! ### Functions `f : E → ā„` -/ variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ā„ E] /-- Lagrange's **Mean Value Theorem**, applied to convex domains. -/ theorem domain_mvt {f : E → ā„} {s : Set E} {x y : E} {f' : E → StrongDual ā„ E} (hf : āˆ€ x ∈ s, HasFDerivWithinAt f (f' x) s x) (hs : Convex ā„ s) (xs : x ∈ s) (ys : y ∈ s) : ∃ z ∈ segment ā„ x y, f y - f x = f' z (y - x) := by -- Use `g = AffineMap.lineMap x y` to parametrize the segment set g : ā„ → E := fun t => AffineMap.lineMap x y t set I := Icc (0 : ā„) 1 have hsub : Ioo (0 : ā„) 1 āŠ† I := Ioo_subset_Icc_self have hmaps : MapsTo g I s := hs.mapsTo_lineMap xs ys -- The one-variable function `f ∘ g` has derivative `f' (g t) (y - x)` at each `t ∈ I` have hfg : āˆ€ t ∈ I, HasDerivWithinAt (f ∘ g) (f' (g t) (y - x)) I t := fun t ht => (hf _ (hmaps ht)).comp_hasDerivWithinAt t AffineMap.hasDerivWithinAt_lineMap hmaps -- apply 1-variable mean value theorem to pullback have hMVT : ∃ t ∈ Ioo (0 : ā„) 1, f' (g t) (y - x) = (f (g 1) - f (g 0)) / (1 - 0) := by refine exists_hasDerivAt_eq_slope (f ∘ g) _ (by simp) ?_ ?_ Ā· exact fun t Ht => (hfg t Ht).continuousWithinAt Ā· exact fun t Ht => (hfg t <| hsub Ht).hasDerivAt (Icc_mem_nhds Ht.1 Ht.2) -- reinterpret on domain rcases hMVT with ⟨t, Ht, hMVT'⟩ rw [segment_eq_image_lineMap, exists_mem_image] refine ⟨t, hsub Ht, ?_⟩ simpa [g] using hMVT'.symm
.lake/packages/mathlib/Mathlib/Analysis/Calculus/Deriv/Abs.lean
import Mathlib.Analysis.Calculus.Deriv.Add import Mathlib.Analysis.InnerProductSpace.Calculus /-! # Derivative of the absolute value This file compiles basic derivability properties of the absolute value, and is largely inspired from `Mathlib/Analysis/InnerProductSpace/Calculus.lean`, which is the analogous file for norms derived from an inner product space. ## Tags absolute value, derivative -/ open Filter Real Set variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ā„ E] variable {n : ā„•āˆž} {f : E → ā„} {f' : StrongDual ā„ E} {s : Set E} {x : E} theorem contDiffAt_abs {x : ā„} (hx : x ≠ 0) : ContDiffAt ā„ n (|Ā·|) x := contDiffAt_norm ā„ hx theorem ContDiffAt.abs (hf : ContDiffAt ā„ n f x) (hā‚€ : f x ≠ 0) : ContDiffAt ā„ n (fun x ↦ |f x|) x := hf.norm ā„ hā‚€ theorem contDiffWithinAt_abs {x : ā„} (hx : x ≠ 0) (s : Set ā„) : ContDiffWithinAt ā„ n (|Ā·|) s x := (contDiffAt_abs hx).contDiffWithinAt theorem ContDiffWithinAt.abs (hf : ContDiffWithinAt ā„ n f s x) (hā‚€ : f x ≠ 0) : ContDiffWithinAt ā„ n (fun y ↦ |f y|) s x := (contDiffAt_abs hā‚€).comp_contDiffWithinAt x hf theorem contDiffOn_abs {s : Set ā„} (hs : āˆ€ x ∈ s, x ≠ 0) : ContDiffOn ā„ n (|Ā·|) s := fun x hx ↦ contDiffWithinAt_abs (hs x hx) s theorem ContDiffOn.abs (hf : ContDiffOn ā„ n f s) (hā‚€ : āˆ€ x ∈ s, f x ≠ 0) : ContDiffOn ā„ n (fun y ↦ |f y|) s := fun x hx ↦ (hf x hx).abs (hā‚€ x hx) theorem ContDiff.abs (hf : ContDiff ā„ n f) (hā‚€ : āˆ€ x, f x ≠ 0) : ContDiff ā„ n fun y ↦ |f y| := contDiff_iff_contDiffAt.2 fun x ↦ hf.contDiffAt.abs (hā‚€ x) theorem hasStrictDerivAt_abs_neg {x : ā„} (hx : x < 0) : HasStrictDerivAt (|Ā·|) (-1) x := (hasStrictDerivAt_neg x).congr_of_eventuallyEq <| EqOn.eventuallyEq_of_mem (fun _ hy ↦ (abs_of_neg (mem_Iio.1 hy)).symm) (Iio_mem_nhds hx) theorem hasDerivAt_abs_neg {x : ā„} (hx : x < 0) : HasDerivAt (|Ā·|) (-1) x := (hasStrictDerivAt_abs_neg hx).hasDerivAt theorem hasStrictDerivAt_abs_pos {x : ā„} (hx : 0 < x) : HasStrictDerivAt (|Ā·|) 1 x := (hasStrictDerivAt_id x).congr_of_eventuallyEq <| EqOn.eventuallyEq_of_mem (fun _ hy ↦ (abs_of_pos (mem_Iio.1 hy)).symm) (Ioi_mem_nhds hx) theorem hasDerivAt_abs_pos {x : ā„} (hx : 0 < x) : HasDerivAt (|Ā·|) 1 x := (hasStrictDerivAt_abs_pos hx).hasDerivAt theorem hasStrictDerivAt_abs {x : ā„} (hx : x ≠ 0) : HasStrictDerivAt (|Ā·|) (SignType.sign x : ā„) x := by obtain hx | hx := hx.lt_or_gt Ā· simpa [hx] using hasStrictDerivAt_abs_neg hx Ā· simpa [hx] using hasStrictDerivAt_abs_pos hx theorem hasDerivAt_abs {x : ā„} (hx : x ≠ 0) : HasDerivAt (|Ā·|) (SignType.sign x : ā„) x := (hasStrictDerivAt_abs hx).hasDerivAt theorem HasStrictFDerivAt.abs_of_neg (hf : HasStrictFDerivAt f f' x) (hā‚€ : f x < 0) : HasStrictFDerivAt (fun x ↦ |f x|) (-f') x := by convert (hasStrictDerivAt_abs_neg hā‚€).hasStrictFDerivAt.comp x hf using 1 ext y simp theorem HasFDerivAt.abs_of_neg (hf : HasFDerivAt f f' x) (hā‚€ : f x < 0) : HasFDerivAt (fun x ↦ |f x|) (-f') x := by convert (hasDerivAt_abs_neg hā‚€).hasFDerivAt.comp x hf using 1 ext y simp theorem HasStrictFDerivAt.abs_of_pos (hf : HasStrictFDerivAt f f' x) (hā‚€ : 0 < f x) : HasStrictFDerivAt (fun x ↦ |f x|) f' x := by convert (hasStrictDerivAt_abs_pos hā‚€).hasStrictFDerivAt.comp x hf using 1 ext y simp theorem HasFDerivAt.abs_of_pos (hf : HasFDerivAt f f' x) (hā‚€ : 0 < f x) : HasFDerivAt (fun x ↦ |f x|) f' x := by convert (hasDerivAt_abs_pos hā‚€).hasFDerivAt.comp x hf using 1 ext y simp theorem HasStrictFDerivAt.abs (hf : HasStrictFDerivAt f f' x) (hā‚€ : f x ≠ 0) : HasStrictFDerivAt (fun x ↦ |f x|) ((SignType.sign (f x) : ā„) • f') x := by convert (hasStrictDerivAt_abs hā‚€).hasStrictFDerivAt.comp x hf using 1 ext y simp [mul_comm] theorem HasFDerivAt.abs (hf : HasFDerivAt f f' x) (hā‚€ : f x ≠ 0) : HasFDerivAt (fun x ↦ |f x|) ((SignType.sign (f x) : ā„) • f') x := by convert (hasDerivAt_abs hā‚€).hasFDerivAt.comp x hf using 1 ext y simp [mul_comm] theorem hasDerivWithinAt_abs_neg (s : Set ā„) {x : ā„} (hx : x < 0) : HasDerivWithinAt (|Ā·|) (-1) s x := (hasDerivAt_abs_neg hx).hasDerivWithinAt theorem hasDerivWithinAt_abs_pos (s : Set ā„) {x : ā„} (hx : 0 < x) : HasDerivWithinAt (|Ā·|) 1 s x := (hasDerivAt_abs_pos hx).hasDerivWithinAt theorem hasDerivWithinAt_abs (s : Set ā„) {x : ā„} (hx : x ≠ 0) : HasDerivWithinAt (|Ā·|) (SignType.sign x : ā„) s x := (hasDerivAt_abs hx).hasDerivWithinAt theorem HasFDerivWithinAt.abs_of_neg (hf : HasFDerivWithinAt f f' s x) (hā‚€ : f x < 0) : HasFDerivWithinAt (fun x ↦ |f x|) (-f') s x := by convert (hasDerivAt_abs_neg hā‚€).comp_hasFDerivWithinAt x hf using 1 simp theorem HasFDerivWithinAt.abs_of_pos (hf : HasFDerivWithinAt f f' s x) (hā‚€ : 0 < f x) : HasFDerivWithinAt (fun x ↦ |f x|) f' s x := by convert (hasDerivAt_abs_pos hā‚€).comp_hasFDerivWithinAt x hf using 1 simp theorem HasFDerivWithinAt.abs (hf : HasFDerivWithinAt f f' s x) (hā‚€ : f x ≠ 0) : HasFDerivWithinAt (fun x ↦ |f x|) ((SignType.sign (f x) : ā„) • f') s x := (hasDerivAt_abs hā‚€).comp_hasFDerivWithinAt x hf theorem differentiableAt_abs_neg {x : ā„} (hx : x < 0) : DifferentiableAt ā„ (|Ā·|) x := (hasDerivAt_abs_neg hx).differentiableAt theorem differentiableAt_abs_pos {x : ā„} (hx : 0 < x) : DifferentiableAt ā„ (|Ā·|) x := (hasDerivAt_abs_pos hx).differentiableAt theorem differentiableAt_abs {x : ā„} (hx : x ≠ 0) : DifferentiableAt ā„ (|Ā·|) x := (hasDerivAt_abs hx).differentiableAt theorem DifferentiableAt.abs_of_neg (hf : DifferentiableAt ā„ f x) (hā‚€ : f x < 0) : DifferentiableAt ā„ (fun x ↦ |f x|) x := (differentiableAt_abs_neg hā‚€).comp x hf theorem DifferentiableAt.abs_of_pos (hf : DifferentiableAt ā„ f x) (hā‚€ : 0 < f x) : DifferentiableAt ā„ (fun x ↦ |f x|) x := (differentiableAt_abs_pos hā‚€).comp x hf theorem DifferentiableAt.abs (hf : DifferentiableAt ā„ f x) (hā‚€ : f x ≠ 0) : DifferentiableAt ā„ (fun x ↦ |f x|) x := (differentiableAt_abs hā‚€).comp x hf theorem differentiableWithinAt_abs_neg (s : Set ā„) {x : ā„} (hx : x < 0) : DifferentiableWithinAt ā„ (|Ā·|) s x := (differentiableAt_abs_neg hx).differentiableWithinAt theorem differentiableWithinAt_abs_pos (s : Set ā„) {x : ā„} (hx : 0 < x) : DifferentiableWithinAt ā„ (|Ā·|) s x := (differentiableAt_abs_pos hx).differentiableWithinAt theorem differentiableWithinAt_abs (s : Set ā„) {x : ā„} (hx : x ≠ 0) : DifferentiableWithinAt ā„ (|Ā·|) s x := (differentiableAt_abs hx).differentiableWithinAt theorem DifferentiableWithinAt.abs_of_neg (hf : DifferentiableWithinAt ā„ f s x) (hā‚€ : f x < 0) : DifferentiableWithinAt ā„ (fun x ↦ |f x|) s x := (differentiableAt_abs_neg hā‚€).comp_differentiableWithinAt x hf theorem DifferentiableWithinAt.abs_of_pos (hf : DifferentiableWithinAt ā„ f s x) (hā‚€ : 0 < f x) : DifferentiableWithinAt ā„ (fun x ↦ |f x|) s x := (differentiableAt_abs_pos hā‚€).comp_differentiableWithinAt x hf theorem DifferentiableWithinAt.abs (hf : DifferentiableWithinAt ā„ f s x) (hā‚€ : f x ≠ 0) : DifferentiableWithinAt ā„ (fun x ↦ |f x|) s x := (differentiableAt_abs hā‚€).comp_differentiableWithinAt x hf theorem differentiableOn_abs {s : Set ā„} (hs : āˆ€ x ∈ s, x ≠ 0) : DifferentiableOn ā„ (|Ā·|) s := fun x hx ↦ differentiableWithinAt_abs s (hs x hx) theorem DifferentiableOn.abs (hf : DifferentiableOn ā„ f s) (hā‚€ : āˆ€ x ∈ s, f x ≠ 0) : DifferentiableOn ā„ (fun x ↦ |f x|) s := fun x hx ↦ (hf x hx).abs (hā‚€ x hx) theorem Differentiable.abs (hf : Differentiable ā„ f) (hā‚€ : āˆ€ x, f x ≠ 0) : Differentiable ā„ (fun x ↦ |f x|) := fun x ↦ (hf x).abs (hā‚€ x) theorem not_differentiableAt_abs_zero : ¬ DifferentiableAt ā„ (abs : ā„ → ā„) 0 := by intro h have h₁ : deriv abs (0 : ā„) = 1 := (uniqueDiffOn_Ici _ _ Set.left_mem_Ici).eq_deriv _ h.hasDerivAt.hasDerivWithinAt <| (hasDerivWithinAt_id _ _).congr_of_mem (fun _ h ↦ abs_of_nonneg h) Set.left_mem_Ici have hā‚‚ : deriv abs (0 : ā„) = -1 := (uniqueDiffOn_Iic _ _ Set.right_mem_Iic).eq_deriv _ h.hasDerivAt.hasDerivWithinAt <| (hasDerivWithinAt_neg _ _).congr_of_mem (fun _ h ↦ abs_of_nonpos h) Set.right_mem_Iic linarith theorem deriv_abs_neg {x : ā„} (hx : x < 0) : deriv (|Ā·|) x = -1 := (hasDerivAt_abs_neg hx).deriv theorem deriv_abs_pos {x : ā„} (hx : 0 < x) : deriv (|Ā·|) x = 1 := (hasDerivAt_abs_pos hx).deriv theorem deriv_abs_zero : deriv (|Ā·|) (0 : ā„) = 0 := deriv_zero_of_not_differentiableAt not_differentiableAt_abs_zero theorem deriv_abs (x : ā„) : deriv (|Ā·|) x = SignType.sign x := by obtain rfl | hx := eq_or_ne x 0 Ā· simpa using deriv_abs_zero Ā· simpa [hx] using (hasDerivAt_abs hx).deriv
.lake/packages/mathlib/Mathlib/Analysis/Calculus/Deriv/Inv.lean
import Mathlib.Analysis.Calculus.Deriv.Mul import Mathlib.Analysis.Calculus.Deriv.Comp /-! # Derivatives of `x ↦ x⁻¹` and `f x / g x` In this file we prove `(x⁻¹)' = -1 / x ^ 2`, `((f x)⁻¹)' = -f' x / (f x) ^ 2`, and `(f x / g x)' = (f' x * g x - f x * g' x) / (g x) ^ 2` for different notions of derivative. For a more detailed overview of one-dimensional derivatives in mathlib, see the module docstring of `Analysis/Calculus/Deriv/Basic`. ## Keywords derivative -/ universe u open scoped Topology open Filter Asymptotics Set open ContinuousLinearMap (smulRight) variable {š•œ : Type u} [NontriviallyNormedField š•œ] {x : š•œ} {s : Set š•œ} section Inverse /-! ### Derivative of `x ↦ x⁻¹` -/ theorem hasStrictDerivAt_inv (hx : x ≠ 0) : HasStrictDerivAt Inv.inv (-(x ^ 2)⁻¹) x := by suffices (fun p : š•œ Ɨ š•œ => (p.1 - p.2) * ((x * x)⁻¹ - (p.1 * p.2)⁻¹)) =o[š“ (x, x)] fun p => (p.1 - p.2) * 1 by refine .of_isLittleO <| this.congr' ?_ (Eventually.of_forall fun _ => mul_one _) refine Eventually.mono ((isOpen_ne.prod isOpen_ne).mem_nhds ⟨hx, hx⟩) ?_ rintro ⟨y, z⟩ ⟨hy, hz⟩ simp only [mem_setOf_eq] at hy hz simp [field] ring refine (isBigO_refl (fun p : š•œ Ɨ š•œ => p.1 - p.2) _).mul_isLittleO ((isLittleO_one_iff š•œ).2 ?_) rw [← sub_self (x * x)⁻¹] exact tendsto_const_nhds.sub ((continuous_mul.tendsto (x, x)).invā‚€ <| mul_ne_zero hx hx) theorem hasDerivAt_inv (x_ne_zero : x ≠ 0) : HasDerivAt (fun y => y⁻¹) (-(x ^ 2)⁻¹) x := (hasStrictDerivAt_inv x_ne_zero).hasDerivAt theorem hasDerivWithinAt_inv (x_ne_zero : x ≠ 0) (s : Set š•œ) : HasDerivWithinAt (fun x => x⁻¹) (-(x ^ 2)⁻¹) s x := (hasDerivAt_inv x_ne_zero).hasDerivWithinAt theorem differentiableAt_inv_iff : DifferentiableAt š•œ (fun x => x⁻¹) x ↔ x ≠ 0 := ⟨fun H => NormedField.continuousAt_inv.1 H.continuousAt, fun H => (hasDerivAt_inv H).differentiableAt⟩ theorem deriv_inv : deriv (fun x => x⁻¹) x = -(x ^ 2)⁻¹ := by rcases eq_or_ne x 0 with (rfl | hne) Ā· simp [deriv_zero_of_not_differentiableAt (mt differentiableAt_inv_iff.1 (not_not.2 rfl))] Ā· exact (hasDerivAt_inv hne).deriv @[simp] theorem deriv_inv' : (deriv fun x : š•œ => x⁻¹) = fun x => -(x ^ 2)⁻¹ := funext fun _ => deriv_inv theorem derivWithin_inv (x_ne_zero : x ≠ 0) (hxs : UniqueDiffWithinAt š•œ s x) : derivWithin (fun x => x⁻¹) s x = -(x ^ 2)⁻¹ := by rw [DifferentiableAt.derivWithin (differentiableAt_inv x_ne_zero) hxs] exact deriv_inv theorem hasFDerivAt_inv (x_ne_zero : x ≠ 0) : HasFDerivAt (fun x => x⁻¹) (smulRight (1 : š•œ →L[š•œ] š•œ) (-(x ^ 2)⁻¹) : š•œ →L[š•œ] š•œ) x := hasDerivAt_inv x_ne_zero theorem hasStrictFDerivAt_inv (x_ne_zero : x ≠ 0) : HasStrictFDerivAt (fun x => x⁻¹) (smulRight (1 : š•œ →L[š•œ] š•œ) (-(x ^ 2)⁻¹) : š•œ →L[š•œ] š•œ) x := hasStrictDerivAt_inv x_ne_zero theorem hasFDerivWithinAt_inv (x_ne_zero : x ≠ 0) : HasFDerivWithinAt (fun x => x⁻¹) (smulRight (1 : š•œ →L[š•œ] š•œ) (-(x ^ 2)⁻¹) : š•œ →L[š•œ] š•œ) s x := (hasFDerivAt_inv x_ne_zero).hasFDerivWithinAt theorem fderiv_inv : fderiv š•œ (fun x => x⁻¹) x = smulRight (1 : š•œ →L[š•œ] š•œ) (-(x ^ 2)⁻¹) := by rw [← deriv_fderiv, deriv_inv] theorem fderivWithin_inv (x_ne_zero : x ≠ 0) (hxs : UniqueDiffWithinAt š•œ s x) : fderivWithin š•œ (fun x => x⁻¹) s x = smulRight (1 : š•œ →L[š•œ] š•œ) (-(x ^ 2)⁻¹) := by rw [DifferentiableAt.fderivWithin (differentiableAt_inv x_ne_zero) hxs] exact fderiv_inv variable {c : š•œ → š•œ} {c' : š•œ} theorem HasDerivWithinAt.fun_inv (hc : HasDerivWithinAt c c' s x) (hx : c x ≠ 0) : HasDerivWithinAt (fun y => (c y)⁻¹) (-c' / c x ^ 2) s x := by convert (hasDerivAt_inv hx).comp_hasDerivWithinAt x hc using 1 ring theorem HasDerivWithinAt.inv (hc : HasDerivWithinAt c c' s x) (hx : c x ≠ 0) : HasDerivWithinAt (c⁻¹) (-c' / c x ^ 2) s x := hc.fun_inv hx theorem HasDerivAt.fun_inv (hc : HasDerivAt c c' x) (hx : c x ≠ 0) : HasDerivAt (fun y => (c y)⁻¹) (-c' / c x ^ 2) x := by rw [← hasDerivWithinAt_univ] at * exact hc.inv hx theorem HasDerivAt.inv (hc : HasDerivAt c c' x) (hx : c x ≠ 0) : HasDerivAt (c⁻¹) (-c' / c x ^ 2) x := hc.fun_inv hx theorem derivWithin_fun_inv' (hc : DifferentiableWithinAt š•œ c s x) (hx : c x ≠ 0) : derivWithin (fun x => (c x)⁻¹) s x = -derivWithin c s x / c x ^ 2 := by by_cases hsx : UniqueDiffWithinAt š•œ s x Ā· exact (hc.hasDerivWithinAt.inv hx).derivWithin hsx Ā· simp [derivWithin_zero_of_not_uniqueDiffWithinAt hsx] theorem derivWithin_inv' (hc : DifferentiableWithinAt š•œ c s x) (hx : c x ≠ 0) : derivWithin (c⁻¹) s x = -derivWithin c s x / c x ^ 2 := derivWithin_fun_inv' hc hx @[simp] theorem deriv_fun_inv'' (hc : DifferentiableAt š•œ c x) (hx : c x ≠ 0) : deriv (fun x => (c x)⁻¹) x = -deriv c x / c x ^ 2 := (hc.hasDerivAt.inv hx).deriv @[simp] theorem deriv_inv'' (hc : DifferentiableAt š•œ c x) (hx : c x ≠ 0) : deriv (c⁻¹) x = -deriv c x / c x ^ 2 := (hc.hasDerivAt.inv hx).deriv end Inverse section Division /-! ### Derivative of `x ↦ c x / d x` -/ variable {š•œ' : Type*} [NontriviallyNormedField š•œ'] [NormedAlgebra š•œ š•œ'] {c d : š•œ → š•œ'} {c' d' : š•œ'} theorem HasDerivWithinAt.fun_div (hc : HasDerivWithinAt c c' s x) (hd : HasDerivWithinAt d d' s x) (hx : d x ≠ 0) : HasDerivWithinAt (fun y => c y / d y) ((c' * d x - c x * d') / d x ^ 2) s x := by convert hc.fun_mul ((hasDerivAt_inv hx).comp_hasDerivWithinAt x hd) using 1 Ā· simp only [div_eq_mul_inv, (Ā· ∘ Ā·)] Ā· simp [field] ring theorem HasDerivWithinAt.div (hc : HasDerivWithinAt c c' s x) (hd : HasDerivWithinAt d d' s x) (hx : d x ≠ 0) : HasDerivWithinAt (c / d) ((c' * d x - c x * d') / d x ^ 2) s x := hc.fun_div hd hx theorem HasStrictDerivAt.fun_div (hc : HasStrictDerivAt c c' x) (hd : HasStrictDerivAt d d' x) (hx : d x ≠ 0) : HasStrictDerivAt (fun y => c y / d y) ((c' * d x - c x * d') / d x ^ 2) x := by convert hc.fun_mul ((hasStrictDerivAt_inv hx).comp x hd) using 1 Ā· simp only [div_eq_mul_inv, (Ā· ∘ Ā·)] Ā· simp [field] ring theorem HasStrictDerivAt.div (hc : HasStrictDerivAt c c' x) (hd : HasStrictDerivAt d d' x) (hx : d x ≠ 0) : HasStrictDerivAt (c / d) ((c' * d x - c x * d') / d x ^ 2) x := hc.fun_div hd hx theorem HasDerivAt.fun_div (hc : HasDerivAt c c' x) (hd : HasDerivAt d d' x) (hx : d x ≠ 0) : HasDerivAt (fun y => c y / d y) ((c' * d x - c x * d') / d x ^ 2) x := by rw [← hasDerivWithinAt_univ] at * exact hc.div hd hx theorem HasDerivAt.div (hc : HasDerivAt c c' x) (hd : HasDerivAt d d' x) (hx : d x ≠ 0) : HasDerivAt (c / d) ((c' * d x - c x * d') / d x ^ 2) x := hc.fun_div hd hx theorem DifferentiableWithinAt.fun_div (hc : DifferentiableWithinAt š•œ c s x) (hd : DifferentiableWithinAt š•œ d s x) (hx : d x ≠ 0) : DifferentiableWithinAt š•œ (fun x => c x / d x) s x := (hc.hasDerivWithinAt.div hd.hasDerivWithinAt hx).differentiableWithinAt theorem DifferentiableWithinAt.div (hc : DifferentiableWithinAt š•œ c s x) (hd : DifferentiableWithinAt š•œ d s x) (hx : d x ≠ 0) : DifferentiableWithinAt š•œ (c / d) s x := hc.fun_div hd hx @[simp, fun_prop] theorem DifferentiableAt.fun_div (hc : DifferentiableAt š•œ c x) (hd : DifferentiableAt š•œ d x) (hx : d x ≠ 0) : DifferentiableAt š•œ (fun x => c x / d x) x := (hc.hasDerivAt.div hd.hasDerivAt hx).differentiableAt @[simp, fun_prop] theorem DifferentiableAt.div (hc : DifferentiableAt š•œ c x) (hd : DifferentiableAt š•œ d x) (hx : d x ≠ 0) : DifferentiableAt š•œ (c / d) x := hc.fun_div hd hx @[fun_prop] theorem DifferentiableOn.fun_div (hc : DifferentiableOn š•œ c s) (hd : DifferentiableOn š•œ d s) (hx : āˆ€ x ∈ s, d x ≠ 0) : DifferentiableOn š•œ (fun x => c x / d x) s := fun x h => (hc x h).div (hd x h) (hx x h) @[fun_prop] theorem DifferentiableOn.div (hc : DifferentiableOn š•œ c s) (hd : DifferentiableOn š•œ d s) (hx : āˆ€ x ∈ s, d x ≠ 0) : DifferentiableOn š•œ (c / d) s := fun x h => (hc x h).div (hd x h) (hx x h) @[simp, fun_prop] theorem Differentiable.fun_div (hc : Differentiable š•œ c) (hd : Differentiable š•œ d) (hx : āˆ€ x, d x ≠ 0) : Differentiable š•œ (fun x => c x / d x) := fun x => (hc x).div (hd x) (hx x) @[simp, fun_prop] theorem Differentiable.div (hc : Differentiable š•œ c) (hd : Differentiable š•œ d) (hx : āˆ€ x, d x ≠ 0) : Differentiable š•œ (c / d) := fun x => (hc x).div (hd x) (hx x) theorem derivWithin_fun_div (hc : DifferentiableWithinAt š•œ c s x) (hd : DifferentiableWithinAt š•œ d s x) (hx : d x ≠ 0) : derivWithin (fun x => c x / d x) s x = (derivWithin c s x * d x - c x * derivWithin d s x) / d x ^ 2 := by by_cases hsx : UniqueDiffWithinAt š•œ s x Ā· exact (hc.hasDerivWithinAt.div hd.hasDerivWithinAt hx).derivWithin hsx Ā· simp [derivWithin_zero_of_not_uniqueDiffWithinAt hsx] theorem derivWithin_div (hc : DifferentiableWithinAt š•œ c s x) (hd : DifferentiableWithinAt š•œ d s x) (hx : d x ≠ 0) : derivWithin (c / d) s x = (derivWithin c s x * d x - c x * derivWithin d s x) / d x ^ 2 := derivWithin_fun_div hc hd hx @[simp] theorem deriv_fun_div (hc : DifferentiableAt š•œ c x) (hd : DifferentiableAt š•œ d x) (hx : d x ≠ 0) : deriv (fun x => c x / d x) x = (deriv c x * d x - c x * deriv d x) / d x ^ 2 := (hc.hasDerivAt.div hd.hasDerivAt hx).deriv @[simp] theorem deriv_div (hc : DifferentiableAt š•œ c x) (hd : DifferentiableAt š•œ d x) (hx : d x ≠ 0) : deriv (c / d) x = (deriv c x * d x - c x * deriv d x) / d x ^ 2 := (hc.hasDerivAt.div hd.hasDerivAt hx).deriv end Division
.lake/packages/mathlib/Mathlib/Analysis/Calculus/InverseFunctionTheorem/Deriv.lean
import Mathlib.Analysis.Calculus.Deriv.Inverse import Mathlib.Analysis.Calculus.InverseFunctionTheorem.FDeriv /-! # Inverse function theorem, 1D case In this file we prove a version of the inverse function theorem for maps `f : š•œ → š•œ`. We use `ContinuousLinearEquiv.unitsEquivAut` to translate `HasStrictDerivAt f f' a` and `f' ≠ 0` into `HasStrictFDerivAt f (_ : š•œ ā‰ƒL[š•œ] š•œ) a`. -/ open Filter open scoped Topology variable {š•œ : Type*} [NontriviallyNormedField š•œ] [CompleteSpace š•œ] (f : š•œ → š•œ) noncomputable section namespace HasStrictDerivAt variable (f' a : š•œ) (hf : HasStrictDerivAt f f' a) (hf' : f' ≠ 0) include hf hf' /-- A function that is inverse to `f` near `a`. -/ abbrev localInverse : š•œ → š•œ := (hf.hasStrictFDerivAt_equiv hf').localInverse _ _ _ variable {f f' a} theorem map_nhds_eq : map f (š“ a) = š“ (f a) := (hf.hasStrictFDerivAt_equiv hf').map_nhds_eq_of_equiv theorem to_localInverse : HasStrictDerivAt (hf.localInverse f f' a hf') f'⁻¹ (f a) := (hf.hasStrictFDerivAt_equiv hf').to_localInverse theorem to_local_left_inverse {g : š•œ → š•œ} (hg : āˆ€į¶  x in š“ a, g (f x) = x) : HasStrictDerivAt g f'⁻¹ (f a) := (hf.hasStrictFDerivAt_equiv hf').to_local_left_inverse hg end HasStrictDerivAt variable {f} /-- If a function has a non-zero strict derivative at all points, then it is an open map. -/ theorem isOpenMap_of_hasStrictDerivAt {f' : š•œ → š•œ} (hf : āˆ€ x, HasStrictDerivAt f (f' x) x) (h0 : āˆ€ x, f' x ≠ 0) : IsOpenMap f := isOpenMap_iff_nhds_le.2 fun x => ((hf x).map_nhds_eq (h0 x)).ge
.lake/packages/mathlib/Mathlib/Analysis/Calculus/InverseFunctionTheorem/ContDiff.lean
import Mathlib.Analysis.Calculus.ContDiff.Operations import Mathlib.Analysis.Calculus.ContDiff.RCLike import Mathlib.Analysis.Calculus.InverseFunctionTheorem.FDeriv /-! # Inverse function theorem, `C^r` case In this file we specialize the inverse function theorem to `C^r`-smooth functions. -/ noncomputable section namespace ContDiffAt variable {š•‚ : Type*} [RCLike š•‚] variable {E : Type*} [NormedAddCommGroup E] [NormedSpace š•‚ E] variable {F : Type*} [NormedAddCommGroup F] [NormedSpace š•‚ F] variable [CompleteSpace E] (f : E → F) {f' : E ā‰ƒL[š•‚] F} {a : E} {n : WithTop ā„•āˆž} /-- Given a `ContDiff` function over `š•‚` (which is `ā„` or `ā„‚`) with an invertible derivative at `a`, returns an `OpenPartialHomeomorph` with `to_fun = f` and `a ∈ source`. -/ def toOpenPartialHomeomorph (hf : ContDiffAt š•‚ n f a) (hf' : HasFDerivAt f (f' : E →L[š•‚] F) a) (hn : 1 ≤ n) : OpenPartialHomeomorph E F := (hf.hasStrictFDerivAt' hf' hn).toOpenPartialHomeomorph f @[deprecated (since := "2025-08-29")] noncomputable alias toPartialHomeomorph := toOpenPartialHomeomorph variable {f} @[simp] theorem toOpenPartialHomeomorph_coe (hf : ContDiffAt š•‚ n f a) (hf' : HasFDerivAt f (f' : E →L[š•‚] F) a) (hn : 1 ≤ n) : (hf.toOpenPartialHomeomorph f hf' hn : E → F) = f := rfl @[deprecated (since := "2025-08-29")] alias toPartialHomeomorph_coe := toOpenPartialHomeomorph_coe theorem mem_toOpenPartialHomeomorph_source (hf : ContDiffAt š•‚ n f a) (hf' : HasFDerivAt f (f' : E →L[š•‚] F) a) (hn : 1 ≤ n) : a ∈ (hf.toOpenPartialHomeomorph f hf' hn).source := (hf.hasStrictFDerivAt' hf' hn).mem_toOpenPartialHomeomorph_source @[deprecated (since := "2025-08-29")] alias mem_toPartialHomeomorph_source := mem_toOpenPartialHomeomorph_source theorem image_mem_toOpenPartialHomeomorph_target (hf : ContDiffAt š•‚ n f a) (hf' : HasFDerivAt f (f' : E →L[š•‚] F) a) (hn : 1 ≤ n) : f a ∈ (hf.toOpenPartialHomeomorph f hf' hn).target := (hf.hasStrictFDerivAt' hf' hn).image_mem_toOpenPartialHomeomorph_target @[deprecated (since := "2025-08-29")] alias image_mem_toPartialHomeomorph_target := image_mem_toOpenPartialHomeomorph_target /-- Given a `ContDiff` function over `š•‚` (which is `ā„` or `ā„‚`) with an invertible derivative at `a`, returns a function that is locally inverse to `f`. -/ def localInverse (hf : ContDiffAt š•‚ n f a) (hf' : HasFDerivAt f (f' : E →L[š•‚] F) a) (hn : 1 ≤ n) : F → E := (hf.hasStrictFDerivAt' hf' hn).localInverse f f' a theorem localInverse_apply_image (hf : ContDiffAt š•‚ n f a) (hf' : HasFDerivAt f (f' : E →L[š•‚] F) a) (hn : 1 ≤ n) : hf.localInverse hf' hn (f a) = a := (hf.hasStrictFDerivAt' hf' hn).localInverse_apply_image /-- Given a `ContDiff` function over `š•‚` (which is `ā„` or `ā„‚`) with an invertible derivative at `a`, the inverse function (produced by `ContDiff.toOpenPartialHomeomorph`) is also `ContDiff`. -/ theorem to_localInverse (hf : ContDiffAt š•‚ n f a) (hf' : HasFDerivAt f (f' : E →L[š•‚] F) a) (hn : 1 ≤ n) : ContDiffAt š•‚ n (hf.localInverse hf' hn) (f a) := by have := hf.localInverse_apply_image hf' hn apply (hf.toOpenPartialHomeomorph f hf' hn).contDiffAt_symm (image_mem_toOpenPartialHomeomorph_target hf hf' hn) Ā· convert hf' Ā· convert hf end ContDiffAt
.lake/packages/mathlib/Mathlib/Analysis/Calculus/InverseFunctionTheorem/ApproximatesLinearOn.lean
import Mathlib.Analysis.Normed.Operator.Banach import Mathlib.Analysis.Normed.Operator.NormedSpace import Mathlib.Topology.OpenPartialHomeomorph /-! # Non-linear maps close to affine maps In this file we study a map `f` such that `‖f x - f y - f' (x - y)‖ ≤ c * ‖x - y‖` on an open set `s`, where `f' : E →L[š•œ] F` is a continuous linear map and `c` is suitably small. Maps of this type behave like `f a + f' (x - a)` near each `a ∈ s`. When `f'` is onto, we show that `f` is locally onto. When `f'` is a continuous linear equiv, we show that `f` is a homeomorphism between `s` and `f '' s`. More precisely, we define `ApproximatesLinearOn.toOpenPartialHomeomorph` to be an `OpenPartialHomeomorph` with `toFun = f`, `source = s`, and `target = f '' s`. between `s` and `f '' s`. More precisely, we define `ApproximatesLinearOn.toOpenPartialHomeomorph` to be an `OpenPartialHomeomorph` with `toFun = f`, `source = s`, and `target = f '' s`. Maps of this type naturally appear in the proof of the inverse function theorem (see next section), and `ApproximatesLinearOn.toOpenPartialHomeomorph` will imply that the locally inverse function and `ApproximatesLinearOn.toOpenPartialHomeomorph` will imply that the locally inverse function exists. We define this auxiliary notion to split the proof of the inverse function theorem into small lemmas. This approach makes it possible - to prove a lower estimate on the size of the domain of the inverse function; - to reuse parts of the proofs in the case if a function is not strictly differentiable. E.g., for a function `f : E Ɨ F → G` with estimates on `f x y₁ - f x yā‚‚` but not on `f x₁ y - f xā‚‚ y`. ## Notation We introduce some `local notation` to make formulas shorter: * by `N` we denote `‖f'⁻¹‖`; * by `g` we denote the auxiliary contracting map `x ↦ x + f'.symm (y - f x)` used to prove that `{x | f x = y}` is nonempty. -/ open Function Set Filter Metric open scoped Topology NNReal noncomputable section variable {š•œ : Type*} [NontriviallyNormedField š•œ] variable {E : Type*} [NormedAddCommGroup E] [NormedSpace š•œ E] variable {F : Type*} [NormedAddCommGroup F] [NormedSpace š•œ F] variable {ε : ā„} open Filter Metric Set open ContinuousLinearMap (id) /-- We say that `f` approximates a continuous linear map `f'` on `s` with constant `c`, if `‖f x - f y - f' (x - y)‖ ≤ c * ‖x - y‖` whenever `x, y ∈ s`. This predicate is defined to facilitate the splitting of the inverse function theorem into small lemmas. Some of these lemmas can be useful, e.g., to prove that the inverse function is defined on a specific set. -/ def ApproximatesLinearOn (f : E → F) (f' : E →L[š•œ] F) (s : Set E) (c : ā„ā‰„0) : Prop := āˆ€ x ∈ s, āˆ€ y ∈ s, ‖f x - f y - f' (x - y)‖ ≤ c * ‖x - y‖ @[simp] theorem approximatesLinearOn_empty (f : E → F) (f' : E →L[š•œ] F) (c : ā„ā‰„0) : ApproximatesLinearOn f f' āˆ… c := by simp [ApproximatesLinearOn] namespace ApproximatesLinearOn variable {f : E → F} /-! First we prove some properties of a function that `ApproximatesLinearOn` a (not necessarily invertible) continuous linear map. -/ section variable {f' : E →L[š•œ] F} {s t : Set E} {c c' : ā„ā‰„0} theorem mono_num (hc : c ≤ c') (hf : ApproximatesLinearOn f f' s c) : ApproximatesLinearOn f f' s c' := fun x hx y hy => le_trans (hf x hx y hy) (mul_le_mul_of_nonneg_right hc <| norm_nonneg _) theorem mono_set (hst : s āŠ† t) (hf : ApproximatesLinearOn f f' t c) : ApproximatesLinearOn f f' s c := fun x hx y hy => hf x (hst hx) y (hst hy) theorem approximatesLinearOn_iff_lipschitzOnWith {f : E → F} {f' : E →L[š•œ] F} {s : Set E} {c : ā„ā‰„0} : ApproximatesLinearOn f f' s c ↔ LipschitzOnWith c (f - ⇑f') s := by have : āˆ€ x y, f x - f y - f' (x - y) = (f - f') x - (f - f') y := fun x y ↦ by simp only [map_sub, Pi.sub_apply]; abel simp only [this, lipschitzOnWith_iff_norm_sub_le, ApproximatesLinearOn] alias ⟨lipschitzOnWith, _root_.LipschitzOnWith.approximatesLinearOn⟩ := approximatesLinearOn_iff_lipschitzOnWith theorem lipschitz_sub (hf : ApproximatesLinearOn f f' s c) : LipschitzWith c fun x : s => f x - f' x := hf.lipschitzOnWith.to_restrict protected theorem lipschitz (hf : ApproximatesLinearOn f f' s c) : LipschitzWith (‖f'ā€–ā‚Š + c) (s.restrict f) := by simpa only [restrict_apply, add_sub_cancel] using (f'.lipschitz.restrict s).add hf.lipschitz_sub protected theorem continuous (hf : ApproximatesLinearOn f f' s c) : Continuous (s.restrict f) := hf.lipschitz.continuous protected theorem continuousOn (hf : ApproximatesLinearOn f f' s c) : ContinuousOn f s := continuousOn_iff_continuous_restrict.2 hf.continuous end section LocallyOnto /-! We prove that a function which is linearly approximated by a continuous linear map with a nonlinear right inverse is locally onto. This will apply to the case where the approximating map is a linear equivalence, for the local inverse theorem, but also whenever the approximating map is onto, by Banach's open mapping theorem. -/ variable [CompleteSpace E] {s : Set E} {c : ā„ā‰„0} {f' : E →L[š•œ] F} /-- If a function is linearly approximated by a continuous linear map with a (possibly nonlinear) right inverse, then it is locally onto: a ball of an explicit radius is included in the image of the map. -/ theorem surjOn_closedBall_of_nonlinearRightInverse (hf : ApproximatesLinearOn f f' s c) (f'symm : f'.NonlinearRightInverse) {ε : ā„} {b : E} (ε0 : 0 ≤ ε) (hε : closedBall b ε āŠ† s) : SurjOn f (closedBall b ε) (closedBall (f b) (((f'symm.nnnorm : ā„)⁻¹ - c) * ε)) := by intro y hy rcases le_or_gt (f'symm.nnnorm : ā„)⁻¹ c with hc | hc Ā· refine ⟨b, by simp [ε0], ?_⟩ have : dist y (f b) ≤ 0 := (mem_closedBall.1 hy).trans (mul_nonpos_of_nonpos_of_nonneg (by linarith) ε0) simp only [dist_le_zero] at this rw [this] have If' : (0 : ā„) < f'symm.nnnorm := by rw [← inv_pos]; exact (NNReal.coe_nonneg _).trans_lt hc have Icf' : (c : ā„) * f'symm.nnnorm < 1 := by rwa [inv_eq_one_div, lt_div_iffā‚€ If'] at hc have Jcf' : (1 : ā„) - c * f'symm.nnnorm ≠ 0 := by apply ne_of_gt; linarith /- We have to show that `y` can be written as `f x` for some `x ∈ closedBall b ε`. The idea of the proof is to apply the Banach contraction principle to the map `g : x ↦ x + f'symm (y - f x)`, as a fixed point of this map satisfies `f x = y`. When `f'symm` is a genuine linear inverse, `g` is a contracting map. In our case, since `f'symm` is nonlinear, this map is not contracting (it is not even continuous), but still the proof of the contraction theorem holds: `uā‚™ = gⁿ b` is a Cauchy sequence, converging exponentially fast to the desired point `x`. Instead of appealing to general results, we check this by hand. The main point is that `f (u n)` becomes exponentially close to `y`, and therefore `dist (u (n+1)) (u n)` becomes exponentally small, making it possible to get an inductive bound on `dist (u n) b`, from which one checks that `u n` stays in the ball on which one has a control. Therefore, the bound can be checked at the next step, and so on inductively. -/ set g := fun x => x + f'symm (y - f x) with hg set u := fun n : ā„• => g^[n] b with hu have usucc : āˆ€ n, u (n + 1) = g (u n) := by simp [hu, ← iterate_succ_apply' g _ b] -- First bound: if `f z` is close to `y`, then `g z` is close to `z` (i.e., almost a fixed point). have A : āˆ€ z, dist (g z) z ≤ f'symm.nnnorm * dist (f z) y := by intro z rw [dist_eq_norm, hg, add_sub_cancel_left, dist_eq_norm'] exact f'symm.bound _ -- Second bound: if `z` and `g z` are in the set with good control, then `f (g z)` becomes closer -- to `y` than `f z` was (this uses the linear approximation property, and is the reason for the -- choice of the formula for `g`). have B : āˆ€ z ∈ closedBall b ε, g z ∈ closedBall b ε → dist (f (g z)) y ≤ c * f'symm.nnnorm * dist (f z) y := by intro z hz hgz set v := f'symm (y - f z) calc dist (f (g z)) y = ‖f (z + v) - y‖ := by rw [dist_eq_norm] _ = ‖f (z + v) - f z - f' v + f' v - (y - f z)‖ := by congr 1; abel _ = ‖f (z + v) - f z - f' (z + v - z)‖ := by simp only [v, ContinuousLinearMap.NonlinearRightInverse.right_inv, add_sub_cancel_left, sub_add_cancel] _ ≤ c * ‖z + v - z‖ := hf _ (hε hgz) _ (hε hz) _ ≤ c * (f'symm.nnnorm * dist (f z) y) := by gcongr simpa [dist_eq_norm'] using f'symm.bound (y - f z) _ = c * f'symm.nnnorm * dist (f z) y := by ring -- Third bound: a complicated bound on `dist w b` (that will show up in the induction) is enough -- to check that `w` is in the ball on which one has controls. Will be used to check that `u n` -- belongs to this ball for all `n`. have C : āˆ€ (n : ā„•) (w : E), dist w b ≤ f'symm.nnnorm * (1 - ((c : ā„) * f'symm.nnnorm) ^ n) / (1 - c * f'symm.nnnorm) * dist (f b) y → w ∈ closedBall b ε := fun n w hw ↦ by apply hw.trans rw [div_mul_eq_mul_div, div_le_iffā‚€]; swap; Ā· linarith calc (f'symm.nnnorm : ā„) * (1 - ((c : ā„) * f'symm.nnnorm) ^ n) * dist (f b) y = f'symm.nnnorm * dist (f b) y * (1 - ((c : ā„) * f'symm.nnnorm) ^ n) := by ring _ ≤ f'symm.nnnorm * dist (f b) y * 1 := by gcongr rw [sub_le_self_iff] positivity _ ≤ f'symm.nnnorm * (((f'symm.nnnorm : ā„)⁻¹ - c) * ε) := by rw [mul_one] gcongr exact mem_closedBall'.1 hy _ = ε * (1 - c * f'symm.nnnorm) := by field /- Main inductive control: `f (u n)` becomes exponentially close to `y`, and therefore `dist (u (n+1)) (u n)` becomes exponentally small, making it possible to get an inductive bound on `dist (u n) b`, from which one checks that `u n` remains in the ball on which we have estimates. -/ have D : āˆ€ n : ā„•, dist (f (u n)) y ≤ ((c : ā„) * f'symm.nnnorm) ^ n * dist (f b) y ∧ dist (u n) b ≤ f'symm.nnnorm * (1 - ((c : ā„) * f'symm.nnnorm) ^ n) / (1 - (c : ā„) * f'symm.nnnorm) * dist (f b) y := fun n ↦ by induction n with | zero => simp [hu, le_refl] | succ n IH => ?_ rw [usucc] have Ign : dist (g (u n)) b ≤ f'symm.nnnorm * (1 - ((c : ā„) * f'symm.nnnorm) ^ n.succ) / (1 - c * f'symm.nnnorm) * dist (f b) y := calc dist (g (u n)) b ≤ dist (g (u n)) (u n) + dist (u n) b := dist_triangle _ _ _ _ ≤ f'symm.nnnorm * dist (f (u n)) y + dist (u n) b := add_le_add (A _) le_rfl _ ≤ f'symm.nnnorm * (((c : ā„) * f'symm.nnnorm) ^ n * dist (f b) y) + f'symm.nnnorm * (1 - ((c : ā„) * f'symm.nnnorm) ^ n) / (1 - c * f'symm.nnnorm) * dist (f b) y := by gcongr Ā· exact IH.1 Ā· exact IH.2 _ = f'symm.nnnorm * (1 - ((c : ā„) * f'symm.nnnorm) ^ n.succ) / (1 - (c : ā„) * f'symm.nnnorm) * dist (f b) y := by replace Jcf' : (1:ā„) - f'symm.nnnorm * c ≠ 0 := by convert Jcf' using 1; ring simp [field, pow_succ, -mul_eq_mul_left_iff] ring refine ⟨?_, Ign⟩ calc dist (f (g (u n))) y ≤ c * f'symm.nnnorm * dist (f (u n)) y := B _ (C n _ IH.2) (C n.succ _ Ign) _ ≤ (c : ā„) * f'symm.nnnorm * (((c : ā„) * f'symm.nnnorm) ^ n * dist (f b) y) := by gcongr apply IH.1 _ = ((c : ā„) * f'symm.nnnorm) ^ n.succ * dist (f b) y := by simp only [pow_succ']; ring -- Deduce from the inductive bound that `uā‚™` is a Cauchy sequence, therefore converging. have : CauchySeq u := by refine cauchySeq_of_le_geometric _ (↑f'symm.nnnorm * dist (f b) y) Icf' fun n ↦ ?_ calc dist (u n) (u (n + 1)) = dist (g (u n)) (u n) := by rw [usucc, dist_comm] _ ≤ f'symm.nnnorm * dist (f (u n)) y := A _ _ ≤ f'symm.nnnorm * (((c : ā„) * f'symm.nnnorm) ^ n * dist (f b) y) := by gcongr exact (D n).1 _ = f'symm.nnnorm * dist (f b) y * ((c : ā„) * f'symm.nnnorm) ^ n := by ring obtain ⟨x, hx⟩ : ∃ x, Tendsto u atTop (š“ x) := cauchySeq_tendsto_of_complete this -- As all the `uā‚™` belong to the ball `closedBall b ε`, so does their limit `x`. have xmem : x ∈ closedBall b ε := isClosed_closedBall.mem_of_tendsto hx (Eventually.of_forall fun n => C n _ (D n).2) refine ⟨x, xmem, ?_⟩ -- It remains to check that `f x = y`. This follows from continuity of `f` on `closedBall b ε` -- and from the fact that `f uā‚™` is converging to `y` by construction. have hx' : Tendsto u atTop (š“[closedBall b ε] x) := by simp only [nhdsWithin, tendsto_inf, hx, true_and, tendsto_principal] exact Eventually.of_forall fun n => C n _ (D n).2 have T1 : Tendsto (f ∘ u) atTop (š“ (f x)) := (hf.continuousOn.mono hε x xmem).tendsto.comp hx' have T2 : Tendsto (f ∘ u) atTop (š“ y) := by rw [tendsto_iff_dist_tendsto_zero] refine squeeze_zero (fun _ => dist_nonneg) (fun n => (D n).1) ?_ simpa using (tendsto_pow_atTop_nhds_zero_of_lt_one (by positivity) Icf').mul tendsto_const_nhds exact tendsto_nhds_unique T1 T2 theorem open_image (hf : ApproximatesLinearOn f f' s c) (f'symm : f'.NonlinearRightInverse) (hs : IsOpen s) (hc : Subsingleton F ∨ c < f'symm.nnnorm⁻¹) : IsOpen (f '' s) := by rcases hc with hE | hc Ā· exact isOpen_discrete _ simp only [isOpen_iff_mem_nhds, nhds_basis_closedBall.mem_iff, forall_mem_image] at hs ⊢ intro x hx rcases hs x hx with ⟨ε, ε0, hε⟩ refine ⟨(f'symm.nnnorm⁻¹ - c) * ε, mul_pos (sub_pos.2 hc) ε0, ?_⟩ exact (hf.surjOn_closedBall_of_nonlinearRightInverse f'symm (le_of_lt ε0) hε).mono hε Subset.rfl theorem image_mem_nhds (hf : ApproximatesLinearOn f f' s c) (f'symm : f'.NonlinearRightInverse) {x : E} (hs : s ∈ š“ x) (hc : Subsingleton F ∨ c < f'symm.nnnorm⁻¹) : f '' s ∈ š“ (f x) := by obtain ⟨t, hts, ht, xt⟩ : ∃ t, t āŠ† s ∧ IsOpen t ∧ x ∈ t := _root_.mem_nhds_iff.1 hs have := IsOpen.mem_nhds ((hf.mono_set hts).open_image f'symm ht hc) (mem_image_of_mem _ xt) exact mem_of_superset this (image_mono hts) theorem map_nhds_eq (hf : ApproximatesLinearOn f f' s c) (f'symm : f'.NonlinearRightInverse) {x : E} (hs : s ∈ š“ x) (hc : Subsingleton F ∨ c < f'symm.nnnorm⁻¹) : map f (š“ x) = š“ (f x) := by refine le_antisymm ((hf.continuousOn x (mem_of_mem_nhds hs)).continuousAt hs) (le_map fun t ht => ?_) have : f '' (s ∩ t) ∈ š“ (f x) := (hf.mono_set inter_subset_left).image_mem_nhds f'symm (inter_mem hs ht) hc exact mem_of_superset this (image_mono inter_subset_right) end LocallyOnto /-! From now on we assume that `f` approximates an invertible continuous linear map `f : E ā‰ƒL[š•œ] F`. We also assume that either `E = {0}`, or `c < ‖f'⁻¹‖⁻¹`. We use `N` as an abbreviation for `‖f'⁻¹‖`. -/ variable {f' : E ā‰ƒL[š•œ] F} {s : Set E} {c : ā„ā‰„0} local notation "N" => ‖(f'.symm : F →L[š•œ] E)ā€–ā‚Š protected theorem antilipschitz (hf : ApproximatesLinearOn f (f' : E →L[š•œ] F) s c) (hc : Subsingleton E ∨ c < N⁻¹) : AntilipschitzWith (N⁻¹ - c)⁻¹ (s.restrict f) := by rcases hc with hE | hc Ā· exact AntilipschitzWith.of_subsingleton convert (f'.antilipschitz.restrict s).add_lipschitzWith hf.lipschitz_sub hc simp [restrict] protected theorem injective (hf : ApproximatesLinearOn f (f' : E →L[š•œ] F) s c) (hc : Subsingleton E ∨ c < N⁻¹) : Injective (s.restrict f) := (hf.antilipschitz hc).injective protected theorem injOn (hf : ApproximatesLinearOn f (f' : E →L[š•œ] F) s c) (hc : Subsingleton E ∨ c < N⁻¹) : InjOn f s := injOn_iff_injective.2 <| hf.injective hc protected theorem surjective [CompleteSpace E] (hf : ApproximatesLinearOn f (f' : E →L[š•œ] F) univ c) (hc : Subsingleton E ∨ c < N⁻¹) : Surjective f := by rcases hc with hE | hc Ā· haveI : Subsingleton F := (Equiv.subsingleton_congr f'.toEquiv).1 hE exact surjective_to_subsingleton _ Ā· apply forall_of_forall_mem_closedBall (fun y : F => ∃ a, f a = y) (f 0) _ have hc' : (0 : ā„) < N⁻¹ - c := by rw [sub_pos]; exact hc let p : ā„ → Prop := fun R => closedBall (f 0) R āŠ† Set.range f have hp : āˆ€į¶  r : ā„ in atTop, p ((N⁻¹ - c) * r) := by have hr : āˆ€į¶  r : ā„ in atTop, 0 ≤ r := eventually_ge_atTop 0 refine hr.mono fun r hr => Subset.trans ?_ (image_subset_range f (closedBall 0 r)) refine hf.surjOn_closedBall_of_nonlinearRightInverse f'.toNonlinearRightInverse hr ?_ exact subset_univ _ refine ((tendsto_id.const_mul_atTop hc').frequently hp.frequently).mono ?_ exact fun R h y hy => h hy /-- A map approximating a linear equivalence on a set defines a partial equivalence on this set. Should not be used outside of this file, because it is superseded by `toOpenPartialHomeomorph` below. This is a first step towards the inverse function. -/ def toPartialEquiv (hf : ApproximatesLinearOn f (f' : E →L[š•œ] F) s c) (hc : Subsingleton E ∨ c < N⁻¹) : PartialEquiv E F := (hf.injOn hc).toPartialEquiv _ _ /-- The inverse function is continuous on `f '' s`. Use properties of `OpenPartialHomeomorph` instead. -/ theorem inverse_continuousOn (hf : ApproximatesLinearOn f (f' : E →L[š•œ] F) s c) (hc : Subsingleton E ∨ c < N⁻¹) : ContinuousOn (hf.toPartialEquiv hc).symm (f '' s) := by apply continuousOn_iff_continuous_restrict.2 refine ((hf.antilipschitz hc).to_rightInvOn' ?_ (hf.toPartialEquiv hc).right_inv').continuous exact fun x hx => (hf.toPartialEquiv hc).map_target hx /-- The inverse function is approximated linearly on `f '' s` by `f'.symm`. -/ theorem to_inv (hf : ApproximatesLinearOn f (f' : E →L[š•œ] F) s c) (hc : Subsingleton E ∨ c < N⁻¹) : ApproximatesLinearOn (hf.toPartialEquiv hc).symm (f'.symm : F →L[š•œ] E) (f '' s) (N * (N⁻¹ - c)⁻¹ * c) := fun x hx y hy ↦ by set A := hf.toPartialEquiv hc have Af : āˆ€ z, A z = f z := fun z => rfl rcases (mem_image _ _ _).1 hx with ⟨x', x's, rfl⟩ rcases (mem_image _ _ _).1 hy with ⟨y', y's, rfl⟩ rw [← Af x', ← Af y', A.left_inv x's, A.left_inv y's] calc ‖x' - y' - f'.symm (A x' - A y')‖ ≤ N * ‖f' (x' - y' - f'.symm (A x' - A y'))‖ := (f' : E →L[š•œ] F).bound_of_antilipschitz f'.antilipschitz _ _ = N * ‖A y' - A x' - f' (y' - x')‖ := by congr 2 simp only [ContinuousLinearEquiv.apply_symm_apply, ContinuousLinearEquiv.map_sub] abel _ ≤ N * (c * ‖y' - x'‖) := mul_le_mul_of_nonneg_left (hf _ y's _ x's) (NNReal.coe_nonneg _) _ ≤ N * (c * (((N⁻¹ - c)⁻¹ : ā„ā‰„0) * ‖A y' - A x'‖)) := by gcongr rw [← dist_eq_norm, ← dist_eq_norm] exact (hf.antilipschitz hc).le_mul_dist ⟨y', y's⟩ ⟨x', x's⟩ _ = (N * (N⁻¹ - c)⁻¹ * c : ā„ā‰„0) * ‖A x' - A y'‖ := by simp only [norm_sub_rev, NNReal.coe_mul]; ring variable [CompleteSpace E] section variable (f s) /-- Given a function `f` that approximates a linear equivalence on an open set `s`, returns a open partial homeomorphism with `toFun = f` and `source = s`. -/ def toOpenPartialHomeomorph (hf : ApproximatesLinearOn f (f' : E →L[š•œ] F) s c) (hc : Subsingleton E ∨ c < N⁻¹) (hs : IsOpen s) : OpenPartialHomeomorph E F where toPartialEquiv := hf.toPartialEquiv hc open_source := hs open_target := hf.open_image f'.toNonlinearRightInverse hs <| by rwa [f'.toEquiv.subsingleton_congr] at hc continuousOn_toFun := hf.continuousOn continuousOn_invFun := hf.inverse_continuousOn hc @[deprecated (since := "2025-08-29")] noncomputable alias toPartialHomeomorph := toOpenPartialHomeomorph @[simp] theorem toOpenPartialHomeomorph_coe (hf : ApproximatesLinearOn f (f' : E →L[š•œ] F) s c) (hc : Subsingleton E ∨ c < N⁻¹) (hs : IsOpen s) : (hf.toOpenPartialHomeomorph f s hc hs : E → F) = f := rfl @[deprecated (since := "2025-08-29")] alias toPartialHomeomorph_coe := toOpenPartialHomeomorph_coe @[simp] theorem toOpenPartialHomeomorph_source (hf : ApproximatesLinearOn f (f' : E →L[š•œ] F) s c) (hc : Subsingleton E ∨ c < N⁻¹) (hs : IsOpen s) : (hf.toOpenPartialHomeomorph f s hc hs).source = s := rfl @[deprecated (since := "2025-08-29")] alias toPartialHomeomorph_source := toOpenPartialHomeomorph_source @[simp] theorem toOpenPartialHomeomorph_target (hf : ApproximatesLinearOn f (f' : E →L[š•œ] F) s c) (hc : Subsingleton E ∨ c < N⁻¹) (hs : IsOpen s) : (hf.toOpenPartialHomeomorph f s hc hs).target = f '' s := rfl @[deprecated (since := "2025-08-29")] alias toPartialHomeomorph_target := toOpenPartialHomeomorph_target /-- A function `f` that approximates a linear equivalence on the whole space is a homeomorphism. -/ def toHomeomorph (hf : ApproximatesLinearOn f (f' : E →L[š•œ] F) univ c) (hc : Subsingleton E ∨ c < N⁻¹) : E ā‰ƒā‚œ F := by refine (hf.toOpenPartialHomeomorph _ _ hc isOpen_univ).toHomeomorphOfSourceEqUnivTargetEqUniv rfl ?_ rw [toOpenPartialHomeomorph_target, image_univ, range_eq_univ] exact hf.surjective hc end theorem closedBall_subset_target (hf : ApproximatesLinearOn f (f' : E →L[š•œ] F) s c) (hc : Subsingleton E ∨ c < N⁻¹) (hs : IsOpen s) {b : E} (ε0 : 0 ≤ ε) (hε : closedBall b ε āŠ† s) : closedBall (f b) ((N⁻¹ - c) * ε) āŠ† (hf.toOpenPartialHomeomorph f s hc hs).target := (hf.surjOn_closedBall_of_nonlinearRightInverse f'.toNonlinearRightInverse ε0 hε).mono hε Subset.rfl end ApproximatesLinearOn
.lake/packages/mathlib/Mathlib/Analysis/Calculus/InverseFunctionTheorem/FDeriv.lean
import Mathlib.Analysis.Calculus.FDeriv.Equiv import Mathlib.Analysis.Calculus.InverseFunctionTheorem.ApproximatesLinearOn /-! # Inverse function theorem In this file we prove the inverse function theorem. It says that if a map `f : E → F` has an invertible strict derivative `f'` at `a`, then it is locally invertible, and the inverse function has derivative `f' ⁻¹`. We define `HasStrictFDerivAt.toOpenPartialHomeomorph` that repacks a function `f` with a `hf : HasStrictFDerivAt f f' a`, `f' : E ā‰ƒL[š•œ] F`, into an `OpenPartialHomeomorph`. The `toFun` of this `OpenPartialHomeomorph` is defeq to `f`, so one can apply theorems about `OpenPartialHomeomorph` to `hf.toOpenPartialHomeomorph f`, and get statements about `f`. Then we define `HasStrictFDerivAt.localInverse` to be the `invFun` of this `OpenPartialHomeomorph`, and prove two versions of the inverse function theorem: * `HasStrictFDerivAt.to_localInverse`: if `f` has an invertible derivative `f'` at `a` in the strict sense (`hf`), then `hf.localInverse f f' a` has derivative `f'.symm` at `f a` in the strict sense; * `HasStrictFDerivAt.to_local_left_inverse`: if `f` has an invertible derivative `f'` at `a` in the strict sense and `g` is locally left inverse to `f` near `a`, then `g` has derivative `f'.symm` at `f a` in the strict sense. Some related theorems, providing the derivative and higher regularity assuming that we already know the inverse function, are formulated in the `Analysis/Calculus/FDeriv` and `Analysis/Calculus/Deriv` folders, and in `ContDiff.lean`. ## Tags derivative, strictly differentiable, continuously differentiable, smooth, inverse function -/ open Function Set Filter Metric open scoped Topology NNReal noncomputable section variable {š•œ : Type*} [NontriviallyNormedField š•œ] variable {E : Type*} [NormedAddCommGroup E] [NormedSpace š•œ E] variable {F : Type*} [NormedAddCommGroup F] [NormedSpace š•œ F] open Asymptotics Filter Metric Set open ContinuousLinearMap (id) /-! ### Inverse function theorem Let `f : E → F` be a map defined on a complete vector space `E`. Assume that `f` has an invertible derivative `f' : E ā‰ƒL[š•œ] F` at `a : E` in the strict sense. Then `f` approximates `f'` in the sense of `ApproximatesLinearOn` on an open neighborhood of `a`, and we can apply `ApproximatesLinearOn.toOpenPartialHomeomorph` to construct the inverse function. -/ namespace HasStrictFDerivAt /-- If `f` has derivative `f'` at `a` in the strict sense and `c > 0`, then `f` approximates `f'` with constant `c` on some neighborhood of `a`. -/ theorem approximates_deriv_on_nhds {f : E → F} {f' : E →L[š•œ] F} {a : E} (hf : HasStrictFDerivAt f f' a) {c : ā„ā‰„0} (hc : Subsingleton E ∨ 0 < c) : ∃ s ∈ š“ a, ApproximatesLinearOn f f' s c := by rcases hc with hE | hc Ā· refine ⟨univ, IsOpen.mem_nhds isOpen_univ trivial, fun x _ y _ => ?_⟩ simp [@Subsingleton.elim E hE x y] have := hf.isLittleO.def hc rw [nhds_prod_eq, Filter.Eventually, mem_prod_same_iff] at this rcases this with ⟨s, has, hs⟩ exact ⟨s, has, fun x hx y hy => hs (mk_mem_prod hx hy)⟩ theorem map_nhds_eq_of_surj [CompleteSpace E] [CompleteSpace F] {f : E → F} {f' : E →L[š•œ] F} {a : E} (hf : HasStrictFDerivAt f (f' : E →L[š•œ] F) a) (h : LinearMap.range f' = ⊤) : map f (š“ a) = š“ (f a) := by let f'symm := f'.nonlinearRightInverseOfSurjective h set c : ā„ā‰„0 := f'symm.nnnorm⁻¹ / 2 with hc have f'symm_pos : 0 < f'symm.nnnorm := f'.nonlinearRightInverseOfSurjective_nnnorm_pos h have cpos : 0 < c := by simp [hc, inv_pos, f'symm_pos] obtain ⟨s, s_nhds, hs⟩ : ∃ s ∈ š“ a, ApproximatesLinearOn f f' s c := hf.approximates_deriv_on_nhds (Or.inr cpos) apply hs.map_nhds_eq f'symm s_nhds (Or.inr (NNReal.half_lt_self _)) simp [ne_of_gt f'symm_pos] variable {f : E → F} {f' : E ā‰ƒL[š•œ] F} {a : E} theorem approximates_deriv_on_open_nhds (hf : HasStrictFDerivAt f (f' : E →L[š•œ] F) a) : ∃ s : Set E, a ∈ s ∧ IsOpen s ∧ ApproximatesLinearOn f (f' : E →L[š•œ] F) s (‖(f'.symm : F →L[š•œ] E)ā€–ā‚Šā»Ā¹ / 2) := by simp only [← and_assoc] refine ((nhds_basis_opens a).exists_iff fun s t => ApproximatesLinearOn.mono_set).1 ?_ exact hf.approximates_deriv_on_nhds <| f'.subsingleton_or_nnnorm_symm_pos.imp id fun hf' => half_pos <| inv_pos.2 hf' variable (f) variable [CompleteSpace E] /-- Given a function with an invertible strict derivative at `a`, returns an `OpenPartialHomeomorph` with `to_fun = f` and `a ∈ source`. This is a part of the inverse function theorem. The other part `HasStrictFDerivAt.to_localInverse` states that the inverse function of this `OpenPartialHomeomorph` has derivative `f'.symm`. -/ def toOpenPartialHomeomorph (hf : HasStrictFDerivAt f (f' : E →L[š•œ] F) a) : OpenPartialHomeomorph E F := ApproximatesLinearOn.toOpenPartialHomeomorph f (Classical.choose hf.approximates_deriv_on_open_nhds) (Classical.choose_spec hf.approximates_deriv_on_open_nhds).2.2 (f'.subsingleton_or_nnnorm_symm_pos.imp id fun hf' => NNReal.half_lt_self <| ne_of_gt <| inv_pos.2 hf') (Classical.choose_spec hf.approximates_deriv_on_open_nhds).2.1 @[deprecated (since := "2025-08-29")] noncomputable alias toPartialHomeomorph := toOpenPartialHomeomorph variable {f} @[simp] theorem toOpenPartialHomeomorph_coe (hf : HasStrictFDerivAt f (f' : E →L[š•œ] F) a) : (hf.toOpenPartialHomeomorph f : E → F) = f := rfl @[deprecated (since := "2025-08-29")] alias toPartialHomeomorph_coe := toOpenPartialHomeomorph_coe theorem mem_toOpenPartialHomeomorph_source (hf : HasStrictFDerivAt f (f' : E →L[š•œ] F) a) : a ∈ (hf.toOpenPartialHomeomorph f).source := (Classical.choose_spec hf.approximates_deriv_on_open_nhds).1 @[deprecated (since := "2025-08-29")] alias mem_toPartialHomeomorph_source := mem_toOpenPartialHomeomorph_source theorem image_mem_toOpenPartialHomeomorph_target (hf : HasStrictFDerivAt f (f' : E →L[š•œ] F) a) : f a ∈ (hf.toOpenPartialHomeomorph f).target := (hf.toOpenPartialHomeomorph f).map_source hf.mem_toOpenPartialHomeomorph_source @[deprecated (since := "2025-08-29")] alias image_mem_toPartialHomeomorph_target := image_mem_toOpenPartialHomeomorph_target theorem map_nhds_eq_of_equiv (hf : HasStrictFDerivAt f (f' : E →L[š•œ] F) a) : map f (š“ a) = š“ (f a) := (hf.toOpenPartialHomeomorph f).map_nhds_eq hf.mem_toOpenPartialHomeomorph_source variable (f f' a) /-- Given a function `f` with an invertible derivative, returns a function that is locally inverse to `f`. -/ def localInverse (hf : HasStrictFDerivAt f (f' : E →L[š•œ] F) a) : F → E := (hf.toOpenPartialHomeomorph f).symm variable {f f' a} theorem localInverse_def (hf : HasStrictFDerivAt f (f' : E →L[š•œ] F) a) : hf.localInverse f _ _ = (hf.toOpenPartialHomeomorph f).symm := rfl theorem eventually_left_inverse (hf : HasStrictFDerivAt f (f' : E →L[š•œ] F) a) : āˆ€į¶  x in š“ a, hf.localInverse f f' a (f x) = x := (hf.toOpenPartialHomeomorph f).eventually_left_inverse hf.mem_toOpenPartialHomeomorph_source @[simp] theorem localInverse_apply_image (hf : HasStrictFDerivAt f (f' : E →L[š•œ] F) a) : hf.localInverse f f' a (f a) = a := hf.eventually_left_inverse.self_of_nhds theorem eventually_right_inverse (hf : HasStrictFDerivAt f (f' : E →L[š•œ] F) a) : āˆ€į¶  y in š“ (f a), f (hf.localInverse f f' a y) = y := (hf.toOpenPartialHomeomorph f).eventually_right_inverse' hf.mem_toOpenPartialHomeomorph_source theorem localInverse_continuousAt (hf : HasStrictFDerivAt f (f' : E →L[š•œ] F) a) : ContinuousAt (hf.localInverse f f' a) (f a) := (hf.toOpenPartialHomeomorph f).continuousAt_symm hf.image_mem_toOpenPartialHomeomorph_target theorem localInverse_tendsto (hf : HasStrictFDerivAt f (f' : E →L[š•œ] F) a) : Tendsto (hf.localInverse f f' a) (š“ <| f a) (š“ a) := (hf.toOpenPartialHomeomorph f).tendsto_symm hf.mem_toOpenPartialHomeomorph_source theorem localInverse_unique (hf : HasStrictFDerivAt f (f' : E →L[š•œ] F) a) {g : F → E} (hg : āˆ€į¶  x in š“ a, g (f x) = x) : āˆ€į¶  y in š“ (f a), g y = localInverse f f' a hf y := eventuallyEq_of_left_inv_of_right_inv hg hf.eventually_right_inverse <| (hf.toOpenPartialHomeomorph f).tendsto_symm hf.mem_toOpenPartialHomeomorph_source /-- If `f` has an invertible derivative `f'` at `a` in the sense of strict differentiability `(hf)`, then the inverse function `hf.localInverse f` has derivative `f'.symm` at `f a`. -/ theorem to_localInverse (hf : HasStrictFDerivAt f (f' : E →L[š•œ] F) a) : HasStrictFDerivAt (hf.localInverse f f' a) (f'.symm : F →L[š•œ] E) (f a) := (hf.toOpenPartialHomeomorph f).hasStrictFDerivAt_symm hf.image_mem_toOpenPartialHomeomorph_target <| by simpa [← localInverse_def] using hf /-- If `f : E → F` has an invertible derivative `f'` at `a` in the sense of strict differentiability and `g (f x) = x` in a neighborhood of `a`, then `g` has derivative `f'.symm` at `f a`. For a version assuming `f (g y) = y` and continuity of `g` at `f a` but not `[CompleteSpace E]` see `of_local_left_inverse`. -/ theorem to_local_left_inverse (hf : HasStrictFDerivAt f (f' : E →L[š•œ] F) a) {g : F → E} (hg : āˆ€į¶  x in š“ a, g (f x) = x) : HasStrictFDerivAt g (f'.symm : F →L[š•œ] E) (f a) := hf.to_localInverse.congr_of_eventuallyEq <| (hf.localInverse_unique hg).mono fun _ => Eq.symm end HasStrictFDerivAt /-- If a function has an invertible strict derivative at all points, then it is an open map. -/ theorem isOpenMap_of_hasStrictFDerivAt_equiv [CompleteSpace E] {f : E → F} {f' : E → E ā‰ƒL[š•œ] F} (hf : āˆ€ x, HasStrictFDerivAt f (f' x : E →L[š•œ] F) x) : IsOpenMap f := isOpenMap_iff_nhds_le.2 fun x => (hf x).map_nhds_eq_of_equiv.ge
.lake/packages/mathlib/Mathlib/Analysis/Calculus/InverseFunctionTheorem/FiniteDimensional.lean
import Mathlib.Analysis.Calculus.InverseFunctionTheorem.ApproximatesLinearOn import Mathlib.Analysis.Normed.Module.FiniteDimension /-! # A lemma about `ApproximatesLinearOn` that needs `FiniteDimensional` In this file we prove that in a real vector space, a function `f` that approximates a linear equivalence on a subset `s` can be extended to a homeomorphism of the whole space. This used to be the only lemma in `Mathlib/Analysis/Calculus/Inverse` depending on `FiniteDimensional`, so it was moved to a new file when the original file got split. -/ open Set open scoped NNReal namespace ApproximatesLinearOn /-- In a real vector space, a function `f` that approximates a linear equivalence on a subset `s` can be extended to a homeomorphism of the whole space. -/ theorem exists_homeomorph_extension {E : Type*} [NormedAddCommGroup E] [NormedSpace ā„ E] {F : Type*} [NormedAddCommGroup F] [NormedSpace ā„ F] [FiniteDimensional ā„ F] {s : Set E} {f : E → F} {f' : E ā‰ƒL[ā„] F} {c : ā„ā‰„0} (hf : ApproximatesLinearOn f (f' : E →L[ā„] F) s c) (hc : Subsingleton E ∨ lipschitzExtensionConstant F * c < ‖(f'.symm : F →L[ā„] E)ā€–ā‚Šā»Ā¹) : ∃ g : E ā‰ƒā‚œ F, EqOn f g s := by -- the difference `f - f'` is Lipschitz on `s`. It can be extended to a Lipschitz function `u` -- on the whole space, with a slightly worse Lipschitz constant. Then `f' + u` will be the -- desired homeomorphism. obtain ⟨u, hu, uf⟩ : ∃ u : E → F, LipschitzWith (lipschitzExtensionConstant F * c) u ∧ EqOn (f - ⇑f') u s := hf.lipschitzOnWith.extend_finite_dimension let g : E → F := fun x => f' x + u x have fg : EqOn f g s := fun x hx => by simp_rw [g, ← uf hx, Pi.sub_apply, add_sub_cancel] have hg : ApproximatesLinearOn g (f' : E →L[ā„] F) univ (lipschitzExtensionConstant F * c) := by apply LipschitzOnWith.approximatesLinearOn rw [lipschitzOnWith_univ] convert hu ext x simp only [g, add_sub_cancel_left, ContinuousLinearEquiv.coe_coe, Pi.sub_apply] haveI : FiniteDimensional ā„ E := f'.symm.finiteDimensional exact ⟨hg.toHomeomorph g hc, fg⟩ end ApproximatesLinearOn
.lake/packages/mathlib/Mathlib/Analysis/Calculus/TangentCone/ProperSpace.lean
import Mathlib.Analysis.Seminorm import Mathlib.Analysis.Calculus.TangentCone.Defs /-! # Tangent cone in a proper space In this file we prove that the tangent cone of a set in a proper normed space at an accumulation point of this set is nontrivial. -/ open Filter Set Metric NormedField open scoped Topology variable {š•œ : Type*} [NontriviallyNormedField š•œ] {E : Type*} [NormedAddCommGroup E] [NormedSpace š•œ E] /-- In a proper space, the tangent cone at a non-isolated point is nontrivial. -/ theorem tangentConeAt_nonempty_of_properSpace [ProperSpace E] {s : Set E} {x : E} (hx : AccPt x (š“Ÿ s)) : (tangentConeAt š•œ s x ∩ {0}ᶜ).Nonempty := by /- Take a sequence `d n` tending to `0` such that `x + d n ∈ s`. Taking `c n` of the order of `1 / d n`. Then `c n • d n` belongs to a fixed annulus. By compactness, one can extract a subsequence converging to a limit `l`. Then `l` is nonzero, and by definition it belongs to the tangent cone. -/ obtain ⟨u, -, u_pos, u_lim⟩ : ∃ u, StrictAnti u ∧ (āˆ€ (n : ā„•), 0 < u n) ∧ Tendsto u atTop (š“ (0 : ā„)) := exists_seq_strictAnti_tendsto (0 : ā„) have A n : ∃ y ∈ closedBall x (u n) ∩ s, y ≠ x := (accPt_iff_nhds).mp hx _ (closedBall_mem_nhds _ (u_pos n)) choose v hv hvx using A choose hvu hvs using hv let d := fun n ↦ v n - x have M n : x + d n ∈ s \ {x} := by simp [d, hvs, hvx] let ⟨r, hr⟩ := exists_one_lt_norm š•œ have W n := rescale_to_shell hr zero_lt_one (x := d n) (by simpa using (M n).2) choose c c_ne c_le le_c hc using W have c_lim : Tendsto (fun n ↦ ‖c n‖) atTop atTop := by suffices Tendsto (fun n ↦ ‖c n‖⁻¹ ⁻¹ ) atTop atTop by simpa apply tendsto_inv_nhdsGT_zero.comp simp only [nhdsWithin, tendsto_inf, tendsto_principal, mem_Ioi, eventually_atTop, ge_iff_le] have B (n : ā„•) : ‖c n‖⁻¹ ≤ 1⁻¹ * ‖r‖ * u n := by apply (hc n).trans gcongr simpa [d, dist_eq_norm] using hvu n refine ⟨?_, 0, fun n hn ↦ by simpa using c_ne n⟩ apply squeeze_zero (fun n ↦ by positivity) B simpa using u_lim.const_mul _ obtain ⟨l, l_mem, φ, φ_strict, hĻ†āŸ© : ∃ l ∈ Metric.closedBall (0 : E) 1 \ Metric.ball (0 : E) (1 / ‖r‖), ∃ (φ : ā„• → ā„•), StrictMono φ ∧ Tendsto ((fun n ↦ c n • d n) ∘ φ) atTop (š“ l) := by apply IsCompact.tendsto_subseq _ (fun n ↦ ?_) Ā· exact (isCompact_closedBall 0 1).diff Metric.isOpen_ball simp only [mem_diff, Metric.mem_closedBall, dist_zero_right, (c_le n).le, Metric.mem_ball, not_lt, true_and, le_c n] refine ⟨l, ?_, ?_⟩; swap Ā· simp only [mem_compl_iff, mem_singleton_iff] contrapose! l_mem simp only [one_div, l_mem, mem_diff, Metric.mem_closedBall, dist_self, zero_le_one, Metric.mem_ball, inv_pos, norm_pos_iff, ne_eq, not_not, true_and] contrapose! hr simp [hr] refine ⟨c ∘ φ, d ∘ φ, .of_forall fun n ↦ ?_, ?_, hĻ†āŸ© Ā· simpa [d] using hvs (φ n) Ā· exact c_lim.comp φ_strict.tendsto_atTop @[deprecated (since := "2025-04-27")] alias tangentCone_nonempty_of_properSpace := tangentConeAt_nonempty_of_properSpace
.lake/packages/mathlib/Mathlib/Analysis/Calculus/TangentCone/Prod.lean
import Mathlib.Analysis.SpecificLimits.Basic import Mathlib.Analysis.Calculus.TangentCone.Defs import Mathlib.Analysis.Normed.Module.Basic /-! # Product of sets with unique differentiability property In this file we prove that the product of two sets with unique differentiability property has the same property, see `UniqueDiffOn.prod`. -/ open Filter Set open scoped Topology variable {š•œ E F : Type*} [NontriviallyNormedField š•œ] [NormedAddCommGroup E] [NormedSpace š•œ E] [NormedAddCommGroup F] [NormedSpace š•œ F] {x : E} {s : Set E} {y : F} {t : Set F} /-- The tangent cone of a product contains the tangent cone of its left factor. -/ theorem subset_tangentConeAt_prod_left (ht : y ∈ closure t) : LinearMap.inl š•œ E F '' tangentConeAt š•œ s x āŠ† tangentConeAt š•œ (s Ć—Ė¢ t) (x, y) := by rintro _ ⟨v, ⟨c, d, hd, hc, hy⟩, rfl⟩ have : āˆ€ n, ∃ d', y + d' ∈ t ∧ ‖c n • d'‖ < ((1 : ā„) / 2) ^ n := by intro n rcases mem_closure_iff_nhds.1 ht _ (eventually_nhds_norm_smul_sub_lt (c n) y (pow_pos one_half_pos n)) with ⟨z, hz, hzt⟩ exact ⟨z - y, by simpa using hzt, by simpa using hz⟩ choose d' hd' using this refine ⟨c, fun n => (d n, d' n), ?_, hc, ?_⟩ Ā· change āˆ€į¶  n in atTop, (x, y) + (d n, d' n) ∈ s Ć—Ė¢ t filter_upwards [hd] with n hn simp [hn, (hd' n).1] Ā· apply Tendsto.prodMk_nhds hy _ refine squeeze_zero_norm (fun n => (hd' n).2.le) ?_ exact tendsto_pow_atTop_nhds_zero_of_lt_one one_half_pos.le one_half_lt_one @[deprecated (since := "2025-04-27")] alias subset_tangentCone_prod_left := subset_tangentConeAt_prod_left /-- The tangent cone of a product contains the tangent cone of its right factor. -/ theorem subset_tangentConeAt_prod_right (hs : x ∈ closure s) : LinearMap.inr š•œ E F '' tangentConeAt š•œ t y āŠ† tangentConeAt š•œ (s Ć—Ė¢ t) (x, y) := by rintro _ ⟨w, ⟨c, d, hd, hc, hy⟩, rfl⟩ have : āˆ€ n, ∃ d', x + d' ∈ s ∧ ‖c n • d'‖ < ((1 : ā„) / 2) ^ n := by intro n rcases mem_closure_iff_nhds.1 hs _ (eventually_nhds_norm_smul_sub_lt (c n) x (pow_pos one_half_pos n)) with ⟨z, hz, hzs⟩ exact ⟨z - x, by simpa using hzs, by simpa using hz⟩ choose d' hd' using this refine ⟨c, fun n => (d' n, d n), ?_, hc, ?_⟩ Ā· change āˆ€į¶  n in atTop, (x, y) + (d' n, d n) ∈ s Ć—Ė¢ t filter_upwards [hd] with n hn simp [hn, (hd' n).1] Ā· apply Tendsto.prodMk_nhds _ hy refine squeeze_zero_norm (fun n => (hd' n).2.le) ?_ exact tendsto_pow_atTop_nhds_zero_of_lt_one one_half_pos.le one_half_lt_one @[deprecated (since := "2025-04-27")] alias subset_tangentCone_prod_right := subset_tangentConeAt_prod_right /-- The product of two sets of unique differentiability at points `x` and `y` has unique differentiability at `(x, y)`. -/ theorem UniqueDiffWithinAt.prod {t : Set F} {y : F} (hs : UniqueDiffWithinAt š•œ s x) (ht : UniqueDiffWithinAt š•œ t y) : UniqueDiffWithinAt š•œ (s Ć—Ė¢ t) (x, y) := by rw [uniqueDiffWithinAt_iff] at hs ht ⊢ rw [closure_prod_eq] refine ⟨?_, hs.2, ht.2⟩ have : _ ≤ Submodule.span š•œ (tangentConeAt š•œ (s Ć—Ė¢ t) (x, y)) := Submodule.span_mono (union_subset (subset_tangentConeAt_prod_left ht.2) (subset_tangentConeAt_prod_right hs.2)) rw [LinearMap.span_inl_union_inr, SetLike.le_def] at this exact (hs.1.prod ht.1).mono this /-- The product of two sets of unique differentiability is a set of unique differentiability. -/ theorem UniqueDiffOn.prod {t : Set F} (hs : UniqueDiffOn š•œ s) (ht : UniqueDiffOn š•œ t) : UniqueDiffOn š•œ (s Ć—Ė¢ t) := fun ⟨x, y⟩ h => UniqueDiffWithinAt.prod (hs x h.1) (ht y h.2)
.lake/packages/mathlib/Mathlib/Analysis/Calculus/TangentCone/Pi.lean
import Mathlib.Analysis.Calculus.TangentCone.Basic /-! # Indexed product of sets with unique differentiability property In this file we prove that the indexed product of a family sets with unique differentiability property has the same property, see `UniqueDiffOn.pi` and `UniqueDiffOn.univ_pi`. -/ open Filter Set open scoped Topology variable {š•œ : Type*} [NontriviallyNormedField š•œ] {ι : Type*} {E : ι → Type*} [āˆ€ i, NormedAddCommGroup (E i)] [āˆ€ i, NormedSpace š•œ (E i)] {s : āˆ€ i, Set (E i)} {x : āˆ€ i, E i} /-- The tangent cone of a product contains the tangent cone of each factor. -/ theorem mapsTo_tangentConeAt_pi [DecidableEq ι] {i : ι} (hi : āˆ€ j ≠ i, x j ∈ closure (s j)) : MapsTo (LinearMap.single š•œ E i) (tangentConeAt š•œ (s i) (x i)) (tangentConeAt š•œ (Set.pi univ s) x) := by rintro w ⟨c, d, hd, hc, hy⟩ have : āˆ€ n, āˆ€ j ≠ i, ∃ d', x j + d' ∈ s j ∧ ‖c n • d'‖ < (1 / 2 : ā„) ^ n := fun n j hj ↦ by rcases mem_closure_iff_nhds.1 (hi j hj) _ (eventually_nhds_norm_smul_sub_lt (c n) (x j) (pow_pos one_half_pos n)) with ⟨z, hz, hzs⟩ exact ⟨z - x j, by simpa using hzs, by simpa using hz⟩ choose! d' hd's hcd' using this refine ⟨c, fun n => Function.update (d' n) i (d n), hd.mono fun n hn j _ => ?_, hc, tendsto_pi_nhds.2 fun j => ?_⟩ Ā· rcases em (j = i) with (rfl | hj) <;> simp [*] Ā· rcases em (j = i) with (rfl | hj) Ā· simp [hy] Ā· suffices Tendsto (fun n => c n • d' n j) atTop (š“ 0) by simpa [hj] refine squeeze_zero_norm (fun n => (hcd' n j hj).le) ?_ exact tendsto_pow_atTop_nhds_zero_of_lt_one one_half_pos.le one_half_lt_one @[deprecated (since := "2025-04-27")] alias mapsTo_tangentCone_pi := mapsTo_tangentConeAt_pi variable (ι E) variable [Finite ι] theorem UniqueDiffWithinAt.univ_pi (s : āˆ€ i, Set (E i)) (x : āˆ€ i, E i) (h : āˆ€ i, UniqueDiffWithinAt š•œ (s i) (x i)) : UniqueDiffWithinAt š•œ (Set.pi univ s) x := by classical simp only [uniqueDiffWithinAt_iff, closure_pi_set] at h ⊢ refine ⟨(dense_pi univ fun i _ => (h i).1).mono ?_, fun i _ => (h i).2⟩ norm_cast simp only [← Submodule.iSup_map_single, iSup_le_iff, LinearMap.map_span, Submodule.span_le, ← mapsTo_iff_image_subset] exact fun i => (mapsTo_tangentConeAt_pi fun j _ => (h j).2).mono Subset.rfl Submodule.subset_span theorem UniqueDiffWithinAt.pi (s : āˆ€ i, Set (E i)) (x : āˆ€ i, E i) (I : Set ι) (h : āˆ€ i ∈ I, UniqueDiffWithinAt š•œ (s i) (x i)) : UniqueDiffWithinAt š•œ (Set.pi I s) x := by classical rw [← Set.univ_pi_piecewise_univ] refine UniqueDiffWithinAt.univ_pi ι E _ _ fun i => ?_ by_cases hi : i ∈ I <;> simp [*, uniqueDiffWithinAt_univ] /-- The finite product of a family of sets of unique differentiability is a set of unique differentiability. -/ theorem UniqueDiffOn.pi (s : āˆ€ i, Set (E i)) (I : Set ι) (h : āˆ€ i ∈ I, UniqueDiffOn š•œ (s i)) : UniqueDiffOn š•œ (Set.pi I s) := fun x hx => UniqueDiffWithinAt.pi _ _ _ _ _ fun i hi => h i hi (x i) (hx i hi) /-- The finite product of a family of sets of unique differentiability is a set of unique differentiability. -/ theorem UniqueDiffOn.univ_pi (s : āˆ€ i, Set (E i)) (h : āˆ€ i, UniqueDiffOn š•œ (s i)) : UniqueDiffOn š•œ (Set.pi univ s) := UniqueDiffOn.pi _ _ _ _ fun i _ => h i
.lake/packages/mathlib/Mathlib/Analysis/Calculus/TangentCone/Basic.lean
import Mathlib.Analysis.Calculus.TangentCone.Defs import Mathlib.Analysis.SpecificLimits.Basic import Mathlib.Analysis.Normed.Module.Basic /-! # Basic properties of tangent cones and sets with unique differentiability property In this file we prove basic lemmas about `tangentConeAt`, `UniqueDiffWithinAt`, and `UniqueDiffOn`. -/ open Filter Set Metric NormedField open scoped Topology Pointwise variable {š•œ : Type*} [NontriviallyNormedField š•œ] variable {E F G : Type*} section TVS variable [AddCommGroup E] [Module š•œ E] [TopologicalSpace E] variable {x y : E} {s t : Set E} theorem mem_tangentConeAt_of_pow_smul {r : š•œ} (hrā‚€ : r ≠ 0) (hr : ‖r‖ < 1) (hs : āˆ€į¶  n : ā„• in atTop, x + r ^ n • y ∈ s) : y ∈ tangentConeAt š•œ s x := by refine ⟨fun n ↦ (r ^ n)⁻¹, fun n ↦ r ^ n • y, hs, ?_, ?_⟩ Ā· simp only [norm_inv, norm_pow, ← inv_pow] exact tendsto_pow_atTop_atTop_of_one_lt <| (one_lt_invā‚€ (norm_pos_iff.2 hrā‚€)).2 hr Ā· simp only [inv_smul_smulā‚€ (pow_ne_zero _ hrā‚€), tendsto_const_nhds] @[simp] theorem tangentConeAt_univ : tangentConeAt š•œ univ x = univ := let ⟨_r, hrā‚€, hr⟩ := exists_norm_lt_one š•œ eq_univ_of_forall fun _ ↦ mem_tangentConeAt_of_pow_smul (norm_pos_iff.1 hrā‚€) hr <| Eventually.of_forall fun _ ↦ mem_univ _ @[deprecated (since := "2025-04-27")] alias tangentCone_univ := tangentConeAt_univ @[gcongr] theorem tangentConeAt_mono (h : s āŠ† t) : tangentConeAt š•œ s x āŠ† tangentConeAt š•œ t x := by rintro y ⟨c, d, ds, ctop, clim⟩ exact ⟨c, d, mem_of_superset ds fun n hn => h hn, ctop, clim⟩ @[deprecated (since := "2025-04-27")] alias tangentCone_mono := tangentConeAt_mono /-- Given `x ∈ s` and a field extension `š•œ āŠ† š•œ'`, the tangent cone of `s` at `x` with respect to `š•œ` is contained in the tangent cone of `s` at `x` with respect to `š•œ'`. -/ theorem tangentConeAt_mono_field {š•œ' : Type*} [NontriviallyNormedField š•œ'] [NormedAlgebra š•œ š•œ'] [Module š•œ' E] [IsScalarTower š•œ š•œ' E] : tangentConeAt š•œ s x āŠ† tangentConeAt š•œ' s x := by intro α hα simp only [tangentConeAt, eventually_atTop, ge_iff_le, tendsto_norm_atTop_iff_cobounded, mem_setOf_eq] at hα ⊢ obtain ⟨c, d, ⟨a, h₁a⟩, h₁, hā‚‚āŸ© := hα use ((algebraMap š•œ š•œ') ∘ c), d constructor Ā· use a Ā· constructor Ā· intro β hβ rw [mem_map, mem_atTop_sets] obtain ⟨n, hn⟩ := mem_atTop_sets.1 (mem_map.1 (h₁ (tendsto_algebraMap_cobounded (š•œ := š•œ) (š•œ' := š•œ') hβ))) use n, fun _ _ ↦ by simp_all Ā· simpa variable [ContinuousSMul š•œ E] /-- Auxiliary lemma ensuring that, under the assumptions defining the tangent cone, the sequence `d` tends to 0 at infinity. -/ theorem tangentConeAt.lim_zero {α : Type*} (l : Filter α) {c : α → š•œ} {d : α → E} (hc : Tendsto (fun n => ‖c n‖) l atTop) (hd : Tendsto (fun n => c n • d n) l (š“ y)) : Tendsto d l (š“ 0) := by have : āˆ€į¶  n in l, (c n)⁻¹ • c n • d n = d n := (eventually_ne_of_tendsto_norm_atTop hc 0).mono fun n hn ↦ inv_smul_smulā‚€ hn (d n) rw [tendsto_norm_atTop_iff_cobounded] at hc simpa using Tendsto.congr' this <| (tendsto_invā‚€_cobounded.comp hc).smul hd variable [ContinuousAdd E] theorem tangentConeAt_mono_nhds (h : š“[s] x ≤ š“[t] x) : tangentConeAt š•œ s x āŠ† tangentConeAt š•œ t x := by rintro y ⟨c, d, ds, ctop, clim⟩ refine ⟨c, d, ?_, ctop, clim⟩ suffices Tendsto (fun n => x + d n) atTop (š“[t] x) from tendsto_principal.1 (tendsto_inf.1 this).2 refine (tendsto_inf.2 ⟨?_, tendsto_principal.2 ds⟩).mono_right h simpa only [add_zero] using tendsto_const_nhds.add (tangentConeAt.lim_zero atTop ctop clim) @[deprecated (since := "2025-04-27")] alias tangentCone_mono_nhds := tangentConeAt_mono_nhds /-- Tangent cone of `s` at `x` depends only on `š“[s] x`. -/ theorem tangentConeAt_congr (h : š“[s] x = š“[t] x) : tangentConeAt š•œ s x = tangentConeAt š•œ t x := Subset.antisymm (tangentConeAt_mono_nhds h.le) (tangentConeAt_mono_nhds h.ge) @[deprecated (since := "2025-04-27")] alias tangentCone_congr := tangentConeAt_congr /-- Intersecting with a neighborhood of the point does not change the tangent cone. -/ theorem tangentConeAt_inter_nhds (ht : t ∈ š“ x) : tangentConeAt š•œ (s ∩ t) x = tangentConeAt š•œ s x := tangentConeAt_congr (nhdsWithin_restrict' _ ht).symm @[deprecated (since := "2025-04-27")] alias tangentCone_inter_nhds := tangentConeAt_inter_nhds end TVS section Normed variable [NormedAddCommGroup E] [NormedSpace š•œ E] variable [NormedAddCommGroup F] [NormedSpace š•œ F] variable {x y : E} {s t : Set E} @[simp] theorem tangentConeAt_closure : tangentConeAt š•œ (closure s) x = tangentConeAt š•œ s x := by refine Subset.antisymm ?_ (tangentConeAt_mono subset_closure) rintro y ⟨c, d, ds, ctop, clim⟩ obtain ⟨u, -, u_pos, u_lim⟩ : ∃ u, StrictAnti u ∧ (āˆ€ (n : ā„•), 0 < u n) ∧ Tendsto u atTop (š“ (0 : ā„)) := exists_seq_strictAnti_tendsto (0 : ā„) have : āˆ€į¶  n in atTop, ∃ d', x + d' ∈ s ∧ dist (c n • d n) (c n • d') < u n := by filter_upwards [ctop.eventually_gt_atTop 0, ds] with n hn hns rcases Metric.mem_closure_iff.mp hns (u n / ‖c n‖) (div_pos (u_pos n) hn) with ⟨y, hys, hy⟩ refine ⟨y - x, by simpa, ?_⟩ rwa [dist_smulā‚€, ← dist_add_left x, add_sub_cancel, ← lt_div_iffā‚€' hn] simp only [Filter.skolem, eventually_and] at this rcases this with ⟨d', hd's, hd'⟩ exact ⟨c, d', hd's, ctop, clim.congr_dist (squeeze_zero' (.of_forall fun _ ↦ dist_nonneg) (hd'.mono fun _ ↦ le_of_lt) u_lim)⟩ /-- The tangent cone at a non-isolated point contains `0`. -/ theorem zero_mem_tangentCone {s : Set E} {x : E} (hx : x ∈ closure s) : 0 ∈ tangentConeAt š•œ s x := by /- Take a sequence `d n` tending to `0` such that `x + d n ∈ s`. Taking `c n` of the order of `1 / (d n) ^ (1/2)`, then `c n` tends to infinity, but `c n • d n` tends to `0`. By definition, this shows that `0` belongs to the tangent cone. -/ obtain ⟨u, -, hu, u_lim⟩ : ∃ u, StrictAnti u ∧ (āˆ€ (n : ā„•), 0 < u n ∧ u n < 1) ∧ Tendsto u atTop (š“ (0 : ā„)) := exists_seq_strictAnti_tendsto' one_pos choose u_pos u_lt_one using hu choose v hvs hvu using fun n ↦ Metric.mem_closure_iff.mp hx _ (mul_pos (u_pos n) (u_pos n)) let d n := v n - x let ⟨r, hr⟩ := exists_one_lt_norm š•œ have A n := exists_nat_pow_near (one_le_inv_iffā‚€.mpr ⟨u_pos n, (u_lt_one n).le⟩) hr choose m hm_le hlt_m using A set c := fun n ↦ r ^ (m n + 1) have c_lim : Tendsto (fun n ↦ ‖c n‖) atTop atTop := by simp only [c, norm_pow] refine tendsto_atTop_mono (fun n ↦ (hlt_m n).le) <| .inv_tendsto_nhdsGT_zero ?_ exact tendsto_nhdsWithin_iff.mpr ⟨u_lim, .of_forall u_pos⟩ refine ⟨c, d, .of_forall <| by simpa [d], c_lim, ?_⟩ have Hle n : ‖c n • d n‖ ≤ ‖r‖ * u n := by specialize u_pos n calc ‖c n • d n‖ ≤ (u n)⁻¹ * ‖r‖ * (u n * u n) := by simp only [c, norm_smul, norm_pow, pow_succ, norm_mul, d, ← dist_eq_norm'] gcongr exacts [hm_le n, (hvu n).le] _ = ‖r‖ * u n := by field refine squeeze_zero_norm Hle ?_ simpa using tendsto_const_nhds.mul u_lim /-- If `x` is not an accumulation point of `s`, then the tangent cone of `s` at `x` is a subset of `{0}`. -/ theorem tangentConeAt_subset_zero (hx : ¬AccPt x (š“Ÿ s)) : tangentConeAt š•œ s x āŠ† 0 := by rintro y ⟨c, d, hds, hc, hcd⟩ suffices āˆ€į¶  n in .atTop, d n = 0 from tendsto_nhds_unique hcd <| tendsto_const_nhds.congr' <| this.mono fun n hn ↦ by simp [hn] simp only [accPt_iff_frequently, not_frequently, not_and', ne_eq, not_not] at hx have : Tendsto (x + d Ā·) atTop (š“ x) := by simpa using tendsto_const_nhds.add (tangentConeAt.lim_zero _ hc hcd) filter_upwards [this.eventually hx, hds] with n h₁ hā‚‚ simpa using h₁ hā‚‚ theorem UniqueDiffWithinAt.accPt [Nontrivial E] (h : UniqueDiffWithinAt š•œ s x) : AccPt x (š“Ÿ s) := by by_contra! h' have : Dense (Submodule.span š•œ (0 : Set E) : Set E) := h.1.mono <| by gcongr; exact tangentConeAt_subset_zero h' simp [dense_iff_closure_eq] at this end Normed section UniqueDiff /-! ### Properties of `UniqueDiffWithinAt` and `UniqueDiffOn` This section is devoted to properties of the predicates `UniqueDiffWithinAt` and `UniqueDiffOn`. -/ section Module variable [AddCommGroup E] [Module š•œ E] [TopologicalSpace E] variable {x y : E} {s t : Set E} theorem UniqueDiffOn.uniqueDiffWithinAt {s : Set E} {x} (hs : UniqueDiffOn š•œ s) (h : x ∈ s) : UniqueDiffWithinAt š•œ s x := hs x h @[simp] theorem uniqueDiffWithinAt_univ : UniqueDiffWithinAt š•œ univ x := by rw [uniqueDiffWithinAt_iff, tangentConeAt_univ] simp @[simp] theorem uniqueDiffOn_univ : UniqueDiffOn š•œ (univ : Set E) := fun _ _ => uniqueDiffWithinAt_univ theorem uniqueDiffOn_empty : UniqueDiffOn š•œ (āˆ… : Set E) := fun _ hx => hx.elim theorem UniqueDiffWithinAt.congr_pt (h : UniqueDiffWithinAt š•œ s x) (hy : x = y) : UniqueDiffWithinAt š•œ s y := hy ā–ø h variable {š•œ' : Type*} [NontriviallyNormedField š•œ'] [NormedAlgebra š•œ š•œ'] [Module š•œ' E] [IsScalarTower š•œ š•œ' E] /-- Assume that `E` is a normed vector space over normed fields `š•œ āŠ† š•œ'` and that `x ∈ s` is a point of unique differentiability with respect to the set `s` and the smaller field `š•œ`, then `x` is also a point of unique differentiability with respect to the set `s` and the larger field `š•œ'`. -/ theorem UniqueDiffWithinAt.mono_field (hā‚‚s : UniqueDiffWithinAt š•œ s x) : UniqueDiffWithinAt š•œ' s x := by simp_all only [uniqueDiffWithinAt_iff, and_true] apply Dense.mono _ hā‚‚s.1 trans ↑(Submodule.span š•œ (tangentConeAt š•œ' s x)) <;> simp [Submodule.span_mono tangentConeAt_mono_field] /-- Assume that `E` is a normed vector space over normed fields `š•œ āŠ† š•œ'` and all points of `s` are points of unique differentiability with respect to the smaller field `š•œ`, then they are also points of unique differentiability with respect to the larger field `š•œ`. -/ theorem UniqueDiffOn.mono_field (hā‚‚s : UniqueDiffOn š•œ s) : UniqueDiffOn š•œ' s := fun x hx ↦ (hā‚‚s x hx).mono_field end Module section TVS variable [AddCommGroup E] [Module š•œ E] [TopologicalSpace E] variable {x y : E} {s t : Set E} variable [ContinuousAdd E] [ContinuousSMul š•œ E] theorem UniqueDiffWithinAt.mono_nhds (h : UniqueDiffWithinAt š•œ s x) (st : š“[s] x ≤ š“[t] x) : UniqueDiffWithinAt š•œ t x := by simp only [uniqueDiffWithinAt_iff] at * rw [mem_closure_iff_nhdsWithin_neBot] at h ⊢ exact ⟨h.1.mono <| Submodule.span_mono <| tangentConeAt_mono_nhds st, h.2.mono st⟩ theorem UniqueDiffWithinAt.mono (h : UniqueDiffWithinAt š•œ s x) (st : s āŠ† t) : UniqueDiffWithinAt š•œ t x := h.mono_nhds <| nhdsWithin_mono _ st theorem uniqueDiffWithinAt_congr (st : š“[s] x = š“[t] x) : UniqueDiffWithinAt š•œ s x ↔ UniqueDiffWithinAt š•œ t x := ⟨fun h => h.mono_nhds <| le_of_eq st, fun h => h.mono_nhds <| le_of_eq st.symm⟩ theorem uniqueDiffWithinAt_inter (ht : t ∈ š“ x) : UniqueDiffWithinAt š•œ (s ∩ t) x ↔ UniqueDiffWithinAt š•œ s x := uniqueDiffWithinAt_congr <| (nhdsWithin_restrict' _ ht).symm theorem UniqueDiffWithinAt.inter (hs : UniqueDiffWithinAt š•œ s x) (ht : t ∈ š“ x) : UniqueDiffWithinAt š•œ (s ∩ t) x := (uniqueDiffWithinAt_inter ht).2 hs theorem uniqueDiffWithinAt_inter' (ht : t ∈ š“[s] x) : UniqueDiffWithinAt š•œ (s ∩ t) x ↔ UniqueDiffWithinAt š•œ s x := uniqueDiffWithinAt_congr <| (nhdsWithin_restrict'' _ ht).symm theorem UniqueDiffWithinAt.inter' (hs : UniqueDiffWithinAt š•œ s x) (ht : t ∈ š“[s] x) : UniqueDiffWithinAt š•œ (s ∩ t) x := (uniqueDiffWithinAt_inter' ht).2 hs theorem uniqueDiffWithinAt_of_mem_nhds (h : s ∈ š“ x) : UniqueDiffWithinAt š•œ s x := by simpa only [univ_inter] using uniqueDiffWithinAt_univ.inter h theorem IsOpen.uniqueDiffWithinAt (hs : IsOpen s) (xs : x ∈ s) : UniqueDiffWithinAt š•œ s x := uniqueDiffWithinAt_of_mem_nhds (IsOpen.mem_nhds hs xs) theorem UniqueDiffOn.inter (hs : UniqueDiffOn š•œ s) (ht : IsOpen t) : UniqueDiffOn š•œ (s ∩ t) := fun x hx => (hs x hx.1).inter (IsOpen.mem_nhds ht hx.2) theorem IsOpen.uniqueDiffOn (hs : IsOpen s) : UniqueDiffOn š•œ s := fun _ hx => IsOpen.uniqueDiffWithinAt hs hx end TVS section Normed variable [NormedAddCommGroup E] [NormedSpace š•œ E] variable [NormedAddCommGroup F] [NormedSpace š•œ F] variable {x y : E} {s t : Set E} @[simp] theorem uniqueDiffWithinAt_closure : UniqueDiffWithinAt š•œ (closure s) x ↔ UniqueDiffWithinAt š•œ s x := by simp [uniqueDiffWithinAt_iff] protected alias ⟨UniqueDiffWithinAt.of_closure, UniqueDiffWithinAt.closure⟩ := uniqueDiffWithinAt_closure theorem UniqueDiffWithinAt.mono_closure (h : UniqueDiffWithinAt š•œ s x) (st : s āŠ† closure t) : UniqueDiffWithinAt š•œ t x := (h.mono st).of_closure end Normed end UniqueDiff
.lake/packages/mathlib/Mathlib/Analysis/Calculus/TangentCone/Defs.lean
import Mathlib.Analysis.Normed.Field.Basic /-! # Tangent cone In this file, we define two predicates `UniqueDiffWithinAt š•œ s x` and `UniqueDiffOn š•œ s` ensuring that, if a function has two derivatives, then they have to coincide. As a direct definition of this fact (quantifying on all target types and all functions) would depend on universes, we use a more intrinsic definition: if all the possible tangent directions to the set `s` at the point `x` span a dense subset of the whole subset, it is easy to check that the derivative has to be unique. Therefore, we introduce the set of all tangent directions, named `tangentConeAt`, and express `UniqueDiffWithinAt` and `UniqueDiffOn` in terms of it. One should however think of this definition as an implementation detail: the only reason to introduce the predicates `UniqueDiffWithinAt` and `UniqueDiffOn` is to ensure the uniqueness of the derivative. This is why their names reflect their uses, and not how they are defined. ## Implementation details Note that this file is imported by `Mathlib/Analysis/Calculus/FDeriv/Basic.lean`. Hence, derivatives are not defined yet. The property of uniqueness of the derivative is therefore proved in `Mathlib/Analysis/Calculus/FDeriv/Basic.lean`, but based on the properties of the tangent cone we prove here. -/ open Filter Set Metric open scoped Topology Pointwise variable (š•œ : Type*) [NontriviallyNormedField š•œ] variable {E : Type*} [AddCommMonoid E] [Module š•œ E] [TopologicalSpace E] /-- The set of all tangent directions to the set `s` at the point `x`. -/ def tangentConeAt (s : Set E) (x : E) : Set E := { y : E | ∃ (c : ā„• → š•œ) (d : ā„• → E), (āˆ€į¶  n in atTop, x + d n ∈ s) ∧ Tendsto (fun n => ‖c n‖) atTop atTop ∧ Tendsto (fun n => c n • d n) atTop (š“ y) } /-- A property ensuring that the tangent cone to `s` at `x` spans a dense subset of the whole space. The main role of this property is to ensure that the differential within `s` at `x` is unique, hence this name. The uniqueness it asserts is proved in `UniqueDiffWithinAt.eq` in `Mathlib/Analysis/Calculus/FDeriv/Basic.lean`. To avoid pathologies in dimension 0, we also require that `x` belongs to the closure of `s` (which is automatic when `E` is not `0`-dimensional). -/ @[mk_iff] structure UniqueDiffWithinAt (s : Set E) (x : E) : Prop where dense_tangentConeAt : Dense (Submodule.span š•œ (tangentConeAt š•œ s x) : Set E) mem_closure : x ∈ closure s @[deprecated (since := "2025-04-27")] alias UniqueDiffWithinAt.dense_tangentCone := UniqueDiffWithinAt.dense_tangentConeAt /-- A property ensuring that the tangent cone to `s` at any of its points spans a dense subset of the whole space. The main role of this property is to ensure that the differential along `s` is unique, hence this name. The uniqueness it asserts is proved in `UniqueDiffOn.eq` in `Mathlib/Analysis/Calculus/FDeriv/Basic.lean`. -/ def UniqueDiffOn (s : Set E) : Prop := āˆ€ x ∈ s, UniqueDiffWithinAt š•œ s x
.lake/packages/mathlib/Mathlib/Analysis/Calculus/TangentCone/DimOne.lean
import Mathlib.Analysis.Calculus.TangentCone.Basic /-! # Unique differentiability property of a set in the base field In this file we prove that a set in the base field has the unique differentiability property at `x` iff `x` is an accumulation point of the set, see `uniqueDiffWithinAt_iff_accPt`. -/ open Filter Metric Set open scoped Topology variable {š•œ : Type*} [NontriviallyNormedField š•œ] /-- The tangent cone at a non-isolated point in dimension 1 is the whole space. -/ theorem tangentConeAt_eq_univ {s : Set š•œ} {x : š•œ} (hx : AccPt x (š“Ÿ s)) : tangentConeAt š•œ s x = univ := by apply eq_univ_iff_forall.2 (fun y ↦ ?_) -- first deal with the case of `0`, which has to be handled separately. rcases eq_or_ne y 0 with rfl | hy Ā· exact zero_mem_tangentCone (mem_closure_iff_clusterPt.mpr hx.clusterPt) /- Assume now `y` is a fixed nonzero scalar. Take a sequence `d n` tending to `0` such that `x + d n ∈ s`. Let `c n = y / d n`. Then `‖c n‖` tends to infinity, and `c n • d n` converges to `y` (as it is equal to `y`). By definition, this shows that `y` belongs to the tangent cone. -/ obtain ⟨u, -, u_pos, u_lim⟩ : ∃ u, StrictAnti u ∧ (āˆ€ (n : ā„•), 0 < u n) ∧ Tendsto u atTop (š“ (0 : ā„)) := exists_seq_strictAnti_tendsto (0 : ā„) have A n : ∃ y ∈ closedBall x (u n) ∩ s, y ≠ x := accPt_iff_nhds.mp hx _ (closedBall_mem_nhds _ (u_pos n)) choose v hv hvx using A choose hvu hvs using hv let d := fun n ↦ v n - x have d_ne n : d n ≠ 0 := by simpa [d, sub_eq_zero] using hvx n refine ⟨fun n ↦ y * (d n)⁻¹, d, .of_forall ?_, ?_, ?_⟩ Ā· simpa [d] using hvs Ā· simp only [norm_mul, norm_inv] apply (tendsto_const_mul_atTop_of_pos (by simpa using hy)).2 apply tendsto_inv_nhdsGT_zero.comp simp only [nhdsWithin, tendsto_inf, tendsto_principal, mem_Ioi, norm_pos_iff, ne_eq, eventually_atTop, ge_iff_le] have B (n : ā„•) : ‖d n‖ ≤ u n := by simpa [dist_eq_norm] using hvu n refine ⟨?_, 0, fun n hn ↦ by simpa using d_ne n⟩ exact squeeze_zero (fun n ↦ by positivity) B u_lim Ā· convert tendsto_const_nhds (α := ā„•) (x := y) with n simp [mul_assoc, inv_mul_cancelā‚€ (d_ne n)] @[deprecated (since := "2025-04-27")] alias tangentCone_eq_univ := tangentConeAt_eq_univ /-- In one dimension, a point is a point of unique differentiability of a set iff it is an accumulation point of the set. -/ theorem uniqueDiffWithinAt_iff_accPt {s : Set š•œ} {x : š•œ} : UniqueDiffWithinAt š•œ s x ↔ AccPt x (š“Ÿ s) := ⟨UniqueDiffWithinAt.accPt, fun h ↦ ⟨by simp [tangentConeAt_eq_univ h], mem_closure_iff_clusterPt.mpr h.clusterPt⟩⟩ alias ⟨_, AccPt.uniqueDiffWithinAt⟩ := uniqueDiffWithinAt_iff_accPt
.lake/packages/mathlib/Mathlib/Analysis/Calculus/TangentCone/Real.lean
import Mathlib.Analysis.Calculus.TangentCone.Basic import Mathlib.Analysis.Convex.Topology /-! # Unique differentiability property in real normed spaces In this file we prove that - `uniqueDiffOn_convex`: a convex set with nonempty interior in a real normed space has the unique differentiability property; - `uniqueDiffOn_Ioc` etc: intervals on the real line have the unique differentiability property. -/ open Filter Set open scoped Topology section RealNormed variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ā„ E] /-- If a subset of a real vector space contains an open segment, then the direction of this segment belongs to the tangent cone at its endpoints. -/ theorem mem_tangentConeAt_of_openSegment_subset {s : Set E} {x y : E} (h : openSegment ā„ x y āŠ† s) : y - x ∈ tangentConeAt ā„ s x := by refine mem_tangentConeAt_of_pow_smul one_half_pos.ne' (by norm_num) ?_ refine (eventually_ne_atTop 0).mono fun n hn ↦ (h ?_) rw [openSegment_eq_image] refine ⟨(1 / 2) ^ n, ⟨?_, ?_⟩, ?_⟩ Ā· exact pow_pos one_half_pos _ Ā· exact pow_lt_oneā‚€ one_half_pos.le one_half_lt_one hn Ā· simp only [sub_smul, one_smul, smul_sub]; abel @[deprecated (since := "2025-04-27")] alias mem_tangentCone_of_openSegment_subset := mem_tangentConeAt_of_openSegment_subset /-- If a subset of a real vector space contains a segment, then the direction of this segment belongs to the tangent cone at its endpoints. -/ theorem mem_tangentConeAt_of_segment_subset {s : Set E} {x y : E} (h : segment ā„ x y āŠ† s) : y - x ∈ tangentConeAt ā„ s x := mem_tangentConeAt_of_openSegment_subset ((openSegment_subset_segment ā„ x y).trans h) @[deprecated (since := "2025-04-27")] alias mem_tangentCone_of_segment_subset := mem_tangentConeAt_of_segment_subset theorem Convex.span_tangentConeAt {s : Set E} (conv : Convex ā„ s) (hs : (interior s).Nonempty) {x : E} (hx : x ∈ closure s) : Submodule.span ā„ (tangentConeAt ā„ s x) = ⊤ := by rcases hs with ⟨y, hy⟩ suffices y - x ∈ interior (tangentConeAt ā„ s x) by apply (Submodule.span ā„ (tangentConeAt ā„ s x)).eq_top_of_nonempty_interior' exact ⟨y - x, interior_mono Submodule.subset_span this⟩ rw [mem_interior_iff_mem_nhds] replace hy : interior s ∈ š“ y := IsOpen.mem_nhds isOpen_interior hy apply mem_of_superset ((isOpenMap_sub_right x).image_mem_nhds hy) rintro _ ⟨z, zs, rfl⟩ refine mem_tangentConeAt_of_openSegment_subset (Subset.trans ?_ interior_subset) exact conv.openSegment_closure_interior_subset_interior hx zs /-- In a real vector space, a convex set with nonempty interior is a set of unique differentiability at every point of its closure. -/ theorem uniqueDiffWithinAt_convex {s : Set E} (conv : Convex ā„ s) (hs : (interior s).Nonempty) {x : E} (hx : x ∈ closure s) : UniqueDiffWithinAt ā„ s x := by simp [uniqueDiffWithinAt_iff, conv.span_tangentConeAt hs hx, hx] /-- In a real vector space, a convex set with nonempty interior is a set of unique differentiability. -/ theorem uniqueDiffOn_convex {s : Set E} (conv : Convex ā„ s) (hs : (interior s).Nonempty) : UniqueDiffOn ā„ s := fun _ xs => uniqueDiffWithinAt_convex conv hs (subset_closure xs) end RealNormed section Real theorem uniqueDiffOn_Ici (a : ā„) : UniqueDiffOn ā„ (Ici a) := uniqueDiffOn_convex (convex_Ici a) <| by simp only [interior_Ici, nonempty_Ioi] theorem uniqueDiffOn_Iic (a : ā„) : UniqueDiffOn ā„ (Iic a) := uniqueDiffOn_convex (convex_Iic a) <| by simp only [interior_Iic, nonempty_Iio] theorem uniqueDiffOn_Ioi (a : ā„) : UniqueDiffOn ā„ (Ioi a) := isOpen_Ioi.uniqueDiffOn theorem uniqueDiffOn_Iio (a : ā„) : UniqueDiffOn ā„ (Iio a) := isOpen_Iio.uniqueDiffOn theorem uniqueDiffOn_Icc {a b : ā„} (hab : a < b) : UniqueDiffOn ā„ (Icc a b) := uniqueDiffOn_convex (convex_Icc a b) <| by simp only [interior_Icc, nonempty_Ioo, hab] theorem uniqueDiffOn_Ico (a b : ā„) : UniqueDiffOn ā„ (Ico a b) := if hab : a < b then uniqueDiffOn_convex (convex_Ico a b) <| by simp only [interior_Ico, nonempty_Ioo, hab] else by simp only [Ico_eq_empty hab, uniqueDiffOn_empty] theorem uniqueDiffOn_Ioc (a b : ā„) : UniqueDiffOn ā„ (Ioc a b) := if hab : a < b then uniqueDiffOn_convex (convex_Ioc a b) <| by simp only [interior_Ioc, nonempty_Ioo, hab] else by simp only [Ioc_eq_empty hab, uniqueDiffOn_empty] theorem uniqueDiffOn_Ioo (a b : ā„) : UniqueDiffOn ā„ (Ioo a b) := isOpen_Ioo.uniqueDiffOn /-- The real interval `[0, 1]` is a set of unique differentiability. -/ theorem uniqueDiffOn_Icc_zero_one : UniqueDiffOn ā„ (Icc (0 : ā„) 1) := uniqueDiffOn_Icc zero_lt_one theorem uniqueDiffWithinAt_Ioo {a b t : ā„} (ht : t ∈ Set.Ioo a b) : UniqueDiffWithinAt ā„ (Set.Ioo a b) t := IsOpen.uniqueDiffWithinAt isOpen_Ioo ht theorem uniqueDiffWithinAt_Ioi (a : ā„) : UniqueDiffWithinAt ā„ (Ioi a) a := uniqueDiffWithinAt_convex (convex_Ioi a) (by simp) (by simp) theorem uniqueDiffWithinAt_Iio (a : ā„) : UniqueDiffWithinAt ā„ (Iio a) a := uniqueDiffWithinAt_convex (convex_Iio a) (by simp) (by simp) theorem uniqueDiffWithinAt_Ici (x : ā„) : UniqueDiffWithinAt ā„ (Ici x) x := (uniqueDiffWithinAt_Ioi x).mono Set.Ioi_subset_Ici_self theorem uniqueDiffWithinAt_Iic (x : ā„) : UniqueDiffWithinAt ā„ (Iic x) x := (uniqueDiffWithinAt_Iio x).mono Set.Iio_subset_Iic_self end Real
.lake/packages/mathlib/Mathlib/Analysis/Calculus/LocalExtr/LineDeriv.lean
import Mathlib.Analysis.Calculus.LocalExtr.Basic import Mathlib.Analysis.Calculus.LineDeriv.Basic /-! # Local extremum and line derivatives If `f` has a local extremum at a point, then the derivative at this point is zero. In this file we prove several versions of this fact for line derivatives. -/ open Function Set Filter open scoped Topology section Module variable {E : Type*} [AddCommGroup E] [Module ā„ E] {f : E → ā„} {s : Set E} {a b : E} {f' : ā„} theorem IsExtrFilter.hasLineDerivAt_eq_zero {l : Filter E} (h : IsExtrFilter f l a) (hd : HasLineDerivAt ā„ f f' a b) (h' : Tendsto (fun t : ā„ ↦ a + t • b) (š“ 0) l) : f' = 0 := IsLocalExtr.hasDerivAt_eq_zero (IsExtrFilter.comp_tendsto (by simpa using h) h') hd theorem IsExtrFilter.lineDeriv_eq_zero {l : Filter E} (h : IsExtrFilter f l a) (h' : Tendsto (fun t : ā„ ↦ a + t • b) (š“ 0) l) : lineDeriv ā„ f a b = 0 := by classical exact if hd : LineDifferentiableAt ā„ f a b then h.hasLineDerivAt_eq_zero hd.hasLineDerivAt h' else lineDeriv_zero_of_not_lineDifferentiableAt hd theorem IsExtrOn.hasLineDerivAt_eq_zero (h : IsExtrOn f s a) (hd : HasLineDerivAt ā„ f f' a b) (h' : āˆ€į¶  t : ā„ in š“ 0, a + t • b ∈ s) : f' = 0 := IsExtrFilter.hasLineDerivAt_eq_zero h hd <| tendsto_principal.2 h' theorem IsExtrOn.lineDeriv_eq_zero (h : IsExtrOn f s a) (h' : āˆ€į¶  t : ā„ in š“ 0, a + t • b ∈ s) : lineDeriv ā„ f a b = 0 := IsExtrFilter.lineDeriv_eq_zero h <| tendsto_principal.2 h' theorem IsMinOn.hasLineDerivAt_eq_zero (h : IsMinOn f s a) (hd : HasLineDerivAt ā„ f f' a b) (h' : āˆ€į¶  t : ā„ in š“ 0, a + t • b ∈ s) : f' = 0 := h.isExtr.hasLineDerivAt_eq_zero hd h' theorem IsMinOn.lineDeriv_eq_zero (h : IsMinOn f s a) (h' : āˆ€į¶  t : ā„ in š“ 0, a + t • b ∈ s) : lineDeriv ā„ f a b = 0 := h.isExtr.lineDeriv_eq_zero h' theorem IsMaxOn.hasLineDerivAt_eq_zero (h : IsMaxOn f s a) (hd : HasLineDerivAt ā„ f f' a b) (h' : āˆ€į¶  t : ā„ in š“ 0, a + t • b ∈ s) : f' = 0 := h.isExtr.hasLineDerivAt_eq_zero hd h' theorem IsMaxOn.lineDeriv_eq_zero (h : IsMaxOn f s a) (h' : āˆ€į¶  t : ā„ in š“ 0, a + t • b ∈ s) : lineDeriv ā„ f a b = 0 := h.isExtr.lineDeriv_eq_zero h' theorem IsExtrOn.hasLineDerivWithinAt_eq_zero (h : IsExtrOn f s a) (hd : HasLineDerivWithinAt ā„ f f' s a b) (h' : āˆ€į¶  t : ā„ in š“ 0, a + t • b ∈ s) : f' = 0 := h.hasLineDerivAt_eq_zero (hd.hasLineDerivAt' h') h' theorem IsExtrOn.lineDerivWithin_eq_zero (h : IsExtrOn f s a) (h' : āˆ€į¶  t : ā„ in š“ 0, a + t • b ∈ s) : lineDerivWithin ā„ f s a b = 0 := by classical exact if hd : LineDifferentiableWithinAt ā„ f s a b then h.hasLineDerivWithinAt_eq_zero hd.hasLineDerivWithinAt h' else lineDerivWithin_zero_of_not_lineDifferentiableWithinAt hd theorem IsMinOn.hasLineDerivWithinAt_eq_zero (h : IsMinOn f s a) (hd : HasLineDerivWithinAt ā„ f f' s a b) (h' : āˆ€į¶  t : ā„ in š“ 0, a + t • b ∈ s) : f' = 0 := h.isExtr.hasLineDerivWithinAt_eq_zero hd h' theorem IsMinOn.lineDerivWithin_eq_zero (h : IsMinOn f s a) (h' : āˆ€į¶  t : ā„ in š“ 0, a + t • b ∈ s) : lineDerivWithin ā„ f s a b = 0 := h.isExtr.lineDerivWithin_eq_zero h' theorem IsMaxOn.hasLineDerivWithinAt_eq_zero (h : IsMaxOn f s a) (hd : HasLineDerivWithinAt ā„ f f' s a b) (h' : āˆ€į¶  t : ā„ in š“ 0, a + t • b ∈ s) : f' = 0 := h.isExtr.hasLineDerivWithinAt_eq_zero hd h' theorem IsMaxOn.lineDerivWithin_eq_zero (h : IsMaxOn f s a) (h' : āˆ€į¶  t : ā„ in š“ 0, a + t • b ∈ s) : lineDerivWithin ā„ f s a b = 0 := h.isExtr.lineDerivWithin_eq_zero h' end Module variable {E : Type*} [AddCommGroup E] [Module ā„ E] [TopologicalSpace E] [ContinuousAdd E] [ContinuousSMul ā„ E] {f : E → ā„} {s : Set E} {a b : E} {f' : ā„} theorem IsLocalExtr.hasLineDerivAt_eq_zero (h : IsLocalExtr f a) (hd : HasLineDerivAt ā„ f f' a b) : f' = 0 := IsExtrFilter.hasLineDerivAt_eq_zero h hd <| Continuous.tendsto' (by fun_prop) _ _ (by simp) theorem IsLocalExtr.lineDeriv_eq_zero (h : IsLocalExtr f a) : lineDeriv ā„ f a = 0 := funext fun b ↦ IsExtrFilter.lineDeriv_eq_zero h <| Continuous.tendsto' (by fun_prop) _ _ (by simp) theorem IsLocalMin.hasLineDerivAt_eq_zero (h : IsLocalMin f a) (hd : HasLineDerivAt ā„ f f' a b) : f' = 0 := IsLocalExtr.hasLineDerivAt_eq_zero (.inl h) hd theorem IsLocalMin.lineDeriv_eq_zero (h : IsLocalMin f a) : lineDeriv ā„ f a = 0 := IsLocalExtr.lineDeriv_eq_zero (.inl h) theorem IsLocalMax.hasLineDerivAt_eq_zero (h : IsLocalMax f a) (hd : HasLineDerivAt ā„ f f' a b) : f' = 0 := IsLocalExtr.hasLineDerivAt_eq_zero (.inr h) hd theorem IsLocalMax.lineDeriv_eq_zero (h : IsLocalMax f a) : lineDeriv ā„ f a = 0 := IsLocalExtr.lineDeriv_eq_zero (.inr h)
.lake/packages/mathlib/Mathlib/Analysis/Calculus/LocalExtr/Basic.lean
import Mathlib.Analysis.Calculus.Deriv.Add /-! # Local extrema of differentiable functions ## Main definitions In a real normed space `E` we define `posTangentConeAt (s : Set E) (x : E)`. This would be the same as `tangentConeAt ā„ā‰„0 s x` if we had a theory of normed semifields. This set is used in the proof of Fermat's Theorem (see below), and can be used to formalize [Lagrange multipliers](https://en.wikipedia.org/wiki/Lagrange_multiplier) and/or [Karush–Kuhn–Tucker conditions](https://en.wikipedia.org/wiki/Karush–Kuhn–Tucker_conditions). ## Main statements For each theorem name listed below, we also prove similar theorems for `min`, `extr` (if applicable), and `fderiv`/`deriv` instead of `HasFDerivAt`/`HasDerivAt`. * `IsLocalMaxOn.hasFDerivWithinAt_nonpos` : `f' y ≤ 0` whenever `a` is a local maximum of `f` on `s`, `f` has derivative `f'` at `a` within `s`, and `y` belongs to the positive tangent cone of `s` at `a`. * `IsLocalMaxOn.hasFDerivWithinAt_eq_zero` : In the settings of the previous theorem, if both `y` and `-y` belong to the positive tangent cone, then `f' y = 0`. * `IsLocalMax.hasFDerivAt_eq_zero` : [Fermat's Theorem](https://en.wikipedia.org/wiki/Fermat's_theorem_(stationary_points)), the derivative of a differentiable function at a local extremum point equals zero. ## Implementation notes For each mathematical fact we prove several versions of its formalization: * for maxima and minima; * using `HasFDeriv*`/`HasDeriv*` or `fderiv*`/`deriv*`. For the `fderiv*`/`deriv*` versions we omit the differentiability condition whenever it is possible due to the fact that `fderiv` and `deriv` are defined to be zero for non-differentiable functions. ## References * [Fermat's Theorem](https://en.wikipedia.org/wiki/Fermat's_theorem_(stationary_points)); * [Tangent cone](https://en.wikipedia.org/wiki/Tangent_cone); ## Tags local extremum, tangent cone, Fermat's Theorem -/ universe u v open Filter Set open scoped Topology Convex section Module variable {E : Type u} [NormedAddCommGroup E] [NormedSpace ā„ E] {f : E → ā„} {f' : StrongDual ā„ E} {s : Set E} {a x y : E} /-! ### Positive tangent cone -/ /-- "Positive" tangent cone to `s` at `x`; the only difference from `tangentConeAt` is that we require `c n → āˆž` instead of `‖c n‖ → āˆž`. One can think about `posTangentConeAt` as `tangentConeAt NNReal` but we have no theory of normed semifields yet. -/ def posTangentConeAt (s : Set E) (x : E) : Set E := { y : E | ∃ (c : ā„• → ā„) (d : ā„• → E), (āˆ€į¶  n in atTop, x + d n ∈ s) ∧ Tendsto c atTop atTop ∧ Tendsto (fun n => c n • d n) atTop (š“ y) } theorem posTangentConeAt_mono : Monotone fun s => posTangentConeAt s a := by rintro s t hst y ⟨c, d, hd, hc, hcd⟩ exact ⟨c, d, mem_of_superset hd fun h hn => hst hn, hc, hcd⟩ theorem mem_posTangentConeAt_of_frequently_mem (h : ∃ᶠ t : ā„ in š“[>] 0, x + t • y ∈ s) : y ∈ posTangentConeAt s x := by obtain ⟨a, ha, has⟩ := Filter.exists_seq_forall_of_frequently h refine ⟨a⁻¹, (a Ā· • y), Eventually.of_forall has, tendsto_inv_nhdsGT_zero.comp ha, ?_⟩ refine tendsto_const_nhds.congr' ?_ filter_upwards [(tendsto_nhdsWithin_iff.1 ha).2] with n (hn : 0 < a n) simp [ne_of_gt hn] /-- If `[x -[ā„] x + y] āŠ† s`, then `y` belongs to the positive tangent cone of `s`. Before 2024-07-13, this lemma used to be called `mem_posTangentConeAt_of_segment_subset`. See also `sub_mem_posTangentConeAt_of_segment_subset` for the lemma that used to be called `mem_posTangentConeAt_of_segment_subset`. -/ theorem mem_posTangentConeAt_of_segment_subset (h : [x -[ā„] x + y] āŠ† s) : y ∈ posTangentConeAt s x := by refine mem_posTangentConeAt_of_frequently_mem (Eventually.frequently ?_) rw [eventually_nhdsWithin_iff] filter_upwards [ge_mem_nhds one_pos] with t ht₁ htā‚€ apply h rw [segment_eq_image', add_sub_cancel_left] exact mem_image_of_mem _ ⟨le_of_lt htā‚€, htā‚āŸ© theorem sub_mem_posTangentConeAt_of_segment_subset (h : segment ā„ x y āŠ† s) : y - x ∈ posTangentConeAt s x := mem_posTangentConeAt_of_segment_subset <| by rwa [add_sub_cancel] @[simp] theorem posTangentConeAt_univ : posTangentConeAt univ a = univ := eq_univ_of_forall fun _ => mem_posTangentConeAt_of_segment_subset (subset_univ _) /-! ### Fermat's Theorem (vector space) -/ /-- If `f` has a local max on `s` at `a`, `f'` is the derivative of `f` at `a` within `s`, and `y` belongs to the positive tangent cone of `s` at `a`, then `f' y ≤ 0`. -/ theorem IsLocalMaxOn.hasFDerivWithinAt_nonpos (h : IsLocalMaxOn f s a) (hf : HasFDerivWithinAt f f' s a) (hy : y ∈ posTangentConeAt s a) : f' y ≤ 0 := by rcases hy with ⟨c, d, hd, hc, hcd⟩ have hc' : Tendsto (‖c ·‖) atTop atTop := tendsto_abs_atTop_atTop.comp hc suffices āˆ€į¶  n in atTop, c n • (f (a + d n) - f a) ≤ 0 from le_of_tendsto (hf.lim atTop hd hc' hcd) this replace hd : Tendsto (fun n => a + d n) atTop (š“[s] (a + 0)) := tendsto_nhdsWithin_iff.2 ⟨tendsto_const_nhds.add (tangentConeAt.lim_zero _ hc' hcd), hd⟩ rw [add_zero] at hd filter_upwards [hd.eventually h, hc.eventually_ge_atTop 0] with n hfn hcn exact mul_nonpos_of_nonneg_of_nonpos hcn (sub_nonpos.2 hfn) /-- If `f` has a local max on `s` at `a` and `y` belongs to the positive tangent cone of `s` at `a`, then `f' y ≤ 0`. -/ theorem IsLocalMaxOn.fderivWithin_nonpos (h : IsLocalMaxOn f s a) (hy : y ∈ posTangentConeAt s a) : (fderivWithin ā„ f s a : E → ā„) y ≤ 0 := by classical exact if hf : DifferentiableWithinAt ā„ f s a then h.hasFDerivWithinAt_nonpos hf.hasFDerivWithinAt hy else by rw [fderivWithin_zero_of_not_differentiableWithinAt hf]; rfl /-- If `f` has a local max on `s` at `a`, `f'` is a derivative of `f` at `a` within `s`, and both `y` and `-y` belong to the positive tangent cone of `s` at `a`, then `f' y ≤ 0`. -/ theorem IsLocalMaxOn.hasFDerivWithinAt_eq_zero (h : IsLocalMaxOn f s a) (hf : HasFDerivWithinAt f f' s a) (hy : y ∈ posTangentConeAt s a) (hy' : -y ∈ posTangentConeAt s a) : f' y = 0 := le_antisymm (h.hasFDerivWithinAt_nonpos hf hy) <| by simpa using h.hasFDerivWithinAt_nonpos hf hy' /-- If `f` has a local max on `s` at `a` and both `y` and `-y` belong to the positive tangent cone of `s` at `a`, then `f' y = 0`. -/ theorem IsLocalMaxOn.fderivWithin_eq_zero (h : IsLocalMaxOn f s a) (hy : y ∈ posTangentConeAt s a) (hy' : -y ∈ posTangentConeAt s a) : (fderivWithin ā„ f s a : E → ā„) y = 0 := by classical exact if hf : DifferentiableWithinAt ā„ f s a then h.hasFDerivWithinAt_eq_zero hf.hasFDerivWithinAt hy hy' else by rw [fderivWithin_zero_of_not_differentiableWithinAt hf]; rfl /-- If `f` has a local min on `s` at `a`, `f'` is the derivative of `f` at `a` within `s`, and `y` belongs to the positive tangent cone of `s` at `a`, then `0 ≤ f' y`. -/ theorem IsLocalMinOn.hasFDerivWithinAt_nonneg (h : IsLocalMinOn f s a) (hf : HasFDerivWithinAt f f' s a) (hy : y ∈ posTangentConeAt s a) : 0 ≤ f' y := by simpa using h.neg.hasFDerivWithinAt_nonpos hf.neg hy /-- If `f` has a local min on `s` at `a` and `y` belongs to the positive tangent cone of `s` at `a`, then `0 ≤ f' y`. -/ theorem IsLocalMinOn.fderivWithin_nonneg (h : IsLocalMinOn f s a) (hy : y ∈ posTangentConeAt s a) : (0 : ā„) ≤ (fderivWithin ā„ f s a : E → ā„) y := by classical exact if hf : DifferentiableWithinAt ā„ f s a then h.hasFDerivWithinAt_nonneg hf.hasFDerivWithinAt hy else by rw [fderivWithin_zero_of_not_differentiableWithinAt hf]; rfl /-- If `f` has a local max on `s` at `a`, `f'` is a derivative of `f` at `a` within `s`, and both `y` and `-y` belong to the positive tangent cone of `s` at `a`, then `f' y ≤ 0`. -/ theorem IsLocalMinOn.hasFDerivWithinAt_eq_zero (h : IsLocalMinOn f s a) (hf : HasFDerivWithinAt f f' s a) (hy : y ∈ posTangentConeAt s a) (hy' : -y ∈ posTangentConeAt s a) : f' y = 0 := by simpa using h.neg.hasFDerivWithinAt_eq_zero hf.neg hy hy' /-- If `f` has a local min on `s` at `a` and both `y` and `-y` belong to the positive tangent cone of `s` at `a`, then `f' y = 0`. -/ theorem IsLocalMinOn.fderivWithin_eq_zero (h : IsLocalMinOn f s a) (hy : y ∈ posTangentConeAt s a) (hy' : -y ∈ posTangentConeAt s a) : (fderivWithin ā„ f s a : E → ā„) y = 0 := by classical exact if hf : DifferentiableWithinAt ā„ f s a then h.hasFDerivWithinAt_eq_zero hf.hasFDerivWithinAt hy hy' else by rw [fderivWithin_zero_of_not_differentiableWithinAt hf]; rfl /-- **Fermat's Theorem**: the derivative of a function at a local minimum equals zero. -/ theorem IsLocalMin.hasFDerivAt_eq_zero (h : IsLocalMin f a) (hf : HasFDerivAt f f' a) : f' = 0 := by ext y apply (h.on univ).hasFDerivWithinAt_eq_zero hf.hasFDerivWithinAt <;> rw [posTangentConeAt_univ] <;> apply mem_univ /-- **Fermat's Theorem**: the derivative of a function at a local minimum equals zero. -/ theorem IsLocalMin.fderiv_eq_zero (h : IsLocalMin f a) : fderiv ā„ f a = 0 := by classical exact if hf : DifferentiableAt ā„ f a then h.hasFDerivAt_eq_zero hf.hasFDerivAt else fderiv_zero_of_not_differentiableAt hf /-- **Fermat's Theorem**: the derivative of a function at a local maximum equals zero. -/ theorem IsLocalMax.hasFDerivAt_eq_zero (h : IsLocalMax f a) (hf : HasFDerivAt f f' a) : f' = 0 := neg_eq_zero.1 <| h.neg.hasFDerivAt_eq_zero hf.neg /-- **Fermat's Theorem**: the derivative of a function at a local maximum equals zero. -/ theorem IsLocalMax.fderiv_eq_zero (h : IsLocalMax f a) : fderiv ā„ f a = 0 := by classical exact if hf : DifferentiableAt ā„ f a then h.hasFDerivAt_eq_zero hf.hasFDerivAt else fderiv_zero_of_not_differentiableAt hf /-- **Fermat's Theorem**: the derivative of a function at a local extremum equals zero. -/ theorem IsLocalExtr.hasFDerivAt_eq_zero (h : IsLocalExtr f a) : HasFDerivAt f f' a → f' = 0 := h.elim IsLocalMin.hasFDerivAt_eq_zero IsLocalMax.hasFDerivAt_eq_zero /-- **Fermat's Theorem**: the derivative of a function at a local extremum equals zero. -/ theorem IsLocalExtr.fderiv_eq_zero (h : IsLocalExtr f a) : fderiv ā„ f a = 0 := h.elim IsLocalMin.fderiv_eq_zero IsLocalMax.fderiv_eq_zero end Module /-! ### Fermat's Theorem -/ section Real variable {f : ā„ → ā„} {f' : ā„} {s : Set ā„} {a b : ā„} lemma one_mem_posTangentConeAt_iff_mem_closure : 1 ∈ posTangentConeAt s a ↔ a ∈ closure (Ioi a ∩ s) := by constructor Ā· rintro ⟨c, d, hs, hc, hcd⟩ have : Tendsto (a + d Ā·) atTop (š“ a) := by simpa only [add_zero] using tendsto_const_nhds.add (tangentConeAt.lim_zero _ (tendsto_abs_atTop_atTop.comp hc) hcd) apply mem_closure_of_tendsto this filter_upwards [hc.eventually_gt_atTop 0, hcd.eventually (lt_mem_nhds one_pos), hs] with n hcn hcdn hdn simp_all Ā· intro h apply mem_posTangentConeAt_of_frequently_mem rw [mem_closure_iff_frequently, ← map_add_left_nhds_zero, frequently_map] at h simpa [nhdsWithin, frequently_inf_principal] using h lemma one_mem_posTangentConeAt_iff_frequently : 1 ∈ posTangentConeAt s a ↔ ∃ᶠ x in š“[>] a, x ∈ s := by rw [one_mem_posTangentConeAt_iff_mem_closure, mem_closure_iff_frequently, frequently_nhdsWithin_iff, inter_comm] simp_rw [mem_inter_iff] /-- **Fermat's Theorem**: the derivative of a function at a local minimum equals zero. -/ theorem IsLocalMin.hasDerivAt_eq_zero (h : IsLocalMin f a) (hf : HasDerivAt f f' a) : f' = 0 := by simpa using DFunLike.congr_fun (h.hasFDerivAt_eq_zero (hasDerivAt_iff_hasFDerivAt.1 hf)) 1 /-- **Fermat's Theorem**: the derivative of a function at a local minimum equals zero. -/ theorem IsLocalMin.deriv_eq_zero (h : IsLocalMin f a) : deriv f a = 0 := by classical exact if hf : DifferentiableAt ā„ f a then h.hasDerivAt_eq_zero hf.hasDerivAt else deriv_zero_of_not_differentiableAt hf /-- **Fermat's Theorem**: the derivative of a function at a local maximum equals zero. -/ theorem IsLocalMax.hasDerivAt_eq_zero (h : IsLocalMax f a) (hf : HasDerivAt f f' a) : f' = 0 := neg_eq_zero.1 <| h.neg.hasDerivAt_eq_zero hf.neg /-- **Fermat's Theorem**: the derivative of a function at a local maximum equals zero. -/ theorem IsLocalMax.deriv_eq_zero (h : IsLocalMax f a) : deriv f a = 0 := by classical exact if hf : DifferentiableAt ā„ f a then h.hasDerivAt_eq_zero hf.hasDerivAt else deriv_zero_of_not_differentiableAt hf /-- **Fermat's Theorem**: the derivative of a function at a local extremum equals zero. -/ theorem IsLocalExtr.hasDerivAt_eq_zero (h : IsLocalExtr f a) : HasDerivAt f f' a → f' = 0 := h.elim IsLocalMin.hasDerivAt_eq_zero IsLocalMax.hasDerivAt_eq_zero /-- **Fermat's Theorem**: the derivative of a function at a local extremum equals zero. -/ theorem IsLocalExtr.deriv_eq_zero (h : IsLocalExtr f a) : deriv f a = 0 := h.elim IsLocalMin.deriv_eq_zero IsLocalMax.deriv_eq_zero end Real
.lake/packages/mathlib/Mathlib/Analysis/Calculus/LocalExtr/Polynomial.lean
import Mathlib.Analysis.Calculus.LocalExtr.Rolle import Mathlib.Analysis.Calculus.Deriv.Polynomial import Mathlib.Topology.Algebra.Polynomial /-! # Rolle's Theorem for polynomials In this file we use Rolle's Theorem to relate the number of real roots of a real polynomial and its derivative. Namely, we prove the following facts. * `Polynomial.card_roots_toFinset_le_card_roots_derivative_diff_roots_succ`: the number of roots of a real polynomial `p` is at most the number of roots of its derivative that are not roots of `p` plus one. * `Polynomial.card_roots_toFinset_le_derivative`, `Polynomial.card_rootSet_le_derivative`: the number of roots of a real polynomial is at most the number of roots of its derivative plus one. * `Polynomial.card_roots_le_derivative`: same, but the roots are counted with multiplicities. ## Keywords polynomial, Rolle's Theorem, root -/ namespace Polynomial /-- The number of roots of a real polynomial `p` is at most the number of roots of its derivative that are not roots of `p` plus one. -/ theorem card_roots_toFinset_le_card_roots_derivative_diff_roots_succ (p : ā„[X]) : p.roots.toFinset.card ≤ (p.derivative.roots.toFinset \ p.roots.toFinset).card + 1 := by rcases eq_or_ne (derivative p) 0 with hp' | hp' Ā· rw [eq_C_of_derivative_eq_zero hp', roots_C, Multiset.toFinset_zero, Finset.card_empty] exact zero_le _ have hp : p ≠ 0 := ne_of_apply_ne derivative (by rwa [derivative_zero]) refine Finset.card_le_diff_of_interleaved fun x hx y hy hxy hxy' => ?_ rw [Multiset.mem_toFinset, mem_roots hp] at hx hy obtain ⟨z, hz1, hz2⟩ := exists_deriv_eq_zero hxy p.continuousOn (hx.trans hy.symm) refine ⟨z, ?_, hz1⟩ rwa [Multiset.mem_toFinset, mem_roots hp', IsRoot, ← p.deriv] /-- The number of roots of a real polynomial is at most the number of roots of its derivative plus one. -/ theorem card_roots_toFinset_le_derivative (p : ā„[X]) : p.roots.toFinset.card ≤ p.derivative.roots.toFinset.card + 1 := p.card_roots_toFinset_le_card_roots_derivative_diff_roots_succ.trans <| by grw [Finset.sdiff_subset] /-- The number of roots of a real polynomial (counted with multiplicities) is at most the number of roots of its derivative (counted with multiplicities) plus one. -/ theorem card_roots_le_derivative (p : ā„[X]) : Multiset.card p.roots ≤ Multiset.card (derivative p).roots + 1 := calc Multiset.card p.roots = āˆ‘ x ∈ p.roots.toFinset, p.roots.count x := (Multiset.toFinset_sum_count_eq _).symm _ = āˆ‘ x ∈ p.roots.toFinset, (p.roots.count x - 1 + 1) := (Eq.symm <| Finset.sum_congr rfl fun _ hx => tsub_add_cancel_of_le <| Nat.succ_le_iff.2 <| Multiset.count_pos.2 <| Multiset.mem_toFinset.1 hx) _ = (āˆ‘ x ∈ p.roots.toFinset, (p.rootMultiplicity x - 1)) + p.roots.toFinset.card := by simp only [Finset.sum_add_distrib, Finset.card_eq_sum_ones, count_roots] _ ≤ (āˆ‘ x ∈ p.roots.toFinset, p.derivative.rootMultiplicity x) + ((p.derivative.roots.toFinset \ p.roots.toFinset).card + 1) := (add_le_add (Finset.sum_le_sum fun _ _ => rootMultiplicity_sub_one_le_derivative_rootMultiplicity _ _) p.card_roots_toFinset_le_card_roots_derivative_diff_roots_succ) _ ≤ (āˆ‘ x ∈ p.roots.toFinset, p.derivative.roots.count x) + ((āˆ‘ x ∈ p.derivative.roots.toFinset \ p.roots.toFinset, p.derivative.roots.count x) + 1) := by simp only [← count_roots, Finset.card_eq_sum_ones] gcongr with x hx rw [Nat.succ_le_iff, Multiset.count_pos, ← Multiset.mem_toFinset] exact (Finset.mem_sdiff.1 hx).1 _ = Multiset.card (derivative p).roots + 1 := by rw [← add_assoc, ← Finset.sum_union Finset.disjoint_sdiff, Finset.union_sdiff_self_eq_union, ← Multiset.toFinset_sum_count_eq, ← Finset.sum_subset Finset.subset_union_right] intro x _ hxā‚‚ simpa only [Multiset.mem_toFinset, Multiset.count_eq_zero] using hxā‚‚ /-- The number of real roots of a polynomial is at most the number of roots of its derivative plus one. -/ theorem card_rootSet_le_derivative {F : Type*} [CommRing F] [Algebra F ā„] (p : F[X]) : Fintype.card (p.rootSet ā„) ≤ Fintype.card (p.derivative.rootSet ā„) + 1 := by simpa only [rootSet_def, Finset.coe_sort_coe, Fintype.card_coe, derivative_map] using card_roots_toFinset_le_derivative (p.map (algebraMap F ā„)) end Polynomial
.lake/packages/mathlib/Mathlib/Analysis/Calculus/LocalExtr/Rolle.lean
import Mathlib.Analysis.Calculus.LocalExtr.Basic import Mathlib.Topology.Order.Rolle /-! # Rolle's Theorem In this file we prove Rolle's Theorem. The theorem says that for a function `f : ā„ → ā„` such that * $f$ is differentiable on an open interval $(a, b)$, $a < b$; * $f$ is continuous on the corresponding closed interval $[a, b]$; * $f(a) = f(b)$, there exists a point $c∈(a, b)$ such that $f'(c)=0$. We prove four versions of this theorem. * `exists_hasDerivAt_eq_zero` is closest to the statement given above. It assumes that at every point $x ∈ (a, b)$ function $f$ has derivative $f'(x)$, then concludes that $f'(c)=0$ for some $c∈(a, b)$. * `exists_deriv_eq_zero` deals with `deriv f` instead of an arbitrary function `f'` and a predicate `HasDerivAt`; since we use zero as the "junk" value for `deriv f c`, this version does not assume that `f` is differentiable on the open interval. * `exists_hasDerivAt_eq_zero'` is similar to `exists_hasDerivAt_eq_zero` but instead of assuming continuity on the closed interval $[a, b]$ it assumes that $f$ tends to the same limit as $x$ tends to $a$ from the right and as $x$ tends to $b$ from the left. * `exists_deriv_eq_zero'` relates to `exists_deriv_eq_zero` as `exists_hasDerivAt_eq_zero'` relates to `exists_hasDerivAt_eq_zero`. ## References * [Rolle's Theorem](https://en.wikipedia.org/wiki/Rolle's_theorem); ## Tags local extremum, Rolle's Theorem -/ open Set Filter Topology variable {f f' : ā„ → ā„} {a b l : ā„} /-- **Rolle's Theorem** `HasDerivAt` version -/ theorem exists_hasDerivAt_eq_zero (hab : a < b) (hfc : ContinuousOn f (Icc a b)) (hfI : f a = f b) (hff' : āˆ€ x ∈ Ioo a b, HasDerivAt f (f' x) x) : ∃ c ∈ Ioo a b, f' c = 0 := let ⟨c, cmem, hc⟩ := exists_isLocalExtr_Ioo hab hfc hfI ⟨c, cmem, hc.hasDerivAt_eq_zero <| hff' c cmem⟩ /-- **Rolle's Theorem** `deriv` version -/ theorem exists_deriv_eq_zero (hab : a < b) (hfc : ContinuousOn f (Icc a b)) (hfI : f a = f b) : ∃ c ∈ Ioo a b, deriv f c = 0 := let ⟨c, cmem, hc⟩ := exists_isLocalExtr_Ioo hab hfc hfI ⟨c, cmem, hc.deriv_eq_zero⟩ /-- **Rolle's Theorem**, a version for a function on an open interval: if `f` has derivative `f'` on `(a, b)` and has the same limit `l` at `š“[>] a` and `š“[<] b`, then `f' c = 0` for some `c ∈ (a, b)`. -/ theorem exists_hasDerivAt_eq_zero' (hab : a < b) (hfa : Tendsto f (š“[>] a) (š“ l)) (hfb : Tendsto f (š“[<] b) (š“ l)) (hff' : āˆ€ x ∈ Ioo a b, HasDerivAt f (f' x) x) : ∃ c ∈ Ioo a b, f' c = 0 := let ⟨c, cmem, hc⟩ := exists_isLocalExtr_Ioo_of_tendsto hab (fun x hx ↦ (hff' x hx).continuousAt.continuousWithinAt) hfa hfb ⟨c, cmem, hc.hasDerivAt_eq_zero <| hff' c cmem⟩ /-- **Rolle's Theorem**, a version for a function on an open interval: if `f` has the same limit `l` at `š“[>] a` and `š“[<] b`, then `deriv f c = 0` for some `c ∈ (a, b)`. This version does not require differentiability of `f` because we define `deriv f c = 0` whenever `f` is not differentiable at `c`. -/ theorem exists_deriv_eq_zero' (hab : a < b) (hfa : Tendsto f (š“[>] a) (š“ l)) (hfb : Tendsto f (š“[<] b) (š“ l)) : ∃ c ∈ Ioo a b, deriv f c = 0 := by by_cases! h : āˆ€ x ∈ Ioo a b, DifferentiableAt ā„ f x Ā· exact exists_hasDerivAt_eq_zero' hab hfa hfb fun x hx => (h x hx).hasDerivAt Ā· obtain ⟨c, hc, hcdiff⟩ : ∃ x ∈ Ioo a b, ¬DifferentiableAt ā„ f x := h exact ⟨c, hc, deriv_zero_of_not_differentiableAt hcdiff⟩
.lake/packages/mathlib/Mathlib/Analysis/Normed/MulAction.lean
import Mathlib.Analysis.Normed.Field.Basic import Mathlib.Data.ENNReal.Action import Mathlib.Topology.Algebra.UniformMulAction import Mathlib.Topology.MetricSpace.Algebra /-! # Lemmas for `IsBoundedSMul` over normed additive groups Lemmas which hold only in `NormedSpace α β` are provided in another file. Notably we prove that `NonUnitalSeminormedRing`s have bounded actions by left- and right- multiplication. This allows downstream files to write general results about `IsBoundedSMul`, and then deduce `const_mul` and `mul_const` results as an immediate corollary. -/ variable {α β : Type*} section SeminormedAddGroup variable [SeminormedAddGroup α] [SeminormedAddGroup β] [SMulZeroClass α β] variable [IsBoundedSMul α β] {r : α} {x : β} @[bound] theorem norm_smul_le (r : α) (x : β) : ‖r • x‖ ≤ ‖r‖ * ‖x‖ := by simpa [smul_zero] using dist_smul_pair r 0 x @[bound] theorem nnnorm_smul_le (r : α) (x : β) : ‖r • xā€–ā‚Š ≤ ‖rā€–ā‚Š * ‖xā€–ā‚Š := norm_smul_le _ _ @[bound] lemma enorm_smul_le : ‖r • x‖ₑ ≤ ‖r‖ₑ * ‖x‖ₑ := by simpa [enorm, ← ENNReal.coe_mul] using nnnorm_smul_le .. theorem dist_smul_le (s : α) (x y : β) : dist (s • x) (s • y) ≤ ‖s‖ * dist x y := by simpa only [dist_eq_norm, sub_zero] using dist_smul_pair s x y theorem nndist_smul_le (s : α) (x y : β) : nndist (s • x) (s • y) ≤ ‖sā€–ā‚Š * nndist x y := dist_smul_le s x y theorem lipschitzWith_smul (s : α) : LipschitzWith ‖sā€–ā‚Š (s • Ā· : β → β) := lipschitzWith_iff_dist_le_mul.2 <| dist_smul_le _ theorem edist_smul_le (s : α) (x y : β) : edist (s • x) (s • y) ≤ ‖sā€–ā‚Š • edist x y := lipschitzWith_smul s x y end SeminormedAddGroup /-- Left multiplication is bounded. -/ instance NonUnitalSeminormedRing.isBoundedSMul [NonUnitalSeminormedRing α] : IsBoundedSMul α α where dist_smul_pair' x y₁ yā‚‚ := by simpa [mul_sub, dist_eq_norm] using norm_mul_le x (y₁ - yā‚‚) dist_pair_smul' x₁ xā‚‚ y := by simpa [sub_mul, dist_eq_norm] using norm_mul_le (x₁ - xā‚‚) y /-- Right multiplication is bounded. -/ instance NonUnitalSeminormedRing.isBoundedSMulOpposite [NonUnitalSeminormedRing α] : IsBoundedSMul αᵐᵒᵖ α where dist_smul_pair' x y₁ yā‚‚ := by simpa [sub_mul, dist_eq_norm, mul_comm] using norm_mul_le (y₁ - yā‚‚) x.unop dist_pair_smul' x₁ xā‚‚ y := by simpa [mul_sub, dist_eq_norm, mul_comm] using norm_mul_le y (x₁ - xā‚‚).unop section SeminormedRing variable [SeminormedRing α] [SeminormedAddCommGroup β] [Module α β] theorem IsBoundedSMul.of_norm_smul_le (h : āˆ€ (r : α) (x : β), ‖r • x‖ ≤ ‖r‖ * ‖x‖) : IsBoundedSMul α β := { dist_smul_pair' := fun a b₁ bā‚‚ => by simpa [smul_sub, dist_eq_norm] using h a (b₁ - bā‚‚) dist_pair_smul' := fun a₁ aā‚‚ b => by simpa [sub_smul, dist_eq_norm] using h (a₁ - aā‚‚) b } theorem IsBoundedSMul.of_enorm_smul_le (h : āˆ€ (r : α) (x : β), ‖r • x‖ₑ ≤ ‖r‖ₑ * ‖x‖ₑ) : IsBoundedSMul α β := .of_norm_smul_le (by simpa [enorm_eq_nnnorm, ← ENNReal.coe_mul, ENNReal.coe_le_coe] using h) theorem IsBoundedSMul.of_nnnorm_smul_le (h : āˆ€ (r : α) (x : β), ‖r • xā€–ā‚Š ≤ ‖rā€–ā‚Š * ‖xā€–ā‚Š) : IsBoundedSMul α β := .of_norm_smul_le h end SeminormedRing section NormSMulClass /-- Mixin class for scalar-multiplication actions with a strictly multiplicative norm, i.e. `‖r • x‖ = ‖r‖ * ‖x‖`. -/ class NormSMulClass (α β : Type*) [Norm α] [Norm β] [SMul α β] : Prop where protected norm_smul (r : α) (x : β) : ‖r • x‖ = ‖r‖ * ‖x‖ lemma norm_smul [Norm α] [Norm β] [SMul α β] [NormSMulClass α β] (r : α) (x : β) : ‖r • x‖ = ‖r‖ * ‖x‖ := NormSMulClass.norm_smul r x instance (priority := 100) NormMulClass.toNormSMulClass [Norm α] [Mul α] [NormMulClass α] : NormSMulClass α α where norm_smul := norm_mul instance (priority := 100) NormMulClass.toNormSMulClass_op [SeminormedRing α] [NormMulClass α] : NormSMulClass αᵐᵒᵖ α where norm_smul a b := mul_comm ‖b‖ ‖a‖ ā–ø norm_mul b a.unop /-- Mixin class for scalar-multiplication actions with a strictly multiplicative norm, i.e. `‖r • x‖ₑ = ‖r‖ₑ * ‖x‖ₑ`. -/ class ENormSMulClass (α β : Type*) [ENorm α] [ENorm β] [SMul α β] : Prop where protected enorm_smul (r : α) (x : β) : ‖r • x‖ₑ = ‖r‖ₑ * ‖x‖ₑ lemma enorm_smul [ENorm α] [ENorm β] [SMul α β] [ENormSMulClass α β] (r : α) (x : β) : ‖r • x‖ₑ = ‖r‖ₑ * ‖x‖ₑ := ENormSMulClass.enorm_smul r x variable [SeminormedRing α] [SeminormedAddGroup β] [SMul α β] theorem NormSMulClass.of_nnnorm_smul (h : āˆ€ (r : α) (x : β), ‖r • xā€–ā‚Š = ‖rā€–ā‚Š * ‖xā€–ā‚Š) : NormSMulClass α β where norm_smul r b := congr_arg NNReal.toReal (h r b) variable [NormSMulClass α β] theorem nnnorm_smul (r : α) (x : β) : ‖r • xā€–ā‚Š = ‖rā€–ā‚Š * ‖xā€–ā‚Š := NNReal.eq <| norm_smul r x instance (priority := 100) : ENormSMulClass α β where enorm_smul r x := by simp [enorm, nnnorm_smul] instance Pi.instNormSMulClass {ι : Type*} {β : ι → Type*} [Fintype ι] [SeminormedRing α] [āˆ€ i, SeminormedAddGroup (β i)] [āˆ€ i, SMul α (β i)] [āˆ€ i, NormSMulClass α (β i)] : NormSMulClass α (Ī  i, β i) where norm_smul r x := by simp [nnnorm_def, ← coe_nnnorm, nnnorm_smul, ← NNReal.coe_mul, NNReal.mul_finset_sup] instance Prod.instNormSMulClass {γ : Type*} [SeminormedAddGroup γ] [SMul α γ] [NormSMulClass α γ] : NormSMulClass α (β Ɨ γ) where norm_smul := fun r ⟨v₁, vā‚‚āŸ© ↦ by simp only [smul_def, ← coe_nnnorm, nnnorm_def, nnnorm_smul r, ← NNReal.coe_mul, NNReal.mul_sup] instance ULift.instNormSMulClass : NormSMulClass α (ULift β) where norm_smul r v := norm_smul r v.down end NormSMulClass section NormSMulClassModule variable [SeminormedRing α] [SeminormedAddCommGroup β] [Module α β] [NormSMulClass α β] theorem dist_smulā‚€ (s : α) (x y : β) : dist (s • x) (s • y) = ‖s‖ * dist x y := by simp_rw [dist_eq_norm, (norm_smul s (x - y)).symm, smul_sub] theorem nndist_smulā‚€ (s : α) (x y : β) : nndist (s • x) (s • y) = ‖sā€–ā‚Š * nndist x y := NNReal.eq <| dist_smulā‚€ s x y theorem edist_smulā‚€ (s : α) (x y : β) : edist (s • x) (s • y) = ‖sā€–ā‚Š • edist x y := by simp only [edist_nndist, nndist_smulā‚€, ENNReal.coe_mul, ENNReal.smul_def, smul_eq_mul] instance NormSMulClass.toIsBoundedSMul : IsBoundedSMul α β := .of_norm_smul_le fun r x ↦ (norm_smul r x).le end NormSMulClassModule section NormedDivisionRing variable [NormedDivisionRing α] [SeminormedAddGroup β] variable [MulActionWithZero α β] [IsBoundedSMul α β] /-- For a normed division ring, a sub-multiplicative norm is actually strictly multiplicative. This is not an instance as it forms a loop with `NormSMulClass.toIsBoundedSMul`. -/ lemma NormedDivisionRing.toNormSMulClass : NormSMulClass α β where norm_smul r x := by by_cases h : r = 0 Ā· simp [h, zero_smul α x] Ā· refine le_antisymm (norm_smul_le r x) ?_ calc ‖r‖ * ‖x‖ = ‖r‖ * ‖r⁻¹ • r • x‖ := by rw [inv_smul_smulā‚€ h] _ ≤ ‖r‖ * (‖r⁻¹‖ * ‖r • x‖) := by gcongr; apply norm_smul_le _ = ‖r • x‖ := by rw [norm_inv, ← mul_assoc, mul_inv_cancelā‚€ (mt norm_eq_zero.1 h), one_mul] end NormedDivisionRing
.lake/packages/mathlib/Mathlib/Analysis/Normed/Order/Basic.lean
import Mathlib.Analysis.Normed.Group.Basic /-! # Ordered normed spaces In this file, we define classes for fields and groups that are both normed and ordered. These are mostly useful to avoid diamonds during type class inference. -/ open Filter Set open Topology variable {α : Type*}
.lake/packages/mathlib/Mathlib/Analysis/Normed/Order/UpperLower.lean
import Mathlib.Algebra.Order.Field.Pi import Mathlib.Algebra.Order.Pi import Mathlib.Analysis.Normed.Field.Basic import Mathlib.Analysis.Normed.Group.Pointwise import Mathlib.Topology.Algebra.Order.UpperLower import Mathlib.Topology.MetricSpace.Sequences /-! # Upper/lower/order-connected sets in normed groups The topological closure and interior of an upper/lower/order-connected set is an upper/lower/order-connected set (with the notable exception of the closure of an order-connected set). We also prove lemmas specific to `ā„āæ`. Those are helpful to prove that order-connected sets in `ā„āæ` are measurable. ## TODO Is there a way to generalise `IsClosed.upperClosure_pi`/`IsClosed.lowerClosure_pi` so that they also apply to `ā„`, `ā„ Ɨ ā„`, `EuclideanSpace ι ā„`? `_pi` has been appended to their names to disambiguate from the other possible lemmas, but we will want there to be a single set of lemmas for all situations. -/ open Bornology Function Metric Set open scoped Pointwise variable {α ι : Type*} section NormedOrderedGroup variable [NormedCommGroup α] [PartialOrder α] [IsOrderedMonoid α] {s : Set α} @[to_additive IsUpperSet.thickening] protected theorem IsUpperSet.thickening' (hs : IsUpperSet s) (ε : ā„) : IsUpperSet (thickening ε s) := by rw [← ball_mul_one] exact hs.mul_left @[to_additive IsLowerSet.thickening] protected theorem IsLowerSet.thickening' (hs : IsLowerSet s) (ε : ā„) : IsLowerSet (thickening ε s) := by rw [← ball_mul_one] exact hs.mul_left @[to_additive IsUpperSet.cthickening] protected theorem IsUpperSet.cthickening' (hs : IsUpperSet s) (ε : ā„) : IsUpperSet (cthickening ε s) := by rw [cthickening_eq_iInter_thickening''] exact isUpperSet_iInterā‚‚ fun Ī“ _ => hs.thickening' _ @[to_additive IsLowerSet.cthickening] protected theorem IsLowerSet.cthickening' (hs : IsLowerSet s) (ε : ā„) : IsLowerSet (cthickening ε s) := by rw [cthickening_eq_iInter_thickening''] exact isLowerSet_iInterā‚‚ fun Ī“ _ => hs.thickening' _ @[to_additive upperClosure_interior_subset] lemma upperClosure_interior_subset' (s : Set α) : (upperClosure (interior s) : Set α) āŠ† interior (upperClosure s) := upperClosure_min (interior_mono subset_upperClosure) (upperClosure s).upper.interior @[to_additive lowerClosure_interior_subset] lemma lowerClosure_interior_subset' (s : Set α) : (lowerClosure (interior s) : Set α) āŠ† interior (lowerClosure s) := lowerClosure_min (interior_mono subset_lowerClosure) (lowerClosure s).lower.interior end NormedOrderedGroup /-! ### `ā„āæ` -/ section Finite variable [Finite ι] {s : Set (ι → ā„)} {x y : ι → ā„} theorem IsUpperSet.mem_interior_of_forall_lt (hs : IsUpperSet s) (hx : x ∈ closure s) (h : āˆ€ i, x i < y i) : y ∈ interior s := by cases nonempty_fintype ι obtain ⟨ε, hε, hxy⟩ := Pi.exists_forall_pos_add_lt h obtain ⟨z, hz, hxz⟩ := Metric.mem_closure_iff.1 hx _ hε rw [dist_pi_lt_iff hε] at hxz have hyz : āˆ€ i, z i < y i := by refine fun i => (hxy _).trans_le' (sub_le_iff_le_add'.1 <| (le_abs_self _).trans ?_) rw [← Real.norm_eq_abs, ← dist_eq_norm'] exact (hxz _).le obtain ⟨Γ, hĪ“, hyz⟩ := Pi.exists_forall_pos_add_lt hyz refine mem_interior.2 ⟨ball y Ī“, ?_, isOpen_ball, mem_ball_self hΓ⟩ rintro w hw refine hs (fun i => ?_) hz simp_rw [ball_pi _ hĪ“, Real.ball_eq_Ioo] at hw exact ((lt_sub_iff_add_lt.2 <| hyz _).trans (hw _ <| mem_univ _).1).le theorem IsLowerSet.mem_interior_of_forall_lt (hs : IsLowerSet s) (hx : x ∈ closure s) (h : āˆ€ i, y i < x i) : y ∈ interior s := by cases nonempty_fintype ι obtain ⟨ε, hε, hxy⟩ := Pi.exists_forall_pos_add_lt h obtain ⟨z, hz, hxz⟩ := Metric.mem_closure_iff.1 hx _ hε rw [dist_pi_lt_iff hε] at hxz have hyz : āˆ€ i, y i < z i := by refine fun i => (lt_sub_iff_add_lt.2 <| hxy _).trans_le (sub_le_comm.1 <| (le_abs_self _).trans ?_) rw [← Real.norm_eq_abs, ← dist_eq_norm] exact (hxz _).le obtain ⟨Γ, hĪ“, hyz⟩ := Pi.exists_forall_pos_add_lt hyz refine mem_interior.2 ⟨ball y Ī“, ?_, isOpen_ball, mem_ball_self hΓ⟩ rintro w hw refine hs (fun i => ?_) hz simp_rw [ball_pi _ hĪ“, Real.ball_eq_Ioo] at hw exact ((hw _ <| mem_univ _).2.trans <| hyz _).le end Finite section Fintype variable [Fintype ι] {s : Set (ι → ā„)} {a₁ aā‚‚ b₁ bā‚‚ x y : ι → ā„} {Ī“ : ā„} -- TODO: Generalise those lemmas so that they also apply to `ā„` and `EuclideanSpace ι ā„` lemma dist_inf_sup_pi (x y : ι → ā„) : dist (x āŠ“ y) (x āŠ” y) = dist x y := by refine congr_arg NNReal.toReal (Finset.sup_congr rfl fun i _ ↦ ?_) simp only [Real.nndist_eq', max_sub_min_eq_abs, Pi.inf_apply, Pi.sup_apply, Real.nnabs_of_nonneg, abs_nonneg, Real.toNNReal_abs] lemma dist_mono_left_pi : MonotoneOn (dist Ā· y) (Ici y) := by refine fun y₁ hy₁ yā‚‚ hyā‚‚ hy ↦ NNReal.coe_le_coe.2 (Finset.sup_mono_fun fun i _ ↦ ?_) rw [Real.nndist_eq, Real.nnabs_of_nonneg (sub_nonneg_of_le (‹y ≤ _› i : y i ≤ y₁ i)), Real.nndist_eq, Real.nnabs_of_nonneg (sub_nonneg_of_le (‹y ≤ _› i : y i ≤ yā‚‚ i))] grw [hy i] -- TODO(gcongr): we would like `grw [hy]` to work here lemma dist_mono_right_pi : MonotoneOn (dist x) (Ici x) := by simpa only [dist_comm _ x] using dist_mono_left_pi (y := x) lemma dist_anti_left_pi : AntitoneOn (dist Ā· y) (Iic y) := by refine fun y₁ hy₁ yā‚‚ hyā‚‚ hy ↦ NNReal.coe_le_coe.2 (Finset.sup_mono_fun fun i _ ↦ ?_) rw [Real.nndist_eq', Real.nnabs_of_nonneg (sub_nonneg_of_le (‹_ ≤ y› i : yā‚‚ i ≤ y i)), Real.nndist_eq', Real.nnabs_of_nonneg (sub_nonneg_of_le (‹_ ≤ y› i : y₁ i ≤ y i))] exact Real.toNNReal_mono (sub_le_sub_left (hy _) _) lemma dist_anti_right_pi : AntitoneOn (dist x) (Iic x) := by simpa only [dist_comm] using dist_anti_left_pi (y := x) lemma dist_le_dist_of_le_pi (ha : aā‚‚ ≤ a₁) (h₁ : a₁ ≤ b₁) (hb : b₁ ≤ bā‚‚) : dist a₁ b₁ ≤ dist aā‚‚ bā‚‚ := (dist_mono_right_pi h₁ (h₁.trans hb) hb).trans <| dist_anti_left_pi (ha.trans <| h₁.trans hb) (h₁.trans hb) ha theorem IsUpperSet.exists_subset_ball (hs : IsUpperSet s) (hx : x ∈ closure s) (hĪ“ : 0 < Ī“) : ∃ y, closedBall y (Ī“ / 4) āŠ† closedBall x Ī“ ∧ closedBall y (Ī“ / 4) āŠ† interior s := by refine ⟨x + const _ (3 / 4 * Ī“), closedBall_subset_closedBall' ?_, ?_⟩ Ā· grw [dist_self_add_left, ← const_def, pi_norm_const_le] apply le_of_eq simp [abs_of_nonneg, hĪ“.le] ring obtain ⟨y, hy, hxy⟩ := Metric.mem_closure_iff.1 hx _ (div_pos hĪ“ zero_lt_four) refine fun z hz => hs.mem_interior_of_forall_lt (subset_closure hy) fun i => ?_ rw [mem_closedBall, dist_eq_norm'] at hz rw [dist_eq_norm] at hxy replace hxy := (norm_le_pi_norm _ i).trans hxy.le replace hz := (norm_le_pi_norm _ i).trans hz dsimp at hxy hz rw [abs_sub_le_iff] at hxy hz linarith theorem IsLowerSet.exists_subset_ball (hs : IsLowerSet s) (hx : x ∈ closure s) (hĪ“ : 0 < Ī“) : ∃ y, closedBall y (Ī“ / 4) āŠ† closedBall x Ī“ ∧ closedBall y (Ī“ / 4) āŠ† interior s := by refine ⟨x - const _ (3 / 4 * Ī“), closedBall_subset_closedBall' ?_, ?_⟩ Ā· grw [dist_self_sub_left, ← const_def, pi_norm_const_le] apply le_of_eq simp [abs_of_nonneg, hĪ“.le] ring obtain ⟨y, hy, hxy⟩ := Metric.mem_closure_iff.1 hx _ (div_pos hĪ“ zero_lt_four) refine fun z hz => hs.mem_interior_of_forall_lt (subset_closure hy) fun i => ?_ rw [mem_closedBall, dist_eq_norm'] at hz rw [dist_eq_norm] at hxy replace hxy := (norm_le_pi_norm _ i).trans hxy.le replace hz := (norm_le_pi_norm _ i).trans hz dsimp at hxy hz rw [abs_sub_le_iff] at hxy hz linarith end Fintype section Finite variable [Finite ι] {s : Set (ι → ā„)} /-! #### Note The closure and frontier of an antichain might not be antichains. Take for example the union of the open segments from `(0, 2)` to `(1, 1)` and from `(2, 1)` to `(3, 0)`. `(1, 1)` and `(2, 1)` are comparable and both in the closure/frontier. -/ protected lemma IsClosed.upperClosure_pi (hs : IsClosed s) (hs' : BddBelow s) : IsClosed (upperClosure s : Set (ι → ā„)) := by cases nonempty_fintype ι refine IsSeqClosed.isClosed fun f x hf hx ↦ ?_ choose g hg hgf using hf obtain ⟨a, ha⟩ := hx.bddAbove_range obtain ⟨b, hb, φ, hφ, hbf⟩ := tendsto_subseq_of_bounded (hs'.isBounded_inter bddAbove_Iic) fun n ↦ ⟨hg n, (hgf _).trans <| ha <| mem_range_self _⟩ exact ⟨b, closure_minimal inter_subset_left hs hb, le_of_tendsto_of_tendsto' hbf (hx.comp hφ.tendsto_atTop) fun _ ↦ hgf _⟩ protected lemma IsClosed.lowerClosure_pi (hs : IsClosed s) (hs' : BddAbove s) : IsClosed (lowerClosure s : Set (ι → ā„)) := by cases nonempty_fintype ι refine IsSeqClosed.isClosed fun f x hf hx ↦ ?_ choose g hg hfg using hf haveI : BoundedGENhdsClass ā„ := by infer_instance obtain ⟨a, ha⟩ := hx.bddBelow_range obtain ⟨b, hb, φ, hφ, hbf⟩ := tendsto_subseq_of_bounded (hs'.isBounded_inter bddBelow_Ici) fun n ↦ ⟨hg n, (ha <| mem_range_self _).trans <| hfg _⟩ exact ⟨b, closure_minimal inter_subset_left hs hb, le_of_tendsto_of_tendsto' (hx.comp hφ.tendsto_atTop) hbf fun _ ↦ hfg _⟩ protected lemma IsClopen.upperClosure_pi (hs : IsClopen s) (hs' : BddBelow s) : IsClopen (upperClosure s : Set (ι → ā„)) := ⟨hs.1.upperClosure_pi hs', hs.2.upperClosure⟩ protected lemma IsClopen.lowerClosure_pi (hs : IsClopen s) (hs' : BddAbove s) : IsClopen (lowerClosure s : Set (ι → ā„)) := ⟨hs.1.lowerClosure_pi hs', hs.2.lowerClosure⟩ lemma closure_upperClosure_comm_pi (hs : BddBelow s) : closure (upperClosure s : Set (ι → ā„)) = upperClosure (closure s) := (closure_minimal (upperClosure_anti subset_closure) <| isClosed_closure.upperClosure_pi hs.closure).antisymm <| upperClosure_min (closure_mono subset_upperClosure) (upperClosure s).upper.closure lemma closure_lowerClosure_comm_pi (hs : BddAbove s) : closure (lowerClosure s : Set (ι → ā„)) = lowerClosure (closure s) := (closure_minimal (lowerClosure_mono subset_closure) <| isClosed_closure.lowerClosure_pi hs.closure).antisymm <| lowerClosure_min (closure_mono subset_lowerClosure) (lowerClosure s).lower.closure end Finite
.lake/packages/mathlib/Mathlib/Analysis/Normed/Order/Lattice.lean
import Mathlib.Analysis.Normed.Group.Constructions import Mathlib.Analysis.Normed.Group.Rat import Mathlib.Analysis.Normed.Group.Uniform import Mathlib.Topology.Order.Lattice /-! # Normed lattice ordered groups Motivated by the theory of Banach Lattices, we then define `NormedLatticeAddCommGroup` as a lattice with a covariant normed group addition satisfying the solid axiom. ## Main statements We show that a normed lattice ordered group is a topological lattice with respect to the norm topology. ## References * [Meyer-Nieberg, Banach lattices][MeyerNieberg1991] ## Tags normed, lattice, ordered, group -/ /-! ### Normed lattice ordered groups Motivated by the theory of Banach Lattices, this section introduces normed lattice ordered groups. -/ section SolidNorm /-- Let `α` be an `AddCommGroup` with a `Lattice` structure. A norm on `α` is *solid* if, for `a` and `b` in `α`, with absolute values `|a|` and `|b|` respectively, `|a| ≤ |b|` implies `‖a‖ ≤ ‖b‖`. -/ class HasSolidNorm (α : Type*) [NormedAddCommGroup α] [Lattice α] : Prop where solid : āˆ€ ⦃x y : α⦄, |x| ≤ |y| → ‖x‖ ≤ ‖y‖ variable {α : Type*} [NormedAddCommGroup α] [Lattice α] [HasSolidNorm α] theorem norm_le_norm_of_abs_le_abs {a b : α} (h : |a| ≤ |b|) : ‖a‖ ≤ ‖b‖ := HasSolidNorm.solid h /-- If `α` has a solid norm, then the balls centered at the origin of `α` are solid sets. -/ theorem LatticeOrderedAddCommGroup.isSolid_ball (r : ā„) : LatticeOrderedAddCommGroup.IsSolid (Metric.ball (0 : α) r) := fun _ hx _ hxy => mem_ball_zero_iff.mpr ((HasSolidNorm.solid hxy).trans_lt (mem_ball_zero_iff.mp hx)) instance : HasSolidNorm ā„ := ⟨fun _ _ => id⟩ instance : HasSolidNorm ā„š := ⟨fun _ _ _ => by simpa only [norm, ← Rat.cast_abs, Rat.cast_le]⟩ instance Int.hasSolidNorm : HasSolidNorm ℤ where solid x y h := by simpa [← Int.norm_cast_real, ← Int.cast_abs] using h end SolidNorm variable {α : Type*} [NormedAddCommGroup α] [Lattice α] [HasSolidNorm α] [IsOrderedAddMonoid α] open HasSolidNorm theorem dual_solid (a b : α) (h : b āŠ“ -b ≤ a āŠ“ -a) : ‖a‖ ≤ ‖b‖ := by apply solid rw [abs] nth_rw 1 [← neg_neg a] rw [← neg_inf] rw [abs] nth_rw 1 [← neg_neg b] rwa [← neg_inf, neg_le_neg_iff, inf_comm _ b, inf_comm _ a] -- see Note [lower instance priority] /-- Let `α` be a normed lattice ordered group, then the order dual is also a normed lattice ordered group. -/ instance (priority := 100) OrderDual.instHasSolidNorm : HasSolidNorm Ī±įµ’įµˆ := { solid := dual_solid (α := α) } theorem norm_abs_eq_norm (a : α) : ‖|a|‖ = ‖a‖ := (solid (abs_abs a).le).antisymm (solid (abs_abs a).symm.le) theorem norm_inf_sub_inf_le_add_norm (a b c d : α) : ‖a āŠ“ b - c āŠ“ d‖ ≤ ‖a - c‖ + ‖b - d‖ := by rw [← norm_abs_eq_norm (a - c), ← norm_abs_eq_norm (b - d)] refine le_trans (solid ?_) (norm_add_le |a - c| |b - d|) rw [abs_of_nonneg (add_nonneg (abs_nonneg (a - c)) (abs_nonneg (b - d)))] calc |a āŠ“ b - c āŠ“ d| = |a āŠ“ b - c āŠ“ b + (c āŠ“ b - c āŠ“ d)| := by rw [sub_add_sub_cancel] _ ≤ |a āŠ“ b - c āŠ“ b| + |c āŠ“ b - c āŠ“ d| := abs_add_le _ _ _ ≤ |a - c| + |b - d| := by gcongr ?_ + ?_ Ā· exact abs_inf_sub_inf_le_abs _ _ _ Ā· rw [inf_comm c, inf_comm c] exact abs_inf_sub_inf_le_abs _ _ _ theorem norm_sup_sub_sup_le_add_norm (a b c d : α) : ‖a āŠ” b - c āŠ” d‖ ≤ ‖a - c‖ + ‖b - d‖ := by rw [← norm_abs_eq_norm (a - c), ← norm_abs_eq_norm (b - d)] refine le_trans (solid ?_) (norm_add_le |a - c| |b - d|) rw [abs_of_nonneg (add_nonneg (abs_nonneg (a - c)) (abs_nonneg (b - d)))] calc |a āŠ” b - c āŠ” d| = |a āŠ” b - c āŠ” b + (c āŠ” b - c āŠ” d)| := by rw [sub_add_sub_cancel] _ ≤ |a āŠ” b - c āŠ” b| + |c āŠ” b - c āŠ” d| := abs_add_le _ _ _ ≤ |a - c| + |b - d| := by gcongr ?_ + ?_ Ā· exact abs_sup_sub_sup_le_abs _ _ _ Ā· rw [sup_comm c, sup_comm c] exact abs_sup_sub_sup_le_abs _ _ _ theorem norm_inf_le_add (x y : α) : ‖x āŠ“ y‖ ≤ ‖x‖ + ‖y‖ := by have h : ‖x āŠ“ y - 0 āŠ“ 0‖ ≤ ‖x - 0‖ + ‖y - 0‖ := norm_inf_sub_inf_le_add_norm x y 0 0 simpa only [inf_idem, sub_zero] using h theorem norm_sup_le_add (x y : α) : ‖x āŠ” y‖ ≤ ‖x‖ + ‖y‖ := by have h : ‖x āŠ” y - 0 āŠ” 0‖ ≤ ‖x - 0‖ + ‖y - 0‖ := norm_sup_sub_sup_le_add_norm x y 0 0 simpa only [sup_idem, sub_zero] using h -- see Note [lower instance priority] /-- Let `α` be a normed lattice ordered group. Then the infimum is jointly continuous. -/ instance (priority := 100) HasSolidNorm.continuousInf : ContinuousInf α := by refine ⟨continuous_iff_continuousAt.2 fun q => tendsto_iff_norm_sub_tendsto_zero.2 <| ?_⟩ have : āˆ€ p : α Ɨ α, ‖p.1 āŠ“ p.2 - q.1 āŠ“ q.2‖ ≤ ‖p.1 - q.1‖ + ‖p.2 - q.2‖ := fun _ => norm_inf_sub_inf_le_add_norm _ _ _ _ refine squeeze_zero (fun e => norm_nonneg _) this ?_ convert ((continuous_fst.tendsto q).sub <| tendsto_const_nhds).norm.add ((continuous_snd.tendsto q).sub <| tendsto_const_nhds).norm simp -- see Note [lower instance priority] instance (priority := 100) HasSolidNorm.continuousSup {α : Type*} [NormedAddCommGroup α] [Lattice α] [HasSolidNorm α] [IsOrderedAddMonoid α] : ContinuousSup α := OrderDual.continuousSup Ī±įµ’įµˆ -- see Note [lower instance priority] /-- Let `α` be a normed lattice ordered group. Then `α` is a topological lattice in the norm topology. -/ instance (priority := 100) HasSolidNorm.toTopologicalLattice : TopologicalLattice α := TopologicalLattice.mk theorem norm_abs_sub_abs (a b : α) : ‖|a| - |b|‖ ≤ ‖a - b‖ := solid (abs_abs_sub_abs_le _ _) theorem norm_sup_sub_sup_le_norm (x y z : α) : ‖x āŠ” z - y āŠ” z‖ ≤ ‖x - y‖ := solid (abs_sup_sub_sup_le_abs x y z) theorem norm_inf_sub_inf_le_norm (x y z : α) : ‖x āŠ“ z - y āŠ“ z‖ ≤ ‖x - y‖ := solid (abs_inf_sub_inf_le_abs x y z) theorem lipschitzWith_sup_right (z : α) : LipschitzWith 1 fun x => x āŠ” z := LipschitzWith.of_dist_le_mul fun x y => by rw [NNReal.coe_one, one_mul, dist_eq_norm, dist_eq_norm] exact norm_sup_sub_sup_le_norm x y z lemma lipschitzWith_posPart : LipschitzWith 1 (posPart : α → α) := lipschitzWith_sup_right 0 lemma lipschitzWith_negPart : LipschitzWith 1 (negPart : α → α) := by simpa [Function.comp] using lipschitzWith_posPart.comp LipschitzWith.id.neg @[fun_prop] lemma continuous_posPart : Continuous (posPart : α → α) := lipschitzWith_posPart.continuous @[fun_prop] lemma continuous_negPart : Continuous (negPart : α → α) := lipschitzWith_negPart.continuous lemma isClosed_nonneg : IsClosed {x : α | 0 ≤ x} := by have : {x : α | 0 ≤ x} = negPart ⁻¹' {0} := by ext; simp [negPart_eq_zero] rw [this] exact isClosed_singleton.preimage continuous_negPart theorem isClosed_le_of_isClosed_nonneg {G} [AddCommGroup G] [PartialOrder G] [IsOrderedAddMonoid G] [TopologicalSpace G] [ContinuousSub G] (h : IsClosed { x : G | 0 ≤ x }) : IsClosed { p : G Ɨ G | p.fst ≤ p.snd } := by have : { p : G Ɨ G | p.fst ≤ p.snd } = (fun p : G Ɨ G => p.snd - p.fst) ⁻¹' { x : G | 0 ≤ x } := by ext1 p; simp only [sub_nonneg, Set.preimage_setOf_eq] rw [this] exact IsClosed.preimage (continuous_snd.sub continuous_fst) h -- See note [lower instance priority] instance (priority := 100) HasSolidNorm.orderClosedTopology {E} [NormedAddCommGroup E] [Lattice E] [HasSolidNorm E] [IsOrderedAddMonoid E] : OrderClosedTopology E := ⟨isClosed_le_of_isClosed_nonneg isClosed_nonneg⟩
.lake/packages/mathlib/Mathlib/Analysis/Normed/Order/Hom/Ultra.lean
import Mathlib.Analysis.Normed.Order.Hom.Basic import Mathlib.Topology.MetricSpace.Ultra.Basic /-! # Constructing nonarchimedean (ultrametric) normed groups from nonarchimedean normed homs This file defines constructions that upgrade `Add(Comm)Group` to `(Semi)NormedAdd(Comm)Group` using an `AddGroup(Semi)normClass` when the codomain is the reals and the hom is nonarchimedean. ## Implementation details The lemmas need to assume `[Dist α]` to be able to be stated, so they take an extra argument that shows that this distance instance is propositionally equal to the one that comes from the hom-based `AddGroupSeminormClass.toSeminormedAddGroup f` construction. To help at use site, the argument is an autoparam that resolves by definitional equality when using these constructions. -/ variable {F α : Type*} [FunLike F α ā„] /-- Proves that when a `SeminormedAddGroup` structure is constructed from an `AddGroupSeminormClass` that satisfies `IsNonarchimedean`, the group has an `IsUltrametricDist`. -/ lemma AddGroupSeminormClass.isUltrametricDist [AddGroup α] [AddGroupSeminormClass F α ā„] [inst : Dist α] {f : F} (hna : IsNonarchimedean f) (hd : inst = (AddGroupSeminormClass.toSeminormedAddGroup f).toDist := by rfl) : IsUltrametricDist α := ⟨fun x y z ↦ by simpa only [hd, dist_eq_norm, AddGroupSeminormClass.toSeminormedAddGroup_norm_eq, ← sub_add_sub_cancel x y z] using hna _ _⟩
.lake/packages/mathlib/Mathlib/Analysis/Normed/Order/Hom/Basic.lean
import Mathlib.Algebra.Order.Hom.Basic import Mathlib.Analysis.Normed.Group.Basic /-! # Constructing (semi)normed groups from (semi)normed homs This file defines constructions that upgrade `(Comm)Group` to `(Semi)Normed(Comm)Group` using a `Group(Semi)normClass` when the codomain is the reals. See `Mathlib/Analysis/Normed/Order/Hom/Ultra.lean` for further upgrades to nonarchimedean normed groups. -/ variable {F α : Type*} [FunLike F α ā„] /-- Constructs a `SeminormedGroup` structure from a `GroupSeminormClass` on a `Group`. -/ -- See note [reducible non-instances] @[to_additive /-- Constructs a `SeminormedAddGroup` structure from an `AddGroupSeminormClass` on an `AddGroup`. -/] abbrev GroupSeminormClass.toSeminormedGroup [Group α] [GroupSeminormClass F α ā„] (f : F) : SeminormedGroup α where norm := f dist x y := f (x / y) dist_eq _ _ := rfl dist_self _ := by simp dist_comm x y := by simp only [← map_inv_eq_map f (x / y), inv_div] dist_triangle x y z := by simpa using map_mul_le_add f (x / y) (y / z) @[to_additive] lemma GroupSeminormClass.toSeminormedGroup_norm_eq [Group α] [GroupSeminormClass F α ā„] (f : F) (x : α) : @norm _ (GroupSeminormClass.toSeminormedGroup f).toNorm x = f x := rfl /-- Constructs a `SeminormedCommGroup` structure from a `GroupSeminormClass` on a `CommGroup`. -/ -- See note [reducible non-instances] @[to_additive /-- Constructs a `SeminormedAddCommGroup` structure from an `AddGroupSeminormClass` on an `AddCommGroup`. -/] abbrev GroupSeminormClass.toSeminormedCommGroup [CommGroup α] [GroupSeminormClass F α ā„] (f : F) : SeminormedCommGroup α where __ := GroupSeminormClass.toSeminormedGroup f __ : CommGroup α := inferInstance @[to_additive] lemma GroupSeminormClass.toSeminormedCommGroup_norm_eq [CommGroup α] [GroupSeminormClass F α ā„] (f : F) (x : α) : @norm _ (GroupSeminormClass.toSeminormedCommGroup f).toNorm x = f x := rfl /-- Constructs a `NormedGroup` structure from a `GroupNormClass` on a `Group`. -/ -- See note [reducible non-instances] @[to_additive /-- Constructs a `NormedAddGroup` structure from an `AddGroupNormClass` on an `AddGroup`. -/] abbrev GroupNormClass.toNormedGroup [Group α] [GroupNormClass F α ā„] (f : F) : NormedGroup α where __ := GroupSeminormClass.toSeminormedGroup f eq_of_dist_eq_zero h := div_eq_one.mp (eq_one_of_map_eq_zero f h) @[to_additive] lemma GroupNormClass.toNormedGroup_norm_eq [Group α] [GroupNormClass F α ā„] (f : F) (x : α) : @norm _ (GroupNormClass.toNormedGroup f).toNorm x = f x := rfl /-- Constructs a `NormedCommGroup` structure from a `GroupNormClass` on a `CommGroup`. -/ -- See note [reducible non-instances] @[to_additive /-- Constructs a `NormedAddCommGroup` structure from an `AddGroupNormClass` on an `AddCommGroup`. -/] abbrev GroupNormClass.toNormedCommGroup [CommGroup α] [GroupNormClass F α ā„] (f : F) : NormedCommGroup α where __ := GroupNormClass.toNormedGroup f __ : CommGroup α := inferInstance @[to_additive] lemma GroupNormClass.toNormedCommGroup_norm_eq [CommGroup α] [GroupNormClass F α ā„] (f : F) (x : α) : @norm _ (GroupNormClass.toNormedCommGroup f).toNorm x = f x := rfl
.lake/packages/mathlib/Mathlib/Analysis/Normed/Group/HomCompletion.lean
import Mathlib.Analysis.Normed.Group.Hom import Mathlib.Analysis.Normed.Group.Completion /-! # Completion of normed group homs Given two (semi) normed groups `G` and `H` and a normed group hom `f : NormedAddGroupHom G H`, we build and study a normed group hom `f.completion : NormedAddGroupHom (completion G) (completion H)` such that the diagram ``` f G -----------> H | | | | | | V V completion G -----------> completion H f.completion ``` commutes. The map itself comes from the general theory of completion of uniform spaces, but here we want a normed group hom, study its operator norm and kernel. The vertical maps in the above diagrams are also normed group homs constructed in this file. ## Main definitions and results: * `NormedAddGroupHom.completion`: see the discussion above. * `NormedAddCommGroup.toCompl : NormedAddGroupHom G (completion G)`: the canonical map from `G` to its completion, as a normed group hom * `NormedAddGroupHom.completion_toCompl`: the above diagram indeed commutes. * `NormedAddGroupHom.norm_completion`: `‖f.completion‖ = ‖f‖` * `NormedAddGroupHom.ker_le_ker_completion`: the kernel of `f.completion` contains the image of the kernel of `f`. * `NormedAddGroupHom.ker_completion`: the kernel of `f.completion` is the closure of the image of the kernel of `f` under an assumption that `f` is quantitatively surjective onto its image. * `NormedAddGroupHom.extension` : if `H` is complete, the extension of `f : NormedAddGroupHom G H` to a `NormedAddGroupHom (completion G) H`. -/ noncomputable section open Set NormedAddGroupHom UniformSpace section Completion variable {G : Type*} [SeminormedAddCommGroup G] {H : Type*} [SeminormedAddCommGroup H] {K : Type*} [SeminormedAddCommGroup K] /-- The normed group hom induced between completions. -/ def NormedAddGroupHom.completion (f : NormedAddGroupHom G H) : NormedAddGroupHom (Completion G) (Completion H) := .ofLipschitz (f.toAddMonoidHom.completion f.continuous) f.lipschitz.completion_map theorem NormedAddGroupHom.completion_def (f : NormedAddGroupHom G H) (x : Completion G) : f.completion x = Completion.map f x := rfl @[simp] theorem NormedAddGroupHom.completion_coe_to_fun (f : NormedAddGroupHom G H) : (f.completion : Completion G → Completion H) = Completion.map f := rfl theorem NormedAddGroupHom.completion_coe (f : NormedAddGroupHom G H) (g : G) : f.completion g = f g := Completion.map_coe f.uniformContinuous _ @[simp] theorem NormedAddGroupHom.completion_coe' (f : NormedAddGroupHom G H) (g : G) : Completion.map f g = f g := f.completion_coe g /-- Completion of normed group homs as a normed group hom. -/ @[simps] def normedAddGroupHomCompletionHom : NormedAddGroupHom G H →+ NormedAddGroupHom (Completion G) (Completion H) where toFun := NormedAddGroupHom.completion map_zero' := toAddMonoidHom_injective AddMonoidHom.completion_zero map_add' f g := toAddMonoidHom_injective <| f.toAddMonoidHom.completion_add g.toAddMonoidHom f.continuous g.continuous @[simp] theorem NormedAddGroupHom.completion_id : (NormedAddGroupHom.id G).completion = NormedAddGroupHom.id (Completion G) := by ext x rw [NormedAddGroupHom.completion_def, NormedAddGroupHom.coe_id, Completion.map_id] rfl theorem NormedAddGroupHom.completion_comp (f : NormedAddGroupHom G H) (g : NormedAddGroupHom H K) : g.completion.comp f.completion = (g.comp f).completion := by ext x rw [NormedAddGroupHom.coe_comp, NormedAddGroupHom.completion_def, NormedAddGroupHom.completion_coe_to_fun, NormedAddGroupHom.completion_coe_to_fun, Completion.map_comp g.uniformContinuous f.uniformContinuous] rfl theorem NormedAddGroupHom.completion_neg (f : NormedAddGroupHom G H) : (-f).completion = -f.completion := map_neg (normedAddGroupHomCompletionHom : NormedAddGroupHom G H →+ _) f theorem NormedAddGroupHom.completion_add (f g : NormedAddGroupHom G H) : (f + g).completion = f.completion + g.completion := normedAddGroupHomCompletionHom.map_add f g theorem NormedAddGroupHom.completion_sub (f g : NormedAddGroupHom G H) : (f - g).completion = f.completion - g.completion := map_sub (normedAddGroupHomCompletionHom : NormedAddGroupHom G H →+ _) f g @[simp] theorem NormedAddGroupHom.zero_completion : (0 : NormedAddGroupHom G H).completion = 0 := normedAddGroupHomCompletionHom.map_zero /-- The map from a normed group to its completion, as a normed group hom. -/ @[simps] def NormedAddCommGroup.toCompl : NormedAddGroupHom G (Completion G) where toFun := (↑) map_add' := Completion.toCompl.map_add bound' := ⟨1, by simp [le_refl]⟩ open NormedAddCommGroup theorem NormedAddCommGroup.norm_toCompl (x : G) : ‖toCompl x‖ = ‖x‖ := Completion.norm_coe x theorem NormedAddCommGroup.denseRange_toCompl : DenseRange (toCompl : G → Completion G) := Completion.isDenseInducing_coe.dense @[simp] theorem NormedAddGroupHom.completion_toCompl (f : NormedAddGroupHom G H) : f.completion.comp toCompl = toCompl.comp f := by ext x; simp @[simp] theorem NormedAddGroupHom.norm_completion (f : NormedAddGroupHom G H) : ‖f.completion‖ = ‖f‖ := le_antisymm (ofLipschitz_norm_le _ _) <| opNorm_le_bound _ (norm_nonneg _) fun x => by simpa using f.completion.le_opNorm x theorem NormedAddGroupHom.ker_le_ker_completion (f : NormedAddGroupHom G H) : (toCompl.comp <| incl f.ker).range ≤ f.completion.ker := by rintro _ ⟨⟨g, hā‚€ : f g = 0⟩, rfl⟩ simp [hā‚€, mem_ker, Completion.coe_zero] theorem NormedAddGroupHom.ker_completion {f : NormedAddGroupHom G H} {C : ā„} (h : f.SurjectiveOnWith f.range C) : (f.completion.ker : Set <| Completion G) = closure (toCompl.comp <| incl f.ker).range := by refine le_antisymm ?_ (closure_minimal f.ker_le_ker_completion f.completion.isClosed_ker) rintro hatg (hatg_in : f.completion hatg = 0) rw [SeminormedAddCommGroup.mem_closure_iff] intro ε ε_pos rcases h.exists_pos with ⟨C', C'_pos, hC'⟩ rcases exists_pos_mul_lt ε_pos (1 + C' * ‖f‖) with ⟨Γ, Ī“_pos, hΓ⟩ obtain ⟨_, ⟨g : G, rfl⟩, hg : ‖hatg - g‖ < Γ⟩ := SeminormedAddCommGroup.mem_closure_iff.mp (Completion.isDenseInducing_coe.dense hatg) Ī“ Ī“_pos obtain ⟨g' : G, hgg' : f g' = f g, hfg : ‖g'‖ ≤ C' * ‖f gā€–āŸ© := hC' (f g) (mem_range_self _ g) have mem_ker : g - g' ∈ f.ker := by rw [f.mem_ker, map_sub, sub_eq_zero.mpr hgg'.symm] refine ⟨_, ⟨⟨g - g', mem_ker⟩, rfl⟩, ?_⟩ have : ‖f g‖ ≤ ‖f‖ * Ī“ := calc ‖f g‖ ≤ ‖f‖ * ‖hatg - g‖ := by simpa [map_sub, hatg_in] using f.completion.le_opNorm (hatg - g) _ ≤ ‖f‖ * Ī“ := by gcongr calc ‖hatg - ↑(g - g')‖ = ‖hatg - g + g'‖ := by rw [Completion.coe_sub, sub_add] _ ≤ ‖hatg - g‖ + ‖(g' : Completion G)‖ := norm_add_le _ _ _ = ‖hatg - g‖ + ‖g'‖ := by rw [Completion.norm_coe] _ < Ī“ + C' * ‖f g‖ := add_lt_add_of_lt_of_le hg hfg _ ≤ Ī“ + C' * (‖f‖ * Ī“) := by gcongr _ < ε := by simpa only [add_mul, one_mul, mul_assoc] using hĪ“ end Completion section Extension variable {G : Type*} [SeminormedAddCommGroup G] variable {H : Type*} [SeminormedAddCommGroup H] [T0Space H] [CompleteSpace H] /-- If `H` is complete, the extension of `f : NormedAddGroupHom G H` to a `NormedAddGroupHom (completion G) H`. -/ def NormedAddGroupHom.extension (f : NormedAddGroupHom G H) : NormedAddGroupHom (Completion G) H := .ofLipschitz (f.toAddMonoidHom.extension f.continuous) <| let _ := MetricSpace.ofT0PseudoMetricSpace H f.lipschitz.completion_extension theorem NormedAddGroupHom.extension_def (f : NormedAddGroupHom G H) (v : G) : f.extension v = Completion.extension f v := rfl @[simp] theorem NormedAddGroupHom.extension_coe (f : NormedAddGroupHom G H) (v : G) : f.extension v = f v := AddMonoidHom.extension_coe _ f.continuous _ theorem NormedAddGroupHom.extension_coe_to_fun (f : NormedAddGroupHom G H) : (f.extension : Completion G → H) = Completion.extension f := rfl theorem NormedAddGroupHom.extension_unique (f : NormedAddGroupHom G H) {g : NormedAddGroupHom (Completion G) H} (hg : āˆ€ v, f v = g v) : f.extension = g := by ext v rw [NormedAddGroupHom.extension_coe_to_fun, Completion.extension_unique f.uniformContinuous g.uniformContinuous fun a => hg a] end Extension
.lake/packages/mathlib/Mathlib/Analysis/Normed/Group/Int.lean
import Mathlib.Analysis.Normed.Group.Basic import Mathlib.Topology.Instances.Int /-! # ℤ as a normed group -/ open NNReal variable {α : Type*} namespace Int instance instNormedAddCommGroup : NormedAddCommGroup ℤ where norm n := ‖(n : ā„)‖ dist_eq m n := by simp only [Int.dist_eq, norm, Int.cast_sub] @[norm_cast] theorem norm_cast_real (m : ℤ) : ‖(m : ā„)‖ = ‖m‖ := rfl theorem norm_eq_abs (n : ℤ) : ‖n‖ = |(n : ā„)| := rfl theorem norm_natCast (n : ā„•) : ‖(n : ℤ)‖ = n := by simp [Int.norm_eq_abs] theorem _root_.NNReal.natCast_natAbs (n : ℤ) : (n.natAbs : ā„ā‰„0) = ‖nā€–ā‚Š := NNReal.eq <| calc ((n.natAbs : ā„ā‰„0) : ā„) = (n.natAbs : ℤ) := by simp only [Int.cast_natCast, NNReal.coe_natCast] _ = |(n : ā„)| := by simp only [Int.natCast_natAbs, Int.cast_abs] _ = ‖n‖ := (norm_eq_abs n).symm theorem abs_le_floor_nnreal_iff (z : ℤ) (c : ā„ā‰„0) : |z| ≤ ⌊cāŒ‹ā‚Š ↔ ‖zā€–ā‚Š ≤ c := by rw [Int.abs_eq_natAbs, Int.ofNat_le, Nat.le_floor_iff (zero_le c), NNReal.natCast_natAbs z] end Int -- Now that we've installed the norm on `ℤ`, -- we can state some lemmas about `zsmul`. section variable [SeminormedCommGroup α] @[to_additive norm_zsmul_le] theorem norm_zpow_le_mul_norm (n : ℤ) (a : α) : ‖a ^ n‖ ≤ ‖n‖ * ‖a‖ := by rcases n.eq_nat_or_neg with ⟨n, rfl | rfl⟩ <;> simpa [Int.norm_natCast] using norm_pow_le_mul_norm @[to_additive nnnorm_zsmul_le] theorem nnnorm_zpow_le_mul_norm (n : ℤ) (a : α) : ‖a ^ nā€–ā‚Š ≤ ‖nā€–ā‚Š * ‖aā€–ā‚Š := by simpa only [← NNReal.coe_le_coe, NNReal.coe_mul] using norm_zpow_le_mul_norm n a end
.lake/packages/mathlib/Mathlib/Analysis/Normed/Group/Uniform.lean
import Mathlib.Analysis.Normed.Group.Continuity import Mathlib.Topology.Algebra.IsUniformGroup.Basic import Mathlib.Topology.MetricSpace.Algebra import Mathlib.Topology.MetricSpace.IsometricSMul /-! # Normed groups are uniform groups This file proves lipschitzness of normed group operations and shows that normed groups are uniform groups. -/ variable {š“• E F : Type*} open Filter Function Metric Bornology open scoped ENNReal NNReal Uniformity Pointwise Topology section SeminormedGroup variable [SeminormedGroup E] [SeminormedGroup F] {s : Set E} {a b : E} {r : ā„} @[to_additive] instance NormedGroup.to_isIsometricSMul_right : IsIsometricSMul Eᵐᵒᵖ E := ⟨fun a => Isometry.of_dist_eq fun b c => by simp [dist_eq_norm_div]⟩ @[to_additive] theorem Isometry.norm_map_of_map_one {f : E → F} (hi : Isometry f) (h₁ : f 1 = 1) (x : E) : ‖f x‖ = ‖x‖ := by rw [← dist_one_right, ← h₁, hi.dist_eq, dist_one_right] @[to_additive (attr := simp) norm_map] theorem norm_map' [FunLike š“• E F] [IsometryClass š“• E F] [OneHomClass š“• E F] (f : š“•) (x : E) : ‖f x‖ = ‖x‖ := (IsometryClass.isometry f).norm_map_of_map_one (map_one f) x @[to_additive (attr := simp) nnnorm_map] theorem nnnorm_map' [FunLike š“• E F] [IsometryClass š“• E F] [OneHomClass š“• E F] (f : š“•) (x : E) : ‖f xā€–ā‚Š = ‖xā€–ā‚Š := NNReal.eq <| norm_map' f x @[to_additive (attr := simp)] theorem dist_mul_self_right (a b : E) : dist b (a * b) = ‖a‖ := by rw [← dist_one_left, ← dist_mul_right 1 a b, one_mul] @[to_additive (attr := simp)] theorem dist_mul_self_left (a b : E) : dist (a * b) b = ‖a‖ := by rw [dist_comm, dist_mul_self_right] @[to_additive (attr := simp)] theorem dist_div_eq_dist_mul_left (a b c : E) : dist (a / b) c = dist a (c * b) := by rw [← dist_mul_right _ _ b, div_mul_cancel] @[to_additive (attr := simp)] theorem dist_div_eq_dist_mul_right (a b c : E) : dist a (b / c) = dist (a * c) b := by rw [← dist_mul_right _ _ c, div_mul_cancel] open Finset variable [FunLike š“• E F] /-- A homomorphism `f` of seminormed groups is Lipschitz, if there exists a constant `C` such that for all `x`, one has `‖f x‖ ≤ C * ‖x‖`. The analogous condition for a linear map of (semi)normed spaces is in `Mathlib/Analysis/NormedSpace/OperatorNorm.lean`. -/ @[to_additive /-- A homomorphism `f` of seminormed groups is Lipschitz, if there exists a constant `C` such that for all `x`, one has `‖f x‖ ≤ C * ‖x‖`. The analogous condition for a linear map of (semi)normed spaces is in `Mathlib/Analysis/NormedSpace/OperatorNorm.lean`. -/] theorem MonoidHomClass.lipschitz_of_bound [MonoidHomClass š“• E F] (f : š“•) (C : ā„) (h : āˆ€ x, ‖f x‖ ≤ C * ‖x‖) : LipschitzWith (Real.toNNReal C) f := LipschitzWith.of_dist_le' fun x y => by simpa only [dist_eq_norm_div, map_div] using h (x / y) @[to_additive] theorem lipschitzOnWith_iff_norm_div_le {f : E → F} {C : ā„ā‰„0} : LipschitzOnWith C f s ↔ āˆ€ ⦃x⦄, x ∈ s → āˆ€ ⦃y⦄, y ∈ s → ‖f x / f y‖ ≤ C * ‖x / y‖ := by simp only [lipschitzOnWith_iff_dist_le_mul, dist_eq_norm_div] alias ⟨LipschitzOnWith.norm_div_le, _⟩ := lipschitzOnWith_iff_norm_div_le attribute [to_additive] LipschitzOnWith.norm_div_le @[to_additive] theorem LipschitzOnWith.norm_div_le_of_le {f : E → F} {C : ā„ā‰„0} (h : LipschitzOnWith C f s) (ha : a ∈ s) (hb : b ∈ s) (hr : ‖a / b‖ ≤ r) : ‖f a / f b‖ ≤ C * r := (h.norm_div_le ha hb).trans <| by gcongr @[to_additive] theorem lipschitzWith_iff_norm_div_le {f : E → F} {C : ā„ā‰„0} : LipschitzWith C f ↔ āˆ€ x y, ‖f x / f y‖ ≤ C * ‖x / y‖ := by simp only [lipschitzWith_iff_dist_le_mul, dist_eq_norm_div] alias ⟨LipschitzWith.norm_div_le, _⟩ := lipschitzWith_iff_norm_div_le attribute [to_additive] LipschitzWith.norm_div_le @[to_additive] theorem LipschitzWith.norm_div_le_of_le {f : E → F} {C : ā„ā‰„0} (h : LipschitzWith C f) (hr : ‖a / b‖ ≤ r) : ‖f a / f b‖ ≤ C * r := (h.norm_div_le _ _).trans <| by gcongr /-- A homomorphism `f` of seminormed groups is continuous, if there exists a constant `C` such that for all `x`, one has `‖f x‖ ≤ C * ‖x‖`. -/ @[to_additive /-- A homomorphism `f` of seminormed groups is continuous, if there exists a constant `C` such that for all `x`, one has `‖f x‖ ≤ C * ‖x‖`. -/] theorem MonoidHomClass.continuous_of_bound [MonoidHomClass š“• E F] (f : š“•) (C : ā„) (h : āˆ€ x, ‖f x‖ ≤ C * ‖x‖) : Continuous f := (MonoidHomClass.lipschitz_of_bound f C h).continuous @[to_additive] theorem MonoidHomClass.uniformContinuous_of_bound [MonoidHomClass š“• E F] (f : š“•) (C : ā„) (h : āˆ€ x, ‖f x‖ ≤ C * ‖x‖) : UniformContinuous f := (MonoidHomClass.lipschitz_of_bound f C h).uniformContinuous @[to_additive] theorem MonoidHomClass.isometry_iff_norm [MonoidHomClass š“• E F] (f : š“•) : Isometry f ↔ āˆ€ x, ‖f x‖ = ‖x‖ := by simp only [isometry_iff_dist_eq, dist_eq_norm_div, ← map_div] refine ⟨fun h x => ?_, fun h x y => h _⟩ simpa using h x 1 alias ⟨_, MonoidHomClass.isometry_of_norm⟩ := MonoidHomClass.isometry_iff_norm attribute [to_additive] MonoidHomClass.isometry_of_norm section NNNorm @[to_additive] theorem MonoidHomClass.lipschitz_of_bound_nnnorm [MonoidHomClass š“• E F] (f : š“•) (C : ā„ā‰„0) (h : āˆ€ x, ‖f xā€–ā‚Š ≤ C * ‖xā€–ā‚Š) : LipschitzWith C f := @Real.toNNReal_coe C ā–ø MonoidHomClass.lipschitz_of_bound f C h @[to_additive] theorem MonoidHomClass.antilipschitz_of_bound [MonoidHomClass š“• E F] (f : š“•) {K : ā„ā‰„0} (h : āˆ€ x, ‖x‖ ≤ K * ‖f x‖) : AntilipschitzWith K f := AntilipschitzWith.of_le_mul_dist fun x y => by simpa only [dist_eq_norm_div, map_div] using h (x / y) @[to_additive LipschitzWith.norm_le_mul] theorem LipschitzWith.norm_le_mul' {f : E → F} {K : ā„ā‰„0} (h : LipschitzWith K f) (hf : f 1 = 1) (x) : ‖f x‖ ≤ K * ‖x‖ := by simpa only [dist_one_right, hf] using h.dist_le_mul x 1 @[to_additive LipschitzWith.nnorm_le_mul] theorem LipschitzWith.nnorm_le_mul' {f : E → F} {K : ā„ā‰„0} (h : LipschitzWith K f) (hf : f 1 = 1) (x) : ‖f xā€–ā‚Š ≤ K * ‖xā€–ā‚Š := h.norm_le_mul' hf x @[to_additive AntilipschitzWith.le_mul_norm] theorem AntilipschitzWith.le_mul_norm' {f : E → F} {K : ā„ā‰„0} (h : AntilipschitzWith K f) (hf : f 1 = 1) (x) : ‖x‖ ≤ K * ‖f x‖ := by simpa only [dist_one_right, hf] using h.le_mul_dist x 1 @[to_additive AntilipschitzWith.le_mul_nnnorm] theorem AntilipschitzWith.le_mul_nnnorm' {f : E → F} {K : ā„ā‰„0} (h : AntilipschitzWith K f) (hf : f 1 = 1) (x) : ‖xā€–ā‚Š ≤ K * ‖f xā€–ā‚Š := h.le_mul_norm' hf x @[to_additive] theorem OneHomClass.bound_of_antilipschitz [OneHomClass š“• E F] (f : š“•) {K : ā„ā‰„0} (h : AntilipschitzWith K f) (x) : ‖x‖ ≤ K * ‖f x‖ := h.le_mul_nnnorm' (map_one f) x @[to_additive] theorem Isometry.nnnorm_map_of_map_one {f : E → F} (hi : Isometry f) (h₁ : f 1 = 1) (x : E) : ‖f xā€–ā‚Š = ‖xā€–ā‚Š := Subtype.ext <| hi.norm_map_of_map_one h₁ x end NNNorm @[to_additive lipschitzWith_one_norm] theorem lipschitzWith_one_norm' : LipschitzWith 1 (norm : E → ā„) := by simpa using LipschitzWith.dist_right (1 : E) @[to_additive lipschitzWith_one_nnnorm] theorem lipschitzWith_one_nnnorm' : LipschitzWith 1 (NNNorm.nnnorm : E → ā„ā‰„0) := lipschitzWith_one_norm' @[to_additive uniformContinuous_norm] theorem uniformContinuous_norm' : UniformContinuous (norm : E → ā„) := lipschitzWith_one_norm'.uniformContinuous @[to_additive uniformContinuous_nnnorm] theorem uniformContinuous_nnnorm' : UniformContinuous fun a : E => ‖aā€–ā‚Š := uniformContinuous_norm'.subtype_mk _ end SeminormedGroup section SeminormedCommGroup variable [SeminormedCommGroup E] [SeminormedCommGroup F] {a₁ aā‚‚ b₁ bā‚‚ : E} {r₁ rā‚‚ : ā„} @[to_additive] instance NormedGroup.to_isIsometricSMul_left : IsIsometricSMul E E := ⟨fun a => Isometry.of_dist_eq fun b c => by simp [dist_eq_norm_div]⟩ @[to_additive (attr := simp)] theorem dist_self_mul_right (a b : E) : dist a (a * b) = ‖b‖ := by rw [← dist_one_left, ← dist_mul_left a 1 b, mul_one] @[to_additive (attr := simp)] theorem dist_self_mul_left (a b : E) : dist (a * b) a = ‖b‖ := by rw [dist_comm, dist_self_mul_right] @[to_additive (attr := simp 1001)] -- Increase priority because `simp` can prove this theorem dist_self_div_right (a b : E) : dist a (a / b) = ‖b‖ := by rw [div_eq_mul_inv, dist_self_mul_right, norm_inv'] @[to_additive (attr := simp 1001)] -- Increase priority because `simp` can prove this theorem dist_self_div_left (a b : E) : dist (a / b) a = ‖b‖ := by rw [dist_comm, dist_self_div_right] @[to_additive] theorem dist_mul_mul_le (a₁ aā‚‚ b₁ bā‚‚ : E) : dist (a₁ * aā‚‚) (b₁ * bā‚‚) ≤ dist a₁ b₁ + dist aā‚‚ bā‚‚ := by simpa only [dist_mul_left, dist_mul_right] using dist_triangle (a₁ * aā‚‚) (b₁ * aā‚‚) (b₁ * bā‚‚) @[to_additive] theorem dist_mul_mul_le_of_le (h₁ : dist a₁ b₁ ≤ r₁) (hā‚‚ : dist aā‚‚ bā‚‚ ≤ rā‚‚) : dist (a₁ * aā‚‚) (b₁ * bā‚‚) ≤ r₁ + rā‚‚ := (dist_mul_mul_le a₁ aā‚‚ b₁ bā‚‚).trans <| add_le_add h₁ hā‚‚ @[to_additive] theorem dist_div_div_le (a₁ aā‚‚ b₁ bā‚‚ : E) : dist (a₁ / aā‚‚) (b₁ / bā‚‚) ≤ dist a₁ b₁ + dist aā‚‚ bā‚‚ := by simpa only [div_eq_mul_inv, dist_inv_inv] using dist_mul_mul_le a₁ a₂⁻¹ b₁ b₂⁻¹ @[to_additive] theorem dist_div_div_le_of_le (h₁ : dist a₁ b₁ ≤ r₁) (hā‚‚ : dist aā‚‚ bā‚‚ ≤ rā‚‚) : dist (a₁ / aā‚‚) (b₁ / bā‚‚) ≤ r₁ + rā‚‚ := (dist_div_div_le a₁ aā‚‚ b₁ bā‚‚).trans <| add_le_add h₁ hā‚‚ @[to_additive] theorem abs_dist_sub_le_dist_mul_mul (a₁ aā‚‚ b₁ bā‚‚ : E) : |dist a₁ b₁ - dist aā‚‚ bā‚‚| ≤ dist (a₁ * aā‚‚) (b₁ * bā‚‚) := by simpa only [dist_mul_left, dist_mul_right, dist_comm bā‚‚] using abs_dist_sub_le (a₁ * aā‚‚) (b₁ * bā‚‚) (b₁ * aā‚‚) open Finset @[to_additive] theorem nndist_mul_mul_le (a₁ aā‚‚ b₁ bā‚‚ : E) : nndist (a₁ * aā‚‚) (b₁ * bā‚‚) ≤ nndist a₁ b₁ + nndist aā‚‚ bā‚‚ := NNReal.coe_le_coe.1 <| dist_mul_mul_le a₁ aā‚‚ b₁ bā‚‚ @[to_additive] theorem edist_mul_mul_le (a₁ aā‚‚ b₁ bā‚‚ : E) : edist (a₁ * aā‚‚) (b₁ * bā‚‚) ≤ edist a₁ b₁ + edist aā‚‚ bā‚‚ := by simp only [edist_nndist] norm_cast apply nndist_mul_mul_le section PseudoEMetricSpace variable {α E : Type*} [SeminormedCommGroup E] [PseudoEMetricSpace α] {K Kf Kg : ā„ā‰„0} {f g : α → E} {s : Set α} @[to_additive (attr := simp)] lemma lipschitzWith_inv_iff : LipschitzWith K f⁻¹ ↔ LipschitzWith K f := by simp [LipschitzWith] @[to_additive (attr := simp)] lemma antilipschitzWith_inv_iff : AntilipschitzWith K f⁻¹ ↔ AntilipschitzWith K f := by simp [AntilipschitzWith] @[to_additive (attr := simp)] lemma lipschitzOnWith_inv_iff : LipschitzOnWith K f⁻¹ s ↔ LipschitzOnWith K f s := by simp [LipschitzOnWith] @[to_additive (attr := simp)] lemma locallyLipschitz_inv_iff : LocallyLipschitz f⁻¹ ↔ LocallyLipschitz f := by simp [LocallyLipschitz] @[to_additive (attr := simp)] lemma locallyLipschitzOn_inv_iff : LocallyLipschitzOn s f⁻¹ ↔ LocallyLipschitzOn s f := by simp [LocallyLipschitzOn] @[to_additive] alias ⟨LipschitzWith.of_inv, LipschitzWith.inv⟩ := lipschitzWith_inv_iff @[to_additive] alias ⟨AntilipschitzWith.of_inv, AntilipschitzWith.inv⟩ := antilipschitzWith_inv_iff @[to_additive] alias ⟨LipschitzOnWith.of_inv, LipschitzOnWith.inv⟩ := lipschitzOnWith_inv_iff @[to_additive] alias ⟨LocallyLipschitz.of_inv, LocallyLipschitz.inv⟩ := locallyLipschitz_inv_iff @[to_additive] alias ⟨LocallyLipschitzOn.of_inv, LocallyLipschitzOn.inv⟩ := locallyLipschitzOn_inv_iff @[to_additive] lemma LipschitzOnWith.mul (hf : LipschitzOnWith Kf f s) (hg : LipschitzOnWith Kg g s) : LipschitzOnWith (Kf + Kg) (fun x ↦ f x * g x) s := fun x hx y hy ↦ calc edist (f x * g x) (f y * g y) ≤ edist (f x) (f y) + edist (g x) (g y) := edist_mul_mul_le _ _ _ _ _ ≤ Kf * edist x y + Kg * edist x y := add_le_add (hf hx hy) (hg hx hy) _ = (Kf + Kg) * edist x y := (add_mul _ _ _).symm @[to_additive] lemma LipschitzWith.mul (hf : LipschitzWith Kf f) (hg : LipschitzWith Kg g) : LipschitzWith (Kf + Kg) fun x ↦ f x * g x := by simpa [← lipschitzOnWith_univ] using hf.lipschitzOnWith.mul hg.lipschitzOnWith @[to_additive] lemma LocallyLipschitzOn.mul (hf : LocallyLipschitzOn s f) (hg : LocallyLipschitzOn s g) : LocallyLipschitzOn s fun x ↦ f x * g x := fun x hx ↦ by obtain ⟨Kf, t, ht, hKf⟩ := hf hx obtain ⟨Kg, u, hu, hKg⟩ := hg hx exact ⟨Kf + Kg, t ∩ u, inter_mem ht hu, (hKf.mono Set.inter_subset_left).mul (hKg.mono Set.inter_subset_right)⟩ @[to_additive] lemma LocallyLipschitz.mul (hf : LocallyLipschitz f) (hg : LocallyLipschitz g) : LocallyLipschitz fun x ↦ f x * g x := by simpa [← locallyLipschitzOn_univ] using hf.locallyLipschitzOn.mul hg.locallyLipschitzOn @[to_additive] lemma LipschitzOnWith.div (hf : LipschitzOnWith Kf f s) (hg : LipschitzOnWith Kg g s) : LipschitzOnWith (Kf + Kg) (fun x ↦ f x / g x) s := by simpa only [div_eq_mul_inv] using hf.mul hg.inv @[to_additive] theorem LipschitzWith.div (hf : LipschitzWith Kf f) (hg : LipschitzWith Kg g) : LipschitzWith (Kf + Kg) fun x => f x / g x := by simpa only [div_eq_mul_inv] using hf.mul hg.inv @[to_additive] lemma LocallyLipschitzOn.div (hf : LocallyLipschitzOn s f) (hg : LocallyLipschitzOn s g) : LocallyLipschitzOn s fun x ↦ f x / g x := by simpa only [div_eq_mul_inv] using hf.mul hg.inv @[to_additive] lemma LocallyLipschitz.div (hf : LocallyLipschitz f) (hg : LocallyLipschitz g) : LocallyLipschitz fun x ↦ f x / g x := by simpa only [div_eq_mul_inv] using hf.mul hg.inv namespace AntilipschitzWith @[to_additive] theorem mul_lipschitzWith (hf : AntilipschitzWith Kf f) (hg : LipschitzWith Kg g) (hK : Kg < Kf⁻¹) : AntilipschitzWith (Kf⁻¹ - Kg)⁻¹ fun x => f x * g x := by letI : PseudoMetricSpace α := PseudoEMetricSpace.toPseudoMetricSpace hf.edist_ne_top refine AntilipschitzWith.of_le_mul_dist fun x y => ?_ rw [NNReal.coe_inv, ← _root_.div_eq_inv_mul] rw [le_div_iffā‚€ (NNReal.coe_pos.2 <| tsub_pos_iff_lt.2 hK)] rw [mul_comm, NNReal.coe_sub hK.le, sub_mul] calc ↑Kf⁻¹ * dist x y - Kg * dist x y ≤ dist (f x) (f y) - dist (g x) (g y) := sub_le_sub (hf.mul_le_dist x y) (hg.dist_le_mul x y) _ ≤ _ := le_trans (le_abs_self _) (abs_dist_sub_le_dist_mul_mul _ _ _ _) @[to_additive] theorem mul_div_lipschitzWith (hf : AntilipschitzWith Kf f) (hg : LipschitzWith Kg (g / f)) (hK : Kg < Kf⁻¹) : AntilipschitzWith (Kf⁻¹ - Kg)⁻¹ g := by simpa only [Pi.div_apply, mul_div_cancel] using hf.mul_lipschitzWith hg hK @[to_additive le_mul_norm_sub] theorem le_mul_norm_div {f : E → F} (hf : AntilipschitzWith K f) (x y : E) : ‖x / y‖ ≤ K * ‖f x / f y‖ := by simp [← dist_eq_norm_div, hf.le_mul_dist x y] end AntilipschitzWith end PseudoEMetricSpace -- See note [lower instance priority] @[to_additive] instance (priority := 100) SeminormedCommGroup.to_lipschitzMul : LipschitzMul E := ⟨⟨1 + 1, LipschitzWith.prod_fst.mul LipschitzWith.prod_snd⟩⟩ -- See note [lower instance priority] /-- A seminormed group is a uniform group, i.e., multiplication and division are uniformly continuous. -/ @[to_additive /-- A seminormed group is a uniform additive group, i.e., addition and subtraction are uniformly continuous. -/] instance (priority := 100) SeminormedCommGroup.to_isUniformGroup : IsUniformGroup E := ⟨(LipschitzWith.prod_fst.div LipschitzWith.prod_snd).uniformContinuous⟩ -- short-circuit type class inference -- See note [lower instance priority] @[to_additive] instance (priority := 100) SeminormedCommGroup.toIsTopologicalGroup : IsTopologicalGroup E := inferInstance /-! ### SeparationQuotient -/ namespace SeparationQuotient @[to_additive instNorm] instance instMulNorm : Norm (SeparationQuotient E) where norm := lift Norm.norm fun _ _ h => h.norm_eq_norm' set_option linter.docPrime false in @[to_additive (attr := simp) norm_mk] theorem norm_mk' (p : E) : ‖mk p‖ = ‖p‖ := rfl @[to_additive] instance : NormedCommGroup (SeparationQuotient E) where __ : CommGroup (SeparationQuotient E) := instCommGroup dist_eq := Quotient.indā‚‚ dist_eq_norm_div @[to_additive] theorem mk_eq_one_iff {p : E} : mk p = 1 ↔ ‖p‖ = 0 := by rw [← norm_mk', norm_eq_zero'] set_option linter.docPrime false in @[to_additive (attr := simp) nnnorm_mk] theorem nnnorm_mk' (p : E) : ‖mk pā€–ā‚Š = ‖pā€–ā‚Š := rfl end SeparationQuotient @[to_additive] theorem cauchySeq_prod_of_eventually_eq {u v : ā„• → E} {N : ā„•} (huv : āˆ€ n ≄ N, u n = v n) (hv : CauchySeq fun n => āˆ k ∈ range (n + 1), v k) : CauchySeq fun n => āˆ k ∈ range (n + 1), u k := by let d : ā„• → E := fun n => āˆ k ∈ range (n + 1), u k / v k rw [show (fun n => āˆ k ∈ range (n + 1), u k) = d * fun n => āˆ k ∈ range (n + 1), v k by ext n; simp [d]] suffices āˆ€ n ≄ N, d n = d N from (tendsto_atTop_of_eventually_const this).cauchySeq.mul hv intro n hn dsimp [d] rw [eventually_constant_prod (N := N + 1) _ (by gcongr)] intro m hm simp [huv m (le_of_lt hm)] @[to_additive CauchySeq.norm_bddAbove] lemma CauchySeq.mul_norm_bddAbove {G : Type*} [SeminormedGroup G] {u : ā„• → G} (hu : CauchySeq u) : BddAbove (Set.range (fun n ↦ ‖u n‖)) := by obtain ⟨C, -, hC⟩ := cauchySeq_bdd hu simp_rw [SeminormedGroup.dist_eq] at hC have : āˆ€ n, ‖u n‖ ≤ C + ‖u 0‖ := by intro n rw [add_comm] refine (norm_le_norm_add_norm_div' (u n) (u 0)).trans ?_ simp [(hC _ _).le] rw [bddAbove_def] exact ⟨C + ‖u 0‖, by simpa using this⟩ end SeminormedCommGroup
.lake/packages/mathlib/Mathlib/Analysis/Normed/Group/Indicator.lean
import Mathlib.Algebra.Order.Group.Indicator import Mathlib.Algebra.Order.Pi import Mathlib.Analysis.Normed.Group.Basic /-! # Indicator function and (e)norm This file contains a few simple lemmas about `Set.indicator`, `norm` and `enorm`. ## Tags indicator, norm -/ open Set section ESeminormedAddMonoid variable {α ε : Type*} [TopologicalSpace ε] [ESeminormedAddMonoid ε] {s t : Set α} (f : α → ε) (a : α) lemma enorm_indicator_eq_indicator_enorm : ‖indicator s f a‖ₑ = indicator s (fun a => ‖f a‖ₑ) a := flip congr_fun a (indicator_comp_of_zero (enorm_zero (E := ε))).symm theorem enorm_indicator_le_of_subset (h : s āŠ† t) (f : α → ε) (a : α) : ‖indicator s f a‖ₑ ≤ ‖indicator t f a‖ₑ := by simp only [enorm_indicator_eq_indicator_enorm] apply indicator_le_indicator_of_subset ‹_› (zero_le _) theorem indicator_enorm_le_enorm_self : indicator s (fun a => ‖f a‖ₑ) a ≤ ‖f a‖ₑ := indicator_le_self' (fun _ _ ↦ zero_le _) a theorem enorm_indicator_le_enorm_self : ‖indicator s f a‖ₑ ≤ ‖f a‖ₑ := by rw [enorm_indicator_eq_indicator_enorm] apply indicator_enorm_le_enorm_self end ESeminormedAddMonoid section SeminormedAddGroup variable {α E : Type*} [SeminormedAddGroup E] {s t : Set α} (f : α → E) (a : α) theorem norm_indicator_eq_indicator_norm : ‖indicator s f a‖ = indicator s (fun a => ‖f a‖) a := flip congr_fun a (indicator_comp_of_zero norm_zero).symm theorem nnnorm_indicator_eq_indicator_nnnorm : ‖indicator s f aā€–ā‚Š = indicator s (fun a => ‖f aā€–ā‚Š) a := flip congr_fun a (indicator_comp_of_zero nnnorm_zero).symm theorem norm_indicator_le_of_subset (h : s āŠ† t) (f : α → E) (a : α) : ‖indicator s f a‖ ≤ ‖indicator t f a‖ := by simp only [norm_indicator_eq_indicator_norm] exact indicator_le_indicator_of_subset ‹_› (fun _ => norm_nonneg _) _ theorem indicator_norm_le_norm_self : indicator s (fun a => ‖f a‖) a ≤ ‖f a‖ := indicator_le_self' (fun _ _ => norm_nonneg _) a theorem norm_indicator_le_norm_self : ‖indicator s f a‖ ≤ ‖f a‖ := by rw [norm_indicator_eq_indicator_norm] apply indicator_norm_le_norm_self end SeminormedAddGroup
.lake/packages/mathlib/Mathlib/Analysis/Normed/Group/Lemmas.lean
import Mathlib.Analysis.Normed.Group.Uniform /-! # Further lemmas about normed groups This file contains further lemmas about normed groups, requiring heavier imports than `Mathlib/Analysis/Normed/Group/Basic.lean`. ## TODO - Move lemmas from `Basic` to other places, including this file. -/ variable {E : Type*} [SeminormedAddCommGroup E] open NNReal Topology theorem eventually_nnnorm_sub_lt (xā‚€ : E) {ε : ā„ā‰„0} (ε_pos : 0 < ε) : āˆ€į¶  x in š“ xā‚€, ‖x - xā‚€ā€–ā‚Š < ε := (continuousAt_id.sub continuousAt_const).nnnorm (gt_mem_nhds <| by simpa) theorem eventually_norm_sub_lt (xā‚€ : E) {ε : ā„} (ε_pos : 0 < ε) : āˆ€į¶  x in š“ xā‚€, ‖x - x₀‖ < ε := (continuousAt_id.sub continuousAt_const).norm (gt_mem_nhds <| by simpa)
.lake/packages/mathlib/Mathlib/Analysis/Normed/Group/InfiniteSum.lean
import Mathlib.Algebra.BigOperators.Intervals import Mathlib.Analysis.Normed.Group.Uniform import Mathlib.Topology.Instances.NNReal.Lemmas import Mathlib.Topology.Instances.ENNReal.Lemmas /-! # Infinite sums in (semi)normed groups In a complete (semi)normed group, - `summable_iff_vanishing_norm`: a series `āˆ‘' i, f i` is summable if and only if for any `ε > 0`, there exists a finite set `s` such that the sum `āˆ‘ i ∈ t, f i` over any finite set `t` disjoint with `s` has norm less than `ε`; - `Summable.of_norm_bounded`, `Summable.of_norm_bounded_eventually`: if `‖f i‖` is bounded above by a summable series `āˆ‘' i, g i`, then `āˆ‘' i, f i` is summable as well; the same is true if the inequality hold only off some finite set. - `tsum_of_norm_bounded`, `HasSum.norm_le_of_bounded`: if `‖f i‖ ≤ g i`, where `āˆ‘' i, g i` is a summable series, then `ā€–āˆ‘' i, f i‖ ≤ āˆ‘' i, g i`. - versions of these lemmas for `nnnorm` and `enorm`. ## Tags infinite series, absolute convergence, normed group -/ open Topology ENNReal NNReal open Finset Filter Metric variable {ι α E F ε : Type*} [SeminormedAddCommGroup E] [SeminormedAddCommGroup F] [TopologicalSpace ε] [ESeminormedAddCommMonoid ε] theorem cauchySeq_finset_iff_vanishing_norm {f : ι → E} : (CauchySeq fun s : Finset ι => āˆ‘ i ∈ s, f i) ↔ āˆ€ ε > (0 : ā„), ∃ s : Finset ι, āˆ€ t, Disjoint t s → ā€–āˆ‘ i ∈ t, f i‖ < ε := by rw [cauchySeq_finset_iff_sum_vanishing, nhds_basis_ball.forall_iff] Ā· simp only [ball_zero_eq, Set.mem_setOf_eq] Ā· rintro s t hst ⟨s', hs'⟩ exact ⟨s', fun t' ht' => hst <| hs' _ ht'⟩ theorem summable_iff_vanishing_norm [CompleteSpace E] {f : ι → E} : Summable f ↔ āˆ€ ε > (0 : ā„), ∃ s : Finset ι, āˆ€ t, Disjoint t s → ā€–āˆ‘ i ∈ t, f i‖ < ε := by rw [summable_iff_cauchySeq_finset, cauchySeq_finset_iff_vanishing_norm] theorem cauchySeq_finset_of_norm_bounded_eventually {f : ι → E} {g : ι → ā„} (hg : Summable g) (h : āˆ€į¶  i in cofinite, ‖f i‖ ≤ g i) : CauchySeq fun s => āˆ‘ i ∈ s, f i := by refine cauchySeq_finset_iff_vanishing_norm.2 fun ε hε => ?_ rcases summable_iff_vanishing_norm.1 hg ε hε with ⟨s, hs⟩ classical refine ⟨s ∪ h.toFinset, fun t ht => ?_⟩ have : āˆ€ i ∈ t, ‖f i‖ ≤ g i := by intro i hi simp only [disjoint_left, mem_union, not_or, h.mem_toFinset, Set.mem_compl_iff, Classical.not_not] at ht exact (ht hi).2 calc ā€–āˆ‘ i ∈ t, f i‖ ≤ āˆ‘ i ∈ t, g i := norm_sum_le_of_le _ this _ ≤ ā€–āˆ‘ i ∈ t, g i‖ := le_abs_self _ _ < ε := hs _ (ht.mono_right le_sup_left) theorem cauchySeq_finset_of_norm_bounded {f : ι → E} {g : ι → ā„} (hg : Summable g) (h : āˆ€ i, ‖f i‖ ≤ g i) : CauchySeq fun s : Finset ι => āˆ‘ i ∈ s, f i := cauchySeq_finset_of_norm_bounded_eventually hg <| Eventually.of_forall h /-- A version of the **direct comparison test** for conditionally convergent series. See `cauchySeq_finset_of_norm_bounded` for the same statement about absolutely convergent ones. -/ theorem cauchySeq_range_of_norm_bounded {f : ā„• → E} {g : ā„• → ā„} (hg : CauchySeq fun n => āˆ‘ i ∈ range n, g i) (hf : āˆ€ i, ‖f i‖ ≤ g i) : CauchySeq fun n => āˆ‘ i ∈ range n, f i := by refine Metric.cauchySeq_iff'.2 fun ε hε => ?_ refine (Metric.cauchySeq_iff'.1 hg ε hε).imp fun N hg n hn => ?_ specialize hg n hn rw [dist_eq_norm, ← sum_Ico_eq_sub _ hn] at hg ⊢ calc ā€–āˆ‘ k ∈ Ico N n, f k‖ ≤ āˆ‘ k ∈ _, ‖f k‖ := norm_sum_le _ _ _ ≤ āˆ‘ k ∈ _, g k := sum_le_sum fun x _ => hf x _ ≤ ā€–āˆ‘ k ∈ _, g k‖ := le_abs_self _ _ < ε := hg theorem cauchySeq_finset_of_summable_norm {f : ι → E} (hf : Summable fun a => ‖f a‖) : CauchySeq fun s : Finset ι => āˆ‘ a ∈ s, f a := cauchySeq_finset_of_norm_bounded hf fun _i => le_rfl /-- If a function `f` is summable in norm, and along some sequence of finsets exhausting the space its sum is converging to a limit `a`, then this holds along all finsets, i.e., `f` is summable with sum `a`. -/ theorem hasSum_of_subseq_of_summable {f : ι → E} (hf : Summable fun a => ‖f a‖) {s : α → Finset ι} {p : Filter α} [NeBot p] (hs : Tendsto s p atTop) {a : E} (ha : Tendsto (fun b => āˆ‘ i ∈ s b, f i) p (š“ a)) : HasSum f a := tendsto_nhds_of_cauchySeq_of_subseq (cauchySeq_finset_of_summable_norm hf) hs ha theorem hasSum_iff_tendsto_nat_of_summable_norm {f : ā„• → E} {a : E} (hf : Summable fun i => ‖f i‖) : HasSum f a ↔ Tendsto (fun n : ā„• => āˆ‘ i ∈ range n, f i) atTop (š“ a) := ⟨fun h => h.tendsto_sum_nat, fun h => hasSum_of_subseq_of_summable hf tendsto_finset_range h⟩ /-- The direct comparison test for series: if the norm of `f` is bounded by a real function `g` which is summable, then `f` is summable. -/ theorem Summable.of_norm_bounded [CompleteSpace E] {f : ι → E} {g : ι → ā„} (hg : Summable g) (h : āˆ€ i, ‖f i‖ ≤ g i) : Summable f := by rw [summable_iff_cauchySeq_finset] exact cauchySeq_finset_of_norm_bounded hg h theorem HasSum.enorm_le_of_bounded {f : ι → ε} {g : ι → ā„ā‰„0āˆž} {a : ε} {b : ā„ā‰„0āˆž} (hf : HasSum f a) (hg : HasSum g b) (h : āˆ€ i, ‖f i‖ₑ ≤ g i) : ‖a‖ₑ ≤ b := by exact le_of_tendsto_of_tendsto' hf.enorm hg fun _s ↦ enorm_sum_le_of_le _ fun i _hi ↦ h i theorem HasSum.norm_le_of_bounded {f : ι → E} {g : ι → ā„} {a : E} {b : ā„} (hf : HasSum f a) (hg : HasSum g b) (h : āˆ€ i, ‖f i‖ ≤ g i) : ‖a‖ ≤ b := by exact le_of_tendsto_of_tendsto' hf.norm hg fun _s ↦ norm_sum_le_of_le _ fun i _hi ↦ h i /-- Quantitative result associated to the direct comparison test for series: If, for all `i`, `‖f i‖ₑ ≤ g i`, then `ā€–āˆ‘' i, f i‖ₑ ≤ āˆ‘' i, g i`. Note that we do not assume that `āˆ‘' i, f i` is summable, and it might not be the case if `α` is not a complete space. -/ theorem tsum_of_enorm_bounded {f : ι → ε} {g : ι → ā„ā‰„0āˆž} {a : ā„ā‰„0āˆž} (hg : HasSum g a) (h : āˆ€ i, ‖f i‖ₑ ≤ g i) : ā€–āˆ‘' i : ι, f i‖ₑ ≤ a := by by_cases hf : Summable f Ā· exact hf.hasSum.enorm_le_of_bounded hg h Ā· simp [tsum_eq_zero_of_not_summable hf] theorem enorm_tsum_le_tsum_enorm {f : ι → ε} : ā€–āˆ‘' i, f i‖ₑ ≤ āˆ‘' i, ‖f i‖ₑ := tsum_of_enorm_bounded ENNReal.summable.hasSum fun _i => le_rfl /-- Quantitative result associated to the direct comparison test for series: If `āˆ‘' i, g i` is summable, and for all `i`, `‖f i‖ ≤ g i`, then `ā€–āˆ‘' i, f i‖ ≤ āˆ‘' i, g i`. Note that we do not assume that `āˆ‘' i, f i` is summable, and it might not be the case if `α` is not a complete space. -/ theorem tsum_of_norm_bounded {f : ι → E} {g : ι → ā„} {a : ā„} (hg : HasSum g a) (h : āˆ€ i, ‖f i‖ ≤ g i) : ā€–āˆ‘' i : ι, f i‖ ≤ a := by by_cases hf : Summable f Ā· exact hf.hasSum.norm_le_of_bounded hg h Ā· rw [tsum_eq_zero_of_not_summable hf, norm_zero] classical exact ge_of_tendsto' hg fun s => sum_nonneg fun i _hi => (norm_nonneg _).trans (h i) /-- If `āˆ‘' i, ‖f i‖` is summable, then `ā€–āˆ‘' i, f i‖ ≤ (āˆ‘' i, ‖f i‖)`. Note that we do not assume that `āˆ‘' i, f i` is summable, and it might not be the case if `α` is not a complete space. -/ theorem norm_tsum_le_tsum_norm {f : ι → E} (hf : Summable fun i => ‖f i‖) : ā€–āˆ‘' i, f i‖ ≤ āˆ‘' i, ‖f i‖ := tsum_of_norm_bounded hf.hasSum fun _i => le_rfl /-- Quantitative result associated to the direct comparison test for series: If `āˆ‘' i, g i` is summable, and for all `i`, `‖f iā€–ā‚Š ≤ g i`, then `ā€–āˆ‘' i, f iā€–ā‚Š ≤ āˆ‘' i, g i`. Note that we do not assume that `āˆ‘' i, f i` is summable, and it might not be the case if `α` is not a complete space. -/ theorem tsum_of_nnnorm_bounded {f : ι → E} {g : ι → ā„ā‰„0} {a : ā„ā‰„0} (hg : HasSum g a) (h : āˆ€ i, ‖f iā€–ā‚Š ≤ g i) : ā€–āˆ‘' i : ι, f iā€–ā‚Š ≤ a := by simp only [← NNReal.coe_le_coe, ← NNReal.hasSum_coe, coe_nnnorm] at * exact tsum_of_norm_bounded hg h /-- If `āˆ‘' i, ‖f iā€–ā‚Š` is summable, then `ā€–āˆ‘' i, f iā€–ā‚Š ≤ āˆ‘' i, ‖f iā€–ā‚Š`. Note that we do not assume that `āˆ‘' i, f i` is summable, and it might not be the case if `α` is not a complete space. -/ theorem nnnorm_tsum_le {f : ι → E} (hf : Summable fun i => ‖f iā€–ā‚Š) : ā€–āˆ‘' i, f iā€–ā‚Š ≤ āˆ‘' i, ‖f iā€–ā‚Š := tsum_of_nnnorm_bounded hf.hasSum fun _i => le_rfl variable [CompleteSpace E] /-- Variant of the direct comparison test for series: if the norm of `f` is eventually bounded by a real function `g` which is summable, then `f` is summable. -/ theorem Summable.of_norm_bounded_eventually {f : ι → E} {g : ι → ā„} (hg : Summable g) (h : āˆ€į¶  i in cofinite, ‖f i‖ ≤ g i) : Summable f := summable_iff_cauchySeq_finset.2 <| cauchySeq_finset_of_norm_bounded_eventually hg h /-- Variant of the direct comparison test for series: if the norm of `f` is eventually bounded by a real function `g` which is summable, then `f` is summable. -/ theorem Summable.of_norm_bounded_eventually_nat {f : ā„• → E} {g : ā„• → ā„} (hg : Summable g) (h : āˆ€į¶  i in atTop, ‖f i‖ ≤ g i) : Summable f := .of_norm_bounded_eventually hg <| Nat.cofinite_eq_atTop ā–ø h theorem Summable.of_nnnorm_bounded {f : ι → E} {g : ι → ā„ā‰„0} (hg : Summable g) (h : āˆ€ i, ‖f iā€–ā‚Š ≤ g i) : Summable f := .of_norm_bounded (NNReal.summable_coe.2 hg) h theorem Summable.of_norm {f : ι → E} (hf : Summable fun a => ‖f a‖) : Summable f := .of_norm_bounded hf fun _i => le_rfl theorem Summable.of_nnnorm {f : ι → E} (hf : Summable fun a => ‖f aā€–ā‚Š) : Summable f := .of_nnnorm_bounded hf fun _i => le_rfl
.lake/packages/mathlib/Mathlib/Analysis/Normed/Group/AddCircle.lean
import Mathlib.Analysis.Normed.Group.Quotient import Mathlib.Analysis.Normed.Module.Ball.Pointwise import Mathlib.Topology.Instances.AddCircle.Real /-! # The additive circle as a normed group We define the normed group structure on `AddCircle p`, for `p : ā„`. For example if `p = 1` then: `‖(x : AddCircle 1)‖ = |x - round x|` for any `x : ā„` (see `UnitAddCircle.norm_eq`). ## Main definitions: * `AddCircle.norm_eq`: a characterisation of the norm on `AddCircle p` ## TODO * The fact `InnerProductGeometry.angle (Real.cos Īø) (Real.sin Īø) = ‖(Īø : Real.Angle)‖` -/ noncomputable section open Metric QuotientAddGroup Set open Int hiding mem_zmultiples_iff open AddSubgroup namespace AddCircle variable (p : ā„) instance : NormedAddCommGroup (AddCircle p) := QuotientAddGroup.instNormedAddCommGroup _ @[simp] theorem norm_coe_mul (x : ā„) (t : ā„) : ‖(↑(t * x) : AddCircle (t * p))‖ = |t| * ‖(x : AddCircle p)‖ := by obtain rfl | ht := eq_or_ne t 0 Ā· simp simp only [norm_eq_infDist, ← Real.norm_eq_abs, ← infDist_smulā‚€ ht, smul_zero] congr 1 with m simp_rw [zmultiples, eq_iff_sub_mem, zsmul_eq_mul, mul_left_comm, ← smul_eq_mul, Set.range_smul] simp [mem_smul_set_iff_inv_smul_memā‚€ ht, mul_sub, ht] theorem norm_neg_period (x : ā„) : ‖(x : AddCircle (-p))‖ = ‖(x : AddCircle p)‖ := by suffices ‖(↑(-1 * x) : AddCircle (-1 * p))‖ = ‖(x : AddCircle p)‖ by rw [← this, neg_one_mul] simp simp only [norm_coe_mul, abs_neg, abs_one, one_mul] @[simp] theorem norm_eq_of_zero {x : ā„} : ‖(x : AddCircle (0 : ā„))‖ = |x| := by suffices { y : ā„ | (y : AddCircle (0 : ā„)) = (x : AddCircle (0 : ā„)) } = {x} by simp [norm_eq_infDist, this] ext y simp [eq_iff_sub_mem, sub_eq_zero] theorem norm_eq {x : ā„} : ‖(x : AddCircle p)‖ = |x - round (p⁻¹ * x) * p| := by suffices āˆ€ x : ā„, ‖(x : AddCircle (1 : ā„))‖ = |x - round x| by rcases eq_or_ne p 0 with (rfl | hp) Ā· simp have hx := norm_coe_mul p x p⁻¹ rw [abs_inv, eq_inv_mul_iff_mul_eqā‚€ ((not_congr abs_eq_zero).mpr hp)] at hx rw [← hx, inv_mul_cancelā‚€ hp, this, ← abs_mul, mul_sub, mul_inv_cancel_leftā‚€ hp, mul_comm p] clear! x p intro x simp only [le_antisymm_iff, le_norm_iff, Real.norm_eq_abs] refine ⟨le_of_forall_le fun r hr ↦ ?_, ?_⟩ Ā· rw [abs_sub_round_eq_min, le_inf_iff] rw [le_norm_iff] at hr constructor Ā· simpa [abs_of_nonneg] using hr (fract x) Ā· simpa [abs_sub_comm (fract x)] using hr (fract x - 1) (by simp) Ā· simpa [zmultiples, QuotientAddGroup.eq, zsmul_eq_mul, mul_one, mem_mk, mem_range, and_imp, forall_exists_index, eq_neg_add_iff_add_eq, ← eq_sub_iff_add_eq, forall_swap (α := ā„•)] using round_le _ theorem norm_eq' (hp : 0 < p) {x : ā„} : ‖(x : AddCircle p)‖ = p * |p⁻¹ * x - round (p⁻¹ * x)| := by conv_rhs => congr rw [← abs_eq_self.mpr hp.le] rw [← abs_mul, mul_sub, mul_inv_cancel_leftā‚€ hp.ne.symm, norm_eq, mul_comm p] theorem norm_le_half_period {x : AddCircle p} (hp : p ≠ 0) : ‖x‖ ≤ |p| / 2 := by obtain ⟨x⟩ := x change ‖(x : AddCircle p)‖ ≤ |p| / 2 rw [norm_eq, ← mul_le_mul_iff_rightā‚€ (abs_pos.mpr (inv_ne_zero hp)), ← abs_mul, mul_sub, mul_left_comm, ← mul_div_assoc, ← abs_mul, inv_mul_cancelā‚€ hp, mul_one, abs_one] exact abs_sub_round (p⁻¹ * x) @[simp] theorem norm_half_period_eq : ‖(↑(p / 2) : AddCircle p)‖ = |p| / 2 := by rcases eq_or_ne p 0 with (rfl | hp); Ā· simp rw [norm_eq, ← mul_div_assoc, inv_mul_cancelā‚€ hp, one_div, round_two_inv, Int.cast_one, one_mul, (by linarith : p / 2 - p = -(p / 2)), abs_neg, abs_div, abs_two] theorem norm_coe_eq_abs_iff {x : ā„} (hp : p ≠ 0) : ‖(x : AddCircle p)‖ = |x| ↔ |x| ≤ |p| / 2 := by refine ⟨fun hx => hx ā–ø norm_le_half_period p hp, fun hx => ?_⟩ suffices āˆ€ p : ā„, 0 < p → |x| ≤ p / 2 → ‖(x : AddCircle p)‖ = |x| by rcases hp.symm.lt_or_gt with (hp | hp) Ā· rw [abs_eq_self.mpr hp.le] at hx exact this p hp hx Ā· rw [← norm_neg_period] rw [abs_eq_neg_self.mpr hp.le] at hx exact this (-p) (neg_pos.mpr hp) hx clear hx intro p hp hx rcases eq_or_ne x (p / (2 : ā„)) with (rfl | hx') Ā· simp [abs_div] suffices round (p⁻¹ * x) = 0 by simp [norm_eq, this] rw [round_eq_zero_iff] obtain ⟨hx₁, hxā‚‚āŸ© := abs_le.mp hx replace hxā‚‚ := Ne.lt_of_le hx' hxā‚‚ constructor Ā· rwa [le_inv_mul_iffā‚€ hp, mul_neg, ← mul_div_assoc, mul_one] Ā· rwa [inv_mul_lt_iffā‚€ hp, ← mul_div_assoc, mul_one] open Metric theorem closedBall_eq_univ_of_half_period_le (hp : p ≠ 0) (x : AddCircle p) {ε : ā„} (hε : |p| / 2 ≤ ε) : closedBall x ε = univ := eq_univ_iff_forall.mpr fun x => by simpa only [mem_closedBall, dist_eq_norm] using (norm_le_half_period p hp).trans hε @[simp] theorem coe_real_preimage_closedBall_period_zero (x ε : ā„) : (↑) ⁻¹' closedBall (x : AddCircle (0 : ā„)) ε = closedBall x ε := by ext y simp [dist_eq_norm, ← QuotientAddGroup.mk_sub] theorem coe_real_preimage_closedBall_eq_iUnion (x ε : ā„) : (↑) ⁻¹' closedBall (x : AddCircle p) ε = ā‹ƒ z : ℤ, closedBall (x + z • p) ε := by rcases eq_or_ne p 0 with (rfl | hp) Ā· simp [iUnion_const] ext y simp only [dist_eq_norm, mem_preimage, mem_closedBall, zsmul_eq_mul, mem_iUnion, Real.norm_eq_abs, ← QuotientAddGroup.mk_sub, norm_eq, ← sub_sub] refine ⟨fun h => ⟨round (p⁻¹ * (y - x)), h⟩, ?_⟩ rintro ⟨n, hn⟩ rw [← mul_le_mul_iff_rightā‚€ (abs_pos.mpr <| inv_ne_zero hp), ← abs_mul, mul_sub, mul_comm _ p, inv_mul_cancel_leftā‚€ hp] at hn ⊢ exact (round_le (p⁻¹ * (y - x)) n).trans hn theorem coe_real_preimage_closedBall_inter_eq {x ε : ā„} (s : Set ā„) (hs : s āŠ† closedBall x (|p| / 2)) : (↑) ⁻¹' closedBall (x : AddCircle p) ε ∩ s = if ε < |p| / 2 then closedBall x ε ∩ s else s := by rcases le_or_gt (|p| / 2) ε with hε | hε Ā· rcases eq_or_ne p 0 with (rfl | hp) Ā· simp only [abs_zero, zero_div] at hε simp only [not_lt.mpr hε, coe_real_preimage_closedBall_period_zero, abs_zero, zero_div, if_false, inter_eq_right] exact hs.trans (closedBall_subset_closedBall <| by simp [hε]) simp [closedBall_eq_univ_of_half_period_le p hp (↑x) hε, not_lt.mpr hε] Ā· suffices āˆ€ z : ℤ, closedBall (x + z • p) ε ∩ s = if z = 0 then closedBall x ε ∩ s else āˆ… by simp [-zsmul_eq_mul, coe_real_preimage_closedBall_eq_iUnion, iUnion_inter, iUnion_ite, this, hε] intro z simp only [Real.closedBall_eq_Icc] at hs ⊢ rcases eq_or_ne z 0 with (rfl | hz) Ā· simp simp only [hz, zsmul_eq_mul, if_false, eq_empty_iff_forall_notMem] rintro y ⟨⟨hy₁, hyā‚‚āŸ©, hyā‚€āŸ© obtain ⟨hyā‚ƒ, hyā‚„āŸ© := hs hyā‚€ rcases lt_trichotomy 0 p with (hp | (rfl : 0 = p) | hp) Ā· rcases Int.cast_le_neg_one_or_one_le_cast_of_ne_zero ā„ hz with hz' | hz' Ā· have : ↑z * p ≤ -p := by nlinarith linarith [abs_eq_self.mpr hp.le] Ā· have : p ≤ ↑z * p := by nlinarith linarith [abs_eq_self.mpr hp.le] Ā· simp only [mul_zero, add_zero, abs_zero, zero_div] at hy₁ hyā‚‚ hε linarith Ā· rcases Int.cast_le_neg_one_or_one_le_cast_of_ne_zero ā„ hz with hz' | hz' Ā· have : -p ≤ ↑z * p := by nlinarith linarith [abs_eq_neg_self.mpr hp.le] Ā· have : ↑z * p ≤ p := by nlinarith linarith [abs_eq_neg_self.mpr hp.le] section FiniteOrderPoints variable {p} [hp : Fact (0 < p)] theorem norm_div_natCast {m n : ā„•} : ‖(↑(↑m / ↑n * p) : AddCircle p)‖ = p * (↑(min (m % n) (n - m % n)) / n) := by have : p⁻¹ * (↑m / ↑n * p) = ↑m / ↑n := by rw [mul_comm _ p, inv_mul_cancel_leftā‚€ hp.out.ne.symm] rw [norm_eq' p hp.out, this, abs_sub_round_div_natCast_eq] theorem exists_norm_eq_of_isOfFinAddOrder {u : AddCircle p} (hu : IsOfFinAddOrder u) : ∃ k : ā„•, ‖u‖ = p * (k / addOrderOf u) := by let n := addOrderOf u change ∃ k : ā„•, ‖u‖ = p * (k / n) obtain ⟨m, -, -, hm⟩ := exists_gcd_eq_one_of_isOfFinAddOrder hu refine ⟨min (m % n) (n - m % n), ?_⟩ rw [← hm, norm_div_natCast] theorem le_add_order_smul_norm_of_isOfFinAddOrder {u : AddCircle p} (hu : IsOfFinAddOrder u) (hu' : u ≠ 0) : p ≤ addOrderOf u • ‖u‖ := by obtain ⟨n, hn⟩ := exists_norm_eq_of_isOfFinAddOrder hu replace hu : (addOrderOf u : ā„) ≠ 0 := by norm_cast exact (addOrderOf_pos_iff.mpr hu).ne' conv_lhs => rw [← mul_one p] rw [hn, nsmul_eq_mul, ← mul_assoc, mul_comm _ p, mul_assoc, mul_div_cancelā‚€ _ hu, mul_le_mul_iff_rightā‚€ hp.out, Nat.one_le_cast, Nat.one_le_iff_ne_zero] contrapose! hu' simpa only [hu', Nat.cast_zero, zero_div, mul_zero, norm_eq_zero] using hn end FiniteOrderPoints end AddCircle namespace UnitAddCircle theorem norm_eq {x : ā„} : ‖(x : UnitAddCircle)‖ = |x - round x| := by simp [AddCircle.norm_eq] end UnitAddCircle
.lake/packages/mathlib/Mathlib/Analysis/Normed/Group/Rat.lean
import Mathlib.Analysis.Normed.Group.Int import Mathlib.Topology.Instances.Rat /-! # ā„š as a normed group -/ namespace Rat instance instNormedAddCommGroup : NormedAddCommGroup ā„š where norm r := ‖(r : ā„)‖ dist_eq r₁ rā‚‚ := by simp only [Rat.dist_eq, norm, Rat.cast_sub] @[norm_cast, simp high] -- increase priority to prevent the left-hand side from simplifying theorem norm_cast_real (r : ā„š) : ‖(r : ā„)‖ = ‖r‖ := rfl @[norm_cast, simp] theorem _root_.Int.norm_cast_rat (m : ℤ) : ‖(m : ā„š)‖ = ‖m‖ := by rw [← Rat.norm_cast_real, ← Int.norm_cast_real]; congr 1 end Rat
.lake/packages/mathlib/Mathlib/Analysis/Normed/Group/Ultra.lean
import Mathlib.Analysis.Normed.Group.Uniform import Mathlib.Topology.Algebra.Nonarchimedean.Basic import Mathlib.Topology.MetricSpace.Ultra.Basic import Mathlib.Topology.Algebra.InfiniteSum.Group import Mathlib.Topology.Order.LiminfLimsup /-! # Ultrametric norms This file contains results on the behavior of norms in ultrametric groups. ## Main results * `IsUltrametricDist.isUltrametricDist_of_isNonarchimedean_norm`: a normed additive group has an ultrametric iff the norm is nonarchimedean * `IsUltrametricDist.nonarchimedeanGroup` and its additive version: instance showing that a commutative group with a nonarchimedean seminorm is a nonarchimedean topological group (i.e. there is a neighbourhood basis of the identity consisting of open subgroups). ## Implementation details Some results are proved first about `nnnorm : X → ā„ā‰„0` because the bottom element in `NNReal` is 0, so easier to make statements about maxima of empty sets. ## Tags ultrametric, nonarchimedean -/ open Metric NNReal namespace IsUltrametricDist section Group variable {S S' ι : Type*} [SeminormedGroup S] [SeminormedGroup S'] [IsUltrametricDist S] @[to_additive] lemma norm_mul_le_max (x y : S) : ‖x * y‖ ≤ max ‖x‖ ‖y‖ := by simpa only [le_max_iff, dist_eq_norm_div, div_inv_eq_mul, div_one, one_mul] using dist_triangle_max x 1 y⁻¹ @[to_additive] lemma isUltrametricDist_of_forall_norm_mul_le_max_norm (h : āˆ€ x y : S', ‖x * y‖ ≤ max ‖x‖ ‖y‖) : IsUltrametricDist S' where dist_triangle_max x y z := by simpa only [dist_eq_norm_div, le_max_iff, div_mul_div_cancel] using h (x / y) (y / z) lemma isUltrametricDist_of_isNonarchimedean_norm {S' : Type*} [SeminormedAddGroup S'] (h : IsNonarchimedean (norm : S' → ā„)) : IsUltrametricDist S' := isUltrametricDist_of_forall_norm_add_le_max_norm h lemma isNonarchimedean_norm {R} [SeminormedAddCommGroup R] [IsUltrametricDist R] : IsNonarchimedean (‖·‖ : R → ā„) := by intro x y convert dist_triangle_max 0 x (x + y) using 1 Ā· simp Ā· congr <;> simp [SeminormedAddGroup.dist_eq] lemma isUltrametricDist_iff_isNonarchimedean_norm {R} [SeminormedAddCommGroup R] : IsUltrametricDist R ↔ IsNonarchimedean (‖·‖ : R → ā„) := ⟨fun h => h.isNonarchimedean_norm, IsUltrametricDist.isUltrametricDist_of_isNonarchimedean_norm⟩ @[to_additive] lemma nnnorm_mul_le_max (x y : S) : ‖x * yā€–ā‚Š ≤ max ‖xā€–ā‚Š ‖yā€–ā‚Š := norm_mul_le_max _ _ @[to_additive] lemma isUltrametricDist_of_forall_nnnorm_mul_le_max_nnnorm (h : āˆ€ x y : S', ‖x * yā€–ā‚Š ≤ max ‖xā€–ā‚Š ‖yā€–ā‚Š) : IsUltrametricDist S' := isUltrametricDist_of_forall_norm_mul_le_max_norm h lemma isUltrametricDist_of_isNonarchimedean_nnnorm {S' : Type*} [SeminormedAddGroup S'] (h : IsNonarchimedean (nnnorm : S' → ā„ā‰„0)) : IsUltrametricDist S' := isUltrametricDist_of_forall_nnnorm_add_le_max_nnnorm h lemma isNonarchimedean_nnnorm {R} [SeminormedAddCommGroup R] [IsUltrametricDist R] : IsNonarchimedean (ā€–Ā·ā€–ā‚Š : R → ā„) := by intro x y convert dist_triangle_max 0 x (x + y) using 1 Ā· simp Ā· congr <;> simp [SeminormedAddGroup.dist_eq] lemma isUltrametricDist_iff_isNonarchimedean_nnnorm {R} [SeminormedAddCommGroup R] : IsUltrametricDist R ↔ IsNonarchimedean (ā€–Ā·ā€–ā‚Š : R → ā„) := ⟨fun h => h.isNonarchimedean_norm, IsUltrametricDist.isUltrametricDist_of_isNonarchimedean_norm⟩ /-- All triangles are isosceles in an ultrametric normed group. -/ @[to_additive /-- All triangles are isosceles in an ultrametric normed additive group. -/] lemma norm_mul_eq_max_of_norm_ne_norm {x y : S} (h : ‖x‖ ≠ ‖y‖) : ‖x * y‖ = max ‖x‖ ‖y‖ := by rw [← div_inv_eq_mul, ← dist_eq_norm_div, dist_eq_max_of_dist_ne_dist _ 1 _ (by simp [h])] simp only [dist_one_right, dist_one_left, norm_inv'] @[to_additive] lemma norm_eq_of_mul_norm_lt_max {x y : S} (h : ‖x * y‖ < max ‖x‖ ‖y‖) : ‖x‖ = ‖y‖ := not_ne_iff.mp (h.ne ∘ norm_mul_eq_max_of_norm_ne_norm) /-- All triangles are isosceles in an ultrametric normed group. -/ @[to_additive /-- All triangles are isosceles in an ultrametric normed additive group. -/] lemma nnnorm_mul_eq_max_of_nnnorm_ne_nnnorm {x y : S} (h : ‖xā€–ā‚Š ≠ ‖yā€–ā‚Š) : ‖x * yā€–ā‚Š = max ‖xā€–ā‚Š ‖yā€–ā‚Š := by simpa only [← NNReal.coe_inj, NNReal.coe_max] using norm_mul_eq_max_of_norm_ne_norm (NNReal.coe_injective.ne h) @[to_additive] lemma nnnorm_eq_of_mul_nnnorm_lt_max {x y : S} (h : ‖x * yā€–ā‚Š < max ‖xā€–ā‚Š ‖yā€–ā‚Š) : ‖xā€–ā‚Š = ‖yā€–ā‚Š := not_ne_iff.mp (h.ne ∘ nnnorm_mul_eq_max_of_nnnorm_ne_nnnorm) /-- All triangles are isosceles in an ultrametric normed group. -/ @[to_additive /-- All triangles are isosceles in an ultrametric normed additive group. -/] lemma norm_div_eq_max_of_norm_div_ne_norm_div (x y z : S) (h : ‖x / y‖ ≠ ‖y / z‖) : ‖x / z‖ = max ‖x / y‖ ‖y / z‖ := by simpa only [div_mul_div_cancel] using norm_mul_eq_max_of_norm_ne_norm h /-- All triangles are isosceles in an ultrametric normed group. -/ @[to_additive /-- All triangles are isosceles in an ultrametric normed additive group. -/] lemma nnnorm_div_eq_max_of_nnnorm_div_ne_nnnorm_div (x y z : S) (h : ‖x / yā€–ā‚Š ≠ ‖y / zā€–ā‚Š) : ‖x / zā€–ā‚Š = max ‖x / yā€–ā‚Š ‖y / zā€–ā‚Š := by simpa only [← NNReal.coe_inj, NNReal.coe_max] using norm_div_eq_max_of_norm_div_ne_norm_div _ _ _ (NNReal.coe_injective.ne h) @[to_additive] lemma nnnorm_pow_le (x : S) (n : ā„•) : ‖x ^ nā€–ā‚Š ≤ ‖xā€–ā‚Š := by induction n with | zero => simp | succ n hn => simpa [pow_add, hn] using nnnorm_mul_le_max (x ^ n) x @[to_additive] lemma norm_pow_le (x : S) (n : ā„•) : ‖x ^ n‖ ≤ ‖x‖ := nnnorm_pow_le x n @[to_additive] lemma nnnorm_zpow_le (x : S) (z : ℤ) : ‖x ^ zā€–ā‚Š ≤ ‖xā€–ā‚Š := by cases z <;> simpa using nnnorm_pow_le _ _ @[to_additive] lemma norm_zpow_le (x : S) (z : ℤ) : ‖x ^ z‖ ≤ ‖x‖ := nnnorm_zpow_le x z section nonarch variable (S) /-- In a group with an ultrametric norm, open balls around 1 of positive radius are open subgroups. -/ @[to_additive /-- In an additive group with an ultrametric norm, open balls around 0 of positive radius are open subgroups. -/] def ball_openSubgroup {r : ā„} (hr : 0 < r) : OpenSubgroup S where carrier := Metric.ball (1 : S) r mul_mem' {x} {y} hx hy := by simp only [Metric.mem_ball, dist_eq_norm_div, div_one] at hx hy ⊢ exact (norm_mul_le_max x y).trans_lt (max_lt hx hy) one_mem' := Metric.mem_ball_self hr inv_mem' := by simp only [Metric.mem_ball, dist_one_right, norm_inv', imp_self, implies_true] isOpen' := Metric.isOpen_ball /-- In a group with an ultrametric norm, closed balls around 1 of positive radius are open subgroups. -/ @[to_additive /-- In an additive group with an ultrametric norm, closed balls around 0 of positive radius are open subgroups. -/] def closedBall_openSubgroup {r : ā„} (hr : 0 < r) : OpenSubgroup S where carrier := Metric.closedBall (1 : S) r mul_mem' {x} {y} hx hy := by simp only [Metric.mem_closedBall, dist_eq_norm_div, div_one] at hx hy ⊢ exact (norm_mul_le_max x y).trans (max_le hx hy) one_mem' := Metric.mem_closedBall_self hr.le inv_mem' := by simp only [mem_closedBall, dist_one_right, norm_inv', imp_self, implies_true] isOpen' := IsUltrametricDist.isOpen_closedBall _ hr.ne' end nonarch end Group section CommGroup variable {M ι : Type*} [SeminormedCommGroup M] [IsUltrametricDist M] /-- A commutative group with an ultrametric group seminorm is nonarchimedean (as a topological group, i.e. every neighborhood of 1 contains an open subgroup). -/ @[to_additive /-- A commutative additive group with an ultrametric group seminorm is nonarchimedean (as a topological group, i.e. every neighborhood of 0 contains an open subgroup). -/] instance nonarchimedeanGroup : NonarchimedeanGroup M where is_nonarchimedean := by simpa only [Metric.mem_nhds_iff] using fun U ⟨ε, hεp, hεU⟩ ↦ ⟨ball_openSubgroup M hεp, hεU⟩ /-- Nonarchimedean norm of a product is less than or equal the norm of any term in the product. This version is phrased using `Finset.sup'` and `Finset.Nonempty` due to `Finset.sup` operating over an `OrderBot`, which `ā„` is not. -/ @[to_additive /-- Nonarchimedean norm of a sum is less than or equal the norm of any term in the sum. This version is phrased using `Finset.sup'` and `Finset.Nonempty` due to `Finset.sup` operating over an `OrderBot`, which `ā„` is not. -/] lemma _root_.Finset.Nonempty.norm_prod_le_sup'_norm {s : Finset ι} (hs : s.Nonempty) (f : ι → M) : ā€–āˆ i ∈ s, f i‖ ≤ s.sup' hs (‖f ·‖) := by simp only [Finset.le_sup'_iff] induction hs using Finset.Nonempty.cons_induction with | singleton j => simp only [Finset.mem_singleton, Finset.prod_singleton, exists_eq_left, le_refl] | cons j t hj _ IH => simp only [Finset.prod_cons, Finset.mem_cons, exists_eq_or_imp] refine (le_total ā€–āˆ i ∈ t, f i‖ ‖f j‖).imp ?_ ?_ <;> intro h Ā· exact (norm_mul_le_max _ _).trans (max_eq_left h).le Ā· exact ⟨_, IH.choose_spec.left, (norm_mul_le_max _ _).trans <| ((max_eq_right h).le.trans IH.choose_spec.right)⟩ /-- Nonarchimedean norm of a product is less than or equal to the largest norm of a term in the product. -/ @[to_additive /-- Nonarchimedean norm of a sum is less than or equal to the largest norm of a term in the sum. -/] lemma _root_.Finset.nnnorm_prod_le_sup_nnnorm (s : Finset ι) (f : ι → M) : ā€–āˆ i ∈ s, f iā€–ā‚Š ≤ s.sup (‖f Ā·ā€–ā‚Š) := by rcases s.eq_empty_or_nonempty with rfl | hs Ā· simp only [Finset.prod_empty, nnnorm_one', Finset.sup_empty, bot_eq_zero', le_refl] Ā· simpa only [← Finset.sup'_eq_sup hs, Finset.le_sup'_iff, coe_le_coe, coe_nnnorm'] using hs.norm_prod_le_sup'_norm f /-- Generalised ultrametric triangle inequality for finite products in commutative groups with an ultrametric norm. -/ @[to_additive /-- Generalised ultrametric triangle inequality for finite sums in additive commutative groups with an ultrametric norm. -/] lemma nnnorm_prod_le_of_forall_le {s : Finset ι} {f : ι → M} {C : ā„ā‰„0} (hC : āˆ€ i ∈ s, ‖f iā€–ā‚Š ≤ C) : ā€–āˆ i ∈ s, f iā€–ā‚Š ≤ C := (s.nnnorm_prod_le_sup_nnnorm f).trans <| Finset.sup_le hC /-- Generalised ultrametric triangle inequality for nonempty finite products in commutative groups with an ultrametric norm. -/ @[to_additive /-- Generalised ultrametric triangle inequality for nonempty finite sums in additive commutative groups with an ultrametric norm. -/] lemma norm_prod_le_of_forall_le_of_nonempty {s : Finset ι} (hs : s.Nonempty) {f : ι → M} {C : ā„} (hC : āˆ€ i ∈ s, ‖f i‖ ≤ C) : ā€–āˆ i ∈ s, f i‖ ≤ C := (hs.norm_prod_le_sup'_norm f).trans (Finset.sup'_le hs _ hC) /-- Generalised ultrametric triangle inequality for finite products in commutative groups with an ultrametric norm. -/ @[to_additive /-- Generalised ultrametric triangle inequality for finite sums in additive commutative groups with an ultrametric norm. -/] lemma norm_prod_le_of_forall_le_of_nonneg {s : Finset ι} {f : ι → M} {C : ā„} (h_nonneg : 0 ≤ C) (hC : āˆ€ i ∈ s, ‖f i‖ ≤ C) : ā€–āˆ i ∈ s, f i‖ ≤ C := by lift C to NNReal using h_nonneg exact nnnorm_prod_le_of_forall_le hC /-- Given a function `f : ι → M` and a nonempty finite set `t āŠ† ι`, we can always find `i ∈ t` such that `ā€–āˆ j in t, f j‖ ≤ ‖f i‖`. -/ @[to_additive /-- Given a function `f : ι → M` and a nonempty finite set `t āŠ† ι`, we can always find `i ∈ t` such that `ā€–āˆ‘ j ∈ t, f j‖ ≤ ‖f i‖`. -/] theorem exists_norm_finset_prod_le_of_nonempty {t : Finset ι} (ht : t.Nonempty) (f : ι → M) : ∃ i ∈ t, ā€–āˆ j ∈ t, f j‖ ≤ ‖f i‖ := match t.exists_mem_eq_sup' ht (‖f ·‖) with |⟨j, hj, hj'⟩ => ⟨j, hj, (ht.norm_prod_le_sup'_norm f).trans (le_of_eq hj')⟩ /-- Given a function `f : ι → M` and a finite set `t āŠ† ι`, we can always find `i : ι`, belonging to `t` if `t` is nonempty, such that `ā€–āˆ j ∈ t, f j‖ ≤ ‖f i‖`. -/ @[to_additive /-- Given a function `f : ι → M` and a finite set `t āŠ† ι`, we can always find `i : ι`, belonging to `t` if `t` is nonempty, such that `ā€–āˆ‘ j ∈ t, f j‖ ≤ ‖f i‖`. -/] theorem exists_norm_finset_prod_le (t : Finset ι) [Nonempty ι] (f : ι → M) : ∃ i : ι, (t.Nonempty → i ∈ t) ∧ ā€–āˆ j ∈ t, f j‖ ≤ ‖f i‖ := by rcases t.eq_empty_or_nonempty with rfl | ht Ā· simp exact (fun ⟨i, h, h'⟩ => ⟨i, fun _ ↦ h, h'⟩) <| exists_norm_finset_prod_le_of_nonempty ht f /-- Given a function `f : ι → M` and a multiset `t : Multiset ι`, we can always find `i : ι`, belonging to `t` if `t` is nonempty, such that `‖(s.map f).prod‖ ≤ ‖f i‖`. -/ @[to_additive /-- Given a function `f : ι → M` and a multiset `t : Multiset ι`, we can always find `i : ι`, belonging to `t` if `t` is nonempty, such that `‖(s.map f).sum‖ ≤ ‖f i‖`. -/] theorem exists_norm_multiset_prod_le (s : Multiset ι) [Nonempty ι] {f : ι → M} : ∃ i : ι, (s ≠ 0 → i ∈ s) ∧ ‖(s.map f).prod‖ ≤ ‖f i‖ := by inhabit ι induction s using Multiset.induction_on with | empty => simp | cons a t hM => obtain ⟨M, hMs, hM⟩ := hM by_cases! hMa : ‖f M‖ ≤ ‖f a‖ Ā· refine ⟨a, by simp, ?_⟩ Ā· rw [Multiset.map_cons, Multiset.prod_cons] exact le_trans (norm_mul_le_max _ _) (max_le (le_refl _) (le_trans hM hMa)) Ā· rcases eq_or_ne t 0 with rfl | ht Ā· exact ⟨a, by simp, by simp⟩ Ā· refine ⟨M, ?_, ?_⟩ Ā· simp [hMs ht] rw [Multiset.map_cons, Multiset.prod_cons] exact le_trans (norm_mul_le_max _ _) (max_le hMa.le hM) @[to_additive] lemma norm_tprod_le (f : ι → M) : ā€–āˆ' i, f i‖ ≤ ⨆ i, ‖f i‖ := by rcases isEmpty_or_nonempty ι with hι | hι Ā· -- Silly case #1 : the index type is empty simp only [tprod_empty, norm_one', Real.iSup_of_isEmpty, le_refl] by_cases h : Multipliable f; swap Ā· -- Silly case #2 : the product is divergent rw [tprod_eq_one_of_not_multipliable h, norm_one'] by_cases h_bd : BddAbove (Set.range fun i ↦ ‖f i‖) Ā· exact le_ciSup_of_le h_bd hι.some (norm_nonneg' _) Ā· rw [Real.iSup_of_not_bddAbove h_bd] -- now the interesting case have h_bd : BddAbove (Set.range fun i ↦ ‖f i‖) := h.tendsto_cofinite_one.norm'.bddAbove_range_of_cofinite refine le_of_tendsto' h.hasProd.norm' (fun s ↦ norm_prod_le_of_forall_le_of_nonneg ?_ ?_) Ā· exact le_ciSup_of_le h_bd hι.some (norm_nonneg' _) Ā· exact fun i _ ↦ le_ciSup h_bd i @[to_additive] lemma nnnorm_tprod_le (f : ι → M) : ā€–āˆ' i, f iā€–ā‚Š ≤ ⨆ i, ‖f iā€–ā‚Š := by simpa only [← NNReal.coe_le_coe, coe_nnnorm', coe_iSup] using norm_tprod_le f @[to_additive] lemma norm_tprod_le_of_forall_le [Nonempty ι] {f : ι → M} {C : ā„} (h : āˆ€ i, ‖f i‖ ≤ C) : ā€–āˆ' i, f i‖ ≤ C := (norm_tprod_le f).trans (ciSup_le h) @[to_additive] lemma norm_tprod_le_of_forall_le_of_nonneg {f : ι → M} {C : ā„} (hC : 0 ≤ C) (h : āˆ€ i, ‖f i‖ ≤ C) : ā€–āˆ' i, f i‖ ≤ C := by rcases isEmpty_or_nonempty ι Ā· simpa only [tprod_empty, norm_one'] using hC Ā· exact norm_tprod_le_of_forall_le h @[to_additive] lemma nnnorm_tprod_le_of_forall_le {f : ι → M} {C : ā„ā‰„0} (h : āˆ€ i, ‖f iā€–ā‚Š ≤ C) : ā€–āˆ' i, f iā€–ā‚Š ≤ C := (nnnorm_tprod_le f).trans (ciSup_le' h) @[to_additive] lemma nnnorm_prod_eq_sup_of_pairwise_ne {s : Finset ι} {f : ι → M} (hs : Set.Pairwise s (fun i j ↦ ‖f iā€–ā‚Š ≠ ‖f jā€–ā‚Š)) : ā€–āˆ i ∈ s, f iā€–ā‚Š = s.sup (fun i ↦ ‖f iā€–ā‚Š) := by induction s using Finset.cons_induction with | empty => simp | cons a s ha IH => rcases s.eq_empty_or_nonempty with rfl | hs' Ā· simp specialize IH (hs.mono (by simp)) obtain ⟨j, hj, hj'⟩ : ∃ j ∈ s, ā€–āˆ i ∈ s, f iā€–ā‚Š = ‖f jā€–ā‚Š := by simpa [IH] using s.exists_mem_eq_sup hs' _ suffices ‖f aā€–ā‚Š ≠ ā€–āˆ x ∈ s, f xā€–ā‚Š by simp [← IH, nnnorm_mul_eq_max_of_nnnorm_ne_nnnorm this] rw [hj'] apply hs <;> grind @[to_additive] lemma norm_prod_eq_sup'_of_pairwise_ne {s : Finset ι} {f : ι → M} (hs' : s.Nonempty) (hs : Set.Pairwise s (fun i j ↦ ‖f i‖ ≠ ‖f j‖)) : ā€–āˆ i ∈ s, f i‖ = s.sup' hs' (fun i ↦ ‖f i‖) := by rw [← coe_nnnorm', nnnorm_prod_eq_sup_of_pairwise_ne, ← Finset.sup'_eq_sup hs'] Ā· exact s.comp_sup'_eq_sup'_comp hs' _ (by tauto) Ā· simpa [← NNReal.coe_inj] using hs end CommGroup end IsUltrametricDist
.lake/packages/mathlib/Mathlib/Analysis/Normed/Group/AddTorsor.lean
import Mathlib.Analysis.Normed.Group.Constructions import Mathlib.Analysis.Normed.Group.Submodule import Mathlib.LinearAlgebra.AffineSpace.AffineSubspace.Basic import Mathlib.Topology.Algebra.Group.AddTorsor import Mathlib.Topology.MetricSpace.IsometricSMul /-! # Torsors of additive normed group actions. This file defines torsors of additive normed group actions, with a metric space structure. The motivating case is Euclidean affine spaces. -/ noncomputable section open NNReal Topology open Filter /-- A `NormedAddTorsor V P` is a torsor of an additive seminormed group action by a `SeminormedAddCommGroup V` on points `P`. We bundle the pseudometric space structure and require the distance to be the same as results from the norm (which in fact implies the distance yields a pseudometric space, but bundling just the distance and using an instance for the pseudometric space results in type class problems). -/ class NormedAddTorsor (V : outParam Type*) (P : Type*) [SeminormedAddCommGroup V] [PseudoMetricSpace P] extends AddTorsor V P where dist_eq_norm' : āˆ€ x y : P, dist x y = ‖(x -ᵄ y : V)‖ /-- Shortcut instance to help typeclass inference out. -/ instance (priority := 100) NormedAddTorsor.toAddTorsor' {V P : Type*} [NormedAddCommGroup V] [MetricSpace P] [NormedAddTorsor V P] : AddTorsor V P := NormedAddTorsor.toAddTorsor variable {α V P W Q : Type*} [SeminormedAddCommGroup V] [PseudoMetricSpace P] [NormedAddTorsor V P] [NormedAddCommGroup W] [MetricSpace Q] [NormedAddTorsor W Q] instance (priority := 100) NormedAddTorsor.to_isIsIsometricVAdd : IsIsometricVAdd V P := ⟨fun c => Isometry.of_dist_eq fun x y => by simp [NormedAddTorsor.dist_eq_norm']⟩ /-- A `SeminormedAddCommGroup` is a `NormedAddTorsor` over itself. -/ instance (priority := 100) SeminormedAddCommGroup.toNormedAddTorsor : NormedAddTorsor V V where dist_eq_norm' := dist_eq_norm -- Because of the AddTorsor.nonempty instance. /-- A nonempty affine subspace of a `NormedAddTorsor` is itself a `NormedAddTorsor`. -/ instance AffineSubspace.toNormedAddTorsor {R : Type*} [Ring R] [Module R V] (s : AffineSubspace R P) [Nonempty s] : NormedAddTorsor s.direction s := { AffineSubspace.toAddTorsor s with dist_eq_norm' := fun x y => NormedAddTorsor.dist_eq_norm' x.val y.val } instance : NormedAddTorsor (V Ɨ W) (P Ɨ Q) where dist_eq_norm' x y := by simp only [Prod.dist_eq, NormedAddTorsor.dist_eq_norm', Prod.norm_def, Prod.fst_vsub, Prod.snd_vsub] section variable (V W) /-- The distance equals the norm of subtracting two points. In this lemma, it is necessary to have `V` as an explicit argument; otherwise `rw dist_eq_norm_vsub` sometimes doesn't work. -/ theorem dist_eq_norm_vsub (x y : P) : dist x y = ‖x -ᵄ y‖ := NormedAddTorsor.dist_eq_norm' x y theorem nndist_eq_nnnorm_vsub (x y : P) : nndist x y = ‖x -ᵄ yā€–ā‚Š := NNReal.eq <| dist_eq_norm_vsub V x y /-- The distance equals the norm of subtracting two points. In this lemma, it is necessary to have `V` as an explicit argument; otherwise `rw dist_eq_norm_vsub'` sometimes doesn't work. -/ theorem dist_eq_norm_vsub' (x y : P) : dist x y = ‖y -ᵄ x‖ := (dist_comm _ _).trans (dist_eq_norm_vsub _ _ _) theorem nndist_eq_nnnorm_vsub' (x y : P) : nndist x y = ‖y -ᵄ xā€–ā‚Š := NNReal.eq <| dist_eq_norm_vsub' V x y end theorem dist_vadd_cancel_left (v : V) (x y : P) : dist (v +ᵄ x) (v +ᵄ y) = dist x y := dist_vadd _ _ _ theorem nndist_vadd_cancel_left (v : V) (x y : P) : nndist (v +ᵄ x) (v +ᵄ y) = nndist x y := NNReal.eq <| dist_vadd_cancel_left _ _ _ @[simp] theorem dist_vadd_cancel_right (v₁ vā‚‚ : V) (x : P) : dist (v₁ +ᵄ x) (vā‚‚ +ᵄ x) = dist v₁ vā‚‚ := by rw [dist_eq_norm_vsub V, dist_eq_norm, vadd_vsub_vadd_cancel_right] @[simp] theorem nndist_vadd_cancel_right (v₁ vā‚‚ : V) (x : P) : nndist (v₁ +ᵄ x) (vā‚‚ +ᵄ x) = nndist v₁ vā‚‚ := NNReal.eq <| dist_vadd_cancel_right _ _ _ @[simp] theorem dist_vadd_left (v : V) (x : P) : dist (v +ᵄ x) x = ‖v‖ := by simp [dist_eq_norm_vsub V _ x] @[simp] theorem nndist_vadd_left (v : V) (x : P) : nndist (v +ᵄ x) x = ‖vā€–ā‚Š := NNReal.eq <| dist_vadd_left _ _ @[simp] theorem dist_vadd_right (v : V) (x : P) : dist x (v +ᵄ x) = ‖v‖ := by rw [dist_comm, dist_vadd_left] @[simp] theorem nndist_vadd_right (v : V) (x : P) : nndist x (v +ᵄ x) = ‖vā€–ā‚Š := NNReal.eq <| dist_vadd_right _ _ /-- Isometry between the tangent space `V` of a (semi)normed add torsor `P` and `P` given by addition/subtraction of `x : P`. -/ @[simps!] def IsometryEquiv.vaddConst (x : P) : V ā‰ƒįµ¢ P where toEquiv := Equiv.vaddConst x isometry_toFun := Isometry.of_dist_eq fun _ _ => dist_vadd_cancel_right _ _ _ @[simp] theorem dist_vsub_cancel_left (x y z : P) : dist (x -ᵄ y) (x -ᵄ z) = dist y z := by rw [dist_eq_norm, vsub_sub_vsub_cancel_left, dist_comm, dist_eq_norm_vsub V] @[simp] theorem nndist_vsub_cancel_left (x y z : P) : nndist (x -ᵄ y) (x -ᵄ z) = nndist y z := NNReal.eq <| dist_vsub_cancel_left _ _ _ /-- Isometry between the tangent space `V` of a (semi)normed add torsor `P` and `P` given by subtraction from `x : P`. -/ @[simps!] def IsometryEquiv.constVSub (x : P) : P ā‰ƒįµ¢ V where toEquiv := Equiv.constVSub x isometry_toFun := Isometry.of_dist_eq fun _ _ => dist_vsub_cancel_left _ _ _ @[simp] theorem dist_vsub_cancel_right (x y z : P) : dist (x -ᵄ z) (y -ᵄ z) = dist x y := (IsometryEquiv.vaddConst z).symm.dist_eq x y @[simp] theorem nndist_vsub_cancel_right (x y z : P) : nndist (x -ᵄ z) (y -ᵄ z) = nndist x y := NNReal.eq <| dist_vsub_cancel_right _ _ _ theorem dist_vadd_vadd_le (v v' : V) (p p' : P) : dist (v +ᵄ p) (v' +ᵄ p') ≤ dist v v' + dist p p' := by simpa using dist_triangle (v +ᵄ p) (v' +ᵄ p) (v' +ᵄ p') theorem nndist_vadd_vadd_le (v v' : V) (p p' : P) : nndist (v +ᵄ p) (v' +ᵄ p') ≤ nndist v v' + nndist p p' := dist_vadd_vadd_le _ _ _ _ theorem dist_vsub_vsub_le (p₁ pā‚‚ pā‚ƒ pā‚„ : P) : dist (p₁ -ᵄ pā‚‚) (pā‚ƒ -ᵄ pā‚„) ≤ dist p₁ pā‚ƒ + dist pā‚‚ pā‚„ := by rw [dist_eq_norm, vsub_sub_vsub_comm, dist_eq_norm_vsub V, dist_eq_norm_vsub V] exact norm_sub_le _ _ theorem nndist_vsub_vsub_le (p₁ pā‚‚ pā‚ƒ pā‚„ : P) : nndist (p₁ -ᵄ pā‚‚) (pā‚ƒ -ᵄ pā‚„) ≤ nndist p₁ pā‚ƒ + nndist pā‚‚ pā‚„ := by simp only [← NNReal.coe_le_coe, NNReal.coe_add, ← dist_nndist, dist_vsub_vsub_le] theorem edist_vadd_vadd_le (v v' : V) (p p' : P) : edist (v +ᵄ p) (v' +ᵄ p') ≤ edist v v' + edist p p' := by simp only [edist_nndist] norm_cast apply dist_vadd_vadd_le theorem edist_vsub_vsub_le (p₁ pā‚‚ pā‚ƒ pā‚„ : P) : edist (p₁ -ᵄ pā‚‚) (pā‚ƒ -ᵄ pā‚„) ≤ edist p₁ pā‚ƒ + edist pā‚‚ pā‚„ := by simp only [edist_nndist] norm_cast apply dist_vsub_vsub_le /-- The pseudodistance defines a pseudometric space structure on the torsor. This is not an instance because it depends on `V` to define a `MetricSpace P`. -/ def pseudoMetricSpaceOfNormedAddCommGroupOfAddTorsor (V P : Type*) [SeminormedAddCommGroup V] [AddTorsor V P] : PseudoMetricSpace P where dist x y := ‖(x -ᵄ y : V)‖ dist_self x := by simp dist_comm x y := by simp only [← neg_vsub_eq_vsub_rev y x, norm_neg] dist_triangle x y z := by rw [← vsub_add_vsub_cancel] apply norm_add_le /-- The distance defines a metric space structure on the torsor. This is not an instance because it depends on `V` to define a `MetricSpace P`. -/ def metricSpaceOfNormedAddCommGroupOfAddTorsor (V P : Type*) [NormedAddCommGroup V] [AddTorsor V P] : MetricSpace P where dist x y := ‖(x -ᵄ y : V)‖ dist_self x := by simp eq_of_dist_eq_zero h := by simpa using h dist_comm x y := by simp only [← neg_vsub_eq_vsub_rev y x, norm_neg] dist_triangle x y z := by rw [← vsub_add_vsub_cancel] apply norm_add_le theorem LipschitzWith.vadd [PseudoEMetricSpace α] {f : α → V} {g : α → P} {Kf Kg : ā„ā‰„0} (hf : LipschitzWith Kf f) (hg : LipschitzWith Kg g) : LipschitzWith (Kf + Kg) (f +ᵄ g) := fun x y => calc edist (f x +ᵄ g x) (f y +ᵄ g y) ≤ edist (f x) (f y) + edist (g x) (g y) := edist_vadd_vadd_le _ _ _ _ _ ≤ Kf * edist x y + Kg * edist x y := add_le_add (hf x y) (hg x y) _ = (Kf + Kg) * edist x y := (add_mul _ _ _).symm theorem LipschitzWith.vsub [PseudoEMetricSpace α] {f g : α → P} {Kf Kg : ā„ā‰„0} (hf : LipschitzWith Kf f) (hg : LipschitzWith Kg g) : LipschitzWith (Kf + Kg) (f -ᵄ g) := fun x y => calc edist (f x -ᵄ g x) (f y -ᵄ g y) ≤ edist (f x) (f y) + edist (g x) (g y) := edist_vsub_vsub_le _ _ _ _ _ ≤ Kf * edist x y + Kg * edist x y := add_le_add (hf x y) (hg x y) _ = (Kf + Kg) * edist x y := (add_mul _ _ _).symm theorem uniformContinuous_vadd : UniformContinuous fun x : V Ɨ P => x.1 +ᵄ x.2 := (LipschitzWith.prod_fst.vadd LipschitzWith.prod_snd).uniformContinuous theorem uniformContinuous_vsub : UniformContinuous fun x : P Ɨ P => x.1 -ᵄ x.2 := (LipschitzWith.prod_fst.vsub LipschitzWith.prod_snd).uniformContinuous instance : IsTopologicalAddTorsor P where continuous_vadd := uniformContinuous_vadd.continuous continuous_vsub := uniformContinuous_vsub.continuous
.lake/packages/mathlib/Mathlib/Analysis/Normed/Group/Tannery.lean
import Mathlib.Analysis.RCLike.Basic import Mathlib.Analysis.Normed.Group.InfiniteSum /-! # Tannery's theorem Tannery's theorem gives a sufficient criterion for the limit of an infinite sum (with respect to an auxiliary parameter) to equal the sum of the pointwise limits. See https://en.wikipedia.org/wiki/Tannery%27s_theorem. It is a special case of the dominated convergence theorem (with the measure chosen to be the counting measure); but we give here a direct proof, in order to avoid some unnecessary hypotheses that appear when specialising the general measure-theoretic result. -/ open Filter Topology /-- **Tannery's theorem**: topological sums commute with termwise limits, when the norms of the summands are eventually uniformly bounded by a summable function. (This is the special case of the Lebesgue dominated convergence theorem for the counting measure on a discrete set. However, we prove it under somewhat weaker assumptions than the general measure-theoretic result, e.g. `G` is not assumed to be an `ā„`-vector space or second countable, and the limit is along an arbitrary filter rather than `atTop ā„•`.) See also: * `MeasureTheory.tendsto_integral_of_dominated_convergence` (for general integrals, but with more assumptions on `G`) * `continuous_tsum` (continuity of infinite sums in a parameter) -/ lemma tendsto_tsum_of_dominated_convergence {α β G : Type*} {š“• : Filter α} [NormedAddCommGroup G] [CompleteSpace G] {f : α → β → G} {g : β → G} {bound : β → ā„} (h_sum : Summable bound) (hab : āˆ€ k : β, Tendsto (f Ā· k) š“• (š“ (g k))) (h_bound : āˆ€į¶  n in š“•, āˆ€ k, ‖f n k‖ ≤ bound k) : Tendsto (āˆ‘' k, f Ā· k) š“• (š“ (āˆ‘' k, g k)) := by -- WLOG β is nonempty rcases isEmpty_or_nonempty β Ā· simpa only [tsum_empty] using tendsto_const_nhds -- WLOG š“• ≠ ⊄ rcases š“•.eq_or_neBot with rfl | _ Ā· simp only [tendsto_bot] -- Auxiliary lemmas have h_g_le (k : β) : ‖g k‖ ≤ bound k := le_of_tendsto (tendsto_norm.comp (hab k)) <| h_bound.mono (fun n h => h k) have h_sumg : Summable (‖g ·‖) := h_sum.of_norm_bounded (fun k ↦ (norm_norm (g k)).symm ā–ø h_g_le k) have h_suma : āˆ€į¶  n in š“•, Summable (‖f n ·‖) := by filter_upwards [h_bound] with n h exact h_sum.of_norm_bounded <| by simpa only [norm_norm] using h -- Now main proof, by an `ε / 3` argument rw [Metric.tendsto_nhds] intro ε hε let ⟨S, hS⟩ := h_sum obtain ⟨T, hT⟩ : ∃ (T : Finset β), dist (āˆ‘ b ∈ T, bound b) S < ε / 3 := by rw [HasSum, Metric.tendsto_nhds] at hS classical exact Eventually.exists <| hS _ (by positivity) have h1 : āˆ‘' (k : (Tᶜ : Set β)), bound k < ε / 3 := by calc _ ≤ ā€–āˆ‘' (k : (Tᶜ : Set β)), bound k‖ := Real.le_norm_self _ _ = ‖S - āˆ‘ b ∈ T, bound b‖ := congrArg _ ?_ _ < ε / 3 := by rwa [dist_eq_norm, norm_sub_rev] at hT simpa only [h_sum.sum_add_tsum_compl, eq_sub_iff_add_eq'] using hS.tsum_eq have h2 : Tendsto (āˆ‘ k ∈ T, f Ā· k) š“• (š“ (T.sum g)) := tendsto_finset_sum _ (fun i _ ↦ hab i) rw [Metric.tendsto_nhds] at h2 filter_upwards [h2 (ε / 3) (by positivity), h_suma, h_bound] with n hn h_suma h_bound rw [dist_eq_norm, ← h_suma.of_norm.tsum_sub h_sumg.of_norm, ← (h_suma.of_norm.sub h_sumg.of_norm).sum_add_tsum_compl (s := T), (by ring : ε = ε / 3 + (ε / 3 + ε / 3))] refine (norm_add_le _ _).trans_lt (add_lt_add ?_ ?_) Ā· simpa only [dist_eq_norm, Finset.sum_sub_distrib] using hn Ā· rw [(h_suma.subtype _).of_norm.tsum_sub (h_sumg.subtype _).of_norm] refine (norm_sub_le _ _).trans_lt (add_lt_add ?_ ?_) Ā· refine ((norm_tsum_le_tsum_norm (h_suma.subtype _)).trans ?_).trans_lt h1 exact (h_suma.subtype _).tsum_le_tsum (h_bound Ā·) (h_sum.subtype _) Ā· refine ((norm_tsum_le_tsum_norm <| h_sumg.subtype _).trans ?_).trans_lt h1 exact (h_sumg.subtype _).tsum_le_tsum (h_g_le Ā·) (h_sum.subtype _)
.lake/packages/mathlib/Mathlib/Analysis/Normed/Group/Pointwise.lean
import Mathlib.Analysis.Normed.Group.Bounded import Mathlib.Analysis.Normed.Group.Uniform import Mathlib.Topology.MetricSpace.Thickening /-! # Properties of pointwise addition of sets in normed groups We explore the relationships between pointwise addition of sets in normed groups, and the norm. Notably, we show that the sum of bounded sets remain bounded. -/ open Metric Set Pointwise Topology variable {E : Type*} section SeminormedGroup variable [SeminormedGroup E] {s t : Set E} -- note: we can't use `LipschitzOnWith.isBounded_image2` here without adding `[IsIsometricSMul E E]` @[to_additive] theorem Bornology.IsBounded.mul (hs : IsBounded s) (ht : IsBounded t) : IsBounded (s * t) := by obtain ⟨Rs, hRs⟩ : ∃ R, āˆ€ x ∈ s, ‖x‖ ≤ R := hs.exists_norm_le' obtain ⟨Rt, hRt⟩ : ∃ R, āˆ€ x ∈ t, ‖x‖ ≤ R := ht.exists_norm_le' refine isBounded_iff_forall_norm_le'.2 ⟨Rs + Rt, ?_⟩ rintro z ⟨x, hx, y, hy, rfl⟩ exact norm_mul_le_of_le' (hRs x hx) (hRt y hy) @[to_additive] theorem Bornology.IsBounded.of_mul (hst : IsBounded (s * t)) : IsBounded s ∨ IsBounded t := AntilipschitzWith.isBounded_of_image2_left _ (fun x => (isometry_mul_right x).antilipschitz) hst @[to_additive] theorem Bornology.IsBounded.inv : IsBounded s → IsBounded s⁻¹ := by simp_rw [isBounded_iff_forall_norm_le', ← image_inv_eq_inv, forall_mem_image, norm_inv'] exact id @[to_additive] theorem Bornology.IsBounded.div (hs : IsBounded s) (ht : IsBounded t) : IsBounded (s / t) := div_eq_mul_inv s t ā–ø hs.mul ht.inv end SeminormedGroup section SeminormedCommGroup variable [SeminormedCommGroup E] {Ī“ : ā„} {s : Set E} {x y : E} section EMetric open EMetric @[to_additive (attr := simp)] theorem infEdist_inv_inv (x : E) (s : Set E) : infEdist x⁻¹ s⁻¹ = infEdist x s := by rw [← image_inv_eq_inv, infEdist_image isometry_inv] @[to_additive] theorem infEdist_inv (x : E) (s : Set E) : infEdist x⁻¹ s = infEdist x s⁻¹ := by rw [← infEdist_inv_inv, inv_inv] @[to_additive] theorem ediam_mul_le (x y : Set E) : EMetric.diam (x * y) ≤ EMetric.diam x + EMetric.diam y := (LipschitzOnWith.ediam_image2_le (Ā· * Ā·) _ _ (fun _ _ => (isometry_mul_right _).lipschitz.lipschitzOnWith) fun _ _ => (isometry_mul_left _).lipschitz.lipschitzOnWith).trans_eq <| by simp only [ENNReal.coe_one, one_mul] end EMetric variable (Ī“ s x y) @[to_additive (attr := simp)] theorem inv_thickening : (thickening Ī“ s)⁻¹ = thickening Ī“ s⁻¹ := by simp_rw [thickening, ← infEdist_inv] rfl @[to_additive (attr := simp)] theorem inv_cthickening : (cthickening Ī“ s)⁻¹ = cthickening Ī“ s⁻¹ := by simp_rw [cthickening, ← infEdist_inv] rfl @[to_additive (attr := simp)] theorem inv_ball : (ball x Ī“)⁻¹ = ball x⁻¹ Ī“ := (IsometryEquiv.inv E).preimage_ball x Ī“ @[to_additive (attr := simp)] theorem inv_closedBall : (closedBall x Ī“)⁻¹ = closedBall x⁻¹ Ī“ := (IsometryEquiv.inv E).preimage_closedBall x Ī“ @[to_additive] theorem singleton_mul_ball : {x} * ball y Ī“ = ball (x * y) Ī“ := by simp only [preimage_mul_ball, image_mul_left, singleton_mul, div_inv_eq_mul, mul_comm y x] @[to_additive] theorem singleton_div_ball : {x} / ball y Ī“ = ball (x / y) Ī“ := by simp_rw [div_eq_mul_inv, inv_ball, singleton_mul_ball] @[to_additive] theorem ball_mul_singleton : ball x Ī“ * {y} = ball (x * y) Ī“ := by rw [mul_comm, singleton_mul_ball, mul_comm y] @[to_additive] theorem ball_div_singleton : ball x Ī“ / {y} = ball (x / y) Ī“ := by simp_rw [div_eq_mul_inv, inv_singleton, ball_mul_singleton] @[to_additive] theorem singleton_mul_ball_one : {x} * ball 1 Ī“ = ball x Ī“ := by simp @[to_additive] theorem singleton_div_ball_one : {x} / ball 1 Ī“ = ball x Ī“ := by rw [singleton_div_ball, div_one] @[to_additive] theorem ball_one_mul_singleton : ball 1 Ī“ * {x} = ball x Ī“ := by simp @[to_additive] theorem ball_one_div_singleton : ball 1 Ī“ / {x} = ball x⁻¹ Ī“ := by rw [ball_div_singleton, one_div] @[to_additive] theorem smul_ball_one : x • ball (1 : E) Ī“ = ball x Ī“ := by rw [smul_ball, smul_eq_mul, mul_one] @[to_additive (attr := simp 1100)] theorem singleton_mul_closedBall : {x} * closedBall y Ī“ = closedBall (x * y) Ī“ := by simp_rw [singleton_mul, ← smul_eq_mul, image_smul, smul_closedBall] @[to_additive (attr := simp 1100)] theorem singleton_div_closedBall : {x} / closedBall y Ī“ = closedBall (x / y) Ī“ := by simp_rw [div_eq_mul_inv, inv_closedBall, singleton_mul_closedBall] @[to_additive (attr := simp 1100)] theorem closedBall_mul_singleton : closedBall x Ī“ * {y} = closedBall (x * y) Ī“ := by simp [mul_comm _ {y}, mul_comm y] @[to_additive (attr := simp 1100)] theorem closedBall_div_singleton : closedBall x Ī“ / {y} = closedBall (x / y) Ī“ := by simp [div_eq_mul_inv] @[to_additive] theorem singleton_mul_closedBall_one : {x} * closedBall 1 Ī“ = closedBall x Ī“ := by simp @[to_additive] theorem singleton_div_closedBall_one : {x} / closedBall 1 Ī“ = closedBall x Ī“ := by rw [singleton_div_closedBall, div_one] @[to_additive] theorem closedBall_one_mul_singleton : closedBall 1 Ī“ * {x} = closedBall x Ī“ := by simp @[to_additive] theorem closedBall_one_div_singleton : closedBall 1 Ī“ / {x} = closedBall x⁻¹ Ī“ := by simp @[to_additive (attr := simp 1100)] theorem smul_closedBall_one : x • closedBall (1 : E) Ī“ = closedBall x Ī“ := by simp @[to_additive] theorem mul_ball_one : s * ball 1 Ī“ = thickening Ī“ s := by rw [thickening_eq_biUnion_ball] convert iUnionā‚‚_mul (fun x (_ : x ∈ s) => {x}) (ball (1 : E) Ī“) Ā· exact s.biUnion_of_singleton.symm ext x simp_rw [singleton_mul_ball, mul_one] @[to_additive] theorem div_ball_one : s / ball 1 Ī“ = thickening Ī“ s := by simp [div_eq_mul_inv, mul_ball_one] @[to_additive] theorem ball_mul_one : ball 1 Ī“ * s = thickening Ī“ s := by rw [mul_comm, mul_ball_one] @[to_additive] theorem ball_div_one : ball 1 Ī“ / s = thickening Ī“ s⁻¹ := by simp [div_eq_mul_inv, ball_mul_one] @[to_additive (attr := simp)] theorem mul_ball : s * ball x Ī“ = x • thickening Ī“ s := by rw [← smul_ball_one, mul_smul_comm, mul_ball_one] @[to_additive (attr := simp)] theorem div_ball : s / ball x Ī“ = x⁻¹ • thickening Ī“ s := by simp [div_eq_mul_inv] @[to_additive (attr := simp)] theorem ball_mul : ball x Ī“ * s = x • thickening Ī“ s := by rw [mul_comm, mul_ball] @[to_additive (attr := simp)] theorem ball_div : ball x Ī“ / s = x • thickening Ī“ s⁻¹ := by simp [div_eq_mul_inv] variable {Ī“ s x y} @[to_additive] theorem IsCompact.mul_closedBall_one (hs : IsCompact s) (hĪ“ : 0 ≤ Ī“) : s * closedBall (1 : E) Ī“ = cthickening Ī“ s := by rw [hs.cthickening_eq_biUnion_closedBall hĪ“] ext x simp only [mem_mul, dist_eq_norm_div, exists_prop, mem_iUnion, mem_closedBall, ← eq_div_iff_mul_eq'', div_one, exists_eq_right] @[to_additive] theorem IsCompact.div_closedBall_one (hs : IsCompact s) (hĪ“ : 0 ≤ Ī“) : s / closedBall 1 Ī“ = cthickening Ī“ s := by simp [div_eq_mul_inv, hs.mul_closedBall_one hĪ“] @[to_additive] theorem IsCompact.closedBall_one_mul (hs : IsCompact s) (hĪ“ : 0 ≤ Ī“) : closedBall 1 Ī“ * s = cthickening Ī“ s := by rw [mul_comm, hs.mul_closedBall_one hĪ“] @[to_additive] theorem IsCompact.closedBall_one_div (hs : IsCompact s) (hĪ“ : 0 ≤ Ī“) : closedBall 1 Ī“ / s = cthickening Ī“ s⁻¹ := by simp [div_eq_mul_inv, mul_comm, hs.inv.mul_closedBall_one hĪ“] @[to_additive] theorem IsCompact.mul_closedBall (hs : IsCompact s) (hĪ“ : 0 ≤ Ī“) (x : E) : s * closedBall x Ī“ = x • cthickening Ī“ s := by rw [← smul_closedBall_one, mul_smul_comm, hs.mul_closedBall_one hĪ“] @[to_additive] theorem IsCompact.div_closedBall (hs : IsCompact s) (hĪ“ : 0 ≤ Ī“) (x : E) : s / closedBall x Ī“ = x⁻¹ • cthickening Ī“ s := by simp [div_eq_mul_inv, hs.mul_closedBall hĪ“] @[to_additive] theorem IsCompact.closedBall_mul (hs : IsCompact s) (hĪ“ : 0 ≤ Ī“) (x : E) : closedBall x Ī“ * s = x • cthickening Ī“ s := by rw [mul_comm, hs.mul_closedBall hĪ“] @[to_additive] theorem IsCompact.closedBall_div (hs : IsCompact s) (hĪ“ : 0 ≤ Ī“) (x : E) : closedBall x Ī“ * s = x • cthickening Ī“ s := by simp [hs.closedBall_mul hĪ“] end SeminormedCommGroup
.lake/packages/mathlib/Mathlib/Analysis/Normed/Group/Completion.lean
import Mathlib.Analysis.Normed.Group.Uniform import Mathlib.Topology.Algebra.GroupCompletion import Mathlib.Topology.MetricSpace.Completion /-! # Completion of a normed group In this file we prove that the completion of a (semi)normed group is a normed group. ## Tags normed group, completion -/ noncomputable section namespace UniformSpace namespace Completion variable (E : Type*) instance [UniformSpace E] [Norm E] : Norm (Completion E) where norm := Completion.extension Norm.norm @[simp] theorem norm_coe {E} [SeminormedAddCommGroup E] (x : E) : ‖(x : Completion E)‖ = ‖x‖ := Completion.extension_coe uniformContinuous_norm x instance [SeminormedAddCommGroup E] : NormedAddCommGroup (Completion E) where dist_eq x y := by induction x, y using Completion.induction_onā‚‚ Ā· refine isClosed_eq (Completion.uniformContinuous_extensionā‚‚ _).continuous ?_ exact Continuous.comp Completion.continuous_extension continuous_sub Ā· rw [← Completion.coe_sub, norm_coe, Completion.dist_eq, dist_eq_norm] @[simp] theorem nnnorm_coe {E} [SeminormedAddCommGroup E] (x : E) : ‖(x : Completion E)ā€–ā‚Š = ‖xā€–ā‚Š := by simp [nnnorm] @[simp] lemma enorm_coe {E} [SeminormedAddCommGroup E] (x : E) : ‖(x : Completion E)‖ₑ = ‖x‖ₑ := by simp [enorm] end Completion end UniformSpace
.lake/packages/mathlib/Mathlib/Analysis/Normed/Group/CocompactMap.lean
import Mathlib.Analysis.Normed.Group.Basic import Mathlib.Topology.ContinuousMap.CocompactMap import Mathlib.Topology.MetricSpace.Bounded /-! # Cocompact maps in normed groups This file gives a characterization of cocompact maps in terms of norm estimates. ## Main statements * `CocompactMapClass.norm_le`: Every cocompact map satisfies a norm estimate * `ContinuousMapClass.toCocompactMapClass_of_norm`: Conversely, this norm estimate implies that a map is cocompact. -/ open Filter Metric variable {š•œ E F š“• : Type*} variable [NormedAddCommGroup E] [NormedAddCommGroup F] variable {f : š“•} theorem CocompactMapClass.norm_le [ProperSpace F] [FunLike š“• E F] [CocompactMapClass š“• E F] (ε : ā„) : ∃ r : ā„, āˆ€ x : E, r < ‖x‖ → ε < ‖f x‖ := by have h := cocompact_tendsto f rw [tendsto_def] at h specialize h (Metric.closedBall 0 ε)ᶜ (mem_cocompact_of_closedBall_compl_subset 0 ⟨ε, rfl.subset⟩) rcases closedBall_compl_subset_of_mem_cocompact h 0 with ⟨r, hr⟩ use r intro x hx suffices x ∈ f⁻¹' (Metric.closedBall 0 ε)ᶜ by simp_all apply hr simp [hx] theorem Filter.tendsto_cocompact_cocompact_of_norm [ProperSpace E] {f : E → F} (h : āˆ€ ε : ā„, ∃ r : ā„, āˆ€ x : E, r < ‖x‖ → ε < ‖f x‖) : Tendsto f (cocompact E) (cocompact F) := by rw [tendsto_def] intro s hs rcases closedBall_compl_subset_of_mem_cocompact hs 0 with ⟨ε, hε⟩ rcases h ε with ⟨r, hr⟩ apply mem_cocompact_of_closedBall_compl_subset 0 use r intro x hx simp only [Set.mem_compl_iff, Metric.mem_closedBall, dist_zero_right, not_le] at hx apply hε simp [hr x hx] theorem ContinuousMapClass.toCocompactMapClass_of_norm [ProperSpace E] [FunLike š“• E F] [ContinuousMapClass š“• E F] (h : āˆ€ (f : š“•) (ε : ā„), ∃ r : ā„, āˆ€ x : E, r < ‖x‖ → ε < ‖f x‖) : CocompactMapClass š“• E F where cocompact_tendsto := (tendsto_cocompact_cocompact_of_norm <| h Ā·)
.lake/packages/mathlib/Mathlib/Analysis/Normed/Group/SeparationQuotient.lean
import Mathlib.Analysis.Normed.Group.Hom import Mathlib.Topology.Algebra.SeparationQuotient.Hom /-! # Lifts of maps to separation quotients of seminormed groups For any `SeminormedAddCommGroup M`, a `NormedAddCommGroup` instance has been defined in `Mathlib/Analysis/Normed/Group/Uniform.lean`. ## Main definitions We use `M` and `N` to denote seminormed groups. All the following definitions are in the `SeparationQuotient` namespace. Hence we can access `SeparationQuotient.normedMk` as `normedMk`. * `normedMk` : the normed group hom from `M` to `SeparationQuotient M`. * `liftNormedAddGroupHom` : any bounded group hom `f : M → N` such that `āˆ€ x, ‖x‖ = 0 → f x = 0` descends to a bounded group hom `SeparationQuotient M → N`. Here, `(f : NormedAddGroupHom M N)`, `(hf : āˆ€ x : M, ‖x‖ = 0 → f x = 0)` and `liftNormedAddGroupHom f hf : NormedAddGroupHom (SeparationQuotient M) N` such that `liftNormedAddGroupHom f hf (mk x) = f x`. ## Main results * `norm_normedMk_eq_one` : the operator norm of the projection is `1` if the subspace is not `⊤`. * `norm_liftNormedAddGroupHom_le` : `‖liftNormedAddGroupHom f hf‖ ≤ ‖f‖`. -/ section open SeparationQuotient NNReal variable {M N : Type*} [SeminormedAddCommGroup M] [SeminormedAddCommGroup N] namespace SeparationQuotient open NormedAddGroupHom /-- The morphism from a seminormed group to the quotient by the inseparable setoid. -/ @[simps] noncomputable def normedMk : NormedAddGroupHom M (SeparationQuotient M) where __ := mkAddMonoidHom bound' := ⟨1, by simp⟩ /-- The operator norm of the projection is at most `1`. -/ theorem norm_normedMk_le : ‖normedMk (M := M)‖ ≤ 1 := NormedAddGroupHom.opNorm_le_bound _ zero_le_one fun m => by simp lemma apply_eq_apply_of_inseparable {F : Type*} [FunLike F M N] [AddMonoidHomClass F M N] (f : F) (hf : āˆ€ x, ‖x‖ = 0 → f x = 0) : āˆ€ x y, Inseparable x y → f x = f y := fun x y h ↦ eq_of_sub_eq_zero <| by rw [← map_sub] rw [Metric.inseparable_iff, dist_eq_norm] at h exact hf (x - y) h /-- The lift of a group hom to the separation quotient as a group hom. -/ @[simps] noncomputable def liftNormedAddGroupHom (f : NormedAddGroupHom M N) (hf : āˆ€ x, ‖x‖ = 0 → f x = 0) : NormedAddGroupHom (SeparationQuotient M) N where toFun := SeparationQuotient.liftContinuousAddMonoidHom f <| apply_eq_apply_of_inseparable f hf map_add' v₁ vā‚‚ := map_add .. bound' := by refine āŸØā€–f‖, fun v ↦ ?_⟩ obtain ⟨v, rfl⟩ := surjective_mk v exact le_opNorm f v theorem norm_liftNormedAddGroupHom_apply_le (f : NormedAddGroupHom M N) (hf : āˆ€ x, ‖x‖ = 0 → f x = 0) (x : SeparationQuotient M) : ‖liftNormedAddGroupHom f hf x‖ ≤ ‖f‖ * ‖x‖ := by obtain ⟨x, rfl⟩ := surjective_mk x exact le_opNorm f x /-- The equivalence between `NormedAddGroupHom M N` vanishing on the inseparable setoid and `NormedAddGroupHom (SeparationQuotient M) N`. -/ @[simps] noncomputable def liftNormedAddGroupHomEquiv {N : Type*} [SeminormedAddCommGroup N] : {f : NormedAddGroupHom M N // āˆ€ x, ‖x‖ = 0 → f x = 0} ā‰ƒ NormedAddGroupHom (SeparationQuotient M) N where toFun f := liftNormedAddGroupHom f f.prop invFun g := ⟨g.comp normedMk, by intro x hx rw [← norm_mk, norm_eq_zero] at hx simp [hx]⟩ right_inv _ := by ext x obtain ⟨x, rfl⟩ := surjective_mk x rfl /-- For a norm-continuous group homomorphism `f`, its lift to the separation quotient is bounded by the norm of `f`. -/ theorem norm_liftNormedAddGroupHom_le {N : Type*} [SeminormedAddCommGroup N] (f : NormedAddGroupHom M N) (hf : āˆ€ s, ‖s‖ = 0 → f s = 0) : ‖liftNormedAddGroupHom f hf‖ ≤ ‖f‖ := NormedAddGroupHom.opNorm_le_bound _ (norm_nonneg f) (norm_liftNormedAddGroupHom_apply_le f hf) theorem liftNormedAddGroupHom_norm_le {N : Type*} [SeminormedAddCommGroup N] (f : NormedAddGroupHom M N) (hf : āˆ€ s, ‖s‖ = 0 → f s = 0) {c : ā„ā‰„0} (fb : ‖f‖ ≤ c) : ‖liftNormedAddGroupHom f hf‖ ≤ c := (norm_liftNormedAddGroupHom_le f hf).trans fb theorem liftNormedAddGroupHom_normNoninc {N : Type*} [SeminormedAddCommGroup N] (f : NormedAddGroupHom M N) (hf : āˆ€ s, ‖s‖ = 0 → f s = 0) (fb : f.NormNoninc) : (liftNormedAddGroupHom f hf).NormNoninc := fun x => by have fb' : ‖f‖ ≤ 1 := NormedAddGroupHom.NormNoninc.normNoninc_iff_norm_le_one.mp fb exact le_trans (norm_liftNormedAddGroupHom_apply_le f hf x) (mul_le_of_le_one_left (norm_nonneg x) fb') /-- The operator norm of the projection is `1` if there is an element whose norm is different from `0`. -/ theorem norm_normedMk_eq_one (h : ∃ x : M, ‖x‖ ≠ 0) : ‖normedMk (M := M)‖ = 1 := by apply NormedAddGroupHom.opNorm_eq_of_bounds _ zero_le_one Ā· simpa only [normedMk_apply, one_mul] using fun _ ↦ le_rfl Ā· intro N _ hle obtain ⟨x, _⟩ := h exact one_le_of_le_mul_rightā‚€ (by positivity) (hle x) /-- The projection is `0` if and only if all the elements have norm `0`. -/ theorem normedMk_eq_zero_iff : normedMk (M := M) = 0 ↔ āˆ€ (x : M), ‖x‖ = 0 := by constructor Ā· intro h x rw [SeparationQuotient.mk_eq_zero_iff.mp] have : normedMk x = 0 := by rw [h] simp only [zero_apply] rw [← this] simp Ā· intro h ext x simpa [← norm_eq_zero] using h x end SeparationQuotient end
.lake/packages/mathlib/Mathlib/Analysis/Normed/Group/NullSubmodule.lean
import Mathlib.Analysis.Normed.Group.Continuity import Mathlib.Analysis.Normed.MulAction /-! # The null subgroup in a seminormed commutative group For any `SeminormedAddCommGroup M`, the quotient `SeparationQuotient M` by the null subgroup is defined as a `NormedAddCommGroup` instance in `Mathlib/Analysis/Normed/Group/Uniform.lean`. Here we define the null space as a subgroup. ## Main definitions We use `M` to denote seminormed groups. * `nullAddSubgroup` : the subgroup of elements `x` with `‖x‖ = 0`. If `E` is a vector space over `š•œ` with an appropriate continuous action, we also define the null subspace as a submodule of `E`. * `nullSubmodule` : the subspace of elements `x` with `‖x‖ = 0`. -/ variable {M : Type*} [SeminormedCommGroup M] variable (M) in /-- The null subgroup with respect to the norm. -/ @[to_additive /-- The additive null subgroup with respect to the norm. -/] def nullSubgroup : Subgroup M where carrier := {x : M | ‖x‖ = 0} mul_mem' {x y} (hx : ‖x‖ = 0) (hy : ‖y‖ = 0) := by apply le_antisymm _ (norm_nonneg' _) refine (norm_mul_le' x y).trans_eq ?_ rw [hx, hy, add_zero] one_mem' := norm_one' inv_mem' {x} (hx : ‖x‖ = 0) := by simpa only [Set.mem_setOf_eq, norm_inv'] using hx @[to_additive] lemma isClosed_nullSubgroup : IsClosed (nullSubgroup M : Set M) := by apply isClosed_singleton.preimage continuous_norm' @[to_additive (attr := simp)] lemma mem_nullSubgroup_iff {x : M} : x ∈ nullSubgroup M ↔ ‖x‖ = 0 := Iff.rfl variable {š•œ E : Type*} variable [SeminormedAddCommGroup E] [SeminormedRing š•œ] [Module š•œ E] [IsBoundedSMul š•œ E] variable (š•œ E) in /-- The null space with respect to the norm. -/ def nullSubmodule : Submodule š•œ E where __ := nullAddSubgroup E smul_mem' c x (hx : ‖x‖ = 0) := by apply le_antisymm _ (norm_nonneg _) refine (norm_smul_le _ _).trans_eq ?_ rw [hx, mul_zero] lemma isClosed_nullSubmodule : IsClosed (nullSubmodule š•œ E : Set E) := isClosed_nullAddSubgroup @[simp] lemma mem_nullSubmodule_iff {x : E} : x ∈ nullSubmodule š•œ E ↔ ‖x‖ = 0 := Iff.rfl
.lake/packages/mathlib/Mathlib/Analysis/Normed/Group/Basic.lean
import Mathlib.Analysis.Normed.Group.Seminorm import Mathlib.Data.NNReal.Basic import Mathlib.Topology.Algebra.Support import Mathlib.Topology.MetricSpace.Basic import Mathlib.Topology.Order.Real /-! # Normed (semi)groups In this file we define 10 classes: * `Norm`, `NNNorm`: auxiliary classes endowing a type `α` with a function `norm : α → ā„` (notation: `‖x‖`) and `nnnorm : α → ā„ā‰„0` (notation: `‖xā€–ā‚Š`), respectively; * `Seminormed...Group`: A seminormed (additive) (commutative) group is an (additive) (commutative) group with a norm and a compatible pseudometric space structure: `āˆ€ x y, dist x y = ‖x / y‖` or `āˆ€ x y, dist x y = ‖x - y‖`, depending on the group operation. * `Normed...Group`: A normed (additive) (commutative) group is an (additive) (commutative) group with a norm and a compatible metric space structure. We also prove basic properties of (semi)normed groups and provide some instances. ## Notes The current convention `dist x y = ‖x - y‖` means that the distance is invariant under right addition, but actions in mathlib are usually from the left. This means we might want to change it to `dist x y = ‖-x + y‖`. The normed group hierarchy would lend itself well to a mixin design (that is, having `SeminormedGroup` and `SeminormedAddGroup` not extend `Group` and `AddGroup`), but we choose not to for performance concerns. ## Tags normed group -/ variable {š“• α ι Īŗ E F G : Type*} open Filter Function Metric Bornology open ENNReal Filter NNReal Uniformity Pointwise Topology /-- Auxiliary class, endowing a type `E` with a function `norm : E → ā„` with notation `‖x‖`. This class is designed to be extended in more interesting classes specifying the properties of the norm. -/ @[notation_class] class Norm (E : Type*) where /-- the `ā„`-valued norm function. -/ norm : E → ā„ /-- Auxiliary class, endowing a type `α` with a function `nnnorm : α → ā„ā‰„0` with notation `‖xā€–ā‚Š`. -/ @[notation_class] class NNNorm (E : Type*) where /-- the `ā„ā‰„0`-valued norm function. -/ nnnorm : E → ā„ā‰„0 /-- Auxiliary class, endowing a type `α` with a function `enorm : α → ā„ā‰„0āˆž` with notation `‖x‖ₑ`. -/ @[notation_class] class ENorm (E : Type*) where /-- the `ā„ā‰„0āˆž`-valued norm function. -/ enorm : E → ā„ā‰„0āˆž export Norm (norm) export NNNorm (nnnorm) export ENorm (enorm) @[inherit_doc] notation "‖" e "‖" => norm e @[inherit_doc] notation "‖" e "ā€–ā‚Š" => nnnorm e @[inherit_doc] notation "‖" e "‖ₑ" => enorm e section ENorm variable {E : Type*} [NNNorm E] {x : E} {r : ā„ā‰„0} instance NNNorm.toENorm : ENorm E where enorm := (ā€–Ā·ā€–ā‚Š : E → ā„ā‰„0āˆž) lemma enorm_eq_nnnorm (x : E) : ‖x‖ₑ = ‖xā€–ā‚Š := rfl @[simp] lemma toNNReal_enorm (x : E) : ‖x‖ₑ.toNNReal = ‖xā€–ā‚Š := rfl @[simp, norm_cast] lemma coe_le_enorm : r ≤ ‖x‖ₑ ↔ r ≤ ‖xā€–ā‚Š := by simp [enorm] @[simp, norm_cast] lemma enorm_le_coe : ‖x‖ₑ ≤ r ↔ ‖xā€–ā‚Š ≤ r := by simp [enorm] @[simp, norm_cast] lemma coe_lt_enorm : r < ‖x‖ₑ ↔ r < ‖xā€–ā‚Š := by simp [enorm] @[simp, norm_cast] lemma enorm_lt_coe : ‖x‖ₑ < r ↔ ‖xā€–ā‚Š < r := by simp [enorm] @[aesop (rule_sets := [finiteness]) safe apply, simp] lemma enorm_ne_top : ‖x‖ₑ ≠ āˆž := by simp [enorm] @[simp] lemma enorm_lt_top : ‖x‖ₑ < āˆž := by simp [enorm] end ENorm /-- A type `E` equipped with a continuous map `‖·‖ₑ : E → ā„ā‰„0āˆž` NB. We do not demand that the topology is somehow defined by the enorm: for `ā„ā‰„0āˆž` (the motivating example behind this definition), this is not true. -/ class ContinuousENorm (E : Type*) [TopologicalSpace E] extends ENorm E where continuous_enorm : Continuous enorm /-- An e-seminormed monoid is an additive monoid endowed with a continuous enorm. Note that we do not ask for the enorm to be positive definite: non-trivial elements may have enorm zero. -/ class ESeminormedAddMonoid (E : Type*) [TopologicalSpace E] extends ContinuousENorm E, AddMonoid E where enorm_zero : ‖(0 : E)‖ₑ = 0 protected enorm_add_le : āˆ€ x y : E, ‖x + y‖ₑ ≤ ‖x‖ₑ + ‖y‖ₑ /-- An enormed monoid is an additive monoid endowed with a continuous enorm, which is positive definite: in other words, this is an `ESeminormedAddMonoid` with a positive definiteness condition added. -/ class ENormedAddMonoid (E : Type*) [TopologicalSpace E] extends ESeminormedAddMonoid E where enorm_eq_zero : āˆ€ x : E, ‖x‖ₑ = 0 ↔ x = 0 /-- An e-seminormed monoid is a monoid endowed with a continuous enorm. Note that we only ask for the enorm to be a semi-norm: non-trivial elements may have enorm zero. -/ @[to_additive] class ESeminormedMonoid (E : Type*) [TopologicalSpace E] extends ContinuousENorm E, Monoid E where enorm_zero : ‖(1 : E)‖ₑ = 0 enorm_mul_le : āˆ€ x y : E, ‖x * y‖ₑ ≤ ‖x‖ₑ + ‖y‖ₑ /-- An enormed monoid is a monoid endowed with a continuous enorm, which is positive definite: in other words, this is an `ESeminormedMonoid` with a positive definiteness condition added. -/ @[to_additive] class ENormedMonoid (E : Type*) [TopologicalSpace E] extends ESeminormedMonoid E where enorm_eq_zero : āˆ€ x : E, ‖x‖ₑ = 0 ↔ x = 1 /-- An e-seminormed commutative monoid is an additive commutative monoid endowed with a continuous enorm. We don't have `ESeminormedAddCommMonoid` extend `EMetricSpace`, since the canonical instance `ā„ā‰„0āˆž` is not an `EMetricSpace`. This is because `ā„ā‰„0āˆž` carries the order topology, which is distinct from the topology coming from `edist`. -/ class ESeminormedAddCommMonoid (E : Type*) [TopologicalSpace E] extends ESeminormedAddMonoid E, AddCommMonoid E where /-- An enormed commutative monoid is an additive commutative monoid endowed with a continuous enorm which is positive definite. We don't have `ENormedAddCommMonoid` extend `EMetricSpace`, since the canonical instance `ā„ā‰„0āˆž` is not an `EMetricSpace`. This is because `ā„ā‰„0āˆž` carries the order topology, which is distinct from the topology coming from `edist`. -/ class ENormedAddCommMonoid (E : Type*) [TopologicalSpace E] extends ESeminormedAddCommMonoid E, ENormedAddMonoid E where /-- An e-seminormed commutative monoid is a commutative monoid endowed with a continuous enorm. -/ @[to_additive] class ESeminormedCommMonoid (E : Type*) [TopologicalSpace E] extends ESeminormedMonoid E, CommMonoid E where /-- An enormed commutative monoid is a commutative monoid endowed with a continuous enorm which is positive definite. -/ @[to_additive] class ENormedCommMonoid (E : Type*) [TopologicalSpace E] extends ESeminormedCommMonoid E, ENormedMonoid E where /-- A seminormed group is an additive group endowed with a norm for which `dist x y = ‖x - y‖` defines a pseudometric space structure. -/ class SeminormedAddGroup (E : Type*) extends Norm E, AddGroup E, PseudoMetricSpace E where dist := fun x y => ‖x - y‖ /-- The distance function is induced by the norm. -/ dist_eq : āˆ€ x y, dist x y = ‖x - y‖ := by aesop /-- A seminormed group is a group endowed with a norm for which `dist x y = ‖x / y‖` defines a pseudometric space structure. -/ @[to_additive] class SeminormedGroup (E : Type*) extends Norm E, Group E, PseudoMetricSpace E where dist := fun x y => ‖x / y‖ /-- The distance function is induced by the norm. -/ dist_eq : āˆ€ x y, dist x y = ‖x / y‖ := by aesop /-- A normed group is an additive group endowed with a norm for which `dist x y = ‖x - y‖` defines a metric space structure. -/ class NormedAddGroup (E : Type*) extends Norm E, AddGroup E, MetricSpace E where dist := fun x y => ‖x - y‖ /-- The distance function is induced by the norm. -/ dist_eq : āˆ€ x y, dist x y = ‖x - y‖ := by aesop /-- A normed group is a group endowed with a norm for which `dist x y = ‖x / y‖` defines a metric space structure. -/ @[to_additive] class NormedGroup (E : Type*) extends Norm E, Group E, MetricSpace E where dist := fun x y => ‖x / y‖ /-- The distance function is induced by the norm. -/ dist_eq : āˆ€ x y, dist x y = ‖x / y‖ := by aesop /-- A seminormed group is an additive group endowed with a norm for which `dist x y = ‖x - y‖` defines a pseudometric space structure. -/ class SeminormedAddCommGroup (E : Type*) extends Norm E, AddCommGroup E, PseudoMetricSpace E where dist := fun x y => ‖x - y‖ /-- The distance function is induced by the norm. -/ dist_eq : āˆ€ x y, dist x y = ‖x - y‖ := by aesop /-- A seminormed group is a group endowed with a norm for which `dist x y = ‖x / y‖` defines a pseudometric space structure. -/ @[to_additive] class SeminormedCommGroup (E : Type*) extends Norm E, CommGroup E, PseudoMetricSpace E where dist := fun x y => ‖x / y‖ /-- The distance function is induced by the norm. -/ dist_eq : āˆ€ x y, dist x y = ‖x / y‖ := by aesop /-- A normed group is an additive group endowed with a norm for which `dist x y = ‖x - y‖` defines a metric space structure. -/ class NormedAddCommGroup (E : Type*) extends Norm E, AddCommGroup E, MetricSpace E where dist := fun x y => ‖x - y‖ /-- The distance function is induced by the norm. -/ dist_eq : āˆ€ x y, dist x y = ‖x - y‖ := by aesop /-- A normed group is a group endowed with a norm for which `dist x y = ‖x / y‖` defines a metric space structure. -/ @[to_additive] class NormedCommGroup (E : Type*) extends Norm E, CommGroup E, MetricSpace E where dist := fun x y => ‖x / y‖ /-- The distance function is induced by the norm. -/ dist_eq : āˆ€ x y, dist x y = ‖x / y‖ := by aesop -- See note [lower instance priority] @[to_additive] instance (priority := 100) NormedGroup.toSeminormedGroup [NormedGroup E] : SeminormedGroup E := { ‹NormedGroup E› with } -- See note [lower instance priority] @[to_additive] instance (priority := 100) NormedCommGroup.toSeminormedCommGroup [NormedCommGroup E] : SeminormedCommGroup E := { ‹NormedCommGroup E› with } -- See note [lower instance priority] @[to_additive] instance (priority := 100) SeminormedCommGroup.toSeminormedGroup [SeminormedCommGroup E] : SeminormedGroup E := { ‹SeminormedCommGroup E› with } -- See note [lower instance priority] @[to_additive] instance (priority := 100) NormedCommGroup.toNormedGroup [NormedCommGroup E] : NormedGroup E := { ‹NormedCommGroup E› with } -- See note [reducible non-instances] /-- Construct a `NormedGroup` from a `SeminormedGroup` satisfying `āˆ€ x, ‖x‖ = 0 → x = 1`. This avoids having to go back to the `(Pseudo)MetricSpace` level when declaring a `NormedGroup` instance as a special case of a more general `SeminormedGroup` instance. -/ @[to_additive /-- Construct a `NormedAddGroup` from a `SeminormedAddGroup` satisfying `āˆ€ x, ‖x‖ = 0 → x = 0`. This avoids having to go back to the `(Pseudo)MetricSpace` level when declaring a `NormedAddGroup` instance as a special case of a more general `SeminormedAddGroup` instance. -/] abbrev NormedGroup.ofSeparation [SeminormedGroup E] (h : āˆ€ x : E, ‖x‖ = 0 → x = 1) : NormedGroup E where dist_eq := ‹SeminormedGroup E›.dist_eq toMetricSpace := { eq_of_dist_eq_zero := fun hxy => div_eq_one.1 <| h _ <| (‹SeminormedGroup E›.dist_eq _ _).symm.trans hxy } -- See note [reducible non-instances] /-- Construct a `NormedCommGroup` from a `SeminormedCommGroup` satisfying `āˆ€ x, ‖x‖ = 0 → x = 1`. This avoids having to go back to the `(Pseudo)MetricSpace` level when declaring a `NormedCommGroup` instance as a special case of a more general `SeminormedCommGroup` instance. -/ @[to_additive /-- Construct a `NormedAddCommGroup` from a `SeminormedAddCommGroup` satisfying `āˆ€ x, ‖x‖ = 0 → x = 0`. This avoids having to go back to the `(Pseudo)MetricSpace` level when declaring a `NormedAddCommGroup` instance as a special case of a more general `SeminormedAddCommGroup` instance. -/] abbrev NormedCommGroup.ofSeparation [SeminormedCommGroup E] (h : āˆ€ x : E, ‖x‖ = 0 → x = 1) : NormedCommGroup E := { ‹SeminormedCommGroup E›, NormedGroup.ofSeparation h with } -- See note [reducible non-instances] /-- Construct a seminormed group from a multiplication-invariant distance. -/ @[to_additive /-- Construct a seminormed group from a translation-invariant distance. -/] abbrev SeminormedGroup.ofMulDist [Norm E] [Group E] [PseudoMetricSpace E] (h₁ : āˆ€ x : E, ‖x‖ = dist x 1) (hā‚‚ : āˆ€ x y z : E, dist x y ≤ dist (x * z) (y * z)) : SeminormedGroup E where dist_eq x y := by rw [h₁]; apply le_antisymm Ā· simpa only [div_eq_mul_inv, ← mul_inv_cancel y] using hā‚‚ _ _ _ Ā· simpa only [div_mul_cancel, one_mul] using hā‚‚ (x / y) 1 y -- See note [reducible non-instances] /-- Construct a seminormed group from a multiplication-invariant pseudodistance. -/ @[to_additive /-- Construct a seminormed group from a translation-invariant pseudodistance. -/] abbrev SeminormedGroup.ofMulDist' [Norm E] [Group E] [PseudoMetricSpace E] (h₁ : āˆ€ x : E, ‖x‖ = dist x 1) (hā‚‚ : āˆ€ x y z : E, dist (x * z) (y * z) ≤ dist x y) : SeminormedGroup E where dist_eq x y := by rw [h₁]; apply le_antisymm Ā· simpa only [div_mul_cancel, one_mul] using hā‚‚ (x / y) 1 y Ā· simpa only [div_eq_mul_inv, ← mul_inv_cancel y] using hā‚‚ _ _ _ -- See note [reducible non-instances] /-- Construct a seminormed group from a multiplication-invariant pseudodistance. -/ @[to_additive /-- Construct a seminormed group from a translation-invariant pseudodistance. -/] abbrev SeminormedCommGroup.ofMulDist [Norm E] [CommGroup E] [PseudoMetricSpace E] (h₁ : āˆ€ x : E, ‖x‖ = dist x 1) (hā‚‚ : āˆ€ x y z : E, dist x y ≤ dist (x * z) (y * z)) : SeminormedCommGroup E := { SeminormedGroup.ofMulDist h₁ hā‚‚ with mul_comm := mul_comm } -- See note [reducible non-instances] /-- Construct a seminormed group from a multiplication-invariant pseudodistance. -/ @[to_additive /-- Construct a seminormed group from a translation-invariant pseudodistance. -/] abbrev SeminormedCommGroup.ofMulDist' [Norm E] [CommGroup E] [PseudoMetricSpace E] (h₁ : āˆ€ x : E, ‖x‖ = dist x 1) (hā‚‚ : āˆ€ x y z : E, dist (x * z) (y * z) ≤ dist x y) : SeminormedCommGroup E := { SeminormedGroup.ofMulDist' h₁ hā‚‚ with mul_comm := mul_comm } -- See note [reducible non-instances] /-- Construct a normed group from a multiplication-invariant distance. -/ @[to_additive /-- Construct a normed group from a translation-invariant distance. -/] abbrev NormedGroup.ofMulDist [Norm E] [Group E] [MetricSpace E] (h₁ : āˆ€ x : E, ‖x‖ = dist x 1) (hā‚‚ : āˆ€ x y z : E, dist x y ≤ dist (x * z) (y * z)) : NormedGroup E := { SeminormedGroup.ofMulDist h₁ hā‚‚ with eq_of_dist_eq_zero := eq_of_dist_eq_zero } -- See note [reducible non-instances] /-- Construct a normed group from a multiplication-invariant pseudodistance. -/ @[to_additive /-- Construct a normed group from a translation-invariant pseudodistance. -/] abbrev NormedGroup.ofMulDist' [Norm E] [Group E] [MetricSpace E] (h₁ : āˆ€ x : E, ‖x‖ = dist x 1) (hā‚‚ : āˆ€ x y z : E, dist (x * z) (y * z) ≤ dist x y) : NormedGroup E := { SeminormedGroup.ofMulDist' h₁ hā‚‚ with eq_of_dist_eq_zero := eq_of_dist_eq_zero } -- See note [reducible non-instances] /-- Construct a normed group from a multiplication-invariant pseudodistance. -/ @[to_additive /-- Construct a normed group from a translation-invariant pseudodistance. -/] abbrev NormedCommGroup.ofMulDist [Norm E] [CommGroup E] [MetricSpace E] (h₁ : āˆ€ x : E, ‖x‖ = dist x 1) (hā‚‚ : āˆ€ x y z : E, dist x y ≤ dist (x * z) (y * z)) : NormedCommGroup E := { NormedGroup.ofMulDist h₁ hā‚‚ with mul_comm := mul_comm } -- See note [reducible non-instances] /-- Construct a normed group from a multiplication-invariant pseudodistance. -/ @[to_additive /-- Construct a normed group from a translation-invariant pseudodistance. -/] abbrev NormedCommGroup.ofMulDist' [Norm E] [CommGroup E] [MetricSpace E] (h₁ : āˆ€ x : E, ‖x‖ = dist x 1) (hā‚‚ : āˆ€ x y z : E, dist (x * z) (y * z) ≤ dist x y) : NormedCommGroup E := { NormedGroup.ofMulDist' h₁ hā‚‚ with mul_comm := mul_comm } -- See note [reducible non-instances] /-- Construct a seminormed group from a seminorm, i.e., registering the pseudodistance and the pseudometric space structure from the seminorm properties. Note that in most cases this instance creates bad definitional equalities (e.g., it does not take into account a possibly existing `UniformSpace` instance on `E`). -/ @[to_additive /-- Construct a seminormed group from a seminorm, i.e., registering the pseudodistance and the pseudometric space structure from the seminorm properties. Note that in most cases this instance creates bad definitional equalities (e.g., it does not take into account a possibly existing `UniformSpace` instance on `E`). -/] abbrev GroupSeminorm.toSeminormedGroup [Group E] (f : GroupSeminorm E) : SeminormedGroup E where dist x y := f (x / y) norm := f dist_eq _ _ := rfl dist_self x := by simp only [div_self', map_one_eq_zero] dist_triangle := le_map_div_add_map_div f dist_comm := map_div_rev f -- See note [reducible non-instances] /-- Construct a seminormed group from a seminorm, i.e., registering the pseudodistance and the pseudometric space structure from the seminorm properties. Note that in most cases this instance creates bad definitional equalities (e.g., it does not take into account a possibly existing `UniformSpace` instance on `E`). -/ @[to_additive /-- Construct a seminormed group from a seminorm, i.e., registering the pseudodistance and the pseudometric space structure from the seminorm properties. Note that in most cases this instance creates bad definitional equalities (e.g., it does not take into account a possibly existing `UniformSpace` instance on `E`). -/] abbrev GroupSeminorm.toSeminormedCommGroup [CommGroup E] (f : GroupSeminorm E) : SeminormedCommGroup E := { f.toSeminormedGroup with mul_comm := mul_comm } -- See note [reducible non-instances] /-- Construct a normed group from a norm, i.e., registering the distance and the metric space structure from the norm properties. Note that in most cases this instance creates bad definitional equalities (e.g., it does not take into account a possibly existing `UniformSpace` instance on `E`). -/ @[to_additive /-- Construct a normed group from a norm, i.e., registering the distance and the metric space structure from the norm properties. Note that in most cases this instance creates bad definitional equalities (e.g., it does not take into account a possibly existing `UniformSpace` instance on `E`). -/] abbrev GroupNorm.toNormedGroup [Group E] (f : GroupNorm E) : NormedGroup E := { f.toGroupSeminorm.toSeminormedGroup with eq_of_dist_eq_zero := fun h => div_eq_one.1 <| eq_one_of_map_eq_zero f h } -- See note [reducible non-instances] /-- Construct a normed group from a norm, i.e., registering the distance and the metric space structure from the norm properties. Note that in most cases this instance creates bad definitional equalities (e.g., it does not take into account a possibly existing `UniformSpace` instance on `E`). -/ @[to_additive /-- Construct a normed group from a norm, i.e., registering the distance and the metric space structure from the norm properties. Note that in most cases this instance creates bad definitional equalities (e.g., it does not take into account a possibly existing `UniformSpace` instance on `E`). -/] abbrev GroupNorm.toNormedCommGroup [CommGroup E] (f : GroupNorm E) : NormedCommGroup E := { f.toNormedGroup with mul_comm := mul_comm } section SeminormedGroup variable [SeminormedGroup E] [SeminormedGroup F] [SeminormedGroup G] {s : Set E} {a a₁ aā‚‚ b c : E} {r r₁ rā‚‚ : ā„} @[to_additive] theorem dist_eq_norm_div (a b : E) : dist a b = ‖a / b‖ := SeminormedGroup.dist_eq _ _ @[to_additive] theorem dist_eq_norm_div' (a b : E) : dist a b = ‖b / a‖ := by rw [dist_comm, dist_eq_norm_div] alias dist_eq_norm := dist_eq_norm_sub alias dist_eq_norm' := dist_eq_norm_sub' @[to_additive of_forall_le_norm] lemma DiscreteTopology.of_forall_le_norm' (hpos : 0 < r) (hr : āˆ€ x : E, x ≠ 1 → r ≤ ‖x‖) : DiscreteTopology E := .of_forall_le_dist hpos fun x y hne ↦ by simp only [dist_eq_norm_div] exact hr _ (div_ne_one.2 hne) @[to_additive (attr := simp)] theorem dist_one_right (a : E) : dist a 1 = ‖a‖ := by rw [dist_eq_norm_div, div_one] @[to_additive] theorem inseparable_one_iff_norm {a : E} : Inseparable a 1 ↔ ‖a‖ = 0 := by rw [Metric.inseparable_iff, dist_one_right] @[to_additive] lemma dist_one_left (a : E) : dist 1 a = ‖a‖ := by rw [dist_comm, dist_one_right] @[to_additive (attr := simp)] lemma dist_one : dist (1 : E) = norm := funext dist_one_left @[to_additive] theorem norm_div_rev (a b : E) : ‖a / b‖ = ‖b / a‖ := by simpa only [dist_eq_norm_div] using dist_comm a b @[to_additive (attr := simp) norm_neg] theorem norm_inv' (a : E) : ‖a⁻¹‖ = ‖a‖ := by simpa using norm_div_rev 1 a @[to_additive (attr := simp) norm_abs_zsmul] theorem norm_zpow_abs (a : E) (n : ℤ) : ‖a ^ |n|‖ = ‖a ^ n‖ := by rcases le_total 0 n with hn | hn <;> simp [hn, abs_of_nonneg, abs_of_nonpos] @[to_additive (attr := simp) norm_natAbs_smul] theorem norm_pow_natAbs (a : E) (n : ℤ) : ‖a ^ n.natAbs‖ = ‖a ^ n‖ := by rw [← zpow_natCast, ← Int.abs_eq_natAbs, norm_zpow_abs] @[to_additive norm_isUnit_zsmul] theorem norm_zpow_isUnit (a : E) {n : ℤ} (hn : IsUnit n) : ‖a ^ n‖ = ‖a‖ := by rw [← norm_pow_natAbs, Int.isUnit_iff_natAbs_eq.mp hn, pow_one] @[simp] theorem norm_units_zsmul {E : Type*} [SeminormedAddGroup E] (n : ℤˣ) (a : E) : ‖n • a‖ = ‖a‖ := norm_isUnit_zsmul a n.isUnit open scoped symmDiff in @[to_additive] theorem dist_mulIndicator (s t : Set α) (f : α → E) (x : α) : dist (s.mulIndicator f x) (t.mulIndicator f x) = ‖(s āˆ† t).mulIndicator f x‖ := by rw [dist_eq_norm_div, Set.apply_mulIndicator_symmDiff norm_inv'] /-- **Triangle inequality** for the norm. -/ @[to_additive norm_add_le /-- **Triangle inequality** for the norm. -/] theorem norm_mul_le' (a b : E) : ‖a * b‖ ≤ ‖a‖ + ‖b‖ := by simpa [dist_eq_norm_div] using dist_triangle a 1 b⁻¹ /-- **Triangle inequality** for the norm. -/ @[to_additive norm_add_le_of_le /-- **Triangle inequality** for the norm. -/] theorem norm_mul_le_of_le' (h₁ : ‖a₁‖ ≤ r₁) (hā‚‚ : ‖a₂‖ ≤ rā‚‚) : ‖a₁ * a₂‖ ≤ r₁ + rā‚‚ := (norm_mul_le' a₁ aā‚‚).trans <| add_le_add h₁ hā‚‚ /-- **Triangle inequality** for the norm. -/ @[to_additive norm_addā‚ƒ_le /-- **Triangle inequality** for the norm. -/] lemma norm_mulā‚ƒ_le' : ‖a * b * c‖ ≤ ‖a‖ + ‖b‖ + ‖c‖ := norm_mul_le_of_le' (norm_mul_le' _ _) le_rfl @[to_additive] lemma norm_div_le_norm_div_add_norm_div (a b c : E) : ‖a / c‖ ≤ ‖a / b‖ + ‖b / c‖ := by simpa only [dist_eq_norm_div] using dist_triangle a b c @[to_additive] lemma norm_le_norm_div_add (a b : E) : ‖a‖ ≤ ‖a / b‖ + ‖b‖ := by simpa only [div_one] using norm_div_le_norm_div_add_norm_div a b 1 @[to_additive (attr := simp) norm_nonneg] theorem norm_nonneg' (a : E) : 0 ≤ ‖a‖ := by rw [← dist_one_right] exact dist_nonneg attribute [bound] norm_nonneg @[to_additive (attr := simp) abs_norm] theorem abs_norm' (z : E) : |‖z‖| = ‖z‖ := abs_of_nonneg <| norm_nonneg' _ @[to_additive (attr := simp) norm_zero] theorem norm_one' : ‖(1 : E)‖ = 0 := by rw [← dist_one_right, dist_self] @[to_additive] theorem ne_one_of_norm_ne_zero : ‖a‖ ≠ 0 → a ≠ 1 := mt <| by rintro rfl exact norm_one' @[to_additive (attr := nontriviality) norm_of_subsingleton] theorem norm_of_subsingleton' [Subsingleton E] (a : E) : ‖a‖ = 0 := by rw [Subsingleton.elim a 1, norm_one'] @[to_additive zero_lt_one_add_norm_sq] theorem zero_lt_one_add_norm_sq' (x : E) : 0 < 1 + ‖x‖ ^ 2 := by positivity @[to_additive] theorem norm_div_le (a b : E) : ‖a / b‖ ≤ ‖a‖ + ‖b‖ := by simpa [dist_eq_norm_div] using dist_triangle a 1 b attribute [bound] norm_sub_le @[to_additive] theorem norm_div_le_of_le {r₁ rā‚‚ : ā„} (H₁ : ‖a₁‖ ≤ r₁) (Hā‚‚ : ‖a₂‖ ≤ rā‚‚) : ‖a₁ / a₂‖ ≤ r₁ + rā‚‚ := (norm_div_le a₁ aā‚‚).trans <| add_le_add H₁ Hā‚‚ @[to_additive dist_le_norm_add_norm] theorem dist_le_norm_add_norm' (a b : E) : dist a b ≤ ‖a‖ + ‖b‖ := by rw [dist_eq_norm_div] apply norm_div_le @[to_additive abs_norm_sub_norm_le] theorem abs_norm_sub_norm_le' (a b : E) : |‖a‖ - ‖b‖| ≤ ‖a / b‖ := by simpa [dist_eq_norm_div] using abs_dist_sub_le a b 1 @[to_additive norm_sub_norm_le] theorem norm_sub_norm_le' (a b : E) : ‖a‖ - ‖b‖ ≤ ‖a / b‖ := (le_abs_self _).trans (abs_norm_sub_norm_le' a b) @[to_additive (attr := bound)] theorem norm_sub_le_norm_mul (a b : E) : ‖a‖ - ‖b‖ ≤ ‖a * b‖ := by simpa using norm_mul_le' (a * b) (b⁻¹) @[to_additive dist_norm_norm_le] theorem dist_norm_norm_le' (a b : E) : dist ‖a‖ ‖b‖ ≤ ‖a / b‖ := abs_norm_sub_norm_le' a b @[to_additive] theorem norm_le_norm_add_norm_div' (u v : E) : ‖u‖ ≤ ‖v‖ + ‖u / v‖ := by rw [add_comm] refine (norm_mul_le' _ _).trans_eq' ?_ rw [div_mul_cancel] @[to_additive] theorem norm_le_norm_add_norm_div (u v : E) : ‖v‖ ≤ ‖u‖ + ‖u / v‖ := by rw [norm_div_rev] exact norm_le_norm_add_norm_div' v u alias norm_le_insert' := norm_le_norm_add_norm_sub' alias norm_le_insert := norm_le_norm_add_norm_sub @[to_additive] theorem norm_le_mul_norm_add (u v : E) : ‖u‖ ≤ ‖u * v‖ + ‖v‖ := calc ‖u‖ = ‖u * v / v‖ := by rw [mul_div_cancel_right] _ ≤ ‖u * v‖ + ‖v‖ := norm_div_le _ _ /-- An analogue of `norm_le_mul_norm_add` for the multiplication from the left. -/ @[to_additive /-- An analogue of `norm_le_add_norm_add` for the addition from the left. -/] theorem norm_le_mul_norm_add' (u v : E) : ‖v‖ ≤ ‖u * v‖ + ‖u‖ := calc ‖v‖ = ‖u⁻¹ * (u * v)‖ := by rw [← mul_assoc, inv_mul_cancel, one_mul] _ ≤ ‖u⁻¹‖ + ‖u * v‖ := norm_mul_le' u⁻¹ (u * v) _ = ‖u * v‖ + ‖u‖ := by rw [norm_inv', add_comm] @[to_additive] lemma norm_mul_eq_norm_right {x : E} (y : E) (h : ‖x‖ = 0) : ‖x * y‖ = ‖y‖ := by apply le_antisymm ?_ ?_ Ā· simpa [h] using norm_mul_le' x y Ā· simpa [h] using norm_le_mul_norm_add' x y @[to_additive] lemma norm_mul_eq_norm_left (x : E) {y : E} (h : ‖y‖ = 0) : ‖x * y‖ = ‖x‖ := by apply le_antisymm ?_ ?_ Ā· simpa [h] using norm_mul_le' x y Ā· simpa [h] using norm_le_mul_norm_add x y @[to_additive] lemma norm_div_eq_norm_right {x : E} (y : E) (h : ‖x‖ = 0) : ‖x / y‖ = ‖y‖ := by apply le_antisymm ?_ ?_ Ā· simpa [h] using norm_div_le x y Ā· simpa [h, norm_div_rev x y] using norm_sub_norm_le' y x @[to_additive] lemma norm_div_eq_norm_left (x : E) {y : E} (h : ‖y‖ = 0) : ‖x / y‖ = ‖x‖ := by apply le_antisymm ?_ ?_ Ā· simpa [h] using norm_div_le x y Ā· simpa [h] using norm_sub_norm_le' x y @[to_additive ball_eq] theorem ball_eq' (y : E) (ε : ā„) : ball y ε = { x | ‖x / y‖ < ε } := Set.ext fun a => by simp [dist_eq_norm_div] @[to_additive] theorem ball_one_eq (r : ā„) : ball (1 : E) r = { x | ‖x‖ < r } := Set.ext fun a => by simp @[to_additive mem_ball_iff_norm] theorem mem_ball_iff_norm'' : b ∈ ball a r ↔ ‖b / a‖ < r := by rw [mem_ball, dist_eq_norm_div] @[to_additive mem_ball_iff_norm'] theorem mem_ball_iff_norm''' : b ∈ ball a r ↔ ‖a / b‖ < r := by rw [mem_ball', dist_eq_norm_div] @[to_additive] theorem mem_ball_one_iff : a ∈ ball (1 : E) r ↔ ‖a‖ < r := by rw [mem_ball, dist_one_right] @[to_additive mem_closedBall_iff_norm] theorem mem_closedBall_iff_norm'' : b ∈ closedBall a r ↔ ‖b / a‖ ≤ r := by rw [mem_closedBall, dist_eq_norm_div] @[to_additive] theorem mem_closedBall_one_iff : a ∈ closedBall (1 : E) r ↔ ‖a‖ ≤ r := by rw [mem_closedBall, dist_one_right] @[to_additive mem_closedBall_iff_norm'] theorem mem_closedBall_iff_norm''' : b ∈ closedBall a r ↔ ‖a / b‖ ≤ r := by rw [mem_closedBall', dist_eq_norm_div] @[to_additive norm_le_of_mem_closedBall] theorem norm_le_of_mem_closedBall' (h : b ∈ closedBall a r) : ‖b‖ ≤ ‖a‖ + r := (norm_le_norm_add_norm_div' _ _).trans <| add_le_add_left (by rwa [← dist_eq_norm_div]) _ @[to_additive norm_le_norm_add_const_of_dist_le] theorem norm_le_norm_add_const_of_dist_le' : dist a b ≤ r → ‖a‖ ≤ ‖b‖ + r := norm_le_of_mem_closedBall' @[to_additive norm_lt_of_mem_ball] theorem norm_lt_of_mem_ball' (h : b ∈ ball a r) : ‖b‖ < ‖a‖ + r := (norm_le_norm_add_norm_div' _ _).trans_lt <| add_lt_add_left (by rwa [← dist_eq_norm_div]) _ @[to_additive] theorem norm_div_sub_norm_div_le_norm_div (u v w : E) : ‖u / w‖ - ‖v / w‖ ≤ ‖u / v‖ := by simpa only [div_div_div_cancel_right] using norm_sub_norm_le' (u / w) (v / w) @[to_additive norm_add_sub_norm_sub_le_two_mul] lemma norm_mul_sub_norm_div_le_two_mul {E : Type*} [SeminormedGroup E] (u v : E) : ‖u * v‖ - ‖u / v‖ ≤ 2 * ‖v‖ := by simpa [- tsub_le_iff_right, tsub_le_iff_left, two_mul, add_assoc] using norm_mulā‚ƒ_le' (a := (u / v)) (b := v) (c := v) @[to_additive norm_add_sub_norm_sub_le_two_mul_min] lemma norm_mul_sub_norm_div_le_two_mul_min {E : Type*} [SeminormedCommGroup E] (u v : E) : ‖u * v‖ - ‖u / v‖ ≤ 2 * min ‖u‖ ‖v‖ := by rw [mul_min_of_nonneg _ _ (by positivity)] refine le_min ?_ (norm_mul_sub_norm_div_le_two_mul u v) rw [norm_div_rev, mul_comm] exact norm_mul_sub_norm_div_le_two_mul _ _ -- Higher priority to fire before `mem_sphere`. @[to_additive (attr := simp high) mem_sphere_iff_norm] theorem mem_sphere_iff_norm' : b ∈ sphere a r ↔ ‖b / a‖ = r := by simp [dist_eq_norm_div] @[to_additive] -- `simp` can prove this theorem mem_sphere_one_iff_norm : a ∈ sphere (1 : E) r ↔ ‖a‖ = r := by simp @[to_additive (attr := simp) norm_eq_of_mem_sphere] theorem norm_eq_of_mem_sphere' (x : sphere (1 : E) r) : ‖(x : E)‖ = r := mem_sphere_one_iff_norm.mp x.2 @[to_additive] theorem ne_one_of_mem_sphere (hr : r ≠ 0) (x : sphere (1 : E) r) : (x : E) ≠ 1 := ne_one_of_norm_ne_zero <| by rwa [norm_eq_of_mem_sphere' x] @[to_additive ne_zero_of_mem_unit_sphere] theorem ne_one_of_mem_unit_sphere (x : sphere (1 : E) 1) : (x : E) ≠ 1 := ne_one_of_mem_sphere one_ne_zero _ variable (E) /-- The norm of a seminormed group as a group seminorm. -/ @[to_additive /-- The norm of a seminormed group as an additive group seminorm. -/] def normGroupSeminorm : GroupSeminorm E := ⟨norm, norm_one', norm_mul_le', norm_inv'⟩ @[to_additive (attr := simp)] theorem coe_normGroupSeminorm : ⇑(normGroupSeminorm E) = norm := rfl variable {E} @[to_additive] theorem NormedCommGroup.tendsto_nhds_one {f : α → E} {l : Filter α} : Tendsto f l (š“ 1) ↔ āˆ€ ε > 0, āˆ€į¶  x in l, ‖f x‖ < ε := Metric.tendsto_nhds.trans <| by simp only [dist_one_right] @[to_additive] theorem NormedCommGroup.tendsto_nhds_nhds {f : E → F} {x : E} {y : F} : Tendsto f (š“ x) (š“ y) ↔ āˆ€ ε > 0, ∃ Ī“ > 0, āˆ€ x', ‖x' / x‖ < Ī“ → ‖f x' / y‖ < ε := by simp_rw [Metric.tendsto_nhds_nhds, dist_eq_norm_div] @[to_additive] theorem NormedCommGroup.nhds_basis_norm_lt (x : E) : (š“ x).HasBasis (fun ε : ā„ => 0 < ε) fun ε => { y | ‖y / x‖ < ε } := by simp_rw [← ball_eq'] exact Metric.nhds_basis_ball @[to_additive] theorem NormedCommGroup.nhds_one_basis_norm_lt : (š“ (1 : E)).HasBasis (fun ε : ā„ => 0 < ε) fun ε => { y | ‖y‖ < ε } := by convert NormedCommGroup.nhds_basis_norm_lt (1 : E) simp @[to_additive] theorem NormedCommGroup.uniformity_basis_dist : (š“¤ E).HasBasis (fun ε : ā„ => 0 < ε) fun ε => { p : E Ɨ E | ‖p.fst / p.snd‖ < ε } := by convert Metric.uniformity_basis_dist (α := E) using 1 simp [dist_eq_norm_div] open Finset variable [FunLike š“• E F] section NNNorm -- See note [lower instance priority] @[to_additive] instance (priority := 100) SeminormedGroup.toNNNorm : NNNorm E := ⟨fun a => āŸØā€–a‖, norm_nonneg' a⟩⟩ @[to_additive (attr := simp, norm_cast) coe_nnnorm] theorem coe_nnnorm' (a : E) : (‖aā€–ā‚Š : ā„) = ‖a‖ := rfl @[to_additive (attr := simp) coe_comp_nnnorm] theorem coe_comp_nnnorm' : (toReal : ā„ā‰„0 → ā„) ∘ (nnnorm : E → ā„ā‰„0) = norm := rfl @[to_additive (attr := simp) norm_toNNReal] theorem norm_toNNReal' : ‖a‖.toNNReal = ‖aā€–ā‚Š := @Real.toNNReal_coe ‖aā€–ā‚Š @[to_additive (attr := simp) toReal_enorm] lemma toReal_enorm' (x : E) : ‖x‖ₑ.toReal = ‖x‖ := by simp [enorm] @[to_additive (attr := simp) ofReal_norm] lemma ofReal_norm' (x : E) : .ofReal ‖x‖ = ‖x‖ₑ := by simp [enorm, ENNReal.ofReal, Real.toNNReal, nnnorm] @[to_additive enorm_eq_iff_norm_eq] theorem enorm'_eq_iff_norm_eq {x : E} {y : F} : ‖x‖ₑ = ‖y‖ₑ ↔ ‖x‖ = ‖y‖ := by simp only [← ofReal_norm'] refine ⟨fun h ↦ ?_, fun h ↦ by congr⟩ exact (Real.toNNReal_eq_toNNReal_iff (norm_nonneg' _) (norm_nonneg' _)).mp (ENNReal.coe_inj.mp h) @[to_additive enorm_le_iff_norm_le] theorem enorm'_le_iff_norm_le {x : E} {y : F} : ‖x‖ₑ ≤ ‖y‖ₑ ↔ ‖x‖ ≤ ‖y‖ := by simp only [← ofReal_norm'] refine ⟨fun h ↦ ?_, fun h ↦ by gcongr⟩ rw [ENNReal.ofReal_le_ofReal_iff (norm_nonneg' _)] at h exact h @[to_additive] theorem nndist_eq_nnnorm_div (a b : E) : nndist a b = ‖a / bā€–ā‚Š := NNReal.eq <| dist_eq_norm_div _ _ alias nndist_eq_nnnorm := nndist_eq_nnnorm_sub @[to_additive (attr := simp)] theorem nndist_one_right (a : E) : nndist a 1 = ‖aā€–ā‚Š := by simp [nndist_eq_nnnorm_div] @[to_additive (attr := simp)] lemma edist_one_right (a : E) : edist a 1 = ‖a‖ₑ := by simp [edist_nndist, nndist_one_right, enorm] @[to_additive (attr := simp) nnnorm_zero] theorem nnnorm_one' : ‖(1 : E)ā€–ā‚Š = 0 := NNReal.eq norm_one' @[to_additive] theorem ne_one_of_nnnorm_ne_zero {a : E} : ‖aā€–ā‚Š ≠ 0 → a ≠ 1 := mt <| by rintro rfl exact nnnorm_one' @[to_additive nnnorm_add_le] theorem nnnorm_mul_le' (a b : E) : ‖a * bā€–ā‚Š ≤ ‖aā€–ā‚Š + ‖bā€–ā‚Š := NNReal.coe_le_coe.1 <| norm_mul_le' a b @[to_additive norm_nsmul_le] lemma norm_pow_le_mul_norm : āˆ€ {n : ā„•}, ‖a ^ n‖ ≤ n * ‖a‖ | 0 => by simp | n + 1 => by simpa [pow_succ, add_mul] using norm_mul_le_of_le' norm_pow_le_mul_norm le_rfl @[to_additive nnnorm_nsmul_le] lemma nnnorm_pow_le_mul_norm {n : ā„•} : ‖a ^ nā€–ā‚Š ≤ n * ‖aā€–ā‚Š := by simpa only [← NNReal.coe_le_coe, NNReal.coe_mul, NNReal.coe_natCast] using norm_pow_le_mul_norm @[to_additive (attr := simp) nnnorm_neg] theorem nnnorm_inv' (a : E) : ‖aā»Ā¹ā€–ā‚Š = ‖aā€–ā‚Š := NNReal.eq <| norm_inv' a @[to_additive (attr := simp) nnnorm_abs_zsmul] theorem nnnorm_zpow_abs (a : E) (n : ℤ) : ‖a ^ |n|ā€–ā‚Š = ‖a ^ nā€–ā‚Š := NNReal.eq <| norm_zpow_abs a n @[to_additive (attr := simp) nnnorm_natAbs_smul] theorem nnnorm_pow_natAbs (a : E) (n : ℤ) : ‖a ^ n.natAbsā€–ā‚Š = ‖a ^ nā€–ā‚Š := NNReal.eq <| norm_pow_natAbs a n @[to_additive nnnorm_isUnit_zsmul] theorem nnnorm_zpow_isUnit (a : E) {n : ℤ} (hn : IsUnit n) : ‖a ^ nā€–ā‚Š = ‖aā€–ā‚Š := NNReal.eq <| norm_zpow_isUnit a hn @[simp] theorem nnnorm_units_zsmul {E : Type*} [SeminormedAddGroup E] (n : ℤˣ) (a : E) : ‖n • aā€–ā‚Š = ‖aā€–ā‚Š := NNReal.eq <| norm_isUnit_zsmul a n.isUnit @[to_additive (attr := simp)] theorem nndist_one_left (a : E) : nndist 1 a = ‖aā€–ā‚Š := by simp [nndist_eq_nnnorm_div] @[to_additive (attr := simp)] theorem edist_one_left (a : E) : edist 1 a = ‖aā€–ā‚Š := by rw [edist_nndist, nndist_one_left] open scoped symmDiff in @[to_additive] theorem nndist_mulIndicator (s t : Set α) (f : α → E) (x : α) : nndist (s.mulIndicator f x) (t.mulIndicator f x) = ‖(s āˆ† t).mulIndicator f xā€–ā‚Š := NNReal.eq <| dist_mulIndicator s t f x @[to_additive] theorem nnnorm_div_le (a b : E) : ‖a / bā€–ā‚Š ≤ ‖aā€–ā‚Š + ‖bā€–ā‚Š := NNReal.coe_le_coe.1 <| norm_div_le _ _ @[to_additive] lemma enorm_div_le : ‖a / b‖ₑ ≤ ‖a‖ₑ + ‖b‖ₑ := by simpa [enorm, ← ENNReal.coe_add] using nnnorm_div_le a b @[to_additive nndist_nnnorm_nnnorm_le] theorem nndist_nnnorm_nnnorm_le' (a b : E) : nndist ‖aā€–ā‚Š ‖bā€–ā‚Š ≤ ‖a / bā€–ā‚Š := NNReal.coe_le_coe.1 <| dist_norm_norm_le' a b @[to_additive] theorem nnnorm_le_nnnorm_add_nnnorm_div (a b : E) : ‖bā€–ā‚Š ≤ ‖aā€–ā‚Š + ‖a / bā€–ā‚Š := norm_le_norm_add_norm_div _ _ @[to_additive] theorem nnnorm_le_nnnorm_add_nnnorm_div' (a b : E) : ‖aā€–ā‚Š ≤ ‖bā€–ā‚Š + ‖a / bā€–ā‚Š := norm_le_norm_add_norm_div' _ _ alias nnnorm_le_insert' := nnnorm_le_nnnorm_add_nnnorm_sub' alias nnnorm_le_insert := nnnorm_le_nnnorm_add_nnnorm_sub @[to_additive] theorem nnnorm_le_mul_nnnorm_add (a b : E) : ‖aā€–ā‚Š ≤ ‖a * bā€–ā‚Š + ‖bā€–ā‚Š := norm_le_mul_norm_add _ _ /-- An analogue of `nnnorm_le_mul_nnnorm_add` for the multiplication from the left. -/ @[to_additive /-- An analogue of `nnnorm_le_add_nnnorm_add` for the addition from the left. -/] theorem nnnorm_le_mul_nnnorm_add' (a b : E) : ‖bā€–ā‚Š ≤ ‖a * bā€–ā‚Š + ‖aā€–ā‚Š := norm_le_mul_norm_add' _ _ @[to_additive] lemma nnnorm_mul_eq_nnnorm_right {x : E} (y : E) (h : ‖xā€–ā‚Š = 0) : ‖x * yā€–ā‚Š = ‖yā€–ā‚Š := NNReal.eq <| norm_mul_eq_norm_right _ <| congr_arg NNReal.toReal h @[to_additive] lemma nnnorm_mul_eq_nnnorm_left (x : E) {y : E} (h : ‖yā€–ā‚Š = 0) : ‖x * yā€–ā‚Š = ‖xā€–ā‚Š := NNReal.eq <| norm_mul_eq_norm_left _ <| congr_arg NNReal.toReal h @[to_additive] lemma nnnorm_div_eq_nnnorm_right {x : E} (y : E) (h : ‖xā€–ā‚Š = 0) : ‖x / yā€–ā‚Š = ‖yā€–ā‚Š := NNReal.eq <| norm_div_eq_norm_right _ <| congr_arg NNReal.toReal h @[to_additive] lemma nnnorm_div_eq_nnnorm_left (x : E) {y : E} (h : ‖yā€–ā‚Š = 0) : ‖x / yā€–ā‚Š = ‖xā€–ā‚Š := NNReal.eq <| norm_div_eq_norm_left _ <| congr_arg NNReal.toReal h /-- The nonnegative norm seen as an `ENNReal` and then as a `Real` is equal to the norm. -/ @[to_additive toReal_coe_nnnorm /-- The nonnegative norm seen as an `ENNReal` and then as a `Real` is equal to the norm. -/] theorem toReal_coe_nnnorm' (a : E) : (‖aā€–ā‚Š : ā„ā‰„0āˆž).toReal = ‖a‖ := rfl open scoped symmDiff in @[to_additive] theorem edist_mulIndicator (s t : Set α) (f : α → E) (x : α) : edist (s.mulIndicator f x) (t.mulIndicator f x) = ‖(s āˆ† t).mulIndicator f xā€–ā‚Š := by rw [edist_nndist, nndist_mulIndicator] end NNNorm section ENorm @[to_additive (attr := simp) enorm_zero] lemma enorm_one' {E : Type*} [TopologicalSpace E] [ESeminormedMonoid E] : ‖(1 : E)‖ₑ = 0 := by rw [ESeminormedMonoid.enorm_zero] @[to_additive exists_enorm_lt] lemma exists_enorm_lt' (E : Type*) [TopologicalSpace E] [ESeminormedMonoid E] [hbot : NeBot (š“[≠] (1 : E))] {c : ā„ā‰„0āˆž} (hc : c ≠ 0) : ∃ x ≠ (1 : E), ‖x‖ₑ < c := frequently_iff_neBot.mpr hbot |>.and_eventually (ContinuousENorm.continuous_enorm.tendsto' 1 0 (by simp) |>.eventually_lt_const hc.bot_lt) |>.exists @[to_additive (attr := simp) enorm_neg] lemma enorm_inv' (a : E) : ‖a⁻¹‖ₑ = ‖a‖ₑ := by simp [enorm] @[to_additive ofReal_norm_eq_enorm] lemma ofReal_norm_eq_enorm' (a : E) : .ofReal ‖a‖ = ‖a‖ₑ := ENNReal.ofReal_eq_coe_nnreal _ instance : ENorm ā„ā‰„0āˆž where enorm x := x @[simp] lemma enorm_eq_self (x : ā„ā‰„0āˆž) : ‖x‖ₑ = x := rfl @[to_additive] theorem edist_eq_enorm_div (a b : E) : edist a b = ‖a / b‖ₑ := by rw [edist_dist, dist_eq_norm_div, ofReal_norm_eq_enorm'] @[to_additive] theorem edist_one_eq_enorm (x : E) : edist x 1 = ‖x‖ₑ := by rw [edist_eq_enorm_div, div_one] @[to_additive] lemma enorm_div_rev {E : Type*} [SeminormedGroup E] (a b : E) : ‖a / b‖ₑ = ‖b / a‖ₑ := by rw [← edist_eq_enorm_div, edist_comm, edist_eq_enorm_div] @[to_additive] theorem mem_emetric_ball_one_iff {r : ā„ā‰„0āˆž} : a ∈ EMetric.ball 1 r ↔ ‖a‖ₑ < r := by rw [EMetric.mem_ball, edist_one_eq_enorm] end ENorm section ContinuousENorm variable {E : Type*} [TopologicalSpace E] [ContinuousENorm E] @[continuity, fun_prop] lemma continuous_enorm : Continuous fun a : E ↦ ‖a‖ₑ := ContinuousENorm.continuous_enorm variable {X : Type*} [TopologicalSpace X] {f : X → E} {s : Set X} {a : X} @[fun_prop] lemma Continuous.enorm : Continuous f → Continuous (‖f ·‖ₑ) := continuous_enorm.comp lemma ContinuousAt.enorm {a : X} (h : ContinuousAt f a) : ContinuousAt (‖f ·‖ₑ) a := by fun_prop @[fun_prop] lemma ContinuousWithinAt.enorm {s : Set X} {a : X} (h : ContinuousWithinAt f s a) : ContinuousWithinAt (‖f ·‖ₑ) s a := (ContinuousENorm.continuous_enorm.continuousWithinAt).comp (t := Set.univ) h (fun _ _ ↦ by trivial) @[fun_prop] lemma ContinuousOn.enorm (h : ContinuousOn f s) : ContinuousOn (‖f ·‖ₑ) s := (ContinuousENorm.continuous_enorm.continuousOn).comp (t := Set.univ) h <| Set.mapsTo_univ _ _ end ContinuousENorm section ESeminormedMonoid variable {E : Type*} [TopologicalSpace E] [ESeminormedMonoid E] @[to_additive enorm_add_le] lemma enorm_mul_le' (a b : E) : ‖a * b‖ₑ ≤ ‖a‖ₑ + ‖b‖ₑ := ESeminormedMonoid.enorm_mul_le a b end ESeminormedMonoid section ENormedMonoid variable {E : Type*} [TopologicalSpace E] [ENormedMonoid E] @[to_additive (attr := simp) enorm_eq_zero] lemma enorm_eq_zero' {a : E} : ‖a‖ₑ = 0 ↔ a = 1 := by simp [ENormedMonoid.enorm_eq_zero] @[to_additive enorm_ne_zero] lemma enorm_ne_zero' {a : E} : ‖a‖ₑ ≠ 0 ↔ a ≠ 1 := enorm_eq_zero'.ne @[to_additive (attr := simp) enorm_pos] lemma enorm_pos' {a : E} : 0 < ‖a‖ₑ ↔ a ≠ 1 := pos_iff_ne_zero.trans enorm_ne_zero' end ENormedMonoid instance : ENormedAddCommMonoid ā„ā‰„0āˆž where continuous_enorm := continuous_id enorm_zero := by simp enorm_eq_zero := by simp enorm_add_le := by simp open Set in @[to_additive] lemma SeminormedGroup.disjoint_nhds (x : E) (f : Filter E) : Disjoint (š“ x) f ↔ ∃ Ī“ > 0, āˆ€į¶  y in f, Ī“ ≤ ‖y / x‖ := by simp [NormedCommGroup.nhds_basis_norm_lt x |>.disjoint_iff_left, compl_setOf, eventually_iff] @[to_additive] lemma SeminormedGroup.disjoint_nhds_one (f : Filter E) : Disjoint (š“ 1) f ↔ ∃ Ī“ > 0, āˆ€į¶  y in f, Ī“ ≤ ‖y‖ := by simpa using disjoint_nhds 1 f end SeminormedGroup section Induced variable (E F) variable [FunLike š“• E F] -- See note [reducible non-instances] /-- A group homomorphism from a `Group` to a `SeminormedGroup` induces a `SeminormedGroup` structure on the domain. -/ @[to_additive /-- A group homomorphism from an `AddGroup` to a `SeminormedAddGroup` induces a `SeminormedAddGroup` structure on the domain. -/] abbrev SeminormedGroup.induced [Group E] [SeminormedGroup F] [MonoidHomClass š“• E F] (f : š“•) : SeminormedGroup E := { PseudoMetricSpace.induced f toPseudoMetricSpace with norm := fun x => ‖f x‖ dist_eq := fun x y => by simp only [map_div, ← dist_eq_norm_div]; rfl } -- See note [reducible non-instances] /-- A group homomorphism from a `CommGroup` to a `SeminormedGroup` induces a `SeminormedCommGroup` structure on the domain. -/ @[to_additive /-- A group homomorphism from an `AddCommGroup` to a `SeminormedAddGroup` induces a `SeminormedAddCommGroup` structure on the domain. -/] abbrev SeminormedCommGroup.induced [CommGroup E] [SeminormedGroup F] [MonoidHomClass š“• E F] (f : š“•) : SeminormedCommGroup E := { SeminormedGroup.induced E F f with mul_comm := mul_comm } -- See note [reducible non-instances]. /-- An injective group homomorphism from a `Group` to a `NormedGroup` induces a `NormedGroup` structure on the domain. -/ @[to_additive /-- An injective group homomorphism from an `AddGroup` to a `NormedAddGroup` induces a `NormedAddGroup` structure on the domain. -/] abbrev NormedGroup.induced [Group E] [NormedGroup F] [MonoidHomClass š“• E F] (f : š“•) (h : Injective f) : NormedGroup E := { SeminormedGroup.induced E F f, MetricSpace.induced f h _ with } -- See note [reducible non-instances]. /-- An injective group homomorphism from a `CommGroup` to a `NormedGroup` induces a `NormedCommGroup` structure on the domain. -/ @[to_additive /-- An injective group homomorphism from a `CommGroup` to a `NormedCommGroup` induces a `NormedCommGroup` structure on the domain. -/] abbrev NormedCommGroup.induced [CommGroup E] [NormedGroup F] [MonoidHomClass š“• E F] (f : š“•) (h : Injective f) : NormedCommGroup E := { SeminormedGroup.induced E F f, MetricSpace.induced f h _ with mul_comm := mul_comm } end Induced namespace Real variable {r : ā„} instance norm : Norm ā„ where norm r := |r| @[simp] theorem norm_eq_abs (r : ā„) : ‖r‖ = |r| := rfl instance normedAddCommGroup : NormedAddCommGroup ā„ := ⟨fun _r _y => rfl⟩ theorem norm_of_nonneg (hr : 0 ≤ r) : ‖r‖ = r := abs_of_nonneg hr theorem norm_of_nonpos (hr : r ≤ 0) : ‖r‖ = -r := abs_of_nonpos hr theorem le_norm_self (r : ā„) : r ≤ ‖r‖ := le_abs_self r lemma norm_natCast (n : ā„•) : ‖(n : ā„)‖ = n := abs_of_nonneg n.cast_nonneg @[simp 1100] lemma nnnorm_natCast (n : ā„•) : ‖(n : ā„)ā€–ā‚Š = n := NNReal.eq <| norm_natCast _ @[simp 1100] lemma enorm_natCast (n : ā„•) : ‖(n : ā„)‖ₑ = n := by simp [enorm] @[simp 1100] lemma norm_ofNat (n : ā„•) [n.AtLeastTwo] : ‖(ofNat(n) : ā„)‖ = ofNat(n) := norm_natCast n @[simp 1100] lemma nnnorm_ofNat (n : ā„•) [n.AtLeastTwo] : ‖(ofNat(n) : ā„)ā€–ā‚Š = ofNat(n) := nnnorm_natCast n lemma norm_two : ‖(2 : ā„)‖ = 2 := abs_of_pos zero_lt_two lemma nnnorm_two : ‖(2 : ā„)ā€–ā‚Š = 2 := NNReal.eq <| by simp @[simp 1100, norm_cast] lemma norm_nnratCast (q : ā„šā‰„0) : ‖(q : ā„)‖ = q := norm_of_nonneg q.cast_nonneg @[simp 1100, norm_cast] lemma nnnorm_nnratCast (q : ā„šā‰„0) : ‖(q : ā„)ā€–ā‚Š = q := by simp [nnnorm, -norm_eq_abs] theorem nnnorm_of_nonneg (hr : 0 ≤ r) : ‖rā€–ā‚Š = ⟨r, hr⟩ := NNReal.eq <| norm_of_nonneg hr lemma enorm_of_nonneg (hr : 0 ≤ r) : ‖r‖ₑ = .ofReal r := by simp [enorm, nnnorm_of_nonneg hr, ENNReal.ofReal, toNNReal, hr] lemma enorm_ofReal_of_nonneg {a : ā„} (ha : 0 ≤ a) : ‖ENNReal.ofReal a‖ₑ = ‖a‖ₑ:= by simp [Real.enorm_of_nonneg, ha] @[simp] lemma nnnorm_abs (r : ā„) : ‖|r|ā€–ā‚Š = ‖rā€–ā‚Š := by simp [nnnorm] @[simp] lemma enorm_abs (r : ā„) : ‖|r|‖ₑ = ‖r‖ₑ := by simp [enorm] theorem enorm_eq_ofReal (hr : 0 ≤ r) : ‖r‖ₑ = .ofReal r := by rw [← ofReal_norm_eq_enorm, norm_of_nonneg hr] theorem enorm_eq_ofReal_abs (r : ā„) : ‖r‖ₑ = ENNReal.ofReal |r| := by rw [← enorm_eq_ofReal (abs_nonneg _), enorm_abs] theorem toNNReal_eq_nnnorm_of_nonneg (hr : 0 ≤ r) : r.toNNReal = ‖rā€–ā‚Š := by rw [Real.toNNReal_of_nonneg hr] congr rw [Real.norm_eq_abs r, abs_of_nonneg hr] theorem ofReal_le_enorm (r : ā„) : ENNReal.ofReal r ≤ ‖r‖ₑ := by rw [enorm_eq_ofReal_abs]; gcongr; exact le_abs_self _ end Real namespace NNReal instance : NNNorm ā„ā‰„0 where nnnorm x := x @[simp] lemma nnnorm_eq_self (x : ā„ā‰„0) : ‖xā€–ā‚Š = x := rfl end NNReal section SeminormedCommGroup variable [SeminormedCommGroup E] [SeminormedCommGroup F] {a b : E} {r : ā„} variable {ε : Type*} [TopologicalSpace ε] [ESeminormedCommMonoid ε] @[to_additive] theorem dist_inv (x y : E) : dist x⁻¹ y = dist x y⁻¹ := by simp_rw [dist_eq_norm_div, ← norm_inv' (x⁻¹ / y), inv_div, div_inv_eq_mul, mul_comm] theorem norm_multiset_sum_le {E} [SeminormedAddCommGroup E] (m : Multiset E) : ‖m.sum‖ ≤ (m.map fun x => ‖x‖).sum := m.le_sum_of_subadditive norm norm_zero.le norm_add_le variable {ε : Type*} [TopologicalSpace ε] [ESeminormedAddCommMonoid ε] in theorem enorm_multisetSum_le (m : Multiset ε) : ‖m.sum‖ₑ ≤ (m.map fun x => ‖x‖ₑ).sum := m.le_sum_of_subadditive enorm enorm_zero.le enorm_add_le @[to_additive existing] theorem norm_multiset_prod_le (m : Multiset E) : ‖m.prod‖ ≤ (m.map fun x => ‖x‖).sum := m.apply_prod_le_sum_map _ norm_one'.le norm_mul_le' variable {ε : Type*} [TopologicalSpace ε] [ESeminormedCommMonoid ε] in @[to_additive existing] theorem enorm_multisetProd_le (m : Multiset ε) : ‖m.prod‖ₑ ≤ (m.map fun x => ‖x‖ₑ).sum := m.apply_prod_le_sum_map _ enorm_one'.le enorm_mul_le' variable {ε : Type*} [TopologicalSpace ε] [ESeminormedAddCommMonoid ε] in @[bound] theorem enorm_sum_le (s : Finset ι) (f : ι → ε) : ā€–āˆ‘ i ∈ s, f i‖ₑ ≤ āˆ‘ i ∈ s, ‖f i‖ₑ := s.le_sum_of_subadditive enorm enorm_zero.le enorm_add_le f @[bound] theorem norm_sum_le {E} [SeminormedAddCommGroup E] (s : Finset ι) (f : ι → E) : ā€–āˆ‘ i ∈ s, f i‖ ≤ āˆ‘ i ∈ s, ‖f i‖ := s.le_sum_of_subadditive norm norm_zero.le norm_add_le f @[to_additive existing] theorem enorm_prod_le (s : Finset ι) (f : ι → ε) : ā€–āˆ i ∈ s, f i‖ₑ ≤ āˆ‘ i ∈ s, ‖f i‖ₑ := s.apply_prod_le_sum_apply _ enorm_one'.le enorm_mul_le' @[to_additive existing] theorem norm_prod_le (s : Finset ι) (f : ι → E) : ā€–āˆ i ∈ s, f i‖ ≤ āˆ‘ i ∈ s, ‖f i‖ := s.apply_prod_le_sum_apply _ norm_one'.le norm_mul_le' @[to_additive] theorem enorm_prod_le_of_le (s : Finset ι) {f : ι → ε} {n : ι → ā„ā‰„0āˆž} (h : āˆ€ b ∈ s, ‖f b‖ₑ ≤ n b) : ā€–āˆ b ∈ s, f b‖ₑ ≤ āˆ‘ b ∈ s, n b := (enorm_prod_le s f).trans <| Finset.sum_le_sum h @[to_additive] theorem norm_prod_le_of_le (s : Finset ι) {f : ι → E} {n : ι → ā„} (h : āˆ€ b ∈ s, ‖f b‖ ≤ n b) : ā€–āˆ b ∈ s, f b‖ ≤ āˆ‘ b ∈ s, n b := (norm_prod_le s f).trans <| Finset.sum_le_sum h @[to_additive] theorem dist_prod_prod_le_of_le (s : Finset ι) {f a : ι → E} {d : ι → ā„} (h : āˆ€ b ∈ s, dist (f b) (a b) ≤ d b) : dist (āˆ b ∈ s, f b) (āˆ b ∈ s, a b) ≤ āˆ‘ b ∈ s, d b := by simp only [dist_eq_norm_div, ← Finset.prod_div_distrib] at * exact norm_prod_le_of_le s h @[to_additive] theorem dist_prod_prod_le (s : Finset ι) (f a : ι → E) : dist (āˆ b ∈ s, f b) (āˆ b ∈ s, a b) ≤ āˆ‘ b ∈ s, dist (f b) (a b) := dist_prod_prod_le_of_le s fun _ _ => le_rfl @[to_additive] theorem mul_mem_ball_iff_norm : a * b ∈ ball a r ↔ ‖b‖ < r := by rw [mem_ball_iff_norm'', mul_div_cancel_left] @[to_additive] theorem mul_mem_closedBall_iff_norm : a * b ∈ closedBall a r ↔ ‖b‖ ≤ r := by rw [mem_closedBall_iff_norm'', mul_div_cancel_left] -- Higher priority to apply this before the equivalent lemma `Metric.preimage_mul_left_ball`. @[to_additive (attr := simp high)] theorem preimage_mul_ball (a b : E) (r : ā„) : (b * Ā·) ⁻¹' ball a r = ball (a / b) r := by ext c simp only [dist_eq_norm_div, Set.mem_preimage, mem_ball, div_div_eq_mul_div, mul_comm] -- Higher priority to apply this before the equivalent lemma `Metric.preimage_mul_left_closedBall`. @[to_additive (attr := simp high)] theorem preimage_mul_closedBall (a b : E) (r : ā„) : (b * Ā·) ⁻¹' closedBall a r = closedBall (a / b) r := by ext c simp only [dist_eq_norm_div, Set.mem_preimage, mem_closedBall, div_div_eq_mul_div, mul_comm] @[to_additive (attr := simp)] theorem preimage_mul_sphere (a b : E) (r : ā„) : (b * Ā·) ⁻¹' sphere a r = sphere (a / b) r := by ext c simp only [Set.mem_preimage, mem_sphere_iff_norm', div_div_eq_mul_div, mul_comm] @[to_additive] theorem pow_mem_closedBall {n : ā„•} (h : a ∈ closedBall b r) : a ^ n ∈ closedBall (b ^ n) (n • r) := by simp only [mem_closedBall, dist_eq_norm_div, ← div_pow] at h ⊢ refine norm_pow_le_mul_norm.trans ?_ simpa only [nsmul_eq_mul] using mul_le_mul_of_nonneg_left h n.cast_nonneg @[to_additive] theorem pow_mem_ball {n : ā„•} (hn : 0 < n) (h : a ∈ ball b r) : a ^ n ∈ ball (b ^ n) (n • r) := by simp only [mem_ball, dist_eq_norm_div, ← div_pow] at h ⊢ refine lt_of_le_of_lt norm_pow_le_mul_norm ?_ replace hn : 0 < (n : ā„) := by norm_cast rw [nsmul_eq_mul] nlinarith @[to_additive] theorem mul_mem_closedBall_mul_iff {c : E} : a * c ∈ closedBall (b * c) r ↔ a ∈ closedBall b r := by simp only [mem_closedBall, dist_eq_norm_div, mul_div_mul_right_eq_div] @[to_additive] theorem mul_mem_ball_mul_iff {c : E} : a * c ∈ ball (b * c) r ↔ a ∈ ball b r := by simp only [mem_ball, dist_eq_norm_div, mul_div_mul_right_eq_div] @[to_additive] theorem smul_closedBall'' : a • closedBall b r = closedBall (a • b) r := by ext simp [mem_closedBall, Set.mem_smul_set, dist_eq_norm_div, div_eq_inv_mul, ← eq_inv_mul_iff_mul_eq, mul_assoc] @[to_additive] theorem smul_ball'' : a • ball b r = ball (a • b) r := by ext simp [mem_ball, Set.mem_smul_set, dist_eq_norm_div, _root_.div_eq_inv_mul, ← eq_inv_mul_iff_mul_eq, mul_assoc] @[to_additive] theorem nnnorm_multiset_prod_le (m : Multiset E) : ‖m.prodā€–ā‚Š ≤ (m.map fun x => ‖xā€–ā‚Š).sum := NNReal.coe_le_coe.1 <| by push_cast rw [Multiset.map_map] exact norm_multiset_prod_le _ @[to_additive] theorem nnnorm_prod_le (s : Finset ι) (f : ι → E) : ā€–āˆ a ∈ s, f aā€–ā‚Š ≤ āˆ‘ a ∈ s, ‖f aā€–ā‚Š := NNReal.coe_le_coe.1 <| by push_cast exact norm_prod_le _ _ @[to_additive] theorem nnnorm_prod_le_of_le (s : Finset ι) {f : ι → E} {n : ι → ā„ā‰„0} (h : āˆ€ b ∈ s, ‖f bā€–ā‚Š ≤ n b) : ā€–āˆ b ∈ s, f bā€–ā‚Š ≤ āˆ‘ b ∈ s, n b := (norm_prod_le_of_le s h).trans_eq (NNReal.coe_sum ..).symm @[to_additive (attr := simp high) norm_norm] -- Higher priority as a shortcut lemma. lemma norm_norm' (x : E) : ‖‖x‖‖ = ‖x‖ := Real.norm_of_nonneg (norm_nonneg' _) @[to_additive (attr := simp) nnnorm_norm] lemma nnnorm_norm' (x : E) : ‖‖xā€–ā€–ā‚Š = ‖xā€–ā‚Š := by simp [nnnorm] @[to_additive (attr := simp) enorm_norm] lemma enorm_norm' (x : E) : ‖‖x‖‖ₑ = ‖x‖ₑ := by simp [enorm] lemma enorm_enorm {ε : Type*} [ENorm ε] (x : ε) : ‖‖x‖ₑ‖ₑ = ‖x‖ₑ := by simp [enorm] end SeminormedCommGroup section NormedGroup variable [NormedGroup E] {a b : E} @[to_additive (attr := simp) norm_le_zero_iff] lemma norm_le_zero_iff' : ‖a‖ ≤ 0 ↔ a = 1 := by rw [← dist_one_right, dist_le_zero] @[to_additive (attr := simp) norm_pos_iff] lemma norm_pos_iff' : 0 < ‖a‖ ↔ a ≠ 1 := by rw [← not_le, norm_le_zero_iff'] @[to_additive (attr := simp) norm_eq_zero] lemma norm_eq_zero' : ‖a‖ = 0 ↔ a = 1 := (norm_nonneg' a).ge_iff_eq'.symm.trans norm_le_zero_iff' @[to_additive norm_ne_zero_iff] lemma norm_ne_zero_iff' : ‖a‖ ≠ 0 ↔ a ≠ 1 := norm_eq_zero'.not @[to_additive] theorem norm_div_eq_zero_iff : ‖a / b‖ = 0 ↔ a = b := by rw [norm_eq_zero', div_eq_one] @[to_additive] theorem norm_div_pos_iff : 0 < ‖a / b‖ ↔ a ≠ b := by rw [(norm_nonneg' _).lt_iff_ne, ne_comm] exact norm_div_eq_zero_iff.not @[to_additive eq_of_norm_sub_le_zero] theorem eq_of_norm_div_le_zero (h : ‖a / b‖ ≤ 0) : a = b := by rwa [← div_eq_one, ← norm_le_zero_iff'] alias ⟨eq_of_norm_div_eq_zero, _⟩ := norm_div_eq_zero_iff attribute [to_additive] eq_of_norm_div_eq_zero @[to_additive] theorem eq_one_or_norm_pos (a : E) : a = 1 ∨ 0 < ‖a‖ := by simpa [eq_comm] using (norm_nonneg' a).eq_or_lt @[to_additive] theorem eq_one_or_nnnorm_pos (a : E) : a = 1 ∨ 0 < ‖aā€–ā‚Š := eq_one_or_norm_pos a @[to_additive (attr := simp) nnnorm_eq_zero] theorem nnnorm_eq_zero' : ‖aā€–ā‚Š = 0 ↔ a = 1 := by rw [← NNReal.coe_eq_zero, coe_nnnorm', norm_eq_zero'] @[to_additive nnnorm_ne_zero_iff] theorem nnnorm_ne_zero_iff' : ‖aā€–ā‚Š ≠ 0 ↔ a ≠ 1 := nnnorm_eq_zero'.not @[to_additive (attr := simp) nnnorm_pos] lemma nnnorm_pos' : 0 < ‖aā€–ā‚Š ↔ a ≠ 1 := pos_iff_ne_zero.trans nnnorm_ne_zero_iff' variable (E) /-- The norm of a normed group as a group norm. -/ @[to_additive /-- The norm of a normed group as an additive group norm. -/] def normGroupNorm : GroupNorm E := { normGroupSeminorm _ with eq_one_of_map_eq_zero' := fun _ => norm_eq_zero'.1 } @[simp] theorem coe_normGroupNorm : ⇑(normGroupNorm E) = norm := rfl end NormedGroup section NormedAddGroup variable [NormedAddGroup E] [TopologicalSpace α] {f : α → E} /-! Some relations with `HasCompactSupport` -/ theorem hasCompactSupport_norm_iff : (HasCompactSupport fun x => ‖f x‖) ↔ HasCompactSupport f := hasCompactSupport_comp_left norm_eq_zero alias ⟨_, HasCompactSupport.norm⟩ := hasCompactSupport_norm_iff end NormedAddGroup lemma tendsto_norm_atTop_atTop : Tendsto (norm : ā„ → ā„) atTop atTop := tendsto_abs_atTop_atTop /-! ### `positivity` extensions -/ namespace Mathlib.Meta.Positivity open Lean Meta Qq Function /-- Extension for the `positivity` tactic: multiplicative norms are always nonnegative, and positive on non-one inputs. -/ @[positivity ‖_‖] def evalMulNorm : PositivityExt where eval {u α} _ _ e := do match u, α, e with | 0, ~q(ā„), ~q(@Norm.norm $E $_n $a) => let _seminormedGroup_E ← synthInstanceQ q(SeminormedGroup $E) assertInstancesCommute -- Check whether we are in a normed group and whether the context contains a `a ≠ 1` assumption let o : Option (Q(NormedGroup $E) Ɨ Q($a ≠ 1)) := ← do let .some normedGroup_E ← trySynthInstanceQ q(NormedGroup $E) | return none let some pa ← findLocalDeclWithTypeQ? q($a ≠ 1) | return none return some (normedGroup_E, pa) match o with -- If so, return a proof of `0 < ‖a‖` | some (_normedGroup_E, pa) => assertInstancesCommute return .positive q(norm_pos_iff'.2 $pa) -- Else, return a proof of `0 ≤ ‖a‖` | none => return .nonnegative q(norm_nonneg' $a) | _, _, _ => throwError "not `‖·‖`" /-- Extension for the `positivity` tactic: additive norms are always nonnegative, and positive on non-zero inputs. -/ @[positivity ‖_‖] def evalAddNorm : PositivityExt where eval {u α} _ _ e := do match u, α, e with | 0, ~q(ā„), ~q(@Norm.norm $E $_n $a) => let _seminormedAddGroup_E ← synthInstanceQ q(SeminormedAddGroup $E) assertInstancesCommute -- Check whether we are in a normed group and whether the context contains a `a ≠ 0` assumption let o : Option (Q(NormedAddGroup $E) Ɨ Q($a ≠ 0)) := ← do let .some normedAddGroup_E ← trySynthInstanceQ q(NormedAddGroup $E) | return none let some pa ← findLocalDeclWithTypeQ? q($a ≠ 0) | return none return some (normedAddGroup_E, pa) match o with -- If so, return a proof of `0 < ‖a‖` | some (_normedAddGroup_E, pa) => assertInstancesCommute return .positive q(norm_pos_iff.2 $pa) -- Else, return a proof of `0 ≤ ‖a‖` | none => return .nonnegative q(norm_nonneg $a) | _, _, _ => throwError "not `‖·‖`" end Mathlib.Meta.Positivity
.lake/packages/mathlib/Mathlib/Analysis/Normed/Group/Quotient.lean
import Mathlib.Analysis.Normed.Module.Basic import Mathlib.Analysis.Normed.Group.Hom import Mathlib.Analysis.Normed.Operator.LinearIsometry import Mathlib.LinearAlgebra.Isomorphisms import Mathlib.RingTheory.Ideal.Quotient.Operations import Mathlib.Topology.MetricSpace.HausdorffDistance /-! # Quotients of seminormed groups For any `SeminormedAddCommGroup M` and any `S : AddSubgroup M`, we provide a `SeminormedAddCommGroup`, the group quotient `M ā§ø S`. If `S` is closed, we provide `NormedAddCommGroup (M ā§ø S)` (regardless of whether `M` itself is separated). The two main properties of these structures are the underlying topology is the quotient topology and the projection is a normed group homomorphism which is norm non-increasing (better, it has operator norm exactly one unless `S` is dense in `M`). The corresponding universal property is that every normed group hom defined on `M` which vanishes on `S` descends to a normed group hom defined on `M ā§ø S`. This file also introduces a predicate `IsQuotient` characterizing normed group homs that are isomorphic to the canonical projection onto a normed group quotient. In addition, this file also provides normed structures for quotients of modules by submodules, and of (commutative) rings by ideals. The `SeminormedAddCommGroup` and `NormedAddCommGroup` instances described above are transferred directly, but we also define instances of `NormedSpace`, `SeminormedCommRing`, `NormedCommRing` and `NormedAlgebra` under appropriate type class assumptions on the original space. Moreover, while `QuotientAddGroup.completeSpace` works out-of-the-box for quotients of `NormedAddCommGroup`s by `AddSubgroup`s, we need to transfer this instance in `Submodule.Quotient.completeSpace` so that it applies to these other quotients. ## Main definitions We use `M` and `N` to denote seminormed groups and `S : AddSubgroup M`. All the following definitions are in the `AddSubgroup` namespace. Hence we can access `AddSubgroup.normedMk S` as `S.normedMk`. * `seminormedAddCommGroupQuotient` : The seminormed group structure on the quotient by an additive subgroup. This is an instance so there is no need to explicitly use it. * `normedAddCommGroupQuotient` : The normed group structure on the quotient by a closed additive subgroup. This is an instance so there is no need to explicitly use it. * `normedMk S` : the normed group hom from `M` to `M ā§ø S`. * `lift S f hf`: implements the universal property of `M ā§ø S`. Here `(f : NormedAddGroupHom M N)`, `(hf : āˆ€ s ∈ S, f s = 0)` and `lift S f hf : NormedAddGroupHom (M ā§ø S) N`. * `IsQuotient`: given `f : NormedAddGroupHom M N`, `IsQuotient f` means `N` is isomorphic to a quotient of `M` by a subgroup, with projection `f`. Technically it asserts `f` is surjective and the norm of `f x` is the infimum of the norms of `x + m` for `m` in `f.ker`. ## Main results * `norm_normedMk` : the operator norm of the projection is `1` if the subspace is not dense. * `IsQuotient.norm_lift`: Provided `f : normed_hom M N` satisfies `IsQuotient f`, for every `n : N` and positive `ε`, there exists `m` such that `f m = n ∧ ‖m‖ < ‖n‖ + ε`. ## Implementation details For any `SeminormedAddCommGroup M` and any `S : AddSubgroup M` we define a norm on `M ā§ø S` by `‖x‖ = sInf (norm '' {m | mk' S m = x})`. This formula is really an implementation detail, it shouldn't be needed outside of this file setting up the theory. Since `M ā§ø S` is automatically a topological space (as any quotient of a topological space), one needs to be careful while defining the `SeminormedAddCommGroup` instance to avoid having two different topologies on this quotient. This is not purely a technological issue. Mathematically there is something to prove. The main point is proved in the auxiliary lemma `quotient_nhds_basis` that has no use beyond this verification and states that zero in the quotient admits as basis of neighborhoods in the quotient topology the sets `{x | ‖x‖ < ε}` for positive `ε`. Once this mathematical point is settled, we have two topologies that are propositionally equal. This is not good enough for the type class system. As usual we ensure *definitional* equality using forgetful inheritance, see Note [forgetful inheritance]. A (semi)-normed group structure includes a uniform space structure which includes a topological space structure, together with propositional fields asserting compatibility conditions. The usual way to define a `SeminormedAddCommGroup` is to let Lean build a uniform space structure using the provided norm, and then trivially build a proof that the norm and uniform structure are compatible. Here the uniform structure is provided using `IsTopologicalAddGroup.rightUniformSpace` which uses the topological structure and the group structure to build the uniform structure. This uniform structure induces the correct topological structure by construction, but the fact that it is compatible with the norm is not obvious; this is where the mathematical content explained in the previous paragraph kicks in. -/ noncomputable section open Metric Set Topology NNReal namespace QuotientGroup variable {M : Type*} [SeminormedCommGroup M] {S T : Subgroup M} {x : M ā§ø S} {m : M} {r ε : ā„} @[to_additive add_norm_aux] private lemma norm_aux (x : M ā§ø S) : {m : M | (m : M ā§ø S) = x}.Nonempty := Quot.exists_rep x /-- The norm of `x` on the quotient by a subgroup `S` is defined as the infimum of the norm on `x * M`. -/ @[to_additive /-- The norm of `x` on the quotient by a subgroup `S` is defined as the infimum of the norm on `x + S`. -/] noncomputable def groupSeminorm : GroupSeminorm (M ā§ø S) where toFun x := infDist 1 {m : M | (m : M ā§ø S) = x} map_one' := infDist_zero_of_mem (by simp) mul_le' x y := by simp only [infDist_eq_iInf] have := (norm_aux x).to_subtype have := (norm_aux y).to_subtype refine le_ciInf_add_ciInf ?_ rintro ⟨a, rfl⟩ ⟨b, rfl⟩ refine ciInf_le_of_le ⟨0, forall_mem_range.2 fun _ ↦ dist_nonneg⟩ ⟨a * b, rfl⟩ ?_ simpa using norm_mul_le' _ _ inv' x := eq_of_forall_le_iff fun r ↦ by simp only [le_infDist (norm_aux _)] exact (Equiv.inv _).forall_congr (by simp [← inv_eq_iff_eq_inv]) /-- The norm of `x` on the quotient by a subgroup `S` is defined as the infimum of the norm on `x * S`. -/ @[to_additive /-- The norm of `x` on the quotient by a subgroup `S` is defined as the infimum of the norm on `x + S`. -/] noncomputable instance instNorm : Norm (M ā§ø S) where norm := groupSeminorm @[to_additive] lemma norm_eq_groupSeminorm (x : M ā§ø S) : ‖x‖ = groupSeminorm x := rfl @[to_additive] lemma norm_eq_infDist (x : M ā§ø S) : ‖x‖ = infDist 1 {m : M | (m : M ā§ø S) = x} := rfl @[to_additive] lemma le_norm_iff : r ≤ ‖x‖ ↔ āˆ€ m : M, ↑m = x → r ≤ ‖m‖ := by simp [norm_eq_infDist, le_infDist (norm_aux _)] @[to_additive] lemma norm_lt_iff : ‖x‖ < r ↔ ∃ m : M, ↑m = x ∧ ‖m‖ < r := by simp [norm_eq_infDist, infDist_lt_iff (norm_aux _)] @[to_additive] lemma nhds_one_hasBasis : (š“ (1 : M ā§ø S)).HasBasis (fun ε ↦ 0 < ε) fun ε ↦ {x | ‖x‖ < ε} := by have : āˆ€ ε : ā„, mk '' ball (1 : M) ε = {x : M ā§ø S | ‖x‖ < ε} := by refine fun ε ↦ Set.ext <| forall_mk.2 fun x ↦ ?_ rw [ball_one_eq, mem_setOf_eq, norm_lt_iff, mem_image] exact exists_congr fun _ ↦ and_comm rw [← mk_one, nhds_eq, ← funext this] exact .map _ Metric.nhds_basis_ball /-- An alternative definition of the norm on the quotient group: the norm of `((x : M) : M ā§ø S)` is equal to the distance from `x` to `S`. -/ @[to_additive /-- An alternative definition of the norm on the quotient group: the norm of `((x : M) : M ā§ø S)` is equal to the distance from `x` to `S`. -/] lemma norm_mk (x : M) : ‖(x : M ā§ø S)‖ = infDist x S := by rw [norm_eq_infDist, ← infDist_image (IsometryEquiv.divLeft x).isometry, ← IsometryEquiv.preimage_symm] simp /-- The norm of the projection is smaller or equal to the norm of the original element. -/ @[to_additive /-- The norm of the projection is smaller or equal to the norm of the original element. -/] lemma norm_mk_le_norm : ‖(m : M ā§ø S)‖ ≤ ‖m‖ := (infDist_le_dist_of_mem (by simp)).trans_eq (dist_one_left _) /-- The norm of the image of `m : M` in the quotient by `S` is zero if and only if `m` belongs to the closure of `S`. -/ @[to_additive /-- The norm of the image of `m : M` in the quotient by `S` is zero if and only if `m` belongs to the closure of `S`. -/] lemma norm_mk_eq_zero_iff_mem_closure : ‖(m : M ā§ø S)‖ = 0 ↔ m ∈ closure (S : Set M) := by rw [norm_mk, ← mem_closure_iff_infDist_zero] exact ⟨1, S.one_mem⟩ /-- The norm of the image of `m : M` in the quotient by a closed subgroup `S` is zero if and only if `m ∈ S`. -/ @[to_additive /-- The norm of the image of `m : M` in the quotient by a closed subgroup `S` is zero if and only if `m ∈ S`. -/] lemma norm_mk_eq_zero [hS : IsClosed (S : Set M)] : ‖(m : M ā§ø S)‖ = 0 ↔ m ∈ S := by rw [norm_mk_eq_zero_iff_mem_closure, hS.closure_eq, SetLike.mem_coe] /-- For any `x : M ā§ø S` and any `0 < ε`, there is `m : M` such that `mk' S m = x` and `‖m‖ < ‖x‖ + ε`. -/ @[to_additive /-- For any `x : M ā§ø S` and any `0 < ε`, there is `m : M` such that `mk' S m = x` and `‖m‖ < ‖x‖ + ε`. -/] lemma exists_norm_mk_lt (x : M ā§ø S) (hε : 0 < ε) : ∃ m : M, m = x ∧ ‖m‖ < ‖x‖ + ε := norm_lt_iff.1 <| lt_add_of_pos_right _ hε /-- For any `m : M` and any `0 < ε`, there is `s ∈ S` such that `‖m * s‖ < ‖mk' S m‖ + ε`. -/ @[to_additive /-- For any `m : M` and any `0 < ε`, there is `s ∈ S` such that `‖m + s‖ < ‖mk' S m‖ + ε`. -/] lemma exists_norm_mul_lt (S : Subgroup M) (m : M) {ε : ā„} (hε : 0 < ε) : ∃ s ∈ S, ‖m * s‖ < ‖mk' S m‖ + ε := by obtain ⟨n : M, hn, hn'⟩ := exists_norm_mk_lt (QuotientGroup.mk' S m) hε exact ⟨m⁻¹ * n, by simpa [eq_comm, QuotientGroup.eq] using hn, by simpa⟩ variable (S) in /-- The seminormed group structure on the quotient by a subgroup. -/ @[to_additive /-- The seminormed group structure on the quotient by an additive subgroup. -/] noncomputable instance instSeminormedCommGroup : SeminormedCommGroup (M ā§ø S) where toUniformSpace := IsTopologicalGroup.rightUniformSpace (M ā§ø S) __ := groupSeminorm.toSeminormedCommGroup uniformity_dist := by rw [uniformity_eq_comap_nhds_one', (nhds_one_hasBasis.comap _).eq_biInf] simp only [dist, preimage_setOf_eq, norm_eq_groupSeminorm, map_div_rev] variable (S) in /-- The quotient in the category of normed groups. -/ @[to_additive /-- The quotient in the category of normed groups. -/] noncomputable instance instNormedCommGroup [hS : IsClosed (S : Set M)] : NormedCommGroup (M ā§ø S) where __ := MetricSpace.ofT0PseudoMetricSpace _ -- This is a sanity check left here on purpose to ensure that potential refactors won't destroy -- this important property. example : (instTopologicalSpaceQuotient : TopologicalSpace <| M ā§ø S) = (instSeminormedCommGroup S).toUniformSpace.toTopologicalSpace := rfl example [IsClosed (S : Set M)] : (instSeminormedCommGroup S) = NormedCommGroup.toSeminormedCommGroup := rfl /-- An isometric version of `Subgroup.quotientEquivOfEq`. -/ @[to_additive /-- An isometric version of `AddSubgroup.quotientEquivOfEq`. -/] def _root_.Subgroup.quotientIsometryEquivOfEq (h : S = T) : M ā§ø S ā‰ƒįµ¢ M ā§ø T where __ := Subgroup.quotientEquivOfEq h isometry_toFun := by subst h; rintro ⟨_⟩ ⟨_⟩; rfl /-- An isometric version of `QuotientGroup.quotientBot`. -/ @[to_additive /-- An isometric version of `QuotientAddGroup.quotientBot`. -/] def quotientBotIsometryEquiv : M ā§ø (⊄ : Subgroup M) ā‰ƒįµ¢ M where __ := quotientBot isometry_toFun : Isometry quotientBot := by rw [MonoidHomClass.isometry_iff_norm] rintro ⟨x⟩ change ‖x‖ = ‖QuotientGroup.mk x‖ simp [norm_mk] /-- An isometric version of `QuotientGroup.quotientQuotientEquivQuotient`. -/ @[to_additive /-- An isometric version of `QuotientAddGroup.quotientQuotientEquivQuotient`. -/] def quotientQuotientIsometryEquivQuotient (h : S ≤ T) : (M ā§ø S) ā§ø T.map (mk' S) ā‰ƒįµ¢ M ā§ø T where __ := quotientQuotientEquivQuotient S T h isometry_toFun : Isometry (quotientQuotientEquivQuotient S T h) := by rw [MonoidHomClass.isometry_iff_norm] refine fun x => eq_of_forall_le_iff fun r => ?_ simp only [le_norm_iff] exact ⟨ fun h₁ y hā‚‚ z hā‚ƒ => h₁ z <| by subst_vars; rfl, fun h₁ y hā‚‚ => h₁ y ((quotientQuotientEquivQuotient S T h).injective hā‚‚) y rfl⟩ end QuotientGroup open QuotientAddGroup Metric Set Topology NNReal variable {M N : Type*} [SeminormedAddCommGroup M] [SeminormedAddCommGroup N] /-- The norm of the image under the natural morphism to the quotient. -/ theorem quotient_norm_mk_eq (S : AddSubgroup M) (m : M) : ‖mk' S m‖ = sInf ((‖m + ·‖) '' S) := by rw [mk'_apply, norm_mk, sInf_image', ← infDist_image isometry_neg, image_neg_eq_neg, neg_coe_set (H := S), infDist_eq_iInf] simp only [dist_eq_norm', sub_neg_eq_add, add_comm] /-- The quotient norm satisfies the triangle inequality. -/ theorem quotient_norm_add_le (S : AddSubgroup M) (x y : M ā§ø S) : ‖x + y‖ ≤ ‖x‖ + ‖y‖ := norm_add_le x y namespace AddSubgroup open NormedAddGroupHom /-- The morphism from a seminormed group to the quotient by a subgroup. -/ noncomputable def normedMk (S : AddSubgroup M) : NormedAddGroupHom M (M ā§ø S) where __ := QuotientAddGroup.mk' S bound' := ⟨1, fun m => by simpa [one_mul] using norm_mk_le_norm⟩ /-- `S.normedMk` agrees with `QuotientAddGroup.mk' S`. -/ @[simp] theorem normedMk.apply (S : AddSubgroup M) (m : M) : normedMk S m = QuotientAddGroup.mk' S m := rfl /-- `S.normedMk` is surjective. -/ theorem surjective_normedMk (S : AddSubgroup M) : Function.Surjective (normedMk S) := Quot.mk_surjective /-- The kernel of `S.normedMk` is `S`. -/ theorem ker_normedMk (S : AddSubgroup M) : S.normedMk.ker = S := QuotientAddGroup.ker_mk' _ /-- The operator norm of the projection is at most `1`. -/ theorem norm_normedMk_le (S : AddSubgroup M) : ‖S.normedMk‖ ≤ 1 := NormedAddGroupHom.opNorm_le_bound _ zero_le_one fun m => by simp [norm_mk_le_norm] theorem _root_.QuotientAddGroup.norm_lift_apply_le {S : AddSubgroup M} (f : NormedAddGroupHom M N) (hf : āˆ€ x ∈ S, f x = 0) (x : M ā§ø S) : ‖lift S f.toAddMonoidHom hf x‖ ≤ ‖f‖ * ‖x‖ := by cases (norm_nonneg f).eq_or_lt' with | inl h => rcases mk_surjective x with ⟨x, rfl⟩ simpa [h] using le_opNorm f x | inr h => rw [← not_lt, ← lt_div_iffā‚€' h, norm_lt_iff] rintro ⟨x, rfl, hx⟩ exact ((lt_div_iffā‚€' h).1 hx).not_ge (le_opNorm f x) /-- The operator norm of the projection is `1` if the subspace is not dense. -/ theorem norm_normedMk (S : AddSubgroup M) (h : (S.topologicalClosure : Set M) ≠ univ) : ‖S.normedMk‖ = 1 := by refine le_antisymm (norm_normedMk_le S) ?_ obtain ⟨x, hx⟩ : ∃ x : M, 0 < ‖(x : M ā§ø S)‖ := by refine (Set.nonempty_compl.2 h).imp fun x hx ↦ ?_ exact (norm_nonneg _).lt_of_ne' <| mt norm_mk_eq_zero_iff_mem_closure.1 hx refine (le_mul_iff_one_le_left hx).1 ?_ exact norm_lift_apply_le S.normedMk (fun x ↦ (eq_zero_iff x).2) x /-- The operator norm of the projection is `0` if the subspace is dense. -/ theorem norm_trivial_quotient_mk (S : AddSubgroup M) (h : (S.topologicalClosure : Set M) = Set.univ) : ‖S.normedMk‖ = 0 := by refine le_antisymm (opNorm_le_bound _ le_rfl fun x => ?_) (norm_nonneg _) have hker : x ∈ S.normedMk.ker.topologicalClosure := by rw [S.ker_normedMk, ← SetLike.mem_coe, h] trivial rw [ker_normedMk] at hker simp [norm_mk_eq_zero_iff_mem_closure.mpr hker] end AddSubgroup namespace NormedAddGroupHom /-- `IsQuotient f`, for `f : M ⟶ N` means that `N` is isomorphic to the quotient of `M` by the kernel of `f`. -/ structure IsQuotient (f : NormedAddGroupHom M N) : Prop where protected surjective : Function.Surjective f protected norm : āˆ€ x, ‖f x‖ = sInf ((fun m => ‖x + m‖) '' f.ker) /-- Given `f : NormedAddGroupHom M N` such that `f s = 0` for all `s ∈ S`, where, `S : AddSubgroup M` is closed, the induced morphism `NormedAddGroupHom (M ā§ø S) N`. -/ noncomputable def lift {N : Type*} [SeminormedAddCommGroup N] (S : AddSubgroup M) (f : NormedAddGroupHom M N) (hf : āˆ€ s ∈ S, f s = 0) : NormedAddGroupHom (M ā§ø S) N := { QuotientAddGroup.lift S f.toAddMonoidHom hf with bound' := āŸØā€–f‖, norm_lift_apply_le f hf⟩ } theorem lift_mk {N : Type*} [SeminormedAddCommGroup N] (S : AddSubgroup M) (f : NormedAddGroupHom M N) (hf : āˆ€ s ∈ S, f s = 0) (m : M) : lift S f hf (S.normedMk m) = f m := rfl theorem lift_unique {N : Type*} [SeminormedAddCommGroup N] (S : AddSubgroup M) (f : NormedAddGroupHom M N) (hf : āˆ€ s ∈ S, f s = 0) (g : NormedAddGroupHom (M ā§ø S) N) (h : g.comp S.normedMk = f) : g = lift S f hf := by ext x rcases AddSubgroup.surjective_normedMk _ x with ⟨x, rfl⟩ change g.comp S.normedMk x = _ simp only [h] rfl /-- `S.normedMk` satisfies `IsQuotient`. -/ theorem isQuotientQuotient (S : AddSubgroup M) : IsQuotient S.normedMk := ⟨S.surjective_normedMk, fun m => by simpa [S.ker_normedMk] using quotient_norm_mk_eq _ m⟩ theorem IsQuotient.norm_lift {f : NormedAddGroupHom M N} (hquot : IsQuotient f) {ε : ā„} (hε : 0 < ε) (n : N) : ∃ m : M, f m = n ∧ ‖m‖ < ‖n‖ + ε := by obtain ⟨m, rfl⟩ := hquot.surjective n have nonemp : ((fun m' => ‖m + m'‖) '' f.ker).Nonempty := by rw [Set.image_nonempty] exact ⟨0, f.ker.zero_mem⟩ rcases Real.lt_sInf_add_pos nonemp hε with ⟨_, ⟨⟨x, hx, rfl⟩, H : ‖m + x‖ < sInf ((fun m' : M => ‖m + m'‖) '' f.ker) + ε⟩⟩ exact ⟨m + x, by rw [map_add, (NormedAddGroupHom.mem_ker f x).mp hx, add_zero], by rwa [hquot.norm]⟩ theorem IsQuotient.norm_le {f : NormedAddGroupHom M N} (hquot : IsQuotient f) (m : M) : ‖f m‖ ≤ ‖m‖ := by rw [hquot.norm] apply csInf_le Ā· use 0 rintro _ ⟨m', -, rfl⟩ apply norm_nonneg Ā· exact ⟨0, f.ker.zero_mem, by simp⟩ theorem norm_lift_le {N : Type*} [SeminormedAddCommGroup N] (S : AddSubgroup M) (f : NormedAddGroupHom M N) (hf : āˆ€ s ∈ S, f s = 0) : ‖lift S f hf‖ ≤ ‖f‖ := opNorm_le_bound _ (norm_nonneg f) (norm_lift_apply_le f hf) -- TODO: deprecate? theorem lift_norm_le {N : Type*} [SeminormedAddCommGroup N] (S : AddSubgroup M) (f : NormedAddGroupHom M N) (hf : āˆ€ s ∈ S, f s = 0) {c : ā„ā‰„0} (fb : ‖f‖ ≤ c) : ‖lift S f hf‖ ≤ c := (norm_lift_le S f hf).trans fb theorem lift_normNoninc {N : Type*} [SeminormedAddCommGroup N] (S : AddSubgroup M) (f : NormedAddGroupHom M N) (hf : āˆ€ s ∈ S, f s = 0) (fb : f.NormNoninc) : (lift S f hf).NormNoninc := fun x => by have fb' : ‖f‖ ≤ (1 : ā„ā‰„0) := NormNoninc.normNoninc_iff_norm_le_one.mp fb simpa using le_of_opNorm_le _ (f.lift_norm_le _ _ fb') _ end NormedAddGroupHom /-! ### Submodules and ideals In what follows, the norm structures created above for quotients of (semi)`NormedAddCommGroup`s by `AddSubgroup`s are transferred via definitional equality to quotients of modules by submodules, and of rings by ideals, thereby preserving the definitional equality for the topological group and uniform structures worked for above. Completeness is also transferred via this definitional equality. In addition, instances are constructed for `NormedSpace`, `SeminormedCommRing`, `NormedCommRing` and `NormedAlgebra` under the appropriate hypotheses. Currently, we do not have quotients of rings by two-sided ideals, hence the commutativity hypotheses are required. -/ section Submodule variable {R : Type*} [Ring R] [Module R M] (S T : Submodule R M) instance Submodule.Quotient.seminormedAddCommGroup : SeminormedAddCommGroup (M ā§ø S) := QuotientAddGroup.instSeminormedAddCommGroup S.toAddSubgroup instance Submodule.Quotient.normedAddCommGroup [hS : IsClosed (S : Set M)] : NormedAddCommGroup (M ā§ø S) := QuotientAddGroup.instNormedAddCommGroup S.toAddSubgroup (hS := hS) instance Submodule.Quotient.completeSpace [CompleteSpace M] : CompleteSpace (M ā§ø S) := QuotientAddGroup.completeSpace M S.toAddSubgroup /-- For any `x : M ā§ø S` and any `0 < ε`, there is `m : M` such that `Submodule.Quotient.mk m = x` and `‖m‖ < ‖x‖ + ε`. -/ nonrec theorem Submodule.Quotient.norm_mk_lt {S : Submodule R M} (x : M ā§ø S) {ε : ā„} (hε : 0 < ε) : ∃ m : M, Submodule.Quotient.mk m = x ∧ ‖m‖ < ‖x‖ + ε := exists_norm_mk_lt x hε theorem Submodule.Quotient.norm_mk_le (m : M) : ‖(Submodule.Quotient.mk m : M ā§ø S)‖ ≤ ‖m‖ := norm_mk_le_norm instance Submodule.Quotient.instIsBoundedSMul (š•œ : Type*) [SeminormedCommRing š•œ] [Module š•œ M] [IsBoundedSMul š•œ M] [SMul š•œ R] [IsScalarTower š•œ R M] : IsBoundedSMul š•œ (M ā§ø S) := .of_norm_smul_le fun k x => -- this is `QuotientAddGroup.norm_lift_apply_le` for `f : M → M ā§ø S` given by -- `x ↦ mk (k • x)`; todo: add scalar multiplication as `NormedAddGroupHom`, use it here _root_.le_of_forall_pos_le_add fun ε hε => by have := (nhds_basis_ball.tendsto_iff nhds_basis_ball).mp ((@Real.uniformContinuous_const_mul ‖k‖).continuous.tendsto ‖x‖) ε hε simp only [mem_ball, dist, abs_sub_lt_iff] at this rcases this with ⟨Γ, hĪ“, h⟩ obtain ⟨a, rfl, ha⟩ := Submodule.Quotient.norm_mk_lt x hĪ“ specialize h ‖a‖ ⟨by linarith, by linarith [Submodule.Quotient.norm_mk_le S a]⟩ calc _ ≤ ‖k‖ * ‖a‖ := (norm_mk_le ..).trans (norm_smul_le k a) _ ≤ _ := (sub_lt_iff_lt_add'.mp h.1).le instance Submodule.Quotient.normedSpace (š•œ : Type*) [NormedField š•œ] [NormedSpace š•œ M] [SMul š•œ R] [IsScalarTower š•œ R M] : NormedSpace š•œ (M ā§ø S) where norm_smul_le := norm_smul_le /-- An isometric version of `Submodule.quotEquivOfEq`. -/ def Submodule.quotLIEOfEq (h : S = T) : M ā§ø S ā‰ƒā‚—įµ¢[R] M ā§ø T where __ := Submodule.quotEquivOfEq S T h norm_map' := by subst h; rintro ⟨_⟩; rfl /-- An isometric version of `Submodule.quotientQuotientEquivQuotient`. -/ def Submodule.quotientQuotientLIEQuotient (h : S ≤ T) : (M ā§ø S) ā§ø map S.mkQ T ā‰ƒā‚—įµ¢[R] M ā§ø T where __ := Submodule.quotientQuotientEquivQuotient S T h norm_map' := (AddMonoidHomClass.isometry_iff_norm _).mp (QuotientAddGroup.quotientQuotientIsometryEquivQuotient ((Submodule.toAddSubgroup_le S T).mpr h)).isometry /-- An isometric version of `Submodule.quotientQuotientEquivQuotientSup`. -/ def Submodule.quotientQuotientLIEQuotientSup : (M ā§ø S) ā§ø map S.mkQ T ā‰ƒā‚—įµ¢[R] M ā§ø (S āŠ” T) := (quotLIEOfEq _ _ (by simp)).trans (quotientQuotientLIEQuotient _ _ le_sup_left) end Submodule section Ideal variable {R : Type*} [SeminormedCommRing R] (I : Ideal R) nonrec theorem Ideal.Quotient.norm_mk_lt {I : Ideal R} (x : R ā§ø I) {ε : ā„} (hε : 0 < ε) : ∃ r : R, Ideal.Quotient.mk I r = x ∧ ‖r‖ < ‖x‖ + ε := exists_norm_mk_lt x hε theorem Ideal.Quotient.norm_mk_le (r : R) : ‖Ideal.Quotient.mk I r‖ ≤ ‖r‖ := norm_mk_le_norm instance Ideal.Quotient.semiNormedCommRing : SeminormedCommRing (R ā§ø I) where dist_eq := dist_eq_norm mul_comm := _root_.mul_comm norm_mul_le x y := le_of_forall_pos_le_add fun ε hε => by have := ((nhds_basis_ball.prod_nhds nhds_basis_ball).tendsto_iff nhds_basis_ball).mp (continuous_mul.tendsto (‖x‖, ‖y‖)) ε hε simp only [Set.mem_prod, mem_ball, and_imp, Prod.forall, Prod.exists] at this rcases this with āŸØĪµā‚, ε₂, ⟨h₁, hā‚‚āŸ©, h⟩ obtain ⟨⟨a, rfl, ha⟩, ⟨b, rfl, hb⟩⟩ := Ideal.Quotient.norm_mk_lt x h₁, Ideal.Quotient.norm_mk_lt y hā‚‚ simp only [dist, abs_sub_lt_iff] at h specialize h ‖a‖ ‖b‖ ⟨by linarith, by linarith [Ideal.Quotient.norm_mk_le I a]⟩ ⟨by linarith, by linarith [Ideal.Quotient.norm_mk_le I b]⟩ calc _ ≤ ‖a‖ * ‖b‖ := (Ideal.Quotient.norm_mk_le I (a * b)).trans (norm_mul_le a b) _ ≤ _ := (sub_lt_iff_lt_add'.mp h.1).le instance Ideal.Quotient.normedCommRing [IsClosed (I : Set R)] : NormedCommRing (R ā§ø I) := { Ideal.Quotient.semiNormedCommRing I, Submodule.Quotient.normedAddCommGroup I with } variable (š•œ : Type*) [NormedField š•œ] instance Ideal.Quotient.normedAlgebra [NormedAlgebra š•œ R] : NormedAlgebra š•œ (R ā§ø I) := { Submodule.Quotient.normedSpace I š•œ, Ideal.Quotient.algebra š•œ with } end Ideal
.lake/packages/mathlib/Mathlib/Analysis/Normed/Group/Constructions.lean
import Mathlib.Algebra.Group.PUnit import Mathlib.Algebra.Group.ULift import Mathlib.Analysis.Normed.Group.Basic /-! # Product of normed groups and other constructions This file constructs the infinity norm on finite products of normed groups and provides instances for type synonyms. -/ open NNReal variable {ι E F : Type*} {G : ι → Type*} /-! ### `PUnit` -/ namespace PUnit instance normedAddCommGroup : NormedAddCommGroup PUnit where norm := Function.const _ 0 dist_eq _ _ := rfl @[simp] lemma norm_eq_zero (x : PUnit) : ‖x‖ = 0 := rfl end PUnit /-! ### `ULift` -/ namespace ULift section Norm variable [Norm E] instance norm : Norm (ULift E) where norm x := ‖x.down‖ lemma norm_def (x : ULift E) : ‖x‖ = ‖x.down‖ := rfl @[simp] lemma norm_up (x : E) : ‖ULift.up x‖ = ‖x‖ := rfl @[simp] lemma norm_down (x : ULift E) : ‖x.down‖ = ‖x‖ := rfl end Norm section NNNorm variable [NNNorm E] instance nnnorm : NNNorm (ULift E) where nnnorm x := ‖x.downā€–ā‚Š lemma nnnorm_def (x : ULift E) : ‖xā€–ā‚Š = ‖x.downā€–ā‚Š := rfl @[simp] lemma nnnorm_up (x : E) : ‖ULift.up xā€–ā‚Š = ‖xā€–ā‚Š := rfl @[simp] lemma nnnorm_down (x : ULift E) : ‖x.downā€–ā‚Š = ‖xā€–ā‚Š := rfl end NNNorm @[to_additive] instance seminormedGroup [SeminormedGroup E] : SeminormedGroup (ULift E) := SeminormedGroup.induced _ _ { toFun := ULift.down, map_one' := rfl, map_mul' := fun _ _ => rfl : ULift E →* E } @[to_additive] instance seminormedCommGroup [SeminormedCommGroup E] : SeminormedCommGroup (ULift E) := SeminormedCommGroup.induced _ _ { toFun := ULift.down, map_one' := rfl, map_mul' := fun _ _ => rfl : ULift E →* E } @[to_additive] instance normedGroup [NormedGroup E] : NormedGroup (ULift E) := NormedGroup.induced _ _ { toFun := ULift.down, map_one' := rfl, map_mul' := fun _ _ => rfl : ULift E →* E } down_injective @[to_additive] instance normedCommGroup [NormedCommGroup E] : NormedCommGroup (ULift E) := NormedCommGroup.induced _ _ { toFun := ULift.down, map_one' := rfl, map_mul' := fun _ _ => rfl : ULift E →* E } down_injective end ULift /-! ### `Additive`, `Multiplicative` -/ section AdditiveMultiplicative open Additive Multiplicative section Norm variable [Norm E] instance Additive.toNorm : Norm (Additive E) := ‹Norm E› instance Multiplicative.toNorm : Norm (Multiplicative E) := ‹Norm E› @[simp] lemma norm_toMul (x : Additive E) : ‖(x.toMul : E)‖ = ‖x‖ := rfl @[simp] lemma norm_ofMul (x : E) : ‖ofMul x‖ = ‖x‖ := rfl @[simp] lemma norm_toAdd (x : Multiplicative E) : ‖(x.toAdd : E)‖ = ‖x‖ := rfl @[simp] lemma norm_ofAdd (x : E) : ‖ofAdd x‖ = ‖x‖ := rfl end Norm section NNNorm variable [NNNorm E] instance Additive.toNNNorm : NNNorm (Additive E) := ‹NNNorm E› instance Multiplicative.toNNNorm : NNNorm (Multiplicative E) := ‹NNNorm E› @[simp] lemma nnnorm_toMul (x : Additive E) : ‖(x.toMul : E)ā€–ā‚Š = ‖xā€–ā‚Š := rfl @[simp] lemma nnnorm_ofMul (x : E) : ‖ofMul xā€–ā‚Š = ‖xā€–ā‚Š := rfl @[simp] lemma nnnorm_toAdd (x : Multiplicative E) : ‖(x.toAdd : E)ā€–ā‚Š = ‖xā€–ā‚Š := rfl @[simp] lemma nnnorm_ofAdd (x : E) : ‖ofAdd xā€–ā‚Š = ‖xā€–ā‚Š := rfl end NNNorm instance Additive.seminormedAddGroup [SeminormedGroup E] : SeminormedAddGroup (Additive E) where dist_eq x y := dist_eq_norm_div x.toMul y.toMul instance Multiplicative.seminormedGroup [SeminormedAddGroup E] : SeminormedGroup (Multiplicative E) where dist_eq x y := dist_eq_norm_sub x.toAdd y.toAdd instance Additive.seminormedCommGroup [SeminormedCommGroup E] : SeminormedAddCommGroup (Additive E) := { Additive.seminormedAddGroup with add_comm := add_comm } instance Multiplicative.seminormedAddCommGroup [SeminormedAddCommGroup E] : SeminormedCommGroup (Multiplicative E) := { Multiplicative.seminormedGroup with mul_comm := mul_comm } instance Additive.normedAddGroup [NormedGroup E] : NormedAddGroup (Additive E) := { Additive.seminormedAddGroup with eq_of_dist_eq_zero := eq_of_dist_eq_zero } instance Multiplicative.normedGroup [NormedAddGroup E] : NormedGroup (Multiplicative E) := { Multiplicative.seminormedGroup with eq_of_dist_eq_zero := eq_of_dist_eq_zero } instance Additive.normedAddCommGroup [NormedCommGroup E] : NormedAddCommGroup (Additive E) := { Additive.seminormedAddGroup with add_comm := add_comm eq_of_dist_eq_zero := eq_of_dist_eq_zero } instance Multiplicative.normedCommGroup [NormedAddCommGroup E] : NormedCommGroup (Multiplicative E) := { Multiplicative.seminormedGroup with mul_comm := mul_comm eq_of_dist_eq_zero := eq_of_dist_eq_zero } end AdditiveMultiplicative /-! ### Order dual -/ section OrderDual open OrderDual section Norm variable [Norm E] instance OrderDual.toNorm : Norm Eįµ’įµˆ := ‹Norm E› @[simp] lemma norm_toDual (x : E) : ‖toDual x‖ = ‖x‖ := rfl @[simp] lemma norm_ofDual (x : Eįµ’įµˆ) : ‖ofDual x‖ = ‖x‖ := rfl end Norm section NNNorm variable [NNNorm E] instance OrderDual.toNNNorm : NNNorm Eįµ’įµˆ := ‹NNNorm E› @[simp] lemma nnnorm_toDual (x : E) : ‖toDual xā€–ā‚Š = ‖xā€–ā‚Š := rfl @[simp] lemma nnnorm_ofDual (x : Eįµ’įµˆ) : ‖ofDual xā€–ā‚Š = ‖xā€–ā‚Š := rfl end NNNorm namespace OrderDual -- See note [lower instance priority] @[to_additive] instance (priority := 100) seminormedGroup [SeminormedGroup E] : SeminormedGroup Eįµ’įµˆ := ‹SeminormedGroup E› -- See note [lower instance priority] @[to_additive] instance (priority := 100) seminormedCommGroup [SeminormedCommGroup E] : SeminormedCommGroup Eįµ’įµˆ := ‹SeminormedCommGroup E› -- See note [lower instance priority] @[to_additive] instance (priority := 100) normedGroup [NormedGroup E] : NormedGroup Eįµ’įµˆ := ‹NormedGroup E› -- See note [lower instance priority] @[to_additive] instance (priority := 100) normedCommGroup [NormedCommGroup E] : NormedCommGroup Eįµ’įµˆ := ‹NormedCommGroup E› end OrderDual end OrderDual /-! ### Binary product of normed groups -/ section Norm variable [Norm E] [Norm F] {x : E Ɨ F} {r : ā„} instance Prod.toNorm : Norm (E Ɨ F) where norm x := ‖x.1‖ āŠ” ‖x.2‖ lemma Prod.norm_def (x : E Ɨ F) : ‖x‖ = max ‖x.1‖ ‖x.2‖ := rfl @[simp] lemma Prod.norm_mk (x : E) (y : F) : ‖(x, y)‖ = max ‖x‖ ‖y‖ := rfl lemma norm_fst_le (x : E Ɨ F) : ‖x.1‖ ≤ ‖x‖ := le_max_left _ _ lemma norm_snd_le (x : E Ɨ F) : ‖x.2‖ ≤ ‖x‖ := le_max_right _ _ lemma norm_prod_le_iff : ‖x‖ ≤ r ↔ ‖x.1‖ ≤ r ∧ ‖x.2‖ ≤ r := max_le_iff end Norm section SeminormedGroup variable [SeminormedGroup E] [SeminormedGroup F] /-- Product of seminormed groups, using the sup norm. -/ @[to_additive /-- Product of seminormed groups, using the sup norm. -/] instance Prod.seminormedGroup : SeminormedGroup (E Ɨ F) where dist_eq x y := by simp only [Prod.norm_def, Prod.dist_eq, dist_eq_norm_div, Prod.fst_div, Prod.snd_div] /-- Multiplicative version of `Prod.nnnorm_def`. Earlier, this names was used for the additive version. -/ @[to_additive Prod.nnnorm_def] lemma Prod.nnnorm_def' (x : E Ɨ F) : ‖xā€–ā‚Š = max ‖x.1ā€–ā‚Š ‖x.2ā€–ā‚Š := rfl /-- Multiplicative version of `Prod.nnnorm_mk`. -/ @[to_additive (attr := simp) Prod.nnnorm_mk] lemma Prod.nnnorm_mk' (x : E) (y : F) : ‖(x, y)ā€–ā‚Š = max ‖xā€–ā‚Š ‖yā€–ā‚Š := rfl end SeminormedGroup namespace Prod /-- Product of seminormed groups, using the sup norm. -/ @[to_additive /-- Product of seminormed groups, using the sup norm. -/] instance seminormedCommGroup [SeminormedCommGroup E] [SeminormedCommGroup F] : SeminormedCommGroup (E Ɨ F) := { Prod.seminormedGroup with mul_comm := mul_comm } /-- Product of normed groups, using the sup norm. -/ @[to_additive /-- Product of normed groups, using the sup norm. -/] instance normedGroup [NormedGroup E] [NormedGroup F] : NormedGroup (E Ɨ F) := { Prod.seminormedGroup with eq_of_dist_eq_zero := eq_of_dist_eq_zero } /-- Product of normed groups, using the sup norm. -/ @[to_additive /-- Product of normed groups, using the sup norm. -/] instance normedCommGroup [NormedCommGroup E] [NormedCommGroup F] : NormedCommGroup (E Ɨ F) := { Prod.seminormedGroup with mul_comm := mul_comm eq_of_dist_eq_zero := eq_of_dist_eq_zero } end Prod /-! ### Finite product of normed groups -/ section Pi variable [Fintype ι] section SeminormedGroup variable [āˆ€ i, SeminormedGroup (G i)] [SeminormedGroup E] (f : āˆ€ i, G i) {x : āˆ€ i, G i} {r : ā„} /-- Finite product of seminormed groups, using the sup norm. -/ @[to_additive /-- Finite product of seminormed groups, using the sup norm. -/] instance Pi.seminormedGroup : SeminormedGroup (āˆ€ i, G i) where norm f := ↑(Finset.univ.sup fun b => ‖f bā€–ā‚Š) dist_eq x y := congr_arg (toReal : ā„ā‰„0 → ā„) <| congr_arg (Finset.sup Finset.univ) <| funext fun a => show nndist (x a) (y a) = ‖x a / y aā€–ā‚Š from nndist_eq_nnnorm_div (x a) (y a) @[to_additive Pi.norm_def] lemma Pi.norm_def' : ‖f‖ = ↑(Finset.univ.sup fun b => ‖f bā€–ā‚Š) := rfl @[to_additive Pi.nnnorm_def] lemma Pi.nnnorm_def' : ‖fā€–ā‚Š = Finset.univ.sup fun b => ‖f bā€–ā‚Š := Subtype.eta _ _ /-- The seminorm of an element in a product space is `≤ r` if and only if the norm of each component is. -/ @[to_additive pi_norm_le_iff_of_nonneg /-- The seminorm of an element in a product space is `≤ r` if and only if the norm of each component is. -/] lemma pi_norm_le_iff_of_nonneg' (hr : 0 ≤ r) : ‖x‖ ≤ r ↔ āˆ€ i, ‖x i‖ ≤ r := by simp only [← dist_one_right, dist_pi_le_iff hr, Pi.one_apply] @[to_additive pi_nnnorm_le_iff] lemma pi_nnnorm_le_iff' {r : ā„ā‰„0} : ‖xā€–ā‚Š ≤ r ↔ āˆ€ i, ‖x iā€–ā‚Š ≤ r := pi_norm_le_iff_of_nonneg' r.coe_nonneg @[to_additive pi_norm_le_iff_of_nonempty] lemma pi_norm_le_iff_of_nonempty' [Nonempty ι] : ‖f‖ ≤ r ↔ āˆ€ b, ‖f b‖ ≤ r := by by_cases hr : 0 ≤ r Ā· exact pi_norm_le_iff_of_nonneg' hr Ā· exact iff_of_false (fun h => hr <| (norm_nonneg' _).trans h) fun h => hr <| (norm_nonneg' _).trans <| h <| Classical.arbitrary _ /-- The seminorm of an element in a product space is `< r` if and only if the norm of each component is. -/ @[to_additive pi_norm_lt_iff /-- The seminorm of an element in a product space is `< r` if and only if the norm of each component is. -/] lemma pi_norm_lt_iff' (hr : 0 < r) : ‖x‖ < r ↔ āˆ€ i, ‖x i‖ < r := by simp only [← dist_one_right, dist_pi_lt_iff hr, Pi.one_apply] @[to_additive pi_nnnorm_lt_iff] lemma pi_nnnorm_lt_iff' {r : ā„ā‰„0} (hr : 0 < r) : ‖xā€–ā‚Š < r ↔ āˆ€ i, ‖x iā€–ā‚Š < r := pi_norm_lt_iff' hr @[to_additive norm_le_pi_norm] lemma norm_le_pi_norm' (i : ι) : ‖f i‖ ≤ ‖f‖ := (pi_norm_le_iff_of_nonneg' <| norm_nonneg' _).1 le_rfl i @[to_additive nnnorm_le_pi_nnnorm] lemma nnnorm_le_pi_nnnorm' (i : ι) : ‖f iā€–ā‚Š ≤ ‖fā€–ā‚Š := norm_le_pi_norm' _ i @[to_additive pi_norm_const_le] lemma pi_norm_const_le' (a : E) : ‖fun _ : ι => a‖ ≤ ‖a‖ := (pi_norm_le_iff_of_nonneg' <| norm_nonneg' _).2 fun _ => le_rfl @[to_additive pi_nnnorm_const_le] lemma pi_nnnorm_const_le' (a : E) : ‖fun _ : ι => aā€–ā‚Š ≤ ‖aā€–ā‚Š := pi_norm_const_le' _ @[to_additive (attr := simp) pi_norm_const] lemma pi_norm_const' [Nonempty ι] (a : E) : ‖fun _i : ι => a‖ = ‖a‖ := by simpa only [← dist_one_right] using dist_pi_const a 1 @[to_additive (attr := simp) pi_nnnorm_const] lemma pi_nnnorm_const' [Nonempty ι] (a : E) : ‖fun _i : ι => aā€–ā‚Š = ‖aā€–ā‚Š := NNReal.eq <| pi_norm_const' a /-- The $L^1$ norm is less than the $L^\infty$ norm scaled by the cardinality. -/ @[to_additive Pi.sum_norm_apply_le_norm /-- The $L^1$ norm is less than the $L^\infty$ norm scaled by the cardinality. -/] lemma Pi.sum_norm_apply_le_norm' : āˆ‘ i, ‖f i‖ ≤ Fintype.card ι • ‖f‖ := Finset.sum_le_card_nsmul _ _ _ fun i _hi => norm_le_pi_norm' _ i /-- The $L^1$ norm is less than the $L^\infty$ norm scaled by the cardinality. -/ @[to_additive Pi.sum_nnnorm_apply_le_nnnorm /-- The $L^1$ norm is less than the $L^\infty$ norm scaled by the cardinality. -/] lemma Pi.sum_nnnorm_apply_le_nnnorm' : āˆ‘ i, ‖f iā€–ā‚Š ≤ Fintype.card ι • ‖fā€–ā‚Š := (NNReal.coe_sum ..).trans_le <| Pi.sum_norm_apply_le_norm' _ end SeminormedGroup /-- Finite product of seminormed groups, using the sup norm. -/ @[to_additive /-- Finite product of seminormed groups, using the sup norm. -/] instance Pi.seminormedCommGroup [āˆ€ i, SeminormedCommGroup (G i)] : SeminormedCommGroup (āˆ€ i, G i) := { Pi.seminormedGroup with mul_comm := mul_comm } /-- Finite product of normed groups, using the sup norm. -/ @[to_additive /-- Finite product of seminormed groups, using the sup norm. -/] instance Pi.normedGroup [āˆ€ i, NormedGroup (G i)] : NormedGroup (āˆ€ i, G i) := { Pi.seminormedGroup with eq_of_dist_eq_zero := eq_of_dist_eq_zero } /-- Finite product of normed groups, using the sup norm. -/ @[to_additive /-- Finite product of seminormed groups, using the sup norm. -/] instance Pi.normedCommGroup [āˆ€ i, NormedCommGroup (G i)] : NormedCommGroup (āˆ€ i, G i) := { Pi.seminormedGroup with mul_comm := mul_comm eq_of_dist_eq_zero := eq_of_dist_eq_zero } theorem Pi.nnnorm_single [DecidableEq ι] [āˆ€ i, NormedAddCommGroup (G i)] {i : ι} (y : G i) : ‖Pi.single i yā€–ā‚Š = ‖yā€–ā‚Š := by have H : āˆ€ b, ‖single i y bā€–ā‚Š = single (M := fun _ ↦ ā„ā‰„0) i ‖yā€–ā‚Š b := by intro b refine Pi.apply_single (fun i (x : G i) ↦ ‖xā€–ā‚Š) ?_ i y b simp simp [Pi.nnnorm_def, H, Pi.single_apply, Finset.sup_ite, Finset.filter_eq'] lemma Pi.enorm_single [DecidableEq ι] [āˆ€ i, NormedAddCommGroup (G i)] {i : ι} (y : G i) : ‖Pi.single i y‖ₑ = ‖y‖ₑ := by simp [enorm, Pi.nnnorm_single] theorem Pi.norm_single [DecidableEq ι] [āˆ€ i, NormedAddCommGroup (G i)] {i : ι} (y : G i) : ‖Pi.single i y‖ = ‖y‖ := congr_arg Subtype.val <| Pi.nnnorm_single y end Pi /-! ### Multiplicative opposite -/ namespace MulOpposite /-- The (additive) norm on the multiplicative opposite is the same as the norm on the original type. Note that we do not provide this more generally as `Norm Eᵐᵒᵖ`, as this is not always a good choice of norm in the multiplicative `SeminormedGroup E` case. We could repeat this instance to provide a `[SeminormedGroup E] : SeminormedGroup Eįµƒįµ’įµ–` instance, but that case would likely never be used. -/ instance instSeminormedAddGroup [SeminormedAddGroup E] : SeminormedAddGroup Eᵐᵒᵖ where __ := instPseudoMetricSpace norm x := ‖x.unop‖ dist_eq _ _ := dist_eq_norm _ _ lemma norm_op [SeminormedAddGroup E] (a : E) : ‖MulOpposite.op a‖ = ‖a‖ := rfl lemma norm_unop [SeminormedAddGroup E] (a : Eᵐᵒᵖ) : ‖MulOpposite.unop a‖ = ‖a‖ := rfl lemma nnnorm_op [SeminormedAddGroup E] (a : E) : ‖MulOpposite.op aā€–ā‚Š = ‖aā€–ā‚Š := rfl lemma nnnorm_unop [SeminormedAddGroup E] (a : Eᵐᵒᵖ) : ‖MulOpposite.unop aā€–ā‚Š = ‖aā€–ā‚Š := rfl instance instNormedAddGroup [NormedAddGroup E] : NormedAddGroup Eᵐᵒᵖ where __ := instMetricSpace __ := instSeminormedAddGroup instance instSeminormedAddCommGroup [SeminormedAddCommGroup E] : SeminormedAddCommGroup Eᵐᵒᵖ where dist_eq _ _ := dist_eq_norm _ _ instance instNormedAddCommGroup [NormedAddCommGroup E] : NormedAddCommGroup Eᵐᵒᵖ where __ := instSeminormedAddCommGroup __ := instNormedAddGroup end MulOpposite
.lake/packages/mathlib/Mathlib/Analysis/Normed/Group/Continuity.lean
import Mathlib.Analysis.Normed.Group.Basic import Mathlib.Topology.Algebra.Ring.Real import Mathlib.Topology.Metrizable.Uniformity import Mathlib.Topology.Sequences /-! # Continuity of the norm on (semi)groups ## Tags normed group -/ variable {š“• α ι Īŗ E F G : Type*} open Filter Function Metric Bornology ENNReal NNReal Uniformity Pointwise Topology section SeminormedGroup variable [SeminormedGroup E] [SeminormedGroup F] [SeminormedGroup G] {s : Set E} {a : E} @[to_additive] theorem tendsto_iff_norm_div_tendsto_zero {f : α → E} {a : Filter α} {b : E} : Tendsto f a (š“ b) ↔ Tendsto (fun e => ‖f e / b‖) a (š“ 0) := by simp only [← dist_eq_norm_div, ← tendsto_iff_dist_tendsto_zero] @[to_additive] theorem tendsto_one_iff_norm_tendsto_zero {f : α → E} {a : Filter α} : Tendsto f a (š“ 1) ↔ Tendsto (‖f ·‖) a (š“ 0) := tendsto_iff_norm_div_tendsto_zero.trans <| by simp only [div_one] @[to_additive (attr := simp 1100)] theorem comap_norm_nhds_one : comap norm (š“ 0) = š“ (1 : E) := by simpa only [dist_one_right] using nhds_comap_dist (1 : E) /-- Special case of the sandwich theorem: if the norm of `f` is eventually bounded by a real function `a` which tends to `0`, then `f` tends to `1` (neutral element of `SeminormedGroup`). In this pair of lemmas (`squeeze_one_norm'` and `squeeze_one_norm`), following a convention of similar lemmas in `Topology.MetricSpace.Basic` and `Topology.Algebra.Order`, the `'` version is phrased using "eventually" and the non-`'` version is phrased absolutely. -/ @[to_additive /-- Special case of the sandwich theorem: if the norm of `f` is eventually bounded by a real function `a` which tends to `0`, then `f` tends to `0`. In this pair of lemmas (`squeeze_zero_norm'` and `squeeze_zero_norm`), following a convention of similar lemmas in `Topology.MetricSpace.Pseudo.Defs` and `Topology.Algebra.Order`, the `'` version is phrased using "eventually" and the non-`'` version is phrased absolutely. -/] theorem squeeze_one_norm' {f : α → E} {a : α → ā„} {tā‚€ : Filter α} (h : āˆ€į¶  n in tā‚€, ‖f n‖ ≤ a n) (h' : Tendsto a tā‚€ (š“ 0)) : Tendsto f tā‚€ (š“ 1) := tendsto_one_iff_norm_tendsto_zero.2 <| squeeze_zero' (Eventually.of_forall fun _n => norm_nonneg' _) h h' /-- Special case of the sandwich theorem: if the norm of `f` is bounded by a real function `a` which tends to `0`, then `f` tends to `1`. -/ @[to_additive /-- Special case of the sandwich theorem: if the norm of `f` is bounded by a real function `a` which tends to `0`, then `f` tends to `0`. -/] theorem squeeze_one_norm {f : α → E} {a : α → ā„} {tā‚€ : Filter α} (h : āˆ€ n, ‖f n‖ ≤ a n) : Tendsto a tā‚€ (š“ 0) → Tendsto f tā‚€ (š“ 1) := squeeze_one_norm' <| Eventually.of_forall h @[to_additive] theorem tendsto_norm_div_self (x : E) : Tendsto (fun a => ‖a / x‖) (š“ x) (š“ 0) := by simpa [dist_eq_norm_div] using tendsto_id.dist (tendsto_const_nhds : Tendsto (fun _a => (x : E)) (š“ x) _) @[to_additive] theorem tendsto_norm_div_self_nhdsGE (x : E) : Tendsto (fun a ↦ ‖a / x‖) (š“ x) (š“[≄] 0) := tendsto_nhdsWithin_iff.mpr ⟨tendsto_norm_div_self x, by simp⟩ @[to_additive tendsto_norm] theorem tendsto_norm' {x : E} : Tendsto (fun a => ‖a‖) (š“ x) (š“ ‖x‖) := by simpa using tendsto_id.dist (tendsto_const_nhds : Tendsto (fun _a => (1 : E)) _ _) /-- See `tendsto_norm_one` for a version with pointed neighborhoods. -/ @[to_additive /-- See `tendsto_norm_zero` for a version with pointed neighborhoods. -/] theorem tendsto_norm_one : Tendsto (fun a : E => ‖a‖) (š“ 1) (š“ 0) := by simpa using tendsto_norm_div_self (1 : E) @[to_additive (attr := continuity, fun_prop) continuous_norm] theorem continuous_norm' : Continuous fun a : E => ‖a‖ := by simpa using continuous_id.dist (continuous_const : Continuous fun _a => (1 : E)) @[to_additive (attr := continuity, fun_prop) continuous_nnnorm] theorem continuous_nnnorm' : Continuous fun a : E => ‖aā€–ā‚Š := continuous_norm'.subtype_mk _ end SeminormedGroup section Instances @[to_additive] instance SeminormedGroup.toContinuousENorm [SeminormedGroup E] : ContinuousENorm E where continuous_enorm := ENNReal.isOpenEmbedding_coe.continuous.comp continuous_nnnorm' @[to_additive] instance NormedGroup.toENormedMonoid {F : Type*} [NormedGroup F] : ENormedMonoid F where enorm_zero := by simp [enorm_eq_nnnorm] enorm_eq_zero := by simp [enorm_eq_nnnorm] enorm_mul_le := by simp [enorm_eq_nnnorm, ← coe_add, nnnorm_mul_le'] @[to_additive] instance NormedCommGroup.toENormedCommMonoid [NormedCommGroup E] : ENormedCommMonoid E where __ := NormedGroup.toENormedMonoid __ := ‹NormedCommGroup E› end Instances section SeminormedGroup variable [SeminormedGroup E] [SeminormedGroup F] [SeminormedGroup G] {s : Set E} {a : E} set_option linter.docPrime false in @[to_additive Inseparable.norm_eq_norm] theorem Inseparable.norm_eq_norm' {u v : E} (h : Inseparable u v) : ‖u‖ = ‖v‖ := h.map continuous_norm' |>.eq set_option linter.docPrime false in @[to_additive Inseparable.nnnorm_eq_nnnorm] theorem Inseparable.nnnorm_eq_nnnorm' {u v : E} (h : Inseparable u v) : ‖uā€–ā‚Š = ‖vā€–ā‚Š := h.map continuous_nnnorm' |>.eq @[to_additive Inseparable.enorm_eq_enorm] theorem Inseparable.enorm_eq_enorm' {E : Type*} [TopologicalSpace E] [ContinuousENorm E] {u v : E} (h : Inseparable u v) : ‖u‖ₑ = ‖v‖ₑ := h.map continuous_enorm |>.eq @[to_additive] theorem mem_closure_one_iff_norm {x : E} : x ∈ closure ({1} : Set E) ↔ ‖x‖ = 0 := by rw [← closedBall_zero', mem_closedBall_one_iff, (norm_nonneg' x).ge_iff_eq'] @[to_additive] theorem closure_one_eq : closure ({1} : Set E) = { x | ‖x‖ = 0 } := Set.ext fun _x => mem_closure_one_iff_norm section variable {l : Filter α} {f : α → E} @[to_additive Filter.Tendsto.norm] theorem Filter.Tendsto.norm' (h : Tendsto f l (š“ a)) : Tendsto (fun x => ‖f x‖) l (š“ ‖a‖) := tendsto_norm'.comp h @[to_additive Filter.Tendsto.nnnorm] theorem Filter.Tendsto.nnnorm' (h : Tendsto f l (š“ a)) : Tendsto (fun x => ‖f xā€–ā‚Š) l (š“ ‖aā€–ā‚Š) := Tendsto.comp continuous_nnnorm'.continuousAt h end section variable [TopologicalSpace α] {f : α → E} {s : Set α} {a : α} @[to_additive (attr := fun_prop) Continuous.norm] theorem Continuous.norm' : Continuous f → Continuous fun x => ‖f x‖ := continuous_norm'.comp @[to_additive (attr := fun_prop) Continuous.nnnorm] theorem Continuous.nnnorm' : Continuous f → Continuous fun x => ‖f xā€–ā‚Š := continuous_nnnorm'.comp end end SeminormedGroup section ContinuousENorm variable [TopologicalSpace E] [ContinuousENorm E] {a : E} {l : Filter α} {f : α → E} @[to_additive Filter.Tendsto.enorm] lemma Filter.Tendsto.enorm' (h : Tendsto f l (š“ a)) : Tendsto (‖f ·‖ₑ) l (š“ ‖a‖ₑ) := .comp continuous_enorm.continuousAt h end ContinuousENorm section SeminormedGroup variable [SeminormedGroup E] [SeminormedGroup F] [SeminormedGroup G] {s : Set E} {a : E} section variable [TopologicalSpace α] {f : α → E} {s : Set α} {a : α} @[to_additive (attr := fun_prop) ContinuousAt.norm] theorem ContinuousAt.norm' {a : α} (h : ContinuousAt f a) : ContinuousAt (fun x => ‖f x‖) a := Tendsto.norm' h @[to_additive (attr := fun_prop) ContinuousAt.nnnorm] theorem ContinuousAt.nnnorm' {a : α} (h : ContinuousAt f a) : ContinuousAt (fun x => ‖f xā€–ā‚Š) a := Tendsto.nnnorm' h @[to_additive ContinuousWithinAt.norm] theorem ContinuousWithinAt.norm' {s : Set α} {a : α} (h : ContinuousWithinAt f s a) : ContinuousWithinAt (fun x => ‖f x‖) s a := Tendsto.norm' h @[to_additive ContinuousWithinAt.nnnorm] theorem ContinuousWithinAt.nnnorm' {s : Set α} {a : α} (h : ContinuousWithinAt f s a) : ContinuousWithinAt (fun x => ‖f xā€–ā‚Š) s a := Tendsto.nnnorm' h @[to_additive (attr := fun_prop) ContinuousOn.norm] theorem ContinuousOn.norm' {s : Set α} (h : ContinuousOn f s) : ContinuousOn (fun x => ‖f x‖) s := fun x hx => (h x hx).norm' @[to_additive (attr := fun_prop) ContinuousOn.nnnorm] theorem ContinuousOn.nnnorm' {s : Set α} (h : ContinuousOn f s) : ContinuousOn (fun x => ‖f xā€–ā‚Š) s := fun x hx => (h x hx).nnnorm' end /-- If `‖y‖ → āˆž`, then we can assume `y ≠ x` for any fixed `x`. -/ @[to_additive eventually_ne_of_tendsto_norm_atTop /-- If `‖yā€–ā†’āˆž`, then we can assume `y≠x` for any fixed `x` -/] theorem eventually_ne_of_tendsto_norm_atTop' {l : Filter α} {f : α → E} (h : Tendsto (fun y => ‖f y‖) l atTop) (x : E) : āˆ€į¶  y in l, f y ≠ x := (h.eventually_ne_atTop _).mono fun _x => ne_of_apply_ne norm @[to_additive] theorem SeminormedCommGroup.mem_closure_iff : a ∈ closure s ↔ āˆ€ ε, 0 < ε → ∃ b ∈ s, ‖a / b‖ < ε := by simp [Metric.mem_closure_iff, dist_eq_norm_div] @[to_additive] theorem SeminormedGroup.tendstoUniformlyOn_one {f : ι → Īŗ → G} {s : Set Īŗ} {l : Filter ι} : TendstoUniformlyOn f 1 l s ↔ āˆ€ ε > 0, āˆ€į¶  i in l, āˆ€ x ∈ s, ‖f i x‖ < ε := by simp only [tendstoUniformlyOn_iff, Pi.one_apply, dist_one_left] @[to_additive] theorem SeminormedGroup.uniformCauchySeqOnFilter_iff_tendstoUniformlyOnFilter_one {f : ι → Īŗ → G} {l : Filter ι} {l' : Filter Īŗ} : UniformCauchySeqOnFilter f l l' ↔ TendstoUniformlyOnFilter (fun n : ι Ɨ ι => fun z => f n.fst z / f n.snd z) 1 (l Ć—Ė¢ l) l' := by refine ⟨fun hf u hu => ?_, fun hf u hu => ?_⟩ Ā· obtain ⟨ε, hε, H⟩ := uniformity_basis_dist.mem_uniformity_iff.mp hu refine (hf { p : G Ɨ G | dist p.fst p.snd < ε } <| dist_mem_uniformity hε).mono fun x hx => H 1 (f x.fst.fst x.snd / f x.fst.snd x.snd) ?_ simpa [dist_eq_norm_div, norm_div_rev] using hx Ā· obtain ⟨ε, hε, H⟩ := uniformity_basis_dist.mem_uniformity_iff.mp hu refine (hf { p : G Ɨ G | dist p.fst p.snd < ε } <| dist_mem_uniformity hε).mono fun x hx => H (f x.fst.fst x.snd) (f x.fst.snd x.snd) ?_ simpa [dist_eq_norm_div, norm_div_rev] using hx @[to_additive] theorem SeminormedGroup.uniformCauchySeqOn_iff_tendstoUniformlyOn_one {f : ι → Īŗ → G} {s : Set Īŗ} {l : Filter ι} : UniformCauchySeqOn f l s ↔ TendstoUniformlyOn (fun n : ι Ɨ ι => fun z => f n.fst z / f n.snd z) 1 (l Ć—Ė¢ l) s := by rw [tendstoUniformlyOn_iff_tendstoUniformlyOnFilter, uniformCauchySeqOn_iff_uniformCauchySeqOnFilter, SeminormedGroup.uniformCauchySeqOnFilter_iff_tendstoUniformlyOnFilter_one] end SeminormedGroup section SeminormedCommGroup variable [SeminormedCommGroup E] [SeminormedCommGroup F] {a b : E} {r : ā„} open Finset @[to_additive] theorem controlled_prod_of_mem_closure {s : Subgroup E} (hg : a ∈ closure (s : Set E)) {b : ā„• → ā„} (b_pos : āˆ€ n, 0 < b n) : ∃ v : ā„• → E, Tendsto (fun n => āˆ i ∈ range (n + 1), v i) atTop (š“ a) ∧ (āˆ€ n, v n ∈ s) ∧ ‖v 0 / a‖ < b 0 ∧ āˆ€ n, 0 < n → ‖v n‖ < b n := by obtain ⟨u : ā„• → E, u_in : āˆ€ n, u n ∈ s, lim_u : Tendsto u atTop (š“ a)⟩ := mem_closure_iff_seq_limit.mp hg obtain ⟨nā‚€, hnā‚€āŸ© : ∃ nā‚€, āˆ€ n ≄ nā‚€, ‖u n / a‖ < b 0 := haveI : { x | ‖x / a‖ < b 0 } ∈ š“ a := by simp_rw [← dist_eq_norm_div] exact Metric.ball_mem_nhds _ (b_pos _) Filter.tendsto_atTop'.mp lim_u _ this set z : ā„• → E := fun n => u (n + nā‚€) have lim_z : Tendsto z atTop (š“ a) := lim_u.comp (tendsto_add_atTop_nat nā‚€) have mem_š“¤ : āˆ€ n, { p : E Ɨ E | ‖p.1 / p.2‖ < b (n + 1) } ∈ š“¤ E := fun n => by simpa [← dist_eq_norm_div] using Metric.dist_mem_uniformity (b_pos <| n + 1) obtain āŸØĻ† : ā„• → ā„•, φ_extr : StrictMono φ, hφ : āˆ€ n, ‖z (φ <| n + 1) / z (φ n)‖ < b (n + 1)⟩ := lim_z.cauchySeq.subseq_mem mem_š“¤ set w : ā„• → E := z ∘ φ have hw : Tendsto w atTop (š“ a) := lim_z.comp φ_extr.tendsto_atTop set v : ā„• → E := fun i => if i = 0 then w 0 else w i / w (i - 1) refine ⟨v, Tendsto.congr (Finset.eq_prod_range_div' w) hw, ?_, hnā‚€ _ (nā‚€.le_add_left _), ?_⟩ Ā· rintro ⟨⟩ Ā· change w 0 ∈ s apply u_in Ā· apply s.div_mem <;> apply u_in Ā· intro l hl obtain ⟨k, rfl⟩ : ∃ k, l = k + 1 := Nat.exists_eq_succ_of_ne_zero hl.ne' apply hφ @[to_additive] theorem controlled_prod_of_mem_closure_range {j : E →* F} {b : F} (hb : b ∈ closure (j.range : Set F)) {f : ā„• → ā„} (b_pos : āˆ€ n, 0 < f n) : ∃ a : ā„• → E, Tendsto (fun n => āˆ i ∈ range (n + 1), j (a i)) atTop (š“ b) ∧ ‖j (a 0) / b‖ < f 0 ∧ āˆ€ n, 0 < n → ‖j (a n)‖ < f n := by obtain ⟨v, sum_v, v_in, hvā‚€, hv_pos⟩ := controlled_prod_of_mem_closure hb b_pos choose g hg using v_in exact ⟨g, by simpa [← hg] using sum_v, by simpa [hg 0] using hvā‚€, fun n hn => by simpa [hg] using hv_pos n hn⟩ end SeminormedCommGroup section NormedGroup variable [NormedGroup E] {a b : E} /-- See `tendsto_norm_one` for a version with full neighborhoods. -/ @[to_additive /-- See `tendsto_norm_zero` for a version with full neighborhoods. -/] lemma tendsto_norm_nhdsNE_one : Tendsto (norm : E → ā„) (š“[≠] 1) (š“[>] 0) := tendsto_norm_one.inf <| tendsto_principal_principal.2 fun _ hx ↦ norm_pos_iff'.2 hx @[to_additive] theorem tendsto_norm_div_self_nhdsNE (a : E) : Tendsto (fun x => ‖x / a‖) (š“[≠] a) (š“[>] 0) := (tendsto_norm_div_self a).inf <| tendsto_principal_principal.2 fun _x hx => norm_pos_iff'.2 <| div_ne_one.2 hx variable (E) /-- A version of `comap_norm_nhdsGT_zero` for a multiplicative normed group. -/ @[to_additive comap_norm_nhdsGT_zero] lemma comap_norm_nhdsGT_zero' : comap norm (š“[>] 0) = š“[≠] (1 : E) := by simp [nhdsWithin, comap_norm_nhds_one, Set.preimage, Set.compl_def] end NormedGroup
.lake/packages/mathlib/Mathlib/Analysis/Normed/Group/Completeness.lean
import Mathlib.Analysis.Normed.Group.Uniform import Mathlib.Analysis.SpecificLimits.Basic /-! # Completeness of normed groups This file includes a completeness criterion for normed additive groups in terms of convergent series. ## Main results * `NormedAddCommGroup.completeSpace_of_summable_imp_tendsto`: A normed additive group is complete if any absolutely convergent series converges in the space. ## References * [bergh_lofstrom_1976] `NormedAddCommGroup.completeSpace_of_summable_imp_tendsto` and `NormedAddCommGroup.summable_imp_tendsto_of_complete` correspond to the two directions of Lemma 2.2.1. ## Tags CompleteSpace, CauchySeq -/ open scoped Topology open Filter Finset section Metric variable {α : Type*} [PseudoMetricSpace α] lemma Metric.exists_subseq_summable_dist_of_cauchySeq (u : ā„• → α) (hu : CauchySeq u) : ∃ f : ā„• → ā„•, StrictMono f ∧ Summable fun i => dist (u (f (i+1))) (u (f i)) := by obtain ⟨f, hf₁, hfā‚‚āŸ© := Metric.exists_subseq_bounded_of_cauchySeq u hu (fun n => (1 / (2 : ā„))^n) (fun n => by positivity) refine ⟨f, hf₁, ?_⟩ refine Summable.of_nonneg_of_le (fun n => by positivity) ?_ summable_geometric_two exact fun n => le_of_lt <| hfā‚‚ n (f (n + 1)) <| hf₁.monotone (Nat.le_add_right n 1) end Metric section Normed variable {E : Type*} [NormedAddCommGroup E] /-- A normed additive group is complete if any absolutely convergent series converges in the space. -/ lemma NormedAddCommGroup.completeSpace_of_summable_imp_tendsto (h : āˆ€ u : ā„• → E, Summable (‖u ·‖) → ∃ a, Tendsto (fun n => āˆ‘ i ∈ range n, u i) atTop (š“ a)) : CompleteSpace E := by apply Metric.complete_of_cauchySeq_tendsto intro u hu obtain ⟨f, hf₁, hfā‚‚āŸ© := Metric.exists_subseq_summable_dist_of_cauchySeq u hu simp only [dist_eq_norm] at hfā‚‚ let v n := u (f (n + 1)) - u (f n) have hv_sum : (fun n => (āˆ‘ i ∈ range n, v i)) = fun n => u (f n) - u (f 0) := by ext n exact sum_range_sub (u ∘ f) n obtain ⟨a, ha⟩ := h v hfā‚‚ refine ⟨a + u (f 0), ?_⟩ refine tendsto_nhds_of_cauchySeq_of_subseq hu hf₁.tendsto_atTop ?_ rw [hv_sum] at ha have h₁ : Tendsto (fun n => u (f n) - u (f 0) + u (f 0)) atTop (š“ (a + u (f 0))) := Tendsto.add_const _ ha simpa only [sub_add_cancel] using h₁ /-- In a complete normed additive group, every absolutely convergent series converges in the space. -/ lemma NormedAddCommGroup.summable_imp_tendsto_of_complete [CompleteSpace E] (u : ā„• → E) (hu : Summable (‖u ·‖)) : ∃ a, Tendsto (fun n => āˆ‘ i ∈ range n, u i) atTop (š“ a) := by refine cauchySeq_tendsto_of_complete <| cauchySeq_of_summable_dist ?_ simp [dist_eq_norm, sum_range_succ, hu] /-- In a normed additive group, every absolutely convergent series converges in the space iff the space is complete. -/ lemma NormedAddCommGroup.summable_imp_tendsto_iff_completeSpace : (āˆ€ u : ā„• → E, Summable (‖u ·‖) → ∃ a, Tendsto (fun n => āˆ‘ i ∈ range n, u i) atTop (š“ a)) ↔ CompleteSpace E := ⟨completeSpace_of_summable_imp_tendsto, fun _ u hu => summable_imp_tendsto_of_complete u hu⟩ end Normed
.lake/packages/mathlib/Mathlib/Analysis/Normed/Group/Subgroup.lean
import Mathlib.Algebra.Group.Subgroup.Defs import Mathlib.Analysis.Normed.Group.Basic /-! # Subgroups of normed (semi)groups In this file, we prove that subgroups of a normed (semi)group are also normed (semi)groups. ## Tags normed group -/ open Filter Function Metric Bornology open ENNReal Filter NNReal Uniformity Pointwise Topology /-! ### Subgroups of normed groups -/ variable {E : Type*} namespace Subgroup section SeminormedGroup variable [SeminormedGroup E] {s : Subgroup E} /-- A subgroup of a seminormed group is also a seminormed group, with the restriction of the norm. -/ @[to_additive /-- A subgroup of a seminormed group is also a seminormed group, with the restriction of the norm. -/] instance seminormedGroup : SeminormedGroup s := SeminormedGroup.induced _ _ s.subtype /-- If `x` is an element of a subgroup `s` of a seminormed group `E`, its norm in `s` is equal to its norm in `E`. -/ @[to_additive (attr := simp) /-- If `x` is an element of a subgroup `s` of a seminormed group `E`, its norm in `s` is equal to its norm in `E`. -/] theorem coe_norm (x : s) : ‖x‖ = ‖(x : E)‖ := rfl /-- If `x` is an element of a subgroup `s` of a seminormed group `E`, its norm in `s` is equal to its norm in `E`. This is a reversed version of the `simp` lemma `Subgroup.coe_norm` for use by `norm_cast`. -/ @[to_additive (attr := norm_cast) /-- If `x` is an element of a subgroup `s` of a seminormed group `E`, its norm in `s` is equal to its norm in `E`. This is a reversed version of the `simp` lemma `AddSubgroup.coe_norm` for use by `norm_cast`. -/] theorem norm_coe {s : Subgroup E} (x : s) : ‖(x : E)‖ = ‖x‖ := rfl end SeminormedGroup @[to_additive] instance seminormedCommGroup [SeminormedCommGroup E] {s : Subgroup E} : SeminormedCommGroup s := SeminormedCommGroup.induced _ _ s.subtype @[to_additive] instance normedGroup [NormedGroup E] {s : Subgroup E} : NormedGroup s := NormedGroup.induced _ _ s.subtype Subtype.coe_injective @[to_additive] instance normedCommGroup [NormedCommGroup E] {s : Subgroup E} : NormedCommGroup s := NormedCommGroup.induced _ _ s.subtype Subtype.coe_injective end Subgroup /-! ### Subgroup classes of normed groups -/ namespace SubgroupClass section SeminormedGroup variable [SeminormedGroup E] {S : Type*} [SetLike S E] [SubgroupClass S E] (s : S) /-- A subgroup of a seminormed group is also a seminormed group, with the restriction of the norm. -/ @[to_additive /-- A subgroup of a seminormed additive group is also a seminormed additive group, with the restriction of the norm. -/] instance (priority := 75) seminormedGroup : SeminormedGroup s := SeminormedGroup.induced _ _ (SubgroupClass.subtype s) /-- If `x` is an element of a subgroup `s` of a seminormed group `E`, its norm in `s` is equal to its norm in `E`. -/ @[to_additive (attr := simp) /-- If `x` is an element of an additive subgroup `s` of a seminormed additive group `E`, its norm in `s` is equal to its norm in `E`. -/] theorem coe_norm (x : s) : ‖x‖ = ‖(x : E)‖ := rfl end SeminormedGroup @[to_additive] instance (priority := 75) seminormedCommGroup [SeminormedCommGroup E] {S : Type*} [SetLike S E] [SubgroupClass S E] (s : S) : SeminormedCommGroup s := SeminormedCommGroup.induced _ _ (SubgroupClass.subtype s) @[to_additive] instance (priority := 75) normedGroup [NormedGroup E] {S : Type*} [SetLike S E] [SubgroupClass S E] (s : S) : NormedGroup s := NormedGroup.induced _ _ (SubgroupClass.subtype s) Subtype.coe_injective @[to_additive] instance (priority := 75) normedCommGroup [NormedCommGroup E] {S : Type*} [SetLike S E] [SubgroupClass S E] (s : S) : NormedCommGroup s := NormedCommGroup.induced _ _ (SubgroupClass.subtype s) Subtype.coe_injective end SubgroupClass
.lake/packages/mathlib/Mathlib/Analysis/Normed/Group/Submodule.lean
import Mathlib.Algebra.Module.Submodule.LinearMap import Mathlib.Analysis.Normed.Group.Basic /-! # Submodules of normed groups -/ variable {š•œ E : Type*} namespace Submodule /-- A submodule of a seminormed group is also a seminormed group, with the restriction of the norm. -/ instance seminormedAddCommGroup [Ring š•œ] [SeminormedAddCommGroup E] [Module š•œ E] (s : Submodule š•œ E) : SeminormedAddCommGroup s := SeminormedAddCommGroup.induced _ _ s.subtype.toAddMonoidHom /-- If `x` is an element of a submodule `s` of a normed group `E`, its norm in `s` is equal to its norm in `E`. -/ @[simp] theorem coe_norm [Ring š•œ] [SeminormedAddCommGroup E] [Module š•œ E] {s : Submodule š•œ E} (x : s) : ‖x‖ = ‖(x : E)‖ := rfl /-- If `x` is an element of a submodule `s` of a normed group `E`, its norm in `E` is equal to its norm in `s`. This is a reversed version of the `simp` lemma `Submodule.coe_norm` for use by `norm_cast`. -/ @[norm_cast] theorem norm_coe [Ring š•œ] [SeminormedAddCommGroup E] [Module š•œ E] {s : Submodule š•œ E} (x : s) : ‖(x : E)‖ = ‖x‖ := rfl /-- A submodule of a normed group is also a normed group, with the restriction of the norm. -/ instance normedAddCommGroup [Ring š•œ] [NormedAddCommGroup E] [Module š•œ E] (s : Submodule š•œ E) : NormedAddCommGroup s := { Submodule.seminormedAddCommGroup s with eq_of_dist_eq_zero := eq_of_dist_eq_zero } end Submodule
.lake/packages/mathlib/Mathlib/Analysis/Normed/Group/Bounded.lean
import Mathlib.Analysis.Normed.Group.Continuity import Mathlib.Topology.MetricSpace.Bounded import Mathlib.Order.Filter.Pointwise /-! # Boundedness in normed groups This file rephrases metric boundedness in terms of norms. ## Tags normed group -/ open Filter Metric Bornology open scoped Pointwise Topology variable {α E F G : Type*} section SeminormedGroup variable [SeminormedGroup E] [SeminormedGroup F] [SeminormedGroup G] {s : Set E} @[to_additive (attr := simp) comap_norm_atTop] lemma comap_norm_atTop' : comap norm atTop = cobounded E := by simpa only [dist_one_right] using comap_dist_right_atTop (1 : E) @[to_additive Filter.HasBasis.cobounded_of_norm] lemma Filter.HasBasis.cobounded_of_norm' {ι : Sort*} {p : ι → Prop} {s : ι → Set ā„} (h : HasBasis atTop p s) : HasBasis (cobounded E) p fun i ↦ norm ⁻¹' s i := comap_norm_atTop' (E := E) ā–ø h.comap _ @[to_additive Filter.hasBasis_cobounded_norm] lemma Filter.hasBasis_cobounded_norm' : HasBasis (cobounded E) (fun _ ↦ True) ({x | Ā· ≤ ‖x‖}) := atTop_basis.cobounded_of_norm' @[to_additive (attr := simp) tendsto_norm_atTop_iff_cobounded] lemma tendsto_norm_atTop_iff_cobounded' {f : α → E} {l : Filter α} : Tendsto (‖f ·‖) l atTop ↔ Tendsto f l (cobounded E) := by rw [← comap_norm_atTop', tendsto_comap_iff]; rfl @[to_additive tendsto_norm_cobounded_atTop] lemma tendsto_norm_cobounded_atTop' : Tendsto norm (cobounded E) atTop := tendsto_norm_atTop_iff_cobounded'.2 tendsto_id @[to_additive eventually_cobounded_le_norm] lemma eventually_cobounded_le_norm' (a : ā„) : āˆ€į¶  x in cobounded E, a ≤ ‖x‖ := tendsto_norm_cobounded_atTop'.eventually_ge_atTop a @[to_additive tendsto_norm_cocompact_atTop] lemma tendsto_norm_cocompact_atTop' [ProperSpace E] : Tendsto norm (cocompact E) atTop := cobounded_eq_cocompact (α := E) ā–ø tendsto_norm_cobounded_atTop' @[to_additive (attr := simp)] lemma Filter.inv_cobounded : (cobounded E)⁻¹ = cobounded E := by simp only [← comap_norm_atTop', ← Filter.comap_inv, comap_comap, Function.comp_def, norm_inv'] /-- In a (semi)normed group, inversion `x ↦ x⁻¹` tends to infinity at infinity. -/ @[to_additive /-- In a (semi)normed group, negation `x ↦ -x` tends to infinity at infinity. -/] theorem Filter.tendsto_inv_cobounded : Tendsto Inv.inv (cobounded E) (cobounded E) := inv_cobounded.le @[to_additive isBounded_iff_forall_norm_le] lemma isBounded_iff_forall_norm_le' : Bornology.IsBounded s ↔ ∃ C, āˆ€ x ∈ s, ‖x‖ ≤ C := by simpa only [Set.subset_def, mem_closedBall_one_iff] using isBounded_iff_subset_closedBall (1 : E) alias ⟨Bornology.IsBounded.exists_norm_le', _⟩ := isBounded_iff_forall_norm_le' alias ⟨Bornology.IsBounded.exists_norm_le, _⟩ := isBounded_iff_forall_norm_le attribute [to_additive existing exists_norm_le] Bornology.IsBounded.exists_norm_le' @[to_additive exists_pos_norm_le] lemma Bornology.IsBounded.exists_pos_norm_le' (hs : IsBounded s) : ∃ R > 0, āˆ€ x ∈ s, ‖x‖ ≤ R := let ⟨Rā‚€, hRā‚€āŸ© := hs.exists_norm_le' ⟨max Rā‚€ 1, by positivity, fun x hx => (hRā‚€ x hx).trans <| le_max_left _ _⟩ @[to_additive Bornology.IsBounded.exists_pos_norm_lt] lemma Bornology.IsBounded.exists_pos_norm_lt' (hs : IsBounded s) : ∃ R > 0, āˆ€ x ∈ s, ‖x‖ < R := let ⟨R, hRā‚€, hR⟩ := hs.exists_pos_norm_le' ⟨R + 1, by positivity, fun x hx ↦ (hR x hx).trans_lt (lt_add_one _)⟩ @[to_additive] lemma NormedCommGroup.cauchySeq_iff [Nonempty α] [SemilatticeSup α] {u : α → E} : CauchySeq u ↔ āˆ€ ε > 0, ∃ N, āˆ€ m, N ≤ m → āˆ€ n, N ≤ n → ‖u m / u n‖ < ε := by simp [Metric.cauchySeq_iff, dist_eq_norm_div] @[to_additive IsCompact.exists_bound_of_continuousOn] lemma IsCompact.exists_bound_of_continuousOn' [TopologicalSpace α] {s : Set α} (hs : IsCompact s) {f : α → E} (hf : ContinuousOn f s) : ∃ C, āˆ€ x ∈ s, ‖f x‖ ≤ C := (isBounded_iff_forall_norm_le'.1 (hs.image_of_continuousOn hf).isBounded).imp fun _C hC _x hx => hC _ <| Set.mem_image_of_mem _ hx @[to_additive] lemma HasCompactMulSupport.exists_bound_of_continuous [TopologicalSpace α] {f : α → E} (hf : HasCompactMulSupport f) (h'f : Continuous f) : ∃ C, āˆ€ x, ‖f x‖ ≤ C := by simpa using (hf.isCompact_range h'f).isBounded.exists_norm_le' /-- A helper lemma used to prove that the (scalar or usual) product of a function that tends to one and a bounded function tends to one. This lemma is formulated for any binary operation `op : E → F → G` with an estimate `‖op x y‖ ≤ A * ‖x‖ * ‖y‖` for some constant A instead of multiplication so that it can be applied to `(*)`, `flip (*)`, `(•)`, and `flip (•)`. -/ @[to_additive /-- A helper lemma used to prove that the (scalar or usual) product of a function that tends to zero and a bounded function tends to zero. This lemma is formulated for any binary operation `op : E → F → G` with an estimate `‖op x y‖ ≤ A * ‖x‖ * ‖y‖` for some constant A instead of multiplication so that it can be applied to `(*)`, `flip (*)`, `(•)`, and `flip (•)`. -/] lemma Filter.Tendsto.op_one_isBoundedUnder_le' {f : α → E} {g : α → F} {l : Filter α} (hf : Tendsto f l (š“ 1)) (hg : IsBoundedUnder (Ā· ≤ Ā·) l (Norm.norm ∘ g)) (op : E → F → G) (h_op : ∃ A, āˆ€ x y, ‖op x y‖ ≤ A * ‖x‖ * ‖y‖) : Tendsto (fun x => op (f x) (g x)) l (š“ 1) := by obtain ⟨A, h_op⟩ := h_op rcases hg with ⟨C, hC⟩; rw [eventually_map] at hC rw [NormedCommGroup.tendsto_nhds_one] at hf ⊢ intro ε ε₀ rcases exists_pos_mul_lt ε₀ (A * C) with ⟨Γ, Γ₀, hΓ⟩ filter_upwards [hf Ī“ Γ₀, hC] with i hf hg refine (h_op _ _).trans_lt ?_ rcases le_total A 0 with hA | hA Ā· exact (mul_nonpos_of_nonpos_of_nonneg (mul_nonpos_of_nonpos_of_nonneg hA <| norm_nonneg' _) <| norm_nonneg' _).trans_lt ε₀ calc A * ‖f i‖ * ‖g i‖ ≤ A * Ī“ * C := by gcongr; exact hg _ = A * C * Ī“ := mul_right_comm _ _ _ _ < ε := hĪ“ /-- A helper lemma used to prove that the (scalar or usual) product of a function that tends to one and a bounded function tends to one. This lemma is formulated for any binary operation `op : E → F → G` with an estimate `‖op x y‖ ≤ ‖x‖ * ‖y‖` instead of multiplication so that it can be applied to `(*)`, `flip (*)`, `(•)`, and `flip (•)`. -/ @[to_additive /-- A helper lemma used to prove that the (scalar or usual) product of a function that tends to zero and a bounded function tends to zero. This lemma is formulated for any binary operation `op : E → F → G` with an estimate `‖op x y‖ ≤ ‖x‖ * ‖y‖` instead of multiplication so that it can be applied to `(*)`, `flip (*)`, `(•)`, and `flip (•)`. -/] theorem Filter.Tendsto.op_one_isBoundedUnder_le {f : α → E} {g : α → F} {l : Filter α} (hf : Tendsto f l (š“ 1)) (hg : IsBoundedUnder (Ā· ≤ Ā·) l (Norm.norm ∘ g)) (op : E → F → G) (h_op : āˆ€ x y, ‖op x y‖ ≤ ‖x‖ * ‖y‖) : Tendsto (fun x => op (f x) (g x)) l (š“ 1) := hf.op_one_isBoundedUnder_le' hg op ⟨1, fun x y => (one_mul ‖x‖).symm ā–ø h_op x y⟩ @[to_additive tendsto_norm_comp_cofinite_atTop_of_isClosedEmbedding] lemma tendsto_norm_comp_cofinite_atTop_of_isClosedEmbedding' {X : Type*} [TopologicalSpace X] [DiscreteTopology X] [ProperSpace E] {e : X → E} (he : Topology.IsClosedEmbedding e) : Tendsto (norm ∘ e) cofinite atTop := by rw [← Filter.cocompact_eq_cofinite X] apply tendsto_norm_cocompact_atTop'.comp (Topology.IsClosedEmbedding.tendsto_cocompact he) end SeminormedGroup section NormedAddGroup variable [NormedAddGroup E] [TopologicalSpace α] {f : α → E} lemma Continuous.bounded_above_of_compact_support (hf : Continuous f) (h : HasCompactSupport f) : ∃ C, āˆ€ x, ‖f x‖ ≤ C := by simpa [bddAbove_def] using hf.norm.bddAbove_range_of_hasCompactSupport h.norm end NormedAddGroup section NormedAddGroupSource variable [NormedAddGroup α] {f : α → E} @[to_additive] lemma HasCompactMulSupport.exists_pos_le_norm [One E] (hf : HasCompactMulSupport f) : ∃ R : ā„, 0 < R ∧ āˆ€ x : α, R ≤ ‖x‖ → f x = 1 := by obtain ⟨K, ⟨hK1, hK2⟩⟩ := exists_compact_iff_hasCompactMulSupport.mpr hf obtain ⟨S, hS, hS'⟩ := hK1.isBounded.exists_pos_norm_le refine ⟨S + 1, by positivity, fun x hx => hK2 x ((mt <| hS' x) ?_)⟩ contrapose! hx exact lt_add_of_le_of_pos hx zero_lt_one end NormedAddGroupSource
.lake/packages/mathlib/Mathlib/Analysis/Normed/Group/SemiNormedGrp.lean
import Mathlib.Analysis.Normed.Group.Constructions import Mathlib.Analysis.Normed.Group.Hom import Mathlib.CategoryTheory.Limits.Shapes.ZeroMorphisms import Mathlib.CategoryTheory.Elementwise /-! # The category of seminormed groups We define `SemiNormedGrp`, the category of seminormed groups and normed group homs between them, as well as `SemiNormedGrp₁`, the subcategory of norm non-increasing morphisms. -/ noncomputable section universe u open CategoryTheory /-- The category of seminormed abelian groups and bounded group homomorphisms. -/ structure SemiNormedGrp : Type (u + 1) where /-- Construct a bundled `SemiNormedGrp` from the underlying type and typeclass. -/ of :: /-- The underlying seminormed abelian group. -/ carrier : Type u [str : SeminormedAddCommGroup carrier] attribute [instance] SemiNormedGrp.str namespace SemiNormedGrp instance : CoeSort SemiNormedGrp Type* where coe X := X.carrier /-- The type of morphisms in `SemiNormedGrp` -/ @[ext] structure Hom (M N : SemiNormedGrp.{u}) where /-- The underlying `NormedAddGroupHom`. -/ hom' : NormedAddGroupHom M N instance : LargeCategory.{u} SemiNormedGrp where Hom X Y := Hom X Y id X := ⟨NormedAddGroupHom.id X⟩ comp f g := ⟨g.hom'.comp f.hom'⟩ instance : ConcreteCategory SemiNormedGrp (NormedAddGroupHom Ā· Ā·) where hom f := f.hom' ofHom f := ⟨f⟩ /-- Turn a morphism in `SemiNormedGrp` back into a `NormedAddGroupHom`. -/ abbrev Hom.hom {M N : SemiNormedGrp.{u}} (f : Hom M N) := ConcreteCategory.hom (C := SemiNormedGrp) f /-- Typecheck a `NormedAddGroupHom` as a morphism in `SemiNormedGrp`. -/ abbrev ofHom {M N : Type u} [SeminormedAddCommGroup M] [SeminormedAddCommGroup N] (f : NormedAddGroupHom M N) : of M ⟶ of N := ConcreteCategory.ofHom (C := SemiNormedGrp) f /-- Use the `ConcreteCategory.hom` projection for `@[simps]` lemmas. -/ def Hom.Simps.hom (M N : SemiNormedGrp.{u}) (f : Hom M N) := f.hom initialize_simps_projections Hom (hom' → hom) /-! The results below duplicate the `ConcreteCategory` simp lemmas, but we can keep them for `dsimp`. -/ @[ext] lemma ext {M N : SemiNormedGrp} {f₁ fā‚‚ : M ⟶ N} (h : āˆ€ (x : M), f₁ x = fā‚‚ x) : f₁ = fā‚‚ := ConcreteCategory.ext_apply h @[simp] lemma hom_id {M : SemiNormedGrp} : (šŸ™ M : M ⟶ M).hom = NormedAddGroupHom.id M := rfl /- Provided for rewriting. -/ lemma id_apply (M : SemiNormedGrp) (r : M) : (šŸ™ M : M ⟶ M) r = r := by simp @[simp] lemma hom_comp {M N O : SemiNormedGrp} (f : M ⟶ N) (g : N ⟶ O) : (f ≫ g).hom = g.hom.comp f.hom := rfl /- Provided for rewriting. -/ lemma comp_apply {M N O : SemiNormedGrp} (f : M ⟶ N) (g : N ⟶ O) (r : M) : (f ≫ g) r = g (f r) := by simp @[ext] lemma hom_ext {M N : SemiNormedGrp} {f g : M ⟶ N} (hf : f.hom = g.hom) : f = g := Hom.ext hf @[simp] lemma hom_ofHom {M N : Type u} [SeminormedAddCommGroup M] [SeminormedAddCommGroup N] (f : NormedAddGroupHom M N) : (ofHom f).hom = f := rfl @[simp] lemma ofHom_hom {M N : SemiNormedGrp} (f : M ⟶ N) : ofHom (Hom.hom f) = f := rfl @[simp] lemma ofHom_id {M : Type u} [SeminormedAddCommGroup M] : ofHom (NormedAddGroupHom.id M) = šŸ™ (of M) := rfl @[simp] lemma ofHom_comp {M N O : Type u} [SeminormedAddCommGroup M] [SeminormedAddCommGroup N] [SeminormedAddCommGroup O] (f : NormedAddGroupHom M N) (g : NormedAddGroupHom N O) : ofHom (g.comp f) = ofHom f ≫ ofHom g := rfl lemma ofHom_apply {M N : Type u} [SeminormedAddCommGroup M] [SeminormedAddCommGroup N] (f : NormedAddGroupHom M N) (r : M) : ofHom f r = f r := rfl lemma inv_hom_apply {M N : SemiNormedGrp} (e : M ≅ N) (r : M) : e.inv (e.hom r) = r := by simp lemma hom_inv_apply {M N : SemiNormedGrp} (e : M ≅ N) (s : N) : e.hom (e.inv s) = s := by simp theorem coe_of (V : Type u) [SeminormedAddCommGroup V] : (SemiNormedGrp.of V : Type u) = V := rfl theorem coe_id (V : SemiNormedGrp) : (šŸ™ V : V → V) = id := rfl theorem coe_comp {M N K : SemiNormedGrp} (f : M ⟶ N) (g : N ⟶ K) : (f ≫ g : M → K) = g ∘ f := rfl instance : Inhabited SemiNormedGrp := ⟨of PUnit⟩ instance {M N : SemiNormedGrp} : Zero (M ⟶ N) where zero := ofHom 0 @[simp] theorem hom_zero {V W : SemiNormedGrp} : (0 : V ⟶ W).hom = 0 := rfl theorem zero_apply {V W : SemiNormedGrp} (x : V) : (0 : V ⟶ W) x = 0 := rfl instance : Limits.HasZeroMorphisms.{u, u + 1} SemiNormedGrp where theorem isZero_of_subsingleton (V : SemiNormedGrp) [Subsingleton V] : Limits.IsZero V := by refine ⟨fun X => ⟨⟨⟨0⟩, fun f => ?_⟩⟩, fun X => ⟨⟨⟨0⟩, fun f => ?_⟩⟩⟩ Ā· ext x; have : x = 0 := Subsingleton.elim _ _; simp only [this, map_zero] Ā· ext; apply Subsingleton.elim instance hasZeroObject : Limits.HasZeroObject SemiNormedGrp.{u} := ⟨⟨of PUnit, isZero_of_subsingleton _⟩⟩ theorem iso_isometry_of_normNoninc {V W : SemiNormedGrp} (i : V ≅ W) (h1 : i.hom.hom.NormNoninc) (h2 : i.inv.hom.NormNoninc) : Isometry i.hom := by apply AddMonoidHomClass.isometry_of_norm intro v apply le_antisymm (h1 v) calc ‖v‖ = ‖i.inv (i.hom v)‖ := by rw [← comp_apply, Iso.hom_inv_id, id_apply] _ ≤ ‖i.hom v‖ := h2 _ instance Hom.add {M N : SemiNormedGrp} : Add (M ⟶ N) where add f g := ofHom (f.hom + g.hom) @[simp] theorem hom_add {V W : SemiNormedGrp} (f g : V ⟶ W) : (f + g).hom = f.hom + g.hom := rfl instance Hom.neg {M N : SemiNormedGrp} : Neg (M ⟶ N) where neg f := ofHom (- f.hom) @[simp] theorem hom_neg {V W : SemiNormedGrp} (f : V ⟶ W) : (-f).hom = - f.hom := rfl instance Hom.sub {M N : SemiNormedGrp} : Sub (M ⟶ N) where sub f g := ofHom (f.hom - g.hom) @[simp] theorem hom_sub {V W : SemiNormedGrp} (f g : V ⟶ W) : (f - g).hom = f.hom - g.hom := rfl instance Hom.nsmul {M N : SemiNormedGrp} : SMul ā„• (M ⟶ N) where smul n f := ofHom (n • f.hom) @[simp] theorem hom_nsum {V W : SemiNormedGrp} (n : ā„•) (f : V ⟶ W) : (n • f).hom = n • f.hom := rfl instance Hom.zsmul {M N : SemiNormedGrp} : SMul ℤ (M ⟶ N) where smul n f := ofHom (n • f.hom) @[simp] theorem hom_zsum {V W : SemiNormedGrp} (n : ℤ) (f : V ⟶ W) : (n • f).hom = n • f.hom := rfl instance Hom.addCommGroup {V W : SemiNormedGrp} : AddCommGroup (V ⟶ W) := Function.Injective.addCommGroup _ ConcreteCategory.hom_injective rfl (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) end SemiNormedGrp /-- `SemiNormedGrp₁` is a type synonym for `SemiNormedGrp`, which we shall equip with the category structure consisting only of the norm non-increasing maps. -/ structure SemiNormedGrp₁ : Type (u + 1) where /-- Construct a bundled `SemiNormedGrp₁` from the underlying type and typeclass. -/ of :: /-- The underlying seminormed abelian group. -/ carrier : Type u [str : SeminormedAddCommGroup carrier] attribute [instance] SemiNormedGrp₁.str namespace SemiNormedGrp₁ instance : CoeSort SemiNormedGrp₁ Type* where coe X := X.carrier /-- The type of morphisms in `SemiNormedGrp₁` -/ @[ext] structure Hom (M N : SemiNormedGrp₁.{u}) where /-- The underlying `NormedAddGroupHom`. -/ hom' : NormedAddGroupHom M N normNoninc : hom'.NormNoninc instance : LargeCategory.{u} SemiNormedGrp₁ where Hom := Hom id X := ⟨NormedAddGroupHom.id X, NormedAddGroupHom.NormNoninc.id⟩ comp {_ _ _} f g := ⟨g.1.comp f.1, g.2.comp f.2⟩ instance instFunLike (X Y : SemiNormedGrp₁) : FunLike { f : NormedAddGroupHom X Y // f.NormNoninc } X Y where coe f := f.1.toFun coe_injective' _ _ h := Subtype.val_inj.mp (NormedAddGroupHom.coe_injective h) instance : ConcreteCategory SemiNormedGrp₁ fun X Y => { f : NormedAddGroupHom X Y // f.NormNoninc } where hom f := ⟨f.1, f.2⟩ ofHom f := ⟨f.1, f.2⟩ instance (X Y : SemiNormedGrp₁) : AddMonoidHomClass { f : NormedAddGroupHom X Y // f.NormNoninc } X Y where map_add f := map_add f.1 map_zero f := map_zero f.1 /-- Turn a morphism in `SemiNormedGrp₁` back into a norm-nonincreasing `NormedAddGroupHom`. -/ abbrev Hom.hom {M N : SemiNormedGrp₁.{u}} (f : Hom M N) := ConcreteCategory.hom (C := SemiNormedGrp₁) f /-- Promote a `NormedAddGroupHom` to a morphism in `SemiNormedGrp₁`. -/ abbrev mkHom {M N : Type u} [SeminormedAddCommGroup M] [SeminormedAddCommGroup N] (f : NormedAddGroupHom M N) (i : f.NormNoninc) : SemiNormedGrp₁.of M ⟶ SemiNormedGrp₁.of N := ConcreteCategory.ofHom ⟨f, i⟩ /-- Use the `ConcreteCategory.hom` projection for `@[simps]` lemmas. -/ def Hom.Simps.hom (M N : SemiNormedGrp₁.{u}) (f : Hom M N) : NormedAddGroupHom M N := f.hom initialize_simps_projections Hom (hom' → hom) instance (X Y : SemiNormedGrp₁) : CoeFun (X ⟶ Y) (fun _ => X → Y) where coe f := f.hom.1 theorem mkHom_apply {M N : Type u} [SeminormedAddCommGroup M] [SeminormedAddCommGroup N] (f : NormedAddGroupHom M N) (i : f.NormNoninc) (x) : mkHom f i x = f x := rfl /-! The results below duplicate the `ConcreteCategory` simp lemmas, but we can keep them for `dsimp`. -/ @[ext] lemma ext {M N : SemiNormedGrp₁} {f₁ fā‚‚ : M ⟶ N} (h : āˆ€ (x : M), f₁ x = fā‚‚ x) : f₁ = fā‚‚ := ConcreteCategory.ext_apply h @[simp] lemma hom_id {M : SemiNormedGrp₁} : (šŸ™ M : M ⟶ M).hom = NormedAddGroupHom.id M := rfl /- Provided for rewriting. -/ lemma id_apply (M : SemiNormedGrp₁) (r : M) : (šŸ™ M : M ⟶ M) r = r := by simp @[simp] lemma hom_comp {M N O : SemiNormedGrp₁} (f : M ⟶ N) (g : N ⟶ O) : (f ≫ g).hom.1 = g.hom.1.comp f.hom.1 := rfl /- Provided for rewriting. -/ lemma comp_apply {M N O : SemiNormedGrp₁} (f : M ⟶ N) (g : N ⟶ O) (r : M) : (f ≫ g) r = g (f r) := by simp @[ext] lemma hom_ext {M N : SemiNormedGrp₁} {f g : M ⟶ N} (hf : f.hom = g.hom) : f = g := Hom.ext (congr_arg Subtype.val hf) @[simp] lemma hom_mkHom {M N : Type u} [SeminormedAddCommGroup M] [SeminormedAddCommGroup N] (f : NormedAddGroupHom M N) (hf : f.NormNoninc) : (mkHom f hf).hom = f := rfl @[simp] lemma mkHom_hom {M N : SemiNormedGrp₁} (f : M ⟶ N) : mkHom (Hom.hom f) f.normNoninc = f := rfl @[simp] lemma mkHom_id {M : Type u} [SeminormedAddCommGroup M] : mkHom (NormedAddGroupHom.id M) NormedAddGroupHom.NormNoninc.id = šŸ™ (of M) := rfl @[simp] lemma mkHom_comp {M N O : Type u} [SeminormedAddCommGroup M] [SeminormedAddCommGroup N] [SeminormedAddCommGroup O] (f : NormedAddGroupHom M N) (g : NormedAddGroupHom N O) (hf : f.NormNoninc) (hg : g.NormNoninc) (hgf : (g.comp f).NormNoninc) : mkHom (g.comp f) hgf = mkHom f hf ≫ mkHom g hg := rfl @[simp] lemma inv_hom_apply {M N : SemiNormedGrp₁} (e : M ≅ N) (r : M) : e.inv (e.hom r) = r := by rw [← comp_apply] simp @[simp] lemma hom_inv_apply {M N : SemiNormedGrp₁} (e : M ≅ N) (s : N) : e.hom (e.inv s) = s := by rw [← comp_apply] simp instance (M : SemiNormedGrp₁) : SeminormedAddCommGroup M := M.str /-- Promote an isomorphism in `SemiNormedGrp` to an isomorphism in `SemiNormedGrp₁`. -/ @[simps] def mkIso {M N : SemiNormedGrp} (f : M ≅ N) (i : f.hom.hom.NormNoninc) (i' : f.inv.hom.NormNoninc) : SemiNormedGrp₁.of M ≅ SemiNormedGrp₁.of N where hom := mkHom f.hom.hom i inv := mkHom f.inv.hom i' instance : HasForgetā‚‚ SemiNormedGrp₁ SemiNormedGrp where forgetā‚‚ := { obj := fun X => SemiNormedGrp.of X map := fun f => SemiNormedGrp.ofHom f.1 } theorem coe_of (V : Type u) [SeminormedAddCommGroup V] : (SemiNormedGrp₁.of V : Type u) = V := rfl theorem coe_id (V : SemiNormedGrp₁) : ⇑(šŸ™ V) = id := rfl theorem coe_comp {M N K : SemiNormedGrp₁} (f : M ⟶ N) (g : N ⟶ K) : (f ≫ g : M → K) = g ∘ f := rfl instance : Inhabited SemiNormedGrp₁ := ⟨of PUnit⟩ instance (X Y : SemiNormedGrp₁) : Zero (X ⟶ Y) where zero := ⟨0, NormedAddGroupHom.NormNoninc.zero⟩ @[simp] theorem zero_apply {V W : SemiNormedGrp₁} (x : V) : (0 : V ⟶ W) x = 0 := rfl instance : Limits.HasZeroMorphisms.{u, u + 1} SemiNormedGrp₁ where theorem isZero_of_subsingleton (V : SemiNormedGrp₁) [Subsingleton V] : Limits.IsZero V := by refine ⟨fun X => ⟨⟨⟨0⟩, fun f => ?_⟩⟩, fun X => ⟨⟨⟨0⟩, fun f => ?_⟩⟩⟩ Ā· ext x; have : x = 0 := Subsingleton.elim _ _; simp only [this, map_zero] Ā· ext; apply Subsingleton.elim instance hasZeroObject : Limits.HasZeroObject SemiNormedGrp₁.{u} := ⟨⟨of PUnit, isZero_of_subsingleton _⟩⟩ theorem iso_isometry {V W : SemiNormedGrp₁} (i : V ≅ W) : Isometry i.hom := by change Isometry (⟨⟨i.hom, map_zero _⟩, fun _ _ => map_add _ _ _⟩ : V →+ W) refine AddMonoidHomClass.isometry_of_norm _ ?_ intro v apply le_antisymm (i.hom.2 v) calc ‖v‖ = ‖i.inv (i.hom v)‖ := by rw [← comp_apply, Iso.hom_inv_id, id_apply] _ ≤ ‖i.hom v‖ := i.inv.2 _ end SemiNormedGrp₁
.lake/packages/mathlib/Mathlib/Analysis/Normed/Group/FunctionSeries.lean
import Mathlib.Analysis.Normed.Group.InfiniteSum import Mathlib.Topology.Instances.ENNReal.Lemmas /-! # Continuity of series of functions We show that series of functions are continuous when each individual function in the series is and additionally suitable uniform summable bounds are satisfied, in `continuous_tsum`. For smoothness of series of functions, see the file `Analysis.Calculus.SmoothSeries`. TODO: update this to use `SummableUniformlyOn`. -/ open Set Metric TopologicalSpace Function Filter open scoped Topology NNReal variable {α β F : Type*} [NormedAddCommGroup F] [CompleteSpace F] {u : α → ā„} /-- An infinite sum of functions with summable sup norm is the uniform limit of its partial sums. Version relative to a set, with general index set. -/ theorem tendstoUniformlyOn_tsum {f : α → β → F} (hu : Summable u) {s : Set β} (hfu : āˆ€ n x, x ∈ s → ‖f n x‖ ≤ u n) : TendstoUniformlyOn (fun t : Finset α => fun x => āˆ‘ n ∈ t, f n x) (fun x => āˆ‘' n, f n x) atTop s := by refine tendstoUniformlyOn_iff.2 fun ε εpos => ?_ filter_upwards [(tendsto_order.1 (tendsto_tsum_compl_atTop_zero u)).2 _ εpos] with t ht x hx have A : Summable fun n => ‖f n x‖ := .of_nonneg_of_le (fun _ ↦ norm_nonneg _) (fun n => hfu n x hx) hu rw [dist_eq_norm, ← A.of_norm.sum_add_tsum_subtype_compl t, add_sub_cancel_left] apply lt_of_le_of_lt _ ht apply (norm_tsum_le_tsum_norm (A.subtype _)).trans exact (A.subtype _).tsum_le_tsum (fun n => hfu _ _ hx) (hu.subtype _) /-- An infinite sum of functions with summable sup norm is the uniform limit of its partial sums. Version relative to a set, with index set `ā„•`. -/ theorem tendstoUniformlyOn_tsum_nat {f : ā„• → β → F} {u : ā„• → ā„} (hu : Summable u) {s : Set β} (hfu : āˆ€ n x, x ∈ s → ‖f n x‖ ≤ u n) : TendstoUniformlyOn (fun N => fun x => āˆ‘ n ∈ Finset.range N, f n x) (fun x => āˆ‘' n, f n x) atTop s := fun v hv => tendsto_finset_range.eventually (tendstoUniformlyOn_tsum hu hfu v hv) /-- An infinite sum of functions with eventually summable sup norm is the uniform limit of its partial sums. Version relative to a set, with general index set. -/ theorem tendstoUniformlyOn_tsum_of_cofinite_eventually {ι : Type*} {f : ι → β → F} {u : ι → ā„} (hu : Summable u) {s : Set β} (hfu : āˆ€į¶  n in cofinite, āˆ€ x ∈ s, ‖f n x‖ ≤ u n) : TendstoUniformlyOn (fun t x => āˆ‘ n ∈ t, f n x) (fun x => āˆ‘' n, f n x) atTop s := by classical refine tendstoUniformlyOn_iff.2 fun ε εpos => ?_ have := (tendsto_order.1 (tendsto_tsum_compl_atTop_zero u)).2 _ εpos simp only [gt_iff_lt, eventually_atTop, ge_iff_le, Finset.le_eq_subset] at * obtain ⟨t, ht⟩ := this rw [eventually_iff_exists_mem] at hfu obtain ⟨N, hN, HN⟩ := hfu refine ⟨hN.toFinset ∪ t, fun n hn x hx => ?_⟩ have A : Summable fun n => ‖f n x‖ := by apply Summable.add_compl (s := hN.toFinset) Summable.of_finite apply Summable.of_nonneg_of_le (fun _ ↦ norm_nonneg _) _ (hu.subtype _) simp only [comp_apply, Subtype.forall, Set.mem_compl_iff, Finset.mem_coe] aesop rw [dist_eq_norm, ← A.of_norm.sum_add_tsum_subtype_compl n, add_sub_cancel_left] apply lt_of_le_of_lt _ (ht n (Finset.union_subset_right hn)) apply (norm_tsum_le_tsum_norm (A.subtype _)).trans apply (A.subtype _).tsum_le_tsum _ (hu.subtype _) simp only [comp_apply, Subtype.forall, imp_false] apply fun i hi => HN i ?_ x hx have : i āˆ‰ hN.toFinset := fun hg ↦ hi (Finset.union_subset_left hn hg) simp_all theorem tendstoUniformlyOn_tsum_nat_eventually {α F : Type*} [NormedAddCommGroup F] [CompleteSpace F] {f : ā„• → α → F} {u : ā„• → ā„} (hu : Summable u) {s : Set α} (hfu : āˆ€į¶  n in atTop, āˆ€ x ∈ s, ‖f n x‖ ≤ u n) : TendstoUniformlyOn (fun N x => āˆ‘ n ∈ Finset.range N, f n x) (fun x => āˆ‘' n, f n x) atTop s := fun v hv ↦ tendsto_finset_range.eventually <| tendstoUniformlyOn_tsum_of_cofinite_eventually hu (Nat.cofinite_eq_atTop ā–ø hfu) v hv /-- An infinite sum of functions with summable sup norm is the uniform limit of its partial sums. Version with general index set. -/ theorem tendstoUniformly_tsum {f : α → β → F} (hu : Summable u) (hfu : āˆ€ n x, ‖f n x‖ ≤ u n) : TendstoUniformly (fun t : Finset α => fun x => āˆ‘ n ∈ t, f n x) (fun x => āˆ‘' n, f n x) atTop := by rw [← tendstoUniformlyOn_univ]; exact tendstoUniformlyOn_tsum hu fun n x _ => hfu n x /-- An infinite sum of functions with summable sup norm is the uniform limit of its partial sums. Version with index set `ā„•`. -/ theorem tendstoUniformly_tsum_nat {f : ā„• → β → F} {u : ā„• → ā„} (hu : Summable u) (hfu : āˆ€ n x, ‖f n x‖ ≤ u n) : TendstoUniformly (fun N => fun x => āˆ‘ n ∈ Finset.range N, f n x) (fun x => āˆ‘' n, f n x) atTop := fun v hv => tendsto_finset_range.eventually (tendstoUniformly_tsum hu hfu v hv) /-- An infinite sum of functions with eventually summable sup norm is the uniform limit of its partial sums. Version with general index set. -/ theorem tendstoUniformly_tsum_of_cofinite_eventually {ι : Type*} {f : ι → β → F} {u : ι → ā„} (hu : Summable u) (hfu : āˆ€į¶  (n : ι) in cofinite, āˆ€ x : β, ‖f n x‖ ≤ u n) : TendstoUniformly (fun t x => āˆ‘ n ∈ t, f n x) (fun x => āˆ‘' n, f n x) atTop := by rw [← tendstoUniformlyOn_univ] apply tendstoUniformlyOn_tsum_of_cofinite_eventually hu simpa using hfu /-- An infinite sum of functions with summable sup norm is continuous on a set if each individual function is. -/ theorem continuousOn_tsum [TopologicalSpace β] {f : α → β → F} {s : Set β} (hf : āˆ€ i, ContinuousOn (f i) s) (hu : Summable u) (hfu : āˆ€ n x, x ∈ s → ‖f n x‖ ≤ u n) : ContinuousOn (fun x => āˆ‘' n, f n x) s := by classical refine (tendstoUniformlyOn_tsum hu hfu).continuousOn (Eventually.of_forall ?_) intro t exact continuousOn_finset_sum _ fun i _ => hf i /-- An infinite sum of functions with summable sup norm is continuous if each individual function is. -/ theorem continuous_tsum [TopologicalSpace β] {f : α → β → F} (hf : āˆ€ i, Continuous (f i)) (hu : Summable u) (hfu : āˆ€ n x, ‖f n x‖ ≤ u n) : Continuous fun x => āˆ‘' n, f n x := by simp_rw [← continuousOn_univ] at hf ⊢ exact continuousOn_tsum hf hu fun n x _ => hfu n x
.lake/packages/mathlib/Mathlib/Analysis/Normed/Group/BallSphere.lean
import Mathlib.Analysis.Normed.Group.Uniform /-! # Negation on spheres and balls In this file we define `InvolutiveNeg` and `ContinuousNeg` instances for spheres, open balls, and closed balls in a seminormed group. -/ open Metric Set Topology variable {E : Type*} [i : SeminormedAddCommGroup E] {r : ā„} /-- We equip the sphere, in a seminormed group, with a formal operation of negation, namely the antipodal map. -/ instance : InvolutiveNeg (sphere (0 : E) r) where neg := Subtype.map Neg.neg fun w => by simp neg_neg x := Subtype.ext <| neg_neg x.1 @[simp] theorem coe_neg_sphere {r : ā„} (v : sphere (0 : E) r) : ↑(-v) = (-v : E) := rfl instance : ContinuousNeg (sphere (0 : E) r) := IsInducing.subtypeVal.continuousNeg fun _ => rfl /-- We equip the ball, in a seminormed group, with a formal operation of negation, namely the antipodal map. -/ instance {r : ā„} : InvolutiveNeg (ball (0 : E) r) where neg := Subtype.map Neg.neg fun w => by simp neg_neg x := Subtype.ext <| neg_neg x.1 @[simp] theorem coe_neg_ball {r : ā„} (v : ball (0 : E) r) : ↑(-v) = (-v : E) := rfl instance : ContinuousNeg (ball (0 : E) r) := IsInducing.subtypeVal.continuousNeg fun _ => rfl /-- We equip the closed ball, in a seminormed group, with a formal operation of negation, namely the antipodal map. -/ instance {r : ā„} : InvolutiveNeg (closedBall (0 : E) r) where neg := Subtype.map Neg.neg fun w => by simp neg_neg x := Subtype.ext <| neg_neg x.1 @[simp] theorem coe_neg_closedBall {r : ā„} (v : closedBall (0 : E) r) : ↑(-v) = (-v : E) := rfl instance : ContinuousNeg (closedBall (0 : E) r) := IsInducing.subtypeVal.continuousNeg fun _ => rfl
.lake/packages/mathlib/Mathlib/Analysis/Normed/Group/Seminorm.lean
import Mathlib.Data.NNReal.Defs import Mathlib.Order.ConditionallyCompleteLattice.Group /-! # Group seminorms This file defines norms and seminorms in a group. A group seminorm is a function to the reals which is positive-semidefinite and subadditive. A norm further only maps zero to zero. ## Main declarations * `AddGroupSeminorm`: A function `f` from an additive group `G` to the reals that preserves zero, takes nonnegative values, is subadditive and such that `f (-x) = f x` for all `x`. * `NonarchAddGroupSeminorm`: A function `f` from an additive group `G` to the reals that preserves zero, takes nonnegative values, is nonarchimedean and such that `f (-x) = f x` for all `x`. * `GroupSeminorm`: A function `f` from a group `G` to the reals that sends one to zero, takes nonnegative values, is submultiplicative and such that `f x⁻¹ = f x` for all `x`. * `AddGroupNorm`: A seminorm `f` such that `f x = 0 → x = 0` for all `x`. * `NonarchAddGroupNorm`: A nonarchimedean seminorm `f` such that `f x = 0 → x = 0` for all `x`. * `GroupNorm`: A seminorm `f` such that `f x = 0 → x = 1` for all `x`. ## Notes The corresponding hom classes are defined in `Analysis.Order.Hom.Basic` to be used by absolute values. We do not define `NonarchAddGroupSeminorm` as an extension of `AddGroupSeminorm` to avoid having a superfluous `add_le'` field in the resulting structure. The same applies to `NonarchAddGroupNorm`. ## References * [H. H. Schaefer, *Topological Vector Spaces*][schaefer1966] ## Tags norm, seminorm -/ assert_not_exists Finset open Set open NNReal variable {R R' E F G : Type*} /-- A seminorm on an additive group `G` is a function `f : G → ā„` that preserves zero, is subadditive and such that `f (-x) = f x` for all `x`. -/ structure AddGroupSeminorm (G : Type*) [AddGroup G] where -- Porting note: can't extend `ZeroHom G ā„` because otherwise `to_additive` won't work since -- we aren't using old structures /-- The bare function of an `AddGroupSeminorm`. -/ protected toFun : G → ā„ /-- The image of zero is zero. -/ protected map_zero' : toFun 0 = 0 /-- The seminorm is subadditive. -/ protected add_le' : āˆ€ r s, toFun (r + s) ≤ toFun r + toFun s /-- The seminorm is invariant under negation. -/ protected neg' : āˆ€ r, toFun (-r) = toFun r /-- A seminorm on a group `G` is a function `f : G → ā„` that sends one to zero, is submultiplicative and such that `f x⁻¹ = f x` for all `x`. -/ @[to_additive] structure GroupSeminorm (G : Type*) [Group G] where /-- The bare function of a `GroupSeminorm`. -/ protected toFun : G → ā„ /-- The image of one is zero. -/ protected map_one' : toFun 1 = 0 /-- The seminorm applied to a product is dominated by the sum of the seminorm applied to the factors. -/ protected mul_le' : āˆ€ x y, toFun (x * y) ≤ toFun x + toFun y /-- The seminorm is invariant under inversion. -/ protected inv' : āˆ€ x, toFun x⁻¹ = toFun x /-- A nonarchimedean seminorm on an additive group `G` is a function `f : G → ā„` that preserves zero, is nonarchimedean and such that `f (-x) = f x` for all `x`. -/ structure NonarchAddGroupSeminorm (G : Type*) [AddGroup G] extends ZeroHom G ā„ where /-- The seminorm applied to a sum is dominated by the maximum of the function applied to the addends. -/ protected add_le_max' : āˆ€ r s, toFun (r + s) ≤ max (toFun r) (toFun s) /-- The seminorm is invariant under negation. -/ protected neg' : āˆ€ r, toFun (-r) = toFun r /-! NOTE: We do not define `NonarchAddGroupSeminorm` as an extension of `AddGroupSeminorm` to avoid having a superfluous `add_le'` field in the resulting structure. The same applies to `NonarchAddGroupNorm` below. -/ /-- A norm on an additive group `G` is a function `f : G → ā„` that preserves zero, is subadditive and such that `f (-x) = f x` and `f x = 0 → x = 0` for all `x`. -/ structure AddGroupNorm (G : Type*) [AddGroup G] extends AddGroupSeminorm G where /-- If the image under the seminorm is zero, then the argument is zero. -/ protected eq_zero_of_map_eq_zero' : āˆ€ x, toFun x = 0 → x = 0 /-- A seminorm on a group `G` is a function `f : G → ā„` that sends one to zero, is submultiplicative and such that `f x⁻¹ = f x` and `f x = 0 → x = 1` for all `x`. -/ @[to_additive] structure GroupNorm (G : Type*) [Group G] extends GroupSeminorm G where /-- If the image under the norm is zero, then the argument is one. -/ protected eq_one_of_map_eq_zero' : āˆ€ x, toFun x = 0 → x = 1 /-- A nonarchimedean norm on an additive group `G` is a function `f : G → ā„` that preserves zero, is nonarchimedean and such that `f (-x) = f x` and `f x = 0 → x = 0` for all `x`. -/ structure NonarchAddGroupNorm (G : Type*) [AddGroup G] extends NonarchAddGroupSeminorm G where /-- If the image under the norm is zero, then the argument is zero. -/ protected eq_zero_of_map_eq_zero' : āˆ€ x, toFun x = 0 → x = 0 /-- `NonarchAddGroupSeminormClass F α` states that `F` is a type of nonarchimedean seminorms on the additive group `α`. You should extend this class when you extend `NonarchAddGroupSeminorm`. -/ class NonarchAddGroupSeminormClass (F : Type*) (α : outParam Type*) [AddGroup α] [FunLike F α ā„] : Prop extends NonarchimedeanHomClass F α ā„ where /-- The image of zero is zero. -/ protected map_zero (f : F) : f 0 = 0 /-- The seminorm is invariant under negation. -/ protected map_neg_eq_map' (f : F) (a : α) : f (-a) = f a /-- `NonarchAddGroupNormClass F α` states that `F` is a type of nonarchimedean norms on the additive group `α`. You should extend this class when you extend `NonarchAddGroupNorm`. -/ class NonarchAddGroupNormClass (F : Type*) (α : outParam Type*) [AddGroup α] [FunLike F α ā„] : Prop extends NonarchAddGroupSeminormClass F α where /-- If the image under the norm is zero, then the argument is zero. -/ protected eq_zero_of_map_eq_zero (f : F) {a : α} : f a = 0 → a = 0 section NonarchAddGroupSeminormClass variable [AddGroup E] [FunLike F E ā„] [NonarchAddGroupSeminormClass F E] (f : F) (x y : E) theorem map_sub_le_max : f (x - y) ≤ max (f x) (f y) := by rw [sub_eq_add_neg, ← NonarchAddGroupSeminormClass.map_neg_eq_map' f y] exact map_add_le_max _ _ _ end NonarchAddGroupSeminormClass -- See note [lower instance priority] instance (priority := 100) NonarchAddGroupSeminormClass.toAddGroupSeminormClass [FunLike F E ā„] [AddGroup E] [NonarchAddGroupSeminormClass F E] : AddGroupSeminormClass F E ā„ := { ‹NonarchAddGroupSeminormClass F E› with map_add_le_add := fun f _ _ => haveI h_nonneg : āˆ€ a, 0 ≤ f a := by intro a rw [← NonarchAddGroupSeminormClass.map_zero f, ← sub_self a] exact le_trans (map_sub_le_max _ _ _) (by rw [max_self (f a)]) le_trans (map_add_le_max _ _ _) (max_le (le_add_of_nonneg_right (h_nonneg _)) (le_add_of_nonneg_left (h_nonneg _))) map_neg_eq_map := NonarchAddGroupSeminormClass.map_neg_eq_map' } -- See note [lower instance priority] instance (priority := 100) NonarchAddGroupNormClass.toAddGroupNormClass [FunLike F E ā„] [AddGroup E] [NonarchAddGroupNormClass F E] : AddGroupNormClass F E ā„ := { ‹NonarchAddGroupNormClass F E› with map_add_le_add := map_add_le_add map_neg_eq_map := NonarchAddGroupSeminormClass.map_neg_eq_map' } /-! ### Seminorms -/ namespace GroupSeminorm section Group variable [Group E] [Group F] [Group G] {p q : GroupSeminorm E} @[to_additive] instance funLike : FunLike (GroupSeminorm E) E ā„ where coe f := f.toFun coe_injective' f g h := by cases f; cases g; congr @[to_additive] instance groupSeminormClass : GroupSeminormClass (GroupSeminorm E) E ā„ where map_one_eq_zero f := f.map_one' map_mul_le_add f := f.mul_le' map_inv_eq_map f := f.inv' @[to_additive (attr := simp)] theorem toFun_eq_coe : p.toFun = p := rfl @[to_additive (attr := ext)] theorem ext : (āˆ€ x, p x = q x) → p = q := DFunLike.ext p q @[to_additive] instance : PartialOrder (GroupSeminorm E) := PartialOrder.lift _ DFunLike.coe_injective @[to_additive] theorem le_def : p ≤ q ↔ (p : E → ā„) ≤ q := Iff.rfl @[to_additive] theorem lt_def : p < q ↔ (p : E → ā„) < q := Iff.rfl @[to_additive (attr := simp, norm_cast)] theorem coe_le_coe : (p : E → ā„) ≤ q ↔ p ≤ q := Iff.rfl @[to_additive (attr := simp, norm_cast)] theorem coe_lt_coe : (p : E → ā„) < q ↔ p < q := Iff.rfl variable (p q) (f : F →* E) @[to_additive] instance instZeroGroupSeminorm : Zero (GroupSeminorm E) := ⟨{ toFun := 0 map_one' := Pi.zero_apply _ mul_le' := fun _ _ => (zero_add _).ge inv' := fun _ => rfl }⟩ @[to_additive (attr := simp, norm_cast)] theorem coe_zero : ⇑(0 : GroupSeminorm E) = 0 := rfl @[to_additive (attr := simp)] theorem zero_apply (x : E) : (0 : GroupSeminorm E) x = 0 := rfl @[to_additive] instance : Inhabited (GroupSeminorm E) := ⟨0⟩ @[to_additive] instance : Add (GroupSeminorm E) := ⟨fun p q => { toFun := fun x => p x + q x map_one' := by simp_rw [map_one_eq_zero p, map_one_eq_zero q, zero_add] mul_le' := fun _ _ => (add_le_add (map_mul_le_add p _ _) <| map_mul_le_add q _ _).trans_eq <| add_add_add_comm _ _ _ _ inv' := fun x => by simp_rw [map_inv_eq_map p, map_inv_eq_map q] }⟩ @[to_additive (attr := simp)] theorem coe_add : ⇑(p + q) = p + q := rfl @[to_additive (attr := simp)] theorem add_apply (x : E) : (p + q) x = p x + q x := rfl -- TODO: define `SupSet` too, from the skeleton at -- https://github.com/leanprover-community/mathlib/pull/11329#issuecomment-1008915345 @[to_additive] instance : Max (GroupSeminorm E) := ⟨fun p q => { toFun := p āŠ” q map_one' := by rw [Pi.sup_apply, ← map_one_eq_zero p, sup_eq_left, map_one_eq_zero p, map_one_eq_zero q] mul_le' := fun x y => sup_le ((map_mul_le_add p x y).trans <| add_le_add le_sup_left le_sup_left) ((map_mul_le_add q x y).trans <| add_le_add le_sup_right le_sup_right) inv' := fun x => by rw [Pi.sup_apply, Pi.sup_apply, map_inv_eq_map p, map_inv_eq_map q] }⟩ @[to_additive (attr := simp, norm_cast)] theorem coe_sup : ⇑(p āŠ” q) = ⇑p āŠ” ⇑q := rfl @[to_additive (attr := simp)] theorem sup_apply (x : E) : (p āŠ” q) x = p x āŠ” q x := rfl @[to_additive] instance semilatticeSup : SemilatticeSup (GroupSeminorm E) := DFunLike.coe_injective.semilatticeSup _ coe_sup /-- Composition of a group seminorm with a monoid homomorphism as a group seminorm. -/ @[to_additive /-- Composition of an additive group seminorm with an additive monoid homomorphism as an additive group seminorm. -/] def comp (p : GroupSeminorm E) (f : F →* E) : GroupSeminorm F where toFun x := p (f x) map_one' := by simp_rw [f.map_one, map_one_eq_zero p] mul_le' _ _ := (congr_arg p <| f.map_mul _ _).trans_le <| map_mul_le_add p _ _ inv' x := by simp_rw [map_inv, map_inv_eq_map p] @[to_additive (attr := simp)] theorem coe_comp : ⇑(p.comp f) = p ∘ f := rfl @[to_additive (attr := simp)] theorem comp_apply (x : F) : (p.comp f) x = p (f x) := rfl @[to_additive (attr := simp)] theorem comp_id : p.comp (MonoidHom.id _) = p := ext fun _ => rfl @[to_additive (attr := simp)] theorem comp_zero : p.comp (1 : F →* E) = 0 := ext fun _ => map_one_eq_zero p @[to_additive (attr := simp)] theorem zero_comp : (0 : GroupSeminorm E).comp f = 0 := ext fun _ => rfl @[to_additive] theorem comp_assoc (g : F →* E) (f : G →* F) : p.comp (g.comp f) = (p.comp g).comp f := ext fun _ => rfl @[to_additive] theorem add_comp (f : F →* E) : (p + q).comp f = p.comp f + q.comp f := ext fun _ => rfl variable {p q} @[to_additive] theorem comp_mono (hp : p ≤ q) : p.comp f ≤ q.comp f := fun _ => hp _ end Group section CommGroup variable [CommGroup E] [CommGroup F] (p q : GroupSeminorm E) (x : E) @[to_additive] theorem comp_mul_le (f g : F →* E) : p.comp (f * g) ≤ p.comp f + p.comp g := fun _ => map_mul_le_add p _ _ @[to_additive] theorem mul_bddBelow_range_add {p q : GroupSeminorm E} {x : E} : BddBelow (range fun y => p y + q (x / y)) := ⟨0, by rintro _ ⟨x, rfl⟩ dsimp positivity⟩ @[to_additive] noncomputable instance : Min (GroupSeminorm E) := ⟨fun p q => { toFun := fun x => ⨅ y, p y + q (x / y) map_one' := ciInf_eq_of_forall_ge_of_forall_gt_exists_lt (fun _ => by positivity) fun r hr => ⟨1, by rwa [div_one, map_one_eq_zero p, map_one_eq_zero q, add_zero]⟩ mul_le' := fun x y => le_ciInf_add_ciInf fun u v => by refine ciInf_le_of_le mul_bddBelow_range_add (u * v) ?_ rw [mul_div_mul_comm, add_add_add_comm] exact add_le_add (map_mul_le_add p _ _) (map_mul_le_add q _ _) inv' := fun x => (inv_surjective.iInf_comp _).symm.trans <| by simp_rw [map_inv_eq_map p, ← inv_div', map_inv_eq_map q] }⟩ @[to_additive (attr := simp)] theorem inf_apply : (p āŠ“ q) x = ⨅ y, p y + q (x / y) := rfl @[to_additive] noncomputable instance : Lattice (GroupSeminorm E) := { GroupSeminorm.semilatticeSup with inf := (Ā· āŠ“ Ā·) inf_le_left := fun p q x => ciInf_le_of_le mul_bddBelow_range_add x <| by rw [div_self', map_one_eq_zero q, add_zero] inf_le_right := fun p q x => ciInf_le_of_le mul_bddBelow_range_add (1 : E) <| by simpa only [div_one x, map_one_eq_zero p, zero_add (q x)] using le_rfl le_inf := fun a _ _ hb hc _ => le_ciInf fun _ => (le_map_add_map_div a _ _).trans <| add_le_add (hb _) (hc _) } end CommGroup end GroupSeminorm /- TODO: All the following ought to be automated using `to_additive`. The problem is that it doesn't see that `SMul R ā„` should be fixed because `ā„` is fixed. -/ namespace AddGroupSeminorm variable [AddGroup E] [SMul R ā„] [SMul R ā„ā‰„0] [IsScalarTower R ā„ā‰„0 ā„] instance toOne [DecidableEq E] : One (AddGroupSeminorm E) := ⟨{ toFun := fun x => if x = 0 then 0 else 1 map_zero' := if_pos rfl add_le' := fun x y => by by_cases hx : x = 0 Ā· rw [if_pos hx, hx, zero_add, zero_add] Ā· rw [if_neg hx] refine le_add_of_le_of_nonneg ?_ ?_ <;> split_ifs <;> norm_num neg' := fun x => by simp_rw [neg_eq_zero] }⟩ @[simp] theorem apply_one [DecidableEq E] (x : E) : (1 : AddGroupSeminorm E) x = if x = 0 then 0 else 1 := rfl /-- Any action on `ā„` which factors through `ā„ā‰„0` applies to an `AddGroupSeminorm`. -/ instance toSMul : SMul R (AddGroupSeminorm E) := ⟨fun r p => { toFun := fun x => r • p x map_zero' := by simp only [← smul_one_smul ā„ā‰„0 r (_ : ā„), NNReal.smul_def, smul_eq_mul, map_zero, mul_zero] add_le' := fun _ _ => by simp only [← smul_one_smul ā„ā‰„0 r (_ : ā„), NNReal.smul_def, smul_eq_mul, ← mul_add] gcongr apply map_add_le_add neg' := fun x => by simp_rw [map_neg_eq_map] }⟩ @[simp, norm_cast] theorem coe_smul (r : R) (p : AddGroupSeminorm E) : ⇑(r • p) = r • ⇑p := rfl @[simp] theorem smul_apply (r : R) (p : AddGroupSeminorm E) (x : E) : (r • p) x = r • p x := rfl instance isScalarTower [SMul R' ā„] [SMul R' ā„ā‰„0] [IsScalarTower R' ā„ā‰„0 ā„] [SMul R R'] [IsScalarTower R R' ā„] : IsScalarTower R R' (AddGroupSeminorm E) := ⟨fun r a p => ext fun x => smul_assoc r a (p x)⟩ theorem smul_sup (r : R) (p q : AddGroupSeminorm E) : r • (p āŠ” q) = r • p āŠ” r • q := have Real.smul_max : āˆ€ x y : ā„, r • max x y = max (r • x) (r • y) := fun x y => by simpa only [← smul_eq_mul, ← NNReal.smul_def, smul_one_smul ā„ā‰„0 r (_ : ā„)] using mul_max_of_nonneg x y (r • (1 : ā„ā‰„0) : ā„ā‰„0).coe_nonneg ext fun _ => Real.smul_max _ _ end AddGroupSeminorm namespace NonarchAddGroupSeminorm section AddGroup variable [AddGroup E] {p q : NonarchAddGroupSeminorm E} instance funLike : FunLike (NonarchAddGroupSeminorm E) E ā„ where coe f := f.toFun coe_injective' f g h := by obtain ⟨⟨_, _⟩, _, _⟩ := f; cases g; congr instance nonarchAddGroupSeminormClass : NonarchAddGroupSeminormClass (NonarchAddGroupSeminorm E) E where map_add_le_max f := f.add_le_max' map_zero f := f.map_zero' map_neg_eq_map' f := f.neg' @[simp] theorem toZeroHom_eq_coe : ⇑p.toZeroHom = p := by rfl @[ext] theorem ext : (āˆ€ x, p x = q x) → p = q := DFunLike.ext p q noncomputable instance : PartialOrder (NonarchAddGroupSeminorm E) := PartialOrder.lift _ DFunLike.coe_injective theorem le_def : p ≤ q ↔ (p : E → ā„) ≤ q := Iff.rfl theorem lt_def : p < q ↔ (p : E → ā„) < q := Iff.rfl @[simp, norm_cast] theorem coe_le_coe : (p : E → ā„) ≤ q ↔ p ≤ q := Iff.rfl @[simp, norm_cast] theorem coe_lt_coe : (p : E → ā„) < q ↔ p < q := Iff.rfl variable (p q) instance : Zero (NonarchAddGroupSeminorm E) := ⟨{ toFun := 0 map_zero' := Pi.zero_apply _ add_le_max' := fun r s => by simp only [Pi.zero_apply]; rw [max_eq_right]; rfl neg' := fun _ => rfl }⟩ @[simp, norm_cast] theorem coe_zero : ⇑(0 : NonarchAddGroupSeminorm E) = 0 := rfl @[simp] theorem zero_apply (x : E) : (0 : NonarchAddGroupSeminorm E) x = 0 := rfl instance : Inhabited (NonarchAddGroupSeminorm E) := ⟨0⟩ -- TODO: define `SupSet` too, from the skeleton at -- https://github.com/leanprover-community/mathlib/pull/11329#issuecomment-1008915345 instance : Max (NonarchAddGroupSeminorm E) := ⟨fun p q => { toFun := p āŠ” q map_zero' := by rw [Pi.sup_apply, ← map_zero p, sup_eq_left, map_zero p, map_zero q] add_le_max' := fun x y => sup_le ((map_add_le_max p x y).trans <| max_le_max le_sup_left le_sup_left) ((map_add_le_max q x y).trans <| max_le_max le_sup_right le_sup_right) neg' := fun x => by simp_rw [Pi.sup_apply, map_neg_eq_map p, map_neg_eq_map q]}⟩ @[simp, norm_cast] theorem coe_sup : ⇑(p āŠ” q) = ⇑p āŠ” ⇑q := rfl @[simp] theorem sup_apply (x : E) : (p āŠ” q) x = p x āŠ” q x := rfl noncomputable instance : SemilatticeSup (NonarchAddGroupSeminorm E) := DFunLike.coe_injective.semilatticeSup _ coe_sup end AddGroup section AddCommGroup variable [AddCommGroup E] theorem add_bddBelow_range_add {p q : NonarchAddGroupSeminorm E} {x : E} : BddBelow (range fun y => p y + q (x - y)) := ⟨0, by rintro _ ⟨x, rfl⟩ dsimp positivity⟩ end AddCommGroup end NonarchAddGroupSeminorm namespace GroupSeminorm variable [Group E] [SMul R ā„] [SMul R ā„ā‰„0] [IsScalarTower R ā„ā‰„0 ā„] instance toOne [DecidableEq E] : One (GroupSeminorm E) := ⟨{ toFun := fun x => if x = 1 then 0 else 1 map_one' := if_pos rfl mul_le' := fun x y => by by_cases hx : x = 1 Ā· rw [if_pos hx, hx, one_mul, zero_add] Ā· rw [if_neg hx] refine le_add_of_le_of_nonneg ?_ ?_ <;> split_ifs <;> norm_num inv' := fun x => by simp_rw [inv_eq_one] }⟩ @[simp] theorem apply_one [DecidableEq E] (x : E) : (1 : GroupSeminorm E) x = if x = 1 then 0 else 1 := rfl /-- Any action on `ā„` which factors through `ā„ā‰„0` applies to an `AddGroupSeminorm`. -/ instance : SMul R (GroupSeminorm E) := ⟨fun r p => { toFun := fun x => r • p x map_one' := by simp only [← smul_one_smul ā„ā‰„0 r (_ : ā„), NNReal.smul_def, smul_eq_mul, map_one_eq_zero p, mul_zero] mul_le' := fun _ _ => by simp only [← smul_one_smul ā„ā‰„0 r (_ : ā„), NNReal.smul_def, smul_eq_mul, ← mul_add] gcongr apply map_mul_le_add inv' := fun x => by simp_rw [map_inv_eq_map p] }⟩ instance [SMul R' ā„] [SMul R' ā„ā‰„0] [IsScalarTower R' ā„ā‰„0 ā„] [SMul R R'] [IsScalarTower R R' ā„] : IsScalarTower R R' (GroupSeminorm E) := ⟨fun r a p => ext fun x => smul_assoc r a <| p x⟩ @[simp, norm_cast] theorem coe_smul (r : R) (p : GroupSeminorm E) : ⇑(r • p) = r • ⇑p := rfl @[simp] theorem smul_apply (r : R) (p : GroupSeminorm E) (x : E) : (r • p) x = r • p x := rfl theorem smul_sup (r : R) (p q : GroupSeminorm E) : r • (p āŠ” q) = r • p āŠ” r • q := have Real.smul_max : āˆ€ x y : ā„, r • max x y = max (r • x) (r • y) := fun x y => by simpa only [← smul_eq_mul, ← NNReal.smul_def, smul_one_smul ā„ā‰„0 r (_ : ā„)] using mul_max_of_nonneg x y (r • (1 : ā„ā‰„0) : ā„ā‰„0).coe_nonneg ext fun _ => Real.smul_max _ _ end GroupSeminorm namespace NonarchAddGroupSeminorm variable [AddGroup E] [SMul R ā„] [SMul R ā„ā‰„0] [IsScalarTower R ā„ā‰„0 ā„] instance [DecidableEq E] : One (NonarchAddGroupSeminorm E) := ⟨{ toFun := fun x => if x = 0 then 0 else 1 map_zero' := if_pos rfl add_le_max' := fun x y => by by_cases hx : x = 0 Ā· simp_rw [if_pos hx, hx, zero_add] exact le_max_of_le_right (le_refl _) Ā· simp_rw [if_neg hx] split_ifs <;> simp neg' := fun x => by simp_rw [neg_eq_zero] }⟩ @[simp] theorem apply_one [DecidableEq E] (x : E) : (1 : NonarchAddGroupSeminorm E) x = if x = 0 then 0 else 1 := rfl /-- Any action on `ā„` which factors through `ā„ā‰„0` applies to a `NonarchAddGroupSeminorm`. -/ instance : SMul R (NonarchAddGroupSeminorm E) := ⟨fun r p => { toFun := fun x => r • p x map_zero' := by simp only [← smul_one_smul ā„ā‰„0 r (_ : ā„), NNReal.smul_def, smul_eq_mul, map_zero p, mul_zero] add_le_max' := fun x y => by simp only [← smul_one_smul ā„ā‰„0 r (_ : ā„), NNReal.smul_def, smul_eq_mul, ← mul_max_of_nonneg _ _ NNReal.zero_le_coe] gcongr apply map_add_le_max neg' := fun x => by simp_rw [map_neg_eq_map p] }⟩ instance [SMul R' ā„] [SMul R' ā„ā‰„0] [IsScalarTower R' ā„ā‰„0 ā„] [SMul R R'] [IsScalarTower R R' ā„] : IsScalarTower R R' (NonarchAddGroupSeminorm E) := ⟨fun r a p => ext fun x => smul_assoc r a <| p x⟩ @[simp, norm_cast] theorem coe_smul (r : R) (p : NonarchAddGroupSeminorm E) : ⇑(r • p) = r • ⇑p := rfl @[simp] theorem smul_apply (r : R) (p : NonarchAddGroupSeminorm E) (x : E) : (r • p) x = r • p x := rfl theorem smul_sup (r : R) (p q : NonarchAddGroupSeminorm E) : r • (p āŠ” q) = r • p āŠ” r • q := have Real.smul_max : āˆ€ x y : ā„, r • max x y = max (r • x) (r • y) := fun x y => by simpa only [← smul_eq_mul, ← NNReal.smul_def, smul_one_smul ā„ā‰„0 r (_ : ā„)] using mul_max_of_nonneg x y (r • (1 : ā„ā‰„0) : ā„ā‰„0).coe_nonneg ext fun _ => Real.smul_max _ _ end NonarchAddGroupSeminorm /-! ### Norms -/ namespace GroupNorm section Group variable [Group E] {p q : GroupNorm E} @[to_additive] instance funLike : FunLike (GroupNorm E) E ā„ where coe f := f.toFun coe_injective' f g h := by obtain ⟨⟨_, _, _, _⟩, _⟩ := f; cases g; congr @[to_additive] instance groupNormClass : GroupNormClass (GroupNorm E) E ā„ where map_one_eq_zero f := f.map_one' map_mul_le_add f := f.mul_le' map_inv_eq_map f := f.inv' eq_one_of_map_eq_zero f := f.eq_one_of_map_eq_zero' _ @[to_additive (attr := simp)] theorem toGroupSeminorm_eq_coe : ⇑p.toGroupSeminorm = p := rfl @[to_additive (attr := ext)] theorem ext : (āˆ€ x, p x = q x) → p = q := DFunLike.ext p q @[to_additive] instance : PartialOrder (GroupNorm E) := PartialOrder.lift _ DFunLike.coe_injective @[to_additive] theorem le_def : p ≤ q ↔ (p : E → ā„) ≤ q := Iff.rfl @[to_additive] theorem lt_def : p < q ↔ (p : E → ā„) < q := Iff.rfl @[to_additive (attr := simp, norm_cast)] theorem coe_le_coe : (p : E → ā„) ≤ q ↔ p ≤ q := Iff.rfl @[to_additive (attr := simp, norm_cast)] theorem coe_lt_coe : (p : E → ā„) < q ↔ p < q := Iff.rfl variable (p q) @[to_additive] instance : Add (GroupNorm E) := ⟨fun p q => { p.toGroupSeminorm + q.toGroupSeminorm with eq_one_of_map_eq_zero' := fun _x hx => of_not_not fun h => hx.not_gt <| add_pos (map_pos_of_ne_one p h) (map_pos_of_ne_one q h) }⟩ @[to_additive (attr := simp)] theorem coe_add : ⇑(p + q) = p + q := rfl @[to_additive (attr := simp)] theorem add_apply (x : E) : (p + q) x = p x + q x := rfl -- TODO: define `SupSet` @[to_additive] instance : Max (GroupNorm E) := ⟨fun p q => { p.toGroupSeminorm āŠ” q.toGroupSeminorm with eq_one_of_map_eq_zero' := fun _x hx => of_not_not fun h => hx.not_gt <| lt_sup_iff.2 <| Or.inl <| map_pos_of_ne_one p h }⟩ @[to_additive (attr := simp, norm_cast)] theorem coe_sup : ⇑(p āŠ” q) = ⇑p āŠ” ⇑q := rfl @[to_additive (attr := simp)] theorem sup_apply (x : E) : (p āŠ” q) x = p x āŠ” q x := rfl @[to_additive] instance : SemilatticeSup (GroupNorm E) := DFunLike.coe_injective.semilatticeSup _ coe_sup end Group end GroupNorm namespace AddGroupNorm variable [AddGroup E] [DecidableEq E] instance : One (AddGroupNorm E) := ⟨{ (1 : AddGroupSeminorm E) with eq_zero_of_map_eq_zero' := fun _x => zero_ne_one.ite_eq_left_iff.1 }⟩ @[simp] theorem apply_one (x : E) : (1 : AddGroupNorm E) x = if x = 0 then 0 else 1 := rfl instance : Inhabited (AddGroupNorm E) := ⟨1⟩ end AddGroupNorm namespace GroupNorm instance _root_.AddGroupNorm.toOne [AddGroup E] [DecidableEq E] : One (AddGroupNorm E) := ⟨{ (1 : AddGroupSeminorm E) with eq_zero_of_map_eq_zero' := fun _ => zero_ne_one.ite_eq_left_iff.1 }⟩ variable [Group E] [DecidableEq E] instance toOne : One (GroupNorm E) := ⟨{ (1 : GroupSeminorm E) with eq_one_of_map_eq_zero' := fun _ => zero_ne_one.ite_eq_left_iff.1 }⟩ @[simp] theorem apply_one (x : E) : (1 : GroupNorm E) x = if x = 1 then 0 else 1 := rfl @[to_additive existing] instance : Inhabited (GroupNorm E) := ⟨1⟩ end GroupNorm namespace NonarchAddGroupNorm section AddGroup variable [AddGroup E] {p q : NonarchAddGroupNorm E} instance funLike : FunLike (NonarchAddGroupNorm E) E ā„ where coe f := f.toFun coe_injective' f g h := by obtain ⟨⟨⟨_, _⟩, _, _⟩, _⟩ := f; cases g; congr instance nonarchAddGroupNormClass : NonarchAddGroupNormClass (NonarchAddGroupNorm E) E where map_add_le_max f := f.add_le_max' map_zero f := f.map_zero' map_neg_eq_map' f := f.neg' eq_zero_of_map_eq_zero f := f.eq_zero_of_map_eq_zero' _ @[simp] theorem toNonarchAddGroupSeminorm_eq_coe : ⇑p.toNonarchAddGroupSeminorm = p := rfl @[ext] theorem ext : (āˆ€ x, p x = q x) → p = q := DFunLike.ext p q noncomputable instance : PartialOrder (NonarchAddGroupNorm E) := PartialOrder.lift _ DFunLike.coe_injective theorem le_def : p ≤ q ↔ (p : E → ā„) ≤ q := Iff.rfl theorem lt_def : p < q ↔ (p : E → ā„) < q := Iff.rfl @[simp, norm_cast] theorem coe_le_coe : (p : E → ā„) ≤ q ↔ p ≤ q := Iff.rfl @[simp, norm_cast] theorem coe_lt_coe : (p : E → ā„) < q ↔ p < q := Iff.rfl variable (p q) instance : Max (NonarchAddGroupNorm E) := ⟨fun p q => { p.toNonarchAddGroupSeminorm āŠ” q.toNonarchAddGroupSeminorm with eq_zero_of_map_eq_zero' := fun _x hx => of_not_not fun h => hx.not_gt <| lt_sup_iff.2 <| Or.inl <| map_pos_of_ne_zero p h }⟩ @[simp, norm_cast] theorem coe_sup : ⇑(p āŠ” q) = ⇑p āŠ” ⇑q := rfl @[simp] theorem sup_apply (x : E) : (p āŠ” q) x = p x āŠ” q x := rfl noncomputable instance : SemilatticeSup (NonarchAddGroupNorm E) := DFunLike.coe_injective.semilatticeSup _ coe_sup instance [DecidableEq E] : One (NonarchAddGroupNorm E) := ⟨{ (1 : NonarchAddGroupSeminorm E) with eq_zero_of_map_eq_zero' := fun _ => zero_ne_one.ite_eq_left_iff.1 }⟩ @[simp] theorem apply_one [DecidableEq E] (x : E) : (1 : NonarchAddGroupNorm E) x = if x = 0 then 0 else 1 := rfl instance [DecidableEq E] : Inhabited (NonarchAddGroupNorm E) := ⟨1⟩ end AddGroup end NonarchAddGroupNorm
.lake/packages/mathlib/Mathlib/Analysis/Normed/Group/ControlledClosure.lean
import Mathlib.Analysis.Normed.Group.Hom import Mathlib.Analysis.SpecificLimits.Normed /-! # Extending a backward bound on a normed group homomorphism from a dense set Possible TODO (from the PR's review, https://github.com/leanprover-community/mathlib/pull/8498): "This feels a lot like the second step in the proof of the Banach open mapping theorem (`exists_preimage_norm_le`) ... wonder if it would be possible to refactor it using one of [the lemmas in this file]." -/ open Filter Finset open Topology variable {G : Type*} [NormedAddCommGroup G] [CompleteSpace G] variable {H : Type*} [NormedAddCommGroup H] /-- Given `f : NormedAddGroupHom G H` for some complete `G` and a subgroup `K` of `H`, if every element `x` of `K` has a preimage under `f` whose norm is at most `C*‖x‖` then the same holds for elements of the (topological) closure of `K` with constant `C+ε` instead of `C`, for any positive `ε`. -/ theorem controlled_closure_of_complete {f : NormedAddGroupHom G H} {K : AddSubgroup H} {C ε : ā„} (hC : 0 < C) (hε : 0 < ε) (hyp : f.SurjectiveOnWith K C) : f.SurjectiveOnWith K.topologicalClosure (C + ε) := by rintro (h : H) (h_in : h ∈ K.topologicalClosure) -- We first get rid of the easy case where `h = 0`. by_cases hyp_h : h = 0 Ā· rw [hyp_h] use 0 simp /- The desired preimage will be constructed as the sum of a series. Convergence of the series will be guaranteed by completeness of `G`. We first write `h` as the sum of a sequence `v` of elements of `K` which starts close to `h` and then quickly goes to zero. The sequence `b` below quantifies this. -/ set b : ā„• → ā„ := fun i => (1 / 2) ^ i * (ε * ‖h‖ / 2) / C have b_pos (i) : 0 < b i := by positivity obtain ⟨v : ā„• → H, lim_v : Tendsto (fun n : ā„• => āˆ‘ k ∈ range (n + 1), v k) atTop (š“ h), v_in : āˆ€ n, v n ∈ K, hvā‚€ : ‖v 0 - h‖ < b 0, hv : āˆ€ n > 0, ‖v n‖ < b n⟩ := controlled_sum_of_mem_closure h_in b_pos /- The controlled surjectivity assumption on `f` allows to build preimages `u n` for all elements `v n` of the `v` sequence. -/ have : āˆ€ n, ∃ m' : G, f m' = v n ∧ ‖m'‖ ≤ C * ‖v n‖ := fun n : ā„• => hyp (v n) (v_in n) choose u hu hnorm_u using this /- The desired series `s` is then obtained by summing `u`. We then check our choice of `b` ensures `s` is Cauchy. -/ set s : ā„• → G := fun n => āˆ‘ k ∈ range (n + 1), u k have : CauchySeq s := by apply NormedAddCommGroup.cauchy_series_of_le_geometric'' (by simp) one_half_lt_one Ā· rintro n (hn : n ≄ 1) calc ‖u n‖ ≤ C * ‖v n‖ := hnorm_u n _ ≤ C * b n := by gcongr; exact (hv _ <| Nat.succ_le_iff.mp hn).le _ = (1 / 2) ^ n * (ε * ‖h‖ / 2) := by simp [b, mul_div_cancelā‚€ _ hC.ne.symm] _ = ε * ‖h‖ / 2 * (1 / 2) ^ n := mul_comm _ _ -- We now show that the limit `g` of `s` is the desired preimage. obtain ⟨g : G, hg⟩ := cauchySeq_tendsto_of_complete this refine ⟨g, ?_, ?_⟩ Ā· -- We indeed get a preimage. First note: have : f ∘ s = fun n => āˆ‘ k ∈ range (n + 1), v k := by ext n simp [s, map_sum, hu] /- In the above equality, the left-hand-side converges to `f g` by continuity of `f` and definition of `g` while the right-hand-side converges to `h` by construction of `v` so `g` is indeed a preimage of `h`. -/ rw [← this] at lim_v exact tendsto_nhds_unique ((f.continuous.tendsto g).comp hg) lim_v Ā· -- Then we need to estimate the norm of `g`, using our careful choice of `b`. suffices āˆ€ n, ‖s n‖ ≤ (C + ε) * ‖h‖ from le_of_tendsto' (continuous_norm.continuousAt.tendsto.comp hg) this intro n have hnormā‚€ : ‖u 0‖ ≤ C * b 0 + C * ‖h‖ := by have := calc ‖v 0‖ ≤ ‖h‖ + ‖v 0 - h‖ := norm_le_insert' _ _ _ ≤ ‖h‖ + b 0 := by gcongr calc ‖u 0‖ ≤ C * ‖v 0‖ := hnorm_u 0 _ ≤ C * (‖h‖ + b 0) := by gcongr _ = C * b 0 + C * ‖h‖ := by rw [add_comm, mul_add] have : (āˆ‘ k ∈ range (n + 1), C * b k) ≤ ε * ‖h‖ := calc (āˆ‘ k ∈ range (n + 1), C * b k) _ = (āˆ‘ k ∈ range (n + 1), (1 / 2 : ā„) ^ k) * (ε * ‖h‖ / 2) := by simp only [b, mul_div_cancelā‚€ _ hC.ne.symm, ← sum_mul] _ ≤ 2 * (ε * ‖h‖ / 2) := by gcongr; apply sum_geometric_two_le _ = ε * ‖h‖ := mul_div_cancelā‚€ _ two_ne_zero calc ‖s n‖ ≤ āˆ‘ k ∈ range (n + 1), ‖u k‖ := norm_sum_le _ _ _ = (āˆ‘ k ∈ range n, ‖u (k + 1)‖) + ‖u 0‖ := sum_range_succ' _ _ _ ≤ (āˆ‘ k ∈ range n, C * ‖v (k + 1)‖) + ‖u 0‖ := by gcongr; apply hnorm_u _ ≤ (āˆ‘ k ∈ range n, C * b (k + 1)) + (C * b 0 + C * ‖h‖) := by gcongr with k; exact (hv _ k.succ_pos).le _ = (āˆ‘ k ∈ range (n + 1), C * b k) + C * ‖h‖ := by rw [← add_assoc, sum_range_succ'] _ ≤ (C + ε) * ‖h‖ := by rw [add_comm, add_mul] gcongr /-- Given `f : NormedAddGroupHom G H` for some complete `G`, if every element `x` of the image of an isometric immersion `j : NormedAddGroupHom K H` has a preimage under `f` whose norm is at most `C*‖x‖` then the same holds for elements of the (topological) closure of this image with constant `C+ε` instead of `C`, for any positive `ε`. This is useful in particular if `j` is the inclusion of a normed group into its completion (in this case the closure is the full target group). -/ theorem controlled_closure_range_of_complete {f : NormedAddGroupHom G H} {K : Type*} [SeminormedAddCommGroup K] {j : NormedAddGroupHom K H} (hj : āˆ€ x, ‖j x‖ = ‖x‖) {C ε : ā„} (hC : 0 < C) (hε : 0 < ε) (hyp : āˆ€ k, ∃ g, f g = j k ∧ ‖g‖ ≤ C * ‖k‖) : f.SurjectiveOnWith j.range.topologicalClosure (C + ε) := by replace hyp : āˆ€ h ∈ j.range, ∃ g, f g = h ∧ ‖g‖ ≤ C * ‖h‖ := by intro h h_in rcases (j.mem_range _).mp h_in with ⟨k, rfl⟩ rw [hj] exact hyp k exact controlled_closure_of_complete hC hε hyp
.lake/packages/mathlib/Mathlib/Analysis/Normed/Group/ZeroAtInfty.lean
import Mathlib.Topology.ContinuousMap.ZeroAtInfty /-! # ZeroAtInftyContinuousMapClass in normed additive groups In this file we give a characterization of the predicate `zero_at_infty` from `ZeroAtInftyContinuousMapClass`. A continuous map `f` is zero at infinity if and only if for every `ε > 0` there exists a `r : ā„` such that for all `x : E` with `r < ‖x‖` it holds that `‖f x‖ < ε`. -/ open Topology Filter variable {E F š“• : Type*} variable [SeminormedAddGroup E] [SeminormedAddCommGroup F] variable [FunLike š“• E F] [ZeroAtInftyContinuousMapClass š“• E F] theorem ZeroAtInftyContinuousMapClass.norm_le (f : š“•) (ε : ā„) (hε : 0 < ε) : ∃ (r : ā„), āˆ€ (x : E) (_hx : r < ‖x‖), ‖f x‖ < ε := by have h := zero_at_infty f rw [tendsto_zero_iff_norm_tendsto_zero, tendsto_def] at h specialize h (Metric.ball 0 ε) (Metric.ball_mem_nhds 0 hε) rcases Metric.closedBall_compl_subset_of_mem_cocompact h 0 with ⟨r, hr⟩ use r intro x hr' suffices x ∈ (fun x ↦ ‖f x‖) ⁻¹' Metric.ball 0 ε by simp_all apply hr simp_all variable [ProperSpace E] theorem zero_at_infty_of_norm_le (f : E → F) (h : āˆ€ (ε : ā„) (_hε : 0 < ε), ∃ (r : ā„), āˆ€ (x : E) (_hx : r < ‖x‖), ‖f x‖ < ε) : Tendsto f (cocompact E) (š“ 0) := by rw [tendsto_zero_iff_norm_tendsto_zero] intro s hs rw [mem_map, Metric.mem_cocompact_iff_closedBall_compl_subset 0] rw [Metric.mem_nhds_iff] at hs rcases hs with ⟨ε, hε, hs⟩ rcases h ε hε with ⟨r, hr⟩ use r intro aesop
.lake/packages/mathlib/Mathlib/Analysis/Normed/Group/Hom.lean
import Mathlib.Analysis.Normed.Group.Int import Mathlib.Analysis.Normed.Group.Subgroup import Mathlib.Analysis.Normed.Group.Uniform /-! # Normed groups homomorphisms This file gathers definitions and elementary constructions about bounded group homomorphisms between normed (abelian) groups (abbreviated to "normed group homs"). The main lemmas relate the boundedness condition to continuity and Lipschitzness. The main construction is to endow the type of normed group homs between two given normed groups with a group structure and a norm, giving rise to a normed group structure. We provide several simple constructions for normed group homs, like kernel, range and equalizer. Some easy other constructions are related to subgroups of normed groups. Since a lot of elementary properties don't require `‖x‖ = 0 → x = 0` we start setting up the theory of `SeminormedAddGroupHom` and we specialize to `NormedAddGroupHom` when needed. -/ noncomputable section open NNReal -- TODO: migrate to the new morphism / morphism_class style /-- A morphism of seminormed abelian groups is a bounded group homomorphism. -/ structure NormedAddGroupHom (V W : Type*) [SeminormedAddCommGroup V] [SeminormedAddCommGroup W] where /-- The function underlying a `NormedAddGroupHom` -/ toFun : V → W /-- A `NormedAddGroupHom` is additive. -/ map_add' : āˆ€ v₁ vā‚‚, toFun (v₁ + vā‚‚) = toFun v₁ + toFun vā‚‚ /-- A `NormedAddGroupHom` is bounded. -/ bound' : ∃ C, āˆ€ v, ‖toFun v‖ ≤ C * ‖v‖ namespace AddMonoidHom variable {V W : Type*} [SeminormedAddCommGroup V] [SeminormedAddCommGroup W] {f g : NormedAddGroupHom V W} /-- Associate to a group homomorphism a bounded group homomorphism under a norm control condition. See `AddMonoidHom.mkNormedAddGroupHom'` for a version that uses `ā„ā‰„0` for the bound. -/ def mkNormedAddGroupHom (f : V →+ W) (C : ā„) (h : āˆ€ v, ‖f v‖ ≤ C * ‖v‖) : NormedAddGroupHom V W := { f with bound' := ⟨C, h⟩ } /-- Associate to a group homomorphism a bounded group homomorphism under a norm control condition. See `AddMonoidHom.mkNormedAddGroupHom` for a version that uses `ā„` for the bound. -/ def mkNormedAddGroupHom' (f : V →+ W) (C : ā„ā‰„0) (hC : āˆ€ x, ‖f xā€–ā‚Š ≤ C * ‖xā€–ā‚Š) : NormedAddGroupHom V W := { f with bound' := ⟨C, hC⟩ } end AddMonoidHom theorem exists_pos_bound_of_bound {V W : Type*} [SeminormedAddCommGroup V] [SeminormedAddCommGroup W] {f : V → W} (M : ā„) (h : āˆ€ x, ‖f x‖ ≤ M * ‖x‖) : ∃ N, 0 < N ∧ āˆ€ x, ‖f x‖ ≤ N * ‖x‖ := ⟨max M 1, lt_of_lt_of_le zero_lt_one (le_max_right _ _), fun x => calc ‖f x‖ ≤ M * ‖x‖ := h x _ ≤ max M 1 * ‖x‖ := by gcongr; apply le_max_left ⟩ namespace NormedAddGroupHom variable {V V₁ Vā‚‚ Vā‚ƒ : Type*} [SeminormedAddCommGroup V] [SeminormedAddCommGroup V₁] [SeminormedAddCommGroup Vā‚‚] [SeminormedAddCommGroup Vā‚ƒ] variable {f g : NormedAddGroupHom V₁ Vā‚‚} /-- A Lipschitz continuous additive homomorphism is a normed additive group homomorphism. -/ def ofLipschitz (f : V₁ →+ Vā‚‚) {K : ā„ā‰„0} (h : LipschitzWith K f) : NormedAddGroupHom V₁ Vā‚‚ := f.mkNormedAddGroupHom K fun x ↦ by simpa only [map_zero, dist_zero_right] using h.dist_le_mul x 0 instance funLike : FunLike (NormedAddGroupHom V₁ Vā‚‚) V₁ Vā‚‚ where coe := toFun coe_injective' f g h := by cases f; cases g; congr instance toAddMonoidHomClass : AddMonoidHomClass (NormedAddGroupHom V₁ Vā‚‚) V₁ Vā‚‚ where map_add f := f.map_add' map_zero f := (AddMonoidHom.mk' f.toFun f.map_add').map_zero initialize_simps_projections NormedAddGroupHom (toFun → apply) theorem coe_inj (H : (f : V₁ → Vā‚‚) = g) : f = g := by cases f; cases g; congr theorem coe_injective : @Function.Injective (NormedAddGroupHom V₁ Vā‚‚) (V₁ → Vā‚‚) toFun := by apply coe_inj theorem coe_inj_iff : f = g ↔ (f : V₁ → Vā‚‚) = g := ⟨congr_arg _, coe_inj⟩ @[ext] theorem ext (H : āˆ€ x, f x = g x) : f = g := coe_inj <| funext H variable (f g) @[simp] theorem toFun_eq_coe : f.toFun = f := rfl theorem coe_mk (f) (h₁) (hā‚‚) (hā‚ƒ) : ⇑(⟨f, h₁, hā‚‚, hā‚ƒāŸ© : NormedAddGroupHom V₁ Vā‚‚) = f := rfl @[simp] theorem coe_mkNormedAddGroupHom (f : V₁ →+ Vā‚‚) (C) (hC) : ⇑(f.mkNormedAddGroupHom C hC) = f := rfl @[simp] theorem coe_mkNormedAddGroupHom' (f : V₁ →+ Vā‚‚) (C) (hC) : ⇑(f.mkNormedAddGroupHom' C hC) = f := rfl /-- The group homomorphism underlying a bounded group homomorphism. -/ def toAddMonoidHom (f : NormedAddGroupHom V₁ Vā‚‚) : V₁ →+ Vā‚‚ := AddMonoidHom.mk' f f.map_add' @[simp] theorem coe_toAddMonoidHom : ⇑f.toAddMonoidHom = f := rfl theorem toAddMonoidHom_injective : Function.Injective (@NormedAddGroupHom.toAddMonoidHom V₁ Vā‚‚ _ _) := fun f g h => coe_inj <| by rw [← coe_toAddMonoidHom f, ← coe_toAddMonoidHom g, h] @[simp] theorem mk_toAddMonoidHom (f) (h₁) (hā‚‚) : (⟨f, h₁, hā‚‚āŸ© : NormedAddGroupHom V₁ Vā‚‚).toAddMonoidHom = AddMonoidHom.mk' f h₁ := rfl theorem bound : ∃ C, 0 < C ∧ āˆ€ x, ‖f x‖ ≤ C * ‖x‖ := let ⟨_C, hC⟩ := f.bound' exists_pos_bound_of_bound _ hC theorem antilipschitz_of_norm_ge {K : ā„ā‰„0} (h : āˆ€ x, ‖x‖ ≤ K * ‖f x‖) : AntilipschitzWith K f := AntilipschitzWith.of_le_mul_dist fun x y => by simpa only [dist_eq_norm, map_sub] using h (x - y) /-- A normed group hom is surjective on the subgroup `K` with constant `C` if every element `x` of `K` has a preimage whose norm is bounded above by `C*‖x‖`. This is a more abstract version of `f` having a right inverse defined on `K` with operator norm at most `C`. -/ def SurjectiveOnWith (f : NormedAddGroupHom V₁ Vā‚‚) (K : AddSubgroup Vā‚‚) (C : ā„) : Prop := āˆ€ h ∈ K, ∃ g, f g = h ∧ ‖g‖ ≤ C * ‖h‖ theorem SurjectiveOnWith.mono {f : NormedAddGroupHom V₁ Vā‚‚} {K : AddSubgroup Vā‚‚} {C C' : ā„} (h : f.SurjectiveOnWith K C) (H : C ≤ C') : f.SurjectiveOnWith K C' := by intro k k_in rcases h k k_in with ⟨g, rfl, hg⟩ use g, rfl by_cases Hg : ‖f g‖ = 0 Ā· simpa [Hg] using hg Ā· exact hg.trans (by gcongr) theorem SurjectiveOnWith.exists_pos {f : NormedAddGroupHom V₁ Vā‚‚} {K : AddSubgroup Vā‚‚} {C : ā„} (h : f.SurjectiveOnWith K C) : ∃ C' > 0, f.SurjectiveOnWith K C' := by refine ⟨|C| + 1, ?_, ?_⟩ Ā· linarith [abs_nonneg C] Ā· apply h.mono linarith [le_abs_self C] theorem SurjectiveOnWith.surjOn {f : NormedAddGroupHom V₁ Vā‚‚} {K : AddSubgroup Vā‚‚} {C : ā„} (h : f.SurjectiveOnWith K C) : Set.SurjOn f Set.univ K := fun x hx => (h x hx).imp fun _a ⟨ha, _⟩ => ⟨Set.mem_univ _, ha⟩ /-! ### The operator norm -/ /-- The operator norm of a seminormed group homomorphism is the inf of all its bounds. -/ def opNorm (f : NormedAddGroupHom V₁ Vā‚‚) := sInf { c | 0 ≤ c ∧ āˆ€ x, ‖f x‖ ≤ c * ‖x‖ } instance hasOpNorm : Norm (NormedAddGroupHom V₁ Vā‚‚) := ⟨opNorm⟩ theorem norm_def : ‖f‖ = sInf { c | 0 ≤ c ∧ āˆ€ x, ‖f x‖ ≤ c * ‖x‖ } := 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 : NormedAddGroupHom V₁ Vā‚‚} : ∃ c, c ∈ { c | 0 ≤ c ∧ āˆ€ x, ‖f x‖ ≤ c * ‖x‖ } := let ⟨M, hMp, hMb⟩ := f.bound ⟨M, le_of_lt hMp, hMb⟩ theorem bounds_bddBelow {f : NormedAddGroupHom V₁ Vā‚‚} : BddBelow { c | 0 ≤ c ∧ āˆ€ x, ‖f x‖ ≤ c * ‖x‖ } := ⟨0, fun _ ⟨hn, _⟩ => hn⟩ theorem opNorm_nonneg : 0 ≤ ‖f‖ := le_csInf bounds_nonempty fun _ ⟨hx, _⟩ => hx /-- The fundamental property of the operator norm: `‖f x‖ ≤ ‖f‖ * ‖x‖`. -/ theorem le_opNorm (x : V₁) : ‖f x‖ ≤ ‖f‖ * ‖x‖ := by obtain ⟨C, _Cpos, hC⟩ := f.bound replace hC := hC x by_cases h : ‖x‖ = 0 Ā· rwa [h, mul_zero] at hC ⊢ have hlt : 0 < ‖x‖ := lt_of_le_of_ne (norm_nonneg x) (Ne.symm h) exact (div_le_iffā‚€ hlt).mp (le_csInf bounds_nonempty fun c ⟨_, hc⟩ => (div_le_iffā‚€ hlt).mpr <| by apply hc) theorem le_opNorm_of_le {c : ā„} {x} (h : ‖x‖ ≤ c) : ‖f x‖ ≤ ‖f‖ * c := le_trans (f.le_opNorm x) (by gcongr; exact f.opNorm_nonneg) theorem le_of_opNorm_le {c : ā„} (h : ‖f‖ ≤ c) (x : V₁) : ‖f x‖ ≤ c * ‖x‖ := (f.le_opNorm x).trans (by gcongr) /-- continuous linear maps are Lipschitz continuous. -/ theorem lipschitz : LipschitzWith āŸØā€–f‖, opNorm_nonneg f⟩ f := LipschitzWith.of_dist_le_mul fun x y => by rw [dist_eq_norm, dist_eq_norm, ← map_sub] apply le_opNorm protected theorem uniformContinuous (f : NormedAddGroupHom V₁ Vā‚‚) : UniformContinuous f := f.lipschitz.uniformContinuous @[continuity] protected theorem continuous (f : NormedAddGroupHom V₁ Vā‚‚) : Continuous f := f.uniformContinuous.continuous instance : ContinuousMapClass (NormedAddGroupHom V₁ Vā‚‚) V₁ Vā‚‚ where map_continuous := fun f => f.continuous theorem ratio_le_opNorm (x : V₁) : ‖f x‖ / ‖x‖ ≤ ‖f‖ := div_le_of_le_mulā‚€ (norm_nonneg _) f.opNorm_nonneg (le_opNorm _ _) /-- If one controls the norm of every `f x`, then one controls the norm of `f`. -/ theorem opNorm_le_bound {M : ā„} (hMp : 0 ≤ M) (hM : āˆ€ x, ‖f x‖ ≤ M * ‖x‖) : ‖f‖ ≤ M := csInf_le bounds_bddBelow ⟨hMp, hM⟩ theorem opNorm_eq_of_bounds {M : ā„} (M_nonneg : 0 ≤ M) (h_above : āˆ€ x, ‖f x‖ ≤ M * ‖x‖) (h_below : āˆ€ N ≄ 0, (āˆ€ x, ‖f x‖ ≤ N * ‖x‖) → M ≤ N) : ‖f‖ = M := le_antisymm (f.opNorm_le_bound M_nonneg h_above) ((le_csInf_iff NormedAddGroupHom.bounds_bddBelow ⟨M, M_nonneg, h_above⟩).mpr fun N ⟨N_nonneg, hN⟩ => h_below N N_nonneg hN) theorem opNorm_le_of_lipschitz {f : NormedAddGroupHom V₁ Vā‚‚} {K : ā„ā‰„0} (hf : LipschitzWith K f) : ‖f‖ ≤ K := f.opNorm_le_bound K.2 fun x => by simpa only [dist_zero_right, map_zero] using hf.dist_le_mul x 0 /-- If a bounded group homomorphism map is constructed from a group homomorphism via the constructor `AddMonoidHom.mkNormedAddGroupHom`, then its norm is bounded by the bound given to the constructor if it is nonnegative. -/ theorem mkNormedAddGroupHom_norm_le (f : V₁ →+ Vā‚‚) {C : ā„} (hC : 0 ≤ C) (h : āˆ€ x, ‖f x‖ ≤ C * ‖x‖) : ‖f.mkNormedAddGroupHom C h‖ ≤ C := opNorm_le_bound _ hC h /-- If a bounded group homomorphism map is constructed from a group homomorphism via the constructor `NormedAddGroupHom.ofLipschitz`, then its norm is bounded by the bound given to the constructor. -/ theorem ofLipschitz_norm_le (f : V₁ →+ Vā‚‚) {K : ā„ā‰„0} (h : LipschitzWith K f) : ‖ofLipschitz f h‖ ≤ K := mkNormedAddGroupHom_norm_le f K.coe_nonneg _ /-- If a bounded group homomorphism map is constructed from a group homomorphism via the constructor `AddMonoidHom.mkNormedAddGroupHom`, then its norm is bounded by the bound given to the constructor or zero if this bound is negative. -/ theorem mkNormedAddGroupHom_norm_le' (f : V₁ →+ Vā‚‚) {C : ā„} (h : āˆ€ x, ‖f x‖ ≤ C * ‖x‖) : ‖f.mkNormedAddGroupHom C h‖ ≤ max C 0 := opNorm_le_bound _ (le_max_right _ _) fun x => (h x).trans <| by gcongr; apply le_max_left alias _root_.AddMonoidHom.mkNormedAddGroupHom_norm_le := mkNormedAddGroupHom_norm_le alias _root_.AddMonoidHom.mkNormedAddGroupHom_norm_le' := mkNormedAddGroupHom_norm_le' /-! ### Addition of normed group homs -/ /-- Addition of normed group homs. -/ instance add : Add (NormedAddGroupHom V₁ Vā‚‚) := ⟨fun f g => (f.toAddMonoidHom + g.toAddMonoidHom).mkNormedAddGroupHom (‖f‖ + ‖g‖) fun v => calc ‖f v + g v‖ ≤ ‖f v‖ + ‖g v‖ := norm_add_le _ _ _ ≤ ‖f‖ * ‖v‖ + ‖g‖ * ‖v‖ := by gcongr <;> apply le_opNorm _ = (‖f‖ + ‖g‖) * ‖v‖ := by rw [add_mul] ⟩ /-- The operator norm satisfies the triangle inequality. -/ theorem opNorm_add_le : ‖f + g‖ ≤ ‖f‖ + ‖g‖ := mkNormedAddGroupHom_norm_le _ (add_nonneg (opNorm_nonneg _) (opNorm_nonneg _)) _ @[simp] theorem coe_add (f g : NormedAddGroupHom V₁ Vā‚‚) : ⇑(f + g) = f + g := rfl @[simp] theorem add_apply (f g : NormedAddGroupHom V₁ Vā‚‚) (v : V₁) : (f + g) v = f v + g v := rfl /-! ### The zero normed group hom -/ instance zero : Zero (NormedAddGroupHom V₁ Vā‚‚) := ⟨(0 : V₁ →+ Vā‚‚).mkNormedAddGroupHom 0 (by simp)⟩ instance inhabited : Inhabited (NormedAddGroupHom V₁ Vā‚‚) := ⟨0⟩ /-- The norm of the `0` operator is `0`. -/ theorem opNorm_zero : ‖(0 : NormedAddGroupHom V₁ Vā‚‚)‖ = 0 := le_antisymm (csInf_le bounds_bddBelow ⟨ge_of_eq rfl, fun _ => le_of_eq (by rw [zero_mul] exact norm_zero)⟩) (opNorm_nonneg _) /-- For normed groups, an operator is zero iff its norm vanishes. -/ theorem opNorm_zero_iff {V₁ Vā‚‚ : Type*} [NormedAddCommGroup V₁] [NormedAddCommGroup Vā‚‚] {f : NormedAddGroupHom V₁ Vā‚‚} : ‖f‖ = 0 ↔ f = 0 := Iff.intro (fun hn => ext fun x => norm_le_zero_iff.1 (calc _ ≤ ‖f‖ * ‖x‖ := le_opNorm _ _ _ = _ := by rw [hn, zero_mul] )) fun hf => by rw [hf, opNorm_zero] @[simp] theorem coe_zero : ⇑(0 : NormedAddGroupHom V₁ Vā‚‚) = 0 := rfl @[simp] theorem zero_apply (v : V₁) : (0 : NormedAddGroupHom V₁ Vā‚‚) v = 0 := rfl variable {f g} /-! ### The identity normed group hom -/ variable (V) /-- The identity as a continuous normed group hom. -/ @[simps!] def id : NormedAddGroupHom V V := (AddMonoidHom.id V).mkNormedAddGroupHom 1 (by simp [le_refl]) /-- The norm of the identity is at most `1`. It is in fact `1`, except when the norm of every element vanishes, where it is `0`. (Since we are working with seminorms this can happen even if the space is non-trivial.) It means that one cannot do better than an inequality in general. -/ theorem norm_id_le : ‖(id V : NormedAddGroupHom V V)‖ ≤ 1 := opNorm_le_bound _ zero_le_one fun x => by simp /-- If there is an element with norm different from `0`, then the norm of the identity equals `1`. (Since we are working with seminorms supposing that the space is non-trivial is not enough.) -/ theorem norm_id_of_nontrivial_seminorm (h : ∃ x : V, ‖x‖ ≠ 0) : ‖id V‖ = 1 := le_antisymm (norm_id_le V) <| by let ⟨x, hx⟩ := h have := (id V).ratio_le_opNorm x rwa [id_apply, div_self hx] at this /-- If a normed space is non-trivial, then the norm of the identity equals `1`. -/ theorem norm_id {V : Type*} [NormedAddCommGroup V] [Nontrivial V] : ‖id V‖ = 1 := by refine norm_id_of_nontrivial_seminorm V ?_ obtain ⟨x, hx⟩ := exists_ne (0 : V) exact ⟨x, ne_of_gt (norm_pos_iff.2 hx)⟩ theorem coe_id : (NormedAddGroupHom.id V : V → V) = _root_.id := rfl /-! ### The negation of a normed group hom -/ /-- Opposite of a normed group hom. -/ instance neg : Neg (NormedAddGroupHom V₁ Vā‚‚) := ⟨fun f => (-f.toAddMonoidHom).mkNormedAddGroupHom ‖f‖ fun v => by simp [le_opNorm f v]⟩ @[simp] theorem coe_neg (f : NormedAddGroupHom V₁ Vā‚‚) : ⇑(-f) = -f := rfl @[simp] theorem neg_apply (f : NormedAddGroupHom V₁ Vā‚‚) (v : V₁) : (-f : NormedAddGroupHom V₁ Vā‚‚) v = -f v := rfl theorem opNorm_neg (f : NormedAddGroupHom V₁ Vā‚‚) : ‖-f‖ = ‖f‖ := by simp only [norm_def, coe_neg, norm_neg, Pi.neg_apply] /-! ### Subtraction of normed group homs -/ /-- Subtraction of normed group homs. -/ instance sub : Sub (NormedAddGroupHom V₁ Vā‚‚) := ⟨fun f g => { f.toAddMonoidHom - g.toAddMonoidHom with bound' := by simp only [AddMonoidHom.toFun_eq_coe, sub_eq_add_neg] exact (f + -g).bound' }⟩ @[simp] theorem coe_sub (f g : NormedAddGroupHom V₁ Vā‚‚) : ⇑(f - g) = f - g := rfl @[simp] theorem sub_apply (f g : NormedAddGroupHom V₁ Vā‚‚) (v : V₁) : (f - g : NormedAddGroupHom V₁ Vā‚‚) v = f v - g v := rfl /-! ### Scalar actions on normed group homs -/ section SMul variable {R R' : Type*} [MonoidWithZero R] [DistribMulAction R Vā‚‚] [PseudoMetricSpace R] [IsBoundedSMul R Vā‚‚] [MonoidWithZero R'] [DistribMulAction R' Vā‚‚] [PseudoMetricSpace R'] [IsBoundedSMul R' Vā‚‚] instance smul : SMul R (NormedAddGroupHom V₁ Vā‚‚) where smul r f := { toFun := r • ⇑f map_add' := (r • f.toAddMonoidHom).map_add' bound' := let ⟨b, hb⟩ := f.bound' ⟨dist r 0 * b, fun x => by have := dist_smul_pair r (f x) (f 0) rw [map_zero, smul_zero, dist_zero_right, dist_zero_right] at this rw [mul_assoc] refine this.trans ?_ gcongr exact hb x⟩ } @[simp] theorem coe_smul (r : R) (f : NormedAddGroupHom V₁ Vā‚‚) : ⇑(r • f) = r • ⇑f := rfl @[simp] theorem smul_apply (r : R) (f : NormedAddGroupHom V₁ Vā‚‚) (v : V₁) : (r • f) v = r • f v := rfl instance smulCommClass [SMulCommClass R R' Vā‚‚] : SMulCommClass R R' (NormedAddGroupHom V₁ Vā‚‚) where smul_comm _ _ _ := ext fun _ => smul_comm _ _ _ instance isScalarTower [SMul R R'] [IsScalarTower R R' Vā‚‚] : IsScalarTower R R' (NormedAddGroupHom V₁ Vā‚‚) where smul_assoc _ _ _ := ext fun _ => smul_assoc _ _ _ instance isCentralScalar [DistribMulAction Rᵐᵒᵖ Vā‚‚] [IsCentralScalar R Vā‚‚] : IsCentralScalar R (NormedAddGroupHom V₁ Vā‚‚) where op_smul_eq_smul _ _ := ext fun _ => op_smul_eq_smul _ _ end SMul instance nsmul : SMul ā„• (NormedAddGroupHom V₁ Vā‚‚) where smul n f := { toFun := n • ⇑f map_add' := (n • f.toAddMonoidHom).map_add' bound' := let ⟨b, hb⟩ := f.bound' ⟨n • b, fun v => by rw [Pi.smul_apply, nsmul_eq_mul, mul_assoc] exact norm_nsmul_le.trans (by gcongr; apply hb)⟩ } @[simp] theorem coe_nsmul (r : ā„•) (f : NormedAddGroupHom V₁ Vā‚‚) : ⇑(r • f) = r • ⇑f := rfl @[simp] theorem nsmul_apply (r : ā„•) (f : NormedAddGroupHom V₁ Vā‚‚) (v : V₁) : (r • f) v = r • f v := rfl instance zsmul : SMul ℤ (NormedAddGroupHom V₁ Vā‚‚) where smul z f := { toFun := z • ⇑f map_add' := (z • f.toAddMonoidHom).map_add' bound' := let ⟨b, hb⟩ := f.bound' āŸØā€–z‖ • b, fun v => by rw [Pi.smul_apply, smul_eq_mul, mul_assoc] exact (norm_zsmul_le _ _).trans (by gcongr; apply hb)⟩ } @[simp] theorem coe_zsmul (r : ℤ) (f : NormedAddGroupHom V₁ Vā‚‚) : ⇑(r • f) = r • ⇑f := rfl @[simp] theorem zsmul_apply (r : ℤ) (f : NormedAddGroupHom V₁ Vā‚‚) (v : V₁) : (r • f) v = r • f v := rfl /-! ### Normed group structure on normed group homs -/ /-- Homs between two given normed groups form a commutative additive group. -/ instance toAddCommGroup : AddCommGroup (NormedAddGroupHom V₁ Vā‚‚) := coe_injective.addCommGroup _ rfl (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) fun _ _ => rfl /-- Normed group homomorphisms themselves form a seminormed group with respect to the operator norm. -/ instance toSeminormedAddCommGroup : SeminormedAddCommGroup (NormedAddGroupHom V₁ Vā‚‚) := AddGroupSeminorm.toSeminormedAddCommGroup { toFun := opNorm map_zero' := opNorm_zero neg' := opNorm_neg add_le' := opNorm_add_le } /-- Normed group homomorphisms themselves form a normed group with respect to the operator norm. -/ instance toNormedAddCommGroup {V₁ Vā‚‚ : Type*} [NormedAddCommGroup V₁] [NormedAddCommGroup Vā‚‚] : NormedAddCommGroup (NormedAddGroupHom V₁ Vā‚‚) := AddGroupNorm.toNormedAddCommGroup { toFun := opNorm map_zero' := opNorm_zero neg' := opNorm_neg add_le' := opNorm_add_le eq_zero_of_map_eq_zero' := fun _f => opNorm_zero_iff.1 } /-- Coercion of a `NormedAddGroupHom` is an `AddMonoidHom`. Similar to `AddMonoidHom.coeFn`. -/ @[simps] def coeAddHom : NormedAddGroupHom V₁ Vā‚‚ →+ V₁ → Vā‚‚ where toFun := DFunLike.coe map_zero' := coe_zero map_add' := coe_add @[simp] theorem coe_sum {ι : Type*} (s : Finset ι) (f : ι → NormedAddGroupHom V₁ Vā‚‚) : ⇑(āˆ‘ i ∈ s, f i) = āˆ‘ i ∈ s, (f i : V₁ → Vā‚‚) := map_sum coeAddHom f s theorem sum_apply {ι : Type*} (s : Finset ι) (f : ι → NormedAddGroupHom V₁ Vā‚‚) (v : V₁) : (āˆ‘ i ∈ s, f i) v = āˆ‘ i ∈ s, f i v := by simp only [coe_sum, Finset.sum_apply] /-! ### Module structure on normed group homs -/ instance distribMulAction {R : Type*} [MonoidWithZero R] [DistribMulAction R Vā‚‚] [PseudoMetricSpace R] [IsBoundedSMul R Vā‚‚] : DistribMulAction R (NormedAddGroupHom V₁ Vā‚‚) := Function.Injective.distribMulAction coeAddHom coe_injective coe_smul instance module {R : Type*} [Semiring R] [Module R Vā‚‚] [PseudoMetricSpace R] [IsBoundedSMul R Vā‚‚] : Module R (NormedAddGroupHom V₁ Vā‚‚) := Function.Injective.module _ coeAddHom coe_injective coe_smul /-! ### Composition of normed group homs -/ /-- The composition of continuous normed group homs. -/ @[simps!] protected def comp (g : NormedAddGroupHom Vā‚‚ Vā‚ƒ) (f : NormedAddGroupHom V₁ Vā‚‚) : NormedAddGroupHom V₁ Vā‚ƒ := (g.toAddMonoidHom.comp f.toAddMonoidHom).mkNormedAddGroupHom (‖g‖ * ‖f‖) fun v => calc ‖g (f v)‖ ≤ ‖g‖ * ‖f v‖ := le_opNorm _ _ _ ≤ ‖g‖ * (‖f‖ * ‖v‖) := by gcongr; apply le_opNorm _ = ‖g‖ * ‖f‖ * ‖v‖ := by rw [mul_assoc] theorem norm_comp_le (g : NormedAddGroupHom Vā‚‚ Vā‚ƒ) (f : NormedAddGroupHom V₁ Vā‚‚) : ‖g.comp f‖ ≤ ‖g‖ * ‖f‖ := mkNormedAddGroupHom_norm_le _ (by positivity) _ theorem norm_comp_le_of_le {g : NormedAddGroupHom Vā‚‚ Vā‚ƒ} {C₁ Cā‚‚ : ā„} (hg : ‖g‖ ≤ Cā‚‚) (hf : ‖f‖ ≤ C₁) : ‖g.comp f‖ ≤ Cā‚‚ * C₁ := le_trans (norm_comp_le g f) <| by gcongr; exact le_trans (norm_nonneg _) hg theorem norm_comp_le_of_le' {g : NormedAddGroupHom Vā‚‚ Vā‚ƒ} (C₁ Cā‚‚ Cā‚ƒ : ā„) (h : Cā‚ƒ = Cā‚‚ * C₁) (hg : ‖g‖ ≤ Cā‚‚) (hf : ‖f‖ ≤ C₁) : ‖g.comp f‖ ≤ Cā‚ƒ := by rw [h] exact norm_comp_le_of_le hg hf /-- Composition of normed groups hom as an additive group morphism. -/ def compHom : NormedAddGroupHom Vā‚‚ Vā‚ƒ →+ NormedAddGroupHom V₁ Vā‚‚ →+ NormedAddGroupHom V₁ Vā‚ƒ := AddMonoidHom.mk' (fun g => AddMonoidHom.mk' (fun f => g.comp f) (by intros ext exact map_add g _ _)) (by intros ext simp only [comp_apply, Pi.add_apply, AddMonoidHom.add_apply, AddMonoidHom.mk'_apply, coe_add]) @[simp] theorem comp_zero (f : NormedAddGroupHom Vā‚‚ Vā‚ƒ) : f.comp (0 : NormedAddGroupHom V₁ Vā‚‚) = 0 := by ext exact map_zero f @[simp] theorem zero_comp (f : NormedAddGroupHom V₁ Vā‚‚) : (0 : NormedAddGroupHom Vā‚‚ Vā‚ƒ).comp f = 0 := by ext rfl theorem comp_assoc {Vā‚„ : Type*} [SeminormedAddCommGroup Vā‚„] (h : NormedAddGroupHom Vā‚ƒ Vā‚„) (g : NormedAddGroupHom Vā‚‚ Vā‚ƒ) (f : NormedAddGroupHom V₁ Vā‚‚) : (h.comp g).comp f = h.comp (g.comp f) := by ext rfl theorem coe_comp (f : NormedAddGroupHom V₁ Vā‚‚) (g : NormedAddGroupHom Vā‚‚ Vā‚ƒ) : (g.comp f : V₁ → Vā‚ƒ) = (g : Vā‚‚ → Vā‚ƒ) ∘ (f : V₁ → Vā‚‚) := rfl end NormedAddGroupHom namespace NormedAddGroupHom variable {V W V₁ Vā‚‚ Vā‚ƒ : Type*} [SeminormedAddCommGroup V] [SeminormedAddCommGroup W] [SeminormedAddCommGroup V₁] [SeminormedAddCommGroup Vā‚‚] [SeminormedAddCommGroup Vā‚ƒ] /-- The inclusion of an `AddSubgroup`, as bounded group homomorphism. -/ @[simps!] def incl (s : AddSubgroup V) : NormedAddGroupHom s V where toFun := (Subtype.val : s → V) map_add' _ _ := AddSubgroup.coe_add _ _ _ bound' := ⟨1, fun v => by rw [one_mul, AddSubgroup.coe_norm]⟩ theorem norm_incl {V' : AddSubgroup V} (x : V') : ‖incl _ x‖ = ‖x‖ := rfl /-!### Kernel -/ section Kernels variable (f : NormedAddGroupHom V₁ Vā‚‚) (g : NormedAddGroupHom Vā‚‚ Vā‚ƒ) /-- The kernel of a bounded group homomorphism. Naturally endowed with a `SeminormedAddCommGroup` instance. -/ def ker : AddSubgroup V₁ := f.toAddMonoidHom.ker theorem mem_ker (v : V₁) : v ∈ f.ker ↔ f v = 0 := by rw [ker, f.toAddMonoidHom.mem_ker, coe_toAddMonoidHom] /-- Given a normed group hom `f : V₁ → Vā‚‚` satisfying `g.comp f = 0` for some `g : Vā‚‚ → Vā‚ƒ`, the corestriction of `f` to the kernel of `g`. -/ @[simps] def ker.lift (h : g.comp f = 0) : NormedAddGroupHom V₁ g.ker where toFun v := ⟨f v, by rw [g.mem_ker, ← comp_apply g f, h, zero_apply]⟩ map_add' v w := by simp only [map_add, AddMemClass.mk_add_mk] bound' := f.bound' @[simp] theorem ker.incl_comp_lift (h : g.comp f = 0) : (incl g.ker).comp (ker.lift f g h) = f := by ext rfl @[simp] theorem ker_zero : (0 : NormedAddGroupHom V₁ Vā‚‚).ker = ⊤ := by ext simp [mem_ker] theorem coe_ker : (f.ker : Set V₁) = (f : V₁ → Vā‚‚) ⁻¹' {0} := rfl theorem isClosed_ker {Vā‚‚ : Type*} [NormedAddCommGroup Vā‚‚] (f : NormedAddGroupHom V₁ Vā‚‚) : IsClosed (f.ker : Set V₁) := f.coe_ker ā–ø IsClosed.preimage f.continuous (T1Space.t1 0) end Kernels /-! ### Range -/ section Range variable (f : NormedAddGroupHom V₁ Vā‚‚) (g : NormedAddGroupHom Vā‚‚ Vā‚ƒ) /-- The image of a bounded group homomorphism. Naturally endowed with a `SeminormedAddCommGroup` instance. -/ def range : AddSubgroup Vā‚‚ := f.toAddMonoidHom.range theorem mem_range (v : Vā‚‚) : v ∈ f.range ↔ ∃ w, f w = v := Iff.rfl @[simp] theorem mem_range_self (v : V₁) : f v ∈ f.range := ⟨v, rfl⟩ theorem comp_range : (g.comp f).range = AddSubgroup.map g.toAddMonoidHom f.range := by unfold range rw [AddMonoidHom.map_range] rfl theorem incl_range (s : AddSubgroup V₁) : (incl s).range = s := by ext x exact ⟨fun ⟨y, hy⟩ => by rw [← hy]; simp, fun hx => ⟨⟨x, hx⟩, by simp⟩⟩ @[simp] theorem range_comp_incl_top : (f.comp (incl (⊤ : AddSubgroup V₁))).range = f.range := by simp [comp_range, incl_range, ← AddMonoidHom.range_eq_map]; rfl end Range variable {f : NormedAddGroupHom V W} /-- A `NormedAddGroupHom` is *norm-nonincreasing* if `‖f v‖ ≤ ‖v‖` for all `v`. -/ def NormNoninc (f : NormedAddGroupHom V W) : Prop := āˆ€ v, ‖f v‖ ≤ ‖v‖ namespace NormNoninc theorem normNoninc_iff_norm_le_one : f.NormNoninc ↔ ‖f‖ ≤ 1 := by refine ⟨fun h => ?_, fun h => fun v => ?_⟩ Ā· refine opNorm_le_bound _ zero_le_one fun v => ?_ simpa [one_mul] using h v Ā· simpa using le_of_opNorm_le f h v theorem zero : (0 : NormedAddGroupHom V₁ Vā‚‚).NormNoninc := fun v => by simp theorem id : (id V).NormNoninc := fun _v => le_rfl theorem comp {g : NormedAddGroupHom Vā‚‚ Vā‚ƒ} {f : NormedAddGroupHom V₁ Vā‚‚} (hg : g.NormNoninc) (hf : f.NormNoninc) : (g.comp f).NormNoninc := fun v => (hg (f v)).trans (hf v) @[simp] theorem neg_iff {f : NormedAddGroupHom V₁ Vā‚‚} : (-f).NormNoninc ↔ f.NormNoninc := ⟨fun h x => by simpa using h x, fun h x => (norm_neg (f x)).le.trans (h x)⟩ end NormNoninc section Isometry theorem norm_eq_of_isometry {f : NormedAddGroupHom V W} (hf : Isometry f) (v : V) : ‖f v‖ = ‖v‖ := (AddMonoidHomClass.isometry_iff_norm f).mp hf v theorem isometry_id : @Isometry V V _ _ (id V) := _root_.isometry_id theorem isometry_comp {g : NormedAddGroupHom Vā‚‚ Vā‚ƒ} {f : NormedAddGroupHom V₁ Vā‚‚} (hg : Isometry g) (hf : Isometry f) : Isometry (g.comp f) := hg.comp hf theorem normNoninc_of_isometry (hf : Isometry f) : f.NormNoninc := fun v => le_of_eq <| norm_eq_of_isometry hf v end Isometry variable {W₁ Wā‚‚ Wā‚ƒ : Type*} [SeminormedAddCommGroup W₁] [SeminormedAddCommGroup Wā‚‚] [SeminormedAddCommGroup Wā‚ƒ] variable (f) (g : NormedAddGroupHom V W) variable {f₁ g₁ : NormedAddGroupHom V₁ W₁} variable {fā‚‚ gā‚‚ : NormedAddGroupHom Vā‚‚ Wā‚‚} variable {fā‚ƒ gā‚ƒ : NormedAddGroupHom Vā‚ƒ Wā‚ƒ} /-- The equalizer of two morphisms `f g : NormedAddGroupHom V W`. -/ def equalizer := (f - g).ker namespace Equalizer /-- The inclusion of `f.equalizer g` as a `NormedAddGroupHom`. -/ def ι : NormedAddGroupHom (f.equalizer g) V := incl _ theorem comp_ι_eq : f.comp (ι f g) = g.comp (ι f g) := by ext x rw [comp_apply, comp_apply, ← sub_eq_zero, ← NormedAddGroupHom.sub_apply] exact x.2 variable {f g} /-- If `φ : NormedAddGroupHom V₁ V` is such that `f.comp φ = g.comp φ`, the induced morphism `NormedAddGroupHom V₁ (f.equalizer g)`. -/ @[simps] def lift (φ : NormedAddGroupHom V₁ V) (h : f.comp φ = g.comp φ) : NormedAddGroupHom V₁ (f.equalizer g) where toFun v := āŸØĻ† v, show (f - g) (φ v) = 0 by rw [NormedAddGroupHom.sub_apply, sub_eq_zero, ← comp_apply, h, comp_apply]⟩ map_add' v₁ vā‚‚ := by ext simp only [map_add, AddSubgroup.coe_add] bound' := by obtain ⟨C, _C_pos, hC⟩ := φ.bound exact ⟨C, hC⟩ @[simp] theorem ι_comp_lift (φ : NormedAddGroupHom V₁ V) (h : f.comp φ = g.comp φ) : (ι _ _).comp (lift φ h) = φ := by ext rfl /-- The lifting property of the equalizer as an equivalence. -/ @[simps] def liftEquiv : { φ : NormedAddGroupHom V₁ V // f.comp φ = g.comp φ } ā‰ƒ NormedAddGroupHom V₁ (f.equalizer g) where toFun φ := lift φ φ.prop invFun ψ := ⟨(ι f g).comp ψ, by rw [← comp_assoc, ← comp_assoc, comp_ι_eq]⟩ left_inv φ := by simp /-- Given `φ : NormedAddGroupHom V₁ Vā‚‚` and `ψ : NormedAddGroupHom W₁ Wā‚‚` such that `ψ.comp f₁ = fā‚‚.comp φ` and `ψ.comp g₁ = gā‚‚.comp φ`, the induced morphism `NormedAddGroupHom (f₁.equalizer g₁) (fā‚‚.equalizer gā‚‚)`. -/ def map (φ : NormedAddGroupHom V₁ Vā‚‚) (ψ : NormedAddGroupHom W₁ Wā‚‚) (hf : ψ.comp f₁ = fā‚‚.comp φ) (hg : ψ.comp g₁ = gā‚‚.comp φ) : NormedAddGroupHom (f₁.equalizer g₁) (fā‚‚.equalizer gā‚‚) := lift (φ.comp <| ι _ _) <| by simp only [← comp_assoc, ← hf, ← hg] simp only [comp_assoc, comp_ι_eq f₁ g₁] variable {φ : NormedAddGroupHom V₁ Vā‚‚} {ψ : NormedAddGroupHom W₁ Wā‚‚} variable {φ' : NormedAddGroupHom Vā‚‚ Vā‚ƒ} {ψ' : NormedAddGroupHom Wā‚‚ Wā‚ƒ} @[simp] theorem ι_comp_map (hf : ψ.comp f₁ = fā‚‚.comp φ) (hg : ψ.comp g₁ = gā‚‚.comp φ) : (ι fā‚‚ gā‚‚).comp (map φ ψ hf hg) = φ.comp (ι f₁ g₁) := ι_comp_lift _ _ @[simp] theorem map_id : map (fā‚‚ := f₁) (gā‚‚ := g₁) (id V₁) (id W₁) rfl rfl = id (f₁.equalizer g₁) := by ext rfl theorem comm_sqā‚‚ (hf : ψ.comp f₁ = fā‚‚.comp φ) (hf' : ψ'.comp fā‚‚ = fā‚ƒ.comp φ') : (ψ'.comp ψ).comp f₁ = fā‚ƒ.comp (φ'.comp φ) := by rw [comp_assoc, hf, ← comp_assoc, hf', comp_assoc] theorem map_comp_map (hf : ψ.comp f₁ = fā‚‚.comp φ) (hg : ψ.comp g₁ = gā‚‚.comp φ) (hf' : ψ'.comp fā‚‚ = fā‚ƒ.comp φ') (hg' : ψ'.comp gā‚‚ = gā‚ƒ.comp φ') : (map φ' ψ' hf' hg').comp (map φ ψ hf hg) = map (φ'.comp φ) (ψ'.comp ψ) (comm_sqā‚‚ hf hf') (comm_sqā‚‚ hg hg') := by ext rfl theorem ι_normNoninc : (ι f g).NormNoninc := fun _v => le_rfl /-- The lifting of a norm nonincreasing morphism is norm nonincreasing. -/ theorem lift_normNoninc (φ : NormedAddGroupHom V₁ V) (h : f.comp φ = g.comp φ) (hφ : φ.NormNoninc) : (lift φ h).NormNoninc := hφ /-- If `φ` satisfies `‖φ‖ ≤ C`, then the same is true for the lifted morphism. -/ theorem norm_lift_le (φ : NormedAddGroupHom V₁ V) (h : f.comp φ = g.comp φ) (C : ā„) (hφ : ‖φ‖ ≤ C) : ‖lift φ h‖ ≤ C := hφ theorem map_normNoninc (hf : ψ.comp f₁ = fā‚‚.comp φ) (hg : ψ.comp g₁ = gā‚‚.comp φ) (hφ : φ.NormNoninc) : (map φ ψ hf hg).NormNoninc := lift_normNoninc _ _ <| hφ.comp ι_normNoninc theorem norm_map_le (hf : ψ.comp f₁ = fā‚‚.comp φ) (hg : ψ.comp g₁ = gā‚‚.comp φ) (C : ā„) (hφ : ‖φ.comp (ι f₁ g₁)‖ ≤ C) : ‖map φ ψ hf hg‖ ≤ C := norm_lift_le _ _ _ hφ end Equalizer end NormedAddGroupHom
.lake/packages/mathlib/Mathlib/Analysis/Normed/Group/SemiNormedGrp/Completion.lean
import Mathlib.Analysis.Normed.Group.SemiNormedGrp import Mathlib.CategoryTheory.Preadditive.AdditiveFunctor import Mathlib.Analysis.Normed.Group.HomCompletion /-! # Completions of normed groups This file contains an API for completions of seminormed groups (basic facts about objects and morphisms). ## Main definitions - `SemiNormedGrp.Completion : SemiNormedGrp ℤ SemiNormedGrp` : the completion of a seminormed group (defined as a functor on `SemiNormedGrp` to itself). - `SemiNormedGrp.Completion.lift (f : V ⟶ W) : (Completion.obj V ⟶ W)` : a normed group hom from `V` to complete `W` extends ("lifts") to a seminormed group hom from the completion of `V` to `W`. ## Projects 1. Construct the category of complete seminormed groups, say `CompleteSemiNormedGrp` and promote the `Completion` functor below to a functor landing in this category. 2. Prove that the functor `Completion : SemiNormedGrp ℤ CompleteSemiNormedGrp` is left adjoint to the forgetful functor. -/ noncomputable section universe u open UniformSpace MulOpposite CategoryTheory NormedAddGroupHom namespace SemiNormedGrp /-- The completion of a seminormed group, as an endofunctor on `SemiNormedGrp`. -/ @[simps] def completion : SemiNormedGrp.{u} ℤ SemiNormedGrp.{u} where obj V := SemiNormedGrp.of (Completion V) map f := SemiNormedGrp.ofHom f.hom.completion map_id _ := SemiNormedGrp.hom_ext completion_id map_comp f g := SemiNormedGrp.hom_ext (completion_comp f.hom g.hom).symm instance completion_completeSpace {V : SemiNormedGrp} : CompleteSpace (completion.obj V) := Completion.completeSpace _ /-- The canonical morphism from a seminormed group `V` to its completion. -/ def completion.incl {V : SemiNormedGrp} : V ⟶ completion.obj V := ofHom { toFun v := (v : Completion V) map_add' := Completion.coe_add bound' := ⟨1, fun v => by simp⟩ } theorem completion.norm_incl_eq {V : SemiNormedGrp} {v : V} : ‖completion.incl v‖ = ‖v‖ := UniformSpace.Completion.norm_coe _ theorem completion.map_normNoninc {V W : SemiNormedGrp} {f : V ⟶ W} (hf : f.hom.NormNoninc) : (completion.map f).hom.NormNoninc := NormedAddGroupHom.NormNoninc.normNoninc_iff_norm_le_one.2 <| (NormedAddGroupHom.norm_completion f.hom).le.trans <| NormedAddGroupHom.NormNoninc.normNoninc_iff_norm_le_one.1 hf variable (V W : SemiNormedGrp) /-- Given a normed group hom `V ⟶ W`, this defines the associated morphism from the completion of `V` to the completion of `W`. The difference from the definition obtained from the functoriality of completion is in that the map sending a morphism `f` to the associated morphism of completions is itself additive. -/ def completion.mapHom (V W : SemiNormedGrp.{u}) : (V ⟶ W) →+ (completion.obj V ⟶ completion.obj W) := @AddMonoidHom.mk' _ _ (_) (_) completion.map fun f g => SemiNormedGrp.hom_ext (f.hom.completion_add g.hom) theorem completion.map_zero (V W : SemiNormedGrp) : completion.map (0 : V ⟶ W) = 0 := (completion.mapHom V W).map_zero instance : Preadditive SemiNormedGrp.{u} where instance : Functor.Additive completion where map_add := SemiNormedGrp.hom_ext <| NormedAddGroupHom.completion_add _ _ /-- Given a normed group hom `f : V → W` with `W` complete, this provides a lift of `f` to the completion of `V`. The lemmas `lift_unique` and `lift_comp_incl` provide the api for the universal property of the completion. -/ def completion.lift {V W : SemiNormedGrp} [CompleteSpace W] [T0Space W] (f : V ⟶ W) : completion.obj V ⟶ W := ofHom { toFun := f.hom.extension map_add' := f.hom.extension.toAddMonoidHom.map_add' bound' := f.hom.extension.bound' } theorem completion.lift_comp_incl {V W : SemiNormedGrp} [CompleteSpace W] [T0Space W] (f : V ⟶ W) : completion.incl ≫ completion.lift f = f := ext <| NormedAddGroupHom.extension_coe _ theorem completion.lift_unique {V W : SemiNormedGrp} [CompleteSpace W] [T0Space W] (f : V ⟶ W) (g : completion.obj V ⟶ W) : completion.incl ≫ g = f → g = completion.lift f := fun h => SemiNormedGrp.hom_ext (NormedAddGroupHom.extension_unique _ fun v => ((SemiNormedGrp.ext_iff.1 h) v).symm).symm end SemiNormedGrp
.lake/packages/mathlib/Mathlib/Analysis/Normed/Group/SemiNormedGrp/Kernels.lean
import Mathlib.Analysis.Normed.Group.SemiNormedGrp import Mathlib.Analysis.Normed.Group.Quotient import Mathlib.CategoryTheory.Limits.Shapes.Kernels /-! # Kernels and cokernels in SemiNormedGrp₁ and SemiNormedGrp We show that `SemiNormedGrp₁` has cokernels (for which of course the `cokernel.Ļ€ f` maps are norm non-increasing), as well as the easier result that `SemiNormedGrp` has cokernels. We also show that `SemiNormedGrp` has kernels. So far, I don't see a way to state nicely what we really want: `SemiNormedGrp` has cokernels, and `cokernel.Ļ€ f` is norm non-increasing. The problem is that the limits API doesn't promise you any particular model of the cokernel, and in `SemiNormedGrp` one can always take a cokernel and rescale its norm (and hence making `cokernel.Ļ€ f` arbitrarily large in norm), obtaining another categorical cokernel. -/ open CategoryTheory CategoryTheory.Limits universe u namespace SemiNormedGrp₁ noncomputable section /-- Auxiliary definition for `HasCokernels SemiNormedGrp₁`. -/ def cokernelCocone {X Y : SemiNormedGrp₁.{u}} (f : X ⟶ Y) : Cofork f 0 := Cofork.ofĻ€ (@SemiNormedGrp₁.mkHom _ (Y ā§ø NormedAddGroupHom.range f.1) _ _ f.hom.1.range.normedMk (NormedAddGroupHom.isQuotientQuotient _).norm_le) (by ext x rw [Limits.zero_comp, comp_apply, SemiNormedGrp₁.mkHom_apply, SemiNormedGrp₁.zero_apply, ← NormedAddGroupHom.mem_ker, f.hom.1.range.ker_normedMk, f.hom.1.mem_range] use x) /-- Auxiliary definition for `HasCokernels SemiNormedGrp₁`. -/ def cokernelLift {X Y : SemiNormedGrp₁.{u}} (f : X ⟶ Y) (s : CokernelCofork f) : (cokernelCocone f).pt ⟶ s.pt := by fconstructor -- The lift itself: Ā· apply NormedAddGroupHom.lift _ s.Ļ€.1 rintro _ ⟨b, rfl⟩ change (f ≫ s.Ļ€) b = 0 simp -- The lift has norm at most one: exact NormedAddGroupHom.lift_normNoninc _ _ _ s.Ļ€.2 instance : HasCokernels SemiNormedGrp₁.{u} where has_colimit f := HasColimit.mk { cocone := cokernelCocone f isColimit := isColimitAux _ (cokernelLift f) (fun s => by ext apply NormedAddGroupHom.lift_mk f.1.range rintro _ ⟨b, rfl⟩ change (f ≫ s.Ļ€) b = 0 simp) fun _ _ w => SemiNormedGrp₁.hom_ext <| Subtype.eq (NormedAddGroupHom.lift_unique f.1.range _ _ _ (congr_arg Subtype.val (congr_arg Hom.hom w))) } -- Sanity check example : HasCokernels SemiNormedGrp₁ := by infer_instance end end SemiNormedGrp₁ namespace SemiNormedGrp section EqualizersAndKernels noncomputable instance {V W : SemiNormedGrp.{u}} : Norm (V ⟶ W) where norm f := norm f.hom noncomputable instance {V W : SemiNormedGrp.{u}} : NNNorm (V ⟶ W) where nnnorm f := nnnorm f.hom /-- The equalizer cone for a parallel pair of morphisms of seminormed groups. -/ def fork {V W : SemiNormedGrp.{u}} (f g : V ⟶ W) : Fork f g := @Fork.ofι _ _ _ _ _ _ (of (f - g).hom.ker) (ofHom (NormedAddGroupHom.incl (f - g).hom.ker)) <| by ext v have : v.1 ∈ (f - g).hom.ker := v.2 simpa [-SetLike.coe_mem, NormedAddGroupHom.mem_ker, sub_eq_zero] using this instance hasLimit_parallelPair {V W : SemiNormedGrp.{u}} (f g : V ⟶ W) : HasLimit (parallelPair f g) where exists_limit := Nonempty.intro { cone := fork f g isLimit := have this := fun (c : Fork f g) => show NormedAddGroupHom.compHom (f - g).hom c.ι.hom = 0 by rw [hom_sub, AddMonoidHom.map_sub, AddMonoidHom.sub_apply, sub_eq_zero] exact congr_arg Hom.hom c.condition Fork.IsLimit.mk _ (fun c => ofHom <| NormedAddGroupHom.ker.lift (Fork.ι c).hom _ <| this c) (fun _ => SemiNormedGrp.hom_ext <| NormedAddGroupHom.ker.incl_comp_lift _ _ (this _)) fun c g h => by ext x; dsimp; simp_rw [← h]; rfl} instance : Limits.HasEqualizers.{u, u + 1} SemiNormedGrp := @hasEqualizers_of_hasLimit_parallelPair SemiNormedGrp _ fun {_ _ f g} => SemiNormedGrp.hasLimit_parallelPair f g end EqualizersAndKernels section Cokernel -- PROJECT: can we reuse the work to construct cokernels in `SemiNormedGrp₁` here? -- I don't see a way to do this that is less work than just repeating the relevant parts. /-- Auxiliary definition for `HasCokernels SemiNormedGrp`. -/ noncomputable def cokernelCocone {X Y : SemiNormedGrp.{u}} (f : X ⟶ Y) : Cofork f 0 := Cofork.ofĻ€ (P := SemiNormedGrp.of (Y ā§ø NormedAddGroupHom.range f.hom)) (ofHom f.hom.range.normedMk) (by aesop) /-- Auxiliary definition for `HasCokernels SemiNormedGrp`. -/ noncomputable def cokernelLift {X Y : SemiNormedGrp.{u}} (f : X ⟶ Y) (s : CokernelCofork f) : (cokernelCocone f).pt ⟶ s.pt := ofHom <| NormedAddGroupHom.lift _ s.Ļ€.hom (by rintro _ ⟨b, rfl⟩ change (f ≫ s.Ļ€) b = 0 simp) /-- Auxiliary definition for `HasCokernels SemiNormedGrp`. -/ noncomputable def isColimitCokernelCocone {X Y : SemiNormedGrp.{u}} (f : X ⟶ Y) : IsColimit (cokernelCocone f) := isColimitAux _ (cokernelLift f) (fun s => by ext apply NormedAddGroupHom.lift_mk f.hom.range rintro _ ⟨b, rfl⟩ change (f ≫ s.Ļ€) b = 0 simp) fun _ _ w => SemiNormedGrp.hom_ext <| NormedAddGroupHom.lift_unique f.hom.range _ _ _ <| congr_arg Hom.hom w instance : HasCokernels SemiNormedGrp.{u} where has_colimit f := HasColimit.mk { cocone := cokernelCocone f isColimit := isColimitCokernelCocone f } -- Sanity check example : HasCokernels SemiNormedGrp := by infer_instance section ExplicitCokernel /-- An explicit choice of cokernel, which has good properties with respect to the norm. -/ noncomputable def explicitCokernel {X Y : SemiNormedGrp.{u}} (f : X ⟶ Y) : SemiNormedGrp.{u} := (cokernelCocone f).pt /-- Descend to the explicit cokernel. -/ noncomputable def explicitCokernelDesc {X Y Z : SemiNormedGrp.{u}} {f : X ⟶ Y} {g : Y ⟶ Z} (w : f ≫ g = 0) : explicitCokernel f ⟶ Z := (isColimitCokernelCocone f).desc (Cofork.ofĻ€ g (by simp [w])) /-- The projection from `Y` to the explicit cokernel of `X ⟶ Y`. -/ noncomputable def explicitCokernelĻ€ {X Y : SemiNormedGrp.{u}} (f : X ⟶ Y) : Y ⟶ explicitCokernel f := (cokernelCocone f).ι.app WalkingParallelPair.one theorem explicitCokernelĻ€_surjective {X Y : SemiNormedGrp.{u}} {f : X ⟶ Y} : Function.Surjective (explicitCokernelĻ€ f) := Quot.mk_surjective @[reassoc (attr := simp)] theorem comp_explicitCokernelĻ€ {X Y : SemiNormedGrp.{u}} (f : X ⟶ Y) : f ≫ explicitCokernelĻ€ f = 0 := by convert (cokernelCocone f).w WalkingParallelPairHom.left simp @[simp] theorem explicitCokernelĻ€_apply_dom_eq_zero {X Y : SemiNormedGrp.{u}} {f : X ⟶ Y} (x : X) : (explicitCokernelĻ€ f) (f x) = 0 := show (f ≫ explicitCokernelĻ€ f) x = 0 by rw [comp_explicitCokernelĻ€]; rfl @[simp, reassoc] theorem explicitCokernelĻ€_desc {X Y Z : SemiNormedGrp.{u}} {f : X ⟶ Y} {g : Y ⟶ Z} (w : f ≫ g = 0) : explicitCokernelĻ€ f ≫ explicitCokernelDesc w = g := (isColimitCokernelCocone f).fac _ _ @[simp] theorem explicitCokernelĻ€_desc_apply {X Y Z : SemiNormedGrp.{u}} {f : X ⟶ Y} {g : Y ⟶ Z} {cond : f ≫ g = 0} (x : Y) : explicitCokernelDesc cond (explicitCokernelĻ€ f x) = g x := show (explicitCokernelĻ€ f ≫ explicitCokernelDesc cond) x = g x by rw [explicitCokernelĻ€_desc] theorem explicitCokernelDesc_unique {X Y Z : SemiNormedGrp.{u}} {f : X ⟶ Y} {g : Y ⟶ Z} (w : f ≫ g = 0) (e : explicitCokernel f ⟶ Z) (he : explicitCokernelĻ€ f ≫ e = g) : e = explicitCokernelDesc w := by apply (isColimitCokernelCocone f).uniq (Cofork.ofĻ€ g (by simp [w])) rintro (_ | _) Ā· convert w.symm simp Ā· exact he theorem explicitCokernelDesc_comp_eq_desc {X Y Z W : SemiNormedGrp.{u}} {f : X ⟶ Y} {g : Y ⟶ Z} {h : Z ⟶ W} {cond : f ≫ g = 0} : explicitCokernelDesc cond ≫ h = explicitCokernelDesc (show f ≫ g ≫ h = 0 by rw [← CategoryTheory.Category.assoc, cond, Limits.zero_comp]) := by refine explicitCokernelDesc_unique _ _ ?_ rw [← CategoryTheory.Category.assoc, explicitCokernelĻ€_desc] @[simp] theorem explicitCokernelDesc_zero {X Y Z : SemiNormedGrp.{u}} {f : X ⟶ Y} : explicitCokernelDesc (show f ≫ (0 : Y ⟶ Z) = 0 from CategoryTheory.Limits.comp_zero) = 0 := Eq.symm <| explicitCokernelDesc_unique _ _ CategoryTheory.Limits.comp_zero @[ext] theorem explicitCokernel_hom_ext {X Y Z : SemiNormedGrp.{u}} {f : X ⟶ Y} (e₁ eā‚‚ : explicitCokernel f ⟶ Z) (h : explicitCokernelĻ€ f ≫ e₁ = explicitCokernelĻ€ f ≫ eā‚‚) : e₁ = eā‚‚ := by let g : Y ⟶ Z := explicitCokernelĻ€ f ≫ eā‚‚ have w : f ≫ g = 0 := by simp [g] have : eā‚‚ = explicitCokernelDesc w := by apply explicitCokernelDesc_unique; rfl rw [this] apply explicitCokernelDesc_unique exact h instance explicitCokernelĻ€.epi {X Y : SemiNormedGrp.{u}} {f : X ⟶ Y} : Epi (explicitCokernelĻ€ f) := by constructor intro Z g h H ext x rw [H] theorem isQuotient_explicitCokernelĻ€ {X Y : SemiNormedGrp.{u}} (f : X ⟶ Y) : NormedAddGroupHom.IsQuotient (explicitCokernelĻ€ f).hom := NormedAddGroupHom.isQuotientQuotient _ theorem normNoninc_explicitCokernelĻ€ {X Y : SemiNormedGrp.{u}} (f : X ⟶ Y) : (explicitCokernelĻ€ f).hom.NormNoninc := (isQuotient_explicitCokernelĻ€ f).norm_le open scoped NNReal theorem explicitCokernelDesc_norm_le_of_norm_le {X Y Z : SemiNormedGrp.{u}} {f : X ⟶ Y} {g : Y ⟶ Z} (w : f ≫ g = 0) (c : ā„ā‰„0) (h : ‖g‖ ≤ c) : ‖explicitCokernelDesc w‖ ≤ c := NormedAddGroupHom.lift_norm_le _ _ _ h theorem explicitCokernelDesc_normNoninc {X Y Z : SemiNormedGrp.{u}} {f : X ⟶ Y} {g : Y ⟶ Z} {cond : f ≫ g = 0} (hg : g.hom.NormNoninc) : (explicitCokernelDesc cond).hom.NormNoninc := by refine NormedAddGroupHom.NormNoninc.normNoninc_iff_norm_le_one.2 ?_ rw [← NNReal.coe_one] exact explicitCokernelDesc_norm_le_of_norm_le cond 1 (NormedAddGroupHom.NormNoninc.normNoninc_iff_norm_le_one.1 hg) theorem explicitCokernelDesc_comp_eq_zero {X Y Z W : SemiNormedGrp.{u}} {f : X ⟶ Y} {g : Y ⟶ Z} {h : Z ⟶ W} (cond : f ≫ g = 0) (cond2 : g ≫ h = 0) : explicitCokernelDesc cond ≫ h = 0 := by rw [← cancel_epi (explicitCokernelĻ€ f), ← Category.assoc, explicitCokernelĻ€_desc] simp [cond2] theorem explicitCokernelDesc_norm_le {X Y Z : SemiNormedGrp.{u}} {f : X ⟶ Y} {g : Y ⟶ Z} (w : f ≫ g = 0) : ‖explicitCokernelDesc w‖ ≤ ‖g‖ := explicitCokernelDesc_norm_le_of_norm_le w ‖gā€–ā‚Š le_rfl /-- The explicit cokernel is isomorphic to the usual cokernel. -/ noncomputable def explicitCokernelIso {X Y : SemiNormedGrp.{u}} (f : X ⟶ Y) : explicitCokernel f ≅ cokernel f := (isColimitCokernelCocone f).coconePointUniqueUpToIso (colimit.isColimit _) @[simp] theorem explicitCokernelIso_hom_Ļ€ {X Y : SemiNormedGrp.{u}} (f : X ⟶ Y) : explicitCokernelĻ€ f ≫ (explicitCokernelIso f).hom = cokernel.Ļ€ _ := by simp [explicitCokernelĻ€, explicitCokernelIso, IsColimit.coconePointUniqueUpToIso] @[simp] theorem explicitCokernelIso_inv_Ļ€ {X Y : SemiNormedGrp.{u}} (f : X ⟶ Y) : cokernel.Ļ€ f ≫ (explicitCokernelIso f).inv = explicitCokernelĻ€ f := by simp [explicitCokernelĻ€, explicitCokernelIso] @[simp] theorem explicitCokernelIso_hom_desc {X Y Z : SemiNormedGrp.{u}} {f : X ⟶ Y} {g : Y ⟶ Z} (w : f ≫ g = 0) : (explicitCokernelIso f).hom ≫ cokernel.desc f g w = explicitCokernelDesc w := by ext1 simp [explicitCokernelDesc, explicitCokernelĻ€, explicitCokernelIso, IsColimit.coconePointUniqueUpToIso] /-- A special case of `CategoryTheory.Limits.cokernel.map` adapted to `explicitCokernel`. -/ noncomputable def explicitCokernel.map {A B C D : SemiNormedGrp.{u}} {fab : A ⟶ B} {fbd : B ⟶ D} {fac : A ⟶ C} {fcd : C ⟶ D} (h : fab ≫ fbd = fac ≫ fcd) : explicitCokernel fab ⟶ explicitCokernel fcd := @explicitCokernelDesc _ _ _ fab (fbd ≫ explicitCokernelĻ€ _) <| by simp [reassoc_of% h] /-- A special case of `CategoryTheory.Limits.cokernel.map_desc` adapted to `explicitCokernel`. -/ theorem ExplicitCoker.map_desc {A B C D B' D' : SemiNormedGrp.{u}} {fab : A ⟶ B} {fbd : B ⟶ D} {fac : A ⟶ C} {fcd : C ⟶ D} {h : fab ≫ fbd = fac ≫ fcd} {fbb' : B ⟶ B'} {fdd' : D ⟶ D'} {condb : fab ≫ fbb' = 0} {condd : fcd ≫ fdd' = 0} {g : B' ⟶ D'} (h' : fbb' ≫ g = fbd ≫ fdd') : explicitCokernelDesc condb ≫ g = explicitCokernel.map h ≫ explicitCokernelDesc condd := by delta explicitCokernel.map simp only [← Category.assoc, ← cancel_epi (explicitCokernelĻ€ fab)] simp [Category.assoc, explicitCokernelĻ€_desc, h'] end ExplicitCokernel end Cokernel end SemiNormedGrp
.lake/packages/mathlib/Mathlib/Analysis/Normed/Module/WeakDual.lean
import Mathlib.Analysis.Normed.Module.Dual import Mathlib.Analysis.Normed.Operator.Completeness import Mathlib.Topology.Algebra.Module.WeakDual /-! # Weak dual of normed space Let `E` be a normed space over a field `š•œ`. This file is concerned with properties of the weak-* topology on the dual of `E`. By the dual, we mean either of the type synonyms `StrongDual š•œ E` or `WeakDual š•œ E`, depending on whether it is viewed as equipped with its usual operator norm topology or the weak-* topology. It is shown that the canonical mapping `StrongDual š•œ E → WeakDual š•œ E` is continuous, and as a consequence the weak-* topology is coarser than the topology obtained from the operator norm (dual norm). In this file, we also establish the Banach-Alaoglu theorem about the compactness of closed balls in the dual of `E` (as well as sets of somewhat more general form) with respect to the weak-* topology. ## Main definitions The main definitions concern the canonical mapping `StrongDual š•œ E → WeakDual š•œ E`. * `StrongDual.toWeakDual` and `WeakDual.toStrongDual`: Linear equivalences from `StrongDual š•œ E` to `WeakDual š•œ E` and in the converse direction. * `NormedSpace.Dual.continuousLinearMapToWeakDual`: A continuous linear mapping from `StrongDual š•œ E` to `WeakDual š•œ E` (same as `StrongDual.toWeakDual` but different bundled data). ## Main results The first main result concerns the comparison of the operator norm topology on `StrongDual š•œ E` and the weak-* topology on (its type synonym) `WeakDual š•œ E`: * `dual_norm_topology_le_weak_dual_topology`: The weak-* topology on the dual of a normed space is coarser (not necessarily strictly) than the operator norm topology. * `WeakDual.isCompact_polar` (a version of the Banach-Alaoglu theorem): The polar set of a neighborhood of the origin in a normed space `E` over `š•œ` is compact in `WeakDual _ E`, if the nontrivially normed field `š•œ` is proper as a topological space. * `WeakDual.isCompact_closedBall` (the most common special case of the Banach-Alaoglu theorem): Closed balls in the dual of a normed space `E` over `ā„` or `ā„‚` are compact in the weak-star topology. ## TODO * Add that in finite dimensions, the weak-* topology and the dual norm topology coincide. * Add that in infinite dimensions, the weak-* topology is strictly coarser than the dual norm topology. * Add metrizability of the dual unit ball (more generally weak-star compact subsets) of `WeakDual š•œ E` under the assumption of separability of `E`. * Add the sequential Banach-Alaoglu theorem: the dual unit ball of a separable normed space `E` is sequentially compact in the weak-star topology. This would follow from the metrizability above. ## Implementation notes Weak-* topology is defined generally in the file `Topology.Algebra.Module.WeakDual`. When `M` is a vector space, the duals `StrongDual š•œ M` and `WeakDual š•œ M` are type synonyms with different topology instances. For the proof of Banach-Alaoglu theorem, the weak dual of `E` is embedded in the space of functions `E → š•œ` with the topology of pointwise convergence. The polar set `polar š•œ s` of a subset `s` of `E` is originally defined as a subset of the dual `StrongDual š•œ E`. We care about properties of these w.r.t. weak-* topology, and for this purpose give the definition `WeakDual.polar š•œ s` for the "same" subset viewed as a subset of `WeakDual š•œ E` (a type synonym of the dual but with a different topology instance). ## References * https://en.wikipedia.org/wiki/Weak_topology#Weak-*_topology * https://en.wikipedia.org/wiki/Banach%E2%80%93Alaoglu_theorem ## Tags weak-star, weak dual -/ noncomputable section open Filter Function Bornology Metric Set open Topology Filter namespace StrongDual section variable {R : Type*} [CommSemiring R] [TopologicalSpace R] [ContinuousAdd R] [ContinuousConstSMul R R] variable {M : Type*} [AddCommMonoid M] [TopologicalSpace M] [Module R M] /-- For vector spaces `M`, there is a canonical map `StrongDual R M → WeakDual R M` (the "identity" mapping). It is a linear equivalence. -/ def toWeakDual : StrongDual R M ā‰ƒā‚—[R] WeakDual R M := LinearEquiv.refl R (StrongDual R M) @[deprecated (since := "2025-08-3")] alias _root_.NormedSpace.Dual.toWeakDual := toWeakDual @[simp] theorem coe_toWeakDual (x' : StrongDual R M) : toWeakDual x' = x' := rfl @[deprecated (since := "2025-08-3")] alias _root_.NormedSpace.Dual.coe_toWeakDual := coe_toWeakDual @[simp] theorem toWeakDual_inj (x' y' : StrongDual R M) : toWeakDual x' = toWeakDual y' ↔ x' = y' := (LinearEquiv.injective toWeakDual).eq_iff @[deprecated (since := "2025-08-3")] alias _root_.NormedSpace.Dual.toWeakDual_inj := toWeakDual_inj end end StrongDual namespace WeakDual variable {š•œ : Type*} [NontriviallyNormedField š•œ] variable {E : Type*} [AddCommMonoid E] [TopologicalSpace E] [Module š•œ E] /-- For vector spaces `E`, there is a canonical map `WeakDual š•œ E → StrongDual š•œ E` (the "identity" mapping). It is a linear equivalence. Here it is implemented as the inverse of the linear equivalence `StrongDual.toWeakDual` in the other direction. -/ def toStrongDual : WeakDual š•œ E ā‰ƒā‚—[š•œ] StrongDual š•œ E := StrongDual.toWeakDual.symm @[deprecated (since := "2025-08-03")] alias toNormedDual := toStrongDual theorem toStrongDual_apply (x : WeakDual š•œ E) (y : E) : (toStrongDual x) y = x y := rfl @[deprecated (since := "2025-08-03")] alias toNormedDual_apply := toStrongDual_apply @[simp] theorem coe_toStrongDual (x' : WeakDual š•œ E) : toStrongDual x' = x' := rfl @[deprecated (since := "2025-08-03")] alias coe_toNormedDual := coe_toStrongDual @[simp] theorem toStrongDual_inj (x' y' : WeakDual š•œ E) : toStrongDual x' = toStrongDual y' ↔ x' = y' := (LinearEquiv.injective toStrongDual).eq_iff @[deprecated (since := "2025-08-03")] alias toNormedDual_inj := toStrongDual_inj variable (š•œ) /-- The polar set `polar š•œ s` of `s : Set E` seen as a subset of the dual of `E` with the weak-star topology is `WeakDual.polar š•œ s`. -/ def polar (s : Set E) : Set (WeakDual š•œ E) := toStrongDual ⁻¹' (StrongDual.polar š•œ) s theorem polar_def (s : Set E) : polar š•œ s = { f : WeakDual š•œ E | āˆ€ x ∈ s, ‖f x‖ ≤ 1 } := rfl /-- The polar `polar š•œ s` of a set `s : E` is a closed subset when the weak star topology is used. -/ theorem isClosed_polar (s : Set E) : IsClosed (polar š•œ s) := by simp only [polar_def, setOf_forall] exact isClosed_biInter fun x hx => isClosed_Iic.preimage (WeakBilin.eval_continuous _ _).norm end WeakDual /-! ### Weak star topology on duals of normed spaces In this section, we prove properties about the weak-* topology on duals of normed spaces. We prove in particular that the canonical mapping `StrongDual š•œ E → WeakDual š•œ E` is continuous, i.e., that the weak-* topology is coarser (not necessarily strictly) than the topology given by the dual-norm (i.e. the operator-norm). -/ variable {š•œ : Type*} [NontriviallyNormedField š•œ] variable {E : Type*} [SeminormedAddCommGroup E] [NormedSpace š•œ E] namespace NormedSpace namespace Dual theorem toWeakDual_continuous : Continuous fun x' : StrongDual š•œ E => StrongDual.toWeakDual x' := WeakBilin.continuous_of_continuous_eval _ fun z => (inclusionInDoubleDual š•œ E z).continuous /-- For a normed space `E`, according to `toWeakDual_continuous` the "identity mapping" `StrongDual š•œ E → WeakDual š•œ E` is continuous. This definition implements it as a continuous linear map. -/ def continuousLinearMapToWeakDual : StrongDual š•œ E →L[š•œ] WeakDual š•œ E := { StrongDual.toWeakDual with cont := toWeakDual_continuous } /-- The weak-star topology is coarser than the dual-norm topology. -/ theorem dual_norm_topology_le_weak_dual_topology : (UniformSpace.toTopologicalSpace : TopologicalSpace (StrongDual š•œ E)) ≤ (instTopologicalSpaceWeakDual .. : TopologicalSpace (WeakDual š•œ E)) := by convert (@toWeakDual_continuous _ _ _ _ (by assumption)).le_induced exact induced_id.symm end Dual end NormedSpace namespace WeakDual open NormedSpace theorem isClosed_closedBall (x' : StrongDual š•œ E) (r : ā„) : IsClosed (toStrongDual ⁻¹' closedBall x' r) := isClosed_induced_iff'.2 (ContinuousLinearMap.is_weak_closed_closedBall x' r) /-! ### Polar sets in the weak dual space -/ /-- While the coercion `↑ : WeakDual š•œ E → (E → š•œ)` is not a closed map, it sends *bounded* closed sets to closed sets. -/ theorem isClosed_image_coe_of_bounded_of_closed {s : Set (WeakDual š•œ E)} (hb : IsBounded (StrongDual.toWeakDual ⁻¹' s)) (hc : IsClosed s) : IsClosed (((↑) : WeakDual š•œ E → E → š•œ) '' s) := ContinuousLinearMap.isClosed_image_coe_of_bounded_of_weak_closed hb (isClosed_induced_iff'.1 hc) theorem isCompact_of_bounded_of_closed [ProperSpace š•œ] {s : Set (WeakDual š•œ E)} (hb : IsBounded (StrongDual.toWeakDual ⁻¹' s)) (hc : IsClosed s) : IsCompact s := DFunLike.coe_injective.isEmbedding_induced.isCompact_iff.mpr <| ContinuousLinearMap.isCompact_image_coe_of_bounded_of_closed_image hb <| isClosed_image_coe_of_bounded_of_closed hb hc variable (š•œ) /-- The image under `↑ : WeakDual š•œ E → (E → š•œ)` of a polar `WeakDual.polar š•œ s` of a neighborhood `s` of the origin is a closed set. -/ theorem isClosed_image_polar_of_mem_nhds {s : Set E} (s_nhds : s ∈ š“ (0 : E)) : IsClosed (((↑) : WeakDual š•œ E → E → š•œ) '' polar š•œ s) := isClosed_image_coe_of_bounded_of_closed (isBounded_polar_of_mem_nhds_zero š•œ s_nhds) (isClosed_polar _ _) /-- The image under `↑ : StrongDual š•œ E → (E → š•œ)` of a polar `polar š•œ s` of a neighborhood `s` of the origin is a closed set. -/ theorem _root_.NormedSpace.Dual.isClosed_image_polar_of_mem_nhds {s : Set E} (s_nhds : s ∈ š“ (0 : E)) : IsClosed (((↑) : StrongDual š•œ E → E → š•œ) '' StrongDual.polar š•œ s) := WeakDual.isClosed_image_polar_of_mem_nhds š•œ s_nhds /-- The **Banach-Alaoglu theorem**: the polar set of a neighborhood `s` of the origin in a normed space `E` is a compact subset of `WeakDual š•œ E`. -/ theorem isCompact_polar [ProperSpace š•œ] {s : Set E} (s_nhds : s ∈ š“ (0 : E)) : IsCompact (polar š•œ s) := isCompact_of_bounded_of_closed (isBounded_polar_of_mem_nhds_zero š•œ s_nhds) (isClosed_polar _ _) /-- The **Banach-Alaoglu theorem**: closed balls of the dual of a normed space `E` are compact in the weak-star topology. -/ theorem isCompact_closedBall [ProperSpace š•œ] (x' : StrongDual š•œ E) (r : ā„) : IsCompact (toStrongDual ⁻¹' closedBall x' r) := isCompact_of_bounded_of_closed isBounded_closedBall (isClosed_closedBall x' r) end WeakDual
.lake/packages/mathlib/Mathlib/Analysis/Normed/Module/HahnBanach.lean
import Mathlib.Analysis.Convex.Cone.Extension import Mathlib.Analysis.Normed.Module.RCLike.Extend import Mathlib.Analysis.RCLike.Lemmas /-! # Extension Hahn-Banach theorem In this file we prove the analytic Hahn-Banach theorem. For any continuous linear function on a subspace, we can extend it to a function on the entire space without changing its norm. We prove * `Real.exists_extension_norm_eq`: Hahn-Banach theorem for continuous linear functions on normed spaces over `ā„`. * `exists_extension_norm_eq`: Hahn-Banach theorem for continuous linear functions on normed spaces over `ā„` or `ā„‚`. In order to state and prove the corollaries uniformly, we prove the statements for a field `š•œ` satisfying `RCLike š•œ`. In this setting, `exists_dual_vector` states that, for any nonzero `x`, there exists a continuous linear form `g` of norm `1` with `g x = ‖x‖` (where the norm has to be interpreted as an element of `š•œ`). -/ universe u v namespace Real variable {E : Type*} [SeminormedAddCommGroup E] [NormedSpace ā„ E] /-- **Hahn-Banach theorem** for continuous linear functions over `ā„`. See also `exists_extension_norm_eq` in the root namespace for a more general version that works both for `ā„` and `ā„‚`. -/ theorem exists_extension_norm_eq (p : Subspace ā„ E) (f : StrongDual ā„ p) : ∃ g : StrongDual ā„ E, (āˆ€ x : p, g x = f x) ∧ ‖g‖ = ‖f‖ := by rcases exists_extension_of_le_sublinear ⟨p, f⟩ (fun x => ‖f‖ * ‖x‖) (fun c hc x => by simp only [norm_smul c x, Real.norm_eq_abs, abs_of_pos hc, mul_left_comm]) (fun x y => by rw [← left_distrib] exact mul_le_mul_of_nonneg_left (norm_add_le x y) (@norm_nonneg _ _ f)) fun x => le_trans (le_abs_self _) (f.le_opNorm _) with ⟨g, g_eq, g_le⟩ set g' := g.mkContinuous ‖f‖ fun x => abs_le.2 ⟨neg_le.1 <| g.map_neg x ā–ø norm_neg x ā–ø g_le (-x), g_le x⟩ refine ⟨g', g_eq, ?_⟩ apply le_antisymm (g.mkContinuous_norm_le (norm_nonneg f) _) refine f.opNorm_le_bound (norm_nonneg _) fun x => ?_ dsimp at g_eq rw [← g_eq] apply g'.le_opNorm end Real section RCLike open RCLike variable {š•œ : Type*} [NontriviallyNormedField š•œ] [IsRCLikeNormedField š•œ] {E F : Type*} [SeminormedAddCommGroup E] [NormedSpace š•œ E] [NormedAddCommGroup F] [NormedSpace š•œ F] /-- **Hahn-Banach theorem** for continuous linear functions over `š•œ` satisfying `IsRCLikeNormedField š•œ`. -/ theorem exists_extension_norm_eq (p : Subspace š•œ E) (f : StrongDual š•œ p) : ∃ g : StrongDual š•œ E, (āˆ€ x : p, g x = f x) ∧ ‖g‖ = ‖f‖ := by letI : RCLike š•œ := IsRCLikeNormedField.rclike š•œ letI : Module ā„ E := RestrictScalars.module ā„ š•œ E letI : IsScalarTower ā„ š•œ E := RestrictScalars.isScalarTower _ _ _ letI : NormedSpace ā„ E := NormedSpace.restrictScalars _ š•œ _ -- Let `fr: StrongDual ā„ p` be the real part of `f`. let fr := reCLM.comp (f.restrictScalars ā„) -- Use the real version to get a norm-preserving extension of `fr`, which -- we'll call `g : StrongDual ā„ E`. rcases Real.exists_extension_norm_eq (p.restrictScalars ā„) fr with ⟨g, ⟨hextends, hnormeq⟩⟩ -- Now `g` can be extended to the `StrongDual š•œ E` we need. refine ⟨g.extendToš•œ, ?_⟩ -- It is an extension of `f`. have h : āˆ€ x : p, g.extendToš•œ x = f x := by intro x rw [ContinuousLinearMap.extendToš•œ_apply, ← Submodule.coe_smul] -- This used to be `rw`, but we need `erw` after https://github.com/leanprover/lean4/pull/2644 -- The goal has a coercion from `RestrictScalars ā„ š•œ StrongDual ā„ E`, but -- `hextends` involves a coercion from `StrongDual ā„ E`. erw [hextends] erw [hextends] have : (fr x : š•œ) - I * ↑(fr ((I : š•œ) • x)) = (re (f x) : š•œ) - (I : š•œ) * re (f ((I : š•œ) • x)) := by rfl -- This used to be `rw`, but we need `erw` after https://github.com/leanprover/lean4/pull/2644 erw [this] apply ext Ā· simp only [add_zero, Algebra.id.smul_eq_mul, I_re, ofReal_im, AddMonoidHom.map_add, zero_sub, I_im', zero_mul, ofReal_re, sub_zero, mul_neg, ofReal_neg, mul_re, mul_zero, sub_neg_eq_add, ContinuousLinearMap.map_smul] Ā· simp only [Algebra.id.smul_eq_mul, I_re, ofReal_im, AddMonoidHom.map_add, zero_sub, I_im', zero_mul, ofReal_re, mul_neg, mul_im, zero_add, ofReal_neg, mul_re, sub_neg_eq_add, ContinuousLinearMap.map_smul] -- And we derive the equality of the norms by bounding on both sides. refine ⟨h, le_antisymm ?_ ?_⟩ Ā· calc ‖g.extendToš•œā€– = ‖g‖ := g.norm_extendToš•œ _ = ‖fr‖ := hnormeq _ ≤ ‖reCLM‖ * ‖f‖ := ContinuousLinearMap.opNorm_comp_le _ _ _ = ‖f‖ := by rw [reCLM_norm, one_mul] Ā· exact f.opNorm_le_bound g.extendToš•œ.opNorm_nonneg fun x => h x ā–ø g.extendToš•œ.le_opNorm x open Module /-- Corollary of the **Hahn-Banach theorem**: if `f : p → F` is a continuous linear map from a submodule of a normed space `E` over `š•œ`, `š•œ = ā„` or `š•œ = ā„‚`, with a finite-dimensional range, then `f` admits an extension to a continuous linear map `E → F`. Note that contrary to the case `F = š•œ`, see `exists_extension_norm_eq`, we provide no estimates on the norm of the extension. -/ lemma ContinuousLinearMap.exist_extension_of_finiteDimensional_range {p : Submodule š•œ E} (f : p →L[š•œ] F) [FiniteDimensional š•œ (LinearMap.range f)] : ∃ g : E →L[š•œ] F, f = g.comp p.subtypeL := by letI : RCLike š•œ := IsRCLikeNormedField.rclike š•œ set b := Module.finBasis š•œ (LinearMap.range f) set e := b.equivFunL set fi := fun i ↦ (LinearMap.toContinuousLinearMap (b.coord i)).comp (f.codRestrict _ <| LinearMap.mem_range_self _) choose gi hgf _ using fun i ↦ exists_extension_norm_eq p (fi i) use (LinearMap.range f).subtypeL.comp <| e.symm.toContinuousLinearMap.comp (.pi gi) ext x simp [fi, e, hgf] /-- A finite-dimensional submodule over `ā„` or `ā„‚` is `Submodule.ClosedComplemented`. -/ lemma Submodule.ClosedComplemented.of_finiteDimensional (p : Submodule š•œ F) [FiniteDimensional š•œ p] : p.ClosedComplemented := let ⟨g, hg⟩ := (ContinuousLinearMap.id š•œ p).exist_extension_of_finiteDimensional_range ⟨g, DFunLike.congr_fun hg.symm⟩ end RCLike section DualVector variable (š•œ : Type v) [RCLike š•œ] variable {E : Type u} [NormedAddCommGroup E] [NormedSpace š•œ E] open ContinuousLinearEquiv Submodule theorem coord_norm' {x : E} (h : x ≠ 0) : ‖(‖x‖ : š•œ) • coord š•œ x h‖ = 1 := by simp [-algebraMap_smul, norm_smul, mul_inv_cancelā‚€ (mt norm_eq_zero.mp h)] /-- Corollary of Hahn-Banach. Given a nonzero element `x` of a normed space, there exists an element of the dual space, of norm `1`, whose value on `x` is `‖x‖`. -/ theorem exists_dual_vector (x : E) (h : x ≠ 0) : ∃ g : StrongDual š•œ E, ‖g‖ = 1 ∧ g x = ‖x‖ := by let p : Submodule š•œ E := š•œ āˆ™ x let f := (‖x‖ : š•œ) • coord š•œ x h obtain ⟨g, hg⟩ := exists_extension_norm_eq p f refine ⟨g, ?_, ?_⟩ Ā· rw [hg.2, coord_norm'] Ā· calc g x = g (⟨x, mem_span_singleton_self x⟩ : š•œ āˆ™ x) := by rw [Submodule.coe_mk] _ = ((‖x‖ : š•œ) • coord š•œ x h) (⟨x, mem_span_singleton_self x⟩ : š•œ āˆ™ x) := by rw [← hg.1] _ = ‖x‖ := by simp [-algebraMap_smul] /-- Variant of Hahn-Banach, eliminating the hypothesis that `x` be nonzero, and choosing the dual element arbitrarily when `x = 0`. -/ theorem exists_dual_vector' [Nontrivial E] (x : E) : ∃ g : StrongDual š•œ E, ‖g‖ = 1 ∧ g x = ‖x‖ := by by_cases hx : x = 0 Ā· obtain ⟨y, hy⟩ := exists_ne (0 : E) obtain ⟨g, hg⟩ : ∃ g : StrongDual š•œ E, ‖g‖ = 1 ∧ g y = ‖y‖ := exists_dual_vector š•œ y hy refine ⟨g, hg.left, ?_⟩ simp [hx] Ā· exact exists_dual_vector š•œ x hx /-- Variant of Hahn-Banach, eliminating the hypothesis that `x` be nonzero, but only ensuring that the dual element has norm at most `1` (this cannot be improved for the trivial vector space). -/ theorem exists_dual_vector'' (x : E) : ∃ g : StrongDual š•œ E, ‖g‖ ≤ 1 ∧ g x = ‖x‖ := by by_cases hx : x = 0 Ā· refine ⟨0, by simp, ?_⟩ symm simp [hx] Ā· rcases exists_dual_vector š•œ x hx with ⟨g, g_norm, g_eq⟩ exact ⟨g, g_norm.le, g_eq⟩ end DualVector
.lake/packages/mathlib/Mathlib/Analysis/Normed/Module/Convex.lean
import Mathlib.Analysis.Convex.Jensen import Mathlib.Analysis.Convex.PathConnected import Mathlib.Analysis.Convex.Topology import Mathlib.Analysis.Normed.Group.Pointwise import Mathlib.Analysis.Normed.Module.Basic import Mathlib.Analysis.Normed.Module.RCLike.Real /-! # Metric properties of convex sets in normed spaces We prove the following facts: * `convexOn_norm`, `convexOn_dist` : norm and distance to a fixed point is convex on any convex set; * `convexOn_univ_norm`, `convexOn_univ_dist` : norm and distance to a fixed point is convex on the whole space; * `convexHull_ediam`, `convexHull_diam` : convex hull of a set has the same (e)metric diameter as the original set; * `isBounded_convexHull` : convex hull of a set is bounded if and only if the original set is bounded. -/ -- TODO assert_not_exists Cardinal variable {E : Type*} open Metric Set section SeminormedAddCommGroup variable [SeminormedAddCommGroup E] [NormedSpace ā„ E] variable {s : Set E} /-- The norm on a real normed space is convex on any convex set. See also `Seminorm.convexOn` and `convexOn_univ_norm`. -/ theorem convexOn_norm (hs : Convex ā„ s) : ConvexOn ā„ s norm := ⟨hs, fun x _ y _ a b ha hb _ => calc ‖a • x + b • y‖ ≤ ‖a • x‖ + ‖b • y‖ := norm_add_le _ _ _ = a * ‖x‖ + b * ‖y‖ := by rw [norm_smul, norm_smul, Real.norm_of_nonneg ha, Real.norm_of_nonneg hb]⟩ /-- The norm on a real normed space is convex on the whole space. See also `Seminorm.convexOn` and `convexOn_norm`. -/ theorem convexOn_univ_norm : ConvexOn ā„ univ (norm : E → ā„) := convexOn_norm convex_univ theorem convexOn_dist (z : E) (hs : Convex ā„ s) : ConvexOn ā„ s fun z' => dist z' z := by simpa [dist_eq_norm, preimage_preimage] using (convexOn_norm (hs.translate (-z))).comp_affineMap (AffineMap.id ā„ E - AffineMap.const ā„ E z) theorem convexOn_univ_dist (z : E) : ConvexOn ā„ univ fun z' => dist z' z := convexOn_dist z convex_univ theorem convex_ball (a : E) (r : ā„) : Convex ā„ (Metric.ball a r) := by simpa only [Metric.ball, sep_univ] using (convexOn_univ_dist a).convex_lt r theorem convex_closedBall (a : E) (r : ā„) : Convex ā„ (Metric.closedBall a r) := by simpa only [Metric.closedBall, sep_univ] using (convexOn_univ_dist a).convex_le r variable {F : Type*} [NormedAddCommGroup F] [NormedSpace ā„ F] open Pointwise in theorem convexHull_sphere_eq_closedBall [Nontrivial F] (x : F) {r : ā„} (hr : 0 ≤ r) : convexHull ā„ (sphere x r) = closedBall x r := by suffices convexHull ā„ (sphere (0 : F) r) = closedBall 0 r by rw [← add_zero x, ← vadd_eq_add, ← vadd_sphere, convexHull_vadd, this, vadd_closedBall_zero, vadd_eq_add, add_zero] refine subset_antisymm (convexHull_min sphere_subset_closedBall (convex_closedBall 0 r)) (fun x h ↦ mem_convexHull_iff.mpr fun U hU_sub hU ↦ ?_) have zero_mem : (0 : F) ∈ U := by have _ : Invertible (2 : ā„) := by use 2⁻¹ <;> grind obtain ⟨z, hz⟩ := NormedSpace.sphere_nonempty (E := F).mpr hr rw [← midpoint_self_neg (R := ā„) (x := z)] exact Convex.midpoint_mem hU (hU_sub hz) <| hU_sub (by simp_all) by_cases hrā‚€ : r = 0 Ā· simp_all by_cases x_zero : x = 0 Ā· rwa [x_zero] set z := (r * ‖x‖⁻¹) • x with hz_def have hr₁ : r⁻¹ * ‖x‖ ≤ 1 := by simp only [mem_closedBall, dist_zero_right] at h grw [h, inv_mul_le_one] have hz : z ∈ U := by apply hU_sub simp_all [norm_smul] have := StarConvex.smul_mem (hU.starConvex zero_mem) hz (by positivity) hr₁ rwa [hz_def, ← smul_assoc, smul_eq_mul, ← mul_assoc, mul_comm, mul_comm r⁻¹, mul_assoc _ r⁻¹, inv_mul_cancelā‚€ hrā‚€, mul_one, inv_mul_cancelā‚€ (by simp_all), one_smul] at this /-- Given a point `x` in the convex hull of `s` and a point `y`, there exists a point of `s` at distance at least `dist x y` from `y`. -/ theorem convexHull_exists_dist_ge {s : Set E} {x : E} (hx : x ∈ convexHull ā„ s) (y : E) : ∃ x' ∈ s, dist x y ≤ dist x' y := (convexOn_dist y (convex_convexHull ā„ _)).exists_ge_of_mem_convexHull (subset_convexHull ..) hx theorem Convex.thickening (hs : Convex ā„ s) (Ī“ : ā„) : Convex ā„ (thickening Ī“ s) := by rw [← add_ball_zero] exact hs.add (convex_ball 0 _) theorem Convex.cthickening (hs : Convex ā„ s) (Ī“ : ā„) : Convex ā„ (cthickening Ī“ s) := by obtain hĪ“ | hĪ“ := le_total 0 Ī“ Ā· rw [cthickening_eq_iInter_thickening hĪ“] exact convex_iInterā‚‚ fun _ _ => hs.thickening _ Ā· rw [cthickening_of_nonpos hĪ“] exact hs.closure /-- Given a point `x` in the convex hull of `s` and a point `y` in the convex hull of `t`, there exist points `x' ∈ s` and `y' ∈ t` at distance at least `dist x y`. -/ theorem convexHull_exists_dist_ge2 {s t : Set E} {x y : E} (hx : x ∈ convexHull ā„ s) (hy : y ∈ convexHull ā„ t) : ∃ x' ∈ s, ∃ y' ∈ t, dist x y ≤ dist x' y' := by rcases convexHull_exists_dist_ge hx y with ⟨x', hx', Hx'⟩ rcases convexHull_exists_dist_ge hy x' with ⟨y', hy', Hy'⟩ use x', hx', y', hy' exact le_trans Hx' (dist_comm y x' ā–ø dist_comm y' x' ā–ø Hy') /-- Emetric diameter of the convex hull of a set `s` equals the emetric diameter of `s`. -/ @[simp] theorem convexHull_ediam (s : Set E) : EMetric.diam (convexHull ā„ s) = EMetric.diam s := by refine (EMetric.diam_le fun x hx y hy => ?_).antisymm (EMetric.diam_mono <| subset_convexHull ā„ s) rcases convexHull_exists_dist_ge2 hx hy with ⟨x', hx', y', hy', H⟩ rw [edist_dist] apply le_trans (ENNReal.ofReal_le_ofReal H) rw [← edist_dist] exact EMetric.edist_le_diam_of_mem hx' hy' /-- Diameter of the convex hull of a set `s` equals the emetric diameter of `s`. -/ @[simp] theorem convexHull_diam (s : Set E) : Metric.diam (convexHull ā„ s) = Metric.diam s := by simp only [Metric.diam, convexHull_ediam] /-- Convex hull of `s` is bounded if and only if `s` is bounded. -/ @[simp] theorem isBounded_convexHull {s : Set E} : Bornology.IsBounded (convexHull ā„ s) ↔ Bornology.IsBounded s := by simp only [Metric.isBounded_iff_ediam_ne_top, convexHull_ediam] instance (priority := 100) NormedSpace.instPathConnectedSpace : PathConnectedSpace E := IsTopologicalAddGroup.pathConnectedSpace /-- The set of vectors in the same ray as `x` is connected. -/ theorem isConnected_setOf_sameRay (x : E) : IsConnected { y | SameRay ā„ x y } := by by_cases hx : x = 0; Ā· simpa [hx] using isConnected_univ (α := E) simp_rw [← exists_nonneg_left_iff_sameRay hx] exact isConnected_Ici.image _ (continuous_id.smul continuous_const).continuousOn /-- The set of nonzero vectors in the same ray as the nonzero vector `x` is connected. -/ theorem isConnected_setOf_sameRay_and_ne_zero {x : E} (hx : x ≠ 0) : IsConnected { y | SameRay ā„ x y ∧ y ≠ 0 } := by simp_rw [← exists_pos_left_iff_sameRay_and_ne_zero hx] exact isConnected_Ioi.image _ (continuous_id.smul continuous_const).continuousOn lemma norm_sub_le_of_mem_segment {x y z : E} (hy : y ∈ segment ā„ x z) : ‖y - x‖ ≤ ‖z - x‖ := by rw [segment_eq_image'] at hy simp only [mem_image, mem_Icc] at hy obtain ⟨u, ⟨hu_nonneg, hu_le_one⟩, rfl⟩ := hy simp only [add_sub_cancel_left, norm_smul, Real.norm_eq_abs] rw [abs_of_nonneg hu_nonneg] conv_rhs => rw [← one_mul (‖z - x‖)] gcongr namespace Filter open scoped Convex Topology variable {α : Type*} {f : Filter α} {x : E} {y z : α → E} {r : α → E → Prop} theorem Eventually.segment_of_prod_nhds (hy : Tendsto y f (š“ x)) (hz : Tendsto z f (š“ x)) (hr : āˆ€į¶  p in f Ć—Ė¢ š“ x, r p.1 p.2) : āˆ€į¶  χ in f, āˆ€ v ∈ [y χ -[ā„] z χ], r χ v := by obtain ⟨p, hp, Ī“, hĪ“, hr⟩ := eventually_prod_nhds_iff.mp hr rw [Metric.tendsto_nhds] at hy hz filter_upwards [hp, hy Ī“ hĪ“, hz Ī“ hĪ“] with χ hp hy hz exact fun v hv => hr hp <| convex_iff_segment_subset.mp (convex_ball x Ī“) hy hz hv theorem Eventually.segment_of_prod_nhdsWithin (hy : Tendsto y f (š“ x)) (hz : Tendsto z f (š“ x)) (hr : āˆ€į¶  p in f Ć—Ė¢ š“[s] x, r p.1 p.2) (seg : āˆ€į¶  χ in f, [y χ -[ā„] z χ] āŠ† s) : āˆ€į¶  χ in f, āˆ€ v ∈ [y χ -[ā„] z χ], r χ v := by refine seg.mp <| .mono ?_ (fun _ => forallā‚‚_imp) apply Eventually.segment_of_prod_nhds hy hz simpa [nhdsWithin, prod_eq_inf, ← inf_assoc, eventually_inf_principal] using hr end Filter end SeminormedAddCommGroup
.lake/packages/mathlib/Mathlib/Analysis/Normed/Module/Ray.lean
import Mathlib.LinearAlgebra.Ray import Mathlib.Analysis.Normed.Module.RCLike.Real import Mathlib.Algebra.Ring.Regular /-! # Rays in a real normed vector space In this file we prove some lemmas about the `SameRay` predicate in case of a real normed space. In this case, for two vectors `x y` in the same ray, the norm of their sum is equal to the sum of their norms and `‖y‖ • x = ‖x‖ • y`. -/ open Real variable {E : Type*} [SeminormedAddCommGroup E] [NormedSpace ā„ E] {F : Type*} [NormedAddCommGroup F] [NormedSpace ā„ F] namespace SameRay variable {x y : E} /-- If `x` and `y` are on the same ray, then the triangle inequality becomes the equality: the norm of `x + y` is the sum of the norms of `x` and `y`. The converse is true for a strictly convex space. -/ theorem norm_add (h : SameRay ā„ x y) : ‖x + y‖ = ‖x‖ + ‖y‖ := by rcases h.exists_eq_smul with ⟨u, a, b, ha, hb, -, rfl, rfl⟩ rw [← add_smul, norm_smul_of_nonneg (add_nonneg ha hb), norm_smul_of_nonneg ha, norm_smul_of_nonneg hb, add_mul] theorem norm_sub (h : SameRay ā„ x y) : ‖x - y‖ = |‖x‖ - ‖y‖| := by rcases h.exists_eq_smul with ⟨u, a, b, ha, hb, -, rfl, rfl⟩ wlog hab : b ≤ a generalizing a b with H Ā· rw [SameRay.sameRay_comm] at h rw [norm_sub_rev, abs_sub_comm] exact H b a hb ha h (le_of_not_ge hab) rw [← sub_nonneg] at hab rw [← sub_smul, norm_smul_of_nonneg hab, norm_smul_of_nonneg ha, norm_smul_of_nonneg hb, ← sub_mul, abs_of_nonneg (mul_nonneg hab (norm_nonneg _))] theorem norm_smul_eq (h : SameRay ā„ x y) : ‖x‖ • y = ‖y‖ • x := by rcases h.exists_eq_smul with ⟨u, a, b, ha, hb, -, rfl, rfl⟩ simp only [norm_smul_of_nonneg, *, mul_smul] rw [smul_comm, smul_comm b, smul_comm a b u] end SameRay variable {x y : F} theorem norm_injOn_ray_left (hx : x ≠ 0) : { y | SameRay ā„ x y }.InjOn norm := by rintro y hy z hz h rcases hy.exists_nonneg_left hx with ⟨r, hr, rfl⟩ rcases hz.exists_nonneg_left hx with ⟨s, hs, rfl⟩ rw [norm_smul, norm_smul, mul_left_inj' (norm_ne_zero_iff.2 hx), norm_of_nonneg hr, norm_of_nonneg hs] at h rw [h] theorem norm_injOn_ray_right (hy : y ≠ 0) : { x | SameRay ā„ x y }.InjOn norm := by simpa only [SameRay.sameRay_comm] using norm_injOn_ray_left hy theorem sameRay_iff_norm_smul_eq : SameRay ā„ x y ↔ ‖x‖ • y = ‖y‖ • x := ⟨SameRay.norm_smul_eq, fun h => or_iff_not_imp_left.2 fun hx => or_iff_not_imp_left.2 fun hy => āŸØā€–y‖, ‖x‖, norm_pos_iff.2 hy, norm_pos_iff.2 hx, h.symm⟩⟩ /-- Two nonzero vectors `x y` in a real normed space are on the same ray if and only if the unit vectors `‖x‖⁻¹ • x` and `‖y‖⁻¹ • y` are equal. -/ theorem sameRay_iff_inv_norm_smul_eq_of_ne (hx : x ≠ 0) (hy : y ≠ 0) : SameRay ā„ x y ↔ ‖x‖⁻¹ • x = ‖y‖⁻¹ • y := by rw [inv_smul_eq_iffā‚€, smul_comm, eq_comm, inv_smul_eq_iffā‚€, sameRay_iff_norm_smul_eq] <;> rwa [norm_ne_zero_iff] alias ⟨SameRay.inv_norm_smul_eq, _⟩ := sameRay_iff_inv_norm_smul_eq_of_ne /-- Two vectors `x y` in a real normed space are on the ray if and only if one of them is zero or the unit vectors `‖x‖⁻¹ • x` and `‖y‖⁻¹ • y` are equal. -/ theorem sameRay_iff_inv_norm_smul_eq : SameRay ā„ x y ↔ x = 0 ∨ y = 0 ∨ ‖x‖⁻¹ • x = ‖y‖⁻¹ • y := by rcases eq_or_ne x 0 with (rfl | hx); Ā· simp [SameRay.zero_left] rcases eq_or_ne y 0 with (rfl | hy); Ā· simp [SameRay.zero_right] simp only [sameRay_iff_inv_norm_smul_eq_of_ne hx hy, *, false_or] /-- Two vectors of the same norm are on the same ray if and only if they are equal. -/ theorem sameRay_iff_of_norm_eq (h : ‖x‖ = ‖y‖) : SameRay ā„ x y ↔ x = y := by obtain rfl | hy := eq_or_ne y 0 Ā· rw [norm_zero, norm_eq_zero] at h exact iff_of_true (SameRay.zero_right _) h Ā· exact ⟨fun hxy => norm_injOn_ray_right hy hxy SameRay.rfl h, fun hxy => hxy ā–ø SameRay.rfl⟩ theorem not_sameRay_iff_of_norm_eq (h : ‖x‖ = ‖y‖) : ¬SameRay ā„ x y ↔ x ≠ y := (sameRay_iff_of_norm_eq h).not /-- If two points on the same ray have the same norm, then they are equal. -/ theorem SameRay.eq_of_norm_eq (h : SameRay ā„ x y) (hn : ‖x‖ = ‖y‖) : x = y := (sameRay_iff_of_norm_eq hn).mp h /-- The norms of two vectors on the same ray are equal if and only if they are equal. -/ theorem SameRay.norm_eq_iff (h : SameRay ā„ x y) : ‖x‖ = ‖y‖ ↔ x = y := ⟨h.eq_of_norm_eq, fun h => h ā–ø rfl⟩
.lake/packages/mathlib/Mathlib/Analysis/Normed/Module/Completion.lean
import Mathlib.Analysis.Normed.Group.Completion import Mathlib.Analysis.Normed.Operator.NormedSpace import Mathlib.Topology.Algebra.UniformRing import Mathlib.Topology.Algebra.UniformField /-! # Normed space structure on the completion of a normed space If `E` is a normed space over `š•œ`, then so is `UniformSpace.Completion E`. In this file we provide necessary instances and define `UniformSpace.Completion.toComplā‚—įµ¢` - coercion `E → UniformSpace.Completion E` as a bundled linear isometry. We also show that if `A` is a normed algebra over `š•œ`, then so is `UniformSpace.Completion A`. TODO: Generalise the results here from the concrete `completion` to any `AbstractCompletion`. -/ noncomputable section namespace UniformSpace namespace Completion variable (š•œ E : Type*) instance [NormedField š•œ] [SeminormedAddCommGroup E] [NormedSpace š•œ E] : NormedSpace š•œ (Completion E) where norm_smul_le := norm_smul_le section Module variable {š•œ E} variable [Semiring š•œ] [SeminormedAddCommGroup E] [Module š•œ E] [UniformContinuousConstSMul š•œ E] /-- Embedding of a normed space to its completion as a linear isometry. -/ def toComplā‚—įµ¢ : E →ₗᵢ[š•œ] Completion E := { toCompl with toFun := (↑) map_smul' := coe_smul norm_map' := norm_coe } @[simp] theorem coe_toComplā‚—įµ¢ : ⇑(toComplā‚—įµ¢ : E →ₗᵢ[š•œ] Completion E) = ((↑) : E → Completion E) := rfl /-- Embedding of a normed space to its completion as a continuous linear map. -/ def toComplL : E →L[š•œ] Completion E := toComplā‚—įµ¢.toContinuousLinearMap @[simp] theorem coe_toComplL : ⇑(toComplL : E →L[š•œ] Completion E) = ((↑) : E → Completion E) := rfl @[simp] theorem norm_toComplL {š•œ E : Type*} [NontriviallyNormedField š•œ] [NormedAddCommGroup E] [NormedSpace š•œ E] [Nontrivial E] : ‖(toComplL : E →L[š•œ] Completion E)‖ = 1 := (toComplā‚—įµ¢ : E →ₗᵢ[š•œ] Completion E).norm_toContinuousLinearMap end Module section Algebra variable (A : Type*) instance [SeminormedRing A] : NormedRing (Completion A) where __ : NormedAddCommGroup (Completion A) := inferInstance __ : Ring (Completion A) := inferInstance norm_mul_le x y := by induction x, y using induction_onā‚‚ with | hp => apply isClosed_le <;> fun_prop | ih x y => simpa only [← coe_mul, norm_coe] using norm_mul_le x y instance [SeminormedCommRing A] : NormedCommRing (Completion A) where __ : CommRing (Completion A) := inferInstance __ : NormedRing (Completion A) := inferInstance instance [NormedField š•œ] [SeminormedCommRing A] [NormedAlgebra š•œ A] : NormedAlgebra š•œ (Completion A) where norm_smul_le := norm_smul_le instance [NormedField A] [CompletableTopField A] : NormedField (UniformSpace.Completion A) where __ : NormedCommRing (Completion A) := inferInstance __ : Field (Completion A) := inferInstance norm_mul x y := induction_onā‚‚ x y (isClosed_eq (by fun_prop) (by fun_prop)) (by simp [← coe_mul]) end Algebra end Completion end UniformSpace
.lake/packages/mathlib/Mathlib/Analysis/Normed/Module/Complemented.lean
import Mathlib.Analysis.Normed.Operator.Banach import Mathlib.Topology.Algebra.Module.FiniteDimension /-! # Complemented subspaces of normed vector spaces A submodule `p` of a topological module `E` over `R` is called *complemented* if there exists a continuous linear projection `f : E →ₗ[R] p`, `āˆ€ x : p, f x = x`. We prove that for a closed subspace of a normed space this condition is equivalent to existence of a closed subspace `q` such that `p āŠ“ q = ⊄`, `p āŠ” q = ⊤`. We also prove that a subspace of finite codimension is always a complemented subspace. ## Tags complemented subspace, normed vector space -/ variable {š•œ E F G : Type*} [NontriviallyNormedField š•œ] [NormedAddCommGroup E] [NormedSpace š•œ E] [NormedAddCommGroup F] [NormedSpace š•œ F] [NormedAddCommGroup G] [NormedSpace š•œ G] noncomputable section open LinearMap (ker range) namespace ContinuousLinearMap section variable [CompleteSpace š•œ] theorem ker_closedComplemented_of_finiteDimensional_range (f : E →L[š•œ] F) [FiniteDimensional š•œ (range f)] : (ker f).ClosedComplemented := by set f' : E →L[š•œ] range f := f.codRestrict _ (LinearMap.mem_range_self (f : E →ₗ[š•œ] F)) rcases f'.exists_right_inverse_of_surjective (f : E →ₗ[š•œ] F).range_rangeRestrict with ⟨g, hg⟩ simpa only [f', ker_codRestrict] using f'.closedComplemented_ker_of_rightInverse g (ContinuousLinearMap.ext_iff.1 hg) end variable [CompleteSpace E] [CompleteSpace (F Ɨ G)] /-- If `f : E →L[R] F` and `g : E →L[R] G` are two surjective linear maps and their kernels are complement of each other, then `x ↦ (f x, g x)` defines a linear equivalence `E ā‰ƒL[R] F Ɨ G`. -/ nonrec def equivProdOfSurjectiveOfIsCompl (f : E →L[š•œ] F) (g : E →L[š•œ] G) (hf : range f = ⊤) (hg : range g = ⊤) (hfg : IsCompl (ker f) (ker g)) : E ā‰ƒL[š•œ] F Ɨ G := (f.equivProdOfSurjectiveOfIsCompl (g : E →ₗ[š•œ] G) hf hg hfg).toContinuousLinearEquivOfContinuous (f.continuous.prodMk g.continuous) @[simp] theorem coe_equivProdOfSurjectiveOfIsCompl {f : E →L[š•œ] F} {g : E →L[š•œ] G} (hf : range f = ⊤) (hg : range g = ⊤) (hfg : IsCompl (ker f) (ker g)) : (equivProdOfSurjectiveOfIsCompl f g hf hg hfg : E →ₗ[š•œ] F Ɨ G) = f.prod g := rfl @[simp] theorem equivProdOfSurjectiveOfIsCompl_toLinearEquiv {f : E →L[š•œ] F} {g : E →L[š•œ] G} (hf : range f = ⊤) (hg : range g = ⊤) (hfg : IsCompl (ker f) (ker g)) : (equivProdOfSurjectiveOfIsCompl f g hf hg hfg).toLinearEquiv = LinearMap.equivProdOfSurjectiveOfIsCompl f g hf hg hfg := rfl @[simp] theorem equivProdOfSurjectiveOfIsCompl_apply {f : E →L[š•œ] F} {g : E →L[š•œ] G} (hf : range f = ⊤) (hg : range g = ⊤) (hfg : IsCompl (ker f) (ker g)) (x : E) : equivProdOfSurjectiveOfIsCompl f g hf hg hfg x = (f x, g x) := rfl end ContinuousLinearMap namespace Submodule variable [CompleteSpace E] (p q : Subspace š•œ E) /-- If `q` is a closed complement of a closed subspace `p`, then `p Ɨ q` is continuously isomorphic to `E`. -/ def prodEquivOfClosedCompl (h : IsCompl p q) (hp : IsClosed (p : Set E)) (hq : IsClosed (q : Set E)) : (p Ɨ q) ā‰ƒL[š•œ] E := by haveI := hp.completeSpace_coe; haveI := hq.completeSpace_coe refine (p.prodEquivOfIsCompl q h).toContinuousLinearEquivOfContinuous ?_ exact (p.subtypeL.coprod q.subtypeL).continuous /-- Projection to a closed submodule along a closed complement. -/ def linearProjOfClosedCompl (h : IsCompl p q) (hp : IsClosed (p : Set E)) (hq : IsClosed (q : Set E)) : E →L[š•œ] p := ContinuousLinearMap.fst š•œ p q ∘L ↑(prodEquivOfClosedCompl p q h hp hq).symm variable {p q} @[simp] theorem coe_prodEquivOfClosedCompl (h : IsCompl p q) (hp : IsClosed (p : Set E)) (hq : IsClosed (q : Set E)) : ⇑(p.prodEquivOfClosedCompl q h hp hq) = p.prodEquivOfIsCompl q h := rfl @[simp] theorem coe_prodEquivOfClosedCompl_symm (h : IsCompl p q) (hp : IsClosed (p : Set E)) (hq : IsClosed (q : Set E)) : ⇑(p.prodEquivOfClosedCompl q h hp hq).symm = (p.prodEquivOfIsCompl q h).symm := rfl @[simp] theorem coe_continuous_linearProjOfClosedCompl (h : IsCompl p q) (hp : IsClosed (p : Set E)) (hq : IsClosed (q : Set E)) : (p.linearProjOfClosedCompl q h hp hq : E →ₗ[š•œ] p) = p.linearProjOfIsCompl q h := rfl @[simp] theorem coe_continuous_linearProjOfClosedCompl' (h : IsCompl p q) (hp : IsClosed (p : Set E)) (hq : IsClosed (q : Set E)) : ⇑(p.linearProjOfClosedCompl q h hp hq) = p.linearProjOfIsCompl q h := rfl theorem ClosedComplemented.of_isCompl_isClosed (h : IsCompl p q) (hp : IsClosed (p : Set E)) (hq : IsClosed (q : Set E)) : p.ClosedComplemented := ⟨p.linearProjOfClosedCompl q h hp hq, Submodule.linearProjOfIsCompl_apply_left h⟩ alias IsCompl.closedComplemented_of_isClosed := ClosedComplemented.of_isCompl_isClosed theorem closedComplemented_iff_isClosed_exists_isClosed_isCompl : p.ClosedComplemented ↔ IsClosed (p : Set E) ∧ ∃ q : Submodule š•œ E, IsClosed (q : Set E) ∧ IsCompl p q := ⟨fun h => ⟨h.isClosed, h.exists_isClosed_isCompl⟩, fun ⟨hp, ⟨_, hq, hpq⟩⟩ => .of_isCompl_isClosed hpq hp hq⟩ theorem ClosedComplemented.of_quotient_finiteDimensional [CompleteSpace š•œ] [FiniteDimensional š•œ (E ā§ø p)] (hp : IsClosed (p : Set E)) : p.ClosedComplemented := by obtain ⟨q, hq⟩ : ∃ q, IsCompl p q := p.exists_isCompl haveI : FiniteDimensional š•œ q := (p.quotientEquivOfIsCompl q hq).finiteDimensional exact .of_isCompl_isClosed hq hp q.closed_of_finiteDimensional end Submodule
.lake/packages/mathlib/Mathlib/Analysis/Normed/Module/Basic.lean
import Mathlib.Algebra.Algebra.Pi import Mathlib.Algebra.Algebra.Prod import Mathlib.Algebra.Algebra.Rat import Mathlib.Algebra.Algebra.RestrictScalars import Mathlib.Algebra.Module.Rat import Mathlib.Analysis.Normed.Field.Lemmas import Mathlib.Analysis.Normed.MulAction /-! # Normed spaces In this file we define (semi)normed spaces and algebras. We also prove some theorems about these definitions. -/ variable {š•œ š•œ' E F α : Type*} open Filter Metric Function Set Topology Bornology open scoped NNReal ENNReal uniformity section SeminormedAddCommGroup -- Here, we set a rather high priority for the instance `[NormedSpace š•œ E] : Module š•œ E` -- to take precedence over `Semiring.toModule` as this leads to instance paths with better -- unification properties. /-- A normed space over a normed field is a vector space endowed with a norm which satisfies the equality `‖c • x‖ = ‖c‖ ‖x‖`. We require only `‖c • x‖ ≤ ‖c‖ ‖x‖` in the definition, then prove `‖c • x‖ = ‖c‖ ‖x‖` in `norm_smul`. Note that since this requires `SeminormedAddCommGroup` and not `NormedAddCommGroup`, this typeclass can be used for "seminormed spaces" too, just as `Module` can be used for "semimodules". -/ @[ext] class NormedSpace (š•œ : Type*) (E : Type*) [NormedField š•œ] [SeminormedAddCommGroup E] extends Module š•œ E where protected norm_smul_le : āˆ€ (a : š•œ) (b : E), ‖a • b‖ ≤ ‖a‖ * ‖b‖ attribute [inherit_doc NormedSpace] NormedSpace.norm_smul_le variable [NormedField š•œ] [SeminormedAddCommGroup E] [SeminormedAddCommGroup F] variable [NormedSpace š•œ E] [NormedSpace š•œ F] -- see Note [lower instance priority] instance (priority := 100) NormedSpace.toNormSMulClass [NormedSpace š•œ E] : NormSMulClass š•œ E := haveI : IsBoundedSMul š•œ E := .of_norm_smul_le NormedSpace.norm_smul_le NormedDivisionRing.toNormSMulClass /-- This is a shortcut instance, which was found to help with performance in https://leanprover.zulipchat.com/#narrow/channel/287929-mathlib4/topic/Normed.20modules/near/516757412. It is implied via `NormedSpace.toNormSMulClass`. -/ instance NormedSpace.toIsBoundedSMul [NormedSpace š•œ E] : IsBoundedSMul š•œ E := inferInstance instance NormedField.toNormedSpace : NormedSpace š•œ š•œ where norm_smul_le a b := norm_mul_le a b variable (š•œ) in theorem norm_zsmul (n : ℤ) (x : E) : ‖n • x‖ = ‖(n : š•œ)‖ * ‖x‖ := by rw [← norm_smul, ← Int.smul_one_eq_cast, smul_assoc, one_smul] theorem norm_intCast_eq_abs_mul_norm_one (α) [SeminormedRing α] [NormSMulClass ℤ α] (n : ℤ) : ‖(n : α)‖ = |n| * ‖(1 : α)‖ := by rw [← zsmul_one, norm_smul, Int.norm_eq_abs, Int.cast_abs] theorem norm_natCast_eq_mul_norm_one (α) [SeminormedRing α] [NormSMulClass ℤ α] (n : ā„•) : ‖(n : α)‖ = n * ‖(1 : α)‖ := by simpa using norm_intCast_eq_abs_mul_norm_one α n @[simp] lemma norm_natCast {α : Type*} [SeminormedRing α] [NormOneClass α] [NormSMulClass ℤ α] (a : ā„•) : ‖(a : α)‖ = a := by simpa using norm_natCast_eq_mul_norm_one α a theorem eventually_nhds_norm_smul_sub_lt (c : š•œ) (x : E) {ε : ā„} (h : 0 < ε) : āˆ€į¶  y in š“ x, ‖c • (y - x)‖ < ε := have : Tendsto (fun y ↦ ‖c • (y - x)‖) (š“ x) (š“ 0) := Continuous.tendsto' (by fun_prop) _ _ (by simp) this.eventually (gt_mem_nhds h) theorem Filter.Tendsto.zero_smul_isBoundedUnder_le {f : α → š•œ} {g : α → E} {l : Filter α} (hf : Tendsto f l (š“ 0)) (hg : IsBoundedUnder (Ā· ≤ Ā·) l (Norm.norm ∘ g)) : Tendsto (fun x => f x • g x) l (š“ 0) := hf.op_zero_isBoundedUnder_le hg (Ā· • Ā·) norm_smul_le theorem Filter.IsBoundedUnder.smul_tendsto_zero {f : α → š•œ} {g : α → E} {l : Filter α} (hf : IsBoundedUnder (Ā· ≤ Ā·) l (norm ∘ f)) (hg : Tendsto g l (š“ 0)) : Tendsto (fun x => f x • g x) l (š“ 0) := hg.op_zero_isBoundedUnder_le hf (flip (Ā· • Ā·)) fun x y => (norm_smul_le y x).trans_eq (mul_comm _ _) instance NormedSpace.discreteTopology_zmultiples {E : Type*} [NormedAddCommGroup E] [NormedSpace ā„š E] (e : E) : DiscreteTopology <| AddSubgroup.zmultiples e := by have : IsAddTorsionFree E := .of_module_rat E rcases eq_or_ne e 0 with (rfl | he) Ā· rw [AddSubgroup.zmultiples_zero_eq_bot] exact Subsingleton.discreteTopology (α := ↑(⊄ : Subspace ā„š E)) Ā· rw [discreteTopology_iff_isOpen_singleton_zero, isOpen_induced_iff] refine ⟨Metric.ball 0 ‖e‖, Metric.isOpen_ball, ?_⟩ ext ⟨x, hx⟩ obtain ⟨k, rfl⟩ := AddSubgroup.mem_zmultiples_iff.mp hx rw [mem_preimage, mem_ball_zero_iff, AddSubgroup.coe_mk, mem_singleton_iff, Subtype.ext_iff, AddSubgroup.coe_mk, AddSubgroup.coe_zero, norm_zsmul ā„š k e, Int.norm_cast_rat, Int.norm_eq_abs, mul_lt_iff_lt_one_left (norm_pos_iff.mpr he), ← @Int.cast_one ā„ _, ← Int.cast_abs, Int.cast_lt, Int.abs_lt_one_iff, smul_eq_zero, or_iff_left he] open NormedField instance ULift.normedSpace : NormedSpace š•œ (ULift E) := { __ := ULift.seminormedAddCommGroup (E := E), __ := ULift.module' norm_smul_le := fun s x => (norm_smul_le s x.down :) } /-- The product of two normed spaces is a normed space, with the sup norm. -/ instance Prod.normedSpace : NormedSpace š•œ (E Ɨ F) := { Prod.seminormedAddCommGroup (E := E) (F := F), Prod.instModule with norm_smul_le := fun s x => by simp only [norm_smul, Prod.norm_def, mul_max_of_nonneg, norm_nonneg, le_rfl] } /-- The product of finitely many normed spaces is a normed space, with the sup norm. -/ instance Pi.normedSpace {ι : Type*} {E : ι → Type*} [Fintype ι] [āˆ€ i, SeminormedAddCommGroup (E i)] [āˆ€ i, NormedSpace š•œ (E i)] : NormedSpace š•œ (āˆ€ i, E i) where norm_smul_le a f := by simp_rw [← coe_nnnorm, ← NNReal.coe_mul, NNReal.coe_le_coe, Pi.nnnorm_def, NNReal.mul_finset_sup] exact Finset.sup_mono_fun fun _ _ => norm_smul_le a _ instance SeparationQuotient.instNormedSpace : NormedSpace š•œ (SeparationQuotient E) where norm_smul_le := norm_smul_le instance MulOpposite.instNormedSpace : NormedSpace š•œ Eᵐᵒᵖ where norm_smul_le _ x := norm_smul_le _ x.unop /-- A subspace of a normed space is also a normed space, with the restriction of the norm. -/ instance Submodule.normedSpace {š•œ R : Type*} [SMul š•œ R] [NormedField š•œ] [Ring R] {E : Type*} [SeminormedAddCommGroup E] [NormedSpace š•œ E] [Module R E] [IsScalarTower š•œ R E] (s : Submodule R E) : NormedSpace š•œ s where norm_smul_le c x := norm_smul_le c (x : E) variable {S š•œ R E : Type*} [SMul š•œ R] [NormedField š•œ] [Ring R] [SeminormedAddCommGroup E] variable [NormedSpace š•œ E] [Module R E] [IsScalarTower š•œ R E] [SetLike S E] [AddSubgroupClass S E] variable [SMulMemClass S R E] (s : S) instance (priority := 75) SubmoduleClass.toNormedSpace : NormedSpace š•œ s where norm_smul_le c x := norm_smul_le c (x : E) end SeminormedAddCommGroup /-- A linear map from a `Module` to a `NormedSpace` induces a `NormedSpace` structure on the domain, using the `SeminormedAddCommGroup.induced` norm. See note [reducible non-instances] -/ abbrev NormedSpace.induced {F : Type*} (š•œ E G : Type*) [NormedField š•œ] [AddCommGroup E] [Module š•œ E] [SeminormedAddCommGroup G] [NormedSpace š•œ G] [FunLike F E G] [LinearMapClass F š•œ E G] (f : F) : @NormedSpace š•œ E _ (SeminormedAddCommGroup.induced E G f) := let _ := SeminormedAddCommGroup.induced E G f ⟨fun a b ↦ by simpa only [← map_smul f a b] using norm_smul_le a (f b)⟩ section NontriviallyNormedSpace variable (š•œ E) variable [NontriviallyNormedField š•œ] [NormedAddCommGroup E] [NormedSpace š•œ E] [Nontrivial E] include š•œ /-- If `E` is a nontrivial normed space over a nontrivially normed field `š•œ`, then `E` is unbounded: for any `c : ā„`, there exists a vector `x : E` with norm strictly greater than `c`. -/ theorem NormedSpace.exists_lt_norm (c : ā„) : ∃ x : E, c < ‖x‖ := by rcases exists_ne (0 : E) with ⟨x, hx⟩ rcases NormedField.exists_lt_norm š•œ (c / ‖x‖) with ⟨r, hr⟩ use r • x rwa [norm_smul, ← div_lt_iffā‚€] rwa [norm_pos_iff] protected theorem NormedSpace.unbounded_univ : ¬Bornology.IsBounded (univ : Set E) := fun h => let ⟨R, hR⟩ := isBounded_iff_forall_norm_le.1 h let ⟨x, hx⟩ := NormedSpace.exists_lt_norm š•œ E R hx.not_ge (hR x trivial) protected lemma NormedSpace.cobounded_neBot : NeBot (cobounded E) := by rw [neBot_iff, Ne, cobounded_eq_bot_iff, ← isBounded_univ] exact NormedSpace.unbounded_univ š•œ E instance (priority := 100) NontriviallyNormedField.cobounded_neBot : NeBot (cobounded š•œ) := NormedSpace.cobounded_neBot š•œ š•œ instance (priority := 80) RealNormedSpace.cobounded_neBot [NormedSpace ā„ E] : NeBot (cobounded E) := NormedSpace.cobounded_neBot ā„ E instance (priority := 80) NontriviallyNormedField.infinite : Infinite š•œ := ⟨fun _ ↦ NormedSpace.unbounded_univ š•œ š•œ (Set.toFinite _).isBounded⟩ end NontriviallyNormedSpace section NormedSpace variable (š•œ E) variable [NormedField š•œ] [Infinite š•œ] [NormedAddCommGroup E] [Nontrivial E] [NormedSpace š•œ E] include š•œ /-- A normed vector space over an infinite normed field is a noncompact space. This cannot be an instance because in order to apply it, Lean would have to search for `NormedSpace š•œ E` with unknown `š•œ`. We register this as an instance in two cases: `š•œ = E` and `š•œ = ā„`. -/ protected theorem NormedSpace.noncompactSpace : NoncompactSpace E := by by_cases! H : ∃ c : š•œ, c ≠ 0 ∧ ‖c‖ ≠ 1 Ā· letI := NontriviallyNormedField.ofNormNeOne H exact ⟨fun h ↦ NormedSpace.unbounded_univ š•œ E h.isBounded⟩ Ā· rcases exists_ne (0 : E) with ⟨x, hx⟩ suffices IsClosedEmbedding (Infinite.natEmbedding š•œ Ā· • x) from this.noncompactSpace refine isClosedEmbedding_of_pairwise_le_dist (norm_pos_iff.2 hx) fun k n hne ↦ ?_ simp only [dist_eq_norm, ← sub_smul, norm_smul] rw [H, one_mul] rwa [sub_ne_zero, (Embedding.injective _).ne_iff] instance (priority := 100) NormedField.noncompactSpace : NoncompactSpace š•œ := NormedSpace.noncompactSpace š•œ š•œ instance (priority := 100) RealNormedSpace.noncompactSpace [NormedSpace ā„ E] : NoncompactSpace E := NormedSpace.noncompactSpace ā„ E end NormedSpace section NormedAlgebra /-- A normed algebra `š•œ'` over `š•œ` is normed module that is also an algebra. See the implementation notes for `Algebra` for a discussion about non-unital algebras. Following the strategy there, a non-unital *normed* algebra can be written as: ```lean variable [NormedField š•œ] [NonUnitalSeminormedRing š•œ'] variable [NormedSpace š•œ š•œ'] [SMulCommClass š•œ š•œ' š•œ'] [IsScalarTower š•œ š•œ' š•œ'] ``` -/ class NormedAlgebra (š•œ : Type*) (š•œ' : Type*) [NormedField š•œ] [SeminormedRing š•œ'] extends Algebra š•œ š•œ' where norm_smul_le : āˆ€ (r : š•œ) (x : š•œ'), ‖r • x‖ ≤ ‖r‖ * ‖x‖ attribute [inherit_doc NormedAlgebra] NormedAlgebra.norm_smul_le variable (š•œ') variable [NormedField š•œ] [SeminormedRing š•œ'] [NormedAlgebra š•œ š•œ'] instance (priority := 100) NormedAlgebra.toNormedSpace : NormedSpace š•œ š•œ' := { NormedAlgebra.toAlgebra.toModule with norm_smul_le := NormedAlgebra.norm_smul_le } theorem norm_algebraMap (x : š•œ) : ‖algebraMap š•œ š•œ' x‖ = ‖x‖ * ‖(1 : š•œ')‖ := by rw [Algebra.algebraMap_eq_smul_one] exact norm_smul _ _ theorem nnnorm_algebraMap (x : š•œ) : ‖algebraMap š•œ š•œ' xā€–ā‚Š = ‖xā€–ā‚Š * ‖(1 : š•œ')ā€–ā‚Š := Subtype.ext <| norm_algebraMap š•œ' x theorem dist_algebraMap (x y : š•œ) : (dist (algebraMap š•œ š•œ' x) (algebraMap š•œ š•œ' y)) = dist x y * ‖(1 : š•œ')‖ := by simp only [dist_eq_norm, ← map_sub, norm_algebraMap] /-- This is a simpler version of `norm_algebraMap` when `‖1‖ = 1` in `š•œ'`. -/ @[simp] theorem norm_algebraMap' [NormOneClass š•œ'] (x : š•œ) : ‖algebraMap š•œ š•œ' x‖ = ‖x‖ := by rw [norm_algebraMap, norm_one, mul_one] @[simp] theorem Algebra.norm_smul_one_eq_norm [NormOneClass š•œ'] (x : š•œ) : ‖x • (1 : š•œ')‖ = ‖x‖ := by simp [norm_smul] /-- This is a simpler version of `nnnorm_algebraMap` when `‖1‖ = 1` in `š•œ'`. -/ @[simp] theorem nnnorm_algebraMap' [NormOneClass š•œ'] (x : š•œ) : ‖algebraMap š•œ š•œ' xā€–ā‚Š = ‖xā€–ā‚Š := Subtype.ext <| norm_algebraMap' _ _ /-- This is a simpler version of `dist_algebraMap` when `‖1‖ = 1` in `š•œ'`. -/ @[simp] theorem dist_algebraMap' [NormOneClass š•œ'] (x y : š•œ) : (dist (algebraMap š•œ š•œ' x) (algebraMap š•œ š•œ' y)) = dist x y := by simp only [dist_eq_norm, ← map_sub, norm_algebraMap'] section NNReal variable [NormOneClass š•œ'] [NormedAlgebra ā„ š•œ'] @[simp] theorem norm_algebraMap_nnreal (x : ā„ā‰„0) : ‖algebraMap ā„ā‰„0 š•œ' x‖ = x := (norm_algebraMap' š•œ' (x : ā„)).symm ā–ø Real.norm_of_nonneg x.prop @[simp] theorem nnnorm_algebraMap_nnreal (x : ā„ā‰„0) : ‖algebraMap ā„ā‰„0 š•œ' xā€–ā‚Š = x := Subtype.ext <| norm_algebraMap_nnreal š•œ' x end NNReal variable (š•œ) open Filter Bornology in /-- Preimages of cobounded sets under the algebra map are cobounded. -/ @[simp] theorem tendsto_algebraMap_cobounded (š•œ š•œ' : Type*) [NormedField š•œ] [SeminormedRing š•œ'] [NormedAlgebra š•œ š•œ'] [NormOneClass š•œ'] : Tendsto (algebraMap š•œ š•œ') (cobounded š•œ) (cobounded š•œ') := by intro c hc rw [mem_map] rw [← isCobounded_def, ← isBounded_compl_iff, isBounded_iff_forall_norm_le] at hc ⊢ obtain ⟨s, hs⟩ := hc exact ⟨s, fun x hx ↦ by simpa using hs (algebraMap š•œ š•œ' x) hx⟩ @[deprecated (since := "2025-11-04")] alias algebraMap_cobounded_le_cobounded := tendsto_algebraMap_cobounded /-- In a normed algebra, the inclusion of the base field in the extended field is an isometry. -/ theorem algebraMap_isometry [NormOneClass š•œ'] : Isometry (algebraMap š•œ š•œ') := by refine Isometry.of_dist_eq fun x y => ?_ rw [dist_eq_norm, dist_eq_norm, ← RingHom.map_sub, norm_algebraMap'] instance NormedAlgebra.id : NormedAlgebra š•œ š•œ := { NormedField.toNormedSpace, Algebra.id š•œ with } /-- Any normed characteristic-zero division ring that is a normed algebra over the reals is also a normed algebra over the rationals. Phrased another way, if `š•œ` is a normed algebra over the reals, then `AlgebraRat` respects that norm. -/ instance normedAlgebraRat {š•œ} [NormedDivisionRing š•œ] [CharZero š•œ] [NormedAlgebra ā„ š•œ] : NormedAlgebra ā„š š•œ where norm_smul_le q x := by rw [← smul_one_smul ā„ q x, Rat.smul_one_eq_cast, norm_smul, Rat.norm_cast_real] instance PUnit.normedAlgebra : NormedAlgebra š•œ PUnit where norm_smul_le q _ := by simp only [norm_eq_zero, mul_zero, le_refl] instance : NormedAlgebra š•œ (ULift š•œ') := { ULift.normedSpace, ULift.algebra with } /-- The product of two normed algebras is a normed algebra, with the sup norm. -/ instance Prod.normedAlgebra {E F : Type*} [SeminormedRing E] [SeminormedRing F] [NormedAlgebra š•œ E] [NormedAlgebra š•œ F] : NormedAlgebra š•œ (E Ɨ F) := { Prod.normedSpace, Prod.algebra š•œ E F with } /-- The product of finitely many normed algebras is a normed algebra, with the sup norm. -/ instance Pi.normedAlgebra {ι : Type*} {E : ι → Type*} [Fintype ι] [āˆ€ i, SeminormedRing (E i)] [āˆ€ i, NormedAlgebra š•œ (E i)] : NormedAlgebra š•œ (āˆ€ i, E i) := { Pi.normedSpace, Pi.algebra _ E with } variable [SeminormedRing E] [NormedAlgebra š•œ E] instance SeparationQuotient.instNormedAlgebra : NormedAlgebra š•œ (SeparationQuotient E) where __ : NormedSpace š•œ (SeparationQuotient E) := inferInstance __ : Algebra š•œ (SeparationQuotient E) := inferInstance instance MulOpposite.instNormedAlgebra {E : Type*} [SeminormedRing E] [NormedAlgebra š•œ E] : NormedAlgebra š•œ Eᵐᵒᵖ where __ := instAlgebra __ := instNormedSpace end NormedAlgebra /-- A non-unital algebra homomorphism from an `Algebra` to a `NormedAlgebra` induces a `NormedAlgebra` structure on the domain, using the `SeminormedRing.induced` norm. See note [reducible non-instances] -/ abbrev NormedAlgebra.induced {F : Type*} (š•œ R S : Type*) [NormedField š•œ] [Ring R] [Algebra š•œ R] [SeminormedRing S] [NormedAlgebra š•œ S] [FunLike F R S] [NonUnitalAlgHomClass F š•œ R S] (f : F) : @NormedAlgebra š•œ R _ (SeminormedRing.induced R S f) := letI := SeminormedRing.induced R S f ⟨fun a b ↦ show ‖f (a • b)‖ ≤ ‖a‖ * ‖f b‖ from (map_smul f a b).symm ā–ø norm_smul_le a (f b)⟩ instance Subalgebra.toNormedAlgebra {š•œ A : Type*} [SeminormedRing A] [NormedField š•œ] [NormedAlgebra š•œ A] (S : Subalgebra š•œ A) : NormedAlgebra š•œ S := NormedAlgebra.induced š•œ S A S.val section SubalgebraClass variable {S š•œ E : Type*} [NormedField š•œ] [SeminormedRing E] [NormedAlgebra š•œ E] variable [SetLike S E] [SubringClass S E] [SMulMemClass S š•œ E] (s : S) instance (priority := 75) SubalgebraClass.toNormedAlgebra : NormedAlgebra š•œ s where norm_smul_le c x := norm_smul_le c (x : E) end SubalgebraClass section RestrictScalars section NormInstances instance [I : SeminormedAddCommGroup E] : SeminormedAddCommGroup (RestrictScalars š•œ š•œ' E) := I instance [I : NormedAddCommGroup E] : NormedAddCommGroup (RestrictScalars š•œ š•œ' E) := I instance [I : NonUnitalSeminormedRing E] : NonUnitalSeminormedRing (RestrictScalars š•œ š•œ' E) := I instance [I : NonUnitalNormedRing E] : NonUnitalNormedRing (RestrictScalars š•œ š•œ' E) := I instance [I : SeminormedRing E] : SeminormedRing (RestrictScalars š•œ š•œ' E) := I instance [I : NormedRing E] : NormedRing (RestrictScalars š•œ š•œ' E) := I instance [I : NonUnitalSeminormedCommRing E] : NonUnitalSeminormedCommRing (RestrictScalars š•œ š•œ' E) := I instance [I : NonUnitalNormedCommRing E] : NonUnitalNormedCommRing (RestrictScalars š•œ š•œ' E) := I instance [I : SeminormedCommRing E] : SeminormedCommRing (RestrictScalars š•œ š•œ' E) := I instance [I : NormedCommRing E] : NormedCommRing (RestrictScalars š•œ š•œ' E) := I end NormInstances section NormedSpace variable (š•œ š•œ' E) variable [NormedField š•œ] [NormedField š•œ'] [NormedAlgebra š•œ š•œ'] [SeminormedAddCommGroup E] [NormedSpace š•œ' E] /-- If `E` is a normed space over `š•œ'` and `š•œ` is a normed algebra over `š•œ'`, then `RestrictScalars.module` is additionally a `NormedSpace`. -/ instance RestrictScalars.normedSpace : NormedSpace š•œ (RestrictScalars š•œ š•œ' E) := { RestrictScalars.module š•œ š•œ' E with norm_smul_le := fun c x => (norm_smul_le (algebraMap š•œ š•œ' c) (_ : E)).trans_eq <| by rw [norm_algebraMap'] } -- If you think you need this, consider instead reproducing `RestrictScalars.lsmul` -- appropriately modified here. /-- The action of the original normed_field on `RestrictScalars š•œ š•œ' E`. This is not an instance as it would be contrary to the purpose of `RestrictScalars`. -/ def Module.RestrictScalars.normedSpaceOrig {š•œ : Type*} {š•œ' : Type*} {E : Type*} [NormedField š•œ'] [SeminormedAddCommGroup E] [I : NormedSpace š•œ' E] : NormedSpace š•œ' (RestrictScalars š•œ š•œ' E) := I /-- Warning: This declaration should be used judiciously. Please consider using `IsScalarTower` and/or `RestrictScalars š•œ š•œ' E` instead. This definition allows the `RestrictScalars.normedSpace` instance to be put directly on `E` rather on `RestrictScalars š•œ š•œ' E`. This would be a very bad instance; both because `š•œ'` cannot be inferred, and because it is likely to create instance diamonds. See Note [reducible non-instances]. -/ abbrev NormedSpace.restrictScalars : NormedSpace š•œ E := RestrictScalars.normedSpace _ š•œ' E theorem NormedSpace.restrictScalars_eq {E : Type*} [SeminormedAddCommGroup E] [h : NormedSpace š•œ E] [NormedSpace š•œ' E] [IsScalarTower š•œ š•œ' E] : NormedSpace.restrictScalars š•œ š•œ' E = h := by ext apply algebraMap_smul end NormedSpace section NormedAlgebra variable (š•œ š•œ' E) variable [NormedField š•œ] [NormedField š•œ'] [NormedAlgebra š•œ š•œ'] [SeminormedRing E] [NormedAlgebra š•œ' E] /-- If `E` is a normed algebra over `š•œ'` and `š•œ` is a normed algebra over `š•œ'`, then `RestrictScalars.module` is additionally a `NormedAlgebra`. -/ instance RestrictScalars.normedAlgebra : NormedAlgebra š•œ (RestrictScalars š•œ š•œ' E) := { RestrictScalars.algebra š•œ š•œ' E with norm_smul_le := norm_smul_le } -- If you think you need this, consider instead reproducing `RestrictScalars.lsmul` -- appropriately modified here. /-- The action of the original normed_field on `RestrictScalars š•œ š•œ' E`. This is not an instance as it would be contrary to the purpose of `RestrictScalars`. -/ def Module.RestrictScalars.normedAlgebraOrig {š•œ : Type*} {š•œ' : Type*} {E : Type*} [NormedField š•œ'] [SeminormedRing E] [I : NormedAlgebra š•œ' E] : NormedAlgebra š•œ' (RestrictScalars š•œ š•œ' E) := I /-- Warning: This declaration should be used judiciously. Please consider using `IsScalarTower` and/or `RestrictScalars š•œ š•œ' E` instead. This definition allows the `RestrictScalars.normedAlgebra` instance to be put directly on `E` rather on `RestrictScalars š•œ š•œ' E`. This would be a very bad instance; both because `š•œ'` cannot be inferred, and because it is likely to create instance diamonds. See Note [reducible non-instances]. -/ abbrev NormedAlgebra.restrictScalars : NormedAlgebra š•œ E := RestrictScalars.normedAlgebra _ š•œ' _ end NormedAlgebra end RestrictScalars section Core /-! ### Structures for constructing new normed spaces This section contains tools meant for constructing new normed spaces. These allow one to easily construct all the relevant instances (distances measures, etc) while proving only a minimal set of axioms. Furthermore, tools are provided to add a norm structure to a type that already has a preexisting uniformity or bornology: in such cases, it is necessary to keep the preexisting instances, while ensuring that the norm induces the same uniformity/bornology. -/ open scoped Uniformity Bornology /-- A structure encapsulating minimal axioms needed to defined a seminormed vector space, as found in textbooks. This is meant to be used to easily define `SeminormedSpace E` instances from scratch on a type with no preexisting distance or topology. -/ structure SeminormedSpace.Core (š•œ : Type*) (E : Type*) [NormedField š•œ] [AddCommGroup E] [Norm E] [Module š•œ E] : Prop where norm_nonneg (x : E) : 0 ≤ ‖x‖ norm_smul (c : š•œ) (x : E) : ‖c • x‖ = ‖c‖ * ‖x‖ norm_triangle (x y : E) : ‖x + y‖ ≤ ‖x‖ + ‖y‖ @[deprecated (since := "2025-06-03")] alias SeminormedAddCommGroup.Core := SeminormedSpace.Core /-- Produces a `PseudoMetricSpace E` instance from a `SeminormedSpace.Core`. Note that if this is used to define an instance on a type, it also provides a new uniformity and topology on the type. See note [reducible non-instances]. -/ abbrev PseudoMetricSpace.ofSeminormedSpaceCore {š•œ E : Type*} [NormedField š•œ] [AddCommGroup E] [Norm E] [Module š•œ E] (core : SeminormedSpace.Core š•œ E) : PseudoMetricSpace E where dist x y := ‖x - y‖ dist_self x := by show ‖x - x‖ = 0 simp only [sub_self] have : (0 : E) = (0 : š•œ) • (0 : E) := by simp rw [this, core.norm_smul] simp dist_comm x y := by show ‖x - y‖ = ‖y - x‖ have : y - x = (-1 : š•œ) • (x - y) := by simp rw [this, core.norm_smul] simp dist_triangle x y z := by show ‖x - z‖ ≤ ‖x - y‖ + ‖y - z‖ have : x - z = (x - y) + (y - z) := by abel rw [this] exact core.norm_triangle _ _ edist_dist x y := by exact (ENNReal.ofReal_eq_coe_nnreal _).symm @[deprecated (since := "2025-06-03")] alias PseudoMetricSpace.ofSeminormedAddCommGroupCore := PseudoMetricSpace.ofSeminormedSpaceCore /-- Produces a `PseudoEMetricSpace E` instance from a `SeminormedSpace.Core`. Note that if this is used to define an instance on a type, it also provides a new uniformity and topology on the type. See note [reducible non-instances]. -/ abbrev PseudoEMetricSpace.ofSeminormedSpaceCore {š•œ E : Type*} [NormedField š•œ] [AddCommGroup E] [Norm E] [Module š•œ E] (core : SeminormedSpace.Core š•œ E) : PseudoEMetricSpace E := (PseudoMetricSpace.ofSeminormedSpaceCore core).toPseudoEMetricSpace @[deprecated (since := "2025-06-03")] alias PseudoEMetricSpace.ofSeminormedAddCommGroupCore := PseudoEMetricSpace.ofSeminormedSpaceCore /-- Produces a `PseudoEMetricSpace E` instance from a `SeminormedSpace.Core` on a type that already has an existing uniform space structure. This requires a proof that the uniformity induced by the norm is equal to the preexisting uniformity. See note [reducible non-instances]. -/ abbrev PseudoMetricSpace.ofSeminormedSpaceCoreReplaceUniformity {š•œ E : Type*} [NormedField š•œ] [AddCommGroup E] [Norm E] [Module š•œ E] [U : UniformSpace E] (core : SeminormedSpace.Core š•œ E) (H : š“¤[U] = š“¤[PseudoEMetricSpace.toUniformSpace (self := PseudoEMetricSpace.ofSeminormedSpaceCore core)]) : PseudoMetricSpace E := .replaceUniformity (.ofSeminormedSpaceCore core) H @[deprecated (since := "2025-06-03")] alias PseudoMetricSpace.ofSeminormedAddCommGroupCoreReplaceUniformity := PseudoMetricSpace.ofSeminormedSpaceCoreReplaceUniformity /-- Produces a `PseudoEMetricSpace E` instance from a `SeminormedSpace.Core` on a type that already has an existing topology. This requires a proof that the topology induced by the norm is equal to the preexisting topology. See note [reducible non-instances]. -/ abbrev PseudoMetricSpace.ofSeminormedSpaceCoreReplaceTopology {š•œ E : Type*} [NormedField š•œ] [AddCommGroup E] [Norm E] [Module š•œ E] [T : TopologicalSpace E] (core : SeminormedSpace.Core š•œ E) (H : T = (PseudoEMetricSpace.ofSeminormedSpaceCore core).toUniformSpace.toTopologicalSpace) : PseudoMetricSpace E := .replaceTopology (.ofSeminormedSpaceCore core) H open Bornology in /-- Produces a `PseudoEMetricSpace E` instance from a `SeminormedSpace.Core` on a type that already has a preexisting uniform space structure and a preexisting bornology. This requires proofs that the uniformity induced by the norm is equal to the preexisting uniformity, and likewise for the bornology. See note [reducible non-instances]. -/ abbrev PseudoMetricSpace.ofSeminormedSpaceCoreReplaceAll {š•œ E : Type*} [NormedField š•œ] [AddCommGroup E] [Norm E] [Module š•œ E] [U : UniformSpace E] [B : Bornology E] (core : SeminormedSpace.Core š•œ E) (HU : š“¤[U] = š“¤[PseudoEMetricSpace.toUniformSpace (self := PseudoEMetricSpace.ofSeminormedSpaceCore core)]) (HB : āˆ€ s : Set E, @IsBounded _ B s ↔ @IsBounded _ (PseudoMetricSpace.ofSeminormedSpaceCore core).toBornology s) : PseudoMetricSpace E := .replaceBornology (.replaceUniformity (.ofSeminormedSpaceCore core) HU) HB @[deprecated (since := "2025-06-03")] alias PseudoMetricSpace.ofSeminormedAddCommGroupCoreReplaceAll := PseudoMetricSpace.ofSeminormedSpaceCoreReplaceAll /-- Produces a `SeminormedAddCommGroup E` instance from a `SeminormedSpace.Core`. Note that if this is used to define an instance on a type, it also provides a new distance measure from the norm. it must therefore not be used on a type with a preexisting distance measure or topology. See note [reducible non-instances]. -/ abbrev SeminormedAddCommGroup.ofCore {š•œ : Type*} {E : Type*} [NormedField š•œ] [AddCommGroup E] [Norm E] [Module š•œ E] (core : SeminormedSpace.Core š•œ E) : SeminormedAddCommGroup E := { PseudoMetricSpace.ofSeminormedSpaceCore core with } /-- Produces a `SeminormedAddCommGroup E` instance from a `SeminormedSpace.Core` on a type that already has an existing uniform space structure. This requires a proof that the uniformity induced by the norm is equal to the preexisting uniformity. See note [reducible non-instances]. -/ abbrev SeminormedAddCommGroup.ofCoreReplaceUniformity {š•œ : Type*} {E : Type*} [NormedField š•œ] [AddCommGroup E] [Norm E] [Module š•œ E] [U : UniformSpace E] (core : SeminormedSpace.Core š•œ E) (H : š“¤[U] = š“¤[PseudoEMetricSpace.toUniformSpace (self := PseudoEMetricSpace.ofSeminormedSpaceCore core)]) : SeminormedAddCommGroup E := { PseudoMetricSpace.ofSeminormedSpaceCoreReplaceUniformity core H with } /-- Produces a `SeminormedAddCommGroup E` instance from a `SeminormedSpace.Core` on a type that already has an existing topology. This requires a proof that the uniformity induced by the norm is equal to the preexisting uniformity. See note [reducible non-instances]. -/ abbrev SeminormedAddCommGroup.ofCoreReplaceTopology {š•œ : Type*} {E : Type*} [NormedField š•œ] [AddCommGroup E] [Norm E] [Module š•œ E] [T : TopologicalSpace E] (core : SeminormedSpace.Core š•œ E) (H : T = (PseudoEMetricSpace.ofSeminormedSpaceCore core).toUniformSpace.toTopologicalSpace) : SeminormedAddCommGroup E := { PseudoMetricSpace.ofSeminormedSpaceCoreReplaceTopology core H with } open Bornology in /-- Produces a `SeminormedAddCommGroup E` instance from a `SeminormedSpace.Core` on a type that already has a preexisting uniform space structure and a preexisting bornology. This requires proofs that the uniformity induced by the norm is equal to the preexisting uniformity, and likewise for the bornology. See note [reducible non-instances]. -/ abbrev SeminormedAddCommGroup.ofCoreReplaceAll {š•œ : Type*} {E : Type*} [NormedField š•œ] [AddCommGroup E] [Norm E] [Module š•œ E] [U : UniformSpace E] [B : Bornology E] (core : SeminormedSpace.Core š•œ E) (HU : š“¤[U] = š“¤[PseudoEMetricSpace.toUniformSpace (self := PseudoEMetricSpace.ofSeminormedSpaceCore core)]) (HB : āˆ€ s : Set E, @IsBounded _ B s ↔ @IsBounded _ (PseudoMetricSpace.ofSeminormedSpaceCore core).toBornology s) : SeminormedAddCommGroup E := { PseudoMetricSpace.ofSeminormedSpaceCoreReplaceAll core HU HB with } /-- A structure encapsulating minimal axioms needed to defined a normed vector space, as found in textbooks. This is meant to be used to easily define `NormedAddCommGroup E` and `NormedSpace E` instances from scratch on a type with no preexisting distance or topology. -/ structure NormedSpace.Core (š•œ : Type*) (E : Type*) [NormedField š•œ] [AddCommGroup E] [Module š•œ E] [Norm E] : Prop extends SeminormedSpace.Core š•œ E where norm_eq_zero_iff (x : E) : ‖x‖ = 0 ↔ x = 0 variable {š•œ : Type*} {E : Type*} [NormedField š•œ] [AddCommGroup E] [Module š•œ E] [Norm E] /-- Produces a `NormedAddCommGroup E` instance from a `NormedSpace.Core`. Note that if this is used to define an instance on a type, it also provides a new distance measure from the norm. it must therefore not be used on a type with a preexisting distance measure. See note [reducible non-instances]. -/ abbrev NormedAddCommGroup.ofCore (core : NormedSpace.Core š•œ E) : NormedAddCommGroup E := { SeminormedAddCommGroup.ofCore core.toCore with eq_of_dist_eq_zero := by intro x y h rw [← sub_eq_zero, ← core.norm_eq_zero_iff] exact h } /-- Produces a `NormedAddCommGroup E` instance from a `NormedSpace.Core` on a type that already has an existing uniform space structure. This requires a proof that the uniformity induced by the norm is equal to the preexisting uniformity. See note [reducible non-instances]. -/ abbrev NormedAddCommGroup.ofCoreReplaceUniformity [U : UniformSpace E] (core : NormedSpace.Core š•œ E) (H : š“¤[U] = š“¤[PseudoEMetricSpace.toUniformSpace (self := PseudoEMetricSpace.ofSeminormedSpaceCore core.toCore)]) : NormedAddCommGroup E := { SeminormedAddCommGroup.ofCoreReplaceUniformity core.toCore H with eq_of_dist_eq_zero := by intro x y h rw [← sub_eq_zero, ← core.norm_eq_zero_iff] exact h } /-- Produces a `NormedAddCommGroup E` instance from a `NormedSpace.Core` on a type that already has an existing topology. This requires a proof that the uniformity induced by the norm is equal to the preexisting uniformity. See note [reducible non-instances]. -/ abbrev NormedAddCommGroup.ofCoreReplaceTopology [T : TopologicalSpace E] (core : NormedSpace.Core š•œ E) (H : T = (PseudoEMetricSpace.ofSeminormedSpaceCore core.toCore).toUniformSpace.toTopologicalSpace) : NormedAddCommGroup E := { SeminormedAddCommGroup.ofCoreReplaceTopology core.toCore H with eq_of_dist_eq_zero := by intro x y h rw [← sub_eq_zero, ← core.norm_eq_zero_iff] exact h } open Bornology in /-- Produces a `NormedAddCommGroup E` instance from a `NormedSpace.Core` on a type that already has a preexisting uniform space structure and a preexisting bornology. This requires proofs that the uniformity induced by the norm is equal to the preexisting uniformity, and likewise for the bornology. See note [reducible non-instances]. -/ abbrev NormedAddCommGroup.ofCoreReplaceAll [U : UniformSpace E] [B : Bornology E] (core : NormedSpace.Core š•œ E) (HU : š“¤[U] = š“¤[PseudoEMetricSpace.toUniformSpace (self := PseudoEMetricSpace.ofSeminormedSpaceCore core.toCore)]) (HB : āˆ€ s : Set E, @IsBounded _ B s ↔ @IsBounded _ (PseudoMetricSpace.ofSeminormedSpaceCore core.toCore).toBornology s) : NormedAddCommGroup E := { SeminormedAddCommGroup.ofCoreReplaceAll core.toCore HU HB with eq_of_dist_eq_zero := by intro x y h rw [← sub_eq_zero, ← core.norm_eq_zero_iff] exact h } /-- Produces a `NormedSpace š•œ E` instance from a `NormedSpace.Core`. This is meant to be used on types where the `NormedAddCommGroup E` instance has also been defined using `core`. See note [reducible non-instances]. -/ abbrev NormedSpace.ofCore {š•œ : Type*} {E : Type*} [NormedField š•œ] [SeminormedAddCommGroup E] [Module š•œ E] (core : NormedSpace.Core š•œ E) : NormedSpace š•œ E where norm_smul_le r x := by rw [core.norm_smul r x] end Core variable {G H : Type*} [SeminormedAddCommGroup G] [SeminormedAddCommGroup H] [NormedSpace ā„ H] {s : Set G} /-- A group homomorphism from a normed group to a real normed space, bounded on a neighborhood of `0`, must be continuous. -/ lemma AddMonoidHom.continuous_of_isBounded_nhds_zero (f : G →+ H) (hs : s ∈ š“ (0 : G)) (hbounded : IsBounded (f '' s)) : Continuous f := by obtain ⟨Γ, hĪ“, hUε⟩ := Metric.mem_nhds_iff.mp hs obtain ⟨C, hC⟩ := (isBounded_iff_subset_ball 0).1 (hbounded.subset <| image_mono hUε) refine continuous_of_continuousAt_zero _ (continuousAt_iff.2 fun ε (hε : _ < _) => ?_) simp only [dist_zero_right, map_zero] simp only [subset_def, mem_image, mem_ball, dist_zero_right, forall_exists_index, and_imp, forall_apply_eq_imp_iffā‚‚] at hC have hCā‚€ : 0 < C := (norm_nonneg _).trans_lt <| hC 0 (by simpa) obtain ⟨n, hn⟩ := exists_nat_gt (C / ε) have hnpos : 0 < (n : ā„) := (div_pos hCā‚€ hε).trans hn have hnā‚€ : n ≠ 0 := by rintro rfl; simp at hnpos refine ⟨Γ / n, div_pos hĪ“ hnpos, fun {x} hxĪ“ => ?_⟩ calc ‖f x‖ _ = ‖(n : ā„)⁻¹ • f (n • x)‖ := by simp [← Nat.cast_smul_eq_nsmul ā„, hnā‚€] _ ≤ ‖(n : ā„)⁻¹‖ * ‖f (n • x)‖ := norm_smul_le .. _ < ‖(n : ā„)⁻¹‖ * C := by gcongr Ā· simpa [pos_iff_ne_zero] Ā· refine hC _ <| norm_nsmul_le.trans_lt ?_ simpa only [norm_mul, Real.norm_natCast, lt_div_iffā‚€ hnpos, mul_comm] using hxĪ“ _ = (n : ā„)⁻¹ * C := by simp _ < (C / ε : ā„)⁻¹ * C := by gcongr _ = ε := by simp [hCā‚€.ne']
.lake/packages/mathlib/Mathlib/Analysis/Normed/Module/FiniteDimension.lean
import Mathlib.Analysis.Asymptotics.AsymptoticEquivalent import Mathlib.Analysis.Normed.Group.Lemmas import Mathlib.Analysis.Normed.Affine.Isometry import Mathlib.Analysis.Normed.Operator.NormedSpace import Mathlib.Analysis.NormedSpace.RieszLemma import Mathlib.Analysis.Normed.Module.Ball.Pointwise import Mathlib.Analysis.SpecificLimits.Normed import Mathlib.Logic.Encodable.Pi import Mathlib.Topology.Algebra.AffineSubspace import Mathlib.Topology.Algebra.Module.FiniteDimension import Mathlib.Topology.Algebra.InfiniteSum.Module import Mathlib.Topology.Instances.Matrix import Mathlib.LinearAlgebra.Dimension.LinearMap /-! # Finite-dimensional normed spaces over complete fields Over a complete nontrivially normed field, in finite dimension, all norms are equivalent and all linear maps are continuous. Moreover, a finite-dimensional subspace is always complete and closed. ## Main results: * `FiniteDimensional.complete` : a finite-dimensional space over a complete field is complete. This is not registered as an instance, as the field would be an unknown metavariable in typeclass resolution. * `Submodule.closed_of_finiteDimensional` : a finite-dimensional subspace over a complete field is closed * `FiniteDimensional.proper` : a finite-dimensional space over a proper field is proper. This is not registered as an instance, as the field would be an unknown metavariable in typeclass resolution. It is however registered as an instance for `š•œ = ā„` and `š•œ = ā„‚`. As properness implies completeness, there is no need to also register `FiniteDimensional.complete` on `ā„` or `ā„‚`. * `FiniteDimensional.of_isCompact_closedBall`: Riesz' theorem: if the closed unit ball is compact, then the space is finite-dimensional. ## Implementation notes The fact that all norms are equivalent is not written explicitly, as it would mean having two norms on a single space, which is not the way type classes work. However, if one has a finite-dimensional vector space `E` with a norm, and a copy `E'` of this type with another norm, then the identities from `E` to `E'` and from `E'`to `E` are continuous thanks to `LinearMap.continuous_of_finiteDimensional`. This gives the desired norm equivalence. -/ universe u v w x noncomputable section open Asymptotics Filter Module Metric Module NNReal Set TopologicalSpace Topology namespace LinearIsometry open LinearMap variable {F E₁ : Type*} [SeminormedAddCommGroup F] [NormedAddCommGroup E₁] variable {R₁ : Type*} [Field R₁] [Module R₁ E₁] [Module R₁ F] [FiniteDimensional R₁ E₁] [FiniteDimensional R₁ F] /-- A linear isometry between finite-dimensional spaces of equal dimension can be upgraded to a linear isometry equivalence. -/ def toLinearIsometryEquiv (li : E₁ →ₗᵢ[R₁] F) (h : finrank R₁ E₁ = finrank R₁ F) : E₁ ā‰ƒā‚—įµ¢[R₁] F where toLinearEquiv := li.toLinearMap.linearEquivOfInjective li.injective h norm_map' := li.norm_map' @[simp] theorem coe_toLinearIsometryEquiv (li : E₁ →ₗᵢ[R₁] F) (h : finrank R₁ E₁ = finrank R₁ F) : (li.toLinearIsometryEquiv h : E₁ → F) = li := rfl @[simp] theorem toLinearIsometryEquiv_apply (li : E₁ →ₗᵢ[R₁] F) (h : finrank R₁ E₁ = finrank R₁ F) (x : E₁) : (li.toLinearIsometryEquiv h) x = li x := rfl end LinearIsometry namespace AffineIsometry open AffineMap variable {š•œ : Type*} {V₁ Vā‚‚ : Type*} {P₁ Pā‚‚ : Type*} [NormedField š•œ] [NormedAddCommGroup V₁] [SeminormedAddCommGroup Vā‚‚] [NormedSpace š•œ V₁] [NormedSpace š•œ Vā‚‚] [MetricSpace P₁] [PseudoMetricSpace Pā‚‚] [NormedAddTorsor V₁ P₁] [NormedAddTorsor Vā‚‚ Pā‚‚] variable [FiniteDimensional š•œ V₁] [FiniteDimensional š•œ Vā‚‚] /-- An affine isometry between finite-dimensional spaces of equal dimension can be upgraded to an affine isometry equivalence. -/ def toAffineIsometryEquiv [Inhabited P₁] (li : P₁ ā†’įµƒā±[š•œ] Pā‚‚) (h : finrank š•œ V₁ = finrank š•œ Vā‚‚) : P₁ ā‰ƒįµƒā±[š•œ] Pā‚‚ := AffineIsometryEquiv.mk' li (li.linearIsometry.toLinearIsometryEquiv h) (Inhabited.default (α := P₁)) fun p => by simp @[simp] theorem coe_toAffineIsometryEquiv [Inhabited P₁] (li : P₁ ā†’įµƒā±[š•œ] Pā‚‚) (h : finrank š•œ V₁ = finrank š•œ Vā‚‚) : (li.toAffineIsometryEquiv h : P₁ → Pā‚‚) = li := rfl @[simp] theorem toAffineIsometryEquiv_apply [Inhabited P₁] (li : P₁ ā†’įµƒā±[š•œ] Pā‚‚) (h : finrank š•œ V₁ = finrank š•œ Vā‚‚) (x : P₁) : (li.toAffineIsometryEquiv h) x = li x := rfl end AffineIsometry section CompleteField variable {š•œ : Type u} [NontriviallyNormedField š•œ] {E : Type v} [NormedAddCommGroup E] [NormedSpace š•œ E] {F : Type w} [NormedAddCommGroup F] [NormedSpace š•œ F] [CompleteSpace š•œ] section Affine variable {PE PF : Type*} [MetricSpace PE] [NormedAddTorsor E PE] [MetricSpace PF] [NormedAddTorsor F PF] [FiniteDimensional š•œ E] theorem AffineMap.continuous_of_finiteDimensional (f : PE ā†’įµƒ[š•œ] PF) : Continuous f := AffineMap.continuous_linear_iff.1 f.linear.continuous_of_finiteDimensional theorem AffineEquiv.continuous_of_finiteDimensional (f : PE ā‰ƒįµƒ[š•œ] PF) : Continuous f := f.toAffineMap.continuous_of_finiteDimensional /-- Reinterpret an affine equivalence as a homeomorphism. -/ def AffineEquiv.toHomeomorphOfFiniteDimensional (f : PE ā‰ƒįµƒ[š•œ] PF) : PE ā‰ƒā‚œ PF where toEquiv := f.toEquiv continuous_toFun := f.continuous_of_finiteDimensional continuous_invFun := haveI : FiniteDimensional š•œ F := f.linear.finiteDimensional f.symm.continuous_of_finiteDimensional @[simp] theorem AffineEquiv.coe_toHomeomorphOfFiniteDimensional (f : PE ā‰ƒįµƒ[š•œ] PF) : ⇑f.toHomeomorphOfFiniteDimensional = f := rfl @[simp] theorem AffineEquiv.coe_toHomeomorphOfFiniteDimensional_symm (f : PE ā‰ƒįµƒ[š•œ] PF) : ⇑f.toHomeomorphOfFiniteDimensional.symm = f.symm := rfl end Affine theorem ContinuousLinearMap.continuous_det : Continuous fun f : E →L[š•œ] E => f.det := by change Continuous fun f : E →L[š•œ] E => LinearMap.det (f : E →ₗ[š•œ] E) -- TODO: this could be easier with `det_cases` by_cases h : ∃ s : Finset E, Nonempty (Basis (ↄs) š•œ E) Ā· rcases h with ⟨s, ⟨b⟩⟩ haveI : FiniteDimensional š•œ E := b.finiteDimensional_of_finite classical simp_rw [LinearMap.det_eq_det_toMatrix_of_finset b] refine Continuous.matrix_det ?_ exact ((LinearMap.toMatrix b b).toLinearMap.comp (ContinuousLinearMap.coeLM š•œ)).continuous_of_finiteDimensional Ā· rw [LinearMap.det] simpa only [h, MonoidHom.one_apply, dif_neg, not_false_iff] using continuous_const /-- Any `K`-Lipschitz map from a subset `s` of a metric space `α` to a finite-dimensional real vector space `E'` can be extended to a Lipschitz map on the whole space `α`, with a slightly worse constant `C * K` where `C` only depends on `E'`. We record a working value for this constant `C` as `lipschitzExtensionConstant E'`. -/ irreducible_def lipschitzExtensionConstant (E' : Type*) [NormedAddCommGroup E'] [NormedSpace ā„ E'] [FiniteDimensional ā„ E'] : ā„ā‰„0 := let A := (Basis.ofVectorSpace ā„ E').equivFun.toContinuousLinearEquiv max (‖A.symm.toContinuousLinearMapā€–ā‚Š * ‖A.toContinuousLinearMapā€–ā‚Š) 1 theorem lipschitzExtensionConstant_pos (E' : Type*) [NormedAddCommGroup E'] [NormedSpace ā„ E'] [FiniteDimensional ā„ E'] : 0 < lipschitzExtensionConstant E' := by rw [lipschitzExtensionConstant] exact zero_lt_one.trans_le (le_max_right _ _) /-- Any `K`-Lipschitz map from a subset `s` of a metric space `α` to a finite-dimensional real vector space `E'` can be extended to a Lipschitz map on the whole space `α`, with a slightly worse constant `lipschitzExtensionConstant E' * K`. -/ theorem LipschitzOnWith.extend_finite_dimension {α : Type*} [PseudoMetricSpace α] {E' : Type*} [NormedAddCommGroup E'] [NormedSpace ā„ E'] [FiniteDimensional ā„ E'] {s : Set α} {f : α → E'} {K : ā„ā‰„0} (hf : LipschitzOnWith K f s) : ∃ g : α → E', LipschitzWith (lipschitzExtensionConstant E' * K) g ∧ EqOn f g s := by /- This result is already known for spaces `ι → ā„`. We use a continuous linear equiv between `E'` and such a space to transfer the result to `E'`. -/ let ι : Type _ := Basis.ofVectorSpaceIndex ā„ E' let A := (Basis.ofVectorSpace ā„ E').equivFun.toContinuousLinearEquiv have LA : LipschitzWith ‖A.toContinuousLinearMapā€–ā‚Š A := by apply A.lipschitz have L : LipschitzOnWith (‖A.toContinuousLinearMapā€–ā‚Š * K) (A ∘ f) s := LA.comp_lipschitzOnWith hf obtain ⟨g, hg, gs⟩ : ∃ g : α → ι → ā„, LipschitzWith (‖A.toContinuousLinearMapā€–ā‚Š * K) g ∧ EqOn (A ∘ f) g s := L.extend_pi refine ⟨A.symm ∘ g, ?_, ?_⟩ Ā· have LAsymm : LipschitzWith ‖A.symm.toContinuousLinearMapā€–ā‚Š A.symm := by apply A.symm.lipschitz apply (LAsymm.comp hg).weaken rw [lipschitzExtensionConstant, ← mul_assoc] exact mul_le_mul' (le_max_left _ _) le_rfl Ā· intro x hx have : A (f x) = g x := gs hx simp only [(Ā· ∘ Ā·), ← this, A.symm_apply_apply] theorem LinearMap.exists_antilipschitzWith [FiniteDimensional š•œ E] (f : E →ₗ[š•œ] F) (hf : LinearMap.ker f = ⊄) : ∃ K > 0, AntilipschitzWith K f := by cases subsingleton_or_nontrivial E Ā· exact ⟨1, zero_lt_one, AntilipschitzWith.of_subsingleton⟩ Ā· rw [LinearMap.ker_eq_bot] at hf let e : E ā‰ƒL[š•œ] LinearMap.range f := (LinearEquiv.ofInjective f hf).toContinuousLinearEquiv exact ⟨_, e.nnnorm_symm_pos, e.antilipschitz⟩ open Function in /-- A `LinearMap` on a finite-dimensional space over a complete field is injective iff it is anti-Lipschitz. -/ theorem LinearMap.injective_iff_antilipschitz [FiniteDimensional š•œ E] (f : E →ₗ[š•œ] F) : Injective f ↔ ∃ K > 0, AntilipschitzWith K f := by constructor Ā· rw [← LinearMap.ker_eq_bot] exact f.exists_antilipschitzWith Ā· rintro ⟨K, -, H⟩ exact H.injective open Function in /-- The set of injective continuous linear maps `E → F` is open, if `E` is finite-dimensional over a complete field. -/ theorem ContinuousLinearMap.isOpen_injective [FiniteDimensional š•œ E] : IsOpen { L : E →L[š•œ] F | Injective L } := by rw [isOpen_iff_eventually] rintro φ₀ hφ₀ rcases φ₀.injective_iff_antilipschitz.mp hφ₀ with ⟨K, K_pos, H⟩ have : āˆ€į¶  φ in š“ φ₀, ‖φ - Ļ†ā‚€ā€–ā‚Š < K⁻¹ := eventually_nnnorm_sub_lt _ <| inv_pos_of_pos K_pos filter_upwards [this] with φ hφ apply φ.injective_iff_antilipschitz.mpr exact ⟨(K⁻¹ - ‖φ - Ļ†ā‚€ā€–ā‚Š)⁻¹, inv_pos_of_pos (tsub_pos_of_lt hφ), H.add_sub_lipschitzWith (φ - φ₀).lipschitz hĻ†āŸ© protected theorem LinearIndependent.eventually {ι} [Finite ι] {f : ι → E} (hf : LinearIndependent š•œ f) : āˆ€į¶  g in š“ f, LinearIndependent š•œ g := by cases nonempty_fintype ι classical simp only [Fintype.linearIndependent_iff'] at hf ⊢ rcases LinearMap.exists_antilipschitzWith _ hf with ⟨K, K0, hK⟩ have : Tendsto (fun g : ι → E => āˆ‘ i, ‖g i - f i‖) (š“ f) (š“ <| āˆ‘ i, ‖f i - f i‖) := tendsto_finset_sum _ fun i _ => Tendsto.norm <| ((continuous_apply i).tendsto _).sub tendsto_const_nhds simp only [sub_self, norm_zero, Finset.sum_const_zero] at this refine (this.eventually (gt_mem_nhds <| inv_pos.2 K0)).mono fun g hg => ?_ replace hg : āˆ‘ i, ‖g i - f iā€–ā‚Š < K⁻¹ := by rw [← NNReal.coe_lt_coe] push_cast exact hg rw [LinearMap.ker_eq_bot] refine (hK.add_sub_lipschitzWith (LipschitzWith.of_dist_le_mul fun v u => ?_) hg).injective simp only [dist_eq_norm, LinearMap.lsum_apply, Pi.sub_apply, LinearMap.sum_apply, LinearMap.comp_apply, LinearMap.proj_apply, LinearMap.smulRight_apply, LinearMap.id_apply, ← Finset.sum_sub_distrib, ← smul_sub, ← sub_smul, NNReal.coe_sum, coe_nnnorm, Finset.sum_mul] refine norm_sum_le_of_le _ fun i _ => ?_ rw [norm_smul, mul_comm] gcongr exact norm_le_pi_norm (v - u) i theorem isOpen_setOf_linearIndependent {ι : Type*} [Finite ι] : IsOpen { f : ι → E | LinearIndependent š•œ f } := isOpen_iff_mem_nhds.2 fun _ => LinearIndependent.eventually theorem isOpen_setOf_nat_le_rank (n : ā„•) : IsOpen { f : E →L[š•œ] F | ↑n ≤ (f : E →ₗ[š•œ] F).rank } := by simp only [LinearMap.le_rank_iff_exists_linearIndependent_finset, setOf_exists, ← exists_prop] refine isOpen_biUnion fun t _ => ?_ have : Continuous fun f : E →L[š•œ] F => fun x : (t : Set E) => f x := continuous_pi fun x => (ContinuousLinearMap.apply š•œ F (x : E)).continuous exact isOpen_setOf_linearIndependent.preimage this theorem isOpen_setOf_affineIndependent {ι : Type*} [Finite ι] : IsOpen {p : ι → E | AffineIndependent š•œ p} := by classical rcases isEmpty_or_nonempty ι with h | ⟨⟨iā‚€āŸ©āŸ© Ā· exact isOpen_discrete _ Ā· simp_rw [affineIndependent_iff_linearIndependent_vsub š•œ _ iā‚€] let ι' := { x // x ≠ iā‚€ } cases nonempty_fintype ι haveI : Fintype ι' := Subtype.fintype _ convert_to IsOpen ((fun (p : ι → E) (i : ι') ↦ p i -ᵄ p iā‚€) ⁻¹' {p : ι' → E | LinearIndependent š•œ p}) exact isOpen_setOf_linearIndependent.preimage (by fun_prop) namespace Module.Basis theorem opNNNorm_le {ι : Type*} [Fintype ι] (v : Basis ι š•œ E) {u : E →L[š•œ] F} (M : ā„ā‰„0) (hu : āˆ€ i, ‖u (v i)ā€–ā‚Š ≤ M) : ‖uā€–ā‚Š ≤ Fintype.card ι • ‖v.equivFunL.toContinuousLinearMapā€–ā‚Š * M := u.opNNNorm_le_bound _ fun e => by set φ := v.equivFunL.toContinuousLinearMap calc ‖u eā€–ā‚Š = ‖u (āˆ‘ i, v.equivFun e i • v i)ā€–ā‚Š := by rw [v.sum_equivFun] _ = ā€–āˆ‘ i, v.equivFun e i • (u <| v i)ā€–ā‚Š := by simp only [equivFun_apply, map_sum, map_smul] _ ≤ āˆ‘ i, ‖v.equivFun e i • (u <| v i)ā€–ā‚Š := nnnorm_sum_le _ _ _ = āˆ‘ i, ‖v.equivFun e iā€–ā‚Š * ‖u (v i)ā€–ā‚Š := by simp only [nnnorm_smul] _ ≤ āˆ‘ i, ‖v.equivFun e iā€–ā‚Š * M := by gcongr; apply hu _ = (āˆ‘ i, ‖v.equivFun e iā€–ā‚Š) * M := by rw [Finset.sum_mul] _ ≤ Fintype.card ι • (ā€–Ļ†ā€–ā‚Š * ‖eā€–ā‚Š) * M := by gcongr calc āˆ‘ i, ‖v.equivFun e iā€–ā‚Š ≤ Fintype.card ι • ‖φ eā€–ā‚Š := Pi.sum_nnnorm_apply_le_nnnorm _ _ ≤ Fintype.card ι • (ā€–Ļ†ā€–ā‚Š * ‖eā€–ā‚Š) := nsmul_le_nsmul_right (φ.le_opNNNorm e) _ _ = Fintype.card ι • ā€–Ļ†ā€–ā‚Š * M * ‖eā€–ā‚Š := by simp only [smul_mul_assoc, mul_right_comm] theorem opNorm_le {ι : Type*} [Fintype ι] (v : Basis ι š•œ E) {u : E →L[š•œ] F} {M : ā„} (hM : 0 ≤ M) (hu : āˆ€ i, ‖u (v i)‖ ≤ M) : ‖u‖ ≤ Fintype.card ι • ‖v.equivFunL.toContinuousLinearMap‖ * M := by simpa using NNReal.coe_le_coe.mpr (v.opNNNorm_le ⟨M, hM⟩ hu) /-- A weaker version of `Basis.opNNNorm_le` that abstracts away the value of `C`. -/ theorem exists_opNNNorm_le {ι : Type*} [Finite ι] (v : Basis ι š•œ E) : ∃ C > (0 : ā„ā‰„0), āˆ€ {u : E →L[š•œ] F} (M : ā„ā‰„0), (āˆ€ i, ‖u (v i)ā€–ā‚Š ≤ M) → ‖uā€–ā‚Š ≤ C * M := by cases nonempty_fintype ι exact ⟨max (Fintype.card ι • ‖v.equivFunL.toContinuousLinearMapā€–ā‚Š) 1, zero_lt_one.trans_le (le_max_right _ _), fun {u} M hu => (v.opNNNorm_le M hu).trans <| mul_le_mul_of_nonneg_right (le_max_left _ _) (zero_le M)⟩ /-- A weaker version of `Basis.opNorm_le` that abstracts away the value of `C`. -/ theorem exists_opNorm_le {ι : Type*} [Finite ι] (v : Basis ι š•œ E) : ∃ C > (0 : ā„), āˆ€ {u : E →L[š•œ] F} {M : ā„}, 0 ≤ M → (āˆ€ i, ‖u (v i)‖ ≤ M) → ‖u‖ ≤ C * M := by obtain ⟨C, hC, h⟩ := v.exists_opNNNorm_le (F := F) refine ⟨C, hC, ?_⟩ intro u M hM H simpa using h ⟨M, hM⟩ H end Module.Basis instance [FiniteDimensional š•œ E] [SecondCountableTopology F] : SecondCountableTopology (E →L[š•œ] F) := by set d := Module.finrank š•œ E suffices āˆ€ ε > (0 : ā„), ∃ n : (E →L[š•œ] F) → Fin d → ā„•, āˆ€ f g : E →L[š•œ] F, n f = n g → dist f g ≤ ε from Metric.secondCountable_of_countable_discretization fun ε ε_pos => ⟨Fin d → ā„•, by infer_instance, this ε ε_pos⟩ intro ε ε_pos obtain ⟨u : ā„• → F, hu : DenseRange u⟩ := exists_dense_seq F let v := Module.finBasis š•œ E obtain ⟨C : ā„, C_pos : 0 < C, hC : āˆ€ {φ : E →L[š•œ] F} {M : ā„}, 0 ≤ M → (āˆ€ i, ‖φ (v i)‖ ≤ M) → ‖φ‖ ≤ C * M⟩ := v.exists_opNorm_le (E := E) (F := F) have h_2C : 0 < 2 * C := mul_pos zero_lt_two C_pos have hε2C : 0 < ε / (2 * C) := div_pos ε_pos h_2C have : āˆ€ φ : E →L[š•œ] F, ∃ n : Fin d → ā„•, ‖φ - (v.constrL <| u ∘ n)‖ ≤ ε / 2 := by intro φ have : āˆ€ i, ∃ n, ‖φ (v i) - u n‖ ≤ ε / (2 * C) := by simp only [norm_sub_rev] intro i have : φ (v i) ∈ closure (range u) := hu _ obtain ⟨n, hn⟩ : ∃ n, ‖u n - φ (v i)‖ < ε / (2 * C) := by rw [mem_closure_iff_nhds_basis Metric.nhds_basis_ball] at this specialize this (ε / (2 * C)) hε2C simpa [dist_eq_norm] exact ⟨n, le_of_lt hn⟩ choose n hn using this use n replace hn : āˆ€ i : Fin d, ‖(φ - (v.constrL <| u ∘ n)) (v i)‖ ≤ ε / (2 * C) := by simp [hn] have : C * (ε / (2 * C)) = ε / 2 := by rw [eq_div_iff (two_ne_zero : (2 : ā„) ≠ 0), mul_comm, ← mul_assoc, mul_div_cancelā‚€ _ (ne_of_gt h_2C)] specialize hC (le_of_lt hε2C) hn rwa [this] at hC choose n hn using this set Φ := fun φ : E →L[š•œ] F => v.constrL <| u ∘ n φ change āˆ€ z, dist z (Φ z) ≤ ε / 2 at hn use n intro x y hxy calc dist x y ≤ dist x (Φ x) + dist (Φ x) y := dist_triangle _ _ _ _ = dist x (Φ x) + dist y (Φ y) := by simp [Φ, hxy, dist_comm] _ ≤ ε := by linarith [hn x, hn y] theorem AffineSubspace.closed_of_finiteDimensional {P : Type*} [MetricSpace P] [NormedAddTorsor E P] (s : AffineSubspace š•œ P) [FiniteDimensional š•œ s.direction] : IsClosed (s : Set P) := s.isClosed_direction_iff.mp s.direction.closed_of_finiteDimensional section Riesz /-- In an infinite-dimensional space, given a finite number of points, one may find a point with norm at most `R` which is at distance at least `1` of all these points. -/ theorem exists_norm_le_le_norm_sub_of_finset {c : š•œ} (hc : 1 < ‖c‖) {R : ā„} (hR : ‖c‖ < R) (h : ¬FiniteDimensional š•œ E) (s : Finset E) : ∃ x : E, ‖x‖ ≤ R ∧ āˆ€ y ∈ s, 1 ≤ ‖y - x‖ := by let F := Submodule.span š•œ (s : Set E) haveI : FiniteDimensional š•œ F := Module.finite_def.2 ((Submodule.fg_top _).2 (Submodule.fg_def.2 ⟨s, Finset.finite_toSet _, rfl⟩)) have Fclosed : IsClosed (F : Set E) := Submodule.closed_of_finiteDimensional _ have : ∃ x, x āˆ‰ F := by contrapose! h have : (⊤ : Submodule š•œ E) = F := by ext x simp [h] have : FiniteDimensional š•œ (⊤ : Submodule š•œ E) := by rwa [this] exact Module.finite_def.2 ((Submodule.fg_top _).1 (Module.finite_def.1 this)) obtain ⟨x, xR, hx⟩ : ∃ x : E, ‖x‖ ≤ R ∧ āˆ€ y : E, y ∈ F → 1 ≤ ‖x - y‖ := riesz_lemma_of_norm_lt hc hR Fclosed this have hx' : āˆ€ y : E, y ∈ F → 1 ≤ ‖y - x‖ := by intro y hy rw [← norm_neg] simpa using hx y hy exact ⟨x, xR, fun y hy => hx' _ (Submodule.subset_span hy)⟩ /-- In an infinite-dimensional normed space, there exists a sequence of points which are all bounded by `R` and at distance at least `1`. For a version not assuming `c` and `R`, see `exists_seq_norm_le_one_le_norm_sub`. -/ theorem exists_seq_norm_le_one_le_norm_sub' {c : š•œ} (hc : 1 < ‖c‖) {R : ā„} (hR : ‖c‖ < R) (h : ¬FiniteDimensional š•œ E) : ∃ f : ā„• → E, (āˆ€ n, ‖f n‖ ≤ R) ∧ Pairwise fun m n => 1 ≤ ‖f m - f n‖ := by have : IsSymm E fun x y : E => 1 ≤ ‖x - y‖ := by constructor intro x y hxy rw [← norm_neg] simpa apply exists_seq_of_forall_finset_exists' (fun x : E => ‖x‖ ≤ R) fun (x : E) (y : E) => 1 ≤ ‖x - y‖ rintro s - exact exists_norm_le_le_norm_sub_of_finset hc hR h s theorem exists_seq_norm_le_one_le_norm_sub (h : ¬FiniteDimensional š•œ E) : ∃ (R : ā„) (f : ā„• → E), 1 < R ∧ (āˆ€ n, ‖f n‖ ≤ R) ∧ Pairwise fun m n => 1 ≤ ‖f m - f n‖ := by obtain ⟨c, hc⟩ : ∃ c : š•œ, 1 < ‖c‖ := NormedField.exists_one_lt_norm š•œ have A : ‖c‖ < ‖c‖ + 1 := by linarith rcases exists_seq_norm_le_one_le_norm_sub' hc A h with ⟨f, hf⟩ exact āŸØā€–c‖ + 1, f, hc.trans A, hf.1, hf.2⟩ variable (š•œ) /-- **Riesz's theorem**: if a closed ball with center zero of positive radius is compact in a vector space, then the space is finite-dimensional. -/ theorem FiniteDimensional.of_isCompact_closedBallā‚€ {r : ā„} (rpos : 0 < r) (h : IsCompact (Metric.closedBall (0 : E) r)) : FiniteDimensional š•œ E := by by_contra hfin obtain ⟨R, f, Rgt, fle, lef⟩ : ∃ (R : ā„) (f : ā„• → E), 1 < R ∧ (āˆ€ n, ‖f n‖ ≤ R) ∧ Pairwise fun m n => 1 ≤ ‖f m - f n‖ := exists_seq_norm_le_one_le_norm_sub hfin have rRpos : 0 < r / R := div_pos rpos (zero_lt_one.trans Rgt) obtain ⟨c, hc⟩ : ∃ c : š•œ, 0 < ‖c‖ ∧ ‖c‖ < r / R := NormedField.exists_norm_lt _ rRpos let g := fun n : ā„• => c • f n have A : āˆ€ n, g n ∈ Metric.closedBall (0 : E) r := by intro n simp only [g, norm_smul, dist_zero_right, Metric.mem_closedBall] calc ‖c‖ * ‖f n‖ ≤ r / R * R := by gcongr Ā· exact hc.2.le Ā· apply fle _ = r := by simp [(zero_lt_one.trans Rgt).ne'] obtain ⟨x : E, _ : x ∈ Metric.closedBall (0 : E) r, φ : ā„• → ā„•, φmono : StrictMono φ, φlim : Tendsto (g ∘ φ) atTop (š“ x)⟩ := h.tendsto_subseq A have B : CauchySeq (g ∘ φ) := φlim.cauchySeq obtain ⟨N, hN⟩ : ∃ N : ā„•, āˆ€ n : ā„•, N ≤ n → dist ((g ∘ φ) n) ((g ∘ φ) N) < ‖c‖ := Metric.cauchySeq_iff'.1 B ‖c‖ hc.1 apply lt_irrefl ‖c‖ calc ‖c‖ ≤ dist (g (φ (N + 1))) (g (φ N)) := by conv_lhs => rw [← mul_one ‖c‖] simp only [g, dist_eq_norm, ← smul_sub, norm_smul] gcongr apply lef (ne_of_gt _) exact φmono (Nat.lt_succ_self N) _ < ‖c‖ := hN (N + 1) (Nat.le_succ N) /-- **Riesz's theorem**: if a closed ball of positive radius is compact in a vector space, then the space is finite-dimensional. -/ theorem FiniteDimensional.of_isCompact_closedBall {r : ā„} (rpos : 0 < r) {c : E} (h : IsCompact (Metric.closedBall c r)) : FiniteDimensional š•œ E := .of_isCompact_closedBallā‚€ š•œ rpos <| by simpa using h.vadd (-c) /-- **Riesz's theorem**: a locally compact normed vector space is finite-dimensional. -/ theorem FiniteDimensional.of_locallyCompactSpace [LocallyCompactSpace E] : FiniteDimensional š•œ E := let ⟨_r, rpos, hr⟩ := exists_isCompact_closedBall (0 : E) .of_isCompact_closedBallā‚€ š•œ rpos hr /-- If a function has compact support, then either the function is trivial or the space is finite-dimensional. -/ theorem HasCompactSupport.eq_zero_or_finiteDimensional {X : Type*} [TopologicalSpace X] [Zero X] [T1Space X] {f : E → X} (hf : HasCompactSupport f) (h'f : Continuous f) : f = 0 ∨ FiniteDimensional š•œ E := (HasCompactSupport.eq_zero_or_locallyCompactSpace_of_addGroup hf h'f).imp_right fun h ↦ -- TODO: Lean doesn't find the instance without this `have` have : LocallyCompactSpace E := h; .of_locallyCompactSpace š•œ /-- If a function has compact multiplicative support, then either the function is trivial or the space is finite-dimensional. -/ @[to_additive existing] theorem HasCompactMulSupport.eq_one_or_finiteDimensional {X : Type*} [TopologicalSpace X] [One X] [T1Space X] {f : E → X} (hf : HasCompactMulSupport f) (h'f : Continuous f) : f = 1 ∨ FiniteDimensional š•œ E := have : T1Space (Additive X) := ‹_› HasCompactSupport.eq_zero_or_finiteDimensional (X := Additive X) š•œ hf h'f /-- A locally compact normed vector space is proper. -/ lemma ProperSpace.of_locallyCompactSpace (š•œ : Type*) [NontriviallyNormedField š•œ] {E : Type*} [SeminormedAddCommGroup E] [NormedSpace š•œ E] [LocallyCompactSpace E] : ProperSpace E := by rcases exists_isCompact_closedBall (0 : E) with ⟨r, rpos, hr⟩ rcases NormedField.exists_one_lt_norm š•œ with ⟨c, hc⟩ have hC : āˆ€ n, IsCompact (closedBall (0 : E) (‖c‖^n * r)) := fun n ↦ by have : c ^ n ≠ 0 := pow_ne_zero _ <| fun h ↦ by simp [h, zero_le_one.not_gt] at hc simpa [_root_.smul_closedBall' this] using hr.smul (c ^ n) have hTop : Tendsto (fun n ↦ ‖c‖^n * r) atTop atTop := Tendsto.atTop_mul_const rpos (tendsto_pow_atTop_atTop_of_one_lt hc) exact .of_seq_closedBall hTop (Eventually.of_forall hC) variable (E) lemma ProperSpace.of_locallyCompact_module [Nontrivial E] [LocallyCompactSpace E] : ProperSpace š•œ := have : LocallyCompactSpace š•œ := by obtain ⟨v, hv⟩ : ∃ v : E, v ≠ 0 := exists_ne 0 let L : š•œ → E := fun t ↦ t • v have : IsClosedEmbedding L := isClosedEmbedding_smul_left hv apply IsClosedEmbedding.locallyCompactSpace this .of_locallyCompactSpace š•œ end Riesz open ContinuousLinearMap /-- Continuous linear equivalence between continuous linear functions `š•œāæ → E` and `Eⁿ`. The spaces `š•œāæ` and `Eⁿ` are represented as `ι → š•œ` and `ι → E`, respectively, where `ι` is a finite type. -/ def ContinuousLinearEquiv.piRing (ι : Type*) [Fintype ι] [DecidableEq ι] : ((ι → š•œ) →L[š•œ] E) ā‰ƒL[š•œ] ι → E := { LinearMap.toContinuousLinearMap.symm.trans (LinearEquiv.piRing š•œ E ι š•œ) with continuous_toFun := by refine continuous_pi fun i => ?_ exact (ContinuousLinearMap.apply š•œ E (Pi.single i 1)).continuous continuous_invFun := by simp_rw [LinearEquiv.invFun_eq_symm, LinearEquiv.trans_symm, LinearEquiv.symm_symm] -- Note: added explicit type and removed `change` that tried to achieve the same refine AddMonoidHomClass.continuous_of_bound (LinearMap.toContinuousLinearMap.toLinearMap.comp (LinearEquiv.piRing š•œ E ι š•œ).symm.toLinearMap) (Fintype.card ι : ā„) fun g => ?_ rw [← nsmul_eq_mul] refine opNorm_le_bound _ (nsmul_nonneg (norm_nonneg g) (Fintype.card ι)) fun t => ?_ simp_rw [LinearMap.coe_comp, LinearEquiv.coe_toLinearMap, Function.comp_apply, LinearMap.coe_toContinuousLinearMap', LinearEquiv.piRing_symm_apply] apply le_trans (norm_sum_le _ _) rw [smul_mul_assoc] refine Finset.sum_le_card_nsmul _ _ _ fun i _ => ?_ rw [norm_smul, mul_comm] gcongr <;> apply norm_le_pi_norm } /-- A family of continuous linear maps is continuous on `s` if all its applications are. -/ theorem continuousOn_clm_apply {X : Type*} [TopologicalSpace X] [FiniteDimensional š•œ E] {f : X → E →L[š•œ] F} {s : Set X} : ContinuousOn f s ↔ āˆ€ y, ContinuousOn (fun x => f x y) s := by refine ⟨fun h y => (ContinuousLinearMap.apply š•œ F y).continuous.comp_continuousOn h, fun h => ?_⟩ let d := finrank š•œ E have hd : d = finrank š•œ (Fin d → š•œ) := (finrank_fin_fun š•œ).symm let e₁ : E ā‰ƒL[š•œ] Fin d → š•œ := ContinuousLinearEquiv.ofFinrankEq hd let eā‚‚ : (E →L[š•œ] F) ā‰ƒL[š•œ] Fin d → F := (e₁.arrowCongr (1 : F ā‰ƒL[š•œ] F)).trans (ContinuousLinearEquiv.piRing (Fin d)) rw [← f.id_comp, ← eā‚‚.symm_comp_self] exact eā‚‚.symm.continuous.comp_continuousOn (continuousOn_pi.mpr fun i => h _) theorem continuous_clm_apply {X : Type*} [TopologicalSpace X] [FiniteDimensional š•œ E] {f : X → E →L[š•œ] F} : Continuous f ↔ āˆ€ y, Continuous (f Ā· y) := by simp_rw [← continuousOn_univ, continuousOn_clm_apply] end CompleteField section LocallyCompactField variable (š•œ : Type u) [NontriviallyNormedField š•œ] (E : Type v) [NormedAddCommGroup E] [NormedSpace š•œ E] [LocallyCompactSpace š•œ] /-- Any finite-dimensional vector space over a locally compact field is proper. We do not register this as an instance to avoid an instance loop when trying to prove the properness of `š•œ`, and the search for `š•œ` as an unknown metavariable. Declare the instance explicitly when needed. -/ theorem FiniteDimensional.proper [FiniteDimensional š•œ E] : ProperSpace E := by have : ProperSpace š•œ := .of_locallyCompactSpace š•œ set e := ContinuousLinearEquiv.ofFinrankEq (@finrank_fin_fun š•œ _ _ (finrank š•œ E)).symm exact e.symm.antilipschitz.properSpace e.symm.continuous e.symm.surjective end LocallyCompactField /- Over the real numbers, we can register the previous statement as an instance as it will not cause problems in instance resolution since the properness of `ā„` is already known. -/ instance (priority := 900) FiniteDimensional.proper_real (E : Type u) [NormedAddCommGroup E] [NormedSpace ā„ E] [FiniteDimensional ā„ E] : ProperSpace E := FiniteDimensional.proper ā„ E /-- A submodule of a locally compact space over a complete field is also locally compact (and even proper). -/ instance {š•œ E : Type*} [NontriviallyNormedField š•œ] [CompleteSpace š•œ] [NormedAddCommGroup E] [NormedSpace š•œ E] [LocallyCompactSpace E] (S : Submodule š•œ E) : ProperSpace S := by nontriviality E have : ProperSpace š•œ := .of_locallyCompact_module š•œ E have : FiniteDimensional š•œ E := .of_locallyCompactSpace š•œ exact FiniteDimensional.proper š•œ S /-- If `E` is a finite-dimensional normed real vector space, `x : E`, and `s` is a neighborhood of `x` that is not equal to the whole space, then there exists a point `y ∈ frontier s` at distance `Metric.infDist x sᶜ` from `x`. See also `IsCompact.exists_mem_frontier_infDist_compl_eq_dist`. -/ theorem exists_mem_frontier_infDist_compl_eq_dist {E : Type*} [NormedAddCommGroup E] [NormedSpace ā„ E] [FiniteDimensional ā„ E] {x : E} {s : Set E} (hx : x ∈ s) (hs : s ≠ univ) : ∃ y ∈ frontier s, Metric.infDist x sᶜ = dist x y := by rcases Metric.exists_mem_closure_infDist_eq_dist (nonempty_compl.2 hs) x with ⟨y, hys, hyd⟩ rw [closure_compl] at hys refine ⟨y, ⟨Metric.closedBall_infDist_compl_subset_closure hx <| Metric.mem_closedBall.2 <| ge_of_eq ?_, hys⟩, hyd⟩ rwa [dist_comm] /-- If `K` is a compact set in a nontrivial real normed space and `x ∈ K`, then there exists a point `y` of the boundary of `K` at distance `Metric.infDist x Kᶜ` from `x`. See also `exists_mem_frontier_infDist_compl_eq_dist`. -/ nonrec theorem IsCompact.exists_mem_frontier_infDist_compl_eq_dist {E : Type*} [NormedAddCommGroup E] [NormedSpace ā„ E] [Nontrivial E] {x : E} {K : Set E} (hK : IsCompact K) (hx : x ∈ K) : ∃ y ∈ frontier K, Metric.infDist x Kᶜ = dist x y := by obtain hx' | hx' : x ∈ interior K ∪ frontier K := by rw [← closure_eq_interior_union_frontier] exact subset_closure hx Ā· rw [mem_interior_iff_mem_nhds, Metric.nhds_basis_closedBall.mem_iff] at hx' rcases hx' with ⟨r, hrā‚€, hrK⟩ have : FiniteDimensional ā„ E := .of_isCompact_closedBall ā„ hrā‚€ (hK.of_isClosed_subset Metric.isClosed_closedBall hrK) exact exists_mem_frontier_infDist_compl_eq_dist hx hK.ne_univ Ā· refine ⟨x, hx', ?_⟩ rw [frontier_eq_closure_inter_closure] at hx' rw [Metric.infDist_zero_of_mem_closure hx'.2, dist_self] /-- In a finite-dimensional vector space over `ā„`, the series `āˆ‘ x, ‖f x‖` is unconditionally summable if and only if the series `āˆ‘ x, f x` is unconditionally summable. One implication holds in any complete normed space, while the other holds only in finite-dimensional spaces. -/ theorem summable_norm_iff {α E : Type*} [NormedAddCommGroup E] [NormedSpace ā„ E] [FiniteDimensional ā„ E] {f : α → E} : (Summable fun x => ‖f x‖) ↔ Summable f := by refine ⟨Summable.of_norm, fun hf ↦ ?_⟩ -- First we use a finite basis to reduce the problem to the case `E = Fin N → ā„` suffices āˆ€ {N : ā„•} {g : α → Fin N → ā„}, Summable g → Summable fun x => ‖g x‖ by obtain v := Module.finBasis ā„ E set e := v.equivFunL have H : Summable fun x => ‖e (f x)‖ := this (e.summable.2 hf) refine .of_norm_bounded (H.mul_left ↑‖(e.symm : (Fin (finrank ā„ E) → ā„) →L[ā„] E)ā€–ā‚Š) fun i ↦ ?_ simpa using (e.symm : (Fin (finrank ā„ E) → ā„) →L[ā„] E).le_opNorm (e <| f i) clear! E -- Now we deal with `g : α → Fin N → ā„` intro N g hg have : āˆ€ i, Summable fun x => ‖g x i‖ := fun i => (Pi.summable.1 hg i).abs refine .of_norm_bounded (summable_sum fun i (_ : i ∈ Finset.univ) => this i) fun x => ?_ rw [norm_norm, pi_norm_le_iff_of_nonneg] Ā· refine fun i => Finset.single_le_sum (f := fun i => ‖g x i‖) (fun i _ => ?_) (Finset.mem_univ i) exact norm_nonneg (g x i) Ā· exact Finset.sum_nonneg fun _ _ => norm_nonneg _ alias ⟨_, Summable.norm⟩ := summable_norm_iff theorem summable_of_sum_range_norm_le {E : Type*} [NormedAddCommGroup E] [NormedSpace ā„ E] [FiniteDimensional ā„ E] {c : ā„} {f : ā„• → E} (h : āˆ€ n, āˆ‘ i ∈ Finset.range n, ‖f i‖ ≤ c) : Summable f := summable_norm_iff.mp <| summable_of_sum_range_le (fun _ ↦ norm_nonneg _) h theorem summable_of_isBigO' {ι E F : Type*} [NormedAddCommGroup E] [CompleteSpace E] [NormedAddCommGroup F] [NormedSpace ā„ F] [FiniteDimensional ā„ F] {f : ι → E} {g : ι → F} (hg : Summable g) (h : f =O[cofinite] g) : Summable f := summable_of_isBigO hg.norm h.norm_right lemma Asymptotics.IsBigO.comp_summable {ι E F : Type*} [NormedAddCommGroup E] [NormedSpace ā„ E] [FiniteDimensional ā„ E] [NormedAddCommGroup F] [CompleteSpace F] {f : E → F} (hf : f =O[š“ 0] id) {g : ι → E} (hg : Summable g) : Summable (f ∘ g) := .of_norm <| hf.comp_summable_norm hg.norm theorem summable_of_isBigO_nat' {E F : Type*} [NormedAddCommGroup E] [CompleteSpace E] [NormedAddCommGroup F] [NormedSpace ā„ F] [FiniteDimensional ā„ F] {f : ā„• → E} {g : ā„• → F} (hg : Summable g) (h : f =O[atTop] g) : Summable f := summable_of_isBigO_nat hg.norm h.norm_right open Nat Asymptotics in /-- This is a version of `summable_norm_mul_geometric_of_norm_lt_one` for more general codomains. We keep the original one due to import restrictions. -/ theorem summable_norm_mul_geometric_of_norm_lt_one' {F : Type*} [NormedRing F] [NormOneClass F] [NormMulClass F] {k : ā„•} {r : F} (hr : ‖r‖ < 1) {u : ā„• → F} (hu : u =O[atTop] fun n ↦ ((n ^ k : ā„•) : F)) : Summable fun n : ā„• ↦ ‖u n * r ^ n‖ := by rcases exists_between hr with ⟨r', hrr', h⟩ apply summable_of_isBigO_nat (summable_geometric_of_lt_one ((norm_nonneg _).trans hrr'.le) h).norm calc fun n ↦ ‖(u n) * r ^ n‖ _ =O[atTop] fun n ↦ ‖u n‖ * ‖r‖ ^ n := by apply (IsBigOWith.of_bound (c := ‖(1 : ā„)‖) ?_).isBigO filter_upwards [eventually_norm_pow_le r] with n hn simp _ =O[atTop] fun n ↦ ‖((n : F) ^ k)‖ * ‖r‖ ^ n := by simpa [Nat.cast_pow] using (isBigO_norm_left.mpr (isBigO_norm_right.mpr hu)).mul (isBigO_refl (fun n ↦ (‖r‖ ^ n)) atTop) _ =O[atTop] fun n ↦ ‖r' ^ n‖ := by convert isBigO_norm_right.mpr (isBigO_norm_left.mpr (isLittleO_pow_const_mul_const_pow_const_pow_of_norm_lt k hrr').isBigO) simp only [norm_pow, norm_mul] theorem summable_of_isEquivalent {ι E : Type*} [NormedAddCommGroup E] [NormedSpace ā„ E] [FiniteDimensional ā„ E] {f : ι → E} {g : ι → E} (hg : Summable g) (h : f ~[cofinite] g) : Summable f := hg.trans_sub (summable_of_isBigO' hg h.isLittleO.isBigO) theorem summable_of_isEquivalent_nat {E : Type*} [NormedAddCommGroup E] [NormedSpace ā„ E] [FiniteDimensional ā„ E] {f : ā„• → E} {g : ā„• → E} (hg : Summable g) (h : f ~[atTop] g) : Summable f := hg.trans_sub (summable_of_isBigO_nat' hg h.isLittleO.isBigO) theorem IsEquivalent.summable_iff {ι E : Type*} [NormedAddCommGroup E] [NormedSpace ā„ E] [FiniteDimensional ā„ E] {f : ι → E} {g : ι → E} (h : f ~[cofinite] g) : Summable f ↔ Summable g := ⟨fun hf => summable_of_isEquivalent hf h.symm, fun hg => summable_of_isEquivalent hg h⟩ theorem IsEquivalent.summable_iff_nat {E : Type*} [NormedAddCommGroup E] [NormedSpace ā„ E] [FiniteDimensional ā„ E] {f : ā„• → E} {g : ā„• → E} (h : f ~[atTop] g) : Summable f ↔ Summable g := ⟨fun hf => summable_of_isEquivalent_nat hf h.symm, fun hg => summable_of_isEquivalent_nat hg h⟩ namespace Module.Basis variable {ι R M : Type*} [Finite ι] [NontriviallyNormedField R] [CompleteSpace R] [AddCommGroup M] [TopologicalSpace M] [IsTopologicalAddGroup M] [T2Space M] [Module R M] [ContinuousSMul R M] (B : Module.Basis ι R M) -- Note that Finsupp has no topology so we need the coercion, see -- https://leanprover.zulipchat.com/#narrow/channel/217875-Is-there-code-for-X.3F/topic/TVS.20and.20NormedSpace.20on.20Finsupp.2C.20DFinsupp.2C.20DirectSum.2C.20.2E.2E/near/512890984 theorem continuous_coe_repr : Continuous (fun m : M => ⇑(B.repr m)) := have := Finite.of_basis B LinearMap.continuous_of_finiteDimensional B.equivFun.toLinearMap -- Note: this could be generalized if we had some typeclass to indicate "each of the projections -- into the basis is continuous". theorem continuous_toMatrix : Continuous fun (v : ι → M) => B.toMatrix v := let _ := Fintype.ofFinite ι have := Finite.of_basis B LinearMap.continuous_of_finiteDimensional B.toMatrixEquiv.toLinearMap end Module.Basis
.lake/packages/mathlib/Mathlib/Analysis/Normed/Module/Span.lean
import Mathlib.Analysis.Normed.Operator.LinearIsometry import Mathlib.Analysis.Normed.Operator.ContinuousLinearMap import Mathlib.Analysis.Normed.Module.Basic import Mathlib.LinearAlgebra.Basis.VectorSpace /-! # The span of a single vector The equivalence of `š•œ` and `š•œ • x` for `x ≠ 0` are defined as continuous linear equivalence and isometry. ## Main definitions * `ContinuousLinearEquiv.toSpanNonzeroSingleton`: The continuous linear equivalence between `š•œ` and `š•œ • x` for `x ≠ 0`. * `LinearIsometryEquiv.toSpanUnitSingleton`: For `‖x‖ = 1` the continuous linear equivalence is a linear isometry equivalence. -/ variable {š•œ E : Type*} namespace LinearMap variable (š•œ) section Seminormed variable [NormedDivisionRing š•œ] [SeminormedAddCommGroup E] [Module š•œ E] [NormSMulClass š•œ E] theorem toSpanSingleton_homothety (x : E) (c : š•œ) : ‖LinearMap.toSpanSingleton š•œ E x c‖ = ‖x‖ * ‖c‖ := by rw [mul_comm] exact norm_smul _ _ end Seminormed end LinearMap namespace ContinuousLinearEquiv variable (š•œ) section Seminormed variable [NormedDivisionRing š•œ] [SeminormedAddCommGroup E] [Module š•œ E] [NormSMulClass š•œ E] theorem _root_.LinearEquiv.toSpanNonzeroSingleton_homothety (x : E) (h : x ≠ 0) (c : š•œ) : ‖LinearEquiv.toSpanNonzeroSingleton š•œ E x h c‖ = ‖x‖ * ‖c‖ := LinearMap.toSpanSingleton_homothety _ _ _ end Seminormed section Normed variable [NormedField š•œ] [NormedAddCommGroup E] [NormedSpace š•œ E] /-- Given a nonzero element `x` of a normed space `E₁` over a field `š•œ`, the natural continuous linear equivalence from `š•œ` to the span of `x`. -/ @[simps!] noncomputable def toSpanNonzeroSingleton (x : E) (h : x ≠ 0) : š•œ ā‰ƒL[š•œ] š•œ āˆ™ x := ofHomothety (LinearEquiv.toSpanNonzeroSingleton š•œ E x h) ‖x‖ (norm_pos_iff.mpr h) (LinearEquiv.toSpanNonzeroSingleton_homothety š•œ x h) /-- Given a nonzero element `x` of a normed space `E₁` over a field `š•œ`, the natural continuous linear map from the span of `x` to `š•œ`. -/ noncomputable def coord (x : E) (h : x ≠ 0) : StrongDual š•œ (š•œ āˆ™ x) := (toSpanNonzeroSingleton š•œ x h).symm @[simp] theorem coe_toSpanNonzeroSingleton_symm {x : E} (h : x ≠ 0) : ⇑(toSpanNonzeroSingleton š•œ x h).symm = coord š•œ x h := rfl @[simp] theorem coord_toSpanNonzeroSingleton {x : E} (h : x ≠ 0) (c : š•œ) : coord š•œ x h (toSpanNonzeroSingleton š•œ x h c) = c := (toSpanNonzeroSingleton š•œ x h).symm_apply_apply c @[simp] theorem toSpanNonzeroSingleton_coord {x : E} (h : x ≠ 0) (y : š•œ āˆ™ x) : toSpanNonzeroSingleton š•œ x h (coord š•œ x h y) = y := (toSpanNonzeroSingleton š•œ x h).apply_symm_apply y @[simp] theorem coord_self (x : E) (h : x ≠ 0) : (coord š•œ x h) (⟨x, Submodule.mem_span_singleton_self x⟩ : š•œ āˆ™ x) = 1 := LinearEquiv.coord_self š•œ E x h end Normed end ContinuousLinearEquiv namespace LinearIsometryEquiv variable [NormedDivisionRing š•œ] [SeminormedAddCommGroup E] [Module š•œ E] [NormSMulClass š•œ E] /-- Given a unit element `x` of a normed space `E` over a field `š•œ`, the natural linear isometry equivalence from `š•œ` to the span of `x`. -/ noncomputable def toSpanUnitSingleton (x : E) (hx : ‖x‖ = 1) : š•œ ā‰ƒā‚—įµ¢[š•œ] š•œ āˆ™ x where toLinearEquiv := LinearEquiv.toSpanNonzeroSingleton š•œ E x (by aesop) norm_map' := by intro rw [LinearEquiv.toSpanNonzeroSingleton_homothety, hx, one_mul] @[simp] theorem toSpanUnitSingleton_apply (x : E) (hx : ‖x‖ = 1) (r : š•œ) : toSpanUnitSingleton x hx r = (⟨r • x, by aesop⟩ : š•œ āˆ™ x) := by rfl end LinearIsometryEquiv
.lake/packages/mathlib/Mathlib/Analysis/Normed/Module/Dual.lean
import Mathlib.Analysis.LocallyConvex.Polar import Mathlib.Analysis.Normed.Module.HahnBanach import Mathlib.Analysis.Normed.Module.RCLike.Basic import Mathlib.Data.Set.Finite.Lemmas import Mathlib.Analysis.LocallyConvex.AbsConvex import Mathlib.Analysis.Normed.Module.Convex /-! # The strong dual of a normed space In this file we consider the strong dual `StrongDual` of a normed space, and the continuous linear map `NormedSpace.inclusionInDoubleDual` from a normed space into its double StrongDual. For base field `š•œ = ā„` or `š•œ = ā„‚`, this map is actually an isometric embedding; we provide a version `NormedSpace.inclusionInDoubleDualLi` of the map which is of type a bundled linear isometric embedding, `E →ₗᵢ[š•œ] (StrongDual š•œ (StrongDual š•œ E))`. Since a lot of elementary properties don't require `eq_of_dist_eq_zero` we start setting up the theory for `SeminormedAddCommGroup` and we specialize to `NormedAddCommGroup` when needed. ## Main definitions * `inclusionInDoubleDual` and `inclusionInDoubleDualLi` are the inclusion of a normed space in its double `StrongDual`, considered as a bounded linear map and as a linear isometry, respectively. * `polar š•œ s` is the subset of `StrongDual š•œ E` consisting of those functionals `x'` for which `‖x' z‖ ≤ 1` for every `z ∈ s`. ## References * [Conway, John B., A course in functional analysis][conway1990] ## Tags strong dual, polar -/ noncomputable section open Topology Bornology universe u v namespace NormedSpace section General variable (š•œ : Type*) [NontriviallyNormedField š•œ] variable (E : Type*) [SeminormedAddCommGroup E] [NormedSpace š•œ E] variable (F : Type*) [NormedAddCommGroup F] [NormedSpace š•œ F] /-- The inclusion of a normed space in its double (topological) strong dual, considered as a bounded linear map. -/ def inclusionInDoubleDual : E →L[š•œ] StrongDual š•œ (StrongDual š•œ E) := ContinuousLinearMap.apply š•œ š•œ @[simp] theorem dual_def (x : E) (f : StrongDual š•œ E) : inclusionInDoubleDual š•œ E x f = f x := rfl theorem inclusionInDoubleDual_norm_eq : ‖inclusionInDoubleDual š•œ E‖ = ‖ContinuousLinearMap.id š•œ (StrongDual š•œ E)‖ := ContinuousLinearMap.opNorm_flip _ theorem inclusionInDoubleDual_norm_le : ‖inclusionInDoubleDual š•œ E‖ ≤ 1 := by rw [inclusionInDoubleDual_norm_eq] exact ContinuousLinearMap.norm_id_le theorem double_dual_bound (x : E) : ‖(inclusionInDoubleDual š•œ E) x‖ ≤ ‖x‖ := by simpa using ContinuousLinearMap.le_of_opNorm_le _ (inclusionInDoubleDual_norm_le š•œ E) x end General section BidualIsometry variable (š•œ : Type v) [RCLike š•œ] {E : Type u} [NormedAddCommGroup E] [NormedSpace š•œ E] /-- If one controls the norm of every `f x`, then one controls the norm of `x`. Compare `ContinuousLinearMap.opNorm_le_bound`. -/ theorem norm_le_dual_bound (x : E) {M : ā„} (hMp : 0 ≤ M) (hM : āˆ€ f : StrongDual š•œ E, ‖f x‖ ≤ M * ‖f‖) : ‖x‖ ≤ M := by classical by_cases h : x = 0 Ā· simp only [h, hMp, norm_zero] Ā· obtain ⟨f, hf₁, hfx⟩ : ∃ f : StrongDual š•œ E, ‖f‖ = 1 ∧ f x = ‖x‖ := exists_dual_vector š•œ x h calc ‖x‖ = ‖(‖x‖ : š•œ)‖ := RCLike.norm_coe_norm.symm _ = ‖f x‖ := by rw [hfx] _ ≤ M * ‖f‖ := hM f _ = M := by rw [hf₁, mul_one] theorem eq_zero_of_forall_dual_eq_zero {x : E} (h : āˆ€ f : StrongDual š•œ E, f x = (0 : š•œ)) : x = 0 := norm_le_zero_iff.mp (norm_le_dual_bound š•œ x le_rfl fun f => by simp [h f]) theorem eq_zero_iff_forall_dual_eq_zero (x : E) : x = 0 ↔ āˆ€ g : StrongDual š•œ E, g x = 0 := ⟨fun hx => by simp [hx], fun h => eq_zero_of_forall_dual_eq_zero š•œ h⟩ /-- See also `geometric_hahn_banach_point_point`. -/ theorem eq_iff_forall_dual_eq {x y : E} : x = y ↔ āˆ€ g : StrongDual š•œ E, g x = g y := by rw [← sub_eq_zero, eq_zero_iff_forall_dual_eq_zero š•œ (x - y)] simp [sub_eq_zero] /-- The inclusion of a normed space in its double strong dual is an isometry onto its image. -/ def inclusionInDoubleDualLi : E →ₗᵢ[š•œ] StrongDual š•œ (StrongDual š•œ E) := { inclusionInDoubleDual š•œ E with norm_map' := by intro x apply le_antisymm Ā· exact double_dual_bound š•œ E x rw [ContinuousLinearMap.norm_def] refine le_csInf ContinuousLinearMap.bounds_nonempty ?_ rintro c ⟨hc1, hc2⟩ exact norm_le_dual_bound š•œ x hc1 hc2 } end BidualIsometry section PolarSets open Metric Set StrongDual variable (š•œ : Type*) [NontriviallyNormedField š•œ] variable {E : Type*} [SeminormedAddCommGroup E] [NormedSpace š•œ E] theorem isClosed_polar (s : Set E) : IsClosed (StrongDual.polar š•œ s) := by dsimp only [StrongDual.polar] simp only [LinearMap.polar_eq_iInter, LinearMap.flip_apply] refine isClosed_biInter fun z _ => ?_ exact isClosed_Iic.preimage (ContinuousLinearMap.apply š•œ š•œ z).continuous.norm @[simp] theorem polar_closure (s : Set E) : StrongDual.polar š•œ (closure s) = StrongDual.polar š•œ s := ((topDualPairing š•œ E).flip.polar_antitone subset_closure).antisymm <| (topDualPairing š•œ E).flip.polar_gc.l_le <| closure_minimal ((topDualPairing š•œ E).flip.polar_gc.le_u_l s) <| by simpa [LinearMap.flip_flip] using (isClosed_polar _ _).preimage (inclusionInDoubleDual š•œ E).continuous variable {š•œ} /-- If `x'` is a `StrongDual š•œ E` element such that the norms `‖x' z‖` are bounded for `z ∈ s`, then a small scalar multiple of `x'` is in `polar š•œ s`. -/ theorem smul_mem_polar {s : Set E} {x' : StrongDual š•œ E} {c : š•œ} (hc : āˆ€ z, z ∈ s → ‖x' z‖ ≤ ‖c‖) : c⁻¹ • x' ∈ StrongDual.polar š•œ s := by by_cases c_zero : c = 0 Ā· simp only [c_zero, inv_zero, zero_smul] exact (topDualPairing š•œ E).flip.zero_mem_polar _ have eq : āˆ€ z, ‖c⁻¹ • x' z‖ = ‖c⁻¹‖ * ‖x' z‖ := fun z => norm_smul c⁻¹ _ have le : āˆ€ z, z ∈ s → ‖c⁻¹ • x' z‖ ≤ ‖c⁻¹‖ * ‖c‖ := by intro z hzs rw [eq z] apply mul_le_mul (le_of_eq rfl) (hc z hzs) (norm_nonneg _) (norm_nonneg _) have cancel : ‖c⁻¹‖ * ‖c‖ = 1 := by simp only [c_zero, norm_eq_zero, Ne, not_false_iff, inv_mul_cancelā‚€, norm_inv] rwa [cancel] at le theorem polar_ball_subset_closedBall_div {c : š•œ} (hc : 1 < ‖c‖) {r : ā„} (hr : 0 < r) : StrongDual.polar š•œ (ball (0 : E) r) āŠ† closedBall (0 : StrongDual š•œ E) (‖c‖ / r) := by intro x' hx' rw [StrongDual.mem_polar_iff] at hx' simp only [mem_closedBall_zero_iff, mem_ball_zero_iff] at * have hcr : 0 < ‖c‖ / r := div_pos (zero_lt_one.trans hc) hr refine ContinuousLinearMap.opNorm_le_of_shell hr hcr.le hc fun x h₁ hā‚‚ => ?_ calc ‖x' x‖ ≤ 1 := hx' _ hā‚‚ _ ≤ ‖c‖ / r * ‖x‖ := (inv_le_iff_one_le_mulā‚€' hcr).1 (by rwa [inv_div]) variable (š•œ) theorem closedBall_inv_subset_polar_closedBall {r : ā„} : closedBall (0 : StrongDual š•œ E) r⁻¹ āŠ† StrongDual.polar š•œ (closedBall (0 : E) r) := fun x' hx' x hx => calc ‖x' x‖ ≤ ‖x'‖ * ‖x‖ := x'.le_opNorm x _ ≤ r⁻¹ * r := (mul_le_mul (mem_closedBall_zero_iff.1 hx') (mem_closedBall_zero_iff.1 hx) (norm_nonneg _) (dist_nonneg.trans hx')) _ = r / r := inv_mul_eq_div _ _ _ ≤ 1 := div_self_le_one r /-- The `polar` of closed ball in a normed space `E` is the closed ball of the dual with inverse radius. -/ theorem polar_closedBall {š•œ E : Type*} [RCLike š•œ] [NormedAddCommGroup E] [NormedSpace š•œ E] {r : ā„} (hr : 0 < r) : StrongDual.polar š•œ (closedBall (0 : E) r) = closedBall (0 : StrongDual š•œ E) r⁻¹ := by refine Subset.antisymm ?_ (closedBall_inv_subset_polar_closedBall š•œ) intro x' h simp only [mem_closedBall_zero_iff] refine ContinuousLinearMap.opNorm_le_of_ball hr (inv_nonneg.mpr hr.le) fun z _ => ?_ simpa only [one_div] using LinearMap.bound_of_ball_bound' hr 1 x'.toLinearMap h z theorem polar_ball {š•œ E : Type*} [RCLike š•œ] [NormedAddCommGroup E] [NormedSpace š•œ E] {r : ā„} (hr : 0 < r) : StrongDual.polar š•œ (ball (0 : E) r) = closedBall (0 : StrongDual š•œ E) r⁻¹ := by apply le_antisymm Ā· intro x hx rw [mem_closedBall_zero_iff] apply le_of_forall_gt_imp_ge_of_dense intro a ha rw [← mem_closedBall_zero_iff, ← (mul_div_cancel_leftā‚€ a (Ne.symm (ne_of_lt hr)))] rw [← RCLike.norm_of_nonneg (K := š•œ) (le_trans zero_le_one (le_of_lt ((inv_lt_iff_one_lt_mulā‚€' hr).mp ha)))] apply polar_ball_subset_closedBall_div _ hr hx rw [RCLike.norm_of_nonneg (K := š•œ) (le_trans zero_le_one (le_of_lt ((inv_lt_iff_one_lt_mulā‚€' hr).mp ha)))] exact (inv_lt_iff_one_lt_mulā‚€' hr).mp ha Ā· rw [← polar_closedBall hr] exact LinearMap.polar_antitone _ ball_subset_closedBall /-- Given a neighborhood `s` of the origin in a normed space `E`, the dual norms of all elements of the polar `polar š•œ s` are bounded by a constant. -/ theorem isBounded_polar_of_mem_nhds_zero {s : Set E} (s_nhds : s ∈ š“ (0 : E)) : IsBounded (StrongDual.polar š•œ s) := by obtain ⟨a, ha⟩ : ∃ a : š•œ, 1 < ‖a‖ := NormedField.exists_one_lt_norm š•œ obtain ⟨r, r_pos, r_ball⟩ : ∃ r : ā„, 0 < r ∧ ball 0 r āŠ† s := Metric.mem_nhds_iff.1 s_nhds exact isBounded_closedBall.subset (((topDualPairing š•œ E).flip.polar_antitone r_ball).trans <| polar_ball_subset_closedBall_div ha r_pos) theorem sInter_polar_eq_closedBall {š•œ E : Type*} [RCLike š•œ] [NormedAddCommGroup E] [NormedSpace š•œ E] {r : ā„} (hr : 0 < r) : ā‹‚ā‚€ (StrongDual.polar š•œ '' { F | F.Finite ∧ F āŠ† closedBall (0 : E) r⁻¹ }) = closedBall 0 r := by conv_rhs => rw [← inv_inv r] rw [← polar_closedBall (inv_pos_of_pos hr), StrongDual.polar, (topDualPairing š•œ E).flip.sInter_polar_finite_subset_eq_polar (closedBall (0 : E) r⁻¹)] end PolarSets end NormedSpace namespace LinearMap section NormedField variable {š•œ E F : Type*} variable [RCLike š•œ] [AddCommMonoid E] [AddCommMonoid F] variable [Module š•œ E] [Module š•œ F] variable {B : E →ₗ[š•œ] F →ₗ[š•œ] š•œ} (s : Set E) open ComplexOrder in theorem polar_AbsConvex : AbsConvex š•œ (B.polar s) := by rw [polar_eq_biInter_preimage] exact AbsConvex.iInterā‚‚ fun i hi => ⟨balanced_closedBall_zero.mulActionHom_preimage (f := (B i : (F →ₑ[(RingHom.id š•œ)] š•œ))), (convex_RCLike_iff_convex_real.mpr (convex_closedBall 0 1)).linear_preimage _⟩ end NormedField end LinearMap
.lake/packages/mathlib/Mathlib/Analysis/Normed/Module/RCLike/Basic.lean
import Mathlib.Analysis.RCLike.Basic import Mathlib.Analysis.Normed.Module.RCLike.Real import Mathlib.Analysis.Normed.Operator.Basic /-! # Normed spaces over R or C This file is about results on normed spaces over the fields `ā„` and `ā„‚`. ## Main definitions None. ## Main theorems * `ContinuousLinearMap.opNorm_bound_of_ball_bound`: A bound on the norms of values of a linear map in a ball yields a bound on the operator norm. ## Notes This file exists mainly to avoid importing `RCLike` in the main normed space theory files. -/ open Metric variable {š•œ : Type*} [RCLike š•œ] {E : Type*} [NormedAddCommGroup E] theorem RCLike.norm_coe_norm {z : E} : ‖(‖z‖ : š•œ)‖ = ‖z‖ := by simp variable [NormedSpace š•œ E] /-- Lemma to normalize a vector in a normed space `E` over either `ā„‚` or `ā„` to unit length. -/ @[simp] theorem norm_smul_inv_norm {x : E} (hx : x ≠ 0) : ‖(‖x‖⁻¹ : š•œ) • x‖ = 1 := by have : ‖x‖ ≠ 0 := by simp [hx] simp [field, norm_smul] /-- Lemma to normalize a vector in a normed space `E` over either `ā„‚` or `ā„` to length `r`. -/ theorem norm_smul_inv_norm' {r : ā„} (r_nonneg : 0 ≤ r) {x : E} (hx : x ≠ 0) : ‖((r : š•œ) * (‖x‖ : š•œ)⁻¹) • x‖ = r := by have : ‖x‖ ≠ 0 := by simp [hx] simp [field, norm_smul, r_nonneg, rclike_simps] theorem LinearMap.bound_of_sphere_bound {r : ā„} (r_pos : 0 < r) (c : ā„) (f : E →ₗ[š•œ] š•œ) (h : āˆ€ z ∈ sphere (0 : E) r, ‖f z‖ ≤ c) (z : E) : ‖f z‖ ≤ c / r * ‖z‖ := by by_cases z_zero : z = 0 Ā· rw [z_zero] simp only [LinearMap.map_zero, norm_zero, mul_zero] exact le_rfl set z₁ := ((r : š•œ) * (‖z‖ : š•œ)⁻¹) • z with hz₁ have norm_f_z₁ : ‖f z₁‖ ≤ c := by apply h rw [mem_sphere_zero_iff_norm] exact norm_smul_inv_norm' r_pos.le z_zero have r_ne_zero : (r : š•œ) ≠ 0 := RCLike.ofReal_ne_zero.mpr r_pos.ne' have eq : f z = ‖z‖ / r * f z₁ := by rw [hz₁, LinearMap.map_smul, smul_eq_mul] rw [← mul_assoc, ← mul_assoc, div_mul_cancelā‚€ _ r_ne_zero, mul_inv_cancelā‚€, one_mul] simp only [z_zero, RCLike.ofReal_eq_zero, norm_eq_zero, Ne, not_false_iff] rw [eq, norm_mul, norm_div, RCLike.norm_coe_norm, RCLike.norm_of_nonneg r_pos.le, div_mul_eq_mul_div, div_mul_eq_mul_div, mul_comm] apply div_le_divā‚€ _ _ r_pos rfl.ge Ā· exact mul_nonneg ((norm_nonneg _).trans norm_f_z₁) (norm_nonneg z) apply mul_le_mul norm_f_z₁ rfl.le (norm_nonneg z) ((norm_nonneg _).trans norm_f_z₁) /-- `LinearMap.bound_of_ball_bound` is a version of this over arbitrary nontrivially normed fields. It produces a less precise bound so we keep both versions. -/ theorem LinearMap.bound_of_ball_bound' {r : ā„} (r_pos : 0 < r) (c : ā„) (f : E →ₗ[š•œ] š•œ) (h : āˆ€ z ∈ closedBall (0 : E) r, ‖f z‖ ≤ c) (z : E) : ‖f z‖ ≤ c / r * ‖z‖ := f.bound_of_sphere_bound r_pos c (fun z hz => h z hz.le) z theorem ContinuousLinearMap.opNorm_bound_of_ball_bound {r : ā„} (r_pos : 0 < r) (c : ā„) (f : StrongDual š•œ E) (h : āˆ€ z ∈ closedBall (0 : E) r, ‖f z‖ ≤ c) : ‖f‖ ≤ c / r := by apply ContinuousLinearMap.opNorm_le_bound Ā· apply div_nonneg _ r_pos.le exact (norm_nonneg _).trans (h 0 (by simp only [norm_zero, mem_closedBall, dist_zero_left, r_pos.le])) apply LinearMap.bound_of_ball_bound' r_pos exact fun z hz => h z hz variable (š•œ) include š•œ in theorem NormedSpace.sphere_nonempty_rclike [Nontrivial E] {r : ā„} (hr : 0 ≤ r) : Nonempty (sphere (0 : E) r) := letI : NormedSpace ā„ E := NormedSpace.restrictScalars ā„ š•œ E (NormedSpace.sphere_nonempty.mpr hr).coe_sort
.lake/packages/mathlib/Mathlib/Analysis/Normed/Module/RCLike/Extend.lean
import Mathlib.Analysis.RCLike.Extend import Mathlib.Analysis.Normed.Operator.Basic /-! # Norm properties of the extension of continuous `ā„`-linear functionals to `š•œ`-linear functionals This file shows that `ContinuousLinearMap.extendToš•œ` preserves the norm of the functional. -/ open RCLike open scoped ComplexConjugate namespace ContinuousLinearMap variable {š•œ F : Type*} [RCLike š•œ] [SeminormedAddCommGroup F] [NormedSpace š•œ F] section ScalarTower variable [NormedSpace ā„ F] [IsScalarTower ā„ š•œ F] /-- The norm of the extension is bounded by `‖fr‖`. -/ theorem norm_extendToš•œ'_bound (fr : StrongDual ā„ F) (x : F) : ‖(fr.extendToš•œ' x : š•œ)‖ ≤ ‖fr‖ * ‖x‖ := by set lm : F →L[š•œ] š•œ := fr.extendToš•œ' by_cases h : lm x = 0 Ā· rw [h, norm_zero] positivity rw [← mul_le_mul_iff_rightā‚€ (norm_pos_iff.2 h), ← sq] calc ‖lm x‖ ^ 2 = fr (conj (lm x : š•œ) • x) := fr.toLinearMap.norm_extendToš•œ'_apply_sq x _ ≤ ‖fr (conj (lm x : š•œ) • x)‖ := le_abs_self _ _ ≤ ‖fr‖ * ‖conj (lm x : š•œ) • x‖ := le_opNorm _ _ _ = ‖(lm x : š•œ)‖ * (‖fr‖ * ‖x‖) := by rw [norm_smul, norm_conj, mul_left_comm] @[simp] theorem norm_extendToš•œ' (fr : StrongDual ā„ F) : ‖(fr.extendToš•œ' : StrongDual š•œ F)‖ = ‖fr‖ := le_antisymm (ContinuousLinearMap.opNorm_le_bound _ (norm_nonneg _) fr.norm_extendToš•œ'_bound) <| opNorm_le_bound _ (norm_nonneg _) fun x => calc ‖fr x‖ = ‖re (fr.extendToš•œ' x : š•œ)‖ := congr_arg norm (fr.extendToš•œ'_apply_re x).symm _ ≤ ‖(fr.extendToš•œ' x : š•œ)‖ := abs_re_le_norm _ _ ≤ ‖(fr.extendToš•œ' : StrongDual š•œ F)‖ * ‖x‖ := le_opNorm _ _ end ScalarTower @[simp] theorem norm_extendToš•œ (fr : StrongDual ā„ (RestrictScalars ā„ š•œ F)) : ‖fr.extendToš•œā€– = ‖fr‖ := fr.norm_extendToš•œ' end ContinuousLinearMap
.lake/packages/mathlib/Mathlib/Analysis/Normed/Module/RCLike/Real.lean
import Mathlib.Analysis.Normed.Module.Basic import Mathlib.LinearAlgebra.Basis.VectorSpace /-! # Basic facts about real (semi)normed spaces In this file we prove some theorems about (semi)normed spaces over real numberes. ## Main results - `closure_ball`, `frontier_ball`, `interior_closedBall`, `frontier_closedBall`, `interior_sphere`, `frontier_sphere`: formulas for the closure/interior/frontier of nontrivial balls and spheres in a real seminormed space; - `interior_closedBall'`, `frontier_closedBall'`, `interior_sphere'`, `frontier_sphere'`: similar lemmas assuming that the ambient space is separated and nontrivial instead of `r ≠ 0`. -/ open Metric Set Function Filter open scoped NNReal Topology /-- If `E` is a nontrivial topological module over `ā„`, then `E` has no isolated points. This is a particular case of `Module.punctured_nhds_neBot`. -/ instance Real.punctured_nhds_module_neBot {E : Type*} [AddCommGroup E] [TopologicalSpace E] [ContinuousAdd E] [Nontrivial E] [Module ā„ E] [ContinuousSMul ā„ E] (x : E) : NeBot (š“[≠] x) := Module.punctured_nhds_neBot ā„ E x section Seminormed variable {E : Type*} [SeminormedAddCommGroup E] [NormedSpace ā„ E] theorem inv_norm_smul_mem_unitClosedBall (x : E) : ‖x‖⁻¹ • x ∈ closedBall (0 : E) 1 := by simp only [mem_closedBall_zero_iff, norm_smul, norm_inv, norm_norm, ← div_eq_inv_mul, div_self_le_one] theorem norm_smul_of_nonneg {t : ā„} (ht : 0 ≤ t) (x : E) : ‖t • x‖ = t * ‖x‖ := by rw [norm_smul, Real.norm_eq_abs, abs_of_nonneg ht] theorem dist_smul_add_one_sub_smul_le {r : ā„} {x y : E} (h : r ∈ Icc 0 1) : dist (r • x + (1 - r) • y) x ≤ dist y x := calc dist (r • x + (1 - r) • y) x = ‖1 - r‖ * ‖x - y‖ := by simp_rw [dist_eq_norm', ← norm_smul, sub_smul, one_smul, smul_sub, ← sub_sub, ← sub_add, sub_right_comm] _ = (1 - r) * dist y x := by rw [Real.norm_eq_abs, abs_eq_self.mpr (sub_nonneg.mpr h.2), dist_eq_norm'] _ ≤ (1 - 0) * dist y x := by gcongr; exact h.1 _ = dist y x := by rw [sub_zero, one_mul] theorem closure_ball (x : E) {r : ā„} (hr : r ≠ 0) : closure (ball x r) = closedBall x r := by refine Subset.antisymm closure_ball_subset_closedBall fun y hy => ?_ have : ContinuousWithinAt (fun c : ā„ => c • (y - x) + x) (Ico 0 1) 1 := ((continuous_id.smul continuous_const).add continuous_const).continuousWithinAt convert this.mem_closure _ _ Ā· rw [one_smul, sub_add_cancel] Ā· simp [closure_Ico zero_ne_one, zero_le_one] Ā· rintro c ⟨hc0, hc1⟩ rw [mem_ball, dist_eq_norm, add_sub_cancel_right, norm_smul, Real.norm_eq_abs, abs_of_nonneg hc0, mul_comm, ← mul_one r] rw [mem_closedBall, dist_eq_norm] at hy replace hr : 0 < r := ((norm_nonneg _).trans hy).lt_of_ne hr.symm apply mul_lt_mul' <;> assumption theorem frontier_ball (x : E) {r : ā„} (hr : r ≠ 0) : frontier (ball x r) = sphere x r := by rw [frontier, closure_ball x hr, isOpen_ball.interior_eq, closedBall_diff_ball] theorem interior_closedBall (x : E) {r : ā„} (hr : r ≠ 0) : interior (closedBall x r) = ball x r := by rcases hr.lt_or_gt with hr | hr Ā· rw [closedBall_eq_empty.2 hr, ball_eq_empty.2 hr.le, interior_empty] refine Subset.antisymm ?_ ball_subset_interior_closedBall intro y hy rcases (mem_closedBall.1 <| interior_subset hy).lt_or_eq with (hr | rfl) Ā· exact hr set f : ā„ → E := fun c : ā„ => c • (y - x) + x suffices f ⁻¹' closedBall x (dist y x) āŠ† Icc (-1) 1 by have hfc : Continuous f := (continuous_id.smul continuous_const).add continuous_const have hf1 : (1 : ā„) ∈ f ⁻¹' interior (closedBall x <| dist y x) := by simpa [f] have h1 : (1 : ā„) ∈ interior (Icc (-1 : ā„) 1) := interior_mono this (preimage_interior_subset_interior_preimage hfc hf1) simp at h1 intro c hc rw [mem_Icc, ← abs_le, ← Real.norm_eq_abs, ← mul_le_mul_iff_leftā‚€ hr] simpa [f, dist_eq_norm, norm_smul] using hc theorem frontier_closedBall (x : E) {r : ā„} (hr : r ≠ 0) : frontier (closedBall x r) = sphere x r := by rw [frontier, closure_closedBall, interior_closedBall x hr, closedBall_diff_ball] theorem interior_sphere (x : E) {r : ā„} (hr : r ≠ 0) : interior (sphere x r) = āˆ… := by rw [← frontier_closedBall x hr, interior_frontier isClosed_closedBall] theorem frontier_sphere (x : E) {r : ā„} (hr : r ≠ 0) : frontier (sphere x r) = sphere x r := by rw [isClosed_sphere.frontier_eq, interior_sphere x hr, diff_empty] end Seminormed section Normed variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ā„ E] [Nontrivial E] section Surj variable (E) theorem exists_norm_eq {c : ā„} (hc : 0 ≤ c) : ∃ x : E, ‖x‖ = c := by rcases exists_ne (0 : E) with ⟨x, hx⟩ rw [← norm_ne_zero_iff] at hx use c • ‖x‖⁻¹ • x simp [norm_smul, Real.norm_of_nonneg hc, inv_mul_cancelā‚€ hx] @[simp] theorem range_norm : range (norm : E → ā„) = Ici 0 := Subset.antisymm (range_subset_iff.2 norm_nonneg) fun _ => exists_norm_eq E theorem nnnorm_surjective : Surjective (nnnorm : E → ā„ā‰„0) := fun c => (exists_norm_eq E c.coe_nonneg).imp fun _ h => NNReal.eq h @[simp] theorem range_nnnorm : range (nnnorm : E → ā„ā‰„0) = univ := (nnnorm_surjective E).range_eq variable {E} in /-- In a nontrivial real normed space, a sphere is nonempty if and only if its radius is nonnegative. -/ @[simp] theorem NormedSpace.sphere_nonempty {x : E} {r : ā„} : (sphere x r).Nonempty ↔ 0 ≤ r := by refine ⟨fun h => nonempty_closedBall.1 (h.mono sphere_subset_closedBall), fun hr => ?_⟩ obtain ⟨y, hy⟩ := exists_norm_eq E hr exact ⟨x + y, by simpa using hy⟩ end Surj theorem interior_closedBall' (x : E) (r : ā„) : interior (closedBall x r) = ball x r := by rcases eq_or_ne r 0 with (rfl | hr) Ā· rw [closedBall_zero, ball_zero, interior_singleton] Ā· exact interior_closedBall x hr theorem frontier_closedBall' (x : E) (r : ā„) : frontier (closedBall x r) = sphere x r := by rw [frontier, closure_closedBall, interior_closedBall' x r, closedBall_diff_ball] @[simp] theorem interior_sphere' (x : E) (r : ā„) : interior (sphere x r) = āˆ… := by rw [← frontier_closedBall' x, interior_frontier isClosed_closedBall] @[simp] theorem frontier_sphere' (x : E) (r : ā„) : frontier (sphere x r) = sphere x r := by rw [isClosed_sphere.frontier_eq, interior_sphere' x, diff_empty] end Normed
.lake/packages/mathlib/Mathlib/Analysis/Normed/Module/Ball/Homeomorph.lean
import Mathlib.Topology.OpenPartialHomeomorph import Mathlib.Analysis.Normed.Group.AddTorsor import Mathlib.Analysis.Normed.Module.Ball.Pointwise import Mathlib.Data.Real.Sqrt /-! # (Local) homeomorphism between a normed space and a ball In this file we show that a real (semi)normed vector space is homeomorphic to the unit ball. We formalize it in two ways: - as a `Homeomorph`, see `Homeomorph.unitBall`; - as an `OpenPartialHomeomorph` with `source = Set.univ` and `target = Metric.ball (0 : E) 1`. While the former approach is more natural, the latter approach provides us with a globally defined inverse function which makes it easier to say that this homeomorphism is in fact a diffeomorphism. We also show that the unit ball `Metric.ball (0 : E) 1` is homeomorphic to a ball of positive radius in an affine space over `E`, see `OpenPartialHomeomorph.unitBallBall`. ## Tags homeomorphism, ball -/ open Set Metric Pointwise variable {E : Type*} [SeminormedAddCommGroup E] [NormedSpace ā„ E] noncomputable section /-- Local homeomorphism between a real (semi)normed space and the unit ball. See also `Homeomorph.unitBall`. -/ @[simps -isSimp] def OpenPartialHomeomorph.univUnitBall : OpenPartialHomeomorph E E where toFun x := (√(1 + ‖x‖ ^ 2))⁻¹ • x invFun y := (√(1 - ‖(y : E)‖ ^ 2))⁻¹ • (y : E) source := univ target := ball 0 1 map_source' x _ := by have : 0 < 1 + ‖x‖ ^ 2 := by positivity rw [mem_ball_zero_iff, norm_smul, Real.norm_eq_abs, abs_inv, ← _root_.div_eq_inv_mul, div_lt_one (abs_pos.mpr <| Real.sqrt_ne_zero'.mpr this), ← abs_norm x, ← sq_lt_sq, abs_norm, Real.sq_sqrt this.le] exact lt_one_add _ map_target' _ _ := trivial left_inv' x _ := by match_scalars simp [norm_smul] field_simp simp [sq_abs, Real.sq_sqrt (zero_lt_one_add_norm_sq x).le] right_inv' y hy := by have : 0 < 1 - ‖y‖ ^ 2 := by nlinarith [norm_nonneg y, mem_ball_zero_iff.1 hy] match_scalars simp [norm_smul] field_simp simp [field, sq_abs, Real.sq_sqrt this.le] open_source := isOpen_univ open_target := isOpen_ball continuousOn_toFun := by suffices Continuous fun (x : E) => (√(1 + ‖x‖ ^ 2))⁻¹ by fun_prop exact Continuous.invā‚€ (by fun_prop) fun x => Real.sqrt_ne_zero'.mpr (by positivity) continuousOn_invFun := by have : āˆ€ y ∈ ball (0 : E) 1, √(1 - ‖(y : E)‖ ^ 2) ≠ 0 := fun y hy ↦ by rw [Real.sqrt_ne_zero'] nlinarith [norm_nonneg y, mem_ball_zero_iff.1 hy] exact ContinuousOn.smul (ContinuousOn.invā‚€ (continuousOn_const.sub (continuous_norm.continuousOn.pow _)).sqrt this) continuousOn_id @[simp] theorem OpenPartialHomeomorph.univUnitBall_apply_zero : univUnitBall (0 : E) = 0 := by simp [OpenPartialHomeomorph.univUnitBall_apply] @[simp] theorem OpenPartialHomeomorph.univUnitBall_symm_apply_zero : univUnitBall.symm (0 : E) = 0 := by simp [OpenPartialHomeomorph.univUnitBall_symm_apply] /-- A (semi) normed real vector space is homeomorphic to the unit ball in the same space. This homeomorphism sends `x : E` to `(1 + ‖x‖²)^(- ½) • x`. In many cases the actual implementation is not important, so we don't mark the projection lemmas `Homeomorph.unitBall_apply_coe` and `Homeomorph.unitBall_symm_apply` as `@[simp]`. See also `Homeomorph.contDiff_unitBall` and `OpenPartialHomeomorph.contDiffOn_unitBall_symm` for smoothness properties that hold when `E` is an inner-product space. -/ @[simps! -isSimp] def Homeomorph.unitBall : E ā‰ƒā‚œ ball (0 : E) 1 := (Homeomorph.Set.univ _).symm.trans OpenPartialHomeomorph.univUnitBall.toHomeomorphSourceTarget @[simp] theorem Homeomorph.coe_unitBall_apply_zero : (Homeomorph.unitBall (0 : E) : E) = 0 := OpenPartialHomeomorph.univUnitBall_apply_zero variable {P : Type*} [PseudoMetricSpace P] [NormedAddTorsor E P] namespace OpenPartialHomeomorph /-- Affine homeomorphism `(r • Ā· +ᵄ c)` between a normed space and an add torsor over this space, interpreted as an `OpenPartialHomeomorph` between `Metric.ball 0 1` and `Metric.ball c r`. -/ @[simps!] def unitBallBall (c : P) (r : ā„) (hr : 0 < r) : OpenPartialHomeomorph E P := ((Homeomorph.smulOfNeZero r hr.ne').trans (IsometryEquiv.vaddConst c).toHomeomorph).toOpenPartialHomeomorphOfImageEq (ball 0 1) isOpen_ball (ball c r) <| by change (IsometryEquiv.vaddConst c) ∘ (r • Ā·) '' ball (0 : E) 1 = ball c r rw [image_comp, image_smul, smul_unitBall hr.ne', IsometryEquiv.image_ball] simp [abs_of_pos hr] /-- If `r > 0`, then `OpenPartialHomeomorph.univBall c r` is a smooth open partial homeomorphism with `source = Set.univ` and `target = Metric.ball c r`. Otherwise, it is the translation by `c`. Thus in all cases, it sends `0` to `c`, see `OpenPartialHomeomorph.univBall_apply_zero`. -/ def univBall (c : P) (r : ā„) : OpenPartialHomeomorph E P := if h : 0 < r then univUnitBall.trans' (unitBallBall c r h) rfl else (IsometryEquiv.vaddConst c).toHomeomorph.toOpenPartialHomeomorph @[simp] theorem univBall_source (c : P) (r : ā„) : (univBall c r).source = univ := by unfold univBall; split_ifs <;> rfl theorem univBall_target (c : P) {r : ā„} (hr : 0 < r) : (univBall c r).target = ball c r := by rw [univBall, dif_pos hr]; rfl theorem ball_subset_univBall_target (c : P) (r : ā„) : ball c r āŠ† (univBall c r).target := by by_cases hr : 0 < r Ā· rw [univBall_target c hr] Ā· rw [univBall, dif_neg hr] exact subset_univ _ @[simp] theorem univBall_apply_zero (c : P) (r : ā„) : univBall c r 0 = c := by unfold univBall; split_ifs <;> simp @[simp] theorem univBall_symm_apply_center (c : P) (r : ā„) : (univBall c r).symm c = 0 := by have : 0 ∈ (univBall c r).source := by simp simpa only [univBall_apply_zero] using (univBall c r).left_inv this @[continuity] theorem continuous_univBall (c : P) (r : ā„) : Continuous (univBall c r) := by simpa [continuousOn_univ] using (univBall c r).continuousOn theorem continuousOn_univBall_symm (c : P) (r : ā„) : ContinuousOn (univBall c r).symm (ball c r) := (univBall c r).symm.continuousOn.mono <| ball_subset_univBall_target c r end OpenPartialHomeomorph
.lake/packages/mathlib/Mathlib/Analysis/Normed/Module/Ball/RadialEquiv.lean
import Mathlib.Analysis.Normed.Module.Basic import Mathlib.LinearAlgebra.Basis.VectorSpace /-! # Homeomorphism between a normed space and sphere times `(0, +āˆž)` In this file we define a homeomorphism between nonzero elements of a normed space `E` and `Metric.sphere (0 : E) 1 Ɨ Set.Ioi (0 : ā„)`. One may think about it as generalization of polar coordinates to any normed space. -/ variable (E : Type*) [NormedAddCommGroup E] [NormedSpace ā„ E] open Set Metric /-- The natural homeomorphism between nonzero elements of a normed space `E` and `Metric.sphere (0 : E) 1 Ɨ Set.Ioi (0 : ā„)`. The forward map sends `⟨x, hx⟩` to `āŸØā€–x‖⁻¹ • x, ‖xā€–āŸ©`, the inverse map sends `(x, r)` to `r • x`. One may think about it as generalization of polar coordinates to any normed space. -/ @[simps apply_fst_coe apply_snd_coe symm_apply_coe] noncomputable def homeomorphUnitSphereProd : ({0}ᶜ : Set E) ā‰ƒā‚œ (sphere (0 : E) 1 Ɨ Ioi (0 : ā„)) where toFun x := (āŸØā€–x.1‖⁻¹ • x.1, by rw [mem_sphere_zero_iff_norm, norm_smul, norm_inv, norm_norm, inv_mul_cancelā‚€ (norm_ne_zero_iff.2 x.2)]⟩, āŸØā€–x.1‖, norm_pos_iff.2 x.2⟩) invFun x := ⟨x.2.1 • x.1.1, smul_ne_zero x.2.2.out.ne' (ne_of_mem_sphere x.1.2 one_ne_zero)⟩ left_inv x := Subtype.eq <| by simp [smul_inv_smulā‚€ (norm_ne_zero_iff.2 x.2)] right_inv | (⟨x, hx⟩, ⟨r, hr⟩) => by rw [mem_sphere_zero_iff_norm] at hx rw [mem_Ioi] at hr ext <;> simp [hx, norm_smul, abs_of_pos hr, hr.ne'] continuous_toFun := by refine .prodMk (.codRestrict (.smul (.invā‚€ ?_ ?_) ?_) _) ?_ Ā· fun_prop Ā· simp Ā· fun_prop Ā· fun_prop continuous_invFun := by apply Continuous.subtype_mk (by fun_prop)
.lake/packages/mathlib/Mathlib/Analysis/Normed/Module/Ball/Pointwise.lean
import Mathlib.Analysis.Normed.Group.Pointwise import Mathlib.Analysis.Normed.Module.RCLike.Real /-! # Properties of pointwise scalar multiplication of sets in normed spaces. We explore the relationships between scalar multiplication of sets in vector spaces, and the norm. Notably, we express arbitrary balls as rescaling of other balls, and we show that the multiplication of bounded sets remain bounded. -/ open Metric Set open Pointwise Topology variable {š•œ E : Type*} section SMulZeroClass variable [SeminormedAddCommGroup š•œ] [SeminormedAddCommGroup E] variable [SMulZeroClass š•œ E] [IsBoundedSMul š•œ E] theorem ediam_smul_le (c : š•œ) (s : Set E) : EMetric.diam (c • s) ≤ ‖cā€–ā‚Š • EMetric.diam s := (lipschitzWith_smul c).ediam_image_le s end SMulZeroClass section DivisionRing variable [NormedDivisionRing š•œ] [SeminormedAddCommGroup E] variable [Module š•œ E] [NormSMulClass š•œ E] theorem ediam_smulā‚€ (c : š•œ) (s : Set E) : EMetric.diam (c • s) = ‖cā€–ā‚Š • EMetric.diam s := by refine le_antisymm (ediam_smul_le c s) ?_ obtain rfl | hc := eq_or_ne c 0 Ā· obtain rfl | hs := s.eq_empty_or_nonempty Ā· simp simp [zero_smul_set hs, ← Set.singleton_zero] Ā· have := (lipschitzWith_smul c⁻¹).ediam_image_le (c • s) rwa [← smul_eq_mul, ← ENNReal.smul_def, Set.image_smul, inv_smul_smulā‚€ hc s, nnnorm_inv, le_inv_smul_iff_of_pos (nnnorm_pos.2 hc)] at this theorem diam_smulā‚€ (c : š•œ) (x : Set E) : diam (c • x) = ‖c‖ * diam x := by simp_rw [diam, ediam_smulā‚€, ENNReal.toReal_smul, NNReal.smul_def, coe_nnnorm, smul_eq_mul] theorem infEdist_smulā‚€ {c : š•œ} (hc : c ≠ 0) (s : Set E) (x : E) : EMetric.infEdist (c • x) (c • s) = ‖cā€–ā‚Š • EMetric.infEdist x s := by simp_rw [EMetric.infEdist] have : Function.Surjective ((c • Ā·) : E → E) := Function.RightInverse.surjective (smul_inv_smulā‚€ hc) trans ⨅ (y) (_ : y ∈ s), ‖cā€–ā‚Š • edist x y Ā· refine (this.iInf_congr _ fun y => ?_).symm simp_rw [smul_mem_smul_set_iffā‚€ hc, edist_smulā‚€] Ā· have : (‖cā€–ā‚Š : ENNReal) ≠ 0 := by simp [hc] simp_rw [ENNReal.smul_def, smul_eq_mul, ENNReal.mul_iInf_of_ne this ENNReal.coe_ne_top] theorem infDist_smulā‚€ {c : š•œ} (hc : c ≠ 0) (s : Set E) (x : E) : Metric.infDist (c • x) (c • s) = ‖c‖ * Metric.infDist x s := by simp_rw [Metric.infDist, infEdist_smulā‚€ hc s, ENNReal.toReal_smul, NNReal.smul_def, coe_nnnorm, smul_eq_mul] end DivisionRing variable [NormedField š•œ] section SeminormedAddCommGroup variable [SeminormedAddCommGroup E] [NormedSpace š•œ E] theorem smul_ball {c : š•œ} (hc : c ≠ 0) (x : E) (r : ā„) : c • ball x r = ball (c • x) (‖c‖ * r) := by ext y rw [mem_smul_set_iff_inv_smul_memā‚€ hc] conv_lhs => rw [← inv_smul_smulā‚€ hc x] simp [← div_eq_inv_mul, div_lt_iffā‚€ (norm_pos_iff.2 hc), mul_comm _ r, dist_smulā‚€] theorem smul_unitBall {c : š•œ} (hc : c ≠ 0) : c • ball (0 : E) (1 : ā„) = ball (0 : E) ‖c‖ := by rw [_root_.smul_ball hc, smul_zero, mul_one] theorem smul_sphere' {c : š•œ} (hc : c ≠ 0) (x : E) (r : ā„) : c • sphere x r = sphere (c • x) (‖c‖ * r) := by ext y rw [mem_smul_set_iff_inv_smul_memā‚€ hc] conv_lhs => rw [← inv_smul_smulā‚€ hc x] simp only [mem_sphere, dist_smulā‚€, norm_inv, ← div_eq_inv_mul, div_eq_iff (norm_pos_iff.2 hc).ne', mul_comm r] theorem smul_closedBall' {c : š•œ} (hc : c ≠ 0) (x : E) (r : ā„) : c • closedBall x r = closedBall (c • x) (‖c‖ * r) := by simp only [← ball_union_sphere, Set.smul_set_union, _root_.smul_ball hc, smul_sphere' hc] theorem set_smul_sphere_zero {s : Set š•œ} (hs : 0 āˆ‰ s) (r : ā„) : s • sphere (0 : E) r = (‖·‖) ⁻¹' ((‖·‖ * r) '' s) := calc s • sphere (0 : E) r = ā‹ƒ c ∈ s, c • sphere (0 : E) r := iUnion_smul_left_image.symm _ = ā‹ƒ c ∈ s, sphere (0 : E) (‖c‖ * r) := iUnionā‚‚_congr fun c hc ↦ by rw [smul_sphere' (ne_of_mem_of_not_mem hc hs), smul_zero] _ = (‖·‖) ⁻¹' ((‖·‖ * r) '' s) := by ext; simp [eq_comm] /-- Image of a bounded set in a normed space under scalar multiplication by a constant is bounded. See also `Bornology.IsBounded.smul` for a similar lemma about an isometric action. -/ theorem Bornology.IsBounded.smulā‚€ {s : Set E} (hs : IsBounded s) (c : š•œ) : IsBounded (c • s) := (lipschitzWith_smul c).isBounded_image hs /-- If `s` is a bounded set, then for small enough `r`, the set `{x} + r • s` is contained in any fixed neighborhood of `x`. -/ theorem eventually_singleton_add_smul_subset {x : E} {s : Set E} (hs : Bornology.IsBounded s) {u : Set E} (hu : u ∈ š“ x) : āˆ€į¶  r in š“ (0 : š•œ), {x} + r • s āŠ† u := by obtain ⟨ε, εpos, hε⟩ : ∃ ε : ā„, 0 < ε ∧ closedBall x ε āŠ† u := nhds_basis_closedBall.mem_iff.1 hu obtain ⟨R, Rpos, hR⟩ : ∃ R : ā„, 0 < R ∧ s āŠ† closedBall 0 R := hs.subset_closedBall_lt 0 0 have : Metric.closedBall (0 : š•œ) (ε / R) ∈ š“ (0 : š•œ) := closedBall_mem_nhds _ (div_pos εpos Rpos) filter_upwards [this] with r hr simp only [image_add_left, singleton_add] intro y hy obtain ⟨z, zs, hz⟩ : ∃ z : E, z ∈ s ∧ r • z = -x + y := by simpa [mem_smul_set] using hy have I : ‖r • z‖ ≤ ε := calc ‖r • z‖ = ‖r‖ * ‖z‖ := norm_smul _ _ _ ≤ ε / R * R := by gcongr exacts [mem_closedBall_zero_iff.1 hr, mem_closedBall_zero_iff.1 (hR zs)] _ = ε := by field have : y = x + r • z := by simp only [hz, add_neg_cancel_left] apply hε simpa only [this, dist_eq_norm, add_sub_cancel_left, mem_closedBall] using I variable [NormedSpace ā„ E] {x y z : E} {Ī“ ε : ā„} /-- In a real normed space, the image of the unit ball under scalar multiplication by a positive constant `r` is the ball of radius `r`. -/ theorem smul_unitBall_of_pos {r : ā„} (hr : 0 < r) : r • ball (0 : E) 1 = ball (0 : E) r := by rw [smul_unitBall hr.ne', Real.norm_of_nonneg hr.le] lemma Ioo_smul_sphere_zero {a b r : ā„} (ha : 0 ≤ a) (hr : 0 < r) : Ioo a b • sphere (0 : E) r = ball 0 (b * r) \ closedBall 0 (a * r) := by have : EqOn (‖·‖) id (Ioo a b) := fun x hx ↦ abs_of_pos (ha.trans_lt hx.1) rw [set_smul_sphere_zero (by simp [ha.not_gt]), ← image_image (Ā· * r), this.image_eq, image_id, image_mul_right_Ioo _ _ hr] ext x; simp [and_comm] -- This is also true for `ā„š`-normed spaces theorem exists_dist_eq (x z : E) {a b : ā„} (ha : 0 ≤ a) (hb : 0 ≤ b) (hab : a + b = 1) : ∃ y, dist x y = b * dist x z ∧ dist y z = a * dist x z := by use a • x + b • z nth_rw 1 [← one_smul ā„ x] nth_rw 4 [← one_smul ā„ z] simp [dist_eq_norm, ← hab, add_smul, ← smul_sub, norm_smul_of_nonneg, ha, hb] theorem exists_dist_le_le (hĪ“ : 0 ≤ Ī“) (hε : 0 ≤ ε) (h : dist x z ≤ ε + Ī“) : ∃ y, dist x y ≤ Ī“ ∧ dist y z ≤ ε := by obtain rfl | hε' := hε.eq_or_lt Ā· exact ⟨z, by rwa [zero_add] at h, (dist_self _).le⟩ have hεΓ := add_pos_of_pos_of_nonneg hε' hĪ“ refine (exists_dist_eq x z (div_nonneg hε <| add_nonneg hε hĪ“) (div_nonneg hĪ“ <| add_nonneg hε hĪ“) <| by rw [← add_div, div_self hεΓ.ne']).imp fun y hy => ?_ rw [hy.1, hy.2, div_mul_comm, div_mul_comm ε] rw [← div_le_one hεΓ] at h exact ⟨mul_le_of_le_one_left hĪ“ h, mul_le_of_le_one_left hε h⟩ -- This is also true for `ā„š`-normed spaces theorem exists_dist_le_lt (hĪ“ : 0 ≤ Ī“) (hε : 0 < ε) (h : dist x z < ε + Ī“) : ∃ y, dist x y ≤ Ī“ ∧ dist y z < ε := by refine (exists_dist_eq x z (div_nonneg hε.le <| add_nonneg hε.le hĪ“) (div_nonneg hĪ“ <| add_nonneg hε.le hĪ“) <| by rw [← add_div, div_self (add_pos_of_pos_of_nonneg hε hĪ“).ne']).imp fun y hy => ?_ rw [hy.1, hy.2, div_mul_comm, div_mul_comm ε] rw [← div_lt_one (add_pos_of_pos_of_nonneg hε hĪ“)] at h exact ⟨mul_le_of_le_one_left hĪ“ h.le, mul_lt_of_lt_one_left hε h⟩ -- This is also true for `ā„š`-normed spaces theorem exists_dist_lt_le (hĪ“ : 0 < Ī“) (hε : 0 ≤ ε) (h : dist x z < ε + Ī“) : ∃ y, dist x y < Ī“ ∧ dist y z ≤ ε := by obtain ⟨y, yz, xy⟩ := exists_dist_le_lt hε hĪ“ (show dist z x < Ī“ + ε by simpa only [dist_comm, add_comm] using h) exact ⟨y, by simp [dist_comm x y, dist_comm y z, *]⟩ -- This is also true for `ā„š`-normed spaces theorem exists_dist_lt_lt (hĪ“ : 0 < Ī“) (hε : 0 < ε) (h : dist x z < ε + Ī“) : ∃ y, dist x y < Ī“ ∧ dist y z < ε := by refine (exists_dist_eq x z (div_nonneg hε.le <| add_nonneg hε.le hĪ“.le) (div_nonneg hĪ“.le <| add_nonneg hε.le hĪ“.le) <| by rw [← add_div, div_self (add_pos hε hĪ“).ne']).imp fun y hy => ?_ rw [hy.1, hy.2, div_mul_comm, div_mul_comm ε] rw [← div_lt_one (add_pos hε hĪ“)] at h exact ⟨mul_lt_of_lt_one_left hĪ“ h, mul_lt_of_lt_one_left hε h⟩ -- This is also true for `ā„š`-normed spaces theorem disjoint_ball_ball_iff (hĪ“ : 0 < Ī“) (hε : 0 < ε) : Disjoint (ball x Ī“) (ball y ε) ↔ Ī“ + ε ≤ dist x y := by refine ⟨fun h => le_of_not_gt fun hxy => ?_, ball_disjoint_ball⟩ rw [add_comm] at hxy obtain ⟨z, hxz, hzy⟩ := exists_dist_lt_lt hĪ“ hε hxy rw [dist_comm] at hxz exact h.le_bot ⟨hxz, hzy⟩ -- This is also true for `ā„š`-normed spaces theorem disjoint_ball_closedBall_iff (hĪ“ : 0 < Ī“) (hε : 0 ≤ ε) : Disjoint (ball x Ī“) (closedBall y ε) ↔ Ī“ + ε ≤ dist x y := by refine ⟨fun h => le_of_not_gt fun hxy => ?_, ball_disjoint_closedBall⟩ rw [add_comm] at hxy obtain ⟨z, hxz, hzy⟩ := exists_dist_lt_le hĪ“ hε hxy rw [dist_comm] at hxz exact h.le_bot ⟨hxz, hzy⟩ -- This is also true for `ā„š`-normed spaces theorem disjoint_closedBall_ball_iff (hĪ“ : 0 ≤ Ī“) (hε : 0 < ε) : Disjoint (closedBall x Ī“) (ball y ε) ↔ Ī“ + ε ≤ dist x y := by rw [disjoint_comm, disjoint_ball_closedBall_iff hε hĪ“, add_comm, dist_comm] theorem disjoint_closedBall_closedBall_iff (hĪ“ : 0 ≤ Ī“) (hε : 0 ≤ ε) : Disjoint (closedBall x Ī“) (closedBall y ε) ↔ Ī“ + ε < dist x y := by refine ⟨fun h => lt_of_not_ge fun hxy => ?_, closedBall_disjoint_closedBall⟩ rw [add_comm] at hxy obtain ⟨z, hxz, hzy⟩ := exists_dist_le_le hĪ“ hε hxy rw [dist_comm] at hxz exact h.le_bot ⟨hxz, hzy⟩ open EMetric ENNReal @[simp] theorem infEdist_thickening (hĪ“ : 0 < Ī“) (s : Set E) (x : E) : infEdist x (thickening Ī“ s) = infEdist x s - ENNReal.ofReal Ī“ := by obtain hs | hs := lt_or_ge (infEdist x s) (ENNReal.ofReal Ī“) Ā· rw [infEdist_zero_of_mem, tsub_eq_zero_of_le hs.le] exact hs refine (tsub_le_iff_right.2 infEdist_le_infEdist_thickening_add).antisymm' ?_ refine le_sub_of_add_le_right ofReal_ne_top ?_ refine le_infEdist.2 fun z hz => le_of_forall_gt fun r h => ?_ cases r with | top => exact add_lt_top.2 ⟨lt_top_iff_ne_top.2 <| infEdist_ne_top ⟨z, self_subset_thickening hĪ“ _ hz⟩, ofReal_lt_top⟩ | coe r => have hr : 0 < ↑r - Ī“ := by refine sub_pos_of_lt ?_ have := hs.trans_lt ((infEdist_le_edist_of_mem hz).trans_lt h) rw [ofReal_eq_coe_nnreal hĪ“.le] at this exact mod_cast this rw [edist_lt_coe, ← dist_lt_coe, ← add_sub_cancel Ī“ ↑r] at h obtain ⟨y, hxy, hyz⟩ := exists_dist_lt_lt hr hĪ“ h refine (ENNReal.add_lt_add_right ofReal_ne_top <| infEdist_lt_iff.2 ⟨_, mem_thickening_iff.2 ⟨_, hz, hyz⟩, edist_lt_ofReal.2 hxy⟩).trans_le ?_ rw [← ofReal_add hr.le hĪ“.le, sub_add_cancel, ofReal_coe_nnreal] @[simp] theorem thickening_thickening (hε : 0 < ε) (hĪ“ : 0 < Ī“) (s : Set E) : thickening ε (thickening Ī“ s) = thickening (ε + Ī“) s := (thickening_thickening_subset _ _ _).antisymm fun x => by simp_rw [mem_thickening_iff] rintro ⟨z, hz, hxz⟩ rw [add_comm] at hxz obtain ⟨y, hxy, hyz⟩ := exists_dist_lt_lt hε hĪ“ hxz exact ⟨y, ⟨_, hz, hyz⟩, hxy⟩ @[simp] theorem cthickening_thickening (hε : 0 ≤ ε) (hĪ“ : 0 < Ī“) (s : Set E) : cthickening ε (thickening Ī“ s) = cthickening (ε + Ī“) s := (cthickening_thickening_subset hε _ _).antisymm fun x => by simp_rw [mem_cthickening_iff, ENNReal.ofReal_add hε hĪ“.le, infEdist_thickening hĪ“] exact tsub_le_iff_right.2 -- Note: `interior (cthickening Ī“ s) ≠ thickening Ī“ s` in general @[simp] theorem closure_thickening (hĪ“ : 0 < Ī“) (s : Set E) : closure (thickening Ī“ s) = cthickening Ī“ s := by rw [← cthickening_zero, cthickening_thickening le_rfl hĪ“, zero_add] @[simp] theorem infEdist_cthickening (Ī“ : ā„) (s : Set E) (x : E) : infEdist x (cthickening Ī“ s) = infEdist x s - ENNReal.ofReal Ī“ := by obtain hĪ“ | hĪ“ := le_or_gt Ī“ 0 Ā· rw [cthickening_of_nonpos hĪ“, infEdist_closure, ofReal_of_nonpos hĪ“, tsub_zero] Ā· rw [← closure_thickening hĪ“, infEdist_closure, infEdist_thickening hĪ“] @[simp] theorem thickening_cthickening (hε : 0 < ε) (hĪ“ : 0 ≤ Ī“) (s : Set E) : thickening ε (cthickening Ī“ s) = thickening (ε + Ī“) s := by obtain rfl | hĪ“ := hĪ“.eq_or_lt Ā· rw [cthickening_zero, thickening_closure, add_zero] Ā· rw [← closure_thickening hĪ“, thickening_closure, thickening_thickening hε hĪ“] @[simp] theorem cthickening_cthickening (hε : 0 ≤ ε) (hĪ“ : 0 ≤ Ī“) (s : Set E) : cthickening ε (cthickening Ī“ s) = cthickening (ε + Ī“) s := (cthickening_cthickening_subset hε hĪ“ _).antisymm fun x => by simp_rw [mem_cthickening_iff, ENNReal.ofReal_add hε hĪ“, infEdist_cthickening] exact tsub_le_iff_right.2 @[simp] theorem thickening_ball (hε : 0 < ε) (hĪ“ : 0 < Ī“) (x : E) : thickening ε (ball x Ī“) = ball x (ε + Ī“) := by rw [← thickening_singleton, thickening_thickening hε hĪ“, thickening_singleton] @[simp] theorem thickening_closedBall (hε : 0 < ε) (hĪ“ : 0 ≤ Ī“) (x : E) : thickening ε (closedBall x Ī“) = ball x (ε + Ī“) := by rw [← cthickening_singleton _ hĪ“, thickening_cthickening hε hĪ“, thickening_singleton] @[simp] theorem cthickening_ball (hε : 0 ≤ ε) (hĪ“ : 0 < Ī“) (x : E) : cthickening ε (ball x Ī“) = closedBall x (ε + Ī“) := by rw [← thickening_singleton, cthickening_thickening hε hĪ“, cthickening_singleton _ (add_nonneg hε hĪ“.le)] @[simp] theorem cthickening_closedBall (hε : 0 ≤ ε) (hĪ“ : 0 ≤ Ī“) (x : E) : cthickening ε (closedBall x Ī“) = closedBall x (ε + Ī“) := by rw [← cthickening_singleton _ hĪ“, cthickening_cthickening hε hĪ“, cthickening_singleton _ (add_nonneg hε hĪ“)] theorem ball_add_ball (hε : 0 < ε) (hĪ“ : 0 < Ī“) (a b : E) : ball a ε + ball b Ī“ = ball (a + b) (ε + Ī“) := by rw [ball_add, thickening_ball hε hĪ“ b, Metric.vadd_ball, vadd_eq_add] theorem ball_sub_ball (hε : 0 < ε) (hĪ“ : 0 < Ī“) (a b : E) : ball a ε - ball b Ī“ = ball (a - b) (ε + Ī“) := by simp_rw [sub_eq_add_neg, neg_ball, ball_add_ball hε hĪ“] theorem ball_add_closedBall (hε : 0 < ε) (hĪ“ : 0 ≤ Ī“) (a b : E) : ball a ε + closedBall b Ī“ = ball (a + b) (ε + Ī“) := by rw [ball_add, thickening_closedBall hε hĪ“ b, Metric.vadd_ball, vadd_eq_add] theorem ball_sub_closedBall (hε : 0 < ε) (hĪ“ : 0 ≤ Ī“) (a b : E) : ball a ε - closedBall b Ī“ = ball (a - b) (ε + Ī“) := by simp_rw [sub_eq_add_neg, neg_closedBall, ball_add_closedBall hε hĪ“] theorem closedBall_add_ball (hε : 0 ≤ ε) (hĪ“ : 0 < Ī“) (a b : E) : closedBall a ε + ball b Ī“ = ball (a + b) (ε + Ī“) := by rw [add_comm, ball_add_closedBall hĪ“ hε b, add_comm, add_comm Ī“] theorem closedBall_sub_ball (hε : 0 ≤ ε) (hĪ“ : 0 < Ī“) (a b : E) : closedBall a ε - ball b Ī“ = ball (a - b) (ε + Ī“) := by simp_rw [sub_eq_add_neg, neg_ball, closedBall_add_ball hε hĪ“] theorem closedBall_add_closedBall [ProperSpace E] (hε : 0 ≤ ε) (hĪ“ : 0 ≤ Ī“) (a b : E) : closedBall a ε + closedBall b Ī“ = closedBall (a + b) (ε + Ī“) := by rw [(isCompact_closedBall _ _).add_closedBall hĪ“ b, cthickening_closedBall hĪ“ hε a, Metric.vadd_closedBall, vadd_eq_add, add_comm, add_comm Ī“] theorem closedBall_sub_closedBall [ProperSpace E] (hε : 0 ≤ ε) (hĪ“ : 0 ≤ Ī“) (a b : E) : closedBall a ε - closedBall b Ī“ = closedBall (a - b) (ε + Ī“) := by rw [sub_eq_add_neg, neg_closedBall, closedBall_add_closedBall hε hĪ“, sub_eq_add_neg] end SeminormedAddCommGroup section NormedAddCommGroup variable [NormedAddCommGroup E] [NormedSpace š•œ E] theorem smul_closedBall (c : š•œ) (x : E) {r : ā„} (hr : 0 ≤ r) : c • closedBall x r = closedBall (c • x) (‖c‖ * r) := by rcases eq_or_ne c 0 with (rfl | hc) Ā· simp [hr, zero_smul_set, Set.singleton_zero, nonempty_closedBall] Ā· exact smul_closedBall' hc x r theorem smul_unitClosedBall (c : š•œ) : c • closedBall (0 : E) (1 : ā„) = closedBall (0 : E) ‖c‖ := by rw [_root_.smul_closedBall _ _ zero_le_one, smul_zero, mul_one] variable [NormedSpace ā„ E] /-- In a real normed space, the image of the unit closed ball under multiplication by a nonnegative number `r` is the closed ball of radius `r` with center at the origin. -/ theorem smul_unitClosedBall_of_nonneg {r : ā„} (hr : 0 ≤ r) : r • closedBall (0 : E) 1 = closedBall (0 : E) r := by rw [smul_unitClosedBall, Real.norm_of_nonneg hr] theorem smul_sphere [Nontrivial E] (c : š•œ) (x : E) {r : ā„} (hr : 0 ≤ r) : c • sphere x r = sphere (c • x) (‖c‖ * r) := by rcases eq_or_ne c 0 with (rfl | hc) Ā· simp [zero_smul_set, Set.singleton_zero, hr] Ā· exact smul_sphere' hc x r /-- Any ball `Metric.ball x r`, `0 < r` is the image of the unit ball under `fun y ↦ x + r • y`. -/ theorem affinity_unitBall {r : ā„} (hr : 0 < r) (x : E) : x +ᵄ r • ball (0 : E) 1 = ball x r := by rw [smul_unitBall_of_pos hr, vadd_ball_zero] /-- Any closed ball `Metric.closedBall x r`, `0 ≤ r` is the image of the unit closed ball under `fun y ↦ x + r • y`. -/ theorem affinity_unitClosedBall {r : ā„} (hr : 0 ≤ r) (x : E) : x +ᵄ r • closedBall (0 : E) 1 = closedBall x r := by rw [smul_unitClosedBall, Real.norm_of_nonneg hr, vadd_closedBall_zero] end NormedAddCommGroup
.lake/packages/mathlib/Mathlib/Analysis/Normed/Module/Ball/Action.lean
import Mathlib.Analysis.Normed.Field.UnitBall import Mathlib.Analysis.Normed.Module.Basic import Mathlib.LinearAlgebra.Basis.VectorSpace /-! # Multiplicative actions of/on balls and spheres Let `E` be a normed vector space over a normed field `š•œ`. In this file we define the following multiplicative actions. - The closed unit ball in `š•œ` acts on open balls and closed balls centered at `0` in `E`. - The unit sphere in `š•œ` acts on open balls, closed balls, and spheres centered at `0` in `E`. -/ open Metric Set variable {š•œ š•œ' E : Type*} [NormedField š•œ] [NormedField š•œ'] [SeminormedAddCommGroup E] [NormedSpace š•œ E] [NormedSpace š•œ' E] {r : ā„} section ClosedBall instance mulActionClosedBallBall : MulAction (closedBall (0 : š•œ) 1) (ball (0 : E) r) where smul c x := ⟨(c : š•œ) • ↑x, mem_ball_zero_iff.2 <| by simpa only [norm_smul, one_mul] using mul_lt_mul' (mem_closedBall_zero_iff.1 c.2) (mem_ball_zero_iff.1 x.2) (norm_nonneg _) one_pos⟩ one_smul _cā‚‚ := Subtype.ext <| one_smul š•œ _ mul_smul _ _ _ := Subtype.ext <| mul_smul _ _ _ instance continuousSMul_closedBall_ball : ContinuousSMul (closedBall (0 : š•œ) 1) (ball (0 : E) r) := ⟨(continuous_subtype_val.fst'.smul continuous_subtype_val.snd').subtype_mk _⟩ instance mulActionClosedBallClosedBall : MulAction (closedBall (0 : š•œ) 1) (closedBall (0 : E) r) where smul c x := ⟨(c : š•œ) • ↑x, mem_closedBall_zero_iff.2 <| by simpa only [norm_smul, one_mul] using mul_le_mul (mem_closedBall_zero_iff.1 c.2) (mem_closedBall_zero_iff.1 x.2) (norm_nonneg _) zero_le_one⟩ one_smul _ := Subtype.ext <| one_smul š•œ _ mul_smul _ _ _ := Subtype.ext <| mul_smul _ _ _ instance continuousSMul_closedBall_closedBall : ContinuousSMul (closedBall (0 : š•œ) 1) (closedBall (0 : E) r) := ⟨(continuous_subtype_val.fst'.smul continuous_subtype_val.snd').subtype_mk _⟩ end ClosedBall section Sphere instance mulActionSphereBall : MulAction (sphere (0 : š•œ) 1) (ball (0 : E) r) where smul c x := inclusion sphere_subset_closedBall c • x one_smul _ := Subtype.ext <| one_smul _ _ mul_smul _ _ _ := Subtype.ext <| mul_smul _ _ _ instance continuousSMul_sphere_ball : ContinuousSMul (sphere (0 : š•œ) 1) (ball (0 : E) r) := ⟨(continuous_subtype_val.fst'.smul continuous_subtype_val.snd').subtype_mk _⟩ instance mulActionSphereClosedBall : MulAction (sphere (0 : š•œ) 1) (closedBall (0 : E) r) where smul c x := inclusion sphere_subset_closedBall c • x one_smul _ := Subtype.ext <| one_smul _ _ mul_smul _ _ _ := Subtype.ext <| mul_smul _ _ _ instance continuousSMul_sphere_closedBall : ContinuousSMul (sphere (0 : š•œ) 1) (closedBall (0 : E) r) := ⟨(continuous_subtype_val.fst'.smul continuous_subtype_val.snd').subtype_mk _⟩ instance mulActionSphereSphere : MulAction (sphere (0 : š•œ) 1) (sphere (0 : E) r) where smul c x := ⟨(c : š•œ) • ↑x, mem_sphere_zero_iff_norm.2 <| by rw [norm_smul, mem_sphere_zero_iff_norm.1 c.coe_prop, mem_sphere_zero_iff_norm.1 x.coe_prop, one_mul]⟩ one_smul _ := Subtype.ext <| one_smul _ _ mul_smul _ _ _ := Subtype.ext <| mul_smul _ _ _ instance continuousSMul_sphere_sphere : ContinuousSMul (sphere (0 : š•œ) 1) (sphere (0 : E) r) := ⟨(continuous_subtype_val.fst'.smul continuous_subtype_val.snd').subtype_mk _⟩ end Sphere section IsScalarTower variable [NormedAlgebra š•œ š•œ'] [IsScalarTower š•œ š•œ' E] instance isScalarTower_closedBall_closedBall_closedBall : IsScalarTower (closedBall (0 : š•œ) 1) (closedBall (0 : š•œ') 1) (closedBall (0 : E) r) := ⟨fun a b c => Subtype.ext <| smul_assoc (a : š•œ) (b : š•œ') (c : E)⟩ instance isScalarTower_closedBall_closedBall_ball : IsScalarTower (closedBall (0 : š•œ) 1) (closedBall (0 : š•œ') 1) (ball (0 : E) r) := ⟨fun a b c => Subtype.ext <| smul_assoc (a : š•œ) (b : š•œ') (c : E)⟩ instance isScalarTower_sphere_closedBall_closedBall : IsScalarTower (sphere (0 : š•œ) 1) (closedBall (0 : š•œ') 1) (closedBall (0 : E) r) := ⟨fun a b c => Subtype.ext <| smul_assoc (a : š•œ) (b : š•œ') (c : E)⟩ instance isScalarTower_sphere_closedBall_ball : IsScalarTower (sphere (0 : š•œ) 1) (closedBall (0 : š•œ') 1) (ball (0 : E) r) := ⟨fun a b c => Subtype.ext <| smul_assoc (a : š•œ) (b : š•œ') (c : E)⟩ instance isScalarTower_sphere_sphere_closedBall : IsScalarTower (sphere (0 : š•œ) 1) (sphere (0 : š•œ') 1) (closedBall (0 : E) r) := ⟨fun a b c => Subtype.ext <| smul_assoc (a : š•œ) (b : š•œ') (c : E)⟩ instance isScalarTower_sphere_sphere_ball : IsScalarTower (sphere (0 : š•œ) 1) (sphere (0 : š•œ') 1) (ball (0 : E) r) := ⟨fun a b c => Subtype.ext <| smul_assoc (a : š•œ) (b : š•œ') (c : E)⟩ instance isScalarTower_sphere_sphere_sphere : IsScalarTower (sphere (0 : š•œ) 1) (sphere (0 : š•œ') 1) (sphere (0 : E) r) := ⟨fun a b c => Subtype.ext <| smul_assoc (a : š•œ) (b : š•œ') (c : E)⟩ instance isScalarTower_sphere_ball_ball : IsScalarTower (sphere (0 : š•œ) 1) (ball (0 : š•œ') 1) (ball (0 : š•œ') 1) := ⟨fun a b c => Subtype.ext <| smul_assoc (a : š•œ) (b : š•œ') (c : š•œ')⟩ instance isScalarTower_closedBall_ball_ball : IsScalarTower (closedBall (0 : š•œ) 1) (ball (0 : š•œ') 1) (ball (0 : š•œ') 1) := ⟨fun a b c => Subtype.ext <| smul_assoc (a : š•œ) (b : š•œ') (c : š•œ')⟩ end IsScalarTower section SMulCommClass variable [SMulCommClass š•œ š•œ' E] instance instSMulCommClass_closedBall_closedBall_closedBall : SMulCommClass (closedBall (0 : š•œ) 1) (closedBall (0 : š•œ') 1) (closedBall (0 : E) r) := ⟨fun a b c => Subtype.ext <| smul_comm (a : š•œ) (b : š•œ') (c : E)⟩ instance instSMulCommClass_closedBall_closedBall_ball : SMulCommClass (closedBall (0 : š•œ) 1) (closedBall (0 : š•œ') 1) (ball (0 : E) r) := ⟨fun a b c => Subtype.ext <| smul_comm (a : š•œ) (b : š•œ') (c : E)⟩ instance instSMulCommClass_sphere_closedBall_closedBall : SMulCommClass (sphere (0 : š•œ) 1) (closedBall (0 : š•œ') 1) (closedBall (0 : E) r) := ⟨fun a b c => Subtype.ext <| smul_comm (a : š•œ) (b : š•œ') (c : E)⟩ instance instSMulCommClass_sphere_closedBall_ball : SMulCommClass (sphere (0 : š•œ) 1) (closedBall (0 : š•œ') 1) (ball (0 : E) r) := ⟨fun a b c => Subtype.ext <| smul_comm (a : š•œ) (b : š•œ') (c : E)⟩ instance instSMulCommClass_sphere_ball_ball [NormedAlgebra š•œ š•œ'] : SMulCommClass (sphere (0 : š•œ) 1) (ball (0 : š•œ') 1) (ball (0 : š•œ') 1) := ⟨fun a b c => Subtype.ext <| smul_comm (a : š•œ) (b : š•œ') (c : š•œ')⟩ instance instSMulCommClass_sphere_sphere_closedBall : SMulCommClass (sphere (0 : š•œ) 1) (sphere (0 : š•œ') 1) (closedBall (0 : E) r) := ⟨fun a b c => Subtype.ext <| smul_comm (a : š•œ) (b : š•œ') (c : E)⟩ instance instSMulCommClass_sphere_sphere_ball : SMulCommClass (sphere (0 : š•œ) 1) (sphere (0 : š•œ') 1) (ball (0 : E) r) := ⟨fun a b c => Subtype.ext <| smul_comm (a : š•œ) (b : š•œ') (c : E)⟩ instance instSMulCommClass_sphere_sphere_sphere : SMulCommClass (sphere (0 : š•œ) 1) (sphere (0 : š•œ') 1) (sphere (0 : E) r) := ⟨fun a b c => Subtype.ext <| smul_comm (a : š•œ) (b : š•œ') (c : E)⟩ end SMulCommClass variable (š•œ) variable [CharZero š•œ] include š•œ in theorem ne_neg_of_mem_sphere {r : ā„} (hr : r ≠ 0) (x : sphere (0 : E) r) : x ≠ -x := have : IsAddTorsionFree E := .of_noZeroSMulDivisors š•œ E fun h => ne_zero_of_mem_sphere hr x (self_eq_neg.mp (by (conv_lhs => rw [h]); rfl)) include š•œ in theorem ne_neg_of_mem_unit_sphere (x : sphere (0 : E) 1) : x ≠ -x := ne_neg_of_mem_sphere š•œ one_ne_zero x