path stringlengths 11 71 | content stringlengths 75 124k |
|---|---|
Analysis\Normed\Operator\BoundedLinearMaps.lean | /-
Copyright (c) 2018 Patrick Massot. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Patrick Massot, Johannes Hölzl
-/
import Mathlib.Analysis.NormedSpace.Multilinear.Basic
import Mathlib.Analysis.Normed.Ring.Units
import Mathlib.Analysis.NormedSpace.OperatorNorm.Completeness
import Mathlib.Analysis.NormedSpace.OperatorNorm.Mul
/-!
# Bounded linear maps
This file defines a class stating that a map between normed vector spaces is (bi)linear and
continuous.
Instead of asking for continuity, the definition takes the equivalent condition (because the space
is normed) that `‖f x‖` is bounded by a multiple of `‖x‖`. Hence the "bounded" in the name refers to
`‖f x‖/‖x‖` rather than `‖f x‖` itself.
## Main definitions
* `IsBoundedLinearMap`: Class stating that a map `f : E → F` is linear and has `‖f x‖` bounded
by a multiple of `‖x‖`.
* `IsBoundedBilinearMap`: Class stating that a map `f : E × F → G` is bilinear and continuous,
but through the simpler to provide statement that `‖f (x, y)‖` is bounded by a multiple of
`‖x‖ * ‖y‖`
* `IsBoundedBilinearMap.linearDeriv`: Derivative of a continuous bilinear map as a linear map.
* `IsBoundedBilinearMap.deriv`: Derivative of a continuous bilinear map as a continuous linear
map. The proof that it is indeed the derivative is `IsBoundedBilinearMap.hasFDerivAt` in
`Analysis.Calculus.FDeriv`.
## Main theorems
* `IsBoundedBilinearMap.continuous`: A bounded bilinear map is continuous.
* `ContinuousLinearEquiv.isOpen`: The continuous linear equivalences are an open subset of the
set of continuous linear maps between a pair of Banach spaces. Placed in this file because its
proof uses `IsBoundedBilinearMap.continuous`.
## Notes
The main use of this file is `IsBoundedBilinearMap`.
The file `Analysis.NormedSpace.Multilinear.Basic`
already expounds the theory of multilinear maps,
but the `2`-variables case is sufficiently simpler to currently deserve its own treatment.
`IsBoundedLinearMap` is effectively an unbundled version of `ContinuousLinearMap` (defined
in `Topology.Algebra.Module.Basic`, theory over normed spaces developed in
`Analysis.NormedSpace.OperatorNorm`), albeit the name disparity. A bundled
`ContinuousLinearMap` is to be preferred over an `IsBoundedLinearMap` hypothesis. Historical
artifact, really.
-/
noncomputable section
open Topology
open Filter (Tendsto)
open Metric ContinuousLinearMap
variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] {E : Type*} [NormedAddCommGroup E]
[NormedSpace 𝕜 E] {F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F] {G : Type*}
[NormedAddCommGroup G] [NormedSpace 𝕜 G]
/-- A function `f` satisfies `IsBoundedLinearMap 𝕜 f` if it is linear and satisfies the
inequality `‖f x‖ ≤ M * ‖x‖` for some positive constant `M`. -/
structure IsBoundedLinearMap (𝕜 : Type*) [NormedField 𝕜] {E : Type*} [NormedAddCommGroup E]
[NormedSpace 𝕜 E] {F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F] (f : E → F) extends
IsLinearMap 𝕜 f : Prop where
bound : ∃ M, 0 < M ∧ ∀ x : E, ‖f x‖ ≤ M * ‖x‖
theorem IsLinearMap.with_bound {f : E → F} (hf : IsLinearMap 𝕜 f) (M : ℝ)
(h : ∀ x : E, ‖f x‖ ≤ M * ‖x‖) : IsBoundedLinearMap 𝕜 f :=
⟨hf,
by_cases
(fun (this : M ≤ 0) =>
⟨1, zero_lt_one, fun x =>
(h x).trans <| mul_le_mul_of_nonneg_right (this.trans zero_le_one) (norm_nonneg x)⟩)
fun (this : ¬M ≤ 0) => ⟨M, lt_of_not_ge this, h⟩⟩
/-- A continuous linear map satisfies `IsBoundedLinearMap` -/
theorem ContinuousLinearMap.isBoundedLinearMap (f : E →L[𝕜] F) : IsBoundedLinearMap 𝕜 f :=
{ f.toLinearMap.isLinear with bound := f.bound }
namespace IsBoundedLinearMap
/-- Construct a linear map from a function `f` satisfying `IsBoundedLinearMap 𝕜 f`. -/
def toLinearMap (f : E → F) (h : IsBoundedLinearMap 𝕜 f) : E →ₗ[𝕜] F :=
IsLinearMap.mk' _ h.toIsLinearMap
/-- Construct a continuous linear map from `IsBoundedLinearMap`. -/
def toContinuousLinearMap {f : E → F} (hf : IsBoundedLinearMap 𝕜 f) : E →L[𝕜] F :=
{ toLinearMap f hf with
cont :=
let ⟨C, _, hC⟩ := hf.bound
AddMonoidHomClass.continuous_of_bound (toLinearMap f hf) C hC }
theorem zero : IsBoundedLinearMap 𝕜 fun _ : E => (0 : F) :=
(0 : E →ₗ[𝕜] F).isLinear.with_bound 0 <| by simp [le_refl]
theorem id : IsBoundedLinearMap 𝕜 fun x : E => x :=
LinearMap.id.isLinear.with_bound 1 <| by simp [le_refl]
theorem fst : IsBoundedLinearMap 𝕜 fun x : E × F => x.1 := by
refine (LinearMap.fst 𝕜 E F).isLinear.with_bound 1 fun x => ?_
rw [one_mul]
exact le_max_left _ _
theorem snd : IsBoundedLinearMap 𝕜 fun x : E × F => x.2 := by
refine (LinearMap.snd 𝕜 E F).isLinear.with_bound 1 fun x => ?_
rw [one_mul]
exact le_max_right _ _
variable {f g : E → F}
theorem smul (c : 𝕜) (hf : IsBoundedLinearMap 𝕜 f) : IsBoundedLinearMap 𝕜 (c • f) :=
let ⟨hlf, M, _, hM⟩ := hf
(c • hlf.mk' f).isLinear.with_bound (‖c‖ * M) fun x =>
calc
‖c • f x‖ = ‖c‖ * ‖f x‖ := norm_smul c (f x)
_ ≤ ‖c‖ * (M * ‖x‖) := mul_le_mul_of_nonneg_left (hM _) (norm_nonneg _)
_ = ‖c‖ * M * ‖x‖ := (mul_assoc _ _ _).symm
theorem neg (hf : IsBoundedLinearMap 𝕜 f) : IsBoundedLinearMap 𝕜 fun e => -f e := by
rw [show (fun e => -f e) = fun e => (-1 : 𝕜) • f e by funext; simp]
exact smul (-1) hf
theorem add (hf : IsBoundedLinearMap 𝕜 f) (hg : IsBoundedLinearMap 𝕜 g) :
IsBoundedLinearMap 𝕜 fun e => f e + g e :=
let ⟨hlf, Mf, _, hMf⟩ := hf
let ⟨hlg, Mg, _, hMg⟩ := hg
(hlf.mk' _ + hlg.mk' _).isLinear.with_bound (Mf + Mg) fun x =>
calc
‖f x + g x‖ ≤ Mf * ‖x‖ + Mg * ‖x‖ := norm_add_le_of_le (hMf x) (hMg x)
_ ≤ (Mf + Mg) * ‖x‖ := by rw [add_mul]
theorem sub (hf : IsBoundedLinearMap 𝕜 f) (hg : IsBoundedLinearMap 𝕜 g) :
IsBoundedLinearMap 𝕜 fun e => f e - g e := by simpa [sub_eq_add_neg] using add hf (neg hg)
theorem comp {g : F → G} (hg : IsBoundedLinearMap 𝕜 g) (hf : IsBoundedLinearMap 𝕜 f) :
IsBoundedLinearMap 𝕜 (g ∘ f) :=
(hg.toContinuousLinearMap.comp hf.toContinuousLinearMap).isBoundedLinearMap
protected theorem tendsto (x : E) (hf : IsBoundedLinearMap 𝕜 f) : Tendsto f (𝓝 x) (𝓝 (f x)) :=
let ⟨hf, M, _, hM⟩ := hf
tendsto_iff_norm_sub_tendsto_zero.2 <|
squeeze_zero (fun e => norm_nonneg _)
(fun e =>
calc
‖f e - f x‖ = ‖hf.mk' f (e - x)‖ := by rw [(hf.mk' _).map_sub e x]; rfl
_ ≤ M * ‖e - x‖ := hM (e - x)
)
(suffices Tendsto (fun e : E => M * ‖e - x‖) (𝓝 x) (𝓝 (M * 0)) by simpa
tendsto_const_nhds.mul (tendsto_norm_sub_self _))
theorem continuous (hf : IsBoundedLinearMap 𝕜 f) : Continuous f :=
continuous_iff_continuousAt.2 fun _ => hf.tendsto _
theorem lim_zero_bounded_linear_map (hf : IsBoundedLinearMap 𝕜 f) : Tendsto f (𝓝 0) (𝓝 0) :=
(hf.1.mk' _).map_zero ▸ continuous_iff_continuousAt.1 hf.continuous 0
section
open Asymptotics Filter
theorem isBigO_id {f : E → F} (h : IsBoundedLinearMap 𝕜 f) (l : Filter E) : f =O[l] fun x => x :=
let ⟨_, _, hM⟩ := h.bound
IsBigO.of_bound _ (mem_of_superset univ_mem fun x _ => hM x)
theorem isBigO_comp {E : Type*} {g : F → G} (hg : IsBoundedLinearMap 𝕜 g) {f : E → F}
(l : Filter E) : (fun x' => g (f x')) =O[l] f :=
(hg.isBigO_id ⊤).comp_tendsto le_top
theorem isBigO_sub {f : E → F} (h : IsBoundedLinearMap 𝕜 f) (l : Filter E) (x : E) :
(fun x' => f (x' - x)) =O[l] fun x' => x' - x :=
isBigO_comp h l
end
end IsBoundedLinearMap
section
variable {ι : Type*} [Fintype ι]
/-- Taking the cartesian product of two continuous multilinear maps is a bounded linear
operation. -/
theorem isBoundedLinearMap_prod_multilinear {E : ι → Type*} [∀ i, NormedAddCommGroup (E i)]
[∀ i, NormedSpace 𝕜 (E i)] :
IsBoundedLinearMap 𝕜 fun p : ContinuousMultilinearMap 𝕜 E F × ContinuousMultilinearMap 𝕜 E G =>
p.1.prod p.2 where
map_add p₁ p₂ := by ext : 1; rfl
map_smul c p := by ext : 1; rfl
bound := by
refine ⟨1, zero_lt_one, fun p ↦ ?_⟩
rw [one_mul]
apply ContinuousMultilinearMap.opNorm_le_bound _ (norm_nonneg _) _
intro m
rw [ContinuousMultilinearMap.prod_apply, norm_prod_le_iff]
constructor
· exact (p.1.le_opNorm m).trans (mul_le_mul_of_nonneg_right (norm_fst_le p) <| by positivity)
· exact (p.2.le_opNorm m).trans (mul_le_mul_of_nonneg_right (norm_snd_le p) <| by positivity)
/-- Given a fixed continuous linear map `g`, associating to a continuous multilinear map `f` the
continuous multilinear map `f (g m₁, ..., g mₙ)` is a bounded linear operation. -/
theorem isBoundedLinearMap_continuousMultilinearMap_comp_linear (g : G →L[𝕜] E) :
IsBoundedLinearMap 𝕜 fun f : ContinuousMultilinearMap 𝕜 (fun _ : ι => E) F =>
f.compContinuousLinearMap fun _ => g := by
refine
IsLinearMap.with_bound
⟨fun f₁ f₂ => by ext; rfl,
fun c f => by ext; rfl⟩
(‖g‖ ^ Fintype.card ι) fun f => ?_
apply ContinuousMultilinearMap.opNorm_le_bound _ _ _
· apply_rules [mul_nonneg, pow_nonneg, norm_nonneg]
intro m
calc
‖f (g ∘ m)‖ ≤ ‖f‖ * ∏ i, ‖g (m i)‖ := f.le_opNorm _
_ ≤ ‖f‖ * ∏ i, ‖g‖ * ‖m i‖ := by
apply mul_le_mul_of_nonneg_left _ (norm_nonneg _)
exact Finset.prod_le_prod (fun i _ => norm_nonneg _) fun i _ => g.le_opNorm _
_ = ‖g‖ ^ Fintype.card ι * ‖f‖ * ∏ i, ‖m i‖ := by
simp only [Finset.prod_mul_distrib, Finset.prod_const, Finset.card_univ]
ring
end
section BilinearMap
namespace ContinuousLinearMap
/-! We prove some computation rules for continuous (semi-)bilinear maps in their first argument.
If `f` is a continuous bilinear map, to use the corresponding rules for the second argument, use
`(f _).map_add` and similar.
We have to assume that `F` and `G` are normed spaces in this section, to use
`ContinuousLinearMap.toNormedAddCommGroup`, but we don't need to assume this for the first
argument of `f`.
-/
variable {R : Type*}
variable {𝕜₂ 𝕜' : Type*} [NontriviallyNormedField 𝕜'] [NontriviallyNormedField 𝕜₂]
variable {M : Type*} [TopologicalSpace M]
variable {σ₁₂ : 𝕜 →+* 𝕜₂}
variable {G' : Type*} [NormedAddCommGroup G'] [NormedSpace 𝕜₂ G'] [NormedSpace 𝕜' G']
variable [SMulCommClass 𝕜₂ 𝕜' G']
section Semiring
variable [Semiring R] [AddCommMonoid M] [Module R M] {ρ₁₂ : R →+* 𝕜'}
theorem map_add₂ (f : M →SL[ρ₁₂] F →SL[σ₁₂] G') (x x' : M) (y : F) :
f (x + x') y = f x y + f x' y := by rw [f.map_add, add_apply]
theorem map_zero₂ (f : M →SL[ρ₁₂] F →SL[σ₁₂] G') (y : F) : f 0 y = 0 := by
rw [f.map_zero, zero_apply]
theorem map_smulₛₗ₂ (f : M →SL[ρ₁₂] F →SL[σ₁₂] G') (c : R) (x : M) (y : F) :
f (c • x) y = ρ₁₂ c • f x y := by rw [f.map_smulₛₗ, smul_apply]
end Semiring
section Ring
variable [Ring R] [AddCommGroup M] [Module R M] {ρ₁₂ : R →+* 𝕜'}
theorem map_sub₂ (f : M →SL[ρ₁₂] F →SL[σ₁₂] G') (x x' : M) (y : F) :
f (x - x') y = f x y - f x' y := by rw [f.map_sub, sub_apply]
theorem map_neg₂ (f : M →SL[ρ₁₂] F →SL[σ₁₂] G') (x : M) (y : F) : f (-x) y = -f x y := by
rw [f.map_neg, neg_apply]
end Ring
theorem map_smul₂ (f : E →L[𝕜] F →L[𝕜] G) (c : 𝕜) (x : E) (y : F) : f (c • x) y = c • f x y := by
rw [f.map_smul, smul_apply]
end ContinuousLinearMap
variable (𝕜)
/-- A map `f : E × F → G` satisfies `IsBoundedBilinearMap 𝕜 f` if it is bilinear and
continuous. -/
structure IsBoundedBilinearMap (f : E × F → G) : Prop where
add_left : ∀ (x₁ x₂ : E) (y : F), f (x₁ + x₂, y) = f (x₁, y) + f (x₂, y)
smul_left : ∀ (c : 𝕜) (x : E) (y : F), f (c • x, y) = c • f (x, y)
add_right : ∀ (x : E) (y₁ y₂ : F), f (x, y₁ + y₂) = f (x, y₁) + f (x, y₂)
smul_right : ∀ (c : 𝕜) (x : E) (y : F), f (x, c • y) = c • f (x, y)
bound : ∃ C > 0, ∀ (x : E) (y : F), ‖f (x, y)‖ ≤ C * ‖x‖ * ‖y‖
variable {𝕜}
variable {f : E × F → G}
theorem ContinuousLinearMap.isBoundedBilinearMap (f : E →L[𝕜] F →L[𝕜] G) :
IsBoundedBilinearMap 𝕜 fun x : E × F => f x.1 x.2 :=
{ add_left := f.map_add₂
smul_left := f.map_smul₂
add_right := fun x => (f x).map_add
smul_right := fun c x => (f x).map_smul c
bound :=
⟨max ‖f‖ 1, zero_lt_one.trans_le (le_max_right _ _), fun x y =>
(f.le_opNorm₂ x y).trans <| by
apply_rules [mul_le_mul_of_nonneg_right, norm_nonneg, le_max_left] ⟩ }
-- Porting note (#11445): new definition
/-- A bounded bilinear map `f : E × F → G` defines a continuous linear map
`f : E →L[𝕜] F →L[𝕜] G`. -/
def IsBoundedBilinearMap.toContinuousLinearMap (hf : IsBoundedBilinearMap 𝕜 f) :
E →L[𝕜] F →L[𝕜] G :=
LinearMap.mkContinuousOfExistsBound₂
(LinearMap.mk₂ _ f.curry hf.add_left hf.smul_left hf.add_right hf.smul_right) <|
hf.bound.imp fun _ ↦ And.right
protected theorem IsBoundedBilinearMap.isBigO (h : IsBoundedBilinearMap 𝕜 f) :
f =O[⊤] fun p : E × F => ‖p.1‖ * ‖p.2‖ :=
let ⟨C, Cpos, hC⟩ := h.bound
Asymptotics.IsBigO.of_bound _ <|
Filter.eventually_of_forall fun ⟨x, y⟩ => by simpa [mul_assoc] using hC x y
theorem IsBoundedBilinearMap.isBigO_comp {α : Type*} (H : IsBoundedBilinearMap 𝕜 f) {g : α → E}
{h : α → F} {l : Filter α} : (fun x => f (g x, h x)) =O[l] fun x => ‖g x‖ * ‖h x‖ :=
H.isBigO.comp_tendsto le_top
protected theorem IsBoundedBilinearMap.isBigO' (h : IsBoundedBilinearMap 𝕜 f) :
f =O[⊤] fun p : E × F => ‖p‖ * ‖p‖ :=
h.isBigO.trans <|
(@Asymptotics.isBigO_fst_prod' _ E F _ _ _ _).norm_norm.mul
(@Asymptotics.isBigO_snd_prod' _ E F _ _ _ _).norm_norm
theorem IsBoundedBilinearMap.map_sub_left (h : IsBoundedBilinearMap 𝕜 f) {x y : E} {z : F} :
f (x - y, z) = f (x, z) - f (y, z) :=
(h.toContinuousLinearMap.flip z).map_sub x y
theorem IsBoundedBilinearMap.map_sub_right (h : IsBoundedBilinearMap 𝕜 f) {x : E} {y z : F} :
f (x, y - z) = f (x, y) - f (x, z) :=
(h.toContinuousLinearMap x).map_sub y z
open Asymptotics in
/-- Useful to use together with `Continuous.comp₂`. -/
theorem IsBoundedBilinearMap.continuous (h : IsBoundedBilinearMap 𝕜 f) : Continuous f := by
refine continuous_iff_continuousAt.2 fun x ↦ tendsto_sub_nhds_zero_iff.1 ?_
suffices Tendsto (fun y : E × F ↦ f (y.1 - x.1, y.2) + f (x.1, y.2 - x.2)) (𝓝 x) (𝓝 (0 + 0)) by
simpa only [h.map_sub_left, h.map_sub_right, sub_add_sub_cancel, zero_add] using this
apply Tendsto.add
· rw [← isLittleO_one_iff ℝ, ← one_mul 1]
refine h.isBigO_comp.trans_isLittleO ?_
refine (IsLittleO.norm_left ?_).mul_isBigO (IsBigO.norm_left ?_)
· exact (isLittleO_one_iff _).2 (tendsto_sub_nhds_zero_iff.2 (continuous_fst.tendsto _))
· exact (continuous_snd.tendsto _).isBigO_one ℝ
· refine Continuous.tendsto' ?_ _ _ (by rw [h.map_sub_right, sub_self])
exact ((h.toContinuousLinearMap x.1).continuous).comp (continuous_snd.sub continuous_const)
theorem IsBoundedBilinearMap.continuous_left (h : IsBoundedBilinearMap 𝕜 f) {e₂ : F} :
Continuous fun e₁ => f (e₁, e₂) :=
h.continuous.comp (continuous_id.prod_mk continuous_const)
theorem IsBoundedBilinearMap.continuous_right (h : IsBoundedBilinearMap 𝕜 f) {e₁ : E} :
Continuous fun e₂ => f (e₁, e₂) :=
h.continuous.comp (continuous_const.prod_mk continuous_id)
/-- Useful to use together with `Continuous.comp₂`. -/
theorem ContinuousLinearMap.continuous₂ (f : E →L[𝕜] F →L[𝕜] G) :
Continuous (Function.uncurry fun x y => f x y) :=
f.isBoundedBilinearMap.continuous
theorem IsBoundedBilinearMap.isBoundedLinearMap_left (h : IsBoundedBilinearMap 𝕜 f) (y : F) :
IsBoundedLinearMap 𝕜 fun x => f (x, y) :=
(h.toContinuousLinearMap.flip y).isBoundedLinearMap
theorem IsBoundedBilinearMap.isBoundedLinearMap_right (h : IsBoundedBilinearMap 𝕜 f) (x : E) :
IsBoundedLinearMap 𝕜 fun y => f (x, y) :=
(h.toContinuousLinearMap x).isBoundedLinearMap
theorem isBoundedBilinearMap_smul {𝕜' : Type*} [NormedField 𝕜'] [NormedAlgebra 𝕜 𝕜'] {E : Type*}
[NormedAddCommGroup E] [NormedSpace 𝕜 E] [NormedSpace 𝕜' E] [IsScalarTower 𝕜 𝕜' E] :
IsBoundedBilinearMap 𝕜 fun p : 𝕜' × E => p.1 • p.2 :=
(lsmul 𝕜 𝕜' : 𝕜' →L[𝕜] E →L[𝕜] E).isBoundedBilinearMap
theorem isBoundedBilinearMap_mul : IsBoundedBilinearMap 𝕜 fun p : 𝕜 × 𝕜 => p.1 * p.2 := by
simp_rw [← smul_eq_mul]
exact isBoundedBilinearMap_smul
theorem isBoundedBilinearMap_comp :
IsBoundedBilinearMap 𝕜 fun p : (F →L[𝕜] G) × (E →L[𝕜] F) => p.1.comp p.2 :=
(compL 𝕜 E F G).isBoundedBilinearMap
theorem ContinuousLinearMap.isBoundedLinearMap_comp_left (g : F →L[𝕜] G) :
IsBoundedLinearMap 𝕜 fun f : E →L[𝕜] F => ContinuousLinearMap.comp g f :=
isBoundedBilinearMap_comp.isBoundedLinearMap_right _
theorem ContinuousLinearMap.isBoundedLinearMap_comp_right (f : E →L[𝕜] F) :
IsBoundedLinearMap 𝕜 fun g : F →L[𝕜] G => ContinuousLinearMap.comp g f :=
isBoundedBilinearMap_comp.isBoundedLinearMap_left _
theorem isBoundedBilinearMap_apply : IsBoundedBilinearMap 𝕜 fun p : (E →L[𝕜] F) × E => p.1 p.2 :=
(ContinuousLinearMap.flip (apply 𝕜 F : E →L[𝕜] (E →L[𝕜] F) →L[𝕜] F)).isBoundedBilinearMap
/-- The function `ContinuousLinearMap.smulRight`, associating to a continuous linear map
`f : E → 𝕜` and a scalar `c : F` the tensor product `f ⊗ c` as a continuous linear map from `E` to
`F`, is a bounded bilinear map. -/
theorem isBoundedBilinearMap_smulRight :
IsBoundedBilinearMap 𝕜 fun p =>
(ContinuousLinearMap.smulRight : (E →L[𝕜] 𝕜) → F → E →L[𝕜] F) p.1 p.2 :=
(smulRightL 𝕜 E F).isBoundedBilinearMap
/-- The composition of a continuous linear map with a continuous multilinear map is a bounded
bilinear operation. -/
theorem isBoundedBilinearMap_compMultilinear {ι : Type*} {E : ι → Type*} [Fintype ι]
[∀ i, NormedAddCommGroup (E i)] [∀ i, NormedSpace 𝕜 (E i)] :
IsBoundedBilinearMap 𝕜 fun p : (F →L[𝕜] G) × ContinuousMultilinearMap 𝕜 E F =>
p.1.compContinuousMultilinearMap p.2 :=
(compContinuousMultilinearMapL 𝕜 E F G).isBoundedBilinearMap
/-- Definition of the derivative of a bilinear map `f`, given at a point `p` by
`q ↦ f(p.1, q.2) + f(q.1, p.2)` as in the standard formula for the derivative of a product.
We define this function here as a linear map `E × F →ₗ[𝕜] G`, then `IsBoundedBilinearMap.deriv`
strengthens it to a continuous linear map `E × F →L[𝕜] G`.
-/
def IsBoundedBilinearMap.linearDeriv (h : IsBoundedBilinearMap 𝕜 f) (p : E × F) : E × F →ₗ[𝕜] G :=
(h.toContinuousLinearMap.deriv₂ p).toLinearMap
/-- The derivative of a bounded bilinear map at a point `p : E × F`, as a continuous linear map
from `E × F` to `G`. The statement that this is indeed the derivative of `f` is
`IsBoundedBilinearMap.hasFDerivAt` in `Analysis.Calculus.FDeriv`. -/
def IsBoundedBilinearMap.deriv (h : IsBoundedBilinearMap 𝕜 f) (p : E × F) : E × F →L[𝕜] G :=
h.toContinuousLinearMap.deriv₂ p
@[simp]
theorem IsBoundedBilinearMap.deriv_apply (h : IsBoundedBilinearMap 𝕜 f) (p q : E × F) :
h.deriv p q = f (p.1, q.2) + f (q.1, p.2) :=
rfl
variable (𝕜)
/-- The function `ContinuousLinearMap.mulLeftRight : 𝕜' × 𝕜' → (𝕜' →L[𝕜] 𝕜')` is a bounded
bilinear map. -/
theorem ContinuousLinearMap.mulLeftRight_isBoundedBilinear (𝕜' : Type*) [NormedRing 𝕜']
[NormedAlgebra 𝕜 𝕜'] :
IsBoundedBilinearMap 𝕜 fun p : 𝕜' × 𝕜' => ContinuousLinearMap.mulLeftRight 𝕜 𝕜' p.1 p.2 :=
(ContinuousLinearMap.mulLeftRight 𝕜 𝕜').isBoundedBilinearMap
variable {𝕜}
/-- Given a bounded bilinear map `f`, the map associating to a point `p` the derivative of `f` at
`p` is itself a bounded linear map. -/
theorem IsBoundedBilinearMap.isBoundedLinearMap_deriv (h : IsBoundedBilinearMap 𝕜 f) :
IsBoundedLinearMap 𝕜 fun p : E × F => h.deriv p :=
h.toContinuousLinearMap.deriv₂.isBoundedLinearMap
end BilinearMap
@[continuity, fun_prop]
theorem Continuous.clm_comp {X} [TopologicalSpace X] {g : X → F →L[𝕜] G} {f : X → E →L[𝕜] F}
(hg : Continuous g) (hf : Continuous f) : Continuous fun x => (g x).comp (f x) :=
(compL 𝕜 E F G).continuous₂.comp₂ hg hf
theorem ContinuousOn.clm_comp {X} [TopologicalSpace X] {g : X → F →L[𝕜] G} {f : X → E →L[𝕜] F}
{s : Set X} (hg : ContinuousOn g s) (hf : ContinuousOn f s) :
ContinuousOn (fun x => (g x).comp (f x)) s :=
(compL 𝕜 E F G).continuous₂.comp_continuousOn (hg.prod hf)
@[continuity, fun_prop]
theorem Continuous.clm_apply {X} [TopologicalSpace X] {f : X → (E →L[𝕜] F)} {g : X → E}
(hf : Continuous f) (hg : Continuous g) : Continuous (fun x ↦ (f x) (g x)) :=
isBoundedBilinearMap_apply.continuous.comp₂ hf hg
theorem ContinuousOn.clm_apply {X} [TopologicalSpace X] {f : X → (E →L[𝕜] F)} {g : X → E}
{s : Set X} (hf : ContinuousOn f s) (hg : ContinuousOn g s) :
ContinuousOn (fun x ↦ f x (g x)) s :=
isBoundedBilinearMap_apply.continuous.comp_continuousOn (hf.prod hg)
namespace ContinuousLinearEquiv
open Set
/-!
### The set of continuous linear equivalences between two Banach spaces is open
In this section we establish that the set of continuous linear equivalences between two Banach
spaces is an open subset of the space of linear maps between them.
-/
protected theorem isOpen [CompleteSpace E] : IsOpen (range ((↑) : (E ≃L[𝕜] F) → E →L[𝕜] F)) := by
rw [isOpen_iff_mem_nhds, forall_mem_range]
refine fun e => IsOpen.mem_nhds ?_ (mem_range_self _)
let O : (E →L[𝕜] F) → E →L[𝕜] E := fun f => (e.symm : F →L[𝕜] E).comp f
have h_O : Continuous O := isBoundedBilinearMap_comp.continuous_right
convert show IsOpen (O ⁻¹' { x | IsUnit x }) from Units.isOpen.preimage h_O using 1
ext f'
constructor
· rintro ⟨e', rfl⟩
exact ⟨(e'.trans e.symm).toUnit, rfl⟩
· rintro ⟨w, hw⟩
use (unitsEquiv 𝕜 E w).trans e
ext x
simp [O, hw]
protected theorem nhds [CompleteSpace E] (e : E ≃L[𝕜] F) :
range ((↑) : (E ≃L[𝕜] F) → E →L[𝕜] F) ∈ 𝓝 (e : E →L[𝕜] F) :=
IsOpen.mem_nhds ContinuousLinearEquiv.isOpen (by simp)
end ContinuousLinearEquiv
|
Analysis\Normed\Operator\Compact.lean | /-
Copyright (c) 2022 Anatole Dedecker. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Anatole Dedecker
-/
import Mathlib.Analysis.LocallyConvex.Bounded
import Mathlib.Topology.Algebra.Module.StrongTopology
/-!
# Compact operators
In this file we define compact linear operators between two topological vector spaces (TVS).
## Main definitions
* `IsCompactOperator` : predicate for compact operators
## Main statements
* `isCompactOperator_iff_isCompact_closure_image_ball` : the usual characterization of
compact operators from a normed space to a T2 TVS.
* `IsCompactOperator.comp_clm` : precomposing a compact operator by a continuous linear map gives
a compact operator
* `IsCompactOperator.clm_comp` : postcomposing a compact operator by a continuous linear map
gives a compact operator
* `IsCompactOperator.continuous` : compact operators are automatically continuous
* `isClosed_setOf_isCompactOperator` : the set of compact operators is closed for the operator
norm
## Implementation details
We define `IsCompactOperator` as a predicate, because the space of compact operators inherits all
of its structure from the space of continuous linear maps (e.g we want to have the usual operator
norm on compact operators).
The two natural options then would be to make it a predicate over linear maps or continuous linear
maps. Instead we define it as a predicate over bare functions, although it really only makes sense
for linear functions, because Lean is really good at finding coercions to bare functions (whereas
coercing from continuous linear maps to linear maps often needs type ascriptions).
## References
* [N. Bourbaki, *Théories Spectrales*, Chapitre 3][bourbaki2023]
## Tags
Compact operator
-/
open Function Set Filter Bornology Metric Pointwise Topology
/-- A compact operator between two topological vector spaces. This definition is usually
given as "there exists a neighborhood of zero whose image is contained in a compact set",
but we choose a definition which involves fewer existential quantifiers and replaces images
with preimages.
We prove the equivalence in `isCompactOperator_iff_exists_mem_nhds_image_subset_compact`. -/
def IsCompactOperator {M₁ M₂ : Type*} [Zero M₁] [TopologicalSpace M₁] [TopologicalSpace M₂]
(f : M₁ → M₂) : Prop :=
∃ K, IsCompact K ∧ f ⁻¹' K ∈ (𝓝 0 : Filter M₁)
theorem isCompactOperator_zero {M₁ M₂ : Type*} [Zero M₁] [TopologicalSpace M₁]
[TopologicalSpace M₂] [Zero M₂] : IsCompactOperator (0 : M₁ → M₂) :=
⟨{0}, isCompact_singleton, mem_of_superset univ_mem fun _ _ => rfl⟩
section Characterizations
section
variable {R₁ R₂ : Type*} [Semiring R₁] [Semiring R₂] {σ₁₂ : R₁ →+* R₂} {M₁ M₂ : Type*}
[TopologicalSpace M₁] [AddCommMonoid M₁] [TopologicalSpace M₂]
theorem isCompactOperator_iff_exists_mem_nhds_image_subset_compact (f : M₁ → M₂) :
IsCompactOperator f ↔ ∃ V ∈ (𝓝 0 : Filter M₁), ∃ K : Set M₂, IsCompact K ∧ f '' V ⊆ K :=
⟨fun ⟨K, hK, hKf⟩ => ⟨f ⁻¹' K, hKf, K, hK, image_preimage_subset _ _⟩, fun ⟨_, hV, K, hK, hVK⟩ =>
⟨K, hK, mem_of_superset hV (image_subset_iff.mp hVK)⟩⟩
theorem isCompactOperator_iff_exists_mem_nhds_isCompact_closure_image [T2Space M₂] (f : M₁ → M₂) :
IsCompactOperator f ↔ ∃ V ∈ (𝓝 0 : Filter M₁), IsCompact (closure <| f '' V) := by
rw [isCompactOperator_iff_exists_mem_nhds_image_subset_compact]
exact
⟨fun ⟨V, hV, K, hK, hKV⟩ => ⟨V, hV, hK.closure_of_subset hKV⟩,
fun ⟨V, hV, hVc⟩ => ⟨V, hV, closure (f '' V), hVc, subset_closure⟩⟩
end
section Bounded
variable {𝕜₁ 𝕜₂ : Type*} [NontriviallyNormedField 𝕜₁] [SeminormedRing 𝕜₂] {σ₁₂ : 𝕜₁ →+* 𝕜₂}
{M₁ M₂ : Type*} [TopologicalSpace M₁] [AddCommMonoid M₁] [TopologicalSpace M₂] [AddCommMonoid M₂]
[Module 𝕜₁ M₁] [Module 𝕜₂ M₂] [ContinuousConstSMul 𝕜₂ M₂]
theorem IsCompactOperator.image_subset_compact_of_isVonNBounded {f : M₁ →ₛₗ[σ₁₂] M₂}
(hf : IsCompactOperator f) {S : Set M₁} (hS : IsVonNBounded 𝕜₁ S) :
∃ K : Set M₂, IsCompact K ∧ f '' S ⊆ K :=
let ⟨K, hK, hKf⟩ := hf
let ⟨r, hr, hrS⟩ := (hS hKf).exists_pos
let ⟨c, hc⟩ := NormedField.exists_lt_norm 𝕜₁ r
let this := ne_zero_of_norm_ne_zero (hr.trans hc).ne.symm
⟨σ₁₂ c • K, hK.image <| continuous_id.const_smul (σ₁₂ c), by
rw [image_subset_iff, preimage_smul_setₛₗ _ _ _ f this.isUnit]; exact hrS c hc.le⟩
theorem IsCompactOperator.isCompact_closure_image_of_isVonNBounded [T2Space M₂] {f : M₁ →ₛₗ[σ₁₂] M₂}
(hf : IsCompactOperator f) {S : Set M₁} (hS : IsVonNBounded 𝕜₁ S) :
IsCompact (closure <| f '' S) :=
let ⟨_, hK, hKf⟩ := hf.image_subset_compact_of_isVonNBounded hS
hK.closure_of_subset hKf
end Bounded
section NormedSpace
variable {𝕜₁ 𝕜₂ : Type*} [NontriviallyNormedField 𝕜₁] [SeminormedRing 𝕜₂] {σ₁₂ : 𝕜₁ →+* 𝕜₂}
{M₁ M₂ M₃ : Type*} [SeminormedAddCommGroup M₁] [TopologicalSpace M₂] [AddCommMonoid M₂]
[NormedSpace 𝕜₁ M₁] [Module 𝕜₂ M₂]
theorem IsCompactOperator.image_subset_compact_of_bounded [ContinuousConstSMul 𝕜₂ M₂]
{f : M₁ →ₛₗ[σ₁₂] M₂} (hf : IsCompactOperator f) {S : Set M₁} (hS : Bornology.IsBounded S) :
∃ K : Set M₂, IsCompact K ∧ f '' S ⊆ K :=
hf.image_subset_compact_of_isVonNBounded <| by rwa [NormedSpace.isVonNBounded_iff]
theorem IsCompactOperator.isCompact_closure_image_of_bounded [ContinuousConstSMul 𝕜₂ M₂]
[T2Space M₂] {f : M₁ →ₛₗ[σ₁₂] M₂} (hf : IsCompactOperator f) {S : Set M₁}
(hS : Bornology.IsBounded S) : IsCompact (closure <| f '' S) :=
hf.isCompact_closure_image_of_isVonNBounded <| by rwa [NormedSpace.isVonNBounded_iff]
theorem IsCompactOperator.image_ball_subset_compact [ContinuousConstSMul 𝕜₂ M₂] {f : M₁ →ₛₗ[σ₁₂] M₂}
(hf : IsCompactOperator f) (r : ℝ) : ∃ K : Set M₂, IsCompact K ∧ f '' Metric.ball 0 r ⊆ K :=
hf.image_subset_compact_of_isVonNBounded (NormedSpace.isVonNBounded_ball 𝕜₁ M₁ r)
theorem IsCompactOperator.image_closedBall_subset_compact [ContinuousConstSMul 𝕜₂ M₂]
{f : M₁ →ₛₗ[σ₁₂] M₂} (hf : IsCompactOperator f) (r : ℝ) :
∃ K : Set M₂, IsCompact K ∧ f '' Metric.closedBall 0 r ⊆ K :=
hf.image_subset_compact_of_isVonNBounded (NormedSpace.isVonNBounded_closedBall 𝕜₁ M₁ r)
theorem IsCompactOperator.isCompact_closure_image_ball [ContinuousConstSMul 𝕜₂ M₂] [T2Space M₂]
{f : M₁ →ₛₗ[σ₁₂] M₂} (hf : IsCompactOperator f) (r : ℝ) :
IsCompact (closure <| f '' Metric.ball 0 r) :=
hf.isCompact_closure_image_of_isVonNBounded (NormedSpace.isVonNBounded_ball 𝕜₁ M₁ r)
theorem IsCompactOperator.isCompact_closure_image_closedBall [ContinuousConstSMul 𝕜₂ M₂]
[T2Space M₂] {f : M₁ →ₛₗ[σ₁₂] M₂} (hf : IsCompactOperator f) (r : ℝ) :
IsCompact (closure <| f '' Metric.closedBall 0 r) :=
hf.isCompact_closure_image_of_isVonNBounded (NormedSpace.isVonNBounded_closedBall 𝕜₁ M₁ r)
theorem isCompactOperator_iff_image_ball_subset_compact [ContinuousConstSMul 𝕜₂ M₂]
(f : M₁ →ₛₗ[σ₁₂] M₂) {r : ℝ} (hr : 0 < r) :
IsCompactOperator f ↔ ∃ K : Set M₂, IsCompact K ∧ f '' Metric.ball 0 r ⊆ K :=
⟨fun hf => hf.image_ball_subset_compact r, fun ⟨K, hK, hKr⟩ =>
(isCompactOperator_iff_exists_mem_nhds_image_subset_compact f).mpr
⟨Metric.ball 0 r, ball_mem_nhds _ hr, K, hK, hKr⟩⟩
theorem isCompactOperator_iff_image_closedBall_subset_compact [ContinuousConstSMul 𝕜₂ M₂]
(f : M₁ →ₛₗ[σ₁₂] M₂) {r : ℝ} (hr : 0 < r) :
IsCompactOperator f ↔ ∃ K : Set M₂, IsCompact K ∧ f '' Metric.closedBall 0 r ⊆ K :=
⟨fun hf => hf.image_closedBall_subset_compact r, fun ⟨K, hK, hKr⟩ =>
(isCompactOperator_iff_exists_mem_nhds_image_subset_compact f).mpr
⟨Metric.closedBall 0 r, closedBall_mem_nhds _ hr, K, hK, hKr⟩⟩
theorem isCompactOperator_iff_isCompact_closure_image_ball [ContinuousConstSMul 𝕜₂ M₂] [T2Space M₂]
(f : M₁ →ₛₗ[σ₁₂] M₂) {r : ℝ} (hr : 0 < r) :
IsCompactOperator f ↔ IsCompact (closure <| f '' Metric.ball 0 r) :=
⟨fun hf => hf.isCompact_closure_image_ball r, fun hf =>
(isCompactOperator_iff_exists_mem_nhds_isCompact_closure_image f).mpr
⟨Metric.ball 0 r, ball_mem_nhds _ hr, hf⟩⟩
theorem isCompactOperator_iff_isCompact_closure_image_closedBall [ContinuousConstSMul 𝕜₂ M₂]
[T2Space M₂] (f : M₁ →ₛₗ[σ₁₂] M₂) {r : ℝ} (hr : 0 < r) :
IsCompactOperator f ↔ IsCompact (closure <| f '' Metric.closedBall 0 r) :=
⟨fun hf => hf.isCompact_closure_image_closedBall r, fun hf =>
(isCompactOperator_iff_exists_mem_nhds_isCompact_closure_image f).mpr
⟨Metric.closedBall 0 r, closedBall_mem_nhds _ hr, hf⟩⟩
end NormedSpace
end Characterizations
section Operations
variable {R₁ R₂ R₃ R₄ : Type*} [Semiring R₁] [Semiring R₂] [CommSemiring R₃] [CommSemiring R₄]
{σ₁₂ : R₁ →+* R₂} {σ₁₄ : R₁ →+* R₄} {σ₃₄ : R₃ →+* R₄} {M₁ M₂ M₃ M₄ : Type*} [TopologicalSpace M₁]
[AddCommMonoid M₁] [TopologicalSpace M₂] [AddCommMonoid M₂] [TopologicalSpace M₃]
[AddCommGroup M₃] [TopologicalSpace M₄] [AddCommGroup M₄]
theorem IsCompactOperator.smul {S : Type*} [Monoid S] [DistribMulAction S M₂]
[ContinuousConstSMul S M₂] {f : M₁ → M₂} (hf : IsCompactOperator f) (c : S) :
IsCompactOperator (c • f) :=
let ⟨K, hK, hKf⟩ := hf
⟨c • K, hK.image <| continuous_id.const_smul c,
mem_of_superset hKf fun _ hx => smul_mem_smul_set hx⟩
theorem IsCompactOperator.add [ContinuousAdd M₂] {f g : M₁ → M₂} (hf : IsCompactOperator f)
(hg : IsCompactOperator g) : IsCompactOperator (f + g) :=
let ⟨A, hA, hAf⟩ := hf
let ⟨B, hB, hBg⟩ := hg
⟨A + B, hA.add hB,
mem_of_superset (inter_mem hAf hBg) fun _ ⟨hxA, hxB⟩ => Set.add_mem_add hxA hxB⟩
theorem IsCompactOperator.neg [ContinuousNeg M₄] {f : M₁ → M₄} (hf : IsCompactOperator f) :
IsCompactOperator (-f) :=
let ⟨K, hK, hKf⟩ := hf
⟨-K, hK.neg, mem_of_superset hKf fun x (hx : f x ∈ K) => Set.neg_mem_neg.mpr hx⟩
theorem IsCompactOperator.sub [TopologicalAddGroup M₄] {f g : M₁ → M₄} (hf : IsCompactOperator f)
(hg : IsCompactOperator g) : IsCompactOperator (f - g) := by
rw [sub_eq_add_neg]; exact hf.add hg.neg
variable (σ₁₄ M₁ M₄)
/-- The submodule of compact continuous linear maps. -/
def compactOperator [Module R₁ M₁] [Module R₄ M₄] [ContinuousConstSMul R₄ M₄]
[TopologicalAddGroup M₄] : Submodule R₄ (M₁ →SL[σ₁₄] M₄) where
carrier := { f | IsCompactOperator f }
add_mem' hf hg := hf.add hg
zero_mem' := isCompactOperator_zero
smul_mem' c _ hf := hf.smul c
end Operations
section Comp
variable {R₁ R₂ R₃ : Type*} [Semiring R₁] [Semiring R₂] [Semiring R₃] {σ₁₂ : R₁ →+* R₂}
{σ₂₃ : R₂ →+* R₃} {M₁ M₂ M₃ : Type*} [TopologicalSpace M₁] [TopologicalSpace M₂]
[TopologicalSpace M₃] [AddCommMonoid M₁] [Module R₁ M₁]
theorem IsCompactOperator.comp_clm [AddCommMonoid M₂] [Module R₂ M₂] {f : M₂ → M₃}
(hf : IsCompactOperator f) (g : M₁ →SL[σ₁₂] M₂) : IsCompactOperator (f ∘ g) := by
have := g.continuous.tendsto 0
rw [map_zero] at this
rcases hf with ⟨K, hK, hKf⟩
exact ⟨K, hK, this hKf⟩
theorem IsCompactOperator.continuous_comp {f : M₁ → M₂} (hf : IsCompactOperator f) {g : M₂ → M₃}
(hg : Continuous g) : IsCompactOperator (g ∘ f) := by
rcases hf with ⟨K, hK, hKf⟩
refine ⟨g '' K, hK.image hg, mem_of_superset hKf ?_⟩
rw [preimage_comp]
exact preimage_mono (subset_preimage_image _ _)
theorem IsCompactOperator.clm_comp [AddCommMonoid M₂] [Module R₂ M₂] [AddCommMonoid M₃]
[Module R₃ M₃] {f : M₁ → M₂} (hf : IsCompactOperator f) (g : M₂ →SL[σ₂₃] M₃) :
IsCompactOperator (g ∘ f) :=
hf.continuous_comp g.continuous
end Comp
section CodRestrict
variable {R₁ R₂ : Type*} [Semiring R₁] [Semiring R₂] {σ₁₂ : R₁ →+* R₂} {M₁ M₂ : Type*}
[TopologicalSpace M₁] [TopologicalSpace M₂] [AddCommMonoid M₁] [AddCommMonoid M₂] [Module R₁ M₁]
[Module R₂ M₂]
theorem IsCompactOperator.codRestrict {f : M₁ → M₂} (hf : IsCompactOperator f) {V : Submodule R₂ M₂}
(hV : ∀ x, f x ∈ V) (h_closed : IsClosed (V : Set M₂)) :
IsCompactOperator (Set.codRestrict f V hV) :=
let ⟨_, hK, hKf⟩ := hf
⟨_, (closedEmbedding_subtype_val h_closed).isCompact_preimage hK, hKf⟩
end CodRestrict
section Restrict
variable {R₁ R₂ R₃ : Type*} [Semiring R₁] [Semiring R₂] [Semiring R₃] {σ₁₂ : R₁ →+* R₂}
{σ₂₃ : R₂ →+* R₃} {M₁ M₂ M₃ : Type*} [TopologicalSpace M₁] [UniformSpace M₂]
[TopologicalSpace M₃] [AddCommMonoid M₁] [AddCommMonoid M₂] [AddCommMonoid M₃] [Module R₁ M₁]
[Module R₂ M₂] [Module R₃ M₃]
/-- If a compact operator preserves a closed submodule, its restriction to that submodule is
compact.
Note that, following mathlib's convention in linear algebra, `restrict` designates the restriction
of an endomorphism `f : E →ₗ E` to an endomorphism `f' : ↥V →ₗ ↥V`. To prove that the restriction
`f' : ↥U →ₛₗ ↥V` of a compact operator `f : E →ₛₗ F` is compact, apply
`IsCompactOperator.codRestrict` to `f ∘ U.subtypeL`, which is compact by
`IsCompactOperator.comp_clm`. -/
theorem IsCompactOperator.restrict {f : M₁ →ₗ[R₁] M₁} (hf : IsCompactOperator f)
{V : Submodule R₁ M₁} (hV : ∀ v ∈ V, f v ∈ V) (h_closed : IsClosed (V : Set M₁)) :
IsCompactOperator (f.restrict hV) :=
(hf.comp_clm V.subtypeL).codRestrict (SetLike.forall.2 hV) h_closed
/-- If a compact operator preserves a complete submodule, its restriction to that submodule is
compact.
Note that, following mathlib's convention in linear algebra, `restrict` designates the restriction
of an endomorphism `f : E →ₗ E` to an endomorphism `f' : ↥V →ₗ ↥V`. To prove that the restriction
`f' : ↥U →ₛₗ ↥V` of a compact operator `f : E →ₛₗ F` is compact, apply
`IsCompactOperator.codRestrict` to `f ∘ U.subtypeL`, which is compact by
`IsCompactOperator.comp_clm`. -/
theorem IsCompactOperator.restrict' [T0Space M₂] {f : M₂ →ₗ[R₂] M₂}
(hf : IsCompactOperator f) {V : Submodule R₂ M₂} (hV : ∀ v ∈ V, f v ∈ V)
[hcomplete : CompleteSpace V] : IsCompactOperator (f.restrict hV) :=
hf.restrict hV (completeSpace_coe_iff_isComplete.mp hcomplete).isClosed
end Restrict
section Continuous
variable {𝕜₁ 𝕜₂ : Type*} [NontriviallyNormedField 𝕜₁] [NontriviallyNormedField 𝕜₂]
{σ₁₂ : 𝕜₁ →+* 𝕜₂} [RingHomIsometric σ₁₂] {M₁ M₂ : Type*} [TopologicalSpace M₁] [AddCommGroup M₁]
[TopologicalSpace M₂] [AddCommGroup M₂] [Module 𝕜₁ M₁] [Module 𝕜₂ M₂] [TopologicalAddGroup M₁]
[ContinuousConstSMul 𝕜₁ M₁] [TopologicalAddGroup M₂] [ContinuousSMul 𝕜₂ M₂]
@[continuity]
theorem IsCompactOperator.continuous {f : M₁ →ₛₗ[σ₁₂] M₂} (hf : IsCompactOperator f) :
Continuous f := by
letI : UniformSpace M₂ := TopologicalAddGroup.toUniformSpace _
haveI : UniformAddGroup M₂ := comm_topologicalAddGroup_is_uniform
-- Since `f` is linear, we only need to show that it is continuous at zero.
-- Let `U` be a neighborhood of `0` in `M₂`.
refine continuous_of_continuousAt_zero f fun U hU => ?_
rw [map_zero] at hU
-- The compactness of `f` gives us a compact set `K : Set M₂` such that `f ⁻¹' K` is a
-- neighborhood of `0` in `M₁`.
rcases hf with ⟨K, hK, hKf⟩
-- But any compact set is totally bounded, hence Von-Neumann bounded. Thus, `K` absorbs `U`.
-- This gives `r > 0` such that `∀ a : 𝕜₂, r ≤ ‖a‖ → K ⊆ a • U`.
rcases (hK.totallyBounded.isVonNBounded 𝕜₂ hU).exists_pos with ⟨r, hr, hrU⟩
-- Choose `c : 𝕜₂` with `r < ‖c‖`.
rcases NormedField.exists_lt_norm 𝕜₁ r with ⟨c, hc⟩
have hcnz : c ≠ 0 := ne_zero_of_norm_ne_zero (hr.trans hc).ne.symm
-- We have `f ⁻¹' ((σ₁₂ c⁻¹) • K) = c⁻¹ • f ⁻¹' K ∈ 𝓝 0`. Thus, showing that
-- `(σ₁₂ c⁻¹) • K ⊆ U` is enough to deduce that `f ⁻¹' U ∈ 𝓝 0`.
suffices (σ₁₂ <| c⁻¹) • K ⊆ U by
refine mem_of_superset ?_ this
have : IsUnit c⁻¹ := hcnz.isUnit.inv
rwa [mem_map, preimage_smul_setₛₗ _ _ _ f this, set_smul_mem_nhds_zero_iff (inv_ne_zero hcnz)]
-- Since `σ₁₂ c⁻¹` = `(σ₁₂ c)⁻¹`, we have to prove that `K ⊆ σ₁₂ c • U`.
rw [map_inv₀, ← subset_set_smul_iff₀ ((map_ne_zero σ₁₂).mpr hcnz)]
-- But `σ₁₂` is isometric, so `‖σ₁₂ c‖ = ‖c‖ > r`, which concludes the argument since
-- `∀ a : 𝕜₂, r ≤ ‖a‖ → K ⊆ a • U`.
refine hrU (σ₁₂ c) ?_
rw [RingHomIsometric.is_iso]
exact hc.le
/-- Upgrade a compact `LinearMap` to a `ContinuousLinearMap`. -/
def ContinuousLinearMap.mkOfIsCompactOperator {f : M₁ →ₛₗ[σ₁₂] M₂} (hf : IsCompactOperator f) :
M₁ →SL[σ₁₂] M₂ :=
⟨f, hf.continuous⟩
@[simp]
theorem ContinuousLinearMap.mkOfIsCompactOperator_to_linearMap {f : M₁ →ₛₗ[σ₁₂] M₂}
(hf : IsCompactOperator f) :
(ContinuousLinearMap.mkOfIsCompactOperator hf : M₁ →ₛₗ[σ₁₂] M₂) = f :=
rfl
@[simp]
theorem ContinuousLinearMap.coe_mkOfIsCompactOperator {f : M₁ →ₛₗ[σ₁₂] M₂}
(hf : IsCompactOperator f) : (ContinuousLinearMap.mkOfIsCompactOperator hf : M₁ → M₂) = f :=
rfl
theorem ContinuousLinearMap.mkOfIsCompactOperator_mem_compactOperator {f : M₁ →ₛₗ[σ₁₂] M₂}
(hf : IsCompactOperator f) :
ContinuousLinearMap.mkOfIsCompactOperator hf ∈ compactOperator σ₁₂ M₁ M₂ :=
hf
end Continuous
/-- The set of compact operators from a normed space to a complete topological vector space is
closed. -/
theorem isClosed_setOf_isCompactOperator {𝕜₁ 𝕜₂ : Type*} [NontriviallyNormedField 𝕜₁]
[NormedField 𝕜₂] {σ₁₂ : 𝕜₁ →+* 𝕜₂} {M₁ M₂ : Type*} [SeminormedAddCommGroup M₁]
[AddCommGroup M₂] [NormedSpace 𝕜₁ M₁] [Module 𝕜₂ M₂] [UniformSpace M₂] [UniformAddGroup M₂]
[ContinuousConstSMul 𝕜₂ M₂] [T2Space M₂] [CompleteSpace M₂] :
IsClosed { f : M₁ →SL[σ₁₂] M₂ | IsCompactOperator f } := by
refine isClosed_of_closure_subset ?_
rintro u hu
rw [mem_closure_iff_nhds_zero] at hu
suffices TotallyBounded (u '' Metric.closedBall 0 1) by
change IsCompactOperator (u : M₁ →ₛₗ[σ₁₂] M₂)
rw [isCompactOperator_iff_isCompact_closure_image_closedBall (u : M₁ →ₛₗ[σ₁₂] M₂) zero_lt_one]
exact isCompact_of_totallyBounded_isClosed this.closure isClosed_closure
rw [totallyBounded_iff_subset_finite_iUnion_nhds_zero]
intro U hU
rcases exists_nhds_zero_half hU with ⟨V, hV, hVU⟩
let SV : Set M₁ × Set M₂ := ⟨closedBall 0 1, -V⟩
rcases hu { f | ∀ x ∈ SV.1, f x ∈ SV.2 }
(ContinuousLinearMap.hasBasis_nhds_zero.mem_of_mem
⟨NormedSpace.isVonNBounded_closedBall _ _ _, neg_mem_nhds_zero M₂ hV⟩) with
⟨v, hv, huv⟩
rcases totallyBounded_iff_subset_finite_iUnion_nhds_zero.mp
(hv.isCompact_closure_image_closedBall 1).totallyBounded V hV with
⟨T, hT, hTv⟩
have hTv : v '' closedBall 0 1 ⊆ _ := subset_closure.trans hTv
refine ⟨T, hT, ?_⟩
rw [image_subset_iff, preimage_iUnion₂] at hTv ⊢
intro x hx
specialize hTv hx
rw [mem_iUnion₂] at hTv ⊢
rcases hTv with ⟨t, ht, htx⟩
refine ⟨t, ht, ?_⟩
rw [mem_preimage, mem_vadd_set_iff_neg_vadd_mem, vadd_eq_add, neg_add_eq_sub] at htx ⊢
convert hVU _ htx _ (huv x hx) using 1
rw [ContinuousLinearMap.sub_apply]
abel
theorem compactOperator_topologicalClosure {𝕜₁ 𝕜₂ : Type*} [NontriviallyNormedField 𝕜₁]
[NormedField 𝕜₂] {σ₁₂ : 𝕜₁ →+* 𝕜₂} {M₁ M₂ : Type*} [SeminormedAddCommGroup M₁]
[AddCommGroup M₂] [NormedSpace 𝕜₁ M₁] [Module 𝕜₂ M₂] [UniformSpace M₂] [UniformAddGroup M₂]
[ContinuousConstSMul 𝕜₂ M₂] [T2Space M₂] [CompleteSpace M₂] :
(compactOperator σ₁₂ M₁ M₂).topologicalClosure = compactOperator σ₁₂ M₁ M₂ :=
SetLike.ext' isClosed_setOf_isCompactOperator.closure_eq
theorem isCompactOperator_of_tendsto {ι 𝕜₁ 𝕜₂ : Type*} [NontriviallyNormedField 𝕜₁]
[NormedField 𝕜₂] {σ₁₂ : 𝕜₁ →+* 𝕜₂} {M₁ M₂ : Type*} [SeminormedAddCommGroup M₁]
[AddCommGroup M₂] [NormedSpace 𝕜₁ M₁] [Module 𝕜₂ M₂] [UniformSpace M₂] [UniformAddGroup M₂]
[ContinuousConstSMul 𝕜₂ M₂] [T2Space M₂] [CompleteSpace M₂] {l : Filter ι} [l.NeBot]
{F : ι → M₁ →SL[σ₁₂] M₂} {f : M₁ →SL[σ₁₂] M₂} (hf : Tendsto F l (𝓝 f))
(hF : ∀ᶠ i in l, IsCompactOperator (F i)) : IsCompactOperator f :=
isClosed_setOf_isCompactOperator.mem_of_tendsto hf hF
|
Analysis\Normed\Operator\ContinuousLinearMap.lean | /-
Copyright (c) 2019 Jan-David Salchow. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jan-David Salchow, Sébastien Gouëzel, Jean Lo
-/
import Mathlib.Topology.Algebra.Module.Basic
import Mathlib.Analysis.Normed.MulAction
/-! # Constructions of continuous linear maps between (semi-)normed spaces
A fundamental fact about (semi-)linear maps between normed spaces over sensible fields is that
continuity and boundedness are equivalent conditions. That is, for normed spaces `E`, `F`, a
`LinearMap` `f : E →ₛₗ[σ] F` is the coercion of some `ContinuousLinearMap` `f' : E →SL[σ] F`, if
and only if there exists a bound `C` such that for all `x`, `‖f x‖ ≤ C * ‖x‖`.
We prove one direction in this file: `LinearMap.mkContinuous`, boundedness implies continuity. The
other direction, `ContinuousLinearMap.bound`, is deferred to a later file, where the
strong operator topology on `E →SL[σ] F` is available, because it is natural to use
`ContinuousLinearMap.bound` to define a norm `⨆ x, ‖f x‖ / ‖x‖` on `E →SL[σ] F` and to show that
this is compatible with the strong operator topology.
This file also contains several corollaries of `LinearMap.mkContinuous`: other "easy"
constructions of continuous linear maps between normed spaces.
This file is meant to be lightweight (it is imported by much of the analysis library); think twice
before adding imports!
-/
open Metric ContinuousLinearMap
open Set Real
open NNReal
variable {𝕜 𝕜₂ E F G : Type*}
/-! # General constructions -/
section SeminormedAddCommGroup
variable [Ring 𝕜] [Ring 𝕜₂]
variable [SeminormedAddCommGroup E] [SeminormedAddCommGroup F] [SeminormedAddCommGroup G]
variable [Module 𝕜 E] [Module 𝕜₂ F] [Module 𝕜 G]
variable {σ : 𝕜 →+* 𝕜₂} (f : E →ₛₗ[σ] F)
/-- Construct a continuous linear map from a linear map and a bound on this linear map.
The fact that the norm of the continuous linear map is then controlled is given in
`LinearMap.mkContinuous_norm_le`. -/
def LinearMap.mkContinuous (C : ℝ) (h : ∀ x, ‖f x‖ ≤ C * ‖x‖) : E →SL[σ] F :=
⟨f, AddMonoidHomClass.continuous_of_bound f C h⟩
/-- Construct a continuous linear map from a linear map and the existence of a bound on this linear
map. If you have an explicit bound, use `LinearMap.mkContinuous` instead, as a norm estimate will
follow automatically in `LinearMap.mkContinuous_norm_le`. -/
def LinearMap.mkContinuousOfExistsBound (h : ∃ C, ∀ x, ‖f x‖ ≤ C * ‖x‖) : E →SL[σ] F :=
⟨f,
let ⟨C, hC⟩ := h
AddMonoidHomClass.continuous_of_bound f C hC⟩
theorem continuous_of_linear_of_boundₛₗ {f : E → F} (h_add : ∀ x y, f (x + y) = f x + f y)
(h_smul : ∀ (c : 𝕜) (x), f (c • x) = σ c • f x) {C : ℝ} (h_bound : ∀ x, ‖f x‖ ≤ C * ‖x‖) :
Continuous f :=
let φ : E →ₛₗ[σ] F :=
{ toFun := f
map_add' := h_add
map_smul' := h_smul }
AddMonoidHomClass.continuous_of_bound φ C h_bound
theorem continuous_of_linear_of_bound {f : E → G} (h_add : ∀ x y, f (x + y) = f x + f y)
(h_smul : ∀ (c : 𝕜) (x), f (c • x) = c • f x) {C : ℝ} (h_bound : ∀ x, ‖f x‖ ≤ C * ‖x‖) :
Continuous f :=
let φ : E →ₗ[𝕜] G :=
{ toFun := f
map_add' := h_add
map_smul' := h_smul }
AddMonoidHomClass.continuous_of_bound φ C h_bound
@[simp, norm_cast]
theorem LinearMap.mkContinuous_coe (C : ℝ) (h : ∀ x, ‖f x‖ ≤ C * ‖x‖) :
(f.mkContinuous C h : E →ₛₗ[σ] F) = f :=
rfl
@[simp]
theorem LinearMap.mkContinuous_apply (C : ℝ) (h : ∀ x, ‖f x‖ ≤ C * ‖x‖) (x : E) :
f.mkContinuous C h x = f x :=
rfl
@[simp, norm_cast]
theorem LinearMap.mkContinuousOfExistsBound_coe (h : ∃ C, ∀ x, ‖f x‖ ≤ C * ‖x‖) :
(f.mkContinuousOfExistsBound h : E →ₛₗ[σ] F) = f :=
rfl
@[simp]
theorem LinearMap.mkContinuousOfExistsBound_apply (h : ∃ C, ∀ x, ‖f x‖ ≤ C * ‖x‖) (x : E) :
f.mkContinuousOfExistsBound h x = f x :=
rfl
namespace ContinuousLinearMap
theorem antilipschitz_of_bound (f : E →SL[σ] F) {K : ℝ≥0} (h : ∀ x, ‖x‖ ≤ K * ‖f x‖) :
AntilipschitzWith K f :=
AddMonoidHomClass.antilipschitz_of_bound _ h
theorem bound_of_antilipschitz (f : E →SL[σ] F) {K : ℝ≥0} (h : AntilipschitzWith K f) (x) :
‖x‖ ≤ K * ‖f x‖ :=
ZeroHomClass.bound_of_antilipschitz _ h x
end ContinuousLinearMap
section
variable {σ₂₁ : 𝕜₂ →+* 𝕜} [RingHomInvPair σ σ₂₁] [RingHomInvPair σ₂₁ σ]
/-- Construct a continuous linear equivalence from a linear equivalence together with
bounds in both directions. -/
def LinearEquiv.toContinuousLinearEquivOfBounds (e : E ≃ₛₗ[σ] F) (C_to C_inv : ℝ)
(h_to : ∀ x, ‖e x‖ ≤ C_to * ‖x‖) (h_inv : ∀ x : F, ‖e.symm x‖ ≤ C_inv * ‖x‖) : E ≃SL[σ] F where
toLinearEquiv := e
continuous_toFun := AddMonoidHomClass.continuous_of_bound e C_to h_to
continuous_invFun := AddMonoidHomClass.continuous_of_bound e.symm C_inv h_inv
end
end SeminormedAddCommGroup
section SeminormedBounded
variable [SeminormedRing 𝕜] [Ring 𝕜₂] [SeminormedAddCommGroup E]
variable [Module 𝕜 E] [BoundedSMul 𝕜 E]
/-- Reinterpret a linear map `𝕜 →ₗ[𝕜] E` as a continuous linear map. This construction
is generalized to the case of any finite dimensional domain
in `LinearMap.toContinuousLinearMap`. -/
def LinearMap.toContinuousLinearMap₁ (f : 𝕜 →ₗ[𝕜] E) : 𝕜 →L[𝕜] E :=
f.mkContinuous ‖f 1‖ fun x => by
conv_lhs => rw [← mul_one x]
rw [← smul_eq_mul, f.map_smul, mul_comm]; exact norm_smul_le _ _
@[simp]
theorem LinearMap.toContinuousLinearMap₁_coe (f : 𝕜 →ₗ[𝕜] E) :
(f.toContinuousLinearMap₁ : 𝕜 →ₗ[𝕜] E) = f :=
rfl
@[simp]
theorem LinearMap.toContinuousLinearMap₁_apply (f : 𝕜 →ₗ[𝕜] E) (x) :
f.toContinuousLinearMap₁ x = f x :=
rfl
end SeminormedBounded
section Normed
variable [Ring 𝕜] [Ring 𝕜₂]
variable [NormedAddCommGroup E] [NormedAddCommGroup F] [Module 𝕜 E] [Module 𝕜₂ F]
variable {σ : 𝕜 →+* 𝕜₂} (f g : E →SL[σ] F) (x y z : E)
theorem ContinuousLinearMap.uniformEmbedding_of_bound {K : ℝ≥0} (hf : ∀ x, ‖x‖ ≤ K * ‖f x‖) :
UniformEmbedding f :=
(AddMonoidHomClass.antilipschitz_of_bound f hf).uniformEmbedding f.uniformContinuous
end Normed
/-! ## Homotheties -/
section Seminormed
variable [Ring 𝕜] [Ring 𝕜₂]
variable [SeminormedAddCommGroup E] [SeminormedAddCommGroup F]
variable [Module 𝕜 E] [Module 𝕜₂ F]
variable {σ : 𝕜 →+* 𝕜₂} (f : E →ₛₗ[σ] F)
/-- A (semi-)linear map which is a homothety is a continuous linear map.
Since the field `𝕜` need not have `ℝ` as a subfield, this theorem is not directly deducible from
the corresponding theorem about isometries plus a theorem about scalar multiplication. Likewise
for the other theorems about homotheties in this file.
-/
def ContinuousLinearMap.ofHomothety (f : E →ₛₗ[σ] F) (a : ℝ) (hf : ∀ x, ‖f x‖ = a * ‖x‖) :
E →SL[σ] F :=
f.mkContinuous a fun x => le_of_eq (hf x)
variable {σ₂₁ : 𝕜₂ →+* 𝕜} [RingHomInvPair σ σ₂₁] [RingHomInvPair σ₂₁ σ]
theorem ContinuousLinearEquiv.homothety_inverse (a : ℝ) (ha : 0 < a) (f : E ≃ₛₗ[σ] F) :
(∀ x : E, ‖f x‖ = a * ‖x‖) → ∀ y : F, ‖f.symm y‖ = a⁻¹ * ‖y‖ := by
intro hf y
calc
‖f.symm y‖ = a⁻¹ * (a * ‖f.symm y‖) := by
rw [← mul_assoc, inv_mul_cancel (ne_of_lt ha).symm, one_mul]
_ = a⁻¹ * ‖f (f.symm y)‖ := by rw [hf]
_ = a⁻¹ * ‖y‖ := by simp
/-- A linear equivalence which is a homothety is a continuous linear equivalence. -/
noncomputable def ContinuousLinearEquiv.ofHomothety (f : E ≃ₛₗ[σ] F) (a : ℝ) (ha : 0 < a)
(hf : ∀ x, ‖f x‖ = a * ‖x‖) : E ≃SL[σ] F :=
LinearEquiv.toContinuousLinearEquivOfBounds f a a⁻¹ (fun x => (hf x).le) fun x =>
(ContinuousLinearEquiv.homothety_inverse a ha f hf x).le
end Seminormed
|
Analysis\Normed\Operator\LinearIsometry.lean | /-
Copyright (c) 2021 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov, Frédéric Dupuis, Heather Macbeth
-/
import Mathlib.Algebra.Star.Basic
import Mathlib.Analysis.Normed.Group.Constructions
import Mathlib.Analysis.Normed.Group.Submodule
import Mathlib.Analysis.Normed.Group.Uniform
import Mathlib.Topology.Algebra.Module.Basic
import Mathlib.LinearAlgebra.Basis
/-!
# (Semi-)linear isometries
In this file we define `LinearIsometry σ₁₂ E E₂` (notation: `E →ₛₗᵢ[σ₁₂] E₂`) to be a semilinear
isometric embedding of `E` into `E₂` and `LinearIsometryEquiv` (notation: `E ≃ₛₗᵢ[σ₁₂] E₂`) to be
a semilinear isometric equivalence between `E` and `E₂`. The notation for the associated purely
linear concepts is `E →ₗᵢ[R] E₂`, `E ≃ₗᵢ[R] E₂`, and `E →ₗᵢ⋆[R] E₂`, `E ≃ₗᵢ⋆[R] E₂` for
the star-linear versions.
We also prove some trivial lemmas and provide convenience constructors.
Since a lot of elementary properties don't require `‖x‖ = 0 → x = 0` we start setting up the
theory for `SeminormedAddCommGroup` and we specialize to `NormedAddCommGroup` when needed.
-/
open Function Set
variable {R R₂ R₃ R₄ E E₂ E₃ E₄ F 𝓕 : Type*} [Semiring R] [Semiring R₂] [Semiring R₃] [Semiring R₄]
{σ₁₂ : R →+* R₂} {σ₂₁ : R₂ →+* R} {σ₁₃ : R →+* R₃} {σ₃₁ : R₃ →+* R} {σ₁₄ : R →+* R₄}
{σ₄₁ : R₄ →+* R} {σ₂₃ : R₂ →+* R₃} {σ₃₂ : R₃ →+* R₂} {σ₂₄ : R₂ →+* R₄} {σ₄₂ : R₄ →+* R₂}
{σ₃₄ : R₃ →+* R₄} {σ₄₃ : R₄ →+* R₃} [RingHomInvPair σ₁₂ σ₂₁] [RingHomInvPair σ₂₁ σ₁₂]
[RingHomInvPair σ₁₃ σ₃₁] [RingHomInvPair σ₃₁ σ₁₃] [RingHomInvPair σ₂₃ σ₃₂]
[RingHomInvPair σ₃₂ σ₂₃] [RingHomInvPair σ₁₄ σ₄₁] [RingHomInvPair σ₄₁ σ₁₄]
[RingHomInvPair σ₂₄ σ₄₂] [RingHomInvPair σ₄₂ σ₂₄] [RingHomInvPair σ₃₄ σ₄₃]
[RingHomInvPair σ₄₃ σ₃₄] [RingHomCompTriple σ₁₂ σ₂₃ σ₁₃] [RingHomCompTriple σ₁₂ σ₂₄ σ₁₄]
[RingHomCompTriple σ₂₃ σ₃₄ σ₂₄] [RingHomCompTriple σ₁₃ σ₃₄ σ₁₄] [RingHomCompTriple σ₃₂ σ₂₁ σ₃₁]
[RingHomCompTriple σ₄₂ σ₂₁ σ₄₁] [RingHomCompTriple σ₄₃ σ₃₂ σ₄₂] [RingHomCompTriple σ₄₃ σ₃₁ σ₄₁]
[SeminormedAddCommGroup E] [SeminormedAddCommGroup E₂] [SeminormedAddCommGroup E₃]
[SeminormedAddCommGroup E₄] [Module R E] [Module R₂ E₂] [Module R₃ E₃] [Module R₄ E₄]
[NormedAddCommGroup F] [Module R F]
/-- A `σ₁₂`-semilinear isometric embedding of a normed `R`-module into an `R₂`-module. -/
structure LinearIsometry (σ₁₂ : R →+* R₂) (E E₂ : Type*) [SeminormedAddCommGroup E]
[SeminormedAddCommGroup E₂] [Module R E] [Module R₂ E₂] extends E →ₛₗ[σ₁₂] E₂ where
norm_map' : ∀ x, ‖toLinearMap x‖ = ‖x‖
@[inherit_doc]
notation:25 E " →ₛₗᵢ[" σ₁₂:25 "] " E₂:0 => LinearIsometry σ₁₂ E E₂
/-- A linear isometric embedding of a normed `R`-module into another one. -/
notation:25 E " →ₗᵢ[" R:25 "] " E₂:0 => LinearIsometry (RingHom.id R) E E₂
/-- An antilinear isometric embedding of a normed `R`-module into another one. -/
notation:25 E " →ₗᵢ⋆[" R:25 "] " E₂:0 => LinearIsometry (starRingEnd R) E E₂
/-- `SemilinearIsometryClass F σ E E₂` asserts `F` is a type of bundled `σ`-semilinear isometries
`E → E₂`.
See also `LinearIsometryClass F R E E₂` for the case where `σ` is the identity map on `R`.
A map `f` between an `R`-module and an `S`-module over a ring homomorphism `σ : R →+* S`
is semilinear if it satisfies the two properties `f (x + y) = f x + f y` and
`f (c • x) = (σ c) • f x`. -/
class SemilinearIsometryClass (𝓕 : Type*) {R R₂ : outParam Type*} [Semiring R] [Semiring R₂]
(σ₁₂ : outParam <| R →+* R₂) (E E₂ : outParam Type*) [SeminormedAddCommGroup E]
[SeminormedAddCommGroup E₂] [Module R E] [Module R₂ E₂] [FunLike 𝓕 E E₂] extends
SemilinearMapClass 𝓕 σ₁₂ E E₂ : Prop where
norm_map : ∀ (f : 𝓕) (x : E), ‖f x‖ = ‖x‖
/-- `LinearIsometryClass F R E E₂` asserts `F` is a type of bundled `R`-linear isometries
`M → M₂`.
This is an abbreviation for `SemilinearIsometryClass F (RingHom.id R) E E₂`.
-/
abbrev LinearIsometryClass (𝓕 : Type*) (R E E₂ : outParam Type*) [Semiring R]
[SeminormedAddCommGroup E] [SeminormedAddCommGroup E₂] [Module R E] [Module R E₂]
[FunLike 𝓕 E E₂] :=
SemilinearIsometryClass 𝓕 (RingHom.id R) E E₂
namespace SemilinearIsometryClass
variable [FunLike 𝓕 E E₂]
protected theorem isometry [SemilinearIsometryClass 𝓕 σ₁₂ E E₂] (f : 𝓕) : Isometry f :=
AddMonoidHomClass.isometry_of_norm _ (norm_map _)
@[continuity]
protected theorem continuous [SemilinearIsometryClass 𝓕 σ₁₂ E E₂] (f : 𝓕) : Continuous f :=
(SemilinearIsometryClass.isometry f).continuous
-- Should be `@[simp]` but it doesn't fire due to `lean4#3107`.
theorem nnnorm_map [SemilinearIsometryClass 𝓕 σ₁₂ E E₂] (f : 𝓕) (x : E) : ‖f x‖₊ = ‖x‖₊ :=
NNReal.eq <| norm_map f x
protected theorem lipschitz [SemilinearIsometryClass 𝓕 σ₁₂ E E₂] (f : 𝓕) : LipschitzWith 1 f :=
(SemilinearIsometryClass.isometry f).lipschitz
protected theorem antilipschitz [SemilinearIsometryClass 𝓕 σ₁₂ E E₂] (f : 𝓕) :
AntilipschitzWith 1 f :=
(SemilinearIsometryClass.isometry f).antilipschitz
theorem ediam_image [SemilinearIsometryClass 𝓕 σ₁₂ E E₂] (f : 𝓕) (s : Set E) :
EMetric.diam (f '' s) = EMetric.diam s :=
(SemilinearIsometryClass.isometry f).ediam_image s
theorem ediam_range [SemilinearIsometryClass 𝓕 σ₁₂ E E₂] (f : 𝓕) :
EMetric.diam (range f) = EMetric.diam (univ : Set E) :=
(SemilinearIsometryClass.isometry f).ediam_range
theorem diam_image [SemilinearIsometryClass 𝓕 σ₁₂ E E₂] (f : 𝓕) (s : Set E) :
Metric.diam (f '' s) = Metric.diam s :=
(SemilinearIsometryClass.isometry f).diam_image s
theorem diam_range [SemilinearIsometryClass 𝓕 σ₁₂ E E₂] (f : 𝓕) :
Metric.diam (range f) = Metric.diam (univ : Set E) :=
(SemilinearIsometryClass.isometry f).diam_range
instance (priority := 100) toContinuousSemilinearMapClass
[SemilinearIsometryClass 𝓕 σ₁₂ E E₂] : ContinuousSemilinearMapClass 𝓕 σ₁₂ E E₂ where
map_continuous := SemilinearIsometryClass.continuous
end SemilinearIsometryClass
namespace LinearIsometry
variable (f : E →ₛₗᵢ[σ₁₂] E₂) (f₁ : F →ₛₗᵢ[σ₁₂] E₂)
theorem toLinearMap_injective : Injective (toLinearMap : (E →ₛₗᵢ[σ₁₂] E₂) → E →ₛₗ[σ₁₂] E₂)
| ⟨_, _⟩, ⟨_, _⟩, rfl => rfl
@[simp]
theorem toLinearMap_inj {f g : E →ₛₗᵢ[σ₁₂] E₂} : f.toLinearMap = g.toLinearMap ↔ f = g :=
toLinearMap_injective.eq_iff
instance instFunLike : FunLike (E →ₛₗᵢ[σ₁₂] E₂) E E₂ where
coe f := f.toFun
coe_injective' _ _ h := toLinearMap_injective (DFunLike.coe_injective h)
instance instSemilinearIsometryClass : SemilinearIsometryClass (E →ₛₗᵢ[σ₁₂] E₂) σ₁₂ E E₂ where
map_add f := map_add f.toLinearMap
map_smulₛₗ f := map_smulₛₗ f.toLinearMap
norm_map f := f.norm_map'
@[simp]
theorem coe_toLinearMap : ⇑f.toLinearMap = f :=
rfl
@[simp]
theorem coe_mk (f : E →ₛₗ[σ₁₂] E₂) (hf) : ⇑(mk f hf) = f :=
rfl
theorem coe_injective : @Injective (E →ₛₗᵢ[σ₁₂] E₂) (E → E₂) (fun f => f) := by
rintro ⟨_⟩ ⟨_⟩
simp
/-- See Note [custom simps projection]. We need to specify this projection explicitly in this case,
because it is a composition of multiple projections. -/
def Simps.apply (σ₁₂ : R →+* R₂) (E E₂ : Type*) [SeminormedAddCommGroup E]
[SeminormedAddCommGroup E₂] [Module R E] [Module R₂ E₂] (h : E →ₛₗᵢ[σ₁₂] E₂) : E → E₂ :=
h
initialize_simps_projections LinearIsometry (toLinearMap_toFun → apply)
@[ext]
theorem ext {f g : E →ₛₗᵢ[σ₁₂] E₂} (h : ∀ x, f x = g x) : f = g :=
coe_injective <| funext h
variable [FunLike 𝓕 E E₂]
-- @[simp] -- Porting note (#10618): simp can prove this
protected theorem map_zero : f 0 = 0 :=
f.toLinearMap.map_zero
-- @[simp] -- Porting note (#10618): simp can prove this
protected theorem map_add (x y : E) : f (x + y) = f x + f y :=
f.toLinearMap.map_add x y
-- @[simp] -- Porting note (#10618): simp can prove this
protected theorem map_neg (x : E) : f (-x) = -f x :=
f.toLinearMap.map_neg x
-- @[simp] -- Porting note (#10618): simp can prove this
protected theorem map_sub (x y : E) : f (x - y) = f x - f y :=
f.toLinearMap.map_sub x y
-- @[simp] -- Porting note (#10618): simp can prove this
protected theorem map_smulₛₗ (c : R) (x : E) : f (c • x) = σ₁₂ c • f x :=
f.toLinearMap.map_smulₛₗ c x
-- @[simp] -- Porting note (#10618): simp can prove this
protected theorem map_smul [Module R E₂] (f : E →ₗᵢ[R] E₂) (c : R) (x : E) : f (c • x) = c • f x :=
f.toLinearMap.map_smul c x
@[simp]
theorem norm_map (x : E) : ‖f x‖ = ‖x‖ :=
SemilinearIsometryClass.norm_map f x
@[simp] -- Should be replaced with `SemilinearIsometryClass.nnorm_map` when `lean4#3107` is fixed.
theorem nnnorm_map (x : E) : ‖f x‖₊ = ‖x‖₊ :=
NNReal.eq <| norm_map f x
protected theorem isometry : Isometry f :=
AddMonoidHomClass.isometry_of_norm f.toLinearMap (norm_map _)
-- Should be `@[simp]` but it doesn't fire due to `lean4#3107`.
theorem isComplete_image_iff [SemilinearIsometryClass 𝓕 σ₁₂ E E₂] (f : 𝓕) {s : Set E} :
IsComplete (f '' s) ↔ IsComplete s :=
_root_.isComplete_image_iff (SemilinearIsometryClass.isometry f).uniformInducing
@[simp] -- Should be replaced with `LinearIsometry.isComplete_image_iff` when `lean4#3107` is fixed.
theorem isComplete_image_iff' (f : LinearIsometry σ₁₂ E E₂) {s : Set E} :
IsComplete (f '' s) ↔ IsComplete s :=
LinearIsometry.isComplete_image_iff _
theorem isComplete_map_iff [RingHomSurjective σ₁₂] {p : Submodule R E} :
IsComplete (p.map f.toLinearMap : Set E₂) ↔ IsComplete (p : Set E) :=
isComplete_image_iff f
theorem isComplete_map_iff' [SemilinearIsometryClass 𝓕 σ₁₂ E E₂] (f : 𝓕) [RingHomSurjective σ₁₂]
{p : Submodule R E} : IsComplete (p.map f : Set E₂) ↔ IsComplete (p : Set E) :=
isComplete_image_iff f
instance completeSpace_map [SemilinearIsometryClass 𝓕 σ₁₂ E E₂] (f : 𝓕) [RingHomSurjective σ₁₂]
(p : Submodule R E) [CompleteSpace p] : CompleteSpace (p.map f) :=
((isComplete_map_iff' f).2 <| completeSpace_coe_iff_isComplete.1 ‹_›).completeSpace_coe
instance completeSpace_map' [RingHomSurjective σ₁₂] (p : Submodule R E) [CompleteSpace p] :
CompleteSpace (p.map f.toLinearMap) :=
(f.isComplete_map_iff.2 <| completeSpace_coe_iff_isComplete.1 ‹_›).completeSpace_coe
@[simp]
theorem dist_map (x y : E) : dist (f x) (f y) = dist x y :=
f.isometry.dist_eq x y
@[simp]
theorem edist_map (x y : E) : edist (f x) (f y) = edist x y :=
f.isometry.edist_eq x y
protected theorem injective : Injective f₁ :=
Isometry.injective (LinearIsometry.isometry f₁)
@[simp]
theorem map_eq_iff {x y : F} : f₁ x = f₁ y ↔ x = y :=
f₁.injective.eq_iff
theorem map_ne {x y : F} (h : x ≠ y) : f₁ x ≠ f₁ y :=
f₁.injective.ne h
protected theorem lipschitz : LipschitzWith 1 f :=
f.isometry.lipschitz
protected theorem antilipschitz : AntilipschitzWith 1 f :=
f.isometry.antilipschitz
@[continuity]
protected theorem continuous : Continuous f :=
f.isometry.continuous
@[simp]
theorem preimage_ball (x : E) (r : ℝ) : f ⁻¹' Metric.ball (f x) r = Metric.ball x r :=
f.isometry.preimage_ball x r
@[simp]
theorem preimage_sphere (x : E) (r : ℝ) : f ⁻¹' Metric.sphere (f x) r = Metric.sphere x r :=
f.isometry.preimage_sphere x r
@[simp]
theorem preimage_closedBall (x : E) (r : ℝ) :
f ⁻¹' Metric.closedBall (f x) r = Metric.closedBall x r :=
f.isometry.preimage_closedBall x r
theorem ediam_image (s : Set E) : EMetric.diam (f '' s) = EMetric.diam s :=
f.isometry.ediam_image s
theorem ediam_range : EMetric.diam (range f) = EMetric.diam (univ : Set E) :=
f.isometry.ediam_range
theorem diam_image (s : Set E) : Metric.diam (f '' s) = Metric.diam s :=
Isometry.diam_image (LinearIsometry.isometry f) s
theorem diam_range : Metric.diam (range f) = Metric.diam (univ : Set E) :=
Isometry.diam_range (LinearIsometry.isometry f)
/-- Interpret a linear isometry as a continuous linear map. -/
def toContinuousLinearMap : E →SL[σ₁₂] E₂ :=
⟨f.toLinearMap, f.continuous⟩
theorem toContinuousLinearMap_injective :
Function.Injective (toContinuousLinearMap : _ → E →SL[σ₁₂] E₂) := fun x _ h =>
coe_injective (congr_arg _ h : ⇑x.toContinuousLinearMap = _)
@[simp]
theorem toContinuousLinearMap_inj {f g : E →ₛₗᵢ[σ₁₂] E₂} :
f.toContinuousLinearMap = g.toContinuousLinearMap ↔ f = g :=
toContinuousLinearMap_injective.eq_iff
@[simp]
theorem coe_toContinuousLinearMap : ⇑f.toContinuousLinearMap = f :=
rfl
@[simp]
theorem comp_continuous_iff {α : Type*} [TopologicalSpace α] {g : α → E} :
Continuous (f ∘ g) ↔ Continuous g :=
f.isometry.comp_continuous_iff
/-- The identity linear isometry. -/
def id : E →ₗᵢ[R] E :=
⟨LinearMap.id, fun _ => rfl⟩
@[simp]
theorem coe_id : ((id : E →ₗᵢ[R] E) : E → E) = _root_.id :=
rfl
@[simp]
theorem id_apply (x : E) : (id : E →ₗᵢ[R] E) x = x :=
rfl
@[simp]
theorem id_toLinearMap : (id.toLinearMap : E →ₗ[R] E) = LinearMap.id :=
rfl
@[simp]
theorem id_toContinuousLinearMap : id.toContinuousLinearMap = ContinuousLinearMap.id R E :=
rfl
instance instInhabited : Inhabited (E →ₗᵢ[R] E) := ⟨id⟩
/-- Composition of linear isometries. -/
def comp (g : E₂ →ₛₗᵢ[σ₂₃] E₃) (f : E →ₛₗᵢ[σ₁₂] E₂) : E →ₛₗᵢ[σ₁₃] E₃ :=
⟨g.toLinearMap.comp f.toLinearMap, fun _ => (norm_map g _).trans (norm_map f _)⟩
@[simp]
theorem coe_comp (g : E₂ →ₛₗᵢ[σ₂₃] E₃) (f : E →ₛₗᵢ[σ₁₂] E₂) : ⇑(g.comp f) = g ∘ f :=
rfl
@[simp]
theorem id_comp : (id : E₂ →ₗᵢ[R₂] E₂).comp f = f :=
ext fun _ => rfl
@[simp]
theorem comp_id : f.comp id = f :=
ext fun _ => rfl
theorem comp_assoc (f : E₃ →ₛₗᵢ[σ₃₄] E₄) (g : E₂ →ₛₗᵢ[σ₂₃] E₃) (h : E →ₛₗᵢ[σ₁₂] E₂) :
(f.comp g).comp h = f.comp (g.comp h) :=
rfl
instance instMonoid : Monoid (E →ₗᵢ[R] E) where
one := id
mul := comp
mul_assoc := comp_assoc
one_mul := id_comp
mul_one := comp_id
@[simp]
theorem coe_one : ((1 : E →ₗᵢ[R] E) : E → E) = _root_.id :=
rfl
@[simp]
theorem coe_mul (f g : E →ₗᵢ[R] E) : ⇑(f * g) = f ∘ g :=
rfl
theorem one_def : (1 : E →ₗᵢ[R] E) = id :=
rfl
theorem mul_def (f g : E →ₗᵢ[R] E) : (f * g : E →ₗᵢ[R] E) = f.comp g :=
rfl
theorem coe_pow (f : E →ₗᵢ[R] E) (n : ℕ) : ⇑(f ^ n) = f^[n] :=
hom_coe_pow _ rfl (fun _ _ ↦ rfl) _ _
end LinearIsometry
/-- Construct a `LinearIsometry` from a `LinearMap` satisfying `Isometry`. -/
def LinearMap.toLinearIsometry (f : E →ₛₗ[σ₁₂] E₂) (hf : Isometry f) : E →ₛₗᵢ[σ₁₂] E₂ :=
{ f with
norm_map' := by
simp_rw [← dist_zero_right]
simpa using (hf.dist_eq · 0) }
namespace Submodule
variable {R' : Type*} [Ring R'] [Module R' E] (p : Submodule R' E)
/-- `Submodule.subtype` as a `LinearIsometry`. -/
def subtypeₗᵢ : p →ₗᵢ[R'] E :=
⟨p.subtype, fun _ => rfl⟩
@[simp]
theorem coe_subtypeₗᵢ : ⇑p.subtypeₗᵢ = p.subtype :=
rfl
@[simp]
theorem subtypeₗᵢ_toLinearMap : p.subtypeₗᵢ.toLinearMap = p.subtype :=
rfl
@[simp]
theorem subtypeₗᵢ_toContinuousLinearMap : p.subtypeₗᵢ.toContinuousLinearMap = p.subtypeL :=
rfl
end Submodule
/-- A semilinear isometric equivalence between two normed vector spaces. -/
structure LinearIsometryEquiv (σ₁₂ : R →+* R₂) {σ₂₁ : R₂ →+* R} [RingHomInvPair σ₁₂ σ₂₁]
[RingHomInvPair σ₂₁ σ₁₂] (E E₂ : Type*) [SeminormedAddCommGroup E] [SeminormedAddCommGroup E₂]
[Module R E] [Module R₂ E₂] extends E ≃ₛₗ[σ₁₂] E₂ where
norm_map' : ∀ x, ‖toLinearEquiv x‖ = ‖x‖
@[inherit_doc]
notation:25 E " ≃ₛₗᵢ[" σ₁₂:25 "] " E₂:0 => LinearIsometryEquiv σ₁₂ E E₂
/-- A linear isometric equivalence between two normed vector spaces. -/
notation:25 E " ≃ₗᵢ[" R:25 "] " E₂:0 => LinearIsometryEquiv (RingHom.id R) E E₂
/-- An antilinear isometric equivalence between two normed vector spaces. -/
notation:25 E " ≃ₗᵢ⋆[" R:25 "] " E₂:0 => LinearIsometryEquiv (starRingEnd R) E E₂
/-- `SemilinearIsometryEquivClass F σ E E₂` asserts `F` is a type of bundled `σ`-semilinear
isometric equivs `E → E₂`.
See also `LinearIsometryEquivClass F R E E₂` for the case where `σ` is the identity map on `R`.
A map `f` between an `R`-module and an `S`-module over a ring homomorphism `σ : R →+* S`
is semilinear if it satisfies the two properties `f (x + y) = f x + f y` and
`f (c • x) = (σ c) • f x`. -/
class SemilinearIsometryEquivClass (𝓕 : Type*) {R R₂ : outParam Type*} [Semiring R]
[Semiring R₂] (σ₁₂ : outParam <| R →+* R₂) {σ₂₁ : outParam <| R₂ →+* R} [RingHomInvPair σ₁₂ σ₂₁]
[RingHomInvPair σ₂₁ σ₁₂] (E E₂ : outParam Type*) [SeminormedAddCommGroup E]
[SeminormedAddCommGroup E₂] [Module R E] [Module R₂ E₂] [EquivLike 𝓕 E E₂]
extends SemilinearEquivClass 𝓕 σ₁₂ E E₂ : Prop where
norm_map : ∀ (f : 𝓕) (x : E), ‖f x‖ = ‖x‖
/-- `LinearIsometryEquivClass F R E E₂` asserts `F` is a type of bundled `R`-linear isometries
`M → M₂`.
This is an abbreviation for `SemilinearIsometryEquivClass F (RingHom.id R) E E₂`.
-/
abbrev LinearIsometryEquivClass (𝓕 : Type*) (R E E₂ : outParam Type*) [Semiring R]
[SeminormedAddCommGroup E] [SeminormedAddCommGroup E₂] [Module R E] [Module R E₂]
[EquivLike 𝓕 E E₂] :=
SemilinearIsometryEquivClass 𝓕 (RingHom.id R) E E₂
namespace SemilinearIsometryEquivClass
variable (𝓕)
-- `σ₂₁` becomes a metavariable, but it's OK since it's an outparam
instance (priority := 100) toSemilinearIsometryClass [EquivLike 𝓕 E E₂]
[s : SemilinearIsometryEquivClass 𝓕 σ₁₂ E E₂] : SemilinearIsometryClass 𝓕 σ₁₂ E E₂ :=
{ s with }
end SemilinearIsometryEquivClass
namespace LinearIsometryEquiv
variable (e : E ≃ₛₗᵢ[σ₁₂] E₂)
theorem toLinearEquiv_injective : Injective (toLinearEquiv : (E ≃ₛₗᵢ[σ₁₂] E₂) → E ≃ₛₗ[σ₁₂] E₂)
| ⟨_, _⟩, ⟨_, _⟩, rfl => rfl
@[simp]
theorem toLinearEquiv_inj {f g : E ≃ₛₗᵢ[σ₁₂] E₂} : f.toLinearEquiv = g.toLinearEquiv ↔ f = g :=
toLinearEquiv_injective.eq_iff
instance instEquivLike : EquivLike (E ≃ₛₗᵢ[σ₁₂] E₂) E E₂ where
coe e := e.toFun
inv e := e.invFun
coe_injective' f g h₁ h₂ := by
cases' f with f' _
cases' g with g' _
cases f'
cases g'
simp only [AddHom.toFun_eq_coe, LinearMap.coe_toAddHom, DFunLike.coe_fn_eq] at h₁
congr
left_inv e := e.left_inv
right_inv e := e.right_inv
instance instSemilinearIsometryEquivClass :
SemilinearIsometryEquivClass (E ≃ₛₗᵢ[σ₁₂] E₂) σ₁₂ E E₂ where
map_add f := map_add f.toLinearEquiv
map_smulₛₗ e := map_smulₛₗ e.toLinearEquiv
norm_map e := e.norm_map'
-- TODO: Shouldn't these `CoeFun` instances be scrapped?
/-- Helper instance for when there's too many metavariables to apply `DFunLike.hasCoeToFun`
directly. -/
instance instCoeFun : CoeFun (E ≃ₛₗᵢ[σ₁₂] E₂) fun _ ↦ E → E₂ := ⟨DFunLike.coe⟩
theorem coe_injective : @Function.Injective (E ≃ₛₗᵢ[σ₁₂] E₂) (E → E₂) (↑) :=
DFunLike.coe_injective
@[simp]
theorem coe_mk (e : E ≃ₛₗ[σ₁₂] E₂) (he : ∀ x, ‖e x‖ = ‖x‖) : ⇑(mk e he) = e :=
rfl
@[simp]
theorem coe_toLinearEquiv (e : E ≃ₛₗᵢ[σ₁₂] E₂) : ⇑e.toLinearEquiv = e :=
rfl
@[ext]
theorem ext {e e' : E ≃ₛₗᵢ[σ₁₂] E₂} (h : ∀ x, e x = e' x) : e = e' :=
toLinearEquiv_injective <| LinearEquiv.ext h
protected theorem congr_arg {f : E ≃ₛₗᵢ[σ₁₂] E₂} : ∀ {x x' : E}, x = x' → f x = f x'
| _, _, rfl => rfl
protected theorem congr_fun {f g : E ≃ₛₗᵢ[σ₁₂] E₂} (h : f = g) (x : E) : f x = g x :=
h ▸ rfl
/-- Construct a `LinearIsometryEquiv` from a `LinearEquiv` and two inequalities:
`∀ x, ‖e x‖ ≤ ‖x‖` and `∀ y, ‖e.symm y‖ ≤ ‖y‖`. -/
def ofBounds (e : E ≃ₛₗ[σ₁₂] E₂) (h₁ : ∀ x, ‖e x‖ ≤ ‖x‖) (h₂ : ∀ y, ‖e.symm y‖ ≤ ‖y‖) :
E ≃ₛₗᵢ[σ₁₂] E₂ :=
⟨e, fun x => le_antisymm (h₁ x) <| by simpa only [e.symm_apply_apply] using h₂ (e x)⟩
@[simp]
theorem norm_map (x : E) : ‖e x‖ = ‖x‖ :=
e.norm_map' x
/-- Reinterpret a `LinearIsometryEquiv` as a `LinearIsometry`. -/
def toLinearIsometry : E →ₛₗᵢ[σ₁₂] E₂ :=
⟨e.1, e.2⟩
theorem toLinearIsometry_injective : Function.Injective (toLinearIsometry : _ → E →ₛₗᵢ[σ₁₂] E₂) :=
fun x _ h => coe_injective (congr_arg _ h : ⇑x.toLinearIsometry = _)
@[simp]
theorem toLinearIsometry_inj {f g : E ≃ₛₗᵢ[σ₁₂] E₂} :
f.toLinearIsometry = g.toLinearIsometry ↔ f = g :=
toLinearIsometry_injective.eq_iff
@[simp]
theorem coe_toLinearIsometry : ⇑e.toLinearIsometry = e :=
rfl
protected theorem isometry : Isometry e :=
e.toLinearIsometry.isometry
/-- Reinterpret a `LinearIsometryEquiv` as an `IsometryEquiv`. -/
def toIsometryEquiv : E ≃ᵢ E₂ :=
⟨e.toLinearEquiv.toEquiv, e.isometry⟩
theorem toIsometryEquiv_injective :
Function.Injective (toIsometryEquiv : (E ≃ₛₗᵢ[σ₁₂] E₂) → E ≃ᵢ E₂) := fun x _ h =>
coe_injective (congr_arg _ h : ⇑x.toIsometryEquiv = _)
@[simp]
theorem toIsometryEquiv_inj {f g : E ≃ₛₗᵢ[σ₁₂] E₂} :
f.toIsometryEquiv = g.toIsometryEquiv ↔ f = g :=
toIsometryEquiv_injective.eq_iff
@[simp]
theorem coe_toIsometryEquiv : ⇑e.toIsometryEquiv = e :=
rfl
theorem range_eq_univ (e : E ≃ₛₗᵢ[σ₁₂] E₂) : Set.range e = Set.univ := by
rw [← coe_toIsometryEquiv]
exact IsometryEquiv.range_eq_univ _
/-- Reinterpret a `LinearIsometryEquiv` as a `Homeomorph`. -/
def toHomeomorph : E ≃ₜ E₂ :=
e.toIsometryEquiv.toHomeomorph
theorem toHomeomorph_injective : Function.Injective (toHomeomorph : (E ≃ₛₗᵢ[σ₁₂] E₂) → E ≃ₜ E₂) :=
fun x _ h => coe_injective (congr_arg _ h : ⇑x.toHomeomorph = _)
@[simp]
theorem toHomeomorph_inj {f g : E ≃ₛₗᵢ[σ₁₂] E₂} : f.toHomeomorph = g.toHomeomorph ↔ f = g :=
toHomeomorph_injective.eq_iff
@[simp]
theorem coe_toHomeomorph : ⇑e.toHomeomorph = e :=
rfl
protected theorem continuous : Continuous e :=
e.isometry.continuous
protected theorem continuousAt {x} : ContinuousAt e x :=
e.continuous.continuousAt
protected theorem continuousOn {s} : ContinuousOn e s :=
e.continuous.continuousOn
protected theorem continuousWithinAt {s x} : ContinuousWithinAt e s x :=
e.continuous.continuousWithinAt
/-- Interpret a `LinearIsometryEquiv` as a `ContinuousLinearEquiv`. -/
def toContinuousLinearEquiv : E ≃SL[σ₁₂] E₂ :=
{ e.toLinearIsometry.toContinuousLinearMap, e.toHomeomorph with }
theorem toContinuousLinearEquiv_injective :
Function.Injective (toContinuousLinearEquiv : _ → E ≃SL[σ₁₂] E₂) := fun x _ h =>
coe_injective (congr_arg _ h : ⇑x.toContinuousLinearEquiv = _)
@[simp]
theorem toContinuousLinearEquiv_inj {f g : E ≃ₛₗᵢ[σ₁₂] E₂} :
f.toContinuousLinearEquiv = g.toContinuousLinearEquiv ↔ f = g :=
toContinuousLinearEquiv_injective.eq_iff
@[simp]
theorem coe_toContinuousLinearEquiv : ⇑e.toContinuousLinearEquiv = e :=
rfl
variable (R E)
/-- Identity map as a `LinearIsometryEquiv`. -/
def refl : E ≃ₗᵢ[R] E :=
⟨LinearEquiv.refl R E, fun _ => rfl⟩
/-- Linear isometry equiv between a space and its lift to another universe. -/
def ulift : ULift E ≃ₗᵢ[R] E :=
{ ContinuousLinearEquiv.ulift with norm_map' := fun _ => rfl }
variable {R E}
instance instInhabited : Inhabited (E ≃ₗᵢ[R] E) := ⟨refl R E⟩
@[simp]
theorem coe_refl : ⇑(refl R E) = id :=
rfl
/-- The inverse `LinearIsometryEquiv`. -/
def symm : E₂ ≃ₛₗᵢ[σ₂₁] E :=
⟨e.toLinearEquiv.symm, fun x =>
(e.norm_map _).symm.trans <| congr_arg norm <| e.toLinearEquiv.apply_symm_apply x⟩
@[simp]
theorem apply_symm_apply (x : E₂) : e (e.symm x) = x :=
e.toLinearEquiv.apply_symm_apply x
@[simp]
theorem symm_apply_apply (x : E) : e.symm (e x) = x :=
e.toLinearEquiv.symm_apply_apply x
-- @[simp] -- Porting note (#10618): simp can prove this
theorem map_eq_zero_iff {x : E} : e x = 0 ↔ x = 0 :=
e.toLinearEquiv.map_eq_zero_iff
@[simp]
theorem symm_symm : e.symm.symm = e :=
ext fun _ => rfl
@[simp]
theorem toLinearEquiv_symm : e.toLinearEquiv.symm = e.symm.toLinearEquiv :=
rfl
@[simp]
theorem toIsometryEquiv_symm : e.toIsometryEquiv.symm = e.symm.toIsometryEquiv :=
rfl
@[simp]
theorem toHomeomorph_symm : e.toHomeomorph.symm = e.symm.toHomeomorph :=
rfl
/-- See Note [custom simps projection]. We need to specify this projection explicitly in this case,
because it is a composition of multiple projections. -/
def Simps.apply (σ₁₂ : R →+* R₂) {σ₂₁ : R₂ →+* R} [RingHomInvPair σ₁₂ σ₂₁] [RingHomInvPair σ₂₁ σ₁₂]
(E E₂ : Type*) [SeminormedAddCommGroup E] [SeminormedAddCommGroup E₂] [Module R E]
[Module R₂ E₂] (h : E ≃ₛₗᵢ[σ₁₂] E₂) : E → E₂ :=
h
/-- See Note [custom simps projection] -/
def Simps.symm_apply (σ₁₂ : R →+* R₂) {σ₂₁ : R₂ →+* R} [RingHomInvPair σ₁₂ σ₂₁]
[RingHomInvPair σ₂₁ σ₁₂] (E E₂ : Type*) [SeminormedAddCommGroup E] [SeminormedAddCommGroup E₂]
[Module R E] [Module R₂ E₂] (h : E ≃ₛₗᵢ[σ₁₂] E₂) : E₂ → E :=
h.symm
initialize_simps_projections LinearIsometryEquiv (toLinearEquiv_toFun → apply,
toLinearEquiv_invFun → symm_apply)
/-- Composition of `LinearIsometryEquiv`s as a `LinearIsometryEquiv`. -/
def trans (e' : E₂ ≃ₛₗᵢ[σ₂₃] E₃) : E ≃ₛₗᵢ[σ₁₃] E₃ :=
⟨e.toLinearEquiv.trans e'.toLinearEquiv, fun _ => (e'.norm_map _).trans (e.norm_map _)⟩
@[simp]
theorem coe_trans (e₁ : E ≃ₛₗᵢ[σ₁₂] E₂) (e₂ : E₂ ≃ₛₗᵢ[σ₂₃] E₃) : ⇑(e₁.trans e₂) = e₂ ∘ e₁ :=
rfl
@[simp]
theorem trans_apply (e₁ : E ≃ₛₗᵢ[σ₁₂] E₂) (e₂ : E₂ ≃ₛₗᵢ[σ₂₃] E₃) (c : E) :
(e₁.trans e₂ : E ≃ₛₗᵢ[σ₁₃] E₃) c = e₂ (e₁ c) :=
rfl
@[simp]
theorem toLinearEquiv_trans (e' : E₂ ≃ₛₗᵢ[σ₂₃] E₃) :
(e.trans e').toLinearEquiv = e.toLinearEquiv.trans e'.toLinearEquiv :=
rfl
@[simp]
theorem trans_refl : e.trans (refl R₂ E₂) = e :=
ext fun _ => rfl
@[simp]
theorem refl_trans : (refl R E).trans e = e :=
ext fun _ => rfl
@[simp]
theorem self_trans_symm : e.trans e.symm = refl R E :=
ext e.symm_apply_apply
@[simp]
theorem symm_trans_self : e.symm.trans e = refl R₂ E₂ :=
ext e.apply_symm_apply
@[simp]
theorem symm_comp_self : e.symm ∘ e = id :=
funext e.symm_apply_apply
@[simp]
theorem self_comp_symm : e ∘ e.symm = id :=
e.symm.symm_comp_self
@[simp]
theorem symm_trans (e₁ : E ≃ₛₗᵢ[σ₁₂] E₂) (e₂ : E₂ ≃ₛₗᵢ[σ₂₃] E₃) :
(e₁.trans e₂).symm = e₂.symm.trans e₁.symm :=
rfl
theorem coe_symm_trans (e₁ : E ≃ₛₗᵢ[σ₁₂] E₂) (e₂ : E₂ ≃ₛₗᵢ[σ₂₃] E₃) :
⇑(e₁.trans e₂).symm = e₁.symm ∘ e₂.symm :=
rfl
theorem trans_assoc (eEE₂ : E ≃ₛₗᵢ[σ₁₂] E₂) (eE₂E₃ : E₂ ≃ₛₗᵢ[σ₂₃] E₃) (eE₃E₄ : E₃ ≃ₛₗᵢ[σ₃₄] E₄) :
eEE₂.trans (eE₂E₃.trans eE₃E₄) = (eEE₂.trans eE₂E₃).trans eE₃E₄ :=
rfl
instance instGroup : Group (E ≃ₗᵢ[R] E) where
mul e₁ e₂ := e₂.trans e₁
one := refl _ _
inv := symm
one_mul := trans_refl
mul_one := refl_trans
mul_assoc _ _ _ := trans_assoc _ _ _
mul_left_inv := self_trans_symm
@[simp]
theorem coe_one : ⇑(1 : E ≃ₗᵢ[R] E) = id :=
rfl
@[simp]
theorem coe_mul (e e' : E ≃ₗᵢ[R] E) : ⇑(e * e') = e ∘ e' :=
rfl
@[simp]
theorem coe_inv (e : E ≃ₗᵢ[R] E) : ⇑e⁻¹ = e.symm :=
rfl
theorem one_def : (1 : E ≃ₗᵢ[R] E) = refl _ _ :=
rfl
theorem mul_def (e e' : E ≃ₗᵢ[R] E) : (e * e' : E ≃ₗᵢ[R] E) = e'.trans e :=
rfl
theorem inv_def (e : E ≃ₗᵢ[R] E) : (e⁻¹ : E ≃ₗᵢ[R] E) = e.symm :=
rfl
/-! Lemmas about mixing the group structure with definitions. Because we have multiple ways to
express `LinearIsometryEquiv.refl`, `LinearIsometryEquiv.symm`, and
`LinearIsometryEquiv.trans`, we want simp lemmas for every combination.
The assumption made here is that if you're using the group structure, you want to preserve it
after simp.
This copies the approach used by the lemmas near `Equiv.Perm.trans_one`. -/
@[simp]
theorem trans_one : e.trans (1 : E₂ ≃ₗᵢ[R₂] E₂) = e :=
trans_refl _
@[simp]
theorem one_trans : (1 : E ≃ₗᵢ[R] E).trans e = e :=
refl_trans _
@[simp]
theorem refl_mul (e : E ≃ₗᵢ[R] E) : refl _ _ * e = e :=
trans_refl _
@[simp]
theorem mul_refl (e : E ≃ₗᵢ[R] E) : e * refl _ _ = e :=
refl_trans _
/-- Reinterpret a `LinearIsometryEquiv` as a `ContinuousLinearEquiv`. -/
instance instCoeTCContinuousLinearEquiv : CoeTC (E ≃ₛₗᵢ[σ₁₂] E₂) (E ≃SL[σ₁₂] E₂) :=
⟨fun e => ⟨e.toLinearEquiv, e.continuous, e.toIsometryEquiv.symm.continuous⟩⟩
instance instCoeTCContinuousLinearMap : CoeTC (E ≃ₛₗᵢ[σ₁₂] E₂) (E →SL[σ₁₂] E₂) :=
⟨fun e => ↑(e : E ≃SL[σ₁₂] E₂)⟩
@[simp]
theorem coe_coe : ⇑(e : E ≃SL[σ₁₂] E₂) = e :=
rfl
-- @[simp] -- Porting note: now a syntactic tautology
-- theorem coe_coe' : ((e : E ≃SL[σ₁₂] E₂) : E →SL[σ₁₂] E₂) = e :=
-- rfl
@[simp]
theorem coe_coe'' : ⇑(e : E →SL[σ₁₂] E₂) = e :=
rfl
-- @[simp] -- Porting note (#10618): simp can prove this
theorem map_zero : e 0 = 0 :=
e.1.map_zero
-- @[simp] -- Porting note (#10618): simp can prove this
theorem map_add (x y : E) : e (x + y) = e x + e y :=
e.1.map_add x y
-- @[simp] -- Porting note (#10618): simp can prove this
theorem map_sub (x y : E) : e (x - y) = e x - e y :=
e.1.map_sub x y
-- @[simp] -- Porting note (#10618): simp can prove this
theorem map_smulₛₗ (c : R) (x : E) : e (c • x) = σ₁₂ c • e x :=
e.1.map_smulₛₗ c x
-- @[simp] -- Porting note (#10618): simp can prove this
theorem map_smul [Module R E₂] {e : E ≃ₗᵢ[R] E₂} (c : R) (x : E) : e (c • x) = c • e x :=
e.1.map_smul c x
@[simp] -- Should be replaced with `SemilinearIsometryClass.nnorm_map` when `lean4#3107` is fixed.
theorem nnnorm_map (x : E) : ‖e x‖₊ = ‖x‖₊ :=
SemilinearIsometryClass.nnnorm_map e x
@[simp]
theorem dist_map (x y : E) : dist (e x) (e y) = dist x y :=
e.toLinearIsometry.dist_map x y
@[simp]
theorem edist_map (x y : E) : edist (e x) (e y) = edist x y :=
e.toLinearIsometry.edist_map x y
protected theorem bijective : Bijective e :=
e.1.bijective
protected theorem injective : Injective e :=
e.1.injective
protected theorem surjective : Surjective e :=
e.1.surjective
-- @[simp] -- Porting note (#10618): simp can prove this
theorem map_eq_iff {x y : E} : e x = e y ↔ x = y :=
e.injective.eq_iff
theorem map_ne {x y : E} (h : x ≠ y) : e x ≠ e y :=
e.injective.ne h
protected theorem lipschitz : LipschitzWith 1 e :=
e.isometry.lipschitz
protected theorem antilipschitz : AntilipschitzWith 1 e :=
e.isometry.antilipschitz
theorem image_eq_preimage (s : Set E) : e '' s = e.symm ⁻¹' s :=
e.toLinearEquiv.image_eq_preimage s
@[simp]
theorem ediam_image (s : Set E) : EMetric.diam (e '' s) = EMetric.diam s :=
e.isometry.ediam_image s
@[simp]
theorem diam_image (s : Set E) : Metric.diam (e '' s) = Metric.diam s :=
e.isometry.diam_image s
@[simp]
theorem preimage_ball (x : E₂) (r : ℝ) : e ⁻¹' Metric.ball x r = Metric.ball (e.symm x) r :=
e.toIsometryEquiv.preimage_ball x r
@[simp]
theorem preimage_sphere (x : E₂) (r : ℝ) : e ⁻¹' Metric.sphere x r = Metric.sphere (e.symm x) r :=
e.toIsometryEquiv.preimage_sphere x r
@[simp]
theorem preimage_closedBall (x : E₂) (r : ℝ) :
e ⁻¹' Metric.closedBall x r = Metric.closedBall (e.symm x) r :=
e.toIsometryEquiv.preimage_closedBall x r
@[simp]
theorem image_ball (x : E) (r : ℝ) : e '' Metric.ball x r = Metric.ball (e x) r :=
e.toIsometryEquiv.image_ball x r
@[simp]
theorem image_sphere (x : E) (r : ℝ) : e '' Metric.sphere x r = Metric.sphere (e x) r :=
e.toIsometryEquiv.image_sphere x r
@[simp]
theorem image_closedBall (x : E) (r : ℝ) : e '' Metric.closedBall x r = Metric.closedBall (e x) r :=
e.toIsometryEquiv.image_closedBall x r
variable {α : Type*} [TopologicalSpace α]
@[simp]
theorem comp_continuousOn_iff {f : α → E} {s : Set α} : ContinuousOn (e ∘ f) s ↔ ContinuousOn f s :=
e.isometry.comp_continuousOn_iff
@[simp]
theorem comp_continuous_iff {f : α → E} : Continuous (e ∘ f) ↔ Continuous f :=
e.isometry.comp_continuous_iff
instance completeSpace_map (p : Submodule R E) [CompleteSpace p] :
CompleteSpace (p.map (e.toLinearEquiv : E →ₛₗ[σ₁₂] E₂)) :=
e.toLinearIsometry.completeSpace_map' p
/-- Construct a linear isometry equiv from a surjective linear isometry. -/
noncomputable def ofSurjective (f : F →ₛₗᵢ[σ₁₂] E₂) (hfr : Function.Surjective f) :
F ≃ₛₗᵢ[σ₁₂] E₂ :=
{ LinearEquiv.ofBijective f.toLinearMap ⟨f.injective, hfr⟩ with norm_map' := f.norm_map }
@[simp]
theorem coe_ofSurjective (f : F →ₛₗᵢ[σ₁₂] E₂) (hfr : Function.Surjective f) :
⇑(LinearIsometryEquiv.ofSurjective f hfr) = f := by
ext
rfl
/-- If a linear isometry has an inverse, it is a linear isometric equivalence. -/
def ofLinearIsometry (f : E →ₛₗᵢ[σ₁₂] E₂) (g : E₂ →ₛₗ[σ₂₁] E)
(h₁ : f.toLinearMap.comp g = LinearMap.id) (h₂ : g.comp f.toLinearMap = LinearMap.id) :
E ≃ₛₗᵢ[σ₁₂] E₂ :=
{ LinearEquiv.ofLinear f.toLinearMap g h₁ h₂ with norm_map' := fun x => f.norm_map x }
@[simp]
theorem coe_ofLinearIsometry (f : E →ₛₗᵢ[σ₁₂] E₂) (g : E₂ →ₛₗ[σ₂₁] E)
(h₁ : f.toLinearMap.comp g = LinearMap.id) (h₂ : g.comp f.toLinearMap = LinearMap.id) :
(ofLinearIsometry f g h₁ h₂ : E → E₂) = (f : E → E₂) :=
rfl
@[simp]
theorem coe_ofLinearIsometry_symm (f : E →ₛₗᵢ[σ₁₂] E₂) (g : E₂ →ₛₗ[σ₂₁] E)
(h₁ : f.toLinearMap.comp g = LinearMap.id) (h₂ : g.comp f.toLinearMap = LinearMap.id) :
((ofLinearIsometry f g h₁ h₂).symm : E₂ → E) = (g : E₂ → E) :=
rfl
variable (R)
/-- The negation operation on a normed space `E`, considered as a linear isometry equivalence. -/
def neg : E ≃ₗᵢ[R] E :=
{ LinearEquiv.neg R with norm_map' := norm_neg }
variable {R}
@[simp]
theorem coe_neg : (neg R : E → E) = fun x => -x :=
rfl
@[simp]
theorem symm_neg : (neg R : E ≃ₗᵢ[R] E).symm = neg R :=
rfl
variable (R E E₂ E₃)
/-- The natural equivalence `(E × E₂) × E₃ ≃ E × (E₂ × E₃)` is a linear isometry. -/
def prodAssoc [Module R E₂] [Module R E₃] : (E × E₂) × E₃ ≃ₗᵢ[R] E × E₂ × E₃ :=
{ Equiv.prodAssoc E E₂ E₃ with
toFun := Equiv.prodAssoc E E₂ E₃
invFun := (Equiv.prodAssoc E E₂ E₃).symm
map_add' := by simp [-_root_.map_add] -- Fix timeout from #8386
map_smul' := by -- was `by simp` before #6057 caused that to time out.
rintro m ⟨⟨e, f⟩, g⟩
simp only [Prod.smul_mk, Equiv.prodAssoc_apply, RingHom.id_apply]
norm_map' := by
rintro ⟨⟨e, f⟩, g⟩
simp only [LinearEquiv.coe_mk, Equiv.prodAssoc_apply, Prod.norm_def, max_assoc] }
@[simp]
theorem coe_prodAssoc [Module R E₂] [Module R E₃] :
(prodAssoc R E E₂ E₃ : (E × E₂) × E₃ → E × E₂ × E₃) = Equiv.prodAssoc E E₂ E₃ :=
rfl
@[simp]
theorem coe_prodAssoc_symm [Module R E₂] [Module R E₃] :
((prodAssoc R E E₂ E₃).symm : E × E₂ × E₃ → (E × E₂) × E₃) = (Equiv.prodAssoc E E₂ E₃).symm :=
rfl
/-- If `p` is a submodule that is equal to `⊤`, then `LinearIsometryEquiv.ofTop p hp` is the
"identity" equivalence between `p` and `E`. -/
@[simps! toLinearEquiv apply symm_apply_coe]
def ofTop {R : Type*} [Ring R] [Module R E] (p : Submodule R E) (hp : p = ⊤) : p ≃ₗᵢ[R] E :=
{ p.subtypeₗᵢ with toLinearEquiv := LinearEquiv.ofTop p hp }
variable {R E E₂ E₃} {R' : Type*} [Ring R']
variable [Module R' E] (p q : Submodule R' E)
/-- `LinearEquiv.ofEq` as a `LinearIsometryEquiv`. -/
def ofEq (hpq : p = q) : p ≃ₗᵢ[R'] q :=
{ LinearEquiv.ofEq p q hpq with norm_map' := fun _ => rfl }
variable {p q}
@[simp]
theorem coe_ofEq_apply (h : p = q) (x : p) : (ofEq p q h x : E) = x :=
rfl
@[simp]
theorem ofEq_symm (h : p = q) : (ofEq p q h).symm = ofEq q p h.symm :=
rfl
@[simp]
theorem ofEq_rfl : ofEq p p rfl = LinearIsometryEquiv.refl R' p := rfl
end LinearIsometryEquiv
/-- Two linear isometries are equal if they are equal on basis vectors. -/
theorem Basis.ext_linearIsometry {ι : Type*} (b : Basis ι R E) {f₁ f₂ : E →ₛₗᵢ[σ₁₂] E₂}
(h : ∀ i, f₁ (b i) = f₂ (b i)) : f₁ = f₂ :=
LinearIsometry.toLinearMap_injective <| b.ext h
/-- Two linear isometric equivalences are equal if they are equal on basis vectors. -/
theorem Basis.ext_linearIsometryEquiv {ι : Type*} (b : Basis ι R E) {f₁ f₂ : E ≃ₛₗᵢ[σ₁₂] E₂}
(h : ∀ i, f₁ (b i) = f₂ (b i)) : f₁ = f₂ :=
LinearIsometryEquiv.toLinearEquiv_injective <| b.ext' h
/-- Reinterpret a `LinearIsometry` as a `LinearIsometryEquiv` to the range. -/
@[simps! apply_coe] -- Porting note: `toLinearEquiv` projection does not simplify using itself
noncomputable def LinearIsometry.equivRange {R S : Type*} [Semiring R] [Ring S] [Module S E]
[Module R F] {σ₁₂ : R →+* S} {σ₂₁ : S →+* R} [RingHomInvPair σ₁₂ σ₂₁] [RingHomInvPair σ₂₁ σ₁₂]
(f : F →ₛₗᵢ[σ₁₂] E) : F ≃ₛₗᵢ[σ₁₂] (LinearMap.range f.toLinearMap) :=
{ f with toLinearEquiv := LinearEquiv.ofInjective f.toLinearMap f.injective }
|
Analysis\Normed\Operator\WeakOperatorTopology.lean | /-
Copyright (c) 2024 Frédéric Dupuis. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Frédéric Dupuis
-/
import Mathlib.Analysis.LocallyConvex.WithSeminorms
import Mathlib.Analysis.Normed.Module.Dual
/-!
# The weak operator topology
This file defines a type copy of `E →L[𝕜] F` (where `F` is a normed space) which is
endowed with the weak operator topology (WOT) rather than the topology induced by the operator norm.
The WOT is defined as the coarsest topology such that the functional `fun A => y (A x)` is
continuous for any `x : E` and `y : NormedSpace.Dual 𝕜 F`. Equivalently, a function `f` tends to
`A : E →WOT[𝕜] F` along filter `l` iff `y (f a x)` tends to `y (A x)` along the same filter.
Basic non-topological properties of `E →L[𝕜] F` (such as the module structure) are copied over to
the type copy.
We also prove that the WOT is induced by the family of seminorms `‖y (A x)‖` for `x : E` and
`y : NormedSpace.Dual 𝕜 F`.
## Main declarations
* `ContinuousLinearMapWOT 𝕜 E F`: The type copy of `E →L[𝕜] F` endowed with the weak operator
topology.
* `ContinuousLinearMapWOT.tendsto_iff_forall_dual_apply_tendsto`: a function `f` tends to
`A : E →WOT[𝕜] F` along filter `l` iff `y ((f a) x)` tends to `y (A x)` along the same filter.
* `ContinuousLinearMap.toWOT`: the inclusion map from `E →L[𝕜] F` to the type copy
* `ContinuousLinearMap.continuous_toWOT`: the inclusion map is continuous, i.e. the WOT is coarser
than the norm topology.
* `ContinuousLinearMapWOT.withSeminorms`: the WOT is induced by the family of seminorms
`‖y (A x)‖` for `x : E` and `y : NormedSpace.Dual 𝕜 F`.
## Notation
* The type copy of `E →L[𝕜] F` endowed with the weak operator topology is denoted by
`E →WOT[𝕜] F`.
* We locally use the notation `F⋆` for `NormedSpace.Dual 𝕜 F`.
## Implementation notes
In the literature, the WOT is only defined on maps between Banach spaces. Here, we generalize this
a bit to `E →L[𝕜] F` where `F` is an normed space, and `E` actually only needs to be a vector
space with some topology for most results in this file.
-/
open scoped Topology
/-- The type copy of `E →L[𝕜] F` endowed with the weak operator topology, denoted as
`E →WOT[𝕜] F`. -/
@[irreducible]
def ContinuousLinearMapWOT (𝕜 : Type*) (E : Type*) (F : Type*) [Semiring 𝕜] [AddCommGroup E]
[TopologicalSpace E] [Module 𝕜 E] [AddCommGroup F] [TopologicalSpace F] [Module 𝕜 F] :=
E →L[𝕜] F
@[inherit_doc]
notation:25 E " →WOT[" 𝕜 "]" F => ContinuousLinearMapWOT 𝕜 E F
namespace ContinuousLinearMapWOT
variable {𝕜 : Type*} {E : Type*} {F : Type*} [RCLike 𝕜] [AddCommGroup E] [TopologicalSpace E]
[Module 𝕜 E] [NormedAddCommGroup F] [NormedSpace 𝕜 F]
local postfix:max "⋆" => NormedSpace.Dual 𝕜
/-!
### Basic properties common with `E →L[𝕜] F`
The section copies basic non-topological properties of `E →L[𝕜] F` over to `E →WOT[𝕜] F`, such as
the module structure, `FunLike`, etc.
-/
section Basic
unseal ContinuousLinearMapWOT in
instance instAddCommGroup : AddCommGroup (E →WOT[𝕜] F) :=
inferInstanceAs <| AddCommGroup (E →L[𝕜] F)
unseal ContinuousLinearMapWOT in
instance instModule : Module 𝕜 (E →WOT[𝕜] F) := inferInstanceAs <| Module 𝕜 (E →L[𝕜] F)
variable (𝕜) (E) (F)
unseal ContinuousLinearMapWOT in
/-- The linear equivalence that sends a continuous linear map to the type copy endowed with the
weak operator topology. -/
def _root_.ContinuousLinearMap.toWOT : (E →L[𝕜] F) ≃ₗ[𝕜] (E →WOT[𝕜] F) := LinearEquiv.refl 𝕜 _
variable {𝕜} {E} {F}
instance instFunLike : FunLike (E →WOT[𝕜] F) E F where
coe f := ((ContinuousLinearMap.toWOT 𝕜 E F).symm f : E → F)
coe_injective' := by intro; simp
instance instContinuousLinearMapClass : ContinuousLinearMapClass (E →WOT[𝕜] F) 𝕜 E F where
map_add f x y := by simp only [DFunLike.coe]; simp
map_smulₛₗ f r x := by simp only [DFunLike.coe]; simp
map_continuous f := ContinuousLinearMap.continuous ((ContinuousLinearMap.toWOT 𝕜 E F).symm f)
lemma _root_.ContinuousLinearMap.toWOT_apply {A : E →L[𝕜] F} {x : E} :
((ContinuousLinearMap.toWOT 𝕜 E F) A) x = A x := rfl
unseal ContinuousLinearMapWOT in
lemma ext {A B : E →WOT[𝕜] F} (h : ∀ x, A x = B x) : A = B := ContinuousLinearMap.ext h
unseal ContinuousLinearMapWOT in
lemma ext_iff {A B : E →WOT[𝕜] F} : A = B ↔ ∀ x, A x = B x := ContinuousLinearMap.ext_iff
-- This `ext` lemma is set at a lower priority than the default of 1000, so that the
-- version with an inner product (`ContinuousLinearMapWOT.ext_inner`) takes precedence
-- in the case of Hilbert spaces.
@[ext 900]
lemma ext_dual {A B : E →WOT[𝕜] F} (h : ∀ x (y : F⋆), y (A x) = y (B x)) : A = B := by
rw [ext_iff]
intro x
specialize h x
rwa [← NormedSpace.eq_iff_forall_dual_eq 𝕜] at h
@[simp] lemma zero_apply (x : E) : (0 : E →WOT[𝕜] F) x = 0 := by simp only [DFunLike.coe]; rfl
unseal ContinuousLinearMapWOT in
@[simp] lemma add_apply {f g : E →WOT[𝕜] F} (x : E) : (f + g) x = f x + g x := by
simp only [DFunLike.coe]; rfl
unseal ContinuousLinearMapWOT in
@[simp] lemma sub_apply {f g : E →WOT[𝕜] F} (x : E) : (f - g) x = f x - g x := by
simp only [DFunLike.coe]; rfl
unseal ContinuousLinearMapWOT in
@[simp] lemma neg_apply {f : E →WOT[𝕜] F} (x : E) : (-f) x = -(f x) := by
simp only [DFunLike.coe]; rfl
unseal ContinuousLinearMapWOT in
@[simp] lemma smul_apply {f : E →WOT[𝕜] F} (c : 𝕜) (x : E) : (c • f) x = c • (f x) := by
simp only [DFunLike.coe]; rfl
end Basic
/-!
### The topology of `E →WOT[𝕜] F`
The section endows `E →WOT[𝕜] F` with the weak operator topology and shows the basic properties
of this topology. In particular, we show that it is a topological vector space.
-/
section Topology
variable (𝕜) (E) (F) in
/-- The function that induces the topology on `E →WOT[𝕜] F`, namely the function that takes
an `A` and maps it to `fun ⟨x, y⟩ => y (A x)` in `E × F⋆ → 𝕜`, bundled as a linear map to make
it easier to prove that it is a TVS. -/
def inducingFn : (E →WOT[𝕜] F) →ₗ[𝕜] (E × F⋆ → 𝕜) where
toFun := fun A ⟨x, y⟩ => y (A x)
map_add' := fun x y => by ext; simp
map_smul' := fun x y => by ext; simp
/-- The weak operator topology is the coarsest topology such that `fun A => y (A x)` is
continuous for all `x, y`. -/
instance instTopologicalSpace : TopologicalSpace (E →WOT[𝕜] F) :=
.induced (inducingFn _ _ _) Pi.topologicalSpace
@[fun_prop]
lemma continuous_inducingFn : Continuous (inducingFn 𝕜 E F) :=
continuous_induced_dom
lemma continuous_dual_apply (x : E) (y : F⋆) : Continuous fun (A : E →WOT[𝕜] F) => y (A x) := by
refine (continuous_pi_iff.mp continuous_inducingFn) ⟨x, y⟩
@[fun_prop]
lemma continuous_of_dual_apply_continuous {α : Type*} [TopologicalSpace α] {g : α → E →WOT[𝕜] F}
(h : ∀ x (y : F⋆), Continuous fun a => y (g a x)) : Continuous g :=
continuous_induced_rng.2 (continuous_pi_iff.mpr fun p => h p.1 p.2)
lemma embedding_inducingFn : Embedding (inducingFn 𝕜 E F) := by
refine Function.Injective.embedding_induced fun A B hAB => ?_
rw [ContinuousLinearMapWOT.ext_dual_iff]
simpa [Function.funext_iff] using hAB
open Filter in
/-- The defining property of the weak operator topology: a function `f` tends to
`A : E →WOT[𝕜] F` along filter `l` iff `y (f a x)` tends to `y (A x)` along the same filter. -/
lemma tendsto_iff_forall_dual_apply_tendsto {α : Type*} {l : Filter α} {f : α → E →WOT[𝕜] F}
{A : E →WOT[𝕜] F} :
Tendsto f l (𝓝 A) ↔ ∀ x (y : F⋆), Tendsto (fun a => y (f a x)) l (𝓝 (y (A x))) := by
have hmain : (∀ x (y : F⋆), Tendsto (fun a => y (f a x)) l (𝓝 (y (A x))))
↔ ∀ (p : E × F⋆), Tendsto (fun a => p.2 (f a p.1)) l (𝓝 (p.2 (A p.1))) :=
⟨fun h p => h p.1 p.2, fun h x y => h ⟨x, y⟩⟩
rw [hmain, ← tendsto_pi_nhds, Embedding.tendsto_nhds_iff embedding_inducingFn]
rfl
lemma le_nhds_iff_forall_dual_apply_le_nhds {l : Filter (E →WOT[𝕜] F)} {A : E →WOT[𝕜] F} :
l ≤ 𝓝 A ↔ ∀ x (y : F⋆), l.map (fun T => y (T x)) ≤ 𝓝 (y (A x)) :=
tendsto_iff_forall_dual_apply_tendsto (f := id)
instance instT3Space : T3Space (E →WOT[𝕜] F) := embedding_inducingFn.t3Space
instance instContinuousAdd : ContinuousAdd (E →WOT[𝕜] F) := .induced (inducingFn 𝕜 E F)
instance instContinuousNeg : ContinuousNeg (E →WOT[𝕜] F) := .induced (inducingFn 𝕜 E F)
instance instContinuousSMul : ContinuousSMul 𝕜 (E →WOT[𝕜] F) := .induced (inducingFn 𝕜 E F)
instance instTopologicalAddGroup : TopologicalAddGroup (E →WOT[𝕜] F) where
instance instUniformSpace : UniformSpace (E →WOT[𝕜] F) := .comap (inducingFn 𝕜 E F) inferInstance
instance instUniformAddGroup : UniformAddGroup (E →WOT[𝕜] F) := .comap (inducingFn 𝕜 E F)
end Topology
/-! ### The WOT is induced by a family of seminorms -/
section Seminorms
/-- The family of seminorms that induce the weak operator topology, namely `‖y (A x)‖` for
all `x` and `y`. -/
def seminorm (x : E) (y : F⋆) : Seminorm 𝕜 (E →WOT[𝕜] F) where
toFun A := ‖y (A x)‖
map_zero' := by simp
add_le' A B := by simpa using norm_add_le _ _
neg' A := by simp
smul' r A := by simp
variable (𝕜) (E) (F) in
/-- The family of seminorms that induce the weak operator topology, namely `‖y (A x)‖` for
all `x` and `y`. -/
def seminormFamily : SeminormFamily 𝕜 (E →WOT[𝕜] F) (E × F⋆) :=
fun ⟨x, y⟩ => seminorm x y
lemma hasBasis_seminorms : (𝓝 (0 : E →WOT[𝕜] F)).HasBasis (seminormFamily 𝕜 E F).basisSets id := by
let p := seminormFamily 𝕜 E F
rw [nhds_induced, nhds_pi]
simp only [map_zero, Pi.zero_apply]
have h := Filter.hasBasis_pi (fun _ : (E × F⋆) ↦ Metric.nhds_basis_ball (x := 0)) |>.comap
(inducingFn 𝕜 E F)
refine h.to_hasBasis' ?_ ?_
· rintro ⟨s, U₂⟩ ⟨hs, hU₂⟩
lift s to Finset (E × F⋆) using hs
by_cases hU₃ : s.Nonempty
· refine ⟨(s.sup p).ball 0 <| s.inf' hU₃ U₂, p.basisSets_mem _ <| (Finset.lt_inf'_iff _).2 hU₂,
fun x hx y hy => ?_⟩
simp only [Set.mem_preimage, Set.mem_pi, mem_ball_zero_iff]
rw [id, Seminorm.mem_ball_zero] at hx
have hp : p y ≤ s.sup p := Finset.le_sup hy
refine lt_of_le_of_lt (hp x) (lt_of_lt_of_le hx ?_)
exact Finset.inf'_le _ hy
· rw [Finset.not_nonempty_iff_eq_empty.mp hU₃]
exact ⟨(p 0).ball 0 1, p.basisSets_singleton_mem 0 one_pos, by simp⟩
· suffices ∀ U ∈ p.basisSets, U ∈ 𝓝 (0 : E →WOT[𝕜] F) by simpa [nhds_induced, nhds_pi]
exact p.basisSets_mem_nhds fun ⟨x, y⟩ ↦ continuous_dual_apply x y |>.norm
lemma withSeminorms : WithSeminorms (seminormFamily 𝕜 E F) :=
SeminormFamily.withSeminorms_of_hasBasis _ hasBasis_seminorms
instance instLocallyConvexSpace [Module ℝ (E →WOT[𝕜] F)] [IsScalarTower ℝ 𝕜 (E →WOT[𝕜] F)] :
LocallyConvexSpace ℝ (E →WOT[𝕜] F) :=
withSeminorms.toLocallyConvexSpace
end Seminorms
end ContinuousLinearMapWOT
section NormedSpace
variable {𝕜 : Type*} {E : Type*} {F : Type*} [RCLike 𝕜] [NormedAddCommGroup E]
[NormedSpace 𝕜 E] [NormedAddCommGroup F] [NormedSpace 𝕜 F]
/-- The weak operator topology is coarser than the norm topology, i.e. the inclusion map is
continuous. -/
@[continuity, fun_prop]
lemma ContinuousLinearMap.continuous_toWOT :
Continuous (ContinuousLinearMap.toWOT 𝕜 E F) := by
refine ContinuousLinearMapWOT.continuous_of_dual_apply_continuous fun x y => ?_
simp_rw [ContinuousLinearMap.toWOT_apply]
change Continuous fun a => y <| (ContinuousLinearMap.id 𝕜 (E →L[𝕜] F)).flip x a
fun_prop
/-- The inclusion map from `E →[𝕜] F` to `E →WOT[𝕜] F`, bundled as a continuous linear map. -/
def ContinuousLinearMap.toWOTCLM : (E →L[𝕜] F) →L[𝕜] (E →WOT[𝕜] F) :=
⟨LinearEquiv.toLinearMap (ContinuousLinearMap.toWOT 𝕜 E F), ContinuousLinearMap.continuous_toWOT⟩
end NormedSpace
|
Analysis\Normed\Order\Basic.lean | /-
Copyright (c) 2020 Anatole Dedecker. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Anatole Dedecker, Yaël Dillies
-/
import Mathlib.Algebra.Order.Group.TypeTags
import Mathlib.Analysis.Normed.Field.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*}
/-- A `NormedOrderedAddGroup` is an additive group that is both a `NormedAddCommGroup` and an
`OrderedAddCommGroup`. This class is necessary to avoid diamonds caused by both classes
carrying their own group structure. -/
class NormedOrderedAddGroup (α : Type*) extends OrderedAddCommGroup α, Norm α, MetricSpace α where
/-- The distance function is induced by the norm. -/
dist_eq : ∀ x y, dist x y = ‖x - y‖ := by aesop
/-- A `NormedOrderedGroup` is a group that is both a `NormedCommGroup` and an
`OrderedCommGroup`. This class is necessary to avoid diamonds caused by both classes
carrying their own group structure. -/
@[to_additive]
class NormedOrderedGroup (α : Type*) extends OrderedCommGroup α, Norm α, MetricSpace α where
/-- The distance function is induced by the norm. -/
dist_eq : ∀ x y, dist x y = ‖x / y‖ := by aesop
/-- A `NormedLinearOrderedAddGroup` is an additive group that is both a `NormedAddCommGroup`
and a `LinearOrderedAddCommGroup`. This class is necessary to avoid diamonds caused by both
classes carrying their own group structure. -/
class NormedLinearOrderedAddGroup (α : Type*) extends LinearOrderedAddCommGroup α, Norm α,
MetricSpace α where
/-- The distance function is induced by the norm. -/
dist_eq : ∀ x y, dist x y = ‖x - y‖ := by aesop
/-- A `NormedLinearOrderedGroup` is a group that is both a `NormedCommGroup` and a
`LinearOrderedCommGroup`. This class is necessary to avoid diamonds caused by both classes
carrying their own group structure. -/
@[to_additive]
class NormedLinearOrderedGroup (α : Type*) extends LinearOrderedCommGroup α, Norm α,
MetricSpace α where
/-- The distance function is induced by the norm. -/
dist_eq : ∀ x y, dist x y = ‖x / y‖ := by aesop
/-- A `NormedLinearOrderedField` is a field that is both a `NormedField` and a
`LinearOrderedField`. This class is necessary to avoid diamonds. -/
class NormedLinearOrderedField (α : Type*) extends LinearOrderedField α, Norm α,
MetricSpace α where
/-- The distance function is induced by the norm. -/
dist_eq : ∀ x y, dist x y = ‖x - y‖ := by aesop
/-- The norm is multiplicative. -/
norm_mul' : ∀ x y : α, ‖x * y‖ = ‖x‖ * ‖y‖
@[to_additive]
instance (priority := 100) NormedOrderedGroup.toNormedCommGroup [NormedOrderedGroup α] :
NormedCommGroup α :=
⟨NormedOrderedGroup.dist_eq⟩
@[to_additive]
instance (priority := 100) NormedLinearOrderedGroup.toNormedOrderedGroup
[NormedLinearOrderedGroup α] : NormedOrderedGroup α :=
⟨NormedLinearOrderedGroup.dist_eq⟩
instance (priority := 100) NormedLinearOrderedField.toNormedField (α : Type*)
[NormedLinearOrderedField α] : NormedField α where
dist_eq := NormedLinearOrderedField.dist_eq
norm_mul' := NormedLinearOrderedField.norm_mul'
instance Rat.normedLinearOrderedField : NormedLinearOrderedField ℚ :=
⟨dist_eq_norm, norm_mul⟩
noncomputable instance Real.normedLinearOrderedField : NormedLinearOrderedField ℝ :=
⟨dist_eq_norm, norm_mul⟩
@[to_additive]
instance OrderDual.normedOrderedGroup [NormedOrderedGroup α] : NormedOrderedGroup αᵒᵈ :=
{ @NormedOrderedGroup.toNormedCommGroup α _, OrderDual.orderedCommGroup with }
@[to_additive]
instance OrderDual.normedLinearOrderedGroup [NormedLinearOrderedGroup α] :
NormedLinearOrderedGroup αᵒᵈ :=
{ OrderDual.normedOrderedGroup, OrderDual.instLinearOrder _ with }
instance Additive.normedOrderedAddGroup [NormedOrderedGroup α] :
NormedOrderedAddGroup (Additive α) :=
{ Additive.normedAddCommGroup, Additive.orderedAddCommGroup with }
instance Multiplicative.normedOrderedGroup [NormedOrderedAddGroup α] :
NormedOrderedGroup (Multiplicative α) :=
{ Multiplicative.normedCommGroup, Multiplicative.orderedCommGroup with }
instance Additive.normedLinearOrderedAddGroup [NormedLinearOrderedGroup α] :
NormedLinearOrderedAddGroup (Additive α) :=
{ Additive.normedAddCommGroup, Additive.linearOrderedAddCommGroup with }
instance Multiplicative.normedlinearOrderedGroup [NormedLinearOrderedAddGroup α] :
NormedLinearOrderedGroup (Multiplicative α) :=
{ Multiplicative.normedCommGroup, Multiplicative.linearOrderedCommGroup with }
|
Analysis\Normed\Order\Lattice.lean | /-
Copyright (c) 2021 Christopher Hoskin. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Christopher Hoskin
-/
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.
-/
-- Porting note: this now exists as a global notation
-- local notation "|" a "|" => abs a
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]⟩
end SolidNorm
/--
Let `α` be a normed commutative group equipped with a partial order covariant with addition, with
respect which `α` forms a lattice. Suppose that `α` is *solid*, that is to say, for `a` and `b` in
`α`, with absolute values `|a|` and `|b|` respectively, `|a| ≤ |b|` implies `‖a‖ ≤ ‖b‖`. Then `α` is
said to be a normed lattice ordered group.
-/
class NormedLatticeAddCommGroup (α : Type*) extends
NormedAddCommGroup α, Lattice α, HasSolidNorm α where
add_le_add_left : ∀ a b : α, a ≤ b → ∀ c : α, c + a ≤ c + b
instance Real.normedLatticeAddCommGroup : NormedLatticeAddCommGroup ℝ where
add_le_add_left _ _ h _ := add_le_add le_rfl h
-- see Note [lower instance priority]
/-- A normed lattice ordered group is an ordered additive commutative group
-/
instance (priority := 100) NormedLatticeAddCommGroup.toOrderedAddCommGroup {α : Type*}
[h : NormedLatticeAddCommGroup α] : OrderedAddCommGroup α :=
{ h with }
variable {α : Type*} [NormedLatticeAddCommGroup α]
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.instNormedLatticeAddCommGroup :
NormedLatticeAddCommGroup αᵒᵈ :=
{ OrderDual.orderedAddCommGroup, OrderDual.normedAddCommGroup, OrderDual.instLattice α with
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
apply add_le_add
· 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
apply add_le_add
· 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) NormedLatticeAddCommGroup.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) NormedLatticeAddCommGroup.continuousSup {α : Type*}
[NormedLatticeAddCommGroup α] : 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) NormedLatticeAddCommGroup.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
lemma continuous_posPart : Continuous (posPart : α → α) := lipschitzWith_posPart.continuous
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} [OrderedAddCommGroup 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) NormedLatticeAddCommGroup.orderClosedTopology {E}
[NormedLatticeAddCommGroup E] : OrderClosedTopology E :=
⟨isClosed_le_of_isClosed_nonneg isClosed_nonneg⟩
|
Analysis\Normed\Order\UpperLower.lean | /-
Copyright (c) 2022 Yaël Dillies. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yaël Dillies
-/
import Mathlib.Algebra.Order.Field.Pi
import Mathlib.Algebra.Order.UpperLower
import Mathlib.Analysis.Normed.Group.Pointwise
import Mathlib.Analysis.Normed.Order.Basic
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 [NormedOrderedGroup α] {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 t : 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', sup_eq_max, inf_eq_min, 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))]
exact Real.toNNReal_mono (sub_le_sub_right (hy _) _)
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' ?_, ?_⟩
· rw [dist_self_add_left]
refine (add_le_add_left (pi_norm_const_le <| 3 / 4 * δ) _).trans_eq ?_
simp only [norm_mul, norm_div, Real.norm_eq_abs]
simp only [gt_iff_lt, zero_lt_three, abs_of_pos, zero_lt_four, abs_of_pos hδ]
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' ?_, ?_⟩
· rw [dist_self_sub_left]
refine (add_le_add_left (pi_norm_const_le <| 3 / 4 * δ) _).trans_eq ?_
simp only [norm_mul, norm_div, Real.norm_eq_abs, gt_iff_lt, zero_lt_three, abs_of_pos,
zero_lt_four, abs_of_pos hδ]
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 t : Set (ι → ℝ)} {a₁ a₂ b₁ b₂ x y : ι → ℝ} {δ : ℝ}
/-!
#### 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
|
Analysis\Normed\Ring\Seminorm.lean | /-
Copyright (c) 2022 María Inés de Frutos-Fernández. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: María Inés de Frutos-Fernández, Yaël Dillies
-/
import Mathlib.Analysis.Normed.Field.Basic
import Mathlib.Analysis.SpecialFunctions.Pow.Real
/-!
# Seminorms and norms on rings
This file defines seminorms and norms on rings. These definitions are useful when one needs to
consider multiple (semi)norms on a given ring.
## Main declarations
For a ring `R`:
* `RingSeminorm`: A seminorm on a ring `R` is a function `f : R → ℝ` that preserves zero, takes
nonnegative values, is subadditive and submultiplicative and such that `f (-x) = f x` for all
`x ∈ R`.
* `RingNorm`: A seminorm `f` is a norm if `f x = 0` if and only if `x = 0`.
* `MulRingSeminorm`: A multiplicative seminorm on a ring `R` is a ring seminorm that preserves
multiplication.
* `MulRingNorm`: A multiplicative norm on a ring `R` is a ring norm that preserves multiplication.
## Notes
The corresponding hom classes are defined in `Mathlib.Analysis.Order.Hom.Basic` to be used by
absolute values.
## References
* [S. Bosch, U. Güntzer, R. Remmert, *Non-Archimedean Analysis*][bosch-guntzer-remmert]
## Tags
ring_seminorm, ring_norm
-/
open NNReal
variable {F R S : Type*} (x y : R) (r : ℝ)
/-- A seminorm on a ring `R` is a function `f : R → ℝ` that preserves zero, takes nonnegative
values, is subadditive and submultiplicative and such that `f (-x) = f x` for all `x ∈ R`. -/
structure RingSeminorm (R : Type*) [NonUnitalNonAssocRing R] extends AddGroupSeminorm R where
/-- The property of a `RingSeminorm` that for all `x` and `y` in the ring, the norm of `x * y` is
less than the norm of `x` times the norm of `y`. -/
mul_le' : ∀ x y : R, toFun (x * y) ≤ toFun x * toFun y
/-- A function `f : R → ℝ` is a norm on a (nonunital) ring if it is a seminorm and `f x = 0`
implies `x = 0`. -/
structure RingNorm (R : Type*) [NonUnitalNonAssocRing R] extends RingSeminorm R, AddGroupNorm R
/-- A multiplicative seminorm on a ring `R` is a function `f : R → ℝ` that preserves zero and
multiplication, takes nonnegative values, is subadditive and such that `f (-x) = f x` for all `x`.
-/
structure MulRingSeminorm (R : Type*) [NonAssocRing R] extends AddGroupSeminorm R,
MonoidWithZeroHom R ℝ
/-- A multiplicative norm on a ring `R` is a multiplicative ring seminorm such that `f x = 0`
implies `x = 0`. -/
structure MulRingNorm (R : Type*) [NonAssocRing R] extends MulRingSeminorm R, AddGroupNorm R
attribute [nolint docBlame]
RingSeminorm.toAddGroupSeminorm RingNorm.toAddGroupNorm RingNorm.toRingSeminorm
MulRingSeminorm.toAddGroupSeminorm MulRingSeminorm.toMonoidWithZeroHom
MulRingNorm.toAddGroupNorm MulRingNorm.toMulRingSeminorm
namespace RingSeminorm
section NonUnitalRing
variable [NonUnitalRing R]
instance funLike : FunLike (RingSeminorm R) R ℝ where
coe f := f.toFun
coe_injective' f g h := by
cases f
cases g
congr
ext x
exact congr_fun h x
instance ringSeminormClass : RingSeminormClass (RingSeminorm R) R ℝ where
map_zero f := f.map_zero'
map_add_le_add f := f.add_le'
map_mul_le_mul f := f.mul_le'
map_neg_eq_map f := f.neg'
@[simp]
theorem toFun_eq_coe (p : RingSeminorm R) : (p.toAddGroupSeminorm : R → ℝ) = p :=
rfl
@[ext]
theorem ext {p q : RingSeminorm R} : (∀ x, p x = q x) → p = q :=
DFunLike.ext p q
instance : Zero (RingSeminorm R) :=
⟨{ AddGroupSeminorm.instZeroAddGroupSeminorm.zero with mul_le' :=
fun _ _ => (zero_mul _).ge }⟩
theorem eq_zero_iff {p : RingSeminorm R} : p = 0 ↔ ∀ x, p x = 0 :=
DFunLike.ext_iff
theorem ne_zero_iff {p : RingSeminorm R} : p ≠ 0 ↔ ∃ x, p x ≠ 0 := by simp [eq_zero_iff]
instance : Inhabited (RingSeminorm R) :=
⟨0⟩
/-- The trivial seminorm on a ring `R` is the `RingSeminorm` taking value `0` at `0` and `1` at
every other element. -/
instance [DecidableEq R] : One (RingSeminorm R) :=
⟨{ (1 : AddGroupSeminorm R) with
mul_le' := fun x y => by
by_cases h : x * y = 0
· refine (if_pos h).trans_le (mul_nonneg ?_ ?_) <;>
· change _ ≤ ite _ _ _
split_ifs
exacts [le_rfl, zero_le_one]
· change ite _ _ _ ≤ ite _ _ _ * ite _ _ _
simp only [if_false, h, left_ne_zero_of_mul h, right_ne_zero_of_mul h, mul_one,
le_refl] }⟩
@[simp]
theorem apply_one [DecidableEq R] (x : R) : (1 : RingSeminorm R) x = if x = 0 then 0 else 1 :=
rfl
end NonUnitalRing
section Ring
variable [Ring R] (p : RingSeminorm R)
theorem seminorm_one_eq_one_iff_ne_zero (hp : p 1 ≤ 1) : p 1 = 1 ↔ p ≠ 0 := by
refine
⟨fun h =>
ne_zero_iff.mpr
⟨1, by
rw [h]
exact one_ne_zero⟩,
fun h => ?_⟩
obtain hp0 | hp0 := (apply_nonneg p (1 : R)).eq_or_gt
· exfalso
refine h (ext fun x => (apply_nonneg _ _).antisymm' ?_)
simpa only [hp0, mul_one, mul_zero] using map_mul_le_mul p x 1
· refine hp.antisymm ((le_mul_iff_one_le_left hp0).1 ?_)
simpa only [one_mul] using map_mul_le_mul p (1 : R) _
end Ring
end RingSeminorm
/-- The norm of a `NonUnitalSeminormedRing` as a `RingSeminorm`. -/
def normRingSeminorm (R : Type*) [NonUnitalSeminormedRing R] : RingSeminorm R :=
{ normAddGroupSeminorm R with
toFun := norm
mul_le' := norm_mul_le }
namespace RingNorm
variable [NonUnitalRing R]
instance funLike : FunLike (RingNorm R) R ℝ where
coe f := f.toFun
coe_injective' f g h := by
cases f
cases g
congr
ext x
exact congr_fun h x
instance ringNormClass : RingNormClass (RingNorm R) R ℝ where
map_zero f := f.map_zero'
map_add_le_add f := f.add_le'
map_mul_le_mul f := f.mul_le'
map_neg_eq_map f := f.neg'
eq_zero_of_map_eq_zero f := f.eq_zero_of_map_eq_zero' _
-- Porting note: This is no longer `@[simp]` in Lean 4
theorem toFun_eq_coe (p : RingNorm R) : p.toFun = p := rfl
@[ext]
theorem ext {p q : RingNorm R} : (∀ x, p x = q x) → p = q :=
DFunLike.ext p q
variable (R)
/-- The trivial norm on a ring `R` is the `RingNorm` taking value `0` at `0` and `1` at every
other element. -/
instance [DecidableEq R] : One (RingNorm R) :=
⟨{ (1 : RingSeminorm R), (1 : AddGroupNorm R) with }⟩
@[simp]
theorem apply_one [DecidableEq R] (x : R) : (1 : RingNorm R) x = if x = 0 then 0 else 1 :=
rfl
instance [DecidableEq R] : Inhabited (RingNorm R) :=
⟨1⟩
end RingNorm
namespace MulRingSeminorm
variable [NonAssocRing R]
instance funLike : FunLike (MulRingSeminorm R) R ℝ where
coe f := f.toFun
coe_injective' f g h := by
cases f
cases g
congr
ext x
exact congr_fun h x
instance mulRingSeminormClass : MulRingSeminormClass (MulRingSeminorm R) R ℝ where
map_zero f := f.map_zero'
map_one f := f.map_one'
map_add_le_add f := f.add_le'
map_mul f := f.map_mul'
map_neg_eq_map f := f.neg'
@[simp]
theorem toFun_eq_coe (p : MulRingSeminorm R) : (p.toAddGroupSeminorm : R → ℝ) = p :=
rfl
@[ext]
theorem ext {p q : MulRingSeminorm R} : (∀ x, p x = q x) → p = q :=
DFunLike.ext p q
variable [DecidableEq R] [NoZeroDivisors R] [Nontrivial R]
/-- The trivial seminorm on a ring `R` is the `MulRingSeminorm` taking value `0` at `0` and `1` at
every other element. -/
instance : One (MulRingSeminorm R) :=
⟨{ (1 : AddGroupSeminorm R) with
map_one' := if_neg one_ne_zero
map_mul' := fun x y => by
obtain rfl | hx := eq_or_ne x 0
· simp
obtain rfl | hy := eq_or_ne y 0
· simp
· simp [hx, hy] }⟩
@[simp]
theorem apply_one (x : R) : (1 : MulRingSeminorm R) x = if x = 0 then 0 else 1 :=
rfl
instance : Inhabited (MulRingSeminorm R) :=
⟨1⟩
end MulRingSeminorm
namespace MulRingNorm
variable [NonAssocRing R]
instance funLike : FunLike (MulRingNorm R) R ℝ where
coe f := f.toFun
coe_injective' f g h := by
cases f
cases g
congr
ext x
exact congr_fun h x
instance mulRingNormClass : MulRingNormClass (MulRingNorm R) R ℝ where
map_zero f := f.map_zero'
map_one f := f.map_one'
map_add_le_add f := f.add_le'
map_mul f := f.map_mul'
map_neg_eq_map f := f.neg'
eq_zero_of_map_eq_zero f := f.eq_zero_of_map_eq_zero' _
-- Porting note: This no longer in `@[simp]`-normal form in Lean 4
theorem toFun_eq_coe (p : MulRingNorm R) : p.toFun = p := rfl
@[ext]
theorem ext {p q : MulRingNorm R} : (∀ x, p x = q x) → p = q :=
DFunLike.ext p q
variable (R)
variable [DecidableEq R] [NoZeroDivisors R] [Nontrivial R]
/-- The trivial norm on a ring `R` is the `MulRingNorm` taking value `0` at `0` and `1` at every
other element. -/
instance : One (MulRingNorm R) :=
⟨{ (1 : MulRingSeminorm R), (1 : AddGroupNorm R) with }⟩
@[simp]
theorem apply_one (x : R) : (1 : MulRingNorm R) x = if x = 0 then 0 else 1 :=
rfl
instance : Inhabited (MulRingNorm R) :=
⟨1⟩
variable {R : Type*} [Ring R]
/-- Two multiplicative ring norms `f, g` on `R` are equivalent if there exists a positive constant
`c` such that for all `x ∈ R`, `(f x)^c = g x`. -/
def equiv (f : MulRingNorm R) (g : MulRingNorm R) :=
∃ c : ℝ, 0 < c ∧ (fun x => (f x) ^ c) = g
/-- Equivalence of multiplicative ring norms is reflexive. -/
lemma equiv_refl (f : MulRingNorm R) : equiv f f := by
exact ⟨1, Real.zero_lt_one, by simp only [Real.rpow_one]⟩
/-- Equivalence of multiplicative ring norms is symmetric. -/
lemma equiv_symm {f g : MulRingNorm R} (hfg : equiv f g) : equiv g f := by
rcases hfg with ⟨c, hcpos, h⟩
use 1/c
constructor
· simp only [one_div, inv_pos, hcpos]
ext x
simpa [← congr_fun h x] using Real.rpow_rpow_inv (apply_nonneg f x) (ne_of_lt hcpos).symm
/-- Equivalence of multiplicative ring norms is transitive. -/
lemma equiv_trans {f g k : MulRingNorm R} (hfg : equiv f g) (hgk : equiv g k) :
equiv f k := by
rcases hfg with ⟨c, hcPos, hfg⟩
rcases hgk with ⟨d, hdPos, hgk⟩
refine ⟨c*d, (mul_pos_iff_of_pos_left hcPos).mpr hdPos, ?_⟩
ext x
rw [Real.rpow_mul (apply_nonneg f x), congr_fun hfg x, congr_fun hgk x]
end MulRingNorm
/-- A nonzero ring seminorm on a field `K` is a ring norm. -/
def RingSeminorm.toRingNorm {K : Type*} [Field K] (f : RingSeminorm K) (hnt : f ≠ 0) :
RingNorm K :=
{ f with
eq_zero_of_map_eq_zero' := fun x hx => by
obtain ⟨c, hc⟩ := RingSeminorm.ne_zero_iff.mp hnt
by_contra hn0
have hc0 : f c = 0 := by
rw [← mul_one c, ← mul_inv_cancel hn0, ← mul_assoc, mul_comm c, mul_assoc]
exact
le_antisymm
(le_trans (map_mul_le_mul f _ _)
(by rw [← RingSeminorm.toFun_eq_coe, ← AddGroupSeminorm.toFun_eq_coe, hx,
zero_mul]))
(apply_nonneg f _)
exact hc hc0 }
/-- The norm of a `NonUnitalNormedRing` as a `RingNorm`. -/
@[simps!]
def normRingNorm (R : Type*) [NonUnitalNormedRing R] : RingNorm R :=
{ normAddGroupNorm R, normRingSeminorm R with }
/-- A multiplicative ring norm satisfies `f n ≤ n` for every `n : ℕ`. -/
lemma MulRingNorm_nat_le_nat {R : Type*} [Ring R] (n : ℕ) (f : MulRingNorm R) : f n ≤ n := by
induction n with
| zero => simp only [Nat.cast_zero, map_zero, le_refl]
| succ n hn =>
simp only [Nat.cast_succ]
calc
f (n + 1) ≤ f (n) + f 1 := f.add_le' ↑n 1
_ = f (n) + 1 := by rw [map_one]
_ ≤ n + 1 := add_le_add_right hn 1
open Int
/-- A multiplicative norm composed with the absolute value on integers equals the norm itself. -/
lemma MulRingNorm.apply_natAbs_eq {R : Type*} [Ring R] (x : ℤ) (f : MulRingNorm R) : f (natAbs x) =
f x := by
obtain ⟨n, rfl | rfl⟩ := eq_nat_or_neg x <;>
simp only [natAbs_neg, natAbs_ofNat, cast_neg, cast_natCast, map_neg_eq_map]
|
Analysis\Normed\Ring\SeminormFromBounded.lean | /-
Copyright (c) 2024 María Inés de Frutos-Fernández. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: María Inés de Frutos-Fernández
-/
import Mathlib.Analysis.Normed.Ring.Seminorm
import Mathlib.Analysis.SpecialFunctions.Pow.Complex
/-!
# seminormFromBounded
In this file, we prove [BGR, Proposition 1.2.1/2][bosch-guntzer-remmert] : given a nonzero
additive group seminorm on a commutative ring `R` such that for some `c : ℝ` and every `x y : R`,
the inequality `f (x * y) ≤ c * f x * f y)` is satisfied, we create a ring seminorm on `R`.
In the file comments, we will use the expression `f is multiplicatively bounded` to indicate that
this condition holds.
## Main Definitions
* `seminormFromBounded'` : the real-valued function sending `x ∈ R` to the supremum of
`f(x*y)/f(y)`, where `y` runs over the elements of `R`.
* `seminormFromBounded` : the function `seminormFromBounded'` as a `RingSeminorm` on `R`.
* `normFromBounded` :`seminormFromBounded' f` as a `RingNorm` on `R`, provided that `f` is
nonnegative, multiplicatively bounded and subadditive, that it preserves `0` and negation, and
that `f` has trivial kernel.
## Main Results
* `seminormFromBounded_isNonarchimedean` : if `f : R → ℝ` is a nonnegative, multiplicatively
bounded, nonarchimedean function, then `seminormFromBounded' f` is nonarchimedean.
* `seminormFromBounded_of_mul_is_mul` : if `f : R → ℝ` is a nonnegative, multiplicatively bounded
function and `x : R` is multiplicative for `f`, then `x` is multiplicative for
`seminormFromBounded' f`.
## References
* [S. Bosch, U. Güntzer, R. Remmert, *Non-Archimedean Analysis*][bosch-guntzer-remmert]
## Tags
seminormFromBounded, RingSeminorm, Nonarchimedean
-/
noncomputable section
open scoped Topology NNReal
variable {R : Type _} [CommRing R] (f : R → ℝ) {c : ℝ}
section seminormFromBounded
/-- The real-valued function sending `x ∈ R` to the supremum of `f(x*y)/f(y)`, where `y` runs over
the elements of `R`.-/
def seminormFromBounded' : R → ℝ := fun x ↦ iSup fun y : R ↦ f (x * y) / f y
variable {f}
/-- If `f : R → ℝ` is a nonzero, nonnegative, multiplicatively bounded function, then `f 1 ≠ 0`. -/
theorem map_one_ne_zero (f_ne_zero : f ≠ 0) (f_nonneg : 0 ≤ f)
(f_mul : ∀ x y : R, f (x * y) ≤ c * f x * f y) : f 1 ≠ 0 := by
intro h1
specialize f_mul 1
simp_rw [h1, one_mul, mul_zero, zero_mul] at f_mul
obtain ⟨z, hz⟩ := Function.ne_iff.mp f_ne_zero
exact hz <| (f_mul z).antisymm (f_nonneg z)
/-- If `f : R → ℝ` is a nonnegative multiplicatively bounded function and `x : R` is a unit with
`f x ≠ 0`, then for every `n : ℕ`, we have `f (x ^ n) ≠ 0`. -/
theorem map_pow_ne_zero (f_nonneg : 0 ≤ f) {x : R} (hx : IsUnit x) (hfx : f x ≠ 0) (n : ℕ)
(f_mul : ∀ x y : R, f (x * y) ≤ c * f x * f y) : f (x ^ n) ≠ 0 := by
have h1 : f 1 ≠ 0 := map_one_ne_zero (Function.ne_iff.mpr ⟨x, hfx⟩) f_nonneg f_mul
intro hxn
have : f 1 ≤ 0 := by simpa [← mul_pow, hxn] using f_mul (x ^ n) (hx.unit⁻¹ ^ n)
exact h1 <| this.antisymm (f_nonneg 1)
/-- If `f : R → ℝ` is a nonnegative, multiplicatively bounded function, then given `x y : R` with
`f x = 0`, we have `f (x * y) = 0`. -/
theorem map_mul_zero_of_map_zero (f_nonneg : 0 ≤ f)
(f_mul : ∀ x y : R, f (x * y) ≤ c * f x * f y) {x : R} (hx : f x = 0)
(y : R) : f (x * y) = 0 := by
replace f_mul : f (x * y) ≤ 0 := by simpa [hx] using f_mul x y
exact le_antisymm f_mul (f_nonneg _)
/-- `seminormFromBounded' f` preserves `0`. -/
theorem seminormFromBounded_zero (f_zero : f 0 = 0) : seminormFromBounded' f (0 : R) = 0 := by
simp_rw [seminormFromBounded', zero_mul, f_zero, zero_div, ciSup_const]
theorem seminormFromBounded_aux (f_nonneg : 0 ≤ f)
(f_mul : ∀ x y : R, f (x * y) ≤ c * f x * f y) (x : R) : 0 ≤ c * f x := by
rcases (f_nonneg x).eq_or_gt with hx | hx
· simp [hx]
· change 0 < f x at hx
have hc : 0 ≤ c := by
specialize f_mul x 1
rw [mul_one, show c * f x * f 1 = c * f 1 * f x by ring, le_mul_iff_one_le_left hx] at f_mul
replace f_nonneg : 0 ≤ f 1 := f_nonneg 1
rcases f_nonneg.eq_or_gt with h1 | h1
· linarith [show (1 : ℝ) ≤ 0 by simpa [h1] using f_mul]
· rw [← div_le_iff h1] at f_mul
linarith [one_div_pos.mpr h1]
positivity
/-- If `f : R → ℝ` is a nonnegative, multiplicatively bounded function, then for every `x : R`,
the image of `y ↦ f (x * y) / f y` is bounded above. -/
theorem seminormFromBounded_bddAbove_range (f_nonneg : 0 ≤ f)
(f_mul : ∀ x y : R, f (x * y) ≤ c * f x * f y) (x : R) :
BddAbove (Set.range fun y ↦ f (x * y) / f y) := by
use c * f x
rintro r ⟨y, rfl⟩
rcases (f_nonneg y).eq_or_gt with hy0 | hy0
· simpa [hy0] using seminormFromBounded_aux f_nonneg f_mul x
· simpa [div_le_iff hy0] using f_mul x y
/-- If `f : R → ℝ` is a nonnegative, multiplicatively bounded function, then for every `x : R`,
`seminormFromBounded' f x` is bounded above by some multiple of `f x`. -/
theorem seminormFromBounded_le (f_nonneg : 0 ≤ f)
(f_mul : ∀ x y : R, f (x * y) ≤ c * f x * f y) (x : R) :
seminormFromBounded' f x ≤ c * f x := by
refine ciSup_le (fun y ↦ ?_)
rcases (f_nonneg y).eq_or_gt with hy | hy
· simpa [hy] using seminormFromBounded_aux f_nonneg f_mul x
· rw [div_le_iff hy]
apply f_mul
/-- If `f : R → ℝ` is a nonnegative, multiplicatively bounded function, then for every `x : R`,
`f x ≤ f 1 * seminormFromBounded' f x`. -/
theorem seminormFromBounded_ge (f_nonneg : 0 ≤ f)
(f_mul : ∀ x y : R, f (x * y) ≤ c * f x * f y) (x : R) :
f x ≤ f 1 * seminormFromBounded' f x := by
by_cases h1 : f 1 = 0
· specialize f_mul x 1
rw [mul_one, h1, mul_zero] at f_mul
have hx0 : f x = 0 := f_mul.antisymm (f_nonneg _)
rw [hx0, h1, zero_mul]
· rw [mul_comm, ← div_le_iff (lt_of_le_of_ne' (f_nonneg _) h1)]
conv_lhs => rw [← mul_one x]
exact le_ciSup (seminormFromBounded_bddAbove_range f_nonneg f_mul x) (1 : R)
/-- If `f : R → ℝ` is a nonnegative, multiplicatively bounded function, then
`seminormFromBounded' f` is nonnegative. -/
theorem seminormFromBounded_nonneg (f_nonneg : 0 ≤ f)
(f_mul : ∀ x y : R, f (x * y) ≤ c * f x * f y) :
0 ≤ seminormFromBounded' f := fun x ↦
le_csSup_of_le (seminormFromBounded_bddAbove_range f_nonneg f_mul x) ⟨1, rfl⟩
(div_nonneg (f_nonneg _) (f_nonneg _))
/-- If `f : R → ℝ` is a nonnegative, multiplicatively bounded function, then
`seminormFromBounded' f x = 0` if and only if `f x = 0`. -/
theorem seminormFromBounded_eq_zero_iff (f_nonneg : 0 ≤ f)
(f_mul : ∀ x y : R, f (x * y) ≤ c * f x * f y) (x : R) :
seminormFromBounded' f x = 0 ↔ f x = 0 := by
refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩
· have hf := seminormFromBounded_ge f_nonneg f_mul x
rw [h, mul_zero] at hf
exact hf.antisymm (f_nonneg _)
· have hf : seminormFromBounded' f x ≤ c * f x :=
seminormFromBounded_le f_nonneg f_mul x
rw [h, mul_zero] at hf
exact hf.antisymm (seminormFromBounded_nonneg f_nonneg f_mul x)
/-- If `f` is invariant under negation of `x`, then so is `seminormFromBounded'`.-/
theorem seminormFromBounded_neg (f_neg : ∀ x : R, f (-x) = f x) (x : R) :
seminormFromBounded' f (-x) = seminormFromBounded' f x := by
suffices ⨆ y, f (-x * y) / f y = ⨆ y, f (x * y) / f y by simpa only [seminormFromBounded']
congr
ext y
rw [neg_mul, f_neg]
/-- If `f : R → ℝ` is a nonnegative, multiplicatively bounded function, then
`seminormFromBounded' f` is submultiplicative. -/
theorem seminormFromBounded_mul (f_nonneg : 0 ≤ f)
(f_mul : ∀ x y : R, f (x * y) ≤ c * f x * f y) (x y : R) :
seminormFromBounded' f (x * y) ≤ seminormFromBounded' f x * seminormFromBounded' f y := by
apply ciSup_le
by_cases hy : seminormFromBounded' f y = 0
· rw [seminormFromBounded_eq_zero_iff f_nonneg f_mul] at hy
intro z
rw [mul_comm x y, mul_assoc, map_mul_zero_of_map_zero f_nonneg f_mul hy (x * z), zero_div]
exact mul_nonneg (seminormFromBounded_nonneg f_nonneg f_mul x)
(seminormFromBounded_nonneg f_nonneg f_mul y)
· intro z
rw [← div_le_iff (lt_of_le_of_ne' (seminormFromBounded_nonneg f_nonneg f_mul _) hy)]
apply le_ciSup_of_le (seminormFromBounded_bddAbove_range f_nonneg f_mul x) z
rw [div_le_iff (lt_of_le_of_ne' (seminormFromBounded_nonneg f_nonneg f_mul _) hy),
div_mul_eq_mul_div]
by_cases hz : f z = 0
· have hxyz : f (z * (x * y)) = 0 := map_mul_zero_of_map_zero f_nonneg f_mul hz _
simp_rw [mul_comm, hxyz, zero_div]
exact div_nonneg (mul_nonneg (seminormFromBounded_nonneg f_nonneg f_mul y) (f_nonneg _))
(f_nonneg _)
· rw [div_le_div_right (lt_of_le_of_ne' (f_nonneg _) hz), mul_comm (f (x * z))]
by_cases hxz : f (x * z) = 0
· rw [mul_comm x y, mul_assoc, mul_comm y, map_mul_zero_of_map_zero f_nonneg f_mul hxz y]
exact mul_nonneg (seminormFromBounded_nonneg f_nonneg f_mul y) (f_nonneg _)
· rw [← div_le_iff (lt_of_le_of_ne' (f_nonneg _) hxz)]
apply le_ciSup_of_le (seminormFromBounded_bddAbove_range f_nonneg f_mul y) (x * z)
rw [div_le_div_right (lt_of_le_of_ne' (f_nonneg _) hxz), mul_comm x y, mul_assoc]
/-- If `f : R → ℝ` is a nonzero, nonnegative, multiplicatively bounded function, then
`seminormFromBounded' f 1 = 1`. -/
theorem seminormFromBounded_one (f_ne_zero : f ≠ 0) (f_nonneg : 0 ≤ f)
(f_mul : ∀ x y : R, f (x * y) ≤ c * f x * f y) :
seminormFromBounded' f 1 = 1 := by
simp_rw [seminormFromBounded', one_mul]
apply le_antisymm
· refine ciSup_le (fun x ↦ ?_)
by_cases hx : f x = 0
· rw [hx, div_zero]; exact zero_le_one
· rw [div_self hx]
· rw [← div_self (map_one_ne_zero f_ne_zero f_nonneg f_mul)]
have h_bdd : BddAbove (Set.range fun y ↦ f y / f y) := by
use (1 : ℝ)
rintro r ⟨y, rfl⟩
by_cases hy : f y = 0
· simp only [hy, div_zero, zero_le_one]
· simp only [div_self hy, le_refl]
exact le_ciSup h_bdd (1 : R)
/-- If `f : R → ℝ` is a nonnegative, multiplicatively bounded function, then
`seminormFromBounded' f 1 ≤ 1`. -/
theorem seminormFromBounded_one_le (f_nonneg : 0 ≤ f)
(f_mul : ∀ x y : R, f (x * y) ≤ c * f x * f y) :
seminormFromBounded' f 1 ≤ 1 := by
by_cases f_ne_zero : f ≠ 0
· exact le_of_eq (seminormFromBounded_one f_ne_zero f_nonneg f_mul)
· simp_rw [seminormFromBounded', one_mul]
refine ciSup_le (fun _ ↦ ?_)
push_neg at f_ne_zero
simp only [f_ne_zero, Pi.zero_apply, div_zero, zero_le_one]
/-- If `f : R → ℝ` is a nonnegative, multiplicatively bounded, subadditive function, then
`seminormFromBounded' f` is subadditive. -/
theorem seminormFromBounded_add (f_nonneg : 0 ≤ f)
(f_mul : ∀ x y : R, f (x * y) ≤ c * f x * f y)
(f_add : ∀ a b, f (a + b) ≤ f a + f b) (x y : R) :
seminormFromBounded' f (x + y) ≤ seminormFromBounded' f x + seminormFromBounded' f y := by
refine ciSup_le (fun z ↦ ?_)
suffices hf : f ((x + y) * z) / f z ≤ f (x * z) / f z + f (y * z) / f z by
exact le_trans hf (add_le_add
(le_ciSup_of_le (seminormFromBounded_bddAbove_range f_nonneg f_mul x) z (le_refl _))
(le_ciSup_of_le (seminormFromBounded_bddAbove_range f_nonneg f_mul y) z (le_refl _)))
by_cases hz : f z = 0
· simp only [hz, div_zero, zero_add, le_refl, or_self_iff]
· rw [div_add_div_same, div_le_div_right (lt_of_le_of_ne' (f_nonneg _) hz), add_mul]
exact f_add _ _
/-- `seminormFromBounded'` is a ring seminorm on `R`. -/
def seminormFromBounded (f_zero : f 0 = 0) (f_nonneg : 0 ≤ f)
(f_mul : ∀ x y : R, f (x * y) ≤ c * f x * f y)
(f_add : ∀ a b, f (a + b) ≤ f a + f b) (f_neg : ∀ x : R, f (-x) = f x) : RingSeminorm R where
toFun := seminormFromBounded' f
map_zero' := seminormFromBounded_zero f_zero
add_le' := seminormFromBounded_add f_nonneg f_mul f_add
mul_le' := seminormFromBounded_mul f_nonneg f_mul
neg' := seminormFromBounded_neg f_neg
/-- If `f : R → ℝ` is a nonnegative, multiplicatively bounded, nonarchimedean function, then
`seminormFromBounded' f` is nonarchimedean. -/
theorem seminormFromBounded_isNonarchimedean (f_nonneg : 0 ≤ f)
(f_mul : ∀ x y : R, f (x * y) ≤ c * f x * f y)
(hna : IsNonarchimedean f) : IsNonarchimedean (seminormFromBounded' f) := by
refine fun x y ↦ ciSup_le (fun z ↦ ?_)
rw [le_max_iff]
suffices hf : f ((x + y) * z) / f z ≤ f (x * z) / f z ∨ f ((x + y) * z) / f z ≤ f (y * z) / f z by
rcases hf with hfx | hfy
· exact Or.inl <| le_ciSup_of_le (seminormFromBounded_bddAbove_range f_nonneg f_mul x) z hfx
· exact Or.inr <| le_ciSup_of_le (seminormFromBounded_bddAbove_range f_nonneg f_mul y) z hfy
by_cases hz : f z = 0
· simp only [hz, div_zero, le_refl, or_self_iff]
· rw [div_le_div_right (lt_of_le_of_ne' (f_nonneg _) hz),
div_le_div_right (lt_of_le_of_ne' (f_nonneg _) hz), add_mul, ← le_max_iff]
exact hna _ _
/-- If `f : R → ℝ` is a nonnegative, multiplicatively bounded function and `x : R` is
multiplicative for `f`, then `seminormFromBounded' f x = f x`. -/
theorem seminormFromBounded_of_mul_apply (f_nonneg : 0 ≤ f)
(f_mul : ∀ x y : R, f (x * y) ≤ c * f x * f y) {x : R}
(hx : ∀ y : R, f (x * y) = f x * f y) : seminormFromBounded' f x = f x := by
simp_rw [seminormFromBounded', hx, ← mul_div_assoc']
apply le_antisymm
· refine ciSup_le (fun x ↦ ?_)
by_cases hx : f x = 0
· rw [hx, div_zero, mul_zero]; exact f_nonneg _
· rw [div_self hx, mul_one]
· by_cases f_ne_zero : f ≠ 0
· conv_lhs => rw [← mul_one (f x)]
rw [← div_self (map_one_ne_zero f_ne_zero f_nonneg f_mul)]
have h_bdd : BddAbove (Set.range fun y ↦ f x * (f y / f y)) := by
use f x
rintro r ⟨y, rfl⟩
by_cases hy0 : f y = 0
· simp only [hy0, div_zero, mul_zero]; exact f_nonneg _
· simp only [div_self hy0, mul_one, le_refl]
exact le_ciSup h_bdd (1 : R)
· push_neg at f_ne_zero
simp_rw [f_ne_zero, Pi.zero_apply, zero_div, zero_mul, ciSup_const]; rfl
/-- If `f : R → ℝ` is a nonnegative function and `x : R` is submultiplicative for `f`, then
`seminormFromBounded' f x = f x`. -/
theorem seminormFromBounded_of_mul_le (f_nonneg : 0 ≤ f) {x : R}
(hx : ∀ y : R, f (x * y) ≤ f x * f y) (h_one : f 1 ≤ 1) : seminormFromBounded' f x = f x := by
simp_rw [seminormFromBounded']
apply le_antisymm
· refine ciSup_le (fun y ↦ ?_)
by_cases hy : f y = 0
· rw [hy, div_zero]; exact f_nonneg _
· rw [div_le_iff (lt_of_le_of_ne' (f_nonneg _) hy)]; exact hx _
· have h_bdd : BddAbove (Set.range fun y ↦ f (x * y) / f y) := by
use f x
rintro r ⟨y, rfl⟩
by_cases hy0 : f y = 0
· simp only [hy0, div_zero]
exact f_nonneg _
· rw [← mul_one (f x), ← div_self hy0, ← mul_div_assoc,
div_le_iff (lt_of_le_of_ne' (f_nonneg _) hy0), mul_div_assoc, div_self hy0, mul_one]
exact hx y
convert le_ciSup h_bdd (1 : R)
by_cases h0 : f x = 0
· rw [mul_one, h0, zero_div]
· have heq : f 1 = 1 := by
apply h_one.antisymm
specialize hx 1
rw [mul_one, le_mul_iff_one_le_right (lt_of_le_of_ne (f_nonneg _) (Ne.symm h0))] at hx
exact hx
rw [heq, mul_one, div_one]
/-- If `f : R → ℝ` is a nonzero, nonnegative, multiplicatively bounded function, then
`seminormFromBounded' f` is nonzero. -/
theorem seminormFromBounded_nonzero (f_ne_zero : f ≠ 0) (f_nonneg : 0 ≤ f)
(f_mul : ∀ x y : R, f (x * y) ≤ c * f x * f y) :
seminormFromBounded' f ≠ 0 := by
obtain ⟨x, hx⟩ := Function.ne_iff.mp f_ne_zero
rw [Function.ne_iff]
use x
rw [ne_eq, Pi.zero_apply, seminormFromBounded_eq_zero_iff f_nonneg f_mul x]
exact hx
/-- If `f : R → ℝ` is a nonnegative, multiplicatively bounded function, then the kernel of
`seminormFromBounded' f` equals the kernel of `f`. -/
theorem seminormFromBounded_ker (f_nonneg : 0 ≤ f)
(f_mul : ∀ x y : R, f (x * y) ≤ c * f x * f y) :
seminormFromBounded' f ⁻¹' {0} = f ⁻¹' {0} := by
ext x
exact seminormFromBounded_eq_zero_iff f_nonneg f_mul x
/-- If `f : R → ℝ` is a nonnegative, multiplicatively bounded, subadditive function that preserves
zero and negation, then `seminormFromBounded' f` is a norm if and only if `f⁻¹' {0} = {0}`. -/
theorem seminormFromBounded_is_norm_iff (f_zero : f 0 = 0) (f_nonneg : 0 ≤ f)
(f_mul : ∀ x y : R, f (x * y) ≤ c * f x * f y)
(f_add : ∀ a b, f (a + b) ≤ f a + f b) (f_neg : ∀ x : R, f (-x) = f x) :
(∀ x : R, (seminormFromBounded f_zero f_nonneg f_mul f_add f_neg).toFun x = 0 → x = 0) ↔
f ⁻¹' {0} = {0} := by
refine ⟨fun h0 ↦ ?_, fun h_ker x hx ↦ ?_⟩
· rw [← seminormFromBounded_ker f_nonneg f_mul]
ext x
simp only [Set.mem_preimage, Set.mem_singleton_iff]
exact ⟨fun h ↦ h0 x h, fun h ↦ by rw [h]; exact seminormFromBounded_zero f_zero⟩
· rw [← Set.mem_singleton_iff, ← h_ker, Set.mem_preimage, Set.mem_singleton_iff,
← seminormFromBounded_eq_zero_iff f_nonneg f_mul x]
exact hx
/-- `seminormFromBounded' f` as a `RingNorm` on `R`, provided that `f` is nonnegative,
multiplicatively bounded and subadditive, that it preserves `0` and negation, and that `f` has
trivial kernel. -/
def normFromBounded (f_zero : f 0 = 0) (f_nonneg : 0 ≤ f)
(f_mul : ∀ x y : R, f (x * y) ≤ c * f x * f y)
(f_add : ∀ a b, f (a + b) ≤ f a + f b) (f_neg : ∀ x : R, f (-x) = f x)
(f_ker : f ⁻¹' {0} = {0}) : RingNorm R :=
{ seminormFromBounded f_zero f_nonneg f_mul f_add f_neg with
eq_zero_of_map_eq_zero' :=
(seminormFromBounded_is_norm_iff f_zero f_nonneg f_mul f_add f_neg).mpr f_ker }
/-- If `f : R → ℝ` is a nonnegative, multiplicatively bounded function and `x : R` is
multiplicative for `f`, then `x` is multiplicative for `seminormFromBounded' f`. -/
theorem seminormFromBounded_of_mul_is_mul (f_nonneg : 0 ≤ f)
(f_mul : ∀ x y : R, f (x * y) ≤ c * f x * f y) {x : R}
(hx : ∀ y : R, f (x * y) = f x * f y) (y : R) :
seminormFromBounded' f (x * y) = seminormFromBounded' f x * seminormFromBounded' f y := by
rw [seminormFromBounded_of_mul_apply f_nonneg f_mul hx]
simp only [seminormFromBounded', mul_assoc, hx, mul_div_assoc,
Real.mul_iSup_of_nonneg (f_nonneg _)]
end seminormFromBounded
|
Analysis\Normed\Ring\SeminormFromConst.lean | /-
Copyright (c) 2024 María Inés de Frutos-Fernández. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: María Inés de Frutos-Fernández
-/
import Mathlib.Analysis.Normed.Ring.Seminorm
/-!
# SeminormFromConst
In this file, we prove [BGR, Proposition 1.3.2/2][bosch-guntzer-remmert] : starting from a
power-multiplicative seminorm on a commutative ring `R` and a nonzero `c : R`, we create a new
power-multiplicative seminorm for which `c` is multiplicative.
## Main Definitions
* `seminormFromConst'` : the real-valued function sending `x ∈ R` to the limit of
`(f (x * c^n))/((f c)^n)`.
* `seminormFromConst` : the function `seminormFromConst'` as a `RingSeminorm` on `R`.
## Main Results
* `seminormFromConst_isNonarchimedean` : the function `seminormFromConst' hf1 hc hpm`
is nonarchimedean when f is nonarchimedean.
* `seminormFromConst_isPowMul` : the function `seminormFromConst' hf1 hc hpm`
is power-multiplicative.
* `seminormFromConst_const_mul` : for every `x : R`, `seminormFromConst' hf1 hc hpm (c * x)`
equals the product `seminormFromConst' hf1 hc hpm c * SeminormFromConst' hf1 hc hpm x`.
## References
* [S. Bosch, U. Güntzer, R. Remmert, *Non-Archimedean Analysis*][bosch-guntzer-remmert]
## Tags
SeminormFromConst, Seminorm, Nonarchimedean
-/
noncomputable section
open Filter
open scoped Topology
section Ring
variable {R : Type _} [CommRing R] (c : R) (f : RingSeminorm R) (hf1 : f 1 ≤ 1) (hc : f c ≠ 0)
(hpm : IsPowMul f)
/-- For a ring seminorm `f` on `R` and `c ∈ R`, the sequence given by `(f (x * c^n))/((f c)^n)`. -/
def seminormFromConst_seq (x : R) : ℕ → ℝ := fun n ↦ f (x * c ^ n) / f c ^ n
lemma seminormFromConst_seq_def (x : R) :
seminormFromConst_seq c f x = fun n ↦ f (x * c ^ n) / f c ^ n := rfl
/-- The terms in the sequence `seminormFromConst_seq c f x` are nonnegative. -/
theorem seminormFromConst_seq_nonneg (x : R) : 0 ≤ seminormFromConst_seq c f x :=
fun n ↦ div_nonneg (apply_nonneg f (x * c ^ n)) (pow_nonneg (apply_nonneg f c) n)
/-- The image of `seminormFromConst_seq c f x` is bounded below by zero. -/
theorem seminormFromConst_bddBelow (x : R) :
BddBelow (Set.range (seminormFromConst_seq c f x)) := by
use 0
rintro r ⟨n, rfl⟩
exact seminormFromConst_seq_nonneg c f x n
variable {f}
/-- `seminormFromConst_seq c f 0` is the constant sequence zero. -/
theorem seminormFromConst_seq_zero (hf : f 0 = 0) : seminormFromConst_seq c f 0 = 0 := by
rw [seminormFromConst_seq_def]
ext n
rw [zero_mul, hf, zero_div, Pi.zero_apply]
variable {c}
/-- If `1 ≤ n`, then `seminormFromConst_seq c f 1 n = 1`. -/
theorem seminormFromConst_seq_one (n : ℕ) (hn : 1 ≤ n) : seminormFromConst_seq c f 1 n = 1 := by
simp only [seminormFromConst_seq]
rw [one_mul, hpm _ hn, div_self (pow_ne_zero n hc)]
/-- `seminormFromConst_seq c f x` is antitone. -/
theorem seminormFromConst_seq_antitone (x : R) : Antitone (seminormFromConst_seq c f x) := by
intro m n hmn
simp only [seminormFromConst_seq]
nth_rw 1 [← Nat.add_sub_of_le hmn]
rw [pow_add, ← mul_assoc]
have hc_pos : 0 < f c := lt_of_le_of_ne (apply_nonneg f _) hc.symm
apply le_trans ((div_le_div_right (pow_pos hc_pos _)).mpr (map_mul_le_mul f _ _))
by_cases heq : m = n
· have hnm : n - m = 0 := by rw [heq, Nat.sub_self n]
rw [hnm, heq, div_le_div_right (pow_pos hc_pos _), pow_zero]
conv_rhs => rw [← mul_one (f (x * c ^ n))]
exact mul_le_mul_of_nonneg_left hf1 (apply_nonneg f _)
· have h1 : 1 ≤ n - m := by
rw [Nat.one_le_iff_ne_zero, ne_eq, Nat.sub_eq_zero_iff_le, not_le]
exact lt_of_le_of_ne hmn heq
rw [hpm c h1, mul_div_assoc, div_eq_mul_inv, pow_sub₀ _ hc hmn, mul_assoc, mul_comm (f c ^ m)⁻¹,
← mul_assoc (f c ^ n), mul_inv_cancel (pow_ne_zero n hc), one_mul, div_eq_mul_inv]
/-- The real-valued function sending `x ∈ R` to the limit of `(f (x * c^n))/((f c)^n)`. -/
def seminormFromConst' (x : R) : ℝ :=
(Real.tendsto_of_bddBelow_antitone (seminormFromConst_bddBelow c f x)
(seminormFromConst_seq_antitone hf1 hc hpm x)).choose
/-- We prove that `seminormFromConst' hf1 hc hpm x` is the limit of the sequence
`seminormFromConst_seq c f x` as `n` tends to infinity. -/
theorem seminormFromConst_isLimit (x : R) :
Tendsto (seminormFromConst_seq c f x) atTop (𝓝 (seminormFromConst' hf1 hc hpm x)) :=
(Real.tendsto_of_bddBelow_antitone (seminormFromConst_bddBelow c f x)
(seminormFromConst_seq_antitone hf1 hc hpm x)).choose_spec
/-- `seminormFromConst' hf1 hc hpm 1 = 1`. -/
theorem seminormFromConst_one : seminormFromConst' hf1 hc hpm 1 = 1 := by
apply tendsto_nhds_unique_of_eventuallyEq (seminormFromConst_isLimit hf1 hc hpm 1)
tendsto_const_nhds
simp only [EventuallyEq, eventually_atTop, ge_iff_le]
exact ⟨1, seminormFromConst_seq_one hc hpm⟩
/-- The function `seminormFromConst` is a `RingSeminorm` on `R`. -/
def seminormFromConst : RingSeminorm R where
toFun := seminormFromConst' hf1 hc hpm
map_zero' := tendsto_nhds_unique (seminormFromConst_isLimit hf1 hc hpm 0)
(by simpa [seminormFromConst_seq_zero c (map_zero _)] using tendsto_const_nhds)
add_le' x y := by
apply le_of_tendsto_of_tendsto' (seminormFromConst_isLimit hf1 hc hpm (x + y))
((seminormFromConst_isLimit hf1 hc hpm x).add (seminormFromConst_isLimit hf1 hc hpm y))
intro n
have h_add : f ((x + y) * c ^ n) ≤ f (x * c ^ n) + f (y * c ^ n) := by
simp only [add_mul, map_add_le_add f _ _]
simp only [seminormFromConst_seq, div_add_div_same]
exact (div_le_div_right (pow_pos (lt_of_le_of_ne (apply_nonneg f _) hc.symm) _)).mpr h_add
neg' x := by
apply tendsto_nhds_unique_of_eventuallyEq (seminormFromConst_isLimit hf1 hc hpm (-x))
(seminormFromConst_isLimit hf1 hc hpm x)
simp only [EventuallyEq, eventually_atTop]
use 0
simp only [seminormFromConst_seq, neg_mul, map_neg_eq_map, zero_le, implies_true]
mul_le' x y := by
have hlim : Tendsto (fun n ↦ seminormFromConst_seq c f (x * y) (2 * n)) atTop
(𝓝 (seminormFromConst' hf1 hc hpm (x * y))) := by
apply (seminormFromConst_isLimit hf1 hc hpm (x * y)).comp
(tendsto_atTop_atTop_of_monotone (fun _ _ hnm ↦ by
simp only [mul_le_mul_left, Nat.succ_pos', hnm]) _)
· rintro n; use n; linarith
refine le_of_tendsto_of_tendsto' hlim ((seminormFromConst_isLimit hf1 hc hpm x).mul
(seminormFromConst_isLimit hf1 hc hpm y)) (fun n ↦ ?_)
simp only [seminormFromConst_seq]
rw [div_mul_div_comm, ← pow_add, two_mul,
div_le_div_right (pow_pos (lt_of_le_of_ne (apply_nonneg f _) hc.symm) _), pow_add,
← mul_assoc, mul_comm (x * y), ← mul_assoc, mul_assoc, mul_comm (c ^ n)]
exact map_mul_le_mul f (x * c ^ n) (y * c ^ n)
theorem seminormFromConst_def (x : R) :
seminormFromConst hf1 hc hpm x = seminormFromConst' hf1 hc hpm x :=
rfl
/-- `seminormFromConst' hf1 hc hpm 1 ≤ 1`. -/
theorem seminormFromConst_one_le : seminormFromConst' hf1 hc hpm 1 ≤ 1 :=
le_of_eq (seminormFromConst_one hf1 hc hpm)
/-- The function `seminormFromConst' hf1 hc hpm` is nonarchimedean. -/
theorem seminormFromConst_isNonarchimedean (hna : IsNonarchimedean f) :
IsNonarchimedean (seminormFromConst' hf1 hc hpm) := fun x y ↦ by
apply le_of_tendsto_of_tendsto' (seminormFromConst_isLimit hf1 hc hpm (x + y))
((seminormFromConst_isLimit hf1 hc hpm x).max (seminormFromConst_isLimit hf1 hc hpm y))
intro n
have hmax : f ((x + y) * c ^ n) ≤ max (f (x * c ^ n)) (f (y * c ^ n)) := by
simp only [add_mul, hna _ _]
rw [le_max_iff] at hmax ⊢
rcases hmax with hmax | hmax <;> [left; right] <;>
exact (div_le_div_right (pow_pos (lt_of_le_of_ne (apply_nonneg f c) hc.symm) _)).mpr hmax
/-- The function `seminormFromConst' hf1 hc hpm` is power-multiplicative. -/
theorem seminormFromConst_isPowMul : IsPowMul (seminormFromConst' hf1 hc hpm) := fun x m hm ↦ by
simp only [seminormFromConst']
have hlim : Tendsto (fun n ↦ seminormFromConst_seq c f (x ^ m) (m * n)) atTop
(𝓝 (seminormFromConst' hf1 hc hpm (x ^ m))) := by
apply (seminormFromConst_isLimit hf1 hc hpm (x ^ m)).comp
(tendsto_atTop_atTop_of_monotone (fun _ _ hnk ↦ mul_le_mul_left' hnk m) _)
rintro n; use n; exact le_mul_of_one_le_left' hm
apply tendsto_nhds_unique hlim
convert (seminormFromConst_isLimit hf1 hc hpm x).pow m using 1
ext n
simp only [seminormFromConst_seq, div_pow, ← hpm _ hm, ← pow_mul, mul_pow, mul_comm m n]
/-- The function `seminormFromConst' hf1 hc hpm` is bounded above by `x`. -/
theorem seminormFromConst_le_seminorm (x : R) : seminormFromConst' hf1 hc hpm x ≤ f x := by
apply le_of_tendsto (seminormFromConst_isLimit hf1 hc hpm x)
simp only [eventually_atTop, ge_iff_le]
use 1
intro n hn
apply le_trans ((div_le_div_right (pow_pos (lt_of_le_of_ne (apply_nonneg f c) hc.symm) _)).mpr
(map_mul_le_mul _ _ _))
rw [hpm c hn, mul_div_assoc, div_self (pow_ne_zero n hc), mul_one]
/-- If `x : R` is multiplicative for `f`, then `seminormFromConst' hf1 hc hpm x = f x`. -/
theorem seminormFromConst_apply_of_isMul {x : R} (hx : ∀ y : R, f (x * y) = f x * f y) :
seminormFromConst' hf1 hc hpm x = f x :=
have hlim : Tendsto (seminormFromConst_seq c f x) atTop (𝓝 (f x)) := by
have hseq : seminormFromConst_seq c f x = fun _n ↦ f x := by
ext n
by_cases hn : n = 0
· simp only [seminormFromConst_seq, hn, pow_zero, mul_one, div_one]
· simp only [seminormFromConst_seq, hx (c ^ n), hpm _ (Nat.one_le_iff_ne_zero.mpr hn),
mul_div_assoc, div_self (pow_ne_zero n hc), mul_one]
rw [hseq]
exact tendsto_const_nhds
tendsto_nhds_unique (seminormFromConst_isLimit hf1 hc hpm x) hlim
/-- If `x : R` is multiplicative for `f`, then it is multiplicative for
`seminormFromConst' hf1 hc hpm`. -/
theorem seminormFromConst_isMul_of_isMul {x : R} (hx : ∀ y : R, f (x * y) = f x * f y) (y : R) :
seminormFromConst' hf1 hc hpm (x * y) =
seminormFromConst' hf1 hc hpm x * seminormFromConst' hf1 hc hpm y :=
have hlim : Tendsto (seminormFromConst_seq c f (x * y)) atTop
(𝓝 (seminormFromConst' hf1 hc hpm x * seminormFromConst' hf1 hc hpm y)) := by
rw [seminormFromConst_apply_of_isMul hf1 hc hpm hx]
have hseq : seminormFromConst_seq c f (x * y) =
fun n ↦ f x * seminormFromConst_seq c f y n := by
ext n
simp only [seminormFromConst_seq, mul_assoc, hx, mul_div_assoc]
simpa [hseq] using (seminormFromConst_isLimit hf1 hc hpm y).const_mul _
tendsto_nhds_unique (seminormFromConst_isLimit hf1 hc hpm (x * y)) hlim
/-- `seminormFromConst' hf1 hc hpm c = f c`. -/
theorem seminormFromConst_apply_c : seminormFromConst' hf1 hc hpm c = f c :=
have hlim : Tendsto (seminormFromConst_seq c f c) atTop (𝓝 (f c)) := by
have hseq : seminormFromConst_seq c f c = fun _n ↦ f c := by
ext n
simp only [seminormFromConst_seq]
rw [mul_comm, ← pow_succ, hpm _ le_add_self, pow_succ, mul_comm, mul_div_assoc,
div_self (pow_ne_zero n hc), mul_one]
rw [hseq]
exact tendsto_const_nhds
tendsto_nhds_unique (seminormFromConst_isLimit hf1 hc hpm c) hlim
/-- For every `x : R`, `seminormFromConst' hf1 hc hpm (c * x)` equals the product
`seminormFromConst' hf1 hc hpm c * SeminormFromConst' hf1 hc hpm x`. -/
theorem seminormFromConst_const_mul (x : R) :
seminormFromConst' hf1 hc hpm (c * x) =
seminormFromConst' hf1 hc hpm c * seminormFromConst' hf1 hc hpm x := by
have hlim : Tendsto (fun n ↦ seminormFromConst_seq c f x (n + 1)) atTop
(𝓝 (seminormFromConst' hf1 hc hpm x)) := by
apply (seminormFromConst_isLimit hf1 hc hpm x).comp
(tendsto_atTop_atTop_of_monotone (fun _ _ hnm ↦ add_le_add_right hnm 1) _)
rintro n; use n; linarith
rw [seminormFromConst_apply_c hf1 hc hpm]
apply tendsto_nhds_unique (seminormFromConst_isLimit hf1 hc hpm (c * x))
have hterm : seminormFromConst_seq c f (c * x) =
fun n ↦ f c * seminormFromConst_seq c f x (n + 1) := by
simp only [seminormFromConst_seq_def]
ext n
ring_nf
rw [mul_assoc _ (f c), mul_inv_cancel hc, mul_one]
simpa [hterm] using tendsto_const_nhds.mul hlim
end Ring
section Field
variable {K : Type _} [Field K]
/-- If `K` is a field, the function `seminormFromConst` is a `RingNorm` on `K`. -/
def normFromConst {k : K} {g : RingSeminorm K} (hg1 : g 1 ≤ 1) (hg_k : g k ≠ 0)
(hg_pm : IsPowMul g) : RingNorm K :=
(seminormFromConst hg1 hg_k hg_pm).toRingNorm (RingSeminorm.ne_zero_iff.mpr
⟨k, by simpa [seminormFromConst_def, seminormFromConst_apply_c] using hg_k⟩)
theorem seminormFromConstRingNormOfField_def {k : K} {g : RingSeminorm K} (hg1 : g 1 ≤ 1)
(hg_k : g k ≠ 0) (hg_pm : IsPowMul g) (x : K) :
normFromConst hg1 hg_k hg_pm x = seminormFromConst' hg1 hg_k hg_pm x := rfl
end Field
|
Analysis\Normed\Ring\Units.lean | /-
Copyright (c) 2020 Heather Macbeth. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Heather Macbeth
-/
import Mathlib.Topology.Algebra.Ring.Ideal
import Mathlib.Analysis.SpecificLimits.Normed
/-!
# The group of units of a complete normed ring
This file contains the basic theory for the group of units (invertible elements) of a complete
normed ring (Banach algebras being a notable special case).
## Main results
The constructions `Units.oneSub`, `Units.add`, and `Units.ofNearby` state, in varying forms, that
perturbations of a unit are units. The latter two are not stated in their optimal form; more precise
versions would use the spectral radius.
The first main result is `Units.isOpen`: the group of units of a complete normed ring is an open
subset of the ring.
The function `Ring.inverse` (defined elsewhere), for a ring `R`, sends `a : R` to `a⁻¹` if `a` is a
unit and `0` if not. The other major results of this file (notably `NormedRing.inverse_add`,
`NormedRing.inverse_add_norm` and `NormedRing.inverse_add_norm_diff_nth_order`) cover the asymptotic
properties of `Ring.inverse (x + t)` as `t → 0`.
-/
noncomputable section
open Topology
variable {R : Type*} [NormedRing R] [CompleteSpace R]
namespace Units
/-- In a complete normed ring, a perturbation of `1` by an element `t` of distance less than `1`
from `1` is a unit. Here we construct its `Units` structure. -/
@[simps val]
def oneSub (t : R) (h : ‖t‖ < 1) : Rˣ where
val := 1 - t
inv := ∑' n : ℕ, t ^ n
val_inv := mul_neg_geom_series t h
inv_val := geom_series_mul_neg t h
/-- In a complete normed ring, a perturbation of a unit `x` by an element `t` of distance less than
`‖x⁻¹‖⁻¹` from `x` is a unit. Here we construct its `Units` structure. -/
@[simps! val]
def add (x : Rˣ) (t : R) (h : ‖t‖ < ‖(↑x⁻¹ : R)‖⁻¹) : Rˣ :=
Units.copy -- to make `add_val` true definitionally, for convenience
(x * Units.oneSub (-((x⁻¹).1 * t)) (by
nontriviality R using zero_lt_one
have hpos : 0 < ‖(↑x⁻¹ : R)‖ := Units.norm_pos x⁻¹
calc
‖-(↑x⁻¹ * t)‖ = ‖↑x⁻¹ * t‖ := by rw [norm_neg]
_ ≤ ‖(↑x⁻¹ : R)‖ * ‖t‖ := norm_mul_le (x⁻¹).1 _
_ < ‖(↑x⁻¹ : R)‖ * ‖(↑x⁻¹ : R)‖⁻¹ := by nlinarith only [h, hpos]
_ = 1 := mul_inv_cancel (ne_of_gt hpos)))
(x + t) (by simp [mul_add]) _ rfl
/-- In a complete normed ring, an element `y` of distance less than `‖x⁻¹‖⁻¹` from `x` is a unit.
Here we construct its `Units` structure. -/
@[simps! val]
def ofNearby (x : Rˣ) (y : R) (h : ‖y - x‖ < ‖(↑x⁻¹ : R)‖⁻¹) : Rˣ :=
(x.add (y - x : R) h).copy y (by simp) _ rfl
/-- The group of units of a complete normed ring is an open subset of the ring. -/
protected theorem isOpen : IsOpen { x : R | IsUnit x } := by
nontriviality R
rw [Metric.isOpen_iff]
rintro _ ⟨x, rfl⟩
refine ⟨‖(↑x⁻¹ : R)‖⁻¹, _root_.inv_pos.mpr (Units.norm_pos x⁻¹), fun y hy ↦ ?_⟩
rw [mem_ball_iff_norm] at hy
exact (x.ofNearby y hy).isUnit
protected theorem nhds (x : Rˣ) : { x : R | IsUnit x } ∈ 𝓝 (x : R) :=
IsOpen.mem_nhds Units.isOpen x.isUnit
end Units
namespace nonunits
/-- The `nonunits` in a complete normed ring are contained in the complement of the ball of radius
`1` centered at `1 : R`. -/
theorem subset_compl_ball : nonunits R ⊆ (Metric.ball (1 : R) 1)ᶜ := fun x hx h₁ ↦ hx <|
sub_sub_self 1 x ▸ (Units.oneSub (1 - x) (by rwa [mem_ball_iff_norm'] at h₁)).isUnit
-- The `nonunits` in a complete normed ring are a closed set
protected theorem isClosed : IsClosed (nonunits R) :=
Units.isOpen.isClosed_compl
end nonunits
namespace NormedRing
open scoped Classical
open Asymptotics Filter Metric Finset Ring
theorem inverse_one_sub (t : R) (h : ‖t‖ < 1) : inverse (1 - t) = ↑(Units.oneSub t h)⁻¹ := by
rw [← inverse_unit (Units.oneSub t h), Units.val_oneSub]
/-- The formula `Ring.inverse (x + t) = Ring.inverse (1 + x⁻¹ * t) * x⁻¹` holds for `t` sufficiently
small. -/
theorem inverse_add (x : Rˣ) :
∀ᶠ t in 𝓝 0, inverse ((x : R) + t) = inverse (1 + ↑x⁻¹ * t) * ↑x⁻¹ := by
nontriviality R
rw [Metric.eventually_nhds_iff]
refine ⟨‖(↑x⁻¹ : R)‖⁻¹, by cancel_denoms, fun t ht ↦ ?_⟩
rw [dist_zero_right] at ht
rw [← x.val_add t ht, inverse_unit, Units.add, Units.copy_eq, mul_inv_rev, Units.val_mul,
← inverse_unit, Units.val_oneSub, sub_neg_eq_add]
theorem inverse_one_sub_nth_order' (n : ℕ) {t : R} (ht : ‖t‖ < 1) :
inverse ((1 : R) - t) = (∑ i ∈ range n, t ^ i) + t ^ n * inverse (1 - t) :=
have := NormedRing.summable_geometric_of_norm_lt_one t ht
calc inverse (1 - t) = ∑' i : ℕ, t ^ i := inverse_one_sub t ht
_ = ∑ i ∈ range n, t ^ i + ∑' i : ℕ, t ^ (i + n) := (sum_add_tsum_nat_add _ this).symm
_ = (∑ i ∈ range n, t ^ i) + t ^ n * inverse (1 - t) := by
simp only [inverse_one_sub t ht, add_comm _ n, pow_add, this.tsum_mul_left]; rfl
theorem inverse_one_sub_nth_order (n : ℕ) :
∀ᶠ t in 𝓝 0, inverse ((1 : R) - t) = (∑ i ∈ range n, t ^ i) + t ^ n * inverse (1 - t) :=
Metric.eventually_nhds_iff.2 ⟨1, one_pos, fun t ht ↦ inverse_one_sub_nth_order' n <| by
rwa [← dist_zero_right]⟩
/-- The formula
`Ring.inverse (x + t) =
(∑ i ∈ Finset.range n, (- x⁻¹ * t) ^ i) * x⁻¹ + (- x⁻¹ * t) ^ n * Ring.inverse (x + t)`
holds for `t` sufficiently small. -/
theorem inverse_add_nth_order (x : Rˣ) (n : ℕ) :
∀ᶠ t in 𝓝 0, inverse ((x : R) + t) =
(∑ i ∈ range n, (-↑x⁻¹ * t) ^ i) * ↑x⁻¹ + (-↑x⁻¹ * t) ^ n * inverse (x + t) := by
have hzero : Tendsto (-(↑x⁻¹ : R) * ·) (𝓝 0) (𝓝 0) :=
(mulLeft_continuous _).tendsto' _ _ <| mul_zero _
filter_upwards [inverse_add x, hzero.eventually (inverse_one_sub_nth_order n)] with t ht ht'
rw [neg_mul, sub_neg_eq_add] at ht'
conv_lhs => rw [ht, ht', add_mul, ← neg_mul, mul_assoc]
rw [ht]
theorem inverse_one_sub_norm : (fun t : R => inverse (1 - t)) =O[𝓝 0] (fun _t => 1 : R → ℝ) := by
simp only [IsBigO, IsBigOWith, Metric.eventually_nhds_iff]
refine ⟨‖(1 : R)‖ + 1, (2 : ℝ)⁻¹, by norm_num, fun t ht ↦ ?_⟩
rw [dist_zero_right] at ht
have ht' : ‖t‖ < 1 := by
have : (2 : ℝ)⁻¹ < 1 := by cancel_denoms
linarith
simp only [inverse_one_sub t ht', norm_one, mul_one, Set.mem_setOf_eq]
change ‖∑' n : ℕ, t ^ n‖ ≤ _
have := NormedRing.tsum_geometric_of_norm_lt_one t ht'
have : (1 - ‖t‖)⁻¹ ≤ 2 := by
rw [← inv_inv (2 : ℝ)]
refine inv_le_inv_of_le (by norm_num) ?_
have : (2 : ℝ)⁻¹ + (2 : ℝ)⁻¹ = 1 := by ring
linarith
linarith
/-- The function `fun t ↦ inverse (x + t)` is O(1) as `t → 0`. -/
theorem inverse_add_norm (x : Rˣ) : (fun t : R => inverse (↑x + t)) =O[𝓝 0] fun _t => (1 : ℝ) := by
refine EventuallyEq.trans_isBigO (inverse_add x) (one_mul (1 : ℝ) ▸ ?_)
simp only [← sub_neg_eq_add, ← neg_mul]
have hzero : Tendsto (-(↑x⁻¹ : R) * ·) (𝓝 0) (𝓝 0) :=
(mulLeft_continuous _).tendsto' _ _ <| mul_zero _
exact (inverse_one_sub_norm.comp_tendsto hzero).mul (isBigO_const_const _ one_ne_zero _)
/-- The function
`fun t ↦ Ring.inverse (x + t) - (∑ i ∈ Finset.range n, (- x⁻¹ * t) ^ i) * x⁻¹`
is `O(t ^ n)` as `t → 0`. -/
theorem inverse_add_norm_diff_nth_order (x : Rˣ) (n : ℕ) :
(fun t : R => inverse (↑x + t) - (∑ i ∈ range n, (-↑x⁻¹ * t) ^ i) * ↑x⁻¹) =O[𝓝 (0 : R)]
fun t => ‖t‖ ^ n := by
refine EventuallyEq.trans_isBigO (.sub (inverse_add_nth_order x n) (.refl _ _)) ?_
simp only [add_sub_cancel_left]
refine ((isBigO_refl _ _).norm_right.mul (inverse_add_norm x)).trans ?_
simp only [mul_one, isBigO_norm_left]
exact ((isBigO_refl _ _).norm_right.const_mul_left _).pow _
/-- The function `fun t ↦ Ring.inverse (x + t) - x⁻¹` is `O(t)` as `t → 0`. -/
theorem inverse_add_norm_diff_first_order (x : Rˣ) :
(fun t : R => inverse (↑x + t) - ↑x⁻¹) =O[𝓝 0] fun t => ‖t‖ := by
simpa using inverse_add_norm_diff_nth_order x 1
/-- The function `fun t ↦ Ring.inverse (x + t) - x⁻¹ + x⁻¹ * t * x⁻¹` is `O(t ^ 2)` as `t → 0`. -/
theorem inverse_add_norm_diff_second_order (x : Rˣ) :
(fun t : R => inverse (↑x + t) - ↑x⁻¹ + ↑x⁻¹ * t * ↑x⁻¹) =O[𝓝 0] fun t => ‖t‖ ^ 2 := by
convert inverse_add_norm_diff_nth_order x 2 using 2
simp only [sum_range_succ, sum_range_zero, zero_add, pow_zero, pow_one, add_mul, one_mul,
← sub_sub, neg_mul, sub_neg_eq_add]
/-- The function `Ring.inverse` is continuous at each unit of `R`. -/
theorem inverse_continuousAt (x : Rˣ) : ContinuousAt inverse (x : R) := by
have h_is_o : (fun t : R => inverse (↑x + t) - ↑x⁻¹) =o[𝓝 0] (fun _ => 1 : R → ℝ) :=
(inverse_add_norm_diff_first_order x).trans_isLittleO (isLittleO_id_const one_ne_zero).norm_left
have h_lim : Tendsto (fun y : R => y - x) (𝓝 x) (𝓝 0) := by
refine tendsto_zero_iff_norm_tendsto_zero.mpr ?_
exact tendsto_iff_norm_sub_tendsto_zero.mp tendsto_id
rw [ContinuousAt, tendsto_iff_norm_sub_tendsto_zero, inverse_unit]
simpa [(· ∘ ·)] using h_is_o.norm_left.tendsto_div_nhds_zero.comp h_lim
end NormedRing
namespace Units
open MulOpposite Filter NormedRing
/-- In a normed ring, the coercion from `Rˣ` (equipped with the induced topology from the
embedding in `R × R`) to `R` is an open embedding. -/
theorem openEmbedding_val : OpenEmbedding (val : Rˣ → R) where
toEmbedding := embedding_val_mk'
(fun _ ⟨u, hu⟩ ↦ hu ▸ (inverse_continuousAt u).continuousWithinAt) Ring.inverse_unit
isOpen_range := Units.isOpen
/-- In a normed ring, the coercion from `Rˣ` (equipped with the induced topology from the
embedding in `R × R`) to `R` is an open map. -/
theorem isOpenMap_val : IsOpenMap (val : Rˣ → R) :=
openEmbedding_val.isOpenMap
end Units
namespace Ideal
/-- An ideal which contains an element within `1` of `1 : R` is the unit ideal. -/
theorem eq_top_of_norm_lt_one (I : Ideal R) {x : R} (hxI : x ∈ I) (hx : ‖1 - x‖ < 1) : I = ⊤ :=
let u := Units.oneSub (1 - x) hx
I.eq_top_iff_one.mpr <| by
simpa only [show u.inv * x = 1 by simp [u]] using I.mul_mem_left u.inv hxI
/-- The `Ideal.closure` of a proper ideal in a complete normed ring is proper. -/
theorem closure_ne_top (I : Ideal R) (hI : I ≠ ⊤) : I.closure ≠ ⊤ := by
have h := closure_minimal (coe_subset_nonunits hI) nonunits.isClosed
simpa only [I.closure.eq_top_iff_one, Ne] using mt (@h 1) one_not_mem_nonunits
/-- The `Ideal.closure` of a maximal ideal in a complete normed ring is the ideal itself. -/
theorem IsMaximal.closure_eq {I : Ideal R} (hI : I.IsMaximal) : I.closure = I :=
(hI.eq_of_le (I.closure_ne_top hI.ne_top) subset_closure).symm
/-- Maximal ideals in complete normed rings are closed. -/
instance IsMaximal.isClosed {I : Ideal R} [hI : I.IsMaximal] : IsClosed (I : Set R) :=
isClosed_of_closure_subset <| Eq.subset <| congr_arg ((↑) : Ideal R → Set R) hI.closure_eq
end Ideal
|
Analysis\NormedSpace\AddTorsor.lean | /-
Copyright (c) 2020 Joseph Myers. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joseph Myers, Yury Kudryashov
-/
import Mathlib.Algebra.CharP.Invertible
import Mathlib.Analysis.Normed.Module.Basic
import Mathlib.Analysis.Normed.Group.AddTorsor
import Mathlib.LinearAlgebra.AffineSpace.AffineSubspace
import Mathlib.Topology.Instances.RealVectorSpace
/-!
# Torsors of normed space actions.
This file contains lemmas about normed additive torsors over normed spaces.
-/
noncomputable section
open NNReal Topology
open Filter
variable {α V P W Q : Type*} [SeminormedAddCommGroup V] [PseudoMetricSpace P] [NormedAddTorsor V P]
[NormedAddCommGroup W] [MetricSpace Q] [NormedAddTorsor W Q]
section NormedSpace
variable {𝕜 : Type*} [NormedField 𝕜] [NormedSpace 𝕜 V] [NormedSpace 𝕜 W]
open AffineMap
theorem AffineSubspace.isClosed_direction_iff (s : AffineSubspace 𝕜 Q) :
IsClosed (s.direction : Set W) ↔ IsClosed (s : Set Q) := by
rcases s.eq_bot_or_nonempty with (rfl | ⟨x, hx⟩); · simp [isClosed_singleton]
rw [← (IsometryEquiv.vaddConst x).toHomeomorph.symm.isClosed_image,
AffineSubspace.coe_direction_eq_vsub_set_right hx]
rfl
@[simp]
theorem dist_center_homothety (p₁ p₂ : P) (c : 𝕜) :
dist p₁ (homothety p₁ c p₂) = ‖c‖ * dist p₁ p₂ := by
simp [homothety_def, norm_smul, ← dist_eq_norm_vsub, dist_comm]
@[simp]
theorem nndist_center_homothety (p₁ p₂ : P) (c : 𝕜) :
nndist p₁ (homothety p₁ c p₂) = ‖c‖₊ * nndist p₁ p₂ :=
NNReal.eq <| dist_center_homothety _ _ _
@[simp]
theorem dist_homothety_center (p₁ p₂ : P) (c : 𝕜) :
dist (homothety p₁ c p₂) p₁ = ‖c‖ * dist p₁ p₂ := by rw [dist_comm, dist_center_homothety]
@[simp]
theorem nndist_homothety_center (p₁ p₂ : P) (c : 𝕜) :
nndist (homothety p₁ c p₂) p₁ = ‖c‖₊ * nndist p₁ p₂ :=
NNReal.eq <| dist_homothety_center _ _ _
@[simp]
theorem dist_lineMap_lineMap (p₁ p₂ : P) (c₁ c₂ : 𝕜) :
dist (lineMap p₁ p₂ c₁) (lineMap p₁ p₂ c₂) = dist c₁ c₂ * dist p₁ p₂ := by
rw [dist_comm p₁ p₂]
simp only [lineMap_apply, dist_eq_norm_vsub, vadd_vsub_vadd_cancel_right,
← sub_smul, norm_smul, vsub_eq_sub]
@[simp]
theorem nndist_lineMap_lineMap (p₁ p₂ : P) (c₁ c₂ : 𝕜) :
nndist (lineMap p₁ p₂ c₁) (lineMap p₁ p₂ c₂) = nndist c₁ c₂ * nndist p₁ p₂ :=
NNReal.eq <| dist_lineMap_lineMap _ _ _ _
theorem lipschitzWith_lineMap (p₁ p₂ : P) : LipschitzWith (nndist p₁ p₂) (lineMap p₁ p₂ : 𝕜 → P) :=
LipschitzWith.of_dist_le_mul fun c₁ c₂ =>
((dist_lineMap_lineMap p₁ p₂ c₁ c₂).trans (mul_comm _ _)).le
@[simp]
theorem dist_lineMap_left (p₁ p₂ : P) (c : 𝕜) : dist (lineMap p₁ p₂ c) p₁ = ‖c‖ * dist p₁ p₂ := by
simpa only [lineMap_apply_zero, dist_zero_right] using dist_lineMap_lineMap p₁ p₂ c 0
@[simp]
theorem nndist_lineMap_left (p₁ p₂ : P) (c : 𝕜) :
nndist (lineMap p₁ p₂ c) p₁ = ‖c‖₊ * nndist p₁ p₂ :=
NNReal.eq <| dist_lineMap_left _ _ _
@[simp]
theorem dist_left_lineMap (p₁ p₂ : P) (c : 𝕜) : dist p₁ (lineMap p₁ p₂ c) = ‖c‖ * dist p₁ p₂ :=
(dist_comm _ _).trans (dist_lineMap_left _ _ _)
@[simp]
theorem nndist_left_lineMap (p₁ p₂ : P) (c : 𝕜) :
nndist p₁ (lineMap p₁ p₂ c) = ‖c‖₊ * nndist p₁ p₂ :=
NNReal.eq <| dist_left_lineMap _ _ _
@[simp]
theorem dist_lineMap_right (p₁ p₂ : P) (c : 𝕜) :
dist (lineMap p₁ p₂ c) p₂ = ‖1 - c‖ * dist p₁ p₂ := by
simpa only [lineMap_apply_one, dist_eq_norm'] using dist_lineMap_lineMap p₁ p₂ c 1
@[simp]
theorem nndist_lineMap_right (p₁ p₂ : P) (c : 𝕜) :
nndist (lineMap p₁ p₂ c) p₂ = ‖1 - c‖₊ * nndist p₁ p₂ :=
NNReal.eq <| dist_lineMap_right _ _ _
@[simp]
theorem dist_right_lineMap (p₁ p₂ : P) (c : 𝕜) : dist p₂ (lineMap p₁ p₂ c) = ‖1 - c‖ * dist p₁ p₂ :=
(dist_comm _ _).trans (dist_lineMap_right _ _ _)
@[simp]
theorem nndist_right_lineMap (p₁ p₂ : P) (c : 𝕜) :
nndist p₂ (lineMap p₁ p₂ c) = ‖1 - c‖₊ * nndist p₁ p₂ :=
NNReal.eq <| dist_right_lineMap _ _ _
@[simp]
theorem dist_homothety_self (p₁ p₂ : P) (c : 𝕜) :
dist (homothety p₁ c p₂) p₂ = ‖1 - c‖ * dist p₁ p₂ := by
rw [homothety_eq_lineMap, dist_lineMap_right]
@[simp]
theorem nndist_homothety_self (p₁ p₂ : P) (c : 𝕜) :
nndist (homothety p₁ c p₂) p₂ = ‖1 - c‖₊ * nndist p₁ p₂ :=
NNReal.eq <| dist_homothety_self _ _ _
@[simp]
theorem dist_self_homothety (p₁ p₂ : P) (c : 𝕜) :
dist p₂ (homothety p₁ c p₂) = ‖1 - c‖ * dist p₁ p₂ := by rw [dist_comm, dist_homothety_self]
@[simp]
theorem nndist_self_homothety (p₁ p₂ : P) (c : 𝕜) :
nndist p₂ (homothety p₁ c p₂) = ‖1 - c‖₊ * nndist p₁ p₂ :=
NNReal.eq <| dist_self_homothety _ _ _
section invertibleTwo
variable [Invertible (2 : 𝕜)]
@[simp]
theorem dist_left_midpoint (p₁ p₂ : P) : dist p₁ (midpoint 𝕜 p₁ p₂) = ‖(2 : 𝕜)‖⁻¹ * dist p₁ p₂ := by
rw [midpoint, dist_comm, dist_lineMap_left, invOf_eq_inv, ← norm_inv]
@[simp]
theorem nndist_left_midpoint (p₁ p₂ : P) :
nndist p₁ (midpoint 𝕜 p₁ p₂) = ‖(2 : 𝕜)‖₊⁻¹ * nndist p₁ p₂ :=
NNReal.eq <| dist_left_midpoint _ _
@[simp]
theorem dist_midpoint_left (p₁ p₂ : P) : dist (midpoint 𝕜 p₁ p₂) p₁ = ‖(2 : 𝕜)‖⁻¹ * dist p₁ p₂ := by
rw [dist_comm, dist_left_midpoint]
@[simp]
theorem nndist_midpoint_left (p₁ p₂ : P) :
nndist (midpoint 𝕜 p₁ p₂) p₁ = ‖(2 : 𝕜)‖₊⁻¹ * nndist p₁ p₂ :=
NNReal.eq <| dist_midpoint_left _ _
@[simp]
theorem dist_midpoint_right (p₁ p₂ : P) :
dist (midpoint 𝕜 p₁ p₂) p₂ = ‖(2 : 𝕜)‖⁻¹ * dist p₁ p₂ := by
rw [midpoint_comm, dist_midpoint_left, dist_comm]
@[simp]
theorem nndist_midpoint_right (p₁ p₂ : P) :
nndist (midpoint 𝕜 p₁ p₂) p₂ = ‖(2 : 𝕜)‖₊⁻¹ * nndist p₁ p₂ :=
NNReal.eq <| dist_midpoint_right _ _
@[simp]
theorem dist_right_midpoint (p₁ p₂ : P) :
dist p₂ (midpoint 𝕜 p₁ p₂) = ‖(2 : 𝕜)‖⁻¹ * dist p₁ p₂ := by
rw [dist_comm, dist_midpoint_right]
@[simp]
theorem nndist_right_midpoint (p₁ p₂ : P) :
nndist p₂ (midpoint 𝕜 p₁ p₂) = ‖(2 : 𝕜)‖₊⁻¹ * nndist p₁ p₂ :=
NNReal.eq <| dist_right_midpoint _ _
theorem dist_midpoint_midpoint_le' (p₁ p₂ p₃ p₄ : P) :
dist (midpoint 𝕜 p₁ p₂) (midpoint 𝕜 p₃ p₄) ≤ (dist p₁ p₃ + dist p₂ p₄) / ‖(2 : 𝕜)‖ := by
rw [dist_eq_norm_vsub V, dist_eq_norm_vsub V, dist_eq_norm_vsub V, midpoint_vsub_midpoint]
rw [midpoint_eq_smul_add, norm_smul, invOf_eq_inv, norm_inv, ← div_eq_inv_mul]
exact div_le_div_of_nonneg_right (norm_add_le _ _) (norm_nonneg _)
theorem nndist_midpoint_midpoint_le' (p₁ p₂ p₃ p₄ : P) :
nndist (midpoint 𝕜 p₁ p₂) (midpoint 𝕜 p₃ p₄) ≤ (nndist p₁ p₃ + nndist p₂ p₄) / ‖(2 : 𝕜)‖₊ :=
dist_midpoint_midpoint_le' _ _ _ _
end invertibleTwo
@[simp] theorem dist_pointReflection_left (p q : P) :
dist (Equiv.pointReflection p q) p = dist p q := by
simp [dist_eq_norm_vsub V, Equiv.pointReflection_vsub_left (G := V)]
@[simp] theorem dist_left_pointReflection (p q : P) :
dist p (Equiv.pointReflection p q) = dist p q :=
(dist_comm _ _).trans (dist_pointReflection_left _ _)
variable (𝕜) in
theorem dist_pointReflection_right (p q : P) :
dist (Equiv.pointReflection p q) q = ‖(2 : 𝕜)‖ * dist p q := by
simp [dist_eq_norm_vsub V, Equiv.pointReflection_vsub_right (G := V), ← Nat.cast_smul_eq_nsmul 𝕜,
norm_smul]
variable (𝕜) in
theorem dist_right_pointReflection (p q : P) :
dist q (Equiv.pointReflection p q) = ‖(2 : 𝕜)‖ * dist p q :=
(dist_comm _ _).trans (dist_pointReflection_right 𝕜 _ _)
theorem antilipschitzWith_lineMap {p₁ p₂ : Q} (h : p₁ ≠ p₂) :
AntilipschitzWith (nndist p₁ p₂)⁻¹ (lineMap p₁ p₂ : 𝕜 → Q) :=
AntilipschitzWith.of_le_mul_dist fun c₁ c₂ => by
rw [dist_lineMap_lineMap, NNReal.coe_inv, ← dist_nndist, mul_left_comm,
inv_mul_cancel (dist_ne_zero.2 h), mul_one]
variable (𝕜)
theorem eventually_homothety_mem_of_mem_interior (x : Q) {s : Set Q} {y : Q} (hy : y ∈ interior s) :
∀ᶠ δ in 𝓝 (1 : 𝕜), homothety x δ y ∈ s := by
rw [(NormedAddCommGroup.nhds_basis_norm_lt (1 : 𝕜)).eventually_iff]
rcases eq_or_ne y x with h | h
· use 1
simp [h.symm, interior_subset hy]
have hxy : 0 < ‖y -ᵥ x‖ := by rwa [norm_pos_iff, vsub_ne_zero]
obtain ⟨u, hu₁, hu₂, hu₃⟩ := mem_interior.mp hy
obtain ⟨ε, hε, hyε⟩ := Metric.isOpen_iff.mp hu₂ y hu₃
refine ⟨ε / ‖y -ᵥ x‖, div_pos hε hxy, fun δ (hδ : ‖δ - 1‖ < ε / ‖y -ᵥ x‖) => hu₁ (hyε ?_)⟩
rw [lt_div_iff hxy, ← norm_smul, sub_smul, one_smul] at hδ
rwa [homothety_apply, Metric.mem_ball, dist_eq_norm_vsub W, vadd_vsub_eq_sub_vsub]
theorem eventually_homothety_image_subset_of_finite_subset_interior (x : Q) {s : Set Q} {t : Set Q}
(ht : t.Finite) (h : t ⊆ interior s) : ∀ᶠ δ in 𝓝 (1 : 𝕜), homothety x δ '' t ⊆ s := by
suffices ∀ y ∈ t, ∀ᶠ δ in 𝓝 (1 : 𝕜), homothety x δ y ∈ s by
simp_rw [Set.image_subset_iff]
exact (Filter.eventually_all_finite ht).mpr this
intro y hy
exact eventually_homothety_mem_of_mem_interior 𝕜 x (h hy)
end NormedSpace
variable [NormedSpace ℝ V] [NormedSpace ℝ W]
theorem dist_midpoint_midpoint_le (p₁ p₂ p₃ p₄ : V) :
dist (midpoint ℝ p₁ p₂) (midpoint ℝ p₃ p₄) ≤ (dist p₁ p₃ + dist p₂ p₄) / 2 := by
simpa using dist_midpoint_midpoint_le' (𝕜 := ℝ) p₁ p₂ p₃ p₄
theorem nndist_midpoint_midpoint_le (p₁ p₂ p₃ p₄ : V) :
nndist (midpoint ℝ p₁ p₂) (midpoint ℝ p₃ p₄) ≤ (nndist p₁ p₃ + nndist p₂ p₄) / 2 :=
dist_midpoint_midpoint_le _ _ _ _
/-- A continuous map between two normed affine spaces is an affine map provided that
it sends midpoints to midpoints. -/
def AffineMap.ofMapMidpoint (f : P → Q) (h : ∀ x y, f (midpoint ℝ x y) = midpoint ℝ (f x) (f y))
(hfc : Continuous f) : P →ᵃ[ℝ] Q :=
let c := Classical.arbitrary P
AffineMap.mk' f (↑((AddMonoidHom.ofMapMidpoint ℝ ℝ
((AffineEquiv.vaddConst ℝ (f <| c)).symm ∘ f ∘ AffineEquiv.vaddConst ℝ c) (by simp)
fun x y => by -- Porting note: was `by simp [h]`
simp only [c, Function.comp_apply, AffineEquiv.vaddConst_apply,
AffineEquiv.vaddConst_symm_apply]
conv_lhs => rw [(midpoint_self ℝ (Classical.arbitrary P)).symm, midpoint_vadd_midpoint, h, h,
midpoint_vsub_midpoint]).toRealLinearMap <| by
apply_rules [Continuous.vadd, Continuous.vsub, continuous_const, hfc.comp, continuous_id]))
c fun p => by simp
end
section
open Dilation
variable {𝕜 E : Type*} [NormedDivisionRing 𝕜] [SeminormedAddCommGroup E]
variable [Module 𝕜 E] [BoundedSMul 𝕜 E] {P : Type*} [PseudoMetricSpace P] [NormedAddTorsor E P]
-- TODO: define `ContinuousAffineEquiv` and reimplement this as one of those.
/-- Scaling by an element `k` of the scalar ring as a `DilationEquiv` with ratio `‖k‖₊`, mapping
from a normed space to a normed torsor over that space sending `0` to `c`. -/
@[simps]
def DilationEquiv.smulTorsor (c : P) {k : 𝕜} (hk : k ≠ 0) : E ≃ᵈ P where
toFun := (k • · +ᵥ c)
invFun := k⁻¹ • (· -ᵥ c)
left_inv x := by simp [inv_smul_smul₀ hk]
right_inv p := by simp [smul_inv_smul₀ hk]
edist_eq' := ⟨‖k‖₊, nnnorm_ne_zero_iff.mpr hk, fun x y ↦ by
rw [show edist (k • x +ᵥ c) (k • y +ᵥ c) = _ from (IsometryEquiv.vaddConst c).isometry ..]
exact edist_smul₀ ..⟩
@[simp]
lemma DilationEquiv.smulTorsor_ratio {c : P} {k : 𝕜} (hk : k ≠ 0) {x y : E}
(h : dist x y ≠ 0) : ratio (smulTorsor c hk) = ‖k‖₊ :=
Eq.symm <| ratio_unique_of_dist_ne_zero h <| by simp [dist_eq_norm, ← smul_sub, norm_smul]
@[simp]
lemma DilationEquiv.smulTorsor_preimage_ball {c : P} {k : 𝕜} (hk : k ≠ 0) :
smulTorsor c hk ⁻¹' (Metric.ball c ‖k‖) = Metric.ball (0 : E) 1 := by
aesop (add simp norm_smul)
end
|
Analysis\NormedSpace\AddTorsorBases.lean | /-
Copyright (c) 2021 Oliver Nash. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Oliver Nash
-/
import Mathlib.Analysis.Normed.Module.FiniteDimension
import Mathlib.LinearAlgebra.AffineSpace.FiniteDimensional
/-!
# Bases in normed affine spaces.
This file contains results about bases in normed affine spaces.
## Main definitions:
* `continuous_barycentric_coord`
* `isOpenMap_barycentric_coord`
* `AffineBasis.interior_convexHull`
* `IsOpen.exists_subset_affineIndependent_span_eq_top`
* `interior_convexHull_nonempty_iff_affineSpan_eq_top`
-/
assert_not_exists HasFDerivAt
section Barycentric
variable {ι 𝕜 E P : Type*} [NontriviallyNormedField 𝕜] [CompleteSpace 𝕜]
variable [NormedAddCommGroup E] [NormedSpace 𝕜 E]
variable [MetricSpace P] [NormedAddTorsor E P]
theorem isOpenMap_barycentric_coord [Nontrivial ι] (b : AffineBasis ι 𝕜 P) (i : ι) :
IsOpenMap (b.coord i) :=
AffineMap.isOpenMap_linear_iff.mp <|
(b.coord i).linear.isOpenMap_of_finiteDimensional <|
(b.coord i).linear_surjective_iff.mpr (b.surjective_coord i)
variable [FiniteDimensional 𝕜 E] (b : AffineBasis ι 𝕜 P)
@[continuity]
theorem continuous_barycentric_coord (i : ι) : Continuous (b.coord i) :=
(b.coord i).continuous_of_finiteDimensional
end Barycentric
open Set
/-- Given a finite-dimensional normed real vector space, the interior of the convex hull of an
affine basis is the set of points whose barycentric coordinates are strictly positive with respect
to this basis.
TODO Restate this result for affine spaces (instead of vector spaces) once the definition of
convexity is generalised to this setting. -/
theorem AffineBasis.interior_convexHull {ι E : Type*} [Finite ι] [NormedAddCommGroup E]
[NormedSpace ℝ E] (b : AffineBasis ι ℝ E) :
interior (convexHull ℝ (range b)) = {x | ∀ i, 0 < b.coord i x} := by
cases subsingleton_or_nontrivial ι
· -- The zero-dimensional case.
have : range b = univ :=
AffineSubspace.eq_univ_of_subsingleton_span_eq_top (subsingleton_range _) b.tot
simp [this]
· -- The positive-dimensional case.
haveI : FiniteDimensional ℝ E := b.finiteDimensional
have : convexHull ℝ (range b) = ⋂ i, b.coord i ⁻¹' Ici 0 := by
rw [b.convexHull_eq_nonneg_coord, setOf_forall]; rfl
ext
simp only [this, interior_iInter_of_finite, ←
IsOpenMap.preimage_interior_eq_interior_preimage (isOpenMap_barycentric_coord b _)
(continuous_barycentric_coord b _),
interior_Ici, mem_iInter, mem_setOf_eq, mem_Ioi, mem_preimage]
variable {V P : Type*} [NormedAddCommGroup V] [NormedSpace ℝ V] [MetricSpace P]
[NormedAddTorsor V P]
open AffineMap
/-- Given a set `s` of affine-independent points belonging to an open set `u`, we may extend `s` to
an affine basis, all of whose elements belong to `u`. -/
theorem IsOpen.exists_between_affineIndependent_span_eq_top {s u : Set P} (hu : IsOpen u)
(hsu : s ⊆ u) (hne : s.Nonempty) (h : AffineIndependent ℝ ((↑) : s → P)) :
∃ t : Set P, s ⊆ t ∧ t ⊆ u ∧ AffineIndependent ℝ ((↑) : t → P) ∧ affineSpan ℝ t = ⊤ := by
obtain ⟨q, hq⟩ := hne
obtain ⟨ε, ε0, hεu⟩ := Metric.nhds_basis_closedBall.mem_iff.1 (hu.mem_nhds <| hsu hq)
obtain ⟨t, ht₁, ht₂, ht₃⟩ := exists_subset_affineIndependent_affineSpan_eq_top h
let f : P → P := fun y => lineMap q y (ε / dist y q)
have hf : ∀ y, f y ∈ u := by
refine fun y => hεu ?_
simp only [f]
rw [Metric.mem_closedBall, lineMap_apply, dist_vadd_left, norm_smul, Real.norm_eq_abs,
dist_eq_norm_vsub V y q, abs_div, abs_of_pos ε0, abs_of_nonneg (norm_nonneg _), div_mul_comm]
exact mul_le_of_le_one_left ε0.le (div_self_le_one _)
have hεyq : ∀ y ∉ s, ε / dist y q ≠ 0 := fun y hy =>
div_ne_zero ε0.ne' (dist_ne_zero.2 (ne_of_mem_of_not_mem hq hy).symm)
classical
let w : t → ℝˣ := fun p => if hp : (p : P) ∈ s then 1 else Units.mk0 _ (hεyq (↑p) hp)
refine ⟨Set.range fun p : t => lineMap q p (w p : ℝ), ?_, ?_, ?_, ?_⟩
· intro p hp; use ⟨p, ht₁ hp⟩; simp [w, hp]
· rintro y ⟨⟨p, hp⟩, rfl⟩
by_cases hps : p ∈ s <;>
simp only [w, hps, lineMap_apply_one, Units.val_mk0, dif_neg, dif_pos, not_false_iff,
Units.val_one, Subtype.coe_mk] <;>
[exact hsu hps; exact hf p]
· exact (ht₂.units_lineMap ⟨q, ht₁ hq⟩ w).range
· rw [affineSpan_eq_affineSpan_lineMap_units (ht₁ hq) w, ht₃]
theorem IsOpen.exists_subset_affineIndependent_span_eq_top {u : Set P} (hu : IsOpen u)
(hne : u.Nonempty) : ∃ s ⊆ u, AffineIndependent ℝ ((↑) : s → P) ∧ affineSpan ℝ s = ⊤ := by
rcases hne with ⟨x, hx⟩
rcases hu.exists_between_affineIndependent_span_eq_top (singleton_subset_iff.mpr hx)
(singleton_nonempty _) (affineIndependent_of_subsingleton _ _) with ⟨s, -, hsu, hs⟩
exact ⟨s, hsu, hs⟩
/-- The affine span of a nonempty open set is `⊤`. -/
theorem IsOpen.affineSpan_eq_top {u : Set P} (hu : IsOpen u) (hne : u.Nonempty) :
affineSpan ℝ u = ⊤ :=
let ⟨_, hsu, _, hs'⟩ := hu.exists_subset_affineIndependent_span_eq_top hne
top_unique <| hs' ▸ affineSpan_mono _ hsu
theorem affineSpan_eq_top_of_nonempty_interior {s : Set V}
(hs : (interior <| convexHull ℝ s).Nonempty) : affineSpan ℝ s = ⊤ :=
top_unique <| isOpen_interior.affineSpan_eq_top hs ▸
(affineSpan_mono _ interior_subset).trans_eq (affineSpan_convexHull _)
theorem AffineBasis.centroid_mem_interior_convexHull {ι} [Fintype ι] (b : AffineBasis ι ℝ V) :
Finset.univ.centroid ℝ b ∈ interior (convexHull ℝ (range b)) := by
haveI := b.nonempty
simp only [b.interior_convexHull, mem_setOf_eq, b.coord_apply_centroid (Finset.mem_univ _),
inv_pos, Nat.cast_pos, Finset.card_pos, Finset.univ_nonempty, forall_true_iff]
theorem interior_convexHull_nonempty_iff_affineSpan_eq_top [FiniteDimensional ℝ V] {s : Set V} :
(interior (convexHull ℝ s)).Nonempty ↔ affineSpan ℝ s = ⊤ := by
refine ⟨affineSpan_eq_top_of_nonempty_interior, fun h => ?_⟩
obtain ⟨t, hts, b, hb⟩ := AffineBasis.exists_affine_subbasis h
suffices (interior (convexHull ℝ (range b))).Nonempty by
rw [hb, Subtype.range_coe_subtype, setOf_mem_eq] at this
refine this.mono (by gcongr)
lift t to Finset V using b.finite_set
exact ⟨_, b.centroid_mem_interior_convexHull⟩
theorem Convex.interior_nonempty_iff_affineSpan_eq_top [FiniteDimensional ℝ V] {s : Set V}
(hs : Convex ℝ s) : (interior s).Nonempty ↔ affineSpan ℝ s = ⊤ := by
rw [← interior_convexHull_nonempty_iff_affineSpan_eq_top, hs.convexHull_eq]
|
Analysis\NormedSpace\AffineIsometry.lean | /-
Copyright (c) 2021 Heather Macbeth. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Heather Macbeth
-/
import Mathlib.Algebra.CharP.Invertible
import Mathlib.Analysis.Normed.Operator.LinearIsometry
import Mathlib.Analysis.Normed.Group.AddTorsor
import Mathlib.Analysis.Normed.Module.Basic
import Mathlib.LinearAlgebra.AffineSpace.Restrict
import Mathlib.Tactic.FailIfNoProgress
/-!
# Affine isometries
In this file we define `AffineIsometry 𝕜 P P₂` to be an affine isometric embedding of normed
add-torsors `P` into `P₂` over normed `𝕜`-spaces and `AffineIsometryEquiv` to be an affine
isometric equivalence between `P` and `P₂`.
We also prove basic lemmas and provide convenience constructors. The choice of these lemmas and
constructors is closely modelled on those for the `LinearIsometry` and `AffineMap` theories.
Since many elementary properties don't require `‖x‖ = 0 → x = 0` we initially set up the theory for
`SeminormedAddCommGroup` and specialize to `NormedAddCommGroup` only when needed.
## Notation
We introduce the notation `P →ᵃⁱ[𝕜] P₂` for `AffineIsometry 𝕜 P P₂`, and `P ≃ᵃⁱ[𝕜] P₂` for
`AffineIsometryEquiv 𝕜 P P₂`. In contrast with the notation `→ₗᵢ` for linear isometries, `≃ᵢ`
for isometric equivalences, etc., the "i" here is a superscript. This is for aesthetic reasons to
match the superscript "a" (note that in mathlib `→ᵃ` is an affine map, since `→ₐ` has been taken by
algebra-homomorphisms.)
-/
open Function Set
variable (𝕜 : Type*) {V V₁ V₁' V₂ V₃ V₄ : Type*} {P₁ P₁' : Type*} (P P₂ : Type*) {P₃ P₄ : Type*}
[NormedField 𝕜]
[SeminormedAddCommGroup V] [NormedSpace 𝕜 V] [PseudoMetricSpace P] [NormedAddTorsor V P]
[SeminormedAddCommGroup V₁] [NormedSpace 𝕜 V₁] [PseudoMetricSpace P₁] [NormedAddTorsor V₁ P₁]
[SeminormedAddCommGroup V₁'] [NormedSpace 𝕜 V₁'] [MetricSpace P₁'] [NormedAddTorsor V₁' P₁']
[SeminormedAddCommGroup V₂] [NormedSpace 𝕜 V₂] [PseudoMetricSpace P₂] [NormedAddTorsor V₂ P₂]
[SeminormedAddCommGroup V₃] [NormedSpace 𝕜 V₃] [PseudoMetricSpace P₃] [NormedAddTorsor V₃ P₃]
[SeminormedAddCommGroup V₄] [NormedSpace 𝕜 V₄] [PseudoMetricSpace P₄] [NormedAddTorsor V₄ P₄]
/-- A `𝕜`-affine isometric embedding of one normed add-torsor over a normed `𝕜`-space into
another. -/
structure AffineIsometry extends P →ᵃ[𝕜] P₂ where
norm_map : ∀ x : V, ‖linear x‖ = ‖x‖
variable {𝕜 P P₂}
@[inherit_doc]
notation:25 -- `→ᵃᵢ` would be more consistent with the linear isometry notation, but it is uglier
P " →ᵃⁱ[" 𝕜:25 "] " P₂:0 => AffineIsometry 𝕜 P P₂
namespace AffineIsometry
variable (f : P →ᵃⁱ[𝕜] P₂)
/-- The underlying linear map of an affine isometry is in fact a linear isometry. -/
protected def linearIsometry : V →ₗᵢ[𝕜] V₂ :=
{ f.linear with norm_map' := f.norm_map }
@[simp]
theorem linear_eq_linearIsometry : f.linear = f.linearIsometry.toLinearMap := by
ext
rfl
instance : FunLike (P →ᵃⁱ[𝕜] P₂) P P₂ :=
{ coe := fun f => f.toFun,
coe_injective' := fun f g => by cases f; cases g; simp }
@[simp]
theorem coe_toAffineMap : ⇑f.toAffineMap = f := by
rfl
theorem toAffineMap_injective : Injective (toAffineMap : (P →ᵃⁱ[𝕜] P₂) → P →ᵃ[𝕜] P₂) := by
rintro ⟨f, _⟩ ⟨g, _⟩ rfl
rfl
theorem coeFn_injective : @Injective (P →ᵃⁱ[𝕜] P₂) (P → P₂) (↑) :=
AffineMap.coeFn_injective.comp toAffineMap_injective
@[ext]
theorem ext {f g : P →ᵃⁱ[𝕜] P₂} (h : ∀ x, f x = g x) : f = g :=
coeFn_injective <| funext h
end AffineIsometry
namespace LinearIsometry
variable (f : V →ₗᵢ[𝕜] V₂)
/-- Reinterpret a linear isometry as an affine isometry. -/
def toAffineIsometry : V →ᵃⁱ[𝕜] V₂ :=
{ f.toLinearMap.toAffineMap with norm_map := f.norm_map }
@[simp]
theorem coe_toAffineIsometry : ⇑(f.toAffineIsometry : V →ᵃⁱ[𝕜] V₂) = f :=
rfl
@[simp]
theorem toAffineIsometry_linearIsometry : f.toAffineIsometry.linearIsometry = f := by
ext
rfl
-- somewhat arbitrary choice of simp direction
@[simp]
theorem toAffineIsometry_toAffineMap : f.toAffineIsometry.toAffineMap = f.toLinearMap.toAffineMap :=
rfl
end LinearIsometry
namespace AffineIsometry
variable (f : P →ᵃⁱ[𝕜] P₂) (f₁ : P₁' →ᵃⁱ[𝕜] P₂)
@[simp]
theorem map_vadd (p : P) (v : V) : f (v +ᵥ p) = f.linearIsometry v +ᵥ f p :=
f.toAffineMap.map_vadd p v
@[simp]
theorem map_vsub (p1 p2 : P) : f.linearIsometry (p1 -ᵥ p2) = f p1 -ᵥ f p2 :=
f.toAffineMap.linearMap_vsub p1 p2
@[simp]
theorem dist_map (x y : P) : dist (f x) (f y) = dist x y := by
rw [dist_eq_norm_vsub V₂, dist_eq_norm_vsub V, ← map_vsub, f.linearIsometry.norm_map]
@[simp]
theorem nndist_map (x y : P) : nndist (f x) (f y) = nndist x y := by simp [nndist_dist]
@[simp]
theorem edist_map (x y : P) : edist (f x) (f y) = edist x y := by simp [edist_dist]
protected theorem isometry : Isometry f :=
f.edist_map
protected theorem injective : Injective f₁ :=
f₁.isometry.injective
@[simp]
theorem map_eq_iff {x y : P₁'} : f₁ x = f₁ y ↔ x = y :=
f₁.injective.eq_iff
theorem map_ne {x y : P₁'} (h : x ≠ y) : f₁ x ≠ f₁ y :=
f₁.injective.ne h
protected theorem lipschitz : LipschitzWith 1 f :=
f.isometry.lipschitz
protected theorem antilipschitz : AntilipschitzWith 1 f :=
f.isometry.antilipschitz
@[continuity]
protected theorem continuous : Continuous f :=
f.isometry.continuous
theorem ediam_image (s : Set P) : EMetric.diam (f '' s) = EMetric.diam s :=
f.isometry.ediam_image s
theorem ediam_range : EMetric.diam (range f) = EMetric.diam (univ : Set P) :=
f.isometry.ediam_range
theorem diam_image (s : Set P) : Metric.diam (f '' s) = Metric.diam s :=
f.isometry.diam_image s
theorem diam_range : Metric.diam (range f) = Metric.diam (univ : Set P) :=
f.isometry.diam_range
@[simp]
theorem comp_continuous_iff {α : Type*} [TopologicalSpace α] {g : α → P} :
Continuous (f ∘ g) ↔ Continuous g :=
f.isometry.comp_continuous_iff
/-- The identity affine isometry. -/
def id : P →ᵃⁱ[𝕜] P :=
⟨AffineMap.id 𝕜 P, fun _ => rfl⟩
@[simp]
theorem coe_id : ⇑(id : P →ᵃⁱ[𝕜] P) = _root_.id :=
rfl
@[simp]
theorem id_apply (x : P) : (AffineIsometry.id : P →ᵃⁱ[𝕜] P) x = x :=
rfl
@[simp]
theorem id_toAffineMap : (id.toAffineMap : P →ᵃ[𝕜] P) = AffineMap.id 𝕜 P :=
rfl
instance : Inhabited (P →ᵃⁱ[𝕜] P) :=
⟨id⟩
/-- Composition of affine isometries. -/
def comp (g : P₂ →ᵃⁱ[𝕜] P₃) (f : P →ᵃⁱ[𝕜] P₂) : P →ᵃⁱ[𝕜] P₃ :=
⟨g.toAffineMap.comp f.toAffineMap, fun _ => (g.norm_map _).trans (f.norm_map _)⟩
@[simp]
theorem coe_comp (g : P₂ →ᵃⁱ[𝕜] P₃) (f : P →ᵃⁱ[𝕜] P₂) : ⇑(g.comp f) = g ∘ f :=
rfl
@[simp]
theorem id_comp : (id : P₂ →ᵃⁱ[𝕜] P₂).comp f = f :=
ext fun _ => rfl
@[simp]
theorem comp_id : f.comp id = f :=
ext fun _ => rfl
theorem comp_assoc (f : P₃ →ᵃⁱ[𝕜] P₄) (g : P₂ →ᵃⁱ[𝕜] P₃) (h : P →ᵃⁱ[𝕜] P₂) :
(f.comp g).comp h = f.comp (g.comp h) :=
rfl
instance : Monoid (P →ᵃⁱ[𝕜] P) where
one := id
mul := comp
mul_assoc := comp_assoc
one_mul := id_comp
mul_one := comp_id
@[simp]
theorem coe_one : ⇑(1 : P →ᵃⁱ[𝕜] P) = _root_.id :=
rfl
@[simp]
theorem coe_mul (f g : P →ᵃⁱ[𝕜] P) : ⇑(f * g) = f ∘ g :=
rfl
end AffineIsometry
namespace AffineSubspace
/-- `AffineSubspace.subtype` as an `AffineIsometry`. -/
def subtypeₐᵢ (s : AffineSubspace 𝕜 P) [Nonempty s] : s →ᵃⁱ[𝕜] P :=
{ s.subtype with norm_map := s.direction.subtypeₗᵢ.norm_map }
theorem subtypeₐᵢ_linear (s : AffineSubspace 𝕜 P) [Nonempty s] :
s.subtypeₐᵢ.linear = s.direction.subtype :=
rfl
@[simp]
theorem subtypeₐᵢ_linearIsometry (s : AffineSubspace 𝕜 P) [Nonempty s] :
s.subtypeₐᵢ.linearIsometry = s.direction.subtypeₗᵢ :=
rfl
@[simp]
theorem coe_subtypeₐᵢ (s : AffineSubspace 𝕜 P) [Nonempty s] : ⇑s.subtypeₐᵢ = s.subtype :=
rfl
@[simp]
theorem subtypeₐᵢ_toAffineMap (s : AffineSubspace 𝕜 P) [Nonempty s] :
s.subtypeₐᵢ.toAffineMap = s.subtype :=
rfl
end AffineSubspace
variable (𝕜 P P₂)
/-- An affine isometric equivalence between two normed vector spaces. -/
structure AffineIsometryEquiv extends P ≃ᵃ[𝕜] P₂ where
norm_map : ∀ x, ‖linear x‖ = ‖x‖
variable {𝕜 P P₂}
-- `≃ᵃᵢ` would be more consistent with the linear isometry equiv notation, but it is uglier
notation:25 P " ≃ᵃⁱ[" 𝕜:25 "] " P₂:0 => AffineIsometryEquiv 𝕜 P P₂
namespace AffineIsometryEquiv
variable (e : P ≃ᵃⁱ[𝕜] P₂)
/-- The underlying linear equiv of an affine isometry equiv is in fact a linear isometry equiv. -/
protected def linearIsometryEquiv : V ≃ₗᵢ[𝕜] V₂ :=
{ e.linear with norm_map' := e.norm_map }
@[simp]
theorem linear_eq_linear_isometry : e.linear = e.linearIsometryEquiv.toLinearEquiv := by
ext
rfl
instance : EquivLike (P ≃ᵃⁱ[𝕜] P₂) P P₂ :=
{ coe := fun f => f.toFun
inv := fun f => f.invFun
left_inv := fun f => f.left_inv
right_inv := fun f => f.right_inv,
coe_injective' := fun f g h _ => by
cases f
cases g
congr
simpa [DFunLike.coe_injective.eq_iff] using h }
@[simp]
theorem coe_mk (e : P ≃ᵃ[𝕜] P₂) (he : ∀ x, ‖e.linear x‖ = ‖x‖) : ⇑(mk e he) = e :=
rfl
@[simp]
theorem coe_toAffineEquiv (e : P ≃ᵃⁱ[𝕜] P₂) : ⇑e.toAffineEquiv = e :=
rfl
theorem toAffineEquiv_injective : Injective (toAffineEquiv : (P ≃ᵃⁱ[𝕜] P₂) → P ≃ᵃ[𝕜] P₂)
| ⟨_, _⟩, ⟨_, _⟩, rfl => rfl
@[ext]
theorem ext {e e' : P ≃ᵃⁱ[𝕜] P₂} (h : ∀ x, e x = e' x) : e = e' :=
toAffineEquiv_injective <| AffineEquiv.ext h
/-- Reinterpret an `AffineIsometryEquiv` as an `AffineIsometry`. -/
def toAffineIsometry : P →ᵃⁱ[𝕜] P₂ :=
⟨e.1.toAffineMap, e.2⟩
@[simp]
theorem coe_toAffineIsometry : ⇑e.toAffineIsometry = e :=
rfl
/-- Construct an affine isometry equivalence by verifying the relation between the map and its
linear part at one base point. Namely, this function takes a map `e : P₁ → P₂`, a linear isometry
equivalence `e' : V₁ ≃ᵢₗ[k] V₂`, and a point `p` such that for any other point `p'` we have
`e p' = e' (p' -ᵥ p) +ᵥ e p`. -/
def mk' (e : P₁ → P₂) (e' : V₁ ≃ₗᵢ[𝕜] V₂) (p : P₁) (h : ∀ p' : P₁, e p' = e' (p' -ᵥ p) +ᵥ e p) :
P₁ ≃ᵃⁱ[𝕜] P₂ :=
{ AffineEquiv.mk' e e'.toLinearEquiv p h with norm_map := e'.norm_map }
@[simp]
theorem coe_mk' (e : P₁ → P₂) (e' : V₁ ≃ₗᵢ[𝕜] V₂) (p h) : ⇑(mk' e e' p h) = e :=
rfl
@[simp]
theorem linearIsometryEquiv_mk' (e : P₁ → P₂) (e' : V₁ ≃ₗᵢ[𝕜] V₂) (p h) :
(mk' e e' p h).linearIsometryEquiv = e' := by
ext
rfl
end AffineIsometryEquiv
namespace LinearIsometryEquiv
variable (e : V ≃ₗᵢ[𝕜] V₂)
/-- Reinterpret a linear isometry equiv as an affine isometry equiv. -/
def toAffineIsometryEquiv : V ≃ᵃⁱ[𝕜] V₂ :=
{ e.toLinearEquiv.toAffineEquiv with norm_map := e.norm_map }
@[simp]
theorem coe_toAffineIsometryEquiv : ⇑(e.toAffineIsometryEquiv : V ≃ᵃⁱ[𝕜] V₂) = e := by
rfl
@[simp]
theorem toAffineIsometryEquiv_linearIsometryEquiv :
e.toAffineIsometryEquiv.linearIsometryEquiv = e := by
ext
rfl
-- somewhat arbitrary choice of simp direction
@[simp]
theorem toAffineIsometryEquiv_toAffineEquiv :
e.toAffineIsometryEquiv.toAffineEquiv = e.toLinearEquiv.toAffineEquiv :=
rfl
-- somewhat arbitrary choice of simp direction
@[simp]
theorem toAffineIsometryEquiv_toAffineIsometry :
e.toAffineIsometryEquiv.toAffineIsometry = e.toLinearIsometry.toAffineIsometry :=
rfl
end LinearIsometryEquiv
namespace AffineIsometryEquiv
variable (e : P ≃ᵃⁱ[𝕜] P₂)
protected theorem isometry : Isometry e :=
e.toAffineIsometry.isometry
/-- Reinterpret an `AffineIsometryEquiv` as an `IsometryEquiv`. -/
def toIsometryEquiv : P ≃ᵢ P₂ :=
⟨e.toAffineEquiv.toEquiv, e.isometry⟩
@[simp]
theorem coe_toIsometryEquiv : ⇑e.toIsometryEquiv = e :=
rfl
theorem range_eq_univ (e : P ≃ᵃⁱ[𝕜] P₂) : Set.range e = Set.univ := by
rw [← coe_toIsometryEquiv]
exact IsometryEquiv.range_eq_univ _
/-- Reinterpret an `AffineIsometryEquiv` as a `Homeomorph`. -/
def toHomeomorph : P ≃ₜ P₂ :=
e.toIsometryEquiv.toHomeomorph
@[simp]
theorem coe_toHomeomorph : ⇑e.toHomeomorph = e :=
rfl
protected theorem continuous : Continuous e :=
e.isometry.continuous
protected theorem continuousAt {x} : ContinuousAt e x :=
e.continuous.continuousAt
protected theorem continuousOn {s} : ContinuousOn e s :=
e.continuous.continuousOn
protected theorem continuousWithinAt {s x} : ContinuousWithinAt e s x :=
e.continuous.continuousWithinAt
variable (𝕜 P)
/-- Identity map as an `AffineIsometryEquiv`. -/
def refl : P ≃ᵃⁱ[𝕜] P :=
⟨AffineEquiv.refl 𝕜 P, fun _ => rfl⟩
variable {𝕜 P}
instance : Inhabited (P ≃ᵃⁱ[𝕜] P) :=
⟨refl 𝕜 P⟩
@[simp]
theorem coe_refl : ⇑(refl 𝕜 P) = id :=
rfl
@[simp]
theorem toAffineEquiv_refl : (refl 𝕜 P).toAffineEquiv = AffineEquiv.refl 𝕜 P :=
rfl
@[simp]
theorem toIsometryEquiv_refl : (refl 𝕜 P).toIsometryEquiv = IsometryEquiv.refl P :=
rfl
@[simp]
theorem toHomeomorph_refl : (refl 𝕜 P).toHomeomorph = Homeomorph.refl P :=
rfl
/-- The inverse `AffineIsometryEquiv`. -/
def symm : P₂ ≃ᵃⁱ[𝕜] P :=
{ e.toAffineEquiv.symm with norm_map := e.linearIsometryEquiv.symm.norm_map }
@[simp]
theorem apply_symm_apply (x : P₂) : e (e.symm x) = x :=
e.toAffineEquiv.apply_symm_apply x
@[simp]
theorem symm_apply_apply (x : P) : e.symm (e x) = x :=
e.toAffineEquiv.symm_apply_apply x
@[simp]
theorem symm_symm : e.symm.symm = e :=
ext fun _ => rfl
@[simp]
theorem toAffineEquiv_symm : e.toAffineEquiv.symm = e.symm.toAffineEquiv :=
rfl
@[simp]
theorem toIsometryEquiv_symm : e.toIsometryEquiv.symm = e.symm.toIsometryEquiv :=
rfl
@[simp]
theorem toHomeomorph_symm : e.toHomeomorph.symm = e.symm.toHomeomorph :=
rfl
/-- Composition of `AffineIsometryEquiv`s as an `AffineIsometryEquiv`. -/
def trans (e' : P₂ ≃ᵃⁱ[𝕜] P₃) : P ≃ᵃⁱ[𝕜] P₃ :=
⟨e.toAffineEquiv.trans e'.toAffineEquiv, fun _ => (e'.norm_map _).trans (e.norm_map _)⟩
@[simp]
theorem coe_trans (e₁ : P ≃ᵃⁱ[𝕜] P₂) (e₂ : P₂ ≃ᵃⁱ[𝕜] P₃) : ⇑(e₁.trans e₂) = e₂ ∘ e₁ :=
rfl
@[simp]
theorem trans_refl : e.trans (refl 𝕜 P₂) = e :=
ext fun _ => rfl
@[simp]
theorem refl_trans : (refl 𝕜 P).trans e = e :=
ext fun _ => rfl
@[simp]
theorem self_trans_symm : e.trans e.symm = refl 𝕜 P :=
ext e.symm_apply_apply
@[simp]
theorem symm_trans_self : e.symm.trans e = refl 𝕜 P₂ :=
ext e.apply_symm_apply
@[simp]
theorem coe_symm_trans (e₁ : P ≃ᵃⁱ[𝕜] P₂) (e₂ : P₂ ≃ᵃⁱ[𝕜] P₃) :
⇑(e₁.trans e₂).symm = e₁.symm ∘ e₂.symm :=
rfl
theorem trans_assoc (ePP₂ : P ≃ᵃⁱ[𝕜] P₂) (eP₂G : P₂ ≃ᵃⁱ[𝕜] P₃) (eGG' : P₃ ≃ᵃⁱ[𝕜] P₄) :
ePP₂.trans (eP₂G.trans eGG') = (ePP₂.trans eP₂G).trans eGG' :=
rfl
/-- The group of affine isometries of a `NormedAddTorsor`, `P`. -/
instance instGroup : Group (P ≃ᵃⁱ[𝕜] P) where
mul e₁ e₂ := e₂.trans e₁
one := refl _ _
inv := symm
one_mul := trans_refl
mul_one := refl_trans
mul_assoc _ _ _ := trans_assoc _ _ _
mul_left_inv := self_trans_symm
@[simp]
theorem coe_one : ⇑(1 : P ≃ᵃⁱ[𝕜] P) = id :=
rfl
@[simp]
theorem coe_mul (e e' : P ≃ᵃⁱ[𝕜] P) : ⇑(e * e') = e ∘ e' :=
rfl
@[simp]
theorem coe_inv (e : P ≃ᵃⁱ[𝕜] P) : ⇑e⁻¹ = e.symm :=
rfl
@[simp]
theorem map_vadd (p : P) (v : V) : e (v +ᵥ p) = e.linearIsometryEquiv v +ᵥ e p :=
e.toAffineIsometry.map_vadd p v
@[simp]
theorem map_vsub (p1 p2 : P) : e.linearIsometryEquiv (p1 -ᵥ p2) = e p1 -ᵥ e p2 :=
e.toAffineIsometry.map_vsub p1 p2
@[simp]
theorem dist_map (x y : P) : dist (e x) (e y) = dist x y :=
e.toAffineIsometry.dist_map x y
@[simp]
theorem edist_map (x y : P) : edist (e x) (e y) = edist x y :=
e.toAffineIsometry.edist_map x y
protected theorem bijective : Bijective e :=
e.1.bijective
protected theorem injective : Injective e :=
e.1.injective
protected theorem surjective : Surjective e :=
e.1.surjective
-- @[simp] Porting note (#10618): simp can prove this
theorem map_eq_iff {x y : P} : e x = e y ↔ x = y :=
e.injective.eq_iff
theorem map_ne {x y : P} (h : x ≠ y) : e x ≠ e y :=
e.injective.ne h
protected theorem lipschitz : LipschitzWith 1 e :=
e.isometry.lipschitz
protected theorem antilipschitz : AntilipschitzWith 1 e :=
e.isometry.antilipschitz
@[simp]
theorem ediam_image (s : Set P) : EMetric.diam (e '' s) = EMetric.diam s :=
e.isometry.ediam_image s
@[simp]
theorem diam_image (s : Set P) : Metric.diam (e '' s) = Metric.diam s :=
e.isometry.diam_image s
variable {α : Type*} [TopologicalSpace α]
@[simp]
theorem comp_continuousOn_iff {f : α → P} {s : Set α} : ContinuousOn (e ∘ f) s ↔ ContinuousOn f s :=
e.isometry.comp_continuousOn_iff
@[simp]
theorem comp_continuous_iff {f : α → P} : Continuous (e ∘ f) ↔ Continuous f :=
e.isometry.comp_continuous_iff
section Constructions
variable (𝕜)
/-- The map `v ↦ v +ᵥ p` as an affine isometric equivalence between `V` and `P`. -/
def vaddConst (p : P) : V ≃ᵃⁱ[𝕜] P :=
{ AffineEquiv.vaddConst 𝕜 p with norm_map := fun _ => rfl }
variable {𝕜}
@[simp]
theorem coe_vaddConst (p : P) : ⇑(vaddConst 𝕜 p) = fun v => v +ᵥ p :=
rfl
@[simp]
theorem coe_vaddConst' (p : P) : ↑(AffineEquiv.vaddConst 𝕜 p) = fun v => v +ᵥ p :=
rfl
@[simp]
theorem coe_vaddConst_symm (p : P) : ⇑(vaddConst 𝕜 p).symm = fun p' => p' -ᵥ p :=
rfl
@[simp]
theorem vaddConst_toAffineEquiv (p : P) :
(vaddConst 𝕜 p).toAffineEquiv = AffineEquiv.vaddConst 𝕜 p :=
rfl
variable (𝕜)
/-- `p' ↦ p -ᵥ p'` as an affine isometric equivalence. -/
def constVSub (p : P) : P ≃ᵃⁱ[𝕜] V :=
{ AffineEquiv.constVSub 𝕜 p with norm_map := norm_neg }
variable {𝕜}
@[simp]
theorem coe_constVSub (p : P) : ⇑(constVSub 𝕜 p) = (p -ᵥ ·) :=
rfl
@[simp]
theorem symm_constVSub (p : P) :
(constVSub 𝕜 p).symm =
(LinearIsometryEquiv.neg 𝕜).toAffineIsometryEquiv.trans (vaddConst 𝕜 p) := by
ext
rfl
variable (𝕜 P)
/-- Translation by `v` (that is, the map `p ↦ v +ᵥ p`) as an affine isometric automorphism of `P`.
-/
def constVAdd (v : V) : P ≃ᵃⁱ[𝕜] P :=
{ AffineEquiv.constVAdd 𝕜 P v with norm_map := fun _ => rfl }
variable {𝕜 P}
@[simp]
theorem coe_constVAdd (v : V) : ⇑(constVAdd 𝕜 P v : P ≃ᵃⁱ[𝕜] P) = (v +ᵥ ·) :=
rfl
@[simp]
theorem constVAdd_zero : constVAdd 𝕜 P (0 : V) = refl 𝕜 P :=
ext <| zero_vadd V
/-- The map `g` from `V` to `V₂` corresponding to a map `f` from `P` to `P₂`, at a base point `p`,
is an isometry if `f` is one. -/
theorem vadd_vsub {f : P → P₂} (hf : Isometry f) {p : P} {g : V → V₂}
(hg : ∀ v, g v = f (v +ᵥ p) -ᵥ f p) : Isometry g := by
convert (vaddConst 𝕜 (f p)).symm.isometry.comp (hf.comp (vaddConst 𝕜 p).isometry)
exact funext hg
variable (𝕜)
/-- Point reflection in `x` as an affine isometric automorphism. -/
def pointReflection (x : P) : P ≃ᵃⁱ[𝕜] P :=
(constVSub 𝕜 x).trans (vaddConst 𝕜 x)
variable {𝕜}
theorem pointReflection_apply (x y : P) : (pointReflection 𝕜 x) y = x -ᵥ y +ᵥ x :=
rfl
@[simp]
theorem pointReflection_toAffineEquiv (x : P) :
(pointReflection 𝕜 x).toAffineEquiv = AffineEquiv.pointReflection 𝕜 x :=
rfl
@[simp]
theorem pointReflection_self (x : P) : pointReflection 𝕜 x x = x :=
AffineEquiv.pointReflection_self 𝕜 x
theorem pointReflection_involutive (x : P) : Function.Involutive (pointReflection 𝕜 x) :=
Equiv.pointReflection_involutive x
@[simp]
theorem pointReflection_symm (x : P) : (pointReflection 𝕜 x).symm = pointReflection 𝕜 x :=
toAffineEquiv_injective <| AffineEquiv.pointReflection_symm 𝕜 x
@[simp]
theorem dist_pointReflection_fixed (x y : P) : dist (pointReflection 𝕜 x y) x = dist y x := by
rw [← (pointReflection 𝕜 x).dist_map y x, pointReflection_self]
set_option linter.deprecated false in
theorem dist_pointReflection_self' (x y : P) :
dist (pointReflection 𝕜 x y) y = ‖2 • (x -ᵥ y)‖ := by
rw [pointReflection_apply, dist_eq_norm_vsub V, vadd_vsub_assoc, two_nsmul]
set_option linter.deprecated false in
theorem dist_pointReflection_self (x y : P) :
dist (pointReflection 𝕜 x y) y = ‖(2 : 𝕜)‖ * dist x y := by
rw [dist_pointReflection_self', ← two_smul' 𝕜 (x -ᵥ y), norm_smul, ← dist_eq_norm_vsub V]
theorem pointReflection_fixed_iff [Invertible (2 : 𝕜)] {x y : P} :
pointReflection 𝕜 x y = y ↔ y = x :=
AffineEquiv.pointReflection_fixed_iff_of_module 𝕜
variable [NormedSpace ℝ V]
theorem dist_pointReflection_self_real (x y : P) :
dist (pointReflection ℝ x y) y = 2 * dist x y := by
rw [dist_pointReflection_self, Real.norm_two]
@[simp]
theorem pointReflection_midpoint_left (x y : P) : pointReflection ℝ (midpoint ℝ x y) x = y :=
AffineEquiv.pointReflection_midpoint_left x y
@[simp]
theorem pointReflection_midpoint_right (x y : P) : pointReflection ℝ (midpoint ℝ x y) y = x :=
AffineEquiv.pointReflection_midpoint_right x y
end Constructions
end AffineIsometryEquiv
/-- If `f` is an affine map, then its linear part is continuous iff `f` is continuous. -/
theorem AffineMap.continuous_linear_iff {f : P →ᵃ[𝕜] P₂} : Continuous f.linear ↔ Continuous f := by
inhabit P
have :
(f.linear : V → V₂) =
(AffineIsometryEquiv.vaddConst 𝕜 <| f default).toHomeomorph.symm ∘
f ∘ (AffineIsometryEquiv.vaddConst 𝕜 default).toHomeomorph := by
ext v
simp
rw [this]
simp only [Homeomorph.comp_continuous_iff, Homeomorph.comp_continuous_iff']
/-- If `f` is an affine map, then its linear part is an open map iff `f` is an open map. -/
theorem AffineMap.isOpenMap_linear_iff {f : P →ᵃ[𝕜] P₂} : IsOpenMap f.linear ↔ IsOpenMap f := by
inhabit P
have :
(f.linear : V → V₂) =
(AffineIsometryEquiv.vaddConst 𝕜 <| f default).toHomeomorph.symm ∘
f ∘ (AffineIsometryEquiv.vaddConst 𝕜 default).toHomeomorph := by
ext v
simp
rw [this]
simp only [Homeomorph.comp_isOpenMap_iff, Homeomorph.comp_isOpenMap_iff']
attribute [local instance] AffineSubspace.nonempty_map -- Porting note: removed `fails_quickly`
namespace AffineSubspace
/-- An affine subspace is isomorphic to its image under an injective affine map.
This is the affine version of `Submodule.equivMapOfInjective`.
-/
@[simps linear, simps! toFun]
noncomputable def equivMapOfInjective (E : AffineSubspace 𝕜 P₁) [Nonempty E] (φ : P₁ →ᵃ[𝕜] P₂)
(hφ : Function.Injective φ) : E ≃ᵃ[𝕜] E.map φ :=
{ Equiv.Set.image _ (E : Set P₁) hφ with
linear :=
(E.direction.equivMapOfInjective φ.linear (φ.linear_injective_iff.mpr hφ)).trans
(LinearEquiv.ofEq _ _ (AffineSubspace.map_direction _ _).symm)
map_vadd' := fun p v => Subtype.ext <| φ.map_vadd p v }
/-- Restricts an affine isometry to an affine isometry equivalence between a nonempty affine
subspace `E` and its image.
This is an isometry version of `AffineSubspace.equivMap`, having a stronger premise and a stronger
conclusion.
-/
noncomputable def isometryEquivMap (φ : P₁' →ᵃⁱ[𝕜] P₂) (E : AffineSubspace 𝕜 P₁') [Nonempty E] :
E ≃ᵃⁱ[𝕜] E.map φ.toAffineMap :=
⟨E.equivMapOfInjective φ.toAffineMap φ.injective, fun _ => φ.norm_map _⟩
@[simp]
theorem isometryEquivMap.apply_symm_apply {E : AffineSubspace 𝕜 P₁'} [Nonempty E]
{φ : P₁' →ᵃⁱ[𝕜] P₂} (x : E.map φ.toAffineMap) : φ ((E.isometryEquivMap φ).symm x) = x :=
congr_arg Subtype.val <| (E.isometryEquivMap φ).apply_symm_apply _
@[simp]
theorem isometryEquivMap.coe_apply (φ : P₁' →ᵃⁱ[𝕜] P₂) (E : AffineSubspace 𝕜 P₁') [Nonempty E]
(g : E) : ↑(E.isometryEquivMap φ g) = φ g :=
rfl
@[simp]
theorem isometryEquivMap.toAffineMap_eq (φ : P₁' →ᵃⁱ[𝕜] P₂) (E : AffineSubspace 𝕜 P₁')
[Nonempty E] :
(E.isometryEquivMap φ).toAffineMap = E.equivMapOfInjective φ.toAffineMap φ.injective :=
rfl
end AffineSubspace
|
Analysis\NormedSpace\BallAction.lean | /-
Copyright (c) 2022 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov, Heather Macbeth
-/
import Mathlib.Analysis.Normed.Field.UnitBall
import Mathlib.Analysis.Normed.Module.Basic
/-!
# 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 x := Subtype.ext <| one_smul 𝕜 _
mul_smul c₁ c₂ x := 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 x := Subtype.ext <| one_smul 𝕜 _
mul_smul c₁ c₂ x := 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 x := Subtype.ext <| one_smul _ _
mul_smul c₁ c₂ x := 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 𝕜]
theorem ne_neg_of_mem_sphere {r : ℝ} (hr : r ≠ 0) (x : sphere (0 : E) r) : x ≠ -x := fun h =>
ne_zero_of_mem_sphere hr x ((self_eq_neg 𝕜 _).mp (by (conv_lhs => rw [h]); rfl))
theorem ne_neg_of_mem_unit_sphere (x : sphere (0 : E) 1) : x ≠ -x :=
ne_neg_of_mem_sphere 𝕜 one_ne_zero x
|
Analysis\NormedSpace\ConformalLinearMap.lean | /-
Copyright (c) 2021 Yourong Zang. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yourong Zang
-/
import Mathlib.Analysis.Normed.Module.Basic
import Mathlib.Analysis.Normed.Operator.LinearIsometry
/-!
# Conformal Linear Maps
A continuous linear map between `R`-normed spaces `X` and `Y` `IsConformalMap` if it is
a nonzero multiple of a linear isometry.
## Main definitions
* `IsConformalMap`: the main definition of conformal linear maps
## Main results
* The conformality of the composition of two conformal linear maps, the identity map
and multiplications by nonzero constants as continuous linear maps
* `isConformalMap_of_subsingleton`: all continuous linear maps on singleton spaces are conformal
See `Analysis.InnerProductSpace.ConformalLinearMap` for
* `isConformalMap_iff`: a map between inner product spaces is conformal
iff it preserves inner products up to a fixed scalar factor.
## Tags
conformal
## Warning
The definition of conformality in this file does NOT require the maps to be orientation-preserving.
-/
noncomputable section
open Function LinearIsometry ContinuousLinearMap
/-- A continuous linear map `f'` is said to be conformal if it's
a nonzero multiple of a linear isometry. -/
def IsConformalMap {R : Type*} {X Y : Type*} [NormedField R] [SeminormedAddCommGroup X]
[SeminormedAddCommGroup Y] [NormedSpace R X] [NormedSpace R Y] (f' : X →L[R] Y) :=
∃ c ≠ (0 : R), ∃ li : X →ₗᵢ[R] Y, f' = c • li.toContinuousLinearMap
variable {R M N G M' : Type*} [NormedField R] [SeminormedAddCommGroup M] [SeminormedAddCommGroup N]
[SeminormedAddCommGroup G] [NormedSpace R M] [NormedSpace R N] [NormedSpace R G]
[NormedAddCommGroup M'] [NormedSpace R M'] {f : M →L[R] N} {g : N →L[R] G} {c : R}
theorem isConformalMap_id : IsConformalMap (id R M) :=
⟨1, one_ne_zero, id, by simp⟩
theorem IsConformalMap.smul (hf : IsConformalMap f) {c : R} (hc : c ≠ 0) :
IsConformalMap (c • f) := by
rcases hf with ⟨c', hc', li, rfl⟩
exact ⟨c * c', mul_ne_zero hc hc', li, smul_smul _ _ _⟩
theorem isConformalMap_const_smul (hc : c ≠ 0) : IsConformalMap (c • id R M) :=
isConformalMap_id.smul hc
protected theorem LinearIsometry.isConformalMap (f' : M →ₗᵢ[R] N) :
IsConformalMap f'.toContinuousLinearMap :=
⟨1, one_ne_zero, f', (one_smul _ _).symm⟩
@[nontriviality]
theorem isConformalMap_of_subsingleton [Subsingleton M] (f' : M →L[R] N) : IsConformalMap f' :=
⟨1, one_ne_zero, ⟨0, fun x => by simp [Subsingleton.elim x 0]⟩, Subsingleton.elim _ _⟩
namespace IsConformalMap
theorem comp (hg : IsConformalMap g) (hf : IsConformalMap f) : IsConformalMap (g.comp f) := by
rcases hf with ⟨cf, hcf, lif, rfl⟩
rcases hg with ⟨cg, hcg, lig, rfl⟩
refine ⟨cg * cf, mul_ne_zero hcg hcf, lig.comp lif, ?_⟩
rw [smul_comp, comp_smul, mul_smul]
rfl
protected theorem injective {f : M' →L[R] N} (h : IsConformalMap f) : Function.Injective f := by
rcases h with ⟨c, hc, li, rfl⟩
exact (smul_right_injective _ hc).comp li.injective
theorem ne_zero [Nontrivial M'] {f' : M' →L[R] N} (hf' : IsConformalMap f') : f' ≠ 0 := by
rintro rfl
rcases exists_ne (0 : M') with ⟨a, ha⟩
exact ha (hf'.injective rfl)
end IsConformalMap
|
Analysis\NormedSpace\Connected.lean | /-
Copyright (c) 2023 Sébastien Gouëzel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sébastien Gouëzel
-/
import Mathlib.Analysis.Convex.Topology
import Mathlib.LinearAlgebra.Dimension.DivisionRing
import Mathlib.Topology.Algebra.Module.Cardinality
/-!
# Connectedness of subsets of vector spaces
We show several results related to the (path)-connectedness of subsets of real vector spaces:
* `Set.Countable.isPathConnected_compl_of_one_lt_rank` asserts that the complement of a countable
set is path-connected in a space of dimension `> 1`.
* `isPathConnected_compl_singleton_of_one_lt_rank` is the special case of the complement of a
singleton.
* `isPathConnected_sphere` shows that any sphere is path-connected in dimension `> 1`.
* `isPathConnected_compl_of_one_lt_codim` shows that the complement of a subspace
of codimension `> 1` is path-connected.
Statements with connectedness instead of path-connectedness are also given.
-/
open Convex Set Metric
section TopologicalVectorSpace
variable {E : Type*} [AddCommGroup E] [Module ℝ E]
[TopologicalSpace E] [ContinuousAdd E] [ContinuousSMul ℝ E]
/-- In a real vector space of dimension `> 1`, the complement of any countable set is path
connected. -/
theorem Set.Countable.isPathConnected_compl_of_one_lt_rank
(h : 1 < Module.rank ℝ E) {s : Set E} (hs : s.Countable) :
IsPathConnected sᶜ := by
have : Nontrivial E := (rank_pos_iff_nontrivial (R := ℝ)).1 (zero_lt_one.trans h)
-- the set `sᶜ` is dense, therefore nonempty. Pick `a ∈ sᶜ`. We have to show that any
-- `b ∈ sᶜ` can be joined to `a`.
obtain ⟨a, ha⟩ : sᶜ.Nonempty := (hs.dense_compl ℝ).nonempty
refine ⟨a, ha, ?_⟩
intro b hb
rcases eq_or_ne a b with rfl|hab
· exact JoinedIn.refl ha
/- Assume `b ≠ a`. Write `a = c - x` and `b = c + x` for some nonzero `x`. Choose `y` which
is linearly independent from `x`. Then the segments joining `a = c - x` to `c + ty` are pairwise
disjoint for varying `t` (except for the endpoint `a`) so only countably many of them can
intersect `s`. In the same way, there are countably many `t`s for which the segment
from `b = c + x` to `c + ty` intersects `s`. Choosing `t` outside of these countable exceptions,
one gets a path in the complement of `s` from `a` to `z = c + ty` and then to `b`.
-/
let c := (2 : ℝ)⁻¹ • (a + b)
let x := (2 : ℝ)⁻¹ • (b - a)
have Ia : c - x = a := by
simp only [c, x, smul_add, smul_sub]
abel_nf
simp [← Int.cast_smul_eq_zsmul ℝ 2]
have Ib : c + x = b := by
simp only [c, x, smul_add, smul_sub]
abel_nf
simp [← Int.cast_smul_eq_zsmul ℝ 2]
have x_ne_zero : x ≠ 0 := by simpa [x] using sub_ne_zero.2 hab.symm
obtain ⟨y, hy⟩ : ∃ y, LinearIndependent ℝ ![x, y] :=
exists_linearIndependent_pair_of_one_lt_rank h x_ne_zero
have A : Set.Countable {t : ℝ | ([c + x -[ℝ] c + t • y] ∩ s).Nonempty} := by
apply countable_setOf_nonempty_of_disjoint _ (fun t ↦ inter_subset_right) hs
intro t t' htt'
apply disjoint_iff_inter_eq_empty.2
have N : {c + x} ∩ s = ∅ := by
simpa only [singleton_inter_eq_empty, mem_compl_iff, Ib] using hb
rw [inter_assoc, inter_comm s, inter_assoc, inter_self, ← inter_assoc, ← subset_empty_iff, ← N]
apply inter_subset_inter_left
apply Eq.subset
apply segment_inter_eq_endpoint_of_linearIndependent_of_ne hy htt'.symm
have B : Set.Countable {t : ℝ | ([c - x -[ℝ] c + t • y] ∩ s).Nonempty} := by
apply countable_setOf_nonempty_of_disjoint _ (fun t ↦ inter_subset_right) hs
intro t t' htt'
apply disjoint_iff_inter_eq_empty.2
have N : {c - x} ∩ s = ∅ := by
simpa only [singleton_inter_eq_empty, mem_compl_iff, Ia] using ha
rw [inter_assoc, inter_comm s, inter_assoc, inter_self, ← inter_assoc, ← subset_empty_iff, ← N]
apply inter_subset_inter_left
rw [sub_eq_add_neg _ x]
apply Eq.subset
apply segment_inter_eq_endpoint_of_linearIndependent_of_ne _ htt'.symm
convert hy.units_smul ![-1, 1]
simp [← List.ofFn_inj]
obtain ⟨t, ht⟩ : Set.Nonempty ({t : ℝ | ([c + x -[ℝ] c + t • y] ∩ s).Nonempty}
∪ {t : ℝ | ([c - x -[ℝ] c + t • y] ∩ s).Nonempty})ᶜ := ((A.union B).dense_compl ℝ).nonempty
let z := c + t • y
simp only [compl_union, mem_inter_iff, mem_compl_iff, mem_setOf_eq, not_nonempty_iff_eq_empty]
at ht
have JA : JoinedIn sᶜ a z := by
apply JoinedIn.of_segment_subset
rw [subset_compl_iff_disjoint_right, disjoint_iff_inter_eq_empty]
convert ht.2
exact Ia.symm
have JB : JoinedIn sᶜ b z := by
apply JoinedIn.of_segment_subset
rw [subset_compl_iff_disjoint_right, disjoint_iff_inter_eq_empty]
convert ht.1
exact Ib.symm
exact JA.trans JB.symm
/-- In a real vector space of dimension `> 1`, the complement of any countable set is
connected. -/
theorem Set.Countable.isConnected_compl_of_one_lt_rank (h : 1 < Module.rank ℝ E) {s : Set E}
(hs : s.Countable) : IsConnected sᶜ :=
(hs.isPathConnected_compl_of_one_lt_rank h).isConnected
/-- In a real vector space of dimension `> 1`, the complement of any singleton is path-connected. -/
theorem isPathConnected_compl_singleton_of_one_lt_rank (h : 1 < Module.rank ℝ E) (x : E) :
IsPathConnected {x}ᶜ :=
Set.Countable.isPathConnected_compl_of_one_lt_rank h (countable_singleton x)
/-- In a real vector space of dimension `> 1`, the complement of a singleton is connected. -/
theorem isConnected_compl_singleton_of_one_lt_rank (h : 1 < Module.rank ℝ E) (x : E) :
IsConnected {x}ᶜ :=
(isPathConnected_compl_singleton_of_one_lt_rank h x).isConnected
end TopologicalVectorSpace
section NormedSpace
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
/-- In a real vector space of dimension `> 1`, any sphere of nonnegative radius is
path connected. -/
theorem isPathConnected_sphere (h : 1 < Module.rank ℝ E) (x : E) {r : ℝ} (hr : 0 ≤ r) :
IsPathConnected (sphere x r) := by
/- when `r > 0`, we write the sphere as the image of `{0}ᶜ` under the map
`y ↦ x + (r * ‖y‖⁻¹) • y`. Since the image under a continuous map of a path connected set
is path connected, this concludes the proof. -/
rcases hr.eq_or_lt with rfl|rpos
· simpa using isPathConnected_singleton x
let f : E → E := fun y ↦ x + (r * ‖y‖⁻¹) • y
have A : ContinuousOn f {0}ᶜ := by
intro y hy
apply (continuousAt_const.add _).continuousWithinAt
apply (continuousAt_const.mul (ContinuousAt.inv₀ continuousAt_id.norm ?_)).smul continuousAt_id
simpa using hy
have B : IsPathConnected ({0}ᶜ : Set E) := isPathConnected_compl_singleton_of_one_lt_rank h 0
have C : IsPathConnected (f '' {0}ᶜ) := B.image' A
have : f '' {0}ᶜ = sphere x r := by
apply Subset.antisymm
· rintro - ⟨y, hy, rfl⟩
have : ‖y‖ ≠ 0 := by simpa using hy
simp [f, norm_smul, abs_of_nonneg hr, mul_assoc, inv_mul_cancel this]
· intro y hy
refine ⟨y - x, ?_, ?_⟩
· intro H
simp only [mem_singleton_iff, sub_eq_zero] at H
simp only [H, mem_sphere_iff_norm, sub_self, norm_zero] at hy
exact rpos.ne hy
· simp [f, mem_sphere_iff_norm.1 hy, mul_inv_cancel rpos.ne']
rwa [this] at C
/-- In a real vector space of dimension `> 1`, any sphere of nonnegative radius is connected. -/
theorem isConnected_sphere (h : 1 < Module.rank ℝ E) (x : E) {r : ℝ} (hr : 0 ≤ r) :
IsConnected (sphere x r) :=
(isPathConnected_sphere h x hr).isConnected
/-- In a real vector space of dimension `> 1`, any sphere is preconnected. -/
theorem isPreconnected_sphere (h : 1 < Module.rank ℝ E) (x : E) (r : ℝ) :
IsPreconnected (sphere x r) := by
rcases le_or_lt 0 r with hr|hr
· exact (isConnected_sphere h x hr).isPreconnected
· simpa [hr] using isPreconnected_empty
end NormedSpace
section
variable {F : Type*} [AddCommGroup F] [Module ℝ F] [TopologicalSpace F]
[TopologicalAddGroup F] [ContinuousSMul ℝ F]
/-- Let `E` be a linear subspace in a real vector space.
If `E` has codimension at least two, its complement is path-connected. -/
theorem isPathConnected_compl_of_one_lt_codim {E : Submodule ℝ F}
(hcodim : 1 < Module.rank ℝ (F ⧸ E)) : IsPathConnected (Eᶜ : Set F) := by
rcases E.exists_isCompl with ⟨E', hE'⟩
refine isPathConnected_compl_of_isPathConnected_compl_zero hE'.symm
(isPathConnected_compl_singleton_of_one_lt_rank ?_ 0)
rwa [← (E.quotientEquivOfIsCompl E' hE').rank_eq]
/-- Let `E` be a linear subspace in a real vector space.
If `E` has codimension at least two, its complement is connected. -/
theorem isConnected_compl_of_one_lt_codim {E : Submodule ℝ F} (hcodim : 1 < Module.rank ℝ (F ⧸ E)) :
IsConnected (Eᶜ : Set F) :=
(isPathConnected_compl_of_one_lt_codim hcodim).isConnected
theorem Submodule.connectedComponentIn_eq_self_of_one_lt_codim (E : Submodule ℝ F)
(hcodim : 1 < Module.rank ℝ (F ⧸ E)) {x : F} (hx : x ∉ E) :
connectedComponentIn ((E : Set F)ᶜ) x = (E : Set F)ᶜ :=
(isConnected_compl_of_one_lt_codim hcodim).2.connectedComponentIn hx
end
|
Analysis\NormedSpace\ContinuousAffineMap.lean | /-
Copyright (c) 2021 Oliver Nash. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Oliver Nash
-/
import Mathlib.Analysis.NormedSpace.AffineIsometry
import Mathlib.Topology.Algebra.ContinuousAffineMap
import Mathlib.Analysis.NormedSpace.OperatorNorm.NormedSpace
/-!
# Continuous affine maps between normed spaces.
This file develops the theory of continuous affine maps between affine spaces modelled on normed
spaces.
In the particular case that the affine spaces are just normed vector spaces `V`, `W`, we define a
norm on the space of continuous affine maps by defining the norm of `f : V →ᴬ[𝕜] W` to be
`‖f‖ = max ‖f 0‖ ‖f.cont_linear‖`. This is chosen so that we have a linear isometry:
`(V →ᴬ[𝕜] W) ≃ₗᵢ[𝕜] W × (V →L[𝕜] W)`.
The abstract picture is that for an affine space `P` modelled on a vector space `V`, together with
a vector space `W`, there is an exact sequence of `𝕜`-modules: `0 → C → A → L → 0` where `C`, `A`
are the spaces of constant and affine maps `P → W` and `L` is the space of linear maps `V → W`.
Any choice of a base point in `P` corresponds to a splitting of this sequence so in particular if we
take `P = V`, using `0 : V` as the base point provides a splitting, and we prove this is an
isometric decomposition.
On the other hand, choosing a base point breaks the affine invariance so the norm fails to be
submultiplicative: for a composition of maps, we have only `‖f.comp g‖ ≤ ‖f‖ * ‖g‖ + ‖f 0‖`.
## Main definitions:
* `ContinuousAffineMap.contLinear`
* `ContinuousAffineMap.hasNorm`
* `ContinuousAffineMap.norm_comp_le`
* `ContinuousAffineMap.toConstProdContinuousLinearMap`
-/
namespace ContinuousAffineMap
variable {𝕜 R V W W₂ P Q Q₂ : Type*}
variable [NormedAddCommGroup V] [MetricSpace P] [NormedAddTorsor V P]
variable [NormedAddCommGroup W] [MetricSpace Q] [NormedAddTorsor W Q]
variable [NormedAddCommGroup W₂] [MetricSpace Q₂] [NormedAddTorsor W₂ Q₂]
variable [NormedField R] [NormedSpace R V] [NormedSpace R W] [NormedSpace R W₂]
variable [NontriviallyNormedField 𝕜] [NormedSpace 𝕜 V] [NormedSpace 𝕜 W] [NormedSpace 𝕜 W₂]
/-- The linear map underlying a continuous affine map is continuous. -/
def contLinear (f : P →ᴬ[R] Q) : V →L[R] W :=
{ f.linear with
toFun := f.linear
cont := by rw [AffineMap.continuous_linear_iff]; exact f.cont }
@[simp]
theorem coe_contLinear (f : P →ᴬ[R] Q) : (f.contLinear : V → W) = f.linear :=
rfl
@[simp]
theorem coe_contLinear_eq_linear (f : P →ᴬ[R] Q) :
(f.contLinear : V →ₗ[R] W) = (f : P →ᵃ[R] Q).linear := by ext; rfl
@[simp]
theorem coe_mk_const_linear_eq_linear (f : P →ᵃ[R] Q) (h) :
((⟨f, h⟩ : P →ᴬ[R] Q).contLinear : V → W) = f.linear :=
rfl
theorem coe_linear_eq_coe_contLinear (f : P →ᴬ[R] Q) :
((f : P →ᵃ[R] Q).linear : V → W) = (⇑f.contLinear : V → W) :=
rfl
@[simp]
theorem comp_contLinear (f : P →ᴬ[R] Q) (g : Q →ᴬ[R] Q₂) :
(g.comp f).contLinear = g.contLinear.comp f.contLinear :=
rfl
@[simp]
theorem map_vadd (f : P →ᴬ[R] Q) (p : P) (v : V) : f (v +ᵥ p) = f.contLinear v +ᵥ f p :=
f.map_vadd' p v
@[simp]
theorem contLinear_map_vsub (f : P →ᴬ[R] Q) (p₁ p₂ : P) : f.contLinear (p₁ -ᵥ p₂) = f p₁ -ᵥ f p₂ :=
f.toAffineMap.linearMap_vsub p₁ p₂
@[simp]
theorem const_contLinear (q : Q) : (const R P q).contLinear = 0 :=
rfl
theorem contLinear_eq_zero_iff_exists_const (f : P →ᴬ[R] Q) :
f.contLinear = 0 ↔ ∃ q, f = const R P q := by
have h₁ : f.contLinear = 0 ↔ (f : P →ᵃ[R] Q).linear = 0 := by
refine ⟨fun h => ?_, fun h => ?_⟩ <;> ext
· rw [← coe_contLinear_eq_linear, h]; rfl
· rw [← coe_linear_eq_coe_contLinear, h]; rfl
have h₂ : ∀ q : Q, f = const R P q ↔ (f : P →ᵃ[R] Q) = AffineMap.const R P q := by
intro q
refine ⟨fun h => ?_, fun h => ?_⟩ <;> ext
· rw [h]; rfl
· rw [← coe_to_affineMap, h]; rfl
simp_rw [h₁, h₂]
exact (f : P →ᵃ[R] Q).linear_eq_zero_iff_exists_const
@[simp]
theorem to_affine_map_contLinear (f : V →L[R] W) : f.toContinuousAffineMap.contLinear = f := by
ext
rfl
@[simp]
theorem zero_contLinear : (0 : P →ᴬ[R] W).contLinear = 0 :=
rfl
@[simp]
theorem add_contLinear (f g : P →ᴬ[R] W) : (f + g).contLinear = f.contLinear + g.contLinear :=
rfl
@[simp]
theorem sub_contLinear (f g : P →ᴬ[R] W) : (f - g).contLinear = f.contLinear - g.contLinear :=
rfl
@[simp]
theorem neg_contLinear (f : P →ᴬ[R] W) : (-f).contLinear = -f.contLinear :=
rfl
@[simp]
theorem smul_contLinear (t : R) (f : P →ᴬ[R] W) : (t • f).contLinear = t • f.contLinear :=
rfl
theorem decomp (f : V →ᴬ[R] W) : (f : V → W) = f.contLinear + Function.const V (f 0) := by
rcases f with ⟨f, h⟩
rw [coe_mk_const_linear_eq_linear, coe_mk, f.decomp, Pi.add_apply, LinearMap.map_zero, zero_add,
← Function.const_def]
section NormedSpaceStructure
variable (f : V →ᴬ[𝕜] W)
/-- Note that unlike the operator norm for linear maps, this norm is _not_ submultiplicative:
we do _not_ necessarily have `‖f.comp g‖ ≤ ‖f‖ * ‖g‖`. See `norm_comp_le` for what we can say. -/
noncomputable instance hasNorm : Norm (V →ᴬ[𝕜] W) :=
⟨fun f => max ‖f 0‖ ‖f.contLinear‖⟩
theorem norm_def : ‖f‖ = max ‖f 0‖ ‖f.contLinear‖ :=
rfl
theorem norm_contLinear_le : ‖f.contLinear‖ ≤ ‖f‖ :=
le_max_right _ _
theorem norm_image_zero_le : ‖f 0‖ ≤ ‖f‖ :=
le_max_left _ _
@[simp]
theorem norm_eq (h : f 0 = 0) : ‖f‖ = ‖f.contLinear‖ :=
calc
‖f‖ = max ‖f 0‖ ‖f.contLinear‖ := by rw [norm_def]
_ = max 0 ‖f.contLinear‖ := by rw [h, norm_zero]
_ = ‖f.contLinear‖ := max_eq_right (norm_nonneg _)
noncomputable instance : NormedAddCommGroup (V →ᴬ[𝕜] W) :=
AddGroupNorm.toNormedAddCommGroup
{ toFun := fun f => max ‖f 0‖ ‖f.contLinear‖
map_zero' := by simp [(ContinuousAffineMap.zero_apply)]
neg' := fun f => by
simp [(ContinuousAffineMap.neg_apply)]
add_le' := fun f g => by
simp only [coe_add, max_le_iff, Pi.add_apply, add_contLinear]
exact
⟨(norm_add_le _ _).trans (add_le_add (le_max_left _ _) (le_max_left _ _)),
(norm_add_le _ _).trans (add_le_add (le_max_right _ _) (le_max_right _ _))⟩
eq_zero_of_map_eq_zero' := fun f h₀ => by
rcases max_eq_iff.mp h₀ with (⟨h₁, h₂⟩ | ⟨h₁, h₂⟩) <;> rw [h₁] at h₂
· rw [norm_le_zero_iff, contLinear_eq_zero_iff_exists_const] at h₂
obtain ⟨q, rfl⟩ := h₂
simp only [norm_eq_zero, coe_const, Function.const_apply] at h₁
rw [h₁]
rfl
· rw [norm_eq_zero', contLinear_eq_zero_iff_exists_const] at h₁
obtain ⟨q, rfl⟩ := h₁
simp only [norm_le_zero_iff, coe_const, Function.const_apply] at h₂
rw [h₂]
rfl }
set_option maxSynthPendingDepth 2 in
instance : NormedSpace 𝕜 (V →ᴬ[𝕜] W) where
norm_smul_le t f := by
simp only [norm_def, coe_smul, Pi.smul_apply, norm_smul, smul_contLinear,
← mul_max_of_nonneg _ _ (norm_nonneg t), le_refl]
theorem norm_comp_le (g : W₂ →ᴬ[𝕜] V) : ‖f.comp g‖ ≤ ‖f‖ * ‖g‖ + ‖f 0‖ := by
rw [norm_def, max_le_iff]
constructor
· calc
‖f.comp g 0‖ = ‖f (g 0)‖ := by simp
_ = ‖f.contLinear (g 0) + f 0‖ := by rw [f.decomp]; simp
_ ≤ ‖f.contLinear‖ * ‖g 0‖ + ‖f 0‖ :=
((norm_add_le _ _).trans (add_le_add_right (f.contLinear.le_opNorm _) _))
_ ≤ ‖f‖ * ‖g‖ + ‖f 0‖ :=
add_le_add_right
(mul_le_mul f.norm_contLinear_le g.norm_image_zero_le (norm_nonneg _) (norm_nonneg _)) _
· calc
‖(f.comp g).contLinear‖ ≤ ‖f.contLinear‖ * ‖g.contLinear‖ :=
(g.comp_contLinear f).symm ▸ f.contLinear.opNorm_comp_le _
_ ≤ ‖f‖ * ‖g‖ :=
(mul_le_mul f.norm_contLinear_le g.norm_contLinear_le (norm_nonneg _) (norm_nonneg _))
_ ≤ ‖f‖ * ‖g‖ + ‖f 0‖ := by rw [le_add_iff_nonneg_right]; apply norm_nonneg
variable (𝕜 V W)
/-- The space of affine maps between two normed spaces is linearly isometric to the product of the
codomain with the space of linear maps, by taking the value of the affine map at `(0 : V)` and the
linear part. -/
def toConstProdContinuousLinearMap : (V →ᴬ[𝕜] W) ≃ₗᵢ[𝕜] W × (V →L[𝕜] W) where
toFun f := ⟨f 0, f.contLinear⟩
invFun p := p.2.toContinuousAffineMap + const 𝕜 V p.1
left_inv f := by
ext
rw [f.decomp]
simp only [coe_add, ContinuousLinearMap.coe_toContinuousAffineMap, Pi.add_apply, coe_const]
right_inv := by rintro ⟨v, f⟩; ext <;> simp
map_add' _ _ := rfl
map_smul' _ _ := rfl
norm_map' f := rfl
@[simp]
theorem toConstProdContinuousLinearMap_fst (f : V →ᴬ[𝕜] W) :
(toConstProdContinuousLinearMap 𝕜 V W f).fst = f 0 :=
rfl
@[simp]
theorem toConstProdContinuousLinearMap_snd (f : V →ᴬ[𝕜] W) :
(toConstProdContinuousLinearMap 𝕜 V W f).snd = f.contLinear :=
rfl
end NormedSpaceStructure
end ContinuousAffineMap
|
Analysis\NormedSpace\DualNumber.lean | /-
Copyright (c) 2023 Eric Wieser. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Eric Wieser
-/
import Mathlib.Algebra.DualNumber
import Mathlib.Analysis.Normed.Algebra.TrivSqZeroExt
/-!
# Results on `DualNumber R` related to the norm
These are just restatements of similar statements about `TrivSqZeroExt R M`.
## Main results
* `exp_eps`
-/
open NormedSpace -- For `NormedSpace.exp`.
namespace DualNumber
open TrivSqZeroExt
variable (𝕜 : Type*) {R : Type*}
variable [Field 𝕜] [CharZero 𝕜] [CommRing R] [Algebra 𝕜 R]
variable [UniformSpace R] [TopologicalRing R] [T2Space R]
@[simp]
theorem exp_eps : exp 𝕜 (eps : DualNumber R) = 1 + eps :=
exp_inr _ _
@[simp]
theorem exp_smul_eps (r : R) : exp 𝕜 (r • eps : DualNumber R) = 1 + r • eps := by
rw [eps, ← inr_smul, exp_inr]
end DualNumber
|
Analysis\NormedSpace\ENorm.lean | /-
Copyright (c) 2020 Yury G. Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury G. Kudryashov
-/
import Mathlib.Analysis.Normed.Module.Basic
/-!
# Extended norm
In this file we define a structure `ENorm 𝕜 V` representing an extended norm (i.e., a norm that can
take the value `∞`) on a vector space `V` over a normed field `𝕜`. We do not use `class` for
an `ENorm` because the same space can have more than one extended norm. For example, the space of
measurable functions `f : α → ℝ` has a family of `L_p` extended norms.
We prove some basic inequalities, then define
* `EMetricSpace` structure on `V` corresponding to `e : ENorm 𝕜 V`;
* the subspace of vectors with finite norm, called `e.finiteSubspace`;
* a `NormedSpace` structure on this space.
The last definition is an instance because the type involves `e`.
## Implementation notes
We do not define extended normed groups. They can be added to the chain once someone will need them.
## Tags
normed space, extended norm
-/
noncomputable section
attribute [local instance] Classical.propDecidable
open ENNReal
/-- Extended norm on a vector space. As in the case of normed spaces, we require only
`‖c • x‖ ≤ ‖c‖ * ‖x‖` in the definition, then prove an equality in `map_smul`. -/
structure ENorm (𝕜 : Type*) (V : Type*) [NormedField 𝕜] [AddCommGroup V] [Module 𝕜 V] where
toFun : V → ℝ≥0∞
eq_zero' : ∀ x, toFun x = 0 → x = 0
map_add_le' : ∀ x y : V, toFun (x + y) ≤ toFun x + toFun y
map_smul_le' : ∀ (c : 𝕜) (x : V), toFun (c • x) ≤ ‖c‖₊ * toFun x
namespace ENorm
variable {𝕜 : Type*} {V : Type*} [NormedField 𝕜] [AddCommGroup V] [Module 𝕜 V] (e : ENorm 𝕜 V)
-- Porting note: added to appease norm_cast complaints
attribute [coe] ENorm.toFun
instance : CoeFun (ENorm 𝕜 V) fun _ => V → ℝ≥0∞ :=
⟨ENorm.toFun⟩
theorem coeFn_injective : Function.Injective ((↑) : ENorm 𝕜 V → V → ℝ≥0∞) := fun e₁ e₂ h => by
cases e₁
cases e₂
congr
@[ext]
theorem ext {e₁ e₂ : ENorm 𝕜 V} (h : ∀ x, e₁ x = e₂ x) : e₁ = e₂ :=
coeFn_injective <| funext h
@[simp, norm_cast]
theorem coe_inj {e₁ e₂ : ENorm 𝕜 V} : (e₁ : V → ℝ≥0∞) = e₂ ↔ e₁ = e₂ :=
coeFn_injective.eq_iff
@[simp]
theorem map_smul (c : 𝕜) (x : V) : e (c • x) = ‖c‖₊ * e x := by
apply le_antisymm (e.map_smul_le' c x)
by_cases hc : c = 0
· simp [hc]
calc
(‖c‖₊ : ℝ≥0∞) * e x = ‖c‖₊ * e (c⁻¹ • c • x) := by rw [inv_smul_smul₀ hc]
_ ≤ ‖c‖₊ * (‖c⁻¹‖₊ * e (c • x)) := mul_le_mul_left' (e.map_smul_le' _ _) _
_ = e (c • x) := by
rw [← mul_assoc, nnnorm_inv, ENNReal.coe_inv, ENNReal.mul_inv_cancel _ ENNReal.coe_ne_top,
one_mul]
<;> simp [hc]
@[simp]
theorem map_zero : e 0 = 0 := by
rw [← zero_smul 𝕜 (0 : V), e.map_smul]
norm_num
@[simp]
theorem eq_zero_iff {x : V} : e x = 0 ↔ x = 0 :=
⟨e.eq_zero' x, fun h => h.symm ▸ e.map_zero⟩
@[simp]
theorem map_neg (x : V) : e (-x) = e x :=
calc
e (-x) = ‖(-1 : 𝕜)‖₊ * e x := by rw [← map_smul, neg_one_smul]
_ = e x := by simp
theorem map_sub_rev (x y : V) : e (x - y) = e (y - x) := by rw [← neg_sub, e.map_neg]
theorem map_add_le (x y : V) : e (x + y) ≤ e x + e y :=
e.map_add_le' x y
theorem map_sub_le (x y : V) : e (x - y) ≤ e x + e y :=
calc
e (x - y) = e (x + -y) := by rw [sub_eq_add_neg]
_ ≤ e x + e (-y) := e.map_add_le x (-y)
_ = e x + e y := by rw [e.map_neg]
instance partialOrder : PartialOrder (ENorm 𝕜 V) where
le e₁ e₂ := ∀ x, e₁ x ≤ e₂ x
le_refl e x := le_rfl
le_trans e₁ e₂ e₃ h₁₂ h₂₃ x := le_trans (h₁₂ x) (h₂₃ x)
le_antisymm e₁ e₂ h₁₂ h₂₁ := ext fun x => le_antisymm (h₁₂ x) (h₂₁ x)
/-- The `ENorm` sending each non-zero vector to infinity. -/
noncomputable instance : Top (ENorm 𝕜 V) :=
⟨{ toFun := fun x => if x = 0 then 0 else ⊤
eq_zero' := fun x => by simp only; split_ifs <;> simp [*]
map_add_le' := fun x y => by
simp only
split_ifs with hxy hx hy hy hx hy hy <;> try simp [*]
simp [hx, hy] at hxy
map_smul_le' := fun c x => by
simp only
split_ifs with hcx hx hx <;> simp only [smul_eq_zero, not_or] at hcx
· simp only [mul_zero, le_refl]
· have : c = 0 := by tauto
simp [this]
· tauto
· simpa [mul_top'] using hcx.1 }⟩
noncomputable instance : Inhabited (ENorm 𝕜 V) :=
⟨⊤⟩
theorem top_map {x : V} (hx : x ≠ 0) : (⊤ : ENorm 𝕜 V) x = ⊤ :=
if_neg hx
noncomputable instance : OrderTop (ENorm 𝕜 V) where
top := ⊤
le_top e x := if h : x = 0 then by simp [h] else by simp [top_map h]
noncomputable instance : SemilatticeSup (ENorm 𝕜 V) :=
{ ENorm.partialOrder with
le := (· ≤ ·)
lt := (· < ·)
sup := fun e₁ e₂ =>
{ toFun := fun x => max (e₁ x) (e₂ x)
eq_zero' := fun x h => e₁.eq_zero_iff.1 (ENNReal.max_eq_zero_iff.1 h).1
map_add_le' := fun x y =>
max_le (le_trans (e₁.map_add_le _ _) <| add_le_add (le_max_left _ _) (le_max_left _ _))
(le_trans (e₂.map_add_le _ _) <| add_le_add (le_max_right _ _) (le_max_right _ _))
map_smul_le' := fun c x => le_of_eq <| by simp only [map_smul, ENNReal.mul_max] }
le_sup_left := fun e₁ e₂ x => le_max_left _ _
le_sup_right := fun e₁ e₂ x => le_max_right _ _
sup_le := fun e₁ e₂ e₃ h₁ h₂ x => max_le (h₁ x) (h₂ x) }
@[simp, norm_cast]
theorem coe_max (e₁ e₂ : ENorm 𝕜 V) : ⇑(e₁ ⊔ e₂) = fun x => max (e₁ x) (e₂ x) :=
rfl
@[norm_cast]
theorem max_map (e₁ e₂ : ENorm 𝕜 V) (x : V) : (e₁ ⊔ e₂) x = max (e₁ x) (e₂ x) :=
rfl
/-- Structure of an `EMetricSpace` defined by an extended norm. -/
abbrev emetricSpace : EMetricSpace V where
edist x y := e (x - y)
edist_self x := by simp
eq_of_edist_eq_zero {x y} := by simp [sub_eq_zero]
edist_comm := e.map_sub_rev
edist_triangle x y z :=
calc
e (x - z) = e (x - y + (y - z)) := by rw [sub_add_sub_cancel]
_ ≤ e (x - y) + e (y - z) := e.map_add_le (x - y) (y - z)
/-- The subspace of vectors with finite enorm. -/
def finiteSubspace : Subspace 𝕜 V where
carrier := { x | e x < ⊤ }
zero_mem' := by simp
add_mem' {x y} hx hy := lt_of_le_of_lt (e.map_add_le x y) (ENNReal.add_lt_top.2 ⟨hx, hy⟩)
smul_mem' c x (hx : _ < _) :=
calc
e (c • x) = ‖c‖₊ * e x := e.map_smul c x
_ < ⊤ := ENNReal.mul_lt_top ENNReal.coe_ne_top hx.ne
/-- Metric space structure on `e.finiteSubspace`. We use `EMetricSpace.toMetricSpace`
to ensure that this definition agrees with `e.emetricSpace`. -/
instance metricSpace : MetricSpace e.finiteSubspace := by
letI := e.emetricSpace
refine EMetricSpace.toMetricSpace fun x y => ?_
change e (x - y) ≠ ⊤
exact ne_top_of_le_ne_top (ENNReal.add_lt_top.2 ⟨x.2, y.2⟩).ne (e.map_sub_le x y)
theorem finite_dist_eq (x y : e.finiteSubspace) : dist x y = (e (x - y)).toReal :=
rfl
theorem finite_edist_eq (x y : e.finiteSubspace) : edist x y = e (x - y) :=
rfl
/-- Normed group instance on `e.finiteSubspace`. -/
instance normedAddCommGroup : NormedAddCommGroup e.finiteSubspace :=
{ e.metricSpace with
norm := fun x => (e x).toReal
dist_eq := fun _ _ => rfl }
theorem finite_norm_eq (x : e.finiteSubspace) : ‖x‖ = (e x).toReal :=
rfl
/-- Normed space instance on `e.finiteSubspace`. -/
instance normedSpace : NormedSpace 𝕜 e.finiteSubspace where
norm_smul_le c x := le_of_eq <| by simp [finite_norm_eq, ENNReal.toReal_mul]
end ENorm
|
Analysis\NormedSpace\Extend.lean | /-
Copyright (c) 2020 Ruben Van de Velde. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Ruben Van de Velde
-/
import Mathlib.Algebra.Algebra.RestrictScalars
import Mathlib.Analysis.NormedSpace.OperatorNorm.Basic
import Mathlib.Analysis.RCLike.Basic
/-!
# Extending a continuous `ℝ`-linear map to a continuous `𝕜`-linear map
In this file we provide a way to extend a continuous `ℝ`-linear map to a continuous `𝕜`-linear map
in a way that bounds the norm by the norm of the original map, when `𝕜` is either `ℝ` (the
extension is trivial) or `ℂ`. We formulate the extension uniformly, by assuming `RCLike 𝕜`.
We motivate the form of the extension as follows. Note that `fc : F →ₗ[𝕜] 𝕜` is determined fully by
`re fc`: for all `x : F`, `fc (I • x) = I * fc x`, so `im (fc x) = -re (fc (I • x))`. Therefore,
given an `fr : F →ₗ[ℝ] ℝ`, we define `fc x = fr x - fr (I • x) * I`.
## Main definitions
* `LinearMap.extendTo𝕜`
* `ContinuousLinearMap.extendTo𝕜`
## Implementation details
For convenience, the main definitions above operate in terms of `RestrictScalars ℝ 𝕜 F`.
Alternate forms which operate on `[IsScalarTower ℝ 𝕜 F]` instead are provided with a primed name.
-/
open RCLike
open ComplexConjugate
variable {𝕜 : Type*} [RCLike 𝕜] {F : Type*}
namespace LinearMap
variable [AddCommGroup F] [Module ℝ F] [Module 𝕜 F] [IsScalarTower ℝ 𝕜 F]
/-- Extend `fr : F →ₗ[ℝ] ℝ` to `F →ₗ[𝕜] 𝕜` in a way that will also be continuous and have its norm
bounded by `‖fr‖` if `fr` is continuous. -/
noncomputable def extendTo𝕜' (fr : F →ₗ[ℝ] ℝ) : F →ₗ[𝕜] 𝕜 := by
let fc : F → 𝕜 := fun x => (fr x : 𝕜) - (I : 𝕜) * fr ((I : 𝕜) • x)
have add : ∀ x y : F, fc (x + y) = fc x + fc y := by
intro x y
simp only [fc, smul_add, LinearMap.map_add, ofReal_add]
rw [mul_add]
abel
have A : ∀ (c : ℝ) (x : F), (fr ((c : 𝕜) • x) : 𝕜) = (c : 𝕜) * (fr x : 𝕜) := by
intro c x
rw [← ofReal_mul]
congr 1
rw [RCLike.ofReal_alg, smul_assoc, fr.map_smul, Algebra.id.smul_eq_mul, one_smul]
have smul_ℝ : ∀ (c : ℝ) (x : F), fc ((c : 𝕜) • x) = (c : 𝕜) * fc x := by
intro c x
dsimp only [fc]
rw [A c x, smul_smul, mul_comm I (c : 𝕜), ← smul_smul, A, mul_sub]
ring
have smul_I : ∀ x : F, fc ((I : 𝕜) • x) = (I : 𝕜) * fc x := by
intro x
dsimp only [fc]
cases' @I_mul_I_ax 𝕜 _ with h h
· simp [h]
rw [mul_sub, ← mul_assoc, smul_smul, h]
simp only [neg_mul, LinearMap.map_neg, one_mul, one_smul, mul_neg, ofReal_neg, neg_smul,
sub_neg_eq_add, add_comm]
have smul_𝕜 : ∀ (c : 𝕜) (x : F), fc (c • x) = c • fc x := by
intro c x
rw [← re_add_im c, add_smul, add_smul, add, smul_ℝ, ← smul_smul, smul_ℝ, smul_I, ← mul_assoc]
rfl
exact
{ toFun := fc
map_add' := add
map_smul' := smul_𝕜 }
theorem extendTo𝕜'_apply (fr : F →ₗ[ℝ] ℝ) (x : F) :
fr.extendTo𝕜' x = (fr x : 𝕜) - (I : 𝕜) * (fr ((I : 𝕜) • x) : 𝕜) := rfl
@[simp]
theorem extendTo𝕜'_apply_re (fr : F →ₗ[ℝ] ℝ) (x : F) : re (fr.extendTo𝕜' x : 𝕜) = fr x := by
simp only [extendTo𝕜'_apply, map_sub, zero_mul, mul_zero, sub_zero,
rclike_simps]
theorem norm_extendTo𝕜'_apply_sq (fr : F →ₗ[ℝ] ℝ) (x : F) :
‖(fr.extendTo𝕜' x : 𝕜)‖ ^ 2 = fr (conj (fr.extendTo𝕜' x : 𝕜) • x) :=
calc
‖(fr.extendTo𝕜' x : 𝕜)‖ ^ 2 = re (conj (fr.extendTo𝕜' x) * fr.extendTo𝕜' x : 𝕜) := by
rw [RCLike.conj_mul, ← ofReal_pow, ofReal_re]
_ = fr (conj (fr.extendTo𝕜' x : 𝕜) • x) := by
rw [← smul_eq_mul, ← map_smul, extendTo𝕜'_apply_re]
end LinearMap
variable [SeminormedAddCommGroup F] [NormedSpace 𝕜 F]
namespace ContinuousLinearMap
variable [NormedSpace ℝ F] [IsScalarTower ℝ 𝕜 F]
/-- The norm of the extension is bounded by `‖fr‖`. -/
theorem norm_extendTo𝕜'_bound (fr : F →L[ℝ] ℝ) (x : F) :
‖(fr.toLinearMap.extendTo𝕜' x : 𝕜)‖ ≤ ‖fr‖ * ‖x‖ := by
set lm : F →ₗ[𝕜] 𝕜 := fr.toLinearMap.extendTo𝕜'
by_cases h : lm x = 0
· rw [h, norm_zero]
apply mul_nonneg <;> exact norm_nonneg _
rw [← mul_le_mul_left (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]
/-- Extend `fr : F →L[ℝ] ℝ` to `F →L[𝕜] 𝕜`. -/
noncomputable def extendTo𝕜' (fr : F →L[ℝ] ℝ) : F →L[𝕜] 𝕜 :=
LinearMap.mkContinuous _ ‖fr‖ fr.norm_extendTo𝕜'_bound
theorem extendTo𝕜'_apply (fr : F →L[ℝ] ℝ) (x : F) :
fr.extendTo𝕜' x = (fr x : 𝕜) - (I : 𝕜) * (fr ((I : 𝕜) • x) : 𝕜) := rfl
@[simp]
theorem norm_extendTo𝕜' (fr : F →L[ℝ] ℝ) : ‖(fr.extendTo𝕜' : F →L[𝕜] 𝕜)‖ = ‖fr‖ :=
le_antisymm (LinearMap.mkContinuous_norm_le _ (norm_nonneg _) _) <|
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𝕜' : F →L[𝕜] 𝕜)‖ * ‖x‖ := le_opNorm _ _
end ContinuousLinearMap
-- Porting note (#10754): Added a new instance. This instance is needed for the rest of the file.
instance : NormedSpace 𝕜 (RestrictScalars ℝ 𝕜 F) := by
unfold RestrictScalars
infer_instance
/-- Extend `fr : RestrictScalars ℝ 𝕜 F →ₗ[ℝ] ℝ` to `F →ₗ[𝕜] 𝕜`. -/
noncomputable def LinearMap.extendTo𝕜 (fr : RestrictScalars ℝ 𝕜 F →ₗ[ℝ] ℝ) : F →ₗ[𝕜] 𝕜 :=
fr.extendTo𝕜'
theorem LinearMap.extendTo𝕜_apply (fr : RestrictScalars ℝ 𝕜 F →ₗ[ℝ] ℝ) (x : F) :
fr.extendTo𝕜 x = (fr x : 𝕜) - (I : 𝕜) * (fr ((I : 𝕜) • x) : 𝕜) := rfl
/-- Extend `fr : RestrictScalars ℝ 𝕜 F →L[ℝ] ℝ` to `F →L[𝕜] 𝕜`. -/
noncomputable def ContinuousLinearMap.extendTo𝕜 (fr : RestrictScalars ℝ 𝕜 F →L[ℝ] ℝ) : F →L[𝕜] 𝕜 :=
fr.extendTo𝕜'
theorem ContinuousLinearMap.extendTo𝕜_apply (fr : RestrictScalars ℝ 𝕜 F →L[ℝ] ℝ) (x : F) :
fr.extendTo𝕜 x = (fr x : 𝕜) - (I : 𝕜) * (fr ((I : 𝕜) • x) : 𝕜) := rfl
@[simp]
theorem ContinuousLinearMap.norm_extendTo𝕜 (fr : RestrictScalars ℝ 𝕜 F →L[ℝ] ℝ) :
‖fr.extendTo𝕜‖ = ‖fr‖ :=
fr.norm_extendTo𝕜'
|
Analysis\NormedSpace\Extr.lean | /-
Copyright (c) 2022 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov
-/
import Mathlib.Analysis.Normed.Module.Ray
import Mathlib.Topology.Order.LocalExtr
/-!
# (Local) maximums in a normed space
In this file we prove the following lemma, see `IsMaxFilter.norm_add_sameRay`. If `f : α → E` is
a function such that `norm ∘ f` has a maximum along a filter `l` at a point `c` and `y` is a vector
on the same ray as `f c`, then the function `fun x => ‖f x + y‖` has a maximum along `l` at `c`.
Then we specialize it to the case `y = f c` and to different special cases of `IsMaxFilter`:
`IsMaxOn`, `IsLocalMaxOn`, and `IsLocalMax`.
## Tags
local maximum, normed space
-/
variable {α X E : Type*} [SeminormedAddCommGroup E] [NormedSpace ℝ E] [TopologicalSpace X]
section
variable {f : α → E} {l : Filter α} {s : Set α} {c : α} {y : E}
/-- If `f : α → E` is a function such that `norm ∘ f` has a maximum along a filter `l` at a point
`c` and `y` is a vector on the same ray as `f c`, then the function `fun x => ‖f x + y‖` has
a maximum along `l` at `c`. -/
theorem IsMaxFilter.norm_add_sameRay (h : IsMaxFilter (norm ∘ f) l c) (hy : SameRay ℝ (f c) y) :
IsMaxFilter (fun x => ‖f x + y‖) l c :=
h.mono fun x hx =>
calc
‖f x + y‖ ≤ ‖f x‖ + ‖y‖ := norm_add_le _ _
_ ≤ ‖f c‖ + ‖y‖ := add_le_add_right hx _
_ = ‖f c + y‖ := hy.norm_add.symm
/-- If `f : α → E` is a function such that `norm ∘ f` has a maximum along a filter `l` at a point
`c`, then the function `fun x => ‖f x + f c‖` has a maximum along `l` at `c`. -/
theorem IsMaxFilter.norm_add_self (h : IsMaxFilter (norm ∘ f) l c) :
IsMaxFilter (fun x => ‖f x + f c‖) l c :=
IsMaxFilter.norm_add_sameRay h SameRay.rfl
/-- If `f : α → E` is a function such that `norm ∘ f` has a maximum on a set `s` at a point `c` and
`y` is a vector on the same ray as `f c`, then the function `fun x => ‖f x + y‖` has a maximum
on `s` at `c`. -/
theorem IsMaxOn.norm_add_sameRay (h : IsMaxOn (norm ∘ f) s c) (hy : SameRay ℝ (f c) y) :
IsMaxOn (fun x => ‖f x + y‖) s c :=
IsMaxFilter.norm_add_sameRay h hy
/-- If `f : α → E` is a function such that `norm ∘ f` has a maximum on a set `s` at a point `c`,
then the function `fun x => ‖f x + f c‖` has a maximum on `s` at `c`. -/
theorem IsMaxOn.norm_add_self (h : IsMaxOn (norm ∘ f) s c) : IsMaxOn (fun x => ‖f x + f c‖) s c :=
IsMaxFilter.norm_add_self h
end
variable {f : X → E} {s : Set X} {c : X} {y : E}
/-- If `f : α → E` is a function such that `norm ∘ f` has a local maximum on a set `s` at a point
`c` and `y` is a vector on the same ray as `f c`, then the function `fun x => ‖f x + y‖` has a local
maximum on `s` at `c`. -/
theorem IsLocalMaxOn.norm_add_sameRay (h : IsLocalMaxOn (norm ∘ f) s c) (hy : SameRay ℝ (f c) y) :
IsLocalMaxOn (fun x => ‖f x + y‖) s c :=
IsMaxFilter.norm_add_sameRay h hy
/-- If `f : α → E` is a function such that `norm ∘ f` has a local maximum on a set `s` at a point
`c`, then the function `fun x => ‖f x + f c‖` has a local maximum on `s` at `c`. -/
theorem IsLocalMaxOn.norm_add_self (h : IsLocalMaxOn (norm ∘ f) s c) :
IsLocalMaxOn (fun x => ‖f x + f c‖) s c :=
IsMaxFilter.norm_add_self h
/-- If `f : α → E` is a function such that `norm ∘ f` has a local maximum at a point `c` and `y` is
a vector on the same ray as `f c`, then the function `fun x => ‖f x + y‖` has a local maximum
at `c`. -/
theorem IsLocalMax.norm_add_sameRay (h : IsLocalMax (norm ∘ f) c) (hy : SameRay ℝ (f c) y) :
IsLocalMax (fun x => ‖f x + y‖) c :=
IsMaxFilter.norm_add_sameRay h hy
/-- If `f : α → E` is a function such that `norm ∘ f` has a local maximum at a point `c`, then the
function `fun x => ‖f x + f c‖` has a local maximum at `c`. -/
theorem IsLocalMax.norm_add_self (h : IsLocalMax (norm ∘ f) c) :
IsLocalMax (fun x => ‖f x + f c‖) c :=
IsMaxFilter.norm_add_self h
|
Analysis\NormedSpace\FunctionSeries.lean | /-
Copyright (c) 2022 Sébastien Gouëzel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sébastien Gouëzel
-/
import Mathlib.Analysis.Normed.Group.InfiniteSum
import Mathlib.Topology.Instances.ENNReal
/-!
# 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`.
-/
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, ← sum_add_tsum_subtype_compl A.of_norm t, add_sub_cancel_left]
apply lt_of_le_of_lt _ ht
apply (norm_tsum_le_tsum_norm (A.subtype _)).trans
exact tsum_le_tsum (fun n => hfu _ _ hx) (A.subtype _) (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 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 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 [continuous_iff_continuousOn_univ] at hf ⊢
exact continuousOn_tsum hf hu fun n x _ => hfu n x
|
Analysis\NormedSpace\HomeomorphBall.lean | /-
Copyright (c) 2021 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov, Oliver Nash
-/
import Mathlib.Topology.PartialHomeomorph
import Mathlib.Analysis.Normed.Group.AddTorsor
import Mathlib.Analysis.NormedSpace.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 a `PartialHomeomorph` 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 `PartialHomeomorph.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 (config := .lemmasOnly)]
def PartialHomeomorph.univUnitBall : PartialHomeomorph 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
field_simp [norm_smul, smul_smul, (zero_lt_one_add_norm_sq x).ne', sq_abs,
Real.sq_sqrt (zero_lt_one_add_norm_sq x).le, ← Real.sqrt_div (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]
field_simp [norm_smul, smul_smul, this.ne', sq_abs, Real.sq_sqrt this.le,
← Real.sqrt_div this.le]
open_source := isOpen_univ
open_target := isOpen_ball
continuousOn_toFun := by
suffices Continuous fun (x : E) => (√(1 + ‖x‖ ^ 2))⁻¹
from (this.smul continuous_id).continuousOn
refine Continuous.inv₀ ?_ fun x => Real.sqrt_ne_zero'.mpr (by positivity)
continuity
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 PartialHomeomorph.univUnitBall_apply_zero : univUnitBall (0 : E) = 0 := by
simp [PartialHomeomorph.univUnitBall_apply]
@[simp]
theorem PartialHomeomorph.univUnitBall_symm_apply_zero : univUnitBall.symm (0 : E) = 0 := by
simp [PartialHomeomorph.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 `PartialHomeomorph.contDiffOn_unitBall_symm`
for smoothness properties that hold when `E` is an inner-product space. -/
@[simps! (config := .lemmasOnly)]
def Homeomorph.unitBall : E ≃ₜ ball (0 : E) 1 :=
(Homeomorph.Set.univ _).symm.trans PartialHomeomorph.univUnitBall.toHomeomorphSourceTarget
@[simp]
theorem Homeomorph.coe_unitBall_apply_zero :
(Homeomorph.unitBall (0 : E) : E) = 0 :=
PartialHomeomorph.univUnitBall_apply_zero
variable {P : Type*} [PseudoMetricSpace P] [NormedAddTorsor E P]
namespace PartialHomeomorph
/-- Affine homeomorphism `(r • · +ᵥ c)` between a normed space and an add torsor over this space,
interpreted as a `PartialHomeomorph` between `Metric.ball 0 1` and `Metric.ball c r`. -/
@[simps!]
def unitBallBall (c : P) (r : ℝ) (hr : 0 < r) : PartialHomeomorph E P :=
((Homeomorph.smulOfNeZero r hr.ne').trans
(IsometryEquiv.vaddConst c).toHomeomorph).toPartialHomeomorphOfImageEq
(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 `PartialHomeomorph.univBall c r` is a smooth 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 `PartialHomeomorph.univBall_apply_zero`. -/
def univBall (c : P) (r : ℝ) : PartialHomeomorph E P :=
if h : 0 < r then univUnitBall.trans' (unitBallBall c r h) rfl
else (IsometryEquiv.vaddConst c).toHomeomorph.toPartialHomeomorph
@[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 [continuous_iff_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 PartialHomeomorph
|
Analysis\NormedSpace\IndicatorFunction.lean | /-
Copyright (c) 2020 Zhouhang Zhou. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Zhouhang Zhou, Yury Kudryashov
-/
import Mathlib.Algebra.Order.Group.Indicator
import Mathlib.Analysis.Normed.Group.Basic
/-!
# Indicator function and norm
This file contains a few simple lemmas about `Set.indicator` and `norm`.
## Tags
indicator, norm
-/
variable {α E : Type*} [SeminormedAddCommGroup E] {s t : Set α} (f : α → E) (a : α)
open Set
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
|
Analysis\NormedSpace\Int.lean | /-
Copyright (c) 2021 Johan Commelin. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin
-/
import Mathlib.Analysis.Normed.Field.Basic
/-!
# The integers as normed ring
This file contains basic facts about the integers as normed ring.
Recall that `‖n‖` denotes the norm of `n` as real number.
This norm is always nonnegative, so we can bundle the norm together with this fact,
to obtain a term of type `NNReal` (the nonnegative real numbers).
The resulting nonnegative real number is denoted by `‖n‖₊`.
-/
namespace Int
theorem nnnorm_coe_units (e : ℤˣ) : ‖(e : ℤ)‖₊ = 1 := by
obtain rfl | rfl := units_eq_one_or e <;>
simp only [Units.coe_neg_one, Units.val_one, nnnorm_neg, nnnorm_one]
theorem norm_coe_units (e : ℤˣ) : ‖(e : ℤ)‖ = 1 := by
rw [← coe_nnnorm, nnnorm_coe_units, NNReal.coe_one]
@[simp]
theorem nnnorm_natCast (n : ℕ) : ‖(n : ℤ)‖₊ = n :=
Real.nnnorm_natCast _
@[deprecated (since := "2024-04-05")] alias nnnorm_coe_nat := nnnorm_natCast
@[simp]
theorem toNat_add_toNat_neg_eq_nnnorm (n : ℤ) : ↑n.toNat + ↑(-n).toNat = ‖n‖₊ := by
rw [← Nat.cast_add, toNat_add_toNat_neg_eq_natAbs, NNReal.natCast_natAbs]
@[simp]
theorem toNat_add_toNat_neg_eq_norm (n : ℤ) : ↑n.toNat + ↑(-n).toNat = ‖n‖ := by
simpa only [NNReal.coe_natCast, NNReal.coe_add] using
congrArg NNReal.toReal (toNat_add_toNat_neg_eq_nnnorm n)
end Int
|
Analysis\NormedSpace\MazurUlam.lean | /-
Copyright (c) 2020 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov
-/
import Mathlib.Topology.Instances.RealVectorSpace
import Mathlib.Analysis.NormedSpace.AffineIsometry
/-!
# Mazur-Ulam Theorem
Mazur-Ulam theorem states that an isometric bijection between two normed affine spaces over `ℝ` is
affine. We formalize it in three definitions:
* `IsometryEquiv.toRealLinearIsometryEquivOfMapZero` : given `E ≃ᵢ F` sending `0` to `0`,
returns `E ≃ₗᵢ[ℝ] F` with the same `toFun` and `invFun`;
* `IsometryEquiv.toRealLinearIsometryEquiv` : given `f : E ≃ᵢ F`, returns a linear isometry
equivalence `g : E ≃ₗᵢ[ℝ] F` with `g x = f x - f 0`.
* `IsometryEquiv.toRealAffineIsometryEquiv` : given `f : PE ≃ᵢ PF`, returns an affine isometry
equivalence `g : PE ≃ᵃⁱ[ℝ] PF` whose underlying `IsometryEquiv` is `f`
The formalization is based on [Jussi Väisälä, *A Proof of the Mazur-Ulam Theorem*][Vaisala_2003].
## Tags
isometry, affine map, linear map
-/
variable {E PE F PF : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [MetricSpace PE]
[NormedAddTorsor E PE] [NormedAddCommGroup F] [NormedSpace ℝ F] [MetricSpace PF]
[NormedAddTorsor F PF]
open Set AffineMap AffineIsometryEquiv
noncomputable section
namespace IsometryEquiv
/-- If an isometric self-homeomorphism of a normed vector space over `ℝ` fixes `x` and `y`,
then it fixes the midpoint of `[x, y]`. This is a lemma for a more general Mazur-Ulam theorem,
see below. -/
theorem midpoint_fixed {x y : PE} :
∀ e : PE ≃ᵢ PE, e x = x → e y = y → e (midpoint ℝ x y) = midpoint ℝ x y := by
set z := midpoint ℝ x y
-- Consider the set of `e : E ≃ᵢ E` such that `e x = x` and `e y = y`
set s := { e : PE ≃ᵢ PE | e x = x ∧ e y = y }
haveI : Nonempty s := ⟨⟨IsometryEquiv.refl PE, rfl, rfl⟩⟩
-- On the one hand, `e` cannot send the midpoint `z` of `[x, y]` too far
have h_bdd : BddAbove (range fun e : s => dist ((e : PE ≃ᵢ PE) z) z) := by
refine ⟨dist x z + dist x z, forall_mem_range.2 <| Subtype.forall.2 ?_⟩
rintro e ⟨hx, _⟩
calc
dist (e z) z ≤ dist (e z) x + dist x z := dist_triangle (e z) x z
_ = dist (e x) (e z) + dist x z := by rw [hx, dist_comm]
_ = dist x z + dist x z := by erw [e.dist_eq x z]
-- On the other hand, consider the map `f : (E ≃ᵢ E) → (E ≃ᵢ E)`
-- sending each `e` to `R ∘ e⁻¹ ∘ R ∘ e`, where `R` is the point reflection in the
-- midpoint `z` of `[x, y]`.
set R : PE ≃ᵢ PE := (pointReflection ℝ z).toIsometryEquiv
set f : PE ≃ᵢ PE → PE ≃ᵢ PE := fun e => ((e.trans R).trans e.symm).trans R
-- Note that `f` doubles the value of `dist (e z) z`
have hf_dist : ∀ e, dist (f e z) z = 2 * dist (e z) z := by
intro e
dsimp only [trans_apply, coe_toIsometryEquiv, f, R]
rw [dist_pointReflection_fixed, ← e.dist_eq, e.apply_symm_apply,
dist_pointReflection_self_real, dist_comm]
-- Also note that `f` maps `s` to itself
have hf_maps_to : MapsTo f s s := by
rintro e ⟨hx, hy⟩
constructor <;> simp [f, R, z, hx, hy, e.symm_apply_eq.2 hx.symm, e.symm_apply_eq.2 hy.symm]
-- Therefore, `dist (e z) z = 0` for all `e ∈ s`.
set c := ⨆ e : s, dist ((e : PE ≃ᵢ PE) z) z
have : c ≤ c / 2 := by
apply ciSup_le
rintro ⟨e, he⟩
simp only [Subtype.coe_mk, le_div_iff' (zero_lt_two' ℝ), ← hf_dist]
exact le_ciSup h_bdd ⟨f e, hf_maps_to he⟩
replace : c ≤ 0 := by linarith
refine fun e hx hy => dist_le_zero.1 (le_trans ?_ this)
exact le_ciSup h_bdd ⟨e, hx, hy⟩
/-- A bijective isometry sends midpoints to midpoints. -/
theorem map_midpoint (f : PE ≃ᵢ PF) (x y : PE) : f (midpoint ℝ x y) = midpoint ℝ (f x) (f y) := by
set e : PE ≃ᵢ PE :=
((f.trans <| (pointReflection ℝ <| midpoint ℝ (f x) (f y)).toIsometryEquiv).trans f.symm).trans
(pointReflection ℝ <| midpoint ℝ x y).toIsometryEquiv
have hx : e x = x := by simp [e]
have hy : e y = y := by simp [e]
have hm := e.midpoint_fixed hx hy
simp only [e, trans_apply] at hm
rwa [← eq_symm_apply, toIsometryEquiv_symm, pointReflection_symm, coe_toIsometryEquiv,
coe_toIsometryEquiv, pointReflection_self, symm_apply_eq, @pointReflection_fixed_iff] at hm
/-!
Since `f : PE ≃ᵢ PF` sends midpoints to midpoints, it is an affine map.
We define a conversion to a `ContinuousLinearEquiv` first, then a conversion to an `AffineMap`.
-/
/-- **Mazur-Ulam Theorem**: if `f` is an isometric bijection between two normed vector spaces
over `ℝ` and `f 0 = 0`, then `f` is a linear isometry equivalence. -/
def toRealLinearIsometryEquivOfMapZero (f : E ≃ᵢ F) (h0 : f 0 = 0) : E ≃ₗᵢ[ℝ] F :=
{ (AddMonoidHom.ofMapMidpoint ℝ ℝ f h0 f.map_midpoint).toRealLinearMap f.continuous, f with
norm_map' := fun x => show ‖f x‖ = ‖x‖ by simp only [← dist_zero_right, ← h0, f.dist_eq] }
@[simp]
theorem coe_toRealLinearIsometryEquivOfMapZero (f : E ≃ᵢ F) (h0 : f 0 = 0) :
⇑(f.toRealLinearIsometryEquivOfMapZero h0) = f :=
rfl
@[simp]
theorem coe_toRealLinearIsometryEquivOfMapZero_symm (f : E ≃ᵢ F) (h0 : f 0 = 0) :
⇑(f.toRealLinearIsometryEquivOfMapZero h0).symm = f.symm :=
rfl
/-- **Mazur-Ulam Theorem**: if `f` is an isometric bijection between two normed vector spaces
over `ℝ`, then `x ↦ f x - f 0` is a linear isometry equivalence. -/
def toRealLinearIsometryEquiv (f : E ≃ᵢ F) : E ≃ₗᵢ[ℝ] F :=
(f.trans (IsometryEquiv.addRight (f 0)).symm).toRealLinearIsometryEquivOfMapZero
(by simpa only [sub_eq_add_neg] using sub_self (f 0))
@[simp]
theorem toRealLinearIsometryEquiv_apply (f : E ≃ᵢ F) (x : E) :
(f.toRealLinearIsometryEquiv : E → F) x = f x - f 0 :=
(sub_eq_add_neg (f x) (f 0)).symm
@[simp]
theorem toRealLinearIsometryEquiv_symm_apply (f : E ≃ᵢ F) (y : F) :
(f.toRealLinearIsometryEquiv.symm : F → E) y = f.symm (y + f 0) :=
rfl
/-- **Mazur-Ulam Theorem**: if `f` is an isometric bijection between two normed add-torsors over
normed vector spaces over `ℝ`, then `f` is an affine isometry equivalence. -/
def toRealAffineIsometryEquiv (f : PE ≃ᵢ PF) : PE ≃ᵃⁱ[ℝ] PF :=
AffineIsometryEquiv.mk' f
((vaddConst (Classical.arbitrary PE)).trans <|
f.trans (vaddConst (f <| Classical.arbitrary PE)).symm).toRealLinearIsometryEquiv
(Classical.arbitrary PE) fun p => by simp
@[simp]
theorem coeFn_toRealAffineIsometryEquiv (f : PE ≃ᵢ PF) : ⇑f.toRealAffineIsometryEquiv = f :=
rfl
@[simp]
theorem coe_toRealAffineIsometryEquiv (f : PE ≃ᵢ PF) :
f.toRealAffineIsometryEquiv.toIsometryEquiv = f := by
ext
rfl
end IsometryEquiv
|
Analysis\NormedSpace\MStructure.lean | /-
Copyright (c) 2022 Christopher Hoskin. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Christopher Hoskin
-/
import Mathlib.Algebra.Ring.Idempotents
import Mathlib.Analysis.Normed.Group.Basic
import Mathlib.Order.Basic
import Mathlib.Tactic.NoncommRing
/-!
# M-structure
A projection P on a normed space X is said to be an L-projection (`IsLprojection`) if, for all `x`
in `X`,
$\|x\| = \|P x\| + \|(1 - P) x\|$.
A projection P on a normed space X is said to be an M-projection if, for all `x` in `X`,
$\|x\| = max(\|P x\|,\|(1 - P) x\|)$.
The L-projections on `X` form a Boolean algebra (`IsLprojection.Subtype.BooleanAlgebra`).
## TODO (Motivational background)
The M-projections on a normed space form a Boolean algebra.
The range of an L-projection on a normed space `X` is said to be an L-summand of `X`. The range of
an M-projection is said to be an M-summand of `X`.
When `X` is a Banach space, the Boolean algebra of L-projections is complete. Let `X` be a normed
space with dual `X^*`. A closed subspace `M` of `X` is said to be an M-ideal if the topological
annihilator `M^∘` is an L-summand of `X^*`.
M-ideal, M-summands and L-summands were introduced by Alfsen and Effros in [alfseneffros1972] to
study the structure of general Banach spaces. When `A` is a JB*-triple, the M-ideals of `A` are
exactly the norm-closed ideals of `A`. When `A` is a JBW*-triple with predual `X`, the M-summands of
`A` are exactly the weak*-closed ideals, and their pre-duals can be identified with the L-summands
of `X`. In the special case when `A` is a C*-algebra, the M-ideals are exactly the norm-closed
two-sided ideals of `A`, when `A` is also a W*-algebra the M-summands are exactly the weak*-closed
two-sided ideals of `A`.
## Implementation notes
The approach to showing that the L-projections form a Boolean algebra is inspired by
`MeasureTheory.MeasurableSpace`.
Instead of using `P : X →L[𝕜] X` to represent projections, we use an arbitrary ring `M` with a
faithful action on `X`. `ContinuousLinearMap.apply_module` can be used to recover the `X →L[𝕜] X`
special case.
## References
* [Behrends, M-structure and the Banach-Stone Theorem][behrends1979]
* [Harmand, Werner, Werner, M-ideals in Banach spaces and Banach algebras][harmandwernerwerner1993]
## Tags
M-summand, M-projection, L-summand, L-projection, M-ideal, M-structure
-/
variable (X : Type*) [NormedAddCommGroup X]
variable {M : Type*} [Ring M] [Module M X]
/-- A projection on a normed space `X` is said to be an L-projection if, for all `x` in `X`,
$\|x\| = \|P x\| + \|(1 - P) x\|$.
Note that we write `P • x` instead of `P x` for reasons described in the module docstring.
-/
structure IsLprojection (P : M) : Prop where
proj : IsIdempotentElem P
Lnorm : ∀ x : X, ‖x‖ = ‖P • x‖ + ‖(1 - P) • x‖
/-- A projection on a normed space `X` is said to be an M-projection if, for all `x` in `X`,
$\|x\| = max(\|P x\|,\|(1 - P) x\|)$.
Note that we write `P • x` instead of `P x` for reasons described in the module docstring.
-/
structure IsMprojection (P : M) : Prop where
proj : IsIdempotentElem P
Mnorm : ∀ x : X, ‖x‖ = max ‖P • x‖ ‖(1 - P) • x‖
variable {X}
namespace IsLprojection
-- Porting note: The literature always uses uppercase 'L' for L-projections
theorem Lcomplement {P : M} (h : IsLprojection X P) : IsLprojection X (1 - P) :=
⟨h.proj.one_sub, fun x => by
rw [add_comm, sub_sub_cancel]
exact h.Lnorm x⟩
theorem Lcomplement_iff (P : M) : IsLprojection X P ↔ IsLprojection X (1 - P) :=
⟨Lcomplement, fun h => sub_sub_cancel 1 P ▸ h.Lcomplement⟩
theorem commute [FaithfulSMul M X] {P Q : M} (h₁ : IsLprojection X P) (h₂ : IsLprojection X Q) :
Commute P Q := by
have PR_eq_RPR : ∀ R : M, IsLprojection X R → P * R = R * P * R := fun R h₃ => by
-- Porting note: Needed to fix function, which changes indent of following lines
refine @eq_of_smul_eq_smul _ X _ _ _ _ fun x => by
rw [← norm_sub_eq_zero_iff]
have e1 : ‖R • x‖ ≥ ‖R • x‖ + 2 • ‖(P * R) • x - (R * P * R) • x‖ :=
calc
‖R • x‖ = ‖R • P • R • x‖ + ‖(1 - R) • P • R • x‖ +
(‖(R * R) • x - R • P • R • x‖ + ‖(1 - R) • (1 - P) • R • x‖) := by
rw [h₁.Lnorm, h₃.Lnorm, h₃.Lnorm ((1 - P) • R • x), sub_smul 1 P, one_smul, smul_sub,
mul_smul]
_ = ‖R • P • R • x‖ + ‖(1 - R) • P • R • x‖ +
(‖R • x - R • P • R • x‖ + ‖((1 - R) * R) • x - (1 - R) • P • R • x‖) := by
rw [h₃.proj.eq, sub_smul 1 P, one_smul, smul_sub, mul_smul]
_ = ‖R • P • R • x‖ + ‖(1 - R) • P • R • x‖ +
(‖R • x - R • P • R • x‖ + ‖(1 - R) • P • R • x‖) := by
rw [sub_mul, h₃.proj.eq, one_mul, sub_self, zero_smul, zero_sub, norm_neg]
_ = ‖R • P • R • x‖ + ‖R • x - R • P • R • x‖ + 2 • ‖(1 - R) • P • R • x‖ := by abel
_ ≥ ‖R • x‖ + 2 • ‖(P * R) • x - (R * P * R) • x‖ := by
rw [GE.ge]
have :=
add_le_add_right (norm_le_insert' (R • x) (R • P • R • x)) (2 • ‖(1 - R) • P • R • x‖)
simpa only [mul_smul, sub_smul, one_smul] using this
rw [GE.ge] at e1
-- Porting note: Bump index in nth_rewrite
nth_rewrite 2 [← add_zero ‖R • x‖] at e1
rw [add_le_add_iff_left, two_smul, ← two_mul] at e1
rw [le_antisymm_iff]
refine ⟨?_, norm_nonneg _⟩
rwa [← mul_zero (2 : ℝ), mul_le_mul_left (show (0 : ℝ) < 2 by norm_num)] at e1
have QP_eq_QPQ : Q * P = Q * P * Q := by
have e1 : P * (1 - Q) = P * (1 - Q) - (Q * P - Q * P * Q) :=
calc
P * (1 - Q) = (1 - Q) * P * (1 - Q) := by rw [PR_eq_RPR (1 - Q) h₂.Lcomplement]
_ = P * (1 - Q) - (Q * P - Q * P * Q) := by noncomm_ring
rwa [eq_sub_iff_add_eq, add_right_eq_self, sub_eq_zero] at e1
show P * Q = Q * P
rw [QP_eq_QPQ, PR_eq_RPR Q h₂]
theorem mul [FaithfulSMul M X] {P Q : M} (h₁ : IsLprojection X P) (h₂ : IsLprojection X Q) :
IsLprojection X (P * Q) := by
refine ⟨IsIdempotentElem.mul_of_commute (h₁.commute h₂) h₁.proj h₂.proj, ?_⟩
intro x
refine le_antisymm ?_ ?_
· calc
‖x‖ = ‖(P * Q) • x + (x - (P * Q) • x)‖ := by rw [add_sub_cancel ((P * Q) • x) x]
_ ≤ ‖(P * Q) • x‖ + ‖x - (P * Q) • x‖ := by apply norm_add_le
_ = ‖(P * Q) • x‖ + ‖(1 - P * Q) • x‖ := by rw [sub_smul, one_smul]
· calc
‖x‖ = ‖P • Q • x‖ + (‖Q • x - P • Q • x‖ + ‖x - Q • x‖) := by
rw [h₂.Lnorm x, h₁.Lnorm (Q • x), sub_smul, one_smul, sub_smul, one_smul, add_assoc]
_ ≥ ‖P • Q • x‖ + ‖Q • x - P • Q • x + (x - Q • x)‖ :=
((add_le_add_iff_left ‖P • Q • x‖).mpr (norm_add_le (Q • x - P • Q • x) (x - Q • x)))
_ = ‖(P * Q) • x‖ + ‖(1 - P * Q) • x‖ := by
rw [sub_add_sub_cancel', sub_smul, one_smul, mul_smul]
theorem join [FaithfulSMul M X] {P Q : M} (h₁ : IsLprojection X P) (h₂ : IsLprojection X Q) :
IsLprojection X (P + Q - P * Q) := by
convert (Lcomplement_iff _).mp (h₁.Lcomplement.mul h₂.Lcomplement) using 1
noncomm_ring
-- Porting note: Advice is to explicitly name instances
-- https://github.com/leanprover-community/mathlib4/wiki/Porting-wiki#some-common-fixes
instance Subtype.hasCompl : HasCompl { f : M // IsLprojection X f } :=
⟨fun P => ⟨1 - P, P.prop.Lcomplement⟩⟩
@[simp]
theorem coe_compl (P : { P : M // IsLprojection X P }) : ↑Pᶜ = (1 : M) - ↑P :=
rfl
instance Subtype.inf [FaithfulSMul M X] : Inf { P : M // IsLprojection X P } :=
⟨fun P Q => ⟨P * Q, P.prop.mul Q.prop⟩⟩
@[simp]
theorem coe_inf [FaithfulSMul M X] (P Q : { P : M // IsLprojection X P }) :
↑(P ⊓ Q) = (↑P : M) * ↑Q :=
rfl
instance Subtype.sup [FaithfulSMul M X] : Sup { P : M // IsLprojection X P } :=
⟨fun P Q => ⟨P + Q - P * Q, P.prop.join Q.prop⟩⟩
@[simp]
theorem coe_sup [FaithfulSMul M X] (P Q : { P : M // IsLprojection X P }) :
↑(P ⊔ Q) = (↑P : M) + ↑Q - ↑P * ↑Q :=
rfl
instance Subtype.sdiff [FaithfulSMul M X] : SDiff { P : M // IsLprojection X P } :=
⟨fun P Q => ⟨P * (1 - Q), P.prop.mul Q.prop.Lcomplement⟩⟩
@[simp]
theorem coe_sdiff [FaithfulSMul M X] (P Q : { P : M // IsLprojection X P }) :
↑(P \ Q) = (↑P : M) * (1 - ↑Q) :=
rfl
instance Subtype.partialOrder [FaithfulSMul M X] :
PartialOrder { P : M // IsLprojection X P } where
le P Q := (↑P : M) = ↑(P ⊓ Q)
le_refl P := by simpa only [coe_inf, ← sq] using P.prop.proj.eq.symm
le_trans P Q R h₁ h₂ := by
simp only [coe_inf] at h₁ h₂ ⊢
rw [h₁, mul_assoc, ← h₂]
le_antisymm P Q h₁ h₂ := Subtype.eq (by convert (P.prop.commute Q.prop).eq)
theorem le_def [FaithfulSMul M X] (P Q : { P : M // IsLprojection X P }) :
P ≤ Q ↔ (P : M) = ↑(P ⊓ Q) :=
Iff.rfl
instance Subtype.zero : Zero { P : M // IsLprojection X P } :=
⟨⟨0, ⟨by rw [IsIdempotentElem, zero_mul], fun x => by
simp only [zero_smul, norm_zero, sub_zero, one_smul, zero_add]⟩⟩⟩
@[simp]
theorem coe_zero : ↑(0 : { P : M // IsLprojection X P }) = (0 : M) :=
rfl
instance Subtype.one : One { P : M // IsLprojection X P } :=
⟨⟨1, sub_zero (1 : M) ▸ (0 : { P : M // IsLprojection X P }).prop.Lcomplement⟩⟩
@[simp]
theorem coe_one : ↑(1 : { P : M // IsLprojection X P }) = (1 : M) :=
rfl
instance Subtype.boundedOrder [FaithfulSMul M X] :
BoundedOrder { P : M // IsLprojection X P } where
top := 1
le_top P := (mul_one (P : M)).symm
bot := 0
bot_le P := (zero_mul (P : M)).symm
@[simp]
theorem coe_bot [FaithfulSMul M X] :
-- Porting note: Manual correction of name required here
↑(BoundedOrder.toOrderBot.toBot.bot : { P : M // IsLprojection X P }) = (0 : M) :=
rfl
@[simp]
theorem coe_top [FaithfulSMul M X] :
-- Porting note: Manual correction of name required here
↑(BoundedOrder.toOrderTop.toTop.top : { P : M // IsLprojection X P }) = (1 : M) :=
rfl
theorem compl_mul {P : { P : M // IsLprojection X P }} {Q : M} : ↑Pᶜ * Q = Q - ↑P * Q := by
rw [coe_compl, sub_mul, one_mul]
theorem mul_compl_self {P : { P : M // IsLprojection X P }} : (↑P : M) * ↑Pᶜ = 0 := by
rw [coe_compl, mul_sub, mul_one, P.prop.proj.eq, sub_self]
theorem distrib_lattice_lemma [FaithfulSMul M X] {P Q R : { P : M // IsLprojection X P }} :
((↑P : M) + ↑Pᶜ * R) * (↑P + ↑Q * ↑R * ↑Pᶜ) = ↑P + ↑Q * ↑R * ↑Pᶜ := by
rw [add_mul, mul_add, mul_add, (mul_assoc _ (R : M) (↑Q * ↑R * ↑Pᶜ)),
← mul_assoc (R : M) (↑Q * ↑R) _, ← coe_inf Q, (Pᶜ.prop.commute R.prop).eq,
((Q ⊓ R).prop.commute Pᶜ.prop).eq, (R.prop.commute (Q ⊓ R).prop).eq, coe_inf Q,
mul_assoc (Q : M), ← mul_assoc, mul_assoc (R : M), (Pᶜ.prop.commute P.prop).eq, mul_compl_self,
zero_mul, mul_zero, zero_add, add_zero, ← mul_assoc, P.prop.proj.eq,
R.prop.proj.eq, ← coe_inf Q, mul_assoc, ((Q ⊓ R).prop.commute Pᶜ.prop).eq, ← mul_assoc,
Pᶜ.prop.proj.eq]
-- Porting note: In mathlib3 we were able to directly show that `{ P : M // IsLprojection X P }` was
-- an instance of a `DistribLattice`. Trying to do that in mathlib4 fails with "error:
-- (deterministic) timeout at 'whnf', maximum number of heartbeats (800000) has been reached"
-- My workaround is to show instance Lattice first
instance [FaithfulSMul M X] : Lattice { P : M // IsLprojection X P } where
le_sup_left P Q := by
rw [le_def, coe_inf, coe_sup, ← add_sub, mul_add, mul_sub, ← mul_assoc, P.prop.proj.eq,
sub_self, add_zero]
le_sup_right P Q := by
rw [le_def, coe_inf, coe_sup, ← add_sub, mul_add, mul_sub, (P.prop.commute Q.prop).eq,
← mul_assoc, Q.prop.proj.eq, add_sub_cancel]
sup_le P Q R := by
rw [le_def, le_def, le_def, coe_inf, coe_inf, coe_sup, coe_inf, coe_sup, ← add_sub, add_mul,
sub_mul, mul_assoc]
intro h₁ h₂
rw [← h₂, ← h₁]
inf_le_left P Q := by
rw [le_def, coe_inf, coe_inf, coe_inf, mul_assoc, (Q.prop.commute P.prop).eq, ← mul_assoc,
P.prop.proj.eq]
inf_le_right P Q := by rw [le_def, coe_inf, coe_inf, coe_inf, mul_assoc, Q.prop.proj.eq]
le_inf P Q R := by
rw [le_def, le_def, le_def, coe_inf, coe_inf, coe_inf, coe_inf, ← mul_assoc]
intro h₁ h₂
rw [← h₁, ← h₂]
instance Subtype.distribLattice [FaithfulSMul M X] :
DistribLattice { P : M // IsLprojection X P } where
le_sup_inf P Q R := by
have e₁ : ↑((P ⊔ Q) ⊓ (P ⊔ R)) = ↑P + ↑Q * (R : M) * ↑Pᶜ := by
rw [coe_inf, coe_sup, coe_sup, ← add_sub, ← add_sub, ← compl_mul, ← compl_mul, add_mul,
mul_add, (Pᶜ.prop.commute Q.prop).eq, mul_add, ← mul_assoc, mul_assoc (Q : M),
(Pᶜ.prop.commute P.prop).eq, mul_compl_self, zero_mul, mul_zero,
zero_add, add_zero, ← mul_assoc, mul_assoc (Q : M), P.prop.proj.eq, Pᶜ.prop.proj.eq,
mul_assoc, (Pᶜ.prop.commute R.prop).eq, ← mul_assoc]
have e₂ : ↑((P ⊔ Q) ⊓ (P ⊔ R)) * ↑(P ⊔ Q ⊓ R) = (P : M) + ↑Q * ↑R * ↑Pᶜ := by
rw [coe_inf, coe_sup, coe_sup, coe_sup, ← add_sub, ← add_sub, ← add_sub, ← compl_mul, ←
compl_mul, ← compl_mul, (Pᶜ.prop.commute (Q ⊓ R).prop).eq, coe_inf, mul_assoc,
distrib_lattice_lemma, (Q.prop.commute R.prop).eq, distrib_lattice_lemma]
rw [le_def, e₁, coe_inf, e₂]
instance Subtype.BooleanAlgebra [FaithfulSMul M X] :
BooleanAlgebra { P : M // IsLprojection X P } :=
-- Porting note: use explicitly specified instance names
{ IsLprojection.Subtype.hasCompl,
IsLprojection.Subtype.sdiff,
IsLprojection.Subtype.boundedOrder with
inf_compl_le_bot := fun P =>
(Subtype.ext (by rw [coe_inf, coe_compl, coe_bot, ← coe_compl, mul_compl_self])).le
top_le_sup_compl := fun P =>
(Subtype.ext
(by
rw [coe_top, coe_sup, coe_compl, add_sub_cancel, ← coe_compl, mul_compl_self,
sub_zero])).le
sdiff_eq := fun P Q => Subtype.ext <| by rw [coe_sdiff, ← coe_compl, coe_inf] }
end IsLprojection
|
Analysis\NormedSpace\Pointwise.lean | /-
Copyright (c) 2021 Sébastien Gouëzel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sébastien Gouëzel, Yaël Dillies
-/
import Mathlib.Analysis.Normed.Group.Pointwise
import Mathlib.Analysis.NormedSpace.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] [BoundedSMul 𝕜 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] [BoundedSMul 𝕜 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 :=
(mul_le_mul (mem_closedBall_zero_iff.1 hr) (mem_closedBall_zero_iff.1 (hR zs))
(norm_nonneg _) (div_pos εpos Rpos).le)
_ = ε := by field_simp
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_lt]), ← 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_lt 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_lt 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_le (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_lt' fun r h => ?_
cases' r with r
· exact add_lt_top.2 ⟨lt_top_iff_ne_top.2 <| infEdist_ne_top ⟨z, self_subset_thickening hδ _ hz⟩,
ofReal_lt_top⟩
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_lt δ 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_closedUnitBall (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_closedUnitBall_of_nonneg {r : ℝ} (hr : 0 ≤ r) :
r • closedBall (0 : E) 1 = closedBall (0 : E) r := by
rw [smul_closedUnitBall, Real.norm_of_nonneg hr]
/-- In a nontrivial real normed space, a sphere is nonempty if and only if its radius is
nonnegative. -/
@[simp]
theorem NormedSpace.sphere_nonempty [Nontrivial E] {x : E} {r : ℝ} :
(sphere x r).Nonempty ↔ 0 ≤ r := by
obtain ⟨y, hy⟩ := exists_ne x
refine ⟨fun h => nonempty_closedBall.1 (h.mono sphere_subset_closedBall), fun hr =>
⟨r • ‖y - x‖⁻¹ • (y - x) + x, ?_⟩⟩
have : ‖y - x‖ ≠ 0 := by simpa [sub_eq_zero]
simp only [mem_sphere_iff_norm, add_sub_cancel_right, norm_smul, Real.norm_eq_abs, norm_inv,
norm_norm, ne_eq, norm_eq_zero]
simp only [abs_norm, ne_eq, norm_eq_zero]
rw [inv_mul_cancel this, mul_one, abs_eq_self.mpr 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_closedUnitBall, Real.norm_of_nonneg hr, vadd_closedBall_zero]
end NormedAddCommGroup
|
Analysis\NormedSpace\RCLike.lean | /-
Copyright (c) 2021 Kalle Kytölä. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kalle Kytölä
-/
import Mathlib.Analysis.RCLike.Basic
import Mathlib.Analysis.NormedSpace.OperatorNorm.Basic
import Mathlib.Analysis.NormedSpace.Pointwise
/-!
# 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]
field_simp [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]
field_simp [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 : E →L[𝕜] 𝕜) (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
@[deprecated (since := "2024-02-02")]
alias ContinuousLinearMap.op_norm_bound_of_ball_bound :=
ContinuousLinearMap.opNorm_bound_of_ball_bound
variable (𝕜)
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
|
Analysis\NormedSpace\Real.lean | /-
Copyright (c) 2020 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov, Patrick Massot, Eric Wieser, Yaël Dillies
-/
import Mathlib.Analysis.Normed.Module.Basic
import Mathlib.Topology.Algebra.Module.Basic
/-!
# 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_closed_unit_ball (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
cases' hr.lt_or_lt 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_right 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_ball]
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, abs_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
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_ball]
@[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
|
Analysis\NormedSpace\RieszLemma.lean | /-
Copyright (c) 2019 Jean Lo. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jean Lo, Yury Kudryashov
-/
import Mathlib.Analysis.NormedSpace.Real
import Mathlib.Analysis.Seminorm
import Mathlib.Topology.MetricSpace.HausdorffDistance
/-!
# Applications of the Hausdorff distance in normed spaces
Riesz's lemma, stated for a normed space over a normed field: for any
closed proper subspace `F` of `E`, there is a nonzero `x` such that `‖x - F‖`
is at least `r * ‖x‖` for any `r < 1`. This is `riesz_lemma`.
In a nontrivially normed field (with an element `c` of norm `> 1`) and any `R > ‖c‖`, one can
guarantee `‖x‖ ≤ R` and `‖x - y‖ ≥ 1` for any `y` in `F`. This is `riesz_lemma_of_norm_lt`.
A further lemma, `Metric.closedBall_infDist_compl_subset_closure`, finds a *closed* ball within
the closure of a set `s` of optimal distance from a point in `x` to the frontier of `s`.
-/
open Set Metric
open Topology
variable {𝕜 : Type*} [NormedField 𝕜]
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E]
variable {F : Type*} [SeminormedAddCommGroup F] [NormedSpace ℝ F]
/-- Riesz's lemma, which usually states that it is possible to find a
vector with norm 1 whose distance to a closed proper subspace is
arbitrarily close to 1. The statement here is in terms of multiples of
norms, since in general the existence of an element of norm exactly 1
is not guaranteed. For a variant giving an element with norm in `[1, R]`, see
`riesz_lemma_of_norm_lt`. -/
theorem riesz_lemma {F : Subspace 𝕜 E} (hFc : IsClosed (F : Set E)) (hF : ∃ x : E, x ∉ F) {r : ℝ}
(hr : r < 1) : ∃ x₀ : E, x₀ ∉ F ∧ ∀ y ∈ F, r * ‖x₀‖ ≤ ‖x₀ - y‖ := by
classical
obtain ⟨x, hx⟩ : ∃ x : E, x ∉ F := hF
let d := Metric.infDist x F
have hFn : (F : Set E).Nonempty := ⟨_, F.zero_mem⟩
have hdp : 0 < d :=
lt_of_le_of_ne Metric.infDist_nonneg fun heq =>
hx ((hFc.mem_iff_infDist_zero hFn).2 heq.symm)
let r' := max r 2⁻¹
have hr' : r' < 1 := by
simp only [r', max_lt_iff, hr, true_and]
norm_num
have hlt : 0 < r' := lt_of_lt_of_le (by norm_num) (le_max_right r 2⁻¹)
have hdlt : d < d / r' := (lt_div_iff hlt).mpr ((mul_lt_iff_lt_one_right hdp).2 hr')
obtain ⟨y₀, hy₀F, hxy₀⟩ : ∃ y ∈ F, dist x y < d / r' := (Metric.infDist_lt_iff hFn).mp hdlt
have x_ne_y₀ : x - y₀ ∉ F := by
by_contra h
have : x - y₀ + y₀ ∈ F := F.add_mem h hy₀F
simp only [neg_add_cancel_right, sub_eq_add_neg] at this
exact hx this
refine ⟨x - y₀, x_ne_y₀, fun y hy => le_of_lt ?_⟩
have hy₀y : y₀ + y ∈ F := F.add_mem hy₀F hy
calc
r * ‖x - y₀‖ ≤ r' * ‖x - y₀‖ := by gcongr; apply le_max_left
_ < d := by
rw [← dist_eq_norm]
exact (lt_div_iff' hlt).1 hxy₀
_ ≤ dist x (y₀ + y) := Metric.infDist_le_dist_of_mem hy₀y
_ = ‖x - y₀ - y‖ := by rw [sub_sub, dist_eq_norm]
/--
A version of Riesz lemma: given a strict closed subspace `F`, one may find an element of norm `≤ R`
which is at distance at least `1` of every element of `F`. Here, `R` is any given constant
strictly larger than the norm of an element of norm `> 1`. For a version without an `R`, see
`riesz_lemma`.
Since we are considering a general nontrivially normed field, there may be a gap in possible norms
(for instance no element of norm in `(1,2)`). Hence, we can not allow `R` arbitrarily close to `1`,
and require `R > ‖c‖` for some `c : 𝕜` with norm `> 1`.
-/
theorem riesz_lemma_of_norm_lt {c : 𝕜} (hc : 1 < ‖c‖) {R : ℝ} (hR : ‖c‖ < R) {F : Subspace 𝕜 E}
(hFc : IsClosed (F : Set E)) (hF : ∃ x : E, x ∉ F) :
∃ x₀ : E, ‖x₀‖ ≤ R ∧ ∀ y ∈ F, 1 ≤ ‖x₀ - y‖ := by
have Rpos : 0 < R := (norm_nonneg _).trans_lt hR
have : ‖c‖ / R < 1 := by
rw [div_lt_iff Rpos]
simpa using hR
rcases riesz_lemma hFc hF this with ⟨x, xF, hx⟩
have x0 : x ≠ 0 := fun H => by simp [H] at xF
obtain ⟨d, d0, dxlt, ledx, -⟩ :
∃ d : 𝕜, d ≠ 0 ∧ ‖d • x‖ < R ∧ R / ‖c‖ ≤ ‖d • x‖ ∧ ‖d‖⁻¹ ≤ R⁻¹ * ‖c‖ * ‖x‖ :=
rescale_to_shell hc Rpos x0
refine ⟨d • x, dxlt.le, fun y hy => ?_⟩
set y' := d⁻¹ • y
have yy' : y = d • y' := by simp [y', smul_smul, mul_inv_cancel d0]
calc
1 = ‖c‖ / R * (R / ‖c‖) := by field_simp [Rpos.ne', (zero_lt_one.trans hc).ne']
_ ≤ ‖c‖ / R * ‖d • x‖ := by gcongr
_ = ‖d‖ * (‖c‖ / R * ‖x‖) := by
simp only [norm_smul]
ring
_ ≤ ‖d‖ * ‖x - y'‖ := by gcongr; exact hx y' (by simp [Submodule.smul_mem _ _ hy])
_ = ‖d • x - y‖ := by rw [yy', ← smul_sub, norm_smul]
theorem Metric.closedBall_infDist_compl_subset_closure {x : F} {s : Set F} (hx : x ∈ s) :
closedBall x (infDist x sᶜ) ⊆ closure s := by
rcases eq_or_ne (infDist x sᶜ) 0 with h₀ | h₀
· rw [h₀, closedBall_zero']
exact closure_mono (singleton_subset_iff.2 hx)
· rw [← closure_ball x h₀]
exact closure_mono ball_infDist_compl_subset
|
Analysis\NormedSpace\SphereNormEquiv.lean | /-
Copyright (c) 2023 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov
-/
import Mathlib.Analysis.Normed.Module.Basic
/-!
# 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, hr.le, abs_of_pos hr, hr.ne']
continuous_toFun := by
refine .prod_mk (.codRestrict (.smul (.inv₀ ?_ ?_) ?_) _) ?_
· fun_prop
· simp
· fun_prop
· fun_prop
continuous_invFun := by apply Continuous.subtype_mk (by fun_prop)
|
Analysis\NormedSpace\HahnBanach\Extension.lean | /-
Copyright (c) 2020 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov, Heather Macbeth
-/
import Mathlib.Analysis.Convex.Cone.Extension
import Mathlib.Analysis.NormedSpace.RCLike
import Mathlib.Analysis.NormedSpace.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 : p →L[ℝ] ℝ) :
∃ g : E →L[ℝ] ℝ, (∀ 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 -- Porting note: placeholder filled here
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*} [RCLike 𝕜] {E F : Type*}
[SeminormedAddCommGroup E] [NormedSpace 𝕜 E]
[NormedAddCommGroup F] [NormedSpace 𝕜 F]
/-- **Hahn-Banach theorem** for continuous linear functions over `𝕜` satisfying `RCLike 𝕜`. -/
theorem exists_extension_norm_eq (p : Subspace 𝕜 E) (f : p →L[𝕜] 𝕜) :
∃ g : E →L[𝕜] 𝕜, (∀ x : p, g x = f x) ∧ ‖g‖ = ‖f‖ := by
letI : Module ℝ E := RestrictScalars.module ℝ 𝕜 E
letI : IsScalarTower ℝ 𝕜 E := RestrictScalars.isScalarTower _ _ _
letI : NormedSpace ℝ E := NormedSpace.restrictScalars _ 𝕜 _
-- Let `fr: p →L[ℝ] ℝ` 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 : E →L[ℝ] ℝ`.
rcases Real.exists_extension_norm_eq (p.restrictScalars ℝ) fr with ⟨g, ⟨hextends, hnormeq⟩⟩
-- Now `g` can be extended to the `E →L[𝕜] 𝕜` we need.
refine ⟨g.extendTo𝕜, ?_⟩
-- It is an extension of `f`.
have h : ∀ x : p, g.extendTo𝕜 x = f x := by
intro x
-- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
erw [ContinuousLinearMap.extendTo𝕜_apply, ← Submodule.coe_smul, hextends, 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 leanprover/lean4#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, eq_self_iff_true, 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 FiniteDimensional
/-- 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
set b := 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
open scoped Classical
theorem coord_norm' {x : E} (h : x ≠ 0) : ‖(‖x‖ : 𝕜) • coord 𝕜 x h‖ = 1 := by
#adaptation_note
/--
`set_option maxSynthPendingDepth 2` required after https://github.com/leanprover/lean4/pull/4119
Alternatively, we can add:
```
let X : SeminormedAddCommGroup (↥(span 𝕜 {x}) →L[𝕜] 𝕜) := inferInstance
have : BoundedSMul 𝕜 (↥(span 𝕜 {x}) →L[𝕜] 𝕜) := @NormedSpace.boundedSMul 𝕜 _ _ X _
```
-/
set_option maxSynthPendingDepth 2 in
rw [norm_smul (α := 𝕜) (x := coord 𝕜 x h), RCLike.norm_coe_norm, coord_norm,
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 : E →L[𝕜] 𝕜, ‖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 [coe_mk]
_ = ((‖x‖ : 𝕜) • coord 𝕜 x h) (⟨x, mem_span_singleton_self x⟩ : 𝕜 ∙ x) := by rw [← hg.1]
_ = ‖x‖ := by simp
/-- 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 : E →L[𝕜] 𝕜, ‖g‖ = 1 ∧ g x = ‖x‖ := by
by_cases hx : x = 0
· obtain ⟨y, hy⟩ := exists_ne (0 : E)
obtain ⟨g, hg⟩ : ∃ g : E →L[𝕜] 𝕜, ‖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 can not be improved for the trivial
vector space). -/
theorem exists_dual_vector'' (x : E) : ∃ g : E →L[𝕜] 𝕜, ‖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
|
Analysis\NormedSpace\HahnBanach\SeparatingDual.lean | /-
Copyright (c) 2023 Sébastien Gouëzel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sébastien Gouëzel
-/
import Mathlib.Analysis.NormedSpace.HahnBanach.Extension
import Mathlib.Analysis.NormedSpace.HahnBanach.Separation
import Mathlib.LinearAlgebra.Dual
import Mathlib.Analysis.Normed.Operator.BoundedLinearMaps
/-!
# Spaces with separating dual
We introduce a typeclass `SeparatingDual R V`, registering that the points of the topological
module `V` over `R` can be separated by continuous linear forms.
This property is satisfied for normed spaces over `ℝ` or `ℂ` (by the analytic Hahn-Banach theorem)
and for locally convex topological spaces over `ℝ` (by the geometric Hahn-Banach theorem).
Under the assumption `SeparatingDual R V`, we show in
`SeparatingDual.exists_continuousLinearMap_apply_eq` that the group of continuous linear
equivalences acts transitively on the set of nonzero vectors.
-/
/-- When `E` is a topological module over a topological ring `R`, the class `SeparatingDual R E`
registers that continuous linear forms on `E` separate points of `E`. -/
@[mk_iff separatingDual_def]
class SeparatingDual (R V : Type*) [Ring R] [AddCommGroup V] [TopologicalSpace V]
[TopologicalSpace R] [Module R V] : Prop :=
/-- Any nonzero vector can be mapped by a continuous linear map to a nonzero scalar. -/
exists_ne_zero' : ∀ (x : V), x ≠ 0 → ∃ f : V →L[R] R, f x ≠ 0
instance {E : Type*} [TopologicalSpace E] [AddCommGroup E] [TopologicalAddGroup E]
[Module ℝ E] [ContinuousSMul ℝ E] [LocallyConvexSpace ℝ E] [T1Space E] : SeparatingDual ℝ E :=
⟨fun x hx ↦ by
rcases geometric_hahn_banach_point_point hx.symm with ⟨f, hf⟩
simp only [map_zero] at hf
exact ⟨f, hf.ne'⟩⟩
instance {E 𝕜 : Type*} [RCLike 𝕜] [NormedAddCommGroup E] [NormedSpace 𝕜 E] : SeparatingDual 𝕜 E :=
⟨fun x hx ↦ by
rcases exists_dual_vector 𝕜 x hx with ⟨f, -, hf⟩
refine ⟨f, ?_⟩
simpa [hf] using hx⟩
namespace SeparatingDual
section Ring
variable {R V : Type*} [Ring R] [AddCommGroup V] [TopologicalSpace V]
[TopologicalSpace R] [Module R V] [SeparatingDual R V]
lemma exists_ne_zero {x : V} (hx : x ≠ 0) :
∃ f : V →L[R] R, f x ≠ 0 :=
exists_ne_zero' x hx
theorem exists_separating_of_ne {x y : V} (h : x ≠ y) :
∃ f : V →L[R] R, f x ≠ f y := by
rcases exists_ne_zero (R := R) (sub_ne_zero_of_ne h) with ⟨f, hf⟩
exact ⟨f, by simpa [sub_ne_zero] using hf⟩
protected theorem t1Space [T1Space R] : T1Space V := by
apply t1Space_iff_exists_open.2 (fun x y hxy ↦ ?_)
rcases exists_separating_of_ne (R := R) hxy with ⟨f, hf⟩
exact ⟨f ⁻¹' {f y}ᶜ, isOpen_compl_singleton.preimage f.continuous, hf, by simp⟩
protected theorem t2Space [T2Space R] : T2Space V := by
apply (t2Space_iff _).2 (fun {x} {y} hxy ↦ ?_)
rcases exists_separating_of_ne (R := R) hxy with ⟨f, hf⟩
exact separated_by_continuous f.continuous hf
end Ring
section Field
variable {R V : Type*} [Field R] [AddCommGroup V] [TopologicalSpace R] [TopologicalSpace V]
[TopologicalRing R] [TopologicalAddGroup V] [Module R V] [SeparatingDual R V]
-- TODO (@alreadydone): this could generalize to CommRing R if we were to add a section
theorem _root_.separatingDual_iff_injective : SeparatingDual R V ↔
Function.Injective (ContinuousLinearMap.coeLM (R := R) R (M := V) (N₃ := R)).flip := by
simp_rw [separatingDual_def, Ne, injective_iff_map_eq_zero]
congrm ∀ v, ?_
rw [not_imp_comm, LinearMap.ext_iff]
push_neg; rfl
open Function in
/-- Given a finite-dimensional subspace `W` of a space `V` with separating dual, any
linear functional on `W` extends to a continuous linear functional on `V`.
This is stated more generally for an injective linear map from `W` to `V`. -/
theorem dualMap_surjective_iff {W} [AddCommGroup W] [Module R W] [FiniteDimensional R W]
{f : W →ₗ[R] V} : Surjective (f.dualMap ∘ ContinuousLinearMap.toLinearMap) ↔ Injective f := by
constructor <;> intro hf
· exact LinearMap.dualMap_surjective_iff.mp hf.of_comp
have := (separatingDual_iff_injective.mp ‹_›).comp hf
rw [← LinearMap.coe_comp] at this
exact LinearMap.flip_surjective_iff₁.mpr this
lemma exists_eq_one {x : V} (hx : x ≠ 0) :
∃ f : V →L[R] R, f x = 1 := by
rcases exists_ne_zero (R := R) hx with ⟨f, hf⟩
exact ⟨(f x)⁻¹ • f, inv_mul_cancel hf⟩
theorem exists_eq_one_ne_zero_of_ne_zero_pair {x y : V} (hx : x ≠ 0) (hy : y ≠ 0) :
∃ f : V →L[R] R, f x = 1 ∧ f y ≠ 0 := by
obtain ⟨u, ux⟩ : ∃ u : V →L[R] R, u x = 1 := exists_eq_one hx
rcases ne_or_eq (u y) 0 with uy|uy
· exact ⟨u, ux, uy⟩
obtain ⟨v, vy⟩ : ∃ v : V →L[R] R, v y = 1 := exists_eq_one hy
rcases ne_or_eq (v x) 0 with vx|vx
· exact ⟨(v x)⁻¹ • v, inv_mul_cancel vx, show (v x)⁻¹ * v y ≠ 0 by simp [vx, vy]⟩
· exact ⟨u + v, by simp [ux, vx], by simp [uy, vy]⟩
/-- In a topological vector space with separating dual, the group of continuous linear equivalences
acts transitively on the set of nonzero vectors: given two nonzero vectors `x` and `y`, there
exists `A : V ≃L[R] V` mapping `x` to `y`. -/
theorem exists_continuousLinearEquiv_apply_eq [ContinuousSMul R V]
{x y : V} (hx : x ≠ 0) (hy : y ≠ 0) :
∃ A : V ≃L[R] V, A x = y := by
obtain ⟨G, Gx, Gy⟩ : ∃ G : V →L[R] R, G x = 1 ∧ G y ≠ 0 :=
exists_eq_one_ne_zero_of_ne_zero_pair hx hy
let A : V ≃L[R] V :=
{ toFun := fun z ↦ z + G z • (y - x)
invFun := fun z ↦ z + ((G y) ⁻¹ * G z) • (x - y)
map_add' := fun a b ↦ by simp [add_smul]; abel
map_smul' := by simp [smul_smul]
left_inv := fun z ↦ by
simp only [id_eq, eq_mpr_eq_cast, RingHom.id_apply, smul_eq_mul, AddHom.toFun_eq_coe,
-- Note: #8386 had to change `map_smulₛₗ` into `map_smulₛₗ _`
AddHom.coe_mk, map_add, map_smulₛₗ _, map_sub, Gx, mul_sub, mul_one, add_sub_cancel]
rw [mul_comm (G z), ← mul_assoc, inv_mul_cancel Gy]
simp only [smul_sub, one_mul]
abel
right_inv := fun z ↦ by
-- Note: #8386 had to change `map_smulₛₗ` into `map_smulₛₗ _`
simp only [map_add, map_smulₛₗ _, map_mul, map_inv₀, RingHom.id_apply, map_sub, Gx,
smul_eq_mul, mul_sub, mul_one]
rw [mul_comm _ (G y), ← mul_assoc, mul_inv_cancel Gy]
simp only [smul_sub, one_mul, add_sub_cancel]
abel
continuous_toFun := continuous_id.add (G.continuous.smul continuous_const)
continuous_invFun :=
continuous_id.add ((continuous_const.mul G.continuous).smul continuous_const) }
exact ⟨A, show x + G x • (y - x) = y by simp [Gx]⟩
open Filter
open scoped Topology
section
variable (𝕜 E F : Type*) [NontriviallyNormedField 𝕜] [NormedAddCommGroup E] [NormedSpace 𝕜 E]
[NormedAddCommGroup F] [NormedSpace 𝕜 F] [SeparatingDual 𝕜 E] [Nontrivial E]
/-- If a space of linear maps from `E` to `F` is complete, and `E` is nontrivial, then `F` is
complete. -/
lemma completeSpace_of_completeSpace_continuousLinearMap [CompleteSpace (E →L[𝕜] F)] :
CompleteSpace F := by
refine Metric.complete_of_cauchySeq_tendsto fun f hf => ?_
obtain ⟨v, hv⟩ : ∃ (v : E), v ≠ 0 := exists_ne 0
obtain ⟨φ, hφ⟩ : ∃ φ : E →L[𝕜] 𝕜, φ v = 1 := exists_eq_one hv
let g : ℕ → (E →L[𝕜] F) := fun n ↦ ContinuousLinearMap.smulRightL 𝕜 E F φ (f n)
have : CauchySeq g := (ContinuousLinearMap.smulRightL 𝕜 E F φ).lipschitz.cauchySeq_comp hf
obtain ⟨a, ha⟩ : ∃ a, Tendsto g atTop (𝓝 a) := cauchy_iff_exists_le_nhds.mp this
refine ⟨a v, ?_⟩
have : Tendsto (fun n ↦ g n v) atTop (𝓝 (a v)) := by
have : Continuous (fun (i : E →L[𝕜] F) ↦ i v) := by fun_prop
exact (this.tendsto _).comp ha
simpa [g, ContinuousLinearMap.smulRightL, hφ]
lemma completeSpace_continuousLinearMap_iff :
CompleteSpace (E →L[𝕜] F) ↔ CompleteSpace F :=
⟨fun _h ↦ completeSpace_of_completeSpace_continuousLinearMap 𝕜 E F, fun _h ↦ inferInstance⟩
open ContinuousMultilinearMap
variable {ι : Type*} [Finite ι] {M : ι → Type*} [∀ i, NormedAddCommGroup (M i)]
[∀ i, NormedSpace 𝕜 (M i)] [∀ i, SeparatingDual 𝕜 (M i)]
/-- If a space of multilinear maps from `Π i, E i` to `F` is complete, and each `E i` has a nonzero
element, then `F` is complete. -/
lemma completeSpace_of_completeSpace_continuousMultilinearMap
[CompleteSpace (ContinuousMultilinearMap 𝕜 M F)]
{m : ∀ i, M i} (hm : ∀ i, m i ≠ 0) : CompleteSpace F := by
refine Metric.complete_of_cauchySeq_tendsto fun f hf => ?_
have : ∀ i, ∃ φ : M i →L[𝕜] 𝕜, φ (m i) = 1 := fun i ↦ exists_eq_one (hm i)
choose φ hφ using this
cases nonempty_fintype ι
let g : ℕ → (ContinuousMultilinearMap 𝕜 M F) := fun n ↦
compContinuousLinearMapL φ
(ContinuousMultilinearMap.smulRightL 𝕜 _ F ((ContinuousMultilinearMap.mkPiAlgebra 𝕜 ι 𝕜)) (f n))
have : CauchySeq g := by
refine (ContinuousLinearMap.lipschitz _).cauchySeq_comp ?_
exact (ContinuousLinearMap.lipschitz _).cauchySeq_comp hf
obtain ⟨a, ha⟩ : ∃ a, Tendsto g atTop (𝓝 a) := cauchy_iff_exists_le_nhds.mp this
refine ⟨a m, ?_⟩
have : Tendsto (fun n ↦ g n m) atTop (𝓝 (a m)) := ((continuous_eval_const _).tendsto _).comp ha
simpa [g, hφ]
lemma completeSpace_continuousMultilinearMap_iff {m : ∀ i, M i} (hm : ∀ i, m i ≠ 0) :
CompleteSpace (ContinuousMultilinearMap 𝕜 M F) ↔ CompleteSpace F :=
⟨fun _h ↦ completeSpace_of_completeSpace_continuousMultilinearMap 𝕜 F hm, fun _h ↦ inferInstance⟩
end
end Field
end SeparatingDual
|
Analysis\NormedSpace\HahnBanach\Separation.lean | /-
Copyright (c) 2022 Bhavik Mehta. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Bhavik Mehta, Yaël Dillies
-/
import Mathlib.Analysis.Convex.Cone.Extension
import Mathlib.Analysis.Convex.Gauge
import Mathlib.Topology.Algebra.Module.FiniteDimension
import Mathlib.Topology.Algebra.Module.LocallyConvex
import Mathlib.Analysis.RCLike.Basic
import Mathlib.Analysis.NormedSpace.Extend
/-!
# Separation Hahn-Banach theorem
In this file we prove the geometric Hahn-Banach theorem. For any two disjoint convex sets, there
exists a continuous linear functional separating them, geometrically meaning that we can intercalate
a plane between them.
We provide many variations to stricten the result under more assumptions on the convex sets:
* `geometric_hahn_banach_open`: One set is open. Weak separation.
* `geometric_hahn_banach_open_point`, `geometric_hahn_banach_point_open`: One set is open, the
other is a singleton. Weak separation.
* `geometric_hahn_banach_open_open`: Both sets are open. Semistrict separation.
* `geometric_hahn_banach_compact_closed`, `geometric_hahn_banach_closed_compact`: One set is closed,
the other one is compact. Strict separation.
* `geometric_hahn_banach_point_closed`, `geometric_hahn_banach_closed_point`: One set is closed, the
other one is a singleton. Strict separation.
* `geometric_hahn_banach_point_point`: Both sets are singletons. Strict separation.
## TODO
* Eidelheit's theorem
* `Convex ℝ s → interior (closure s) ⊆ s`
-/
open Set
open Pointwise
variable {𝕜 E : Type*}
/-- Given a set `s` which is a convex neighbourhood of `0` and a point `x₀` outside of it, there is
a continuous linear functional `f` separating `x₀` and `s`, in the sense that it sends `x₀` to 1 and
all of `s` to values strictly below `1`. -/
theorem separate_convex_open_set [TopologicalSpace E] [AddCommGroup E] [TopologicalAddGroup E]
[Module ℝ E] [ContinuousSMul ℝ E] {s : Set E} (hs₀ : (0 : E) ∈ s) (hs₁ : Convex ℝ s)
(hs₂ : IsOpen s) {x₀ : E} (hx₀ : x₀ ∉ s) : ∃ f : E →L[ℝ] ℝ, f x₀ = 1 ∧ ∀ x ∈ s, f x < 1 := by
let f : E →ₗ.[ℝ] ℝ := LinearPMap.mkSpanSingleton x₀ 1 (ne_of_mem_of_not_mem hs₀ hx₀).symm
have := exists_extension_of_le_sublinear f (gauge s) (fun c hc => gauge_smul_of_nonneg hc.le)
(gauge_add_le hs₁ <| absorbent_nhds_zero <| hs₂.mem_nhds hs₀) ?_
· obtain ⟨φ, hφ₁, hφ₂⟩ := this
have hφ₃ : φ x₀ = 1 := by
rw [← f.domain.coe_mk x₀ (Submodule.mem_span_singleton_self _), hφ₁,
LinearPMap.mkSpanSingleton'_apply_self]
have hφ₄ : ∀ x ∈ s, φ x < 1 := fun x hx =>
(hφ₂ x).trans_lt (gauge_lt_one_of_mem_of_isOpen hs₂ hx)
refine ⟨⟨φ, ?_⟩, hφ₃, hφ₄⟩
refine
φ.continuous_of_nonzero_on_open _ (hs₂.vadd (-x₀)) (Nonempty.vadd_set ⟨0, hs₀⟩)
(vadd_set_subset_iff.mpr fun x hx => ?_)
change φ (-x₀ + x) ≠ 0
rw [map_add, map_neg]
specialize hφ₄ x hx
linarith
rintro ⟨x, hx⟩
obtain ⟨y, rfl⟩ := Submodule.mem_span_singleton.1 hx
rw [LinearPMap.mkSpanSingleton'_apply]
simp only [mul_one, Algebra.id.smul_eq_mul, Submodule.coe_mk]
obtain h | h := le_or_lt y 0
· exact h.trans (gauge_nonneg _)
· rw [gauge_smul_of_nonneg h.le, smul_eq_mul, le_mul_iff_one_le_right h]
exact
one_le_gauge_of_not_mem (hs₁.starConvex hs₀)
(absorbent_nhds_zero <| hs₂.mem_nhds hs₀).absorbs hx₀
variable [TopologicalSpace E] [AddCommGroup E] [TopologicalAddGroup E] [Module ℝ E]
[ContinuousSMul ℝ E] {s t : Set E} {x y : E}
/-- A version of the **Hahn-Banach theorem**: given disjoint convex sets `s`, `t` where `s` is open,
there is a continuous linear functional which separates them. -/
theorem geometric_hahn_banach_open (hs₁ : Convex ℝ s) (hs₂ : IsOpen s) (ht : Convex ℝ t)
(disj : Disjoint s t) : ∃ (f : E →L[ℝ] ℝ) (u : ℝ), (∀ a ∈ s, f a < u) ∧ ∀ b ∈ t, u ≤ f b := by
obtain rfl | ⟨a₀, ha₀⟩ := s.eq_empty_or_nonempty
· exact ⟨0, 0, by simp, fun b _hb => le_rfl⟩
obtain rfl | ⟨b₀, hb₀⟩ := t.eq_empty_or_nonempty
· exact ⟨0, 1, fun a _ha => zero_lt_one, by simp⟩
let x₀ := b₀ - a₀
let C := x₀ +ᵥ (s - t)
have : (0 : E) ∈ C :=
⟨a₀ - b₀, sub_mem_sub ha₀ hb₀, by simp_rw [x₀, vadd_eq_add, sub_add_sub_cancel', sub_self]⟩
have : Convex ℝ C := (hs₁.sub ht).vadd _
have : x₀ ∉ C := by
intro hx₀
rw [← add_zero x₀] at hx₀
exact disj.zero_not_mem_sub_set (vadd_mem_vadd_set_iff.1 hx₀)
obtain ⟨f, hf₁, hf₂⟩ := separate_convex_open_set ‹0 ∈ C› ‹_› (hs₂.sub_right.vadd _) ‹x₀ ∉ C›
have : f b₀ = f a₀ + 1 := by simp [x₀, ← hf₁]
have forall_le : ∀ a ∈ s, ∀ b ∈ t, f a ≤ f b := by
intro a ha b hb
have := hf₂ (x₀ + (a - b)) (vadd_mem_vadd_set <| sub_mem_sub ha hb)
simp only [f.map_add, f.map_sub, hf₁] at this
linarith
refine ⟨f, sInf (f '' t), image_subset_iff.1 (?_ : f '' s ⊆ Iio (sInf (f '' t))), fun b hb => ?_⟩
· rw [← interior_Iic]
refine interior_maximal (image_subset_iff.2 fun a ha => ?_) (f.isOpenMap_of_ne_zero ?_ _ hs₂)
· exact le_csInf (Nonempty.image _ ⟨_, hb₀⟩) (forall_mem_image.2 <| forall_le _ ha)
· rintro rfl
simp at hf₁
· exact csInf_le ⟨f a₀, forall_mem_image.2 <| forall_le _ ha₀⟩ (mem_image_of_mem _ hb)
theorem geometric_hahn_banach_open_point (hs₁ : Convex ℝ s) (hs₂ : IsOpen s) (disj : x ∉ s) :
∃ f : E →L[ℝ] ℝ, ∀ a ∈ s, f a < f x :=
let ⟨f, _s, hs, hx⟩ :=
geometric_hahn_banach_open hs₁ hs₂ (convex_singleton x) (disjoint_singleton_right.2 disj)
⟨f, fun a ha => lt_of_lt_of_le (hs a ha) (hx x (mem_singleton _))⟩
theorem geometric_hahn_banach_point_open (ht₁ : Convex ℝ t) (ht₂ : IsOpen t) (disj : x ∉ t) :
∃ f : E →L[ℝ] ℝ, ∀ b ∈ t, f x < f b :=
let ⟨f, hf⟩ := geometric_hahn_banach_open_point ht₁ ht₂ disj
⟨-f, by simpa⟩
theorem geometric_hahn_banach_open_open (hs₁ : Convex ℝ s) (hs₂ : IsOpen s) (ht₁ : Convex ℝ t)
(ht₃ : IsOpen t) (disj : Disjoint s t) :
∃ (f : E →L[ℝ] ℝ) (u : ℝ), (∀ a ∈ s, f a < u) ∧ ∀ b ∈ t, u < f b := by
obtain rfl | ⟨a₀, ha₀⟩ := s.eq_empty_or_nonempty
· exact ⟨0, -1, by simp, fun b _hb => by norm_num⟩
obtain rfl | ⟨b₀, hb₀⟩ := t.eq_empty_or_nonempty
· exact ⟨0, 1, fun a _ha => by norm_num, by simp⟩
obtain ⟨f, s, hf₁, hf₂⟩ := geometric_hahn_banach_open hs₁ hs₂ ht₁ disj
have hf : IsOpenMap f := by
refine f.isOpenMap_of_ne_zero ?_
rintro rfl
simp_rw [ContinuousLinearMap.zero_apply] at hf₁ hf₂
exact (hf₁ _ ha₀).not_le (hf₂ _ hb₀)
refine ⟨f, s, hf₁, image_subset_iff.1 (?_ : f '' t ⊆ Ioi s)⟩
rw [← interior_Ici]
refine interior_maximal (image_subset_iff.2 hf₂) (f.isOpenMap_of_ne_zero ?_ _ ht₃)
rintro rfl
simp_rw [ContinuousLinearMap.zero_apply] at hf₁ hf₂
exact (hf₁ _ ha₀).not_le (hf₂ _ hb₀)
variable [LocallyConvexSpace ℝ E]
/-- A version of the **Hahn-Banach theorem**: given disjoint convex sets `s`, `t` where `s` is
compact and `t` is closed, there is a continuous linear functional which strongly separates them. -/
theorem geometric_hahn_banach_compact_closed (hs₁ : Convex ℝ s) (hs₂ : IsCompact s)
(ht₁ : Convex ℝ t) (ht₂ : IsClosed t) (disj : Disjoint s t) :
∃ (f : E →L[ℝ] ℝ) (u v : ℝ), (∀ a ∈ s, f a < u) ∧ u < v ∧ ∀ b ∈ t, v < f b := by
obtain rfl | hs := s.eq_empty_or_nonempty
· exact ⟨0, -2, -1, by simp, by norm_num, fun b _hb => by norm_num⟩
obtain rfl | _ht := t.eq_empty_or_nonempty
· exact ⟨0, 1, 2, fun a _ha => by norm_num, by norm_num, by simp⟩
obtain ⟨U, V, hU, hV, hU₁, hV₁, sU, tV, disj'⟩ := disj.exists_open_convexes hs₁ hs₂ ht₁ ht₂
obtain ⟨f, u, hf₁, hf₂⟩ := geometric_hahn_banach_open_open hU₁ hU hV₁ hV disj'
obtain ⟨x, hx₁, hx₂⟩ := hs₂.exists_isMaxOn hs f.continuous.continuousOn
have : f x < u := hf₁ x (sU hx₁)
exact
⟨f, (f x + u) / 2, u,
fun a ha => by have := hx₂ ha; dsimp at this; linarith,
by linarith,
fun b hb => hf₂ b (tV hb)⟩
/-- A version of the **Hahn-Banach theorem**: given disjoint convex sets `s`, `t` where `s` is
closed, and `t` is compact, there is a continuous linear functional which strongly separates them.
-/
theorem geometric_hahn_banach_closed_compact (hs₁ : Convex ℝ s) (hs₂ : IsClosed s)
(ht₁ : Convex ℝ t) (ht₂ : IsCompact t) (disj : Disjoint s t) :
∃ (f : E →L[ℝ] ℝ) (u v : ℝ), (∀ a ∈ s, f a < u) ∧ u < v ∧ ∀ b ∈ t, v < f b :=
let ⟨f, s, t, hs, st, ht⟩ := geometric_hahn_banach_compact_closed ht₁ ht₂ hs₁ hs₂ disj.symm
⟨-f, -t, -s, by simpa using ht, by simpa using st, by simpa using hs⟩
theorem geometric_hahn_banach_point_closed (ht₁ : Convex ℝ t) (ht₂ : IsClosed t) (disj : x ∉ t) :
∃ (f : E →L[ℝ] ℝ) (u : ℝ), f x < u ∧ ∀ b ∈ t, u < f b :=
let ⟨f, _u, v, ha, hst, hb⟩ :=
geometric_hahn_banach_compact_closed (convex_singleton x) isCompact_singleton ht₁ ht₂
(disjoint_singleton_left.2 disj)
⟨f, v, hst.trans' <| ha x <| mem_singleton _, hb⟩
theorem geometric_hahn_banach_closed_point (hs₁ : Convex ℝ s) (hs₂ : IsClosed s) (disj : x ∉ s) :
∃ (f : E →L[ℝ] ℝ) (u : ℝ), (∀ a ∈ s, f a < u) ∧ u < f x :=
let ⟨f, s, _t, ha, hst, hb⟩ :=
geometric_hahn_banach_closed_compact hs₁ hs₂ (convex_singleton x) isCompact_singleton
(disjoint_singleton_right.2 disj)
⟨f, s, ha, hst.trans <| hb x <| mem_singleton _⟩
/-- See also `NormedSpace.eq_iff_forall_dual_eq`. -/
theorem geometric_hahn_banach_point_point [T1Space E] (hxy : x ≠ y) :
∃ f : E →L[ℝ] ℝ, f x < f y := by
obtain ⟨f, s, t, hs, st, ht⟩ :=
geometric_hahn_banach_compact_closed (convex_singleton x) isCompact_singleton
(convex_singleton y) isClosed_singleton (disjoint_singleton.2 hxy)
exact ⟨f, by linarith [hs x rfl, ht y rfl]⟩
/-- A closed convex set is the intersection of the halfspaces containing it. -/
theorem iInter_halfspaces_eq (hs₁ : Convex ℝ s) (hs₂ : IsClosed s) :
⋂ l : E →L[ℝ] ℝ, { x | ∃ y ∈ s, l x ≤ l y } = s := by
rw [Set.iInter_setOf]
refine Set.Subset.antisymm (fun x hx => ?_) fun x hx l => ⟨x, hx, le_rfl⟩
by_contra h
obtain ⟨l, s, hlA, hl⟩ := geometric_hahn_banach_closed_point hs₁ hs₂ h
obtain ⟨y, hy, hxy⟩ := hx l
exact ((hxy.trans_lt (hlA y hy)).trans hl).not_le le_rfl
namespace RCLike
variable [RCLike 𝕜] [Module 𝕜 E] [ContinuousSMul 𝕜 E] [IsScalarTower ℝ 𝕜 E]
/--Real linear extension of continuous extension of `LinearMap.extendTo𝕜'` -/
noncomputable def extendTo𝕜'ₗ : (E →L[ℝ] ℝ) →ₗ[ℝ] (E →L[𝕜] 𝕜) :=
letI to𝕜 (fr : (E →L[ℝ] ℝ)) : (E →L[𝕜] 𝕜) :=
{ toLinearMap := LinearMap.extendTo𝕜' fr
cont := show Continuous fun x ↦ (fr x : 𝕜) - (I : 𝕜) * (fr ((I : 𝕜) • x) : 𝕜) by fun_prop }
have h fr x : to𝕜 fr x = ((fr x : 𝕜) - (I : 𝕜) * (fr ((I : 𝕜) • x) : 𝕜)) := rfl
{ toFun := to𝕜
map_add' := by intros; ext; simp [h]; ring
map_smul' := by intros; ext; simp [h, real_smul_eq_coe_mul]; ring }
@[simp]
lemma re_extendTo𝕜'ₗ (g : E →L[ℝ] ℝ) (x : E) : re ((extendTo𝕜'ₗ g) x : 𝕜) = g x := by
have h g (x : E) : extendTo𝕜'ₗ g x = ((g x : 𝕜) - (I : 𝕜) * (g ((I : 𝕜) • x) : 𝕜)) := rfl
simp only [h , map_sub, ofReal_re, mul_re, I_re, zero_mul, ofReal_im, mul_zero,
sub_self, sub_zero]
variable [ContinuousSMul ℝ E]
theorem separate_convex_open_set {s : Set E}
(hs₀ : (0 : E) ∈ s) (hs₁ : Convex ℝ s) (hs₂ : IsOpen s) {x₀ : E} (hx₀ : x₀ ∉ s) :
∃ f : E →L[𝕜] 𝕜, re (f x₀) = 1 ∧ ∀ x ∈ s, re (f x) < 1 := by
obtain ⟨g, hg⟩ := _root_.separate_convex_open_set hs₀ hs₁ hs₂ hx₀
use extendTo𝕜'ₗ g
simp only [re_extendTo𝕜'ₗ]
exact hg
theorem geometric_hahn_banach_open (hs₁ : Convex ℝ s) (hs₂ : IsOpen s) (ht : Convex ℝ t)
(disj : Disjoint s t) : ∃ (f : E →L[𝕜] 𝕜) (u : ℝ), (∀ a ∈ s, re (f a) < u) ∧
∀ b ∈ t, u ≤ re (f b) := by
obtain ⟨f, u, h⟩ := _root_.geometric_hahn_banach_open hs₁ hs₂ ht disj
use extendTo𝕜'ₗ f
simp only [re_extendTo𝕜'ₗ]
exact Exists.intro u h
theorem geometric_hahn_banach_open_point (hs₁ : Convex ℝ s) (hs₂ : IsOpen s) (disj : x ∉ s) :
∃ f : E →L[𝕜] 𝕜, ∀ a ∈ s, re (f a) < re (f x) := by
obtain ⟨f, h⟩ := _root_.geometric_hahn_banach_open_point hs₁ hs₂ disj
use extendTo𝕜'ₗ f
simp only [re_extendTo𝕜'ₗ]
exact fun a a_1 ↦ h a a_1
theorem geometric_hahn_banach_point_open (ht₁ : Convex ℝ t) (ht₂ : IsOpen t) (disj : x ∉ t) :
∃ f : E →L[𝕜] 𝕜, ∀ b ∈ t, re (f x) < re (f b) :=
let ⟨f, hf⟩ := geometric_hahn_banach_open_point ht₁ ht₂ disj
⟨-f, by simpa⟩
theorem geometric_hahn_banach_open_open (hs₁ : Convex ℝ s) (hs₂ : IsOpen s)
(ht₁ : Convex ℝ t) (ht₃ : IsOpen t) (disj : Disjoint s t) :
∃ (f : E →L[𝕜] 𝕜) (u : ℝ), (∀ a ∈ s, re (f a) < u) ∧ ∀ b ∈ t, u < re (f b) := by
obtain ⟨f, u, h⟩ := _root_.geometric_hahn_banach_open_open hs₁ hs₂ ht₁ ht₃ disj
use extendTo𝕜'ₗ f
simp only [re_extendTo𝕜'ₗ]
exact Exists.intro u h
variable [LocallyConvexSpace ℝ E]
theorem geometric_hahn_banach_compact_closed (hs₁ : Convex ℝ s) (hs₂ : IsCompact s)
(ht₁ : Convex ℝ t) (ht₂ : IsClosed t) (disj : Disjoint s t) :
∃ (f : E →L[𝕜] 𝕜) (u v : ℝ), (∀ a ∈ s, re (f a) < u) ∧ u < v ∧ ∀ b ∈ t, v < re (f b) := by
obtain ⟨g, u, v, h1⟩ := _root_.geometric_hahn_banach_compact_closed hs₁ hs₂ ht₁ ht₂ disj
use extendTo𝕜'ₗ g
simp only [re_extendTo𝕜'ₗ, exists_and_left]
exact ⟨u, h1.1, v, h1.2⟩
theorem geometric_hahn_banach_closed_compact (hs₁ : Convex ℝ s) (hs₂ : IsClosed s)
(ht₁ : Convex ℝ t) (ht₂ : IsCompact t) (disj : Disjoint s t) :
∃ (f : E →L[𝕜] 𝕜) (u v : ℝ), (∀ a ∈ s, re (f a) < u) ∧ u < v ∧ ∀ b ∈ t, v < re (f b) :=
let ⟨f, s, t, hs, st, ht⟩ := geometric_hahn_banach_compact_closed ht₁ ht₂ hs₁ hs₂ disj.symm
⟨-f, -t, -s, by simpa using ht, by simpa using st, by simpa using hs⟩
theorem geometric_hahn_banach_point_closed (ht₁ : Convex ℝ t) (ht₂ : IsClosed t)
(disj : x ∉ t) : ∃ (f : E →L[𝕜] 𝕜) (u : ℝ), re (f x) < u ∧ ∀ b ∈ t, u < re (f b) :=
let ⟨f, _u, v, ha, hst, hb⟩ :=
geometric_hahn_banach_compact_closed (convex_singleton x) isCompact_singleton ht₁ ht₂
(disjoint_singleton_left.2 disj)
⟨f, v, hst.trans' <| ha x <| mem_singleton _, hb⟩
theorem geometric_hahn_banach_closed_point (hs₁ : Convex ℝ s) (hs₂ : IsClosed s)
(disj : x ∉ s) : ∃ (f : E →L[𝕜] 𝕜) (u : ℝ), (∀ a ∈ s, re (f a) < u) ∧ u < re (f x) :=
let ⟨f, s, _t, ha, hst, hb⟩ :=
geometric_hahn_banach_closed_compact hs₁ hs₂ (convex_singleton x) isCompact_singleton
(disjoint_singleton_right.2 disj)
⟨f, s, ha, hst.trans <| hb x <| mem_singleton _⟩
theorem geometric_hahn_banach_point_point [T1Space E] (hxy : x ≠ y) :
∃ f : E →L[𝕜] 𝕜, re (f x) < re (f y) := by
obtain ⟨f, s, t, hs, st, ht⟩ :=
geometric_hahn_banach_compact_closed (𝕜 := 𝕜) (convex_singleton x) isCompact_singleton
(convex_singleton y) isClosed_singleton (disjoint_singleton.2 hxy)
exact ⟨f, by linarith [hs x rfl, ht y rfl]⟩
theorem iInter_halfspaces_eq (hs₁ : Convex ℝ s) (hs₂ : IsClosed s) :
⋂ l : E →L[𝕜] 𝕜, { x | ∃ y ∈ s, re (l x) ≤ re (l y) } = s := by
rw [Set.iInter_setOf]
refine Set.Subset.antisymm (fun x hx => ?_) fun x hx l => ⟨x, hx, le_rfl⟩
by_contra h
obtain ⟨l, s, hlA, hl⟩ := geometric_hahn_banach_closed_point (𝕜 := 𝕜) hs₁ hs₂ h
obtain ⟨y, hy, hxy⟩ := hx l
exact ((hxy.trans_lt (hlA y hy)).trans hl).false
end RCLike
|
Analysis\NormedSpace\Multilinear\Basic.lean | /-
Copyright (c) 2020 Sébastien Gouëzel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sébastien Gouëzel, Sophie Morel, Yury Kudryashov
-/
import Mathlib.Analysis.NormedSpace.OperatorNorm.NormedSpace
import Mathlib.Logic.Embedding.Basic
import Mathlib.Data.Fintype.CardEmbedding
import Mathlib.Topology.Algebra.Module.Multilinear.Topology
/-!
# Operator norm on the space of continuous multilinear maps
When `f` is a continuous multilinear map in finitely many variables, we define its norm `‖f‖` as the
smallest number such that `‖f m‖ ≤ ‖f‖ * ∏ i, ‖m i‖` for all `m`.
We show that it is indeed a norm, and prove its basic properties.
## Main results
Let `f` be a multilinear map in finitely many variables.
* `exists_bound_of_continuous` asserts that, if `f` is continuous, then there exists `C > 0`
with `‖f m‖ ≤ C * ∏ i, ‖m i‖` for all `m`.
* `continuous_of_bound`, conversely, asserts that this bound implies continuity.
* `mkContinuous` constructs the associated continuous multilinear map.
Let `f` be a continuous multilinear map in finitely many variables.
* `‖f‖` is its norm, i.e., the smallest number such that `‖f m‖ ≤ ‖f‖ * ∏ i, ‖m i‖` for
all `m`.
* `le_opNorm f m` asserts the fundamental inequality `‖f m‖ ≤ ‖f‖ * ∏ i, ‖m i‖`.
* `norm_image_sub_le f m₁ m₂` gives a control of the difference `f m₁ - f m₂` in terms of
`‖f‖` and `‖m₁ - m₂‖`.
## Implementation notes
We mostly follow the API (and the proofs) of `OperatorNorm.lean`, with the additional complexity
that we should deal with multilinear maps in several variables. The currying/uncurrying
constructions are based on those in `Multilinear.lean`.
From the mathematical point of view, all the results follow from the results on operator norm in
one variable, by applying them to one variable after the other through currying. However, this
is only well defined when there is an order on the variables (for instance on `Fin n`) although
the final result is independent of the order. While everything could be done following this
approach, it turns out that direct proofs are easier and more efficient.
-/
suppress_compilation
noncomputable section
open scoped NNReal Topology Uniformity
open Finset Metric Function Filter
/-
Porting note: These lines are not required in Mathlib4.
```lean
attribute [local instance 1001]
AddCommGroup.toAddCommMonoid NormedAddCommGroup.toAddCommGroup NormedSpace.toModule'
```
-/
/-!
### Type variables
We use the following type variables in this file:
* `𝕜` : a `NontriviallyNormedField`;
* `ι`, `ι'` : finite index types with decidable equality;
* `E`, `E₁` : families of normed vector spaces over `𝕜` indexed by `i : ι`;
* `E'` : a family of normed vector spaces over `𝕜` indexed by `i' : ι'`;
* `Ei` : a family of normed vector spaces over `𝕜` indexed by `i : Fin (Nat.succ n)`;
* `G`, `G'` : normed vector spaces over `𝕜`.
-/
universe u v v' wE wE₁ wE' wG wG'
/-- Applying a multilinear map to a vector is continuous in both coordinates. -/
theorem ContinuousMultilinearMap.continuous_eval {𝕜 ι : Type*} {E : ι → Type*} {F : Type*}
[NormedField 𝕜] [Finite ι] [∀ i, SeminormedAddCommGroup (E i)] [∀ i, NormedSpace 𝕜 (E i)]
[TopologicalSpace F] [AddCommGroup F] [TopologicalAddGroup F] [Module 𝕜 F] :
Continuous fun p : ContinuousMultilinearMap 𝕜 E F × ∀ i, E i => p.1 p.2 := by
cases nonempty_fintype ι
let _ := TopologicalAddGroup.toUniformSpace F
have := comm_topologicalAddGroup_is_uniform (G := F)
refine (UniformOnFun.continuousOn_eval₂ fun m ↦ ?_).comp_continuous
(embedding_toUniformOnFun.continuous.prod_map continuous_id) fun (f, x) ↦ f.cont.continuousAt
exact ⟨ball m 1, NormedSpace.isVonNBounded_of_isBounded _ isBounded_ball,
ball_mem_nhds _ one_pos⟩
section Seminorm
variable {𝕜 : Type u} {ι : Type v} {ι' : Type v'} {E : ι → Type wE} {E₁ : ι → Type wE₁}
{E' : ι' → Type wE'} {G : Type wG} {G' : Type wG'}
[Fintype ι'] [NontriviallyNormedField 𝕜] [∀ i, SeminormedAddCommGroup (E i)]
[∀ i, NormedSpace 𝕜 (E i)] [∀ i, SeminormedAddCommGroup (E₁ i)] [∀ i, NormedSpace 𝕜 (E₁ i)]
[SeminormedAddCommGroup G] [NormedSpace 𝕜 G] [SeminormedAddCommGroup G'] [NormedSpace 𝕜 G']
/-!
### Continuity properties of multilinear maps
We relate continuity of multilinear maps to the inequality `‖f m‖ ≤ C * ∏ i, ‖m i‖`, in
both directions. Along the way, we prove useful bounds on the difference `‖f m₁ - f m₂‖`.
-/
namespace MultilinearMap
variable (f : MultilinearMap 𝕜 E G)
/-- If `f` is a continuous multilinear map in finitely many variables on `E` and `m` is an element
of `∀ i, E i` such that one of the `m i` has norm `0`, then `f m` has norm `0`.
Note that we cannot drop the continuity assumption because `f (m : Unit → E) = f (m ())`,
where the domain has zero norm and the codomain has a nonzero norm
does not satisfy this condition. -/
lemma norm_map_coord_zero (hf : Continuous f) {m : ∀ i, E i} {i : ι} (hi : ‖m i‖ = 0) :
‖f m‖ = 0 := by
classical
rw [← inseparable_zero_iff_norm] at hi ⊢
have : Inseparable (update m i 0) m := inseparable_pi.2 <|
(forall_update_iff m fun i a ↦ Inseparable a (m i)).2 ⟨hi.symm, fun _ _ ↦ rfl⟩
simpa only [map_update_zero] using this.symm.map hf
variable [Fintype ι]
theorem bound_of_shell_of_norm_map_coord_zero (hf₀ : ∀ {m i}, ‖m i‖ = 0 → ‖f m‖ = 0)
{ε : ι → ℝ} {C : ℝ} (hε : ∀ i, 0 < ε i) {c : ι → 𝕜} (hc : ∀ i, 1 < ‖c i‖)
(hf : ∀ m : ∀ i, E i, (∀ i, ε i / ‖c i‖ ≤ ‖m i‖) → (∀ i, ‖m i‖ < ε i) → ‖f m‖ ≤ C * ∏ i, ‖m i‖)
(m : ∀ i, E i) : ‖f m‖ ≤ C * ∏ i, ‖m i‖ := by
rcases em (∃ i, ‖m i‖ = 0) with (⟨i, hi⟩ | hm)
· rw [hf₀ hi, prod_eq_zero (mem_univ i) hi, mul_zero]
push_neg at hm
choose δ hδ0 hδm_lt hle_δm _ using fun i => rescale_to_shell_semi_normed (hc i) (hε i) (hm i)
have hδ0 : 0 < ∏ i, ‖δ i‖ := prod_pos fun i _ => norm_pos_iff.2 (hδ0 i)
simpa [map_smul_univ, norm_smul, prod_mul_distrib, mul_left_comm C, mul_le_mul_left hδ0] using
hf (fun i => δ i • m i) hle_δm hδm_lt
/-- If a continuous multilinear map in finitely many variables on normed spaces satisfies
the inequality `‖f m‖ ≤ C * ∏ i, ‖m i‖` on a shell `ε i / ‖c i‖ < ‖m i‖ < ε i` for some positive
numbers `ε i` and elements `c i : 𝕜`, `1 < ‖c i‖`, then it satisfies this inequality for all `m`. -/
theorem bound_of_shell_of_continuous (hfc : Continuous f)
{ε : ι → ℝ} {C : ℝ} (hε : ∀ i, 0 < ε i) {c : ι → 𝕜} (hc : ∀ i, 1 < ‖c i‖)
(hf : ∀ m : ∀ i, E i, (∀ i, ε i / ‖c i‖ ≤ ‖m i‖) → (∀ i, ‖m i‖ < ε i) → ‖f m‖ ≤ C * ∏ i, ‖m i‖)
(m : ∀ i, E i) : ‖f m‖ ≤ C * ∏ i, ‖m i‖ :=
bound_of_shell_of_norm_map_coord_zero f (norm_map_coord_zero f hfc) hε hc hf m
/-- If a multilinear map in finitely many variables on normed spaces is continuous, then it
satisfies the inequality `‖f m‖ ≤ C * ∏ i, ‖m i‖`, for some `C` which can be chosen to be
positive. -/
theorem exists_bound_of_continuous (hf : Continuous f) :
∃ C : ℝ, 0 < C ∧ ∀ m, ‖f m‖ ≤ C * ∏ i, ‖m i‖ := by
cases isEmpty_or_nonempty ι
· refine ⟨‖f 0‖ + 1, add_pos_of_nonneg_of_pos (norm_nonneg _) zero_lt_one, fun m => ?_⟩
obtain rfl : m = 0 := funext (IsEmpty.elim ‹_›)
simp [univ_eq_empty, zero_le_one]
obtain ⟨ε : ℝ, ε0 : 0 < ε, hε : ∀ m : ∀ i, E i, ‖m - 0‖ < ε → ‖f m - f 0‖ < 1⟩ :=
NormedAddCommGroup.tendsto_nhds_nhds.1 (hf.tendsto 0) 1 zero_lt_one
simp only [sub_zero, f.map_zero] at hε
rcases NormedField.exists_one_lt_norm 𝕜 with ⟨c, hc⟩
have : 0 < (‖c‖ / ε) ^ Fintype.card ι := pow_pos (div_pos (zero_lt_one.trans hc) ε0) _
refine ⟨_, this, ?_⟩
refine f.bound_of_shell_of_continuous hf (fun _ => ε0) (fun _ => hc) fun m hcm hm => ?_
refine (hε m ((pi_norm_lt_iff ε0).2 hm)).le.trans ?_
rw [← div_le_iff' this, one_div, ← inv_pow, inv_div, Fintype.card, ← prod_const]
exact prod_le_prod (fun _ _ => div_nonneg ε0.le (norm_nonneg _)) fun i _ => hcm i
/-- If `f` satisfies a boundedness property around `0`, one can deduce a bound on `f m₁ - f m₂`
using the multilinearity. Here, we give a precise but hard to use version. See
`norm_image_sub_le_of_bound` for a less precise but more usable version. The bound reads
`‖f m - f m'‖ ≤
C * ‖m 1 - m' 1‖ * max ‖m 2‖ ‖m' 2‖ * max ‖m 3‖ ‖m' 3‖ * ... * max ‖m n‖ ‖m' n‖ + ...`,
where the other terms in the sum are the same products where `1` is replaced by any `i`. -/
theorem norm_image_sub_le_of_bound' [DecidableEq ι] {C : ℝ} (hC : 0 ≤ C)
(H : ∀ m, ‖f m‖ ≤ C * ∏ i, ‖m i‖) (m₁ m₂ : ∀ i, E i) :
‖f m₁ - f m₂‖ ≤ C * ∑ i, ∏ j, if j = i then ‖m₁ i - m₂ i‖ else max ‖m₁ j‖ ‖m₂ j‖ := by
have A :
∀ s : Finset ι,
‖f m₁ - f (s.piecewise m₂ m₁)‖ ≤
C * ∑ i ∈ s, ∏ j, if j = i then ‖m₁ i - m₂ i‖ else max ‖m₁ j‖ ‖m₂ j‖ := by
intro s
induction' s using Finset.induction with i s his Hrec
· simp
have I :
‖f (s.piecewise m₂ m₁) - f ((insert i s).piecewise m₂ m₁)‖ ≤
C * ∏ j, if j = i then ‖m₁ i - m₂ i‖ else max ‖m₁ j‖ ‖m₂ j‖ := by
have A : (insert i s).piecewise m₂ m₁ = Function.update (s.piecewise m₂ m₁) i (m₂ i) :=
s.piecewise_insert _ _ _
have B : s.piecewise m₂ m₁ = Function.update (s.piecewise m₂ m₁) i (m₁ i) := by
simp [eq_update_iff, his]
rw [B, A, ← f.map_sub]
apply le_trans (H _)
gcongr with j
· exact fun j _ => norm_nonneg _
by_cases h : j = i
· rw [h]
simp
· by_cases h' : j ∈ s <;> simp [h', h, le_refl]
calc
‖f m₁ - f ((insert i s).piecewise m₂ m₁)‖ ≤
‖f m₁ - f (s.piecewise m₂ m₁)‖ +
‖f (s.piecewise m₂ m₁) - f ((insert i s).piecewise m₂ m₁)‖ := by
rw [← dist_eq_norm, ← dist_eq_norm, ← dist_eq_norm]
exact dist_triangle _ _ _
_ ≤ (C * ∑ i ∈ s, ∏ j, if j = i then ‖m₁ i - m₂ i‖ else max ‖m₁ j‖ ‖m₂ j‖) +
C * ∏ j, if j = i then ‖m₁ i - m₂ i‖ else max ‖m₁ j‖ ‖m₂ j‖ :=
(add_le_add Hrec I)
_ = C * ∑ i ∈ insert i s, ∏ j, if j = i then ‖m₁ i - m₂ i‖ else max ‖m₁ j‖ ‖m₂ j‖ := by
simp [his, add_comm, left_distrib]
convert A univ
simp
/-- If `f` satisfies a boundedness property around `0`, one can deduce a bound on `f m₁ - f m₂`
using the multilinearity. Here, we give a usable but not very precise version. See
`norm_image_sub_le_of_bound'` for a more precise but less usable version. The bound is
`‖f m - f m'‖ ≤ C * card ι * ‖m - m'‖ * (max ‖m‖ ‖m'‖) ^ (card ι - 1)`. -/
theorem norm_image_sub_le_of_bound {C : ℝ} (hC : 0 ≤ C) (H : ∀ m, ‖f m‖ ≤ C * ∏ i, ‖m i‖)
(m₁ m₂ : ∀ i, E i) :
‖f m₁ - f m₂‖ ≤ C * Fintype.card ι * max ‖m₁‖ ‖m₂‖ ^ (Fintype.card ι - 1) * ‖m₁ - m₂‖ := by
classical
have A :
∀ i : ι,
∏ j, (if j = i then ‖m₁ i - m₂ i‖ else max ‖m₁ j‖ ‖m₂ j‖) ≤
‖m₁ - m₂‖ * max ‖m₁‖ ‖m₂‖ ^ (Fintype.card ι - 1) := by
intro i
calc
∏ j, (if j = i then ‖m₁ i - m₂ i‖ else max ‖m₁ j‖ ‖m₂ j‖) ≤
∏ j : ι, Function.update (fun _ => max ‖m₁‖ ‖m₂‖) i ‖m₁ - m₂‖ j := by
apply Finset.prod_le_prod
· intro j _
by_cases h : j = i <;> simp [h, norm_nonneg]
· intro j _
by_cases h : j = i
· rw [h]
simp only [ite_true, Function.update_same]
exact norm_le_pi_norm (m₁ - m₂) i
· simp [h, -le_max_iff, -max_le_iff, max_le_max, norm_le_pi_norm (_ : ∀ i, E i)]
_ = ‖m₁ - m₂‖ * max ‖m₁‖ ‖m₂‖ ^ (Fintype.card ι - 1) := by
rw [prod_update_of_mem (Finset.mem_univ _)]
simp [card_univ_diff]
calc
‖f m₁ - f m₂‖ ≤ C * ∑ i, ∏ j, if j = i then ‖m₁ i - m₂ i‖ else max ‖m₁ j‖ ‖m₂ j‖ :=
f.norm_image_sub_le_of_bound' hC H m₁ m₂
_ ≤ C * ∑ _i, ‖m₁ - m₂‖ * max ‖m₁‖ ‖m₂‖ ^ (Fintype.card ι - 1) := by gcongr; apply A
_ = C * Fintype.card ι * max ‖m₁‖ ‖m₂‖ ^ (Fintype.card ι - 1) * ‖m₁ - m₂‖ := by
rw [sum_const, card_univ, nsmul_eq_mul]
ring
/-- If a multilinear map satisfies an inequality `‖f m‖ ≤ C * ∏ i, ‖m i‖`, then it is
continuous. -/
theorem continuous_of_bound (C : ℝ) (H : ∀ m, ‖f m‖ ≤ C * ∏ i, ‖m i‖) : Continuous f := by
let D := max C 1
have D_pos : 0 ≤ D := le_trans zero_le_one (le_max_right _ _)
replace H (m) : ‖f m‖ ≤ D * ∏ i, ‖m i‖ :=
(H m).trans (mul_le_mul_of_nonneg_right (le_max_left _ _) <| by positivity)
refine continuous_iff_continuousAt.2 fun m => ?_
refine
continuousAt_of_locally_lipschitz zero_lt_one
(D * Fintype.card ι * (‖m‖ + 1) ^ (Fintype.card ι - 1)) fun m' h' => ?_
rw [dist_eq_norm, dist_eq_norm]
have : max ‖m'‖ ‖m‖ ≤ ‖m‖ + 1 := by
simp [zero_le_one, norm_le_of_mem_closedBall (le_of_lt h')]
calc
‖f m' - f m‖ ≤ D * Fintype.card ι * max ‖m'‖ ‖m‖ ^ (Fintype.card ι - 1) * ‖m' - m‖ :=
f.norm_image_sub_le_of_bound D_pos H m' m
_ ≤ D * Fintype.card ι * (‖m‖ + 1) ^ (Fintype.card ι - 1) * ‖m' - m‖ := by gcongr
/-- Constructing a continuous multilinear map from a multilinear map satisfying a boundedness
condition. -/
def mkContinuous (C : ℝ) (H : ∀ m, ‖f m‖ ≤ C * ∏ i, ‖m i‖) : ContinuousMultilinearMap 𝕜 E G :=
{ f with cont := f.continuous_of_bound C H }
@[simp]
theorem coe_mkContinuous (C : ℝ) (H : ∀ m, ‖f m‖ ≤ C * ∏ i, ‖m i‖) : ⇑(f.mkContinuous C H) = f :=
rfl
/-- Given a multilinear map in `n` variables, if one restricts it to `k` variables putting `z` on
the other coordinates, then the resulting restricted function satisfies an inequality
`‖f.restr v‖ ≤ C * ‖z‖^(n-k) * Π ‖v i‖` if the original function satisfies `‖f v‖ ≤ C * Π ‖v i‖`. -/
theorem restr_norm_le {k n : ℕ} (f : (MultilinearMap 𝕜 (fun _ : Fin n => G) G' : _))
(s : Finset (Fin n)) (hk : s.card = k) (z : G) {C : ℝ} (H : ∀ m, ‖f m‖ ≤ C * ∏ i, ‖m i‖)
(v : Fin k → G) : ‖f.restr s hk z v‖ ≤ C * ‖z‖ ^ (n - k) * ∏ i, ‖v i‖ := by
rw [mul_right_comm, mul_assoc]
convert H _ using 2
simp only [apply_dite norm, Fintype.prod_dite, prod_const ‖z‖, Finset.card_univ,
Fintype.card_of_subtype sᶜ fun _ => mem_compl, card_compl, Fintype.card_fin, hk, mk_coe, ←
(s.orderIsoOfFin hk).symm.bijective.prod_comp fun x => ‖v x‖]
convert rfl
end MultilinearMap
/-!
### Continuous multilinear maps
We define the norm `‖f‖` of a continuous multilinear map `f` in finitely many variables as the
smallest number such that `‖f m‖ ≤ ‖f‖ * ∏ i, ‖m i‖` for all `m`. We show that this
defines a normed space structure on `ContinuousMultilinearMap 𝕜 E G`.
-/
namespace ContinuousMultilinearMap
variable [Fintype ι] (c : 𝕜) (f g : ContinuousMultilinearMap 𝕜 E G) (m : ∀ i, E i)
theorem bound : ∃ C : ℝ, 0 < C ∧ ∀ m, ‖f m‖ ≤ C * ∏ i, ‖m i‖ :=
f.toMultilinearMap.exists_bound_of_continuous f.2
open Real
/-- The operator norm of a continuous multilinear map is the inf of all its bounds. -/
def opNorm :=
sInf { c | 0 ≤ (c : ℝ) ∧ ∀ m, ‖f m‖ ≤ c * ∏ i, ‖m i‖ }
instance hasOpNorm : Norm (ContinuousMultilinearMap 𝕜 E G) :=
⟨opNorm⟩
/-- An alias of `ContinuousMultilinearMap.hasOpNorm` with non-dependent types to help typeclass
search. -/
instance hasOpNorm' : Norm (ContinuousMultilinearMap 𝕜 (fun _ : ι => G) G') :=
ContinuousMultilinearMap.hasOpNorm
theorem norm_def : ‖f‖ = sInf { c | 0 ≤ (c : ℝ) ∧ ∀ m, ‖f m‖ ≤ c * ∏ i, ‖m i‖ } :=
rfl
-- So that invocations of `le_csInf` make sense: we show that the set of
-- bounds is nonempty and bounded below.
theorem bounds_nonempty {f : ContinuousMultilinearMap 𝕜 E G} :
∃ c, c ∈ { c | 0 ≤ c ∧ ∀ m, ‖f m‖ ≤ c * ∏ i, ‖m i‖ } :=
let ⟨M, hMp, hMb⟩ := f.bound
⟨M, le_of_lt hMp, hMb⟩
theorem bounds_bddBelow {f : ContinuousMultilinearMap 𝕜 E G} :
BddBelow { c | 0 ≤ c ∧ ∀ m, ‖f m‖ ≤ c * ∏ i, ‖m i‖ } :=
⟨0, fun _ ⟨hn, _⟩ => hn⟩
theorem isLeast_opNorm : IsLeast {c : ℝ | 0 ≤ c ∧ ∀ m, ‖f m‖ ≤ c * ∏ i, ‖m i‖} ‖f‖ := by
refine IsClosed.isLeast_csInf ?_ bounds_nonempty bounds_bddBelow
simp only [Set.setOf_and, Set.setOf_forall]
exact isClosed_Ici.inter (isClosed_iInter fun m ↦
isClosed_le continuous_const (continuous_id.mul continuous_const))
@[deprecated (since := "2024-02-02")] alias isLeast_op_norm := isLeast_opNorm
theorem opNorm_nonneg : 0 ≤ ‖f‖ :=
Real.sInf_nonneg _ fun _ ⟨hx, _⟩ => hx
@[deprecated (since := "2024-02-02")] alias op_norm_nonneg := opNorm_nonneg
/-- The fundamental property of the operator norm of a continuous multilinear map:
`‖f m‖` is bounded by `‖f‖` times the product of the `‖m i‖`. -/
theorem le_opNorm : ‖f m‖ ≤ ‖f‖ * ∏ i, ‖m i‖ := f.isLeast_opNorm.1.2 m
@[deprecated (since := "2024-02-02")] alias le_op_norm := le_opNorm
variable {f m}
theorem le_mul_prod_of_le_opNorm_of_le {C : ℝ} {b : ι → ℝ} (hC : ‖f‖ ≤ C) (hm : ∀ i, ‖m i‖ ≤ b i) :
‖f m‖ ≤ C * ∏ i, b i :=
(f.le_opNorm m).trans <| mul_le_mul hC (prod_le_prod (fun _ _ ↦ norm_nonneg _) fun _ _ ↦ hm _)
(by positivity) ((opNorm_nonneg _).trans hC)
@[deprecated (since := "2024-02-02")]
alias le_mul_prod_of_le_op_norm_of_le := le_mul_prod_of_le_opNorm_of_le
variable (f)
theorem le_opNorm_mul_prod_of_le {b : ι → ℝ} (hm : ∀ i, ‖m i‖ ≤ b i) : ‖f m‖ ≤ ‖f‖ * ∏ i, b i :=
le_mul_prod_of_le_opNorm_of_le le_rfl hm
@[deprecated (since := "2024-02-02")] alias le_op_norm_mul_prod_of_le := le_opNorm_mul_prod_of_le
theorem le_opNorm_mul_pow_card_of_le {b : ℝ} (hm : ‖m‖ ≤ b) :
‖f m‖ ≤ ‖f‖ * b ^ Fintype.card ι := by
simpa only [prod_const] using f.le_opNorm_mul_prod_of_le fun i => (norm_le_pi_norm m i).trans hm
@[deprecated (since := "2024-02-02")]
alias le_op_norm_mul_pow_card_of_le := le_opNorm_mul_pow_card_of_le
theorem le_opNorm_mul_pow_of_le {n : ℕ} {Ei : Fin n → Type*} [∀ i, SeminormedAddCommGroup (Ei i)]
[∀ i, NormedSpace 𝕜 (Ei i)] (f : ContinuousMultilinearMap 𝕜 Ei G) {m : ∀ i, Ei i} {b : ℝ}
(hm : ‖m‖ ≤ b) : ‖f m‖ ≤ ‖f‖ * b ^ n := by
simpa only [Fintype.card_fin] using f.le_opNorm_mul_pow_card_of_le hm
@[deprecated (since := "2024-02-02")] alias le_op_norm_mul_pow_of_le := le_opNorm_mul_pow_of_le
variable {f} (m)
theorem le_of_opNorm_le {C : ℝ} (h : ‖f‖ ≤ C) : ‖f m‖ ≤ C * ∏ i, ‖m i‖ :=
le_mul_prod_of_le_opNorm_of_le h fun _ ↦ le_rfl
@[deprecated (since := "2024-02-02")] alias le_of_op_norm_le := le_of_opNorm_le
variable (f)
theorem ratio_le_opNorm : (‖f m‖ / ∏ i, ‖m i‖) ≤ ‖f‖ :=
div_le_of_nonneg_of_le_mul (by positivity) (opNorm_nonneg _) (f.le_opNorm m)
@[deprecated (since := "2024-02-02")] alias ratio_le_op_norm := ratio_le_opNorm
/-- The image of the unit ball under a continuous multilinear map is bounded. -/
theorem unit_le_opNorm (h : ‖m‖ ≤ 1) : ‖f m‖ ≤ ‖f‖ :=
(le_opNorm_mul_pow_card_of_le f h).trans <| by simp
@[deprecated (since := "2024-02-02")] alias unit_le_op_norm := unit_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 : ∀ m, ‖f m‖ ≤ M * ∏ i, ‖m i‖) : ‖f‖ ≤ M :=
csInf_le bounds_bddBelow ⟨hMp, hM⟩
@[deprecated (since := "2024-02-02")] alias op_norm_le_bound := opNorm_le_bound
theorem opNorm_le_iff {C : ℝ} (hC : 0 ≤ C) : ‖f‖ ≤ C ↔ ∀ m, ‖f m‖ ≤ C * ∏ i, ‖m i‖ :=
⟨fun h _ ↦ le_of_opNorm_le _ h, opNorm_le_bound _ hC⟩
@[deprecated (since := "2024-02-02")] alias op_norm_le_iff := opNorm_le_iff
/-- The operator norm satisfies the triangle inequality. -/
theorem opNorm_add_le : ‖f + g‖ ≤ ‖f‖ + ‖g‖ :=
opNorm_le_bound _ (add_nonneg (opNorm_nonneg _) (opNorm_nonneg _)) fun x => by
rw [add_mul]
exact norm_add_le_of_le (le_opNorm _ _) (le_opNorm _ _)
@[deprecated (since := "2024-02-02")] alias op_norm_add_le := opNorm_add_le
theorem opNorm_zero : ‖(0 : ContinuousMultilinearMap 𝕜 E G)‖ = 0 :=
(opNorm_nonneg _).antisymm' <| opNorm_le_bound 0 le_rfl fun m => by simp
@[deprecated (since := "2024-02-02")] alias op_norm_zero := opNorm_zero
section
variable {𝕜' : Type*} [NormedField 𝕜'] [NormedSpace 𝕜' G] [SMulCommClass 𝕜 𝕜' G]
theorem opNorm_smul_le (c : 𝕜') : ‖c • f‖ ≤ ‖c‖ * ‖f‖ :=
(c • f).opNorm_le_bound (mul_nonneg (norm_nonneg _) (opNorm_nonneg _)) fun m ↦ by
rw [smul_apply, norm_smul, mul_assoc]
exact mul_le_mul_of_nonneg_left (le_opNorm _ _) (norm_nonneg _)
@[deprecated (since := "2024-02-02")] alias op_norm_smul_le := opNorm_smul_le
theorem opNorm_neg : ‖-f‖ = ‖f‖ := by
rw [norm_def]
apply congr_arg
ext
simp
@[deprecated (since := "2024-02-02")] alias op_norm_neg := opNorm_neg
variable (𝕜 E G) in
/-- Operator seminorm on the space of continuous multilinear maps, as `Seminorm`.
We use this seminorm
to define a `SeminormedAddCommGroup` structure on `ContinuousMultilinearMap 𝕜 E G`,
but we have to override the projection `UniformSpace`
so that it is definitionally equal to the one coming from the topologies on `E` and `G`. -/
protected def seminorm : Seminorm 𝕜 (ContinuousMultilinearMap 𝕜 E G) :=
.ofSMulLE norm opNorm_zero opNorm_add_le fun c f ↦ opNorm_smul_le f c
private lemma uniformity_eq_seminorm :
𝓤 (ContinuousMultilinearMap 𝕜 E G) = ⨅ r > 0, 𝓟 {f | ‖f.1 - f.2‖ < r} := by
refine (ContinuousMultilinearMap.seminorm 𝕜 E G).uniformity_eq_of_hasBasis
(ContinuousMultilinearMap.hasBasis_nhds_zero_of_basis Metric.nhds_basis_closedBall)
?_ fun (s, r) ⟨hs, hr⟩ ↦ ?_
· rcases NormedField.exists_lt_norm 𝕜 1 with ⟨c, hc⟩
have hc₀ : 0 < ‖c‖ := one_pos.trans hc
simp only [hasBasis_nhds_zero.mem_iff, Prod.exists]
use 1, closedBall 0 ‖c‖, closedBall 0 1
suffices ∀ f : ContinuousMultilinearMap 𝕜 E G, (∀ x, ‖x‖ ≤ ‖c‖ → ‖f x‖ ≤ 1) → ‖f‖ ≤ 1 by
simpa [NormedSpace.isVonNBounded_closedBall, closedBall_mem_nhds, Set.subset_def, Set.MapsTo]
intro f hf
refine opNorm_le_bound _ (by positivity) <|
f.1.bound_of_shell_of_continuous f.2 (fun _ ↦ hc₀) (fun _ ↦ hc) fun x hcx hx ↦ ?_
calc
‖f x‖ ≤ 1 := hf _ <| (pi_norm_le_iff_of_nonneg (norm_nonneg c)).2 fun i ↦ (hx i).le
_ = ∏ i : ι, 1 := by simp
_ ≤ ∏ i, ‖x i‖ := Finset.prod_le_prod (fun _ _ ↦ zero_le_one) fun i _ ↦ by
simpa only [div_self hc₀.ne'] using hcx i
_ = 1 * ∏ i, ‖x i‖ := (one_mul _).symm
· rcases (NormedSpace.isVonNBounded_iff' _).1 hs with ⟨ε, hε⟩
rcases exists_pos_mul_lt hr (ε ^ Fintype.card ι) with ⟨δ, hδ₀, hδ⟩
refine ⟨δ, hδ₀, fun f hf x hx ↦ ?_⟩
simp only [Seminorm.mem_ball_zero, mem_closedBall_zero_iff] at hf ⊢
replace hf : ‖f‖ ≤ δ := hf.le
replace hx : ‖x‖ ≤ ε := hε x hx
calc
‖f x‖ ≤ ‖f‖ * ε ^ Fintype.card ι := le_opNorm_mul_pow_card_of_le f hx
_ ≤ δ * ε ^ Fintype.card ι := by have := (norm_nonneg x).trans hx; gcongr
_ ≤ r := (mul_comm _ _).trans_le hδ.le
instance instPseudoMetricSpace : PseudoMetricSpace (ContinuousMultilinearMap 𝕜 E G) :=
.replaceUniformity
(ContinuousMultilinearMap.seminorm 𝕜 E G).toSeminormedAddCommGroup.toPseudoMetricSpace
uniformity_eq_seminorm
/-- Continuous multilinear maps themselves form a seminormed space with respect to
the operator norm. -/
instance seminormedAddCommGroup :
SeminormedAddCommGroup (ContinuousMultilinearMap 𝕜 E G) := ⟨fun _ _ ↦ rfl⟩
/-- An alias of `ContinuousMultilinearMap.seminormedAddCommGroup` with non-dependent types to help
typeclass search. -/
instance seminormedAddCommGroup' :
SeminormedAddCommGroup (ContinuousMultilinearMap 𝕜 (fun _ : ι => G) G') :=
ContinuousMultilinearMap.seminormedAddCommGroup
instance normedSpace : NormedSpace 𝕜' (ContinuousMultilinearMap 𝕜 E G) :=
⟨fun c f => f.opNorm_smul_le c⟩
/-- An alias of `ContinuousMultilinearMap.normedSpace` with non-dependent types to help typeclass
search. -/
instance normedSpace' : NormedSpace 𝕜' (ContinuousMultilinearMap 𝕜 (fun _ : ι => G') G) :=
ContinuousMultilinearMap.normedSpace
/-- The fundamental property of the operator norm of a continuous multilinear map:
`‖f m‖` is bounded by `‖f‖` times the product of the `‖m i‖`, `nnnorm` version. -/
theorem le_opNNNorm : ‖f m‖₊ ≤ ‖f‖₊ * ∏ i, ‖m i‖₊ :=
NNReal.coe_le_coe.1 <| by
push_cast
exact f.le_opNorm m
@[deprecated (since := "2024-02-02")] alias le_op_nnnorm := le_opNNNorm
theorem le_of_opNNNorm_le {C : ℝ≥0} (h : ‖f‖₊ ≤ C) : ‖f m‖₊ ≤ C * ∏ i, ‖m i‖₊ :=
(f.le_opNNNorm m).trans <| mul_le_mul' h le_rfl
@[deprecated (since := "2024-02-02")] alias le_of_op_nnnorm_le := le_of_opNNNorm_le
theorem opNNNorm_le_iff {C : ℝ≥0} : ‖f‖₊ ≤ C ↔ ∀ m, ‖f m‖₊ ≤ C * ∏ i, ‖m i‖₊ := by
simp only [← NNReal.coe_le_coe]; simp [opNorm_le_iff _ C.coe_nonneg, NNReal.coe_prod]
@[deprecated (since := "2024-02-02")] alias op_nnnorm_le_iff := opNNNorm_le_iff
theorem isLeast_opNNNorm : IsLeast {C : ℝ≥0 | ∀ m, ‖f m‖₊ ≤ C * ∏ i, ‖m i‖₊} ‖f‖₊ := by
simpa only [← opNNNorm_le_iff] using isLeast_Ici
@[deprecated (since := "2024-02-02")] alias isLeast_op_nnnorm := isLeast_opNNNorm
theorem opNNNorm_prod (f : ContinuousMultilinearMap 𝕜 E G) (g : ContinuousMultilinearMap 𝕜 E G') :
‖f.prod g‖₊ = max ‖f‖₊ ‖g‖₊ :=
eq_of_forall_ge_iff fun _ ↦ by
simp only [opNNNorm_le_iff, prod_apply, Prod.nnnorm_def', max_le_iff, forall_and]
@[deprecated (since := "2024-02-02")] alias op_nnnorm_prod := opNNNorm_prod
theorem opNorm_prod (f : ContinuousMultilinearMap 𝕜 E G) (g : ContinuousMultilinearMap 𝕜 E G') :
‖f.prod g‖ = max ‖f‖ ‖g‖ :=
congr_arg NNReal.toReal (opNNNorm_prod f g)
@[deprecated (since := "2024-02-02")] alias op_norm_prod := opNorm_prod
theorem opNNNorm_pi
[∀ i', SeminormedAddCommGroup (E' i')] [∀ i', NormedSpace 𝕜 (E' i')]
(f : ∀ i', ContinuousMultilinearMap 𝕜 E (E' i')) : ‖pi f‖₊ = ‖f‖₊ :=
eq_of_forall_ge_iff fun _ ↦ by simpa [opNNNorm_le_iff, pi_nnnorm_le_iff] using forall_swap
theorem opNorm_pi {ι' : Type v'} [Fintype ι'] {E' : ι' → Type wE'}
[∀ i', SeminormedAddCommGroup (E' i')] [∀ i', NormedSpace 𝕜 (E' i')]
(f : ∀ i', ContinuousMultilinearMap 𝕜 E (E' i')) :
‖pi f‖ = ‖f‖ :=
congr_arg NNReal.toReal (opNNNorm_pi f)
@[deprecated (since := "2024-02-02")] alias op_norm_pi := opNorm_pi
section
@[simp]
theorem norm_ofSubsingleton [Subsingleton ι] (i : ι) (f : G →L[𝕜] G') :
‖ofSubsingleton 𝕜 G G' i f‖ = ‖f‖ := by
letI : Unique ι := uniqueOfSubsingleton i
simp [norm_def, ContinuousLinearMap.norm_def, (Equiv.funUnique _ _).symm.surjective.forall]
@[simp]
theorem nnnorm_ofSubsingleton [Subsingleton ι] (i : ι) (f : G →L[𝕜] G') :
‖ofSubsingleton 𝕜 G G' i f‖₊ = ‖f‖₊ :=
NNReal.eq <| norm_ofSubsingleton i f
variable (𝕜 G)
/-- Linear isometry between continuous linear maps from `G` to `G'`
and continuous `1`-multilinear maps from `G` to `G'`. -/
@[simps apply symm_apply]
def ofSubsingletonₗᵢ [Subsingleton ι] (i : ι) :
(G →L[𝕜] G') ≃ₗᵢ[𝕜] ContinuousMultilinearMap 𝕜 (fun _ : ι ↦ G) G' :=
{ ofSubsingleton 𝕜 G G' i with
map_add' := fun _ _ ↦ rfl
map_smul' := fun _ _ ↦ rfl
norm_map' := norm_ofSubsingleton i }
theorem norm_ofSubsingleton_id_le [Subsingleton ι] (i : ι) :
‖ofSubsingleton 𝕜 G G i (.id _ _)‖ ≤ 1 := by
rw [norm_ofSubsingleton]
apply ContinuousLinearMap.norm_id_le
theorem nnnorm_ofSubsingleton_id_le [Subsingleton ι] (i : ι) :
‖ofSubsingleton 𝕜 G G i (.id _ _)‖₊ ≤ 1 :=
norm_ofSubsingleton_id_le _ _ _
variable {G} (E)
@[simp]
theorem norm_constOfIsEmpty [IsEmpty ι] (x : G) : ‖constOfIsEmpty 𝕜 E x‖ = ‖x‖ := by
apply le_antisymm
· refine opNorm_le_bound _ (norm_nonneg _) fun x => ?_
rw [Fintype.prod_empty, mul_one, constOfIsEmpty_apply]
· simpa using (constOfIsEmpty 𝕜 E x).le_opNorm 0
@[simp]
theorem nnnorm_constOfIsEmpty [IsEmpty ι] (x : G) : ‖constOfIsEmpty 𝕜 E x‖₊ = ‖x‖₊ :=
NNReal.eq <| norm_constOfIsEmpty _ _ _
end
section
variable (𝕜 E E' G G')
/-- `ContinuousMultilinearMap.prod` as a `LinearIsometryEquiv`. -/
def prodL :
ContinuousMultilinearMap 𝕜 E G × ContinuousMultilinearMap 𝕜 E G' ≃ₗᵢ[𝕜]
ContinuousMultilinearMap 𝕜 E (G × G') where
toFun f := f.1.prod f.2
invFun f :=
((ContinuousLinearMap.fst 𝕜 G G').compContinuousMultilinearMap f,
(ContinuousLinearMap.snd 𝕜 G G').compContinuousMultilinearMap f)
map_add' f g := rfl
map_smul' c f := rfl
left_inv f := by ext <;> rfl
right_inv f := by ext <;> rfl
norm_map' f := opNorm_prod f.1 f.2
/-- `ContinuousMultilinearMap.pi` as a `LinearIsometryEquiv`. -/
def piₗᵢ {ι' : Type v'} [Fintype ι'] {E' : ι' → Type wE'} [∀ i', NormedAddCommGroup (E' i')]
[∀ i', NormedSpace 𝕜 (E' i')] :
@LinearIsometryEquiv 𝕜 𝕜 _ _ (RingHom.id 𝕜) _ _ _ (∀ i', ContinuousMultilinearMap 𝕜 E (E' i'))
(ContinuousMultilinearMap 𝕜 E (∀ i, E' i)) _ _ (@Pi.module ι' _ 𝕜 _ _ fun _ => inferInstance)
_ where
toLinearEquiv := piLinearEquiv
norm_map' := opNorm_pi
end
end
section RestrictScalars
variable {𝕜' : Type*} [NontriviallyNormedField 𝕜'] [NormedAlgebra 𝕜' 𝕜]
variable [NormedSpace 𝕜' G] [IsScalarTower 𝕜' 𝕜 G]
variable [∀ i, NormedSpace 𝕜' (E i)] [∀ i, IsScalarTower 𝕜' 𝕜 (E i)]
@[simp]
theorem norm_restrictScalars : ‖f.restrictScalars 𝕜'‖ = ‖f‖ := rfl
variable (𝕜')
/-- `ContinuousMultilinearMap.restrictScalars` as a `LinearIsometry`. -/
def restrictScalarsₗᵢ : ContinuousMultilinearMap 𝕜 E G →ₗᵢ[𝕜'] ContinuousMultilinearMap 𝕜' E G where
toFun := restrictScalars 𝕜'
map_add' _ _ := rfl
map_smul' _ _ := rfl
norm_map' _ := rfl
/-- `ContinuousMultilinearMap.restrictScalars` as a `ContinuousLinearMap`. -/
def restrictScalarsLinear : ContinuousMultilinearMap 𝕜 E G →L[𝕜'] ContinuousMultilinearMap 𝕜' E G :=
(restrictScalarsₗᵢ 𝕜').toContinuousLinearMap
variable {𝕜'}
theorem continuous_restrictScalars :
Continuous
(restrictScalars 𝕜' : ContinuousMultilinearMap 𝕜 E G → ContinuousMultilinearMap 𝕜' E G) :=
(restrictScalarsLinear 𝕜').continuous
end RestrictScalars
/-- The difference `f m₁ - f m₂` is controlled in terms of `‖f‖` and `‖m₁ - m₂‖`, precise version.
For a less precise but more usable version, see `norm_image_sub_le`. The bound reads
`‖f m - f m'‖ ≤
‖f‖ * ‖m 1 - m' 1‖ * max ‖m 2‖ ‖m' 2‖ * max ‖m 3‖ ‖m' 3‖ * ... * max ‖m n‖ ‖m' n‖ + ...`,
where the other terms in the sum are the same products where `1` is replaced by any `i`. -/
theorem norm_image_sub_le' [DecidableEq ι] (m₁ m₂ : ∀ i, E i) :
‖f m₁ - f m₂‖ ≤ ‖f‖ * ∑ i, ∏ j, if j = i then ‖m₁ i - m₂ i‖ else max ‖m₁ j‖ ‖m₂ j‖ :=
f.toMultilinearMap.norm_image_sub_le_of_bound' (norm_nonneg _) f.le_opNorm _ _
/-- The difference `f m₁ - f m₂` is controlled in terms of `‖f‖` and `‖m₁ - m₂‖`, less precise
version. For a more precise but less usable version, see `norm_image_sub_le'`.
The bound is `‖f m - f m'‖ ≤ ‖f‖ * card ι * ‖m - m'‖ * (max ‖m‖ ‖m'‖) ^ (card ι - 1)`. -/
theorem norm_image_sub_le (m₁ m₂ : ∀ i, E i) :
‖f m₁ - f m₂‖ ≤ ‖f‖ * Fintype.card ι * max ‖m₁‖ ‖m₂‖ ^ (Fintype.card ι - 1) * ‖m₁ - m₂‖ :=
f.toMultilinearMap.norm_image_sub_le_of_bound (norm_nonneg _) f.le_opNorm _ _
end ContinuousMultilinearMap
variable [Fintype ι]
/-- If a continuous multilinear map is constructed from a multilinear map via the constructor
`mkContinuous`, then its norm is bounded by the bound given to the constructor if it is
nonnegative. -/
theorem MultilinearMap.mkContinuous_norm_le (f : MultilinearMap 𝕜 E G) {C : ℝ} (hC : 0 ≤ C)
(H : ∀ m, ‖f m‖ ≤ C * ∏ i, ‖m i‖) : ‖f.mkContinuous C H‖ ≤ C :=
ContinuousMultilinearMap.opNorm_le_bound _ hC fun m => H m
/-- If a continuous multilinear map is constructed from a multilinear map via the constructor
`mkContinuous`, then its norm is bounded by the bound given to the constructor if it is
nonnegative. -/
theorem MultilinearMap.mkContinuous_norm_le' (f : MultilinearMap 𝕜 E G) {C : ℝ}
(H : ∀ m, ‖f m‖ ≤ C * ∏ i, ‖m i‖) : ‖f.mkContinuous C H‖ ≤ max C 0 :=
ContinuousMultilinearMap.opNorm_le_bound _ (le_max_right _ _) fun m ↦ (H m).trans <|
mul_le_mul_of_nonneg_right (le_max_left _ _) <| by positivity
namespace ContinuousMultilinearMap
/-- Given a continuous multilinear map `f` on `n` variables (parameterized by `Fin n`) and a subset
`s` of `k` of these variables, one gets a new continuous multilinear map on `Fin k` by varying
these variables, and fixing the other ones equal to a given value `z`. It is denoted by
`f.restr s hk z`, where `hk` is a proof that the cardinality of `s` is `k`. The implicit
identification between `Fin k` and `s` that we use is the canonical (increasing) bijection. -/
def restr {k n : ℕ} (f : (G[×n]→L[𝕜] G' : _)) (s : Finset (Fin n)) (hk : s.card = k) (z : G) :
G[×k]→L[𝕜] G' :=
(f.toMultilinearMap.restr s hk z).mkContinuous (‖f‖ * ‖z‖ ^ (n - k)) fun _ =>
MultilinearMap.restr_norm_le _ _ _ _ f.le_opNorm _
theorem norm_restr {k n : ℕ} (f : G[×n]→L[𝕜] G') (s : Finset (Fin n)) (hk : s.card = k) (z : G) :
‖f.restr s hk z‖ ≤ ‖f‖ * ‖z‖ ^ (n - k) := by
apply MultilinearMap.mkContinuous_norm_le
exact mul_nonneg (norm_nonneg _) (pow_nonneg (norm_nonneg _) _)
section
variable {A : Type*} [NormedCommRing A] [NormedAlgebra 𝕜 A]
@[simp]
theorem norm_mkPiAlgebra_le [Nonempty ι] : ‖ContinuousMultilinearMap.mkPiAlgebra 𝕜 ι A‖ ≤ 1 := by
refine opNorm_le_bound _ zero_le_one fun m => ?_
simp only [ContinuousMultilinearMap.mkPiAlgebra_apply, one_mul]
exact norm_prod_le' _ univ_nonempty _
theorem norm_mkPiAlgebra_of_empty [IsEmpty ι] :
‖ContinuousMultilinearMap.mkPiAlgebra 𝕜 ι A‖ = ‖(1 : A)‖ := by
apply le_antisymm
· apply opNorm_le_bound <;> simp
· -- Porting note: have to annotate types to get mvars to unify
convert ratio_le_opNorm (ContinuousMultilinearMap.mkPiAlgebra 𝕜 ι A) fun _ => (1 : A)
simp [eq_empty_of_isEmpty (univ : Finset ι)]
@[simp]
theorem norm_mkPiAlgebra [NormOneClass A] : ‖ContinuousMultilinearMap.mkPiAlgebra 𝕜 ι A‖ = 1 := by
cases isEmpty_or_nonempty ι
· simp [norm_mkPiAlgebra_of_empty]
· refine le_antisymm norm_mkPiAlgebra_le ?_
convert ratio_le_opNorm (ContinuousMultilinearMap.mkPiAlgebra 𝕜 ι A) fun _ => 1
simp
end
section
variable {n : ℕ} {A : Type*} [NormedRing A] [NormedAlgebra 𝕜 A]
theorem norm_mkPiAlgebraFin_succ_le : ‖ContinuousMultilinearMap.mkPiAlgebraFin 𝕜 n.succ A‖ ≤ 1 := by
refine opNorm_le_bound _ zero_le_one fun m => ?_
simp only [ContinuousMultilinearMap.mkPiAlgebraFin_apply, one_mul, List.ofFn_eq_map,
Fin.prod_univ_def, Multiset.map_coe, Multiset.prod_coe]
refine (List.norm_prod_le' ?_).trans_eq ?_
· rw [Ne, List.map_eq_nil, List.finRange_eq_nil]
exact Nat.succ_ne_zero _
rw [List.map_map, Function.comp_def]
theorem norm_mkPiAlgebraFin_le_of_pos (hn : 0 < n) :
‖ContinuousMultilinearMap.mkPiAlgebraFin 𝕜 n A‖ ≤ 1 := by
obtain ⟨n, rfl⟩ := Nat.exists_eq_succ_of_ne_zero hn.ne'
exact norm_mkPiAlgebraFin_succ_le
theorem norm_mkPiAlgebraFin_zero : ‖ContinuousMultilinearMap.mkPiAlgebraFin 𝕜 0 A‖ = ‖(1 : A)‖ := by
refine le_antisymm ?_ ?_
· refine opNorm_le_bound _ (norm_nonneg (1 : A)) ?_
simp
· convert ratio_le_opNorm (ContinuousMultilinearMap.mkPiAlgebraFin 𝕜 0 A) fun _ => (1 : A)
simp
@[simp]
theorem norm_mkPiAlgebraFin [NormOneClass A] :
‖ContinuousMultilinearMap.mkPiAlgebraFin 𝕜 n A‖ = 1 := by
cases n
· rw [norm_mkPiAlgebraFin_zero]
simp
· refine le_antisymm norm_mkPiAlgebraFin_succ_le ?_
refine le_of_eq_of_le ?_ <|
ratio_le_opNorm (ContinuousMultilinearMap.mkPiAlgebraFin 𝕜 (Nat.succ _) A) fun _ => 1
simp
end
@[simp]
theorem nnnorm_smulRight (f : ContinuousMultilinearMap 𝕜 E 𝕜) (z : G) :
‖f.smulRight z‖₊ = ‖f‖₊ * ‖z‖₊ := by
refine le_antisymm ?_ ?_
· refine (opNNNorm_le_iff _ |>.2 fun m => (nnnorm_smul_le _ _).trans ?_)
rw [mul_right_comm]
gcongr
exact le_opNNNorm _ _
· obtain hz | hz := eq_or_ne ‖z‖₊ 0
· simp [hz]
rw [← NNReal.le_div_iff hz, opNNNorm_le_iff]
intro m
rw [div_mul_eq_mul_div, NNReal.le_div_iff hz]
refine le_trans ?_ ((f.smulRight z).le_opNNNorm m)
rw [smulRight_apply, nnnorm_smul]
@[simp]
theorem norm_smulRight (f : ContinuousMultilinearMap 𝕜 E 𝕜) (z : G) :
‖f.smulRight z‖ = ‖f‖ * ‖z‖ :=
congr_arg NNReal.toReal (nnnorm_smulRight f z)
@[simp]
theorem norm_mkPiRing (z : G) : ‖ContinuousMultilinearMap.mkPiRing 𝕜 ι z‖ = ‖z‖ := by
rw [ContinuousMultilinearMap.mkPiRing, norm_smulRight, norm_mkPiAlgebra, one_mul]
variable (𝕜 E G) in
/-- Continuous bilinear map realizing `(f, z) ↦ f.smulRight z`. -/
def smulRightL : ContinuousMultilinearMap 𝕜 E 𝕜 →L[𝕜] G →L[𝕜] ContinuousMultilinearMap 𝕜 E G :=
LinearMap.mkContinuous₂
{ toFun := fun f ↦
{ toFun := fun z ↦ f.smulRight z
map_add' := fun x y ↦ by ext; simp
map_smul' := fun c x ↦ by ext; simp [smul_smul, mul_comm] }
map_add' := fun f g ↦ by ext; simp [add_smul]
map_smul' := fun c f ↦ by ext; simp [smul_smul] }
1 (fun f z ↦ by simp [norm_smulRight])
@[simp] lemma smulRightL_apply (f : ContinuousMultilinearMap 𝕜 E 𝕜) (z : G) :
smulRightL 𝕜 E G f z = f.smulRight z := rfl
#adaptation_note
/--
Before https://github.com/leanprover/lean4/pull/4119 we had to create a local instance:
```
letI : SeminormedAddCommGroup
(ContinuousMultilinearMap 𝕜 E 𝕜 →L[𝕜] G →L[𝕜] ContinuousMultilinearMap 𝕜 E G) :=
ContinuousLinearMap.toSeminormedAddCommGroup
(F := G →L[𝕜] ContinuousMultilinearMap 𝕜 E G) (σ₁₂ := RingHom.id 𝕜)
```
-/
set_option maxSynthPendingDepth 2 in
lemma norm_smulRightL_le : ‖smulRightL 𝕜 E G‖ ≤ 1 :=
LinearMap.mkContinuous₂_norm_le _ zero_le_one _
variable (𝕜 ι G)
/-- Continuous multilinear maps on `𝕜^n` with values in `G` are in bijection with `G`, as such a
continuous multilinear map is completely determined by its value on the constant vector made of
ones. We register this bijection as a linear isometry in
`ContinuousMultilinearMap.piFieldEquiv`. -/
protected def piFieldEquiv : G ≃ₗᵢ[𝕜] ContinuousMultilinearMap 𝕜 (fun _ : ι => 𝕜) G where
toFun z := ContinuousMultilinearMap.mkPiRing 𝕜 ι z
invFun f := f fun i => 1
map_add' z z' := by
ext m
simp [smul_add]
map_smul' c z := by
ext m
simp [smul_smul, mul_comm]
left_inv z := by simp
right_inv f := f.mkPiRing_apply_one_eq_self
norm_map' := norm_mkPiRing
end ContinuousMultilinearMap
namespace ContinuousLinearMap
theorem norm_compContinuousMultilinearMap_le (g : G →L[𝕜] G') (f : ContinuousMultilinearMap 𝕜 E G) :
‖g.compContinuousMultilinearMap f‖ ≤ ‖g‖ * ‖f‖ :=
ContinuousMultilinearMap.opNorm_le_bound _ (mul_nonneg (norm_nonneg _) (norm_nonneg _)) fun m =>
calc
‖g (f m)‖ ≤ ‖g‖ * (‖f‖ * ∏ i, ‖m i‖) := g.le_opNorm_of_le <| f.le_opNorm _
_ = _ := (mul_assoc _ _ _).symm
variable (𝕜 E G G')
/-- `ContinuousLinearMap.compContinuousMultilinearMap` as a bundled continuous bilinear map. -/
def compContinuousMultilinearMapL :
(G →L[𝕜] G') →L[𝕜] ContinuousMultilinearMap 𝕜 E G →L[𝕜] ContinuousMultilinearMap 𝕜 E G' :=
LinearMap.mkContinuous₂
(LinearMap.mk₂ 𝕜 compContinuousMultilinearMap (fun f₁ f₂ g => rfl) (fun c f g => rfl)
(fun f g₁ g₂ => by ext1; apply f.map_add)
(fun c f g => by ext1; simp))
1
fun f g => by rw [one_mul]; exact f.norm_compContinuousMultilinearMap_le g
variable {𝕜 G G'}
/-- `ContinuousLinearMap.compContinuousMultilinearMap` as a bundled
continuous linear equiv. -/
nonrec
def _root_.ContinuousLinearEquiv.compContinuousMultilinearMapL (g : G ≃L[𝕜] G') :
ContinuousMultilinearMap 𝕜 E G ≃L[𝕜] ContinuousMultilinearMap 𝕜 E G' :=
{ compContinuousMultilinearMapL 𝕜 E G G' g.toContinuousLinearMap with
invFun := compContinuousMultilinearMapL 𝕜 E G' G g.symm.toContinuousLinearMap
left_inv := by
intro f
ext1 m
simp [compContinuousMultilinearMapL]
right_inv := by
intro f
ext1 m
simp [compContinuousMultilinearMapL]
continuous_toFun := (compContinuousMultilinearMapL 𝕜 E G G' g.toContinuousLinearMap).continuous
continuous_invFun :=
(compContinuousMultilinearMapL 𝕜 E G' G g.symm.toContinuousLinearMap).continuous }
@[simp]
theorem _root_.ContinuousLinearEquiv.compContinuousMultilinearMapL_symm (g : G ≃L[𝕜] G') :
(g.compContinuousMultilinearMapL E).symm = g.symm.compContinuousMultilinearMapL E :=
rfl
variable {E}
@[simp]
theorem _root_.ContinuousLinearEquiv.compContinuousMultilinearMapL_apply (g : G ≃L[𝕜] G')
(f : ContinuousMultilinearMap 𝕜 E G) :
g.compContinuousMultilinearMapL E f = (g : G →L[𝕜] G').compContinuousMultilinearMap f :=
rfl
/-- Flip arguments in `f : G →L[𝕜] ContinuousMultilinearMap 𝕜 E G'` to get
`ContinuousMultilinearMap 𝕜 E (G →L[𝕜] G')` -/
@[simps! apply_apply]
def flipMultilinear (f : G →L[𝕜] ContinuousMultilinearMap 𝕜 E G') :
ContinuousMultilinearMap 𝕜 E (G →L[𝕜] G') :=
MultilinearMap.mkContinuous
{ toFun := fun m =>
LinearMap.mkContinuous
{ toFun := fun x => f x m
map_add' := fun x y => by simp only [map_add, ContinuousMultilinearMap.add_apply]
map_smul' := fun c x => by
simp only [ContinuousMultilinearMap.smul_apply, map_smul, RingHom.id_apply] }
(‖f‖ * ∏ i, ‖m i‖) fun x => by
rw [mul_right_comm]
exact (f x).le_of_opNorm_le _ (f.le_opNorm x)
map_add' := fun m i x y => by
ext1
simp only [add_apply, ContinuousMultilinearMap.map_add, LinearMap.coe_mk,
LinearMap.mkContinuous_apply, AddHom.coe_mk]
map_smul' := fun m i c x => by
ext1
simp only [coe_smul', ContinuousMultilinearMap.map_smul, LinearMap.coe_mk,
LinearMap.mkContinuous_apply, Pi.smul_apply, AddHom.coe_mk] }
‖f‖ fun m => by
dsimp only [MultilinearMap.coe_mk]
exact LinearMap.mkContinuous_norm_le _ (by positivity) _
end ContinuousLinearMap
theorem LinearIsometry.norm_compContinuousMultilinearMap (g : G →ₗᵢ[𝕜] G')
(f : ContinuousMultilinearMap 𝕜 E G) :
‖g.toContinuousLinearMap.compContinuousMultilinearMap f‖ = ‖f‖ := by
simp only [ContinuousLinearMap.compContinuousMultilinearMap_coe,
LinearIsometry.coe_toContinuousLinearMap, LinearIsometry.norm_map,
ContinuousMultilinearMap.norm_def, Function.comp_apply]
open ContinuousMultilinearMap
namespace MultilinearMap
/-- Given a map `f : G →ₗ[𝕜] MultilinearMap 𝕜 E G'` and an estimate
`H : ∀ x m, ‖f x m‖ ≤ C * ‖x‖ * ∏ i, ‖m i‖`, construct a continuous linear
map from `G` to `ContinuousMultilinearMap 𝕜 E G'`.
In order to lift, e.g., a map `f : (MultilinearMap 𝕜 E G) →ₗ[𝕜] MultilinearMap 𝕜 E' G'`
to a map `(ContinuousMultilinearMap 𝕜 E G) →L[𝕜] ContinuousMultilinearMap 𝕜 E' G'`,
one can apply this construction to `f.comp ContinuousMultilinearMap.toMultilinearMapLinear`
which is a linear map from `ContinuousMultilinearMap 𝕜 E G` to `MultilinearMap 𝕜 E' G'`. -/
def mkContinuousLinear (f : G →ₗ[𝕜] MultilinearMap 𝕜 E G') (C : ℝ)
(H : ∀ x m, ‖f x m‖ ≤ C * ‖x‖ * ∏ i, ‖m i‖) : G →L[𝕜] ContinuousMultilinearMap 𝕜 E G' :=
LinearMap.mkContinuous
{ toFun := fun x => (f x).mkContinuous (C * ‖x‖) <| H x
map_add' := fun x y => by
ext1
simp only [_root_.map_add]
rfl
map_smul' := fun c x => by
ext1
simp only [_root_.map_smul]
rfl }
(max C 0) fun x => by
rw [LinearMap.coe_mk, AddHom.coe_mk] -- Porting note: added
exact ((f x).mkContinuous_norm_le' _).trans_eq <| by
rw [max_mul_of_nonneg _ _ (norm_nonneg x), zero_mul]
theorem mkContinuousLinear_norm_le' (f : G →ₗ[𝕜] MultilinearMap 𝕜 E G') (C : ℝ)
(H : ∀ x m, ‖f x m‖ ≤ C * ‖x‖ * ∏ i, ‖m i‖) : ‖mkContinuousLinear f C H‖ ≤ max C 0 := by
dsimp only [mkContinuousLinear]
exact LinearMap.mkContinuous_norm_le _ (le_max_right _ _) _
theorem mkContinuousLinear_norm_le (f : G →ₗ[𝕜] MultilinearMap 𝕜 E G') {C : ℝ} (hC : 0 ≤ C)
(H : ∀ x m, ‖f x m‖ ≤ C * ‖x‖ * ∏ i, ‖m i‖) : ‖mkContinuousLinear f C H‖ ≤ C :=
(mkContinuousLinear_norm_le' f C H).trans_eq (max_eq_left hC)
variable [∀ i, SeminormedAddCommGroup (E' i)] [∀ i, NormedSpace 𝕜 (E' i)]
/-- Given a map `f : MultilinearMap 𝕜 E (MultilinearMap 𝕜 E' G)` and an estimate
`H : ∀ m m', ‖f m m'‖ ≤ C * ∏ i, ‖m i‖ * ∏ i, ‖m' i‖`, upgrade all `MultilinearMap`s in the type to
`ContinuousMultilinearMap`s. -/
def mkContinuousMultilinear (f : MultilinearMap 𝕜 E (MultilinearMap 𝕜 E' G)) (C : ℝ)
(H : ∀ m₁ m₂, ‖f m₁ m₂‖ ≤ (C * ∏ i, ‖m₁ i‖) * ∏ i, ‖m₂ i‖) :
ContinuousMultilinearMap 𝕜 E (ContinuousMultilinearMap 𝕜 E' G) :=
mkContinuous
{ toFun := fun m => mkContinuous (f m) (C * ∏ i, ‖m i‖) <| H m
map_add' := fun m i x y => by
ext1
simp
map_smul' := fun m i c x => by
ext1
simp }
(max C 0) fun m => by
simp only [coe_mk]
refine ((f m).mkContinuous_norm_le' _).trans_eq ?_
rw [max_mul_of_nonneg, zero_mul]
positivity
@[simp]
theorem mkContinuousMultilinear_apply (f : MultilinearMap 𝕜 E (MultilinearMap 𝕜 E' G)) {C : ℝ}
(H : ∀ m₁ m₂, ‖f m₁ m₂‖ ≤ (C * ∏ i, ‖m₁ i‖) * ∏ i, ‖m₂ i‖) (m : ∀ i, E i) :
⇑(mkContinuousMultilinear f C H m) = f m :=
rfl
theorem mkContinuousMultilinear_norm_le' (f : MultilinearMap 𝕜 E (MultilinearMap 𝕜 E' G)) (C : ℝ)
(H : ∀ m₁ m₂, ‖f m₁ m₂‖ ≤ (C * ∏ i, ‖m₁ i‖) * ∏ i, ‖m₂ i‖) :
‖mkContinuousMultilinear f C H‖ ≤ max C 0 := by
dsimp only [mkContinuousMultilinear]
exact mkContinuous_norm_le _ (le_max_right _ _) _
theorem mkContinuousMultilinear_norm_le (f : MultilinearMap 𝕜 E (MultilinearMap 𝕜 E' G)) {C : ℝ}
(hC : 0 ≤ C) (H : ∀ m₁ m₂, ‖f m₁ m₂‖ ≤ (C * ∏ i, ‖m₁ i‖) * ∏ i, ‖m₂ i‖) :
‖mkContinuousMultilinear f C H‖ ≤ C :=
(mkContinuousMultilinear_norm_le' f C H).trans_eq (max_eq_left hC)
end MultilinearMap
namespace ContinuousMultilinearMap
theorem norm_compContinuousLinearMap_le (g : ContinuousMultilinearMap 𝕜 E₁ G)
(f : ∀ i, E i →L[𝕜] E₁ i) : ‖g.compContinuousLinearMap f‖ ≤ ‖g‖ * ∏ i, ‖f i‖ :=
opNorm_le_bound _ (by positivity) fun m =>
calc
‖g fun i => f i (m i)‖ ≤ ‖g‖ * ∏ i, ‖f i (m i)‖ := g.le_opNorm _
_ ≤ ‖g‖ * ∏ i, ‖f i‖ * ‖m i‖ :=
(mul_le_mul_of_nonneg_left
(prod_le_prod (fun _ _ => norm_nonneg _) fun i _ => (f i).le_opNorm (m i))
(norm_nonneg g))
_ = (‖g‖ * ∏ i, ‖f i‖) * ∏ i, ‖m i‖ := by rw [prod_mul_distrib, mul_assoc]
theorem norm_compContinuous_linearIsometry_le (g : ContinuousMultilinearMap 𝕜 E₁ G)
(f : ∀ i, E i →ₗᵢ[𝕜] E₁ i) :
‖g.compContinuousLinearMap fun i => (f i).toContinuousLinearMap‖ ≤ ‖g‖ := by
refine opNorm_le_bound _ (norm_nonneg _) fun m => ?_
apply (g.le_opNorm _).trans _
simp only [ContinuousLinearMap.coe_coe, LinearIsometry.coe_toContinuousLinearMap,
LinearIsometry.norm_map, le_rfl]
theorem norm_compContinuous_linearIsometryEquiv (g : ContinuousMultilinearMap 𝕜 E₁ G)
(f : ∀ i, E i ≃ₗᵢ[𝕜] E₁ i) :
‖g.compContinuousLinearMap fun i => (f i : E i →L[𝕜] E₁ i)‖ = ‖g‖ := by
apply le_antisymm (g.norm_compContinuous_linearIsometry_le fun i => (f i).toLinearIsometry)
have : g = (g.compContinuousLinearMap fun i => (f i : E i →L[𝕜] E₁ i)).compContinuousLinearMap
fun i => ((f i).symm : E₁ i →L[𝕜] E i) := by
ext1 m
simp only [compContinuousLinearMap_apply, LinearIsometryEquiv.coe_coe'',
LinearIsometryEquiv.apply_symm_apply]
conv_lhs => rw [this]
apply (g.compContinuousLinearMap fun i =>
(f i : E i →L[𝕜] E₁ i)).norm_compContinuous_linearIsometry_le
fun i => (f i).symm.toLinearIsometry
/-- `ContinuousMultilinearMap.compContinuousLinearMap` as a bundled continuous linear map.
This implementation fixes `f : Π i, E i →L[𝕜] E₁ i`.
Actually, the map is multilinear in `f`,
see `ContinuousMultilinearMap.compContinuousLinearMapContinuousMultilinear`.
For a version fixing `g` and varying `f`, see `compContinuousLinearMapLRight`. -/
def compContinuousLinearMapL (f : ∀ i, E i →L[𝕜] E₁ i) :
ContinuousMultilinearMap 𝕜 E₁ G →L[𝕜] ContinuousMultilinearMap 𝕜 E G :=
LinearMap.mkContinuous
{ toFun := fun g => g.compContinuousLinearMap f
map_add' := fun _ _ => rfl
map_smul' := fun _ _ => rfl }
(∏ i, ‖f i‖)
fun _ => (norm_compContinuousLinearMap_le _ _).trans_eq (mul_comm _ _)
@[simp]
theorem compContinuousLinearMapL_apply (g : ContinuousMultilinearMap 𝕜 E₁ G)
(f : ∀ i, E i →L[𝕜] E₁ i) : compContinuousLinearMapL f g = g.compContinuousLinearMap f :=
rfl
variable (G) in
theorem norm_compContinuousLinearMapL_le (f : ∀ i, E i →L[𝕜] E₁ i) :
‖compContinuousLinearMapL (G := G) f‖ ≤ ∏ i, ‖f i‖ :=
LinearMap.mkContinuous_norm_le _ (by positivity) _
/-- `ContinuousMultilinearMap.compContinuousLinearMap` as a bundled continuous linear map.
This implementation fixes `g : ContinuousMultilinearMap 𝕜 E₁ G`.
Actually, the map is linear in `g`,
see `ContinuousMultilinearMap.compContinuousLinearMapContinuousMultilinear`.
For a version fixing `f` and varying `g`, see `compContinuousLinearMapL`. -/
def compContinuousLinearMapLRight (g : ContinuousMultilinearMap 𝕜 E₁ G) :
ContinuousMultilinearMap 𝕜 (fun i ↦ E i →L[𝕜] E₁ i) (ContinuousMultilinearMap 𝕜 E G) :=
MultilinearMap.mkContinuous
{ toFun := fun f => g.compContinuousLinearMap f
map_add' := by
intro h f i f₁ f₂
ext x
simp only [compContinuousLinearMap_apply, add_apply]
convert g.map_add (fun j ↦ f j (x j)) i (f₁ (x i)) (f₂ (x i)) <;>
exact apply_update (fun (i : ι) (f : E i →L[𝕜] E₁ i) ↦ f (x i)) f i _ _
map_smul' := by
intro h f i a f₀
ext x
simp only [compContinuousLinearMap_apply, smul_apply]
convert g.map_smul (fun j ↦ f j (x j)) i a (f₀ (x i)) <;>
exact apply_update (fun (i : ι) (f : E i →L[𝕜] E₁ i) ↦ f (x i)) f i _ _ }
(‖g‖) (fun f ↦ by simp [norm_compContinuousLinearMap_le])
@[simp]
theorem compContinuousLinearMapLRight_apply (g : ContinuousMultilinearMap 𝕜 E₁ G)
(f : ∀ i, E i →L[𝕜] E₁ i) : compContinuousLinearMapLRight g f = g.compContinuousLinearMap f :=
rfl
variable (E) in
theorem norm_compContinuousLinearMapLRight_le (g : ContinuousMultilinearMap 𝕜 E₁ G) :
‖compContinuousLinearMapLRight (E := E) g‖ ≤ ‖g‖ :=
MultilinearMap.mkContinuous_norm_le _ (norm_nonneg _) _
variable (𝕜 E E₁ G)
open Function in
/-- If `f` is a collection of continuous linear maps, then the construction
`ContinuousMultilinearMap.compContinuousLinearMap`
sending a continuous multilinear map `g` to `g (f₁ ·, ..., fₙ ·)`
is continuous-linear in `g` and multilinear in `f₁, ..., fₙ`. -/
noncomputable def compContinuousLinearMapMultilinear :
MultilinearMap 𝕜 (fun i ↦ E i →L[𝕜] E₁ i)
((ContinuousMultilinearMap 𝕜 E₁ G) →L[𝕜] ContinuousMultilinearMap 𝕜 E G) where
toFun := compContinuousLinearMapL
map_add' f i f₁ f₂ := by
ext g x
change (g fun j ↦ update f i (f₁ + f₂) j <| x j) =
(g fun j ↦ update f i f₁ j <| x j) + g fun j ↦ update f i f₂ j (x j)
convert g.map_add (fun j ↦ f j (x j)) i (f₁ (x i)) (f₂ (x i)) <;>
exact apply_update (fun (i : ι) (f : E i →L[𝕜] E₁ i) ↦ f (x i)) f i _ _
map_smul' f i a f₀ := by
ext g x
change (g fun j ↦ update f i (a • f₀) j <| x j) = a • g fun j ↦ update f i f₀ j (x j)
convert g.map_smul (fun j ↦ f j (x j)) i a (f₀ (x i)) <;>
exact apply_update (fun (i : ι) (f : E i →L[𝕜] E₁ i) ↦ f (x i)) f i _ _
/-- If `f` is a collection of continuous linear maps, then the construction
`ContinuousMultilinearMap.compContinuousLinearMap`
sending a continuous multilinear map `g` to `g (f₁ ·, ..., fₙ ·)` is continuous-linear in `g` and
continuous-multilinear in `f₁, ..., fₙ`. -/
noncomputable def compContinuousLinearMapContinuousMultilinear :
ContinuousMultilinearMap 𝕜 (fun i ↦ E i →L[𝕜] E₁ i)
((ContinuousMultilinearMap 𝕜 E₁ G) →L[𝕜] ContinuousMultilinearMap 𝕜 E G) :=
@MultilinearMap.mkContinuous 𝕜 ι (fun i ↦ E i →L[𝕜] E₁ i)
((ContinuousMultilinearMap 𝕜 E₁ G) →L[𝕜] ContinuousMultilinearMap 𝕜 E G) _
(fun _ ↦ ContinuousLinearMap.toSeminormedAddCommGroup)
(fun _ ↦ ContinuousLinearMap.toNormedSpace) _ _
(compContinuousLinearMapMultilinear 𝕜 E E₁ G) _ 1
fun f ↦ by simpa using norm_compContinuousLinearMapL_le G f
variable {𝕜 E E₁}
/-- `ContinuousMultilinearMap.compContinuousLinearMap` as a bundled continuous linear equiv,
given `f : Π i, E i ≃L[𝕜] E₁ i`. -/
def compContinuousLinearMapEquivL (f : ∀ i, E i ≃L[𝕜] E₁ i) :
ContinuousMultilinearMap 𝕜 E₁ G ≃L[𝕜] ContinuousMultilinearMap 𝕜 E G :=
{ compContinuousLinearMapL fun i => (f i : E i →L[𝕜] E₁ i) with
invFun := compContinuousLinearMapL fun i => ((f i).symm : E₁ i →L[𝕜] E i)
continuous_toFun := (compContinuousLinearMapL fun i => (f i : E i →L[𝕜] E₁ i)).continuous
continuous_invFun :=
(compContinuousLinearMapL fun i => ((f i).symm : E₁ i →L[𝕜] E i)).continuous
left_inv := by
intro g
ext1 m
simp only [LinearMap.toFun_eq_coe, ContinuousLinearMap.coe_coe,
compContinuousLinearMapL_apply, compContinuousLinearMap_apply,
ContinuousLinearEquiv.coe_coe, ContinuousLinearEquiv.apply_symm_apply]
right_inv := by
intro g
ext1 m
simp only [compContinuousLinearMapL_apply, LinearMap.toFun_eq_coe,
ContinuousLinearMap.coe_coe, compContinuousLinearMap_apply,
ContinuousLinearEquiv.coe_coe, ContinuousLinearEquiv.symm_apply_apply] }
@[simp]
theorem compContinuousLinearMapEquivL_symm (f : ∀ i, E i ≃L[𝕜] E₁ i) :
(compContinuousLinearMapEquivL G f).symm =
compContinuousLinearMapEquivL G fun i : ι => (f i).symm :=
rfl
variable {G}
@[simp]
theorem compContinuousLinearMapEquivL_apply (g : ContinuousMultilinearMap 𝕜 E₁ G)
(f : ∀ i, E i ≃L[𝕜] E₁ i) :
compContinuousLinearMapEquivL G f g =
g.compContinuousLinearMap fun i => (f i : E i →L[𝕜] E₁ i) :=
rfl
/-- One of the components of the iterated derivative of a continuous multilinear map. Given a
bijection `e` between a type `α` (typically `Fin k`) and a subset `s` of `ι`, this component is a
continuous multilinear map of `k` vectors `v₁, ..., vₖ`, mapping them
to `f (x₁, (v_{e.symm 2})₂, x₃, ...)`, where at indices `i` in `s` one uses the `i`-th coordinate of
the vector `v_{e.symm i}` and otherwise one uses the `i`-th coordinate of a reference vector `x`.
This is continuous multilinear in the components of `x` outside of `s`, and in the `v_j`. -/
noncomputable def iteratedFDerivComponent {α : Type*} [Fintype α]
(f : ContinuousMultilinearMap 𝕜 E₁ G) {s : Set ι} (e : α ≃ s) [DecidablePred (· ∈ s)] :
ContinuousMultilinearMap 𝕜 (fun (i : {a : ι // a ∉ s}) ↦ E₁ i)
(ContinuousMultilinearMap 𝕜 (fun (_ : α) ↦ (∀ i, E₁ i)) G) :=
(f.toMultilinearMap.iteratedFDerivComponent e).mkContinuousMultilinear ‖f‖ <| by
intro x m
simp only [MultilinearMap.iteratedFDerivComponent, MultilinearMap.domDomRestrictₗ,
MultilinearMap.coe_mk, MultilinearMap.domDomRestrict_apply, coe_coe]
apply (f.le_opNorm _).trans _
classical
rw [← prod_compl_mul_prod s.toFinset, mul_assoc]
gcongr
· apply le_of_eq
have : ∀ x, x ∈ s.toFinsetᶜ ↔ (fun x ↦ x ∉ s) x := by simp
rw [prod_subtype _ this]
congr with i
simp [i.2]
· rw [prod_subtype _ (fun _ ↦ s.mem_toFinset), ← Equiv.prod_comp e.symm]
apply Finset.prod_le_prod (fun i _ ↦ norm_nonneg _) (fun i _ ↦ ?_)
simpa only [i.2, ↓reduceDIte, Subtype.coe_eta] using norm_le_pi_norm (m (e.symm i)) ↑i
@[simp] lemma iteratedFDerivComponent_apply {α : Type*} [Fintype α]
(f : ContinuousMultilinearMap 𝕜 E₁ G) {s : Set ι} (e : α ≃ s) [DecidablePred (· ∈ s)]
(v : ∀ i : {a : ι // a ∉ s}, E₁ i) (w : α → (∀ i, E₁ i)) :
f.iteratedFDerivComponent e v w =
f (fun j ↦ if h : j ∈ s then w (e.symm ⟨j, h⟩) j else v ⟨j, h⟩) := by
simp [iteratedFDerivComponent, MultilinearMap.iteratedFDerivComponent,
MultilinearMap.domDomRestrictₗ]
lemma norm_iteratedFDerivComponent_le {α : Type*} [Fintype α]
(f : ContinuousMultilinearMap 𝕜 E₁ G) {s : Set ι} (e : α ≃ s) [DecidablePred (· ∈ s)]
(x : (i : ι) → E₁ i) :
‖f.iteratedFDerivComponent e (x ·)‖ ≤ ‖f‖ * ‖x‖ ^ (Fintype.card ι - Fintype.card α) := calc
‖f.iteratedFDerivComponent e (fun i ↦ x i)‖
≤ ‖f.iteratedFDerivComponent e‖ * ∏ i : {a : ι // a ∉ s}, ‖x i‖ :=
ContinuousMultilinearMap.le_opNorm _ _
_ ≤ ‖f‖ * ∏ _i : {a : ι // a ∉ s}, ‖x‖ := by
gcongr
· exact MultilinearMap.mkContinuousMultilinear_norm_le _ (norm_nonneg _) _
· exact fun _ _ ↦ norm_nonneg _
· exact norm_le_pi_norm _ _
_ = ‖f‖ * ‖x‖ ^ (Fintype.card {a : ι // a ∉ s}) := by rw [prod_const, card_univ]
_ = ‖f‖ * ‖x‖ ^ (Fintype.card ι - Fintype.card α) := by simp [Fintype.card_congr e]
open Classical in
/-- The `k`-th iterated derivative of a continuous multilinear map `f` at the point `x`. It is a
continuous multilinear map of `k` vectors `v₁, ..., vₖ` (with the same type as `x`), mapping them
to `∑ f (x₁, (v_{i₁})₂, x₃, ...)`, where at each index `j` one uses either `xⱼ` or one
of the `(vᵢ)ⱼ`, and each `vᵢ` has to be used exactly once.
The sum is parameterized by the embeddings of `Fin k` in the index type `ι` (or, equivalently,
by the subsets `s` of `ι` of cardinality `k` and then the bijections between `Fin k` and `s`).
The fact that this is indeed the iterated Fréchet derivative is proved in
`ContinuousMultilinearMap.iteratedFDeriv_eq`.
-/
protected def iteratedFDeriv (f : ContinuousMultilinearMap 𝕜 E₁ G) (k : ℕ) (x : (i : ι) → E₁ i) :
ContinuousMultilinearMap 𝕜 (fun (_ : Fin k) ↦ (∀ i, E₁ i)) G :=
∑ e : Fin k ↪ ι, iteratedFDerivComponent f e.toEquivRange (Pi.compRightL 𝕜 _ Subtype.val x)
/-- Controlling the norm of `f.iteratedFDeriv` when `f` is continuous multilinear. For the same
bound on the iterated derivative of `f` in the calculus sense,
see `ContinuousMultilinearMap.norm_iteratedFDeriv_le`. -/
lemma norm_iteratedFDeriv_le' (f : ContinuousMultilinearMap 𝕜 E₁ G) (k : ℕ) (x : (i : ι) → E₁ i) :
‖f.iteratedFDeriv k x‖
≤ Nat.descFactorial (Fintype.card ι) k * ‖f‖ * ‖x‖ ^ (Fintype.card ι - k) := by
classical
calc ‖f.iteratedFDeriv k x‖
_ ≤ ∑ e : Fin k ↪ ι, ‖iteratedFDerivComponent f e.toEquivRange (fun i ↦ x i)‖ := norm_sum_le _ _
_ ≤ ∑ _ : Fin k ↪ ι, ‖f‖ * ‖x‖ ^ (Fintype.card ι - k) := by
gcongr with e _
simpa using norm_iteratedFDerivComponent_le f e.toEquivRange x
_ = Nat.descFactorial (Fintype.card ι) k * ‖f‖ * ‖x‖ ^ (Fintype.card ι - k) := by
simp [card_univ, mul_assoc]
end ContinuousMultilinearMap
end Seminorm
section Norm
namespace ContinuousMultilinearMap
/-! Results that are only true if the target space is a `NormedAddCommGroup` (and not just a
`SeminormedAddCommGroup`). -/
variable {𝕜 : Type u} {ι : Type v} {E : ι → Type wE} {G : Type wG} {G' : Type wG'} [Fintype ι]
[NontriviallyNormedField 𝕜] [∀ i, SeminormedAddCommGroup (E i)] [∀ i, NormedSpace 𝕜 (E i)]
[NormedAddCommGroup G] [NormedSpace 𝕜 G] [SeminormedAddCommGroup G'] [NormedSpace 𝕜 G']
variable (f : ContinuousMultilinearMap 𝕜 E G)
/-- A continuous linear map is zero iff its norm vanishes. -/
theorem opNorm_zero_iff : ‖f‖ = 0 ↔ f = 0 := by
simp [← (opNorm_nonneg f).le_iff_eq, opNorm_le_iff f le_rfl, ContinuousMultilinearMap.ext_iff]
@[deprecated (since := "2024-02-02")] alias op_norm_zero_iff := opNorm_zero_iff
/-- Continuous multilinear maps themselves form a normed group with respect to
the operator norm. -/
instance normedAddCommGroup : NormedAddCommGroup (ContinuousMultilinearMap 𝕜 E G) :=
NormedAddCommGroup.ofSeparation (fun f ↦ (opNorm_zero_iff f).mp)
/-- An alias of `ContinuousMultilinearMap.normedAddCommGroup` with non-dependent types to help
typeclass search. -/
instance normedAddCommGroup' :
NormedAddCommGroup (ContinuousMultilinearMap 𝕜 (fun _ : ι => G') G) :=
ContinuousMultilinearMap.normedAddCommGroup
variable (𝕜 G)
theorem norm_ofSubsingleton_id [Subsingleton ι] [Nontrivial G] (i : ι) :
‖ofSubsingleton 𝕜 G G i (.id _ _)‖ = 1 := by simp
theorem nnnorm_ofSubsingleton_id [Subsingleton ι] [Nontrivial G] (i : ι) :
‖ofSubsingleton 𝕜 G G i (.id _ _)‖₊ = 1 :=
NNReal.eq <| norm_ofSubsingleton_id _ _ _
end ContinuousMultilinearMap
end Norm
section Norm
/-! Results that are only true if the source is a `NormedAddCommGroup` (and not just a
`SeminormedAddCommGroup`). -/
variable {𝕜 : Type u} {ι : Type v} {E : ι → Type wE} {G : Type wG} [Fintype ι]
[NontriviallyNormedField 𝕜] [∀ i, NormedAddCommGroup (E i)] [∀ i, NormedSpace 𝕜 (E i)]
[SeminormedAddCommGroup G] [NormedSpace 𝕜 G]
namespace MultilinearMap
variable (f : MultilinearMap 𝕜 E G)
/-- If a multilinear map in finitely many variables on normed spaces satisfies the inequality
`‖f m‖ ≤ C * ∏ i, ‖m i‖` on a shell `ε i / ‖c i‖ < ‖m i‖ < ε i` for some positive numbers `ε i`
and elements `c i : 𝕜`, `1 < ‖c i‖`, then it satisfies this inequality for all `m`. -/
theorem bound_of_shell {ε : ι → ℝ} {C : ℝ} (hε : ∀ i, 0 < ε i) {c : ι → 𝕜} (hc : ∀ i, 1 < ‖c i‖)
(hf : ∀ m : ∀ i, E i, (∀ i, ε i / ‖c i‖ ≤ ‖m i‖) → (∀ i, ‖m i‖ < ε i) → ‖f m‖ ≤ C * ∏ i, ‖m i‖)
(m : ∀ i, E i) : ‖f m‖ ≤ C * ∏ i, ‖m i‖ :=
bound_of_shell_of_norm_map_coord_zero f
(fun h ↦ by rw [map_coord_zero f _ (norm_eq_zero.1 h), norm_zero]) hε hc hf m
end MultilinearMap
end Norm
|
Analysis\NormedSpace\Multilinear\Curry.lean | /-
Copyright (c) 2020 Sébastien Gouëzel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sébastien Gouëzel
-/
import Mathlib.Analysis.NormedSpace.Multilinear.Basic
/-!
# Currying and uncurrying continuous multilinear maps
We associate to a continuous multilinear map in `n+1` variables (i.e., based on `Fin n.succ`) two
curried functions, named `f.curryLeft` (which is a continuous linear map on `E 0` taking values
in continuous multilinear maps in `n` variables) and `f.curryRight` (which is a continuous
multilinear map in `n` variables taking values in continuous linear maps on `E (last n)`).
The inverse operations are called `uncurryLeft` and `uncurryRight`.
We also register continuous linear equiv versions of these correspondences, in
`continuousMultilinearCurryLeftEquiv` and `continuousMultilinearCurryRightEquiv`.
## Main results
* `ContinuousMultilinearMap.curryLeft`, `ContinuousLinearMap.uncurryLeft` and
`continuousMultilinearCurryLeftEquiv`
* `ContinuousMultilinearMap.curryRight`, `ContinuousMultilinearMap.uncurryRight` and
`continuousMultilinearCurryRightEquiv`.
-/
suppress_compilation
noncomputable section
open NNReal Finset Metric ContinuousMultilinearMap Fin Function
/-!
### Type variables
We use the following type variables in this file:
* `𝕜` : a `NontriviallyNormedField`;
* `ι`, `ι'` : finite index types with decidable equality;
* `E`, `E₁` : families of normed vector spaces over `𝕜` indexed by `i : ι`;
* `E'` : a family of normed vector spaces over `𝕜` indexed by `i' : ι'`;
* `Ei` : a family of normed vector spaces over `𝕜` indexed by `i : Fin (Nat.succ n)`;
* `G`, `G'` : normed vector spaces over `𝕜`.
-/
universe u v v' wE wE₁ wE' wEi wG wG'
variable {𝕜 : Type u} {ι : Type v} {ι' : Type v'} {n : ℕ} {E : ι → Type wE} {E₁ : ι → Type wE₁}
{E' : ι' → Type wE'} {Ei : Fin n.succ → Type wEi} {G : Type wG} {G' : Type wG'} [Fintype ι]
[Fintype ι'] [NontriviallyNormedField 𝕜] [∀ i, NormedAddCommGroup (E i)]
[∀ i, NormedSpace 𝕜 (E i)] [∀ i, NormedAddCommGroup (E₁ i)] [∀ i, NormedSpace 𝕜 (E₁ i)]
[∀ i, NormedAddCommGroup (E' i)] [∀ i, NormedSpace 𝕜 (E' i)] [∀ i, NormedAddCommGroup (Ei i)]
[∀ i, NormedSpace 𝕜 (Ei i)] [NormedAddCommGroup G] [NormedSpace 𝕜 G] [NormedAddCommGroup G']
[NormedSpace 𝕜 G']
theorem ContinuousLinearMap.norm_map_tail_le
(f : Ei 0 →L[𝕜] ContinuousMultilinearMap 𝕜 (fun i : Fin n => Ei i.succ) G) (m : ∀ i, Ei i) :
‖f (m 0) (tail m)‖ ≤ ‖f‖ * ∏ i, ‖m i‖ :=
calc
‖f (m 0) (tail m)‖ ≤ ‖f (m 0)‖ * ∏ i, ‖(tail m) i‖ := (f (m 0)).le_opNorm _
_ ≤ ‖f‖ * ‖m 0‖ * ∏ i, ‖tail m i‖ := mul_le_mul_of_nonneg_right (f.le_opNorm _) <| by positivity
_ = ‖f‖ * (‖m 0‖ * ∏ i, ‖(tail m) i‖) := by ring
_ = ‖f‖ * ∏ i, ‖m i‖ := by
rw [prod_univ_succ]
rfl
theorem ContinuousMultilinearMap.norm_map_init_le
(f : ContinuousMultilinearMap 𝕜 (fun i : Fin n => Ei <| castSucc i) (Ei (last n) →L[𝕜] G))
(m : ∀ i, Ei i) : ‖f (init m) (m (last n))‖ ≤ ‖f‖ * ∏ i, ‖m i‖ :=
calc
‖f (init m) (m (last n))‖ ≤ ‖f (init m)‖ * ‖m (last n)‖ := (f (init m)).le_opNorm _
_ ≤ (‖f‖ * ∏ i, ‖(init m) i‖) * ‖m (last n)‖ :=
(mul_le_mul_of_nonneg_right (f.le_opNorm _) (norm_nonneg _))
_ = ‖f‖ * ((∏ i, ‖(init m) i‖) * ‖m (last n)‖) := mul_assoc _ _ _
_ = ‖f‖ * ∏ i, ‖m i‖ := by
rw [prod_univ_castSucc]
rfl
theorem ContinuousMultilinearMap.norm_map_cons_le (f : ContinuousMultilinearMap 𝕜 Ei G) (x : Ei 0)
(m : ∀ i : Fin n, Ei i.succ) : ‖f (cons x m)‖ ≤ ‖f‖ * ‖x‖ * ∏ i, ‖m i‖ :=
calc
‖f (cons x m)‖ ≤ ‖f‖ * ∏ i, ‖cons x m i‖ := f.le_opNorm _
_ = ‖f‖ * ‖x‖ * ∏ i, ‖m i‖ := by
rw [prod_univ_succ]
simp [mul_assoc]
theorem ContinuousMultilinearMap.norm_map_snoc_le (f : ContinuousMultilinearMap 𝕜 Ei G)
(m : ∀ i : Fin n, Ei <| castSucc i) (x : Ei (last n)) :
‖f (snoc m x)‖ ≤ (‖f‖ * ∏ i, ‖m i‖) * ‖x‖ :=
calc
‖f (snoc m x)‖ ≤ ‖f‖ * ∏ i, ‖snoc m x i‖ := f.le_opNorm _
_ = (‖f‖ * ∏ i, ‖m i‖) * ‖x‖ := by
rw [prod_univ_castSucc]
simp [mul_assoc]
/-! #### Left currying -/
/-- Given a continuous linear map `f` from `E 0` to continuous multilinear maps on `n` variables,
construct the corresponding continuous multilinear map on `n+1` variables obtained by concatenating
the variables, given by `m ↦ f (m 0) (tail m)`-/
def ContinuousLinearMap.uncurryLeft
(f : Ei 0 →L[𝕜] ContinuousMultilinearMap 𝕜 (fun i : Fin n => Ei i.succ) G) :
ContinuousMultilinearMap 𝕜 Ei G :=
(@LinearMap.uncurryLeft 𝕜 n Ei G _ _ _ _ _
(ContinuousMultilinearMap.toMultilinearMapLinear.comp f.toLinearMap)).mkContinuous
‖f‖ fun m => by exact ContinuousLinearMap.norm_map_tail_le f m
@[simp]
theorem ContinuousLinearMap.uncurryLeft_apply
(f : Ei 0 →L[𝕜] ContinuousMultilinearMap 𝕜 (fun i : Fin n => Ei i.succ) G) (m : ∀ i, Ei i) :
f.uncurryLeft m = f (m 0) (tail m) :=
rfl
/-- Given a continuous multilinear map `f` in `n+1` variables, split the first variable to obtain
a continuous linear map into continuous multilinear maps in `n` variables, given by
`x ↦ (m ↦ f (cons x m))`. -/
def ContinuousMultilinearMap.curryLeft (f : ContinuousMultilinearMap 𝕜 Ei G) :
Ei 0 →L[𝕜] ContinuousMultilinearMap 𝕜 (fun i : Fin n => Ei i.succ) G :=
LinearMap.mkContinuous
{ -- define a linear map into `n` continuous multilinear maps
-- from an `n+1` continuous multilinear map
toFun := fun x =>
(f.toMultilinearMap.curryLeft x).mkContinuous (‖f‖ * ‖x‖) (f.norm_map_cons_le x)
map_add' := fun x y => by
ext m
exact f.cons_add m x y
map_smul' := fun c x => by
ext m
exact
f.cons_smul m c x }-- then register its continuity thanks to its boundedness properties.
‖f‖ fun x => by
rw [LinearMap.coe_mk, AddHom.coe_mk]
exact MultilinearMap.mkContinuous_norm_le _ (mul_nonneg (norm_nonneg _) (norm_nonneg _)) _
@[simp]
theorem ContinuousMultilinearMap.curryLeft_apply (f : ContinuousMultilinearMap 𝕜 Ei G) (x : Ei 0)
(m : ∀ i : Fin n, Ei i.succ) : f.curryLeft x m = f (cons x m) :=
rfl
@[simp]
theorem ContinuousLinearMap.curry_uncurryLeft
(f : Ei 0 →L[𝕜] ContinuousMultilinearMap 𝕜 (fun i : Fin n => Ei i.succ) G) :
f.uncurryLeft.curryLeft = f := by
ext m x
rw [ContinuousMultilinearMap.curryLeft_apply, ContinuousLinearMap.uncurryLeft_apply, tail_cons,
cons_zero]
@[simp]
theorem ContinuousMultilinearMap.uncurry_curryLeft (f : ContinuousMultilinearMap 𝕜 Ei G) :
f.curryLeft.uncurryLeft = f :=
ContinuousMultilinearMap.toMultilinearMap_injective <| f.toMultilinearMap.uncurry_curryLeft
variable (𝕜 Ei G)
/-- The space of continuous multilinear maps on `Π(i : Fin (n+1)), E i` is canonically isomorphic to
the space of continuous linear maps from `E 0` to the space of continuous multilinear maps on
`Π(i : Fin n), E i.succ`, by separating the first variable. We register this isomorphism in
`continuousMultilinearCurryLeftEquiv 𝕜 E E₂`. The algebraic version (without topology) is given
in `multilinearCurryLeftEquiv 𝕜 E E₂`.
The direct and inverse maps are given by `f.uncurryLeft` and `f.curryLeft`. Use these
unless you need the full framework of linear isometric equivs. -/
def continuousMultilinearCurryLeftEquiv :
(Ei 0 →L[𝕜] ContinuousMultilinearMap 𝕜 (fun i : Fin n => Ei i.succ) G) ≃ₗᵢ[𝕜]
ContinuousMultilinearMap 𝕜 Ei G :=
LinearIsometryEquiv.ofBounds
{ toFun := ContinuousLinearMap.uncurryLeft
map_add' := fun f₁ f₂ => by
ext m
rfl
map_smul' := fun c f => by
ext m
rfl
invFun := ContinuousMultilinearMap.curryLeft
left_inv := ContinuousLinearMap.curry_uncurryLeft
right_inv := ContinuousMultilinearMap.uncurry_curryLeft }
(fun f => by
simp only [LinearEquiv.coe_mk]
exact MultilinearMap.mkContinuous_norm_le _ (norm_nonneg f) _)
(fun f => by
simp only [LinearEquiv.coe_symm_mk]
exact LinearMap.mkContinuous_norm_le _ (norm_nonneg f) _)
variable {𝕜 Ei G}
@[simp]
theorem continuousMultilinearCurryLeftEquiv_apply
(f : Ei 0 →L[𝕜] ContinuousMultilinearMap 𝕜 (fun i : Fin n => Ei i.succ) G) (v : ∀ i, Ei i) :
continuousMultilinearCurryLeftEquiv 𝕜 Ei G f v = f (v 0) (tail v) :=
rfl
@[simp]
theorem continuousMultilinearCurryLeftEquiv_symm_apply (f : ContinuousMultilinearMap 𝕜 Ei G)
(x : Ei 0) (v : ∀ i : Fin n, Ei i.succ) :
(continuousMultilinearCurryLeftEquiv 𝕜 Ei G).symm f x v = f (cons x v) :=
rfl
@[simp]
theorem ContinuousMultilinearMap.curryLeft_norm (f : ContinuousMultilinearMap 𝕜 Ei G) :
‖f.curryLeft‖ = ‖f‖ :=
(continuousMultilinearCurryLeftEquiv 𝕜 Ei G).symm.norm_map f
@[simp]
theorem ContinuousLinearMap.uncurryLeft_norm
(f : Ei 0 →L[𝕜] ContinuousMultilinearMap 𝕜 (fun i : Fin n => Ei i.succ) G) :
‖f.uncurryLeft‖ = ‖f‖ :=
(continuousMultilinearCurryLeftEquiv 𝕜 Ei G).norm_map f
/-! #### Right currying -/
/-- Given a continuous linear map `f` from continuous multilinear maps on `n` variables to
continuous linear maps on `E 0`, construct the corresponding continuous multilinear map on `n+1`
variables obtained by concatenating the variables, given by `m ↦ f (init m) (m (last n))`. -/
def ContinuousMultilinearMap.uncurryRight
(f : ContinuousMultilinearMap 𝕜 (fun i : Fin n => Ei <| castSucc i) (Ei (last n) →L[𝕜] G)) :
ContinuousMultilinearMap 𝕜 Ei G :=
let f' : MultilinearMap 𝕜 (fun i : Fin n => Ei <| castSucc i) (Ei (last n) →ₗ[𝕜] G) :=
{ toFun := fun m => (f m).toLinearMap
map_add' := fun m i x y => by simp
map_smul' := fun m i c x => by simp }
(@MultilinearMap.uncurryRight 𝕜 n Ei G _ _ _ _ _ f').mkContinuous ‖f‖ fun m =>
f.norm_map_init_le m
@[simp]
theorem ContinuousMultilinearMap.uncurryRight_apply
(f : ContinuousMultilinearMap 𝕜 (fun i : Fin n => Ei <| castSucc i) (Ei (last n) →L[𝕜] G))
(m : ∀ i, Ei i) : f.uncurryRight m = f (init m) (m (last n)) :=
rfl
/-- Given a continuous multilinear map `f` in `n+1` variables, split the last variable to obtain
a continuous multilinear map in `n` variables into continuous linear maps, given by
`m ↦ (x ↦ f (snoc m x))`. -/
def ContinuousMultilinearMap.curryRight (f : ContinuousMultilinearMap 𝕜 Ei G) :
ContinuousMultilinearMap 𝕜 (fun i : Fin n => Ei <| castSucc i) (Ei (last n) →L[𝕜] G) :=
let f' : MultilinearMap 𝕜 (fun i : Fin n => Ei <| castSucc i) (Ei (last n) →L[𝕜] G) :=
{ toFun := fun m =>
(f.toMultilinearMap.curryRight m).mkContinuous (‖f‖ * ∏ i, ‖m i‖) fun x =>
f.norm_map_snoc_le m x
map_add' := fun m i x y => by
ext
simp
map_smul' := fun m i c x => by
ext
simp }
f'.mkContinuous ‖f‖ fun m => by
simp only [f', MultilinearMap.coe_mk]
exact LinearMap.mkContinuous_norm_le _ (by positivity) _
@[simp]
theorem ContinuousMultilinearMap.curryRight_apply (f : ContinuousMultilinearMap 𝕜 Ei G)
(m : ∀ i : Fin n, Ei <| castSucc i) (x : Ei (last n)) : f.curryRight m x = f (snoc m x) :=
rfl
@[simp]
theorem ContinuousMultilinearMap.curry_uncurryRight
(f : ContinuousMultilinearMap 𝕜 (fun i : Fin n => Ei <| castSucc i) (Ei (last n) →L[𝕜] G)) :
f.uncurryRight.curryRight = f := by
ext m x
rw [ContinuousMultilinearMap.curryRight_apply, ContinuousMultilinearMap.uncurryRight_apply,
snoc_last, init_snoc]
@[simp]
theorem ContinuousMultilinearMap.uncurry_curryRight (f : ContinuousMultilinearMap 𝕜 Ei G) :
f.curryRight.uncurryRight = f := by
ext m
rw [uncurryRight_apply, curryRight_apply, snoc_init_self]
variable (𝕜 Ei G)
/--
The space of continuous multilinear maps on `Π(i : Fin (n+1)), Ei i` is canonically isomorphic to
the space of continuous multilinear maps on `Π(i : Fin n), Ei <| castSucc i` with values in the
space of continuous linear maps on `Ei (last n)`, by separating the last variable. We register this
isomorphism as a continuous linear equiv in `continuousMultilinearCurryRightEquiv 𝕜 Ei G`.
The algebraic version (without topology) is given in `multilinearCurryRightEquiv 𝕜 Ei G`.
The direct and inverse maps are given by `f.uncurryRight` and `f.curryRight`. Use these
unless you need the full framework of linear isometric equivs.
-/
def continuousMultilinearCurryRightEquiv :
ContinuousMultilinearMap 𝕜 (fun i : Fin n => Ei <| castSucc i) (Ei (last n) →L[𝕜] G) ≃ₗᵢ[𝕜]
ContinuousMultilinearMap 𝕜 Ei G :=
LinearIsometryEquiv.ofBounds
{ toFun := ContinuousMultilinearMap.uncurryRight
map_add' := fun f₁ f₂ => by
ext m
rfl
map_smul' := fun c f => by
ext m
rfl
invFun := ContinuousMultilinearMap.curryRight
left_inv := ContinuousMultilinearMap.curry_uncurryRight
right_inv := ContinuousMultilinearMap.uncurry_curryRight } (fun f => by
simp only [uncurryRight, LinearEquiv.coe_mk]
exact MultilinearMap.mkContinuous_norm_le _ (norm_nonneg f) _) fun f => by
simp only [curryRight, LinearEquiv.coe_symm_mk]
exact MultilinearMap.mkContinuous_norm_le _ (norm_nonneg f) _
variable (n G')
/-- The space of continuous multilinear maps on `Π(i : Fin (n+1)), G` is canonically isomorphic to
the space of continuous multilinear maps on `Π(i : Fin n), G` with values in the space
of continuous linear maps on `G`, by separating the last variable. We register this
isomorphism as a continuous linear equiv in `continuousMultilinearCurryRightEquiv' 𝕜 n G G'`.
For a version allowing dependent types, see `continuousMultilinearCurryRightEquiv`. When there
are no dependent types, use the primed version as it helps Lean a lot for unification.
The direct and inverse maps are given by `f.uncurryRight` and `f.curryRight`. Use these
unless you need the full framework of linear isometric equivs. -/
def continuousMultilinearCurryRightEquiv' : (G[×n]→L[𝕜] G →L[𝕜] G') ≃ₗᵢ[𝕜] G[×n.succ]→L[𝕜] G' :=
continuousMultilinearCurryRightEquiv 𝕜 (fun _ => G) G'
variable {n 𝕜 G Ei G'}
@[simp]
theorem continuousMultilinearCurryRightEquiv_apply
(f : ContinuousMultilinearMap 𝕜 (fun i : Fin n => Ei <| castSucc i) (Ei (last n) →L[𝕜] G))
(v : ∀ i, Ei i) : (continuousMultilinearCurryRightEquiv 𝕜 Ei G) f v = f (init v) (v (last n)) :=
rfl
@[simp]
theorem continuousMultilinearCurryRightEquiv_symm_apply (f : ContinuousMultilinearMap 𝕜 Ei G)
(v : ∀ i : Fin n, Ei <| castSucc i) (x : Ei (last n)) :
(continuousMultilinearCurryRightEquiv 𝕜 Ei G).symm f v x = f (snoc v x) :=
rfl
@[simp]
theorem continuousMultilinearCurryRightEquiv_apply' (f : G[×n]→L[𝕜] G →L[𝕜] G')
(v : Fin (n + 1) → G) :
continuousMultilinearCurryRightEquiv' 𝕜 n G G' f v = f (init v) (v (last n)) :=
rfl
@[simp]
theorem continuousMultilinearCurryRightEquiv_symm_apply' (f : G[×n.succ]→L[𝕜] G')
(v : Fin n → G) (x : G) :
(continuousMultilinearCurryRightEquiv' 𝕜 n G G').symm f v x = f (snoc v x) :=
rfl
@[simp]
theorem ContinuousMultilinearMap.curryRight_norm (f : ContinuousMultilinearMap 𝕜 Ei G) :
‖f.curryRight‖ = ‖f‖ :=
(continuousMultilinearCurryRightEquiv 𝕜 Ei G).symm.norm_map f
@[simp]
theorem ContinuousMultilinearMap.uncurryRight_norm
(f : ContinuousMultilinearMap 𝕜 (fun i : Fin n => Ei <| castSucc i) (Ei (last n) →L[𝕜] G)) :
‖f.uncurryRight‖ = ‖f‖ :=
(continuousMultilinearCurryRightEquiv 𝕜 Ei G).norm_map f
/-!
#### Currying with `0` variables
The space of multilinear maps with `0` variables is trivial: such a multilinear map is just an
arbitrary constant (note that multilinear maps in `0` variables need not map `0` to `0`!).
Therefore, the space of continuous multilinear maps on `(Fin 0) → G` with values in `E₂` is
isomorphic (and even isometric) to `E₂`. As this is the zeroth step in the construction of iterated
derivatives, we register this isomorphism. -/
section
/-- Associating to a continuous multilinear map in `0` variables the unique value it takes. -/
def ContinuousMultilinearMap.uncurry0 (f : ContinuousMultilinearMap 𝕜 (fun _ : Fin 0 => G) G') :
G' :=
f 0
variable (𝕜 G)
/-- Associating to an element `x` of a vector space `E₂` the continuous multilinear map in `0`
variables taking the (unique) value `x` -/
def ContinuousMultilinearMap.curry0 (x : G') : G[×0]→L[𝕜] G' :=
ContinuousMultilinearMap.constOfIsEmpty 𝕜 _ x
variable {G}
@[simp]
theorem ContinuousMultilinearMap.curry0_apply (x : G') (m : Fin 0 → G) :
ContinuousMultilinearMap.curry0 𝕜 G x m = x :=
rfl
variable {𝕜}
@[simp]
theorem ContinuousMultilinearMap.uncurry0_apply (f : G[×0]→L[𝕜] G') : f.uncurry0 = f 0 :=
rfl
@[simp]
theorem ContinuousMultilinearMap.apply_zero_curry0 (f : G[×0]→L[𝕜] G') {x : Fin 0 → G} :
ContinuousMultilinearMap.curry0 𝕜 G (f x) = f := by
ext m
simp [Subsingleton.elim x m]
theorem ContinuousMultilinearMap.uncurry0_curry0 (f : G[×0]→L[𝕜] G') :
ContinuousMultilinearMap.curry0 𝕜 G f.uncurry0 = f := by simp
variable (𝕜 G)
theorem ContinuousMultilinearMap.curry0_uncurry0 (x : G') :
(ContinuousMultilinearMap.curry0 𝕜 G x).uncurry0 = x :=
rfl
@[simp]
theorem ContinuousMultilinearMap.curry0_norm (x : G') :
‖ContinuousMultilinearMap.curry0 𝕜 G x‖ = ‖x‖ :=
norm_constOfIsEmpty _ _ _
variable {𝕜 G}
@[simp]
theorem ContinuousMultilinearMap.fin0_apply_norm (f : G[×0]→L[𝕜] G') {x : Fin 0 → G} :
‖f x‖ = ‖f‖ := by
obtain rfl : x = 0 := Subsingleton.elim _ _
refine le_antisymm (by simpa using f.le_opNorm 0) ?_
have : ‖ContinuousMultilinearMap.curry0 𝕜 G f.uncurry0‖ ≤ ‖f.uncurry0‖ :=
ContinuousMultilinearMap.opNorm_le_bound _ (norm_nonneg _) fun m => by
simp [-ContinuousMultilinearMap.apply_zero_curry0]
simpa [-Matrix.zero_empty] using this
theorem ContinuousMultilinearMap.uncurry0_norm (f : G[×0]→L[𝕜] G') : ‖f.uncurry0‖ = ‖f‖ := by simp
variable (𝕜 G G')
/-- The continuous linear isomorphism between elements of a normed space, and continuous multilinear
maps in `0` variables with values in this normed space.
The direct and inverse maps are `uncurry0` and `curry0`. Use these unless you need the full
framework of linear isometric equivs. -/
def continuousMultilinearCurryFin0 : (G[×0]→L[𝕜] G') ≃ₗᵢ[𝕜] G' where
toFun f := ContinuousMultilinearMap.uncurry0 f
invFun f := ContinuousMultilinearMap.curry0 𝕜 G f
map_add' _ _ := rfl
map_smul' _ _ := rfl
left_inv := ContinuousMultilinearMap.uncurry0_curry0
right_inv := ContinuousMultilinearMap.curry0_uncurry0 𝕜 G
norm_map' := ContinuousMultilinearMap.uncurry0_norm
variable {𝕜 G G'}
@[simp]
theorem continuousMultilinearCurryFin0_apply (f : G[×0]→L[𝕜] G') :
continuousMultilinearCurryFin0 𝕜 G G' f = f 0 :=
rfl
@[simp]
theorem continuousMultilinearCurryFin0_symm_apply (x : G') (v : Fin 0 → G) :
(continuousMultilinearCurryFin0 𝕜 G G').symm x v = x :=
rfl
end
/-! #### With 1 variable -/
variable (𝕜 G G')
/-- Continuous multilinear maps from `G^1` to `G'` are isomorphic with continuous linear maps from
`G` to `G'`. -/
def continuousMultilinearCurryFin1 : (G[×1]→L[𝕜] G') ≃ₗᵢ[𝕜] G →L[𝕜] G' :=
(continuousMultilinearCurryRightEquiv 𝕜 (fun _ : Fin 1 => G) G').symm.trans
(continuousMultilinearCurryFin0 𝕜 G (G →L[𝕜] G'))
variable {𝕜 G G'}
@[simp]
theorem continuousMultilinearCurryFin1_apply (f : G[×1]→L[𝕜] G') (x : G) :
continuousMultilinearCurryFin1 𝕜 G G' f x = f (Fin.snoc 0 x) :=
rfl
@[simp]
theorem continuousMultilinearCurryFin1_symm_apply (f : G →L[𝕜] G') (v : Fin 1 → G) :
(continuousMultilinearCurryFin1 𝕜 G G').symm f v = f (v 0) :=
rfl
namespace ContinuousMultilinearMap
variable (𝕜 G G')
@[simp]
theorem norm_domDomCongr (σ : ι ≃ ι') (f : ContinuousMultilinearMap 𝕜 (fun _ : ι => G) G') :
‖domDomCongr σ f‖ = ‖f‖ := by
simp only [norm_def, LinearEquiv.coe_mk, ← σ.prod_comp,
(σ.arrowCongr (Equiv.refl G)).surjective.forall, domDomCongr_apply, Equiv.arrowCongr_apply,
Equiv.coe_refl, id_comp, comp_apply, Equiv.symm_apply_apply, id]
/-- An equivalence of the index set defines a linear isometric equivalence between the spaces
of multilinear maps. -/
def domDomCongrₗᵢ (σ : ι ≃ ι') :
ContinuousMultilinearMap 𝕜 (fun _ : ι => G) G' ≃ₗᵢ[𝕜]
ContinuousMultilinearMap 𝕜 (fun _ : ι' => G) G' :=
{ domDomCongrEquiv σ with
map_add' := fun _ _ => rfl
map_smul' := fun _ _ => rfl
norm_map' := norm_domDomCongr 𝕜 G G' σ }
variable {𝕜 G G'}
section
/-- A continuous multilinear map with variables indexed by `ι ⊕ ι'` defines a continuous
multilinear map with variables indexed by `ι` taking values in the space of continuous multilinear
maps with variables indexed by `ι'`. -/
def currySum (f : ContinuousMultilinearMap 𝕜 (fun _ : ι ⊕ ι' => G) G') :
ContinuousMultilinearMap 𝕜 (fun _ : ι => G) (ContinuousMultilinearMap 𝕜 (fun _ : ι' => G) G') :=
MultilinearMap.mkContinuousMultilinear (MultilinearMap.currySum f.toMultilinearMap) ‖f‖
fun m m' => by simpa [Fintype.prod_sum_type, mul_assoc] using f.le_opNorm (Sum.elim m m')
@[simp]
theorem currySum_apply (f : ContinuousMultilinearMap 𝕜 (fun _ : ι ⊕ ι' => G) G') (m : ι → G)
(m' : ι' → G) : f.currySum m m' = f (Sum.elim m m') :=
rfl
/-- A continuous multilinear map with variables indexed by `ι` taking values in the space of
continuous multilinear maps with variables indexed by `ι'` defines a continuous multilinear map with
variables indexed by `ι ⊕ ι'`. -/
def uncurrySum (f : ContinuousMultilinearMap 𝕜 (fun _ : ι => G)
(ContinuousMultilinearMap 𝕜 (fun _ : ι' => G) G')) :
ContinuousMultilinearMap 𝕜 (fun _ : ι ⊕ ι' => G) G' :=
MultilinearMap.mkContinuous
(toMultilinearMapLinear.compMultilinearMap f.toMultilinearMap).uncurrySum ‖f‖ fun m => by
simpa [Fintype.prod_sum_type, mul_assoc] using
(f (m ∘ Sum.inl)).le_of_opNorm_le (m ∘ Sum.inr) (f.le_opNorm _)
@[simp]
theorem uncurrySum_apply (f : ContinuousMultilinearMap 𝕜 (fun _ : ι => G)
(ContinuousMultilinearMap 𝕜 (fun _ : ι' => G) G'))
(m : ι ⊕ ι' → G) : f.uncurrySum m = f (m ∘ Sum.inl) (m ∘ Sum.inr) :=
rfl
variable (𝕜 ι ι' G G')
/-- Linear isometric equivalence between the space of continuous multilinear maps with variables
indexed by `ι ⊕ ι'` and the space of continuous multilinear maps with variables indexed by `ι`
taking values in the space of continuous multilinear maps with variables indexed by `ι'`.
The forward and inverse functions are `ContinuousMultilinearMap.currySum`
and `ContinuousMultilinearMap.uncurrySum`. Use this definition only if you need
some properties of `LinearIsometryEquiv`. -/
def currySumEquiv : ContinuousMultilinearMap 𝕜 (fun _ : ι ⊕ ι' => G) G' ≃ₗᵢ[𝕜]
ContinuousMultilinearMap 𝕜 (fun _ : ι => G) (ContinuousMultilinearMap 𝕜 (fun _ : ι' => G) G') :=
LinearIsometryEquiv.ofBounds
{ toFun := currySum
invFun := uncurrySum
map_add' := fun f g => by
ext
rfl
map_smul' := fun c f => by
ext
rfl
left_inv := fun f => by
ext m
exact congr_arg f (Sum.elim_comp_inl_inr m)
right_inv := fun f => by
ext m₁ m₂
rfl }
(fun f => MultilinearMap.mkContinuousMultilinear_norm_le _ (norm_nonneg f) _) fun f => by
simp only [LinearEquiv.coe_symm_mk]
exact MultilinearMap.mkContinuous_norm_le _ (norm_nonneg f) _
end
section
variable (𝕜 G G') {k l : ℕ} {s : Finset (Fin n)}
/-- If `s : Finset (Fin n)` is a finite set of cardinality `k` and its complement has cardinality
`l`, then the space of continuous multilinear maps `G [×n]→L[𝕜] G'` of `n` variables is isomorphic
to the space of continuous multilinear maps `G [×k]→L[𝕜] G [×l]→L[𝕜] G'` of `k` variables taking
values in the space of continuous multilinear maps of `l` variables. -/
def curryFinFinset {k l n : ℕ} {s : Finset (Fin n)} (hk : s.card = k) (hl : sᶜ.card = l) :
(G[×n]→L[𝕜] G') ≃ₗᵢ[𝕜] G[×k]→L[𝕜] G[×l]→L[𝕜] G' :=
(domDomCongrₗᵢ 𝕜 G G' (finSumEquivOfFinset hk hl).symm).trans
(currySumEquiv 𝕜 (Fin k) (Fin l) G G')
variable {𝕜 G G'}
@[simp]
theorem curryFinFinset_apply (hk : s.card = k) (hl : sᶜ.card = l) (f : G[×n]→L[𝕜] G')
(mk : Fin k → G) (ml : Fin l → G) : curryFinFinset 𝕜 G G' hk hl f mk ml =
f fun i => Sum.elim mk ml ((finSumEquivOfFinset hk hl).symm i) :=
rfl
@[simp]
theorem curryFinFinset_symm_apply (hk : s.card = k) (hl : sᶜ.card = l)
(f : G[×k]→L[𝕜] G[×l]→L[𝕜] G') (m : Fin n → G) : (curryFinFinset 𝕜 G G' hk hl).symm f m =
f (fun i => m <| finSumEquivOfFinset hk hl (Sum.inl i)) fun i =>
m <| finSumEquivOfFinset hk hl (Sum.inr i) :=
rfl
-- @[simp] -- Porting note (#10618): simp removed: simp can reduce LHS
theorem curryFinFinset_symm_apply_piecewise_const (hk : s.card = k) (hl : sᶜ.card = l)
(f : G[×k]→L[𝕜] G[×l]→L[𝕜] G') (x y : G) :
(curryFinFinset 𝕜 G G' hk hl).symm f (s.piecewise (fun _ => x) fun _ => y) =
f (fun _ => x) fun _ => y :=
MultilinearMap.curryFinFinset_symm_apply_piecewise_const hk hl _ x y
@[simp]
theorem curryFinFinset_symm_apply_const (hk : s.card = k) (hl : sᶜ.card = l)
(f : G[×k]→L[𝕜] G[×l]→L[𝕜] G') (x : G) :
((curryFinFinset 𝕜 G G' hk hl).symm f fun _ => x) = f (fun _ => x) fun _ => x :=
rfl
-- @[simp] -- Porting note (#10618): simp removed: simp can reduce LHS
theorem curryFinFinset_apply_const (hk : s.card = k) (hl : sᶜ.card = l) (f : G[×n]→L[𝕜] G')
(x y : G) : (curryFinFinset 𝕜 G G' hk hl f (fun _ => x) fun _ => y) =
f (s.piecewise (fun _ => x) fun _ => y) := by
refine (curryFinFinset_symm_apply_piecewise_const hk hl _ _ _).symm.trans ?_
rw [LinearIsometryEquiv.symm_apply_apply]
end
end ContinuousMultilinearMap
|
Analysis\NormedSpace\OperatorNorm\Asymptotics.lean | /-
Copyright (c) 2019 Jan-David Salchow. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jan-David Salchow, Sébastien Gouëzel, Jean Lo
-/
import Mathlib.Analysis.NormedSpace.OperatorNorm.Basic
import Mathlib.Analysis.Asymptotics.Asymptotics
/-!
# Asymptotic statements about the operator norm
This file contains lemmas about how operator norm on continuous linear maps interacts with `IsBigO`.
-/
open Asymptotics
variable {𝕜 𝕜₂ 𝕜₃ E F G : Type*}
variable [SeminormedAddCommGroup E] [SeminormedAddCommGroup F] [SeminormedAddCommGroup G]
variable [NontriviallyNormedField 𝕜] [NontriviallyNormedField 𝕜₂] [NontriviallyNormedField 𝕜₃]
[NormedSpace 𝕜 E] [NormedSpace 𝕜₂ F] [NormedSpace 𝕜₃ G] {σ₁₂ : 𝕜 →+* 𝕜₂} {σ₂₃ : 𝕜₂ →+* 𝕜₃}
namespace ContinuousLinearMap
variable [RingHomIsometric σ₁₂] (f : E →SL[σ₁₂] F) (l : Filter E)
theorem isBigOWith_id : IsBigOWith ‖f‖ l f fun x => x :=
isBigOWith_of_le' _ f.le_opNorm
theorem isBigO_id : f =O[l] fun x => x :=
(f.isBigOWith_id l).isBigO
theorem isBigOWith_comp [RingHomIsometric σ₂₃] {α : Type*} (g : F →SL[σ₂₃] G) (f : α → F)
(l : Filter α) : IsBigOWith ‖g‖ l (fun x' => g (f x')) f :=
(g.isBigOWith_id ⊤).comp_tendsto le_top
theorem isBigO_comp [RingHomIsometric σ₂₃] {α : Type*} (g : F →SL[σ₂₃] G) (f : α → F)
(l : Filter α) : (fun x' => g (f x')) =O[l] f :=
(g.isBigOWith_comp f l).isBigO
theorem isBigOWith_sub (x : E) :
IsBigOWith ‖f‖ l (fun x' => f (x' - x)) fun x' => x' - x :=
f.isBigOWith_comp _ l
theorem isBigO_sub (x : E) :
(fun x' => f (x' - x)) =O[l] fun x' => x' - x :=
f.isBigO_comp _ l
end ContinuousLinearMap
namespace ContinuousLinearEquiv
variable {σ₂₁ : 𝕜₂ →+* 𝕜} [RingHomInvPair σ₁₂ σ₂₁] [RingHomInvPair σ₂₁ σ₁₂] (e : E ≃SL[σ₁₂] F)
section
variable [RingHomIsometric σ₁₂]
theorem isBigO_comp {α : Type*} (f : α → E) (l : Filter α) : (fun x' => e (f x')) =O[l] f :=
(e : E →SL[σ₁₂] F).isBigO_comp f l
theorem isBigO_sub (l : Filter E) (x : E) : (fun x' => e (x' - x)) =O[l] fun x' => x' - x :=
(e : E →SL[σ₁₂] F).isBigO_sub l x
end
section
variable [RingHomIsometric σ₂₁]
theorem isBigO_comp_rev {α : Type*} (f : α → E) (l : Filter α) : f =O[l] fun x' => e (f x') :=
(e.symm.isBigO_comp _ l).congr_left fun _ => e.symm_apply_apply _
theorem isBigO_sub_rev (l : Filter E) (x : E) : (fun x' => x' - x) =O[l] fun x' => e (x' - x) :=
e.isBigO_comp_rev _ _
end
end ContinuousLinearEquiv
|
Analysis\NormedSpace\OperatorNorm\Basic.lean | /-
Copyright (c) 2019 Jan-David Salchow. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jan-David Salchow, Sébastien Gouëzel, Jean Lo
-/
import Mathlib.Algebra.Algebra.Tower
import Mathlib.Analysis.LocallyConvex.WithSeminorms
import Mathlib.Topology.Algebra.Module.StrongTopology
import Mathlib.Analysis.Normed.Operator.LinearIsometry
import Mathlib.Analysis.Normed.Operator.ContinuousLinearMap
import Mathlib.Tactic.SuppressCompilation
/-!
# Operator norm on the space of continuous linear maps
Define the operator (semi)-norm on the space of continuous (semi)linear maps between (semi)-normed
spaces, and prove its basic properties. In particular, show that this space is itself a semi-normed
space.
Since a lot of elementary properties don't require `‖x‖ = 0 → x = 0` we start setting up the
theory for `SeminormedAddCommGroup`. Later we will specialize to `NormedAddCommGroup` in the
file `NormedSpace.lean`.
Note that most of statements that apply to semilinear maps only hold when the ring homomorphism
is isometric, as expressed by the typeclass `[RingHomIsometric σ]`.
-/
suppress_compilation
open Bornology
open Filter hiding map_smul
open scoped NNReal Topology Uniformity
-- the `ₗ` subscript variables are for special cases about linear (as opposed to semilinear) maps
variable {𝕜 𝕜₂ 𝕜₃ E Eₗ F Fₗ G Gₗ 𝓕 : Type*}
section SemiNormed
open Metric ContinuousLinearMap
variable [SeminormedAddCommGroup E] [SeminormedAddCommGroup Eₗ] [SeminormedAddCommGroup F]
[SeminormedAddCommGroup Fₗ] [SeminormedAddCommGroup G] [SeminormedAddCommGroup Gₗ]
variable [NontriviallyNormedField 𝕜] [NontriviallyNormedField 𝕜₂] [NontriviallyNormedField 𝕜₃]
[NormedSpace 𝕜 E] [NormedSpace 𝕜 Eₗ] [NormedSpace 𝕜₂ F] [NormedSpace 𝕜 Fₗ] [NormedSpace 𝕜₃ G]
{σ₁₂ : 𝕜 →+* 𝕜₂} {σ₂₃ : 𝕜₂ →+* 𝕜₃} {σ₁₃ : 𝕜 →+* 𝕜₃} [RingHomCompTriple σ₁₂ σ₂₃ σ₁₃]
variable [FunLike 𝓕 E F]
/-- If `‖x‖ = 0` and `f` is continuous then `‖f x‖ = 0`. -/
theorem norm_image_of_norm_zero [SemilinearMapClass 𝓕 σ₁₂ E F] (f : 𝓕) (hf : Continuous f) {x : E}
(hx : ‖x‖ = 0) : ‖f x‖ = 0 := by
rw [← mem_closure_zero_iff_norm, ← specializes_iff_mem_closure, ← map_zero f] at *
exact hx.map hf
section
variable [RingHomIsometric σ₁₂] [RingHomIsometric σ₂₃]
theorem SemilinearMapClass.bound_of_shell_semi_normed [SemilinearMapClass 𝓕 σ₁₂ E F] (f : 𝓕)
{ε C : ℝ} (ε_pos : 0 < ε) {c : 𝕜} (hc : 1 < ‖c‖)
(hf : ∀ x, ε / ‖c‖ ≤ ‖x‖ → ‖x‖ < ε → ‖f x‖ ≤ C * ‖x‖) {x : E} (hx : ‖x‖ ≠ 0) :
‖f x‖ ≤ C * ‖x‖ :=
(normSeminorm 𝕜 E).bound_of_shell ((normSeminorm 𝕜₂ F).comp ⟨⟨f, map_add f⟩, map_smulₛₗ f⟩)
ε_pos hc hf hx
/-- A continuous linear map between seminormed spaces is bounded when the field is nontrivially
normed. The continuity ensures boundedness on a ball of some radius `ε`. The nontriviality of the
norm is then used to rescale any element into an element of norm in `[ε/C, ε]`, whose image has a
controlled norm. The norm control for the original element follows by rescaling. -/
theorem SemilinearMapClass.bound_of_continuous [SemilinearMapClass 𝓕 σ₁₂ E F] (f : 𝓕)
(hf : Continuous f) : ∃ C, 0 < C ∧ ∀ x : E, ‖f x‖ ≤ C * ‖x‖ :=
let φ : E →ₛₗ[σ₁₂] F := ⟨⟨f, map_add f⟩, map_smulₛₗ f⟩
((normSeminorm 𝕜₂ F).comp φ).bound_of_continuous_normedSpace (continuous_norm.comp hf)
end
namespace ContinuousLinearMap
theorem bound [RingHomIsometric σ₁₂] (f : E →SL[σ₁₂] F) : ∃ C, 0 < C ∧ ∀ x : E, ‖f x‖ ≤ C * ‖x‖ :=
SemilinearMapClass.bound_of_continuous f f.2
section
open Filter
variable (𝕜 E)
/-- Given a unit-length element `x` of a normed space `E` over a field `𝕜`, the natural linear
isometry map from `𝕜` to `E` by taking multiples of `x`. -/
def _root_.LinearIsometry.toSpanSingleton {v : E} (hv : ‖v‖ = 1) : 𝕜 →ₗᵢ[𝕜] E :=
{ LinearMap.toSpanSingleton 𝕜 E v with norm_map' := fun x => by simp [norm_smul, hv] }
variable {𝕜 E}
@[simp]
theorem _root_.LinearIsometry.toSpanSingleton_apply {v : E} (hv : ‖v‖ = 1) (a : 𝕜) :
LinearIsometry.toSpanSingleton 𝕜 E hv a = a • v :=
rfl
@[simp]
theorem _root_.LinearIsometry.coe_toSpanSingleton {v : E} (hv : ‖v‖ = 1) :
(LinearIsometry.toSpanSingleton 𝕜 E hv).toLinearMap = LinearMap.toSpanSingleton 𝕜 E v :=
rfl
end
section OpNorm
open Set Real
/-- The operator norm of a continuous linear map is the inf of all its bounds. -/
def opNorm (f : E →SL[σ₁₂] F) :=
sInf { c | 0 ≤ c ∧ ∀ x, ‖f x‖ ≤ c * ‖x‖ }
instance hasOpNorm : Norm (E →SL[σ₁₂] F) :=
⟨opNorm⟩
theorem norm_def (f : E →SL[σ₁₂] F) : ‖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 [RingHomIsometric σ₁₂] {f : E →SL[σ₁₂] F} :
∃ 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 : E →SL[σ₁₂] F} : BddBelow { c | 0 ≤ c ∧ ∀ x, ‖f x‖ ≤ c * ‖x‖ } :=
⟨0, fun _ ⟨hn, _⟩ => hn⟩
theorem isLeast_opNorm [RingHomIsometric σ₁₂] (f : E →SL[σ₁₂] F) :
IsLeast {c | 0 ≤ c ∧ ∀ x, ‖f x‖ ≤ c * ‖x‖} ‖f‖ := by
refine IsClosed.isLeast_csInf ?_ bounds_nonempty bounds_bddBelow
simp only [setOf_and, setOf_forall]
refine isClosed_Ici.inter <| isClosed_iInter fun _ ↦ isClosed_le ?_ ?_ <;> continuity
@[deprecated (since := "2024-02-02")] alias isLeast_op_norm := isLeast_opNorm
/-- If one controls the norm of every `A x`, then one controls the norm of `A`. -/
theorem opNorm_le_bound (f : E →SL[σ₁₂] F) {M : ℝ} (hMp : 0 ≤ M) (hM : ∀ x, ‖f x‖ ≤ M * ‖x‖) :
‖f‖ ≤ M :=
csInf_le bounds_bddBelow ⟨hMp, hM⟩
@[deprecated (since := "2024-02-02")] alias op_norm_le_bound := opNorm_le_bound
/-- If one controls the norm of every `A x`, `‖x‖ ≠ 0`, then one controls the norm of `A`. -/
theorem opNorm_le_bound' (f : E →SL[σ₁₂] F) {M : ℝ} (hMp : 0 ≤ M)
(hM : ∀ x, ‖x‖ ≠ 0 → ‖f x‖ ≤ M * ‖x‖) : ‖f‖ ≤ M :=
opNorm_le_bound f hMp fun x =>
(ne_or_eq ‖x‖ 0).elim (hM x) fun h => by
simp only [h, mul_zero, norm_image_of_norm_zero f f.2 h, le_refl]
@[deprecated (since := "2024-02-02")] alias op_norm_le_bound' := opNorm_le_bound'
theorem opNorm_le_of_lipschitz {f : E →SL[σ₁₂] F} {K : ℝ≥0} (hf : LipschitzWith K f) : ‖f‖ ≤ K :=
f.opNorm_le_bound K.2 fun x => by
simpa only [dist_zero_right, f.map_zero] using hf.dist_le_mul x 0
@[deprecated (since := "2024-02-02")] alias op_norm_le_of_lipschitz := opNorm_le_of_lipschitz
theorem opNorm_eq_of_bounds {φ : E →SL[σ₁₂] F} {M : ℝ} (M_nonneg : 0 ≤ M)
(h_above : ∀ x, ‖φ x‖ ≤ M * ‖x‖) (h_below : ∀ N ≥ 0, (∀ x, ‖φ x‖ ≤ N * ‖x‖) → M ≤ N) :
‖φ‖ = M :=
le_antisymm (φ.opNorm_le_bound M_nonneg h_above)
((le_csInf_iff ContinuousLinearMap.bounds_bddBelow ⟨M, M_nonneg, h_above⟩).mpr
fun N ⟨N_nonneg, hN⟩ => h_below N N_nonneg hN)
@[deprecated (since := "2024-02-02")] alias op_norm_eq_of_bounds := opNorm_eq_of_bounds
theorem opNorm_neg (f : E →SL[σ₁₂] F) : ‖-f‖ = ‖f‖ := by simp only [norm_def, neg_apply, norm_neg]
@[deprecated (since := "2024-02-02")] alias op_norm_neg := opNorm_neg
theorem opNorm_nonneg (f : E →SL[σ₁₂] F) : 0 ≤ ‖f‖ :=
Real.sInf_nonneg _ fun _ ↦ And.left
@[deprecated (since := "2024-02-02")] alias op_norm_nonneg := opNorm_nonneg
/-- The norm of the `0` operator is `0`. -/
theorem opNorm_zero : ‖(0 : E →SL[σ₁₂] F)‖ = 0 :=
le_antisymm (opNorm_le_bound _ le_rfl fun _ ↦ by simp) (opNorm_nonneg _)
@[deprecated (since := "2024-02-02")] alias op_norm_zero := opNorm_zero
/-- The norm of the identity is at most `1`. It is in fact `1`, except when the space is trivial
where it is `0`. It means that one can not do better than an inequality in general. -/
theorem norm_id_le : ‖id 𝕜 E‖ ≤ 1 :=
opNorm_le_bound _ zero_le_one fun x => by simp
section
variable [RingHomIsometric σ₁₂] [RingHomIsometric σ₂₃] (f g : E →SL[σ₁₂] F) (h : F →SL[σ₂₃] G)
(x : E)
/-- The fundamental property of the operator norm: `‖f x‖ ≤ ‖f‖ * ‖x‖`. -/
theorem le_opNorm : ‖f x‖ ≤ ‖f‖ * ‖x‖ := (isLeast_opNorm f).1.2 x
@[deprecated (since := "2024-02-02")] alias le_op_norm := le_opNorm
theorem dist_le_opNorm (x y : E) : dist (f x) (f y) ≤ ‖f‖ * dist x y := by
simp_rw [dist_eq_norm, ← map_sub, f.le_opNorm]
@[deprecated (since := "2024-02-02")] alias dist_le_op_norm := dist_le_opNorm
theorem le_of_opNorm_le_of_le {x} {a b : ℝ} (hf : ‖f‖ ≤ a) (hx : ‖x‖ ≤ b) :
‖f x‖ ≤ a * b :=
(f.le_opNorm x).trans <| by gcongr; exact (opNorm_nonneg f).trans hf
@[deprecated (since := "2024-02-02")] alias le_of_op_norm_le_of_le := le_of_opNorm_le_of_le
theorem le_opNorm_of_le {c : ℝ} {x} (h : ‖x‖ ≤ c) : ‖f x‖ ≤ ‖f‖ * c :=
f.le_of_opNorm_le_of_le le_rfl h
@[deprecated (since := "2024-02-02")] alias le_op_norm_of_le := le_opNorm_of_le
theorem le_of_opNorm_le {c : ℝ} (h : ‖f‖ ≤ c) (x : E) : ‖f x‖ ≤ c * ‖x‖ :=
f.le_of_opNorm_le_of_le h le_rfl
@[deprecated (since := "2024-02-02")] alias le_of_op_norm_le := le_of_opNorm_le
theorem opNorm_le_iff {f : E →SL[σ₁₂] F} {M : ℝ} (hMp : 0 ≤ M) :
‖f‖ ≤ M ↔ ∀ x, ‖f x‖ ≤ M * ‖x‖ :=
⟨f.le_of_opNorm_le, opNorm_le_bound f hMp⟩
@[deprecated (since := "2024-02-02")] alias op_norm_le_iff := opNorm_le_iff
theorem ratio_le_opNorm : ‖f x‖ / ‖x‖ ≤ ‖f‖ :=
div_le_of_nonneg_of_le_mul (norm_nonneg _) f.opNorm_nonneg (le_opNorm _ _)
@[deprecated (since := "2024-02-02")] alias ratio_le_op_norm := ratio_le_opNorm
/-- The image of the unit ball under a continuous linear map is bounded. -/
theorem unit_le_opNorm : ‖x‖ ≤ 1 → ‖f x‖ ≤ ‖f‖ :=
mul_one ‖f‖ ▸ f.le_opNorm_of_le
@[deprecated (since := "2024-02-02")] alias unit_le_op_norm := unit_le_opNorm
theorem opNorm_le_of_shell {f : E →SL[σ₁₂] F} {ε C : ℝ} (ε_pos : 0 < ε) (hC : 0 ≤ C) {c : 𝕜}
(hc : 1 < ‖c‖) (hf : ∀ x, ε / ‖c‖ ≤ ‖x‖ → ‖x‖ < ε → ‖f x‖ ≤ C * ‖x‖) : ‖f‖ ≤ C :=
f.opNorm_le_bound' hC fun _ hx => SemilinearMapClass.bound_of_shell_semi_normed f ε_pos hc hf hx
@[deprecated (since := "2024-02-02")] alias op_norm_le_of_shell := opNorm_le_of_shell
theorem opNorm_le_of_ball {f : E →SL[σ₁₂] F} {ε : ℝ} {C : ℝ} (ε_pos : 0 < ε) (hC : 0 ≤ C)
(hf : ∀ x ∈ ball (0 : E) ε, ‖f x‖ ≤ C * ‖x‖) : ‖f‖ ≤ C := by
rcases NormedField.exists_one_lt_norm 𝕜 with ⟨c, hc⟩
refine opNorm_le_of_shell ε_pos hC hc fun x _ hx => hf x ?_
rwa [ball_zero_eq]
@[deprecated (since := "2024-02-02")] alias op_norm_le_of_ball := opNorm_le_of_ball
theorem opNorm_le_of_nhds_zero {f : E →SL[σ₁₂] F} {C : ℝ} (hC : 0 ≤ C)
(hf : ∀ᶠ x in 𝓝 (0 : E), ‖f x‖ ≤ C * ‖x‖) : ‖f‖ ≤ C :=
let ⟨_, ε0, hε⟩ := Metric.eventually_nhds_iff_ball.1 hf
opNorm_le_of_ball ε0 hC hε
@[deprecated (since := "2024-02-02")] alias op_norm_le_of_nhds_zero := opNorm_le_of_nhds_zero
theorem opNorm_le_of_shell' {f : E →SL[σ₁₂] F} {ε C : ℝ} (ε_pos : 0 < ε) (hC : 0 ≤ C) {c : 𝕜}
(hc : ‖c‖ < 1) (hf : ∀ x, ε * ‖c‖ ≤ ‖x‖ → ‖x‖ < ε → ‖f x‖ ≤ C * ‖x‖) : ‖f‖ ≤ C := by
by_cases h0 : c = 0
· refine opNorm_le_of_ball ε_pos hC fun x hx => hf x ?_ ?_
· simp [h0]
· rwa [ball_zero_eq] at hx
· rw [← inv_inv c, norm_inv, inv_lt_one_iff_of_pos (norm_pos_iff.2 <| inv_ne_zero h0)] at hc
refine opNorm_le_of_shell ε_pos hC hc ?_
rwa [norm_inv, div_eq_mul_inv, inv_inv]
@[deprecated (since := "2024-02-02")] alias op_norm_le_of_shell' := opNorm_le_of_shell'
/-- For a continuous real linear map `f`, if one controls the norm of every `f x`, `‖x‖ = 1`, then
one controls the norm of `f`. -/
theorem opNorm_le_of_unit_norm [NormedSpace ℝ E] [NormedSpace ℝ F] {f : E →L[ℝ] F} {C : ℝ}
(hC : 0 ≤ C) (hf : ∀ x, ‖x‖ = 1 → ‖f x‖ ≤ C) : ‖f‖ ≤ C := by
refine opNorm_le_bound' f hC fun x hx => ?_
have H₁ : ‖‖x‖⁻¹ • x‖ = 1 := by rw [norm_smul, norm_inv, norm_norm, inv_mul_cancel hx]
have H₂ := hf _ H₁
rwa [map_smul, norm_smul, norm_inv, norm_norm, ← div_eq_inv_mul, _root_.div_le_iff] at H₂
exact (norm_nonneg x).lt_of_ne' hx
@[deprecated (since := "2024-02-02")] alias op_norm_le_of_unit_norm := opNorm_le_of_unit_norm
/-- The operator norm satisfies the triangle inequality. -/
theorem opNorm_add_le : ‖f + g‖ ≤ ‖f‖ + ‖g‖ :=
(f + g).opNorm_le_bound (add_nonneg f.opNorm_nonneg g.opNorm_nonneg) fun x =>
(norm_add_le_of_le (f.le_opNorm x) (g.le_opNorm x)).trans_eq (add_mul _ _ _).symm
@[deprecated (since := "2024-02-02")] alias op_norm_add_le := opNorm_add_le
/-- 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 : E, ‖x‖ ≠ 0) : ‖id 𝕜 E‖ = 1 :=
le_antisymm norm_id_le <| by
let ⟨x, hx⟩ := h
have := (id 𝕜 E).ratio_le_opNorm x
rwa [id_apply, div_self hx] at this
theorem opNorm_smul_le {𝕜' : Type*} [NormedField 𝕜'] [NormedSpace 𝕜' F] [SMulCommClass 𝕜₂ 𝕜' F]
(c : 𝕜') (f : E →SL[σ₁₂] F) : ‖c • f‖ ≤ ‖c‖ * ‖f‖ :=
(c • f).opNorm_le_bound (mul_nonneg (norm_nonneg _) (opNorm_nonneg _)) fun _ => by
rw [smul_apply, norm_smul, mul_assoc]
exact mul_le_mul_of_nonneg_left (le_opNorm _ _) (norm_nonneg _)
@[deprecated (since := "2024-02-02")] alias op_norm_smul_le := opNorm_smul_le
/-- Operator seminorm on the space of continuous (semi)linear maps, as `Seminorm`.
We use this seminorm to define a `SeminormedGroup` structure on `E →SL[σ] F`,
but we have to override the projection `UniformSpace`
so that it is definitionally equal to the one coming from the topologies on `E` and `F`. -/
protected def seminorm : Seminorm 𝕜₂ (E →SL[σ₁₂] F) :=
.ofSMulLE norm opNorm_zero opNorm_add_le opNorm_smul_le
private lemma uniformity_eq_seminorm :
𝓤 (E →SL[σ₁₂] F) = ⨅ r > 0, 𝓟 {f | ‖f.1 - f.2‖ < r} := by
refine ContinuousLinearMap.seminorm (σ₁₂ := σ₁₂) (E := E) (F := F) |>.uniformity_eq_of_hasBasis
(ContinuousLinearMap.hasBasis_nhds_zero_of_basis Metric.nhds_basis_closedBall)
?_ fun (s, r) ⟨hs, hr⟩ ↦ ?_
· rcases NormedField.exists_lt_norm 𝕜 1 with ⟨c, hc⟩
refine ⟨‖c‖, ContinuousLinearMap.hasBasis_nhds_zero.mem_iff.2
⟨(closedBall 0 1, closedBall 0 1), ?_⟩⟩
suffices ∀ f : E →SL[σ₁₂] F, (∀ x, ‖x‖ ≤ 1 → ‖f x‖ ≤ 1) → ‖f‖ ≤ ‖c‖ by
simpa [NormedSpace.isVonNBounded_closedBall, closedBall_mem_nhds, subset_def] using this
intro f hf
refine opNorm_le_of_shell (f := f) one_pos (norm_nonneg c) hc fun x hcx hx ↦ ?_
exact (hf x hx.le).trans ((div_le_iff' <| one_pos.trans hc).1 hcx)
· rcases (NormedSpace.isVonNBounded_iff' _).1 hs with ⟨ε, hε⟩
rcases exists_pos_mul_lt hr ε with ⟨δ, hδ₀, hδ⟩
refine ⟨δ, hδ₀, fun f hf x hx ↦ ?_⟩
simp only [Seminorm.mem_ball_zero, mem_closedBall_zero_iff] at hf ⊢
rw [mul_comm] at hδ
exact le_trans (le_of_opNorm_le_of_le _ hf.le (hε _ hx)) hδ.le
instance toPseudoMetricSpace : PseudoMetricSpace (E →SL[σ₁₂] F) := .replaceUniformity
ContinuousLinearMap.seminorm.toSeminormedAddCommGroup.toPseudoMetricSpace uniformity_eq_seminorm
/-- Continuous linear maps themselves form a seminormed space with respect to
the operator norm. -/
instance toSeminormedAddCommGroup : SeminormedAddCommGroup (E →SL[σ₁₂] F) where
dist_eq _ _ := rfl
instance toNormedSpace {𝕜' : Type*} [NormedField 𝕜'] [NormedSpace 𝕜' F] [SMulCommClass 𝕜₂ 𝕜' F] :
NormedSpace 𝕜' (E →SL[σ₁₂] F) :=
⟨opNorm_smul_le⟩
/-- The operator norm is submultiplicative. -/
theorem opNorm_comp_le (f : E →SL[σ₁₂] F) : ‖h.comp f‖ ≤ ‖h‖ * ‖f‖ :=
csInf_le bounds_bddBelow
⟨mul_nonneg (opNorm_nonneg _) (opNorm_nonneg _), fun x => by
rw [mul_assoc]
exact h.le_opNorm_of_le (f.le_opNorm x)⟩
@[deprecated (since := "2024-02-02")] alias op_norm_comp_le := opNorm_comp_le
/-- Continuous linear maps form a seminormed ring with respect to the operator norm. -/
instance toSemiNormedRing : SeminormedRing (E →L[𝕜] E) :=
{ ContinuousLinearMap.toSeminormedAddCommGroup, ContinuousLinearMap.ring with
norm_mul := fun f g => opNorm_comp_le f g }
/-- For a normed space `E`, continuous linear endomorphisms form a normed algebra with
respect to the operator norm. -/
instance toNormedAlgebra : NormedAlgebra 𝕜 (E →L[𝕜] E) :=
{ algebra with
norm_smul_le := by
intro c f
apply opNorm_smul_le c f}
end
variable [RingHomIsometric σ₁₂] (f : E →SL[σ₁₂] F)
@[simp, nontriviality]
theorem opNorm_subsingleton [Subsingleton E] : ‖f‖ = 0 := by
refine le_antisymm ?_ (norm_nonneg _)
apply opNorm_le_bound _ rfl.ge
intro x
simp [Subsingleton.elim x 0]
@[deprecated (since := "2024-02-02")] alias op_norm_subsingleton := opNorm_subsingleton
end OpNorm
section RestrictScalars
variable {𝕜' : Type*} [NontriviallyNormedField 𝕜'] [NormedAlgebra 𝕜' 𝕜]
variable [NormedSpace 𝕜' E] [IsScalarTower 𝕜' 𝕜 E]
variable [NormedSpace 𝕜' Fₗ] [IsScalarTower 𝕜' 𝕜 Fₗ]
@[simp]
theorem norm_restrictScalars (f : E →L[𝕜] Fₗ) : ‖f.restrictScalars 𝕜'‖ = ‖f‖ :=
le_antisymm (opNorm_le_bound _ (norm_nonneg _) fun x => f.le_opNorm x)
(opNorm_le_bound _ (norm_nonneg _) fun x => f.le_opNorm x)
variable (𝕜 E Fₗ 𝕜') (𝕜'' : Type*) [Ring 𝕜'']
variable [Module 𝕜'' Fₗ] [ContinuousConstSMul 𝕜'' Fₗ]
[SMulCommClass 𝕜 𝕜'' Fₗ] [SMulCommClass 𝕜' 𝕜'' Fₗ]
/-- `ContinuousLinearMap.restrictScalars` as a `LinearIsometry`. -/
def restrictScalarsIsometry : (E →L[𝕜] Fₗ) →ₗᵢ[𝕜''] E →L[𝕜'] Fₗ :=
⟨restrictScalarsₗ 𝕜 E Fₗ 𝕜' 𝕜'', norm_restrictScalars⟩
variable {𝕜''}
@[simp]
theorem coe_restrictScalarsIsometry :
⇑(restrictScalarsIsometry 𝕜 E Fₗ 𝕜' 𝕜'') = restrictScalars 𝕜' :=
rfl
@[simp]
theorem restrictScalarsIsometry_toLinearMap :
(restrictScalarsIsometry 𝕜 E Fₗ 𝕜' 𝕜'').toLinearMap = restrictScalarsₗ 𝕜 E Fₗ 𝕜' 𝕜'' :=
rfl
variable (𝕜'')
/-- `ContinuousLinearMap.restrictScalars` as a `ContinuousLinearMap`. -/
def restrictScalarsL : (E →L[𝕜] Fₗ) →L[𝕜''] E →L[𝕜'] Fₗ :=
(restrictScalarsIsometry 𝕜 E Fₗ 𝕜' 𝕜'').toContinuousLinearMap
variable {𝕜 E Fₗ 𝕜' 𝕜''}
@[simp]
theorem coe_restrictScalarsL : (restrictScalarsL 𝕜 E Fₗ 𝕜' 𝕜'' : (E →L[𝕜] Fₗ) →ₗ[𝕜''] E →L[𝕜'] Fₗ) =
restrictScalarsₗ 𝕜 E Fₗ 𝕜' 𝕜'' :=
rfl
@[simp]
theorem coe_restrict_scalarsL' : ⇑(restrictScalarsL 𝕜 E Fₗ 𝕜' 𝕜'') = restrictScalars 𝕜' :=
rfl
end RestrictScalars
lemma norm_pi_le_of_le {ι : Type*} [Fintype ι]
{M : ι → Type*} [∀ i, SeminormedAddCommGroup (M i)] [∀ i, NormedSpace 𝕜 (M i)] {C : ℝ}
{L : (i : ι) → (E →L[𝕜] M i)} (hL : ∀ i, ‖L i‖ ≤ C) (hC : 0 ≤ C) :
‖pi L‖ ≤ C := by
refine opNorm_le_bound _ hC (fun x ↦ ?_)
refine (pi_norm_le_iff_of_nonneg (by positivity)).mpr (fun i ↦ ?_)
exact (L i).le_of_opNorm_le (hL i) _
end ContinuousLinearMap
namespace LinearMap
/-- If a continuous linear map is constructed from a linear map via the constructor `mkContinuous`,
then its norm is bounded by the bound given to the constructor if it is nonnegative. -/
theorem mkContinuous_norm_le (f : E →ₛₗ[σ₁₂] F) {C : ℝ} (hC : 0 ≤ C) (h : ∀ x, ‖f x‖ ≤ C * ‖x‖) :
‖f.mkContinuous C h‖ ≤ C :=
ContinuousLinearMap.opNorm_le_bound _ hC h
/-- If a continuous linear map is constructed from a linear map via the constructor `mkContinuous`,
then its norm is bounded by the bound or zero if bound is negative. -/
theorem mkContinuous_norm_le' (f : E →ₛₗ[σ₁₂] F) {C : ℝ} (h : ∀ x, ‖f x‖ ≤ C * ‖x‖) :
‖f.mkContinuous C h‖ ≤ max C 0 :=
ContinuousLinearMap.opNorm_le_bound _ (le_max_right _ _) fun x =>
(h x).trans <| mul_le_mul_of_nonneg_right (le_max_left _ _) (norm_nonneg x)
end LinearMap
namespace LinearIsometry
theorem norm_toContinuousLinearMap_le (f : E →ₛₗᵢ[σ₁₂] F) : ‖f.toContinuousLinearMap‖ ≤ 1 :=
f.toContinuousLinearMap.opNorm_le_bound zero_le_one fun x => by simp
end LinearIsometry
namespace Submodule
theorem norm_subtypeL_le (K : Submodule 𝕜 E) : ‖K.subtypeL‖ ≤ 1 :=
K.subtypeₗᵢ.norm_toContinuousLinearMap_le
end Submodule
end SemiNormed
|
Analysis\NormedSpace\OperatorNorm\Bilinear.lean | /-
Copyright (c) 2019 Jan-David Salchow. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jan-David Salchow, Sébastien Gouëzel, Jean Lo
-/
import Mathlib.Analysis.NormedSpace.OperatorNorm.Basic
import Mathlib.Analysis.Normed.Operator.LinearIsometry
import Mathlib.Analysis.Normed.Operator.ContinuousLinearMap
/-!
# Operator norm: bilinear maps
This file contains lemmas concerning operator norm as applied to bilinear maps `E × F → G`,
interpreted as linear maps `E → F → G` as usual (and similarly for semilinear variants).
-/
suppress_compilation
open Bornology
open Filter hiding map_smul
open scoped NNReal Topology Uniformity
-- the `ₗ` subscript variables are for special cases about linear (as opposed to semilinear) maps
variable {𝕜 𝕜₂ 𝕜₃ E Eₗ F Fₗ G Gₗ 𝓕 : Type*}
section SemiNormed
open Metric ContinuousLinearMap
variable [SeminormedAddCommGroup E] [SeminormedAddCommGroup Eₗ] [SeminormedAddCommGroup F]
[SeminormedAddCommGroup Fₗ] [SeminormedAddCommGroup G] [SeminormedAddCommGroup Gₗ]
variable [NontriviallyNormedField 𝕜] [NontriviallyNormedField 𝕜₂] [NontriviallyNormedField 𝕜₃]
[NormedSpace 𝕜 E] [NormedSpace 𝕜 Eₗ] [NormedSpace 𝕜₂ F] [NormedSpace 𝕜 Fₗ] [NormedSpace 𝕜₃ G]
[NormedSpace 𝕜 Gₗ] {σ₁₂ : 𝕜 →+* 𝕜₂} {σ₂₃ : 𝕜₂ →+* 𝕜₃} {σ₁₃ : 𝕜 →+* 𝕜₃}
[RingHomCompTriple σ₁₂ σ₂₃ σ₁₃]
variable [FunLike 𝓕 E F]
namespace ContinuousLinearMap
section OpNorm
open Set Real
theorem opNorm_ext [RingHomIsometric σ₁₃] (f : E →SL[σ₁₂] F) (g : E →SL[σ₁₃] G)
(h : ∀ x, ‖f x‖ = ‖g x‖) : ‖f‖ = ‖g‖ :=
opNorm_eq_of_bounds (norm_nonneg _)
(fun x => by
rw [h x]
exact le_opNorm _ _)
fun c hc h₂ =>
opNorm_le_bound _ hc fun z => by
rw [← h z]
exact h₂ z
@[deprecated (since := "2024-02-02")] alias op_norm_ext := opNorm_ext
variable [RingHomIsometric σ₂₃]
theorem opNorm_le_bound₂ (f : E →SL[σ₁₃] F →SL[σ₂₃] G) {C : ℝ} (h0 : 0 ≤ C)
(hC : ∀ x y, ‖f x y‖ ≤ C * ‖x‖ * ‖y‖) : ‖f‖ ≤ C :=
f.opNorm_le_bound h0 fun x => (f x).opNorm_le_bound (mul_nonneg h0 (norm_nonneg _)) <| hC x
@[deprecated (since := "2024-02-02")] alias op_norm_le_bound₂ := opNorm_le_bound₂
theorem le_opNorm₂ [RingHomIsometric σ₁₃] (f : E →SL[σ₁₃] F →SL[σ₂₃] G) (x : E) (y : F) :
‖f x y‖ ≤ ‖f‖ * ‖x‖ * ‖y‖ :=
(f x).le_of_opNorm_le (f.le_opNorm x) y
@[deprecated (since := "2024-02-02")] alias le_op_norm₂ := le_opNorm₂
theorem le_of_opNorm₂_le_of_le [RingHomIsometric σ₁₃] (f : E →SL[σ₁₃] F →SL[σ₂₃] G) {x : E} {y : F}
{a b c : ℝ} (hf : ‖f‖ ≤ a) (hx : ‖x‖ ≤ b) (hy : ‖y‖ ≤ c) :
‖f x y‖ ≤ a * b * c :=
(f x).le_of_opNorm_le_of_le (f.le_of_opNorm_le_of_le hf hx) hy
@[deprecated (since := "2024-02-02")] alias le_of_op_norm₂_le_of_le := le_of_opNorm₂_le_of_le
end OpNorm
end ContinuousLinearMap
namespace LinearMap
lemma norm_mkContinuous₂_aux (f : E →ₛₗ[σ₁₃] F →ₛₗ[σ₂₃] G) (C : ℝ)
(h : ∀ x y, ‖f x y‖ ≤ C * ‖x‖ * ‖y‖) (x : E) :
‖(f x).mkContinuous (C * ‖x‖) (h x)‖ ≤ max C 0 * ‖x‖ :=
(mkContinuous_norm_le' (f x) (h x)).trans_eq <| by
rw [max_mul_of_nonneg _ _ (norm_nonneg x), zero_mul]
variable [RingHomIsometric σ₂₃]
/-- Create a bilinear map (represented as a map `E →L[𝕜] F →L[𝕜] G`) from the corresponding linear
map and existence of a bound on the norm of the image. The linear map can be constructed using
`LinearMap.mk₂`.
If you have an explicit bound, use `LinearMap.mkContinuous₂` instead, as a norm estimate will
follow automatically in `LinearMap.mkContinuous₂_norm_le`. -/
def mkContinuousOfExistsBound₂ (f : E →ₛₗ[σ₁₃] F →ₛₗ[σ₂₃] G)
(h : ∃ C, ∀ x y, ‖f x y‖ ≤ C * ‖x‖ * ‖y‖) : E →SL[σ₁₃] F →SL[σ₂₃] G :=
LinearMap.mkContinuousOfExistsBound
{ toFun := fun x => (f x).mkContinuousOfExistsBound <| let ⟨C, hC⟩ := h; ⟨C * ‖x‖, hC x⟩
map_add' := fun x y => by
ext z
simp
map_smul' := fun c x => by
ext z
simp } <|
let ⟨C, hC⟩ := h; ⟨max C 0, norm_mkContinuous₂_aux f C hC⟩
/-- Create a bilinear map (represented as a map `E →L[𝕜] F →L[𝕜] G`) from the corresponding linear
map and a bound on the norm of the image. The linear map can be constructed using
`LinearMap.mk₂`. Lemmas `LinearMap.mkContinuous₂_norm_le'` and `LinearMap.mkContinuous₂_norm_le`
provide estimates on the norm of an operator constructed using this function. -/
def mkContinuous₂ (f : E →ₛₗ[σ₁₃] F →ₛₗ[σ₂₃] G) (C : ℝ) (hC : ∀ x y, ‖f x y‖ ≤ C * ‖x‖ * ‖y‖) :
E →SL[σ₁₃] F →SL[σ₂₃] G :=
mkContinuousOfExistsBound₂ f ⟨C, hC⟩
@[simp]
theorem mkContinuous₂_apply (f : E →ₛₗ[σ₁₃] F →ₛₗ[σ₂₃] G) {C : ℝ}
(hC : ∀ x y, ‖f x y‖ ≤ C * ‖x‖ * ‖y‖) (x : E) (y : F) : f.mkContinuous₂ C hC x y = f x y :=
rfl
theorem mkContinuous₂_norm_le' (f : E →ₛₗ[σ₁₃] F →ₛₗ[σ₂₃] G) {C : ℝ}
(hC : ∀ x y, ‖f x y‖ ≤ C * ‖x‖ * ‖y‖) : ‖f.mkContinuous₂ C hC‖ ≤ max C 0 :=
mkContinuous_norm_le _ (le_max_iff.2 <| Or.inr le_rfl) (norm_mkContinuous₂_aux f C hC)
theorem mkContinuous₂_norm_le (f : E →ₛₗ[σ₁₃] F →ₛₗ[σ₂₃] G) {C : ℝ} (h0 : 0 ≤ C)
(hC : ∀ x y, ‖f x y‖ ≤ C * ‖x‖ * ‖y‖) : ‖f.mkContinuous₂ C hC‖ ≤ C :=
(f.mkContinuous₂_norm_le' hC).trans_eq <| max_eq_left h0
end LinearMap
namespace ContinuousLinearMap
variable [RingHomIsometric σ₂₃] [RingHomIsometric σ₁₃]
/-- Flip the order of arguments of a continuous bilinear map.
For a version bundled as `LinearIsometryEquiv`, see
`ContinuousLinearMap.flipL`. -/
def flip (f : E →SL[σ₁₃] F →SL[σ₂₃] G) : F →SL[σ₂₃] E →SL[σ₁₃] G :=
LinearMap.mkContinuous₂
-- Porting note: the `simp only`s below used to be `rw`.
-- Now that doesn't work as we need to do some beta reduction along the way.
(LinearMap.mk₂'ₛₗ σ₂₃ σ₁₃ (fun y x => f x y) (fun x y z => (f z).map_add x y)
(fun c y x => (f x).map_smulₛₗ c y) (fun z x y => by simp only [f.map_add, add_apply])
(fun c y x => by simp only [f.map_smulₛₗ, smul_apply]))
‖f‖ fun y x => (f.le_opNorm₂ x y).trans_eq <| by simp only [mul_right_comm]
private theorem le_norm_flip (f : E →SL[σ₁₃] F →SL[σ₂₃] G) : ‖f‖ ≤ ‖flip f‖ :=
#adaptation_note
/--
After https://github.com/leanprover/lean4/pull/4119 we either need
to specify the `f.flip` argument, or use `set_option maxSynthPendingDepth 2 in`.
-/
f.opNorm_le_bound₂ (norm_nonneg f.flip) fun x y => by
rw [mul_right_comm]
exact (flip f).le_opNorm₂ y x
@[simp]
theorem flip_apply (f : E →SL[σ₁₃] F →SL[σ₂₃] G) (x : E) (y : F) : f.flip y x = f x y :=
rfl
@[simp]
theorem flip_flip (f : E →SL[σ₁₃] F →SL[σ₂₃] G) : f.flip.flip = f := by
ext
rfl
@[simp]
theorem opNorm_flip (f : E →SL[σ₁₃] F →SL[σ₂₃] G) : ‖f.flip‖ = ‖f‖ :=
le_antisymm (by simpa only [flip_flip] using le_norm_flip f.flip) (le_norm_flip f)
@[deprecated (since := "2024-02-02")] alias op_norm_flip := opNorm_flip
@[simp]
theorem flip_add (f g : E →SL[σ₁₃] F →SL[σ₂₃] G) : (f + g).flip = f.flip + g.flip :=
rfl
@[simp]
theorem flip_smul (c : 𝕜₃) (f : E →SL[σ₁₃] F →SL[σ₂₃] G) : (c • f).flip = c • f.flip :=
rfl
variable (E F G σ₁₃ σ₂₃)
/-- Flip the order of arguments of a continuous bilinear map.
This is a version bundled as a `LinearIsometryEquiv`.
For an unbundled version see `ContinuousLinearMap.flip`. -/
def flipₗᵢ' : (E →SL[σ₁₃] F →SL[σ₂₃] G) ≃ₗᵢ[𝕜₃] F →SL[σ₂₃] E →SL[σ₁₃] G where
toFun := flip
invFun := flip
map_add' := flip_add
map_smul' := flip_smul
left_inv := flip_flip
right_inv := flip_flip
norm_map' := opNorm_flip
variable {E F G σ₁₃ σ₂₃}
@[simp]
theorem flipₗᵢ'_symm : (flipₗᵢ' E F G σ₂₃ σ₁₃).symm = flipₗᵢ' F E G σ₁₃ σ₂₃ :=
rfl
@[simp]
theorem coe_flipₗᵢ' : ⇑(flipₗᵢ' E F G σ₂₃ σ₁₃) = flip :=
rfl
variable (𝕜 E Fₗ Gₗ)
/-- Flip the order of arguments of a continuous bilinear map.
This is a version bundled as a `LinearIsometryEquiv`.
For an unbundled version see `ContinuousLinearMap.flip`. -/
def flipₗᵢ : (E →L[𝕜] Fₗ →L[𝕜] Gₗ) ≃ₗᵢ[𝕜] Fₗ →L[𝕜] E →L[𝕜] Gₗ where
toFun := flip
invFun := flip
map_add' := flip_add
map_smul' := flip_smul
left_inv := flip_flip
right_inv := flip_flip
norm_map' := opNorm_flip
variable {𝕜 E Fₗ Gₗ}
@[simp]
theorem flipₗᵢ_symm : (flipₗᵢ 𝕜 E Fₗ Gₗ).symm = flipₗᵢ 𝕜 Fₗ E Gₗ :=
rfl
@[simp]
theorem coe_flipₗᵢ : ⇑(flipₗᵢ 𝕜 E Fₗ Gₗ) = flip :=
rfl
variable (F σ₁₂)
variable [RingHomIsometric σ₁₂]
/-- The continuous semilinear map obtained by applying a continuous semilinear map at a given
vector.
This is the continuous version of `LinearMap.applyₗ`. -/
def apply' : E →SL[σ₁₂] (E →SL[σ₁₂] F) →L[𝕜₂] F :=
flip (id 𝕜₂ (E →SL[σ₁₂] F))
variable {F σ₁₂}
@[simp]
theorem apply_apply' (v : E) (f : E →SL[σ₁₂] F) : apply' F σ₁₂ v f = f v :=
rfl
variable (𝕜 Fₗ)
/-- The continuous semilinear map obtained by applying a continuous semilinear map at a given
vector.
This is the continuous version of `LinearMap.applyₗ`. -/
def apply : E →L[𝕜] (E →L[𝕜] Fₗ) →L[𝕜] Fₗ :=
flip (id 𝕜 (E →L[𝕜] Fₗ))
variable {𝕜 Fₗ}
@[simp]
theorem apply_apply (v : E) (f : E →L[𝕜] Fₗ) : apply 𝕜 Fₗ v f = f v :=
rfl
variable (σ₁₂ σ₂₃ E F G)
/-- Composition of continuous semilinear maps as a continuous semibilinear map. -/
def compSL : (F →SL[σ₂₃] G) →L[𝕜₃] (E →SL[σ₁₂] F) →SL[σ₂₃] E →SL[σ₁₃] G :=
LinearMap.mkContinuous₂
(LinearMap.mk₂'ₛₗ (RingHom.id 𝕜₃) σ₂₃ comp add_comp smul_comp comp_add fun c f g => by
ext
simp only [ContinuousLinearMap.map_smulₛₗ, coe_smul', coe_comp', Function.comp_apply,
Pi.smul_apply])
1 fun f g => by simpa only [one_mul] using opNorm_comp_le f g
#adaptation_note
/--
Before https://github.com/leanprover/lean4/pull/4119 we had to create a local instance:
```
letI : Norm ((F →SL[σ₂₃] G) →L[𝕜₃] (E →SL[σ₁₂] F) →SL[σ₂₃] E →SL[σ₁₃] G) :=
hasOpNorm (𝕜₂ := 𝕜₃) (E := F →SL[σ₂₃] G) (F := (E →SL[σ₁₂] F) →SL[σ₂₃] E →SL[σ₁₃] G)
```
-/
set_option maxSynthPendingDepth 2 in
theorem norm_compSL_le : ‖compSL E F G σ₁₂ σ₂₃‖ ≤ 1 :=
LinearMap.mkContinuous₂_norm_le _ zero_le_one _
variable {σ₁₂ σ₂₃ E F G}
@[simp]
theorem compSL_apply (f : F →SL[σ₂₃] G) (g : E →SL[σ₁₂] F) : compSL E F G σ₁₂ σ₂₃ f g = f.comp g :=
rfl
theorem _root_.Continuous.const_clm_comp {X} [TopologicalSpace X] {f : X → E →SL[σ₁₂] F}
(hf : Continuous f) (g : F →SL[σ₂₃] G) :
Continuous (fun x => g.comp (f x) : X → E →SL[σ₁₃] G) :=
(compSL E F G σ₁₂ σ₂₃ g).continuous.comp hf
-- Giving the implicit argument speeds up elaboration significantly
theorem _root_.Continuous.clm_comp_const {X} [TopologicalSpace X] {g : X → F →SL[σ₂₃] G}
(hg : Continuous g) (f : E →SL[σ₁₂] F) :
Continuous (fun x => (g x).comp f : X → E →SL[σ₁₃] G) :=
(@ContinuousLinearMap.flip _ _ _ _ _ (E →SL[σ₁₃] G) _ _ _ _ _ _ _ _ _ _ _ _ _
(compSL E F G σ₁₂ σ₂₃) f).continuous.comp hg
variable (𝕜 σ₁₂ σ₂₃ E Fₗ Gₗ)
/-- Composition of continuous linear maps as a continuous bilinear map. -/
def compL : (Fₗ →L[𝕜] Gₗ) →L[𝕜] (E →L[𝕜] Fₗ) →L[𝕜] E →L[𝕜] Gₗ :=
compSL E Fₗ Gₗ (RingHom.id 𝕜) (RingHom.id 𝕜)
#adaptation_note
/--
Before https://github.com/leanprover/lean4/pull/4119 we had to create a local instance:
```
letI : Norm ((Fₗ →L[𝕜] Gₗ) →L[𝕜] (E →L[𝕜] Fₗ) →L[𝕜] E →L[𝕜] Gₗ) :=
hasOpNorm (𝕜₂ := 𝕜) (E := Fₗ →L[𝕜] Gₗ) (F := (E →L[𝕜] Fₗ) →L[𝕜] E →L[𝕜] Gₗ)
```
-/
set_option maxSynthPendingDepth 2 in
theorem norm_compL_le : ‖compL 𝕜 E Fₗ Gₗ‖ ≤ 1 :=
norm_compSL_le _ _ _ _ _
@[simp]
theorem compL_apply (f : Fₗ →L[𝕜] Gₗ) (g : E →L[𝕜] Fₗ) : compL 𝕜 E Fₗ Gₗ f g = f.comp g :=
rfl
variable (Eₗ) {𝕜 E Fₗ Gₗ}
/-- Apply `L(x,-)` pointwise to bilinear maps, as a continuous bilinear map -/
@[simps! apply]
def precompR (L : E →L[𝕜] Fₗ →L[𝕜] Gₗ) : E →L[𝕜] (Eₗ →L[𝕜] Fₗ) →L[𝕜] Eₗ →L[𝕜] Gₗ :=
(compL 𝕜 Eₗ Fₗ Gₗ).comp L
/-- Apply `L(-,y)` pointwise to bilinear maps, as a continuous bilinear map -/
def precompL (L : E →L[𝕜] Fₗ →L[𝕜] Gₗ) : (Eₗ →L[𝕜] E) →L[𝕜] Fₗ →L[𝕜] Eₗ →L[𝕜] Gₗ :=
(precompR Eₗ (flip L)).flip
@[simp] lemma precompL_apply (L : E →L[𝕜] Fₗ →L[𝕜] Gₗ) (u : Eₗ →L[𝕜] E) (f : Fₗ) (g : Eₗ) :
precompL Eₗ L u f g = L (u g) f := rfl
#adaptation_note
/--
Before https://github.com/leanprover/lean4/pull/4119
we had to create a local instance in the signature:
```
letI : SeminormedAddCommGroup ((Eₗ →L[𝕜] Fₗ) →L[𝕜] Eₗ →L[𝕜] Gₗ) := inferInstance
letI : NormedSpace 𝕜 ((Eₗ →L[𝕜] Fₗ) →L[𝕜] Eₗ →L[𝕜] Gₗ) := inferInstance
```
-/
set_option maxSynthPendingDepth 2 in
theorem norm_precompR_le (L : E →L[𝕜] Fₗ →L[𝕜] Gₗ) : ‖precompR Eₗ L‖ ≤ ‖L‖ :=
calc
‖precompR Eₗ L‖ ≤ ‖compL 𝕜 Eₗ Fₗ Gₗ‖ * ‖L‖ := opNorm_comp_le _ _
_ ≤ 1 * ‖L‖ := mul_le_mul_of_nonneg_right (norm_compL_le _ _ _ _) (norm_nonneg L)
_ = ‖L‖ := by rw [one_mul]
#adaptation_note
/--
Before https://github.com/leanprover/lean4/pull/4119
we had to create a local instance in the signature:
```
letI : Norm ((Eₗ →L[𝕜] E) →L[𝕜] Fₗ →L[𝕜] Eₗ →L[𝕜] Gₗ) :=
hasOpNorm (𝕜₂ := 𝕜) (E := Eₗ →L[𝕜] E) (F := Fₗ →L[𝕜] Eₗ →L[𝕜] Gₗ)
```
-/
set_option maxSynthPendingDepth 2 in
theorem norm_precompL_le (L : E →L[𝕜] Fₗ →L[𝕜] Gₗ) : ‖precompL Eₗ L‖ ≤ ‖L‖ := by
rw [precompL, opNorm_flip, ← opNorm_flip L]
exact norm_precompR_le _ L.flip
end ContinuousLinearMap
variable {σ₂₁ : 𝕜₂ →+* 𝕜} [RingHomInvPair σ₁₂ σ₂₁] [RingHomInvPair σ₂₁ σ₁₂]
namespace ContinuousLinearMap
variable {E' F' : Type*} [SeminormedAddCommGroup E'] [SeminormedAddCommGroup F']
variable {𝕜₁' : Type*} {𝕜₂' : Type*} [NontriviallyNormedField 𝕜₁'] [NontriviallyNormedField 𝕜₂']
[NormedSpace 𝕜₁' E'] [NormedSpace 𝕜₂' F'] {σ₁' : 𝕜₁' →+* 𝕜} {σ₁₃' : 𝕜₁' →+* 𝕜₃} {σ₂' : 𝕜₂' →+* 𝕜₂}
{σ₂₃' : 𝕜₂' →+* 𝕜₃} [RingHomCompTriple σ₁' σ₁₃ σ₁₃'] [RingHomCompTriple σ₂' σ₂₃ σ₂₃']
[RingHomIsometric σ₂₃] [RingHomIsometric σ₁₃'] [RingHomIsometric σ₂₃']
/-- Compose a bilinear map `E →SL[σ₁₃] F →SL[σ₂₃] G` with two linear maps
`E' →SL[σ₁'] E` and `F' →SL[σ₂'] F`. -/
def bilinearComp (f : E →SL[σ₁₃] F →SL[σ₂₃] G) (gE : E' →SL[σ₁'] E) (gF : F' →SL[σ₂'] F) :
E' →SL[σ₁₃'] F' →SL[σ₂₃'] G :=
((f.comp gE).flip.comp gF).flip
@[simp]
theorem bilinearComp_apply (f : E →SL[σ₁₃] F →SL[σ₂₃] G) (gE : E' →SL[σ₁'] E) (gF : F' →SL[σ₂'] F)
(x : E') (y : F') : f.bilinearComp gE gF x y = f (gE x) (gF y) :=
rfl
variable [RingHomIsometric σ₁₃] [RingHomIsometric σ₁'] [RingHomIsometric σ₂']
/-- Derivative of a continuous bilinear map `f : E →L[𝕜] F →L[𝕜] G` interpreted as a map `E × F → G`
at point `p : E × F` evaluated at `q : E × F`, as a continuous bilinear map. -/
def deriv₂ (f : E →L[𝕜] Fₗ →L[𝕜] Gₗ) : E × Fₗ →L[𝕜] E × Fₗ →L[𝕜] Gₗ :=
f.bilinearComp (fst _ _ _) (snd _ _ _) + f.flip.bilinearComp (snd _ _ _) (fst _ _ _)
@[simp]
theorem coe_deriv₂ (f : E →L[𝕜] Fₗ →L[𝕜] Gₗ) (p : E × Fₗ) :
⇑(f.deriv₂ p) = fun q : E × Fₗ => f p.1 q.2 + f q.1 p.2 :=
rfl
theorem map_add_add (f : E →L[𝕜] Fₗ →L[𝕜] Gₗ) (x x' : E) (y y' : Fₗ) :
f (x + x') (y + y') = f x y + f.deriv₂ (x, y) (x', y') + f x' y' := by
simp only [map_add, add_apply, coe_deriv₂, add_assoc]
abel
end ContinuousLinearMap
end SemiNormed
|
Analysis\NormedSpace\OperatorNorm\Completeness.lean | /-
Copyright (c) 2019 Jan-David Salchow. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jan-David Salchow, Sébastien Gouëzel, Jean Lo
-/
import Mathlib.Analysis.NormedSpace.OperatorNorm.Bilinear
import Mathlib.Analysis.NormedSpace.OperatorNorm.NNNorm
/-!
# Operators on complete normed spaces
This file contains statements about norms of operators on complete normed spaces, such as a
version of the Banach-Alaoglu theorem (`ContinuousLinearMap.isCompact_image_coe_closedBall`).
-/
suppress_compilation
open Bornology Metric Set Real
open Filter hiding map_smul
open scoped NNReal Topology Uniformity
-- the `ₗ` subscript variables are for special cases about linear (as opposed to semilinear) maps
variable {𝕜 𝕜₂ 𝕜₃ E Eₗ F Fₗ G Gₗ 𝓕 : Type*}
variable [NormedAddCommGroup E] [NormedAddCommGroup F] [NormedAddCommGroup G]
[NormedAddCommGroup Fₗ]
variable [NontriviallyNormedField 𝕜] [NontriviallyNormedField 𝕜₂] [NontriviallyNormedField 𝕜₃]
[NormedSpace 𝕜 E] [NormedSpace 𝕜₂ F] [NormedSpace 𝕜₃ G] [NormedSpace 𝕜 Fₗ] (c : 𝕜)
{σ₁₂ : 𝕜 →+* 𝕜₂} {σ₂₃ : 𝕜₂ →+* 𝕜₃} (f g : E →SL[σ₁₂] F) (x y z : E)
namespace ContinuousLinearMap
section Completeness
variable {E' : Type*} [SeminormedAddCommGroup E'] [NormedSpace 𝕜 E'] [RingHomIsometric σ₁₂]
/-- Construct a bundled continuous (semi)linear map from a map `f : E → F` and a proof of the fact
that it belongs to the closure of the image of a bounded set `s : Set (E →SL[σ₁₂] F)` under coercion
to function. Coercion to function of the result is definitionally equal to `f`. -/
@[simps! (config := .asFn) apply]
def ofMemClosureImageCoeBounded (f : E' → F) {s : Set (E' →SL[σ₁₂] F)} (hs : IsBounded s)
(hf : f ∈ closure (((↑) : (E' →SL[σ₁₂] F) → E' → F) '' s)) : E' →SL[σ₁₂] F := by
-- `f` is a linear map due to `linearMapOfMemClosureRangeCoe`
refine (linearMapOfMemClosureRangeCoe f ?_).mkContinuousOfExistsBound ?_
· refine closure_mono (image_subset_iff.2 fun g _ => ?_) hf
exact ⟨g, rfl⟩
· -- We need to show that `f` has bounded norm. Choose `C` such that `‖g‖ ≤ C` for all `g ∈ s`.
rcases isBounded_iff_forall_norm_le.1 hs with ⟨C, hC⟩
-- Then `‖g x‖ ≤ C * ‖x‖` for all `g ∈ s`, `x : E`, hence `‖f x‖ ≤ C * ‖x‖` for all `x`.
have : ∀ x, IsClosed { g : E' → F | ‖g x‖ ≤ C * ‖x‖ } := fun x =>
isClosed_Iic.preimage (@continuous_apply E' (fun _ => F) _ x).norm
refine ⟨C, fun x => (this x).closure_subset_iff.2 (image_subset_iff.2 fun g hg => ?_) hf⟩
exact g.le_of_opNorm_le (hC _ hg) _
/-- Let `f : E → F` be a map, let `g : α → E →SL[σ₁₂] F` be a family of continuous (semi)linear maps
that takes values in a bounded set and converges to `f` pointwise along a nontrivial filter. Then
`f` is a continuous (semi)linear map. -/
@[simps! (config := .asFn) apply]
def ofTendstoOfBoundedRange {α : Type*} {l : Filter α} [l.NeBot] (f : E' → F)
(g : α → E' →SL[σ₁₂] F) (hf : Tendsto (fun a x => g a x) l (𝓝 f))
(hg : IsBounded (Set.range g)) : E' →SL[σ₁₂] F :=
ofMemClosureImageCoeBounded f hg <| mem_closure_of_tendsto hf <|
eventually_of_forall fun _ => mem_image_of_mem _ <| Set.mem_range_self _
/-- If a Cauchy sequence of continuous linear map converges to a continuous linear map pointwise,
then it converges to the same map in norm. This lemma is used to prove that the space of continuous
linear maps is complete provided that the codomain is a complete space. -/
theorem tendsto_of_tendsto_pointwise_of_cauchySeq {f : ℕ → E' →SL[σ₁₂] F} {g : E' →SL[σ₁₂] F}
(hg : Tendsto (fun n x => f n x) atTop (𝓝 g)) (hf : CauchySeq f) : Tendsto f atTop (𝓝 g) := by
/- Since `f` is a Cauchy sequence, there exists `b → 0` such that `‖f n - f m‖ ≤ b N` for any
`m, n ≥ N`. -/
rcases cauchySeq_iff_le_tendsto_0.1 hf with ⟨b, hb₀, hfb, hb_lim⟩
-- Since `b → 0`, it suffices to show that `‖f n x - g x‖ ≤ b n * ‖x‖` for all `n` and `x`.
suffices ∀ n x, ‖f n x - g x‖ ≤ b n * ‖x‖ from
tendsto_iff_norm_sub_tendsto_zero.2
(squeeze_zero (fun n => norm_nonneg _) (fun n => opNorm_le_bound _ (hb₀ n) (this n)) hb_lim)
intro n x
-- Note that `f m x → g x`, hence `‖f n x - f m x‖ → ‖f n x - g x‖` as `m → ∞`
have : Tendsto (fun m => ‖f n x - f m x‖) atTop (𝓝 ‖f n x - g x‖) :=
(tendsto_const_nhds.sub <| tendsto_pi_nhds.1 hg _).norm
-- Thus it suffices to verify `‖f n x - f m x‖ ≤ b n * ‖x‖` for `m ≥ n`.
refine le_of_tendsto this (eventually_atTop.2 ⟨n, fun m hm => ?_⟩)
-- This inequality follows from `‖f n - f m‖ ≤ b n`.
exact (f n - f m).le_of_opNorm_le (hfb _ _ _ le_rfl hm) _
/-- If the target space is complete, the space of continuous linear maps with its norm is also
complete. This works also if the source space is seminormed. -/
instance [CompleteSpace F] : CompleteSpace (E' →SL[σ₁₂] F) := by
-- We show that every Cauchy sequence converges.
refine Metric.complete_of_cauchySeq_tendsto fun f hf => ?_
-- The evaluation at any point `v : E` is Cauchy.
have cau : ∀ v, CauchySeq fun n => f n v := fun v => hf.map (lipschitz_apply v).uniformContinuous
-- We assemble the limits points of those Cauchy sequences
-- (which exist as `F` is complete)
-- into a function which we call `G`.
choose G hG using fun v => cauchySeq_tendsto_of_complete (cau v)
-- Next, we show that this `G` is a continuous linear map.
-- This is done in `ContinuousLinearMap.ofTendstoOfBoundedRange`.
set Glin : E' →SL[σ₁₂] F :=
ofTendstoOfBoundedRange _ _ (tendsto_pi_nhds.mpr hG) hf.isBounded_range
-- Finally, `f n` converges to `Glin` in norm because of
-- `ContinuousLinearMap.tendsto_of_tendsto_pointwise_of_cauchySeq`
exact ⟨Glin, tendsto_of_tendsto_pointwise_of_cauchySeq (tendsto_pi_nhds.2 hG) hf⟩
/-- Let `s` be a bounded set in the space of continuous (semi)linear maps `E →SL[σ] F` taking values
in a proper space. Then `s` interpreted as a set in the space of maps `E → F` with topology of
pointwise convergence is precompact: its closure is a compact set. -/
theorem isCompact_closure_image_coe_of_bounded [ProperSpace F] {s : Set (E' →SL[σ₁₂] F)}
(hb : IsBounded s) : IsCompact (closure (((↑) : (E' →SL[σ₁₂] F) → E' → F) '' s)) :=
have : ∀ x, IsCompact (closure (apply' F σ₁₂ x '' s)) := fun x =>
((apply' F σ₁₂ x).lipschitz.isBounded_image hb).isCompact_closure
(isCompact_pi_infinite this).closure_of_subset
(image_subset_iff.2 fun _ hg _ => subset_closure <| mem_image_of_mem _ hg)
/-- Let `s` be a bounded set in the space of continuous (semi)linear maps `E →SL[σ] F` taking values
in a proper space. If `s` interpreted as a set in the space of maps `E → F` with topology of
pointwise convergence is closed, then it is compact.
TODO: reformulate this in terms of a type synonym with the right topology. -/
theorem isCompact_image_coe_of_bounded_of_closed_image [ProperSpace F] {s : Set (E' →SL[σ₁₂] F)}
(hb : IsBounded s) (hc : IsClosed (((↑) : (E' →SL[σ₁₂] F) → E' → F) '' s)) :
IsCompact (((↑) : (E' →SL[σ₁₂] F) → E' → F) '' s) :=
hc.closure_eq ▸ isCompact_closure_image_coe_of_bounded hb
/-- If a set `s` of semilinear functions is bounded and is closed in the weak-* topology, then its
image under coercion to functions `E → F` is a closed set. We don't have a name for `E →SL[σ] F`
with weak-* topology in `mathlib`, so we use an equivalent condition (see `isClosed_induced_iff'`).
TODO: reformulate this in terms of a type synonym with the right topology. -/
theorem isClosed_image_coe_of_bounded_of_weak_closed {s : Set (E' →SL[σ₁₂] F)} (hb : IsBounded s)
(hc : ∀ f : E' →SL[σ₁₂] F,
(⇑f : E' → F) ∈ closure (((↑) : (E' →SL[σ₁₂] F) → E' → F) '' s) → f ∈ s) :
IsClosed (((↑) : (E' →SL[σ₁₂] F) → E' → F) '' s) :=
isClosed_of_closure_subset fun f hf =>
⟨ofMemClosureImageCoeBounded f hb hf, hc (ofMemClosureImageCoeBounded f hb hf) hf, rfl⟩
/-- If a set `s` of semilinear functions is bounded and is closed in the weak-* topology, then its
image under coercion to functions `E → F` is a compact set. We don't have a name for `E →SL[σ] F`
with weak-* topology in `mathlib`, so we use an equivalent condition (see `isClosed_induced_iff'`).
-/
theorem isCompact_image_coe_of_bounded_of_weak_closed [ProperSpace F] {s : Set (E' →SL[σ₁₂] F)}
(hb : IsBounded s) (hc : ∀ f : E' →SL[σ₁₂] F,
(⇑f : E' → F) ∈ closure (((↑) : (E' →SL[σ₁₂] F) → E' → F) '' s) → f ∈ s) :
IsCompact (((↑) : (E' →SL[σ₁₂] F) → E' → F) '' s) :=
isCompact_image_coe_of_bounded_of_closed_image hb <|
isClosed_image_coe_of_bounded_of_weak_closed hb hc
/-- A closed ball is closed in the weak-* topology. We don't have a name for `E →SL[σ] F` with
weak-* topology in `mathlib`, so we use an equivalent condition (see `isClosed_induced_iff'`). -/
theorem is_weak_closed_closedBall (f₀ : E' →SL[σ₁₂] F) (r : ℝ) ⦃f : E' →SL[σ₁₂] F⦄
(hf : ⇑f ∈ closure (((↑) : (E' →SL[σ₁₂] F) → E' → F) '' closedBall f₀ r)) :
f ∈ closedBall f₀ r := by
have hr : 0 ≤ r := nonempty_closedBall.1 (closure_nonempty_iff.1 ⟨_, hf⟩).of_image
refine mem_closedBall_iff_norm.2 (opNorm_le_bound _ hr fun x => ?_)
have : IsClosed { g : E' → F | ‖g x - f₀ x‖ ≤ r * ‖x‖ } :=
isClosed_Iic.preimage ((@continuous_apply E' (fun _ => F) _ x).sub continuous_const).norm
refine this.closure_subset_iff.2 (image_subset_iff.2 fun g hg => ?_) hf
exact (g - f₀).le_of_opNorm_le (mem_closedBall_iff_norm.1 hg) _
/-- The set of functions `f : E → F` that represent continuous linear maps `f : E →SL[σ₁₂] F`
at distance `≤ r` from `f₀ : E →SL[σ₁₂] F` is closed in the topology of pointwise convergence.
This is one of the key steps in the proof of the **Banach-Alaoglu** theorem. -/
theorem isClosed_image_coe_closedBall (f₀ : E →SL[σ₁₂] F) (r : ℝ) :
IsClosed (((↑) : (E →SL[σ₁₂] F) → E → F) '' closedBall f₀ r) :=
isClosed_image_coe_of_bounded_of_weak_closed isBounded_closedBall (is_weak_closed_closedBall f₀ r)
/-- **Banach-Alaoglu** theorem. The set of functions `f : E → F` that represent continuous linear
maps `f : E →SL[σ₁₂] F` at distance `≤ r` from `f₀ : E →SL[σ₁₂] F` is compact in the topology of
pointwise convergence. Other versions of this theorem can be found in
`Analysis.Normed.Module.WeakDual`. -/
theorem isCompact_image_coe_closedBall [ProperSpace F] (f₀ : E →SL[σ₁₂] F) (r : ℝ) :
IsCompact (((↑) : (E →SL[σ₁₂] F) → E → F) '' closedBall f₀ r) :=
isCompact_image_coe_of_bounded_of_weak_closed isBounded_closedBall <|
is_weak_closed_closedBall f₀ r
end Completeness
section UniformlyExtend
variable [CompleteSpace F] (e : E →L[𝕜] Fₗ) (h_dense : DenseRange e)
section
variable (h_e : UniformInducing e)
/-- Extension of a continuous linear map `f : E →SL[σ₁₂] F`, with `E` a normed space and `F` a
complete normed space, along a uniform and dense embedding `e : E →L[𝕜] Fₗ`. -/
def extend : Fₗ →SL[σ₁₂] F :=
-- extension of `f` is continuous
have cont := (uniformContinuous_uniformly_extend h_e h_dense f.uniformContinuous).continuous
-- extension of `f` agrees with `f` on the domain of the embedding `e`
have eq := uniformly_extend_of_ind h_e h_dense f.uniformContinuous
{ toFun := (h_e.denseInducing h_dense).extend f
map_add' := by
refine h_dense.induction_on₂ ?_ ?_
· exact isClosed_eq (cont.comp continuous_add)
((cont.comp continuous_fst).add (cont.comp continuous_snd))
· intro x y
simp only [eq, ← e.map_add]
exact f.map_add _ _
map_smul' := fun k => by
refine fun b => h_dense.induction_on b ?_ ?_
· exact isClosed_eq (cont.comp (continuous_const_smul _))
((continuous_const_smul _).comp cont)
· intro x
rw [← map_smul]
simp only [eq]
exact ContinuousLinearMap.map_smulₛₗ _ _ _
cont }
-- Porting note: previously `(h_e.denseInducing h_dense)` was inferred.
@[simp]
theorem extend_eq (x : E) : extend f e h_dense h_e (e x) = f x :=
DenseInducing.extend_eq (h_e.denseInducing h_dense) f.cont _
theorem extend_unique (g : Fₗ →SL[σ₁₂] F) (H : g.comp e = f) : extend f e h_dense h_e = g :=
ContinuousLinearMap.coeFn_injective <|
uniformly_extend_unique h_e h_dense (ContinuousLinearMap.ext_iff.1 H) g.continuous
@[simp]
theorem extend_zero : extend (0 : E →SL[σ₁₂] F) e h_dense h_e = 0 :=
extend_unique _ _ _ _ _ (zero_comp _)
end
section
variable {N : ℝ≥0} (h_e : ∀ x, ‖x‖ ≤ N * ‖e x‖) [RingHomIsometric σ₁₂]
/-- If a dense embedding `e : E →L[𝕜] G` expands the norm by a constant factor `N⁻¹`, then the
norm of the extension of `f` along `e` is bounded by `N * ‖f‖`. -/
theorem opNorm_extend_le :
‖f.extend e h_dense (uniformEmbedding_of_bound _ h_e).toUniformInducing‖ ≤ N * ‖f‖ := by
-- Add `opNorm_le_of_dense`?
refine opNorm_le_bound _ ?_ (isClosed_property h_dense (isClosed_le ?_ ?_) fun x ↦ ?_)
· cases le_total 0 N with
| inl hN => exact mul_nonneg hN (norm_nonneg _)
| inr hN =>
have : Unique E := ⟨⟨0⟩, fun x ↦ norm_le_zero_iff.mp <|
(h_e x).trans (mul_nonpos_of_nonpos_of_nonneg hN (norm_nonneg _))⟩
obtain rfl : f = 0 := Subsingleton.elim ..
simp
· exact (cont _).norm
· exact continuous_const.mul continuous_norm
· rw [extend_eq]
calc
‖f x‖ ≤ ‖f‖ * ‖x‖ := le_opNorm _ _
_ ≤ ‖f‖ * (N * ‖e x‖) := mul_le_mul_of_nonneg_left (h_e x) (norm_nonneg _)
_ ≤ N * ‖f‖ * ‖e x‖ := by rw [mul_comm ↑N ‖f‖, mul_assoc]
@[deprecated (since := "2024-02-02")] alias op_norm_extend_le := opNorm_extend_le
end
end UniformlyExtend
end ContinuousLinearMap
|
Analysis\NormedSpace\OperatorNorm\Mul.lean | /-
Copyright (c) 2019 Jan-David Salchow. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jan-David Salchow, Sébastien Gouëzel, Jean Lo
-/
import Mathlib.Analysis.NormedSpace.OperatorNorm.NormedSpace
/-!
# Results about operator norms in normed algebras
This file (split off from `OperatorNorm.lean`) contains results about the operator norm
of multiplication and scalar-multiplication operations in normed algebras and normed modules.
-/
suppress_compilation
open Metric
open scoped NNReal Topology Uniformity
variable {𝕜 E : Type*} [NontriviallyNormedField 𝕜]
section SemiNormed
variable [SeminormedAddCommGroup E] [NormedSpace 𝕜 E]
namespace ContinuousLinearMap
section MultiplicationLinear
section NonUnital
variable (𝕜) (𝕜' : Type*) [NonUnitalSeminormedRing 𝕜']
variable [NormedSpace 𝕜 𝕜'] [IsScalarTower 𝕜 𝕜' 𝕜'] [SMulCommClass 𝕜 𝕜' 𝕜']
/-- Multiplication in a non-unital normed algebra as a continuous bilinear map. -/
def mul : 𝕜' →L[𝕜] 𝕜' →L[𝕜] 𝕜' :=
(LinearMap.mul 𝕜 𝕜').mkContinuous₂ 1 fun x y => by simpa using norm_mul_le x y
@[simp]
theorem mul_apply' (x y : 𝕜') : mul 𝕜 𝕜' x y = x * y :=
rfl
@[simp]
theorem opNorm_mul_apply_le (x : 𝕜') : ‖mul 𝕜 𝕜' x‖ ≤ ‖x‖ :=
opNorm_le_bound _ (norm_nonneg x) (norm_mul_le x)
@[deprecated (since := "2024-02-02")] alias op_norm_mul_apply_le := opNorm_mul_apply_le
theorem opNorm_mul_le : ‖mul 𝕜 𝕜'‖ ≤ 1 :=
LinearMap.mkContinuous₂_norm_le _ zero_le_one _
@[deprecated (since := "2024-02-02")] alias op_norm_mul_le := opNorm_mul_le
/-- Multiplication on the left in a non-unital normed algebra `𝕜'` as a non-unital algebra
homomorphism into the algebra of *continuous* linear maps. This is the left regular representation
of `A` acting on itself.
This has more algebraic structure than `ContinuousLinearMap.mul`, but there is no longer continuity
bundled in the first coordinate. An alternative viewpoint is that this upgrades
`NonUnitalAlgHom.lmul` from a homomorphism into linear maps to a homomorphism into *continuous*
linear maps. -/
def _root_.NonUnitalAlgHom.Lmul : 𝕜' →ₙₐ[𝕜] 𝕜' →L[𝕜] 𝕜' :=
{ mul 𝕜 𝕜' with
map_mul' := fun _ _ ↦ ext fun _ ↦ mul_assoc _ _ _
map_zero' := ext fun _ ↦ zero_mul _ }
variable {𝕜 𝕜'} in
@[simp]
theorem _root_.NonUnitalAlgHom.coe_Lmul : ⇑(NonUnitalAlgHom.Lmul 𝕜 𝕜') = mul 𝕜 𝕜' :=
rfl
/-- Simultaneous left- and right-multiplication in a non-unital normed algebra, considered as a
continuous trilinear map. This is akin to its non-continuous version `LinearMap.mulLeftRight`,
but there is a minor difference: `LinearMap.mulLeftRight` is uncurried. -/
def mulLeftRight : 𝕜' →L[𝕜] 𝕜' →L[𝕜] 𝕜' →L[𝕜] 𝕜' :=
((compL 𝕜 𝕜' 𝕜' 𝕜').comp (mul 𝕜 𝕜').flip).flip.comp (mul 𝕜 𝕜')
@[simp]
theorem mulLeftRight_apply (x y z : 𝕜') : mulLeftRight 𝕜 𝕜' x y z = x * z * y :=
rfl
theorem opNorm_mulLeftRight_apply_apply_le (x y : 𝕜') : ‖mulLeftRight 𝕜 𝕜' x y‖ ≤ ‖x‖ * ‖y‖ :=
(opNorm_comp_le _ _).trans <|
(mul_comm _ _).trans_le <|
mul_le_mul (opNorm_mul_apply_le _ _ _)
(opNorm_le_bound _ (norm_nonneg _) fun _ => (norm_mul_le _ _).trans_eq (mul_comm _ _))
(norm_nonneg _) (norm_nonneg _)
@[deprecated (since := "2024-02-02")]
alias op_norm_mulLeftRight_apply_apply_le :=
opNorm_mulLeftRight_apply_apply_le
theorem opNorm_mulLeftRight_apply_le (x : 𝕜') : ‖mulLeftRight 𝕜 𝕜' x‖ ≤ ‖x‖ :=
opNorm_le_bound _ (norm_nonneg x) (opNorm_mulLeftRight_apply_apply_le 𝕜 𝕜' x)
@[deprecated (since := "2024-02-02")]
alias op_norm_mulLeftRight_apply_le := opNorm_mulLeftRight_apply_le
#adaptation_note
/--
Before https://github.com/leanprover/lean4/pull/4119
we had to create a local instance in the signature:
```
letI : Norm (𝕜' →L[𝕜] 𝕜' →L[𝕜] 𝕜' →L[𝕜] 𝕜') :=
hasOpNorm (𝕜₂ := 𝕜) (E := 𝕜') (F := 𝕜' →L[𝕜] 𝕜' →L[𝕜] 𝕜')
```
-/
set_option maxSynthPendingDepth 2 in
theorem opNorm_mulLeftRight_le :
‖mulLeftRight 𝕜 𝕜'‖ ≤ 1 :=
opNorm_le_bound _ zero_le_one fun x => (one_mul ‖x‖).symm ▸ opNorm_mulLeftRight_apply_le 𝕜 𝕜' x
@[deprecated (since := "2024-02-02")] alias op_norm_mulLeftRight_le := opNorm_mulLeftRight_le
/-- This is a mixin class for non-unital normed algebras which states that the left-regular
representation of the algebra on itself is isometric. Every unital normed algebra with `‖1‖ = 1` is
a regular normed algebra (see `NormedAlgebra.instRegularNormedAlgebra`). In addition, so is every
C⋆-algebra, non-unital included (see `CStarRing.instRegularNormedAlgebra`), but there are yet other
examples. Any algebra with an approximate identity (e.g., $$L^1$$) is also regular.
This is a useful class because it gives rise to a nice norm on the unitization; in particular it is
a C⋆-norm when the norm on `A` is a C⋆-norm. -/
class _root_.RegularNormedAlgebra : Prop :=
/-- The left regular representation of the algebra on itself is an isometry. -/
isometry_mul' : Isometry (mul 𝕜 𝕜')
/-- Every (unital) normed algebra such that `‖1‖ = 1` is a `RegularNormedAlgebra`. -/
instance _root_.NormedAlgebra.instRegularNormedAlgebra {𝕜 𝕜' : Type*} [NontriviallyNormedField 𝕜]
[SeminormedRing 𝕜'] [NormedAlgebra 𝕜 𝕜'] [NormOneClass 𝕜'] : RegularNormedAlgebra 𝕜 𝕜' where
isometry_mul' := AddMonoidHomClass.isometry_of_norm (mul 𝕜 𝕜') <|
fun x => le_antisymm (opNorm_mul_apply_le _ _ _) <| by
convert ratio_le_opNorm ((mul 𝕜 𝕜') x) (1 : 𝕜')
simp [norm_one]
variable [RegularNormedAlgebra 𝕜 𝕜']
lemma isometry_mul : Isometry (mul 𝕜 𝕜') :=
RegularNormedAlgebra.isometry_mul'
@[simp]
lemma opNorm_mul_apply (x : 𝕜') : ‖mul 𝕜 𝕜' x‖ = ‖x‖ :=
(AddMonoidHomClass.isometry_iff_norm (mul 𝕜 𝕜')).mp (isometry_mul 𝕜 𝕜') x
@[deprecated (since := "2024-02-02")] alias op_norm_mul_apply := opNorm_mul_apply
@[simp]
lemma opNNNorm_mul_apply (x : 𝕜') : ‖mul 𝕜 𝕜' x‖₊ = ‖x‖₊ :=
Subtype.ext <| opNorm_mul_apply 𝕜 𝕜' x
@[deprecated (since := "2024-02-02")] alias op_nnnorm_mul_apply := opNNNorm_mul_apply
/-- Multiplication in a normed algebra as a linear isometry to the space of
continuous linear maps. -/
def mulₗᵢ : 𝕜' →ₗᵢ[𝕜] 𝕜' →L[𝕜] 𝕜' where
toLinearMap := mul 𝕜 𝕜'
norm_map' x := opNorm_mul_apply 𝕜 𝕜' x
@[simp]
theorem coe_mulₗᵢ : ⇑(mulₗᵢ 𝕜 𝕜') = mul 𝕜 𝕜' :=
rfl
end NonUnital
section RingEquiv
variable (𝕜 E)
/-- If `M` is a normed space over `𝕜`, then the space of maps `𝕜 →L[𝕜] M` is linearly equivalent
to `M`. (See `ring_lmap_equiv_self` for a stronger statement.) -/
def ring_lmap_equiv_selfₗ : (𝕜 →L[𝕜] E) ≃ₗ[𝕜] E where
toFun := fun f ↦ f 1
invFun := (ContinuousLinearMap.id 𝕜 𝕜).smulRight
map_smul' := fun a f ↦ by simp only [coe_smul', Pi.smul_apply, RingHom.id_apply]
map_add' := fun f g ↦ by simp only [add_apply]
left_inv := fun f ↦ by ext; simp only [smulRight_apply, coe_id', _root_.id, one_smul]
right_inv := fun m ↦ by simp only [smulRight_apply, id_apply, one_smul]
/-- If `M` is a normed space over `𝕜`, then the space of maps `𝕜 →L[𝕜] M` is linearly isometrically
equivalent to `M`. -/
def ring_lmap_equiv_self : (𝕜 →L[𝕜] E) ≃ₗᵢ[𝕜] E where
toLinearEquiv := ring_lmap_equiv_selfₗ 𝕜 E
norm_map' := by
refine fun f ↦ le_antisymm ?_ ?_
· simpa only [norm_one, mul_one] using le_opNorm f 1
· refine opNorm_le_bound' f (norm_nonneg <| f 1) (fun x _ ↦ ?_)
rw [(by rw [smul_eq_mul, mul_one] : f x = f (x • 1)), ContinuousLinearMap.map_smul,
norm_smul, mul_comm, (by rfl : ring_lmap_equiv_selfₗ 𝕜 E f = f 1)]
end RingEquiv
end MultiplicationLinear
section SMulLinear
variable (𝕜) (𝕜' : Type*) [NormedField 𝕜']
variable [NormedAlgebra 𝕜 𝕜'] [NormedSpace 𝕜' E] [IsScalarTower 𝕜 𝕜' E]
/-- Scalar multiplication as a continuous bilinear map. -/
def lsmul : 𝕜' →L[𝕜] E →L[𝕜] E :=
((Algebra.lsmul 𝕜 𝕜 E).toLinearMap : 𝕜' →ₗ[𝕜] E →ₗ[𝕜] E).mkContinuous₂ 1 fun c x => by
simpa only [one_mul] using norm_smul_le c x
@[simp]
theorem lsmul_apply (c : 𝕜') (x : E) : lsmul 𝕜 𝕜' c x = c • x :=
rfl
variable {𝕜'}
theorem norm_toSpanSingleton (x : E) : ‖toSpanSingleton 𝕜 x‖ = ‖x‖ := by
refine opNorm_eq_of_bounds (norm_nonneg _) (fun x => ?_) fun N _ h => ?_
· rw [toSpanSingleton_apply, norm_smul, mul_comm]
· specialize h 1
rw [toSpanSingleton_apply, norm_smul, mul_comm] at h
exact (mul_le_mul_right (by simp)).mp h
variable {𝕜}
theorem opNorm_lsmul_apply_le (x : 𝕜') : ‖(lsmul 𝕜 𝕜' x : E →L[𝕜] E)‖ ≤ ‖x‖ :=
ContinuousLinearMap.opNorm_le_bound _ (norm_nonneg x) fun y => norm_smul_le x y
@[deprecated (since := "2024-02-02")] alias op_norm_lsmul_apply_le := opNorm_lsmul_apply_le
/-- The norm of `lsmul` is at most 1 in any semi-normed group. -/
theorem opNorm_lsmul_le : ‖(lsmul 𝕜 𝕜' : 𝕜' →L[𝕜] E →L[𝕜] E)‖ ≤ 1 := by
refine ContinuousLinearMap.opNorm_le_bound _ zero_le_one fun x => ?_
simp_rw [one_mul]
exact opNorm_lsmul_apply_le _
@[deprecated (since := "2024-02-02")] alias op_norm_lsmul_le := opNorm_lsmul_le
end SMulLinear
end ContinuousLinearMap
end SemiNormed
section Normed
namespace ContinuousLinearMap
variable [NormedAddCommGroup E] [NormedSpace 𝕜 E] (c : 𝕜)
variable (𝕜) (𝕜' : Type*)
section
variable [NonUnitalNormedRing 𝕜'] [NormedSpace 𝕜 𝕜'] [IsScalarTower 𝕜 𝕜' 𝕜']
variable [SMulCommClass 𝕜 𝕜' 𝕜'] [RegularNormedAlgebra 𝕜 𝕜'] [Nontrivial 𝕜']
@[simp]
theorem opNorm_mul : ‖mul 𝕜 𝕜'‖ = 1 :=
(mulₗᵢ 𝕜 𝕜').norm_toContinuousLinearMap
@[deprecated (since := "2024-02-02")] alias op_norm_mul := opNorm_mul
@[simp]
theorem opNNNorm_mul : ‖mul 𝕜 𝕜'‖₊ = 1 :=
Subtype.ext <| opNorm_mul 𝕜 𝕜'
@[deprecated (since := "2024-02-02")] alias op_nnnorm_mul := opNNNorm_mul
end
/-- The norm of `lsmul` equals 1 in any nontrivial normed group.
This is `ContinuousLinearMap.opNorm_lsmul_le` as an equality. -/
@[simp]
theorem opNorm_lsmul [NormedField 𝕜'] [NormedAlgebra 𝕜 𝕜'] [NormedSpace 𝕜' E]
[IsScalarTower 𝕜 𝕜' E] [Nontrivial E] : ‖(lsmul 𝕜 𝕜' : 𝕜' →L[𝕜] E →L[𝕜] E)‖ = 1 := by
refine ContinuousLinearMap.opNorm_eq_of_bounds zero_le_one (fun x => ?_) fun N _ h => ?_
· rw [one_mul]
apply opNorm_lsmul_apply_le
obtain ⟨y, hy⟩ := exists_ne (0 : E)
have := le_of_opNorm_le _ (h 1) y
simp_rw [lsmul_apply, one_smul, norm_one, mul_one] at this
refine le_of_mul_le_mul_right ?_ (norm_pos_iff.mpr hy)
simp_rw [one_mul, this]
@[deprecated (since := "2024-02-02")] alias op_norm_lsmul := opNorm_lsmul
end ContinuousLinearMap
end Normed
|
Analysis\NormedSpace\OperatorNorm\NNNorm.lean | /-
Copyright (c) 2019 Jan-David Salchow. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jan-David Salchow, Sébastien Gouëzel, Jean Lo
-/
import Mathlib.Analysis.NormedSpace.OperatorNorm.Basic
/-!
# Operator norm as an `NNNorm`
Operator norm as an `NNNorm`, i.e. taking values in non-negative reals.
-/
suppress_compilation
open Bornology
open Filter hiding map_smul
open scoped NNReal Topology Uniformity
-- the `ₗ` subscript variables are for special cases about linear (as opposed to semilinear) maps
variable {𝕜 𝕜₂ 𝕜₃ E Eₗ F Fₗ G Gₗ 𝓕 : Type*}
section SemiNormed
open Metric ContinuousLinearMap
variable [SeminormedAddCommGroup E] [SeminormedAddCommGroup Eₗ] [SeminormedAddCommGroup F]
[SeminormedAddCommGroup Fₗ] [SeminormedAddCommGroup G] [SeminormedAddCommGroup Gₗ]
variable [NontriviallyNormedField 𝕜] [NontriviallyNormedField 𝕜₂] [NontriviallyNormedField 𝕜₃]
[NormedSpace 𝕜 E] [NormedSpace 𝕜 Eₗ] [NormedSpace 𝕜₂ F] [NormedSpace 𝕜 Fₗ] [NormedSpace 𝕜₃ G]
[NormedSpace 𝕜 Gₗ] {σ₁₂ : 𝕜 →+* 𝕜₂} {σ₂₃ : 𝕜₂ →+* 𝕜₃} {σ₁₃ : 𝕜 →+* 𝕜₃}
[RingHomCompTriple σ₁₂ σ₂₃ σ₁₃]
variable [FunLike 𝓕 E F]
namespace ContinuousLinearMap
section OpNorm
open Set Real
section
variable [RingHomIsometric σ₁₂] [RingHomIsometric σ₂₃] (f g : E →SL[σ₁₂] F) (h : F →SL[σ₂₃] G)
(x : E)
theorem nnnorm_def (f : E →SL[σ₁₂] F) : ‖f‖₊ = sInf { c | ∀ x, ‖f x‖₊ ≤ c * ‖x‖₊ } := by
ext
rw [NNReal.coe_sInf, coe_nnnorm, norm_def, NNReal.coe_image]
simp_rw [← NNReal.coe_le_coe, NNReal.coe_mul, coe_nnnorm, mem_setOf_eq, NNReal.coe_mk,
exists_prop]
/-- If one controls the norm of every `A x`, then one controls the norm of `A`. -/
theorem opNNNorm_le_bound (f : E →SL[σ₁₂] F) (M : ℝ≥0) (hM : ∀ x, ‖f x‖₊ ≤ M * ‖x‖₊) : ‖f‖₊ ≤ M :=
opNorm_le_bound f (zero_le M) hM
@[deprecated (since := "2024-02-02")] alias op_nnnorm_le_bound := opNNNorm_le_bound
/-- If one controls the norm of every `A x`, `‖x‖₊ ≠ 0`, then one controls the norm of `A`. -/
theorem opNNNorm_le_bound' (f : E →SL[σ₁₂] F) (M : ℝ≥0) (hM : ∀ x, ‖x‖₊ ≠ 0 → ‖f x‖₊ ≤ M * ‖x‖₊) :
‖f‖₊ ≤ M :=
opNorm_le_bound' f (zero_le M) fun x hx => hM x <| by rwa [← NNReal.coe_ne_zero]
@[deprecated (since := "2024-02-02")] alias op_nnnorm_le_bound' := opNNNorm_le_bound'
/-- For a continuous real linear map `f`, if one controls the norm of every `f x`, `‖x‖₊ = 1`, then
one controls the norm of `f`. -/
theorem opNNNorm_le_of_unit_nnnorm [NormedSpace ℝ E] [NormedSpace ℝ F] {f : E →L[ℝ] F} {C : ℝ≥0}
(hf : ∀ x, ‖x‖₊ = 1 → ‖f x‖₊ ≤ C) : ‖f‖₊ ≤ C :=
opNorm_le_of_unit_norm C.coe_nonneg fun x hx => hf x <| by rwa [← NNReal.coe_eq_one]
@[deprecated (since := "2024-02-02")]
alias op_nnnorm_le_of_unit_nnnorm := opNNNorm_le_of_unit_nnnorm
theorem opNNNorm_le_of_lipschitz {f : E →SL[σ₁₂] F} {K : ℝ≥0} (hf : LipschitzWith K f) :
‖f‖₊ ≤ K :=
opNorm_le_of_lipschitz hf
@[deprecated (since := "2024-02-02")] alias op_nnnorm_le_of_lipschitz := opNNNorm_le_of_lipschitz
theorem opNNNorm_eq_of_bounds {φ : E →SL[σ₁₂] F} (M : ℝ≥0) (h_above : ∀ x, ‖φ x‖₊ ≤ M * ‖x‖₊)
(h_below : ∀ N, (∀ x, ‖φ x‖₊ ≤ N * ‖x‖₊) → M ≤ N) : ‖φ‖₊ = M :=
Subtype.ext <| opNorm_eq_of_bounds (zero_le M) h_above <| Subtype.forall'.mpr h_below
@[deprecated (since := "2024-02-02")] alias op_nnnorm_eq_of_bounds := opNNNorm_eq_of_bounds
theorem opNNNorm_le_iff {f : E →SL[σ₁₂] F} {C : ℝ≥0} : ‖f‖₊ ≤ C ↔ ∀ x, ‖f x‖₊ ≤ C * ‖x‖₊ :=
opNorm_le_iff C.2
@[deprecated (since := "2024-02-02")] alias op_nnnorm_le_iff := opNNNorm_le_iff
theorem isLeast_opNNNorm : IsLeast {C : ℝ≥0 | ∀ x, ‖f x‖₊ ≤ C * ‖x‖₊} ‖f‖₊ := by
simpa only [← opNNNorm_le_iff] using isLeast_Ici
@[deprecated (since := "2024-02-02")] alias isLeast_op_nnnorm := isLeast_opNNNorm
theorem opNNNorm_comp_le [RingHomIsometric σ₁₃] (f : E →SL[σ₁₂] F) : ‖h.comp f‖₊ ≤ ‖h‖₊ * ‖f‖₊ :=
opNorm_comp_le h f
@[deprecated (since := "2024-02-02")] alias op_nnnorm_comp_le := opNNNorm_comp_le
theorem le_opNNNorm : ‖f x‖₊ ≤ ‖f‖₊ * ‖x‖₊ :=
f.le_opNorm x
@[deprecated (since := "2024-02-02")] alias le_op_nnnorm := le_opNNNorm
theorem nndist_le_opNNNorm (x y : E) : nndist (f x) (f y) ≤ ‖f‖₊ * nndist x y :=
dist_le_opNorm f x y
@[deprecated (since := "2024-02-02")] alias nndist_le_op_nnnorm := nndist_le_opNNNorm
/-- continuous linear maps are Lipschitz continuous. -/
theorem lipschitz : LipschitzWith ‖f‖₊ f :=
AddMonoidHomClass.lipschitz_of_bound_nnnorm f _ f.le_opNNNorm
/-- Evaluation of a continuous linear map `f` at a point is Lipschitz continuous in `f`. -/
theorem lipschitz_apply (x : E) : LipschitzWith ‖x‖₊ fun f : E →SL[σ₁₂] F => f x :=
lipschitzWith_iff_norm_sub_le.2 fun f g => ((f - g).le_opNorm x).trans_eq (mul_comm _ _)
end
section Sup
variable [RingHomIsometric σ₁₂]
theorem exists_mul_lt_apply_of_lt_opNNNorm (f : E →SL[σ₁₂] F) {r : ℝ≥0} (hr : r < ‖f‖₊) :
∃ x, r * ‖x‖₊ < ‖f x‖₊ := by
simpa only [not_forall, not_le, Set.mem_setOf] using
not_mem_of_lt_csInf (nnnorm_def f ▸ hr : r < sInf { c : ℝ≥0 | ∀ x, ‖f x‖₊ ≤ c * ‖x‖₊ })
(OrderBot.bddBelow _)
@[deprecated (since := "2024-02-02")]
alias exists_mul_lt_apply_of_lt_op_nnnorm := exists_mul_lt_apply_of_lt_opNNNorm
theorem exists_mul_lt_of_lt_opNorm (f : E →SL[σ₁₂] F) {r : ℝ} (hr₀ : 0 ≤ r) (hr : r < ‖f‖) :
∃ x, r * ‖x‖ < ‖f x‖ := by
lift r to ℝ≥0 using hr₀
exact f.exists_mul_lt_apply_of_lt_opNNNorm hr
@[deprecated (since := "2024-02-02")]
alias exists_mul_lt_of_lt_op_norm := exists_mul_lt_of_lt_opNorm
theorem exists_lt_apply_of_lt_opNNNorm {𝕜 𝕜₂ E F : Type*} [NormedAddCommGroup E]
[SeminormedAddCommGroup F] [DenselyNormedField 𝕜] [NontriviallyNormedField 𝕜₂] {σ₁₂ : 𝕜 →+* 𝕜₂}
[NormedSpace 𝕜 E] [NormedSpace 𝕜₂ F] [RingHomIsometric σ₁₂] (f : E →SL[σ₁₂] F) {r : ℝ≥0}
(hr : r < ‖f‖₊) : ∃ x : E, ‖x‖₊ < 1 ∧ r < ‖f x‖₊ := by
obtain ⟨y, hy⟩ := f.exists_mul_lt_apply_of_lt_opNNNorm hr
have hy' : ‖y‖₊ ≠ 0 :=
nnnorm_ne_zero_iff.2 fun heq => by
simp [heq, nnnorm_zero, map_zero, not_lt_zero'] at hy
have hfy : ‖f y‖₊ ≠ 0 := (zero_le'.trans_lt hy).ne'
rw [← inv_inv ‖f y‖₊, NNReal.lt_inv_iff_mul_lt (inv_ne_zero hfy), mul_assoc, mul_comm ‖y‖₊, ←
mul_assoc, ← NNReal.lt_inv_iff_mul_lt hy'] at hy
obtain ⟨k, hk₁, hk₂⟩ := NormedField.exists_lt_nnnorm_lt 𝕜 hy
refine ⟨k • y, (nnnorm_smul k y).symm ▸ (NNReal.lt_inv_iff_mul_lt hy').1 hk₂, ?_⟩
have : ‖σ₁₂ k‖₊ = ‖k‖₊ := Subtype.ext RingHomIsometric.is_iso
rwa [map_smulₛₗ f, nnnorm_smul, ← NNReal.div_lt_iff hfy, div_eq_mul_inv, this]
@[deprecated (since := "2024-02-02")]
alias exists_lt_apply_of_lt_op_nnnorm := exists_lt_apply_of_lt_opNNNorm
theorem exists_lt_apply_of_lt_opNorm {𝕜 𝕜₂ E F : Type*} [NormedAddCommGroup E]
[SeminormedAddCommGroup F] [DenselyNormedField 𝕜] [NontriviallyNormedField 𝕜₂] {σ₁₂ : 𝕜 →+* 𝕜₂}
[NormedSpace 𝕜 E] [NormedSpace 𝕜₂ F] [RingHomIsometric σ₁₂] (f : E →SL[σ₁₂] F) {r : ℝ}
(hr : r < ‖f‖) : ∃ x : E, ‖x‖ < 1 ∧ r < ‖f x‖ := by
by_cases hr₀ : r < 0
· exact ⟨0, by simpa using hr₀⟩
· lift r to ℝ≥0 using not_lt.1 hr₀
exact f.exists_lt_apply_of_lt_opNNNorm hr
@[deprecated (since := "2024-02-02")]
alias exists_lt_apply_of_lt_op_norm := exists_lt_apply_of_lt_opNorm
theorem sSup_unit_ball_eq_nnnorm {𝕜 𝕜₂ E F : Type*} [NormedAddCommGroup E]
[SeminormedAddCommGroup F] [DenselyNormedField 𝕜] [NontriviallyNormedField 𝕜₂] {σ₁₂ : 𝕜 →+* 𝕜₂}
[NormedSpace 𝕜 E] [NormedSpace 𝕜₂ F] [RingHomIsometric σ₁₂] (f : E →SL[σ₁₂] F) :
sSup ((fun x => ‖f x‖₊) '' ball 0 1) = ‖f‖₊ := by
refine csSup_eq_of_forall_le_of_forall_lt_exists_gt ((nonempty_ball.mpr zero_lt_one).image _) ?_
fun ub hub => ?_
· rintro - ⟨x, hx, rfl⟩
simpa only [mul_one] using f.le_opNorm_of_le (mem_ball_zero_iff.1 hx).le
· obtain ⟨x, hx, hxf⟩ := f.exists_lt_apply_of_lt_opNNNorm hub
exact ⟨_, ⟨x, mem_ball_zero_iff.2 hx, rfl⟩, hxf⟩
theorem sSup_unit_ball_eq_norm {𝕜 𝕜₂ E F : Type*} [NormedAddCommGroup E] [SeminormedAddCommGroup F]
[DenselyNormedField 𝕜] [NontriviallyNormedField 𝕜₂] {σ₁₂ : 𝕜 →+* 𝕜₂} [NormedSpace 𝕜 E]
[NormedSpace 𝕜₂ F] [RingHomIsometric σ₁₂] (f : E →SL[σ₁₂] F) :
sSup ((fun x => ‖f x‖) '' ball 0 1) = ‖f‖ := by
simpa only [NNReal.coe_sSup, Set.image_image] using NNReal.coe_inj.2 f.sSup_unit_ball_eq_nnnorm
theorem sSup_closed_unit_ball_eq_nnnorm {𝕜 𝕜₂ E F : Type*} [NormedAddCommGroup E]
[SeminormedAddCommGroup F] [DenselyNormedField 𝕜] [NontriviallyNormedField 𝕜₂] {σ₁₂ : 𝕜 →+* 𝕜₂}
[NormedSpace 𝕜 E] [NormedSpace 𝕜₂ F] [RingHomIsometric σ₁₂] (f : E →SL[σ₁₂] F) :
sSup ((fun x => ‖f x‖₊) '' closedBall 0 1) = ‖f‖₊ := by
have hbdd : ∀ y ∈ (fun x => ‖f x‖₊) '' closedBall 0 1, y ≤ ‖f‖₊ := by
rintro - ⟨x, hx, rfl⟩
exact f.unit_le_opNorm x (mem_closedBall_zero_iff.1 hx)
refine le_antisymm (csSup_le ((nonempty_closedBall.mpr zero_le_one).image _) hbdd) ?_
rw [← sSup_unit_ball_eq_nnnorm]
exact csSup_le_csSup ⟨‖f‖₊, hbdd⟩ ((nonempty_ball.2 zero_lt_one).image _)
(Set.image_subset _ ball_subset_closedBall)
theorem sSup_closed_unit_ball_eq_norm {𝕜 𝕜₂ E F : Type*} [NormedAddCommGroup E]
[SeminormedAddCommGroup F] [DenselyNormedField 𝕜] [NontriviallyNormedField 𝕜₂] {σ₁₂ : 𝕜 →+* 𝕜₂}
[NormedSpace 𝕜 E] [NormedSpace 𝕜₂ F] [RingHomIsometric σ₁₂] (f : E →SL[σ₁₂] F) :
sSup ((fun x => ‖f x‖) '' closedBall 0 1) = ‖f‖ := by
simpa only [NNReal.coe_sSup, Set.image_image] using
NNReal.coe_inj.2 f.sSup_closed_unit_ball_eq_nnnorm
end Sup
end OpNorm
end ContinuousLinearMap
namespace ContinuousLinearEquiv
variable {σ₂₁ : 𝕜₂ →+* 𝕜} [RingHomInvPair σ₁₂ σ₂₁] [RingHomInvPair σ₂₁ σ₁₂] [RingHomIsometric σ₁₂]
variable (e : E ≃SL[σ₁₂] F)
protected theorem lipschitz : LipschitzWith ‖(e : E →SL[σ₁₂] F)‖₊ e :=
(e : E →SL[σ₁₂] F).lipschitz
end ContinuousLinearEquiv
end SemiNormed
|
Analysis\NormedSpace\OperatorNorm\NormedSpace.lean | /-
Copyright (c) 2019 Jan-David Salchow. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jan-David Salchow, Sébastien Gouëzel, Jean Lo
-/
import Mathlib.Analysis.NormedSpace.OperatorNorm.Bilinear
import Mathlib.Analysis.NormedSpace.OperatorNorm.NNNorm
import Mathlib.Analysis.Normed.Module.Span
/-!
# Operator norm for maps on normed spaces
This file contains statements about operator norm for which it really matters that the
underlying space has a norm (rather than just a seminorm).
-/
suppress_compilation
open Bornology
open Filter hiding map_smul
open scoped NNReal Topology Uniformity
-- the `ₗ` subscript variables are for special cases about linear (as opposed to semilinear) maps
variable {𝕜 𝕜₂ 𝕜₃ E Eₗ F Fₗ G Gₗ 𝓕 : Type*}
section Normed
variable [NormedAddCommGroup E] [NormedAddCommGroup F] [NormedAddCommGroup G]
[NormedAddCommGroup Fₗ]
open Metric ContinuousLinearMap
section
variable [NontriviallyNormedField 𝕜] [NontriviallyNormedField 𝕜₂] [NontriviallyNormedField 𝕜₃]
[NormedSpace 𝕜 E] [NormedSpace 𝕜₂ F] [NormedSpace 𝕜₃ G] [NormedSpace 𝕜 Fₗ] (c : 𝕜)
{σ₁₂ : 𝕜 →+* 𝕜₂} {σ₂₃ : 𝕜₂ →+* 𝕜₃} (f g : E →SL[σ₁₂] F) (x y z : E)
namespace LinearMap
theorem bound_of_shell [RingHomIsometric σ₁₂] (f : E →ₛₗ[σ₁₂] F) {ε C : ℝ} (ε_pos : 0 < ε) {c : 𝕜}
(hc : 1 < ‖c‖) (hf : ∀ x, ε / ‖c‖ ≤ ‖x‖ → ‖x‖ < ε → ‖f x‖ ≤ C * ‖x‖) (x : E) :
‖f x‖ ≤ C * ‖x‖ := by
by_cases hx : x = 0; · simp [hx]
exact SemilinearMapClass.bound_of_shell_semi_normed f ε_pos hc hf (norm_ne_zero_iff.2 hx)
/-- `LinearMap.bound_of_ball_bound'` is a version of this lemma over a field satisfying `RCLike`
that produces a concrete bound.
-/
theorem bound_of_ball_bound {r : ℝ} (r_pos : 0 < r) (c : ℝ) (f : E →ₗ[𝕜] Fₗ)
(h : ∀ z ∈ Metric.ball (0 : E) r, ‖f z‖ ≤ c) : ∃ C, ∀ z : E, ‖f z‖ ≤ C * ‖z‖ := by
cases' @NontriviallyNormedField.non_trivial 𝕜 _ with k hk
use c * (‖k‖ / r)
intro z
refine bound_of_shell _ r_pos hk (fun x hko hxo => ?_) _
calc
‖f x‖ ≤ c := h _ (mem_ball_zero_iff.mpr hxo)
_ ≤ c * (‖x‖ * ‖k‖ / r) := le_mul_of_one_le_right ?_ ?_
_ = _ := by ring
· exact le_trans (norm_nonneg _) (h 0 (by simp [r_pos]))
· rw [div_le_iff (zero_lt_one.trans hk)] at hko
exact (one_le_div r_pos).mpr hko
theorem antilipschitz_of_comap_nhds_le [h : RingHomIsometric σ₁₂] (f : E →ₛₗ[σ₁₂] F)
(hf : (𝓝 0).comap f ≤ 𝓝 0) : ∃ K, AntilipschitzWith K f := by
rcases ((nhds_basis_ball.comap _).le_basis_iff nhds_basis_ball).1 hf 1 one_pos with ⟨ε, ε0, hε⟩
simp only [Set.subset_def, Set.mem_preimage, mem_ball_zero_iff] at hε
lift ε to ℝ≥0 using ε0.le
rcases NormedField.exists_one_lt_norm 𝕜 with ⟨c, hc⟩
refine ⟨ε⁻¹ * ‖c‖₊, AddMonoidHomClass.antilipschitz_of_bound f fun x => ?_⟩
by_cases hx : f x = 0
· rw [← hx] at hf
obtain rfl : x = 0 := Specializes.eq (specializes_iff_pure.2 <|
((Filter.tendsto_pure_pure _ _).mono_right (pure_le_nhds _)).le_comap.trans hf)
exact norm_zero.trans_le (mul_nonneg (NNReal.coe_nonneg _) (norm_nonneg _))
have hc₀ : c ≠ 0 := norm_pos_iff.1 (one_pos.trans hc)
rw [← h.1] at hc
rcases rescale_to_shell_zpow hc ε0 hx with ⟨n, -, hlt, -, hle⟩
simp only [← map_zpow₀, h.1, ← map_smulₛₗ] at hlt hle
calc
‖x‖ = ‖c ^ n‖⁻¹ * ‖c ^ n • x‖ := by
rwa [← norm_inv, ← norm_smul, inv_smul_smul₀ (zpow_ne_zero _ _)]
_ ≤ ‖c ^ n‖⁻¹ * 1 := (mul_le_mul_of_nonneg_left (hε _ hlt).le (inv_nonneg.2 (norm_nonneg _)))
_ ≤ ε⁻¹ * ‖c‖ * ‖f x‖ := by rwa [mul_one]
end LinearMap
namespace ContinuousLinearMap
section OpNorm
open Set Real
/-- An operator is zero iff its norm vanishes. -/
theorem opNorm_zero_iff [RingHomIsometric σ₁₂] : ‖f‖ = 0 ↔ f = 0 :=
Iff.intro
(fun hn => ContinuousLinearMap.ext fun x => norm_le_zero_iff.1
(calc
_ ≤ ‖f‖ * ‖x‖ := le_opNorm _ _
_ = _ := by rw [hn, zero_mul]))
(by
rintro rfl
exact opNorm_zero)
@[deprecated (since := "2024-02-02")] alias op_norm_zero_iff := opNorm_zero_iff
/-- If a normed space is non-trivial, then the norm of the identity equals `1`. -/
@[simp]
theorem norm_id [Nontrivial E] : ‖id 𝕜 E‖ = 1 := by
refine norm_id_of_nontrivial_seminorm ?_
obtain ⟨x, hx⟩ := exists_ne (0 : E)
exact ⟨x, ne_of_gt (norm_pos_iff.2 hx)⟩
@[simp]
lemma nnnorm_id [Nontrivial E] : ‖id 𝕜 E‖₊ = 1 := NNReal.eq norm_id
instance normOneClass [Nontrivial E] : NormOneClass (E →L[𝕜] E) :=
⟨norm_id⟩
/-- Continuous linear maps themselves form a normed space with respect to
the operator norm. -/
instance toNormedAddCommGroup [RingHomIsometric σ₁₂] : NormedAddCommGroup (E →SL[σ₁₂] F) :=
NormedAddCommGroup.ofSeparation fun f => (opNorm_zero_iff f).mp
/-- Continuous linear maps form a normed ring with respect to the operator norm. -/
instance toNormedRing : NormedRing (E →L[𝕜] E) :=
{ ContinuousLinearMap.toNormedAddCommGroup, ContinuousLinearMap.toSemiNormedRing with }
variable {f}
theorem homothety_norm [RingHomIsometric σ₁₂] [Nontrivial E] (f : E →SL[σ₁₂] F) {a : ℝ}
(hf : ∀ x, ‖f x‖ = a * ‖x‖) : ‖f‖ = a := by
obtain ⟨x, hx⟩ : ∃ x : E, x ≠ 0 := exists_ne 0
rw [← norm_pos_iff] at hx
have ha : 0 ≤ a := by simpa only [hf, hx, mul_nonneg_iff_of_pos_right] using norm_nonneg (f x)
apply le_antisymm (f.opNorm_le_bound ha fun y => le_of_eq (hf y))
simpa only [hf, hx, mul_le_mul_right] using f.le_opNorm x
variable (f)
/-- If a continuous linear map is a topology embedding, then it is expands the distances
by a positive factor. -/
theorem antilipschitz_of_embedding (f : E →L[𝕜] Fₗ) (hf : Embedding f) :
∃ K, AntilipschitzWith K f :=
f.toLinearMap.antilipschitz_of_comap_nhds_le <| map_zero f ▸ (hf.nhds_eq_comap 0).ge
end OpNorm
end ContinuousLinearMap
namespace LinearIsometry
@[simp]
theorem norm_toContinuousLinearMap [Nontrivial E] [RingHomIsometric σ₁₂] (f : E →ₛₗᵢ[σ₁₂] F) :
‖f.toContinuousLinearMap‖ = 1 :=
f.toContinuousLinearMap.homothety_norm <| by simp
variable {σ₁₃ : 𝕜 →+* 𝕜₃} [RingHomCompTriple σ₁₂ σ₂₃ σ₁₃]
/-- Postcomposition of a continuous linear map with a linear isometry preserves
the operator norm. -/
theorem norm_toContinuousLinearMap_comp [RingHomIsometric σ₁₂] (f : F →ₛₗᵢ[σ₂₃] G)
{g : E →SL[σ₁₂] F} : ‖f.toContinuousLinearMap.comp g‖ = ‖g‖ :=
opNorm_ext (f.toContinuousLinearMap.comp g) g fun x => by
simp only [norm_map, coe_toContinuousLinearMap, coe_comp', Function.comp_apply]
end LinearIsometry
end
namespace ContinuousLinearMap
variable [NontriviallyNormedField 𝕜] [NontriviallyNormedField 𝕜₂] [NontriviallyNormedField 𝕜₃]
[NormedSpace 𝕜 E] [NormedSpace 𝕜₂ F] [NormedSpace 𝕜₃ G] [NormedSpace 𝕜 Fₗ] (c : 𝕜)
{σ₁₂ : 𝕜 →+* 𝕜₂} {σ₂₃ : 𝕜₂ →+* 𝕜₃}
variable {𝕜₂' : Type*} [NontriviallyNormedField 𝕜₂'] {F' : Type*} [NormedAddCommGroup F']
[NormedSpace 𝕜₂' F'] {σ₂' : 𝕜₂' →+* 𝕜₂} {σ₂'' : 𝕜₂ →+* 𝕜₂'} {σ₂₃' : 𝕜₂' →+* 𝕜₃}
[RingHomInvPair σ₂' σ₂''] [RingHomInvPair σ₂'' σ₂'] [RingHomCompTriple σ₂' σ₂₃ σ₂₃']
[RingHomCompTriple σ₂'' σ₂₃' σ₂₃] [RingHomIsometric σ₂₃] [RingHomIsometric σ₂']
[RingHomIsometric σ₂''] [RingHomIsometric σ₂₃']
/-- Precomposition with a linear isometry preserves the operator norm. -/
theorem opNorm_comp_linearIsometryEquiv (f : F →SL[σ₂₃] G) (g : F' ≃ₛₗᵢ[σ₂'] F) :
‖f.comp g.toLinearIsometry.toContinuousLinearMap‖ = ‖f‖ := by
cases subsingleton_or_nontrivial F'
· haveI := g.symm.toLinearEquiv.toEquiv.subsingleton
simp
refine le_antisymm ?_ ?_
· convert f.opNorm_comp_le g.toLinearIsometry.toContinuousLinearMap
simp [g.toLinearIsometry.norm_toContinuousLinearMap]
· convert (f.comp g.toLinearIsometry.toContinuousLinearMap).opNorm_comp_le
g.symm.toLinearIsometry.toContinuousLinearMap
· ext
simp
haveI := g.symm.surjective.nontrivial
simp [g.symm.toLinearIsometry.norm_toContinuousLinearMap]
@[deprecated (since := "2024-02-02")]
alias op_norm_comp_linearIsometryEquiv := opNorm_comp_linearIsometryEquiv
/-- The norm of the tensor product of a scalar linear map and of an element of a normed space
is the product of the norms. -/
@[simp]
theorem norm_smulRight_apply (c : E →L[𝕜] 𝕜) (f : Fₗ) : ‖smulRight c f‖ = ‖c‖ * ‖f‖ := by
refine le_antisymm ?_ ?_
· refine opNorm_le_bound _ (mul_nonneg (norm_nonneg _) (norm_nonneg _)) fun x => ?_
calc
‖c x • f‖ = ‖c x‖ * ‖f‖ := norm_smul _ _
_ ≤ ‖c‖ * ‖x‖ * ‖f‖ := mul_le_mul_of_nonneg_right (le_opNorm _ _) (norm_nonneg _)
_ = ‖c‖ * ‖f‖ * ‖x‖ := by ring
· by_cases h : f = 0
· simp [h]
· have : 0 < ‖f‖ := norm_pos_iff.2 h
rw [← le_div_iff this]
refine opNorm_le_bound _ (div_nonneg (norm_nonneg _) (norm_nonneg f)) fun x => ?_
rw [div_mul_eq_mul_div, le_div_iff this]
calc
‖c x‖ * ‖f‖ = ‖c x • f‖ := (norm_smul _ _).symm
_ = ‖smulRight c f x‖ := rfl
_ ≤ ‖smulRight c f‖ * ‖x‖ := le_opNorm _ _
/-- The non-negative norm of the tensor product of a scalar linear map and of an element of a normed
space is the product of the non-negative norms. -/
@[simp]
theorem nnnorm_smulRight_apply (c : E →L[𝕜] 𝕜) (f : Fₗ) : ‖smulRight c f‖₊ = ‖c‖₊ * ‖f‖₊ :=
NNReal.eq <| c.norm_smulRight_apply f
variable (𝕜 E Fₗ)
/-- `ContinuousLinearMap.smulRight` as a continuous trilinear map:
`smulRightL (c : E →L[𝕜] 𝕜) (f : F) (x : E) = c x • f`. -/
def smulRightL : (E →L[𝕜] 𝕜) →L[𝕜] Fₗ →L[𝕜] E →L[𝕜] Fₗ :=
LinearMap.mkContinuous₂
{ toFun := smulRightₗ
map_add' := fun c₁ c₂ => by
ext x
simp only [add_smul, coe_smulRightₗ, add_apply, smulRight_apply, LinearMap.add_apply]
map_smul' := fun m c => by
ext x
dsimp
rw [smul_smul] }
1 fun c x => by
simp only [coe_smulRightₗ, one_mul, norm_smulRight_apply, LinearMap.coe_mk, AddHom.coe_mk,
le_refl]
variable {𝕜 E Fₗ}
@[simp]
theorem norm_smulRightL_apply (c : E →L[𝕜] 𝕜) (f : Fₗ) : ‖smulRightL 𝕜 E Fₗ c f‖ = ‖c‖ * ‖f‖ :=
norm_smulRight_apply c f
@[simp]
theorem norm_smulRightL (c : E →L[𝕜] 𝕜) [Nontrivial Fₗ] : ‖smulRightL 𝕜 E Fₗ c‖ = ‖c‖ :=
ContinuousLinearMap.homothety_norm _ c.norm_smulRight_apply
#adaptation_note
/--
Before https://github.com/leanprover/lean4/pull/4119 we had to create a local instance:
```
letI : SeminormedAddCommGroup ((E →L[𝕜] 𝕜) →L[𝕜] Fₗ →L[𝕜] E →L[𝕜] Fₗ) :=
toSeminormedAddCommGroup (F := Fₗ →L[𝕜] E →L[𝕜] Fₗ) (𝕜 := 𝕜) (σ₁₂ := RingHom.id 𝕜)
```
-/
set_option maxSynthPendingDepth 2 in
lemma norm_smulRightL_le : ‖smulRightL 𝕜 E Fₗ‖ ≤ 1 :=
LinearMap.mkContinuous₂_norm_le _ zero_le_one _
end ContinuousLinearMap
namespace Submodule
variable [NontriviallyNormedField 𝕜] [NontriviallyNormedField 𝕜₂] [NontriviallyNormedField 𝕜₃]
[NormedSpace 𝕜 E] [NormedSpace 𝕜₂ F] {σ₁₂ : 𝕜 →+* 𝕜₂}
theorem norm_subtypeL (K : Submodule 𝕜 E) [Nontrivial K] : ‖K.subtypeL‖ = 1 :=
K.subtypeₗᵢ.norm_toContinuousLinearMap
end Submodule
namespace ContinuousLinearEquiv
variable [NontriviallyNormedField 𝕜] [NontriviallyNormedField 𝕜₂] [NontriviallyNormedField 𝕜₃]
[NormedSpace 𝕜 E] [NormedSpace 𝕜₂ F] {σ₁₂ : 𝕜 →+* 𝕜₂} {σ₂₁ : 𝕜₂ →+* 𝕜} [RingHomInvPair σ₁₂ σ₂₁]
[RingHomInvPair σ₂₁ σ₁₂]
section
variable [RingHomIsometric σ₂₁]
protected theorem antilipschitz (e : E ≃SL[σ₁₂] F) :
AntilipschitzWith ‖(e.symm : F →SL[σ₂₁] E)‖₊ e :=
e.symm.lipschitz.to_rightInverse e.left_inv
theorem one_le_norm_mul_norm_symm [RingHomIsometric σ₁₂] [Nontrivial E] (e : E ≃SL[σ₁₂] F) :
1 ≤ ‖(e : E →SL[σ₁₂] F)‖ * ‖(e.symm : F →SL[σ₂₁] E)‖ := by
rw [mul_comm]
convert (e.symm : F →SL[σ₂₁] E).opNorm_comp_le (e : E →SL[σ₁₂] F)
rw [e.coe_symm_comp_coe, ContinuousLinearMap.norm_id]
theorem norm_pos [RingHomIsometric σ₁₂] [Nontrivial E] (e : E ≃SL[σ₁₂] F) :
0 < ‖(e : E →SL[σ₁₂] F)‖ :=
pos_of_mul_pos_left (lt_of_lt_of_le zero_lt_one e.one_le_norm_mul_norm_symm) (norm_nonneg _)
theorem norm_symm_pos [RingHomIsometric σ₁₂] [Nontrivial E] (e : E ≃SL[σ₁₂] F) :
0 < ‖(e.symm : F →SL[σ₂₁] E)‖ :=
pos_of_mul_pos_right (zero_lt_one.trans_le e.one_le_norm_mul_norm_symm) (norm_nonneg _)
theorem nnnorm_symm_pos [RingHomIsometric σ₁₂] [Nontrivial E] (e : E ≃SL[σ₁₂] F) :
0 < ‖(e.symm : F →SL[σ₂₁] E)‖₊ :=
e.norm_symm_pos
theorem subsingleton_or_norm_symm_pos [RingHomIsometric σ₁₂] (e : E ≃SL[σ₁₂] F) :
Subsingleton E ∨ 0 < ‖(e.symm : F →SL[σ₂₁] E)‖ := by
rcases subsingleton_or_nontrivial E with (_i | _i)
· left
infer_instance
· right
exact e.norm_symm_pos
theorem subsingleton_or_nnnorm_symm_pos [RingHomIsometric σ₁₂] (e : E ≃SL[σ₁₂] F) :
Subsingleton E ∨ 0 < ‖(e.symm : F →SL[σ₂₁] E)‖₊ :=
subsingleton_or_norm_symm_pos e
variable (𝕜)
@[simp]
theorem coord_norm (x : E) (h : x ≠ 0) : ‖coord 𝕜 x h‖ = ‖x‖⁻¹ := by
have hx : 0 < ‖x‖ := norm_pos_iff.mpr h
haveI : Nontrivial (𝕜 ∙ x) := Submodule.nontrivial_span_singleton h
exact ContinuousLinearMap.homothety_norm _ fun y =>
homothety_inverse _ hx _ (LinearEquiv.toSpanNonzeroSingleton_homothety 𝕜 x h) _
end
end ContinuousLinearEquiv
end Normed
/-- A bounded bilinear form `B` in a real normed space is *coercive*
if there is some positive constant C such that `C * ‖u‖ * ‖u‖ ≤ B u u`.
-/
def IsCoercive [NormedAddCommGroup E] [NormedSpace ℝ E] (B : E →L[ℝ] E →L[ℝ] ℝ) : Prop :=
∃ C, 0 < C ∧ ∀ u, C * ‖u‖ * ‖u‖ ≤ B u u
section Equicontinuous
variable {ι : Type*} [NontriviallyNormedField 𝕜] [NontriviallyNormedField 𝕜₂] {σ₁₂ : 𝕜 →+* 𝕜₂}
[RingHomIsometric σ₁₂] [SeminormedAddCommGroup E] [SeminormedAddCommGroup F]
[NormedSpace 𝕜 E] [NormedSpace 𝕜₂ F] (f : ι → E →SL[σ₁₂] F)
/-- Equivalent characterizations for equicontinuity of a family of continuous linear maps
between normed spaces. See also `WithSeminorms.equicontinuous_TFAE` for similar characterizations
between spaces satisfying `WithSeminorms`. -/
protected theorem NormedSpace.equicontinuous_TFAE : List.TFAE
[ EquicontinuousAt ((↑) ∘ f) 0,
Equicontinuous ((↑) ∘ f),
UniformEquicontinuous ((↑) ∘ f),
∃ C, ∀ i x, ‖f i x‖ ≤ C * ‖x‖,
∃ C ≥ 0, ∀ i x, ‖f i x‖ ≤ C * ‖x‖,
∃ C, ∀ i, ‖f i‖ ≤ C,
∃ C ≥ 0, ∀ i, ‖f i‖ ≤ C,
BddAbove (Set.range (‖f ·‖)),
(⨆ i, (‖f i‖₊ : ENNReal)) < ⊤ ] := by
-- `1 ↔ 2 ↔ 3` follows from `uniformEquicontinuous_of_equicontinuousAt_zero`
tfae_have 1 → 3
· exact uniformEquicontinuous_of_equicontinuousAt_zero f
tfae_have 3 → 2
· exact UniformEquicontinuous.equicontinuous
tfae_have 2 → 1
· exact fun H ↦ H 0
-- `4 ↔ 5 ↔ 6 ↔ 7 ↔ 8 ↔ 9` is morally trivial, we just have to use a lot of rewriting
-- and `congr` lemmas
tfae_have 4 ↔ 5
· rw [exists_ge_and_iff_exists]
exact fun C₁ C₂ hC ↦ forall₂_imp fun i x ↦ le_trans' <| by gcongr
tfae_have 5 ↔ 7
· refine exists_congr (fun C ↦ and_congr_right fun hC ↦ forall_congr' fun i ↦ ?_)
rw [ContinuousLinearMap.opNorm_le_iff hC]
tfae_have 7 ↔ 8
· simp_rw [bddAbove_iff_exists_ge (0 : ℝ), Set.forall_mem_range]
tfae_have 6 ↔ 8
· simp_rw [bddAbove_def, Set.forall_mem_range]
tfae_have 8 ↔ 9
· rw [ENNReal.iSup_coe_lt_top, ← NNReal.bddAbove_coe, ← Set.range_comp]
rfl
-- `3 ↔ 4` is the interesting part of the result. It is essentially a combination of
-- `WithSeminorms.uniformEquicontinuous_iff_exists_continuous_seminorm` which turns
-- equicontinuity into existence of some continuous seminorm and
-- `Seminorm.bound_of_continuous_normedSpace` which characterize such seminorms.
tfae_have 3 ↔ 4
· refine ((norm_withSeminorms 𝕜₂ F).uniformEquicontinuous_iff_exists_continuous_seminorm _).trans
?_
rw [forall_const]
constructor
· intro ⟨p, hp, hpf⟩
rcases p.bound_of_continuous_normedSpace hp with ⟨C, -, hC⟩
exact ⟨C, fun i x ↦ (hpf i x).trans (hC x)⟩
· intro ⟨C, hC⟩
refine ⟨C.toNNReal • normSeminorm 𝕜 E,
((norm_withSeminorms 𝕜 E).continuous_seminorm 0).const_smul C.toNNReal, fun i x ↦ ?_⟩
exact (hC i x).trans (mul_le_mul_of_nonneg_right (C.le_coe_toNNReal) (norm_nonneg x))
tfae_finish
end Equicontinuous
|
Analysis\NormedSpace\OperatorNorm\Prod.lean | /-
Copyright (c) 2019 Jan-David Salchow. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jan-David Salchow, Sébastien Gouëzel, Jean Lo
-/
import Mathlib.Analysis.NormedSpace.OperatorNorm.Bilinear
/-!
# Operator norm: Cartesian products
Interaction of operator norm with Cartesian products.
-/
variable {𝕜 E F G : Type*} [NontriviallyNormedField 𝕜]
open Set Real Metric ContinuousLinearMap
section SemiNormed
variable [SeminormedAddCommGroup E] [SeminormedAddCommGroup F] [SeminormedAddCommGroup G]
variable [NormedSpace 𝕜 E] [NormedSpace 𝕜 F] [NormedSpace 𝕜 G]
namespace ContinuousLinearMap
section FirstSecond
variable (𝕜 E F)
/-- The operator norm of the first projection `E × F → E` is at most 1. (It is 0 if `E` is zero, so
the inequality cannot be improved without further assumptions.) -/
lemma norm_fst_le : ‖fst 𝕜 E F‖ ≤ 1 :=
opNorm_le_bound _ zero_le_one (fun ⟨e, f⟩ ↦ by simpa only [one_mul] using le_max_left ‖e‖ ‖f‖)
/-- The operator norm of the second projection `E × F → F` is at most 1. (It is 0 if `F` is zero, so
the inequality cannot be improved without further assumptions.) -/
lemma norm_snd_le : ‖snd 𝕜 E F‖ ≤ 1 :=
opNorm_le_bound _ zero_le_one (fun ⟨e, f⟩ ↦ by simpa only [one_mul] using le_max_right ‖e‖ ‖f‖)
end FirstSecond
section OpNorm
@[simp]
theorem opNorm_prod (f : E →L[𝕜] F) (g : E →L[𝕜] G) : ‖f.prod g‖ = ‖(f, g)‖ :=
le_antisymm
(opNorm_le_bound _ (norm_nonneg _) fun x => by
simpa only [prod_apply, Prod.norm_def, max_mul_of_nonneg, norm_nonneg] using
max_le_max (le_opNorm f x) (le_opNorm g x)) <|
max_le
(opNorm_le_bound _ (norm_nonneg _) fun x =>
(le_max_left _ _).trans ((f.prod g).le_opNorm x))
(opNorm_le_bound _ (norm_nonneg _) fun x =>
(le_max_right _ _).trans ((f.prod g).le_opNorm x))
@[deprecated (since := "2024-02-02")] alias op_norm_prod := opNorm_prod
@[simp]
theorem opNNNorm_prod (f : E →L[𝕜] F) (g : E →L[𝕜] G) : ‖f.prod g‖₊ = ‖(f, g)‖₊ :=
Subtype.ext <| opNorm_prod f g
@[deprecated (since := "2024-02-02")] alias op_nnnorm_prod := opNNNorm_prod
/-- `ContinuousLinearMap.prod` as a `LinearIsometryEquiv`. -/
def prodₗᵢ (R : Type*) [Semiring R] [Module R F] [Module R G] [ContinuousConstSMul R F]
[ContinuousConstSMul R G] [SMulCommClass 𝕜 R F] [SMulCommClass 𝕜 R G] :
(E →L[𝕜] F) × (E →L[𝕜] G) ≃ₗᵢ[R] E →L[𝕜] F × G :=
⟨prodₗ R, fun ⟨f, g⟩ => opNorm_prod f g⟩
end OpNorm
section Prod
variable (𝕜)
variable (M₁ M₂ M₃ M₄ : Type*)
[SeminormedAddCommGroup M₁] [NormedSpace 𝕜 M₁]
[SeminormedAddCommGroup M₂] [NormedSpace 𝕜 M₂]
[SeminormedAddCommGroup M₃] [NormedSpace 𝕜 M₃]
[SeminormedAddCommGroup M₄] [NormedSpace 𝕜 M₄]
/-- `ContinuousLinearMap.prodMap` as a continuous linear map. -/
def prodMapL : (M₁ →L[𝕜] M₂) × (M₃ →L[𝕜] M₄) →L[𝕜] M₁ × M₃ →L[𝕜] M₂ × M₄ :=
ContinuousLinearMap.copy
(have Φ₁ : (M₁ →L[𝕜] M₂) →L[𝕜] M₁ →L[𝕜] M₂ × M₄ :=
ContinuousLinearMap.compL 𝕜 M₁ M₂ (M₂ × M₄) (ContinuousLinearMap.inl 𝕜 M₂ M₄)
have Φ₂ : (M₃ →L[𝕜] M₄) →L[𝕜] M₃ →L[𝕜] M₂ × M₄ :=
ContinuousLinearMap.compL 𝕜 M₃ M₄ (M₂ × M₄) (ContinuousLinearMap.inr 𝕜 M₂ M₄)
have Φ₁' :=
(ContinuousLinearMap.compL 𝕜 (M₁ × M₃) M₁ (M₂ × M₄)).flip (ContinuousLinearMap.fst 𝕜 M₁ M₃)
have Φ₂' :=
(ContinuousLinearMap.compL 𝕜 (M₁ × M₃) M₃ (M₂ × M₄)).flip (ContinuousLinearMap.snd 𝕜 M₁ M₃)
have Ψ₁ : (M₁ →L[𝕜] M₂) × (M₃ →L[𝕜] M₄) →L[𝕜] M₁ →L[𝕜] M₂ :=
ContinuousLinearMap.fst 𝕜 (M₁ →L[𝕜] M₂) (M₃ →L[𝕜] M₄)
have Ψ₂ : (M₁ →L[𝕜] M₂) × (M₃ →L[𝕜] M₄) →L[𝕜] M₃ →L[𝕜] M₄ :=
ContinuousLinearMap.snd 𝕜 (M₁ →L[𝕜] M₂) (M₃ →L[𝕜] M₄)
Φ₁' ∘L Φ₁ ∘L Ψ₁ + Φ₂' ∘L Φ₂ ∘L Ψ₂)
(fun p : (M₁ →L[𝕜] M₂) × (M₃ →L[𝕜] M₄) => p.1.prodMap p.2) (by
apply funext
rintro ⟨φ, ψ⟩
refine ContinuousLinearMap.ext fun ⟨x₁, x₂⟩ => ?_
dsimp
simp)
variable {M₁ M₂ M₃ M₄}
@[simp]
theorem prodMapL_apply (p : (M₁ →L[𝕜] M₂) × (M₃ →L[𝕜] M₄)) :
ContinuousLinearMap.prodMapL 𝕜 M₁ M₂ M₃ M₄ p = p.1.prodMap p.2 :=
rfl
variable {X : Type*} [TopologicalSpace X]
theorem _root_.Continuous.prod_mapL {f : X → M₁ →L[𝕜] M₂} {g : X → M₃ →L[𝕜] M₄} (hf : Continuous f)
(hg : Continuous g) : Continuous fun x => (f x).prodMap (g x) :=
(prodMapL 𝕜 M₁ M₂ M₃ M₄).continuous.comp (hf.prod_mk hg)
theorem _root_.Continuous.prod_map_equivL {f : X → M₁ ≃L[𝕜] M₂} {g : X → M₃ ≃L[𝕜] M₄}
(hf : Continuous fun x => (f x : M₁ →L[𝕜] M₂)) (hg : Continuous fun x => (g x : M₃ →L[𝕜] M₄)) :
Continuous fun x => ((f x).prod (g x) : M₁ × M₃ →L[𝕜] M₂ × M₄) :=
(prodMapL 𝕜 M₁ M₂ M₃ M₄).continuous.comp (hf.prod_mk hg)
theorem _root_.ContinuousOn.prod_mapL {f : X → M₁ →L[𝕜] M₂} {g : X → M₃ →L[𝕜] M₄} {s : Set X}
(hf : ContinuousOn f s) (hg : ContinuousOn g s) :
ContinuousOn (fun x => (f x).prodMap (g x)) s :=
((prodMapL 𝕜 M₁ M₂ M₃ M₄).continuous.comp_continuousOn (hf.prod hg) : _)
theorem _root_.ContinuousOn.prod_map_equivL {f : X → M₁ ≃L[𝕜] M₂} {g : X → M₃ ≃L[𝕜] M₄} {s : Set X}
(hf : ContinuousOn (fun x => (f x : M₁ →L[𝕜] M₂)) s)
(hg : ContinuousOn (fun x => (g x : M₃ →L[𝕜] M₄)) s) :
ContinuousOn (fun x => ((f x).prod (g x) : M₁ × M₃ →L[𝕜] M₂ × M₄)) s :=
(prodMapL 𝕜 M₁ M₂ M₃ M₄).continuous.comp_continuousOn (hf.prod hg)
end Prod
end ContinuousLinearMap
end SemiNormed
section Normed
namespace ContinuousLinearMap
section FirstSecond
variable (𝕜 E F)
/-- The operator norm of the first projection `E × F → E` is exactly 1 if `E` is nontrivial. -/
@[simp] lemma norm_fst [NormedAddCommGroup E] [NormedSpace 𝕜 E]
[SeminormedAddCommGroup F] [NormedSpace 𝕜 F] [Nontrivial E] :
‖fst 𝕜 E F‖ = 1 := by
refine le_antisymm (norm_fst_le ..) ?_
let ⟨e, he⟩ := exists_ne (0 : E)
have : ‖e‖ ≤ _ * max ‖e‖ ‖(0 : F)‖ := (fst 𝕜 E F).le_opNorm (e, 0)
rw [norm_zero, max_eq_left (norm_nonneg e)] at this
rwa [← mul_le_mul_iff_of_pos_right (norm_pos_iff.mpr he), one_mul]
/-- The operator norm of the second projection `E × F → F` is exactly 1 if `F` is nontrivial. -/
@[simp] lemma norm_snd [SeminormedAddCommGroup E] [NormedSpace 𝕜 E]
[NormedAddCommGroup F] [NormedSpace 𝕜 F] [Nontrivial F] :
‖snd 𝕜 E F‖ = 1 := by
refine le_antisymm (norm_snd_le ..) ?_
let ⟨f, hf⟩ := exists_ne (0 : F)
have : ‖f‖ ≤ _ * max ‖(0 : E)‖ ‖f‖ := (snd 𝕜 E F).le_opNorm (0, f)
rw [norm_zero, max_eq_right (norm_nonneg f)] at this
rwa [← mul_le_mul_iff_of_pos_right (norm_pos_iff.mpr hf), one_mul]
end FirstSecond
end ContinuousLinearMap
end Normed
|
Analysis\NormedSpace\PiTensorProduct\InjectiveSeminorm.lean | /-
Copyright (c) 2024 Sophie Morel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sophie Morel
-/
import Mathlib.Analysis.NormedSpace.PiTensorProduct.ProjectiveSeminorm
import Mathlib.LinearAlgebra.Isomorphisms
/-!
# Injective seminorm on the tensor of a finite family of normed spaces.
Let `𝕜` be a nontrivially normed field and `E` be a family of normed `𝕜`-vector spaces `Eᵢ`,
indexed by a finite type `ι`. We define a seminorm on `⨂[𝕜] i, Eᵢ`, which we call the
"injective seminorm". It is chosen to satisfy the following property: for every
normed `𝕜`-vector space `F`, the linear equivalence
`MultilinearMap 𝕜 E F ≃ₗ[𝕜] (⨂[𝕜] i, Eᵢ) →ₗ[𝕜] F`
expressing the universal property of the tensor product induces an isometric linear equivalence
`ContinuousMultilinearMap 𝕜 E F ≃ₗᵢ[𝕜] (⨂[𝕜] i, Eᵢ) →L[𝕜] F`.
The idea is the following: Every normed `𝕜`-vector space `F` defines a linear map
from `⨂[𝕜] i, Eᵢ` to `ContinuousMultilinearMap 𝕜 E F →ₗ[𝕜] F`, which sends `x` to the map
`f ↦ f.lift x`. Thanks to `PiTensorProduct.norm_eval_le_projectiveSeminorm`, this map lands in
`ContinuousMultilinearMap 𝕜 E F →L[𝕜] F`. As this last space has a natural operator (semi)norm,
we get an induced seminorm on `⨂[𝕜] i, Eᵢ`, which, by
`PiTensorProduct.norm_eval_le_projectiveSeminorm`, is bounded above by the projective seminorm
`PiTensorProduct.projectiveSeminorm`. We then take the `sup` of these seminorms as `F` varies;
as this family of seminorms is bounded, its `sup` has good properties.
In fact, we cannot take the `sup` over all normed spaces `F` because of set-theoretical issues,
so we only take spaces `F` in the same universe as `⨂[𝕜] i, Eᵢ`. We prove in
`norm_eval_le_injectiveSeminorm` that this gives the same result, because every multilinear map
from `E = Πᵢ Eᵢ` to `F` factors though a normed vector space in the same universe as
`⨂[𝕜] i, Eᵢ`.
We then prove the universal property and the functoriality of `⨂[𝕜] i, Eᵢ` as a normed vector
space.
## Main definitions
* `PiTensorProduct.toDualContinuousMultilinearMap`: The `𝕜`-linear map from
`⨂[𝕜] i, Eᵢ` to `ContinuousMultilinearMap 𝕜 E F →L[𝕜] F` sending `x` to the map
`f ↦ f x`.
* `PiTensorProduct.injectiveSeminorm`: The injective seminorm on `⨂[𝕜] i, Eᵢ`.
* `PiTensorProduct.liftEquiv`: The bijection between `ContinuousMultilinearMap 𝕜 E F`
and `(⨂[𝕜] i, Eᵢ) →L[𝕜] F`, as a continuous linear equivalence.
* `PiTensorProduct.liftIsometry`: The bijection between `ContinuousMultilinearMap 𝕜 E F`
and `(⨂[𝕜] i, Eᵢ) →L[𝕜] F`, as an isometric linear equivalence.
* `PiTensorProduct.tprodL`: The canonical continuous multilinear map from `E = Πᵢ Eᵢ`
to `⨂[𝕜] i, Eᵢ`.
* `PiTensorProduct.mapL`: The continuous linear map from `⨂[𝕜] i, Eᵢ` to `⨂[𝕜] i, E'ᵢ`
induced by a family of continuous linear maps `Eᵢ →L[𝕜] E'ᵢ`.
* `PiTensorProduct.mapLMultilinear`: The continuous multilinear map from
`Πᵢ (Eᵢ →L[𝕜] E'ᵢ)` to `(⨂[𝕜] i, Eᵢ) →L[𝕜] (⨂[𝕜] i, E'ᵢ)` sending a family
`f` to `PiTensorProduct.mapL f`.
## Main results
* `PiTensorProduct.norm_eval_le_injectiveSeminorm`: The main property of the injective seminorm
on `⨂[𝕜] i, Eᵢ`: for every `x` in `⨂[𝕜] i, Eᵢ` and every continuous multilinear map `f` from
`E = Πᵢ Eᵢ` to a normed space `F`, we have `‖f.lift x‖ ≤ ‖f‖ * injectiveSeminorm x `.
* `PiTensorProduct.mapL_opNorm`: If `f` is a family of continuous linear maps
`fᵢ : Eᵢ →L[𝕜] Fᵢ`, then `‖PiTensorProduct.mapL f‖ ≤ ∏ i, ‖fᵢ‖`.
* `PiTensorProduct.mapLMultilinear_opNorm` : If `F` is a normed vecteor space, then
`‖mapLMultilinear 𝕜 E F‖ ≤ 1`.
## TODO
* If all `Eᵢ` are separated and satisfy `SeparatingDual`, then the seminorm on
`⨂[𝕜] i, Eᵢ` is a norm. This uses the construction of a basis of the `PiTensorProduct`, hence
depends on PR #11156. It should probably go in a separate file.
* Adapt the remaining functoriality constructions/properties from `PiTensorProduct`.
-/
universe uι u𝕜 uE uF
variable {ι : Type uι} [Fintype ι]
variable {𝕜 : Type u𝕜} [NontriviallyNormedField 𝕜]
variable {E : ι → Type uE} [∀ i, SeminormedAddCommGroup (E i)] [∀ i, NormedSpace 𝕜 (E i)]
variable {F : Type uF} [SeminormedAddCommGroup F] [NormedSpace 𝕜 F]
open scoped TensorProduct
namespace PiTensorProduct
section seminorm
variable (F) in
/-- The linear map from `⨂[𝕜] i, Eᵢ` to `ContinuousMultilinearMap 𝕜 E F →L[𝕜] F` sending
`x` in `⨂[𝕜] i, Eᵢ` to the map `f ↦ f.lift x`.
-/
@[simps!]
noncomputable def toDualContinuousMultilinearMap : (⨂[𝕜] i, E i) →ₗ[𝕜]
ContinuousMultilinearMap 𝕜 E F →L[𝕜] F where
toFun x := LinearMap.mkContinuous
((LinearMap.flip (lift (R := 𝕜) (s := E) (E := F)).toLinearMap x) ∘ₗ
ContinuousMultilinearMap.toMultilinearMapLinear)
(projectiveSeminorm x)
(fun _ ↦ by simp only [LinearMap.coe_comp, Function.comp_apply,
ContinuousMultilinearMap.toMultilinearMapLinear_apply, LinearMap.flip_apply,
LinearEquiv.coe_coe]
exact norm_eval_le_projectiveSeminorm _ _ _)
map_add' x y := by
ext _
simp only [map_add, LinearMap.mkContinuous_apply, LinearMap.coe_comp, Function.comp_apply,
ContinuousMultilinearMap.toMultilinearMapLinear_apply, LinearMap.add_apply,
LinearMap.flip_apply, LinearEquiv.coe_coe, ContinuousLinearMap.add_apply]
map_smul' a x := by
ext _
simp only [map_smul, LinearMap.mkContinuous_apply, LinearMap.coe_comp, Function.comp_apply,
ContinuousMultilinearMap.toMultilinearMapLinear_apply, LinearMap.smul_apply,
LinearMap.flip_apply, LinearEquiv.coe_coe, RingHom.id_apply, ContinuousLinearMap.coe_smul',
Pi.smul_apply]
theorem toDualContinuousMultilinearMap_le_projectiveSeminorm (x : ⨂[𝕜] i, E i) :
‖toDualContinuousMultilinearMap F x‖ ≤ projectiveSeminorm x := by
simp only [toDualContinuousMultilinearMap, LinearMap.coe_mk, AddHom.coe_mk]
apply LinearMap.mkContinuous_norm_le _ (apply_nonneg _ _)
/-- The injective seminorm on `⨂[𝕜] i, Eᵢ`. Morally, it sends `x` in `⨂[𝕜] i, Eᵢ` to the
`sup` of the operator norms of the `PiTensorProduct.toDualContinuousMultilinearMap F x`, for all
normed vector spaces `F`. In fact, we only take in the same universe as `⨂[𝕜] i, Eᵢ`, and then
prove in `PiTensorProduct.norm_eval_le_injectiveSeminorm` that this gives the same result.
-/
noncomputable irreducible_def injectiveSeminorm : Seminorm 𝕜 (⨂[𝕜] i, E i) :=
sSup {p | ∃ (G : Type (max uι u𝕜 uE)) (_ : SeminormedAddCommGroup G)
(_ : NormedSpace 𝕜 G), p = Seminorm.comp (normSeminorm 𝕜 (ContinuousMultilinearMap 𝕜 E G →L[𝕜] G))
(toDualContinuousMultilinearMap G (𝕜 := 𝕜) (E := E))}
lemma dualSeminorms_bounded : BddAbove {p | ∃ (G : Type (max uι u𝕜 uE))
(_ : SeminormedAddCommGroup G) (_ : NormedSpace 𝕜 G),
p = Seminorm.comp (normSeminorm 𝕜 (ContinuousMultilinearMap 𝕜 E G →L[𝕜] G))
(toDualContinuousMultilinearMap G (𝕜 := 𝕜) (E := E))} := by
existsi projectiveSeminorm
rw [mem_upperBounds]
simp only [Set.mem_setOf_eq, forall_exists_index]
intro p G _ _ hp
rw [hp]
intro x
simp only [Seminorm.comp_apply, coe_normSeminorm]
exact toDualContinuousMultilinearMap_le_projectiveSeminorm _
theorem injectiveSeminorm_apply (x : ⨂[𝕜] i, E i) :
injectiveSeminorm x = ⨆ p : {p | ∃ (G : Type (max uι u𝕜 uE))
(_ : SeminormedAddCommGroup G) (_ : NormedSpace 𝕜 G), p = Seminorm.comp (normSeminorm 𝕜
(ContinuousMultilinearMap 𝕜 E G →L[𝕜] G))
(toDualContinuousMultilinearMap G (𝕜 := 𝕜) (E := E))}, p.1 x := by
simpa only [injectiveSeminorm, Set.coe_setOf, Set.mem_setOf_eq]
using Seminorm.sSup_apply dualSeminorms_bounded
theorem norm_eval_le_injectiveSeminorm (f : ContinuousMultilinearMap 𝕜 E F) (x : ⨂[𝕜] i, E i) :
‖lift f.toMultilinearMap x‖ ≤ ‖f‖ * injectiveSeminorm x := by
/- If `F` were in `Type (max uι u𝕜 uE)` (which is the type of `⨂[𝕜] i, E i`), then the
property that we want to prove would hold by definition of `injectiveSeminorm`. This is
not necessarily true, but we will show that there exists a normed vector space `G` in
`Type (max uι u𝕜 uE)` and an injective isometry from `G` to `F` such that `f` factors
through a continuous multilinear map `f'` from `E = Π i, E i` to `G`, to which we can apply
the definition of `injectiveSeminorm`. The desired inequality for `f` then follows
immediately.
The idea is very simple: the multilinear map `f` corresponds by `PiTensorProduct.lift`
to a linear map from `⨂[𝕜] i, E i` to `F`, say `l`. We want to take `G` to be the image of
`l`, with the norm induced from that of `F`; to make sure that we are in the correct universe,
it is actually more convenient to take `G` equal to the coimage of `l` (i.e. the quotient
of `⨂[𝕜] i, E i` by the kernel of `l`), which is canonically isomorphic to its image by
`LinearMap.quotKerEquivRange`. -/
set G := (⨂[𝕜] i, E i) ⧸ LinearMap.ker (lift f.toMultilinearMap)
set G' := LinearMap.range (lift f.toMultilinearMap)
set e := LinearMap.quotKerEquivRange (lift f.toMultilinearMap)
letI := SeminormedAddCommGroup.induced G G' e
letI := NormedSpace.induced 𝕜 G G' e
set f'₀ := lift.symm (e.symm.toLinearMap ∘ₗ LinearMap.rangeRestrict (lift f.toMultilinearMap))
have hf'₀ : ∀ (x : Π (i : ι), E i), ‖f'₀ x‖ ≤ ‖f‖ * ∏ i, ‖x i‖ := fun x ↦ by
change ‖e (f'₀ x)‖ ≤ _
simp only [lift_symm, LinearMap.compMultilinearMap_apply, LinearMap.coe_comp,
LinearEquiv.coe_coe, Function.comp_apply, LinearEquiv.apply_symm_apply, Submodule.coe_norm,
LinearMap.codRestrict_apply, lift.tprod, ContinuousMultilinearMap.coe_coe, e, f'₀]
exact f.le_opNorm x
set f' := MultilinearMap.mkContinuous f'₀ ‖f‖ hf'₀
have hnorm : ‖f'‖ ≤ ‖f‖ := (f'.opNorm_le_iff (norm_nonneg f)).mpr hf'₀
have heq : e (lift f'.toMultilinearMap x) = lift f.toMultilinearMap x := by
induction' x using PiTensorProduct.induction_on with a m _ _ hx hy
· simp only [lift_symm, map_smul, lift.tprod, ContinuousMultilinearMap.coe_coe,
MultilinearMap.coe_mkContinuous, LinearMap.compMultilinearMap_apply, LinearMap.coe_comp,
LinearEquiv.coe_coe, Function.comp_apply, LinearEquiv.apply_symm_apply, SetLike.val_smul,
LinearMap.codRestrict_apply, f', f'₀]
· simp only [map_add, AddSubmonoid.coe_add, Submodule.coe_toAddSubmonoid, hx, hy]
suffices h : ‖lift f'.toMultilinearMap x‖ ≤ ‖f'‖ * injectiveSeminorm x by
change ‖(e (lift f'.toMultilinearMap x)).1‖ ≤ _ at h
rw [heq] at h
exact le_trans h (mul_le_mul_of_nonneg_right hnorm (apply_nonneg _ _))
have hle : Seminorm.comp (normSeminorm 𝕜 (ContinuousMultilinearMap 𝕜 E G →L[𝕜] G))
(toDualContinuousMultilinearMap G (𝕜 := 𝕜) (E := E)) ≤ injectiveSeminorm := by
simp only [injectiveSeminorm]
refine le_csSup dualSeminorms_bounded ?_
rw [Set.mem_setOf]
existsi G, inferInstance, inferInstance
rfl
refine le_trans ?_ (mul_le_mul_of_nonneg_left (hle x) (norm_nonneg f'))
simp only [Seminorm.comp_apply, coe_normSeminorm, ← toDualContinuousMultilinearMap_apply_apply]
rw [mul_comm]
exact ContinuousLinearMap.le_opNorm _ _
theorem injectiveSeminorm_le_projectiveSeminorm :
injectiveSeminorm (𝕜 := 𝕜) (E := E) ≤ projectiveSeminorm := by
rw [injectiveSeminorm]
refine csSup_le ?_ ?_
· existsi 0
simp only [Set.mem_setOf_eq]
existsi PUnit, inferInstance, inferInstance
ext x
simp only [Seminorm.zero_apply, Seminorm.comp_apply, coe_normSeminorm]
have heq : toDualContinuousMultilinearMap PUnit x = 0 := by ext _
rw [heq, norm_zero]
· intro p hp
simp only [Set.mem_setOf_eq] at hp
obtain ⟨G, _, _, h⟩ := hp
rw [h]; intro x; simp only [Seminorm.comp_apply, coe_normSeminorm]
exact toDualContinuousMultilinearMap_le_projectiveSeminorm _
theorem injectiveSeminorm_tprod_le (m : Π (i : ι), E i) :
injectiveSeminorm (⨂ₜ[𝕜] i, m i) ≤ ∏ i, ‖m i‖ :=
le_trans (injectiveSeminorm_le_projectiveSeminorm _) (projectiveSeminorm_tprod_le m)
noncomputable instance : SeminormedAddCommGroup (⨂[𝕜] i, E i) :=
AddGroupSeminorm.toSeminormedAddCommGroup injectiveSeminorm.toAddGroupSeminorm
noncomputable instance : NormedSpace 𝕜 (⨂[𝕜] i, E i) where
norm_smul_le a x := by
change injectiveSeminorm.toFun (a • x) ≤ _
rw [injectiveSeminorm.smul']
rfl
variable (𝕜 E F)
/-- The linear equivalence between `ContinuousMultilinearMap 𝕜 E F` and `(⨂[𝕜] i, Eᵢ) →L[𝕜] F`
induced by `PiTensorProduct.lift`, for every normed space `F`.
-/
@[simps]
noncomputable def liftEquiv : ContinuousMultilinearMap 𝕜 E F ≃ₗ[𝕜] (⨂[𝕜] i, E i) →L[𝕜] F where
toFun f := LinearMap.mkContinuous (lift f.toMultilinearMap) ‖f‖
(fun x ↦ norm_eval_le_injectiveSeminorm f x)
map_add' f g := by ext _; simp only [ContinuousMultilinearMap.toMultilinearMap_add, map_add,
LinearMap.mkContinuous_apply, LinearMap.add_apply, ContinuousLinearMap.add_apply]
map_smul' a f := by ext _; simp only [ContinuousMultilinearMap.toMultilinearMap_smul, map_smul,
LinearMap.mkContinuous_apply, LinearMap.smul_apply, RingHom.id_apply,
ContinuousLinearMap.coe_smul', Pi.smul_apply]
invFun l := MultilinearMap.mkContinuous (lift.symm l.toLinearMap) ‖l‖ (fun x ↦ by
simp only [lift_symm, LinearMap.compMultilinearMap_apply, ContinuousLinearMap.coe_coe]
refine le_trans (ContinuousLinearMap.le_opNorm _ _) (mul_le_mul_of_nonneg_left ?_
(norm_nonneg l))
exact injectiveSeminorm_tprod_le x)
left_inv f := by ext x; simp only [LinearMap.mkContinuous_coe, LinearEquiv.symm_apply_apply,
MultilinearMap.coe_mkContinuous, ContinuousMultilinearMap.coe_coe]
right_inv l := by
rw [← ContinuousLinearMap.coe_inj]
apply PiTensorProduct.ext; ext m
simp only [lift_symm, LinearMap.mkContinuous_coe, LinearMap.compMultilinearMap_apply,
lift.tprod, ContinuousMultilinearMap.coe_coe, MultilinearMap.coe_mkContinuous,
ContinuousLinearMap.coe_coe]
/-- For a normed space `F`, we have constructed in `PiTensorProduct.liftEquiv` the canonical
linear equivalence between `ContinuousMultilinearMap 𝕜 E F` and `(⨂[𝕜] i, Eᵢ) →L[𝕜] F`
(induced by `PiTensorProduct.lift`). Here we give the upgrade of this equivalence to
an isometric linear equivalence; in particular, it is a continuous linear equivalence.
-/
noncomputable def liftIsometry : ContinuousMultilinearMap 𝕜 E F ≃ₗᵢ[𝕜] (⨂[𝕜] i, E i) →L[𝕜] F :=
{ liftEquiv 𝕜 E F with
norm_map' := by
intro f
refine le_antisymm ?_ ?_
· simp only [liftEquiv, lift_symm, LinearEquiv.coe_mk]
exact LinearMap.mkContinuous_norm_le _ (norm_nonneg f) _
· conv_lhs => rw [← (liftEquiv 𝕜 E F).left_inv f]
simp only [liftEquiv, lift_symm, AddHom.toFun_eq_coe, AddHom.coe_mk,
LinearEquiv.invFun_eq_symm, LinearEquiv.coe_symm_mk, LinearMap.mkContinuous_coe,
LinearEquiv.coe_mk]
exact MultilinearMap.mkContinuous_norm_le _ (norm_nonneg _) _ }
variable {𝕜 E F}
@[simp]
theorem liftIsometry_apply_apply (f : ContinuousMultilinearMap 𝕜 E F) (x : ⨂[𝕜] i, E i) :
liftIsometry 𝕜 E F f x = lift f.toMultilinearMap x := by
simp only [liftIsometry, LinearIsometryEquiv.coe_mk, liftEquiv_apply,
LinearMap.mkContinuous_apply]
variable (𝕜)
/-- The canonical continuous multilinear map from `E = Πᵢ Eᵢ` to `⨂[𝕜] i, Eᵢ`.
-/
@[simps!]
noncomputable def tprodL : ContinuousMultilinearMap 𝕜 E (⨂[𝕜] i, E i) :=
(liftIsometry 𝕜 E _).symm (ContinuousLinearMap.id 𝕜 _)
variable {𝕜}
@[simp]
theorem tprodL_coe : (tprodL 𝕜).toMultilinearMap = tprod 𝕜 (s := E) := by
ext m
simp only [ContinuousMultilinearMap.coe_coe, tprodL_toFun]
@[simp]
theorem liftIsometry_symm_apply (l : (⨂[𝕜] i, E i) →L[𝕜] F) :
(liftIsometry 𝕜 E F).symm l = l.compContinuousMultilinearMap (tprodL 𝕜) := by
ext m
change (liftEquiv 𝕜 E F).symm l m = _
simp only [liftEquiv_symm_apply, lift_symm, MultilinearMap.coe_mkContinuous,
LinearMap.compMultilinearMap_apply, ContinuousLinearMap.coe_coe,
ContinuousLinearMap.compContinuousMultilinearMap_coe, Function.comp_apply, tprodL_toFun]
@[simp]
theorem liftIsometry_tprodL :
liftIsometry 𝕜 E _ (tprodL 𝕜) = ContinuousLinearMap.id 𝕜 (⨂[𝕜] i, E i) := by
ext _
simp only [liftIsometry_apply_apply, tprodL_coe, lift_tprod, LinearMap.id_coe, id_eq,
ContinuousLinearMap.coe_id']
end seminorm
section map
variable {E' E'' : ι → Type*}
variable [∀ i, SeminormedAddCommGroup (E' i)] [∀ i, NormedSpace 𝕜 (E' i)]
variable [∀ i, SeminormedAddCommGroup (E'' i)] [∀ i, NormedSpace 𝕜 (E'' i)]
variable (g : Π i, E' i →L[𝕜] E'' i) (f : Π i, E i →L[𝕜] E' i)
/--
Let `Eᵢ` and `E'ᵢ` be two families of normed `𝕜`-vector spaces.
Let `f` be a family of continuous `𝕜`-linear maps between `Eᵢ` and `E'ᵢ`, i.e.
`f : Πᵢ Eᵢ →L[𝕜] E'ᵢ`, then there is an induced continuous linear map
`⨂ᵢ Eᵢ → ⨂ᵢ E'ᵢ` by `⨂ aᵢ ↦ ⨂ fᵢ aᵢ`.
-/
noncomputable def mapL : (⨂[𝕜] i, E i) →L[𝕜] ⨂[𝕜] i, E' i :=
liftIsometry 𝕜 E _ <| (tprodL 𝕜).compContinuousLinearMap f
@[simp]
theorem mapL_coe : (mapL f).toLinearMap = map (fun i ↦ (f i).toLinearMap) := by
ext
simp only [mapL, LinearMap.compMultilinearMap_apply, ContinuousLinearMap.coe_coe,
liftIsometry_apply_apply, lift.tprod, ContinuousMultilinearMap.coe_coe,
ContinuousMultilinearMap.compContinuousLinearMap_apply, tprodL_toFun, map_tprod]
@[simp]
theorem mapL_apply (x : ⨂[𝕜] i, E i) : mapL f x = map (fun i ↦ (f i).toLinearMap) x := by
induction' x using PiTensorProduct.induction_on with _ _ _ _ hx hy
· simp only [mapL, map_smul, liftIsometry_apply_apply, lift.tprod,
ContinuousMultilinearMap.coe_coe, ContinuousMultilinearMap.compContinuousLinearMap_apply,
tprodL_toFun, map_tprod, ContinuousLinearMap.coe_coe]
· simp only [map_add, hx, hy]
/-- Given submodules `pᵢ ⊆ Eᵢ`, this is the natural map: `⨂[𝕜] i, pᵢ → ⨂[𝕜] i, Eᵢ`.
This is the continuous version of `PiTensorProduct.mapIncl`.
-/
@[simp]
noncomputable def mapLIncl (p : Π i, Submodule 𝕜 (E i)) : (⨂[𝕜] i, p i) →L[𝕜] ⨂[𝕜] i, E i :=
mapL fun (i : ι) ↦ (p i).subtypeL
theorem mapL_comp : mapL (fun (i : ι) ↦ g i ∘L f i) = mapL g ∘L mapL f := by
apply ContinuousLinearMap.coe_injective
ext
simp only [mapL_coe, ContinuousLinearMap.coe_comp, LinearMap.compMultilinearMap_apply, map_tprod,
LinearMap.coe_comp, ContinuousLinearMap.coe_coe, Function.comp_apply]
theorem liftIsometry_comp_mapL (h : ContinuousMultilinearMap 𝕜 E' F) :
liftIsometry 𝕜 E' F h ∘L mapL f = liftIsometry 𝕜 E F (h.compContinuousLinearMap f) := by
apply ContinuousLinearMap.coe_injective
ext
simp only [ContinuousLinearMap.coe_comp, mapL_coe, LinearMap.compMultilinearMap_apply,
LinearMap.coe_comp, ContinuousLinearMap.coe_coe, Function.comp_apply, map_tprod,
liftIsometry_apply_apply, lift.tprod, ContinuousMultilinearMap.coe_coe,
ContinuousMultilinearMap.compContinuousLinearMap_apply]
@[simp]
theorem mapL_id : mapL (fun i ↦ ContinuousLinearMap.id 𝕜 (E i)) = ContinuousLinearMap.id _ _ := by
apply ContinuousLinearMap.coe_injective
ext
simp only [mapL_coe, ContinuousLinearMap.coe_id, map_id, LinearMap.compMultilinearMap_apply,
LinearMap.id_coe, id_eq]
@[simp]
theorem mapL_one : mapL (fun (i : ι) ↦ (1 : E i →L[𝕜] E i)) = 1 :=
mapL_id
theorem mapL_mul (f₁ f₂ : Π i, E i →L[𝕜] E i) :
mapL (fun i ↦ f₁ i * f₂ i) = mapL f₁ * mapL f₂ :=
mapL_comp f₁ f₂
/-- Upgrading `PiTensorProduct.mapL` to a `MonoidHom` when `E = E'`. -/
@[simps]
noncomputable def mapLMonoidHom : (Π i, E i →L[𝕜] E i) →* ((⨂[𝕜] i, E i) →L[𝕜] ⨂[𝕜] i, E i) where
toFun := mapL
map_one' := mapL_one
map_mul' := mapL_mul
@[simp]
protected theorem mapL_pow (f : Π i, E i →L[𝕜] E i) (n : ℕ) :
mapL (f ^ n) = mapL f ^ n := MonoidHom.map_pow mapLMonoidHom _ _
open Function in
private theorem mapL_add_smul_aux [DecidableEq ι] (i : ι) (u : E i →L[𝕜] E' i) :
(fun j ↦ (update f i u j).toLinearMap) =
update (fun j ↦ (f j).toLinearMap) i u.toLinearMap := by
symm
rw [update_eq_iff]
constructor
· simp only [update_same]
· exact fun _ h ↦ by simp only [ne_eq, h, not_false_eq_true, update_noteq]
open Function in
protected theorem mapL_add [DecidableEq ι] (i : ι) (u v : E i →L[𝕜] E' i) :
mapL (update f i (u + v)) = mapL (update f i u) + mapL (update f i v) := by
ext x
simp only [mapL_apply, mapL_add_smul_aux, ContinuousLinearMap.coe_add, PiTensorProduct.map_add,
LinearMap.add_apply, ContinuousLinearMap.add_apply]
open Function in
protected theorem mapL_smul [DecidableEq ι] (i : ι) (c : 𝕜) (u : E i →L[𝕜] E' i) :
mapL (update f i (c • u)) = c • mapL (update f i u) := by
ext x
simp only [mapL_apply, mapL_add_smul_aux, ContinuousLinearMap.coe_smul, PiTensorProduct.map_smul,
LinearMap.smul_apply, ContinuousLinearMap.coe_smul', Pi.smul_apply]
theorem mapL_opNorm : ‖mapL f‖ ≤ ∏ i, ‖f i‖ := by
rw [ContinuousLinearMap.opNorm_le_iff (Finset.prod_nonneg (fun _ _ ↦ norm_nonneg _))]
intro x
rw [mapL, liftIsometry]
simp only [LinearIsometryEquiv.coe_mk, liftEquiv_apply, LinearMap.mkContinuous_apply]
refine le_trans (norm_eval_le_injectiveSeminorm _ _)
(mul_le_mul_of_nonneg_right ?_ (norm_nonneg x))
rw [ContinuousMultilinearMap.opNorm_le_iff _ (Finset.prod_nonneg (fun _ _ ↦ norm_nonneg _))]
intro m
simp only [ContinuousMultilinearMap.compContinuousLinearMap_apply]
refine le_trans (injectiveSeminorm_tprod_le (fun i ↦ (f i) (m i))) ?_
rw [← Finset.prod_mul_distrib]
exact Finset.prod_le_prod (fun _ _ ↦ norm_nonneg _) (fun _ _ ↦ ContinuousLinearMap.le_opNorm _ _ )
variable (𝕜 E E')
/-- The tensor of a family of linear maps from `Eᵢ` to `E'ᵢ`, as a continuous multilinear map of
the family.
-/
@[simps!]
noncomputable def mapLMultilinear : ContinuousMultilinearMap 𝕜 (fun (i : ι) ↦ E i →L[𝕜] E' i)
((⨂[𝕜] i, E i) →L[𝕜] ⨂[𝕜] i, E' i) :=
MultilinearMap.mkContinuous
{ toFun := mapL
map_smul' := fun _ _ _ _ ↦ PiTensorProduct.mapL_smul _ _ _ _
map_add' := fun _ _ _ _ ↦ PiTensorProduct.mapL_add _ _ _ _ }
1 (fun f ↦ by rw [one_mul]; exact mapL_opNorm f)
variable {𝕜 E E'}
theorem mapLMultilinear_opNorm : ‖mapLMultilinear 𝕜 E E'‖ ≤ 1 :=
MultilinearMap.mkContinuous_norm_le _ zero_le_one _
end map
end PiTensorProduct
|
Analysis\NormedSpace\PiTensorProduct\ProjectiveSeminorm.lean | /-
Copyright (c) 2024 Sophie Morel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sophie Morel
-/
import Mathlib.Analysis.NormedSpace.Multilinear.Basic
import Mathlib.LinearAlgebra.PiTensorProduct
/-!
# Projective seminorm on the tensor of a finite family of normed spaces.
Let `𝕜` be a nontrivially normed field and `E` be a family of normed `𝕜`-vector spaces `Eᵢ`,
indexed by a finite type `ι`. We define a seminorm on `⨂[𝕜] i, Eᵢ`, which we call the
"projective seminorm". For `x` an element of `⨂[𝕜] i, Eᵢ`, its projective seminorm is the
infimum over all expressions of `x` as `∑ j, ⨂ₜ[𝕜] mⱼ i` (with the `mⱼ` ∈ `Π i, Eᵢ`)
of `∑ j, Π i, ‖mⱼ i‖`.
In particular, every norm `‖.‖` on `⨂[𝕜] i, Eᵢ` satisfying `‖⨂ₜ[𝕜] i, m i‖ ≤ Π i, ‖m i‖`
for every `m` in `Π i, Eᵢ` is bounded above by the projective seminorm.
## Main definitions
* `PiTensorProduct.projectiveSeminorm`: The projective seminorm on `⨂[𝕜] i, Eᵢ`.
## Main results
* `PiTensorProduct.norm_eval_le_projectiveSeminorm`: If `f` is a continuous multilinear map on
`E = Π i, Eᵢ` and `x` is in `⨂[𝕜] i, Eᵢ`, then `‖f.lift x‖ ≤ projectiveSeminorm x * ‖f‖`.
## TODO
* If the base field is `ℝ` or `ℂ` (or more generally if the injection of `Eᵢ` into its bidual is
an isometry for every `i`), then we have `projectiveSeminorm ⨂ₜ[𝕜] i, mᵢ = Π i, ‖mᵢ‖`.
* The functoriality.
-/
universe uι u𝕜 uE uF
variable {ι : Type uι} [Fintype ι]
variable {𝕜 : Type u𝕜} [NontriviallyNormedField 𝕜]
variable {E : ι → Type uE} [∀ i, SeminormedAddCommGroup (E i)]
variable {F : Type uF} [SeminormedAddCommGroup F] [NormedSpace 𝕜 F]
open scoped TensorProduct
namespace PiTensorProduct
/-- A lift of the projective seminorm to `FreeAddMonoid (𝕜 × Π i, Eᵢ)`, useful to prove the
properties of `projectiveSeminorm`.
-/
def projectiveSeminormAux : FreeAddMonoid (𝕜 × Π i, E i) → ℝ :=
List.sum ∘ (List.map (fun p ↦ ‖p.1‖ * ∏ i, ‖p.2 i‖))
theorem projectiveSeminormAux_nonneg (p : FreeAddMonoid (𝕜 × Π i, E i)) :
0 ≤ projectiveSeminormAux p := by
simp only [projectiveSeminormAux, Function.comp_apply]
refine List.sum_nonneg ?_
intro a
simp only [Multiset.map_coe, Multiset.mem_coe, List.mem_map, Prod.exists, forall_exists_index,
and_imp]
intro x m _ h
rw [← h]
exact mul_nonneg (norm_nonneg _) (Finset.prod_nonneg (fun _ _ ↦ norm_nonneg _))
theorem projectiveSeminormAux_add_le (p q : FreeAddMonoid (𝕜 × Π i, E i)) :
projectiveSeminormAux (p + q) ≤ projectiveSeminormAux p + projectiveSeminormAux q := by
simp only [projectiveSeminormAux, Function.comp_apply, Multiset.map_coe, Multiset.sum_coe]
erw [List.map_append]
rw [List.sum_append]
rfl
theorem projectiveSeminormAux_smul (p : FreeAddMonoid (𝕜 × Π i, E i)) (a : 𝕜) :
projectiveSeminormAux (List.map (fun (y : 𝕜 × Π i, E i) ↦ (a * y.1, y.2)) p) =
‖a‖ * projectiveSeminormAux p := by
simp only [projectiveSeminormAux, Function.comp_apply, Multiset.map_coe, List.map_map,
Multiset.sum_coe]
rw [← smul_eq_mul, List.smul_sum, ← List.comp_map]
congr 2
ext x
simp only [Function.comp_apply, norm_mul, smul_eq_mul]
rw [mul_assoc]
variable [∀ i, NormedSpace 𝕜 (E i)]
theorem bddBelow_projectiveSemiNormAux (x : ⨂[𝕜] i, E i) :
BddBelow (Set.range (fun (p : lifts x) ↦ projectiveSeminormAux p.1)) := by
existsi 0
rw [mem_lowerBounds]
simp only [Set.mem_range, Subtype.exists, exists_prop, forall_exists_index, and_imp,
forall_apply_eq_imp_iff₂]
exact fun p _ ↦ projectiveSeminormAux_nonneg p
/-- The projective seminorm on `⨂[𝕜] i, Eᵢ`. It sends an element `x` of `⨂[𝕜] i, Eᵢ` to the
infimum over all expressions of `x` as `∑ j, ⨂ₜ[𝕜] mⱼ i` (with the `mⱼ` ∈ `Π i, Eᵢ`)
of `∑ j, Π i, ‖mⱼ i‖`.
-/
noncomputable def projectiveSeminorm : Seminorm 𝕜 (⨂[𝕜] i, E i) := by
refine Seminorm.ofSMulLE (fun x ↦ iInf (fun (p : lifts x) ↦ projectiveSeminormAux p.1)) ?_ ?_ ?_
· refine le_antisymm ?_ ?_
· refine ciInf_le_of_le (bddBelow_projectiveSemiNormAux (0 : ⨂[𝕜] i, E i)) ⟨0, lifts_zero⟩ ?_
simp only [projectiveSeminormAux, Function.comp_apply]
rw [List.sum_eq_zero]
intro _
simp only [List.mem_map, Prod.exists, forall_exists_index, and_imp]
intro _ _ hxm
rw [← FreeAddMonoid.ofList_nil] at hxm
exfalso
exact List.not_mem_nil _ hxm
· letI : Nonempty (lifts 0) := ⟨0, lifts_zero (R := 𝕜) (s := E)⟩
exact le_ciInf (fun p ↦ projectiveSeminormAux_nonneg p.1)
· intro x y
letI := nonempty_subtype.mpr (nonempty_lifts x); letI := nonempty_subtype.mpr (nonempty_lifts y)
exact le_ciInf_add_ciInf (fun p q ↦ ciInf_le_of_le (bddBelow_projectiveSemiNormAux _)
⟨p.1 + q.1, lifts_add p.2 q.2⟩ (projectiveSeminormAux_add_le p.1 q.1))
· intro a x
letI := nonempty_subtype.mpr (nonempty_lifts x)
rw [Real.mul_iInf_of_nonneg (norm_nonneg _)]
refine le_ciInf ?_
intro p
rw [← projectiveSeminormAux_smul]
exact ciInf_le_of_le (bddBelow_projectiveSemiNormAux _)
⟨(List.map (fun y ↦ (a * y.1, y.2)) p.1), lifts_smul p.2 a⟩ (le_refl _)
theorem projectiveSeminorm_apply (x : ⨂[𝕜] i, E i) :
projectiveSeminorm x = iInf (fun (p : lifts x) ↦ projectiveSeminormAux p.1) := rfl
theorem projectiveSeminorm_tprod_le (m : Π i, E i) :
projectiveSeminorm (⨂ₜ[𝕜] i, m i) ≤ ∏ i, ‖m i‖ := by
rw [projectiveSeminorm_apply]
convert ciInf_le (bddBelow_projectiveSemiNormAux _) ⟨[((1 : 𝕜), m)] ,?_⟩
· simp only [projectiveSeminormAux, Function.comp_apply, List.map_cons, norm_one, one_mul,
List.map_nil, List.sum_cons, List.sum_nil, add_zero]
· rw [mem_lifts_iff, List.map_singleton, List.sum_singleton, one_smul]
theorem norm_eval_le_projectiveSeminorm (x : ⨂[𝕜] i, E i) (G : Type*) [SeminormedAddCommGroup G]
[NormedSpace 𝕜 G] (f : ContinuousMultilinearMap 𝕜 E G) :
‖lift f.toMultilinearMap x‖ ≤ projectiveSeminorm x * ‖f‖ := by
letI := nonempty_subtype.mpr (nonempty_lifts x)
rw [projectiveSeminorm_apply, Real.iInf_mul_of_nonneg (norm_nonneg _), projectiveSeminormAux]
refine le_ciInf ?_
intro ⟨p, hp⟩
rw [mem_lifts_iff] at hp
conv_lhs => rw [← hp, ← List.sum_map_hom, ← Multiset.sum_coe]
refine le_trans (norm_multiset_sum_le _) ?_
simp only [tprodCoeff_eq_smul_tprod, Multiset.map_coe, List.map_map, Multiset.sum_coe,
Function.comp_apply]
rw [mul_comm, ← smul_eq_mul, List.smul_sum]
refine List.Forall₂.sum_le_sum ?_
simp only [smul_eq_mul, List.map_map, List.forall₂_map_right_iff, Function.comp_apply,
List.forall₂_map_left_iff, map_smul, lift.tprod, ContinuousMultilinearMap.coe_coe,
List.forall₂_same, Prod.forall]
intro a m _
rw [norm_smul, ← mul_assoc, mul_comm ‖f‖ _, mul_assoc]
exact mul_le_mul_of_nonneg_left (f.le_opNorm _) (norm_nonneg _)
end PiTensorProduct
|
Analysis\ODE\Gronwall.lean | /-
Copyright (c) 2020 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov
-/
import Mathlib.Analysis.SpecialFunctions.ExpDeriv
/-!
# Grönwall's inequality
The main technical result of this file is the Grönwall-like inequality
`norm_le_gronwallBound_of_norm_deriv_right_le`. It states that if `f : ℝ → E` satisfies `‖f a‖ ≤ δ`
and `∀ x ∈ [a, b), ‖f' x‖ ≤ K * ‖f x‖ + ε`, then for all `x ∈ [a, b]` we have `‖f x‖ ≤ δ * exp (K *
x) + (ε / K) * (exp (K * x) - 1)`.
Then we use this inequality to prove some estimates on the possible rate of growth of the distance
between two approximate or exact solutions of an ordinary differential equation.
The proofs are based on [Hubbard and West, *Differential Equations: A Dynamical Systems Approach*,
Sec. 4.5][HubbardWest-ode], where `norm_le_gronwallBound_of_norm_deriv_right_le` is called
“Fundamental Inequality”.
## TODO
- Once we have FTC, prove an inequality for a function satisfying `‖f' x‖ ≤ K x * ‖f x‖ + ε`,
or more generally `liminf_{y→x+0} (f y - f x)/(y - x) ≤ K x * f x + ε` with any sign
of `K x` and `f x`.
-/
open Metric Set Asymptotics Filter Real
open scoped Topology NNReal
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] {F : Type*} [NormedAddCommGroup F]
[NormedSpace ℝ F]
/-! ### Technical lemmas about `gronwallBound` -/
/-- Upper bound used in several Grönwall-like inequalities. -/
noncomputable def gronwallBound (δ K ε x : ℝ) : ℝ :=
if K = 0 then δ + ε * x else δ * exp (K * x) + ε / K * (exp (K * x) - 1)
theorem gronwallBound_K0 (δ ε : ℝ) : gronwallBound δ 0 ε = fun x => δ + ε * x :=
funext fun _ => if_pos rfl
theorem gronwallBound_of_K_ne_0 {δ K ε : ℝ} (hK : K ≠ 0) :
gronwallBound δ K ε = fun x => δ * exp (K * x) + ε / K * (exp (K * x) - 1) :=
funext fun _ => if_neg hK
theorem hasDerivAt_gronwallBound (δ K ε x : ℝ) :
HasDerivAt (gronwallBound δ K ε) (K * gronwallBound δ K ε x + ε) x := by
by_cases hK : K = 0
· subst K
simp only [gronwallBound_K0, zero_mul, zero_add]
convert ((hasDerivAt_id x).const_mul ε).const_add δ
rw [mul_one]
· simp only [gronwallBound_of_K_ne_0 hK]
convert (((hasDerivAt_id x).const_mul K).exp.const_mul δ).add
((((hasDerivAt_id x).const_mul K).exp.sub_const 1).const_mul (ε / K)) using 1
simp only [id, mul_add, (mul_assoc _ _ _).symm, mul_comm _ K, mul_div_cancel₀ _ hK]
ring
theorem hasDerivAt_gronwallBound_shift (δ K ε x a : ℝ) :
HasDerivAt (fun y => gronwallBound δ K ε (y - a)) (K * gronwallBound δ K ε (x - a) + ε) x := by
convert (hasDerivAt_gronwallBound δ K ε _).comp x ((hasDerivAt_id x).sub_const a) using 1
rw [id, mul_one]
theorem gronwallBound_x0 (δ K ε : ℝ) : gronwallBound δ K ε 0 = δ := by
by_cases hK : K = 0
· simp only [gronwallBound, if_pos hK, mul_zero, add_zero]
· simp only [gronwallBound, if_neg hK, mul_zero, exp_zero, sub_self, mul_one,
add_zero]
theorem gronwallBound_ε0 (δ K x : ℝ) : gronwallBound δ K 0 x = δ * exp (K * x) := by
by_cases hK : K = 0
· simp only [gronwallBound_K0, hK, zero_mul, exp_zero, add_zero, mul_one]
· simp only [gronwallBound_of_K_ne_0 hK, zero_div, zero_mul, add_zero]
theorem gronwallBound_ε0_δ0 (K x : ℝ) : gronwallBound 0 K 0 x = 0 := by
simp only [gronwallBound_ε0, zero_mul]
theorem gronwallBound_continuous_ε (δ K x : ℝ) : Continuous fun ε => gronwallBound δ K ε x := by
by_cases hK : K = 0
· simp only [gronwallBound_K0, hK]
exact continuous_const.add (continuous_id.mul continuous_const)
· simp only [gronwallBound_of_K_ne_0 hK]
exact continuous_const.add ((continuous_id.mul continuous_const).mul continuous_const)
/-! ### Inequality and corollaries -/
/-- A Grönwall-like inequality: if `f : ℝ → ℝ` is continuous on `[a, b]` and satisfies
the inequalities `f a ≤ δ` and
`∀ x ∈ [a, b), liminf_{z→x+0} (f z - f x)/(z - x) ≤ K * (f x) + ε`, then `f x`
is bounded by `gronwallBound δ K ε (x - a)` on `[a, b]`.
See also `norm_le_gronwallBound_of_norm_deriv_right_le` for a version bounding `‖f x‖`,
`f : ℝ → E`. -/
theorem le_gronwallBound_of_liminf_deriv_right_le {f f' : ℝ → ℝ} {δ K ε : ℝ} {a b : ℝ}
(hf : ContinuousOn f (Icc a b))
(hf' : ∀ x ∈ Ico a b, ∀ r, f' x < r → ∃ᶠ z in 𝓝[>] x, (z - x)⁻¹ * (f z - f x) < r)
(ha : f a ≤ δ) (bound : ∀ x ∈ Ico a b, f' x ≤ K * f x + ε) :
∀ x ∈ Icc a b, f x ≤ gronwallBound δ K ε (x - a) := by
have H : ∀ x ∈ Icc a b, ∀ ε' ∈ Ioi ε, f x ≤ gronwallBound δ K ε' (x - a) := by
intro x hx ε' hε'
apply image_le_of_liminf_slope_right_lt_deriv_boundary hf hf'
· rwa [sub_self, gronwallBound_x0]
· exact fun x => hasDerivAt_gronwallBound_shift δ K ε' x a
· intro x hx hfB
rw [← hfB]
apply lt_of_le_of_lt (bound x hx)
exact add_lt_add_left (mem_Ioi.1 hε') _
· exact hx
intro x hx
change f x ≤ (fun ε' => gronwallBound δ K ε' (x - a)) ε
convert continuousWithinAt_const.closure_le _ _ (H x hx)
· simp only [closure_Ioi, left_mem_Ici]
exact (gronwallBound_continuous_ε δ K (x - a)).continuousWithinAt
/-- A Grönwall-like inequality: if `f : ℝ → E` is continuous on `[a, b]`, has right derivative
`f' x` at every point `x ∈ [a, b)`, and satisfies the inequalities `‖f a‖ ≤ δ`,
`∀ x ∈ [a, b), ‖f' x‖ ≤ K * ‖f x‖ + ε`, then `‖f x‖` is bounded by `gronwallBound δ K ε (x - a)`
on `[a, b]`. -/
theorem norm_le_gronwallBound_of_norm_deriv_right_le {f f' : ℝ → E} {δ K ε : ℝ} {a b : ℝ}
(hf : ContinuousOn f (Icc a b)) (hf' : ∀ x ∈ Ico a b, HasDerivWithinAt f (f' x) (Ici x) x)
(ha : ‖f a‖ ≤ δ) (bound : ∀ x ∈ Ico a b, ‖f' x‖ ≤ K * ‖f x‖ + ε) :
∀ x ∈ Icc a b, ‖f x‖ ≤ gronwallBound δ K ε (x - a) :=
le_gronwallBound_of_liminf_deriv_right_le (continuous_norm.comp_continuousOn hf)
(fun x hx _r hr => (hf' x hx).liminf_right_slope_norm_le hr) ha bound
variable {v : ℝ → E → E} {s : ℝ → Set E} {K : ℝ≥0} {f g f' g' : ℝ → E} {a b t₀ : ℝ} {εf εg δ : ℝ}
(hv : ∀ t, LipschitzOnWith K (v t) (s t))
/-- If `f` and `g` are two approximate solutions of the same ODE, then the distance between them
can't grow faster than exponentially. This is a simple corollary of Grönwall's inequality, and some
people call this Grönwall's inequality too.
This version assumes all inequalities to be true in some time-dependent set `s t`,
and assumes that the solutions never leave this set. -/
theorem dist_le_of_approx_trajectories_ODE_of_mem
(hf : ContinuousOn f (Icc a b))
(hf' : ∀ t ∈ Ico a b, HasDerivWithinAt f (f' t) (Ici t) t)
(f_bound : ∀ t ∈ Ico a b, dist (f' t) (v t (f t)) ≤ εf)
(hfs : ∀ t ∈ Ico a b, f t ∈ s t)
(hg : ContinuousOn g (Icc a b))
(hg' : ∀ t ∈ Ico a b, HasDerivWithinAt g (g' t) (Ici t) t)
(g_bound : ∀ t ∈ Ico a b, dist (g' t) (v t (g t)) ≤ εg)
(hgs : ∀ t ∈ Ico a b, g t ∈ s t)
(ha : dist (f a) (g a) ≤ δ) :
∀ t ∈ Icc a b, dist (f t) (g t) ≤ gronwallBound δ K (εf + εg) (t - a) := by
simp only [dist_eq_norm] at ha ⊢
have h_deriv : ∀ t ∈ Ico a b, HasDerivWithinAt (fun t => f t - g t) (f' t - g' t) (Ici t) t :=
fun t ht => (hf' t ht).sub (hg' t ht)
apply norm_le_gronwallBound_of_norm_deriv_right_le (hf.sub hg) h_deriv ha
intro t ht
have := dist_triangle4_right (f' t) (g' t) (v t (f t)) (v t (g t))
have hv := (hv t).dist_le_mul _ (hfs t ht) _ (hgs t ht)
rw [← dist_eq_norm, ← dist_eq_norm]
refine this.trans ((add_le_add (add_le_add (f_bound t ht) (g_bound t ht)) hv).trans ?_)
rw [add_comm]
/-- If `f` and `g` are two approximate solutions of the same ODE, then the distance between them
can't grow faster than exponentially. This is a simple corollary of Grönwall's inequality, and some
people call this Grönwall's inequality too.
This version assumes all inequalities to be true in the whole space. -/
theorem dist_le_of_approx_trajectories_ODE
(hv : ∀ t, LipschitzWith K (v t))
(hf : ContinuousOn f (Icc a b))
(hf' : ∀ t ∈ Ico a b, HasDerivWithinAt f (f' t) (Ici t) t)
(f_bound : ∀ t ∈ Ico a b, dist (f' t) (v t (f t)) ≤ εf)
(hg : ContinuousOn g (Icc a b))
(hg' : ∀ t ∈ Ico a b, HasDerivWithinAt g (g' t) (Ici t) t)
(g_bound : ∀ t ∈ Ico a b, dist (g' t) (v t (g t)) ≤ εg)
(ha : dist (f a) (g a) ≤ δ) :
∀ t ∈ Icc a b, dist (f t) (g t) ≤ gronwallBound δ K (εf + εg) (t - a) :=
have hfs : ∀ t ∈ Ico a b, f t ∈ @univ E := fun _ _ => trivial
dist_le_of_approx_trajectories_ODE_of_mem (fun t => (hv t).lipschitzOnWith _) hf hf'
f_bound hfs hg hg' g_bound (fun _ _ => trivial) ha
/-- If `f` and `g` are two exact solutions of the same ODE, then the distance between them
can't grow faster than exponentially. This is a simple corollary of Grönwall's inequality, and some
people call this Grönwall's inequality too.
This version assumes all inequalities to be true in some time-dependent set `s t`,
and assumes that the solutions never leave this set. -/
theorem dist_le_of_trajectories_ODE_of_mem
(hf : ContinuousOn f (Icc a b))
(hf' : ∀ t ∈ Ico a b, HasDerivWithinAt f (v t (f t)) (Ici t) t)
(hfs : ∀ t ∈ Ico a b, f t ∈ s t)
(hg : ContinuousOn g (Icc a b)) (hg' : ∀ t ∈ Ico a b, HasDerivWithinAt g (v t (g t)) (Ici t) t)
(hgs : ∀ t ∈ Ico a b, g t ∈ s t) (ha : dist (f a) (g a) ≤ δ) :
∀ t ∈ Icc a b, dist (f t) (g t) ≤ δ * exp (K * (t - a)) := by
have f_bound : ∀ t ∈ Ico a b, dist (v t (f t)) (v t (f t)) ≤ 0 := by intros; rw [dist_self]
have g_bound : ∀ t ∈ Ico a b, dist (v t (g t)) (v t (g t)) ≤ 0 := by intros; rw [dist_self]
intro t ht
have :=
dist_le_of_approx_trajectories_ODE_of_mem hv hf hf' f_bound hfs hg hg' g_bound hgs ha t ht
rwa [zero_add, gronwallBound_ε0] at this
/-- If `f` and `g` are two exact solutions of the same ODE, then the distance between them
can't grow faster than exponentially. This is a simple corollary of Grönwall's inequality, and some
people call this Grönwall's inequality too.
This version assumes all inequalities to be true in the whole space. -/
theorem dist_le_of_trajectories_ODE
(hv : ∀ t, LipschitzWith K (v t))
(hf : ContinuousOn f (Icc a b))
(hf' : ∀ t ∈ Ico a b, HasDerivWithinAt f (v t (f t)) (Ici t) t)
(hg : ContinuousOn g (Icc a b))
(hg' : ∀ t ∈ Ico a b, HasDerivWithinAt g (v t (g t)) (Ici t) t)
(ha : dist (f a) (g a) ≤ δ) :
∀ t ∈ Icc a b, dist (f t) (g t) ≤ δ * exp (K * (t - a)) :=
have hfs : ∀ t ∈ Ico a b, f t ∈ @univ E := fun _ _ => trivial
dist_le_of_trajectories_ODE_of_mem (fun t => (hv t).lipschitzOnWith _) hf hf' hfs hg
hg' (fun _ _ => trivial) ha
/-- There exists only one solution of an ODE \(\dot x=v(t, x)\) in a set `s ⊆ ℝ × E` with
a given initial value provided that the RHS is Lipschitz continuous in `x` within `s`,
and we consider only solutions included in `s`.
This version shows uniqueness in a closed interval `Icc a b`, where `a` is the initial time. -/
theorem ODE_solution_unique_of_mem_Icc_right
(hf : ContinuousOn f (Icc a b))
(hf' : ∀ t ∈ Ico a b, HasDerivWithinAt f (v t (f t)) (Ici t) t)
(hfs : ∀ t ∈ Ico a b, f t ∈ s t)
(hg : ContinuousOn g (Icc a b))
(hg' : ∀ t ∈ Ico a b, HasDerivWithinAt g (v t (g t)) (Ici t) t)
(hgs : ∀ t ∈ Ico a b, g t ∈ s t)
(ha : f a = g a) :
EqOn f g (Icc a b) := fun t ht ↦ by
have := dist_le_of_trajectories_ODE_of_mem hv hf hf' hfs hg hg' hgs (dist_le_zero.2 ha) t ht
rwa [zero_mul, dist_le_zero] at this
/-- A time-reversed version of `ODE_solution_unique_of_mem_Icc_right`. Uniqueness is shown in a
closed interval `Icc a b`, where `b` is the "initial" time. -/
theorem ODE_solution_unique_of_mem_Icc_left
(hf : ContinuousOn f (Icc a b))
(hf' : ∀ t ∈ Ioc a b, HasDerivWithinAt f (v t (f t)) (Iic t) t)
(hfs : ∀ t ∈ Ioc a b, f t ∈ s t)
(hg : ContinuousOn g (Icc a b))
(hg' : ∀ t ∈ Ioc a b, HasDerivWithinAt g (v t (g t)) (Iic t) t)
(hgs : ∀ t ∈ Ioc a b, g t ∈ s t)
(hb : f b = g b) :
EqOn f g (Icc a b) := by
have hv' t : LipschitzOnWith K (Neg.neg ∘ (v (-t))) (s (-t)) := by
rw [← one_mul K]
exact LipschitzWith.id.neg.comp_lipschitzOnWith (hv _)
have hmt1 : MapsTo Neg.neg (Icc (-b) (-a)) (Icc a b) :=
fun _ ht ↦ ⟨le_neg.mp ht.2, neg_le.mp ht.1⟩
have hmt2 : MapsTo Neg.neg (Ico (-b) (-a)) (Ioc a b) :=
fun _ ht ↦ ⟨lt_neg.mp ht.2, neg_le.mp ht.1⟩
have hmt3 (t : ℝ) : MapsTo Neg.neg (Ici t) (Iic (-t)) :=
fun _ ht' ↦ mem_Iic.mpr <| neg_le_neg ht'
suffices EqOn (f ∘ Neg.neg) (g ∘ Neg.neg) (Icc (-b) (-a)) by
rw [eqOn_comp_right_iff] at this
convert this
simp
apply ODE_solution_unique_of_mem_Icc_right hv'
(hf.comp continuousOn_neg hmt1) _ (fun _ ht ↦ hfs _ (hmt2 ht))
(hg.comp continuousOn_neg hmt1) _ (fun _ ht ↦ hgs _ (hmt2 ht)) (by simp [hb])
· intros t ht
convert HasFDerivWithinAt.comp_hasDerivWithinAt t (hf' (-t) (hmt2 ht))
(hasDerivAt_neg t).hasDerivWithinAt (hmt3 t)
simp
· intros t ht
convert HasFDerivWithinAt.comp_hasDerivWithinAt t (hg' (-t) (hmt2 ht))
(hasDerivAt_neg t).hasDerivWithinAt (hmt3 t)
simp
/-- A version of `ODE_solution_unique_of_mem_Icc_right` for uniqueness in a closed interval whose
interior contains the initial time. -/
theorem ODE_solution_unique_of_mem_Icc
(ht : t₀ ∈ Ioo a b)
(hf : ContinuousOn f (Icc a b))
(hf' : ∀ t ∈ Ioo a b, HasDerivAt f (v t (f t)) t)
(hfs : ∀ t ∈ Ioo a b, f t ∈ s t)
(hg : ContinuousOn g (Icc a b))
(hg' : ∀ t ∈ Ioo a b, HasDerivAt g (v t (g t)) t)
(hgs : ∀ t ∈ Ioo a b, g t ∈ s t)
(heq : f t₀ = g t₀) :
EqOn f g (Icc a b) := by
rw [← Icc_union_Icc_eq_Icc (le_of_lt ht.1) (le_of_lt ht.2)]
apply EqOn.union
· have hss : Ioc a t₀ ⊆ Ioo a b := Ioc_subset_Ioo_right ht.2
exact ODE_solution_unique_of_mem_Icc_left hv
(hf.mono <| Icc_subset_Icc_right <| le_of_lt ht.2)
(fun _ ht' ↦ (hf' _ (hss ht')).hasDerivWithinAt) (fun _ ht' ↦ (hfs _ (hss ht')))
(hg.mono <| Icc_subset_Icc_right <| le_of_lt ht.2)
(fun _ ht' ↦ (hg' _ (hss ht')).hasDerivWithinAt) (fun _ ht' ↦ (hgs _ (hss ht'))) heq
· have hss : Ico t₀ b ⊆ Ioo a b := Ico_subset_Ioo_left ht.1
exact ODE_solution_unique_of_mem_Icc_right hv
(hf.mono <| Icc_subset_Icc_left <| le_of_lt ht.1)
(fun _ ht' ↦ (hf' _ (hss ht')).hasDerivWithinAt) (fun _ ht' ↦ (hfs _ (hss ht')))
(hg.mono <| Icc_subset_Icc_left <| le_of_lt ht.1)
(fun _ ht' ↦ (hg' _ (hss ht')).hasDerivWithinAt) (fun _ ht' ↦ (hgs _ (hss ht'))) heq
/-- A version of `ODE_solution_unique_of_mem_Icc` for uniqueness in an open interval. -/
theorem ODE_solution_unique_of_mem_Ioo
(ht : t₀ ∈ Ioo a b)
(hf : ∀ t ∈ Ioo a b, HasDerivAt f (v t (f t)) t ∧ f t ∈ s t)
(hg : ∀ t ∈ Ioo a b, HasDerivAt g (v t (g t)) t ∧ g t ∈ s t)
(heq : f t₀ = g t₀) :
EqOn f g (Ioo a b) := by
intros t' ht'
rcases lt_or_le t' t₀ with (h | h)
· have hss : Icc t' t₀ ⊆ Ioo a b :=
fun _ ht'' ↦ ⟨lt_of_lt_of_le ht'.1 ht''.1, lt_of_le_of_lt ht''.2 ht.2⟩
exact ODE_solution_unique_of_mem_Icc_left hv
(ContinuousAt.continuousOn fun _ ht'' ↦ (hf _ <| hss ht'').1.continuousAt)
(fun _ ht'' ↦ (hf _ <| hss <| Ioc_subset_Icc_self ht'').1.hasDerivWithinAt)
(fun _ ht'' ↦ (hf _ <| hss <| Ioc_subset_Icc_self ht'').2)
(ContinuousAt.continuousOn fun _ ht'' ↦ (hg _ <| hss ht'').1.continuousAt)
(fun _ ht'' ↦ (hg _ <| hss <| Ioc_subset_Icc_self ht'').1.hasDerivWithinAt)
(fun _ ht'' ↦ (hg _ <| hss <| Ioc_subset_Icc_self ht'').2) heq
⟨le_rfl, le_of_lt h⟩
· have hss : Icc t₀ t' ⊆ Ioo a b :=
fun _ ht'' ↦ ⟨lt_of_lt_of_le ht.1 ht''.1, lt_of_le_of_lt ht''.2 ht'.2⟩
exact ODE_solution_unique_of_mem_Icc_right hv
(ContinuousAt.continuousOn fun _ ht'' ↦ (hf _ <| hss ht'').1.continuousAt)
(fun _ ht'' ↦ (hf _ <| hss <| Ico_subset_Icc_self ht'').1.hasDerivWithinAt)
(fun _ ht'' ↦ (hf _ <| hss <| Ico_subset_Icc_self ht'').2)
(ContinuousAt.continuousOn fun _ ht'' ↦ (hg _ <| hss ht'').1.continuousAt)
(fun _ ht'' ↦ (hg _ <| hss <| Ico_subset_Icc_self ht'').1.hasDerivWithinAt)
(fun _ ht'' ↦ (hg _ <| hss <| Ico_subset_Icc_self ht'').2) heq
⟨h, le_rfl⟩
/-- Local unqueness of ODE solutions. -/
theorem ODE_solution_unique_of_eventually
(hf : ∀ᶠ t in 𝓝 t₀, HasDerivAt f (v t (f t)) t ∧ f t ∈ s t)
(hg : ∀ᶠ t in 𝓝 t₀, HasDerivAt g (v t (g t)) t ∧ g t ∈ s t)
(heq : f t₀ = g t₀) : f =ᶠ[𝓝 t₀] g := by
obtain ⟨ε, hε, h⟩ := eventually_nhds_iff_ball.mp (hf.and hg)
rw [Filter.eventuallyEq_iff_exists_mem]
refine ⟨ball t₀ ε, ball_mem_nhds _ hε, ?_⟩
simp_rw [Real.ball_eq_Ioo] at *
apply ODE_solution_unique_of_mem_Ioo hv (Real.ball_eq_Ioo t₀ ε ▸ mem_ball_self hε)
(fun _ ht ↦ (h _ ht).1) (fun _ ht ↦ (h _ ht).2) heq
/-- There exists only one solution of an ODE \(\dot x=v(t, x)\) with
a given initial value provided that the RHS is Lipschitz continuous in `x`. -/
theorem ODE_solution_unique
(hv : ∀ t, LipschitzWith K (v t))
(hf : ContinuousOn f (Icc a b))
(hf' : ∀ t ∈ Ico a b, HasDerivWithinAt f (v t (f t)) (Ici t) t)
(hg : ContinuousOn g (Icc a b))
(hg' : ∀ t ∈ Ico a b, HasDerivWithinAt g (v t (g t)) (Ici t) t)
(ha : f a = g a) :
EqOn f g (Icc a b) :=
have hfs : ∀ t ∈ Ico a b, f t ∈ @univ E := fun _ _ => trivial
ODE_solution_unique_of_mem_Icc_right (fun t => (hv t).lipschitzOnWith _) hf hf' hfs hg hg'
(fun _ _ => trivial) ha
|
Analysis\ODE\PicardLindelof.lean | /-
Copyright (c) 2021 Yury G. Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury G. Kudryashov, Winston Yin
-/
import Mathlib.Analysis.SpecialFunctions.Integrals
import Mathlib.Topology.MetricSpace.Contracting
/-!
# Picard-Lindelöf (Cauchy-Lipschitz) Theorem
In this file we prove that an ordinary differential equation $\dot x=v(t, x)$ such that $v$ is
Lipschitz continuous in $x$ and continuous in $t$ has a local solution, see
`IsPicardLindelof.exists_forall_hasDerivWithinAt_Icc_eq`.
As a corollary, we prove that a time-independent locally continuously differentiable ODE has a
local solution.
## Implementation notes
In order to split the proof into small lemmas, we introduce a structure `PicardLindelof` that holds
all assumptions of the main theorem. This structure and lemmas in the `PicardLindelof` namespace
should be treated as private implementation details. This is not to be confused with the `Prop`-
valued structure `IsPicardLindelof`, which holds the long hypotheses of the Picard-Lindelöf
theorem for actual use as part of the public API.
We only prove existence of a solution in this file. For uniqueness see `ODE_solution_unique` and
related theorems in `Mathlib/Analysis/ODE/Gronwall.lean`.
## Tags
differential equation
-/
open Filter Function Set Metric TopologicalSpace intervalIntegral MeasureTheory
open MeasureTheory.MeasureSpace (volume)
open scoped Filter Topology NNReal ENNReal Nat Interval
noncomputable section
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
/-- `Prop` structure holding the hypotheses of the Picard-Lindelöf theorem.
The similarly named `PicardLindelof` structure is part of the internal API for convenience, so as
not to constantly invoke choice, but is not intended for public use. -/
structure IsPicardLindelof {E : Type*} [NormedAddCommGroup E] (v : ℝ → E → E) (tMin t₀ tMax : ℝ)
(x₀ : E) (L : ℝ≥0) (R C : ℝ) : Prop where
ht₀ : t₀ ∈ Icc tMin tMax
hR : 0 ≤ R
lipschitz : ∀ t ∈ Icc tMin tMax, LipschitzOnWith L (v t) (closedBall x₀ R)
cont : ∀ x ∈ closedBall x₀ R, ContinuousOn (fun t : ℝ => v t x) (Icc tMin tMax)
norm_le : ∀ t ∈ Icc tMin tMax, ∀ x ∈ closedBall x₀ R, ‖v t x‖ ≤ C
C_mul_le_R : (C : ℝ) * max (tMax - t₀) (t₀ - tMin) ≤ R
/-- This structure holds arguments of the Picard-Lipschitz (Cauchy-Lipschitz) theorem. It is part of
the internal API for convenience, so as not to constantly invoke choice. Unless you want to use one
of the auxiliary lemmas, use `IsPicardLindelof.exists_forall_hasDerivWithinAt_Icc_eq` instead
of using this structure.
The similarly named `IsPicardLindelof` is a bundled `Prop` holding the long hypotheses of the
Picard-Lindelöf theorem as named arguments. It is used as part of the public API.
-/
structure PicardLindelof (E : Type*) [NormedAddCommGroup E] [NormedSpace ℝ E] where
toFun : ℝ → E → E
(tMin tMax : ℝ)
t₀ : Icc tMin tMax
x₀ : E
(C R L : ℝ≥0)
isPicardLindelof : IsPicardLindelof toFun tMin t₀ tMax x₀ L R C
namespace PicardLindelof
variable (v : PicardLindelof E)
instance : CoeFun (PicardLindelof E) fun _ => ℝ → E → E :=
⟨toFun⟩
instance : Inhabited (PicardLindelof E) :=
⟨⟨0, 0, 0, ⟨0, le_rfl, le_rfl⟩, 0, 0, 0, 0,
{ ht₀ := by rw [Subtype.coe_mk, Icc_self]; exact mem_singleton _
hR := le_rfl
lipschitz := fun t _ => (LipschitzWith.const 0).lipschitzOnWith _
cont := fun _ _ => by simpa only [Pi.zero_apply] using continuousOn_const
norm_le := fun t _ x _ => norm_zero.le
C_mul_le_R := (zero_mul _).le }⟩⟩
theorem tMin_le_tMax : v.tMin ≤ v.tMax :=
v.t₀.2.1.trans v.t₀.2.2
protected theorem nonempty_Icc : (Icc v.tMin v.tMax).Nonempty :=
nonempty_Icc.2 v.tMin_le_tMax
protected theorem lipschitzOnWith {t} (ht : t ∈ Icc v.tMin v.tMax) :
LipschitzOnWith v.L (v t) (closedBall v.x₀ v.R) :=
v.isPicardLindelof.lipschitz t ht
protected theorem continuousOn :
ContinuousOn (uncurry v) (Icc v.tMin v.tMax ×ˢ closedBall v.x₀ v.R) :=
have : ContinuousOn (uncurry (flip v)) (closedBall v.x₀ v.R ×ˢ Icc v.tMin v.tMax) :=
continuousOn_prod_of_continuousOn_lipschitzOnWith _ v.L v.isPicardLindelof.cont
v.isPicardLindelof.lipschitz
this.comp continuous_swap.continuousOn (preimage_swap_prod _ _).symm.subset
theorem norm_le {t : ℝ} (ht : t ∈ Icc v.tMin v.tMax) {x : E} (hx : x ∈ closedBall v.x₀ v.R) :
‖v t x‖ ≤ v.C :=
v.isPicardLindelof.norm_le _ ht _ hx
/-- The maximum of distances from `t₀` to the endpoints of `[tMin, tMax]`. -/
def tDist : ℝ :=
max (v.tMax - v.t₀) (v.t₀ - v.tMin)
theorem tDist_nonneg : 0 ≤ v.tDist :=
le_max_iff.2 <| Or.inl <| sub_nonneg.2 v.t₀.2.2
theorem dist_t₀_le (t : Icc v.tMin v.tMax) : dist t v.t₀ ≤ v.tDist := by
rw [Subtype.dist_eq, Real.dist_eq]
rcases le_total t v.t₀ with ht | ht
· rw [abs_of_nonpos (sub_nonpos.2 <| Subtype.coe_le_coe.2 ht), neg_sub]
exact (sub_le_sub_left t.2.1 _).trans (le_max_right _ _)
· rw [abs_of_nonneg (sub_nonneg.2 <| Subtype.coe_le_coe.2 ht)]
exact (sub_le_sub_right t.2.2 _).trans (le_max_left _ _)
/-- Projection $ℝ → [t_{\min}, t_{\max}]$ sending $(-∞, t_{\min}]$ to $t_{\min}$ and $[t_{\max}, ∞)$
to $t_{\max}$. -/
def proj : ℝ → Icc v.tMin v.tMax :=
projIcc v.tMin v.tMax v.tMin_le_tMax
theorem proj_coe (t : Icc v.tMin v.tMax) : v.proj t = t :=
projIcc_val _ _
theorem proj_of_mem {t : ℝ} (ht : t ∈ Icc v.tMin v.tMax) : ↑(v.proj t) = t := by
simp only [proj, projIcc_of_mem v.tMin_le_tMax ht]
@[continuity, fun_prop]
theorem continuous_proj : Continuous v.proj :=
continuous_projIcc
/-- The space of curves $γ \colon [t_{\min}, t_{\max}] \to E$ such that $γ(t₀) = x₀$ and $γ$ is
Lipschitz continuous with constant $C$. The map sending $γ$ to
$\mathbf Pγ(t)=x₀ + ∫_{t₀}^{t} v(τ, γ(τ))\,dτ$ is a contracting map on this space, and its fixed
point is a solution of the ODE $\dot x=v(t, x)$. -/
structure FunSpace where
toFun : Icc v.tMin v.tMax → E
map_t₀' : toFun v.t₀ = v.x₀
lipschitz' : LipschitzWith v.C toFun
namespace FunSpace
variable {v}
variable (f : FunSpace v)
instance : CoeFun (FunSpace v) fun _ => Icc v.tMin v.tMax → E :=
⟨toFun⟩
instance : Inhabited v.FunSpace :=
⟨⟨fun _ => v.x₀, rfl, (LipschitzWith.const _).weaken (zero_le _)⟩⟩
protected theorem lipschitz : LipschitzWith v.C f :=
f.lipschitz'
protected theorem continuous : Continuous f :=
f.lipschitz.continuous
/-- Each curve in `PicardLindelof.FunSpace` is continuous. -/
def toContinuousMap : v.FunSpace ↪ C(Icc v.tMin v.tMax, E) :=
⟨fun f => ⟨f, f.continuous⟩, fun f g h => by cases f; cases g; simpa using h⟩
instance : MetricSpace v.FunSpace :=
MetricSpace.induced toContinuousMap toContinuousMap.injective inferInstance
theorem uniformInducing_toContinuousMap : UniformInducing (@toContinuousMap _ _ _ v) :=
⟨rfl⟩
theorem range_toContinuousMap :
range toContinuousMap =
{f : C(Icc v.tMin v.tMax, E) | f v.t₀ = v.x₀ ∧ LipschitzWith v.C f} := by
ext f; constructor
· rintro ⟨⟨f, hf₀, hf_lip⟩, rfl⟩; exact ⟨hf₀, hf_lip⟩
· rcases f with ⟨f, hf⟩; rintro ⟨hf₀, hf_lip⟩; exact ⟨⟨f, hf₀, hf_lip⟩, rfl⟩
theorem map_t₀ : f v.t₀ = v.x₀ :=
f.map_t₀'
protected theorem mem_closedBall (t : Icc v.tMin v.tMax) : f t ∈ closedBall v.x₀ v.R :=
calc
dist (f t) v.x₀ = dist (f t) (f.toFun v.t₀) := by rw [f.map_t₀']
_ ≤ v.C * dist t v.t₀ := f.lipschitz.dist_le_mul _ _
_ ≤ v.C * v.tDist := mul_le_mul_of_nonneg_left (v.dist_t₀_le _) v.C.2
_ ≤ v.R := v.isPicardLindelof.C_mul_le_R
/-- Given a curve $γ \colon [t_{\min}, t_{\max}] → E$, `PicardLindelof.vComp` is the function
$F(t)=v(π t, γ(π t))$, where `π` is the projection $ℝ → [t_{\min}, t_{\max}]$. The integral of this
function is the image of `γ` under the contracting map we are going to define below. -/
def vComp (t : ℝ) : E :=
v (v.proj t) (f (v.proj t))
theorem vComp_apply_coe (t : Icc v.tMin v.tMax) : f.vComp t = v t (f t) := by
simp only [vComp, proj_coe]
theorem continuous_vComp : Continuous f.vComp := by
have := (continuous_subtype_val.prod_mk f.continuous).comp v.continuous_proj
refine ContinuousOn.comp_continuous v.continuousOn this fun x => ?_
exact ⟨(v.proj x).2, f.mem_closedBall _⟩
theorem norm_vComp_le (t : ℝ) : ‖f.vComp t‖ ≤ v.C :=
v.norm_le (v.proj t).2 <| f.mem_closedBall _
theorem dist_apply_le_dist (f₁ f₂ : FunSpace v) (t : Icc v.tMin v.tMax) :
dist (f₁ t) (f₂ t) ≤ dist f₁ f₂ :=
@ContinuousMap.dist_apply_le_dist _ _ _ _ _ (toContinuousMap f₁) (toContinuousMap f₂) _
theorem dist_le_of_forall {f₁ f₂ : FunSpace v} {d : ℝ} (h : ∀ t, dist (f₁ t) (f₂ t) ≤ d) :
dist f₁ f₂ ≤ d :=
(@ContinuousMap.dist_le_iff_of_nonempty _ _ _ _ _ (toContinuousMap f₁) (toContinuousMap f₂) _
v.nonempty_Icc.to_subtype).2 h
instance [CompleteSpace E] : CompleteSpace v.FunSpace := by
refine (completeSpace_iff_isComplete_range uniformInducing_toContinuousMap).2
(IsClosed.isComplete ?_)
rw [range_toContinuousMap, setOf_and]
refine (isClosed_eq (ContinuousMap.continuous_eval_const _) continuous_const).inter ?_
have : IsClosed {f : Icc v.tMin v.tMax → E | LipschitzWith v.C f} :=
isClosed_setOf_lipschitzWith v.C
exact this.preimage ContinuousMap.continuous_coe
theorem intervalIntegrable_vComp (t₁ t₂ : ℝ) : IntervalIntegrable f.vComp volume t₁ t₂ :=
f.continuous_vComp.intervalIntegrable _ _
variable [CompleteSpace E]
/-- The Picard-Lindelöf operator. This is a contracting map on `PicardLindelof.FunSpace v` such
that the fixed point of this map is the solution of the corresponding ODE.
More precisely, some iteration of this map is a contracting map. -/
def next (f : FunSpace v) : FunSpace v where
toFun t := v.x₀ + ∫ τ : ℝ in v.t₀..t, f.vComp τ
map_t₀' := by simp only [integral_same, add_zero]
lipschitz' := LipschitzWith.of_dist_le_mul fun t₁ t₂ => by
rw [dist_add_left, dist_eq_norm,
integral_interval_sub_left (f.intervalIntegrable_vComp _ _) (f.intervalIntegrable_vComp _ _)]
exact norm_integral_le_of_norm_le_const fun t _ => f.norm_vComp_le _
theorem next_apply (t : Icc v.tMin v.tMax) : f.next t = v.x₀ + ∫ τ : ℝ in v.t₀..t, f.vComp τ :=
rfl
theorem hasDerivWithinAt_next (t : Icc v.tMin v.tMax) :
HasDerivWithinAt (f.next ∘ v.proj) (v t (f t)) (Icc v.tMin v.tMax) t := by
haveI : Fact ((t : ℝ) ∈ Icc v.tMin v.tMax) := ⟨t.2⟩
simp only [(· ∘ ·), next_apply]
refine HasDerivWithinAt.const_add _ ?_
have : HasDerivWithinAt (∫ τ in v.t₀..·, f.vComp τ) (f.vComp t) (Icc v.tMin v.tMax) t :=
integral_hasDerivWithinAt_right (f.intervalIntegrable_vComp _ _)
(f.continuous_vComp.stronglyMeasurableAtFilter _ _)
f.continuous_vComp.continuousWithinAt
rw [vComp_apply_coe] at this
refine this.congr_of_eventuallyEq_of_mem ?_ t.coe_prop
filter_upwards [self_mem_nhdsWithin] with _ ht'
rw [v.proj_of_mem ht']
theorem dist_next_apply_le_of_le {f₁ f₂ : FunSpace v} {n : ℕ} {d : ℝ}
(h : ∀ t, dist (f₁ t) (f₂ t) ≤ (v.L * |t.1 - v.t₀|) ^ n / n ! * d) (t : Icc v.tMin v.tMax) :
dist (next f₁ t) (next f₂ t) ≤ (v.L * |t.1 - v.t₀|) ^ (n + 1) / (n + 1)! * d := by
simp only [dist_eq_norm, next_apply, add_sub_add_left_eq_sub, ←
intervalIntegral.integral_sub (intervalIntegrable_vComp _ _ _)
(intervalIntegrable_vComp _ _ _),
norm_integral_eq_norm_integral_Ioc] at *
calc
‖∫ τ in Ι (v.t₀ : ℝ) t, f₁.vComp τ - f₂.vComp τ‖ ≤
∫ τ in Ι (v.t₀ : ℝ) t, v.L * ((v.L * |τ - v.t₀|) ^ n / n ! * d) := by
refine norm_integral_le_of_norm_le (Continuous.integrableOn_uIoc (by fun_prop)) ?_
refine (ae_restrict_mem measurableSet_Ioc).mono fun τ hτ ↦ ?_
refine (v.lipschitzOnWith (v.proj τ).2).norm_sub_le_of_le (f₁.mem_closedBall _)
(f₂.mem_closedBall _) ((h _).trans_eq ?_)
rw [v.proj_of_mem]
exact uIcc_subset_Icc v.t₀.2 t.2 <| Ioc_subset_Icc_self hτ
_ = (v.L * |t.1 - v.t₀|) ^ (n + 1) / (n + 1)! * d := by
simp_rw [mul_pow, div_eq_mul_inv, mul_assoc, MeasureTheory.integral_mul_left,
MeasureTheory.integral_mul_right, integral_pow_abs_sub_uIoc, div_eq_mul_inv,
pow_succ' (v.L : ℝ), Nat.factorial_succ, Nat.cast_mul, Nat.cast_succ, mul_inv, mul_assoc]
theorem dist_iterate_next_apply_le (f₁ f₂ : FunSpace v) (n : ℕ) (t : Icc v.tMin v.tMax) :
dist (next^[n] f₁ t) (next^[n] f₂ t) ≤ (v.L * |t.1 - v.t₀|) ^ n / n ! * dist f₁ f₂ := by
induction' n with n ihn generalizing t
· rw [pow_zero, Nat.factorial_zero, Nat.cast_one, div_one, one_mul]
exact dist_apply_le_dist f₁ f₂ t
· rw [iterate_succ_apply', iterate_succ_apply']
exact dist_next_apply_le_of_le ihn _
theorem dist_iterate_next_le (f₁ f₂ : FunSpace v) (n : ℕ) :
dist (next^[n] f₁) (next^[n] f₂) ≤ (v.L * v.tDist) ^ n / n ! * dist f₁ f₂ := by
refine dist_le_of_forall fun t => (dist_iterate_next_apply_le _ _ _ _).trans ?_
have : |(t - v.t₀ : ℝ)| ≤ v.tDist := v.dist_t₀_le t
gcongr
end FunSpace
variable [CompleteSpace E]
section
theorem exists_contracting_iterate :
∃ (N : ℕ) (K : _), ContractingWith K (FunSpace.next : v.FunSpace → v.FunSpace)^[N] := by
rcases ((Real.tendsto_pow_div_factorial_atTop (v.L * v.tDist)).eventually
(gt_mem_nhds zero_lt_one)).exists with ⟨N, hN⟩
have : (0 : ℝ) ≤ (v.L * v.tDist) ^ N / N ! :=
div_nonneg (pow_nonneg (mul_nonneg v.L.2 v.tDist_nonneg) _) (Nat.cast_nonneg _)
exact ⟨N, ⟨_, this⟩, hN, LipschitzWith.of_dist_le_mul fun f g =>
FunSpace.dist_iterate_next_le f g N⟩
theorem exists_fixed : ∃ f : v.FunSpace, f.next = f :=
let ⟨_N, _K, hK⟩ := exists_contracting_iterate v
⟨_, hK.isFixedPt_fixedPoint_iterate⟩
end
/-- Picard-Lindelöf (Cauchy-Lipschitz) theorem. Use
`IsPicardLindelof.exists_forall_hasDerivWithinAt_Icc_eq` instead for the public API. -/
theorem exists_solution :
∃ f : ℝ → E, f v.t₀ = v.x₀ ∧ ∀ t ∈ Icc v.tMin v.tMax,
HasDerivWithinAt f (v t (f t)) (Icc v.tMin v.tMax) t := by
rcases v.exists_fixed with ⟨f, hf⟩
refine ⟨f ∘ v.proj, ?_, fun t ht => ?_⟩
· simp only [(· ∘ ·), proj_coe, f.map_t₀]
· simp only [(· ∘ ·), v.proj_of_mem ht]
lift t to Icc v.tMin v.tMax using ht
simpa only [hf, v.proj_coe] using f.hasDerivWithinAt_next t
end PicardLindelof
theorem IsPicardLindelof.norm_le₀ {E : Type*} [NormedAddCommGroup E] {v : ℝ → E → E}
{tMin t₀ tMax : ℝ} {x₀ : E} {C R : ℝ} {L : ℝ≥0}
(hpl : IsPicardLindelof v tMin t₀ tMax x₀ L R C) : ‖v t₀ x₀‖ ≤ C :=
hpl.norm_le t₀ hpl.ht₀ x₀ <| mem_closedBall_self hpl.hR
/-- Picard-Lindelöf (Cauchy-Lipschitz) theorem. -/
theorem IsPicardLindelof.exists_forall_hasDerivWithinAt_Icc_eq [CompleteSpace E] {v : ℝ → E → E}
{tMin t₀ tMax : ℝ} (x₀ : E) {C R : ℝ} {L : ℝ≥0}
(hpl : IsPicardLindelof v tMin t₀ tMax x₀ L R C) :
∃ f : ℝ → E, f t₀ = x₀ ∧
∀ t ∈ Icc tMin tMax, HasDerivWithinAt f (v t (f t)) (Icc tMin tMax) t := by
lift C to ℝ≥0 using (norm_nonneg _).trans hpl.norm_le₀
lift t₀ to Icc tMin tMax using hpl.ht₀
exact PicardLindelof.exists_solution
⟨v, tMin, tMax, t₀, x₀, C, ⟨R, hpl.hR⟩, L, { hpl with ht₀ := t₀.property }⟩
variable {v : E → E} (t₀ : ℝ) {x₀ : E}
/-- A time-independent, continuously differentiable ODE satisfies the hypotheses of the
Picard-Lindelöf theorem. -/
theorem exists_isPicardLindelof_const_of_contDiffAt (hv : ContDiffAt ℝ 1 v x₀) :
∃ ε > (0 : ℝ), ∃ L R C, IsPicardLindelof (fun _ => v) (t₀ - ε) t₀ (t₀ + ε) x₀ L R C := by
obtain ⟨L, s, hs, hlip⟩ := hv.exists_lipschitzOnWith
obtain ⟨R₁, hR₁ : 0 < R₁, hball⟩ := Metric.mem_nhds_iff.mp hs
obtain ⟨R₂, hR₂ : 0 < R₂, hbdd⟩ := Metric.continuousAt_iff.mp hv.continuousAt.norm 1 zero_lt_one
have hbdd' : ∀ x ∈ Metric.ball x₀ R₂, ‖v x‖ ≤ 1 + ‖v x₀‖ := fun _ hx =>
sub_le_iff_le_add.mp <| le_of_lt <| lt_of_abs_lt <| Real.dist_eq _ _ ▸ hbdd hx
set ε := min R₁ R₂ / 2 / (1 + ‖v x₀‖) with hε
have hε0 : 0 < ε := hε ▸ div_pos (half_pos <| lt_min hR₁ hR₂)
(add_pos_of_pos_of_nonneg zero_lt_one (norm_nonneg _))
refine ⟨ε, hε0, L, min R₁ R₂ / 2, 1 + ‖v x₀‖, ?_⟩
exact
{ ht₀ := Real.closedBall_eq_Icc ▸ mem_closedBall_self hε0.le
hR := by positivity
lipschitz := fun _ _ => hlip.mono <|
(closedBall_subset_ball <| half_lt_self <| lt_min hR₁ hR₂).trans <|
(Metric.ball_subset_ball <| min_le_left _ _).trans hball
cont := fun _ _ => continuousOn_const
norm_le := fun _ _ x hx => hbdd' x <| mem_of_mem_of_subset hx <|
(closedBall_subset_ball <| half_lt_self <| lt_min hR₁ hR₂).trans <|
(Metric.ball_subset_ball <| min_le_right _ _).trans (subset_refl _)
C_mul_le_R := by
rw [add_sub_cancel_left, sub_sub_cancel, max_self, hε, mul_div_left_comm, div_self, mul_one]
exact ne_of_gt <| add_pos_of_pos_of_nonneg zero_lt_one <| norm_nonneg _ }
variable [CompleteSpace E]
/-- A time-independent, continuously differentiable ODE admits a solution in some open interval. -/
theorem exists_forall_hasDerivAt_Ioo_eq_of_contDiffAt (hv : ContDiffAt ℝ 1 v x₀) :
∃ f : ℝ → E, f t₀ = x₀ ∧
∃ ε > (0 : ℝ), ∀ t ∈ Ioo (t₀ - ε) (t₀ + ε), HasDerivAt f (v (f t)) t := by
obtain ⟨ε, hε, _, _, _, hpl⟩ := exists_isPicardLindelof_const_of_contDiffAt t₀ hv
obtain ⟨f, hf1, hf2⟩ := hpl.exists_forall_hasDerivWithinAt_Icc_eq x₀
exact ⟨f, hf1, ε, hε, fun t ht =>
(hf2 t (Ioo_subset_Icc_self ht)).hasDerivAt (Icc_mem_nhds ht.1 ht.2)⟩
/-- A time-independent, continuously differentiable ODE admits a solution in some open interval. -/
theorem exists_forall_hasDerivAt_Ioo_eq_of_contDiff (hv : ContDiff ℝ 1 v) :
∃ f : ℝ → E, f t₀ = x₀ ∧
∃ ε > (0 : ℝ), ∀ t ∈ Ioo (t₀ - ε) (t₀ + ε), HasDerivAt f (v (f t)) t :=
let ⟨f, hf1, ε, hε, hf2⟩ :=
exists_forall_hasDerivAt_Ioo_eq_of_contDiffAt t₀ hv.contDiffAt
⟨f, hf1, ε, hε, fun _ h => hf2 _ h⟩
|
Analysis\RCLike\Basic.lean | /-
Copyright (c) 2020 Frédéric Dupuis. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Frédéric Dupuis
-/
import Mathlib.Algebra.Star.Order
import Mathlib.Analysis.CStarAlgebra.Basic
import Mathlib.Analysis.Normed.Operator.ContinuousLinearMap
import Mathlib.Analysis.Normed.Module.Basic
import Mathlib.Data.Real.Sqrt
import Mathlib.Algebra.Algebra.Field
/-!
# `RCLike`: a typeclass for ℝ or ℂ
This file defines the typeclass `RCLike` intended to have only two instances:
ℝ and ℂ. It is meant for definitions and theorems which hold for both the real and the complex case,
and in particular when the real case follows directly from the complex case by setting `re` to `id`,
`im` to zero and so on. Its API follows closely that of ℂ.
Applications include defining inner products and Hilbert spaces for both the real and
complex case. One typically produces the definitions and proof for an arbitrary field of this
typeclass, which basically amounts to doing the complex case, and the two cases then fall out
immediately from the two instances of the class.
The instance for `ℝ` is registered in this file.
The instance for `ℂ` is declared in `Mathlib/Analysis/Complex/Basic.lean`.
## Implementation notes
The coercion from reals into an `RCLike` field is done by registering `RCLike.ofReal` as
a `CoeTC`. For this to work, we must proceed carefully to avoid problems involving circular
coercions in the case `K=ℝ`; in particular, we cannot use the plain `Coe` and must set
priorities carefully. This problem was already solved for `ℕ`, and we copy the solution detailed
in `Mathlib/Data/Nat/Cast/Defs.lean`. See also Note [coercion into rings] for more details.
In addition, several lemmas need to be set at priority 900 to make sure that they do not override
their counterparts in `Mathlib/Analysis/Complex/Basic.lean` (which causes linter errors).
A few lemmas requiring heavier imports are in `Mathlib/Data/RCLike/Lemmas.lean`.
-/
section
local notation "𝓚" => algebraMap ℝ _
open ComplexConjugate
/--
This typeclass captures properties shared by ℝ and ℂ, with an API that closely matches that of ℂ.
-/
class RCLike (K : semiOutParam Type*) extends DenselyNormedField K, StarRing K,
NormedAlgebra ℝ K, CompleteSpace K where
re : K →+ ℝ
im : K →+ ℝ
/-- Imaginary unit in `K`. Meant to be set to `0` for `K = ℝ`. -/
I : K
I_re_ax : re I = 0
I_mul_I_ax : I = 0 ∨ I * I = -1
re_add_im_ax : ∀ z : K, 𝓚 (re z) + 𝓚 (im z) * I = z
ofReal_re_ax : ∀ r : ℝ, re (𝓚 r) = r
ofReal_im_ax : ∀ r : ℝ, im (𝓚 r) = 0
mul_re_ax : ∀ z w : K, re (z * w) = re z * re w - im z * im w
mul_im_ax : ∀ z w : K, im (z * w) = re z * im w + im z * re w
conj_re_ax : ∀ z : K, re (conj z) = re z
conj_im_ax : ∀ z : K, im (conj z) = -im z
conj_I_ax : conj I = -I
norm_sq_eq_def_ax : ∀ z : K, ‖z‖ ^ 2 = re z * re z + im z * im z
mul_im_I_ax : ∀ z : K, im z * im I = im z
/-- only an instance in the `ComplexOrder` locale -/
[toPartialOrder : PartialOrder K]
le_iff_re_im {z w : K} : z ≤ w ↔ re z ≤ re w ∧ im z = im w
-- note we cannot put this in the `extends` clause
[toDecidableEq : DecidableEq K]
scoped[ComplexOrder] attribute [instance 100] RCLike.toPartialOrder
attribute [instance 100] RCLike.toDecidableEq
end
variable {K E : Type*} [RCLike K]
namespace RCLike
open ComplexConjugate
/-- Coercion from `ℝ` to an `RCLike` field. -/
@[coe] abbrev ofReal : ℝ → K := Algebra.cast
/- The priority must be set at 900 to ensure that coercions are tried in the right order.
See Note [coercion into rings], or `Mathlib/Data/Nat/Cast/Basic.lean` for more details. -/
noncomputable instance (priority := 900) algebraMapCoe : CoeTC ℝ K :=
⟨ofReal⟩
theorem ofReal_alg (x : ℝ) : (x : K) = x • (1 : K) :=
Algebra.algebraMap_eq_smul_one x
theorem real_smul_eq_coe_mul (r : ℝ) (z : K) : r • z = (r : K) * z :=
Algebra.smul_def r z
theorem real_smul_eq_coe_smul [AddCommGroup E] [Module K E] [Module ℝ E] [IsScalarTower ℝ K E]
(r : ℝ) (x : E) : r • x = (r : K) • x := by rw [RCLike.ofReal_alg, smul_one_smul]
theorem algebraMap_eq_ofReal : ⇑(algebraMap ℝ K) = ofReal :=
rfl
@[simp, rclike_simps]
theorem re_add_im (z : K) : (re z : K) + im z * I = z :=
RCLike.re_add_im_ax z
@[simp, norm_cast, rclike_simps]
theorem ofReal_re : ∀ r : ℝ, re (r : K) = r :=
RCLike.ofReal_re_ax
@[simp, norm_cast, rclike_simps]
theorem ofReal_im : ∀ r : ℝ, im (r : K) = 0 :=
RCLike.ofReal_im_ax
@[simp, rclike_simps]
theorem mul_re : ∀ z w : K, re (z * w) = re z * re w - im z * im w :=
RCLike.mul_re_ax
@[simp, rclike_simps]
theorem mul_im : ∀ z w : K, im (z * w) = re z * im w + im z * re w :=
RCLike.mul_im_ax
theorem ext_iff {z w : K} : z = w ↔ re z = re w ∧ im z = im w :=
⟨fun h => h ▸ ⟨rfl, rfl⟩, fun ⟨h₁, h₂⟩ => re_add_im z ▸ re_add_im w ▸ h₁ ▸ h₂ ▸ rfl⟩
theorem ext {z w : K} (hre : re z = re w) (him : im z = im w) : z = w :=
ext_iff.2 ⟨hre, him⟩
@[norm_cast]
theorem ofReal_zero : ((0 : ℝ) : K) = 0 :=
algebraMap.coe_zero
@[rclike_simps]
theorem zero_re' : re (0 : K) = (0 : ℝ) :=
map_zero re
@[norm_cast]
theorem ofReal_one : ((1 : ℝ) : K) = 1 :=
map_one (algebraMap ℝ K)
@[simp, rclike_simps]
theorem one_re : re (1 : K) = 1 := by rw [← ofReal_one, ofReal_re]
@[simp, rclike_simps]
theorem one_im : im (1 : K) = 0 := by rw [← ofReal_one, ofReal_im]
theorem ofReal_injective : Function.Injective ((↑) : ℝ → K) :=
(algebraMap ℝ K).injective
@[norm_cast]
theorem ofReal_inj {z w : ℝ} : (z : K) = (w : K) ↔ z = w :=
algebraMap.coe_inj
-- replaced by `RCLike.ofNat_re`
-- replaced by `RCLike.ofNat_im`
theorem ofReal_eq_zero {x : ℝ} : (x : K) = 0 ↔ x = 0 :=
algebraMap.lift_map_eq_zero_iff x
theorem ofReal_ne_zero {x : ℝ} : (x : K) ≠ 0 ↔ x ≠ 0 :=
ofReal_eq_zero.not
@[rclike_simps, norm_cast]
theorem ofReal_add (r s : ℝ) : ((r + s : ℝ) : K) = r + s :=
algebraMap.coe_add _ _
-- replaced by `RCLike.ofReal_ofNat`
@[rclike_simps, norm_cast]
theorem ofReal_neg (r : ℝ) : ((-r : ℝ) : K) = -r :=
algebraMap.coe_neg r
@[rclike_simps, norm_cast]
theorem ofReal_sub (r s : ℝ) : ((r - s : ℝ) : K) = r - s :=
map_sub (algebraMap ℝ K) r s
@[rclike_simps, norm_cast]
theorem ofReal_sum {α : Type*} (s : Finset α) (f : α → ℝ) :
((∑ i ∈ s, f i : ℝ) : K) = ∑ i ∈ s, (f i : K) :=
map_sum (algebraMap ℝ K) _ _
@[simp, rclike_simps, norm_cast]
theorem ofReal_finsupp_sum {α M : Type*} [Zero M] (f : α →₀ M) (g : α → M → ℝ) :
((f.sum fun a b => g a b : ℝ) : K) = f.sum fun a b => (g a b : K) :=
map_finsupp_sum (algebraMap ℝ K) f g
@[rclike_simps, norm_cast]
theorem ofReal_mul (r s : ℝ) : ((r * s : ℝ) : K) = r * s :=
algebraMap.coe_mul _ _
@[rclike_simps, norm_cast]
theorem ofReal_pow (r : ℝ) (n : ℕ) : ((r ^ n : ℝ) : K) = (r : K) ^ n :=
map_pow (algebraMap ℝ K) r n
@[rclike_simps, norm_cast]
theorem ofReal_prod {α : Type*} (s : Finset α) (f : α → ℝ) :
((∏ i ∈ s, f i : ℝ) : K) = ∏ i ∈ s, (f i : K) :=
map_prod (algebraMap ℝ K) _ _
@[simp, rclike_simps, norm_cast]
theorem ofReal_finsupp_prod {α M : Type*} [Zero M] (f : α →₀ M) (g : α → M → ℝ) :
((f.prod fun a b => g a b : ℝ) : K) = f.prod fun a b => (g a b : K) :=
map_finsupp_prod _ f g
@[simp, norm_cast, rclike_simps]
theorem real_smul_ofReal (r x : ℝ) : r • (x : K) = (r : K) * (x : K) :=
real_smul_eq_coe_mul _ _
@[rclike_simps]
theorem re_ofReal_mul (r : ℝ) (z : K) : re (↑r * z) = r * re z := by
simp only [mul_re, ofReal_im, zero_mul, ofReal_re, sub_zero]
@[rclike_simps]
theorem im_ofReal_mul (r : ℝ) (z : K) : im (↑r * z) = r * im z := by
simp only [add_zero, ofReal_im, zero_mul, ofReal_re, mul_im]
@[rclike_simps]
theorem smul_re (r : ℝ) (z : K) : re (r • z) = r * re z := by
rw [real_smul_eq_coe_mul, re_ofReal_mul]
@[rclike_simps]
theorem smul_im (r : ℝ) (z : K) : im (r • z) = r * im z := by
rw [real_smul_eq_coe_mul, im_ofReal_mul]
@[rclike_simps, norm_cast]
theorem norm_ofReal (r : ℝ) : ‖(r : K)‖ = |r| :=
norm_algebraMap' K r
/-! ### Characteristic zero -/
-- see Note [lower instance priority]
/-- ℝ and ℂ are both of characteristic zero. -/
instance (priority := 100) charZero_rclike : CharZero K :=
(RingHom.charZero_iff (algebraMap ℝ K).injective).1 inferInstance
/-! ### The imaginary unit, `I` -/
/-- The imaginary unit. -/
@[simp, rclike_simps]
theorem I_re : re (I : K) = 0 :=
I_re_ax
@[simp, rclike_simps]
theorem I_im (z : K) : im z * im (I : K) = im z :=
mul_im_I_ax z
@[simp, rclike_simps]
theorem I_im' (z : K) : im (I : K) * im z = im z := by rw [mul_comm, I_im]
@[rclike_simps] -- porting note (#10618): was `simp`
theorem I_mul_re (z : K) : re (I * z) = -im z := by
simp only [I_re, zero_sub, I_im', zero_mul, mul_re]
theorem I_mul_I : (I : K) = 0 ∨ (I : K) * I = -1 :=
I_mul_I_ax
variable (𝕜) in
lemma I_eq_zero_or_im_I_eq_one : (I : K) = 0 ∨ im (I : K) = 1 :=
I_mul_I (K := K) |>.imp_right fun h ↦ by simpa [h] using (I_mul_re (I : K)).symm
@[simp, rclike_simps]
theorem conj_re (z : K) : re (conj z) = re z :=
RCLike.conj_re_ax z
@[simp, rclike_simps]
theorem conj_im (z : K) : im (conj z) = -im z :=
RCLike.conj_im_ax z
@[simp, rclike_simps]
theorem conj_I : conj (I : K) = -I :=
RCLike.conj_I_ax
@[simp, rclike_simps]
theorem conj_ofReal (r : ℝ) : conj (r : K) = (r : K) := by
rw [ext_iff]
simp only [ofReal_im, conj_im, eq_self_iff_true, conj_re, and_self_iff, neg_zero]
-- replaced by `RCLike.conj_ofNat`
theorem conj_nat_cast (n : ℕ) : conj (n : K) = n := map_natCast _ _
-- See note [no_index around OfNat.ofNat]
theorem conj_ofNat (n : ℕ) [n.AtLeastTwo] : conj (no_index (OfNat.ofNat n : K)) = OfNat.ofNat n :=
map_ofNat _ _
@[rclike_simps] -- Porting note (#10618): was a `simp` but `simp` can prove it
theorem conj_neg_I : conj (-I) = (I : K) := by rw [map_neg, conj_I, neg_neg]
theorem conj_eq_re_sub_im (z : K) : conj z = re z - im z * I :=
(congr_arg conj (re_add_im z).symm).trans <| by
rw [map_add, map_mul, conj_I, conj_ofReal, conj_ofReal, mul_neg, sub_eq_add_neg]
theorem sub_conj (z : K) : z - conj z = 2 * im z * I :=
calc
z - conj z = re z + im z * I - (re z - im z * I) := by rw [re_add_im, ← conj_eq_re_sub_im]
_ = 2 * im z * I := by rw [add_sub_sub_cancel, ← two_mul, mul_assoc]
@[rclike_simps]
theorem conj_smul (r : ℝ) (z : K) : conj (r • z) = r • conj z := by
rw [conj_eq_re_sub_im, conj_eq_re_sub_im, smul_re, smul_im, ofReal_mul, ofReal_mul,
real_smul_eq_coe_mul r (_ - _), mul_sub, mul_assoc]
theorem add_conj (z : K) : z + conj z = 2 * re z :=
calc
z + conj z = re z + im z * I + (re z - im z * I) := by rw [re_add_im, conj_eq_re_sub_im]
_ = 2 * re z := by rw [add_add_sub_cancel, two_mul]
theorem re_eq_add_conj (z : K) : ↑(re z) = (z + conj z) / 2 := by
rw [add_conj, mul_div_cancel_left₀ (re z : K) two_ne_zero]
theorem im_eq_conj_sub (z : K) : ↑(im z) = I * (conj z - z) / 2 := by
rw [← neg_inj, ← ofReal_neg, ← I_mul_re, re_eq_add_conj, map_mul, conj_I, ← neg_div, ← mul_neg,
neg_sub, mul_sub, neg_mul, sub_eq_add_neg]
open List in
/-- There are several equivalent ways to say that a number `z` is in fact a real number. -/
theorem is_real_TFAE (z : K) : TFAE [conj z = z, ∃ r : ℝ, (r : K) = z, ↑(re z) = z, im z = 0] := by
tfae_have 1 → 4
· intro h
rw [← @ofReal_inj K, im_eq_conj_sub, h, sub_self, mul_zero, zero_div,
ofReal_zero]
tfae_have 4 → 3
· intro h
conv_rhs => rw [← re_add_im z, h, ofReal_zero, zero_mul, add_zero]
tfae_have 3 → 2
· exact fun h => ⟨_, h⟩
tfae_have 2 → 1
· exact fun ⟨r, hr⟩ => hr ▸ conj_ofReal _
tfae_finish
theorem conj_eq_iff_real {z : K} : conj z = z ↔ ∃ r : ℝ, z = (r : K) :=
((is_real_TFAE z).out 0 1).trans <| by simp only [eq_comm]
theorem conj_eq_iff_re {z : K} : conj z = z ↔ (re z : K) = z :=
(is_real_TFAE z).out 0 2
theorem conj_eq_iff_im {z : K} : conj z = z ↔ im z = 0 :=
(is_real_TFAE z).out 0 3
@[simp]
theorem star_def : (Star.star : K → K) = conj :=
rfl
variable (K)
/-- Conjugation as a ring equivalence. This is used to convert the inner product into a
sesquilinear product. -/
abbrev conjToRingEquiv : K ≃+* Kᵐᵒᵖ :=
starRingEquiv
variable {K} {z : K}
/-- The norm squared function. -/
def normSq : K →*₀ ℝ where
toFun z := re z * re z + im z * im z
map_zero' := by simp only [add_zero, mul_zero, map_zero]
map_one' := by simp only [one_im, add_zero, mul_one, one_re, mul_zero]
map_mul' z w := by
simp only [mul_im, mul_re]
ring
theorem normSq_apply (z : K) : normSq z = re z * re z + im z * im z :=
rfl
theorem norm_sq_eq_def {z : K} : ‖z‖ ^ 2 = re z * re z + im z * im z :=
norm_sq_eq_def_ax z
theorem normSq_eq_def' (z : K) : normSq z = ‖z‖ ^ 2 :=
norm_sq_eq_def.symm
@[rclike_simps]
theorem normSq_zero : normSq (0 : K) = 0 :=
normSq.map_zero
@[rclike_simps]
theorem normSq_one : normSq (1 : K) = 1 :=
normSq.map_one
theorem normSq_nonneg (z : K) : 0 ≤ normSq z :=
add_nonneg (mul_self_nonneg _) (mul_self_nonneg _)
@[rclike_simps] -- porting note (#10618): was `simp`
theorem normSq_eq_zero {z : K} : normSq z = 0 ↔ z = 0 :=
map_eq_zero _
@[simp, rclike_simps]
theorem normSq_pos {z : K} : 0 < normSq z ↔ z ≠ 0 := by
rw [lt_iff_le_and_ne, Ne, eq_comm]; simp [normSq_nonneg]
@[simp, rclike_simps]
theorem normSq_neg (z : K) : normSq (-z) = normSq z := by simp only [normSq_eq_def', norm_neg]
@[simp, rclike_simps]
theorem normSq_conj (z : K) : normSq (conj z) = normSq z := by
simp only [normSq_apply, neg_mul, mul_neg, neg_neg, rclike_simps]
@[rclike_simps] -- porting note (#10618): was `simp`
theorem normSq_mul (z w : K) : normSq (z * w) = normSq z * normSq w :=
map_mul _ z w
theorem normSq_add (z w : K) : normSq (z + w) = normSq z + normSq w + 2 * re (z * conj w) := by
simp only [normSq_apply, map_add, rclike_simps]
ring
theorem re_sq_le_normSq (z : K) : re z * re z ≤ normSq z :=
le_add_of_nonneg_right (mul_self_nonneg _)
theorem im_sq_le_normSq (z : K) : im z * im z ≤ normSq z :=
le_add_of_nonneg_left (mul_self_nonneg _)
theorem mul_conj (z : K) : z * conj z = ‖z‖ ^ 2 := by
apply ext <;> simp [← ofReal_pow, norm_sq_eq_def, mul_comm]
theorem conj_mul (z : K) : conj z * z = ‖z‖ ^ 2 := by rw [mul_comm, mul_conj]
lemma inv_eq_conj (hz : ‖z‖ = 1) : z⁻¹ = conj z :=
inv_eq_of_mul_eq_one_left $ by simp_rw [conj_mul, hz, algebraMap.coe_one, one_pow]
theorem normSq_sub (z w : K) : normSq (z - w) = normSq z + normSq w - 2 * re (z * conj w) := by
simp only [normSq_add, sub_eq_add_neg, map_neg, mul_neg, normSq_neg, map_neg]
theorem sqrt_normSq_eq_norm {z : K} : √(normSq z) = ‖z‖ := by
rw [normSq_eq_def', Real.sqrt_sq (norm_nonneg _)]
/-! ### Inversion -/
@[rclike_simps, norm_cast]
theorem ofReal_inv (r : ℝ) : ((r⁻¹ : ℝ) : K) = (r : K)⁻¹ :=
map_inv₀ _ r
theorem inv_def (z : K) : z⁻¹ = conj z * ((‖z‖ ^ 2)⁻¹ : ℝ) := by
rcases eq_or_ne z 0 with (rfl | h₀)
· simp
· apply inv_eq_of_mul_eq_one_right
rw [← mul_assoc, mul_conj, ofReal_inv, ofReal_pow, mul_inv_cancel]
simpa
@[simp, rclike_simps]
theorem inv_re (z : K) : re z⁻¹ = re z / normSq z := by
rw [inv_def, normSq_eq_def', mul_comm, re_ofReal_mul, conj_re, div_eq_inv_mul]
@[simp, rclike_simps]
theorem inv_im (z : K) : im z⁻¹ = -im z / normSq z := by
rw [inv_def, normSq_eq_def', mul_comm, im_ofReal_mul, conj_im, div_eq_inv_mul]
theorem div_re (z w : K) : re (z / w) = re z * re w / normSq w + im z * im w / normSq w := by
simp only [div_eq_mul_inv, mul_assoc, sub_eq_add_neg, neg_mul, mul_neg, neg_neg, map_neg,
rclike_simps]
theorem div_im (z w : K) : im (z / w) = im z * re w / normSq w - re z * im w / normSq w := by
simp only [div_eq_mul_inv, mul_assoc, sub_eq_add_neg, add_comm, neg_mul, mul_neg, map_neg,
rclike_simps]
@[rclike_simps] -- porting note (#10618): was `simp`
theorem conj_inv (x : K) : conj x⁻¹ = (conj x)⁻¹ :=
star_inv' _
lemma conj_div (x y : K) : conj (x / y) = conj x / conj y := map_div' conj conj_inv _ _
--TODO: Do we rather want the map as an explicit definition?
lemma exists_norm_eq_mul_self (x : K) : ∃ c, ‖c‖ = 1 ∧ ↑‖x‖ = c * x := by
obtain rfl | hx := eq_or_ne x 0
· exact ⟨1, by simp⟩
· exact ⟨‖x‖ / x, by simp [norm_ne_zero_iff.2, hx]⟩
lemma exists_norm_mul_eq_self (x : K) : ∃ c, ‖c‖ = 1 ∧ c * ‖x‖ = x := by
obtain rfl | hx := eq_or_ne x 0
· exact ⟨1, by simp⟩
· exact ⟨x / ‖x‖, by simp [norm_ne_zero_iff.2, hx]⟩
@[rclike_simps, norm_cast]
theorem ofReal_div (r s : ℝ) : ((r / s : ℝ) : K) = r / s :=
map_div₀ (algebraMap ℝ K) r s
theorem div_re_ofReal {z : K} {r : ℝ} : re (z / r) = re z / r := by
rw [div_eq_inv_mul, div_eq_inv_mul, ← ofReal_inv, re_ofReal_mul]
@[rclike_simps, norm_cast]
theorem ofReal_zpow (r : ℝ) (n : ℤ) : ((r ^ n : ℝ) : K) = (r : K) ^ n :=
map_zpow₀ (algebraMap ℝ K) r n
theorem I_mul_I_of_nonzero : (I : K) ≠ 0 → (I : K) * I = -1 :=
I_mul_I_ax.resolve_left
@[simp, rclike_simps]
theorem inv_I : (I : K)⁻¹ = -I := by
by_cases h : (I : K) = 0
· simp [h]
· field_simp [I_mul_I_of_nonzero h]
@[simp, rclike_simps]
theorem div_I (z : K) : z / I = -(z * I) := by rw [div_eq_mul_inv, inv_I, mul_neg]
@[rclike_simps] -- porting note (#10618): was `simp`
theorem normSq_inv (z : K) : normSq z⁻¹ = (normSq z)⁻¹ :=
map_inv₀ normSq z
@[rclike_simps] -- porting note (#10618): was `simp`
theorem normSq_div (z w : K) : normSq (z / w) = normSq z / normSq w :=
map_div₀ normSq z w
@[rclike_simps] -- porting note (#10618): was `simp`
theorem norm_conj {z : K} : ‖conj z‖ = ‖z‖ := by simp only [← sqrt_normSq_eq_norm, normSq_conj]
instance (priority := 100) : CStarRing K where
norm_mul_self_le x := le_of_eq <| ((norm_mul _ _).trans <| congr_arg (· * ‖x‖) norm_conj).symm
/-! ### Cast lemmas -/
@[rclike_simps, norm_cast]
theorem ofReal_natCast (n : ℕ) : ((n : ℝ) : K) = n :=
map_natCast (algebraMap ℝ K) n
@[simp, rclike_simps] -- Porting note: removed `norm_cast`
theorem natCast_re (n : ℕ) : re (n : K) = n := by rw [← ofReal_natCast, ofReal_re]
@[simp, rclike_simps, norm_cast]
theorem natCast_im (n : ℕ) : im (n : K) = 0 := by rw [← ofReal_natCast, ofReal_im]
-- See note [no_index around OfNat.ofNat]
@[simp, rclike_simps]
theorem ofNat_re (n : ℕ) [n.AtLeastTwo] : re (no_index (OfNat.ofNat n) : K) = OfNat.ofNat n :=
natCast_re n
-- See note [no_index around OfNat.ofNat]
@[simp, rclike_simps]
theorem ofNat_im (n : ℕ) [n.AtLeastTwo] : im (no_index (OfNat.ofNat n) : K) = 0 :=
natCast_im n
-- See note [no_index around OfNat.ofNat]
@[rclike_simps, norm_cast]
theorem ofReal_ofNat (n : ℕ) [n.AtLeastTwo] :
((no_index (OfNat.ofNat n) : ℝ) : K) = OfNat.ofNat n :=
ofReal_natCast n
theorem ofNat_mul_re (n : ℕ) [n.AtLeastTwo] (z : K) :
re (OfNat.ofNat n * z) = OfNat.ofNat n * re z := by
rw [← ofReal_ofNat, re_ofReal_mul]
theorem ofNat_mul_im (n : ℕ) [n.AtLeastTwo] (z : K) :
im (OfNat.ofNat n * z) = OfNat.ofNat n * im z := by
rw [← ofReal_ofNat, im_ofReal_mul]
@[rclike_simps, norm_cast]
theorem ofReal_intCast (n : ℤ) : ((n : ℝ) : K) = n :=
map_intCast _ n
@[simp, rclike_simps] -- Porting note: removed `norm_cast`
theorem intCast_re (n : ℤ) : re (n : K) = n := by rw [← ofReal_intCast, ofReal_re]
@[simp, rclike_simps, norm_cast]
theorem intCast_im (n : ℤ) : im (n : K) = 0 := by rw [← ofReal_intCast, ofReal_im]
@[rclike_simps, norm_cast]
theorem ofReal_ratCast (n : ℚ) : ((n : ℝ) : K) = n :=
map_ratCast _ n
@[simp, rclike_simps] -- Porting note: removed `norm_cast`
theorem ratCast_re (q : ℚ) : re (q : K) = q := by rw [← ofReal_ratCast, ofReal_re]
@[simp, rclike_simps, norm_cast]
theorem ratCast_im (q : ℚ) : im (q : K) = 0 := by rw [← ofReal_ratCast, ofReal_im]
/-! ### Norm -/
theorem norm_of_nonneg {r : ℝ} (h : 0 ≤ r) : ‖(r : K)‖ = r :=
(norm_ofReal _).trans (abs_of_nonneg h)
@[simp, rclike_simps, norm_cast]
theorem norm_natCast (n : ℕ) : ‖(n : K)‖ = n := by
rw [← ofReal_natCast]
exact norm_of_nonneg (Nat.cast_nonneg n)
@[simp, rclike_simps]
theorem norm_ofNat (n : ℕ) [n.AtLeastTwo] : ‖(no_index (OfNat.ofNat n) : K)‖ = OfNat.ofNat n :=
norm_natCast n
variable (K) in
lemma norm_nsmul [NormedAddCommGroup E] [NormedSpace K E] (n : ℕ) (x : E) : ‖n • x‖ = n • ‖x‖ := by
rw [← Nat.cast_smul_eq_nsmul K, norm_smul, RCLike.norm_natCast, nsmul_eq_mul]
theorem mul_self_norm (z : K) : ‖z‖ * ‖z‖ = normSq z := by rw [normSq_eq_def', sq]
attribute [rclike_simps] norm_zero norm_one norm_eq_zero abs_norm norm_inv norm_div
-- Porting note: removed @[simp, rclike_simps], b/c generalized to `norm_ofNat`
theorem norm_two : ‖(2 : K)‖ = 2 := norm_ofNat 2
theorem abs_re_le_norm (z : K) : |re z| ≤ ‖z‖ := by
rw [mul_self_le_mul_self_iff (abs_nonneg _) (norm_nonneg _), abs_mul_abs_self, mul_self_norm]
apply re_sq_le_normSq
theorem abs_im_le_norm (z : K) : |im z| ≤ ‖z‖ := by
rw [mul_self_le_mul_self_iff (abs_nonneg _) (norm_nonneg _), abs_mul_abs_self, mul_self_norm]
apply im_sq_le_normSq
theorem norm_re_le_norm (z : K) : ‖re z‖ ≤ ‖z‖ :=
abs_re_le_norm z
theorem norm_im_le_norm (z : K) : ‖im z‖ ≤ ‖z‖ :=
abs_im_le_norm z
theorem re_le_norm (z : K) : re z ≤ ‖z‖ :=
(abs_le.1 (abs_re_le_norm z)).2
theorem im_le_norm (z : K) : im z ≤ ‖z‖ :=
(abs_le.1 (abs_im_le_norm _)).2
theorem im_eq_zero_of_le {a : K} (h : ‖a‖ ≤ re a) : im a = 0 := by
simpa only [mul_self_norm a, normSq_apply, self_eq_add_right, mul_self_eq_zero]
using congr_arg (fun z => z * z) ((re_le_norm a).antisymm h)
theorem re_eq_self_of_le {a : K} (h : ‖a‖ ≤ re a) : (re a : K) = a := by
rw [← conj_eq_iff_re, conj_eq_iff_im, im_eq_zero_of_le h]
open IsAbsoluteValue
theorem abs_re_div_norm_le_one (z : K) : |re z / ‖z‖| ≤ 1 := by
rw [abs_div, abs_norm]
exact div_le_one_of_le (abs_re_le_norm _) (norm_nonneg _)
theorem abs_im_div_norm_le_one (z : K) : |im z / ‖z‖| ≤ 1 := by
rw [abs_div, abs_norm]
exact div_le_one_of_le (abs_im_le_norm _) (norm_nonneg _)
theorem norm_I_of_ne_zero (hI : (I : K) ≠ 0) : ‖(I : K)‖ = 1 := by
rw [← mul_self_inj_of_nonneg (norm_nonneg I) zero_le_one, one_mul, ← norm_mul,
I_mul_I_of_nonzero hI, norm_neg, norm_one]
theorem re_eq_norm_of_mul_conj (x : K) : re (x * conj x) = ‖x * conj x‖ := by
rw [mul_conj, ← ofReal_pow]; simp [-map_pow]
theorem norm_sq_re_add_conj (x : K) : ‖x + conj x‖ ^ 2 = re (x + conj x) ^ 2 := by
rw [add_conj, ← ofReal_ofNat, ← ofReal_mul, norm_ofReal, sq_abs, ofReal_re]
theorem norm_sq_re_conj_add (x : K) : ‖conj x + x‖ ^ 2 = re (conj x + x) ^ 2 := by
rw [add_comm, norm_sq_re_add_conj]
/-! ### Cauchy sequences -/
theorem isCauSeq_re (f : CauSeq K norm) : IsCauSeq abs fun n => re (f n) := fun ε ε0 =>
(f.cauchy ε0).imp fun i H j ij =>
lt_of_le_of_lt (by simpa only [map_sub] using abs_re_le_norm (f j - f i)) (H _ ij)
theorem isCauSeq_im (f : CauSeq K norm) : IsCauSeq abs fun n => im (f n) := fun ε ε0 =>
(f.cauchy ε0).imp fun i H j ij =>
lt_of_le_of_lt (by simpa only [map_sub] using abs_im_le_norm (f j - f i)) (H _ ij)
/-- The real part of a K Cauchy sequence, as a real Cauchy sequence. -/
noncomputable def cauSeqRe (f : CauSeq K norm) : CauSeq ℝ abs :=
⟨_, isCauSeq_re f⟩
/-- The imaginary part of a K Cauchy sequence, as a real Cauchy sequence. -/
noncomputable def cauSeqIm (f : CauSeq K norm) : CauSeq ℝ abs :=
⟨_, isCauSeq_im f⟩
theorem isCauSeq_norm {f : ℕ → K} (hf : IsCauSeq norm f) : IsCauSeq abs (norm ∘ f) := fun ε ε0 =>
let ⟨i, hi⟩ := hf ε ε0
⟨i, fun j hj => lt_of_le_of_lt (abs_norm_sub_norm_le _ _) (hi j hj)⟩
end RCLike
section Instances
noncomputable instance Real.RCLike : RCLike ℝ where
re := AddMonoidHom.id ℝ
im := 0
I := 0
I_re_ax := by simp only [AddMonoidHom.map_zero]
I_mul_I_ax := Or.intro_left _ rfl
re_add_im_ax z := by
simp only [add_zero, mul_zero, Algebra.id.map_eq_id, RingHom.id_apply, AddMonoidHom.id_apply]
ofReal_re_ax f := rfl
ofReal_im_ax r := rfl
mul_re_ax z w := by simp only [sub_zero, mul_zero, AddMonoidHom.zero_apply, AddMonoidHom.id_apply]
mul_im_ax z w := by simp only [add_zero, zero_mul, mul_zero, AddMonoidHom.zero_apply]
conj_re_ax z := by simp only [starRingEnd_apply, star_id_of_comm]
conj_im_ax _ := by simp only [neg_zero, AddMonoidHom.zero_apply]
conj_I_ax := by simp only [RingHom.map_zero, neg_zero]
norm_sq_eq_def_ax z := by simp only [sq, Real.norm_eq_abs, ← abs_mul, abs_mul_self z, add_zero,
mul_zero, AddMonoidHom.zero_apply, AddMonoidHom.id_apply]
mul_im_I_ax _ := by simp only [mul_zero, AddMonoidHom.zero_apply]
le_iff_re_im := (and_iff_left rfl).symm
end Instances
namespace RCLike
section Order
open scoped ComplexOrder
variable {z w : K}
theorem lt_iff_re_im : z < w ↔ re z < re w ∧ im z = im w := by
simp_rw [lt_iff_le_and_ne, @RCLike.le_iff_re_im K]
constructor
· rintro ⟨⟨hr, hi⟩, heq⟩
exact ⟨⟨hr, mt (fun hreq => ext hreq hi) heq⟩, hi⟩
· rintro ⟨⟨hr, hrn⟩, hi⟩
exact ⟨⟨hr, hi⟩, ne_of_apply_ne _ hrn⟩
theorem nonneg_iff : 0 ≤ z ↔ 0 ≤ re z ∧ im z = 0 := by
simpa only [map_zero, eq_comm] using le_iff_re_im (z := 0) (w := z)
theorem pos_iff : 0 < z ↔ 0 < re z ∧ im z = 0 := by
simpa only [map_zero, eq_comm] using lt_iff_re_im (z := 0) (w := z)
theorem nonpos_iff : z ≤ 0 ↔ re z ≤ 0 ∧ im z = 0 := by
simpa only [map_zero] using le_iff_re_im (z := z) (w := 0)
theorem neg_iff : z < 0 ↔ re z < 0 ∧ im z = 0 := by
simpa only [map_zero] using lt_iff_re_im (z := z) (w := 0)
lemma nonneg_iff_exists_ofReal : 0 ≤ z ↔ ∃ x ≥ (0 : ℝ), x = z := by
simp_rw [nonneg_iff (K := K), ext_iff (K := K)]; aesop
lemma pos_iff_exists_ofReal : 0 < z ↔ ∃ x > (0 : ℝ), x = z := by
simp_rw [pos_iff (K := K), ext_iff (K := K)]; aesop
lemma nonpos_iff_exists_ofReal : z ≤ 0 ↔ ∃ x ≤ (0 : ℝ), x = z := by
simp_rw [nonpos_iff (K := K), ext_iff (K := K)]; aesop
lemma neg_iff_exists_ofReal : z < 0 ↔ ∃ x < (0 : ℝ), x = z := by
simp_rw [neg_iff (K := K), ext_iff (K := K)]; aesop
@[simp, norm_cast]
lemma ofReal_le_ofReal {x y : ℝ} : (x : K) ≤ (y : K) ↔ x ≤ y := by
rw [le_iff_re_im]
simp
@[simp, norm_cast]
lemma ofReal_lt_ofReal {x y : ℝ} : (x : K) < (y : K) ↔ x < y := by
rw [lt_iff_re_im]
simp
@[simp, norm_cast]
lemma ofReal_nonneg {x : ℝ} : 0 ≤ (x : K) ↔ 0 ≤ x := by
rw [← ofReal_zero, ofReal_le_ofReal]
@[simp, norm_cast]
lemma ofReal_nonpos {x : ℝ} : (x : K) ≤ 0 ↔ x ≤ 0 := by
rw [← ofReal_zero, ofReal_le_ofReal]
@[simp, norm_cast]
lemma ofReal_pos {x : ℝ} : 0 < (x : K) ↔ 0 < x := by
rw [← ofReal_zero, ofReal_lt_ofReal]
@[simp, norm_cast]
lemma ofReal_lt_zero {x : ℝ} : (x : K) < 0 ↔ x < 0 := by
rw [← ofReal_zero, ofReal_lt_ofReal]
protected lemma inv_pos_of_pos (hz : 0 < z) : 0 < z⁻¹ := by
rw [pos_iff_exists_ofReal] at hz
obtain ⟨x, hx, hx'⟩ := hz
rw [← hx', ← ofReal_inv, ofReal_pos]
exact inv_pos_of_pos hx
protected lemma inv_pos : 0 < z⁻¹ ↔ 0 < z := by
refine ⟨fun h => ?_, fun h => RCLike.inv_pos_of_pos h⟩
rw [← inv_inv z]
exact RCLike.inv_pos_of_pos h
/-- With `z ≤ w` iff `w - z` is real and nonnegative, `ℝ` and `ℂ` are star ordered rings.
(That is, a star ring in which the nonnegative elements are those of the form `star z * z`.)
Note this is only an instance with `open scoped ComplexOrder`. -/
lemma toStarOrderedRing : StarOrderedRing K :=
StarOrderedRing.of_nonneg_iff'
(h_add := fun {x y} hxy z => by
rw [RCLike.le_iff_re_im] at *
simpa [map_add, add_le_add_iff_left, add_right_inj] using hxy)
(h_nonneg_iff := fun x => by
rw [nonneg_iff]
refine ⟨fun h ↦ ⟨√(re x), by simp [ext_iff (K := K), h.1, h.2]⟩, ?_⟩
rintro ⟨s, rfl⟩
simp [mul_comm, mul_self_nonneg, add_nonneg])
scoped[ComplexOrder] attribute [instance] RCLike.toStarOrderedRing
/-- With `z ≤ w` iff `w - z` is real and nonnegative, `ℝ` and `ℂ` are strictly ordered rings.
Note this is only an instance with `open scoped ComplexOrder`. -/
def toStrictOrderedCommRing : StrictOrderedCommRing K where
zero_le_one := by simp [@RCLike.le_iff_re_im K]
add_le_add_left _ _ := add_le_add_left
mul_pos z w hz hw := by
rw [lt_iff_re_im, map_zero] at hz hw ⊢
simp [mul_re, mul_im, ← hz.2, ← hw.2, mul_pos hz.1 hw.1]
mul_comm := by intros; apply ext <;> ring_nf
scoped[ComplexOrder] attribute [instance] RCLike.toStrictOrderedCommRing
theorem toOrderedSMul : OrderedSMul ℝ K :=
OrderedSMul.mk' fun a b r hab hr => by
replace hab := hab.le
rw [RCLike.le_iff_re_im] at hab
rw [RCLike.le_iff_re_im, smul_re, smul_re, smul_im, smul_im]
exact hab.imp (fun h => mul_le_mul_of_nonneg_left h hr.le) (congr_arg _)
scoped[ComplexOrder] attribute [instance] RCLike.toOrderedSMul
/-- A star algebra over `K` has a scalar multiplication that respects the order. -/
lemma _root_.StarModule.instOrderedSMul {A : Type*} [NonUnitalRing A] [StarRing A] [PartialOrder A]
[StarOrderedRing A] [Module K A] [StarModule K A] [IsScalarTower K A A] [SMulCommClass K A A] :
OrderedSMul K A where
smul_lt_smul_of_pos {x y c} hxy hc := StarModule.smul_lt_smul_of_pos hxy hc
lt_of_smul_lt_smul_of_pos {x y c} hxy hc := by
have : c⁻¹ • c • x < c⁻¹ • c • y :=
StarModule.smul_lt_smul_of_pos hxy (RCLike.inv_pos_of_pos hc)
simpa [smul_smul, inv_mul_cancel hc.ne'] using this
scoped[ComplexOrder] attribute [instance] StarModule.instOrderedSMul
end Order
open ComplexConjugate
section CleanupLemmas
local notation "reR" => @RCLike.re ℝ _
local notation "imR" => @RCLike.im ℝ _
local notation "IR" => @RCLike.I ℝ _
local notation "normSqR" => @RCLike.normSq ℝ _
@[simp, rclike_simps]
theorem re_to_real {x : ℝ} : reR x = x :=
rfl
@[simp, rclike_simps]
theorem im_to_real {x : ℝ} : imR x = 0 :=
rfl
@[rclike_simps]
theorem conj_to_real {x : ℝ} : conj x = x :=
rfl
@[simp, rclike_simps]
theorem I_to_real : IR = 0 :=
rfl
@[simp, rclike_simps]
theorem normSq_to_real {x : ℝ} : normSq x = x * x := by simp [RCLike.normSq]
@[simp]
theorem ofReal_real_eq_id : @ofReal ℝ _ = id :=
rfl
end CleanupLemmas
section LinearMaps
/-- The real part in an `RCLike` field, as a linear map. -/
def reLm : K →ₗ[ℝ] ℝ :=
{ re with map_smul' := smul_re }
@[simp, rclike_simps]
theorem reLm_coe : (reLm : K → ℝ) = re :=
rfl
/-- The real part in an `RCLike` field, as a continuous linear map. -/
noncomputable def reCLM : K →L[ℝ] ℝ :=
reLm.mkContinuous 1 fun x => by
rw [one_mul]
exact abs_re_le_norm x
@[simp, rclike_simps, norm_cast]
theorem reCLM_coe : ((reCLM : K →L[ℝ] ℝ) : K →ₗ[ℝ] ℝ) = reLm :=
rfl
@[simp, rclike_simps]
theorem reCLM_apply : ((reCLM : K →L[ℝ] ℝ) : K → ℝ) = re :=
rfl
@[continuity, fun_prop]
theorem continuous_re : Continuous (re : K → ℝ) :=
reCLM.continuous
/-- The imaginary part in an `RCLike` field, as a linear map. -/
def imLm : K →ₗ[ℝ] ℝ :=
{ im with map_smul' := smul_im }
@[simp, rclike_simps]
theorem imLm_coe : (imLm : K → ℝ) = im :=
rfl
/-- The imaginary part in an `RCLike` field, as a continuous linear map. -/
noncomputable def imCLM : K →L[ℝ] ℝ :=
imLm.mkContinuous 1 fun x => by
rw [one_mul]
exact abs_im_le_norm x
@[simp, rclike_simps, norm_cast]
theorem imCLM_coe : ((imCLM : K →L[ℝ] ℝ) : K →ₗ[ℝ] ℝ) = imLm :=
rfl
@[simp, rclike_simps]
theorem imCLM_apply : ((imCLM : K →L[ℝ] ℝ) : K → ℝ) = im :=
rfl
@[continuity, fun_prop]
theorem continuous_im : Continuous (im : K → ℝ) :=
imCLM.continuous
/-- Conjugate as an `ℝ`-algebra equivalence -/
def conjAe : K ≃ₐ[ℝ] K :=
{ conj with
invFun := conj
left_inv := conj_conj
right_inv := conj_conj
commutes' := conj_ofReal }
@[simp, rclike_simps]
theorem conjAe_coe : (conjAe : K → K) = conj :=
rfl
/-- Conjugate as a linear isometry -/
noncomputable def conjLIE : K ≃ₗᵢ[ℝ] K :=
⟨conjAe.toLinearEquiv, fun _ => norm_conj⟩
@[simp, rclike_simps]
theorem conjLIE_apply : (conjLIE : K → K) = conj :=
rfl
/-- Conjugate as a continuous linear equivalence -/
noncomputable def conjCLE : K ≃L[ℝ] K :=
@conjLIE K _
@[simp, rclike_simps]
theorem conjCLE_coe : (@conjCLE K _).toLinearEquiv = conjAe.toLinearEquiv :=
rfl
@[simp, rclike_simps]
theorem conjCLE_apply : (conjCLE : K → K) = conj :=
rfl
instance (priority := 100) : ContinuousStar K :=
⟨conjLIE.continuous⟩
@[continuity]
theorem continuous_conj : Continuous (conj : K → K) :=
continuous_star
/-- The `ℝ → K` coercion, as a linear map -/
noncomputable def ofRealAm : ℝ →ₐ[ℝ] K :=
Algebra.ofId ℝ K
@[simp, rclike_simps]
theorem ofRealAm_coe : (ofRealAm : ℝ → K) = ofReal :=
rfl
/-- The ℝ → K coercion, as a linear isometry -/
noncomputable def ofRealLI : ℝ →ₗᵢ[ℝ] K where
toLinearMap := ofRealAm.toLinearMap
norm_map' := norm_ofReal
@[simp, rclike_simps]
theorem ofRealLI_apply : (ofRealLI : ℝ → K) = ofReal :=
rfl
/-- The `ℝ → K` coercion, as a continuous linear map -/
noncomputable def ofRealCLM : ℝ →L[ℝ] K :=
ofRealLI.toContinuousLinearMap
@[simp, rclike_simps]
theorem ofRealCLM_coe : (@ofRealCLM K _ : ℝ →ₗ[ℝ] K) = ofRealAm.toLinearMap :=
rfl
@[simp, rclike_simps]
theorem ofRealCLM_apply : (ofRealCLM : ℝ → K) = ofReal :=
rfl
@[continuity, fun_prop]
theorem continuous_ofReal : Continuous (ofReal : ℝ → K) :=
ofRealLI.continuous
@[continuity]
theorem continuous_normSq : Continuous (normSq : K → ℝ) :=
(continuous_re.mul continuous_re).add (continuous_im.mul continuous_im)
end LinearMaps
/-!
### ℝ-dependent results
Here we gather results that depend on whether `K` is `ℝ`.
-/
section CaseSpecific
lemma im_eq_zero (h : I = (0 : K)) (z : K) : im z = 0 := by
rw [← re_add_im z, h]
simp
/-- The natural isomorphism between `𝕜` satisfying `RCLike 𝕜` and `ℝ` when `RCLike.I = 0`. -/
@[simps]
def realRingEquiv (h : I = (0 : K)) : K ≃+* ℝ where
toFun := re
invFun := (↑)
left_inv x := by nth_rw 2 [← re_add_im x]; simp [h]
right_inv := ofReal_re
map_add' := map_add re
map_mul' := by simp [im_eq_zero h]
/-- The natural `ℝ`-linear isometry equivalence between `𝕜` satisfying `RCLike 𝕜` and `ℝ` when
`RCLike.I = 0`. -/
@[simps]
noncomputable def realLinearIsometryEquiv (h : I = (0 : K)) : K ≃ₗᵢ[ℝ] ℝ where
map_smul' := smul_re
norm_map' z := by rw [← re_add_im z]; simp [- re_add_im, h]
__ := realRingEquiv h
end CaseSpecific
end RCLike
|
Analysis\RCLike\Lemmas.lean | /-
Copyright (c) 2020 Frédéric Dupuis. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Frédéric Dupuis
-/
import Mathlib.Analysis.Normed.Module.FiniteDimension
import Mathlib.Analysis.RCLike.Basic
/-! # Further lemmas about `RCLike` -/
variable {K E : Type*} [RCLike K]
namespace Polynomial
open Polynomial
theorem ofReal_eval (p : ℝ[X]) (x : ℝ) : (↑(p.eval x) : K) = aeval (↑x) p :=
(@aeval_algebraMap_apply_eq_algebraMap_eval ℝ K _ _ _ x p).symm
end Polynomial
namespace FiniteDimensional
open scoped Classical
open RCLike
library_note "RCLike instance"/--
This instance generates a type-class problem with a metavariable `?m` that should satisfy
`RCLike ?m`. Since this can only be satisfied by `ℝ` or `ℂ`, this does not cause problems. -/
/-- An `RCLike` field is finite-dimensional over `ℝ`, since it is spanned by `{1, I}`. -/
-- Porting note(#12094): removed nolint; dangerous_instance linter not ported yet
-- @[nolint dangerous_instance]
instance rclike_to_real : FiniteDimensional ℝ K :=
⟨{1, I}, by
suffices ∀ x : K, ∃ a b : ℝ, a • 1 + b • I = x by
simpa [Submodule.eq_top_iff', Submodule.mem_span_pair]
exact fun x ↦ ⟨re x, im x, by simp [real_smul_eq_coe_mul]⟩⟩
variable (K E)
variable [NormedAddCommGroup E] [NormedSpace K E]
/-- A finite dimensional vector space over an `RCLike` is a proper metric space.
This is not an instance because it would cause a search for `FiniteDimensional ?x E` before
`RCLike ?x`. -/
theorem proper_rclike [FiniteDimensional K E] : ProperSpace E := by
letI : NormedSpace ℝ E := RestrictScalars.normedSpace ℝ K E
letI : FiniteDimensional ℝ E := FiniteDimensional.trans ℝ K E
infer_instance
variable {E}
instance RCLike.properSpace_submodule (S : Submodule K E) [FiniteDimensional K S] :
ProperSpace S :=
proper_rclike K S
end FiniteDimensional
namespace RCLike
@[simp, rclike_simps]
theorem reCLM_norm : ‖(reCLM : K →L[ℝ] ℝ)‖ = 1 := by
apply le_antisymm (LinearMap.mkContinuous_norm_le _ zero_le_one _)
convert ContinuousLinearMap.ratio_le_opNorm (reCLM : K →L[ℝ] ℝ) (1 : K)
simp
@[simp, rclike_simps]
theorem conjCLE_norm : ‖(@conjCLE K _ : K →L[ℝ] K)‖ = 1 :=
(@conjLIE K _).toLinearIsometry.norm_toContinuousLinearMap
@[simp, rclike_simps]
theorem ofRealCLM_norm : ‖(ofRealCLM : ℝ →L[ℝ] K)‖ = 1 :=
-- Porting note: the following timed out
-- LinearIsometry.norm_toContinuousLinearMap ofRealLI
LinearIsometry.norm_toContinuousLinearMap _
end RCLike
namespace Polynomial
open ComplexConjugate in
lemma aeval_conj (p : ℝ[X]) (z : K) : aeval (conj z) p = conj (aeval z p) :=
aeval_algHom_apply (RCLike.conjAe (K := K)) z p
lemma aeval_ofReal (p : ℝ[X]) (x : ℝ) : aeval (RCLike.ofReal x : K) p = eval x p :=
aeval_algHom_apply RCLike.ofRealAm x p
end Polynomial
|
Analysis\SpecialFunctions\Arsinh.lean | /-
Copyright (c) 2020 James Arthur. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: James Arthur, Chris Hughes, Shing Tak Lam
-/
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Deriv
import Mathlib.Analysis.SpecialFunctions.Log.Basic
/-!
# Inverse of the sinh function
In this file we prove that sinh is bijective and hence has an
inverse, arsinh.
## Main definitions
- `Real.arsinh`: The inverse function of `Real.sinh`.
- `Real.sinhEquiv`, `Real.sinhOrderIso`, `Real.sinhHomeomorph`: `Real.sinh` as an `Equiv`,
`OrderIso`, and `Homeomorph`, respectively.
## Main Results
- `Real.sinh_surjective`, `Real.sinh_bijective`: `Real.sinh` is surjective and bijective;
- `Real.arsinh_injective`, `Real.arsinh_surjective`, `Real.arsinh_bijective`: `Real.arsinh` is
injective, surjective, and bijective;
- `Real.continuous_arsinh`, `Real.differentiable_arsinh`, `Real.contDiff_arsinh`: `Real.arsinh` is
continuous, differentiable, and continuously differentiable; we also provide dot notation
convenience lemmas like `Filter.Tendsto.arsinh` and `ContDiffAt.arsinh`.
## Tags
arsinh, arcsinh, argsinh, asinh, sinh injective, sinh bijective, sinh surjective
-/
noncomputable section
open Function Filter Set
open scoped Topology
namespace Real
variable {x y : ℝ}
/-- `arsinh` is defined using a logarithm, `arsinh x = log (x + sqrt(1 + x^2))`. -/
@[pp_nodot]
def arsinh (x : ℝ) :=
log (x + √(1 + x ^ 2))
theorem exp_arsinh (x : ℝ) : exp (arsinh x) = x + √(1 + x ^ 2) := by
apply exp_log
rw [← neg_lt_iff_pos_add']
apply lt_sqrt_of_sq_lt
simp
@[simp]
theorem arsinh_zero : arsinh 0 = 0 := by simp [arsinh]
@[simp]
theorem arsinh_neg (x : ℝ) : arsinh (-x) = -arsinh x := by
rw [← exp_eq_exp, exp_arsinh, exp_neg, exp_arsinh]
apply eq_inv_of_mul_eq_one_left
rw [neg_sq, neg_add_eq_sub, add_comm x, mul_comm, ← sq_sub_sq, sq_sqrt, add_sub_cancel_right]
exact add_nonneg zero_le_one (sq_nonneg _)
/-- `arsinh` is the right inverse of `sinh`. -/
@[simp]
theorem sinh_arsinh (x : ℝ) : sinh (arsinh x) = x := by
rw [sinh_eq, ← arsinh_neg, exp_arsinh, exp_arsinh, neg_sq]; field_simp
@[simp]
theorem cosh_arsinh (x : ℝ) : cosh (arsinh x) = √(1 + x ^ 2) := by
rw [← sqrt_sq (cosh_pos _).le, cosh_sq', sinh_arsinh]
/-- `sinh` is surjective, `∀ b, ∃ a, sinh a = b`. In this case, we use `a = arsinh b`. -/
theorem sinh_surjective : Surjective sinh :=
LeftInverse.surjective sinh_arsinh
/-- `sinh` is bijective, both injective and surjective. -/
theorem sinh_bijective : Bijective sinh :=
⟨sinh_injective, sinh_surjective⟩
/-- `arsinh` is the left inverse of `sinh`. -/
@[simp]
theorem arsinh_sinh (x : ℝ) : arsinh (sinh x) = x :=
rightInverse_of_injective_of_leftInverse sinh_injective sinh_arsinh x
/-- `Real.sinh` as an `Equiv`. -/
@[simps]
def sinhEquiv : ℝ ≃ ℝ where
toFun := sinh
invFun := arsinh
left_inv := arsinh_sinh
right_inv := sinh_arsinh
/-- `Real.sinh` as an `OrderIso`. -/
@[simps! (config := .asFn)]
def sinhOrderIso : ℝ ≃o ℝ where
toEquiv := sinhEquiv
map_rel_iff' := @sinh_le_sinh
/-- `Real.sinh` as a `Homeomorph`. -/
@[simps! (config := .asFn)]
def sinhHomeomorph : ℝ ≃ₜ ℝ :=
sinhOrderIso.toHomeomorph
theorem arsinh_bijective : Bijective arsinh :=
sinhEquiv.symm.bijective
theorem arsinh_injective : Injective arsinh :=
sinhEquiv.symm.injective
theorem arsinh_surjective : Surjective arsinh :=
sinhEquiv.symm.surjective
theorem arsinh_strictMono : StrictMono arsinh :=
sinhOrderIso.symm.strictMono
@[simp]
theorem arsinh_inj : arsinh x = arsinh y ↔ x = y :=
arsinh_injective.eq_iff
@[simp]
theorem arsinh_le_arsinh : arsinh x ≤ arsinh y ↔ x ≤ y :=
sinhOrderIso.symm.le_iff_le
@[gcongr] protected alias ⟨_, GCongr.arsinh_le_arsinh⟩ := arsinh_le_arsinh
@[simp]
theorem arsinh_lt_arsinh : arsinh x < arsinh y ↔ x < y :=
sinhOrderIso.symm.lt_iff_lt
@[simp]
theorem arsinh_eq_zero_iff : arsinh x = 0 ↔ x = 0 :=
arsinh_injective.eq_iff' arsinh_zero
@[simp]
theorem arsinh_nonneg_iff : 0 ≤ arsinh x ↔ 0 ≤ x := by rw [← sinh_le_sinh, sinh_zero, sinh_arsinh]
@[simp]
theorem arsinh_nonpos_iff : arsinh x ≤ 0 ↔ x ≤ 0 := by rw [← sinh_le_sinh, sinh_zero, sinh_arsinh]
@[simp]
theorem arsinh_pos_iff : 0 < arsinh x ↔ 0 < x :=
lt_iff_lt_of_le_iff_le arsinh_nonpos_iff
@[simp]
theorem arsinh_neg_iff : arsinh x < 0 ↔ x < 0 :=
lt_iff_lt_of_le_iff_le arsinh_nonneg_iff
theorem hasStrictDerivAt_arsinh (x : ℝ) : HasStrictDerivAt arsinh (√(1 + x ^ 2))⁻¹ x := by
convert sinhHomeomorph.toPartialHomeomorph.hasStrictDerivAt_symm (mem_univ x) (cosh_pos _).ne'
(hasStrictDerivAt_sinh _) using 2
exact (cosh_arsinh _).symm
theorem hasDerivAt_arsinh (x : ℝ) : HasDerivAt arsinh (√(1 + x ^ 2))⁻¹ x :=
(hasStrictDerivAt_arsinh x).hasDerivAt
theorem differentiable_arsinh : Differentiable ℝ arsinh := fun x =>
(hasDerivAt_arsinh x).differentiableAt
theorem contDiff_arsinh {n : ℕ∞} : ContDiff ℝ n arsinh :=
sinhHomeomorph.contDiff_symm_deriv (fun x => (cosh_pos x).ne') hasDerivAt_sinh contDiff_sinh
@[continuity]
theorem continuous_arsinh : Continuous arsinh :=
sinhHomeomorph.symm.continuous
end Real
open Real
theorem Filter.Tendsto.arsinh {α : Type*} {l : Filter α} {f : α → ℝ} {a : ℝ}
(h : Tendsto f l (𝓝 a)) : Tendsto (fun x => arsinh (f x)) l (𝓝 (arsinh a)) :=
(continuous_arsinh.tendsto _).comp h
section Continuous
variable {X : Type*} [TopologicalSpace X] {f : X → ℝ} {s : Set X} {a : X}
nonrec theorem ContinuousAt.arsinh (h : ContinuousAt f a) :
ContinuousAt (fun x => arsinh (f x)) a :=
h.arsinh
nonrec theorem ContinuousWithinAt.arsinh (h : ContinuousWithinAt f s a) :
ContinuousWithinAt (fun x => arsinh (f x)) s a :=
h.arsinh
theorem ContinuousOn.arsinh (h : ContinuousOn f s) : ContinuousOn (fun x => arsinh (f x)) s :=
fun x hx => (h x hx).arsinh
theorem Continuous.arsinh (h : Continuous f) : Continuous fun x => arsinh (f x) :=
continuous_arsinh.comp h
end Continuous
section fderiv
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] {f : E → ℝ} {s : Set E} {a : E}
{f' : E →L[ℝ] ℝ} {n : ℕ∞}
theorem HasStrictFDerivAt.arsinh (hf : HasStrictFDerivAt f f' a) :
HasStrictFDerivAt (fun x => arsinh (f x)) ((√(1 + f a ^ 2))⁻¹ • f') a :=
(hasStrictDerivAt_arsinh _).comp_hasStrictFDerivAt a hf
theorem HasFDerivAt.arsinh (hf : HasFDerivAt f f' a) :
HasFDerivAt (fun x => arsinh (f x)) ((√(1 + f a ^ 2))⁻¹ • f') a :=
(hasDerivAt_arsinh _).comp_hasFDerivAt a hf
theorem HasFDerivWithinAt.arsinh (hf : HasFDerivWithinAt f f' s a) :
HasFDerivWithinAt (fun x => arsinh (f x)) ((√(1 + f a ^ 2))⁻¹ • f') s a :=
(hasDerivAt_arsinh _).comp_hasFDerivWithinAt a hf
theorem DifferentiableAt.arsinh (h : DifferentiableAt ℝ f a) :
DifferentiableAt ℝ (fun x => arsinh (f x)) a :=
(differentiable_arsinh _).comp a h
theorem DifferentiableWithinAt.arsinh (h : DifferentiableWithinAt ℝ f s a) :
DifferentiableWithinAt ℝ (fun x => arsinh (f x)) s a :=
(differentiable_arsinh _).comp_differentiableWithinAt a h
theorem DifferentiableOn.arsinh (h : DifferentiableOn ℝ f s) :
DifferentiableOn ℝ (fun x => arsinh (f x)) s := fun x hx => (h x hx).arsinh
theorem Differentiable.arsinh (h : Differentiable ℝ f) : Differentiable ℝ fun x => arsinh (f x) :=
differentiable_arsinh.comp h
theorem ContDiffAt.arsinh (h : ContDiffAt ℝ n f a) : ContDiffAt ℝ n (fun x => arsinh (f x)) a :=
contDiff_arsinh.contDiffAt.comp a h
theorem ContDiffWithinAt.arsinh (h : ContDiffWithinAt ℝ n f s a) :
ContDiffWithinAt ℝ n (fun x => arsinh (f x)) s a :=
contDiff_arsinh.contDiffAt.comp_contDiffWithinAt a h
theorem ContDiff.arsinh (h : ContDiff ℝ n f) : ContDiff ℝ n fun x => arsinh (f x) :=
contDiff_arsinh.comp h
theorem ContDiffOn.arsinh (h : ContDiffOn ℝ n f s) : ContDiffOn ℝ n (fun x => arsinh (f x)) s :=
fun x hx => (h x hx).arsinh
end fderiv
section deriv
variable {f : ℝ → ℝ} {s : Set ℝ} {a f' : ℝ}
theorem HasStrictDerivAt.arsinh (hf : HasStrictDerivAt f f' a) :
HasStrictDerivAt (fun x => arsinh (f x)) ((√(1 + f a ^ 2))⁻¹ • f') a :=
(hasStrictDerivAt_arsinh _).comp a hf
theorem HasDerivAt.arsinh (hf : HasDerivAt f f' a) :
HasDerivAt (fun x => arsinh (f x)) ((√(1 + f a ^ 2))⁻¹ • f') a :=
(hasDerivAt_arsinh _).comp a hf
theorem HasDerivWithinAt.arsinh (hf : HasDerivWithinAt f f' s a) :
HasDerivWithinAt (fun x => arsinh (f x)) ((√(1 + f a ^ 2))⁻¹ • f') s a :=
(hasDerivAt_arsinh _).comp_hasDerivWithinAt a hf
end deriv
|
Analysis\SpecialFunctions\Bernstein.lean | /-
Copyright (c) 2021 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison
-/
import Mathlib.Analysis.SpecificLimits.Basic
import Mathlib.RingTheory.Polynomial.Bernstein
import Mathlib.Topology.ContinuousFunction.Polynomial
import Mathlib.Topology.ContinuousFunction.Compact
/-!
# Bernstein approximations and Weierstrass' theorem
We prove that the Bernstein approximations
```
∑ k : Fin (n+1), f (k/n : ℝ) * n.choose k * x^k * (1-x)^(n-k)
```
for a continuous function `f : C([0,1], ℝ)` converge uniformly to `f` as `n` tends to infinity.
Our proof follows [Richard Beals' *Analysis, an introduction*][beals-analysis], §7D.
The original proof, due to [Bernstein](bernstein1912) in 1912, is probabilistic,
and relies on Bernoulli's theorem,
which gives bounds for how quickly the observed frequencies in a
Bernoulli trial approach the underlying probability.
The proof here does not directly rely on Bernoulli's theorem,
but can also be given a probabilistic account.
* Consider a weighted coin which with probability `x` produces heads,
and with probability `1-x` produces tails.
* The value of `bernstein n k x` is the probability that
such a coin gives exactly `k` heads in a sequence of `n` tosses.
* If such an appearance of `k` heads results in a payoff of `f(k / n)`,
the `n`-th Bernstein approximation for `f` evaluated at `x` is the expected payoff.
* The main estimate in the proof bounds the probability that
the observed frequency of heads differs from `x` by more than some `δ`,
obtaining a bound of `(4 * n * δ^2)⁻¹`, irrespective of `x`.
* This ensures that for `n` large, the Bernstein approximation is (uniformly) close to the
payoff function `f`.
(You don't need to think in these terms to follow the proof below: it's a giant `calc` block!)
This result proves Weierstrass' theorem that polynomials are dense in `C([0,1], ℝ)`,
although we defer an abstract statement of this until later.
-/
noncomputable section
open scoped BoundedContinuousFunction unitInterval
/-- The Bernstein polynomials, as continuous functions on `[0,1]`.
-/
def bernstein (n ν : ℕ) : C(I, ℝ) :=
(bernsteinPolynomial ℝ n ν).toContinuousMapOn I
@[simp]
theorem bernstein_apply (n ν : ℕ) (x : I) :
bernstein n ν x = (n.choose ν : ℝ) * (x : ℝ) ^ ν * (1 - (x : ℝ)) ^ (n - ν) := by
dsimp [bernstein, Polynomial.toContinuousMapOn, Polynomial.toContinuousMap, bernsteinPolynomial]
simp
theorem bernstein_nonneg {n ν : ℕ} {x : I} : 0 ≤ bernstein n ν x := by
simp only [bernstein_apply]
have h₁ : (0 : ℝ) ≤ x := by unit_interval
have h₂ : (0 : ℝ) ≤ 1 - x := by unit_interval
positivity
namespace Mathlib.Meta.Positivity
open Lean Meta Qq Function
/-- Extension of the `positivity` tactic for Bernstein polynomials: they are always non-negative. -/
@[positivity DFunLike.coe _ _]
def evalBernstein : PositivityExt where eval {_ _} _zα _pα e := do
let .app (.app _coe (.app (.app _ n) ν)) x ← whnfR e | throwError "not bernstein polynomial"
let p ← mkAppOptM ``bernstein_nonneg #[n, ν, x]
pure (.nonnegative p)
end Mathlib.Meta.Positivity
/-!
We now give a slight reformulation of `bernsteinPolynomial.variance`.
-/
namespace bernstein
/-- Send `k : Fin (n+1)` to the equally spaced points `k/n` in the unit interval.
-/
def z {n : ℕ} (k : Fin (n + 1)) : I :=
⟨(k : ℝ) / n, by
cases' n with n
· norm_num
· have h₁ : 0 < (n.succ : ℝ) := mod_cast Nat.succ_pos _
have h₂ : ↑k ≤ n.succ := mod_cast Fin.le_last k
rw [Set.mem_Icc, le_div_iff h₁, div_le_iff h₁]
norm_cast
simp [h₂]⟩
local postfix:90 "/ₙ" => z
theorem probability (n : ℕ) (x : I) : (∑ k : Fin (n + 1), bernstein n k x) = 1 := by
have := bernsteinPolynomial.sum ℝ n
apply_fun fun p => Polynomial.aeval (x : ℝ) p at this
simp? [AlgHom.map_sum, Finset.sum_range] at this says
simp only [Finset.sum_range, map_sum, Polynomial.coe_aeval_eq_eval, map_one] at this
exact this
theorem variance {n : ℕ} (h : 0 < (n : ℝ)) (x : I) :
(∑ k : Fin (n + 1), (x - k/ₙ : ℝ) ^ 2 * bernstein n k x) = (x : ℝ) * (1 - x) / n := by
have h' : (n : ℝ) ≠ 0 := ne_of_gt h
apply_fun fun x : ℝ => x * n using GroupWithZero.mul_right_injective h'
apply_fun fun x : ℝ => x * n using GroupWithZero.mul_right_injective h'
dsimp
conv_lhs => simp only [Finset.sum_mul, z]
conv_rhs => rw [div_mul_cancel₀ _ h']
have := bernsteinPolynomial.variance ℝ n
apply_fun fun p => Polynomial.aeval (x : ℝ) p at this
simp? [AlgHom.map_sum, Finset.sum_range, ← Polynomial.natCast_mul] at this says
simp only [nsmul_eq_mul, Finset.sum_range, map_sum, map_mul, map_pow, map_sub, map_natCast,
Polynomial.aeval_X, Polynomial.coe_aeval_eq_eval, map_one] at this
convert this using 1
· congr 1; funext k
rw [mul_comm _ (n : ℝ), mul_comm _ (n : ℝ), ← mul_assoc, ← mul_assoc]
congr 1
field_simp [h]
ring
· ring
end bernstein
open bernstein
local postfix:1024 "/ₙ" => z
/-- The `n`-th approximation of a continuous function on `[0,1]` by Bernstein polynomials,
given by `∑ k, f (k/n) * bernstein n k x`.
-/
def bernsteinApproximation (n : ℕ) (f : C(I, ℝ)) : C(I, ℝ) :=
∑ k : Fin (n + 1), f k/ₙ • bernstein n k
/-!
We now set up some of the basic machinery of the proof that the Bernstein approximations
converge uniformly.
A key player is the set `S f ε h n x`,
for some function `f : C(I, ℝ)`, `h : 0 < ε`, `n : ℕ` and `x : I`.
This is the set of points `k` in `Fin (n+1)` such that
`k/n` is within `δ` of `x`, where `δ` is the modulus of uniform continuity for `f`,
chosen so `|f x - f y| < ε/2` when `|x - y| < δ`.
We show that if `k ∉ S`, then `1 ≤ δ^-2 * (x - k/n)^2`.
-/
namespace bernsteinApproximation
@[simp]
theorem apply (n : ℕ) (f : C(I, ℝ)) (x : I) :
bernsteinApproximation n f x = ∑ k : Fin (n + 1), f k/ₙ * bernstein n k x := by
simp [bernsteinApproximation]
/-- The modulus of (uniform) continuity for `f`, chosen so `|f x - f y| < ε/2` when `|x - y| < δ`.
-/
def δ (f : C(I, ℝ)) (ε : ℝ) (h : 0 < ε) : ℝ :=
f.modulus (ε / 2) (half_pos h)
theorem δ_pos {f : C(I, ℝ)} {ε : ℝ} {h : 0 < ε} : 0 < δ f ε h :=
f.modulus_pos
/-- The set of points `k` so `k/n` is within `δ` of `x`.
-/
def S (f : C(I, ℝ)) (ε : ℝ) (h : 0 < ε) (n : ℕ) (x : I) : Finset (Fin (n + 1)) :=
{k : Fin (n + 1) | dist k/ₙ x < δ f ε h}.toFinset
/-- If `k ∈ S`, then `f(k/n)` is close to `f x`.
-/
theorem lt_of_mem_S {f : C(I, ℝ)} {ε : ℝ} {h : 0 < ε} {n : ℕ} {x : I} {k : Fin (n + 1)}
(m : k ∈ S f ε h n x) : |f k/ₙ - f x| < ε / 2 := by
apply f.dist_lt_of_dist_lt_modulus (ε / 2) (half_pos h)
-- Porting note: `simp` fails to apply `Set.mem_toFinset` on its own
simpa [S, (Set.mem_toFinset)] using m
/-- If `k ∉ S`, then as `δ ≤ |x - k/n|`, we have the inequality `1 ≤ δ^-2 * (x - k/n)^2`.
This particular formulation will be helpful later.
-/
theorem le_of_mem_S_compl {f : C(I, ℝ)} {ε : ℝ} {h : 0 < ε} {n : ℕ} {x : I} {k : Fin (n + 1)}
(m : k ∈ (S f ε h n x)ᶜ) : (1 : ℝ) ≤ δ f ε h ^ (-2 : ℤ) * ((x : ℝ) - k/ₙ) ^ 2 := by
-- Porting note: added parentheses to help `simp`
simp only [Finset.mem_compl, not_lt, Set.mem_toFinset, Set.mem_setOf_eq, S] at m
rw [zpow_neg, ← div_eq_inv_mul, zpow_two, ← pow_two, one_le_div (pow_pos δ_pos 2), sq_le_sq,
abs_of_pos δ_pos]
rwa [dist_comm] at m
end bernsteinApproximation
open bernsteinApproximation
open BoundedContinuousFunction
open Filter
open scoped Topology
/-- The Bernstein approximations
```
∑ k : Fin (n+1), f (k/n : ℝ) * n.choose k * x^k * (1-x)^(n-k)
```
for a continuous function `f : C([0,1], ℝ)` converge uniformly to `f` as `n` tends to infinity.
This is the proof given in [Richard Beals' *Analysis, an introduction*][beals-analysis], §7D,
and reproduced on wikipedia.
-/
theorem bernsteinApproximation_uniform (f : C(I, ℝ)) :
Tendsto (fun n : ℕ => bernsteinApproximation n f) atTop (𝓝 f) := by
simp only [Metric.nhds_basis_ball.tendsto_right_iff, Metric.mem_ball, dist_eq_norm]
intro ε h
let δ := δ f ε h
have nhds_zero := tendsto_const_div_atTop_nhds_zero_nat (2 * ‖f‖ * δ ^ (-2 : ℤ))
filter_upwards [nhds_zero.eventually (gt_mem_nhds (half_pos h)), eventually_gt_atTop 0] with n nh
npos'
have npos : 0 < (n : ℝ) := by positivity
-- As `[0,1]` is compact, it suffices to check the inequality pointwise.
rw [ContinuousMap.norm_lt_iff _ h]
intro x
-- The idea is to split up the sum over `k` into two sets,
-- `S`, where `x - k/n < δ`, and its complement.
let S := S f ε h n x
calc
|(bernsteinApproximation n f - f) x| = |bernsteinApproximation n f x - f x| := rfl
_ = |bernsteinApproximation n f x - f x * 1| := by rw [mul_one]
_ = |bernsteinApproximation n f x - f x * ∑ k : Fin (n + 1), bernstein n k x| := by
rw [bernstein.probability]
_ = |∑ k : Fin (n + 1), (f k/ₙ - f x) * bernstein n k x| := by
simp [bernsteinApproximation, Finset.mul_sum, sub_mul]
_ ≤ ∑ k : Fin (n + 1), |(f k/ₙ - f x) * bernstein n k x| := Finset.abs_sum_le_sum_abs _ _
_ = ∑ k : Fin (n + 1), |f k/ₙ - f x| * bernstein n k x := by
simp_rw [abs_mul, abs_eq_self.mpr bernstein_nonneg]
_ = (∑ k ∈ S, |f k/ₙ - f x| * bernstein n k x) + ∑ k ∈ Sᶜ, |f k/ₙ - f x| * bernstein n k x :=
(S.sum_add_sum_compl _).symm
-- We'll now deal with the terms in `S` and the terms in `Sᶜ` in separate calc blocks.
_ < ε / 2 + ε / 2 :=
(add_lt_add_of_le_of_lt ?_ ?_)
_ = ε := add_halves ε
· -- We now work on the terms in `S`: uniform continuity and `bernstein.probability`
-- quickly give us a bound.
calc
∑ k ∈ S, |f k/ₙ - f x| * bernstein n k x ≤ ∑ k ∈ S, ε / 2 * bernstein n k x := by
gcongr with _ m
exact le_of_lt (lt_of_mem_S m)
_ = ε / 2 * ∑ k ∈ S, bernstein n k x := by rw [Finset.mul_sum]
-- In this step we increase the sum over `S` back to a sum over all of `Fin (n+1)`,
-- so that we can use `bernstein.probability`.
_ ≤ ε / 2 * ∑ k : Fin (n + 1), bernstein n k x := by
gcongr
exact Finset.sum_le_univ_sum_of_nonneg fun k => bernstein_nonneg
_ = ε / 2 := by rw [bernstein.probability, mul_one]
· -- We now turn to working on `Sᶜ`: we control the difference term just using `‖f‖`,
-- and then insert a `δ^(-2) * (x - k/n)^2` factor
-- (which is at least one because we are not in `S`).
calc
∑ k ∈ Sᶜ, |f k/ₙ - f x| * bernstein n k x ≤ ∑ k ∈ Sᶜ, 2 * ‖f‖ * bernstein n k x := by
gcongr
apply f.dist_le_two_norm
_ = 2 * ‖f‖ * ∑ k ∈ Sᶜ, bernstein n k x := by rw [Finset.mul_sum]
_ ≤ 2 * ‖f‖ * ∑ k ∈ Sᶜ, δ ^ (-2 : ℤ) * ((x : ℝ) - k/ₙ) ^ 2 * bernstein n k x := by
gcongr with _ m
conv_lhs => rw [← one_mul (bernstein _ _ _)]
gcongr
exact le_of_mem_S_compl m
-- Again enlarging the sum from `Sᶜ` to all of `Fin (n+1)`
_ ≤ 2 * ‖f‖ * ∑ k : Fin (n + 1), δ ^ (-2 : ℤ) * ((x : ℝ) - k/ₙ) ^ 2 * bernstein n k x := by
gcongr
refine Finset.sum_le_univ_sum_of_nonneg fun k => ?_
positivity
_ = 2 * ‖f‖ * δ ^ (-2 : ℤ) * ∑ k : Fin (n + 1), ((x : ℝ) - k/ₙ) ^ 2 * bernstein n k x := by
conv_rhs =>
rw [mul_assoc, Finset.mul_sum]
simp only [← mul_assoc]
-- `bernstein.variance` and `x ∈ [0,1]` gives the uniform bound
_ = 2 * ‖f‖ * δ ^ (-2 : ℤ) * x * (1 - x) / n := by rw [variance npos]; ring
_ ≤ 2 * ‖f‖ * δ ^ (-2 : ℤ) * 1 * 1 / n := by gcongr <;> unit_interval
_ < ε / 2 := by simp only [mul_one]; exact nh
|
Analysis\SpecialFunctions\CompareExp.lean | /-
Copyright (c) 2022 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov
-/
import Mathlib.Analysis.SpecialFunctions.Pow.Asymptotics
import Mathlib.Analysis.Asymptotics.AsymptoticEquivalent
import Mathlib.Analysis.Asymptotics.SpecificAsymptotics
/-!
# Growth estimates on `x ^ y` for complex `x`, `y`
Let `l` be a filter on `ℂ` such that `Complex.re` tends to infinity along `l` and `Complex.im z`
grows at a subexponential rate compared to `Complex.re z`. Then
- `Complex.isLittleO_log_abs_re`: `Real.log ∘ Complex.abs` is `o`-small of
`Complex.re` along `l`;
- `Complex.isLittleO_cpow_mul_exp`: $z^{a_1}e^{b_1 * z} = o\left(z^{a_1}e^{b_1 * z}\right)$
along `l` for any complex `a₁`, `a₂` and real `b₁ < b₂`.
We use these assumptions on `l` for two reasons. First, these are the assumptions that naturally
appear in the proof. Second, in some applications (e.g., in Ilyashenko's proof of the individual
finiteness theorem for limit cycles of polynomial ODEs with hyperbolic singularities only) natural
stronger assumptions (e.g., `im z` is bounded from below and from above) are not available.
-/
open Asymptotics Filter Function
open scoped Topology
namespace Complex
/-- We say that `l : Filter ℂ` is an *exponential comparison filter* if the real part tends to
infinity along `l` and the imaginary part grows subexponentially compared to the real part. These
properties guarantee that `(fun z ↦ z ^ a₁ * exp (b₁ * z)) =o[l] (fun z ↦ z ^ a₂ * exp (b₂ * z))`
for any complex `a₁`, `a₂` and real `b₁ < b₂`.
In particular, the second property is automatically satisfied if the imaginary part is bounded along
`l`. -/
structure IsExpCmpFilter (l : Filter ℂ) : Prop where
tendsto_re : Tendsto re l atTop
isBigO_im_pow_re : ∀ n : ℕ, (fun z : ℂ => z.im ^ n) =O[l] fun z => Real.exp z.re
namespace IsExpCmpFilter
variable {l : Filter ℂ}
/-!
### Alternative constructors
-/
theorem of_isBigO_im_re_rpow (hre : Tendsto re l atTop) (r : ℝ) (hr : im =O[l] fun z => z.re ^ r) :
IsExpCmpFilter l :=
⟨hre, fun n =>
IsLittleO.isBigO <|
calc
(fun z : ℂ => z.im ^ n) =O[l] fun z => (z.re ^ r) ^ n := hr.pow n
_ =ᶠ[l] fun z => z.re ^ (r * n) :=
((hre.eventually_ge_atTop 0).mono fun z hz => by
simp only [Real.rpow_mul hz r n, Real.rpow_natCast])
_ =o[l] fun z => Real.exp z.re := (isLittleO_rpow_exp_atTop _).comp_tendsto hre ⟩
theorem of_isBigO_im_re_pow (hre : Tendsto re l atTop) (n : ℕ) (hr : im =O[l] fun z => z.re ^ n) :
IsExpCmpFilter l :=
of_isBigO_im_re_rpow hre n <| mod_cast hr
theorem of_boundedUnder_abs_im (hre : Tendsto re l atTop)
(him : IsBoundedUnder (· ≤ ·) l fun z => |z.im|) : IsExpCmpFilter l :=
of_isBigO_im_re_pow hre 0 <| by
simpa only [pow_zero] using him.isBigO_const (f := im) one_ne_zero
theorem of_boundedUnder_im (hre : Tendsto re l atTop) (him_le : IsBoundedUnder (· ≤ ·) l im)
(him_ge : IsBoundedUnder (· ≥ ·) l im) : IsExpCmpFilter l :=
of_boundedUnder_abs_im hre <| isBoundedUnder_le_abs.2 ⟨him_le, him_ge⟩
/-!
### Preliminary lemmas
-/
theorem eventually_ne (hl : IsExpCmpFilter l) : ∀ᶠ w : ℂ in l, w ≠ 0 :=
hl.tendsto_re.eventually_ne_atTop' _
theorem tendsto_abs_re (hl : IsExpCmpFilter l) : Tendsto (fun z : ℂ => |z.re|) l atTop :=
tendsto_abs_atTop_atTop.comp hl.tendsto_re
theorem tendsto_abs (hl : IsExpCmpFilter l) : Tendsto abs l atTop :=
tendsto_atTop_mono abs_re_le_abs hl.tendsto_abs_re
theorem isLittleO_log_re_re (hl : IsExpCmpFilter l) : (fun z => Real.log z.re) =o[l] re :=
Real.isLittleO_log_id_atTop.comp_tendsto hl.tendsto_re
theorem isLittleO_im_pow_exp_re (hl : IsExpCmpFilter l) (n : ℕ) :
(fun z : ℂ => z.im ^ n) =o[l] fun z => Real.exp z.re :=
flip IsLittleO.of_pow two_ne_zero <|
calc
(fun z : ℂ ↦ (z.im ^ n) ^ 2) = (fun z ↦ z.im ^ (2 * n)) := by simp only [pow_mul']
_ =O[l] fun z ↦ Real.exp z.re := hl.isBigO_im_pow_re _
_ = fun z ↦ (Real.exp z.re) ^ 1 := by simp only [pow_one]
_ =o[l] fun z ↦ (Real.exp z.re) ^ 2 :=
(isLittleO_pow_pow_atTop_of_lt one_lt_two).comp_tendsto <|
Real.tendsto_exp_atTop.comp hl.tendsto_re
theorem abs_im_pow_eventuallyLE_exp_re (hl : IsExpCmpFilter l) (n : ℕ) :
(fun z : ℂ => |z.im| ^ n) ≤ᶠ[l] fun z => Real.exp z.re := by
simpa using (hl.isLittleO_im_pow_exp_re n).bound zero_lt_one
/-- If `l : Filter ℂ` is an "exponential comparison filter", then $\log |z| =o(ℜ z)$ along `l`.
This is the main lemma in the proof of `Complex.IsExpCmpFilter.isLittleO_cpow_exp` below.
-/
theorem isLittleO_log_abs_re (hl : IsExpCmpFilter l) : (fun z => Real.log (abs z)) =o[l] re :=
calc
(fun z => Real.log (abs z)) =O[l] fun z => Real.log (√2) + Real.log (max z.re |z.im|) :=
IsBigO.of_bound 1 <|
(hl.tendsto_re.eventually_ge_atTop 1).mono fun z hz => by
have h2 : 0 < √2 := by simp
have hz' : 1 ≤ abs z := hz.trans (re_le_abs z)
have hm₀ : 0 < max z.re |z.im| := lt_max_iff.2 (Or.inl <| one_pos.trans_le hz)
rw [one_mul, Real.norm_eq_abs, _root_.abs_of_nonneg (Real.log_nonneg hz')]
refine le_trans ?_ (le_abs_self _)
rw [← Real.log_mul, Real.log_le_log_iff, ← _root_.abs_of_nonneg (le_trans zero_le_one hz)]
exacts [abs_le_sqrt_two_mul_max z, one_pos.trans_le hz', mul_pos h2 hm₀, h2.ne', hm₀.ne']
_ =o[l] re :=
IsLittleO.add (isLittleO_const_left.2 <| Or.inr <| hl.tendsto_abs_re) <|
isLittleO_iff_nat_mul_le.2 fun n => by
filter_upwards [isLittleO_iff_nat_mul_le'.1 hl.isLittleO_log_re_re n,
hl.abs_im_pow_eventuallyLE_exp_re n,
hl.tendsto_re.eventually_gt_atTop 1] with z hre him h₁
rcases le_total |z.im| z.re with hle | hle
· rwa [max_eq_left hle]
· have H : 1 < |z.im| := h₁.trans_le hle
norm_cast at *
rwa [max_eq_right hle, Real.norm_eq_abs, Real.norm_eq_abs, abs_of_pos (Real.log_pos H),
← Real.log_pow, Real.log_le_iff_le_exp (pow_pos (one_pos.trans H) _),
abs_of_pos (one_pos.trans h₁)]
/-!
### Main results
-/
lemma isTheta_cpow_exp_re_mul_log (hl : IsExpCmpFilter l) (a : ℂ) :
(· ^ a) =Θ[l] fun z ↦ Real.exp (re a * Real.log (abs z)) :=
calc
(fun z => z ^ a) =Θ[l] (fun z : ℂ => (abs z ^ re a)) :=
isTheta_cpow_const_rpow fun _ _ => hl.eventually_ne
_ =ᶠ[l] fun z => Real.exp (re a * Real.log (abs z)) :=
(hl.eventually_ne.mono fun z hz => by simp only [Real.rpow_def_of_pos, abs.pos hz, mul_comm])
/-- If `l : Filter ℂ` is an "exponential comparison filter", then for any complex `a` and any
positive real `b`, we have `(fun z ↦ z ^ a) =o[l] (fun z ↦ exp (b * z))`. -/
theorem isLittleO_cpow_exp (hl : IsExpCmpFilter l) (a : ℂ) {b : ℝ} (hb : 0 < b) :
(fun z => z ^ a) =o[l] fun z => exp (b * z) :=
calc
(fun z => z ^ a) =Θ[l] fun z => Real.exp (re a * Real.log (abs z)) :=
hl.isTheta_cpow_exp_re_mul_log a
_ =o[l] fun z => exp (b * z) :=
IsLittleO.of_norm_right <| by
simp only [norm_eq_abs, abs_exp, re_ofReal_mul, Real.isLittleO_exp_comp_exp_comp]
refine (IsEquivalent.refl.sub_isLittleO ?_).symm.tendsto_atTop
(hl.tendsto_re.const_mul_atTop hb)
exact (hl.isLittleO_log_abs_re.const_mul_left _).const_mul_right hb.ne'
/-- If `l : Filter ℂ` is an "exponential comparison filter", then for any complex `a₁`, `a₂` and any
real `b₁ < b₂`, we have `(fun z ↦ z ^ a₁ * exp (b₁ * z)) =o[l] (fun z ↦ z ^ a₂ * exp (b₂ * z))`. -/
theorem isLittleO_cpow_mul_exp {b₁ b₂ : ℝ} (hl : IsExpCmpFilter l) (hb : b₁ < b₂) (a₁ a₂ : ℂ) :
(fun z => z ^ a₁ * exp (b₁ * z)) =o[l] fun z => z ^ a₂ * exp (b₂ * z) :=
calc
(fun z => z ^ a₁ * exp (b₁ * z)) =ᶠ[l] fun z => z ^ a₂ * exp (b₁ * z) * z ^ (a₁ - a₂) :=
hl.eventually_ne.mono fun z hz => by
simp only
rw [mul_right_comm, ← cpow_add _ _ hz, add_sub_cancel]
_ =o[l] fun z => z ^ a₂ * exp (b₁ * z) * exp (↑(b₂ - b₁) * z) :=
((isBigO_refl (fun z => z ^ a₂ * exp (b₁ * z)) l).mul_isLittleO <|
hl.isLittleO_cpow_exp _ (sub_pos.2 hb))
_ =ᶠ[l] fun z => z ^ a₂ * exp (b₂ * z) := by
simp only [ofReal_sub, sub_mul, mul_assoc, ← exp_add, add_sub_cancel]
norm_cast
/-- If `l : Filter ℂ` is an "exponential comparison filter", then for any complex `a` and any
negative real `b`, we have `(fun z ↦ exp (b * z)) =o[l] (fun z ↦ z ^ a)`. -/
theorem isLittleO_exp_cpow (hl : IsExpCmpFilter l) (a : ℂ) {b : ℝ} (hb : b < 0) :
(fun z => exp (b * z)) =o[l] fun z => z ^ a := by simpa using hl.isLittleO_cpow_mul_exp hb 0 a
/-- If `l : Filter ℂ` is an "exponential comparison filter", then for any complex `a₁`, `a₂` and any
natural `b₁ < b₂`, we have
`(fun z ↦ z ^ a₁ * exp (b₁ * z)) =o[l] (fun z ↦ z ^ a₂ * exp (b₂ * z))`. -/
theorem isLittleO_pow_mul_exp {b₁ b₂ : ℝ} (hl : IsExpCmpFilter l) (hb : b₁ < b₂) (m n : ℕ) :
(fun z => z ^ m * exp (b₁ * z)) =o[l] fun z => z ^ n * exp (b₂ * z) := by
simpa only [cpow_natCast] using hl.isLittleO_cpow_mul_exp hb m n
/-- If `l : Filter ℂ` is an "exponential comparison filter", then for any complex `a₁`, `a₂` and any
integer `b₁ < b₂`, we have
`(fun z ↦ z ^ a₁ * exp (b₁ * z)) =o[l] (fun z ↦ z ^ a₂ * exp (b₂ * z))`. -/
theorem isLittleO_zpow_mul_exp {b₁ b₂ : ℝ} (hl : IsExpCmpFilter l) (hb : b₁ < b₂) (m n : ℤ) :
(fun z => z ^ m * exp (b₁ * z)) =o[l] fun z => z ^ n * exp (b₂ * z) := by
simpa only [cpow_intCast] using hl.isLittleO_cpow_mul_exp hb m n
end IsExpCmpFilter
end Complex
|
Analysis\SpecialFunctions\Exp.lean | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne
-/
import Mathlib.Analysis.Complex.Asymptotics
import Mathlib.Analysis.SpecificLimits.Normed
/-!
# Complex and real exponential
In this file we prove continuity of `Complex.exp` and `Real.exp`. We also prove a few facts about
limits of `Real.exp` at infinity.
## Tags
exp
-/
noncomputable section
open Finset Filter Metric Asymptotics Set Function Bornology
open scoped Topology Nat
namespace Complex
variable {z y x : ℝ}
theorem exp_bound_sq (x z : ℂ) (hz : ‖z‖ ≤ 1) :
‖exp (x + z) - exp x - z • exp x‖ ≤ ‖exp x‖ * ‖z‖ ^ 2 :=
calc
‖exp (x + z) - exp x - z * exp x‖ = ‖exp x * (exp z - 1 - z)‖ := by
congr
rw [exp_add]
ring
_ = ‖exp x‖ * ‖exp z - 1 - z‖ := norm_mul _ _
_ ≤ ‖exp x‖ * ‖z‖ ^ 2 :=
mul_le_mul_of_nonneg_left (abs_exp_sub_one_sub_id_le hz) (norm_nonneg _)
theorem locally_lipschitz_exp {r : ℝ} (hr_nonneg : 0 ≤ r) (hr_le : r ≤ 1) (x y : ℂ)
(hyx : ‖y - x‖ < r) : ‖exp y - exp x‖ ≤ (1 + r) * ‖exp x‖ * ‖y - x‖ := by
have hy_eq : y = x + (y - x) := by abel
have hyx_sq_le : ‖y - x‖ ^ 2 ≤ r * ‖y - x‖ := by
rw [pow_two]
exact mul_le_mul hyx.le le_rfl (norm_nonneg _) hr_nonneg
have h_sq : ∀ z, ‖z‖ ≤ 1 → ‖exp (x + z) - exp x‖ ≤ ‖z‖ * ‖exp x‖ + ‖exp x‖ * ‖z‖ ^ 2 := by
intro z hz
have : ‖exp (x + z) - exp x - z • exp x‖ ≤ ‖exp x‖ * ‖z‖ ^ 2 := exp_bound_sq x z hz
rw [← sub_le_iff_le_add', ← norm_smul z]
exact (norm_sub_norm_le _ _).trans this
calc
‖exp y - exp x‖ = ‖exp (x + (y - x)) - exp x‖ := by nth_rw 1 [hy_eq]
_ ≤ ‖y - x‖ * ‖exp x‖ + ‖exp x‖ * ‖y - x‖ ^ 2 := h_sq (y - x) (hyx.le.trans hr_le)
_ ≤ ‖y - x‖ * ‖exp x‖ + ‖exp x‖ * (r * ‖y - x‖) :=
(add_le_add_left (mul_le_mul le_rfl hyx_sq_le (sq_nonneg _) (norm_nonneg _)) _)
_ = (1 + r) * ‖exp x‖ * ‖y - x‖ := by ring
-- Porting note: proof by term mode `locally_lipschitz_exp zero_le_one le_rfl x`
-- doesn't work because `‖y - x‖` and `dist y x` don't unify
@[continuity]
theorem continuous_exp : Continuous exp :=
continuous_iff_continuousAt.mpr fun x =>
continuousAt_of_locally_lipschitz zero_lt_one (2 * ‖exp x‖)
(fun y ↦ by
convert locally_lipschitz_exp zero_le_one le_rfl x y using 2
congr
ring)
theorem continuousOn_exp {s : Set ℂ} : ContinuousOn exp s :=
continuous_exp.continuousOn
lemma exp_sub_sum_range_isBigO_pow (n : ℕ) :
(fun x ↦ exp x - ∑ i ∈ Finset.range n, x ^ i / i !) =O[𝓝 0] (· ^ n) := by
rcases (zero_le n).eq_or_lt with rfl | hn
· simpa using continuous_exp.continuousAt.norm.isBoundedUnder_le
· refine .of_bound (n.succ / (n ! * n)) ?_
rw [NormedAddCommGroup.nhds_zero_basis_norm_lt.eventually_iff]
refine ⟨1, one_pos, fun x hx ↦ ?_⟩
convert exp_bound hx.out.le hn using 1
field_simp [mul_comm]
lemma exp_sub_sum_range_succ_isLittleO_pow (n : ℕ) :
(fun x ↦ exp x - ∑ i ∈ Finset.range (n + 1), x ^ i / i !) =o[𝓝 0] (· ^ n) :=
(exp_sub_sum_range_isBigO_pow (n + 1)).trans_isLittleO <| isLittleO_pow_pow n.lt_succ_self
end Complex
section ComplexContinuousExpComp
variable {α : Type*}
open Complex
theorem Filter.Tendsto.cexp {l : Filter α} {f : α → ℂ} {z : ℂ} (hf : Tendsto f l (𝓝 z)) :
Tendsto (fun x => exp (f x)) l (𝓝 (exp z)) :=
(continuous_exp.tendsto _).comp hf
variable [TopologicalSpace α] {f : α → ℂ} {s : Set α} {x : α}
nonrec
theorem ContinuousWithinAt.cexp (h : ContinuousWithinAt f s x) :
ContinuousWithinAt (fun y => exp (f y)) s x :=
h.cexp
@[fun_prop]
nonrec
theorem ContinuousAt.cexp (h : ContinuousAt f x) : ContinuousAt (fun y => exp (f y)) x :=
h.cexp
@[fun_prop]
theorem ContinuousOn.cexp (h : ContinuousOn f s) : ContinuousOn (fun y => exp (f y)) s :=
fun x hx => (h x hx).cexp
@[fun_prop]
theorem Continuous.cexp (h : Continuous f) : Continuous fun y => exp (f y) :=
continuous_iff_continuousAt.2 fun _ => h.continuousAt.cexp
/-- The complex exponential function is uniformly continuous on left half planes. -/
lemma UniformlyContinuousOn.cexp (a : ℝ) : UniformContinuousOn exp {x : ℂ | x.re ≤ a} := by
have : Continuous (cexp - 1) := Continuous.sub (Continuous.cexp continuous_id') continuous_one
rw [Metric.uniformContinuousOn_iff, Metric.continuous_iff'] at *
intro ε hε
simp only [gt_iff_lt, Pi.sub_apply, Pi.one_apply, dist_sub_eq_dist_add_right,
sub_add_cancel] at this
have ha : 0 < ε / (2 * Real.exp a) := by positivity
have H := this 0 (ε / (2 * Real.exp a)) ha
rw [Metric.eventually_nhds_iff] at H
obtain ⟨δ, hδ⟩ := H
refine ⟨δ, hδ.1, ?_⟩
intros x _ y hy hxy
have h3 := hδ.2 (y := x - y) (by simpa only [dist_zero_right, norm_eq_abs] using hxy)
rw [dist_eq_norm, exp_zero] at *
have : cexp x - cexp y = cexp y * (cexp (x - y) - 1) := by
rw [mul_sub_one, ← exp_add]
ring_nf
rw [this, mul_comm]
have hya : ‖cexp y‖ ≤ Real.exp a := by
simp only [norm_eq_abs, abs_exp, Real.exp_le_exp]
exact hy
simp only [gt_iff_lt, dist_zero_right, norm_eq_abs, Set.mem_setOf_eq, norm_mul,
Complex.abs_exp] at *
apply lt_of_le_of_lt (mul_le_mul h3.le hya (Real.exp_nonneg y.re) (le_of_lt ha))
have hrr : ε / (2 * a.exp) * a.exp = ε / 2 := by
nth_rw 2 [mul_comm]
field_simp [mul_assoc]
rw [hrr]
exact div_two_lt_of_pos hε
end ComplexContinuousExpComp
namespace Real
@[continuity]
theorem continuous_exp : Continuous exp :=
Complex.continuous_re.comp Complex.continuous_ofReal.cexp
theorem continuousOn_exp {s : Set ℝ} : ContinuousOn exp s :=
continuous_exp.continuousOn
lemma exp_sub_sum_range_isBigO_pow (n : ℕ) :
(fun x ↦ exp x - ∑ i ∈ Finset.range n, x ^ i / i !) =O[𝓝 0] (· ^ n) := by
have := (Complex.exp_sub_sum_range_isBigO_pow n).comp_tendsto
(Complex.continuous_ofReal.tendsto' 0 0 rfl)
simp only [(· ∘ ·)] at this
norm_cast at this
lemma exp_sub_sum_range_succ_isLittleO_pow (n : ℕ) :
(fun x ↦ exp x - ∑ i ∈ Finset.range (n + 1), x ^ i / i !) =o[𝓝 0] (· ^ n) :=
(exp_sub_sum_range_isBigO_pow (n + 1)).trans_isLittleO <| isLittleO_pow_pow n.lt_succ_self
end Real
section RealContinuousExpComp
variable {α : Type*}
open Real
theorem Filter.Tendsto.rexp {l : Filter α} {f : α → ℝ} {z : ℝ} (hf : Tendsto f l (𝓝 z)) :
Tendsto (fun x => exp (f x)) l (𝓝 (exp z)) :=
(continuous_exp.tendsto _).comp hf
variable [TopologicalSpace α] {f : α → ℝ} {s : Set α} {x : α}
nonrec
theorem ContinuousWithinAt.rexp (h : ContinuousWithinAt f s x) :
ContinuousWithinAt (fun y ↦ exp (f y)) s x :=
h.rexp
@[deprecated (since := "2024-05-09")] alias ContinuousWithinAt.exp := ContinuousWithinAt.rexp
@[fun_prop]
nonrec
theorem ContinuousAt.rexp (h : ContinuousAt f x) : ContinuousAt (fun y ↦ exp (f y)) x :=
h.rexp
@[deprecated (since := "2024-05-09")] alias ContinuousAt.exp := ContinuousAt.rexp
@[fun_prop]
theorem ContinuousOn.rexp (h : ContinuousOn f s) :
ContinuousOn (fun y ↦ exp (f y)) s :=
fun x hx ↦ (h x hx).rexp
@[deprecated (since := "2024-05-09")] alias ContinuousOn.exp := ContinuousOn.rexp
@[fun_prop]
theorem Continuous.rexp (h : Continuous f) : Continuous fun y ↦ exp (f y) :=
continuous_iff_continuousAt.2 fun _ ↦ h.continuousAt.rexp
@[deprecated (since := "2024-05-09")] alias Continuous.exp := Continuous.rexp
end RealContinuousExpComp
namespace Real
variable {α : Type*} {x y z : ℝ} {l : Filter α}
theorem exp_half (x : ℝ) : exp (x / 2) = √(exp x) := by
rw [eq_comm, sqrt_eq_iff_sq_eq, sq, ← exp_add, add_halves] <;> exact (exp_pos _).le
/-- The real exponential function tends to `+∞` at `+∞`. -/
theorem tendsto_exp_atTop : Tendsto exp atTop atTop := by
have A : Tendsto (fun x : ℝ => x + 1) atTop atTop :=
tendsto_atTop_add_const_right atTop 1 tendsto_id
have B : ∀ᶠ x in atTop, x + 1 ≤ exp x := eventually_atTop.2 ⟨0, fun x _ => add_one_le_exp x⟩
exact tendsto_atTop_mono' atTop B A
/-- The real exponential function tends to `0` at `-∞` or, equivalently, `exp(-x)` tends to `0`
at `+∞` -/
theorem tendsto_exp_neg_atTop_nhds_zero : Tendsto (fun x => exp (-x)) atTop (𝓝 0) :=
(tendsto_inv_atTop_zero.comp tendsto_exp_atTop).congr fun x => (exp_neg x).symm
@[deprecated (since := "2024-01-31")]
alias tendsto_exp_neg_atTop_nhds_0 := tendsto_exp_neg_atTop_nhds_zero
/-- The real exponential function tends to `1` at `0`. -/
theorem tendsto_exp_nhds_zero_nhds_one : Tendsto exp (𝓝 0) (𝓝 1) := by
convert continuous_exp.tendsto 0
simp
@[deprecated (since := "2024-01-31")]
alias tendsto_exp_nhds_0_nhds_1 := tendsto_exp_nhds_zero_nhds_one
theorem tendsto_exp_atBot : Tendsto exp atBot (𝓝 0) :=
(tendsto_exp_neg_atTop_nhds_zero.comp tendsto_neg_atBot_atTop).congr fun x =>
congr_arg exp <| neg_neg x
theorem tendsto_exp_atBot_nhdsWithin : Tendsto exp atBot (𝓝[>] 0) :=
tendsto_inf.2 ⟨tendsto_exp_atBot, tendsto_principal.2 <| eventually_of_forall exp_pos⟩
@[simp]
theorem isBoundedUnder_ge_exp_comp (l : Filter α) (f : α → ℝ) :
IsBoundedUnder (· ≥ ·) l fun x => exp (f x) :=
isBoundedUnder_of ⟨0, fun _ => (exp_pos _).le⟩
@[simp]
theorem isBoundedUnder_le_exp_comp {f : α → ℝ} :
(IsBoundedUnder (· ≤ ·) l fun x => exp (f x)) ↔ IsBoundedUnder (· ≤ ·) l f :=
exp_monotone.isBoundedUnder_le_comp_iff tendsto_exp_atTop
/-- The function `exp(x)/x^n` tends to `+∞` at `+∞`, for any natural number `n` -/
theorem tendsto_exp_div_pow_atTop (n : ℕ) : Tendsto (fun x => exp x / x ^ n) atTop atTop := by
refine (atTop_basis_Ioi.tendsto_iff (atTop_basis' 1)).2 fun C hC₁ => ?_
have hC₀ : 0 < C := zero_lt_one.trans_le hC₁
have : 0 < (exp 1 * C)⁻¹ := inv_pos.2 (mul_pos (exp_pos _) hC₀)
obtain ⟨N, hN⟩ : ∃ N : ℕ, ∀ k ≥ N, (↑k : ℝ) ^ n / exp 1 ^ k < (exp 1 * C)⁻¹ :=
eventually_atTop.1
((tendsto_pow_const_div_const_pow_of_one_lt n (one_lt_exp_iff.2 zero_lt_one)).eventually
(gt_mem_nhds this))
simp only [← exp_nat_mul, mul_one, div_lt_iff, exp_pos, ← div_eq_inv_mul] at hN
refine ⟨N, trivial, fun x hx => ?_⟩
rw [Set.mem_Ioi] at hx
have hx₀ : 0 < x := (Nat.cast_nonneg N).trans_lt hx
rw [Set.mem_Ici, le_div_iff (pow_pos hx₀ _), ← le_div_iff' hC₀]
calc
x ^ n ≤ ⌈x⌉₊ ^ n := mod_cast pow_le_pow_left hx₀.le (Nat.le_ceil _) _
_ ≤ exp ⌈x⌉₊ / (exp 1 * C) := mod_cast (hN _ (Nat.lt_ceil.2 hx).le).le
_ ≤ exp (x + 1) / (exp 1 * C) := by gcongr; exact (Nat.ceil_lt_add_one hx₀.le).le
_ = exp x / C := by rw [add_comm, exp_add, mul_div_mul_left _ _ (exp_pos _).ne']
/-- The function `x^n * exp(-x)` tends to `0` at `+∞`, for any natural number `n`. -/
theorem tendsto_pow_mul_exp_neg_atTop_nhds_zero (n : ℕ) :
Tendsto (fun x => x ^ n * exp (-x)) atTop (𝓝 0) :=
(tendsto_inv_atTop_zero.comp (tendsto_exp_div_pow_atTop n)).congr fun x => by
rw [comp_apply, inv_eq_one_div, div_div_eq_mul_div, one_mul, div_eq_mul_inv, exp_neg]
@[deprecated (since := "2024-01-31")]
alias tendsto_pow_mul_exp_neg_atTop_nhds_0 := tendsto_pow_mul_exp_neg_atTop_nhds_zero
/-- The function `(b * exp x + c) / (x ^ n)` tends to `+∞` at `+∞`, for any natural number
`n` and any real numbers `b` and `c` such that `b` is positive. -/
theorem tendsto_mul_exp_add_div_pow_atTop (b c : ℝ) (n : ℕ) (hb : 0 < b) :
Tendsto (fun x => (b * exp x + c) / x ^ n) atTop atTop := by
rcases eq_or_ne n 0 with (rfl | hn)
· simp only [pow_zero, div_one]
exact (tendsto_exp_atTop.const_mul_atTop hb).atTop_add tendsto_const_nhds
simp only [add_div, mul_div_assoc]
exact
((tendsto_exp_div_pow_atTop n).const_mul_atTop hb).atTop_add
(tendsto_const_nhds.div_atTop (tendsto_pow_atTop hn))
/-- The function `(x ^ n) / (b * exp x + c)` tends to `0` at `+∞`, for any natural number
`n` and any real numbers `b` and `c` such that `b` is nonzero. -/
theorem tendsto_div_pow_mul_exp_add_atTop (b c : ℝ) (n : ℕ) (hb : 0 ≠ b) :
Tendsto (fun x => x ^ n / (b * exp x + c)) atTop (𝓝 0) := by
have H : ∀ d e, 0 < d → Tendsto (fun x : ℝ => x ^ n / (d * exp x + e)) atTop (𝓝 0) := by
intro b' c' h
convert (tendsto_mul_exp_add_div_pow_atTop b' c' n h).inv_tendsto_atTop using 1
ext x
simp
cases' lt_or_gt_of_ne hb with h h
· exact H b c h
· convert (H (-b) (-c) (neg_pos.mpr h)).neg using 1
· ext x
field_simp
rw [← neg_add (b * exp x) c, neg_div_neg_eq]
· rw [neg_zero]
/-- `Real.exp` as an order isomorphism between `ℝ` and `(0, +∞)`. -/
def expOrderIso : ℝ ≃o Ioi (0 : ℝ) :=
StrictMono.orderIsoOfSurjective _ (exp_strictMono.codRestrict exp_pos) <|
(continuous_exp.subtype_mk _).surjective
(by simp only [tendsto_Ioi_atTop, Subtype.coe_mk, tendsto_exp_atTop])
(by simp [tendsto_exp_atBot_nhdsWithin])
@[simp]
theorem coe_expOrderIso_apply (x : ℝ) : (expOrderIso x : ℝ) = exp x :=
rfl
@[simp]
theorem coe_comp_expOrderIso : (↑) ∘ expOrderIso = exp :=
rfl
@[simp]
theorem range_exp : range exp = Set.Ioi 0 := by
rw [← coe_comp_expOrderIso, range_comp, expOrderIso.range_eq, image_univ, Subtype.range_coe]
@[simp]
theorem map_exp_atTop : map exp atTop = atTop := by
rw [← coe_comp_expOrderIso, ← Filter.map_map, OrderIso.map_atTop, map_val_Ioi_atTop]
@[simp]
theorem comap_exp_atTop : comap exp atTop = atTop := by
rw [← map_exp_atTop, comap_map exp_injective, map_exp_atTop]
@[simp]
theorem tendsto_exp_comp_atTop {f : α → ℝ} :
Tendsto (fun x => exp (f x)) l atTop ↔ Tendsto f l atTop := by
simp_rw [← comp_apply (f := exp), ← tendsto_comap_iff, comap_exp_atTop]
theorem tendsto_comp_exp_atTop {f : ℝ → α} :
Tendsto (fun x => f (exp x)) atTop l ↔ Tendsto f atTop l := by
simp_rw [← comp_apply (g := exp), ← tendsto_map'_iff, map_exp_atTop]
@[simp]
theorem map_exp_atBot : map exp atBot = 𝓝[>] 0 := by
rw [← coe_comp_expOrderIso, ← Filter.map_map, expOrderIso.map_atBot, ← map_coe_Ioi_atBot]
@[simp]
theorem comap_exp_nhdsWithin_Ioi_zero : comap exp (𝓝[>] 0) = atBot := by
rw [← map_exp_atBot, comap_map exp_injective]
theorem tendsto_comp_exp_atBot {f : ℝ → α} :
Tendsto (fun x => f (exp x)) atBot l ↔ Tendsto f (𝓝[>] 0) l := by
rw [← map_exp_atBot, tendsto_map'_iff]
rfl
@[simp]
theorem comap_exp_nhds_zero : comap exp (𝓝 0) = atBot :=
(comap_nhdsWithin_range exp 0).symm.trans <| by simp
@[simp]
theorem tendsto_exp_comp_nhds_zero {f : α → ℝ} :
Tendsto (fun x => exp (f x)) l (𝓝 0) ↔ Tendsto f l atBot := by
simp_rw [← comp_apply (f := exp), ← tendsto_comap_iff, comap_exp_nhds_zero]
theorem openEmbedding_exp : OpenEmbedding exp :=
isOpen_Ioi.openEmbedding_subtype_val.comp expOrderIso.toHomeomorph.openEmbedding
@[simp]
theorem map_exp_nhds (x : ℝ) : map exp (𝓝 x) = 𝓝 (exp x) :=
openEmbedding_exp.map_nhds_eq x
@[simp]
theorem comap_exp_nhds_exp (x : ℝ) : comap exp (𝓝 (exp x)) = 𝓝 x :=
(openEmbedding_exp.nhds_eq_comap x).symm
theorem isLittleO_pow_exp_atTop {n : ℕ} : (fun x : ℝ => x ^ n) =o[atTop] Real.exp := by
simpa [isLittleO_iff_tendsto fun x hx => ((exp_pos x).ne' hx).elim] using
tendsto_div_pow_mul_exp_add_atTop 1 0 n zero_ne_one
@[simp]
theorem isBigO_exp_comp_exp_comp {f g : α → ℝ} :
((fun x => exp (f x)) =O[l] fun x => exp (g x)) ↔ IsBoundedUnder (· ≤ ·) l (f - g) :=
Iff.trans (isBigO_iff_isBoundedUnder_le_div <| eventually_of_forall fun x => exp_ne_zero _) <| by
simp only [norm_eq_abs, abs_exp, ← exp_sub, isBoundedUnder_le_exp_comp, Pi.sub_def]
@[simp]
theorem isTheta_exp_comp_exp_comp {f g : α → ℝ} :
((fun x => exp (f x)) =Θ[l] fun x => exp (g x)) ↔
IsBoundedUnder (· ≤ ·) l fun x => |f x - g x| := by
simp only [isBoundedUnder_le_abs, ← isBoundedUnder_le_neg, neg_sub, IsTheta,
isBigO_exp_comp_exp_comp, Pi.sub_def]
@[simp]
theorem isLittleO_exp_comp_exp_comp {f g : α → ℝ} :
((fun x => exp (f x)) =o[l] fun x => exp (g x)) ↔ Tendsto (fun x => g x - f x) l atTop := by
simp only [isLittleO_iff_tendsto, exp_ne_zero, ← exp_sub, ← tendsto_neg_atTop_iff, false_imp_iff,
imp_true_iff, tendsto_exp_comp_nhds_zero, neg_sub]
-- Porting note (#10618): @[simp] can prove: by simp only [@Asymptotics.isLittleO_one_left_iff,
-- Real.norm_eq_abs, Real.abs_exp, @Real.tendsto_exp_comp_atTop]
theorem isLittleO_one_exp_comp {f : α → ℝ} :
((fun _ => 1 : α → ℝ) =o[l] fun x => exp (f x)) ↔ Tendsto f l atTop := by
simp only [← exp_zero, isLittleO_exp_comp_exp_comp, sub_zero]
/-- `Real.exp (f x)` is bounded away from zero along a filter if and only if this filter is bounded
from below under `f`. -/
@[simp]
theorem isBigO_one_exp_comp {f : α → ℝ} :
((fun _ => 1 : α → ℝ) =O[l] fun x => exp (f x)) ↔ IsBoundedUnder (· ≥ ·) l f := by
simp only [← exp_zero, isBigO_exp_comp_exp_comp, Pi.sub_def, zero_sub, isBoundedUnder_le_neg]
/-- `Real.exp (f x)` is bounded away from zero along a filter if and only if this filter is bounded
from below under `f`. -/
theorem isBigO_exp_comp_one {f : α → ℝ} :
(fun x => exp (f x)) =O[l] (fun _ => 1 : α → ℝ) ↔ IsBoundedUnder (· ≤ ·) l f := by
simp only [isBigO_one_iff, norm_eq_abs, abs_exp, isBoundedUnder_le_exp_comp]
/-- `Real.exp (f x)` is bounded away from zero and infinity along a filter `l` if and only if
`|f x|` is bounded from above along this filter. -/
@[simp]
theorem isTheta_exp_comp_one {f : α → ℝ} :
(fun x => exp (f x)) =Θ[l] (fun _ => 1 : α → ℝ) ↔ IsBoundedUnder (· ≤ ·) l fun x => |f x| := by
simp only [← exp_zero, isTheta_exp_comp_exp_comp, sub_zero]
lemma summable_exp_nat_mul_iff {a : ℝ} :
Summable (fun n : ℕ ↦ exp (n * a)) ↔ a < 0 := by
simp only [exp_nat_mul, summable_geometric_iff_norm_lt_one, norm_of_nonneg (exp_nonneg _),
exp_lt_one_iff]
lemma summable_exp_neg_nat : Summable fun n : ℕ ↦ exp (-n) := by
simpa only [mul_neg_one] using summable_exp_nat_mul_iff.mpr neg_one_lt_zero
lemma summable_pow_mul_exp_neg_nat_mul (k : ℕ) {r : ℝ} (hr : 0 < r) :
Summable fun n : ℕ ↦ n ^ k * exp (-r * n) := by
simp_rw [mul_comm (-r), exp_nat_mul]
apply summable_pow_mul_geometric_of_norm_lt_one
rwa [norm_of_nonneg (exp_nonneg _), exp_lt_one_iff, neg_lt_zero]
end Real
open Real in
/-- If `f` has sum `a`, then `exp ∘ f` has product `exp a`. -/
lemma HasSum.rexp {ι} {f : ι → ℝ} {a : ℝ} (h : HasSum f a) : HasProd (rexp ∘ f) (rexp a) :=
Tendsto.congr (fun s ↦ exp_sum s f) <| Tendsto.rexp h
namespace Complex
@[simp]
theorem comap_exp_cobounded : comap exp (cobounded ℂ) = comap re atTop :=
calc
comap exp (cobounded ℂ) = comap re (comap Real.exp atTop) := by
simp only [← comap_norm_atTop, Complex.norm_eq_abs, comap_comap, (· ∘ ·), abs_exp]
_ = comap re atTop := by rw [Real.comap_exp_atTop]
@[simp]
theorem comap_exp_nhds_zero : comap exp (𝓝 0) = comap re atBot :=
calc
comap exp (𝓝 0) = comap re (comap Real.exp (𝓝 0)) := by
simp only [comap_comap, ← comap_abs_nhds_zero, (· ∘ ·), abs_exp]
_ = comap re atBot := by rw [Real.comap_exp_nhds_zero]
theorem comap_exp_nhdsWithin_zero : comap exp (𝓝[≠] 0) = comap re atBot := by
have : (exp ⁻¹' {0})ᶜ = Set.univ := eq_univ_of_forall exp_ne_zero
simp [nhdsWithin, comap_exp_nhds_zero, this]
theorem tendsto_exp_nhds_zero_iff {α : Type*} {l : Filter α} {f : α → ℂ} :
Tendsto (fun x => exp (f x)) l (𝓝 0) ↔ Tendsto (fun x => re (f x)) l atBot := by
simp_rw [← comp_apply (f := exp), ← tendsto_comap_iff, comap_exp_nhds_zero, tendsto_comap_iff]
rfl
/-- `Complex.abs (Complex.exp z) → ∞` as `Complex.re z → ∞`. -/
theorem tendsto_exp_comap_re_atTop : Tendsto exp (comap re atTop) (cobounded ℂ) :=
comap_exp_cobounded ▸ tendsto_comap
/-- `Complex.exp z → 0` as `Complex.re z → -∞`. -/
theorem tendsto_exp_comap_re_atBot : Tendsto exp (comap re atBot) (𝓝 0) :=
comap_exp_nhds_zero ▸ tendsto_comap
theorem tendsto_exp_comap_re_atBot_nhdsWithin : Tendsto exp (comap re atBot) (𝓝[≠] 0) :=
comap_exp_nhdsWithin_zero ▸ tendsto_comap
end Complex
open Complex in
/-- If `f` has sum `a`, then `exp ∘ f` has product `exp a`. -/
lemma HasSum.cexp {ι : Type*} {f : ι → ℂ} {a : ℂ} (h : HasSum f a) : HasProd (cexp ∘ f) (cexp a) :=
Filter.Tendsto.congr (fun s ↦ exp_sum s f) <| Filter.Tendsto.cexp h
|
Analysis\SpecialFunctions\ExpDeriv.lean | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne
-/
import Mathlib.Analysis.Complex.RealDeriv
import Mathlib.Analysis.Calculus.ContDiff.RCLike
import Mathlib.Analysis.Calculus.IteratedDeriv.Lemmas
/-!
# Complex and real exponential
In this file we prove that `Complex.exp` and `Real.exp` are infinitely smooth functions.
## Tags
exp, derivative
-/
noncomputable section
open Filter Asymptotics Set Function
open scoped Topology
/-! ## `Complex.exp` -/
namespace Complex
variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] [NormedAlgebra 𝕜 ℂ]
/-- The complex exponential is everywhere differentiable, with the derivative `exp x`. -/
theorem hasDerivAt_exp (x : ℂ) : HasDerivAt exp (exp x) x := by
rw [hasDerivAt_iff_isLittleO_nhds_zero]
have : (1 : ℕ) < 2 := by norm_num
refine (IsBigO.of_bound ‖exp x‖ ?_).trans_isLittleO (isLittleO_pow_id this)
filter_upwards [Metric.ball_mem_nhds (0 : ℂ) zero_lt_one]
simp only [Metric.mem_ball, dist_zero_right, norm_pow]
exact fun z hz => exp_bound_sq x z hz.le
theorem differentiable_exp : Differentiable 𝕜 exp := fun x =>
(hasDerivAt_exp x).differentiableAt.restrictScalars 𝕜
theorem differentiableAt_exp {x : ℂ} : DifferentiableAt 𝕜 exp x :=
differentiable_exp x
@[simp]
theorem deriv_exp : deriv exp = exp :=
funext fun x => (hasDerivAt_exp x).deriv
@[simp]
theorem iter_deriv_exp : ∀ n : ℕ, deriv^[n] exp = exp
| 0 => rfl
| n + 1 => by rw [iterate_succ_apply, deriv_exp, iter_deriv_exp n]
theorem contDiff_exp : ∀ {n}, ContDiff 𝕜 n exp := by
-- Porting note: added `@` due to `∀ {n}` weirdness above
refine @(contDiff_all_iff_nat.2 fun n => ?_)
have : ContDiff ℂ (↑n) exp := by
induction' n with n ihn
· exact contDiff_zero.2 continuous_exp
· rw [contDiff_succ_iff_deriv]
use differentiable_exp
rwa [deriv_exp]
exact this.restrict_scalars 𝕜
theorem hasStrictDerivAt_exp (x : ℂ) : HasStrictDerivAt exp (exp x) x :=
contDiff_exp.contDiffAt.hasStrictDerivAt' (hasDerivAt_exp x) le_rfl
theorem hasStrictFDerivAt_exp_real (x : ℂ) : HasStrictFDerivAt exp (exp x • (1 : ℂ →L[ℝ] ℂ)) x :=
(hasStrictDerivAt_exp x).complexToReal_fderiv
end Complex
section
variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] [NormedAlgebra 𝕜 ℂ] {f : 𝕜 → ℂ} {f' : ℂ} {x : 𝕜}
{s : Set 𝕜}
theorem HasStrictDerivAt.cexp (hf : HasStrictDerivAt f f' x) :
HasStrictDerivAt (fun x => Complex.exp (f x)) (Complex.exp (f x) * f') x :=
(Complex.hasStrictDerivAt_exp (f x)).comp x hf
theorem HasDerivAt.cexp (hf : HasDerivAt f f' x) :
HasDerivAt (fun x => Complex.exp (f x)) (Complex.exp (f x) * f') x :=
(Complex.hasDerivAt_exp (f x)).comp x hf
theorem HasDerivWithinAt.cexp (hf : HasDerivWithinAt f f' s x) :
HasDerivWithinAt (fun x => Complex.exp (f x)) (Complex.exp (f x) * f') s x :=
(Complex.hasDerivAt_exp (f x)).comp_hasDerivWithinAt x hf
theorem derivWithin_cexp (hf : DifferentiableWithinAt 𝕜 f s x) (hxs : UniqueDiffWithinAt 𝕜 s x) :
derivWithin (fun x => Complex.exp (f x)) s x = Complex.exp (f x) * derivWithin f s x :=
hf.hasDerivWithinAt.cexp.derivWithin hxs
@[simp]
theorem deriv_cexp (hc : DifferentiableAt 𝕜 f x) :
deriv (fun x => Complex.exp (f x)) x = Complex.exp (f x) * deriv f x :=
hc.hasDerivAt.cexp.deriv
end
section
variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] [NormedAlgebra 𝕜 ℂ] {E : Type*}
[NormedAddCommGroup E] [NormedSpace 𝕜 E] {f : E → ℂ} {f' : E →L[𝕜] ℂ} {x : E} {s : Set E}
theorem HasStrictFDerivAt.cexp (hf : HasStrictFDerivAt f f' x) :
HasStrictFDerivAt (fun x => Complex.exp (f x)) (Complex.exp (f x) • f') x :=
(Complex.hasStrictDerivAt_exp (f x)).comp_hasStrictFDerivAt x hf
theorem HasFDerivWithinAt.cexp (hf : HasFDerivWithinAt f f' s x) :
HasFDerivWithinAt (fun x => Complex.exp (f x)) (Complex.exp (f x) • f') s x :=
(Complex.hasDerivAt_exp (f x)).comp_hasFDerivWithinAt x hf
theorem HasFDerivAt.cexp (hf : HasFDerivAt f f' x) :
HasFDerivAt (fun x => Complex.exp (f x)) (Complex.exp (f x) • f') x :=
hasFDerivWithinAt_univ.1 <| hf.hasFDerivWithinAt.cexp
theorem DifferentiableWithinAt.cexp (hf : DifferentiableWithinAt 𝕜 f s x) :
DifferentiableWithinAt 𝕜 (fun x => Complex.exp (f x)) s x :=
hf.hasFDerivWithinAt.cexp.differentiableWithinAt
@[simp]
theorem DifferentiableAt.cexp (hc : DifferentiableAt 𝕜 f x) :
DifferentiableAt 𝕜 (fun x => Complex.exp (f x)) x :=
hc.hasFDerivAt.cexp.differentiableAt
theorem DifferentiableOn.cexp (hc : DifferentiableOn 𝕜 f s) :
DifferentiableOn 𝕜 (fun x => Complex.exp (f x)) s := fun x h => (hc x h).cexp
@[simp]
theorem Differentiable.cexp (hc : Differentiable 𝕜 f) :
Differentiable 𝕜 fun x => Complex.exp (f x) := fun x => (hc x).cexp
theorem ContDiff.cexp {n} (h : ContDiff 𝕜 n f) : ContDiff 𝕜 n fun x => Complex.exp (f x) :=
Complex.contDiff_exp.comp h
theorem ContDiffAt.cexp {n} (hf : ContDiffAt 𝕜 n f x) :
ContDiffAt 𝕜 n (fun x => Complex.exp (f x)) x :=
Complex.contDiff_exp.contDiffAt.comp x hf
theorem ContDiffOn.cexp {n} (hf : ContDiffOn 𝕜 n f s) :
ContDiffOn 𝕜 n (fun x => Complex.exp (f x)) s :=
Complex.contDiff_exp.comp_contDiffOn hf
theorem ContDiffWithinAt.cexp {n} (hf : ContDiffWithinAt 𝕜 n f s x) :
ContDiffWithinAt 𝕜 n (fun x => Complex.exp (f x)) s x :=
Complex.contDiff_exp.contDiffAt.comp_contDiffWithinAt x hf
end
open Complex in
@[simp]
theorem iteratedDeriv_cexp_const_mul (n : ℕ) (c : ℂ) :
(iteratedDeriv n fun s : ℂ => exp (c * s)) = fun s => c ^ n * exp (c * s) := by
rw [iteratedDeriv_const_mul contDiff_exp, iteratedDeriv_eq_iterate, iter_deriv_exp]
/-! ## `Real.exp` -/
namespace Real
variable {x y z : ℝ}
theorem hasStrictDerivAt_exp (x : ℝ) : HasStrictDerivAt exp (exp x) x :=
(Complex.hasStrictDerivAt_exp x).real_of_complex
theorem hasDerivAt_exp (x : ℝ) : HasDerivAt exp (exp x) x :=
(Complex.hasDerivAt_exp x).real_of_complex
theorem contDiff_exp {n} : ContDiff ℝ n exp :=
Complex.contDiff_exp.real_of_complex
theorem differentiable_exp : Differentiable ℝ exp := fun x => (hasDerivAt_exp x).differentiableAt
theorem differentiableAt_exp : DifferentiableAt ℝ exp x :=
differentiable_exp x
@[simp]
theorem deriv_exp : deriv exp = exp :=
funext fun x => (hasDerivAt_exp x).deriv
@[simp]
theorem iter_deriv_exp : ∀ n : ℕ, deriv^[n] exp = exp
| 0 => rfl
| n + 1 => by rw [iterate_succ_apply, deriv_exp, iter_deriv_exp n]
end Real
section
/-! Register lemmas for the derivatives of the composition of `Real.exp` with a differentiable
function, for standalone use and use with `simp`. -/
variable {f : ℝ → ℝ} {f' x : ℝ} {s : Set ℝ}
theorem HasStrictDerivAt.exp (hf : HasStrictDerivAt f f' x) :
HasStrictDerivAt (fun x => Real.exp (f x)) (Real.exp (f x) * f') x :=
(Real.hasStrictDerivAt_exp (f x)).comp x hf
theorem HasDerivAt.exp (hf : HasDerivAt f f' x) :
HasDerivAt (fun x => Real.exp (f x)) (Real.exp (f x) * f') x :=
(Real.hasDerivAt_exp (f x)).comp x hf
theorem HasDerivWithinAt.exp (hf : HasDerivWithinAt f f' s x) :
HasDerivWithinAt (fun x => Real.exp (f x)) (Real.exp (f x) * f') s x :=
(Real.hasDerivAt_exp (f x)).comp_hasDerivWithinAt x hf
theorem derivWithin_exp (hf : DifferentiableWithinAt ℝ f s x) (hxs : UniqueDiffWithinAt ℝ s x) :
derivWithin (fun x => Real.exp (f x)) s x = Real.exp (f x) * derivWithin f s x :=
hf.hasDerivWithinAt.exp.derivWithin hxs
@[simp]
theorem deriv_exp (hc : DifferentiableAt ℝ f x) :
deriv (fun x => Real.exp (f x)) x = Real.exp (f x) * deriv f x :=
hc.hasDerivAt.exp.deriv
end
section
/-! Register lemmas for the derivatives of the composition of `Real.exp` with a differentiable
function, for standalone use and use with `simp`. -/
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] {f : E → ℝ} {f' : E →L[ℝ] ℝ} {x : E}
{s : Set E}
theorem ContDiff.exp {n} (hf : ContDiff ℝ n f) : ContDiff ℝ n fun x => Real.exp (f x) :=
Real.contDiff_exp.comp hf
theorem ContDiffAt.exp {n} (hf : ContDiffAt ℝ n f x) : ContDiffAt ℝ n (fun x => Real.exp (f x)) x :=
Real.contDiff_exp.contDiffAt.comp x hf
theorem ContDiffOn.exp {n} (hf : ContDiffOn ℝ n f s) : ContDiffOn ℝ n (fun x => Real.exp (f x)) s :=
Real.contDiff_exp.comp_contDiffOn hf
theorem ContDiffWithinAt.exp {n} (hf : ContDiffWithinAt ℝ n f s x) :
ContDiffWithinAt ℝ n (fun x => Real.exp (f x)) s x :=
Real.contDiff_exp.contDiffAt.comp_contDiffWithinAt x hf
theorem HasFDerivWithinAt.exp (hf : HasFDerivWithinAt f f' s x) :
HasFDerivWithinAt (fun x => Real.exp (f x)) (Real.exp (f x) • f') s x :=
(Real.hasDerivAt_exp (f x)).comp_hasFDerivWithinAt x hf
theorem HasFDerivAt.exp (hf : HasFDerivAt f f' x) :
HasFDerivAt (fun x => Real.exp (f x)) (Real.exp (f x) • f') x :=
(Real.hasDerivAt_exp (f x)).comp_hasFDerivAt x hf
theorem HasStrictFDerivAt.exp (hf : HasStrictFDerivAt f f' x) :
HasStrictFDerivAt (fun x => Real.exp (f x)) (Real.exp (f x) • f') x :=
(Real.hasStrictDerivAt_exp (f x)).comp_hasStrictFDerivAt x hf
theorem DifferentiableWithinAt.exp (hf : DifferentiableWithinAt ℝ f s x) :
DifferentiableWithinAt ℝ (fun x => Real.exp (f x)) s x :=
hf.hasFDerivWithinAt.exp.differentiableWithinAt
@[simp]
theorem DifferentiableAt.exp (hc : DifferentiableAt ℝ f x) :
DifferentiableAt ℝ (fun x => Real.exp (f x)) x :=
hc.hasFDerivAt.exp.differentiableAt
theorem DifferentiableOn.exp (hc : DifferentiableOn ℝ f s) :
DifferentiableOn ℝ (fun x => Real.exp (f x)) s := fun x h => (hc x h).exp
@[simp]
theorem Differentiable.exp (hc : Differentiable ℝ f) : Differentiable ℝ fun x => Real.exp (f x) :=
fun x => (hc x).exp
theorem fderivWithin_exp (hf : DifferentiableWithinAt ℝ f s x) (hxs : UniqueDiffWithinAt ℝ s x) :
fderivWithin ℝ (fun x => Real.exp (f x)) s x = Real.exp (f x) • fderivWithin ℝ f s x :=
hf.hasFDerivWithinAt.exp.fderivWithin hxs
@[simp]
theorem fderiv_exp (hc : DifferentiableAt ℝ f x) :
fderiv ℝ (fun x => Real.exp (f x)) x = Real.exp (f x) • fderiv ℝ f x :=
hc.hasFDerivAt.exp.fderiv
end
open Real in
@[simp]
theorem iteratedDeriv_exp_const_mul (n : ℕ) (c : ℝ) :
(iteratedDeriv n fun s => exp (c * s)) = fun s => c ^ n * exp (c * s) := by
rw [iteratedDeriv_const_mul contDiff_exp, iteratedDeriv_eq_iterate, iter_deriv_exp]
|
Analysis\SpecialFunctions\Exponential.lean | /-
Copyright (c) 2021 Anatole Dedecker. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Anatole Dedecker, Eric Wieser
-/
import Mathlib.Analysis.Normed.Algebra.Exponential
import Mathlib.Analysis.Calculus.FDeriv.Analytic
import Mathlib.Topology.MetricSpace.CauSeqFilter
/-!
# Calculus results on exponential in a Banach algebra
In this file, we prove basic properties about the derivative of the exponential map `exp 𝕂`
in a Banach algebra `𝔸` over a field `𝕂`. We keep them separate from the main file
`Analysis.Normed.Algebra.Exponential` in order to minimize dependencies.
## Main results
We prove most results for an arbitrary field `𝕂`, and then specialize to `𝕂 = ℝ` or `𝕂 = ℂ`.
### General case
- `hasStrictFDerivAt_exp_zero_of_radius_pos` : `NormedSpace.exp 𝕂` has strict Fréchet derivative
`1 : 𝔸 →L[𝕂] 𝔸` at zero, as long as it converges on a neighborhood of zero
(see also `hasStrictDerivAt_exp_zero_of_radius_pos` for the case `𝔸 = 𝕂`)
- `hasStrictFDerivAt_exp_of_lt_radius` : if `𝕂` has characteristic zero and `𝔸` is commutative,
then given a point `x` in the disk of convergence, `NormedSpace.exp 𝕂` has strict Fréchet
derivative `NormedSpace.exp 𝕂 x • 1 : 𝔸 →L[𝕂] 𝔸` at x
(see also `hasStrictDerivAt_exp_of_lt_radius` for the case `𝔸 = 𝕂`)
- `hasStrictFDerivAt_exp_smul_const_of_mem_ball`: even when `𝔸` is non-commutative,
if we have an intermediate algebra `𝕊` which is commutative, the function
`(u : 𝕊) ↦ NormedSpace.exp 𝕂 (u • x)`, still has strict Fréchet derivative
`NormedSpace.exp 𝕂 (t • x) • (1 : 𝕊 →L[𝕂] 𝕊).smulRight x` at `t` if
`t • x` is in the radius of convergence.
### `𝕂 = ℝ` or `𝕂 = ℂ`
- `hasStrictFDerivAt_exp_zero` : `NormedSpace.exp 𝕂` has strict Fréchet derivative `1 : 𝔸 →L[𝕂] 𝔸`
at zero (see also `hasStrictDerivAt_exp_zero` for the case `𝔸 = 𝕂`)
- `hasStrictFDerivAt_exp` : if `𝔸` is commutative, then given any point `x`, `NormedSpace.exp 𝕂`
has strict Fréchet derivative `NormedSpace.exp 𝕂 x • 1 : 𝔸 →L[𝕂] 𝔸` at x
(see also `hasStrictDerivAt_exp` for the case `𝔸 = 𝕂`)
- `hasStrictFDerivAt_exp_smul_const`: even when `𝔸` is non-commutative, if we have
an intermediate algebra `𝕊` which is commutative, the function
`(u : 𝕊) ↦ NormedSpace.exp 𝕂 (u • x)` still has strict Fréchet derivative
`NormedSpace.exp 𝕂 (t • x) • (1 : 𝔸 →L[𝕂] 𝔸).smulRight x` at `t`.
### Compatibility with `Real.exp` and `Complex.exp`
- `Complex.exp_eq_exp_ℂ` : `Complex.exp = NormedSpace.exp ℂ ℂ`
- `Real.exp_eq_exp_ℝ` : `Real.exp = NormedSpace.exp ℝ ℝ`
-/
open Filter RCLike ContinuousMultilinearMap NormedField NormedSpace Asymptotics
open scoped Nat Topology ENNReal
section AnyFieldAnyAlgebra
variable {𝕂 𝔸 : Type*} [NontriviallyNormedField 𝕂] [NormedRing 𝔸] [NormedAlgebra 𝕂 𝔸]
[CompleteSpace 𝔸]
/-- The exponential in a Banach algebra `𝔸` over a normed field `𝕂` has strict Fréchet derivative
`1 : 𝔸 →L[𝕂] 𝔸` at zero, as long as it converges on a neighborhood of zero. -/
theorem hasStrictFDerivAt_exp_zero_of_radius_pos (h : 0 < (expSeries 𝕂 𝔸).radius) :
HasStrictFDerivAt (exp 𝕂) (1 : 𝔸 →L[𝕂] 𝔸) 0 := by
convert (hasFPowerSeriesAt_exp_zero_of_radius_pos h).hasStrictFDerivAt
ext x
change x = expSeries 𝕂 𝔸 1 fun _ => x
simp [expSeries_apply_eq, Nat.factorial]
/-- The exponential in a Banach algebra `𝔸` over a normed field `𝕂` has Fréchet derivative
`1 : 𝔸 →L[𝕂] 𝔸` at zero, as long as it converges on a neighborhood of zero. -/
theorem hasFDerivAt_exp_zero_of_radius_pos (h : 0 < (expSeries 𝕂 𝔸).radius) :
HasFDerivAt (exp 𝕂) (1 : 𝔸 →L[𝕂] 𝔸) 0 :=
(hasStrictFDerivAt_exp_zero_of_radius_pos h).hasFDerivAt
end AnyFieldAnyAlgebra
section AnyFieldCommAlgebra
variable {𝕂 𝔸 : Type*} [NontriviallyNormedField 𝕂] [NormedCommRing 𝔸] [NormedAlgebra 𝕂 𝔸]
[CompleteSpace 𝔸]
/-- The exponential map in a commutative Banach algebra `𝔸` over a normed field `𝕂` of
characteristic zero has Fréchet derivative `NormedSpace.exp 𝕂 x • 1 : 𝔸 →L[𝕂] 𝔸`
at any point `x`in the disk of convergence. -/
theorem hasFDerivAt_exp_of_mem_ball [CharZero 𝕂] {x : 𝔸}
(hx : x ∈ EMetric.ball (0 : 𝔸) (expSeries 𝕂 𝔸).radius) :
HasFDerivAt (exp 𝕂) (exp 𝕂 x • (1 : 𝔸 →L[𝕂] 𝔸)) x := by
have hpos : 0 < (expSeries 𝕂 𝔸).radius := (zero_le _).trans_lt hx
rw [hasFDerivAt_iff_isLittleO_nhds_zero]
suffices
(fun h => exp 𝕂 x * (exp 𝕂 (0 + h) - exp 𝕂 0 - ContinuousLinearMap.id 𝕂 𝔸 h)) =ᶠ[𝓝 0] fun h =>
exp 𝕂 (x + h) - exp 𝕂 x - exp 𝕂 x • ContinuousLinearMap.id 𝕂 𝔸 h by
refine (IsLittleO.const_mul_left ?_ _).congr' this (EventuallyEq.refl _ _)
rw [← hasFDerivAt_iff_isLittleO_nhds_zero]
exact hasFDerivAt_exp_zero_of_radius_pos hpos
have : ∀ᶠ h in 𝓝 (0 : 𝔸), h ∈ EMetric.ball (0 : 𝔸) (expSeries 𝕂 𝔸).radius :=
EMetric.ball_mem_nhds _ hpos
filter_upwards [this] with _ hh
rw [exp_add_of_mem_ball hx hh, exp_zero, zero_add, ContinuousLinearMap.id_apply, smul_eq_mul]
ring
/-- The exponential map in a commutative Banach algebra `𝔸` over a normed field `𝕂` of
characteristic zero has strict Fréchet derivative `NormedSpace.exp 𝕂 x • 1 : 𝔸 →L[𝕂] 𝔸`
at any point `x` in the disk of convergence. -/
theorem hasStrictFDerivAt_exp_of_mem_ball [CharZero 𝕂] {x : 𝔸}
(hx : x ∈ EMetric.ball (0 : 𝔸) (expSeries 𝕂 𝔸).radius) :
HasStrictFDerivAt (exp 𝕂) (exp 𝕂 x • (1 : 𝔸 →L[𝕂] 𝔸)) x :=
let ⟨_, hp⟩ := analyticAt_exp_of_mem_ball x hx
hp.hasFDerivAt.unique (hasFDerivAt_exp_of_mem_ball hx) ▸ hp.hasStrictFDerivAt
end AnyFieldCommAlgebra
section deriv
variable {𝕂 : Type*} [NontriviallyNormedField 𝕂] [CompleteSpace 𝕂]
/-- The exponential map in a complete normed field `𝕂` of characteristic zero has strict derivative
`NormedSpace.exp 𝕂 x` at any point `x` in the disk of convergence. -/
theorem hasStrictDerivAt_exp_of_mem_ball [CharZero 𝕂] {x : 𝕂}
(hx : x ∈ EMetric.ball (0 : 𝕂) (expSeries 𝕂 𝕂).radius) :
HasStrictDerivAt (exp 𝕂) (exp 𝕂 x) x := by
simpa using (hasStrictFDerivAt_exp_of_mem_ball hx).hasStrictDerivAt
/-- The exponential map in a complete normed field `𝕂` of characteristic zero has derivative
`NormedSpace.exp 𝕂 x` at any point `x` in the disk of convergence. -/
theorem hasDerivAt_exp_of_mem_ball [CharZero 𝕂] {x : 𝕂}
(hx : x ∈ EMetric.ball (0 : 𝕂) (expSeries 𝕂 𝕂).radius) : HasDerivAt (exp 𝕂) (exp 𝕂 x) x :=
(hasStrictDerivAt_exp_of_mem_ball hx).hasDerivAt
/-- The exponential map in a complete normed field `𝕂` of characteristic zero has strict derivative
`1` at zero, as long as it converges on a neighborhood of zero. -/
theorem hasStrictDerivAt_exp_zero_of_radius_pos (h : 0 < (expSeries 𝕂 𝕂).radius) :
HasStrictDerivAt (exp 𝕂) (1 : 𝕂) 0 :=
(hasStrictFDerivAt_exp_zero_of_radius_pos h).hasStrictDerivAt
/-- The exponential map in a complete normed field `𝕂` of characteristic zero has derivative
`1` at zero, as long as it converges on a neighborhood of zero. -/
theorem hasDerivAt_exp_zero_of_radius_pos (h : 0 < (expSeries 𝕂 𝕂).radius) :
HasDerivAt (exp 𝕂) (1 : 𝕂) 0 :=
(hasStrictDerivAt_exp_zero_of_radius_pos h).hasDerivAt
end deriv
section RCLikeAnyAlgebra
variable {𝕂 𝔸 : Type*} [RCLike 𝕂] [NormedRing 𝔸] [NormedAlgebra 𝕂 𝔸] [CompleteSpace 𝔸]
/-- The exponential in a Banach algebra `𝔸` over `𝕂 = ℝ` or `𝕂 = ℂ` has strict Fréchet derivative
`1 : 𝔸 →L[𝕂] 𝔸` at zero. -/
theorem hasStrictFDerivAt_exp_zero : HasStrictFDerivAt (exp 𝕂) (1 : 𝔸 →L[𝕂] 𝔸) 0 :=
hasStrictFDerivAt_exp_zero_of_radius_pos (expSeries_radius_pos 𝕂 𝔸)
/-- The exponential in a Banach algebra `𝔸` over `𝕂 = ℝ` or `𝕂 = ℂ` has Fréchet derivative
`1 : 𝔸 →L[𝕂] 𝔸` at zero. -/
theorem hasFDerivAt_exp_zero : HasFDerivAt (exp 𝕂) (1 : 𝔸 →L[𝕂] 𝔸) 0 :=
hasStrictFDerivAt_exp_zero.hasFDerivAt
end RCLikeAnyAlgebra
section RCLikeCommAlgebra
variable {𝕂 𝔸 : Type*} [RCLike 𝕂] [NormedCommRing 𝔸] [NormedAlgebra 𝕂 𝔸] [CompleteSpace 𝔸]
/-- The exponential map in a commutative Banach algebra `𝔸` over `𝕂 = ℝ` or `𝕂 = ℂ` has strict
Fréchet derivative `NormedSpace.exp 𝕂 x • 1 : 𝔸 →L[𝕂] 𝔸` at any point `x`. -/
theorem hasStrictFDerivAt_exp {x : 𝔸} : HasStrictFDerivAt (exp 𝕂) (exp 𝕂 x • (1 : 𝔸 →L[𝕂] 𝔸)) x :=
hasStrictFDerivAt_exp_of_mem_ball ((expSeries_radius_eq_top 𝕂 𝔸).symm ▸ edist_lt_top _ _)
/-- The exponential map in a commutative Banach algebra `𝔸` over `𝕂 = ℝ` or `𝕂 = ℂ` has
Fréchet derivative `NormedSpace.exp 𝕂 x • 1 : 𝔸 →L[𝕂] 𝔸` at any point `x`. -/
theorem hasFDerivAt_exp {x : 𝔸} : HasFDerivAt (exp 𝕂) (exp 𝕂 x • (1 : 𝔸 →L[𝕂] 𝔸)) x :=
hasStrictFDerivAt_exp.hasFDerivAt
end RCLikeCommAlgebra
section DerivRCLike
variable {𝕂 : Type*} [RCLike 𝕂]
/-- The exponential map in `𝕂 = ℝ` or `𝕂 = ℂ` has strict derivative `NormedSpace.exp 𝕂 x`
at any point `x`. -/
theorem hasStrictDerivAt_exp {x : 𝕂} : HasStrictDerivAt (exp 𝕂) (exp 𝕂 x) x :=
hasStrictDerivAt_exp_of_mem_ball ((expSeries_radius_eq_top 𝕂 𝕂).symm ▸ edist_lt_top _ _)
/-- The exponential map in `𝕂 = ℝ` or `𝕂 = ℂ` has derivative `NormedSpace.exp 𝕂 x`
at any point `x`. -/
theorem hasDerivAt_exp {x : 𝕂} : HasDerivAt (exp 𝕂) (exp 𝕂 x) x :=
hasStrictDerivAt_exp.hasDerivAt
/-- The exponential map in `𝕂 = ℝ` or `𝕂 = ℂ` has strict derivative `1` at zero. -/
theorem hasStrictDerivAt_exp_zero : HasStrictDerivAt (exp 𝕂) (1 : 𝕂) 0 :=
hasStrictDerivAt_exp_zero_of_radius_pos (expSeries_radius_pos 𝕂 𝕂)
/-- The exponential map in `𝕂 = ℝ` or `𝕂 = ℂ` has derivative `1` at zero. -/
theorem hasDerivAt_exp_zero : HasDerivAt (exp 𝕂) (1 : 𝕂) 0 :=
hasStrictDerivAt_exp_zero.hasDerivAt
end DerivRCLike
theorem Complex.exp_eq_exp_ℂ : Complex.exp = NormedSpace.exp ℂ := by
refine funext fun x => ?_
rw [Complex.exp, exp_eq_tsum_div]
have : CauSeq.IsComplete ℂ norm := Complex.instIsComplete
exact tendsto_nhds_unique x.exp'.tendsto_limit (expSeries_div_summable ℝ x).hasSum.tendsto_sum_nat
theorem Real.exp_eq_exp_ℝ : Real.exp = NormedSpace.exp ℝ := by
ext x; exact mod_cast congr_fun Complex.exp_eq_exp_ℂ x
/-! ### Derivative of $\exp (ux)$ by $u$
Note that since for `x : 𝔸` we have `NormedRing 𝔸` not `NormedCommRing 𝔸`, we cannot deduce
these results from `hasFDerivAt_exp_of_mem_ball` applied to the algebra `𝔸`.
One possible solution for that would be to apply `hasFDerivAt_exp_of_mem_ball` to the
commutative algebra `Algebra.elementalAlgebra 𝕊 x`. Unfortunately we don't have all the required
API, so we leave that to a future refactor (see leanprover-community/mathlib#19062 for discussion).
We could also go the other way around and deduce `hasFDerivAt_exp_of_mem_ball` from
`hasFDerivAt_exp_smul_const_of_mem_ball` applied to `𝕊 := 𝔸`, `x := (1 : 𝔸)`, and `t := x`.
However, doing so would make the aforementioned `elementalAlgebra` refactor harder, so for now we
just prove these two lemmas independently.
A last strategy would be to deduce everything from the more general non-commutative case,
$$\frac{d}{dt}e^{x(t)} = \int_0^1 e^{sx(t)} \left(\frac{d}{dt}e^{x(t)}\right) e^{(1-s)x(t)} ds$$
but this is harder to prove, and typically is shown by going via these results first.
TODO: prove this result too!
-/
section exp_smul
variable {𝕂 𝕊 𝔸 : Type*}
variable (𝕂)
open scoped Topology
open Asymptotics Filter
section MemBall
variable [NontriviallyNormedField 𝕂] [CharZero 𝕂]
variable [NormedCommRing 𝕊] [NormedRing 𝔸]
variable [NormedSpace 𝕂 𝕊] [NormedAlgebra 𝕂 𝔸] [Algebra 𝕊 𝔸] [ContinuousSMul 𝕊 𝔸]
variable [IsScalarTower 𝕂 𝕊 𝔸]
variable [CompleteSpace 𝔸]
theorem hasFDerivAt_exp_smul_const_of_mem_ball (x : 𝔸) (t : 𝕊)
(htx : t • x ∈ EMetric.ball (0 : 𝔸) (expSeries 𝕂 𝔸).radius) :
HasFDerivAt (fun u : 𝕊 => exp 𝕂 (u • x)) (exp 𝕂 (t • x) • (1 : 𝕊 →L[𝕂] 𝕊).smulRight x) t := by
-- TODO: prove this via `hasFDerivAt_exp_of_mem_ball` using the commutative ring
-- `Algebra.elementalAlgebra 𝕊 x`. See leanprover-community/mathlib#19062 for discussion.
have hpos : 0 < (expSeries 𝕂 𝔸).radius := (zero_le _).trans_lt htx
rw [hasFDerivAt_iff_isLittleO_nhds_zero]
suffices (fun (h : 𝕊) => exp 𝕂 (t • x) *
(exp 𝕂 ((0 + h) • x) - exp 𝕂 ((0 : 𝕊) • x) - ((1 : 𝕊 →L[𝕂] 𝕊).smulRight x) h)) =ᶠ[𝓝 0]
fun h =>
exp 𝕂 ((t + h) • x) - exp 𝕂 (t • x) - (exp 𝕂 (t • x) • (1 : 𝕊 →L[𝕂] 𝕊).smulRight x) h by
apply (IsLittleO.const_mul_left _ _).congr' this (EventuallyEq.refl _ _)
rw [← hasFDerivAt_iff_isLittleO_nhds_zero (f := fun u => exp 𝕂 (u • x))
(f' := (1 : 𝕊 →L[𝕂] 𝕊).smulRight x) (x := 0)]
have : HasFDerivAt (exp 𝕂) (1 : 𝔸 →L[𝕂] 𝔸) ((1 : 𝕊 →L[𝕂] 𝕊).smulRight x 0) := by
rw [ContinuousLinearMap.smulRight_apply, ContinuousLinearMap.one_apply, zero_smul]
exact hasFDerivAt_exp_zero_of_radius_pos hpos
exact this.comp 0 ((1 : 𝕊 →L[𝕂] 𝕊).smulRight x).hasFDerivAt
have : Tendsto (fun h : 𝕊 => h • x) (𝓝 0) (𝓝 0) := by
rw [← zero_smul 𝕊 x]
exact tendsto_id.smul_const x
have : ∀ᶠ h in 𝓝 (0 : 𝕊), h • x ∈ EMetric.ball (0 : 𝔸) (expSeries 𝕂 𝔸).radius :=
this.eventually (EMetric.ball_mem_nhds _ hpos)
filter_upwards [this] with h hh
have : Commute (t • x) (h • x) := ((Commute.refl x).smul_left t).smul_right h
rw [add_smul t h, exp_add_of_commute_of_mem_ball this htx hh, zero_add, zero_smul, exp_zero,
ContinuousLinearMap.smulRight_apply, ContinuousLinearMap.one_apply,
ContinuousLinearMap.smul_apply, ContinuousLinearMap.smulRight_apply,
ContinuousLinearMap.one_apply, smul_eq_mul, mul_sub_left_distrib, mul_sub_left_distrib, mul_one]
theorem hasFDerivAt_exp_smul_const_of_mem_ball' (x : 𝔸) (t : 𝕊)
(htx : t • x ∈ EMetric.ball (0 : 𝔸) (expSeries 𝕂 𝔸).radius) :
HasFDerivAt (fun u : 𝕊 => exp 𝕂 (u • x))
(((1 : 𝕊 →L[𝕂] 𝕊).smulRight x).smulRight (exp 𝕂 (t • x))) t := by
convert hasFDerivAt_exp_smul_const_of_mem_ball 𝕂 _ _ htx using 1
ext t'
show Commute (t' • x) (exp 𝕂 (t • x))
exact (((Commute.refl x).smul_left t').smul_right t).exp_right 𝕂
theorem hasStrictFDerivAt_exp_smul_const_of_mem_ball (x : 𝔸) (t : 𝕊)
(htx : t • x ∈ EMetric.ball (0 : 𝔸) (expSeries 𝕂 𝔸).radius) :
HasStrictFDerivAt (fun u : 𝕊 => exp 𝕂 (u • x))
(exp 𝕂 (t • x) • (1 : 𝕊 →L[𝕂] 𝕊).smulRight x) t :=
let ⟨_, hp⟩ := analyticAt_exp_of_mem_ball (t • x) htx
have deriv₁ : HasStrictFDerivAt (fun u : 𝕊 => exp 𝕂 (u • x)) _ t :=
hp.hasStrictFDerivAt.comp t ((ContinuousLinearMap.id 𝕂 𝕊).smulRight x).hasStrictFDerivAt
have deriv₂ : HasFDerivAt (fun u : 𝕊 => exp 𝕂 (u • x)) _ t :=
hasFDerivAt_exp_smul_const_of_mem_ball 𝕂 x t htx
deriv₁.hasFDerivAt.unique deriv₂ ▸ deriv₁
theorem hasStrictFDerivAt_exp_smul_const_of_mem_ball' (x : 𝔸) (t : 𝕊)
(htx : t • x ∈ EMetric.ball (0 : 𝔸) (expSeries 𝕂 𝔸).radius) :
HasStrictFDerivAt (fun u : 𝕊 => exp 𝕂 (u • x))
(((1 : 𝕊 →L[𝕂] 𝕊).smulRight x).smulRight (exp 𝕂 (t • x))) t := by
let ⟨_, _⟩ := analyticAt_exp_of_mem_ball (t • x) htx
convert hasStrictFDerivAt_exp_smul_const_of_mem_ball 𝕂 _ _ htx using 1
ext t'
show Commute (t' • x) (exp 𝕂 (t • x))
exact (((Commute.refl x).smul_left t').smul_right t).exp_right 𝕂
variable {𝕂}
theorem hasStrictDerivAt_exp_smul_const_of_mem_ball (x : 𝔸) (t : 𝕂)
(htx : t • x ∈ EMetric.ball (0 : 𝔸) (expSeries 𝕂 𝔸).radius) :
HasStrictDerivAt (fun u : 𝕂 => exp 𝕂 (u • x)) (exp 𝕂 (t • x) * x) t := by
simpa using (hasStrictFDerivAt_exp_smul_const_of_mem_ball 𝕂 x t htx).hasStrictDerivAt
theorem hasStrictDerivAt_exp_smul_const_of_mem_ball' (x : 𝔸) (t : 𝕂)
(htx : t • x ∈ EMetric.ball (0 : 𝔸) (expSeries 𝕂 𝔸).radius) :
HasStrictDerivAt (fun u : 𝕂 => exp 𝕂 (u • x)) (x * exp 𝕂 (t • x)) t := by
simpa using (hasStrictFDerivAt_exp_smul_const_of_mem_ball' 𝕂 x t htx).hasStrictDerivAt
theorem hasDerivAt_exp_smul_const_of_mem_ball (x : 𝔸) (t : 𝕂)
(htx : t • x ∈ EMetric.ball (0 : 𝔸) (expSeries 𝕂 𝔸).radius) :
HasDerivAt (fun u : 𝕂 => exp 𝕂 (u • x)) (exp 𝕂 (t • x) * x) t :=
(hasStrictDerivAt_exp_smul_const_of_mem_ball x t htx).hasDerivAt
theorem hasDerivAt_exp_smul_const_of_mem_ball' (x : 𝔸) (t : 𝕂)
(htx : t • x ∈ EMetric.ball (0 : 𝔸) (expSeries 𝕂 𝔸).radius) :
HasDerivAt (fun u : 𝕂 => exp 𝕂 (u • x)) (x * exp 𝕂 (t • x)) t :=
(hasStrictDerivAt_exp_smul_const_of_mem_ball' x t htx).hasDerivAt
end MemBall
section RCLike
variable [RCLike 𝕂]
variable [NormedCommRing 𝕊] [NormedRing 𝔸]
variable [NormedAlgebra 𝕂 𝕊] [NormedAlgebra 𝕂 𝔸] [Algebra 𝕊 𝔸] [ContinuousSMul 𝕊 𝔸]
variable [IsScalarTower 𝕂 𝕊 𝔸]
variable [CompleteSpace 𝔸]
theorem hasFDerivAt_exp_smul_const (x : 𝔸) (t : 𝕊) :
HasFDerivAt (fun u : 𝕊 => exp 𝕂 (u • x)) (exp 𝕂 (t • x) • (1 : 𝕊 →L[𝕂] 𝕊).smulRight x) t :=
hasFDerivAt_exp_smul_const_of_mem_ball 𝕂 _ _ <|
(expSeries_radius_eq_top 𝕂 𝔸).symm ▸ edist_lt_top _ _
theorem hasFDerivAt_exp_smul_const' (x : 𝔸) (t : 𝕊) :
HasFDerivAt (fun u : 𝕊 => exp 𝕂 (u • x))
(((1 : 𝕊 →L[𝕂] 𝕊).smulRight x).smulRight (exp 𝕂 (t • x))) t :=
hasFDerivAt_exp_smul_const_of_mem_ball' 𝕂 _ _ <|
(expSeries_radius_eq_top 𝕂 𝔸).symm ▸ edist_lt_top _ _
theorem hasStrictFDerivAt_exp_smul_const (x : 𝔸) (t : 𝕊) :
HasStrictFDerivAt (fun u : 𝕊 => exp 𝕂 (u • x))
(exp 𝕂 (t • x) • (1 : 𝕊 →L[𝕂] 𝕊).smulRight x) t :=
hasStrictFDerivAt_exp_smul_const_of_mem_ball 𝕂 _ _ <|
(expSeries_radius_eq_top 𝕂 𝔸).symm ▸ edist_lt_top _ _
theorem hasStrictFDerivAt_exp_smul_const' (x : 𝔸) (t : 𝕊) :
HasStrictFDerivAt (fun u : 𝕊 => exp 𝕂 (u • x))
(((1 : 𝕊 →L[𝕂] 𝕊).smulRight x).smulRight (exp 𝕂 (t • x))) t :=
hasStrictFDerivAt_exp_smul_const_of_mem_ball' 𝕂 _ _ <|
(expSeries_radius_eq_top 𝕂 𝔸).symm ▸ edist_lt_top _ _
variable {𝕂}
theorem hasStrictDerivAt_exp_smul_const (x : 𝔸) (t : 𝕂) :
HasStrictDerivAt (fun u : 𝕂 => exp 𝕂 (u • x)) (exp 𝕂 (t • x) * x) t :=
hasStrictDerivAt_exp_smul_const_of_mem_ball _ _ <|
(expSeries_radius_eq_top 𝕂 𝔸).symm ▸ edist_lt_top _ _
theorem hasStrictDerivAt_exp_smul_const' (x : 𝔸) (t : 𝕂) :
HasStrictDerivAt (fun u : 𝕂 => exp 𝕂 (u • x)) (x * exp 𝕂 (t • x)) t :=
hasStrictDerivAt_exp_smul_const_of_mem_ball' _ _ <|
(expSeries_radius_eq_top 𝕂 𝔸).symm ▸ edist_lt_top _ _
theorem hasDerivAt_exp_smul_const (x : 𝔸) (t : 𝕂) :
HasDerivAt (fun u : 𝕂 => exp 𝕂 (u • x)) (exp 𝕂 (t • x) * x) t :=
hasDerivAt_exp_smul_const_of_mem_ball _ _ <| (expSeries_radius_eq_top 𝕂 𝔸).symm ▸ edist_lt_top _ _
theorem hasDerivAt_exp_smul_const' (x : 𝔸) (t : 𝕂) :
HasDerivAt (fun u : 𝕂 => exp 𝕂 (u • x)) (x * exp 𝕂 (t • x)) t :=
hasDerivAt_exp_smul_const_of_mem_ball' _ _ <|
(expSeries_radius_eq_top 𝕂 𝔸).symm ▸ edist_lt_top _ _
end RCLike
end exp_smul
section tsum_tprod
variable {𝕂 𝔸 : Type*} [RCLike 𝕂] [NormedCommRing 𝔸] [NormedAlgebra 𝕂 𝔸] [CompleteSpace 𝔸]
/-- If `f` has sum `a`, then `NormedSpace.exp ∘ f` has product `NormedSpace.exp a`. -/
lemma HasSum.exp {ι : Type*} {f : ι → 𝔸} {a : 𝔸} (h : HasSum f a) :
HasProd (exp 𝕂 ∘ f) (exp 𝕂 a) :=
Tendsto.congr (fun s ↦ exp_sum s f) <| Tendsto.exp h
end tsum_tprod
|
Analysis\SpecialFunctions\ImproperIntegrals.lean | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.SpecialFunctions.JapaneseBracket
import Mathlib.Analysis.SpecialFunctions.Integrals
import Mathlib.MeasureTheory.Group.Integral
import Mathlib.MeasureTheory.Integral.IntegralEqImproper
import Mathlib.MeasureTheory.Measure.Lebesgue.Integral
/-!
# Evaluation of specific improper integrals
This file contains some integrability results, and evaluations of integrals, over `ℝ` or over
half-infinite intervals in `ℝ`.
## See also
- `Mathlib.Analysis.SpecialFunctions.Integrals` -- integrals over finite intervals
- `Mathlib.Analysis.SpecialFunctions.Gaussian` -- integral of `exp (-x ^ 2)`
- `Mathlib.Analysis.SpecialFunctions.JapaneseBracket`-- integrability of `(1+‖x‖)^(-r)`.
-/
open Real Set Filter MeasureTheory intervalIntegral
open scoped Topology
theorem integrableOn_exp_Iic (c : ℝ) : IntegrableOn exp (Iic c) := by
refine
integrableOn_Iic_of_intervalIntegral_norm_bounded (exp c) c
(fun y => intervalIntegrable_exp.1) tendsto_id
(eventually_of_mem (Iic_mem_atBot 0) fun y _ => ?_)
simp_rw [norm_of_nonneg (exp_pos _).le, integral_exp, sub_le_self_iff]
exact (exp_pos _).le
theorem integral_exp_Iic (c : ℝ) : ∫ x : ℝ in Iic c, exp x = exp c := by
refine
tendsto_nhds_unique
(intervalIntegral_tendsto_integral_Iic _ (integrableOn_exp_Iic _) tendsto_id) ?_
simp_rw [integral_exp, show 𝓝 (exp c) = 𝓝 (exp c - 0) by rw [sub_zero]]
exact tendsto_exp_atBot.const_sub _
theorem integral_exp_Iic_zero : ∫ x : ℝ in Iic 0, exp x = 1 :=
exp_zero ▸ integral_exp_Iic 0
theorem integral_exp_neg_Ioi (c : ℝ) : (∫ x : ℝ in Ioi c, exp (-x)) = exp (-c) := by
simpa only [integral_comp_neg_Ioi] using integral_exp_Iic (-c)
theorem integral_exp_neg_Ioi_zero : (∫ x : ℝ in Ioi 0, exp (-x)) = 1 := by
simpa only [neg_zero, exp_zero] using integral_exp_neg_Ioi 0
/-- If `0 < c`, then `(fun t : ℝ ↦ t ^ a)` is integrable on `(c, ∞)` for all `a < -1`. -/
theorem integrableOn_Ioi_rpow_of_lt {a : ℝ} (ha : a < -1) {c : ℝ} (hc : 0 < c) :
IntegrableOn (fun t : ℝ => t ^ a) (Ioi c) := by
have hd : ∀ x ∈ Ici c, HasDerivAt (fun t => t ^ (a + 1) / (a + 1)) (x ^ a) x := by
intro x hx
-- Porting note: helped `convert` with explicit arguments
convert (hasDerivAt_rpow_const (p := a + 1) (Or.inl (hc.trans_le hx).ne')).div_const _ using 1
field_simp [show a + 1 ≠ 0 from ne_of_lt (by linarith), mul_comm]
have ht : Tendsto (fun t => t ^ (a + 1) / (a + 1)) atTop (𝓝 (0 / (a + 1))) := by
apply Tendsto.div_const
simpa only [neg_neg] using tendsto_rpow_neg_atTop (by linarith : 0 < -(a + 1))
exact
integrableOn_Ioi_deriv_of_nonneg' hd (fun t ht => rpow_nonneg (hc.trans ht).le a) ht
theorem integrableOn_Ioi_rpow_iff {s t : ℝ} (ht : 0 < t) :
IntegrableOn (fun x ↦ x ^ s) (Ioi t) ↔ s < -1 := by
refine ⟨fun h ↦ ?_, fun h ↦ integrableOn_Ioi_rpow_of_lt h ht⟩
contrapose! h
intro H
have H' : IntegrableOn (fun x ↦ x ^ s) (Ioi (max 1 t)) :=
H.mono (Set.Ioi_subset_Ioi (le_max_right _ _)) le_rfl
have : IntegrableOn (fun x ↦ x⁻¹) (Ioi (max 1 t)) := by
apply H'.mono' measurable_inv.aestronglyMeasurable
filter_upwards [ae_restrict_mem measurableSet_Ioi] with x hx
have x_one : 1 ≤ x := ((le_max_left _ _).trans_lt (mem_Ioi.1 hx)).le
simp only [norm_inv, Real.norm_eq_abs, abs_of_nonneg (zero_le_one.trans x_one)]
rw [← Real.rpow_neg_one x]
exact Real.rpow_le_rpow_of_exponent_le x_one h
exact not_IntegrableOn_Ioi_inv this
/-- The real power function with any exponent is not integrable on `(0, +∞)`. -/
theorem not_integrableOn_Ioi_rpow (s : ℝ) : ¬ IntegrableOn (fun x ↦ x ^ s) (Ioi (0 : ℝ)) := by
intro h
rcases le_or_lt s (-1) with hs|hs
· have : IntegrableOn (fun x ↦ x ^ s) (Ioo (0 : ℝ) 1) := h.mono Ioo_subset_Ioi_self le_rfl
rw [integrableOn_Ioo_rpow_iff zero_lt_one] at this
exact hs.not_lt this
· have : IntegrableOn (fun x ↦ x ^ s) (Ioi (1 : ℝ)) := h.mono (Ioi_subset_Ioi zero_le_one) le_rfl
rw [integrableOn_Ioi_rpow_iff zero_lt_one] at this
exact hs.not_lt this
theorem setIntegral_Ioi_zero_rpow (s : ℝ) : ∫ x in Ioi (0 : ℝ), x ^ s = 0 :=
MeasureTheory.integral_undef (not_integrableOn_Ioi_rpow s)
theorem integral_Ioi_rpow_of_lt {a : ℝ} (ha : a < -1) {c : ℝ} (hc : 0 < c) :
∫ t : ℝ in Ioi c, t ^ a = -c ^ (a + 1) / (a + 1) := by
have hd : ∀ x ∈ Ici c, HasDerivAt (fun t => t ^ (a + 1) / (a + 1)) (x ^ a) x := by
intro x hx
convert (hasDerivAt_rpow_const (p := a + 1) (Or.inl (hc.trans_le hx).ne')).div_const _ using 1
field_simp [show a + 1 ≠ 0 from ne_of_lt (by linarith), mul_comm]
have ht : Tendsto (fun t => t ^ (a + 1) / (a + 1)) atTop (𝓝 (0 / (a + 1))) := by
apply Tendsto.div_const
simpa only [neg_neg] using tendsto_rpow_neg_atTop (by linarith : 0 < -(a + 1))
convert integral_Ioi_of_hasDerivAt_of_tendsto' hd (integrableOn_Ioi_rpow_of_lt ha hc) ht using 1
simp only [neg_div, zero_div, zero_sub]
theorem integrableOn_Ioi_cpow_of_lt {a : ℂ} (ha : a.re < -1) {c : ℝ} (hc : 0 < c) :
IntegrableOn (fun t : ℝ => (t : ℂ) ^ a) (Ioi c) := by
rw [IntegrableOn, ← integrable_norm_iff, ← IntegrableOn]
· refine (integrableOn_Ioi_rpow_of_lt ha hc).congr_fun (fun x hx => ?_) measurableSet_Ioi
· dsimp only
rw [Complex.norm_eq_abs, Complex.abs_cpow_eq_rpow_re_of_pos (hc.trans hx)]
· refine ContinuousOn.aestronglyMeasurable (fun t ht => ?_) measurableSet_Ioi
exact
(Complex.continuousAt_ofReal_cpow_const _ _ (Or.inr (hc.trans ht).ne')).continuousWithinAt
theorem integrableOn_Ioi_cpow_iff {s : ℂ} {t : ℝ} (ht : 0 < t) :
IntegrableOn (fun x : ℝ ↦ (x : ℂ) ^ s) (Ioi t) ↔ s.re < -1 := by
refine ⟨fun h ↦ ?_, fun h ↦ integrableOn_Ioi_cpow_of_lt h ht⟩
have B : IntegrableOn (fun a ↦ a ^ s.re) (Ioi t) := by
apply (integrableOn_congr_fun _ measurableSet_Ioi).1 h.norm
intro a ha
have : 0 < a := ht.trans ha
simp [Complex.abs_cpow_eq_rpow_re_of_pos this]
rwa [integrableOn_Ioi_rpow_iff ht] at B
/-- The complex power function with any exponent is not integrable on `(0, +∞)`. -/
theorem not_integrableOn_Ioi_cpow (s : ℂ) :
¬ IntegrableOn (fun x : ℝ ↦ (x : ℂ) ^ s) (Ioi (0 : ℝ)) := by
intro h
rcases le_or_lt s.re (-1) with hs|hs
· have : IntegrableOn (fun x : ℝ ↦ (x : ℂ) ^ s) (Ioo (0 : ℝ) 1) :=
h.mono Ioo_subset_Ioi_self le_rfl
rw [integrableOn_Ioo_cpow_iff zero_lt_one] at this
exact hs.not_lt this
· have : IntegrableOn (fun x : ℝ ↦ (x : ℂ) ^ s) (Ioi 1) :=
h.mono (Ioi_subset_Ioi zero_le_one) le_rfl
rw [integrableOn_Ioi_cpow_iff zero_lt_one] at this
exact hs.not_lt this
theorem setIntegral_Ioi_zero_cpow (s : ℂ) : ∫ x in Ioi (0 : ℝ), (x : ℂ) ^ s = 0 :=
MeasureTheory.integral_undef (not_integrableOn_Ioi_cpow s)
theorem integral_Ioi_cpow_of_lt {a : ℂ} (ha : a.re < -1) {c : ℝ} (hc : 0 < c) :
(∫ t : ℝ in Ioi c, (t : ℂ) ^ a) = -(c : ℂ) ^ (a + 1) / (a + 1) := by
refine
tendsto_nhds_unique
(intervalIntegral_tendsto_integral_Ioi c (integrableOn_Ioi_cpow_of_lt ha hc) tendsto_id) ?_
suffices
Tendsto (fun x : ℝ => ((x : ℂ) ^ (a + 1) - (c : ℂ) ^ (a + 1)) / (a + 1)) atTop
(𝓝 <| -c ^ (a + 1) / (a + 1)) by
refine this.congr' ((eventually_gt_atTop 0).mp (eventually_of_forall fun x hx => ?_))
dsimp only
rw [integral_cpow, id]
refine Or.inr ⟨?_, not_mem_uIcc_of_lt hc hx⟩
apply_fun Complex.re
rw [Complex.neg_re, Complex.one_re]
exact ha.ne
simp_rw [← zero_sub, sub_div]
refine (Tendsto.div_const ?_ _).sub_const _
rw [tendsto_zero_iff_norm_tendsto_zero]
refine
(tendsto_rpow_neg_atTop (by linarith : 0 < -(a.re + 1))).congr'
((eventually_gt_atTop 0).mp (eventually_of_forall fun x hx => ?_))
simp_rw [neg_neg, Complex.norm_eq_abs, Complex.abs_cpow_eq_rpow_re_of_pos hx, Complex.add_re,
Complex.one_re]
theorem integrable_inv_one_add_sq : Integrable fun (x : ℝ) ↦ (1 + x ^ 2)⁻¹ := by
suffices Integrable fun (x : ℝ) ↦ (1 + ‖x‖ ^ 2) ^ ((-2 : ℝ) / 2) by simpa [rpow_neg_one]
exact integrable_rpow_neg_one_add_norm_sq (by simp)
@[simp]
theorem integral_Iic_inv_one_add_sq {i : ℝ} :
∫ (x : ℝ) in Set.Iic i, (1 + x ^ 2)⁻¹ = arctan i + (π / 2) :=
integral_Iic_of_hasDerivAt_of_tendsto' (fun x _ => hasDerivAt_arctan' x)
integrable_inv_one_add_sq.integrableOn (tendsto_nhds_of_tendsto_nhdsWithin tendsto_arctan_atBot)
|>.trans (sub_neg_eq_add _ _)
@[simp]
theorem integral_Ioi_inv_one_add_sq {i : ℝ} :
∫ (x : ℝ) in Set.Ioi i, (1 + x ^ 2)⁻¹ = (π / 2) - arctan i :=
integral_Ioi_of_hasDerivAt_of_tendsto' (fun x _ => hasDerivAt_arctan' x)
integrable_inv_one_add_sq.integrableOn (tendsto_nhds_of_tendsto_nhdsWithin tendsto_arctan_atTop)
@[simp]
theorem integral_univ_inv_one_add_sq : ∫ (x : ℝ), (1 + x ^ 2)⁻¹ = π :=
(by ring : π = (π / 2) - (-(π / 2))) ▸ integral_of_hasDerivAt_of_tendsto hasDerivAt_arctan'
integrable_inv_one_add_sq (tendsto_nhds_of_tendsto_nhdsWithin tendsto_arctan_atBot)
(tendsto_nhds_of_tendsto_nhdsWithin tendsto_arctan_atTop)
|
Analysis\SpecialFunctions\Integrals.lean | /-
Copyright (c) 2021 Benjamin Davidson. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Benjamin Davidson
-/
import Mathlib.MeasureTheory.Integral.FundThmCalculus
import Mathlib.Analysis.SpecialFunctions.Trigonometric.ArctanDeriv
import Mathlib.Analysis.SpecialFunctions.NonIntegrable
import Mathlib.Analysis.SpecialFunctions.Pow.Deriv
/-!
# Integration of specific interval integrals
This file contains proofs of the integrals of various specific functions. This includes:
* Integrals of simple functions, such as `id`, `pow`, `inv`, `exp`, `log`
* Integrals of some trigonometric functions, such as `sin`, `cos`, `1 / (1 + x^2)`
* The integral of `cos x ^ 2 - sin x ^ 2`
* Reduction formulae for the integrals of `sin x ^ n` and `cos x ^ n` for `n ≥ 2`
* The computation of `∫ x in 0..π, sin x ^ n` as a product for even and odd `n` (used in proving the
Wallis product for pi)
* Integrals of the form `sin x ^ m * cos x ^ n`
With these lemmas, many simple integrals can be computed by `simp` or `norm_num`.
See `test/integration.lean` for specific examples.
This file also contains some facts about the interval integrability of specific functions.
This file is still being developed.
## Tags
integrate, integration, integrable, integrability
-/
open Real Nat Set Finset
open scoped Real Interval
variable {a b : ℝ} (n : ℕ)
namespace intervalIntegral
open MeasureTheory
variable {f : ℝ → ℝ} {μ ν : Measure ℝ} [IsLocallyFiniteMeasure μ] (c d : ℝ)
/-! ### Interval integrability -/
@[simp]
theorem intervalIntegrable_pow : IntervalIntegrable (fun x => x ^ n) μ a b :=
(continuous_pow n).intervalIntegrable a b
theorem intervalIntegrable_zpow {n : ℤ} (h : 0 ≤ n ∨ (0 : ℝ) ∉ [[a, b]]) :
IntervalIntegrable (fun x => x ^ n) μ a b :=
(continuousOn_id.zpow₀ n fun _ hx => h.symm.imp (ne_of_mem_of_not_mem hx) id).intervalIntegrable
/-- See `intervalIntegrable_rpow'` for a version with a weaker hypothesis on `r`, but assuming the
measure is volume. -/
theorem intervalIntegrable_rpow {r : ℝ} (h : 0 ≤ r ∨ (0 : ℝ) ∉ [[a, b]]) :
IntervalIntegrable (fun x => x ^ r) μ a b :=
(continuousOn_id.rpow_const fun _ hx =>
h.symm.imp (ne_of_mem_of_not_mem hx) id).intervalIntegrable
/-- See `intervalIntegrable_rpow` for a version applying to any locally finite measure, but with a
stronger hypothesis on `r`. -/
theorem intervalIntegrable_rpow' {r : ℝ} (h : -1 < r) :
IntervalIntegrable (fun x => x ^ r) volume a b := by
suffices ∀ c : ℝ, IntervalIntegrable (fun x => x ^ r) volume 0 c by
exact IntervalIntegrable.trans (this a).symm (this b)
have : ∀ c : ℝ, 0 ≤ c → IntervalIntegrable (fun x => x ^ r) volume 0 c := by
intro c hc
rw [intervalIntegrable_iff, uIoc_of_le hc]
have hderiv : ∀ x ∈ Ioo 0 c, HasDerivAt (fun x : ℝ => x ^ (r + 1) / (r + 1)) (x ^ r) x := by
intro x hx
convert (Real.hasDerivAt_rpow_const (p := r + 1) (Or.inl hx.1.ne')).div_const (r + 1) using 1
field_simp [(by linarith : r + 1 ≠ 0)]
apply integrableOn_deriv_of_nonneg _ hderiv
· intro x hx; apply rpow_nonneg hx.1.le
· refine (continuousOn_id.rpow_const ?_).div_const _; intro x _; right; linarith
intro c; rcases le_total 0 c with (hc | hc)
· exact this c hc
· rw [IntervalIntegrable.iff_comp_neg, neg_zero]
have m := (this (-c) (by linarith)).smul (cos (r * π))
rw [intervalIntegrable_iff] at m ⊢
refine m.congr_fun ?_ measurableSet_Ioc; intro x hx
rw [uIoc_of_le (by linarith : 0 ≤ -c)] at hx
simp only [Pi.smul_apply, Algebra.id.smul_eq_mul, log_neg_eq_log, mul_comm,
rpow_def_of_pos hx.1, rpow_def_of_neg (by linarith [hx.1] : -x < 0)]
/-- The power function `x ↦ x^s` is integrable on `(0, t)` iff `-1 < s`. -/
lemma integrableOn_Ioo_rpow_iff {s t : ℝ} (ht : 0 < t) :
IntegrableOn (fun x ↦ x ^ s) (Ioo (0 : ℝ) t) ↔ -1 < s := by
refine ⟨fun h ↦ ?_, fun h ↦ by simpa [intervalIntegrable_iff_integrableOn_Ioo_of_le ht.le]
using intervalIntegrable_rpow' h (a := 0) (b := t)⟩
contrapose! h
intro H
have I : 0 < min 1 t := lt_min zero_lt_one ht
have H' : IntegrableOn (fun x ↦ x ^ s) (Ioo 0 (min 1 t)) :=
H.mono (Set.Ioo_subset_Ioo le_rfl (min_le_right _ _)) le_rfl
have : IntegrableOn (fun x ↦ x⁻¹) (Ioo 0 (min 1 t)) := by
apply H'.mono' measurable_inv.aestronglyMeasurable
filter_upwards [ae_restrict_mem measurableSet_Ioo] with x hx
simp only [norm_inv, Real.norm_eq_abs, abs_of_nonneg (le_of_lt hx.1)]
rwa [← Real.rpow_neg_one x, Real.rpow_le_rpow_left_iff_of_base_lt_one hx.1]
exact lt_of_lt_of_le hx.2 (min_le_left _ _)
have : IntervalIntegrable (fun x ↦ x⁻¹) volume 0 (min 1 t) := by
rwa [intervalIntegrable_iff_integrableOn_Ioo_of_le I.le]
simp [intervalIntegrable_inv_iff, I.ne] at this
/-- See `intervalIntegrable_cpow'` for a version with a weaker hypothesis on `r`, but assuming the
measure is volume. -/
theorem intervalIntegrable_cpow {r : ℂ} (h : 0 ≤ r.re ∨ (0 : ℝ) ∉ [[a, b]]) :
IntervalIntegrable (fun x : ℝ => (x : ℂ) ^ r) μ a b := by
by_cases h2 : (0 : ℝ) ∉ [[a, b]]
· -- Easy case #1: 0 ∉ [a, b] -- use continuity.
refine (ContinuousAt.continuousOn fun x hx => ?_).intervalIntegrable
exact Complex.continuousAt_ofReal_cpow_const _ _ (Or.inr <| ne_of_mem_of_not_mem hx h2)
rw [eq_false h2, or_false_iff] at h
rcases lt_or_eq_of_le h with (h' | h')
· -- Easy case #2: 0 < re r -- again use continuity
exact (Complex.continuous_ofReal_cpow_const h').intervalIntegrable _ _
-- Now the hard case: re r = 0 and 0 is in the interval.
refine (IntervalIntegrable.intervalIntegrable_norm_iff ?_).mp ?_
· refine (measurable_of_continuousOn_compl_singleton (0 : ℝ) ?_).aestronglyMeasurable
exact ContinuousAt.continuousOn fun x hx =>
Complex.continuousAt_ofReal_cpow_const x r (Or.inr hx)
-- reduce to case of integral over `[0, c]`
suffices ∀ c : ℝ, IntervalIntegrable (fun x : ℝ => ‖(x : ℂ) ^ r‖) μ 0 c from
(this a).symm.trans (this b)
intro c
rcases le_or_lt 0 c with (hc | hc)
· -- case `0 ≤ c`: integrand is identically 1
have : IntervalIntegrable (fun _ => 1 : ℝ → ℝ) μ 0 c := intervalIntegrable_const
rw [intervalIntegrable_iff_integrableOn_Ioc_of_le hc] at this ⊢
refine IntegrableOn.congr_fun this (fun x hx => ?_) measurableSet_Ioc
dsimp only
rw [Complex.norm_eq_abs, Complex.abs_cpow_eq_rpow_re_of_pos hx.1, ← h', rpow_zero]
· -- case `c < 0`: integrand is identically constant, *except* at `x = 0` if `r ≠ 0`.
apply IntervalIntegrable.symm
rw [intervalIntegrable_iff_integrableOn_Ioc_of_le hc.le]
have : Ioc c 0 = Ioo c 0 ∪ {(0 : ℝ)} := by
rw [← Ioo_union_Icc_eq_Ioc hc (le_refl 0), ← Icc_def]
simp_rw [← le_antisymm_iff, setOf_eq_eq_singleton']
rw [this, integrableOn_union, and_comm]; constructor
· refine integrableOn_singleton_iff.mpr (Or.inr ?_)
exact isFiniteMeasureOnCompacts_of_isLocallyFiniteMeasure.lt_top_of_isCompact
isCompact_singleton
· have : ∀ x : ℝ, x ∈ Ioo c 0 → ‖Complex.exp (↑π * Complex.I * r)‖ = ‖(x : ℂ) ^ r‖ := by
intro x hx
rw [Complex.ofReal_cpow_of_nonpos hx.2.le, norm_mul, ← Complex.ofReal_neg,
Complex.norm_eq_abs (_ ^ _), Complex.abs_cpow_eq_rpow_re_of_pos (neg_pos.mpr hx.2), ← h',
rpow_zero, one_mul]
refine IntegrableOn.congr_fun ?_ this measurableSet_Ioo
rw [integrableOn_const]
refine Or.inr ((measure_mono Set.Ioo_subset_Icc_self).trans_lt ?_)
exact isFiniteMeasureOnCompacts_of_isLocallyFiniteMeasure.lt_top_of_isCompact isCompact_Icc
/-- See `intervalIntegrable_cpow` for a version applying to any locally finite measure, but with a
stronger hypothesis on `r`. -/
theorem intervalIntegrable_cpow' {r : ℂ} (h : -1 < r.re) :
IntervalIntegrable (fun x : ℝ => (x : ℂ) ^ r) volume a b := by
suffices ∀ c : ℝ, IntervalIntegrable (fun x => (x : ℂ) ^ r) volume 0 c by
exact IntervalIntegrable.trans (this a).symm (this b)
have : ∀ c : ℝ, 0 ≤ c → IntervalIntegrable (fun x => (x : ℂ) ^ r) volume 0 c := by
intro c hc
rw [← IntervalIntegrable.intervalIntegrable_norm_iff]
· rw [intervalIntegrable_iff]
apply IntegrableOn.congr_fun
· rw [← intervalIntegrable_iff]; exact intervalIntegral.intervalIntegrable_rpow' h
· intro x hx
rw [uIoc_of_le hc] at hx
dsimp only
rw [Complex.norm_eq_abs, Complex.abs_cpow_eq_rpow_re_of_pos hx.1]
· exact measurableSet_uIoc
· refine ContinuousOn.aestronglyMeasurable ?_ measurableSet_uIoc
refine ContinuousAt.continuousOn fun x hx => ?_
rw [uIoc_of_le hc] at hx
refine (continuousAt_cpow_const (Or.inl ?_)).comp Complex.continuous_ofReal.continuousAt
rw [Complex.ofReal_re]
exact hx.1
intro c; rcases le_total 0 c with (hc | hc)
· exact this c hc
· rw [IntervalIntegrable.iff_comp_neg, neg_zero]
have m := (this (-c) (by linarith)).const_mul (Complex.exp (π * Complex.I * r))
rw [intervalIntegrable_iff, uIoc_of_le (by linarith : 0 ≤ -c)] at m ⊢
refine m.congr_fun (fun x hx => ?_) measurableSet_Ioc
dsimp only
have : -x ≤ 0 := by linarith [hx.1]
rw [Complex.ofReal_cpow_of_nonpos this, mul_comm]
simp
/-- The complex power function `x ↦ x^s` is integrable on `(0, t)` iff `-1 < s.re`. -/
theorem integrableOn_Ioo_cpow_iff {s : ℂ} {t : ℝ} (ht : 0 < t) :
IntegrableOn (fun x : ℝ ↦ (x : ℂ) ^ s) (Ioo (0 : ℝ) t) ↔ -1 < s.re := by
refine ⟨fun h ↦ ?_, fun h ↦ by simpa [intervalIntegrable_iff_integrableOn_Ioo_of_le ht.le]
using intervalIntegrable_cpow' h (a := 0) (b := t)⟩
have B : IntegrableOn (fun a ↦ a ^ s.re) (Ioo 0 t) := by
apply (integrableOn_congr_fun _ measurableSet_Ioo).1 h.norm
intro a ha
simp [Complex.abs_cpow_eq_rpow_re_of_pos ha.1]
rwa [integrableOn_Ioo_rpow_iff ht] at B
@[simp]
theorem intervalIntegrable_id : IntervalIntegrable (fun x => x) μ a b :=
continuous_id.intervalIntegrable a b
-- @[simp] -- Porting note (#10618): simp can prove this
theorem intervalIntegrable_const : IntervalIntegrable (fun _ => c) μ a b :=
continuous_const.intervalIntegrable a b
theorem intervalIntegrable_one_div (h : ∀ x : ℝ, x ∈ [[a, b]] → f x ≠ 0)
(hf : ContinuousOn f [[a, b]]) : IntervalIntegrable (fun x => 1 / f x) μ a b :=
(continuousOn_const.div hf h).intervalIntegrable
@[simp]
theorem intervalIntegrable_inv (h : ∀ x : ℝ, x ∈ [[a, b]] → f x ≠ 0)
(hf : ContinuousOn f [[a, b]]) : IntervalIntegrable (fun x => (f x)⁻¹) μ a b := by
simpa only [one_div] using intervalIntegrable_one_div h hf
@[simp]
theorem intervalIntegrable_exp : IntervalIntegrable exp μ a b :=
continuous_exp.intervalIntegrable a b
@[simp]
theorem _root_.IntervalIntegrable.log (hf : ContinuousOn f [[a, b]])
(h : ∀ x : ℝ, x ∈ [[a, b]] → f x ≠ 0) :
IntervalIntegrable (fun x => log (f x)) μ a b :=
(ContinuousOn.log hf h).intervalIntegrable
@[simp]
theorem intervalIntegrable_log (h : (0 : ℝ) ∉ [[a, b]]) : IntervalIntegrable log μ a b :=
IntervalIntegrable.log continuousOn_id fun _ hx => ne_of_mem_of_not_mem hx h
@[simp]
theorem intervalIntegrable_sin : IntervalIntegrable sin μ a b :=
continuous_sin.intervalIntegrable a b
@[simp]
theorem intervalIntegrable_cos : IntervalIntegrable cos μ a b :=
continuous_cos.intervalIntegrable a b
theorem intervalIntegrable_one_div_one_add_sq :
IntervalIntegrable (fun x : ℝ => 1 / (↑1 + x ^ 2)) μ a b := by
refine (continuous_const.div ?_ fun x => ?_).intervalIntegrable a b
· fun_prop
· nlinarith
@[simp]
theorem intervalIntegrable_inv_one_add_sq :
IntervalIntegrable (fun x : ℝ => (↑1 + x ^ 2)⁻¹) μ a b := by
field_simp; exact mod_cast intervalIntegrable_one_div_one_add_sq
/-! ### Integrals of the form `c * ∫ x in a..b, f (c * x + d)` -/
section
@[simp]
theorem mul_integral_comp_mul_right : (c * ∫ x in a..b, f (x * c)) = ∫ x in a * c..b * c, f x :=
smul_integral_comp_mul_right f c
@[simp]
theorem mul_integral_comp_mul_left : (c * ∫ x in a..b, f (c * x)) = ∫ x in c * a..c * b, f x :=
smul_integral_comp_mul_left f c
@[simp]
theorem inv_mul_integral_comp_div : (c⁻¹ * ∫ x in a..b, f (x / c)) = ∫ x in a / c..b / c, f x :=
inv_smul_integral_comp_div f c
@[simp]
theorem mul_integral_comp_mul_add :
(c * ∫ x in a..b, f (c * x + d)) = ∫ x in c * a + d..c * b + d, f x :=
smul_integral_comp_mul_add f c d
@[simp]
theorem mul_integral_comp_add_mul :
(c * ∫ x in a..b, f (d + c * x)) = ∫ x in d + c * a..d + c * b, f x :=
smul_integral_comp_add_mul f c d
@[simp]
theorem inv_mul_integral_comp_div_add :
(c⁻¹ * ∫ x in a..b, f (x / c + d)) = ∫ x in a / c + d..b / c + d, f x :=
inv_smul_integral_comp_div_add f c d
@[simp]
theorem inv_mul_integral_comp_add_div :
(c⁻¹ * ∫ x in a..b, f (d + x / c)) = ∫ x in d + a / c..d + b / c, f x :=
inv_smul_integral_comp_add_div f c d
@[simp]
theorem mul_integral_comp_mul_sub :
(c * ∫ x in a..b, f (c * x - d)) = ∫ x in c * a - d..c * b - d, f x :=
smul_integral_comp_mul_sub f c d
@[simp]
theorem mul_integral_comp_sub_mul :
(c * ∫ x in a..b, f (d - c * x)) = ∫ x in d - c * b..d - c * a, f x :=
smul_integral_comp_sub_mul f c d
@[simp]
theorem inv_mul_integral_comp_div_sub :
(c⁻¹ * ∫ x in a..b, f (x / c - d)) = ∫ x in a / c - d..b / c - d, f x :=
inv_smul_integral_comp_div_sub f c d
@[simp]
theorem inv_mul_integral_comp_sub_div :
(c⁻¹ * ∫ x in a..b, f (d - x / c)) = ∫ x in d - b / c..d - a / c, f x :=
inv_smul_integral_comp_sub_div f c d
end
end intervalIntegral
open intervalIntegral
/-! ### Integrals of simple functions -/
theorem integral_cpow {r : ℂ} (h : -1 < r.re ∨ r ≠ -1 ∧ (0 : ℝ) ∉ [[a, b]]) :
(∫ x : ℝ in a..b, (x : ℂ) ^ r) = ((b : ℂ) ^ (r + 1) - (a : ℂ) ^ (r + 1)) / (r + 1) := by
rw [sub_div]
have hr : r + 1 ≠ 0 := by
cases' h with h h
· apply_fun Complex.re
rw [Complex.add_re, Complex.one_re, Complex.zero_re, Ne, add_eq_zero_iff_eq_neg]
exact h.ne'
· rw [Ne, ← add_eq_zero_iff_eq_neg] at h; exact h.1
by_cases hab : (0 : ℝ) ∉ [[a, b]]
· apply integral_eq_sub_of_hasDerivAt (fun x hx => ?_)
(intervalIntegrable_cpow (r := r) <| Or.inr hab)
refine hasDerivAt_ofReal_cpow (ne_of_mem_of_not_mem hx hab) ?_
contrapose! hr; rwa [add_eq_zero_iff_eq_neg]
replace h : -1 < r.re := by tauto
suffices ∀ c : ℝ, (∫ x : ℝ in (0)..c, (x : ℂ) ^ r) =
(c : ℂ) ^ (r + 1) / (r + 1) - (0 : ℂ) ^ (r + 1) / (r + 1) by
rw [← integral_add_adjacent_intervals (@intervalIntegrable_cpow' a 0 r h)
(@intervalIntegrable_cpow' 0 b r h), integral_symm, this a, this b, Complex.zero_cpow hr]
ring
intro c
apply integral_eq_sub_of_hasDeriv_right
· refine ((Complex.continuous_ofReal_cpow_const ?_).div_const _).continuousOn
rwa [Complex.add_re, Complex.one_re, ← neg_lt_iff_pos_add]
· refine fun x hx => (hasDerivAt_ofReal_cpow ?_ ?_).hasDerivWithinAt
· rcases le_total c 0 with (hc | hc)
· rw [max_eq_left hc] at hx; exact hx.2.ne
· rw [min_eq_left hc] at hx; exact hx.1.ne'
· contrapose! hr; rw [hr]; ring
· exact intervalIntegrable_cpow' h
theorem integral_rpow {r : ℝ} (h : -1 < r ∨ r ≠ -1 ∧ (0 : ℝ) ∉ [[a, b]]) :
∫ x in a..b, x ^ r = (b ^ (r + 1) - a ^ (r + 1)) / (r + 1) := by
have h' : -1 < (r : ℂ).re ∨ (r : ℂ) ≠ -1 ∧ (0 : ℝ) ∉ [[a, b]] := by
cases h
· left; rwa [Complex.ofReal_re]
· right; rwa [← Complex.ofReal_one, ← Complex.ofReal_neg, Ne, Complex.ofReal_inj]
have :
(∫ x in a..b, (x : ℂ) ^ (r : ℂ)) = ((b : ℂ) ^ (r + 1 : ℂ) - (a : ℂ) ^ (r + 1 : ℂ)) / (r + 1) :=
integral_cpow h'
apply_fun Complex.re at this; convert this
· simp_rw [intervalIntegral_eq_integral_uIoc, Complex.real_smul, Complex.re_ofReal_mul]
-- Porting note: was `change ... with ...`
have : Complex.re = RCLike.re := rfl
rw [this, ← integral_re]
· rfl
refine intervalIntegrable_iff.mp ?_
cases' h' with h' h'
· exact intervalIntegrable_cpow' h'
· exact intervalIntegrable_cpow (Or.inr h'.2)
· rw [(by push_cast; rfl : (r : ℂ) + 1 = ((r + 1 : ℝ) : ℂ))]
simp_rw [div_eq_inv_mul, ← Complex.ofReal_inv, Complex.re_ofReal_mul, Complex.sub_re]
rfl
theorem integral_zpow {n : ℤ} (h : 0 ≤ n ∨ n ≠ -1 ∧ (0 : ℝ) ∉ [[a, b]]) :
∫ x in a..b, x ^ n = (b ^ (n + 1) - a ^ (n + 1)) / (n + 1) := by
replace h : -1 < (n : ℝ) ∨ (n : ℝ) ≠ -1 ∧ (0 : ℝ) ∉ [[a, b]] := mod_cast h
exact mod_cast integral_rpow h
@[simp]
theorem integral_pow : ∫ x in a..b, x ^ n = (b ^ (n + 1) - a ^ (n + 1)) / (n + 1) := by
simpa only [← Int.ofNat_succ, zpow_natCast] using integral_zpow (Or.inl n.cast_nonneg)
/-- Integral of `|x - a| ^ n` over `Ι a b`. This integral appears in the proof of the
Picard-Lindelöf/Cauchy-Lipschitz theorem. -/
theorem integral_pow_abs_sub_uIoc : ∫ x in Ι a b, |x - a| ^ n = |b - a| ^ (n + 1) / (n + 1) := by
rcases le_or_lt a b with hab | hab
· calc
∫ x in Ι a b, |x - a| ^ n = ∫ x in a..b, |x - a| ^ n := by
rw [uIoc_of_le hab, ← integral_of_le hab]
_ = ∫ x in (0)..(b - a), x ^ n := by
simp only [integral_comp_sub_right fun x => |x| ^ n, sub_self]
refine integral_congr fun x hx => congr_arg₂ Pow.pow (abs_of_nonneg <| ?_) rfl
rw [uIcc_of_le (sub_nonneg.2 hab)] at hx
exact hx.1
_ = |b - a| ^ (n + 1) / (n + 1) := by simp [abs_of_nonneg (sub_nonneg.2 hab)]
· calc
∫ x in Ι a b, |x - a| ^ n = ∫ x in b..a, |x - a| ^ n := by
rw [uIoc_of_ge hab.le, ← integral_of_le hab.le]
_ = ∫ x in b - a..0, (-x) ^ n := by
simp only [integral_comp_sub_right fun x => |x| ^ n, sub_self]
refine integral_congr fun x hx => congr_arg₂ Pow.pow (abs_of_nonpos <| ?_) rfl
rw [uIcc_of_le (sub_nonpos.2 hab.le)] at hx
exact hx.2
_ = |b - a| ^ (n + 1) / (n + 1) := by
simp [integral_comp_neg fun x => x ^ n, abs_of_neg (sub_neg.2 hab)]
@[simp]
theorem integral_id : ∫ x in a..b, x = (b ^ 2 - a ^ 2) / 2 := by
have := @integral_pow a b 1
norm_num at this
exact this
-- @[simp] -- Porting note (#10618): simp can prove this
theorem integral_one : (∫ _ in a..b, (1 : ℝ)) = b - a := by
simp only [mul_one, smul_eq_mul, integral_const]
theorem integral_const_on_unit_interval : ∫ _ in a..a + 1, b = b := by simp
@[simp]
theorem integral_inv (h : (0 : ℝ) ∉ [[a, b]]) : ∫ x in a..b, x⁻¹ = log (b / a) := by
have h' := fun x (hx : x ∈ [[a, b]]) => ne_of_mem_of_not_mem hx h
rw [integral_deriv_eq_sub' _ deriv_log' (fun x hx => differentiableAt_log (h' x hx))
(continuousOn_inv₀.mono <| subset_compl_singleton_iff.mpr h),
log_div (h' b right_mem_uIcc) (h' a left_mem_uIcc)]
@[simp]
theorem integral_inv_of_pos (ha : 0 < a) (hb : 0 < b) : ∫ x in a..b, x⁻¹ = log (b / a) :=
integral_inv <| not_mem_uIcc_of_lt ha hb
@[simp]
theorem integral_inv_of_neg (ha : a < 0) (hb : b < 0) : ∫ x in a..b, x⁻¹ = log (b / a) :=
integral_inv <| not_mem_uIcc_of_gt ha hb
theorem integral_one_div (h : (0 : ℝ) ∉ [[a, b]]) : ∫ x : ℝ in a..b, 1 / x = log (b / a) := by
simp only [one_div, integral_inv h]
theorem integral_one_div_of_pos (ha : 0 < a) (hb : 0 < b) :
∫ x : ℝ in a..b, 1 / x = log (b / a) := by simp only [one_div, integral_inv_of_pos ha hb]
theorem integral_one_div_of_neg (ha : a < 0) (hb : b < 0) :
∫ x : ℝ in a..b, 1 / x = log (b / a) := by simp only [one_div, integral_inv_of_neg ha hb]
@[simp]
theorem integral_exp : ∫ x in a..b, exp x = exp b - exp a := by
rw [integral_deriv_eq_sub']
· simp
· exact fun _ _ => differentiableAt_exp
· exact continuousOn_exp
theorem integral_exp_mul_complex {c : ℂ} (hc : c ≠ 0) :
(∫ x in a..b, Complex.exp (c * x)) = (Complex.exp (c * b) - Complex.exp (c * a)) / c := by
have D : ∀ x : ℝ, HasDerivAt (fun y : ℝ => Complex.exp (c * y) / c) (Complex.exp (c * x)) x := by
intro x
conv => congr
rw [← mul_div_cancel_right₀ (Complex.exp (c * x)) hc]
apply ((Complex.hasDerivAt_exp _).comp x _).div_const c
simpa only [mul_one] using ((hasDerivAt_id (x : ℂ)).const_mul _).comp_ofReal
rw [integral_deriv_eq_sub' _ (funext fun x => (D x).deriv) fun x _ => (D x).differentiableAt]
· ring
· fun_prop
@[simp]
theorem integral_log (h : (0 : ℝ) ∉ [[a, b]]) :
∫ x in a..b, log x = b * log b - a * log a - b + a := by
have h' := fun x (hx : x ∈ [[a, b]]) => ne_of_mem_of_not_mem hx h
have heq := fun x hx => mul_inv_cancel (h' x hx)
convert integral_mul_deriv_eq_deriv_mul (fun x hx => hasDerivAt_log (h' x hx))
(fun x _ => hasDerivAt_id x) (continuousOn_inv₀.mono <|
subset_compl_singleton_iff.mpr h).intervalIntegrable
continuousOn_const.intervalIntegrable using 1 <;>
simp [integral_congr heq, mul_comm, ← sub_add]
@[simp]
theorem integral_log_of_pos (ha : 0 < a) (hb : 0 < b) :
∫ x in a..b, log x = b * log b - a * log a - b + a :=
integral_log <| not_mem_uIcc_of_lt ha hb
@[simp]
theorem integral_log_of_neg (ha : a < 0) (hb : b < 0) :
∫ x in a..b, log x = b * log b - a * log a - b + a :=
integral_log <| not_mem_uIcc_of_gt ha hb
@[simp]
theorem integral_sin : ∫ x in a..b, sin x = cos a - cos b := by
rw [integral_deriv_eq_sub' fun x => -cos x]
· ring
· norm_num
· simp only [differentiableAt_neg_iff, differentiableAt_cos, implies_true]
· exact continuousOn_sin
@[simp]
theorem integral_cos : ∫ x in a..b, cos x = sin b - sin a := by
rw [integral_deriv_eq_sub']
· norm_num
· simp only [differentiableAt_sin, implies_true]
· exact continuousOn_cos
theorem integral_cos_mul_complex {z : ℂ} (hz : z ≠ 0) (a b : ℝ) :
(∫ x in a..b, Complex.cos (z * x)) = Complex.sin (z * b) / z - Complex.sin (z * a) / z := by
apply integral_eq_sub_of_hasDerivAt
swap
· apply Continuous.intervalIntegrable
exact Complex.continuous_cos.comp (continuous_const.mul Complex.continuous_ofReal)
intro x _
have a := Complex.hasDerivAt_sin (↑x * z)
have b : HasDerivAt (fun y => y * z : ℂ → ℂ) z ↑x := hasDerivAt_mul_const _
have c : HasDerivAt (fun y : ℂ => Complex.sin (y * z)) _ ↑x := HasDerivAt.comp (𝕜 := ℂ) x a b
have d := HasDerivAt.comp_ofReal (c.div_const z)
simp only [mul_comm] at d
convert d using 1
conv_rhs => arg 1; rw [mul_comm]
rw [mul_div_cancel_right₀ _ hz]
theorem integral_cos_sq_sub_sin_sq :
∫ x in a..b, cos x ^ 2 - sin x ^ 2 = sin b * cos b - sin a * cos a := by
simpa only [sq, sub_eq_add_neg, neg_mul_eq_mul_neg] using
integral_deriv_mul_eq_sub (fun x _ => hasDerivAt_sin x) (fun x _ => hasDerivAt_cos x)
continuousOn_cos.intervalIntegrable continuousOn_sin.neg.intervalIntegrable
theorem integral_one_div_one_add_sq :
(∫ x : ℝ in a..b, ↑1 / (↑1 + x ^ 2)) = arctan b - arctan a := by
refine integral_deriv_eq_sub' _ Real.deriv_arctan (fun _ _ => differentiableAt_arctan _)
(continuous_const.div ?_ fun x => ?_).continuousOn
· fun_prop
· nlinarith
@[simp]
theorem integral_inv_one_add_sq : (∫ x : ℝ in a..b, (↑1 + x ^ 2)⁻¹) = arctan b - arctan a := by
simp only [← one_div, integral_one_div_one_add_sq]
section RpowCpow
open Complex
theorem integral_mul_cpow_one_add_sq {t : ℂ} (ht : t ≠ -1) :
(∫ x : ℝ in a..b, (x : ℂ) * ((1 : ℂ) + ↑x ^ 2) ^ t) =
((1 : ℂ) + (b : ℂ) ^ 2) ^ (t + 1) / (2 * (t + ↑1)) -
((1 : ℂ) + (a : ℂ) ^ 2) ^ (t + 1) / (2 * (t + ↑1)) := by
have : t + 1 ≠ 0 := by contrapose! ht; rwa [add_eq_zero_iff_eq_neg] at ht
apply integral_eq_sub_of_hasDerivAt
· intro x _
have f : HasDerivAt (fun y : ℂ => 1 + y ^ 2) (2 * x : ℂ) x := by
convert (hasDerivAt_pow 2 (x : ℂ)).const_add 1
simp
have g :
∀ {z : ℂ}, 0 < z.re → HasDerivAt (fun z => z ^ (t + 1) / (2 * (t + 1))) (z ^ t / 2) z := by
intro z hz
convert (HasDerivAt.cpow_const (c := t + 1) (hasDerivAt_id _)
(Or.inl hz)).div_const (2 * (t + 1)) using 1
field_simp
ring
convert (HasDerivAt.comp (↑x) (g _) f).comp_ofReal using 1
· field_simp; ring
· exact mod_cast add_pos_of_pos_of_nonneg zero_lt_one (sq_nonneg x)
· apply Continuous.intervalIntegrable
refine continuous_ofReal.mul ?_
apply Continuous.cpow
· exact continuous_const.add (continuous_ofReal.pow 2)
· exact continuous_const
· intro a
norm_cast
exact ofReal_mem_slitPlane.2 <| add_pos_of_pos_of_nonneg one_pos <| sq_nonneg a
theorem integral_mul_rpow_one_add_sq {t : ℝ} (ht : t ≠ -1) :
(∫ x : ℝ in a..b, x * (↑1 + x ^ 2) ^ t) =
(↑1 + b ^ 2) ^ (t + 1) / (↑2 * (t + ↑1)) - (↑1 + a ^ 2) ^ (t + 1) / (↑2 * (t + ↑1)) := by
have : ∀ x s : ℝ, (((↑1 + x ^ 2) ^ s : ℝ) : ℂ) = (1 + (x : ℂ) ^ 2) ^ (s : ℂ) := by
intro x s
norm_cast
rw [ofReal_cpow, ofReal_add, ofReal_pow, ofReal_one]
exact add_nonneg zero_le_one (sq_nonneg x)
rw [← ofReal_inj]
convert integral_mul_cpow_one_add_sq (_ : (t : ℂ) ≠ -1)
· rw [← intervalIntegral.integral_ofReal]
congr with x : 1
rw [ofReal_mul, this x t]
· simp_rw [ofReal_sub, ofReal_div, this a (t + 1), this b (t + 1)]
push_cast; rfl
· rw [← ofReal_one, ← ofReal_neg, Ne, ofReal_inj]
exact ht
end RpowCpow
/-! ### Integral of `sin x ^ n` -/
theorem integral_sin_pow_aux :
(∫ x in a..b, sin x ^ (n + 2)) =
(sin a ^ (n + 1) * cos a - sin b ^ (n + 1) * cos b + (↑n + 1) * ∫ x in a..b, sin x ^ n) -
(↑n + 1) * ∫ x in a..b, sin x ^ (n + 2) := by
let C := sin a ^ (n + 1) * cos a - sin b ^ (n + 1) * cos b
have h : ∀ α β γ : ℝ, β * α * γ * α = β * (α * α * γ) := fun α β γ => by ring
have hu : ∀ x ∈ [[a, b]],
HasDerivAt (fun y => sin y ^ (n + 1)) ((n + 1 : ℕ) * cos x * sin x ^ n) x :=
fun x _ => by simpa only [mul_right_comm] using (hasDerivAt_sin x).pow (n + 1)
have hv : ∀ x ∈ [[a, b]], HasDerivAt (-cos) (sin x) x := fun x _ => by
simpa only [neg_neg] using (hasDerivAt_cos x).neg
have H := integral_mul_deriv_eq_deriv_mul hu hv ?_ ?_
· calc
(∫ x in a..b, sin x ^ (n + 2)) = ∫ x in a..b, sin x ^ (n + 1) * sin x := by
simp only [_root_.pow_succ]
_ = C + (↑n + 1) * ∫ x in a..b, cos x ^ 2 * sin x ^ n := by simp [H, h, sq]; ring
_ = C + (↑n + 1) * ∫ x in a..b, sin x ^ n - sin x ^ (n + 2) := by
simp [cos_sq', sub_mul, ← pow_add, add_comm]
_ = (C + (↑n + 1) * ∫ x in a..b, sin x ^ n) - (↑n + 1) * ∫ x in a..b, sin x ^ (n + 2) := by
rw [integral_sub, mul_sub, add_sub_assoc] <;>
apply Continuous.intervalIntegrable <;> fun_prop
all_goals apply Continuous.intervalIntegrable; fun_prop
/-- The reduction formula for the integral of `sin x ^ n` for any natural `n ≥ 2`. -/
theorem integral_sin_pow :
(∫ x in a..b, sin x ^ (n + 2)) =
(sin a ^ (n + 1) * cos a - sin b ^ (n + 1) * cos b) / (n + 2) +
(n + 1) / (n + 2) * ∫ x in a..b, sin x ^ n := by
field_simp
convert eq_sub_iff_add_eq.mp (integral_sin_pow_aux n) using 1
ring
@[simp]
theorem integral_sin_sq : ∫ x in a..b, sin x ^ 2 = (sin a * cos a - sin b * cos b + b - a) / 2 := by
field_simp [integral_sin_pow, add_sub_assoc]
theorem integral_sin_pow_odd :
(∫ x in (0)..π, sin x ^ (2 * n + 1)) = 2 * ∏ i ∈ range n, (2 * (i : ℝ) + 2) / (2 * i + 3) := by
induction' n with k ih; · norm_num
rw [prod_range_succ_comm, mul_left_comm, ← ih, mul_succ, integral_sin_pow]
norm_cast
simp [-cast_add, field_simps]
theorem integral_sin_pow_even :
(∫ x in (0)..π, sin x ^ (2 * n)) = π * ∏ i ∈ range n, (2 * (i : ℝ) + 1) / (2 * i + 2) := by
induction' n with k ih; · simp
rw [prod_range_succ_comm, mul_left_comm, ← ih, mul_succ, integral_sin_pow]
norm_cast
simp [-cast_add, field_simps]
theorem integral_sin_pow_pos : 0 < ∫ x in (0)..π, sin x ^ n := by
rcases even_or_odd' n with ⟨k, rfl | rfl⟩ <;>
simp only [integral_sin_pow_even, integral_sin_pow_odd] <;>
refine mul_pos (by norm_num [pi_pos]) (prod_pos fun n _ => div_pos ?_ ?_) <;>
norm_cast <;>
omega
theorem integral_sin_pow_succ_le : (∫ x in (0)..π, sin x ^ (n + 1)) ≤ ∫ x in (0)..π, sin x ^ n := by
let H x h := pow_le_pow_of_le_one (sin_nonneg_of_mem_Icc h) (sin_le_one x) (n.le_add_right 1)
refine integral_mono_on pi_pos.le ?_ ?_ H <;> exact (continuous_sin.pow _).intervalIntegrable 0 π
theorem integral_sin_pow_antitone : Antitone fun n : ℕ => ∫ x in (0)..π, sin x ^ n :=
antitone_nat_of_succ_le integral_sin_pow_succ_le
/-! ### Integral of `cos x ^ n` -/
theorem integral_cos_pow_aux :
(∫ x in a..b, cos x ^ (n + 2)) =
(cos b ^ (n + 1) * sin b - cos a ^ (n + 1) * sin a + (n + 1) * ∫ x in a..b, cos x ^ n) -
(n + 1) * ∫ x in a..b, cos x ^ (n + 2) := by
let C := cos b ^ (n + 1) * sin b - cos a ^ (n + 1) * sin a
have h : ∀ α β γ : ℝ, β * α * γ * α = β * (α * α * γ) := fun α β γ => by ring
have hu : ∀ x ∈ [[a, b]],
HasDerivAt (fun y => cos y ^ (n + 1)) (-(n + 1 : ℕ) * sin x * cos x ^ n) x :=
fun x _ => by
simpa only [mul_right_comm, neg_mul, mul_neg] using (hasDerivAt_cos x).pow (n + 1)
have hv : ∀ x ∈ [[a, b]], HasDerivAt sin (cos x) x := fun x _ => hasDerivAt_sin x
have H := integral_mul_deriv_eq_deriv_mul hu hv ?_ ?_
· calc
(∫ x in a..b, cos x ^ (n + 2)) = ∫ x in a..b, cos x ^ (n + 1) * cos x := by
simp only [_root_.pow_succ]
_ = C + (n + 1) * ∫ x in a..b, sin x ^ 2 * cos x ^ n := by simp [H, h, sq, -neg_add_rev]
_ = C + (n + 1) * ∫ x in a..b, cos x ^ n - cos x ^ (n + 2) := by
simp [sin_sq, sub_mul, ← pow_add, add_comm]
_ = (C + (n + 1) * ∫ x in a..b, cos x ^ n) - (n + 1) * ∫ x in a..b, cos x ^ (n + 2) := by
rw [integral_sub, mul_sub, add_sub_assoc] <;>
apply Continuous.intervalIntegrable <;> fun_prop
all_goals apply Continuous.intervalIntegrable; fun_prop
/-- The reduction formula for the integral of `cos x ^ n` for any natural `n ≥ 2`. -/
theorem integral_cos_pow :
(∫ x in a..b, cos x ^ (n + 2)) =
(cos b ^ (n + 1) * sin b - cos a ^ (n + 1) * sin a) / (n + 2) +
(n + 1) / (n + 2) * ∫ x in a..b, cos x ^ n := by
field_simp
convert eq_sub_iff_add_eq.mp (integral_cos_pow_aux n) using 1
ring
@[simp]
theorem integral_cos_sq : ∫ x in a..b, cos x ^ 2 = (cos b * sin b - cos a * sin a + b - a) / 2 := by
field_simp [integral_cos_pow, add_sub_assoc]
/-! ### Integral of `sin x ^ m * cos x ^ n` -/
/-- Simplification of the integral of `sin x ^ m * cos x ^ n`, case `n` is odd. -/
theorem integral_sin_pow_mul_cos_pow_odd (m n : ℕ) :
(∫ x in a..b, sin x ^ m * cos x ^ (2 * n + 1)) = ∫ u in sin a..sin b, u^m * (↑1 - u ^ 2) ^ n :=
have hc : Continuous fun u : ℝ => u ^ m * (↑1 - u ^ 2) ^ n := by fun_prop
calc
(∫ x in a..b, sin x ^ m * cos x ^ (2 * n + 1)) =
∫ x in a..b, sin x ^ m * (↑1 - sin x ^ 2) ^ n * cos x := by
simp only [_root_.pow_zero, _root_.pow_succ, mul_assoc, pow_mul, one_mul]
congr! 5
rw [← sq, ← sq, cos_sq']
_ = ∫ u in sin a..sin b, u ^ m * (1 - u ^ 2) ^ n := by
-- Note(kmill): Didn't need `by exact`, but elaboration order seems to matter here.
exact integral_comp_mul_deriv (fun x _ => hasDerivAt_sin x) continuousOn_cos hc
/-- The integral of `sin x * cos x`, given in terms of sin².
See `integral_sin_mul_cos₂` below for the integral given in terms of cos². -/
@[simp]
theorem integral_sin_mul_cos₁ : ∫ x in a..b, sin x * cos x = (sin b ^ 2 - sin a ^ 2) / 2 := by
simpa using integral_sin_pow_mul_cos_pow_odd 1 0
@[simp]
theorem integral_sin_sq_mul_cos :
∫ x in a..b, sin x ^ 2 * cos x = (sin b ^ 3 - sin a ^ 3) / 3 := by
have := @integral_sin_pow_mul_cos_pow_odd a b 2 0
norm_num at this; exact this
@[simp]
theorem integral_cos_pow_three :
∫ x in a..b, cos x ^ 3 = sin b - sin a - (sin b ^ 3 - sin a ^ 3) / 3 := by
have := @integral_sin_pow_mul_cos_pow_odd a b 0 1
norm_num at this; exact this
/-- Simplification of the integral of `sin x ^ m * cos x ^ n`, case `m` is odd. -/
theorem integral_sin_pow_odd_mul_cos_pow (m n : ℕ) :
(∫ x in a..b, sin x ^ (2 * m + 1) * cos x ^ n) = ∫ u in cos b..cos a, u^n * (↑1 - u ^ 2) ^ m :=
have hc : Continuous fun u : ℝ => u ^ n * (↑1 - u ^ 2) ^ m := by fun_prop
calc
(∫ x in a..b, sin x ^ (2 * m + 1) * cos x ^ n) =
-∫ x in b..a, sin x ^ (2 * m + 1) * cos x ^ n := by rw [integral_symm]
_ = ∫ x in b..a, (↑1 - cos x ^ 2) ^ m * -sin x * cos x ^ n := by
simp only [_root_.pow_succ, pow_mul, _root_.pow_zero, one_mul, mul_neg, neg_mul,
integral_neg, neg_inj]
congr! 5
rw [← sq, ← sq, sin_sq]
_ = ∫ x in b..a, cos x ^ n * (↑1 - cos x ^ 2) ^ m * -sin x := by congr; ext; ring
_ = ∫ u in cos b..cos a, u ^ n * (↑1 - u ^ 2) ^ m :=
integral_comp_mul_deriv (fun x _ => hasDerivAt_cos x) continuousOn_sin.neg hc
/-- The integral of `sin x * cos x`, given in terms of cos².
See `integral_sin_mul_cos₁` above for the integral given in terms of sin². -/
theorem integral_sin_mul_cos₂ : ∫ x in a..b, sin x * cos x = (cos a ^ 2 - cos b ^ 2) / 2 := by
simpa using integral_sin_pow_odd_mul_cos_pow 0 1
@[simp]
theorem integral_sin_mul_cos_sq :
∫ x in a..b, sin x * cos x ^ 2 = (cos a ^ 3 - cos b ^ 3) / 3 := by
have := @integral_sin_pow_odd_mul_cos_pow a b 0 2
norm_num at this; exact this
@[simp]
theorem integral_sin_pow_three :
∫ x in a..b, sin x ^ 3 = cos a - cos b - (cos a ^ 3 - cos b ^ 3) / 3 := by
have := @integral_sin_pow_odd_mul_cos_pow a b 1 0
norm_num at this; exact this
/-- Simplification of the integral of `sin x ^ m * cos x ^ n`, case `m` and `n` are both even. -/
theorem integral_sin_pow_even_mul_cos_pow_even (m n : ℕ) :
(∫ x in a..b, sin x ^ (2 * m) * cos x ^ (2 * n)) =
∫ x in a..b, ((1 - cos (2 * x)) / 2) ^ m * ((1 + cos (2 * x)) / 2) ^ n := by
field_simp [pow_mul, sin_sq, cos_sq, ← sub_sub, (by ring : (2 : ℝ) - 1 = 1)]
@[simp]
theorem integral_sin_sq_mul_cos_sq :
∫ x in a..b, sin x ^ 2 * cos x ^ 2 = (b - a) / 8 - (sin (4 * b) - sin (4 * a)) / 32 := by
convert integral_sin_pow_even_mul_cos_pow_even 1 1 using 1
have h1 : ∀ c : ℝ, (↑1 - c) / ↑2 * ((↑1 + c) / ↑2) = (↑1 - c ^ 2) / 4 := fun c => by ring
have h2 : Continuous fun x => cos (2 * x) ^ 2 := by fun_prop
have h3 : ∀ x, cos x * sin x = sin (2 * x) / 2 := by intro; rw [sin_two_mul]; ring
have h4 : ∀ d : ℝ, 2 * (2 * d) = 4 * d := fun d => by ring
simp [h1, h2.intervalIntegrable, integral_comp_mul_left fun x => cos x ^ 2, h3, h4]
ring
/-! ### Integral of miscellaneous functions -/
theorem integral_sqrt_one_sub_sq : ∫ x in (-1 : ℝ)..1, √(1 - x ^ 2 : ℝ) = π / 2 :=
calc
_ = ∫ x in sin (-(π / 2)).. sin (π / 2), √(1 - x ^ 2 : ℝ) := by rw [sin_neg, sin_pi_div_two]
_ = ∫ x in (-(π / 2))..(π / 2), √(1 - sin x ^ 2 : ℝ) * cos x :=
(integral_comp_mul_deriv (fun x _ => hasDerivAt_sin x) continuousOn_cos
(by fun_prop)).symm
_ = ∫ x in (-(π / 2))..(π / 2), cos x ^ 2 := by
refine integral_congr_ae (MeasureTheory.ae_of_all _ fun _ h => ?_)
rw [uIoc_of_le (neg_le_self (le_of_lt (half_pos Real.pi_pos))), Set.mem_Ioc] at h
rw [← Real.cos_eq_sqrt_one_sub_sin_sq (le_of_lt h.1) h.2, pow_two]
_ = π / 2 := by simp
|
Analysis\SpecialFunctions\JapaneseBracket.lean | /-
Copyright (c) 2022 Moritz Doll. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Moritz Doll
-/
import Mathlib.Analysis.SpecialFunctions.Integrals
import Mathlib.MeasureTheory.Measure.Lebesgue.EqHaar
import Mathlib.MeasureTheory.Integral.Layercake
/-!
# Japanese Bracket
In this file, we show that Japanese bracket $(1 + \|x\|^2)^{1/2}$ can be estimated from above
and below by $1 + \|x\|$.
The functions $(1 + \|x\|^2)^{-r/2}$ and $(1 + |x|)^{-r}$ are integrable provided that `r` is larger
than the dimension.
## Main statements
* `integrable_one_add_norm`: the function $(1 + |x|)^{-r}$ is integrable
* `integrable_jap` the Japanese bracket is integrable
-/
noncomputable section
open scoped NNReal Filter Topology ENNReal
open Asymptotics Filter Set Real MeasureTheory FiniteDimensional
variable {E : Type*} [NormedAddCommGroup E]
theorem sqrt_one_add_norm_sq_le (x : E) : √((1 : ℝ) + ‖x‖ ^ 2) ≤ 1 + ‖x‖ := by
rw [sqrt_le_left (by positivity)]
simp [add_sq]
theorem one_add_norm_le_sqrt_two_mul_sqrt (x : E) :
(1 : ℝ) + ‖x‖ ≤ √2 * √(1 + ‖x‖ ^ 2) := by
rw [← sqrt_mul zero_le_two]
have := sq_nonneg (‖x‖ - 1)
apply le_sqrt_of_sq_le
linarith
theorem rpow_neg_one_add_norm_sq_le {r : ℝ} (x : E) (hr : 0 < r) :
((1 : ℝ) + ‖x‖ ^ 2) ^ (-r / 2) ≤ (2 : ℝ) ^ (r / 2) * (1 + ‖x‖) ^ (-r) :=
calc
((1 : ℝ) + ‖x‖ ^ 2) ^ (-r / 2)
= (2 : ℝ) ^ (r / 2) * ((√2 * √((1 : ℝ) + ‖x‖ ^ 2)) ^ r)⁻¹ := by
rw [rpow_div_two_eq_sqrt, rpow_div_two_eq_sqrt, mul_rpow, mul_inv, rpow_neg,
mul_inv_cancel_left₀] <;> positivity
_ ≤ (2 : ℝ) ^ (r / 2) * ((1 + ‖x‖) ^ r)⁻¹ := by
gcongr
apply one_add_norm_le_sqrt_two_mul_sqrt
_ = (2 : ℝ) ^ (r / 2) * (1 + ‖x‖) ^ (-r) := by rw [rpow_neg]; positivity
theorem le_rpow_one_add_norm_iff_norm_le {r t : ℝ} (hr : 0 < r) (ht : 0 < t) (x : E) :
t ≤ (1 + ‖x‖) ^ (-r) ↔ ‖x‖ ≤ t ^ (-r⁻¹) - 1 := by
rw [le_sub_iff_add_le', neg_inv]
exact (Real.le_rpow_inv_iff_of_neg (by positivity) ht (neg_lt_zero.mpr hr)).symm
variable (E)
theorem closedBall_rpow_sub_one_eq_empty_aux {r t : ℝ} (hr : 0 < r) (ht : 1 < t) :
Metric.closedBall (0 : E) (t ^ (-r⁻¹) - 1) = ∅ := by
rw [Metric.closedBall_eq_empty, sub_neg]
exact Real.rpow_lt_one_of_one_lt_of_neg ht (by simp only [hr, Right.neg_neg_iff, inv_pos])
variable [NormedSpace ℝ E] [FiniteDimensional ℝ E]
variable {E}
theorem finite_integral_rpow_sub_one_pow_aux {r : ℝ} (n : ℕ) (hnr : (n : ℝ) < r) :
(∫⁻ x : ℝ in Ioc 0 1, ENNReal.ofReal ((x ^ (-r⁻¹) - 1) ^ n)) < ∞ := by
have hr : 0 < r := lt_of_le_of_lt n.cast_nonneg hnr
have h_int : ∀ x : ℝ, x ∈ Ioc (0 : ℝ) 1 →
ENNReal.ofReal ((x ^ (-r⁻¹) - 1) ^ n) ≤ ENNReal.ofReal (x ^ (-(r⁻¹ * n))) := fun x hx ↦ by
apply ENNReal.ofReal_le_ofReal
rw [← neg_mul, rpow_mul hx.1.le, rpow_natCast]
refine pow_le_pow_left ?_ (by simp only [sub_le_self_iff, zero_le_one]) n
rw [le_sub_iff_add_le', add_zero]
refine Real.one_le_rpow_of_pos_of_le_one_of_nonpos hx.1 hx.2 ?_
rw [Right.neg_nonpos_iff, inv_nonneg]
exact hr.le
refine lt_of_le_of_lt (setLIntegral_mono' measurableSet_Ioc h_int) ?_
refine IntegrableOn.setLIntegral_lt_top ?_
rw [← intervalIntegrable_iff_integrableOn_Ioc_of_le zero_le_one]
apply intervalIntegral.intervalIntegrable_rpow'
rwa [neg_lt_neg_iff, inv_mul_lt_iff' hr, one_mul]
variable [MeasurableSpace E] [BorelSpace E] {μ : Measure E} [μ.IsAddHaarMeasure]
theorem finite_integral_one_add_norm {r : ℝ} (hnr : (finrank ℝ E : ℝ) < r) :
(∫⁻ x : E, ENNReal.ofReal ((1 + ‖x‖) ^ (-r)) ∂μ) < ∞ := by
have hr : 0 < r := lt_of_le_of_lt (finrank ℝ E).cast_nonneg hnr
-- We start by applying the layer cake formula
have h_meas : Measurable fun ω : E => (1 + ‖ω‖) ^ (-r) := by fun_prop
have h_pos : ∀ x : E, 0 ≤ (1 + ‖x‖) ^ (-r) := fun x ↦ by positivity
rw [lintegral_eq_lintegral_meas_le μ (eventually_of_forall h_pos) h_meas.aemeasurable]
have h_int : ∀ t, 0 < t → μ {a : E | t ≤ (1 + ‖a‖) ^ (-r)} =
μ (Metric.closedBall (0 : E) (t ^ (-r⁻¹) - 1)) := fun t ht ↦ by
congr 1
ext x
simp only [mem_setOf_eq, mem_closedBall_zero_iff]
exact le_rpow_one_add_norm_iff_norm_le hr (mem_Ioi.mp ht) x
rw [setLIntegral_congr_fun measurableSet_Ioi (eventually_of_forall h_int)]
set f := fun t : ℝ ↦ μ (Metric.closedBall (0 : E) (t ^ (-r⁻¹) - 1))
set mB := μ (Metric.ball (0 : E) 1)
-- the next two inequalities are in fact equalities but we don't need that
calc
∫⁻ t in Ioi 0, f t ≤ ∫⁻ t in Ioc 0 1 ∪ Ioi 1, f t := lintegral_mono_set Ioi_subset_Ioc_union_Ioi
_ ≤ (∫⁻ t in Ioc 0 1, f t) + ∫⁻ t in Ioi 1, f t := lintegral_union_le _ _ _
_ < ∞ := ENNReal.add_lt_top.2 ⟨?_, ?_⟩
· -- We use estimates from auxiliary lemmas to deal with integral from `0` to `1`
have h_int' : ∀ t ∈ Ioc (0 : ℝ) 1,
f t = ENNReal.ofReal ((t ^ (-r⁻¹) - 1) ^ finrank ℝ E) * mB := fun t ht ↦ by
refine μ.addHaar_closedBall (0 : E) ?_
rw [sub_nonneg]
exact Real.one_le_rpow_of_pos_of_le_one_of_nonpos ht.1 ht.2 (by simp [hr.le])
rw [setLIntegral_congr_fun measurableSet_Ioc (ae_of_all _ h_int'),
lintegral_mul_const' _ _ measure_ball_lt_top.ne]
exact ENNReal.mul_lt_top
(finite_integral_rpow_sub_one_pow_aux (finrank ℝ E) hnr).ne measure_ball_lt_top.ne
· -- The integral from 1 to ∞ is zero:
have h_int'' : ∀ t ∈ Ioi (1 : ℝ), f t = 0 := fun t ht => by
simp only [f, closedBall_rpow_sub_one_eq_empty_aux E hr ht, measure_empty]
-- The integral over the constant zero function is finite:
rw [setLIntegral_congr_fun measurableSet_Ioi (ae_of_all volume <| h_int''), lintegral_const 0,
zero_mul]
exact WithTop.zero_lt_top
theorem integrable_one_add_norm {r : ℝ} (hnr : (finrank ℝ E : ℝ) < r) :
Integrable (fun x ↦ (1 + ‖x‖) ^ (-r)) μ := by
constructor
· apply Measurable.aestronglyMeasurable (by fun_prop)
-- Lower Lebesgue integral
have : (∫⁻ a : E, ‖(1 + ‖a‖) ^ (-r)‖₊ ∂μ) = ∫⁻ a : E, ENNReal.ofReal ((1 + ‖a‖) ^ (-r)) ∂μ :=
lintegral_nnnorm_eq_of_nonneg fun _ => rpow_nonneg (by positivity) _
rw [HasFiniteIntegral, this]
exact finite_integral_one_add_norm hnr
theorem integrable_rpow_neg_one_add_norm_sq {r : ℝ} (hnr : (finrank ℝ E : ℝ) < r) :
Integrable (fun x ↦ ((1 : ℝ) + ‖x‖ ^ 2) ^ (-r / 2)) μ := by
have hr : 0 < r := lt_of_le_of_lt (finrank ℝ E).cast_nonneg hnr
refine ((integrable_one_add_norm hnr).const_mul <| (2 : ℝ) ^ (r / 2)).mono'
?_ (eventually_of_forall fun x => ?_)
· apply Measurable.aestronglyMeasurable (by fun_prop)
refine (abs_of_pos ?_).trans_le (rpow_neg_one_add_norm_sq_le x hr)
positivity
|
Analysis\SpecialFunctions\NonIntegrable.lean | /-
Copyright (c) 2021 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov
-/
import Mathlib.Analysis.SpecialFunctions.Log.Deriv
import Mathlib.MeasureTheory.Integral.FundThmCalculus
/-!
# Non integrable functions
In this file we prove that the derivative of a function that tends to infinity is not interval
integrable, see `not_intervalIntegrable_of_tendsto_norm_atTop_of_deriv_isBigO_filter` and
`not_intervalIntegrable_of_tendsto_norm_atTop_of_deriv_isBigO_punctured`. Then we apply the
latter lemma to prove that the function `fun x => x⁻¹` is integrable on `a..b` if and only if
`a = b` or `0 ∉ [a, b]`.
## Main results
* `not_intervalIntegrable_of_tendsto_norm_atTop_of_deriv_isBigO_punctured`: if `f` tends to infinity
along `𝓝[≠] c` and `f' = O(g)` along the same filter, then `g` is not interval integrable on any
nontrivial integral `a..b`, `c ∈ [a, b]`.
* `not_intervalIntegrable_of_tendsto_norm_atTop_of_deriv_isBigO_filter`: a version of
`not_intervalIntegrable_of_tendsto_norm_atTop_of_deriv_isBigO_punctured` that works for one-sided
neighborhoods;
* `not_intervalIntegrable_of_sub_inv_isBigO_punctured`: if `1 / (x - c) = O(f)` as `x → c`, `x ≠ c`,
then `f` is not interval integrable on any nontrivial interval `a..b`, `c ∈ [a, b]`;
* `intervalIntegrable_sub_inv_iff`, `intervalIntegrable_inv_iff`: integrability conditions for
`(x - c)⁻¹` and `x⁻¹`.
## Tags
integrable function
-/
open scoped MeasureTheory Topology Interval NNReal ENNReal
open MeasureTheory TopologicalSpace Set Filter Asymptotics intervalIntegral
variable {E F : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [NormedAddCommGroup F]
/-- If `f` is eventually differentiable along a nontrivial filter `l : Filter ℝ` that is generated
by convex sets, the norm of `f` tends to infinity along `l`, and `f' = O(g)` along `l`, where `f'`
is the derivative of `f`, then `g` is not integrable on any set `k` belonging to `l`.
Auxiliary version assuming that `E` is complete. -/
theorem not_integrableOn_of_tendsto_norm_atTop_of_deriv_isBigO_filter_aux
[CompleteSpace E] {f : ℝ → E} {g : ℝ → F}
{k : Set ℝ} (l : Filter ℝ) [NeBot l] [TendstoIxxClass Icc l l]
(hl : k ∈ l) (hd : ∀ᶠ x in l, DifferentiableAt ℝ f x) (hf : Tendsto (fun x => ‖f x‖) l atTop)
(hfg : deriv f =O[l] g) : ¬IntegrableOn g k := by
intro hgi
obtain ⟨C, hC₀, s, hsl, hsub, hfd, hg⟩ :
∃ (C : ℝ) (_ : 0 ≤ C), ∃ s ∈ l, (∀ x ∈ s, ∀ y ∈ s, [[x, y]] ⊆ k) ∧
(∀ x ∈ s, ∀ y ∈ s, ∀ z ∈ [[x, y]], DifferentiableAt ℝ f z) ∧
∀ x ∈ s, ∀ y ∈ s, ∀ z ∈ [[x, y]], ‖deriv f z‖ ≤ C * ‖g z‖ := by
rcases hfg.exists_nonneg with ⟨C, C₀, hC⟩
have h : ∀ᶠ x : ℝ × ℝ in l.prod l,
∀ y ∈ [[x.1, x.2]], (DifferentiableAt ℝ f y ∧ ‖deriv f y‖ ≤ C * ‖g y‖) ∧ y ∈ k :=
(tendsto_fst.uIcc tendsto_snd).eventually ((hd.and hC.bound).and hl).smallSets
rcases mem_prod_self_iff.1 h with ⟨s, hsl, hs⟩
simp only [prod_subset_iff, mem_setOf_eq] at hs
exact ⟨C, C₀, s, hsl, fun x hx y hy z hz => (hs x hx y hy z hz).2, fun x hx y hy z hz =>
(hs x hx y hy z hz).1.1, fun x hx y hy z hz => (hs x hx y hy z hz).1.2⟩
replace hgi : IntegrableOn (fun x ↦ C * ‖g x‖) k := by exact hgi.norm.smul C
obtain ⟨c, hc, d, hd, hlt⟩ : ∃ c ∈ s, ∃ d ∈ s, (‖f c‖ + ∫ y in k, C * ‖g y‖) < ‖f d‖ := by
rcases Filter.nonempty_of_mem hsl with ⟨c, hc⟩
have : ∀ᶠ x in l, (‖f c‖ + ∫ y in k, C * ‖g y‖) < ‖f x‖ :=
hf.eventually (eventually_gt_atTop _)
exact ⟨c, hc, (this.and hsl).exists.imp fun d hd => ⟨hd.2, hd.1⟩⟩
specialize hsub c hc d hd; specialize hfd c hc d hd
replace hg : ∀ x ∈ Ι c d, ‖deriv f x‖ ≤ C * ‖g x‖ :=
fun z hz => hg c hc d hd z ⟨hz.1.le, hz.2⟩
have hg_ae : ∀ᵐ x ∂volume.restrict (Ι c d), ‖deriv f x‖ ≤ C * ‖g x‖ :=
(ae_restrict_mem measurableSet_uIoc).mono hg
have hsub' : Ι c d ⊆ k := Subset.trans Ioc_subset_Icc_self hsub
have hfi : IntervalIntegrable (deriv f) volume c d := by
rw [intervalIntegrable_iff]
have : IntegrableOn (fun x ↦ C * ‖g x‖) (Ι c d) := IntegrableOn.mono hgi hsub' le_rfl
exact Integrable.mono' this (aestronglyMeasurable_deriv _ _) hg_ae
refine hlt.not_le (sub_le_iff_le_add'.1 ?_)
calc
‖f d‖ - ‖f c‖ ≤ ‖f d - f c‖ := norm_sub_norm_le _ _
_ = ‖∫ x in c..d, deriv f x‖ := congr_arg _ (integral_deriv_eq_sub hfd hfi).symm
_ = ‖∫ x in Ι c d, deriv f x‖ := norm_integral_eq_norm_integral_Ioc _
_ ≤ ∫ x in Ι c d, ‖deriv f x‖ := norm_integral_le_integral_norm _
_ ≤ ∫ x in Ι c d, C * ‖g x‖ :=
setIntegral_mono_on hfi.norm.def' (hgi.mono_set hsub') measurableSet_uIoc hg
_ ≤ ∫ x in k, C * ‖g x‖ := by
apply setIntegral_mono_set hgi
(ae_of_all _ fun x => mul_nonneg hC₀ (norm_nonneg _)) hsub'.eventuallyLE
theorem not_integrableOn_of_tendsto_norm_atTop_of_deriv_isBigO_filter
{f : ℝ → E} {g : ℝ → F}
{k : Set ℝ} (l : Filter ℝ) [NeBot l] [TendstoIxxClass Icc l l]
(hl : k ∈ l) (hd : ∀ᶠ x in l, DifferentiableAt ℝ f x) (hf : Tendsto (fun x => ‖f x‖) l atTop)
(hfg : deriv f =O[l] g) : ¬IntegrableOn g k := by
let a : E →ₗᵢ[ℝ] UniformSpace.Completion E := UniformSpace.Completion.toComplₗᵢ
let f' := a ∘ f
have h'd : ∀ᶠ x in l, DifferentiableAt ℝ f' x := by
filter_upwards [hd] with x hx using a.toContinuousLinearMap.differentiableAt.comp x hx
have h'f : Tendsto (fun x => ‖f' x‖) l atTop := hf.congr (fun x ↦ by simp [f'])
have h'fg : deriv f' =O[l] g := by
apply IsBigO.trans _ hfg
rw [← isBigO_norm_norm]
suffices (fun x ↦ ‖deriv f' x‖) =ᶠ[l] (fun x ↦ ‖deriv f x‖) by exact this.isBigO
filter_upwards [hd] with x hx
have : deriv f' x = a (deriv f x) := by
rw [fderiv.comp_deriv x _ hx]
· have : fderiv ℝ a (f x) = a.toContinuousLinearMap := a.toContinuousLinearMap.fderiv
simp only [this]
rfl
· exact a.toContinuousLinearMap.differentiableAt
simp only [this]
simp
exact not_integrableOn_of_tendsto_norm_atTop_of_deriv_isBigO_filter_aux l hl h'd h'f h'fg
/-- If `f` is eventually differentiable along a nontrivial filter `l : Filter ℝ` that is generated
by convex sets, the norm of `f` tends to infinity along `l`, and `f' = O(g)` along `l`, where `f'`
is the derivative of `f`, then `g` is not integrable on any interval `a..b` such that
`[a, b] ∈ l`. -/
theorem not_intervalIntegrable_of_tendsto_norm_atTop_of_deriv_isBigO_filter {f : ℝ → E} {g : ℝ → F}
{a b : ℝ} (l : Filter ℝ) [NeBot l] [TendstoIxxClass Icc l l] (hl : [[a, b]] ∈ l)
(hd : ∀ᶠ x in l, DifferentiableAt ℝ f x) (hf : Tendsto (fun x => ‖f x‖) l atTop)
(hfg : deriv f =O[l] g) : ¬IntervalIntegrable g volume a b := by
rw [intervalIntegrable_iff']
exact not_integrableOn_of_tendsto_norm_atTop_of_deriv_isBigO_filter _ hl hd hf hfg
/-- If `a ≠ b`, `c ∈ [a, b]`, `f` is differentiable in the neighborhood of `c` within
`[a, b] \ {c}`, `‖f x‖ → ∞` as `x → c` within `[a, b] \ {c}`, and `f' = O(g)` along
`𝓝[[a, b] \ {c}] c`, where `f'` is the derivative of `f`, then `g` is not interval integrable on
`a..b`. -/
theorem not_intervalIntegrable_of_tendsto_norm_atTop_of_deriv_isBigO_within_diff_singleton
{f : ℝ → E} {g : ℝ → F} {a b c : ℝ} (hne : a ≠ b) (hc : c ∈ [[a, b]])
(h_deriv : ∀ᶠ x in 𝓝[[[a, b]] \ {c}] c, DifferentiableAt ℝ f x)
(h_infty : Tendsto (fun x => ‖f x‖) (𝓝[[[a, b]] \ {c}] c) atTop)
(hg : deriv f =O[𝓝[[[a, b]] \ {c}] c] g) : ¬IntervalIntegrable g volume a b := by
obtain ⟨l, hl, hl', hle, hmem⟩ :
∃ l : Filter ℝ, TendstoIxxClass Icc l l ∧ l.NeBot ∧ l ≤ 𝓝 c ∧ [[a, b]] \ {c} ∈ l := by
cases' (min_lt_max.2 hne).lt_or_lt c with hlt hlt
· refine ⟨𝓝[<] c, inferInstance, inferInstance, inf_le_left, ?_⟩
rw [← Iic_diff_right]
exact diff_mem_nhdsWithin_diff (Icc_mem_nhdsWithin_Iic ⟨hlt, hc.2⟩) _
· refine ⟨𝓝[>] c, inferInstance, inferInstance, inf_le_left, ?_⟩
rw [← Ici_diff_left]
exact diff_mem_nhdsWithin_diff (Icc_mem_nhdsWithin_Ici ⟨hc.1, hlt⟩) _
have : l ≤ 𝓝[[[a, b]] \ {c}] c := le_inf hle (le_principal_iff.2 hmem)
exact not_intervalIntegrable_of_tendsto_norm_atTop_of_deriv_isBigO_filter l
(mem_of_superset hmem diff_subset) (h_deriv.filter_mono this) (h_infty.mono_left this)
(hg.mono this)
/-- If `f` is differentiable in a punctured neighborhood of `c`, `‖f x‖ → ∞` as `x → c` (more
formally, along the filter `𝓝[≠] c`), and `f' = O(g)` along `𝓝[≠] c`, where `f'` is the derivative
of `f`, then `g` is not interval integrable on any nontrivial interval `a..b` such that
`c ∈ [a, b]`. -/
theorem not_intervalIntegrable_of_tendsto_norm_atTop_of_deriv_isBigO_punctured {f : ℝ → E}
{g : ℝ → F} {a b c : ℝ} (h_deriv : ∀ᶠ x in 𝓝[≠] c, DifferentiableAt ℝ f x)
(h_infty : Tendsto (fun x => ‖f x‖) (𝓝[≠] c) atTop) (hg : deriv f =O[𝓝[≠] c] g) (hne : a ≠ b)
(hc : c ∈ [[a, b]]) : ¬IntervalIntegrable g volume a b :=
have : 𝓝[[[a, b]] \ {c}] c ≤ 𝓝[≠] c := nhdsWithin_mono _ inter_subset_right
not_intervalIntegrable_of_tendsto_norm_atTop_of_deriv_isBigO_within_diff_singleton hne hc
(h_deriv.filter_mono this) (h_infty.mono_left this) (hg.mono this)
/-- If `f` grows in the punctured neighborhood of `c : ℝ` at least as fast as `1 / (x - c)`,
then it is not interval integrable on any nontrivial interval `a..b`, `c ∈ [a, b]`. -/
theorem not_intervalIntegrable_of_sub_inv_isBigO_punctured {f : ℝ → F} {a b c : ℝ}
(hf : (fun x => (x - c)⁻¹) =O[𝓝[≠] c] f) (hne : a ≠ b) (hc : c ∈ [[a, b]]) :
¬IntervalIntegrable f volume a b := by
have A : ∀ᶠ x in 𝓝[≠] c, HasDerivAt (fun x => Real.log (x - c)) (x - c)⁻¹ x := by
filter_upwards [self_mem_nhdsWithin] with x hx
simpa using ((hasDerivAt_id x).sub_const c).log (sub_ne_zero.2 hx)
have B : Tendsto (fun x => ‖Real.log (x - c)‖) (𝓝[≠] c) atTop := by
refine tendsto_abs_atBot_atTop.comp (Real.tendsto_log_nhdsWithin_zero.comp ?_)
rw [← sub_self c]
exact ((hasDerivAt_id c).sub_const c).tendsto_punctured_nhds one_ne_zero
exact not_intervalIntegrable_of_tendsto_norm_atTop_of_deriv_isBigO_punctured
(A.mono fun x hx => hx.differentiableAt) B
(hf.congr' (A.mono fun x hx => hx.deriv.symm) EventuallyEq.rfl) hne hc
/-- The function `fun x => (x - c)⁻¹` is integrable on `a..b` if and only if
`a = b` or `c ∉ [a, b]`. -/
@[simp]
theorem intervalIntegrable_sub_inv_iff {a b c : ℝ} :
IntervalIntegrable (fun x => (x - c)⁻¹) volume a b ↔ a = b ∨ c ∉ [[a, b]] := by
constructor
· refine fun h => or_iff_not_imp_left.2 fun hne hc => ?_
exact not_intervalIntegrable_of_sub_inv_isBigO_punctured (isBigO_refl _ _) hne hc h
· rintro (rfl | h₀)
· exact IntervalIntegrable.refl
refine ((continuous_sub_right c).continuousOn.inv₀ ?_).intervalIntegrable
exact fun x hx => sub_ne_zero.2 <| ne_of_mem_of_not_mem hx h₀
/-- The function `fun x => x⁻¹` is integrable on `a..b` if and only if
`a = b` or `0 ∉ [a, b]`. -/
@[simp]
theorem intervalIntegrable_inv_iff {a b : ℝ} :
IntervalIntegrable (fun x => x⁻¹) volume a b ↔ a = b ∨ (0 : ℝ) ∉ [[a, b]] := by
simp only [← intervalIntegrable_sub_inv_iff, sub_zero]
/-- The function `fun x ↦ x⁻¹` is not integrable on any interval `[a, +∞)`. -/
theorem not_IntegrableOn_Ici_inv {a : ℝ} :
¬ IntegrableOn (fun x => x⁻¹) (Ici a) := by
have A : ∀ᶠ x in atTop, HasDerivAt (fun x => Real.log x) x⁻¹ x := by
filter_upwards [Ioi_mem_atTop 0] with x hx using Real.hasDerivAt_log (ne_of_gt hx)
have B : Tendsto (fun x => ‖Real.log x‖) atTop atTop :=
tendsto_norm_atTop_atTop.comp Real.tendsto_log_atTop
exact not_integrableOn_of_tendsto_norm_atTop_of_deriv_isBigO_filter atTop (Ici_mem_atTop a)
(A.mono (fun x hx ↦ hx.differentiableAt)) B
(Filter.EventuallyEq.isBigO (A.mono (fun x hx ↦ hx.deriv)))
/-- The function `fun x ↦ x⁻¹` is not integrable on any interval `(a, +∞)`. -/
theorem not_IntegrableOn_Ioi_inv {a : ℝ} :
¬ IntegrableOn (·⁻¹) (Ioi a) := by
simpa only [IntegrableOn, restrict_Ioi_eq_restrict_Ici] using not_IntegrableOn_Ici_inv
|
Analysis\SpecialFunctions\PolarCoord.lean | /-
Copyright (c) 2022 Sébastien Gouëzel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sébastien Gouëzel
-/
import Mathlib.MeasureTheory.Function.Jacobian
import Mathlib.MeasureTheory.Measure.Lebesgue.Complex
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Deriv
/-!
# Polar coordinates
We define polar coordinates, as a partial homeomorphism in `ℝ^2` between `ℝ^2 - (-∞, 0]` and
`(0, +∞) × (-π, π)`. Its inverse is given by `(r, θ) ↦ (r cos θ, r sin θ)`.
It satisfies the following change of variables formula (see `integral_comp_polarCoord_symm`):
`∫ p in polarCoord.target, p.1 • f (polarCoord.symm p) = ∫ p, f p`
-/
noncomputable section Real
open Real Set MeasureTheory
open scoped Real Topology
/-- The polar coordinates partial homeomorphism in `ℝ^2`, mapping `(r cos θ, r sin θ)` to `(r, θ)`.
It is a homeomorphism between `ℝ^2 - (-∞, 0]` and `(0, +∞) × (-π, π)`. -/
@[simps]
def polarCoord : PartialHomeomorph (ℝ × ℝ) (ℝ × ℝ) where
toFun q := (√(q.1 ^ 2 + q.2 ^ 2), Complex.arg (Complex.equivRealProd.symm q))
invFun p := (p.1 * cos p.2, p.1 * sin p.2)
source := {q | 0 < q.1} ∪ {q | q.2 ≠ 0}
target := Ioi (0 : ℝ) ×ˢ Ioo (-π) π
map_target' := by
rintro ⟨r, θ⟩ ⟨hr, hθ⟩
dsimp at hr hθ
rcases eq_or_ne θ 0 with (rfl | h'θ)
· simpa using hr
· right
simp at hr
simpa only [ne_of_gt hr, Ne, mem_setOf_eq, mul_eq_zero, false_or_iff,
sin_eq_zero_iff_of_lt_of_lt hθ.1 hθ.2] using h'θ
map_source' := by
rintro ⟨x, y⟩ hxy
simp only [prod_mk_mem_set_prod_eq, mem_Ioi, sqrt_pos, mem_Ioo, Complex.neg_pi_lt_arg,
true_and_iff, Complex.arg_lt_pi_iff]
constructor
· cases' hxy with hxy hxy
· dsimp at hxy; linarith [sq_pos_of_ne_zero hxy.ne', sq_nonneg y]
· linarith [sq_nonneg x, sq_pos_of_ne_zero hxy]
· cases' hxy with hxy hxy
· exact Or.inl (le_of_lt hxy)
· exact Or.inr hxy
right_inv' := by
rintro ⟨r, θ⟩ ⟨hr, hθ⟩
dsimp at hr hθ
simp only [Prod.mk.inj_iff]
constructor
· conv_rhs => rw [← sqrt_sq (le_of_lt hr), ← one_mul (r ^ 2), ← sin_sq_add_cos_sq θ]
congr 1
ring
· convert Complex.arg_mul_cos_add_sin_mul_I hr ⟨hθ.1, hθ.2.le⟩
simp only [Complex.equivRealProd_symm_apply, Complex.ofReal_mul, Complex.ofReal_cos,
Complex.ofReal_sin]
ring
left_inv' := by
rintro ⟨x, y⟩ _
have A : √(x ^ 2 + y ^ 2) = Complex.abs (x + y * Complex.I) := by
rw [Complex.abs_apply, Complex.normSq_add_mul_I]
have Z := Complex.abs_mul_cos_add_sin_mul_I (x + y * Complex.I)
simp only [← Complex.ofReal_cos, ← Complex.ofReal_sin, mul_add, ← Complex.ofReal_mul, ←
mul_assoc] at Z
simp [A]
open_target := isOpen_Ioi.prod isOpen_Ioo
open_source :=
(isOpen_lt continuous_const continuous_fst).union
(isOpen_ne_fun continuous_snd continuous_const)
continuousOn_invFun :=
((continuous_fst.mul (continuous_cos.comp continuous_snd)).prod_mk
(continuous_fst.mul (continuous_sin.comp continuous_snd))).continuousOn
continuousOn_toFun := by
apply ((continuous_fst.pow 2).add (continuous_snd.pow 2)).sqrt.continuousOn.prod
have A : MapsTo Complex.equivRealProd.symm ({q : ℝ × ℝ | 0 < q.1} ∪ {q : ℝ × ℝ | q.2 ≠ 0})
Complex.slitPlane := by
rintro ⟨x, y⟩ hxy; simpa only using hxy
refine ContinuousOn.comp (f := Complex.equivRealProd.symm)
(g := Complex.arg) (fun z hz => ?_) ?_ A
· exact (Complex.continuousAt_arg hz).continuousWithinAt
· exact Complex.equivRealProdCLM.symm.continuous.continuousOn
theorem hasFDerivAt_polarCoord_symm (p : ℝ × ℝ) :
HasFDerivAt polarCoord.symm
(LinearMap.toContinuousLinearMap (Matrix.toLin (Basis.finTwoProd ℝ) (Basis.finTwoProd ℝ)
!![cos p.2, -p.1 * sin p.2; sin p.2, p.1 * cos p.2])) p := by
rw [Matrix.toLin_finTwoProd_toContinuousLinearMap]
convert HasFDerivAt.prod (𝕜 := ℝ)
(hasFDerivAt_fst.mul ((hasDerivAt_cos p.2).comp_hasFDerivAt p hasFDerivAt_snd))
(hasFDerivAt_fst.mul ((hasDerivAt_sin p.2).comp_hasFDerivAt p hasFDerivAt_snd)) using 2 <;>
simp [smul_smul, add_comm, neg_mul, smul_neg, neg_smul _ (ContinuousLinearMap.snd ℝ ℝ ℝ)]
-- Porting note: this instance is needed but not automatically synthesised
instance : Measure.IsAddHaarMeasure volume (G := ℝ × ℝ) :=
Measure.prod.instIsAddHaarMeasure _ _
theorem polarCoord_source_ae_eq_univ : polarCoord.source =ᵐ[volume] univ := by
have A : polarCoord.sourceᶜ ⊆ LinearMap.ker (LinearMap.snd ℝ ℝ ℝ) := by
intro x hx
simp only [polarCoord_source, compl_union, mem_inter_iff, mem_compl_iff, mem_setOf_eq, not_lt,
Classical.not_not] at hx
exact hx.2
have B : volume (LinearMap.ker (LinearMap.snd ℝ ℝ ℝ) : Set (ℝ × ℝ)) = 0 := by
apply Measure.addHaar_submodule
rw [Ne, LinearMap.ker_eq_top]
intro h
have : (LinearMap.snd ℝ ℝ ℝ) (0, 1) = (0 : ℝ × ℝ →ₗ[ℝ] ℝ) (0, 1) := by rw [h]
simp at this
simp only [ae_eq_univ]
exact le_antisymm ((measure_mono A).trans (le_of_eq B)) bot_le
theorem integral_comp_polarCoord_symm {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
(f : ℝ × ℝ → E) :
(∫ p in polarCoord.target, p.1 • f (polarCoord.symm p)) = ∫ p, f p := by
set B : ℝ × ℝ → ℝ × ℝ →L[ℝ] ℝ × ℝ := fun p =>
LinearMap.toContinuousLinearMap (Matrix.toLin (Basis.finTwoProd ℝ) (Basis.finTwoProd ℝ)
!![cos p.2, -p.1 * sin p.2; sin p.2, p.1 * cos p.2])
have A : ∀ p ∈ polarCoord.symm.source, HasFDerivAt polarCoord.symm (B p) p := fun p _ =>
hasFDerivAt_polarCoord_symm p
have B_det : ∀ p, (B p).det = p.1 := by
intro p
conv_rhs => rw [← one_mul p.1, ← cos_sq_add_sin_sq p.2]
simp only [B, neg_mul, LinearMap.det_toContinuousLinearMap, LinearMap.det_toLin,
Matrix.det_fin_two_of, sub_neg_eq_add]
ring
symm
calc
∫ p, f p = ∫ p in polarCoord.source, f p := by
rw [← integral_univ]
apply setIntegral_congr_set_ae
exact polarCoord_source_ae_eq_univ.symm
_ = ∫ p in polarCoord.target, abs (B p).det • f (polarCoord.symm p) := by
apply integral_target_eq_integral_abs_det_fderiv_smul volume A
_ = ∫ p in polarCoord.target, p.1 • f (polarCoord.symm p) := by
apply setIntegral_congr polarCoord.open_target.measurableSet fun x hx => ?_
rw [B_det, abs_of_pos]
exact hx.1
end Real
noncomputable section Complex
namespace Complex
open scoped Real
/-- The polar coordinates partial homeomorphism in `ℂ`, mapping `r (cos θ + I * sin θ)` to `(r, θ)`.
It is a homeomorphism between `ℂ - ℝ≤0` and `(0, +∞) × (-π, π)`. -/
protected noncomputable def polarCoord : PartialHomeomorph ℂ (ℝ × ℝ) :=
equivRealProdCLM.toHomeomorph.transPartialHomeomorph polarCoord
protected theorem polarCoord_apply (a : ℂ) :
Complex.polarCoord a = (Complex.abs a, Complex.arg a) := by
simp_rw [Complex.abs_def, Complex.normSq_apply, ← pow_two]
rfl
protected theorem polarCoord_source : Complex.polarCoord.source = slitPlane := rfl
protected theorem polarCoord_target :
Complex.polarCoord.target = Set.Ioi (0 : ℝ) ×ˢ Set.Ioo (-π) π := rfl
@[simp]
protected theorem polarCoord_symm_apply (p : ℝ × ℝ) :
Complex.polarCoord.symm p = p.1 * (Real.cos p.2 + Real.sin p.2 * Complex.I) := by
simp [Complex.polarCoord, equivRealProdCLM_symm_apply, mul_add, mul_assoc]
theorem polarCoord_symm_abs (p : ℝ × ℝ) :
Complex.abs (Complex.polarCoord.symm p) = |p.1| := by simp
@[deprecated (since := "2024-07-15")] alias polardCoord_symm_abs := polarCoord_symm_abs
protected theorem integral_comp_polarCoord_symm {E : Type*} [NormedAddCommGroup E]
[NormedSpace ℝ E] (f : ℂ → E) :
(∫ p in polarCoord.target, p.1 • f (Complex.polarCoord.symm p)) = ∫ p, f p := by
rw [← (Complex.volume_preserving_equiv_real_prod.symm).integral_comp
measurableEquivRealProd.symm.measurableEmbedding, ← integral_comp_polarCoord_symm]
rfl
end Complex
|
Analysis\SpecialFunctions\PolynomialExp.lean | /-
Copyright (c) 2023 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov
-/
import Mathlib.Algebra.Polynomial.Eval
import Mathlib.Analysis.SpecialFunctions.Exp
/-!
# Limits of `P(x) / e ^ x` for a polynomial `P`
In this file we prove that $\lim_{x\to\infty}\frac{P(x)}{e^x}=0$ for any polynomial `P`.
## TODO
Add more similar lemmas: limit at `-∞`, versions with $e^{cx}$ etc.
## Keywords
polynomial, limit, exponential
-/
open Filter Topology Real
namespace Polynomial
theorem tendsto_div_exp_atTop (p : ℝ[X]) : Tendsto (fun x ↦ p.eval x / exp x) atTop (𝓝 0) := by
induction p using Polynomial.induction_on' with
| h_monomial n c => simpa [exp_neg, div_eq_mul_inv, mul_assoc]
using tendsto_const_nhds.mul (tendsto_pow_mul_exp_neg_atTop_nhds_zero n)
| h_add p q hp hq => simpa [add_div] using hp.add hq
end Polynomial
|
Analysis\SpecialFunctions\Polynomials.lean | /-
Copyright (c) 2020 Anatole Dedecker. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Anatole Dedecker, Devon Tuma
-/
import Mathlib.Algebra.Polynomial.Roots
import Mathlib.Analysis.Asymptotics.AsymptoticEquivalent
import Mathlib.Analysis.Asymptotics.SpecificAsymptotics
/-!
# Limits related to polynomial and rational functions
This file proves basic facts about limits of polynomial and rationals functions.
The main result is `eval_is_equivalent_at_top_eval_lead`, which states that for
any polynomial `P` of degree `n` with leading coefficient `a`, the corresponding
polynomial function is equivalent to `a * x^n` as `x` goes to +∞.
We can then use this result to prove various limits for polynomial and rational
functions, depending on the degrees and leading coefficients of the considered
polynomials.
-/
open Filter Finset Asymptotics
open Asymptotics Polynomial Topology
namespace Polynomial
variable {𝕜 : Type*} [NormedLinearOrderedField 𝕜] (P Q : 𝕜[X])
theorem eventually_no_roots (hP : P ≠ 0) : ∀ᶠ x in atTop, ¬P.IsRoot x :=
atTop_le_cofinite <| (finite_setOf_isRoot hP).compl_mem_cofinite
variable [OrderTopology 𝕜]
section PolynomialAtTop
theorem isEquivalent_atTop_lead :
(fun x => eval x P) ~[atTop] fun x => P.leadingCoeff * x ^ P.natDegree := by
by_cases h : P = 0
· simp [h, IsEquivalent.refl]
· simp only [Polynomial.eval_eq_sum_range, sum_range_succ]
exact
IsLittleO.add_isEquivalent
(IsLittleO.sum fun i hi =>
IsLittleO.const_mul_left
((IsLittleO.const_mul_right fun hz => h <| leadingCoeff_eq_zero.mp hz) <|
isLittleO_pow_pow_atTop_of_lt (mem_range.mp hi))
_)
IsEquivalent.refl
theorem tendsto_atTop_of_leadingCoeff_nonneg (hdeg : 0 < P.degree) (hnng : 0 ≤ P.leadingCoeff) :
Tendsto (fun x => eval x P) atTop atTop :=
P.isEquivalent_atTop_lead.symm.tendsto_atTop <|
tendsto_const_mul_pow_atTop (natDegree_pos_iff_degree_pos.2 hdeg).ne' <|
hnng.lt_of_ne' <| leadingCoeff_ne_zero.mpr <| ne_zero_of_degree_gt hdeg
theorem tendsto_atTop_iff_leadingCoeff_nonneg :
Tendsto (fun x => eval x P) atTop atTop ↔ 0 < P.degree ∧ 0 ≤ P.leadingCoeff := by
refine ⟨fun h => ?_, fun h => tendsto_atTop_of_leadingCoeff_nonneg P h.1 h.2⟩
have : Tendsto (fun x => P.leadingCoeff * x ^ P.natDegree) atTop atTop :=
(isEquivalent_atTop_lead P).tendsto_atTop h
rw [tendsto_const_mul_pow_atTop_iff, ← pos_iff_ne_zero, natDegree_pos_iff_degree_pos] at this
exact ⟨this.1, this.2.le⟩
theorem tendsto_atBot_iff_leadingCoeff_nonpos :
Tendsto (fun x => eval x P) atTop atBot ↔ 0 < P.degree ∧ P.leadingCoeff ≤ 0 := by
simp only [← tendsto_neg_atTop_iff, ← eval_neg, tendsto_atTop_iff_leadingCoeff_nonneg,
degree_neg, leadingCoeff_neg, neg_nonneg]
theorem tendsto_atBot_of_leadingCoeff_nonpos (hdeg : 0 < P.degree) (hnps : P.leadingCoeff ≤ 0) :
Tendsto (fun x => eval x P) atTop atBot :=
P.tendsto_atBot_iff_leadingCoeff_nonpos.2 ⟨hdeg, hnps⟩
theorem abs_tendsto_atTop (hdeg : 0 < P.degree) :
Tendsto (fun x => abs <| eval x P) atTop atTop := by
rcases le_total 0 P.leadingCoeff with hP | hP
· exact tendsto_abs_atTop_atTop.comp (P.tendsto_atTop_of_leadingCoeff_nonneg hdeg hP)
· exact tendsto_abs_atBot_atTop.comp (P.tendsto_atBot_of_leadingCoeff_nonpos hdeg hP)
theorem abs_isBoundedUnder_iff :
(IsBoundedUnder (· ≤ ·) atTop fun x => |eval x P|) ↔ P.degree ≤ 0 := by
refine ⟨fun h => ?_, fun h => ⟨|P.coeff 0|, eventually_map.mpr (eventually_of_forall
(forall_imp (fun _ => le_of_eq) fun x => congr_arg abs <| _root_.trans (congr_arg (eval x)
(eq_C_of_degree_le_zero h)) eval_C))⟩⟩
contrapose! h
exact not_isBoundedUnder_of_tendsto_atTop (abs_tendsto_atTop P h)
theorem abs_tendsto_atTop_iff : Tendsto (fun x => abs <| eval x P) atTop atTop ↔ 0 < P.degree :=
⟨fun h => not_le.mp (mt (abs_isBoundedUnder_iff P).mpr (not_isBoundedUnder_of_tendsto_atTop h)),
abs_tendsto_atTop P⟩
theorem tendsto_nhds_iff {c : 𝕜} :
Tendsto (fun x => eval x P) atTop (𝓝 c) ↔ P.leadingCoeff = c ∧ P.degree ≤ 0 := by
refine ⟨fun h => ?_, fun h => ?_⟩
· have := P.isEquivalent_atTop_lead.tendsto_nhds h
by_cases hP : P.leadingCoeff = 0
· simp only [hP, zero_mul, tendsto_const_nhds_iff] at this
exact ⟨_root_.trans hP this, by simp [leadingCoeff_eq_zero.1 hP]⟩
· rw [tendsto_const_mul_pow_nhds_iff hP, natDegree_eq_zero_iff_degree_le_zero] at this
exact this.symm
· refine P.isEquivalent_atTop_lead.symm.tendsto_nhds ?_
have : P.natDegree = 0 := natDegree_eq_zero_iff_degree_le_zero.2 h.2
simp only [h.1, this, pow_zero, mul_one]
exact tendsto_const_nhds
end PolynomialAtTop
section PolynomialDivAtTop
theorem isEquivalent_atTop_div :
(fun x => eval x P / eval x Q) ~[atTop] fun x =>
P.leadingCoeff / Q.leadingCoeff * x ^ (P.natDegree - Q.natDegree : ℤ) := by
by_cases hP : P = 0
· simp [hP, IsEquivalent.refl]
by_cases hQ : Q = 0
· simp [hQ, IsEquivalent.refl]
refine
(P.isEquivalent_atTop_lead.symm.div Q.isEquivalent_atTop_lead.symm).symm.trans
(EventuallyEq.isEquivalent ((eventually_gt_atTop 0).mono fun x hx => ?_))
simp [← div_mul_div_comm, hP, hQ, zpow_sub₀ hx.ne.symm]
theorem div_tendsto_zero_of_degree_lt (hdeg : P.degree < Q.degree) :
Tendsto (fun x => eval x P / eval x Q) atTop (𝓝 0) := by
by_cases hP : P = 0
· simp [hP, tendsto_const_nhds]
rw [← natDegree_lt_natDegree_iff hP] at hdeg
refine (isEquivalent_atTop_div P Q).symm.tendsto_nhds ?_
rw [← mul_zero]
refine (tendsto_zpow_atTop_zero ?_).const_mul _
omega
theorem div_tendsto_zero_iff_degree_lt (hQ : Q ≠ 0) :
Tendsto (fun x => eval x P / eval x Q) atTop (𝓝 0) ↔ P.degree < Q.degree := by
refine ⟨fun h => ?_, div_tendsto_zero_of_degree_lt P Q⟩
by_cases hPQ : P.leadingCoeff / Q.leadingCoeff = 0
· simp only [div_eq_mul_inv, inv_eq_zero, mul_eq_zero] at hPQ
cases' hPQ with hP0 hQ0
· rw [leadingCoeff_eq_zero.1 hP0, degree_zero]
exact bot_lt_iff_ne_bot.2 fun hQ' => hQ (degree_eq_bot.1 hQ')
· exact absurd (leadingCoeff_eq_zero.1 hQ0) hQ
· have := (isEquivalent_atTop_div P Q).tendsto_nhds h
rw [tendsto_const_mul_zpow_atTop_nhds_iff hPQ] at this
cases' this with h h
· exact absurd h.2 hPQ
· rw [sub_lt_iff_lt_add, zero_add, Int.ofNat_lt] at h
exact degree_lt_degree h.1
theorem div_tendsto_leadingCoeff_div_of_degree_eq (hdeg : P.degree = Q.degree) :
Tendsto (fun x => eval x P / eval x Q) atTop (𝓝 <| P.leadingCoeff / Q.leadingCoeff) := by
refine (isEquivalent_atTop_div P Q).symm.tendsto_nhds ?_
rw [show (P.natDegree : ℤ) = Q.natDegree by simp [hdeg, natDegree]]
simp [tendsto_const_nhds]
theorem div_tendsto_atTop_of_degree_gt' (hdeg : Q.degree < P.degree)
(hpos : 0 < P.leadingCoeff / Q.leadingCoeff) :
Tendsto (fun x => eval x P / eval x Q) atTop atTop := by
have hQ : Q ≠ 0 := fun h => by
simp only [h, div_zero, leadingCoeff_zero] at hpos
exact hpos.false
rw [← natDegree_lt_natDegree_iff hQ] at hdeg
refine (isEquivalent_atTop_div P Q).symm.tendsto_atTop ?_
apply Tendsto.const_mul_atTop hpos
apply tendsto_zpow_atTop_atTop
omega
theorem div_tendsto_atTop_of_degree_gt (hdeg : Q.degree < P.degree) (hQ : Q ≠ 0)
(hnng : 0 ≤ P.leadingCoeff / Q.leadingCoeff) :
Tendsto (fun x => eval x P / eval x Q) atTop atTop :=
have ratio_pos : 0 < P.leadingCoeff / Q.leadingCoeff :=
lt_of_le_of_ne hnng
(div_ne_zero (fun h => ne_zero_of_degree_gt hdeg <| leadingCoeff_eq_zero.mp h) fun h =>
hQ <| leadingCoeff_eq_zero.mp h).symm
div_tendsto_atTop_of_degree_gt' P Q hdeg ratio_pos
theorem div_tendsto_atBot_of_degree_gt' (hdeg : Q.degree < P.degree)
(hneg : P.leadingCoeff / Q.leadingCoeff < 0) :
Tendsto (fun x => eval x P / eval x Q) atTop atBot := by
have hQ : Q ≠ 0 := fun h => by
simp only [h, div_zero, leadingCoeff_zero] at hneg
exact hneg.false
rw [← natDegree_lt_natDegree_iff hQ] at hdeg
refine (isEquivalent_atTop_div P Q).symm.tendsto_atBot ?_
apply Tendsto.const_mul_atTop_of_neg hneg
apply tendsto_zpow_atTop_atTop
omega
theorem div_tendsto_atBot_of_degree_gt (hdeg : Q.degree < P.degree) (hQ : Q ≠ 0)
(hnps : P.leadingCoeff / Q.leadingCoeff ≤ 0) :
Tendsto (fun x => eval x P / eval x Q) atTop atBot :=
have ratio_neg : P.leadingCoeff / Q.leadingCoeff < 0 :=
lt_of_le_of_ne hnps
(div_ne_zero (fun h => ne_zero_of_degree_gt hdeg <| leadingCoeff_eq_zero.mp h) fun h =>
hQ <| leadingCoeff_eq_zero.mp h)
div_tendsto_atBot_of_degree_gt' P Q hdeg ratio_neg
theorem abs_div_tendsto_atTop_of_degree_gt (hdeg : Q.degree < P.degree) (hQ : Q ≠ 0) :
Tendsto (fun x => |eval x P / eval x Q|) atTop atTop := by
by_cases h : 0 ≤ P.leadingCoeff / Q.leadingCoeff
· exact tendsto_abs_atTop_atTop.comp (P.div_tendsto_atTop_of_degree_gt Q hdeg hQ h)
· push_neg at h
exact tendsto_abs_atBot_atTop.comp (P.div_tendsto_atBot_of_degree_gt Q hdeg hQ h.le)
end PolynomialDivAtTop
theorem isBigO_of_degree_le (h : P.degree ≤ Q.degree) :
(fun x => eval x P) =O[atTop] fun x => eval x Q := by
by_cases hp : P = 0
· simpa [hp] using isBigO_zero (fun x => eval x Q) atTop
· have hq : Q ≠ 0 := ne_zero_of_degree_ge_degree h hp
have hPQ : ∀ᶠ x : 𝕜 in atTop, eval x Q = 0 → eval x P = 0 :=
Filter.mem_of_superset (Polynomial.eventually_no_roots Q hq) fun x h h' => absurd h' h
cases' le_iff_lt_or_eq.mp h with h h
· exact isBigO_of_div_tendsto_nhds hPQ 0 (div_tendsto_zero_of_degree_lt P Q h)
· exact isBigO_of_div_tendsto_nhds hPQ _ (div_tendsto_leadingCoeff_div_of_degree_eq P Q h)
end Polynomial
|
Analysis\SpecialFunctions\SmoothTransition.lean | /-
Copyright (c) 2020 Sébastien Gouëzel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sébastien Gouëzel, Yury Kudryashov
-/
import Mathlib.Analysis.Calculus.Deriv.Inv
import Mathlib.Analysis.Calculus.Deriv.Polynomial
import Mathlib.Analysis.SpecialFunctions.ExpDeriv
import Mathlib.Analysis.SpecialFunctions.PolynomialExp
/-!
# Infinitely smooth transition function
In this file we construct two infinitely smooth functions with properties that an analytic function
cannot have:
* `expNegInvGlue` is equal to zero for `x ≤ 0` and is strictly positive otherwise; it is given by
`x ↦ exp (-1/x)` for `x > 0`;
* `Real.smoothTransition` is equal to zero for `x ≤ 0` and is equal to one for `x ≥ 1`; it is given
by `expNegInvGlue x / (expNegInvGlue x + expNegInvGlue (1 - x))`;
-/
noncomputable section
open scoped Topology
open Polynomial Real Filter Set Function
/-- `expNegInvGlue` is the real function given by `x ↦ exp (-1/x)` for `x > 0` and `0`
for `x ≤ 0`. It is a basic building block to construct smooth partitions of unity. Its main property
is that it vanishes for `x ≤ 0`, it is positive for `x > 0`, and the junction between the two
behaviors is flat enough to retain smoothness. The fact that this function is `C^∞` is proved in
`expNegInvGlue.contDiff`. -/
def expNegInvGlue (x : ℝ) : ℝ :=
if x ≤ 0 then 0 else exp (-x⁻¹)
namespace expNegInvGlue
/-- The function `expNegInvGlue` vanishes on `(-∞, 0]`. -/
theorem zero_of_nonpos {x : ℝ} (hx : x ≤ 0) : expNegInvGlue x = 0 := by simp [expNegInvGlue, hx]
@[simp]
protected theorem zero : expNegInvGlue 0 = 0 := zero_of_nonpos le_rfl
/-- The function `expNegInvGlue` is positive on `(0, +∞)`. -/
theorem pos_of_pos {x : ℝ} (hx : 0 < x) : 0 < expNegInvGlue x := by
simp [expNegInvGlue, not_le.2 hx, exp_pos]
/-- The function `expNegInvGlue` is nonnegative. -/
theorem nonneg (x : ℝ) : 0 ≤ expNegInvGlue x := by
cases le_or_gt x 0 with
| inl h => exact ge_of_eq (zero_of_nonpos h)
| inr h => exact le_of_lt (pos_of_pos h)
@[simp] theorem zero_iff_nonpos {x : ℝ} : expNegInvGlue x = 0 ↔ x ≤ 0 :=
⟨fun h ↦ not_lt.mp fun h' ↦ (pos_of_pos h').ne' h, zero_of_nonpos⟩
/-!
### Smoothness of `expNegInvGlue`
In this section we prove that the function `f = expNegInvGlue` is infinitely smooth. To do
this, we show that $g_p(x)=p(x^{-1})f(x)$ is infinitely smooth for any polynomial `p` with real
coefficients. First we show that $g_p(x)$ tends to zero at zero, then we show that it is
differentiable with derivative $g_p'=g_{x^2(p-p')}$. Finally, we prove smoothness of $g_p$ by
induction, then deduce smoothness of $f$ by setting $p=1$.
-/
/-- Our function tends to zero at zero faster than any $P(x^{-1})$, $P∈ℝ[X]$, tends to infinity. -/
theorem tendsto_polynomial_inv_mul_zero (p : ℝ[X]) :
Tendsto (fun x ↦ p.eval x⁻¹ * expNegInvGlue x) (𝓝 0) (𝓝 0) := by
simp only [expNegInvGlue, mul_ite, mul_zero]
refine tendsto_const_nhds.if ?_
simp only [not_le]
have : Tendsto (fun x ↦ p.eval x⁻¹ / exp x⁻¹) (𝓝[>] 0) (𝓝 0) :=
p.tendsto_div_exp_atTop.comp tendsto_inv_zero_atTop
refine this.congr' <| mem_of_superset self_mem_nhdsWithin fun x hx ↦ ?_
simp [expNegInvGlue, hx.out.not_le, exp_neg, div_eq_mul_inv]
theorem hasDerivAt_polynomial_eval_inv_mul (p : ℝ[X]) (x : ℝ) :
HasDerivAt (fun x ↦ p.eval x⁻¹ * expNegInvGlue x)
((X ^ 2 * (p - derivative (R := ℝ) p)).eval x⁻¹ * expNegInvGlue x) x := by
rcases lt_trichotomy x 0 with hx | rfl | hx
· rw [zero_of_nonpos hx.le, mul_zero]
refine (hasDerivAt_const _ 0).congr_of_eventuallyEq ?_
filter_upwards [gt_mem_nhds hx] with y hy
rw [zero_of_nonpos hy.le, mul_zero]
· rw [expNegInvGlue.zero, mul_zero, hasDerivAt_iff_tendsto_slope]
refine ((tendsto_polynomial_inv_mul_zero (p * X)).mono_left inf_le_left).congr fun x ↦ ?_
simp [slope_def_field, div_eq_mul_inv, mul_right_comm]
· have := ((p.hasDerivAt x⁻¹).mul (hasDerivAt_neg _).exp).comp x (hasDerivAt_inv hx.ne')
convert this.congr_of_eventuallyEq _ using 1
· simp [expNegInvGlue, hx.not_le]
ring
· filter_upwards [lt_mem_nhds hx] with y hy
simp [expNegInvGlue, hy.not_le]
theorem differentiable_polynomial_eval_inv_mul (p : ℝ[X]) :
Differentiable ℝ (fun x ↦ p.eval x⁻¹ * expNegInvGlue x) := fun x ↦
(hasDerivAt_polynomial_eval_inv_mul p x).differentiableAt
theorem continuous_polynomial_eval_inv_mul (p : ℝ[X]) :
Continuous (fun x ↦ p.eval x⁻¹ * expNegInvGlue x) :=
(differentiable_polynomial_eval_inv_mul p).continuous
theorem contDiff_polynomial_eval_inv_mul {n : ℕ∞} (p : ℝ[X]) :
ContDiff ℝ n (fun x ↦ p.eval x⁻¹ * expNegInvGlue x) := by
apply contDiff_all_iff_nat.2 (fun m => ?_) n
induction m generalizing p with
| zero => exact contDiff_zero.2 <| continuous_polynomial_eval_inv_mul _
| succ m ihm =>
refine contDiff_succ_iff_deriv.2 ⟨differentiable_polynomial_eval_inv_mul _, ?_⟩
convert ihm (X ^ 2 * (p - derivative (R := ℝ) p)) using 2
exact (hasDerivAt_polynomial_eval_inv_mul p _).deriv
/-- The function `expNegInvGlue` is smooth. -/
protected theorem contDiff {n} : ContDiff ℝ n expNegInvGlue := by
simpa using contDiff_polynomial_eval_inv_mul 1
end expNegInvGlue
/-- An infinitely smooth function `f : ℝ → ℝ` such that `f x = 0` for `x ≤ 0`,
`f x = 1` for `1 ≤ x`, and `0 < f x < 1` for `0 < x < 1`. -/
def Real.smoothTransition (x : ℝ) : ℝ :=
expNegInvGlue x / (expNegInvGlue x + expNegInvGlue (1 - x))
namespace Real
namespace smoothTransition
variable {x : ℝ}
open expNegInvGlue
theorem pos_denom (x) : 0 < expNegInvGlue x + expNegInvGlue (1 - x) :=
(zero_lt_one.lt_or_lt x).elim (fun hx => add_pos_of_pos_of_nonneg (pos_of_pos hx) (nonneg _))
fun hx => add_pos_of_nonneg_of_pos (nonneg _) (pos_of_pos <| sub_pos.2 hx)
theorem one_of_one_le (h : 1 ≤ x) : smoothTransition x = 1 :=
(div_eq_one_iff_eq <| (pos_denom x).ne').2 <| by rw [zero_of_nonpos (sub_nonpos.2 h), add_zero]
@[simp]
nonrec theorem zero_iff_nonpos : smoothTransition x = 0 ↔ x ≤ 0 := by
simp only [smoothTransition, _root_.div_eq_zero_iff, (pos_denom x).ne', zero_iff_nonpos, or_false]
theorem zero_of_nonpos (h : x ≤ 0) : smoothTransition x = 0 := zero_iff_nonpos.2 h
@[simp]
protected theorem zero : smoothTransition 0 = 0 :=
zero_of_nonpos le_rfl
@[simp]
protected theorem one : smoothTransition 1 = 1 :=
one_of_one_le le_rfl
/-- Since `Real.smoothTransition` is constant on $(-∞, 0]$ and $[1, ∞)$, applying it to the
projection of `x : ℝ` to $[0, 1]$ gives the same result as applying it to `x`. -/
@[simp]
protected theorem projIcc :
smoothTransition (projIcc (0 : ℝ) 1 zero_le_one x) = smoothTransition x := by
refine congr_fun
(IccExtend_eq_self zero_le_one smoothTransition (fun x hx => ?_) fun x hx => ?_) x
· rw [smoothTransition.zero, zero_of_nonpos hx.le]
· rw [smoothTransition.one, one_of_one_le hx.le]
theorem le_one (x : ℝ) : smoothTransition x ≤ 1 :=
(div_le_one (pos_denom x)).2 <| le_add_of_nonneg_right (nonneg _)
theorem nonneg (x : ℝ) : 0 ≤ smoothTransition x :=
div_nonneg (expNegInvGlue.nonneg _) (pos_denom x).le
theorem lt_one_of_lt_one (h : x < 1) : smoothTransition x < 1 :=
(div_lt_one <| pos_denom x).2 <| lt_add_of_pos_right _ <| pos_of_pos <| sub_pos.2 h
theorem pos_of_pos (h : 0 < x) : 0 < smoothTransition x :=
div_pos (expNegInvGlue.pos_of_pos h) (pos_denom x)
protected theorem contDiff {n} : ContDiff ℝ n smoothTransition :=
expNegInvGlue.contDiff.div
(expNegInvGlue.contDiff.add <| expNegInvGlue.contDiff.comp <| contDiff_const.sub contDiff_id)
fun x => (pos_denom x).ne'
protected theorem contDiffAt {x n} : ContDiffAt ℝ n smoothTransition x :=
smoothTransition.contDiff.contDiffAt
protected theorem continuous : Continuous smoothTransition :=
(@smoothTransition.contDiff 0).continuous
protected theorem continuousAt : ContinuousAt smoothTransition x :=
smoothTransition.continuous.continuousAt
end smoothTransition
end Real
|
Analysis\SpecialFunctions\Sqrt.lean | /-
Copyright (c) 2021 Yury G. Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury G. Kudryashov
-/
import Mathlib.Analysis.Calculus.ContDiff.Basic
import Mathlib.Analysis.Calculus.Deriv.Pow
/-!
# Smoothness of `Real.sqrt`
In this file we prove that `Real.sqrt` is infinitely smooth at all points `x ≠ 0` and provide some
dot-notation lemmas.
## Tags
sqrt, differentiable
-/
open Set
open scoped Topology
namespace Real
/-- Local homeomorph between `(0, +∞)` and `(0, +∞)` with `toFun = (· ^ 2)` and
`invFun = Real.sqrt`. -/
noncomputable def sqPartialHomeomorph : PartialHomeomorph ℝ ℝ where
toFun x := x ^ 2
invFun := (√·)
source := Ioi 0
target := Ioi 0
map_source' _ h := mem_Ioi.2 (pow_pos (mem_Ioi.1 h) _)
map_target' _ h := mem_Ioi.2 (sqrt_pos.2 h)
left_inv' _ h := sqrt_sq (le_of_lt h)
right_inv' _ h := sq_sqrt (le_of_lt h)
open_source := isOpen_Ioi
open_target := isOpen_Ioi
continuousOn_toFun := (continuous_pow 2).continuousOn
continuousOn_invFun := continuousOn_id.sqrt
theorem deriv_sqrt_aux {x : ℝ} (hx : x ≠ 0) :
HasStrictDerivAt (√·) (1 / (2 * √x)) x ∧ ∀ n, ContDiffAt ℝ n (√·) x := by
cases' hx.lt_or_lt with hx hx
· rw [sqrt_eq_zero_of_nonpos hx.le, mul_zero, div_zero]
have : (√·) =ᶠ[𝓝 x] fun _ => 0 := (gt_mem_nhds hx).mono fun x hx => sqrt_eq_zero_of_nonpos hx.le
exact
⟨(hasStrictDerivAt_const x (0 : ℝ)).congr_of_eventuallyEq this.symm, fun n =>
contDiffAt_const.congr_of_eventuallyEq this⟩
· have : ↑2 * √x ^ (2 - 1) ≠ 0 := by simp [(sqrt_pos.2 hx).ne', @two_ne_zero ℝ]
constructor
· simpa using sqPartialHomeomorph.hasStrictDerivAt_symm hx this (hasStrictDerivAt_pow 2 _)
· exact fun n => sqPartialHomeomorph.contDiffAt_symm_deriv this hx (hasDerivAt_pow 2 (√x))
(contDiffAt_id.pow 2)
theorem hasStrictDerivAt_sqrt {x : ℝ} (hx : x ≠ 0) : HasStrictDerivAt (√·) (1 / (2 * √x)) x :=
(deriv_sqrt_aux hx).1
theorem contDiffAt_sqrt {x : ℝ} {n : ℕ∞} (hx : x ≠ 0) : ContDiffAt ℝ n (√·) x :=
(deriv_sqrt_aux hx).2 n
theorem hasDerivAt_sqrt {x : ℝ} (hx : x ≠ 0) : HasDerivAt (√·) (1 / (2 * √x)) x :=
(hasStrictDerivAt_sqrt hx).hasDerivAt
end Real
open Real
section deriv
variable {f : ℝ → ℝ} {s : Set ℝ} {f' x : ℝ}
theorem HasDerivWithinAt.sqrt (hf : HasDerivWithinAt f f' s x) (hx : f x ≠ 0) :
HasDerivWithinAt (fun y => √(f y)) (f' / (2 * √(f x))) s x := by
simpa only [(· ∘ ·), div_eq_inv_mul, mul_one] using
(hasDerivAt_sqrt hx).comp_hasDerivWithinAt x hf
theorem HasDerivAt.sqrt (hf : HasDerivAt f f' x) (hx : f x ≠ 0) :
HasDerivAt (fun y => √(f y)) (f' / (2 * √(f x))) x := by
simpa only [(· ∘ ·), div_eq_inv_mul, mul_one] using (hasDerivAt_sqrt hx).comp x hf
theorem HasStrictDerivAt.sqrt (hf : HasStrictDerivAt f f' x) (hx : f x ≠ 0) :
HasStrictDerivAt (fun t => √(f t)) (f' / (2 * √(f x))) x := by
simpa only [(· ∘ ·), div_eq_inv_mul, mul_one] using (hasStrictDerivAt_sqrt hx).comp x hf
theorem derivWithin_sqrt (hf : DifferentiableWithinAt ℝ f s x) (hx : f x ≠ 0)
(hxs : UniqueDiffWithinAt ℝ s x) :
derivWithin (fun x => √(f x)) s x = derivWithin f s x / (2 * √(f x)) :=
(hf.hasDerivWithinAt.sqrt hx).derivWithin hxs
@[simp]
theorem deriv_sqrt (hf : DifferentiableAt ℝ f x) (hx : f x ≠ 0) :
deriv (fun x => √(f x)) x = deriv f x / (2 * √(f x)) :=
(hf.hasDerivAt.sqrt hx).deriv
end deriv
section fderiv
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] {f : E → ℝ} {n : ℕ∞} {s : Set E}
{x : E} {f' : E →L[ℝ] ℝ}
theorem HasFDerivAt.sqrt (hf : HasFDerivAt f f' x) (hx : f x ≠ 0) :
HasFDerivAt (fun y => √(f y)) ((1 / (2 * √(f x))) • f') x :=
(hasDerivAt_sqrt hx).comp_hasFDerivAt x hf
theorem HasStrictFDerivAt.sqrt (hf : HasStrictFDerivAt f f' x) (hx : f x ≠ 0) :
HasStrictFDerivAt (fun y => √(f y)) ((1 / (2 * √(f x))) • f') x :=
(hasStrictDerivAt_sqrt hx).comp_hasStrictFDerivAt x hf
theorem HasFDerivWithinAt.sqrt (hf : HasFDerivWithinAt f f' s x) (hx : f x ≠ 0) :
HasFDerivWithinAt (fun y => √(f y)) ((1 / (2 * √(f x))) • f') s x :=
(hasDerivAt_sqrt hx).comp_hasFDerivWithinAt x hf
theorem DifferentiableWithinAt.sqrt (hf : DifferentiableWithinAt ℝ f s x) (hx : f x ≠ 0) :
DifferentiableWithinAt ℝ (fun y => √(f y)) s x :=
(hf.hasFDerivWithinAt.sqrt hx).differentiableWithinAt
theorem DifferentiableAt.sqrt (hf : DifferentiableAt ℝ f x) (hx : f x ≠ 0) :
DifferentiableAt ℝ (fun y => √(f y)) x :=
(hf.hasFDerivAt.sqrt hx).differentiableAt
theorem DifferentiableOn.sqrt (hf : DifferentiableOn ℝ f s) (hs : ∀ x ∈ s, f x ≠ 0) :
DifferentiableOn ℝ (fun y => √(f y)) s := fun x hx => (hf x hx).sqrt (hs x hx)
theorem Differentiable.sqrt (hf : Differentiable ℝ f) (hs : ∀ x, f x ≠ 0) :
Differentiable ℝ fun y => √(f y) := fun x => (hf x).sqrt (hs x)
theorem fderivWithin_sqrt (hf : DifferentiableWithinAt ℝ f s x) (hx : f x ≠ 0)
(hxs : UniqueDiffWithinAt ℝ s x) :
fderivWithin ℝ (fun x => √(f x)) s x = (1 / (2 * √(f x))) • fderivWithin ℝ f s x :=
(hf.hasFDerivWithinAt.sqrt hx).fderivWithin hxs
@[simp]
theorem fderiv_sqrt (hf : DifferentiableAt ℝ f x) (hx : f x ≠ 0) :
fderiv ℝ (fun x => √(f x)) x = (1 / (2 * √(f x))) • fderiv ℝ f x :=
(hf.hasFDerivAt.sqrt hx).fderiv
theorem ContDiffAt.sqrt (hf : ContDiffAt ℝ n f x) (hx : f x ≠ 0) :
ContDiffAt ℝ n (fun y => √(f y)) x :=
(contDiffAt_sqrt hx).comp x hf
theorem ContDiffWithinAt.sqrt (hf : ContDiffWithinAt ℝ n f s x) (hx : f x ≠ 0) :
ContDiffWithinAt ℝ n (fun y => √(f y)) s x :=
(contDiffAt_sqrt hx).comp_contDiffWithinAt x hf
theorem ContDiffOn.sqrt (hf : ContDiffOn ℝ n f s) (hs : ∀ x ∈ s, f x ≠ 0) :
ContDiffOn ℝ n (fun y => √(f y)) s := fun x hx => (hf x hx).sqrt (hs x hx)
theorem ContDiff.sqrt (hf : ContDiff ℝ n f) (h : ∀ x, f x ≠ 0) : ContDiff ℝ n fun y => √(f y) :=
contDiff_iff_contDiffAt.2 fun x => hf.contDiffAt.sqrt (h x)
end fderiv
|
Analysis\SpecialFunctions\Stirling.lean | /-
Copyright (c) 2022 Moritz Firsching. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Moritz Firsching, Fabian Kruse, Nikolas Kuhn
-/
import Mathlib.Analysis.PSeries
import Mathlib.Data.Real.Pi.Wallis
import Mathlib.Tactic.AdaptationNote
/-!
# Stirling's formula
This file proves Stirling's formula for the factorial.
It states that $n!$ grows asymptotically like $\sqrt{2\pi n}(\frac{n}{e})^n$.
## Proof outline
The proof follows: <https://proofwiki.org/wiki/Stirling%27s_Formula>.
We proceed in two parts.
**Part 1**: We consider the sequence $a_n$ of fractions $\frac{n!}{\sqrt{2n}(\frac{n}{e})^n}$
and prove that this sequence converges to a real, positive number $a$. For this the two main
ingredients are
- taking the logarithm of the sequence and
- using the series expansion of $\log(1 + x)$.
**Part 2**: We use the fact that the series defined in part 1 converges against a real number $a$
and prove that $a = \sqrt{\pi}$. Here the main ingredient is the convergence of Wallis' product
formula for `π`.
-/
open scoped Topology Real Nat Asymptotics
open Finset Filter Nat Real
namespace Stirling
/-!
### Part 1
https://proofwiki.org/wiki/Stirling%27s_Formula#Part_1
-/
/-- Define `stirlingSeq n` as $\frac{n!}{\sqrt{2n}(\frac{n}{e})^n}$.
Stirling's formula states that this sequence has limit $\sqrt(π)$.
-/
noncomputable def stirlingSeq (n : ℕ) : ℝ :=
n ! / (√(2 * n : ℝ) * (n / exp 1) ^ n)
@[simp]
theorem stirlingSeq_zero : stirlingSeq 0 = 0 := by
rw [stirlingSeq, cast_zero, mul_zero, Real.sqrt_zero, zero_mul, div_zero]
@[simp]
theorem stirlingSeq_one : stirlingSeq 1 = exp 1 / √2 := by
rw [stirlingSeq, pow_one, factorial_one, cast_one, mul_one, mul_one_div, one_div_div]
theorem log_stirlingSeq_formula (n : ℕ) :
log (stirlingSeq n) = Real.log n ! - 1 / 2 * Real.log (2 * n) - n * log (n / exp 1) := by
cases n
· simp
· rw [stirlingSeq, log_div, log_mul, sqrt_eq_rpow, log_rpow, Real.log_pow, tsub_tsub]
<;> positivity
/-- The sequence `log (stirlingSeq (m + 1)) - log (stirlingSeq (m + 2))` has the series expansion
`∑ 1 / (2 * (k + 1) + 1) * (1 / 2 * (m + 1) + 1)^(2 * (k + 1))`
-/
theorem log_stirlingSeq_diff_hasSum (m : ℕ) :
HasSum (fun k : ℕ => (1 : ℝ) / (2 * ↑(k + 1) + 1) * ((1 / (2 * ↑(m + 1) + 1)) ^ 2) ^ ↑(k + 1))
(log (stirlingSeq (m + 1)) - log (stirlingSeq (m + 2))) := by
let f (k : ℕ) := (1 : ℝ) / (2 * k + 1) * ((1 / (2 * ↑(m + 1) + 1)) ^ 2) ^ k
change HasSum (fun k => f (k + 1)) _
rw [hasSum_nat_add_iff]
convert (hasSum_log_one_add_inv m.cast_add_one_pos).mul_left ((↑(m + 1) : ℝ) + 1 / 2) using 1
· ext k
dsimp only [f]
rw [← pow_mul, pow_add]
push_cast
field_simp
ring
· have h : ∀ x ≠ (0 : ℝ), 1 + x⁻¹ = (x + 1) / x := fun x hx ↦ by field_simp [hx]
simp (disch := positivity) only [log_stirlingSeq_formula, log_div, log_mul, log_exp,
factorial_succ, cast_mul, cast_succ, cast_zero, range_one, sum_singleton, h]
ring
/-- The sequence `log ∘ stirlingSeq ∘ succ` is monotone decreasing -/
theorem log_stirlingSeq'_antitone : Antitone (Real.log ∘ stirlingSeq ∘ succ) :=
antitone_nat_of_succ_le fun n =>
sub_nonneg.mp <| (log_stirlingSeq_diff_hasSum n).nonneg fun m => by positivity
/-- We have a bound for successive elements in the sequence `log (stirlingSeq k)`.
-/
theorem log_stirlingSeq_diff_le_geo_sum (n : ℕ) :
log (stirlingSeq (n + 1)) - log (stirlingSeq (n + 2)) ≤
((1 : ℝ) / (2 * ↑(n + 1) + 1)) ^ 2 / (1 - ((1 : ℝ) / (2 * ↑(n + 1) + 1)) ^ 2) := by
have h_nonneg : (0 : ℝ) ≤ ((1 : ℝ) / (2 * ↑(n + 1) + 1)) ^ 2 := sq_nonneg _
have g : HasSum (fun k : ℕ => (((1 : ℝ) / (2 * ↑(n + 1) + 1)) ^ 2) ^ ↑(k + 1))
(((1 : ℝ) / (2 * ↑(n + 1) + 1)) ^ 2 / (1 - ((1 : ℝ) / (2 * ↑(n + 1) + 1)) ^ 2)) := by
have := (hasSum_geometric_of_lt_one h_nonneg ?_).mul_left (((1 : ℝ) / (2 * ↑(n + 1) + 1)) ^ 2)
· simp_rw [← _root_.pow_succ'] at this
exact this
rw [one_div, inv_pow]
exact inv_lt_one (one_lt_pow ((lt_add_iff_pos_left 1).mpr <| by positivity) two_ne_zero)
have hab (k : ℕ) : (1 : ℝ) / (2 * ↑(k + 1) + 1) * ((1 / (2 * ↑(n + 1) + 1)) ^ 2) ^ ↑(k + 1) ≤
(((1 : ℝ) / (2 * ↑(n + 1) + 1)) ^ 2) ^ ↑(k + 1) := by
refine mul_le_of_le_one_left (pow_nonneg h_nonneg ↑(k + 1)) ?_
rw [one_div]
exact inv_le_one (le_add_of_nonneg_left <| by positivity)
exact hasSum_le hab (log_stirlingSeq_diff_hasSum n) g
#adaptation_note /-- after v4.7.0-rc1, there is a performance problem in `field_simp`.
(Part of the code was ignoring the `maxDischargeDepth` setting:
now that we have to increase it, other paths become slow.) -/
set_option maxHeartbeats 400000 in
/-- We have the bound `log (stirlingSeq n) - log (stirlingSeq (n+1))` ≤ 1/(4 n^2)
-/
theorem log_stirlingSeq_sub_log_stirlingSeq_succ (n : ℕ) :
log (stirlingSeq (n + 1)) - log (stirlingSeq (n + 2)) ≤ 1 / (4 * (↑(n + 1) : ℝ) ^ 2) := by
have h₁ : (0 : ℝ) < 4 * ((n : ℝ) + 1) ^ 2 := by positivity
have h₃ : (0 : ℝ) < (2 * ((n : ℝ) + 1) + 1) ^ 2 := by positivity
have h₂ : (0 : ℝ) < 1 - (1 / (2 * ((n : ℝ) + 1) + 1)) ^ 2 := by
rw [← mul_lt_mul_right h₃]
have H : 0 < (2 * ((n : ℝ) + 1) + 1) ^ 2 - 1 := by nlinarith [@cast_nonneg ℝ _ n]
convert H using 1 <;> field_simp [h₃.ne']
refine (log_stirlingSeq_diff_le_geo_sum n).trans ?_
push_cast
rw [div_le_div_iff h₂ h₁]
field_simp [h₃.ne']
rw [div_le_div_right h₃]
ring_nf
norm_cast
omega
/-- For any `n`, we have `log_stirlingSeq 1 - log_stirlingSeq n ≤ 1/4 * ∑' 1/k^2` -/
theorem log_stirlingSeq_bounded_aux :
∃ c : ℝ, ∀ n : ℕ, log (stirlingSeq 1) - log (stirlingSeq (n + 1)) ≤ c := by
let d : ℝ := ∑' k : ℕ, (1 : ℝ) / (↑(k + 1) : ℝ) ^ 2
use 1 / 4 * d
let log_stirlingSeq' : ℕ → ℝ := fun k => log (stirlingSeq (k + 1))
intro n
have h₁ k : log_stirlingSeq' k - log_stirlingSeq' (k + 1) ≤ 1 / 4 * (1 / (↑(k + 1) : ℝ) ^ 2) := by
convert log_stirlingSeq_sub_log_stirlingSeq_succ k using 1; field_simp
have h₂ : (∑ k ∈ range n, 1 / (↑(k + 1) : ℝ) ^ 2) ≤ d := by
have := (summable_nat_add_iff 1).mpr <| Real.summable_one_div_nat_pow.mpr one_lt_two
exact sum_le_tsum (range n) (fun k _ => by positivity) this
calc
log (stirlingSeq 1) - log (stirlingSeq (n + 1)) = log_stirlingSeq' 0 - log_stirlingSeq' n :=
rfl
_ = ∑ k ∈ range n, (log_stirlingSeq' k - log_stirlingSeq' (k + 1)) := by
rw [← sum_range_sub' log_stirlingSeq' n]
_ ≤ ∑ k ∈ range n, 1 / 4 * (1 / ↑((k + 1)) ^ 2) := sum_le_sum fun k _ => h₁ k
_ = 1 / 4 * ∑ k ∈ range n, 1 / ↑((k + 1)) ^ 2 := by rw [mul_sum]
_ ≤ 1 / 4 * d := by gcongr
/-- The sequence `log_stirlingSeq` is bounded below for `n ≥ 1`. -/
theorem log_stirlingSeq_bounded_by_constant : ∃ c, ∀ n : ℕ, c ≤ log (stirlingSeq (n + 1)) := by
obtain ⟨d, h⟩ := log_stirlingSeq_bounded_aux
exact ⟨log (stirlingSeq 1) - d, fun n => sub_le_comm.mp (h n)⟩
/-- The sequence `stirlingSeq` is positive for `n > 0` -/
theorem stirlingSeq'_pos (n : ℕ) : 0 < stirlingSeq (n + 1) := by unfold stirlingSeq; positivity
/-- The sequence `stirlingSeq` has a positive lower bound.
-/
theorem stirlingSeq'_bounded_by_pos_constant : ∃ a, 0 < a ∧ ∀ n : ℕ, a ≤ stirlingSeq (n + 1) := by
cases' log_stirlingSeq_bounded_by_constant with c h
refine ⟨exp c, exp_pos _, fun n => ?_⟩
rw [← le_log_iff_exp_le (stirlingSeq'_pos n)]
exact h n
/-- The sequence `stirlingSeq ∘ succ` is monotone decreasing -/
theorem stirlingSeq'_antitone : Antitone (stirlingSeq ∘ succ) := fun n m h =>
(log_le_log_iff (stirlingSeq'_pos m) (stirlingSeq'_pos n)).mp (log_stirlingSeq'_antitone h)
/-- The limit `a` of the sequence `stirlingSeq` satisfies `0 < a` -/
theorem stirlingSeq_has_pos_limit_a : ∃ a : ℝ, 0 < a ∧ Tendsto stirlingSeq atTop (𝓝 a) := by
obtain ⟨x, x_pos, hx⟩ := stirlingSeq'_bounded_by_pos_constant
have hx' : x ∈ lowerBounds (Set.range (stirlingSeq ∘ succ)) := by simpa [lowerBounds] using hx
refine ⟨_, lt_of_lt_of_le x_pos (le_csInf (Set.range_nonempty _) hx'), ?_⟩
rw [← Filter.tendsto_add_atTop_iff_nat 1]
exact tendsto_atTop_ciInf stirlingSeq'_antitone ⟨x, hx'⟩
/-!
### Part 2
https://proofwiki.org/wiki/Stirling%27s_Formula#Part_2
-/
/-- The sequence `n / (2 * n + 1)` tends to `1/2` -/
theorem tendsto_self_div_two_mul_self_add_one :
Tendsto (fun n : ℕ => (n : ℝ) / (2 * n + 1)) atTop (𝓝 (1 / 2)) := by
conv =>
congr
· skip
· skip
rw [one_div, ← add_zero (2 : ℝ)]
refine (((tendsto_const_div_atTop_nhds_zero_nat 1).const_add (2 : ℝ)).inv₀
((add_zero (2 : ℝ)).symm ▸ two_ne_zero)).congr' (eventually_atTop.mpr ⟨1, fun n hn => ?_⟩)
rw [add_div' (1 : ℝ) 2 n (cast_ne_zero.mpr (one_le_iff_ne_zero.mp hn)), inv_div]
/-- For any `n ≠ 0`, we have the identity
`(stirlingSeq n)^4 / (stirlingSeq (2*n))^2 * (n / (2 * n + 1)) = W n`, where `W n` is the
`n`-th partial product of Wallis' formula for `π / 2`. -/
theorem stirlingSeq_pow_four_div_stirlingSeq_pow_two_eq (n : ℕ) (hn : n ≠ 0) :
stirlingSeq n ^ 4 / stirlingSeq (2 * n) ^ 2 * (n / (2 * n + 1)) = Wallis.W n := by
have : 4 = 2 * 2 := by rfl
rw [stirlingSeq, this, pow_mul, stirlingSeq, Wallis.W_eq_factorial_ratio]
simp_rw [div_pow, mul_pow]
rw [sq_sqrt, sq_sqrt]
any_goals positivity
field_simp [← exp_nsmul]
ring_nf
/-- Suppose the sequence `stirlingSeq` (defined above) has the limit `a ≠ 0`.
Then the Wallis sequence `W n` has limit `a^2 / 2`.
-/
theorem second_wallis_limit (a : ℝ) (hane : a ≠ 0) (ha : Tendsto stirlingSeq atTop (𝓝 a)) :
Tendsto Wallis.W atTop (𝓝 (a ^ 2 / 2)) := by
refine Tendsto.congr' (eventually_atTop.mpr ⟨1, fun n hn =>
stirlingSeq_pow_four_div_stirlingSeq_pow_two_eq n (one_le_iff_ne_zero.mp hn)⟩) ?_
have h : a ^ 2 / 2 = a ^ 4 / a ^ 2 * (1 / 2) := by
rw [mul_one_div, ← mul_one_div (a ^ 4) (a ^ 2), one_div, ← pow_sub_of_lt a]
norm_num
rw [h]
exact ((ha.pow 4).div ((ha.comp (tendsto_id.const_mul_atTop' two_pos)).pow 2)
(pow_ne_zero 2 hane)).mul tendsto_self_div_two_mul_self_add_one
/-- **Stirling's Formula** -/
theorem tendsto_stirlingSeq_sqrt_pi : Tendsto stirlingSeq atTop (𝓝 (√π)) := by
obtain ⟨a, hapos, halimit⟩ := stirlingSeq_has_pos_limit_a
have hπ : π / 2 = a ^ 2 / 2 :=
tendsto_nhds_unique Wallis.tendsto_W_nhds_pi_div_two (second_wallis_limit a hapos.ne' halimit)
rwa [(div_left_inj' (two_ne_zero' ℝ)).mp hπ, sqrt_sq hapos.le]
/-- **Stirling's Formula**, formulated in terms of `Asymptotics.IsEquivalent`. -/
lemma factorial_isEquivalent_stirling :
(fun n ↦ n ! : ℕ → ℝ) ~[atTop] fun n ↦ Real.sqrt (2 * n * π) * (n / exp 1) ^ n := by
refine Asymptotics.isEquivalent_of_tendsto_one ?_ ?_
· filter_upwards [eventually_ne_atTop 0] with n hn h
exact absurd h (by positivity)
· have : sqrt π ≠ 0 := by positivity
nth_rewrite 2 [← div_self this]
convert tendsto_stirlingSeq_sqrt_pi.div tendsto_const_nhds this using 1
ext n
field_simp [stirlingSeq, mul_right_comm]
end Stirling
|
Analysis\SpecialFunctions\Complex\Analytic.lean | /-
Copyright (c) 2024 Geoffrey Irving. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Geoffrey Irving
-/
import Mathlib.Analysis.Analytic.Composition
import Mathlib.Analysis.Analytic.Constructions
import Mathlib.Analysis.Complex.CauchyIntegral
import Mathlib.Analysis.SpecialFunctions.Complex.LogDeriv
/-!
# Various complex special functions are analytic
`exp`, `log`, and `cpow` are analytic, since they are differentiable.
-/
open Complex Set
open scoped Topology
variable {E : Type} [NormedAddCommGroup E] [NormedSpace ℂ E]
variable {f g : E → ℂ} {z : ℂ} {x : E} {s : Set E}
/-- `exp` is entire -/
theorem analyticOn_cexp : AnalyticOn ℂ exp univ := by
rw [analyticOn_univ_iff_differentiable]; exact differentiable_exp
/-- `exp` is analytic at any point -/
theorem analyticAt_cexp : AnalyticAt ℂ exp z :=
analyticOn_cexp z (mem_univ _)
/-- `exp ∘ f` is analytic -/
theorem AnalyticAt.cexp (fa : AnalyticAt ℂ f x) : AnalyticAt ℂ (fun z ↦ exp (f z)) x :=
analyticAt_cexp.comp fa
/-- `exp ∘ f` is analytic -/
theorem AnalyticOn.cexp (fs : AnalyticOn ℂ f s) : AnalyticOn ℂ (fun z ↦ exp (f z)) s :=
fun z n ↦ analyticAt_cexp.comp (fs z n)
/-- `log` is analytic away from nonpositive reals -/
theorem analyticAt_clog (m : z ∈ slitPlane) : AnalyticAt ℂ log z := by
rw [analyticAt_iff_eventually_differentiableAt]
filter_upwards [isOpen_slitPlane.eventually_mem m]
intro z m
exact differentiableAt_id.clog m
/-- `log` is analytic away from nonpositive reals -/
theorem AnalyticAt.clog (fa : AnalyticAt ℂ f x) (m : f x ∈ slitPlane) :
AnalyticAt ℂ (fun z ↦ log (f z)) x :=
(analyticAt_clog m).comp fa
/-- `log` is analytic away from nonpositive reals -/
theorem AnalyticOn.clog (fs : AnalyticOn ℂ f s) (m : ∀ z ∈ s, f z ∈ slitPlane) :
AnalyticOn ℂ (fun z ↦ log (f z)) s :=
fun z n ↦ (analyticAt_clog (m z n)).comp (fs z n)
/-- `f z ^ g z` is analytic if `f z` is not a nonpositive real -/
theorem AnalyticAt.cpow (fa : AnalyticAt ℂ f x) (ga : AnalyticAt ℂ g x)
(m : f x ∈ slitPlane) : AnalyticAt ℂ (fun z ↦ f z ^ g z) x := by
have e : (fun z ↦ f z ^ g z) =ᶠ[𝓝 x] fun z ↦ exp (log (f z) * g z) := by
filter_upwards [(fa.continuousAt.eventually_ne (slitPlane_ne_zero m))]
intro z fz
simp only [fz, cpow_def, if_false]
rw [analyticAt_congr e]
exact ((fa.clog m).mul ga).cexp
/-- `f z ^ g z` is analytic if `f z` avoids nonpositive reals -/
theorem AnalyticOn.cpow (fs : AnalyticOn ℂ f s) (gs : AnalyticOn ℂ g s)
(m : ∀ z ∈ s, f z ∈ slitPlane) : AnalyticOn ℂ (fun z ↦ f z ^ g z) s :=
fun z n ↦ (fs z n).cpow (gs z n) (m z n)
|
Analysis\SpecialFunctions\Complex\Arctan.lean | /-
Copyright (c) 2024 Jeremy Tan. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Tan
-/
import Mathlib.Analysis.SpecialFunctions.Complex.LogBounds
/-!
# Complex arctangent
This file defines the complex arctangent `Complex.arctan` as
$$\arctan z = -\frac i2 \log \frac{1 + zi}{1 - zi}$$
and shows that it extends `Real.arctan` to the complex plane. Its Taylor series expansion
$$\arctan z = \frac{(-1)^n}{2n + 1} z^{2n + 1},\ |z|<1$$
is proved in `Complex.hasSum_arctan`.
-/
namespace Complex
open scoped Real
/-- The complex arctangent, defined via the complex logarithm. -/
noncomputable def arctan (z : ℂ) : ℂ := -I / 2 * log ((1 + z * I) / (1 - z * I))
theorem tan_arctan {z : ℂ} (h₁ : z ≠ I) (h₂ : z ≠ -I) : tan (arctan z) = z := by
unfold tan sin cos
rw [div_div_eq_mul_div, div_mul_cancel₀ _ two_ne_zero, ← div_mul_eq_mul_div,
-- multiply top and bottom by `exp (arctan z * I)`
← mul_div_mul_right _ _ (exp_ne_zero (arctan z * I)), sub_mul, add_mul,
← exp_add, neg_mul, add_left_neg, exp_zero, ← exp_add, ← two_mul]
have z₁ : 1 + z * I ≠ 0 := by
contrapose! h₁
rw [add_eq_zero_iff_neg_eq, ← div_eq_iff I_ne_zero, div_I, neg_one_mul, neg_neg] at h₁
exact h₁.symm
have z₂ : 1 - z * I ≠ 0 := by
contrapose! h₂
rw [sub_eq_zero, ← div_eq_iff I_ne_zero, div_I, one_mul] at h₂
exact h₂.symm
have key : exp (2 * (arctan z * I)) = (1 + z * I) / (1 - z * I) := by
rw [arctan, ← mul_rotate, ← mul_assoc,
show 2 * (I * (-I / 2)) = 1 by field_simp, one_mul, exp_log]
· exact div_ne_zero z₁ z₂
-- multiply top and bottom by `1 - z * I`
rw [key, ← mul_div_mul_right _ _ z₂, sub_mul, add_mul, div_mul_cancel₀ _ z₂, one_mul,
show _ / _ * I = -(I * I) * z by ring, I_mul_I, neg_neg, one_mul]
/-- `cos z` is nonzero when the bounds in `arctan_tan` are met (`z` lies in the vertical strip
`-π / 2 < z.re < π / 2` and `z ≠ π / 2`). -/
lemma cos_ne_zero_of_arctan_bounds {z : ℂ} (h₀ : z ≠ π / 2) (h₁ : -(π / 2) < z.re)
(h₂ : z.re ≤ π / 2) : cos z ≠ 0 := by
refine cos_ne_zero_iff.mpr (fun k ↦ ?_)
rw [ne_eq, Complex.ext_iff, not_and_or] at h₀ ⊢
norm_cast at h₀ ⊢
cases' h₀ with nr ni
· left; contrapose! nr
rw [nr, mul_div_assoc, neg_eq_neg_one_mul, mul_lt_mul_iff_of_pos_right (by positivity)] at h₁
rw [nr, ← one_mul (π / 2), mul_div_assoc, mul_le_mul_iff_of_pos_right (by positivity)] at h₂
norm_cast at h₁ h₂
change -1 < _ at h₁
rwa [show 2 * k + 1 = 1 by omega, Int.cast_one, one_mul] at nr
· exact Or.inr ni
theorem arctan_tan {z : ℂ} (h₀ : z ≠ π / 2) (h₁ : -(π / 2) < z.re) (h₂ : z.re ≤ π / 2) :
arctan (tan z) = z := by
have h := cos_ne_zero_of_arctan_bounds h₀ h₁ h₂
unfold arctan tan
-- multiply top and bottom by `cos z`
rw [← mul_div_mul_right (1 + _) _ h, add_mul, sub_mul, one_mul, ← mul_rotate, mul_div_cancel₀ _ h]
conv_lhs =>
enter [2, 1, 2]
rw [sub_eq_add_neg, ← neg_mul, ← sin_neg, ← cos_neg]
rw [← exp_mul_I, ← exp_mul_I, ← exp_sub, show z * I - -z * I = 2 * (I * z) by ring, log_exp,
show -I / 2 * (2 * (I * z)) = -(I * I) * z by ring, I_mul_I, neg_neg, one_mul]
all_goals norm_num
· rwa [← div_lt_iff' two_pos, neg_div]
· rwa [← le_div_iff' two_pos]
@[simp, norm_cast]
theorem ofReal_arctan (x : ℝ) : (Real.arctan x : ℂ) = arctan x := by
conv_rhs => rw [← Real.tan_arctan x]
rw [ofReal_tan, arctan_tan]
all_goals norm_cast
· rw [← ne_eq]; exact (Real.arctan_lt_pi_div_two _).ne
· exact Real.neg_pi_div_two_lt_arctan _
· exact (Real.arctan_lt_pi_div_two _).le
/-- The argument of `1 + z` for `z` in the open unit disc is always in `(-π / 2, π / 2)`. -/
lemma arg_one_add_mem_Ioo {z : ℂ} (hz : ‖z‖ < 1) : (1 + z).arg ∈ Set.Ioo (-(π / 2)) (π / 2) := by
rw [Set.mem_Ioo, ← abs_lt, abs_arg_lt_pi_div_two_iff, add_re, one_re, ← neg_lt_iff_pos_add']
exact Or.inl (abs_lt.mp ((abs_re_le_abs z).trans_lt (norm_eq_abs z ▸ hz))).1
/-- We can combine the logs in `log (1 + z * I) + -log (1 - z * I)` into one.
This is only used in `hasSum_arctan`. -/
lemma hasSum_arctan_aux {z : ℂ} (hz : ‖z‖ < 1) :
log (1 + z * I) + -log (1 - z * I) = log ((1 + z * I) / (1 - z * I)) := by
have z₁ := mem_slitPlane_iff_arg.mp (mem_slitPlane_of_norm_lt_one (z := z * I) (by simpa))
have z₂ := mem_slitPlane_iff_arg.mp (mem_slitPlane_of_norm_lt_one (z := -(z * I)) (by simpa))
rw [← sub_eq_add_neg] at z₂
rw [← log_inv _ z₂.1, ← (log_mul_eq_add_log_iff z₁.2 (inv_eq_zero.ne.mpr z₂.2)).mpr,
div_eq_mul_inv]
-- `log_mul_eq_add_log_iff` requires a bound on `arg (1 + z * I) + arg (1 - z * I)⁻¹`.
-- `arg_one_add_mem_Ioo` provides sufficiently tight bounds on both terms
have b₁ := arg_one_add_mem_Ioo (z := z * I) (by simpa)
have b₂ : arg (1 - z * I)⁻¹ ∈ Set.Ioo (-(π / 2)) (π / 2) := by
simp_rw [arg_inv, z₂.1, ite_false, Set.neg_mem_Ioo_iff, neg_neg, sub_eq_add_neg]
exact arg_one_add_mem_Ioo (by simpa)
have c₁ := add_lt_add b₁.1 b₂.1
have c₂ := add_lt_add b₁.2 b₂.2
rw [show -(π / 2) + -(π / 2) = -π by ring] at c₁
rw [show π / 2 + π / 2 = π by ring] at c₂
exact ⟨c₁, c₂.le⟩
/-- The power series expansion of `Complex.arctan`, valid on the open unit disc. -/
theorem hasSum_arctan {z : ℂ} (hz : ‖z‖ < 1) :
HasSum (fun n : ℕ ↦ (-1) ^ n * z ^ (2 * n + 1) / ↑(2 * n + 1)) (arctan z) := by
have := ((hasSum_taylorSeries_log (z := z * I) (by simpa)).add
(hasSum_taylorSeries_neg_log (z := z * I) (by simpa))).mul_left (-I / 2)
simp_rw [← add_div, ← add_one_mul, hasSum_arctan_aux hz] at this
replace := (Nat.divModEquiv 2).symm.hasSum_iff.mpr this
dsimp [Function.comp_def] at this
simp_rw [← mul_comm 2 _] at this
refine this.prod_fiberwise fun k => ?_
dsimp only
convert hasSum_fintype (_ : Fin 2 → ℂ) using 1
rw [Fin.sum_univ_two, Fin.val_zero, Fin.val_one, Odd.neg_one_pow (n := 2 * k + 0 + 1) (by simp),
add_left_neg, zero_mul, zero_div, mul_zero, zero_add, show 2 * k + 1 + 1 = 2 * (k + 1) by ring,
Even.neg_one_pow (n := 2 * (k + 1)) (by simp), ← mul_div_assoc (_ / _), ← mul_assoc,
show -I / 2 * (1 + 1) = -I by ring]
congr 1
rw [mul_pow, pow_succ' I, pow_mul, I_sq,
show -I * _ = -(I * I) * (-1) ^ k * z ^ (2 * k + 1) by ring, I_mul_I, neg_neg, one_mul]
end Complex
/-- The power series expansion of `Real.arctan`, valid on `-1 < x < 1`. -/
theorem Real.hasSum_arctan {x : ℝ} (hx : ‖x‖ < 1) :
HasSum (fun n : ℕ => (-1) ^ n * x ^ (2 * n + 1) / ↑(2 * n + 1)) (arctan x) :=
mod_cast Complex.hasSum_arctan (z := x) (by simpa)
|
Analysis\SpecialFunctions\Complex\Arg.lean | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson
-/
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Angle
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse
/-!
# The argument of a complex number.
We define `arg : ℂ → ℝ`, returning a real number in the range (-π, π],
such that for `x ≠ 0`, `sin (arg x) = x.im / x.abs` and `cos (arg x) = x.re / x.abs`,
while `arg 0` defaults to `0`
-/
open Filter Metric Set
open scoped ComplexConjugate Real Topology
namespace Complex
variable {a x z : ℂ}
/-- `arg` returns values in the range (-π, π], such that for `x ≠ 0`,
`sin (arg x) = x.im / x.abs` and `cos (arg x) = x.re / x.abs`,
`arg 0` defaults to `0` -/
noncomputable def arg (x : ℂ) : ℝ :=
if 0 ≤ x.re then Real.arcsin (x.im / abs x)
else if 0 ≤ x.im then Real.arcsin ((-x).im / abs x) + π else Real.arcsin ((-x).im / abs x) - π
theorem sin_arg (x : ℂ) : Real.sin (arg x) = x.im / abs x := by
unfold arg; split_ifs <;>
simp [sub_eq_add_neg, arg,
Real.sin_arcsin (abs_le.1 (abs_im_div_abs_le_one x)).1 (abs_le.1 (abs_im_div_abs_le_one x)).2,
Real.sin_add, neg_div, Real.arcsin_neg, Real.sin_neg]
theorem cos_arg {x : ℂ} (hx : x ≠ 0) : Real.cos (arg x) = x.re / abs x := by
rw [arg]
split_ifs with h₁ h₂
· rw [Real.cos_arcsin]
field_simp [Real.sqrt_sq, (abs.pos hx).le, *]
· rw [Real.cos_add_pi, Real.cos_arcsin]
field_simp [Real.sqrt_div (sq_nonneg _), Real.sqrt_sq_eq_abs,
_root_.abs_of_neg (not_le.1 h₁), *]
· rw [Real.cos_sub_pi, Real.cos_arcsin]
field_simp [Real.sqrt_div (sq_nonneg _), Real.sqrt_sq_eq_abs,
_root_.abs_of_neg (not_le.1 h₁), *]
@[simp]
theorem abs_mul_exp_arg_mul_I (x : ℂ) : ↑(abs x) * exp (arg x * I) = x := by
rcases eq_or_ne x 0 with (rfl | hx)
· simp
· have : abs x ≠ 0 := abs.ne_zero hx
apply Complex.ext <;> field_simp [sin_arg, cos_arg hx, this, mul_comm (abs x)]
@[simp]
theorem abs_mul_cos_add_sin_mul_I (x : ℂ) : (abs x * (cos (arg x) + sin (arg x) * I) : ℂ) = x := by
rw [← exp_mul_I, abs_mul_exp_arg_mul_I]
@[simp]
lemma abs_mul_cos_arg (x : ℂ) : abs x * Real.cos (arg x) = x.re := by
simpa [-abs_mul_cos_add_sin_mul_I] using congr_arg re (abs_mul_cos_add_sin_mul_I x)
@[simp]
lemma abs_mul_sin_arg (x : ℂ) : abs x * Real.sin (arg x) = x.im := by
simpa [-abs_mul_cos_add_sin_mul_I] using congr_arg im (abs_mul_cos_add_sin_mul_I x)
theorem abs_eq_one_iff (z : ℂ) : abs z = 1 ↔ ∃ θ : ℝ, exp (θ * I) = z := by
refine ⟨fun hz => ⟨arg z, ?_⟩, ?_⟩
· calc
exp (arg z * I) = abs z * exp (arg z * I) := by rw [hz, ofReal_one, one_mul]
_ = z := abs_mul_exp_arg_mul_I z
· rintro ⟨θ, rfl⟩
exact Complex.abs_exp_ofReal_mul_I θ
@[simp]
theorem range_exp_mul_I : (Set.range fun x : ℝ => exp (x * I)) = Metric.sphere 0 1 := by
ext x
simp only [mem_sphere_zero_iff_norm, norm_eq_abs, abs_eq_one_iff, Set.mem_range]
theorem arg_mul_cos_add_sin_mul_I {r : ℝ} (hr : 0 < r) {θ : ℝ} (hθ : θ ∈ Set.Ioc (-π) π) :
arg (r * (cos θ + sin θ * I)) = θ := by
simp only [arg, map_mul, abs_cos_add_sin_mul_I, abs_of_nonneg hr.le, mul_one]
simp only [re_ofReal_mul, im_ofReal_mul, neg_im, ← ofReal_cos, ← ofReal_sin, ←
mk_eq_add_mul_I, neg_div, mul_div_cancel_left₀ _ hr.ne', mul_nonneg_iff_right_nonneg_of_pos hr]
by_cases h₁ : θ ∈ Set.Icc (-(π / 2)) (π / 2)
· rw [if_pos]
exacts [Real.arcsin_sin' h₁, Real.cos_nonneg_of_mem_Icc h₁]
· rw [Set.mem_Icc, not_and_or, not_le, not_le] at h₁
cases' h₁ with h₁ h₁
· replace hθ := hθ.1
have hcos : Real.cos θ < 0 := by
rw [← neg_pos, ← Real.cos_add_pi]
refine Real.cos_pos_of_mem_Ioo ⟨?_, ?_⟩ <;> linarith
have hsin : Real.sin θ < 0 := Real.sin_neg_of_neg_of_neg_pi_lt (by linarith) hθ
rw [if_neg, if_neg, ← Real.sin_add_pi, Real.arcsin_sin, add_sub_cancel_right] <;> [linarith;
linarith; exact hsin.not_le; exact hcos.not_le]
· replace hθ := hθ.2
have hcos : Real.cos θ < 0 := Real.cos_neg_of_pi_div_two_lt_of_lt h₁ (by linarith)
have hsin : 0 ≤ Real.sin θ := Real.sin_nonneg_of_mem_Icc ⟨by linarith, hθ⟩
rw [if_neg, if_pos, ← Real.sin_sub_pi, Real.arcsin_sin, sub_add_cancel] <;> [linarith;
linarith; exact hsin; exact hcos.not_le]
theorem arg_cos_add_sin_mul_I {θ : ℝ} (hθ : θ ∈ Set.Ioc (-π) π) : arg (cos θ + sin θ * I) = θ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I zero_lt_one hθ]
lemma arg_exp_mul_I (θ : ℝ) :
arg (exp (θ * I)) = toIocMod (mul_pos two_pos Real.pi_pos) (-π) θ := by
convert arg_cos_add_sin_mul_I (θ := toIocMod (mul_pos two_pos Real.pi_pos) (-π) θ) _ using 2
· rw [← exp_mul_I, eq_sub_of_add_eq $ toIocMod_add_toIocDiv_zsmul _ _ θ, ofReal_sub,
ofReal_zsmul, ofReal_mul, ofReal_ofNat, exp_mul_I_periodic.sub_zsmul_eq]
· convert toIocMod_mem_Ioc _ _ _
ring
@[simp]
theorem arg_zero : arg 0 = 0 := by simp [arg, le_refl]
theorem ext_abs_arg {x y : ℂ} (h₁ : abs x = abs y) (h₂ : x.arg = y.arg) : x = y := by
rw [← abs_mul_exp_arg_mul_I x, ← abs_mul_exp_arg_mul_I y, h₁, h₂]
theorem ext_abs_arg_iff {x y : ℂ} : x = y ↔ abs x = abs y ∧ arg x = arg y :=
⟨fun h => h ▸ ⟨rfl, rfl⟩, and_imp.2 ext_abs_arg⟩
theorem arg_mem_Ioc (z : ℂ) : arg z ∈ Set.Ioc (-π) π := by
have hπ : 0 < π := Real.pi_pos
rcases eq_or_ne z 0 with (rfl | hz)
· simp [hπ, hπ.le]
rcases existsUnique_add_zsmul_mem_Ioc Real.two_pi_pos (arg z) (-π) with ⟨N, hN, -⟩
rw [two_mul, neg_add_cancel_left, ← two_mul, zsmul_eq_mul] at hN
rw [← abs_mul_cos_add_sin_mul_I z, ← cos_add_int_mul_two_pi _ N, ← sin_add_int_mul_two_pi _ N]
have := arg_mul_cos_add_sin_mul_I (abs.pos hz) hN
push_cast at this
rwa [this]
@[simp]
theorem range_arg : Set.range arg = Set.Ioc (-π) π :=
(Set.range_subset_iff.2 arg_mem_Ioc).antisymm fun _ hx => ⟨_, arg_cos_add_sin_mul_I hx⟩
theorem arg_le_pi (x : ℂ) : arg x ≤ π :=
(arg_mem_Ioc x).2
theorem neg_pi_lt_arg (x : ℂ) : -π < arg x :=
(arg_mem_Ioc x).1
theorem abs_arg_le_pi (z : ℂ) : |arg z| ≤ π :=
abs_le.2 ⟨(neg_pi_lt_arg z).le, arg_le_pi z⟩
@[simp]
theorem arg_nonneg_iff {z : ℂ} : 0 ≤ arg z ↔ 0 ≤ z.im := by
rcases eq_or_ne z 0 with (rfl | h₀); · simp
calc
0 ≤ arg z ↔ 0 ≤ Real.sin (arg z) :=
⟨fun h => Real.sin_nonneg_of_mem_Icc ⟨h, arg_le_pi z⟩, by
contrapose!
intro h
exact Real.sin_neg_of_neg_of_neg_pi_lt h (neg_pi_lt_arg _)⟩
_ ↔ _ := by rw [sin_arg, le_div_iff (abs.pos h₀), zero_mul]
@[simp]
theorem arg_neg_iff {z : ℂ} : arg z < 0 ↔ z.im < 0 :=
lt_iff_lt_of_le_iff_le arg_nonneg_iff
theorem arg_real_mul (x : ℂ) {r : ℝ} (hr : 0 < r) : arg (r * x) = arg x := by
rcases eq_or_ne x 0 with (rfl | hx); · rw [mul_zero]
conv_lhs =>
rw [← abs_mul_cos_add_sin_mul_I x, ← mul_assoc, ← ofReal_mul,
arg_mul_cos_add_sin_mul_I (mul_pos hr (abs.pos hx)) x.arg_mem_Ioc]
theorem arg_mul_real {r : ℝ} (hr : 0 < r) (x : ℂ) : arg (x * r) = arg x :=
mul_comm x r ▸ arg_real_mul x hr
theorem arg_eq_arg_iff {x y : ℂ} (hx : x ≠ 0) (hy : y ≠ 0) :
arg x = arg y ↔ (abs y / abs x : ℂ) * x = y := by
simp only [ext_abs_arg_iff, map_mul, map_div₀, abs_ofReal, abs_abs,
div_mul_cancel₀ _ (abs.ne_zero hx), eq_self_iff_true, true_and_iff]
rw [← ofReal_div, arg_real_mul]
exact div_pos (abs.pos hy) (abs.pos hx)
@[simp]
theorem arg_one : arg 1 = 0 := by simp [arg, zero_le_one]
@[simp]
theorem arg_neg_one : arg (-1) = π := by simp [arg, le_refl, not_le.2 (zero_lt_one' ℝ)]
@[simp]
theorem arg_I : arg I = π / 2 := by simp [arg, le_refl]
@[simp]
theorem arg_neg_I : arg (-I) = -(π / 2) := by simp [arg, le_refl]
@[simp]
theorem tan_arg (x : ℂ) : Real.tan (arg x) = x.im / x.re := by
by_cases h : x = 0
· simp only [h, zero_div, Complex.zero_im, Complex.arg_zero, Real.tan_zero, Complex.zero_re]
rw [Real.tan_eq_sin_div_cos, sin_arg, cos_arg h, div_div_div_cancel_right _ (abs.ne_zero h)]
theorem arg_ofReal_of_nonneg {x : ℝ} (hx : 0 ≤ x) : arg x = 0 := by simp [arg, hx]
@[simp, norm_cast]
lemma natCast_arg {n : ℕ} : arg n = 0 :=
ofReal_natCast n ▸ arg_ofReal_of_nonneg n.cast_nonneg
@[simp]
lemma ofNat_arg {n : ℕ} [n.AtLeastTwo] : arg (no_index (OfNat.ofNat n)) = 0 :=
natCast_arg
theorem arg_eq_zero_iff {z : ℂ} : arg z = 0 ↔ 0 ≤ z.re ∧ z.im = 0 := by
refine ⟨fun h => ?_, ?_⟩
· rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [abs.nonneg]
· cases' z with x y
rintro ⟨h, rfl : y = 0⟩
exact arg_ofReal_of_nonneg h
open ComplexOrder in
lemma arg_eq_zero_iff_zero_le {z : ℂ} : arg z = 0 ↔ 0 ≤ z := by
rw [arg_eq_zero_iff, eq_comm, nonneg_iff]
theorem arg_eq_pi_iff {z : ℂ} : arg z = π ↔ z.re < 0 ∧ z.im = 0 := by
by_cases h₀ : z = 0
· simp [h₀, lt_irrefl, Real.pi_ne_zero.symm]
constructor
· intro h
rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [h₀]
· cases' z with x y
rintro ⟨h : x < 0, rfl : y = 0⟩
rw [← arg_neg_one, ← arg_real_mul (-1) (neg_pos.2 h)]
simp [← ofReal_def]
open ComplexOrder in
lemma arg_eq_pi_iff_lt_zero {z : ℂ} : arg z = π ↔ z < 0 := arg_eq_pi_iff
theorem arg_lt_pi_iff {z : ℂ} : arg z < π ↔ 0 ≤ z.re ∨ z.im ≠ 0 := by
rw [(arg_le_pi z).lt_iff_ne, not_iff_comm, not_or, not_le, Classical.not_not, arg_eq_pi_iff]
theorem arg_ofReal_of_neg {x : ℝ} (hx : x < 0) : arg x = π :=
arg_eq_pi_iff.2 ⟨hx, rfl⟩
theorem arg_eq_pi_div_two_iff {z : ℂ} : arg z = π / 2 ↔ z.re = 0 ∧ 0 < z.im := by
by_cases h₀ : z = 0; · simp [h₀, lt_irrefl, Real.pi_div_two_pos.ne]
constructor
· intro h
rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [h₀]
· cases' z with x y
rintro ⟨rfl : x = 0, hy : 0 < y⟩
rw [← arg_I, ← arg_real_mul I hy, ofReal_mul', I_re, I_im, mul_zero, mul_one]
theorem arg_eq_neg_pi_div_two_iff {z : ℂ} : arg z = -(π / 2) ↔ z.re = 0 ∧ z.im < 0 := by
by_cases h₀ : z = 0; · simp [h₀, lt_irrefl, Real.pi_ne_zero]
constructor
· intro h
rw [← abs_mul_cos_add_sin_mul_I z, h]
simp [h₀]
· cases' z with x y
rintro ⟨rfl : x = 0, hy : y < 0⟩
rw [← arg_neg_I, ← arg_real_mul (-I) (neg_pos.2 hy), mk_eq_add_mul_I]
simp
theorem arg_of_re_nonneg {x : ℂ} (hx : 0 ≤ x.re) : arg x = Real.arcsin (x.im / abs x) :=
if_pos hx
theorem arg_of_re_neg_of_im_nonneg {x : ℂ} (hx_re : x.re < 0) (hx_im : 0 ≤ x.im) :
arg x = Real.arcsin ((-x).im / abs x) + π := by
simp only [arg, hx_re.not_le, hx_im, if_true, if_false]
theorem arg_of_re_neg_of_im_neg {x : ℂ} (hx_re : x.re < 0) (hx_im : x.im < 0) :
arg x = Real.arcsin ((-x).im / abs x) - π := by
simp only [arg, hx_re.not_le, hx_im.not_le, if_false]
theorem arg_of_im_nonneg_of_ne_zero {z : ℂ} (h₁ : 0 ≤ z.im) (h₂ : z ≠ 0) :
arg z = Real.arccos (z.re / abs z) := by
rw [← cos_arg h₂, Real.arccos_cos (arg_nonneg_iff.2 h₁) (arg_le_pi _)]
theorem arg_of_im_pos {z : ℂ} (hz : 0 < z.im) : arg z = Real.arccos (z.re / abs z) :=
arg_of_im_nonneg_of_ne_zero hz.le fun h => hz.ne' <| h.symm ▸ rfl
theorem arg_of_im_neg {z : ℂ} (hz : z.im < 0) : arg z = -Real.arccos (z.re / abs z) := by
have h₀ : z ≠ 0 := mt (congr_arg im) hz.ne
rw [← cos_arg h₀, ← Real.cos_neg, Real.arccos_cos, neg_neg]
exacts [neg_nonneg.2 (arg_neg_iff.2 hz).le, neg_le.2 (neg_pi_lt_arg z).le]
theorem arg_conj (x : ℂ) : arg (conj x) = if arg x = π then π else -arg x := by
simp_rw [arg_eq_pi_iff, arg, neg_im, conj_im, conj_re, abs_conj, neg_div, neg_neg,
Real.arcsin_neg]
rcases lt_trichotomy x.re 0 with (hr | hr | hr) <;>
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· simp [hr, hr.not_le, hi.le, hi.ne, not_le.2 hi, add_comm]
· simp [hr, hr.not_le, hi]
· simp [hr, hr.not_le, hi.ne.symm, hi.le, not_le.2 hi, sub_eq_neg_add]
· simp [hr]
· simp [hr]
· simp [hr]
· simp [hr, hr.le, hi.ne]
· simp [hr, hr.le, hr.le.not_lt]
· simp [hr, hr.le, hr.le.not_lt]
theorem arg_inv (x : ℂ) : arg x⁻¹ = if arg x = π then π else -arg x := by
rw [← arg_conj, inv_def, mul_comm]
by_cases hx : x = 0
· simp [hx]
· exact arg_real_mul (conj x) (by simp [hx])
@[simp] lemma abs_arg_inv (x : ℂ) : |x⁻¹.arg| = |x.arg| := by rw [arg_inv]; split_ifs <;> simp [*]
-- TODO: Replace the next two lemmas by general facts about periodic functions
lemma abs_eq_one_iff' : abs x = 1 ↔ ∃ θ ∈ Set.Ioc (-π) π, exp (θ * I) = x := by
rw [abs_eq_one_iff]
constructor
· rintro ⟨θ, rfl⟩
refine ⟨toIocMod (mul_pos two_pos Real.pi_pos) (-π) θ, ?_, ?_⟩
· convert toIocMod_mem_Ioc _ _ _
ring
· rw [eq_sub_of_add_eq $ toIocMod_add_toIocDiv_zsmul _ _ θ, ofReal_sub,
ofReal_zsmul, ofReal_mul, ofReal_ofNat, exp_mul_I_periodic.sub_zsmul_eq]
· rintro ⟨θ, _, rfl⟩
exact ⟨θ, rfl⟩
lemma image_exp_Ioc_eq_sphere : (fun θ : ℝ ↦ exp (θ * I)) '' Set.Ioc (-π) π = sphere 0 1 := by
ext; simpa using abs_eq_one_iff'.symm
theorem arg_le_pi_div_two_iff {z : ℂ} : arg z ≤ π / 2 ↔ 0 ≤ re z ∨ im z < 0 := by
rcases le_or_lt 0 (re z) with hre | hre
· simp only [hre, arg_of_re_nonneg hre, Real.arcsin_le_pi_div_two, true_or_iff]
simp only [hre.not_le, false_or_iff]
rcases le_or_lt 0 (im z) with him | him
· simp only [him.not_lt]
rw [iff_false_iff, not_le, arg_of_re_neg_of_im_nonneg hre him, ← sub_lt_iff_lt_add, half_sub,
Real.neg_pi_div_two_lt_arcsin, neg_im, neg_div, neg_lt_neg_iff, div_lt_one, ←
_root_.abs_of_nonneg him, abs_im_lt_abs]
exacts [hre.ne, abs.pos <| ne_of_apply_ne re hre.ne]
· simp only [him]
rw [iff_true_iff, arg_of_re_neg_of_im_neg hre him]
exact (sub_le_self _ Real.pi_pos.le).trans (Real.arcsin_le_pi_div_two _)
theorem neg_pi_div_two_le_arg_iff {z : ℂ} : -(π / 2) ≤ arg z ↔ 0 ≤ re z ∨ 0 ≤ im z := by
rcases le_or_lt 0 (re z) with hre | hre
· simp only [hre, arg_of_re_nonneg hre, Real.neg_pi_div_two_le_arcsin, true_or_iff]
simp only [hre.not_le, false_or_iff]
rcases le_or_lt 0 (im z) with him | him
· simp only [him]
rw [iff_true_iff, arg_of_re_neg_of_im_nonneg hre him]
exact (Real.neg_pi_div_two_le_arcsin _).trans (le_add_of_nonneg_right Real.pi_pos.le)
· simp only [him.not_le]
rw [iff_false_iff, not_le, arg_of_re_neg_of_im_neg hre him, sub_lt_iff_lt_add', ←
sub_eq_add_neg, sub_half, Real.arcsin_lt_pi_div_two, div_lt_one, neg_im, ← abs_of_neg him,
abs_im_lt_abs]
exacts [hre.ne, abs.pos <| ne_of_apply_ne re hre.ne]
lemma neg_pi_div_two_lt_arg_iff {z : ℂ} : -(π / 2) < arg z ↔ 0 < re z ∨ 0 ≤ im z := by
rw [lt_iff_le_and_ne, neg_pi_div_two_le_arg_iff, ne_comm, Ne, arg_eq_neg_pi_div_two_iff]
rcases lt_trichotomy z.re 0 with hre | hre | hre
· simp [hre.ne, hre.not_le, hre.not_lt]
· simp [hre]
· simp [hre, hre.le, hre.ne']
lemma arg_lt_pi_div_two_iff {z : ℂ} : arg z < π / 2 ↔ 0 < re z ∨ im z < 0 ∨ z = 0 := by
rw [lt_iff_le_and_ne, arg_le_pi_div_two_iff, Ne, arg_eq_pi_div_two_iff]
rcases lt_trichotomy z.re 0 with hre | hre | hre
· have : z ≠ 0 := by simp [Complex.ext_iff, hre.ne]
simp [hre.ne, hre.not_le, hre.not_lt, this]
· have : z = 0 ↔ z.im = 0 := by simp [Complex.ext_iff, hre]
simp [hre, this, or_comm, le_iff_eq_or_lt]
· simp [hre, hre.le, hre.ne']
@[simp]
theorem abs_arg_le_pi_div_two_iff {z : ℂ} : |arg z| ≤ π / 2 ↔ 0 ≤ re z := by
rw [abs_le, arg_le_pi_div_two_iff, neg_pi_div_two_le_arg_iff, ← or_and_left, ← not_le,
and_not_self_iff, or_false_iff]
@[simp]
theorem abs_arg_lt_pi_div_two_iff {z : ℂ} : |arg z| < π / 2 ↔ 0 < re z ∨ z = 0 := by
rw [abs_lt, arg_lt_pi_div_two_iff, neg_pi_div_two_lt_arg_iff, ← or_and_left]
rcases eq_or_ne z 0 with hz | hz
· simp [hz]
· simp_rw [hz, or_false, ← not_lt, not_and_self_iff, or_false]
@[simp]
theorem arg_conj_coe_angle (x : ℂ) : (arg (conj x) : Real.Angle) = -arg x := by
by_cases h : arg x = π <;> simp [arg_conj, h]
@[simp]
theorem arg_inv_coe_angle (x : ℂ) : (arg x⁻¹ : Real.Angle) = -arg x := by
by_cases h : arg x = π <;> simp [arg_inv, h]
theorem arg_neg_eq_arg_sub_pi_of_im_pos {x : ℂ} (hi : 0 < x.im) : arg (-x) = arg x - π := by
rw [arg_of_im_pos hi, arg_of_im_neg (show (-x).im < 0 from Left.neg_neg_iff.2 hi)]
simp [neg_div, Real.arccos_neg]
theorem arg_neg_eq_arg_add_pi_of_im_neg {x : ℂ} (hi : x.im < 0) : arg (-x) = arg x + π := by
rw [arg_of_im_neg hi, arg_of_im_pos (show 0 < (-x).im from Left.neg_pos_iff.2 hi)]
simp [neg_div, Real.arccos_neg, add_comm, ← sub_eq_add_neg]
theorem arg_neg_eq_arg_sub_pi_iff {x : ℂ} :
arg (-x) = arg x - π ↔ 0 < x.im ∨ x.im = 0 ∧ x.re < 0 := by
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· simp [hi, hi.ne, hi.not_lt, arg_neg_eq_arg_add_pi_of_im_neg, sub_eq_add_neg, ←
add_eq_zero_iff_eq_neg, Real.pi_ne_zero]
· rw [(ext rfl hi : x = x.re)]
rcases lt_trichotomy x.re 0 with (hr | hr | hr)
· rw [arg_ofReal_of_neg hr, ← ofReal_neg, arg_ofReal_of_nonneg (Left.neg_pos_iff.2 hr).le]
simp [hr]
· simp [hr, hi, Real.pi_ne_zero]
· rw [arg_ofReal_of_nonneg hr.le, ← ofReal_neg, arg_ofReal_of_neg (Left.neg_neg_iff.2 hr)]
simp [hr.not_lt, ← add_eq_zero_iff_eq_neg, Real.pi_ne_zero]
· simp [hi, arg_neg_eq_arg_sub_pi_of_im_pos]
theorem arg_neg_eq_arg_add_pi_iff {x : ℂ} :
arg (-x) = arg x + π ↔ x.im < 0 ∨ x.im = 0 ∧ 0 < x.re := by
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· simp [hi, arg_neg_eq_arg_add_pi_of_im_neg]
· rw [(ext rfl hi : x = x.re)]
rcases lt_trichotomy x.re 0 with (hr | hr | hr)
· rw [arg_ofReal_of_neg hr, ← ofReal_neg, arg_ofReal_of_nonneg (Left.neg_pos_iff.2 hr).le]
simp [hr.not_lt, ← two_mul, Real.pi_ne_zero]
· simp [hr, hi, Real.pi_ne_zero.symm]
· rw [arg_ofReal_of_nonneg hr.le, ← ofReal_neg, arg_ofReal_of_neg (Left.neg_neg_iff.2 hr)]
simp [hr]
· simp [hi, hi.ne.symm, hi.not_lt, arg_neg_eq_arg_sub_pi_of_im_pos, sub_eq_add_neg, ←
add_eq_zero_iff_neg_eq, Real.pi_ne_zero]
theorem arg_neg_coe_angle {x : ℂ} (hx : x ≠ 0) : (arg (-x) : Real.Angle) = arg x + π := by
rcases lt_trichotomy x.im 0 with (hi | hi | hi)
· rw [arg_neg_eq_arg_add_pi_of_im_neg hi, Real.Angle.coe_add]
· rw [(ext rfl hi : x = x.re)]
rcases lt_trichotomy x.re 0 with (hr | hr | hr)
· rw [arg_ofReal_of_neg hr, ← ofReal_neg, arg_ofReal_of_nonneg (Left.neg_pos_iff.2 hr).le, ←
Real.Angle.coe_add, ← two_mul, Real.Angle.coe_two_pi, Real.Angle.coe_zero]
· exact False.elim (hx (ext hr hi))
· rw [arg_ofReal_of_nonneg hr.le, ← ofReal_neg, arg_ofReal_of_neg (Left.neg_neg_iff.2 hr),
Real.Angle.coe_zero, zero_add]
· rw [arg_neg_eq_arg_sub_pi_of_im_pos hi, Real.Angle.coe_sub, Real.Angle.sub_coe_pi_eq_add_coe_pi]
theorem arg_mul_cos_add_sin_mul_I_eq_toIocMod {r : ℝ} (hr : 0 < r) (θ : ℝ) :
arg (r * (cos θ + sin θ * I)) = toIocMod Real.two_pi_pos (-π) θ := by
have hi : toIocMod Real.two_pi_pos (-π) θ ∈ Set.Ioc (-π) π := by
convert toIocMod_mem_Ioc _ _ θ
ring
convert arg_mul_cos_add_sin_mul_I hr hi using 3
simp [toIocMod, cos_sub_int_mul_two_pi, sin_sub_int_mul_two_pi]
theorem arg_cos_add_sin_mul_I_eq_toIocMod (θ : ℝ) :
arg (cos θ + sin θ * I) = toIocMod Real.two_pi_pos (-π) θ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I_eq_toIocMod zero_lt_one]
theorem arg_mul_cos_add_sin_mul_I_sub {r : ℝ} (hr : 0 < r) (θ : ℝ) :
arg (r * (cos θ + sin θ * I)) - θ = 2 * π * ⌊(π - θ) / (2 * π)⌋ := by
rw [arg_mul_cos_add_sin_mul_I_eq_toIocMod hr, toIocMod_sub_self, toIocDiv_eq_neg_floor,
zsmul_eq_mul]
ring_nf
theorem arg_cos_add_sin_mul_I_sub (θ : ℝ) :
arg (cos θ + sin θ * I) - θ = 2 * π * ⌊(π - θ) / (2 * π)⌋ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I_sub zero_lt_one]
theorem arg_mul_cos_add_sin_mul_I_coe_angle {r : ℝ} (hr : 0 < r) (θ : Real.Angle) :
(arg (r * (Real.Angle.cos θ + Real.Angle.sin θ * I)) : Real.Angle) = θ := by
induction' θ using Real.Angle.induction_on with θ
rw [Real.Angle.cos_coe, Real.Angle.sin_coe, Real.Angle.angle_eq_iff_two_pi_dvd_sub]
use ⌊(π - θ) / (2 * π)⌋
exact mod_cast arg_mul_cos_add_sin_mul_I_sub hr θ
theorem arg_cos_add_sin_mul_I_coe_angle (θ : Real.Angle) :
(arg (Real.Angle.cos θ + Real.Angle.sin θ * I) : Real.Angle) = θ := by
rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I_coe_angle zero_lt_one]
theorem arg_mul_coe_angle {x y : ℂ} (hx : x ≠ 0) (hy : y ≠ 0) :
(arg (x * y) : Real.Angle) = arg x + arg y := by
convert arg_mul_cos_add_sin_mul_I_coe_angle (mul_pos (abs.pos hx) (abs.pos hy))
(arg x + arg y : Real.Angle) using
3
simp_rw [← Real.Angle.coe_add, Real.Angle.sin_coe, Real.Angle.cos_coe, ofReal_cos, ofReal_sin,
cos_add_sin_I, ofReal_add, add_mul, exp_add, ofReal_mul]
rw [mul_assoc, mul_comm (exp _), ← mul_assoc (abs y : ℂ), abs_mul_exp_arg_mul_I, mul_comm y, ←
mul_assoc, abs_mul_exp_arg_mul_I]
theorem arg_div_coe_angle {x y : ℂ} (hx : x ≠ 0) (hy : y ≠ 0) :
(arg (x / y) : Real.Angle) = arg x - arg y := by
rw [div_eq_mul_inv, arg_mul_coe_angle hx (inv_ne_zero hy), arg_inv_coe_angle, sub_eq_add_neg]
@[simp]
theorem arg_coe_angle_toReal_eq_arg (z : ℂ) : (arg z : Real.Angle).toReal = arg z := by
rw [Real.Angle.toReal_coe_eq_self_iff_mem_Ioc]
exact arg_mem_Ioc _
theorem arg_coe_angle_eq_iff_eq_toReal {z : ℂ} {θ : Real.Angle} :
(arg z : Real.Angle) = θ ↔ arg z = θ.toReal := by
rw [← Real.Angle.toReal_inj, arg_coe_angle_toReal_eq_arg]
@[simp]
theorem arg_coe_angle_eq_iff {x y : ℂ} : (arg x : Real.Angle) = arg y ↔ arg x = arg y := by
simp_rw [← Real.Angle.toReal_inj, arg_coe_angle_toReal_eq_arg]
lemma arg_mul_eq_add_arg_iff {x y : ℂ} (hx₀ : x ≠ 0) (hy₀ : y ≠ 0) :
(x * y).arg = x.arg + y.arg ↔ arg x + arg y ∈ Set.Ioc (-π) π := by
rw [← arg_coe_angle_toReal_eq_arg, arg_mul_coe_angle hx₀ hy₀, ← Real.Angle.coe_add,
Real.Angle.toReal_coe_eq_self_iff_mem_Ioc]
alias ⟨_, arg_mul⟩ := arg_mul_eq_add_arg_iff
section slitPlane
open ComplexOrder in
/-- An alternative description of the slit plane as consisting of nonzero complex numbers
whose argument is not π. -/
lemma mem_slitPlane_iff_arg {z : ℂ} : z ∈ slitPlane ↔ z.arg ≠ π ∧ z ≠ 0 := by
simp only [mem_slitPlane_iff_not_le_zero, le_iff_lt_or_eq, ne_eq, arg_eq_pi_iff_lt_zero, not_or]
lemma slitPlane_arg_ne_pi {z : ℂ} (hz : z ∈ slitPlane) : z.arg ≠ Real.pi :=
(mem_slitPlane_iff_arg.mp hz).1
end slitPlane
section Continuity
theorem arg_eq_nhds_of_re_pos (hx : 0 < x.re) : arg =ᶠ[𝓝 x] fun x => Real.arcsin (x.im / abs x) :=
((continuous_re.tendsto _).eventually (lt_mem_nhds hx)).mono fun _ hy => arg_of_re_nonneg hy.le
theorem arg_eq_nhds_of_re_neg_of_im_pos (hx_re : x.re < 0) (hx_im : 0 < x.im) :
arg =ᶠ[𝓝 x] fun x => Real.arcsin ((-x).im / abs x) + π := by
suffices h_forall_nhds : ∀ᶠ y : ℂ in 𝓝 x, y.re < 0 ∧ 0 < y.im from
h_forall_nhds.mono fun y hy => arg_of_re_neg_of_im_nonneg hy.1 hy.2.le
refine IsOpen.eventually_mem ?_ (⟨hx_re, hx_im⟩ : x.re < 0 ∧ 0 < x.im)
exact
IsOpen.and (isOpen_lt continuous_re continuous_zero) (isOpen_lt continuous_zero continuous_im)
theorem arg_eq_nhds_of_re_neg_of_im_neg (hx_re : x.re < 0) (hx_im : x.im < 0) :
arg =ᶠ[𝓝 x] fun x => Real.arcsin ((-x).im / abs x) - π := by
suffices h_forall_nhds : ∀ᶠ y : ℂ in 𝓝 x, y.re < 0 ∧ y.im < 0 from
h_forall_nhds.mono fun y hy => arg_of_re_neg_of_im_neg hy.1 hy.2
refine IsOpen.eventually_mem ?_ (⟨hx_re, hx_im⟩ : x.re < 0 ∧ x.im < 0)
exact
IsOpen.and (isOpen_lt continuous_re continuous_zero) (isOpen_lt continuous_im continuous_zero)
theorem arg_eq_nhds_of_im_pos (hz : 0 < im z) : arg =ᶠ[𝓝 z] fun x => Real.arccos (x.re / abs x) :=
((continuous_im.tendsto _).eventually (lt_mem_nhds hz)).mono fun _ => arg_of_im_pos
theorem arg_eq_nhds_of_im_neg (hz : im z < 0) : arg =ᶠ[𝓝 z] fun x => -Real.arccos (x.re / abs x) :=
((continuous_im.tendsto _).eventually (gt_mem_nhds hz)).mono fun _ => arg_of_im_neg
theorem continuousAt_arg (h : x ∈ slitPlane) : ContinuousAt arg x := by
have h₀ : abs x ≠ 0 := by
rw [abs.ne_zero_iff]
exact slitPlane_ne_zero h
rw [mem_slitPlane_iff, ← lt_or_lt_iff_ne] at h
rcases h with (hx_re | hx_im | hx_im)
exacts [(Real.continuousAt_arcsin.comp
(continuous_im.continuousAt.div continuous_abs.continuousAt h₀)).congr
(arg_eq_nhds_of_re_pos hx_re).symm,
(Real.continuous_arccos.continuousAt.comp
(continuous_re.continuousAt.div continuous_abs.continuousAt h₀)).neg.congr
(arg_eq_nhds_of_im_neg hx_im).symm,
(Real.continuous_arccos.continuousAt.comp
(continuous_re.continuousAt.div continuous_abs.continuousAt h₀)).congr
(arg_eq_nhds_of_im_pos hx_im).symm]
theorem tendsto_arg_nhdsWithin_im_neg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0)
(him : z.im = 0) : Tendsto arg (𝓝[{ z : ℂ | z.im < 0 }] z) (𝓝 (-π)) := by
suffices H : Tendsto (fun x : ℂ => Real.arcsin ((-x).im / abs x) - π)
(𝓝[{ z : ℂ | z.im < 0 }] z) (𝓝 (-π)) by
refine H.congr' ?_
have : ∀ᶠ x : ℂ in 𝓝 z, x.re < 0 := continuous_re.tendsto z (gt_mem_nhds hre)
filter_upwards [self_mem_nhdsWithin, mem_nhdsWithin_of_mem_nhds this] with _ him hre
rw [arg, if_neg hre.not_le, if_neg him.not_le]
convert (Real.continuousAt_arcsin.comp_continuousWithinAt
((continuous_im.continuousAt.comp_continuousWithinAt continuousWithinAt_neg).div
continuous_abs.continuousWithinAt _)
).sub_const π using 1
· simp [him]
· lift z to ℝ using him
simpa using hre.ne
theorem continuousWithinAt_arg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0) (him : z.im = 0) :
ContinuousWithinAt arg { z : ℂ | 0 ≤ z.im } z := by
have : arg =ᶠ[𝓝[{ z : ℂ | 0 ≤ z.im }] z] fun x => Real.arcsin ((-x).im / abs x) + π := by
have : ∀ᶠ x : ℂ in 𝓝 z, x.re < 0 := continuous_re.tendsto z (gt_mem_nhds hre)
filter_upwards [self_mem_nhdsWithin (s := { z : ℂ | 0 ≤ z.im }),
mem_nhdsWithin_of_mem_nhds this] with _ him hre
rw [arg, if_neg hre.not_le, if_pos him]
refine ContinuousWithinAt.congr_of_eventuallyEq ?_ this ?_
· refine
(Real.continuousAt_arcsin.comp_continuousWithinAt
((continuous_im.continuousAt.comp_continuousWithinAt continuousWithinAt_neg).div
continuous_abs.continuousWithinAt ?_)).add
tendsto_const_nhds
lift z to ℝ using him
simpa using hre.ne
· rw [arg, if_neg hre.not_le, if_pos him.ge]
theorem tendsto_arg_nhdsWithin_im_nonneg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0)
(him : z.im = 0) : Tendsto arg (𝓝[{ z : ℂ | 0 ≤ z.im }] z) (𝓝 π) := by
simpa only [arg_eq_pi_iff.2 ⟨hre, him⟩] using
(continuousWithinAt_arg_of_re_neg_of_im_zero hre him).tendsto
theorem continuousAt_arg_coe_angle (h : x ≠ 0) : ContinuousAt ((↑) ∘ arg : ℂ → Real.Angle) x := by
by_cases hs : x ∈ slitPlane
· exact Real.Angle.continuous_coe.continuousAt.comp (continuousAt_arg hs)
· rw [← Function.comp_id (((↑) : ℝ → Real.Angle) ∘ arg),
(Function.funext_iff.2 fun _ => (neg_neg _).symm : (id : ℂ → ℂ) = Neg.neg ∘ Neg.neg), ←
Function.comp.assoc]
refine ContinuousAt.comp ?_ continuous_neg.continuousAt
suffices ContinuousAt (Function.update (((↑) ∘ arg) ∘ Neg.neg : ℂ → Real.Angle) 0 π) (-x) by
rwa [continuousAt_update_of_ne (neg_ne_zero.2 h)] at this
have ha :
Function.update (((↑) ∘ arg) ∘ Neg.neg : ℂ → Real.Angle) 0 π = fun z =>
(arg z : Real.Angle) + π := by
rw [Function.update_eq_iff]
exact ⟨by simp, fun z hz => arg_neg_coe_angle hz⟩
rw [ha]
replace hs := mem_slitPlane_iff.mpr.mt hs
push_neg at hs
refine
(Real.Angle.continuous_coe.continuousAt.comp (continuousAt_arg (Or.inl ?_))).add
continuousAt_const
rw [neg_re, neg_pos]
exact hs.1.lt_of_ne fun h0 => h (Complex.ext_iff.2 ⟨h0, hs.2⟩)
end Continuity
end Complex
|
Analysis\SpecialFunctions\Complex\Circle.lean | /-
Copyright (c) 2021 Yury G. Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury G. Kudryashov
-/
import Mathlib.Analysis.Complex.Circle
import Mathlib.Analysis.SpecialFunctions.Complex.Log
/-!
# Maps on the unit circle
In this file we prove some basic lemmas about `expMapCircle` and the restriction of `Complex.arg`
to the unit circle. These two maps define a partial equivalence between `circle` and `ℝ`, see
`circle.argPartialEquiv` and `circle.argEquiv`, that sends the whole circle to `(-π, π]`.
-/
open Complex Function Set
open Real
namespace circle
theorem injective_arg : Injective fun z : circle => arg z := fun z w h =>
Subtype.ext <| ext_abs_arg ((abs_coe_circle z).trans (abs_coe_circle w).symm) h
@[simp]
theorem arg_eq_arg {z w : circle} : arg z = arg w ↔ z = w :=
injective_arg.eq_iff
end circle
theorem arg_expMapCircle {x : ℝ} (h₁ : -π < x) (h₂ : x ≤ π) : arg (expMapCircle x) = x := by
rw [expMapCircle_apply, exp_mul_I, arg_cos_add_sin_mul_I ⟨h₁, h₂⟩]
@[simp]
theorem expMapCircle_arg (z : circle) : expMapCircle (arg z) = z :=
circle.injective_arg <| arg_expMapCircle (neg_pi_lt_arg _) (arg_le_pi _)
namespace circle
/-- `Complex.arg ∘ (↑)` and `expMapCircle` define a partial equivalence between `circle` and `ℝ`
with `source = Set.univ` and `target = Set.Ioc (-π) π`. -/
@[simps (config := .asFn)]
noncomputable def argPartialEquiv : PartialEquiv circle ℝ where
toFun := arg ∘ (↑)
invFun := expMapCircle
source := univ
target := Ioc (-π) π
map_source' _ _ := ⟨neg_pi_lt_arg _, arg_le_pi _⟩
map_target' := mapsTo_univ _ _
left_inv' z _ := expMapCircle_arg z
right_inv' _ hx := arg_expMapCircle hx.1 hx.2
/-- `Complex.arg` and `expMapCircle` define an equivalence between `circle` and `(-π, π]`. -/
@[simps (config := .asFn)]
noncomputable def argEquiv : circle ≃ Ioc (-π) π where
toFun z := ⟨arg z, neg_pi_lt_arg _, arg_le_pi _⟩
invFun := expMapCircle ∘ (↑)
left_inv _ := argPartialEquiv.left_inv trivial
right_inv x := Subtype.ext <| argPartialEquiv.right_inv x.2
end circle
theorem leftInverse_expMapCircle_arg : LeftInverse expMapCircle (arg ∘ (↑)) :=
expMapCircle_arg
theorem invOn_arg_expMapCircle : InvOn (arg ∘ (↑)) expMapCircle (Ioc (-π) π) univ :=
circle.argPartialEquiv.symm.invOn
theorem surjOn_expMapCircle_neg_pi_pi : SurjOn expMapCircle (Ioc (-π) π) univ :=
circle.argPartialEquiv.symm.surjOn
theorem expMapCircle_eq_expMapCircle {x y : ℝ} :
expMapCircle x = expMapCircle y ↔ ∃ m : ℤ, x = y + m * (2 * π) := by
rw [Subtype.ext_iff, expMapCircle_apply, expMapCircle_apply, exp_eq_exp_iff_exists_int]
refine exists_congr fun n => ?_
rw [← mul_assoc, ← add_mul, mul_left_inj' I_ne_zero]
norm_cast
theorem periodic_expMapCircle : Periodic expMapCircle (2 * π) := fun z =>
expMapCircle_eq_expMapCircle.2 ⟨1, by rw [Int.cast_one, one_mul]⟩
@[simp]
theorem expMapCircle_two_pi : expMapCircle (2 * π) = 1 :=
periodic_expMapCircle.eq.trans expMapCircle_zero
theorem expMapCircle_sub_two_pi (x : ℝ) : expMapCircle (x - 2 * π) = expMapCircle x :=
periodic_expMapCircle.sub_eq x
theorem expMapCircle_add_two_pi (x : ℝ) : expMapCircle (x + 2 * π) = expMapCircle x :=
periodic_expMapCircle x
/-- `expMapCircle`, applied to a `Real.Angle`. -/
noncomputable def Real.Angle.expMapCircle (θ : Real.Angle) : circle :=
periodic_expMapCircle.lift θ
@[simp]
theorem Real.Angle.expMapCircle_coe (x : ℝ) : Real.Angle.expMapCircle x = _root_.expMapCircle x :=
rfl
theorem Real.Angle.coe_expMapCircle (θ : Real.Angle) :
(θ.expMapCircle : ℂ) = θ.cos + θ.sin * I := by
induction θ using Real.Angle.induction_on
simp [exp_mul_I]
@[simp]
theorem Real.Angle.expMapCircle_zero : Real.Angle.expMapCircle 0 = 1 := by
rw [← Real.Angle.coe_zero, Real.Angle.expMapCircle_coe, _root_.expMapCircle_zero]
@[simp]
theorem Real.Angle.expMapCircle_neg (θ : Real.Angle) :
Real.Angle.expMapCircle (-θ) = (Real.Angle.expMapCircle θ)⁻¹ := by
induction θ using Real.Angle.induction_on
simp_rw [← Real.Angle.coe_neg, Real.Angle.expMapCircle_coe, _root_.expMapCircle_neg]
@[simp]
theorem Real.Angle.expMapCircle_add (θ₁ θ₂ : Real.Angle) : Real.Angle.expMapCircle (θ₁ + θ₂) =
Real.Angle.expMapCircle θ₁ * Real.Angle.expMapCircle θ₂ := by
induction θ₁ using Real.Angle.induction_on
induction θ₂ using Real.Angle.induction_on
exact _root_.expMapCircle_add _ _
@[simp]
theorem Real.Angle.arg_expMapCircle (θ : Real.Angle) :
(arg (Real.Angle.expMapCircle θ) : Real.Angle) = θ := by
induction θ using Real.Angle.induction_on
rw [Real.Angle.expMapCircle_coe, expMapCircle_apply, exp_mul_I, ← ofReal_cos, ← ofReal_sin, ←
Real.Angle.cos_coe, ← Real.Angle.sin_coe, arg_cos_add_sin_mul_I_coe_angle]
namespace AddCircle
variable {T : ℝ}
/-! ### Map from `AddCircle` to `Circle` -/
theorem scaled_exp_map_periodic : Function.Periodic (fun x => expMapCircle (2 * π / T * x)) T := by
-- The case T = 0 is not interesting, but it is true, so we prove it to save hypotheses
rcases eq_or_ne T 0 with (rfl | hT)
· intro x; simp
· intro x; simp_rw [mul_add]; rw [div_mul_cancel₀ _ hT, periodic_expMapCircle]
/-- The canonical map `fun x => exp (2 π i x / T)` from `ℝ / ℤ • T` to the unit circle in `ℂ`.
If `T = 0` we understand this as the constant function 1. -/
noncomputable def toCircle : AddCircle T → circle :=
(@scaled_exp_map_periodic T).lift
theorem toCircle_apply_mk (x : ℝ) : @toCircle T x = expMapCircle (2 * π / T * x) :=
rfl
theorem toCircle_add (x : AddCircle T) (y : AddCircle T) :
@toCircle T (x + y) = toCircle x * toCircle y := by
induction x using QuotientAddGroup.induction_on
induction y using QuotientAddGroup.induction_on
simp_rw [← coe_add, toCircle_apply_mk, mul_add, expMapCircle_add]
lemma toCircle_zero : toCircle (0 : AddCircle T) = 1 := by
rw [← QuotientAddGroup.mk_zero, toCircle_apply_mk, mul_zero, expMapCircle_zero]
theorem continuous_toCircle : Continuous (@toCircle T) :=
continuous_coinduced_dom.mpr (expMapCircle.continuous.comp <| continuous_const.mul continuous_id')
theorem injective_toCircle (hT : T ≠ 0) : Function.Injective (@toCircle T) := by
intro a b h
induction a using QuotientAddGroup.induction_on
induction b using QuotientAddGroup.induction_on
simp_rw [toCircle_apply_mk] at h
obtain ⟨m, hm⟩ := expMapCircle_eq_expMapCircle.mp h.symm
rw [QuotientAddGroup.eq]; simp_rw [AddSubgroup.mem_zmultiples_iff, zsmul_eq_mul]
use m
field_simp at hm
rw [← mul_right_inj' Real.two_pi_pos.ne']
linarith
/-- The homeomorphism between `AddCircle (2 * π)` and `circle`. -/
@[simps] noncomputable def homeomorphCircle' : AddCircle (2 * π) ≃ₜ circle where
toFun := Angle.expMapCircle
invFun := fun x ↦ arg x
left_inv := Angle.arg_expMapCircle
right_inv := expMapCircle_arg
continuous_toFun := continuous_coinduced_dom.mpr expMapCircle.continuous
continuous_invFun := by
rw [continuous_iff_continuousAt]
intro x
apply (continuousAt_arg_coe_angle (ne_zero_of_mem_circle x)).comp
continuousAt_subtype_val
theorem homeomorphCircle'_apply_mk (x : ℝ) : homeomorphCircle' x = expMapCircle x :=
rfl
/-- The homeomorphism between `AddCircle` and `circle`. -/
noncomputable def homeomorphCircle (hT : T ≠ 0) : AddCircle T ≃ₜ circle :=
(homeomorphAddCircle T (2 * π) hT (by positivity)).trans homeomorphCircle'
theorem homeomorphCircle_apply (hT : T ≠ 0) (x : AddCircle T) :
homeomorphCircle hT x = toCircle x := by
induction' x using QuotientAddGroup.induction_on with x
rw [homeomorphCircle, Homeomorph.trans_apply,
homeomorphAddCircle_apply_mk, homeomorphCircle'_apply_mk, toCircle_apply_mk]
ring_nf
end AddCircle
open AddCircle
-- todo: upgrade this to `IsCoveringMap expMapCircle`.
lemma isLocalHomeomorph_expMapCircle : IsLocalHomeomorph expMapCircle := by
have : Fact (0 < 2 * π) := ⟨by positivity⟩
exact homeomorphCircle'.isLocalHomeomorph.comp (isLocalHomeomorph_coe (2 * π))
|
Analysis\SpecialFunctions\Complex\CircleAddChar.lean | /-
Copyright (c) 2024 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.SpecialFunctions.Complex.Circle
import Mathlib.NumberTheory.LegendreSymbol.AddCharacter
/-!
# Additive characters valued in the unit circle
This file defines additive characters, valued in the unit circle, from either
* the ring `ZMod N` for any non-zero natural `N`,
* the additive circle `ℝ / T ⬝ ℤ`, for any real `T`.
These results are separate from `Analysis.SpecialFunctions.Complex.Circle` in order to reduce
the imports of that file.
-/
open Complex Function
open scoped Real
/-- The canonical map from the additive to the multiplicative circle, as an `AddChar`. -/
noncomputable def AddCircle.toCircle_addChar {T : ℝ} : AddChar (AddCircle T) circle where
toFun := toCircle
map_zero_eq_one' := toCircle_zero
map_add_eq_mul' := toCircle_add
open AddCircle
namespace ZMod
variable {N : ℕ} [NeZero N]
/-- The additive character from `ZMod N` to the unit circle in `ℂ`, sending `j mod N` to
`exp (2 * π * I * j / N)`. -/
noncomputable def toCircle : AddChar (ZMod N) circle :=
toCircle_addChar.compAddMonoidHom toAddCircle
lemma toCircle_intCast (j : ℤ) :
toCircle (j : ZMod N) = exp (2 * π * I * j / N) := by
rw [toCircle, AddChar.compAddMonoidHom_apply, toCircle_addChar, AddChar.coe_mk,
AddCircle.toCircle, toAddCircle_intCast, Function.Periodic.lift_coe, expMapCircle_apply]
push_cast
ring_nf
lemma toCircle_natCast (j : ℕ) :
toCircle (j : ZMod N) = exp (2 * π * I * j / N) := by
simpa using toCircle_intCast (N := N) j
/--
Explicit formula for `toCircle j`. Note that this is "evil" because it uses `ZMod.val`. Where
possible, it is recommended to lift `j` to `ℤ` and use `toCircle_intCast` instead.
-/
lemma toCircle_apply (j : ZMod N) :
toCircle j = exp (2 * π * I * j.val / N) := by
rw [← toCircle_natCast, natCast_zmod_val]
lemma injective_toCircle : Injective (toCircle : ZMod N → circle) :=
(AddCircle.injective_toCircle one_ne_zero).comp (toAddCircle_injective N)
/-- The additive character from `ZMod N` to `ℂ`, sending `j mod N` to `exp (2 * π * I * j / N)`. -/
noncomputable def stdAddChar : AddChar (ZMod N) ℂ := circle.subtype.compAddChar toCircle
lemma stdAddChar_coe (j : ℤ) :
stdAddChar (j : ZMod N) = exp (2 * π * I * j / N) := by
simp only [stdAddChar, MonoidHom.coe_compAddChar, Function.comp_apply,
Submonoid.coe_subtype, toCircle_intCast]
lemma stdAddChar_apply (j : ZMod N) : stdAddChar j = ↑(toCircle j) := rfl
lemma injective_stdAddChar : Injective (stdAddChar : AddChar (ZMod N) ℂ) :=
Subtype.coe_injective.comp injective_toCircle
/-- The standard additive character `ZMod N → ℂ` is primitive. -/
lemma isPrimitive_stdAddChar (N : ℕ) [NeZero N] :
(stdAddChar (N := N)).IsPrimitive := by
refine AddChar.zmod_char_primitive_of_eq_one_only_at_zero _ _ (fun t ht ↦ ?_)
rwa [← (stdAddChar (N := N)).map_zero_eq_one, injective_stdAddChar.eq_iff] at ht
end ZMod
|
Analysis\SpecialFunctions\Complex\Log.lean | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson
-/
import Mathlib.Analysis.SpecialFunctions.Complex.Arg
import Mathlib.Analysis.SpecialFunctions.Log.Basic
/-!
# The complex `log` function
Basic properties, relationship with `exp`.
-/
noncomputable section
namespace Complex
open Set Filter Bornology
open scoped Real Topology ComplexConjugate
/-- Inverse of the `exp` function. Returns values such that `(log x).im > - π` and `(log x).im ≤ π`.
`log 0 = 0`-/
@[pp_nodot]
noncomputable def log (x : ℂ) : ℂ :=
x.abs.log + arg x * I
theorem log_re (x : ℂ) : x.log.re = x.abs.log := by simp [log]
theorem log_im (x : ℂ) : x.log.im = x.arg := by simp [log]
theorem neg_pi_lt_log_im (x : ℂ) : -π < (log x).im := by simp only [log_im, neg_pi_lt_arg]
theorem log_im_le_pi (x : ℂ) : (log x).im ≤ π := by simp only [log_im, arg_le_pi]
theorem exp_log {x : ℂ} (hx : x ≠ 0) : exp (log x) = x := by
rw [log, exp_add_mul_I, ← ofReal_sin, sin_arg, ← ofReal_cos, cos_arg hx, ← ofReal_exp,
Real.exp_log (abs.pos hx), mul_add, ofReal_div, ofReal_div,
mul_div_cancel₀ _ (ofReal_ne_zero.2 <| abs.ne_zero hx), ← mul_assoc,
mul_div_cancel₀ _ (ofReal_ne_zero.2 <| abs.ne_zero hx), re_add_im]
@[simp]
theorem range_exp : Set.range exp = {0}ᶜ :=
Set.ext fun x =>
⟨by
rintro ⟨x, rfl⟩
exact exp_ne_zero x, fun hx => ⟨log x, exp_log hx⟩⟩
theorem log_exp {x : ℂ} (hx₁ : -π < x.im) (hx₂ : x.im ≤ π) : log (exp x) = x := by
rw [log, abs_exp, Real.log_exp, exp_eq_exp_re_mul_sin_add_cos, ← ofReal_exp,
arg_mul_cos_add_sin_mul_I (Real.exp_pos _) ⟨hx₁, hx₂⟩, re_add_im]
theorem exp_inj_of_neg_pi_lt_of_le_pi {x y : ℂ} (hx₁ : -π < x.im) (hx₂ : x.im ≤ π) (hy₁ : -π < y.im)
(hy₂ : y.im ≤ π) (hxy : exp x = exp y) : x = y := by
rw [← log_exp hx₁ hx₂, ← log_exp hy₁ hy₂, hxy]
theorem ofReal_log {x : ℝ} (hx : 0 ≤ x) : (x.log : ℂ) = log x :=
Complex.ext (by rw [log_re, ofReal_re, abs_of_nonneg hx])
(by rw [ofReal_im, log_im, arg_ofReal_of_nonneg hx])
@[simp, norm_cast]
lemma natCast_log {n : ℕ} : Real.log n = log n := ofReal_natCast n ▸ ofReal_log n.cast_nonneg
@[simp]
lemma ofNat_log {n : ℕ} [n.AtLeastTwo] :
Real.log (no_index (OfNat.ofNat n)) = log (OfNat.ofNat n) :=
natCast_log
theorem log_ofReal_re (x : ℝ) : (log (x : ℂ)).re = Real.log x := by simp [log_re]
theorem log_ofReal_mul {r : ℝ} (hr : 0 < r) {x : ℂ} (hx : x ≠ 0) :
log (r * x) = Real.log r + log x := by
replace hx := Complex.abs.ne_zero_iff.mpr hx
simp_rw [log, map_mul, abs_ofReal, arg_real_mul _ hr, abs_of_pos hr, Real.log_mul hr.ne' hx,
ofReal_add, add_assoc]
theorem log_mul_ofReal (r : ℝ) (hr : 0 < r) (x : ℂ) (hx : x ≠ 0) :
log (x * r) = Real.log r + log x := by rw [mul_comm, log_ofReal_mul hr hx]
lemma log_mul_eq_add_log_iff {x y : ℂ} (hx₀ : x ≠ 0) (hy₀ : y ≠ 0) :
log (x * y) = log x + log y ↔ arg x + arg y ∈ Set.Ioc (-π) π := by
refine Complex.ext_iff.trans <| Iff.trans ?_ <| arg_mul_eq_add_arg_iff hx₀ hy₀
simp_rw [add_re, add_im, log_re, log_im, AbsoluteValue.map_mul,
Real.log_mul (abs.ne_zero hx₀) (abs.ne_zero hy₀), true_and]
alias ⟨_, log_mul⟩ := log_mul_eq_add_log_iff
@[simp]
theorem log_zero : log 0 = 0 := by simp [log]
@[simp]
theorem log_one : log 1 = 0 := by simp [log]
theorem log_neg_one : log (-1) = π * I := by simp [log]
theorem log_I : log I = π / 2 * I := by simp [log]
theorem log_neg_I : log (-I) = -(π / 2) * I := by simp [log]
theorem log_conj_eq_ite (x : ℂ) : log (conj x) = if x.arg = π then log x else conj (log x) := by
simp_rw [log, abs_conj, arg_conj, map_add, map_mul, conj_ofReal]
split_ifs with hx
· rw [hx]
simp_rw [ofReal_neg, conj_I, mul_neg, neg_mul]
theorem log_conj (x : ℂ) (h : x.arg ≠ π) : log (conj x) = conj (log x) := by
rw [log_conj_eq_ite, if_neg h]
theorem log_inv_eq_ite (x : ℂ) : log x⁻¹ = if x.arg = π then -conj (log x) else -log x := by
by_cases hx : x = 0
· simp [hx]
rw [inv_def, log_mul_ofReal, Real.log_inv, ofReal_neg, ← sub_eq_neg_add, log_conj_eq_ite]
· simp_rw [log, map_add, map_mul, conj_ofReal, conj_I, normSq_eq_abs, Real.log_pow,
Nat.cast_two, ofReal_mul, neg_add, mul_neg, neg_neg]
norm_num; rw [two_mul] -- Porting note: added to simplify `↑2`
split_ifs
· rw [add_sub_right_comm, sub_add_cancel_left]
· rw [add_sub_right_comm, sub_add_cancel_left]
· rwa [inv_pos, Complex.normSq_pos]
· rwa [map_ne_zero]
theorem log_inv (x : ℂ) (hx : x.arg ≠ π) : log x⁻¹ = -log x := by rw [log_inv_eq_ite, if_neg hx]
theorem two_pi_I_ne_zero : (2 * π * I : ℂ) ≠ 0 := by norm_num [Real.pi_ne_zero, I_ne_zero]
theorem exp_eq_one_iff {x : ℂ} : exp x = 1 ↔ ∃ n : ℤ, x = n * (2 * π * I) := by
constructor
· intro h
rcases existsUnique_add_zsmul_mem_Ioc Real.two_pi_pos x.im (-π) with ⟨n, hn, -⟩
use -n
rw [Int.cast_neg, neg_mul, eq_neg_iff_add_eq_zero]
have : (x + n * (2 * π * I)).im ∈ Set.Ioc (-π) π := by simpa [two_mul, mul_add] using hn
rw [← log_exp this.1 this.2, exp_periodic.int_mul n, h, log_one]
· rintro ⟨n, rfl⟩
exact (exp_periodic.int_mul n).eq.trans exp_zero
theorem exp_eq_exp_iff_exp_sub_eq_one {x y : ℂ} : exp x = exp y ↔ exp (x - y) = 1 := by
rw [exp_sub, div_eq_one_iff_eq (exp_ne_zero _)]
theorem exp_eq_exp_iff_exists_int {x y : ℂ} : exp x = exp y ↔ ∃ n : ℤ, x = y + n * (2 * π * I) := by
simp only [exp_eq_exp_iff_exp_sub_eq_one, exp_eq_one_iff, sub_eq_iff_eq_add']
@[simp]
theorem countable_preimage_exp {s : Set ℂ} : (exp ⁻¹' s).Countable ↔ s.Countable := by
refine ⟨fun hs => ?_, fun hs => ?_⟩
· refine ((hs.image exp).insert 0).mono ?_
rw [Set.image_preimage_eq_inter_range, range_exp, ← Set.diff_eq, ← Set.union_singleton,
Set.diff_union_self]
exact Set.subset_union_left
· rw [← Set.biUnion_preimage_singleton]
refine hs.biUnion fun z hz => ?_
rcases em (∃ w, exp w = z) with (⟨w, rfl⟩ | hne)
· simp only [Set.preimage, Set.mem_singleton_iff, exp_eq_exp_iff_exists_int, Set.setOf_exists]
exact Set.countable_iUnion fun m => Set.countable_singleton _
· push_neg at hne
simp [Set.preimage, hne]
alias ⟨_, _root_.Set.Countable.preimage_cexp⟩ := countable_preimage_exp
theorem tendsto_log_nhdsWithin_im_neg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0)
(him : z.im = 0) : Tendsto log (𝓝[{ z : ℂ | z.im < 0 }] z) (𝓝 <| Real.log (abs z) - π * I) := by
convert
(continuous_ofReal.continuousAt.comp_continuousWithinAt
(continuous_abs.continuousWithinAt.log _)).tendsto.add
(((continuous_ofReal.tendsto _).comp <|
tendsto_arg_nhdsWithin_im_neg_of_re_neg_of_im_zero hre him).mul
tendsto_const_nhds) using 1
· simp [sub_eq_add_neg]
· lift z to ℝ using him
simpa using hre.ne
theorem continuousWithinAt_log_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0) (him : z.im = 0) :
ContinuousWithinAt log { z : ℂ | 0 ≤ z.im } z := by
convert
(continuous_ofReal.continuousAt.comp_continuousWithinAt
(continuous_abs.continuousWithinAt.log _)).tendsto.add
((continuous_ofReal.continuousAt.comp_continuousWithinAt <|
continuousWithinAt_arg_of_re_neg_of_im_zero hre him).mul
tendsto_const_nhds) using 1
lift z to ℝ using him
simpa using hre.ne
theorem tendsto_log_nhdsWithin_im_nonneg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0)
(him : z.im = 0) : Tendsto log (𝓝[{ z : ℂ | 0 ≤ z.im }] z) (𝓝 <| Real.log (abs z) + π * I) := by
simpa only [log, arg_eq_pi_iff.2 ⟨hre, him⟩] using
(continuousWithinAt_log_of_re_neg_of_im_zero hre him).tendsto
@[simp]
theorem map_exp_comap_re_atBot : map exp (comap re atBot) = 𝓝[≠] 0 := by
rw [← comap_exp_nhds_zero, map_comap, range_exp, nhdsWithin]
@[simp]
theorem map_exp_comap_re_atTop : map exp (comap re atTop) = cobounded ℂ := by
rw [← comap_exp_cobounded, map_comap, range_exp, inf_eq_left, le_principal_iff]
exact eventually_ne_cobounded _
end Complex
section LogDeriv
open Complex Filter
open Topology
variable {α : Type*}
theorem continuousAt_clog {x : ℂ} (h : x ∈ slitPlane) : ContinuousAt log x := by
refine ContinuousAt.add ?_ ?_
· refine continuous_ofReal.continuousAt.comp ?_
refine (Real.continuousAt_log ?_).comp Complex.continuous_abs.continuousAt
exact Complex.abs.ne_zero_iff.mpr <| slitPlane_ne_zero h
· have h_cont_mul : Continuous fun x : ℂ => x * I := continuous_id'.mul continuous_const
refine h_cont_mul.continuousAt.comp (continuous_ofReal.continuousAt.comp ?_)
exact continuousAt_arg h
theorem _root_.Filter.Tendsto.clog {l : Filter α} {f : α → ℂ} {x : ℂ} (h : Tendsto f l (𝓝 x))
(hx : x ∈ slitPlane) : Tendsto (fun t => log (f t)) l (𝓝 <| log x) :=
(continuousAt_clog hx).tendsto.comp h
variable [TopologicalSpace α]
nonrec
theorem _root_.ContinuousAt.clog {f : α → ℂ} {x : α} (h₁ : ContinuousAt f x)
(h₂ : f x ∈ slitPlane) : ContinuousAt (fun t => log (f t)) x :=
h₁.clog h₂
nonrec
theorem _root_.ContinuousWithinAt.clog {f : α → ℂ} {s : Set α} {x : α}
(h₁ : ContinuousWithinAt f s x) (h₂ : f x ∈ slitPlane) :
ContinuousWithinAt (fun t => log (f t)) s x :=
h₁.clog h₂
nonrec
theorem _root_.ContinuousOn.clog {f : α → ℂ} {s : Set α} (h₁ : ContinuousOn f s)
(h₂ : ∀ x ∈ s, f x ∈ slitPlane) : ContinuousOn (fun t => log (f t)) s := fun x hx =>
(h₁ x hx).clog (h₂ x hx)
nonrec
theorem _root_.Continuous.clog {f : α → ℂ} (h₁ : Continuous f)
(h₂ : ∀ x, f x ∈ slitPlane) : Continuous fun t => log (f t) :=
continuous_iff_continuousAt.2 fun x => h₁.continuousAt.clog (h₂ x)
end LogDeriv
|
Analysis\SpecialFunctions\Complex\LogBounds.lean | /-
Copyright (c) 2023 Michael Stoll. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Michael Stoll
-/
import Mathlib.Analysis.Complex.Convex
import Mathlib.Analysis.SpecialFunctions.Integrals
import Mathlib.Analysis.Calculus.Deriv.Shift
/-!
# Estimates for the complex logarithm
We show that `log (1+z)` differs from its Taylor polynomial up to degree `n` by at most
`‖z‖^(n+1)/((n+1)*(1-‖z‖))` when `‖z‖ < 1`; see `Complex.norm_log_sub_logTaylor_le`.
To this end, we derive the representation of `log (1+z)` as the integral of `1/(1+tz)`
over the unit interval (`Complex.log_eq_integral`) and introduce notation
`Complex.logTaylor n` for the Taylor polynomial up to degree `n-1`.
## TODO
Refactor using general Taylor series theory, once this exists in Mathlib.
-/
namespace Complex
/-!
### Integral representation of the complex log
-/
lemma continuousOn_one_add_mul_inv {z : ℂ} (hz : 1 + z ∈ slitPlane) :
ContinuousOn (fun t : ℝ ↦ (1 + t • z)⁻¹) (Set.Icc 0 1) :=
ContinuousOn.inv₀ (by fun_prop)
(fun t ht ↦ slitPlane_ne_zero <| StarConvex.add_smul_mem starConvex_one_slitPlane hz ht.1 ht.2)
open intervalIntegral in
/-- Represent `log (1 + z)` as an integral over the unit interval -/
lemma log_eq_integral {z : ℂ} (hz : 1 + z ∈ slitPlane) :
log (1 + z) = z * ∫ (t : ℝ) in (0 : ℝ)..1, (1 + t • z)⁻¹ := by
convert (integral_unitInterval_deriv_eq_sub (continuousOn_one_add_mul_inv hz)
(fun _ ht ↦ hasDerivAt_log <|
StarConvex.add_smul_mem starConvex_one_slitPlane hz ht.1 ht.2)).symm using 1
simp only [log_one, sub_zero]
/-- Represent `log (1 - z)⁻¹` as an integral over the unit interval -/
lemma log_inv_eq_integral {z : ℂ} (hz : 1 - z ∈ slitPlane) :
log (1 - z)⁻¹ = z * ∫ (t : ℝ) in (0 : ℝ)..1, (1 - t • z)⁻¹ := by
rw [sub_eq_add_neg 1 z] at hz ⊢
rw [log_inv _ <| slitPlane_arg_ne_pi hz, neg_eq_iff_eq_neg, ← neg_mul]
convert log_eq_integral hz using 5
rw [sub_eq_add_neg, smul_neg]
/-!
### The Taylor polynomials of the logarithm
-/
/-- The `n`th Taylor polynomial of `log` at `1`, as a function `ℂ → ℂ` -/
noncomputable
def logTaylor (n : ℕ) : ℂ → ℂ := fun z ↦ ∑ j ∈ Finset.range n, (-1) ^ (j + 1) * z ^ j / j
lemma logTaylor_zero : logTaylor 0 = fun _ ↦ 0 := by
funext
simp only [logTaylor, Finset.range_zero, Nat.odd_iff_not_even, Int.cast_pow, Int.cast_neg,
Int.cast_one, Finset.sum_empty]
lemma logTaylor_succ (n : ℕ) :
logTaylor (n + 1) = logTaylor n + (fun z : ℂ ↦ (-1) ^ (n + 1) * z ^ n / n) := by
funext
simpa only [logTaylor] using Finset.sum_range_succ ..
lemma logTaylor_at_zero (n : ℕ) : logTaylor n 0 = 0 := by
induction n with
| zero => simp [logTaylor_zero]
| succ n ih => simpa [logTaylor_succ, ih] using ne_or_eq n 0
lemma hasDerivAt_logTaylor (n : ℕ) (z : ℂ) :
HasDerivAt (logTaylor (n + 1)) (∑ j ∈ Finset.range n, (-1) ^ j * z ^ j) z := by
induction n with
| zero => simp [logTaylor_succ, logTaylor_zero, Pi.add_def, hasDerivAt_const]
| succ n ih =>
rw [logTaylor_succ]
simp only [cpow_natCast, Nat.cast_add, Nat.cast_one, Nat.odd_iff_not_even,
Finset.sum_range_succ, (show (-1) ^ (n + 1 + 1) = (-1) ^ n by ring)]
refine HasDerivAt.add ih ?_
simp only [Nat.odd_iff_not_even, Int.cast_pow, Int.cast_neg, Int.cast_one, mul_div_assoc]
have : HasDerivAt (fun x : ℂ ↦ (x ^ (n + 1) / (n + 1))) (z ^ n) z := by
simp_rw [div_eq_mul_inv]
convert HasDerivAt.mul_const (hasDerivAt_pow (n + 1) z) (((n : ℂ) + 1)⁻¹) using 1
field_simp [Nat.cast_add_one_ne_zero n]
convert HasDerivAt.const_mul _ this using 2
ring
/-!
### Bounds for the difference between log and its Taylor polynomials
-/
lemma hasDerivAt_log_sub_logTaylor (n : ℕ) {z : ℂ} (hz : 1 + z ∈ slitPlane) :
HasDerivAt (fun z : ℂ ↦ log (1 + z) - logTaylor (n + 1) z) ((-z) ^ n * (1 + z)⁻¹) z := by
convert ((hasDerivAt_log hz).comp_const_add 1 z).sub (hasDerivAt_logTaylor n z) using 1
have hz' : -z ≠ 1 := by
intro H
rw [neg_eq_iff_eq_neg] at H
simp only [H, add_right_neg] at hz
exact slitPlane_ne_zero hz rfl
simp_rw [← mul_pow, neg_one_mul, geom_sum_eq hz', ← neg_add', div_neg, add_comm z]
field_simp [slitPlane_ne_zero hz]
/-- Give a bound on `‖(1 + t * z)⁻¹‖` for `0 ≤ t ≤ 1` and `‖z‖ < 1`. -/
lemma norm_one_add_mul_inv_le {t : ℝ} (ht : t ∈ Set.Icc 0 1) {z : ℂ} (hz : ‖z‖ < 1) :
‖(1 + t * z)⁻¹‖ ≤ (1 - ‖z‖)⁻¹ := by
rw [Set.mem_Icc] at ht
rw [norm_inv, norm_eq_abs]
refine inv_le_inv_of_le (by linarith) ?_
calc 1 - ‖z‖
_ ≤ 1 - t * ‖z‖ := by
nlinarith [norm_nonneg z]
_ = 1 - ‖t * z‖ := by
rw [norm_mul, norm_eq_abs (t : ℂ), abs_of_nonneg ht.1]
_ ≤ ‖1 + t * z‖ := by
rw [← norm_neg (t * z), ← sub_neg_eq_add]
convert norm_sub_norm_le 1 (-(t * z))
exact norm_one.symm
lemma integrable_pow_mul_norm_one_add_mul_inv (n : ℕ) {z : ℂ} (hz : ‖z‖ < 1) :
IntervalIntegrable (fun t : ℝ ↦ t ^ n * ‖(1 + t * z)⁻¹‖) MeasureTheory.volume 0 1 := by
have := continuousOn_one_add_mul_inv <| mem_slitPlane_of_norm_lt_one hz
rw [← Set.uIcc_of_le zero_le_one] at this
exact ContinuousOn.intervalIntegrable (by fun_prop)
open intervalIntegral in
/-- The difference of `log (1+z)` and its `(n+1)`st Taylor polynomial can be bounded in
terms of `‖z‖`. -/
lemma norm_log_sub_logTaylor_le (n : ℕ) {z : ℂ} (hz : ‖z‖ < 1) :
‖log (1 + z) - logTaylor (n + 1) z‖ ≤ ‖z‖ ^ (n + 1) * (1 - ‖z‖)⁻¹ / (n + 1) := by
have help : IntervalIntegrable (fun t : ℝ ↦ t ^ n * (1 - ‖z‖)⁻¹) MeasureTheory.volume 0 1 :=
IntervalIntegrable.mul_const (Continuous.intervalIntegrable (by fun_prop) 0 1) (1 - ‖z‖)⁻¹
let f (z : ℂ) : ℂ := log (1 + z) - logTaylor (n + 1) z
let f' (z : ℂ) : ℂ := (-z) ^ n * (1 + z)⁻¹
have hderiv : ∀ t ∈ Set.Icc (0 : ℝ) 1, HasDerivAt f (f' (0 + t * z)) (0 + t * z) := by
intro t ht
rw [zero_add]
exact hasDerivAt_log_sub_logTaylor n <|
StarConvex.add_smul_mem starConvex_one_slitPlane (mem_slitPlane_of_norm_lt_one hz) ht.1 ht.2
have hcont : ContinuousOn (fun t : ℝ ↦ f' (0 + t * z)) (Set.Icc 0 1) := by
simp only [zero_add, zero_le_one, not_true_eq_false]
exact (Continuous.continuousOn (by fun_prop)).mul <|
continuousOn_one_add_mul_inv <| mem_slitPlane_of_norm_lt_one hz
have H : f z = z * ∫ t in (0 : ℝ)..1, (-(t * z)) ^ n * (1 + t * z)⁻¹ := by
convert (integral_unitInterval_deriv_eq_sub hcont hderiv).symm using 1
· simp only [f, zero_add, add_zero, log_one, logTaylor_at_zero, sub_self, sub_zero]
· simp only [add_zero, log_one, logTaylor_at_zero, sub_self, real_smul, zero_add, smul_eq_mul]
unfold_let f at H
simp only [H, norm_mul]
simp_rw [neg_pow (_ * z) n, mul_assoc, intervalIntegral.integral_const_mul, mul_pow,
mul_comm _ (z ^ n), mul_assoc, intervalIntegral.integral_const_mul, norm_mul, norm_pow,
norm_neg, norm_one, one_pow, one_mul, ← mul_assoc, ← pow_succ', mul_div_assoc]
refine mul_le_mul_of_nonneg_left ?_ (pow_nonneg (norm_nonneg z) (n + 1))
calc ‖∫ t in (0 : ℝ)..1, (t : ℂ) ^ n * (1 + t * z)⁻¹‖
_ ≤ ∫ t in (0 : ℝ)..1, ‖(t : ℂ) ^ n * (1 + t * z)⁻¹‖ :=
intervalIntegral.norm_integral_le_integral_norm zero_le_one
_ = ∫ t in (0 : ℝ)..1, t ^ n * ‖(1 + t * z)⁻¹‖ := by
refine intervalIntegral.integral_congr <| fun t ht ↦ ?_
rw [Set.uIcc_of_le zero_le_one, Set.mem_Icc] at ht
simp_rw [norm_mul, norm_pow, norm_eq_abs, abs_of_nonneg ht.1]
_ ≤ ∫ t in (0 : ℝ)..1, t ^ n * (1 - ‖z‖)⁻¹ :=
intervalIntegral.integral_mono_on zero_le_one
(integrable_pow_mul_norm_one_add_mul_inv n hz) help <|
fun t ht ↦ mul_le_mul_of_nonneg_left (norm_one_add_mul_inv_le ht hz)
(pow_nonneg ((Set.mem_Icc.mp ht).1) _)
_ = (1 - ‖z‖)⁻¹ / (n + 1) := by
rw [intervalIntegral.integral_mul_const, mul_comm, integral_pow]
field_simp
/-- The difference `log (1+z) - z` is bounded by `‖z‖^2/(2*(1-‖z‖))` when `‖z‖ < 1`. -/
lemma norm_log_one_add_sub_self_le {z : ℂ} (hz : ‖z‖ < 1) :
‖log (1 + z) - z‖ ≤ ‖z‖ ^ 2 * (1 - ‖z‖)⁻¹ / 2 := by
convert norm_log_sub_logTaylor_le 1 hz using 2
· simp [logTaylor_succ, logTaylor_zero, sub_eq_add_neg]
· norm_num
/-- The difference of `log (1-z)⁻¹` and its `(n+1)`st Taylor polynomial can be bounded in
terms of `‖z‖`. -/
lemma norm_log_one_sub_inv_add_logTaylor_neg_le (n : ℕ) {z : ℂ} (hz : ‖z‖ < 1) :
‖log (1 - z)⁻¹ + logTaylor (n + 1) (-z)‖ ≤ ‖z‖ ^ (n + 1) * (1 - ‖z‖)⁻¹ / (n + 1) := by
rw [sub_eq_add_neg,
log_inv _ <| slitPlane_arg_ne_pi <| mem_slitPlane_of_norm_lt_one <| (norm_neg z).symm ▸ hz,
← sub_neg_eq_add, ← neg_sub', norm_neg]
convert norm_log_sub_logTaylor_le n <| (norm_neg z).symm ▸ hz using 4 <;> rw [norm_neg]
/-- The difference `log (1-z)⁻¹ - z` is bounded by `‖z‖^2/(2*(1-‖z‖))` when `‖z‖ < 1`. -/
lemma norm_log_one_sub_inv_sub_self_le {z : ℂ} (hz : ‖z‖ < 1) :
‖log (1 - z)⁻¹ - z‖ ≤ ‖z‖ ^ 2 * (1 - ‖z‖)⁻¹ / 2 := by
convert norm_log_one_sub_inv_add_logTaylor_neg_le 1 hz using 2
· simp [logTaylor_succ, logTaylor_zero, sub_eq_add_neg]
· norm_num
open Filter Asymptotics in
/-- The Taylor series of the complex logarithm at `1` converges to the logarithm in the
open unit disk. -/
lemma hasSum_taylorSeries_log {z : ℂ} (hz : ‖z‖ < 1) :
HasSum (fun n : ℕ ↦ (-1) ^ (n + 1) * z ^ n / n) (log (1 + z)) := by
refine (hasSum_iff_tendsto_nat_of_summable_norm ?_).mpr ?_
· refine (summable_geometric_of_norm_lt_one hz).norm.of_nonneg_of_le (fun _ ↦ norm_nonneg _) ?_
intro n
simp only [norm_div, norm_mul, norm_pow, norm_neg, norm_one, one_pow, one_mul, norm_nat]
rcases n.eq_zero_or_pos with rfl | hn
· simp
conv => enter [2]; rw [← div_one (‖z‖ ^ n)]
gcongr
norm_cast
· rw [← tendsto_sub_nhds_zero_iff]
conv => enter [1, x]; rw [← div_one (_ - _), ← logTaylor]
rw [← isLittleO_iff_tendsto fun _ h ↦ (one_ne_zero h).elim]
refine IsLittleO.trans_isBigO ?_ <| isBigO_const_one ℂ (1 : ℝ) atTop
have H : (fun n ↦ logTaylor n z - log (1 + z)) =O[atTop] (fun n : ℕ ↦ ‖z‖ ^ n) := by
have (n : ℕ) : ‖logTaylor n z - log (1 + z)‖
≤ (max ‖log (1 + z)‖ (1 - ‖z‖)⁻¹) * ‖(‖z‖ ^ n)‖ := by
rw [norm_sub_rev, norm_pow, norm_norm]
cases n with
| zero => simp [logTaylor_zero]
| succ n =>
refine (norm_log_sub_logTaylor_le n hz).trans ?_
rw [mul_comm, ← div_one ((max _ _) * _)]
gcongr
· exact le_max_right ..
· linarith
exact (isBigOWith_of_le' atTop this).isBigO
refine IsBigO.trans_isLittleO H ?_
convert isLittleO_pow_pow_of_lt_left (norm_nonneg z) hz
exact (one_pow _).symm
/-- The series `∑ z^n/n` converges to `-log (1-z)` on the open unit disk. -/
lemma hasSum_taylorSeries_neg_log {z : ℂ} (hz : ‖z‖ < 1) :
HasSum (fun n : ℕ ↦ z ^ n / n) (-log (1 - z)) := by
conv => enter [1, n]; rw [← neg_neg (z ^ n / n)]
refine HasSum.neg ?_
convert hasSum_taylorSeries_log (z := -z) (norm_neg z ▸ hz) using 2 with n
rcases n.eq_zero_or_pos with rfl | hn
· simp
field_simp
rw [div_eq_div_iff, pow_succ', mul_assoc (-1), ← mul_pow, neg_mul_neg, neg_one_mul, one_mul]
all_goals {norm_cast; exact hn.ne'}
end Complex
|
Analysis\SpecialFunctions\Complex\LogDeriv.lean | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson
-/
import Mathlib.Analysis.Calculus.InverseFunctionTheorem.Deriv
import Mathlib.Analysis.Calculus.LogDeriv
import Mathlib.Analysis.SpecialFunctions.Complex.Log
import Mathlib.Analysis.SpecialFunctions.ExpDeriv
/-!
# Differentiability of the complex `log` function
-/
open Set Filter
open scoped Real Topology
namespace Complex
theorem isOpenMap_exp : IsOpenMap exp :=
isOpenMap_of_hasStrictDerivAt hasStrictDerivAt_exp exp_ne_zero
/-- `Complex.exp` as a `PartialHomeomorph` with `source = {z | -π < im z < π}` and
`target = {z | 0 < re z} ∪ {z | im z ≠ 0}`. This definition is used to prove that `Complex.log`
is complex differentiable at all points but the negative real semi-axis. -/
noncomputable def expPartialHomeomorph : PartialHomeomorph ℂ ℂ :=
PartialHomeomorph.ofContinuousOpen
{ toFun := exp
invFun := log
source := {z : ℂ | z.im ∈ Ioo (-π) π}
target := slitPlane
map_source' := by
rintro ⟨x, y⟩ ⟨h₁ : -π < y, h₂ : y < π⟩
refine (not_or_of_imp fun hz => ?_).symm
obtain rfl : y = 0 := by
rw [exp_im] at hz
simpa [(Real.exp_pos _).ne', Real.sin_eq_zero_iff_of_lt_of_lt h₁ h₂] using hz
rw [← ofReal_def, exp_ofReal_re]
exact Real.exp_pos x
map_target' := fun z h => by
simp only [mem_setOf, log_im, mem_Ioo, neg_pi_lt_arg, arg_lt_pi_iff, true_and]
exact h.imp_left le_of_lt
left_inv' := fun x hx => log_exp hx.1 (le_of_lt hx.2)
right_inv' := fun x hx => exp_log <| slitPlane_ne_zero hx }
continuous_exp.continuousOn isOpenMap_exp (isOpen_Ioo.preimage continuous_im)
theorem hasStrictDerivAt_log {x : ℂ} (h : x ∈ slitPlane) : HasStrictDerivAt log x⁻¹ x :=
have h0 : x ≠ 0 := slitPlane_ne_zero h
expPartialHomeomorph.hasStrictDerivAt_symm h h0 <| by
simpa [exp_log h0] using hasStrictDerivAt_exp (log x)
lemma hasDerivAt_log {z : ℂ} (hz : z ∈ slitPlane) : HasDerivAt log z⁻¹ z :=
HasStrictDerivAt.hasDerivAt <| hasStrictDerivAt_log hz
lemma differentiableAt_log {z : ℂ} (hz : z ∈ slitPlane) : DifferentiableAt ℂ log z :=
(hasDerivAt_log hz).differentiableAt
theorem hasStrictFDerivAt_log_real {x : ℂ} (h : x ∈ slitPlane) :
HasStrictFDerivAt log (x⁻¹ • (1 : ℂ →L[ℝ] ℂ)) x :=
(hasStrictDerivAt_log h).complexToReal_fderiv
theorem contDiffAt_log {x : ℂ} (h : x ∈ slitPlane) {n : ℕ∞} : ContDiffAt ℂ n log x :=
expPartialHomeomorph.contDiffAt_symm_deriv (exp_ne_zero <| log x) h (hasDerivAt_exp _)
contDiff_exp.contDiffAt
end Complex
section LogDeriv
open Complex Filter
open scoped Topology
variable {α : Type*} [TopologicalSpace α] {E : Type*} [NormedAddCommGroup E] [NormedSpace ℂ E]
theorem HasStrictFDerivAt.clog {f : E → ℂ} {f' : E →L[ℂ] ℂ} {x : E} (h₁ : HasStrictFDerivAt f f' x)
(h₂ : f x ∈ slitPlane) : HasStrictFDerivAt (fun t => log (f t)) ((f x)⁻¹ • f') x :=
(hasStrictDerivAt_log h₂).comp_hasStrictFDerivAt x h₁
theorem HasStrictDerivAt.clog {f : ℂ → ℂ} {f' x : ℂ} (h₁ : HasStrictDerivAt f f' x)
(h₂ : f x ∈ slitPlane) : HasStrictDerivAt (fun t => log (f t)) (f' / f x) x := by
rw [div_eq_inv_mul]; exact (hasStrictDerivAt_log h₂).comp x h₁
theorem HasStrictDerivAt.clog_real {f : ℝ → ℂ} {x : ℝ} {f' : ℂ} (h₁ : HasStrictDerivAt f f' x)
(h₂ : f x ∈ slitPlane) : HasStrictDerivAt (fun t => log (f t)) (f' / f x) x := by
simpa only [div_eq_inv_mul] using (hasStrictFDerivAt_log_real h₂).comp_hasStrictDerivAt x h₁
theorem HasFDerivAt.clog {f : E → ℂ} {f' : E →L[ℂ] ℂ} {x : E} (h₁ : HasFDerivAt f f' x)
(h₂ : f x ∈ slitPlane) : HasFDerivAt (fun t => log (f t)) ((f x)⁻¹ • f') x :=
(hasStrictDerivAt_log h₂).hasDerivAt.comp_hasFDerivAt x h₁
theorem HasDerivAt.clog {f : ℂ → ℂ} {f' x : ℂ} (h₁ : HasDerivAt f f' x)
(h₂ : f x ∈ slitPlane) : HasDerivAt (fun t => log (f t)) (f' / f x) x := by
rw [div_eq_inv_mul]; exact (hasStrictDerivAt_log h₂).hasDerivAt.comp x h₁
theorem HasDerivAt.clog_real {f : ℝ → ℂ} {x : ℝ} {f' : ℂ} (h₁ : HasDerivAt f f' x)
(h₂ : f x ∈ slitPlane) : HasDerivAt (fun t => log (f t)) (f' / f x) x := by
simpa only [div_eq_inv_mul] using
(hasStrictFDerivAt_log_real h₂).hasFDerivAt.comp_hasDerivAt x h₁
theorem DifferentiableAt.clog {f : E → ℂ} {x : E} (h₁ : DifferentiableAt ℂ f x)
(h₂ : f x ∈ slitPlane) : DifferentiableAt ℂ (fun t => log (f t)) x :=
(h₁.hasFDerivAt.clog h₂).differentiableAt
theorem HasFDerivWithinAt.clog {f : E → ℂ} {f' : E →L[ℂ] ℂ} {s : Set E} {x : E}
(h₁ : HasFDerivWithinAt f f' s x) (h₂ : f x ∈ slitPlane) :
HasFDerivWithinAt (fun t => log (f t)) ((f x)⁻¹ • f') s x :=
(hasStrictDerivAt_log h₂).hasDerivAt.comp_hasFDerivWithinAt x h₁
theorem HasDerivWithinAt.clog {f : ℂ → ℂ} {f' x : ℂ} {s : Set ℂ} (h₁ : HasDerivWithinAt f f' s x)
(h₂ : f x ∈ slitPlane) : HasDerivWithinAt (fun t => log (f t)) (f' / f x) s x := by
rw [div_eq_inv_mul]
exact (hasStrictDerivAt_log h₂).hasDerivAt.comp_hasDerivWithinAt x h₁
theorem HasDerivWithinAt.clog_real {f : ℝ → ℂ} {s : Set ℝ} {x : ℝ} {f' : ℂ}
(h₁ : HasDerivWithinAt f f' s x) (h₂ : f x ∈ slitPlane) :
HasDerivWithinAt (fun t => log (f t)) (f' / f x) s x := by
simpa only [div_eq_inv_mul] using
(hasStrictFDerivAt_log_real h₂).hasFDerivAt.comp_hasDerivWithinAt x h₁
theorem DifferentiableWithinAt.clog {f : E → ℂ} {s : Set E} {x : E}
(h₁ : DifferentiableWithinAt ℂ f s x) (h₂ : f x ∈ slitPlane) :
DifferentiableWithinAt ℂ (fun t => log (f t)) s x :=
(h₁.hasFDerivWithinAt.clog h₂).differentiableWithinAt
theorem DifferentiableOn.clog {f : E → ℂ} {s : Set E} (h₁ : DifferentiableOn ℂ f s)
(h₂ : ∀ x ∈ s, f x ∈ slitPlane) : DifferentiableOn ℂ (fun t => log (f t)) s :=
fun x hx => (h₁ x hx).clog (h₂ x hx)
theorem Differentiable.clog {f : E → ℂ} (h₁ : Differentiable ℂ f)
(h₂ : ∀ x, f x ∈ slitPlane) : Differentiable ℂ fun t => log (f t) := fun x =>
(h₁ x).clog (h₂ x)
/-- The derivative of `log ∘ f` is the logarithmic derivative provided `f` is differentiable and
we are on the slitPlane. -/
lemma Complex.deriv_log_comp_eq_logDeriv {f : ℂ → ℂ} {x : ℂ} (h₁ : DifferentiableAt ℂ f x)
(h₂ : f x ∈ Complex.slitPlane) : deriv (Complex.log ∘ f) x = logDeriv f x := by
have A := (HasDerivAt.clog h₁.hasDerivAt h₂).deriv
rw [← h₁.hasDerivAt.deriv] at A
simp only [logDeriv, Pi.div_apply, ← A, Function.comp_def]
end LogDeriv
|
Analysis\SpecialFunctions\ContinuousFunctionalCalculus\ExpLog.lean | /-
Copyright (c) 2024 Frédéric Dupuis. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Frédéric Dupuis
-/
import Mathlib.Analysis.Normed.Algebra.Spectrum
import Mathlib.Analysis.SpecialFunctions.Exponential
import Mathlib.Analysis.CStarAlgebra.ContinuousFunctionalCalculus.Unital
/-!
# The exponential and logarithm based on the continuous functional calculus
This file defines the logarithm via the continuous functional calculus (CFC) and builds its API.
This allows one to take logs of matrices, operators, elements of a C⋆-algebra, etc.
It also shows that exponentials defined via the continuous functional calculus are equal to
`NormedSpace.exp` (defined via power series) whenever the former are not junk values.
## Main declarations
+ `CFC.log`: the real log function based on the CFC, i.e. `cfc Real.log`
+ `CFC.exp_eq_normedSpace_exp`: exponentials based on the CFC are equal to exponentials based
on power series.
+ `CFC.log_exp` and `CFC.exp_log`: `CFC.log` and `NormedSpace.exp ℝ` are inverses of each other.
## Implementation notes
Since `cfc Real.exp` and `cfc Complex.exp` are strictly less general than `NormedSpace.exp`
(defined via power series), we only give minimal API for these here in order to relate
`NormedSpace.exp` to functions defined via the CFC. In particular, we don't give separate
definitions for them.
## TODO
+ Show that `log (a * b) = log a + log b` whenever `a` and `b` commute (and the same for indexed
products).
+ Relate `CFC.log` to `rpow`, `zpow`, `sqrt`, `inv`.
-/
open NormedSpace
section general_exponential
variable {𝕜 : Type*} {α : Type*} [RCLike 𝕜] [TopologicalSpace α] [CompactSpace α]
lemma NormedSpace.exp_continuousMap_eq (f : C(α, 𝕜)) :
exp 𝕜 f = (⟨exp 𝕜 ∘ f, exp_continuous.comp f.continuous⟩ : C(α, 𝕜)) := by
ext a
simp only [Function.comp_apply, NormedSpace.exp, FormalMultilinearSeries.sum]
have h_sum := NormedSpace.expSeries_summable (𝕂 := 𝕜) f
simp_rw [← ContinuousMap.tsum_apply h_sum a, NormedSpace.expSeries_apply_eq]
simp [NormedSpace.exp_eq_tsum]
end general_exponential
namespace CFC
section RCLikeNormed
variable {𝕜 : Type*} {A : Type*} [RCLike 𝕜] {p : A → Prop} [PartialOrder A] [NormedRing A]
[StarRing A] [StarOrderedRing A] [TopologicalRing A] [NormedAlgebra 𝕜 A] [CompleteSpace A]
[ContinuousFunctionalCalculus 𝕜 p]
[UniqueContinuousFunctionalCalculus 𝕜 A]
lemma exp_eq_normedSpace_exp {a : A} (ha : p a := by cfc_tac) :
cfc (exp 𝕜 : 𝕜 → 𝕜) a = exp 𝕜 a := by
conv_rhs => rw [← cfc_id 𝕜 a ha, cfc_apply id a ha]
have h := (cfcHom_closedEmbedding (R := 𝕜) (show p a from ha)).continuous
have _ : ContinuousOn (exp 𝕜) (spectrum 𝕜 a) := exp_continuous.continuousOn
simp_rw [← map_exp 𝕜 _ h, cfc_apply (exp 𝕜) a ha]
congr 1
ext
simp [exp_continuousMap_eq]
end RCLikeNormed
section RealNormed
variable {A : Type*} {p : A → Prop} [PartialOrder A] [NormedRing A] [StarRing A] [StarOrderedRing A]
[TopologicalRing A] [NormedAlgebra ℝ A] [CompleteSpace A]
[ContinuousFunctionalCalculus ℝ p]
[UniqueContinuousFunctionalCalculus ℝ A]
lemma real_exp_eq_normedSpace_exp {a : A} (ha : p a := by cfc_tac) :
cfc Real.exp a = exp ℝ a :=
Real.exp_eq_exp_ℝ ▸ exp_eq_normedSpace_exp ha
end RealNormed
section ComplexNormed
variable {A : Type*} {p : A → Prop} [PartialOrder A] [NormedRing A] [StarRing A] [StarOrderedRing A]
[TopologicalRing A] [NormedAlgebra ℂ A] [CompleteSpace A]
[ContinuousFunctionalCalculus ℂ p]
[UniqueContinuousFunctionalCalculus ℂ A]
lemma complex_exp_eq_normedSpace_exp {a : A} (ha : p a := by cfc_tac) :
cfc Complex.exp a = exp ℂ a :=
Complex.exp_eq_exp_ℂ ▸ exp_eq_normedSpace_exp ha
end ComplexNormed
section real_log
open scoped ComplexOrder
variable {A : Type*} [PartialOrder A] [NormedRing A] [StarRing A] [StarOrderedRing A]
[TopologicalRing A] [NormedAlgebra ℝ A] [CompleteSpace A]
[ContinuousFunctionalCalculus ℝ (IsSelfAdjoint : A → Prop)]
[UniqueContinuousFunctionalCalculus ℝ A]
/-- The real logarithm, defined via the continuous functional calculus. This can be used on
matrices, operators on a Hilbert space, elements of a C⋆-algebra, etc. -/
noncomputable def log (a : A) : A := cfc Real.log a
@[simp]
protected lemma _root_.IsSelfAdjoint.log {a : A} : IsSelfAdjoint (log a) := cfc_predicate _ a
lemma log_exp (a : A) (ha : IsSelfAdjoint a := by cfc_tac) : log (NormedSpace.exp ℝ a) = a := by
have hcont : ContinuousOn Real.log (Real.exp '' spectrum ℝ a) := by fun_prop (disch := aesop)
rw [log, ← real_exp_eq_normedSpace_exp, ← cfc_comp' Real.log Real.exp a hcont]
simp [cfc_id' (R := ℝ) a]
-- TODO: Relate the hypothesis to a notion of strict positivity
lemma exp_log (a : A) (ha₂ : ∀ x ∈ spectrum ℝ a, 0 < x) (ha₁ : IsSelfAdjoint a := by cfc_tac) :
NormedSpace.exp ℝ (log a) = a := by
have ha₃ : ContinuousOn Real.log (spectrum ℝ a) := by
have : ∀ x ∈ spectrum ℝ a, x ≠ 0 := by peel ha₂ with x hx h; exact h.ne'
fun_prop (disch := assumption)
rw [← real_exp_eq_normedSpace_exp .log, log, ← cfc_comp' Real.exp Real.log a (by fun_prop) ha₃]
conv_rhs => rw [← cfc_id (R := ℝ) a ha₁]
exact cfc_congr (Real.exp_log <| ha₂ · ·)
@[simp] lemma log_zero : log (0 : A) = 0 := by simp [log]
@[simp] lemma log_one : log (1 : A) = 0 := by simp [log]
@[simp]
lemma log_algebraMap {r : ℝ} : log (algebraMap ℝ A r) = algebraMap ℝ A (Real.log r) := by
simp [log]
-- TODO: Relate the hypothesis to a notion of strict positivity
lemma log_smul {r : ℝ} (a : A) (ha₂ : ∀ x ∈ spectrum ℝ a, 0 < x) (hr : 0 < r)
(ha₁ : IsSelfAdjoint a := by cfc_tac) :
log (r • a) = algebraMap ℝ A (Real.log r) + log a := by
have : ∀ x ∈ spectrum ℝ a, x ≠ 0 := by peel ha₂ with x hx h; exact h.ne'
rw [log, ← cfc_smul_id (R := ℝ) r a, ← cfc_comp Real.log (r • ·) a, log]
calc
_ = cfc (fun z => Real.log r + Real.log z) a :=
cfc_congr (Real.log_mul hr.ne' <| ne_of_gt <| ha₂ · ·)
_ = _ := by rw [cfc_const_add _ _ _]
-- TODO: Relate the hypothesis to a notion of strict positivity
lemma log_pow (n : ℕ) (a : A) (ha₂ : ∀ x ∈ spectrum ℝ a, 0 < x)
(ha₁ : IsSelfAdjoint a := by cfc_tac) : log (a ^ n) = n • log a := by
have : ∀ x ∈ spectrum ℝ a, x ≠ 0 := by peel ha₂ with x hx h; exact h.ne'
have ha₂' : ContinuousOn Real.log (spectrum ℝ a) := by fun_prop (disch := assumption)
have ha₂'' : ContinuousOn Real.log ((· ^ n) '' spectrum ℝ a) := by fun_prop (disch := aesop)
rw [log, ← cfc_pow_id (R := ℝ) a n ha₁, ← cfc_comp' Real.log (· ^ n) a ha₂'', log]
simp_rw [Real.log_pow, ← Nat.cast_smul_eq_nsmul ℝ n, cfc_const_mul (n : ℝ) Real.log a ha₂']
end real_log
end CFC
|
Analysis\SpecialFunctions\Gamma\Basic.lean | /-
Copyright (c) 2022 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.MeasureTheory.Integral.ExpDecay
import Mathlib.Analysis.MellinTransform
/-!
# The Gamma function
This file defines the `Γ` function (of a real or complex variable `s`). We define this by Euler's
integral `Γ(s) = ∫ x in Ioi 0, exp (-x) * x ^ (s - 1)` in the range where this integral converges
(i.e., for `0 < s` in the real case, and `0 < re s` in the complex case).
We show that this integral satisfies `Γ(1) = 1` and `Γ(s + 1) = s * Γ(s)`; hence we can define
`Γ(s)` for all `s` as the unique function satisfying this recurrence and agreeing with Euler's
integral in the convergence range. (If `s = -n` for `n ∈ ℕ`, then the function is undefined, and we
set it to be `0` by convention.)
## Gamma function: main statements (complex case)
* `Complex.Gamma`: the `Γ` function (of a complex variable).
* `Complex.Gamma_eq_integral`: for `0 < re s`, `Γ(s)` agrees with Euler's integral.
* `Complex.Gamma_add_one`: for all `s : ℂ` with `s ≠ 0`, we have `Γ (s + 1) = s Γ(s)`.
* `Complex.Gamma_nat_eq_factorial`: for all `n : ℕ` we have `Γ (n + 1) = n!`.
* `Complex.differentiableAt_Gamma`: `Γ` is complex-differentiable at all `s : ℂ` with
`s ∉ {-n : n ∈ ℕ}`.
## Gamma function: main statements (real case)
* `Real.Gamma`: the `Γ` function (of a real variable).
* Real counterparts of all the properties of the complex Gamma function listed above:
`Real.Gamma_eq_integral`, `Real.Gamma_add_one`, `Real.Gamma_nat_eq_factorial`,
`Real.differentiableAt_Gamma`.
## Tags
Gamma
-/
noncomputable section
open Filter intervalIntegral Set Real MeasureTheory Asymptotics
open scoped Nat Topology ComplexConjugate
namespace Real
/-- Asymptotic bound for the `Γ` function integrand. -/
theorem Gamma_integrand_isLittleO (s : ℝ) :
(fun x : ℝ => exp (-x) * x ^ s) =o[atTop] fun x : ℝ => exp (-(1 / 2) * x) := by
refine isLittleO_of_tendsto (fun x hx => ?_) ?_
· exfalso; exact (exp_pos (-(1 / 2) * x)).ne' hx
have : (fun x : ℝ => exp (-x) * x ^ s / exp (-(1 / 2) * x)) =
(fun x : ℝ => exp (1 / 2 * x) / x ^ s)⁻¹ := by
ext1 x
field_simp [exp_ne_zero, exp_neg, ← Real.exp_add]
left
ring
rw [this]
exact (tendsto_exp_mul_div_rpow_atTop s (1 / 2) one_half_pos).inv_tendsto_atTop
/-- The Euler integral for the `Γ` function converges for positive real `s`. -/
theorem GammaIntegral_convergent {s : ℝ} (h : 0 < s) :
IntegrableOn (fun x : ℝ => exp (-x) * x ^ (s - 1)) (Ioi 0) := by
rw [← Ioc_union_Ioi_eq_Ioi (@zero_le_one ℝ _ _ _ _), integrableOn_union]
constructor
· rw [← integrableOn_Icc_iff_integrableOn_Ioc]
refine IntegrableOn.continuousOn_mul continuousOn_id.neg.rexp ?_ isCompact_Icc
refine (intervalIntegrable_iff_integrableOn_Icc_of_le zero_le_one).mp ?_
exact intervalIntegrable_rpow' (by linarith)
· refine integrable_of_isBigO_exp_neg one_half_pos ?_ (Gamma_integrand_isLittleO _).isBigO
refine continuousOn_id.neg.rexp.mul (continuousOn_id.rpow_const ?_)
intro x hx
exact Or.inl ((zero_lt_one : (0 : ℝ) < 1).trans_le hx).ne'
end Real
namespace Complex
/- Technical note: In defining the Gamma integrand exp (-x) * x ^ (s - 1) for s complex, we have to
make a choice between ↑(Real.exp (-x)), Complex.exp (↑(-x)), and Complex.exp (-↑x), all of which are
equal but not definitionally so. We use the first of these throughout. -/
/-- The integral defining the `Γ` function converges for complex `s` with `0 < re s`.
This is proved by reduction to the real case. -/
theorem GammaIntegral_convergent {s : ℂ} (hs : 0 < s.re) :
IntegrableOn (fun x => (-x).exp * x ^ (s - 1) : ℝ → ℂ) (Ioi 0) := by
constructor
· refine ContinuousOn.aestronglyMeasurable ?_ measurableSet_Ioi
apply (continuous_ofReal.comp continuous_neg.rexp).continuousOn.mul
apply ContinuousAt.continuousOn
intro x hx
have : ContinuousAt (fun x : ℂ => x ^ (s - 1)) ↑x :=
continuousAt_cpow_const <| ofReal_mem_slitPlane.2 hx
exact ContinuousAt.comp this continuous_ofReal.continuousAt
· rw [← hasFiniteIntegral_norm_iff]
refine HasFiniteIntegral.congr (Real.GammaIntegral_convergent hs).2 ?_
apply (ae_restrict_iff' measurableSet_Ioi).mpr
filter_upwards with x hx
rw [norm_eq_abs, map_mul, abs_of_nonneg <| le_of_lt <| exp_pos <| -x,
abs_cpow_eq_rpow_re_of_pos hx _]
simp
/-- Euler's integral for the `Γ` function (of a complex variable `s`), defined as
`∫ x in Ioi 0, exp (-x) * x ^ (s - 1)`.
See `Complex.GammaIntegral_convergent` for a proof of the convergence of the integral for
`0 < re s`. -/
def GammaIntegral (s : ℂ) : ℂ :=
∫ x in Ioi (0 : ℝ), ↑(-x).exp * ↑x ^ (s - 1)
theorem GammaIntegral_conj (s : ℂ) : GammaIntegral (conj s) = conj (GammaIntegral s) := by
rw [GammaIntegral, GammaIntegral, ← integral_conj]
refine setIntegral_congr measurableSet_Ioi fun x hx => ?_
dsimp only
rw [RingHom.map_mul, conj_ofReal, cpow_def_of_ne_zero (ofReal_ne_zero.mpr (ne_of_gt hx)),
cpow_def_of_ne_zero (ofReal_ne_zero.mpr (ne_of_gt hx)), ← exp_conj, RingHom.map_mul, ←
ofReal_log (le_of_lt hx), conj_ofReal, RingHom.map_sub, RingHom.map_one]
theorem GammaIntegral_ofReal (s : ℝ) :
GammaIntegral ↑s = ↑(∫ x : ℝ in Ioi 0, Real.exp (-x) * x ^ (s - 1)) := by
have : ∀ r : ℝ, Complex.ofReal' r = @RCLike.ofReal ℂ _ r := fun r => rfl
rw [GammaIntegral]
conv_rhs => rw [this, ← _root_.integral_ofReal]
refine setIntegral_congr measurableSet_Ioi ?_
intro x hx; dsimp only
conv_rhs => rw [← this]
rw [ofReal_mul, ofReal_cpow (mem_Ioi.mp hx).le]
simp
@[simp]
theorem GammaIntegral_one : GammaIntegral 1 = 1 := by
simpa only [← ofReal_one, GammaIntegral_ofReal, ofReal_inj, sub_self, rpow_zero,
mul_one] using integral_exp_neg_Ioi_zero
end Complex
/-! Now we establish the recurrence relation `Γ(s + 1) = s * Γ(s)` using integration by parts. -/
namespace Complex
section GammaRecurrence
/-- The indefinite version of the `Γ` function, `Γ(s, X) = ∫ x ∈ 0..X, exp(-x) x ^ (s - 1)`. -/
def partialGamma (s : ℂ) (X : ℝ) : ℂ :=
∫ x in (0)..X, (-x).exp * x ^ (s - 1)
theorem tendsto_partialGamma {s : ℂ} (hs : 0 < s.re) :
Tendsto (fun X : ℝ => partialGamma s X) atTop (𝓝 <| GammaIntegral s) :=
intervalIntegral_tendsto_integral_Ioi 0 (GammaIntegral_convergent hs) tendsto_id
private theorem Gamma_integrand_intervalIntegrable (s : ℂ) {X : ℝ} (hs : 0 < s.re) (hX : 0 ≤ X) :
IntervalIntegrable (fun x => (-x).exp * x ^ (s - 1) : ℝ → ℂ) volume 0 X := by
rw [intervalIntegrable_iff_integrableOn_Ioc_of_le hX]
exact IntegrableOn.mono_set (GammaIntegral_convergent hs) Ioc_subset_Ioi_self
private theorem Gamma_integrand_deriv_integrable_A {s : ℂ} (hs : 0 < s.re) {X : ℝ} (hX : 0 ≤ X) :
IntervalIntegrable (fun x => -((-x).exp * x ^ s) : ℝ → ℂ) volume 0 X := by
convert (Gamma_integrand_intervalIntegrable (s + 1) _ hX).neg
· simp only [ofReal_exp, ofReal_neg, add_sub_cancel_right]; rfl
· simp only [add_re, one_re]; linarith
private theorem Gamma_integrand_deriv_integrable_B {s : ℂ} (hs : 0 < s.re) {Y : ℝ} (hY : 0 ≤ Y) :
IntervalIntegrable (fun x : ℝ => (-x).exp * (s * x ^ (s - 1)) : ℝ → ℂ) volume 0 Y := by
have : (fun x => (-x).exp * (s * x ^ (s - 1)) : ℝ → ℂ) =
(fun x => s * ((-x).exp * x ^ (s - 1)) : ℝ → ℂ) := by ext1; ring
rw [this, intervalIntegrable_iff_integrableOn_Ioc_of_le hY]
constructor
· refine (continuousOn_const.mul ?_).aestronglyMeasurable measurableSet_Ioc
apply (continuous_ofReal.comp continuous_neg.rexp).continuousOn.mul
apply ContinuousAt.continuousOn
intro x hx
refine (?_ : ContinuousAt (fun x : ℂ => x ^ (s - 1)) _).comp continuous_ofReal.continuousAt
exact continuousAt_cpow_const <| ofReal_mem_slitPlane.2 hx.1
rw [← hasFiniteIntegral_norm_iff]
simp_rw [norm_eq_abs, map_mul]
refine (((Real.GammaIntegral_convergent hs).mono_set
Ioc_subset_Ioi_self).hasFiniteIntegral.congr ?_).const_mul _
rw [EventuallyEq, ae_restrict_iff']
· filter_upwards with x hx
rw [abs_of_nonneg (exp_pos _).le, abs_cpow_eq_rpow_re_of_pos hx.1]
simp
· exact measurableSet_Ioc
/-- The recurrence relation for the indefinite version of the `Γ` function. -/
theorem partialGamma_add_one {s : ℂ} (hs : 0 < s.re) {X : ℝ} (hX : 0 ≤ X) :
partialGamma (s + 1) X = s * partialGamma s X - (-X).exp * X ^ s := by
rw [partialGamma, partialGamma, add_sub_cancel_right]
have F_der_I : ∀ x : ℝ, x ∈ Ioo 0 X → HasDerivAt (fun x => (-x).exp * x ^ s : ℝ → ℂ)
(-((-x).exp * x ^ s) + (-x).exp * (s * x ^ (s - 1))) x := by
intro x hx
have d1 : HasDerivAt (fun y : ℝ => (-y).exp) (-(-x).exp) x := by
simpa using (hasDerivAt_neg x).exp
have d2 : HasDerivAt (fun y : ℝ => (y : ℂ) ^ s) (s * x ^ (s - 1)) x := by
have t := @HasDerivAt.cpow_const _ _ _ s (hasDerivAt_id ↑x) ?_
· simpa only [mul_one] using t.comp_ofReal
· exact ofReal_mem_slitPlane.2 hx.1
simpa only [ofReal_neg, neg_mul] using d1.ofReal_comp.mul d2
have cont := (continuous_ofReal.comp continuous_neg.rexp).mul (continuous_ofReal_cpow_const hs)
have der_ible :=
(Gamma_integrand_deriv_integrable_A hs hX).add (Gamma_integrand_deriv_integrable_B hs hX)
have int_eval := integral_eq_sub_of_hasDerivAt_of_le hX cont.continuousOn F_der_I der_ible
-- We are basically done here but manipulating the output into the right form is fiddly.
apply_fun fun x : ℂ => -x at int_eval
rw [intervalIntegral.integral_add (Gamma_integrand_deriv_integrable_A hs hX)
(Gamma_integrand_deriv_integrable_B hs hX),
intervalIntegral.integral_neg, neg_add, neg_neg] at int_eval
rw [eq_sub_of_add_eq int_eval, sub_neg_eq_add, neg_sub, add_comm, add_sub]
have : (fun x => (-x).exp * (s * x ^ (s - 1)) : ℝ → ℂ) =
(fun x => s * (-x).exp * x ^ (s - 1) : ℝ → ℂ) := by ext1; ring
rw [this]
have t := @integral_const_mul 0 X volume _ _ s fun x : ℝ => (-x).exp * x ^ (s - 1)
rw [← t, ofReal_zero, zero_cpow]
· rw [mul_zero, add_zero]; congr 2; ext1; ring
· contrapose! hs; rw [hs, zero_re]
/-- The recurrence relation for the `Γ` integral. -/
theorem GammaIntegral_add_one {s : ℂ} (hs : 0 < s.re) :
GammaIntegral (s + 1) = s * GammaIntegral s := by
suffices Tendsto (s + 1).partialGamma atTop (𝓝 <| s * GammaIntegral s) by
refine tendsto_nhds_unique ?_ this
apply tendsto_partialGamma; rw [add_re, one_re]; linarith
have : (fun X : ℝ => s * partialGamma s X - X ^ s * (-X).exp) =ᶠ[atTop]
(s + 1).partialGamma := by
apply eventuallyEq_of_mem (Ici_mem_atTop (0 : ℝ))
intro X hX
rw [partialGamma_add_one hs (mem_Ici.mp hX)]
ring_nf
refine Tendsto.congr' this ?_
suffices Tendsto (fun X => -X ^ s * (-X).exp : ℝ → ℂ) atTop (𝓝 0) by
simpa using Tendsto.add (Tendsto.const_mul s (tendsto_partialGamma hs)) this
rw [tendsto_zero_iff_norm_tendsto_zero]
have :
(fun e : ℝ => ‖-(e : ℂ) ^ s * (-e).exp‖) =ᶠ[atTop] fun e : ℝ => e ^ s.re * (-1 * e).exp := by
refine eventuallyEq_of_mem (Ioi_mem_atTop 0) ?_
intro x hx; dsimp only
rw [norm_eq_abs, map_mul, abs.map_neg, abs_cpow_eq_rpow_re_of_pos hx,
abs_of_nonneg (exp_pos (-x)).le, neg_mul, one_mul]
exact (tendsto_congr' this).mpr (tendsto_rpow_mul_exp_neg_mul_atTop_nhds_zero _ _ zero_lt_one)
end GammaRecurrence
/-! Now we define `Γ(s)` on the whole complex plane, by recursion. -/
section GammaDef
/-- The `n`th function in this family is `Γ(s)` if `-n < s.re`, and junk otherwise. -/
noncomputable def GammaAux : ℕ → ℂ → ℂ
| 0 => GammaIntegral
| n + 1 => fun s : ℂ => GammaAux n (s + 1) / s
theorem GammaAux_recurrence1 (s : ℂ) (n : ℕ) (h1 : -s.re < ↑n) :
GammaAux n s = GammaAux n (s + 1) / s := by
induction' n with n hn generalizing s
· simp only [Nat.zero_eq, CharP.cast_eq_zero, Left.neg_neg_iff] at h1
dsimp only [GammaAux]; rw [GammaIntegral_add_one h1]
rw [mul_comm, mul_div_cancel_right₀]; contrapose! h1; rw [h1]
simp
· dsimp only [GammaAux]
have hh1 : -(s + 1).re < n := by
rw [Nat.cast_add, Nat.cast_one] at h1
rw [add_re, one_re]; linarith
rw [← hn (s + 1) hh1]
theorem GammaAux_recurrence2 (s : ℂ) (n : ℕ) (h1 : -s.re < ↑n) :
GammaAux n s = GammaAux (n + 1) s := by
cases' n with n n
· simp only [Nat.zero_eq, CharP.cast_eq_zero, Left.neg_neg_iff] at h1
dsimp only [GammaAux]
rw [GammaIntegral_add_one h1, mul_div_cancel_left₀]
rintro rfl
rw [zero_re] at h1
exact h1.false
· dsimp only [GammaAux]
have : GammaAux n (s + 1 + 1) / (s + 1) = GammaAux n (s + 1) := by
have hh1 : -(s + 1).re < n := by
rw [Nat.cast_add, Nat.cast_one] at h1
rw [add_re, one_re]; linarith
rw [GammaAux_recurrence1 (s + 1) n hh1]
rw [this]
/-- The `Γ` function (of a complex variable `s`). -/
@[pp_nodot]
irreducible_def Gamma (s : ℂ) : ℂ :=
GammaAux ⌊1 - s.re⌋₊ s
theorem Gamma_eq_GammaAux (s : ℂ) (n : ℕ) (h1 : -s.re < ↑n) : Gamma s = GammaAux n s := by
have u : ∀ k : ℕ, GammaAux (⌊1 - s.re⌋₊ + k) s = Gamma s := by
intro k; induction' k with k hk
· simp [Gamma]
· rw [← hk, ← add_assoc]
refine (GammaAux_recurrence2 s (⌊1 - s.re⌋₊ + k) ?_).symm
rw [Nat.cast_add]
have i0 := Nat.sub_one_lt_floor (1 - s.re)
simp only [sub_sub_cancel_left] at i0
refine lt_add_of_lt_of_nonneg i0 ?_
rw [← Nat.cast_zero, Nat.cast_le]; exact Nat.zero_le k
convert (u <| n - ⌊1 - s.re⌋₊).symm; rw [Nat.add_sub_of_le]
by_cases h : 0 ≤ 1 - s.re
· apply Nat.le_of_lt_succ
exact_mod_cast lt_of_le_of_lt (Nat.floor_le h) (by linarith : 1 - s.re < n + 1)
· rw [Nat.floor_of_nonpos]
· omega
· linarith
/-- The recurrence relation for the `Γ` function. -/
theorem Gamma_add_one (s : ℂ) (h2 : s ≠ 0) : Gamma (s + 1) = s * Gamma s := by
let n := ⌊1 - s.re⌋₊
have t1 : -s.re < n := by simpa only [sub_sub_cancel_left] using Nat.sub_one_lt_floor (1 - s.re)
have t2 : -(s + 1).re < n := by rw [add_re, one_re]; linarith
rw [Gamma_eq_GammaAux s n t1, Gamma_eq_GammaAux (s + 1) n t2, GammaAux_recurrence1 s n t1]
field_simp
theorem Gamma_eq_integral {s : ℂ} (hs : 0 < s.re) : Gamma s = GammaIntegral s :=
Gamma_eq_GammaAux s 0 (by norm_cast; linarith)
@[simp]
theorem Gamma_one : Gamma 1 = 1 := by rw [Gamma_eq_integral] <;> simp
theorem Gamma_nat_eq_factorial (n : ℕ) : Gamma (n + 1) = n ! := by
induction' n with n hn
· simp
· rw [Gamma_add_one n.succ <| Nat.cast_ne_zero.mpr <| Nat.succ_ne_zero n]
simp only [Nat.cast_succ, Nat.factorial_succ, Nat.cast_mul]; congr
@[simp]
theorem Gamma_ofNat_eq_factorial (n : ℕ) [(n + 1).AtLeastTwo] :
Gamma (no_index (OfNat.ofNat (n + 1) : ℂ)) = n ! :=
mod_cast Gamma_nat_eq_factorial (n : ℕ)
/-- At `0` the Gamma function is undefined; by convention we assign it the value `0`. -/
@[simp]
theorem Gamma_zero : Gamma 0 = 0 := by
simp_rw [Gamma, zero_re, sub_zero, Nat.floor_one, GammaAux, div_zero]
/-- At `-n` for `n ∈ ℕ`, the Gamma function is undefined; by convention we assign it the value 0. -/
theorem Gamma_neg_nat_eq_zero (n : ℕ) : Gamma (-n) = 0 := by
induction' n with n IH
· rw [Nat.cast_zero, neg_zero, Gamma_zero]
· have A : -(n.succ : ℂ) ≠ 0 := by
rw [neg_ne_zero, Nat.cast_ne_zero]
apply Nat.succ_ne_zero
have : -(n : ℂ) = -↑n.succ + 1 := by simp
rw [this, Gamma_add_one _ A] at IH
contrapose! IH
exact mul_ne_zero A IH
theorem Gamma_conj (s : ℂ) : Gamma (conj s) = conj (Gamma s) := by
suffices ∀ (n : ℕ) (s : ℂ), GammaAux n (conj s) = conj (GammaAux n s) by
simp [Gamma, this]
intro n
induction' n with n IH
· rw [GammaAux]; exact GammaIntegral_conj
· intro s
rw [GammaAux]
dsimp only
rw [div_eq_mul_inv _ s, RingHom.map_mul, conj_inv, ← div_eq_mul_inv]
suffices conj s + 1 = conj (s + 1) by rw [this, IH]
rw [RingHom.map_add, RingHom.map_one]
/-- Expresses the integral over `Ioi 0` of `t ^ (a - 1) * exp (-(r * t))` in terms of the Gamma
function, for complex `a`. -/
lemma integral_cpow_mul_exp_neg_mul_Ioi {a : ℂ} {r : ℝ} (ha : 0 < a.re) (hr : 0 < r) :
∫ (t : ℝ) in Ioi 0, t ^ (a - 1) * exp (-(r * t)) = (1 / r) ^ a * Gamma a := by
have aux : (1 / r : ℂ) ^ a = 1 / r * (1 / r) ^ (a - 1) := by
nth_rewrite 2 [← cpow_one (1 / r : ℂ)]
rw [← cpow_add _ _ (one_div_ne_zero <| ofReal_ne_zero.mpr hr.ne'), add_sub_cancel]
calc
_ = ∫ (t : ℝ) in Ioi 0, (1 / r) ^ (a - 1) * (r * t) ^ (a - 1) * exp (-(r * t)) := by
refine MeasureTheory.setIntegral_congr measurableSet_Ioi (fun x hx ↦ ?_)
rw [mem_Ioi] at hx
rw [mul_cpow_ofReal_nonneg hr.le hx.le, ← mul_assoc, one_div, ← ofReal_inv,
← mul_cpow_ofReal_nonneg (inv_pos.mpr hr).le hr.le, ← ofReal_mul r⁻¹, inv_mul_cancel hr.ne',
ofReal_one, one_cpow, one_mul]
_ = 1 / r * ∫ (t : ℝ) in Ioi 0, (1 / r) ^ (a - 1) * t ^ (a - 1) * exp (-t) := by
simp_rw [← ofReal_mul]
rw [integral_comp_mul_left_Ioi (fun x ↦ _ * x ^ (a - 1) * exp (-x)) _ hr, mul_zero,
real_smul, ← one_div, ofReal_div, ofReal_one]
_ = 1 / r * (1 / r : ℂ) ^ (a - 1) * (∫ (t : ℝ) in Ioi 0, t ^ (a - 1) * exp (-t)) := by
simp_rw [← integral_mul_left, mul_assoc]
_ = (1 / r) ^ a * Gamma a := by
rw [aux, Gamma_eq_integral ha]
congr 2 with x
rw [ofReal_exp, ofReal_neg, mul_comm]
end GammaDef
/-! Now check that the `Γ` function is differentiable, wherever this makes sense. -/
section GammaHasDeriv
/-- Rewrite the Gamma integral as an example of a Mellin transform. -/
theorem GammaIntegral_eq_mellin : GammaIntegral = mellin fun x => ↑(Real.exp (-x)) :=
funext fun s => by simp only [mellin, GammaIntegral, smul_eq_mul, mul_comm]
/-- The derivative of the `Γ` integral, at any `s ∈ ℂ` with `1 < re s`, is given by the Mellin
transform of `log t * exp (-t)`. -/
theorem hasDerivAt_GammaIntegral {s : ℂ} (hs : 0 < s.re) :
HasDerivAt GammaIntegral (∫ t : ℝ in Ioi 0, t ^ (s - 1) * (Real.log t * Real.exp (-t))) s := by
rw [GammaIntegral_eq_mellin]
convert (mellin_hasDerivAt_of_isBigO_rpow (E := ℂ) _ _ (lt_add_one _) _ hs).2
· refine (Continuous.continuousOn ?_).locallyIntegrableOn measurableSet_Ioi
exact continuous_ofReal.comp (Real.continuous_exp.comp continuous_neg)
· rw [← isBigO_norm_left]
simp_rw [Complex.norm_eq_abs, abs_ofReal, ← Real.norm_eq_abs, isBigO_norm_left]
simpa only [neg_one_mul] using (isLittleO_exp_neg_mul_rpow_atTop zero_lt_one _).isBigO
· simp_rw [neg_zero, rpow_zero]
refine isBigO_const_of_tendsto (?_ : Tendsto _ _ (𝓝 (1 : ℂ))) one_ne_zero
rw [(by simp : (1 : ℂ) = Real.exp (-0))]
exact (continuous_ofReal.comp (Real.continuous_exp.comp continuous_neg)).continuousWithinAt
theorem differentiableAt_GammaAux (s : ℂ) (n : ℕ) (h1 : 1 - s.re < n) (h2 : ∀ m : ℕ, s ≠ -m) :
DifferentiableAt ℂ (GammaAux n) s := by
induction' n with n hn generalizing s
· refine (hasDerivAt_GammaIntegral ?_).differentiableAt
rw [Nat.cast_zero] at h1; linarith
· dsimp only [GammaAux]
specialize hn (s + 1)
have a : 1 - (s + 1).re < ↑n := by
rw [Nat.cast_succ] at h1; rw [Complex.add_re, Complex.one_re]; linarith
have b : ∀ m : ℕ, s + 1 ≠ -m := by
intro m; have := h2 (1 + m)
contrapose! this
rw [← eq_sub_iff_add_eq] at this
simpa using this
refine DifferentiableAt.div (DifferentiableAt.comp _ (hn a b) ?_) ?_ ?_
· rw [differentiableAt_add_const_iff (1 : ℂ)]; exact differentiableAt_id
· exact differentiableAt_id
· simpa using h2 0
theorem differentiableAt_Gamma (s : ℂ) (hs : ∀ m : ℕ, s ≠ -m) : DifferentiableAt ℂ Gamma s := by
let n := ⌊1 - s.re⌋₊ + 1
have hn : 1 - s.re < n := mod_cast Nat.lt_floor_add_one (1 - s.re)
apply (differentiableAt_GammaAux s n hn hs).congr_of_eventuallyEq
let S := {t : ℂ | 1 - t.re < n}
have : S ∈ 𝓝 s := by
rw [mem_nhds_iff]; use S
refine ⟨Subset.rfl, ?_, hn⟩
have : S = re ⁻¹' Ioi (1 - n : ℝ) := by
ext; rw [preimage, Ioi, mem_setOf_eq, mem_setOf_eq, mem_setOf_eq]; exact sub_lt_comm
rw [this]
exact Continuous.isOpen_preimage continuous_re _ isOpen_Ioi
apply eventuallyEq_of_mem this
intro t ht; rw [mem_setOf_eq] at ht
apply Gamma_eq_GammaAux; linarith
end GammaHasDeriv
/-- At `s = 0`, the Gamma function has a simple pole with residue 1. -/
theorem tendsto_self_mul_Gamma_nhds_zero : Tendsto (fun z : ℂ => z * Gamma z) (𝓝[≠] 0) (𝓝 1) := by
rw [show 𝓝 (1 : ℂ) = 𝓝 (Gamma (0 + 1)) by simp only [zero_add, Complex.Gamma_one]]
convert (Tendsto.mono_left _ nhdsWithin_le_nhds).congr'
(eventuallyEq_of_mem self_mem_nhdsWithin Complex.Gamma_add_one)
refine ContinuousAt.comp (g := Gamma) ?_ (continuous_id.add continuous_const).continuousAt
refine (Complex.differentiableAt_Gamma _ fun m => ?_).continuousAt
rw [zero_add, ← ofReal_natCast, ← ofReal_neg, ← ofReal_one, Ne, ofReal_inj]
refine (lt_of_le_of_lt ?_ zero_lt_one).ne'
exact neg_nonpos.mpr (Nat.cast_nonneg _)
end Complex
namespace Real
/-- The `Γ` function (of a real variable `s`). -/
@[pp_nodot]
def Gamma (s : ℝ) : ℝ :=
(Complex.Gamma s).re
theorem Gamma_eq_integral {s : ℝ} (hs : 0 < s) :
Gamma s = ∫ x in Ioi 0, exp (-x) * x ^ (s - 1) := by
rw [Gamma, Complex.Gamma_eq_integral (by rwa [Complex.ofReal_re] : 0 < Complex.re s)]
dsimp only [Complex.GammaIntegral]
simp_rw [← Complex.ofReal_one, ← Complex.ofReal_sub]
suffices ∫ x : ℝ in Ioi 0, ↑(exp (-x)) * (x : ℂ) ^ ((s - 1 : ℝ) : ℂ) =
∫ x : ℝ in Ioi 0, ((exp (-x) * x ^ (s - 1) : ℝ) : ℂ) by
have cc : ∀ r : ℝ, Complex.ofReal' r = @RCLike.ofReal ℂ _ r := fun r => rfl
conv_lhs => rw [this]; enter [1, 2, x]; rw [cc]
rw [_root_.integral_ofReal, ← cc, Complex.ofReal_re]
refine setIntegral_congr measurableSet_Ioi fun x hx => ?_
push_cast
rw [Complex.ofReal_cpow (le_of_lt hx)]
push_cast; rfl
theorem Gamma_add_one {s : ℝ} (hs : s ≠ 0) : Gamma (s + 1) = s * Gamma s := by
simp_rw [Gamma]
rw [Complex.ofReal_add, Complex.ofReal_one, Complex.Gamma_add_one, Complex.re_ofReal_mul]
rwa [Complex.ofReal_ne_zero]
@[simp]
theorem Gamma_one : Gamma 1 = 1 := by
rw [Gamma, Complex.ofReal_one, Complex.Gamma_one, Complex.one_re]
theorem _root_.Complex.Gamma_ofReal (s : ℝ) : Complex.Gamma (s : ℂ) = Gamma s := by
rw [Gamma, eq_comm, ← Complex.conj_eq_iff_re, ← Complex.Gamma_conj, Complex.conj_ofReal]
theorem Gamma_nat_eq_factorial (n : ℕ) : Gamma (n + 1) = n ! := by
rw [Gamma, Complex.ofReal_add, Complex.ofReal_natCast, Complex.ofReal_one,
Complex.Gamma_nat_eq_factorial, ← Complex.ofReal_natCast, Complex.ofReal_re]
@[simp]
theorem Gamma_ofNat_eq_factorial (n : ℕ) [(n + 1).AtLeastTwo] :
Gamma (no_index (OfNat.ofNat (n + 1) : ℝ)) = n ! :=
mod_cast Gamma_nat_eq_factorial (n : ℕ)
/-- At `0` the Gamma function is undefined; by convention we assign it the value `0`. -/
@[simp]
theorem Gamma_zero : Gamma 0 = 0 := by
simpa only [← Complex.ofReal_zero, Complex.Gamma_ofReal, Complex.ofReal_inj] using
Complex.Gamma_zero
/-- At `-n` for `n ∈ ℕ`, the Gamma function is undefined; by convention we assign it the value `0`.
-/
theorem Gamma_neg_nat_eq_zero (n : ℕ) : Gamma (-n) = 0 := by
simpa only [← Complex.ofReal_natCast, ← Complex.ofReal_neg, Complex.Gamma_ofReal,
Complex.ofReal_eq_zero] using Complex.Gamma_neg_nat_eq_zero n
theorem Gamma_pos_of_pos {s : ℝ} (hs : 0 < s) : 0 < Gamma s := by
rw [Gamma_eq_integral hs]
have : (Function.support fun x : ℝ => exp (-x) * x ^ (s - 1)) ∩ Ioi 0 = Ioi 0 := by
rw [inter_eq_right]
intro x hx
rw [Function.mem_support]
exact mul_ne_zero (exp_pos _).ne' (rpow_pos_of_pos hx _).ne'
rw [setIntegral_pos_iff_support_of_nonneg_ae]
· rw [this, volume_Ioi, ← ENNReal.ofReal_zero]
exact ENNReal.ofReal_lt_top
· refine eventually_of_mem (self_mem_ae_restrict measurableSet_Ioi) ?_
exact fun x hx => (mul_pos (exp_pos _) (rpow_pos_of_pos hx _)).le
· exact GammaIntegral_convergent hs
theorem Gamma_nonneg_of_nonneg {s : ℝ} (hs : 0 ≤ s) : 0 ≤ Gamma s := by
obtain rfl | h := eq_or_lt_of_le hs
· rw [Gamma_zero]
· exact (Gamma_pos_of_pos h).le
open Complex in
/-- Expresses the integral over `Ioi 0` of `t ^ (a - 1) * exp (-(r * t))`, for positive real `r`,
in terms of the Gamma function. -/
lemma integral_rpow_mul_exp_neg_mul_Ioi {a r : ℝ} (ha : 0 < a) (hr : 0 < r) :
∫ t : ℝ in Ioi 0, t ^ (a - 1) * exp (-(r * t)) = (1 / r) ^ a * Gamma a := by
rw [← ofReal_inj, ofReal_mul, ← Gamma_ofReal, ofReal_cpow (by positivity), ofReal_div]
convert integral_cpow_mul_exp_neg_mul_Ioi (by rwa [ofReal_re] : 0 < (a : ℂ).re) hr
refine _root_.integral_ofReal.symm.trans <| setIntegral_congr measurableSet_Ioi (fun t ht ↦ ?_)
norm_cast
rw [← ofReal_cpow (le_of_lt ht), RCLike.ofReal_mul]
rfl
open Lean.Meta Qq Mathlib.Meta.Positivity in
/-- The `positivity` extension which identifies expressions of the form `Gamma a`. -/
@[positivity Gamma (_ : ℝ)]
def _root_.Mathlib.Meta.Positivity.evalGamma : PositivityExt where eval {u α} _zα _pα e := do
match u, α, e with
| 0, ~q(ℝ), ~q(Gamma $a) =>
match ← core q(inferInstance) q(inferInstance) a with
| .positive pa =>
assertInstancesCommute
pure (.positive q(Gamma_pos_of_pos $pa))
| .nonnegative pa =>
assertInstancesCommute
pure (.nonnegative q(Gamma_nonneg_of_nonneg $pa))
| _ => pure .none
| _, _, _ => throwError "failed to match on Gamma application"
/-- The Gamma function does not vanish on `ℝ` (except at non-positive integers, where the function
is mathematically undefined and we set it to `0` by convention). -/
theorem Gamma_ne_zero {s : ℝ} (hs : ∀ m : ℕ, s ≠ -m) : Gamma s ≠ 0 := by
suffices ∀ {n : ℕ}, -(n : ℝ) < s → Gamma s ≠ 0 by
apply this
swap
· exact ⌊-s⌋₊ + 1
rw [neg_lt, Nat.cast_add, Nat.cast_one]
exact Nat.lt_floor_add_one _
intro n
induction' n with _ n_ih generalizing s
· intro hs
refine (Gamma_pos_of_pos ?_).ne'
rwa [Nat.cast_zero, neg_zero] at hs
· intro hs'
have : Gamma (s + 1) ≠ 0 := by
apply n_ih
· intro m
specialize hs (1 + m)
contrapose! hs
rw [← eq_sub_iff_add_eq] at hs
rw [hs]
push_cast
ring
· rw [Nat.cast_add, Nat.cast_one, neg_add] at hs'
linarith
rw [Gamma_add_one, mul_ne_zero_iff] at this
· exact this.2
· simpa using hs 0
theorem Gamma_eq_zero_iff (s : ℝ) : Gamma s = 0 ↔ ∃ m : ℕ, s = -m :=
⟨by contrapose!; exact Gamma_ne_zero, by rintro ⟨m, rfl⟩; exact Gamma_neg_nat_eq_zero m⟩
theorem differentiableAt_Gamma {s : ℝ} (hs : ∀ m : ℕ, s ≠ -m) : DifferentiableAt ℝ Gamma s := by
refine (Complex.differentiableAt_Gamma _ ?_).hasDerivAt.real_of_complex.differentiableAt
simp_rw [← Complex.ofReal_natCast, ← Complex.ofReal_neg, Ne, Complex.ofReal_inj]
exact hs
end Real
|
Analysis\SpecialFunctions\Gamma\Beta.lean | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
import Mathlib.Analysis.Complex.CauchyIntegral
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Β(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : ℂ` with `s ∉ {-n : n ∈ ℕ}` we have `Γ s ≠ 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n → ∞` of the sequence
`n ↦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Γ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = π / sin π s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Γ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * √π`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Β (u, v)`, defined as `∫ x:ℝ in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : ℂ) : ℂ :=
∫ x : ℝ in (0)..1, (x : ℂ) ^ (u - 1) * (1 - (x : ℂ)) ^ (v - 1)
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : ℂ} (hu : 0 < re u) (v : ℂ) :
IntervalIntegrable (fun x =>
(x : ℂ) ^ (u - 1) * (1 - (x : ℂ)) ^ (v - 1) : ℝ → ℂ) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
· refine intervalIntegral.intervalIntegrable_cpow' ?_
rwa [sub_re, one_re, ← zero_sub, sub_lt_sub_iff_right]
· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : ℝ) ≤ 1 / 2)] at hx
apply ContinuousAt.cpow
· exact (continuous_const.sub continuous_ofReal).continuousAt
· exact continuousAt_const
· norm_cast
exact ofReal_mem_slitPlane.2 <| by linarith only [hx.2]
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : ℂ} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : ℂ) ^ (u - 1) * (1 - (x : ℂ)) ^ (v - 1) : ℝ → ℂ) volume 0 1 := by
refine (betaIntegral_convergent_left hu v).trans ?_
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> · push_cast; ring
· norm_num
· norm_num
theorem betaIntegral_symm (u v : ℂ) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : ℝ => (x : ℂ) ^ (u - 1) * (1 - (x : ℂ)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, ← intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel_right, neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, ← sub_eq_add_neg, mul_comm]
exact this
theorem betaIntegral_eval_one_right {u : ℂ} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
· rwa [sub_re, one_re, ← sub_pos, sub_neg_eq_add, sub_add_cancel]
theorem betaIntegral_scaled (s t : ℂ) {a : ℝ} (ha : 0 < a) :
∫ x in (0)..a, (x : ℂ) ^ (s - 1) * ((a : ℂ) - x) ^ (t - 1) =
(a : ℂ) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : ℂ) ≠ 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : ℂ) ^ (s + t - 1) = a * ((a : ℂ) ^ (s - 1) * (a : ℂ) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, ← intervalIntegral.integral_const_mul, ← real_smul, ← zero_div a, ←
div_self ha.ne', ← intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine setIntegral_congr measurableSet_Ioc fun x hx => ?_
rw [mul_mul_mul_comm]
congr 1
· rw [← mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel₀ _ ha']
· rw [(by norm_cast : (1 : ℂ) - ↑(x / a) = ↑(1 - x / a)), ←
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel₀ _ ha']
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : ℂ} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul ℝ ℂ)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, ← conv_int, ← integral_mul_right (betaIntegral _ _)]
refine setIntegral_congr measurableSet_Ioi fun x hx => ?_
rw [mul_assoc, ← betaIntegral_scaled s t hx, ← intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
rw [← Complex.exp_add]; congr 1; abel
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : ℂ} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) ≠ 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : ℝ → ℂ := fun x => (x : ℂ) ^ u * (1 - (x : ℂ)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine (ContinuousAt.continuousOn fun x hx => ?_).mul (ContinuousAt.continuousOn fun x hx => ?_)
· refine (continuousAt_cpow_const_of_re_pos (Or.inl ?_) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
· refine (continuousAt_cpow_const_of_re_pos (Or.inl ?_) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : ∀ x : ℝ, x ∈ Ioo (0 : ℝ) 1 →
HasDerivAt F (u * ((x : ℂ) ^ (u - 1) * (1 - (x : ℂ)) ^ v) -
v * ((x : ℂ) ^ u * (1 - (x : ℂ)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : ℂ => y ^ u) (u * (x : ℂ) ^ (u - 1)) ↑x := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : ℂ)) (Or.inl ?_)
· simp only [id_eq, mul_one] at this
exact this
· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : ℂ => (1 - y) ^ v) (-v * (1 - (x : ℂ)) ^ (v - 1)) ↑x := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : ℂ))) (Or.inl ?_)
swap; · rw [id, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id] at A
have B : HasDerivAt (fun y : ℂ => 1 - y) (-1) ↑x := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (↑x) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel_right, add_sub_cancel_right] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [F, mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne,
true_and_iff, sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [F, mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
· rw [betaIntegral, betaIntegral, ← sub_eq_zero]
convert int_ev <;> ring
· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : ℂ} (hu : 0 < re u) (n : ℕ) :
betaIntegral u (n + 1) = n ! / ∏ j ∈ Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; · rw [← ofReal_natCast, ofReal_re]; positivity
rw [mul_comm u _, ← eq_div_iff] at this
swap; · contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; · rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, ←
mul_div_assoc, ← div_div]
congr 3 with j : 1
push_cast; abel
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Γ(s)` as `n → ∞`. -/
noncomputable def GammaSeq (s : ℂ) (n : ℕ) :=
(n : ℂ) ^ s * n ! / ∏ j ∈ Finset.range (n + 1), (s + j)
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : ℂ} (hs : 0 < re s) (n : ℕ) :
GammaSeq s n = (n : ℂ) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, ← mul_div_assoc]
theorem GammaSeq_add_one_left (s : ℂ) {n : ℕ} (hn : n ≠ 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, ← mul_assoc,
← mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
· refine Finset.prod_congr (by rfl) fun x _ => ?_
push_cast; ring
· abel
theorem GammaSeq_eq_approx_Gamma_integral {s : ℂ} (hs : 0 < re s) {n : ℕ} (hn : n ≠ 0) :
GammaSeq s n = ∫ x : ℝ in (0)..n, ↑((1 - x / n) ^ n) * (x : ℂ) ^ (s - 1) := by
have : ∀ x : ℝ, x = x / n * n := by intro x; rw [div_mul_cancel₀]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => ↑((1 - x) ^ n) * ↑(x * ↑n) ^ (s - 1) : ℝ → ℂ) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel_right,
← intervalIntegral.integral_const_mul, ← intervalIntegral.integral_const_mul]
swap; · exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine setIntegral_congr measurableSet_Ioc fun x hx => ?_
push_cast
have hn' : (n : ℂ) ≠ 0 := Nat.cast_ne_zero.mpr hn
have A : (n : ℂ) ^ s = (n : ℂ) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
have B : ((x : ℂ) * ↑n) ^ (s - 1) = (x : ℂ) ^ (s - 1) * (n : ℂ) ^ (s - 1) := by
rw [← ofReal_natCast,
mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le]
rw [A, B, cpow_natCast]; ring
/-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : ℂ} (hs : 0 < re s) :
Tendsto (fun n : ℕ => ∫ x : ℝ in (0)..n, ((1 - x / n) ^ n : ℝ) * (x : ℂ) ^ (s - 1)) atTop
(𝓝 <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : ℕ → ℝ → ℂ := fun n =>
indicator (Ioc 0 (n : ℝ)) fun x : ℝ => ((1 - x / n) ^ n : ℝ) * (x : ℂ) ^ (s - 1)
-- integrability of f
have f_ible : ∀ n : ℕ, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : ℝ) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, ← IntegrableOn, ←
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : ℝ) ≤ n)]
apply IntervalIntegrable.continuousOn_mul
· refine intervalIntegral.intervalIntegrable_cpow' ?_
rwa [sub_re, one_re, ← zero_sub, sub_lt_sub_iff_right]
· apply Continuous.continuousOn
exact RCLike.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const ↑n)).pow n)
-- pointwise limit of f
have f_tends : ∀ x : ℝ, x ∈ Ioi (0 : ℝ) →
Tendsto (fun n : ℕ => f n x) atTop (𝓝 <| ↑(Real.exp (-x)) * (x : ℂ) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
· show ∀ᶠ n : ℕ in atTop, ↑((1 - x / n) ^ n) * (x : ℂ) ^ (s - 1) = f n x
filter_upwards [eventually_ge_atTop ⌈x⌉₊] with n hn
rw [Nat.ceil_le] at hn
dsimp only [f]
rw [indicator_of_mem]
exact ⟨hx, hn⟩
· simp_rw [mul_comm]
refine (Tendsto.comp (continuous_ofReal.tendsto _) ?_).const_mul _
convert tendsto_one_plus_div_pow_exp (-x) using 1
ext1 n
rw [neg_div, ← sub_eq_add_neg]
-- let `convert` identify the remaining goals
convert tendsto_integral_of_dominated_convergence _ (fun n => (f_ible n).1)
(Real.GammaIntegral_convergent hs) _
((ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ f_tends)) using 1
-- limit of f is the integrand we want
· ext1 n
rw [MeasureTheory.integral_indicator (measurableSet_Ioc : MeasurableSet (Ioc (_ : ℝ) _)),
intervalIntegral.integral_of_le (by positivity : 0 ≤ (n : ℝ)),
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self]
-- f is uniformly bounded by the Gamma integrand
· intro n
rw [ae_restrict_iff' measurableSet_Ioi]
filter_upwards with x hx
dsimp only [f]
rcases lt_or_le (n : ℝ) x with (hxn | hxn)
· rw [indicator_of_not_mem (not_mem_Ioc_of_gt hxn), norm_zero,
mul_nonneg_iff_right_nonneg_of_pos (exp_pos _)]
exact rpow_nonneg (le_of_lt hx) _
· rw [indicator_of_mem (mem_Ioc.mpr ⟨mem_Ioi.mp hx, hxn⟩), norm_mul, Complex.norm_eq_abs,
Complex.abs_of_nonneg
(pow_nonneg (sub_nonneg.mpr <| div_le_one_of_le hxn <| by positivity) _),
Complex.norm_eq_abs, abs_cpow_eq_rpow_re_of_pos hx, sub_re, one_re,
mul_le_mul_right (rpow_pos_of_pos hx _)]
exact one_sub_div_pow_le_exp_neg hxn
/-- Euler's limit formula for the complex Gamma function. -/
theorem GammaSeq_tendsto_Gamma (s : ℂ) : Tendsto (GammaSeq s) atTop (𝓝 <| Gamma s) := by
suffices ∀ m : ℕ, -↑m < re s → Tendsto (GammaSeq s) atTop (𝓝 <| GammaAux m s) by
rw [Gamma]
apply this
rw [neg_lt]
rcases lt_or_le 0 (re s) with (hs | hs)
· exact (neg_neg_of_pos hs).trans_le (Nat.cast_nonneg _)
· refine (Nat.lt_floor_add_one _).trans_le ?_
rw [sub_eq_neg_add, Nat.floor_add_one (neg_nonneg.mpr hs), Nat.cast_add_one]
intro m
induction' m with m IH generalizing s
· -- Base case: `0 < re s`, so Gamma is given by the integral formula
intro hs
rw [Nat.cast_zero, neg_zero] at hs
rw [← Gamma_eq_GammaAux]
· refine Tendsto.congr' ?_ (approx_Gamma_integral_tendsto_Gamma_integral hs)
refine (eventually_ne_atTop 0).mp (eventually_of_forall fun n hn => ?_)
exact (GammaSeq_eq_approx_Gamma_integral hs hn).symm
· rwa [Nat.cast_zero, neg_lt_zero]
· -- Induction step: use recurrence formulae in `s` for Gamma and GammaSeq
intro hs
rw [Nat.cast_succ, neg_add, ← sub_eq_add_neg, sub_lt_iff_lt_add, ← one_re, ← add_re] at hs
rw [GammaAux]
have := @Tendsto.congr' _ _ _ ?_ _ _
((eventually_ne_atTop 0).mp (eventually_of_forall fun n hn => ?_)) ((IH _ hs).div_const s)
pick_goal 3; · exact GammaSeq_add_one_left s hn -- doesn't work if inlined?
conv at this => arg 1; intro n; rw [mul_comm]
rwa [← mul_one (GammaAux m (s + 1) / s), tendsto_mul_iff_of_ne_zero _ (one_ne_zero' ℂ)] at this
simp_rw [add_assoc]
exact tendsto_natCast_div_add_atTop (1 + s)
end Complex
end LimitFormula
section GammaReflection
/-! ## The reflection formula -/
namespace Complex
theorem GammaSeq_mul (z : ℂ) {n : ℕ} (hn : n ≠ 0) :
GammaSeq z n * GammaSeq (1 - z) n =
n / (n + ↑1 - z) * (↑1 / (z * ∏ j ∈ Finset.range n, (↑1 - z ^ 2 / ((j : ℂ) + 1) ^ 2))) := by
-- also true for n = 0 but we don't need it
have aux : ∀ a b c d : ℂ, a * b * (c * d) = a * c * (b * d) := by intros; ring
rw [GammaSeq, GammaSeq, div_mul_div_comm, aux, ← pow_two]
have : (n : ℂ) ^ z * (n : ℂ) ^ (1 - z) = n := by
rw [← cpow_add _ _ (Nat.cast_ne_zero.mpr hn), add_sub_cancel, cpow_one]
rw [this, Finset.prod_range_succ', Finset.prod_range_succ, aux, ← Finset.prod_mul_distrib,
Nat.cast_zero, add_zero, add_comm (1 - z) n, ← add_sub_assoc]
have : ∀ j : ℕ, (z + ↑(j + 1)) * (↑1 - z + ↑j) =
((j + 1) ^ 2 :) * (↑1 - z ^ 2 / ((j : ℂ) + 1) ^ 2) := by
intro j
push_cast
have : (j : ℂ) + 1 ≠ 0 := by rw [← Nat.cast_succ, Nat.cast_ne_zero]; exact Nat.succ_ne_zero j
field_simp; ring
simp_rw [this]
rw [Finset.prod_mul_distrib, ← Nat.cast_prod, Finset.prod_pow,
Finset.prod_range_add_one_eq_factorial, Nat.cast_pow,
(by intros; ring : ∀ a b c d : ℂ, a * b * (c * d) = a * (d * (b * c))), ← div_div,
mul_div_cancel_right₀, ← div_div, mul_comm z _, mul_one_div]
exact pow_ne_zero 2 (Nat.cast_ne_zero.mpr <| Nat.factorial_ne_zero n)
/-- Euler's reflection formula for the complex Gamma function. -/
theorem Gamma_mul_Gamma_one_sub (z : ℂ) : Gamma z * Gamma (1 - z) = π / sin (π * z) := by
have pi_ne : (π : ℂ) ≠ 0 := Complex.ofReal_ne_zero.mpr pi_ne_zero
by_cases hs : sin (↑π * z) = 0
· -- first deal with silly case z = integer
rw [hs, div_zero]
rw [← neg_eq_zero, ← Complex.sin_neg, ← mul_neg, Complex.sin_eq_zero_iff, mul_comm] at hs
obtain ⟨k, hk⟩ := hs
rw [mul_eq_mul_right_iff, eq_false (ofReal_ne_zero.mpr pi_pos.ne'), or_false_iff,
neg_eq_iff_eq_neg] at hk
rw [hk]
cases k
· rw [Int.ofNat_eq_coe, Int.cast_natCast, Complex.Gamma_neg_nat_eq_zero, zero_mul]
· rw [Int.cast_negSucc, neg_neg, Nat.cast_add, Nat.cast_one, add_comm, sub_add_cancel_left,
Complex.Gamma_neg_nat_eq_zero, mul_zero]
refine tendsto_nhds_unique ((GammaSeq_tendsto_Gamma z).mul (GammaSeq_tendsto_Gamma <| 1 - z)) ?_
have : ↑π / sin (↑π * z) = 1 * (π / sin (π * z)) := by rw [one_mul]
convert Tendsto.congr' ((eventually_ne_atTop 0).mp (eventually_of_forall fun n hn =>
(GammaSeq_mul z hn).symm)) (Tendsto.mul _ _)
· convert tendsto_natCast_div_add_atTop (1 - z) using 1; ext1 n; rw [add_sub_assoc]
· have : ↑π / sin (↑π * z) = 1 / (sin (π * z) / π) := by field_simp
convert tendsto_const_nhds.div _ (div_ne_zero hs pi_ne)
rw [← tendsto_mul_iff_of_ne_zero tendsto_const_nhds pi_ne, div_mul_cancel₀ _ pi_ne]
convert tendsto_euler_sin_prod z using 1
ext1 n; rw [mul_comm, ← mul_assoc]
/-- The Gamma function does not vanish on `ℂ` (except at non-positive integers, where the function
is mathematically undefined and we set it to `0` by convention). -/
theorem Gamma_ne_zero {s : ℂ} (hs : ∀ m : ℕ, s ≠ -m) : Gamma s ≠ 0 := by
by_cases h_im : s.im = 0
· have : s = ↑s.re := by
conv_lhs => rw [← Complex.re_add_im s]
rw [h_im, ofReal_zero, zero_mul, add_zero]
rw [this, Gamma_ofReal, ofReal_ne_zero]
refine Real.Gamma_ne_zero fun n => ?_
specialize hs n
contrapose! hs
rwa [this, ← ofReal_natCast, ← ofReal_neg, ofReal_inj]
· have : sin (↑π * s) ≠ 0 := by
rw [Complex.sin_ne_zero_iff]
intro k
apply_fun im
rw [im_ofReal_mul, ← ofReal_intCast, ← ofReal_mul, ofReal_im]
exact mul_ne_zero Real.pi_pos.ne' h_im
have A := div_ne_zero (ofReal_ne_zero.mpr Real.pi_pos.ne') this
rw [← Complex.Gamma_mul_Gamma_one_sub s, mul_ne_zero_iff] at A
exact A.1
theorem Gamma_eq_zero_iff (s : ℂ) : Gamma s = 0 ↔ ∃ m : ℕ, s = -m := by
constructor
· contrapose!; exact Gamma_ne_zero
· rintro ⟨m, rfl⟩; exact Gamma_neg_nat_eq_zero m
/-- A weaker, but easier-to-apply, version of `Complex.Gamma_ne_zero`. -/
theorem Gamma_ne_zero_of_re_pos {s : ℂ} (hs : 0 < re s) : Gamma s ≠ 0 := by
refine Gamma_ne_zero fun m => ?_
contrapose! hs
simpa only [hs, neg_re, ← ofReal_natCast, ofReal_re, neg_nonpos] using Nat.cast_nonneg _
end Complex
namespace Real
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for real `s`. We
will show that this tends to `Γ(s)` as `n → ∞`. -/
noncomputable def GammaSeq (s : ℝ) (n : ℕ) :=
(n : ℝ) ^ s * n ! / ∏ j ∈ Finset.range (n + 1), (s + j)
/-- Euler's limit formula for the real Gamma function. -/
theorem GammaSeq_tendsto_Gamma (s : ℝ) : Tendsto (GammaSeq s) atTop (𝓝 <| Gamma s) := by
suffices Tendsto ((↑) ∘ GammaSeq s : ℕ → ℂ) atTop (𝓝 <| Complex.Gamma s) by
exact (Complex.continuous_re.tendsto (Complex.Gamma ↑s)).comp this
convert Complex.GammaSeq_tendsto_Gamma s
ext1 n
dsimp only [GammaSeq, Function.comp_apply, Complex.GammaSeq]
push_cast
rw [Complex.ofReal_cpow n.cast_nonneg, Complex.ofReal_natCast]
/-- Euler's reflection formula for the real Gamma function. -/
theorem Gamma_mul_Gamma_one_sub (s : ℝ) : Gamma s * Gamma (1 - s) = π / sin (π * s) := by
simp_rw [← Complex.ofReal_inj, Complex.ofReal_div, Complex.ofReal_sin, Complex.ofReal_mul, ←
Complex.Gamma_ofReal, Complex.ofReal_sub, Complex.ofReal_one]
exact Complex.Gamma_mul_Gamma_one_sub s
end Real
end GammaReflection
section InvGamma
open scoped Real
namespace Complex
/-! ## The reciprocal Gamma function
We show that the reciprocal Gamma function `1 / Γ(s)` is entire. These lemmas show that (in this
case at least) mathlib's conventions for division by zero do actually give a mathematically useful
answer! (These results are useful in the theory of zeta and L-functions.) -/
/-- A reformulation of the Gamma recurrence relation which is true for `s = 0` as well. -/
theorem one_div_Gamma_eq_self_mul_one_div_Gamma_add_one (s : ℂ) :
(Gamma s)⁻¹ = s * (Gamma (s + 1))⁻¹ := by
rcases ne_or_eq s 0 with (h | rfl)
· rw [Gamma_add_one s h, mul_inv, mul_inv_cancel_left₀ h]
· rw [zero_add, Gamma_zero, inv_zero, zero_mul]
/-- The reciprocal of the Gamma function is differentiable everywhere
(including the points where Gamma itself is not). -/
theorem differentiable_one_div_Gamma : Differentiable ℂ fun s : ℂ => (Gamma s)⁻¹ := fun s ↦ by
rcases exists_nat_gt (-s.re) with ⟨n, hs⟩
induction n generalizing s with
| zero =>
rw [Nat.cast_zero, neg_lt_zero] at hs
suffices ∀ m : ℕ, s ≠ -↑m from (differentiableAt_Gamma _ this).inv (Gamma_ne_zero this)
rintro m rfl
apply hs.not_le
simp
| succ n ihn =>
rw [funext one_div_Gamma_eq_self_mul_one_div_Gamma_add_one]
specialize ihn (s + 1) (by rwa [add_re, one_re, neg_add', sub_lt_iff_lt_add, ← Nat.cast_succ])
exact differentiableAt_id.mul (ihn.comp s <| differentiableAt_id.add_const _)
end Complex
end InvGamma
section Doubling
/-!
## The doubling formula for Gamma
We prove the doubling formula for arbitrary real or complex arguments, by analytic continuation from
the positive real case. (Knowing that `Γ⁻¹` is analytic everywhere makes this much simpler, since we
do not have to do any special-case handling for the poles of `Γ`.)
-/
namespace Complex
theorem Gamma_mul_Gamma_add_half (s : ℂ) :
Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * (2 : ℂ) ^ (1 - 2 * s) * ↑(√π) := by
suffices (fun z => (Gamma z)⁻¹ * (Gamma (z + 1 / 2))⁻¹) = fun z =>
(Gamma (2 * z))⁻¹ * (2 : ℂ) ^ (2 * z - 1) / ↑(√π) by
convert congr_arg Inv.inv (congr_fun this s) using 1
· rw [mul_inv, inv_inv, inv_inv]
· rw [div_eq_mul_inv, mul_inv, mul_inv, inv_inv, inv_inv, ← cpow_neg, neg_sub]
have h1 : AnalyticOn ℂ (fun z : ℂ => (Gamma z)⁻¹ * (Gamma (z + 1 / 2))⁻¹) univ := by
refine DifferentiableOn.analyticOn ?_ isOpen_univ
refine (differentiable_one_div_Gamma.mul ?_).differentiableOn
exact differentiable_one_div_Gamma.comp (differentiable_id.add (differentiable_const _))
have h2 : AnalyticOn ℂ
(fun z => (Gamma (2 * z))⁻¹ * (2 : ℂ) ^ (2 * z - 1) / ↑(√π)) univ := by
refine DifferentiableOn.analyticOn ?_ isOpen_univ
refine (Differentiable.mul ?_ (differentiable_const _)).differentiableOn
apply Differentiable.mul
· exact differentiable_one_div_Gamma.comp (differentiable_id'.const_mul _)
· refine fun t => DifferentiableAt.const_cpow ?_ (Or.inl two_ne_zero)
exact DifferentiableAt.sub_const (differentiableAt_id.const_mul _) _
have h3 : Tendsto ((↑) : ℝ → ℂ) (𝓝[≠] 1) (𝓝[≠] 1) := by
rw [tendsto_nhdsWithin_iff]; constructor
· exact tendsto_nhdsWithin_of_tendsto_nhds continuous_ofReal.continuousAt
· exact eventually_nhdsWithin_iff.mpr (eventually_of_forall fun t ht => ofReal_ne_one.mpr ht)
refine AnalyticOn.eq_of_frequently_eq h1 h2 (h3.frequently ?_)
refine ((Eventually.filter_mono nhdsWithin_le_nhds) ?_).frequently
refine (eventually_gt_nhds zero_lt_one).mp (eventually_of_forall fun t ht => ?_)
rw [← mul_inv, Gamma_ofReal, (by norm_num : (t : ℂ) + 1 / 2 = ↑(t + 1 / 2)), Gamma_ofReal, ←
ofReal_mul, Gamma_mul_Gamma_add_half_of_pos ht, ofReal_mul, ofReal_mul, ← Gamma_ofReal,
mul_inv, mul_inv, (by norm_num : 2 * (t : ℂ) = ↑(2 * t)), Gamma_ofReal,
ofReal_cpow zero_le_two, show (2 : ℝ) = (2 : ℂ) by norm_cast, ← cpow_neg, ofReal_sub,
ofReal_one, neg_sub, ← div_eq_mul_inv]
end Complex
namespace Real
open Complex
theorem Gamma_mul_Gamma_add_half (s : ℝ) :
Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * (2 : ℝ) ^ (1 - 2 * s) * √π := by
rw [← ofReal_inj]
simpa only [← Gamma_ofReal, ofReal_cpow zero_le_two, ofReal_mul, ofReal_add, ofReal_div,
ofReal_sub] using Complex.Gamma_mul_Gamma_add_half ↑s
end Real
end Doubling
|
Analysis\SpecialFunctions\Gamma\BohrMollerup.lean | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.SpecialFunctions.Gaussian.GaussianIntegral
/-! # Convexity properties of the Gamma function
In this file, we prove that `Gamma` and `log ∘ Gamma` are convex functions on the positive real
line. We then prove the Bohr-Mollerup theorem, which characterises `Gamma` as the *unique*
positive-real-valued, log-convex function on the positive reals satisfying `f (x + 1) = x f x` and
`f 1 = 1`.
The proof of the Bohr-Mollerup theorem is bound up with the proof of (a weak form of) the Euler
limit formula, `Real.BohrMollerup.tendsto_logGammaSeq`, stating that for positive
real `x` the sequence `x * log n + log n! - ∑ (m : ℕ) ∈ Finset.range (n + 1), log (x + m)`
tends to `log Γ(x)` as `n → ∞`. We prove that any function satisfying the hypotheses of the
Bohr-Mollerup theorem must agree with the limit in the Euler limit formula, so there is at most one
such function; then we show that `Γ` satisfies these conditions.
Since most of the auxiliary lemmas for the Bohr-Mollerup theorem are of no relevance outside the
context of this proof, we place them in a separate namespace `Real.BohrMollerup` to avoid clutter.
(This includes the logarithmic form of the Euler limit formula, since later we will prove a more
general form of the Euler limit formula valid for any real or complex `x`; see
`Real.Gamma_seq_tendsto_Gamma` and `Complex.Gamma_seq_tendsto_Gamma` in the file
`Mathlib/Analysis/SpecialFunctions/Gamma/Beta.lean`.)
As an application of the Bohr-Mollerup theorem we prove the Legendre doubling formula for the
Gamma function for real positive `s` (which will be upgraded to a proof for all complex `s` in a
later file).
TODO: This argument can be extended to prove the general `k`-multiplication formula (at least up
to a constant, and it should be possible to deduce the value of this constant using Stirling's
formula).
-/
noncomputable section
open Filter Set MeasureTheory
open scoped Nat ENNReal Topology Real
namespace Real
section Convexity
/-- Log-convexity of the Gamma function on the positive reals (stated in multiplicative form),
proved using the Hölder inequality applied to Euler's integral. -/
theorem Gamma_mul_add_mul_le_rpow_Gamma_mul_rpow_Gamma {s t a b : ℝ} (hs : 0 < s) (ht : 0 < t)
(ha : 0 < a) (hb : 0 < b) (hab : a + b = 1) :
Gamma (a * s + b * t) ≤ Gamma s ^ a * Gamma t ^ b := by
-- We will apply Hölder's inequality, for the conjugate exponents `p = 1 / a`
-- and `q = 1 / b`, to the functions `f a s` and `f b t`, where `f` is as follows:
let f : ℝ → ℝ → ℝ → ℝ := fun c u x => exp (-c * x) * x ^ (c * (u - 1))
have e : IsConjExponent (1 / a) (1 / b) := Real.isConjExponent_one_div ha hb hab
have hab' : b = 1 - a := by linarith
have hst : 0 < a * s + b * t := add_pos (mul_pos ha hs) (mul_pos hb ht)
-- some properties of f:
have posf : ∀ c u x : ℝ, x ∈ Ioi (0 : ℝ) → 0 ≤ f c u x := fun c u x hx =>
mul_nonneg (exp_pos _).le (rpow_pos_of_pos hx _).le
have posf' : ∀ c u : ℝ, ∀ᵐ x : ℝ ∂volume.restrict (Ioi 0), 0 ≤ f c u x := fun c u =>
(ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ (posf c u))
have fpow :
∀ {c x : ℝ} (_ : 0 < c) (u : ℝ) (_ : 0 < x), exp (-x) * x ^ (u - 1) = f c u x ^ (1 / c) := by
intro c x hc u hx
dsimp only [f]
rw [mul_rpow (exp_pos _).le ((rpow_nonneg hx.le) _), ← exp_mul, ← rpow_mul hx.le]
congr 2 <;> field_simp [hc.ne']; ring
-- show `f c u` is in `ℒp` for `p = 1/c`:
have f_mem_Lp :
∀ {c u : ℝ} (hc : 0 < c) (hu : 0 < u),
Memℒp (f c u) (ENNReal.ofReal (1 / c)) (volume.restrict (Ioi 0)) := by
intro c u hc hu
have A : ENNReal.ofReal (1 / c) ≠ 0 := by
rwa [Ne, ENNReal.ofReal_eq_zero, not_le, one_div_pos]
have B : ENNReal.ofReal (1 / c) ≠ ∞ := ENNReal.ofReal_ne_top
rw [← memℒp_norm_rpow_iff _ A B, ENNReal.toReal_ofReal (one_div_nonneg.mpr hc.le),
ENNReal.div_self A B, memℒp_one_iff_integrable]
· apply Integrable.congr (GammaIntegral_convergent hu)
refine eventuallyEq_of_mem (self_mem_ae_restrict measurableSet_Ioi) fun x hx => ?_
dsimp only
rw [fpow hc u hx]
congr 1
exact (norm_of_nonneg (posf _ _ x hx)).symm
· refine ContinuousOn.aestronglyMeasurable ?_ measurableSet_Ioi
refine (Continuous.continuousOn ?_).mul (ContinuousAt.continuousOn fun x hx => ?_)
· exact continuous_exp.comp (continuous_const.mul continuous_id')
· exact continuousAt_rpow_const _ _ (Or.inl (mem_Ioi.mp hx).ne')
-- now apply Hölder:
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst]
convert
MeasureTheory.integral_mul_le_Lp_mul_Lq_of_nonneg e (posf' a s) (posf' b t) (f_mem_Lp ha hs)
(f_mem_Lp hb ht) using
1
· refine setIntegral_congr measurableSet_Ioi fun x hx => ?_
dsimp only
have A : exp (-x) = exp (-a * x) * exp (-b * x) := by
rw [← exp_add, ← add_mul, ← neg_add, hab, neg_one_mul]
have B : x ^ (a * s + b * t - 1) = x ^ (a * (s - 1)) * x ^ (b * (t - 1)) := by
rw [← rpow_add hx, hab']; congr 1; ring
rw [A, B]
ring
· rw [one_div_one_div, one_div_one_div]
congr 2 <;> exact setIntegral_congr measurableSet_Ioi fun x hx => fpow (by assumption) _ hx
theorem convexOn_log_Gamma : ConvexOn ℝ (Ioi 0) (log ∘ Gamma) := by
refine convexOn_iff_forall_pos.mpr ⟨convex_Ioi _, fun x hx y hy a b ha hb hab => ?_⟩
have : b = 1 - a := by linarith
subst this
simp_rw [Function.comp_apply, smul_eq_mul]
simp only [mem_Ioi] at hx hy
rw [← log_rpow, ← log_rpow, ← log_mul]
· gcongr
exact Gamma_mul_add_mul_le_rpow_Gamma_mul_rpow_Gamma hx hy ha hb hab
all_goals positivity
theorem convexOn_Gamma : ConvexOn ℝ (Ioi 0) Gamma := by
refine
((convexOn_exp.subset (subset_univ _) ?_).comp convexOn_log_Gamma
(exp_monotone.monotoneOn _)).congr
fun x hx => exp_log (Gamma_pos_of_pos hx)
rw [convex_iff_isPreconnected]
refine isPreconnected_Ioi.image _ fun x hx => ContinuousAt.continuousWithinAt ?_
refine (differentiableAt_Gamma fun m => ?_).continuousAt.log (Gamma_pos_of_pos hx).ne'
exact (neg_lt_iff_pos_add.mpr (add_pos_of_pos_of_nonneg (mem_Ioi.mp hx) (Nat.cast_nonneg m))).ne'
end Convexity
section BohrMollerup
namespace BohrMollerup
/-- The function `n ↦ x log n + log n! - (log x + ... + log (x + n))`, which we will show tends to
`log (Gamma x)` as `n → ∞`. -/
def logGammaSeq (x : ℝ) (n : ℕ) : ℝ :=
x * log n + log n ! - ∑ m ∈ Finset.range (n + 1), log (x + m)
variable {f : ℝ → ℝ} {x : ℝ} {n : ℕ}
theorem f_nat_eq (hf_feq : ∀ {y : ℝ}, 0 < y → f (y + 1) = f y + log y) (hn : n ≠ 0) :
f n = f 1 + log (n - 1)! := by
refine Nat.le_induction (by simp) (fun m hm IH => ?_) n (Nat.one_le_iff_ne_zero.2 hn)
have A : 0 < (m : ℝ) := Nat.cast_pos.2 hm
simp only [hf_feq A, Nat.cast_add, Nat.cast_one, Nat.add_succ_sub_one, add_zero]
rw [IH, add_assoc, ← log_mul (Nat.cast_ne_zero.mpr (Nat.factorial_ne_zero _)) A.ne', ←
Nat.cast_mul]
conv_rhs => rw [← Nat.succ_pred_eq_of_pos hm, Nat.factorial_succ, mul_comm]
congr
exact (Nat.succ_pred_eq_of_pos hm).symm
theorem f_add_nat_eq (hf_feq : ∀ {y : ℝ}, 0 < y → f (y + 1) = f y + log y) (hx : 0 < x) (n : ℕ) :
f (x + n) = f x + ∑ m ∈ Finset.range n, log (x + m) := by
induction' n with n hn
· simp
· have : x + n.succ = x + n + 1 := by push_cast; ring
rw [this, hf_feq, hn]
· rw [Finset.range_succ, Finset.sum_insert Finset.not_mem_range_self]
abel
· linarith [(Nat.cast_nonneg n : 0 ≤ (n : ℝ))]
/-- Linear upper bound for `f (x + n)` on unit interval -/
theorem f_add_nat_le (hf_conv : ConvexOn ℝ (Ioi 0) f)
(hf_feq : ∀ {y : ℝ}, 0 < y → f (y + 1) = f y + log y) (hn : n ≠ 0) (hx : 0 < x) (hx' : x ≤ 1) :
f (n + x) ≤ f n + x * log n := by
have hn' : 0 < (n : ℝ) := Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)
have : f n + x * log n = (1 - x) * f n + x * f (n + 1) := by rw [hf_feq hn']; ring
rw [this, (by ring : (n : ℝ) + x = (1 - x) * n + x * (n + 1))]
simpa only [smul_eq_mul] using
hf_conv.2 hn' (by linarith : 0 < (n + 1 : ℝ)) (by linarith : 0 ≤ 1 - x) hx.le (by linarith)
/-- Linear lower bound for `f (x + n)` on unit interval -/
theorem f_add_nat_ge (hf_conv : ConvexOn ℝ (Ioi 0) f)
(hf_feq : ∀ {y : ℝ}, 0 < y → f (y + 1) = f y + log y) (hn : 2 ≤ n) (hx : 0 < x) :
f n + x * log (n - 1) ≤ f (n + x) := by
have npos : 0 < (n : ℝ) - 1 := by rw [← Nat.cast_one, sub_pos, Nat.cast_lt]; linarith
have c :=
(convexOn_iff_slope_mono_adjacent.mp <| hf_conv).2 npos (by linarith : 0 < (n : ℝ) + x)
(by linarith : (n : ℝ) - 1 < (n : ℝ)) (by linarith)
rw [add_sub_cancel_left, sub_sub_cancel, div_one] at c
have : f (↑n - 1) = f n - log (↑n - 1) := by
-- Porting note: was
-- nth_rw_rhs 1 [(by ring : (n : ℝ) = ↑n - 1 + 1)]
-- rw [hf_feq npos, add_sub_cancel]
rw [eq_sub_iff_add_eq, ← hf_feq npos, sub_add_cancel]
rwa [this, le_div_iff hx, sub_sub_cancel, le_sub_iff_add_le, mul_comm _ x, add_comm] at c
theorem logGammaSeq_add_one (x : ℝ) (n : ℕ) :
logGammaSeq (x + 1) n = logGammaSeq x (n + 1) + log x - (x + 1) * (log (n + 1) - log n) := by
dsimp only [Nat.factorial_succ, logGammaSeq]
conv_rhs => rw [Finset.sum_range_succ', Nat.cast_zero, add_zero]
rw [Nat.cast_mul, log_mul]; rotate_left
· rw [Nat.cast_ne_zero]; exact Nat.succ_ne_zero n
· rw [Nat.cast_ne_zero]; exact Nat.factorial_ne_zero n
have :
∑ m ∈ Finset.range (n + 1), log (x + 1 + ↑m) =
∑ k ∈ Finset.range (n + 1), log (x + ↑(k + 1)) := by
congr! 2 with m
push_cast
abel
rw [← this, Nat.cast_add_one n]
ring
theorem le_logGammaSeq (hf_conv : ConvexOn ℝ (Ioi 0) f)
(hf_feq : ∀ {y : ℝ}, 0 < y → f (y + 1) = f y + log y) (hx : 0 < x) (hx' : x ≤ 1) (n : ℕ) :
f x ≤ f 1 + x * log (n + 1) - x * log n + logGammaSeq x n := by
rw [logGammaSeq, ← add_sub_assoc, le_sub_iff_add_le, ← f_add_nat_eq (@hf_feq) hx, add_comm x]
refine (f_add_nat_le hf_conv (@hf_feq) (Nat.add_one_ne_zero n) hx hx').trans (le_of_eq ?_)
rw [f_nat_eq @hf_feq (by linarith : n + 1 ≠ 0), Nat.add_sub_cancel, Nat.cast_add_one]
ring
theorem ge_logGammaSeq (hf_conv : ConvexOn ℝ (Ioi 0) f)
(hf_feq : ∀ {y : ℝ}, 0 < y → f (y + 1) = f y + log y) (hx : 0 < x) (hn : n ≠ 0) :
f 1 + logGammaSeq x n ≤ f x := by
dsimp [logGammaSeq]
rw [← add_sub_assoc, sub_le_iff_le_add, ← f_add_nat_eq (@hf_feq) hx, add_comm x _]
refine le_trans (le_of_eq ?_) (f_add_nat_ge hf_conv @hf_feq ?_ hx)
· rw [f_nat_eq @hf_feq, Nat.add_sub_cancel, Nat.cast_add_one, add_sub_cancel_right]
· ring
· exact Nat.succ_ne_zero _
· omega
theorem tendsto_logGammaSeq_of_le_one (hf_conv : ConvexOn ℝ (Ioi 0) f)
(hf_feq : ∀ {y : ℝ}, 0 < y → f (y + 1) = f y + log y) (hx : 0 < x) (hx' : x ≤ 1) :
Tendsto (logGammaSeq x) atTop (𝓝 <| f x - f 1) := by
refine tendsto_of_tendsto_of_tendsto_of_le_of_le' (f := logGammaSeq x)
(g := fun n ↦ f x - f 1 - x * (log (n + 1) - log n)) ?_ tendsto_const_nhds ?_ ?_
· have : f x - f 1 = f x - f 1 - x * 0 := by ring
nth_rw 2 [this]
exact Tendsto.sub tendsto_const_nhds (tendsto_log_nat_add_one_sub_log.const_mul _)
· filter_upwards with n
rw [sub_le_iff_le_add', sub_le_iff_le_add']
convert le_logGammaSeq hf_conv (@hf_feq) hx hx' n using 1
ring
· show ∀ᶠ n : ℕ in atTop, logGammaSeq x n ≤ f x - f 1
filter_upwards [eventually_ne_atTop 0] with n hn using
le_sub_iff_add_le'.mpr (ge_logGammaSeq hf_conv hf_feq hx hn)
theorem tendsto_logGammaSeq (hf_conv : ConvexOn ℝ (Ioi 0) f)
(hf_feq : ∀ {y : ℝ}, 0 < y → f (y + 1) = f y + log y) (hx : 0 < x) :
Tendsto (logGammaSeq x) atTop (𝓝 <| f x - f 1) := by
suffices ∀ m : ℕ, ↑m < x → x ≤ m + 1 → Tendsto (logGammaSeq x) atTop (𝓝 <| f x - f 1) by
refine this ⌈x - 1⌉₊ ?_ ?_
· rcases lt_or_le x 1 with ⟨⟩
· rwa [Nat.ceil_eq_zero.mpr (by linarith : x - 1 ≤ 0), Nat.cast_zero]
· convert Nat.ceil_lt_add_one (by linarith : 0 ≤ x - 1)
abel
· rw [← sub_le_iff_le_add]; exact Nat.le_ceil _
intro m
induction' m with m hm generalizing x
· rw [Nat.cast_zero, zero_add]
exact fun _ hx' => tendsto_logGammaSeq_of_le_one hf_conv (@hf_feq) hx hx'
· intro hy hy'
rw [Nat.cast_succ, ← sub_le_iff_le_add] at hy'
rw [Nat.cast_succ, ← lt_sub_iff_add_lt] at hy
specialize hm ((Nat.cast_nonneg _).trans_lt hy) hy hy'
-- now massage gauss_product n (x - 1) into gauss_product (n - 1) x
have :
∀ᶠ n : ℕ in atTop,
logGammaSeq (x - 1) n =
logGammaSeq x (n - 1) + x * (log (↑(n - 1) + 1) - log ↑(n - 1)) - log (x - 1) := by
refine Eventually.mp (eventually_ge_atTop 1) (eventually_of_forall fun n hn => ?_)
have := logGammaSeq_add_one (x - 1) (n - 1)
rw [sub_add_cancel, Nat.sub_add_cancel hn] at this
rw [this]
ring
replace hm :=
((Tendsto.congr' this hm).add (tendsto_const_nhds : Tendsto (fun _ => log (x - 1)) _ _)).comp
(tendsto_add_atTop_nat 1)
have :
((fun x_1 : ℕ =>
(fun n : ℕ =>
logGammaSeq x (n - 1) + x * (log (↑(n - 1) + 1) - log ↑(n - 1)) - log (x - 1))
x_1 +
(fun b : ℕ => log (x - 1)) x_1) ∘
fun a : ℕ => a + 1) =
fun n => logGammaSeq x n + x * (log (↑n + 1) - log ↑n) := by
ext1 n
dsimp only [Function.comp_apply]
rw [sub_add_cancel, Nat.add_sub_cancel]
rw [this] at hm
convert hm.sub (tendsto_log_nat_add_one_sub_log.const_mul x) using 2
· ring
· have := hf_feq ((Nat.cast_nonneg m).trans_lt hy)
rw [sub_add_cancel] at this
rw [this]
ring
theorem tendsto_log_gamma {x : ℝ} (hx : 0 < x) :
Tendsto (logGammaSeq x) atTop (𝓝 <| log (Gamma x)) := by
have : log (Gamma x) = (log ∘ Gamma) x - (log ∘ Gamma) 1 := by
simp_rw [Function.comp_apply, Gamma_one, log_one, sub_zero]
rw [this]
refine BohrMollerup.tendsto_logGammaSeq convexOn_log_Gamma (fun {y} hy => ?_) hx
rw [Function.comp_apply, Gamma_add_one hy.ne', log_mul hy.ne' (Gamma_pos_of_pos hy).ne', add_comm,
Function.comp_apply]
end BohrMollerup
-- (namespace)
/-- The **Bohr-Mollerup theorem**: the Gamma function is the *unique* log-convex, positive-valued
function on the positive reals which satisfies `f 1 = 1` and `f (x + 1) = x * f x` for all `x`. -/
theorem eq_Gamma_of_log_convex {f : ℝ → ℝ} (hf_conv : ConvexOn ℝ (Ioi 0) (log ∘ f))
(hf_feq : ∀ {y : ℝ}, 0 < y → f (y + 1) = y * f y) (hf_pos : ∀ {y : ℝ}, 0 < y → 0 < f y)
(hf_one : f 1 = 1) : EqOn f Gamma (Ioi (0 : ℝ)) := by
suffices EqOn (log ∘ f) (log ∘ Gamma) (Ioi (0 : ℝ)) from
fun x hx ↦ log_injOn_pos (hf_pos hx) (Gamma_pos_of_pos hx) (this hx)
intro x hx
have e1 := BohrMollerup.tendsto_logGammaSeq hf_conv ?_ hx
· rw [Function.comp_apply (f := log) (g := f) (x := 1), hf_one, log_one, sub_zero] at e1
exact tendsto_nhds_unique e1 (BohrMollerup.tendsto_log_gamma hx)
· intro y hy
rw [Function.comp_apply, Function.comp_apply, hf_feq hy, log_mul hy.ne' (hf_pos hy).ne']
ring
end BohrMollerup
-- (section)
section StrictMono
theorem Gamma_two : Gamma 2 = 1 := by simp [Nat.factorial_one]
theorem Gamma_three_div_two_lt_one : Gamma (3 / 2) < 1 := by
-- This can also be proved using the closed-form evaluation of `Gamma (1 / 2)` in
-- `Mathlib/Analysis/SpecialFunctions/Gaussian.lean`, but we give a self-contained proof using
-- log-convexity to avoid unnecessary imports.
have A : (0 : ℝ) < 3 / 2 := by norm_num
have :=
BohrMollerup.f_add_nat_le convexOn_log_Gamma (fun {y} hy => ?_) two_ne_zero one_half_pos
(by norm_num : 1 / 2 ≤ (1 : ℝ))
swap
· rw [Function.comp_apply, Gamma_add_one hy.ne', log_mul hy.ne' (Gamma_pos_of_pos hy).ne',
add_comm, Function.comp_apply]
rw [Function.comp_apply, Function.comp_apply, Nat.cast_two, Gamma_two, log_one, zero_add,
(by norm_num : (2 : ℝ) + 1 / 2 = 3 / 2 + 1), Gamma_add_one A.ne',
log_mul A.ne' (Gamma_pos_of_pos A).ne', ← le_sub_iff_add_le',
log_le_iff_le_exp (Gamma_pos_of_pos A)] at this
refine this.trans_lt (exp_lt_one_iff.mpr ?_)
rw [mul_comm, ← mul_div_assoc, div_sub' _ _ (2 : ℝ) two_ne_zero]
refine div_neg_of_neg_of_pos ?_ two_pos
rw [sub_neg, mul_one, ← Nat.cast_two, ← log_pow, ← exp_lt_exp, Nat.cast_two, exp_log two_pos,
exp_log] <;>
norm_num
theorem Gamma_strictMonoOn_Ici : StrictMonoOn Gamma (Ici 2) := by
convert
convexOn_Gamma.strict_mono_of_lt (by norm_num : (0 : ℝ) < 3 / 2)
(by norm_num : (3 / 2 : ℝ) < 2) (Gamma_two.symm ▸ Gamma_three_div_two_lt_one)
symm
rw [inter_eq_right]
exact fun x hx => two_pos.trans_le <| mem_Ici.mp hx
end StrictMono
section Doubling
/-!
## The Gamma doubling formula
As a fun application of the Bohr-Mollerup theorem, we prove the Gamma-function doubling formula
(for positive real `s`). The idea is that `2 ^ s * Gamma (s / 2) * Gamma (s / 2 + 1 / 2)` is
log-convex and satisfies the Gamma functional equation, so it must actually be a constant
multiple of `Gamma`, and we can compute the constant by specialising at `s = 1`. -/
/-- Auxiliary definition for the doubling formula (we'll show this is equal to `Gamma s`) -/
def doublingGamma (s : ℝ) : ℝ :=
Gamma (s / 2) * Gamma (s / 2 + 1 / 2) * 2 ^ (s - 1) / √π
theorem doublingGamma_add_one (s : ℝ) (hs : s ≠ 0) :
doublingGamma (s + 1) = s * doublingGamma s := by
rw [doublingGamma, doublingGamma, (by abel : s + 1 - 1 = s - 1 + 1), add_div, add_assoc,
add_halves (1 : ℝ), Gamma_add_one (div_ne_zero hs two_ne_zero), rpow_add two_pos, rpow_one]
ring
theorem doublingGamma_one : doublingGamma 1 = 1 := by
simp_rw [doublingGamma, Gamma_one_half_eq, add_halves (1 : ℝ), sub_self, Gamma_one, mul_one,
rpow_zero, mul_one, div_self (sqrt_ne_zero'.mpr pi_pos)]
theorem log_doublingGamma_eq :
EqOn (log ∘ doublingGamma)
(fun s => log (Gamma (s / 2)) + log (Gamma (s / 2 + 1 / 2)) + s * log 2 - log (2 * √π))
(Ioi 0) := by
intro s hs
have h1 : √π ≠ 0 := sqrt_ne_zero'.mpr pi_pos
have h2 : Gamma (s / 2) ≠ 0 := (Gamma_pos_of_pos <| div_pos hs two_pos).ne'
have h3 : Gamma (s / 2 + 1 / 2) ≠ 0 :=
(Gamma_pos_of_pos <| add_pos (div_pos hs two_pos) one_half_pos).ne'
have h4 : (2 : ℝ) ^ (s - 1) ≠ 0 := (rpow_pos_of_pos two_pos _).ne'
rw [Function.comp_apply, doublingGamma, log_div (mul_ne_zero (mul_ne_zero h2 h3) h4) h1,
log_mul (mul_ne_zero h2 h3) h4, log_mul h2 h3, log_rpow two_pos, log_mul two_ne_zero h1]
ring_nf
theorem doublingGamma_log_convex_Ioi : ConvexOn ℝ (Ioi (0 : ℝ)) (log ∘ doublingGamma) := by
refine (((ConvexOn.add ?_ ?_).add ?_).add_const _).congr log_doublingGamma_eq.symm
· convert
convexOn_log_Gamma.comp_affineMap (DistribMulAction.toLinearMap ℝ ℝ (1 / 2 : ℝ)).toAffineMap
using 1
· simpa only [zero_div] using (preimage_const_mul_Ioi (0 : ℝ) one_half_pos).symm
· ext1 x
-- Porting note: was
-- change log (Gamma (x / 2)) = log (Gamma ((1 / 2 : ℝ) • x))
simp only [LinearMap.coe_toAffineMap, Function.comp_apply, DistribMulAction.toLinearMap_apply]
rw [smul_eq_mul, mul_comm, mul_one_div]
· refine ConvexOn.subset ?_ (Ioi_subset_Ioi <| neg_one_lt_zero.le) (convex_Ioi _)
convert
convexOn_log_Gamma.comp_affineMap
((DistribMulAction.toLinearMap ℝ ℝ (1 / 2 : ℝ)).toAffineMap +
AffineMap.const ℝ ℝ (1 / 2 : ℝ)) using 1
· change Ioi (-1 : ℝ) = ((fun x : ℝ => x + 1 / 2) ∘ fun x : ℝ => (1 / 2 : ℝ) * x) ⁻¹' Ioi 0
rw [preimage_comp, preimage_add_const_Ioi, zero_sub,
preimage_const_mul_Ioi (_ : ℝ) one_half_pos, neg_div, div_self (@one_half_pos ℝ _).ne']
· ext1 x
change log (Gamma (x / 2 + 1 / 2)) = log (Gamma ((1 / 2 : ℝ) • x + 1 / 2))
rw [smul_eq_mul, mul_comm, mul_one_div]
· simpa only [mul_comm _ (log _)] using
(convexOn_id (convex_Ioi (0 : ℝ))).smul (log_pos one_lt_two).le
theorem doublingGamma_eq_Gamma {s : ℝ} (hs : 0 < s) : doublingGamma s = Gamma s := by
refine
eq_Gamma_of_log_convex doublingGamma_log_convex_Ioi
(fun {y} hy => doublingGamma_add_one y hy.ne') (fun {y} hy => ?_) doublingGamma_one hs
apply_rules [mul_pos, Gamma_pos_of_pos, add_pos, inv_pos_of_pos, rpow_pos_of_pos, two_pos,
one_pos, sqrt_pos_of_pos pi_pos]
/-- Legendre's doubling formula for the Gamma function, for positive real arguments. Note that
we shall later prove this for all `s` as `Real.Gamma_mul_Gamma_add_half` (superseding this result)
but this result is needed as an intermediate step. -/
theorem Gamma_mul_Gamma_add_half_of_pos {s : ℝ} (hs : 0 < s) :
Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * √π := by
rw [← doublingGamma_eq_Gamma (mul_pos two_pos hs), doublingGamma,
mul_div_cancel_left₀ _ (two_ne_zero' ℝ), (by abel : 1 - 2 * s = -(2 * s - 1)),
rpow_neg zero_le_two]
field_simp [(sqrt_pos_of_pos pi_pos).ne', (rpow_pos_of_pos two_pos (2 * s - 1)).ne']
ring
end Doubling
end Real
|
Analysis\SpecialFunctions\Gamma\Deligne.lean | /-
Copyright (c) 2024 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.SpecialFunctions.Gamma.Beta
/-!
# Deligne's archimedean Gamma-factors
In the theory of L-series one frequently encounters the following functions (of a complex variable
`s`) introduced in Deligne's landmark paper *Valeurs de fonctions L et periodes d'integrales*:
$$ \Gamma_{\mathbb{R}}(s) = \pi ^ {-s / 2} \Gamma (s / 2) $$
and
$$ \Gamma_{\mathbb{C}}(s) = 2 (2 \pi) ^ {-s} \Gamma (s). $$
These are the factors that need to be included in the Dedekind zeta function of a number field
for each real, resp. complex, infinite place.
(Note that these are *not* the same as Mathlib's `Real.Gamma` vs. `Complex.Gamma`; Deligne's
functions both take a complex variable as input.)
This file defines these functions, and proves some elementary properties, including a reflection
formula which is an important input in functional equations of (un-completed) Dirichlet L-functions.
-/
open Filter Topology Asymptotics Real Set MeasureTheory
open Complex hiding abs_of_nonneg
namespace Complex
/-- Deligne's archimedean Gamma factor for a real infinite place.
See "Valeurs de fonctions L et periodes d'integrales" § 5.3. Note that this is not the same as
`Real.Gamma`; in particular it is a function `ℂ → ℂ`. -/
noncomputable def Gammaℝ (s : ℂ) := π ^ (-s / 2) * Gamma (s / 2)
lemma Gammaℝ_def (s : ℂ) : Gammaℝ s = π ^ (-s / 2) * Gamma (s / 2) := rfl
/-- Deligne's archimedean Gamma factor for a complex infinite place.
See "Valeurs de fonctions L et periodes d'integrales" § 5.3. (Some authors omit the factor of 2).
Note that this is not the same as `Complex.Gamma`. -/
noncomputable def Gammaℂ (s : ℂ) := 2 * (2 * π) ^ (-s) * Gamma s
lemma Gammaℂ_def (s : ℂ) : Gammaℂ s = 2 * (2 * π) ^ (-s) * Gamma s := rfl
lemma Gammaℝ_add_two {s : ℂ} (hs : s ≠ 0) : Gammaℝ (s + 2) = Gammaℝ s * s / 2 / π := by
rw [Gammaℝ_def, Gammaℝ_def, neg_div, add_div, neg_add, div_self two_ne_zero,
Gamma_add_one _ (div_ne_zero hs two_ne_zero),
cpow_add _ _ (ofReal_ne_zero.mpr pi_ne_zero), cpow_neg_one]
field_simp [pi_ne_zero]
ring
lemma Gammaℂ_add_one {s : ℂ} (hs : s ≠ 0) : Gammaℂ (s + 1) = Gammaℂ s * s / 2 / π := by
rw [Gammaℂ_def, Gammaℂ_def, Gamma_add_one _ hs, neg_add,
cpow_add _ _ (mul_ne_zero two_ne_zero (ofReal_ne_zero.mpr pi_ne_zero)), cpow_neg_one]
field_simp [pi_ne_zero]
ring
lemma Gammaℝ_ne_zero_of_re_pos {s : ℂ} (hs : 0 < re s) : Gammaℝ s ≠ 0 := by
apply mul_ne_zero
· simp [pi_ne_zero]
· apply Gamma_ne_zero_of_re_pos
rw [div_ofNat_re]
exact div_pos hs two_pos
lemma Gammaℝ_eq_zero_iff {s : ℂ} : Gammaℝ s = 0 ↔ ∃ n : ℕ, s = -(2 * n) := by
simp [Gammaℝ_def, Complex.Gamma_eq_zero_iff, pi_ne_zero, div_eq_iff (two_ne_zero' ℂ), mul_comm]
@[simp]
lemma Gammaℝ_one : Gammaℝ 1 = 1 := by
rw [Gammaℝ_def, Complex.Gamma_one_half_eq]
simp [neg_div, cpow_neg, inv_mul_cancel, pi_ne_zero]
@[simp]
lemma Gammaℂ_one : Gammaℂ 1 = 1 / π := by
rw [Gammaℂ_def, cpow_neg_one, Complex.Gamma_one]
field_simp [pi_ne_zero]
section analyticity
lemma differentiable_Gammaℝ_inv : Differentiable ℂ (fun s ↦ (Gammaℝ s)⁻¹) := by
conv => enter [2, s]; rw [Gammaℝ, mul_inv]
refine Differentiable.mul (fun s ↦ .inv ?_ (by simp [pi_ne_zero])) ?_
· refine ((differentiableAt_id.neg.div_const (2 : ℂ)).const_cpow ?_)
exact Or.inl (ofReal_ne_zero.mpr pi_ne_zero)
· exact differentiable_one_div_Gamma.comp (differentiable_id.div_const _)
lemma Gammaℝ_residue_zero : Tendsto (fun s ↦ s * Gammaℝ s) (𝓝[≠] 0) (𝓝 2) := by
have h : Tendsto (fun z : ℂ ↦ z / 2 * Gamma (z / 2)) (𝓝[≠] 0) (𝓝 1) := by
refine tendsto_self_mul_Gamma_nhds_zero.comp ?_
rw [tendsto_nhdsWithin_iff, (by simp : 𝓝 (0 : ℂ) = 𝓝 (0 / 2))]
exact ⟨(tendsto_id.div_const _).mono_left nhdsWithin_le_nhds,
eventually_of_mem self_mem_nhdsWithin fun x hx ↦ div_ne_zero hx two_ne_zero⟩
have h' : Tendsto (fun s : ℂ ↦ 2 * (π : ℂ) ^ (-s / 2)) (𝓝[≠] 0) (𝓝 2) := by
rw [(by simp : 𝓝 2 = 𝓝 (2 * (π : ℂ) ^ (-(0 : ℂ) / 2)))]
refine Tendsto.mono_left (ContinuousAt.tendsto ?_) nhdsWithin_le_nhds
exact continuousAt_const.mul ((continuousAt_const_cpow (ofReal_ne_zero.mpr pi_ne_zero)).comp
(continuousAt_id.neg.div_const _))
convert mul_one (2 : ℂ) ▸ (h'.mul h) using 2 with z
rw [Gammaℝ]
ring_nf
end analyticity
section reflection
/-- Reformulation of the doubling formula in terms of `Gammaℝ`. -/
lemma Gammaℝ_mul_Gammaℝ_add_one (s : ℂ) : Gammaℝ s * Gammaℝ (s + 1) = Gammaℂ s := by
simp only [Gammaℝ_def, Gammaℂ_def]
calc
_ = (π ^ (-s / 2) * π ^ (-(s + 1) / 2)) * (Gamma (s / 2) * Gamma (s / 2 + 1 / 2)) := by ring_nf
_ = 2 ^ (1 - s) * (π ^ (-1 / 2 - s) * π ^ (1 / 2 : ℂ)) * Gamma s := by
rw [← cpow_add _ _ (ofReal_ne_zero.mpr pi_ne_zero), Complex.Gamma_mul_Gamma_add_half,
sqrt_eq_rpow, ofReal_cpow pi_pos.le, ofReal_div, ofReal_one, ofReal_ofNat]
ring_nf
_ = 2 * ((2 : ℝ) ^ (-s) * π ^ (-s)) * Gamma s := by
rw [sub_eq_add_neg, cpow_add _ _ two_ne_zero, cpow_one,
← cpow_add _ _ (ofReal_ne_zero.mpr pi_ne_zero), ofReal_ofNat]
ring_nf
_ = 2 * (2 * π) ^ (-s) * Gamma s := by
rw [← mul_cpow_ofReal_nonneg two_pos.le pi_pos.le, ofReal_ofNat]
/-- Reformulation of the reflection formula in terms of `Gammaℝ`. -/
lemma Gammaℝ_one_sub_mul_Gammaℝ_one_add (s : ℂ) :
Gammaℝ (1 - s) * Gammaℝ (1 + s) = (cos (π * s / 2))⁻¹ :=
calc Gammaℝ (1 - s) * Gammaℝ (1 + s)
_ = (π ^ ((s - 1) / 2) * π ^ ((-1 - s) / 2)) *
(Gamma ((1 - s) / 2) * Gamma (1 - (1 - s) / 2)) := by
simp only [Gammaℝ_def]
ring_nf
_ = (π ^ ((s - 1) / 2) * π ^ ((-1 - s) / 2) * π ^ (1 : ℂ)) / sin (π / 2 - π * s / 2) := by
rw [Complex.Gamma_mul_Gamma_one_sub, cpow_one]
ring_nf
_ = _ := by
simp_rw [← cpow_add _ _ (ofReal_ne_zero.mpr pi_ne_zero),
Complex.sin_pi_div_two_sub]
ring_nf
rw [cpow_zero, one_mul]
/-- Another formulation of the reflection formula in terms of `Gammaℝ`. -/
lemma Gammaℝ_div_Gammaℝ_one_sub {s : ℂ} (hs : ∀ (n : ℕ), s ≠ -(2 * n + 1)) :
Gammaℝ s / Gammaℝ (1 - s) = Gammaℂ s * cos (π * s / 2) := by
have : Gammaℝ (s + 1) ≠ 0 := by
simpa only [Ne, Gammaℝ_eq_zero_iff, not_exists, ← eq_sub_iff_add_eq,
sub_eq_add_neg, ← neg_add]
calc Gammaℝ s / Gammaℝ (1 - s)
_ = (Gammaℝ s * Gammaℝ (s + 1)) / (Gammaℝ (1 - s) * Gammaℝ (1 + s)) := by
rw [add_comm 1 s, mul_comm (Gammaℝ (1 - s)) (Gammaℝ (s + 1)), ← div_div,
mul_div_cancel_right₀ _ this]
_ = (2 * (2 * π) ^ (-s) * Gamma s) / ((cos (π * s / 2))⁻¹) := by
rw [Gammaℝ_one_sub_mul_Gammaℝ_one_add, Gammaℝ_mul_Gammaℝ_add_one, Gammaℂ_def]
_ = _ := by rw [Gammaℂ_def, div_eq_mul_inv, inv_inv]
/-- Formulation of reflection formula tailored to functional equations of L-functions of even
Dirichlet characters (including Riemann zeta). -/
lemma inv_Gammaℝ_one_sub {s : ℂ} (hs : ∀ (n : ℕ), s ≠ -n) :
(Gammaℝ (1 - s))⁻¹ = Gammaℂ s * cos (π * s / 2) * (Gammaℝ s)⁻¹ := by
have h1 : Gammaℝ s ≠ 0 := by
rw [Ne, Gammaℝ_eq_zero_iff, not_exists]
intro n h
specialize hs (2 * n)
simp_all
have h2 : ∀ (n : ℕ), s ≠ -(2 * ↑n + 1) := by
intro n h
specialize hs (2 * n + 1)
simp_all
rw [← Gammaℝ_div_Gammaℝ_one_sub h2, ← div_eq_mul_inv, div_right_comm, div_self h1, one_div]
/-- Formulation of reflection formula tailored to functional equations of L-functions of odd
Dirichlet characters. -/
lemma inv_Gammaℝ_two_sub {s : ℂ} (hs : ∀ (n : ℕ), s ≠ -n) :
(Gammaℝ (2 - s))⁻¹ = Gammaℂ s * sin (π * s / 2) * (Gammaℝ (s + 1))⁻¹ := by
by_cases h : s = 1
· rw [h, (by ring : 2 - 1 = (1 : ℂ)), Gammaℝ_one, Gammaℝ,
neg_div, (by norm_num : (1 + 1) / 2 = (1 : ℂ)), Complex.Gamma_one, Gammaℂ_one,
mul_one, Complex.sin_pi_div_two, mul_one, cpow_neg_one, mul_one, inv_inv,
div_mul_cancel₀ _ (ofReal_ne_zero.mpr pi_ne_zero), inv_one]
rw [← Ne, ← sub_ne_zero] at h
have h' (n : ℕ) : s - 1 ≠ -n := by
cases' n with m
· rwa [Nat.cast_zero, neg_zero]
· rw [Ne, sub_eq_iff_eq_add]
convert hs m using 2
push_cast
ring
rw [(by ring : 2 - s = 1 - (s - 1)), inv_Gammaℝ_one_sub h',
(by rw [sub_add_cancel] : Gammaℂ s = Gammaℂ (s - 1 + 1)), Gammaℂ_add_one h,
(by ring : s + 1 = (s - 1) + 2), Gammaℝ_add_two h, mul_sub, sub_div, mul_one,
Complex.cos_sub_pi_div_two]
simp_rw [mul_div_assoc, mul_inv]
generalize (Gammaℝ (s - 1))⁻¹ = A
field_simp [pi_ne_zero]
ring
end reflection
end Complex
|
Analysis\SpecialFunctions\Gaussian\FourierTransform.lean | /-
Copyright (c) 2022 Sébastien Gouëzel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sébastien Gouëzel
-/
import Mathlib.Analysis.SpecialFunctions.Gaussian.GaussianIntegral
import Mathlib.Analysis.Complex.CauchyIntegral
import Mathlib.MeasureTheory.Integral.Pi
import Mathlib.Analysis.Fourier.FourierTransform
/-!
# Fourier transform of the Gaussian
We prove that the Fourier transform of the Gaussian function is another Gaussian:
* `integral_cexp_quadratic`: general formula for `∫ (x : ℝ), exp (b * x ^ 2 + c * x + d)`
* `fourierIntegral_gaussian`: for all complex `b` and `t` with `0 < re b`, we have
`∫ x:ℝ, exp (I * t * x) * exp (-b * x^2) = (π / b) ^ (1 / 2) * exp (-t ^ 2 / (4 * b))`.
* `fourierIntegral_gaussian_pi`: a variant with `b` and `t` scaled to give a more symmetric
statement, and formulated in terms of the Fourier transform operator `𝓕`.
We also give versions of these formulas in finite-dimensional inner product spaces, see
`integral_cexp_neg_mul_sq_norm_add` and `fourierIntegral_gaussian_innerProductSpace`.
-/
/-!
## Fourier integral of Gaussian functions
-/
open Real Set MeasureTheory Filter Asymptotics intervalIntegral
open scoped Real Topology FourierTransform RealInnerProductSpace
open Complex hiding exp continuous_exp abs_of_nonneg sq_abs
noncomputable section
namespace GaussianFourier
variable {b : ℂ}
/-- The integral of the Gaussian function over the vertical edges of a rectangle
with vertices at `(±T, 0)` and `(±T, c)`. -/
def verticalIntegral (b : ℂ) (c T : ℝ) : ℂ :=
∫ y : ℝ in (0 : ℝ)..c, I * (cexp (-b * (T + y * I) ^ 2) - cexp (-b * (T - y * I) ^ 2))
/-- Explicit formula for the norm of the Gaussian function along the vertical
edges. -/
theorem norm_cexp_neg_mul_sq_add_mul_I (b : ℂ) (c T : ℝ) :
‖cexp (-b * (T + c * I) ^ 2)‖ = exp (-(b.re * T ^ 2 - 2 * b.im * c * T - b.re * c ^ 2)) := by
rw [Complex.norm_eq_abs, Complex.abs_exp, neg_mul, neg_re, ← re_add_im b]
simp only [sq, re_add_im, mul_re, mul_im, add_re, add_im, ofReal_re, ofReal_im, I_re, I_im]
ring_nf
theorem norm_cexp_neg_mul_sq_add_mul_I' (hb : b.re ≠ 0) (c T : ℝ) :
‖cexp (-b * (T + c * I) ^ 2)‖ =
exp (-(b.re * (T - b.im * c / b.re) ^ 2 - c ^ 2 * (b.im ^ 2 / b.re + b.re))) := by
have :
b.re * T ^ 2 - 2 * b.im * c * T - b.re * c ^ 2 =
b.re * (T - b.im * c / b.re) ^ 2 - c ^ 2 * (b.im ^ 2 / b.re + b.re) := by
field_simp; ring
rw [norm_cexp_neg_mul_sq_add_mul_I, this]
theorem verticalIntegral_norm_le (hb : 0 < b.re) (c : ℝ) {T : ℝ} (hT : 0 ≤ T) :
‖verticalIntegral b c T‖ ≤
(2 : ℝ) * |c| * exp (-(b.re * T ^ 2 - (2 : ℝ) * |b.im| * |c| * T - b.re * c ^ 2)) := by
-- first get uniform bound for integrand
have vert_norm_bound :
∀ {T : ℝ},
0 ≤ T →
∀ {c y : ℝ},
|y| ≤ |c| →
‖cexp (-b * (T + y * I) ^ 2)‖ ≤
exp (-(b.re * T ^ 2 - (2 : ℝ) * |b.im| * |c| * T - b.re * c ^ 2)) := by
intro T hT c y hy
rw [norm_cexp_neg_mul_sq_add_mul_I b]
gcongr exp (- (_ - ?_ * _ - _ * ?_))
· (conv_lhs => rw [mul_assoc]); (conv_rhs => rw [mul_assoc])
gcongr _ * ?_
refine (le_abs_self _).trans ?_
rw [abs_mul]
gcongr
· rwa [sq_le_sq]
-- now main proof
apply (intervalIntegral.norm_integral_le_of_norm_le_const _).trans
· rw [sub_zero]
conv_lhs => simp only [mul_comm _ |c|]
conv_rhs =>
conv =>
congr
rw [mul_comm]
rw [mul_assoc]
· intro y hy
have absy : |y| ≤ |c| := by
rcases le_or_lt 0 c with (h | h)
· rw [uIoc_of_le h] at hy
rw [abs_of_nonneg h, abs_of_pos hy.1]
exact hy.2
· rw [uIoc_of_ge h.le] at hy
rw [abs_of_neg h, abs_of_nonpos hy.2, neg_le_neg_iff]
exact hy.1.le
rw [norm_mul, Complex.norm_eq_abs, abs_I, one_mul, two_mul]
refine (norm_sub_le _ _).trans (add_le_add (vert_norm_bound hT absy) ?_)
rw [← abs_neg y] at absy
simpa only [neg_mul, ofReal_neg] using vert_norm_bound hT absy
theorem tendsto_verticalIntegral (hb : 0 < b.re) (c : ℝ) :
Tendsto (verticalIntegral b c) atTop (𝓝 0) := by
-- complete proof using squeeze theorem:
rw [tendsto_zero_iff_norm_tendsto_zero]
refine
tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_const_nhds ?_
(eventually_of_forall fun _ => norm_nonneg _)
((eventually_ge_atTop (0 : ℝ)).mp
(eventually_of_forall fun T hT => verticalIntegral_norm_le hb c hT))
rw [(by ring : 0 = 2 * |c| * 0)]
refine (tendsto_exp_atBot.comp (tendsto_neg_atTop_atBot.comp ?_)).const_mul _
apply tendsto_atTop_add_const_right
simp_rw [sq, ← mul_assoc, ← sub_mul]
refine Tendsto.atTop_mul_atTop (tendsto_atTop_add_const_right _ _ ?_) tendsto_id
exact (tendsto_const_mul_atTop_of_pos hb).mpr tendsto_id
theorem integrable_cexp_neg_mul_sq_add_real_mul_I (hb : 0 < b.re) (c : ℝ) :
Integrable fun x : ℝ => cexp (-b * (x + c * I) ^ 2) := by
refine
⟨(Complex.continuous_exp.comp
(continuous_const.mul
((continuous_ofReal.add continuous_const).pow 2))).aestronglyMeasurable,
?_⟩
rw [← hasFiniteIntegral_norm_iff]
simp_rw [norm_cexp_neg_mul_sq_add_mul_I' hb.ne', neg_sub _ (c ^ 2 * _),
sub_eq_add_neg _ (b.re * _), Real.exp_add]
suffices Integrable fun x : ℝ => exp (-(b.re * x ^ 2)) by
exact (Integrable.comp_sub_right this (b.im * c / b.re)).hasFiniteIntegral.const_mul _
simp_rw [← neg_mul]
apply integrable_exp_neg_mul_sq hb
theorem integral_cexp_neg_mul_sq_add_real_mul_I (hb : 0 < b.re) (c : ℝ) :
∫ x : ℝ, cexp (-b * (x + c * I) ^ 2) = (π / b) ^ (1 / 2 : ℂ) := by
refine
tendsto_nhds_unique
(intervalIntegral_tendsto_integral (integrable_cexp_neg_mul_sq_add_real_mul_I hb c)
tendsto_neg_atTop_atBot tendsto_id)
?_
set I₁ := fun T => ∫ x : ℝ in -T..T, cexp (-b * (x + c * I) ^ 2) with HI₁
let I₂ := fun T : ℝ => ∫ x : ℝ in -T..T, cexp (-b * (x : ℂ) ^ 2)
let I₄ := fun T : ℝ => ∫ y : ℝ in (0 : ℝ)..c, cexp (-b * (T + y * I) ^ 2)
let I₅ := fun T : ℝ => ∫ y : ℝ in (0 : ℝ)..c, cexp (-b * (-T + y * I) ^ 2)
have C : ∀ T : ℝ, I₂ T - I₁ T + I * I₄ T - I * I₅ T = 0 := by
intro T
have :=
integral_boundary_rect_eq_zero_of_differentiableOn (fun z => cexp (-b * z ^ 2)) (-T)
(T + c * I)
(by
refine Differentiable.differentiableOn (Differentiable.const_mul ?_ _).cexp
exact differentiable_pow 2)
simpa only [neg_im, ofReal_im, neg_zero, ofReal_zero, zero_mul, add_zero, neg_re,
ofReal_re, add_re, mul_re, I_re, mul_zero, I_im, tsub_zero, add_im, mul_im,
mul_one, zero_add, Algebra.id.smul_eq_mul, ofReal_neg] using this
simp_rw [id, ← HI₁]
have : I₁ = fun T : ℝ => I₂ T + verticalIntegral b c T := by
ext1 T
specialize C T
rw [sub_eq_zero] at C
unfold verticalIntegral
rw [integral_const_mul, intervalIntegral.integral_sub]
· simp_rw [(fun a b => by rw [sq]; ring_nf : ∀ a b : ℂ, (a - b * I) ^ 2 = (-a + b * I) ^ 2)]
change I₁ T = I₂ T + I * (I₄ T - I₅ T)
rw [mul_sub, ← C]
abel
all_goals apply Continuous.intervalIntegrable; continuity
rw [this, ← add_zero ((π / b : ℂ) ^ (1 / 2 : ℂ)), ← integral_gaussian_complex hb]
refine Tendsto.add ?_ (tendsto_verticalIntegral hb c)
exact
intervalIntegral_tendsto_integral (integrable_cexp_neg_mul_sq hb) tendsto_neg_atTop_atBot
tendsto_id
theorem _root_.integral_cexp_quadratic (hb : b.re < 0) (c d : ℂ) :
∫ x : ℝ, cexp (b * x ^ 2 + c * x + d) = (π / -b) ^ (1 / 2 : ℂ) * cexp (d - c^2 / (4 * b)) := by
have hb' : b ≠ 0 := by contrapose! hb; rw [hb, zero_re]
have h (x : ℝ) : cexp (b * x ^ 2 + c * x + d) =
cexp (- -b * (x + c / (2 * b)) ^ 2) * cexp (d - c ^ 2 / (4 * b)) := by
simp_rw [← Complex.exp_add]
congr 1
field_simp
ring_nf
simp_rw [h, integral_mul_right]
rw [← re_add_im (c / (2 * b))]
simp_rw [← add_assoc, ← ofReal_add]
rw [integral_add_right_eq_self fun a : ℝ ↦ cexp (- -b * (↑a + ↑(c / (2 * b)).im * I) ^ 2),
integral_cexp_neg_mul_sq_add_real_mul_I ((neg_re b).symm ▸ (neg_pos.mpr hb))]
lemma _root_.integrable_cexp_quadratic' (hb : b.re < 0) (c d : ℂ) :
Integrable (fun (x : ℝ) ↦ cexp (b * x ^ 2 + c * x + d)) := by
have hb' : b ≠ 0 := by contrapose! hb; rw [hb, zero_re]
by_contra H
simpa [hb', pi_ne_zero, Complex.exp_ne_zero, integral_undef H]
using integral_cexp_quadratic hb c d
lemma _root_.integrable_cexp_quadratic (hb : 0 < b.re) (c d : ℂ) :
Integrable (fun (x : ℝ) ↦ cexp (-b * x ^ 2 + c * x + d)) := by
have : (-b).re < 0 := by simpa using hb
exact integrable_cexp_quadratic' this c d
theorem _root_.fourierIntegral_gaussian (hb : 0 < b.re) (t : ℂ) :
∫ x : ℝ, cexp (I * t * x) * cexp (-b * x ^ 2) =
(π / b) ^ (1 / 2 : ℂ) * cexp (-t ^ 2 / (4 * b)) := by
conv => enter [1, 2, x]; rw [← Complex.exp_add, add_comm, ← add_zero (-b * x ^ 2 + I * t * x)]
rw [integral_cexp_quadratic (show (-b).re < 0 by rwa [neg_re, neg_lt_zero]), neg_neg, zero_sub,
mul_neg, div_neg, neg_neg, mul_pow, I_sq, neg_one_mul, mul_comm]
@[deprecated (since := "2024-02-21")]
alias _root_.fourier_transform_gaussian := fourierIntegral_gaussian
theorem _root_.fourierIntegral_gaussian_pi' (hb : 0 < b.re) (c : ℂ) :
(𝓕 fun x : ℝ => cexp (-π * b * x ^ 2 + 2 * π * c * x)) = fun t : ℝ =>
1 / b ^ (1 / 2 : ℂ) * cexp (-π / b * (t + I * c) ^ 2) := by
haveI : b ≠ 0 := by contrapose! hb; rw [hb, zero_re]
have h : (-↑π * b).re < 0 := by
simpa only [neg_mul, neg_re, re_ofReal_mul, neg_lt_zero] using mul_pos pi_pos hb
ext1 t
simp_rw [fourierIntegral_real_eq_integral_exp_smul, smul_eq_mul, ← Complex.exp_add, ← add_assoc]
have (x : ℝ) : ↑(-2 * π * x * t) * I + -π * b * x ^ 2 + 2 * π * c * x =
-π * b * x ^ 2 + (-2 * π * I * t + 2 * π * c) * x + 0 := by push_cast; ring
simp_rw [this, integral_cexp_quadratic h, neg_mul, neg_neg]
congr 2
· rw [← div_div, div_self <| ofReal_ne_zero.mpr pi_ne_zero, one_div, inv_cpow, ← one_div]
rw [Ne, arg_eq_pi_iff, not_and_or, not_lt]
exact Or.inl hb.le
· field_simp [ofReal_ne_zero.mpr pi_ne_zero]
ring_nf
simp only [I_sq]
ring
@[deprecated (since := "2024-02-21")]
alias _root_.fourier_transform_gaussian_pi' := _root_.fourierIntegral_gaussian_pi'
theorem _root_.fourierIntegral_gaussian_pi (hb : 0 < b.re) :
(𝓕 fun (x : ℝ) ↦ cexp (-π * b * x ^ 2)) =
fun t : ℝ ↦ 1 / b ^ (1 / 2 : ℂ) * cexp (-π / b * t ^ 2) := by
simpa only [mul_zero, zero_mul, add_zero] using fourierIntegral_gaussian_pi' hb 0
@[deprecated (since := "2024-02-21")]
alias root_.fourier_transform_gaussian_pi := _root_.fourierIntegral_gaussian_pi
section InnerProductSpace
variable {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V] [FiniteDimensional ℝ V]
[MeasurableSpace V] [BorelSpace V]
theorem integrable_cexp_neg_sum_mul_add {ι : Type*} [Fintype ι] {b : ι → ℂ}
(hb : ∀ i, 0 < (b i).re) (c : ι → ℂ) :
Integrable (fun (v : ι → ℝ) ↦ cexp (- ∑ i, b i * (v i : ℂ) ^ 2 + ∑ i, c i * v i)) := by
simp_rw [← Finset.sum_neg_distrib, ← Finset.sum_add_distrib, Complex.exp_sum, ← neg_mul]
apply Integrable.fintype_prod (f := fun i (v : ℝ) ↦ cexp (-b i * v^2 + c i * v)) (fun i ↦ ?_)
convert integrable_cexp_quadratic (hb i) (c i) 0 using 3 with x
simp only [add_zero]
theorem integrable_cexp_neg_mul_sum_add {ι : Type*} [Fintype ι] (hb : 0 < b.re) (c : ι → ℂ) :
Integrable (fun (v : ι → ℝ) ↦ cexp (- b * ∑ i, (v i : ℂ) ^ 2 + ∑ i, c i * v i)) := by
simp_rw [neg_mul, Finset.mul_sum]
exact integrable_cexp_neg_sum_mul_add (fun _ ↦ hb) c
theorem integrable_cexp_neg_mul_sq_norm_add_of_euclideanSpace
{ι : Type*} [Fintype ι] (hb : 0 < b.re) (c : ℂ) (w : EuclideanSpace ℝ ι) :
Integrable (fun (v : EuclideanSpace ℝ ι) ↦ cexp (- b * ‖v‖^2 + c * ⟪w, v⟫)) := by
have := EuclideanSpace.volume_preserving_measurableEquiv ι
rw [← MeasurePreserving.integrable_comp_emb this.symm (MeasurableEquiv.measurableEmbedding _)]
simp only [neg_mul, Function.comp_def]
convert integrable_cexp_neg_mul_sum_add hb (fun i ↦ c * w i) using 3 with v
simp only [EuclideanSpace.measurableEquiv, MeasurableEquiv.symm_mk, MeasurableEquiv.coe_mk,
EuclideanSpace.norm_eq, WithLp.equiv_symm_pi_apply, Real.norm_eq_abs, sq_abs, PiLp.inner_apply,
RCLike.inner_apply, conj_trivial, ofReal_sum, ofReal_mul, Finset.mul_sum, neg_mul,
Finset.sum_neg_distrib, mul_assoc, add_left_inj, neg_inj]
norm_cast
rw [sq_sqrt]
· simp [Finset.mul_sum]
· exact Finset.sum_nonneg (fun i _hi ↦ by positivity)
/-- In a real inner product space, the complex exponential of minus the square of the norm plus
a scalar product is integrable. Useful when discussing the Fourier transform of a Gaussian. -/
theorem integrable_cexp_neg_mul_sq_norm_add (hb : 0 < b.re) (c : ℂ) (w : V) :
Integrable (fun (v : V) ↦ cexp (-b * ‖v‖^2 + c * ⟪w, v⟫)) := by
let e := (stdOrthonormalBasis ℝ V).repr.symm
rw [← e.measurePreserving.integrable_comp_emb e.toHomeomorph.measurableEmbedding]
convert integrable_cexp_neg_mul_sq_norm_add_of_euclideanSpace
hb c (e.symm w) with v
simp only [neg_mul, Function.comp_apply, LinearIsometryEquiv.norm_map,
LinearIsometryEquiv.symm_symm, conj_trivial, ofReal_sum,
ofReal_mul, LinearIsometryEquiv.inner_map_eq_flip]
theorem integral_cexp_neg_sum_mul_add {ι : Type*} [Fintype ι] {b : ι → ℂ}
(hb : ∀ i, 0 < (b i).re) (c : ι → ℂ) :
∫ v : ι → ℝ, cexp (- ∑ i, b i * (v i : ℂ) ^ 2 + ∑ i, c i * v i)
= ∏ i, (π / b i) ^ (1 / 2 : ℂ) * cexp (c i ^ 2 / (4 * b i)) := by
simp_rw [← Finset.sum_neg_distrib, ← Finset.sum_add_distrib, Complex.exp_sum, ← neg_mul]
rw [integral_fintype_prod_eq_prod (f := fun i (v : ℝ) ↦ cexp (-b i * v ^ 2 + c i * v))]
congr with i
have : (-b i).re < 0 := by simpa using hb i
convert integral_cexp_quadratic this (c i) 0 using 1 <;> simp [div_neg]
theorem integral_cexp_neg_mul_sum_add {ι : Type*} [Fintype ι] (hb : 0 < b.re) (c : ι → ℂ) :
∫ v : ι → ℝ, cexp (- b * ∑ i, (v i : ℂ) ^ 2 + ∑ i, c i * v i)
= (π / b) ^ (Fintype.card ι / 2 : ℂ) * cexp ((∑ i, c i ^ 2) / (4 * b)) := by
simp_rw [neg_mul, Finset.mul_sum, integral_cexp_neg_sum_mul_add (fun _ ↦ hb) c, one_div,
Finset.prod_mul_distrib, Finset.prod_const, ← cpow_nat_mul, ← Complex.exp_sum, Fintype.card,
Finset.sum_div, div_eq_mul_inv]
theorem integral_cexp_neg_mul_sq_norm_add_of_euclideanSpace
{ι : Type*} [Fintype ι] (hb : 0 < b.re) (c : ℂ) (w : EuclideanSpace ℝ ι) :
∫ v : EuclideanSpace ℝ ι, cexp (- b * ‖v‖^2 + c * ⟪w, v⟫) =
(π / b) ^ (Fintype.card ι / 2 : ℂ) * cexp (c ^ 2 * ‖w‖^2 / (4 * b)) := by
have := (EuclideanSpace.volume_preserving_measurableEquiv ι).symm
rw [← this.integral_comp (MeasurableEquiv.measurableEmbedding _)]
simp only [neg_mul, Function.comp_def]
convert integral_cexp_neg_mul_sum_add hb (fun i ↦ c * w i) using 5 with _x y
· simp only [EuclideanSpace.measurableEquiv, MeasurableEquiv.symm_mk, MeasurableEquiv.coe_mk,
EuclideanSpace.norm_eq, WithLp.equiv_symm_pi_apply, Real.norm_eq_abs, sq_abs, neg_mul,
neg_inj, mul_eq_mul_left_iff]
norm_cast
left
rw [sq_sqrt]
exact Finset.sum_nonneg (fun i _hi ↦ by positivity)
· simp [PiLp.inner_apply, EuclideanSpace.measurableEquiv, Finset.mul_sum, mul_assoc]
· simp only [EuclideanSpace.norm_eq, Real.norm_eq_abs, sq_abs, mul_pow, ← Finset.mul_sum]
congr
norm_cast
rw [sq_sqrt]
exact Finset.sum_nonneg (fun i _hi ↦ by positivity)
theorem integral_cexp_neg_mul_sq_norm_add
(hb : 0 < b.re) (c : ℂ) (w : V) :
∫ v : V, cexp (- b * ‖v‖^2 + c * ⟪w, v⟫) =
(π / b) ^ (FiniteDimensional.finrank ℝ V / 2 : ℂ) * cexp (c ^ 2 * ‖w‖^2 / (4 * b)) := by
let e := (stdOrthonormalBasis ℝ V).repr.symm
rw [← e.measurePreserving.integral_comp e.toHomeomorph.measurableEmbedding]
convert integral_cexp_neg_mul_sq_norm_add_of_euclideanSpace
hb c (e.symm w) <;> simp [LinearIsometryEquiv.inner_map_eq_flip]
theorem integral_cexp_neg_mul_sq_norm (hb : 0 < b.re) :
∫ v : V, cexp (- b * ‖v‖^2) = (π / b) ^ (FiniteDimensional.finrank ℝ V / 2 : ℂ) := by
simpa using integral_cexp_neg_mul_sq_norm_add hb 0 (0 : V)
theorem integral_rexp_neg_mul_sq_norm {b : ℝ} (hb : 0 < b) :
∫ v : V, rexp (- b * ‖v‖^2) = (π / b) ^ (FiniteDimensional.finrank ℝ V / 2 : ℝ) := by
rw [← ofReal_inj]
convert integral_cexp_neg_mul_sq_norm (show 0 < (b : ℂ).re from hb) (V := V)
· change ofRealLI (∫ (v : V), rexp (-b * ‖v‖ ^ 2)) = ∫ (v : V), cexp (-↑b * ↑‖v‖ ^ 2)
rw [← ofRealLI.integral_comp_comm]
simp [ofRealLI]
· rw [← ofReal_div, ofReal_cpow (by positivity)]
simp
theorem _root_.fourierIntegral_gaussian_innerProductSpace' (hb : 0 < b.re) (x w : V) :
𝓕 (fun v ↦ cexp (- b * ‖v‖^2 + 2 * π * Complex.I * ⟪x, v⟫)) w =
(π / b) ^ (FiniteDimensional.finrank ℝ V / 2 : ℂ) * cexp (-π ^ 2 * ‖x - w‖ ^ 2 / b) := by
simp only [neg_mul, fourierIntegral_eq', ofReal_neg, ofReal_mul, ofReal_ofNat,
smul_eq_mul, ← Complex.exp_add, real_inner_comm w]
convert integral_cexp_neg_mul_sq_norm_add hb (2 * π * Complex.I) (x - w) using 3 with v
· congr 1
simp [inner_sub_left]
ring
· have : b ≠ 0 := by contrapose! hb; rw [hb, zero_re]
field_simp [mul_pow]
ring
theorem _root_.fourierIntegral_gaussian_innerProductSpace (hb : 0 < b.re) (w : V) :
𝓕 (fun v ↦ cexp (- b * ‖v‖^2)) w =
(π / b) ^ (FiniteDimensional.finrank ℝ V / 2 : ℂ) * cexp (-π ^ 2 * ‖w‖^2 / b) := by
simpa using fourierIntegral_gaussian_innerProductSpace' hb 0 w
end InnerProductSpace
end GaussianFourier
|
Analysis\SpecialFunctions\Gaussian\GaussianIntegral.lean | /-
Copyright (c) 2022 Sébastien Gouëzel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sébastien Gouëzel
-/
import Mathlib.Analysis.SpecialFunctions.Gamma.Basic
import Mathlib.Analysis.SpecialFunctions.PolarCoord
import Mathlib.Analysis.Convex.Complex
/-!
# Gaussian integral
We prove various versions of the formula for the Gaussian integral:
* `integral_gaussian`: for real `b` we have `∫ x:ℝ, exp (-b * x^2) = √(π / b)`.
* `integral_gaussian_complex`: for complex `b` with `0 < re b` we have
`∫ x:ℝ, exp (-b * x^2) = (π / b) ^ (1 / 2)`.
* `integral_gaussian_Ioi` and `integral_gaussian_complex_Ioi`: variants for integrals over `Ioi 0`.
* `Complex.Gamma_one_half_eq`: the formula `Γ (1 / 2) = √π`.
-/
noncomputable section
open Real Set MeasureTheory Filter Asymptotics
open scoped Real Topology
open Complex hiding exp abs_of_nonneg
theorem exp_neg_mul_rpow_isLittleO_exp_neg {p b : ℝ} (hb : 0 < b) (hp : 1 < p) :
(fun x : ℝ => exp (- b * x ^ p)) =o[atTop] fun x : ℝ => exp (-x) := by
rw [isLittleO_exp_comp_exp_comp]
suffices Tendsto (fun x => x * (b * x ^ (p - 1) + -1)) atTop atTop by
refine Tendsto.congr' ?_ this
refine eventuallyEq_of_mem (Ioi_mem_atTop (0 : ℝ)) (fun x hx => ?_)
rw [mem_Ioi] at hx
rw [rpow_sub_one hx.ne']
field_simp [hx.ne']
ring
apply Tendsto.atTop_mul_atTop tendsto_id
refine tendsto_atTop_add_const_right atTop (-1 : ℝ) ?_
exact Tendsto.const_mul_atTop hb (tendsto_rpow_atTop (by linarith))
theorem exp_neg_mul_sq_isLittleO_exp_neg {b : ℝ} (hb : 0 < b) :
(fun x : ℝ => exp (-b * x ^ 2)) =o[atTop] fun x : ℝ => exp (-x) := by
simp_rw [← rpow_two]
exact exp_neg_mul_rpow_isLittleO_exp_neg hb one_lt_two
theorem rpow_mul_exp_neg_mul_rpow_isLittleO_exp_neg (s : ℝ) {b p : ℝ} (hp : 1 < p) (hb : 0 < b) :
(fun x : ℝ => x ^ s * exp (- b * x ^ p)) =o[atTop] fun x : ℝ => exp (-(1 / 2) * x) := by
apply ((isBigO_refl (fun x : ℝ => x ^ s) atTop).mul_isLittleO
(exp_neg_mul_rpow_isLittleO_exp_neg hb hp)).trans
simpa only [mul_comm] using Real.Gamma_integrand_isLittleO s
theorem rpow_mul_exp_neg_mul_sq_isLittleO_exp_neg {b : ℝ} (hb : 0 < b) (s : ℝ) :
(fun x : ℝ => x ^ s * exp (-b * x ^ 2)) =o[atTop] fun x : ℝ => exp (-(1 / 2) * x) := by
simp_rw [← rpow_two]
exact rpow_mul_exp_neg_mul_rpow_isLittleO_exp_neg s one_lt_two hb
theorem integrableOn_rpow_mul_exp_neg_rpow {p s : ℝ} (hs : -1 < s) (hp : 1 ≤ p) :
IntegrableOn (fun x : ℝ => x ^ s * exp (- x ^ p)) (Ioi 0) := by
obtain hp | hp := le_iff_lt_or_eq.mp hp
· have h_exp : ∀ x, ContinuousAt (fun x => exp (- x)) x := fun x => continuousAt_neg.rexp
rw [← Ioc_union_Ioi_eq_Ioi zero_le_one, integrableOn_union]
constructor
· rw [← integrableOn_Icc_iff_integrableOn_Ioc]
refine IntegrableOn.mul_continuousOn ?_ ?_ isCompact_Icc
· refine (intervalIntegrable_iff_integrableOn_Icc_of_le zero_le_one).mp ?_
exact intervalIntegral.intervalIntegrable_rpow' hs
· intro x _
change ContinuousWithinAt ((fun x => exp (- x)) ∘ (fun x => x ^ p)) (Icc 0 1) x
refine ContinuousAt.comp_continuousWithinAt (h_exp _) ?_
exact continuousWithinAt_id.rpow_const (Or.inr (le_of_lt (lt_trans zero_lt_one hp)))
· have h_rpow : ∀ (x r : ℝ), x ∈ Ici 1 → ContinuousWithinAt (fun x => x ^ r) (Ici 1) x := by
intro _ _ hx
refine continuousWithinAt_id.rpow_const (Or.inl ?_)
exact ne_of_gt (lt_of_lt_of_le zero_lt_one hx)
refine integrable_of_isBigO_exp_neg (by norm_num : (0 : ℝ) < 1 / 2)
(ContinuousOn.mul (fun x hx => h_rpow x s hx) (fun x hx => ?_)) (IsLittleO.isBigO ?_)
· change ContinuousWithinAt ((fun x => exp (- x)) ∘ (fun x => x ^ p)) (Ici 1) x
exact ContinuousAt.comp_continuousWithinAt (h_exp _) (h_rpow x p hx)
· convert rpow_mul_exp_neg_mul_rpow_isLittleO_exp_neg s hp (by norm_num : (0 : ℝ) < 1) using 3
rw [neg_mul, one_mul]
· simp_rw [← hp, Real.rpow_one]
convert Real.GammaIntegral_convergent (by linarith : 0 < s + 1) using 2
rw [add_sub_cancel_right, mul_comm]
theorem integrableOn_rpow_mul_exp_neg_mul_rpow {p s b : ℝ} (hs : -1 < s) (hp : 1 ≤ p) (hb : 0 < b) :
IntegrableOn (fun x : ℝ => x ^ s * exp (- b * x ^ p)) (Ioi 0) := by
have hib : 0 < b ^ (-p⁻¹) := rpow_pos_of_pos hb _
suffices IntegrableOn (fun x ↦ (b ^ (-p⁻¹)) ^ s * (x ^ s * exp (-x ^ p))) (Ioi 0) by
rw [show 0 = b ^ (-p⁻¹) * 0 by rw [mul_zero], ← integrableOn_Ioi_comp_mul_left_iff _ _ hib]
refine this.congr_fun (fun _ hx => ?_) measurableSet_Ioi
rw [← mul_assoc, mul_rpow, mul_rpow, ← rpow_mul (z := p), neg_mul, neg_mul, inv_mul_cancel,
rpow_neg_one, mul_inv_cancel_left₀]
all_goals linarith [mem_Ioi.mp hx]
refine Integrable.const_mul ?_ _
rw [← IntegrableOn]
exact integrableOn_rpow_mul_exp_neg_rpow hs hp
theorem integrableOn_rpow_mul_exp_neg_mul_sq {b : ℝ} (hb : 0 < b) {s : ℝ} (hs : -1 < s) :
IntegrableOn (fun x : ℝ => x ^ s * exp (-b * x ^ 2)) (Ioi 0) := by
simp_rw [← rpow_two]
exact integrableOn_rpow_mul_exp_neg_mul_rpow hs one_le_two hb
theorem integrable_rpow_mul_exp_neg_mul_sq {b : ℝ} (hb : 0 < b) {s : ℝ} (hs : -1 < s) :
Integrable fun x : ℝ => x ^ s * exp (-b * x ^ 2) := by
rw [← integrableOn_univ, ← @Iio_union_Ici _ _ (0 : ℝ), integrableOn_union,
integrableOn_Ici_iff_integrableOn_Ioi]
refine ⟨?_, integrableOn_rpow_mul_exp_neg_mul_sq hb hs⟩
rw [← (Measure.measurePreserving_neg (volume : Measure ℝ)).integrableOn_comp_preimage
(Homeomorph.neg ℝ).measurableEmbedding]
simp only [Function.comp, neg_sq, neg_preimage, preimage_neg_Iio, neg_neg, neg_zero]
apply Integrable.mono' (integrableOn_rpow_mul_exp_neg_mul_sq hb hs)
· apply Measurable.aestronglyMeasurable
exact (measurable_id'.neg.pow measurable_const).mul
((measurable_id'.pow measurable_const).const_mul (-b)).exp
· have : MeasurableSet (Ioi (0 : ℝ)) := measurableSet_Ioi
filter_upwards [ae_restrict_mem this] with x hx
have h'x : 0 ≤ x := le_of_lt hx
rw [Real.norm_eq_abs, abs_mul, abs_of_nonneg (exp_pos _).le]
apply mul_le_mul_of_nonneg_right _ (exp_pos _).le
simpa [abs_of_nonneg h'x] using abs_rpow_le_abs_rpow (-x) s
theorem integrable_exp_neg_mul_sq {b : ℝ} (hb : 0 < b) :
Integrable fun x : ℝ => exp (-b * x ^ 2) := by
simpa using integrable_rpow_mul_exp_neg_mul_sq hb (by norm_num : (-1 : ℝ) < 0)
theorem integrableOn_Ioi_exp_neg_mul_sq_iff {b : ℝ} :
IntegrableOn (fun x : ℝ => exp (-b * x ^ 2)) (Ioi 0) ↔ 0 < b := by
refine ⟨fun h => ?_, fun h => (integrable_exp_neg_mul_sq h).integrableOn⟩
by_contra! hb
have : ∫⁻ _ : ℝ in Ioi 0, 1 ≤ ∫⁻ x : ℝ in Ioi 0, ‖exp (-b * x ^ 2)‖₊ := by
apply lintegral_mono (fun x ↦ _)
simp only [neg_mul, ENNReal.one_le_coe_iff, ← toNNReal_one, toNNReal_le_iff_le_coe,
Real.norm_of_nonneg (exp_pos _).le, coe_nnnorm, one_le_exp_iff, Right.nonneg_neg_iff]
exact fun x ↦ mul_nonpos_of_nonpos_of_nonneg hb (sq_nonneg x)
simpa using this.trans_lt h.2
theorem integrable_exp_neg_mul_sq_iff {b : ℝ} :
(Integrable fun x : ℝ => exp (-b * x ^ 2)) ↔ 0 < b :=
⟨fun h => integrableOn_Ioi_exp_neg_mul_sq_iff.mp h.integrableOn, integrable_exp_neg_mul_sq⟩
theorem integrable_mul_exp_neg_mul_sq {b : ℝ} (hb : 0 < b) :
Integrable fun x : ℝ => x * exp (-b * x ^ 2) := by
simpa using integrable_rpow_mul_exp_neg_mul_sq hb (by norm_num : (-1 : ℝ) < 1)
theorem norm_cexp_neg_mul_sq (b : ℂ) (x : ℝ) :
‖Complex.exp (-b * (x : ℂ) ^ 2)‖ = exp (-b.re * x ^ 2) := by
rw [Complex.norm_eq_abs, Complex.abs_exp, ← ofReal_pow, mul_comm (-b) _, re_ofReal_mul, neg_re,
mul_comm]
theorem integrable_cexp_neg_mul_sq {b : ℂ} (hb : 0 < b.re) :
Integrable fun x : ℝ => cexp (-b * (x : ℂ) ^ 2) := by
refine ⟨(Complex.continuous_exp.comp
(continuous_const.mul (continuous_ofReal.pow 2))).aestronglyMeasurable, ?_⟩
rw [← hasFiniteIntegral_norm_iff]
simp_rw [norm_cexp_neg_mul_sq]
exact (integrable_exp_neg_mul_sq hb).2
theorem integrable_mul_cexp_neg_mul_sq {b : ℂ} (hb : 0 < b.re) :
Integrable fun x : ℝ => ↑x * cexp (-b * (x : ℂ) ^ 2) := by
refine ⟨(continuous_ofReal.mul (Complex.continuous_exp.comp ?_)).aestronglyMeasurable, ?_⟩
· exact continuous_const.mul (continuous_ofReal.pow 2)
have := (integrable_mul_exp_neg_mul_sq hb).hasFiniteIntegral
rw [← hasFiniteIntegral_norm_iff] at this ⊢
convert this
rw [norm_mul, norm_mul, norm_cexp_neg_mul_sq b, Complex.norm_eq_abs, abs_ofReal, Real.norm_eq_abs,
norm_of_nonneg (exp_pos _).le]
theorem integral_mul_cexp_neg_mul_sq {b : ℂ} (hb : 0 < b.re) :
∫ r : ℝ in Ioi 0, (r : ℂ) * cexp (-b * (r : ℂ) ^ 2) = (2 * b)⁻¹ := by
have hb' : b ≠ 0 := by contrapose! hb; rw [hb, zero_re]
have A : ∀ x : ℂ, HasDerivAt (fun x => -(2 * b)⁻¹ * cexp (-b * x ^ 2))
(x * cexp (-b * x ^ 2)) x := by
intro x
convert ((hasDerivAt_pow 2 x).const_mul (-b)).cexp.const_mul (-(2 * b)⁻¹) using 1
field_simp [hb']
ring
have B : Tendsto (fun y : ℝ ↦ -(2 * b)⁻¹ * cexp (-b * (y : ℂ) ^ 2))
atTop (𝓝 (-(2 * b)⁻¹ * 0)) := by
refine Tendsto.const_mul _ (tendsto_zero_iff_norm_tendsto_zero.mpr ?_)
simp_rw [norm_cexp_neg_mul_sq b]
exact tendsto_exp_atBot.comp
((tendsto_pow_atTop two_ne_zero).const_mul_atTop_of_neg (neg_lt_zero.2 hb))
convert integral_Ioi_of_hasDerivAt_of_tendsto' (fun x _ => (A ↑x).comp_ofReal)
(integrable_mul_cexp_neg_mul_sq hb).integrableOn B using 1
simp only [mul_zero, ofReal_zero, zero_pow, Ne, Nat.one_ne_zero,
not_false_iff, Complex.exp_zero, mul_one, sub_neg_eq_add, zero_add]
/-- The *square* of the Gaussian integral `∫ x:ℝ, exp (-b * x^2)` is equal to `π / b`. -/
theorem integral_gaussian_sq_complex {b : ℂ} (hb : 0 < b.re) :
(∫ x : ℝ, cexp (-b * (x : ℂ) ^ 2)) ^ 2 = π / b := by
/- We compute `(∫ exp (-b x^2))^2` as an integral over `ℝ^2`, and then make a polar change
of coordinates. We are left with `∫ r * exp (-b r^2)`, which has been computed in
`integral_mul_cexp_neg_mul_sq` using the fact that this function has an obvious primitive. -/
calc
(∫ x : ℝ, cexp (-b * (x : ℂ) ^ 2)) ^ 2 =
∫ p : ℝ × ℝ, cexp (-b * (p.1 : ℂ) ^ 2) * cexp (-b * (p.2 : ℂ) ^ 2) := by
rw [pow_two, ← integral_prod_mul]; rfl
_ = ∫ p : ℝ × ℝ, cexp (-b * ((p.1 : ℂ)^ 2 + (p.2 : ℂ) ^ 2)) := by
congr
ext1 p
rw [← Complex.exp_add, mul_add]
_ = ∫ p in polarCoord.target, p.1 •
cexp (-b * ((p.1 * Complex.cos p.2) ^ 2 + (p.1 * Complex.sin p.2) ^ 2)) := by
rw [← integral_comp_polarCoord_symm]
simp only [polarCoord_symm_apply, ofReal_mul, ofReal_cos, ofReal_sin]
_ = (∫ r in Ioi (0 : ℝ), r * cexp (-b * (r : ℂ) ^ 2)) * ∫ θ in Ioo (-π) π, 1 := by
rw [← setIntegral_prod_mul]
congr with p : 1
rw [mul_one]
congr
conv_rhs => rw [← one_mul ((p.1 : ℂ) ^ 2), ← sin_sq_add_cos_sq (p.2 : ℂ)]
ring
_ = ↑π / b := by
have : 0 ≤ π + π := by linarith [Real.pi_pos]
simp only [integral_const, Measure.restrict_apply', measurableSet_Ioo, univ_inter, volume_Ioo,
sub_neg_eq_add, ENNReal.toReal_ofReal, this]
rw [← two_mul, real_smul, mul_one, ofReal_mul, ofReal_ofNat, integral_mul_cexp_neg_mul_sq hb]
field_simp [(by contrapose! hb; rw [hb, zero_re] : b ≠ 0)]
ring
theorem integral_gaussian (b : ℝ) : ∫ x : ℝ, exp (-b * x ^ 2) = √(π / b) := by
-- First we deal with the crazy case where `b ≤ 0`: then both sides vanish.
rcases le_or_lt b 0 with (hb | hb)
· rw [integral_undef, sqrt_eq_zero_of_nonpos]
· exact div_nonpos_of_nonneg_of_nonpos pi_pos.le hb
· simpa only [not_lt, integrable_exp_neg_mul_sq_iff] using hb
-- Assume now `b > 0`. Then both sides are non-negative and their squares agree.
refine (sq_eq_sq (by positivity) (by positivity)).1 ?_
rw [← ofReal_inj, ofReal_pow, ← coe_algebraMap, RCLike.algebraMap_eq_ofReal, ← integral_ofReal,
sq_sqrt (div_pos pi_pos hb).le, ← RCLike.algebraMap_eq_ofReal, coe_algebraMap, ofReal_div]
convert integral_gaussian_sq_complex (by rwa [ofReal_re] : 0 < (b : ℂ).re) with _ x
rw [ofReal_exp, ofReal_mul, ofReal_pow, ofReal_neg]
theorem continuousAt_gaussian_integral (b : ℂ) (hb : 0 < re b) :
ContinuousAt (fun c : ℂ => ∫ x : ℝ, cexp (-c * (x : ℂ) ^ 2)) b := by
let f : ℂ → ℝ → ℂ := fun (c : ℂ) (x : ℝ) => cexp (-c * (x : ℂ) ^ 2)
obtain ⟨d, hd, hd'⟩ := exists_between hb
have f_meas : ∀ c : ℂ, AEStronglyMeasurable (f c) volume := fun c => by
apply Continuous.aestronglyMeasurable
exact Complex.continuous_exp.comp (continuous_const.mul (continuous_ofReal.pow 2))
have f_cts : ∀ x : ℝ, ContinuousAt (fun c => f c x) b := fun x =>
(Complex.continuous_exp.comp (continuous_id'.neg.mul continuous_const)).continuousAt
have f_le_bd : ∀ᶠ c : ℂ in 𝓝 b, ∀ᵐ x : ℝ, ‖f c x‖ ≤ exp (-d * x ^ 2) := by
refine eventually_of_mem ((continuous_re.isOpen_preimage _ isOpen_Ioi).mem_nhds hd') ?_
intro c hc; filter_upwards with x
rw [norm_cexp_neg_mul_sq]
gcongr
exact le_of_lt hc
exact
continuousAt_of_dominated (eventually_of_forall f_meas) f_le_bd (integrable_exp_neg_mul_sq hd)
(ae_of_all _ f_cts)
theorem integral_gaussian_complex {b : ℂ} (hb : 0 < re b) :
∫ x : ℝ, cexp (-b * (x : ℂ) ^ 2) = (π / b) ^ (1 / 2 : ℂ) := by
have nv : ∀ {b : ℂ}, 0 < re b → b ≠ 0 := by intro b hb; contrapose! hb; rw [hb]; simp
apply
(convex_halfspace_re_gt 0).isPreconnected.eq_of_sq_eq ?_ ?_ (fun c hc => ?_) (fun {c} hc => ?_)
(by simp : 0 < re (1 : ℂ)) ?_ hb
· -- integral is continuous
exact ContinuousAt.continuousOn continuousAt_gaussian_integral
· -- `(π / b) ^ (1 / 2 : ℂ)` is continuous
refine
ContinuousAt.continuousOn fun b hb =>
(continuousAt_cpow_const (Or.inl ?_)).comp (continuousAt_const.div continuousAt_id (nv hb))
rw [div_re, ofReal_im, ofReal_re, zero_mul, zero_div, add_zero]
exact div_pos (mul_pos pi_pos hb) (normSq_pos.mpr (nv hb))
· -- equality at 1
have : ∀ x : ℝ, cexp (-(1 : ℂ) * (x : ℂ) ^ 2) = exp (-(1 : ℝ) * x ^ 2) := by
intro x
simp only [ofReal_exp, neg_mul, one_mul, ofReal_neg, ofReal_pow]
simp_rw [this, ← coe_algebraMap, RCLike.algebraMap_eq_ofReal, integral_ofReal,
← RCLike.algebraMap_eq_ofReal, coe_algebraMap]
conv_rhs =>
congr
· rw [← ofReal_one, ← ofReal_div]
· rw [← ofReal_one, ← ofReal_ofNat, ← ofReal_div]
rw [← ofReal_cpow, ofReal_inj]
· convert integral_gaussian (1 : ℝ) using 1
rw [sqrt_eq_rpow]
· rw [div_one]; exact pi_pos.le
· -- squares of both sides agree
dsimp only [Pi.pow_apply]
rw [integral_gaussian_sq_complex hc, sq]
conv_lhs => rw [← cpow_one (↑π / c)]
rw [← cpow_add _ _ (div_ne_zero (ofReal_ne_zero.mpr pi_ne_zero) (nv hc))]
norm_num
· -- RHS doesn't vanish
rw [Ne, cpow_eq_zero_iff, not_and_or]
exact Or.inl (div_ne_zero (ofReal_ne_zero.mpr pi_ne_zero) (nv hc))
-- The Gaussian integral on the half-line, `∫ x in Ioi 0, exp (-b * x^2)`, for complex `b`.
theorem integral_gaussian_complex_Ioi {b : ℂ} (hb : 0 < re b) :
∫ x : ℝ in Ioi 0, cexp (-b * (x : ℂ) ^ 2) = (π / b) ^ (1 / 2 : ℂ) / 2 := by
have full_integral := integral_gaussian_complex hb
have : MeasurableSet (Ioi (0 : ℝ)) := measurableSet_Ioi
rw [← integral_add_compl this (integrable_cexp_neg_mul_sq hb), compl_Ioi] at full_integral
suffices ∫ x : ℝ in Iic 0, cexp (-b * (x : ℂ) ^ 2) = ∫ x : ℝ in Ioi 0, cexp (-b * (x : ℂ) ^ 2) by
rw [this, ← mul_two] at full_integral
rwa [eq_div_iff]; exact two_ne_zero
have : ∀ c : ℝ, ∫ x in (0 : ℝ)..c, cexp (-b * (x : ℂ) ^ 2) =
∫ x in -c..0, cexp (-b * (x : ℂ) ^ 2) := by
intro c
have := intervalIntegral.integral_comp_sub_left (a := 0) (b := c)
(fun x => cexp (-b * (x : ℂ) ^ 2)) 0
simpa [zero_sub, neg_sq, neg_zero] using this
have t1 :=
intervalIntegral_tendsto_integral_Ioi 0 (integrable_cexp_neg_mul_sq hb).integrableOn tendsto_id
have t2 :
Tendsto (fun c : ℝ => ∫ x : ℝ in (0 : ℝ)..c, cexp (-b * (x : ℂ) ^ 2)) atTop
(𝓝 (∫ x : ℝ in Iic 0, cexp (-b * (x : ℂ) ^ 2))) := by
simp_rw [this]
refine intervalIntegral_tendsto_integral_Iic _ ?_ tendsto_neg_atTop_atBot
apply (integrable_cexp_neg_mul_sq hb).integrableOn
exact tendsto_nhds_unique t2 t1
-- The Gaussian integral on the half-line, `∫ x in Ioi 0, exp (-b * x^2)`, for real `b`.
theorem integral_gaussian_Ioi (b : ℝ) :
∫ x in Ioi (0 : ℝ), exp (-b * x ^ 2) = √(π / b) / 2 := by
rcases le_or_lt b 0 with (hb | hb)
· rw [integral_undef, sqrt_eq_zero_of_nonpos, zero_div]
· exact div_nonpos_of_nonneg_of_nonpos pi_pos.le hb
· rwa [← IntegrableOn, integrableOn_Ioi_exp_neg_mul_sq_iff, not_lt]
rw [← RCLike.ofReal_inj (K := ℂ), ← integral_ofReal, ← RCLike.algebraMap_eq_ofReal,
coe_algebraMap]
convert integral_gaussian_complex_Ioi (by rwa [ofReal_re] : 0 < (b : ℂ).re)
· simp
· rw [sqrt_eq_rpow, ← ofReal_div, ofReal_div, ofReal_cpow]
· norm_num
· exact (div_pos pi_pos hb).le
/-- The special-value formula `Γ(1/2) = √π`, which is equivalent to the Gaussian integral. -/
theorem Real.Gamma_one_half_eq : Real.Gamma (1 / 2) = √π := by
rw [Gamma_eq_integral one_half_pos, ← integral_comp_rpow_Ioi_of_pos zero_lt_two]
convert congr_arg (fun x : ℝ => 2 * x) (integral_gaussian_Ioi 1) using 1
· rw [← integral_mul_left]
refine setIntegral_congr measurableSet_Ioi fun x hx => ?_
dsimp only
have : (x ^ (2 : ℝ)) ^ (1 / (2 : ℝ) - 1) = x⁻¹ := by
rw [← rpow_mul (le_of_lt hx)]
norm_num
rw [rpow_neg (le_of_lt hx), rpow_one]
rw [smul_eq_mul, this]
field_simp [(ne_of_lt (show 0 < x from hx)).symm]
norm_num; ring
· rw [div_one, ← mul_div_assoc, mul_comm, mul_div_cancel_right₀ _ (two_ne_zero' ℝ)]
/-- The special-value formula `Γ(1/2) = √π`, which is equivalent to the Gaussian integral. -/
theorem Complex.Gamma_one_half_eq : Complex.Gamma (1 / 2) = (π : ℂ) ^ (1 / 2 : ℂ) := by
convert congr_arg ((↑) : ℝ → ℂ) Real.Gamma_one_half_eq
· simpa only [one_div, ofReal_inv, ofReal_ofNat] using Gamma_ofReal (1 / 2)
· rw [sqrt_eq_rpow, ofReal_cpow pi_pos.le, ofReal_div, ofReal_ofNat, ofReal_one]
|
Analysis\SpecialFunctions\Gaussian\PoissonSummation.lean | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.SpecialFunctions.Gaussian.FourierTransform
import Mathlib.Analysis.Fourier.PoissonSummation
/-!
# Poisson summation applied to the Gaussian
In `Real.tsum_exp_neg_mul_int_sq` and `Complex.tsum_exp_neg_mul_int_sq`, we use Poisson summation
to prove the identity
`∑' (n : ℤ), exp (-π * a * n ^ 2) = 1 / a ^ (1 / 2) * ∑' (n : ℤ), exp (-π / a * n ^ 2)`
for positive real `a`, or complex `a` with positive real part. (See also
`NumberTheory.ModularForms.JacobiTheta`.)
-/
open Real Set MeasureTheory Filter Asymptotics intervalIntegral
open scoped Real Topology FourierTransform RealInnerProductSpace
open Complex hiding exp continuous_exp abs_of_nonneg sq_abs
noncomputable section
section GaussianPoisson
variable {E : Type*} [NormedAddCommGroup E]
/-! First we show that Gaussian-type functions have rapid decay along `cocompact ℝ`. -/
lemma rexp_neg_quadratic_isLittleO_rpow_atTop {a : ℝ} (ha : a < 0) (b s : ℝ) :
(fun x ↦ rexp (a * x ^ 2 + b * x)) =o[atTop] (· ^ s) := by
suffices (fun x ↦ rexp (a * x ^ 2 + b * x)) =o[atTop] (fun x ↦ rexp (-x)) by
refine this.trans ?_
simpa only [neg_one_mul] using isLittleO_exp_neg_mul_rpow_atTop zero_lt_one s
rw [isLittleO_exp_comp_exp_comp]
have : (fun x ↦ -x - (a * x ^ 2 + b * x)) = fun x ↦ x * (-a * x - (b + 1)) := by
ext1 x; ring_nf
rw [this]
exact tendsto_id.atTop_mul_atTop <|
Filter.tendsto_atTop_add_const_right _ _ <| tendsto_id.const_mul_atTop (neg_pos.mpr ha)
lemma cexp_neg_quadratic_isLittleO_rpow_atTop {a : ℂ} (ha : a.re < 0) (b : ℂ) (s : ℝ) :
(fun x : ℝ ↦ cexp (a * x ^ 2 + b * x)) =o[atTop] (· ^ s) := by
apply Asymptotics.IsLittleO.of_norm_left
convert rexp_neg_quadratic_isLittleO_rpow_atTop ha b.re s with x
simp_rw [Complex.norm_eq_abs, Complex.abs_exp, add_re, ← ofReal_pow, mul_comm (_ : ℂ) ↑(_ : ℝ),
re_ofReal_mul, mul_comm _ (re _)]
lemma cexp_neg_quadratic_isLittleO_abs_rpow_cocompact {a : ℂ} (ha : a.re < 0) (b : ℂ) (s : ℝ) :
(fun x : ℝ ↦ cexp (a * x ^ 2 + b * x)) =o[cocompact ℝ] (|·| ^ s) := by
rw [cocompact_eq_atBot_atTop, isLittleO_sup]
constructor
· refine ((cexp_neg_quadratic_isLittleO_rpow_atTop ha (-b) s).comp_tendsto
Filter.tendsto_neg_atBot_atTop).congr' (eventually_of_forall fun x ↦ ?_) ?_
· simp only [neg_mul, Function.comp_apply, ofReal_neg, neg_sq, mul_neg, neg_neg]
· refine (eventually_lt_atBot 0).mp (eventually_of_forall fun x hx ↦ ?_)
simp only [Function.comp_apply, abs_of_neg hx]
· refine (cexp_neg_quadratic_isLittleO_rpow_atTop ha b s).congr' EventuallyEq.rfl ?_
refine (eventually_gt_atTop 0).mp (eventually_of_forall fun x hx ↦ ?_)
simp_rw [abs_of_pos hx]
theorem tendsto_rpow_abs_mul_exp_neg_mul_sq_cocompact {a : ℝ} (ha : 0 < a) (s : ℝ) :
Tendsto (fun x : ℝ => |x| ^ s * rexp (-a * x ^ 2)) (cocompact ℝ) (𝓝 0) := by
conv in rexp _ => rw [← sq_abs]
erw [cocompact_eq_atBot_atTop, ← comap_abs_atTop,
@tendsto_comap'_iff _ _ _ (fun y => y ^ s * rexp (-a * y ^ 2)) _ _ _
(mem_atTop_sets.mpr ⟨0, fun b hb => ⟨b, abs_of_nonneg hb⟩⟩)]
exact
(rpow_mul_exp_neg_mul_sq_isLittleO_exp_neg ha s).tendsto_zero_of_tendsto
(tendsto_exp_atBot.comp <| tendsto_id.const_mul_atTop_of_neg (neg_lt_zero.mpr one_half_pos))
theorem isLittleO_exp_neg_mul_sq_cocompact {a : ℂ} (ha : 0 < a.re) (s : ℝ) :
(fun x : ℝ => Complex.exp (-a * x ^ 2)) =o[cocompact ℝ] fun x : ℝ => |x| ^ s := by
convert cexp_neg_quadratic_isLittleO_abs_rpow_cocompact (?_ : (-a).re < 0) 0 s using 1
· simp_rw [zero_mul, add_zero]
· rwa [neg_re, neg_lt_zero]
/-- Jacobi's theta-function transformation formula for the sum of `exp -Q(x)`, where `Q` is a
negative definite quadratic form. -/
theorem Complex.tsum_exp_neg_quadratic {a : ℂ} (ha : 0 < a.re) (b : ℂ) :
(∑' n : ℤ, cexp (-π * a * n ^ 2 + 2 * π * b * n)) =
1 / a ^ (1 / 2 : ℂ) * ∑' n : ℤ, cexp (-π / a * (n + I * b) ^ 2) := by
let f : ℝ → ℂ := fun x ↦ cexp (-π * a * x ^ 2 + 2 * π * b * x)
have hCf : Continuous f := by
refine Complex.continuous_exp.comp (Continuous.add ?_ ?_)
· exact continuous_const.mul (Complex.continuous_ofReal.pow 2)
· exact continuous_const.mul Complex.continuous_ofReal
have hFf : 𝓕 f = fun x : ℝ ↦ 1 / a ^ (1 / 2 : ℂ) * cexp (-π / a * (x + I * b) ^ 2) :=
fourierIntegral_gaussian_pi' ha b
have h1 : 0 < (↑π * a).re := by
rw [re_ofReal_mul]
exact mul_pos pi_pos ha
have h2 : 0 < (↑π / a).re := by
rw [div_eq_mul_inv, re_ofReal_mul, inv_re]
refine mul_pos pi_pos (div_pos ha <| normSq_pos.mpr ?_)
contrapose! ha
rw [ha, zero_re]
have f_bd : f =O[cocompact ℝ] (fun x => |x| ^ (-2 : ℝ)) := by
convert (cexp_neg_quadratic_isLittleO_abs_rpow_cocompact ?_ _ (-2)).isBigO
rwa [neg_mul, neg_re, neg_lt_zero]
have Ff_bd : (𝓕 f) =O[cocompact ℝ] (fun x => |x| ^ (-2 : ℝ)) := by
rw [hFf]
have : ∀ (x : ℝ), -↑π / a * (↑x + I * b) ^ 2 =
-↑π / a * x ^ 2 + (-2 * π * I * b) / a * x + π * b ^ 2 / a := by
intro x; ring_nf; rw [I_sq]; ring
simp_rw [this]
conv => enter [2, x]; rw [Complex.exp_add, ← mul_assoc _ _ (Complex.exp _), mul_comm]
refine ((cexp_neg_quadratic_isLittleO_abs_rpow_cocompact
(?_) (-2 * ↑π * I * b / a) (-2)).isBigO.const_mul_left _).const_mul_left _
rwa [neg_div, neg_re, neg_lt_zero]
convert Real.tsum_eq_tsum_fourierIntegral_of_rpow_decay hCf one_lt_two f_bd Ff_bd 0 using 1
· simp only [f, zero_add, ofReal_intCast]
· rw [← tsum_mul_left]
simp only [QuotientAddGroup.mk_zero, fourier_eval_zero, mul_one, hFf, ofReal_intCast]
theorem Complex.tsum_exp_neg_mul_int_sq {a : ℂ} (ha : 0 < a.re) :
(∑' n : ℤ, cexp (-π * a * (n : ℂ) ^ 2)) =
1 / a ^ (1 / 2 : ℂ) * ∑' n : ℤ, cexp (-π / a * (n : ℂ) ^ 2) := by
simpa only [mul_zero, zero_mul, add_zero] using Complex.tsum_exp_neg_quadratic ha 0
theorem Real.tsum_exp_neg_mul_int_sq {a : ℝ} (ha : 0 < a) :
(∑' n : ℤ, exp (-π * a * (n : ℝ) ^ 2)) =
(1 : ℝ) / a ^ (1 / 2 : ℝ) * (∑' n : ℤ, exp (-π / a * (n : ℝ) ^ 2)) := by
simpa only [← ofReal_inj, ofReal_tsum, ofReal_exp, ofReal_mul, ofReal_neg, ofReal_pow,
ofReal_intCast, ofReal_div, ofReal_one, ofReal_cpow ha.le, ofReal_ofNat, mul_zero, zero_mul,
add_zero] using Complex.tsum_exp_neg_quadratic (by rwa [ofReal_re] : 0 < (a : ℂ).re) 0
end GaussianPoisson
|
Analysis\SpecialFunctions\Log\Base.lean | /-
Copyright (c) 2022 Bolton Bailey. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Bolton Bailey, Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne
-/
import Mathlib.Analysis.SpecialFunctions.Pow.Real
import Mathlib.Data.Int.Log
/-!
# Real logarithm base `b`
In this file we define `Real.logb` to be the logarithm of a real number in a given base `b`. We
define this as the division of the natural logarithms of the argument and the base, so that we have
a globally defined function with `logb b 0 = 0`, `logb b (-x) = logb b x` `logb 0 x = 0` and
`logb (-b) x = logb b x`.
We prove some basic properties of this function and its relation to `rpow`.
## Tags
logarithm, continuity
-/
open Set Filter Function
open Topology
noncomputable section
namespace Real
variable {b x y : ℝ}
/-- The real logarithm in a given base. As with the natural logarithm, we define `logb b x` to
be `logb b |x|` for `x < 0`, and `0` for `x = 0`. -/
@[pp_nodot]
noncomputable def logb (b x : ℝ) : ℝ :=
log x / log b
theorem log_div_log : log x / log b = logb b x :=
rfl
@[simp]
theorem logb_zero : logb b 0 = 0 := by simp [logb]
@[simp]
theorem logb_one : logb b 1 = 0 := by simp [logb]
@[simp]
lemma logb_self_eq_one (hb : 1 < b) : logb b b = 1 :=
div_self (log_pos hb).ne'
lemma logb_self_eq_one_iff : logb b b = 1 ↔ b ≠ 0 ∧ b ≠ 1 ∧ b ≠ -1 :=
Iff.trans ⟨fun h h' => by simp [logb, h'] at h, div_self⟩ log_ne_zero
@[simp]
theorem logb_abs (x : ℝ) : logb b |x| = logb b x := by rw [logb, logb, log_abs]
@[simp]
theorem logb_neg_eq_logb (x : ℝ) : logb b (-x) = logb b x := by
rw [← logb_abs x, ← logb_abs (-x), abs_neg]
theorem logb_mul (hx : x ≠ 0) (hy : y ≠ 0) : logb b (x * y) = logb b x + logb b y := by
simp_rw [logb, log_mul hx hy, add_div]
theorem logb_div (hx : x ≠ 0) (hy : y ≠ 0) : logb b (x / y) = logb b x - logb b y := by
simp_rw [logb, log_div hx hy, sub_div]
@[simp]
theorem logb_inv (x : ℝ) : logb b x⁻¹ = -logb b x := by simp [logb, neg_div]
theorem inv_logb (a b : ℝ) : (logb a b)⁻¹ = logb b a := by simp_rw [logb, inv_div]
theorem inv_logb_mul_base {a b : ℝ} (h₁ : a ≠ 0) (h₂ : b ≠ 0) (c : ℝ) :
(logb (a * b) c)⁻¹ = (logb a c)⁻¹ + (logb b c)⁻¹ := by
simp_rw [inv_logb]; exact logb_mul h₁ h₂
theorem inv_logb_div_base {a b : ℝ} (h₁ : a ≠ 0) (h₂ : b ≠ 0) (c : ℝ) :
(logb (a / b) c)⁻¹ = (logb a c)⁻¹ - (logb b c)⁻¹ := by
simp_rw [inv_logb]; exact logb_div h₁ h₂
theorem logb_mul_base {a b : ℝ} (h₁ : a ≠ 0) (h₂ : b ≠ 0) (c : ℝ) :
logb (a * b) c = ((logb a c)⁻¹ + (logb b c)⁻¹)⁻¹ := by rw [← inv_logb_mul_base h₁ h₂ c, inv_inv]
theorem logb_div_base {a b : ℝ} (h₁ : a ≠ 0) (h₂ : b ≠ 0) (c : ℝ) :
logb (a / b) c = ((logb a c)⁻¹ - (logb b c)⁻¹)⁻¹ := by rw [← inv_logb_div_base h₁ h₂ c, inv_inv]
theorem mul_logb {a b c : ℝ} (h₁ : b ≠ 0) (h₂ : b ≠ 1) (h₃ : b ≠ -1) :
logb a b * logb b c = logb a c := by
unfold logb
rw [mul_comm, div_mul_div_cancel _ (log_ne_zero.mpr ⟨h₁, h₂, h₃⟩)]
theorem div_logb {a b c : ℝ} (h₁ : c ≠ 0) (h₂ : c ≠ 1) (h₃ : c ≠ -1) :
logb a c / logb b c = logb a b :=
div_div_div_cancel_left' _ _ <| log_ne_zero.mpr ⟨h₁, h₂, h₃⟩
theorem logb_rpow_eq_mul_logb_of_pos (hx : 0 < x) : logb b (x ^ y) = y * logb b x := by
rw [logb, log_rpow hx, logb, mul_div_assoc]
theorem logb_pow {k : ℕ} (hx : 0 < x) : logb b (x ^ k) = k * logb b x := by
rw [← rpow_natCast, logb_rpow_eq_mul_logb_of_pos hx]
section BPosAndNeOne
variable (b_pos : 0 < b) (b_ne_one : b ≠ 1)
private theorem log_b_ne_zero : log b ≠ 0 := by
have b_ne_zero : b ≠ 0 := by linarith
have b_ne_minus_one : b ≠ -1 := by linarith
simp [b_ne_one, b_ne_zero, b_ne_minus_one]
@[simp]
theorem logb_rpow : logb b (b ^ x) = x := by
rw [logb, div_eq_iff, log_rpow b_pos]
exact log_b_ne_zero b_pos b_ne_one
theorem rpow_logb_eq_abs (hx : x ≠ 0) : b ^ logb b x = |x| := by
apply log_injOn_pos
· simp only [Set.mem_Ioi]
apply rpow_pos_of_pos b_pos
· simp only [abs_pos, mem_Ioi, Ne, hx, not_false_iff]
rw [log_rpow b_pos, logb, log_abs]
field_simp [log_b_ne_zero b_pos b_ne_one]
@[simp]
theorem rpow_logb (hx : 0 < x) : b ^ logb b x = x := by
rw [rpow_logb_eq_abs b_pos b_ne_one hx.ne']
exact abs_of_pos hx
theorem rpow_logb_of_neg (hx : x < 0) : b ^ logb b x = -x := by
rw [rpow_logb_eq_abs b_pos b_ne_one (ne_of_lt hx)]
exact abs_of_neg hx
theorem logb_eq_iff_rpow_eq (hy : 0 < y) : logb b y = x ↔ b ^ x = y := by
constructor <;> rintro rfl
· exact rpow_logb b_pos b_ne_one hy
· exact logb_rpow b_pos b_ne_one
theorem surjOn_logb : SurjOn (logb b) (Ioi 0) univ := fun x _ =>
⟨b ^ x, rpow_pos_of_pos b_pos x, logb_rpow b_pos b_ne_one⟩
theorem logb_surjective : Surjective (logb b) := fun x => ⟨b ^ x, logb_rpow b_pos b_ne_one⟩
@[simp]
theorem range_logb : range (logb b) = univ :=
(logb_surjective b_pos b_ne_one).range_eq
theorem surjOn_logb' : SurjOn (logb b) (Iio 0) univ := by
intro x _
use -b ^ x
constructor
· simp only [Right.neg_neg_iff, Set.mem_Iio]
apply rpow_pos_of_pos b_pos
· rw [logb_neg_eq_logb, logb_rpow b_pos b_ne_one]
end BPosAndNeOne
section OneLtB
variable (hb : 1 < b)
private theorem b_pos : 0 < b := by linarith
-- Porting note: prime added to avoid clashing with `b_ne_one` further down the file
private theorem b_ne_one' : b ≠ 1 := by linarith
@[simp]
theorem logb_le_logb (h : 0 < x) (h₁ : 0 < y) : logb b x ≤ logb b y ↔ x ≤ y := by
rw [logb, logb, div_le_div_right (log_pos hb), log_le_log_iff h h₁]
@[gcongr]
theorem logb_le_logb_of_le (h : 0 < x) (hxy : x ≤ y) : logb b x ≤ logb b y :=
(logb_le_logb hb h (by linarith)).mpr hxy
@[gcongr]
theorem logb_lt_logb (hx : 0 < x) (hxy : x < y) : logb b x < logb b y := by
rw [logb, logb, div_lt_div_right (log_pos hb)]
exact log_lt_log hx hxy
@[simp]
theorem logb_lt_logb_iff (hx : 0 < x) (hy : 0 < y) : logb b x < logb b y ↔ x < y := by
rw [logb, logb, div_lt_div_right (log_pos hb)]
exact log_lt_log_iff hx hy
theorem logb_le_iff_le_rpow (hx : 0 < x) : logb b x ≤ y ↔ x ≤ b ^ y := by
rw [← rpow_le_rpow_left_iff hb, rpow_logb (b_pos hb) (b_ne_one' hb) hx]
theorem logb_lt_iff_lt_rpow (hx : 0 < x) : logb b x < y ↔ x < b ^ y := by
rw [← rpow_lt_rpow_left_iff hb, rpow_logb (b_pos hb) (b_ne_one' hb) hx]
theorem le_logb_iff_rpow_le (hy : 0 < y) : x ≤ logb b y ↔ b ^ x ≤ y := by
rw [← rpow_le_rpow_left_iff hb, rpow_logb (b_pos hb) (b_ne_one' hb) hy]
theorem lt_logb_iff_rpow_lt (hy : 0 < y) : x < logb b y ↔ b ^ x < y := by
rw [← rpow_lt_rpow_left_iff hb, rpow_logb (b_pos hb) (b_ne_one' hb) hy]
theorem logb_pos_iff (hx : 0 < x) : 0 < logb b x ↔ 1 < x := by
rw [← @logb_one b]
rw [logb_lt_logb_iff hb zero_lt_one hx]
theorem logb_pos (hx : 1 < x) : 0 < logb b x := by
rw [logb_pos_iff hb (lt_trans zero_lt_one hx)]
exact hx
theorem logb_neg_iff (h : 0 < x) : logb b x < 0 ↔ x < 1 := by
rw [← logb_one]
exact logb_lt_logb_iff hb h zero_lt_one
theorem logb_neg (h0 : 0 < x) (h1 : x < 1) : logb b x < 0 :=
(logb_neg_iff hb h0).2 h1
theorem logb_nonneg_iff (hx : 0 < x) : 0 ≤ logb b x ↔ 1 ≤ x := by
rw [← not_lt, logb_neg_iff hb hx, not_lt]
theorem logb_nonneg (hx : 1 ≤ x) : 0 ≤ logb b x :=
(logb_nonneg_iff hb (zero_lt_one.trans_le hx)).2 hx
theorem logb_nonpos_iff (hx : 0 < x) : logb b x ≤ 0 ↔ x ≤ 1 := by
rw [← not_lt, logb_pos_iff hb hx, not_lt]
theorem logb_nonpos_iff' (hx : 0 ≤ x) : logb b x ≤ 0 ↔ x ≤ 1 := by
rcases hx.eq_or_lt with (rfl | hx)
· simp [le_refl, zero_le_one]
exact logb_nonpos_iff hb hx
theorem logb_nonpos (hx : 0 ≤ x) (h'x : x ≤ 1) : logb b x ≤ 0 :=
(logb_nonpos_iff' hb hx).2 h'x
theorem strictMonoOn_logb : StrictMonoOn (logb b) (Set.Ioi 0) := fun _ hx _ _ hxy =>
logb_lt_logb hb hx hxy
theorem strictAntiOn_logb : StrictAntiOn (logb b) (Set.Iio 0) := by
rintro x (hx : x < 0) y (hy : y < 0) hxy
rw [← logb_abs y, ← logb_abs x]
refine logb_lt_logb hb (abs_pos.2 hy.ne) ?_
rwa [abs_of_neg hy, abs_of_neg hx, neg_lt_neg_iff]
theorem logb_injOn_pos : Set.InjOn (logb b) (Set.Ioi 0) :=
(strictMonoOn_logb hb).injOn
theorem eq_one_of_pos_of_logb_eq_zero (h₁ : 0 < x) (h₂ : logb b x = 0) : x = 1 :=
logb_injOn_pos hb (Set.mem_Ioi.2 h₁) (Set.mem_Ioi.2 zero_lt_one) (h₂.trans Real.logb_one.symm)
theorem logb_ne_zero_of_pos_of_ne_one (hx_pos : 0 < x) (hx : x ≠ 1) : logb b x ≠ 0 :=
mt (eq_one_of_pos_of_logb_eq_zero hb hx_pos) hx
theorem tendsto_logb_atTop : Tendsto (logb b) atTop atTop :=
Tendsto.atTop_div_const (log_pos hb) tendsto_log_atTop
end OneLtB
section BPosAndBLtOne
variable (b_pos : 0 < b) (b_lt_one : b < 1)
private theorem b_ne_one : b ≠ 1 := by linarith
@[simp]
theorem logb_le_logb_of_base_lt_one (h : 0 < x) (h₁ : 0 < y) : logb b x ≤ logb b y ↔ y ≤ x := by
rw [logb, logb, div_le_div_right_of_neg (log_neg b_pos b_lt_one), log_le_log_iff h₁ h]
theorem logb_lt_logb_of_base_lt_one (hx : 0 < x) (hxy : x < y) : logb b y < logb b x := by
rw [logb, logb, div_lt_div_right_of_neg (log_neg b_pos b_lt_one)]
exact log_lt_log hx hxy
@[simp]
theorem logb_lt_logb_iff_of_base_lt_one (hx : 0 < x) (hy : 0 < y) :
logb b x < logb b y ↔ y < x := by
rw [logb, logb, div_lt_div_right_of_neg (log_neg b_pos b_lt_one)]
exact log_lt_log_iff hy hx
theorem logb_le_iff_le_rpow_of_base_lt_one (hx : 0 < x) : logb b x ≤ y ↔ b ^ y ≤ x := by
rw [← rpow_le_rpow_left_iff_of_base_lt_one b_pos b_lt_one, rpow_logb b_pos (b_ne_one b_lt_one) hx]
theorem logb_lt_iff_lt_rpow_of_base_lt_one (hx : 0 < x) : logb b x < y ↔ b ^ y < x := by
rw [← rpow_lt_rpow_left_iff_of_base_lt_one b_pos b_lt_one, rpow_logb b_pos (b_ne_one b_lt_one) hx]
theorem le_logb_iff_rpow_le_of_base_lt_one (hy : 0 < y) : x ≤ logb b y ↔ y ≤ b ^ x := by
rw [← rpow_le_rpow_left_iff_of_base_lt_one b_pos b_lt_one, rpow_logb b_pos (b_ne_one b_lt_one) hy]
theorem lt_logb_iff_rpow_lt_of_base_lt_one (hy : 0 < y) : x < logb b y ↔ y < b ^ x := by
rw [← rpow_lt_rpow_left_iff_of_base_lt_one b_pos b_lt_one, rpow_logb b_pos (b_ne_one b_lt_one) hy]
theorem logb_pos_iff_of_base_lt_one (hx : 0 < x) : 0 < logb b x ↔ x < 1 := by
rw [← @logb_one b, logb_lt_logb_iff_of_base_lt_one b_pos b_lt_one zero_lt_one hx]
theorem logb_pos_of_base_lt_one (hx : 0 < x) (hx' : x < 1) : 0 < logb b x := by
rw [logb_pos_iff_of_base_lt_one b_pos b_lt_one hx]
exact hx'
theorem logb_neg_iff_of_base_lt_one (h : 0 < x) : logb b x < 0 ↔ 1 < x := by
rw [← @logb_one b, logb_lt_logb_iff_of_base_lt_one b_pos b_lt_one h zero_lt_one]
theorem logb_neg_of_base_lt_one (h1 : 1 < x) : logb b x < 0 :=
(logb_neg_iff_of_base_lt_one b_pos b_lt_one (lt_trans zero_lt_one h1)).2 h1
theorem logb_nonneg_iff_of_base_lt_one (hx : 0 < x) : 0 ≤ logb b x ↔ x ≤ 1 := by
rw [← not_lt, logb_neg_iff_of_base_lt_one b_pos b_lt_one hx, not_lt]
theorem logb_nonneg_of_base_lt_one (hx : 0 < x) (hx' : x ≤ 1) : 0 ≤ logb b x := by
rw [logb_nonneg_iff_of_base_lt_one b_pos b_lt_one hx]
exact hx'
theorem logb_nonpos_iff_of_base_lt_one (hx : 0 < x) : logb b x ≤ 0 ↔ 1 ≤ x := by
rw [← not_lt, logb_pos_iff_of_base_lt_one b_pos b_lt_one hx, not_lt]
theorem strictAntiOn_logb_of_base_lt_one : StrictAntiOn (logb b) (Set.Ioi 0) := fun _ hx _ _ hxy =>
logb_lt_logb_of_base_lt_one b_pos b_lt_one hx hxy
theorem strictMonoOn_logb_of_base_lt_one : StrictMonoOn (logb b) (Set.Iio 0) := by
rintro x (hx : x < 0) y (hy : y < 0) hxy
rw [← logb_abs y, ← logb_abs x]
refine logb_lt_logb_of_base_lt_one b_pos b_lt_one (abs_pos.2 hy.ne) ?_
rwa [abs_of_neg hy, abs_of_neg hx, neg_lt_neg_iff]
theorem logb_injOn_pos_of_base_lt_one : Set.InjOn (logb b) (Set.Ioi 0) :=
(strictAntiOn_logb_of_base_lt_one b_pos b_lt_one).injOn
theorem eq_one_of_pos_of_logb_eq_zero_of_base_lt_one (h₁ : 0 < x) (h₂ : logb b x = 0) : x = 1 :=
logb_injOn_pos_of_base_lt_one b_pos b_lt_one (Set.mem_Ioi.2 h₁) (Set.mem_Ioi.2 zero_lt_one)
(h₂.trans Real.logb_one.symm)
theorem logb_ne_zero_of_pos_of_ne_one_of_base_lt_one (hx_pos : 0 < x) (hx : x ≠ 1) : logb b x ≠ 0 :=
mt (eq_one_of_pos_of_logb_eq_zero_of_base_lt_one b_pos b_lt_one hx_pos) hx
theorem tendsto_logb_atTop_of_base_lt_one : Tendsto (logb b) atTop atBot := by
rw [tendsto_atTop_atBot]
intro e
use 1 ⊔ b ^ e
intro a
simp only [and_imp, sup_le_iff]
intro ha
rw [logb_le_iff_le_rpow_of_base_lt_one b_pos b_lt_one]
· tauto
· exact lt_of_lt_of_le zero_lt_one ha
end BPosAndBLtOne
theorem floor_logb_natCast {b : ℕ} {r : ℝ} (hb : 1 < b) (hr : 0 ≤ r) :
⌊logb b r⌋ = Int.log b r := by
obtain rfl | hr := hr.eq_or_lt
· rw [logb_zero, Int.log_zero_right, Int.floor_zero]
have hb1' : 1 < (b : ℝ) := Nat.one_lt_cast.mpr hb
apply le_antisymm
· rw [← Int.zpow_le_iff_le_log hb hr, ← rpow_intCast b]
refine le_of_le_of_eq ?_ (rpow_logb (zero_lt_one.trans hb1') hb1'.ne' hr)
exact rpow_le_rpow_of_exponent_le hb1'.le (Int.floor_le _)
· rw [Int.le_floor, le_logb_iff_rpow_le hb1' hr, rpow_intCast]
exact Int.zpow_log_le_self hb hr
@[deprecated (since := "2024-04-17")]
alias floor_logb_nat_cast := floor_logb_natCast
theorem ceil_logb_natCast {b : ℕ} {r : ℝ} (hb : 1 < b) (hr : 0 ≤ r) :
⌈logb b r⌉ = Int.clog b r := by
obtain rfl | hr := hr.eq_or_lt
· rw [logb_zero, Int.clog_zero_right, Int.ceil_zero]
have hb1' : 1 < (b : ℝ) := Nat.one_lt_cast.mpr hb
apply le_antisymm
· rw [Int.ceil_le, logb_le_iff_le_rpow hb1' hr, rpow_intCast]
exact Int.self_le_zpow_clog hb r
· rw [← Int.le_zpow_iff_clog_le hb hr, ← rpow_intCast b]
refine (rpow_logb (zero_lt_one.trans hb1') hb1'.ne' hr).symm.trans_le ?_
exact rpow_le_rpow_of_exponent_le hb1'.le (Int.le_ceil _)
@[deprecated (since := "2024-04-17")]
alias ceil_logb_nat_cast := ceil_logb_natCast
@[simp]
theorem logb_eq_zero : logb b x = 0 ↔ b = 0 ∨ b = 1 ∨ b = -1 ∨ x = 0 ∨ x = 1 ∨ x = -1 := by
simp_rw [logb, div_eq_zero_iff, log_eq_zero]
tauto
-- TODO add other limits and continuous API lemmas analogous to those in Log.lean
theorem logb_prod {α : Type*} (s : Finset α) (f : α → ℝ) (hf : ∀ x ∈ s, f x ≠ 0) :
logb b (∏ i ∈ s, f i) = ∑ i ∈ s, logb b (f i) := by
classical
induction' s using Finset.induction_on with a s ha ih
· simp
simp only [Finset.mem_insert, forall_eq_or_imp] at hf
simp [ha, ih hf.2, logb_mul hf.1 (Finset.prod_ne_zero_iff.2 hf.2)]
end Real
section Induction
/-- Induction principle for intervals of real numbers: if a proposition `P` is true
on `[x₀, r * x₀)` and if `P` for `[x₀, r^n * x₀)` implies `P` for `[r^n * x₀, r^(n+1) * x₀)`,
then `P` is true for all `x ≥ x₀`. -/
lemma Real.induction_Ico_mul {P : ℝ → Prop} (x₀ r : ℝ) (hr : 1 < r) (hx₀ : 0 < x₀)
(base : ∀ x ∈ Set.Ico x₀ (r * x₀), P x)
(step : ∀ n : ℕ, n ≥ 1 → (∀ z ∈ Set.Ico x₀ (r ^ n * x₀), P z) →
(∀ z ∈ Set.Ico (r ^ n * x₀) (r ^ (n+1) * x₀), P z)) :
∀ x ≥ x₀, P x := by
suffices ∀ n : ℕ, ∀ x ∈ Set.Ico x₀ (r ^ (n + 1) * x₀), P x by
intro x hx
have hx' : 0 < x / x₀ := div_pos (hx₀.trans_le hx) hx₀
refine this ⌊logb r (x / x₀)⌋₊ x ?_
rw [mem_Ico, ← div_lt_iff hx₀, ← rpow_natCast, ← logb_lt_iff_lt_rpow hr hx', Nat.cast_add,
Nat.cast_one]
exact ⟨hx, Nat.lt_floor_add_one _⟩
intro n
induction n with
| zero => simpa using base
| succ n ih =>
exact fun x hx => (Ico_subset_Ico_union_Ico hx).elim (ih x) (step (n + 1) (by simp) ih _)
end Induction
|
Analysis\SpecialFunctions\Log\Basic.lean | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne
-/
import Mathlib.Analysis.SpecialFunctions.Exp
import Mathlib.Data.Nat.Factorization.Defs
import Mathlib.Analysis.NormedSpace.Real
/-!
# Real logarithm
In this file we define `Real.log` to be the logarithm of a real number. As usual, we extend it from
its domain `(0, +∞)` to a globally defined function. We choose to do it so that `log 0 = 0` and
`log (-x) = log x`.
We prove some basic properties of this function and show that it is continuous.
## Tags
logarithm, continuity
-/
open Set Filter Function
open Topology
noncomputable section
namespace Real
variable {x y : ℝ}
/-- The real logarithm function, equal to the inverse of the exponential for `x > 0`,
to `log |x|` for `x < 0`, and to `0` for `0`. We use this unconventional extension to
`(-∞, 0]` as it gives the formula `log (x * y) = log x + log y` for all nonzero `x` and `y`, and
the derivative of `log` is `1/x` away from `0`. -/
@[pp_nodot]
noncomputable def log (x : ℝ) : ℝ :=
if hx : x = 0 then 0 else expOrderIso.symm ⟨|x|, abs_pos.2 hx⟩
theorem log_of_ne_zero (hx : x ≠ 0) : log x = expOrderIso.symm ⟨|x|, abs_pos.2 hx⟩ :=
dif_neg hx
theorem log_of_pos (hx : 0 < x) : log x = expOrderIso.symm ⟨x, hx⟩ := by
rw [log_of_ne_zero hx.ne']
congr
exact abs_of_pos hx
theorem exp_log_eq_abs (hx : x ≠ 0) : exp (log x) = |x| := by
rw [log_of_ne_zero hx, ← coe_expOrderIso_apply, OrderIso.apply_symm_apply, Subtype.coe_mk]
theorem exp_log (hx : 0 < x) : exp (log x) = x := by
rw [exp_log_eq_abs hx.ne']
exact abs_of_pos hx
theorem exp_log_of_neg (hx : x < 0) : exp (log x) = -x := by
rw [exp_log_eq_abs (ne_of_lt hx)]
exact abs_of_neg hx
theorem le_exp_log (x : ℝ) : x ≤ exp (log x) := by
by_cases h_zero : x = 0
· rw [h_zero, log, dif_pos rfl, exp_zero]
exact zero_le_one
· rw [exp_log_eq_abs h_zero]
exact le_abs_self _
@[simp]
theorem log_exp (x : ℝ) : log (exp x) = x :=
exp_injective <| exp_log (exp_pos x)
theorem surjOn_log : SurjOn log (Ioi 0) univ := fun x _ => ⟨exp x, exp_pos x, log_exp x⟩
theorem log_surjective : Surjective log := fun x => ⟨exp x, log_exp x⟩
@[simp]
theorem range_log : range log = univ :=
log_surjective.range_eq
@[simp]
theorem log_zero : log 0 = 0 :=
dif_pos rfl
@[simp]
theorem log_one : log 1 = 0 :=
exp_injective <| by rw [exp_log zero_lt_one, exp_zero]
@[simp]
theorem log_abs (x : ℝ) : log |x| = log x := by
by_cases h : x = 0
· simp [h]
· rw [← exp_eq_exp, exp_log_eq_abs h, exp_log_eq_abs (abs_pos.2 h).ne', abs_abs]
@[simp]
theorem log_neg_eq_log (x : ℝ) : log (-x) = log x := by rw [← log_abs x, ← log_abs (-x), abs_neg]
theorem sinh_log {x : ℝ} (hx : 0 < x) : sinh (log x) = (x - x⁻¹) / 2 := by
rw [sinh_eq, exp_neg, exp_log hx]
theorem cosh_log {x : ℝ} (hx : 0 < x) : cosh (log x) = (x + x⁻¹) / 2 := by
rw [cosh_eq, exp_neg, exp_log hx]
theorem surjOn_log' : SurjOn log (Iio 0) univ := fun x _ =>
⟨-exp x, neg_lt_zero.2 <| exp_pos x, by rw [log_neg_eq_log, log_exp]⟩
theorem log_mul (hx : x ≠ 0) (hy : y ≠ 0) : log (x * y) = log x + log y :=
exp_injective <| by
rw [exp_log_eq_abs (mul_ne_zero hx hy), exp_add, exp_log_eq_abs hx, exp_log_eq_abs hy, abs_mul]
theorem log_div (hx : x ≠ 0) (hy : y ≠ 0) : log (x / y) = log x - log y :=
exp_injective <| by
rw [exp_log_eq_abs (div_ne_zero hx hy), exp_sub, exp_log_eq_abs hx, exp_log_eq_abs hy, abs_div]
@[simp]
theorem log_inv (x : ℝ) : log x⁻¹ = -log x := by
by_cases hx : x = 0; · simp [hx]
rw [← exp_eq_exp, exp_log_eq_abs (inv_ne_zero hx), exp_neg, exp_log_eq_abs hx, abs_inv]
theorem log_le_log_iff (h : 0 < x) (h₁ : 0 < y) : log x ≤ log y ↔ x ≤ y := by
rw [← exp_le_exp, exp_log h, exp_log h₁]
@[gcongr, bound]
lemma log_le_log (hx : 0 < x) (hxy : x ≤ y) : log x ≤ log y :=
(log_le_log_iff hx (hx.trans_le hxy)).2 hxy
@[gcongr]
theorem log_lt_log (hx : 0 < x) (h : x < y) : log x < log y := by
rwa [← exp_lt_exp, exp_log hx, exp_log (lt_trans hx h)]
theorem log_lt_log_iff (hx : 0 < x) (hy : 0 < y) : log x < log y ↔ x < y := by
rw [← exp_lt_exp, exp_log hx, exp_log hy]
theorem log_le_iff_le_exp (hx : 0 < x) : log x ≤ y ↔ x ≤ exp y := by rw [← exp_le_exp, exp_log hx]
theorem log_lt_iff_lt_exp (hx : 0 < x) : log x < y ↔ x < exp y := by rw [← exp_lt_exp, exp_log hx]
theorem le_log_iff_exp_le (hy : 0 < y) : x ≤ log y ↔ exp x ≤ y := by rw [← exp_le_exp, exp_log hy]
theorem lt_log_iff_exp_lt (hy : 0 < y) : x < log y ↔ exp x < y := by rw [← exp_lt_exp, exp_log hy]
theorem log_pos_iff (hx : 0 < x) : 0 < log x ↔ 1 < x := by
rw [← log_one]
exact log_lt_log_iff zero_lt_one hx
theorem log_pos (hx : 1 < x) : 0 < log x :=
(log_pos_iff (lt_trans zero_lt_one hx)).2 hx
theorem log_pos_of_lt_neg_one (hx : x < -1) : 0 < log x := by
rw [← neg_neg x, log_neg_eq_log]
have : 1 < -x := by linarith
exact log_pos this
theorem log_neg_iff (h : 0 < x) : log x < 0 ↔ x < 1 := by
rw [← log_one]
exact log_lt_log_iff h zero_lt_one
theorem log_neg (h0 : 0 < x) (h1 : x < 1) : log x < 0 :=
(log_neg_iff h0).2 h1
theorem log_neg_of_lt_zero (h0 : x < 0) (h1 : -1 < x) : log x < 0 := by
rw [← neg_neg x, log_neg_eq_log]
have h0' : 0 < -x := by linarith
have h1' : -x < 1 := by linarith
exact log_neg h0' h1'
theorem log_nonneg_iff (hx : 0 < x) : 0 ≤ log x ↔ 1 ≤ x := by rw [← not_lt, log_neg_iff hx, not_lt]
@[bound]
theorem log_nonneg (hx : 1 ≤ x) : 0 ≤ log x :=
(log_nonneg_iff (zero_lt_one.trans_le hx)).2 hx
theorem log_nonpos_iff (hx : 0 < x) : log x ≤ 0 ↔ x ≤ 1 := by rw [← not_lt, log_pos_iff hx, not_lt]
theorem log_nonpos_iff' (hx : 0 ≤ x) : log x ≤ 0 ↔ x ≤ 1 := by
rcases hx.eq_or_lt with (rfl | hx)
· simp [le_refl, zero_le_one]
exact log_nonpos_iff hx
theorem log_nonpos (hx : 0 ≤ x) (h'x : x ≤ 1) : log x ≤ 0 :=
(log_nonpos_iff' hx).2 h'x
theorem log_natCast_nonneg (n : ℕ) : 0 ≤ log n := by
if hn : n = 0 then
simp [hn]
else
have : (1 : ℝ) ≤ n := mod_cast Nat.one_le_of_lt <| Nat.pos_of_ne_zero hn
exact log_nonneg this
@[deprecated (since := "2024-04-17")]
alias log_nat_cast_nonneg := log_natCast_nonneg
theorem log_neg_natCast_nonneg (n : ℕ) : 0 ≤ log (-n) := by
rw [← log_neg_eq_log, neg_neg]
exact log_natCast_nonneg _
@[deprecated (since := "2024-04-17")]
alias log_neg_nat_cast_nonneg := log_neg_natCast_nonneg
theorem log_intCast_nonneg (n : ℤ) : 0 ≤ log n := by
cases lt_trichotomy 0 n with
| inl hn =>
have : (1 : ℝ) ≤ n := mod_cast hn
exact log_nonneg this
| inr hn =>
cases hn with
| inl hn => simp [hn.symm]
| inr hn =>
have : (1 : ℝ) ≤ -n := by rw [← neg_zero, ← lt_neg] at hn; exact mod_cast hn
rw [← log_neg_eq_log]
exact log_nonneg this
@[deprecated (since := "2024-04-17")]
alias log_int_cast_nonneg := log_intCast_nonneg
theorem strictMonoOn_log : StrictMonoOn log (Set.Ioi 0) := fun _ hx _ _ hxy => log_lt_log hx hxy
theorem strictAntiOn_log : StrictAntiOn log (Set.Iio 0) := by
rintro x (hx : x < 0) y (hy : y < 0) hxy
rw [← log_abs y, ← log_abs x]
refine log_lt_log (abs_pos.2 hy.ne) ?_
rwa [abs_of_neg hy, abs_of_neg hx, neg_lt_neg_iff]
theorem log_injOn_pos : Set.InjOn log (Set.Ioi 0) :=
strictMonoOn_log.injOn
theorem log_lt_sub_one_of_pos (hx1 : 0 < x) (hx2 : x ≠ 1) : log x < x - 1 := by
have h : log x ≠ 0 := by
rwa [← log_one, log_injOn_pos.ne_iff hx1]
exact mem_Ioi.mpr zero_lt_one
linarith [add_one_lt_exp h, exp_log hx1]
theorem eq_one_of_pos_of_log_eq_zero {x : ℝ} (h₁ : 0 < x) (h₂ : log x = 0) : x = 1 :=
log_injOn_pos (Set.mem_Ioi.2 h₁) (Set.mem_Ioi.2 zero_lt_one) (h₂.trans Real.log_one.symm)
theorem log_ne_zero_of_pos_of_ne_one {x : ℝ} (hx_pos : 0 < x) (hx : x ≠ 1) : log x ≠ 0 :=
mt (eq_one_of_pos_of_log_eq_zero hx_pos) hx
@[simp]
theorem log_eq_zero {x : ℝ} : log x = 0 ↔ x = 0 ∨ x = 1 ∨ x = -1 := by
constructor
· intro h
rcases lt_trichotomy x 0 with (x_lt_zero | rfl | x_gt_zero)
· refine Or.inr (Or.inr (neg_eq_iff_eq_neg.mp ?_))
rw [← log_neg_eq_log x] at h
exact eq_one_of_pos_of_log_eq_zero (neg_pos.mpr x_lt_zero) h
· exact Or.inl rfl
· exact Or.inr (Or.inl (eq_one_of_pos_of_log_eq_zero x_gt_zero h))
· rintro (rfl | rfl | rfl) <;> simp only [log_one, log_zero, log_neg_eq_log]
theorem log_ne_zero {x : ℝ} : log x ≠ 0 ↔ x ≠ 0 ∧ x ≠ 1 ∧ x ≠ -1 := by
simpa only [not_or] using log_eq_zero.not
@[simp]
theorem log_pow (x : ℝ) (n : ℕ) : log (x ^ n) = n * log x := by
induction' n with n ih
· simp
rcases eq_or_ne x 0 with (rfl | hx)
· simp
rw [pow_succ, log_mul (pow_ne_zero _ hx) hx, ih, Nat.cast_succ, add_mul, one_mul]
@[simp]
theorem log_zpow (x : ℝ) (n : ℤ) : log (x ^ n) = n * log x := by
induction n
· rw [Int.ofNat_eq_coe, zpow_natCast, log_pow, Int.cast_natCast]
rw [zpow_negSucc, log_inv, log_pow, Int.cast_negSucc, Nat.cast_add_one, neg_mul_eq_neg_mul]
theorem log_sqrt {x : ℝ} (hx : 0 ≤ x) : log (√x) = log x / 2 := by
rw [eq_div_iff, mul_comm, ← Nat.cast_two, ← log_pow, sq_sqrt hx]
exact two_ne_zero
theorem log_le_sub_one_of_pos {x : ℝ} (hx : 0 < x) : log x ≤ x - 1 := by
rw [le_sub_iff_add_le]
convert add_one_le_exp (log x)
rw [exp_log hx]
/-- Bound for `|log x * x|` in the interval `(0, 1]`. -/
theorem abs_log_mul_self_lt (x : ℝ) (h1 : 0 < x) (h2 : x ≤ 1) : |log x * x| < 1 := by
have : 0 < 1 / x := by simpa only [one_div, inv_pos] using h1
replace := log_le_sub_one_of_pos this
replace : log (1 / x) < 1 / x := by linarith
rw [log_div one_ne_zero h1.ne', log_one, zero_sub, lt_div_iff h1] at this
have aux : 0 ≤ -log x * x := by
refine mul_nonneg ?_ h1.le
rw [← log_inv]
apply log_nonneg
rw [← le_inv h1 zero_lt_one, inv_one]
exact h2
rw [← abs_of_nonneg aux, neg_mul, abs_neg] at this
exact this
/-- The real logarithm function tends to `+∞` at `+∞`. -/
theorem tendsto_log_atTop : Tendsto log atTop atTop :=
tendsto_comp_exp_atTop.1 <| by simpa only [log_exp] using tendsto_id
theorem tendsto_log_nhdsWithin_zero : Tendsto log (𝓝[≠] 0) atBot := by
rw [← show _ = log from funext log_abs]
refine Tendsto.comp (g := log) ?_ tendsto_abs_nhdsWithin_zero
simpa [← tendsto_comp_exp_atBot] using tendsto_id
lemma tendsto_log_nhdsWithin_zero_right : Tendsto log (𝓝[>] 0) atBot :=
tendsto_log_nhdsWithin_zero.mono_left <| nhdsWithin_mono _ fun _ h ↦ ne_of_gt h
theorem continuousOn_log : ContinuousOn log {0}ᶜ := by
simp (config := { unfoldPartialApp := true }) only [continuousOn_iff_continuous_restrict,
restrict]
conv in log _ => rw [log_of_ne_zero (show (x : ℝ) ≠ 0 from x.2)]
exact expOrderIso.symm.continuous.comp (continuous_subtype_val.norm.subtype_mk _)
@[continuity]
theorem continuous_log : Continuous fun x : { x : ℝ // x ≠ 0 } => log x :=
continuousOn_iff_continuous_restrict.1 <| continuousOn_log.mono fun _ => id
@[continuity]
theorem continuous_log' : Continuous fun x : { x : ℝ // 0 < x } => log x :=
continuousOn_iff_continuous_restrict.1 <| continuousOn_log.mono fun _ hx => ne_of_gt hx
theorem continuousAt_log (hx : x ≠ 0) : ContinuousAt log x :=
(continuousOn_log x hx).continuousAt <| isOpen_compl_singleton.mem_nhds hx
@[simp]
theorem continuousAt_log_iff : ContinuousAt log x ↔ x ≠ 0 := by
refine ⟨?_, continuousAt_log⟩
rintro h rfl
exact not_tendsto_nhds_of_tendsto_atBot tendsto_log_nhdsWithin_zero _
(h.tendsto.mono_left inf_le_left)
theorem log_prod {α : Type*} (s : Finset α) (f : α → ℝ) (hf : ∀ x ∈ s, f x ≠ 0) :
log (∏ i ∈ s, f i) = ∑ i ∈ s, log (f i) := by
induction' s using Finset.cons_induction_on with a s ha ih
· simp
· rw [Finset.forall_mem_cons] at hf
simp [ih hf.2, log_mul hf.1 (Finset.prod_ne_zero_iff.2 hf.2)]
protected theorem _root_.Finsupp.log_prod {α β : Type*} [Zero β] (f : α →₀ β) (g : α → β → ℝ)
(hg : ∀ a, g a (f a) = 0 → f a = 0) : log (f.prod g) = f.sum fun a b ↦ log (g a b) :=
log_prod _ _ fun _x hx h₀ ↦ Finsupp.mem_support_iff.1 hx <| hg _ h₀
theorem log_nat_eq_sum_factorization (n : ℕ) :
log n = n.factorization.sum fun p t => t * log p := by
rcases eq_or_ne n 0 with (rfl | hn)
· simp -- relies on junk values of `log` and `Nat.factorization`
· simp only [← log_pow, ← Nat.cast_pow]
rw [← Finsupp.log_prod, ← Nat.cast_finsupp_prod, Nat.factorization_prod_pow_eq_self hn]
intro p hp
rw [pow_eq_zero (Nat.cast_eq_zero.1 hp), Nat.factorization_zero_right]
theorem tendsto_pow_log_div_mul_add_atTop (a b : ℝ) (n : ℕ) (ha : a ≠ 0) :
Tendsto (fun x => log x ^ n / (a * x + b)) atTop (𝓝 0) :=
((tendsto_div_pow_mul_exp_add_atTop a b n ha.symm).comp tendsto_log_atTop).congr' <| by
filter_upwards [eventually_gt_atTop (0 : ℝ)] with x hx using by simp [exp_log hx]
theorem isLittleO_pow_log_id_atTop {n : ℕ} : (fun x => log x ^ n) =o[atTop] id := by
rw [Asymptotics.isLittleO_iff_tendsto']
· simpa using tendsto_pow_log_div_mul_add_atTop 1 0 n one_ne_zero
filter_upwards [eventually_ne_atTop (0 : ℝ)] with x h₁ h₂ using (h₁ h₂).elim
theorem isLittleO_log_id_atTop : log =o[atTop] id :=
isLittleO_pow_log_id_atTop.congr_left fun _ => pow_one _
theorem isLittleO_const_log_atTop {c : ℝ} : (fun _ => c) =o[atTop] log := by
refine Asymptotics.isLittleO_of_tendsto' ?_
<| Tendsto.div_atTop (a := c) (by simp) tendsto_log_atTop
filter_upwards [eventually_gt_atTop 1] with x hx
aesop (add safe forward log_pos)
end Real
section Continuity
open Real
variable {α : Type*}
theorem Filter.Tendsto.log {f : α → ℝ} {l : Filter α} {x : ℝ} (h : Tendsto f l (𝓝 x)) (hx : x ≠ 0) :
Tendsto (fun x => log (f x)) l (𝓝 (log x)) :=
(continuousAt_log hx).tendsto.comp h
variable [TopologicalSpace α] {f : α → ℝ} {s : Set α} {a : α}
@[fun_prop]
theorem Continuous.log (hf : Continuous f) (h₀ : ∀ x, f x ≠ 0) : Continuous fun x => log (f x) :=
continuousOn_log.comp_continuous hf h₀
@[fun_prop]
nonrec theorem ContinuousAt.log (hf : ContinuousAt f a) (h₀ : f a ≠ 0) :
ContinuousAt (fun x => log (f x)) a :=
hf.log h₀
nonrec theorem ContinuousWithinAt.log (hf : ContinuousWithinAt f s a) (h₀ : f a ≠ 0) :
ContinuousWithinAt (fun x => log (f x)) s a :=
hf.log h₀
@[fun_prop]
theorem ContinuousOn.log (hf : ContinuousOn f s) (h₀ : ∀ x ∈ s, f x ≠ 0) :
ContinuousOn (fun x => log (f x)) s := fun x hx => (hf x hx).log (h₀ x hx)
end Continuity
section TendstoCompAddSub
open Filter
namespace Real
theorem tendsto_log_comp_add_sub_log (y : ℝ) :
Tendsto (fun x : ℝ => log (x + y) - log x) atTop (𝓝 0) := by
have : Tendsto (fun x ↦ 1 + y / x) atTop (𝓝 (1 + 0)) :=
tendsto_const_nhds.add (tendsto_const_nhds.div_atTop tendsto_id)
rw [← comap_exp_nhds_exp, exp_zero, tendsto_comap_iff, ← add_zero (1 : ℝ)]
refine this.congr' ?_
filter_upwards [eventually_gt_atTop (0 : ℝ), eventually_gt_atTop (-y)] with x hx₀ hxy
rw [comp_apply, exp_sub, exp_log, exp_log, one_add_div] <;> linarith
theorem tendsto_log_nat_add_one_sub_log : Tendsto (fun k : ℕ => log (k + 1) - log k) atTop (𝓝 0) :=
(tendsto_log_comp_add_sub_log 1).comp tendsto_natCast_atTop_atTop
end Real
end TendstoCompAddSub
namespace Mathlib.Meta.Positivity
open Lean.Meta Qq
variable {e : ℝ} {d : ℕ}
lemma log_nonneg_of_isNat {n : ℕ} (h : NormNum.IsNat e n) : 0 ≤ Real.log (e : ℝ) := by
rw [NormNum.IsNat.to_eq h rfl]
exact Real.log_natCast_nonneg _
lemma log_pos_of_isNat {n : ℕ} (h : NormNum.IsNat e n) (w : Nat.blt 1 n = true) :
0 < Real.log (e : ℝ) := by
rw [NormNum.IsNat.to_eq h rfl]
apply Real.log_pos
simpa using w
lemma log_nonneg_of_isNegNat {n : ℕ} (h : NormNum.IsInt e (.negOfNat n)) :
0 ≤ Real.log (e : ℝ) := by
rw [NormNum.IsInt.neg_to_eq h rfl]
exact Real.log_neg_natCast_nonneg _
lemma log_pos_of_isNegNat {n : ℕ} (h : NormNum.IsInt e (.negOfNat n)) (w : Nat.blt 1 n = true) :
0 < Real.log (e : ℝ) := by
rw [NormNum.IsInt.neg_to_eq h rfl]
rw [Real.log_neg_eq_log]
apply Real.log_pos
simpa using w
lemma log_pos_of_isRat {n : ℤ} :
(NormNum.IsRat e n d) → (decide ((1 : ℚ) < n / d)) → (0 < Real.log (e : ℝ))
| ⟨inv, eq⟩, h => by
rw [eq, invOf_eq_inv, ← div_eq_mul_inv]
have : 1 < (n : ℝ) / d := by exact_mod_cast of_decide_eq_true h
exact Real.log_pos this
lemma log_pos_of_isRat_neg {n : ℤ} :
(NormNum.IsRat e n d) → (decide (n / d < (-1 : ℚ))) → (0 < Real.log (e : ℝ))
| ⟨inv, eq⟩, h => by
rw [eq, invOf_eq_inv, ← div_eq_mul_inv]
have : (n : ℝ) / d < -1 := by exact_mod_cast of_decide_eq_true h
exact Real.log_pos_of_lt_neg_one this
lemma log_nz_of_isRat {n : ℤ} : (NormNum.IsRat e n d) → (decide ((0 : ℚ) < n / d))
→ (decide (n / d < (1 : ℚ))) → (Real.log (e : ℝ) ≠ 0)
| ⟨inv, eq⟩, h₁, h₂ => by
rw [eq, invOf_eq_inv, ← div_eq_mul_inv]
have h₁' : 0 < (n : ℝ) / d := by exact_mod_cast of_decide_eq_true h₁
have h₂' : (n : ℝ) / d < 1 := by exact_mod_cast of_decide_eq_true h₂
exact ne_of_lt <| Real.log_neg h₁' h₂'
lemma log_nz_of_isRat_neg {n : ℤ} : (NormNum.IsRat e n d) → (decide (n / d < (0 : ℚ)))
→ (decide ((-1 : ℚ) < n / d)) → (Real.log (e : ℝ) ≠ 0)
| ⟨inv, eq⟩, h₁, h₂ => by
rw [eq, invOf_eq_inv, ← div_eq_mul_inv]
have h₁' : (n : ℝ) / d < 0 := by exact_mod_cast of_decide_eq_true h₁
have h₂' : -1 < (n : ℝ) / d := by exact_mod_cast of_decide_eq_true h₂
exact ne_of_lt <| Real.log_neg_of_lt_zero h₁' h₂'
/-- Extension for the `positivity` tactic: `Real.log` of a natural number is always nonnegative. -/
@[positivity Real.log (Nat.cast _)]
def evalLogNatCast : PositivityExt where eval {u α} _zα _pα e := do
match u, α, e with
| 0, ~q(ℝ), ~q(Real.log (Nat.cast $a)) =>
assertInstancesCommute
pure (.nonnegative q(Real.log_natCast_nonneg $a))
| _, _, _ => throwError "not Real.log"
/-- Extension for the `positivity` tactic: `Real.log` of an integer is always nonnegative. -/
@[positivity Real.log (Int.cast _)]
def evalLogIntCast : PositivityExt where eval {u α} _zα _pα e := do
match u, α, e with
| 0, ~q(ℝ), ~q(Real.log (Int.cast $a)) =>
assertInstancesCommute
pure (.nonnegative q(Real.log_intCast_nonneg $a))
| _, _, _ => throwError "not Real.log"
/-- Extension for the `positivity` tactic: `Real.log` of a numeric literal. -/
@[positivity Real.log _]
def evalLogNatLit : PositivityExt where eval {u α} _ _ e := do
match u, α, e with
| 0, ~q(ℝ), ~q(Real.log $a) =>
match ← NormNum.derive a with
| .isNat (_ : Q(AddMonoidWithOne ℝ)) lit p =>
assumeInstancesCommute
have p : Q(NormNum.IsNat $a $lit) := p
if 1 < lit.natLit! then
let p' : Q(Nat.blt 1 $lit = true) := (q(Eq.refl true) : Lean.Expr)
pure (.positive q(log_pos_of_isNat $p $p'))
else
pure (.nonnegative q(log_nonneg_of_isNat $p))
| .isNegNat _ lit p =>
assumeInstancesCommute
have p : Q(NormNum.IsInt $a (Int.negOfNat $lit)) := p
if 1 < lit.natLit! then
let p' : Q(Nat.blt 1 $lit = true) := (q(Eq.refl true) : Lean.Expr)
pure (.positive q(log_pos_of_isNegNat $p $p'))
else
pure (.nonnegative q(log_nonneg_of_isNegNat $p))
| .isRat (i : Q(DivisionRing ℝ)) q n d p =>
assumeInstancesCommute
have p : Q(by clear! «$i»; exact NormNum.IsRat $a $n $d) := p
if 0 < q ∧ q < 1 then
let w₁ : Q(decide ((0 : ℚ) < $n / $d) = true) := (q(Eq.refl true) : Lean.Expr)
let w₂ : Q(decide ($n / $d < (1 : ℚ)) = true) := (q(Eq.refl true) : Lean.Expr)
pure (.nonzero q(log_nz_of_isRat $p $w₁ $w₂))
else if 1 < q then
let w : Q(decide ((1 : ℚ) < $n / $d) = true) := (q(Eq.refl true) : Lean.Expr)
pure (.positive q(log_pos_of_isRat $p $w))
else if -1 < q ∧ q < 0 then
let w₁ : Q(decide ($n / $d < (0 : ℚ)) = true) := (q(Eq.refl true) : Lean.Expr)
let w₂ : Q(decide ((-1 : ℚ) < $n / $d) = true) := (q(Eq.refl true) : Lean.Expr)
pure (.nonzero q(log_nz_of_isRat_neg $p $w₁ $w₂))
else if q < -1 then
let w : Q(decide ($n / $d < (-1 : ℚ)) = true) := (q(Eq.refl true) : Lean.Expr)
pure (.positive q(log_pos_of_isRat_neg $p $w))
else
failure
| _ => failure
| _, _, _ => throwError "not Real.log"
end Mathlib.Meta.Positivity
|
Analysis\SpecialFunctions\Log\Deriv.lean | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne
-/
import Mathlib.Analysis.Calculus.Deriv.Pow
import Mathlib.Analysis.Calculus.LogDeriv
import Mathlib.Analysis.SpecialFunctions.Log.Basic
import Mathlib.Analysis.SpecialFunctions.ExpDeriv
import Mathlib.Tactic.AdaptationNote
/-!
# Derivative and series expansion of real logarithm
In this file we prove that `Real.log` is infinitely smooth at all nonzero `x : ℝ`. We also prove
that the series `∑' n : ℕ, x ^ (n + 1) / (n + 1)` converges to `(-Real.log (1 - x))` for all
`x : ℝ`, `|x| < 1`.
## Tags
logarithm, derivative
-/
open Filter Finset Set
open scoped Topology
namespace Real
variable {x : ℝ}
theorem hasStrictDerivAt_log_of_pos (hx : 0 < x) : HasStrictDerivAt log x⁻¹ x := by
have : HasStrictDerivAt log (exp <| log x)⁻¹ x :=
(hasStrictDerivAt_exp <| log x).of_local_left_inverse (continuousAt_log hx.ne')
(ne_of_gt <| exp_pos _) <|
Eventually.mono (lt_mem_nhds hx) @exp_log
rwa [exp_log hx] at this
theorem hasStrictDerivAt_log (hx : x ≠ 0) : HasStrictDerivAt log x⁻¹ x := by
cases' hx.lt_or_lt with hx hx
· convert (hasStrictDerivAt_log_of_pos (neg_pos.mpr hx)).comp x (hasStrictDerivAt_neg x) using 1
· ext y; exact (log_neg_eq_log y).symm
· field_simp [hx.ne]
· exact hasStrictDerivAt_log_of_pos hx
theorem hasDerivAt_log (hx : x ≠ 0) : HasDerivAt log x⁻¹ x :=
(hasStrictDerivAt_log hx).hasDerivAt
theorem differentiableAt_log (hx : x ≠ 0) : DifferentiableAt ℝ log x :=
(hasDerivAt_log hx).differentiableAt
theorem differentiableOn_log : DifferentiableOn ℝ log {0}ᶜ := fun _x hx =>
(differentiableAt_log hx).differentiableWithinAt
@[simp]
theorem differentiableAt_log_iff : DifferentiableAt ℝ log x ↔ x ≠ 0 :=
⟨fun h => continuousAt_log_iff.1 h.continuousAt, differentiableAt_log⟩
theorem deriv_log (x : ℝ) : deriv log x = x⁻¹ :=
if hx : x = 0 then by
rw [deriv_zero_of_not_differentiableAt (differentiableAt_log_iff.not_left.2 hx), hx, inv_zero]
else (hasDerivAt_log hx).deriv
@[simp]
theorem deriv_log' : deriv log = Inv.inv :=
funext deriv_log
theorem contDiffOn_log {n : ℕ∞} : ContDiffOn ℝ n log {0}ᶜ := by
suffices ContDiffOn ℝ ⊤ log {0}ᶜ from this.of_le le_top
refine (contDiffOn_top_iff_deriv_of_isOpen isOpen_compl_singleton).2 ?_
simp [differentiableOn_log, contDiffOn_inv]
theorem contDiffAt_log {n : ℕ∞} : ContDiffAt ℝ n log x ↔ x ≠ 0 :=
⟨fun h => continuousAt_log_iff.1 h.continuousAt, fun hx =>
(contDiffOn_log x hx).contDiffAt <| IsOpen.mem_nhds isOpen_compl_singleton hx⟩
end Real
section LogDifferentiable
open Real
section deriv
variable {f : ℝ → ℝ} {x f' : ℝ} {s : Set ℝ}
theorem HasDerivWithinAt.log (hf : HasDerivWithinAt f f' s x) (hx : f x ≠ 0) :
HasDerivWithinAt (fun y => log (f y)) (f' / f x) s x := by
rw [div_eq_inv_mul]
exact (hasDerivAt_log hx).comp_hasDerivWithinAt x hf
theorem HasDerivAt.log (hf : HasDerivAt f f' x) (hx : f x ≠ 0) :
HasDerivAt (fun y => log (f y)) (f' / f x) x := by
rw [← hasDerivWithinAt_univ] at *
exact hf.log hx
theorem HasStrictDerivAt.log (hf : HasStrictDerivAt f f' x) (hx : f x ≠ 0) :
HasStrictDerivAt (fun y => log (f y)) (f' / f x) x := by
rw [div_eq_inv_mul]
exact (hasStrictDerivAt_log hx).comp x hf
theorem derivWithin.log (hf : DifferentiableWithinAt ℝ f s x) (hx : f x ≠ 0)
(hxs : UniqueDiffWithinAt ℝ s x) :
derivWithin (fun x => log (f x)) s x = derivWithin f s x / f x :=
(hf.hasDerivWithinAt.log hx).derivWithin hxs
@[simp]
theorem deriv.log (hf : DifferentiableAt ℝ f x) (hx : f x ≠ 0) :
deriv (fun x => log (f x)) x = deriv f x / f x :=
(hf.hasDerivAt.log hx).deriv
/-- The derivative of `log ∘ f` is the logarithmic derivative provided `f` is differentiable and
`f x ≠ 0`. -/
lemma Real.deriv_log_comp_eq_logDeriv {f : ℝ → ℝ} {x : ℝ} (h₁ : DifferentiableAt ℝ f x)
(h₂ : f x ≠ 0) : deriv (log ∘ f) x = logDeriv f x := by
simp only [ne_eq, logDeriv, Pi.div_apply, ← deriv.log h₁ h₂]
rfl
end deriv
section fderiv
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] {f : E → ℝ} {x : E} {f' : E →L[ℝ] ℝ}
{s : Set E}
theorem HasFDerivWithinAt.log (hf : HasFDerivWithinAt f f' s x) (hx : f x ≠ 0) :
HasFDerivWithinAt (fun x => log (f x)) ((f x)⁻¹ • f') s x :=
(hasDerivAt_log hx).comp_hasFDerivWithinAt x hf
theorem HasFDerivAt.log (hf : HasFDerivAt f f' x) (hx : f x ≠ 0) :
HasFDerivAt (fun x => log (f x)) ((f x)⁻¹ • f') x :=
(hasDerivAt_log hx).comp_hasFDerivAt x hf
theorem HasStrictFDerivAt.log (hf : HasStrictFDerivAt f f' x) (hx : f x ≠ 0) :
HasStrictFDerivAt (fun x => log (f x)) ((f x)⁻¹ • f') x :=
(hasStrictDerivAt_log hx).comp_hasStrictFDerivAt x hf
theorem DifferentiableWithinAt.log (hf : DifferentiableWithinAt ℝ f s x) (hx : f x ≠ 0) :
DifferentiableWithinAt ℝ (fun x => log (f x)) s x :=
(hf.hasFDerivWithinAt.log hx).differentiableWithinAt
@[simp]
theorem DifferentiableAt.log (hf : DifferentiableAt ℝ f x) (hx : f x ≠ 0) :
DifferentiableAt ℝ (fun x => log (f x)) x :=
(hf.hasFDerivAt.log hx).differentiableAt
theorem ContDiffAt.log {n} (hf : ContDiffAt ℝ n f x) (hx : f x ≠ 0) :
ContDiffAt ℝ n (fun x => log (f x)) x :=
(contDiffAt_log.2 hx).comp x hf
theorem ContDiffWithinAt.log {n} (hf : ContDiffWithinAt ℝ n f s x) (hx : f x ≠ 0) :
ContDiffWithinAt ℝ n (fun x => log (f x)) s x :=
(contDiffAt_log.2 hx).comp_contDiffWithinAt x hf
theorem ContDiffOn.log {n} (hf : ContDiffOn ℝ n f s) (hs : ∀ x ∈ s, f x ≠ 0) :
ContDiffOn ℝ n (fun x => log (f x)) s := fun x hx => (hf x hx).log (hs x hx)
theorem ContDiff.log {n} (hf : ContDiff ℝ n f) (h : ∀ x, f x ≠ 0) :
ContDiff ℝ n fun x => log (f x) :=
contDiff_iff_contDiffAt.2 fun x => hf.contDiffAt.log (h x)
theorem DifferentiableOn.log (hf : DifferentiableOn ℝ f s) (hx : ∀ x ∈ s, f x ≠ 0) :
DifferentiableOn ℝ (fun x => log (f x)) s := fun x h => (hf x h).log (hx x h)
@[simp]
theorem Differentiable.log (hf : Differentiable ℝ f) (hx : ∀ x, f x ≠ 0) :
Differentiable ℝ fun x => log (f x) := fun x => (hf x).log (hx x)
theorem fderivWithin.log (hf : DifferentiableWithinAt ℝ f s x) (hx : f x ≠ 0)
(hxs : UniqueDiffWithinAt ℝ s x) :
fderivWithin ℝ (fun x => log (f x)) s x = (f x)⁻¹ • fderivWithin ℝ f s x :=
(hf.hasFDerivWithinAt.log hx).fderivWithin hxs
@[simp]
theorem fderiv.log (hf : DifferentiableAt ℝ f x) (hx : f x ≠ 0) :
fderiv ℝ (fun x => log (f x)) x = (f x)⁻¹ • fderiv ℝ f x :=
(hf.hasFDerivAt.log hx).fderiv
end fderiv
end LogDifferentiable
namespace Real
/-- The function `x * log (1 + t / x)` tends to `t` at `+∞`. -/
theorem tendsto_mul_log_one_plus_div_atTop (t : ℝ) :
Tendsto (fun x => x * log (1 + t / x)) atTop (𝓝 t) := by
have h₁ : Tendsto (fun h => h⁻¹ * log (1 + t * h)) (𝓝[≠] 0) (𝓝 t) := by
simpa [hasDerivAt_iff_tendsto_slope, slope_fun_def] using
(((hasDerivAt_id (0 : ℝ)).const_mul t).const_add 1).log (by simp)
have h₂ : Tendsto (fun x : ℝ => x⁻¹) atTop (𝓝[≠] 0) :=
tendsto_inv_atTop_zero'.mono_right (nhdsWithin_mono _ fun x hx => (Set.mem_Ioi.mp hx).ne')
simpa only [(· ∘ ·), inv_inv] using h₁.comp h₂
/-- A crude lemma estimating the difference between `log (1-x)` and its Taylor series at `0`,
where the main point of the bound is that it tends to `0`. The goal is to deduce the series
expansion of the logarithm, in `hasSum_pow_div_log_of_abs_lt_1`.
Porting note (#11215): TODO: use one of generic theorems about Taylor's series
to prove this estimate.
-/
theorem abs_log_sub_add_sum_range_le {x : ℝ} (h : |x| < 1) (n : ℕ) :
|(∑ i ∈ range n, x ^ (i + 1) / (i + 1)) + log (1 - x)| ≤ |x| ^ (n + 1) / (1 - |x|) := by
/- For the proof, we show that the derivative of the function to be estimated is small,
and then apply the mean value inequality. -/
let F : ℝ → ℝ := fun x => (∑ i ∈ range n, x ^ (i + 1) / (i + 1)) + log (1 - x)
let F' : ℝ → ℝ := fun x ↦ -x ^ n / (1 - x)
-- Porting note: In `mathlib3`, the proof used `deriv`/`DifferentiableAt`. `simp` failed to
-- compute `deriv`, so I changed the proof to use `HasDerivAt` instead
-- First step: compute the derivative of `F`
have A : ∀ y ∈ Ioo (-1 : ℝ) 1, HasDerivAt F (F' y) y := fun y hy ↦ by
have : HasDerivAt F ((∑ i ∈ range n, ↑(i + 1) * y ^ i / (↑i + 1)) + (-1) / (1 - y)) y :=
.add (.sum fun i _ ↦ (hasDerivAt_pow (i + 1) y).div_const ((i : ℝ) + 1))
(((hasDerivAt_id y).const_sub _).log <| sub_ne_zero.2 hy.2.ne')
convert this using 1
calc
-y ^ n / (1 - y) = ∑ i ∈ Finset.range n, y ^ i + -1 / (1 - y) := by
field_simp [geom_sum_eq hy.2.ne, sub_ne_zero.2 hy.2.ne, sub_ne_zero.2 hy.2.ne']
ring
_ = ∑ i ∈ Finset.range n, ↑(i + 1) * y ^ i / (↑i + 1) + -1 / (1 - y) := by
congr with i
rw [Nat.cast_succ, mul_div_cancel_left₀ _ (Nat.cast_add_one_pos i).ne']
-- second step: show that the derivative of `F` is small
have B : ∀ y ∈ Icc (-|x|) |x|, |F' y| ≤ |x| ^ n / (1 - |x|) := fun y hy ↦
calc
|F' y| = |y| ^ n / |1 - y| := by simp [F', abs_div]
_ ≤ |x| ^ n / (1 - |x|) := by
have : |y| ≤ |x| := abs_le.2 hy
have : 1 - |x| ≤ |1 - y| := le_trans (by linarith [hy.2]) (le_abs_self _)
gcongr
exact sub_pos.2 h
-- third step: apply the mean value inequality
have C : ‖F x - F 0‖ ≤ |x| ^ n / (1 - |x|) * ‖x - 0‖ := by
refine Convex.norm_image_sub_le_of_norm_hasDerivWithin_le
(fun y hy ↦ (A _ ?_).hasDerivWithinAt) B (convex_Icc _ _) ?_ ?_
· exact Icc_subset_Ioo (neg_lt_neg h) h hy
· simp
· simp [le_abs_self x, neg_le.mp (neg_le_abs x)]
-- fourth step: conclude by massaging the inequality of the third step
simpa [F, div_mul_eq_mul_div, pow_succ] using C
/-- Power series expansion of the logarithm around `1`. -/
theorem hasSum_pow_div_log_of_abs_lt_one {x : ℝ} (h : |x| < 1) :
HasSum (fun n : ℕ => x ^ (n + 1) / (n + 1)) (-log (1 - x)) := by
rw [Summable.hasSum_iff_tendsto_nat]
· show Tendsto (fun n : ℕ => ∑ i ∈ range n, x ^ (i + 1) / (i + 1)) atTop (𝓝 (-log (1 - x)))
rw [tendsto_iff_norm_sub_tendsto_zero]
simp only [norm_eq_abs, sub_neg_eq_add]
refine squeeze_zero (fun n => abs_nonneg _) (abs_log_sub_add_sum_range_le h) ?_
suffices Tendsto (fun t : ℕ => |x| ^ (t + 1) / (1 - |x|)) atTop (𝓝 (|x| * 0 / (1 - |x|))) by
simpa
simp only [pow_succ']
refine (tendsto_const_nhds.mul ?_).div_const _
exact tendsto_pow_atTop_nhds_zero_of_lt_one (abs_nonneg _) h
show Summable fun n : ℕ => x ^ (n + 1) / (n + 1)
refine .of_norm_bounded _ (summable_geometric_of_lt_one (abs_nonneg _) h) fun i => ?_
calc
‖x ^ (i + 1) / (i + 1)‖ = |x| ^ (i + 1) / (i + 1) := by
have : (0 : ℝ) ≤ i + 1 := le_of_lt (Nat.cast_add_one_pos i)
rw [norm_eq_abs, abs_div, ← pow_abs, abs_of_nonneg this]
_ ≤ |x| ^ (i + 1) / (0 + 1) := by
gcongr
exact i.cast_nonneg
_ ≤ |x| ^ i := by
simpa [pow_succ] using mul_le_of_le_one_right (pow_nonneg (abs_nonneg x) i) (le_of_lt h)
@[deprecated (since := "2024-01-31")]
alias hasSum_pow_div_log_of_abs_lt_1 := hasSum_pow_div_log_of_abs_lt_one
/-- Power series expansion of `log(1 + x) - log(1 - x)` for `|x| < 1`. -/
theorem hasSum_log_sub_log_of_abs_lt_one {x : ℝ} (h : |x| < 1) :
HasSum (fun k : ℕ => (2 : ℝ) * (1 / (2 * k + 1)) * x ^ (2 * k + 1))
(log (1 + x) - log (1 - x)) := by
set term := fun n : ℕ => -1 * ((-x) ^ (n + 1) / ((n : ℝ) + 1)) + x ^ (n + 1) / (n + 1)
have h_term_eq_goal :
term ∘ (2 * ·) = fun k : ℕ => 2 * (1 / (2 * k + 1)) * x ^ (2 * k + 1) := by
ext n
dsimp only [term, (· ∘ ·)]
rw [Odd.neg_pow (⟨n, rfl⟩ : Odd (2 * n + 1)) x]
push_cast
ring_nf
rw [← h_term_eq_goal, (mul_right_injective₀ (two_ne_zero' ℕ)).hasSum_iff]
· have h₁ := (hasSum_pow_div_log_of_abs_lt_one (Eq.trans_lt (abs_neg x) h)).mul_left (-1)
convert h₁.add (hasSum_pow_div_log_of_abs_lt_one h) using 1
ring_nf
· intro m hm
rw [range_two_mul, Set.mem_setOf_eq, ← Nat.even_add_one] at hm
dsimp [term]
rw [Even.neg_pow hm, neg_one_mul, neg_add_self]
@[deprecated (since := "2024-01-31")]
alias hasSum_log_sub_log_of_abs_lt_1 := hasSum_log_sub_log_of_abs_lt_one
#adaptation_note /-- after v4.7.0-rc1, there is a performance problem in `field_simp`.
(Part of the code was ignoring the `maxDischargeDepth` setting:
now that we have to increase it, other paths becomes slow.) -/
set_option maxHeartbeats 400000 in
/-- Expansion of `log (1 + a⁻¹)` as a series in powers of `1 / (2 * a + 1)`. -/
theorem hasSum_log_one_add_inv {a : ℝ} (h : 0 < a) :
HasSum (fun k : ℕ => (2 : ℝ) * (1 / (2 * k + 1)) * (1 / (2 * a + 1)) ^ (2 * k + 1))
(log (1 + a⁻¹)) := by
have h₁ : |1 / (2 * a + 1)| < 1 := by
rw [abs_of_pos, div_lt_one]
· linarith
· linarith
· exact div_pos one_pos (by linarith)
convert hasSum_log_sub_log_of_abs_lt_one h₁ using 1
have h₂ : (2 : ℝ) * a + 1 ≠ 0 := by linarith
have h₃ := h.ne'
rw [← log_div]
· congr
field_simp
linarith
· field_simp
linarith
· field_simp
end Real
|
Analysis\SpecialFunctions\Log\ENNRealLog.lean | /-
Copyright (c) 2024 Damien Thomine. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Damien Thomine, Pietro Monticone, Rémy Degenne, Lorenzo Luccioli
-/
import Mathlib.Data.Real.EReal
import Mathlib.Analysis.SpecialFunctions.Pow.NNReal
/-!
# Extended Nonnegative Real Logarithm
We define `log` as an extension of the logarithm of a positive real
to the extended nonnegative reals `ℝ≥0∞`. The function takes values
in the extended reals `EReal`, with `log 0 = ⊥` and `log ⊤ = ⊤`.
## Main Definitions
- `ENNReal.log`: The extension of the real logarithm to `ℝ≥0∞`.
## Main Results
- `ENNReal.log_strictMono`: `log` is increasing;
- `ENNReal.log_injective`, `ENNReal.log_surjective`, `ENNReal.log_bijective`: `log` is
injective, surjective, and bijective;
- `ENNReal.log_mul_add`, `ENNReal.log_pow`, `ENNReal.log_rpow`: `log` satisfies
the identities `log (x * y) = log x + log y` and `log (x ^ y) = y * log x`
(with either `y ∈ ℕ` or `y ∈ ℝ`).
## Tags
ENNReal, EReal, logarithm
-/
namespace ENNReal
open scoped NNReal
/-! ### Definition -/
section Definition
/-- The logarithm function defined on the extended nonnegative reals `ℝ≥0∞`
to the extended reals `EReal`. Coincides with the usual logarithm function
and with `Real.log` on positive reals, and takes values `log 0 = ⊥` and `log ⊤ = ⊤`.
Conventions about multiplication in `ℝ≥0∞` and addition in `EReal` make the identity
`log (x * y) = log x + log y` unconditional. -/
noncomputable def log (x : ℝ≥0∞) : EReal :=
if x = 0 then ⊥
else if x = ⊤ then ⊤
else Real.log x.toReal
@[simp] lemma log_zero : log 0 = ⊥ := if_pos rfl
@[simp] lemma log_one : log 1 = 0 := by simp [log]
@[simp] lemma log_top : log ⊤ = ⊤ := rfl
@[simp]
lemma log_ofReal (x : ℝ) : log (ENNReal.ofReal x) = if x ≤ 0 then ⊥ else ↑(Real.log x) := by
simp only [log, ENNReal.none_eq_top, ENNReal.ofReal_ne_top, IsEmpty.forall_iff,
ENNReal.ofReal_eq_zero, EReal.coe_ennreal_ofReal]
split_ifs with h_nonpos
· rfl
· trivial
· rw [ENNReal.toReal_ofReal]
exact (not_le.mp h_nonpos).le
lemma log_ofReal_of_pos {x : ℝ} (hx : 0 < x) : log (ENNReal.ofReal x) = Real.log x := by
rw [log_ofReal, if_neg]
exact not_le.mpr hx
theorem log_pos_real {x : ℝ≥0∞} (h : x ≠ 0) (h' : x ≠ ⊤) :
log x = Real.log (ENNReal.toReal x) := by simp [log, h, h']
theorem log_pos_real' {x : ℝ≥0∞} (h : 0 < x.toReal) :
log x = Real.log (ENNReal.toReal x) := by
simp [log, Ne.symm (ne_of_lt (ENNReal.toReal_pos_iff.1 h).1),
ne_of_lt (ENNReal.toReal_pos_iff.1 h).2]
theorem log_of_nnreal {x : ℝ≥0} (h : x ≠ 0) :
log (x : ℝ≥0∞) = Real.log x := by simp [log, h]
end Definition
/-! ### Monotonicity -/
section Monotonicity
theorem log_strictMono : StrictMono log := by
intro x y h
unfold log
rcases ENNReal.trichotomy x with (rfl | rfl | x_real)
· rcases ENNReal.trichotomy y with (rfl | rfl | y_real)
· exfalso; exact lt_irrefl 0 h
· simp
· simp [Ne.symm (ne_of_lt (ENNReal.toReal_pos_iff.1 y_real).1),
ne_of_lt (ENNReal.toReal_pos_iff.1 y_real).2, EReal.bot_lt_coe]
· exfalso; exact (ne_top_of_lt h) (Eq.refl ⊤)
· simp only [Ne.symm (ne_of_lt (ENNReal.toReal_pos_iff.1 x_real).1),
ne_of_lt (ENNReal.toReal_pos_iff.1 x_real).2]
rcases ENNReal.trichotomy y with (rfl | rfl | y_real)
· exfalso; rw [← ENNReal.bot_eq_zero] at h; exact not_lt_bot h
· simp
· simp only [Ne.symm (ne_of_lt (ENNReal.toReal_pos_iff.1 y_real).1), ↓reduceIte,
ne_of_lt (ENNReal.toReal_pos_iff.1 y_real).2, EReal.coe_lt_coe_iff]
apply Real.log_lt_log x_real
exact (ENNReal.toReal_lt_toReal (ne_of_lt (ENNReal.toReal_pos_iff.1 x_real).2)
(ne_of_lt (ENNReal.toReal_pos_iff.1 y_real).2)).2 h
theorem log_monotone : Monotone log := log_strictMono.monotone
theorem log_injective : Function.Injective log := log_strictMono.injective
theorem log_surjective : Function.Surjective log := by
intro y
cases' eq_bot_or_bot_lt y with y_bot y_nbot
· exact y_bot ▸ ⟨⊥, log_zero⟩
cases' eq_top_or_lt_top y with y_top y_ntop
· exact y_top ▸ ⟨⊤, log_top⟩
use ENNReal.ofReal (Real.exp y.toReal)
have exp_y_pos := not_le_of_lt (Real.exp_pos y.toReal)
simp only [log, ofReal_eq_zero, exp_y_pos, ↓reduceIte, ofReal_ne_top,
ENNReal.toReal_ofReal (le_of_lt (Real.exp_pos y.toReal)), Real.log_exp y.toReal]
exact EReal.coe_toReal (ne_of_lt y_ntop) (Ne.symm (ne_of_lt y_nbot))
theorem log_bijective : Function.Bijective log := ⟨log_injective, log_surjective⟩
@[simp]
theorem log_eq_iff {x y : ℝ≥0∞} : log x = log y ↔ x = y :=
Iff.intro (@log_injective x y) (fun h ↦ by rw [h])
@[simp] theorem log_eq_bot_iff {x : ℝ≥0∞} : log x = ⊥ ↔ x = 0 := log_zero ▸ @log_eq_iff x 0
@[simp] theorem log_eq_one_iff {x : ℝ≥0∞} : log x = 0 ↔ x = 1 := log_one ▸ @log_eq_iff x 1
@[simp] theorem log_eq_top_iff {x : ℝ≥0∞} : log x = ⊤ ↔ x = ⊤ := log_top ▸ @log_eq_iff x ⊤
@[simp] lemma log_lt_log_iff {x y : ℝ≥0∞} : log x < log y ↔ x < y := log_strictMono.lt_iff_lt
@[simp] lemma bot_lt_log_iff {x : ℝ≥0∞} : ⊥ < log x ↔ 0 < x := log_zero ▸ @log_lt_log_iff 0 x
@[simp] lemma log_lt_top_iff {x : ℝ≥0∞} : log x < ⊤ ↔ x < ⊤ := log_top ▸ @log_lt_log_iff x ⊤
@[simp] lemma log_lt_zero_iff {x : ℝ≥0∞} : log x < 0 ↔ x < 1 := log_one ▸ @log_lt_log_iff x 1
@[simp] lemma zero_lt_log_iff {x : ℝ≥0∞} : 0 < log x ↔ 1 < x := log_one ▸ @log_lt_log_iff 1 x
@[simp] lemma log_le_log_iff {x y : ℝ≥0∞} : log x ≤ log y ↔ x ≤ y := log_strictMono.le_iff_le
@[simp] lemma log_le_zero_iff {x : ℝ≥0∞} : log x ≤ 0 ↔ x ≤ 1 := log_one ▸ @log_le_log_iff x 1
@[simp] lemma zero_le_log_iff {x : ℝ≥0∞} : 0 ≤ log x ↔ 1 ≤ x := log_one ▸ @log_le_log_iff 1 x
end Monotonicity
/-! ### Algebraic properties -/
section Morphism
theorem log_mul_add {x y : ℝ≥0∞} : log (x * y) = log x + log y := by
rcases ENNReal.trichotomy x with (rfl | rfl | x_real)
· simp
· rw [log_top]
rcases ENNReal.trichotomy y with (rfl | rfl | y_real)
· rw [mul_zero, log_zero, EReal.add_bot]
· simp
· rw [log_pos_real' y_real, ENNReal.top_mul', EReal.top_add_coe, log_eq_top_iff]
simp only [ite_eq_right_iff, zero_ne_top, imp_false]
exact Ne.symm (ne_of_lt (ENNReal.toReal_pos_iff.1 y_real).1)
· rw [log_pos_real' x_real]
rcases ENNReal.trichotomy y with (rfl | rfl | y_real)
· simp
· simp [Ne.symm (ne_of_lt (ENNReal.toReal_pos_iff.1 x_real).1)]
· have xy_real := Real.mul_pos x_real y_real
rw [← ENNReal.toReal_mul] at xy_real
rw_mod_cast [log_pos_real' xy_real, log_pos_real' y_real, ENNReal.toReal_mul]
exact Real.log_mul (Ne.symm (ne_of_lt x_real)) (Ne.symm (ne_of_lt y_real))
theorem log_pow {x : ℝ≥0∞} {n : ℕ} : log (x ^ n) = n * log x := by
cases' Nat.eq_zero_or_pos n with n_zero n_pos
· simp [n_zero, pow_zero x]
rcases ENNReal.trichotomy x with (rfl | rfl | x_real)
· rw [zero_pow (Ne.symm (ne_of_lt n_pos)), log_zero, EReal.mul_bot_of_pos (Nat.cast_pos'.2 n_pos)]
· rw [ENNReal.top_pow n_pos, log_top, EReal.mul_top_of_pos (Nat.cast_pos'.2 n_pos)]
· replace x_real := ENNReal.toReal_pos_iff.1 x_real
have x_ne_zero := Ne.symm (LT.lt.ne x_real.1)
have x_ne_top := LT.lt.ne x_real.2
simp only [log, pow_eq_zero_iff', x_ne_zero, false_and, ↓reduceIte, pow_eq_top_iff, x_ne_top,
toReal_pow, Real.log_pow, EReal.coe_mul]
rfl
theorem log_rpow {x : ℝ≥0∞} {y : ℝ} : log (x ^ y) = y * log x := by
rcases lt_trichotomy y 0 with (y_neg | rfl | y_pos)
· rcases ENNReal.trichotomy x with (rfl | rfl | x_real)
· simp only [ENNReal.zero_rpow_def y, not_lt_of_lt y_neg, ne_of_lt y_neg, log_top, log_zero]
exact Eq.symm (EReal.coe_mul_bot_of_neg y_neg)
· rw [ENNReal.top_rpow_of_neg y_neg, log_zero, log_top]
exact Eq.symm (EReal.coe_mul_top_of_neg y_neg)
· have x_ne_zero := Ne.symm (LT.lt.ne (ENNReal.toReal_pos_iff.1 x_real).1)
have x_ne_top := LT.lt.ne (ENNReal.toReal_pos_iff.1 x_real).2
simp only [log, rpow_eq_zero_iff, x_ne_zero, false_and, x_ne_top, or_self, ↓reduceIte,
rpow_eq_top_iff]
norm_cast
exact ENNReal.toReal_rpow x y ▸ Real.log_rpow x_real y
· simp
· rcases ENNReal.trichotomy x with (rfl | rfl | x_real)
· rw [ENNReal.zero_rpow_of_pos y_pos, log_zero, EReal.mul_bot_of_pos]; norm_cast
· rw [ENNReal.top_rpow_of_pos y_pos, log_top, EReal.mul_top_of_pos]; norm_cast
· have x_ne_zero := Ne.symm (LT.lt.ne (ENNReal.toReal_pos_iff.1 x_real).1)
have x_ne_top := LT.lt.ne (ENNReal.toReal_pos_iff.1 x_real).2
simp only [log, rpow_eq_zero_iff, x_ne_zero, false_and, x_ne_top, or_self, ↓reduceIte,
rpow_eq_top_iff]
norm_cast
exact ENNReal.toReal_rpow x y ▸ Real.log_rpow x_real y
lemma log_inv {x : ℝ≥0∞} : log x⁻¹ = - log x := by
simp [← rpow_neg_one, log_rpow]
end Morphism
end ENNReal
|
Analysis\SpecialFunctions\Log\ENNRealLogExp.lean | /-
Copyright (c) 2024 Rémy Degenne. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Damien Thomine, Pietro Monticone, Rémy Degenne, Lorenzo Luccioli
-/
import Mathlib.Analysis.SpecialFunctions.Log.ERealExp
import Mathlib.Analysis.SpecialFunctions.Log.ENNRealLog
import Mathlib.MeasureTheory.Constructions.BorelSpace.Basic
import Mathlib.Topology.MetricSpace.Polish
/-!
# Properties of the extended logarithm and exponential
We prove that `log` and `exp` define order isomorphisms between `ℝ≥0∞` and `EReal`.
## Main Definitions
- `ENNReal.logOrderIso`: The order isomorphism between `ℝ≥0∞` and `EReal` defined by `log`
and `exp`.
- `EReal.expOrderIso`: The order isomorphism between `EReal` and `ℝ≥0∞` defined by `exp`
and `log`.
- `ENNReal.logHomeomorph`: `log` as a homeomorphism.
- `EReal.expHomeomorph`: `exp` as a homeomorphism.
## Main Results
- `EReal.log_exp`, `ENNReal.exp_log`: `log` and `exp` are inverses of each other.
- `EReal.exp_nmul`, `EReal.exp_mul`: `exp` satisfies the identities `exp (n * x) = (exp x) ^ n`
and `exp (x * y) = (exp x) ^ y`.
- `EReal` is a Polish space.
## Tags
ENNReal, EReal, logarithm, exponential
-/
open EReal ENNReal
section LogExp
@[simp] lemma EReal.log_exp (x : EReal) : log (exp x) = x := by
induction x
· simp
· rw [exp_coe, log_ofReal, if_neg (not_le.mpr (Real.exp_pos _)), Real.log_exp]
· simp
@[simp] lemma ENNReal.exp_log (x : ℝ≥0∞) : exp (log x) = x := by
by_cases hx_top : x = ∞
· simp [hx_top]
by_cases hx_zero : x = 0
· simp [hx_zero]
have hx_pos : 0 < x.toReal := ENNReal.toReal_pos hx_zero hx_top
rw [← ENNReal.ofReal_toReal hx_top, log_ofReal_of_pos hx_pos, exp_coe, Real.exp_log hx_pos]
end LogExp
section Exp
namespace EReal
lemma exp_nmul (x : EReal) (n : ℕ) : exp (n * x) = (exp x) ^ n := by
simp_rw [← log_eq_iff, log_pow, log_exp]
lemma exp_mul (x : EReal) (y : ℝ) : exp (x * y) = (exp x) ^ y := by
rw [← log_eq_iff, log_rpow, log_exp, log_exp, mul_comm]
end EReal
end Exp
namespace ENNReal
section OrderIso
/-- `ENNReal.log` and its inverse `EReal.exp` are an order isomorphism between `ℝ≥0∞` and
`EReal`. -/
noncomputable
def logOrderIso : ℝ≥0∞ ≃o EReal where
toFun := log
invFun := exp
left_inv x := exp_log x
right_inv x := log_exp x
map_rel_iff' := by simp only [Equiv.coe_fn_mk, log_le_log_iff, forall_const]
@[simp] lemma logOrderIso_apply (x : ℝ≥0∞) : logOrderIso x = log x := rfl
/-- `EReal.exp` and its inverse `ENNReal.log` are an order isomorphism between `EReal` and
`ℝ≥0∞`. -/
noncomputable
def _root_.EReal.expOrderIso := logOrderIso.symm
@[simp] lemma _root_.EReal.expOrderIso_apply (x : EReal) : expOrderIso x = exp x := rfl
@[simp] lemma logOrderIso_symm : logOrderIso.symm = expOrderIso := rfl
@[simp] lemma _root_.EReal.expOrderIso_symm : expOrderIso.symm = logOrderIso := rfl
end OrderIso
section Continuity
/-- `log` as a homeomorphism. -/
noncomputable def logHomeomorph : ℝ≥0∞ ≃ₜ EReal := logOrderIso.toHomeomorph
@[simp] lemma logHomeomorph_apply (x : ℝ≥0∞) : logHomeomorph x = log x := rfl
/-- `exp` as a homeomorphism. -/
noncomputable def _root_.EReal.expHomeomorph : EReal ≃ₜ ℝ≥0∞ := expOrderIso.toHomeomorph
@[simp] lemma _root_.EReal.expHomeomorph_apply (x : EReal) : expHomeomorph x = exp x := rfl
@[simp] lemma logHomeomorph_symm : logHomeomorph.symm = expHomeomorph := rfl
@[simp] lemma _root_.EReal.expHomeomorph_symm : expHomeomorph.symm = logHomeomorph := rfl
@[continuity, fun_prop]
lemma continuous_log : Continuous log := logOrderIso.continuous
@[continuity, fun_prop]
lemma continuous_exp : Continuous exp := expOrderIso.continuous
end Continuity
section Measurability
@[measurability, fun_prop]
lemma measurable_log : Measurable log := continuous_log.measurable
@[measurability, fun_prop]
lemma _root_.EReal.measurable_exp : Measurable exp := continuous_exp.measurable
@[measurability, fun_prop]
lemma _root_.Measurable.ennreal_log {α : Type*} {_ : MeasurableSpace α}
{f : α → ℝ≥0∞} (hf : Measurable f) :
Measurable fun x ↦ log (f x) := measurable_log.comp hf
@[measurability, fun_prop]
lemma _root_.Measurable.ereal_exp {α : Type*} {_ : MeasurableSpace α}
{f : α → EReal} (hf : Measurable f) :
Measurable fun x ↦ exp (f x) := measurable_exp.comp hf
end Measurability
end ENNReal
instance : PolishSpace EReal :=
ClosedEmbedding.polishSpace ⟨ENNReal.logOrderIso.symm.toHomeomorph.embedding,
ENNReal.logOrderIso.symm.toHomeomorph.range_coe ▸ isClosed_univ⟩
|
Analysis\SpecialFunctions\Log\ERealExp.lean | /-
Copyright (c) 2024 Rémy Degenne. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Pietro Monticone, Rémy Degenne, Lorenzo Luccioli
-/
import Mathlib.Data.Complex.Exponential
import Mathlib.Data.Real.EReal
/-!
# Extended Nonnegative Real Exponential
We define `exp` as an extension of the exponential of a real
to the extended reals `EReal`. The function takes values
in the extended nonnegative reals `ℝ≥0∞`, with `exp ⊥ = 0` and `exp ⊤ = ⊤`.
## Main Definitions
- `EReal.exp`: The extension of the real exponential to `EReal`.
## Main Results
- `EReal.exp_strictMono`: `exp` is increasing;
- `EReal.exp_neg`, `EReal.exp_add`: `exp` satisfies
the identities `exp (-x) = (exp x)⁻¹` and `exp (x + y) = exp x * exp y`.
## Tags
ENNReal, EReal, exponential
-/
namespace EReal
open scoped ENNReal
/-! ### Definition -/
section Definition
/-- Exponential as a function from `EReal` to `ℝ≥0∞`. -/
noncomputable
def exp : EReal → ℝ≥0∞
| ⊥ => 0
| ⊤ => ∞
| (x : ℝ) => ENNReal.ofReal (Real.exp x)
@[simp] lemma exp_bot : exp ⊥ = 0 := rfl
@[simp] lemma exp_zero : exp 0 = 1 := by simp [exp]
@[simp] lemma exp_top : exp ⊤ = ∞ := rfl
@[simp] lemma exp_coe (x : ℝ) : exp x = ENNReal.ofReal (Real.exp x) := rfl
@[simp] lemma exp_eq_zero_iff {x : EReal} : exp x = 0 ↔ x = ⊥ := by
induction x <;> simp [Real.exp_pos]
@[simp] lemma exp_eq_top_iff {x : EReal} : exp x = ∞ ↔ x = ⊤ := by
induction x <;> simp
end Definition
/-! ### Monotonicity -/
section Monotonicity
lemma exp_strictMono : StrictMono exp := by
intro x y h
induction x
· rw [exp_bot, pos_iff_ne_zero, ne_eq, exp_eq_zero_iff]
exact h.ne'
· induction y
· simp at h
· simp_rw [exp_coe]
exact ENNReal.ofReal_lt_ofReal_iff'.mpr ⟨Real.exp_lt_exp_of_lt (mod_cast h), Real.exp_pos _⟩
· simp
· exact (not_top_lt h).elim
lemma exp_monotone : Monotone exp := exp_strictMono.monotone
@[simp] lemma exp_lt_exp_iff {a b : EReal} : exp a < exp b ↔ a < b := exp_strictMono.lt_iff_lt
@[simp] lemma zero_lt_exp_iff {a : EReal} : 0 < exp a ↔ ⊥ < a := exp_bot ▸ @exp_lt_exp_iff ⊥ a
@[simp] lemma exp_lt_top_iff {a : EReal} : exp a < ⊤ ↔ a < ⊤ := exp_top ▸ @exp_lt_exp_iff a ⊤
@[simp] lemma exp_lt_one_iff {a : EReal} : exp a < 1 ↔ a < 0 := exp_zero ▸ @exp_lt_exp_iff a 0
@[simp] lemma one_lt_exp_iff {a : EReal} : 1 < exp a ↔ 0 < a := exp_zero ▸ @exp_lt_exp_iff 0 a
@[simp] lemma exp_le_exp_iff {a b : EReal} : exp a ≤ exp b ↔ a ≤ b := exp_strictMono.le_iff_le
@[simp] lemma exp_le_one_iff {a : EReal} : exp a ≤ 1 ↔ a ≤ 0 := exp_zero ▸ @exp_le_exp_iff a 0
@[simp] lemma one_le_exp_iff {a : EReal} : 1 ≤ exp a ↔ 0 ≤ a := exp_zero ▸ @exp_le_exp_iff 0 a
end Monotonicity
/-! ### Algebraic properties -/
section Morphism
lemma exp_neg (x : EReal) : exp (-x) = (exp x)⁻¹ := by
induction x
· simp
· rw [exp_coe, ← EReal.coe_neg, exp_coe, ← ENNReal.ofReal_inv_of_pos (Real.exp_pos _),
Real.exp_neg]
· simp
lemma exp_add (x y : EReal) : exp (x + y) = exp x * exp y := by
induction x
· simp
· induction y
· simp
· simp only [← EReal.coe_add, exp_coe]
rw [← ENNReal.ofReal_mul (Real.exp_nonneg _), Real.exp_add]
· simp only [EReal.coe_add_top, exp_top, exp_coe]
rw [ENNReal.mul_top]
simp [Real.exp_pos]
· induction y
· simp
· simp only [EReal.top_add_coe, exp_top, exp_coe]
rw [ENNReal.top_mul]
simp [Real.exp_pos]
· simp
end Morphism
end EReal
|
Analysis\SpecialFunctions\Log\Monotone.lean | /-
Copyright (c) 2021 Bolton Bailey. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Bolton Bailey
-/
import Mathlib.Analysis.SpecialFunctions.Pow.Real
/-!
# Logarithm Tonality
In this file we describe the tonality of the logarithm function when multiplied by functions of the
form `x ^ a`.
## Tags
logarithm, tonality
-/
open Set Filter Function
open Topology
noncomputable section
namespace Real
variable {x y : ℝ}
theorem log_mul_self_monotoneOn : MonotoneOn (fun x : ℝ => log x * x) { x | 1 ≤ x } := by
-- TODO: can be strengthened to exp (-1) ≤ x
simp only [MonotoneOn, mem_setOf_eq]
intro x hex y hey hxy
have y_pos : 0 < y := lt_of_lt_of_le zero_lt_one hey
gcongr
rwa [le_log_iff_exp_le y_pos, Real.exp_zero]
theorem log_div_self_antitoneOn : AntitoneOn (fun x : ℝ => log x / x) { x | exp 1 ≤ x } := by
simp only [AntitoneOn, mem_setOf_eq]
intro x hex y hey hxy
have x_pos : 0 < x := (exp_pos 1).trans_le hex
have y_pos : 0 < y := (exp_pos 1).trans_le hey
have hlogx : 1 ≤ log x := by rwa [le_log_iff_exp_le x_pos]
have hyx : 0 ≤ y / x - 1 := by rwa [le_sub_iff_add_le, le_div_iff x_pos, zero_add, one_mul]
rw [div_le_iff y_pos, ← sub_le_sub_iff_right (log x)]
calc
log y - log x = log (y / x) := by rw [log_div y_pos.ne' x_pos.ne']
_ ≤ y / x - 1 := log_le_sub_one_of_pos (div_pos y_pos x_pos)
_ ≤ log x * (y / x - 1) := le_mul_of_one_le_left hyx hlogx
_ = log x / x * y - log x := by ring
theorem log_div_self_rpow_antitoneOn {a : ℝ} (ha : 0 < a) :
AntitoneOn (fun x : ℝ => log x / x ^ a) { x | exp (1 / a) ≤ x } := by
simp only [AntitoneOn, mem_setOf_eq]
intro x hex y _ hxy
have x_pos : 0 < x := lt_of_lt_of_le (exp_pos (1 / a)) hex
have y_pos : 0 < y := by linarith
have x_nonneg : 0 ≤ x := le_trans (le_of_lt (exp_pos (1 / a))) hex
have y_nonneg : 0 ≤ y := by linarith
nth_rw 1 [← rpow_one y]
nth_rw 1 [← rpow_one x]
rw [← div_self (ne_of_lt ha).symm, div_eq_mul_one_div a a, rpow_mul y_nonneg, rpow_mul x_nonneg,
log_rpow (rpow_pos_of_pos y_pos a), log_rpow (rpow_pos_of_pos x_pos a), mul_div_assoc,
mul_div_assoc, mul_le_mul_left (one_div_pos.mpr ha)]
refine log_div_self_antitoneOn ?_ ?_ ?_
· simp only [Set.mem_setOf_eq]
convert rpow_le_rpow _ hex (le_of_lt ha) using 1
· rw [← exp_mul]
simp only [Real.exp_eq_exp]
field_simp [(ne_of_lt ha).symm]
exact le_of_lt (exp_pos (1 / a))
· simp only [Set.mem_setOf_eq]
convert rpow_le_rpow _ (_root_.trans hex hxy) (le_of_lt ha) using 1
· rw [← exp_mul]
simp only [Real.exp_eq_exp]
field_simp [(ne_of_lt ha).symm]
exact le_of_lt (exp_pos (1 / a))
gcongr
theorem log_div_sqrt_antitoneOn : AntitoneOn (fun x : ℝ => log x / √x) { x | exp 2 ≤ x } := by
simp_rw [sqrt_eq_rpow]
convert @log_div_self_rpow_antitoneOn (1 / 2) (by norm_num)
norm_num
end Real
|
Analysis\SpecialFunctions\Log\NegMulLog.lean | /-
Copyright (c) 2023 Rémy Degenne. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Rémy Degenne
-/
import Mathlib.Analysis.SpecialFunctions.Log.Deriv
import Mathlib.Analysis.SpecialFunctions.Pow.Asymptotics
import Mathlib.Analysis.Convex.Deriv
/-!
# The function `x ↦ - x * log x`
The purpose of this file is to record basic analytic properties of the function `x ↦ - x * log x`,
which is notably used in the theory of Shannon entropy.
## Main definitions
* `negMulLog`: the function `x ↦ - x * log x` from `ℝ` to `ℝ`.
-/
open scoped Topology
namespace Real
lemma continuous_mul_log : Continuous fun x ↦ x * log x := by
rw [continuous_iff_continuousAt]
intro x
obtain hx | rfl := ne_or_eq x 0
· exact (continuous_id'.continuousAt).mul (continuousAt_log hx)
rw [ContinuousAt, zero_mul]
simp_rw [mul_comm _ (log _)]
nth_rewrite 1 [← nhdsWithin_univ]
have : (Set.univ : Set ℝ) = Set.Iio 0 ∪ Set.Ioi 0 ∪ {0} := by ext; simp [em]
rw [this, nhdsWithin_union, nhdsWithin_union]
simp only [nhdsWithin_singleton, sup_le_iff, Filter.nonpos_iff, Filter.tendsto_sup]
refine ⟨⟨tendsto_log_mul_self_nhds_zero_left, ?_⟩, ?_⟩
· simpa only [rpow_one] using tendsto_log_mul_rpow_nhds_zero zero_lt_one
· convert tendsto_pure_nhds (fun x ↦ log x * x) 0
simp
lemma differentiableOn_mul_log : DifferentiableOn ℝ (fun x ↦ x * log x) {0}ᶜ :=
differentiable_id'.differentiableOn.mul differentiableOn_log
lemma deriv_mul_log {x : ℝ} (hx : x ≠ 0) : deriv (fun x ↦ x * log x) x = log x + 1 := by
rw [deriv_mul differentiableAt_id' (differentiableAt_log hx)]
simp only [deriv_id'', one_mul, deriv_log', ne_eq, add_right_inj]
exact mul_inv_cancel hx
lemma hasDerivAt_mul_log {x : ℝ} (hx : x ≠ 0) : HasDerivAt (fun x ↦ x * log x) (log x + 1) x := by
rw [← deriv_mul_log hx, hasDerivAt_deriv_iff]
refine DifferentiableOn.differentiableAt differentiableOn_mul_log ?_
simp [hx]
lemma deriv2_mul_log {x : ℝ} (hx : x ≠ 0) : deriv^[2] (fun x ↦ x * log x) x = x⁻¹ := by
simp only [Function.iterate_succ, Function.iterate_zero, Function.id_comp, Function.comp_apply]
suffices ∀ᶠ y in (𝓝 x), deriv (fun x ↦ x * log x) y = log y + 1 by
refine (Filter.EventuallyEq.deriv_eq this).trans ?_
rw [deriv_add_const, deriv_log x]
filter_upwards [eventually_ne_nhds hx] with y hy using deriv_mul_log hy
lemma strictConvexOn_mul_log : StrictConvexOn ℝ (Set.Ici (0 : ℝ)) (fun x ↦ x * log x) := by
refine strictConvexOn_of_deriv2_pos (convex_Ici 0) (continuous_mul_log.continuousOn) ?_
intro x hx
simp only [Set.nonempty_Iio, interior_Ici', Set.mem_Ioi] at hx
rw [deriv2_mul_log hx.ne']
positivity
lemma convexOn_mul_log : ConvexOn ℝ (Set.Ici (0 : ℝ)) (fun x ↦ x * log x) :=
strictConvexOn_mul_log.convexOn
lemma mul_log_nonneg {x : ℝ} (hx : 1 ≤ x) : 0 ≤ x * log x :=
mul_nonneg (zero_le_one.trans hx) (log_nonneg hx)
lemma mul_log_nonpos {x : ℝ} (hx₀ : 0 ≤ x) (hx₁ : x ≤ 1) : x * log x ≤ 0 :=
mul_nonpos_of_nonneg_of_nonpos hx₀ (log_nonpos hx₀ hx₁)
section negMulLog
/-- The function `x ↦ - x * log x` from `ℝ` to `ℝ`. -/
noncomputable def negMulLog (x : ℝ) : ℝ := - x * log x
lemma negMulLog_def : negMulLog = fun x ↦ - x * log x := rfl
lemma negMulLog_eq_neg : negMulLog = fun x ↦ - (x * log x) := by simp [negMulLog_def]
@[simp] lemma negMulLog_zero : negMulLog (0 : ℝ) = 0 := by simp [negMulLog]
@[simp] lemma negMulLog_one : negMulLog (1 : ℝ) = 0 := by simp [negMulLog]
lemma negMulLog_nonneg {x : ℝ} (h1 : 0 ≤ x) (h2 : x ≤ 1) : 0 ≤ negMulLog x := by
simpa only [negMulLog_eq_neg, neg_nonneg] using mul_log_nonpos h1 h2
lemma negMulLog_mul (x y : ℝ) : negMulLog (x * y) = y * negMulLog x + x * negMulLog y := by
simp only [negMulLog, neg_mul, neg_add_rev]
by_cases hx : x = 0
· simp [hx]
by_cases hy : y = 0
· simp [hy]
rw [log_mul hx hy]
ring
lemma continuous_negMulLog : Continuous negMulLog := by
simpa only [negMulLog_eq_neg] using continuous_mul_log.neg
lemma differentiableOn_negMulLog : DifferentiableOn ℝ negMulLog {0}ᶜ := by
simpa only [negMulLog_eq_neg] using differentiableOn_mul_log.neg
lemma deriv_negMulLog {x : ℝ} (hx : x ≠ 0) : deriv negMulLog x = - log x - 1 := by
rw [negMulLog_eq_neg, deriv.neg, deriv_mul_log hx]
ring
lemma hasDerivAt_negMulLog {x : ℝ} (hx : x ≠ 0) : HasDerivAt negMulLog (- log x - 1) x := by
rw [← deriv_negMulLog hx, hasDerivAt_deriv_iff]
refine DifferentiableOn.differentiableAt differentiableOn_negMulLog ?_
simp [hx]
lemma deriv2_negMulLog {x : ℝ} (hx : x ≠ 0) : deriv^[2] negMulLog x = - x⁻¹ := by
rw [negMulLog_eq_neg]
have h := deriv2_mul_log hx
simp only [Function.iterate_succ, Function.iterate_zero, Function.id_comp,
Function.comp_apply, deriv.neg', differentiableAt_id', differentiableAt_log_iff, ne_eq] at h ⊢
rw [h]
lemma strictConcaveOn_negMulLog : StrictConcaveOn ℝ (Set.Ici (0 : ℝ)) negMulLog := by
simpa only [negMulLog_eq_neg] using strictConvexOn_mul_log.neg
lemma concaveOn_negMulLog : ConcaveOn ℝ (Set.Ici (0 : ℝ)) negMulLog :=
strictConcaveOn_negMulLog.concaveOn
end negMulLog
end Real
|
Analysis\SpecialFunctions\Pow\Asymptotics.lean | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Sébastien Gouëzel,
Rémy Degenne, David Loeffler
-/
import Mathlib.Analysis.SpecialFunctions.Pow.NNReal
/-!
# Limits and asymptotics of power functions at `+∞`
This file contains results about the limiting behaviour of power functions at `+∞`. For convenience
some results on asymptotics as `x → 0` (those which are not just continuity statements) are also
located here.
-/
noncomputable section
open scoped Classical
open Real Topology NNReal ENNReal Filter ComplexConjugate Finset Set
/-!
## Limits at `+∞`
-/
section Limits
open Real Filter
/-- The function `x ^ y` tends to `+∞` at `+∞` for any positive real `y`. -/
theorem tendsto_rpow_atTop {y : ℝ} (hy : 0 < y) : Tendsto (fun x : ℝ => x ^ y) atTop atTop := by
rw [tendsto_atTop_atTop]
intro b
use max b 0 ^ (1 / y)
intro x hx
exact
le_of_max_le_left
(by
convert rpow_le_rpow (rpow_nonneg (le_max_right b 0) (1 / y)) hx (le_of_lt hy)
using 1
rw [← rpow_mul (le_max_right b 0), (eq_div_iff (ne_of_gt hy)).mp rfl, Real.rpow_one])
/-- The function `x ^ (-y)` tends to `0` at `+∞` for any positive real `y`. -/
theorem tendsto_rpow_neg_atTop {y : ℝ} (hy : 0 < y) : Tendsto (fun x : ℝ => x ^ (-y)) atTop (𝓝 0) :=
Tendsto.congr' (eventuallyEq_of_mem (Ioi_mem_atTop 0) fun _ hx => (rpow_neg (le_of_lt hx) y).symm)
(tendsto_rpow_atTop hy).inv_tendsto_atTop
open Asymptotics in
lemma tendsto_rpow_atTop_of_base_lt_one (b : ℝ) (hb₀ : -1 < b) (hb₁ : b < 1) :
Tendsto (b ^ · : ℝ → ℝ) atTop (𝓝 (0 : ℝ)) := by
rcases lt_trichotomy b 0 with hb|rfl|hb
case inl => -- b < 0
simp_rw [Real.rpow_def_of_nonpos hb.le, hb.ne, ite_false]
rw [← isLittleO_const_iff (c := (1 : ℝ)) one_ne_zero, (one_mul (1 : ℝ)).symm]
refine IsLittleO.mul_isBigO ?exp ?cos
case exp =>
rw [isLittleO_const_iff one_ne_zero]
refine tendsto_exp_atBot.comp <| (tendsto_const_mul_atBot_of_neg ?_).mpr tendsto_id
rw [← log_neg_eq_log, log_neg_iff (by linarith)]
linarith
case cos =>
rw [isBigO_iff]
exact ⟨1, eventually_of_forall fun x => by simp [Real.abs_cos_le_one]⟩
case inr.inl => -- b = 0
refine Tendsto.mono_right ?_ (Iff.mpr pure_le_nhds_iff rfl)
rw [tendsto_pure]
filter_upwards [eventually_ne_atTop 0] with _ hx
simp [hx]
case inr.inr => -- b > 0
simp_rw [Real.rpow_def_of_pos hb]
refine tendsto_exp_atBot.comp <| (tendsto_const_mul_atBot_of_neg ?_).mpr tendsto_id
exact (log_neg_iff hb).mpr hb₁
lemma tendsto_rpow_atTop_of_base_gt_one (b : ℝ) (hb : 1 < b) :
Tendsto (b ^ · : ℝ → ℝ) atBot (𝓝 (0 : ℝ)) := by
simp_rw [Real.rpow_def_of_pos (by positivity : 0 < b)]
refine tendsto_exp_atBot.comp <| (tendsto_const_mul_atBot_of_pos ?_).mpr tendsto_id
exact (log_pos_iff (by positivity)).mpr <| by aesop
lemma tendsto_rpow_atBot_of_base_lt_one (b : ℝ) (hb₀ : 0 < b) (hb₁ : b < 1) :
Tendsto (b ^ · : ℝ → ℝ) atBot atTop := by
simp_rw [Real.rpow_def_of_pos (by positivity : 0 < b)]
refine tendsto_exp_atTop.comp <| (tendsto_const_mul_atTop_iff_neg <| tendsto_id (α := ℝ)).mpr ?_
exact (log_neg_iff hb₀).mpr hb₁
lemma tendsto_rpow_atBot_of_base_gt_one (b : ℝ) (hb : 1 < b) :
Tendsto (b ^ · : ℝ → ℝ) atBot (𝓝 0) := by
simp_rw [Real.rpow_def_of_pos (by positivity : 0 < b)]
refine tendsto_exp_atBot.comp <| (tendsto_const_mul_atBot_iff_pos <| tendsto_id (α := ℝ)).mpr ?_
exact (log_pos_iff (by positivity)).mpr <| by aesop
/-- The function `x ^ (a / (b * x + c))` tends to `1` at `+∞`, for any real numbers `a`, `b`, and
`c` such that `b` is nonzero. -/
theorem tendsto_rpow_div_mul_add (a b c : ℝ) (hb : 0 ≠ b) :
Tendsto (fun x => x ^ (a / (b * x + c))) atTop (𝓝 1) := by
refine
Tendsto.congr' ?_
((tendsto_exp_nhds_zero_nhds_one.comp
(by
simpa only [mul_zero, pow_one] using
(tendsto_const_nhds (x := a)).mul
(tendsto_div_pow_mul_exp_add_atTop b c 1 hb))).comp
tendsto_log_atTop)
apply eventuallyEq_of_mem (Ioi_mem_atTop (0 : ℝ))
intro x hx
simp only [Set.mem_Ioi, Function.comp_apply] at hx ⊢
rw [exp_log hx, ← exp_log (rpow_pos_of_pos hx (a / (b * x + c))), log_rpow hx (a / (b * x + c))]
field_simp
/-- The function `x ^ (1 / x)` tends to `1` at `+∞`. -/
theorem tendsto_rpow_div : Tendsto (fun x => x ^ ((1 : ℝ) / x)) atTop (𝓝 1) := by
convert tendsto_rpow_div_mul_add (1 : ℝ) _ (0 : ℝ) zero_ne_one
ring
/-- The function `x ^ (-1 / x)` tends to `1` at `+∞`. -/
theorem tendsto_rpow_neg_div : Tendsto (fun x => x ^ (-(1 : ℝ) / x)) atTop (𝓝 1) := by
convert tendsto_rpow_div_mul_add (-(1 : ℝ)) _ (0 : ℝ) zero_ne_one
ring
/-- The function `exp(x) / x ^ s` tends to `+∞` at `+∞`, for any real number `s`. -/
theorem tendsto_exp_div_rpow_atTop (s : ℝ) : Tendsto (fun x : ℝ => exp x / x ^ s) atTop atTop := by
cases' archimedean_iff_nat_lt.1 Real.instArchimedean s with n hn
refine tendsto_atTop_mono' _ ?_ (tendsto_exp_div_pow_atTop n)
filter_upwards [eventually_gt_atTop (0 : ℝ), eventually_ge_atTop (1 : ℝ)] with x hx₀ hx₁
rw [div_le_div_left (exp_pos _) (pow_pos hx₀ _) (rpow_pos_of_pos hx₀ _), ← Real.rpow_natCast]
exact rpow_le_rpow_of_exponent_le hx₁ hn.le
/-- The function `exp (b * x) / x ^ s` tends to `+∞` at `+∞`, for any real `s` and `b > 0`. -/
theorem tendsto_exp_mul_div_rpow_atTop (s : ℝ) (b : ℝ) (hb : 0 < b) :
Tendsto (fun x : ℝ => exp (b * x) / x ^ s) atTop atTop := by
refine ((tendsto_rpow_atTop hb).comp (tendsto_exp_div_rpow_atTop (s / b))).congr' ?_
filter_upwards [eventually_ge_atTop (0 : ℝ)] with x hx₀
simp [Real.div_rpow, (exp_pos x).le, rpow_nonneg, ← Real.rpow_mul, ← exp_mul,
mul_comm x, hb.ne', *]
/-- The function `x ^ s * exp (-b * x)` tends to `0` at `+∞`, for any real `s` and `b > 0`. -/
theorem tendsto_rpow_mul_exp_neg_mul_atTop_nhds_zero (s : ℝ) (b : ℝ) (hb : 0 < b) :
Tendsto (fun x : ℝ => x ^ s * exp (-b * x)) atTop (𝓝 0) := by
refine (tendsto_exp_mul_div_rpow_atTop s b hb).inv_tendsto_atTop.congr' ?_
filter_upwards with x using by simp [exp_neg, inv_div, div_eq_mul_inv _ (exp _)]
@[deprecated (since := "2024-01-31")]
alias tendsto_rpow_mul_exp_neg_mul_atTop_nhds_0 := tendsto_rpow_mul_exp_neg_mul_atTop_nhds_zero
nonrec theorem NNReal.tendsto_rpow_atTop {y : ℝ} (hy : 0 < y) :
Tendsto (fun x : ℝ≥0 => x ^ y) atTop atTop := by
rw [Filter.tendsto_atTop_atTop]
intro b
obtain ⟨c, hc⟩ := tendsto_atTop_atTop.mp (tendsto_rpow_atTop hy) b
use c.toNNReal
intro a ha
exact mod_cast hc a (Real.toNNReal_le_iff_le_coe.mp ha)
theorem ENNReal.tendsto_rpow_at_top {y : ℝ} (hy : 0 < y) :
Tendsto (fun x : ℝ≥0∞ => x ^ y) (𝓝 ⊤) (𝓝 ⊤) := by
rw [ENNReal.tendsto_nhds_top_iff_nnreal]
intro x
obtain ⟨c, _, hc⟩ :=
(atTop_basis_Ioi.tendsto_iff atTop_basis_Ioi).mp (NNReal.tendsto_rpow_atTop hy) x trivial
have hc' : Set.Ioi ↑c ∈ 𝓝 (⊤ : ℝ≥0∞) := Ioi_mem_nhds ENNReal.coe_lt_top
filter_upwards [hc'] with a ha
by_cases ha' : a = ⊤
· simp [ha', hy]
lift a to ℝ≥0 using ha'
-- Porting note: reduced defeq abuse
simp only [Set.mem_Ioi, coe_lt_coe] at ha hc
rw [ENNReal.coe_rpow_of_nonneg _ hy.le]
exact mod_cast hc a ha
end Limits
/-!
## Asymptotic results: `IsBigO`, `IsLittleO` and `IsTheta`
-/
namespace Complex
section
variable {α : Type*} {l : Filter α} {f g : α → ℂ}
open Asymptotics
theorem isTheta_exp_arg_mul_im (hl : IsBoundedUnder (· ≤ ·) l fun x => |(g x).im|) :
(fun x => Real.exp (arg (f x) * im (g x))) =Θ[l] fun _ => (1 : ℝ) := by
rcases hl with ⟨b, hb⟩
refine Real.isTheta_exp_comp_one.2 ⟨π * b, ?_⟩
rw [eventually_map] at hb ⊢
refine hb.mono fun x hx => ?_
erw [abs_mul]
exact mul_le_mul (abs_arg_le_pi _) hx (abs_nonneg _) Real.pi_pos.le
theorem isBigO_cpow_rpow (hl : IsBoundedUnder (· ≤ ·) l fun x => |(g x).im|) :
(fun x => f x ^ g x) =O[l] fun x => abs (f x) ^ (g x).re :=
calc
(fun x => f x ^ g x) =O[l]
(show α → ℝ from fun x => abs (f x) ^ (g x).re / Real.exp (arg (f x) * im (g x))) :=
isBigO_of_le _ fun x => (abs_cpow_le _ _).trans (le_abs_self _)
_ =Θ[l] (show α → ℝ from fun x => abs (f x) ^ (g x).re / (1 : ℝ)) :=
((isTheta_refl _ _).div (isTheta_exp_arg_mul_im hl))
_ =ᶠ[l] (show α → ℝ from fun x => abs (f x) ^ (g x).re) := by
simp only [ofReal_one, div_one]
rfl
theorem isTheta_cpow_rpow (hl_im : IsBoundedUnder (· ≤ ·) l fun x => |(g x).im|)
(hl : ∀ᶠ x in l, f x = 0 → re (g x) = 0 → g x = 0) :
(fun x => f x ^ g x) =Θ[l] fun x => abs (f x) ^ (g x).re :=
calc
(fun x => f x ^ g x) =Θ[l]
(show α → ℝ from fun x => abs (f x) ^ (g x).re / Real.exp (arg (f x) * im (g x))) :=
isTheta_of_norm_eventuallyEq' <| hl.mono fun x => abs_cpow_of_imp
_ =Θ[l] (show α → ℝ from fun x => abs (f x) ^ (g x).re / (1 : ℝ)) :=
((isTheta_refl _ _).div (isTheta_exp_arg_mul_im hl_im))
_ =ᶠ[l] (show α → ℝ from fun x => abs (f x) ^ (g x).re) := by
simp only [ofReal_one, div_one]
rfl
theorem isTheta_cpow_const_rpow {b : ℂ} (hl : b.re = 0 → b ≠ 0 → ∀ᶠ x in l, f x ≠ 0) :
(fun x => f x ^ b) =Θ[l] fun x => abs (f x) ^ b.re :=
isTheta_cpow_rpow isBoundedUnder_const <| by
-- Porting note: was
-- simpa only [eventually_imp_distrib_right, Ne.def, ← not_frequently, not_imp_not, Imp.swap]
-- using hl
-- but including `Imp.swap` caused an infinite loop
convert hl
rw [eventually_imp_distrib_right]
tauto
end
end Complex
open Real
namespace Asymptotics
variable {α : Type*} {r c : ℝ} {l : Filter α} {f g : α → ℝ}
theorem IsBigOWith.rpow (h : IsBigOWith c l f g) (hc : 0 ≤ c) (hr : 0 ≤ r) (hg : 0 ≤ᶠ[l] g) :
IsBigOWith (c ^ r) l (fun x => f x ^ r) fun x => g x ^ r := by
apply IsBigOWith.of_bound
filter_upwards [hg, h.bound] with x hgx hx
calc
|f x ^ r| ≤ |f x| ^ r := abs_rpow_le_abs_rpow _ _
_ ≤ (c * |g x|) ^ r := rpow_le_rpow (abs_nonneg _) hx hr
_ = c ^ r * |g x ^ r| := by rw [mul_rpow hc (abs_nonneg _), abs_rpow_of_nonneg hgx]
theorem IsBigO.rpow (hr : 0 ≤ r) (hg : 0 ≤ᶠ[l] g) (h : f =O[l] g) :
(fun x => f x ^ r) =O[l] fun x => g x ^ r :=
let ⟨_, hc, h'⟩ := h.exists_nonneg
(h'.rpow hc hr hg).isBigO
theorem IsTheta.rpow (hr : 0 ≤ r) (hf : 0 ≤ᶠ[l] f) (hg : 0 ≤ᶠ[l] g) (h : f =Θ[l] g) :
(fun x => f x ^ r) =Θ[l] fun x => g x ^ r :=
⟨h.1.rpow hr hg, h.2.rpow hr hf⟩
theorem IsLittleO.rpow (hr : 0 < r) (hg : 0 ≤ᶠ[l] g) (h : f =o[l] g) :
(fun x => f x ^ r) =o[l] fun x => g x ^ r := by
refine .of_isBigOWith fun c hc ↦ ?_
rw [← rpow_inv_rpow hc.le hr.ne']
refine (h.forall_isBigOWith ?_).rpow ?_ ?_ hg <;> positivity
protected lemma IsBigO.sqrt (hfg : f =O[l] g) (hg : 0 ≤ᶠ[l] g) :
(Real.sqrt <| f ·) =O[l] (Real.sqrt <| g ·) := by
simpa [Real.sqrt_eq_rpow] using hfg.rpow one_half_pos.le hg
protected lemma IsLittleO.sqrt (hfg : f =o[l] g) (hg : 0 ≤ᶠ[l] g) :
(Real.sqrt <| f ·) =o[l] (Real.sqrt <| g ·) := by
simpa [Real.sqrt_eq_rpow] using hfg.rpow one_half_pos hg
protected lemma IsTheta.sqrt (hfg : f =Θ[l] g) (hf : 0 ≤ᶠ[l] f) (hg : 0 ≤ᶠ[l] g) :
(Real.sqrt <| f ·) =Θ[l] (Real.sqrt <| g ·) :=
⟨hfg.1.sqrt hg, hfg.2.sqrt hf⟩
end Asymptotics
open Asymptotics
/-- `x ^ s = o(exp(b * x))` as `x → ∞` for any real `s` and positive `b`. -/
theorem isLittleO_rpow_exp_pos_mul_atTop (s : ℝ) {b : ℝ} (hb : 0 < b) :
(fun x : ℝ => x ^ s) =o[atTop] fun x => exp (b * x) :=
isLittleO_of_tendsto (fun x h => absurd h (exp_pos _).ne') <| by
simpa only [div_eq_mul_inv, exp_neg, neg_mul] using
tendsto_rpow_mul_exp_neg_mul_atTop_nhds_zero s b hb
/-- `x ^ k = o(exp(b * x))` as `x → ∞` for any integer `k` and positive `b`. -/
theorem isLittleO_zpow_exp_pos_mul_atTop (k : ℤ) {b : ℝ} (hb : 0 < b) :
(fun x : ℝ => x ^ k) =o[atTop] fun x => exp (b * x) := by
simpa only [Real.rpow_intCast] using isLittleO_rpow_exp_pos_mul_atTop k hb
/-- `x ^ k = o(exp(b * x))` as `x → ∞` for any natural `k` and positive `b`. -/
theorem isLittleO_pow_exp_pos_mul_atTop (k : ℕ) {b : ℝ} (hb : 0 < b) :
(fun x : ℝ => x ^ k) =o[atTop] fun x => exp (b * x) := by
simpa using isLittleO_zpow_exp_pos_mul_atTop k hb
/-- `x ^ s = o(exp x)` as `x → ∞` for any real `s`. -/
theorem isLittleO_rpow_exp_atTop (s : ℝ) : (fun x : ℝ => x ^ s) =o[atTop] exp := by
simpa only [one_mul] using isLittleO_rpow_exp_pos_mul_atTop s one_pos
/-- `exp (-a * x) = o(x ^ s)` as `x → ∞`, for any positive `a` and real `s`. -/
theorem isLittleO_exp_neg_mul_rpow_atTop {a : ℝ} (ha : 0 < a) (b : ℝ) :
IsLittleO atTop (fun x : ℝ => exp (-a * x)) fun x : ℝ => x ^ b := by
apply isLittleO_of_tendsto'
· refine (eventually_gt_atTop 0).mono fun t ht h => ?_
rw [rpow_eq_zero_iff_of_nonneg ht.le] at h
exact (ht.ne' h.1).elim
· refine (tendsto_exp_mul_div_rpow_atTop (-b) a ha).inv_tendsto_atTop.congr' ?_
refine (eventually_ge_atTop 0).mono fun t ht => ?_
field_simp [Real.exp_neg, rpow_neg ht]
theorem isLittleO_log_rpow_atTop {r : ℝ} (hr : 0 < r) : log =o[atTop] fun x => x ^ r :=
calc
log =O[atTop] fun x => r * log x := isBigO_self_const_mul _ hr.ne' _ _
_ =ᶠ[atTop] fun x => log (x ^ r) :=
((eventually_gt_atTop 0).mono fun _ hx => (log_rpow hx _).symm)
_ =o[atTop] fun x => x ^ r := isLittleO_log_id_atTop.comp_tendsto (tendsto_rpow_atTop hr)
theorem isLittleO_log_rpow_rpow_atTop {s : ℝ} (r : ℝ) (hs : 0 < s) :
(fun x => log x ^ r) =o[atTop] fun x => x ^ s :=
let r' := max r 1
have hr : 0 < r' := lt_max_iff.2 <| Or.inr one_pos
have H : 0 < s / r' := div_pos hs hr
calc
(fun x => log x ^ r) =O[atTop] fun x => log x ^ r' :=
IsBigO.of_bound 1 <|
(tendsto_log_atTop.eventually_ge_atTop 1).mono fun x hx => by
have hx₀ : 0 ≤ log x := zero_le_one.trans hx
simp [r', norm_eq_abs, abs_rpow_of_nonneg, abs_rpow_of_nonneg hx₀,
rpow_le_rpow_of_exponent_le (hx.trans (le_abs_self _))]
_ =o[atTop] fun x => (x ^ (s / r')) ^ r' :=
((isLittleO_log_rpow_atTop H).rpow hr <|
(_root_.tendsto_rpow_atTop H).eventually <| eventually_ge_atTop 0)
_ =ᶠ[atTop] fun x => x ^ s :=
(eventually_ge_atTop 0).mono fun x hx ↦ by simp only [← rpow_mul hx, div_mul_cancel₀ _ hr.ne']
theorem isLittleO_abs_log_rpow_rpow_nhds_zero {s : ℝ} (r : ℝ) (hs : s < 0) :
(fun x => |log x| ^ r) =o[𝓝[>] 0] fun x => x ^ s :=
((isLittleO_log_rpow_rpow_atTop r (neg_pos.2 hs)).comp_tendsto tendsto_inv_zero_atTop).congr'
(mem_of_superset (Icc_mem_nhdsWithin_Ioi <| Set.left_mem_Ico.2 one_pos) fun x hx => by
simp [abs_of_nonpos, log_nonpos hx.1 hx.2])
(eventually_mem_nhdsWithin.mono fun x hx => by
rw [Function.comp_apply, inv_rpow hx.out.le, rpow_neg hx.out.le, inv_inv])
theorem isLittleO_log_rpow_nhds_zero {r : ℝ} (hr : r < 0) : log =o[𝓝[>] 0] fun x => x ^ r :=
(isLittleO_abs_log_rpow_rpow_nhds_zero 1 hr).neg_left.congr'
(mem_of_superset (Icc_mem_nhdsWithin_Ioi <| Set.left_mem_Ico.2 one_pos) fun x hx => by
simp [abs_of_nonpos (log_nonpos hx.1 hx.2)])
EventuallyEq.rfl
theorem tendsto_log_div_rpow_nhds_zero {r : ℝ} (hr : r < 0) :
Tendsto (fun x => log x / x ^ r) (𝓝[>] 0) (𝓝 0) :=
(isLittleO_log_rpow_nhds_zero hr).tendsto_div_nhds_zero
theorem tendsto_log_mul_rpow_nhds_zero {r : ℝ} (hr : 0 < r) :
Tendsto (fun x => log x * x ^ r) (𝓝[>] 0) (𝓝 0) :=
(tendsto_log_div_rpow_nhds_zero <| neg_lt_zero.2 hr).congr' <|
eventually_mem_nhdsWithin.mono fun x hx => by rw [rpow_neg hx.out.le, div_inv_eq_mul]
lemma tendsto_log_mul_self_nhds_zero_left : Filter.Tendsto (fun x ↦ log x * x) (𝓝[<] 0) (𝓝 0) := by
have h := tendsto_log_mul_rpow_nhds_zero zero_lt_one
simp only [Real.rpow_one] at h
have h_eq : ∀ x ∈ Set.Iio 0, (- (fun x ↦ log x * x) ∘ (fun x ↦ |x|)) x = log x * x := by
simp only [Set.mem_Iio, Pi.neg_apply, Function.comp_apply, log_abs]
intro x hx
simp only [abs_of_nonpos hx.le, mul_neg, neg_neg]
refine tendsto_nhdsWithin_congr h_eq ?_
nth_rewrite 3 [← neg_zero]
refine (h.comp (tendsto_abs_nhdsWithin_zero.mono_left ?_)).neg
refine nhdsWithin_mono 0 (fun x hx ↦ ?_)
simp only [Set.mem_Iio] at hx
simp only [Set.mem_compl_iff, Set.mem_singleton_iff, hx.ne, not_false_eq_true]
|
Analysis\SpecialFunctions\Pow\Complex.lean | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Sébastien Gouëzel,
Rémy Degenne, David Loeffler
-/
import Mathlib.Analysis.SpecialFunctions.Complex.Log
/-! # Power function on `ℂ`
We construct the power functions `x ^ y`, where `x` and `y` are complex numbers.
-/
open scoped Classical
open Real Topology Filter ComplexConjugate Finset Set
namespace Complex
/-- The complex power function `x ^ y`, given by `x ^ y = exp(y log x)` (where `log` is the
principal determination of the logarithm), unless `x = 0` where one sets `0 ^ 0 = 1` and
`0 ^ y = 0` for `y ≠ 0`. -/
noncomputable def cpow (x y : ℂ) : ℂ :=
if x = 0 then if y = 0 then 1 else 0 else exp (log x * y)
noncomputable instance : Pow ℂ ℂ :=
⟨cpow⟩
@[simp]
theorem cpow_eq_pow (x y : ℂ) : cpow x y = x ^ y :=
rfl
theorem cpow_def (x y : ℂ) : x ^ y = if x = 0 then if y = 0 then 1 else 0 else exp (log x * y) :=
rfl
theorem cpow_def_of_ne_zero {x : ℂ} (hx : x ≠ 0) (y : ℂ) : x ^ y = exp (log x * y) :=
if_neg hx
@[simp]
theorem cpow_zero (x : ℂ) : x ^ (0 : ℂ) = 1 := by simp [cpow_def]
@[simp]
theorem cpow_eq_zero_iff (x y : ℂ) : x ^ y = 0 ↔ x = 0 ∧ y ≠ 0 := by
simp only [cpow_def]
split_ifs <;> simp [*, exp_ne_zero]
@[simp]
theorem zero_cpow {x : ℂ} (h : x ≠ 0) : (0 : ℂ) ^ x = 0 := by simp [cpow_def, *]
theorem zero_cpow_eq_iff {x : ℂ} {a : ℂ} : (0 : ℂ) ^ x = a ↔ x ≠ 0 ∧ a = 0 ∨ x = 0 ∧ a = 1 := by
constructor
· intro hyp
simp only [cpow_def, eq_self_iff_true, if_true] at hyp
by_cases h : x = 0
· subst h
simp only [if_true, eq_self_iff_true] at hyp
right
exact ⟨rfl, hyp.symm⟩
· rw [if_neg h] at hyp
left
exact ⟨h, hyp.symm⟩
· rintro (⟨h, rfl⟩ | ⟨rfl, rfl⟩)
· exact zero_cpow h
· exact cpow_zero _
theorem eq_zero_cpow_iff {x : ℂ} {a : ℂ} : a = (0 : ℂ) ^ x ↔ x ≠ 0 ∧ a = 0 ∨ x = 0 ∧ a = 1 := by
rw [← zero_cpow_eq_iff, eq_comm]
@[simp]
theorem cpow_one (x : ℂ) : x ^ (1 : ℂ) = x :=
if hx : x = 0 then by simp [hx, cpow_def]
else by rw [cpow_def, if_neg (one_ne_zero : (1 : ℂ) ≠ 0), if_neg hx, mul_one, exp_log hx]
@[simp]
theorem one_cpow (x : ℂ) : (1 : ℂ) ^ x = 1 := by
rw [cpow_def]
split_ifs <;> simp_all [one_ne_zero]
theorem cpow_add {x : ℂ} (y z : ℂ) (hx : x ≠ 0) : x ^ (y + z) = x ^ y * x ^ z := by
simp only [cpow_def, ite_mul, boole_mul, mul_ite, mul_boole]
simp_all [exp_add, mul_add]
theorem cpow_mul {x y : ℂ} (z : ℂ) (h₁ : -π < (log x * y).im) (h₂ : (log x * y).im ≤ π) :
x ^ (y * z) = (x ^ y) ^ z := by
simp only [cpow_def]
split_ifs <;> simp_all [exp_ne_zero, log_exp h₁ h₂, mul_assoc]
theorem cpow_neg (x y : ℂ) : x ^ (-y) = (x ^ y)⁻¹ := by
simp only [cpow_def, neg_eq_zero, mul_neg]
split_ifs <;> simp [exp_neg]
theorem cpow_sub {x : ℂ} (y z : ℂ) (hx : x ≠ 0) : x ^ (y - z) = x ^ y / x ^ z := by
rw [sub_eq_add_neg, cpow_add _ _ hx, cpow_neg, div_eq_mul_inv]
theorem cpow_neg_one (x : ℂ) : x ^ (-1 : ℂ) = x⁻¹ := by simpa using cpow_neg x 1
/-- See also `Complex.cpow_int_mul'`. -/
lemma cpow_int_mul (x : ℂ) (n : ℤ) (y : ℂ) : x ^ (n * y) = (x ^ y) ^ n := by
rcases eq_or_ne x 0 with rfl | hx
· rcases eq_or_ne n 0 with rfl | hn
· simp
· rcases eq_or_ne y 0 with rfl | hy <;> simp [*, zero_zpow]
· rw [cpow_def_of_ne_zero hx, cpow_def_of_ne_zero hx, mul_left_comm, exp_int_mul]
lemma cpow_mul_int (x y : ℂ) (n : ℤ) : x ^ (y * n) = (x ^ y) ^ n := by rw [mul_comm, cpow_int_mul]
lemma cpow_nat_mul (x : ℂ) (n : ℕ) (y : ℂ) : x ^ (n * y) = (x ^ y) ^ n :=
mod_cast cpow_int_mul x n y
/-- See Note [no_index around OfNat.ofNat] -/
lemma cpow_ofNat_mul (x : ℂ) (n : ℕ) [n.AtLeastTwo] (y : ℂ) :
x ^ (no_index (OfNat.ofNat n) * y) = (x ^ y) ^ (OfNat.ofNat n : ℕ) :=
cpow_nat_mul x n y
lemma cpow_mul_nat (x y : ℂ) (n : ℕ) : x ^ (y * n) = (x ^ y) ^ n := by
rw [mul_comm, cpow_nat_mul]
/-- See Note [no_index around OfNat.ofNat] -/
lemma cpow_mul_ofNat (x y : ℂ) (n : ℕ) [n.AtLeastTwo] :
x ^ (y * no_index (OfNat.ofNat n)) = (x ^ y) ^ (OfNat.ofNat n : ℕ) :=
cpow_mul_nat x y n
@[simp, norm_cast]
theorem cpow_natCast (x : ℂ) (n : ℕ) : x ^ (n : ℂ) = x ^ n := by simpa using cpow_nat_mul x n 1
@[deprecated (since := "2024-04-17")]
alias cpow_nat_cast := cpow_natCast
/-- See Note [no_index around OfNat.ofNat] -/
@[simp]
lemma cpow_ofNat (x : ℂ) (n : ℕ) [n.AtLeastTwo] :
x ^ (no_index (OfNat.ofNat n) : ℂ) = x ^ (OfNat.ofNat n : ℕ) :=
cpow_natCast x n
theorem cpow_two (x : ℂ) : x ^ (2 : ℂ) = x ^ (2 : ℕ) := cpow_ofNat x 2
@[simp, norm_cast]
theorem cpow_intCast (x : ℂ) (n : ℤ) : x ^ (n : ℂ) = x ^ n := by simpa using cpow_int_mul x n 1
@[deprecated (since := "2024-04-17")]
alias cpow_int_cast := cpow_intCast
@[simp]
theorem cpow_nat_inv_pow (x : ℂ) {n : ℕ} (hn : n ≠ 0) : (x ^ (n⁻¹ : ℂ)) ^ n = x := by
rw [← cpow_nat_mul, mul_inv_cancel, cpow_one]
assumption_mod_cast
/-- See Note [no_index around OfNat.ofNat] -/
@[simp]
lemma cpow_ofNat_inv_pow (x : ℂ) (n : ℕ) [n.AtLeastTwo] :
(x ^ ((no_index (OfNat.ofNat n) : ℂ)⁻¹)) ^ (no_index (OfNat.ofNat n) : ℕ) = x :=
cpow_nat_inv_pow _ (NeZero.ne n)
/-- A version of `Complex.cpow_int_mul` with RHS that matches `Complex.cpow_mul`.
The assumptions on the arguments are needed
because the equality fails, e.g., for `x = -I`, `n = 2`, `y = 1/2`. -/
lemma cpow_int_mul' {x : ℂ} {n : ℤ} (hlt : -π < n * x.arg) (hle : n * x.arg ≤ π) (y : ℂ) :
x ^ (n * y) = (x ^ n) ^ y := by
rw [mul_comm] at hlt hle
rw [cpow_mul, cpow_intCast] <;> simpa [log_im]
/-- A version of `Complex.cpow_nat_mul` with RHS that matches `Complex.cpow_mul`.
The assumptions on the arguments are needed
because the equality fails, e.g., for `x = -I`, `n = 2`, `y = 1/2`. -/
lemma cpow_nat_mul' {x : ℂ} {n : ℕ} (hlt : -π < n * x.arg) (hle : n * x.arg ≤ π) (y : ℂ) :
x ^ (n * y) = (x ^ n) ^ y :=
cpow_int_mul' hlt hle y
lemma cpow_ofNat_mul' {x : ℂ} {n : ℕ} [n.AtLeastTwo] (hlt : -π < OfNat.ofNat n * x.arg)
(hle : OfNat.ofNat n * x.arg ≤ π) (y : ℂ) :
x ^ (OfNat.ofNat n * y) = (x ^ (OfNat.ofNat n : ℕ)) ^ y :=
cpow_nat_mul' hlt hle y
lemma pow_cpow_nat_inv {x : ℂ} {n : ℕ} (h₀ : n ≠ 0) (hlt : -(π / n) < x.arg) (hle : x.arg ≤ π / n) :
(x ^ n) ^ (n⁻¹ : ℂ) = x := by
rw [← cpow_nat_mul', mul_inv_cancel (Nat.cast_ne_zero.2 h₀), cpow_one]
· rwa [← div_lt_iff' (Nat.cast_pos.2 h₀.bot_lt), neg_div]
· rwa [← le_div_iff' (Nat.cast_pos.2 h₀.bot_lt)]
lemma pow_cpow_ofNat_inv {x : ℂ} {n : ℕ} [n.AtLeastTwo] (hlt : -(π / OfNat.ofNat n) < x.arg)
(hle : x.arg ≤ π / OfNat.ofNat n) :
(x ^ (OfNat.ofNat n : ℕ)) ^ ((OfNat.ofNat n : ℂ)⁻¹) = x :=
pow_cpow_nat_inv (NeZero.ne n) hlt hle
/-- See also `Complex.pow_cpow_ofNat_inv` for a version that also works for `x * I`, `0 ≤ x`. -/
lemma sq_cpow_two_inv {x : ℂ} (hx : 0 < x.re) : (x ^ (2 : ℕ)) ^ (2⁻¹ : ℂ) = x :=
pow_cpow_ofNat_inv (neg_pi_div_two_lt_arg_iff.2 <| .inl hx)
(arg_le_pi_div_two_iff.2 <| .inl hx.le)
theorem mul_cpow_ofReal_nonneg {a b : ℝ} (ha : 0 ≤ a) (hb : 0 ≤ b) (r : ℂ) :
((a : ℂ) * (b : ℂ)) ^ r = (a : ℂ) ^ r * (b : ℂ) ^ r := by
rcases eq_or_ne r 0 with (rfl | hr)
· simp only [cpow_zero, mul_one]
rcases eq_or_lt_of_le ha with (rfl | ha')
· rw [ofReal_zero, zero_mul, zero_cpow hr, zero_mul]
rcases eq_or_lt_of_le hb with (rfl | hb')
· rw [ofReal_zero, mul_zero, zero_cpow hr, mul_zero]
have ha'' : (a : ℂ) ≠ 0 := ofReal_ne_zero.mpr ha'.ne'
have hb'' : (b : ℂ) ≠ 0 := ofReal_ne_zero.mpr hb'.ne'
rw [cpow_def_of_ne_zero (mul_ne_zero ha'' hb''), log_ofReal_mul ha' hb'', ofReal_log ha,
add_mul, exp_add, ← cpow_def_of_ne_zero ha'', ← cpow_def_of_ne_zero hb'']
lemma natCast_mul_natCast_cpow (m n : ℕ) (s : ℂ) : (m * n : ℂ) ^ s = m ^ s * n ^ s :=
ofReal_natCast m ▸ ofReal_natCast n ▸ mul_cpow_ofReal_nonneg m.cast_nonneg n.cast_nonneg s
lemma natCast_cpow_natCast_mul (n m : ℕ) (z : ℂ) : (n : ℂ) ^ (m * z) = ((n : ℂ) ^ m) ^ z := by
refine cpow_nat_mul' (x := n) (n := m) ?_ ?_ z
· simp only [natCast_arg, mul_zero, Left.neg_neg_iff, pi_pos]
· simp only [natCast_arg, mul_zero, pi_pos.le]
theorem inv_cpow_eq_ite (x : ℂ) (n : ℂ) :
x⁻¹ ^ n = if x.arg = π then conj (x ^ conj n)⁻¹ else (x ^ n)⁻¹ := by
simp_rw [Complex.cpow_def, log_inv_eq_ite, inv_eq_zero, map_eq_zero, ite_mul, neg_mul,
RCLike.conj_inv, apply_ite conj, apply_ite exp, apply_ite Inv.inv, map_zero, map_one, exp_neg,
inv_one, inv_zero, ← exp_conj, map_mul, conj_conj]
split_ifs with hx hn ha ha <;> rfl
theorem inv_cpow (x : ℂ) (n : ℂ) (hx : x.arg ≠ π) : x⁻¹ ^ n = (x ^ n)⁻¹ := by
rw [inv_cpow_eq_ite, if_neg hx]
/-- `Complex.inv_cpow_eq_ite` with the `ite` on the other side. -/
theorem inv_cpow_eq_ite' (x : ℂ) (n : ℂ) :
(x ^ n)⁻¹ = if x.arg = π then conj (x⁻¹ ^ conj n) else x⁻¹ ^ n := by
rw [inv_cpow_eq_ite, apply_ite conj, conj_conj, conj_conj]
split_ifs with h
· rfl
· rw [inv_cpow _ _ h]
theorem conj_cpow_eq_ite (x : ℂ) (n : ℂ) :
conj x ^ n = if x.arg = π then x ^ n else conj (x ^ conj n) := by
simp_rw [cpow_def, map_eq_zero, apply_ite conj, map_one, map_zero, ← exp_conj, map_mul, conj_conj,
log_conj_eq_ite]
split_ifs with hcx hn hx <;> rfl
theorem conj_cpow (x : ℂ) (n : ℂ) (hx : x.arg ≠ π) : conj x ^ n = conj (x ^ conj n) := by
rw [conj_cpow_eq_ite, if_neg hx]
theorem cpow_conj (x : ℂ) (n : ℂ) (hx : x.arg ≠ π) : x ^ conj n = conj (conj x ^ n) := by
rw [conj_cpow _ _ hx, conj_conj]
end Complex
-- section Tactics
-- /-!
-- ## Tactic extensions for complex powers
-- -/
-- namespace NormNum
-- theorem cpow_pos (a b : ℂ) (b' : ℕ) (c : ℂ) (hb : b = b') (h : a ^ b' = c) : a ^ b = c := by
-- rw [← h, hb, Complex.cpow_natCast]
-- theorem cpow_neg (a b : ℂ) (b' : ℕ) (c c' : ℂ) (hb : b = b') (h : a ^ b' = c) (hc : c⁻¹ = c') :
-- a ^ (-b) = c' := by rw [← hc, ← h, hb, Complex.cpow_neg, Complex.cpow_natCast]
-- open Tactic
-- /-- Generalized version of `prove_cpow`, `prove_nnrpow`, `prove_ennrpow`. -/
-- unsafe def prove_rpow' (pos neg zero : Name) (α β one a b : expr) : tactic (expr × expr) := do
-- let na ← a.to_rat
-- let icα ← mk_instance_cache α
-- let icβ ← mk_instance_cache β
-- match match_sign b with
-- | Sum.inl b => do
-- let nc ← mk_instance_cache q(ℕ)
-- let (icβ, nc, b', hb) ← prove_nat_uncast icβ nc b
-- let (icα, c, h) ← prove_pow a na icα b'
-- let cr ← c
-- let (icα, c', hc) ← prove_inv icα c cr
-- pure (c', (expr.const neg []).mk_app [a, b, b', c, c', hb, h, hc])
-- | Sum.inr ff => pure (one, expr.const zero [] a)
-- | Sum.inr tt => do
-- let nc ← mk_instance_cache q(ℕ)
-- let (icβ, nc, b', hb) ← prove_nat_uncast icβ nc b
-- let (icα, c, h) ← prove_pow a na icα b'
-- pure (c, (expr.const Pos []).mk_app [a, b, b', c, hb, h])
-- /-- Evaluate `Complex.cpow a b` where `a` is a rational numeral and `b` is an integer. -/
-- unsafe def prove_cpow : expr → expr → tactic (expr × expr) :=
-- prove_rpow' `` cpow_pos `` cpow_neg `` Complex.cpow_zero q(ℂ) q(ℂ) q((1 : ℂ))
-- /-- Evaluates expressions of the form `cpow a b` and `a ^ b` in the special case where
-- `b` is an integer and `a` is a positive rational (so it's really just a rational power). -/
-- @[norm_num]
-- unsafe def eval_cpow : expr → tactic (expr × expr)
-- | q(@Pow.pow _ _ Complex.hasPow $(a) $(b)) => b.to_int >> prove_cpow a b
-- | q(Complex.cpow $(a) $(b)) => b.to_int >> prove_cpow a b
-- | _ => tactic.failed
-- end NormNum
-- end Tactics
|
Analysis\SpecialFunctions\Pow\Continuity.lean | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Sébastien Gouëzel,
Rémy Degenne, David Loeffler
-/
import Mathlib.Analysis.SpecialFunctions.Pow.Asymptotics
/-!
# Continuity of power functions
This file contains lemmas about continuity of the power functions on `ℂ`, `ℝ`, `ℝ≥0`, and `ℝ≥0∞`.
-/
noncomputable section
open scoped Classical
open Real Topology NNReal ENNReal Filter ComplexConjugate
open Filter Finset Set
section CpowLimits
/-!
## Continuity for complex powers
-/
open Complex
variable {α : Type*}
theorem zero_cpow_eq_nhds {b : ℂ} (hb : b ≠ 0) : (fun x : ℂ => (0 : ℂ) ^ x) =ᶠ[𝓝 b] 0 := by
suffices ∀ᶠ x : ℂ in 𝓝 b, x ≠ 0 from
this.mono fun x hx ↦ by
dsimp only
rw [zero_cpow hx, Pi.zero_apply]
exact IsOpen.eventually_mem isOpen_ne hb
theorem cpow_eq_nhds {a b : ℂ} (ha : a ≠ 0) :
(fun x => x ^ b) =ᶠ[𝓝 a] fun x => exp (log x * b) := by
suffices ∀ᶠ x : ℂ in 𝓝 a, x ≠ 0 from
this.mono fun x hx ↦ by
dsimp only
rw [cpow_def_of_ne_zero hx]
exact IsOpen.eventually_mem isOpen_ne ha
theorem cpow_eq_nhds' {p : ℂ × ℂ} (hp_fst : p.fst ≠ 0) :
(fun x => x.1 ^ x.2) =ᶠ[𝓝 p] fun x => exp (log x.1 * x.2) := by
suffices ∀ᶠ x : ℂ × ℂ in 𝓝 p, x.1 ≠ 0 from
this.mono fun x hx ↦ by
dsimp only
rw [cpow_def_of_ne_zero hx]
refine IsOpen.eventually_mem ?_ hp_fst
change IsOpen { x : ℂ × ℂ | x.1 = 0 }ᶜ
rw [isOpen_compl_iff]
exact isClosed_eq continuous_fst continuous_const
-- Continuity of `fun x => a ^ x`: union of these two lemmas is optimal.
theorem continuousAt_const_cpow {a b : ℂ} (ha : a ≠ 0) : ContinuousAt (fun x : ℂ => a ^ x) b := by
have cpow_eq : (fun x : ℂ => a ^ x) = fun x => exp (log a * x) := by
ext1 b
rw [cpow_def_of_ne_zero ha]
rw [cpow_eq]
exact continuous_exp.continuousAt.comp (ContinuousAt.mul continuousAt_const continuousAt_id)
theorem continuousAt_const_cpow' {a b : ℂ} (h : b ≠ 0) : ContinuousAt (fun x : ℂ => a ^ x) b := by
by_cases ha : a = 0
· rw [ha, continuousAt_congr (zero_cpow_eq_nhds h)]
exact continuousAt_const
· exact continuousAt_const_cpow ha
/-- The function `z ^ w` is continuous in `(z, w)` provided that `z` does not belong to the interval
`(-∞, 0]` on the real line. See also `Complex.continuousAt_cpow_zero_of_re_pos` for a version that
works for `z = 0` but assumes `0 < re w`. -/
theorem continuousAt_cpow {p : ℂ × ℂ} (hp_fst : p.fst ∈ slitPlane) :
ContinuousAt (fun x : ℂ × ℂ => x.1 ^ x.2) p := by
rw [continuousAt_congr (cpow_eq_nhds' <| slitPlane_ne_zero hp_fst)]
refine continuous_exp.continuousAt.comp ?_
exact
ContinuousAt.mul
(ContinuousAt.comp (continuousAt_clog hp_fst) continuous_fst.continuousAt)
continuous_snd.continuousAt
theorem continuousAt_cpow_const {a b : ℂ} (ha : a ∈ slitPlane) :
ContinuousAt (· ^ b) a :=
Tendsto.comp (@continuousAt_cpow (a, b) ha) (continuousAt_id.prod continuousAt_const)
theorem Filter.Tendsto.cpow {l : Filter α} {f g : α → ℂ} {a b : ℂ} (hf : Tendsto f l (𝓝 a))
(hg : Tendsto g l (𝓝 b)) (ha : a ∈ slitPlane) :
Tendsto (fun x => f x ^ g x) l (𝓝 (a ^ b)) :=
(@continuousAt_cpow (a, b) ha).tendsto.comp (hf.prod_mk_nhds hg)
theorem Filter.Tendsto.const_cpow {l : Filter α} {f : α → ℂ} {a b : ℂ} (hf : Tendsto f l (𝓝 b))
(h : a ≠ 0 ∨ b ≠ 0) : Tendsto (fun x => a ^ f x) l (𝓝 (a ^ b)) := by
cases h with
| inl h => exact (continuousAt_const_cpow h).tendsto.comp hf
| inr h => exact (continuousAt_const_cpow' h).tendsto.comp hf
variable [TopologicalSpace α] {f g : α → ℂ} {s : Set α} {a : α}
nonrec theorem ContinuousWithinAt.cpow (hf : ContinuousWithinAt f s a)
(hg : ContinuousWithinAt g s a) (h0 : f a ∈ slitPlane) :
ContinuousWithinAt (fun x => f x ^ g x) s a :=
hf.cpow hg h0
nonrec theorem ContinuousWithinAt.const_cpow {b : ℂ} (hf : ContinuousWithinAt f s a)
(h : b ≠ 0 ∨ f a ≠ 0) : ContinuousWithinAt (fun x => b ^ f x) s a :=
hf.const_cpow h
nonrec theorem ContinuousAt.cpow (hf : ContinuousAt f a) (hg : ContinuousAt g a)
(h0 : f a ∈ slitPlane) : ContinuousAt (fun x => f x ^ g x) a :=
hf.cpow hg h0
nonrec theorem ContinuousAt.const_cpow {b : ℂ} (hf : ContinuousAt f a) (h : b ≠ 0 ∨ f a ≠ 0) :
ContinuousAt (fun x => b ^ f x) a :=
hf.const_cpow h
theorem ContinuousOn.cpow (hf : ContinuousOn f s) (hg : ContinuousOn g s)
(h0 : ∀ a ∈ s, f a ∈ slitPlane) : ContinuousOn (fun x => f x ^ g x) s := fun a ha =>
(hf a ha).cpow (hg a ha) (h0 a ha)
theorem ContinuousOn.const_cpow {b : ℂ} (hf : ContinuousOn f s) (h : b ≠ 0 ∨ ∀ a ∈ s, f a ≠ 0) :
ContinuousOn (fun x => b ^ f x) s := fun a ha => (hf a ha).const_cpow (h.imp id fun h => h a ha)
theorem Continuous.cpow (hf : Continuous f) (hg : Continuous g)
(h0 : ∀ a, f a ∈ slitPlane) : Continuous fun x => f x ^ g x :=
continuous_iff_continuousAt.2 fun a => hf.continuousAt.cpow hg.continuousAt (h0 a)
theorem Continuous.const_cpow {b : ℂ} (hf : Continuous f) (h : b ≠ 0 ∨ ∀ a, f a ≠ 0) :
Continuous fun x => b ^ f x :=
continuous_iff_continuousAt.2 fun a => hf.continuousAt.const_cpow <| h.imp id fun h => h a
theorem ContinuousOn.cpow_const {b : ℂ} (hf : ContinuousOn f s)
(h : ∀ a : α, a ∈ s → f a ∈ slitPlane) : ContinuousOn (fun x => f x ^ b) s :=
hf.cpow continuousOn_const h
end CpowLimits
section RpowLimits
/-!
## Continuity for real powers
-/
namespace Real
theorem continuousAt_const_rpow {a b : ℝ} (h : a ≠ 0) : ContinuousAt (a ^ ·) b := by
simp only [rpow_def]
refine Complex.continuous_re.continuousAt.comp ?_
refine (continuousAt_const_cpow ?_).comp Complex.continuous_ofReal.continuousAt
norm_cast
theorem continuousAt_const_rpow' {a b : ℝ} (h : b ≠ 0) : ContinuousAt (a ^ ·) b := by
simp only [rpow_def]
refine Complex.continuous_re.continuousAt.comp ?_
refine (continuousAt_const_cpow' ?_).comp Complex.continuous_ofReal.continuousAt
norm_cast
theorem rpow_eq_nhds_of_neg {p : ℝ × ℝ} (hp_fst : p.fst < 0) :
(fun x : ℝ × ℝ => x.1 ^ x.2) =ᶠ[𝓝 p] fun x => exp (log x.1 * x.2) * cos (x.2 * π) := by
suffices ∀ᶠ x : ℝ × ℝ in 𝓝 p, x.1 < 0 from
this.mono fun x hx ↦ by
dsimp only
rw [rpow_def_of_neg hx]
exact IsOpen.eventually_mem (isOpen_lt continuous_fst continuous_const) hp_fst
theorem rpow_eq_nhds_of_pos {p : ℝ × ℝ} (hp_fst : 0 < p.fst) :
(fun x : ℝ × ℝ => x.1 ^ x.2) =ᶠ[𝓝 p] fun x => exp (log x.1 * x.2) := by
suffices ∀ᶠ x : ℝ × ℝ in 𝓝 p, 0 < x.1 from
this.mono fun x hx ↦ by
dsimp only
rw [rpow_def_of_pos hx]
exact IsOpen.eventually_mem (isOpen_lt continuous_const continuous_fst) hp_fst
theorem continuousAt_rpow_of_ne (p : ℝ × ℝ) (hp : p.1 ≠ 0) :
ContinuousAt (fun p : ℝ × ℝ => p.1 ^ p.2) p := by
rw [ne_iff_lt_or_gt] at hp
cases hp with
| inl hp =>
rw [continuousAt_congr (rpow_eq_nhds_of_neg hp)]
refine ContinuousAt.mul ?_ (continuous_cos.continuousAt.comp ?_)
· refine continuous_exp.continuousAt.comp (ContinuousAt.mul ?_ continuous_snd.continuousAt)
refine (continuousAt_log ?_).comp continuous_fst.continuousAt
exact hp.ne
· exact continuous_snd.continuousAt.mul continuousAt_const
| inr hp =>
rw [continuousAt_congr (rpow_eq_nhds_of_pos hp)]
refine continuous_exp.continuousAt.comp (ContinuousAt.mul ?_ continuous_snd.continuousAt)
refine (continuousAt_log ?_).comp continuous_fst.continuousAt
exact hp.lt.ne.symm
theorem continuousAt_rpow_of_pos (p : ℝ × ℝ) (hp : 0 < p.2) :
ContinuousAt (fun p : ℝ × ℝ => p.1 ^ p.2) p := by
cases' p with x y
dsimp only at hp
obtain hx | rfl := ne_or_eq x 0
· exact continuousAt_rpow_of_ne (x, y) hx
have A : Tendsto (fun p : ℝ × ℝ => exp (log p.1 * p.2)) (𝓝[≠] 0 ×ˢ 𝓝 y) (𝓝 0) :=
tendsto_exp_atBot.comp
((tendsto_log_nhdsWithin_zero.comp tendsto_fst).atBot_mul hp tendsto_snd)
have B : Tendsto (fun p : ℝ × ℝ => p.1 ^ p.2) (𝓝[≠] 0 ×ˢ 𝓝 y) (𝓝 0) :=
squeeze_zero_norm (fun p => abs_rpow_le_exp_log_mul p.1 p.2) A
have C : Tendsto (fun p : ℝ × ℝ => p.1 ^ p.2) (𝓝[{0}] 0 ×ˢ 𝓝 y) (pure 0) := by
rw [nhdsWithin_singleton, tendsto_pure, pure_prod, eventually_map]
exact (lt_mem_nhds hp).mono fun y hy => zero_rpow hy.ne'
simpa only [← sup_prod, ← nhdsWithin_union, compl_union_self, nhdsWithin_univ, nhds_prod_eq,
ContinuousAt, zero_rpow hp.ne'] using B.sup (C.mono_right (pure_le_nhds _))
theorem continuousAt_rpow (p : ℝ × ℝ) (h : p.1 ≠ 0 ∨ 0 < p.2) :
ContinuousAt (fun p : ℝ × ℝ => p.1 ^ p.2) p :=
h.elim (fun h => continuousAt_rpow_of_ne p h) fun h => continuousAt_rpow_of_pos p h
@[fun_prop]
theorem continuousAt_rpow_const (x : ℝ) (q : ℝ) (h : x ≠ 0 ∨ 0 ≤ q) :
ContinuousAt (fun x : ℝ => x ^ q) x := by
· rw [le_iff_lt_or_eq, ← or_assoc] at h
obtain h|rfl := h
· exact (continuousAt_rpow (x, q) h).comp₂ continuousAt_id continuousAt_const
· simp_rw [rpow_zero]; exact continuousAt_const
@[fun_prop]
theorem continuous_rpow_const {q : ℝ} (h : 0 ≤ q) : Continuous (fun x : ℝ => x ^ q) :=
continuous_iff_continuousAt.mpr fun x ↦ continuousAt_rpow_const x q (.inr h)
end Real
section
variable {α : Type*}
theorem Filter.Tendsto.rpow {l : Filter α} {f g : α → ℝ} {x y : ℝ} (hf : Tendsto f l (𝓝 x))
(hg : Tendsto g l (𝓝 y)) (h : x ≠ 0 ∨ 0 < y) : Tendsto (fun t => f t ^ g t) l (𝓝 (x ^ y)) :=
(Real.continuousAt_rpow (x, y) h).tendsto.comp (hf.prod_mk_nhds hg)
theorem Filter.Tendsto.rpow_const {l : Filter α} {f : α → ℝ} {x p : ℝ} (hf : Tendsto f l (𝓝 x))
(h : x ≠ 0 ∨ 0 ≤ p) : Tendsto (fun a => f a ^ p) l (𝓝 (x ^ p)) :=
if h0 : 0 = p then h0 ▸ by simp [tendsto_const_nhds]
else hf.rpow tendsto_const_nhds (h.imp id fun h' => h'.lt_of_ne h0)
variable [TopologicalSpace α] {f g : α → ℝ} {s : Set α} {x : α} {p : ℝ}
nonrec theorem ContinuousAt.rpow (hf : ContinuousAt f x) (hg : ContinuousAt g x)
(h : f x ≠ 0 ∨ 0 < g x) : ContinuousAt (fun t => f t ^ g t) x :=
hf.rpow hg h
nonrec theorem ContinuousWithinAt.rpow (hf : ContinuousWithinAt f s x)
(hg : ContinuousWithinAt g s x) (h : f x ≠ 0 ∨ 0 < g x) :
ContinuousWithinAt (fun t => f t ^ g t) s x :=
hf.rpow hg h
theorem ContinuousOn.rpow (hf : ContinuousOn f s) (hg : ContinuousOn g s)
(h : ∀ x ∈ s, f x ≠ 0 ∨ 0 < g x) : ContinuousOn (fun t => f t ^ g t) s := fun t ht =>
(hf t ht).rpow (hg t ht) (h t ht)
theorem Continuous.rpow (hf : Continuous f) (hg : Continuous g) (h : ∀ x, f x ≠ 0 ∨ 0 < g x) :
Continuous fun x => f x ^ g x :=
continuous_iff_continuousAt.2 fun x => hf.continuousAt.rpow hg.continuousAt (h x)
nonrec theorem ContinuousWithinAt.rpow_const (hf : ContinuousWithinAt f s x) (h : f x ≠ 0 ∨ 0 ≤ p) :
ContinuousWithinAt (fun x => f x ^ p) s x :=
hf.rpow_const h
nonrec theorem ContinuousAt.rpow_const (hf : ContinuousAt f x) (h : f x ≠ 0 ∨ 0 ≤ p) :
ContinuousAt (fun x => f x ^ p) x :=
hf.rpow_const h
theorem ContinuousOn.rpow_const (hf : ContinuousOn f s) (h : ∀ x ∈ s, f x ≠ 0 ∨ 0 ≤ p) :
ContinuousOn (fun x => f x ^ p) s := fun x hx => (hf x hx).rpow_const (h x hx)
theorem Continuous.rpow_const (hf : Continuous f) (h : ∀ x, f x ≠ 0 ∨ 0 ≤ p) :
Continuous fun x => f x ^ p :=
continuous_iff_continuousAt.2 fun x => hf.continuousAt.rpow_const (h x)
end
end RpowLimits
/-! ## Continuity results for `cpow`, part II
These results involve relating real and complex powers, so cannot be done higher up.
-/
section CpowLimits2
namespace Complex
/-- See also `continuousAt_cpow` and `Complex.continuousAt_cpow_of_re_pos`. -/
theorem continuousAt_cpow_zero_of_re_pos {z : ℂ} (hz : 0 < z.re) :
ContinuousAt (fun x : ℂ × ℂ => x.1 ^ x.2) (0, z) := by
have hz₀ : z ≠ 0 := ne_of_apply_ne re hz.ne'
rw [ContinuousAt, zero_cpow hz₀, tendsto_zero_iff_norm_tendsto_zero]
refine squeeze_zero (fun _ => norm_nonneg _) (fun _ => abs_cpow_le _ _) ?_
simp only [div_eq_mul_inv, ← Real.exp_neg]
refine Tendsto.zero_mul_isBoundedUnder_le ?_ ?_
· convert
(continuous_fst.norm.tendsto ((0 : ℂ), z)).rpow
((continuous_re.comp continuous_snd).tendsto _) _ <;>
simp [hz, Real.zero_rpow hz.ne']
· simp only [Function.comp, Real.norm_eq_abs, abs_of_pos (Real.exp_pos _)]
rcases exists_gt |im z| with ⟨C, hC⟩
refine ⟨Real.exp (π * C), eventually_map.2 ?_⟩
refine
(((continuous_im.comp continuous_snd).abs.tendsto (_, z)).eventually (gt_mem_nhds hC)).mono
fun z hz => Real.exp_le_exp.2 <| (neg_le_abs _).trans ?_
rw [_root_.abs_mul]
exact
mul_le_mul (abs_le.2 ⟨(neg_pi_lt_arg _).le, arg_le_pi _⟩) hz.le (_root_.abs_nonneg _)
Real.pi_pos.le
open ComplexOrder in
/-- See also `continuousAt_cpow` for a version that assumes `p.1 ≠ 0` but makes no
assumptions about `p.2`. -/
theorem continuousAt_cpow_of_re_pos {p : ℂ × ℂ} (h₁ : 0 ≤ p.1.re ∨ p.1.im ≠ 0) (h₂ : 0 < p.2.re) :
ContinuousAt (fun x : ℂ × ℂ => x.1 ^ x.2) p := by
cases' p with z w
rw [← not_lt_zero_iff, lt_iff_le_and_ne, not_and_or, Ne, Classical.not_not,
not_le_zero_iff] at h₁
rcases h₁ with (h₁ | (rfl : z = 0))
exacts [continuousAt_cpow h₁, continuousAt_cpow_zero_of_re_pos h₂]
/-- See also `continuousAt_cpow_const` for a version that assumes `z ≠ 0` but makes no
assumptions about `w`. -/
theorem continuousAt_cpow_const_of_re_pos {z w : ℂ} (hz : 0 ≤ re z ∨ im z ≠ 0) (hw : 0 < re w) :
ContinuousAt (fun x => x ^ w) z :=
Tendsto.comp (@continuousAt_cpow_of_re_pos (z, w) hz hw) (continuousAt_id.prod continuousAt_const)
/-- Continuity of `(x, y) ↦ x ^ y` as a function on `ℝ × ℂ`. -/
theorem continuousAt_ofReal_cpow (x : ℝ) (y : ℂ) (h : 0 < y.re ∨ x ≠ 0) :
ContinuousAt (fun p => (p.1 : ℂ) ^ p.2 : ℝ × ℂ → ℂ) (x, y) := by
rcases lt_trichotomy (0 : ℝ) x with (hx | rfl | hx)
· -- x > 0 : easy case
have : ContinuousAt (fun p => ⟨↑p.1, p.2⟩ : ℝ × ℂ → ℂ × ℂ) (x, y) :=
continuous_ofReal.continuousAt.prod_map continuousAt_id
refine (continuousAt_cpow (Or.inl ?_)).comp this
rwa [ofReal_re]
· -- x = 0 : reduce to continuousAt_cpow_zero_of_re_pos
have A : ContinuousAt (fun p => p.1 ^ p.2 : ℂ × ℂ → ℂ) ⟨↑(0 : ℝ), y⟩ := by
rw [ofReal_zero]
apply continuousAt_cpow_zero_of_re_pos
tauto
have B : ContinuousAt (fun p => ⟨↑p.1, p.2⟩ : ℝ × ℂ → ℂ × ℂ) ⟨0, y⟩ :=
continuous_ofReal.continuousAt.prod_map continuousAt_id
exact A.comp_of_eq B rfl
· -- x < 0 : difficult case
suffices ContinuousAt (fun p => (-(p.1 : ℂ)) ^ p.2 * exp (π * I * p.2) : ℝ × ℂ → ℂ) (x, y) by
refine this.congr (eventually_of_mem (prod_mem_nhds (Iio_mem_nhds hx) univ_mem) ?_)
exact fun p hp => (ofReal_cpow_of_nonpos (le_of_lt hp.1) p.2).symm
have A : ContinuousAt (fun p => ⟨-↑p.1, p.2⟩ : ℝ × ℂ → ℂ × ℂ) (x, y) :=
ContinuousAt.prod_map continuous_ofReal.continuousAt.neg continuousAt_id
apply ContinuousAt.mul
· refine (continuousAt_cpow (Or.inl ?_)).comp A
rwa [neg_re, ofReal_re, neg_pos]
· exact (continuous_exp.comp (continuous_const.mul continuous_snd)).continuousAt
theorem continuousAt_ofReal_cpow_const (x : ℝ) (y : ℂ) (h : 0 < y.re ∨ x ≠ 0) :
ContinuousAt (fun a => (a : ℂ) ^ y : ℝ → ℂ) x :=
ContinuousAt.comp (x := x) (continuousAt_ofReal_cpow x y h)
(continuous_id.prod_mk continuous_const).continuousAt
theorem continuous_ofReal_cpow_const {y : ℂ} (hs : 0 < y.re) :
Continuous (fun x => (x : ℂ) ^ y : ℝ → ℂ) :=
continuous_iff_continuousAt.mpr fun x => continuousAt_ofReal_cpow_const x y (Or.inl hs)
end Complex
end CpowLimits2
/-! ## Limits and continuity for `ℝ≥0` powers -/
namespace NNReal
theorem continuousAt_rpow {x : ℝ≥0} {y : ℝ} (h : x ≠ 0 ∨ 0 < y) :
ContinuousAt (fun p : ℝ≥0 × ℝ => p.1 ^ p.2) (x, y) := by
have :
(fun p : ℝ≥0 × ℝ => p.1 ^ p.2) =
Real.toNNReal ∘ (fun p : ℝ × ℝ => p.1 ^ p.2) ∘ fun p : ℝ≥0 × ℝ => (p.1.1, p.2) := by
ext p
erw [coe_rpow, Real.coe_toNNReal _ (Real.rpow_nonneg p.1.2 _)]
rfl
rw [this]
refine continuous_real_toNNReal.continuousAt.comp (ContinuousAt.comp ?_ ?_)
· apply Real.continuousAt_rpow
simpa using h
· exact ((continuous_subtype_val.comp continuous_fst).prod_mk continuous_snd).continuousAt
theorem eventually_pow_one_div_le (x : ℝ≥0) {y : ℝ≥0} (hy : 1 < y) :
∀ᶠ n : ℕ in atTop, x ^ (1 / n : ℝ) ≤ y := by
obtain ⟨m, hm⟩ := add_one_pow_unbounded_of_pos x (tsub_pos_of_lt hy)
rw [tsub_add_cancel_of_le hy.le] at hm
refine eventually_atTop.2 ⟨m + 1, fun n hn => ?_⟩
simp only [one_div]
simpa only [NNReal.rpow_inv_le_iff (Nat.cast_pos.2 <| m.succ_pos.trans_le hn),
NNReal.rpow_natCast] using hm.le.trans (pow_le_pow_right hy.le (m.le_succ.trans hn))
end NNReal
open Filter
theorem Filter.Tendsto.nnrpow {α : Type*} {f : Filter α} {u : α → ℝ≥0} {v : α → ℝ} {x : ℝ≥0}
{y : ℝ} (hx : Tendsto u f (𝓝 x)) (hy : Tendsto v f (𝓝 y)) (h : x ≠ 0 ∨ 0 < y) :
Tendsto (fun a => u a ^ v a) f (𝓝 (x ^ y)) :=
Tendsto.comp (NNReal.continuousAt_rpow h) (hx.prod_mk_nhds hy)
namespace NNReal
theorem continuousAt_rpow_const {x : ℝ≥0} {y : ℝ} (h : x ≠ 0 ∨ 0 ≤ y) :
ContinuousAt (fun z => z ^ y) x :=
h.elim (fun h => tendsto_id.nnrpow tendsto_const_nhds (Or.inl h)) fun h =>
h.eq_or_lt.elim (fun h => h ▸ by simp only [rpow_zero, continuousAt_const]) fun h =>
tendsto_id.nnrpow tendsto_const_nhds (Or.inr h)
@[fun_prop]
theorem continuous_rpow_const {y : ℝ} (h : 0 ≤ y) : Continuous fun x : ℝ≥0 => x ^ y :=
continuous_iff_continuousAt.2 fun _ => continuousAt_rpow_const (Or.inr h)
end NNReal
/-! ## Continuity for `ℝ≥0∞` powers -/
namespace ENNReal
theorem eventually_pow_one_div_le {x : ℝ≥0∞} (hx : x ≠ ∞) {y : ℝ≥0∞} (hy : 1 < y) :
∀ᶠ n : ℕ in atTop, x ^ (1 / n : ℝ) ≤ y := by
lift x to ℝ≥0 using hx
by_cases h : y = ∞
· exact eventually_of_forall fun n => h.symm ▸ le_top
· lift y to ℝ≥0 using h
have := NNReal.eventually_pow_one_div_le x (mod_cast hy : 1 < y)
refine this.congr (eventually_of_forall fun n => ?_)
rw [coe_rpow_of_nonneg x (by positivity : 0 ≤ (1 / n : ℝ)), coe_le_coe]
private theorem continuousAt_rpow_const_of_pos {x : ℝ≥0∞} {y : ℝ} (h : 0 < y) :
ContinuousAt (fun a : ℝ≥0∞ => a ^ y) x := by
by_cases hx : x = ⊤
· rw [hx, ContinuousAt]
convert ENNReal.tendsto_rpow_at_top h
simp [h]
lift x to ℝ≥0 using hx
rw [continuousAt_coe_iff]
convert continuous_coe.continuousAt.comp (NNReal.continuousAt_rpow_const (Or.inr h.le)) using 1
ext1 x
simp [coe_rpow_of_nonneg _ h.le]
@[continuity, fun_prop]
theorem continuous_rpow_const {y : ℝ} : Continuous fun a : ℝ≥0∞ => a ^ y := by
refine continuous_iff_continuousAt.2 fun x => ?_
rcases lt_trichotomy (0 : ℝ) y with (hy | rfl | hy)
· exact continuousAt_rpow_const_of_pos hy
· simp only [rpow_zero]
exact continuousAt_const
· obtain ⟨z, hz⟩ : ∃ z, y = -z := ⟨-y, (neg_neg _).symm⟩
have z_pos : 0 < z := by simpa [hz] using hy
simp_rw [hz, rpow_neg]
exact continuous_inv.continuousAt.comp (continuousAt_rpow_const_of_pos z_pos)
theorem tendsto_const_mul_rpow_nhds_zero_of_pos {c : ℝ≥0∞} (hc : c ≠ ∞) {y : ℝ} (hy : 0 < y) :
Tendsto (fun x : ℝ≥0∞ => c * x ^ y) (𝓝 0) (𝓝 0) := by
convert ENNReal.Tendsto.const_mul (ENNReal.continuous_rpow_const.tendsto 0) _
· simp [hy]
· exact Or.inr hc
end ENNReal
theorem Filter.Tendsto.ennrpow_const {α : Type*} {f : Filter α} {m : α → ℝ≥0∞} {a : ℝ≥0∞} (r : ℝ)
(hm : Tendsto m f (𝓝 a)) : Tendsto (fun x => m x ^ r) f (𝓝 (a ^ r)) :=
(ENNReal.continuous_rpow_const.tendsto a).comp hm
|
Analysis\SpecialFunctions\Pow\Deriv.lean | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Sébastien Gouëzel,
Rémy Degenne
-/
import Mathlib.Analysis.SpecialFunctions.Pow.Continuity
import Mathlib.Analysis.SpecialFunctions.Complex.LogDeriv
import Mathlib.Analysis.Calculus.FDeriv.Extend
import Mathlib.Analysis.Calculus.Deriv.Prod
import Mathlib.Analysis.SpecialFunctions.Log.Deriv
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Deriv
/-!
# Derivatives of power function on `ℂ`, `ℝ`, `ℝ≥0`, and `ℝ≥0∞`
We also prove differentiability and provide derivatives for the power functions `x ^ y`.
-/
noncomputable section
open scoped Real Topology NNReal ENNReal
open Filter
namespace Complex
theorem hasStrictFDerivAt_cpow {p : ℂ × ℂ} (hp : p.1 ∈ slitPlane) :
HasStrictFDerivAt (fun x : ℂ × ℂ => x.1 ^ x.2)
((p.2 * p.1 ^ (p.2 - 1)) • ContinuousLinearMap.fst ℂ ℂ ℂ +
(p.1 ^ p.2 * log p.1) • ContinuousLinearMap.snd ℂ ℂ ℂ) p := by
have A : p.1 ≠ 0 := slitPlane_ne_zero hp
have : (fun x : ℂ × ℂ => x.1 ^ x.2) =ᶠ[𝓝 p] fun x => exp (log x.1 * x.2) :=
((isOpen_ne.preimage continuous_fst).eventually_mem A).mono fun p hp =>
cpow_def_of_ne_zero hp _
rw [cpow_sub _ _ A, cpow_one, mul_div_left_comm, mul_smul, mul_smul]
refine HasStrictFDerivAt.congr_of_eventuallyEq ?_ this.symm
simpa only [cpow_def_of_ne_zero A, div_eq_mul_inv, mul_smul, add_comm, smul_add] using
((hasStrictFDerivAt_fst.clog hp).mul hasStrictFDerivAt_snd).cexp
theorem hasStrictFDerivAt_cpow' {x y : ℂ} (hp : x ∈ slitPlane) :
HasStrictFDerivAt (fun x : ℂ × ℂ => x.1 ^ x.2)
((y * x ^ (y - 1)) • ContinuousLinearMap.fst ℂ ℂ ℂ +
(x ^ y * log x) • ContinuousLinearMap.snd ℂ ℂ ℂ) (x, y) :=
@hasStrictFDerivAt_cpow (x, y) hp
theorem hasStrictDerivAt_const_cpow {x y : ℂ} (h : x ≠ 0 ∨ y ≠ 0) :
HasStrictDerivAt (fun y => x ^ y) (x ^ y * log x) y := by
rcases em (x = 0) with (rfl | hx)
· replace h := h.neg_resolve_left rfl
rw [log_zero, mul_zero]
refine (hasStrictDerivAt_const _ 0).congr_of_eventuallyEq ?_
exact (isOpen_ne.eventually_mem h).mono fun y hy => (zero_cpow hy).symm
· simpa only [cpow_def_of_ne_zero hx, mul_one] using
((hasStrictDerivAt_id y).const_mul (log x)).cexp
theorem hasFDerivAt_cpow {p : ℂ × ℂ} (hp : p.1 ∈ slitPlane) :
HasFDerivAt (fun x : ℂ × ℂ => x.1 ^ x.2)
((p.2 * p.1 ^ (p.2 - 1)) • ContinuousLinearMap.fst ℂ ℂ ℂ +
(p.1 ^ p.2 * log p.1) • ContinuousLinearMap.snd ℂ ℂ ℂ) p :=
(hasStrictFDerivAt_cpow hp).hasFDerivAt
end Complex
section fderiv
open Complex
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℂ E] {f g : E → ℂ} {f' g' : E →L[ℂ] ℂ}
{x : E} {s : Set E} {c : ℂ}
theorem HasStrictFDerivAt.cpow (hf : HasStrictFDerivAt f f' x) (hg : HasStrictFDerivAt g g' x)
(h0 : f x ∈ slitPlane) : HasStrictFDerivAt (fun x => f x ^ g x)
((g x * f x ^ (g x - 1)) • f' + (f x ^ g x * Complex.log (f x)) • g') x := by
convert (@hasStrictFDerivAt_cpow ((fun x => (f x, g x)) x) h0).comp x (hf.prod hg)
theorem HasStrictFDerivAt.const_cpow (hf : HasStrictFDerivAt f f' x) (h0 : c ≠ 0 ∨ f x ≠ 0) :
HasStrictFDerivAt (fun x => c ^ f x) ((c ^ f x * Complex.log c) • f') x :=
(hasStrictDerivAt_const_cpow h0).comp_hasStrictFDerivAt x hf
theorem HasFDerivAt.cpow (hf : HasFDerivAt f f' x) (hg : HasFDerivAt g g' x)
(h0 : f x ∈ slitPlane) : HasFDerivAt (fun x => f x ^ g x)
((g x * f x ^ (g x - 1)) • f' + (f x ^ g x * Complex.log (f x)) • g') x := by
convert (@Complex.hasFDerivAt_cpow ((fun x => (f x, g x)) x) h0).comp x (hf.prod hg)
theorem HasFDerivAt.const_cpow (hf : HasFDerivAt f f' x) (h0 : c ≠ 0 ∨ f x ≠ 0) :
HasFDerivAt (fun x => c ^ f x) ((c ^ f x * Complex.log c) • f') x :=
(hasStrictDerivAt_const_cpow h0).hasDerivAt.comp_hasFDerivAt x hf
theorem HasFDerivWithinAt.cpow (hf : HasFDerivWithinAt f f' s x) (hg : HasFDerivWithinAt g g' s x)
(h0 : f x ∈ slitPlane) : HasFDerivWithinAt (fun x => f x ^ g x)
((g x * f x ^ (g x - 1)) • f' + (f x ^ g x * Complex.log (f x)) • g') s x := by
convert
(@Complex.hasFDerivAt_cpow ((fun x => (f x, g x)) x) h0).comp_hasFDerivWithinAt x (hf.prod hg)
theorem HasFDerivWithinAt.const_cpow (hf : HasFDerivWithinAt f f' s x) (h0 : c ≠ 0 ∨ f x ≠ 0) :
HasFDerivWithinAt (fun x => c ^ f x) ((c ^ f x * Complex.log c) • f') s x :=
(hasStrictDerivAt_const_cpow h0).hasDerivAt.comp_hasFDerivWithinAt x hf
theorem DifferentiableAt.cpow (hf : DifferentiableAt ℂ f x) (hg : DifferentiableAt ℂ g x)
(h0 : f x ∈ slitPlane) : DifferentiableAt ℂ (fun x => f x ^ g x) x :=
(hf.hasFDerivAt.cpow hg.hasFDerivAt h0).differentiableAt
theorem DifferentiableAt.const_cpow (hf : DifferentiableAt ℂ f x) (h0 : c ≠ 0 ∨ f x ≠ 0) :
DifferentiableAt ℂ (fun x => c ^ f x) x :=
(hf.hasFDerivAt.const_cpow h0).differentiableAt
theorem DifferentiableWithinAt.cpow (hf : DifferentiableWithinAt ℂ f s x)
(hg : DifferentiableWithinAt ℂ g s x) (h0 : f x ∈ slitPlane) :
DifferentiableWithinAt ℂ (fun x => f x ^ g x) s x :=
(hf.hasFDerivWithinAt.cpow hg.hasFDerivWithinAt h0).differentiableWithinAt
theorem DifferentiableWithinAt.const_cpow (hf : DifferentiableWithinAt ℂ f s x)
(h0 : c ≠ 0 ∨ f x ≠ 0) : DifferentiableWithinAt ℂ (fun x => c ^ f x) s x :=
(hf.hasFDerivWithinAt.const_cpow h0).differentiableWithinAt
theorem DifferentiableOn.cpow (hf : DifferentiableOn ℂ f s) (hg : DifferentiableOn ℂ g s)
(h0 : Set.MapsTo f s slitPlane) : DifferentiableOn ℂ (fun x ↦ f x ^ g x) s :=
fun x hx ↦ (hf x hx).cpow (hg x hx) (h0 hx)
theorem DifferentiableOn.const_cpow (hf : DifferentiableOn ℂ f s)
(h0 : c ≠ 0 ∨ ∀ x ∈ s, f x ≠ 0) : DifferentiableOn ℂ (fun x ↦ c ^ f x) s :=
fun x hx ↦ (hf x hx).const_cpow (h0.imp_right fun h ↦ h x hx)
theorem Differentiable.cpow (hf : Differentiable ℂ f) (hg : Differentiable ℂ g)
(h0 : ∀ x, f x ∈ slitPlane) : Differentiable ℂ (fun x ↦ f x ^ g x) :=
fun x ↦ (hf x).cpow (hg x) (h0 x)
theorem Differentiable.const_cpow (hf : Differentiable ℂ f)
(h0 : c ≠ 0 ∨ ∀ x, f x ≠ 0) : Differentiable ℂ (fun x ↦ c ^ f x) :=
fun x ↦ (hf x).const_cpow (h0.imp_right fun h ↦ h x)
end fderiv
section deriv
open Complex
variable {f g : ℂ → ℂ} {s : Set ℂ} {f' g' x c : ℂ}
/-- A private lemma that rewrites the output of lemmas like `HasFDerivAt.cpow` to the form
expected by lemmas like `HasDerivAt.cpow`. -/
private theorem aux : ((g x * f x ^ (g x - 1)) • (1 : ℂ →L[ℂ] ℂ).smulRight f' +
(f x ^ g x * log (f x)) • (1 : ℂ →L[ℂ] ℂ).smulRight g') 1 =
g x * f x ^ (g x - 1) * f' + f x ^ g x * log (f x) * g' := by
simp only [Algebra.id.smul_eq_mul, one_mul, ContinuousLinearMap.one_apply,
ContinuousLinearMap.smulRight_apply, ContinuousLinearMap.add_apply, Pi.smul_apply,
ContinuousLinearMap.coe_smul']
nonrec theorem HasStrictDerivAt.cpow (hf : HasStrictDerivAt f f' x) (hg : HasStrictDerivAt g g' x)
(h0 : f x ∈ slitPlane) : HasStrictDerivAt (fun x => f x ^ g x)
(g x * f x ^ (g x - 1) * f' + f x ^ g x * Complex.log (f x) * g') x := by
simpa using (hf.cpow hg h0).hasStrictDerivAt
theorem HasStrictDerivAt.const_cpow (hf : HasStrictDerivAt f f' x) (h : c ≠ 0 ∨ f x ≠ 0) :
HasStrictDerivAt (fun x => c ^ f x) (c ^ f x * Complex.log c * f') x :=
(hasStrictDerivAt_const_cpow h).comp x hf
theorem Complex.hasStrictDerivAt_cpow_const (h : x ∈ slitPlane) :
HasStrictDerivAt (fun z : ℂ => z ^ c) (c * x ^ (c - 1)) x := by
simpa only [mul_zero, add_zero, mul_one] using
(hasStrictDerivAt_id x).cpow (hasStrictDerivAt_const x c) h
theorem HasStrictDerivAt.cpow_const (hf : HasStrictDerivAt f f' x)
(h0 : f x ∈ slitPlane) :
HasStrictDerivAt (fun x => f x ^ c) (c * f x ^ (c - 1) * f') x :=
(Complex.hasStrictDerivAt_cpow_const h0).comp x hf
theorem HasDerivAt.cpow (hf : HasDerivAt f f' x) (hg : HasDerivAt g g' x)
(h0 : f x ∈ slitPlane) : HasDerivAt (fun x => f x ^ g x)
(g x * f x ^ (g x - 1) * f' + f x ^ g x * Complex.log (f x) * g') x := by
simpa only [aux] using (hf.hasFDerivAt.cpow hg h0).hasDerivAt
theorem HasDerivAt.const_cpow (hf : HasDerivAt f f' x) (h0 : c ≠ 0 ∨ f x ≠ 0) :
HasDerivAt (fun x => c ^ f x) (c ^ f x * Complex.log c * f') x :=
(hasStrictDerivAt_const_cpow h0).hasDerivAt.comp x hf
theorem HasDerivAt.cpow_const (hf : HasDerivAt f f' x) (h0 : f x ∈ slitPlane) :
HasDerivAt (fun x => f x ^ c) (c * f x ^ (c - 1) * f') x :=
(Complex.hasStrictDerivAt_cpow_const h0).hasDerivAt.comp x hf
theorem HasDerivWithinAt.cpow (hf : HasDerivWithinAt f f' s x) (hg : HasDerivWithinAt g g' s x)
(h0 : f x ∈ slitPlane) : HasDerivWithinAt (fun x => f x ^ g x)
(g x * f x ^ (g x - 1) * f' + f x ^ g x * Complex.log (f x) * g') s x := by
simpa only [aux] using (hf.hasFDerivWithinAt.cpow hg h0).hasDerivWithinAt
theorem HasDerivWithinAt.const_cpow (hf : HasDerivWithinAt f f' s x) (h0 : c ≠ 0 ∨ f x ≠ 0) :
HasDerivWithinAt (fun x => c ^ f x) (c ^ f x * Complex.log c * f') s x :=
(hasStrictDerivAt_const_cpow h0).hasDerivAt.comp_hasDerivWithinAt x hf
theorem HasDerivWithinAt.cpow_const (hf : HasDerivWithinAt f f' s x)
(h0 : f x ∈ slitPlane) :
HasDerivWithinAt (fun x => f x ^ c) (c * f x ^ (c - 1) * f') s x :=
(Complex.hasStrictDerivAt_cpow_const h0).hasDerivAt.comp_hasDerivWithinAt x hf
/-- Although `fun x => x ^ r` for fixed `r` is *not* complex-differentiable along the negative real
line, it is still real-differentiable, and the derivative is what one would formally expect. -/
theorem hasDerivAt_ofReal_cpow {x : ℝ} (hx : x ≠ 0) {r : ℂ} (hr : r ≠ -1) :
HasDerivAt (fun y : ℝ => (y : ℂ) ^ (r + 1) / (r + 1)) (x ^ r) x := by
rw [Ne, ← add_eq_zero_iff_eq_neg, ← Ne] at hr
rcases lt_or_gt_of_ne hx.symm with (hx | hx)
· -- easy case : `0 < x`
-- Porting note: proof used to be
-- convert (((hasDerivAt_id (x : ℂ)).cpow_const _).div_const (r + 1)).comp_ofReal using 1
-- · rw [add_sub_cancel, id.def, mul_one, mul_comm, mul_div_cancel _ hr]
-- · rw [id.def, ofReal_re]; exact Or.inl hx
apply HasDerivAt.comp_ofReal (e := fun y => (y : ℂ) ^ (r + 1) / (r + 1))
convert HasDerivAt.div_const (𝕜 := ℂ) ?_ (r + 1) using 1
· exact (mul_div_cancel_right₀ _ hr).symm
· convert HasDerivAt.cpow_const ?_ ?_ using 1
· rw [add_sub_cancel_right, mul_comm]; exact (mul_one _).symm
· exact hasDerivAt_id (x : ℂ)
· simp [hx]
· -- harder case : `x < 0`
have : ∀ᶠ y : ℝ in 𝓝 x,
(y : ℂ) ^ (r + 1) / (r + 1) = (-y : ℂ) ^ (r + 1) * exp (π * I * (r + 1)) / (r + 1) := by
refine Filter.eventually_of_mem (Iio_mem_nhds hx) fun y hy => ?_
rw [ofReal_cpow_of_nonpos (le_of_lt hy)]
refine HasDerivAt.congr_of_eventuallyEq ?_ this
rw [ofReal_cpow_of_nonpos (le_of_lt hx)]
suffices HasDerivAt (fun y : ℝ => (-↑y) ^ (r + 1) * exp (↑π * I * (r + 1)))
((r + 1) * (-↑x) ^ r * exp (↑π * I * r)) x by
convert this.div_const (r + 1) using 1
conv_rhs => rw [mul_assoc, mul_comm, mul_div_cancel_right₀ _ hr]
rw [mul_add ((π : ℂ) * _), mul_one, exp_add, exp_pi_mul_I, mul_comm (_ : ℂ) (-1 : ℂ),
neg_one_mul]
simp_rw [mul_neg, ← neg_mul, ← ofReal_neg]
suffices HasDerivAt (fun y : ℝ => (↑(-y) : ℂ) ^ (r + 1)) (-(r + 1) * ↑(-x) ^ r) x by
convert this.neg.mul_const _ using 1; ring
suffices HasDerivAt (fun y : ℝ => (y : ℂ) ^ (r + 1)) ((r + 1) * ↑(-x) ^ r) (-x) by
convert @HasDerivAt.scomp ℝ _ ℂ _ _ x ℝ _ _ _ _ _ _ _ _ this (hasDerivAt_neg x) using 1
rw [real_smul, ofReal_neg 1, ofReal_one]; ring
suffices HasDerivAt (fun y : ℂ => y ^ (r + 1)) ((r + 1) * ↑(-x) ^ r) ↑(-x) by
exact this.comp_ofReal
conv in ↑_ ^ _ => rw [(by ring : r = r + 1 - 1)]
convert HasDerivAt.cpow_const ?_ ?_ using 1
· rw [add_sub_cancel_right, add_sub_cancel_right]; exact (mul_one _).symm
· exact hasDerivAt_id ((-x : ℝ) : ℂ)
· simp [hx]
end deriv
namespace Real
variable {x y z : ℝ}
/-- `(x, y) ↦ x ^ y` is strictly differentiable at `p : ℝ × ℝ` such that `0 < p.fst`. -/
theorem hasStrictFDerivAt_rpow_of_pos (p : ℝ × ℝ) (hp : 0 < p.1) :
HasStrictFDerivAt (fun x : ℝ × ℝ => x.1 ^ x.2)
((p.2 * p.1 ^ (p.2 - 1)) • ContinuousLinearMap.fst ℝ ℝ ℝ +
(p.1 ^ p.2 * log p.1) • ContinuousLinearMap.snd ℝ ℝ ℝ) p := by
have : (fun x : ℝ × ℝ => x.1 ^ x.2) =ᶠ[𝓝 p] fun x => exp (log x.1 * x.2) :=
(continuousAt_fst.eventually (lt_mem_nhds hp)).mono fun p hp => rpow_def_of_pos hp _
refine HasStrictFDerivAt.congr_of_eventuallyEq ?_ this.symm
convert ((hasStrictFDerivAt_fst.log hp.ne').mul hasStrictFDerivAt_snd).exp using 1
rw [rpow_sub_one hp.ne', ← rpow_def_of_pos hp, smul_add, smul_smul, mul_div_left_comm,
div_eq_mul_inv, smul_smul, smul_smul, mul_assoc, add_comm]
/-- `(x, y) ↦ x ^ y` is strictly differentiable at `p : ℝ × ℝ` such that `p.fst < 0`. -/
theorem hasStrictFDerivAt_rpow_of_neg (p : ℝ × ℝ) (hp : p.1 < 0) :
HasStrictFDerivAt (fun x : ℝ × ℝ => x.1 ^ x.2)
((p.2 * p.1 ^ (p.2 - 1)) • ContinuousLinearMap.fst ℝ ℝ ℝ +
(p.1 ^ p.2 * log p.1 - exp (log p.1 * p.2) * sin (p.2 * π) * π) •
ContinuousLinearMap.snd ℝ ℝ ℝ) p := by
have : (fun x : ℝ × ℝ => x.1 ^ x.2) =ᶠ[𝓝 p] fun x => exp (log x.1 * x.2) * cos (x.2 * π) :=
(continuousAt_fst.eventually (gt_mem_nhds hp)).mono fun p hp => rpow_def_of_neg hp _
refine HasStrictFDerivAt.congr_of_eventuallyEq ?_ this.symm
convert ((hasStrictFDerivAt_fst.log hp.ne).mul hasStrictFDerivAt_snd).exp.mul
(hasStrictFDerivAt_snd.mul_const π).cos using 1
simp_rw [rpow_sub_one hp.ne, smul_add, ← add_assoc, smul_smul, ← add_smul, ← mul_assoc,
mul_comm (cos _), ← rpow_def_of_neg hp]
rw [div_eq_mul_inv, add_comm]; congr 2 <;> ring
/-- The function `fun (x, y) => x ^ y` is infinitely smooth at `(x, y)` unless `x = 0`. -/
theorem contDiffAt_rpow_of_ne (p : ℝ × ℝ) (hp : p.1 ≠ 0) {n : ℕ∞} :
ContDiffAt ℝ n (fun p : ℝ × ℝ => p.1 ^ p.2) p := by
cases' hp.lt_or_lt with hneg hpos
exacts
[(((contDiffAt_fst.log hneg.ne).mul contDiffAt_snd).exp.mul
(contDiffAt_snd.mul contDiffAt_const).cos).congr_of_eventuallyEq
((continuousAt_fst.eventually (gt_mem_nhds hneg)).mono fun p hp => rpow_def_of_neg hp _),
((contDiffAt_fst.log hpos.ne').mul contDiffAt_snd).exp.congr_of_eventuallyEq
((continuousAt_fst.eventually (lt_mem_nhds hpos)).mono fun p hp => rpow_def_of_pos hp _)]
theorem differentiableAt_rpow_of_ne (p : ℝ × ℝ) (hp : p.1 ≠ 0) :
DifferentiableAt ℝ (fun p : ℝ × ℝ => p.1 ^ p.2) p :=
(contDiffAt_rpow_of_ne p hp).differentiableAt le_rfl
theorem _root_.HasStrictDerivAt.rpow {f g : ℝ → ℝ} {f' g' : ℝ} (hf : HasStrictDerivAt f f' x)
(hg : HasStrictDerivAt g g' x) (h : 0 < f x) : HasStrictDerivAt (fun x => f x ^ g x)
(f' * g x * f x ^ (g x - 1) + g' * f x ^ g x * Real.log (f x)) x := by
convert (hasStrictFDerivAt_rpow_of_pos ((fun x => (f x, g x)) x) h).comp_hasStrictDerivAt x
(hf.prod hg) using 1
simp [mul_assoc, mul_comm, mul_left_comm]
theorem hasStrictDerivAt_rpow_const_of_ne {x : ℝ} (hx : x ≠ 0) (p : ℝ) :
HasStrictDerivAt (fun x => x ^ p) (p * x ^ (p - 1)) x := by
cases' hx.lt_or_lt with hx hx
· have := (hasStrictFDerivAt_rpow_of_neg (x, p) hx).comp_hasStrictDerivAt x
((hasStrictDerivAt_id x).prod (hasStrictDerivAt_const _ _))
convert this using 1; simp
· simpa using (hasStrictDerivAt_id x).rpow (hasStrictDerivAt_const x p) hx
theorem hasStrictDerivAt_const_rpow {a : ℝ} (ha : 0 < a) (x : ℝ) :
HasStrictDerivAt (fun x => a ^ x) (a ^ x * log a) x := by
simpa using (hasStrictDerivAt_const _ _).rpow (hasStrictDerivAt_id x) ha
lemma differentiableAt_rpow_const_of_ne (p : ℝ) {x : ℝ} (hx : x ≠ 0) :
DifferentiableAt ℝ (fun x => x ^ p) x :=
(hasStrictDerivAt_rpow_const_of_ne hx p).differentiableAt
lemma differentiableOn_rpow_const (p : ℝ) :
DifferentiableOn ℝ (fun x => (x : ℝ) ^ p) {0}ᶜ :=
fun _ hx => (Real.differentiableAt_rpow_const_of_ne p hx).differentiableWithinAt
/-- This lemma says that `fun x => a ^ x` is strictly differentiable for `a < 0`. Note that these
values of `a` are outside of the "official" domain of `a ^ x`, and we may redefine `a ^ x`
for negative `a` if some other definition will be more convenient. -/
theorem hasStrictDerivAt_const_rpow_of_neg {a x : ℝ} (ha : a < 0) :
HasStrictDerivAt (fun x => a ^ x) (a ^ x * log a - exp (log a * x) * sin (x * π) * π) x := by
simpa using (hasStrictFDerivAt_rpow_of_neg (a, x) ha).comp_hasStrictDerivAt x
((hasStrictDerivAt_const _ _).prod (hasStrictDerivAt_id _))
end Real
namespace Real
variable {z x y : ℝ}
theorem hasDerivAt_rpow_const {x p : ℝ} (h : x ≠ 0 ∨ 1 ≤ p) :
HasDerivAt (fun x => x ^ p) (p * x ^ (p - 1)) x := by
rcases ne_or_eq x 0 with (hx | rfl)
· exact (hasStrictDerivAt_rpow_const_of_ne hx _).hasDerivAt
replace h : 1 ≤ p := h.neg_resolve_left rfl
apply hasDerivAt_of_hasDerivAt_of_ne fun x hx =>
(hasStrictDerivAt_rpow_const_of_ne hx p).hasDerivAt
exacts [continuousAt_id.rpow_const (Or.inr (zero_le_one.trans h)),
continuousAt_const.mul (continuousAt_id.rpow_const (Or.inr (sub_nonneg.2 h)))]
theorem differentiable_rpow_const {p : ℝ} (hp : 1 ≤ p) : Differentiable ℝ fun x : ℝ => x ^ p :=
fun _ => (hasDerivAt_rpow_const (Or.inr hp)).differentiableAt
theorem deriv_rpow_const {x p : ℝ} (h : x ≠ 0 ∨ 1 ≤ p) :
deriv (fun x : ℝ => x ^ p) x = p * x ^ (p - 1) :=
(hasDerivAt_rpow_const h).deriv
theorem deriv_rpow_const' {p : ℝ} (h : 1 ≤ p) :
(deriv fun x : ℝ => x ^ p) = fun x => p * x ^ (p - 1) :=
funext fun _ => deriv_rpow_const (Or.inr h)
theorem contDiffAt_rpow_const_of_ne {x p : ℝ} {n : ℕ∞} (h : x ≠ 0) :
ContDiffAt ℝ n (fun x => x ^ p) x :=
(contDiffAt_rpow_of_ne (x, p) h).comp x (contDiffAt_id.prod contDiffAt_const)
theorem contDiff_rpow_const_of_le {p : ℝ} {n : ℕ} (h : ↑n ≤ p) :
ContDiff ℝ n fun x : ℝ => x ^ p := by
induction' n with n ihn generalizing p
· exact contDiff_zero.2 (continuous_id.rpow_const fun x => Or.inr <| by simpa using h)
· have h1 : 1 ≤ p := le_trans (by simp) h
rw [Nat.cast_succ, ← le_sub_iff_add_le] at h
rw [contDiff_succ_iff_deriv, deriv_rpow_const' h1]
exact ⟨differentiable_rpow_const h1, contDiff_const.mul (ihn h)⟩
theorem contDiffAt_rpow_const_of_le {x p : ℝ} {n : ℕ} (h : ↑n ≤ p) :
ContDiffAt ℝ n (fun x : ℝ => x ^ p) x :=
(contDiff_rpow_const_of_le h).contDiffAt
theorem contDiffAt_rpow_const {x p : ℝ} {n : ℕ} (h : x ≠ 0 ∨ ↑n ≤ p) :
ContDiffAt ℝ n (fun x : ℝ => x ^ p) x :=
h.elim contDiffAt_rpow_const_of_ne contDiffAt_rpow_const_of_le
theorem hasStrictDerivAt_rpow_const {x p : ℝ} (hx : x ≠ 0 ∨ 1 ≤ p) :
HasStrictDerivAt (fun x => x ^ p) (p * x ^ (p - 1)) x :=
ContDiffAt.hasStrictDerivAt' (contDiffAt_rpow_const (by rwa [← Nat.cast_one] at hx))
(hasDerivAt_rpow_const hx) le_rfl
end Real
section Differentiability
open Real
section fderiv
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] {f g : E → ℝ} {f' g' : E →L[ℝ] ℝ}
{x : E} {s : Set E} {c p : ℝ} {n : ℕ∞}
theorem HasFDerivWithinAt.rpow (hf : HasFDerivWithinAt f f' s x) (hg : HasFDerivWithinAt g g' s x)
(h : 0 < f x) : HasFDerivWithinAt (fun x => f x ^ g x)
((g x * f x ^ (g x - 1)) • f' + (f x ^ g x * Real.log (f x)) • g') s x :=
(hasStrictFDerivAt_rpow_of_pos (f x, g x) h).hasFDerivAt.comp_hasFDerivWithinAt x (hf.prod hg)
theorem HasFDerivAt.rpow (hf : HasFDerivAt f f' x) (hg : HasFDerivAt g g' x) (h : 0 < f x) :
HasFDerivAt (fun x => f x ^ g x)
((g x * f x ^ (g x - 1)) • f' + (f x ^ g x * Real.log (f x)) • g') x :=
(hasStrictFDerivAt_rpow_of_pos (f x, g x) h).hasFDerivAt.comp x (hf.prod hg)
theorem HasStrictFDerivAt.rpow (hf : HasStrictFDerivAt f f' x) (hg : HasStrictFDerivAt g g' x)
(h : 0 < f x) : HasStrictFDerivAt (fun x => f x ^ g x)
((g x * f x ^ (g x - 1)) • f' + (f x ^ g x * Real.log (f x)) • g') x :=
(hasStrictFDerivAt_rpow_of_pos (f x, g x) h).comp x (hf.prod hg)
theorem DifferentiableWithinAt.rpow (hf : DifferentiableWithinAt ℝ f s x)
(hg : DifferentiableWithinAt ℝ g s x) (h : f x ≠ 0) :
DifferentiableWithinAt ℝ (fun x => f x ^ g x) s x :=
(differentiableAt_rpow_of_ne (f x, g x) h).comp_differentiableWithinAt x (hf.prod hg)
theorem DifferentiableAt.rpow (hf : DifferentiableAt ℝ f x) (hg : DifferentiableAt ℝ g x)
(h : f x ≠ 0) : DifferentiableAt ℝ (fun x => f x ^ g x) x :=
(differentiableAt_rpow_of_ne (f x, g x) h).comp x (hf.prod hg)
theorem DifferentiableOn.rpow (hf : DifferentiableOn ℝ f s) (hg : DifferentiableOn ℝ g s)
(h : ∀ x ∈ s, f x ≠ 0) : DifferentiableOn ℝ (fun x => f x ^ g x) s := fun x hx =>
(hf x hx).rpow (hg x hx) (h x hx)
theorem Differentiable.rpow (hf : Differentiable ℝ f) (hg : Differentiable ℝ g) (h : ∀ x, f x ≠ 0) :
Differentiable ℝ fun x => f x ^ g x := fun x => (hf x).rpow (hg x) (h x)
theorem HasFDerivWithinAt.rpow_const (hf : HasFDerivWithinAt f f' s x) (h : f x ≠ 0 ∨ 1 ≤ p) :
HasFDerivWithinAt (fun x => f x ^ p) ((p * f x ^ (p - 1)) • f') s x :=
(hasDerivAt_rpow_const h).comp_hasFDerivWithinAt x hf
theorem HasFDerivAt.rpow_const (hf : HasFDerivAt f f' x) (h : f x ≠ 0 ∨ 1 ≤ p) :
HasFDerivAt (fun x => f x ^ p) ((p * f x ^ (p - 1)) • f') x :=
(hasDerivAt_rpow_const h).comp_hasFDerivAt x hf
theorem HasStrictFDerivAt.rpow_const (hf : HasStrictFDerivAt f f' x) (h : f x ≠ 0 ∨ 1 ≤ p) :
HasStrictFDerivAt (fun x => f x ^ p) ((p * f x ^ (p - 1)) • f') x :=
(hasStrictDerivAt_rpow_const h).comp_hasStrictFDerivAt x hf
theorem DifferentiableWithinAt.rpow_const (hf : DifferentiableWithinAt ℝ f s x)
(h : f x ≠ 0 ∨ 1 ≤ p) : DifferentiableWithinAt ℝ (fun x => f x ^ p) s x :=
(hf.hasFDerivWithinAt.rpow_const h).differentiableWithinAt
@[simp]
theorem DifferentiableAt.rpow_const (hf : DifferentiableAt ℝ f x) (h : f x ≠ 0 ∨ 1 ≤ p) :
DifferentiableAt ℝ (fun x => f x ^ p) x :=
(hf.hasFDerivAt.rpow_const h).differentiableAt
theorem DifferentiableOn.rpow_const (hf : DifferentiableOn ℝ f s) (h : ∀ x ∈ s, f x ≠ 0 ∨ 1 ≤ p) :
DifferentiableOn ℝ (fun x => f x ^ p) s := fun x hx => (hf x hx).rpow_const (h x hx)
theorem Differentiable.rpow_const (hf : Differentiable ℝ f) (h : ∀ x, f x ≠ 0 ∨ 1 ≤ p) :
Differentiable ℝ fun x => f x ^ p := fun x => (hf x).rpow_const (h x)
theorem HasFDerivWithinAt.const_rpow (hf : HasFDerivWithinAt f f' s x) (hc : 0 < c) :
HasFDerivWithinAt (fun x => c ^ f x) ((c ^ f x * Real.log c) • f') s x :=
(hasStrictDerivAt_const_rpow hc (f x)).hasDerivAt.comp_hasFDerivWithinAt x hf
theorem HasFDerivAt.const_rpow (hf : HasFDerivAt f f' x) (hc : 0 < c) :
HasFDerivAt (fun x => c ^ f x) ((c ^ f x * Real.log c) • f') x :=
(hasStrictDerivAt_const_rpow hc (f x)).hasDerivAt.comp_hasFDerivAt x hf
theorem HasStrictFDerivAt.const_rpow (hf : HasStrictFDerivAt f f' x) (hc : 0 < c) :
HasStrictFDerivAt (fun x => c ^ f x) ((c ^ f x * Real.log c) • f') x :=
(hasStrictDerivAt_const_rpow hc (f x)).comp_hasStrictFDerivAt x hf
theorem ContDiffWithinAt.rpow (hf : ContDiffWithinAt ℝ n f s x) (hg : ContDiffWithinAt ℝ n g s x)
(h : f x ≠ 0) : ContDiffWithinAt ℝ n (fun x => f x ^ g x) s x :=
(contDiffAt_rpow_of_ne (f x, g x) h).comp_contDiffWithinAt x (hf.prod hg)
theorem ContDiffAt.rpow (hf : ContDiffAt ℝ n f x) (hg : ContDiffAt ℝ n g x) (h : f x ≠ 0) :
ContDiffAt ℝ n (fun x => f x ^ g x) x :=
(contDiffAt_rpow_of_ne (f x, g x) h).comp x (hf.prod hg)
theorem ContDiffOn.rpow (hf : ContDiffOn ℝ n f s) (hg : ContDiffOn ℝ n g s) (h : ∀ x ∈ s, f x ≠ 0) :
ContDiffOn ℝ n (fun x => f x ^ g x) s := fun x hx => (hf x hx).rpow (hg x hx) (h x hx)
theorem ContDiff.rpow (hf : ContDiff ℝ n f) (hg : ContDiff ℝ n g) (h : ∀ x, f x ≠ 0) :
ContDiff ℝ n fun x => f x ^ g x :=
contDiff_iff_contDiffAt.mpr fun x => hf.contDiffAt.rpow hg.contDiffAt (h x)
theorem ContDiffWithinAt.rpow_const_of_ne (hf : ContDiffWithinAt ℝ n f s x) (h : f x ≠ 0) :
ContDiffWithinAt ℝ n (fun x => f x ^ p) s x :=
hf.rpow contDiffWithinAt_const h
theorem ContDiffAt.rpow_const_of_ne (hf : ContDiffAt ℝ n f x) (h : f x ≠ 0) :
ContDiffAt ℝ n (fun x => f x ^ p) x :=
hf.rpow contDiffAt_const h
theorem ContDiffOn.rpow_const_of_ne (hf : ContDiffOn ℝ n f s) (h : ∀ x ∈ s, f x ≠ 0) :
ContDiffOn ℝ n (fun x => f x ^ p) s := fun x hx => (hf x hx).rpow_const_of_ne (h x hx)
theorem ContDiff.rpow_const_of_ne (hf : ContDiff ℝ n f) (h : ∀ x, f x ≠ 0) :
ContDiff ℝ n fun x => f x ^ p :=
hf.rpow contDiff_const h
variable {m : ℕ}
theorem ContDiffWithinAt.rpow_const_of_le (hf : ContDiffWithinAt ℝ m f s x) (h : ↑m ≤ p) :
ContDiffWithinAt ℝ m (fun x => f x ^ p) s x :=
(contDiffAt_rpow_const_of_le h).comp_contDiffWithinAt x hf
theorem ContDiffAt.rpow_const_of_le (hf : ContDiffAt ℝ m f x) (h : ↑m ≤ p) :
ContDiffAt ℝ m (fun x => f x ^ p) x := by
rw [← contDiffWithinAt_univ] at *; exact hf.rpow_const_of_le h
theorem ContDiffOn.rpow_const_of_le (hf : ContDiffOn ℝ m f s) (h : ↑m ≤ p) :
ContDiffOn ℝ m (fun x => f x ^ p) s := fun x hx => (hf x hx).rpow_const_of_le h
theorem ContDiff.rpow_const_of_le (hf : ContDiff ℝ m f) (h : ↑m ≤ p) :
ContDiff ℝ m fun x => f x ^ p :=
contDiff_iff_contDiffAt.mpr fun _ => hf.contDiffAt.rpow_const_of_le h
end fderiv
section deriv
variable {f g : ℝ → ℝ} {f' g' x y p : ℝ} {s : Set ℝ}
theorem HasDerivWithinAt.rpow (hf : HasDerivWithinAt f f' s x) (hg : HasDerivWithinAt g g' s x)
(h : 0 < f x) : HasDerivWithinAt (fun x => f x ^ g x)
(f' * g x * f x ^ (g x - 1) + g' * f x ^ g x * Real.log (f x)) s x := by
convert (hf.hasFDerivWithinAt.rpow hg.hasFDerivWithinAt h).hasDerivWithinAt using 1
dsimp; ring
theorem HasDerivAt.rpow (hf : HasDerivAt f f' x) (hg : HasDerivAt g g' x) (h : 0 < f x) :
HasDerivAt (fun x => f x ^ g x)
(f' * g x * f x ^ (g x - 1) + g' * f x ^ g x * Real.log (f x)) x := by
rw [← hasDerivWithinAt_univ] at *
exact hf.rpow hg h
theorem HasDerivWithinAt.rpow_const (hf : HasDerivWithinAt f f' s x) (hx : f x ≠ 0 ∨ 1 ≤ p) :
HasDerivWithinAt (fun y => f y ^ p) (f' * p * f x ^ (p - 1)) s x := by
convert (hasDerivAt_rpow_const hx).comp_hasDerivWithinAt x hf using 1
ring
theorem HasDerivAt.rpow_const (hf : HasDerivAt f f' x) (hx : f x ≠ 0 ∨ 1 ≤ p) :
HasDerivAt (fun y => f y ^ p) (f' * p * f x ^ (p - 1)) x := by
rw [← hasDerivWithinAt_univ] at *
exact hf.rpow_const hx
theorem derivWithin_rpow_const (hf : DifferentiableWithinAt ℝ f s x) (hx : f x ≠ 0 ∨ 1 ≤ p)
(hxs : UniqueDiffWithinAt ℝ s x) :
derivWithin (fun x => f x ^ p) s x = derivWithin f s x * p * f x ^ (p - 1) :=
(hf.hasDerivWithinAt.rpow_const hx).derivWithin hxs
@[simp]
theorem deriv_rpow_const (hf : DifferentiableAt ℝ f x) (hx : f x ≠ 0 ∨ 1 ≤ p) :
deriv (fun x => f x ^ p) x = deriv f x * p * f x ^ (p - 1) :=
(hf.hasDerivAt.rpow_const hx).deriv
lemma isTheta_deriv_rpow_const_atTop {p : ℝ} (hp : p ≠ 0) :
deriv (fun (x : ℝ) => x ^ p) =Θ[atTop] fun x => x ^ (p-1) := by
calc deriv (fun (x : ℝ) => x ^ p) =ᶠ[atTop] fun x => p * x ^ (p - 1) := by
filter_upwards [eventually_ne_atTop 0] with x hx
rw [Real.deriv_rpow_const (Or.inl hx)]
_ =Θ[atTop] fun x => x ^ (p-1) :=
Asymptotics.IsTheta.const_mul_left hp Asymptotics.isTheta_rfl
lemma isBigO_deriv_rpow_const_atTop (p : ℝ) :
deriv (fun (x : ℝ) => x ^ p) =O[atTop] fun x => x ^ (p-1) := by
rcases eq_or_ne p 0 with rfl | hp
case inl =>
simp [zero_sub, Real.rpow_neg_one, Real.rpow_zero, deriv_const', Asymptotics.isBigO_zero]
case inr =>
exact (isTheta_deriv_rpow_const_atTop hp).1
end deriv
end Differentiability
section Limits
open Real Filter
/-- The function `(1 + t/x) ^ x` tends to `exp t` at `+∞`. -/
theorem tendsto_one_plus_div_rpow_exp (t : ℝ) :
Tendsto (fun x : ℝ => (1 + t / x) ^ x) atTop (𝓝 (exp t)) := by
apply ((Real.continuous_exp.tendsto _).comp (tendsto_mul_log_one_plus_div_atTop t)).congr' _
have h₁ : (1 : ℝ) / 2 < 1 := by linarith
have h₂ : Tendsto (fun x : ℝ => 1 + t / x) atTop (𝓝 1) := by
simpa using (tendsto_inv_atTop_zero.const_mul t).const_add 1
refine (eventually_ge_of_tendsto_gt h₁ h₂).mono fun x hx => ?_
have hx' : 0 < 1 + t / x := by linarith
simp [mul_comm x, exp_mul, exp_log hx']
/-- The function `(1 + t/x) ^ x` tends to `exp t` at `+∞` for naturals `x`. -/
theorem tendsto_one_plus_div_pow_exp (t : ℝ) :
Tendsto (fun x : ℕ => (1 + t / (x : ℝ)) ^ x) atTop (𝓝 (Real.exp t)) :=
((tendsto_one_plus_div_rpow_exp t).comp tendsto_natCast_atTop_atTop).congr (by simp)
end Limits
|
Analysis\SpecialFunctions\Pow\Integral.lean | /-
Copyright (c) 2022 Kalle Kytölä. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kalle Kytölä
-/
import Mathlib.Analysis.SpecialFunctions.Integrals
import Mathlib.MeasureTheory.Integral.Layercake
/-!
# The integral of the real power of a nonnegative function
In this file, we give a common application of the layer cake formula -
a representation of the integral of the p:th power of a nonnegative function f:
∫ f(ω)^p ∂μ(ω) = p * ∫ t^(p-1) * μ {ω | f(ω) ≥ t} dt .
A variant of the formula with measures of sets of the form {ω | f(ω) > t} instead of {ω | f(ω) ≥ t}
is also included.
## Main results
* `MeasureTheory.lintegral_rpow_eq_lintegral_meas_le_mul` and
`MeasureTheory.lintegral_rpow_eq_lintegral_meas_lt_mul`:
Other common special cases of the layer cake formulas, stating that for a nonnegative function f
and p > 0, we have ∫ f(ω)^p ∂μ(ω) = p * ∫ μ {ω | f(ω) ≥ t} * t^(p-1) dt and
∫ f(ω)^p ∂μ(ω) = p * ∫ μ {ω | f(ω) > t} * t^(p-1) dt, respectively.
## Tags
layer cake representation, Cavalieri's principle, tail probability formula
-/
open Set
namespace MeasureTheory
variable {α : Type*} [MeasurableSpace α] {f : α → ℝ} (μ : Measure α) (f_nn : 0 ≤ᵐ[μ] f)
(f_mble : AEMeasurable f μ) {p : ℝ} (p_pos : 0 < p)
section Layercake
/-- An application of the layer cake formula / Cavalieri's principle / tail probability formula:
For a nonnegative function `f` on a measure space, the Lebesgue integral of `f` can
be written (roughly speaking) as: `∫⁻ f^p ∂μ = p * ∫⁻ t in 0..∞, t^(p-1) * μ {ω | f(ω) ≥ t}`.
See `MeasureTheory.lintegral_rpow_eq_lintegral_meas_lt_mul` for a version with sets of the form
`{ω | f(ω) > t}` instead. -/
theorem lintegral_rpow_eq_lintegral_meas_le_mul :
∫⁻ ω, ENNReal.ofReal (f ω ^ p) ∂μ =
ENNReal.ofReal p * ∫⁻ t in Ioi 0, μ {a : α | t ≤ f a} * ENNReal.ofReal (t ^ (p - 1)) := by
have one_lt_p : -1 < p - 1 := by linarith
have obs : ∀ x : ℝ, ∫ t : ℝ in (0)..x, t ^ (p - 1) = x ^ p / p := by
intro x
rw [integral_rpow (Or.inl one_lt_p)]
simp [Real.zero_rpow p_pos.ne.symm]
set g := fun t : ℝ => t ^ (p - 1)
have g_nn : ∀ᵐ t ∂volume.restrict (Ioi (0 : ℝ)), 0 ≤ g t := by
filter_upwards [self_mem_ae_restrict (measurableSet_Ioi : MeasurableSet (Ioi (0 : ℝ)))]
intro t t_pos
exact Real.rpow_nonneg (mem_Ioi.mp t_pos).le (p - 1)
have g_intble : ∀ t > 0, IntervalIntegrable g volume 0 t := fun _ _ =>
intervalIntegral.intervalIntegrable_rpow' one_lt_p
have key := lintegral_comp_eq_lintegral_meas_le_mul μ f_nn f_mble g_intble g_nn
rw [← key, ← lintegral_const_mul'' (ENNReal.ofReal p)] <;> simp_rw [obs]
· congr with ω
rw [← ENNReal.ofReal_mul p_pos.le, mul_div_cancel₀ (f ω ^ p) p_pos.ne.symm]
· have aux := (@measurable_const ℝ α (by infer_instance) (by infer_instance) p).aemeasurable
(μ := μ)
exact (Measurable.ennreal_ofReal (hf := measurable_id)).comp_aemeasurable
((f_mble.pow aux).div_const p)
end Layercake
section LayercakeLT
/-- An application of the layer cake formula / Cavalieri's principle / tail probability formula:
For a nonnegative function `f` on a measure space, the Lebesgue integral of `f` can
be written (roughly speaking) as: `∫⁻ f^p ∂μ = p * ∫⁻ t in 0..∞, t^(p-1) * μ {ω | f(ω) > t}`.
See `MeasureTheory.lintegral_rpow_eq_lintegral_meas_le_mul` for a version with sets of the form
`{ω | f(ω) ≥ t}` instead. -/
theorem lintegral_rpow_eq_lintegral_meas_lt_mul :
∫⁻ ω, ENNReal.ofReal (f ω ^ p) ∂μ =
ENNReal.ofReal p * ∫⁻ t in Ioi 0, μ {a : α | t < f a} * ENNReal.ofReal (t ^ (p - 1)) := by
rw [lintegral_rpow_eq_lintegral_meas_le_mul μ f_nn f_mble p_pos]
apply congr_arg fun z => ENNReal.ofReal p * z
apply lintegral_congr_ae
filter_upwards [meas_le_ae_eq_meas_lt μ (volume.restrict (Ioi 0)) f]
with t ht
rw [ht]
end LayercakeLT
end MeasureTheory
|
Analysis\SpecialFunctions\Pow\NNReal.lean | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Sébastien Gouëzel,
Rémy Degenne, David Loeffler
-/
import Mathlib.Analysis.SpecialFunctions.Pow.Real
/-!
# Power function on `ℝ≥0` and `ℝ≥0∞`
We construct the power functions `x ^ y` where
* `x` is a nonnegative real number and `y` is a real number;
* `x` is a number from `[0, +∞]` (a.k.a. `ℝ≥0∞`) and `y` is a real number.
We also prove basic properties of these functions.
-/
noncomputable section
open scoped Classical
open Real NNReal ENNReal ComplexConjugate
open Finset Function Set
namespace NNReal
variable {w x y z : ℝ}
/-- The nonnegative real power function `x^y`, defined for `x : ℝ≥0` and `y : ℝ` as the
restriction of the real power function. For `x > 0`, it is equal to `exp (y log x)`. For `x = 0`,
one sets `0 ^ 0 = 1` and `0 ^ y = 0` for `y ≠ 0`. -/
noncomputable def rpow (x : ℝ≥0) (y : ℝ) : ℝ≥0 :=
⟨(x : ℝ) ^ y, Real.rpow_nonneg x.2 y⟩
noncomputable instance : Pow ℝ≥0 ℝ :=
⟨rpow⟩
@[simp]
theorem rpow_eq_pow (x : ℝ≥0) (y : ℝ) : rpow x y = x ^ y :=
rfl
@[simp, norm_cast]
theorem coe_rpow (x : ℝ≥0) (y : ℝ) : ((x ^ y : ℝ≥0) : ℝ) = (x : ℝ) ^ y :=
rfl
@[simp]
theorem rpow_zero (x : ℝ≥0) : x ^ (0 : ℝ) = 1 :=
NNReal.eq <| Real.rpow_zero _
@[simp]
theorem rpow_eq_zero_iff {x : ℝ≥0} {y : ℝ} : x ^ y = 0 ↔ x = 0 ∧ y ≠ 0 := by
rw [← NNReal.coe_inj, coe_rpow, ← NNReal.coe_eq_zero]
exact Real.rpow_eq_zero_iff_of_nonneg x.2
@[simp]
theorem zero_rpow {x : ℝ} (h : x ≠ 0) : (0 : ℝ≥0) ^ x = 0 :=
NNReal.eq <| Real.zero_rpow h
@[simp]
theorem rpow_one (x : ℝ≥0) : x ^ (1 : ℝ) = x :=
NNReal.eq <| Real.rpow_one _
@[simp]
theorem one_rpow (x : ℝ) : (1 : ℝ≥0) ^ x = 1 :=
NNReal.eq <| Real.one_rpow _
theorem rpow_add {x : ℝ≥0} (hx : x ≠ 0) (y z : ℝ) : x ^ (y + z) = x ^ y * x ^ z :=
NNReal.eq <| Real.rpow_add (pos_iff_ne_zero.2 hx) _ _
theorem rpow_add' (x : ℝ≥0) {y z : ℝ} (h : y + z ≠ 0) : x ^ (y + z) = x ^ y * x ^ z :=
NNReal.eq <| Real.rpow_add' x.2 h
theorem rpow_add_of_nonneg (x : ℝ≥0) {y z : ℝ} (hy : 0 ≤ y) (hz : 0 ≤ z) :
x ^ (y + z) = x ^ y * x ^ z := by
ext; exact Real.rpow_add_of_nonneg x.2 hy hz
/-- Variant of `NNReal.rpow_add'` that avoids having to prove `y + z = w` twice. -/
lemma rpow_of_add_eq (x : ℝ≥0) (hw : w ≠ 0) (h : y + z = w) : x ^ w = x ^ y * x ^ z := by
rw [← h, rpow_add']; rwa [h]
theorem rpow_mul (x : ℝ≥0) (y z : ℝ) : x ^ (y * z) = (x ^ y) ^ z :=
NNReal.eq <| Real.rpow_mul x.2 y z
theorem rpow_neg (x : ℝ≥0) (y : ℝ) : x ^ (-y) = (x ^ y)⁻¹ :=
NNReal.eq <| Real.rpow_neg x.2 _
theorem rpow_neg_one (x : ℝ≥0) : x ^ (-1 : ℝ) = x⁻¹ := by simp [rpow_neg]
theorem rpow_sub {x : ℝ≥0} (hx : x ≠ 0) (y z : ℝ) : x ^ (y - z) = x ^ y / x ^ z :=
NNReal.eq <| Real.rpow_sub (pos_iff_ne_zero.2 hx) y z
theorem rpow_sub' (x : ℝ≥0) {y z : ℝ} (h : y - z ≠ 0) : x ^ (y - z) = x ^ y / x ^ z :=
NNReal.eq <| Real.rpow_sub' x.2 h
theorem rpow_inv_rpow_self {y : ℝ} (hy : y ≠ 0) (x : ℝ≥0) : (x ^ y) ^ (1 / y) = x := by
field_simp [← rpow_mul]
theorem rpow_self_rpow_inv {y : ℝ} (hy : y ≠ 0) (x : ℝ≥0) : (x ^ (1 / y)) ^ y = x := by
field_simp [← rpow_mul]
theorem inv_rpow (x : ℝ≥0) (y : ℝ) : x⁻¹ ^ y = (x ^ y)⁻¹ :=
NNReal.eq <| Real.inv_rpow x.2 y
theorem div_rpow (x y : ℝ≥0) (z : ℝ) : (x / y) ^ z = x ^ z / y ^ z :=
NNReal.eq <| Real.div_rpow x.2 y.2 z
theorem sqrt_eq_rpow (x : ℝ≥0) : sqrt x = x ^ (1 / (2 : ℝ)) := by
refine NNReal.eq ?_
push_cast
exact Real.sqrt_eq_rpow x.1
@[simp, norm_cast]
theorem rpow_natCast (x : ℝ≥0) (n : ℕ) : x ^ (n : ℝ) = x ^ n :=
NNReal.eq <| by simpa only [coe_rpow, coe_pow] using Real.rpow_natCast x n
@[deprecated (since := "2024-04-17")]
alias rpow_nat_cast := rpow_natCast
@[simp]
lemma rpow_ofNat (x : ℝ≥0) (n : ℕ) [n.AtLeastTwo] :
x ^ (no_index (OfNat.ofNat n) : ℝ) = x ^ (OfNat.ofNat n : ℕ) :=
rpow_natCast x n
theorem rpow_two (x : ℝ≥0) : x ^ (2 : ℝ) = x ^ 2 := rpow_ofNat x 2
theorem mul_rpow {x y : ℝ≥0} {z : ℝ} : (x * y) ^ z = x ^ z * y ^ z :=
NNReal.eq <| Real.mul_rpow x.2 y.2
/-- `rpow` as a `MonoidHom`-/
@[simps]
def rpowMonoidHom (r : ℝ) : ℝ≥0 →* ℝ≥0 where
toFun := (· ^ r)
map_one' := one_rpow _
map_mul' _x _y := mul_rpow
/-- `rpow` variant of `List.prod_map_pow` for `ℝ≥0`-/
theorem list_prod_map_rpow (l : List ℝ≥0) (r : ℝ) :
(l.map (· ^ r)).prod = l.prod ^ r :=
l.prod_hom (rpowMonoidHom r)
theorem list_prod_map_rpow' {ι} (l : List ι) (f : ι → ℝ≥0) (r : ℝ) :
(l.map (f · ^ r)).prod = (l.map f).prod ^ r := by
rw [← list_prod_map_rpow, List.map_map]; rfl
/-- `rpow` version of `Multiset.prod_map_pow` for `ℝ≥0`. -/
lemma multiset_prod_map_rpow {ι} (s : Multiset ι) (f : ι → ℝ≥0) (r : ℝ) :
(s.map (f · ^ r)).prod = (s.map f).prod ^ r :=
s.prod_hom' (rpowMonoidHom r) _
/-- `rpow` version of `Finset.prod_pow` for `ℝ≥0`. -/
lemma finset_prod_rpow {ι} (s : Finset ι) (f : ι → ℝ≥0) (r : ℝ) :
(∏ i ∈ s, f i ^ r) = (∏ i ∈ s, f i) ^ r :=
multiset_prod_map_rpow _ _ _
-- note: these don't really belong here, but they're much easier to prove in terms of the above
section Real
/-- `rpow` version of `List.prod_map_pow` for `Real`. -/
theorem _root_.Real.list_prod_map_rpow (l : List ℝ) (hl : ∀ x ∈ l, (0 : ℝ) ≤ x) (r : ℝ) :
(l.map (· ^ r)).prod = l.prod ^ r := by
lift l to List ℝ≥0 using hl
have := congr_arg ((↑) : ℝ≥0 → ℝ) (NNReal.list_prod_map_rpow l r)
push_cast at this
rw [List.map_map] at this ⊢
exact mod_cast this
theorem _root_.Real.list_prod_map_rpow' {ι} (l : List ι) (f : ι → ℝ)
(hl : ∀ i ∈ l, (0 : ℝ) ≤ f i) (r : ℝ) :
(l.map (f · ^ r)).prod = (l.map f).prod ^ r := by
rw [← Real.list_prod_map_rpow (l.map f) _ r, List.map_map]
· rfl
simpa using hl
/-- `rpow` version of `Multiset.prod_map_pow`. -/
theorem _root_.Real.multiset_prod_map_rpow {ι} (s : Multiset ι) (f : ι → ℝ)
(hs : ∀ i ∈ s, (0 : ℝ) ≤ f i) (r : ℝ) :
(s.map (f · ^ r)).prod = (s.map f).prod ^ r := by
induction' s using Quotient.inductionOn with l
simpa using Real.list_prod_map_rpow' l f hs r
/-- `rpow` version of `Finset.prod_pow`. -/
theorem _root_.Real.finset_prod_rpow
{ι} (s : Finset ι) (f : ι → ℝ) (hs : ∀ i ∈ s, 0 ≤ f i) (r : ℝ) :
(∏ i ∈ s, f i ^ r) = (∏ i ∈ s, f i) ^ r :=
Real.multiset_prod_map_rpow s.val f hs r
end Real
@[gcongr] theorem rpow_le_rpow {x y : ℝ≥0} {z : ℝ} (h₁ : x ≤ y) (h₂ : 0 ≤ z) : x ^ z ≤ y ^ z :=
Real.rpow_le_rpow x.2 h₁ h₂
@[gcongr] theorem rpow_lt_rpow {x y : ℝ≥0} {z : ℝ} (h₁ : x < y) (h₂ : 0 < z) : x ^ z < y ^ z :=
Real.rpow_lt_rpow x.2 h₁ h₂
theorem rpow_lt_rpow_iff {x y : ℝ≥0} {z : ℝ} (hz : 0 < z) : x ^ z < y ^ z ↔ x < y :=
Real.rpow_lt_rpow_iff x.2 y.2 hz
theorem rpow_le_rpow_iff {x y : ℝ≥0} {z : ℝ} (hz : 0 < z) : x ^ z ≤ y ^ z ↔ x ≤ y :=
Real.rpow_le_rpow_iff x.2 y.2 hz
theorem le_rpow_inv_iff {x y : ℝ≥0} {z : ℝ} (hz : 0 < z) : x ≤ y ^ z⁻¹ ↔ x ^ z ≤ y := by
rw [← rpow_le_rpow_iff hz, ← one_div, rpow_self_rpow_inv hz.ne']
@[deprecated le_rpow_inv_iff (since := "2024-07-10")]
theorem le_rpow_one_div_iff {x y : ℝ≥0} {z : ℝ} (hz : 0 < z) : x ≤ y ^ (1 / z) ↔ x ^ z ≤ y := by
rw [← rpow_le_rpow_iff hz, rpow_self_rpow_inv hz.ne']
theorem rpow_inv_le_iff {x y : ℝ≥0} {z : ℝ} (hz : 0 < z) : x ^ z⁻¹ ≤ y ↔ x ≤ y ^ z := by
rw [← rpow_le_rpow_iff hz, ← one_div, rpow_self_rpow_inv hz.ne']
@[deprecated rpow_inv_le_iff (since := "2024-07-10")]
theorem rpow_one_div_le_iff {x y : ℝ≥0} {z : ℝ} (hz : 0 < z) : x ^ (1 / z) ≤ y ↔ x ≤ y ^ z := by
rw [← rpow_le_rpow_iff hz, rpow_self_rpow_inv hz.ne']
theorem lt_rpow_inv_iff {x y : ℝ≥0} {z : ℝ} (hz : 0 < z) : x < y ^ z⁻¹ ↔ x ^z < y := by
simp only [← not_le, rpow_inv_le_iff hz]
theorem rpow_inv_lt_iff {x y : ℝ≥0} {z : ℝ} (hz : 0 < z) : x ^ z⁻¹ < y ↔ x < y ^ z := by
simp only [← not_le, le_rpow_inv_iff hz]
@[gcongr] theorem rpow_lt_rpow_of_exponent_lt {x : ℝ≥0} {y z : ℝ} (hx : 1 < x) (hyz : y < z) :
x ^ y < x ^ z :=
Real.rpow_lt_rpow_of_exponent_lt hx hyz
@[gcongr] theorem rpow_le_rpow_of_exponent_le {x : ℝ≥0} {y z : ℝ} (hx : 1 ≤ x) (hyz : y ≤ z) :
x ^ y ≤ x ^ z :=
Real.rpow_le_rpow_of_exponent_le hx hyz
theorem rpow_lt_rpow_of_exponent_gt {x : ℝ≥0} {y z : ℝ} (hx0 : 0 < x) (hx1 : x < 1) (hyz : z < y) :
x ^ y < x ^ z :=
Real.rpow_lt_rpow_of_exponent_gt hx0 hx1 hyz
theorem rpow_le_rpow_of_exponent_ge {x : ℝ≥0} {y z : ℝ} (hx0 : 0 < x) (hx1 : x ≤ 1) (hyz : z ≤ y) :
x ^ y ≤ x ^ z :=
Real.rpow_le_rpow_of_exponent_ge hx0 hx1 hyz
theorem rpow_pos {p : ℝ} {x : ℝ≥0} (hx_pos : 0 < x) : 0 < x ^ p := by
have rpow_pos_of_nonneg : ∀ {p : ℝ}, 0 < p → 0 < x ^ p := by
intro p hp_pos
rw [← zero_rpow hp_pos.ne']
exact rpow_lt_rpow hx_pos hp_pos
rcases lt_trichotomy (0 : ℝ) p with (hp_pos | rfl | hp_neg)
· exact rpow_pos_of_nonneg hp_pos
· simp only [zero_lt_one, rpow_zero]
· rw [← neg_neg p, rpow_neg, inv_pos]
exact rpow_pos_of_nonneg (neg_pos.mpr hp_neg)
theorem rpow_lt_one {x : ℝ≥0} {z : ℝ} (hx1 : x < 1) (hz : 0 < z) : x ^ z < 1 :=
Real.rpow_lt_one (coe_nonneg x) hx1 hz
theorem rpow_le_one {x : ℝ≥0} {z : ℝ} (hx2 : x ≤ 1) (hz : 0 ≤ z) : x ^ z ≤ 1 :=
Real.rpow_le_one x.2 hx2 hz
theorem rpow_lt_one_of_one_lt_of_neg {x : ℝ≥0} {z : ℝ} (hx : 1 < x) (hz : z < 0) : x ^ z < 1 :=
Real.rpow_lt_one_of_one_lt_of_neg hx hz
theorem rpow_le_one_of_one_le_of_nonpos {x : ℝ≥0} {z : ℝ} (hx : 1 ≤ x) (hz : z ≤ 0) : x ^ z ≤ 1 :=
Real.rpow_le_one_of_one_le_of_nonpos hx hz
theorem one_lt_rpow {x : ℝ≥0} {z : ℝ} (hx : 1 < x) (hz : 0 < z) : 1 < x ^ z :=
Real.one_lt_rpow hx hz
theorem one_le_rpow {x : ℝ≥0} {z : ℝ} (h : 1 ≤ x) (h₁ : 0 ≤ z) : 1 ≤ x ^ z :=
Real.one_le_rpow h h₁
theorem one_lt_rpow_of_pos_of_lt_one_of_neg {x : ℝ≥0} {z : ℝ} (hx1 : 0 < x) (hx2 : x < 1)
(hz : z < 0) : 1 < x ^ z :=
Real.one_lt_rpow_of_pos_of_lt_one_of_neg hx1 hx2 hz
theorem one_le_rpow_of_pos_of_le_one_of_nonpos {x : ℝ≥0} {z : ℝ} (hx1 : 0 < x) (hx2 : x ≤ 1)
(hz : z ≤ 0) : 1 ≤ x ^ z :=
Real.one_le_rpow_of_pos_of_le_one_of_nonpos hx1 hx2 hz
theorem rpow_le_self_of_le_one {x : ℝ≥0} {z : ℝ} (hx : x ≤ 1) (h_one_le : 1 ≤ z) : x ^ z ≤ x := by
rcases eq_bot_or_bot_lt x with (rfl | (h : 0 < x))
· have : z ≠ 0 := by linarith
simp [this]
nth_rw 2 [← NNReal.rpow_one x]
exact NNReal.rpow_le_rpow_of_exponent_ge h hx h_one_le
theorem rpow_left_injective {x : ℝ} (hx : x ≠ 0) : Function.Injective fun y : ℝ≥0 => y ^ x :=
fun y z hyz => by simpa only [rpow_inv_rpow_self hx] using congr_arg (fun y => y ^ (1 / x)) hyz
theorem rpow_eq_rpow_iff {x y : ℝ≥0} {z : ℝ} (hz : z ≠ 0) : x ^ z = y ^ z ↔ x = y :=
(rpow_left_injective hz).eq_iff
theorem rpow_left_surjective {x : ℝ} (hx : x ≠ 0) : Function.Surjective fun y : ℝ≥0 => y ^ x :=
fun y => ⟨y ^ x⁻¹, by simp_rw [← rpow_mul, _root_.inv_mul_cancel hx, rpow_one]⟩
theorem rpow_left_bijective {x : ℝ} (hx : x ≠ 0) : Function.Bijective fun y : ℝ≥0 => y ^ x :=
⟨rpow_left_injective hx, rpow_left_surjective hx⟩
theorem eq_rpow_inv_iff {x y : ℝ≥0} {z : ℝ} (hz : z ≠ 0) : x = y ^ z⁻¹ ↔ x ^ z = y := by
rw [← rpow_eq_rpow_iff hz, ← one_div, rpow_self_rpow_inv hz]
@[deprecated eq_rpow_inv_iff (since := "2024-07-10")]
theorem eq_rpow_one_div_iff {x y : ℝ≥0} {z : ℝ} (hz : z ≠ 0) : x = y ^ (1 / z) ↔ x ^ z = y := by
rw [← rpow_eq_rpow_iff hz, rpow_self_rpow_inv hz]
theorem rpow_inv_eq_iff {x y : ℝ≥0} {z : ℝ} (hz : z ≠ 0) : x ^ z⁻¹ = y ↔ x = y ^ z := by
rw [← rpow_eq_rpow_iff hz, ← one_div, rpow_self_rpow_inv hz]
@[deprecated rpow_inv_eq_iff (since := "2024-07-10")]
theorem rpow_one_div_eq_iff {x y : ℝ≥0} {z : ℝ} (hz : z ≠ 0) : x ^ (1 / z) = y ↔ x = y ^ z := by
rw [← rpow_eq_rpow_iff hz, rpow_self_rpow_inv hz]
@[simp] lemma rpow_rpow_inv {y : ℝ} (hy : y ≠ 0) (x : ℝ≥0) : (x ^ y) ^ y⁻¹ = x := by
rw [← rpow_mul, mul_inv_cancel hy, rpow_one]
@[simp] lemma rpow_inv_rpow {y : ℝ} (hy : y ≠ 0) (x : ℝ≥0) : (x ^ y⁻¹) ^ y = x := by
rw [← rpow_mul, inv_mul_cancel hy, rpow_one]
theorem pow_rpow_inv_natCast (x : ℝ≥0) {n : ℕ} (hn : n ≠ 0) : (x ^ n) ^ (n⁻¹ : ℝ) = x := by
rw [← NNReal.coe_inj, coe_rpow, NNReal.coe_pow]
exact Real.pow_rpow_inv_natCast x.2 hn
theorem rpow_inv_natCast_pow (x : ℝ≥0) {n : ℕ} (hn : n ≠ 0) : (x ^ (n⁻¹ : ℝ)) ^ n = x := by
rw [← NNReal.coe_inj, NNReal.coe_pow, coe_rpow]
exact Real.rpow_inv_natCast_pow x.2 hn
theorem _root_.Real.toNNReal_rpow_of_nonneg {x y : ℝ} (hx : 0 ≤ x) :
Real.toNNReal (x ^ y) = Real.toNNReal x ^ y := by
nth_rw 1 [← Real.coe_toNNReal x hx]
rw [← NNReal.coe_rpow, Real.toNNReal_coe]
theorem strictMono_rpow_of_pos {z : ℝ} (h : 0 < z) : StrictMono fun x : ℝ≥0 => x ^ z :=
fun x y hxy => by simp only [NNReal.rpow_lt_rpow hxy h, coe_lt_coe]
theorem monotone_rpow_of_nonneg {z : ℝ} (h : 0 ≤ z) : Monotone fun x : ℝ≥0 => x ^ z :=
h.eq_or_lt.elim (fun h0 => h0 ▸ by simp only [rpow_zero, monotone_const]) fun h0 =>
(strictMono_rpow_of_pos h0).monotone
/-- Bundles `fun x : ℝ≥0 => x ^ y` into an order isomorphism when `y : ℝ` is positive,
where the inverse is `fun x : ℝ≥0 => x ^ (1 / y)`. -/
@[simps! apply]
def orderIsoRpow (y : ℝ) (hy : 0 < y) : ℝ≥0 ≃o ℝ≥0 :=
(strictMono_rpow_of_pos hy).orderIsoOfRightInverse (fun x => x ^ y) (fun x => x ^ (1 / y))
fun x => by
dsimp
rw [← rpow_mul, one_div_mul_cancel hy.ne.symm, rpow_one]
theorem orderIsoRpow_symm_eq (y : ℝ) (hy : 0 < y) :
(orderIsoRpow y hy).symm = orderIsoRpow (1 / y) (one_div_pos.2 hy) := by
simp only [orderIsoRpow, one_div_one_div]; rfl
theorem _root_.Real.nnnorm_rpow_of_nonneg {x y : ℝ} (hx : 0 ≤ x) : ‖x ^ y‖₊ = ‖x‖₊ ^ y := by
ext; exact Real.norm_rpow_of_nonneg hx
end NNReal
namespace ENNReal
/-- The real power function `x^y` on extended nonnegative reals, defined for `x : ℝ≥0∞` and
`y : ℝ` as the restriction of the real power function if `0 < x < ⊤`, and with the natural values
for `0` and `⊤` (i.e., `0 ^ x = 0` for `x > 0`, `1` for `x = 0` and `⊤` for `x < 0`, and
`⊤ ^ x = 1 / 0 ^ x`). -/
noncomputable def rpow : ℝ≥0∞ → ℝ → ℝ≥0∞
| some x, y => if x = 0 ∧ y < 0 then ⊤ else (x ^ y : ℝ≥0)
| none, y => if 0 < y then ⊤ else if y = 0 then 1 else 0
noncomputable instance : Pow ℝ≥0∞ ℝ :=
⟨rpow⟩
@[simp]
theorem rpow_eq_pow (x : ℝ≥0∞) (y : ℝ) : rpow x y = x ^ y :=
rfl
@[simp]
theorem rpow_zero {x : ℝ≥0∞} : x ^ (0 : ℝ) = 1 := by
cases x <;>
· dsimp only [(· ^ ·), Pow.pow, rpow]
simp [lt_irrefl]
theorem top_rpow_def (y : ℝ) : (⊤ : ℝ≥0∞) ^ y = if 0 < y then ⊤ else if y = 0 then 1 else 0 :=
rfl
@[simp]
theorem top_rpow_of_pos {y : ℝ} (h : 0 < y) : (⊤ : ℝ≥0∞) ^ y = ⊤ := by simp [top_rpow_def, h]
@[simp]
theorem top_rpow_of_neg {y : ℝ} (h : y < 0) : (⊤ : ℝ≥0∞) ^ y = 0 := by
simp [top_rpow_def, asymm h, ne_of_lt h]
@[simp]
theorem zero_rpow_of_pos {y : ℝ} (h : 0 < y) : (0 : ℝ≥0∞) ^ y = 0 := by
rw [← ENNReal.coe_zero, ← ENNReal.some_eq_coe]
dsimp only [(· ^ ·), rpow, Pow.pow]
simp [h, asymm h, ne_of_gt h]
@[simp]
theorem zero_rpow_of_neg {y : ℝ} (h : y < 0) : (0 : ℝ≥0∞) ^ y = ⊤ := by
rw [← ENNReal.coe_zero, ← ENNReal.some_eq_coe]
dsimp only [(· ^ ·), rpow, Pow.pow]
simp [h, ne_of_gt h]
theorem zero_rpow_def (y : ℝ) : (0 : ℝ≥0∞) ^ y = if 0 < y then 0 else if y = 0 then 1 else ⊤ := by
rcases lt_trichotomy (0 : ℝ) y with (H | rfl | H)
· simp [H, ne_of_gt, zero_rpow_of_pos, lt_irrefl]
· simp [lt_irrefl]
· simp [H, asymm H, ne_of_lt, zero_rpow_of_neg]
@[simp]
theorem zero_rpow_mul_self (y : ℝ) : (0 : ℝ≥0∞) ^ y * (0 : ℝ≥0∞) ^ y = (0 : ℝ≥0∞) ^ y := by
rw [zero_rpow_def]
split_ifs
exacts [zero_mul _, one_mul _, top_mul_top]
@[norm_cast]
theorem coe_rpow_of_ne_zero {x : ℝ≥0} (h : x ≠ 0) (y : ℝ) : (x : ℝ≥0∞) ^ y = (x ^ y : ℝ≥0) := by
rw [← ENNReal.some_eq_coe]
dsimp only [(· ^ ·), Pow.pow, rpow]
simp [h]
@[norm_cast]
theorem coe_rpow_of_nonneg (x : ℝ≥0) {y : ℝ} (h : 0 ≤ y) : (x : ℝ≥0∞) ^ y = (x ^ y : ℝ≥0) := by
by_cases hx : x = 0
· rcases le_iff_eq_or_lt.1 h with (H | H)
· simp [hx, H.symm]
· simp [hx, zero_rpow_of_pos H, NNReal.zero_rpow (ne_of_gt H)]
· exact coe_rpow_of_ne_zero hx _
theorem coe_rpow_def (x : ℝ≥0) (y : ℝ) :
(x : ℝ≥0∞) ^ y = if x = 0 ∧ y < 0 then ⊤ else ↑(x ^ y) :=
rfl
@[simp]
theorem rpow_one (x : ℝ≥0∞) : x ^ (1 : ℝ) = x := by
cases x
· exact dif_pos zero_lt_one
· change ite _ _ _ = _
simp only [NNReal.rpow_one, some_eq_coe, ite_eq_right_iff, top_ne_coe, and_imp]
exact fun _ => zero_le_one.not_lt
@[simp]
theorem one_rpow (x : ℝ) : (1 : ℝ≥0∞) ^ x = 1 := by
rw [← coe_one, coe_rpow_of_ne_zero one_ne_zero]
simp
@[simp]
theorem rpow_eq_zero_iff {x : ℝ≥0∞} {y : ℝ} : x ^ y = 0 ↔ x = 0 ∧ 0 < y ∨ x = ⊤ ∧ y < 0 := by
cases' x with x
· rcases lt_trichotomy y 0 with (H | H | H) <;>
simp [H, top_rpow_of_neg, top_rpow_of_pos, le_of_lt]
· by_cases h : x = 0
· rcases lt_trichotomy y 0 with (H | H | H) <;>
simp [h, H, zero_rpow_of_neg, zero_rpow_of_pos, le_of_lt]
· simp [coe_rpow_of_ne_zero h, h]
lemma rpow_eq_zero_iff_of_pos {x : ℝ≥0∞} {y : ℝ} (hy : 0 < y) : x ^ y = 0 ↔ x = 0 := by
simp [hy, hy.not_lt]
@[simp]
theorem rpow_eq_top_iff {x : ℝ≥0∞} {y : ℝ} : x ^ y = ⊤ ↔ x = 0 ∧ y < 0 ∨ x = ⊤ ∧ 0 < y := by
cases' x with x
· rcases lt_trichotomy y 0 with (H | H | H) <;>
simp [H, top_rpow_of_neg, top_rpow_of_pos, le_of_lt]
· by_cases h : x = 0
· rcases lt_trichotomy y 0 with (H | H | H) <;>
simp [h, H, zero_rpow_of_neg, zero_rpow_of_pos, le_of_lt]
· simp [coe_rpow_of_ne_zero h, h]
theorem rpow_eq_top_iff_of_pos {x : ℝ≥0∞} {y : ℝ} (hy : 0 < y) : x ^ y = ⊤ ↔ x = ⊤ := by
simp [rpow_eq_top_iff, hy, asymm hy]
lemma rpow_lt_top_iff_of_pos {x : ℝ≥0∞} {y : ℝ} (hy : 0 < y) : x ^ y < ∞ ↔ x < ∞ := by
simp only [lt_top_iff_ne_top, Ne, rpow_eq_top_iff_of_pos hy]
theorem rpow_eq_top_of_nonneg (x : ℝ≥0∞) {y : ℝ} (hy0 : 0 ≤ y) : x ^ y = ⊤ → x = ⊤ := by
rw [ENNReal.rpow_eq_top_iff]
rintro (h|h)
· exfalso
rw [lt_iff_not_ge] at h
exact h.right hy0
· exact h.left
theorem rpow_ne_top_of_nonneg {x : ℝ≥0∞} {y : ℝ} (hy0 : 0 ≤ y) (h : x ≠ ⊤) : x ^ y ≠ ⊤ :=
mt (ENNReal.rpow_eq_top_of_nonneg x hy0) h
theorem rpow_lt_top_of_nonneg {x : ℝ≥0∞} {y : ℝ} (hy0 : 0 ≤ y) (h : x ≠ ⊤) : x ^ y < ⊤ :=
lt_top_iff_ne_top.mpr (ENNReal.rpow_ne_top_of_nonneg hy0 h)
theorem rpow_add {x : ℝ≥0∞} (y z : ℝ) (hx : x ≠ 0) (h'x : x ≠ ⊤) : x ^ (y + z) = x ^ y * x ^ z := by
cases' x with x
· exact (h'x rfl).elim
have : x ≠ 0 := fun h => by simp [h] at hx
simp [coe_rpow_of_ne_zero this, NNReal.rpow_add this]
theorem rpow_add_of_nonneg {x : ℝ≥0∞} (y z : ℝ) (hy : 0 ≤ y) (hz : 0 ≤ z) :
x ^ (y + z) = x ^ y * x ^ z := by
induction x using recTopCoe
· rcases hy.eq_or_lt with rfl|hy
· rw [rpow_zero, one_mul, zero_add]
rcases hz.eq_or_lt with rfl|hz
· rw [rpow_zero, mul_one, add_zero]
simp [top_rpow_of_pos, hy, hz, add_pos hy hz]
simp [coe_rpow_of_nonneg, hy, hz, add_nonneg hy hz, NNReal.rpow_add_of_nonneg _ hy hz]
theorem rpow_neg (x : ℝ≥0∞) (y : ℝ) : x ^ (-y) = (x ^ y)⁻¹ := by
cases' x with x
· rcases lt_trichotomy y 0 with (H | H | H) <;>
simp [top_rpow_of_pos, top_rpow_of_neg, H, neg_pos.mpr]
· by_cases h : x = 0
· rcases lt_trichotomy y 0 with (H | H | H) <;>
simp [h, zero_rpow_of_pos, zero_rpow_of_neg, H, neg_pos.mpr]
· have A : x ^ y ≠ 0 := by simp [h]
simp [coe_rpow_of_ne_zero h, ← coe_inv A, NNReal.rpow_neg]
theorem rpow_sub {x : ℝ≥0∞} (y z : ℝ) (hx : x ≠ 0) (h'x : x ≠ ⊤) : x ^ (y - z) = x ^ y / x ^ z := by
rw [sub_eq_add_neg, rpow_add _ _ hx h'x, rpow_neg, div_eq_mul_inv]
theorem rpow_neg_one (x : ℝ≥0∞) : x ^ (-1 : ℝ) = x⁻¹ := by simp [rpow_neg]
theorem rpow_mul (x : ℝ≥0∞) (y z : ℝ) : x ^ (y * z) = (x ^ y) ^ z := by
cases' x with x
· rcases lt_trichotomy y 0 with (Hy | Hy | Hy) <;>
rcases lt_trichotomy z 0 with (Hz | Hz | Hz) <;>
simp [Hy, Hz, zero_rpow_of_neg, zero_rpow_of_pos, top_rpow_of_neg, top_rpow_of_pos,
mul_pos_of_neg_of_neg, mul_neg_of_neg_of_pos, mul_neg_of_pos_of_neg]
· by_cases h : x = 0
· rcases lt_trichotomy y 0 with (Hy | Hy | Hy) <;>
rcases lt_trichotomy z 0 with (Hz | Hz | Hz) <;>
simp [h, Hy, Hz, zero_rpow_of_neg, zero_rpow_of_pos, top_rpow_of_neg, top_rpow_of_pos,
mul_pos_of_neg_of_neg, mul_neg_of_neg_of_pos, mul_neg_of_pos_of_neg]
· have : x ^ y ≠ 0 := by simp [h]
simp [coe_rpow_of_ne_zero h, coe_rpow_of_ne_zero this, NNReal.rpow_mul]
@[simp, norm_cast]
theorem rpow_natCast (x : ℝ≥0∞) (n : ℕ) : x ^ (n : ℝ) = x ^ n := by
cases x
· cases n <;> simp [top_rpow_of_pos (Nat.cast_add_one_pos _), top_pow (Nat.succ_pos _)]
· simp [coe_rpow_of_nonneg _ (Nat.cast_nonneg n)]
@[deprecated (since := "2024-04-17")]
alias rpow_nat_cast := rpow_natCast
@[simp]
lemma rpow_ofNat (x : ℝ≥0∞) (n : ℕ) [n.AtLeastTwo] :
x ^ (no_index (OfNat.ofNat n) : ℝ) = x ^ (OfNat.ofNat n) :=
rpow_natCast x n
@[simp, norm_cast]
lemma rpow_intCast (x : ℝ≥0∞) (n : ℤ) : x ^ (n : ℝ) = x ^ n := by
cases n <;> simp only [Int.ofNat_eq_coe, Int.cast_natCast, rpow_natCast, zpow_natCast,
Int.cast_negSucc, rpow_neg, zpow_negSucc]
@[deprecated (since := "2024-04-17")]
alias rpow_int_cast := rpow_intCast
theorem rpow_two (x : ℝ≥0∞) : x ^ (2 : ℝ) = x ^ 2 := rpow_ofNat x 2
theorem mul_rpow_eq_ite (x y : ℝ≥0∞) (z : ℝ) :
(x * y) ^ z = if (x = 0 ∧ y = ⊤ ∨ x = ⊤ ∧ y = 0) ∧ z < 0 then ⊤ else x ^ z * y ^ z := by
rcases eq_or_ne z 0 with (rfl | hz); · simp
replace hz := hz.lt_or_lt
wlog hxy : x ≤ y
· convert this y x z hz (le_of_not_le hxy) using 2 <;> simp only [mul_comm, and_comm, or_comm]
rcases eq_or_ne x 0 with (rfl | hx0)
· induction y <;> cases' hz with hz hz <;> simp [*, hz.not_lt]
rcases eq_or_ne y 0 with (rfl | hy0)
· exact (hx0 (bot_unique hxy)).elim
induction x
· cases' hz with hz hz <;> simp [hz, top_unique hxy]
induction y
· rw [ne_eq, coe_eq_zero] at hx0
cases' hz with hz hz <;> simp [*]
simp only [*, false_and_iff, and_false_iff, false_or_iff, if_false]
norm_cast at *
rw [coe_rpow_of_ne_zero (mul_ne_zero hx0 hy0), NNReal.mul_rpow]
norm_cast
theorem mul_rpow_of_ne_top {x y : ℝ≥0∞} (hx : x ≠ ⊤) (hy : y ≠ ⊤) (z : ℝ) :
(x * y) ^ z = x ^ z * y ^ z := by simp [*, mul_rpow_eq_ite]
@[norm_cast]
theorem coe_mul_rpow (x y : ℝ≥0) (z : ℝ) : ((x : ℝ≥0∞) * y) ^ z = (x : ℝ≥0∞) ^ z * (y : ℝ≥0∞) ^ z :=
mul_rpow_of_ne_top coe_ne_top coe_ne_top z
theorem prod_coe_rpow {ι} (s : Finset ι) (f : ι → ℝ≥0) (r : ℝ) :
∏ i ∈ s, (f i : ℝ≥0∞) ^ r = ((∏ i ∈ s, f i : ℝ≥0) : ℝ≥0∞) ^ r := by
induction s using Finset.induction with
| empty => simp
| insert hi ih => simp_rw [prod_insert hi, ih, ← coe_mul_rpow, coe_mul]
theorem mul_rpow_of_ne_zero {x y : ℝ≥0∞} (hx : x ≠ 0) (hy : y ≠ 0) (z : ℝ) :
(x * y) ^ z = x ^ z * y ^ z := by simp [*, mul_rpow_eq_ite]
theorem mul_rpow_of_nonneg (x y : ℝ≥0∞) {z : ℝ} (hz : 0 ≤ z) : (x * y) ^ z = x ^ z * y ^ z := by
simp [hz.not_lt, mul_rpow_eq_ite]
theorem prod_rpow_of_ne_top {ι} {s : Finset ι} {f : ι → ℝ≥0∞} (hf : ∀ i ∈ s, f i ≠ ∞) (r : ℝ) :
∏ i ∈ s, f i ^ r = (∏ i ∈ s, f i) ^ r := by
induction s using Finset.induction with
| empty => simp
| @insert i s hi ih =>
have h2f : ∀ i ∈ s, f i ≠ ∞ := fun i hi ↦ hf i <| mem_insert_of_mem hi
rw [prod_insert hi, prod_insert hi, ih h2f, ← mul_rpow_of_ne_top <| hf i <| mem_insert_self ..]
apply prod_lt_top h2f |>.ne
theorem prod_rpow_of_nonneg {ι} {s : Finset ι} {f : ι → ℝ≥0∞} {r : ℝ} (hr : 0 ≤ r) :
∏ i ∈ s, f i ^ r = (∏ i ∈ s, f i) ^ r := by
induction s using Finset.induction with
| empty => simp
| insert hi ih => simp_rw [prod_insert hi, ih, ← mul_rpow_of_nonneg _ _ hr]
theorem inv_rpow (x : ℝ≥0∞) (y : ℝ) : x⁻¹ ^ y = (x ^ y)⁻¹ := by
rcases eq_or_ne y 0 with (rfl | hy); · simp only [rpow_zero, inv_one]
replace hy := hy.lt_or_lt
rcases eq_or_ne x 0 with (rfl | h0); · cases hy <;> simp [*]
rcases eq_or_ne x ⊤ with (rfl | h_top); · cases hy <;> simp [*]
apply ENNReal.eq_inv_of_mul_eq_one_left
rw [← mul_rpow_of_ne_zero (ENNReal.inv_ne_zero.2 h_top) h0, ENNReal.inv_mul_cancel h0 h_top,
one_rpow]
theorem div_rpow_of_nonneg (x y : ℝ≥0∞) {z : ℝ} (hz : 0 ≤ z) : (x / y) ^ z = x ^ z / y ^ z := by
rw [div_eq_mul_inv, mul_rpow_of_nonneg _ _ hz, inv_rpow, div_eq_mul_inv]
theorem strictMono_rpow_of_pos {z : ℝ} (h : 0 < z) : StrictMono fun x : ℝ≥0∞ => x ^ z := by
intro x y hxy
lift x to ℝ≥0 using ne_top_of_lt hxy
rcases eq_or_ne y ∞ with (rfl | hy)
· simp only [top_rpow_of_pos h, coe_rpow_of_nonneg _ h.le, coe_lt_top]
· lift y to ℝ≥0 using hy
simp only [coe_rpow_of_nonneg _ h.le, NNReal.rpow_lt_rpow (coe_lt_coe.1 hxy) h, coe_lt_coe]
theorem monotone_rpow_of_nonneg {z : ℝ} (h : 0 ≤ z) : Monotone fun x : ℝ≥0∞ => x ^ z :=
h.eq_or_lt.elim (fun h0 => h0 ▸ by simp only [rpow_zero, monotone_const]) fun h0 =>
(strictMono_rpow_of_pos h0).monotone
/-- Bundles `fun x : ℝ≥0∞ => x ^ y` into an order isomorphism when `y : ℝ` is positive,
where the inverse is `fun x : ℝ≥0∞ => x ^ (1 / y)`. -/
@[simps! apply]
def orderIsoRpow (y : ℝ) (hy : 0 < y) : ℝ≥0∞ ≃o ℝ≥0∞ :=
(strictMono_rpow_of_pos hy).orderIsoOfRightInverse (fun x => x ^ y) (fun x => x ^ (1 / y))
fun x => by
dsimp
rw [← rpow_mul, one_div_mul_cancel hy.ne.symm, rpow_one]
theorem orderIsoRpow_symm_apply (y : ℝ) (hy : 0 < y) :
(orderIsoRpow y hy).symm = orderIsoRpow (1 / y) (one_div_pos.2 hy) := by
simp only [orderIsoRpow, one_div_one_div]
rfl
@[gcongr] theorem rpow_le_rpow {x y : ℝ≥0∞} {z : ℝ} (h₁ : x ≤ y) (h₂ : 0 ≤ z) : x ^ z ≤ y ^ z :=
monotone_rpow_of_nonneg h₂ h₁
@[gcongr] theorem rpow_lt_rpow {x y : ℝ≥0∞} {z : ℝ} (h₁ : x < y) (h₂ : 0 < z) : x ^ z < y ^ z :=
strictMono_rpow_of_pos h₂ h₁
theorem rpow_le_rpow_iff {x y : ℝ≥0∞} {z : ℝ} (hz : 0 < z) : x ^ z ≤ y ^ z ↔ x ≤ y :=
(strictMono_rpow_of_pos hz).le_iff_le
theorem rpow_lt_rpow_iff {x y : ℝ≥0∞} {z : ℝ} (hz : 0 < z) : x ^ z < y ^ z ↔ x < y :=
(strictMono_rpow_of_pos hz).lt_iff_lt
theorem le_rpow_inv_iff {x y : ℝ≥0∞} {z : ℝ} (hz : 0 < z) : x ≤ y ^ z⁻¹ ↔ x ^ z ≤ y := by
nth_rw 1 [← rpow_one x]
nth_rw 1 [← @_root_.mul_inv_cancel _ _ z hz.ne']
rw [rpow_mul, @rpow_le_rpow_iff _ _ z⁻¹ (by simp [hz])]
@[deprecated le_rpow_inv_iff (since := "2024-07-10")]
theorem le_rpow_one_div_iff {x y : ℝ≥0∞} {z : ℝ} (hz : 0 < z) : x ≤ y ^ (1 / z) ↔ x ^ z ≤ y := by
nth_rw 1 [← rpow_one x]
nth_rw 1 [← @_root_.mul_inv_cancel _ _ z hz.ne']
rw [rpow_mul, ← one_div, @rpow_le_rpow_iff _ _ (1 / z) (by simp [hz])]
theorem rpow_inv_lt_iff {x y : ℝ≥0∞} {z : ℝ} (hz : 0 < z) : x ^ z⁻¹ < y ↔ x < y ^ z := by
simp only [← not_le, le_rpow_inv_iff hz]
theorem lt_rpow_inv_iff {x y : ℝ≥0∞} {z : ℝ} (hz : 0 < z) : x < y ^ z⁻¹ ↔ x ^ z < y := by
nth_rw 1 [← rpow_one x]
nth_rw 1 [← @_root_.mul_inv_cancel _ _ z (ne_of_lt hz).symm]
rw [rpow_mul, @rpow_lt_rpow_iff _ _ z⁻¹ (by simp [hz])]
@[deprecated lt_rpow_inv_iff (since := "2024-07-10")]
theorem lt_rpow_one_div_iff {x y : ℝ≥0∞} {z : ℝ} (hz : 0 < z) : x < y ^ (1 / z) ↔ x ^ z < y := by
nth_rw 1 [← rpow_one x]
nth_rw 1 [← @_root_.mul_inv_cancel _ _ z (ne_of_lt hz).symm]
rw [rpow_mul, ← one_div, @rpow_lt_rpow_iff _ _ (1 / z) (by simp [hz])]
theorem rpow_inv_le_iff {x y : ℝ≥0∞} {z : ℝ} (hz : 0 < z) : x ^ z⁻¹ ≤ y ↔ x ≤ y ^ z := by
nth_rw 1 [← ENNReal.rpow_one y]
nth_rw 1 [← @_root_.mul_inv_cancel _ _ z hz.ne.symm]
rw [ENNReal.rpow_mul, ENNReal.rpow_le_rpow_iff (inv_pos.2 hz)]
@[deprecated rpow_inv_le_iff (since := "2024-07-10")]
theorem rpow_one_div_le_iff {x y : ℝ≥0∞} {z : ℝ} (hz : 0 < z) : x ^ (1 / z) ≤ y ↔ x ≤ y ^ z := by
nth_rw 1 [← ENNReal.rpow_one y]
nth_rw 2 [← @_root_.mul_inv_cancel _ _ z hz.ne.symm]
rw [ENNReal.rpow_mul, ← one_div, ENNReal.rpow_le_rpow_iff (one_div_pos.2 hz)]
theorem rpow_lt_rpow_of_exponent_lt {x : ℝ≥0∞} {y z : ℝ} (hx : 1 < x) (hx' : x ≠ ⊤) (hyz : y < z) :
x ^ y < x ^ z := by
lift x to ℝ≥0 using hx'
rw [one_lt_coe_iff] at hx
simp [coe_rpow_of_ne_zero (ne_of_gt (lt_trans zero_lt_one hx)),
NNReal.rpow_lt_rpow_of_exponent_lt hx hyz]
@[gcongr] theorem rpow_le_rpow_of_exponent_le {x : ℝ≥0∞} {y z : ℝ} (hx : 1 ≤ x) (hyz : y ≤ z) :
x ^ y ≤ x ^ z := by
cases x
· rcases lt_trichotomy y 0 with (Hy | Hy | Hy) <;>
rcases lt_trichotomy z 0 with (Hz | Hz | Hz) <;>
simp [Hy, Hz, top_rpow_of_neg, top_rpow_of_pos, le_refl] <;>
linarith
· simp only [one_le_coe_iff, some_eq_coe] at hx
simp [coe_rpow_of_ne_zero (ne_of_gt (lt_of_lt_of_le zero_lt_one hx)),
NNReal.rpow_le_rpow_of_exponent_le hx hyz]
theorem rpow_lt_rpow_of_exponent_gt {x : ℝ≥0∞} {y z : ℝ} (hx0 : 0 < x) (hx1 : x < 1) (hyz : z < y) :
x ^ y < x ^ z := by
lift x to ℝ≥0 using ne_of_lt (lt_of_lt_of_le hx1 le_top)
simp only [coe_lt_one_iff, coe_pos] at hx0 hx1
simp [coe_rpow_of_ne_zero (ne_of_gt hx0), NNReal.rpow_lt_rpow_of_exponent_gt hx0 hx1 hyz]
theorem rpow_le_rpow_of_exponent_ge {x : ℝ≥0∞} {y z : ℝ} (hx1 : x ≤ 1) (hyz : z ≤ y) :
x ^ y ≤ x ^ z := by
lift x to ℝ≥0 using ne_of_lt (lt_of_le_of_lt hx1 coe_lt_top)
by_cases h : x = 0
· rcases lt_trichotomy y 0 with (Hy | Hy | Hy) <;>
rcases lt_trichotomy z 0 with (Hz | Hz | Hz) <;>
simp [Hy, Hz, h, zero_rpow_of_neg, zero_rpow_of_pos, le_refl] <;>
linarith
· rw [coe_le_one_iff] at hx1
simp [coe_rpow_of_ne_zero h,
NNReal.rpow_le_rpow_of_exponent_ge (bot_lt_iff_ne_bot.mpr h) hx1 hyz]
theorem rpow_le_self_of_le_one {x : ℝ≥0∞} {z : ℝ} (hx : x ≤ 1) (h_one_le : 1 ≤ z) : x ^ z ≤ x := by
nth_rw 2 [← ENNReal.rpow_one x]
exact ENNReal.rpow_le_rpow_of_exponent_ge hx h_one_le
theorem le_rpow_self_of_one_le {x : ℝ≥0∞} {z : ℝ} (hx : 1 ≤ x) (h_one_le : 1 ≤ z) : x ≤ x ^ z := by
nth_rw 1 [← ENNReal.rpow_one x]
exact ENNReal.rpow_le_rpow_of_exponent_le hx h_one_le
theorem rpow_pos_of_nonneg {p : ℝ} {x : ℝ≥0∞} (hx_pos : 0 < x) (hp_nonneg : 0 ≤ p) : 0 < x ^ p := by
by_cases hp_zero : p = 0
· simp [hp_zero, zero_lt_one]
· rw [← Ne] at hp_zero
have hp_pos := lt_of_le_of_ne hp_nonneg hp_zero.symm
rw [← zero_rpow_of_pos hp_pos]
exact rpow_lt_rpow hx_pos hp_pos
theorem rpow_pos {p : ℝ} {x : ℝ≥0∞} (hx_pos : 0 < x) (hx_ne_top : x ≠ ⊤) : 0 < x ^ p := by
cases' lt_or_le 0 p with hp_pos hp_nonpos
· exact rpow_pos_of_nonneg hx_pos (le_of_lt hp_pos)
· rw [← neg_neg p, rpow_neg, ENNReal.inv_pos]
exact rpow_ne_top_of_nonneg (Right.nonneg_neg_iff.mpr hp_nonpos) hx_ne_top
theorem rpow_lt_one {x : ℝ≥0∞} {z : ℝ} (hx : x < 1) (hz : 0 < z) : x ^ z < 1 := by
lift x to ℝ≥0 using ne_of_lt (lt_of_lt_of_le hx le_top)
simp only [coe_lt_one_iff] at hx
simp [coe_rpow_of_nonneg _ (le_of_lt hz), NNReal.rpow_lt_one hx hz]
theorem rpow_le_one {x : ℝ≥0∞} {z : ℝ} (hx : x ≤ 1) (hz : 0 ≤ z) : x ^ z ≤ 1 := by
lift x to ℝ≥0 using ne_of_lt (lt_of_le_of_lt hx coe_lt_top)
simp only [coe_le_one_iff] at hx
simp [coe_rpow_of_nonneg _ hz, NNReal.rpow_le_one hx hz]
theorem rpow_lt_one_of_one_lt_of_neg {x : ℝ≥0∞} {z : ℝ} (hx : 1 < x) (hz : z < 0) : x ^ z < 1 := by
cases x
· simp [top_rpow_of_neg hz, zero_lt_one]
· simp only [some_eq_coe, one_lt_coe_iff] at hx
simp [coe_rpow_of_ne_zero (ne_of_gt (lt_trans zero_lt_one hx)),
NNReal.rpow_lt_one_of_one_lt_of_neg hx hz]
theorem rpow_le_one_of_one_le_of_neg {x : ℝ≥0∞} {z : ℝ} (hx : 1 ≤ x) (hz : z < 0) : x ^ z ≤ 1 := by
cases x
· simp [top_rpow_of_neg hz, zero_lt_one]
· simp only [one_le_coe_iff, some_eq_coe] at hx
simp [coe_rpow_of_ne_zero (ne_of_gt (lt_of_lt_of_le zero_lt_one hx)),
NNReal.rpow_le_one_of_one_le_of_nonpos hx (le_of_lt hz)]
theorem one_lt_rpow {x : ℝ≥0∞} {z : ℝ} (hx : 1 < x) (hz : 0 < z) : 1 < x ^ z := by
cases x
· simp [top_rpow_of_pos hz]
· simp only [some_eq_coe, one_lt_coe_iff] at hx
simp [coe_rpow_of_nonneg _ (le_of_lt hz), NNReal.one_lt_rpow hx hz]
theorem one_le_rpow {x : ℝ≥0∞} {z : ℝ} (hx : 1 ≤ x) (hz : 0 < z) : 1 ≤ x ^ z := by
cases x
· simp [top_rpow_of_pos hz]
· simp only [one_le_coe_iff, some_eq_coe] at hx
simp [coe_rpow_of_nonneg _ (le_of_lt hz), NNReal.one_le_rpow hx (le_of_lt hz)]
theorem one_lt_rpow_of_pos_of_lt_one_of_neg {x : ℝ≥0∞} {z : ℝ} (hx1 : 0 < x) (hx2 : x < 1)
(hz : z < 0) : 1 < x ^ z := by
lift x to ℝ≥0 using ne_of_lt (lt_of_lt_of_le hx2 le_top)
simp only [coe_lt_one_iff, coe_pos] at hx1 hx2 ⊢
simp [coe_rpow_of_ne_zero (ne_of_gt hx1), NNReal.one_lt_rpow_of_pos_of_lt_one_of_neg hx1 hx2 hz]
theorem one_le_rpow_of_pos_of_le_one_of_neg {x : ℝ≥0∞} {z : ℝ} (hx1 : 0 < x) (hx2 : x ≤ 1)
(hz : z < 0) : 1 ≤ x ^ z := by
lift x to ℝ≥0 using ne_of_lt (lt_of_le_of_lt hx2 coe_lt_top)
simp only [coe_le_one_iff, coe_pos] at hx1 hx2 ⊢
simp [coe_rpow_of_ne_zero (ne_of_gt hx1),
NNReal.one_le_rpow_of_pos_of_le_one_of_nonpos hx1 hx2 (le_of_lt hz)]
theorem toNNReal_rpow (x : ℝ≥0∞) (z : ℝ) : x.toNNReal ^ z = (x ^ z).toNNReal := by
rcases lt_trichotomy z 0 with (H | H | H)
· cases' x with x
· simp [H, ne_of_lt]
by_cases hx : x = 0
· simp [hx, H, ne_of_lt]
· simp [coe_rpow_of_ne_zero hx]
· simp [H]
· cases x
· simp [H, ne_of_gt]
simp [coe_rpow_of_nonneg _ (le_of_lt H)]
theorem toReal_rpow (x : ℝ≥0∞) (z : ℝ) : x.toReal ^ z = (x ^ z).toReal := by
rw [ENNReal.toReal, ENNReal.toReal, ← NNReal.coe_rpow, ENNReal.toNNReal_rpow]
theorem ofReal_rpow_of_pos {x p : ℝ} (hx_pos : 0 < x) :
ENNReal.ofReal x ^ p = ENNReal.ofReal (x ^ p) := by
simp_rw [ENNReal.ofReal]
rw [coe_rpow_of_ne_zero, coe_inj, Real.toNNReal_rpow_of_nonneg hx_pos.le]
simp [hx_pos]
theorem ofReal_rpow_of_nonneg {x p : ℝ} (hx_nonneg : 0 ≤ x) (hp_nonneg : 0 ≤ p) :
ENNReal.ofReal x ^ p = ENNReal.ofReal (x ^ p) := by
by_cases hp0 : p = 0
· simp [hp0]
by_cases hx0 : x = 0
· rw [← Ne] at hp0
have hp_pos : 0 < p := lt_of_le_of_ne hp_nonneg hp0.symm
simp [hx0, hp_pos, hp_pos.ne.symm]
rw [← Ne] at hx0
exact ofReal_rpow_of_pos (hx_nonneg.lt_of_ne hx0.symm)
@[simp] lemma rpow_rpow_inv {y : ℝ} (hy : y ≠ 0) (x : ℝ≥0∞) : (x ^ y) ^ y⁻¹ = x := by
rw [← rpow_mul, mul_inv_cancel hy, rpow_one]
@[simp] lemma rpow_inv_rpow {y : ℝ} (hy : y ≠ 0) (x : ℝ≥0∞) : (x ^ y⁻¹) ^ y = x := by
rw [← rpow_mul, inv_mul_cancel hy, rpow_one]
lemma pow_rpow_inv_natCast {n : ℕ} (hn : n ≠ 0) (x : ℝ≥0∞) : (x ^ n) ^ (n⁻¹ : ℝ) = x := by
rw [← rpow_natCast, ← rpow_mul, mul_inv_cancel (by positivity), rpow_one]
lemma rpow_inv_natCast_pow {n : ℕ} (hn : n ≠ 0) (x : ℝ≥0∞) : (x ^ (n⁻¹ : ℝ)) ^ n = x := by
rw [← rpow_natCast, ← rpow_mul, inv_mul_cancel (by positivity), rpow_one]
lemma rpow_natCast_mul (x : ℝ≥0∞) (n : ℕ) (z : ℝ) : x ^ (n * z) = (x ^ n) ^ z := by
rw [rpow_mul, rpow_natCast]
lemma rpow_mul_natCast (x : ℝ≥0∞) (y : ℝ) (n : ℕ) : x ^ (y * n) = (x ^ y) ^ n := by
rw [rpow_mul, rpow_natCast]
lemma rpow_intCast_mul (x : ℝ≥0∞) (n : ℤ) (z : ℝ) : x ^ (n * z) = (x ^ n) ^ z := by
rw [rpow_mul, rpow_intCast]
lemma rpow_mul_intCast (x : ℝ≥0∞) (y : ℝ) (n : ℤ) : x ^ (y * n) = (x ^ y) ^ n := by
rw [rpow_mul, rpow_intCast]
lemma rpow_left_injective {x : ℝ} (hx : x ≠ 0) : Injective fun y : ℝ≥0∞ ↦ y ^ x :=
HasLeftInverse.injective ⟨fun y ↦ y ^ x⁻¹, rpow_rpow_inv hx⟩
theorem rpow_left_surjective {x : ℝ} (hx : x ≠ 0) : Function.Surjective fun y : ℝ≥0∞ => y ^ x :=
HasRightInverse.surjective ⟨fun y ↦ y ^ x⁻¹, rpow_inv_rpow hx⟩
theorem rpow_left_bijective {x : ℝ} (hx : x ≠ 0) : Function.Bijective fun y : ℝ≥0∞ => y ^ x :=
⟨rpow_left_injective hx, rpow_left_surjective hx⟩
end ENNReal
-- Porting note(https://github.com/leanprover-community/mathlib4/issues/6038): restore
-- section Tactics
-- /-!
-- ## Tactic extensions for powers on `ℝ≥0` and `ℝ≥0∞`
-- -/
-- namespace NormNum
-- theorem nnrpow_pos (a : ℝ≥0) (b : ℝ) (b' : ℕ) (c : ℝ≥0) (hb : b = b') (h : a ^ b' = c) :
-- a ^ b = c := by rw [← h, hb, NNReal.rpow_natCast]
-- theorem nnrpow_neg (a : ℝ≥0) (b : ℝ) (b' : ℕ) (c c' : ℝ≥0) (hb : b = b') (h : a ^ b' = c)
-- (hc : c⁻¹ = c') : a ^ (-b) = c' := by
-- rw [← hc, ← h, hb, NNReal.rpow_neg, NNReal.rpow_natCast]
-- theorem ennrpow_pos (a : ℝ≥0∞) (b : ℝ) (b' : ℕ) (c : ℝ≥0∞) (hb : b = b') (h : a ^ b' = c) :
-- a ^ b = c := by rw [← h, hb, ENNReal.rpow_natCast]
-- theorem ennrpow_neg (a : ℝ≥0∞) (b : ℝ) (b' : ℕ) (c c' : ℝ≥0∞) (hb : b = b') (h : a ^ b' = c)
-- (hc : c⁻¹ = c') : a ^ (-b) = c' := by
-- rw [← hc, ← h, hb, ENNReal.rpow_neg, ENNReal.rpow_natCast]
-- /-- Evaluate `NNReal.rpow a b` where `a` is a rational numeral and `b` is an integer. -/
-- unsafe def prove_nnrpow : expr → expr → tactic (expr × expr) :=
-- prove_rpow' `` nnrpow_pos `` nnrpow_neg `` NNReal.rpow_zero q(ℝ≥0) q(ℝ) q((1 : ℝ≥0))
-- /-- Evaluate `ENNReal.rpow a b` where `a` is a rational numeral and `b` is an integer. -/
-- unsafe def prove_ennrpow : expr → expr → tactic (expr × expr) :=
-- prove_rpow' `` ennrpow_pos `` ennrpow_neg `` ENNReal.rpow_zero q(ℝ≥0∞) q(ℝ) q((1 : ℝ≥0∞))
-- /-- Evaluates expressions of the form `rpow a b` and `a ^ b` in the special case where
-- `b` is an integer and `a` is a positive rational (so it's really just a rational power). -/
-- @[norm_num]
-- unsafe def eval_nnrpow_ennrpow : expr → tactic (expr × expr)
-- | q(@Pow.pow _ _ NNReal.Real.hasPow $(a) $(b)) => b.to_int >> prove_nnrpow a b
-- | q(NNReal.rpow $(a) $(b)) => b.to_int >> prove_nnrpow a b
-- | q(@Pow.pow _ _ ENNReal.Real.hasPow $(a) $(b)) => b.to_int >> prove_ennrpow a b
-- | q(ENNReal.rpow $(a) $(b)) => b.to_int >> prove_ennrpow a b
-- | _ => tactic.failed
-- end NormNum
-- namespace Tactic
-- namespace Positivity
-- private theorem nnrpow_pos {a : ℝ≥0} (ha : 0 < a) (b : ℝ) : 0 < a ^ b :=
-- NNReal.rpow_pos ha
-- /-- Auxiliary definition for the `positivity` tactic to handle real powers of nonnegative reals.
-- -/
-- unsafe def prove_nnrpow (a b : expr) : tactic strictness := do
-- let strictness_a ← core a
-- match strictness_a with
-- | positive p => positive <$> mk_app `` nnrpow_pos [p, b]
-- | _ => failed
-- -- We already know `0 ≤ x` for all `x : ℝ≥0`
-- private theorem ennrpow_pos {a : ℝ≥0∞} {b : ℝ} (ha : 0 < a) (hb : 0 < b) : 0 < a ^ b :=
-- ENNReal.rpow_pos_of_nonneg ha hb.le
-- /-- Auxiliary definition for the `positivity` tactic to handle real powers of extended
-- nonnegative reals. -/
-- unsafe def prove_ennrpow (a b : expr) : tactic strictness := do
-- let strictness_a ← core a
-- let strictness_b ← core b
-- match strictness_a, strictness_b with
-- | positive pa, positive pb => positive <$> mk_app `` ennrpow_pos [pa, pb]
-- | positive pa, nonnegative pb => positive <$> mk_app `` ENNReal.rpow_pos_of_nonneg [pa, pb]
-- | _, _ => failed
-- -- We already know `0 ≤ x` for all `x : ℝ≥0∞`
-- end Positivity
-- open Positivity
-- /-- Extension for the `positivity` tactic: exponentiation by a real number is nonnegative when
-- the base is nonnegative and positive when the base is positive. -/
-- @[positivity]
-- unsafe def positivity_nnrpow_ennrpow : expr → tactic strictness
-- | q(@Pow.pow _ _ NNReal.Real.hasPow $(a) $(b)) => prove_nnrpow a b
-- | q(NNReal.rpow $(a) $(b)) => prove_nnrpow a b
-- | q(@Pow.pow _ _ ENNReal.Real.hasPow $(a) $(b)) => prove_ennrpow a b
-- | q(ENNReal.rpow $(a) $(b)) => prove_ennrpow a b
-- | _ => failed
-- end Tactic
-- end Tactics
|
Analysis\SpecialFunctions\Pow\Real.lean | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Sébastien Gouëzel,
Rémy Degenne, David Loeffler
-/
import Mathlib.Analysis.SpecialFunctions.Pow.Complex
import Qq
/-! # Power function on `ℝ`
We construct the power functions `x ^ y`, where `x` and `y` are real numbers.
-/
noncomputable section
open scoped Classical
open Real ComplexConjugate
open Finset Set
/-
## Definitions
-/
namespace Real
variable {x y z : ℝ}
/-- The real power function `x ^ y`, defined as the real part of the complex power function.
For `x > 0`, it is equal to `exp (y log x)`. For `x = 0`, one sets `0 ^ 0=1` and `0 ^ y=0` for
`y ≠ 0`. For `x < 0`, the definition is somewhat arbitrary as it depends on the choice of a complex
determination of the logarithm. With our conventions, it is equal to `exp (y log x) cos (π y)`. -/
noncomputable def rpow (x y : ℝ) :=
((x : ℂ) ^ (y : ℂ)).re
noncomputable instance : Pow ℝ ℝ := ⟨rpow⟩
@[simp]
theorem rpow_eq_pow (x y : ℝ) : rpow x y = x ^ y := rfl
theorem rpow_def (x y : ℝ) : x ^ y = ((x : ℂ) ^ (y : ℂ)).re := rfl
theorem rpow_def_of_nonneg {x : ℝ} (hx : 0 ≤ x) (y : ℝ) :
x ^ y = if x = 0 then if y = 0 then 1 else 0 else exp (log x * y) := by
simp only [rpow_def, Complex.cpow_def]; split_ifs <;>
simp_all [(Complex.ofReal_log hx).symm, -Complex.ofReal_mul,
(Complex.ofReal_mul _ _).symm, Complex.exp_ofReal_re, Complex.ofReal_eq_zero]
theorem rpow_def_of_pos {x : ℝ} (hx : 0 < x) (y : ℝ) : x ^ y = exp (log x * y) := by
rw [rpow_def_of_nonneg (le_of_lt hx), if_neg (ne_of_gt hx)]
theorem exp_mul (x y : ℝ) : exp (x * y) = exp x ^ y := by rw [rpow_def_of_pos (exp_pos _), log_exp]
@[simp, norm_cast]
theorem rpow_intCast (x : ℝ) (n : ℤ) : x ^ (n : ℝ) = x ^ n := by
simp only [rpow_def, ← Complex.ofReal_zpow, Complex.cpow_intCast, Complex.ofReal_intCast,
Complex.ofReal_re]
@[deprecated (since := "2024-04-17")]
alias rpow_int_cast := rpow_intCast
@[simp, norm_cast]
theorem rpow_natCast (x : ℝ) (n : ℕ) : x ^ (n : ℝ) = x ^ n := by simpa using rpow_intCast x n
@[deprecated (since := "2024-04-17")]
alias rpow_nat_cast := rpow_natCast
@[simp]
theorem exp_one_rpow (x : ℝ) : exp 1 ^ x = exp x := by rw [← exp_mul, one_mul]
@[simp] lemma exp_one_pow (n : ℕ) : exp 1 ^ n = exp n := by rw [← rpow_natCast, exp_one_rpow]
theorem rpow_eq_zero_iff_of_nonneg (hx : 0 ≤ x) : x ^ y = 0 ↔ x = 0 ∧ y ≠ 0 := by
simp only [rpow_def_of_nonneg hx]
split_ifs <;> simp [*, exp_ne_zero]
@[simp]
lemma rpow_eq_zero (hx : 0 ≤ x) (hy : y ≠ 0) : x ^ y = 0 ↔ x = 0 := by
simp [rpow_eq_zero_iff_of_nonneg, *]
@[simp]
lemma rpow_ne_zero (hx : 0 ≤ x) (hy : y ≠ 0) : x ^ y ≠ 0 ↔ x ≠ 0 :=
Real.rpow_eq_zero hx hy |>.not
open Real
theorem rpow_def_of_neg {x : ℝ} (hx : x < 0) (y : ℝ) : x ^ y = exp (log x * y) * cos (y * π) := by
rw [rpow_def, Complex.cpow_def, if_neg]
· have : Complex.log x * y = ↑(log (-x) * y) + ↑(y * π) * Complex.I := by
simp only [Complex.log, abs_of_neg hx, Complex.arg_ofReal_of_neg hx, Complex.abs_ofReal,
Complex.ofReal_mul]
ring
rw [this, Complex.exp_add_mul_I, ← Complex.ofReal_exp, ← Complex.ofReal_cos, ←
Complex.ofReal_sin, mul_add, ← Complex.ofReal_mul, ← mul_assoc, ← Complex.ofReal_mul,
Complex.add_re, Complex.ofReal_re, Complex.mul_re, Complex.I_re, Complex.ofReal_im,
Real.log_neg_eq_log]
ring
· rw [Complex.ofReal_eq_zero]
exact ne_of_lt hx
theorem rpow_def_of_nonpos {x : ℝ} (hx : x ≤ 0) (y : ℝ) :
x ^ y = if x = 0 then if y = 0 then 1 else 0 else exp (log x * y) * cos (y * π) := by
split_ifs with h <;> simp [rpow_def, *]; exact rpow_def_of_neg (lt_of_le_of_ne hx h) _
@[bound]
theorem rpow_pos_of_pos {x : ℝ} (hx : 0 < x) (y : ℝ) : 0 < x ^ y := by
rw [rpow_def_of_pos hx]; apply exp_pos
@[simp]
theorem rpow_zero (x : ℝ) : x ^ (0 : ℝ) = 1 := by simp [rpow_def]
theorem rpow_zero_pos (x : ℝ) : 0 < x ^ (0 : ℝ) := by simp
@[simp]
theorem zero_rpow {x : ℝ} (h : x ≠ 0) : (0 : ℝ) ^ x = 0 := by simp [rpow_def, *]
theorem zero_rpow_eq_iff {x : ℝ} {a : ℝ} : 0 ^ x = a ↔ x ≠ 0 ∧ a = 0 ∨ x = 0 ∧ a = 1 := by
constructor
· intro hyp
simp only [rpow_def, Complex.ofReal_zero] at hyp
by_cases h : x = 0
· subst h
simp only [Complex.one_re, Complex.ofReal_zero, Complex.cpow_zero] at hyp
exact Or.inr ⟨rfl, hyp.symm⟩
· rw [Complex.zero_cpow (Complex.ofReal_ne_zero.mpr h)] at hyp
exact Or.inl ⟨h, hyp.symm⟩
· rintro (⟨h, rfl⟩ | ⟨rfl, rfl⟩)
· exact zero_rpow h
· exact rpow_zero _
theorem eq_zero_rpow_iff {x : ℝ} {a : ℝ} : a = 0 ^ x ↔ x ≠ 0 ∧ a = 0 ∨ x = 0 ∧ a = 1 := by
rw [← zero_rpow_eq_iff, eq_comm]
@[simp]
theorem rpow_one (x : ℝ) : x ^ (1 : ℝ) = x := by simp [rpow_def]
@[simp]
theorem one_rpow (x : ℝ) : (1 : ℝ) ^ x = 1 := by simp [rpow_def]
theorem zero_rpow_le_one (x : ℝ) : (0 : ℝ) ^ x ≤ 1 := by
by_cases h : x = 0 <;> simp [h, zero_le_one]
theorem zero_rpow_nonneg (x : ℝ) : 0 ≤ (0 : ℝ) ^ x := by
by_cases h : x = 0 <;> simp [h, zero_le_one]
@[bound]
theorem rpow_nonneg {x : ℝ} (hx : 0 ≤ x) (y : ℝ) : 0 ≤ x ^ y := by
rw [rpow_def_of_nonneg hx]; split_ifs <;>
simp only [zero_le_one, le_refl, le_of_lt (exp_pos _)]
theorem abs_rpow_of_nonneg {x y : ℝ} (hx_nonneg : 0 ≤ x) : |x ^ y| = |x| ^ y := by
have h_rpow_nonneg : 0 ≤ x ^ y := Real.rpow_nonneg hx_nonneg _
rw [abs_eq_self.mpr hx_nonneg, abs_eq_self.mpr h_rpow_nonneg]
@[bound]
theorem abs_rpow_le_abs_rpow (x y : ℝ) : |x ^ y| ≤ |x| ^ y := by
rcases le_or_lt 0 x with hx | hx
· rw [abs_rpow_of_nonneg hx]
· rw [abs_of_neg hx, rpow_def_of_neg hx, rpow_def_of_pos (neg_pos.2 hx), log_neg_eq_log, abs_mul,
abs_of_pos (exp_pos _)]
exact mul_le_of_le_one_right (exp_pos _).le (abs_cos_le_one _)
theorem abs_rpow_le_exp_log_mul (x y : ℝ) : |x ^ y| ≤ exp (log x * y) := by
refine (abs_rpow_le_abs_rpow x y).trans ?_
by_cases hx : x = 0
· by_cases hy : y = 0 <;> simp [hx, hy, zero_le_one]
· rw [rpow_def_of_pos (abs_pos.2 hx), log_abs]
theorem norm_rpow_of_nonneg {x y : ℝ} (hx_nonneg : 0 ≤ x) : ‖x ^ y‖ = ‖x‖ ^ y := by
simp_rw [Real.norm_eq_abs]
exact abs_rpow_of_nonneg hx_nonneg
variable {w x y z : ℝ}
theorem rpow_add (hx : 0 < x) (y z : ℝ) : x ^ (y + z) = x ^ y * x ^ z := by
simp only [rpow_def_of_pos hx, mul_add, exp_add]
theorem rpow_add' (hx : 0 ≤ x) (h : y + z ≠ 0) : x ^ (y + z) = x ^ y * x ^ z := by
rcases hx.eq_or_lt with (rfl | pos)
· rw [zero_rpow h, zero_eq_mul]
have : y ≠ 0 ∨ z ≠ 0 := not_and_or.1 fun ⟨hy, hz⟩ => h <| hy.symm ▸ hz.symm ▸ zero_add 0
exact this.imp zero_rpow zero_rpow
· exact rpow_add pos _ _
/-- Variant of `Real.rpow_add'` that avoids having to prove `y + z = w` twice. -/
lemma rpow_of_add_eq (hx : 0 ≤ x) (hw : w ≠ 0) (h : y + z = w) : x ^ w = x ^ y * x ^ z := by
rw [← h, rpow_add' hx]; rwa [h]
theorem rpow_add_of_nonneg (hx : 0 ≤ x) (hy : 0 ≤ y) (hz : 0 ≤ z) :
x ^ (y + z) = x ^ y * x ^ z := by
rcases hy.eq_or_lt with (rfl | hy)
· rw [zero_add, rpow_zero, one_mul]
exact rpow_add' hx (ne_of_gt <| add_pos_of_pos_of_nonneg hy hz)
/-- For `0 ≤ x`, the only problematic case in the equality `x ^ y * x ^ z = x ^ (y + z)` is for
`x = 0` and `y + z = 0`, where the right hand side is `1` while the left hand side can vanish.
The inequality is always true, though, and given in this lemma. -/
theorem le_rpow_add {x : ℝ} (hx : 0 ≤ x) (y z : ℝ) : x ^ y * x ^ z ≤ x ^ (y + z) := by
rcases le_iff_eq_or_lt.1 hx with (H | pos)
· by_cases h : y + z = 0
· simp only [H.symm, h, rpow_zero]
calc
(0 : ℝ) ^ y * 0 ^ z ≤ 1 * 1 :=
mul_le_mul (zero_rpow_le_one y) (zero_rpow_le_one z) (zero_rpow_nonneg z) zero_le_one
_ = 1 := by simp
· simp [rpow_add', ← H, h]
· simp [rpow_add pos]
theorem rpow_sum_of_pos {ι : Type*} {a : ℝ} (ha : 0 < a) (f : ι → ℝ) (s : Finset ι) :
(a ^ ∑ x ∈ s, f x) = ∏ x ∈ s, a ^ f x :=
map_sum (⟨⟨fun (x : ℝ) => (a ^ x : ℝ), rpow_zero a⟩, rpow_add ha⟩ : ℝ →+ (Additive ℝ)) f s
theorem rpow_sum_of_nonneg {ι : Type*} {a : ℝ} (ha : 0 ≤ a) {s : Finset ι} {f : ι → ℝ}
(h : ∀ x ∈ s, 0 ≤ f x) : (a ^ ∑ x ∈ s, f x) = ∏ x ∈ s, a ^ f x := by
induction' s using Finset.cons_induction with i s hi ihs
· rw [sum_empty, Finset.prod_empty, rpow_zero]
· rw [forall_mem_cons] at h
rw [sum_cons, prod_cons, ← ihs h.2, rpow_add_of_nonneg ha h.1 (sum_nonneg h.2)]
theorem rpow_neg {x : ℝ} (hx : 0 ≤ x) (y : ℝ) : x ^ (-y) = (x ^ y)⁻¹ := by
simp only [rpow_def_of_nonneg hx]; split_ifs <;> simp_all [exp_neg]
theorem rpow_sub {x : ℝ} (hx : 0 < x) (y z : ℝ) : x ^ (y - z) = x ^ y / x ^ z := by
simp only [sub_eq_add_neg, rpow_add hx, rpow_neg (le_of_lt hx), div_eq_mul_inv]
theorem rpow_sub' {x : ℝ} (hx : 0 ≤ x) {y z : ℝ} (h : y - z ≠ 0) : x ^ (y - z) = x ^ y / x ^ z := by
simp only [sub_eq_add_neg] at h ⊢
simp only [rpow_add' hx h, rpow_neg hx, div_eq_mul_inv]
protected theorem _root_.HasCompactSupport.rpow_const {α : Type*} [TopologicalSpace α] {f : α → ℝ}
(hf : HasCompactSupport f) {r : ℝ} (hr : r ≠ 0) : HasCompactSupport (fun x ↦ f x ^ r) :=
hf.comp_left (g := (· ^ r)) (Real.zero_rpow hr)
end Real
/-!
## Comparing real and complex powers
-/
namespace Complex
theorem ofReal_cpow {x : ℝ} (hx : 0 ≤ x) (y : ℝ) : ((x ^ y : ℝ) : ℂ) = (x : ℂ) ^ (y : ℂ) := by
simp only [Real.rpow_def_of_nonneg hx, Complex.cpow_def, ofReal_eq_zero]; split_ifs <;>
simp [Complex.ofReal_log hx]
theorem ofReal_cpow_of_nonpos {x : ℝ} (hx : x ≤ 0) (y : ℂ) :
(x : ℂ) ^ y = (-x : ℂ) ^ y * exp (π * I * y) := by
rcases hx.eq_or_lt with (rfl | hlt)
· rcases eq_or_ne y 0 with (rfl | hy) <;> simp [*]
have hne : (x : ℂ) ≠ 0 := ofReal_ne_zero.mpr hlt.ne
rw [cpow_def_of_ne_zero hne, cpow_def_of_ne_zero (neg_ne_zero.2 hne), ← exp_add, ← add_mul, log,
log, abs.map_neg, arg_ofReal_of_neg hlt, ← ofReal_neg,
arg_ofReal_of_nonneg (neg_nonneg.2 hx), ofReal_zero, zero_mul, add_zero]
lemma cpow_ofReal (x : ℂ) (y : ℝ) :
x ^ (y : ℂ) = ↑(abs x ^ y) * (Real.cos (arg x * y) + Real.sin (arg x * y) * I) := by
rcases eq_or_ne x 0 with rfl | hx
· simp [ofReal_cpow le_rfl]
· rw [cpow_def_of_ne_zero hx, exp_eq_exp_re_mul_sin_add_cos, mul_comm (log x)]
norm_cast
rw [re_ofReal_mul, im_ofReal_mul, log_re, log_im, mul_comm y, mul_comm y, Real.exp_mul,
Real.exp_log]
rwa [abs.pos_iff]
lemma cpow_ofReal_re (x : ℂ) (y : ℝ) : (x ^ (y : ℂ)).re = (abs x) ^ y * Real.cos (arg x * y) := by
rw [cpow_ofReal]; generalize arg x * y = z; simp [Real.cos]
lemma cpow_ofReal_im (x : ℂ) (y : ℝ) : (x ^ (y : ℂ)).im = (abs x) ^ y * Real.sin (arg x * y) := by
rw [cpow_ofReal]; generalize arg x * y = z; simp [Real.sin]
theorem abs_cpow_of_ne_zero {z : ℂ} (hz : z ≠ 0) (w : ℂ) :
abs (z ^ w) = abs z ^ w.re / Real.exp (arg z * im w) := by
rw [cpow_def_of_ne_zero hz, abs_exp, mul_re, log_re, log_im, Real.exp_sub,
Real.rpow_def_of_pos (abs.pos hz)]
theorem abs_cpow_of_imp {z w : ℂ} (h : z = 0 → w.re = 0 → w = 0) :
abs (z ^ w) = abs z ^ w.re / Real.exp (arg z * im w) := by
rcases ne_or_eq z 0 with (hz | rfl) <;> [exact abs_cpow_of_ne_zero hz w; rw [map_zero]]
rcases eq_or_ne w.re 0 with hw | hw
· simp [hw, h rfl hw]
· rw [Real.zero_rpow hw, zero_div, zero_cpow, map_zero]
exact ne_of_apply_ne re hw
theorem abs_cpow_le (z w : ℂ) : abs (z ^ w) ≤ abs z ^ w.re / Real.exp (arg z * im w) := by
by_cases h : z = 0 → w.re = 0 → w = 0
· exact (abs_cpow_of_imp h).le
· push_neg at h
simp [h]
@[simp]
theorem abs_cpow_real (x : ℂ) (y : ℝ) : abs (x ^ (y : ℂ)) = Complex.abs x ^ y := by
rw [abs_cpow_of_imp] <;> simp
@[simp]
theorem abs_cpow_inv_nat (x : ℂ) (n : ℕ) : abs (x ^ (n⁻¹ : ℂ)) = Complex.abs x ^ (n⁻¹ : ℝ) := by
rw [← abs_cpow_real]; simp [-abs_cpow_real]
theorem abs_cpow_eq_rpow_re_of_pos {x : ℝ} (hx : 0 < x) (y : ℂ) : abs (x ^ y) = x ^ y.re := by
rw [abs_cpow_of_ne_zero (ofReal_ne_zero.mpr hx.ne'), arg_ofReal_of_nonneg hx.le,
zero_mul, Real.exp_zero, div_one, abs_of_nonneg hx.le]
theorem abs_cpow_eq_rpow_re_of_nonneg {x : ℝ} (hx : 0 ≤ x) {y : ℂ} (hy : re y ≠ 0) :
abs (x ^ y) = x ^ re y := by
rw [abs_cpow_of_imp] <;> simp [*, arg_ofReal_of_nonneg, _root_.abs_of_nonneg]
lemma norm_natCast_cpow_of_re_ne_zero (n : ℕ) {s : ℂ} (hs : s.re ≠ 0) :
‖(n : ℂ) ^ s‖ = (n : ℝ) ^ (s.re) := by
rw [norm_eq_abs, ← ofReal_natCast, abs_cpow_eq_rpow_re_of_nonneg n.cast_nonneg hs]
lemma norm_natCast_cpow_of_pos {n : ℕ} (hn : 0 < n) (s : ℂ) :
‖(n : ℂ) ^ s‖ = (n : ℝ) ^ (s.re) := by
rw [norm_eq_abs, ← ofReal_natCast, abs_cpow_eq_rpow_re_of_pos (Nat.cast_pos.mpr hn) _]
lemma norm_natCast_cpow_pos_of_pos {n : ℕ} (hn : 0 < n) (s : ℂ) : 0 < ‖(n : ℂ) ^ s‖ :=
(norm_natCast_cpow_of_pos hn _).symm ▸ Real.rpow_pos_of_pos (Nat.cast_pos.mpr hn) _
theorem cpow_mul_ofReal_nonneg {x : ℝ} (hx : 0 ≤ x) (y : ℝ) (z : ℂ) :
(x : ℂ) ^ (↑y * z) = (↑(x ^ y) : ℂ) ^ z := by
rw [cpow_mul, ofReal_cpow hx]
· rw [← ofReal_log hx, ← ofReal_mul, ofReal_im, neg_lt_zero]; exact Real.pi_pos
· rw [← ofReal_log hx, ← ofReal_mul, ofReal_im]; exact Real.pi_pos.le
end Complex
/-! ### Positivity extension -/
namespace Mathlib.Meta.Positivity
open Lean Meta Qq
/-- Extension for the `positivity` tactic: exponentiation by a real number is positive (namely 1)
when the exponent is zero. The other cases are done in `evalRpow`. -/
@[positivity (_ : ℝ) ^ (0 : ℝ)]
def evalRpowZero : PositivityExt where eval {u α} _ _ e := do
match u, α, e with
| 0, ~q(ℝ), ~q($a ^ (0 : ℝ)) =>
assertInstancesCommute
pure (.positive q(Real.rpow_zero_pos $a))
| _, _, _ => throwError "not Real.rpow"
/-- Extension for the `positivity` tactic: exponentiation by a real number is nonnegative when
the base is nonnegative and positive when the base is positive. -/
@[positivity (_ : ℝ) ^ (_ : ℝ)]
def evalRpow : PositivityExt where eval {u α} _zα _pα e := do
match u, α, e with
| 0, ~q(ℝ), ~q($a ^ ($b : ℝ)) =>
let ra ← core q(inferInstance) q(inferInstance) a
assertInstancesCommute
match ra with
| .positive pa =>
pure (.positive q(Real.rpow_pos_of_pos $pa $b))
| .nonnegative pa =>
pure (.nonnegative q(Real.rpow_nonneg $pa $b))
| _ => pure .none
| _, _, _ => throwError "not Real.rpow"
end Mathlib.Meta.Positivity
/-!
## Further algebraic properties of `rpow`
-/
namespace Real
variable {x y z : ℝ} {n : ℕ}
theorem rpow_mul {x : ℝ} (hx : 0 ≤ x) (y z : ℝ) : x ^ (y * z) = (x ^ y) ^ z := by
rw [← Complex.ofReal_inj, Complex.ofReal_cpow (rpow_nonneg hx _),
Complex.ofReal_cpow hx, Complex.ofReal_mul, Complex.cpow_mul, Complex.ofReal_cpow hx] <;>
simp only [(Complex.ofReal_mul _ _).symm, (Complex.ofReal_log hx).symm, Complex.ofReal_im,
neg_lt_zero, pi_pos, le_of_lt pi_pos]
theorem rpow_add_int {x : ℝ} (hx : x ≠ 0) (y : ℝ) (n : ℤ) : x ^ (y + n) = x ^ y * x ^ n := by
rw [rpow_def, rpow_def, Complex.ofReal_add,
Complex.cpow_add _ _ (Complex.ofReal_ne_zero.mpr hx), Complex.ofReal_intCast,
Complex.cpow_intCast, ← Complex.ofReal_zpow, mul_comm, Complex.re_ofReal_mul, mul_comm]
theorem rpow_add_nat {x : ℝ} (hx : x ≠ 0) (y : ℝ) (n : ℕ) : x ^ (y + n) = x ^ y * x ^ n := by
simpa using rpow_add_int hx y n
theorem rpow_sub_int {x : ℝ} (hx : x ≠ 0) (y : ℝ) (n : ℕ) : x ^ (y - n) = x ^ y / x ^ n := by
simpa using rpow_add_int hx y (-n)
theorem rpow_sub_nat {x : ℝ} (hx : x ≠ 0) (y : ℝ) (n : ℕ) : x ^ (y - n) = x ^ y / x ^ n := by
simpa using rpow_sub_int hx y n
lemma rpow_add_int' (hx : 0 ≤ x) {n : ℤ} (h : y + n ≠ 0) : x ^ (y + n) = x ^ y * x ^ n := by
rw [rpow_add' hx h, rpow_intCast]
lemma rpow_add_nat' (hx : 0 ≤ x) (h : y + n ≠ 0) : x ^ (y + n) = x ^ y * x ^ n := by
rw [rpow_add' hx h, rpow_natCast]
lemma rpow_sub_int' (hx : 0 ≤ x) {n : ℤ} (h : y - n ≠ 0) : x ^ (y - n) = x ^ y / x ^ n := by
rw [rpow_sub' hx h, rpow_intCast]
lemma rpow_sub_nat' (hx : 0 ≤ x) (h : y - n ≠ 0) : x ^ (y - n) = x ^ y / x ^ n := by
rw [rpow_sub' hx h, rpow_natCast]
theorem rpow_add_one {x : ℝ} (hx : x ≠ 0) (y : ℝ) : x ^ (y + 1) = x ^ y * x := by
simpa using rpow_add_nat hx y 1
theorem rpow_sub_one {x : ℝ} (hx : x ≠ 0) (y : ℝ) : x ^ (y - 1) = x ^ y / x := by
simpa using rpow_sub_nat hx y 1
lemma rpow_add_one' (hx : 0 ≤ x) (h : y + 1 ≠ 0) : x ^ (y + 1) = x ^ y * x := by
rw [rpow_add' hx h, rpow_one]
lemma rpow_one_add' (hx : 0 ≤ x) (h : 1 + y ≠ 0) : x ^ (1 + y) = x * x ^ y := by
rw [rpow_add' hx h, rpow_one]
lemma rpow_sub_one' (hx : 0 ≤ x) (h : y - 1 ≠ 0) : x ^ (y - 1) = x ^ y / x := by
rw [rpow_sub' hx h, rpow_one]
lemma rpow_one_sub' (hx : 0 ≤ x) (h : 1 - y ≠ 0) : x ^ (1 - y) = x / x ^ y := by
rw [rpow_sub' hx h, rpow_one]
@[simp]
theorem rpow_two (x : ℝ) : x ^ (2 : ℝ) = x ^ 2 := by
rw [← rpow_natCast]
simp only [Nat.cast_ofNat]
theorem rpow_neg_one (x : ℝ) : x ^ (-1 : ℝ) = x⁻¹ := by
suffices H : x ^ ((-1 : ℤ) : ℝ) = x⁻¹ by rwa [Int.cast_neg, Int.cast_one] at H
simp only [rpow_intCast, zpow_one, zpow_neg]
theorem mul_rpow (hx : 0 ≤ x) (hy : 0 ≤ y) : (x * y) ^ z = x ^ z * y ^ z := by
iterate 2 rw [Real.rpow_def_of_nonneg]; split_ifs with h_ifs <;> simp_all
· rw [log_mul ‹_› ‹_›, add_mul, exp_add, rpow_def_of_pos (hy.lt_of_ne' ‹_›)]
all_goals positivity
theorem inv_rpow (hx : 0 ≤ x) (y : ℝ) : x⁻¹ ^ y = (x ^ y)⁻¹ := by
simp only [← rpow_neg_one, ← rpow_mul hx, mul_comm]
theorem div_rpow (hx : 0 ≤ x) (hy : 0 ≤ y) (z : ℝ) : (x / y) ^ z = x ^ z / y ^ z := by
simp only [div_eq_mul_inv, mul_rpow hx (inv_nonneg.2 hy), inv_rpow hy]
theorem log_rpow {x : ℝ} (hx : 0 < x) (y : ℝ) : log (x ^ y) = y * log x := by
apply exp_injective
rw [exp_log (rpow_pos_of_pos hx y), ← exp_log hx, mul_comm, rpow_def_of_pos (exp_pos (log x)) y]
theorem mul_log_eq_log_iff {x y z : ℝ} (hx : 0 < x) (hz : 0 < z) :
y * log x = log z ↔ x ^ y = z :=
⟨fun h ↦ log_injOn_pos (rpow_pos_of_pos hx _) hz <| log_rpow hx _ |>.trans h,
by rintro rfl; rw [log_rpow hx]⟩
@[simp] lemma rpow_rpow_inv (hx : 0 ≤ x) (hy : y ≠ 0) : (x ^ y) ^ y⁻¹ = x := by
rw [← rpow_mul hx, mul_inv_cancel hy, rpow_one]
@[simp] lemma rpow_inv_rpow (hx : 0 ≤ x) (hy : y ≠ 0) : (x ^ y⁻¹) ^ y = x := by
rw [← rpow_mul hx, inv_mul_cancel hy, rpow_one]
theorem pow_rpow_inv_natCast (hx : 0 ≤ x) (hn : n ≠ 0) : (x ^ n) ^ (n⁻¹ : ℝ) = x := by
have hn0 : (n : ℝ) ≠ 0 := Nat.cast_ne_zero.2 hn
rw [← rpow_natCast, ← rpow_mul hx, mul_inv_cancel hn0, rpow_one]
theorem rpow_inv_natCast_pow (hx : 0 ≤ x) (hn : n ≠ 0) : (x ^ (n⁻¹ : ℝ)) ^ n = x := by
have hn0 : (n : ℝ) ≠ 0 := Nat.cast_ne_zero.2 hn
rw [← rpow_natCast, ← rpow_mul hx, inv_mul_cancel hn0, rpow_one]
lemma rpow_natCast_mul (hx : 0 ≤ x) (n : ℕ) (z : ℝ) : x ^ (n * z) = (x ^ n) ^ z := by
rw [rpow_mul hx, rpow_natCast]
lemma rpow_mul_natCast (hx : 0 ≤ x) (y : ℝ) (n : ℕ) : x ^ (y * n) = (x ^ y) ^ n := by
rw [rpow_mul hx, rpow_natCast]
lemma rpow_intCast_mul (hx : 0 ≤ x) (n : ℤ) (z : ℝ) : x ^ (n * z) = (x ^ n) ^ z := by
rw [rpow_mul hx, rpow_intCast]
lemma rpow_mul_intCast (hx : 0 ≤ x) (y : ℝ) (n : ℤ) : x ^ (y * n) = (x ^ y) ^ n := by
rw [rpow_mul hx, rpow_intCast]
/-! Note: lemmas about `(∏ i ∈ s, f i ^ r)` such as `Real.finset_prod_rpow` are proved
in `Mathlib/Analysis/SpecialFunctions/Pow/NNReal.lean` instead. -/
/-!
## Order and monotonicity
-/
@[gcongr, bound]
theorem rpow_lt_rpow (hx : 0 ≤ x) (hxy : x < y) (hz : 0 < z) : x ^ z < y ^ z := by
rw [le_iff_eq_or_lt] at hx; cases' hx with hx hx
· rw [← hx, zero_rpow (ne_of_gt hz)]
exact rpow_pos_of_pos (by rwa [← hx] at hxy) _
· rw [rpow_def_of_pos hx, rpow_def_of_pos (lt_trans hx hxy), exp_lt_exp]
exact mul_lt_mul_of_pos_right (log_lt_log hx hxy) hz
theorem strictMonoOn_rpow_Ici_of_exponent_pos {r : ℝ} (hr : 0 < r) :
StrictMonoOn (fun (x : ℝ) => x ^ r) (Set.Ici 0) :=
fun _ ha _ _ hab => rpow_lt_rpow ha hab hr
@[gcongr, bound]
theorem rpow_le_rpow {x y z : ℝ} (h : 0 ≤ x) (h₁ : x ≤ y) (h₂ : 0 ≤ z) : x ^ z ≤ y ^ z := by
rcases eq_or_lt_of_le h₁ with (rfl | h₁'); · rfl
rcases eq_or_lt_of_le h₂ with (rfl | h₂'); · simp
exact le_of_lt (rpow_lt_rpow h h₁' h₂')
theorem monotoneOn_rpow_Ici_of_exponent_nonneg {r : ℝ} (hr : 0 ≤ r) :
MonotoneOn (fun (x : ℝ) => x ^ r) (Set.Ici 0) :=
fun _ ha _ _ hab => rpow_le_rpow ha hab hr
lemma rpow_lt_rpow_of_neg (hx : 0 < x) (hxy : x < y) (hz : z < 0) : y ^ z < x ^ z := by
have := hx.trans hxy
rw [← inv_lt_inv, ← rpow_neg, ← rpow_neg]
on_goal 1 => refine rpow_lt_rpow ?_ hxy (neg_pos.2 hz)
all_goals positivity
lemma rpow_le_rpow_of_nonpos (hx : 0 < x) (hxy : x ≤ y) (hz : z ≤ 0) : y ^ z ≤ x ^ z := by
have := hx.trans_le hxy
rw [← inv_le_inv, ← rpow_neg, ← rpow_neg]
on_goal 1 => refine rpow_le_rpow ?_ hxy (neg_nonneg.2 hz)
all_goals positivity
theorem rpow_lt_rpow_iff (hx : 0 ≤ x) (hy : 0 ≤ y) (hz : 0 < z) : x ^ z < y ^ z ↔ x < y :=
⟨lt_imp_lt_of_le_imp_le fun h => rpow_le_rpow hy h (le_of_lt hz), fun h => rpow_lt_rpow hx h hz⟩
theorem rpow_le_rpow_iff (hx : 0 ≤ x) (hy : 0 ≤ y) (hz : 0 < z) : x ^ z ≤ y ^ z ↔ x ≤ y :=
le_iff_le_iff_lt_iff_lt.2 <| rpow_lt_rpow_iff hy hx hz
lemma rpow_lt_rpow_iff_of_neg (hx : 0 < x) (hy : 0 < y) (hz : z < 0) : x ^ z < y ^ z ↔ y < x :=
⟨lt_imp_lt_of_le_imp_le fun h ↦ rpow_le_rpow_of_nonpos hx h hz.le,
fun h ↦ rpow_lt_rpow_of_neg hy h hz⟩
lemma rpow_le_rpow_iff_of_neg (hx : 0 < x) (hy : 0 < y) (hz : z < 0) : x ^ z ≤ y ^ z ↔ y ≤ x :=
le_iff_le_iff_lt_iff_lt.2 <| rpow_lt_rpow_iff_of_neg hy hx hz
lemma le_rpow_inv_iff_of_pos (hx : 0 ≤ x) (hy : 0 ≤ y) (hz : 0 < z) : x ≤ y ^ z⁻¹ ↔ x ^ z ≤ y := by
rw [← rpow_le_rpow_iff hx _ hz, rpow_inv_rpow] <;> positivity
lemma rpow_inv_le_iff_of_pos (hx : 0 ≤ x) (hy : 0 ≤ y) (hz : 0 < z) : x ^ z⁻¹ ≤ y ↔ x ≤ y ^ z := by
rw [← rpow_le_rpow_iff _ hy hz, rpow_inv_rpow] <;> positivity
lemma lt_rpow_inv_iff_of_pos (hx : 0 ≤ x) (hy : 0 ≤ y) (hz : 0 < z) : x < y ^ z⁻¹ ↔ x ^ z < y :=
lt_iff_lt_of_le_iff_le <| rpow_inv_le_iff_of_pos hy hx hz
lemma rpow_inv_lt_iff_of_pos (hx : 0 ≤ x) (hy : 0 ≤ y) (hz : 0 < z) : x ^ z⁻¹ < y ↔ x < y ^ z :=
lt_iff_lt_of_le_iff_le <| le_rpow_inv_iff_of_pos hy hx hz
theorem le_rpow_inv_iff_of_neg (hx : 0 < x) (hy : 0 < y) (hz : z < 0) :
x ≤ y ^ z⁻¹ ↔ y ≤ x ^ z := by
rw [← rpow_le_rpow_iff_of_neg _ hx hz, rpow_inv_rpow _ hz.ne] <;> positivity
theorem lt_rpow_inv_iff_of_neg (hx : 0 < x) (hy : 0 < y) (hz : z < 0) :
x < y ^ z⁻¹ ↔ y < x ^ z := by
rw [← rpow_lt_rpow_iff_of_neg _ hx hz, rpow_inv_rpow _ hz.ne] <;> positivity
theorem rpow_inv_lt_iff_of_neg (hx : 0 < x) (hy : 0 < y) (hz : z < 0) :
x ^ z⁻¹ < y ↔ y ^ z < x := by
rw [← rpow_lt_rpow_iff_of_neg hy _ hz, rpow_inv_rpow _ hz.ne] <;> positivity
theorem rpow_inv_le_iff_of_neg (hx : 0 < x) (hy : 0 < y) (hz : z < 0) :
x ^ z⁻¹ ≤ y ↔ y ^ z ≤ x := by
rw [← rpow_le_rpow_iff_of_neg hy _ hz, rpow_inv_rpow _ hz.ne] <;> positivity
theorem rpow_lt_rpow_of_exponent_lt (hx : 1 < x) (hyz : y < z) : x ^ y < x ^ z := by
repeat' rw [rpow_def_of_pos (lt_trans zero_lt_one hx)]
rw [exp_lt_exp]; exact mul_lt_mul_of_pos_left hyz (log_pos hx)
@[gcongr]
theorem rpow_le_rpow_of_exponent_le (hx : 1 ≤ x) (hyz : y ≤ z) : x ^ y ≤ x ^ z := by
repeat' rw [rpow_def_of_pos (lt_of_lt_of_le zero_lt_one hx)]
rw [exp_le_exp]; exact mul_le_mul_of_nonneg_left hyz (log_nonneg hx)
theorem rpow_lt_rpow_of_exponent_neg {x y z : ℝ} (hy : 0 < y) (hxy : y < x) (hz : z < 0) :
x ^ z < y ^ z := by
have hx : 0 < x := hy.trans hxy
rw [← neg_neg z, Real.rpow_neg (le_of_lt hx) (-z), Real.rpow_neg (le_of_lt hy) (-z),
inv_lt_inv (rpow_pos_of_pos hx _) (rpow_pos_of_pos hy _)]
exact Real.rpow_lt_rpow (by positivity) hxy <| neg_pos_of_neg hz
theorem strictAntiOn_rpow_Ioi_of_exponent_neg {r : ℝ} (hr : r < 0) :
StrictAntiOn (fun (x : ℝ) => x ^ r) (Set.Ioi 0) :=
fun _ ha _ _ hab => rpow_lt_rpow_of_exponent_neg ha hab hr
theorem rpow_le_rpow_of_exponent_nonpos {x y : ℝ} (hy : 0 < y) (hxy : y ≤ x) (hz : z ≤ 0) :
x ^ z ≤ y ^ z := by
rcases ne_or_eq z 0 with hz_zero | rfl
case inl =>
rcases ne_or_eq x y with hxy' | rfl
case inl =>
exact le_of_lt <| rpow_lt_rpow_of_exponent_neg hy (Ne.lt_of_le (id (Ne.symm hxy')) hxy)
(Ne.lt_of_le hz_zero hz)
case inr => simp
case inr => simp
theorem antitoneOn_rpow_Ioi_of_exponent_nonpos {r : ℝ} (hr : r ≤ 0) :
AntitoneOn (fun (x : ℝ) => x ^ r) (Set.Ioi 0) :=
fun _ ha _ _ hab => rpow_le_rpow_of_exponent_nonpos ha hab hr
@[simp]
theorem rpow_le_rpow_left_iff (hx : 1 < x) : x ^ y ≤ x ^ z ↔ y ≤ z := by
have x_pos : 0 < x := lt_trans zero_lt_one hx
rw [← log_le_log_iff (rpow_pos_of_pos x_pos y) (rpow_pos_of_pos x_pos z), log_rpow x_pos,
log_rpow x_pos, mul_le_mul_right (log_pos hx)]
@[simp]
theorem rpow_lt_rpow_left_iff (hx : 1 < x) : x ^ y < x ^ z ↔ y < z := by
rw [lt_iff_not_le, rpow_le_rpow_left_iff hx, lt_iff_not_le]
theorem rpow_lt_rpow_of_exponent_gt (hx0 : 0 < x) (hx1 : x < 1) (hyz : z < y) : x ^ y < x ^ z := by
repeat' rw [rpow_def_of_pos hx0]
rw [exp_lt_exp]; exact mul_lt_mul_of_neg_left hyz (log_neg hx0 hx1)
theorem rpow_le_rpow_of_exponent_ge (hx0 : 0 < x) (hx1 : x ≤ 1) (hyz : z ≤ y) : x ^ y ≤ x ^ z := by
repeat' rw [rpow_def_of_pos hx0]
rw [exp_le_exp]; exact mul_le_mul_of_nonpos_left hyz (log_nonpos (le_of_lt hx0) hx1)
@[simp]
theorem rpow_le_rpow_left_iff_of_base_lt_one (hx0 : 0 < x) (hx1 : x < 1) :
x ^ y ≤ x ^ z ↔ z ≤ y := by
rw [← log_le_log_iff (rpow_pos_of_pos hx0 y) (rpow_pos_of_pos hx0 z), log_rpow hx0, log_rpow hx0,
mul_le_mul_right_of_neg (log_neg hx0 hx1)]
@[simp]
theorem rpow_lt_rpow_left_iff_of_base_lt_one (hx0 : 0 < x) (hx1 : x < 1) :
x ^ y < x ^ z ↔ z < y := by
rw [lt_iff_not_le, rpow_le_rpow_left_iff_of_base_lt_one hx0 hx1, lt_iff_not_le]
theorem rpow_lt_one {x z : ℝ} (hx1 : 0 ≤ x) (hx2 : x < 1) (hz : 0 < z) : x ^ z < 1 := by
rw [← one_rpow z]
exact rpow_lt_rpow hx1 hx2 hz
theorem rpow_le_one {x z : ℝ} (hx1 : 0 ≤ x) (hx2 : x ≤ 1) (hz : 0 ≤ z) : x ^ z ≤ 1 := by
rw [← one_rpow z]
exact rpow_le_rpow hx1 hx2 hz
theorem rpow_lt_one_of_one_lt_of_neg {x z : ℝ} (hx : 1 < x) (hz : z < 0) : x ^ z < 1 := by
convert rpow_lt_rpow_of_exponent_lt hx hz
exact (rpow_zero x).symm
theorem rpow_le_one_of_one_le_of_nonpos {x z : ℝ} (hx : 1 ≤ x) (hz : z ≤ 0) : x ^ z ≤ 1 := by
convert rpow_le_rpow_of_exponent_le hx hz
exact (rpow_zero x).symm
theorem one_lt_rpow {x z : ℝ} (hx : 1 < x) (hz : 0 < z) : 1 < x ^ z := by
rw [← one_rpow z]
exact rpow_lt_rpow zero_le_one hx hz
theorem one_le_rpow {x z : ℝ} (hx : 1 ≤ x) (hz : 0 ≤ z) : 1 ≤ x ^ z := by
rw [← one_rpow z]
exact rpow_le_rpow zero_le_one hx hz
theorem one_lt_rpow_of_pos_of_lt_one_of_neg (hx1 : 0 < x) (hx2 : x < 1) (hz : z < 0) :
1 < x ^ z := by
convert rpow_lt_rpow_of_exponent_gt hx1 hx2 hz
exact (rpow_zero x).symm
theorem one_le_rpow_of_pos_of_le_one_of_nonpos (hx1 : 0 < x) (hx2 : x ≤ 1) (hz : z ≤ 0) :
1 ≤ x ^ z := by
convert rpow_le_rpow_of_exponent_ge hx1 hx2 hz
exact (rpow_zero x).symm
theorem rpow_lt_one_iff_of_pos (hx : 0 < x) : x ^ y < 1 ↔ 1 < x ∧ y < 0 ∨ x < 1 ∧ 0 < y := by
rw [rpow_def_of_pos hx, exp_lt_one_iff, mul_neg_iff, log_pos_iff hx, log_neg_iff hx]
theorem rpow_lt_one_iff (hx : 0 ≤ x) :
x ^ y < 1 ↔ x = 0 ∧ y ≠ 0 ∨ 1 < x ∧ y < 0 ∨ x < 1 ∧ 0 < y := by
rcases hx.eq_or_lt with (rfl | hx)
· rcases _root_.em (y = 0) with (rfl | hy) <;> simp [*, lt_irrefl, zero_lt_one]
· simp [rpow_lt_one_iff_of_pos hx, hx.ne.symm]
theorem rpow_lt_one_iff' {x y : ℝ} (hx : 0 ≤ x) (hy : 0 < y) :
x ^ y < 1 ↔ x < 1 := by
rw [← Real.rpow_lt_rpow_iff hx zero_le_one hy, Real.one_rpow]
theorem one_lt_rpow_iff_of_pos (hx : 0 < x) : 1 < x ^ y ↔ 1 < x ∧ 0 < y ∨ x < 1 ∧ y < 0 := by
rw [rpow_def_of_pos hx, one_lt_exp_iff, mul_pos_iff, log_pos_iff hx, log_neg_iff hx]
theorem one_lt_rpow_iff (hx : 0 ≤ x) : 1 < x ^ y ↔ 1 < x ∧ 0 < y ∨ 0 < x ∧ x < 1 ∧ y < 0 := by
rcases hx.eq_or_lt with (rfl | hx)
· rcases _root_.em (y = 0) with (rfl | hy) <;> simp [*, lt_irrefl, (zero_lt_one' ℝ).not_lt]
· simp [one_lt_rpow_iff_of_pos hx, hx]
theorem rpow_le_rpow_of_exponent_ge' (hx0 : 0 ≤ x) (hx1 : x ≤ 1) (hz : 0 ≤ z) (hyz : z ≤ y) :
x ^ y ≤ x ^ z := by
rcases eq_or_lt_of_le hx0 with (rfl | hx0')
· rcases eq_or_lt_of_le hz with (rfl | hz')
· exact (rpow_zero 0).symm ▸ rpow_le_one hx0 hx1 hyz
rw [zero_rpow, zero_rpow] <;> linarith
· exact rpow_le_rpow_of_exponent_ge hx0' hx1 hyz
theorem rpow_left_injOn {x : ℝ} (hx : x ≠ 0) : InjOn (fun y : ℝ => y ^ x) { y : ℝ | 0 ≤ y } := by
rintro y hy z hz (hyz : y ^ x = z ^ x)
rw [← rpow_one y, ← rpow_one z, ← _root_.mul_inv_cancel hx, rpow_mul hy, rpow_mul hz, hyz]
lemma rpow_left_inj (hx : 0 ≤ x) (hy : 0 ≤ y) (hz : z ≠ 0) : x ^ z = y ^ z ↔ x = y :=
(rpow_left_injOn hz).eq_iff hx hy
lemma rpow_inv_eq (hx : 0 ≤ x) (hy : 0 ≤ y) (hz : z ≠ 0) : x ^ z⁻¹ = y ↔ x = y ^ z := by
rw [← rpow_left_inj _ hy hz, rpow_inv_rpow hx hz]; positivity
lemma eq_rpow_inv (hx : 0 ≤ x) (hy : 0 ≤ y) (hz : z ≠ 0) : x = y ^ z⁻¹ ↔ x ^ z = y := by
rw [← rpow_left_inj hx _ hz, rpow_inv_rpow hy hz]; positivity
theorem le_rpow_iff_log_le (hx : 0 < x) (hy : 0 < y) : x ≤ y ^ z ↔ Real.log x ≤ z * Real.log y := by
rw [← Real.log_le_log_iff hx (Real.rpow_pos_of_pos hy z), Real.log_rpow hy]
theorem le_rpow_of_log_le (hx : 0 ≤ x) (hy : 0 < y) (h : Real.log x ≤ z * Real.log y) :
x ≤ y ^ z := by
obtain hx | rfl := hx.lt_or_eq
· exact (le_rpow_iff_log_le hx hy).2 h
exact (Real.rpow_pos_of_pos hy z).le
theorem lt_rpow_iff_log_lt (hx : 0 < x) (hy : 0 < y) : x < y ^ z ↔ Real.log x < z * Real.log y := by
rw [← Real.log_lt_log_iff hx (Real.rpow_pos_of_pos hy z), Real.log_rpow hy]
theorem lt_rpow_of_log_lt (hx : 0 ≤ x) (hy : 0 < y) (h : Real.log x < z * Real.log y) :
x < y ^ z := by
obtain hx | rfl := hx.lt_or_eq
· exact (lt_rpow_iff_log_lt hx hy).2 h
exact Real.rpow_pos_of_pos hy z
theorem rpow_le_one_iff_of_pos (hx : 0 < x) : x ^ y ≤ 1 ↔ 1 ≤ x ∧ y ≤ 0 ∨ x ≤ 1 ∧ 0 ≤ y := by
rw [rpow_def_of_pos hx, exp_le_one_iff, mul_nonpos_iff, log_nonneg_iff hx, log_nonpos_iff hx]
/-- Bound for `|log x * x ^ t|` in the interval `(0, 1]`, for positive real `t`. -/
theorem abs_log_mul_self_rpow_lt (x t : ℝ) (h1 : 0 < x) (h2 : x ≤ 1) (ht : 0 < t) :
|log x * x ^ t| < 1 / t := by
rw [lt_div_iff ht]
have := abs_log_mul_self_lt (x ^ t) (rpow_pos_of_pos h1 t) (rpow_le_one h1.le h2 ht.le)
rwa [log_rpow h1, mul_assoc, abs_mul, abs_of_pos ht, mul_comm] at this
/-- `log x` is bounded above by a multiple of every power of `x` with positive exponent. -/
lemma log_le_rpow_div {x ε : ℝ} (hx : 0 ≤ x) (hε : 0 < ε) : log x ≤ x ^ ε / ε := by
rcases hx.eq_or_lt with rfl | h
· rw [log_zero, zero_rpow hε.ne', zero_div]
rw [le_div_iff' hε]
exact (log_rpow h ε).symm.trans_le <| (log_le_sub_one_of_pos <| rpow_pos_of_pos h ε).trans
(sub_one_lt _).le
/-- The (real) logarithm of a natural number `n` is bounded by a multiple of every power of `n`
with positive exponent. -/
lemma log_natCast_le_rpow_div (n : ℕ) {ε : ℝ} (hε : 0 < ε) : log n ≤ n ^ ε / ε :=
log_le_rpow_div n.cast_nonneg hε
lemma strictMono_rpow_of_base_gt_one {b : ℝ} (hb : 1 < b) :
StrictMono (b ^ · : ℝ → ℝ) := by
simp_rw [Real.rpow_def_of_pos (zero_lt_one.trans hb)]
exact exp_strictMono.comp <| StrictMono.const_mul strictMono_id <| Real.log_pos hb
lemma monotone_rpow_of_base_ge_one {b : ℝ} (hb : 1 ≤ b) :
Monotone (b ^ · : ℝ → ℝ) := by
rcases lt_or_eq_of_le hb with hb | rfl
case inl => exact (strictMono_rpow_of_base_gt_one hb).monotone
case inr => intro _ _ _; simp
lemma strictAnti_rpow_of_base_lt_one {b : ℝ} (hb₀ : 0 < b) (hb₁ : b < 1) :
StrictAnti (b ^ · : ℝ → ℝ) := by
simp_rw [Real.rpow_def_of_pos hb₀]
exact exp_strictMono.comp_strictAnti <| StrictMono.const_mul_of_neg strictMono_id
<| Real.log_neg hb₀ hb₁
lemma antitone_rpow_of_base_le_one {b : ℝ} (hb₀ : 0 < b) (hb₁ : b ≤ 1) :
Antitone (b ^ · : ℝ → ℝ) := by
rcases lt_or_eq_of_le hb₁ with hb₁ | rfl
case inl => exact (strictAnti_rpow_of_base_lt_one hb₀ hb₁).antitone
case inr => intro _ _ _; simp
/-- Guessing rule for the `bound` tactic: when trying to prove `x ^ y ≤ x ^ z`, we can either assume
`1 ≤ x` or `0 < x ≤ 1`. -/
@[bound] lemma rpow_le_rpow_of_exponent_le_or_ge {x y z : ℝ}
(h : 1 ≤ x ∧ y ≤ z ∨ 0 < x ∧ x ≤ 1 ∧ z ≤ y) : x ^ y ≤ x ^ z := by
rcases h with ⟨x1, yz⟩ | ⟨x0, x1, zy⟩
· exact Real.rpow_le_rpow_of_exponent_le x1 yz
· exact Real.rpow_le_rpow_of_exponent_ge x0 x1 zy
end Real
namespace Complex
lemma norm_prime_cpow_le_one_half (p : Nat.Primes) {s : ℂ} (hs : 1 < s.re) :
‖(p : ℂ) ^ (-s)‖ ≤ 1 / 2 := by
rw [norm_natCast_cpow_of_re_ne_zero p <| by rw [neg_re]; linarith only [hs]]
refine (Real.rpow_le_rpow_of_nonpos zero_lt_two (Nat.cast_le.mpr p.prop.two_le) <|
by rw [neg_re]; linarith only [hs]).trans ?_
rw [one_div, ← Real.rpow_neg_one]
exact Real.rpow_le_rpow_of_exponent_le one_le_two <| (neg_lt_neg hs).le
lemma one_sub_prime_cpow_ne_zero {p : ℕ} (hp : p.Prime) {s : ℂ} (hs : 1 < s.re) :
1 - (p : ℂ) ^ (-s) ≠ 0 := by
refine sub_ne_zero_of_ne fun H ↦ ?_
have := norm_prime_cpow_le_one_half ⟨p, hp⟩ hs
simp only at this
rw [← H, norm_one] at this
norm_num at this
lemma norm_natCast_cpow_le_norm_natCast_cpow_of_pos {n : ℕ} (hn : 0 < n) {w z : ℂ}
(h : w.re ≤ z.re) :
‖(n : ℂ) ^ w‖ ≤ ‖(n : ℂ) ^ z‖ := by
simp_rw [norm_natCast_cpow_of_pos hn]
exact Real.rpow_le_rpow_of_exponent_le (by exact_mod_cast hn) h
lemma norm_natCast_cpow_le_norm_natCast_cpow_iff {n : ℕ} (hn : 1 < n) {w z : ℂ} :
‖(n : ℂ) ^ w‖ ≤ ‖(n : ℂ) ^ z‖ ↔ w.re ≤ z.re := by
simp_rw [norm_natCast_cpow_of_pos (Nat.zero_lt_of_lt hn),
Real.rpow_le_rpow_left_iff (Nat.one_lt_cast.mpr hn)]
lemma norm_log_natCast_le_rpow_div (n : ℕ) {ε : ℝ} (hε : 0 < ε) : ‖log n‖ ≤ n ^ ε / ε := by
rcases n.eq_zero_or_pos with rfl | h
· rw [Nat.cast_zero, Nat.cast_zero, log_zero, norm_zero, Real.zero_rpow hε.ne', zero_div]
rw [norm_eq_abs, ← natCast_log, abs_ofReal,
_root_.abs_of_nonneg <| Real.log_nonneg <| by exact_mod_cast Nat.one_le_of_lt h.lt]
exact Real.log_natCast_le_rpow_div n hε
end Complex
/-!
## Square roots of reals
-/
namespace Real
variable {z x y : ℝ}
section Sqrt
theorem sqrt_eq_rpow (x : ℝ) : √x = x ^ (1 / (2 : ℝ)) := by
obtain h | h := le_or_lt 0 x
· rw [← mul_self_inj_of_nonneg (sqrt_nonneg _) (rpow_nonneg h _), mul_self_sqrt h, ← sq,
← rpow_natCast, ← rpow_mul h]
norm_num
· have : 1 / (2 : ℝ) * π = π / (2 : ℝ) := by ring
rw [sqrt_eq_zero_of_nonpos h.le, rpow_def_of_neg h, this, cos_pi_div_two, mul_zero]
theorem rpow_div_two_eq_sqrt {x : ℝ} (r : ℝ) (hx : 0 ≤ x) : x ^ (r / 2) = √x ^ r := by
rw [sqrt_eq_rpow, ← rpow_mul hx]
congr
ring
end Sqrt
variable {n : ℕ}
theorem exists_rat_pow_btwn_rat_aux (hn : n ≠ 0) (x y : ℝ) (h : x < y) (hy : 0 < y) :
∃ q : ℚ, 0 < q ∧ x < (q : ℝ) ^ n ∧ (q : ℝ) ^ n < y := by
have hn' : 0 < (n : ℝ) := mod_cast hn.bot_lt
obtain ⟨q, hxq, hqy⟩ :=
exists_rat_btwn (rpow_lt_rpow (le_max_left 0 x) (max_lt hy h) <| inv_pos.mpr hn')
have := rpow_nonneg (le_max_left 0 x) n⁻¹
have hq := this.trans_lt hxq
replace hxq := rpow_lt_rpow this hxq hn'
replace hqy := rpow_lt_rpow hq.le hqy hn'
rw [rpow_natCast, rpow_natCast, rpow_inv_natCast_pow _ hn] at hxq hqy
· exact ⟨q, mod_cast hq, (le_max_right _ _).trans_lt hxq, hqy⟩
· exact hy.le
· exact le_max_left _ _
theorem exists_rat_pow_btwn_rat (hn : n ≠ 0) {x y : ℚ} (h : x < y) (hy : 0 < y) :
∃ q : ℚ, 0 < q ∧ x < q ^ n ∧ q ^ n < y := by
apply_mod_cast exists_rat_pow_btwn_rat_aux hn x y <;> assumption
/-- There is a rational power between any two positive elements of an archimedean ordered field. -/
theorem exists_rat_pow_btwn {α : Type*} [LinearOrderedField α] [Archimedean α] (hn : n ≠ 0)
{x y : α} (h : x < y) (hy : 0 < y) : ∃ q : ℚ, 0 < q ∧ x < (q : α) ^ n ∧ (q : α) ^ n < y := by
obtain ⟨q₂, hx₂, hy₂⟩ := exists_rat_btwn (max_lt h hy)
obtain ⟨q₁, hx₁, hq₁₂⟩ := exists_rat_btwn hx₂
have : (0 : α) < q₂ := (le_max_right _ _).trans_lt hx₂
norm_cast at hq₁₂ this
obtain ⟨q, hq, hq₁, hq₂⟩ := exists_rat_pow_btwn_rat hn hq₁₂ this
refine ⟨q, hq, (le_max_left _ _).trans_lt <| hx₁.trans ?_, hy₂.trans' ?_⟩ <;> assumption_mod_cast
end Real
namespace Complex
lemma cpow_inv_two_re (x : ℂ) : (x ^ (2⁻¹ : ℂ)).re = sqrt ((abs x + x.re) / 2) := by
rw [← ofReal_ofNat, ← ofReal_inv, cpow_ofReal_re, ← div_eq_mul_inv, ← one_div,
← Real.sqrt_eq_rpow, cos_half, ← sqrt_mul, ← mul_div_assoc, mul_add, mul_one, abs_mul_cos_arg]
exacts [abs.nonneg _, (neg_pi_lt_arg _).le, arg_le_pi _]
lemma cpow_inv_two_im_eq_sqrt {x : ℂ} (hx : 0 ≤ x.im) :
(x ^ (2⁻¹ : ℂ)).im = sqrt ((abs x - x.re) / 2) := by
rw [← ofReal_ofNat, ← ofReal_inv, cpow_ofReal_im, ← div_eq_mul_inv, ← one_div,
← Real.sqrt_eq_rpow, sin_half_eq_sqrt, ← sqrt_mul (abs.nonneg _), ← mul_div_assoc, mul_sub,
mul_one, abs_mul_cos_arg]
· rwa [arg_nonneg_iff]
· linarith [pi_pos, arg_le_pi x]
lemma cpow_inv_two_im_eq_neg_sqrt {x : ℂ} (hx : x.im < 0) :
(x ^ (2⁻¹ : ℂ)).im = -sqrt ((abs x - x.re) / 2) := by
rw [← ofReal_ofNat, ← ofReal_inv, cpow_ofReal_im, ← div_eq_mul_inv, ← one_div,
← Real.sqrt_eq_rpow, sin_half_eq_neg_sqrt, mul_neg, ← sqrt_mul (abs.nonneg _),
← mul_div_assoc, mul_sub, mul_one, abs_mul_cos_arg]
· linarith [pi_pos, neg_pi_lt_arg x]
· exact (arg_neg_iff.2 hx).le
lemma abs_cpow_inv_two_im (x : ℂ) : |(x ^ (2⁻¹ : ℂ)).im| = sqrt ((abs x - x.re) / 2) := by
rw [← ofReal_ofNat, ← ofReal_inv, cpow_ofReal_im, ← div_eq_mul_inv, ← one_div,
← Real.sqrt_eq_rpow, _root_.abs_mul, _root_.abs_of_nonneg (sqrt_nonneg _), abs_sin_half,
← sqrt_mul (abs.nonneg _), ← mul_div_assoc, mul_sub, mul_one, abs_mul_cos_arg]
end Complex
section Tactics
/-!
## Tactic extensions for real powers
-/
namespace Mathlib.Meta.NormNum
open Lean.Meta Qq
theorem isNat_rpow_pos {a b : ℝ} {nb ne : ℕ}
(pb : IsNat b nb) (pe' : IsNat (a ^ nb) ne) :
IsNat (a ^ b) ne := by
rwa [pb.out, rpow_natCast]
theorem isNat_rpow_neg {a b : ℝ} {nb ne : ℕ}
(pb : IsInt b (Int.negOfNat nb)) (pe' : IsNat (a ^ (Int.negOfNat nb)) ne) :
IsNat (a ^ b) ne := by
rwa [pb.out, Real.rpow_intCast]
theorem isInt_rpow_pos {a b : ℝ} {nb ne : ℕ}
(pb : IsNat b nb) (pe' : IsInt (a ^ nb) (Int.negOfNat ne)) :
IsInt (a ^ b) (Int.negOfNat ne) := by
rwa [pb.out, rpow_natCast]
theorem isInt_rpow_neg {a b : ℝ} {nb ne : ℕ}
(pb : IsInt b (Int.negOfNat nb)) (pe' : IsInt (a ^ (Int.negOfNat nb)) (Int.negOfNat ne)) :
IsInt (a ^ b) (Int.negOfNat ne) := by
rwa [pb.out, Real.rpow_intCast]
theorem isRat_rpow_pos {a b : ℝ} {nb : ℕ}
{num : ℤ} {den : ℕ}
(pb : IsNat b nb) (pe' : IsRat (a ^ nb) num den) :
IsRat (a ^ b) num den := by
rwa [pb.out, rpow_natCast]
theorem isRat_rpow_neg {a b : ℝ} {nb : ℕ}
{num : ℤ} {den : ℕ}
(pb : IsInt b (Int.negOfNat nb)) (pe' : IsRat (a ^ (Int.negOfNat nb)) num den) :
IsRat (a ^ b) num den := by
rwa [pb.out, Real.rpow_intCast]
/-- Evaluates expressions of the form `a ^ b` when `a` and `b` are both reals. -/
@[norm_num (_ : ℝ) ^ (_ : ℝ)]
def evalRPow : NormNumExt where eval {u α} e := do
let .app (.app f (a : Q(ℝ))) (b : Q(ℝ)) ← Lean.Meta.whnfR e | failure
guard <|← withNewMCtxDepth <| isDefEq f q(HPow.hPow (α := ℝ) (β := ℝ))
haveI' : u =QL 0 := ⟨⟩
haveI' : $α =Q ℝ := ⟨⟩
haveI' h : $e =Q $a ^ $b := ⟨⟩
h.check
let (rb : Result b) ← derive (α := q(ℝ)) b
match rb with
| .isBool .. | .isRat _ .. => failure
| .isNat sβ nb pb =>
match ← derive q($a ^ $nb) with
| .isBool .. => failure
| .isNat sα' ne' pe' =>
assumeInstancesCommute
haveI' : $sα' =Q AddGroupWithOne.toAddMonoidWithOne := ⟨⟩
return .isNat sα' ne' q(isNat_rpow_pos $pb $pe')
| .isNegNat sα' ne' pe' =>
assumeInstancesCommute
return .isNegNat sα' ne' q(isInt_rpow_pos $pb $pe')
| .isRat sα' qe' nume' dene' pe' =>
assumeInstancesCommute
return .isRat sα' qe' nume' dene' q(isRat_rpow_pos $pb $pe')
| .isNegNat sβ nb pb =>
match ← derive q($a ^ (-($nb : ℤ))) with
| .isBool .. => failure
| .isNat sα' ne' pe' =>
assumeInstancesCommute
return .isNat sα' ne' q(isNat_rpow_neg $pb $pe')
| .isNegNat sα' ne' pe' =>
let _ := q(Real.instRing)
assumeInstancesCommute
return .isNegNat sα' ne' q(isInt_rpow_neg $pb $pe')
| .isRat sα' qe' nume' dene' pe' =>
assumeInstancesCommute
return .isRat sα' qe' nume' dene' q(isRat_rpow_neg $pb $pe')
end Mathlib.Meta.NormNum
end Tactics
@[deprecated (since := "2024-01-07")] alias rpow_nonneg_of_nonneg := rpow_nonneg
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.