source stringlengths 17 118 | lean4 stringlengths 0 335k |
|---|---|
.lake/packages/mathlib/Mathlib/Dynamics/Ergodic/Action/Regular.lean | import Mathlib.Dynamics.Ergodic.Action.Basic
import Mathlib.MeasureTheory.Group.Prod
/-!
# Regular action of a group on itself is ergodic
In this file we prove that the left and right actions of a group on itself are ergodic.
-/
open MeasureTheory Measure Filter Set
open scoped Pointwise
variable {G : Type*} [Group G] [MeasurableSpace G] [MeasurableMul₂ G] [MeasurableInv G]
{μ : Measure G} [SFinite μ]
@[to_additive]
instance [μ.IsMulLeftInvariant] : ErgodicSMul G G μ := by
refine ⟨fun {s} hsm hs ↦ ?_⟩
suffices (∃ᵐ x ∂μ, x ∈ s) → ∀ᵐ x ∂μ, x ∈ s by
simp only [eventuallyConst_set, ← not_frequently]
exact or_not_of_imp this
intro hμs
obtain ⟨a, has, ha⟩ : ∃ a ∈ s, ∀ᵐ b ∂μ, (b * a ∈ s ↔ a ∈ s) := by
refine (hμs.and_eventually ?_).exists
rw [ae_ae_comm]
· exact ae_of_all _ fun b ↦ (hs b).mem_iff
· exact ((hsm.preimage <| measurable_snd.mul measurable_fst).mem.iff
(hsm.preimage measurable_fst).mem).setOf
simpa [has] using (MeasureTheory.quasiMeasurePreserving_mul_right μ a⁻¹).ae ha
@[to_additive]
instance [μ.IsMulRightInvariant] : ErgodicSMul Gᵐᵒᵖ G μ := by
refine ⟨fun {s} hsm hs ↦ ?_⟩
suffices (∃ᵐ x ∂μ, x ∈ s) → ∀ᵐ x ∂μ, x ∈ s by
simp only [eventuallyConst_set, ← not_frequently]
exact or_not_of_imp this
intro hμs
obtain ⟨a, has, ha⟩ : ∃ a ∈ s, ∀ᵐ b ∂μ, (a * b ∈ s ↔ a ∈ s) := by
refine (hμs.and_eventually ?_).exists
rw [ae_ae_comm]
· exact ae_of_all _ fun b ↦ (hs ⟨b⟩).mem_iff
· exact ((hsm.preimage <| measurable_fst.mul measurable_snd).mem.iff
(hsm.preimage measurable_fst).mem).setOf
simpa [has] using (quasiMeasurePreserving_mul_left μ a⁻¹).ae ha |
.lake/packages/mathlib/Mathlib/Dynamics/Ergodic/Action/Basic.lean | import Mathlib.MeasureTheory.Group.AEStabilizer
import Mathlib.Dynamics.Ergodic.Ergodic
/-!
# Ergodic group actions
A group action of `G` on a space `α` with measure `μ` is called *ergodic*,
if for any (null) measurable set `s`,
if it is a.e.-invariant under each scalar multiplication `(g • ·)`, `g : G`,
then it is either null or conull.
-/
open Set Filter MeasureTheory MulAction
open scoped Pointwise
/--
An additive group action of `G` on a space `α` with measure `μ` is called *ergodic*,
if for any (null) measurable set `s`,
if it is a.e.-invariant under each scalar addition `(g +ᵥ ·)`, `g : G`,
then it is either null or conull.
-/
class ErgodicVAdd (G α : Type*) [VAdd G α] {_ : MeasurableSpace α} (μ : Measure α) : Prop
extends VAddInvariantMeasure G α μ where
aeconst_of_forall_preimage_vadd_ae_eq {s : Set α} : MeasurableSet s →
(∀ g : G, (g +ᵥ ·) ⁻¹' s =ᵐ[μ] s) → EventuallyConst s (ae μ)
/--
A group action of `G` on a space `α` with measure `μ` is called *ergodic*,
if for any (null) measurable set `s`,
if it is a.e.-invariant under each scalar multiplication `(g • ·)`, `g : G`,
then it is either null or conull.
-/
@[to_additive, mk_iff]
class ErgodicSMul (G α : Type*) [SMul G α] {_ : MeasurableSpace α} (μ : Measure α) : Prop
extends SMulInvariantMeasure G α μ where
aeconst_of_forall_preimage_smul_ae_eq {s : Set α} : MeasurableSet s →
(∀ g : G, (g • ·) ⁻¹' s =ᵐ[μ] s) → EventuallyConst s (ae μ)
attribute [to_additive] ergodicSMul_iff
namespace MeasureTheory
variable (G : Type*) {α : Type*} {m : MeasurableSpace α} {μ : Measure α}
@[to_additive]
theorem aeconst_of_forall_preimage_smul_ae_eq [SMul G α] [ErgodicSMul G α μ] {s : Set α}
(hm : NullMeasurableSet s μ) (h : ∀ g : G, (g • ·) ⁻¹' s =ᵐ[μ] s) :
EventuallyConst s (ae μ) := by
rcases hm with ⟨t, htm, hst⟩
refine .congr ?_ hst.symm
refine ErgodicSMul.aeconst_of_forall_preimage_smul_ae_eq htm fun g : G ↦ ?_
refine .trans (.trans ?_ (h g)) hst
exact tendsto_smul_ae _ _ hst.symm
section Group
variable [Group G] [MulAction G α] [ErgodicSMul G α μ] {s : Set α}
@[to_additive]
theorem aeconst_of_forall_smul_ae_eq (hm : NullMeasurableSet s μ) (h : ∀ g : G, g • s =ᵐ[μ] s) :
EventuallyConst s (ae μ) :=
aeconst_of_forall_preimage_smul_ae_eq G hm fun g ↦ by
simpa only [preimage_smul] using h g⁻¹
@[to_additive]
theorem _root_.MulAction.aeconst_of_aestabilizer_eq_top
(hm : NullMeasurableSet s μ) (h : aestabilizer G μ s = ⊤) : EventuallyConst s (ae μ) :=
aeconst_of_forall_smul_ae_eq G hm <| (Subgroup.eq_top_iff' _).1 h
end Group
theorem _root_.ErgodicSMul.of_aestabilizer [Group G] [MulAction G α] [SMulInvariantMeasure G α μ]
(h : ∀ s, MeasurableSet s → aestabilizer G μ s = ⊤ → EventuallyConst s (ae μ)) :
ErgodicSMul G α μ :=
⟨fun hm hs ↦ h _ hm <| (Subgroup.eq_top_iff' _).2 fun g ↦ by
simpa only [preimage_smul_inv] using hs g⁻¹⟩
theorem ergodicSMul_iterateMulAct {f : α → α} (hf : Measurable f) :
ErgodicSMul (IterateMulAct f) α μ ↔ Ergodic f μ := by
simp only [ergodicSMul_iff, smulInvariantMeasure_iterateMulAct, hf]
refine ⟨fun ⟨h₁, h₂⟩ ↦ ⟨h₁, ⟨?_⟩⟩, fun h ↦ ⟨h.1, ?_⟩⟩
· intro s hm hs
refine h₂ hm fun n ↦ ?_
nth_rewrite 2 [← Function.IsFixedPt.preimage_iterate hs n.val]
rfl
· intro s hm hs
exact h.quasiErgodic.aeconst_set₀ hm.nullMeasurableSet <| hs (.mk 1)
end MeasureTheory |
.lake/packages/mathlib/Mathlib/Dynamics/Ergodic/Action/OfMinimal.lean | import Mathlib.Dynamics.Ergodic.Action.Regular
import Mathlib.MeasureTheory.Measure.ContinuousPreimage
import Mathlib.MeasureTheory.Measure.Haar.Unique
/-!
# Ergodicity from minimality
In this file we prove that the left shift `(a * ·)` on a compact topological group `G`
is ergodic with respect to the Haar measure if and only if it is minimal,
i.e., the powers `a ^ n` are dense in `G`.
The proof of the more difficult "if minimal, then ergodic" implication
is based on the ergodicity of the left action of a group on itself
and the following fact that we prove in `ergodic_smul_of_denseRange_pow` below:
If a monoid `M` continuously acts on an R₁ topological space `X`,
`g` is an element of `M` such that its natural powers are dense in `M`,
and `μ` is a finite inner regular measure on `X` which is ergodic with respect to the action of `M`,
then the scalar multiplication by `g` is an ergodic map.
We also prove that a continuous monoid homomorphism `f : G →* G` is ergodic,
if it is surjective and the preimages of `1` under iterations of `f` are dense in the group.
This theorem applies, e.g., to the map `z ↦ n • z` on the additive circle or a torus.
-/
open MeasureTheory Filter Set Function
open scoped Pointwise Topology
section SMul
variable {M : Type*} [TopologicalSpace M]
{X : Type*} [TopologicalSpace X] [R1Space X] [MeasurableSpace X] [BorelSpace X]
[SMul M X] [ContinuousSMul M X]
{μ : Measure X} [IsFiniteMeasure μ] [μ.InnerRegular] [ErgodicSMul M X μ] {s : Set X}
/-- Let `M` act continuously on an R₁ topological space `X`.
Let `μ` be a finite inner regular measure on `X` which is ergodic with respect to this action.
If a null measurable set `s` is a.e. equal
to its preimages under the action of a dense set of elements of `M`,
then it is either null or conull. -/
@[to_additive /-- Let `M` act continuously on an R₁ topological space `X`.
Let `μ` be a finite inner regular measure on `X` which is ergodic with respect to this action.
If a null measurable set `s` is a.e. equal
to its preimages under the action of a dense set of elements of `M`,
then it is either null or conull. -/]
theorem aeconst_of_dense_setOf_preimage_smul_ae (hsm : NullMeasurableSet s μ)
(hd : Dense {g : M | (g • ·) ⁻¹' s =ᵐ[μ] s}) : EventuallyConst s (ae μ) := by
borelize M
refine aeconst_of_forall_preimage_smul_ae_eq M hsm ?_
rwa [dense_iff_closure_eq, IsClosed.closure_eq, eq_univ_iff_forall] at hd
let f : C(M × X, X) := ⟨(· • ·).uncurry, continuous_smul⟩
exact isClosed_setOf_preimage_ae_eq f.curry.continuous (measurePreserving_smul · μ) _ hsm
(measure_ne_top _ _)
@[to_additive]
theorem aeconst_of_dense_setOf_preimage_smul_eq (hsm : NullMeasurableSet s μ)
(hd : Dense {g : M | (g • ·) ⁻¹' s = s}) : EventuallyConst s (ae μ) :=
aeconst_of_dense_setOf_preimage_smul_ae hsm <| hd.mono fun _ h ↦ mem_setOf.2 <| .of_eq h
/-- If a monoid `M` continuously acts on an R₁ topological space `X`,
`g` is an element of `M` such that its natural powers are dense in `M`,
and `μ` is a finite inner regular measure on `X` which is ergodic with respect to the action of `M`,
then the scalar multiplication by `g` is an ergodic map. -/
@[to_additive /-- If an additive monoid `M` continuously acts on an R₁ topological space `X`,
`g` is an element of `M` such that its natural multiples are dense in `M`,
and `μ` is a finite inner regular measure on `X` which is ergodic with respect to the action of `M`,
then the vector addition of `g` is an ergodic map. -/]
theorem ergodic_smul_of_denseRange_pow {M : Type*} [Monoid M] [TopologicalSpace M]
[MulAction M X] [ContinuousSMul M X] {g : M} (hg : DenseRange (g ^ · : ℕ → M))
(μ : Measure X) [IsFiniteMeasure μ] [μ.InnerRegular] [ErgodicSMul M X μ] :
Ergodic (g • ·) μ := by
borelize M
refine ⟨measurePreserving_smul _ _, ⟨fun s hsm hs ↦ ?_⟩⟩
refine aeconst_of_dense_setOf_preimage_smul_eq hsm.nullMeasurableSet (hg.mono ?_)
refine range_subset_iff.2 fun n ↦ ?_
rw [mem_setOf, ← smul_iterate, preimage_iterate_eq, iterate_fixed hs]
end SMul
section IsScalarTower
variable {M X : Type*} [Monoid M] [SMul M X]
[TopologicalSpace X] [R1Space X] [MeasurableSpace X] [BorelSpace X]
(μ : Measure X) [IsFiniteMeasure μ] [μ.InnerRegular]
/-- If `N` acts continuously and ergodically on `X` and `M` acts minimally on `N`,
then the corresponding action of `M` on `X` is ergodic. -/
@[to_additive
/-- If `N` acts additively continuously and ergodically on `X` and `M` acts minimally on `N`,
then the corresponding action of `M` on `X` is ergodic. -/]
theorem ErgodicSMul.trans_isMinimal (N : Type*) [MulAction M N]
[Monoid N] [TopologicalSpace N] [MulAction.IsMinimal M N]
[MulAction N X] [IsScalarTower M N X] [ContinuousSMul N X] [ErgodicSMul N X μ] :
ErgodicSMul M X μ where
measure_preimage_smul c s hsm := by
simpa only [smul_one_smul] using SMulInvariantMeasure.measure_preimage_smul (c • 1 : N) hsm
aeconst_of_forall_preimage_smul_ae_eq {s} hsm hs := by
refine aeconst_of_dense_setOf_preimage_smul_ae (M := N) hsm.nullMeasurableSet ?_
refine (MulAction.dense_orbit M 1).mono ?_
rintro _ ⟨g, rfl⟩
simpa using hs g
end IsScalarTower
section MulActionGroup
variable {G : Type*} [Group G] [TopologicalSpace G] [ContinuousInv G]
{X : Type*} [TopologicalSpace X] [R1Space X] [MeasurableSpace X] [BorelSpace X]
[MulAction G X] [ContinuousSMul G X]
{μ : Measure X} [IsFiniteMeasure μ] [μ.InnerRegular] [ErgodicSMul G X μ] {s : Set X}
@[to_additive]
theorem aeconst_of_dense_aestabilizer_smul (hsm : NullMeasurableSet s μ)
(hd : Dense (MulAction.aestabilizer G μ s : Set G)) : EventuallyConst s (ae μ) :=
aeconst_of_dense_setOf_preimage_smul_ae hsm <| (hd.preimage (isOpenMap_inv _)).mono fun g hg ↦ by
simpa only [preimage_smul] using hg
/-- If a monoid `M` continuously acts on an R₁ topological space `X`,
`g` is an element of `M` such that its integer powers are dense in `M`,
and `μ` is a finite inner regular measure on `X` which is ergodic with respect to the action of `M`,
then the scalar multiplication by `g` is an ergodic map. -/
@[to_additive /-- If an additive monoid `M` continuously acts on an R₁ topological space `X`,
`g` is an element of `M` such that its integer multiples are dense in `M`,
and `μ` is a finite inner regular measure on `X` which is ergodic with respect to the action of `M`,
then the vector addition of `g` is an ergodic map. -/]
theorem ergodic_smul_of_denseRange_zpow {g : G} (hg : DenseRange (g ^ · : ℤ → G))
(μ : Measure X) [IsFiniteMeasure μ] [μ.InnerRegular] [ErgodicSMul G X μ] :
Ergodic (g • ·) μ := by
borelize G
refine ⟨measurePreserving_smul _ _, ⟨fun s hsm hs ↦ ?_⟩⟩
refine aeconst_of_dense_aestabilizer_smul hsm.nullMeasurableSet (hg.mono ?_)
rw [← Subgroup.coe_zpowers, SetLike.coe_subset_coe, ← Subgroup.zpowers_inv, Subgroup.zpowers_le,
MulAction.mem_aestabilizer, ← preimage_smul, hs]
end MulActionGroup
section IsTopologicalGroup
variable {G : Type*} [Group G] [TopologicalSpace G] [IsTopologicalGroup G] [MeasurableSpace G]
/-- If the left multiplication by `g` is ergodic
with respect to a measure which is positive on nonempty open sets,
then the integer powers of `g` are dense in `G`. -/
@[to_additive /-- If the left addition of `g` is ergodic
with respect to a measure which is positive on nonempty open sets,
then the integer multiples of `g` are dense in `G`. -/]
theorem DenseRange.zpow_of_ergodic_mul_left [OpensMeasurableSpace G]
{μ : Measure G} [μ.IsOpenPosMeasure] {g : G} (hg : Ergodic (g * ·) μ) :
DenseRange (g ^ · : ℤ → G) := by
intro a
by_contra h
obtain ⟨V, hV₁, hVo, hV⟩ :
∃ V : Set G, 1 ∈ V ∧ IsOpen V ∧ ∀ x ∈ V, ∀ y ∈ V, ∀ m : ℤ, g ^ m ≠ a * x / y := by
rw [← mem_compl_iff, ← interior_compl, mem_interior_iff_mem_nhds] at h
have : Tendsto (fun (x, y) ↦ a * x / y) (𝓝 1) (𝓝 a) :=
Continuous.tendsto' (by fun_prop) _ _ (by simp)
rw [nhds_prod_eq] at this
simpa [(nhds_basis_opens (1 : G)).prod_self.mem_iff, prod_subset_iff, and_assoc] using this h
set s := ⋃ m : ℤ, g ^ m • V
have hso : IsOpen s := isOpen_iUnion fun m ↦ hVo.smul _
have hsne : s.Nonempty := ⟨1, mem_iUnion.2 ⟨0, by simpa⟩⟩
have hd : Disjoint s (a • V) := by
simp_rw [s, disjoint_iUnion_left, disjoint_left]
rintro m _ ⟨x, hx, rfl⟩ ⟨y, hy, hxy⟩
apply hV y hy x hx m
simp_all
have hgs : (g * ·) ⁻¹' s = s := by
simp only [s, preimage_iUnion, ← smul_eq_mul, preimage_smul]
refine iUnion_congr_of_surjective _ (add_left_surjective (-1)) fun m ↦ ?_
simp [zpow_add, mul_smul]
cases hg.measure_self_or_compl_eq_zero hso.measurableSet hgs with
| inl h => exact hso.measure_ne_zero _ hsne h
| inr h =>
refine (hVo.smul a).measure_ne_zero μ (.image _ ⟨1, hV₁⟩) (measure_mono_null ?_ h)
rwa [disjoint_right] at hd
variable [SecondCountableTopology G] [BorelSpace G] {g : G}
@[to_additive]
theorem ergodic_mul_left_of_denseRange_pow (hg : DenseRange (g ^ · : ℕ → G))
(μ : Measure G) [IsFiniteMeasure μ] [μ.InnerRegular] [μ.IsMulLeftInvariant] :
Ergodic (g * ·) μ :=
ergodic_smul_of_denseRange_pow hg μ
@[to_additive]
theorem ergodic_mul_left_of_denseRange_zpow (hg : DenseRange (g ^ · : ℤ → G))
(μ : Measure G) [IsFiniteMeasure μ] [μ.InnerRegular] [μ.IsMulLeftInvariant] :
Ergodic (g * ·) μ :=
ergodic_smul_of_denseRange_zpow hg μ
@[to_additive]
theorem ergodic_mul_left_iff_denseRange_zpow (μ : Measure G) [IsFiniteMeasure μ]
[μ.InnerRegular] [μ.IsMulLeftInvariant] [NeZero μ] :
Ergodic (g * ·) μ ↔ DenseRange (g ^ · : ℤ → G) :=
⟨.zpow_of_ergodic_mul_left, (ergodic_mul_left_of_denseRange_zpow · μ)⟩
end IsTopologicalGroup
namespace MonoidHom
variable {G : Type*} [Group G] [TopologicalSpace G]
[IsTopologicalGroup G] [SecondCountableTopology G] [MeasurableSpace G] [BorelSpace G]
/-- Let `f : G →* G` be a group endomorphism of a topological group with second countable topology.
If the preimages of `1` under the iterations of `f` are dense,
then it is preergodic with respect to any finite inner regular left invariant measure. -/
@[to_additive /-- Let `f : G →+ G` be an additive group endomorphism
of a topological additive group with second countable topology.
If the preimages of `0` under the iterations of `f` are dense,
then it is preergodic with respect to any finite inner regular left invariant measure. -/]
theorem preErgodic_of_dense_iUnion_preimage_one
{μ : Measure G} [IsFiniteMeasure μ] [μ.InnerRegular] [μ.IsMulLeftInvariant]
(f : G →* G) (hf : Dense (⋃ n, f^[n] ⁻¹' 1)) : PreErgodic f μ := by
refine ⟨fun s hsm hs ↦ aeconst_of_dense_setOf_preimage_smul_eq (M := G) hsm.nullMeasurableSet ?_⟩
refine hf.mono <| iUnion_subset fun n x hx ↦ ?_
have hsn : f^[n] ⁻¹' s = s := by
rw [preimage_iterate_eq, iterate_fixed hs]
rw [mem_preimage, Set.mem_one] at hx
rw [mem_setOf, ← hsn]
ext y
simp [hx]
/-- Let `f : G →* G` be a continuous surjective group endomorphism
of a compact topological group with second countable topology.
If the preimages of `1` under the iterations of `f` are dense,
then `f` is ergodic with respect to any finite inner regular left invariant measure. -/
@[to_additive /-- Let `f : G →+ G` be a continuous surjective additive group endomorphism
of a compact topological additive group with second countable topology.
If the preimages of `0` under the iterations of `f` are dense,
then `f` is ergodic with respect to any finite inner regular left invariant measure. -/]
theorem ergodic_of_dense_iUnion_preimage_one [CompactSpace G] {μ : Measure G} [μ.IsHaarMeasure]
(f : G →* G) (hf : Dense (⋃ n, f^[n] ⁻¹' 1)) (hcont : Continuous f) (hsurj : Surjective f) :
Ergodic f μ :=
⟨f.measurePreserving hcont hsurj rfl, f.preErgodic_of_dense_iUnion_preimage_one hf⟩
end MonoidHom |
.lake/packages/mathlib/Mathlib/Dynamics/PeriodicPts/Lemmas.lean | import Mathlib.Data.Fintype.Card
import Mathlib.Data.Fintype.EquivFin
import Mathlib.Data.Nat.Prime.Basic
import Mathlib.Data.PNat.Basic
import Mathlib.Data.Set.Lattice.Image
import Mathlib.Dynamics.PeriodicPts.Defs
/-!
# Extra lemmas about periodic points
-/
open Nat Set
namespace Function
variable {α : Type*} {f : α → α} {x y : α}
open Function (Commute)
theorem directed_ptsOfPeriod_pnat (f : α → α) : Directed (· ⊆ ·) fun n : ℕ+ => ptsOfPeriod f n :=
fun m n => ⟨m * n, fun _ hx => hx.mul_const n, fun _ hx => hx.const_mul m⟩
@[deprecated (since := "2025-04-27")]
alias directed_ptsOfPeriod_pNat := directed_ptsOfPeriod_pnat
variable (f) in
theorem bijOn_periodicPts : BijOn f (periodicPts f) (periodicPts f) :=
iUnion_pnat_ptsOfPeriod f ▸
bijOn_iUnion_of_directed (directed_ptsOfPeriod_pnat f) fun i => bijOn_ptsOfPeriod f i.pos
theorem minimalPeriod_eq_prime_iff {p : ℕ} [hp : Fact p.Prime] :
minimalPeriod f x = p ↔ IsPeriodicPt f p x ∧ ¬IsFixedPt f x := by
rw [Function.isPeriodicPt_iff_minimalPeriod_dvd, Nat.dvd_prime hp.out,
← minimalPeriod_eq_one_iff_isFixedPt.not, or_and_right, and_not_self_iff, false_or,
iff_self_and]
exact fun h ↦ ne_of_eq_of_ne h hp.out.ne_one
/-- The backward direction of `minimalPeriod_eq_prime_iff`. -/
theorem minimalPeriod_eq_prime {p : ℕ} [hp : Fact p.Prime] (hper : IsPeriodicPt f p x)
(hfix : ¬IsFixedPt f x) : minimalPeriod f x = p :=
minimalPeriod_eq_prime_iff.mpr ⟨hper, hfix⟩
theorem minimalPeriod_eq_prime_pow {p k : ℕ} [hp : Fact p.Prime] (hk : ¬IsPeriodicPt f (p ^ k) x)
(hk1 : IsPeriodicPt f (p ^ (k + 1)) x) : minimalPeriod f x = p ^ (k + 1) := by
apply Nat.eq_prime_pow_of_dvd_least_prime_pow hp.out <;>
rwa [← isPeriodicPt_iff_minimalPeriod_dvd]
theorem Commute.minimalPeriod_of_comp_dvd_mul {g : α → α} (h : Commute f g) :
minimalPeriod (f ∘ g) x ∣ minimalPeriod f x * minimalPeriod g x :=
dvd_trans h.minimalPeriod_of_comp_dvd_lcm (lcm_dvd_mul _ _)
theorem Commute.minimalPeriod_of_comp_eq_mul_of_coprime {g : α → α} (h : Commute f g)
(hco : Coprime (minimalPeriod f x) (minimalPeriod g x)) :
minimalPeriod (f ∘ g) x = minimalPeriod f x * minimalPeriod g x := by
apply h.minimalPeriod_of_comp_dvd_mul.antisymm
suffices
∀ {f g : α → α},
Commute f g →
Coprime (minimalPeriod f x) (minimalPeriod g x) →
minimalPeriod f x ∣ minimalPeriod (f ∘ g) x from
hco.mul_dvd_of_dvd_of_dvd (this h hco) (h.comp_eq.symm ▸ this h.symm hco.symm)
intro f g h hco
refine hco.dvd_of_dvd_mul_left (IsPeriodicPt.left_of_comp h ?_ ?_).minimalPeriod_dvd
· exact (isPeriodicPt_minimalPeriod _ _).const_mul _
· exact (isPeriodicPt_minimalPeriod _ _).mul_const _
section Fintype
open Fintype
theorem minimalPeriod_le_card [Fintype α] : minimalPeriod f x ≤ card α := by
rw [← periodicOrbit_length]
exact List.Nodup.length_le_card nodup_periodicOrbit
theorem isPeriodicPt_factorial_card_of_mem_periodicPts [Fintype α] (h : x ∈ periodicPts f) :
IsPeriodicPt f (card α)! x :=
isPeriodicPt_iff_minimalPeriod_dvd.mpr
(Nat.dvd_factorial (minimalPeriod_pos_of_mem_periodicPts h) minimalPeriod_le_card)
theorem mem_periodicPts_iff_isPeriodicPt_factorial_card [Fintype α] :
x ∈ periodicPts f ↔ IsPeriodicPt f (card α)! x where
mp := isPeriodicPt_factorial_card_of_mem_periodicPts
mpr h := minimalPeriod_pos_iff_mem_periodicPts.mp
(IsPeriodicPt.minimalPeriod_pos (Nat.factorial_pos _) h)
theorem Injective.mem_periodicPts [Finite α] (h : Injective f) (x : α) : x ∈ periodicPts f := by
obtain ⟨m, n, heq, hne⟩ : ∃ m n, f^[m] x = f^[n] x ∧ m ≠ n := by
simpa [Injective] using not_injective_infinite_finite (f^[·] x)
rcases lt_or_gt_of_ne hne with hlt | hlt
· exact mk_mem_periodicPts (by cutsat) (iterate_cancel h heq.symm)
· exact mk_mem_periodicPts (by cutsat) (iterate_cancel h heq)
@[deprecated (since := "2025-04-27")]
alias mem_periodicPts_of_injective := Injective.mem_periodicPts
theorem injective_iff_periodicPts_eq_univ [Finite α] : Injective f ↔ periodicPts f = univ := by
refine ⟨fun h ↦ eq_univ_iff_forall.mpr h.mem_periodicPts, fun h ↦ ?_⟩
rw [Finite.injective_iff_surjective, ← range_eq_univ, ← univ_subset_iff, ← h]
apply periodicPts_subset_range
@[deprecated (since := "2025-04-27")]
alias injective_iff_forall_mem_periodicPts := injective_iff_periodicPts_eq_univ
theorem injective_iff_iterate_factorial_card_eq_id [Fintype α] :
Injective f ↔ f^[(card α)!] = id := by
simp only [injective_iff_periodicPts_eq_univ, mem_periodicPts_iff_isPeriodicPt_factorial_card,
funext_iff, eq_univ_iff_forall, IsPeriodicPt, id, IsFixedPt]
end Fintype
end Function
namespace Function
variable {α β : Type*} {f : α → α} {g : β → β} {x : α × β} {a : α} {b : β} {m n : ℕ}
theorem minimalPeriod_prodMap (f : α → α) (g : β → β) (x : α × β) :
minimalPeriod (Prod.map f g) x = (minimalPeriod f x.1).lcm (minimalPeriod g x.2) :=
eq_of_forall_dvd <| by simp [← isPeriodicPt_iff_minimalPeriod_dvd, Nat.lcm_dvd_iff]
theorem minimalPeriod_fst_dvd : minimalPeriod f x.1 ∣ minimalPeriod (Prod.map f g) x := by
rw [minimalPeriod_prodMap]; exact Nat.dvd_lcm_left _ _
theorem minimalPeriod_snd_dvd : minimalPeriod g x.2 ∣ minimalPeriod (Prod.map f g) x := by
rw [minimalPeriod_prodMap]; exact Nat.dvd_lcm_right _ _
end Function |
.lake/packages/mathlib/Mathlib/Dynamics/PeriodicPts/Defs.lean | import Mathlib.Algebra.Group.Action.Defs
import Mathlib.Algebra.Order.Group.Nat
import Mathlib.Algebra.Order.Sub.Basic
import Mathlib.Data.List.Cycle
import Mathlib.Data.PNat.Notation
import Mathlib.Dynamics.FixedPoints.Basic
/-!
# Periodic points
A point `x : α` is a periodic point of `f : α → α` of period `n` if `f^[n] x = x`.
## Main definitions
* `IsPeriodicPt f n x` : `x` is a periodic point of `f` of period `n`, i.e. `f^[n] x = x`.
We do not require `n > 0` in the definition.
* `ptsOfPeriod f n` : the set `{x | IsPeriodicPt f n x}`. Note that `n` is not required to
be the minimal period of `x`.
* `periodicPts f` : the set of all periodic points of `f`.
* `minimalPeriod f x` : the minimal period of a point `x` under an endomorphism `f` or zero
if `x` is not a periodic point of `f`.
* `orbit f x`: the cycle `[x, f x, f (f x), ...]` for a periodic point.
* `MulAction.period g x` : the minimal period of a point `x` under the multiplicative action of `g`;
an equivalent `AddAction.period g x` is defined for additive actions.
## Main statements
We provide “dot syntax”-style operations on terms of the form `h : IsPeriodicPt f n x` including
arithmetic operations on `n` and `h.map (hg : SemiconjBy g f f')`. We also prove that `f`
is bijective on each set `ptsOfPeriod f n` and on `periodicPts f`. Finally, we prove that `x`
is a periodic point of `f` of period `n` if and only if `minimalPeriod f x | n`.
## References
* https://en.wikipedia.org/wiki/Periodic_point
-/
assert_not_exists MonoidWithZero
open Set
namespace Function
open Function (Commute)
variable {α : Type*} {β : Type*} {f fa : α → α} {fb : β → β} {x y : α} {m n : ℕ}
/-- A point `x` is a periodic point of `f : α → α` of period `n` if `f^[n] x = x`.
Note that we do not require `0 < n` in this definition. Many theorems about periodic points
need this assumption. -/
def IsPeriodicPt (f : α → α) (n : ℕ) (x : α) :=
IsFixedPt f^[n] x
/-- A fixed point of `f` is a periodic point of `f` of any prescribed period. -/
theorem IsFixedPt.isPeriodicPt (hf : IsFixedPt f x) (n : ℕ) : IsPeriodicPt f n x :=
hf.iterate n
/-- For the identity map, all points are periodic. -/
theorem is_periodic_id (n : ℕ) (x : α) : IsPeriodicPt id n x :=
(isFixedPt_id x).isPeriodicPt n
/-- Any point is a periodic point of period `0`. -/
theorem isPeriodicPt_zero (f : α → α) (x : α) : IsPeriodicPt f 0 x :=
isFixedPt_id x
namespace IsPeriodicPt
@[nontriviality]
theorem of_subsingleton [Subsingleton α] (f : α → α) (n : ℕ) (x : α) : IsPeriodicPt f n x :=
IsFixedPt.of_subsingleton _ _
instance [DecidableEq α] {f : α → α} {n : ℕ} {x : α} : Decidable (IsPeriodicPt f n x) :=
IsFixedPt.decidable
protected theorem isFixedPt (hf : IsPeriodicPt f n x) : IsFixedPt f^[n] x :=
hf
protected theorem map (hx : IsPeriodicPt fa n x) {g : α → β} (hg : Semiconj g fa fb) :
IsPeriodicPt fb n (g x) :=
IsFixedPt.map hx (hg.iterate_right n)
theorem apply_iterate (hx : IsPeriodicPt f n x) (m : ℕ) : IsPeriodicPt f n (f^[m] x) :=
hx.map <| Commute.iterate_self f m
protected theorem apply (hx : IsPeriodicPt f n x) : IsPeriodicPt f n (f x) :=
hx.apply_iterate 1
protected theorem add (hn : IsPeriodicPt f n x) (hm : IsPeriodicPt f m x) :
IsPeriodicPt f (n + m) x := by
rw [IsPeriodicPt, iterate_add]
exact hn.comp hm
theorem left_of_add (hn : IsPeriodicPt f (n + m) x) (hm : IsPeriodicPt f m x) :
IsPeriodicPt f n x := by
rw [IsPeriodicPt, iterate_add] at hn
exact hn.left_of_comp hm
theorem right_of_add (hn : IsPeriodicPt f (n + m) x) (hm : IsPeriodicPt f n x) :
IsPeriodicPt f m x := by
rw [add_comm] at hn
exact hn.left_of_add hm
protected theorem sub (hm : IsPeriodicPt f m x) (hn : IsPeriodicPt f n x) :
IsPeriodicPt f (m - n) x := by
rcases le_total n m with h | h
· refine left_of_add ?_ hn
rwa [tsub_add_cancel_of_le h]
· rw [tsub_eq_zero_iff_le.mpr h]
apply isPeriodicPt_zero
protected theorem mul_const (hm : IsPeriodicPt f m x) (n : ℕ) : IsPeriodicPt f (m * n) x := by
simp only [IsPeriodicPt, iterate_mul, hm.isFixedPt.iterate n]
protected theorem const_mul (hm : IsPeriodicPt f m x) (n : ℕ) : IsPeriodicPt f (n * m) x := by
simp only [mul_comm n, hm.mul_const n]
theorem trans_dvd (hm : IsPeriodicPt f m x) {n : ℕ} (hn : m ∣ n) : IsPeriodicPt f n x :=
let ⟨k, hk⟩ := hn
hk.symm ▸ hm.mul_const k
protected theorem iterate (hf : IsPeriodicPt f n x) (m : ℕ) : IsPeriodicPt f^[m] n x := by
rw [IsPeriodicPt, ← iterate_mul, mul_comm, iterate_mul]
exact hf.isFixedPt.iterate m
theorem comp {g : α → α} (hco : Commute f g) (hf : IsPeriodicPt f n x) (hg : IsPeriodicPt g n x) :
IsPeriodicPt (f ∘ g) n x := by
rw [IsPeriodicPt, hco.comp_iterate]
exact IsFixedPt.comp hf hg
theorem comp_lcm {g : α → α} (hco : Commute f g) (hf : IsPeriodicPt f m x)
(hg : IsPeriodicPt g n x) : IsPeriodicPt (f ∘ g) (Nat.lcm m n) x :=
(hf.trans_dvd <| Nat.dvd_lcm_left _ _).comp hco (hg.trans_dvd <| Nat.dvd_lcm_right _ _)
theorem left_of_comp {g : α → α} (hco : Commute f g) (hfg : IsPeriodicPt (f ∘ g) n x)
(hg : IsPeriodicPt g n x) : IsPeriodicPt f n x := by
rw [IsPeriodicPt, hco.comp_iterate] at hfg
exact hfg.left_of_comp hg
theorem iterate_mod_apply (h : IsPeriodicPt f n x) (m : ℕ) : f^[m % n] x = f^[m] x := by
conv_rhs => rw [← Nat.mod_add_div m n, iterate_add_apply, (h.mul_const _).eq]
protected theorem mod (hm : IsPeriodicPt f m x) (hn : IsPeriodicPt f n x) :
IsPeriodicPt f (m % n) x :=
(hn.iterate_mod_apply m).trans hm
protected theorem gcd (hm : IsPeriodicPt f m x) (hn : IsPeriodicPt f n x) :
IsPeriodicPt f (m.gcd n) x := by
revert hm hn
refine Nat.gcd.induction m n (fun n _ hn => ?_) fun m n _ ih hm hn => ?_
· rwa [Nat.gcd_zero_left]
· rw [Nat.gcd_rec]
exact ih (hn.mod hm) hm
/-- If `f` sends two periodic points `x` and `y` of the same positive period to the same point,
then `x = y`. For a similar statement about points of different periods see `eq_of_apply_eq`. -/
theorem eq_of_apply_eq_same (hx : IsPeriodicPt f n x) (hy : IsPeriodicPt f n y) (hn : 0 < n)
(h : f x = f y) : x = y := by
rw [← hx.eq, ← hy.eq, ← iterate_pred_comp_of_pos f hn, comp_apply, comp_apply, h]
/-- If `f` sends two periodic points `x` and `y` of positive periods to the same point,
then `x = y`. -/
theorem eq_of_apply_eq (hx : IsPeriodicPt f m x) (hy : IsPeriodicPt f n y) (hm : 0 < m) (hn : 0 < n)
(h : f x = f y) : x = y :=
(hx.mul_const n).eq_of_apply_eq_same (hy.const_mul m) (Nat.mul_pos hm hn) h
end IsPeriodicPt
/-- The set of periodic points of a given (possibly non-minimal) period. -/
def ptsOfPeriod (f : α → α) (n : ℕ) : Set α :=
{ x : α | IsPeriodicPt f n x }
@[simp]
theorem mem_ptsOfPeriod : x ∈ ptsOfPeriod f n ↔ IsPeriodicPt f n x :=
Iff.rfl
theorem Semiconj.mapsTo_ptsOfPeriod {g : α → β} (h : Semiconj g fa fb) (n : ℕ) :
MapsTo g (ptsOfPeriod fa n) (ptsOfPeriod fb n) :=
(h.iterate_right n).mapsTo_fixedPoints
theorem bijOn_ptsOfPeriod (f : α → α) {n : ℕ} (hn : 0 < n) :
BijOn f (ptsOfPeriod f n) (ptsOfPeriod f n) :=
⟨(Commute.refl f).mapsTo_ptsOfPeriod n, fun _ hx _ hy hxy => hx.eq_of_apply_eq_same hy hn hxy,
fun x hx =>
⟨f^[n.pred] x, hx.apply_iterate _, by
rw [← comp_apply (f := f), comp_iterate_pred_of_pos f hn, hx.eq]⟩⟩
/-- The set of periodic points of a map `f : α → α`. -/
def periodicPts (f : α → α) : Set α :=
{ x : α | ∃ n > 0, IsPeriodicPt f n x }
theorem mk_mem_periodicPts (hn : 0 < n) (hx : IsPeriodicPt f n x) : x ∈ periodicPts f :=
⟨n, hn, hx⟩
theorem mem_periodicPts : x ∈ periodicPts f ↔ ∃ n > 0, IsPeriodicPt f n x :=
Iff.rfl
theorem periodicPts_subset_range : periodicPts f ⊆ range f := by
intro x h
rw [mem_periodicPts] at h
rcases h with ⟨n, _, h⟩
use f^[n - 1] x
nth_rw 1 [← iterate_one f]
rw [← iterate_add_apply, Nat.add_sub_cancel' (by cutsat)]
exact h
@[deprecated (since := "2025-04-27")]
alias periodicPts_subset_image := periodicPts_subset_range
theorem isPeriodicPt_of_mem_periodicPts_of_isPeriodicPt_iterate (hx : x ∈ periodicPts f)
(hm : IsPeriodicPt f m (f^[n] x)) : IsPeriodicPt f m x := by
rcases hx with ⟨r, hr, hr'⟩
suffices n ≤ (n / r + 1) * r by
unfold IsPeriodicPt IsFixedPt
convert (hm.apply_iterate ((n / r + 1) * r - n)).eq <;>
rw [← iterate_add_apply, Nat.sub_add_cancel this, iterate_mul, (hr'.iterate _).eq]
rw [Nat.add_mul, one_mul]
exact (Nat.lt_div_mul_add hr).le
variable (f)
theorem bUnion_ptsOfPeriod : ⋃ n > 0, ptsOfPeriod f n = periodicPts f :=
Set.ext fun x => by simp [mem_periodicPts]
theorem iUnion_pnat_ptsOfPeriod : ⋃ n : ℕ+, ptsOfPeriod f n = periodicPts f :=
iSup_subtype.trans <| bUnion_ptsOfPeriod f
@[deprecated (since := "2025-04-27")]
alias iUnion_pNat_ptsOfPeriod := iUnion_pnat_ptsOfPeriod
variable {f}
theorem Semiconj.mapsTo_periodicPts {g : α → β} (h : Semiconj g fa fb) :
MapsTo g (periodicPts fa) (periodicPts fb) := fun _ ⟨n, hn, hx⟩ => ⟨n, hn, hx.map h⟩
noncomputable section
open scoped Classical in
/-- Minimal period of a point `x` under an endomorphism `f`. If `x` is not a periodic point of `f`,
then `minimalPeriod f x = 0`. -/
def minimalPeriod (f : α → α) (x : α) :=
if h : x ∈ periodicPts f then Nat.find h else 0
theorem isPeriodicPt_minimalPeriod (f : α → α) (x : α) : IsPeriodicPt f (minimalPeriod f x) x := by
classical
delta minimalPeriod
split_ifs with hx
· exact (Nat.find_spec hx).2
· exact isPeriodicPt_zero f x
@[simp]
theorem iterate_minimalPeriod : f^[minimalPeriod f x] x = x :=
isPeriodicPt_minimalPeriod f x
@[simp]
theorem iterate_add_minimalPeriod_eq : f^[n + minimalPeriod f x] x = f^[n] x := by
rw [iterate_add_apply]
congr
exact isPeriodicPt_minimalPeriod f x
@[simp]
theorem iterate_mod_minimalPeriod_eq : f^[n % minimalPeriod f x] x = f^[n] x :=
(isPeriodicPt_minimalPeriod f x).iterate_mod_apply n
theorem minimalPeriod_pos_of_mem_periodicPts (hx : x ∈ periodicPts f) : 0 < minimalPeriod f x := by
classical
simp only [minimalPeriod, dif_pos hx, (Nat.find_spec hx).1.lt]
theorem minimalPeriod_eq_zero_of_notMem_periodicPts (hx : x ∉ periodicPts f) :
minimalPeriod f x = 0 := by simp only [minimalPeriod, dif_neg hx]
@[deprecated (since := "2025-05-24")]
alias minimalPeriod_eq_zero_of_nmem_periodicPts := minimalPeriod_eq_zero_of_notMem_periodicPts
theorem IsPeriodicPt.minimalPeriod_pos (hn : 0 < n) (hx : IsPeriodicPt f n x) :
0 < minimalPeriod f x :=
minimalPeriod_pos_of_mem_periodicPts <| mk_mem_periodicPts hn hx
theorem minimalPeriod_pos_iff_mem_periodicPts : 0 < minimalPeriod f x ↔ x ∈ periodicPts f :=
⟨not_imp_not.1 fun h => by simp only [minimalPeriod, dif_neg h, lt_irrefl 0, not_false_iff],
minimalPeriod_pos_of_mem_periodicPts⟩
theorem minimalPeriod_eq_zero_iff_notMem_periodicPts :
minimalPeriod f x = 0 ↔ x ∉ periodicPts f := by
rw [← minimalPeriod_pos_iff_mem_periodicPts, not_lt, nonpos_iff_eq_zero]
@[deprecated (since := "2025-05-24")]
alias minimalPeriod_eq_zero_iff_nmem_periodicPts := minimalPeriod_eq_zero_iff_notMem_periodicPts
theorem IsPeriodicPt.minimalPeriod_le (hn : 0 < n) (hx : IsPeriodicPt f n x) :
minimalPeriod f x ≤ n := by
classical
rw [minimalPeriod, dif_pos (mk_mem_periodicPts hn hx)]
exact Nat.find_min' (mk_mem_periodicPts hn hx) ⟨hn, hx⟩
theorem minimalPeriod_apply_iterate (hx : x ∈ periodicPts f) (n : ℕ) :
minimalPeriod f (f^[n] x) = minimalPeriod f x := by
apply
(IsPeriodicPt.minimalPeriod_le (minimalPeriod_pos_of_mem_periodicPts hx) _).antisymm
((isPeriodicPt_of_mem_periodicPts_of_isPeriodicPt_iterate hx
(isPeriodicPt_minimalPeriod f _)).minimalPeriod_le
(minimalPeriod_pos_of_mem_periodicPts _))
· exact (isPeriodicPt_minimalPeriod f x).apply_iterate n
· rcases hx with ⟨m, hm, hx⟩
exact ⟨m, hm, hx.apply_iterate n⟩
theorem minimalPeriod_apply (hx : x ∈ periodicPts f) : minimalPeriod f (f x) = minimalPeriod f x :=
minimalPeriod_apply_iterate hx 1
theorem le_of_lt_minimalPeriod_of_iterate_eq {m n : ℕ} (hm : m < minimalPeriod f x)
(hmn : f^[m] x = f^[n] x) : m ≤ n := by
by_contra! hmn'
rw [← Nat.add_sub_of_le hmn'.le, add_comm, iterate_add_apply] at hmn
exact
((IsPeriodicPt.minimalPeriod_le (tsub_pos_of_lt hmn')
(isPeriodicPt_of_mem_periodicPts_of_isPeriodicPt_iterate
(minimalPeriod_pos_iff_mem_periodicPts.1 ((zero_le m).trans_lt hm)) hmn)).trans
(Nat.sub_le m n)).not_gt
hm
theorem iterate_injOn_Iio_minimalPeriod : (Iio <| minimalPeriod f x).InjOn (f^[·] x) :=
fun _m hm _n hn hmn ↦ (le_of_lt_minimalPeriod_of_iterate_eq hm hmn).antisymm
(le_of_lt_minimalPeriod_of_iterate_eq hn hmn.symm)
theorem iterate_eq_iterate_iff_of_lt_minimalPeriod {m n : ℕ} (hm : m < minimalPeriod f x)
(hn : n < minimalPeriod f x) : f^[m] x = f^[n] x ↔ m = n :=
iterate_injOn_Iio_minimalPeriod.eq_iff hm hn
@[simp] theorem minimalPeriod_id : minimalPeriod id x = 1 :=
((is_periodic_id _ _).minimalPeriod_le Nat.one_pos).antisymm
(Nat.succ_le_of_lt ((is_periodic_id _ _).minimalPeriod_pos Nat.one_pos))
@[simp]
theorem minimalPeriod_eq_one_iff_isFixedPt : minimalPeriod f x = 1 ↔ IsFixedPt f x := by
refine ⟨fun h => ?_, fun h => ?_⟩
· rw [← iterate_one f]
refine Function.IsPeriodicPt.isFixedPt ?_
rw [← h]
exact isPeriodicPt_minimalPeriod f x
· exact
((h.isPeriodicPt 1).minimalPeriod_le Nat.one_pos).antisymm
(Nat.succ_le_of_lt ((h.isPeriodicPt 1).minimalPeriod_pos Nat.one_pos))
@[nontriviality]
theorem minimalPeriod_eq_one_of_subsingleton [Subsingleton α] : minimalPeriod f x = 1 := by
simp [nontriviality]
theorem IsPeriodicPt.eq_zero_of_lt_minimalPeriod (hx : IsPeriodicPt f n x)
(hn : n < minimalPeriod f x) : n = 0 :=
Eq.symm <|
(eq_or_lt_of_le <| n.zero_le).resolve_right fun hn0 => not_lt.2 (hx.minimalPeriod_le hn0) hn
theorem not_isPeriodicPt_of_pos_of_lt_minimalPeriod :
∀ {n : ℕ} (_ : n ≠ 0) (_ : n < minimalPeriod f x), ¬IsPeriodicPt f n x
| 0, n0, _ => (n0 rfl).elim
| _ + 1, _, hn => fun hp => Nat.succ_ne_zero _ (hp.eq_zero_of_lt_minimalPeriod hn)
theorem IsPeriodicPt.minimalPeriod_dvd (hx : IsPeriodicPt f n x) : minimalPeriod f x ∣ n :=
(eq_or_lt_of_le <| n.zero_le).elim (fun hn0 => hn0 ▸ Nat.dvd_zero _) fun hn0 =>
Nat.dvd_iff_mod_eq_zero.2 <|
(hx.mod <| isPeriodicPt_minimalPeriod f x).eq_zero_of_lt_minimalPeriod <|
Nat.mod_lt _ <| hx.minimalPeriod_pos hn0
theorem isPeriodicPt_iff_minimalPeriod_dvd : IsPeriodicPt f n x ↔ minimalPeriod f x ∣ n :=
⟨IsPeriodicPt.minimalPeriod_dvd, fun h => (isPeriodicPt_minimalPeriod f x).trans_dvd h⟩
open Nat
theorem minimalPeriod_eq_minimalPeriod_iff {g : β → β} {y : β} :
minimalPeriod f x = minimalPeriod g y ↔ ∀ n, IsPeriodicPt f n x ↔ IsPeriodicPt g n y := by
simp_rw [isPeriodicPt_iff_minimalPeriod_dvd, dvd_right_iff_eq]
theorem Commute.minimalPeriod_of_comp_dvd_lcm {g : α → α} (h : Commute f g) :
minimalPeriod (f ∘ g) x ∣ Nat.lcm (minimalPeriod f x) (minimalPeriod g x) := by
rw [← isPeriodicPt_iff_minimalPeriod_dvd]
exact (isPeriodicPt_minimalPeriod f x).comp_lcm h (isPeriodicPt_minimalPeriod g x)
private theorem minimalPeriod_iterate_eq_div_gcd_aux (h : 0 < gcd (minimalPeriod f x) n) :
minimalPeriod f^[n] x = minimalPeriod f x / Nat.gcd (minimalPeriod f x) n := by
apply Nat.dvd_antisymm
· apply IsPeriodicPt.minimalPeriod_dvd
rw [IsPeriodicPt, IsFixedPt, ← iterate_mul, ← Nat.mul_div_assoc _ (gcd_dvd_left _ _),
mul_comm, Nat.mul_div_assoc _ (gcd_dvd_right _ _), mul_comm, iterate_mul]
exact (isPeriodicPt_minimalPeriod f x).iterate _
· apply Coprime.dvd_of_dvd_mul_right (coprime_div_gcd_div_gcd h)
apply Nat.dvd_of_mul_dvd_mul_right h
rw [Nat.div_mul_cancel (gcd_dvd_left _ _), mul_assoc, Nat.div_mul_cancel (gcd_dvd_right _ _),
mul_comm]
apply IsPeriodicPt.minimalPeriod_dvd
rw [IsPeriodicPt, IsFixedPt, iterate_mul]
exact isPeriodicPt_minimalPeriod _ _
theorem minimalPeriod_iterate_eq_div_gcd (h : n ≠ 0) :
minimalPeriod f^[n] x = minimalPeriod f x / Nat.gcd (minimalPeriod f x) n :=
minimalPeriod_iterate_eq_div_gcd_aux <| gcd_pos_of_pos_right _ (Nat.pos_of_ne_zero h)
theorem minimalPeriod_iterate_eq_div_gcd' (h : x ∈ periodicPts f) :
minimalPeriod f^[n] x = minimalPeriod f x / Nat.gcd (minimalPeriod f x) n :=
minimalPeriod_iterate_eq_div_gcd_aux <|
gcd_pos_of_pos_left n (minimalPeriod_pos_iff_mem_periodicPts.mpr h)
/-- The orbit of a periodic point `x` of `f` is the cycle `[x, f x, f (f x), ...]`. Its length is
the minimal period of `x`.
If `x` is not a periodic point, then this is the empty (aka nil) cycle. -/
def periodicOrbit (f : α → α) (x : α) : Cycle α :=
(List.range (minimalPeriod f x)).map fun n => f^[n] x
/-- The definition of a periodic orbit, in terms of `List.map`. -/
theorem periodicOrbit_def (f : α → α) (x : α) :
periodicOrbit f x = (List.range (minimalPeriod f x)).map fun n => f^[n] x :=
rfl
/-- The definition of a periodic orbit, in terms of `Cycle.map`. -/
theorem periodicOrbit_eq_cycle_map (f : α → α) (x : α) :
periodicOrbit f x = (List.range (minimalPeriod f x) : Cycle ℕ).map fun n => f^[n] x :=
rfl
@[simp]
theorem periodicOrbit_length : (periodicOrbit f x).length = minimalPeriod f x := by
rw [periodicOrbit, Cycle.length_coe, List.length_map, List.length_range]
@[simp]
theorem periodicOrbit_eq_nil_iff_not_periodic_pt :
periodicOrbit f x = Cycle.nil ↔ x ∉ periodicPts f := by
simp only [periodicOrbit.eq_1, Cycle.coe_eq_nil, List.map_eq_nil_iff, List.range_eq_nil]
exact minimalPeriod_eq_zero_iff_notMem_periodicPts
theorem periodicOrbit_eq_nil_of_not_periodic_pt (h : x ∉ periodicPts f) :
periodicOrbit f x = Cycle.nil :=
periodicOrbit_eq_nil_iff_not_periodic_pt.2 h
@[simp]
theorem mem_periodicOrbit_iff (hx : x ∈ periodicPts f) :
y ∈ periodicOrbit f x ↔ ∃ n, f^[n] x = y := by
simp only [periodicOrbit, Cycle.mem_coe_iff, List.mem_map, List.mem_range]
use fun ⟨a, _, ha'⟩ => ⟨a, ha'⟩
rintro ⟨n, rfl⟩
use n % minimalPeriod f x, mod_lt _ (minimalPeriod_pos_of_mem_periodicPts hx)
rw [iterate_mod_minimalPeriod_eq]
theorem iterate_mem_periodicOrbit (hx : x ∈ periodicPts f) (n : ℕ) :
f^[n] x ∈ periodicOrbit f x := by
simp [hx]
@[simp]
theorem exists_iterate_apply_eq_of_mem_periodicPts (hx : x ∈ periodicPts f) : ∃ n, f^[n] x = x := by
simpa only [← mem_periodicOrbit_iff hx] using iterate_mem_periodicOrbit hx 0
theorem self_mem_periodicOrbit (hx : x ∈ periodicPts f) : x ∈ periodicOrbit f x := by
simp [hx]
theorem nodup_periodicOrbit : (periodicOrbit f x).Nodup := by
rw [periodicOrbit, Cycle.nodup_coe_iff, List.nodup_map_iff_inj_on List.nodup_range]
intro m hm n hn hmn
rw [List.mem_range] at hm hn
rwa [iterate_eq_iterate_iff_of_lt_minimalPeriod hm hn] at hmn
theorem periodicOrbit_apply_iterate_eq (hx : x ∈ periodicPts f) (n : ℕ) :
periodicOrbit f (f^[n] x) = periodicOrbit f x :=
Eq.symm <| Cycle.coe_eq_coe.2 <| .intro n <|
List.ext_get (by simp [minimalPeriod_apply_iterate hx]) fun m _ _ ↦ by
simp [List.getElem_rotate, iterate_add_apply]
theorem periodicOrbit_apply_eq (hx : x ∈ periodicPts f) :
periodicOrbit f (f x) = periodicOrbit f x :=
periodicOrbit_apply_iterate_eq hx 1
theorem periodicOrbit_chain (r : α → α → Prop) {f : α → α} {x : α} :
(periodicOrbit f x).Chain r ↔ ∀ n < minimalPeriod f x, r (f^[n] x) (f^[n+1] x) := by
by_cases hx : x ∈ periodicPts f
· have hx' := minimalPeriod_pos_of_mem_periodicPts hx
have hM := Nat.sub_add_cancel (succ_le_iff.2 hx')
rw [periodicOrbit, ← Cycle.map_coe, Cycle.chain_map, ← hM, Cycle.chain_range_succ]
refine ⟨?_, fun H => ⟨?_, fun m hm => H _ (hm.trans (Nat.lt_succ_self _))⟩⟩
· rintro ⟨hr, H⟩ n hn
rcases eq_or_lt_of_le (Nat.lt_succ_iff.1 hn) with hM' | hM'
· rwa [hM', hM, iterate_minimalPeriod]
· exact H _ hM'
· rw [iterate_zero_apply]
nth_rw 3 [← @iterate_minimalPeriod α f x]
nth_rw 2 [← hM]
exact H _ (Nat.lt_succ_self _)
· rw [periodicOrbit_eq_nil_of_not_periodic_pt hx, minimalPeriod_eq_zero_of_notMem_periodicPts hx]
simp
theorem periodicOrbit_chain' (r : α → α → Prop) {f : α → α} {x : α} (hx : x ∈ periodicPts f) :
(periodicOrbit f x).Chain r ↔ ∀ n, r (f^[n] x) (f^[n+1] x) := by
rw [periodicOrbit_chain r]
refine ⟨fun H n => ?_, fun H n _ => H n⟩
rw [iterate_succ_apply, ← iterate_mod_minimalPeriod_eq, ← iterate_mod_minimalPeriod_eq (n := n),
← iterate_succ_apply, minimalPeriod_apply hx]
exact H _ (mod_lt _ (minimalPeriod_pos_of_mem_periodicPts hx))
end -- noncomputable
end Function
namespace Function
variable {α β : Type*} {f : α → α} {g : β → β} {x : α × β} {a : α} {b : β} {m n : ℕ}
@[simp]
theorem isFixedPt_prodMap (x : α × β) :
IsFixedPt (Prod.map f g) x ↔ IsFixedPt f x.1 ∧ IsFixedPt g x.2 :=
Prod.ext_iff
theorem IsFixedPt.prodMap (ha : IsFixedPt f a) (hb : IsFixedPt g b) :
IsFixedPt (Prod.map f g) (a, b) :=
(isFixedPt_prodMap _).mpr ⟨ha, hb⟩
@[simp]
theorem isPeriodicPt_prodMap (x : α × β) :
IsPeriodicPt (Prod.map f g) n x ↔ IsPeriodicPt f n x.1 ∧ IsPeriodicPt g n x.2 := by
simp [IsPeriodicPt]
theorem IsPeriodicPt.prodMap (ha : IsPeriodicPt f n a) (hb : IsPeriodicPt g n b) :
IsPeriodicPt (Prod.map f g) n (a, b) :=
(isPeriodicPt_prodMap _).mpr ⟨ha, hb⟩
end Function
namespace MulAction
open Function
universe u v
variable {α : Type v}
variable {G : Type u} [Group G] [MulAction G α]
variable {M : Type u} [Monoid M] [MulAction M α]
/--
The period of a multiplicative action of `g` on `a` is the smallest positive `n` such that
`g ^ n • a = a`, or `0` if such an `n` does not exist.
-/
@[to_additive /-- The period of an additive action of `g` on `a` is the smallest positive `n`
such that `(n • g) +ᵥ a = a`, or `0` if such an `n` does not exist. -/]
noncomputable def period (m : M) (a : α) : ℕ := minimalPeriod (fun x => m • x) a
/-- `MulAction.period m a` is definitionally equal to `Function.minimalPeriod (m • ·) a`. -/
@[to_additive /-- `AddAction.period m a` is definitionally equal to
`Function.minimalPeriod (m +ᵥ ·) a` -/]
theorem period_eq_minimalPeriod {m : M} {a : α} :
MulAction.period m a = minimalPeriod (fun x => m • x) a := rfl
/-- `m ^ (period m a)` fixes `a`. -/
@[to_additive (attr := simp) /-- `(period m a) • m` fixes `a`. -/]
theorem pow_period_smul (m : M) (a : α) : m ^ (period m a) • a = a := by
rw [period_eq_minimalPeriod, ← smul_iterate_apply, iterate_minimalPeriod]
@[to_additive]
lemma isPeriodicPt_smul_iff {m : M} {a : α} {n : ℕ} :
IsPeriodicPt (m • ·) n a ↔ m ^ n • a = a := by
rw [← smul_iterate_apply, IsPeriodicPt, IsFixedPt]
/-! ### Multiples of `MulAction.period`
It is easy to convince oneself that if `g ^ n • a = a` (resp. `(n • g) +ᵥ a = a`),
then `n` must be a multiple of `period g a`.
This also holds for negative powers/multiples.
-/
@[to_additive]
theorem pow_smul_eq_iff_period_dvd {n : ℕ} {m : M} {a : α} :
m ^ n • a = a ↔ period m a ∣ n := by
rw [period_eq_minimalPeriod, ← isPeriodicPt_iff_minimalPeriod_dvd, isPeriodicPt_smul_iff]
@[to_additive]
theorem zpow_smul_eq_iff_period_dvd {j : ℤ} {g : G} {a : α} :
g ^ j • a = a ↔ (period g a : ℤ) ∣ j := by
match j with
| (n : ℕ) => rw [zpow_natCast, Int.natCast_dvd_natCast, pow_smul_eq_iff_period_dvd]
| -(n + 1 : ℕ) =>
rw [zpow_neg, zpow_natCast, inv_smul_eq_iff, eq_comm, Int.dvd_neg, Int.natCast_dvd_natCast,
pow_smul_eq_iff_period_dvd]
@[to_additive (attr := simp)]
theorem pow_mod_period_smul (n : ℕ) {m : M} {a : α} :
m ^ (n % period m a) • a = m ^ n • a := by
conv_rhs => rw [← Nat.mod_add_div n (period m a), pow_add, mul_smul,
pow_smul_eq_iff_period_dvd.mpr (dvd_mul_right _ _)]
@[to_additive (attr := simp)]
theorem zpow_mod_period_smul (j : ℤ) {g : G} {a : α} :
g ^ (j % (period g a : ℤ)) • a = g ^ j • a := by
conv_rhs => rw [← Int.emod_add_mul_ediv j (period g a), zpow_add, mul_smul,
zpow_smul_eq_iff_period_dvd.mpr (dvd_mul_right _ _)]
@[to_additive (attr := simp)]
theorem pow_add_period_smul (n : ℕ) (m : M) (a : α) :
m ^ (n + period m a) • a = m ^ n • a := by
rw [← pow_mod_period_smul, Nat.add_mod_right, pow_mod_period_smul]
@[to_additive (attr := simp)]
theorem pow_period_add_smul (n : ℕ) (m : M) (a : α) :
m ^ (period m a + n) • a = m ^ n • a := by
rw [← pow_mod_period_smul, Nat.add_mod_left, pow_mod_period_smul]
@[to_additive (attr := simp)]
theorem zpow_add_period_smul (i : ℤ) (g : G) (a : α) :
g ^ (i + period g a) • a = g ^ i • a := by
rw [← zpow_mod_period_smul, Int.add_emod_right, zpow_mod_period_smul]
@[to_additive (attr := simp)]
theorem zpow_period_add_smul (i : ℤ) (g : G) (a : α) :
g ^ (period g a + i) • a = g ^ i • a := by
rw [← zpow_mod_period_smul, Int.add_emod_left, zpow_mod_period_smul]
variable {a : G} {b : α}
@[to_additive]
theorem pow_smul_eq_iff_minimalPeriod_dvd {n : ℕ} :
a ^ n • b = b ↔ minimalPeriod (a • ·) b ∣ n := by
rw [← period_eq_minimalPeriod, pow_smul_eq_iff_period_dvd]
@[to_additive]
theorem zpow_smul_eq_iff_minimalPeriod_dvd {n : ℤ} :
a ^ n • b = b ↔ (minimalPeriod (a • ·) b : ℤ) ∣ n := by
rw [← period_eq_minimalPeriod, zpow_smul_eq_iff_period_dvd]
variable (a b)
@[to_additive (attr := simp)]
theorem pow_smul_mod_minimalPeriod (n : ℕ) :
a ^ (n % minimalPeriod (a • ·) b) • b = a ^ n • b := by
rw [← period_eq_minimalPeriod, pow_mod_period_smul]
@[to_additive (attr := simp)]
theorem zpow_smul_mod_minimalPeriod (n : ℤ) :
a ^ (n % (minimalPeriod (a • ·) b : ℤ)) • b = a ^ n • b := by
rw [← period_eq_minimalPeriod, zpow_mod_period_smul]
end MulAction |
.lake/packages/mathlib/Mathlib/Analysis/Hofer.lean | import Mathlib.Analysis.SpecificLimits.Basic
/-!
# Hofer's lemma
This is an elementary lemma about complete metric spaces. It is motivated by an
application to the bubbling-off analysis for holomorphic curves in symplectic topology.
We are *very* far away from having these applications, but the proof here is a nice
example of a proof needing to construct a sequence by induction in the middle of the proof.
## References:
* H. Hofer and C. Viterbo, *The Weinstein conjecture in the presence of holomorphic spheres*
-/
open Topology Filter Finset
local notation "d" => dist
theorem hofer {X : Type*} [MetricSpace X] [CompleteSpace X] (x : X) (ε : ℝ) (ε_pos : 0 < ε)
{ϕ : X → ℝ} (cont : Continuous ϕ) (nonneg : ∀ y, 0 ≤ ϕ y) : ∃ ε' > 0, ∃ x' : X,
ε' ≤ ε ∧ d x' x ≤ 2 * ε ∧ ε * ϕ x ≤ ε' * ϕ x' ∧ ∀ y, d x' y ≤ ε' → ϕ y ≤ 2 * ϕ x' := by
by_contra! H
have reformulation : ∀ (x') (k : ℕ), ε * ϕ x ≤ ε / 2 ^ k * ϕ x' ↔ 2 ^ k * ϕ x ≤ ϕ x' := by
intro x' k
rw [div_mul_eq_mul_div, le_div_iff₀, mul_assoc, mul_le_mul_iff_right₀ ε_pos, mul_comm]
positivity
-- Now let's specialize to `ε/2^k`
replace H : ∀ k : ℕ, ∀ x', d x' x ≤ 2 * ε ∧ 2 ^ k * ϕ x ≤ ϕ x' →
∃ y, d x' y ≤ ε / 2 ^ k ∧ 2 * ϕ x' < ϕ y := by
intro k x'
have := H (ε / 2 ^ k) (by positivity) x' (div_le_self ε_pos.le <| one_le_pow₀ one_le_two)
simpa [reformulation] using this
haveI : Nonempty X := ⟨x⟩
choose! F hF using H
-- Use the axiom of choice
-- Now define u by induction starting at x, with u_{n+1} = F(n, u_n)
let u : ℕ → X := fun n => Nat.recOn n x F
-- The properties of F translate to properties of u
have hu :
∀ n,
d (u n) x ≤ 2 * ε ∧ 2 ^ n * ϕ x ≤ ϕ (u n) →
d (u n) (u <| n + 1) ≤ ε / 2 ^ n ∧ 2 * ϕ (u n) < ϕ (u <| n + 1) := by
exact fun n ↦ hF n (u n)
-- Key properties of u, to be proven by induction
have key : ∀ n, d (u n) (u (n + 1)) ≤ ε / 2 ^ n ∧ 2 * ϕ (u n) < ϕ (u (n + 1)) := by
intro n
induction n using Nat.case_strong_induction_on with
| hz => simpa [u, ε_pos.le] using hu 0
| hi n IH =>
have A : d (u (n + 1)) x ≤ 2 * ε := by
rw [dist_comm]
let r := range (n + 1) -- range (n+1) = {0, ..., n}
calc
d (u 0) (u (n + 1)) ≤ ∑ i ∈ r, d (u i) (u <| i + 1) := dist_le_range_sum_dist u (n + 1)
_ ≤ ∑ i ∈ r, ε / 2 ^ i :=
(sum_le_sum fun i i_in => (IH i <| Nat.lt_succ_iff.mp <| Finset.mem_range.mp i_in).1)
_ = (∑ i ∈ r, (1 / 2 : ℝ) ^ i) * ε := by
rw [Finset.sum_mul]
simp
field_simp
_ ≤ 2 * ε := by gcongr; apply sum_geometric_two_le
have B : 2 ^ (n + 1) * ϕ x ≤ ϕ (u (n + 1)) := by
refine @geom_le (ϕ ∘ u) _ zero_le_two (n + 1) fun m hm => ?_
exact (IH _ <| Nat.lt_add_one_iff.1 hm).2.le
exact hu (n + 1) ⟨A, B⟩
obtain ⟨key₁, key₂⟩ := forall_and.mp key
-- Hence u is Cauchy
have cauchy_u : CauchySeq u := by
refine cauchySeq_of_le_geometric _ ε one_half_lt_one fun n => ?_
simpa only [one_div, inv_pow] using key₁ n
-- So u converges to some y
obtain ⟨y, limy⟩ : ∃ y, Tendsto u atTop (𝓝 y) := CompleteSpace.complete cauchy_u
-- And ϕ ∘ u goes to +∞
have lim_top : Tendsto (ϕ ∘ u) atTop atTop := by
let v n := (ϕ ∘ u) (n + 1)
suffices Tendsto v atTop atTop by rwa [tendsto_add_atTop_iff_nat] at this
have hv₀ : 0 < v 0 := by
calc
0 ≤ 2 * ϕ (u 0) := by specialize nonneg x; positivity
_ < ϕ (u (0 + 1)) := key₂ 0
apply tendsto_atTop_of_geom_le hv₀ one_lt_two
exact fun n => (key₂ (n + 1)).le
-- But ϕ ∘ u also needs to go to ϕ(y)
have lim : Tendsto (ϕ ∘ u) atTop (𝓝 (ϕ y)) := Tendsto.comp cont.continuousAt limy
-- So we have our contradiction!
exact not_tendsto_atTop_of_tendsto_nhds lim lim_top |
.lake/packages/mathlib/Mathlib/Analysis/Convolution.lean | import Mathlib.Analysis.Calculus.ContDiff.Basic
import Mathlib.Analysis.Calculus.ParametricIntegral
import Mathlib.MeasureTheory.Integral.Prod
import Mathlib.MeasureTheory.Function.LocallyIntegrable
import Mathlib.MeasureTheory.Group.Integral
import Mathlib.MeasureTheory.Group.Prod
import Mathlib.MeasureTheory.Integral.IntervalIntegral.Basic
/-!
# Convolution of functions
This file defines the convolution on two functions, i.e. `x ↦ ∫ f(t)g(x - t) ∂t`.
In the general case, these functions can be vector-valued, and have an arbitrary (additive)
group as domain. We use a continuous bilinear operation `L` on these function values as
"multiplication". The domain must be equipped with a Haar measure `μ`
(though many individual results have weaker conditions on `μ`).
For many applications we can take `L = ContinuousLinearMap.lsmul ℝ ℝ` or
`L = ContinuousLinearMap.mul ℝ ℝ`.
We also define `ConvolutionExists` and `ConvolutionExistsAt` to state that the convolution is
well-defined (everywhere or at a single point). These conditions are needed for pointwise
computations (e.g. `ConvolutionExistsAt.distrib_add`), but are generally not strong enough for any
local (or global) properties of the convolution. For this we need stronger assumptions on `f`
and/or `g`, and generally if we impose stronger conditions on one of the functions, we can impose
weaker conditions on the other.
We have proven many of the properties of the convolution assuming one of these functions
has compact support (in which case the other function only needs to be locally integrable).
We still need to prove the properties for other pairs of conditions (e.g. both functions are
rapidly decreasing)
## Design Decisions
We use a bilinear map `L` to "multiply" the two functions in the integrand.
This generality has several advantages
* This allows us to compute the total derivative of the convolution, in case the functions are
multivariate. The total derivative is again a convolution, but where the codomains of the
functions can be higher-dimensional. See `HasCompactSupport.hasFDerivAt_convolution_right`.
* This allows us to use `@[to_additive]` everywhere (which would not be possible if we would use
`mul`/`smul` in the integral, since `@[to_additive]` will incorrectly also try to additivize
those definitions).
* We need to support the case where at least one of the functions is vector-valued, but if we use
`smul` to multiply the functions, that would be an asymmetric definition.
## Main Definitions
* `MeasureTheory.convolution f g L μ x = (f ⋆[L, μ] g) x = ∫ t, L (f t) (g (x - t)) ∂μ`
is the convolution of `f` and `g` w.r.t. the continuous bilinear map `L` and measure `μ`.
* `MeasureTheory.ConvolutionExistsAt f g x L μ` states that the convolution `(f ⋆[L, μ] g) x`
is well-defined (i.e. the integral exists).
* `MeasureTheory.ConvolutionExists f g L μ` states that the convolution `f ⋆[L, μ] g`
is well-defined at each point.
## Main Results
* `HasCompactSupport.hasFDerivAt_convolution_right` and
`HasCompactSupport.hasFDerivAt_convolution_left`: we can compute the total derivative
of the convolution as a convolution with the total derivative of the right (left) function.
* `HasCompactSupport.contDiff_convolution_right` and
`HasCompactSupport.contDiff_convolution_left`: the convolution is `𝒞ⁿ` if one of the functions
is `𝒞ⁿ` with compact support and the other function in locally integrable.
Versions of these statements for functions depending on a parameter are also given.
* `MeasureTheory.convolution_tendsto_right`: Given a sequence of nonnegative normalized functions
whose support tends to a small neighborhood around `0`, the convolution tends to the right
argument. This is specialized to bump functions in `ContDiffBump.convolution_tendsto_right`.
## Notation
The following notations are localized in the scope `Convolution`:
* `f ⋆[L, μ] g` for the convolution. Note: you have to use parentheses to apply the convolution
to an argument: `(f ⋆[L, μ] g) x`.
* `f ⋆[L] g := f ⋆[L, volume] g`
* `f ⋆ g := f ⋆[lsmul ℝ ℝ] g`
## To do
* Existence and (uniform) continuity of the convolution if
one of the maps is in `ℒ^p` and the other in `ℒ^q` with `1 / p + 1 / q = 1`.
This might require a generalization of `MeasureTheory.MemLp.smul` where `smul` is generalized
to a continuous bilinear map.
(see e.g. [Fremlin, *Measure Theory* (volume 2)][fremlin_vol2], 255K)
* The convolution is an `AEStronglyMeasurable` function
(see e.g. [Fremlin, *Measure Theory* (volume 2)][fremlin_vol2], 255I).
* Prove properties about the convolution if both functions are rapidly decreasing.
* Use `@[to_additive]` everywhere (this likely requires changes in `to_additive`)
-/
open Set Function Filter MeasureTheory MeasureTheory.Measure TopologicalSpace
open Bornology ContinuousLinearMap Metric Topology
open scoped Pointwise NNReal Filter
universe u𝕜 uG uE uE' uE'' uF uF' uF'' uP
variable {𝕜 : Type u𝕜} {G : Type uG} {E : Type uE} {E' : Type uE'} {E'' : Type uE''} {F : Type uF}
{F' : Type uF'} {F'' : Type uF''} {P : Type uP}
variable [NormedAddCommGroup E] [NormedAddCommGroup E'] [NormedAddCommGroup E'']
[NormedAddCommGroup F] {f f' : G → E} {g g' : G → E'} {x x' : G} {y y' : E}
namespace MeasureTheory
section NontriviallyNormedField
variable [NontriviallyNormedField 𝕜]
variable [NormedSpace 𝕜 E] [NormedSpace 𝕜 E'] [NormedSpace 𝕜 E''] [NormedSpace 𝕜 F]
variable (L : E →L[𝕜] E' →L[𝕜] F)
section NoMeasurability
variable [AddGroup G] [TopologicalSpace G]
theorem convolution_integrand_bound_right_of_le_of_subset {C : ℝ} (hC : ∀ i, ‖g i‖ ≤ C) {x t : G}
{s u : Set G} (hx : x ∈ s) (hu : -tsupport g + s ⊆ u) :
‖L (f t) (g (x - t))‖ ≤ u.indicator (fun t => ‖L‖ * ‖f t‖ * C) t := by
-- Porting note: had to add `f := _`
refine le_indicator (f := fun t ↦ ‖L (f t) (g (x - t))‖) (fun t _ => ?_) (fun t ht => ?_) t
· apply_rules [L.le_of_opNorm₂_le_of_le, le_rfl]
· have : x - t ∉ support g := by
refine mt (fun hxt => hu ?_) ht
refine ⟨_, Set.neg_mem_neg.mpr (subset_closure hxt), _, hx, ?_⟩
simp only [neg_sub, sub_add_cancel]
simp only [notMem_support.mp this, (L _).map_zero, norm_zero, le_rfl]
theorem _root_.HasCompactSupport.convolution_integrand_bound_right_of_subset
(hcg : HasCompactSupport g) (hg : Continuous g)
{x t : G} {s u : Set G} (hx : x ∈ s) (hu : -tsupport g + s ⊆ u) :
‖L (f t) (g (x - t))‖ ≤ u.indicator (fun t => ‖L‖ * ‖f t‖ * ⨆ i, ‖g i‖) t := by
refine convolution_integrand_bound_right_of_le_of_subset _ (fun i => ?_) hx hu
exact le_ciSup (hg.norm.bddAbove_range_of_hasCompactSupport hcg.norm) _
theorem _root_.HasCompactSupport.convolution_integrand_bound_right (hcg : HasCompactSupport g)
(hg : Continuous g) {x t : G} {s : Set G} (hx : x ∈ s) :
‖L (f t) (g (x - t))‖ ≤ (-tsupport g + s).indicator (fun t => ‖L‖ * ‖f t‖ * ⨆ i, ‖g i‖) t :=
hcg.convolution_integrand_bound_right_of_subset L hg hx Subset.rfl
theorem _root_.Continuous.convolution_integrand_fst [ContinuousSub G] (hg : Continuous g) (t : G) :
Continuous fun x => L (f t) (g (x - t)) :=
L.continuous₂.comp₂ continuous_const <| hg.comp <| continuous_id.sub continuous_const
theorem _root_.HasCompactSupport.convolution_integrand_bound_left (hcf : HasCompactSupport f)
(hf : Continuous f) {x t : G} {s : Set G} (hx : x ∈ s) :
‖L (f (x - t)) (g t)‖ ≤
(-tsupport f + s).indicator (fun t => (‖L‖ * ⨆ i, ‖f i‖) * ‖g t‖) t := by
convert hcf.convolution_integrand_bound_right L.flip hf hx using 1
simp_rw [L.opNorm_flip, mul_right_comm]
end NoMeasurability
section Measurability
variable [MeasurableSpace G] {μ ν : Measure G}
/-- The convolution of `f` and `g` exists at `x` when the function `t ↦ L (f t) (g (x - t))` is
integrable. There are various conditions on `f` and `g` to prove this. -/
def ConvolutionExistsAt [Sub G] (f : G → E) (g : G → E') (x : G) (L : E →L[𝕜] E' →L[𝕜] F)
(μ : Measure G := by volume_tac) : Prop :=
Integrable (fun t => L (f t) (g (x - t))) μ
/-- The convolution of `f` and `g` exists when the function `t ↦ L (f t) (g (x - t))` is integrable
for all `x : G`. There are various conditions on `f` and `g` to prove this. -/
def ConvolutionExists [Sub G] (f : G → E) (g : G → E') (L : E →L[𝕜] E' →L[𝕜] F)
(μ : Measure G := by volume_tac) : Prop :=
∀ x : G, ConvolutionExistsAt f g x L μ
section ConvolutionExists
variable {L} in
theorem ConvolutionExistsAt.integrable [Sub G] {x : G} (h : ConvolutionExistsAt f g x L μ) :
Integrable (fun t => L (f t) (g (x - t))) μ :=
h
section Group
variable [AddGroup G]
theorem AEStronglyMeasurable.convolution_integrand' [MeasurableAdd₂ G]
[MeasurableNeg G] (hf : AEStronglyMeasurable f ν)
(hg : AEStronglyMeasurable g <| map (fun p : G × G => p.1 - p.2) (μ.prod ν)) :
AEStronglyMeasurable (fun p : G × G => L (f p.2) (g (p.1 - p.2))) (μ.prod ν) :=
L.aestronglyMeasurable_comp₂ hf.comp_snd <| hg.comp_measurable measurable_sub
section
variable [MeasurableAdd G] [MeasurableNeg G]
theorem AEStronglyMeasurable.convolution_integrand_snd'
(hf : AEStronglyMeasurable f μ) {x : G}
(hg : AEStronglyMeasurable g <| map (fun t => x - t) μ) :
AEStronglyMeasurable (fun t => L (f t) (g (x - t))) μ :=
L.aestronglyMeasurable_comp₂ hf <| hg.comp_measurable <| measurable_id.const_sub x
theorem AEStronglyMeasurable.convolution_integrand_swap_snd' {x : G}
(hf : AEStronglyMeasurable f <| map (fun t => x - t) μ) (hg : AEStronglyMeasurable g μ) :
AEStronglyMeasurable (fun t => L (f (x - t)) (g t)) μ :=
L.aestronglyMeasurable_comp₂ (hf.comp_measurable <| measurable_id.const_sub x) hg
/-- A sufficient condition to prove that `f ⋆[L, μ] g` exists.
We assume that `f` is integrable on a set `s` and `g` is bounded and ae strongly measurable
on `x₀ - s` (note that both properties hold if `g` is continuous with compact support). -/
theorem _root_.BddAbove.convolutionExistsAt' {x₀ : G} {s : Set G}
(hbg : BddAbove ((fun i => ‖g i‖) '' ((fun t => -t + x₀) ⁻¹' s))) (hs : MeasurableSet s)
(h2s : (support fun t => L (f t) (g (x₀ - t))) ⊆ s) (hf : IntegrableOn f s μ)
(hmg : AEStronglyMeasurable g <| map (fun t => x₀ - t) (μ.restrict s)) :
ConvolutionExistsAt f g x₀ L μ := by
rw [ConvolutionExistsAt]
rw [← integrableOn_iff_integrable_of_support_subset h2s]
set s' := (fun t => -t + x₀) ⁻¹' s
have : ∀ᵐ t : G ∂μ.restrict s,
‖L (f t) (g (x₀ - t))‖ ≤ s.indicator (fun t => ‖L‖ * ‖f t‖ * ⨆ i : s', ‖g i‖) t := by
filter_upwards
refine le_indicator (fun t ht => ?_) fun t ht => ?_
· apply_rules [L.le_of_opNorm₂_le_of_le, le_rfl]
refine (le_ciSup_set hbg <| mem_preimage.mpr ?_)
rwa [neg_sub, sub_add_cancel]
· have : t ∉ support fun t => L (f t) (g (x₀ - t)) := mt (fun h => h2s h) ht
rw [notMem_support.mp this, norm_zero]
refine Integrable.mono' ?_ ?_ this
· rw [integrable_indicator_iff hs]; exact ((hf.norm.const_mul _).mul_const _).integrableOn
· exact hf.aestronglyMeasurable.convolution_integrand_snd' L hmg
/-- If `‖f‖ *[μ] ‖g‖` exists, then `f *[L, μ] g` exists. -/
theorem ConvolutionExistsAt.of_norm' {x₀ : G}
(h : ConvolutionExistsAt (fun x => ‖f x‖) (fun x => ‖g x‖) x₀ (mul ℝ ℝ) μ)
(hmf : AEStronglyMeasurable f μ) (hmg : AEStronglyMeasurable g <| map (fun t => x₀ - t) μ) :
ConvolutionExistsAt f g x₀ L μ := by
refine (h.const_mul ‖L‖).mono'
(hmf.convolution_integrand_snd' L hmg) (Eventually.of_forall fun x => ?_)
rw [mul_apply', ← mul_assoc]
apply L.le_opNorm₂
end
section Left
variable [MeasurableAdd₂ G] [MeasurableNeg G] [SFinite μ] [IsAddRightInvariant μ]
theorem AEStronglyMeasurable.convolution_integrand_snd (hf : AEStronglyMeasurable f μ)
(hg : AEStronglyMeasurable g μ) (x : G) :
AEStronglyMeasurable (fun t => L (f t) (g (x - t))) μ :=
hf.convolution_integrand_snd' L <|
hg.mono_ac <| (quasiMeasurePreserving_sub_left_of_right_invariant μ x).absolutelyContinuous
theorem AEStronglyMeasurable.convolution_integrand_swap_snd
(hf : AEStronglyMeasurable f μ) (hg : AEStronglyMeasurable g μ) (x : G) :
AEStronglyMeasurable (fun t => L (f (x - t)) (g t)) μ :=
(hf.mono_ac
(quasiMeasurePreserving_sub_left_of_right_invariant μ
x).absolutelyContinuous).convolution_integrand_swap_snd'
L hg
/-- If `‖f‖ *[μ] ‖g‖` exists, then `f *[L, μ] g` exists. -/
theorem ConvolutionExistsAt.of_norm {x₀ : G}
(h : ConvolutionExistsAt (fun x => ‖f x‖) (fun x => ‖g x‖) x₀ (mul ℝ ℝ) μ)
(hmf : AEStronglyMeasurable f μ) (hmg : AEStronglyMeasurable g μ) :
ConvolutionExistsAt f g x₀ L μ :=
h.of_norm' L hmf <|
hmg.mono_ac (quasiMeasurePreserving_sub_left_of_right_invariant μ x₀).absolutelyContinuous
end Left
section Right
variable [MeasurableAdd₂ G] [MeasurableNeg G] [SFinite μ] [IsAddRightInvariant μ] [SFinite ν]
theorem AEStronglyMeasurable.convolution_integrand (hf : AEStronglyMeasurable f ν)
(hg : AEStronglyMeasurable g μ) :
AEStronglyMeasurable (fun p : G × G => L (f p.2) (g (p.1 - p.2))) (μ.prod ν) :=
hf.convolution_integrand' L <|
hg.mono_ac (quasiMeasurePreserving_sub_of_right_invariant μ ν).absolutelyContinuous
theorem Integrable.convolution_integrand (hf : Integrable f ν) (hg : Integrable g μ) :
Integrable (fun p : G × G => L (f p.2) (g (p.1 - p.2))) (μ.prod ν) := by
have h_meas : AEStronglyMeasurable (fun p : G × G => L (f p.2) (g (p.1 - p.2))) (μ.prod ν) :=
hf.aestronglyMeasurable.convolution_integrand L hg.aestronglyMeasurable
have h2_meas : AEStronglyMeasurable (fun y : G => ∫ x : G, ‖L (f y) (g (x - y))‖ ∂μ) ν :=
h_meas.prod_swap.norm.integral_prod_right'
simp_rw [integrable_prod_iff' h_meas]
refine ⟨Eventually.of_forall fun t => (L (f t)).integrable_comp (hg.comp_sub_right t), ?_⟩
refine Integrable.mono' ?_ h2_meas
(Eventually.of_forall fun t => (?_ : _ ≤ ‖L‖ * ‖f t‖ * ∫ x, ‖g (x - t)‖ ∂μ))
· simp only [integral_sub_right_eq_self (‖g ·‖)]
exact (hf.norm.const_mul _).mul_const _
· simp_rw [← integral_const_mul]
rw [Real.norm_of_nonneg (by positivity)]
exact integral_mono_of_nonneg (Eventually.of_forall fun t => norm_nonneg _)
((hg.comp_sub_right t).norm.const_mul _) (Eventually.of_forall fun t => L.le_opNorm₂ _ _)
theorem Integrable.ae_convolution_exists (hf : Integrable f ν) (hg : Integrable g μ) :
∀ᵐ x ∂μ, ConvolutionExistsAt f g x L ν :=
((integrable_prod_iff <|
hf.aestronglyMeasurable.convolution_integrand L hg.aestronglyMeasurable).mp <|
hf.convolution_integrand L hg).1
end Right
variable [TopologicalSpace G] [IsTopologicalAddGroup G] [BorelSpace G]
theorem _root_.HasCompactSupport.convolutionExistsAt {x₀ : G}
(h : HasCompactSupport fun t => L (f t) (g (x₀ - t))) (hf : LocallyIntegrable f μ)
(hg : Continuous g) : ConvolutionExistsAt f g x₀ L μ := by
let u := (Homeomorph.neg G).trans (Homeomorph.addRight x₀)
let v := (Homeomorph.neg G).trans (Homeomorph.addLeft x₀)
apply ((u.isCompact_preimage.mpr h).bddAbove_image hg.norm.continuousOn).convolutionExistsAt' L
isClosed_closure.measurableSet subset_closure (hf.integrableOn_isCompact h)
have A : AEStronglyMeasurable (g ∘ v)
(μ.restrict (tsupport fun t : G => L (f t) (g (x₀ - t)))) := by
apply (hg.comp v.continuous).continuousOn.aestronglyMeasurable_of_isCompact h
exact (isClosed_tsupport _).measurableSet
convert ((v.continuous.measurable.measurePreserving
(μ.restrict (tsupport fun t => L (f t) (g (x₀ - t))))).aestronglyMeasurable_comp_iff
v.measurableEmbedding).1 A
ext x
simp only [v, Homeomorph.neg, sub_eq_add_neg, val_toAddUnits_apply, Homeomorph.trans_apply,
Equiv.neg_apply, Homeomorph.homeomorph_mk_coe, Homeomorph.coe_addLeft]
theorem _root_.HasCompactSupport.convolutionExists_right (hcg : HasCompactSupport g)
(hf : LocallyIntegrable f μ) (hg : Continuous g) : ConvolutionExists f g L μ := by
intro x₀
refine HasCompactSupport.convolutionExistsAt L ?_ hf hg
refine (hcg.comp_homeomorph (Homeomorph.subLeft x₀)).mono ?_
refine fun t => mt fun ht : g (x₀ - t) = 0 => ?_
simp_rw [ht, (L _).map_zero]
theorem _root_.HasCompactSupport.convolutionExists_left_of_continuous_right
(hcf : HasCompactSupport f) (hf : LocallyIntegrable f μ) (hg : Continuous g) :
ConvolutionExists f g L μ := by
intro x₀
refine HasCompactSupport.convolutionExistsAt L ?_ hf hg
refine hcf.mono ?_
refine fun t => mt fun ht : f t = 0 => ?_
simp_rw [ht, L.map_zero₂]
end Group
section CommGroup
variable [AddCommGroup G]
section MeasurableGroup
variable [MeasurableNeg G] [IsAddLeftInvariant μ]
/-- A sufficient condition to prove that `f ⋆[L, μ] g` exists.
We assume that the integrand has compact support and `g` is bounded on this support (note that
both properties hold if `g` is continuous with compact support). We also require that `f` is
integrable on the support of the integrand, and that both functions are strongly measurable.
This is a variant of `BddAbove.convolutionExistsAt'` in an abelian group with a left-invariant
measure. This allows us to state the boundedness and measurability of `g` in a more natural way. -/
theorem _root_.BddAbove.convolutionExistsAt [MeasurableAdd₂ G] [SFinite μ] {x₀ : G} {s : Set G}
(hbg : BddAbove ((fun i => ‖g i‖) '' ((fun t => x₀ - t) ⁻¹' s))) (hs : MeasurableSet s)
(h2s : (support fun t => L (f t) (g (x₀ - t))) ⊆ s) (hf : IntegrableOn f s μ)
(hmg : AEStronglyMeasurable g μ) : ConvolutionExistsAt f g x₀ L μ := by
refine BddAbove.convolutionExistsAt' L ?_ hs h2s hf ?_
· simp_rw [← sub_eq_neg_add, hbg]
· have : AEStronglyMeasurable g (map (fun t : G => x₀ - t) μ) :=
hmg.mono_ac (quasiMeasurePreserving_sub_left_of_right_invariant μ x₀).absolutelyContinuous
apply this.mono_measure
exact map_mono restrict_le_self (measurable_const.sub measurable_id')
variable {L} [MeasurableAdd G] [IsNegInvariant μ]
theorem convolutionExistsAt_flip :
ConvolutionExistsAt g f x L.flip μ ↔ ConvolutionExistsAt f g x L μ := by
simp_rw [ConvolutionExistsAt, ← integrable_comp_sub_left (fun t => L (f t) (g (x - t))) x,
sub_sub_cancel, flip_apply]
theorem ConvolutionExistsAt.integrable_swap (h : ConvolutionExistsAt f g x L μ) :
Integrable (fun t => L (f (x - t)) (g t)) μ := by
convert h.comp_sub_left x
simp_rw [sub_sub_self]
theorem convolutionExistsAt_iff_integrable_swap :
ConvolutionExistsAt f g x L μ ↔ Integrable (fun t => L (f (x - t)) (g t)) μ :=
convolutionExistsAt_flip.symm
end MeasurableGroup
variable [TopologicalSpace G] [IsTopologicalAddGroup G] [BorelSpace G]
variable [IsAddLeftInvariant μ] [IsNegInvariant μ]
theorem _root_.HasCompactSupport.convolutionExists_left
(hcf : HasCompactSupport f) (hf : Continuous f)
(hg : LocallyIntegrable g μ) : ConvolutionExists f g L μ := fun x₀ =>
convolutionExistsAt_flip.mp <| hcf.convolutionExists_right L.flip hg hf x₀
theorem _root_.HasCompactSupport.convolutionExists_right_of_continuous_left
(hcg : HasCompactSupport g) (hf : Continuous f) (hg : LocallyIntegrable g μ) :
ConvolutionExists f g L μ := fun x₀ =>
convolutionExistsAt_flip.mp <| hcg.convolutionExists_left_of_continuous_right L.flip hg hf x₀
end CommGroup
end ConvolutionExists
variable [NormedSpace ℝ F]
/-- The convolution of two functions `f` and `g` with respect to a continuous bilinear map `L` and
measure `μ`. It is defined to be `(f ⋆[L, μ] g) x = ∫ t, L (f t) (g (x - t)) ∂μ`. -/
noncomputable def convolution [Sub G] (f : G → E) (g : G → E') (L : E →L[𝕜] E' →L[𝕜] F)
(μ : Measure G := by volume_tac) : G → F := fun x =>
∫ t, L (f t) (g (x - t)) ∂μ
/-- The convolution of two functions with respect to a bilinear operation `L` and a measure `μ`. -/
scoped[Convolution] notation:67 f " ⋆[" L:67 ", " μ:67 "] " g:66 => convolution f g L μ
/-- The convolution of two functions with respect to a bilinear operation `L` and the volume. -/
scoped[Convolution]
notation:67 f " ⋆[" L:67 "]" g:66 => convolution f g L MeasureSpace.volume
/-- The convolution of two real-valued functions with respect to volume. -/
scoped[Convolution]
notation:67 f " ⋆ " g:66 =>
convolution f g (ContinuousLinearMap.lsmul ℝ ℝ) MeasureSpace.volume
open scoped Convolution
theorem convolution_def [Sub G] : (f ⋆[L, μ] g) x = ∫ t, L (f t) (g (x - t)) ∂μ :=
rfl
/-- The definition of convolution where the bilinear operator is scalar multiplication.
Note: it often helps the elaborator to give the type of the convolution explicitly. -/
theorem convolution_lsmul [Sub G] {f : G → 𝕜} {g : G → F} :
(f ⋆[lsmul 𝕜 𝕜, μ] g : G → F) x = ∫ t, f t • g (x - t) ∂μ :=
rfl
/-- The definition of convolution where the bilinear operator is multiplication. -/
theorem convolution_mul [Sub G] [NormedSpace ℝ 𝕜] {f : G → 𝕜} {g : G → 𝕜} :
(f ⋆[mul 𝕜 𝕜, μ] g) x = ∫ t, f t * g (x - t) ∂μ :=
rfl
section Group
variable {L} [AddGroup G]
theorem smul_convolution [SMulCommClass ℝ 𝕜 F] {y : 𝕜} : y • f ⋆[L, μ] g = y • (f ⋆[L, μ] g) := by
ext; simp only [Pi.smul_apply, convolution_def, ← integral_smul, L.map_smul₂]
theorem convolution_smul [SMulCommClass ℝ 𝕜 F] {y : 𝕜} : f ⋆[L, μ] y • g = y • (f ⋆[L, μ] g) := by
ext; simp only [Pi.smul_apply, convolution_def, ← integral_smul, (L _).map_smul]
@[simp]
theorem zero_convolution : 0 ⋆[L, μ] g = 0 := by
ext
simp_rw [convolution_def, Pi.zero_apply, L.map_zero₂, integral_zero]
@[simp]
theorem convolution_zero : f ⋆[L, μ] 0 = 0 := by
ext
simp_rw [convolution_def, Pi.zero_apply, (L _).map_zero, integral_zero]
theorem ConvolutionExistsAt.distrib_add {x : G} (hfg : ConvolutionExistsAt f g x L μ)
(hfg' : ConvolutionExistsAt f g' x L μ) :
(f ⋆[L, μ] (g + g')) x = (f ⋆[L, μ] g) x + (f ⋆[L, μ] g') x := by
simp only [convolution_def, (L _).map_add, Pi.add_apply, integral_add hfg hfg']
theorem ConvolutionExists.distrib_add (hfg : ConvolutionExists f g L μ)
(hfg' : ConvolutionExists f g' L μ) : f ⋆[L, μ] (g + g') = f ⋆[L, μ] g + f ⋆[L, μ] g' := by
ext x
exact (hfg x).distrib_add (hfg' x)
theorem ConvolutionExistsAt.add_distrib {x : G} (hfg : ConvolutionExistsAt f g x L μ)
(hfg' : ConvolutionExistsAt f' g x L μ) :
((f + f') ⋆[L, μ] g) x = (f ⋆[L, μ] g) x + (f' ⋆[L, μ] g) x := by
simp only [convolution_def, L.map_add₂, Pi.add_apply, integral_add hfg hfg']
theorem ConvolutionExists.add_distrib (hfg : ConvolutionExists f g L μ)
(hfg' : ConvolutionExists f' g L μ) : (f + f') ⋆[L, μ] g = f ⋆[L, μ] g + f' ⋆[L, μ] g := by
ext x
exact (hfg x).add_distrib (hfg' x)
theorem convolution_mono_right {f g g' : G → ℝ} (hfg : ConvolutionExistsAt f g x (lsmul ℝ ℝ) μ)
(hfg' : ConvolutionExistsAt f g' x (lsmul ℝ ℝ) μ) (hf : ∀ x, 0 ≤ f x) (hg : ∀ x, g x ≤ g' x) :
(f ⋆[lsmul ℝ ℝ, μ] g) x ≤ (f ⋆[lsmul ℝ ℝ, μ] g') x := by
apply integral_mono hfg hfg'
simp only [lsmul_apply, Algebra.id.smul_eq_mul]
intro t
apply mul_le_mul_of_nonneg_left (hg _) (hf _)
theorem convolution_mono_right_of_nonneg {f g g' : G → ℝ}
(hfg' : ConvolutionExistsAt f g' x (lsmul ℝ ℝ) μ) (hf : ∀ x, 0 ≤ f x) (hg : ∀ x, g x ≤ g' x)
(hg' : ∀ x, 0 ≤ g' x) : (f ⋆[lsmul ℝ ℝ, μ] g) x ≤ (f ⋆[lsmul ℝ ℝ, μ] g') x := by
by_cases H : ConvolutionExistsAt f g x (lsmul ℝ ℝ) μ
· exact convolution_mono_right H hfg' hf hg
have : (f ⋆[lsmul ℝ ℝ, μ] g) x = 0 := integral_undef H
rw [this]
exact integral_nonneg fun y => mul_nonneg (hf y) (hg' (x - y))
variable (L)
theorem convolution_congr [MeasurableAdd₂ G] [MeasurableNeg G] [SFinite μ]
[IsAddRightInvariant μ] (h1 : f =ᵐ[μ] f') (h2 : g =ᵐ[μ] g') : f ⋆[L, μ] g = f' ⋆[L, μ] g' := by
ext x
apply integral_congr_ae
exact (h1.prodMk <| h2.comp_tendsto
(quasiMeasurePreserving_sub_left_of_right_invariant μ x).tendsto_ae).fun_comp ↿fun x y ↦ L x y
theorem support_convolution_subset_swap : support (f ⋆[L, μ] g) ⊆ support g + support f := by
intro x h2x
by_contra hx
apply h2x
simp_rw [Set.mem_add, ← exists_and_left, not_exists, not_and_or, notMem_support] at hx
rw [convolution_def]
convert integral_zero G F using 2
ext t
rcases hx (x - t) t with (h | h | h)
· rw [h, (L _).map_zero]
· rw [h, L.map_zero₂]
· exact (h <| sub_add_cancel x t).elim
section
variable [MeasurableAdd₂ G] [MeasurableNeg G] [SFinite μ] [IsAddRightInvariant μ]
theorem Integrable.integrable_convolution (hf : Integrable f μ)
(hg : Integrable g μ) : Integrable (f ⋆[L, μ] g) μ :=
(hf.convolution_integrand L hg).integral_prod_left
end
variable [TopologicalSpace G]
variable [IsTopologicalAddGroup G]
protected theorem _root_.HasCompactSupport.convolution [T2Space G] (hcf : HasCompactSupport f)
(hcg : HasCompactSupport g) : HasCompactSupport (f ⋆[L, μ] g) :=
(hcg.isCompact.add hcf).of_isClosed_subset isClosed_closure <|
closure_minimal
((support_convolution_subset_swap L).trans <| add_subset_add subset_closure subset_closure)
(hcg.isCompact.add hcf).isClosed
variable [BorelSpace G] [TopologicalSpace P]
/-- The convolution `f * g` is continuous if `f` is locally integrable and `g` is continuous and
compactly supported. Version where `g` depends on an additional parameter in a subset `s` of
a parameter space `P` (and the compact support `k` is independent of the parameter in `s`). -/
theorem continuousOn_convolution_right_with_param {g : P → G → E'} {s : Set P} {k : Set G}
(hk : IsCompact k) (hgs : ∀ p, ∀ x, p ∈ s → x ∉ k → g p x = 0)
(hf : LocallyIntegrable f μ) (hg : ContinuousOn ↿g (s ×ˢ univ)) :
ContinuousOn (fun q : P × G => (f ⋆[L, μ] g q.1) q.2) (s ×ˢ univ) := by
/- First get rid of the case where the space is not locally compact. Then `g` vanishes everywhere
and the conclusion is trivial. -/
by_cases! H : ∀ p ∈ s, ∀ x, g p x = 0
· apply (continuousOn_const (c := 0)).congr
rintro ⟨p, x⟩ ⟨hp, -⟩
apply integral_eq_zero_of_ae (Eventually.of_forall (fun y ↦ ?_))
simp [H p hp _]
have : LocallyCompactSpace G := by
rcases H with ⟨p, hp, x, hx⟩
have A : support (g p) ⊆ k := support_subset_iff'.2 (fun y hy ↦ hgs p y hp hy)
have B : Continuous (g p) := by
refine hg.comp_continuous (.prodMk_right _) fun x => ?_
simpa only [prodMk_mem_set_prod_eq, mem_univ, and_true] using hp
rcases eq_zero_or_locallyCompactSpace_of_support_subset_isCompact_of_addGroup hk A B with H|H
· simp [H] at hx
· exact H
/- Since `G` is locally compact, one may thicken `k` a little bit into a larger compact set
`(-k) + t`, outside of which all functions that appear in the convolution vanish. Then we can
apply a continuity statement for integrals depending on a parameter, with respect to
locally integrable functions and compactly supported continuous functions. -/
rintro ⟨q₀, x₀⟩ ⟨hq₀, -⟩
obtain ⟨t, t_comp, ht⟩ : ∃ t, IsCompact t ∧ t ∈ 𝓝 x₀ := exists_compact_mem_nhds x₀
let k' : Set G := (-k) +ᵥ t
have k'_comp : IsCompact k' := IsCompact.vadd_set hk.neg t_comp
let g' : (P × G) → G → E' := fun p x ↦ g p.1 (p.2 - x)
let s' : Set (P × G) := s ×ˢ t
have A : ContinuousOn g'.uncurry (s' ×ˢ univ) := by
have : g'.uncurry = g.uncurry ∘ (fun w ↦ (w.1.1, w.1.2 - w.2)) := by ext y; rfl
rw [this]
refine hg.comp (by fun_prop) ?_
simp +contextual [s', MapsTo]
have B : ContinuousOn (fun a ↦ ∫ x, L (f x) (g' a x) ∂μ) s' := by
apply continuousOn_integral_bilinear_of_locally_integrable_of_compact_support L k'_comp A _
(hf.integrableOn_isCompact k'_comp)
rintro ⟨p, x⟩ y ⟨hp, hx⟩ hy
apply hgs p _ hp
contrapose! hy
exact ⟨y - x, by simpa using hy, x, hx, by simp⟩
apply ContinuousWithinAt.mono_of_mem_nhdsWithin (B (q₀, x₀) ⟨hq₀, mem_of_mem_nhds ht⟩)
exact mem_nhdsWithin_prod_iff.2 ⟨s, self_mem_nhdsWithin, t, nhdsWithin_le_nhds ht, Subset.rfl⟩
/-- The convolution `f * g` is continuous if `f` is locally integrable and `g` is continuous and
compactly supported. Version where `g` depends on an additional parameter in an open subset `s` of
a parameter space `P` (and the compact support `k` is independent of the parameter in `s`),
given in terms of compositions with an additional continuous map. -/
theorem continuousOn_convolution_right_with_param_comp {s : Set P} {v : P → G}
(hv : ContinuousOn v s) {g : P → G → E'} {k : Set G} (hk : IsCompact k)
(hgs : ∀ p, ∀ x, p ∈ s → x ∉ k → g p x = 0) (hf : LocallyIntegrable f μ)
(hg : ContinuousOn ↿g (s ×ˢ univ)) : ContinuousOn (fun x => (f ⋆[L, μ] g x) (v x)) s := by
apply
(continuousOn_convolution_right_with_param L hk hgs hf hg).comp (continuousOn_id.prodMk hv)
intro x hx
simp only [hx, prodMk_mem_set_prod_eq, mem_univ, and_self_iff, _root_.id]
/-- The convolution is continuous if one function is locally integrable and the other has compact
support and is continuous. -/
theorem _root_.HasCompactSupport.continuous_convolution_right (hcg : HasCompactSupport g)
(hf : LocallyIntegrable f μ) (hg : Continuous g) : Continuous (f ⋆[L, μ] g) := by
rw [← continuousOn_univ]
let g' : G → G → E' := fun _ q => g q
have : ContinuousOn ↿g' (univ ×ˢ univ) := (hg.comp continuous_snd).continuousOn
exact continuousOn_convolution_right_with_param_comp L
(continuousOn_univ.2 continuous_id) hcg
(fun p x _ hx => image_eq_zero_of_notMem_tsupport hx) hf this
/-- The convolution is continuous if one function is integrable and the other is bounded and
continuous. -/
theorem _root_.BddAbove.continuous_convolution_right_of_integrable
[FirstCountableTopology G] [SecondCountableTopologyEither G E']
(hbg : BddAbove (range fun x => ‖g x‖)) (hf : Integrable f μ) (hg : Continuous g) :
Continuous (f ⋆[L, μ] g) := by
refine continuous_iff_continuousAt.mpr fun x₀ => ?_
have : ∀ᶠ x in 𝓝 x₀, ∀ᵐ t : G ∂μ, ‖L (f t) (g (x - t))‖ ≤ ‖L‖ * ‖f t‖ * ⨆ i, ‖g i‖ := by
filter_upwards with x; filter_upwards with t
apply_rules [L.le_of_opNorm₂_le_of_le, le_rfl, le_ciSup hbg (x - t)]
refine continuousAt_of_dominated ?_ this ?_ ?_
· exact Eventually.of_forall fun x =>
hf.aestronglyMeasurable.convolution_integrand_snd' L hg.aestronglyMeasurable
· exact (hf.norm.const_mul _).mul_const _
· exact Eventually.of_forall fun t => (L.continuous₂.comp₂ continuous_const <|
hg.comp <| continuous_id.sub continuous_const).continuousAt
end Group
section CommGroup
variable [AddCommGroup G]
theorem support_convolution_subset : support (f ⋆[L, μ] g) ⊆ support f + support g :=
(support_convolution_subset_swap L).trans (add_comm _ _).subset
variable [IsAddLeftInvariant μ] [IsNegInvariant μ]
section Measurable
variable [MeasurableNeg G]
variable [MeasurableAdd G]
/-- Commutativity of convolution -/
theorem convolution_flip : g ⋆[L.flip, μ] f = f ⋆[L, μ] g := by
ext1 x
simp_rw [convolution_def]
rw [← integral_sub_left_eq_self _ μ x]
simp_rw [sub_sub_self, flip_apply]
/-- The symmetric definition of convolution. -/
theorem convolution_eq_swap : (f ⋆[L, μ] g) x = ∫ t, L (f (x - t)) (g t) ∂μ := by
rw [← convolution_flip]; rfl
/-- The symmetric definition of convolution where the bilinear operator is scalar multiplication. -/
theorem convolution_lsmul_swap {f : G → 𝕜} {g : G → F} :
(f ⋆[lsmul 𝕜 𝕜, μ] g : G → F) x = ∫ t, f (x - t) • g t ∂μ :=
convolution_eq_swap _
/-- The symmetric definition of convolution where the bilinear operator is multiplication. -/
theorem convolution_mul_swap [NormedSpace ℝ 𝕜] {f : G → 𝕜} {g : G → 𝕜} :
(f ⋆[mul 𝕜 𝕜, μ] g) x = ∫ t, f (x - t) * g t ∂μ :=
convolution_eq_swap _
/-- The convolution of two even functions is also even. -/
theorem convolution_neg_of_neg_eq (h1 : ∀ᵐ x ∂μ, f (-x) = f x) (h2 : ∀ᵐ x ∂μ, g (-x) = g x) :
(f ⋆[L, μ] g) (-x) = (f ⋆[L, μ] g) x :=
calc
∫ t : G, (L (f t)) (g (-x - t)) ∂μ = ∫ t : G, (L (f (-t))) (g (x + t)) ∂μ := by
apply integral_congr_ae
filter_upwards [h1, (eventually_add_left_iff μ x).2 h2] with t ht h't
simp_rw [ht, ← h't, neg_add']
_ = ∫ t : G, (L (f t)) (g (x - t)) ∂μ := by
rw [← integral_neg_eq_self]
simp only [neg_neg, ← sub_eq_add_neg]
end Measurable
variable [TopologicalSpace G]
variable [IsTopologicalAddGroup G]
variable [BorelSpace G]
theorem _root_.HasCompactSupport.continuous_convolution_left
(hcf : HasCompactSupport f) (hf : Continuous f) (hg : LocallyIntegrable g μ) :
Continuous (f ⋆[L, μ] g) := by
rw [← convolution_flip]
exact hcf.continuous_convolution_right L.flip hg hf
theorem _root_.BddAbove.continuous_convolution_left_of_integrable
[FirstCountableTopology G] [SecondCountableTopologyEither G E]
(hbf : BddAbove (range fun x => ‖f x‖)) (hf : Continuous f) (hg : Integrable g μ) :
Continuous (f ⋆[L, μ] g) := by
rw [← convolution_flip]
exact hbf.continuous_convolution_right_of_integrable L.flip hg hf
end CommGroup
section NormedAddCommGroup
variable [SeminormedAddCommGroup G]
/-- Compute `(f ⋆ g) x₀` if the support of the `f` is within `Metric.ball 0 R`, and `g` is constant
on `Metric.ball x₀ R`.
We can simplify the RHS further if we assume `f` is integrable, but also if `L = (•)` or more
generally if `L` has an `AntilipschitzWith`-condition. -/
theorem convolution_eq_right' {x₀ : G} {R : ℝ} (hf : support f ⊆ ball (0 : G) R)
(hg : ∀ x ∈ ball x₀ R, g x = g x₀) : (f ⋆[L, μ] g) x₀ = ∫ t, L (f t) (g x₀) ∂μ := by
have h2 : ∀ t, L (f t) (g (x₀ - t)) = L (f t) (g x₀) := fun t ↦ by
by_cases ht : t ∈ support f
· have h2t := hf ht
rw [mem_ball_zero_iff] at h2t
specialize hg (x₀ - t)
rw [sub_eq_add_neg, add_mem_ball_iff_norm, norm_neg, ← sub_eq_add_neg] at hg
rw [hg h2t]
· rw [notMem_support] at ht
simp_rw [ht, L.map_zero₂]
simp_rw [convolution_def, h2]
variable [BorelSpace G] [SecondCountableTopology G]
variable [IsAddLeftInvariant μ] [SFinite μ]
/-- Approximate `(f ⋆ g) x₀` if the support of the `f` is bounded within a ball, and `g` is near
`g x₀` on a ball with the same radius around `x₀`. See `dist_convolution_le` for a special case.
We can simplify the second argument of `dist` further if we add some extra type-classes on `E`
and `𝕜` or if `L` is scalar multiplication. -/
theorem dist_convolution_le' {x₀ : G} {R ε : ℝ} {z₀ : E'} (hε : 0 ≤ ε) (hif : Integrable f μ)
(hf : support f ⊆ ball (0 : G) R) (hmg : AEStronglyMeasurable g μ)
(hg : ∀ x ∈ ball x₀ R, dist (g x) z₀ ≤ ε) :
dist ((f ⋆[L, μ] g : G → F) x₀) (∫ t, L (f t) z₀ ∂μ) ≤ (‖L‖ * ∫ x, ‖f x‖ ∂μ) * ε := by
have hfg : ConvolutionExistsAt f g x₀ L μ := by
refine BddAbove.convolutionExistsAt L ?_ Metric.isOpen_ball.measurableSet (Subset.trans ?_ hf)
hif.integrableOn hmg
swap; · refine fun t => mt fun ht : f t = 0 => ?_; simp_rw [ht, L.map_zero₂]
rw [bddAbove_def]
refine ⟨‖z₀‖ + ε, ?_⟩
rintro _ ⟨x, hx, rfl⟩
refine norm_le_norm_add_const_of_dist_le (hg x ?_)
rwa [mem_ball_iff_norm, norm_sub_rev, ← mem_ball_zero_iff]
have h2 : ∀ t, dist (L (f t) (g (x₀ - t))) (L (f t) z₀) ≤ ‖L (f t)‖ * ε := by
intro t; by_cases ht : t ∈ support f
· have h2t := hf ht
rw [mem_ball_zero_iff] at h2t
specialize hg (x₀ - t)
rw [sub_eq_add_neg, add_mem_ball_iff_norm, norm_neg, ← sub_eq_add_neg] at hg
refine ((L (f t)).dist_le_opNorm _ _).trans ?_
exact mul_le_mul_of_nonneg_left (hg h2t) (norm_nonneg _)
· rw [notMem_support] at ht
simp_rw [ht, L.map_zero₂, L.map_zero, norm_zero, zero_mul, dist_self]
rfl
simp_rw [convolution_def]
simp_rw [dist_eq_norm] at h2 ⊢
rw [← integral_sub hfg.integrable]; swap; · exact (L.flip z₀).integrable_comp hif
refine (norm_integral_le_of_norm_le ((L.integrable_comp hif).norm.mul_const ε)
(Eventually.of_forall h2)).trans ?_
rw [integral_mul_const]
refine mul_le_mul_of_nonneg_right ?_ hε
have h3 : ∀ t, ‖L (f t)‖ ≤ ‖L‖ * ‖f t‖ := by
intro t
exact L.le_opNorm (f t)
refine (integral_mono (L.integrable_comp hif).norm (hif.norm.const_mul _) h3).trans_eq ?_
rw [integral_const_mul]
variable [NormedSpace ℝ E] [NormedSpace ℝ E'] [CompleteSpace E']
/-- Approximate `f ⋆ g` if the support of the `f` is bounded within a ball, and `g` is near `g x₀`
on a ball with the same radius around `x₀`.
This is a special case of `dist_convolution_le'` where `L` is `(•)`, `f` has integral 1 and `f` is
nonnegative. -/
theorem dist_convolution_le {f : G → ℝ} {x₀ : G} {R ε : ℝ} {z₀ : E'} (hε : 0 ≤ ε)
(hf : support f ⊆ ball (0 : G) R) (hnf : ∀ x, 0 ≤ f x) (hintf : ∫ x, f x ∂μ = 1)
(hmg : AEStronglyMeasurable g μ) (hg : ∀ x ∈ ball x₀ R, dist (g x) z₀ ≤ ε) :
dist ((f ⋆[lsmul ℝ ℝ, μ] g : G → E') x₀) z₀ ≤ ε := by
have hif : Integrable f μ := integrable_of_integral_eq_one hintf
convert (dist_convolution_le' (lsmul ℝ ℝ) hε hif hf hmg hg).trans _
· simp_rw [lsmul_apply, integral_smul_const, hintf, one_smul]
· simp_rw [Real.norm_of_nonneg (hnf _), hintf, mul_one]
exact (mul_le_mul_of_nonneg_right opNorm_lsmul_le hε).trans_eq (one_mul ε)
/-- `(φ i ⋆ g i) (k i)` tends to `z₀` as `i` tends to some filter `l` if
* `φ` is a sequence of nonnegative functions with integral `1` as `i` tends to `l`;
* The support of `φ` tends to small neighborhoods around `(0 : G)` as `i` tends to `l`;
* `g i` is `mu`-a.e. strongly measurable as `i` tends to `l`;
* `g i x` tends to `z₀` as `(i, x)` tends to `l ×ˢ 𝓝 x₀`;
* `k i` tends to `x₀`.
See also `ContDiffBump.convolution_tendsto_right`.
-/
theorem convolution_tendsto_right {ι} {g : ι → G → E'} {l : Filter ι} {x₀ : G} {z₀ : E'}
{φ : ι → G → ℝ} {k : ι → G} (hnφ : ∀ᶠ i in l, ∀ x, 0 ≤ φ i x)
(hiφ : ∀ᶠ i in l, ∫ x, φ i x ∂μ = 1)
-- todo: we could weaken this to "the integral tends to 1"
(hφ : Tendsto (fun n => support (φ n)) l (𝓝 0).smallSets)
(hmg : ∀ᶠ i in l, AEStronglyMeasurable (g i) μ) (hcg : Tendsto (uncurry g) (l ×ˢ 𝓝 x₀) (𝓝 z₀))
(hk : Tendsto k l (𝓝 x₀)) :
Tendsto (fun i : ι => (φ i ⋆[lsmul ℝ ℝ, μ] g i : G → E') (k i)) l (𝓝 z₀) := by
simp_rw [tendsto_smallSets_iff] at hφ
rw [Metric.tendsto_nhds] at hcg ⊢
simp_rw [Metric.eventually_prod_nhds_iff] at hcg
intro ε hε
have h2ε : 0 < ε / 3 := div_pos hε (by simp)
obtain ⟨p, hp, δ, hδ, hgδ⟩ := hcg _ h2ε
dsimp only [uncurry] at hgδ
have h2k := hk.eventually (ball_mem_nhds x₀ <| half_pos hδ)
have h2φ := hφ (ball (0 : G) _) <| ball_mem_nhds _ (half_pos hδ)
filter_upwards [hp, h2k, h2φ, hnφ, hiφ, hmg] with i hpi hki hφi hnφi hiφi hmgi
have hgi : dist (g i (k i)) z₀ < ε / 3 := hgδ hpi (hki.trans <| half_lt_self hδ)
have h1 : ∀ x' ∈ ball (k i) (δ / 2), dist (g i x') (g i (k i)) ≤ ε / 3 + ε / 3 := by
intro x' hx'
refine (dist_triangle_right _ _ _).trans (add_le_add (hgδ hpi ?_).le hgi.le)
exact ((dist_triangle _ _ _).trans_lt (add_lt_add hx'.out hki)).trans_eq (add_halves δ)
have := dist_convolution_le (add_pos h2ε h2ε).le hφi hnφi hiφi hmgi h1
refine ((dist_triangle _ _ _).trans_lt (add_lt_add_of_le_of_lt this hgi)).trans_eq ?_
ring
end NormedAddCommGroup
end Measurability
end NontriviallyNormedField
open scoped Convolution
section RCLike
variable [RCLike 𝕜]
variable [NormedSpace 𝕜 E]
variable [NormedSpace 𝕜 E']
variable [NormedSpace 𝕜 E'']
variable [NormedSpace ℝ F] [NormedSpace 𝕜 F]
variable {n : ℕ∞}
variable [MeasurableSpace G] {μ ν : Measure G}
variable (L : E →L[𝕜] E' →L[𝕜] F)
section Assoc
variable [CompleteSpace F]
variable [NormedAddCommGroup F'] [NormedSpace ℝ F'] [NormedSpace 𝕜 F'] [CompleteSpace F']
variable [NormedAddCommGroup F''] [NormedSpace ℝ F''] [NormedSpace 𝕜 F''] [CompleteSpace F'']
variable {k : G → E''}
variable (L₂ : F →L[𝕜] E'' →L[𝕜] F')
variable (L₃ : E →L[𝕜] F'' →L[𝕜] F')
variable (L₄ : E' →L[𝕜] E'' →L[𝕜] F'')
variable [AddGroup G]
variable [SFinite μ] [SFinite ν] [IsAddRightInvariant μ]
theorem integral_convolution [MeasurableAdd₂ G] [MeasurableNeg G] [NormedSpace ℝ E]
[NormedSpace ℝ E'] [CompleteSpace E] [CompleteSpace E'] (hf : Integrable f ν)
(hg : Integrable g μ) : ∫ x, (f ⋆[L, ν] g) x ∂μ = L (∫ x, f x ∂ν) (∫ x, g x ∂μ) := by
refine (integral_integral_swap (by apply hf.convolution_integrand L hg)).trans ?_
simp_rw [integral_comp_comm _ (hg.comp_sub_right _), integral_sub_right_eq_self]
exact (L.flip (∫ x, g x ∂μ)).integral_comp_comm hf
variable [MeasurableAdd₂ G] [IsAddRightInvariant ν] [MeasurableNeg G]
/-- Convolution is associative. This has a weak but inconvenient integrability condition.
See also `MeasureTheory.convolution_assoc`. -/
theorem convolution_assoc' (hL : ∀ (x : E) (y : E') (z : E''), L₂ (L x y) z = L₃ x (L₄ y z))
{x₀ : G} (hfg : ∀ᵐ y ∂μ, ConvolutionExistsAt f g y L ν)
(hgk : ∀ᵐ x ∂ν, ConvolutionExistsAt g k x L₄ μ)
(hi : Integrable (uncurry fun x y => (L₃ (f y)) ((L₄ (g (x - y))) (k (x₀ - x)))) (μ.prod ν)) :
((f ⋆[L, ν] g) ⋆[L₂, μ] k) x₀ = (f ⋆[L₃, ν] g ⋆[L₄, μ] k) x₀ :=
calc
((f ⋆[L, ν] g) ⋆[L₂, μ] k) x₀ = ∫ t, L₂ (∫ s, L (f s) (g (t - s)) ∂ν) (k (x₀ - t)) ∂μ := rfl
_ = ∫ t, ∫ s, L₂ (L (f s) (g (t - s))) (k (x₀ - t)) ∂ν ∂μ :=
(integral_congr_ae (hfg.mono fun t ht => ((L₂.flip (k (x₀ - t))).integral_comp_comm ht).symm))
_ = ∫ t, ∫ s, L₃ (f s) (L₄ (g (t - s)) (k (x₀ - t))) ∂ν ∂μ := by simp_rw [hL]
_ = ∫ s, ∫ t, L₃ (f s) (L₄ (g (t - s)) (k (x₀ - t))) ∂μ ∂ν := by rw [integral_integral_swap hi]
_ = ∫ s, ∫ u, L₃ (f s) (L₄ (g u) (k (x₀ - s - u))) ∂μ ∂ν := by
congr; ext t
rw [eq_comm, ← integral_sub_right_eq_self _ t]
simp_rw [sub_sub_sub_cancel_right]
_ = ∫ s, L₃ (f s) (∫ u, L₄ (g u) (k (x₀ - s - u)) ∂μ) ∂ν := by
refine integral_congr_ae ?_
refine ((quasiMeasurePreserving_sub_left_of_right_invariant ν x₀).ae hgk).mono fun t ht => ?_
exact (L₃ (f t)).integral_comp_comm ht
_ = (f ⋆[L₃, ν] g ⋆[L₄, μ] k) x₀ := rfl
/-- Convolution is associative. This requires that
* all maps are a.e. strongly measurable w.r.t. one of the measures
* `f ⋆[L, ν] g` exists almost everywhere
* `‖g‖ ⋆[μ] ‖k‖` exists almost everywhere
* `‖f‖ ⋆[ν] (‖g‖ ⋆[μ] ‖k‖)` exists at `x₀` -/
theorem convolution_assoc (hL : ∀ (x : E) (y : E') (z : E''), L₂ (L x y) z = L₃ x (L₄ y z)) {x₀ : G}
(hf : AEStronglyMeasurable f ν) (hg : AEStronglyMeasurable g μ) (hk : AEStronglyMeasurable k μ)
(hfg : ∀ᵐ y ∂μ, ConvolutionExistsAt f g y L ν)
(hgk : ∀ᵐ x ∂ν, ConvolutionExistsAt (fun x => ‖g x‖) (fun x => ‖k x‖) x (mul ℝ ℝ) μ)
(hfgk :
ConvolutionExistsAt (fun x => ‖f x‖) ((fun x => ‖g x‖) ⋆[mul ℝ ℝ, μ] fun x => ‖k x‖) x₀
(mul ℝ ℝ) ν) :
((f ⋆[L, ν] g) ⋆[L₂, μ] k) x₀ = (f ⋆[L₃, ν] g ⋆[L₄, μ] k) x₀ := by
refine convolution_assoc' L L₂ L₃ L₄ hL hfg (hgk.mono fun x hx => hx.of_norm L₄ hg hk) ?_
-- the following is similar to `Integrable.convolution_integrand`
have h_meas :
AEStronglyMeasurable (uncurry fun x y => L₃ (f y) (L₄ (g x) (k (x₀ - y - x))))
(μ.prod ν) := by
refine L₃.aestronglyMeasurable_comp₂ hf.comp_snd ?_
refine L₄.aestronglyMeasurable_comp₂ hg.comp_fst ?_
refine (hk.mono_ac ?_).comp_measurable
((measurable_const.sub measurable_snd).sub measurable_fst)
refine QuasiMeasurePreserving.absolutelyContinuous ?_
refine QuasiMeasurePreserving.prod_of_left
((measurable_const.sub measurable_snd).sub measurable_fst) (Eventually.of_forall fun y => ?_)
dsimp only
exact quasiMeasurePreserving_sub_left_of_right_invariant μ _
have h2_meas :
AEStronglyMeasurable (fun y => ∫ x, ‖L₃ (f y) (L₄ (g x) (k (x₀ - y - x)))‖ ∂μ) ν :=
h_meas.prod_swap.norm.integral_prod_right'
have h3 : map (fun z : G × G => (z.1 - z.2, z.2)) (μ.prod ν) = μ.prod ν :=
(measurePreserving_sub_prod μ ν).map_eq
suffices Integrable (uncurry fun x y => L₃ (f y) (L₄ (g x) (k (x₀ - y - x)))) (μ.prod ν) by
rw [← h3] at this
convert this.comp_measurable (measurable_sub.prodMk measurable_snd)
ext ⟨x, y⟩
simp +unfoldPartialApp only [uncurry, Function.comp_apply,
sub_sub_sub_cancel_right]
simp_rw [integrable_prod_iff' h_meas]
refine ⟨((quasiMeasurePreserving_sub_left_of_right_invariant ν x₀).ae hgk).mono fun t ht =>
(L₃ (f t)).integrable_comp <| ht.of_norm L₄ hg hk, ?_⟩
refine (hfgk.const_mul (‖L₃‖ * ‖L₄‖)).mono' h2_meas
(((quasiMeasurePreserving_sub_left_of_right_invariant ν x₀).ae hgk).mono fun t ht => ?_)
simp_rw [convolution_def, mul_apply', mul_mul_mul_comm ‖L₃‖ ‖L₄‖, ← integral_const_mul]
rw [Real.norm_of_nonneg (by positivity)]
refine integral_mono_of_nonneg (Eventually.of_forall fun t => norm_nonneg _)
((ht.const_mul _).const_mul _) (Eventually.of_forall fun s => ?_)
simp only [← mul_assoc ‖L₄‖]
apply_rules [ContinuousLinearMap.le_of_opNorm₂_le_of_le, le_rfl]
end Assoc
variable [NormedAddCommGroup G] [BorelSpace G]
theorem convolution_precompR_apply {g : G → E'' →L[𝕜] E'} (hf : LocallyIntegrable f μ)
(hcg : HasCompactSupport g) (hg : Continuous g) (x₀ : G) (x : E'') :
(f ⋆[L.precompR E'', μ] g) x₀ x = (f ⋆[L, μ] fun a => g a x) x₀ := by
have := hcg.convolutionExists_right (L.precompR E'' :) hf hg x₀
simp_rw [convolution_def, ContinuousLinearMap.integral_apply this]
rfl
variable [NormedSpace 𝕜 G] [SFinite μ] [IsAddLeftInvariant μ]
/-- Compute the total derivative of `f ⋆ g` if `g` is `C^1` with compact support and `f` is locally
integrable. To write down the total derivative as a convolution, we use
`ContinuousLinearMap.precompR`. -/
theorem _root_.HasCompactSupport.hasFDerivAt_convolution_right (hcg : HasCompactSupport g)
(hf : LocallyIntegrable f μ) (hg : ContDiff 𝕜 1 g) (x₀ : G) :
HasFDerivAt (f ⋆[L, μ] g) ((f ⋆[L.precompR G, μ] fderiv 𝕜 g) x₀) x₀ := by
rcases hcg.eq_zero_or_finiteDimensional 𝕜 hg.continuous with (rfl | fin_dim)
· have : fderiv 𝕜 (0 : G → E') = 0 := fderiv_const (0 : E')
simp only [this, convolution_zero, Pi.zero_apply]
exact hasFDerivAt_const (0 : F) x₀
have : ProperSpace G := FiniteDimensional.proper_rclike 𝕜 G
set L' := L.precompR G
have h1 : ∀ᶠ x in 𝓝 x₀, AEStronglyMeasurable (fun t => L (f t) (g (x - t))) μ :=
Eventually.of_forall
(hf.aestronglyMeasurable.convolution_integrand_snd L hg.continuous.aestronglyMeasurable)
have h2 : ∀ x, AEStronglyMeasurable (fun t => L' (f t) (fderiv 𝕜 g (x - t))) μ :=
hf.aestronglyMeasurable.convolution_integrand_snd L'
(hg.continuous_fderiv le_rfl).aestronglyMeasurable
have h3 : ∀ x t, HasFDerivAt (fun x => g (x - t)) (fderiv 𝕜 g (x - t)) x := fun x t ↦ by
simpa using
(hg.differentiable le_rfl).differentiableAt.hasFDerivAt.comp x
((hasFDerivAt_id x).sub (hasFDerivAt_const t x))
let K' := -tsupport (fderiv 𝕜 g) + closedBall x₀ 1
have hK' : IsCompact K' := (hcg.fderiv 𝕜).isCompact.neg.add (isCompact_closedBall x₀ 1)
apply hasFDerivAt_integral_of_dominated_of_fderiv_le zero_lt_one h1 _ (h2 x₀)
· filter_upwards with t x hx using
(hcg.fderiv 𝕜).convolution_integrand_bound_right L' (hg.continuous_fderiv le_rfl)
(ball_subset_closedBall hx)
· rw [integrable_indicator_iff hK'.measurableSet]
exact ((hf.integrableOn_isCompact hK').norm.const_mul _).mul_const _
· exact Eventually.of_forall fun t x _ => (L _).hasFDerivAt.comp x (h3 x t)
· exact hcg.convolutionExists_right L hf hg.continuous x₀
theorem _root_.HasCompactSupport.hasFDerivAt_convolution_left [IsNegInvariant μ]
(hcf : HasCompactSupport f) (hf : ContDiff 𝕜 1 f) (hg : LocallyIntegrable g μ) (x₀ : G) :
HasFDerivAt (f ⋆[L, μ] g) ((fderiv 𝕜 f ⋆[L.precompL G, μ] g) x₀) x₀ := by
simp +singlePass only [← convolution_flip]
exact hcf.hasFDerivAt_convolution_right L.flip hg hf x₀
end RCLike
section Real
/-! The one-variable case -/
variable [RCLike 𝕜]
variable [NormedSpace 𝕜 E]
variable [NormedSpace 𝕜 E']
variable [NormedSpace ℝ F] [NormedSpace 𝕜 F]
variable {f₀ : 𝕜 → E} {g₀ : 𝕜 → E'}
variable {n : ℕ∞}
variable (L : E →L[𝕜] E' →L[𝕜] F)
variable {μ : Measure 𝕜}
variable [IsAddLeftInvariant μ] [SFinite μ]
theorem _root_.HasCompactSupport.hasDerivAt_convolution_right (hf : LocallyIntegrable f₀ μ)
(hcg : HasCompactSupport g₀) (hg : ContDiff 𝕜 1 g₀) (x₀ : 𝕜) :
HasDerivAt (f₀ ⋆[L, μ] g₀) ((f₀ ⋆[L, μ] deriv g₀) x₀) x₀ := by
convert (hcg.hasFDerivAt_convolution_right L hf hg x₀).hasDerivAt using 1
rw [convolution_precompR_apply L hf (hcg.fderiv 𝕜) (hg.continuous_fderiv le_rfl)]
rfl
theorem _root_.HasCompactSupport.hasDerivAt_convolution_left [IsNegInvariant μ]
(hcf : HasCompactSupport f₀) (hf : ContDiff 𝕜 1 f₀) (hg : LocallyIntegrable g₀ μ) (x₀ : 𝕜) :
HasDerivAt (f₀ ⋆[L, μ] g₀) ((deriv f₀ ⋆[L, μ] g₀) x₀) x₀ := by
simp +singlePass only [← convolution_flip]
exact hcf.hasDerivAt_convolution_right L.flip hg hf x₀
end Real
section WithParam
variable [RCLike 𝕜] [NormedSpace 𝕜 E] [NormedSpace 𝕜 E'] [NormedSpace 𝕜 E''] [NormedSpace ℝ F]
[NormedSpace 𝕜 F] [MeasurableSpace G] [NormedAddCommGroup G] [BorelSpace G]
[NormedSpace 𝕜 G] [NormedAddCommGroup P] [NormedSpace 𝕜 P] {μ : Measure G}
(L : E →L[𝕜] E' →L[𝕜] F)
/-- The derivative of the convolution `f * g` is given by `f * Dg`, when `f` is locally integrable
and `g` is `C^1` and compactly supported. Version where `g` depends on an additional parameter in an
open subset `s` of a parameter space `P` (and the compact support `k` is independent of the
parameter in `s`). -/
theorem hasFDerivAt_convolution_right_with_param {g : P → G → E'} {s : Set P} {k : Set G}
(hs : IsOpen s) (hk : IsCompact k) (hgs : ∀ p, ∀ x, p ∈ s → x ∉ k → g p x = 0)
(hf : LocallyIntegrable f μ) (hg : ContDiffOn 𝕜 1 ↿g (s ×ˢ univ)) (q₀ : P × G)
(hq₀ : q₀.1 ∈ s) :
HasFDerivAt (fun q : P × G => (f ⋆[L, μ] g q.1) q.2)
((f ⋆[L.precompR (P × G), μ] fun x : G => fderiv 𝕜 ↿g (q₀.1, x)) q₀.2) q₀ := by
let g' := fderiv 𝕜 ↿g
have A : ∀ p ∈ s, Continuous (g p) := fun p hp ↦ by
refine hg.continuousOn.comp_continuous (.prodMk_right _) fun x => ?_
simpa only [prodMk_mem_set_prod_eq, mem_univ, and_true] using hp
have A' : ∀ q : P × G, q.1 ∈ s → s ×ˢ univ ∈ 𝓝 q := fun q hq ↦ by
apply (hs.prod isOpen_univ).mem_nhds
simpa only [mem_prod, mem_univ, and_true] using hq
-- The derivative of `g` vanishes away from `k`.
have g'_zero : ∀ p x, p ∈ s → x ∉ k → g' (p, x) = 0 := by
intro p x hp hx
refine (hasFDerivAt_zero_of_eventually_const 0 ?_).fderiv
have M2 : kᶜ ∈ 𝓝 x := hk.isClosed.isOpen_compl.mem_nhds hx
have M1 : s ∈ 𝓝 p := hs.mem_nhds hp
rw [nhds_prod_eq]
filter_upwards [prod_mem_prod M1 M2]
rintro ⟨p, y⟩ ⟨hp, hy⟩
exact hgs p y hp hy
/- We find a small neighborhood of `{q₀.1} × k` on which the derivative is uniformly bounded. This
follows from the continuity at all points of the compact set `k`. -/
obtain ⟨ε, C, εpos, h₀ε, hε⟩ :
∃ ε C, 0 < ε ∧ ball q₀.1 ε ⊆ s ∧ ∀ p x, ‖p - q₀.1‖ < ε → ‖g' (p, x)‖ ≤ C := by
have A : IsCompact ({q₀.1} ×ˢ k) := isCompact_singleton.prod hk
obtain ⟨t, kt, t_open, ht⟩ : ∃ t, {q₀.1} ×ˢ k ⊆ t ∧ IsOpen t ∧ IsBounded (g' '' t) := by
have B : ContinuousOn g' (s ×ˢ univ) :=
hg.continuousOn_fderiv_of_isOpen (hs.prod isOpen_univ) le_rfl
apply exists_isOpen_isBounded_image_of_isCompact_of_continuousOn A (hs.prod isOpen_univ) _ B
simp only [prod_subset_prod_iff, hq₀, singleton_subset_iff, subset_univ, and_self_iff,
true_or]
obtain ⟨ε, εpos, hε, h'ε⟩ :
∃ ε : ℝ, 0 < ε ∧ thickening ε ({q₀.fst} ×ˢ k) ⊆ t ∧ ball q₀.1 ε ⊆ s := by
obtain ⟨ε, εpos, hε⟩ : ∃ ε : ℝ, 0 < ε ∧ thickening ε (({q₀.fst} : Set P) ×ˢ k) ⊆ t :=
A.exists_thickening_subset_open t_open kt
obtain ⟨δ, δpos, hδ⟩ : ∃ δ : ℝ, 0 < δ ∧ ball q₀.1 δ ⊆ s := Metric.isOpen_iff.1 hs _ hq₀
refine ⟨min ε δ, lt_min εpos δpos, ?_, ?_⟩
· exact Subset.trans (thickening_mono (min_le_left _ _) _) hε
· exact Subset.trans (ball_subset_ball (min_le_right _ _)) hδ
obtain ⟨C, Cpos, hC⟩ : ∃ C, 0 < C ∧ g' '' t ⊆ closedBall 0 C := ht.subset_closedBall_lt 0 0
refine ⟨ε, C, εpos, h'ε, fun p x hp => ?_⟩
have hps : p ∈ s := h'ε (mem_ball_iff_norm.2 hp)
by_cases hx : x ∈ k
· have H : (p, x) ∈ t := by
apply hε
refine mem_thickening_iff.2 ⟨(q₀.1, x), ?_, ?_⟩
· simp only [hx, singleton_prod, mem_image, Prod.mk_inj, true_and, exists_eq_right]
· rw [← dist_eq_norm] at hp
simpa only [Prod.dist_eq, εpos, dist_self, max_lt_iff, and_true] using hp
have : g' (p, x) ∈ closedBall (0 : P × G →L[𝕜] E') C := hC (mem_image_of_mem _ H)
rwa [mem_closedBall_zero_iff] at this
· have : g' (p, x) = 0 := g'_zero _ _ hps hx
rw [this]
simpa only [norm_zero] using Cpos.le
/- Now, we wish to apply a theorem on differentiation of integrals. For this, we need to check
trivial measurability or integrability assumptions (in `I1`, `I2`, `I3`), as well as a uniform
integrability assumption over the derivative (in `I4` and `I5`) and pointwise differentiability
in `I6`. -/
have I1 :
∀ᶠ x : P × G in 𝓝 q₀, AEStronglyMeasurable (fun a : G => L (f a) (g x.1 (x.2 - a))) μ := by
filter_upwards [A' q₀ hq₀]
rintro ⟨p, x⟩ ⟨hp, -⟩
refine (HasCompactSupport.convolutionExists_right L ?_ hf (A _ hp) _).1
apply hk.of_isClosed_subset (isClosed_tsupport _)
exact closure_minimal (support_subset_iff'.2 fun z hz => hgs _ _ hp hz) hk.isClosed
have I2 : Integrable (fun a : G => L (f a) (g q₀.1 (q₀.2 - a))) μ := by
have M : HasCompactSupport (g q₀.1) := HasCompactSupport.intro hk fun x hx => hgs q₀.1 x hq₀ hx
apply M.convolutionExists_right L hf (A q₀.1 hq₀) q₀.2
have I3 : AEStronglyMeasurable (fun a : G => (L (f a)).comp (g' (q₀.fst, q₀.snd - a))) μ := by
have T : HasCompactSupport fun y => g' (q₀.1, y) :=
HasCompactSupport.intro hk fun x hx => g'_zero q₀.1 x hq₀ hx
apply (HasCompactSupport.convolutionExists_right (L.precompR (P × G) :) T hf _ q₀.2).1
have : ContinuousOn g' (s ×ˢ univ) :=
hg.continuousOn_fderiv_of_isOpen (hs.prod isOpen_univ) le_rfl
apply this.comp_continuous (.prodMk_right _)
intro x
simpa only [prodMk_mem_set_prod_eq, mem_univ, and_true] using hq₀
set K' := (-k + {q₀.2} : Set G) with K'_def
have hK' : IsCompact K' := hk.neg.add isCompact_singleton
obtain ⟨U, U_open, K'U, hU⟩ : ∃ U, IsOpen U ∧ K' ⊆ U ∧ IntegrableOn f U μ :=
hf.integrableOn_nhds_isCompact hK'
obtain ⟨δ, δpos, δε, hδ⟩ : ∃ δ, (0 : ℝ) < δ ∧ δ ≤ ε ∧ K' + ball 0 δ ⊆ U := by
obtain ⟨V, V_mem, hV⟩ : ∃ V ∈ 𝓝 (0 : G), K' + V ⊆ U :=
compact_open_separated_add_right hK' U_open K'U
rcases Metric.mem_nhds_iff.1 V_mem with ⟨δ, δpos, hδ⟩
refine ⟨min δ ε, lt_min δpos εpos, min_le_right δ ε, ?_⟩
exact (add_subset_add_left ((ball_subset_ball (min_le_left _ _)).trans hδ)).trans hV
letI := ContinuousLinearMap.hasOpNorm (𝕜 := 𝕜) (𝕜₂ := 𝕜) (E := E)
(F := (P × G →L[𝕜] E') →L[𝕜] P × G →L[𝕜] F) (σ₁₂ := RingHom.id 𝕜)
let bound : G → ℝ := indicator U fun t => ‖(L.precompR (P × G))‖ * ‖f t‖ * C
have I4 : ∀ᵐ a : G ∂μ, ∀ x : P × G, dist x q₀ < δ →
‖L.precompR (P × G) (f a) (g' (x.fst, x.snd - a))‖ ≤ bound a := by
filter_upwards with a x hx
rw [Prod.dist_eq, dist_eq_norm, dist_eq_norm] at hx
have : (-tsupport fun a => g' (x.1, a)) + ball q₀.2 δ ⊆ U := by
apply Subset.trans _ hδ
rw [K'_def, add_assoc]
apply add_subset_add
· rw [neg_subset_neg]
refine closure_minimal (support_subset_iff'.2 fun z hz => ?_) hk.isClosed
apply g'_zero x.1 z (h₀ε _) hz
rw [mem_ball_iff_norm]
exact ((le_max_left _ _).trans_lt hx).trans_le δε
· simp only [add_ball, thickening_singleton, zero_vadd, subset_rfl]
apply convolution_integrand_bound_right_of_le_of_subset _ _ _ this
· intro y
exact hε _ _ (((le_max_left _ _).trans_lt hx).trans_le δε)
· rw [mem_ball_iff_norm]
exact (le_max_right _ _).trans_lt hx
have I5 : Integrable bound μ := by
rw [integrable_indicator_iff U_open.measurableSet]
exact (hU.norm.const_mul _).mul_const _
have I6 : ∀ᵐ a : G ∂μ, ∀ x : P × G, dist x q₀ < δ →
HasFDerivAt (fun x : P × G => L (f a) (g x.1 (x.2 - a)))
((L (f a)).comp (g' (x.fst, x.snd - a))) x := by
filter_upwards with a x hx
apply (L _).hasFDerivAt.comp x
have N : s ×ˢ univ ∈ 𝓝 (x.1, x.2 - a) := by
apply A'
apply h₀ε
rw [Prod.dist_eq] at hx
exact lt_of_lt_of_le (lt_of_le_of_lt (le_max_left _ _) hx) δε
have Z := ((hg.differentiableOn le_rfl).differentiableAt N).hasFDerivAt
have Z' :
HasFDerivAt (fun x : P × G => (x.1, x.2 - a)) (ContinuousLinearMap.id 𝕜 (P × G)) x := by
have : (fun x : P × G => (x.1, x.2 - a)) = _root_.id - fun x => (0, a) := by
ext x <;> simp only [Pi.sub_apply, _root_.id, Prod.fst_sub, sub_zero, Prod.snd_sub]
rw [this]
exact (hasFDerivAt_id x).sub_const (0, a)
exact Z.comp x Z'
exact hasFDerivAt_integral_of_dominated_of_fderiv_le δpos I1 I2 I3 I4 I5 I6
/-- The convolution `f * g` is `C^n` when `f` is locally integrable and `g` is `C^n` and compactly
supported. Version where `g` depends on an additional parameter in an open subset `s` of a
parameter space `P` (and the compact support `k` is independent of the parameter in `s`).
In this version, all the types belong to the same universe (to get an induction working in the
proof). Use instead `contDiffOn_convolution_right_with_param`, which removes this restriction. -/
theorem contDiffOn_convolution_right_with_param_aux {G : Type uP} {E' : Type uP} {F : Type uP}
{P : Type uP} [NormedAddCommGroup E'] [NormedAddCommGroup F] [NormedSpace 𝕜 E']
[NormedSpace ℝ F] [NormedSpace 𝕜 F] [MeasurableSpace G]
{μ : Measure G}
[NormedAddCommGroup G] [BorelSpace G] [NormedSpace 𝕜 G] [NormedAddCommGroup P] [NormedSpace 𝕜 P]
{f : G → E} {n : ℕ∞} (L : E →L[𝕜] E' →L[𝕜] F) {g : P → G → E'} {s : Set P} {k : Set G}
(hs : IsOpen s) (hk : IsCompact k) (hgs : ∀ p, ∀ x, p ∈ s → x ∉ k → g p x = 0)
(hf : LocallyIntegrable f μ) (hg : ContDiffOn 𝕜 n ↿g (s ×ˢ univ)) :
ContDiffOn 𝕜 n (fun q : P × G => (f ⋆[L, μ] g q.1) q.2) (s ×ˢ univ) := by
/- We have a formula for the derivation of `f * g`, which is of the same form, thanks to
`hasFDerivAt_convolution_right_with_param`. Therefore, we can prove the result by induction on
`n` (but for this we need the spaces at the different steps of the induction to live in the same
universe, which is why we make the assumption in the lemma that all the relevant spaces
come from the same universe). -/
induction n using ENat.nat_induction generalizing g E' F with
| zero =>
rw [WithTop.coe_zero, contDiffOn_zero] at hg ⊢
exact continuousOn_convolution_right_with_param L hk hgs hf hg
| succ n ih =>
simp only [Nat.succ_eq_add_one, Nat.cast_add, Nat.cast_one, WithTop.coe_add,
WithTop.coe_natCast, WithTop.coe_one] at hg ⊢
let f' : P → G → P × G →L[𝕜] F := fun p a =>
(f ⋆[L.precompR (P × G), μ] fun x : G => fderiv 𝕜 (uncurry g) (p, x)) a
have A : ∀ q₀ : P × G, q₀.1 ∈ s →
HasFDerivAt (fun q : P × G => (f ⋆[L, μ] g q.1) q.2) (f' q₀.1 q₀.2) q₀ :=
hasFDerivAt_convolution_right_with_param L hs hk hgs hf hg.one_of_succ
rw [contDiffOn_succ_iff_fderiv_of_isOpen (hs.prod (@isOpen_univ G _))] at hg ⊢
refine ⟨?_, by simp, ?_⟩
· rintro ⟨p, x⟩ ⟨hp, -⟩
exact (A (p, x) hp).differentiableAt.differentiableWithinAt
· suffices H : ContDiffOn 𝕜 n ↿f' (s ×ˢ univ) by
apply H.congr
rintro ⟨p, x⟩ ⟨hp, -⟩
exact (A (p, x) hp).fderiv
have B : ∀ (p : P) (x : G), p ∈ s → x ∉ k → fderiv 𝕜 (uncurry g) (p, x) = 0 := by
intro p x hp hx
apply (hasFDerivAt_zero_of_eventually_const (0 : E') _).fderiv
have M2 : kᶜ ∈ 𝓝 x := IsOpen.mem_nhds hk.isClosed.isOpen_compl hx
have M1 : s ∈ 𝓝 p := hs.mem_nhds hp
rw [nhds_prod_eq]
filter_upwards [prod_mem_prod M1 M2]
rintro ⟨p, y⟩ ⟨hp, hy⟩
exact hgs p y hp hy
apply ih (L.precompR (P × G) :) B
convert hg.2.2
| top ih =>
rw [contDiffOn_infty] at hg ⊢
exact fun n ↦ ih n L hgs (hg n)
/-- The convolution `f * g` is `C^n` when `f` is locally integrable and `g` is `C^n` and compactly
supported. Version where `g` depends on an additional parameter in an open subset `s` of a
parameter space `P` (and the compact support `k` is independent of the parameter in `s`). -/
theorem contDiffOn_convolution_right_with_param {f : G → E} {n : ℕ∞} (L : E →L[𝕜] E' →L[𝕜] F)
{g : P → G → E'} {s : Set P} {k : Set G} (hs : IsOpen s) (hk : IsCompact k)
(hgs : ∀ p, ∀ x, p ∈ s → x ∉ k → g p x = 0) (hf : LocallyIntegrable f μ)
(hg : ContDiffOn 𝕜 n ↿g (s ×ˢ univ)) :
ContDiffOn 𝕜 n (fun q : P × G => (f ⋆[L, μ] g q.1) q.2) (s ×ˢ univ) := by
/- The result is known when all the universes are the same, from
`contDiffOn_convolution_right_with_param_aux`. We reduce to this situation by pushing
everything through `ULift` continuous linear equivalences. -/
let eG : Type max uG uE' uF uP := ULift.{max uE' uF uP} G
borelize eG
let eE' : Type max uE' uG uF uP := ULift.{max uG uF uP} E'
let eF : Type max uF uG uE' uP := ULift.{max uG uE' uP} F
let eP : Type max uP uG uE' uF := ULift.{max uG uE' uF} P
let isoG : eG ≃L[𝕜] G := ContinuousLinearEquiv.ulift
let isoE' : eE' ≃L[𝕜] E' := ContinuousLinearEquiv.ulift
let isoF : eF ≃L[𝕜] F := ContinuousLinearEquiv.ulift
let isoP : eP ≃L[𝕜] P := ContinuousLinearEquiv.ulift
let ef := f ∘ isoG
let eμ : Measure eG := Measure.map isoG.symm μ
let eg : eP → eG → eE' := fun ep ex => isoE'.symm (g (isoP ep) (isoG ex))
let eL :=
ContinuousLinearMap.comp
((ContinuousLinearEquiv.arrowCongr isoE' isoF).symm : (E' →L[𝕜] F) →L[𝕜] eE' →L[𝕜] eF) L
let R := fun q : eP × eG => (ef ⋆[eL, eμ] eg q.1) q.2
have R_contdiff : ContDiffOn 𝕜 n R ((isoP ⁻¹' s) ×ˢ univ) := by
have hek : IsCompact (isoG ⁻¹' k) := isoG.toHomeomorph.isClosedEmbedding.isCompact_preimage hk
have hes : IsOpen (isoP ⁻¹' s) := isoP.continuous.isOpen_preimage _ hs
refine contDiffOn_convolution_right_with_param_aux eL hes hek ?_ ?_ ?_
· intro p x hp hx
simp only [eg,
ContinuousLinearEquiv.map_eq_zero_iff]
exact hgs _ _ hp hx
· exact (locallyIntegrable_map_homeomorph isoG.symm.toHomeomorph).2 hf
· apply isoE'.symm.contDiff.comp_contDiffOn
apply hg.comp (isoP.prodCongr isoG).contDiff.contDiffOn
rintro ⟨p, x⟩ ⟨hp, -⟩
simpa only [mem_preimage, ContinuousLinearEquiv.prodCongr_apply, prodMk_mem_set_prod_eq,
mem_univ, and_true] using hp
have A : ContDiffOn 𝕜 n (isoF ∘ R ∘ (isoP.prodCongr isoG).symm) (s ×ˢ univ) := by
apply isoF.contDiff.comp_contDiffOn
apply R_contdiff.comp (ContinuousLinearEquiv.contDiff _).contDiffOn
rintro ⟨p, x⟩ ⟨hp, -⟩
simpa only [mem_preimage, mem_prod, mem_univ, and_true, ContinuousLinearEquiv.prodCongr_symm,
ContinuousLinearEquiv.prodCongr_apply, ContinuousLinearEquiv.apply_symm_apply] using hp
have : isoF ∘ R ∘ (isoP.prodCongr isoG).symm = fun q : P × G => (f ⋆[L, μ] g q.1) q.2 := by
apply funext
rintro ⟨p, x⟩
simp only [(· ∘ ·), ContinuousLinearEquiv.prodCongr_symm, ContinuousLinearEquiv.prodCongr_apply]
simp only [R, convolution]
rw [IsClosedEmbedding.integral_map, ← isoF.integral_comp_comm]
· rfl
· exact isoG.symm.toHomeomorph.isClosedEmbedding
simp_rw [this] at A
exact A
/-- The convolution `f * g` is `C^n` when `f` is locally integrable and `g` is `C^n` and compactly
supported. Version where `g` depends on an additional parameter in an open subset `s` of a
parameter space `P` (and the compact support `k` is independent of the parameter in `s`),
given in terms of composition with an additional `C^n` function. -/
theorem contDiffOn_convolution_right_with_param_comp {n : ℕ∞} (L : E →L[𝕜] E' →L[𝕜] F) {s : Set P}
{v : P → G} (hv : ContDiffOn 𝕜 n v s) {f : G → E} {g : P → G → E'} {k : Set G} (hs : IsOpen s)
(hk : IsCompact k) (hgs : ∀ p, ∀ x, p ∈ s → x ∉ k → g p x = 0) (hf : LocallyIntegrable f μ)
(hg : ContDiffOn 𝕜 n ↿g (s ×ˢ univ)) : ContDiffOn 𝕜 n (fun x => (f ⋆[L, μ] g x) (v x)) s := by
apply (contDiffOn_convolution_right_with_param L hs hk hgs hf hg).comp (contDiffOn_id.prodMk hv)
intro x hx
simp only [hx, prodMk_mem_set_prod_eq, mem_univ, and_self_iff, _root_.id]
/-- The convolution `g * f` is `C^n` when `f` is locally integrable and `g` is `C^n` and compactly
supported. Version where `g` depends on an additional parameter in an open subset `s` of a
parameter space `P` (and the compact support `k` is independent of the parameter in `s`). -/
theorem contDiffOn_convolution_left_with_param [μ.IsAddLeftInvariant] [μ.IsNegInvariant]
(L : E' →L[𝕜] E →L[𝕜] F) {f : G → E} {n : ℕ∞} {g : P → G → E'} {s : Set P} {k : Set G}
(hs : IsOpen s) (hk : IsCompact k) (hgs : ∀ p, ∀ x, p ∈ s → x ∉ k → g p x = 0)
(hf : LocallyIntegrable f μ) (hg : ContDiffOn 𝕜 n ↿g (s ×ˢ univ)) :
ContDiffOn 𝕜 n (fun q : P × G => (g q.1 ⋆[L, μ] f) q.2) (s ×ˢ univ) := by
simpa only [convolution_flip] using contDiffOn_convolution_right_with_param L.flip hs hk hgs hf hg
/-- The convolution `g * f` is `C^n` when `f` is locally integrable and `g` is `C^n` and compactly
supported. Version where `g` depends on an additional parameter in an open subset `s` of a
parameter space `P` (and the compact support `k` is independent of the parameter in `s`),
given in terms of composition with additional `C^n` functions. -/
theorem contDiffOn_convolution_left_with_param_comp [μ.IsAddLeftInvariant] [μ.IsNegInvariant]
(L : E' →L[𝕜] E →L[𝕜] F) {s : Set P} {n : ℕ∞} {v : P → G} (hv : ContDiffOn 𝕜 n v s) {f : G → E}
{g : P → G → E'} {k : Set G} (hs : IsOpen s) (hk : IsCompact k)
(hgs : ∀ p, ∀ x, p ∈ s → x ∉ k → g p x = 0) (hf : LocallyIntegrable f μ)
(hg : ContDiffOn 𝕜 n ↿g (s ×ˢ univ)) : ContDiffOn 𝕜 n (fun x => (g x ⋆[L, μ] f) (v x)) s := by
apply (contDiffOn_convolution_left_with_param L hs hk hgs hf hg).comp (contDiffOn_id.prodMk hv)
intro x hx
simp only [hx, prodMk_mem_set_prod_eq, mem_univ, and_self_iff, _root_.id]
theorem _root_.HasCompactSupport.contDiff_convolution_right {n : ℕ∞} (hcg : HasCompactSupport g)
(hf : LocallyIntegrable f μ) (hg : ContDiff 𝕜 n g) : ContDiff 𝕜 n (f ⋆[L, μ] g) := by
rcases exists_compact_iff_hasCompactSupport.2 hcg with ⟨k, hk, h'k⟩
rw [← contDiffOn_univ]
exact contDiffOn_convolution_right_with_param_comp L contDiffOn_id isOpen_univ hk
(fun p x _ hx => h'k x hx) hf (hg.comp contDiff_snd).contDiffOn
theorem _root_.HasCompactSupport.contDiff_convolution_left [μ.IsAddLeftInvariant] [μ.IsNegInvariant]
{n : ℕ∞} (hcf : HasCompactSupport f) (hf : ContDiff 𝕜 n f) (hg : LocallyIntegrable g μ) :
ContDiff 𝕜 n (f ⋆[L, μ] g) := by
rw [← convolution_flip]
exact hcf.contDiff_convolution_right L.flip hg hf
end WithParam
section Nonneg
variable [NormedSpace ℝ E] [NormedSpace ℝ E'] [NormedSpace ℝ F]
/-- The forward convolution of two functions `f` and `g` on `ℝ`, with respect to a continuous
bilinear map `L` and measure `ν`. It is defined to be the function mapping `x` to
`∫ t in 0..x, L (f t) (g (x - t)) ∂ν` if `0 < x`, and 0 otherwise. -/
noncomputable def posConvolution (f : ℝ → E) (g : ℝ → E') (L : E →L[ℝ] E' →L[ℝ] F)
(ν : Measure ℝ := by volume_tac) : ℝ → F :=
indicator (Ioi (0 : ℝ)) fun x => ∫ t in 0..x, L (f t) (g (x - t)) ∂ν
theorem posConvolution_eq_convolution_indicator (f : ℝ → E) (g : ℝ → E') (L : E →L[ℝ] E' →L[ℝ] F)
(ν : Measure ℝ := by volume_tac) [NoAtoms ν] :
posConvolution f g L ν = convolution (indicator (Ioi 0) f) (indicator (Ioi 0) g) L ν := by
ext1 x
rw [convolution, posConvolution, indicator]
split_ifs with h
· rw [intervalIntegral.integral_of_le (le_of_lt h), integral_Ioc_eq_integral_Ioo, ←
integral_indicator (measurableSet_Ioo : MeasurableSet (Ioo 0 x))]
congr 1 with t : 1
have : t ≤ 0 ∨ t ∈ Ioo 0 x ∨ x ≤ t := by
rcases le_or_gt t 0 with (h | h)
· exact Or.inl h
· rcases lt_or_ge t x with (h' | h')
exacts [Or.inr (Or.inl ⟨h, h'⟩), Or.inr (Or.inr h')]
rcases this with (ht | ht | ht)
· rw [indicator_of_notMem (notMem_Ioo_of_le ht), indicator_of_notMem (notMem_Ioi.mpr ht),
ContinuousLinearMap.map_zero, ContinuousLinearMap.zero_apply]
· rw [indicator_of_mem ht, indicator_of_mem (mem_Ioi.mpr ht.1),
indicator_of_mem (mem_Ioi.mpr <| sub_pos.mpr ht.2)]
· rw [indicator_of_notMem (notMem_Ioo_of_ge ht),
indicator_of_notMem (notMem_Ioi.mpr (sub_nonpos_of_le ht)),
ContinuousLinearMap.map_zero]
· convert (integral_zero ℝ F).symm with t
by_cases ht : 0 < t
· rw [indicator_of_notMem (_ : x - t ∉ Ioi 0), ContinuousLinearMap.map_zero]
rw [notMem_Ioi] at h ⊢
exact sub_nonpos.mpr (h.trans ht.le)
· rw [indicator_of_notMem (mem_Ioi.not.mpr ht), ContinuousLinearMap.map_zero,
ContinuousLinearMap.zero_apply]
theorem integrable_posConvolution {f : ℝ → E} {g : ℝ → E'} {μ ν : Measure ℝ} [SFinite μ]
[SFinite ν] [IsAddRightInvariant μ] [NoAtoms ν] (hf : IntegrableOn f (Ioi 0) ν)
(hg : IntegrableOn g (Ioi 0) μ) (L : E →L[ℝ] E' →L[ℝ] F) :
Integrable (posConvolution f g L ν) μ := by
rw [← integrable_indicator_iff (measurableSet_Ioi : MeasurableSet (Ioi (0 : ℝ)))] at hf hg
rw [posConvolution_eq_convolution_indicator f g L ν]
exact (hf.convolution_integrand L hg).integral_prod_left
/-- The integral over `Ioi 0` of a forward convolution of two functions is equal to the product
of their integrals over this set. (Compare `integral_convolution` for the two-sided convolution.) -/
theorem integral_posConvolution [CompleteSpace E] [CompleteSpace E'] [CompleteSpace F]
{μ ν : Measure ℝ}
[SFinite μ] [SFinite ν] [IsAddRightInvariant μ] [NoAtoms ν] {f : ℝ → E} {g : ℝ → E'}
(hf : IntegrableOn f (Ioi 0) ν) (hg : IntegrableOn g (Ioi 0) μ) (L : E →L[ℝ] E' →L[ℝ] F) :
∫ x : ℝ in Ioi 0, ∫ t : ℝ in 0..x, L (f t) (g (x - t)) ∂ν ∂μ =
L (∫ x : ℝ in Ioi 0, f x ∂ν) (∫ x : ℝ in Ioi 0, g x ∂μ) := by
rw [← integrable_indicator_iff measurableSet_Ioi] at hf hg
simp_rw [← integral_indicator measurableSet_Ioi]
convert integral_convolution L hf hg using 4 with x
apply posConvolution_eq_convolution_indicator
end Nonneg
end MeasureTheory |
.lake/packages/mathlib/Mathlib/Analysis/Matrix.lean | import Mathlib.Analysis.Matrix.Normed
deprecated_module (since := "2025-11-03") |
.lake/packages/mathlib/Mathlib/Analysis/Subadditive.lean | import Mathlib.Order.Filter.AtTopBot.Archimedean
import Mathlib.Order.Filter.AtTopBot.Finite
import Mathlib.Order.Filter.AtTopBot.Prod
import Mathlib.Topology.Algebra.Ring.Real
/-!
# Convergence of subadditive sequences
A subadditive sequence `u : ℕ → ℝ` is a sequence satisfying `u (m + n) ≤ u m + u n` for all `m, n`.
We define this notion as `Subadditive u`, and prove in `Subadditive.tendsto_lim` that, if `u n / n`
is bounded below, then it converges to a limit (that we denote by `Subadditive.lim` for
convenience). This result is known as Fekete's lemma in the literature.
## TODO
Define a bundled `SubadditiveHom`, use it.
-/
noncomputable section
open Set Filter Topology
/-- A real-valued sequence is subadditive if it satisfies the inequality `u (m + n) ≤ u m + u n`
for all `m, n`. -/
def Subadditive (u : ℕ → ℝ) : Prop :=
∀ m n, u (m + n) ≤ u m + u n
namespace Subadditive
variable {u : ℕ → ℝ} (h : Subadditive u)
/-- The limit of a bounded-below subadditive sequence. The fact that the sequence indeed tends to
this limit is given in `Subadditive.tendsto_lim` -/
@[nolint unusedArguments, irreducible]
protected def lim (_h : Subadditive u) :=
sInf ((fun n : ℕ => u n / n) '' Ici 1)
theorem lim_le_div (hbdd : BddBelow (range fun n => u n / n)) {n : ℕ} (hn : n ≠ 0) :
h.lim ≤ u n / n := by
rw [Subadditive.lim]
exact csInf_le (hbdd.mono <| image_subset_range _ _) ⟨n, hn.bot_lt, rfl⟩
include h in
theorem apply_mul_add_le (k n r) : u (k * n + r) ≤ k * u n + u r := by
induction k with
| zero => simp only [Nat.cast_zero, zero_mul, zero_add]; rfl
| succ k IH =>
calc
u ((k + 1) * n + r) = u (n + (k * n + r)) := by congr 1; ring
_ ≤ u n + u (k * n + r) := h _ _
_ ≤ u n + (k * u n + u r) := by grw [IH]
_ = (k + 1 : ℕ) * u n + u r := by simp; ring
include h in
theorem eventually_div_lt_of_div_lt {L : ℝ} {n : ℕ} (hn : n ≠ 0) (hL : u n / n < L) :
∀ᶠ p in atTop, u p / p < L := by
/- It suffices to prove the statement for each arithmetic progression `(n * · + r)`. -/
refine .atTop_of_arithmetic hn fun r _ => ?_
/- `(k * u n + u r) / (k * n + r)` tends to `u n / n < L`, hence
`(k * u n + u r) / (k * n + r) < L` for sufficiently large `k`. -/
have A : Tendsto (fun x : ℝ => (u n + u r / x) / (n + r / x)) atTop (𝓝 ((u n + 0) / (n + 0))) :=
(tendsto_const_nhds.add <| tendsto_const_nhds.div_atTop tendsto_id).div
(tendsto_const_nhds.add <| tendsto_const_nhds.div_atTop tendsto_id) <| by simpa
have B : Tendsto (fun x => (x * u n + u r) / (x * n + r)) atTop (𝓝 (u n / n)) := by
rw [add_zero, add_zero] at A
refine A.congr' <| (eventually_ne_atTop 0).mono fun x hx => ?_
simp only [add_div' _ _ _ hx, div_div_div_cancel_right₀ hx, mul_comm]
refine ((B.comp tendsto_natCast_atTop_atTop).eventually (gt_mem_nhds hL)).mono fun k hk => ?_
/- Finally, we use an upper estimate on `u (k * n + r)` to get an estimate on
`u (k * n + r) / (k * n + r)`. -/
rw [mul_comm]
refine lt_of_le_of_lt ?_ hk
simp only [(· ∘ ·), ← Nat.cast_add, ← Nat.cast_mul]
gcongr
apply h.apply_mul_add_le
/-- Fekete's lemma: a subadditive sequence which is bounded below converges. -/
theorem tendsto_lim (hbdd : BddBelow (range fun n => u n / n)) :
Tendsto (fun n => u n / n) atTop (𝓝 h.lim) := by
refine tendsto_order.2 ⟨fun l hl => ?_, fun L hL => ?_⟩
· refine eventually_atTop.2
⟨1, fun n hn => hl.trans_le (h.lim_le_div hbdd (zero_lt_one.trans_le hn).ne')⟩
· obtain ⟨n, npos, hn⟩ : ∃ n : ℕ, 0 < n ∧ u n / n < L := by
rw [Subadditive.lim] at hL
rcases exists_lt_of_csInf_lt (by simp) hL with ⟨x, hx, xL⟩
rcases (mem_image _ _ _).1 hx with ⟨n, hn, rfl⟩
exact ⟨n, zero_lt_one.trans_le hn, xL⟩
exact h.eventually_div_lt_of_div_lt npos.ne' hn
end Subadditive |
.lake/packages/mathlib/Mathlib/Analysis/MellinTransform.lean | import Mathlib.Analysis.SpecialFunctions.ImproperIntegrals
import Mathlib.Analysis.Calculus.ParametricIntegral
import Mathlib.MeasureTheory.Measure.Haar.NormedSpace
/-! # The Mellin transform
We define the Mellin transform of a locally integrable function on `Ioi 0`, and show it is
differentiable in a suitable vertical strip.
## Main statements
- `mellin` : the Mellin transform `∫ (t : ℝ) in Ioi 0, t ^ (s - 1) • f t`,
where `s` is a complex number.
- `HasMellin`: shorthand asserting that the Mellin transform exists and has a given value
(analogous to `HasSum`).
- `mellin_differentiableAt_of_isBigO_rpow` : if `f` is `O(x ^ (-a))` at infinity, and
`O(x ^ (-b))` at 0, then `mellin f` is holomorphic on the domain `b < re s < a`.
-/
open MeasureTheory Set Filter Asymptotics TopologicalSpace
open Real
open Complex hiding exp log
open scoped Topology
noncomputable section
section Defs
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℂ E]
/-- Predicate on `f` and `s` asserting that the Mellin integral is well-defined. -/
def MellinConvergent (f : ℝ → E) (s : ℂ) : Prop :=
IntegrableOn (fun t : ℝ => (t : ℂ) ^ (s - 1) • f t) (Ioi 0)
theorem MellinConvergent.const_smul {f : ℝ → E} {s : ℂ} (hf : MellinConvergent f s) {𝕜 : Type*}
[NormedAddCommGroup 𝕜] [SMulZeroClass 𝕜 E] [IsBoundedSMul 𝕜 E] [SMulCommClass ℂ 𝕜 E] (c : 𝕜) :
MellinConvergent (fun t => c • f t) s := by
simpa only [MellinConvergent, smul_comm] using hf.smul c
theorem MellinConvergent.cpow_smul {f : ℝ → E} {s a : ℂ} :
MellinConvergent (fun t => (t : ℂ) ^ a • f t) s ↔ MellinConvergent f (s + a) := by
refine integrableOn_congr_fun (fun t ht => ?_) measurableSet_Ioi
simp_rw [← sub_add_eq_add_sub, cpow_add _ _ (ofReal_ne_zero.2 <| ne_of_gt ht), mul_smul]
nonrec theorem MellinConvergent.div_const {f : ℝ → ℂ} {s : ℂ} (hf : MellinConvergent f s) (a : ℂ) :
MellinConvergent (fun t => f t / a) s := by
simpa only [MellinConvergent, smul_eq_mul, ← mul_div_assoc] using hf.div_const a
theorem MellinConvergent.comp_mul_left {f : ℝ → E} {s : ℂ} {a : ℝ} (ha : 0 < a) :
MellinConvergent (fun t => f (a * t)) s ↔ MellinConvergent f s := by
have := integrableOn_Ioi_comp_mul_left_iff (fun t : ℝ => (t : ℂ) ^ (s - 1) • f t) 0 ha
rw [mul_zero] at this
have h1 : EqOn (fun t : ℝ => (↑(a * t) : ℂ) ^ (s - 1) • f (a * t))
((a : ℂ) ^ (s - 1) • fun t : ℝ => (t : ℂ) ^ (s - 1) • f (a * t)) (Ioi 0) := fun t ht ↦ by
simp only [ofReal_mul, mul_cpow_ofReal_nonneg ha.le (le_of_lt ht), mul_smul, Pi.smul_apply]
have h2 : (a : ℂ) ^ (s - 1) ≠ 0 := by
rw [Ne, cpow_eq_zero_iff, not_and_or, ofReal_eq_zero]
exact Or.inl ha.ne'
rw [MellinConvergent, MellinConvergent, ← this, integrableOn_congr_fun h1 measurableSet_Ioi,
IntegrableOn, IntegrableOn, integrable_smul_iff h2]
theorem MellinConvergent.comp_rpow {f : ℝ → E} {s : ℂ} {a : ℝ} (ha : a ≠ 0) :
MellinConvergent (fun t => f (t ^ a)) s ↔ MellinConvergent f (s / a) := by
refine Iff.trans ?_ (integrableOn_Ioi_comp_rpow_iff' _ ha)
rw [MellinConvergent]
refine integrableOn_congr_fun (fun t ht => ?_) measurableSet_Ioi
dsimp only [Pi.smul_apply]
rw [← Complex.coe_smul (t ^ (a - 1)), ← mul_smul, ← cpow_mul_ofReal_nonneg (le_of_lt ht),
ofReal_cpow (le_of_lt ht), ← cpow_add _ _ (ofReal_ne_zero.mpr (ne_of_gt ht)), ofReal_sub,
ofReal_one, mul_sub, mul_div_cancel₀ _ (ofReal_ne_zero.mpr ha), mul_one, add_comm, ←
add_sub_assoc, sub_add_cancel]
/-- A function `f` is `VerticalIntegrable` at `σ` if `y ↦ f(σ + yi)` is integrable. -/
def Complex.VerticalIntegrable (f : ℂ → E) (σ : ℝ) (μ : Measure ℝ := by volume_tac) : Prop :=
Integrable (fun (y : ℝ) ↦ f (σ + y * I)) μ
/-- The Mellin transform of a function `f` (for a complex exponent `s`), defined as the integral of
`t ^ (s - 1) • f` over `Ioi 0`. -/
def mellin (f : ℝ → E) (s : ℂ) : E :=
∫ t : ℝ in Ioi 0, (t : ℂ) ^ (s - 1) • f t
/-- The Mellin inverse transform of a function `f`, defined as `1 / (2π)` times
the integral of `y ↦ x ^ -(σ + yi) • f (σ + yi)`. -/
def mellinInv (σ : ℝ) (f : ℂ → E) (x : ℝ) : E :=
(1 / (2 * π)) • ∫ y : ℝ, (x : ℂ) ^ (-(σ + y * I)) • f (σ + y * I)
-- next few lemmas don't require convergence of the Mellin transform (they are just 0 = 0 otherwise)
theorem mellin_cpow_smul (f : ℝ → E) (s a : ℂ) :
mellin (fun t => (t : ℂ) ^ a • f t) s = mellin f (s + a) := by
refine setIntegral_congr_fun measurableSet_Ioi fun t ht => ?_
simp_rw [← sub_add_eq_add_sub, cpow_add _ _ (ofReal_ne_zero.2 <| ne_of_gt ht), mul_smul]
/-- Compatibility with scalar multiplication by a normed field. For scalar multiplication by more
general rings assuming *a priori* that the Mellin transform is defined, see
`hasMellin_const_smul`. -/
theorem mellin_const_smul (f : ℝ → E) (s : ℂ) {𝕜 : Type*}
[NormedField 𝕜] [NormedSpace 𝕜 E] [SMulCommClass ℂ 𝕜 E] (c : 𝕜) :
mellin (fun t => c • f t) s = c • mellin f s := by
simp only [mellin, smul_comm, integral_smul]
theorem mellin_div_const (f : ℝ → ℂ) (s a : ℂ) : mellin (fun t => f t / a) s = mellin f s / a := by
simp_rw [mellin, smul_eq_mul, ← mul_div_assoc, integral_div]
theorem mellin_comp_rpow (f : ℝ → E) (s : ℂ) (a : ℝ) :
mellin (fun t => f (t ^ a)) s = |a|⁻¹ • mellin f (s / a) := by
/- This is true for `a = 0` as all sides are undefined but turn out to vanish thanks to our
convention. The interesting case is `a ≠ 0` -/
rcases eq_or_ne a 0 with rfl | ha
· by_cases hE : CompleteSpace E
· simp [integral_smul_const, mellin, setIntegral_Ioi_zero_cpow]
· simp [integral, mellin, hE]
simp_rw [mellin]
conv_rhs => rw [← integral_comp_rpow_Ioi _ ha, ← integral_smul]
refine setIntegral_congr_fun measurableSet_Ioi fun t ht => ?_
dsimp only
rw [← mul_smul, ← mul_assoc, inv_mul_cancel₀ (mt abs_eq_zero.1 ha), one_mul, ← smul_assoc,
real_smul]
rw [ofReal_cpow (le_of_lt ht), ← cpow_mul_ofReal_nonneg (le_of_lt ht), ←
cpow_add _ _ (ofReal_ne_zero.mpr <| ne_of_gt ht), ofReal_sub, ofReal_one, mul_sub,
mul_div_cancel₀ _ (ofReal_ne_zero.mpr ha), add_comm, ← add_sub_assoc, mul_one, sub_add_cancel]
theorem mellin_comp_mul_left (f : ℝ → E) (s : ℂ) {a : ℝ} (ha : 0 < a) :
mellin (fun t => f (a * t)) s = (a : ℂ) ^ (-s) • mellin f s := by
simp_rw [mellin]
have : EqOn (fun t : ℝ => (t : ℂ) ^ (s - 1) • f (a * t))
(fun t : ℝ => (a : ℂ) ^ (1 - s) • (fun u : ℝ => (u : ℂ) ^ (s - 1) • f u) (a * t))
(Ioi 0) := fun t ht ↦ by
dsimp only
rw [ofReal_mul, mul_cpow_ofReal_nonneg ha.le (le_of_lt ht), ← mul_smul,
(by ring : 1 - s = -(s - 1)), cpow_neg, inv_mul_cancel_left₀]
rw [Ne, cpow_eq_zero_iff, ofReal_eq_zero, not_and_or]
exact Or.inl ha.ne'
rw [setIntegral_congr_fun measurableSet_Ioi this, integral_smul,
integral_comp_mul_left_Ioi (fun u ↦ (u : ℂ) ^ (s - 1) • f u) _ ha,
mul_zero, ← Complex.coe_smul, ← mul_smul, sub_eq_add_neg,
cpow_add _ _ (ofReal_ne_zero.mpr ha.ne'), cpow_one, ofReal_inv,
mul_assoc, mul_comm, inv_mul_cancel_right₀ (ofReal_ne_zero.mpr ha.ne')]
theorem mellin_comp_mul_right (f : ℝ → E) (s : ℂ) {a : ℝ} (ha : 0 < a) :
mellin (fun t => f (t * a)) s = (a : ℂ) ^ (-s) • mellin f s := by
simpa only [mul_comm] using mellin_comp_mul_left f s ha
theorem mellin_comp_inv (f : ℝ → E) (s : ℂ) : mellin (fun t => f t⁻¹) s = mellin f (-s) := by
simp_rw [← rpow_neg_one, mellin_comp_rpow _ _ _, abs_neg, abs_one,
inv_one, one_smul, ofReal_neg, ofReal_one, div_neg, div_one]
/-- Predicate standing for "the Mellin transform of `f` is defined at `s` and equal to `m`". This
shortens some arguments. -/
def HasMellin (f : ℝ → E) (s : ℂ) (m : E) : Prop :=
MellinConvergent f s ∧ mellin f s = m
theorem hasMellin_add {f g : ℝ → E} {s : ℂ} (hf : MellinConvergent f s)
(hg : MellinConvergent g s) : HasMellin (fun t => f t + g t) s (mellin f s + mellin g s) :=
⟨by simpa only [MellinConvergent, smul_add] using hf.add hg, by
simpa only [mellin, smul_add] using integral_add hf hg⟩
theorem hasMellin_sub {f g : ℝ → E} {s : ℂ} (hf : MellinConvergent f s)
(hg : MellinConvergent g s) : HasMellin (fun t => f t - g t) s (mellin f s - mellin g s) :=
⟨by simpa only [MellinConvergent, smul_sub] using hf.sub hg, by
simpa only [mellin, smul_sub] using integral_sub hf hg⟩
theorem hasMellin_const_smul {f : ℝ → E} {s : ℂ} (hf : MellinConvergent f s)
{R : Type*} [NormedRing R] [Module R E] [IsBoundedSMul R E] [SMulCommClass ℂ R E] (c : R) :
HasMellin (fun t => c • f t) s (c • mellin f s) :=
⟨hf.const_smul c, by simp [mellin, smul_comm, hf.integral_smul]⟩
end Defs
variable {E : Type*} [NormedAddCommGroup E]
section MellinConvergent
/-! ## Convergence of Mellin transform integrals -/
/-- Auxiliary lemma to reduce convergence statements from vector-valued functions to real
scalar-valued functions. -/
theorem mellin_convergent_iff_norm [NormedSpace ℂ E] {f : ℝ → E} {T : Set ℝ} (hT : T ⊆ Ioi 0)
(hT' : MeasurableSet T) (hfc : AEStronglyMeasurable f <| volume.restrict <| Ioi 0) {s : ℂ} :
IntegrableOn (fun t : ℝ => (t : ℂ) ^ (s - 1) • f t) T ↔
IntegrableOn (fun t : ℝ => t ^ (s.re - 1) * ‖f t‖) T := by
have : AEStronglyMeasurable (fun t : ℝ => (t : ℂ) ^ (s - 1) • f t) (volume.restrict T) := by
refine ((continuousOn_of_forall_continuousAt ?_).aestronglyMeasurable hT').smul
(hfc.mono_set hT)
exact fun t ht => continuousAt_ofReal_cpow_const _ _ (Or.inr <| ne_of_gt (hT ht))
rw [IntegrableOn, ← integrable_norm_iff this, ← IntegrableOn]
refine integrableOn_congr_fun (fun t ht => ?_) hT'
simp_rw [norm_smul, norm_cpow_eq_rpow_re_of_pos (hT ht), sub_re, one_re]
/-- If `f` is a locally integrable real-valued function which is `O(x ^ (-a))` at `∞`, then for any
`s < a`, its Mellin transform converges on some neighbourhood of `+∞`. -/
theorem mellin_convergent_top_of_isBigO {f : ℝ → ℝ}
(hfc : AEStronglyMeasurable f <| volume.restrict (Ioi 0)) {a s : ℝ}
(hf : f =O[atTop] (· ^ (-a))) (hs : s < a) :
∃ c : ℝ, 0 < c ∧ IntegrableOn (fun t : ℝ => t ^ (s - 1) * f t) (Ioi c) := by
obtain ⟨d, hd'⟩ := hf.isBigOWith
simp_rw [IsBigOWith, eventually_atTop] at hd'
obtain ⟨e, he⟩ := hd'
have he' : 0 < max e 1 := zero_lt_one.trans_le (le_max_right _ _)
refine ⟨max e 1, he', ?_, ?_⟩
· refine AEStronglyMeasurable.mul ?_ (hfc.mono_set (Ioi_subset_Ioi he'.le))
refine (continuousOn_of_forall_continuousAt fun t ht => ?_).aestronglyMeasurable
measurableSet_Ioi
exact continuousAt_rpow_const _ _ (Or.inl <| (he'.trans ht).ne')
· have : ∀ᵐ t : ℝ ∂volume.restrict (Ioi <| max e 1),
‖t ^ (s - 1) * f t‖ ≤ t ^ (s - 1 + -a) * d := by
refine (ae_restrict_mem measurableSet_Ioi).mono fun t ht => ?_
have ht' : 0 < t := he'.trans ht
rw [norm_mul, rpow_add ht', ← norm_of_nonneg (rpow_nonneg ht'.le (-a)), mul_assoc,
mul_comm _ d, norm_of_nonneg (rpow_nonneg ht'.le _)]
gcongr
exact he t ((le_max_left e 1).trans_lt ht).le
refine (HasFiniteIntegral.mul_const ?_ _).mono' this
exact (integrableOn_Ioi_rpow_of_lt (by linarith) he').hasFiniteIntegral
/-- If `f` is a locally integrable real-valued function which is `O(x ^ (-b))` at `0`, then for any
`b < s`, its Mellin transform converges on some right neighbourhood of `0`. -/
theorem mellin_convergent_zero_of_isBigO {b : ℝ} {f : ℝ → ℝ}
(hfc : AEStronglyMeasurable f <| volume.restrict (Ioi 0))
(hf : f =O[𝓝[>] 0] (· ^ (-b))) {s : ℝ} (hs : b < s) :
∃ c : ℝ, 0 < c ∧ IntegrableOn (fun t : ℝ => t ^ (s - 1) * f t) (Ioc 0 c) := by
obtain ⟨d, _, hd'⟩ := hf.exists_pos
simp_rw [IsBigOWith, eventually_nhdsWithin_iff, Metric.eventually_nhds_iff, gt_iff_lt] at hd'
obtain ⟨ε, hε, hε'⟩ := hd'
refine ⟨ε, hε, Iff.mpr integrableOn_Ioc_iff_integrableOn_Ioo ⟨?_, ?_⟩⟩
· refine AEStronglyMeasurable.mul ?_ (hfc.mono_set Ioo_subset_Ioi_self)
refine (continuousOn_of_forall_continuousAt fun t ht => ?_).aestronglyMeasurable
measurableSet_Ioo
exact continuousAt_rpow_const _ _ (Or.inl ht.1.ne')
· apply HasFiniteIntegral.mono'
· change HasFiniteIntegral (fun t => d * t ^ (s - b - 1)) _
refine (Integrable.hasFiniteIntegral ?_).const_mul _
rw [← IntegrableOn, ← integrableOn_Ioc_iff_integrableOn_Ioo, ←
intervalIntegrable_iff_integrableOn_Ioc_of_le hε.le]
exact intervalIntegral.intervalIntegrable_rpow' (by linarith)
· refine (ae_restrict_iff' measurableSet_Ioo).mpr (Eventually.of_forall fun t ht => ?_)
rw [mul_comm, norm_mul]
specialize hε' _ ht.1
· rw [dist_eq_norm, sub_zero, norm_of_nonneg (le_of_lt ht.1)]
exact ht.2
· calc _ ≤ d * ‖t ^ (-b)‖ * ‖t ^ (s - 1)‖ := by gcongr
_ = d * t ^ (s - b - 1) := ?_
simp_rw [norm_of_nonneg (rpow_nonneg (le_of_lt ht.1) _), mul_assoc]
rw [← rpow_add ht.1]
congr 2
abel
/-- If `f` is a locally integrable real-valued function on `Ioi 0` which is `O(x ^ (-a))` at `∞`
and `O(x ^ (-b))` at `0`, then its Mellin transform integral converges for `b < s < a`. -/
theorem mellin_convergent_of_isBigO_scalar {a b : ℝ} {f : ℝ → ℝ} {s : ℝ}
(hfc : LocallyIntegrableOn f <| Ioi 0) (hf_top : f =O[atTop] (· ^ (-a)))
(hs_top : s < a) (hf_bot : f =O[𝓝[>] 0] (· ^ (-b))) (hs_bot : b < s) :
IntegrableOn (fun t : ℝ => t ^ (s - 1) * f t) (Ioi 0) := by
obtain ⟨c1, hc1, hc1'⟩ := mellin_convergent_top_of_isBigO hfc.aestronglyMeasurable hf_top hs_top
obtain ⟨c2, hc2, hc2'⟩ :=
mellin_convergent_zero_of_isBigO hfc.aestronglyMeasurable hf_bot hs_bot
have : Ioi 0 = Ioc 0 c2 ∪ Ioc c2 c1 ∪ Ioi c1 := by
rw [union_assoc, Ioc_union_Ioi (le_max_right _ _),
Ioc_union_Ioi ((min_le_left _ _).trans (le_max_right _ _)), min_eq_left (lt_min hc2 hc1).le]
rw [this, integrableOn_union, integrableOn_union]
refine ⟨⟨hc2', Iff.mp integrableOn_Icc_iff_integrableOn_Ioc ?_⟩, hc1'⟩
refine
(hfc.continuousOn_mul ?_ isOpen_Ioi.isLocallyClosed).integrableOn_compact_subset
(fun t ht => (hc2.trans_le ht.1 : 0 < t)) isCompact_Icc
exact continuousOn_of_forall_continuousAt
fun t ht ↦ continuousAt_rpow_const _ _ <| Or.inl <| ne_of_gt ht
theorem mellinConvergent_of_isBigO_rpow [NormedSpace ℂ E] {a b : ℝ} {f : ℝ → E} {s : ℂ}
(hfc : LocallyIntegrableOn f <| Ioi 0) (hf_top : f =O[atTop] (· ^ (-a)))
(hs_top : s.re < a) (hf_bot : f =O[𝓝[>] 0] (· ^ (-b))) (hs_bot : b < s.re) :
MellinConvergent f s := by
rw [MellinConvergent,
mellin_convergent_iff_norm Subset.rfl measurableSet_Ioi hfc.aestronglyMeasurable]
exact mellin_convergent_of_isBigO_scalar hfc.norm hf_top.norm_left hs_top hf_bot.norm_left hs_bot
end MellinConvergent
section MellinDiff
/-- If `f` is `O(x ^ (-a))` as `x → +∞`, then `log • f` is `O(x ^ (-b))` for every `b < a`. -/
theorem isBigO_rpow_top_log_smul [NormedSpace ℝ E] {a b : ℝ} {f : ℝ → E} (hab : b < a)
(hf : f =O[atTop] (· ^ (-a))) :
(fun t : ℝ => log t • f t) =O[atTop] (· ^ (-b)) := by
refine
((isLittleO_log_rpow_atTop (sub_pos.mpr hab)).isBigO.smul hf).congr'
(Eventually.of_forall fun t => by rfl)
((eventually_gt_atTop 0).mp (Eventually.of_forall fun t ht => ?_))
simp only
rw [smul_eq_mul, ← rpow_add ht, ← sub_eq_add_neg, sub_eq_add_neg a, add_sub_cancel_left]
/-- If `f` is `O(x ^ (-a))` as `x → 0`, then `log • f` is `O(x ^ (-b))` for every `a < b`. -/
theorem isBigO_rpow_zero_log_smul [NormedSpace ℝ E] {a b : ℝ} {f : ℝ → E} (hab : a < b)
(hf : f =O[𝓝[>] 0] (· ^ (-a))) :
(fun t : ℝ => log t • f t) =O[𝓝[>] 0] (· ^ (-b)) := by
have : log =o[𝓝[>] 0] fun t : ℝ => t ^ (a - b) := by
refine ((isLittleO_log_rpow_atTop (sub_pos.mpr hab)).neg_left.comp_tendsto
tendsto_inv_nhdsGT_zero).congr'
(.of_forall fun t => ?_)
(eventually_mem_nhdsWithin.mono fun t ht => ?_)
· simp
· simp_rw [Function.comp_apply, inv_rpow (le_of_lt ht), ← rpow_neg (le_of_lt ht), neg_sub]
refine (this.isBigO.smul hf).congr' (Eventually.of_forall fun t => by rfl)
(eventually_nhdsWithin_iff.mpr (Eventually.of_forall fun t ht => ?_))
simp_rw [smul_eq_mul, ← rpow_add ht]
congr 1
abel
/-- Suppose `f` is locally integrable on `(0, ∞)`, is `O(x ^ (-a))` as `x → ∞`, and is
`O(x ^ (-b))` as `x → 0`. Then its Mellin transform is differentiable on the domain `b < re s < a`,
with derivative equal to the Mellin transform of `log • f`. -/
theorem mellin_hasDerivAt_of_isBigO_rpow [NormedSpace ℂ E] {a b : ℝ}
{f : ℝ → E} {s : ℂ} (hfc : LocallyIntegrableOn f (Ioi 0)) (hf_top : f =O[atTop] (· ^ (-a)))
(hs_top : s.re < a) (hf_bot : f =O[𝓝[>] 0] (· ^ (-b))) (hs_bot : b < s.re) :
MellinConvergent (fun t => log t • f t) s ∧
HasDerivAt (mellin f) (mellin (fun t => log t • f t) s) s := by
set F : ℂ → ℝ → E := fun (z : ℂ) (t : ℝ) => (t : ℂ) ^ (z - 1) • f t
set F' : ℂ → ℝ → E := fun (z : ℂ) (t : ℝ) => ((t : ℂ) ^ (z - 1) * log t) • f t
-- A convenient radius of ball within which we can uniformly bound the derivative.
obtain ⟨v, hv0, hv1, hv2⟩ : ∃ v : ℝ, 0 < v ∧ v < s.re - b ∧ v < a - s.re := by
obtain ⟨w, hw1, hw2⟩ := exists_between (sub_pos.mpr hs_top)
obtain ⟨w', hw1', hw2'⟩ := exists_between (sub_pos.mpr hs_bot)
exact
⟨min w w', lt_min hw1 hw1', (min_le_right _ _).trans_lt hw2', (min_le_left _ _).trans_lt hw2⟩
let bound : ℝ → ℝ := fun t : ℝ => (t ^ (s.re + v - 1) + t ^ (s.re - v - 1)) * |log t| * ‖f t‖
have h1 : ∀ᶠ z : ℂ in 𝓝 s, AEStronglyMeasurable (F z) (volume.restrict <| Ioi 0) := by
refine Eventually.of_forall fun z => AEStronglyMeasurable.smul ?_ hfc.aestronglyMeasurable
refine ContinuousOn.aestronglyMeasurable ?_ measurableSet_Ioi
refine continuousOn_of_forall_continuousAt fun t ht => ?_
exact continuousAt_ofReal_cpow_const _ _ (Or.inr <| ne_of_gt ht)
have h2 : IntegrableOn (F s) (Ioi (0 : ℝ)) := by
exact mellinConvergent_of_isBigO_rpow hfc hf_top hs_top hf_bot hs_bot
have h3 : AEStronglyMeasurable (F' s) (volume.restrict <| Ioi 0) := by
apply LocallyIntegrableOn.aestronglyMeasurable
refine hfc.continuousOn_smul isOpen_Ioi.isLocallyClosed
((continuousOn_of_forall_continuousAt fun t ht => ?_).mul ?_)
· exact continuousAt_ofReal_cpow_const _ _ (Or.inr <| ne_of_gt ht)
· refine continuous_ofReal.comp_continuousOn ?_
exact continuousOn_log.mono (subset_compl_singleton_iff.mpr notMem_Ioi_self)
have h4 : ∀ᵐ t : ℝ ∂volume.restrict (Ioi 0),
∀ z : ℂ, z ∈ Metric.ball s v → ‖F' z t‖ ≤ bound t := by
refine (ae_restrict_mem measurableSet_Ioi).mono fun t ht z hz => ?_
simp_rw [F', bound, norm_smul, norm_mul, norm_real, mul_assoc, norm_eq_abs]
gcongr
rw [norm_cpow_eq_rpow_re_of_pos ht]
rcases le_or_gt 1 t with h | h
· refine le_add_of_le_of_nonneg (rpow_le_rpow_of_exponent_le h ?_)
(rpow_nonneg (zero_le_one.trans h) _)
rw [sub_re, one_re, sub_le_sub_iff_right]
rw [mem_ball_iff_norm] at hz
have hz' := (re_le_norm _).trans hz.le
rwa [sub_re, sub_le_iff_le_add'] at hz'
· refine
le_add_of_nonneg_of_le (rpow_pos_of_pos ht _).le (rpow_le_rpow_of_exponent_ge ht h.le ?_)
rw [sub_re, one_re, sub_le_iff_le_add, sub_add_cancel]
rw [mem_ball_iff_norm'] at hz
have hz' := (re_le_norm _).trans hz.le
rwa [sub_re, sub_le_iff_le_add, ← sub_le_iff_le_add'] at hz'
have h5 : IntegrableOn bound (Ioi 0) := by
simp_rw [bound, add_mul, mul_assoc]
suffices ∀ {j : ℝ}, b < j → j < a →
IntegrableOn (fun t : ℝ => t ^ (j - 1) * (|log t| * ‖f t‖)) (Ioi 0) volume by
refine Integrable.add (this ?_ ?_) (this ?_ ?_)
all_goals linarith
· intro j hj hj'
obtain ⟨w, hw1, hw2⟩ := exists_between hj
obtain ⟨w', hw1', hw2'⟩ := exists_between hj'
refine mellin_convergent_of_isBigO_scalar ?_ ?_ hw1' ?_ hw2
· simp_rw [mul_comm]
refine hfc.norm.mul_continuousOn ?_ isOpen_Ioi.isLocallyClosed
refine Continuous.comp_continuousOn _root_.continuous_abs (continuousOn_log.mono ?_)
exact subset_compl_singleton_iff.mpr notMem_Ioi_self
· refine (isBigO_rpow_top_log_smul hw2' hf_top).norm_left.congr_left fun t ↦ ?_
simp only [norm_smul, Real.norm_eq_abs]
· refine (isBigO_rpow_zero_log_smul hw1 hf_bot).norm_left.congr_left fun t ↦ ?_
simp only [norm_smul, Real.norm_eq_abs]
have h6 : ∀ᵐ t : ℝ ∂volume.restrict (Ioi 0),
∀ y : ℂ, y ∈ Metric.ball s v → HasDerivAt (fun z : ℂ => F z t) (F' y t) y := by
refine (ae_restrict_mem measurableSet_Ioi).mono fun t ht y _ => ?_
have ht' : (t : ℂ) ≠ 0 := ofReal_ne_zero.mpr (ne_of_gt ht)
have u1 : HasDerivAt (fun z : ℂ => (t : ℂ) ^ (z - 1)) (t ^ (y - 1) * log t) y := by
convert ((hasDerivAt_id' y).sub_const 1).const_cpow (Or.inl ht') using 1
rw [ofReal_log (le_of_lt ht)]
ring
exact u1.smul_const (f t)
have main := hasDerivAt_integral_of_dominated_loc_of_deriv_le hv0 h1 h2 h3 h4 h5 h6
simpa only [F', mul_smul] using main
/-- Suppose `f` is locally integrable on `(0, ∞)`, is `O(x ^ (-a))` as `x → ∞`, and is
`O(x ^ (-b))` as `x → 0`. Then its Mellin transform is differentiable on the domain `b < re s < a`.
-/
theorem mellin_differentiableAt_of_isBigO_rpow [NormedSpace ℂ E] {a b : ℝ}
{f : ℝ → E} {s : ℂ} (hfc : LocallyIntegrableOn f <| Ioi 0)
(hf_top : f =O[atTop] (· ^ (-a))) (hs_top : s.re < a)
(hf_bot : f =O[𝓝[>] 0] (· ^ (-b))) (hs_bot : b < s.re) :
DifferentiableAt ℂ (mellin f) s :=
(mellin_hasDerivAt_of_isBigO_rpow hfc hf_top hs_top hf_bot hs_bot).2.differentiableAt
end MellinDiff
section ExpDecay
/-- If `f` is locally integrable, decays exponentially at infinity, and is `O(x ^ (-b))` at 0, then
its Mellin transform converges for `b < s.re`. -/
theorem mellinConvergent_of_isBigO_rpow_exp [NormedSpace ℂ E] {a b : ℝ} (ha : 0 < a) {f : ℝ → E}
{s : ℂ} (hfc : LocallyIntegrableOn f <| Ioi 0) (hf_top : f =O[atTop] fun t => exp (-a * t))
(hf_bot : f =O[𝓝[>] 0] (· ^ (-b))) (hs_bot : b < s.re) : MellinConvergent f s :=
mellinConvergent_of_isBigO_rpow hfc (hf_top.trans (isLittleO_exp_neg_mul_rpow_atTop ha _).isBigO)
(lt_add_one _) hf_bot hs_bot
/-- If `f` is locally integrable, decays exponentially at infinity, and is `O(x ^ (-b))` at 0, then
its Mellin transform is holomorphic on `b < s.re`. -/
theorem mellin_differentiableAt_of_isBigO_rpow_exp [NormedSpace ℂ E] {a b : ℝ}
(ha : 0 < a) {f : ℝ → E} {s : ℂ} (hfc : LocallyIntegrableOn f <| Ioi 0)
(hf_top : f =O[atTop] fun t => exp (-a * t)) (hf_bot : f =O[𝓝[>] 0] (· ^ (-b)))
(hs_bot : b < s.re) : DifferentiableAt ℂ (mellin f) s :=
mellin_differentiableAt_of_isBigO_rpow hfc
(hf_top.trans (isLittleO_exp_neg_mul_rpow_atTop ha _).isBigO) (lt_add_one _) hf_bot hs_bot
end ExpDecay
section MellinIoc
/-!
## Mellin transforms of functions on `Ioc 0 1`
-/
/-- The Mellin transform of the indicator function of `Ioc 0 1`. -/
theorem hasMellin_one_Ioc {s : ℂ} (hs : 0 < re s) :
HasMellin (indicator (Ioc 0 1) (fun _ => 1 : ℝ → ℂ)) s (1 / s) := by
have aux1 : -1 < (s - 1).re := by
simpa only [sub_re, one_re, sub_eq_add_neg] using lt_add_of_pos_left _ hs
have aux2 : s ≠ 0 := by contrapose! hs; rw [hs, zero_re]
have aux3 : MeasurableSet (Ioc (0 : ℝ) 1) := measurableSet_Ioc
simp_rw [HasMellin, mellin, MellinConvergent, ← indicator_smul, IntegrableOn,
integrable_indicator_iff aux3, smul_eq_mul, integral_indicator aux3, mul_one, IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self]
rw [← IntegrableOn, ← intervalIntegrable_iff_integrableOn_Ioc_of_le zero_le_one]
refine ⟨intervalIntegral.intervalIntegrable_cpow' aux1, ?_⟩
rw [← intervalIntegral.integral_of_le zero_le_one, integral_cpow (Or.inl aux1), sub_add_cancel,
ofReal_zero, ofReal_one, one_cpow, zero_cpow aux2, sub_zero]
/-- The Mellin transform of a power function restricted to `Ioc 0 1`. -/
theorem hasMellin_cpow_Ioc (a : ℂ) {s : ℂ} (hs : 0 < re s + re a) :
HasMellin (indicator (Ioc 0 1) (fun t => ↑t ^ a : ℝ → ℂ)) s (1 / (s + a)) := by
have := hasMellin_one_Ioc (by rwa [add_re] : 0 < (s + a).re)
simp_rw [HasMellin, ← MellinConvergent.cpow_smul, ← mellin_cpow_smul, ← indicator_smul,
smul_eq_mul, mul_one] at this
exact this
end MellinIoc |
.lake/packages/mathlib/Mathlib/Analysis/PSeries.lean | import Mathlib.Analysis.SpecialFunctions.Pow.NNReal
import Mathlib.Analysis.SpecialFunctions.Pow.Continuity
import Mathlib.Analysis.SumOverResidueClass
/-!
# Convergence of `p`-series
In this file we prove that the series `∑' k in ℕ, 1 / k ^ p` converges if and only if `p > 1`.
The proof is based on the
[Cauchy condensation test](https://en.wikipedia.org/wiki/Cauchy_condensation_test): `∑ k, f k`
converges if and only if so does `∑ k, 2 ^ k f (2 ^ k)`. We prove this test in
`NNReal.summable_condensed_iff` and `summable_condensed_iff_of_nonneg`, then use it to prove
`summable_one_div_rpow`. After this transformation, a `p`-series turns into a geometric series.
## Tags
p-series, Cauchy condensation test
-/
/-!
### Schlömilch's generalization of the Cauchy condensation test
In this section we prove the Schlömilch's generalization of the Cauchy condensation test:
for a strictly increasing `u : ℕ → ℕ` with ratio of successive differences bounded and an
antitone `f : ℕ → ℝ≥0` or `f : ℕ → ℝ`, `∑ k, f k` converges if and only if
so does `∑ k, (u (k + 1) - u k) * f (u k)`. Instead of giving a monolithic proof, we split it
into a series of lemmas with explicit estimates of partial sums of each series in terms of the
partial sums of the other series.
-/
/--
A sequence `u` has the property that its ratio of successive differences is bounded
when there is a positive real number `C` such that, for all n ∈ ℕ,
(u (n + 2) - u (n + 1)) ≤ C * (u (n + 1) - u n)
-/
def SuccDiffBounded (C : ℕ) (u : ℕ → ℕ) : Prop :=
∀ n : ℕ, u (n + 2) - u (n + 1) ≤ C • (u (n + 1) - u n)
namespace Finset
variable {M : Type*} [AddCommMonoid M] [PartialOrder M] [IsOrderedAddMonoid M]
{f : ℕ → M} {u : ℕ → ℕ}
theorem le_sum_schlomilch' (hf : ∀ ⦃m n⦄, 0 < m → m ≤ n → f n ≤ f m) (h_pos : ∀ n, 0 < u n)
(hu : Monotone u) (n : ℕ) :
(∑ k ∈ Ico (u 0) (u n), f k) ≤ ∑ k ∈ range n, (u (k + 1) - u k) • f (u k) := by
induction n with
| zero => simp
| succ n ihn =>
suffices (∑ k ∈ Ico (u n) (u (n + 1)), f k) ≤ (u (n + 1) - u n) • f (u n) by
rw [sum_range_succ, ← sum_Ico_consecutive]
· exact add_le_add ihn this
exacts [hu n.zero_le, hu n.le_succ]
have : ∀ k ∈ Ico (u n) (u (n + 1)), f k ≤ f (u n) := fun k hk =>
hf (Nat.succ_le_of_lt (h_pos n)) (mem_Ico.mp hk).1
convert sum_le_sum this
simp
theorem le_sum_condensed' (hf : ∀ ⦃m n⦄, 0 < m → m ≤ n → f n ≤ f m) (n : ℕ) :
(∑ k ∈ Ico 1 (2 ^ n), f k) ≤ ∑ k ∈ range n, 2 ^ k • f (2 ^ k) := by
convert le_sum_schlomilch' hf (fun n => pow_pos zero_lt_two n)
(fun m n hm => pow_right_mono₀ one_le_two hm) n using 2
simp [pow_succ, mul_two]
theorem le_sum_schlomilch (hf : ∀ ⦃m n⦄, 0 < m → m ≤ n → f n ≤ f m) (h_pos : ∀ n, 0 < u n)
(hu : Monotone u) (n : ℕ) :
(∑ k ∈ range (u n), f k) ≤
∑ k ∈ range (u 0), f k + ∑ k ∈ range n, (u (k + 1) - u k) • f (u k) := by
grw [← le_sum_schlomilch' hf h_pos hu n, ← sum_range_add_sum_Ico _ (hu n.zero_le)]
theorem le_sum_condensed (hf : ∀ ⦃m n⦄, 0 < m → m ≤ n → f n ≤ f m) (n : ℕ) :
(∑ k ∈ range (2 ^ n), f k) ≤ f 0 + ∑ k ∈ range n, 2 ^ k • f (2 ^ k) := by
grw [← le_sum_condensed' hf n, ← sum_range_add_sum_Ico _ n.one_le_two_pow, sum_range_succ,
sum_range_zero, zero_add]
theorem sum_schlomilch_le' (hf : ∀ ⦃m n⦄, 1 < m → m ≤ n → f n ≤ f m) (h_pos : ∀ n, 0 < u n)
(hu : Monotone u) (n : ℕ) :
(∑ k ∈ range n, (u (k + 1) - u k) • f (u (k + 1))) ≤ ∑ k ∈ Ico (u 0 + 1) (u n + 1), f k := by
induction n with
| zero => simp
| succ n ihn =>
suffices (u (n + 1) - u n) • f (u (n + 1)) ≤ ∑ k ∈ Ico (u n + 1) (u (n + 1) + 1), f k by
rw [sum_range_succ, ← sum_Ico_consecutive]
exacts [add_le_add ihn this,
(add_le_add_right (hu n.zero_le) _ : u 0 + 1 ≤ u n + 1),
add_le_add_right (hu n.le_succ) _]
have : ∀ k ∈ Ico (u n + 1) (u (n + 1) + 1), f (u (n + 1)) ≤ f k := fun k hk =>
hf (Nat.lt_of_le_of_lt (Nat.succ_le_of_lt (h_pos n)) <| (Nat.lt_succ_of_le le_rfl).trans_le
(mem_Ico.mp hk).1) (Nat.le_of_lt_succ <| (mem_Ico.mp hk).2)
convert sum_le_sum this
simp
theorem sum_condensed_le' (hf : ∀ ⦃m n⦄, 1 < m → m ≤ n → f n ≤ f m) (n : ℕ) :
(∑ k ∈ range n, 2 ^ k • f (2 ^ (k + 1))) ≤ ∑ k ∈ Ico 2 (2 ^ n + 1), f k := by
convert sum_schlomilch_le' hf (fun n => pow_pos zero_lt_two n)
(fun m n hm => pow_right_mono₀ one_le_two hm) n using 2
simp [pow_succ, mul_two]
theorem sum_schlomilch_le {C : ℕ} (hf : ∀ ⦃m n⦄, 1 < m → m ≤ n → f n ≤ f m) (h_pos : ∀ n, 0 < u n)
(h_nonneg : ∀ n, 0 ≤ f n) (hu : Monotone u) (h_succ_diff : SuccDiffBounded C u) (n : ℕ) :
∑ k ∈ range (n + 1), (u (k + 1) - u k) • f (u k) ≤
(u 1 - u 0) • f (u 0) + C • ∑ k ∈ Ico (u 0 + 1) (u n + 1), f k := by
rw [sum_range_succ', add_comm]
gcongr
suffices ∑ k ∈ range n, (u (k + 2) - u (k + 1)) • f (u (k + 1)) ≤
C • ∑ k ∈ range n, ((u (k + 1) - u k) • f (u (k + 1))) by
refine this.trans (nsmul_le_nsmul_right ?_ _)
exact sum_schlomilch_le' hf h_pos hu n
have : ∀ k ∈ range n, (u (k + 2) - u (k + 1)) • f (u (k + 1)) ≤
C • ((u (k + 1) - u k) • f (u (k + 1))) := by
intro k _
rw [smul_smul]
gcongr
· exact h_nonneg (u (k + 1))
exact mod_cast h_succ_diff k
convert sum_le_sum this
simp [smul_sum]
theorem sum_condensed_le (hf : ∀ ⦃m n⦄, 1 < m → m ≤ n → f n ≤ f m) (n : ℕ) :
(∑ k ∈ range (n + 1), 2 ^ k • f (2 ^ k)) ≤ f 1 + 2 • ∑ k ∈ Ico 2 (2 ^ n + 1), f k := by
grw [← sum_condensed_le' hf n]
simp [sum_range_succ', add_comm, pow_succ', mul_nsmul', sum_nsmul]
end Finset
namespace ENNReal
open Filter Finset
variable {u : ℕ → ℕ} {f : ℕ → ℝ≥0∞}
open NNReal in
theorem le_tsum_schlomilch (hf : ∀ ⦃m n⦄, 0 < m → m ≤ n → f n ≤ f m) (h_pos : ∀ n, 0 < u n)
(hu : StrictMono u) :
∑' k, f k ≤ ∑ k ∈ range (u 0), f k + ∑' k : ℕ, (u (k + 1) - u k) * f (u k) := by
rw [ENNReal.tsum_eq_iSup_nat' hu.tendsto_atTop]
refine iSup_le fun n => ?_
grw [Finset.le_sum_schlomilch hf h_pos hu.monotone n]
gcongr
have (k : ℕ) : (u (k + 1) - u k : ℝ≥0∞) = (u (k + 1) - (u k : ℕ) : ℕ) := by simp
simp only [nsmul_eq_mul, this]
apply ENNReal.sum_le_tsum
theorem le_tsum_condensed (hf : ∀ ⦃m n⦄, 0 < m → m ≤ n → f n ≤ f m) :
∑' k, f k ≤ f 0 + ∑' k : ℕ, 2 ^ k * f (2 ^ k) := by
rw [ENNReal.tsum_eq_iSup_nat' (tendsto_pow_atTop_atTop_of_one_lt _root_.one_lt_two)]
refine iSup_le fun n => (Finset.le_sum_condensed hf n).trans ?_
simp only [nsmul_eq_mul, Nat.cast_pow, Nat.cast_two]
grw [ENNReal.sum_le_tsum]
theorem tsum_schlomilch_le {C : ℕ} (hf : ∀ ⦃m n⦄, 1 < m → m ≤ n → f n ≤ f m) (h_pos : ∀ n, 0 < u n)
(h_nonneg : ∀ n, 0 ≤ f n) (hu : Monotone u) (h_succ_diff : SuccDiffBounded C u) :
∑' k : ℕ, (u (k + 1) - u k) * f (u k) ≤ (u 1 - u 0) * f (u 0) + C * ∑' k, f k := by
rw [ENNReal.tsum_eq_iSup_nat' (tendsto_atTop_mono Nat.le_succ tendsto_id)]
refine iSup_le fun n => ?_
grw [← ENNReal.sum_le_tsum <| Finset.Ico (u 0 + 1) (u n + 1)]
simpa using Finset.sum_schlomilch_le hf h_pos h_nonneg hu h_succ_diff n
theorem tsum_condensed_le (hf : ∀ ⦃m n⦄, 1 < m → m ≤ n → f n ≤ f m) :
(∑' k : ℕ, 2 ^ k * f (2 ^ k)) ≤ f 1 + 2 * ∑' k, f k := by
rw [ENNReal.tsum_eq_iSup_nat' (tendsto_atTop_mono Nat.le_succ tendsto_id), two_mul, ← two_nsmul]
refine iSup_le fun n => ?_
grw [← ENNReal.sum_le_tsum <| Finset.Ico 2 (2 ^ n + 1)]
simpa using Finset.sum_condensed_le hf n
end ENNReal
namespace NNReal
open Finset
open ENNReal in
/-- for a series of `NNReal` version. -/
theorem summable_schlomilch_iff {C : ℕ} {u : ℕ → ℕ} {f : ℕ → ℝ≥0}
(hf : ∀ ⦃m n⦄, 0 < m → m ≤ n → f n ≤ f m)
(h_pos : ∀ n, 0 < u n) (hu_strict : StrictMono u)
(hC_nonzero : C ≠ 0) (h_succ_diff : SuccDiffBounded C u) :
(Summable fun k : ℕ => (u (k + 1) - (u k : ℝ≥0)) * f (u k)) ↔ Summable f := by
simp only [← tsum_coe_ne_top_iff_summable, Ne, not_iff_not, ENNReal.coe_mul]
constructor <;> intro h
· replace hf : ∀ m n, 1 < m → m ≤ n → (f n : ℝ≥0∞) ≤ f m := fun m n hm hmn =>
ENNReal.coe_le_coe.2 (hf (zero_lt_one.trans hm) hmn)
have h_nonneg : ∀ n, 0 ≤ (f n : ℝ≥0∞) := fun n =>
ENNReal.coe_le_coe.2 (f n).2
obtain hC := tsum_schlomilch_le hf h_pos h_nonneg hu_strict.monotone h_succ_diff
simpa [add_eq_top, mul_ne_top, mul_eq_top, hC_nonzero] using eq_top_mono hC h
· replace hf : ∀ m n, 0 < m → m ≤ n → (f n : ℝ≥0∞) ≤ f m := fun m n hm hmn =>
ENNReal.coe_le_coe.2 (hf hm hmn)
have : ∑ k ∈ range (u 0), (f k : ℝ≥0∞) ≠ ∞ := sum_ne_top.2 fun a _ => coe_ne_top
simpa [h, add_eq_top, this] using le_tsum_schlomilch hf h_pos hu_strict
open ENNReal in
theorem summable_condensed_iff {f : ℕ → ℝ≥0} (hf : ∀ ⦃m n⦄, 0 < m → m ≤ n → f n ≤ f m) :
(Summable fun k : ℕ => (2 : ℝ≥0) ^ k * f (2 ^ k)) ↔ Summable f := by
have h_succ_diff : SuccDiffBounded 2 (2 ^ ·) := by
intro n
simp [pow_succ, mul_two, two_mul]
convert summable_schlomilch_iff hf (pow_pos zero_lt_two) (pow_right_strictMono₀ _root_.one_lt_two)
two_ne_zero h_succ_diff
simp [pow_succ, mul_two]
end NNReal
open NNReal in
/-- for series of nonnegative real numbers. -/
theorem summable_schlomilch_iff_of_nonneg {C : ℕ} {u : ℕ → ℕ} {f : ℕ → ℝ} (h_nonneg : ∀ n, 0 ≤ f n)
(hf : ∀ ⦃m n⦄, 0 < m → m ≤ n → f n ≤ f m) (h_pos : ∀ n, 0 < u n)
(hu_strict : StrictMono u) (hC_nonzero : C ≠ 0) (h_succ_diff : SuccDiffBounded C u) :
(Summable fun k : ℕ => (u (k + 1) - (u k : ℝ)) * f (u k)) ↔ Summable f := by
lift f to ℕ → ℝ≥0 using h_nonneg
simp only [NNReal.coe_le_coe] at *
have (k : ℕ) : (u (k + 1) - (u k : ℝ)) = ((u (k + 1) : ℝ≥0) - (u k : ℝ≥0) : ℝ≥0) := by
have := Nat.cast_le (α := ℝ≥0).mpr <| (hu_strict k.lt_succ_self).le
simp [NNReal.coe_sub this]
simp_rw [this]
exact_mod_cast NNReal.summable_schlomilch_iff hf h_pos hu_strict hC_nonzero h_succ_diff
/-- Cauchy condensation test for antitone series of nonnegative real numbers. -/
theorem summable_condensed_iff_of_nonneg {f : ℕ → ℝ} (h_nonneg : ∀ n, 0 ≤ f n)
(h_mono : ∀ ⦃m n⦄, 0 < m → m ≤ n → f n ≤ f m) :
(Summable fun k : ℕ => (2 : ℝ) ^ k * f (2 ^ k)) ↔ Summable f := by
have h_succ_diff : SuccDiffBounded 2 (2 ^ ·) := by
intro n
simp [pow_succ, mul_two, two_mul]
convert summable_schlomilch_iff_of_nonneg h_nonneg h_mono (pow_pos zero_lt_two)
(pow_right_strictMono₀ one_lt_two) two_ne_zero h_succ_diff
simp [pow_succ, mul_two]
section p_series
/-!
### Convergence of the `p`-series
In this section we prove that for a real number `p`, the series `∑' n : ℕ, 1 / (n ^ p)` converges if
and only if `1 < p`. There are many different proofs of this fact. The proof in this file uses the
Cauchy condensation test we formalized above. This test implies that `∑ n, 1 / (n ^ p)` converges if
and only if `∑ n, 2 ^ n / ((2 ^ n) ^ p)` converges, and the latter series is a geometric series with
common ratio `2 ^ {1 - p}`. -/
namespace Real
open Filter
/-- Test for convergence of the `p`-series: the real-valued series `∑' n : ℕ, (n ^ p)⁻¹` converges
if and only if `1 < p`. -/
@[simp]
theorem summable_nat_rpow_inv {p : ℝ} :
Summable (fun n => ((n : ℝ) ^ p)⁻¹ : ℕ → ℝ) ↔ 1 < p := by
rcases le_or_gt 0 p with hp | hp
/- Cauchy condensation test applies only to antitone sequences, so we consider the
cases `0 ≤ p` and `p < 0` separately. -/
· rw [← summable_condensed_iff_of_nonneg]
· simp_rw [Nat.cast_pow, Nat.cast_two, ← rpow_natCast, ← rpow_mul zero_lt_two.le, mul_comm _ p,
rpow_mul zero_lt_two.le, rpow_natCast, ← inv_pow, ← mul_pow,
summable_geometric_iff_norm_lt_one]
nth_rw 1 [← rpow_one 2]
rw [← division_def, ← rpow_sub zero_lt_two, norm_eq_abs,
abs_of_pos (rpow_pos_of_pos zero_lt_two _), rpow_lt_one_iff zero_lt_two.le]
simp
· intro n
positivity
· intro m n hm hmn
gcongr
-- If `p < 0`, then `1 / n ^ p` tends to infinity, thus the series diverges.
· suffices ¬Summable (fun n => ((n : ℝ) ^ p)⁻¹ : ℕ → ℝ) by
have : ¬1 < p := fun hp₁ => hp.not_ge (zero_le_one.trans hp₁.le)
simpa only [this, iff_false]
intro h
obtain ⟨k : ℕ, hk₁ : ((k : ℝ) ^ p)⁻¹ < 1, hk₀ : k ≠ 0⟩ :=
((h.tendsto_cofinite_zero.eventually (gt_mem_nhds zero_lt_one)).and
(eventually_cofinite_ne 0)).exists
apply hk₀
rw [← pos_iff_ne_zero, ← @Nat.cast_pos ℝ] at hk₀
simpa [inv_lt_one₀ (rpow_pos_of_pos hk₀ _), one_lt_rpow_iff_of_pos hk₀, hp,
hp.not_gt, hk₀] using hk₁
@[simp]
theorem summable_nat_rpow {p : ℝ} : Summable (fun n => (n : ℝ) ^ p : ℕ → ℝ) ↔ p < -1 := by
rcases neg_surjective p with ⟨p, rfl⟩
simp [rpow_neg]
/-- Test for convergence of the `p`-series: the real-valued series `∑' n : ℕ, 1 / n ^ p` converges
if and only if `1 < p`. -/
theorem summable_one_div_nat_rpow {p : ℝ} :
Summable (fun n => 1 / (n : ℝ) ^ p : ℕ → ℝ) ↔ 1 < p := by
simp
/-- Test for convergence of the `p`-series: the real-valued series `∑' n : ℕ, (n ^ p)⁻¹` converges
if and only if `1 < p`. -/
@[simp]
theorem summable_nat_pow_inv {p : ℕ} :
Summable (fun n => ((n : ℝ) ^ p)⁻¹ : ℕ → ℝ) ↔ 1 < p := by
simp only [← rpow_natCast, summable_nat_rpow_inv, Nat.one_lt_cast]
/-- Test for convergence of the `p`-series: the real-valued series `∑' n : ℕ, 1 / n ^ p` converges
if and only if `1 < p`. -/
theorem summable_one_div_nat_pow {p : ℕ} :
Summable (fun n => 1 / (n : ℝ) ^ p : ℕ → ℝ) ↔ 1 < p := by
simp only [one_div, Real.summable_nat_pow_inv]
/-- Summability of the `p`-series over `ℤ`. -/
theorem summable_one_div_int_pow {p : ℕ} :
(Summable fun n : ℤ ↦ 1 / (n : ℝ) ^ p) ↔ 1 < p := by
refine ⟨fun h ↦ summable_one_div_nat_pow.mp (h.comp_injective Nat.cast_injective),
fun h ↦ .of_nat_of_neg (summable_one_div_nat_pow.mpr h)
(((summable_one_div_nat_pow.mpr h).mul_left <| 1 / (-1 : ℝ) ^ p).congr fun n ↦ ?_)⟩
rw [Int.cast_neg, Int.cast_natCast, neg_eq_neg_one_mul (n : ℝ), mul_pow, mul_one_div, div_div]
theorem summable_abs_int_rpow {b : ℝ} (hb : 1 < b) :
Summable fun n : ℤ => |(n : ℝ)| ^ (-b) := by
apply Summable.of_nat_of_neg
on_goal 2 => simp_rw [Int.cast_neg, abs_neg]
all_goals
simp_rw [Int.cast_natCast, fun n : ℕ => abs_of_nonneg (n.cast_nonneg : 0 ≤ (n : ℝ))]
rwa [summable_nat_rpow, neg_lt_neg_iff]
/-- Harmonic series is not unconditionally summable. -/
theorem not_summable_natCast_inv : ¬Summable (fun n => n⁻¹ : ℕ → ℝ) := by
have : ¬Summable (fun n => ((n : ℝ) ^ 1)⁻¹ : ℕ → ℝ) :=
mt (summable_nat_pow_inv (p := 1)).1 (lt_irrefl 1)
simpa
/-- Harmonic series is not unconditionally summable. -/
theorem not_summable_one_div_natCast : ¬Summable (fun n => 1 / n : ℕ → ℝ) := by
simpa only [inv_eq_one_div] using not_summable_natCast_inv
/-- **Divergence of the Harmonic Series** -/
theorem tendsto_sum_range_one_div_nat_succ_atTop :
Tendsto (fun n => ∑ i ∈ Finset.range n, (1 / (i + 1) : ℝ)) atTop atTop := by
rw [← not_summable_iff_tendsto_nat_atTop_of_nonneg]
· exact_mod_cast mt (_root_.summable_nat_add_iff 1).1 not_summable_one_div_natCast
· exact fun i => by positivity
end Real
namespace NNReal
@[simp]
theorem summable_rpow_inv {p : ℝ} :
Summable (fun n => ((n : ℝ≥0) ^ p)⁻¹ : ℕ → ℝ≥0) ↔ 1 < p := by
simp [← NNReal.summable_coe]
@[simp]
theorem summable_rpow {p : ℝ} : Summable (fun n => (n : ℝ≥0) ^ p : ℕ → ℝ≥0) ↔ p < -1 := by
simp [← NNReal.summable_coe]
theorem summable_one_div_rpow {p : ℝ} :
Summable (fun n => 1 / (n : ℝ≥0) ^ p : ℕ → ℝ≥0) ↔ 1 < p := by
simp
end NNReal
end p_series
section
open Finset
variable {α : Type*} [Field α] [LinearOrder α] [IsStrictOrderedRing α]
theorem sum_Ioc_inv_sq_le_sub {k n : ℕ} (hk : k ≠ 0) (h : k ≤ n) :
(∑ i ∈ Ioc k n, ((i : α) ^ 2)⁻¹) ≤ (k : α)⁻¹ - (n : α)⁻¹ := by
refine Nat.le_induction ?_ ?_ n h
· simp only [Ioc_self, sum_empty, sub_self, le_refl]
intro n hn IH
rw [sum_Ioc_succ_top hn]
grw [IH]
push_cast
have A : 0 < (n : α) := by simpa using hk.bot_lt.trans_le hn
field_simp
linarith
theorem sum_Ioo_inv_sq_le (k n : ℕ) : (∑ i ∈ Ioo k n, (i ^ 2 : α)⁻¹) ≤ 2 / (k + 1) :=
calc
(∑ i ∈ Ioo k n, ((i : α) ^ 2)⁻¹) ≤ ∑ i ∈ Ioc k (max (k + 1) n), ((i : α) ^ 2)⁻¹ := by
apply sum_le_sum_of_subset_of_nonneg
· intro x hx
simp only [mem_Ioo] at hx
simp only [hx, hx.2.le, mem_Ioc, le_max_iff, or_true, and_self_iff]
· intro i _hi _hident
positivity
_ ≤ ((k + 1 : α) ^ 2)⁻¹ + ∑ i ∈ Ioc k.succ (max (k + 1) n), ((i : α) ^ 2)⁻¹ := by
rw [← Icc_add_one_left_eq_Ioc, ← Ico_add_one_right_eq_Icc, sum_eq_sum_Ico_succ_bot]
swap; · exact Nat.succ_lt_succ ((Nat.lt_succ_self k).trans_le (le_max_left _ _))
rw [Ico_add_one_right_eq_Icc, Icc_add_one_left_eq_Ioc]
norm_cast
_ ≤ ((k + 1 : α) ^ 2)⁻¹ + (k + 1 : α)⁻¹ := by
refine add_le_add le_rfl ((sum_Ioc_inv_sq_le_sub ?_ (le_max_left _ _)).trans ?_)
· simp only [Ne, Nat.succ_ne_zero, not_false_iff]
· simp only [Nat.cast_succ, sub_le_self_iff, inv_nonneg, Nat.cast_nonneg]
_ ≤ 1 / (k + 1) + 1 / (k + 1) := by
have A : (1 : α) ≤ k + 1 := by simp only [le_add_iff_nonneg_left, Nat.cast_nonneg]
simp_rw [← one_div]
gcongr
simpa using pow_right_mono₀ A one_le_two
_ = 2 / (k + 1) := by ring
end
open Set Nat in
/-- The harmonic series restricted to a residue class is not summable. -/
lemma Real.not_summable_indicator_one_div_natCast {m : ℕ} (hm : m ≠ 0) (k : ZMod m) :
¬ Summable ({n : ℕ | (n : ZMod m) = k}.indicator fun n : ℕ ↦ (1 / n : ℝ)) := by
have : NeZero m := ⟨hm⟩ -- instance is needed below
rw [← summable_nat_add_iff 1] -- shift by one to avoid non-monotonicity at zero
have h (n : ℕ) : {n : ℕ | (n : ZMod m) = k - 1}.indicator (fun n : ℕ ↦ (1 / (n + 1 :) : ℝ)) n =
if (n : ZMod m) = k - 1 then (1 / (n + 1) : ℝ) else (0 : ℝ) := by
simp only [indicator_apply, mem_setOf_eq, cast_add, cast_one]
simp_rw [indicator_apply, mem_setOf, cast_add, cast_one, ← eq_sub_iff_add_eq, ← h]
rw [summable_indicator_mod_iff (fun n₁ n₂ h ↦ by gcongr) (k - 1)]
exact mt (summable_nat_add_iff (f := fun n : ℕ ↦ 1 / (n : ℝ)) 1).mp not_summable_one_div_natCast
/-!
## Translating the `p`-series by a real number
-/
section shifted
open Filter Asymptotics Topology
-- see https://github.com/leanprover-community/mathlib4/issues/29041
set_option linter.unusedSimpArgs false in
lemma Real.summable_one_div_nat_add_rpow (a : ℝ) (s : ℝ) :
Summable (fun n : ℕ ↦ 1 / |n + a| ^ s) ↔ 1 < s := by
suffices ∀ (b c : ℝ), Summable (fun n : ℕ ↦ 1 / |n + b| ^ s) →
Summable (fun n : ℕ ↦ 1 / |n + c| ^ s) by
simp_rw [← summable_one_div_nat_rpow, Iff.intro (this a 0) (this 0 a), add_zero, Nat.abs_cast]
refine fun b c h ↦ summable_of_isBigO_nat h (isBigO_of_div_tendsto_nhds ?_ 1 ?_)
· filter_upwards [eventually_gt_atTop (Nat.ceil |b|)] with n hn hx
have hna : 0 < n + b := by linarith [lt_of_abs_lt ((abs_neg b).symm ▸ Nat.lt_of_ceil_lt hn)]
exfalso
revert hx
positivity
· simp_rw [Pi.div_def, div_div, mul_one_div, one_div_div]
refine (?_ : Tendsto (fun x : ℝ ↦ |x + b| ^ s / |x + c| ^ s) atTop (𝓝 1)).comp
tendsto_natCast_atTop_atTop
have : Tendsto (fun x : ℝ ↦ 1 + (b - c) / x) atTop (𝓝 1) := by
simpa using tendsto_const_nhds.add ((tendsto_const_nhds (X := ℝ)).div_atTop tendsto_id)
have : Tendsto (fun x ↦ (x + b) / (x + c)) atTop (𝓝 1) := by
refine (this.comp (tendsto_id.atTop_add (tendsto_const_nhds (x := c)))).congr' ?_
filter_upwards [eventually_gt_atTop (-c)] with x hx
simp [field, (by linarith : 0 < x + c).ne']
apply (one_rpow s ▸ (continuousAt_rpow_const _ s (by simp)).tendsto.comp this).congr'
filter_upwards [eventually_gt_atTop (-b), eventually_gt_atTop (-c)] with x hb hc
rw [neg_lt_iff_pos_add] at hb hc
rw [Function.comp_apply, div_rpow hb.le hc.le, abs_of_pos hb, abs_of_pos hc]
lemma Real.summable_one_div_int_add_rpow (a : ℝ) (s : ℝ) :
Summable (fun n : ℤ ↦ 1 / |n + a| ^ s) ↔ 1 < s := by
simp_rw [summable_int_iff_summable_nat_and_neg, ← abs_neg (↑(-_ : ℤ) + a), neg_add,
Int.cast_neg, neg_neg, Int.cast_natCast, summable_one_div_nat_add_rpow, and_self]
theorem summable_pow_div_add {α : Type*} (x : α) [RCLike α] (q k : ℕ) (hq : 1 < q) :
Summable fun n : ℕ => ‖(x / (↑n + k) ^ q)‖ := by
simp_rw [norm_div]
apply Summable.const_div
simpa [hq, Nat.cast_add, one_div, norm_inv, norm_pow, RCLike.norm_natCast,
Real.summable_nat_pow_inv, iff_true]
using summable_nat_add_iff (f := fun x => ‖1 / (x ^ q : α)‖) k
end shifted |
.lake/packages/mathlib/Mathlib/Analysis/MeanInequalities.lean | import Mathlib.Algebra.BigOperators.Expect
import Mathlib.Algebra.BigOperators.Field
import Mathlib.Analysis.Convex.Jensen
import Mathlib.Analysis.Convex.SpecificFunctions.Basic
import Mathlib.Analysis.SpecialFunctions.Pow.NNReal
import Mathlib.Data.Real.ConjExponents
/-!
# Mean value inequalities
In this file we prove several inequalities for finite sums, including AM-GM inequality,
HM-GM inequality, Young's inequality, Hölder inequality, and Minkowski inequality. Versions for
integrals of some of these inequalities are available in
`Mathlib/MeasureTheory/Integral/MeanInequalities.lean`.
## Main theorems
### AM-GM inequality:
The inequality says that the geometric mean of a tuple of non-negative numbers is less than or equal
to their arithmetic mean. We prove the weighted version of this inequality: if $w$ and $z$
are two non-negative vectors and $\sum_{i\in s} w_i=1$, then
$$
\prod_{i\in s} z_i^{w_i} ≤ \sum_{i\in s} w_iz_i.
$$
The classical version is a special case of this inequality for $w_i=\frac{1}{n}$.
We prove a few versions of this inequality. Each of the following lemmas comes in two versions:
a version for real-valued non-negative functions is in the `Real` namespace, and a version for
`NNReal`-valued functions is in the `NNReal` namespace.
- `geom_mean_le_arith_mean_weighted` : weighted version for functions on `Finset`s;
- `geom_mean_le_arith_mean2_weighted` : weighted version for two numbers;
- `geom_mean_le_arith_mean3_weighted` : weighted version for three numbers;
- `geom_mean_le_arith_mean4_weighted` : weighted version for four numbers.
### HM-GM inequality:
The inequality says that the harmonic mean of a tuple of positive numbers is less than or equal
to their geometric mean. We prove the weighted version of this inequality: if $w$ and $z$
are two positive vectors and $\sum_{i\in s} w_i=1$, then
$$
1/(\sum_{i\in s} w_i/z_i) ≤ \prod_{i\in s} z_i^{w_i}
$$
The classical version is proven as a special case of this inequality for $w_i=\frac{1}{n}$.
The inequalities are proven only for real-valued positive functions on `Finset`s, and namespaced in
`Real`. The weighted version follows as a corollary of the weighted AM-GM inequality.
### Young's inequality
Young's inequality says that for non-negative numbers `a`, `b`, `p`, `q` such that
$\frac{1}{p}+\frac{1}{q}=1$ we have
$$
ab ≤ \frac{a^p}{p} + \frac{b^q}{q}.
$$
This inequality is a special case of the AM-GM inequality. It is then used to prove Hölder's
inequality (see below).
### Hölder's inequality
The inequality says that for two conjugate exponents `p` and `q` (i.e., for two positive numbers
such that $\frac{1}{p}+\frac{1}{q}=1$) and any two non-negative vectors their inner product is
less than or equal to the product of the $L_p$ norm of the first vector and the $L_q$ norm of the
second vector:
$$
\sum_{i\in s} a_ib_i ≤ \sqrt[p]{\sum_{i\in s} a_i^p}\sqrt[q]{\sum_{i\in s} b_i^q}.
$$
We give versions of this result in `ℝ`, `ℝ≥0` and `ℝ≥0∞`.
There are at least two short proofs of this inequality. In our proof we prenormalize both vectors,
then apply Young's inequality to each $a_ib_i$. Another possible proof would be to deduce this
inequality from the generalized mean inequality for well-chosen vectors and weights.
### Minkowski's inequality
The inequality says that for `p ≥ 1` the function
$$
\|a\|_p=\sqrt[p]{\sum_{i\in s} a_i^p}
$$
satisfies the triangle inequality $\|a+b\|_p\le \|a\|_p+\|b\|_p$.
We give versions of this result in `Real`, `ℝ≥0` and `ℝ≥0∞`.
We deduce this inequality from Hölder's inequality. Namely, Hölder inequality implies that $\|a\|_p$
is the maximum of the inner product $\sum_{i\in s}a_ib_i$ over `b` such that $\|b\|_q\le 1$. Now
Minkowski's inequality follows from the fact that the maximum value of the sum of two functions is
less than or equal to the sum of the maximum values of the summands.
## TODO
- each inequality `A ≤ B` should come with a theorem `A = B ↔ _`; one of the ways to prove them
is to define `StrictConvexOn` functions.
- generalized mean inequality with any `p ≤ q`, including negative numbers;
- prove that the power mean tends to the geometric mean as the exponent tends to zero.
-/
universe u v
open Finset NNReal ENNReal
open scoped BigOperators
noncomputable section
variable {ι : Type u} (s : Finset ι)
section GeomMeanLEArithMean
/-! ### AM-GM inequality -/
namespace Real
/-- **AM-GM inequality**: The geometric mean is less than or equal to the arithmetic mean, weighted
version for real-valued nonnegative functions. -/
theorem geom_mean_le_arith_mean_weighted (w z : ι → ℝ) (hw : ∀ i ∈ s, 0 ≤ w i)
(hw' : ∑ i ∈ s, w i = 1) (hz : ∀ i ∈ s, 0 ≤ z i) :
∏ i ∈ s, z i ^ w i ≤ ∑ i ∈ s, w i * z i := by
-- If some number `z i` equals zero and has non-zero weight, then LHS is 0 and RHS is nonnegative.
by_cases! A : ∃ i ∈ s, z i = 0 ∧ w i ≠ 0
· rcases A with ⟨i, his, hzi, hwi⟩
rw [prod_eq_zero his]
· exact sum_nonneg fun j hj => mul_nonneg (hw j hj) (hz j hj)
· rw [hzi]
exact zero_rpow hwi
-- If all numbers `z i` with non-zero weight are positive, then we apply Jensen's inequality
-- for `exp` and numbers `log (z i)` with weights `w i`.
· have := convexOn_exp.map_sum_le hw hw' fun i _ => Set.mem_univ <| log (z i)
simp only [exp_sum, smul_eq_mul, mul_comm (w _) (log _)] at this
convert this using 1 <;> [apply prod_congr rfl;apply sum_congr rfl] <;> intro i hi
· rcases eq_or_lt_of_le (hz i hi) with hz | hz
· simp [A i hi hz.symm]
· exact rpow_def_of_pos hz _
· rcases eq_or_lt_of_le (hz i hi) with hz | hz
· simp [A i hi hz.symm]
· rw [exp_log hz]
/-- **AM-GM inequality**: The **geometric mean is less than or equal to the arithmetic mean. -/
theorem geom_mean_le_arith_mean {ι : Type*} (s : Finset ι) (w : ι → ℝ) (z : ι → ℝ)
(hw : ∀ i ∈ s, 0 ≤ w i) (hw' : 0 < ∑ i ∈ s, w i) (hz : ∀ i ∈ s, 0 ≤ z i) :
(∏ i ∈ s, z i ^ w i) ^ (∑ i ∈ s, w i)⁻¹ ≤ (∑ i ∈ s, w i * z i) / (∑ i ∈ s, w i) := by
convert geom_mean_le_arith_mean_weighted s (fun i => (w i) / ∑ i ∈ s, w i) z ?_ ?_ hz using 2
· rw [← finset_prod_rpow _ _ (fun i hi => rpow_nonneg (hz _ hi) _) _]
refine Finset.prod_congr rfl (fun _ ih => ?_)
rw [div_eq_mul_inv, rpow_mul (hz _ ih)]
· simp_rw [div_eq_mul_inv, mul_assoc, mul_comm, ← mul_assoc, ← Finset.sum_mul, mul_comm]
· exact fun _ hi => div_nonneg (hw _ hi) (le_of_lt hw')
· simp_rw [div_eq_mul_inv, ← Finset.sum_mul]
exact mul_inv_cancel₀ (by linarith)
theorem geom_mean_weighted_of_constant (w z : ι → ℝ) (x : ℝ) (hw : ∀ i ∈ s, 0 ≤ w i)
(hw' : ∑ i ∈ s, w i = 1) (hz : ∀ i ∈ s, 0 ≤ z i) (hx : ∀ i ∈ s, w i ≠ 0 → z i = x) :
∏ i ∈ s, z i ^ w i = x :=
calc
∏ i ∈ s, z i ^ w i = ∏ i ∈ s, x ^ w i := by
refine prod_congr rfl fun i hi => ?_
rcases eq_or_ne (w i) 0 with h₀ | h₀
· rw [h₀, rpow_zero, rpow_zero]
· rw [hx i hi h₀]
_ = x := by
rw [← rpow_sum_of_nonneg _ hw, hw', rpow_one]
have : (∑ i ∈ s, w i) ≠ 0 := by
rw [hw']
exact one_ne_zero
obtain ⟨i, his, hi⟩ := exists_ne_zero_of_sum_ne_zero this
rw [← hx i his hi]
exact hz i his
theorem arith_mean_weighted_of_constant (w z : ι → ℝ) (x : ℝ) (hw' : ∑ i ∈ s, w i = 1)
(hx : ∀ i ∈ s, w i ≠ 0 → z i = x) : ∑ i ∈ s, w i * z i = x :=
calc
∑ i ∈ s, w i * z i = ∑ i ∈ s, w i * x := by
refine sum_congr rfl fun i hi => ?_
rcases eq_or_ne (w i) 0 with hwi | hwi
· rw [hwi, zero_mul, zero_mul]
· rw [hx i hi hwi]
_ = x := by rw [← sum_mul, hw', one_mul]
theorem geom_mean_eq_arith_mean_weighted_of_constant (w z : ι → ℝ) (x : ℝ) (hw : ∀ i ∈ s, 0 ≤ w i)
(hw' : ∑ i ∈ s, w i = 1) (hz : ∀ i ∈ s, 0 ≤ z i) (hx : ∀ i ∈ s, w i ≠ 0 → z i = x) :
∏ i ∈ s, z i ^ w i = ∑ i ∈ s, w i * z i := by
rw [geom_mean_weighted_of_constant, arith_mean_weighted_of_constant] <;> assumption
/-- **AM-GM inequality - equality condition**: This theorem provides the equality condition for the
*positive* weighted version of the AM-GM inequality for real-valued nonnegative functions. -/
theorem geom_mean_eq_arith_mean_weighted_iff' (w z : ι → ℝ) (hw : ∀ i ∈ s, 0 < w i)
(hw' : ∑ i ∈ s, w i = 1) (hz : ∀ i ∈ s, 0 ≤ z i) :
∏ i ∈ s, z i ^ w i = ∑ i ∈ s, w i * z i ↔ ∀ j ∈ s, z j = ∑ i ∈ s, w i * z i := by
by_cases! A : ∃ i ∈ s, z i = 0 ∧ w i ≠ 0
· rcases A with ⟨i, his, hzi, hwi⟩
rw [prod_eq_zero his]
· constructor
· intro h
rw [← h]
intro j hj
apply eq_zero_of_ne_zero_of_mul_left_eq_zero (ne_of_lt (hw j hj)).symm
apply (sum_eq_zero_iff_of_nonneg ?_).mp h.symm j hj
exact fun i hi => (mul_nonneg_iff_of_pos_left (hw i hi)).mpr (hz i hi)
· intro h
convert h i his
exact hzi.symm
· rw [hzi]
exact zero_rpow hwi
· have hz' := fun i h => lt_of_le_of_ne (hz i h) (fun a => (ne_of_gt (hw i h)) (A i h a.symm))
have := strictConvexOn_exp.map_sum_eq_iff hw hw' fun i _ => Set.mem_univ <| log (z i)
simp only [exp_sum, smul_eq_mul, mul_comm (w _) (log _)] at this
convert this using 1
· apply Eq.congr <;>
[apply prod_congr rfl; apply sum_congr rfl] <;>
intro i hi <;>
simp only [exp_mul, exp_log (hz' i hi)]
· constructor <;> intro h j hj
· rw [← arith_mean_weighted_of_constant s w _ (log (z j)) hw' fun i _ => congrFun rfl]
apply sum_congr rfl
intro x hx
simp only [mul_comm, h j hj, h x hx]
· rw [← arith_mean_weighted_of_constant s w _ (z j) hw' fun i _ => congrFun rfl]
apply sum_congr rfl
intro x hx
simp only [log_injOn_pos (hz' j hj) (hz' x hx), h j hj, h x hx]
/-- **AM-GM inequality - equality condition**: This theorem provides the equality condition for the
weighted version of the AM-GM inequality for real-valued nonnegative functions. -/
theorem geom_mean_eq_arith_mean_weighted_iff (w z : ι → ℝ) (hw : ∀ i ∈ s, 0 ≤ w i)
(hw' : ∑ i ∈ s, w i = 1) (hz : ∀ i ∈ s, 0 ≤ z i) :
∏ i ∈ s, z i ^ w i = ∑ i ∈ s, w i * z i ↔ ∀ j ∈ s, w j ≠ 0 → z j = ∑ i ∈ s, w i * z i := by
have h (i) (_ : i ∈ s) : w i * z i ≠ 0 → w i ≠ 0 := by apply left_ne_zero_of_mul
have h' (i) (_ : i ∈ s) : z i ^ w i ≠ 1 → w i ≠ 0 := by
by_contra!
obtain ⟨h1, h2⟩ := this
simp only [h2, rpow_zero, ne_self_iff_false] at h1
rw [← sum_filter_of_ne h, ← prod_filter_of_ne h', geom_mean_eq_arith_mean_weighted_iff']
· simp
· simp +contextual [(hw _ _).lt_iff_ne']
· rwa [sum_filter_ne_zero]
· simp_all only [ne_eq, mul_eq_zero, not_or, not_false_eq_true, implies_true, mem_filter]
/-- **AM-GM inequality - strict inequality condition**: This theorem provides the strict inequality
condition for the *positive* weighted version of the AM-GM inequality for real-valued nonnegative
functions. -/
theorem geom_mean_lt_arith_mean_weighted_iff_of_pos (w z : ι → ℝ) (hw : ∀ i ∈ s, 0 < w i)
(hw' : ∑ i ∈ s, w i = 1) (hz : ∀ i ∈ s, 0 ≤ z i) :
∏ i ∈ s, z i ^ w i < ∑ i ∈ s, w i * z i ↔ ∃ j ∈ s, ∃ k ∈ s, z j ≠ z k:= by
constructor
· intro h
by_contra! h_contra
rw [(geom_mean_eq_arith_mean_weighted_iff' s w z hw hw' hz).mpr ?_] at h
· exact (lt_self_iff_false _).mp h
· intro j hjs
rw [← arith_mean_weighted_of_constant s w (fun _ => z j) (z j) hw' fun _ _ => congrFun rfl]
apply sum_congr rfl (fun x a => congrArg (HMul.hMul (w x)) (h_contra j hjs x a))
· rintro ⟨j, hjs, k, hks, hzjk⟩
have := geom_mean_le_arith_mean_weighted s w z (fun i a => le_of_lt (hw i a)) hw' hz
by_contra! h
apply le_antisymm this at h
apply (geom_mean_eq_arith_mean_weighted_iff' s w z hw hw' hz).mp at h
simp only [h j hjs, h k hks, ne_eq, not_true_eq_false] at hzjk
end Real
namespace NNReal
/-- **AM-GM inequality**: The geometric mean is less than or equal to the arithmetic mean, weighted
version for `NNReal`-valued functions. -/
theorem geom_mean_le_arith_mean_weighted (w z : ι → ℝ≥0) (hw' : ∑ i ∈ s, w i = 1) :
(∏ i ∈ s, z i ^ (w i : ℝ)) ≤ ∑ i ∈ s, w i * z i :=
mod_cast
Real.geom_mean_le_arith_mean_weighted _ _ _ (fun i _ => (w i).coe_nonneg)
(by assumption_mod_cast) fun i _ => (z i).coe_nonneg
/-- **AM-GM inequality**: The geometric mean is less than or equal to the arithmetic mean, weighted
version for two `NNReal` numbers. -/
theorem geom_mean_le_arith_mean2_weighted (w₁ w₂ p₁ p₂ : ℝ≥0) :
w₁ + w₂ = 1 → p₁ ^ (w₁ : ℝ) * p₂ ^ (w₂ : ℝ) ≤ w₁ * p₁ + w₂ * p₂ := by
simpa only [Fin.prod_univ_succ, Fin.sum_univ_succ, Finset.prod_empty, Finset.sum_empty,
Finset.univ_eq_empty, Fin.cons_succ, Fin.cons_zero, add_zero, mul_one] using
geom_mean_le_arith_mean_weighted univ ![w₁, w₂] ![p₁, p₂]
theorem geom_mean_le_arith_mean3_weighted (w₁ w₂ w₃ p₁ p₂ p₃ : ℝ≥0) :
w₁ + w₂ + w₃ = 1 →
p₁ ^ (w₁ : ℝ) * p₂ ^ (w₂ : ℝ) * p₃ ^ (w₃ : ℝ) ≤ w₁ * p₁ + w₂ * p₂ + w₃ * p₃ := by
simpa only [Fin.prod_univ_succ, Fin.sum_univ_succ, Finset.prod_empty, Finset.sum_empty,
Finset.univ_eq_empty, Fin.cons_succ, Fin.cons_zero, add_zero, mul_one, ← add_assoc,
mul_assoc] using geom_mean_le_arith_mean_weighted univ ![w₁, w₂, w₃] ![p₁, p₂, p₃]
theorem geom_mean_le_arith_mean4_weighted (w₁ w₂ w₃ w₄ p₁ p₂ p₃ p₄ : ℝ≥0) :
w₁ + w₂ + w₃ + w₄ = 1 →
p₁ ^ (w₁ : ℝ) * p₂ ^ (w₂ : ℝ) * p₃ ^ (w₃ : ℝ) * p₄ ^ (w₄ : ℝ) ≤
w₁ * p₁ + w₂ * p₂ + w₃ * p₃ + w₄ * p₄ := by
simpa only [Fin.prod_univ_succ, Fin.sum_univ_succ, Finset.prod_empty, Finset.sum_empty,
Finset.univ_eq_empty, Fin.cons_succ, Fin.cons_zero, add_zero, mul_one, ← add_assoc,
mul_assoc] using geom_mean_le_arith_mean_weighted univ ![w₁, w₂, w₃, w₄] ![p₁, p₂, p₃, p₄]
end NNReal
namespace Real
theorem geom_mean_le_arith_mean2_weighted {w₁ w₂ p₁ p₂ : ℝ} (hw₁ : 0 ≤ w₁) (hw₂ : 0 ≤ w₂)
(hp₁ : 0 ≤ p₁) (hp₂ : 0 ≤ p₂) (hw : w₁ + w₂ = 1) : p₁ ^ w₁ * p₂ ^ w₂ ≤ w₁ * p₁ + w₂ * p₂ :=
NNReal.geom_mean_le_arith_mean2_weighted ⟨w₁, hw₁⟩ ⟨w₂, hw₂⟩ ⟨p₁, hp₁⟩ ⟨p₂, hp₂⟩ <|
NNReal.coe_inj.1 <| by assumption
theorem geom_mean_le_arith_mean3_weighted {w₁ w₂ w₃ p₁ p₂ p₃ : ℝ} (hw₁ : 0 ≤ w₁) (hw₂ : 0 ≤ w₂)
(hw₃ : 0 ≤ w₃) (hp₁ : 0 ≤ p₁) (hp₂ : 0 ≤ p₂) (hp₃ : 0 ≤ p₃) (hw : w₁ + w₂ + w₃ = 1) :
p₁ ^ w₁ * p₂ ^ w₂ * p₃ ^ w₃ ≤ w₁ * p₁ + w₂ * p₂ + w₃ * p₃ :=
NNReal.geom_mean_le_arith_mean3_weighted ⟨w₁, hw₁⟩ ⟨w₂, hw₂⟩ ⟨w₃, hw₃⟩ ⟨p₁, hp₁⟩ ⟨p₂, hp₂⟩
⟨p₃, hp₃⟩ <|
NNReal.coe_inj.1 hw
theorem geom_mean_le_arith_mean4_weighted {w₁ w₂ w₃ w₄ p₁ p₂ p₃ p₄ : ℝ} (hw₁ : 0 ≤ w₁)
(hw₂ : 0 ≤ w₂) (hw₃ : 0 ≤ w₃) (hw₄ : 0 ≤ w₄) (hp₁ : 0 ≤ p₁) (hp₂ : 0 ≤ p₂) (hp₃ : 0 ≤ p₃)
(hp₄ : 0 ≤ p₄) (hw : w₁ + w₂ + w₃ + w₄ = 1) :
p₁ ^ w₁ * p₂ ^ w₂ * p₃ ^ w₃ * p₄ ^ w₄ ≤ w₁ * p₁ + w₂ * p₂ + w₃ * p₃ + w₄ * p₄ :=
NNReal.geom_mean_le_arith_mean4_weighted ⟨w₁, hw₁⟩ ⟨w₂, hw₂⟩ ⟨w₃, hw₃⟩ ⟨w₄, hw₄⟩ ⟨p₁, hp₁⟩
⟨p₂, hp₂⟩ ⟨p₃, hp₃⟩ ⟨p₄, hp₄⟩ <|
NNReal.coe_inj.1 <| by assumption
end Real
end GeomMeanLEArithMean
section HarmMeanLEGeomMean
/-! ### HM-GM inequality -/
namespace Real
/-- **HM-GM inequality**: The harmonic mean is less than or equal to the geometric mean, weighted
version for real-valued nonnegative functions. -/
theorem harm_mean_le_geom_mean_weighted (w z : ι → ℝ) (hs : s.Nonempty) (hw : ∀ i ∈ s, 0 < w i)
(hw' : ∑ i ∈ s, w i = 1) (hz : ∀ i ∈ s, 0 < z i) :
(∑ i ∈ s, w i / z i)⁻¹ ≤ ∏ i ∈ s, z i ^ w i := by
have : ∏ i ∈ s, (1 / z) i ^ w i ≤ ∑ i ∈ s, w i * (1 / z) i :=
geom_mean_le_arith_mean_weighted s w (1/z) (fun i hi ↦ le_of_lt (hw i hi)) hw'
(fun i hi ↦ one_div_nonneg.2 (le_of_lt (hz i hi)))
have p_pos : 0 < ∏ i ∈ s, (z i)⁻¹ ^ w i :=
prod_pos fun i hi => rpow_pos_of_pos (inv_pos.2 (hz i hi)) _
have s_pos : 0 < ∑ i ∈ s, w i * (z i)⁻¹ :=
sum_pos (fun i hi => mul_pos (hw i hi) (inv_pos.2 (hz i hi))) hs
norm_num at this
rw [← inv_le_inv₀ s_pos p_pos] at this
apply le_trans this
have p_pos₂ : 0 < (∏ i ∈ s, (z i) ^ w i)⁻¹ :=
inv_pos.2 (prod_pos fun i hi => rpow_pos_of_pos ((hz i hi)) _ )
rw [← inv_inv (∏ i ∈ s, z i ^ w i), inv_le_inv₀ p_pos p_pos₂, ← Finset.prod_inv_distrib]
gcongr
· exact fun i hi ↦ inv_nonneg.mpr (Real.rpow_nonneg (le_of_lt (hz i hi)) _)
· rw [Real.inv_rpow]; apply fun i hi ↦ le_of_lt (hz i hi); assumption
/-- **HM-GM inequality**: The **harmonic mean is less than or equal to the geometric mean. -/
theorem harm_mean_le_geom_mean {ι : Type*} (s : Finset ι) (hs : s.Nonempty) (w : ι → ℝ)
(z : ι → ℝ) (hw : ∀ i ∈ s, 0 < w i) (hw' : 0 < ∑ i ∈ s, w i) (hz : ∀ i ∈ s, 0 < z i) :
(∑ i ∈ s, w i) / (∑ i ∈ s, w i / z i) ≤ (∏ i ∈ s, z i ^ w i) ^ (∑ i ∈ s, w i)⁻¹ := by
have := harm_mean_le_geom_mean_weighted s (fun i => (w i) / ∑ i ∈ s, w i) z hs ?_ ?_ hz
· simp only at this
set n := ∑ i ∈ s, w i
nth_rw 1 [div_eq_mul_inv, (show n = (n⁻¹)⁻¹ by simp), ← mul_inv, Finset.mul_sum _ _ n⁻¹]
simp_rw [inv_mul_eq_div n ((w _)/(z _)), div_right_comm _ _ n]
convert this
rw [← Real.finset_prod_rpow s _ (fun i hi ↦ Real.rpow_nonneg (le_of_lt <| hz i hi) _)]
refine Finset.prod_congr rfl (fun i hi => ?_)
rw [← Real.rpow_mul (le_of_lt <| hz i hi) (w _) n⁻¹, div_eq_mul_inv (w _) n]
· exact fun i hi ↦ div_pos (hw i hi) hw'
· simp_rw [div_eq_mul_inv (w _) (∑ i ∈ s, w i), ← Finset.sum_mul _ _ (∑ i ∈ s, w i)⁻¹]
exact mul_inv_cancel₀ hw'.ne'
end Real
end HarmMeanLEGeomMean
section Young
/-! ### Young's inequality -/
namespace Real
/-- **Young's inequality**, a version for nonnegative real numbers. -/
theorem young_inequality_of_nonneg {a b p q : ℝ} (ha : 0 ≤ a) (hb : 0 ≤ b)
(hpq : p.HolderConjugate q) : a * b ≤ a ^ p / p + b ^ q / q := by
simpa [← rpow_mul, ha, hb, hpq.ne_zero, hpq.symm.ne_zero, _root_.div_eq_inv_mul] using
geom_mean_le_arith_mean2_weighted hpq.inv_nonneg hpq.symm.inv_nonneg
(rpow_nonneg ha p) (rpow_nonneg hb q) hpq.inv_add_inv_eq_one
/-- **Young's inequality**, a version for arbitrary real numbers. -/
theorem young_inequality (a b : ℝ) {p q : ℝ} (hpq : p.HolderConjugate q) :
a * b ≤ |a| ^ p / p + |b| ^ q / q :=
calc
a * b ≤ |a * b| := le_abs_self (a * b)
_ = |a| * |b| := abs_mul a b
_ ≤ |a| ^ p / p + |b| ^ q / q :=
Real.young_inequality_of_nonneg (abs_nonneg a) (abs_nonneg b) hpq
end Real
namespace NNReal
/-- **Young's inequality**, `ℝ≥0` version. We use `{p q : ℝ≥0}` in order to avoid constructing
witnesses of `0 ≤ p` and `0 ≤ q` for the denominators. -/
theorem young_inequality (a b : ℝ≥0) {p q : ℝ≥0} (hpq : p.HolderConjugate q) :
a * b ≤ a ^ (p : ℝ) / p + b ^ (q : ℝ) / q :=
Real.young_inequality_of_nonneg a.coe_nonneg b.coe_nonneg hpq.coe
/-- **Young's inequality**, `ℝ≥0` version with real conjugate exponents. -/
theorem young_inequality_real (a b : ℝ≥0) {p q : ℝ} (hpq : p.HolderConjugate q) :
a * b ≤ a ^ p / Real.toNNReal p + b ^ q / Real.toNNReal q := by
simpa [Real.coe_toNNReal, hpq.nonneg, hpq.symm.nonneg] using young_inequality a b hpq.toNNReal
end NNReal
namespace ENNReal
/-- **Young's inequality**, `ℝ≥0∞` version with real conjugate exponents. -/
theorem young_inequality (a b : ℝ≥0∞) {p q : ℝ} (hpq : p.HolderConjugate q) :
a * b ≤ a ^ p / ENNReal.ofReal p + b ^ q / ENNReal.ofReal q := by
by_cases! h : a = ⊤ ∨ b = ⊤
· refine le_trans le_top (le_of_eq ?_)
repeat rw [div_eq_mul_inv]
rcases h with h | h <;> rw [h] <;> simp [hpq.pos, hpq.symm.pos]
-- if a ≠ ⊤ and b ≠ ⊤, use the nnreal version: nnreal.young_inequality_real
rw [← coe_toNNReal h.left, ← coe_toNNReal h.right, ← coe_mul, ← coe_rpow_of_nonneg _ hpq.nonneg,
← coe_rpow_of_nonneg _ hpq.symm.nonneg, ENNReal.ofReal, ENNReal.ofReal, ←
@coe_div (Real.toNNReal p) _ (by simp [hpq.pos]), ←
@coe_div (Real.toNNReal q) _ (by simp [hpq.symm.pos]), ← coe_add, coe_le_coe]
exact NNReal.young_inequality_real a.toNNReal b.toNNReal hpq
end ENNReal
end Young
section HoelderMinkowski
/-! ### Hölder's and Minkowski's inequalities -/
namespace NNReal
private theorem inner_le_Lp_mul_Lp_of_norm_le_one (f g : ι → ℝ≥0) {p q : ℝ}
(hpq : p.HolderConjugate q) (hf : ∑ i ∈ s, f i ^ p ≤ 1) (hg : ∑ i ∈ s, g i ^ q ≤ 1) :
∑ i ∈ s, f i * g i ≤ 1 := by
have hp : 0 < p.toNNReal := zero_lt_one.trans hpq.toNNReal.lt
have hq : 0 < q.toNNReal := zero_lt_one.trans hpq.toNNReal.symm.lt
calc
∑ i ∈ s, f i * g i ≤ ∑ i ∈ s, (f i ^ p / Real.toNNReal p + g i ^ q / Real.toNNReal q) :=
Finset.sum_le_sum fun i _ => young_inequality_real (f i) (g i) hpq
_ = (∑ i ∈ s, f i ^ p) / Real.toNNReal p + (∑ i ∈ s, g i ^ q) / Real.toNNReal q := by
rw [sum_add_distrib, sum_div, sum_div]
_ ≤ 1 / Real.toNNReal p + 1 / Real.toNNReal q := by
refine add_le_add ?_ ?_ <;> rwa [div_le_iff₀, div_mul_cancel₀] <;> positivity
_ = 1 := by simp_rw [one_div, hpq.toNNReal.inv_add_inv_eq_one]
private theorem inner_le_Lp_mul_Lp_of_norm_eq_zero (f g : ι → ℝ≥0) {p q : ℝ}
(hpq : p.HolderConjugate q) (hf : ∑ i ∈ s, f i ^ p = 0) :
∑ i ∈ s, f i * g i ≤ (∑ i ∈ s, f i ^ p) ^ (1 / p) * (∑ i ∈ s, g i ^ q) ^ (1 / q) := by
simp only [hf, hpq.ne_zero, one_div, sum_eq_zero_iff, zero_rpow, zero_mul,
inv_eq_zero, Ne, not_false_iff, le_zero_iff, mul_eq_zero]
intro i his
left
rw [sum_eq_zero_iff] at hf
exact (rpow_eq_zero_iff.mp (hf i his)).left
/-- **Hölder inequality**: The scalar product of two functions is bounded by the product of their
`L^p` and `L^q` norms when `p` and `q` are conjugate exponents. Version for sums over finite sets,
with `ℝ≥0`-valued functions. -/
theorem inner_le_Lp_mul_Lq (f g : ι → ℝ≥0) {p q : ℝ} (hpq : p.HolderConjugate q) :
∑ i ∈ s, f i * g i ≤ (∑ i ∈ s, f i ^ p) ^ (1 / p) * (∑ i ∈ s, g i ^ q) ^ (1 / q) := by
obtain hf | hf := eq_zero_or_pos (∑ i ∈ s, f i ^ p)
· exact inner_le_Lp_mul_Lp_of_norm_eq_zero s f g hpq hf
obtain hg | hg := eq_zero_or_pos (∑ i ∈ s, g i ^ q)
· calc
∑ i ∈ s, f i * g i = ∑ i ∈ s, g i * f i := by
congr with i
rw [mul_comm]
_ ≤ (∑ i ∈ s, g i ^ q) ^ (1 / q) * (∑ i ∈ s, f i ^ p) ^ (1 / p) :=
(inner_le_Lp_mul_Lp_of_norm_eq_zero s g f hpq.symm hg)
_ = (∑ i ∈ s, f i ^ p) ^ (1 / p) * (∑ i ∈ s, g i ^ q) ^ (1 / q) := mul_comm _ _
let f' i := f i / (∑ i ∈ s, f i ^ p) ^ (1 / p)
let g' i := g i / (∑ i ∈ s, g i ^ q) ^ (1 / q)
suffices (∑ i ∈ s, f' i * g' i) ≤ 1 by
simp_rw [f', g', div_mul_div_comm, ← sum_div] at this
rwa [div_le_iff₀, one_mul] at this
-- TODO: We are missing a positivity extension here
exact mul_pos (rpow_pos hf) (rpow_pos hg)
refine inner_le_Lp_mul_Lp_of_norm_le_one s f' g' hpq (le_of_eq ?_) (le_of_eq ?_)
· simp_rw [f', div_rpow, ← sum_div, ← rpow_mul, one_div, inv_mul_cancel₀ hpq.ne_zero, rpow_one,
div_self hf.ne']
· simp_rw [g', div_rpow, ← sum_div, ← rpow_mul, one_div, inv_mul_cancel₀ hpq.symm.ne_zero,
rpow_one, div_self hg.ne']
/-- **Weighted Hölder inequality**. -/
lemma inner_le_weight_mul_Lp (s : Finset ι) {p : ℝ} (hp : 1 ≤ p) (w f : ι → ℝ≥0) :
∑ i ∈ s, w i * f i ≤ (∑ i ∈ s, w i) ^ (1 - p⁻¹) * (∑ i ∈ s, w i * f i ^ p) ^ p⁻¹ := by
obtain rfl | hp := hp.eq_or_lt
· simp
calc
_ = ∑ i ∈ s, w i ^ (1 - p⁻¹) * (w i ^ p⁻¹ * f i) := ?_
_ ≤ (∑ i ∈ s, (w i ^ (1 - p⁻¹)) ^ (1 - p⁻¹)⁻¹) ^ (1 / (1 - p⁻¹)⁻¹) *
(∑ i ∈ s, (w i ^ p⁻¹ * f i) ^ p) ^ (1 / p) :=
inner_le_Lp_mul_Lq _ _ _ (.symm <| Real.holderConjugate_iff.mpr ⟨hp, by simp⟩)
_ = _ := ?_
· congr with i
rw [← mul_assoc, ← rpow_of_add_eq _ one_ne_zero, rpow_one]
simp
· have hp₀ : p ≠ 0 := by positivity
have hp₁ : 1 - p⁻¹ ≠ 0 := by simp [sub_eq_zero, hp.ne']
simp [mul_rpow, div_inv_eq_mul, one_mul, one_div, hp₀, hp₁]
/-- **Hölder inequality**: the scalar product of two functions is bounded by the product of their
`L^p` and `L^q` norms when `p` and `q` are conjugate exponents. A version for `NNReal`-valued
functions. For an alternative version, convenient if the infinite sums are already expressed as
`p`-th powers, see `inner_le_Lp_mul_Lq_hasSum`. -/
theorem inner_le_Lp_mul_Lq_tsum {f g : ι → ℝ≥0} {p q : ℝ} (hpq : p.HolderConjugate q)
(hf : Summable fun i => f i ^ p) (hg : Summable fun i => g i ^ q) :
(Summable fun i => f i * g i) ∧
∑' i, f i * g i ≤ (∑' i, f i ^ p) ^ (1 / p) * (∑' i, g i ^ q) ^ (1 / q) := by
have H₁ : ∀ s : Finset ι,
∑ i ∈ s, f i * g i ≤ (∑' i, f i ^ p) ^ (1 / p) * (∑' i, g i ^ q) ^ (1 / q) := by
intro s
refine le_trans (inner_le_Lp_mul_Lq s f g hpq) (mul_le_mul ?_ ?_ bot_le bot_le)
· rw [NNReal.rpow_le_rpow_iff (one_div_pos.mpr hpq.pos)]
exact hf.sum_le_tsum _ (fun _ _ => zero_le _)
· rw [NNReal.rpow_le_rpow_iff (one_div_pos.mpr hpq.symm.pos)]
exact hg.sum_le_tsum _ (fun _ _ => zero_le _)
have bdd : BddAbove (Set.range fun s => ∑ i ∈ s, f i * g i) := by
refine ⟨(∑' i, f i ^ p) ^ (1 / p) * (∑' i, g i ^ q) ^ (1 / q), ?_⟩
rintro a ⟨s, rfl⟩
exact H₁ s
have H₂ : Summable _ := (hasSum_of_isLUB _ (isLUB_ciSup bdd)).summable
exact ⟨H₂, H₂.tsum_le_of_sum_le H₁⟩
theorem summable_mul_of_Lp_Lq {f g : ι → ℝ≥0} {p q : ℝ} (hpq : p.HolderConjugate q)
(hf : Summable fun i => f i ^ p) (hg : Summable fun i => g i ^ q) :
Summable fun i => f i * g i :=
(inner_le_Lp_mul_Lq_tsum hpq hf hg).1
theorem inner_le_Lp_mul_Lq_tsum' {f g : ι → ℝ≥0} {p q : ℝ} (hpq : p.HolderConjugate q)
(hf : Summable fun i => f i ^ p) (hg : Summable fun i => g i ^ q) :
∑' i, f i * g i ≤ (∑' i, f i ^ p) ^ (1 / p) * (∑' i, g i ^ q) ^ (1 / q) :=
(inner_le_Lp_mul_Lq_tsum hpq hf hg).2
/-- **Hölder inequality**: the scalar product of two functions is bounded by the product of their
`L^p` and `L^q` norms when `p` and `q` are conjugate exponents. A version for `NNReal`-valued
functions. For an alternative version, convenient if the infinite sums are not already expressed as
`p`-th powers, see `inner_le_Lp_mul_Lq_tsum`. -/
theorem inner_le_Lp_mul_Lq_hasSum {f g : ι → ℝ≥0} {A B : ℝ≥0} {p q : ℝ}
(hpq : p.HolderConjugate q) (hf : HasSum (fun i => f i ^ p) (A ^ p))
(hg : HasSum (fun i => g i ^ q) (B ^ q)) : ∃ C, C ≤ A * B ∧ HasSum (fun i => f i * g i) C := by
obtain ⟨H₁, H₂⟩ := inner_le_Lp_mul_Lq_tsum hpq hf.summable hg.summable
have hA : A = (∑' i : ι, f i ^ p) ^ (1 / p) := by rw [hf.tsum_eq, rpow_inv_rpow_self hpq.ne_zero]
have hB : B = (∑' i : ι, g i ^ q) ^ (1 / q) := by
rw [hg.tsum_eq, rpow_inv_rpow_self hpq.symm.ne_zero]
refine ⟨∑' i, f i * g i, ?_, ?_⟩
· simpa [hA, hB] using H₂
· simpa only [rpow_self_rpow_inv hpq.ne_zero] using H₁.hasSum
/-- For `1 ≤ p`, the `p`-th power of the sum of `f i` is bounded above by a constant times the
sum of the `p`-th powers of `f i`. Version for sums over finite sets, with `ℝ≥0`-valued functions.
-/
theorem rpow_sum_le_const_mul_sum_rpow (f : ι → ℝ≥0) {p : ℝ} (hp : 1 ≤ p) :
(∑ i ∈ s, f i) ^ p ≤ (#s : ℝ≥0) ^ (p - 1) * ∑ i ∈ s, f i ^ p := by
rcases eq_or_lt_of_le hp with hp | hp
· simp [← hp]
let q : ℝ := p / (p - 1)
have hpq : p.HolderConjugate q := .conjExponent hp
have hp₁ : 1 / p * p = 1 := one_div_mul_cancel hpq.ne_zero
have hq : 1 / q * p = p - 1 := by
rw [← hpq.div_conj_eq_sub_one]
ring
simpa only [NNReal.mul_rpow, ← NNReal.rpow_mul, hp₁, hq, one_mul, one_rpow, rpow_one,
Pi.one_apply, sum_const, Nat.smul_one_eq_cast] using
NNReal.rpow_le_rpow (inner_le_Lp_mul_Lq s 1 f hpq.symm) hpq.nonneg
/-- The `L_p` seminorm of a vector `f` is the greatest value of the inner product
`∑ i ∈ s, f i * g i` over functions `g` of `L_q` seminorm less than or equal to one. -/
theorem isGreatest_Lp (f : ι → ℝ≥0) {p q : ℝ} (hpq : p.HolderConjugate q) :
IsGreatest ((fun g : ι → ℝ≥0 => ∑ i ∈ s, f i * g i) '' { g | ∑ i ∈ s, g i ^ q ≤ 1 })
((∑ i ∈ s, f i ^ p) ^ (1 / p)) := by
constructor
· use fun i => f i ^ p / f i / (∑ i ∈ s, f i ^ p) ^ (1 / q)
obtain hf | hf := eq_zero_or_pos (∑ i ∈ s, f i ^ p)
· simp [hf, hpq.ne_zero, hpq.symm.ne_zero]
· have A : p + q - q ≠ 0 := by simp [hpq.ne_zero]
have B : ∀ y : ℝ≥0, y * y ^ p / y = y ^ p := by
refine fun y => mul_div_cancel_left_of_imp fun h => ?_
simp [h, hpq.ne_zero]
simp only [Set.mem_setOf_eq, div_rpow, ← sum_div, ← rpow_mul,
div_mul_cancel₀ _ hpq.symm.ne_zero, rpow_one, div_le_iff₀ hf, one_mul, hpq.mul_eq_add, ←
rpow_sub' A, add_sub_cancel_right, le_refl, true_and, ← mul_div_assoc, B]
rw [div_eq_iff, ← rpow_add hf.ne', one_div, one_div, hpq.inv_add_inv_eq_one, rpow_one]
simpa [hpq.symm.ne_zero] using hf.ne'
· rintro _ ⟨g, hg, rfl⟩
apply le_trans (inner_le_Lp_mul_Lq s f g hpq)
simpa only [mul_one] using
mul_le_mul_left' (NNReal.rpow_le_one hg (le_of_lt hpq.symm.one_div_pos)) _
/-- **Minkowski inequality**: the `L_p` seminorm of the sum of two vectors is less than or equal
to the sum of the `L_p`-seminorms of the summands. A version for `NNReal`-valued functions. -/
theorem Lp_add_le (f g : ι → ℝ≥0) {p : ℝ} (hp : 1 ≤ p) :
(∑ i ∈ s, (f i + g i) ^ p) ^ (1 / p) ≤
(∑ i ∈ s, f i ^ p) ^ (1 / p) + (∑ i ∈ s, g i ^ p) ^ (1 / p) := by
-- The result is trivial when `p = 1`, so we can assume `1 < p`.
rcases eq_or_lt_of_le hp with (rfl | hp)
· simp [Finset.sum_add_distrib]
have hpq := Real.HolderConjugate.conjExponent hp
have := isGreatest_Lp s (f + g) hpq
simp only [Pi.add_apply, add_mul, sum_add_distrib] at this
rcases this.1 with ⟨φ, hφ, H⟩
rw [← H]
exact
add_le_add ((isGreatest_Lp s f hpq).2 ⟨φ, hφ, rfl⟩) ((isGreatest_Lp s g hpq).2 ⟨φ, hφ, rfl⟩)
/-- **Minkowski inequality**: the `L_p` seminorm of the infinite sum of two vectors is less than or
equal to the infinite sum of the `L_p`-seminorms of the summands, if these infinite sums both
exist. A version for `NNReal`-valued functions. For an alternative version, convenient if the
infinite sums are already expressed as `p`-th powers, see `Lp_add_le_hasSum_of_nonneg`. -/
theorem Lp_add_le_tsum {f g : ι → ℝ≥0} {p : ℝ} (hp : 1 ≤ p) (hf : Summable fun i => f i ^ p)
(hg : Summable fun i => g i ^ p) :
(Summable fun i => (f i + g i) ^ p) ∧
(∑' i, (f i + g i) ^ p) ^ (1 / p) ≤
(∑' i, f i ^ p) ^ (1 / p) + (∑' i, g i ^ p) ^ (1 / p) := by
have pos : 0 < p := lt_of_lt_of_le zero_lt_one hp
have H₁ : ∀ s : Finset ι,
(∑ i ∈ s, (f i + g i) ^ p) ≤
((∑' i, f i ^ p) ^ (1 / p) + (∑' i, g i ^ p) ^ (1 / p)) ^ p := by
intro s
rw [one_div, ← NNReal.rpow_inv_le_iff pos, ← one_div]
refine le_trans (Lp_add_le s f g hp) (add_le_add ?_ ?_) <;>
rw [NNReal.rpow_le_rpow_iff (one_div_pos.mpr pos)] <;>
refine Summable.sum_le_tsum _ (fun _ _ => zero_le _) ?_
exacts [hf, hg]
have bdd : BddAbove (Set.range fun s => ∑ i ∈ s, (f i + g i) ^ p) := by
refine ⟨((∑' i, f i ^ p) ^ (1 / p) + (∑' i, g i ^ p) ^ (1 / p)) ^ p, ?_⟩
rintro a ⟨s, rfl⟩
exact H₁ s
have H₂ : Summable _ := (hasSum_of_isLUB _ (isLUB_ciSup bdd)).summable
refine ⟨H₂, ?_⟩
rw [one_div, NNReal.rpow_inv_le_iff pos, ← one_div]
exact H₂.tsum_le_of_sum_le H₁
theorem summable_Lp_add {f g : ι → ℝ≥0} {p : ℝ} (hp : 1 ≤ p) (hf : Summable fun i => f i ^ p)
(hg : Summable fun i => g i ^ p) : Summable fun i => (f i + g i) ^ p :=
(Lp_add_le_tsum hp hf hg).1
theorem Lp_add_le_tsum' {f g : ι → ℝ≥0} {p : ℝ} (hp : 1 ≤ p) (hf : Summable fun i => f i ^ p)
(hg : Summable fun i => g i ^ p) :
(∑' i, (f i + g i) ^ p) ^ (1 / p) ≤ (∑' i, f i ^ p) ^ (1 / p) + (∑' i, g i ^ p) ^ (1 / p) :=
(Lp_add_le_tsum hp hf hg).2
/-- **Minkowski inequality**: the `L_p` seminorm of the infinite sum of two vectors is less than or
equal to the infinite sum of the `L_p`-seminorms of the summands, if these infinite sums both
exist. A version for `NNReal`-valued functions. For an alternative version, convenient if the
infinite sums are not already expressed as `p`-th powers, see `Lp_add_le_tsum_of_nonneg`. -/
theorem Lp_add_le_hasSum {f g : ι → ℝ≥0} {A B : ℝ≥0} {p : ℝ} (hp : 1 ≤ p)
(hf : HasSum (fun i => f i ^ p) (A ^ p)) (hg : HasSum (fun i => g i ^ p) (B ^ p)) :
∃ C, C ≤ A + B ∧ HasSum (fun i => (f i + g i) ^ p) (C ^ p) := by
have hp' : p ≠ 0 := (lt_of_lt_of_le zero_lt_one hp).ne'
obtain ⟨H₁, H₂⟩ := Lp_add_le_tsum hp hf.summable hg.summable
have hA : A = (∑' i : ι, f i ^ p) ^ (1 / p) := by rw [hf.tsum_eq, rpow_inv_rpow_self hp']
have hB : B = (∑' i : ι, g i ^ p) ^ (1 / p) := by rw [hg.tsum_eq, rpow_inv_rpow_self hp']
refine ⟨(∑' i, (f i + g i) ^ p) ^ (1 / p), ?_, ?_⟩
· simpa [hA, hB] using H₂
· simpa only [rpow_self_rpow_inv hp'] using H₁.hasSum
end NNReal
namespace Real
variable (f g : ι → ℝ) {p q : ℝ}
/-- **Hölder inequality**: the scalar product of two functions is bounded by the product of their
`L^p` and `L^q` norms when `p` and `q` are conjugate exponents. Version for sums over finite sets,
with real-valued functions. -/
theorem inner_le_Lp_mul_Lq (hpq : HolderConjugate p q) :
∑ i ∈ s, f i * g i ≤ (∑ i ∈ s, |f i| ^ p) ^ (1 / p) * (∑ i ∈ s, |g i| ^ q) ^ (1 / q) := by
have :=
NNReal.coe_le_coe.2
(NNReal.inner_le_Lp_mul_Lq s (fun i => ⟨_, abs_nonneg (f i)⟩) (fun i => ⟨_, abs_nonneg (g i)⟩)
hpq)
push_cast at this
refine le_trans (sum_le_sum fun i _ => ?_) this
simp only [← abs_mul, le_abs_self]
/-- For `1 ≤ p`, the `p`-th power of the sum of `f i` is bounded above by a constant times the
sum of the `p`-th powers of `f i`. Version for sums over finite sets, with `ℝ`-valued functions. -/
theorem rpow_sum_le_const_mul_sum_rpow (hp : 1 ≤ p) :
(∑ i ∈ s, |f i|) ^ p ≤ (#s : ℝ) ^ (p - 1) * ∑ i ∈ s, |f i| ^ p := by
have :=
NNReal.coe_le_coe.2
(NNReal.rpow_sum_le_const_mul_sum_rpow s (fun i => ⟨_, abs_nonneg (f i)⟩) hp)
push_cast at this
exact this
-- for some reason `exact_mod_cast` can't replace this argument
/-- **Minkowski inequality**: the `L_p` seminorm of the sum of two vectors is less than or equal
to the sum of the `L_p`-seminorms of the summands. A version for `Real`-valued functions. -/
theorem Lp_add_le (hp : 1 ≤ p) :
(∑ i ∈ s, |f i + g i| ^ p) ^ (1 / p) ≤
(∑ i ∈ s, |f i| ^ p) ^ (1 / p) + (∑ i ∈ s, |g i| ^ p) ^ (1 / p) := by
have :=
NNReal.coe_le_coe.2
(NNReal.Lp_add_le s (fun i => ⟨_, abs_nonneg (f i)⟩) (fun i => ⟨_, abs_nonneg (g i)⟩) hp)
push_cast at this
refine le_trans (rpow_le_rpow ?_ (sum_le_sum fun i _ => ?_) ?_) this <;>
simp [sum_nonneg, rpow_nonneg, abs_nonneg, le_trans zero_le_one hp, abs_add_le,
rpow_le_rpow]
variable {f g}
/-- **Hölder inequality**: the scalar product of two functions is bounded by the product of their
`L^p` and `L^q` norms when `p` and `q` are conjugate exponents. Version for sums over finite sets,
with real-valued nonnegative functions. -/
theorem inner_le_Lp_mul_Lq_of_nonneg (hpq : HolderConjugate p q) (hf : ∀ i ∈ s, 0 ≤ f i)
(hg : ∀ i ∈ s, 0 ≤ g i) :
∑ i ∈ s, f i * g i ≤ (∑ i ∈ s, f i ^ p) ^ (1 / p) * (∑ i ∈ s, g i ^ q) ^ (1 / q) := by
convert inner_le_Lp_mul_Lq s f g hpq using 3 <;> apply sum_congr rfl <;> intro i hi <;>
simp only [abs_of_nonneg, hf i hi, hg i hi]
/-- **Weighted Hölder inequality**. -/
lemma inner_le_weight_mul_Lp_of_nonneg (s : Finset ι) {p : ℝ} (hp : 1 ≤ p) (w f : ι → ℝ)
(hw : ∀ i, 0 ≤ w i) (hf : ∀ i, 0 ≤ f i) :
∑ i ∈ s, w i * f i ≤ (∑ i ∈ s, w i) ^ (1 - p⁻¹) * (∑ i ∈ s, w i * f i ^ p) ^ p⁻¹ := by
lift w to ι → ℝ≥0 using hw
lift f to ι → ℝ≥0 using hf
beta_reduce at *
norm_cast at *
exact NNReal.inner_le_weight_mul_Lp _ hp _ _
/-- **Weighted Hölder inequality** in terms of `Finset.expect`. -/
lemma compact_inner_le_weight_mul_Lp_of_nonneg (s : Finset ι) {p : ℝ} (hp : 1 ≤ p) {w f : ι → ℝ}
(hw : ∀ i, 0 ≤ w i) (hf : ∀ i, 0 ≤ f i) :
𝔼 i ∈ s, w i * f i ≤ (𝔼 i ∈ s, w i) ^ (1 - p⁻¹) * (𝔼 i ∈ s, w i * f i ^ p) ^ p⁻¹ := by
simp_rw [expect_eq_sum_div_card]
rw [div_rpow, div_rpow, div_mul_div_comm, ← rpow_add', sub_add_cancel, rpow_one]
· gcongr
exact inner_le_weight_mul_Lp_of_nonneg s hp _ _ hw hf
any_goals simp
· exact sum_nonneg fun i _ ↦ by have := hw i; have := hf i; positivity
· exact sum_nonneg fun i _ ↦ by have := hw i; positivity
/-- **Hölder inequality**: the scalar product of two functions is bounded by the product of their
`L^p` and `L^q` norms when `p` and `q` are conjugate exponents. A version for `ℝ`-valued functions.
For an alternative version, convenient if the infinite sums are already expressed as `p`-th powers,
see `inner_le_Lp_mul_Lq_hasSum_of_nonneg`. -/
theorem inner_le_Lp_mul_Lq_tsum_of_nonneg (hpq : p.HolderConjugate q) (hf : ∀ i, 0 ≤ f i)
(hg : ∀ i, 0 ≤ g i) (hf_sum : Summable fun i => f i ^ p) (hg_sum : Summable fun i => g i ^ q) :
(Summable fun i => f i * g i) ∧
∑' i, f i * g i ≤ (∑' i, f i ^ p) ^ (1 / p) * (∑' i, g i ^ q) ^ (1 / q) := by
lift f to ι → ℝ≥0 using hf
lift g to ι → ℝ≥0 using hg
-- After https://github.com/leanprover/lean4/pull/2734, `norm_cast` needs help with beta reduction.
beta_reduce at *
norm_cast at *
exact NNReal.inner_le_Lp_mul_Lq_tsum hpq hf_sum hg_sum
theorem summable_mul_of_Lp_Lq_of_nonneg (hpq : p.HolderConjugate q) (hf : ∀ i, 0 ≤ f i)
(hg : ∀ i, 0 ≤ g i) (hf_sum : Summable fun i => f i ^ p) (hg_sum : Summable fun i => g i ^ q) :
Summable fun i => f i * g i :=
(inner_le_Lp_mul_Lq_tsum_of_nonneg hpq hf hg hf_sum hg_sum).1
theorem inner_le_Lp_mul_Lq_tsum_of_nonneg' (hpq : p.HolderConjugate q) (hf : ∀ i, 0 ≤ f i)
(hg : ∀ i, 0 ≤ g i) (hf_sum : Summable fun i => f i ^ p) (hg_sum : Summable fun i => g i ^ q) :
∑' i, f i * g i ≤ (∑' i, f i ^ p) ^ (1 / p) * (∑' i, g i ^ q) ^ (1 / q) :=
(inner_le_Lp_mul_Lq_tsum_of_nonneg hpq hf hg hf_sum hg_sum).2
/-- **Hölder inequality**: the scalar product of two functions is bounded by the product of their
`L^p` and `L^q` norms when `p` and `q` are conjugate exponents. A version for `NNReal`-valued
functions. For an alternative version, convenient if the infinite sums are not already expressed as
`p`-th powers, see `inner_le_Lp_mul_Lq_tsum_of_nonneg`. -/
theorem inner_le_Lp_mul_Lq_hasSum_of_nonneg (hpq : p.HolderConjugate q) {A B : ℝ} (hA : 0 ≤ A)
(hB : 0 ≤ B) (hf : ∀ i, 0 ≤ f i) (hg : ∀ i, 0 ≤ g i)
(hf_sum : HasSum (fun i => f i ^ p) (A ^ p)) (hg_sum : HasSum (fun i => g i ^ q) (B ^ q)) :
∃ C : ℝ, 0 ≤ C ∧ C ≤ A * B ∧ HasSum (fun i => f i * g i) C := by
lift f to ι → ℝ≥0 using hf
lift g to ι → ℝ≥0 using hg
lift A to ℝ≥0 using hA
lift B to ℝ≥0 using hB
-- After https://github.com/leanprover/lean4/pull/2734, `norm_cast` needs help with beta reduction.
beta_reduce at *
norm_cast at hf_sum hg_sum
obtain ⟨C, hC, H⟩ := NNReal.inner_le_Lp_mul_Lq_hasSum hpq hf_sum hg_sum
refine ⟨C, C.prop, hC, ?_⟩
norm_cast
/-- For `1 ≤ p`, the `p`-th power of the sum of `f i` is bounded above by a constant times the
sum of the `p`-th powers of `f i`. Version for sums over finite sets, with nonnegative `ℝ`-valued
functions. -/
theorem rpow_sum_le_const_mul_sum_rpow_of_nonneg (hp : 1 ≤ p) (hf : ∀ i ∈ s, 0 ≤ f i) :
(∑ i ∈ s, f i) ^ p ≤ (#s : ℝ) ^ (p - 1) * ∑ i ∈ s, f i ^ p := by
convert rpow_sum_le_const_mul_sum_rpow s f hp using 2 <;> apply sum_congr rfl <;> intro i hi <;>
simp only [abs_of_nonneg, hf i hi]
/-- **Minkowski inequality**: the `L_p` seminorm of the sum of two vectors is less than or equal
to the sum of the `L_p`-seminorms of the summands. A version for `ℝ`-valued nonnegative
functions. -/
theorem Lp_add_le_of_nonneg (hp : 1 ≤ p) (hf : ∀ i ∈ s, 0 ≤ f i) (hg : ∀ i ∈ s, 0 ≤ g i) :
(∑ i ∈ s, (f i + g i) ^ p) ^ (1 / p) ≤
(∑ i ∈ s, f i ^ p) ^ (1 / p) + (∑ i ∈ s, g i ^ p) ^ (1 / p) := by
convert Lp_add_le s f g hp using 2 <;> [skip;congr 1;congr 1] <;> apply sum_congr rfl <;>
intro i hi <;>
simp only [abs_of_nonneg, hf i hi, hg i hi, add_nonneg]
/-- **Minkowski inequality**: the `L_p` seminorm of the infinite sum of two vectors is less than or
equal to the infinite sum of the `L_p`-seminorms of the summands, if these infinite sums both
exist. A version for `ℝ`-valued functions. For an alternative version, convenient if the infinite
sums are already expressed as `p`-th powers, see `Lp_add_le_hasSum_of_nonneg`. -/
theorem Lp_add_le_tsum_of_nonneg (hp : 1 ≤ p) (hf : ∀ i, 0 ≤ f i) (hg : ∀ i, 0 ≤ g i)
(hf_sum : Summable fun i => f i ^ p) (hg_sum : Summable fun i => g i ^ p) :
(Summable fun i => (f i + g i) ^ p) ∧
(∑' i, (f i + g i) ^ p) ^ (1 / p) ≤
(∑' i, f i ^ p) ^ (1 / p) + (∑' i, g i ^ p) ^ (1 / p) := by
lift f to ι → ℝ≥0 using hf
lift g to ι → ℝ≥0 using hg
-- After https://github.com/leanprover/lean4/pull/2734, `norm_cast` needs help with beta reduction.
beta_reduce at *
norm_cast0 at *
exact NNReal.Lp_add_le_tsum hp hf_sum hg_sum
theorem summable_Lp_add_of_nonneg (hp : 1 ≤ p) (hf : ∀ i, 0 ≤ f i) (hg : ∀ i, 0 ≤ g i)
(hf_sum : Summable fun i => f i ^ p) (hg_sum : Summable fun i => g i ^ p) :
Summable fun i => (f i + g i) ^ p :=
(Lp_add_le_tsum_of_nonneg hp hf hg hf_sum hg_sum).1
theorem Lp_add_le_tsum_of_nonneg' (hp : 1 ≤ p) (hf : ∀ i, 0 ≤ f i) (hg : ∀ i, 0 ≤ g i)
(hf_sum : Summable fun i => f i ^ p) (hg_sum : Summable fun i => g i ^ p) :
(∑' i, (f i + g i) ^ p) ^ (1 / p) ≤ (∑' i, f i ^ p) ^ (1 / p) + (∑' i, g i ^ p) ^ (1 / p) :=
(Lp_add_le_tsum_of_nonneg hp hf hg hf_sum hg_sum).2
/-- **Minkowski inequality**: the `L_p` seminorm of the infinite sum of two vectors is less than or
equal to the infinite sum of the `L_p`-seminorms of the summands, if these infinite sums both
exist. A version for `ℝ`-valued functions. For an alternative version, convenient if the infinite
sums are not already expressed as `p`-th powers, see `Lp_add_le_tsum_of_nonneg`. -/
theorem Lp_add_le_hasSum_of_nonneg (hp : 1 ≤ p) (hf : ∀ i, 0 ≤ f i) (hg : ∀ i, 0 ≤ g i) {A B : ℝ}
(hA : 0 ≤ A) (hB : 0 ≤ B) (hfA : HasSum (fun i => f i ^ p) (A ^ p))
(hgB : HasSum (fun i => g i ^ p) (B ^ p)) :
∃ C, 0 ≤ C ∧ C ≤ A + B ∧ HasSum (fun i => (f i + g i) ^ p) (C ^ p) := by
lift f to ι → ℝ≥0 using hf
lift g to ι → ℝ≥0 using hg
lift A to ℝ≥0 using hA
lift B to ℝ≥0 using hB
-- After https://github.com/leanprover/lean4/pull/2734, `norm_cast` needs help with beta reduction.
beta_reduce at hfA hgB
norm_cast at hfA hgB
obtain ⟨C, hC₁, hC₂⟩ := NNReal.Lp_add_le_hasSum hp hfA hgB
use C
-- After https://github.com/leanprover/lean4/pull/2734, `norm_cast` needs help with beta reduction.
beta_reduce
norm_cast
exact ⟨zero_le _, hC₁, hC₂⟩
end Real
namespace ENNReal
variable (f g : ι → ℝ≥0∞) {p q : ℝ}
/-- **Hölder inequality**: the scalar product of two functions is bounded by the product of their
`L^p` and `L^q` norms when `p` and `q` are conjugate exponents. Version for sums over finite sets,
with `ℝ≥0∞`-valued functions. -/
theorem inner_le_Lp_mul_Lq (hpq : p.HolderConjugate q) :
∑ i ∈ s, f i * g i ≤ (∑ i ∈ s, f i ^ p) ^ (1 / p) * (∑ i ∈ s, g i ^ q) ^ (1 / q) := by
by_cases! H : (∑ i ∈ s, f i ^ p) ^ (1 / p) = 0 ∨ (∑ i ∈ s, g i ^ q) ^ (1 / q) = 0
· replace H : (∀ i ∈ s, f i = 0) ∨ ∀ i ∈ s, g i = 0 := by
simpa [ENNReal.rpow_eq_zero_iff, hpq.pos, hpq.symm.pos, asymm hpq.pos, asymm hpq.symm.pos,
sum_eq_zero_iff_of_nonneg] using H
have : ∀ i ∈ s, f i * g i = 0 := fun i hi => by rcases H with H | H <;> simp [H i hi]
simp [sum_eq_zero this]
by_cases H' : (∑ i ∈ s, f i ^ p) ^ (1 / p) = ⊤ ∨ (∑ i ∈ s, g i ^ q) ^ (1 / q) = ⊤
· rcases H' with H' | H' <;> simp [H', -one_div, -sum_eq_zero_iff, -rpow_eq_zero_iff, H]
replace H' : (∀ i ∈ s, f i ≠ ⊤) ∧ ∀ i ∈ s, g i ≠ ⊤ := by
simpa [ENNReal.rpow_eq_top_iff, asymm hpq.pos, asymm hpq.symm.pos, hpq.pos, hpq.symm.pos,
ENNReal.sum_eq_top, not_or] using H'
have := ENNReal.coe_le_coe.2 (@NNReal.inner_le_Lp_mul_Lq _ s (fun i => ENNReal.toNNReal (f i))
(fun i => ENNReal.toNNReal (g i)) _ _ hpq)
simp [ENNReal.coe_rpow_of_nonneg, hpq.pos.le, hpq.symm.pos.le] at this
convert this using 1 <;> [skip; congr 2] <;> [skip; skip; simp; skip; simp] <;>
· refine Finset.sum_congr rfl fun i hi => ?_
simp [H'.1 i hi, H'.2 i hi, -WithZero.coe_mul]
/-- **Weighted Hölder inequality**. -/
lemma inner_le_weight_mul_Lp_of_nonneg (s : Finset ι) {p : ℝ} (hp : 1 ≤ p) (w f : ι → ℝ≥0∞) :
∑ i ∈ s, w i * f i ≤ (∑ i ∈ s, w i) ^ (1 - p⁻¹) * (∑ i ∈ s, w i * f i ^ p) ^ p⁻¹ := by
obtain rfl | hp := hp.eq_or_lt
· simp
have hp₀ : 0 < p := by positivity
have hp₁ : p⁻¹ < 1 := inv_lt_one_of_one_lt₀ hp
by_cases! H : (∑ i ∈ s, w i) ^ (1 - p⁻¹) = 0 ∨ (∑ i ∈ s, w i * f i ^ p) ^ p⁻¹ = 0
· replace H : (∀ i ∈ s, w i = 0) ∨ ∀ i ∈ s, w i = 0 ∨ f i = 0 := by
simpa [hp₀, hp₁, hp₀.not_gt, hp₁.not_gt, sum_eq_zero_iff_of_nonneg] using H
have (i) (hi : i ∈ s) : w i * f i = 0 := by rcases H with H | H <;> simp [H i hi]
simp [sum_eq_zero this]
by_cases H' : (∑ i ∈ s, w i) ^ (1 - p⁻¹) = ⊤ ∨ (∑ i ∈ s, w i * f i ^ p) ^ p⁻¹ = ⊤
· rcases H' with H' | H' <;> simp [H', -one_div, -sum_eq_zero_iff, -rpow_eq_zero_iff, H]
replace H' : (∀ i ∈ s, w i ≠ ⊤) ∧ ∀ i ∈ s, w i * f i ^ p ≠ ⊤ := by
simpa [rpow_eq_top_iff,hp₀, hp₁, hp₀.not_gt, hp₁.not_gt, sum_eq_top, not_or] using H'
have := coe_le_coe.2 <| NNReal.inner_le_weight_mul_Lp s hp.le (fun i ↦ ENNReal.toNNReal (w i))
fun i ↦ ENNReal.toNNReal (f i)
rw [coe_mul] at this
simp_rw [coe_rpow_of_nonneg _ <| inv_nonneg.2 hp₀.le, coe_finset_sum, ← ENNReal.toNNReal_rpow,
← ENNReal.toNNReal_mul, sum_congr rfl fun i hi ↦ coe_toNNReal (H'.2 i hi)] at this
simp [ENNReal.coe_rpow_of_nonneg, hp₁.le] at this
convert this using 2 with i hi
· obtain hw | hw := eq_or_ne (w i) 0
· simp [hw]
rw [coe_toNNReal (H'.1 _ hi), coe_toNNReal]
simpa [mul_eq_top, hw, hp₀, hp₀.not_gt, H'.1 _ hi] using H'.2 _ hi
· convert rfl with i hi
exact coe_toNNReal (H'.1 _ hi)
/-- For `1 ≤ p`, the `p`-th power of the sum of `f i` is bounded above by a constant times the
sum of the `p`-th powers of `f i`. Version for sums over finite sets, with `ℝ≥0∞`-valued functions.
-/
theorem rpow_sum_le_const_mul_sum_rpow (hp : 1 ≤ p) :
(∑ i ∈ s, f i) ^ p ≤ (card s : ℝ≥0∞) ^ (p - 1) * ∑ i ∈ s, f i ^ p := by
rcases eq_or_lt_of_le hp with hp | hp
· simp [← hp]
let q : ℝ := p / (p - 1)
have hpq : p.HolderConjugate q := .conjExponent hp
have hp₁ : 1 / p * p = 1 := one_div_mul_cancel hpq.ne_zero
have hq : 1 / q * p = p - 1 := by
rw [← hpq.div_conj_eq_sub_one]
ring
simpa only [ENNReal.mul_rpow_of_nonneg _ _ hpq.nonneg, ← ENNReal.rpow_mul, hp₁, hq, coe_one,
one_mul, one_rpow, rpow_one, Pi.one_apply, sum_const, Nat.smul_one_eq_cast] using
ENNReal.rpow_le_rpow (inner_le_Lp_mul_Lq s 1 f hpq.symm) hpq.nonneg
/-- **Minkowski inequality**: the `L_p` seminorm of the sum of two vectors is less than or equal
to the sum of the `L_p`-seminorms of the summands. A version for `ℝ≥0∞`-valued nonnegative
functions. -/
theorem Lp_add_le (hp : 1 ≤ p) :
(∑ i ∈ s, (f i + g i) ^ p) ^ (1 / p) ≤
(∑ i ∈ s, f i ^ p) ^ (1 / p) + (∑ i ∈ s, g i ^ p) ^ (1 / p) := by
by_cases H' : (∑ i ∈ s, f i ^ p) ^ (1 / p) = ⊤ ∨ (∑ i ∈ s, g i ^ p) ^ (1 / p) = ⊤
· rcases H' with H' | H' <;> simp [H', -one_div]
have pos : 0 < p := lt_of_lt_of_le zero_lt_one hp
replace H' : (∀ i ∈ s, f i ≠ ⊤) ∧ ∀ i ∈ s, g i ≠ ⊤ := by
simpa [ENNReal.rpow_eq_top_iff, asymm pos, pos, ENNReal.sum_eq_top, not_or] using H'
have :=
ENNReal.coe_le_coe.2
(@NNReal.Lp_add_le _ s (fun i => ENNReal.toNNReal (f i)) (fun i => ENNReal.toNNReal (g i)) _
hp)
push_cast [ENNReal.coe_rpow_of_nonneg, le_of_lt pos, le_of_lt (one_div_pos.2 pos)] at this
convert this using 2 <;> [skip; congr 1; congr 1] <;>
· refine Finset.sum_congr rfl fun i hi => ?_
simp [H'.1 i hi, H'.2 i hi]
end ENNReal
end HoelderMinkowski |
.lake/packages/mathlib/Mathlib/Analysis/ConstantSpeed.lean | import Mathlib.Data.Set.Function
import Mathlib.Analysis.RCLike.Basic
import Mathlib.Topology.EMetricSpace.BoundedVariation
/-!
# Constant speed
This file defines the notion of constant (and unit) speed for a function `f : ℝ → E` with
pseudo-emetric structure on `E` with respect to a set `s : Set ℝ` and "speed" `l : ℝ≥0`, and shows
that if `f` has locally bounded variation on `s`, it can be obtained (up to distance zero, on `s`),
as a composite `φ ∘ (variationOnFromTo f s a)`, where `φ` has unit speed and `a ∈ s`.
## Main definitions
* `HasConstantSpeedOnWith f s l`, stating that the speed of `f` on `s` is `l`.
* `HasUnitSpeedOn f s`, stating that the speed of `f` on `s` is `1`.
* `naturalParameterization f s a : ℝ → E`, the unit speed reparameterization of `f` on `s` relative
to `a`.
## Main statements
* `unique_unit_speed_on_Icc_zero` proves that if `f` and `f ∘ φ` are both naturally
parameterized on closed intervals starting at `0`, then `φ` must be the identity on
those intervals.
* `edist_naturalParameterization_eq_zero` proves that if `f` has locally bounded variation, then
precomposing `naturalParameterization f s a` with `variationOnFromTo f s a` yields a function
at distance zero from `f` on `s`.
* `has_unit_speed_naturalParameterization` proves that if `f` has locally bounded
variation, then `naturalParameterization f s a` has unit speed on `s`.
## Tags
arc-length, parameterization
-/
open scoped NNReal ENNReal
open Set
variable {α : Type*} [LinearOrder α] {E : Type*} [PseudoEMetricSpace E]
variable (f : ℝ → E) (s : Set ℝ) (l : ℝ≥0)
/-- `f` has constant speed `l` on `s` if the variation of `f` on `s ∩ Icc x y` is equal to
`l * (y - x)` for any `x y` in `s`.
-/
def HasConstantSpeedOnWith :=
∀ ⦃x⦄ (_ : x ∈ s) ⦃y⦄ (_ : y ∈ s), eVariationOn f (s ∩ Icc x y) = ENNReal.ofReal (l * (y - x))
variable {f s l}
theorem HasConstantSpeedOnWith.hasLocallyBoundedVariationOn (h : HasConstantSpeedOnWith f s l) :
LocallyBoundedVariationOn f s := fun x y hx hy => by
simp only [BoundedVariationOn, h hx hy, Ne, ENNReal.ofReal_ne_top, not_false_iff]
theorem hasConstantSpeedOnWith_of_subsingleton (f : ℝ → E) {s : Set ℝ} (hs : s.Subsingleton)
(l : ℝ≥0) : HasConstantSpeedOnWith f s l := by
rintro x hx y hy; cases hs hx hy
rw [eVariationOn.subsingleton f (fun y hy z hz => hs hy.1 hz.1 : (s ∩ Icc x x).Subsingleton)]
simp only [sub_self, mul_zero, ENNReal.ofReal_zero]
theorem hasConstantSpeedOnWith_iff_ordered :
HasConstantSpeedOnWith f s l ↔ ∀ ⦃x⦄ (_ : x ∈ s) ⦃y⦄ (_ : y ∈ s),
x ≤ y → eVariationOn f (s ∩ Icc x y) = ENNReal.ofReal (l * (y - x)) := by
refine ⟨fun h x xs y ys _ => h xs ys, fun h x xs y ys => ?_⟩
rcases le_total x y with (xy | yx)
· exact h xs ys xy
· rw [eVariationOn.subsingleton, ENNReal.ofReal_of_nonpos]
· exact mul_nonpos_of_nonneg_of_nonpos l.prop (sub_nonpos_of_le yx)
· rintro z ⟨zs, xz, zy⟩ w ⟨ws, xw, wy⟩
cases le_antisymm (zy.trans yx) xz
cases le_antisymm (wy.trans yx) xw
rfl
theorem hasConstantSpeedOnWith_iff_variationOnFromTo_eq :
HasConstantSpeedOnWith f s l ↔ LocallyBoundedVariationOn f s ∧
∀ ⦃x⦄ (_ : x ∈ s) ⦃y⦄ (_ : y ∈ s), variationOnFromTo f s x y = l * (y - x) := by
constructor
· rintro h; refine ⟨h.hasLocallyBoundedVariationOn, fun x xs y ys => ?_⟩
rw [hasConstantSpeedOnWith_iff_ordered] at h
rcases le_total x y with (xy | yx)
· rw [variationOnFromTo.eq_of_le f s xy, h xs ys xy]
exact ENNReal.toReal_ofReal (mul_nonneg l.prop (sub_nonneg.mpr xy))
· rw [variationOnFromTo.eq_of_ge f s yx, h ys xs yx]
have := ENNReal.toReal_ofReal (mul_nonneg l.prop (sub_nonneg.mpr yx))
simp_all only [NNReal.val_eq_coe]; ring
· rw [hasConstantSpeedOnWith_iff_ordered]
rintro h x xs y ys xy
rw [← h.2 xs ys, variationOnFromTo.eq_of_le f s xy, ENNReal.ofReal_toReal (h.1 x y xs ys)]
theorem HasConstantSpeedOnWith.union {t : Set ℝ} (hfs : HasConstantSpeedOnWith f s l)
(hft : HasConstantSpeedOnWith f t l) {x : ℝ} (hs : IsGreatest s x) (ht : IsLeast t x) :
HasConstantSpeedOnWith f (s ∪ t) l := by
rw [hasConstantSpeedOnWith_iff_ordered] at hfs hft ⊢
rintro z (zs | zt) y (ys | yt) zy
· have : (s ∪ t) ∩ Icc z y = s ∩ Icc z y := by
ext w; constructor
· rintro ⟨ws | wt, zw, wy⟩
· exact ⟨ws, zw, wy⟩
· exact ⟨(le_antisymm (wy.trans (hs.2 ys)) (ht.2 wt)).symm ▸ hs.1, zw, wy⟩
· rintro ⟨ws, zwy⟩; exact ⟨Or.inl ws, zwy⟩
rw [this, hfs zs ys zy]
· have : (s ∪ t) ∩ Icc z y = s ∩ Icc z x ∪ t ∩ Icc x y := by
ext w; constructor
· rintro ⟨ws | wt, zw, wy⟩
exacts [Or.inl ⟨ws, zw, hs.2 ws⟩, Or.inr ⟨wt, ht.2 wt, wy⟩]
· rintro (⟨ws, zw, wx⟩ | ⟨wt, xw, wy⟩)
exacts [⟨Or.inl ws, zw, wx.trans (ht.2 yt)⟩, ⟨Or.inr wt, (hs.2 zs).trans xw, wy⟩]
rw [this, @eVariationOn.union _ _ _ _ f _ _ x, hfs zs hs.1 (hs.2 zs), hft ht.1 yt (ht.2 yt)]
· have q := ENNReal.ofReal_add (mul_nonneg l.prop (sub_nonneg.mpr (hs.2 zs)))
(mul_nonneg l.prop (sub_nonneg.mpr (ht.2 yt)))
simp only [NNReal.val_eq_coe] at q
rw [← q]
ring_nf
exacts [⟨⟨hs.1, hs.2 zs, le_rfl⟩, fun w ⟨_, _, wx⟩ => wx⟩,
⟨⟨ht.1, le_rfl, ht.2 yt⟩, fun w ⟨_, xw, _⟩ => xw⟩]
· cases le_antisymm zy ((hs.2 ys).trans (ht.2 zt))
simp only [Icc_self, sub_self, mul_zero, ENNReal.ofReal_zero]
exact eVariationOn.subsingleton _ fun _ ⟨_, uz⟩ _ ⟨_, vz⟩ => uz.trans vz.symm
· have : (s ∪ t) ∩ Icc z y = t ∩ Icc z y := by
ext w; constructor
· rintro ⟨ws | wt, zw, wy⟩
· exact ⟨le_antisymm ((ht.2 zt).trans zw) (hs.2 ws) ▸ ht.1, zw, wy⟩
· exact ⟨wt, zw, wy⟩
· rintro ⟨wt, zwy⟩; exact ⟨Or.inr wt, zwy⟩
rw [this, hft zt yt zy]
theorem HasConstantSpeedOnWith.Icc_Icc {x y z : ℝ} (hfs : HasConstantSpeedOnWith f (Icc x y) l)
(hft : HasConstantSpeedOnWith f (Icc y z) l) : HasConstantSpeedOnWith f (Icc x z) l := by
rcases le_total x y with (xy | yx)
· rcases le_total y z with (yz | zy)
· rw [← Set.Icc_union_Icc_eq_Icc xy yz]
exact hfs.union hft (isGreatest_Icc xy) (isLeast_Icc yz)
· rintro u ⟨xu, uz⟩ v ⟨xv, vz⟩
rw [Icc_inter_Icc, sup_of_le_right xu, inf_of_le_right vz, ←
hfs ⟨xu, uz.trans zy⟩ ⟨xv, vz.trans zy⟩, Icc_inter_Icc, sup_of_le_right xu,
inf_of_le_right (vz.trans zy)]
· rintro u ⟨xu, uz⟩ v ⟨xv, vz⟩
rw [Icc_inter_Icc, sup_of_le_right xu, inf_of_le_right vz, ←
hft ⟨yx.trans xu, uz⟩ ⟨yx.trans xv, vz⟩, Icc_inter_Icc, sup_of_le_right (yx.trans xu),
inf_of_le_right vz]
theorem hasConstantSpeedOnWith_zero_iff :
HasConstantSpeedOnWith f s 0 ↔ ∀ᵉ (x ∈ s) (y ∈ s), edist (f x) (f y) = 0 := by
dsimp [HasConstantSpeedOnWith]
simp only [zero_mul, ENNReal.ofReal_zero, ← eVariationOn.eq_zero_iff]
constructor
· by_contra!
obtain ⟨h, hfs⟩ := this
simp_rw [ne_eq, eVariationOn.eq_zero_iff] at hfs h
push_neg at hfs
obtain ⟨x, xs, y, ys, hxy⟩ := hfs
rcases le_total x y with (xy | yx)
· exact hxy (h xs ys x ⟨xs, le_rfl, xy⟩ y ⟨ys, xy, le_rfl⟩)
· rw [edist_comm] at hxy
exact hxy (h ys xs y ⟨ys, le_rfl, yx⟩ x ⟨xs, yx, le_rfl⟩)
· rintro h x _ y _
refine le_antisymm ?_ zero_le'
rw [← h]
exact eVariationOn.mono f inter_subset_left
theorem HasConstantSpeedOnWith.ratio {l' : ℝ≥0} (hl' : l' ≠ 0) {φ : ℝ → ℝ} (φm : MonotoneOn φ s)
(hfφ : HasConstantSpeedOnWith (f ∘ φ) s l) (hf : HasConstantSpeedOnWith f (φ '' s) l') ⦃x : ℝ⦄
(xs : x ∈ s) : EqOn φ (fun y => l / l' * (y - x) + φ x) s := by
rintro y ys
rw [← sub_eq_iff_eq_add, mul_comm, ← mul_div_assoc, eq_div_iff (NNReal.coe_ne_zero.mpr hl')]
rw [hasConstantSpeedOnWith_iff_variationOnFromTo_eq] at hf
rw [hasConstantSpeedOnWith_iff_variationOnFromTo_eq] at hfφ
symm
calc
(y - x) * l = l * (y - x) := by rw [mul_comm]
_ = variationOnFromTo (f ∘ φ) s x y := (hfφ.2 xs ys).symm
_ = variationOnFromTo f (φ '' s) (φ x) (φ y) :=
(variationOnFromTo.comp_eq_of_monotoneOn f φ φm xs ys)
_ = l' * (φ y - φ x) := (hf.2 ⟨x, xs, rfl⟩ ⟨y, ys, rfl⟩)
_ = (φ y - φ x) * l' := by rw [mul_comm]
/-- `f` has unit speed on `s` if it is linearly parameterized by `l = 1` on `s`. -/
def HasUnitSpeedOn (f : ℝ → E) (s : Set ℝ) :=
HasConstantSpeedOnWith f s 1
theorem HasUnitSpeedOn.union {t : Set ℝ} {x : ℝ} (hfs : HasUnitSpeedOn f s)
(hft : HasUnitSpeedOn f t) (hs : IsGreatest s x) (ht : IsLeast t x) :
HasUnitSpeedOn f (s ∪ t) :=
HasConstantSpeedOnWith.union hfs hft hs ht
theorem HasUnitSpeedOn.Icc_Icc {x y z : ℝ} (hfs : HasUnitSpeedOn f (Icc x y))
(hft : HasUnitSpeedOn f (Icc y z)) : HasUnitSpeedOn f (Icc x z) :=
HasConstantSpeedOnWith.Icc_Icc hfs hft
/-- If both `f` and `f ∘ φ` have unit speed (on `t` and `s` respectively) and `φ`
monotonically maps `s` onto `t`, then `φ` is just a translation (on `s`).
-/
theorem unique_unit_speed {φ : ℝ → ℝ} (φm : MonotoneOn φ s) (hfφ : HasUnitSpeedOn (f ∘ φ) s)
(hf : HasUnitSpeedOn f (φ '' s)) ⦃x : ℝ⦄ (xs : x ∈ s) : EqOn φ (fun y => y - x + φ x) s := by
dsimp only [HasUnitSpeedOn] at hf hfφ
convert HasConstantSpeedOnWith.ratio one_ne_zero φm hfφ hf xs using 3
simp
/-- If both `f` and `f ∘ φ` have unit speed (on `Icc 0 t` and `Icc 0 s` respectively)
and `φ` monotonically maps `Icc 0 s` onto `Icc 0 t`, then `φ` is the identity on `Icc 0 s`
-/
theorem unique_unit_speed_on_Icc_zero {s t : ℝ} (hs : 0 ≤ s) (ht : 0 ≤ t) {φ : ℝ → ℝ}
(φm : MonotoneOn φ <| Icc 0 s) (φst : φ '' Icc 0 s = Icc 0 t)
(hfφ : HasUnitSpeedOn (f ∘ φ) (Icc 0 s)) (hf : HasUnitSpeedOn f (Icc 0 t)) :
EqOn φ id (Icc 0 s) := by
rw [← φst] at hf
convert unique_unit_speed φm hfφ hf ⟨le_rfl, hs⟩ using 1
have : φ 0 = 0 := by
have hm : 0 ∈ φ '' Icc 0 s := by simp only [φst, ht, mem_Icc, le_refl, and_self]
obtain ⟨x, xs, hx⟩ := hm
apply le_antisymm ((φm ⟨le_rfl, hs⟩ xs xs.1).trans_eq hx) _
have := φst ▸ mapsTo_image φ (Icc 0 s)
exact (mem_Icc.mp (@this 0 (by rw [mem_Icc]; exact ⟨le_rfl, hs⟩))).1
simp only [tsub_zero, this, add_zero]
rfl
/-- The natural parameterization of `f` on `s`, which, if `f` has locally bounded variation on `s`,
* has unit speed on `s` (by `has_unit_speed_naturalParameterization`).
* composed with `variationOnFromTo f s a`, is at distance zero from `f`
(by `edist_naturalParameterization_eq_zero`).
-/
noncomputable def naturalParameterization (f : α → E) (s : Set α) (a : α) : ℝ → E :=
f ∘ @Function.invFunOn _ _ ⟨a⟩ (variationOnFromTo f s a) s
theorem edist_naturalParameterization_eq_zero {f : α → E} {s : Set α}
(hf : LocallyBoundedVariationOn f s) {a : α} (as : a ∈ s) {b : α} (bs : b ∈ s) :
edist (naturalParameterization f s a (variationOnFromTo f s a b)) (f b) = 0 := by
dsimp only [naturalParameterization]
haveI : Nonempty α := ⟨a⟩
obtain ⟨cs, hc⟩ := Function.invFunOn_pos (b := variationOnFromTo f s a b) ⟨b, bs, rfl⟩
rw [variationOnFromTo.eq_left_iff hf as cs bs] at hc
apply variationOnFromTo.edist_zero_of_eq_zero hf cs bs hc
theorem has_unit_speed_naturalParameterization (f : α → E) {s : Set α}
(hf : LocallyBoundedVariationOn f s) {a : α} (as : a ∈ s) :
HasUnitSpeedOn (naturalParameterization f s a) (variationOnFromTo f s a '' s) := by
dsimp only [HasUnitSpeedOn]
rw [hasConstantSpeedOnWith_iff_ordered]
rintro _ ⟨b, bs, rfl⟩ _ ⟨c, cs, rfl⟩ h
rcases le_total c b with (cb | bc)
· rw [NNReal.coe_one, one_mul, le_antisymm h (variationOnFromTo.monotoneOn hf as cs bs cb),
sub_self, ENNReal.ofReal_zero, Icc_self, eVariationOn.subsingleton]
exact fun x hx y hy => hx.2.trans hy.2.symm
· rw [NNReal.coe_one, one_mul, sub_eq_add_neg, variationOnFromTo.eq_neg_swap, neg_neg, add_comm,
variationOnFromTo.add hf bs as cs, ← variationOnFromTo.eq_neg_swap f]
rw [←
eVariationOn.comp_inter_Icc_eq_of_monotoneOn (naturalParameterization f s a) _
(variationOnFromTo.monotoneOn hf as) bs cs]
rw [@eVariationOn.eq_of_edist_zero_on _ _ _ _ _ f]
· rw [variationOnFromTo.eq_of_le _ _ bc, ENNReal.ofReal_toReal (hf b c bs cs)]
· rintro x ⟨xs, _, _⟩
exact edist_naturalParameterization_eq_zero hf as xs |
.lake/packages/mathlib/Mathlib/Analysis/Oscillation.lean | import Mathlib.Data.ENNReal.Real
import Mathlib.Order.WellFoundedSet
import Mathlib.Topology.EMetricSpace.Diam
/-!
# Oscillation
In this file we define the oscillation of a function `f: E → F` at a point `x` of `E`. (`E` is
required to be a TopologicalSpace and `F` a PseudoEMetricSpace.) The oscillation of `f` at `x` is
defined to be the infimum of `diam f '' N` for all neighborhoods `N` of `x`. We also define
`oscillationWithin f D x`, which is the oscillation at `x` of `f` restricted to `D`.
We also prove some simple facts about oscillation, most notably that the oscillation of `f`
at `x` is 0 if and only if `f` is continuous at `x`, with versions for both `oscillation` and
`oscillationWithin`.
## Tags
oscillation, oscillationWithin
-/
open Topology EMetric Set ENNReal
universe u v
variable {E : Type u} {F : Type v} [PseudoEMetricSpace F]
/-- The oscillation of `f : E → F` at `x`. -/
noncomputable def oscillation [TopologicalSpace E] (f : E → F) (x : E) : ENNReal :=
⨅ S ∈ (𝓝 x).map f, diam S
/-- The oscillation of `f : E → F` within `D` at `x`. -/
noncomputable def oscillationWithin [TopologicalSpace E] (f : E → F) (D : Set E) (x : E) :
ENNReal :=
⨅ S ∈ (𝓝[D] x).map f, diam S
/-- The oscillation of `f` at `x` within a neighborhood `D` of `x` is equal to `oscillation f x` -/
theorem oscillationWithin_nhds_eq_oscillation [TopologicalSpace E] (f : E → F) (D : Set E) (x : E)
(hD : D ∈ 𝓝 x) : oscillationWithin f D x = oscillation f x := by
rw [oscillation, oscillationWithin, nhdsWithin_eq_nhds.2 hD]
@[deprecated (since := "2025-05-22")]
alias oscillationWithin_nhd_eq_oscillation := oscillationWithin_nhds_eq_oscillation
/-- The oscillation of `f` at `x` within `univ` is equal to `oscillation f x` -/
theorem oscillationWithin_univ_eq_oscillation [TopologicalSpace E] (f : E → F) (x : E) :
oscillationWithin f univ x = oscillation f x :=
oscillationWithin_nhds_eq_oscillation f univ x Filter.univ_mem
namespace ContinuousWithinAt
theorem oscillationWithin_eq_zero [TopologicalSpace E] {f : E → F} {D : Set E}
{x : E} (hf : ContinuousWithinAt f D x) : oscillationWithin f D x = 0 := by
refine le_antisymm (_root_.le_of_forall_pos_le_add fun ε hε ↦ ?_) (zero_le _)
rw [zero_add]
have : ball (f x) (ε / 2) ∈ (𝓝[D] x).map f := hf <| ball_mem_nhds _ (by simp [ne_of_gt hε])
refine (biInf_le diam this).trans (le_of_le_of_eq diam_ball ?_)
exact (ENNReal.mul_div_cancel (by simp) (by simp))
end ContinuousWithinAt
namespace ContinuousAt
theorem oscillation_eq_zero [TopologicalSpace E] {f : E → F} {x : E} (hf : ContinuousAt f x) :
oscillation f x = 0 := by
rw [← continuousWithinAt_univ f x] at hf
exact oscillationWithin_univ_eq_oscillation f x ▸ hf.oscillationWithin_eq_zero
end ContinuousAt
namespace OscillationWithin
/-- The oscillation within `D` of `f` at `x ∈ D` is 0 if and only if `ContinuousWithinAt f D x`. -/
theorem eq_zero_iff_continuousWithinAt [TopologicalSpace E] (f : E → F) {D : Set E}
{x : E} (xD : x ∈ D) : oscillationWithin f D x = 0 ↔ ContinuousWithinAt f D x := by
refine ⟨fun hf ↦ EMetric.tendsto_nhds.mpr (fun ε ε0 ↦ ?_), fun hf ↦ hf.oscillationWithin_eq_zero⟩
simp_rw [← hf, oscillationWithin, iInf_lt_iff] at ε0
obtain ⟨S, hS, Sε⟩ := ε0
refine Filter.mem_of_superset hS (fun y hy ↦ lt_of_le_of_lt ?_ Sε)
exact edist_le_diam_of_mem (mem_preimage.1 hy) <| mem_preimage.1 (mem_of_mem_nhdsWithin xD hS)
end OscillationWithin
namespace Oscillation
/-- The oscillation of `f` at `x` is 0 if and only if `f` is continuous at `x`. -/
theorem eq_zero_iff_continuousAt [TopologicalSpace E] (f : E → F) (x : E) :
oscillation f x = 0 ↔ ContinuousAt f x := by
rw [← oscillationWithin_univ_eq_oscillation, ← continuousWithinAt_univ f x]
exact OscillationWithin.eq_zero_iff_continuousWithinAt f (mem_univ x)
end Oscillation
namespace IsCompact
variable [PseudoEMetricSpace E] {K : Set E}
variable {f : E → F} {D : Set E} {ε : ENNReal}
/-- If `oscillationWithin f D x < ε` at every `x` in a compact set `K`, then there exists `δ > 0`
such that the oscillation of `f` on `ball x δ ∩ D` is less than `ε` for every `x` in `K`. -/
theorem uniform_oscillationWithin (comp : IsCompact K) (hK : ∀ x ∈ K, oscillationWithin f D x < ε) :
∃ δ > 0, ∀ x ∈ K, diam (f '' (ball x (ENNReal.ofReal δ) ∩ D)) ≤ ε := by
let S := fun r ↦ { x : E | ∃ (a : ℝ), (a > r ∧ diam (f '' (ball x (ENNReal.ofReal a) ∩ D)) ≤ ε) }
have S_open : ∀ r > 0, IsOpen (S r) := by
refine fun r _ ↦ isOpen_iff.mpr fun x ⟨a, ar, ha⟩ ↦
⟨ENNReal.ofReal ((a - r) / 2), by simp [ar], ?_⟩
refine fun y hy ↦ ⟨a - (a - r) / 2, by linarith,
le_trans (diam_mono (image_mono fun z hz ↦ ?_)) ha⟩
refine ⟨lt_of_le_of_lt (edist_triangle z y x) (lt_of_lt_of_eq (ENNReal.add_lt_add hz.1 hy) ?_),
hz.2⟩
rw [← ofReal_add (by linarith) (by linarith), sub_add_cancel]
have S_cover : K ⊆ ⋃ r > 0, S r := by
intro x hx
have : oscillationWithin f D x < ε := hK x hx
simp only [oscillationWithin, Filter.mem_map, iInf_lt_iff] at this
obtain ⟨n, hn₁, hn₂⟩ := this
obtain ⟨r, r0, hr⟩ := mem_nhdsWithin_iff.1 hn₁
simp only [gt_iff_lt, mem_iUnion, exists_prop]
have : ∀ r', (ENNReal.ofReal r') ≤ r → diam (f '' (ball x (ENNReal.ofReal r') ∩ D)) ≤ ε := by
intro r' hr'
grw [← hn₂, ← image_subset_iff.2 hr, hr']
by_cases r_top : r = ⊤
· exact ⟨1, one_pos, 2, by simp, this 2 (by simp only [r_top, le_top])⟩
· obtain ⟨r', hr'⟩ := exists_between (toReal_pos (ne_of_gt r0) r_top)
use r', hr'.1, r.toReal, hr'.2, this r.toReal ofReal_toReal_le
have S_antitone : ∀ (r₁ r₂ : ℝ), r₁ ≤ r₂ → S r₂ ⊆ S r₁ :=
fun r₁ r₂ hr x ⟨a, ar₂, ha⟩ ↦ ⟨a, lt_of_le_of_lt hr ar₂, ha⟩
obtain ⟨δ, δ0, hδ⟩ : ∃ r > 0, K ⊆ S r := by
obtain ⟨T, Tb, Tfin, hT⟩ := comp.elim_finite_subcover_image S_open S_cover
by_cases T_nonempty : T.Nonempty
· use Tfin.isWF.min T_nonempty, Tb (Tfin.isWF.min_mem T_nonempty)
intro x hx
obtain ⟨r, hr⟩ := mem_iUnion.1 (hT hx)
simp only [mem_iUnion, exists_prop] at hr
exact (S_antitone _ r (IsWF.min_le Tfin.isWF T_nonempty hr.1)) hr.2
· rw [not_nonempty_iff_eq_empty] at T_nonempty
use 1, one_pos, subset_trans hT (by simp [T_nonempty])
use δ, δ0
intro x xK
obtain ⟨a, δa, ha⟩ := hδ xK
grw [← ha]
gcongr
/-- If `oscillation f x < ε` at every `x` in a compact set `K`, then there exists `δ > 0` such
that the oscillation of `f` on `ball x δ` is less than `ε` for every `x` in `K`. -/
theorem uniform_oscillation {K : Set E} (comp : IsCompact K)
{f : E → F} {ε : ENNReal} (hK : ∀ x ∈ K, oscillation f x < ε) :
∃ δ > 0, ∀ x ∈ K, diam (f '' (ball x (ENNReal.ofReal δ))) ≤ ε := by
simp only [← oscillationWithin_univ_eq_oscillation] at hK
convert ← comp.uniform_oscillationWithin hK
exact inter_univ _
end IsCompact |
.lake/packages/mathlib/Mathlib/Analysis/Quaternion.lean | import Mathlib.Algebra.Quaternion
import Mathlib.Analysis.InnerProductSpace.Continuous
import Mathlib.Analysis.InnerProductSpace.PiL2
import Mathlib.Topology.Algebra.Algebra
/-!
# Quaternions as a normed algebra
In this file we define the following structures on the space `ℍ := ℍ[ℝ]` of quaternions:
* inner product space;
* normed ring;
* normed space over `ℝ`.
We show that the norm on `ℍ[ℝ]` agrees with the Euclidean norm of its components.
## Notation
The following notation is available with `open Quaternion` or `open scoped Quaternion`:
* `ℍ` : quaternions
## Tags
quaternion, normed ring, normed space, normed algebra
-/
@[inherit_doc] scoped[Quaternion] notation "ℍ" => Quaternion ℝ
open scoped RealInnerProductSpace
namespace Quaternion
instance : Inner ℝ ℍ :=
⟨fun a b => (a * star b).re⟩
theorem inner_self (a : ℍ) : ⟪a, a⟫ = normSq a :=
rfl
theorem inner_def (a b : ℍ) : ⟪a, b⟫ = (a * star b).re :=
rfl
noncomputable instance : NormedAddCommGroup ℍ :=
@InnerProductSpace.Core.toNormedAddCommGroup ℝ ℍ _ _ _
{ toInner := inferInstance
conj_inner_symm := fun x y => by simp [inner_def, mul_comm]
re_inner_nonneg := fun _ => normSq_nonneg
definite := fun _ => normSq_eq_zero.1
add_left := fun x y z => by simp only [inner_def, add_mul, re_add]
smul_left := fun x y r => by simp [inner_def] }
noncomputable instance : InnerProductSpace ℝ ℍ :=
InnerProductSpace.ofCore _
theorem normSq_eq_norm_mul_self (a : ℍ) : normSq a = ‖a‖ * ‖a‖ := by
rw [← inner_self, real_inner_self_eq_norm_mul_norm]
instance : NormOneClass ℍ :=
⟨by rw [norm_eq_sqrt_real_inner, inner_self, normSq.map_one, Real.sqrt_one]⟩
@[simp, norm_cast]
theorem norm_coe (a : ℝ) : ‖(a : ℍ)‖ = ‖a‖ := by
rw [norm_eq_sqrt_real_inner, inner_self, normSq_coe, Real.sqrt_sq_eq_abs, Real.norm_eq_abs]
@[simp, norm_cast]
theorem nnnorm_coe (a : ℝ) : ‖(a : ℍ)‖₊ = ‖a‖₊ :=
Subtype.ext <| norm_coe a
-- This does not need to be `@[simp]`, as it is a consequence of later simp lemmas.
theorem norm_star (a : ℍ) : ‖star a‖ = ‖a‖ := by
simp_rw [norm_eq_sqrt_real_inner, inner_self, normSq_star]
-- This does not need to be `@[simp]`, as it is a consequence of later simp lemmas.
theorem nnnorm_star (a : ℍ) : ‖star a‖₊ = ‖a‖₊ :=
Subtype.ext <| norm_star a
noncomputable instance : NormedDivisionRing ℍ where
dist_eq _ _ := rfl
norm_mul _ _ := by simp_rw [norm_eq_sqrt_real_inner, inner_self]; simp
noncomputable instance : NormedAlgebra ℝ ℍ where
norm_smul_le := norm_smul_le
toAlgebra := Quaternion.algebra
instance : CStarRing ℍ where
norm_mul_self_le x :=
le_of_eq <| Eq.symm <| (norm_mul _ _).trans <| congr_arg (· * ‖x‖) (norm_star x)
/-- Coercion from `ℂ` to `ℍ`. -/
@[coe] def coeComplex (z : ℂ) : ℍ := ⟨z.re, z.im, 0, 0⟩
instance : Coe ℂ ℍ := ⟨coeComplex⟩
@[simp, norm_cast]
theorem re_coeComplex (z : ℂ) : (z : ℍ).re = z.re :=
rfl
@[deprecated (since := "2025-08-31")] alias coeComplex_re := re_coeComplex
@[simp, norm_cast]
theorem imI_coeComplex (z : ℂ) : (z : ℍ).imI = z.im :=
rfl
@[deprecated (since := "2025-08-31")] alias coeComplex_imI := imI_coeComplex
@[simp, norm_cast]
theorem imJ_coeComplex (z : ℂ) : (z : ℍ).imJ = 0 :=
rfl
@[deprecated (since := "2025-08-31")] alias coeComplex_imJ := imJ_coeComplex
@[simp, norm_cast]
theorem imK_coeComplex (z : ℂ) : (z : ℍ).imK = 0 :=
rfl
@[deprecated (since := "2025-08-31")] alias coeComplex_imK := imK_coeComplex
@[simp, norm_cast]
theorem coeComplex_add (z w : ℂ) : ↑(z + w) = (z + w : ℍ) := by ext <;> simp
@[simp, norm_cast]
theorem coeComplex_mul (z w : ℂ) : ↑(z * w) = (z * w : ℍ) := by ext <;> simp
@[simp, norm_cast]
theorem coeComplex_zero : ((0 : ℂ) : ℍ) = 0 :=
rfl
@[simp, norm_cast]
theorem coeComplex_one : ((1 : ℂ) : ℍ) = 1 :=
rfl
@[simp, norm_cast]
theorem coe_real_complex_mul (r : ℝ) (z : ℂ) : (r • z : ℍ) = ↑r * ↑z := by ext <;> simp
@[simp, norm_cast]
theorem coeComplex_coe (r : ℝ) : ((r : ℂ) : ℍ) = r :=
rfl
/-- Coercion `ℂ →ₐ[ℝ] ℍ` as an algebra homomorphism. -/
def ofComplex : ℂ →ₐ[ℝ] ℍ where
toFun := (↑)
map_one' := rfl
map_zero' := rfl
map_add' := coeComplex_add
map_mul' := coeComplex_mul
commutes' _ := rfl
@[simp]
theorem coe_ofComplex : ⇑ofComplex = coeComplex := rfl
/-- The norm of the components as a Euclidean vector equals the norm of the quaternion. -/
lemma norm_toLp_equivTuple (x : ℍ) : ‖WithLp.toLp 2 (equivTuple ℝ x)‖ = ‖x‖ := by
rw [norm_eq_sqrt_real_inner, norm_eq_sqrt_real_inner, inner_self, normSq_def', PiLp.inner_apply,
Fin.sum_univ_four]
simp_rw [RCLike.inner_apply, starRingEnd_apply, star_trivial, ← sq]
rfl
/-- `QuaternionAlgebra.linearEquivTuple` as a `LinearIsometryEquiv`. -/
@[simps apply symm_apply]
noncomputable def linearIsometryEquivTuple : ℍ ≃ₗᵢ[ℝ] EuclideanSpace ℝ (Fin 4) :=
{ (QuaternionAlgebra.linearEquivTuple (-1 : ℝ) (0 : ℝ) (-1 : ℝ)).trans
(WithLp.linearEquiv 2 ℝ (Fin 4 → ℝ)).symm with
toFun := fun a => !₂[a.1, a.2, a.3, a.4]
invFun := fun a => ⟨a 0, a 1, a 2, a 3⟩
norm_map' := norm_toLp_equivTuple }
@[continuity]
theorem continuous_coe : Continuous (coe : ℝ → ℍ) :=
continuous_algebraMap ℝ ℍ
@[continuity]
theorem continuous_normSq : Continuous (normSq : ℍ → ℝ) := by
simpa [← normSq_eq_norm_mul_self] using
(continuous_norm.mul continuous_norm : Continuous fun q : ℍ => ‖q‖ * ‖q‖)
@[continuity]
theorem continuous_re : Continuous fun q : ℍ => q.re :=
(PiLp.continuous_apply 2 _ 0).comp linearIsometryEquivTuple.continuous
@[continuity]
theorem continuous_imI : Continuous fun q : ℍ => q.imI :=
(PiLp.continuous_apply 2 _ 1).comp linearIsometryEquivTuple.continuous
@[continuity]
theorem continuous_imJ : Continuous fun q : ℍ => q.imJ :=
(PiLp.continuous_apply 2 _ 2).comp linearIsometryEquivTuple.continuous
@[continuity]
theorem continuous_imK : Continuous fun q : ℍ => q.imK :=
(PiLp.continuous_apply 2 _ 3).comp linearIsometryEquivTuple.continuous
@[continuity]
theorem continuous_im : Continuous fun q : ℍ => q.im := by
simpa only [← sub_re_self] using continuous_id.sub (continuous_coe.comp continuous_re)
instance : CompleteSpace ℍ :=
haveI : IsUniformEmbedding linearIsometryEquivTuple.toLinearEquiv.toEquiv.symm :=
linearIsometryEquivTuple.toContinuousLinearEquiv.symm.isUniformEmbedding
(completeSpace_congr this).1 inferInstance
section infinite_sum
variable {α : Type*} {L : SummationFilter α}
@[simp, norm_cast]
theorem hasSum_coe {f : α → ℝ} {r : ℝ} : HasSum (fun a => (f a : ℍ)) (↑r : ℍ) L ↔ HasSum f r L :=
⟨fun h => by
simpa only using
h.map (show ℍ →ₗ[ℝ] ℝ from QuaternionAlgebra.reₗ _ _ _) continuous_re,
fun h => by simpa only using h.map (algebraMap ℝ ℍ) (continuous_algebraMap _ _)⟩
@[simp, norm_cast]
theorem summable_coe {f : α → ℝ} : (Summable (fun a => (f a : ℍ)) L) ↔ Summable f L := by
simpa only using
Summable.map_iff_of_leftInverse (algebraMap ℝ ℍ) (show ℍ →ₗ[ℝ] ℝ from
QuaternionAlgebra.reₗ _ _ _)
(continuous_algebraMap _ _) continuous_re re_coe
@[norm_cast]
theorem tsum_coe (f : α → ℝ) : (∑'[L] a, (f a : ℍ)) = ↑(∑'[L] a, f a) :=
(Function.LeftInverse.map_tsum f (continuous_algebraMap _ _) continuous_re re_coe).symm
end infinite_sum
end Quaternion |
.lake/packages/mathlib/Mathlib/Analysis/MeanInequalitiesPow.lean | import Mathlib.Analysis.Convex.Jensen
import Mathlib.Analysis.Convex.Mul
import Mathlib.Analysis.Convex.SpecificFunctions.Basic
import Mathlib.Analysis.SpecialFunctions.Pow.NNReal
/-!
# Mean value inequalities
In this file we prove several mean inequalities for finite sums. Versions for integrals of some of
these inequalities are available in `MeasureTheory.MeanInequalities`.
## Main theorems: generalized mean inequality
The inequality says that for two non-negative vectors $w$ and $z$ with $\sum_{i\in s} w_i=1$
and $p ≤ q$ we have
$$
\sqrt[p]{\sum_{i\in s} w_i z_i^p} ≤ \sqrt[q]{\sum_{i\in s} w_i z_i^q}.
$$
Currently we only prove this inequality for $p=1$. As in the rest of `Mathlib`, we provide
different theorems for natural exponents (`pow_arith_mean_le_arith_mean_pow`), integer exponents
(`zpow_arith_mean_le_arith_mean_zpow`), and real exponents (`rpow_arith_mean_le_arith_mean_rpow` and
`arith_mean_le_rpow_mean`). In the first two cases we prove
$$
\left(\sum_{i\in s} w_i z_i\right)^n ≤ \sum_{i\in s} w_i z_i^n
$$
in order to avoid using real exponents. For real exponents we prove both this and standard versions.
## TODO
- each inequality `A ≤ B` should come with a theorem `A = B ↔ _`; one of the ways to prove them
is to define `StrictConvexOn` functions.
- generalized mean inequality with any `p ≤ q`, including negative numbers;
- prove that the power mean tends to the geometric mean as the exponent tends to zero.
-/
universe u v
open Finset NNReal ENNReal
noncomputable section
variable {ι : Type u} (s : Finset ι)
namespace Real
theorem pow_arith_mean_le_arith_mean_pow (w z : ι → ℝ) (hw : ∀ i ∈ s, 0 ≤ w i)
(hw' : ∑ i ∈ s, w i = 1) (hz : ∀ i ∈ s, 0 ≤ z i) (n : ℕ) :
(∑ i ∈ s, w i * z i) ^ n ≤ ∑ i ∈ s, w i * z i ^ n :=
(convexOn_pow n).map_sum_le hw hw' hz
theorem pow_arith_mean_le_arith_mean_pow_of_even (w z : ι → ℝ) (hw : ∀ i ∈ s, 0 ≤ w i)
(hw' : ∑ i ∈ s, w i = 1) {n : ℕ} (hn : Even n) :
(∑ i ∈ s, w i * z i) ^ n ≤ ∑ i ∈ s, w i * z i ^ n :=
hn.convexOn_pow.map_sum_le hw hw' fun _ _ => Set.mem_univ _
theorem zpow_arith_mean_le_arith_mean_zpow (w z : ι → ℝ) (hw : ∀ i ∈ s, 0 ≤ w i)
(hw' : ∑ i ∈ s, w i = 1) (hz : ∀ i ∈ s, 0 < z i) (m : ℤ) :
(∑ i ∈ s, w i * z i) ^ m ≤ ∑ i ∈ s, w i * z i ^ m :=
(convexOn_zpow m).map_sum_le hw hw' hz
theorem rpow_arith_mean_le_arith_mean_rpow (w z : ι → ℝ) (hw : ∀ i ∈ s, 0 ≤ w i)
(hw' : ∑ i ∈ s, w i = 1) (hz : ∀ i ∈ s, 0 ≤ z i) {p : ℝ} (hp : 1 ≤ p) :
(∑ i ∈ s, w i * z i) ^ p ≤ ∑ i ∈ s, w i * z i ^ p :=
(convexOn_rpow hp).map_sum_le hw hw' hz
theorem arith_mean_le_rpow_mean (w z : ι → ℝ) (hw : ∀ i ∈ s, 0 ≤ w i) (hw' : ∑ i ∈ s, w i = 1)
(hz : ∀ i ∈ s, 0 ≤ z i) {p : ℝ} (hp : 1 ≤ p) :
∑ i ∈ s, w i * z i ≤ (∑ i ∈ s, w i * z i ^ p) ^ (1 / p) := by
have : 0 < p := by positivity
rw [← rpow_le_rpow_iff _ _ this, ← rpow_mul, one_div_mul_cancel (ne_of_gt this), rpow_one]
· exact rpow_arith_mean_le_arith_mean_rpow s w z hw hw' hz hp
all_goals
apply_rules [sum_nonneg, rpow_nonneg]
intro i hi
apply_rules [mul_nonneg, rpow_nonneg, hw i hi, hz i hi]
end Real
namespace NNReal
/-- Weighted generalized mean inequality, version sums over finite sets, with `ℝ≥0`-valued
functions and natural exponent. -/
theorem pow_arith_mean_le_arith_mean_pow (w z : ι → ℝ≥0) (hw' : ∑ i ∈ s, w i = 1) (n : ℕ) :
(∑ i ∈ s, w i * z i) ^ n ≤ ∑ i ∈ s, w i * z i ^ n :=
mod_cast
Real.pow_arith_mean_le_arith_mean_pow s _ _ (fun i _ => (w i).coe_nonneg)
(mod_cast hw') (fun i _ => (z i).coe_nonneg) n
/-- Weighted generalized mean inequality, version for sums over finite sets, with `ℝ≥0`-valued
functions and real exponents. -/
theorem rpow_arith_mean_le_arith_mean_rpow (w z : ι → ℝ≥0) (hw' : ∑ i ∈ s, w i = 1) {p : ℝ}
(hp : 1 ≤ p) : (∑ i ∈ s, w i * z i) ^ p ≤ ∑ i ∈ s, w i * z i ^ p :=
mod_cast
Real.rpow_arith_mean_le_arith_mean_rpow s _ _ (fun i _ => (w i).coe_nonneg)
(mod_cast hw') (fun i _ => (z i).coe_nonneg) hp
/-- Weighted generalized mean inequality, version for two elements of `ℝ≥0` and real exponents. -/
theorem rpow_arith_mean_le_arith_mean2_rpow (w₁ w₂ z₁ z₂ : ℝ≥0) (hw' : w₁ + w₂ = 1) {p : ℝ}
(hp : 1 ≤ p) : (w₁ * z₁ + w₂ * z₂) ^ p ≤ w₁ * z₁ ^ p + w₂ * z₂ ^ p := by
have h := rpow_arith_mean_le_arith_mean_rpow univ ![w₁, w₂] ![z₁, z₂] ?_ hp
· simpa [Fin.sum_univ_succ] using h
· simp [hw', Fin.sum_univ_succ]
/-- Unweighted mean inequality, version for two elements of `ℝ≥0` and real exponents. -/
theorem rpow_add_le_mul_rpow_add_rpow (z₁ z₂ : ℝ≥0) {p : ℝ} (hp : 1 ≤ p) :
(z₁ + z₂) ^ p ≤ (2 : ℝ≥0) ^ (p - 1) * (z₁ ^ p + z₂ ^ p) := by
rcases eq_or_lt_of_le hp with (rfl | h'p)
· simp only [rpow_one, sub_self, rpow_zero, one_mul]; rfl
convert rpow_arith_mean_le_arith_mean2_rpow (1 / 2) (1 / 2) (2 * z₁) (2 * z₂) (add_halves 1) hp
using 1
· simp only [one_div, inv_mul_cancel_left₀, Ne, two_ne_zero,
not_false_iff]
· have A : p - 1 ≠ 0 := ne_of_gt (sub_pos.2 h'p)
simp only [mul_rpow, rpow_sub' A, div_eq_inv_mul, rpow_one, mul_one]
ring
/-- Weighted generalized mean inequality, version for sums over finite sets, with `ℝ≥0`-valued
functions and real exponents. -/
theorem arith_mean_le_rpow_mean (w z : ι → ℝ≥0) (hw' : ∑ i ∈ s, w i = 1) {p : ℝ} (hp : 1 ≤ p) :
∑ i ∈ s, w i * z i ≤ (∑ i ∈ s, w i * z i ^ p) ^ (1 / p) :=
mod_cast
Real.arith_mean_le_rpow_mean s _ _ (fun i _ => (w i).coe_nonneg) (mod_cast hw')
(fun i _ => (z i).coe_nonneg) hp
private theorem add_rpow_le_one_of_add_le_one {p : ℝ} (a b : ℝ≥0) (hab : a + b ≤ 1) (hp1 : 1 ≤ p) :
a ^ p + b ^ p ≤ 1 := by
have h_le_one : ∀ x : ℝ≥0, x ≤ 1 → x ^ p ≤ x := fun x hx => rpow_le_self_of_le_one hx hp1
have ha : a ≤ 1 := (self_le_add_right a b).trans hab
have hb : b ≤ 1 := (self_le_add_left b a).trans hab
exact (add_le_add (h_le_one a ha) (h_le_one b hb)).trans hab
theorem add_rpow_le_rpow_add {p : ℝ} (a b : ℝ≥0) (hp1 : 1 ≤ p) : a ^ p + b ^ p ≤ (a + b) ^ p := by
have hp_pos : 0 < p := by positivity
by_cases h_zero : a + b = 0
· simp [add_eq_zero.mp h_zero, hp_pos.ne']
have h_nonzero : ¬(a = 0 ∧ b = 0) := by rwa [add_eq_zero] at h_zero
have h_add : a / (a + b) + b / (a + b) = 1 := by rw [← add_div, div_self h_zero]
have h := add_rpow_le_one_of_add_le_one (a / (a + b)) (b / (a + b)) h_add.le hp1
rw [div_rpow a (a + b), div_rpow b (a + b)] at h
have hab_0 : (a + b) ^ p ≠ 0 := by simp [h_nonzero]
have hab_0' : 0 < (a + b) ^ p := zero_lt_iff.mpr hab_0
have h_mul : (a + b) ^ p * (a ^ p / (a + b) ^ p + b ^ p / (a + b) ^ p) ≤ (a + b) ^ p := by
nth_rw 4 [← mul_one ((a + b) ^ p)]; gcongr
rwa [div_eq_mul_inv, div_eq_mul_inv, mul_add, mul_comm (a ^ p), mul_comm (b ^ p), ← mul_assoc, ←
mul_assoc, mul_inv_cancel₀ hab_0, one_mul, one_mul] at h_mul
theorem rpow_add_rpow_le_add {p : ℝ} (a b : ℝ≥0) (hp1 : 1 ≤ p) :
(a ^ p + b ^ p) ^ (1 / p) ≤ a + b := by
rw [one_div]
rw [← @NNReal.le_rpow_inv_iff _ _ p⁻¹ (by simp [lt_of_lt_of_le zero_lt_one hp1])]
rw [inv_inv]
exact add_rpow_le_rpow_add _ _ hp1
theorem rpow_add_rpow_le {p q : ℝ} (a b : ℝ≥0) (hp_pos : 0 < p) (hpq : p ≤ q) :
(a ^ q + b ^ q) ^ (1 / q) ≤ (a ^ p + b ^ p) ^ (1 / p) := by
have h_rpow : ∀ a : ℝ≥0, a ^ q = (a ^ p) ^ (q / p) := fun a => by
rw [← NNReal.rpow_mul, div_eq_inv_mul, ← mul_assoc, mul_inv_cancel₀ hp_pos.ne.symm,
one_mul]
have h_rpow_add_rpow_le_add :
((a ^ p) ^ (q / p) + (b ^ p) ^ (q / p)) ^ (1 / (q / p)) ≤ a ^ p + b ^ p := by
refine rpow_add_rpow_le_add (a ^ p) (b ^ p) ?_
rwa [one_le_div hp_pos]
rw [h_rpow a, h_rpow b, one_div p, NNReal.le_rpow_inv_iff hp_pos, ← NNReal.rpow_mul, mul_comm,
mul_one_div]
rwa [one_div_div] at h_rpow_add_rpow_le_add
theorem rpow_add_le_add_rpow {p : ℝ} (a b : ℝ≥0) (hp : 0 ≤ p) (hp1 : p ≤ 1) :
(a + b) ^ p ≤ a ^ p + b ^ p := by
rcases hp.eq_or_lt with (rfl | hp_pos)
· simp
have h := rpow_add_rpow_le a b hp_pos hp1
rw [one_div_one, one_div] at h
repeat' rw [NNReal.rpow_one] at h
exact (NNReal.le_rpow_inv_iff hp_pos).mp h
end NNReal
namespace Real
lemma add_rpow_le_rpow_add {p : ℝ} {a b : ℝ} (ha : 0 ≤ a) (hb : 0 ≤ b) (hp1 : 1 ≤ p) :
a ^ p + b ^ p ≤ (a + b) ^ p := by
lift a to NNReal using ha
lift b to NNReal using hb
exact_mod_cast NNReal.add_rpow_le_rpow_add a b hp1
lemma rpow_add_rpow_le_add {p : ℝ} {a b : ℝ} (ha : 0 ≤ a) (hb : 0 ≤ b) (hp1 : 1 ≤ p) :
(a ^ p + b ^ p) ^ (1 / p) ≤ a + b := by
lift a to NNReal using ha
lift b to NNReal using hb
exact_mod_cast NNReal.rpow_add_rpow_le_add a b hp1
lemma rpow_add_rpow_le {p q : ℝ} {a b : ℝ} (ha : 0 ≤ a) (hb : 0 ≤ b) (hp_pos : 0 < p)
(hpq : p ≤ q) :
(a ^ q + b ^ q) ^ (1 / q) ≤ (a ^ p + b ^ p) ^ (1 / p) := by
lift a to NNReal using ha
lift b to NNReal using hb
exact_mod_cast NNReal.rpow_add_rpow_le a b hp_pos hpq
lemma rpow_add_le_add_rpow {p : ℝ} {a b : ℝ} (ha : 0 ≤ a) (hb : 0 ≤ b) (hp : 0 ≤ p)
(hp1 : p ≤ 1) :
(a + b) ^ p ≤ a ^ p + b ^ p := by
lift a to NNReal using ha
lift b to NNReal using hb
exact_mod_cast NNReal.rpow_add_le_add_rpow a b hp hp1
end Real
namespace ENNReal
/-- Weighted generalized mean inequality, version for sums over finite sets, with `ℝ≥0∞`-valued
functions and real exponents. -/
theorem rpow_arith_mean_le_arith_mean_rpow (w z : ι → ℝ≥0∞) (hw' : ∑ i ∈ s, w i = 1) {p : ℝ}
(hp : 1 ≤ p) : (∑ i ∈ s, w i * z i) ^ p ≤ ∑ i ∈ s, w i * z i ^ p := by
have hp_pos : 0 < p := by positivity
have hp_nonneg : 0 ≤ p := by positivity
have hp_not_neg : ¬p < 0 := by simp [hp_nonneg]
have h_top_iff_rpow_top : ∀ (i : ι), i ∈ s → (w i * z i = ⊤ ↔ w i * z i ^ p = ⊤) := by
simp [ENNReal.mul_eq_top, hp_pos, hp_not_neg]
refine le_of_top_imp_top_of_toNNReal_le ?_ ?_
· -- first, prove `(∑ i ∈ s, w i * z i) ^ p = ⊤ → ∑ i ∈ s, (w i * z i ^ p) = ⊤`
rw [rpow_eq_top_iff, sum_eq_top, sum_eq_top]
grind
· -- second, suppose both `(∑ i ∈ s, w i * z i) ^ p ≠ ⊤` and `∑ i ∈ s, (w i * z i ^ p) ≠ ⊤`,
-- and prove `((∑ i ∈ s, w i * z i) ^ p).toNNReal ≤ (∑ i ∈ s, (w i * z i ^ p)).toNNReal`,
-- by using `NNReal.rpow_arith_mean_le_arith_mean_rpow`.
intro h_top_rpow_sum _
-- show hypotheses needed to put the `.toNNReal` inside the sums.
have h_top : ∀ a : ι, a ∈ s → w a * z a ≠ ⊤ :=
haveI h_top_sum : ∑ i ∈ s, w i * z i ≠ ⊤ := by
intro h
rw [h, top_rpow_of_pos hp_pos] at h_top_rpow_sum
exact h_top_rpow_sum rfl
fun a ha => (lt_top_of_sum_ne_top h_top_sum ha).ne
have h_top_rpow : ∀ a : ι, a ∈ s → w a * z a ^ p ≠ ⊤ := by
intro i hi
specialize h_top i hi
rwa [Ne, ← h_top_iff_rpow_top i hi]
-- put the `.toNNReal` inside the sums.
simp_rw [toNNReal_sum h_top_rpow, toNNReal_rpow, toNNReal_sum h_top, toNNReal_mul,
toNNReal_rpow]
-- use corresponding nnreal result
refine
NNReal.rpow_arith_mean_le_arith_mean_rpow s (fun i => (w i).toNNReal)
(fun i => (z i).toNNReal) ?_ hp
-- verify the hypothesis `∑ i ∈ s, (w i).toNNReal = 1`, using `∑ i ∈ s, w i = 1` .
have h_sum_nnreal : ∑ i ∈ s, w i = ↑(∑ i ∈ s, (w i).toNNReal) := by
rw [coe_finset_sum]
refine sum_congr rfl fun i hi => (coe_toNNReal ?_).symm
refine (lt_top_of_sum_ne_top ?_ hi).ne
exact hw'.symm ▸ ENNReal.one_ne_top
rwa [← coe_inj, ← h_sum_nnreal]
/-- Weighted generalized mean inequality, version for two elements of `ℝ≥0∞` and real
exponents. -/
theorem rpow_arith_mean_le_arith_mean2_rpow (w₁ w₂ z₁ z₂ : ℝ≥0∞) (hw' : w₁ + w₂ = 1) {p : ℝ}
(hp : 1 ≤ p) : (w₁ * z₁ + w₂ * z₂) ^ p ≤ w₁ * z₁ ^ p + w₂ * z₂ ^ p := by
have h := rpow_arith_mean_le_arith_mean_rpow univ ![w₁, w₂] ![z₁, z₂] ?_ hp
· simpa [Fin.sum_univ_succ] using h
· simp [hw', Fin.sum_univ_succ]
/-- Unweighted mean inequality, version for two elements of `ℝ≥0∞` and real exponents. -/
theorem rpow_add_le_mul_rpow_add_rpow (z₁ z₂ : ℝ≥0∞) {p : ℝ} (hp : 1 ≤ p) :
(z₁ + z₂) ^ p ≤ (2 : ℝ≥0∞) ^ (p - 1) * (z₁ ^ p + z₂ ^ p) := by
convert rpow_arith_mean_le_arith_mean2_rpow (1 / 2) (1 / 2) (2 * z₁) (2 * z₂)
(ENNReal.add_halves 1) hp using 1
· simp [← mul_assoc, ENNReal.inv_mul_cancel two_ne_zero ofNat_ne_top]
· simp only [mul_rpow_of_nonneg _ _ (zero_le_one.trans hp), rpow_sub _ _ two_ne_zero ofNat_ne_top,
ENNReal.div_eq_inv_mul, rpow_one, mul_one]
ring
theorem add_rpow_le_rpow_add {p : ℝ} (a b : ℝ≥0∞) (hp1 : 1 ≤ p) : a ^ p + b ^ p ≤ (a + b) ^ p := by
have hp_pos : 0 < p := by positivity
by_cases h_top : a + b = ⊤
· rw [← @ENNReal.rpow_eq_top_iff_of_pos (a + b) p hp_pos] at h_top
rw [h_top]
exact le_top
obtain ⟨ha_top, hb_top⟩ := add_ne_top.mp h_top
lift a to ℝ≥0 using ha_top
lift b to ℝ≥0 using hb_top
simpa [ENNReal.coe_rpow_of_nonneg _ hp_pos.le] using
ENNReal.coe_le_coe.2 (NNReal.add_rpow_le_rpow_add a b hp1)
theorem rpow_add_rpow_le_add {p : ℝ} (a b : ℝ≥0∞) (hp1 : 1 ≤ p) :
(a ^ p + b ^ p) ^ (1 / p) ≤ a + b := by
rw [one_div, ← @ENNReal.le_rpow_inv_iff _ _ p⁻¹ (by simp [lt_of_lt_of_le zero_lt_one hp1])]
rw [inv_inv]
exact add_rpow_le_rpow_add _ _ hp1
theorem rpow_add_rpow_le {p q : ℝ} (a b : ℝ≥0∞) (hp_pos : 0 < p) (hpq : p ≤ q) :
(a ^ q + b ^ q) ^ (1 / q) ≤ (a ^ p + b ^ p) ^ (1 / p) := by
have h_rpow : ∀ a : ℝ≥0∞, a ^ q = (a ^ p) ^ (q / p) := fun a => by
rw [← ENNReal.rpow_mul, mul_div_cancel₀ _ hp_pos.ne']
have h_rpow_add_rpow_le_add :
((a ^ p) ^ (q / p) + (b ^ p) ^ (q / p)) ^ (1 / (q / p)) ≤ a ^ p + b ^ p := by
refine rpow_add_rpow_le_add (a ^ p) (b ^ p) ?_
rwa [one_le_div hp_pos]
rw [h_rpow a, h_rpow b, one_div p, ENNReal.le_rpow_inv_iff hp_pos, ← ENNReal.rpow_mul, mul_comm,
mul_one_div]
rwa [one_div_div] at h_rpow_add_rpow_le_add
theorem rpow_add_le_add_rpow {p : ℝ} (a b : ℝ≥0∞) (hp : 0 ≤ p) (hp1 : p ≤ 1) :
(a + b) ^ p ≤ a ^ p + b ^ p := by
rcases hp.eq_or_lt with (rfl | hp_pos)
· simp
have h := rpow_add_rpow_le a b hp_pos hp1
rw [one_div_one, one_div] at h
repeat' rw [ENNReal.rpow_one] at h
exact (ENNReal.le_rpow_inv_iff hp_pos).mp h
end ENNReal |
.lake/packages/mathlib/Mathlib/Analysis/BoundedVariation.lean | import Mathlib.Analysis.Calculus.FDeriv.Equiv
import Mathlib.Analysis.Calculus.FDeriv.Prod
import Mathlib.Analysis.Calculus.Monotone
import Mathlib.Topology.EMetricSpace.BoundedVariation
/-!
# Almost everywhere differentiability of functions with locally bounded variation
In this file we show that a bounded variation function is differentiable almost everywhere.
This implies that Lipschitz functions from the real line into finite-dimensional vector space
are also differentiable almost everywhere.
## Main definitions and results
* `LocallyBoundedVariationOn.ae_differentiableWithinAt` shows that a bounded variation
function on a subset of ℝ into a finite-dimensional real vector space is differentiable almost
everywhere, with `DifferentiableWithinAt` in its conclusion.
* `BoundedVariationOn.ae_differentiableAt_of_mem_uIcc` shows that a bounded variation function on
an interval of ℝ into a finite-dimensional real vector space is differentiable almost everywhere,
with `DifferentiableAt` in its conclusion.
* `LipschitzOnWith.ae_differentiableWithinAt` is the same result for Lipschitz functions.
We also give several variations around these results.
-/
open scoped NNReal Topology
open Set MeasureTheory Filter
variable {V : Type*} [NormedAddCommGroup V] [NormedSpace ℝ V] [FiniteDimensional ℝ V]
namespace LocallyBoundedVariationOn
/-- A bounded variation function into `ℝ` is differentiable almost everywhere. Superseded by
`ae_differentiableWithinAt_of_mem`. -/
theorem ae_differentiableWithinAt_of_mem_real {f : ℝ → ℝ} {s : Set ℝ}
(h : LocallyBoundedVariationOn f s) : ∀ᵐ x, x ∈ s → DifferentiableWithinAt ℝ f s x := by
obtain ⟨p, q, hp, hq, rfl⟩ : ∃ p q, MonotoneOn p s ∧ MonotoneOn q s ∧ f = p - q :=
h.exists_monotoneOn_sub_monotoneOn
filter_upwards [hp.ae_differentiableWithinAt_of_mem, hq.ae_differentiableWithinAt_of_mem] with
x hxp hxq xs
exact (hxp xs).sub (hxq xs)
/-- A bounded variation function into a finite-dimensional product vector space is differentiable
almost everywhere. Superseded by `ae_differentiableWithinAt_of_mem`. -/
theorem ae_differentiableWithinAt_of_mem_pi {ι : Type*} [Fintype ι] {f : ℝ → ι → ℝ} {s : Set ℝ}
(h : LocallyBoundedVariationOn f s) : ∀ᵐ x, x ∈ s → DifferentiableWithinAt ℝ f s x := by
have A : ∀ i : ι, LipschitzWith 1 fun x : ι → ℝ => x i := fun i => LipschitzWith.eval i
have : ∀ i : ι, ∀ᵐ x, x ∈ s → DifferentiableWithinAt ℝ (fun x : ℝ => f x i) s x := fun i ↦ by
apply ae_differentiableWithinAt_of_mem_real
exact LipschitzWith.comp_locallyBoundedVariationOn (A i) h
filter_upwards [ae_all_iff.2 this] with x hx xs
exact differentiableWithinAt_pi.2 fun i => hx i xs
/-- A real function into a finite-dimensional real vector space with bounded variation on a set
is differentiable almost everywhere in this set. -/
theorem ae_differentiableWithinAt_of_mem {f : ℝ → V} {s : Set ℝ}
(h : LocallyBoundedVariationOn f s) : ∀ᵐ x, x ∈ s → DifferentiableWithinAt ℝ f s x := by
let A := (Module.Basis.ofVectorSpace ℝ V).equivFun.toContinuousLinearEquiv
suffices H : ∀ᵐ x, x ∈ s → DifferentiableWithinAt ℝ (A ∘ f) s x by
filter_upwards [H] with x hx xs
have : f = (A.symm ∘ A) ∘ f := by
simp only [ContinuousLinearEquiv.symm_comp_self, Function.id_comp]
rw [this]
exact A.symm.differentiableAt.comp_differentiableWithinAt x (hx xs)
apply ae_differentiableWithinAt_of_mem_pi
exact A.lipschitz.comp_locallyBoundedVariationOn h
/-- A real function into a finite-dimensional real vector space with bounded variation on an
interval is differentiable almost everywhere in this interval. This one differs from
`LocallyBoundedVariationOn.ae_differentiableWithinAt_of_mem` by using `DifferentiableAt` instead of
`DifferentiableWithinAt` in its conclusion. -/
theorem _root_.BoundedVariationOn.ae_differentiableAt_of_mem_uIcc {f : ℝ → V} {a b : ℝ}
(h : BoundedVariationOn f (uIcc a b)) : ∀ᵐ x, x ∈ uIcc a b → DifferentiableAt ℝ f x := by
have h₁ : ∀ᵐ x, x ≠ min a b := by simp [ae_iff, measure_singleton]
have h₂ : ∀ᵐ x, x ≠ max a b := by simp [ae_iff, measure_singleton]
filter_upwards [h.locallyBoundedVariationOn.ae_differentiableWithinAt_of_mem, h₁, h₂]
with x hx₁ hx₂ hx₃ hx₄
rw [uIcc, mem_Icc] at hx₄
exact (hx₁ hx₄).differentiableAt
(Icc_mem_nhds (lt_of_le_of_ne hx₄.left hx₂.symm) (lt_of_le_of_ne hx₄.right hx₃))
/-- A real function into a finite-dimensional real vector space with bounded variation on a set
is differentiable almost everywhere in this set. -/
theorem ae_differentiableWithinAt {f : ℝ → V} {s : Set ℝ} (h : LocallyBoundedVariationOn f s)
(hs : MeasurableSet s) : ∀ᵐ x ∂volume.restrict s, DifferentiableWithinAt ℝ f s x := by
rw [ae_restrict_iff' hs]
exact h.ae_differentiableWithinAt_of_mem
/-- A real function into a finite-dimensional real vector space with bounded variation
is differentiable almost everywhere. -/
theorem ae_differentiableAt {f : ℝ → V} (h : LocallyBoundedVariationOn f univ) :
∀ᵐ x, DifferentiableAt ℝ f x := by
filter_upwards [h.ae_differentiableWithinAt_of_mem] with x hx
rw [differentiableWithinAt_univ] at hx
exact hx (mem_univ _)
end LocallyBoundedVariationOn
/-- A real function into a finite-dimensional real vector space which is Lipschitz on a set
is differentiable almost everywhere in this set. For the general Rademacher theorem assuming
that the source space is finite dimensional, see `LipschitzOnWith.ae_differentiableWithinAt_of_mem`.
-/
theorem LipschitzOnWith.ae_differentiableWithinAt_of_mem_real {C : ℝ≥0} {f : ℝ → V} {s : Set ℝ}
(h : LipschitzOnWith C f s) : ∀ᵐ x, x ∈ s → DifferentiableWithinAt ℝ f s x :=
h.locallyBoundedVariationOn.ae_differentiableWithinAt_of_mem
/-- A real function into a finite-dimensional real vector space which is Lipschitz on a set
is differentiable almost everywhere in this set. For the general Rademacher theorem assuming
that the source space is finite dimensional, see `LipschitzOnWith.ae_differentiableWithinAt`. -/
theorem LipschitzOnWith.ae_differentiableWithinAt_real {C : ℝ≥0} {f : ℝ → V} {s : Set ℝ}
(h : LipschitzOnWith C f s) (hs : MeasurableSet s) :
∀ᵐ x ∂volume.restrict s, DifferentiableWithinAt ℝ f s x :=
h.locallyBoundedVariationOn.ae_differentiableWithinAt hs
/-- A real Lipschitz function into a finite-dimensional real vector space is differentiable
almost everywhere. For the general Rademacher theorem assuming
that the source space is finite dimensional, see `LipschitzWith.ae_differentiableAt`. -/
theorem LipschitzWith.ae_differentiableAt_real {C : ℝ≥0} {f : ℝ → V} (h : LipschitzWith C f) :
∀ᵐ x, DifferentiableAt ℝ f x :=
(h.locallyBoundedVariationOn univ).ae_differentiableAt |
.lake/packages/mathlib/Mathlib/Analysis/PSeriesComplex.lean | import Mathlib.Analysis.Normed.Module.FiniteDimension
import Mathlib.Analysis.PSeries
import Mathlib.LinearAlgebra.Complex.FiniteDimensional
/-!
# Convergence of `p`-series (complex case)
Here we show convergence of `∑ n : ℕ, 1 / n ^ p` for complex `p`. This is done in a separate file
rather than in `Analysis.PSeries` in order to keep the prerequisites of the former relatively light.
## Tags
p-series, Cauchy condensation test
-/
lemma Complex.summable_one_div_nat_cpow {p : ℂ} :
Summable (fun n : ℕ ↦ 1 / (n : ℂ) ^ p) ↔ 1 < re p := by
rw [← Real.summable_one_div_nat_rpow, ← summable_nat_add_iff 1 (G := ℝ),
← summable_nat_add_iff 1 (G := ℂ), ← summable_norm_iff]
simp only [norm_div, norm_one, ← ofReal_natCast, norm_cpow_eq_rpow_re_of_pos
(Nat.cast_pos.mpr <| Nat.succ_pos _)] |
.lake/packages/mathlib/Mathlib/Analysis/SumIntegralComparisons.lean | import Mathlib.MeasureTheory.Integral.IntervalIntegral.Basic
import Mathlib.Data.Set.Function
/-!
# Comparing sums and integrals
## Summary
It is often the case that error terms in analysis can be computed by comparing
an infinite sum to the improper integral of an antitone function. This file will eventually enable
that.
At the moment it contains several lemmas in this direction, for antitone or monotone functions
(or products of antitone and monotone functions), formulated for sums on `range i` or `Ico a b`.
`TODO`: Add more lemmas to the API to directly address limiting issues
## Main Results
* `AntitoneOn.integral_le_sum`: The integral of an antitone function is at most the sum of its
values at integer steps aligning with the left-hand side of the interval
* `AntitoneOn.sum_le_integral`: The sum of an antitone function along integer steps aligning with
the right-hand side of the interval is at most the integral of the function along that interval
* `MonotoneOn.integral_le_sum`: The integral of a monotone function is at most the sum of its
values at integer steps aligning with the right-hand side of the interval
* `MonotoneOn.sum_le_integral`: The sum of a monotone function along integer steps aligning with
the left-hand side of the interval is at most the integral of the function along that interval
* `sum_mul_Ico_le_integral_of_monotone_antitone`: the sum of `f i * g i` on an interval is bounded
by the integral of `f x * g (x - 1)` if `f` is monotone and `g` is antitone.
* `integral_le_sum_mul_Ico_of_antitone_monotone`: the sum of `f i * g i` on an interval is bounded
below by the integral of `f x * g (x - 1)` if `f` is antitone and `g` is monotone.
## Tags
analysis, comparison, asymptotics
-/
open Set MeasureTheory MeasureSpace
variable {x₀ : ℝ} {a b : ℕ} {f g : ℝ → ℝ}
lemma sum_Ico_le_integral_of_le
(hab : a ≤ b) (h : ∀ i ∈ Ico a b, ∀ x ∈ Ico (i : ℝ) (i + 1 : ℕ), f i ≤ g x)
(hg : IntegrableOn g (Set.Ico a b)) :
∑ i ∈ Finset.Ico a b, f i ≤ ∫ x in a..b, g x := by
have A i (hi : i ∈ Finset.Ico a b) : IntervalIntegrable g volume i (i + 1 : ℕ) := by
rw [intervalIntegrable_iff_integrableOn_Ico_of_le (by simp)]
apply hg.mono _ le_rfl
rintro x ⟨hx, h'x⟩
simp only [Finset.mem_Ico, mem_Ico] at hi ⊢
exact ⟨le_trans (mod_cast hi.1) hx, h'x.trans_le (mod_cast hi.2)⟩
calc
∑ i ∈ Finset.Ico a b, f i
_ = ∑ i ∈ Finset.Ico a b, (∫ x in (i : ℝ)..(i + 1 : ℕ), f i) := by simp
_ ≤ ∑ i ∈ Finset.Ico a b, (∫ x in (i : ℝ)..(i + 1 : ℕ), g x) := by
gcongr with i hi
apply intervalIntegral.integral_mono_on_of_le_Ioo (by simp) (by simp) (A _ hi) (fun x hx ↦ ?_)
exact h _ (by simpa using hi) _ (Ioo_subset_Ico_self hx)
_ = ∫ x in a..b, g x := by
rw [intervalIntegral.sum_integral_adjacent_intervals_Ico (a := fun i ↦ i) hab]
intro i hi
exact A _ (by simpa using hi)
lemma integral_le_sum_Ico_of_le
(hab : a ≤ b) (h : ∀ i ∈ Ico a b, ∀ x ∈ Ico (i : ℝ) (i + 1 : ℕ), g x ≤ f i)
(hg : IntegrableOn g (Set.Ico a b)) :
∫ x in a..b, g x ≤ ∑ i ∈ Finset.Ico a b, f i := by
convert neg_le_neg (sum_Ico_le_integral_of_le (f := -f) (g := -g) hab
(fun i hi x hx ↦ neg_le_neg (h i hi x hx)) hg.neg) <;> simp
theorem AntitoneOn.integral_le_sum (hf : AntitoneOn f (Icc x₀ (x₀ + a))) :
(∫ x in x₀..x₀ + a, f x) ≤ ∑ i ∈ Finset.range a, f (x₀ + i) := by
have hint : ∀ k : ℕ, k < a → IntervalIntegrable f volume (x₀ + k) (x₀ + (k + 1 : ℕ)) := by
intro k hk
refine (hf.mono ?_).intervalIntegrable
rw [uIcc_of_le]
· apply Icc_subset_Icc
· simp only [le_add_iff_nonneg_right, Nat.cast_nonneg]
· simp only [add_le_add_iff_left, Nat.cast_le, Nat.succ_le_of_lt hk]
· simp only [add_le_add_iff_left, Nat.cast_le, Nat.le_succ]
calc
∫ x in x₀..x₀ + a, f x = ∑ i ∈ Finset.range a, ∫ x in x₀ + i..x₀ + (i + 1 : ℕ), f x := by
convert (intervalIntegral.sum_integral_adjacent_intervals hint).symm
simp only [Nat.cast_zero, add_zero]
_ ≤ ∑ i ∈ Finset.range a, ∫ _ in x₀ + i..x₀ + (i + 1 : ℕ), f (x₀ + i) := by
apply Finset.sum_le_sum fun i hi => ?_
have ia : i < a := Finset.mem_range.1 hi
refine intervalIntegral.integral_mono_on (by simp) (hint _ ia) (by simp) fun x hx => ?_
apply hf _ _ hx.1
· simp only [ia.le, mem_Icc, le_add_iff_nonneg_right, Nat.cast_nonneg, add_le_add_iff_left,
Nat.cast_le, and_self_iff]
· refine mem_Icc.2 ⟨le_trans (by simp) hx.1, le_trans hx.2 ?_⟩
simp only [add_le_add_iff_left, Nat.cast_le, Nat.succ_le_of_lt ia]
_ = ∑ i ∈ Finset.range a, f (x₀ + i) := by simp
theorem AntitoneOn.integral_le_sum_Ico (hab : a ≤ b) (hf : AntitoneOn f (Set.Icc a b)) :
(∫ x in a..b, f x) ≤ ∑ x ∈ Finset.Ico a b, f x := by
rw [(Nat.sub_add_cancel hab).symm, Nat.cast_add]
conv =>
congr
congr
· skip
· skip
rw [add_comm]
· skip
· skip
congr
congr
rw [← zero_add a]
rw [← Finset.sum_Ico_add, Nat.Ico_zero_eq_range]
conv =>
rhs
congr
· skip
ext
rw [Nat.cast_add]
apply AntitoneOn.integral_le_sum
simp only [hf, hab, Nat.cast_sub, add_sub_cancel]
theorem AntitoneOn.sum_le_integral (hf : AntitoneOn f (Icc x₀ (x₀ + a))) :
(∑ i ∈ Finset.range a, f (x₀ + (i + 1 : ℕ))) ≤ ∫ x in x₀..x₀ + a, f x := by
have hint : ∀ k : ℕ, k < a → IntervalIntegrable f volume (x₀ + k) (x₀ + (k + 1 : ℕ)) := by
intro k hk
refine (hf.mono ?_).intervalIntegrable
rw [uIcc_of_le]
· apply Icc_subset_Icc
· simp only [le_add_iff_nonneg_right, Nat.cast_nonneg]
· simp only [add_le_add_iff_left, Nat.cast_le, Nat.succ_le_of_lt hk]
· simp only [add_le_add_iff_left, Nat.cast_le, Nat.le_succ]
calc
(∑ i ∈ Finset.range a, f (x₀ + (i + 1 : ℕ))) =
∑ i ∈ Finset.range a, ∫ _ in x₀ + i..x₀ + (i + 1 : ℕ), f (x₀ + (i + 1 : ℕ)) := by simp
_ ≤ ∑ i ∈ Finset.range a, ∫ x in x₀ + i..x₀ + (i + 1 : ℕ), f x := by
apply Finset.sum_le_sum fun i hi => ?_
have ia : i + 1 ≤ a := Finset.mem_range.1 hi
refine intervalIntegral.integral_mono_on (by simp) (by simp) (hint _ ia) fun x hx => ?_
apply hf _ _ hx.2
· refine mem_Icc.2 ⟨le_trans (le_add_of_nonneg_right (Nat.cast_nonneg _)) hx.1,
le_trans hx.2 ?_⟩
simp only [Nat.cast_le, add_le_add_iff_left, ia]
· refine mem_Icc.2 ⟨le_add_of_nonneg_right (Nat.cast_nonneg _), ?_⟩
simp only [add_le_add_iff_left, Nat.cast_le, ia]
_ = ∫ x in x₀..x₀ + a, f x := by
convert intervalIntegral.sum_integral_adjacent_intervals hint
simp only [Nat.cast_zero, add_zero]
theorem AntitoneOn.sum_le_integral_Ico (hab : a ≤ b) (hf : AntitoneOn f (Set.Icc a b)) :
(∑ i ∈ Finset.Ico a b, f (i + 1 : ℕ)) ≤ ∫ x in a..b, f x := by
rw [(Nat.sub_add_cancel hab).symm, Nat.cast_add]
conv =>
congr
congr
congr
rw [← zero_add a]
· skip
· skip
· skip
rw [add_comm]
rw [← Finset.sum_Ico_add, Nat.Ico_zero_eq_range]
conv =>
lhs
congr
congr
· skip
ext
rw [add_assoc, Nat.cast_add]
apply AntitoneOn.sum_le_integral
simp only [hf, hab, Nat.cast_sub, add_sub_cancel]
theorem MonotoneOn.sum_le_integral (hf : MonotoneOn f (Icc x₀ (x₀ + a))) :
(∑ i ∈ Finset.range a, f (x₀ + i)) ≤ ∫ x in x₀..x₀ + a, f x := by
rw [← neg_le_neg_iff, ← Finset.sum_neg_distrib, ← intervalIntegral.integral_neg]
exact hf.neg.integral_le_sum
theorem MonotoneOn.sum_le_integral_Ico (hab : a ≤ b) (hf : MonotoneOn f (Set.Icc a b)) :
∑ x ∈ Finset.Ico a b, f x ≤ ∫ x in a..b, f x := by
rw [← neg_le_neg_iff, ← Finset.sum_neg_distrib, ← intervalIntegral.integral_neg]
exact hf.neg.integral_le_sum_Ico hab
theorem MonotoneOn.integral_le_sum (hf : MonotoneOn f (Icc x₀ (x₀ + a))) :
(∫ x in x₀..x₀ + a, f x) ≤ ∑ i ∈ Finset.range a, f (x₀ + (i + 1 : ℕ)) := by
rw [← neg_le_neg_iff, ← Finset.sum_neg_distrib, ← intervalIntegral.integral_neg]
exact hf.neg.sum_le_integral
theorem MonotoneOn.integral_le_sum_Ico (hab : a ≤ b) (hf : MonotoneOn f (Set.Icc a b)) :
(∫ x in a..b, f x) ≤ ∑ i ∈ Finset.Ico a b, f (i + 1 : ℕ) := by
rw [← neg_le_neg_iff, ← Finset.sum_neg_distrib, ← intervalIntegral.integral_neg]
exact hf.neg.sum_le_integral_Ico hab
lemma sum_mul_Ico_le_integral_of_monotone_antitone
(hab : a ≤ b) (hf : MonotoneOn f (Icc a b)) (hg : AntitoneOn g (Icc (a - 1) (b - 1)))
(fpos : 0 ≤ f a) (gpos : 0 ≤ g (b - 1)) :
∑ i ∈ Finset.Ico a b, f i * g i ≤ ∫ x in a..b, f x * g (x - 1) := by
apply sum_Ico_le_integral_of_le (f := fun x ↦ f x * g x) hab
· intro i hi x hx
simp only [Nat.cast_add, Nat.cast_one, mem_Ico] at hx hi
have I0 : (i : ℝ) ≤ b - 1 := by
simp only [le_sub_iff_add_le]
norm_cast
omega
have I1 : (i : ℝ) ∈ Icc (a - 1 : ℝ) (b - 1) := by
simp only [mem_Icc, tsub_le_iff_right]
exact ⟨by norm_cast; cutsat, I0⟩
have I2 : x ∈ Icc (a : ℝ) b := by
refine ⟨le_trans (mod_cast hi.1) hx.1, hx.2.le.trans ?_⟩
norm_cast
omega
apply mul_le_mul
· apply hf
· simp only [mem_Icc, Nat.cast_le]
exact ⟨hi.1, hi.2.le⟩
· exact I2
· exact hx.1
· apply hg
· simp only [mem_Icc, tsub_le_iff_right, sub_add_cancel]
refine ⟨le_trans (mod_cast hi.1) hx.1, hx.2.le.trans ?_⟩
norm_cast
cutsat
· exact I1
· simpa [sub_le_iff_le_add] using hx.2.le
· apply gpos.trans
apply hg I1 (by simp [hab]) I0
· apply fpos.trans
apply hf (by simp [hab]) I2
exact le_trans (mod_cast hi.1) hx.1
· apply Integrable.mono_measure _ (Measure.restrict_mono_set _ Ico_subset_Icc_self)
apply Integrable.mul_of_top_left
· exact hf.integrableOn_isCompact isCompact_Icc
· apply AntitoneOn.memLp_isCompact isCompact_Icc
intro x hx y hy hxy
apply hg
· simpa using hx
· simpa using hy
· simpa using hxy
lemma integral_le_sum_mul_Ico_of_antitone_monotone
(hab : a ≤ b) (hf : AntitoneOn f (Icc a b)) (hg : MonotoneOn g (Icc (a - 1) (b - 1)))
(fpos : 0 ≤ f b) (gpos : 0 ≤ g (a - 1)) :
∫ x in a..b, f x * g (x - 1) ≤ ∑ i ∈ Finset.Ico a b, f i * g i := by
apply integral_le_sum_Ico_of_le (f := fun x ↦ f x * g x) hab
· intro i hi x hx
simp only [Nat.cast_add, Nat.cast_one, mem_Ico] at hx hi
have I0 : (i : ℝ) ≤ b - 1 := by
simp only [le_sub_iff_add_le]
norm_cast
omega
have I1 : (i : ℝ) ∈ Icc (a - 1 : ℝ) (b - 1) := by
simp only [mem_Icc, tsub_le_iff_right]
exact ⟨by norm_cast; cutsat, I0⟩
have I2 : x ∈ Icc (a : ℝ) b := by
refine ⟨le_trans (mod_cast hi.1) hx.1, hx.2.le.trans ?_⟩
norm_cast
omega
apply mul_le_mul
· apply hf
· simp only [mem_Icc, Nat.cast_le]
exact ⟨hi.1, hi.2.le⟩
· exact I2
· exact hx.1
· apply hg
· simp only [mem_Icc, tsub_le_iff_right, sub_add_cancel]
refine ⟨le_trans (mod_cast hi.1) hx.1, hx.2.le.trans ?_⟩
norm_cast
cutsat
· exact I1
· simpa [sub_le_iff_le_add] using hx.2.le
· apply gpos.trans
apply hg (by simp [hab]) (by simpa using I2) (by simpa using I2.1)
· apply fpos.trans
apply hf ⟨mod_cast hi.1, mod_cast hi.2.le⟩ (by simpa using hab) (mod_cast hi.2.le)
· apply Integrable.mono_measure _ (Measure.restrict_mono_set _ Ico_subset_Icc_self)
apply Integrable.mul_of_top_left
· exact hf.integrableOn_isCompact isCompact_Icc
· apply MonotoneOn.memLp_isCompact isCompact_Icc
intro x hx y hy hxy
apply hg
· simpa using hx
· simpa using hy
· simpa using hxy |
.lake/packages/mathlib/Mathlib/Analysis/Seminorm.lean | import Mathlib.Algebra.Order.Pi
import Mathlib.Analysis.Convex.Function
import Mathlib.Analysis.LocallyConvex.Basic
import Mathlib.Analysis.Normed.Module.Basic
import Mathlib.Data.Real.Pointwise
/-!
# Seminorms
This file defines seminorms.
A seminorm is a function to the reals which is positive-semidefinite, absolutely homogeneous, and
subadditive. They are closely related to convex sets, and a topological vector space is locally
convex if and only if its topology is induced by a family of seminorms.
## Main declarations
For a module over a normed ring:
* `Seminorm`: A function to the reals that is positive-semidefinite, absolutely homogeneous, and
subadditive.
* `normSeminorm 𝕜 E`: The norm on `E` as a seminorm.
## References
* [H. H. Schaefer, *Topological Vector Spaces*][schaefer1966]
## Tags
seminorm, locally convex, LCTVS
-/
assert_not_exists balancedCore
open NormedField Set Filter
open scoped NNReal Pointwise Topology Uniformity
variable {R R' 𝕜 𝕜₂ 𝕜₃ 𝕝 E E₂ E₃ F ι : Type*}
/-- A seminorm on a module over a normed ring is a function to the reals that is positive
semidefinite, positive homogeneous, and subadditive. -/
structure Seminorm (𝕜 : Type*) (E : Type*) [SeminormedRing 𝕜] [AddGroup E] [SMul 𝕜 E] extends
AddGroupSeminorm E where
/-- The seminorm of a scalar multiplication is the product of the absolute value of the scalar
and the original seminorm. -/
smul' : ∀ (a : 𝕜) (x : E), toFun (a • x) = ‖a‖ * toFun x
attribute [nolint docBlame] Seminorm.toAddGroupSeminorm
/-- `SeminormClass F 𝕜 E` states that `F` is a type of seminorms on the `𝕜`-module `E`.
You should extend this class when you extend `Seminorm`. -/
class SeminormClass (F : Type*) (𝕜 E : outParam Type*) [SeminormedRing 𝕜] [AddGroup E]
[SMul 𝕜 E] [FunLike F E ℝ] : Prop extends AddGroupSeminormClass F E ℝ where
/-- The seminorm of a scalar multiplication is the product of the absolute value of the scalar
and the original seminorm. -/
map_smul_eq_mul (f : F) (a : 𝕜) (x : E) : f (a • x) = ‖a‖ * f x
export SeminormClass (map_smul_eq_mul)
section Of
/-- Alternative constructor for a `Seminorm` on an `AddCommGroup E` that is a module over a
`SeminormedRing 𝕜`. -/
def Seminorm.of [SeminormedRing 𝕜] [AddCommGroup E] [Module 𝕜 E] (f : E → ℝ)
(add_le : ∀ x y : E, f (x + y) ≤ f x + f y) (smul : ∀ (a : 𝕜) (x : E), f (a • x) = ‖a‖ * f x) :
Seminorm 𝕜 E where
toFun := f
map_zero' := by rw [← zero_smul 𝕜 (0 : E), smul, norm_zero, zero_mul]
add_le' := add_le
smul' := smul
neg' x := by rw [← neg_one_smul 𝕜, smul, norm_neg, ← smul, one_smul]
/-- Alternative constructor for a `Seminorm` over a normed field `𝕜` that only assumes `f 0 = 0`
and an inequality for the scalar multiplication. -/
def Seminorm.ofSMulLE [NormedField 𝕜] [AddCommGroup E] [Module 𝕜 E] (f : E → ℝ) (map_zero : f 0 = 0)
(add_le : ∀ x y, f (x + y) ≤ f x + f y) (smul_le : ∀ (r : 𝕜) (x), f (r • x) ≤ ‖r‖ * f x) :
Seminorm 𝕜 E :=
Seminorm.of f add_le fun r x => by
refine le_antisymm (smul_le r x) ?_
by_cases h : r = 0
· simp [h, map_zero]
rw [← mul_le_mul_iff_right₀ (inv_pos.mpr (norm_pos_iff.mpr h))]
rw [inv_mul_cancel_left₀ (norm_ne_zero_iff.mpr h)]
specialize smul_le r⁻¹ (r • x)
rw [norm_inv] at smul_le
convert smul_le
simp [h]
end Of
namespace Seminorm
section SeminormedRing
variable [SeminormedRing 𝕜]
section AddGroup
variable [AddGroup E]
section SMul
variable [SMul 𝕜 E]
instance instFunLike : FunLike (Seminorm 𝕜 E) E ℝ where
coe f := f.toFun
coe_injective' f g h := by
rcases f with ⟨⟨_⟩⟩
rcases g with ⟨⟨_⟩⟩
congr
instance instSeminormClass : SeminormClass (Seminorm 𝕜 E) 𝕜 E where
map_zero f := f.map_zero'
map_add_le_add f := f.add_le'
map_neg_eq_map f := f.neg'
map_smul_eq_mul f := f.smul'
@[ext]
theorem ext {p q : Seminorm 𝕜 E} (h : ∀ x, (p : E → ℝ) x = q x) : p = q :=
DFunLike.ext p q h
instance instZero : Zero (Seminorm 𝕜 E) :=
⟨{ AddGroupSeminorm.instZeroAddGroupSeminorm.zero with
smul' := fun _ _ => (mul_zero _).symm }⟩
@[simp]
theorem coe_zero : ⇑(0 : Seminorm 𝕜 E) = 0 :=
rfl
@[simp]
theorem zero_apply (x : E) : (0 : Seminorm 𝕜 E) x = 0 :=
rfl
instance : Inhabited (Seminorm 𝕜 E) :=
⟨0⟩
variable (p : Seminorm 𝕜 E) (x : E) (r : ℝ)
/-- Any action on `ℝ` which factors through `ℝ≥0` applies to a seminorm. -/
instance instSMul [SMul R ℝ] [SMul R ℝ≥0] [IsScalarTower R ℝ≥0 ℝ] : SMul R (Seminorm 𝕜 E) where
smul r p :=
{ r • p.toAddGroupSeminorm with
toFun := fun x => r • p x
smul' := fun _ _ => by
simp only [← smul_one_smul ℝ≥0 r (_ : ℝ), NNReal.smul_def, smul_eq_mul]
rw [map_smul_eq_mul, mul_left_comm] }
instance [SMul R ℝ] [SMul R ℝ≥0] [IsScalarTower R ℝ≥0 ℝ] [SMul R' ℝ] [SMul R' ℝ≥0]
[IsScalarTower R' ℝ≥0 ℝ] [SMul R R'] [IsScalarTower R R' ℝ] :
IsScalarTower R R' (Seminorm 𝕜 E) where
smul_assoc r a p := ext fun x => smul_assoc r a (p x)
theorem coe_smul [SMul R ℝ] [SMul R ℝ≥0] [IsScalarTower R ℝ≥0 ℝ] (r : R) (p : Seminorm 𝕜 E) :
⇑(r • p) = r • ⇑p :=
rfl
@[simp]
theorem smul_apply [SMul R ℝ] [SMul R ℝ≥0] [IsScalarTower R ℝ≥0 ℝ] (r : R) (p : Seminorm 𝕜 E)
(x : E) : (r • p) x = r • p x :=
rfl
instance instAdd : Add (Seminorm 𝕜 E) where
add p q :=
{ p.toAddGroupSeminorm + q.toAddGroupSeminorm with
toFun := fun x => p x + q x
smul' := fun a x => by simp only [map_smul_eq_mul, map_smul_eq_mul, mul_add] }
theorem coe_add (p q : Seminorm 𝕜 E) : ⇑(p + q) = p + q :=
rfl
@[simp]
theorem add_apply (p q : Seminorm 𝕜 E) (x : E) : (p + q) x = p x + q x :=
rfl
instance instAddMonoid : AddMonoid (Seminorm 𝕜 E) :=
DFunLike.coe_injective.addMonoid _ rfl coe_add fun _ _ => by rfl
instance instAddCommMonoid : AddCommMonoid (Seminorm 𝕜 E) :=
DFunLike.coe_injective.addCommMonoid _ rfl coe_add fun _ _ => by rfl
instance instPartialOrder : PartialOrder (Seminorm 𝕜 E) :=
PartialOrder.lift _ DFunLike.coe_injective
instance instIsOrderedCancelAddMonoid : IsOrderedCancelAddMonoid (Seminorm 𝕜 E) :=
Function.Injective.isOrderedCancelAddMonoid DFunLike.coe coe_add .rfl
instance instMulAction [Monoid R] [MulAction R ℝ] [SMul R ℝ≥0] [IsScalarTower R ℝ≥0 ℝ] :
MulAction R (Seminorm 𝕜 E) :=
DFunLike.coe_injective.mulAction _ (by intros; rfl)
variable (𝕜 E)
/-- `coeFn` as an `AddMonoidHom`. Helper definition for showing that `Seminorm 𝕜 E` is a module. -/
@[simps]
def coeFnAddMonoidHom : AddMonoidHom (Seminorm 𝕜 E) (E → ℝ) where
toFun := (↑)
map_zero' := coe_zero
map_add' := coe_add
theorem coeFnAddMonoidHom_injective : Function.Injective (coeFnAddMonoidHom 𝕜 E) :=
show @Function.Injective (Seminorm 𝕜 E) (E → ℝ) (↑) from DFunLike.coe_injective
variable {𝕜 E}
instance instDistribMulAction [Monoid R] [DistribMulAction R ℝ] [SMul R ℝ≥0]
[IsScalarTower R ℝ≥0 ℝ] : DistribMulAction R (Seminorm 𝕜 E) :=
(coeFnAddMonoidHom_injective 𝕜 E).distribMulAction _ (by intros; rfl)
instance instModule [Semiring R] [Module R ℝ] [SMul R ℝ≥0] [IsScalarTower R ℝ≥0 ℝ] :
Module R (Seminorm 𝕜 E) :=
(coeFnAddMonoidHom_injective 𝕜 E).module R _ (by intros; rfl)
instance instSup : Max (Seminorm 𝕜 E) where
max p q :=
{ p.toAddGroupSeminorm ⊔ q.toAddGroupSeminorm with
toFun := p ⊔ q
smul' := fun x v =>
(congr_arg₂ max (map_smul_eq_mul p x v) (map_smul_eq_mul q x v)).trans <|
(mul_max_of_nonneg _ _ <| norm_nonneg x).symm }
@[simp]
theorem coe_sup (p q : Seminorm 𝕜 E) : ⇑(p ⊔ q) = (p : E → ℝ) ⊔ (q : E → ℝ) :=
rfl
theorem sup_apply (p q : Seminorm 𝕜 E) (x : E) : (p ⊔ q) x = p x ⊔ q x :=
rfl
theorem smul_sup [SMul R ℝ] [SMul R ℝ≥0] [IsScalarTower R ℝ≥0 ℝ] (r : R) (p q : Seminorm 𝕜 E) :
r • (p ⊔ q) = r • p ⊔ r • q :=
have real.smul_max : ∀ x y : ℝ, r • max x y = max (r • x) (r • y) := fun x y => by
simpa only [← smul_eq_mul, ← NNReal.smul_def, smul_one_smul ℝ≥0 r (_ : ℝ)] using
mul_max_of_nonneg x y (r • (1 : ℝ≥0) : ℝ≥0).coe_nonneg
ext fun _ => real.smul_max _ _
@[simp, norm_cast]
theorem coe_le_coe {p q : Seminorm 𝕜 E} : (p : E → ℝ) ≤ q ↔ p ≤ q :=
Iff.rfl
@[simp, norm_cast]
theorem coe_lt_coe {p q : Seminorm 𝕜 E} : (p : E → ℝ) < q ↔ p < q :=
Iff.rfl
theorem le_def {p q : Seminorm 𝕜 E} : p ≤ q ↔ ∀ x, p x ≤ q x :=
Iff.rfl
theorem lt_def {p q : Seminorm 𝕜 E} : p < q ↔ p ≤ q ∧ ∃ x, p x < q x :=
@Pi.lt_def _ _ _ p q
instance instSemilatticeSup : SemilatticeSup (Seminorm 𝕜 E) :=
Function.Injective.semilatticeSup _ DFunLike.coe_injective coe_sup
end SMul
end AddGroup
section Module
variable [SeminormedRing 𝕜₂] [SeminormedRing 𝕜₃]
variable {σ₁₂ : 𝕜 →+* 𝕜₂} [RingHomIsometric σ₁₂]
variable {σ₂₃ : 𝕜₂ →+* 𝕜₃} [RingHomIsometric σ₂₃]
variable {σ₁₃ : 𝕜 →+* 𝕜₃} [RingHomIsometric σ₁₃]
variable [AddCommGroup E] [AddCommGroup E₂] [AddCommGroup E₃]
variable [Module 𝕜 E] [Module 𝕜₂ E₂] [Module 𝕜₃ E₃]
variable [SMul R ℝ] [SMul R ℝ≥0] [IsScalarTower R ℝ≥0 ℝ]
/-- Composition of a seminorm with a linear map is a seminorm. -/
def comp (p : Seminorm 𝕜₂ E₂) (f : E →ₛₗ[σ₁₂] E₂) : Seminorm 𝕜 E :=
{ p.toAddGroupSeminorm.comp f.toAddMonoidHom with
toFun := fun x => p (f x)
-- Note: https://github.com/leanprover-community/mathlib4/pull/8386 had to change `map_smulₛₗ` to `map_smulₛₗ _`
smul' _ _ := by simp only [map_smulₛₗ _, map_smul_eq_mul, RingHomIsometric.norm_map] }
theorem coe_comp (p : Seminorm 𝕜₂ E₂) (f : E →ₛₗ[σ₁₂] E₂) : ⇑(p.comp f) = p ∘ f :=
rfl
@[simp]
theorem comp_apply (p : Seminorm 𝕜₂ E₂) (f : E →ₛₗ[σ₁₂] E₂) (x : E) : (p.comp f) x = p (f x) :=
rfl
@[simp]
theorem comp_id (p : Seminorm 𝕜 E) : p.comp LinearMap.id = p :=
ext fun _ => rfl
@[simp]
theorem comp_zero (p : Seminorm 𝕜₂ E₂) : p.comp (0 : E →ₛₗ[σ₁₂] E₂) = 0 :=
ext fun _ => map_zero p
@[simp]
theorem zero_comp (f : E →ₛₗ[σ₁₂] E₂) : (0 : Seminorm 𝕜₂ E₂).comp f = 0 :=
ext fun _ => rfl
theorem comp_comp [RingHomCompTriple σ₁₂ σ₂₃ σ₁₃] (p : Seminorm 𝕜₃ E₃) (g : E₂ →ₛₗ[σ₂₃] E₃)
(f : E →ₛₗ[σ₁₂] E₂) : p.comp (g.comp f) = (p.comp g).comp f :=
ext fun _ => rfl
theorem add_comp (p q : Seminorm 𝕜₂ E₂) (f : E →ₛₗ[σ₁₂] E₂) :
(p + q).comp f = p.comp f + q.comp f :=
ext fun _ => rfl
theorem comp_add_le (p : Seminorm 𝕜₂ E₂) (f g : E →ₛₗ[σ₁₂] E₂) :
p.comp (f + g) ≤ p.comp f + p.comp g := fun _ => map_add_le_add p _ _
theorem smul_comp (p : Seminorm 𝕜₂ E₂) (f : E →ₛₗ[σ₁₂] E₂) (c : R) :
(c • p).comp f = c • p.comp f :=
ext fun _ => rfl
theorem comp_mono {p q : Seminorm 𝕜₂ E₂} (f : E →ₛₗ[σ₁₂] E₂) (hp : p ≤ q) : p.comp f ≤ q.comp f :=
fun _ => hp _
/-- The composition as an `AddMonoidHom`. -/
@[simps]
def pullback (f : E →ₛₗ[σ₁₂] E₂) : Seminorm 𝕜₂ E₂ →+ Seminorm 𝕜 E where
toFun := fun p => p.comp f
map_zero' := zero_comp f
map_add' := fun p q => add_comp p q f
instance instOrderBot : OrderBot (Seminorm 𝕜 E) where
bot := 0
bot_le := apply_nonneg
@[simp]
theorem coe_bot : ⇑(⊥ : Seminorm 𝕜 E) = 0 :=
rfl
theorem bot_eq_zero : (⊥ : Seminorm 𝕜 E) = 0 :=
rfl
theorem smul_le_smul {p q : Seminorm 𝕜 E} {a b : ℝ≥0} (hpq : p ≤ q) (hab : a ≤ b) :
a • p ≤ b • q := by
simp_rw [le_def]
intro x
exact mul_le_mul hab (hpq x) (apply_nonneg p x) (NNReal.coe_nonneg b)
theorem finset_sup_apply (p : ι → Seminorm 𝕜 E) (s : Finset ι) (x : E) :
s.sup p x = ↑(s.sup fun i => ⟨p i x, apply_nonneg (p i) x⟩ : ℝ≥0) := by
induction s using Finset.cons_induction_on with
| empty =>
rw [Finset.sup_empty, Finset.sup_empty, coe_bot, _root_.bot_eq_zero, Pi.zero_apply]
norm_cast
| cons a s ha ih =>
rw [Finset.sup_cons, Finset.sup_cons, coe_sup, Pi.sup_apply, NNReal.coe_max, NNReal.coe_mk, ih]
theorem exists_apply_eq_finset_sup (p : ι → Seminorm 𝕜 E) {s : Finset ι} (hs : s.Nonempty) (x : E) :
∃ i ∈ s, s.sup p x = p i x := by
rcases Finset.exists_mem_eq_sup s hs (fun i ↦ (⟨p i x, apply_nonneg _ _⟩ : ℝ≥0)) with ⟨i, hi, hix⟩
rw [finset_sup_apply]
exact ⟨i, hi, congr_arg _ hix⟩
theorem zero_or_exists_apply_eq_finset_sup (p : ι → Seminorm 𝕜 E) (s : Finset ι) (x : E) :
s.sup p x = 0 ∨ ∃ i ∈ s, s.sup p x = p i x := by
rcases Finset.eq_empty_or_nonempty s with (rfl | hs)
· left; rfl
· right; exact exists_apply_eq_finset_sup p hs x
theorem finset_sup_smul (p : ι → Seminorm 𝕜 E) (s : Finset ι) (C : ℝ≥0) :
s.sup (C • p) = C • s.sup p := by
ext x
rw [smul_apply, finset_sup_apply, finset_sup_apply]
symm
exact congr_arg ((↑) : ℝ≥0 → ℝ) (NNReal.mul_finset_sup C s (fun i ↦ ⟨p i x, apply_nonneg _ _⟩))
theorem finset_sup_le_sum (p : ι → Seminorm 𝕜 E) (s : Finset ι) : s.sup p ≤ ∑ i ∈ s, p i := by
classical
refine Finset.sup_le_iff.mpr ?_
intro i hi
rw [Finset.sum_eq_sum_diff_singleton_add hi, le_add_iff_nonneg_left]
exact bot_le
theorem finset_sup_apply_le {p : ι → Seminorm 𝕜 E} {s : Finset ι} {x : E} {a : ℝ} (ha : 0 ≤ a)
(h : ∀ i, i ∈ s → p i x ≤ a) : s.sup p x ≤ a := by
lift a to ℝ≥0 using ha
rw [finset_sup_apply, NNReal.coe_le_coe]
exact Finset.sup_le h
theorem le_finset_sup_apply {p : ι → Seminorm 𝕜 E} {s : Finset ι} {x : E} {i : ι}
(hi : i ∈ s) : p i x ≤ s.sup p x :=
(Finset.le_sup hi : p i ≤ s.sup p) x
theorem finset_sup_apply_lt {p : ι → Seminorm 𝕜 E} {s : Finset ι} {x : E} {a : ℝ} (ha : 0 < a)
(h : ∀ i, i ∈ s → p i x < a) : s.sup p x < a := by
lift a to ℝ≥0 using ha.le
rw [finset_sup_apply, NNReal.coe_lt_coe, Finset.sup_lt_iff]
· exact h
· exact NNReal.coe_pos.mpr ha
theorem norm_sub_map_le_sub (p : Seminorm 𝕜 E) (x y : E) : ‖p x - p y‖ ≤ p (x - y) :=
abs_sub_map_le_sub p x y
end Module
end SeminormedRing
section SeminormedCommRing
variable [SeminormedRing 𝕜] [SeminormedCommRing 𝕜₂]
variable {σ₁₂ : 𝕜 →+* 𝕜₂} [RingHomIsometric σ₁₂]
variable [AddCommGroup E] [AddCommGroup E₂] [Module 𝕜 E] [Module 𝕜₂ E₂]
theorem comp_smul (p : Seminorm 𝕜₂ E₂) (f : E →ₛₗ[σ₁₂] E₂) (c : 𝕜₂) :
p.comp (c • f) = ‖c‖₊ • p.comp f :=
ext fun _ => by
rw [comp_apply, smul_apply, LinearMap.smul_apply, map_smul_eq_mul, NNReal.smul_def, coe_nnnorm,
smul_eq_mul, comp_apply]
theorem comp_smul_apply (p : Seminorm 𝕜₂ E₂) (f : E →ₛₗ[σ₁₂] E₂) (c : 𝕜₂) (x : E) :
p.comp (c • f) x = ‖c‖ * p (f x) :=
map_smul_eq_mul p _ _
end SeminormedCommRing
section NormedField
variable [NormedField 𝕜] [AddCommGroup E] [Module 𝕜 E] {p q : Seminorm 𝕜 E} {x : E}
/-- Auxiliary lemma to show that the infimum of seminorms is well-defined. -/
theorem bddBelow_range_add : BddBelow (range fun u => p u + q (x - u)) :=
⟨0, by
rintro _ ⟨x, rfl⟩
dsimp; positivity⟩
noncomputable instance instInf : Min (Seminorm 𝕜 E) where
min p q :=
{ p.toAddGroupSeminorm ⊓ q.toAddGroupSeminorm with
toFun := fun x => ⨅ u : E, p u + q (x - u)
smul' := by
intro a x
obtain rfl | ha := eq_or_ne a 0
· rw [norm_zero, zero_mul, zero_smul]
refine
ciInf_eq_of_forall_ge_of_forall_gt_exists_lt
(fun i => by positivity)
fun x hx => ⟨0, by rwa [map_zero, sub_zero, map_zero, add_zero]⟩
simp_rw [Real.mul_iInf_of_nonneg (norm_nonneg a), mul_add, ← map_smul_eq_mul p, ←
map_smul_eq_mul q, smul_sub]
refine
Function.Surjective.iInf_congr ((a⁻¹ • ·) : E → E)
(fun u => ⟨a • u, inv_smul_smul₀ ha u⟩) fun u => ?_
rw [smul_inv_smul₀ ha] }
@[simp]
theorem inf_apply (p q : Seminorm 𝕜 E) (x : E) : (p ⊓ q) x = ⨅ u : E, p u + q (x - u) :=
rfl
noncomputable instance instLattice : Lattice (Seminorm 𝕜 E) :=
{ Seminorm.instSemilatticeSup with
inf := (· ⊓ ·)
inf_le_left := fun p q x =>
ciInf_le_of_le bddBelow_range_add x <| by
simp only [sub_self, map_zero, add_zero]; rfl
inf_le_right := fun p q x =>
ciInf_le_of_le bddBelow_range_add 0 <| by
simp only [map_zero, zero_add, sub_zero]; rfl
le_inf := fun a _ _ hab hac _ =>
le_ciInf fun _ => (le_map_add_map_sub a _ _).trans <| add_le_add (hab _) (hac _) }
theorem smul_inf [SMul R ℝ] [SMul R ℝ≥0] [IsScalarTower R ℝ≥0 ℝ] (r : R) (p q : Seminorm 𝕜 E) :
r • (p ⊓ q) = r • p ⊓ r • q := by
ext
simp_rw [smul_apply, inf_apply, smul_apply, ← smul_one_smul ℝ≥0 r (_ : ℝ), NNReal.smul_def,
smul_eq_mul, Real.mul_iInf_of_nonneg (NNReal.coe_nonneg _), mul_add]
section Classical
open Classical in
/-- We define the supremum of an arbitrary subset of `Seminorm 𝕜 E` as follows:
* if `s` is `BddAbove` *as a set of functions `E → ℝ`* (that is, if `s` is pointwise bounded
above), we take the pointwise supremum of all elements of `s`, and we prove that it is indeed a
seminorm.
* otherwise, we take the zero seminorm `⊥`.
There are two things worth mentioning here:
* First, it is not trivial at first that `s` being bounded above *by a function* implies
being bounded above *as a seminorm*. We show this in `Seminorm.bddAbove_iff` by using
that the `Sup s` as defined here is then a bounding seminorm for `s`. So it is important to make
the case disjunction on `BddAbove ((↑) '' s : Set (E → ℝ))` and not `BddAbove s`.
* Since the pointwise `Sup` already gives `0` at points where a family of functions is
not bounded above, one could hope that just using the pointwise `Sup` would work here, without the
need for an additional case disjunction. As discussed on Zulip, this doesn't work because this can
give a function which does *not* satisfy the seminorm axioms (typically sub-additivity).
-/
noncomputable instance instSupSet : SupSet (Seminorm 𝕜 E) where
sSup s :=
if h : BddAbove ((↑) '' s : Set (E → ℝ)) then
{ toFun := ⨆ p : s, ((p : Seminorm 𝕜 E) : E → ℝ)
map_zero' := by
rw [iSup_apply, ← @Real.iSup_const_zero s]
congr!
rename_i _ _ _ i
exact map_zero i.1
add_le' := fun x y => by
rcases h with ⟨q, hq⟩
obtain rfl | h := s.eq_empty_or_nonempty
· simp [Real.iSup_of_isEmpty]
haveI : Nonempty ↑s := h.coe_sort
simp only [iSup_apply]
refine ciSup_le fun i =>
((i : Seminorm 𝕜 E).add_le' x y).trans <| add_le_add
-- Porting note: `f` is provided to force `Subtype.val` to appear.
-- A type ascription on `_` would have also worked, but would have been more verbose.
(le_ciSup (f := fun i => (Subtype.val i : Seminorm 𝕜 E).toFun x) ⟨q x, ?_⟩ i)
(le_ciSup (f := fun i => (Subtype.val i : Seminorm 𝕜 E).toFun y) ⟨q y, ?_⟩ i)
<;> rw [mem_upperBounds, forall_mem_range]
<;> exact fun j => hq (mem_image_of_mem _ j.2) _
neg' := fun x => by
simp only [iSup_apply]
congr! 2
rename_i _ _ _ i
exact i.1.neg' _
smul' := fun a x => by
simp only [iSup_apply]
rw [← smul_eq_mul,
Real.smul_iSup_of_nonneg (norm_nonneg a) fun i : s => (i : Seminorm 𝕜 E) x]
congr!
rename_i _ _ _ i
exact i.1.smul' a x }
else ⊥
protected theorem coe_sSup_eq' {s : Set <| Seminorm 𝕜 E}
(hs : BddAbove ((↑) '' s : Set (E → ℝ))) : ↑(sSup s) = ⨆ p : s, ((p : Seminorm 𝕜 E) : E → ℝ) :=
congr_arg _ (dif_pos hs)
protected theorem bddAbove_iff {s : Set <| Seminorm 𝕜 E} :
BddAbove s ↔ BddAbove ((↑) '' s : Set (E → ℝ)) :=
⟨fun ⟨q, hq⟩ => ⟨q, forall_mem_image.2 fun _ hp => hq hp⟩, fun H =>
⟨sSup s, fun p hp x => by
dsimp
rw [Seminorm.coe_sSup_eq' H, iSup_apply]
rcases H with ⟨q, hq⟩
exact
le_ciSup ⟨q x, forall_mem_range.mpr fun i : s => hq (mem_image_of_mem _ i.2) x⟩ ⟨p, hp⟩⟩⟩
protected theorem bddAbove_range_iff {ι : Sort*} {p : ι → Seminorm 𝕜 E} :
BddAbove (range p) ↔ ∀ x, BddAbove (range fun i ↦ p i x) := by
rw [Seminorm.bddAbove_iff, ← range_comp, bddAbove_range_pi]; rfl
protected theorem coe_sSup_eq {s : Set <| Seminorm 𝕜 E} (hs : BddAbove s) :
↑(sSup s) = ⨆ p : s, ((p : Seminorm 𝕜 E) : E → ℝ) :=
Seminorm.coe_sSup_eq' (Seminorm.bddAbove_iff.mp hs)
protected theorem coe_iSup_eq {ι : Sort*} {p : ι → Seminorm 𝕜 E} (hp : BddAbove (range p)) :
↑(⨆ i, p i) = ⨆ i, ((p i : Seminorm 𝕜 E) : E → ℝ) := by
rw [← sSup_range, Seminorm.coe_sSup_eq hp]
exact iSup_range' (fun p : Seminorm 𝕜 E => (p : E → ℝ)) p
protected theorem sSup_apply {s : Set (Seminorm 𝕜 E)} (hp : BddAbove s) {x : E} :
(sSup s) x = ⨆ p : s, (p : E → ℝ) x := by
rw [Seminorm.coe_sSup_eq hp, iSup_apply]
protected theorem iSup_apply {ι : Sort*} {p : ι → Seminorm 𝕜 E}
(hp : BddAbove (range p)) {x : E} : (⨆ i, p i) x = ⨆ i, p i x := by
rw [Seminorm.coe_iSup_eq hp, iSup_apply]
protected theorem sSup_empty : sSup (∅ : Set (Seminorm 𝕜 E)) = ⊥ := by
ext
rw [Seminorm.sSup_apply bddAbove_empty, Real.iSup_of_isEmpty]
rfl
private theorem isLUB_sSup (s : Set (Seminorm 𝕜 E)) (hs₁ : BddAbove s) (hs₂ : s.Nonempty) :
IsLUB s (sSup s) := by
refine ⟨fun p hp x => ?_, fun p hp x => ?_⟩ <;> haveI : Nonempty ↑s := hs₂.coe_sort <;>
dsimp <;> rw [Seminorm.coe_sSup_eq hs₁, iSup_apply]
· rcases hs₁ with ⟨q, hq⟩
exact le_ciSup ⟨q x, forall_mem_range.mpr fun i : s => hq i.2 x⟩ ⟨p, hp⟩
· exact ciSup_le fun q => hp q.2 x
/-- `Seminorm 𝕜 E` is a conditionally complete lattice.
Note that, while `inf`, `sup` and `sSup` have good definitional properties (corresponding to
the instances given here for `Inf`, `Sup` and `SupSet` respectively), `sInf s` is just
defined as the supremum of the lower bounds of `s`, which is not really useful in practice. If you
need to use `sInf` on seminorms, then you should probably provide a more workable definition first,
but this is unlikely to happen so we keep the "bad" definition for now. -/
noncomputable instance instConditionallyCompleteLattice :
ConditionallyCompleteLattice (Seminorm 𝕜 E) :=
conditionallyCompleteLatticeOfLatticeOfsSup (Seminorm 𝕜 E) Seminorm.isLUB_sSup
end Classical
end NormedField
/-! ### Seminorm ball -/
section SeminormedRing
variable [SeminormedRing 𝕜]
section AddCommGroup
variable [AddCommGroup E]
section SMul
variable [SMul 𝕜 E] (p : Seminorm 𝕜 E)
/-- The ball of radius `r` at `x` with respect to seminorm `p` is the set of elements `y` with
`p (y - x) < r`. -/
def ball (x : E) (r : ℝ) :=
{ y : E | p (y - x) < r }
/-- The closed ball of radius `r` at `x` with respect to seminorm `p` is the set of elements `y`
with `p (y - x) ≤ r`. -/
def closedBall (x : E) (r : ℝ) :=
{ y : E | p (y - x) ≤ r }
variable {x y : E} {r : ℝ}
@[simp]
theorem mem_ball : y ∈ ball p x r ↔ p (y - x) < r :=
Iff.rfl
@[simp]
theorem mem_closedBall : y ∈ closedBall p x r ↔ p (y - x) ≤ r :=
Iff.rfl
theorem mem_ball_self (hr : 0 < r) : x ∈ ball p x r := by simp [hr]
theorem mem_closedBall_self (hr : 0 ≤ r) : x ∈ closedBall p x r := by simp [hr]
theorem mem_ball_zero : y ∈ ball p 0 r ↔ p y < r := by rw [mem_ball, sub_zero]
theorem mem_closedBall_zero : y ∈ closedBall p 0 r ↔ p y ≤ r := by rw [mem_closedBall, sub_zero]
theorem ball_zero_eq : ball p 0 r = { y : E | p y < r } :=
Set.ext fun _ => p.mem_ball_zero
theorem closedBall_zero_eq : closedBall p 0 r = { y : E | p y ≤ r } :=
Set.ext fun _ => p.mem_closedBall_zero
theorem ball_subset_closedBall (x r) : ball p x r ⊆ closedBall p x r := fun _ h =>
(mem_closedBall _).mpr ((mem_ball _).mp h).le
theorem closedBall_eq_biInter_ball (x r) : closedBall p x r = ⋂ ρ > r, ball p x ρ := by
ext y; simp_rw [mem_closedBall, mem_iInter₂, mem_ball, ← forall_gt_iff_le]
@[simp]
theorem ball_zero' (x : E) (hr : 0 < r) : ball (0 : Seminorm 𝕜 E) x r = Set.univ := by
rw [Set.eq_univ_iff_forall, ball]
simp [hr]
@[simp]
theorem closedBall_zero' (x : E) (hr : 0 < r) : closedBall (0 : Seminorm 𝕜 E) x r = Set.univ :=
eq_univ_of_subset (ball_subset_closedBall _ _ _) (ball_zero' x hr)
theorem ball_smul (p : Seminorm 𝕜 E) {c : NNReal} (hc : 0 < c) (r : ℝ) (x : E) :
(c • p).ball x r = p.ball x (r / c) := by
ext
rw [mem_ball, mem_ball, smul_apply, NNReal.smul_def, smul_eq_mul, mul_comm,
lt_div_iff₀ (NNReal.coe_pos.mpr hc)]
theorem closedBall_smul (p : Seminorm 𝕜 E) {c : NNReal} (hc : 0 < c) (r : ℝ) (x : E) :
(c • p).closedBall x r = p.closedBall x (r / c) := by
ext
rw [mem_closedBall, mem_closedBall, smul_apply, NNReal.smul_def, smul_eq_mul, mul_comm,
le_div_iff₀ (NNReal.coe_pos.mpr hc)]
theorem ball_sup (p : Seminorm 𝕜 E) (q : Seminorm 𝕜 E) (e : E) (r : ℝ) :
ball (p ⊔ q) e r = ball p e r ∩ ball q e r := by
simp_rw [ball, ← Set.setOf_and, coe_sup, Pi.sup_apply, sup_lt_iff]
theorem closedBall_sup (p : Seminorm 𝕜 E) (q : Seminorm 𝕜 E) (e : E) (r : ℝ) :
closedBall (p ⊔ q) e r = closedBall p e r ∩ closedBall q e r := by
simp_rw [closedBall, ← Set.setOf_and, coe_sup, Pi.sup_apply, sup_le_iff]
theorem ball_finset_sup' (p : ι → Seminorm 𝕜 E) (s : Finset ι) (H : s.Nonempty) (e : E) (r : ℝ) :
ball (s.sup' H p) e r = s.inf' H fun i => ball (p i) e r := by
induction H using Finset.Nonempty.cons_induction with
| singleton => simp
| cons _ _ _ hs ih =>
simp only [Finset.sup'_cons hs, Finset.inf'_cons hs, ball_sup, inf_eq_inter, ih]
theorem closedBall_finset_sup' (p : ι → Seminorm 𝕜 E) (s : Finset ι) (H : s.Nonempty) (e : E)
(r : ℝ) : closedBall (s.sup' H p) e r = s.inf' H fun i => closedBall (p i) e r := by
induction H using Finset.Nonempty.cons_induction with
| singleton => simp
| cons _ _ _ hs ih =>
simp only [Finset.sup'_cons hs, Finset.inf'_cons hs, closedBall_sup, inf_eq_inter, ih]
theorem ball_mono {p : Seminorm 𝕜 E} {r₁ r₂ : ℝ} (h : r₁ ≤ r₂) : p.ball x r₁ ⊆ p.ball x r₂ :=
fun _ (hx : _ < _) => hx.trans_le h
theorem closedBall_mono {p : Seminorm 𝕜 E} {r₁ r₂ : ℝ} (h : r₁ ≤ r₂) :
p.closedBall x r₁ ⊆ p.closedBall x r₂ := fun _ (hx : _ ≤ _) => hx.trans h
theorem ball_antitone {p q : Seminorm 𝕜 E} (h : q ≤ p) : p.ball x r ⊆ q.ball x r := fun _ =>
(h _).trans_lt
theorem closedBall_antitone {p q : Seminorm 𝕜 E} (h : q ≤ p) :
p.closedBall x r ⊆ q.closedBall x r := fun _ => (h _).trans
theorem ball_add_ball_subset (p : Seminorm 𝕜 E) (r₁ r₂ : ℝ) (x₁ x₂ : E) :
p.ball (x₁ : E) r₁ + p.ball (x₂ : E) r₂ ⊆ p.ball (x₁ + x₂) (r₁ + r₂) := by
rintro x ⟨y₁, hy₁, y₂, hy₂, rfl⟩
rw [mem_ball, add_sub_add_comm]
exact (map_add_le_add p _ _).trans_lt (add_lt_add hy₁ hy₂)
theorem closedBall_add_closedBall_subset (p : Seminorm 𝕜 E) (r₁ r₂ : ℝ) (x₁ x₂ : E) :
p.closedBall (x₁ : E) r₁ + p.closedBall (x₂ : E) r₂ ⊆ p.closedBall (x₁ + x₂) (r₁ + r₂) := by
rintro x ⟨y₁, hy₁, y₂, hy₂, rfl⟩
rw [mem_closedBall, add_sub_add_comm]
exact (map_add_le_add p _ _).trans (add_le_add hy₁ hy₂)
theorem sub_mem_ball (p : Seminorm 𝕜 E) (x₁ x₂ y : E) (r : ℝ) :
x₁ - x₂ ∈ p.ball y r ↔ x₁ ∈ p.ball (x₂ + y) r := by simp_rw [mem_ball, sub_sub]
theorem sub_mem_closedBall (p : Seminorm 𝕜 E) (x₁ x₂ y : E) (r : ℝ) :
x₁ - x₂ ∈ p.closedBall y r ↔ x₁ ∈ p.closedBall (x₂ + y) r := by
simp_rw [mem_closedBall, sub_sub]
/-- The image of a ball under addition with a singleton is another ball. -/
theorem vadd_ball (p : Seminorm 𝕜 E) : x +ᵥ p.ball y r = p.ball (x +ᵥ y) r :=
letI := AddGroupSeminorm.toSeminormedAddCommGroup p.toAddGroupSeminorm
Metric.vadd_ball x y r
/-- The image of a closed ball under addition with a singleton is another closed ball. -/
theorem vadd_closedBall (p : Seminorm 𝕜 E) : x +ᵥ p.closedBall y r = p.closedBall (x +ᵥ y) r :=
letI := AddGroupSeminorm.toSeminormedAddCommGroup p.toAddGroupSeminorm
Metric.vadd_closedBall x y r
end SMul
section Module
variable [Module 𝕜 E]
variable [SeminormedRing 𝕜₂] [AddCommGroup E₂] [Module 𝕜₂ E₂]
variable {σ₁₂ : 𝕜 →+* 𝕜₂} [RingHomIsometric σ₁₂]
theorem ball_comp (p : Seminorm 𝕜₂ E₂) (f : E →ₛₗ[σ₁₂] E₂) (x : E) (r : ℝ) :
(p.comp f).ball x r = f ⁻¹' p.ball (f x) r := by
ext
simp_rw [ball, mem_preimage, comp_apply, Set.mem_setOf_eq, map_sub]
theorem closedBall_comp (p : Seminorm 𝕜₂ E₂) (f : E →ₛₗ[σ₁₂] E₂) (x : E) (r : ℝ) :
(p.comp f).closedBall x r = f ⁻¹' p.closedBall (f x) r := by
ext
simp_rw [closedBall, mem_preimage, comp_apply, Set.mem_setOf_eq, map_sub]
variable (p : Seminorm 𝕜 E)
theorem preimage_metric_ball {r : ℝ} : p ⁻¹' Metric.ball 0 r = { x | p x < r } := by
ext x
simp only [mem_setOf, mem_preimage, mem_ball_zero_iff, Real.norm_of_nonneg (apply_nonneg p _)]
theorem preimage_metric_closedBall {r : ℝ} : p ⁻¹' Metric.closedBall 0 r = { x | p x ≤ r } := by
ext x
simp only [mem_setOf, mem_preimage, mem_closedBall_zero_iff,
Real.norm_of_nonneg (apply_nonneg p _)]
theorem ball_zero_eq_preimage_ball {r : ℝ} : p.ball 0 r = p ⁻¹' Metric.ball 0 r := by
rw [ball_zero_eq, preimage_metric_ball]
theorem closedBall_zero_eq_preimage_closedBall {r : ℝ} :
p.closedBall 0 r = p ⁻¹' Metric.closedBall 0 r := by
rw [closedBall_zero_eq, preimage_metric_closedBall]
@[simp]
theorem ball_bot {r : ℝ} (x : E) (hr : 0 < r) : ball (⊥ : Seminorm 𝕜 E) x r = Set.univ :=
ball_zero' x hr
@[simp]
theorem closedBall_bot {r : ℝ} (x : E) (hr : 0 < r) :
closedBall (⊥ : Seminorm 𝕜 E) x r = Set.univ :=
closedBall_zero' x hr
/-- Seminorm-balls at the origin are balanced. -/
theorem balanced_ball_zero (r : ℝ) : Balanced 𝕜 (ball p 0 r) := by
rintro a ha x ⟨y, hy, hx⟩
rw [mem_ball_zero, ← hx, map_smul_eq_mul]
calc
_ ≤ p y := mul_le_of_le_one_left (apply_nonneg p _) ha
_ < r := by rwa [mem_ball_zero] at hy
/-- Closed seminorm-balls at the origin are balanced. -/
theorem balanced_closedBall_zero (r : ℝ) : Balanced 𝕜 (closedBall p 0 r) := by
rintro a ha x ⟨y, hy, hx⟩
rw [mem_closedBall_zero, ← hx, map_smul_eq_mul]
calc
_ ≤ p y := mul_le_of_le_one_left (apply_nonneg p _) ha
_ ≤ r := by rwa [mem_closedBall_zero] at hy
theorem ball_finset_sup_eq_iInter (p : ι → Seminorm 𝕜 E) (s : Finset ι) (x : E) {r : ℝ}
(hr : 0 < r) : ball (s.sup p) x r = ⋂ i ∈ s, ball (p i) x r := by
lift r to NNReal using hr.le
simp_rw [ball, iInter_setOf, finset_sup_apply, NNReal.coe_lt_coe,
Finset.sup_lt_iff (show ⊥ < r from hr), ← NNReal.coe_lt_coe, NNReal.coe_mk]
theorem closedBall_finset_sup_eq_iInter (p : ι → Seminorm 𝕜 E) (s : Finset ι) (x : E) {r : ℝ}
(hr : 0 ≤ r) : closedBall (s.sup p) x r = ⋂ i ∈ s, closedBall (p i) x r := by
lift r to NNReal using hr
simp_rw [closedBall, iInter_setOf, finset_sup_apply, NNReal.coe_le_coe, Finset.sup_le_iff, ←
NNReal.coe_le_coe, NNReal.coe_mk]
theorem ball_finset_sup (p : ι → Seminorm 𝕜 E) (s : Finset ι) (x : E) {r : ℝ} (hr : 0 < r) :
ball (s.sup p) x r = s.inf fun i => ball (p i) x r := by
rw [Finset.inf_eq_iInf]
exact ball_finset_sup_eq_iInter _ _ _ hr
theorem closedBall_finset_sup (p : ι → Seminorm 𝕜 E) (s : Finset ι) (x : E) {r : ℝ} (hr : 0 ≤ r) :
closedBall (s.sup p) x r = s.inf fun i => closedBall (p i) x r := by
rw [Finset.inf_eq_iInf]
exact closedBall_finset_sup_eq_iInter _ _ _ hr
@[simp]
theorem ball_eq_emptyset (p : Seminorm 𝕜 E) {x : E} {r : ℝ} (hr : r ≤ 0) : p.ball x r = ∅ := by
ext
rw [Seminorm.mem_ball, Set.mem_empty_iff_false, iff_false, not_lt]
exact hr.trans (apply_nonneg p _)
@[simp]
theorem closedBall_eq_emptyset (p : Seminorm 𝕜 E) {x : E} {r : ℝ} (hr : r < 0) :
p.closedBall x r = ∅ := by
ext
rw [Seminorm.mem_closedBall, Set.mem_empty_iff_false, iff_false, not_le]
exact hr.trans_le (apply_nonneg _ _)
theorem closedBall_smul_ball (p : Seminorm 𝕜 E) {r₁ : ℝ} (hr₁ : r₁ ≠ 0) (r₂ : ℝ) :
Metric.closedBall (0 : 𝕜) r₁ • p.ball 0 r₂ ⊆ p.ball 0 (r₁ * r₂) := by
simp only [smul_subset_iff, mem_ball_zero, mem_closedBall_zero_iff, map_smul_eq_mul]
refine fun a ha b hb ↦ mul_lt_mul' ha hb (apply_nonneg _ _) ?_
exact hr₁.lt_or_gt.resolve_left <| ((norm_nonneg a).trans ha).not_gt
theorem ball_smul_closedBall (p : Seminorm 𝕜 E) (r₁ : ℝ) {r₂ : ℝ} (hr₂ : r₂ ≠ 0) :
Metric.ball (0 : 𝕜) r₁ • p.closedBall 0 r₂ ⊆ p.ball 0 (r₁ * r₂) := by
simp only [smul_subset_iff, mem_ball_zero, mem_closedBall_zero, mem_ball_zero_iff,
map_smul_eq_mul]
intro a ha b hb
rw [mul_comm, mul_comm r₁]
refine mul_lt_mul' hb ha (norm_nonneg _) (hr₂.lt_or_gt.resolve_left ?_)
exact ((apply_nonneg p b).trans hb).not_gt
theorem ball_smul_ball (p : Seminorm 𝕜 E) (r₁ r₂ : ℝ) :
Metric.ball (0 : 𝕜) r₁ • p.ball 0 r₂ ⊆ p.ball 0 (r₁ * r₂) := by
rcases eq_or_ne r₂ 0 with rfl | hr₂
· simp
· exact (smul_subset_smul_left (ball_subset_closedBall _ _ _)).trans
(ball_smul_closedBall _ _ hr₂)
theorem closedBall_smul_closedBall (p : Seminorm 𝕜 E) (r₁ r₂ : ℝ) :
Metric.closedBall (0 : 𝕜) r₁ • p.closedBall 0 r₂ ⊆ p.closedBall 0 (r₁ * r₂) := by
simp only [smul_subset_iff, mem_closedBall_zero, mem_closedBall_zero_iff, map_smul_eq_mul]
intro a ha b hb
gcongr
exact (norm_nonneg _).trans ha
theorem neg_mem_ball_zero {r : ℝ} {x : E} : -x ∈ ball p 0 r ↔ x ∈ ball p 0 r := by
simp only [mem_ball_zero, map_neg_eq_map]
theorem neg_mem_closedBall_zero {r : ℝ} {x : E} : -x ∈ closedBall p 0 r ↔ x ∈ closedBall p 0 r := by
simp only [mem_closedBall_zero, map_neg_eq_map]
@[simp]
theorem neg_ball (p : Seminorm 𝕜 E) (r : ℝ) (x : E) : -ball p x r = ball p (-x) r := by
ext
rw [Set.mem_neg, mem_ball, mem_ball, ← neg_add', sub_neg_eq_add, map_neg_eq_map]
@[simp]
theorem neg_closedBall (p : Seminorm 𝕜 E) (r : ℝ) (x : E) :
-closedBall p x r = closedBall p (-x) r := by
ext
rw [Set.mem_neg, mem_closedBall, mem_closedBall, ← neg_add', sub_neg_eq_add, map_neg_eq_map]
end Module
end AddCommGroup
end SeminormedRing
section NormedField
variable [NormedField 𝕜] [AddCommGroup E] [Module 𝕜 E] (p : Seminorm 𝕜 E) {r : ℝ} {x : E}
theorem closedBall_iSup {ι : Sort*} {p : ι → Seminorm 𝕜 E} (hp : BddAbove (range p)) (e : E)
{r : ℝ} (hr : 0 < r) : closedBall (⨆ i, p i) e r = ⋂ i, closedBall (p i) e r := by
cases isEmpty_or_nonempty ι
· rw [iSup_of_empty', iInter_of_empty, Seminorm.sSup_empty]
exact closedBall_bot _ hr
· ext x
have := Seminorm.bddAbove_range_iff.mp hp (x - e)
simp only [mem_closedBall, mem_iInter, Seminorm.iSup_apply hp, ciSup_le_iff this]
theorem ball_norm_mul_subset {p : Seminorm 𝕜 E} {k : 𝕜} {r : ℝ} :
p.ball 0 (‖k‖ * r) ⊆ k • p.ball 0 r := by
rcases eq_or_ne k 0 with (rfl | hk)
· rw [norm_zero, zero_mul, ball_eq_emptyset _ le_rfl]
exact empty_subset _
· intro x
rw [Set.mem_smul_set, Seminorm.mem_ball_zero]
refine fun hx => ⟨k⁻¹ • x, ?_, ?_⟩
· rwa [Seminorm.mem_ball_zero, map_smul_eq_mul, norm_inv, ←
mul_lt_mul_iff_right₀ <| norm_pos_iff.mpr hk, ← mul_assoc, ← div_eq_mul_inv ‖k‖ ‖k‖,
div_self (ne_of_gt <| norm_pos_iff.mpr hk), one_mul]
rw [← smul_assoc, smul_eq_mul, ← div_eq_mul_inv, div_self hk, one_smul]
theorem smul_ball_zero {p : Seminorm 𝕜 E} {k : 𝕜} {r : ℝ} (hk : k ≠ 0) :
k • p.ball 0 r = p.ball 0 (‖k‖ * r) := by
ext
rw [mem_smul_set_iff_inv_smul_mem₀ hk, p.mem_ball_zero, p.mem_ball_zero, map_smul_eq_mul,
norm_inv, ← div_eq_inv_mul, div_lt_iff₀ (norm_pos_iff.2 hk), mul_comm]
theorem smul_closedBall_subset {p : Seminorm 𝕜 E} {k : 𝕜} {r : ℝ} :
k • p.closedBall 0 r ⊆ p.closedBall 0 (‖k‖ * r) := by
rintro x ⟨y, hy, h⟩
rw [Seminorm.mem_closedBall_zero, ← h, map_smul_eq_mul]
rw [Seminorm.mem_closedBall_zero] at hy
gcongr
theorem smul_closedBall_zero {p : Seminorm 𝕜 E} {k : 𝕜} {r : ℝ} (hk : 0 < ‖k‖) :
k • p.closedBall 0 r = p.closedBall 0 (‖k‖ * r) := by
refine subset_antisymm smul_closedBall_subset ?_
intro x
rw [Set.mem_smul_set, Seminorm.mem_closedBall_zero]
refine fun hx => ⟨k⁻¹ • x, ?_, ?_⟩
· rwa [Seminorm.mem_closedBall_zero, map_smul_eq_mul, norm_inv, inv_mul_le_iff₀ hk]
rw [← smul_assoc, smul_eq_mul, ← div_eq_mul_inv, div_self (norm_pos_iff.mp hk), one_smul]
theorem ball_zero_absorbs_ball_zero (p : Seminorm 𝕜 E) {r₁ r₂ : ℝ} (hr₁ : 0 < r₁) :
Absorbs 𝕜 (p.ball 0 r₁) (p.ball 0 r₂) := by
rcases exists_pos_lt_mul hr₁ r₂ with ⟨r, hr₀, hr⟩
refine .of_norm ⟨r, fun a ha x hx => ?_⟩
rw [smul_ball_zero (norm_pos_iff.1 <| hr₀.trans_le ha), p.mem_ball_zero]
rw [p.mem_ball_zero] at hx
exact hx.trans (hr.trans_le <| by gcongr)
/-- Seminorm-balls at the origin are absorbent. -/
protected theorem absorbent_ball_zero (hr : 0 < r) : Absorbent 𝕜 (ball p (0 : E) r) :=
absorbent_iff_forall_absorbs_singleton.2 fun _ =>
(p.ball_zero_absorbs_ball_zero hr).mono_right <|
singleton_subset_iff.2 <| p.mem_ball_zero.2 <| lt_add_one _
/-- Closed seminorm-balls at the origin are absorbent. -/
protected theorem absorbent_closedBall_zero (hr : 0 < r) : Absorbent 𝕜 (closedBall p (0 : E) r) :=
(p.absorbent_ball_zero hr).mono (p.ball_subset_closedBall _ _)
/-- Seminorm-balls containing the origin are absorbent. -/
protected theorem absorbent_ball (hpr : p x < r) : Absorbent 𝕜 (ball p x r) := by
refine (p.absorbent_ball_zero <| sub_pos.2 hpr).mono fun y hy => ?_
rw [p.mem_ball_zero] at hy
exact p.mem_ball.2 ((map_sub_le_add p _ _).trans_lt <| add_lt_of_lt_sub_right hy)
/-- Seminorm-balls containing the origin are absorbent. -/
protected theorem absorbent_closedBall (hpr : p x < r) : Absorbent 𝕜 (closedBall p x r) := by
refine (p.absorbent_closedBall_zero <| sub_pos.2 hpr).mono fun y hy => ?_
rw [p.mem_closedBall_zero] at hy
exact p.mem_closedBall.2 ((map_sub_le_add p _ _).trans <| add_le_of_le_sub_right hy)
@[simp]
theorem smul_ball_preimage (p : Seminorm 𝕜 E) (y : E) (r : ℝ) (a : 𝕜) (ha : a ≠ 0) :
(a • ·) ⁻¹' p.ball y r = p.ball (a⁻¹ • y) (r / ‖a‖) :=
Set.ext fun _ => by
rw [mem_preimage, mem_ball, mem_ball, lt_div_iff₀ (norm_pos_iff.mpr ha), mul_comm, ←
map_smul_eq_mul p, smul_sub, smul_inv_smul₀ ha]
@[simp]
theorem smul_closedBall_preimage (p : Seminorm 𝕜 E) (y : E) (r : ℝ) (a : 𝕜) (ha : a ≠ 0) :
(a • ·) ⁻¹' p.closedBall y r = p.closedBall (a⁻¹ • y) (r / ‖a‖) :=
Set.ext fun _ => by
rw [mem_preimage, mem_closedBall, mem_closedBall, le_div_iff₀ (norm_pos_iff.mpr ha), mul_comm, ←
map_smul_eq_mul p, smul_sub, smul_inv_smul₀ ha]
end NormedField
section Convex
variable [NormedField 𝕜] [AddCommGroup E] [NormedSpace ℝ 𝕜] [Module 𝕜 E]
section SMul
variable [SMul ℝ E] [IsScalarTower ℝ 𝕜 E] (p : Seminorm 𝕜 E)
/-- A seminorm is convex. Also see `convexOn_norm`. -/
protected theorem convexOn : ConvexOn ℝ univ p := by
refine ⟨convex_univ, fun x _ y _ a b ha hb _ => ?_⟩
calc
p (a • x + b • y) ≤ p (a • x) + p (b • y) := map_add_le_add p _ _
_ = ‖a • (1 : 𝕜)‖ * p x + ‖b • (1 : 𝕜)‖ * p y := by
rw [← map_smul_eq_mul p, ← map_smul_eq_mul p, smul_one_smul, smul_one_smul]
_ = a * p x + b * p y := by
rw [norm_smul, norm_smul, norm_one, mul_one, mul_one, Real.norm_of_nonneg ha,
Real.norm_of_nonneg hb]
end SMul
section Module
variable [Module ℝ E] [IsScalarTower ℝ 𝕜 E] (p : Seminorm 𝕜 E) (x : E) (r : ℝ)
/-- Seminorm-balls are convex. -/
theorem convex_ball : Convex ℝ (ball p x r) := by
convert (p.convexOn.translate_left (-x)).convex_lt r
ext y
rw [preimage_univ, sep_univ, p.mem_ball, sub_eq_add_neg]
rfl
/-- Closed seminorm-balls are convex. -/
theorem convex_closedBall : Convex ℝ (closedBall p x r) := by
rw [closedBall_eq_biInter_ball]
exact convex_iInter₂ fun _ _ => convex_ball _ _ _
end Module
end Convex
section RestrictScalars
variable (𝕜) {𝕜' : Type*} [NormedField 𝕜] [SeminormedRing 𝕜'] [NormedAlgebra 𝕜 𝕜']
[NormOneClass 𝕜'] [AddCommGroup E] [Module 𝕜' E] [SMul 𝕜 E] [IsScalarTower 𝕜 𝕜' E]
/-- Reinterpret a seminorm over a field `𝕜'` as a seminorm over a smaller field `𝕜`. This will
typically be used with `RCLike 𝕜'` and `𝕜 = ℝ`. -/
protected def restrictScalars (p : Seminorm 𝕜' E) : Seminorm 𝕜 E :=
{ p with
smul' := fun a x => by rw [← smul_one_smul 𝕜' a x, p.smul', norm_smul, norm_one, mul_one] }
@[simp]
theorem coe_restrictScalars (p : Seminorm 𝕜' E) : (p.restrictScalars 𝕜 : E → ℝ) = p :=
rfl
@[simp]
theorem restrictScalars_ball (p : Seminorm 𝕜' E) : (p.restrictScalars 𝕜).ball = p.ball :=
rfl
@[simp]
theorem restrictScalars_closedBall (p : Seminorm 𝕜' E) :
(p.restrictScalars 𝕜).closedBall = p.closedBall :=
rfl
end RestrictScalars
/-! ### Continuity criteria for seminorms -/
section Continuity
variable [NontriviallyNormedField 𝕜] [SeminormedRing 𝕝] [AddCommGroup E] [Module 𝕜 E]
variable [Module 𝕝 E]
/-- A seminorm is continuous at `0` if `p.closedBall 0 r ∈ 𝓝 0` for *all* `r > 0`.
Over a `NontriviallyNormedField` it is actually enough to check that this is true
for *some* `r`, see `Seminorm.continuousAt_zero'`. -/
theorem continuousAt_zero_of_forall' [TopologicalSpace E] {p : Seminorm 𝕝 E}
(hp : ∀ r > 0, p.closedBall 0 r ∈ (𝓝 0 : Filter E)) :
ContinuousAt p 0 := by
simp_rw [Seminorm.closedBall_zero_eq_preimage_closedBall] at hp
rwa [ContinuousAt, Metric.nhds_basis_closedBall.tendsto_right_iff, map_zero]
theorem continuousAt_zero' [TopologicalSpace E] [ContinuousConstSMul 𝕜 E] {p : Seminorm 𝕜 E}
{r : ℝ} (hp : p.closedBall 0 r ∈ (𝓝 0 : Filter E)) : ContinuousAt p 0 := by
refine continuousAt_zero_of_forall' fun ε hε ↦ ?_
obtain ⟨k, hk₀, hk⟩ : ∃ k : 𝕜, 0 < ‖k‖ ∧ ‖k‖ * r < ε := by
rcases le_or_gt r 0 with hr | hr
· use 1; simpa using hr.trans_lt hε
· simpa [lt_div_iff₀ hr] using exists_norm_lt 𝕜 (div_pos hε hr)
rw [← set_smul_mem_nhds_zero_iff (norm_pos_iff.1 hk₀), smul_closedBall_zero hk₀] at hp
exact mem_of_superset hp <| p.closedBall_mono hk.le
/-- A seminorm is continuous at `0` if `p.ball 0 r ∈ 𝓝 0` for *all* `r > 0`.
Over a `NontriviallyNormedField` it is actually enough to check that this is true
for *some* `r`, see `Seminorm.continuousAt_zero'`. -/
theorem continuousAt_zero_of_forall [TopologicalSpace E] {p : Seminorm 𝕝 E}
(hp : ∀ r > 0, p.ball 0 r ∈ (𝓝 0 : Filter E)) :
ContinuousAt p 0 :=
continuousAt_zero_of_forall'
(fun r hr ↦ Filter.mem_of_superset (hp r hr) <| p.ball_subset_closedBall _ _)
theorem continuousAt_zero [TopologicalSpace E] [ContinuousConstSMul 𝕜 E] {p : Seminorm 𝕜 E} {r : ℝ}
(hp : p.ball 0 r ∈ (𝓝 0 : Filter E)) : ContinuousAt p 0 :=
continuousAt_zero' (Filter.mem_of_superset hp <| p.ball_subset_closedBall _ _)
protected theorem uniformContinuous_of_continuousAt_zero [UniformSpace E] [IsUniformAddGroup E]
{p : Seminorm 𝕝 E} (hp : ContinuousAt p 0) : UniformContinuous p := by
have hp : Filter.Tendsto p (𝓝 0) (𝓝 0) := map_zero p ▸ hp
rw [UniformContinuous, uniformity_eq_comap_nhds_zero_swapped,
Metric.uniformity_eq_comap_nhds_zero, Filter.tendsto_comap_iff]
exact
tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_const_nhds (hp.comp Filter.tendsto_comap)
(fun xy => dist_nonneg) fun xy => p.norm_sub_map_le_sub _ _
protected theorem continuous_of_continuousAt_zero [TopologicalSpace E] [IsTopologicalAddGroup E]
{p : Seminorm 𝕝 E} (hp : ContinuousAt p 0) : Continuous p := by
letI := IsTopologicalAddGroup.rightUniformSpace E
haveI : IsUniformAddGroup E := isUniformAddGroup_of_addCommGroup
exact (Seminorm.uniformContinuous_of_continuousAt_zero hp).continuous
/-- A seminorm is uniformly continuous if `p.ball 0 r ∈ 𝓝 0` for *all* `r > 0`.
Over a `NontriviallyNormedField` it is actually enough to check that this is true
for *some* `r`, see `Seminorm.uniformContinuous`. -/
protected theorem uniformContinuous_of_forall [UniformSpace E] [IsUniformAddGroup E]
{p : Seminorm 𝕝 E} (hp : ∀ r > 0, p.ball 0 r ∈ (𝓝 0 : Filter E)) :
UniformContinuous p :=
Seminorm.uniformContinuous_of_continuousAt_zero (continuousAt_zero_of_forall hp)
protected theorem uniformContinuous [UniformSpace E] [IsUniformAddGroup E]
[ContinuousConstSMul 𝕜 E] {p : Seminorm 𝕜 E} {r : ℝ} (hp : p.ball 0 r ∈ (𝓝 0 : Filter E)) :
UniformContinuous p :=
Seminorm.uniformContinuous_of_continuousAt_zero (continuousAt_zero hp)
/-- A seminorm is uniformly continuous if `p.closedBall 0 r ∈ 𝓝 0` for *all* `r > 0`.
Over a `NontriviallyNormedField` it is actually enough to check that this is true
for *some* `r`, see `Seminorm.uniformContinuous'`. -/
protected theorem uniformContinuous_of_forall' [UniformSpace E] [IsUniformAddGroup E]
{p : Seminorm 𝕝 E} (hp : ∀ r > 0, p.closedBall 0 r ∈ (𝓝 0 : Filter E)) :
UniformContinuous p :=
Seminorm.uniformContinuous_of_continuousAt_zero (continuousAt_zero_of_forall' hp)
protected theorem uniformContinuous' [UniformSpace E] [IsUniformAddGroup E]
[ContinuousConstSMul 𝕜 E] {p : Seminorm 𝕜 E} {r : ℝ}
(hp : p.closedBall 0 r ∈ (𝓝 0 : Filter E)) : UniformContinuous p :=
Seminorm.uniformContinuous_of_continuousAt_zero (continuousAt_zero' hp)
/-- A seminorm is continuous if `p.ball 0 r ∈ 𝓝 0` for *all* `r > 0`.
Over a `NontriviallyNormedField` it is actually enough to check that this is true
for *some* `r`, see `Seminorm.continuous`. -/
protected theorem continuous_of_forall [TopologicalSpace E] [IsTopologicalAddGroup E]
{p : Seminorm 𝕝 E} (hp : ∀ r > 0, p.ball 0 r ∈ (𝓝 0 : Filter E)) :
Continuous p :=
Seminorm.continuous_of_continuousAt_zero (continuousAt_zero_of_forall hp)
protected theorem continuous [TopologicalSpace E] [IsTopologicalAddGroup E]
[ContinuousConstSMul 𝕜 E] {p : Seminorm 𝕜 E} {r : ℝ} (hp : p.ball 0 r ∈ (𝓝 0 : Filter E)) :
Continuous p :=
Seminorm.continuous_of_continuousAt_zero (continuousAt_zero hp)
protected theorem continuous_iff [TopologicalSpace E] [IsTopologicalAddGroup E]
[ContinuousConstSMul 𝕜 E] {p : Seminorm 𝕜 E} {r : ℝ} (hr : 0 < r) :
Continuous p ↔ p.ball 0 r ∈ 𝓝 0 :=
⟨fun H ↦ p.ball_zero_eq ▸ (H.tendsto' 0 0 (map_zero p)).eventually_lt_const hr, p.continuous⟩
/-- A seminorm is continuous if `p.closedBall 0 r ∈ 𝓝 0` for *all* `r > 0`.
Over a `NontriviallyNormedField` it is actually enough to check that this is true
for *some* `r`, see `Seminorm.continuous'`. -/
protected theorem continuous_of_forall' [TopologicalSpace E] [IsTopologicalAddGroup E]
{p : Seminorm 𝕝 E} (hp : ∀ r > 0, p.closedBall 0 r ∈ (𝓝 0 : Filter E)) :
Continuous p :=
Seminorm.continuous_of_continuousAt_zero (continuousAt_zero_of_forall' hp)
protected theorem continuous' [TopologicalSpace E] [IsTopologicalAddGroup E]
[ContinuousConstSMul 𝕜 E] {p : Seminorm 𝕜 E} {r : ℝ}
(hp : p.closedBall 0 r ∈ (𝓝 0 : Filter E)) : Continuous p :=
Seminorm.continuous_of_continuousAt_zero (continuousAt_zero' hp)
theorem continuous_of_le [TopologicalSpace E] [IsTopologicalAddGroup E]
{p q : Seminorm 𝕝 E} (hq : Continuous q) (hpq : p ≤ q) : Continuous p := by
refine Seminorm.continuous_of_forall (fun r hr ↦ Filter.mem_of_superset
(IsOpen.mem_nhds ?_ <| q.mem_ball_self hr) (ball_antitone hpq))
rw [ball_zero_eq]
exact isOpen_lt hq continuous_const
lemma ball_mem_nhds [TopologicalSpace E] {p : Seminorm 𝕝 E} (hp : Continuous p) {r : ℝ}
(hr : 0 < r) : p.ball 0 r ∈ (𝓝 0 : Filter E) :=
have this : Tendsto p (𝓝 0) (𝓝 0) := map_zero p ▸ hp.tendsto 0
by simpa only [p.ball_zero_eq] using this (Iio_mem_nhds hr)
lemma uniformSpace_eq_of_hasBasis
{ι} [UniformSpace E] [IsUniformAddGroup E] [ContinuousConstSMul 𝕜 E]
{p' : ι → Prop} {s : ι → Set E} (p : Seminorm 𝕜 E) (hb : (𝓝 0 : Filter E).HasBasis p' s)
(h₁ : ∃ r, p.closedBall 0 r ∈ 𝓝 0) (h₂ : ∀ i, p' i → ∃ r > 0, p.ball 0 r ⊆ s i) :
‹UniformSpace E› = p.toAddGroupSeminorm.toSeminormedAddGroup.toUniformSpace := by
refine IsUniformAddGroup.ext ‹_›
p.toAddGroupSeminorm.toSeminormedAddCommGroup.to_isUniformAddGroup ?_
apply le_antisymm
· rw [← @comap_norm_nhds_zero E p.toAddGroupSeminorm.toSeminormedAddGroup, ← tendsto_iff_comap]
suffices Continuous p from this.tendsto' 0 _ (map_zero p)
rcases h₁ with ⟨r, hr⟩
exact p.continuous' hr
· rw [(@NormedAddCommGroup.nhds_zero_basis_norm_lt E
p.toAddGroupSeminorm.toSeminormedAddGroup).le_basis_iff hb]
simpa only [subset_def, mem_ball_zero] using h₂
lemma uniformity_eq_of_hasBasis
{ι} [UniformSpace E] [IsUniformAddGroup E] [ContinuousConstSMul 𝕜 E]
{p' : ι → Prop} {s : ι → Set E} (p : Seminorm 𝕜 E) (hb : (𝓝 0 : Filter E).HasBasis p' s)
(h₁ : ∃ r, p.closedBall 0 r ∈ 𝓝 0) (h₂ : ∀ i, p' i → ∃ r > 0, p.ball 0 r ⊆ s i) :
𝓤 E = ⨅ r > 0, 𝓟 {x | p (x.1 - x.2) < r} := by
rw [uniformSpace_eq_of_hasBasis p hb h₁ h₂]; rfl
end Continuity
section ShellLemmas
variable [NormedField 𝕜] [AddCommGroup E] [Module 𝕜 E]
/-- Let `p` be a seminorm on a vector space over a `NormedField`.
If there is a scalar `c` with `‖c‖>1`, then any `x` such that `p x ≠ 0` can be
moved by scalar multiplication to any `p`-shell of width `‖c‖`. Also recap information on the
value of `p` on the rescaling element that shows up in applications. -/
lemma rescale_to_shell_zpow (p : Seminorm 𝕜 E) {c : 𝕜} (hc : 1 < ‖c‖) {ε : ℝ}
(εpos : 0 < ε) {x : E} (hx : p x ≠ 0) : ∃ n : ℤ, c ^ n ≠ 0 ∧
p (c ^ n • x) < ε ∧ (ε / ‖c‖ ≤ p (c ^ n • x)) ∧ (‖c ^ n‖⁻¹ ≤ ε⁻¹ * ‖c‖ * p x) := by
have xεpos : 0 < (p x) / ε := by positivity
rcases exists_mem_Ico_zpow xεpos hc with ⟨n, hn⟩
have cpos : 0 < ‖c‖ := by positivity
have cnpos : 0 < ‖c^(n + 1)‖ := by rw [norm_zpow]; exact xεpos.trans hn.2
refine ⟨-(n + 1), ?_, ?_, ?_, ?_⟩
· show c ^ (-(n + 1)) ≠ 0; exact zpow_ne_zero _ (norm_pos_iff.1 cpos)
· show p ((c ^ (-(n + 1))) • x) < ε
rw [map_smul_eq_mul, zpow_neg, norm_inv, ← div_eq_inv_mul, div_lt_iff₀ cnpos, mul_comm,
norm_zpow]
exact (div_lt_iff₀ εpos).1 (hn.2)
· show ε / ‖c‖ ≤ p (c ^ (-(n + 1)) • x)
rw [zpow_neg, div_le_iff₀ cpos, map_smul_eq_mul, norm_inv, norm_zpow, zpow_add₀ (ne_of_gt cpos),
zpow_one, mul_inv_rev, mul_comm, ← mul_assoc, ← mul_assoc, mul_inv_cancel₀ (ne_of_gt cpos),
one_mul, ← div_eq_inv_mul, le_div_iff₀ (zpow_pos cpos _), mul_comm]
exact (le_div_iff₀ εpos).1 hn.1
· show ‖(c ^ (-(n + 1)))‖⁻¹ ≤ ε⁻¹ * ‖c‖ * p x
have : ε⁻¹ * ‖c‖ * p x = ε⁻¹ * p x * ‖c‖ := by ring
rw [zpow_neg, norm_inv, inv_inv, norm_zpow, zpow_add₀ (ne_of_gt cpos), zpow_one, this,
← div_eq_inv_mul]
exact mul_le_mul_of_nonneg_right hn.1 (norm_nonneg _)
/-- Let `p` be a seminorm on a vector space over a `NormedField`.
If there is a scalar `c` with `‖c‖>1`, then any `x` such that `p x ≠ 0` can be
moved by scalar multiplication to any `p`-shell of width `‖c‖`. Also recap information on the
value of `p` on the rescaling element that shows up in applications. -/
lemma rescale_to_shell (p : Seminorm 𝕜 E) {c : 𝕜} (hc : 1 < ‖c‖) {ε : ℝ} (εpos : 0 < ε) {x : E}
(hx : p x ≠ 0) :
∃ d : 𝕜, d ≠ 0 ∧ p (d • x) < ε ∧ (ε / ‖c‖ ≤ p (d • x)) ∧ (‖d‖⁻¹ ≤ ε⁻¹ * ‖c‖ * p x) :=
let ⟨_, hn⟩ := p.rescale_to_shell_zpow hc εpos hx; ⟨_, hn⟩
/-- Let `p` and `q` be two seminorms on a vector space over a `NontriviallyNormedField`.
If we have `q x ≤ C * p x` on some shell of the form `{x | ε/‖c‖ ≤ p x < ε}` (where `ε > 0`
and `‖c‖ > 1`), then we also have `q x ≤ C * p x` for all `x` such that `p x ≠ 0`. -/
lemma bound_of_shell
(p q : Seminorm 𝕜 E) {ε C : ℝ} (ε_pos : 0 < ε) {c : 𝕜} (hc : 1 < ‖c‖)
(hf : ∀ x, ε / ‖c‖ ≤ p x → p x < ε → q x ≤ C * p x) {x : E} (hx : p x ≠ 0) :
q x ≤ C * p x := by
rcases p.rescale_to_shell hc ε_pos hx with ⟨δ, hδ, δxle, leδx, -⟩
simpa only [map_smul_eq_mul, mul_left_comm C, mul_le_mul_iff_right₀ (norm_pos_iff.2 hδ)]
using hf (δ • x) leδx δxle
/-- A version of `Seminorm.bound_of_shell` expressed using pointwise scalar multiplication of
seminorms. -/
lemma bound_of_shell_smul
(p q : Seminorm 𝕜 E) {ε : ℝ} {C : ℝ≥0} (ε_pos : 0 < ε) {c : 𝕜} (hc : 1 < ‖c‖)
(hf : ∀ x, ε / ‖c‖ ≤ p x → p x < ε → q x ≤ (C • p) x) {x : E} (hx : p x ≠ 0) :
q x ≤ (C • p) x :=
Seminorm.bound_of_shell p q ε_pos hc hf hx
lemma bound_of_shell_sup (p : ι → Seminorm 𝕜 E) (s : Finset ι)
(q : Seminorm 𝕜 E) {ε : ℝ} {C : ℝ≥0} (ε_pos : 0 < ε) {c : 𝕜} (hc : 1 < ‖c‖)
(hf : ∀ x, (∀ i ∈ s, p i x < ε) → ∀ j ∈ s, ε / ‖c‖ ≤ p j x → q x ≤ (C • p j) x)
{x : E} (hx : ∃ j, j ∈ s ∧ p j x ≠ 0) :
q x ≤ (C • s.sup p) x := by
rcases hx with ⟨j, hj, hjx⟩
have : (s.sup p) x ≠ 0 :=
ne_of_gt ((hjx.symm.lt_of_le <| apply_nonneg _ _).trans_le (le_finset_sup_apply hj))
refine (s.sup p).bound_of_shell_smul q ε_pos hc (fun y hle hlt ↦ ?_) this
rcases exists_apply_eq_finset_sup p ⟨j, hj⟩ y with ⟨i, hi, hiy⟩
rw [smul_apply, hiy]
exact hf y (fun k hk ↦ (le_finset_sup_apply hk).trans_lt hlt) i hi (hiy ▸ hle)
end ShellLemmas
section NontriviallyNormedField
variable [NontriviallyNormedField 𝕜] [AddCommGroup E] [Module 𝕜 E]
/-- Let `p i` be a family of seminorms on `E`. Let `s` be an absorbent set in `𝕜`.
If all seminorms are uniformly bounded at every point of `s`,
then they are bounded in the space of seminorms. -/
lemma bddAbove_of_absorbent {ι : Sort*} {p : ι → Seminorm 𝕜 E} {s : Set E} (hs : Absorbent 𝕜 s)
(h : ∀ x ∈ s, BddAbove (range (p · x))) : BddAbove (range p) := by
rw [Seminorm.bddAbove_range_iff]
intro x
obtain ⟨c, hc₀, hc⟩ : ∃ c ≠ 0, (c : 𝕜) • x ∈ s :=
(eventually_mem_nhdsWithin.and (hs.eventually_nhdsNE_zero x)).exists
rcases h _ hc with ⟨M, hM⟩
refine ⟨M / ‖c‖, forall_mem_range.mpr fun i ↦ (le_div_iff₀' (norm_pos_iff.2 hc₀)).2 ?_⟩
exact hM ⟨i, map_smul_eq_mul ..⟩
end NontriviallyNormedField
end Seminorm
/-! ### The norm as a seminorm -/
section normSeminorm
variable (𝕜) (E) [NormedField 𝕜] [SeminormedAddCommGroup E] [NormedSpace 𝕜 E] {r : ℝ}
/-- The norm of a seminormed group as a seminorm. -/
def normSeminorm : Seminorm 𝕜 E :=
{ normAddGroupSeminorm E with smul' := norm_smul }
@[simp]
theorem coe_normSeminorm : ⇑(normSeminorm 𝕜 E) = norm :=
rfl
@[simp]
theorem ball_normSeminorm : (normSeminorm 𝕜 E).ball = Metric.ball := by
ext x r y
simp only [Seminorm.mem_ball, Metric.mem_ball, coe_normSeminorm, dist_eq_norm]
@[simp]
theorem closedBall_normSeminorm : (normSeminorm 𝕜 E).closedBall = Metric.closedBall := by
ext x r y
simp only [Seminorm.mem_closedBall, Metric.mem_closedBall, coe_normSeminorm, dist_eq_norm]
variable {𝕜 E} {x : E}
/-- Balls at the origin are absorbent. -/
theorem absorbent_ball_zero (hr : 0 < r) : Absorbent 𝕜 (Metric.ball (0 : E) r) := by
rw [← ball_normSeminorm 𝕜]
exact (normSeminorm _ _).absorbent_ball_zero hr
/-- Balls containing the origin are absorbent. -/
theorem absorbent_ball (hx : ‖x‖ < r) : Absorbent 𝕜 (Metric.ball x r) := by
rw [← ball_normSeminorm 𝕜]
exact (normSeminorm _ _).absorbent_ball hx
/-- Balls at the origin are balanced. -/
theorem balanced_ball_zero : Balanced 𝕜 (Metric.ball (0 : E) r) := by
rw [← ball_normSeminorm 𝕜]
exact (normSeminorm _ _).balanced_ball_zero r
/-- Closed balls at the origin are balanced. -/
theorem balanced_closedBall_zero : Balanced 𝕜 (Metric.closedBall (0 : E) r) := by
rw [← closedBall_normSeminorm 𝕜]
exact (normSeminorm _ _).balanced_closedBall_zero r
/-- If there is a scalar `c` with `‖c‖>1`, then any element with nonzero norm can be
moved by scalar multiplication to any shell of width `‖c‖`. Also recap information on the norm of
the rescaling element that shows up in applications. -/
lemma rescale_to_shell_semi_normed_zpow {c : 𝕜} (hc : 1 < ‖c‖) {ε : ℝ} (εpos : 0 < ε) {x : E}
(hx : ‖x‖ ≠ 0) :
∃ n : ℤ, c ^ n ≠ 0 ∧ ‖c ^ n • x‖ < ε ∧ (ε / ‖c‖ ≤ ‖c ^ n • x‖) ∧
(‖c ^ n‖⁻¹ ≤ ε⁻¹ * ‖c‖ * ‖x‖) :=
(normSeminorm 𝕜 E).rescale_to_shell_zpow hc εpos hx
/-- If there is a scalar `c` with `‖c‖>1`, then any element with nonzero norm can be
moved by scalar multiplication to any shell of width `‖c‖`. Also recap information on the norm of
the rescaling element that shows up in applications. -/
lemma rescale_to_shell_semi_normed {c : 𝕜} (hc : 1 < ‖c‖) {ε : ℝ} (εpos : 0 < ε)
{x : E} (hx : ‖x‖ ≠ 0) :
∃ d : 𝕜, d ≠ 0 ∧ ‖d • x‖ < ε ∧ (ε / ‖c‖ ≤ ‖d • x‖) ∧ (‖d‖⁻¹ ≤ ε⁻¹ * ‖c‖ * ‖x‖) :=
(normSeminorm 𝕜 E).rescale_to_shell hc εpos hx
lemma rescale_to_shell_zpow [NormedAddCommGroup F] [NormedSpace 𝕜 F] {c : 𝕜} (hc : 1 < ‖c‖)
{ε : ℝ} (εpos : 0 < ε) {x : F} (hx : x ≠ 0) :
∃ n : ℤ, c ^ n ≠ 0 ∧ ‖c ^ n • x‖ < ε ∧ (ε / ‖c‖ ≤ ‖c ^ n • x‖) ∧
(‖c ^ n‖⁻¹ ≤ ε⁻¹ * ‖c‖ * ‖x‖) :=
rescale_to_shell_semi_normed_zpow hc εpos (norm_ne_zero_iff.mpr hx)
/-- If there is a scalar `c` with `‖c‖>1`, then any element can be moved by scalar multiplication to
any shell of width `‖c‖`. Also recap information on the norm of the rescaling element that shows
up in applications. -/
lemma rescale_to_shell [NormedAddCommGroup F] [NormedSpace 𝕜 F] {c : 𝕜} (hc : 1 < ‖c‖)
{ε : ℝ} (εpos : 0 < ε) {x : F} (hx : x ≠ 0) :
∃ d : 𝕜, d ≠ 0 ∧ ‖d • x‖ < ε ∧ (ε / ‖c‖ ≤ ‖d • x‖) ∧ (‖d‖⁻¹ ≤ ε⁻¹ * ‖c‖ * ‖x‖) :=
rescale_to_shell_semi_normed hc εpos (norm_ne_zero_iff.mpr hx)
end normSeminorm |
.lake/packages/mathlib/Mathlib/Analysis/SumOverResidueClass.lean | import Mathlib.Analysis.Normed.Group.Basic
import Mathlib.Data.ZMod.Basic
import Mathlib.Topology.Instances.ENNReal.Lemmas
/-!
# Sums over residue classes
We consider infinite sums over functions `f` on `ℕ`, restricted to a residue class mod `m`.
The main result is `summable_indicator_mod_iff`, which states that when `f : ℕ → ℝ` is
decreasing, then the sum over `f` restricted to any residue class
mod `m ≠ 0` converges if and only if the sum over all of `ℕ` converges.
-/
lemma Finset.sum_indicator_mod {R : Type*} [AddCommMonoid R] (m : ℕ) [NeZero m] (f : ℕ → R) :
f = ∑ a : ZMod m, {n : ℕ | (n : ZMod m) = a}.indicator f := by
ext n
simp only [Finset.sum_apply, Set.indicator_apply, Set.mem_setOf_eq, Finset.sum_ite_eq,
Finset.mem_univ, ↓reduceIte]
open Set in
/-- A sequence `f` with values in an additive topological group `R` is summable on the
residue class of `k` mod `m` if and only if `f (m*n + k)` is summable. -/
lemma summable_indicator_mod_iff_summable {R : Type*} [AddCommGroup R] [TopologicalSpace R]
[IsTopologicalAddGroup R] (m : ℕ) [hm : NeZero m] (k : ℕ) (f : ℕ → R) :
Summable ({n : ℕ | (n : ZMod m) = k}.indicator f) ↔ Summable fun n ↦ f (m * n + k) := by
trans Summable ({n : ℕ | (n : ZMod m) = k ∧ k ≤ n}.indicator f)
· rw [← (finite_lt_nat k).summable_compl_iff (f := {n : ℕ | (n : ZMod m) = k}.indicator f)]
simp only [summable_subtype_iff_indicator, indicator_indicator, inter_comm, setOf_and,
compl_setOf, not_lt]
· let g : ℕ → ℕ := fun n ↦ m * n + k
have hg : Function.Injective g := fun m n hmn ↦ by simpa [g, hm.ne] using hmn
have hg' : ∀ n ∉ range g, {n : ℕ | (n : ZMod m) = k ∧ k ≤ n}.indicator f n = 0 := by
intro n hn
contrapose! hn
exact (Nat.range_mul_add m k).symm ▸ mem_of_indicator_ne_zero hn
convert (Function.Injective.summable_iff hg hg').symm using 3
simp only [Function.comp_apply, mem_setOf_eq, Nat.cast_add, Nat.cast_mul, CharP.cast_eq_zero,
zero_mul, zero_add, le_add_iff_nonneg_left, zero_le, and_self, indicator_of_mem, g]
/-- If `f : ℕ → ℝ` is decreasing and has a negative term, then `f` is not summable. -/
lemma not_summable_of_antitone_of_neg {f : ℕ → ℝ} (hf : Antitone f) {n : ℕ} (hn : f n < 0) :
¬ Summable f := by
intro hs
have := hs.tendsto_atTop_zero
simp only [Metric.tendsto_atTop, dist_zero_right, Real.norm_eq_abs] at this
obtain ⟨N, hN⟩ := this (|f n|) (abs_pos_of_neg hn)
specialize hN (max n N) (n.le_max_right N)
contrapose! hN; clear hN
have H : f (max n N) ≤ f n := hf (n.le_max_left N)
rwa [abs_of_neg hn, abs_of_neg (H.trans_lt hn), neg_le_neg_iff]
/-- If `f : ℕ → ℝ` is decreasing and has a negative term, then `f` restricted to a residue
class is not summable. -/
lemma not_summable_indicator_mod_of_antitone_of_neg {m : ℕ} [hm : NeZero m] {f : ℕ → ℝ}
(hf : Antitone f) {n : ℕ} (hn : f n < 0) (k : ZMod m) :
¬ Summable ({n : ℕ | (n : ZMod m) = k}.indicator f) := by
rw [← ZMod.natCast_zmod_val k, summable_indicator_mod_iff_summable]
exact not_summable_of_antitone_of_neg
(hf.comp_monotone <| (Covariant.monotone_of_const m).add_const k.val) <|
(hf <| (Nat.le_mul_of_pos_left n Fin.pos').trans <| Nat.le_add_right ..).trans_lt hn
/-- If a decreasing sequence of real numbers is summable on one residue class
modulo `m`, then it is also summable on every other residue class mod `m`. -/
lemma summable_indicator_mod_iff_summable_indicator_mod {m : ℕ} [NeZero m] {f : ℕ → ℝ}
(hf : Antitone f) {k : ZMod m} (l : ZMod m)
(hs : Summable ({n : ℕ | (n : ZMod m) = k}.indicator f)) :
Summable ({n : ℕ | (n : ZMod m) = l}.indicator f) := by
by_cases! hf₀ : ∀ n, 0 ≤ f n -- the interesting case
· rw [← ZMod.natCast_zmod_val k, summable_indicator_mod_iff_summable] at hs
have hl : (l.val + m : ZMod m) = l := by
simp only [ZMod.natCast_val, ZMod.cast_id', id_eq, CharP.cast_eq_zero, add_zero]
rw [← hl, ← Nat.cast_add, summable_indicator_mod_iff_summable]
exact hs.of_nonneg_of_le (fun _ ↦ hf₀ _)
fun _ ↦ hf <| Nat.add_le_add Nat.le.refl (k.val_lt.trans_le <| m.le_add_left l.val).le
· obtain ⟨n, hn⟩ := hf₀
exact (not_summable_indicator_mod_of_antitone_of_neg hf hn k hs).elim
/-- A decreasing sequence of real numbers is summable on a residue class
if and only if it is summable. -/
lemma summable_indicator_mod_iff {m : ℕ} [NeZero m] {f : ℕ → ℝ} (hf : Antitone f) (k : ZMod m) :
Summable ({n : ℕ | (n : ZMod m) = k}.indicator f) ↔ Summable f := by
refine ⟨fun H ↦ ?_, fun H ↦ Summable.indicator H _⟩
rw [Finset.sum_indicator_mod m f]
convert summable_sum (s := Finset.univ)
fun a _ ↦ summable_indicator_mod_iff_summable_indicator_mod hf a H
simp only [Finset.sum_apply]
open ZMod
/-- If `f` is a summable function on `ℕ`, and `0 < N`, then we may compute `∑' n : ℕ, f n` by
summing each residue class mod `N` separately. -/
lemma Nat.sumByResidueClasses {R : Type*} [AddCommGroup R] [UniformSpace R] [IsUniformAddGroup R]
[CompleteSpace R] [T0Space R] {f : ℕ → R} (hf : Summable f) (N : ℕ) [NeZero N] :
∑' n, f n = ∑ j : ZMod N, ∑' m, f (j.val + N * m) := by
rw [← (residueClassesEquiv N).symm.tsum_eq f, Summable.tsum_prod, tsum_fintype,
residueClassesEquiv, Equiv.coe_fn_symm_mk]
exact hf.comp_injective (residueClassesEquiv N).symm.injective |
.lake/packages/mathlib/Mathlib/Analysis/MellinInversion.lean | import Mathlib.Analysis.Fourier.Inversion
import Mathlib.Analysis.MellinTransform
/-!
# Mellin inversion formula
We derive the Mellin inversion formula as a consequence of the Fourier inversion formula.
## Main results
- `mellin_inversion`: The inverse Mellin transform of the Mellin transform applied to `x > 0` is x.
-/
open Real Complex Set MeasureTheory
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℂ E]
open scoped FourierTransform
private theorem rexp_neg_deriv_aux :
∀ x ∈ univ, HasDerivWithinAt (rexp ∘ Neg.neg) (-rexp (-x)) univ x :=
fun x _ ↦ mul_neg_one (rexp (-x)) ▸
((Real.hasDerivAt_exp (-x)).comp x (hasDerivAt_neg x)).hasDerivWithinAt
private theorem rexp_neg_image_aux : rexp ∘ Neg.neg '' univ = Ioi 0 := by
rw [Set.image_comp, Set.image_univ_of_surjective neg_surjective, Set.image_univ, Real.range_exp]
private theorem rexp_neg_injOn_aux : univ.InjOn (rexp ∘ Neg.neg) :=
Real.exp_injective.injOn.comp neg_injective.injOn (univ.mapsTo_univ _)
private theorem rexp_cexp_aux (x : ℝ) (s : ℂ) (f : E) :
rexp (-x) • cexp (-↑x) ^ (s - 1) • f = cexp (-s * ↑x) • f := by
change (rexp (-x) : ℂ) • _ = _ • f
rw [← smul_assoc, smul_eq_mul]
push_cast
conv in cexp _ * _ => lhs; rw [← cpow_one (cexp _)]
rw [← cpow_add _ _ (Complex.exp_ne_zero _), cpow_def_of_ne_zero (Complex.exp_ne_zero _),
Complex.log_exp (by simp [pi_pos]) (by simpa using pi_nonneg)]
ring_nf
theorem mellin_eq_fourierIntegral (f : ℝ → E) {s : ℂ} :
mellin f s = 𝓕 (fun (u : ℝ) ↦ (Real.exp (-s.re * u) • f (Real.exp (-u)))) (s.im / (2 * π)) :=
calc
mellin f s
= ∫ (u : ℝ), Complex.exp (-s * u) • f (Real.exp (-u)) := by
rw [mellin, ← rexp_neg_image_aux, integral_image_eq_integral_abs_deriv_smul
MeasurableSet.univ rexp_neg_deriv_aux rexp_neg_injOn_aux]
simp [rexp_cexp_aux]
_ = ∫ (u : ℝ), Complex.exp (↑(-2 * π * (u * (s.im / (2 * π)))) * I) •
(Real.exp (-s.re * u) • f (Real.exp (-u))) := by
congr
ext u
trans Complex.exp (-s.im * u * I) • (Real.exp (-s.re * u) • f (Real.exp (-u)))
· conv => lhs; rw [← re_add_im s]
rw [neg_add, add_mul, Complex.exp_add, mul_comm, ← smul_eq_mul, smul_assoc]
norm_cast
push_cast
ring_nf
congr
simp [field]
_ = 𝓕 (fun (u : ℝ) ↦ (Real.exp (-s.re * u) • f (Real.exp (-u)))) (s.im / (2 * π)) := by
simp [fourierIntegral_eq', mul_comm (_ / _)]
theorem mellinInv_eq_fourierIntegralInv (σ : ℝ) (f : ℂ → E) {x : ℝ} (hx : 0 < x) :
mellinInv σ f x =
(x : ℂ) ^ (-σ : ℂ) • 𝓕⁻ (fun (y : ℝ) ↦ f (σ + 2 * π * y * I)) (-Real.log x) := calc
mellinInv σ f x
= (x : ℂ) ^ (-σ : ℂ) •
(∫ (y : ℝ), Complex.exp (2 * π * (y * (-Real.log x)) * I) • f (σ + 2 * π * y * I)) := by
rw [mellinInv, one_div, ← abs_of_pos (show 0 < (2 * π)⁻¹ by simp [pi_pos])]
have hx0 : (x : ℂ) ≠ 0 := ofReal_ne_zero.mpr (ne_of_gt hx)
simp_rw [neg_add, cpow_add _ _ hx0, mul_smul, integral_smul]
rw [smul_comm, ← Measure.integral_comp_mul_left]
congr! 3
rw [cpow_def_of_ne_zero hx0, ← Complex.ofReal_log hx.le]
push_cast
ring_nf
_ = (x : ℂ) ^ (-σ : ℂ) • 𝓕⁻ (fun (y : ℝ) ↦ f (σ + 2 * π * y * I)) (-Real.log x) := by
simp [fourierIntegralInv_eq', mul_comm (Real.log _)]
variable [CompleteSpace E]
/-- The inverse Mellin transform of the Mellin transform applied to `x > 0` is x. -/
theorem mellin_inversion (σ : ℝ) (f : ℝ → E) {x : ℝ} (hx : 0 < x) (hf : MellinConvergent f σ)
(hFf : VerticalIntegrable (mellin f) σ) (hfx : ContinuousAt f x) :
mellinInv σ (mellin f) x = f x := by
let g := fun (u : ℝ) => Real.exp (-σ * u) • f (Real.exp (-u))
replace hf : Integrable g := by
rw [MellinConvergent, ← rexp_neg_image_aux, integrableOn_image_iff_integrableOn_abs_deriv_smul
MeasurableSet.univ rexp_neg_deriv_aux rexp_neg_injOn_aux] at hf
replace hf : Integrable fun (x : ℝ) ↦ cexp (-↑σ * ↑x) • f (rexp (-x)) := by
simpa [rexp_cexp_aux] using hf
norm_cast at hf
replace hFf : Integrable (𝓕 g) := by
have h2π : 2 * π ≠ 0 := by simp
have : Integrable (𝓕 (fun u ↦ rexp (-(σ * u)) • f (rexp (-u)))) := by
simpa [mellin_eq_fourierIntegral, mul_div_cancel_right₀ _ h2π] using hFf.comp_mul_right' h2π
simp_rw [neg_mul_eq_neg_mul] at this
exact this
replace hfx : ContinuousAt g (-Real.log x) := by
refine ContinuousAt.smul (by fun_prop) (ContinuousAt.comp ?_ (by fun_prop))
simpa [Real.exp_log hx] using hfx
calc
mellinInv σ (mellin f) x
= mellinInv σ (fun s ↦ 𝓕 g (s.im / (2 * π))) x := by
simp [g, mellinInv, mellin_eq_fourierIntegral]
_ = (x : ℂ) ^ (-σ : ℂ) • g (-Real.log x) := by
rw [mellinInv_eq_fourierIntegralInv _ _ hx, ← hf.fourier_inversion hFf hfx]
simp [mul_div_cancel_left₀ _ (show 2 * π ≠ 0 by simp)]
_ = (x : ℂ) ^ (-σ : ℂ) • rexp (σ * Real.log x) • f (rexp (Real.log x)) := by simp [g]
_ = f x := by
norm_cast
rw [mul_comm σ, ← rpow_def_of_pos hx, Real.exp_log hx, ← Complex.ofReal_cpow hx.le]
norm_cast
rw [← smul_assoc, smul_eq_mul, Real.rpow_neg hx.le,
inv_mul_cancel₀ (ne_of_gt (rpow_pos_of_pos hx σ)), one_smul] |
.lake/packages/mathlib/Mathlib/Analysis/LConvolution.lean | import Mathlib.MeasureTheory.Group.Prod
import Mathlib.MeasureTheory.Group.LIntegral
/-!
# Convolution of functions using the Lebesgue integral
In this file we define and prove properties about the convolution of two functions
using the Lebesgue integral.
## Design Decisions
We define the convolution of two functions using the Lebesgue integral (in the additive case)
by the formula `(f ⋆ₗ[μ] g) x = ∫⁻ y, (f y) * (g (-y + x)) ∂μ`. This does not agree with the
formula used by `MeasureTheory.convolution` for convolution of two functions, however it does agree
when the domain of `f` and `g` is a commutative group. The main reason for this is so that
(under sufficient conditions) if `{μ ν π : Measure G} {f g : G → ℝ≥0∞}` are such that
`μ = π.withDensity f`, `ν = π.withDensity g` where `π` is left-invariant then
`(μ ∗ ν) = π.withDensity (f ⋆ₗ[π] g)`. If the formula in `MeasureTheory.convolution` was used
the order of the densities would be flipped.
## Main Definitions
* `MeasureTheory.mlconvolution f g μ x = (f ⋆ₘₗ[μ] g) x = ∫⁻ y, (f y) * (g (y⁻¹ * x)) ∂μ`
is the multiplicative convolution of `f` and `g` w.r.t. the measure `μ`.
* `MeasureTheory.lconvolution f g μ x = (f ⋆ₗ[μ] g) x = ∫⁻ y, (f y) * (g (-y + x)) ∂μ`
is the additive convolution of `f` and `g` w.r.t. the measure `μ`.
-/
namespace MeasureTheory
open Measure
open scoped ENNReal
variable {G : Type*} {mG : MeasurableSpace G}
section NoGroup
variable [Mul G] [Inv G]
/-- Multiplicative convolution of functions. -/
@[to_additive /-- Additive convolution of functions -/]
noncomputable def mlconvolution (f g : G → ℝ≥0∞) (μ : Measure G) :
G → ℝ≥0∞ := fun x ↦ ∫⁻ y, (f y) * (g (y⁻¹ * x)) ∂μ
/-- Scoped notation for the multiplicative convolution of functions with respect to a measure `μ`.
-/
scoped[MeasureTheory] notation:67 f " ⋆ₘₗ["μ:67"] " g:66 => MeasureTheory.mlconvolution f g μ
/-- Scoped notation for the multiplicative convolution of functions with respect to `volume`. -/
scoped[MeasureTheory] notation:67 f " ⋆ₘₗ " g:66 => MeasureTheory.mlconvolution f g volume
/-- Scoped notation for the additive convolution of functions with respect to a measure `μ`. -/
scoped[MeasureTheory] notation:67 f " ⋆ₗ["μ:67"] " g:66 => MeasureTheory.lconvolution f g μ
/-- Scoped notation for the additive convolution of functions with respect to `volume`. -/
scoped[MeasureTheory] notation:67 f " ⋆ₗ " g:66 => MeasureTheory.lconvolution f g volume
/- The definition of multiplicative convolution of functions. -/
@[to_additive /-- The definition of additive convolution of functions. -/]
theorem mlconvolution_def {f g : G → ℝ≥0∞} {μ : Measure G} {x : G} :
(f ⋆ₘₗ[μ] g) x = ∫⁻ y, (f y) * (g (y⁻¹ * x)) ∂μ := rfl
/-- Convolution of the zero function with a function returns the zero function. -/
@[to_additive (attr := simp)
/-- Convolution of the zero function with a function returns the zero function. -/]
theorem zero_mlconvolution (f : G → ℝ≥0∞) (μ : Measure G) : 0 ⋆ₘₗ[μ] f = 0 := by
ext; simp [mlconvolution]
/-- Convolution of a function with the zero function returns the zero function. -/
@[to_additive (attr := simp)
/-- Convolution of a function with the zero function returns the zero function. -/]
theorem mlconvolution_zero (f : G → ℝ≥0∞) (μ : Measure G) : f ⋆ₘₗ[μ] 0 = 0 := by
ext; simp [mlconvolution]
section Measurable
variable [MeasurableMul₂ G] [MeasurableInv G]
/-- The convolution of measurable functions is measurable. -/
@[to_additive (attr := measurability, fun_prop)
/-- The convolution of measurable functions is measurable. -/]
theorem measurable_mlconvolution {f g : G → ℝ≥0∞} (μ : Measure G) [SFinite μ]
(hf : Measurable f) (hg : Measurable g) : Measurable (f ⋆ₘₗ[μ] g) := by
unfold mlconvolution
fun_prop
end Measurable
end NoGroup
section Group
variable [Group G] [MeasurableMul₂ G] [MeasurableInv G]
variable {μ : Measure G} [IsMulLeftInvariant μ] [SFinite μ]
/-- The convolution of `AEMeasurable` functions is `AEMeasurable`. -/
@[to_additive (attr := measurability, fun_prop)
/-- The convolution of `AEMeasurable` functions is `AEMeasurable`. -/]
theorem aemeasurable_mlconvolution {f g : G → ℝ≥0∞}
(hf : AEMeasurable f μ) (hg : AEMeasurable g μ) :
AEMeasurable (f ⋆ₘₗ[μ] g) μ := by
unfold mlconvolution
fun_prop
@[to_additive]
theorem mlconvolution_assoc₀ {f g k : G → ℝ≥0∞}
(hf : AEMeasurable f μ) (hg : AEMeasurable g μ) (hk : AEMeasurable k μ) :
f ⋆ₘₗ[μ] g ⋆ₘₗ[μ] k = (f ⋆ₘₗ[μ] g) ⋆ₘₗ[μ] k := by
ext x
simp only [mlconvolution_def]
conv in f _ * (∫⁻ _ , _ ∂μ) =>
rw [← lintegral_const_mul'' _ (by fun_prop), ← lintegral_mul_left_eq_self _ y⁻¹]
conv in (∫⁻ _ , _ ∂μ) * k _ =>
rw [← lintegral_mul_const'' _ (by fun_prop)]
rw [lintegral_lintegral_swap]
· simp [mul_assoc]
simpa [mul_assoc] using by fun_prop
/- Convolution is associative. -/
@[to_additive /-- Convolution is associative. -/]
theorem mlconvolution_assoc {f g k : G → ℝ≥0∞}
(hf : Measurable f) (hg : Measurable g) (hk : Measurable k) :
f ⋆ₘₗ[μ] g ⋆ₘₗ[μ] k = (f ⋆ₘₗ[μ] g) ⋆ₘₗ[μ] k :=
mlconvolution_assoc₀ hf.aemeasurable hg.aemeasurable hk.aemeasurable
end Group
section CommGroup
variable [CommGroup G] [MeasurableMul₂ G] [MeasurableInv G] {μ : Measure G}
/-- Convolution is commutative when the group is commutative. -/
@[to_additive /-- Convolution is commutative when the group is commutative. -/]
theorem mlconvolution_comm [IsMulLeftInvariant μ] [IsInvInvariant μ] {f g : G → ℝ≥0∞} :
(f ⋆ₘₗ[μ] g) = (g ⋆ₘₗ[μ] f) := by
ext x
simp only [mlconvolution_def]
rw [← lintegral_mul_left_eq_self _ x, ← lintegral_inv_eq_self]
simp [mul_comm]
end CommGroup
end MeasureTheory |
.lake/packages/mathlib/Mathlib/Analysis/InnerProductSpace/Orthonormal.lean | import Mathlib.Analysis.InnerProductSpace.LinearMap
import Mathlib.LinearAlgebra.FiniteDimensional.Lemmas
import Mathlib.RingTheory.LocalRing.Basic
/-!
# Orthonormal sets
This file defines orthonormal sets in inner product spaces.
## Main results
- We define `Orthonormal`, a predicate on a function `v : ι → E`, and prove the existence of a
maximal orthonormal set, `exists_maximal_orthonormal`.
- Bessel's inequality, `Orthonormal.tsum_inner_products_le`, states that given an orthonormal set
`v` and a vector `x`, the sum of the norm-squares of the inner products `⟪v i, x⟫` is no more
than the norm-square of `x`.
For the existence of orthonormal bases, Hilbert bases, etc., see the file
`Analysis.InnerProductSpace.projection`.
-/
noncomputable section
open RCLike Real Filter Module Topology ComplexConjugate Finsupp
open LinearMap (BilinForm)
variable {𝕜 E F : Type*} [RCLike 𝕜]
section OrthonormalSets_Seminormed
variable [SeminormedAddCommGroup E] [InnerProductSpace 𝕜 E]
variable [SeminormedAddCommGroup F] [InnerProductSpace ℝ F]
local notation "⟪" x ", " y "⟫" => inner 𝕜 x y
variable {ι : Type*} (𝕜)
/-- An orthonormal set of vectors in an `InnerProductSpace` -/
def Orthonormal (v : ι → E) : Prop :=
(∀ i, ‖v i‖ = 1) ∧ Pairwise fun i j => ⟪v i, v j⟫ = 0
variable {𝕜}
@[simp]
lemma Orthonormal.of_isEmpty [IsEmpty ι] (v : ι → E) : Orthonormal 𝕜 v :=
⟨IsEmpty.elim ‹_›, Subsingleton.pairwise⟩
@[simp]
lemma orthonormal_vecCons_iff {n : ℕ} {v : E} {vs : Fin n → E} :
Orthonormal 𝕜 (Matrix.vecCons v vs) ↔ ‖v‖ = 1 ∧ (∀ i, ⟪v, vs i⟫ = 0) ∧ Orthonormal 𝕜 vs := by
simp_rw [Orthonormal, pairwise_fin_succ_iff_of_isSymm, Fin.forall_fin_succ]
tauto
lemma Orthonormal.norm_eq_one {v : ι → E} (h : Orthonormal 𝕜 v) (i : ι) :
‖v i‖ = 1 := h.1 i
lemma Orthonormal.nnnorm_eq_one {v : ι → E} (h : Orthonormal 𝕜 v) (i : ι) :
‖v i‖₊ = 1 := by
suffices (‖v i‖₊ : ℝ) = 1 by norm_cast at this
simp [h.norm_eq_one]
lemma Orthonormal.enorm_eq_one {v : ι → E} (h : Orthonormal 𝕜 v) (i : ι) :
‖v i‖ₑ = 1 := by rw [← ofReal_norm]; simp [h.norm_eq_one]
lemma Orthonormal.inner_eq_zero {v : ι → E} {i j : ι} (h : Orthonormal 𝕜 v) (hij : i ≠ j) :
⟪v i, v j⟫ = 0 := h.2 hij
/-- `if ... then ... else` characterization of an indexed set of vectors being orthonormal. (Inner
product equals Kronecker delta.) -/
theorem orthonormal_iff_ite [DecidableEq ι] {v : ι → E} :
Orthonormal 𝕜 v ↔ ∀ i j, ⟪v i, v j⟫ = if i = j then (1 : 𝕜) else (0 : 𝕜) := by
constructor
· intro hv i j
split_ifs with h
· simp [h, inner_self_eq_norm_sq_to_K, hv.norm_eq_one]
· exact hv.inner_eq_zero h
· intro h
constructor
· intro i
have h' : ‖v i‖ ^ 2 = 1 ^ 2 := by
rw [@norm_sq_eq_re_inner 𝕜, h i i]; simp
have h₁ : 0 ≤ ‖v i‖ := norm_nonneg _
have h₂ : (0 : ℝ) ≤ 1 := zero_le_one
rwa [sq_eq_sq₀ h₁ h₂] at h'
· intro i j hij
simpa [hij] using h i j
/-- `if ... then ... else` characterization of a set of vectors being orthonormal. (Inner product
equals Kronecker delta.) -/
theorem orthonormal_subtype_iff_ite [DecidableEq E] {s : Set E} :
Orthonormal 𝕜 (Subtype.val : s → E) ↔ ∀ v ∈ s, ∀ w ∈ s, ⟪v, w⟫ = if v = w then 1 else 0 := by
rw [orthonormal_iff_ite]
simp
/-- The inner product of a linear combination of a set of orthonormal vectors with one of those
vectors picks out the coefficient of that vector. -/
theorem Orthonormal.inner_right_finsupp {v : ι → E} (hv : Orthonormal 𝕜 v) (l : ι →₀ 𝕜) (i : ι) :
⟪v i, linearCombination 𝕜 v l⟫ = l i := by
classical
simpa [linearCombination_apply, Finsupp.inner_sum, orthonormal_iff_ite.mp hv] using Eq.symm
/-- The inner product of a linear combination of a set of orthonormal vectors with one of those
vectors picks out the coefficient of that vector. -/
theorem Orthonormal.inner_right_sum {v : ι → E} (hv : Orthonormal 𝕜 v) (l : ι → 𝕜) {s : Finset ι}
{i : ι} (hi : i ∈ s) : ⟪v i, ∑ i ∈ s, l i • v i⟫ = l i := by
classical
simp [inner_sum, inner_smul_right, orthonormal_iff_ite.mp hv, hi]
/-- The inner product of a linear combination of a set of orthonormal vectors with one of those
vectors picks out the coefficient of that vector. -/
theorem Orthonormal.inner_right_fintype [Fintype ι] {v : ι → E} (hv : Orthonormal 𝕜 v) (l : ι → 𝕜)
(i : ι) : ⟪v i, ∑ i : ι, l i • v i⟫ = l i :=
hv.inner_right_sum l (Finset.mem_univ _)
/-- The inner product of a linear combination of a set of orthonormal vectors with one of those
vectors picks out the coefficient of that vector. -/
theorem Orthonormal.inner_left_finsupp {v : ι → E} (hv : Orthonormal 𝕜 v) (l : ι →₀ 𝕜) (i : ι) :
⟪linearCombination 𝕜 v l, v i⟫ = conj (l i) := by rw [← inner_conj_symm, hv.inner_right_finsupp]
/-- The inner product of a linear combination of a set of orthonormal vectors with one of those
vectors picks out the coefficient of that vector. -/
theorem Orthonormal.inner_left_sum {v : ι → E} (hv : Orthonormal 𝕜 v) (l : ι → 𝕜) {s : Finset ι}
{i : ι} (hi : i ∈ s) : ⟪∑ i ∈ s, l i • v i, v i⟫ = conj (l i) := by
classical
simp only [sum_inner, inner_smul_left, orthonormal_iff_ite.mp hv, hi, mul_boole,
Finset.sum_ite_eq', if_true]
/-- The inner product of a linear combination of a set of orthonormal vectors with one of those
vectors picks out the coefficient of that vector. -/
theorem Orthonormal.inner_left_fintype [Fintype ι] {v : ι → E} (hv : Orthonormal 𝕜 v) (l : ι → 𝕜)
(i : ι) : ⟪∑ i : ι, l i • v i, v i⟫ = conj (l i) :=
hv.inner_left_sum l (Finset.mem_univ _)
/-- The inner product of two linear combinations of a set of orthonormal vectors, expressed as
a sum over the first `Finsupp`. -/
theorem Orthonormal.inner_finsupp_eq_sum_left {v : ι → E} (hv : Orthonormal 𝕜 v) (l₁ l₂ : ι →₀ 𝕜) :
⟪linearCombination 𝕜 v l₁, linearCombination 𝕜 v l₂⟫ = l₁.sum fun i y => conj y * l₂ i := by
simp only [l₁.linearCombination_apply _, Finsupp.sum_inner, hv.inner_right_finsupp, smul_eq_mul]
/-- The inner product of two linear combinations of a set of orthonormal vectors, expressed as
a sum over the second `Finsupp`. -/
theorem Orthonormal.inner_finsupp_eq_sum_right {v : ι → E} (hv : Orthonormal 𝕜 v) (l₁ l₂ : ι →₀ 𝕜) :
⟪linearCombination 𝕜 v l₁, linearCombination 𝕜 v l₂⟫ = l₂.sum fun i y => conj (l₁ i) * y := by
simp only [l₂.linearCombination_apply _, Finsupp.inner_sum, hv.inner_left_finsupp, mul_comm,
smul_eq_mul]
/-- The inner product of two linear combinations of a set of orthonormal vectors, expressed as
a sum. -/
protected theorem Orthonormal.inner_sum {v : ι → E} (hv : Orthonormal 𝕜 v) (l₁ l₂ : ι → 𝕜)
(s : Finset ι) : ⟪∑ i ∈ s, l₁ i • v i, ∑ i ∈ s, l₂ i • v i⟫ = ∑ i ∈ s, conj (l₁ i) * l₂ i := by
simp_rw [sum_inner, inner_smul_left]
refine Finset.sum_congr rfl fun i hi => ?_
rw [hv.inner_right_sum l₂ hi]
/--
The double sum of weighted inner products of pairs of vectors from an orthonormal sequence is the
sum of the weights.
-/
theorem Orthonormal.inner_left_right_finset {s : Finset ι} {v : ι → E} (hv : Orthonormal 𝕜 v)
{a : ι → ι → 𝕜} : (∑ i ∈ s, ∑ j ∈ s, a i j • ⟪v j, v i⟫) = ∑ k ∈ s, a k k := by
classical
simp [orthonormal_iff_ite.mp hv]
/-- An orthonormal set is linearly independent. -/
theorem Orthonormal.linearIndependent {v : ι → E} (hv : Orthonormal 𝕜 v) :
LinearIndependent 𝕜 v := by
rw [linearIndependent_iff]
intro l hl
ext i
have key : ⟪v i, Finsupp.linearCombination 𝕜 v l⟫ = ⟪v i, 0⟫ := by rw [hl]
simpa only [hv.inner_right_finsupp, inner_zero_right] using key
/-- A subfamily of an orthonormal family (i.e., a composition with an injective map) is an
orthonormal family. -/
theorem Orthonormal.comp {ι' : Type*} {v : ι → E} (hv : Orthonormal 𝕜 v) (f : ι' → ι)
(hf : Function.Injective f) : Orthonormal 𝕜 (v ∘ f) := by
classical
rw [orthonormal_iff_ite] at hv ⊢
intro i j
convert hv (f i) (f j) using 1
simp [hf.eq_iff]
/-- An injective family `v : ι → E` is orthonormal if and only if `Subtype.val : (range v) → E` is
orthonormal. -/
theorem orthonormal_subtype_range {v : ι → E} (hv : Function.Injective v) :
Orthonormal 𝕜 (Subtype.val : Set.range v → E) ↔ Orthonormal 𝕜 v := by
let f : ι ≃ Set.range v := Equiv.ofInjective v hv
refine ⟨fun h => h.comp f f.injective, fun h => ?_⟩
rw [← Equiv.self_comp_ofInjective_symm hv]
exact h.comp f.symm f.symm.injective
/-- If `v : ι → E` is an orthonormal family, then `Subtype.val : (range v) → E` is an orthonormal
family. -/
theorem Orthonormal.toSubtypeRange {v : ι → E} (hv : Orthonormal 𝕜 v) :
Orthonormal 𝕜 (Subtype.val : Set.range v → E) :=
(orthonormal_subtype_range hv.linearIndependent.injective).2 hv
/-- A linear combination of some subset of an orthonormal set is orthogonal to other members of the
set. -/
theorem Orthonormal.inner_finsupp_eq_zero {v : ι → E} (hv : Orthonormal 𝕜 v) {s : Set ι} {i : ι}
(hi : i ∉ s) {l : ι →₀ 𝕜} (hl : l ∈ Finsupp.supported 𝕜 𝕜 s) :
⟪Finsupp.linearCombination 𝕜 v l, v i⟫ = 0 := by
rw [Finsupp.mem_supported'] at hl
simp only [hv.inner_left_finsupp, hl i hi, map_zero]
/-- Given an orthonormal family, a second family of vectors is orthonormal if every vector equals
the corresponding vector in the original family or its negation. -/
theorem Orthonormal.orthonormal_of_forall_eq_or_eq_neg {v w : ι → E} (hv : Orthonormal 𝕜 v)
(hw : ∀ i, w i = v i ∨ w i = -v i) : Orthonormal 𝕜 w := by
classical
rw [orthonormal_iff_ite] at *
intro i j
rcases hw i with hi | hi <;> rcases hw j with hj | hj <;>
replace hv := hv i j <;> split_ifs at hv ⊢ with h <;>
simpa only [hi, hj, h, inner_neg_right, inner_neg_left, neg_neg, eq_self_iff_true,
neg_eq_zero] using hv
/- The material that follows, culminating in the existence of a maximal orthonormal subset, is
adapted from the corresponding development of the theory of linearly independent sets. See
`exists_linearIndependent` in particular. -/
variable (𝕜 E)
theorem orthonormal_empty : Orthonormal 𝕜 (fun x => x : (∅ : Set E) → E) := by
classical
simp
variable {𝕜 E}
theorem orthonormal_iUnion_of_directed {η : Type*} {s : η → Set E} (hs : Directed (· ⊆ ·) s)
(h : ∀ i, Orthonormal 𝕜 (fun x => x : s i → E)) :
Orthonormal 𝕜 (fun x => x : (⋃ i, s i) → E) := by
classical
rw [orthonormal_subtype_iff_ite]
rintro x ⟨_, ⟨i, rfl⟩, hxi⟩ y ⟨_, ⟨j, rfl⟩, hyj⟩
obtain ⟨k, hik, hjk⟩ := hs i j
have h_orth : Orthonormal 𝕜 (fun x => x : s k → E) := h k
rw [orthonormal_subtype_iff_ite] at h_orth
exact h_orth x (hik hxi) y (hjk hyj)
theorem orthonormal_sUnion_of_directed {s : Set (Set E)} (hs : DirectedOn (· ⊆ ·) s)
(h : ∀ a ∈ s, Orthonormal 𝕜 (fun x => ((x : a) : E))) :
Orthonormal 𝕜 (fun x => x : ⋃₀ s → E) := by
rw [Set.sUnion_eq_iUnion]; exact orthonormal_iUnion_of_directed hs.directed_val (by simpa using h)
/-- Given an orthonormal set `v` of vectors in `E`, there exists a maximal orthonormal set
containing it. -/
theorem exists_maximal_orthonormal {s : Set E} (hs : Orthonormal 𝕜 (Subtype.val : s → E)) :
∃ w ⊇ s, Orthonormal 𝕜 (Subtype.val : w → E) ∧
∀ u ⊇ w, Orthonormal 𝕜 (Subtype.val : u → E) → u = w := by
have := zorn_subset_nonempty { b | Orthonormal 𝕜 (Subtype.val : b → E) } ?_ _ hs
· obtain ⟨b, hb⟩ := this
exact ⟨b, hb.1, hb.2.1, fun u hus hu => hb.2.eq_of_ge hu hus⟩
· refine fun c hc cc _c0 => ⟨⋃₀ c, ?_, ?_⟩
· exact orthonormal_sUnion_of_directed cc.directedOn fun x xc => hc xc
· exact fun _ => Set.subset_sUnion_of_mem
open Module
/-- A family of orthonormal vectors with the correct cardinality forms a basis. -/
def basisOfOrthonormalOfCardEqFinrank [Fintype ι] [Nonempty ι] {v : ι → E} (hv : Orthonormal 𝕜 v)
(card_eq : Fintype.card ι = finrank 𝕜 E) : Basis ι 𝕜 E :=
basisOfLinearIndependentOfCardEqFinrank hv.linearIndependent card_eq
@[simp]
theorem coe_basisOfOrthonormalOfCardEqFinrank [Fintype ι] [Nonempty ι] {v : ι → E}
(hv : Orthonormal 𝕜 v) (card_eq : Fintype.card ι = finrank 𝕜 E) :
(basisOfOrthonormalOfCardEqFinrank hv card_eq : ι → E) = v :=
coe_basisOfLinearIndependentOfCardEqFinrank _ _
theorem Orthonormal.ne_zero {v : ι → E} (hv : Orthonormal 𝕜 v) (i : ι) : v i ≠ 0 := by
refine ne_of_apply_ne norm ?_
rw [hv.1 i, norm_zero]
simp
end OrthonormalSets_Seminormed
section Norm_Seminormed
open scoped InnerProductSpace
variable [SeminormedAddCommGroup E] [InnerProductSpace 𝕜 E]
variable [SeminormedAddCommGroup F] [InnerProductSpace ℝ F]
local notation "⟪" x ", " y "⟫" => inner 𝕜 x y
section
variable {ι : Type*} {ι' : Type*} {ι'' : Type*}
variable {E' : Type*} [SeminormedAddCommGroup E'] [InnerProductSpace 𝕜 E']
variable {E'' : Type*} [SeminormedAddCommGroup E''] [InnerProductSpace 𝕜 E'']
/-- A linear isometry preserves the property of being orthonormal. -/
theorem LinearIsometry.orthonormal_comp_iff {v : ι → E} (f : E →ₗᵢ[𝕜] E') :
Orthonormal 𝕜 (f ∘ v) ↔ Orthonormal 𝕜 v := by
classical simp_rw [orthonormal_iff_ite, Function.comp_apply, LinearIsometry.inner_map_map]
/-- A linear isometry preserves the property of being orthonormal. -/
theorem Orthonormal.comp_linearIsometry {v : ι → E} (hv : Orthonormal 𝕜 v) (f : E →ₗᵢ[𝕜] E') :
Orthonormal 𝕜 (f ∘ v) := by rwa [f.orthonormal_comp_iff]
/-- A linear isometric equivalence preserves the property of being orthonormal. -/
theorem Orthonormal.comp_linearIsometryEquiv {v : ι → E} (hv : Orthonormal 𝕜 v) (f : E ≃ₗᵢ[𝕜] E') :
Orthonormal 𝕜 (f ∘ v) :=
hv.comp_linearIsometry f.toLinearIsometry
/-- A linear isometric equivalence, applied with `Basis.map`, preserves the property of being
orthonormal. -/
theorem Orthonormal.mapLinearIsometryEquiv {v : Basis ι 𝕜 E} (hv : Orthonormal 𝕜 v)
(f : E ≃ₗᵢ[𝕜] E') : Orthonormal 𝕜 (v.map f.toLinearEquiv) :=
hv.comp_linearIsometryEquiv f
/-- A linear map that sends an orthonormal basis to orthonormal vectors is a linear isometry. -/
def LinearMap.isometryOfOrthonormal (f : E →ₗ[𝕜] E') {v : Basis ι 𝕜 E} (hv : Orthonormal 𝕜 v)
(hf : Orthonormal 𝕜 (f ∘ v)) : E →ₗᵢ[𝕜] E' :=
f.isometryOfInner fun x y => by
classical rw [← v.linearCombination_repr x, ← v.linearCombination_repr y,
Finsupp.apply_linearCombination, Finsupp.apply_linearCombination,
hv.inner_finsupp_eq_sum_left, hf.inner_finsupp_eq_sum_left]
@[simp]
theorem LinearMap.coe_isometryOfOrthonormal (f : E →ₗ[𝕜] E') {v : Basis ι 𝕜 E}
(hv : Orthonormal 𝕜 v) (hf : Orthonormal 𝕜 (f ∘ v)) : ⇑(f.isometryOfOrthonormal hv hf) = f :=
rfl
@[simp]
theorem LinearMap.isometryOfOrthonormal_toLinearMap (f : E →ₗ[𝕜] E') {v : Basis ι 𝕜 E}
(hv : Orthonormal 𝕜 v) (hf : Orthonormal 𝕜 (f ∘ v)) :
(f.isometryOfOrthonormal hv hf).toLinearMap = f :=
rfl
/-- A linear equivalence that sends an orthonormal basis to orthonormal vectors is a linear
isometric equivalence. -/
def LinearEquiv.isometryOfOrthonormal (f : E ≃ₗ[𝕜] E') {v : Basis ι 𝕜 E} (hv : Orthonormal 𝕜 v)
(hf : Orthonormal 𝕜 (f ∘ v)) : E ≃ₗᵢ[𝕜] E' :=
f.isometryOfInner fun x y => by
rw [← LinearEquiv.coe_coe] at hf
classical rw [← v.linearCombination_repr x, ← v.linearCombination_repr y,
← LinearEquiv.coe_coe f, Finsupp.apply_linearCombination,
Finsupp.apply_linearCombination, hv.inner_finsupp_eq_sum_left, hf.inner_finsupp_eq_sum_left]
@[simp]
theorem LinearEquiv.coe_isometryOfOrthonormal (f : E ≃ₗ[𝕜] E') {v : Basis ι 𝕜 E}
(hv : Orthonormal 𝕜 v) (hf : Orthonormal 𝕜 (f ∘ v)) : ⇑(f.isometryOfOrthonormal hv hf) = f :=
rfl
@[simp]
theorem LinearEquiv.isometryOfOrthonormal_toLinearEquiv (f : E ≃ₗ[𝕜] E') {v : Basis ι 𝕜 E}
(hv : Orthonormal 𝕜 v) (hf : Orthonormal 𝕜 (f ∘ v)) :
(f.isometryOfOrthonormal hv hf).toLinearEquiv = f :=
rfl
/-- A linear isometric equivalence that sends an orthonormal basis to a given orthonormal basis. -/
def Orthonormal.equiv {v : Basis ι 𝕜 E} (hv : Orthonormal 𝕜 v) {v' : Basis ι' 𝕜 E'}
(hv' : Orthonormal 𝕜 v') (e : ι ≃ ι') : E ≃ₗᵢ[𝕜] E' :=
(v.equiv v' e).isometryOfOrthonormal hv
(by
have h : v.equiv v' e ∘ v = v' ∘ e := by
ext i
simp
rw [h]
classical exact hv'.comp _ e.injective)
@[simp]
theorem Orthonormal.equiv_toLinearEquiv {v : Basis ι 𝕜 E} (hv : Orthonormal 𝕜 v)
{v' : Basis ι' 𝕜 E'} (hv' : Orthonormal 𝕜 v') (e : ι ≃ ι') :
(hv.equiv hv' e).toLinearEquiv = v.equiv v' e :=
rfl
@[simp]
theorem Orthonormal.equiv_apply {ι' : Type*} {v : Basis ι 𝕜 E} (hv : Orthonormal 𝕜 v)
{v' : Basis ι' 𝕜 E'} (hv' : Orthonormal 𝕜 v') (e : ι ≃ ι') (i : ι) :
hv.equiv hv' e (v i) = v' (e i) :=
Basis.equiv_apply _ _ _ _
@[simp]
theorem Orthonormal.equiv_trans {v : Basis ι 𝕜 E} (hv : Orthonormal 𝕜 v) {v' : Basis ι' 𝕜 E'}
(hv' : Orthonormal 𝕜 v') (e : ι ≃ ι') {v'' : Basis ι'' 𝕜 E''} (hv'' : Orthonormal 𝕜 v'')
(e' : ι' ≃ ι'') : (hv.equiv hv' e).trans (hv'.equiv hv'' e') = hv.equiv hv'' (e.trans e') :=
v.ext_linearIsometryEquiv fun i => by
simp only [LinearIsometryEquiv.trans_apply, Orthonormal.equiv_apply, e.coe_trans,
Function.comp_apply]
theorem Orthonormal.map_equiv {v : Basis ι 𝕜 E} (hv : Orthonormal 𝕜 v) {v' : Basis ι' 𝕜 E'}
(hv' : Orthonormal 𝕜 v') (e : ι ≃ ι') :
v.map (hv.equiv hv' e).toLinearEquiv = v'.reindex e.symm :=
v.map_equiv _ _
end
section
variable {ι : Type*} {ι' : Type*} {E' : Type*} [SeminormedAddCommGroup E'] [InnerProductSpace 𝕜 E']
@[simp]
theorem Orthonormal.equiv_refl {v : Basis ι 𝕜 E} (hv : Orthonormal 𝕜 v) :
hv.equiv hv (Equiv.refl ι) = LinearIsometryEquiv.refl 𝕜 E :=
v.ext_linearIsometryEquiv fun i => by
simp only [Orthonormal.equiv_apply, Equiv.coe_refl, id, LinearIsometryEquiv.coe_refl]
@[simp]
theorem Orthonormal.equiv_symm {v : Basis ι 𝕜 E} (hv : Orthonormal 𝕜 v) {v' : Basis ι' 𝕜 E'}
(hv' : Orthonormal 𝕜 v') (e : ι ≃ ι') : (hv.equiv hv' e).symm = hv'.equiv hv e.symm :=
v'.ext_linearIsometryEquiv fun i =>
(hv.equiv hv' e).injective <| by
simp only [LinearIsometryEquiv.apply_symm_apply, Orthonormal.equiv_apply, e.apply_symm_apply]
end
end Norm_Seminormed
section BesselsInequality
variable [SeminormedAddCommGroup E] [InnerProductSpace 𝕜 E]
variable {ι : Type*} (x : E) {v : ι → E}
local notation "⟪" x ", " y "⟫" => inner 𝕜 x y
/-- Bessel's inequality for finite sums. -/
theorem Orthonormal.sum_inner_products_le {s : Finset ι} (hv : Orthonormal 𝕜 v) :
∑ i ∈ s, ‖⟪v i, x⟫‖ ^ 2 ≤ ‖x‖ ^ 2 := by
have h₂ :
(∑ i ∈ s, ∑ j ∈ s, ⟪v i, x⟫ * ⟪x, v j⟫ * ⟪v j, v i⟫) = (∑ k ∈ s, ⟪v k, x⟫ * ⟪x, v k⟫ : 𝕜) := by
classical exact hv.inner_left_right_finset
have h₃ : ∀ z : 𝕜, re (z * conj z) = ‖z‖ ^ 2 := by
intro z
simp only [mul_conj]
norm_cast
suffices hbf : ‖x - ∑ i ∈ s, ⟪v i, x⟫ • v i‖ ^ 2 = ‖x‖ ^ 2 - ∑ i ∈ s, ‖⟪v i, x⟫‖ ^ 2 by
rw [← sub_nonneg, ← hbf]
simp only [norm_nonneg, pow_nonneg]
rw [@norm_sub_sq 𝕜, sub_add]
simp only [@InnerProductSpace.norm_sq_eq_re_inner 𝕜 E, inner_sum, sum_inner]
simp only [inner_smul_right, two_mul, inner_smul_left, inner_conj_symm, ← mul_assoc, h₂,
add_sub_cancel_right, sub_right_inj]
simp only [map_sum, ← inner_conj_symm x, ← h₃]
/-- Bessel's inequality. -/
theorem Orthonormal.tsum_inner_products_le (hv : Orthonormal 𝕜 v) :
∑' i, ‖⟪v i, x⟫‖ ^ 2 ≤ ‖x‖ ^ 2 := by
refine tsum_le_of_sum_le' ?_ fun s => hv.sum_inner_products_le x
simp only [norm_nonneg, pow_nonneg]
/-- The sum defined in Bessel's inequality is summable. -/
theorem Orthonormal.inner_products_summable (hv : Orthonormal 𝕜 v) :
Summable fun i => ‖⟪v i, x⟫‖ ^ 2 := by
use ⨆ s : Finset ι, ∑ i ∈ s, ‖⟪v i, x⟫‖ ^ 2
apply hasSum_of_isLUB_of_nonneg
· intro b
simp only [norm_nonneg, pow_nonneg]
· refine isLUB_ciSup ?_
use ‖x‖ ^ 2
rintro y ⟨s, rfl⟩
exact hv.sum_inner_products_le x
end BesselsInequality |
.lake/packages/mathlib/Mathlib/Analysis/InnerProductSpace/Convex.lean | import Mathlib.Analysis.Convex.Uniform
import Mathlib.Analysis.InnerProductSpace.Basic
/-!
# Convexity properties of inner product spaces
## Main results
- `InnerProductSpace.toUniformConvexSpace`: an inner product space is a uniformly convex space.
## Tags
inner product space, Hilbert space, norm
-/
noncomputable section
open RCLike Real Filter Topology ComplexConjugate Finsupp
open LinearMap (BilinForm)
variable {𝕜 E F : Type*} [RCLike 𝕜] [SeminormedAddCommGroup E] [InnerProductSpace 𝕜 E]
[SeminormedAddCommGroup F] [InnerProductSpace ℝ F]
-- See note [lower instance priority]
instance (priority := 100) InnerProductSpace.toUniformConvexSpace : UniformConvexSpace F :=
⟨fun ε hε => by
refine
⟨2 - √(4 - ε ^ 2), sub_pos_of_lt <| (sqrt_lt' zero_lt_two).2 ?_, fun x hx y hy hxy => ?_⟩
· norm_num
exact pow_pos hε _
rw [sub_sub_cancel]
refine le_sqrt_of_sq_le ?_
rw [sq, eq_sub_iff_add_eq.2 (parallelogram_law_with_norm ℝ x y), ← sq ‖x - y‖, hx, hy]
ring_nf
gcongr⟩ |
.lake/packages/mathlib/Mathlib/Analysis/InnerProductSpace/MeanErgodic.lean | import Mathlib.Analysis.InnerProductSpace.Projection.Submodule
import Mathlib.Dynamics.BirkhoffSum.NormedSpace
/-!
# Von Neumann Mean Ergodic Theorem in a Hilbert Space
In this file we prove the von Neumann Mean Ergodic Theorem for an operator in a Hilbert space.
It says that for a contracting linear self-map `f : E →ₗ[𝕜] E` of a Hilbert space,
the Birkhoff averages
```
birkhoffAverage 𝕜 f id N x = (N : 𝕜)⁻¹ • ∑ n ∈ Finset.range N, f^[n] x
```
converge to the orthogonal projection of `x` to the subspace of fixed points of `f`,
see `ContinuousLinearMap.tendsto_birkhoffAverage_orthogonalProjection`.
-/
open Filter Finset Function Bornology
open scoped Topology
variable {𝕜 E : Type*} [RCLike 𝕜] [NormedAddCommGroup E]
/-- **Von Neumann Mean Ergodic Theorem**, a version for a normed space.
Let `f : E → E` be a contracting linear self-map of a normed space.
Let `S` be the subspace of fixed points of `f`.
Let `g : E → S` be a continuous linear projection, `g|_S=id`.
If the range of `f - id` is dense in the kernel of `g`,
then for each `x`, the Birkhoff averages
```
birkhoffAverage 𝕜 f id N x = (N : 𝕜)⁻¹ • ∑ n ∈ Finset.range N, f^[n] x
```
converge to `g x` as `N → ∞`.
Usually, this fact is not formulated as a separate lemma.
I chose to do it in order to isolate parts of the proof that do not rely
on the inner product space structure.
-/
theorem LinearMap.tendsto_birkhoffAverage_of_ker_subset_closure [NormedSpace 𝕜 E]
(f : E →ₗ[𝕜] E) (hf : LipschitzWith 1 f) (g : E →L[𝕜] LinearMap.eqLocus f 1)
(hg_proj : ∀ x : LinearMap.eqLocus f 1, g x = x)
(hg_ker : (LinearMap.ker g : Set E) ⊆ closure (LinearMap.range (f - 1))) (x : E) :
Tendsto (birkhoffAverage 𝕜 f _root_.id · x) atTop (𝓝 (g x)) := by
/- Any point can be represented as a sum of `y ∈ LinearMap.ker g` and a fixed point `z`. -/
obtain ⟨y, hy, z, hz, rfl⟩ : ∃ y, g y = 0 ∧ ∃ z, IsFixedPt f z ∧ x = y + z :=
⟨x - g x, by simp [hg_proj], g x, (g x).2, by simp⟩
/- For a fixed point, the theorem is trivial,
so it suffices to prove it for `y ∈ LinearMap.ker g`. -/
suffices Tendsto (birkhoffAverage 𝕜 f _root_.id · y) atTop (𝓝 0) by
have hgz : g z = z := congr_arg Subtype.val (hg_proj ⟨z, hz⟩)
simpa [hy, hgz, birkhoffAverage, birkhoffSum, Finset.sum_add_distrib, smul_add]
using this.add (hz.tendsto_birkhoffAverage 𝕜 _root_.id)
/- By continuity, it suffices to prove the theorem on a dense subset of `LinearMap.ker g`.
By assumption, `LinearMap.range (f - 1)` is dense in the kernel of `g`,
so it suffices to prove the theorem for `y = f x - x`. -/
have : IsClosed {x | Tendsto (birkhoffAverage 𝕜 f _root_.id · x) atTop (𝓝 0)} :=
isClosed_setOf_tendsto_birkhoffAverage 𝕜 hf uniformContinuous_id continuous_const
refine closure_minimal (Set.forall_mem_range.2 fun x ↦ ?_) this (hg_ker hy)
/- Finally, for `y = f x - x` the average is equal to the difference between averages
along the orbits of `f x` and `x`, and most of the terms cancel. -/
have : IsBounded (Set.range (_root_.id <| f^[·] x)) :=
isBounded_iff_forall_norm_le.2 ⟨‖x‖, Set.forall_mem_range.2 fun n ↦ by
have H : f^[n] 0 = 0 := iterate_map_zero (f : E →+ E) n
simpa [H] using (hf.iterate n).dist_le_mul x 0⟩
have H : ∀ n x y, f^[n] (x - y) = f^[n] x - f^[n] y := iterate_map_sub (f : E →+ E)
simpa [birkhoffAverage, birkhoffSum, Finset.sum_sub_distrib, smul_sub, H]
using tendsto_birkhoffAverage_apply_sub_birkhoffAverage 𝕜 this
variable [InnerProductSpace 𝕜 E] [CompleteSpace E]
local notation "⟪" x ", " y "⟫" => inner 𝕜 x y
/-- **Von Neumann Mean Ergodic Theorem** for an operator in a Hilbert space.
For a contracting continuous linear self-map `f : E →L[𝕜] E` of a Hilbert space, `‖f‖ ≤ 1`,
the Birkhoff averages
```
birkhoffAverage 𝕜 f id N x = (N : 𝕜)⁻¹ • ∑ n ∈ Finset.range N, f^[n] x
```
converge to the orthogonal projection of `x` to the subspace of fixed points of `f`. -/
theorem ContinuousLinearMap.tendsto_birkhoffAverage_orthogonalProjection (f : E →L[𝕜] E)
(hf : ‖f‖ ≤ 1) (x : E) :
Tendsto (birkhoffAverage 𝕜 f _root_.id · x) atTop
(𝓝 <| (LinearMap.eqLocus f 1).orthogonalProjection x) := by
/- Due to the previous theorem, it suffices to verify
that the range of `f - 1` is dense in the orthogonal complement
to the submodule of fixed points of `f`. -/
apply (f : E →ₗ[𝕜] E).tendsto_birkhoffAverage_of_ker_subset_closure (f.lipschitz.weaken hf)
· exact (LinearMap.eqLocus f 1).orthogonalProjection_mem_subspace_eq_self
· clear x
/- In other words, we need to verify that any vector that is orthogonal to the range of `f - 1`
is a fixed point of `f`. -/
rw [Submodule.ker_orthogonalProjection, ← Submodule.topologicalClosure_coe,
SetLike.coe_subset_coe, ← Submodule.orthogonal_orthogonal_eq_closure]
/- To verify this, we verify `‖f x‖ ≤ ‖x‖` (because `‖f‖ ≤ 1`) and `⟪f x, x⟫ = ‖x‖²`. -/
refine Submodule.orthogonal_le fun x hx ↦ eq_of_norm_le_re_inner_eq_norm_sq (𝕜 := 𝕜) ?_ ?_
· simpa using f.le_of_opNorm_le hf x
· have : ∀ y, ⟪f y, x⟫ = ⟪y, x⟫ := by
simpa [Submodule.mem_orthogonal, inner_sub_left, sub_eq_zero] using hx
simp [this] |
.lake/packages/mathlib/Mathlib/Analysis/InnerProductSpace/TensorProduct.lean | import Mathlib.Analysis.InnerProductSpace.Adjoint
import Mathlib.Analysis.InnerProductSpace.LinearMap
import Mathlib.Analysis.InnerProductSpace.PiL2
import Mathlib.LinearAlgebra.TensorProduct.Basic
import Mathlib.LinearAlgebra.TensorProduct.Finiteness
import Mathlib.RingTheory.TensorProduct.Finite
/-!
# Inner product space structure on tensor product spaces
This file provides the inner product space structure on tensor product spaces.
We define the inner product on `E ⊗ F` by `⟪a ⊗ₜ b, c ⊗ₜ d⟫ = ⟪a, c⟫ * ⟪b, d⟫`, when `E` and `F` are
inner product spaces.
## Main definitions:
* `TensorProduct.instNormedAddCommGroup`: the normed additive group structure on tensor products,
where `‖x ⊗ₜ y‖ = ‖x‖ * ‖y‖`.
* `TensorProduct.instInnerProductSpace`: the inner product space structure on tensor products, where
`⟪a ⊗ₜ b, c ⊗ₜ d⟫ = ⟪a, c⟫ * ⟪b, d⟫`.
* `TensorProduct.mapIsometry`: the linear isometry version of `TensorProduct.map f g` when
`f` and `g` are linear isometries.
* `TensorProduct.congrIsometry`: the linear isometry equivalence version of
`TensorProduct.congr f g` when `f` and `g` are linear isometry equivalences.
* `TensorProduct.mapInclIsometry`: the linear isometry version of `TensorProduct.mapIncl`.
* `TensorProduct.commIsometry`: the linear isometry version of `TensorProduct.comm`.
* `TensorProduct.lidIsometry`: the linear isometry version of `TensorProduct.lid`.
* `TensorProduct.assocIsometry`: the linear isometry version of `TensorProduct.assoc`.
* `OrthonormalBasis.tensorProduct`: the orthonormal basis of the tensor product of two orthonormal
bases.
## TODO:
* Define the continuous linear map version of `TensorProduct.map`.
* Complete space of tensor products.
* Define the normed space without needing inner products, this should be analogous to
`Mathlib/Analysis/NormedSpace/PiTensorProduct/InjectiveSeminorm.lean`.
-/
variable {𝕜 E F G H : Type*} [RCLike 𝕜]
[NormedAddCommGroup E] [InnerProductSpace 𝕜 E]
[NormedAddCommGroup F] [InnerProductSpace 𝕜 F]
[NormedAddCommGroup G] [InnerProductSpace 𝕜 G]
[NormedAddCommGroup H] [InnerProductSpace 𝕜 H]
open scoped TensorProduct
namespace TensorProduct
/-- Bilinear map for the inner product on tensor products.
On pure tensors: `inner_ (a ⊗ₜ b) (c ⊗ₜ d) = ⟪a, c⟫ * ⟪b, d⟫`. -/
private abbrev inner_ : E ⊗[𝕜] F →ₗ⋆[𝕜] E ⊗[𝕜] F →ₗ[𝕜] 𝕜 :=
(lift <| mapBilinear (.id 𝕜) E F 𝕜 𝕜).compr₂ (LinearMap.mul' 𝕜 𝕜) ∘ₛₗ map (innerₛₗ 𝕜) (innerₛₗ 𝕜)
instance instInner : Inner 𝕜 (E ⊗[𝕜] F) := ⟨fun x y => inner_ x y⟩
private lemma inner_def (x y : E ⊗[𝕜] F) : inner 𝕜 x y = inner_ x y := rfl
variable (𝕜) in
@[simp] theorem inner_tmul (x x' : E) (y y' : F) :
inner 𝕜 (x ⊗ₜ[𝕜] y) (x' ⊗ₜ[𝕜] y') = inner 𝕜 x x' * inner 𝕜 y y' := rfl
@[simp] lemma inner_map_map (f : E →ₗᵢ[𝕜] G) (g : F →ₗᵢ[𝕜] H) (x y : E ⊗[𝕜] F) :
inner 𝕜 (map f.toLinearMap g.toLinearMap x) (map f.toLinearMap g.toLinearMap y) = inner 𝕜 x y :=
x.induction_on (by simp [inner_def]) (y.induction_on (by simp [inner_def]) (by simp)
(by simp_all [inner_def])) (by simp_all [inner_def])
lemma inner_mapIncl_mapIncl (E' : Submodule 𝕜 E) (F' : Submodule 𝕜 F) (x y : E' ⊗[𝕜] F') :
inner 𝕜 (mapIncl E' F' x) (mapIncl E' F' y) = inner 𝕜 x y :=
inner_map_map E'.subtypeₗᵢ F'.subtypeₗᵢ x y
open scoped ComplexOrder
open Module
/- This holds in any inner product space, but we need this to set up the instance.
This is a helper lemma for showing that this inner product is positive definite. -/
private theorem inner_self {ι ι' : Type*} [Fintype ι] [Fintype ι'] (x : E ⊗[𝕜] F)
(e : OrthonormalBasis ι 𝕜 E) (f : OrthonormalBasis ι' 𝕜 F) :
inner 𝕜 x x = ∑ i, ‖(e.toBasis.tensorProduct f.toBasis).repr x i‖ ^ 2 := by
classical
have : x = ∑ i : ι, ∑ j : ι', (e.toBasis.tensorProduct f.toBasis).repr x (i, j) • e i ⊗ₜ f j := by
conv_lhs => rw [← (e.toBasis.tensorProduct f.toBasis).sum_repr x]
simp [← Finset.sum_product', Basis.tensorProduct_apply']
conv_lhs => rw [this]
simp only [inner_def, map_sum, LinearMap.sum_apply]
simp [OrthonormalBasis.inner_eq_ite, ← Finset.sum_product', RCLike.mul_conj]
private theorem inner_definite (x : E ⊗[𝕜] F) (hx : inner 𝕜 x x = 0) : x = 0 := by
/-
The way we prove this is by noting that every element of a tensor product lies
in the tensor product of some finite submodules.
So for `x : E ⊗ F`, there exists finite submodules `E', F'` such that `x ∈ mapIncl E' F'`.
And so the rest then follows from the above lemmas `inner_mapIncl_mapIncl` and `inner_self`.
-/
obtain ⟨E', F', iE', iF', hz⟩ := exists_finite_submodule_of_setFinite {x} (Set.finite_singleton x)
obtain ⟨y : E' ⊗ F', rfl : mapIncl E' F' y = x⟩ := Set.singleton_subset_iff.mp hz
obtain e := stdOrthonormalBasis 𝕜 E'
obtain f := stdOrthonormalBasis 𝕜 F'
have (i) (j) : (e.toBasis.tensorProduct f.toBasis).repr y (i, j) = 0 := by
rw [inner_mapIncl_mapIncl, inner_self y e f, RCLike.ofReal_eq_zero,
Finset.sum_eq_zero_iff_of_nonneg fun _ _ => sq_nonneg _] at hx
simpa using hx (i, j)
have : y = 0 := by simp [(e.toBasis.tensorProduct f.toBasis).ext_elem_iff, this]
rw [this, map_zero]
private protected theorem re_inner_self_nonneg (x : E ⊗[𝕜] F) :
0 ≤ RCLike.re (inner 𝕜 x x) := by
/-
Similarly to the above proof, for `x : E ⊗ F`, there exists finite submodules `E', F'` such that
`x ∈ mapIncl E' F'`.
And so the rest then follows from the above lemmas `inner_mapIncl_mapIncl` and `inner_self`.
-/
obtain ⟨E', F', iE', iF', hz⟩ := exists_finite_submodule_of_setFinite {x} (Set.finite_singleton x)
obtain ⟨y, rfl⟩ := Set.singleton_subset_iff.mp hz
obtain e := stdOrthonormalBasis 𝕜 E'
obtain f := stdOrthonormalBasis 𝕜 F'
rw [inner_mapIncl_mapIncl, inner_self y e f, RCLike.ofReal_re]
exact Finset.sum_nonneg fun _ _ ↦ sq_nonneg _
noncomputable instance instNormedAddCommGroup : NormedAddCommGroup (E ⊗[𝕜] F) :=
letI : InnerProductSpace.Core 𝕜 (E ⊗[𝕜] F) :=
{ conj_inner_symm x y :=
x.induction_on (by simp [inner]) (y.induction_on (by simp [inner]) (by simp)
(by simp_all [inner])) (by simp_all [inner])
add_left _ _ _ := LinearMap.map_add₂ _ _ _ _
smul_left _ _ _ := LinearMap.map_smulₛₗ₂ _ _ _ _
definite := TensorProduct.inner_definite
re_inner_nonneg := TensorProduct.re_inner_self_nonneg }
this.toNormedAddCommGroup
instance instInnerProductSpace : InnerProductSpace 𝕜 (E ⊗[𝕜] F) := .ofCore _
@[simp] theorem norm_tmul (x : E) (y : F) :
‖x ⊗ₜ[𝕜] y‖ = ‖x‖ * ‖y‖ := by
simpa using congr(√(RCLike.re $(inner_tmul 𝕜 x x y y)))
@[simp] theorem nnnorm_tmul (x : E) (y : F) :
‖x ⊗ₜ[𝕜] y‖₊ = ‖x‖₊ * ‖y‖₊ := by simp [← NNReal.coe_inj]
@[simp] theorem enorm_tmul (x : E) (y : F) :
‖x ⊗ₜ[𝕜] y‖ₑ = ‖x‖ₑ * ‖y‖ₑ := ENNReal.coe_inj.mpr <| by simp
theorem dist_tmul_le (x x' : E) (y y' : F) :
dist (x ⊗ₜ[𝕜] y) (x' ⊗ₜ y') ≤ ‖x‖ * ‖y‖ + ‖x'‖ * ‖y'‖ := by
grw [dist_eq_norm, norm_sub_le]; simp
theorem nndist_tmul_le (x x' : E) (y y' : F) :
nndist (x ⊗ₜ[𝕜] y) (x' ⊗ₜ y') ≤ ‖x‖₊ * ‖y‖₊ + ‖x'‖₊ * ‖y'‖₊ := by
grw [nndist_eq_nnnorm, nnnorm_sub_le]; simp
theorem edist_tmul_le (x x' : E) (y y' : F) :
edist (x ⊗ₜ[𝕜] y) (x' ⊗ₜ y') ≤ ‖x‖ₑ * ‖y‖ₑ + ‖x'‖ₑ * ‖y'‖ₑ := by
grw [edist_eq_enorm_sub, enorm_sub_le]; simp
/-- In `ℝ` or `ℂ` fields, the inner product on tensor products is essentially just the inner product
with multiplication instead of tensors, i.e., `⟪a ⊗ₜ b, c ⊗ₜ d⟫ = ⟪a * b, c * d⟫`. -/
theorem _root_.RCLike.inner_tmul_eq (a b c d : 𝕜) :
inner 𝕜 (a ⊗ₜ[𝕜] b) (c ⊗ₜ[𝕜] d) = inner 𝕜 (a * b) (c * d) := by
simp; ring
/-- Given `x, y : E ⊗ F`, `x = y` iff `⟪x, a ⊗ₜ b⟫ = ⟪y, a ⊗ₜ b⟫` for all `a, b`. -/
protected theorem ext_iff_inner_right {x y : E ⊗[𝕜] F} :
x = y ↔ ∀ a b, inner 𝕜 x (a ⊗ₜ[𝕜] b) = inner 𝕜 y (a ⊗ₜ[𝕜] b) :=
⟨fun h _ _ ↦ h ▸ rfl, fun h ↦ innerSL_inj.mp <| ContinuousLinearMap.coe_inj.mp <| ext' h⟩
/-- Given `x, y : E ⊗ F`, `x = y` iff `⟪a ⊗ₜ b, x⟫ = ⟪a ⊗ₜ b, y⟫` for all `a, b`. -/
protected theorem ext_iff_inner_left {x y : E ⊗[𝕜] F} :
x = y ↔ ∀ a b, inner 𝕜 (a ⊗ₜ b) x = inner 𝕜 (a ⊗ₜ b) y := by
simpa only [← inner_conj_symm x, ← inner_conj_symm y, starRingEnd_apply, star_inj] using
TensorProduct.ext_iff_inner_right (x := x) (y := y)
/-- Given `x, y : E ⊗ F ⊗ G`, `x = y` iff `⟪x, a ⊗ₜ b ⊗ₜ c⟫ = ⟪y, a ⊗ₜ b ⊗ₜ c⟫` for all `a, b, c`.
See also `ext_iff_inner_right_threefold'` for when `x, y : E ⊗ (F ⊗ G)`. -/
theorem ext_iff_inner_right_threefold {x y : E ⊗[𝕜] F ⊗[𝕜] G} :
x = y ↔ ∀ a b c, inner 𝕜 x (a ⊗ₜ[𝕜] b ⊗ₜ[𝕜] c) = inner 𝕜 y (a ⊗ₜ[𝕜] b ⊗ₜ[𝕜] c) :=
⟨fun h _ _ _ ↦ h ▸ rfl, fun h ↦ innerSL_inj.mp (ContinuousLinearMap.coe_inj.mp (ext_threefold h))⟩
/-- Given `x, y : E ⊗ F ⊗ G`, `x = y` iff `⟪a ⊗ₜ b ⊗ₜ c, x⟫ = ⟪a ⊗ₜ b ⊗ₜ c, y⟫` for all `a, b, c`.
See also `ext_iff_inner_left_threefold'` for when `x, y : E ⊗ (F ⊗ G)`. -/
theorem ext_iff_inner_left_threefold {x y : E ⊗[𝕜] F ⊗[𝕜] G} :
x = y ↔ ∀ a b c, inner 𝕜 (a ⊗ₜ b ⊗ₜ c) x = inner 𝕜 (a ⊗ₜ b ⊗ₜ c) y := by
simpa only [← inner_conj_symm x, ← inner_conj_symm y, starRingEnd_apply, star_inj] using
ext_iff_inner_right_threefold (x := x) (y := y)
section isometry
/-- The tensor product map of two linear isometries is a linear isometry. In particular, this is
the linear isometry version of `TensorProduct.map f g` when `f` and `g` are linear isometries. -/
def mapIsometry (f : E →ₗᵢ[𝕜] G) (g : F →ₗᵢ[𝕜] H) :
E ⊗[𝕜] F →ₗᵢ[𝕜] G ⊗[𝕜] H :=
map f.toLinearMap g.toLinearMap |>.isometryOfInner <| inner_map_map _ _
@[simp] lemma mapIsometry_apply (f : E →ₗᵢ[𝕜] G) (g : F →ₗᵢ[𝕜] H) (x : E ⊗[𝕜] F) :
mapIsometry f g x = map f.toLinearMap g.toLinearMap x := rfl
@[simp] lemma toLinearMap_mapIsometry (f : E →ₗᵢ[𝕜] G) (g : F →ₗᵢ[𝕜] H) :
(mapIsometry f g).toLinearMap = map f.toLinearMap g.toLinearMap := rfl
@[simp] lemma norm_map (f : E →ₗᵢ[𝕜] G) (g : F →ₗᵢ[𝕜] H) (x : E ⊗[𝕜] F) :
‖map f.toLinearMap g.toLinearMap x‖ = ‖x‖ := mapIsometry f g |>.norm_map x
@[simp] lemma nnnorm_map (f : E →ₗᵢ[𝕜] G) (g : F →ₗᵢ[𝕜] H) (x : E ⊗[𝕜] F) :
‖map f.toLinearMap g.toLinearMap x‖₊ = ‖x‖₊ := mapIsometry f g |>.nnnorm_map x
@[simp] lemma enorm_map (f : E →ₗᵢ[𝕜] G) (g : F →ₗᵢ[𝕜] H) (x : E ⊗[𝕜] F) :
‖map f.toLinearMap g.toLinearMap x‖ₑ = ‖x‖ₑ := mapIsometry f g |>.enorm_map x
@[simp] lemma mapIsometry_id_id :
mapIsometry (.id : E →ₗᵢ[𝕜] E) (.id : F →ₗᵢ[𝕜] F) = .id := by ext; simp
variable (E) in
/-- This is the natural linear isometry induced by `f : F ≃ₗᵢ G`. -/
def _root_.LinearIsometry.lTensor (f : F →ₗᵢ[𝕜] G) :
E ⊗[𝕜] F →ₗᵢ[𝕜] E ⊗[𝕜] G := mapIsometry .id f
variable (G) in
/-- This is the natural linear isometry induced by `f : E ≃ₗᵢ F`. -/
def _root_.LinearIsometry.rTensor (f : E →ₗᵢ[𝕜] F) :
E ⊗[𝕜] G →ₗᵢ[𝕜] F ⊗[𝕜] G := mapIsometry f .id
lemma _root_.LinearIsometry.lTensor_def (f : F →ₗᵢ[𝕜] G) :
f.lTensor E = mapIsometry .id f := rfl
lemma _root_.LinearIsometry.rTensor_def (f : E →ₗᵢ[𝕜] F) :
f.rTensor G = mapIsometry f .id := rfl
@[simp] lemma _root_.LinearIsometry.toLinearMap_lTensor (f : F →ₗᵢ[𝕜] G) :
(f.lTensor E).toLinearMap = f.toLinearMap.lTensor E := rfl
@[simp] lemma _root_.LinearIsometry.toLinearMap_rTensor (f : E →ₗᵢ[𝕜] F) :
(f.rTensor G).toLinearMap = f.toLinearMap.rTensor G := rfl
@[simp] lemma _root_.LinearIsometry.lTensor_apply (f : F →ₗᵢ[𝕜] G) (x : E ⊗[𝕜] F) :
f.lTensor E x = f.toLinearMap.lTensor E x := rfl
@[simp] lemma _root_.LinearIsometry.rTensor_apply (f : E →ₗᵢ[𝕜] F) (x : E ⊗[𝕜] G) :
f.rTensor G x = f.toLinearMap.rTensor G x := rfl
/-- The tensor product of two linear isometry equivalences is a linear isometry equivalence.
In particular, this is the linear isometry equivalence version of `TensorProduct.congr f g` when `f`
and `g` are linear isometry equivalences. -/
def congrIsometry (f : E ≃ₗᵢ[𝕜] G) (g : F ≃ₗᵢ[𝕜] H) :
E ⊗[𝕜] F ≃ₗᵢ[𝕜] G ⊗[𝕜] H :=
congr f.toLinearEquiv g.toLinearEquiv |>.isometryOfInner <|
inner_map_map f.toLinearIsometry g.toLinearIsometry
@[simp] lemma congrIsometry_apply (f : E ≃ₗᵢ[𝕜] G) (g : F ≃ₗᵢ[𝕜] H) (x : E ⊗[𝕜] F) :
congrIsometry f g x = congr (σ₁₂ := .id _) f g x := rfl
lemma congrIsometry_symm (f : E ≃ₗᵢ[𝕜] G) (g : F ≃ₗᵢ[𝕜] H) :
(congrIsometry f g).symm = congrIsometry f.symm g.symm := rfl
@[simp] lemma toLinearEquiv_congrIsometry (f : E ≃ₗᵢ[𝕜] G) (g : F ≃ₗᵢ[𝕜] H) :
(congrIsometry f g).toLinearEquiv = congr f.toLinearEquiv g.toLinearEquiv := rfl
@[simp] lemma congrIsometry_refl_refl :
congrIsometry (.refl 𝕜 E) (.refl 𝕜 F) = .refl 𝕜 (E ⊗ F) :=
LinearIsometryEquiv.toLinearEquiv_inj.mp <| LinearEquiv.toLinearMap_inj.mp <| by ext; simp
variable (E) in
/-- This is the natural linear isometric equivalence induced by `f : F ≃ₗᵢ G`. -/
def _root_.LinearIsometryEquiv.lTensor (f : F ≃ₗᵢ[𝕜] G) :
E ⊗[𝕜] F ≃ₗᵢ[𝕜] E ⊗[𝕜] G := congrIsometry (.refl 𝕜 E) f
variable (G) in
/-- This is the natural linear isometric equivalence induced by `f : E ≃ₗᵢ F`. -/
def _root_.LinearIsometryEquiv.rTensor (f : E ≃ₗᵢ[𝕜] F) :
E ⊗[𝕜] G ≃ₗᵢ[𝕜] F ⊗[𝕜] G := congrIsometry f (.refl 𝕜 G)
lemma _root_.LinearIsometryEquiv.lTensor_def (f : F ≃ₗᵢ[𝕜] G) :
f.lTensor E = congrIsometry (.refl 𝕜 E) f := rfl
lemma _root_.LinearIsometryEquiv.rTensor_def (f : E ≃ₗᵢ[𝕜] F) :
f.rTensor G = congrIsometry f (.refl 𝕜 G) := rfl
lemma _root_.LinearIsometryEquiv.symm_lTensor (f : F ≃ₗᵢ[𝕜] G) :
(f.lTensor E).symm = f.symm.lTensor E := rfl
lemma _root_.LinearIsometryEquiv.symm_rTensor (f : E ≃ₗᵢ[𝕜] F) :
(f.rTensor G).symm = f.symm.rTensor G := rfl
@[simp] lemma _root_.LinearIsometryEquiv.toLinearEquiv_lTensor (f : F ≃ₗᵢ[𝕜] G) :
(f.lTensor E).toLinearEquiv = f.toLinearEquiv.lTensor E := rfl
@[simp] lemma _root_.LinearIsometryEquiv.toLinearIsometry_lTensor (f : F ≃ₗᵢ[𝕜] G) :
(f.lTensor E).toLinearIsometry = f.toLinearIsometry.lTensor E := rfl
@[simp] lemma _root_.LinearIsometryEquiv.toLinearEquiv_rTensor (f : E ≃ₗᵢ[𝕜] F) :
(f.rTensor G).toLinearEquiv = f.toLinearEquiv.rTensor G := rfl
@[simp] lemma _root_.LinearIsometryEquiv.toLinearIsometry_rTensor (f : E ≃ₗᵢ[𝕜] F) :
(f.rTensor G).toLinearIsometry = f.toLinearIsometry.rTensor G := rfl
@[simp] lemma _root_.LinearIsometryEquiv.lTensor_apply (f : F ≃ₗᵢ[𝕜] G) (x : E ⊗[𝕜] F) :
f.lTensor E x = f.toLinearEquiv.lTensor E x := rfl
@[simp] lemma _root_.LinearIsometryEquiv.rTensor_apply (f : E ≃ₗᵢ[𝕜] F) (x : E ⊗[𝕜] G) :
f.rTensor G x = f.toLinearEquiv.rTensor G x := rfl
/-- The linear isometry version of `TensorProduct.mapIncl`. -/
def mapInclIsometry (E' : Submodule 𝕜 E) (F' : Submodule 𝕜 F) :
E' ⊗[𝕜] F' →ₗᵢ[𝕜] E ⊗[𝕜] F :=
mapIsometry E'.subtypeₗᵢ F'.subtypeₗᵢ
@[simp] lemma mapInclIsometry_apply (E' : Submodule 𝕜 E) (F' : Submodule 𝕜 F)
(x : E' ⊗[𝕜] F') : mapInclIsometry E' F' x = mapIncl E' F' x := rfl
@[simp] lemma toLinearMap_mapInclIsometry (E' : Submodule 𝕜 E) (F' : Submodule 𝕜 F) :
(mapInclIsometry E' F').toLinearMap = mapIncl E' F' := rfl
@[simp] theorem inner_comm_comm (x y : E ⊗[𝕜] F) :
inner 𝕜 (TensorProduct.comm 𝕜 E F x) (TensorProduct.comm 𝕜 E F y) = inner 𝕜 x y :=
x.induction_on (by simp) (fun _ _ =>
y.induction_on (by simp) (by simp [mul_comm])
fun _ _ h1 h2 => by simp only [inner_add_right, map_add, h1, h2])
fun _ _ h1 h2 => by simp only [inner_add_left, map_add, h1, h2]
variable (𝕜 E F) in
/-- The linear isometry equivalence version of `TensorProduct.comm`. -/
def commIsometry : E ⊗[𝕜] F ≃ₗᵢ[𝕜] F ⊗[𝕜] E :=
TensorProduct.comm 𝕜 E F |>.isometryOfInner inner_comm_comm
@[simp] lemma commIsometry_apply (x : E ⊗[𝕜] F) :
commIsometry 𝕜 E F x = TensorProduct.comm 𝕜 E F x := rfl
@[simp] lemma commIsometry_symm :
(commIsometry 𝕜 E F).symm = commIsometry 𝕜 F E := rfl
@[simp] lemma toLinearEquiv_commIsometry :
(commIsometry 𝕜 E F).toLinearEquiv = TensorProduct.comm 𝕜 E F := rfl
@[simp] lemma norm_comm (x : E ⊗[𝕜] F) :
‖TensorProduct.comm 𝕜 E F x‖ = ‖x‖ := commIsometry 𝕜 E F |>.norm_map x
@[simp] lemma nnnorm_comm (x : E ⊗[𝕜] F) :
‖TensorProduct.comm 𝕜 E F x‖₊ = ‖x‖₊ := commIsometry 𝕜 E F |>.nnnorm_map x
@[simp] lemma enorm_comm (x : E ⊗[𝕜] F) :
‖TensorProduct.comm 𝕜 E F x‖ₑ = ‖x‖ₑ := commIsometry 𝕜 E F |>.toLinearIsometry.enorm_map x
@[simp] theorem inner_lid_lid (x y : 𝕜 ⊗[𝕜] E) :
inner 𝕜 (TensorProduct.lid 𝕜 E x) (TensorProduct.lid 𝕜 E y) = inner 𝕜 x y :=
x.induction_on (by simp) (fun _ _ =>
y.induction_on (by simp) (by simp [inner_smul_left, inner_smul_right, mul_assoc])
fun _ _ h1 h2 => by simp only [inner_add_right, map_add, h1, h2])
fun _ _ h1 h2 => by simp only [inner_add_left, map_add, h1, h2]
variable (𝕜 E) in
/-- The linear isometry equivalence version of `TensorProduct.lid`. -/
def lidIsometry : 𝕜 ⊗[𝕜] E ≃ₗᵢ[𝕜] E :=
TensorProduct.lid 𝕜 E |>.isometryOfInner inner_lid_lid
@[simp] lemma lidIsometry_apply (x : 𝕜 ⊗[𝕜] E) :
lidIsometry 𝕜 E x = TensorProduct.lid 𝕜 E x := rfl
@[simp] lemma lidIsometry_symm_apply (x : E) :
(lidIsometry 𝕜 E).symm x = 1 ⊗ₜ x := rfl
@[simp] lemma toLinearEquiv_lidIsometry :
(lidIsometry 𝕜 E).toLinearEquiv = TensorProduct.lid 𝕜 E := rfl
@[simp] lemma norm_lid (x : 𝕜 ⊗[𝕜] E) :
‖TensorProduct.lid 𝕜 E x‖ = ‖x‖ := lidIsometry 𝕜 E |>.norm_map x
@[simp] lemma nnnorm_lid (x : 𝕜 ⊗[𝕜] E) :
‖TensorProduct.lid 𝕜 E x‖₊ = ‖x‖₊ := lidIsometry 𝕜 E |>.nnnorm_map x
@[simp] lemma enorm_lid (x : 𝕜 ⊗[𝕜] E) :
‖TensorProduct.lid 𝕜 E x‖ₑ = ‖x‖ₑ := lidIsometry 𝕜 E |>.toLinearIsometry.enorm_map x
@[simp] theorem inner_assoc_assoc (x y : E ⊗[𝕜] F ⊗[𝕜] G) :
inner 𝕜 (TensorProduct.assoc 𝕜 E F G x) (TensorProduct.assoc 𝕜 E F G y) = inner 𝕜 x y :=
x.induction_on (by simp) (fun a _ =>
y.induction_on (by simp) (fun c _ =>
a.induction_on (by simp) (fun _ _ =>
c.induction_on (by simp) (by simp [mul_assoc])
fun _ _ h1 h2 => by simp only [add_tmul, inner_add_right, map_add, h1, h2])
fun _ _ h1 h2 => by simp only [add_tmul, inner_add_left, map_add, h1, h2])
fun _ _ h1 h2 => by simp only [inner_add_right, map_add, h1, h2])
fun _ _ h1 h2 => by simp only [inner_add_left, map_add, h1, h2]
variable (𝕜 E F G) in
/-- The linear isometry equivalence version of `TensorProduct.assoc`. -/
def assocIsometry : E ⊗[𝕜] F ⊗[𝕜] G ≃ₗᵢ[𝕜] E ⊗[𝕜] (F ⊗[𝕜] G) :=
TensorProduct.assoc 𝕜 E F G |>.isometryOfInner inner_assoc_assoc
@[simp] lemma assocIsometry_apply (x : E ⊗[𝕜] F ⊗[𝕜] G) :
assocIsometry 𝕜 E F G x = TensorProduct.assoc 𝕜 E F G x := rfl
@[simp] lemma assocIsometry_symm_apply (x : E ⊗[𝕜] (F ⊗[𝕜] G)) :
(assocIsometry 𝕜 E F G).symm x = (TensorProduct.assoc 𝕜 E F G).symm x := rfl
@[simp] lemma toLinearEquiv_assocIsometry :
(assocIsometry 𝕜 E F G).toLinearEquiv = TensorProduct.assoc 𝕜 E F G := rfl
@[simp] lemma norm_assoc (x : E ⊗[𝕜] F ⊗[𝕜] G) :
‖TensorProduct.assoc 𝕜 E F G x‖ = ‖x‖ := assocIsometry 𝕜 E F G |>.norm_map x
@[simp] lemma nnnorm_assoc (x : E ⊗[𝕜] F ⊗[𝕜] G) :
‖TensorProduct.assoc 𝕜 E F G x‖₊ = ‖x‖₊ := assocIsometry 𝕜 E F G |>.nnnorm_map x
@[simp] lemma enorm_assoc (x : E ⊗[𝕜] F ⊗[𝕜] G) :
‖TensorProduct.assoc 𝕜 E F G x‖ₑ = ‖x‖ₑ := assocIsometry 𝕜 E F G |>.toLinearIsometry.enorm_map x
end isometry
-- TODO: upgrade `map` to a `ContinuousLinearMap`
@[simp] theorem adjoint_map [FiniteDimensional 𝕜 E] [FiniteDimensional 𝕜 F] [FiniteDimensional 𝕜 G]
[FiniteDimensional 𝕜 H] (f : E →ₗ[𝕜] F) (g : G →ₗ[𝕜] H) :
LinearMap.adjoint (map f g) = map (LinearMap.adjoint f) (LinearMap.adjoint g) :=
ext' fun _ _ => by simp [TensorProduct.ext_iff_inner_right, LinearMap.adjoint_inner_left]
/-- Given `x, y : E ⊗ (F ⊗ G)`, `x = y` iff `⟪x, a ⊗ₜ (b ⊗ₜ c)⟫ = ⟪y, a ⊗ₜ (b ⊗ₜ c)⟫` for all
`a, b, c`.
See also `ext_iff_inner_right_threefold` for when `x, y : E ⊗ F ⊗ G`. -/
theorem ext_iff_inner_right_threefold' {x y : E ⊗[𝕜] (F ⊗[𝕜] G)} :
x = y ↔ ∀ a b c, inner 𝕜 x (a ⊗ₜ[𝕜] (b ⊗ₜ[𝕜] c)) = inner 𝕜 y (a ⊗ₜ[𝕜] (b ⊗ₜ[𝕜] c)) := by
simp only [← (assocIsometry 𝕜 E F G).symm.injective.eq_iff,
ext_iff_inner_right_threefold, LinearIsometryEquiv.inner_map_eq_flip]
simp
/-- Given `x, y : E ⊗ (F ⊗ G)`, `x = y` iff `⟪a ⊗ₜ (b ⊗ₜ c), x⟫ = ⟪a ⊗ₜ (b ⊗ₜ c), y⟫` for all
`a, b, c`.
See also `ext_iff_inner_left_threefold` for when `x, y : E ⊗ F ⊗ G`. -/
theorem ext_iff_inner_left_threefold' {x y : E ⊗[𝕜] (F ⊗[𝕜] G)} :
x = y ↔ ∀ a b c, inner 𝕜 (a ⊗ₜ[𝕜] (b ⊗ₜ[𝕜] c)) x = inner 𝕜 (a ⊗ₜ[𝕜] (b ⊗ₜ[𝕜] c)) y := by
simpa only [← inner_conj_symm x, ← inner_conj_symm y, starRingEnd_apply, star_inj] using
ext_iff_inner_right_threefold' (x := x) (y := y)
end TensorProduct
section orthonormal
variable {ι₁ ι₂ : Type*} [DecidableEq ι₁] [DecidableEq ι₂]
open Module
/-- The tensor product of two orthonormal vectors is orthonormal. -/
theorem Orthonormal.tmul
{b₁ : ι₁ → E} {b₂ : ι₂ → F} (hb₁ : Orthonormal 𝕜 b₁) (hb₂ : Orthonormal 𝕜 b₂) :
Orthonormal 𝕜 fun i : ι₁ × ι₂ ↦ b₁ i.1 ⊗ₜ[𝕜] b₂ i.2 :=
orthonormal_iff_ite.mpr fun ⟨i₁, i₂⟩ ⟨j₁, j₂⟩ => by
simp [orthonormal_iff_ite.mp, hb₁, hb₂, ← ite_and, and_comm]
/-- The tensor product of two orthonormal bases is orthonormal. -/
theorem Orthonormal.basisTensorProduct
{b₁ : Basis ι₁ 𝕜 E} {b₂ : Basis ι₂ 𝕜 F} (hb₁ : Orthonormal 𝕜 b₁) (hb₂ : Orthonormal 𝕜 b₂) :
Orthonormal 𝕜 (b₁.tensorProduct b₂) := by
convert hb₁.tmul hb₂
exact b₁.tensorProduct_apply' b₂ _
namespace OrthonormalBasis
variable [Fintype ι₁] [Fintype ι₂]
/-- The orthonormal basis of the tensor product of two orthonormal bases. -/
protected noncomputable def tensorProduct
(b₁ : OrthonormalBasis ι₁ 𝕜 E) (b₂ : OrthonormalBasis ι₂ 𝕜 F) :
OrthonormalBasis (ι₁ × ι₂) 𝕜 (E ⊗[𝕜] F) :=
(b₁.toBasis.tensorProduct b₂.toBasis).toOrthonormalBasis
(b₁.orthonormal.basisTensorProduct b₂.orthonormal)
@[simp]
lemma tensorProduct_apply
(b₁ : OrthonormalBasis ι₁ 𝕜 E) (b₂ : OrthonormalBasis ι₂ 𝕜 F) (i : ι₁) (j : ι₂) :
b₁.tensorProduct b₂ (i, j) = b₁ i ⊗ₜ[𝕜] b₂ j := by simp [OrthonormalBasis.tensorProduct]
lemma tensorProduct_apply'
(b₁ : OrthonormalBasis ι₁ 𝕜 E) (b₂ : OrthonormalBasis ι₂ 𝕜 F) (i : ι₁ × ι₂) :
b₁.tensorProduct b₂ i = b₁ i.1 ⊗ₜ[𝕜] b₂ i.2 := tensorProduct_apply _ _ _ _
@[simp]
lemma tensorProduct_repr_tmul_apply (b₁ : OrthonormalBasis ι₁ 𝕜 E) (b₂ : OrthonormalBasis ι₂ 𝕜 F)
(x : E) (y : F) (i : ι₁) (j : ι₂) :
(b₁.tensorProduct b₂).repr (x ⊗ₜ[𝕜] y) (i, j) = b₂.repr y j * b₁.repr x i := by
simp [OrthonormalBasis.tensorProduct]
lemma tensorProduct_repr_tmul_apply'
(b₁ : OrthonormalBasis ι₁ 𝕜 E) (b₂ : OrthonormalBasis ι₂ 𝕜 F) (x : E) (y : F) (i : ι₁ × ι₂) :
(b₁.tensorProduct b₂).repr (x ⊗ₜ[𝕜] y) i = b₂.repr y i.2 * b₁.repr x i.1 :=
tensorProduct_repr_tmul_apply _ _ _ _ _ _
@[simp]
lemma toBasis_tensorProduct (b₁ : OrthonormalBasis ι₁ 𝕜 E) (b₂ : OrthonormalBasis ι₂ 𝕜 F) :
(b₁.tensorProduct b₂).toBasis = b₁.toBasis.tensorProduct b₂.toBasis := by
simp [OrthonormalBasis.tensorProduct]
end OrthonormalBasis
end orthonormal |
.lake/packages/mathlib/Mathlib/Analysis/InnerProductSpace/MulOpposite.lean | import Mathlib.Analysis.InnerProductSpace.PiL2
import Mathlib.LinearAlgebra.Basis.MulOpposite
/-!
# Inner product space on `Hᵐᵒᵖ`
This file defines the inner product space structure on `Hᵐᵒᵖ` where we define
the inner product naturally. We also define `OrthonormalBasis.mulOpposite`.
-/
namespace MulOpposite
variable {𝕜 H : Type*}
open MulOpposite
/-- The inner product of `Hᵐᵒᵖ` is given by `⟪x, y⟫ ↦ ⟪x.unop, y.unop⟫`. -/
instance [Inner 𝕜 H] : Inner 𝕜 Hᵐᵒᵖ where inner x y := inner 𝕜 x.unop y.unop
@[simp] theorem inner_unop [Inner 𝕜 H] (x y : Hᵐᵒᵖ) : inner 𝕜 x.unop y.unop = inner 𝕜 x y := rfl
@[simp] theorem inner_op [Inner 𝕜 H] (x y : H) : inner 𝕜 (op x) (op y) = inner 𝕜 x y := rfl
section InnerProductSpace
variable [RCLike 𝕜] [SeminormedAddCommGroup H] [InnerProductSpace 𝕜 H]
instance : InnerProductSpace 𝕜 Hᵐᵒᵖ where
norm_sq_eq_re_inner x := (inner_self_eq_norm_sq x.unop).symm
conj_inner_symm x y := InnerProductSpace.conj_inner_symm x.unop y.unop
add_left x y z := InnerProductSpace.add_left x.unop y.unop z.unop
smul_left x y r := InnerProductSpace.smul_left x.unop y.unop r
section orthonormal
theorem _root_.Module.Basis.mulOpposite_is_orthonormal_iff {ι : Type*} (b : Module.Basis ι 𝕜 H) :
Orthonormal 𝕜 b.mulOpposite ↔ Orthonormal 𝕜 b := Iff.rfl
variable {ι H : Type*} [NormedAddCommGroup H] [InnerProductSpace 𝕜 H] [Fintype ι]
/-- The multiplicative opposite of an orthonormal basis `b`, i.e., `b i ↦ op (b i)`. -/
noncomputable def _root_.OrthonormalBasis.mulOpposite (b : OrthonormalBasis ι 𝕜 H) :
OrthonormalBasis ι 𝕜 Hᵐᵒᵖ := b.toBasis.mulOpposite.toOrthonormalBasis b.orthonormal
@[simp] lemma _root_.OrthonormalBasis.toBasis_mulOpposite (b : OrthonormalBasis ι 𝕜 H) :
b.mulOpposite.toBasis = b.toBasis.mulOpposite := rfl
end orthonormal
end InnerProductSpace
end MulOpposite |
.lake/packages/mathlib/Mathlib/Analysis/InnerProductSpace/Rayleigh.lean | import Mathlib.Analysis.InnerProductSpace.Calculus
import Mathlib.Analysis.InnerProductSpace.Dual
import Mathlib.Analysis.InnerProductSpace.Adjoint
import Mathlib.Analysis.Calculus.LagrangeMultipliers
import Mathlib.LinearAlgebra.Eigenspace.Basic
import Mathlib.Algebra.EuclideanDomain.Basic
/-!
# The Rayleigh quotient
The Rayleigh quotient of a self-adjoint operator `T` on an inner product space `E` is the function
`fun x ↦ ⟪T x, x⟫ / ‖x‖ ^ 2`.
The main results of this file are `IsSelfAdjoint.hasEigenvector_of_isMaxOn` and
`IsSelfAdjoint.hasEigenvector_of_isMinOn`, which state that if `E` is complete, and if the
Rayleigh quotient attains its global maximum/minimum over some sphere at the point `x₀`, then `x₀`
is an eigenvector of `T`, and the `iSup`/`iInf` of `fun x ↦ ⟪T x, x⟫ / ‖x‖ ^ 2` is the corresponding
eigenvalue.
The corollaries `LinearMap.IsSymmetric.hasEigenvalue_iSup_of_finiteDimensional` and
`LinearMap.IsSymmetric.hasEigenvalue_iSup_of_finiteDimensional` state that if `E` is
finite-dimensional and nontrivial, then `T` has some (nonzero) eigenvectors with eigenvalue the
`iSup`/`iInf` of `fun x ↦ ⟪T x, x⟫ / ‖x‖ ^ 2`.
## TODO
A slightly more elaborate corollary is that if `E` is complete and `T` is a compact operator, then
`T` has some (nonzero) eigenvector with eigenvalue either `⨆ x, ⟪T x, x⟫ / ‖x‖ ^ 2` or
`⨅ x, ⟪T x, x⟫ / ‖x‖ ^ 2` (not necessarily both).
-/
variable {𝕜 : Type*} [RCLike 𝕜]
variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace 𝕜 E]
local notation "⟪" x ", " y "⟫" => inner 𝕜 x y
open scoped NNReal
open Module.End Metric
namespace ContinuousLinearMap
variable (T : E →L[𝕜] E)
/-- The *Rayleigh quotient* of a continuous linear map `T` (over `ℝ` or `ℂ`) at a vector `x` is
the quantity `re ⟪T x, x⟫ / ‖x‖ ^ 2`. -/
noncomputable abbrev rayleighQuotient (x : E) := T.reApplyInnerSelf x / ‖(x : E)‖ ^ 2
theorem rayleigh_smul (x : E) {c : 𝕜} (hc : c ≠ 0) :
rayleighQuotient T (c • x) = rayleighQuotient T x := by
by_cases hx : x = 0
· simp [hx]
simp [field, norm_smul, T.reApplyInnerSelf_smul]
theorem image_rayleigh_eq_image_rayleigh_sphere {r : ℝ} (hr : 0 < r) :
rayleighQuotient T '' {0}ᶜ = rayleighQuotient T '' sphere 0 r := by
ext a
constructor
· rintro ⟨x, hx : x ≠ 0, hxT⟩
let c : 𝕜 := ↑‖x‖⁻¹ * r
have : c ≠ 0 := by simp [c, hx, hr.ne']
refine ⟨c • x, ?_, ?_⟩
· simp [field, c, norm_smul, abs_of_pos hr]
· rw [T.rayleigh_smul x this]
exact hxT
· rintro ⟨x, hx, hxT⟩
exact ⟨x, ne_zero_of_mem_sphere hr.ne' ⟨x, hx⟩, hxT⟩
theorem iSup_rayleigh_eq_iSup_rayleigh_sphere {r : ℝ} (hr : 0 < r) :
⨆ x : { x : E // x ≠ 0 }, rayleighQuotient T x =
⨆ x : sphere (0 : E) r, rayleighQuotient T x :=
show ⨆ x : ({0}ᶜ : Set E), rayleighQuotient T x = _ by
simp only [← @sSup_image' _ _ _ _ (rayleighQuotient T),
T.image_rayleigh_eq_image_rayleigh_sphere hr]
theorem iInf_rayleigh_eq_iInf_rayleigh_sphere {r : ℝ} (hr : 0 < r) :
⨅ x : { x : E // x ≠ 0 }, rayleighQuotient T x =
⨅ x : sphere (0 : E) r, rayleighQuotient T x :=
show ⨅ x : ({0}ᶜ : Set E), rayleighQuotient T x = _ by
simp only [← @sInf_image' _ _ _ _ (rayleighQuotient T),
T.image_rayleigh_eq_image_rayleigh_sphere hr]
end ContinuousLinearMap
namespace IsSelfAdjoint
section Real
variable {F : Type*} [NormedAddCommGroup F] [InnerProductSpace ℝ F]
theorem _root_.LinearMap.IsSymmetric.hasStrictFDerivAt_reApplyInnerSelf {T : F →L[ℝ] F}
(hT : (T : F →ₗ[ℝ] F).IsSymmetric) (x₀ : F) :
HasStrictFDerivAt T.reApplyInnerSelf (2 • (innerSL ℝ (T x₀))) x₀ := by
convert T.hasStrictFDerivAt.inner ℝ (hasStrictFDerivAt_id x₀) using 1
ext y
rw [ContinuousLinearMap.smul_apply, ContinuousLinearMap.comp_apply, fderivInnerCLM_apply,
ContinuousLinearMap.prod_apply, innerSL_apply_apply, id, ContinuousLinearMap.id_apply,
hT.apply_clm x₀ y, real_inner_comm _ x₀, two_smul]
variable [CompleteSpace F] {T : F →L[ℝ] F}
theorem linearly_dependent_of_isLocalExtrOn (hT : IsSelfAdjoint T) {x₀ : F}
(hextr : IsLocalExtrOn T.reApplyInnerSelf (sphere (0 : F) ‖x₀‖) x₀) :
∃ a b : ℝ, (a, b) ≠ 0 ∧ a • x₀ + b • T x₀ = 0 := by
have H : IsLocalExtrOn T.reApplyInnerSelf {x : F | ‖x‖ ^ 2 = ‖x₀‖ ^ 2} x₀ := by
convert hextr
ext x
simp
-- find Lagrange multipliers for the function `T.re_apply_inner_self` and the
-- hypersurface-defining function `fun x ↦ ‖x‖ ^ 2`
obtain ⟨a, b, h₁, h₂⟩ :=
IsLocalExtrOn.exists_multipliers_of_hasStrictFDerivAt_1d H (hasStrictFDerivAt_norm_sq x₀)
(hT.isSymmetric.hasStrictFDerivAt_reApplyInnerSelf x₀)
refine ⟨a, b, h₁, ?_⟩
apply (InnerProductSpace.toDualMap ℝ F).injective
simp only [LinearIsometry.map_add, LinearIsometry.map_zero]
-- Note: https://github.com/leanprover-community/mathlib4/pull/8386 changed `map_smulₛₗ` into `map_smulₛₗ _`
simp only [map_smulₛₗ _, RCLike.conj_to_real]
change a • innerSL ℝ x₀ + b • innerSL ℝ (T x₀) = 0
apply smul_right_injective (F →L[ℝ] ℝ) (two_ne_zero : (2 : ℝ) ≠ 0)
simpa only [two_smul, smul_add, add_smul, add_zero] using h₂
open scoped InnerProductSpace in
theorem eq_smul_self_of_isLocalExtrOn_real (hT : IsSelfAdjoint T) {x₀ : F}
(hextr : IsLocalExtrOn T.reApplyInnerSelf (sphere (0 : F) ‖x₀‖) x₀) :
T x₀ = T.rayleighQuotient x₀ • x₀ := by
obtain ⟨a, b, h₁, h₂⟩ := hT.linearly_dependent_of_isLocalExtrOn hextr
by_cases hx₀ : x₀ = 0
· simp [hx₀]
by_cases hb : b = 0
· have : a ≠ 0 := by simpa [hb] using h₁
refine absurd ?_ hx₀
apply smul_right_injective F this
simpa [hb] using h₂
have hc : T x₀ = (-b⁻¹ * a) • x₀ := by
linear_combination (norm := match_scalars <;> field) b⁻¹ • h₂
set c : ℝ := -b⁻¹ * a
convert hc
have := congr_arg (fun x => ⟪x, x₀⟫_ℝ) hc
simp [field, inner_smul_left, mul_comm a] at this ⊢
exact this
end Real
section CompleteSpace
variable [CompleteSpace E] {T : E →L[𝕜] E}
theorem eq_smul_self_of_isLocalExtrOn (hT : IsSelfAdjoint T) {x₀ : E}
(hextr : IsLocalExtrOn T.reApplyInnerSelf (sphere (0 : E) ‖x₀‖) x₀) :
T x₀ = (↑(T.rayleighQuotient x₀) : 𝕜) • x₀ := by
letI := InnerProductSpace.rclikeToReal 𝕜 E
let hSA := hT.isSymmetric.restrictScalars.toSelfAdjoint.prop
exact hSA.eq_smul_self_of_isLocalExtrOn_real hextr
/-- For a self-adjoint operator `T`, a local extremum of the Rayleigh quotient of `T` on a sphere
centred at the origin is an eigenvector of `T`. -/
theorem hasEigenvector_of_isLocalExtrOn (hT : IsSelfAdjoint T) {x₀ : E} (hx₀ : x₀ ≠ 0)
(hextr : IsLocalExtrOn T.reApplyInnerSelf (sphere (0 : E) ‖x₀‖) x₀) :
HasEigenvector (T : E →ₗ[𝕜] E) (↑(T.rayleighQuotient x₀)) x₀ := by
refine ⟨?_, hx₀⟩
rw [Module.End.mem_eigenspace_iff]
exact hT.eq_smul_self_of_isLocalExtrOn hextr
/-- For a self-adjoint operator `T`, a maximum of the Rayleigh quotient of `T` on a sphere centred
at the origin is an eigenvector of `T`, with eigenvalue the global supremum of the Rayleigh
quotient. -/
theorem hasEigenvector_of_isMaxOn (hT : IsSelfAdjoint T) {x₀ : E} (hx₀ : x₀ ≠ 0)
(hextr : IsMaxOn T.reApplyInnerSelf (sphere (0 : E) ‖x₀‖) x₀) :
HasEigenvector (T : E →ₗ[𝕜] E) (↑(⨆ x : { x : E // x ≠ 0 }, T.rayleighQuotient x)) x₀ := by
convert hT.hasEigenvector_of_isLocalExtrOn hx₀ (Or.inr hextr.localize)
have hx₀' : 0 < ‖x₀‖ := by simp [hx₀]
have hx₀'' : x₀ ∈ sphere (0 : E) ‖x₀‖ := by simp
rw [T.iSup_rayleigh_eq_iSup_rayleigh_sphere hx₀']
refine IsMaxOn.iSup_eq hx₀'' ?_
intro x hx
dsimp
have : ‖x‖ = ‖x₀‖ := by simpa using hx
simp only [ContinuousLinearMap.rayleighQuotient]
rw [this]
gcongr
exact hextr hx
/-- For a self-adjoint operator `T`, a minimum of the Rayleigh quotient of `T` on a sphere centred
at the origin is an eigenvector of `T`, with eigenvalue the global infimum of the Rayleigh
quotient. -/
theorem hasEigenvector_of_isMinOn (hT : IsSelfAdjoint T) {x₀ : E} (hx₀ : x₀ ≠ 0)
(hextr : IsMinOn T.reApplyInnerSelf (sphere (0 : E) ‖x₀‖) x₀) :
HasEigenvector (T : E →ₗ[𝕜] E) (↑(⨅ x : { x : E // x ≠ 0 }, T.rayleighQuotient x)) x₀ := by
convert hT.hasEigenvector_of_isLocalExtrOn hx₀ (Or.inl hextr.localize)
have hx₀' : 0 < ‖x₀‖ := by simp [hx₀]
have hx₀'' : x₀ ∈ sphere (0 : E) ‖x₀‖ := by simp
rw [T.iInf_rayleigh_eq_iInf_rayleigh_sphere hx₀']
refine IsMinOn.iInf_eq hx₀'' ?_
intro x hx
dsimp
have : ‖x‖ = ‖x₀‖ := by simpa using hx
simp only [ContinuousLinearMap.rayleighQuotient]
rw [this]
gcongr
exact hextr hx
end CompleteSpace
end IsSelfAdjoint
section FiniteDimensional
variable [FiniteDimensional 𝕜 E] {T : E →ₗ[𝕜] E}
namespace LinearMap
namespace IsSymmetric
/-- The supremum of the Rayleigh quotient of a symmetric operator `T` on a nontrivial
finite-dimensional vector space is an eigenvalue for that operator. -/
theorem hasEigenvalue_iSup_of_finiteDimensional [Nontrivial E] (hT : T.IsSymmetric) :
HasEigenvalue T ↑(⨆ x : { x : E // x ≠ 0 }, RCLike.re ⟪T x, x⟫ / ‖(x : E)‖ ^ 2 : ℝ) := by
haveI := FiniteDimensional.proper_rclike 𝕜 E
let T' := hT.toSelfAdjoint
obtain ⟨x, hx⟩ : ∃ x : E, x ≠ 0 := exists_ne 0
have H₁ : IsCompact (sphere (0 : E) ‖x‖) := isCompact_sphere _ _
have H₂ : (sphere (0 : E) ‖x‖).Nonempty := ⟨x, by simp⟩
-- key point: in finite dimension, a continuous function on the sphere has a max
obtain ⟨x₀, hx₀', hTx₀⟩ :=
H₁.exists_isMaxOn H₂ T'.val.reApplyInnerSelf_continuous.continuousOn
have hx₀ : ‖x₀‖ = ‖x‖ := by simpa using hx₀'
have : IsMaxOn T'.val.reApplyInnerSelf (sphere 0 ‖x₀‖) x₀ := by simpa only [← hx₀] using hTx₀
have hx₀_ne : x₀ ≠ 0 := by
have : ‖x₀‖ ≠ 0 := by simp only [hx₀, norm_eq_zero, hx, Ne, not_false_iff]
simpa [← norm_eq_zero, Ne]
exact hasEigenvalue_of_hasEigenvector (T'.prop.hasEigenvector_of_isMaxOn hx₀_ne this)
/-- The infimum of the Rayleigh quotient of a symmetric operator `T` on a nontrivial
finite-dimensional vector space is an eigenvalue for that operator. -/
theorem hasEigenvalue_iInf_of_finiteDimensional [Nontrivial E] (hT : T.IsSymmetric) :
HasEigenvalue T ↑(⨅ x : { x : E // x ≠ 0 }, RCLike.re ⟪T x, x⟫ / ‖(x : E)‖ ^ 2 : ℝ) := by
haveI := FiniteDimensional.proper_rclike 𝕜 E
let T' := hT.toSelfAdjoint
obtain ⟨x, hx⟩ : ∃ x : E, x ≠ 0 := exists_ne 0
have H₁ : IsCompact (sphere (0 : E) ‖x‖) := isCompact_sphere _ _
have H₂ : (sphere (0 : E) ‖x‖).Nonempty := ⟨x, by simp⟩
-- key point: in finite dimension, a continuous function on the sphere has a min
obtain ⟨x₀, hx₀', hTx₀⟩ :=
H₁.exists_isMinOn H₂ T'.val.reApplyInnerSelf_continuous.continuousOn
have hx₀ : ‖x₀‖ = ‖x‖ := by simpa using hx₀'
have : IsMinOn T'.val.reApplyInnerSelf (sphere 0 ‖x₀‖) x₀ := by simpa only [← hx₀] using hTx₀
have hx₀_ne : x₀ ≠ 0 := by
have : ‖x₀‖ ≠ 0 := by simp only [hx₀, norm_eq_zero, hx, Ne, not_false_iff]
simpa [← norm_eq_zero, Ne]
exact hasEigenvalue_of_hasEigenvector (T'.prop.hasEigenvector_of_isMinOn hx₀_ne this)
theorem subsingleton_of_no_eigenvalue_finiteDimensional (hT : T.IsSymmetric)
(hT' : ∀ μ : 𝕜, Module.End.eigenspace (T : E →ₗ[𝕜] E) μ = ⊥) : Subsingleton E :=
(subsingleton_or_nontrivial E).resolve_right fun _h =>
absurd (hT' _) hT.hasEigenvalue_iSup_of_finiteDimensional
end IsSymmetric
end LinearMap
end FiniteDimensional |
.lake/packages/mathlib/Mathlib/Analysis/InnerProductSpace/WeakOperatorTopology.lean | import Mathlib.Analysis.InnerProductSpace.Dual
import Mathlib.Analysis.LocallyConvex.WeakOperatorTopology
/-!
# The weak operator topology in Hilbert spaces
This file gives a few properties of the weak operator topology that are specific to operators on
Hilbert spaces. This mostly involves using the Fréchet-Riesz representation to convert between
applications of elements of the dual and inner products with vectors in the space.
-/
open scoped Topology InnerProductSpace
namespace ContinuousLinearMapWOT
variable {𝕜 : Type*} {E : Type*} {F : Type*} [RCLike 𝕜] [AddCommGroup E] [TopologicalSpace E]
[Module 𝕜 E] [NormedAddCommGroup F] [InnerProductSpace 𝕜 F]
@[ext]
lemma ext_inner {A B : E →WOT[𝕜] F} (h : ∀ x y, ⟪y, A x⟫_𝕜 = ⟪y, B x⟫_𝕜) : A = B := by
rw [ext_iff]
exact fun x => ext_inner_left 𝕜 fun y => h x y
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_inner_apply_tendsto [CompleteSpace F] {α : Type*} {l : Filter α}
{f : α → E →WOT[𝕜] F} {A : E →WOT[𝕜] F} :
Tendsto f l (𝓝 A) ↔ ∀ x y, Tendsto (fun a => ⟪y, (f a) x⟫_𝕜) l (𝓝 ⟪y, A x⟫_𝕜) := by
simp_rw [tendsto_iff_forall_dual_apply_tendsto]
exact .symm <| forall_congr' fun _ ↦
Equiv.forall_congr (InnerProductSpace.toDual 𝕜 F) fun _ ↦ Iff.rfl
lemma le_nhds_iff_forall_inner_apply_le_nhds [CompleteSpace F] {l : Filter (E →WOT[𝕜] F)}
{A : E →WOT[𝕜] F} : l ≤ 𝓝 A ↔ ∀ x y, l.map (fun T => ⟪y, T x⟫_𝕜) ≤ 𝓝 (⟪y, A x⟫_𝕜) :=
tendsto_iff_forall_inner_apply_tendsto (f := id)
end ContinuousLinearMapWOT |
.lake/packages/mathlib/Mathlib/Analysis/InnerProductSpace/Calculus.lean | import Mathlib.Analysis.InnerProductSpace.PiL2
import Mathlib.Analysis.SpecialFunctions.Sqrt
import Mathlib.Analysis.Normed.Module.Ball.Homeomorph
import Mathlib.Analysis.Calculus.ContDiff.WithLp
import Mathlib.Analysis.Calculus.FDeriv.WithLp
/-!
# Calculus in inner product spaces
In this file we prove that the inner product and square of the norm in an inner space are
infinitely `ℝ`-smooth. In order to state these results, we need a `NormedSpace ℝ E`
instance. Though we can deduce this structure from `InnerProductSpace 𝕜 E`, this instance may be
not definitionally equal to some other “natural” instance. So, we assume `[NormedSpace ℝ E]`.
We also prove that functions to a `EuclideanSpace` are (higher) differentiable if and only if
their components are. This follows from the corresponding fact for finite product of normed spaces,
and from the equivalence of norms in finite dimensions.
## TODO
The last part of the file should be generalized to `PiLp`.
-/
noncomputable section
open RCLike Real Filter
section DerivInner
variable {𝕜 E F : Type*} [RCLike 𝕜]
variable [NormedAddCommGroup E] [InnerProductSpace 𝕜 E]
variable [NormedAddCommGroup F] [InnerProductSpace ℝ F]
local notation "⟪" x ", " y "⟫" => inner 𝕜 x y
variable (𝕜) [NormedSpace ℝ E]
/-- Derivative of the inner product. -/
def fderivInnerCLM (p : E × E) : E × E →L[ℝ] 𝕜 :=
isBoundedBilinearMap_inner.deriv p
@[simp]
theorem fderivInnerCLM_apply (p x : E × E) : fderivInnerCLM 𝕜 p x = ⟪p.1, x.2⟫ + ⟪x.1, p.2⟫ :=
rfl
variable {𝕜}
theorem contDiff_inner {n} : ContDiff ℝ n fun p : E × E => ⟪p.1, p.2⟫ :=
isBoundedBilinearMap_inner.contDiff
theorem contDiffAt_inner {p : E × E} {n} : ContDiffAt ℝ n (fun p : E × E => ⟪p.1, p.2⟫) p :=
ContDiff.contDiffAt contDiff_inner
theorem differentiable_inner : Differentiable ℝ fun p : E × E => ⟪p.1, p.2⟫ :=
isBoundedBilinearMap_inner.differentiableAt
variable (𝕜)
variable {G : Type*} [NormedAddCommGroup G] [NormedSpace ℝ G] {f g : G → E} {f' g' : G →L[ℝ] E}
{s : Set G} {x : G} {n : WithTop ℕ∞}
theorem ContDiffWithinAt.inner (hf : ContDiffWithinAt ℝ n f s x) (hg : ContDiffWithinAt ℝ n g s x) :
ContDiffWithinAt ℝ n (fun x => ⟪f x, g x⟫) s x :=
contDiffAt_inner.comp_contDiffWithinAt x (hf.prodMk hg)
nonrec theorem ContDiffAt.inner (hf : ContDiffAt ℝ n f x) (hg : ContDiffAt ℝ n g x) :
ContDiffAt ℝ n (fun x => ⟪f x, g x⟫) x :=
hf.inner 𝕜 hg
theorem ContDiffOn.inner (hf : ContDiffOn ℝ n f s) (hg : ContDiffOn ℝ n g s) :
ContDiffOn ℝ n (fun x => ⟪f x, g x⟫) s := fun x hx => (hf x hx).inner 𝕜 (hg x hx)
theorem ContDiff.inner (hf : ContDiff ℝ n f) (hg : ContDiff ℝ n g) :
ContDiff ℝ n fun x => ⟪f x, g x⟫ :=
contDiff_inner.comp (hf.prodMk hg)
theorem HasFDerivWithinAt.inner (hf : HasFDerivWithinAt f f' s x)
(hg : HasFDerivWithinAt g g' s x) :
HasFDerivWithinAt (fun t => ⟪f t, g t⟫) ((fderivInnerCLM 𝕜 (f x, g x)).comp <| f'.prod g') s
x := by
-- `by exact` to handle a tricky unification.
exact isBoundedBilinearMap_inner (𝕜 := 𝕜) (E := E)
|>.hasFDerivAt (f x, g x) |>.comp_hasFDerivWithinAt x (hf.prodMk hg)
theorem HasStrictFDerivAt.inner (hf : HasStrictFDerivAt f f' x) (hg : HasStrictFDerivAt g g' x) :
HasStrictFDerivAt (fun t => ⟪f t, g t⟫) ((fderivInnerCLM 𝕜 (f x, g x)).comp <| f'.prod g') x :=
isBoundedBilinearMap_inner (𝕜 := 𝕜) (E := E)
|>.hasStrictFDerivAt (f x, g x) |>.comp x (hf.prodMk hg)
theorem HasFDerivAt.inner (hf : HasFDerivAt f f' x) (hg : HasFDerivAt g g' x) :
HasFDerivAt (fun t => ⟪f t, g t⟫) ((fderivInnerCLM 𝕜 (f x, g x)).comp <| f'.prod g') x := by
-- `by exact` to handle a tricky unification.
exact isBoundedBilinearMap_inner (𝕜 := 𝕜) (E := E)
|>.hasFDerivAt (f x, g x) |>.comp x (hf.prodMk hg)
theorem HasDerivWithinAt.inner {f g : ℝ → E} {f' g' : E} {s : Set ℝ} {x : ℝ}
(hf : HasDerivWithinAt f f' s x) (hg : HasDerivWithinAt g g' s x) :
HasDerivWithinAt (fun t => ⟪f t, g t⟫) (⟪f x, g'⟫ + ⟪f', g x⟫) s x := by
simpa using (hf.hasFDerivWithinAt.inner 𝕜 hg.hasFDerivWithinAt).hasDerivWithinAt
theorem HasDerivAt.inner {f g : ℝ → E} {f' g' : E} {x : ℝ} :
HasDerivAt f f' x → HasDerivAt g g' x →
HasDerivAt (fun t => ⟪f t, g t⟫) (⟪f x, g'⟫ + ⟪f', g x⟫) x := by
simpa only [← hasDerivWithinAt_univ] using HasDerivWithinAt.inner 𝕜
theorem DifferentiableWithinAt.inner (hf : DifferentiableWithinAt ℝ f s x)
(hg : DifferentiableWithinAt ℝ g s x) : DifferentiableWithinAt ℝ (fun x => ⟪f x, g x⟫) s x :=
(hf.hasFDerivWithinAt.inner 𝕜 hg.hasFDerivWithinAt).differentiableWithinAt
theorem DifferentiableAt.inner (hf : DifferentiableAt ℝ f x) (hg : DifferentiableAt ℝ g x) :
DifferentiableAt ℝ (fun x => ⟪f x, g x⟫) x :=
(hf.hasFDerivAt.inner 𝕜 hg.hasFDerivAt).differentiableAt
theorem DifferentiableOn.inner (hf : DifferentiableOn ℝ f s) (hg : DifferentiableOn ℝ g s) :
DifferentiableOn ℝ (fun x => ⟪f x, g x⟫) s := fun x hx => (hf x hx).inner 𝕜 (hg x hx)
theorem Differentiable.inner (hf : Differentiable ℝ f) (hg : Differentiable ℝ g) :
Differentiable ℝ fun x => ⟪f x, g x⟫ := fun x => (hf x).inner 𝕜 (hg x)
theorem fderiv_inner_apply (hf : DifferentiableAt ℝ f x) (hg : DifferentiableAt ℝ g x) (y : G) :
fderiv ℝ (fun t => ⟪f t, g t⟫) x y = ⟪f x, fderiv ℝ g x y⟫ + ⟪fderiv ℝ f x y, g x⟫ := by
rw [(hf.hasFDerivAt.inner 𝕜 hg.hasFDerivAt).fderiv]; rfl
theorem deriv_inner_apply {f g : ℝ → E} {x : ℝ} (hf : DifferentiableAt ℝ f x)
(hg : DifferentiableAt ℝ g x) :
deriv (fun t => ⟪f t, g t⟫) x = ⟪f x, deriv g x⟫ + ⟪deriv f x, g x⟫ :=
(hf.hasDerivAt.inner 𝕜 hg.hasDerivAt).deriv
section
include 𝕜
theorem contDiff_norm_sq : ContDiff ℝ n fun x : E => ‖x‖ ^ 2 := by
convert (reCLM : 𝕜 →L[ℝ] ℝ).contDiff.comp ((contDiff_id (E := E)).inner 𝕜 (contDiff_id (E := E)))
exact (inner_self_eq_norm_sq _).symm
theorem ContDiff.norm_sq (hf : ContDiff ℝ n f) : ContDiff ℝ n fun x => ‖f x‖ ^ 2 :=
(contDiff_norm_sq 𝕜).comp hf
theorem ContDiffWithinAt.norm_sq (hf : ContDiffWithinAt ℝ n f s x) :
ContDiffWithinAt ℝ n (fun y => ‖f y‖ ^ 2) s x :=
(contDiff_norm_sq 𝕜).contDiffAt.comp_contDiffWithinAt x hf
nonrec theorem ContDiffAt.norm_sq (hf : ContDiffAt ℝ n f x) : ContDiffAt ℝ n (‖f ·‖ ^ 2) x :=
hf.norm_sq 𝕜
theorem contDiffAt_norm {x : E} (hx : x ≠ 0) : ContDiffAt ℝ n norm x := by
have : ‖id x‖ ^ 2 ≠ 0 := pow_ne_zero 2 (norm_pos_iff.2 hx).ne'
simpa only [id, sqrt_sq, norm_nonneg] using (contDiffAt_id.norm_sq 𝕜).sqrt this
theorem ContDiffAt.norm (hf : ContDiffAt ℝ n f x) (h0 : f x ≠ 0) :
ContDiffAt ℝ n (fun y => ‖f y‖) x :=
(contDiffAt_norm 𝕜 h0).comp x hf
theorem ContDiffAt.dist (hf : ContDiffAt ℝ n f x) (hg : ContDiffAt ℝ n g x) (hne : f x ≠ g x) :
ContDiffAt ℝ n (fun y => dist (f y) (g y)) x := by
simp only [dist_eq_norm]
exact (hf.sub hg).norm 𝕜 (sub_ne_zero.2 hne)
theorem ContDiffWithinAt.norm (hf : ContDiffWithinAt ℝ n f s x) (h0 : f x ≠ 0) :
ContDiffWithinAt ℝ n (fun y => ‖f y‖) s x :=
(contDiffAt_norm 𝕜 h0).comp_contDiffWithinAt x hf
theorem ContDiffWithinAt.dist (hf : ContDiffWithinAt ℝ n f s x) (hg : ContDiffWithinAt ℝ n g s x)
(hne : f x ≠ g x) : ContDiffWithinAt ℝ n (fun y => dist (f y) (g y)) s x := by
simp only [dist_eq_norm]; exact (hf.sub hg).norm 𝕜 (sub_ne_zero.2 hne)
theorem ContDiffOn.norm_sq (hf : ContDiffOn ℝ n f s) : ContDiffOn ℝ n (fun y => ‖f y‖ ^ 2) s :=
fun x hx => (hf x hx).norm_sq 𝕜
theorem ContDiffOn.norm (hf : ContDiffOn ℝ n f s) (h0 : ∀ x ∈ s, f x ≠ 0) :
ContDiffOn ℝ n (fun y => ‖f y‖) s := fun x hx => (hf x hx).norm 𝕜 (h0 x hx)
theorem ContDiffOn.dist (hf : ContDiffOn ℝ n f s) (hg : ContDiffOn ℝ n g s)
(hne : ∀ x ∈ s, f x ≠ g x) : ContDiffOn ℝ n (fun y => dist (f y) (g y)) s := fun x hx =>
(hf x hx).dist 𝕜 (hg x hx) (hne x hx)
theorem ContDiff.norm (hf : ContDiff ℝ n f) (h0 : ∀ x, f x ≠ 0) : ContDiff ℝ n fun y => ‖f y‖ :=
contDiff_iff_contDiffAt.2 fun x => hf.contDiffAt.norm 𝕜 (h0 x)
theorem ContDiff.dist (hf : ContDiff ℝ n f) (hg : ContDiff ℝ n g) (hne : ∀ x, f x ≠ g x) :
ContDiff ℝ n fun y => dist (f y) (g y) :=
contDiff_iff_contDiffAt.2 fun x => hf.contDiffAt.dist 𝕜 hg.contDiffAt (hne x)
end
section
open scoped RealInnerProductSpace
theorem hasStrictFDerivAt_norm_sq (x : F) :
HasStrictFDerivAt (fun x => ‖x‖ ^ 2) (2 • (innerSL ℝ x)) x := by
simp only [sq, ← @inner_self_eq_norm_mul_norm ℝ]
convert (hasStrictFDerivAt_id x).inner ℝ (hasStrictFDerivAt_id x)
ext y
simp [two_smul, real_inner_comm]
@[simp]
theorem fderiv_norm_sq_apply (x : F) : fderiv ℝ (fun (x : F) ↦ ‖x‖ ^ 2) x = 2 • innerSL ℝ x :=
(hasStrictFDerivAt_norm_sq x).hasFDerivAt.fderiv
theorem fderiv_norm_sq : fderiv ℝ (fun (x : F) ↦ ‖x‖ ^ 2) = 2 • (innerSL ℝ (E := F)) := by
ext1; simp
theorem HasFDerivAt.norm_sq {f : G → F} {f' : G →L[ℝ] F} (hf : HasFDerivAt f f' x) :
HasFDerivAt (‖f ·‖ ^ 2) (2 • (innerSL ℝ (f x)).comp f') x :=
(hasStrictFDerivAt_norm_sq _).hasFDerivAt.comp x hf
theorem HasDerivAt.norm_sq {f : ℝ → F} {f' : F} {x : ℝ} (hf : HasDerivAt f f' x) :
HasDerivAt (‖f ·‖ ^ 2) (2 * ⟪f x, f'⟫) x := by
simpa using hf.hasFDerivAt.norm_sq.hasDerivAt
theorem HasFDerivWithinAt.norm_sq {f : G → F} {f' : G →L[ℝ] F} (hf : HasFDerivWithinAt f f' s x) :
HasFDerivWithinAt (‖f ·‖ ^ 2) (2 • (innerSL ℝ (f x)).comp f') s x :=
(hasStrictFDerivAt_norm_sq _).hasFDerivAt.comp_hasFDerivWithinAt x hf
theorem HasDerivWithinAt.norm_sq {f : ℝ → F} {f' : F} {s : Set ℝ} {x : ℝ}
(hf : HasDerivWithinAt f f' s x) :
HasDerivWithinAt (‖f ·‖ ^ 2) (2 * ⟪f x, f'⟫) s x := by
simpa using hf.hasFDerivWithinAt.norm_sq.hasDerivWithinAt
end
section
include 𝕜
theorem DifferentiableAt.norm_sq (hf : DifferentiableAt ℝ f x) :
DifferentiableAt ℝ (fun y => ‖f y‖ ^ 2) x :=
((contDiffAt_id.norm_sq 𝕜).differentiableAt le_rfl).comp x hf
theorem DifferentiableAt.norm (hf : DifferentiableAt ℝ f x) (h0 : f x ≠ 0) :
DifferentiableAt ℝ (fun y => ‖f y‖) x :=
((contDiffAt_norm 𝕜 h0).differentiableAt le_rfl).comp x hf
theorem DifferentiableAt.dist (hf : DifferentiableAt ℝ f x) (hg : DifferentiableAt ℝ g x)
(hne : f x ≠ g x) : DifferentiableAt ℝ (fun y => dist (f y) (g y)) x := by
simp only [dist_eq_norm]; exact (hf.sub hg).norm 𝕜 (sub_ne_zero.2 hne)
theorem Differentiable.norm_sq (hf : Differentiable ℝ f) : Differentiable ℝ fun y => ‖f y‖ ^ 2 :=
fun x => (hf x).norm_sq 𝕜
theorem Differentiable.norm (hf : Differentiable ℝ f) (h0 : ∀ x, f x ≠ 0) :
Differentiable ℝ fun y => ‖f y‖ := fun x => (hf x).norm 𝕜 (h0 x)
theorem Differentiable.dist (hf : Differentiable ℝ f) (hg : Differentiable ℝ g)
(hne : ∀ x, f x ≠ g x) : Differentiable ℝ fun y => dist (f y) (g y) := fun x =>
(hf x).dist 𝕜 (hg x) (hne x)
theorem DifferentiableWithinAt.norm_sq (hf : DifferentiableWithinAt ℝ f s x) :
DifferentiableWithinAt ℝ (fun y => ‖f y‖ ^ 2) s x :=
((contDiffAt_id.norm_sq 𝕜).differentiableAt le_rfl).comp_differentiableWithinAt x hf
theorem DifferentiableWithinAt.norm (hf : DifferentiableWithinAt ℝ f s x) (h0 : f x ≠ 0) :
DifferentiableWithinAt ℝ (fun y => ‖f y‖) s x :=
((contDiffAt_id.norm 𝕜 h0).differentiableAt le_rfl).comp_differentiableWithinAt x hf
theorem DifferentiableWithinAt.dist (hf : DifferentiableWithinAt ℝ f s x)
(hg : DifferentiableWithinAt ℝ g s x) (hne : f x ≠ g x) :
DifferentiableWithinAt ℝ (fun y => dist (f y) (g y)) s x := by
simp only [dist_eq_norm]
exact (hf.sub hg).norm 𝕜 (sub_ne_zero.2 hne)
theorem DifferentiableOn.norm_sq (hf : DifferentiableOn ℝ f s) :
DifferentiableOn ℝ (fun y => ‖f y‖ ^ 2) s := fun x hx => (hf x hx).norm_sq 𝕜
theorem DifferentiableOn.norm (hf : DifferentiableOn ℝ f s) (h0 : ∀ x ∈ s, f x ≠ 0) :
DifferentiableOn ℝ (fun y => ‖f y‖) s := fun x hx => (hf x hx).norm 𝕜 (h0 x hx)
theorem DifferentiableOn.dist (hf : DifferentiableOn ℝ f s) (hg : DifferentiableOn ℝ g s)
(hne : ∀ x ∈ s, f x ≠ g x) : DifferentiableOn ℝ (fun y => dist (f y) (g y)) s := fun x hx =>
(hf x hx).dist 𝕜 (hg x hx) (hne x hx)
end
end DerivInner
section PiLike
/-! ### Convenience aliases of `PiLp` lemmas for `EuclideanSpace` -/
open ContinuousLinearMap
variable {𝕜 ι H : Type*} [RCLike 𝕜] [NormedAddCommGroup H] [NormedSpace 𝕜 H] [Fintype ι]
{f : H → EuclideanSpace 𝕜 ι} {f' : H →L[𝕜] EuclideanSpace 𝕜 ι} {t : Set H} {y : H}
theorem differentiableWithinAt_euclidean :
DifferentiableWithinAt 𝕜 f t y ↔ ∀ i, DifferentiableWithinAt 𝕜 (fun x => f x i) t y :=
differentiableWithinAt_piLp _
theorem differentiableAt_euclidean :
DifferentiableAt 𝕜 f y ↔ ∀ i, DifferentiableAt 𝕜 (fun x => f x i) y :=
differentiableAt_piLp _
theorem differentiableOn_euclidean :
DifferentiableOn 𝕜 f t ↔ ∀ i, DifferentiableOn 𝕜 (fun x => f x i) t :=
differentiableOn_piLp _
theorem differentiable_euclidean : Differentiable 𝕜 f ↔ ∀ i, Differentiable 𝕜 fun x => f x i :=
differentiable_piLp _
theorem hasStrictFDerivAt_euclidean :
HasStrictFDerivAt f f' y ↔
∀ i, HasStrictFDerivAt (fun x => f x i) (PiLp.proj _ _ i ∘L f') y :=
hasStrictFDerivAt_piLp _
theorem hasFDerivWithinAt_euclidean :
HasFDerivWithinAt f f' t y ↔
∀ i, HasFDerivWithinAt (fun x => f x i) (PiLp.proj _ _ i ∘L f') t y :=
hasFDerivWithinAt_piLp _
theorem contDiffWithinAt_euclidean {n : WithTop ℕ∞} :
ContDiffWithinAt 𝕜 n f t y ↔ ∀ i, ContDiffWithinAt 𝕜 n (fun x => f x i) t y :=
contDiffWithinAt_piLp _
theorem contDiffAt_euclidean {n : WithTop ℕ∞} :
ContDiffAt 𝕜 n f y ↔ ∀ i, ContDiffAt 𝕜 n (fun x => f x i) y :=
contDiffAt_piLp _
theorem contDiffOn_euclidean {n : WithTop ℕ∞} :
ContDiffOn 𝕜 n f t ↔ ∀ i, ContDiffOn 𝕜 n (fun x => f x i) t :=
contDiffOn_piLp _
theorem contDiff_euclidean {n : WithTop ℕ∞} : ContDiff 𝕜 n f ↔ ∀ i, ContDiff 𝕜 n fun x => f x i :=
contDiff_piLp _
end PiLike
section DiffeomorphUnitBall
open Metric hiding mem_nhds_iff
variable {n : ℕ∞} {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E]
theorem OpenPartialHomeomorph.contDiff_univUnitBall : ContDiff ℝ n (univUnitBall : E → E) := by
suffices ContDiff ℝ n fun x : E => (√(1 + ‖x‖ ^ 2 : ℝ))⁻¹ from this.smul contDiff_id
have h : ∀ x : E, (0 : ℝ) < (1 : ℝ) + ‖x‖ ^ 2 := fun x => by positivity
refine ContDiff.inv ?_ fun x => Real.sqrt_ne_zero'.mpr (h x)
exact (contDiff_const.add <| contDiff_norm_sq ℝ).sqrt fun x => (h x).ne'
theorem OpenPartialHomeomorph.contDiffOn_univUnitBall_symm :
ContDiffOn ℝ n univUnitBall.symm (ball (0 : E) 1) := fun y hy ↦ by
apply ContDiffAt.contDiffWithinAt
suffices ContDiffAt ℝ n (fun y : E => (√(1 - ‖y‖ ^ 2 : ℝ))⁻¹) y from this.smul contDiffAt_id
have h : (0 : ℝ) < (1 : ℝ) - ‖(y : E)‖ ^ 2 := by
rwa [mem_ball_zero_iff, ← _root_.abs_one, ← abs_norm, ← sq_lt_sq, one_pow, ← sub_pos] at hy
refine ContDiffAt.inv ?_ (Real.sqrt_ne_zero'.mpr h)
change ContDiffAt ℝ n ((fun y ↦ √(y)) ∘ fun y ↦ (1 - ‖y‖ ^ 2)) y
refine (contDiffAt_sqrt h.ne').comp y ?_
exact contDiffAt_const.sub (contDiff_norm_sq ℝ).contDiffAt
theorem Homeomorph.contDiff_unitBall : ContDiff ℝ n fun x : E => (unitBall x : E) :=
OpenPartialHomeomorph.contDiff_univUnitBall
namespace OpenPartialHomeomorph
variable {c : E} {r : ℝ}
theorem contDiff_unitBallBall (hr : 0 < r) : ContDiff ℝ n (unitBallBall c r hr) :=
(contDiff_id.const_smul _).add contDiff_const
theorem contDiff_unitBallBall_symm (hr : 0 < r) : ContDiff ℝ n (unitBallBall c r hr).symm :=
(contDiff_id.sub contDiff_const).const_smul _
theorem contDiff_univBall : ContDiff ℝ n (univBall c r) := by
unfold univBall; split_ifs with h
· exact (contDiff_unitBallBall h).comp contDiff_univUnitBall
· exact contDiff_id.add contDiff_const
theorem contDiffOn_univBall_symm :
ContDiffOn ℝ n (univBall c r).symm (ball c r) := by
unfold univBall; split_ifs with h
· refine contDiffOn_univUnitBall_symm.comp (contDiff_unitBallBall_symm h).contDiffOn ?_
rw [← unitBallBall_source c r h, ← unitBallBall_target c r h]
apply OpenPartialHomeomorph.symm_mapsTo
· exact contDiffOn_id.sub contDiffOn_const
end OpenPartialHomeomorph
end DiffeomorphUnitBall |
.lake/packages/mathlib/Mathlib/Analysis/InnerProductSpace/TwoDim.lean | import Mathlib.Analysis.InnerProductSpace.Dual
import Mathlib.Analysis.InnerProductSpace.Orientation
import Mathlib.LinearAlgebra.Alternating.Curry
import Mathlib.LinearAlgebra.Complex.FiniteDimensional
import Mathlib.LinearAlgebra.Complex.Orientation
import Mathlib.Tactic.LinearCombination
/-!
# Oriented two-dimensional real inner product spaces
This file defines constructions specific to the geometry of an oriented two-dimensional real inner
product space `E`.
## Main declarations
* `Orientation.areaForm`: an antisymmetric bilinear form `E →ₗ[ℝ] E →ₗ[ℝ] ℝ` (usual notation `ω`).
Morally, when `ω` is evaluated on two vectors, it gives the oriented area of the parallelogram
they span. (But mathlib does not yet have a construction of oriented area, and in fact the
construction of oriented area should pass through `ω`.)
* `Orientation.rightAngleRotation`: an isometric automorphism `E ≃ₗᵢ[ℝ] E` (usual notation `J`).
This automorphism squares to -1. In a later file, rotations (`Orientation.rotation`) are defined,
in such a way that this automorphism is equal to rotation by 90 degrees.
* `Orientation.basisRightAngleRotation`: for a nonzero vector `x` in `E`, the basis `![x, J x]`
for `E`.
* `Orientation.kahler`: a complex-valued real-bilinear map `E →ₗ[ℝ] E →ₗ[ℝ] ℂ`. Its real part is the
inner product and its imaginary part is `Orientation.areaForm`. For vectors `x` and `y` in `E`,
the complex number `o.kahler x y` has modulus `‖x‖ * ‖y‖`. In a later file, oriented angles
(`Orientation.oangle`) are defined, in such a way that the argument of `o.kahler x y` is the
oriented angle from `x` to `y`.
## Main results
* `Orientation.rightAngleRotation_rightAngleRotation`: the identity `J (J x) = - x`
* `Orientation.nonneg_inner_and_areaForm_eq_zero_iff_sameRay`: `x`, `y` are in the same ray, if
and only if `0 ≤ ⟪x, y⟫` and `ω x y = 0`
* `Orientation.kahler_mul`: the identity `o.kahler x a * o.kahler a y = ‖a‖ ^ 2 * o.kahler x y`
* `Complex.areaForm`, `Complex.rightAngleRotation`, `Complex.kahler`: the concrete
interpretations of `areaForm`, `rightAngleRotation`, `kahler` for the oriented real inner
product space `ℂ`
* `Orientation.areaForm_map_complex`, `Orientation.rightAngleRotation_map_complex`,
`Orientation.kahler_map_complex`: given an orientation-preserving isometry from `E` to `ℂ`,
expressions for `areaForm`, `rightAngleRotation`, `kahler` as the pullback of their concrete
interpretations on `ℂ`
## Implementation notes
Notation `ω` for `Orientation.areaForm` and `J` for `Orientation.rightAngleRotation` should be
defined locally in each file which uses them, since otherwise one would need a more cumbersome
notation which mentions the orientation explicitly (something like `ω[o]`). Write
```
local notation "ω" => o.areaForm
local notation "J" => o.rightAngleRotation
```
-/
noncomputable section
open scoped RealInnerProductSpace ComplexConjugate
open Module
lemma FiniteDimensional.of_fact_finrank_eq_two {K V : Type*} [DivisionRing K]
[AddCommGroup V] [Module K V] [Fact (finrank K V = 2)] : FiniteDimensional K V :=
.of_fact_finrank_eq_succ 1
attribute [local instance] FiniteDimensional.of_fact_finrank_eq_two
variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [Fact (finrank ℝ E = 2)]
(o : Orientation ℝ E (Fin 2))
namespace Orientation
/-- An antisymmetric bilinear form on an oriented real inner product space of dimension 2 (usual
notation `ω`). When evaluated on two vectors, it gives the oriented area of the parallelogram they
span. -/
irreducible_def areaForm : E →ₗ[ℝ] E →ₗ[ℝ] ℝ := by
let z : E [⋀^Fin 0]→ₗ[ℝ] ℝ ≃ₗ[ℝ] ℝ :=
AlternatingMap.constLinearEquivOfIsEmpty.symm
let y : E [⋀^Fin 1]→ₗ[ℝ] ℝ →ₗ[ℝ] E →ₗ[ℝ] ℝ :=
LinearMap.llcomp ℝ E (E [⋀^Fin 0]→ₗ[ℝ] ℝ) ℝ z ∘ₗ AlternatingMap.curryLeftLinearMap
exact y ∘ₗ AlternatingMap.curryLeftLinearMap o.volumeForm
local notation "ω" => o.areaForm
theorem areaForm_to_volumeForm (x y : E) : ω x y = o.volumeForm ![x, y] := by simp [areaForm]
@[simp]
theorem areaForm_apply_self (x : E) : ω x x = 0 := by
rw [areaForm_to_volumeForm]
refine o.volumeForm.map_eq_zero_of_eq ![x, x] ?_ (?_ : (0 : Fin 2) ≠ 1)
· simp
· simp
theorem areaForm_swap (x y : E) : ω x y = -ω y x := by
simp only [areaForm_to_volumeForm]
convert o.volumeForm.map_swap ![y, x] (_ : (0 : Fin 2) ≠ 1)
· ext i
fin_cases i <;> rfl
· simp
@[simp]
theorem areaForm_neg_orientation : (-o).areaForm = -o.areaForm := by
ext x y
simp [areaForm_to_volumeForm]
/-- Continuous linear map version of `Orientation.areaForm`, useful for calculus. -/
def areaForm' : E →L[ℝ] E →L[ℝ] ℝ :=
LinearMap.toContinuousLinearMap
(↑(LinearMap.toContinuousLinearMap : (E →ₗ[ℝ] ℝ) ≃ₗ[ℝ] E →L[ℝ] ℝ) ∘ₗ o.areaForm)
@[simp]
theorem areaForm'_apply (x : E) :
o.areaForm' x = LinearMap.toContinuousLinearMap (o.areaForm x) :=
rfl
theorem abs_areaForm_le (x y : E) : |ω x y| ≤ ‖x‖ * ‖y‖ := by
simpa [areaForm_to_volumeForm, Fin.prod_univ_succ] using o.abs_volumeForm_apply_le ![x, y]
theorem areaForm_le (x y : E) : ω x y ≤ ‖x‖ * ‖y‖ := by
simpa [areaForm_to_volumeForm, Fin.prod_univ_succ] using o.volumeForm_apply_le ![x, y]
theorem abs_areaForm_of_orthogonal {x y : E} (h : ⟪x, y⟫ = 0) : |ω x y| = ‖x‖ * ‖y‖ := by
rw [o.areaForm_to_volumeForm, o.abs_volumeForm_apply_of_pairwise_orthogonal]
· simp [Fin.prod_univ_succ]
intro i j hij
fin_cases i <;> fin_cases j
· simp_all
· simpa using h
· simpa [real_inner_comm] using h
· simp_all
theorem areaForm_map {F : Type*} [NormedAddCommGroup F] [InnerProductSpace ℝ F]
[hF : Fact (finrank ℝ F = 2)] (φ : E ≃ₗᵢ[ℝ] F) (x y : F) :
(Orientation.map (Fin 2) φ.toLinearEquiv o).areaForm x y =
o.areaForm (φ.symm x) (φ.symm y) := by
have : φ.symm ∘ ![x, y] = ![φ.symm x, φ.symm y] := by
ext i
fin_cases i <;> rfl
simp [areaForm_to_volumeForm, volumeForm_map, this]
/-- The area form is invariant under pullback by a positively-oriented isometric automorphism. -/
theorem areaForm_comp_linearIsometryEquiv (φ : E ≃ₗᵢ[ℝ] E)
(hφ : 0 < LinearMap.det (φ.toLinearEquiv : E →ₗ[ℝ] E)) (x y : E) :
o.areaForm (φ x) (φ y) = o.areaForm x y := by
convert o.areaForm_map φ (φ x) (φ y)
· symm
rwa [← o.map_eq_iff_det_pos φ.toLinearEquiv] at hφ
rw [@Fact.out (finrank ℝ E = 2), Fintype.card_fin]
· simp
· simp
/-- Auxiliary construction for `Orientation.rightAngleRotation`, rotation by 90 degrees in an
oriented real inner product space of dimension 2. -/
irreducible_def rightAngleRotationAux₁ : E →ₗ[ℝ] E :=
let to_dual : E ≃ₗ[ℝ] E →ₗ[ℝ] ℝ :=
(InnerProductSpace.toDual ℝ E).toLinearEquiv ≪≫ₗ LinearMap.toContinuousLinearMap.symm
↑to_dual.symm ∘ₗ ω
@[simp]
theorem inner_rightAngleRotationAux₁_left (x y : E) : ⟪o.rightAngleRotationAux₁ x, y⟫ = ω x y := by
simp only [rightAngleRotationAux₁, LinearEquiv.trans_symm, LinearEquiv.symm_symm,
LinearMap.coe_comp, LinearEquiv.coe_coe, Function.comp_apply, LinearEquiv.trans_apply,
LinearIsometryEquiv.coe_symm_toLinearEquiv]
rw [InnerProductSpace.toDual_symm_apply]
norm_cast
@[simp]
theorem inner_rightAngleRotationAux₁_right (x y : E) :
⟪x, o.rightAngleRotationAux₁ y⟫ = -ω x y := by
rw [real_inner_comm]
simp [o.areaForm_swap y x]
/-- Auxiliary construction for `Orientation.rightAngleRotation`, rotation by 90 degrees in an
oriented real inner product space of dimension 2. -/
def rightAngleRotationAux₂ : E →ₗᵢ[ℝ] E :=
{ o.rightAngleRotationAux₁ with
norm_map' := fun x => by
refine le_antisymm ?_ ?_
· rcases eq_or_lt_of_le (norm_nonneg (o.rightAngleRotationAux₁ x)) with h | h
· rw [← h]
positivity
refine le_of_mul_le_mul_right ?_ h
rw [← real_inner_self_eq_norm_mul_norm, o.inner_rightAngleRotationAux₁_left]
exact o.areaForm_le x (o.rightAngleRotationAux₁ x)
· let K : Submodule ℝ E := ℝ ∙ x
have : Nontrivial Kᗮ := by
apply nontrivial_of_finrank_pos (R := ℝ)
have : finrank ℝ K ≤ Finset.card {x} := by
rw [← Set.toFinset_singleton]
exact finrank_span_le_card ({x} : Set E)
have : Finset.card {x} = 1 := Finset.card_singleton x
have : finrank ℝ K + finrank ℝ Kᗮ = finrank ℝ E := K.finrank_add_finrank_orthogonal
have : finrank ℝ E = 2 := Fact.out
omega
obtain ⟨w, hw₀⟩ : ∃ w : Kᗮ, w ≠ 0 := exists_ne 0
have hw' : ⟪x, (w : E)⟫ = 0 := Submodule.mem_orthogonal_singleton_iff_inner_right.mp w.2
have hw : (w : E) ≠ 0 := fun h => hw₀ (Submodule.coe_eq_zero.mp h)
refine le_of_mul_le_mul_right ?_ (by rwa [norm_pos_iff] : 0 < ‖(w : E)‖)
rw [← o.abs_areaForm_of_orthogonal hw']
rw [← o.inner_rightAngleRotationAux₁_left x w]
exact abs_real_inner_le_norm (o.rightAngleRotationAux₁ x) w }
@[simp]
theorem rightAngleRotationAux₁_rightAngleRotationAux₁ (x : E) :
o.rightAngleRotationAux₁ (o.rightAngleRotationAux₁ x) = -x := by
apply ext_inner_left ℝ
intro y
have : ⟪o.rightAngleRotationAux₁ y, o.rightAngleRotationAux₁ x⟫ = ⟪y, x⟫ :=
LinearIsometry.inner_map_map o.rightAngleRotationAux₂ y x
rw [o.inner_rightAngleRotationAux₁_right, ← o.inner_rightAngleRotationAux₁_left, this,
inner_neg_right]
/-- An isometric automorphism of an oriented real inner product space of dimension 2 (usual notation
`J`). This automorphism squares to -1. We will define rotations in such a way that this
automorphism is equal to rotation by 90 degrees. -/
irreducible_def rightAngleRotation : E ≃ₗᵢ[ℝ] E :=
LinearIsometryEquiv.ofLinearIsometry o.rightAngleRotationAux₂ (-o.rightAngleRotationAux₁)
(by ext; simp [rightAngleRotationAux₂]) (by ext; simp [rightAngleRotationAux₂])
local notation "J" => o.rightAngleRotation
@[simp]
theorem inner_rightAngleRotation_left (x y : E) : ⟪J x, y⟫ = ω x y := by
rw [rightAngleRotation]
exact o.inner_rightAngleRotationAux₁_left x y
@[simp]
theorem inner_rightAngleRotation_right (x y : E) : ⟪x, J y⟫ = -ω x y := by
rw [rightAngleRotation]
exact o.inner_rightAngleRotationAux₁_right x y
@[simp]
theorem rightAngleRotation_rightAngleRotation (x : E) : J (J x) = -x := by
rw [rightAngleRotation]
exact o.rightAngleRotationAux₁_rightAngleRotationAux₁ x
@[simp]
theorem rightAngleRotation_symm :
LinearIsometryEquiv.symm J = LinearIsometryEquiv.trans J (LinearIsometryEquiv.neg ℝ) := by
rw [rightAngleRotation]
exact LinearIsometryEquiv.toLinearIsometry_injective rfl
theorem inner_rightAngleRotation_self (x : E) : ⟪J x, x⟫ = 0 := by simp
theorem inner_rightAngleRotation_swap (x y : E) : ⟪x, J y⟫ = -⟪J x, y⟫ := by simp
theorem inner_rightAngleRotation_swap' (x y : E) : ⟪J x, y⟫ = -⟪x, J y⟫ := by
simp [o.inner_rightAngleRotation_swap x y]
theorem inner_comp_rightAngleRotation (x y : E) : ⟪J x, J y⟫ = ⟪x, y⟫ :=
LinearIsometryEquiv.inner_map_map J x y
@[simp]
theorem areaForm_rightAngleRotation_left (x y : E) : ω (J x) y = -⟪x, y⟫ := by
rw [← o.inner_comp_rightAngleRotation, o.inner_rightAngleRotation_right, neg_neg]
@[simp]
theorem areaForm_rightAngleRotation_right (x y : E) : ω x (J y) = ⟪x, y⟫ := by
rw [← o.inner_rightAngleRotation_left, o.inner_comp_rightAngleRotation]
theorem areaForm_comp_rightAngleRotation (x y : E) : ω (J x) (J y) = ω x y := by simp
@[simp]
theorem rightAngleRotation_trans_rightAngleRotation :
LinearIsometryEquiv.trans J J = LinearIsometryEquiv.neg ℝ := by ext; simp
theorem rightAngleRotation_neg_orientation (x : E) :
(-o).rightAngleRotation x = -o.rightAngleRotation x := by
apply ext_inner_right ℝ
intro y
rw [inner_rightAngleRotation_left]
simp
@[simp]
theorem rightAngleRotation_trans_neg_orientation :
(-o).rightAngleRotation = o.rightAngleRotation.trans (LinearIsometryEquiv.neg ℝ) :=
LinearIsometryEquiv.ext <| o.rightAngleRotation_neg_orientation
theorem rightAngleRotation_map {F : Type*} [NormedAddCommGroup F] [InnerProductSpace ℝ F]
[hF : Fact (finrank ℝ F = 2)] (φ : E ≃ₗᵢ[ℝ] F) (x : F) :
(Orientation.map (Fin 2) φ.toLinearEquiv o).rightAngleRotation x =
φ (o.rightAngleRotation (φ.symm x)) := by
apply ext_inner_right ℝ
intro y
rw [inner_rightAngleRotation_left]
trans ⟪J (φ.symm x), φ.symm y⟫
· simp [o.areaForm_map]
trans ⟪φ (J (φ.symm x)), φ (φ.symm y)⟫
· rw [φ.inner_map_map]
· simp
/-- `J` commutes with any positively-oriented isometric automorphism. -/
theorem linearIsometryEquiv_comp_rightAngleRotation (φ : E ≃ₗᵢ[ℝ] E)
(hφ : 0 < LinearMap.det (φ.toLinearEquiv : E →ₗ[ℝ] E)) (x : E) : φ (J x) = J (φ x) := by
convert (o.rightAngleRotation_map φ (φ x)).symm
· simp
· symm
rwa [← o.map_eq_iff_det_pos φ.toLinearEquiv] at hφ
rw [@Fact.out (finrank ℝ E = 2), Fintype.card_fin]
theorem rightAngleRotation_map' {F : Type*} [NormedAddCommGroup F] [InnerProductSpace ℝ F]
[Fact (finrank ℝ F = 2)] (φ : E ≃ₗᵢ[ℝ] F) :
(Orientation.map (Fin 2) φ.toLinearEquiv o).rightAngleRotation =
(φ.symm.trans o.rightAngleRotation).trans φ :=
LinearIsometryEquiv.ext <| o.rightAngleRotation_map φ
/-- `J` commutes with any positively-oriented isometric automorphism. -/
theorem linearIsometryEquiv_comp_rightAngleRotation' (φ : E ≃ₗᵢ[ℝ] E)
(hφ : 0 < LinearMap.det (φ.toLinearEquiv : E →ₗ[ℝ] E)) :
LinearIsometryEquiv.trans J φ = φ.trans J :=
LinearIsometryEquiv.ext <| o.linearIsometryEquiv_comp_rightAngleRotation φ hφ
/-- For a nonzero vector `x` in an oriented two-dimensional real inner product space `E`,
`![x, J x]` forms an (orthogonal) basis for `E`. -/
def basisRightAngleRotation (x : E) (hx : x ≠ 0) : Basis (Fin 2) ℝ E :=
@basisOfLinearIndependentOfCardEqFinrank ℝ _ _ _ _ _ _ _ ![x, J x]
(linearIndependent_of_ne_zero_of_inner_eq_zero (fun i => by fin_cases i <;> simp [hx])
(by
intro i j hij
fin_cases i <;> fin_cases j <;> simp_all))
(@Fact.out (finrank ℝ E = 2)).symm
@[simp]
theorem coe_basisRightAngleRotation (x : E) (hx : x ≠ 0) :
⇑(o.basisRightAngleRotation x hx) = ![x, J x] :=
coe_basisOfLinearIndependentOfCardEqFinrank _ _
/-- For vectors `a x y : E`, the identity `⟪a, x⟫ * ⟪a, y⟫ + ω a x * ω a y = ‖a‖ ^ 2 * ⟪x, y⟫`. (See
`Orientation.inner_mul_inner_add_areaForm_mul_areaForm` for the "applied" form.) -/
theorem inner_mul_inner_add_areaForm_mul_areaForm' (a x : E) :
⟪a, x⟫ • innerₛₗ ℝ a + ω a x • ω a = ‖a‖ ^ 2 • innerₛₗ ℝ x := by
by_cases ha : a = 0
· simp [ha]
apply (o.basisRightAngleRotation a ha).ext
intro i
fin_cases i
· simp [mul_comm, real_inner_comm]
· simp [mul_comm, o.areaForm_swap a x]
/-- For vectors `a x y : E`, the identity `⟪a, x⟫ * ⟪a, y⟫ + ω a x * ω a y = ‖a‖ ^ 2 * ⟪x, y⟫`. -/
theorem inner_mul_inner_add_areaForm_mul_areaForm (a x y : E) :
⟪a, x⟫ * ⟪a, y⟫ + ω a x * ω a y = ‖a‖ ^ 2 * ⟪x, y⟫ :=
congr_arg (fun f : E →ₗ[ℝ] ℝ => f y) (o.inner_mul_inner_add_areaForm_mul_areaForm' a x)
theorem inner_sq_add_areaForm_sq (a b : E) : ⟪a, b⟫ ^ 2 + ω a b ^ 2 = ‖a‖ ^ 2 * ‖b‖ ^ 2 := by
simpa [sq, real_inner_self_eq_norm_sq] using o.inner_mul_inner_add_areaForm_mul_areaForm a b b
/-- For vectors `a x y : E`, the identity `⟪a, x⟫ * ω a y - ω a x * ⟪a, y⟫ = ‖a‖ ^ 2 * ω x y`. (See
`Orientation.inner_mul_areaForm_sub` for the "applied" form.) -/
theorem inner_mul_areaForm_sub' (a x : E) : ⟪a, x⟫ • ω a - ω a x • innerₛₗ ℝ a = ‖a‖ ^ 2 • ω x := by
by_cases ha : a = 0
· simp [ha]
apply (o.basisRightAngleRotation a ha).ext
intro i
fin_cases i
· simp [mul_comm, o.areaForm_swap a x]
· simp [mul_comm, real_inner_comm]
/-- For vectors `a x y : E`, the identity `⟪a, x⟫ * ω a y - ω a x * ⟪a, y⟫ = ‖a‖ ^ 2 * ω x y`. -/
theorem inner_mul_areaForm_sub (a x y : E) : ⟪a, x⟫ * ω a y - ω a x * ⟪a, y⟫ = ‖a‖ ^ 2 * ω x y :=
congr_arg (fun f : E →ₗ[ℝ] ℝ => f y) (o.inner_mul_areaForm_sub' a x)
theorem nonneg_inner_and_areaForm_eq_zero_iff_sameRay (x y : E) :
0 ≤ ⟪x, y⟫ ∧ ω x y = 0 ↔ SameRay ℝ x y := by
by_cases hx : x = 0
· simp [hx]
constructor
· let a : ℝ := (o.basisRightAngleRotation x hx).repr y 0
let b : ℝ := (o.basisRightAngleRotation x hx).repr y 1
suffices ↑0 ≤ a * ‖x‖ ^ 2 ∧ b * ‖x‖ ^ 2 = 0 → SameRay ℝ x (a • x + b • J x) by
rw [← (o.basisRightAngleRotation x hx).sum_repr y]
simp only [Fin.sum_univ_succ, coe_basisRightAngleRotation, Matrix.cons_val_zero,
Fin.succ_zero_eq_one', Finset.univ_eq_empty, Finset.sum_empty, areaForm_apply_self,
map_smul, map_add, real_inner_smul_right, inner_add_right, Matrix.cons_val_one,
Algebra.id.smul_eq_mul, areaForm_rightAngleRotation_right,
mul_zero, add_zero, zero_add, neg_zero, inner_rightAngleRotation_right,
real_inner_self_eq_norm_sq]
exact this
rintro ⟨ha, hb⟩
have hx' : 0 < ‖x‖ := by simpa using hx
have ha' : 0 ≤ a := nonneg_of_mul_nonneg_left ha (by positivity)
have hb' : b = 0 := eq_zero_of_ne_zero_of_mul_right_eq_zero (pow_ne_zero 2 hx'.ne') hb
exact (SameRay.sameRay_nonneg_smul_right x ha').add_right <| by simp [hb']
· intro h
obtain ⟨r, hr, rfl⟩ := h.exists_nonneg_left hx
simp only [inner_smul_right, real_inner_self_eq_norm_sq, LinearMap.map_smulₛₗ,
areaForm_apply_self, Algebra.id.smul_eq_mul, mul_zero, and_true]
positivity
/-- A complex-valued real-bilinear map on an oriented real inner product space of dimension 2. Its
real part is the inner product and its imaginary part is `Orientation.areaForm`.
On `ℂ` with the standard orientation, `kahler w z = conj w * z`; see `Complex.kahler`. -/
def kahler : E →ₗ[ℝ] E →ₗ[ℝ] ℂ :=
LinearMap.llcomp ℝ E ℝ ℂ Complex.ofRealCLM ∘ₗ innerₛₗ ℝ +
LinearMap.llcomp ℝ E ℝ ℂ ((LinearMap.lsmul ℝ ℂ).flip Complex.I) ∘ₗ ω
theorem kahler_apply_apply (x y : E) : o.kahler x y = ⟪x, y⟫ + ω x y • Complex.I :=
rfl
theorem kahler_swap (x y : E) : o.kahler x y = conj (o.kahler y x) := by
simp only [kahler_apply_apply]
rw [real_inner_comm, areaForm_swap]
simp [Complex.conj_ofReal]
@[simp]
theorem kahler_apply_self (x : E) : o.kahler x x = ‖x‖ ^ 2 := by
simp [kahler_apply_apply]
@[simp]
theorem kahler_rightAngleRotation_left (x y : E) :
o.kahler (J x) y = -Complex.I * o.kahler x y := by
simp only [o.areaForm_rightAngleRotation_left, o.inner_rightAngleRotation_left,
o.kahler_apply_apply, Complex.ofReal_neg, Complex.real_smul]
linear_combination ω x y * Complex.I_sq
@[simp]
theorem kahler_rightAngleRotation_right (x y : E) :
o.kahler x (J y) = Complex.I * o.kahler x y := by
simp only [o.areaForm_rightAngleRotation_right, o.inner_rightAngleRotation_right,
o.kahler_apply_apply, Complex.ofReal_neg, Complex.real_smul]
linear_combination -ω x y * Complex.I_sq
-- `simp` normal form is `kahler_comp_rightAngleRotation'`
theorem kahler_comp_rightAngleRotation (x y : E) : o.kahler (J x) (J y) = o.kahler x y := by
simp only [kahler_rightAngleRotation_left, kahler_rightAngleRotation_right]
linear_combination -o.kahler x y * Complex.I_sq
theorem kahler_comp_rightAngleRotation' (x y : E) :
-(Complex.I * (Complex.I * o.kahler x y)) = o.kahler x y := by
linear_combination -o.kahler x y * Complex.I_sq
@[simp]
theorem kahler_neg_orientation (x y : E) : (-o).kahler x y = conj (o.kahler x y) := by
simp [kahler_apply_apply, Complex.conj_ofReal]
theorem kahler_mul (a x y : E) : o.kahler x a * o.kahler a y = ‖a‖ ^ 2 * o.kahler x y := by
trans ((‖a‖ ^ 2 :) : ℂ) * o.kahler x y
· apply Complex.ext
· simp only [o.kahler_apply_apply, Complex.add_im, Complex.add_re, Complex.I_im, Complex.I_re,
Complex.mul_im, Complex.mul_re, Complex.ofReal_im, Complex.ofReal_re, Complex.real_smul]
rw [real_inner_comm a x, o.areaForm_swap x a]
linear_combination o.inner_mul_inner_add_areaForm_mul_areaForm a x y
· simp only [o.kahler_apply_apply, Complex.add_im, Complex.add_re, Complex.I_im, Complex.I_re,
Complex.mul_im, Complex.mul_re, Complex.ofReal_im, Complex.ofReal_re, Complex.real_smul]
rw [real_inner_comm a x, o.areaForm_swap x a]
linear_combination o.inner_mul_areaForm_sub a x y
· norm_cast
theorem normSq_kahler (x y : E) : Complex.normSq (o.kahler x y) = ‖x‖ ^ 2 * ‖y‖ ^ 2 := by
simpa [kahler_apply_apply, Complex.normSq, sq] using o.inner_sq_add_areaForm_sq x y
theorem norm_kahler (x y : E) : ‖o.kahler x y‖ = ‖x‖ * ‖y‖ := by
rw [← sq_eq_sq₀, Complex.sq_norm]
· linear_combination o.normSq_kahler x y
· positivity
· positivity
theorem eq_zero_or_eq_zero_of_kahler_eq_zero {x y : E} (hx : o.kahler x y = 0) : x = 0 ∨ y = 0 := by
have : ‖x‖ * ‖y‖ = 0 := by simpa [hx] using (o.norm_kahler x y).symm
rcases eq_zero_or_eq_zero_of_mul_eq_zero this with h | h
· left
simpa using h
· right
simpa using h
theorem kahler_eq_zero_iff (x y : E) : o.kahler x y = 0 ↔ x = 0 ∨ y = 0 := by
refine ⟨o.eq_zero_or_eq_zero_of_kahler_eq_zero, ?_⟩
rintro (rfl | rfl) <;> simp
theorem kahler_ne_zero {x y : E} (hx : x ≠ 0) (hy : y ≠ 0) : o.kahler x y ≠ 0 := by
apply mt o.eq_zero_or_eq_zero_of_kahler_eq_zero
tauto
theorem kahler_ne_zero_iff (x y : E) : o.kahler x y ≠ 0 ↔ x ≠ 0 ∧ y ≠ 0 := by
refine ⟨?_, fun h => o.kahler_ne_zero h.1 h.2⟩
contrapose
simp only [not_and_or, Classical.not_not, kahler_apply_apply, Complex.real_smul]
rintro (rfl | rfl) <;> simp
theorem kahler_map {F : Type*} [NormedAddCommGroup F] [InnerProductSpace ℝ F]
[hF : Fact (finrank ℝ F = 2)] (φ : E ≃ₗᵢ[ℝ] F) (x y : F) :
(Orientation.map (Fin 2) φ.toLinearEquiv o).kahler x y = o.kahler (φ.symm x) (φ.symm y) := by
simp [kahler_apply_apply, areaForm_map]
/-- The bilinear map `kahler` is invariant under pullback by a positively-oriented isometric
automorphism. -/
theorem kahler_comp_linearIsometryEquiv (φ : E ≃ₗᵢ[ℝ] E)
(hφ : 0 < LinearMap.det (φ.toLinearEquiv : E →ₗ[ℝ] E)) (x y : E) :
o.kahler (φ x) (φ y) = o.kahler x y := by
simp [kahler_apply_apply, o.areaForm_comp_linearIsometryEquiv φ hφ]
end Orientation
namespace Complex
attribute [local instance] Complex.finrank_real_complex_fact
@[simp]
protected theorem areaForm (w z : ℂ) : Complex.orientation.areaForm w z = (conj w * z).im := by
let o := Complex.orientation
simp only [o, o.areaForm_to_volumeForm,
o.volumeForm_robust Complex.orthonormalBasisOneI rfl, Basis.det_apply, Matrix.det_fin_two,
Basis.toMatrix_apply, toBasis_orthonormalBasisOneI, Matrix.cons_val_zero, coe_basisOneI_repr,
Matrix.cons_val_one, mul_im, conj_re, conj_im]
ring
@[simp]
protected theorem rightAngleRotation (z : ℂ) :
Complex.orientation.rightAngleRotation z = I * z := by
apply ext_inner_right ℝ
intro w
rw [Orientation.inner_rightAngleRotation_left]
simp only [Complex.areaForm, Complex.inner, mul_re, mul_im, conj_re, conj_im, map_mul, conj_I,
neg_re, neg_im, I_re, I_im]
ring
@[simp]
protected theorem kahler (w z : ℂ) : Complex.orientation.kahler w z = z * conj w := by
rw [Orientation.kahler_apply_apply]
apply Complex.ext <;> simp [mul_comm]
end Complex
namespace Orientation
local notation "ω" => o.areaForm
local notation "J" => o.rightAngleRotation
open Complex
/-- The area form on an oriented real inner product space of dimension 2 can be evaluated in terms
of a complex-number representation of the space. -/
theorem areaForm_map_complex (f : E ≃ₗᵢ[ℝ] ℂ)
(hf : Orientation.map (Fin 2) f.toLinearEquiv o = Complex.orientation) (x y : E) :
ω x y = (conj (f x) * f y).im := by
rw [← Complex.areaForm, ← hf, areaForm_map]
iterate 2 rw [LinearIsometryEquiv.symm_apply_apply]
/-- The rotation by 90 degrees on an oriented real inner product space of dimension 2 can be
evaluated in terms of a complex-number representation of the space. -/
theorem rightAngleRotation_map_complex (f : E ≃ₗᵢ[ℝ] ℂ)
(hf : Orientation.map (Fin 2) f.toLinearEquiv o = Complex.orientation) (x : E) :
f (J x) = I * f x := by
rw [← Complex.rightAngleRotation, ← hf, rightAngleRotation_map,
LinearIsometryEquiv.symm_apply_apply]
/-- The Kahler form on an oriented real inner product space of dimension 2 can be evaluated in terms
of a complex-number representation of the space. -/
theorem kahler_map_complex (f : E ≃ₗᵢ[ℝ] ℂ)
(hf : Orientation.map (Fin 2) f.toLinearEquiv o = Complex.orientation) (x y : E) :
o.kahler x y = f y * conj (f x) := by
rw [← Complex.kahler, ← hf, kahler_map]
iterate 2 rw [LinearIsometryEquiv.symm_apply_apply]
end Orientation |
.lake/packages/mathlib/Mathlib/Analysis/InnerProductSpace/Completion.lean | import Mathlib.Analysis.InnerProductSpace.LinearMap
import Mathlib.Analysis.Normed.Module.Completion
/-!
# Completion of an inner product space
We show that the separation quotient and the completion of an inner product space are inner
product spaces.
-/
noncomputable section
variable {𝕜 E F : Type*} [RCLike 𝕜]
local notation "⟪" x ", " y "⟫" => inner 𝕜 x y
section SeparationQuotient
variable [SeminormedAddCommGroup E] [InnerProductSpace 𝕜 E]
theorem Inseparable.inner_eq_inner {x₁ x₂ y₁ y₂ : E}
(hx : Inseparable x₁ x₂) (hy : Inseparable y₁ y₂) :
⟪x₁, y₁⟫ = ⟪x₂, y₂⟫ :=
((hx.prod hy).map continuous_inner).eq
namespace SeparationQuotient
instance : Inner 𝕜 (SeparationQuotient E) where
inner := SeparationQuotient.lift₂ (inner 𝕜) fun _ _ _ _ => Inseparable.inner_eq_inner
@[simp]
theorem inner_mk_mk (x y : E) :
⟪mk x, mk y⟫ = ⟪x, y⟫ := rfl
instance : InnerProductSpace 𝕜 (SeparationQuotient E) where
norm_sq_eq_re_inner := Quotient.ind norm_sq_eq_re_inner
conj_inner_symm := Quotient.ind₂ inner_conj_symm
add_left := Quotient.ind fun x => Quotient.ind₂ <| inner_add_left x
smul_left := Quotient.ind₂ inner_smul_left
end SeparationQuotient
end SeparationQuotient
section UniformSpace.Completion
variable [SeminormedAddCommGroup E] [InnerProductSpace 𝕜 E]
namespace UniformSpace.Completion
open RCLike Function
instance toInner {𝕜' E' : Type*} [TopologicalSpace 𝕜'] [UniformSpace E'] [Inner 𝕜' E'] :
Inner 𝕜' (Completion E') where
inner := curry <| (isDenseInducing_coe.prodMap isDenseInducing_coe).extend (uncurry (inner 𝕜'))
@[simp]
theorem inner_coe (a b : E) : ⟪(a : Completion E), (b : Completion E)⟫ = ⟪a, b⟫ :=
(isDenseInducing_coe.prodMap isDenseInducing_coe).extend_eq
(continuous_inner : Continuous (uncurry (inner 𝕜))) (a, b)
protected theorem continuous_inner :
Continuous (uncurry (inner 𝕜 (E := Completion E))) := by
let inner' : E →+ E →+ 𝕜 :=
{ toFun := fun x => (innerₛₗ 𝕜 x).toAddMonoidHom
map_zero' := by ext x; exact inner_zero_left _
map_add' := fun x y => by ext z; exact inner_add_left _ _ _ }
have : Continuous fun p : E × E => inner' p.1 p.2 := continuous_inner
rw [Completion.toInner, inner, uncurry_curry _]
change
Continuous
(((isDenseInducing_toCompl E).prodMap (isDenseInducing_toCompl E)).extend fun p : E × E =>
inner' p.1 p.2)
exact (isDenseInducing_toCompl E).extend_Z_bilin (isDenseInducing_toCompl E) this
@[fun_prop]
protected theorem Continuous.inner {α : Type*} [TopologicalSpace α] {f g : α → Completion E}
(hf : Continuous f) (hg : Continuous g) : Continuous (fun x : α => ⟪f x, g x⟫) :=
UniformSpace.Completion.continuous_inner.comp (hf.prodMk hg :)
instance innerProductSpace : InnerProductSpace 𝕜 (Completion E) where
norm_sq_eq_re_inner x :=
Completion.induction_on x (isClosed_eq (by fun_prop) (by fun_prop))
fun a => by simp only [norm_coe, inner_coe, inner_self_eq_norm_sq]
conj_inner_symm x y :=
Completion.induction_on₂ x y
(isClosed_eq (continuous_conj.comp (by fun_prop)) (by fun_prop))
fun a b => by simp only [inner_coe, inner_conj_symm]
add_left x y z :=
Completion.induction_on₃ x y z (isClosed_eq (by fun_prop) (by fun_prop))
fun a b c => by simp only [← coe_add, inner_coe, inner_add_left]
smul_left x y c :=
Completion.induction_on₂ x y
(isClosed_eq (Continuous.inner (continuous_fst.const_smul c) continuous_snd)
((continuous_mul_left _).comp (by fun_prop)))
fun a b => by simp only [← coe_smul c a, inner_coe, inner_smul_left]
end UniformSpace.Completion
end UniformSpace.Completion |
.lake/packages/mathlib/Mathlib/Analysis/InnerProductSpace/StarOrder.lean | import Mathlib.Analysis.InnerProductSpace.Positive
import Mathlib.Analysis.CStarAlgebra.ContinuousFunctionalCalculus.Basic
import Mathlib.Analysis.CStarAlgebra.ContinuousLinearMap
/-!
# Continuous linear maps on a Hilbert space are a `StarOrderedRing`
In this file we show that the continuous linear maps on a complex Hilbert space form a
`StarOrderedRing`. Note that they are already equipped with the Loewner partial order. We also
prove that, with respect to this partial order, a map is positive if every element of the
real spectrum is nonnegative. Consequently, when `H` is a Hilbert space, then `H →L[ℂ] H` is
equipped with all the usual instances of the continuous functional calculus.
-/
namespace ContinuousLinearMap
open RCLike
open scoped NNReal
variable {𝕜 H : Type*} [RCLike 𝕜] [NormedAddCommGroup H] [InnerProductSpace 𝕜 H] [CompleteSpace H]
variable [Algebra ℝ (H →L[𝕜] H)] [IsScalarTower ℝ 𝕜 (H →L[𝕜] H)]
open scoped InnerProductSpace in
lemma IsPositive.spectrumRestricts {f : H →L[𝕜] H} (hf : f.IsPositive) :
SpectrumRestricts f ContinuousMap.realToNNReal := by
rw [SpectrumRestricts.nnreal_iff]
intro c hc
contrapose! hc
rw [spectrum.notMem_iff, IsUnit.sub_iff, sub_eq_add_neg, ← map_neg]
rw [← neg_pos] at hc
set c := -c
exact isUnit_of_forall_le_norm_inner_map _ (c := ⟨c, hc.le⟩) hc fun x ↦ calc
‖x‖ ^ 2 * c = re ⟪algebraMap ℝ (H →L[𝕜] H) c x, x⟫_𝕜 := by
rw [Algebra.algebraMap_eq_smul_one, ← algebraMap_smul 𝕜 c (1 : (H →L[𝕜] H)), coe_smul',
Pi.smul_apply, one_apply, inner_smul_left, RCLike.algebraMap_eq_ofReal, conj_ofReal,
re_ofReal_mul, inner_self_eq_norm_sq, mul_comm]
_ ≤ re ⟪(f + (algebraMap ℝ (H →L[𝕜] H)) c) x, x⟫_𝕜 := by
simpa only [add_apply, inner_add_left, map_add, le_add_iff_nonneg_left]
using hf.re_inner_nonneg_left x
_ ≤ ‖⟪(f + (algebraMap ℝ (H →L[𝕜] H)) c) x, x⟫_𝕜‖ := RCLike.re_le_norm _
instance : NonnegSpectrumClass ℝ (H →L[𝕜] H) where
quasispectrum_nonneg_of_nonneg f hf :=
QuasispectrumRestricts.nnreal_iff.mp <| sub_zero f ▸ hf.spectrumRestricts
/-- Because this takes `ContinuousFunctionalCalculus ℝ (H →L[𝕜] H) IsSelfAdjoint` as an argument,
and for the moment we only have this for `𝕜 := ℂ`, this is not registered as an instance. -/
lemma instStarOrderedRingRCLike
[ContinuousFunctionalCalculus ℝ (H →L[𝕜] H) IsSelfAdjoint] :
StarOrderedRing (H →L[𝕜] H) where
le_iff f g := by
constructor
· intro h
rw [le_def] at h
obtain ⟨p, hp₁, -, hp₃⟩ := CFC.exists_sqrt_of_isSelfAdjoint_of_quasispectrumRestricts
h.isSelfAdjoint h.spectrumRestricts
refine ⟨p ^ 2, ?_, by symm; rwa [add_comm, ← eq_sub_iff_add_eq]⟩
exact AddSubmonoid.subset_closure ⟨p, by simp only [hp₁.star_eq, sq]⟩
· rintro ⟨p, hp, rfl⟩
rw [le_def, add_sub_cancel_left]
induction hp using AddSubmonoid.closure_induction with
| mem _ hf =>
obtain ⟨f, rfl⟩ := hf
simpa using ContinuousLinearMap.IsPositive.adjoint_conj isPositive_one f
| zero => exact isPositive_zero
| add f g _ _ hf hg => exact hf.add hg
instance instStarOrderedRing {H : Type*} [NormedAddCommGroup H]
[InnerProductSpace ℂ H] [CompleteSpace H] : StarOrderedRing (H →L[ℂ] H) :=
instStarOrderedRingRCLike
end ContinuousLinearMap |
.lake/packages/mathlib/Mathlib/Analysis/InnerProductSpace/Laplacian.lean | import Mathlib.Analysis.Calculus.ContDiff.Basic
import Mathlib.Analysis.Calculus.ContDiff.Operations
import Mathlib.Analysis.Calculus.IteratedDeriv.Defs
import Mathlib.Analysis.InnerProductSpace.CanonicalTensor
/-!
# The Laplacian
This file defines the Laplacian for functions `f : E → F` on real, finite-dimensional, inner product
spaces `E`. In essence, we define the Laplacian of `f` as the second derivative, applied to the
canonical covariant tensor of `E`, as defined and discussed in
`Mathlib.Analysis.InnerProductSpace.CanonicalTensor`.
We show that the Laplacian is `ℝ`-linear on continuously differentiable functions, and establish the
standard formula for computing the Laplacian in terms of orthonormal bases of `E`.
-/
open Filter TensorProduct Topology
section secondDerivativeAPI
/-!
## Supporting API
The definition of the Laplacian of a function `f : E → F` involves the notion of the second
derivative, which can be seen as a continuous multilinear map `ContinuousMultilinearMap 𝕜 (fun (i :
Fin 2) ↦ E) F`, a bilinear map `E →ₗ[𝕜] E →ₗ[𝕜] F`, or a linear map on tensors `E ⊗[𝕜] E →ₗ[𝕜]
F`. This section provides convenience API to convert between these notions.
-/
variable
{𝕜 : Type*} [NontriviallyNormedField 𝕜]
{E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E]
{F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F]
{G : Type*} [NormedAddCommGroup G] [NormedSpace 𝕜 G]
variable (𝕜) in
/--
Convenience reformulation of the second iterated derivative, as a map from `E` to bilinear maps
`E →ₗ[ℝ] E →ₗ[ℝ] ℝ`.
-/
noncomputable def bilinearIteratedFDerivWithinTwo (f : E → F) (s : Set E) : E → E →ₗ[𝕜] E →ₗ[𝕜] F :=
fun x ↦ (fderivWithin 𝕜 (fderivWithin 𝕜 f s) s x).toLinearMap₁₂
variable (𝕜) in
/--
Convenience reformulation of the second iterated derivative, as a map from `E` to bilinear maps
`E →ₗ[ℝ] E →ₗ[ℝ] ℝ`.
-/
noncomputable def bilinearIteratedFDerivTwo (f : E → F) : E → E →ₗ[𝕜] E →ₗ[𝕜] F :=
fun x ↦ (fderiv 𝕜 (fderiv 𝕜 f) x).toLinearMap₁₂
/--
Expression of `bilinearIteratedFDerivWithinTwo` in terms of `iteratedFDerivWithin`.
-/
lemma bilinearIteratedFDerivWithinTwo_eq_iteratedFDeriv {e : E} {s : Set E} (f : E → F)
(hs : UniqueDiffOn 𝕜 s) (he : e ∈ s) (e₁ e₂ : E) :
bilinearIteratedFDerivWithinTwo 𝕜 f s e e₁ e₂ = iteratedFDerivWithin 𝕜 2 f s e ![e₁, e₂] := by
simp [iteratedFDerivWithin_two_apply f hs he ![e₁, e₂], bilinearIteratedFDerivWithinTwo]
/--
Expression of `bilinearIteratedFDerivTwo` in terms of `iteratedFDeriv`.
-/
lemma bilinearIteratedFDerivTwo_eq_iteratedFDeriv (f : E → F) (e e₁ e₂ : E) :
bilinearIteratedFDerivTwo 𝕜 f e e₁ e₂ = iteratedFDeriv 𝕜 2 f e ![e₁, e₂] := by
simp [iteratedFDeriv_two_apply f e ![e₁, e₂], bilinearIteratedFDerivTwo]
variable (𝕜) in
/--
Convenience reformulation of the second iterated derivative, as a map from `E` to linear maps
`E ⊗[𝕜] E →ₗ[𝕜] F`.
-/
noncomputable def tensorIteratedFDerivWithinTwo (f : E → F) (s : Set E) : E → E ⊗[𝕜] E →ₗ[𝕜] F :=
fun e ↦ lift (bilinearIteratedFDerivWithinTwo 𝕜 f s e)
variable (𝕜) in
/--
Convenience reformulation of the second iterated derivative, as a map from `E` to linear maps
`E ⊗[𝕜] E →ₗ[𝕜] F`.
-/
noncomputable def tensorIteratedFDerivTwo (f : E → F) : E → E ⊗[𝕜] E →ₗ[𝕜] F :=
fun e ↦ lift (bilinearIteratedFDerivTwo 𝕜 f e)
/--
Expression of `tensorIteratedFDerivTwo` in terms of `iteratedFDerivWithin`.
-/
lemma tensorIteratedFDerivWithinTwo_eq_iteratedFDerivWithin {e : E} {s : Set E} (f : E → F)
(hs : UniqueDiffOn 𝕜 s) (he : e ∈ s) (e₁ e₂ : E) :
tensorIteratedFDerivWithinTwo 𝕜 f s e (e₁ ⊗ₜ[𝕜] e₂) =
iteratedFDerivWithin 𝕜 2 f s e ![e₁, e₂] := by
rw [← bilinearIteratedFDerivWithinTwo_eq_iteratedFDeriv f hs he, tensorIteratedFDerivWithinTwo,
lift.tmul]
/--
Expression of `tensorIteratedFDerivTwo` in terms of `iteratedFDeriv`.
-/
lemma tensorIteratedFDerivTwo_eq_iteratedFDeriv (f : E → F) (e e₁ e₂ : E) :
tensorIteratedFDerivTwo 𝕜 f e (e₁ ⊗ₜ[𝕜] e₂) = iteratedFDeriv 𝕜 2 f e ![e₁, e₂] := by
rw [← bilinearIteratedFDerivTwo_eq_iteratedFDeriv, tensorIteratedFDerivTwo, lift.tmul]
end secondDerivativeAPI
/-!
## Definition of the Laplacian
-/
variable
{E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E]
{F : Type*} [NormedAddCommGroup F] [NormedSpace ℝ F]
{G : Type*} [NormedAddCommGroup G] [NormedSpace ℝ G]
{f f₁ f₂ : E → F} {x : E} {s : Set E}
namespace InnerProductSpace
variable (f s) in
/--
Laplacian for functions on real inner product spaces, with respect to a set `s`. Use `open
InnerProductSpace` to access the notation `Δ[s]` for `InnerProductSpace.LaplacianWithin`.
-/
noncomputable def laplacianWithin : E → F :=
fun x ↦ tensorIteratedFDerivWithinTwo ℝ f s x (InnerProductSpace.canonicalCovariantTensor E)
@[inherit_doc]
scoped[InnerProductSpace] notation "Δ[" s "]" f:60 => laplacianWithin f s
variable (f) in
/--
Laplacian for functions on real inner product spaces. Use `open InnerProductSpace` to access the
notation `Δ` for `InnerProductSpace.Laplacian`.
-/
noncomputable def laplacian : E → F :=
fun x ↦ tensorIteratedFDerivTwo ℝ f x (InnerProductSpace.canonicalCovariantTensor E)
@[inherit_doc]
scoped[InnerProductSpace] notation "Δ" => laplacian
/--
The Laplacian equals the Laplacian with respect to `Set.univ`.
-/
@[simp]
theorem laplacianWithin_univ :
Δ[(Set.univ : Set E)] f = Δ f := by
ext x
simp [laplacian, tensorIteratedFDerivTwo, bilinearIteratedFDerivTwo,
laplacianWithin, tensorIteratedFDerivWithinTwo, bilinearIteratedFDerivWithinTwo]
/-!
## Computation of Δ in Terms of Orthonormal Bases
-/
variable (f) in
/--
Standard formula, computing the Laplacian from any orthonormal basis.
-/
theorem laplacianWithin_eq_iteratedFDerivWithin_orthonormalBasis {ι : Type*} [Fintype ι] {e : E}
(hs : UniqueDiffOn ℝ s) (he : e ∈ s) (v : OrthonormalBasis ι ℝ E) :
(Δ[s] f) e = ∑ i, iteratedFDerivWithin ℝ 2 f s e ![v i, v i] := by
simp [InnerProductSpace.laplacianWithin, canonicalCovariantTensor_eq_sum E v,
tensorIteratedFDerivWithinTwo_eq_iteratedFDerivWithin f hs he]
variable (f) in
/--
Standard formula, computing the Laplacian from any orthonormal basis.
-/
theorem laplacian_eq_iteratedFDeriv_orthonormalBasis {ι : Type*} [Fintype ι]
(v : OrthonormalBasis ι ℝ E) :
Δ f = fun x ↦ ∑ i, iteratedFDeriv ℝ 2 f x ![v i, v i] := by
ext x
simp [InnerProductSpace.laplacian, canonicalCovariantTensor_eq_sum E v,
tensorIteratedFDerivTwo_eq_iteratedFDeriv]
variable (f) in
/--
Standard formula, computing the Laplacian from the standard orthonormal basis of a real inner
product space.
-/
theorem laplacianWithin_eq_iteratedFDerivWithin_stdOrthonormalBasis {e : E} (hs : UniqueDiffOn ℝ s)
(he : e ∈ s) :
(Δ[s] f) e = ∑ i, iteratedFDerivWithin ℝ 2 f s e
![(stdOrthonormalBasis ℝ E) i, (stdOrthonormalBasis ℝ E) i] := by
apply laplacianWithin_eq_iteratedFDerivWithin_orthonormalBasis f hs he (stdOrthonormalBasis ℝ E)
variable (f) in
/--
Standard formula, computing the Laplacian from the standard orthonormal basis of a real inner
product space.
-/
theorem laplacian_eq_iteratedFDeriv_stdOrthonormalBasis :
Δ f = fun x ↦
∑ i, iteratedFDeriv ℝ 2 f x ![(stdOrthonormalBasis ℝ E) i, (stdOrthonormalBasis ℝ E) i] :=
laplacian_eq_iteratedFDeriv_orthonormalBasis f (stdOrthonormalBasis ℝ E)
/-- For a function on `ℝ`, the Laplacian is the second derivative: version within a set. -/
theorem laplacianWithin_eq_iteratedDerivWithin_real {e : ℝ} {s : Set ℝ} (f : ℝ → F)
(hs : UniqueDiffOn ℝ s) (he : e ∈ s) :
(Δ[s] f) e = iteratedDerivWithin 2 f s e := by
simp only [laplacianWithin_eq_iteratedFDerivWithin_orthonormalBasis f hs he
(OrthonormalBasis.singleton (Fin 1) ℝ),
Finset.univ_unique, Fin.default_eq_zero, Fin.isValue, OrthonormalBasis.singleton_apply,
Finset.sum_const, Finset.card_singleton, one_smul, iteratedDerivWithin_eq_iteratedFDerivWithin]
congr with i
fin_cases i <;> simp
/-- For a function on `ℝ`, the Laplacian is the second derivative. -/
@[simp]
theorem laplacian_eq_iteratedDeriv_real {e : ℝ} (f : ℝ → F) :
Δ f e = iteratedDeriv 2 f e := by
rw [← laplacianWithin_univ, ← iteratedDerivWithin_univ,
laplacianWithin_eq_iteratedDerivWithin_real _ (by simp) (by simp)]
/--
Special case of the standard formula for functions on `ℂ`, with the standard real inner product
structure.
-/
theorem laplacianWithin_eq_iteratedFDerivWithin_complexPlane {e : ℂ} {s : Set ℂ} (f : ℂ → F)
(hs : UniqueDiffOn ℝ s) (he : e ∈ s) :
(Δ[s] f) e = iteratedFDerivWithin ℝ 2 f s e ![1, 1]
+ iteratedFDerivWithin ℝ 2 f s e ![Complex.I, Complex.I] := by
simp [laplacianWithin_eq_iteratedFDerivWithin_orthonormalBasis f hs he
Complex.orthonormalBasisOneI]
/--
Special case of the standard formula for functions on `ℂ`, with the standard real inner product
structure.
-/
theorem laplacian_eq_iteratedFDeriv_complexPlane (f : ℂ → F) :
Δ f = fun x ↦
iteratedFDeriv ℝ 2 f x ![1, 1] + iteratedFDeriv ℝ 2 f x ![Complex.I, Complex.I] := by
simp [laplacian_eq_iteratedFDeriv_orthonormalBasis f Complex.orthonormalBasisOneI]
/-!
## Congruence Lemmata for Δ
-/
/--
If two functions agree in a neighborhood of a point, then so do their Laplacians.
-/
theorem laplacianWithin_congr_nhdsWithin (h : f₁ =ᶠ[𝓝[s] x] f₂) (hs : UniqueDiffOn ℝ s) :
Δ[s] f₁ =ᶠ[𝓝[s] x] Δ[s] f₂ := by
filter_upwards [EventuallyEq.iteratedFDerivWithin (𝕜 := ℝ) h 2,
eventually_mem_nhdsWithin] with x h₁x h₂x
simp [laplacianWithin_eq_iteratedFDerivWithin_stdOrthonormalBasis _ hs h₂x, h₁x]
/--
If two functions agree in a neighborhood of a point, then so do their Laplacians.
-/
theorem laplacian_congr_nhds (h : f₁ =ᶠ[𝓝 x] f₂) :
Δ f₁ =ᶠ[𝓝 x] Δ f₂ := by
filter_upwards [EventuallyEq.iteratedFDeriv ℝ h 2] with x hx
simp [laplacian_eq_iteratedFDeriv_stdOrthonormalBasis, hx]
/-!
## ℝ-Linearity of Δ on Continuously Differentiable Functions
-/
/-- The Laplacian commutes with addition. -/
theorem _root_.ContDiffWithinAt.laplacianWithin_add (h₁ : ContDiffWithinAt ℝ 2 f₁ s x)
(h₂ : ContDiffWithinAt ℝ 2 f₂ s x) (hs : UniqueDiffOn ℝ s) (hx : x ∈ s) :
(Δ[s] (f₁ + f₂)) x = (Δ[s] f₁) x + (Δ[s] f₂) x := by
simp [laplacianWithin_eq_iteratedFDerivWithin_stdOrthonormalBasis _ hs hx,
← Finset.sum_add_distrib, iteratedFDerivWithin_add_apply h₁ h₂ hs hx]
/-- The Laplacian commutes with addition. -/
theorem _root_.ContDiffAt.laplacian_add (h₁ : ContDiffAt ℝ 2 f₁ x) (h₂ : ContDiffAt ℝ 2 f₂ x) :
Δ (f₁ + f₂) x = Δ f₁ x + Δ f₂ x := by
simp [laplacian_eq_iteratedFDeriv_stdOrthonormalBasis,
← Finset.sum_add_distrib, iteratedFDeriv_add_apply h₁ h₂]
/-- The Laplacian commutes with addition. -/
theorem _root_.ContDiffAt.laplacianWithin_add_nhdsWithin (h₁ : ContDiffWithinAt ℝ 2 f₁ s x)
(h₂ : ContDiffWithinAt ℝ 2 f₂ s x) (hs : UniqueDiffOn ℝ s) (hx : x ∈ s) :
Δ[s] (f₁ + f₂) =ᶠ[𝓝[s] x] (Δ[s] f₁) + Δ[s] f₂ := by
nth_rw 1 [← s.insert_eq_of_mem hx]
filter_upwards [h₁.eventually (by simp), h₂.eventually (by simp),
eventually_mem_nhdsWithin] with y h₁y h₂y h₃y
rw [s.insert_eq_of_mem hx] at h₃y
simp [h₁y.laplacianWithin_add h₂y hs h₃y]
/-- The Laplacian commutes with addition. -/
theorem _root_.ContDiffAt.laplacian_add_nhds (h₁ : ContDiffAt ℝ 2 f₁ x) (h₂ : ContDiffAt ℝ 2 f₂ x) :
Δ (f₁ + f₂) =ᶠ[𝓝 x] (Δ f₁) + (Δ f₂) := by
filter_upwards [h₁.eventually (by simp), h₂.eventually (by simp)] with x h₁x h₂x
exact h₁x.laplacian_add h₂x
/-- The Laplacian commutes with scalar multiplication. -/
theorem laplacianWithin_smul (v : ℝ) (hf : ContDiffWithinAt ℝ 2 f s x) (hs : UniqueDiffOn ℝ s)
(hx : x ∈ s) :
(Δ[s] (v • f)) x = v • (Δ[s] f) x := by
simp [laplacianWithin_eq_iteratedFDerivWithin_stdOrthonormalBasis _ hs hx,
iteratedFDerivWithin_const_smul_apply hf hs hx,
Finset.smul_sum]
/-- The Laplacian commutes with scalar multiplication. -/
theorem laplacian_smul (v : ℝ) (hf : ContDiffAt ℝ 2 f x) : Δ (v • f) x = v • (Δ f) x := by
simp [laplacian_eq_iteratedFDeriv_stdOrthonormalBasis, iteratedFDeriv_const_smul_apply hf,
Finset.smul_sum]
/-- The Laplacian commutes with scalar multiplication. -/
theorem laplacianWithin_smul_nhds
(v : ℝ) (hf : ContDiffWithinAt ℝ 2 f s x) (hs : UniqueDiffOn ℝ s) :
Δ[s] (v • f) =ᶠ[𝓝[s] x] v • (Δ[s] f) := by
filter_upwards [(hf.eventually (by simp)).filter_mono (nhdsWithin_mono _ (Set.subset_insert ..)),
eventually_mem_nhdsWithin] with a h₁a using laplacianWithin_smul v h₁a hs
/-- The Laplacian commutes with scalar multiplication. -/
theorem laplacian_smul_nhds (v : ℝ) (h : ContDiffAt ℝ 2 f x) :
Δ (v • f) =ᶠ[𝓝 x] v • (Δ f) := by
filter_upwards [h.eventually (by simp)] with a ha
simp [laplacian_smul v ha]
/-!
## Commutativity of Δ with Linear Operators
This section establishes commutativity with linear operators, showing in particular that `Δ`
commutes with taking real and imaginary parts of complex-valued functions.
-/
/-- The Laplacian commutes with left composition by continuous linear maps. -/
theorem _root_.ContDiffWithinAt.laplacianWithin_CLM_comp_left {l : F →L[ℝ] G}
(h : ContDiffWithinAt ℝ 2 f s x) (hs : UniqueDiffOn ℝ s) (hx : x ∈ s) :
(Δ[s] (l ∘ f)) x = (l ∘ (Δ[s] f)) x := by
simp [laplacianWithin_eq_iteratedFDerivWithin_stdOrthonormalBasis _ hs hx,
l.iteratedFDerivWithin_comp_left h hs hx]
/-- The Laplacian commutes with left composition by continuous linear maps. -/
theorem _root_.ContDiffAt.laplacian_CLM_comp_left {l : F →L[ℝ] G} (h : ContDiffAt ℝ 2 f x) :
Δ (l ∘ f) x = (l ∘ (Δ f)) x := by
simp [laplacian_eq_iteratedFDeriv_stdOrthonormalBasis, l.iteratedFDeriv_comp_left h]
/-- The Laplacian commutes with left composition by continuous linear maps. -/
theorem _root_.ContDiffWithinAt.laplacianWithin_CLM_comp_left_nhds {l : F →L[ℝ] G}
(h : ContDiffWithinAt ℝ 2 f s x) (hs : UniqueDiffOn ℝ s) :
Δ[s] (l ∘ f) =ᶠ[𝓝[s] x] l ∘ Δ[s] f := by
filter_upwards [(h.eventually (by simp)).filter_mono (nhdsWithin_mono _ (Set.subset_insert ..)),
eventually_mem_nhdsWithin] with a h₁a using h₁a.laplacianWithin_CLM_comp_left hs
/-- The Laplacian commutes with left composition by continuous linear maps. -/
theorem _root_.ContDiffAt.laplacian_CLM_comp_left_nhds {l : F →L[ℝ] G} (h : ContDiffAt ℝ 2 f x) :
Δ (l ∘ f) =ᶠ[𝓝 x] l ∘ (Δ f) := by
filter_upwards [h.eventually (by simp)] with a ha
rw [ha.laplacian_CLM_comp_left]
/-- The Laplacian commutes with left composition by continuous linear equivalences. -/
theorem laplacianWithin_CLE_comp_left {l : F ≃L[ℝ] G} (hs : UniqueDiffOn ℝ s) (hx : x ∈ s) :
(Δ[s] (l ∘ f)) x = (l ∘ (Δ[s] f)) x := by
simp [laplacianWithin_eq_iteratedFDerivWithin_stdOrthonormalBasis _ hs hx,
l.iteratedFDerivWithin_comp_left _ hs hx]
/-- The Laplacian commutes with left composition by continuous linear equivalences. -/
theorem laplacian_CLE_comp_left {l : F ≃L[ℝ] G} :
Δ (l ∘ f) = l ∘ (Δ f) := by
ext x
simp [laplacian_eq_iteratedFDeriv_stdOrthonormalBasis, l.iteratedFDeriv_comp_left]
end InnerProductSpace |
.lake/packages/mathlib/Mathlib/Analysis/InnerProductSpace/Orientation.lean | import Mathlib.Analysis.InnerProductSpace.GramSchmidtOrtho
import Mathlib.LinearAlgebra.Orientation
/-!
# Orientations of real inner product spaces.
This file provides definitions and proves lemmas about orientations of real inner product spaces.
## Main definitions
* `OrthonormalBasis.adjustToOrientation` takes an orthonormal basis and an orientation, and
returns an orthonormal basis with that orientation: either the original orthonormal basis, or one
constructed by negating a single (arbitrary) basis vector.
* `Orientation.finOrthonormalBasis` is an orthonormal basis, indexed by `Fin n`, with the given
orientation.
* `Orientation.volumeForm` is a nonvanishing top-dimensional alternating form on an oriented real
inner product space, uniquely defined by compatibility with the orientation and inner product
structure.
## Main theorems
* `Orientation.volumeForm_apply_le` states that the result of applying the volume form to a set of
`n` vectors, where `n` is the dimension the inner product space, is bounded by the product of the
lengths of the vectors.
* `Orientation.abs_volumeForm_apply_of_pairwise_orthogonal` states that the result of applying the
volume form to a set of `n` orthogonal vectors, where `n` is the dimension the inner product
space, is equal up to sign to the product of the lengths of the vectors.
-/
noncomputable section
variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E]
open Module InnerProductSpace
open scoped RealInnerProductSpace
namespace OrthonormalBasis
variable {ι : Type*} [Fintype ι] [DecidableEq ι] (e f : OrthonormalBasis ι ℝ E)
(x : Orientation ℝ E ι)
/-- The change-of-basis matrix between two orthonormal bases with the same orientation has
determinant 1. -/
theorem det_to_matrix_orthonormalBasis_of_same_orientation
(h : e.toBasis.orientation = f.toBasis.orientation) : e.toBasis.det f = 1 := by
apply (e.det_to_matrix_orthonormalBasis_real f).resolve_right
have : 0 < e.toBasis.det f := by
rw [e.toBasis.orientation_eq_iff_det_pos] at h
simpa using h
linarith
/-- The change-of-basis matrix between two orthonormal bases with the opposite orientations has
determinant -1. -/
theorem det_to_matrix_orthonormalBasis_of_opposite_orientation
(h : e.toBasis.orientation ≠ f.toBasis.orientation) : e.toBasis.det f = -1 := by
contrapose! h
simp [e.toBasis.orientation_eq_iff_det_pos,
(e.det_to_matrix_orthonormalBasis_real f).resolve_right h]
variable {e f}
/-- Two orthonormal bases with the same orientation determine the same "determinant" top-dimensional
form on `E`, and conversely. -/
theorem same_orientation_iff_det_eq_det :
e.toBasis.det = f.toBasis.det ↔ e.toBasis.orientation = f.toBasis.orientation := by
constructor
· intro h
dsimp [Basis.orientation]
congr
· intro h
rw [e.toBasis.det.eq_smul_basis_det f.toBasis]
simp [e.det_to_matrix_orthonormalBasis_of_same_orientation f h]
variable (e f)
/-- Two orthonormal bases with opposite orientations determine opposite "determinant"
top-dimensional forms on `E`. -/
theorem det_eq_neg_det_of_opposite_orientation (h : e.toBasis.orientation ≠ f.toBasis.orientation) :
e.toBasis.det = -f.toBasis.det := by
rw [e.toBasis.det.eq_smul_basis_det f.toBasis]
simp [e.det_to_matrix_orthonormalBasis_of_opposite_orientation f h]
variable [Nonempty ι]
section AdjustToOrientation
/-- `OrthonormalBasis.adjustToOrientation`, applied to an orthonormal basis, preserves the
property of orthonormality. -/
theorem orthonormal_adjustToOrientation : Orthonormal ℝ (e.toBasis.adjustToOrientation x) := by
apply e.orthonormal.orthonormal_of_forall_eq_or_eq_neg
simpa using e.toBasis.adjustToOrientation_apply_eq_or_eq_neg x
/-- Given an orthonormal basis and an orientation, return an orthonormal basis giving that
orientation: either the original basis, or one constructed by negating a single (arbitrary) basis
vector. -/
def adjustToOrientation : OrthonormalBasis ι ℝ E :=
(e.toBasis.adjustToOrientation x).toOrthonormalBasis (e.orthonormal_adjustToOrientation x)
theorem toBasis_adjustToOrientation :
(e.adjustToOrientation x).toBasis = e.toBasis.adjustToOrientation x :=
(e.toBasis.adjustToOrientation x).toBasis_toOrthonormalBasis _
/-- `adjustToOrientation` gives an orthonormal basis with the required orientation. -/
@[simp]
theorem orientation_adjustToOrientation : (e.adjustToOrientation x).toBasis.orientation = x := by
rw [e.toBasis_adjustToOrientation]
exact e.toBasis.orientation_adjustToOrientation x
/-- Every basis vector from `adjustToOrientation` is either that from the original basis or its
negation. -/
theorem adjustToOrientation_apply_eq_or_eq_neg (i : ι) :
e.adjustToOrientation x i = e i ∨ e.adjustToOrientation x i = -e i := by
simpa [← e.toBasis_adjustToOrientation] using
e.toBasis.adjustToOrientation_apply_eq_or_eq_neg x i
theorem det_adjustToOrientation :
(e.adjustToOrientation x).toBasis.det = e.toBasis.det ∨
(e.adjustToOrientation x).toBasis.det = -e.toBasis.det := by
simpa using e.toBasis.det_adjustToOrientation x
theorem abs_det_adjustToOrientation (v : ι → E) :
|(e.adjustToOrientation x).toBasis.det v| = |e.toBasis.det v| := by
simp [toBasis_adjustToOrientation]
end AdjustToOrientation
end OrthonormalBasis
namespace Orientation
variable {n : ℕ}
open OrthonormalBasis
/-- An orthonormal basis, indexed by `Fin n`, with the given orientation. -/
protected def finOrthonormalBasis (hn : 0 < n) (h : finrank ℝ E = n) (x : Orientation ℝ E (Fin n)) :
OrthonormalBasis (Fin n) ℝ E := by
haveI := Fin.pos_iff_nonempty.1 hn
haveI : FiniteDimensional ℝ E := .of_finrank_pos <| h.symm ▸ hn
exact ((@stdOrthonormalBasis _ _ _ _ _ this).reindex <| finCongr h).adjustToOrientation x
/-- `Orientation.finOrthonormalBasis` gives a basis with the required orientation. -/
@[simp]
theorem finOrthonormalBasis_orientation (hn : 0 < n) (h : finrank ℝ E = n)
(x : Orientation ℝ E (Fin n)) : (x.finOrthonormalBasis hn h).toBasis.orientation = x := by
haveI := Fin.pos_iff_nonempty.1 hn
haveI : FiniteDimensional ℝ E := .of_finrank_pos <| h.symm ▸ hn
exact ((@stdOrthonormalBasis _ _ _ _ _ this).reindex <|
finCongr h).orientation_adjustToOrientation x
section VolumeForm
variable [_i : Fact (finrank ℝ E = n)] (o : Orientation ℝ E (Fin n))
/-- The volume form on an oriented real inner product space, a nonvanishing top-dimensional
alternating form uniquely defined by compatibility with the orientation and inner product structure.
-/
irreducible_def volumeForm : E [⋀^Fin n]→ₗ[ℝ] ℝ := by
classical
cases n with
| zero =>
let opos : E [⋀^Fin 0]→ₗ[ℝ] ℝ := .constOfIsEmpty ℝ E (Fin 0) (1 : ℝ)
exact o.eq_or_eq_neg_of_isEmpty.by_cases (fun _ => opos) fun _ => -opos
| succ n => exact (o.finOrthonormalBasis n.succ_pos _i.out).toBasis.det
@[simp]
theorem volumeForm_zero_pos [_i : Fact (finrank ℝ E = 0)] :
Orientation.volumeForm (positiveOrientation : Orientation ℝ E (Fin 0)) =
AlternatingMap.constLinearEquivOfIsEmpty 1 := by
simp [volumeForm, Or.by_cases]
theorem volumeForm_zero_neg [_i : Fact (finrank ℝ E = 0)] :
Orientation.volumeForm (-positiveOrientation : Orientation ℝ E (Fin 0)) =
-AlternatingMap.constLinearEquivOfIsEmpty 1 := by
simp_rw [volumeForm, Or.by_cases, positiveOrientation]
apply if_neg
simp only [neg_rayOfNeZero]
rw [ray_eq_iff, SameRay.sameRay_comm]
intro h
simpa using
congr_arg AlternatingMap.constLinearEquivOfIsEmpty.symm (eq_zero_of_sameRay_self_neg h)
/-- The volume form on an oriented real inner product space can be evaluated as the determinant with
respect to any orthonormal basis of the space compatible with the orientation. -/
theorem volumeForm_robust (b : OrthonormalBasis (Fin n) ℝ E) (hb : b.toBasis.orientation = o) :
o.volumeForm = b.toBasis.det := by
cases n
· classical
have : o = positiveOrientation := hb.symm.trans b.toBasis.orientation_isEmpty
simp_rw [volumeForm, Or.by_cases, dif_pos this, Nat.rec_zero, Basis.det_isEmpty]
· simp_rw [volumeForm]
rw [same_orientation_iff_det_eq_det, hb]
exact o.finOrthonormalBasis_orientation _ _
/-- The volume form on an oriented real inner product space can be evaluated as the determinant with
respect to any orthonormal basis of the space compatible with the orientation. -/
theorem volumeForm_robust_neg (b : OrthonormalBasis (Fin n) ℝ E) (hb : b.toBasis.orientation ≠ o) :
o.volumeForm = -b.toBasis.det := by
rcases n with - | n
· classical
have : positiveOrientation ≠ o := by rwa [b.toBasis.orientation_isEmpty] at hb
simp_rw [volumeForm, Or.by_cases, dif_neg this.symm, Nat.rec_zero, Basis.det_isEmpty]
let e : OrthonormalBasis (Fin n.succ) ℝ E := o.finOrthonormalBasis n.succ_pos Fact.out
simp_rw [volumeForm]
apply e.det_eq_neg_det_of_opposite_orientation b
convert hb.symm
exact o.finOrthonormalBasis_orientation _ _
@[simp]
theorem volumeForm_neg_orientation : (-o).volumeForm = -o.volumeForm := by
rcases n with - | n
· refine o.eq_or_eq_neg_of_isEmpty.elim ?_ ?_ <;> rintro rfl
· simp [volumeForm_zero_neg]
· simp [volumeForm_zero_neg]
let e : OrthonormalBasis (Fin n.succ) ℝ E := o.finOrthonormalBasis n.succ_pos Fact.out
have h₁ : e.toBasis.orientation = o := o.finOrthonormalBasis_orientation _ _
have h₂ : e.toBasis.orientation ≠ -o := by
symm
rw [e.toBasis.orientation_ne_iff_eq_neg, h₁]
rw [o.volumeForm_robust e h₁, (-o).volumeForm_robust_neg e h₂]
theorem volumeForm_robust' (b : OrthonormalBasis (Fin n) ℝ E) (v : Fin n → E) :
|o.volumeForm v| = |b.toBasis.det v| := by
cases n
· refine o.eq_or_eq_neg_of_isEmpty.elim ?_ ?_ <;> rintro rfl <;> simp
· rw [o.volumeForm_robust (b.adjustToOrientation o) (b.orientation_adjustToOrientation o),
b.abs_det_adjustToOrientation]
/-- Let `v` be an indexed family of `n` vectors in an oriented `n`-dimensional real inner
product space `E`. The output of the volume form of `E` when evaluated on `v` is bounded in absolute
value by the product of the norms of the vectors `v i`. -/
theorem abs_volumeForm_apply_le (v : Fin n → E) : |o.volumeForm v| ≤ ∏ i : Fin n, ‖v i‖ := by
rcases n with - | n
· refine o.eq_or_eq_neg_of_isEmpty.elim ?_ ?_ <;> rintro rfl <;> simp
haveI : FiniteDimensional ℝ E := .of_fact_finrank_eq_succ n
have : finrank ℝ E = Fintype.card (Fin n.succ) := by simpa using _i.out
let b : OrthonormalBasis (Fin n.succ) ℝ E := gramSchmidtOrthonormalBasis this v
have hb : b.toBasis.det v = ∏ i, ⟪b i, v i⟫ := gramSchmidtOrthonormalBasis_det this v
rw [o.volumeForm_robust' b, hb, Finset.abs_prod]
apply Finset.prod_le_prod
· intro i _
positivity
intro i _
convert abs_real_inner_le_norm (b i) (v i)
simp [b.orthonormal.1 i]
theorem volumeForm_apply_le (v : Fin n → E) : o.volumeForm v ≤ ∏ i : Fin n, ‖v i‖ :=
(le_abs_self _).trans (o.abs_volumeForm_apply_le v)
/-- Let `v` be an indexed family of `n` orthogonal vectors in an oriented `n`-dimensional
real inner product space `E`. The output of the volume form of `E` when evaluated on `v` is, up to
sign, the product of the norms of the vectors `v i`. -/
theorem abs_volumeForm_apply_of_pairwise_orthogonal {v : Fin n → E}
(hv : Pairwise fun i j => ⟪v i, v j⟫ = 0) : |o.volumeForm v| = ∏ i : Fin n, ‖v i‖ := by
rcases n with - | n
· refine o.eq_or_eq_neg_of_isEmpty.elim ?_ ?_ <;> rintro rfl <;> simp
haveI : FiniteDimensional ℝ E := .of_fact_finrank_eq_succ n
have hdim : finrank ℝ E = Fintype.card (Fin n.succ) := by simpa using _i.out
let b : OrthonormalBasis (Fin n.succ) ℝ E := gramSchmidtOrthonormalBasis hdim v
have hb : b.toBasis.det v = ∏ i, ⟪b i, v i⟫ := gramSchmidtOrthonormalBasis_det hdim v
rw [o.volumeForm_robust' b, hb, Finset.abs_prod]
by_cases! h : ∃ i, v i = 0
· obtain ⟨i, hi⟩ := h
rw [Finset.prod_eq_zero (Finset.mem_univ i), Finset.prod_eq_zero (Finset.mem_univ i)] <;>
simp [hi]
congr
ext i
have hb : b i = ‖v i‖⁻¹ • v i := gramSchmidtOrthonormalBasis_apply_of_orthogonal hdim hv (h i)
simp only [hb, inner_smul_left, real_inner_self_eq_norm_mul_norm, RCLike.conj_to_real]
rw [abs_of_nonneg]
· field
· positivity
/-- The output of the volume form of an oriented real inner product space `E` when evaluated on an
orthonormal basis is ±1. -/
theorem abs_volumeForm_apply_of_orthonormal (v : OrthonormalBasis (Fin n) ℝ E) :
|o.volumeForm v| = 1 := by
simpa [o.volumeForm_robust' v v] using congr_arg abs v.toBasis.det_self
theorem volumeForm_map {F : Type*} [NormedAddCommGroup F] [InnerProductSpace ℝ F]
[Fact (finrank ℝ F = n)] (φ : E ≃ₗᵢ[ℝ] F) (x : Fin n → F) :
(Orientation.map (Fin n) φ.toLinearEquiv o).volumeForm x = o.volumeForm (φ.symm ∘ x) := by
rcases n with - | n
· refine o.eq_or_eq_neg_of_isEmpty.elim ?_ ?_ <;> rintro rfl <;> simp
let e : OrthonormalBasis (Fin n.succ) ℝ E := o.finOrthonormalBasis n.succ_pos Fact.out
have he : e.toBasis.orientation = o :=
o.finOrthonormalBasis_orientation n.succ_pos Fact.out
have heφ : (e.map φ).toBasis.orientation = Orientation.map (Fin n.succ) φ.toLinearEquiv o := by
rw [← he]
exact e.toBasis.orientation_map φ.toLinearEquiv
rw [(Orientation.map (Fin n.succ) φ.toLinearEquiv o).volumeForm_robust (e.map φ) heφ]
rw [o.volumeForm_robust e he]
simp
/-- The volume form is invariant under pullback by a positively-oriented isometric automorphism. -/
theorem volumeForm_comp_linearIsometryEquiv (φ : E ≃ₗᵢ[ℝ] E)
(hφ : 0 < LinearMap.det (φ.toLinearEquiv : E →ₗ[ℝ] E)) (x : Fin n → E) :
o.volumeForm (φ ∘ x) = o.volumeForm x := by
rcases n with - | n
· refine o.eq_or_eq_neg_of_isEmpty.elim ?_ ?_ <;> rintro rfl <;> simp
have : FiniteDimensional ℝ E := .of_fact_finrank_eq_succ n
convert o.volumeForm_map φ (φ ∘ x)
· symm
rwa [← o.map_eq_iff_det_pos φ.toLinearEquiv] at hφ
rw [_i.out, Fintype.card_fin]
· ext
simp
end VolumeForm
end Orientation |
.lake/packages/mathlib/Mathlib/Analysis/InnerProductSpace/Basic.lean | import Mathlib.Algebra.BigOperators.Field
import Mathlib.Analysis.Complex.Basic
import Mathlib.Analysis.InnerProductSpace.Defs
/-!
# Properties of inner product spaces
This file proves many basic properties of inner product spaces (real or complex).
## Main results
- `inner_mul_inner_self_le`: the Cauchy-Schwarz inequality (one of many variants).
- `norm_inner_eq_norm_iff`: the equality criterion in the Cauchy-Schwarz inequality (also in many
variants).
- `inner_eq_sum_norm_sq_div_four`: the polarization identity.
## Tags
inner product space, Hilbert space, norm
-/
noncomputable section
open RCLike Real Filter Topology ComplexConjugate Finsupp
open LinearMap (BilinForm)
variable {𝕜 E F : Type*} [RCLike 𝕜]
section BasicProperties_Seminormed
open scoped InnerProductSpace
variable [SeminormedAddCommGroup E] [InnerProductSpace 𝕜 E]
variable [SeminormedAddCommGroup F] [InnerProductSpace ℝ F]
local notation "⟪" x ", " y "⟫" => inner 𝕜 x y
local postfix:90 "†" => starRingEnd _
export InnerProductSpace (norm_sq_eq_re_inner)
@[simp]
theorem inner_conj_symm (x y : E) : ⟪y, x⟫† = ⟪x, y⟫ :=
InnerProductSpace.conj_inner_symm _ _
theorem real_inner_comm (x y : F) : ⟪y, x⟫_ℝ = ⟪x, y⟫_ℝ :=
@inner_conj_symm ℝ _ _ _ _ x y
theorem inner_eq_zero_symm {x y : E} : ⟪x, y⟫ = 0 ↔ ⟪y, x⟫ = 0 := by
rw [← inner_conj_symm]
exact star_eq_zero
instance {ι : Sort*} (v : ι → E) : IsSymm ι fun i j => ⟪v i, v j⟫ = 0 where
symm _ _ := inner_eq_zero_symm.1
theorem inner_self_im (x : E) : im ⟪x, x⟫ = 0 := by
rw [← @ofReal_inj 𝕜, im_eq_conj_sub]; simp
theorem inner_add_left (x y z : E) : ⟪x + y, z⟫ = ⟪x, z⟫ + ⟪y, z⟫ :=
InnerProductSpace.add_left _ _ _
theorem inner_add_right (x y z : E) : ⟪x, y + z⟫ = ⟪x, y⟫ + ⟪x, z⟫ := by
rw [← inner_conj_symm, inner_add_left, RingHom.map_add]
simp only [inner_conj_symm]
theorem inner_re_symm (x y : E) : re ⟪x, y⟫ = re ⟪y, x⟫ := by rw [← inner_conj_symm, conj_re]
theorem inner_im_symm (x y : E) : im ⟪x, y⟫ = -im ⟪y, x⟫ := by rw [← inner_conj_symm, conj_im]
section Algebra
variable {𝕝 : Type*} [CommSemiring 𝕝] [StarRing 𝕝] [Algebra 𝕝 𝕜] [Module 𝕝 E]
[IsScalarTower 𝕝 𝕜 E] [StarModule 𝕝 𝕜]
/-- See `inner_smul_left` for the common special when `𝕜 = 𝕝`. -/
lemma inner_smul_left_eq_star_smul (x y : E) (r : 𝕝) : ⟪r • x, y⟫ = r† • ⟪x, y⟫ := by
rw [← algebraMap_smul 𝕜 r, InnerProductSpace.smul_left, starRingEnd_apply, starRingEnd_apply,
← algebraMap_star_comm, ← smul_eq_mul, algebraMap_smul]
/-- Special case of `inner_smul_left_eq_star_smul` when the acting ring has a trivial star
(e.g. `ℕ`, `ℤ`, `ℚ≥0`, `ℚ`, `ℝ`). -/
lemma inner_smul_left_eq_smul [TrivialStar 𝕝] (x y : E) (r : 𝕝) : ⟪r • x, y⟫ = r • ⟪x, y⟫ := by
rw [inner_smul_left_eq_star_smul, starRingEnd_apply, star_trivial]
/-- See `inner_smul_right` for the common special when `𝕜 = 𝕝`. -/
lemma inner_smul_right_eq_smul (x y : E) (r : 𝕝) : ⟪x, r • y⟫ = r • ⟪x, y⟫ := by
rw [← inner_conj_symm, inner_smul_left_eq_star_smul, starRingEnd_apply, starRingEnd_apply,
star_smul, star_star, ← starRingEnd_apply, inner_conj_symm]
end Algebra
/-- See `inner_smul_left_eq_star_smul` for the case of a general algebra action. -/
theorem inner_smul_left (x y : E) (r : 𝕜) : ⟪r • x, y⟫ = r† * ⟪x, y⟫ :=
inner_smul_left_eq_star_smul ..
theorem real_inner_smul_left (x y : F) (r : ℝ) : ⟪r • x, y⟫_ℝ = r * ⟪x, y⟫_ℝ :=
inner_smul_left _ _ _
theorem inner_smul_real_left (x y : E) (r : ℝ) : ⟪(r : 𝕜) • x, y⟫ = r • ⟪x, y⟫ := by
rw [inner_smul_left, conj_ofReal, Algebra.smul_def]
/-- See `inner_smul_right_eq_smul` for the case of a general algebra action. -/
theorem inner_smul_right (x y : E) (r : 𝕜) : ⟪x, r • y⟫ = r * ⟪x, y⟫ :=
inner_smul_right_eq_smul ..
theorem real_inner_smul_right (x y : F) (r : ℝ) : ⟪x, r • y⟫_ℝ = r * ⟪x, y⟫_ℝ :=
inner_smul_right _ _ _
theorem inner_smul_real_right (x y : E) (r : ℝ) : ⟪x, (r : 𝕜) • y⟫ = r • ⟪x, y⟫ := by
rw [inner_smul_right, Algebra.smul_def]
/-- The inner product as a sesquilinear form.
Note that in the case `𝕜 = ℝ` this is a bilinear form. -/
@[simps!]
def sesqFormOfInner : E →ₗ[𝕜] E →ₗ⋆[𝕜] 𝕜 :=
LinearMap.mk₂'ₛₗ (RingHom.id 𝕜) (starRingEnd _) (fun x y => ⟪y, x⟫)
(fun _x _y _z => inner_add_right _ _ _) (fun _r _x _y => inner_smul_right _ _ _)
(fun _x _y _z => inner_add_left _ _ _) fun _r _x _y => inner_smul_left _ _ _
/-- The real inner product as a bilinear form.
Note that unlike `sesqFormOfInner`, this does not reverse the order of the arguments. -/
@[simps!]
def bilinFormOfRealInner : BilinForm ℝ F := sesqFormOfInner.flip
/-- An inner product with a sum on the left. -/
theorem sum_inner {ι : Type*} (s : Finset ι) (f : ι → E) (x : E) :
⟪∑ i ∈ s, f i, x⟫ = ∑ i ∈ s, ⟪f i, x⟫ :=
map_sum (sesqFormOfInner (𝕜 := 𝕜) (E := E) x) _ _
/-- An inner product with a sum on the right. -/
theorem inner_sum {ι : Type*} (s : Finset ι) (f : ι → E) (x : E) :
⟪x, ∑ i ∈ s, f i⟫ = ∑ i ∈ s, ⟪x, f i⟫ :=
map_sum (LinearMap.flip sesqFormOfInner x) _ _
/-- An inner product with a sum on the left, `Finsupp` version. -/
protected theorem Finsupp.sum_inner {ι : Type*} (l : ι →₀ 𝕜) (v : ι → E) (x : E) :
⟪l.sum fun (i : ι) (a : 𝕜) => a • v i, x⟫ = l.sum fun (i : ι) (a : 𝕜) => conj a • ⟪v i, x⟫ := by
convert sum_inner (𝕜 := 𝕜) l.support (fun a => l a • v a) x
simp only [inner_smul_left, Finsupp.sum, smul_eq_mul]
/-- An inner product with a sum on the right, `Finsupp` version. -/
protected theorem Finsupp.inner_sum {ι : Type*} (l : ι →₀ 𝕜) (v : ι → E) (x : E) :
⟪x, l.sum fun (i : ι) (a : 𝕜) => a • v i⟫ = l.sum fun (i : ι) (a : 𝕜) => a • ⟪x, v i⟫ := by
convert inner_sum (𝕜 := 𝕜) l.support (fun a => l a • v a) x
simp only [inner_smul_right, Finsupp.sum, smul_eq_mul]
protected theorem DFinsupp.sum_inner {ι : Type*} [DecidableEq ι] {α : ι → Type*}
[∀ i, AddZeroClass (α i)] [∀ (i) (x : α i), Decidable (x ≠ 0)] (f : ∀ i, α i → E)
(l : Π₀ i, α i) (x : E) : ⟪l.sum f, x⟫ = l.sum fun i a => ⟪f i a, x⟫ := by
simp +contextual only [DFinsupp.sum, sum_inner]
protected theorem DFinsupp.inner_sum {ι : Type*} [DecidableEq ι] {α : ι → Type*}
[∀ i, AddZeroClass (α i)] [∀ (i) (x : α i), Decidable (x ≠ 0)] (f : ∀ i, α i → E)
(l : Π₀ i, α i) (x : E) : ⟪x, l.sum f⟫ = l.sum fun i a => ⟪x, f i a⟫ := by
simp +contextual only [DFinsupp.sum, inner_sum]
@[simp]
theorem inner_zero_left (x : E) : ⟪0, x⟫ = 0 := by
rw [← zero_smul 𝕜 (0 : E), inner_smul_left, RingHom.map_zero, zero_mul]
theorem inner_re_zero_left (x : E) : re ⟪0, x⟫ = 0 := by
simp only [inner_zero_left, AddMonoidHom.map_zero]
@[simp]
theorem inner_zero_right (x : E) : ⟪x, 0⟫ = 0 := by
rw [← inner_conj_symm, inner_zero_left, RingHom.map_zero]
theorem inner_re_zero_right (x : E) : re ⟪x, 0⟫ = 0 := by
simp only [inner_zero_right, AddMonoidHom.map_zero]
theorem inner_self_nonneg {x : E} : 0 ≤ re ⟪x, x⟫ :=
PreInnerProductSpace.toCore.re_inner_nonneg x
theorem real_inner_self_nonneg {x : F} : 0 ≤ ⟪x, x⟫_ℝ :=
@inner_self_nonneg ℝ F _ _ _ x
theorem inner_self_ofReal_re (x : E) : (re ⟪x, x⟫ : 𝕜) = ⟪x, x⟫ :=
((RCLike.is_real_TFAE (⟪x, x⟫ : 𝕜)).out 2 3).2 (inner_self_im (𝕜 := 𝕜) x)
@[simp]
theorem inner_self_eq_norm_sq_to_K (x : E) : ⟪x, x⟫ = (‖x‖ : 𝕜) ^ 2 := by
rw [← inner_self_ofReal_re, ← norm_sq_eq_re_inner, ofReal_pow]
theorem inner_self_re_eq_norm (x : E) : re ⟪x, x⟫ = ‖⟪x, x⟫‖ := by
conv_rhs => rw [← inner_self_ofReal_re]
symm
exact norm_of_nonneg inner_self_nonneg
theorem inner_self_ofReal_norm (x : E) : (‖⟪x, x⟫‖ : 𝕜) = ⟪x, x⟫ := by
rw [← inner_self_re_eq_norm]
exact inner_self_ofReal_re _
theorem real_inner_self_abs (x : F) : |⟪x, x⟫_ℝ| = ⟪x, x⟫_ℝ :=
@inner_self_ofReal_norm ℝ F _ _ _ x
theorem norm_inner_symm (x y : E) : ‖⟪x, y⟫‖ = ‖⟪y, x⟫‖ := by rw [← inner_conj_symm, norm_conj]
@[simp]
theorem inner_neg_left (x y : E) : ⟪-x, y⟫ = -⟪x, y⟫ := by
rw [← neg_one_smul 𝕜 x, inner_smul_left]
simp
@[simp]
theorem inner_neg_right (x y : E) : ⟪x, -y⟫ = -⟪x, y⟫ := by
rw [← inner_conj_symm, inner_neg_left]; simp only [RingHom.map_neg, inner_conj_symm]
theorem inner_neg_neg (x y : E) : ⟪-x, -y⟫ = ⟪x, y⟫ := by simp
theorem inner_self_conj (x : E) : ⟪x, x⟫† = ⟪x, x⟫ := inner_conj_symm _ _
theorem inner_sub_left (x y z : E) : ⟪x - y, z⟫ = ⟪x, z⟫ - ⟪y, z⟫ := by
simp [sub_eq_add_neg, inner_add_left]
theorem inner_sub_right (x y z : E) : ⟪x, y - z⟫ = ⟪x, y⟫ - ⟪x, z⟫ := by
simp [sub_eq_add_neg, inner_add_right]
theorem inner_mul_symm_re_eq_norm (x y : E) : re (⟪x, y⟫ * ⟪y, x⟫) = ‖⟪x, y⟫ * ⟪y, x⟫‖ := by
rw [← inner_conj_symm, mul_comm]
exact re_eq_norm_of_mul_conj ⟪y, x⟫
/-- Expand `⟪x + y, x + y⟫` -/
theorem inner_add_add_self (x y : E) : ⟪x + y, x + y⟫ = ⟪x, x⟫ + ⟪x, y⟫ + ⟪y, x⟫ + ⟪y, y⟫ := by
simp only [inner_add_left, inner_add_right]; ring
/-- Expand `⟪x + y, x + y⟫_ℝ` -/
theorem real_inner_add_add_self (x y : F) :
⟪x + y, x + y⟫_ℝ = ⟪x, x⟫_ℝ + 2 * ⟪x, y⟫_ℝ + ⟪y, y⟫_ℝ := by
have : ⟪y, x⟫_ℝ = ⟪x, y⟫_ℝ := by rw [← inner_conj_symm]; rfl
simp only [inner_add_add_self, this, add_left_inj]
ring
-- Expand `⟪x - y, x - y⟫`
theorem inner_sub_sub_self (x y : E) : ⟪x - y, x - y⟫ = ⟪x, x⟫ - ⟪x, y⟫ - ⟪y, x⟫ + ⟪y, y⟫ := by
simp only [inner_sub_left, inner_sub_right]; ring
/-- Expand `⟪x - y, x - y⟫_ℝ` -/
theorem real_inner_sub_sub_self (x y : F) :
⟪x - y, x - y⟫_ℝ = ⟪x, x⟫_ℝ - 2 * ⟪x, y⟫_ℝ + ⟪y, y⟫_ℝ := by
have : ⟪y, x⟫_ℝ = ⟪x, y⟫_ℝ := by rw [← inner_conj_symm]; rfl
simp only [inner_sub_sub_self, this, add_left_inj]
ring
/-- Parallelogram law -/
theorem parallelogram_law {x y : E} : ⟪x + y, x + y⟫ + ⟪x - y, x - y⟫ = 2 * (⟪x, x⟫ + ⟪y, y⟫) := by
simp only [inner_add_add_self, inner_sub_sub_self]
ring
/-- **Cauchy–Schwarz inequality**. -/
theorem inner_mul_inner_self_le (x y : E) : ‖⟪x, y⟫‖ * ‖⟪y, x⟫‖ ≤ re ⟪x, x⟫ * re ⟪y, y⟫ :=
letI : PreInnerProductSpace.Core 𝕜 E := PreInnerProductSpace.toCore
InnerProductSpace.Core.inner_mul_inner_self_le x y
/-- Cauchy–Schwarz inequality for real inner products. -/
theorem real_inner_mul_inner_self_le (x y : F) : ⟪x, y⟫_ℝ * ⟪x, y⟫_ℝ ≤ ⟪x, x⟫_ℝ * ⟪y, y⟫_ℝ :=
calc
⟪x, y⟫_ℝ * ⟪x, y⟫_ℝ ≤ ‖⟪x, y⟫_ℝ‖ * ‖⟪y, x⟫_ℝ‖ := by
rw [real_inner_comm y, ← norm_mul]
exact le_abs_self _
_ ≤ ⟪x, x⟫_ℝ * ⟪y, y⟫_ℝ := @inner_mul_inner_self_le ℝ _ _ _ _ x y
theorem inner_eq_ofReal_norm_sq_left_iff {v w : E} : ⟪v, w⟫_𝕜 = ‖v‖ ^ 2 ↔ ⟪v, v - w⟫_𝕜 = 0 := by
rw [inner_sub_right, sub_eq_zero, inner_self_eq_norm_sq_to_K, eq_comm]
theorem inner_eq_norm_sq_left_iff {v w : F} : ⟪v, w⟫_ℝ = ‖v‖ ^ 2 ↔ ⟪v, v - w⟫_ℝ = 0 :=
inner_eq_ofReal_norm_sq_left_iff
theorem inner_eq_ofReal_norm_sq_right_iff {v w : E} : ⟪v, w⟫_𝕜 = ‖w‖ ^ 2 ↔ ⟪v - w, w⟫_𝕜 = 0 := by
rw [inner_sub_left, sub_eq_zero, inner_self_eq_norm_sq_to_K, eq_comm]
theorem inner_eq_norm_sq_right_iff {v w : F} : ⟪v, w⟫_ℝ = ‖w‖ ^ 2 ↔ ⟪v - w, w⟫_ℝ = 0 :=
inner_eq_ofReal_norm_sq_right_iff
end BasicProperties_Seminormed
section BasicProperties
variable [NormedAddCommGroup E] [InnerProductSpace 𝕜 E]
variable [NormedAddCommGroup F] [InnerProductSpace ℝ F]
local notation "⟪" x ", " y "⟫" => inner 𝕜 x y
export InnerProductSpace (norm_sq_eq_re_inner)
theorem inner_self_eq_zero {x : E} : ⟪x, x⟫ = 0 ↔ x = 0 := by
rw [inner_self_eq_norm_sq_to_K, sq_eq_zero_iff, ofReal_eq_zero, norm_eq_zero]
theorem inner_self_ne_zero {x : E} : ⟪x, x⟫ ≠ 0 ↔ x ≠ 0 :=
inner_self_eq_zero.not
variable (𝕜)
theorem ext_inner_left {x y : E} (h : ∀ v, ⟪v, x⟫ = ⟪v, y⟫) : x = y := by
rw [← sub_eq_zero, ← @inner_self_eq_zero 𝕜, inner_sub_right, sub_eq_zero, h (x - y)]
theorem ext_iff_inner_left {x y : E} : x = y ↔ ∀ v, ⟪v, x⟫ = ⟪v, y⟫ :=
⟨fun h _ ↦ h ▸ rfl, ext_inner_left 𝕜⟩
theorem ext_inner_right {x y : E} (h : ∀ v, ⟪x, v⟫ = ⟪y, v⟫) : x = y := by
rw [← sub_eq_zero, ← @inner_self_eq_zero 𝕜, inner_sub_left, sub_eq_zero, h (x - y)]
theorem ext_iff_inner_right {x y : E} : x = y ↔ ∀ v, ⟪x, v⟫ = ⟪y, v⟫ :=
⟨fun h _ ↦ h ▸ rfl, ext_inner_right 𝕜⟩
variable {𝕜}
theorem re_inner_self_nonpos {x : E} : re ⟪x, x⟫ ≤ 0 ↔ x = 0 := by
simp
lemma re_inner_self_pos {x : E} : 0 < re ⟪x, x⟫ ↔ x ≠ 0 := by
simp [sq_pos_iff]
@[deprecated (since := "2025-04-22")] alias inner_self_nonpos := re_inner_self_nonpos
@[deprecated (since := "2025-04-22")] alias inner_self_pos := re_inner_self_pos
open scoped InnerProductSpace in
theorem real_inner_self_nonpos {x : F} : ⟪x, x⟫_ℝ ≤ 0 ↔ x = 0 := re_inner_self_nonpos (𝕜 := ℝ)
open scoped InnerProductSpace in
theorem real_inner_self_pos {x : F} : 0 < ⟪x, x⟫_ℝ ↔ x ≠ 0 := re_inner_self_pos (𝕜 := ℝ)
/-- A family of vectors is linearly independent if they are nonzero
and orthogonal. -/
theorem linearIndependent_of_ne_zero_of_inner_eq_zero {ι : Type*} {v : ι → E} (hz : ∀ i, v i ≠ 0)
(ho : Pairwise fun i j => ⟪v i, v j⟫ = 0) : LinearIndependent 𝕜 v := by
rw [linearIndependent_iff']
intro s g hg i hi
have h' : g i * ⟪v i, v i⟫ = ⟪v i, ∑ j ∈ s, g j • v j⟫ := by
rw [inner_sum]
symm
convert Finset.sum_eq_single (M := 𝕜) i ?_ ?_
· rw [inner_smul_right]
· intro j _hj hji
rw [inner_smul_right, ho hji.symm, mul_zero]
· exact fun h => False.elim (h hi)
simpa [hg, hz] using h'
end BasicProperties
section Norm_Seminormed
open scoped InnerProductSpace
variable [SeminormedAddCommGroup E] [InnerProductSpace 𝕜 E]
variable [SeminormedAddCommGroup F] [InnerProductSpace ℝ F]
local notation "⟪" x ", " y "⟫" => inner 𝕜 x y
local notation "IK" => @RCLike.I 𝕜 _
theorem norm_eq_sqrt_re_inner (x : E) : ‖x‖ = √(re ⟪x, x⟫) :=
calc
‖x‖ = √(‖x‖ ^ 2) := (sqrt_sq (norm_nonneg _)).symm
_ = √(re ⟪x, x⟫) := congr_arg _ (norm_sq_eq_re_inner _)
@[deprecated (since := "2025-04-22")] alias norm_eq_sqrt_inner := norm_eq_sqrt_re_inner
theorem norm_eq_sqrt_real_inner (x : F) : ‖x‖ = √⟪x, x⟫_ℝ :=
@norm_eq_sqrt_re_inner ℝ _ _ _ _ x
theorem inner_self_eq_norm_mul_norm (x : E) : re ⟪x, x⟫ = ‖x‖ * ‖x‖ := by
rw [@norm_eq_sqrt_re_inner 𝕜, ← sqrt_mul inner_self_nonneg (re ⟪x, x⟫),
sqrt_mul_self inner_self_nonneg]
theorem inner_self_eq_norm_sq (x : E) : re ⟪x, x⟫ = ‖x‖ ^ 2 := by
rw [pow_two, inner_self_eq_norm_mul_norm]
theorem real_inner_self_eq_norm_mul_norm (x : F) : ⟪x, x⟫_ℝ = ‖x‖ * ‖x‖ := by
have h := @inner_self_eq_norm_mul_norm ℝ F _ _ _ x
simpa using h
theorem real_inner_self_eq_norm_sq (x : F) : ⟪x, x⟫_ℝ = ‖x‖ ^ 2 := by
rw [pow_two, real_inner_self_eq_norm_mul_norm]
/-- Expand the square -/
theorem norm_add_sq (x y : E) : ‖x + y‖ ^ 2 = ‖x‖ ^ 2 + 2 * re ⟪x, y⟫ + ‖y‖ ^ 2 := by
repeat' rw [sq (M := ℝ), ← @inner_self_eq_norm_mul_norm 𝕜]
rw [inner_add_add_self, two_mul]
simp only [add_assoc, add_left_inj, add_right_inj, AddMonoidHom.map_add]
rw [← inner_conj_symm, conj_re]
alias norm_add_pow_two := norm_add_sq
/-- Expand the square -/
theorem norm_add_sq_real (x y : F) : ‖x + y‖ ^ 2 = ‖x‖ ^ 2 + 2 * ⟪x, y⟫_ℝ + ‖y‖ ^ 2 := by
have h := @norm_add_sq ℝ _ _ _ _ x y
simpa using h
alias norm_add_pow_two_real := norm_add_sq_real
/-- Expand the square -/
theorem norm_add_mul_self (x y : E) :
‖x + y‖ * ‖x + y‖ = ‖x‖ * ‖x‖ + 2 * re ⟪x, y⟫ + ‖y‖ * ‖y‖ := by
repeat' rw [← sq (M := ℝ)]
exact norm_add_sq _ _
/-- Expand the square -/
theorem norm_add_mul_self_real (x y : F) :
‖x + y‖ * ‖x + y‖ = ‖x‖ * ‖x‖ + 2 * ⟪x, y⟫_ℝ + ‖y‖ * ‖y‖ := by
have h := @norm_add_mul_self ℝ _ _ _ _ x y
simpa using h
/-- Expand the square -/
theorem norm_sub_sq (x y : E) : ‖x - y‖ ^ 2 = ‖x‖ ^ 2 - 2 * re ⟪x, y⟫ + ‖y‖ ^ 2 := by
rw [sub_eq_add_neg, @norm_add_sq 𝕜 _ _ _ _ x (-y), norm_neg, inner_neg_right, map_neg, mul_neg,
sub_eq_add_neg]
alias norm_sub_pow_two := norm_sub_sq
/-- Expand the square -/
theorem norm_sub_sq_real (x y : F) : ‖x - y‖ ^ 2 = ‖x‖ ^ 2 - 2 * ⟪x, y⟫_ℝ + ‖y‖ ^ 2 :=
@norm_sub_sq ℝ _ _ _ _ _ _
alias norm_sub_pow_two_real := norm_sub_sq_real
/-- Expand the square -/
theorem norm_sub_mul_self (x y : E) :
‖x - y‖ * ‖x - y‖ = ‖x‖ * ‖x‖ - 2 * re ⟪x, y⟫ + ‖y‖ * ‖y‖ := by
repeat' rw [← sq (M := ℝ)]
exact norm_sub_sq _ _
/-- Expand the square -/
theorem norm_sub_mul_self_real (x y : F) :
‖x - y‖ * ‖x - y‖ = ‖x‖ * ‖x‖ - 2 * ⟪x, y⟫_ℝ + ‖y‖ * ‖y‖ := by
have h := @norm_sub_mul_self ℝ _ _ _ _ x y
simpa using h
/-- Cauchy–Schwarz inequality with norm -/
theorem norm_inner_le_norm (x y : E) : ‖⟪x, y⟫‖ ≤ ‖x‖ * ‖y‖ := by
rw [norm_eq_sqrt_re_inner (𝕜 := 𝕜) x, norm_eq_sqrt_re_inner (𝕜 := 𝕜) y]
letI : PreInnerProductSpace.Core 𝕜 E := PreInnerProductSpace.toCore
exact InnerProductSpace.Core.norm_inner_le_norm x y
theorem nnnorm_inner_le_nnnorm (x y : E) : ‖⟪x, y⟫‖₊ ≤ ‖x‖₊ * ‖y‖₊ :=
norm_inner_le_norm x y
theorem re_inner_le_norm (x y : E) : re ⟪x, y⟫ ≤ ‖x‖ * ‖y‖ :=
le_trans (re_le_norm ⟪x, y⟫) (norm_inner_le_norm x y)
/-- Cauchy–Schwarz inequality with norm -/
theorem abs_real_inner_le_norm (x y : F) : |⟪x, y⟫_ℝ| ≤ ‖x‖ * ‖y‖ :=
(Real.norm_eq_abs _).ge.trans (norm_inner_le_norm x y)
/-- Cauchy–Schwarz inequality with norm -/
theorem real_inner_le_norm (x y : F) : ⟪x, y⟫_ℝ ≤ ‖x‖ * ‖y‖ :=
le_trans (le_abs_self _) (abs_real_inner_le_norm _ _)
lemma inner_eq_zero_of_left {x : E} (y : E) (h : ‖x‖ = 0) : ⟪x, y⟫_𝕜 = 0 := by
rw [← norm_eq_zero]
refine le_antisymm ?_ (by positivity)
exact norm_inner_le_norm _ _ |>.trans <| by simp [h]
lemma inner_eq_zero_of_right (x : E) {y : E} (h : ‖y‖ = 0) : ⟪x, y⟫_𝕜 = 0 := by
rw [inner_eq_zero_symm, inner_eq_zero_of_left _ h]
variable (𝕜)
include 𝕜 in
theorem parallelogram_law_with_norm (x y : E) :
‖x + y‖ * ‖x + y‖ + ‖x - y‖ * ‖x - y‖ = 2 * (‖x‖ * ‖x‖ + ‖y‖ * ‖y‖) := by
simp only [← @inner_self_eq_norm_mul_norm 𝕜]
rw [← re.map_add, parallelogram_law, two_mul, two_mul]
simp only [re.map_add]
include 𝕜 in
theorem parallelogram_law_with_nnnorm (x y : E) :
‖x + y‖₊ * ‖x + y‖₊ + ‖x - y‖₊ * ‖x - y‖₊ = 2 * (‖x‖₊ * ‖x‖₊ + ‖y‖₊ * ‖y‖₊) :=
Subtype.ext <| parallelogram_law_with_norm 𝕜 x y
variable {𝕜}
/-- Polarization identity: The real part of the inner product, in terms of the norm. -/
theorem re_inner_eq_norm_add_mul_self_sub_norm_mul_self_sub_norm_mul_self_div_two (x y : E) :
re ⟪x, y⟫ = (‖x + y‖ * ‖x + y‖ - ‖x‖ * ‖x‖ - ‖y‖ * ‖y‖) / 2 := by
rw [@norm_add_mul_self 𝕜]
ring
/-- Polarization identity: The real part of the inner product, in terms of the norm. -/
theorem re_inner_eq_norm_mul_self_add_norm_mul_self_sub_norm_sub_mul_self_div_two (x y : E) :
re ⟪x, y⟫ = (‖x‖ * ‖x‖ + ‖y‖ * ‖y‖ - ‖x - y‖ * ‖x - y‖) / 2 := by
rw [@norm_sub_mul_self 𝕜]
ring
/-- Polarization identity: The real part of the inner product, in terms of the norm. -/
theorem re_inner_eq_norm_add_mul_self_sub_norm_sub_mul_self_div_four (x y : E) :
re ⟪x, y⟫ = (‖x + y‖ * ‖x + y‖ - ‖x - y‖ * ‖x - y‖) / 4 := by
rw [@norm_add_mul_self 𝕜, @norm_sub_mul_self 𝕜]
ring
/-- Polarization identity: The imaginary part of the inner product, in terms of the norm. -/
theorem im_inner_eq_norm_sub_i_smul_mul_self_sub_norm_add_i_smul_mul_self_div_four (x y : E) :
im ⟪x, y⟫ = (‖x - IK • y‖ * ‖x - IK • y‖ - ‖x + IK • y‖ * ‖x + IK • y‖) / 4 := by
simp only [@norm_add_mul_self 𝕜, @norm_sub_mul_self 𝕜, inner_smul_right, I_mul_re]
ring
/-- Polarization identity: The inner product, in terms of the norm. -/
theorem inner_eq_sum_norm_sq_div_four (x y : E) :
⟪x, y⟫ = ((‖x + y‖ : 𝕜) ^ 2 - (‖x - y‖ : 𝕜) ^ 2 +
((‖x - IK • y‖ : 𝕜) ^ 2 - (‖x + IK • y‖ : 𝕜) ^ 2) * IK) / 4 := by
rw [← re_add_im ⟪x, y⟫, re_inner_eq_norm_add_mul_self_sub_norm_sub_mul_self_div_four,
im_inner_eq_norm_sub_i_smul_mul_self_sub_norm_add_i_smul_mul_self_div_four]
push_cast
simp only [sq, ← mul_div_right_comm, ← add_div]
/-- Polarization identity: The real inner product, in terms of the norm. -/
theorem real_inner_eq_norm_add_mul_self_sub_norm_mul_self_sub_norm_mul_self_div_two (x y : F) :
⟪x, y⟫_ℝ = (‖x + y‖ * ‖x + y‖ - ‖x‖ * ‖x‖ - ‖y‖ * ‖y‖) / 2 :=
re_to_real.symm.trans <|
re_inner_eq_norm_add_mul_self_sub_norm_mul_self_sub_norm_mul_self_div_two x y
/-- Polarization identity: The real inner product, in terms of the norm. -/
theorem real_inner_eq_norm_mul_self_add_norm_mul_self_sub_norm_sub_mul_self_div_two (x y : F) :
⟪x, y⟫_ℝ = (‖x‖ * ‖x‖ + ‖y‖ * ‖y‖ - ‖x - y‖ * ‖x - y‖) / 2 :=
re_to_real.symm.trans <|
re_inner_eq_norm_mul_self_add_norm_mul_self_sub_norm_sub_mul_self_div_two x y
/-- Pythagorean theorem, if-and-only-if vector inner product form. -/
theorem norm_add_sq_eq_norm_sq_add_norm_sq_iff_real_inner_eq_zero (x y : F) :
‖x + y‖ * ‖x + y‖ = ‖x‖ * ‖x‖ + ‖y‖ * ‖y‖ ↔ ⟪x, y⟫_ℝ = 0 := by
rw [@norm_add_mul_self ℝ, add_right_cancel_iff, add_eq_left, mul_eq_zero]
simp
/-- Pythagorean theorem, if-and-if vector inner product form using square roots. -/
theorem norm_add_eq_sqrt_iff_real_inner_eq_zero {x y : F} :
‖x + y‖ = √(‖x‖ * ‖x‖ + ‖y‖ * ‖y‖) ↔ ⟪x, y⟫_ℝ = 0 := by
rw [← norm_add_sq_eq_norm_sq_add_norm_sq_iff_real_inner_eq_zero, eq_comm, sqrt_eq_iff_mul_self_eq,
eq_comm] <;> positivity
/-- Pythagorean theorem, vector inner product form. -/
theorem norm_add_sq_eq_norm_sq_add_norm_sq_of_inner_eq_zero (x y : E) (h : ⟪x, y⟫ = 0) :
‖x + y‖ * ‖x + y‖ = ‖x‖ * ‖x‖ + ‖y‖ * ‖y‖ := by
rw [@norm_add_mul_self 𝕜, add_right_cancel_iff, add_eq_left, mul_eq_zero]
apply Or.inr
simp only [h, zero_re]
/-- Pythagorean theorem, vector inner product form. -/
theorem norm_add_sq_eq_norm_sq_add_norm_sq_real {x y : F} (h : ⟪x, y⟫_ℝ = 0) :
‖x + y‖ * ‖x + y‖ = ‖x‖ * ‖x‖ + ‖y‖ * ‖y‖ :=
(norm_add_sq_eq_norm_sq_add_norm_sq_iff_real_inner_eq_zero x y).2 h
/-- Pythagorean theorem, subtracting vectors, if-and-only-if vector
inner product form. -/
theorem norm_sub_sq_eq_norm_sq_add_norm_sq_iff_real_inner_eq_zero (x y : F) :
‖x - y‖ * ‖x - y‖ = ‖x‖ * ‖x‖ + ‖y‖ * ‖y‖ ↔ ⟪x, y⟫_ℝ = 0 := by
rw [@norm_sub_mul_self ℝ, add_right_cancel_iff, sub_eq_add_neg, add_eq_left, neg_eq_zero,
mul_eq_zero]
simp
/-- Pythagorean theorem, subtracting vectors, if-and-if vector inner product form using square
roots. -/
theorem norm_sub_eq_sqrt_iff_real_inner_eq_zero {x y : F} :
‖x - y‖ = √(‖x‖ * ‖x‖ + ‖y‖ * ‖y‖) ↔ ⟪x, y⟫_ℝ = 0 := by
rw [← norm_sub_sq_eq_norm_sq_add_norm_sq_iff_real_inner_eq_zero, eq_comm, sqrt_eq_iff_mul_self_eq,
eq_comm] <;> positivity
/-- Pythagorean theorem, subtracting vectors, vector inner product
form. -/
theorem norm_sub_sq_eq_norm_sq_add_norm_sq_real {x y : F} (h : ⟪x, y⟫_ℝ = 0) :
‖x - y‖ * ‖x - y‖ = ‖x‖ * ‖x‖ + ‖y‖ * ‖y‖ :=
(norm_sub_sq_eq_norm_sq_add_norm_sq_iff_real_inner_eq_zero x y).2 h
/-- The sum and difference of two vectors are orthogonal if and only
if they have the same norm. -/
theorem real_inner_add_sub_eq_zero_iff (x y : F) : ⟪x + y, x - y⟫_ℝ = 0 ↔ ‖x‖ = ‖y‖ := by
conv_rhs => rw [← mul_self_inj_of_nonneg (norm_nonneg _) (norm_nonneg _)]
simp only [← @inner_self_eq_norm_mul_norm ℝ, inner_add_left, inner_sub_right, real_inner_comm y x,
sub_eq_zero, re_to_real]
grind
/-- Given two orthogonal vectors, their sum and difference have equal norms. -/
theorem norm_sub_eq_norm_add {v w : E} (h : ⟪v, w⟫ = 0) : ‖w - v‖ = ‖w + v‖ := by
rw [← mul_self_inj_of_nonneg (norm_nonneg _) (norm_nonneg _)]
simp only [h, ← @inner_self_eq_norm_mul_norm 𝕜, sub_neg_eq_add, sub_zero, map_sub, zero_re,
zero_sub, add_zero, map_add, inner_add_right, inner_sub_left, inner_sub_right, inner_re_symm,
zero_add]
/-- The real inner product of two vectors, divided by the product of their
norms, has absolute value at most 1. -/
theorem abs_real_inner_div_norm_mul_norm_le_one (x y : F) : |⟪x, y⟫_ℝ / (‖x‖ * ‖y‖)| ≤ 1 := by
rw [abs_div, abs_mul, abs_norm, abs_norm]
exact div_le_one_of_le₀ (abs_real_inner_le_norm x y) (by positivity)
/-- The inner product of a vector with a multiple of itself. -/
theorem real_inner_smul_self_left (x : F) (r : ℝ) : ⟪r • x, x⟫_ℝ = r * (‖x‖ * ‖x‖) := by
rw [real_inner_smul_left, ← real_inner_self_eq_norm_mul_norm]
/-- The inner product of a vector with a multiple of itself. -/
theorem real_inner_smul_self_right (x : F) (r : ℝ) : ⟪x, r • x⟫_ℝ = r * (‖x‖ * ‖x‖) := by
rw [inner_smul_right, ← real_inner_self_eq_norm_mul_norm]
/-- The inner product of two weighted sums, where the weights in each
sum add to 0, in terms of the norms of pairwise differences. -/
theorem inner_sum_smul_sum_smul_of_sum_eq_zero {ι₁ : Type*} {s₁ : Finset ι₁} {w₁ : ι₁ → ℝ}
(v₁ : ι₁ → F) (h₁ : ∑ i ∈ s₁, w₁ i = 0) {ι₂ : Type*} {s₂ : Finset ι₂} {w₂ : ι₂ → ℝ}
(v₂ : ι₂ → F) (h₂ : ∑ i ∈ s₂, w₂ i = 0) :
⟪∑ i₁ ∈ s₁, w₁ i₁ • v₁ i₁, ∑ i₂ ∈ s₂, w₂ i₂ • v₂ i₂⟫_ℝ =
(-∑ i₁ ∈ s₁, ∑ i₂ ∈ s₂, w₁ i₁ * w₂ i₂ * (‖v₁ i₁ - v₂ i₂‖ * ‖v₁ i₁ - v₂ i₂‖)) / 2 := by
simp_rw [sum_inner, inner_sum, real_inner_smul_left, real_inner_smul_right,
real_inner_eq_norm_mul_self_add_norm_mul_self_sub_norm_sub_mul_self_div_two, ← div_sub_div_same,
add_div, mul_sub_left_distrib, left_distrib, Finset.sum_sub_distrib,
Finset.sum_add_distrib, ← Finset.mul_sum, ← Finset.sum_mul, h₁, h₂, zero_mul,
mul_zero, Finset.sum_const_zero, zero_add, zero_sub, Finset.mul_sum, neg_div,
Finset.sum_div, mul_div_assoc, mul_assoc]
end Norm_Seminormed
section Norm
open scoped InnerProductSpace
variable [NormedAddCommGroup E] [InnerProductSpace 𝕜 E]
variable [NormedAddCommGroup F] [InnerProductSpace ℝ F]
variable {ι : Type*}
local notation "⟪" x ", " y "⟫" => inner 𝕜 x y
/-- Formula for the distance between the images of two nonzero points under an inversion with center
zero. See also `EuclideanGeometry.dist_inversion_inversion` for inversions around a general
point. -/
theorem dist_div_norm_sq_smul {x y : F} (hx : x ≠ 0) (hy : y ≠ 0) (R : ℝ) :
dist ((R / ‖x‖) ^ 2 • x) ((R / ‖y‖) ^ 2 • y) = R ^ 2 / (‖x‖ * ‖y‖) * dist x y :=
calc
dist ((R / ‖x‖) ^ 2 • x) ((R / ‖y‖) ^ 2 • y) =
√(‖(R / ‖x‖) ^ 2 • x - (R / ‖y‖) ^ 2 • y‖ ^ 2) := by
rw [dist_eq_norm, sqrt_sq (norm_nonneg _)]
_ = √((R ^ 2 / (‖x‖ * ‖y‖)) ^ 2 * ‖x - y‖ ^ 2) :=
congr_arg (√·) <| by
simp [field, sq, norm_sub_mul_self_real, norm_smul, real_inner_smul_left, inner_smul_right,
Real.norm_of_nonneg (mul_self_nonneg _), -mul_eq_mul_left_iff]
ring
_ = R ^ 2 / (‖x‖ * ‖y‖) * dist x y := by
rw [sqrt_mul, sqrt_sq, sqrt_sq, dist_eq_norm] <;> positivity
/-- The inner product of a nonzero vector with a nonzero multiple of
itself, divided by the product of their norms, has absolute value
1. -/
theorem norm_inner_div_norm_mul_norm_eq_one_of_ne_zero_of_ne_zero_mul {x : E} {r : 𝕜} (hx : x ≠ 0)
(hr : r ≠ 0) : ‖⟪x, r • x⟫‖ / (‖x‖ * ‖r • x‖) = 1 := by
have hx' : ‖x‖ ≠ 0 := by simp [hx]
have hr' : ‖r‖ ≠ 0 := by simp [hr]
rw [inner_smul_right, norm_mul, ← inner_self_re_eq_norm, inner_self_eq_norm_mul_norm, norm_smul]
rw [← mul_assoc, ← div_div, mul_div_cancel_right₀ _ hx', ← div_div, mul_comm,
mul_div_cancel_right₀ _ hr', div_self hx']
/-- The inner product of a nonzero vector with a nonzero multiple of
itself, divided by the product of their norms, has absolute value
1. -/
theorem abs_real_inner_div_norm_mul_norm_eq_one_of_ne_zero_of_ne_zero_mul {x : F} {r : ℝ}
(hx : x ≠ 0) (hr : r ≠ 0) : |⟪x, r • x⟫_ℝ| / (‖x‖ * ‖r • x‖) = 1 :=
norm_inner_div_norm_mul_norm_eq_one_of_ne_zero_of_ne_zero_mul hx hr
/-- The inner product of a nonzero vector with a positive multiple of
itself, divided by the product of their norms, has value 1. -/
theorem real_inner_div_norm_mul_norm_eq_one_of_ne_zero_of_pos_mul {x : F} {r : ℝ} (hx : x ≠ 0)
(hr : 0 < r) : ⟪x, r • x⟫_ℝ / (‖x‖ * ‖r • x‖) = 1 := by
rw [real_inner_smul_self_right, norm_smul, Real.norm_eq_abs, ← mul_assoc ‖x‖, mul_comm _ |r|,
mul_assoc, abs_of_nonneg hr.le, div_self]
exact mul_ne_zero hr.ne' (mul_self_ne_zero.2 (norm_ne_zero_iff.2 hx))
/-- The inner product of a nonzero vector with a negative multiple of
itself, divided by the product of their norms, has value -1. -/
theorem real_inner_div_norm_mul_norm_eq_neg_one_of_ne_zero_of_neg_mul {x : F} {r : ℝ} (hx : x ≠ 0)
(hr : r < 0) : ⟪x, r • x⟫_ℝ / (‖x‖ * ‖r • x‖) = -1 := by
rw [real_inner_smul_self_right, norm_smul, Real.norm_eq_abs, ← mul_assoc ‖x‖, mul_comm _ |r|,
mul_assoc, abs_of_neg hr, neg_mul, div_neg_eq_neg_div, div_self]
exact mul_ne_zero hr.ne (mul_self_ne_zero.2 (norm_ne_zero_iff.2 hx))
variable (𝕜) in
theorem norm_inner_eq_norm_tfae (x y : E) :
List.TFAE [‖⟪x, y⟫‖ = ‖x‖ * ‖y‖,
x = 0 ∨ y = (⟪x, y⟫ / ⟪x, x⟫) • x,
x = 0 ∨ ∃ r : 𝕜, y = r • x,
x = 0 ∨ y ∈ 𝕜 ∙ x] := by
tfae_have 1 → 2 := by
refine fun h => or_iff_not_imp_left.2 fun hx₀ => ?_
have : ‖x‖ ^ 2 ≠ 0 := pow_ne_zero _ (norm_ne_zero_iff.2 hx₀)
rw [← sq_eq_sq₀, mul_pow, ← mul_right_inj' this, eq_comm, ← sub_eq_zero, ← mul_sub] at h <;>
try positivity
simp only [@norm_sq_eq_re_inner 𝕜] at h
letI : InnerProductSpace.Core 𝕜 E := InnerProductSpace.toCore
erw [← InnerProductSpace.Core.cauchy_schwarz_aux (𝕜 := 𝕜) (F := E)] at h
rw [InnerProductSpace.Core.normSq_eq_zero, sub_eq_zero] at h
rw [div_eq_inv_mul, mul_smul, h, inv_smul_smul₀]
rwa [inner_self_ne_zero]
tfae_have 2 → 3 := fun h => h.imp_right fun h' => ⟨_, h'⟩
tfae_have 3 → 1 := by
rintro (rfl | ⟨r, rfl⟩) <;>
simp [inner_smul_right, norm_smul, inner_self_eq_norm_sq_to_K,
sq, mul_left_comm]
tfae_have 3 ↔ 4 := by simp only [Submodule.mem_span_singleton, eq_comm]
tfae_finish
/-- If the inner product of two vectors is equal to the product of their norms, then the two vectors
are multiples of each other. One form of the equality case for Cauchy-Schwarz.
Compare `inner_eq_norm_mul_iff`, which takes the stronger hypothesis `⟪x, y⟫ = ‖x‖ * ‖y‖`. -/
theorem norm_inner_eq_norm_iff {x y : E} (hx₀ : x ≠ 0) (hy₀ : y ≠ 0) :
‖⟪x, y⟫‖ = ‖x‖ * ‖y‖ ↔ ∃ r : 𝕜, r ≠ 0 ∧ y = r • x :=
calc
‖⟪x, y⟫‖ = ‖x‖ * ‖y‖ ↔ x = 0 ∨ ∃ r : 𝕜, y = r • x :=
(norm_inner_eq_norm_tfae 𝕜 x y).out 0 2
_ ↔ ∃ r : 𝕜, y = r • x := or_iff_right hx₀
_ ↔ ∃ r : 𝕜, r ≠ 0 ∧ y = r • x :=
⟨fun ⟨r, h⟩ => ⟨r, fun hr₀ => hy₀ <| h.symm ▸ smul_eq_zero.2 <| Or.inl hr₀, h⟩,
fun ⟨r, _hr₀, h⟩ => ⟨r, h⟩⟩
/-- The inner product of two vectors, divided by the product of their
norms, has absolute value 1 if and only if they are nonzero and one is
a multiple of the other. One form of equality case for Cauchy-Schwarz. -/
theorem norm_inner_div_norm_mul_norm_eq_one_iff (x y : E) :
‖⟪x, y⟫ / (‖x‖ * ‖y‖)‖ = 1 ↔ x ≠ 0 ∧ ∃ r : 𝕜, r ≠ 0 ∧ y = r • x := by
constructor
· intro h
have hx₀ : x ≠ 0 := fun h₀ => by simp [h₀] at h
have hy₀ : y ≠ 0 := fun h₀ => by simp [h₀] at h
refine ⟨hx₀, (norm_inner_eq_norm_iff hx₀ hy₀).1 <| eq_of_div_eq_one ?_⟩
simpa using h
· rintro ⟨hx, ⟨r, ⟨hr, rfl⟩⟩⟩
simp only [norm_div, norm_mul, norm_ofReal, abs_norm]
exact norm_inner_div_norm_mul_norm_eq_one_of_ne_zero_of_ne_zero_mul hx hr
/-- The inner product of two vectors, divided by the product of their
norms, has absolute value 1 if and only if they are nonzero and one is
a multiple of the other. One form of equality case for Cauchy-Schwarz. -/
theorem abs_real_inner_div_norm_mul_norm_eq_one_iff (x y : F) :
|⟪x, y⟫_ℝ / (‖x‖ * ‖y‖)| = 1 ↔ x ≠ 0 ∧ ∃ r : ℝ, r ≠ 0 ∧ y = r • x :=
@norm_inner_div_norm_mul_norm_eq_one_iff ℝ F _ _ _ x y
theorem inner_eq_norm_mul_iff_div {x y : E} (h₀ : x ≠ 0) :
⟪x, y⟫ = (‖x‖ : 𝕜) * ‖y‖ ↔ (‖y‖ / ‖x‖ : 𝕜) • x = y := by
have h₀' := h₀
rw [← norm_ne_zero_iff, Ne, ← @ofReal_eq_zero 𝕜] at h₀'
constructor <;> intro h
· have : x = 0 ∨ y = (⟪x, y⟫ / ⟪x, x⟫ : 𝕜) • x :=
((norm_inner_eq_norm_tfae 𝕜 x y).out 0 1).1 (by simp [h])
rw [this.resolve_left h₀, h]
simp [norm_smul, mul_div_cancel_right₀ _ h₀']
· conv_lhs => rw [← h, inner_smul_right, inner_self_eq_norm_sq_to_K]
field
/-- If the inner product of two vectors is equal to the product of their norms (i.e.,
`⟪x, y⟫ = ‖x‖ * ‖y‖`), then the two vectors are nonnegative real multiples of each other. One form
of the equality case for Cauchy-Schwarz.
Compare `norm_inner_eq_norm_iff`, which takes the weaker hypothesis `abs ⟪x, y⟫ = ‖x‖ * ‖y‖`. -/
theorem inner_eq_norm_mul_iff {x y : E} :
⟪x, y⟫ = (‖x‖ : 𝕜) * ‖y‖ ↔ (‖y‖ : 𝕜) • x = (‖x‖ : 𝕜) • y := by
rcases eq_or_ne x 0 with (rfl | h₀)
· simp
· rw [inner_eq_norm_mul_iff_div h₀, div_eq_inv_mul, mul_smul, inv_smul_eq_iff₀]
rwa [Ne, ofReal_eq_zero, norm_eq_zero]
/-- If the inner product of two vectors is equal to the product of their norms (i.e.,
`⟪x, y⟫ = ‖x‖ * ‖y‖`), then the two vectors are nonnegative real multiples of each other. One form
of the equality case for Cauchy-Schwarz.
Compare `norm_inner_eq_norm_iff`, which takes the weaker hypothesis `abs ⟪x, y⟫ = ‖x‖ * ‖y‖`. -/
theorem inner_eq_norm_mul_iff_real {x y : F} : ⟪x, y⟫_ℝ = ‖x‖ * ‖y‖ ↔ ‖y‖ • x = ‖x‖ • y :=
inner_eq_norm_mul_iff
/-- The inner product of two vectors, divided by the product of their
norms, has value 1 if and only if they are nonzero and one is
a positive multiple of the other. -/
theorem real_inner_div_norm_mul_norm_eq_one_iff (x y : F) :
⟪x, y⟫_ℝ / (‖x‖ * ‖y‖) = 1 ↔ x ≠ 0 ∧ ∃ r : ℝ, 0 < r ∧ y = r • x := by
constructor
· intro h
have hx₀ : x ≠ 0 := fun h₀ => by simp [h₀] at h
have hy₀ : y ≠ 0 := fun h₀ => by simp [h₀] at h
refine ⟨hx₀, ‖y‖ / ‖x‖, div_pos (norm_pos_iff.2 hy₀) (norm_pos_iff.2 hx₀), ?_⟩
exact ((inner_eq_norm_mul_iff_div hx₀).1 (eq_of_div_eq_one h)).symm
· rintro ⟨hx, ⟨r, ⟨hr, rfl⟩⟩⟩
exact real_inner_div_norm_mul_norm_eq_one_of_ne_zero_of_pos_mul hx hr
/-- The inner product of two vectors, divided by the product of their
norms, has value -1 if and only if they are nonzero and one is
a negative multiple of the other. -/
theorem real_inner_div_norm_mul_norm_eq_neg_one_iff (x y : F) :
⟪x, y⟫_ℝ / (‖x‖ * ‖y‖) = -1 ↔ x ≠ 0 ∧ ∃ r : ℝ, r < 0 ∧ y = r • x := by
rw [← neg_eq_iff_eq_neg, ← neg_div, ← inner_neg_right, ← norm_neg y,
real_inner_div_norm_mul_norm_eq_one_iff, (@neg_surjective ℝ _).exists]
refine Iff.rfl.and (exists_congr fun r => ?_)
rw [neg_pos, neg_smul, neg_inj]
/-- If the inner product of two unit vectors is `1`, then the two vectors are equal. One form of
the equality case for Cauchy-Schwarz. -/
theorem inner_eq_one_iff_of_norm_eq_one {x y : E} (hx : ‖x‖ = 1) (hy : ‖y‖ = 1) :
⟪x, y⟫ = 1 ↔ x = y := by
convert inner_eq_norm_mul_iff (𝕜 := 𝕜) (E := E) using 2 <;> simp [hx, hy]
theorem inner_self_eq_one_of_norm_eq_one {x : E} (hx : ‖x‖ = 1) : ⟪x, x⟫_𝕜 = 1 :=
(inner_eq_one_iff_of_norm_eq_one hx hx).mpr rfl
theorem inner_lt_norm_mul_iff_real {x y : F} : ⟪x, y⟫_ℝ < ‖x‖ * ‖y‖ ↔ ‖y‖ • x ≠ ‖x‖ • y :=
calc
⟪x, y⟫_ℝ < ‖x‖ * ‖y‖ ↔ ⟪x, y⟫_ℝ ≠ ‖x‖ * ‖y‖ :=
⟨ne_of_lt, lt_of_le_of_ne (real_inner_le_norm _ _)⟩
_ ↔ ‖y‖ • x ≠ ‖x‖ • y := not_congr inner_eq_norm_mul_iff_real
/-- If the inner product of two unit vectors is strictly less than `1`, then the two vectors are
distinct. One form of the equality case for Cauchy-Schwarz. -/
theorem inner_lt_one_iff_real_of_norm_eq_one {x y : F} (hx : ‖x‖ = 1) (hy : ‖y‖ = 1) :
⟪x, y⟫_ℝ < 1 ↔ x ≠ y := by convert inner_lt_norm_mul_iff_real (F := F) <;> simp [hx, hy]
@[deprecated (since := "2025-11-15")] alias inner_eq_one_iff_of_norm_one :=
inner_eq_one_iff_of_norm_eq_one
@[deprecated (since := "2025-11-15")] alias inner_self_eq_one_of_norm_one :=
inner_self_eq_one_of_norm_eq_one
@[deprecated (since := "2025-11-15")] alias inner_lt_one_iff_real_of_norm_one :=
inner_lt_one_iff_real_of_norm_eq_one
/-- The sphere of radius `r = ‖y‖` is tangent to the plane `⟪x, y⟫ = ‖y‖ ^ 2` at `x = y`. -/
theorem eq_of_norm_le_re_inner_eq_norm_sq {x y : E} (hle : ‖x‖ ≤ ‖y‖) (h : re ⟪x, y⟫ = ‖y‖ ^ 2) :
x = y := by
suffices H : re ⟪x - y, x - y⟫ ≤ 0 by rwa [re_inner_self_nonpos, sub_eq_zero] at H
have H₁ : ‖x‖ ^ 2 ≤ ‖y‖ ^ 2 := by gcongr
have H₂ : re ⟪y, x⟫ = ‖y‖ ^ 2 := by rwa [← inner_conj_symm, conj_re]
simp only [inner_sub_left, inner_sub_right]
simpa [h, H₂] using H₁
/-- Equality is achieved in the triangle inequality iff the two vectors are collinear. -/
theorem norm_add_eq_iff_real {x y : F} : ‖x + y‖ = ‖x‖ + ‖y‖ ↔ ‖y‖ • x = ‖x‖ • y := by
rw [← pow_left_inj₀ (norm_nonneg _) (Left.add_nonneg (norm_nonneg _) (norm_nonneg _)) two_ne_zero,
norm_add_sq (𝕜 := ℝ), add_pow_two, add_left_inj, add_right_inj, re_to_real, mul_assoc,
mul_right_inj' two_ne_zero, ← inner_eq_norm_mul_iff_real]
end Norm
section RCLike
local notation "⟪" x ", " y "⟫" => inner 𝕜 x y
/-- A field `𝕜` satisfying `RCLike` is itself a `𝕜`-inner product space. -/
instance RCLike.innerProductSpace : InnerProductSpace 𝕜 𝕜 where
inner x y := y * conj x
norm_sq_eq_re_inner x := by simp only [mul_conj, ← ofReal_pow, ofReal_re]
conj_inner_symm x y := by simp only [mul_comm, map_mul, starRingEnd_self_apply]
add_left x y z := by simp only [mul_add, map_add]
smul_left x y z := by simp only [mul_comm (conj z), mul_assoc, smul_eq_mul, map_mul]
@[simp]
theorem RCLike.inner_apply (x y : 𝕜) : ⟪x, y⟫ = y * conj x :=
rfl
/-- A version of `RCLike.inner_apply` that swaps the order of multiplication. -/
theorem RCLike.inner_apply' (x y : 𝕜) : ⟪x, y⟫ = conj x * y := mul_comm _ _
end RCLike
section RCLikeToReal
open scoped InnerProductSpace
variable {G : Type*}
variable (𝕜 E)
variable [SeminormedAddCommGroup E] [InnerProductSpace 𝕜 E]
local notation "⟪" x ", " y "⟫" => inner 𝕜 x y
/-- A general inner product implies a real inner product. This is not registered as an instance
since `𝕜` does not appear in the return type `Inner ℝ E`. -/
def Inner.rclikeToReal : Inner ℝ E where inner x y := re ⟪x, y⟫
/-- A general inner product space structure implies a real inner product structure.
This is not registered as an instance since
* `𝕜` does not appear in the return type `InnerProductSpace ℝ E`,
* It is likely to create instance diamonds, as it builds upon the diamond-prone
`NormedSpace.restrictScalars`.
However, it can be used in a proof to obtain a real inner product space structure from a given
`𝕜`-inner product space structure. -/
-- See note [reducible non-instances]
abbrev InnerProductSpace.rclikeToReal : InnerProductSpace ℝ E :=
{ Inner.rclikeToReal 𝕜 E,
NormedSpace.restrictScalars ℝ 𝕜 E with
norm_sq_eq_re_inner := norm_sq_eq_re_inner
conj_inner_symm := fun _ _ => inner_re_symm _ _
add_left := fun x y z => by
simp only [Inner.rclikeToReal, inner_add_left, map_add]
smul_left := fun x y r => by
letI := NormedSpace.restrictScalars ℝ 𝕜 E
have : r • x = (r : 𝕜) • x := rfl
simp only [Inner.rclikeToReal, this, conj_trivial, inner_smul_left, conj_ofReal,
re_ofReal_mul] }
variable {E}
theorem real_inner_eq_re_inner (x y : E) :
(Inner.rclikeToReal 𝕜 E).inner x y = re ⟪x, y⟫ :=
rfl
theorem real_inner_I_smul_self (x : E) :
(Inner.rclikeToReal 𝕜 E).inner x ((I : 𝕜) • x) = 0 := by
simp [real_inner_eq_re_inner 𝕜, inner_smul_right]
/-- A complex inner product implies a real inner product. This cannot be an instance since it
creates a diamond with `PiLp.innerProductSpace` because `re (sum i, ⟪x i, y i⟫)` and
`sum i, re ⟪x i, y i⟫` are not defeq. -/
def InnerProductSpace.complexToReal [SeminormedAddCommGroup G] [InnerProductSpace ℂ G] :
InnerProductSpace ℝ G :=
InnerProductSpace.rclikeToReal ℂ G
instance : InnerProductSpace ℝ ℂ := InnerProductSpace.complexToReal
@[simp]
protected theorem Complex.inner (w z : ℂ) : ⟪w, z⟫_ℝ = (z * conj w).re :=
rfl
end RCLikeToReal
/-- An `RCLike` field is a real inner product space. -/
noncomputable instance RCLike.toInnerProductSpaceReal : InnerProductSpace ℝ 𝕜 where
__ := Inner.rclikeToReal 𝕜 𝕜
norm_sq_eq_re_inner := norm_sq_eq_re_inner
conj_inner_symm x y := inner_re_symm ..
add_left x y z :=
show re (_ * _) = re (_ * _) + re (_ * _) by simp only [map_add, mul_re, conj_re, conj_im]; ring
smul_left x y r :=
show re (_ * _) = _ * re (_ * _) by
simp only [mul_re, conj_re, conj_im, conj_trivial, smul_re, smul_im]; ring
-- The instance above does not create diamonds for concrete `𝕜`:
example : (innerProductSpace : InnerProductSpace ℝ ℝ) = RCLike.toInnerProductSpaceReal := rfl
example :
(instInnerProductSpaceRealComplex : InnerProductSpace ℝ ℂ) = RCLike.toInnerProductSpaceReal :=
rfl |
.lake/packages/mathlib/Mathlib/Analysis/InnerProductSpace/Subspace.lean | import Mathlib.Analysis.InnerProductSpace.Orthonormal
/-!
# Subspaces of inner product spaces
This file defines the inner-product structure on a subspace of an inner-product space, and proves
some theorems about orthogonal families of subspaces.
-/
noncomputable section
open RCLike Real Filter Topology ComplexConjugate Finsupp Module
open LinearMap (BilinForm)
variable {𝕜 E F : Type*} [RCLike 𝕜]
section Submodule
variable [SeminormedAddCommGroup E] [InnerProductSpace 𝕜 E]
local notation "⟪" x ", " y "⟫" => inner 𝕜 x y
/-! ### Inner product space structure on subspaces -/
/-- Induced inner product on a submodule. -/
instance Submodule.innerProductSpace (W : Submodule 𝕜 E) : InnerProductSpace 𝕜 W :=
{ Submodule.normedSpace W with
inner := fun x y => ⟪(x : E), (y : E)⟫
conj_inner_symm := fun _ _ => inner_conj_symm _ _
norm_sq_eq_re_inner := fun x => norm_sq_eq_re_inner (x : E)
add_left := fun _ _ _ => inner_add_left _ _ _
smul_left := fun _ _ _ => inner_smul_left _ _ _ }
/-- The inner product on submodules is the same as on the ambient space. -/
@[simp]
theorem Submodule.coe_inner (W : Submodule 𝕜 E) (x y : W) : ⟪x, y⟫ = ⟪(x : E), ↑y⟫ :=
rfl
theorem Orthonormal.codRestrict {ι : Type*} {v : ι → E} (hv : Orthonormal 𝕜 v) (s : Submodule 𝕜 E)
(hvs : ∀ i, v i ∈ s) : @Orthonormal 𝕜 s _ _ _ ι (Set.codRestrict v s hvs) :=
s.subtypeₗᵢ.orthonormal_comp_iff.mp hv
theorem orthonormal_span {ι : Type*} {v : ι → E} (hv : Orthonormal 𝕜 v) :
@Orthonormal 𝕜 (Submodule.span 𝕜 (Set.range v)) _ _ _ ι fun i : ι =>
⟨v i, Submodule.subset_span (Set.mem_range_self i)⟩ :=
hv.codRestrict (Submodule.span 𝕜 (Set.range v)) fun i =>
Submodule.subset_span (Set.mem_range_self i)
end Submodule
/-! ### Families of mutually-orthogonal subspaces of an inner product space -/
section OrthogonalFamily_Seminormed
variable [SeminormedAddCommGroup E] [InnerProductSpace 𝕜 E]
local notation "⟪" x ", " y "⟫" => inner 𝕜 x y
variable {ι : Type*} (𝕜)
open DirectSum
/-- An indexed family of mutually-orthogonal subspaces of an inner product space `E`.
The simple way to express this concept would be as a condition on `V : ι → Submodule 𝕜 E`. We
instead implement it as a condition on a family of inner product spaces each equipped with an
isometric embedding into `E`, thus making it a property of morphisms rather than subobjects.
The connection to the subobject spelling is shown in `orthogonalFamily_iff_pairwise`.
This definition is less lightweight, but allows for better definitional properties when the inner
product space structure on each of the submodules is important -- for example, when considering
their Hilbert sum (`PiLp V 2`). For example, given an orthonormal set of vectors `v : ι → E`,
we have an associated orthogonal family of one-dimensional subspaces of `E`, which it is convenient
to be able to discuss using `ι → 𝕜` rather than `Π i : ι, span 𝕜 (v i)`. -/
def OrthogonalFamily (G : ι → Type*) [∀ i, SeminormedAddCommGroup (G i)]
[∀ i, InnerProductSpace 𝕜 (G i)] (V : ∀ i, G i →ₗᵢ[𝕜] E) : Prop :=
Pairwise fun i j => ∀ v : G i, ∀ w : G j, ⟪V i v, V j w⟫ = 0
variable {𝕜}
variable {G : ι → Type*} [∀ i, NormedAddCommGroup (G i)] [∀ i, InnerProductSpace 𝕜 (G i)]
{V : ∀ i, G i →ₗᵢ[𝕜] E}
theorem Orthonormal.orthogonalFamily {v : ι → E} (hv : Orthonormal 𝕜 v) :
OrthogonalFamily 𝕜 (fun _i : ι => 𝕜) fun i => LinearIsometry.toSpanSingleton 𝕜 E (hv.1 i) :=
fun i j hij a b => by simp [inner_smul_left, inner_smul_right, hv.2 hij]
section
variable (hV : OrthogonalFamily 𝕜 G V)
include hV
theorem OrthogonalFamily.eq_ite [DecidableEq ι] {i j : ι} (v : G i) (w : G j) :
⟪V i v, V j w⟫ = ite (i = j) ⟪V i v, V j w⟫ 0 := by
split_ifs with h
· rfl
· exact hV h v w
theorem OrthogonalFamily.inner_right_dfinsupp
[∀ (i) (x : G i), Decidable (x ≠ 0)] [DecidableEq ι] (l : ⨁ i, G i) (i : ι) (v : G i) :
⟪V i v, l.sum fun j => V j⟫ = ⟪v, l i⟫ :=
calc
⟪V i v, l.sum fun j => V j⟫ = l.sum fun j => fun w => ⟪V i v, V j w⟫ :=
DFinsupp.inner_sum (fun j => V j) l (V i v)
_ = l.sum fun j => fun w => ite (i = j) ⟪V i v, V j w⟫ 0 :=
(congr_arg l.sum <| funext fun _ => funext <| hV.eq_ite v)
_ = ⟪v, l i⟫ := by
simp only [DFinsupp.sum, Finset.sum_ite_eq,
DFinsupp.mem_support_toFun]
split_ifs with h
· simp only [LinearIsometry.inner_map_map]
· simp only [of_not_not h, inner_zero_right]
theorem OrthogonalFamily.inner_right_fintype [Fintype ι] (l : ∀ i, G i) (i : ι) (v : G i) :
⟪V i v, ∑ j : ι, V j (l j)⟫ = ⟪v, l i⟫ := by
classical
calc
⟪V i v, ∑ j : ι, V j (l j)⟫ = ∑ j : ι, ⟪V i v, V j (l j)⟫ := by rw [inner_sum]
_ = ∑ j, ite (i = j) ⟪V i v, V j (l j)⟫ 0 :=
(congr_arg (Finset.sum Finset.univ) <| funext fun j => hV.eq_ite v (l j))
_ = ⟪v, l i⟫ := by
simp only [Finset.sum_ite_eq, Finset.mem_univ, (V i).inner_map_map, if_true]
nonrec theorem OrthogonalFamily.inner_sum (l₁ l₂ : ∀ i, G i) (s : Finset ι) :
⟪∑ i ∈ s, V i (l₁ i), ∑ j ∈ s, V j (l₂ j)⟫ = ∑ i ∈ s, ⟪l₁ i, l₂ i⟫ := by
classical
calc
⟪∑ i ∈ s, V i (l₁ i), ∑ j ∈ s, V j (l₂ j)⟫ = ∑ j ∈ s, ∑ i ∈ s, ⟪V i (l₁ i), V j (l₂ j)⟫ := by
simp only [sum_inner, inner_sum]
_ = ∑ j ∈ s, ∑ i ∈ s, ite (i = j) ⟪V i (l₁ i), V j (l₂ j)⟫ 0 := by
congr with i
congr with j
apply hV.eq_ite
_ = ∑ i ∈ s, ⟪l₁ i, l₂ i⟫ := by
simp only [Finset.sum_ite_of_true, Finset.sum_ite_eq', LinearIsometry.inner_map_map,
imp_self, imp_true_iff]
theorem OrthogonalFamily.norm_sum (l : ∀ i, G i) (s : Finset ι) :
‖∑ i ∈ s, V i (l i)‖ ^ 2 = ∑ i ∈ s, ‖l i‖ ^ 2 := by
have : ((‖∑ i ∈ s, V i (l i)‖ : ℝ) : 𝕜) ^ 2 = ∑ i ∈ s, ((‖l i‖ : ℝ) : 𝕜) ^ 2 := by
simp only [← inner_self_eq_norm_sq_to_K, hV.inner_sum]
exact mod_cast this
/-- The composition of an orthogonal family of subspaces with an injective function is also an
orthogonal family. -/
theorem OrthogonalFamily.comp {γ : Type*} {f : γ → ι} (hf : Function.Injective f) :
OrthogonalFamily 𝕜 (fun g => G (f g)) fun g => V (f g) :=
fun _i _j hij v w => hV (hf.ne hij) v w
theorem OrthogonalFamily.orthonormal_sigma_orthonormal {α : ι → Type*} {v_family : ∀ i, α i → G i}
(hv_family : ∀ i, Orthonormal 𝕜 (v_family i)) :
Orthonormal 𝕜 fun a : Σ i, α i => V a.1 (v_family a.1 a.2) := by
constructor
· rintro ⟨i, v⟩
simpa only [LinearIsometry.norm_map] using (hv_family i).left v
rintro ⟨i, v⟩ ⟨j, w⟩ hvw
by_cases hij : i = j
· subst hij
have : v ≠ w := fun h => by
subst h
exact hvw rfl
simpa only [LinearIsometry.inner_map_map] using (hv_family i).2 this
· exact hV hij (v_family i v) (v_family j w)
theorem OrthogonalFamily.norm_sq_diff_sum [DecidableEq ι] (f : ∀ i, G i) (s₁ s₂ : Finset ι) :
‖(∑ i ∈ s₁, V i (f i)) - ∑ i ∈ s₂, V i (f i)‖ ^ 2 =
(∑ i ∈ s₁ \ s₂, ‖f i‖ ^ 2) + ∑ i ∈ s₂ \ s₁, ‖f i‖ ^ 2 := by
rw [← Finset.sum_sdiff_sub_sum_sdiff, sub_eq_add_neg, ← Finset.sum_neg_distrib]
let F : ∀ i, G i := fun i => if i ∈ s₁ then f i else -f i
have hF₁ : ∀ i ∈ s₁ \ s₂, F i = f i := fun i hi => if_pos (Finset.sdiff_subset hi)
have hF₂ : ∀ i ∈ s₂ \ s₁, F i = -f i := fun i hi => if_neg (Finset.mem_sdiff.mp hi).2
have hF : ∀ i, ‖F i‖ = ‖f i‖ := by
intro i
dsimp only [F]
split_ifs <;> simp only [norm_neg]
have :
‖(∑ i ∈ s₁ \ s₂, V i (F i)) + ∑ i ∈ s₂ \ s₁, V i (F i)‖ ^ 2 =
(∑ i ∈ s₁ \ s₂, ‖F i‖ ^ 2) + ∑ i ∈ s₂ \ s₁, ‖F i‖ ^ 2 := by
have hs : Disjoint (s₁ \ s₂) (s₂ \ s₁) := disjoint_sdiff_sdiff
simpa only [Finset.sum_union hs] using hV.norm_sum F (s₁ \ s₂ ∪ s₂ \ s₁)
convert this using 4
· refine Finset.sum_congr rfl fun i hi => ?_
simp only [hF₁ i hi]
· refine Finset.sum_congr rfl fun i hi => ?_
simp only [hF₂ i hi, LinearIsometry.map_neg]
· simp only [hF]
· simp only [hF]
/-- A family `f` of mutually-orthogonal elements of `E` is summable, if and only if
`(fun i ↦ ‖f i‖ ^ 2)` is summable. -/
theorem OrthogonalFamily.summable_iff_norm_sq_summable [CompleteSpace E] (f : ∀ i, G i) :
(Summable fun i => V i (f i)) ↔ Summable fun i => ‖f i‖ ^ 2 := by
classical
simp only [summable_iff_cauchySeq_finset, NormedAddCommGroup.cauchySeq_iff, Real.norm_eq_abs]
constructor
· intro hf ε hε
obtain ⟨a, H⟩ := hf _ (sqrt_pos.mpr hε)
use a
intro s₁ hs₁ s₂ hs₂
rw [← Finset.sum_sdiff_sub_sum_sdiff]
refine (abs_sub _ _).trans_lt ?_
have : ∀ i, 0 ≤ ‖f i‖ ^ 2 := fun i : ι => sq_nonneg _
simp only [Finset.abs_sum_of_nonneg' this]
have : ((∑ i ∈ s₁ \ s₂, ‖f i‖ ^ 2) + ∑ i ∈ s₂ \ s₁, ‖f i‖ ^ 2) < √ε ^ 2 := by
rw [← hV.norm_sq_diff_sum, sq_lt_sq, abs_of_nonneg (sqrt_nonneg _),
abs_of_nonneg (norm_nonneg _)]
exact H s₁ hs₁ s₂ hs₂
have hη := sq_sqrt (le_of_lt hε)
linarith
· intro hf ε hε
have hε' : 0 < ε ^ 2 / 2 := half_pos (sq_pos_of_pos hε)
obtain ⟨a, H⟩ := hf _ hε'
use a
intro s₁ hs₁ s₂ hs₂
refine (abs_lt_of_sq_lt_sq' ?_ (le_of_lt hε)).2
have has : a ≤ s₁ ⊓ s₂ := le_inf hs₁ hs₂
rw [hV.norm_sq_diff_sum]
have Hs₁ : ∑ x ∈ s₁ \ s₂, ‖f x‖ ^ 2 < ε ^ 2 / 2 := by
convert H _ hs₁ _ has
have : s₁ ⊓ s₂ ⊆ s₁ := Finset.inter_subset_left
rw [← Finset.sum_sdiff this, add_tsub_cancel_right, Finset.abs_sum_of_nonneg']
· simp
· exact fun i => sq_nonneg _
have Hs₂ : ∑ x ∈ s₂ \ s₁, ‖f x‖ ^ 2 < ε ^ 2 / 2 := by
convert H _ hs₂ _ has
have : s₁ ⊓ s₂ ⊆ s₂ := Finset.inter_subset_right
rw [← Finset.sum_sdiff this, add_tsub_cancel_right, Finset.abs_sum_of_nonneg']
· simp
· exact fun i => sq_nonneg _
linarith
end
end OrthogonalFamily_Seminormed
section OrthogonalFamily
variable [NormedAddCommGroup E] [InnerProductSpace 𝕜 E]
local notation "⟪" x ", " y "⟫" => inner 𝕜 x y
variable {ι : Type*} {G : ι → Type*}
/-- An orthogonal family forms an independent family of subspaces; that is, any collection of
elements each from a different subspace in the family is linearly independent. In particular, the
pairwise intersections of elements of the family are 0. -/
theorem OrthogonalFamily.independent {V : ι → Submodule 𝕜 E}
(hV : OrthogonalFamily 𝕜 (fun i => V i) fun i => (V i).subtypeₗᵢ) :
iSupIndep V := by
classical
apply iSupIndep_of_dfinsupp_lsum_injective
refine LinearMap.ker_eq_bot.mp ?_
rw [Submodule.eq_bot_iff]
intro v hv
rw [LinearMap.mem_ker] at hv
ext i
suffices ⟪(v i : E), v i⟫ = 0 by simpa only [inner_self_eq_zero] using this
calc
⟪(v i : E), v i⟫ = ⟪(v i : E), DFinsupp.lsum ℕ (fun i => (V i).subtype) v⟫ := by
simpa only [DFinsupp.sumAddHom_apply, DFinsupp.lsum_apply_apply] using
(hV.inner_right_dfinsupp v i (v i)).symm
_ = 0 := by simp only [hv, inner_zero_right]
theorem DirectSum.IsInternal.collectedBasis_orthonormal [DecidableEq ι] {V : ι → Submodule 𝕜 E}
(hV : OrthogonalFamily 𝕜 (fun i => V i) fun i => (V i).subtypeₗᵢ)
(hV_sum : DirectSum.IsInternal fun i => V i) {α : ι → Type*}
{v_family : ∀ i, Basis (α i) 𝕜 (V i)} (hv_family : ∀ i, Orthonormal 𝕜 (v_family i)) :
Orthonormal 𝕜 (hV_sum.collectedBasis v_family) := by
simpa only [hV_sum.collectedBasis_coe] using hV.orthonormal_sigma_orthonormal hv_family
end OrthogonalFamily |
.lake/packages/mathlib/Mathlib/Analysis/InnerProductSpace/GramSchmidtOrtho.lean | import Mathlib.Analysis.InnerProductSpace.PiL2
import Mathlib.LinearAlgebra.Matrix.Block
/-!
# Gram-Schmidt Orthogonalization and Orthonormalization
In this file we introduce Gram-Schmidt Orthogonalization and Orthonormalization.
The Gram-Schmidt process takes a set of vectors as input
and outputs a set of orthogonal vectors which have the same span.
## Main results
- `gramSchmidt`: the Gram-Schmidt process
- `gramSchmidt_orthogonal`: `gramSchmidt` produces an orthogonal system of vectors.
- `span_gramSchmidt`: `gramSchmidt` preserves span of vectors.
- `gramSchmidt_linearIndependent`: if the input vectors of `gramSchmidt` are linearly independent,
then so are the output vectors.
- `gramSchmidt_ne_zero`: if the input vectors of `gramSchmidt` are linearly independent,
then the output vectors are non-zero.
- `gramSchmidtBasis`: the basis produced by the Gram-Schmidt process when given a basis as input
- `gramSchmidtNormed`:
the normalized `gramSchmidt` process, i.e each vector in `gramSchmidtNormed` has unit length
- `gramSchmidt_orthonormal`: `gramSchmidtNormed` produces an orthornormal system of vectors.
- `gramSchmidtOrthonormalBasis`: orthonormal basis constructed by the Gram-Schmidt process from
an indexed set of vectors of the right size
-/
open Finset Submodule Module
variable (𝕜 : Type*) {E : Type*} [RCLike 𝕜] [NormedAddCommGroup E] [InnerProductSpace 𝕜 E]
variable {ι : Type*} [LinearOrder ι] [LocallyFiniteOrderBot ι] [WellFoundedLT ι]
attribute [local instance] IsWellOrder.toHasWellFounded
local notation "⟪" x ", " y "⟫" => inner 𝕜 x y
namespace InnerProductSpace
/-- The Gram-Schmidt process takes a set of vectors as input
and outputs a set of orthogonal vectors which have the same span. -/
noncomputable def gramSchmidt [WellFoundedLT ι] (f : ι → E) (n : ι) : E :=
f n - ∑ i : Iio n, (𝕜 ∙ gramSchmidt f i).starProjection (f n)
termination_by n
decreasing_by exact mem_Iio.1 i.2
/-- This lemma uses `∑ i in` instead of `∑ i :`. -/
theorem gramSchmidt_def (f : ι → E) (n : ι) :
gramSchmidt 𝕜 f n = f n - ∑ i ∈ Iio n, (𝕜 ∙ gramSchmidt 𝕜 f i).starProjection (f n) := by
rw [← sum_attach, attach_eq_univ, gramSchmidt]
theorem gramSchmidt_def' (f : ι → E) (n : ι) :
f n = gramSchmidt 𝕜 f n + ∑ i ∈ Iio n, (𝕜 ∙ gramSchmidt 𝕜 f i).starProjection (f n) := by
rw [gramSchmidt_def, sub_add_cancel]
theorem gramSchmidt_def'' (f : ι → E) (n : ι) :
f n = gramSchmidt 𝕜 f n + ∑ i ∈ Iio n,
(⟪gramSchmidt 𝕜 f i, f n⟫ / (‖gramSchmidt 𝕜 f i‖ : 𝕜) ^ 2) • gramSchmidt 𝕜 f i := by
simp only [← map_pow, ← starProjection_singleton, ← gramSchmidt_def' 𝕜 f n]
@[simp]
theorem gramSchmidt_bot {ι : Type*} [LinearOrder ι] [LocallyFiniteOrder ι] [OrderBot ι]
[WellFoundedLT ι] (f : ι → E) : gramSchmidt 𝕜 f ⊥ = f ⊥ := by
rw [gramSchmidt_def, Iio_eq_Ico, Finset.Ico_self, Finset.sum_empty, sub_zero]
@[simp]
theorem gramSchmidt_zero (n : ι) : gramSchmidt 𝕜 (0 : ι → E) n = 0 := by rw [gramSchmidt_def]; simp
/-- **Gram-Schmidt Orthogonalisation**:
`gramSchmidt` produces an orthogonal system of vectors. -/
theorem gramSchmidt_orthogonal (f : ι → E) {a b : ι} (h₀ : a ≠ b) :
⟪gramSchmidt 𝕜 f a, gramSchmidt 𝕜 f b⟫ = 0 := by
suffices ∀ a b : ι, a < b → ⟪gramSchmidt 𝕜 f a, gramSchmidt 𝕜 f b⟫ = 0 by
rcases h₀.lt_or_gt with ha | hb
· exact this _ _ ha
· rw [inner_eq_zero_symm]
exact this _ _ hb
clear h₀ a b
intro a b h₀
revert a
apply wellFounded_lt.induction b
intro b ih a h₀
simp only [gramSchmidt_def 𝕜 f b, inner_sub_right, inner_sum,
starProjection_singleton, inner_smul_right]
rw [Finset.sum_eq_single_of_mem a (Finset.mem_Iio.mpr h₀)]
· by_cases h : gramSchmidt 𝕜 f a = 0
· simp only [h, inner_zero_left, zero_div, zero_mul, sub_zero]
· rw [RCLike.ofReal_pow, ← inner_self_eq_norm_sq_to_K, div_mul_cancel₀, sub_self]
rwa [inner_self_ne_zero]
intro i hi hia
simp only [mul_eq_zero, div_eq_zero_iff]
right
rcases hia.lt_or_gt with hia₁ | hia₂
· rw [inner_eq_zero_symm]
exact ih a h₀ i hia₁
· exact ih i (mem_Iio.1 hi) a hia₂
/-- This is another version of `gramSchmidt_orthogonal` using `Pairwise` instead. -/
theorem gramSchmidt_pairwise_orthogonal (f : ι → E) :
Pairwise fun a b => ⟪gramSchmidt 𝕜 f a, gramSchmidt 𝕜 f b⟫ = 0 := fun _ _ =>
gramSchmidt_orthogonal 𝕜 f
theorem gramSchmidt_inv_triangular (v : ι → E) {i j : ι} (hij : i < j) :
⟪gramSchmidt 𝕜 v j, v i⟫ = 0 := by
rw [gramSchmidt_def'' 𝕜 v]
simp only [inner_add_right, inner_sum, inner_smul_right]
set b : ι → E := gramSchmidt 𝕜 v
convert zero_add (0 : 𝕜)
· exact gramSchmidt_orthogonal 𝕜 v hij.ne'
apply Finset.sum_eq_zero
rintro k hki'
have hki : k < i := by simpa using hki'
have : ⟪b j, b k⟫ = 0 := gramSchmidt_orthogonal 𝕜 v (hki.trans hij).ne'
simp [this]
open Submodule Set Order
theorem mem_span_gramSchmidt (f : ι → E) {i j : ι} (hij : i ≤ j) :
f i ∈ span 𝕜 (gramSchmidt 𝕜 f '' Set.Iic j) := by
rw [gramSchmidt_def' 𝕜 f i]
simp_rw [starProjection_singleton]
exact Submodule.add_mem _ (subset_span <| mem_image_of_mem _ hij)
(Submodule.sum_mem _ fun k hk => smul_mem (span 𝕜 (gramSchmidt 𝕜 f '' Set.Iic j)) _ <|
subset_span <| mem_image_of_mem (gramSchmidt 𝕜 f) <| (Finset.mem_Iio.1 hk).le.trans hij)
theorem gramSchmidt_mem_span (f : ι → E) :
∀ {j i}, i ≤ j → gramSchmidt 𝕜 f i ∈ span 𝕜 (f '' Set.Iic j) := by
intro j i hij
rw [gramSchmidt_def 𝕜 f i]
simp_rw [starProjection_singleton]
refine Submodule.sub_mem _ (subset_span (mem_image_of_mem _ hij))
(Submodule.sum_mem _ fun k hk => ?_)
let hkj : k < j := (Finset.mem_Iio.1 hk).trans_le hij
exact smul_mem _ _
(span_mono (image_mono <| Set.Iic_subset_Iic.2 hkj.le) <| gramSchmidt_mem_span _ le_rfl)
termination_by j => j
theorem span_gramSchmidt_Iic (f : ι → E) (c : ι) :
span 𝕜 (gramSchmidt 𝕜 f '' Set.Iic c) = span 𝕜 (f '' Set.Iic c) :=
span_eq_span (Set.image_subset_iff.2 fun _ => gramSchmidt_mem_span _ _) <|
Set.image_subset_iff.2 fun _ => mem_span_gramSchmidt _ _
theorem span_gramSchmidt_Iio (f : ι → E) (c : ι) :
span 𝕜 (gramSchmidt 𝕜 f '' Set.Iio c) = span 𝕜 (f '' Set.Iio c) :=
span_eq_span (Set.image_subset_iff.2 fun _ hi =>
span_mono (image_mono <| Iic_subset_Iio.2 hi) <| gramSchmidt_mem_span _ _ le_rfl) <|
Set.image_subset_iff.2 fun _ hi =>
span_mono (image_mono <| Iic_subset_Iio.2 hi) <| mem_span_gramSchmidt _ _ le_rfl
/-- `gramSchmidt` preserves span of vectors. -/
theorem span_gramSchmidt (f : ι → E) : span 𝕜 (range (gramSchmidt 𝕜 f)) = span 𝕜 (range f) :=
span_eq_span (range_subset_iff.2 fun _ =>
span_mono (image_subset_range _ _) <| gramSchmidt_mem_span _ _ le_rfl) <|
range_subset_iff.2 fun _ =>
span_mono (image_subset_range _ _) <| mem_span_gramSchmidt _ _ le_rfl
/-- If given an orthogonal set of vectors, `gramSchmidt` fixes its input. -/
theorem gramSchmidt_of_orthogonal {f : ι → E} (hf : Pairwise (⟪f ·, f ·⟫ = 0)) :
gramSchmidt 𝕜 f = f := by
ext i
rw [gramSchmidt_def]
trans f i - 0
· congr
apply Finset.sum_eq_zero
intro j hj
rw [Submodule.starProjection_apply, Submodule.coe_eq_zero]
suffices span 𝕜 (f '' Set.Iic j) ⟂ 𝕜 ∙ f i by
apply orthogonalProjection_mem_subspace_orthogonalComplement_eq_zero
rw [mem_orthogonal_singleton_iff_inner_left, ← mem_orthogonal_singleton_iff_inner_right]
exact this (gramSchmidt_mem_span 𝕜 f (le_refl j))
rw [isOrtho_span]
rintro u ⟨k, hk, rfl⟩ v (rfl : v = f i)
apply hf
exact (lt_of_le_of_lt hk (Finset.mem_Iio.mp hj)).ne
· simp
variable {𝕜}
theorem gramSchmidt_ne_zero_coe {f : ι → E} (n : ι)
(h₀ : LinearIndependent 𝕜 (f ∘ ((↑) : Set.Iic n → ι))) : gramSchmidt 𝕜 f n ≠ 0 := by
by_contra h
have h₁ : f n ∈ span 𝕜 (f '' Set.Iio n) := by
rw [← span_gramSchmidt_Iio 𝕜 f n, gramSchmidt_def' 𝕜 f, h, zero_add]
apply Submodule.sum_mem _ _
intro a ha
simp only [starProjection_singleton]
apply Submodule.smul_mem _ _ _
rw [Finset.mem_Iio] at ha
exact subset_span ⟨a, ha, by rfl⟩
have h₂ : (f ∘ ((↑) : Set.Iic n → ι)) ⟨n, le_refl n⟩ ∈
span 𝕜 (f ∘ ((↑) : Set.Iic n → ι) '' Set.Iio ⟨n, le_refl n⟩) := by
rw [image_comp]
simpa using h₁
apply LinearIndependent.notMem_span_image h₀ _ h₂
simp only [Set.mem_Iio, lt_self_iff_false, not_false_iff]
/-- If the input vectors of `gramSchmidt` are linearly independent,
then the output vectors are non-zero. -/
theorem gramSchmidt_ne_zero {f : ι → E} (n : ι) (h₀ : LinearIndependent 𝕜 f) :
gramSchmidt 𝕜 f n ≠ 0 :=
gramSchmidt_ne_zero_coe _ (LinearIndependent.comp h₀ _ Subtype.coe_injective)
/-- `gramSchmidt` produces a triangular matrix of vectors when given a basis. -/
theorem gramSchmidt_triangular {i j : ι} (hij : i < j) (b : Basis ι 𝕜 E) :
b.repr (gramSchmidt 𝕜 b i) j = 0 := by
have : gramSchmidt 𝕜 b i ∈ span 𝕜 (gramSchmidt 𝕜 b '' Set.Iio j) :=
subset_span ((Set.mem_image _ _ _).2 ⟨i, hij, rfl⟩)
have : gramSchmidt 𝕜 b i ∈ span 𝕜 (b '' Set.Iio j) := by rwa [← span_gramSchmidt_Iio 𝕜 b j]
have : ↑(b.repr (gramSchmidt 𝕜 b i)).support ⊆ Set.Iio j :=
Basis.repr_support_subset_of_mem_span b (Set.Iio j) this
exact (Finsupp.mem_supported' _ _).1 ((Finsupp.mem_supported 𝕜 _).2 this) j Set.notMem_Iio_self
/-- `gramSchmidt` produces linearly independent vectors when given linearly independent vectors. -/
theorem gramSchmidt_linearIndependent {f : ι → E} (h₀ : LinearIndependent 𝕜 f) :
LinearIndependent 𝕜 (gramSchmidt 𝕜 f) :=
linearIndependent_of_ne_zero_of_inner_eq_zero (fun _ => gramSchmidt_ne_zero _ h₀) fun _ _ =>
gramSchmidt_orthogonal 𝕜 f
/-- When given a basis, `gramSchmidt` produces a basis. -/
noncomputable def gramSchmidtBasis (b : Basis ι 𝕜 E) : Basis ι 𝕜 E :=
Basis.mk (gramSchmidt_linearIndependent b.linearIndependent)
((span_gramSchmidt 𝕜 b).trans b.span_eq).ge
theorem coe_gramSchmidtBasis (b : Basis ι 𝕜 E) : (gramSchmidtBasis b : ι → E) = gramSchmidt 𝕜 b :=
Basis.coe_mk _ _
variable (𝕜) in
/-- the normalized `gramSchmidt` (i.e each vector in `gramSchmidtNormed` has unit length.) -/
noncomputable def gramSchmidtNormed (f : ι → E) (n : ι) : E :=
(‖gramSchmidt 𝕜 f n‖ : 𝕜)⁻¹ • gramSchmidt 𝕜 f n
theorem gramSchmidtNormed_unit_length_coe {f : ι → E} (n : ι)
(h₀ : LinearIndependent 𝕜 (f ∘ ((↑) : Set.Iic n → ι))) : ‖gramSchmidtNormed 𝕜 f n‖ = 1 := by
simp only [gramSchmidt_ne_zero_coe n h₀, gramSchmidtNormed, norm_smul_inv_norm, Ne,
not_false_iff]
theorem gramSchmidtNormed_unit_length {f : ι → E} (n : ι) (h₀ : LinearIndependent 𝕜 f) :
‖gramSchmidtNormed 𝕜 f n‖ = 1 :=
gramSchmidtNormed_unit_length_coe _ (LinearIndependent.comp h₀ _ Subtype.coe_injective)
theorem gramSchmidtNormed_unit_length' {f : ι → E} {n : ι} (hn : gramSchmidtNormed 𝕜 f n ≠ 0) :
‖gramSchmidtNormed 𝕜 f n‖ = 1 := by
rw [gramSchmidtNormed] at *
rw [norm_smul_inv_norm]
simpa using hn
/-- **Gram-Schmidt Orthonormalization**:
`gramSchmidtNormed` applied to a linearly independent set of vectors produces an orthornormal
system of vectors. -/
theorem gramSchmidtNormed_orthonormal {f : ι → E} (h₀ : LinearIndependent 𝕜 f) :
Orthonormal 𝕜 (gramSchmidtNormed 𝕜 f) := by
unfold Orthonormal
constructor
· simp only [gramSchmidtNormed_unit_length, h₀, imp_true_iff]
· intro i j hij
simp only [gramSchmidtNormed, inner_smul_left, inner_smul_right, RCLike.conj_inv,
RCLike.conj_ofReal, mul_eq_zero, inv_eq_zero, RCLike.ofReal_eq_zero, norm_eq_zero]
repeat' right
exact gramSchmidt_orthogonal 𝕜 f hij
@[deprecated (since := "2025-07-10")] alias gramSchmidt_orthonormal := gramSchmidtNormed_orthonormal
/-- **Gram-Schmidt Orthonormalization**:
`gramSchmidtNormed` produces an orthornormal system of vectors after removing the vectors which
become zero in the process. -/
theorem gramSchmidtNormed_orthonormal' (f : ι → E) :
Orthonormal 𝕜 fun i : { i | gramSchmidtNormed 𝕜 f i ≠ 0 } => gramSchmidtNormed 𝕜 f i := by
refine ⟨fun i => gramSchmidtNormed_unit_length' i.prop, ?_⟩
rintro i j (hij : ¬_)
rw [Subtype.ext_iff] at hij
simp [gramSchmidtNormed, inner_smul_left, inner_smul_right, gramSchmidt_orthogonal 𝕜 f hij]
@[deprecated (since := "2025-07-10")]
alias gramSchmidt_orthonormal' := gramSchmidtNormed_orthonormal'
open Submodule Set Order
theorem span_gramSchmidtNormed (f : ι → E) (s : Set ι) :
span 𝕜 (gramSchmidtNormed 𝕜 f '' s) = span 𝕜 (gramSchmidt 𝕜 f '' s) := by
refine span_eq_span
(Set.image_subset_iff.2 fun i hi => smul_mem _ _ <| subset_span <| mem_image_of_mem _ hi)
(Set.image_subset_iff.2 fun i hi =>
span_mono (image_mono <| singleton_subset_set_iff.2 hi) ?_)
simp only [coe_singleton, Set.image_singleton]
by_cases h : gramSchmidt 𝕜 f i = 0
· simp [h]
· refine mem_span_singleton.2 ⟨‖gramSchmidt 𝕜 f i‖, smul_inv_smul₀ ?_ _⟩
exact mod_cast norm_ne_zero_iff.2 h
theorem span_gramSchmidtNormed_range (f : ι → E) :
span 𝕜 (range (gramSchmidtNormed 𝕜 f)) = span 𝕜 (range (gramSchmidt 𝕜 f)) := by
simpa only [image_univ.symm] using span_gramSchmidtNormed f univ
/-- `gramSchmidtNormed` produces linearly independent vectors when given linearly independent
vectors. -/
theorem gramSchmidtNormed_linearIndependent {f : ι → E} (h₀ : LinearIndependent 𝕜 f) :
LinearIndependent 𝕜 (gramSchmidtNormed 𝕜 f) := by
unfold gramSchmidtNormed
have (i : ι) : IsUnit (‖gramSchmidt 𝕜 f i‖⁻¹ : 𝕜) :=
isUnit_iff_ne_zero.mpr (by simp [gramSchmidt_ne_zero i h₀])
let w : ι → 𝕜ˣ := fun i ↦ (this i).unit
apply (gramSchmidt_linearIndependent h₀).units_smul (w := fun i ↦ (this i).unit)
section OrthonormalBasis
variable [Fintype ι] [FiniteDimensional 𝕜 E] (h : finrank 𝕜 E = Fintype.card ι) (f : ι → E)
/-- Given an indexed family `f : ι → E` of vectors in an inner product space `E`, for which the
size of the index set is the dimension of `E`, produce an orthonormal basis for `E` which agrees
with the orthonormal set produced by the Gram-Schmidt orthonormalization process on the elements of
`ι` for which this process gives a nonzero number. -/
noncomputable def gramSchmidtOrthonormalBasis : OrthonormalBasis ι 𝕜 E :=
((gramSchmidtNormed_orthonormal' f).exists_orthonormalBasis_extension_of_card_eq
(v := gramSchmidtNormed 𝕜 f) h).choose
theorem gramSchmidtOrthonormalBasis_apply {f : ι → E} {i : ι} (hi : gramSchmidtNormed 𝕜 f i ≠ 0) :
gramSchmidtOrthonormalBasis h f i = gramSchmidtNormed 𝕜 f i :=
((gramSchmidtNormed_orthonormal' f).exists_orthonormalBasis_extension_of_card_eq
(v := gramSchmidtNormed 𝕜 f) h).choose_spec i hi
theorem gramSchmidtOrthonormalBasis_apply_of_orthogonal {f : ι → E}
(hf : Pairwise fun i j => ⟪f i, f j⟫ = 0) {i : ι} (hi : f i ≠ 0) :
gramSchmidtOrthonormalBasis h f i = (‖f i‖⁻¹ : 𝕜) • f i := by
have H : gramSchmidtNormed 𝕜 f i = (‖f i‖⁻¹ : 𝕜) • f i := by
rw [gramSchmidtNormed, gramSchmidt_of_orthogonal 𝕜 hf]
rw [gramSchmidtOrthonormalBasis_apply h, H]
simpa [H] using hi
theorem inner_gramSchmidtOrthonormalBasis_eq_zero {f : ι → E} {i : ι}
(hi : gramSchmidtNormed 𝕜 f i = 0) (j : ι) : ⟪gramSchmidtOrthonormalBasis h f i, f j⟫ = 0 := by
rw [← mem_orthogonal_singleton_iff_inner_right]
suffices span 𝕜 (gramSchmidtNormed 𝕜 f '' Set.Iic j) ⟂ 𝕜 ∙ gramSchmidtOrthonormalBasis h f i by
apply this
rw [span_gramSchmidtNormed]
exact mem_span_gramSchmidt 𝕜 f le_rfl
rw [isOrtho_span]
rintro u ⟨k, _, rfl⟩ v (rfl : v = _)
by_cases hk : gramSchmidtNormed 𝕜 f k = 0
· rw [hk, inner_zero_left]
rw [← gramSchmidtOrthonormalBasis_apply h hk]
have : k ≠ i := by
rintro rfl
exact hk hi
exact (gramSchmidtOrthonormalBasis h f).orthonormal.2 this
theorem gramSchmidtOrthonormalBasis_inv_triangular {i j : ι} (hij : i < j) :
⟪gramSchmidtOrthonormalBasis h f j, f i⟫ = 0 := by
by_cases hi : gramSchmidtNormed 𝕜 f j = 0
· rw [inner_gramSchmidtOrthonormalBasis_eq_zero h hi]
· simp [gramSchmidtOrthonormalBasis_apply h hi, gramSchmidtNormed, inner_smul_left,
gramSchmidt_inv_triangular 𝕜 f hij]
theorem gramSchmidtOrthonormalBasis_inv_triangular' {i j : ι} (hij : i < j) :
(gramSchmidtOrthonormalBasis h f).repr (f i) j = 0 := by
simpa [OrthonormalBasis.repr_apply_apply] using gramSchmidtOrthonormalBasis_inv_triangular h f hij
/-- Given an indexed family `f : ι → E` of vectors in an inner product space `E`, for which the
size of the index set is the dimension of `E`, the matrix of coefficients of `f` with respect to the
orthonormal basis `gramSchmidtOrthonormalBasis` constructed from `f` is upper-triangular. -/
theorem gramSchmidtOrthonormalBasis_inv_blockTriangular :
((gramSchmidtOrthonormalBasis h f).toBasis.toMatrix f).BlockTriangular id := fun _ _ =>
gramSchmidtOrthonormalBasis_inv_triangular' h f
theorem gramSchmidtOrthonormalBasis_det [DecidableEq ι] :
(gramSchmidtOrthonormalBasis h f).toBasis.det f =
∏ i, ⟪gramSchmidtOrthonormalBasis h f i, f i⟫ := by
convert Matrix.det_of_upperTriangular (gramSchmidtOrthonormalBasis_inv_blockTriangular h f)
exact ((gramSchmidtOrthonormalBasis h f).repr_apply_apply (f _) _).symm
end OrthonormalBasis
end InnerProductSpace |
.lake/packages/mathlib/Mathlib/Analysis/InnerProductSpace/EuclideanDist.lean | import Mathlib.Analysis.InnerProductSpace.Calculus
import Mathlib.Analysis.InnerProductSpace.PiL2
import Mathlib.Topology.MetricSpace.ProperSpace.Lemmas
/-!
# Euclidean distance on a finite-dimensional space
When we define a smooth bump function on a normed space, it is useful to have a smooth distance on
the space. Since the default distance is not guaranteed to be smooth, we define `toEuclidean` to be
an equivalence between a finite-dimensional topological vector space and the standard Euclidean
space of the same dimension.
Then we define `Euclidean.dist x y = dist (toEuclidean x) (toEuclidean y)` and
provide some definitions (`Euclidean.ball`, `Euclidean.closedBall`) and simple lemmas about this
distance. This way we hide the usage of `toEuclidean` behind an API.
-/
open scoped Topology
open Set
variable {E : Type*} [AddCommGroup E] [TopologicalSpace E] [IsTopologicalAddGroup E] [T2Space E]
[Module ℝ E] [ContinuousSMul ℝ E] [FiniteDimensional ℝ E]
noncomputable section
open Module
/-- If `E` is a finite-dimensional space over `ℝ`, then `toEuclidean` is a continuous `ℝ`-linear
equivalence between `E` and the Euclidean space of the same dimension. -/
def toEuclidean : E ≃L[ℝ] EuclideanSpace ℝ (Fin <| finrank ℝ E) :=
ContinuousLinearEquiv.ofFinrankEq finrank_euclideanSpace_fin.symm
namespace Euclidean
/-- If `x` and `y` are two points in a finite-dimensional space over `ℝ`, then `Euclidean.dist x y`
is the distance between these points in the metric defined by some inner product space structure on
`E`. -/
nonrec def dist (x y : E) : ℝ :=
dist (toEuclidean x) (toEuclidean y)
/-- Closed ball w.r.t. the Euclidean distance. -/
def closedBall (x : E) (r : ℝ) : Set E :=
{y | dist y x ≤ r}
/-- Open ball w.r.t. the Euclidean distance. -/
def ball (x : E) (r : ℝ) : Set E :=
{y | dist y x < r}
theorem ball_eq_preimage (x : E) (r : ℝ) :
ball x r = toEuclidean ⁻¹' Metric.ball (toEuclidean x) r :=
rfl
theorem closedBall_eq_preimage (x : E) (r : ℝ) :
closedBall x r = toEuclidean ⁻¹' Metric.closedBall (toEuclidean x) r :=
rfl
theorem ball_subset_closedBall {x : E} {r : ℝ} : ball x r ⊆ closedBall x r := fun _ (hy : _ < r) =>
le_of_lt hy
@[simp] theorem isOpen_ball {x : E} {r : ℝ} : IsOpen (ball x r) :=
Metric.isOpen_ball.preimage toEuclidean.continuous
theorem mem_ball_self {x : E} {r : ℝ} (hr : 0 < r) : x ∈ ball x r :=
Metric.mem_ball_self hr
theorem closedBall_eq_image (x : E) (r : ℝ) :
closedBall x r = toEuclidean.symm '' Metric.closedBall (toEuclidean x) r := by
rw [toEuclidean.image_symm_eq_preimage, closedBall_eq_preimage]
nonrec theorem isCompact_closedBall {x : E} {r : ℝ} : IsCompact (closedBall x r) := by
rw [closedBall_eq_image]
exact (isCompact_closedBall _ _).image toEuclidean.symm.continuous
theorem isClosed_closedBall {x : E} {r : ℝ} : IsClosed (closedBall x r) :=
isCompact_closedBall.isClosed
nonrec theorem closure_ball (x : E) {r : ℝ} (h : r ≠ 0) : closure (ball x r) = closedBall x r := by
rw [ball_eq_preimage, ← toEuclidean.preimage_closure, closure_ball (toEuclidean x) h,
closedBall_eq_preimage]
nonrec theorem exists_pos_lt_subset_ball {R : ℝ} {s : Set E} {x : E} (hR : 0 < R) (hs : IsClosed s)
(h : s ⊆ ball x R) : ∃ r ∈ Ioo 0 R, s ⊆ ball x r := by
rw [ball_eq_preimage, ← image_subset_iff] at h
rcases exists_pos_lt_subset_ball hR (toEuclidean.isClosed_image.2 hs) h with ⟨r, hr, hsr⟩
exact ⟨r, hr, image_subset_iff.1 hsr⟩
theorem nhds_basis_closedBall {x : E} : (𝓝 x).HasBasis (fun r : ℝ => 0 < r) (closedBall x) := by
rw [toEuclidean.toHomeomorph.nhds_eq_comap x]
exact Metric.nhds_basis_closedBall.comap _
theorem closedBall_mem_nhds {x : E} {r : ℝ} (hr : 0 < r) : closedBall x r ∈ 𝓝 x :=
nhds_basis_closedBall.mem_of_mem hr
theorem nhds_basis_ball {x : E} : (𝓝 x).HasBasis (fun r : ℝ => 0 < r) (ball x) := by
rw [toEuclidean.toHomeomorph.nhds_eq_comap x]
exact Metric.nhds_basis_ball.comap _
theorem ball_mem_nhds {x : E} {r : ℝ} (hr : 0 < r) : ball x r ∈ 𝓝 x :=
nhds_basis_ball.mem_of_mem hr
end Euclidean
variable {F : Type*} [NormedAddCommGroup F] [NormedSpace ℝ F] {G : Type*} [NormedAddCommGroup G]
[NormedSpace ℝ G] [FiniteDimensional ℝ G] {f g : F → G} {n : ℕ∞}
theorem ContDiff.euclidean_dist (hf : ContDiff ℝ n f) (hg : ContDiff ℝ n g) (h : ∀ x, f x ≠ g x) :
ContDiff ℝ n fun x => Euclidean.dist (f x) (g x) := by
simp only [Euclidean.dist]
apply ContDiff.dist ℝ
exacts [(toEuclidean (E := G)).contDiff.comp hf,
(toEuclidean (E := G)).contDiff.comp hg, fun x => toEuclidean.injective.ne (h x)] |
.lake/packages/mathlib/Mathlib/Analysis/InnerProductSpace/JointEigenspace.lean | import Mathlib.Analysis.InnerProductSpace.Spectrum
import Mathlib.LinearAlgebra.Eigenspace.Pi
import Mathlib.LinearAlgebra.Eigenspace.Semisimple
import Mathlib.Analysis.InnerProductSpace.Semisimple
/-! # Joint eigenspaces of commuting symmetric operators
This file collects various decomposition results for joint eigenspaces of commuting
symmetric operators on a finite-dimensional inner product space.
## Main Result
* `LinearMap.IsSymmetric.directSum_isInternal_of_commute` establishes that in finite dimensions
if `{A B : E →ₗ[𝕜] E}`, then `IsSymmetric A`, `IsSymmetric B` and `Commute A B` imply that
`E` decomposes as an internal direct sum of the pairwise orthogonal spaces
`eigenspace B μ ⊓ eigenspace A ν`
* `LinearMap.IsSymmetric.iSup_iInf_eigenspace_eq_top_of_commute` establishes that in finite
dimensions, the indexed supremum of the joint eigenspaces of a commuting tuple of symmetric
linear operators equals `⊤`
* `LinearMap.IsSymmetric.directSum_isInternal_of_pairwise_commute` establishes the
analogous result to `LinearMap.IsSymmetric.directSum_isInternal_of_commute` for commuting
tuples of symmetric operators.
## TODO
Develop a `Diagonalization` structure for linear maps and / or matrices which consists of a basis,
and a proof obligation that the basis vectors are eigenvectors.
## Tags
symmetric operator, simultaneous eigenspaces, joint eigenspaces
-/
open Module.End
namespace LinearMap
namespace IsSymmetric
variable {𝕜 E n m : Type*}
open Submodule
section RCLike
variable [RCLike 𝕜] [NormedAddCommGroup E] [InnerProductSpace 𝕜 E]
variable {α : 𝕜} {A B : E →ₗ[𝕜] E} {T : n → Module.End 𝕜 E}
/-- The joint eigenspaces of a pair of symmetric operators form an
`OrthogonalFamily`. -/
theorem orthogonalFamily_eigenspace_inf_eigenspace (hA : A.IsSymmetric) (hB : B.IsSymmetric) :
OrthogonalFamily 𝕜 (fun (i : 𝕜 × 𝕜) => (eigenspace A i.2 ⊓ eigenspace B i.1 : Submodule 𝕜 E))
fun i => (eigenspace A i.2 ⊓ eigenspace B i.1).subtypeₗᵢ :=
OrthogonalFamily.of_pairwise fun i j hij v ⟨hv1, hv2⟩ ↦ by
obtain (h₁ | h₂) : i.1 ≠ j.1 ∨ i.2 ≠ j.2 := by rwa [Ne.eq_def, Prod.ext_iff, not_and_or] at hij
all_goals intro w ⟨hw1, hw2⟩
· exact hB.orthogonalFamily_eigenspaces.pairwise h₁ hv2 w hw2
· exact hA.orthogonalFamily_eigenspaces.pairwise h₂ hv1 w hw1
/-- The joint eigenspaces of a family of symmetric operators form an
`OrthogonalFamily`. -/
theorem orthogonalFamily_iInf_eigenspaces (hT : ∀ i, (T i).IsSymmetric) :
OrthogonalFamily 𝕜 (fun γ : n → 𝕜 ↦ (⨅ j, eigenspace (T j) (γ j) : Submodule 𝕜 E))
fun γ : n → 𝕜 ↦ (⨅ j, eigenspace (T j) (γ j)).subtypeₗᵢ := by
intro f g hfg Ef Eg
obtain ⟨a, ha⟩ := Function.ne_iff.mp hfg
have H := orthogonalFamily_eigenspaces (hT a) ha
simp only [Submodule.coe_subtypeₗᵢ, Submodule.coe_subtype, Subtype.forall] at H
apply H
· exact (Submodule.mem_iInf <| fun _ ↦ eigenspace (T _) (f _)).mp Ef.2 _
· exact (Submodule.mem_iInf <| fun _ ↦ eigenspace (T _) (g _)).mp Eg.2 _
variable [FiniteDimensional 𝕜 E]
open IsFinitelySemisimple
/-- If A and B are commuting symmetric operators on a finite-dimensional inner product space
then the eigenspaces of the restriction of B to any eigenspace of A exhaust that eigenspace. -/
theorem iSup_eigenspace_inf_eigenspace_of_commute (hB : B.IsSymmetric) (hAB : Commute A B) :
(⨆ γ, eigenspace A α ⊓ eigenspace B γ) = eigenspace A α := by
conv_rhs => rw [← (eigenspace A α).map_subtype_top]
simp only [← Submodule.map_iSup,
(eigenspace A α).inf_genEigenspace _ (mapsTo_genEigenspace_of_comm hAB α 1)]
congr 1
simpa only [genEigenspace_eq_eigenspace, Submodule.orthogonal_eq_bot_iff]
using orthogonalComplement_iSup_eigenspaces_eq_bot <|
hB.restrict_invariant <| mapsTo_genEigenspace_of_comm hAB α 1
/-- If A and B are commuting symmetric operators acting on a finite-dimensional inner product space,
then the simultaneous eigenspaces of A and B exhaust the space. -/
theorem iSup_iSup_eigenspace_inf_eigenspace_eq_top_of_commute (hA : A.IsSymmetric)
(hB : B.IsSymmetric) (hAB : Commute A B) :
(⨆ α, ⨆ γ, eigenspace A α ⊓ eigenspace B γ) = ⊤ := by
simpa [iSup_eigenspace_inf_eigenspace_of_commute hB hAB] using
Submodule.orthogonal_eq_bot_iff.mp <| hA.orthogonalComplement_iSup_eigenspaces_eq_bot
/-- Given a commuting pair of symmetric linear operators on a finite-dimensional inner product
space, the space decomposes as an internal direct sum of simultaneous eigenspaces of these
operators. -/
theorem directSum_isInternal_of_commute (hA : A.IsSymmetric) (hB : B.IsSymmetric)
(hAB : Commute A B) :
DirectSum.IsInternal (fun (i : 𝕜 × 𝕜) ↦ (eigenspace A i.2 ⊓ eigenspace B i.1)):= by
apply (orthogonalFamily_eigenspace_inf_eigenspace hA hB).isInternal_iff.mpr
rw [Submodule.orthogonal_eq_bot_iff, iSup_prod, iSup_comm]
exact iSup_iSup_eigenspace_inf_eigenspace_eq_top_of_commute hA hB hAB
open scoped Function -- required for scoped `on` notation
/-- A commuting family of symmetric linear maps on a finite-dimensional inner
product space is simultaneously diagonalizable. -/
theorem iSup_iInf_eq_top_of_commute {ι : Type*} {T : ι → E →ₗ[𝕜] E}
(hT : ∀ i, (T i).IsSymmetric) (h : Pairwise (Commute on T)) :
⨆ χ : ι → 𝕜, ⨅ i, eigenspace (T i) (χ i) = ⊤ :=
calc
_ = ⨆ χ : ι → 𝕜, ⨅ i, maxGenEigenspace (T i) (χ i) :=
congr(⨆ χ : ι → 𝕜, ⨅ i,
$(maxGenEigenspace_eq_eigenspace (isFinitelySemisimple <| hT _) (χ _))).symm
_ = ⊤ :=
iSup_iInf_maxGenEigenspace_eq_top_of_iSup_maxGenEigenspace_eq_top_of_commute T h fun _ ↦ by
rw [← orthogonal_eq_bot_iff,
congr(⨆ μ, $(maxGenEigenspace_eq_eigenspace (isFinitelySemisimple <| hT _) μ)),
(hT _).orthogonalComplement_iSup_eigenspaces_eq_bot]
/-- In finite dimensions, given a commuting family of symmetric linear operators, the inner
product space on which they act decomposes as an internal direct sum of joint eigenspaces. -/
theorem LinearMap.IsSymmetric.directSum_isInternal_of_pairwise_commute [DecidableEq (n → 𝕜)]
(hT : ∀ i, (T i).IsSymmetric) (hC : Pairwise (Commute on T)) :
DirectSum.IsInternal (fun α : n → 𝕜 ↦ ⨅ j, eigenspace (T j) (α j)) := by
rw [OrthogonalFamily.isInternal_iff]
· rw [iSup_iInf_eq_top_of_commute hT hC, top_orthogonal_eq_bot]
· exact orthogonalFamily_iInf_eigenspaces hT
end RCLike
end IsSymmetric
end LinearMap |
.lake/packages/mathlib/Mathlib/Analysis/InnerProductSpace/OfNorm.lean | import Mathlib.Topology.Algebra.Algebra
import Mathlib.Analysis.InnerProductSpace.Convex
import Mathlib.Algebra.Module.LinearMap.Rat
import Mathlib.Tactic.Module
/-!
# Inner product space derived from a norm
This file defines an `InnerProductSpace` instance from a norm that respects the
parallellogram identity. The parallelogram identity is a way to express the inner product of `x` and
`y` in terms of the norms of `x`, `y`, `x + y`, `x - y`.
## Main results
- `InnerProductSpace.ofNorm`: a normed space whose norm respects the parallellogram identity,
can be seen as an inner product space.
## Implementation notes
We define `inner_`
$$\langle x, y \rangle := \frac{1}{4} (‖x + y‖^2 - ‖x - y‖^2 + i ‖ix + y‖ ^ 2 - i ‖ix - y‖^2)$$
and use the parallelogram identity
$$‖x + y‖^2 + ‖x - y‖^2 = 2 (‖x‖^2 + ‖y‖^2)$$
to prove it is an inner product, i.e., that it is conjugate-symmetric (`inner_.conj_symm`) and
linear in the first argument. `add_left` is proved by judicious application of the parallelogram
identity followed by tedious arithmetic. `smul_left` is proved step by step, first noting that
$\langle λ x, y \rangle = λ \langle x, y \rangle$ for $λ ∈ ℕ$, $λ = -1$, hence $λ ∈ ℤ$ and $λ ∈ ℚ$
by arithmetic. Then by continuity and the fact that ℚ is dense in ℝ, the same is true for ℝ.
The case of ℂ then follows by applying the result for ℝ and more arithmetic.
## TODO
Move upstream to `Analysis.InnerProductSpace.Basic`.
## References
- [Jordan, P. and von Neumann, J., *On inner products in linear, metric spaces*][Jordan1935]
- https://math.stackexchange.com/questions/21792/norms-induced-by-inner-products-and-the-parallelogram-law
- https://math.dartmouth.edu/archive/m113w10/public_html/jordan-vneumann-thm.pdf
## Tags
inner product space, Hilbert space, norm
-/
open RCLike
open scoped ComplexConjugate
variable {𝕜 : Type*} [RCLike 𝕜] (E : Type*) [NormedAddCommGroup E]
/-- Predicate for the parallelogram identity to hold in a normed group. This is a scalar-less
version of `InnerProductSpace`. If you have an `InnerProductSpaceable` assumption, you can
locally upgrade that to `InnerProductSpace 𝕜 E` using `casesI nonempty_innerProductSpace 𝕜 E`.
-/
class InnerProductSpaceable : Prop where
parallelogram_identity :
∀ x y : E, ‖x + y‖ * ‖x + y‖ + ‖x - y‖ * ‖x - y‖ = 2 * (‖x‖ * ‖x‖ + ‖y‖ * ‖y‖)
variable (𝕜) {E}
theorem InnerProductSpace.toInnerProductSpaceable [InnerProductSpace 𝕜 E] :
InnerProductSpaceable E :=
⟨parallelogram_law_with_norm 𝕜⟩
-- See note [lower instance priority]
instance (priority := 100) InnerProductSpace.toInnerProductSpaceable_ofReal
[InnerProductSpace ℝ E] : InnerProductSpaceable E :=
⟨parallelogram_law_with_norm ℝ⟩
variable [NormedSpace 𝕜 E]
local notation "𝓚" => algebraMap ℝ 𝕜
/-- Auxiliary definition of the inner product derived from the norm. -/
private noncomputable def inner_ (x y : E) : 𝕜 :=
4⁻¹ * (𝓚 ‖x + y‖ * 𝓚 ‖x + y‖ - 𝓚 ‖x - y‖ * 𝓚 ‖x - y‖ +
(I : 𝕜) * 𝓚 ‖(I : 𝕜) • x + y‖ * 𝓚 ‖(I : 𝕜) • x + y‖ -
(I : 𝕜) * 𝓚 ‖(I : 𝕜) • x - y‖ * 𝓚 ‖(I : 𝕜) • x - y‖)
namespace InnerProductSpaceable
variable {𝕜} (E)
-- This has a prime added to avoid clashing with public `innerProp`
/-- Auxiliary definition for the `add_left` property. -/
private def innerProp' (r : 𝕜) : Prop :=
∀ x y : E, inner_ 𝕜 (r • x) y = conj r * inner_ 𝕜 x y
variable {E}
theorem _root_.Continuous.inner_ {f g : ℝ → E} (hf : Continuous f) (hg : Continuous g) :
Continuous fun x => inner_ 𝕜 (f x) (g x) := by
unfold _root_.inner_
fun_prop
theorem inner_.norm_sq (x : E) : ‖x‖ ^ 2 = re (inner_ 𝕜 x x) := by
simp only [inner_, normSq_apply, ofNat_re, ofNat_im, map_sub, map_add,
ofReal_re, ofReal_im, mul_re, inv_re, mul_im, I_re, inv_im]
have h₁ : ‖x - x‖ = 0 := by simp
have h₂ : ‖x + x‖ = 2 • ‖x‖ := by convert norm_nsmul 𝕜 2 x using 2; module
rw [h₁, h₂]
ring
theorem inner_.conj_symm (x y : E) : conj (inner_ 𝕜 y x) = inner_ 𝕜 x y := by
simp only [inner_, map_sub, map_add, map_mul, map_inv₀, map_ofNat, conj_ofReal, conj_I]
rw [add_comm y x, norm_sub_rev]
by_cases hI : (I : 𝕜) = 0
· simp only [hI, neg_zero, zero_mul]
have hI' := I_mul_I_of_nonzero hI
have I_smul (v : E) : ‖(I : 𝕜) • v‖ = ‖v‖ := by rw [norm_smul, norm_I_of_ne_zero hI, one_mul]
have h₁ : ‖(I : 𝕜) • y - x‖ = ‖(I : 𝕜) • x + y‖ := by
convert I_smul ((I : 𝕜) • x + y) using 2
linear_combination (norm := module) -hI' • x
have h₂ : ‖(I : 𝕜) • y + x‖ = ‖(I : 𝕜) • x - y‖ := by
convert (I_smul ((I : 𝕜) • y + x)).symm using 2
linear_combination (norm := module) -hI' • y
rw [h₁, h₂]
ring
variable [InnerProductSpaceable E]
theorem add_left (x y z : E) : inner_ 𝕜 (x + y) z = inner_ 𝕜 x z + inner_ 𝕜 y z := by
unfold inner_
have h1 := parallelogram_identity (x + y + z) (x - z)
have h2 := parallelogram_identity (x + y - z) (x + z)
have h3 := parallelogram_identity (y + z) z
have h4 := parallelogram_identity (y - z) z
have h5 := parallelogram_identity ((I : 𝕜) • (x + y) + z) ((I : 𝕜) • x - z)
have h6 := parallelogram_identity ((I : 𝕜) • (x + y) - z) ((I : 𝕜) • x + z)
have h7 := parallelogram_identity ((I : 𝕜) • y + z) z
have h8 := parallelogram_identity ((I : 𝕜) • y - z) z
apply_fun 𝓚 at h1 h2 h3 h4 h5 h6 h7 h8
simp only [map_add, map_mul, map_ofNat, smul_add] at *
abel_nf at * -- TODO this should be `module_nf` (then the `smul_add` above can go)
linear_combination (- h1 + h2 + h3 - h4 + I * (- h5 + h6 + h7 - h8)) / 8
private theorem rat_prop (r : ℚ) : innerProp' E (r : 𝕜) := by
intro x y
let hom : 𝕜 →ₗ[ℚ] 𝕜 := AddMonoidHom.toRatLinearMap <|
AddMonoidHom.mk' (fun r ↦ inner_ 𝕜 (r • x) y) <| fun a b ↦ by
simpa [add_smul] using add_left (a • x) (b • x) y
simpa [hom, Rat.smul_def] using map_smul hom r 1
private theorem real_prop (r : ℝ) : innerProp' E (r : 𝕜) := by
intro x y
revert r
rw [← funext_iff]
refine Rat.isDenseEmbedding_coe_real.dense.equalizer ?_ ?_ (funext fun X => ?_)
· exact (continuous_ofReal.smul continuous_const).inner_ continuous_const
· exact (continuous_conj.comp continuous_ofReal).mul continuous_const
· simp only [Function.comp_apply, RCLike.ofReal_ratCast, rat_prop _ _]
private theorem I_prop : innerProp' E (I : 𝕜) := by
by_cases hI : (I : 𝕜) = 0
· rw [hI]
simpa using real_prop (𝕜 := 𝕜) 0
intro x y
have hI' := I_mul_I_of_nonzero hI
rw [conj_I, inner_, inner_, mul_left_comm, smul_smul, hI', neg_one_smul]
have h₁ : ‖-x - y‖ = ‖x + y‖ := by rw [← neg_add', norm_neg]
have h₂ : ‖-x + y‖ = ‖x - y‖ := by rw [← neg_sub, norm_neg, sub_eq_neg_add]
rw [h₁, h₂]
linear_combination (- 𝓚 ‖(I : 𝕜) • x - y‖ ^ 2 + 𝓚 ‖(I : 𝕜) • x + y‖ ^ 2) * hI' / 4
theorem innerProp (r : 𝕜) : innerProp' E r := by
intro x y
rw [← re_add_im r, add_smul, add_left, real_prop _ x, ← smul_smul, real_prop _ _ y, I_prop,
map_add, map_mul, conj_ofReal, conj_ofReal, conj_I]
ring
end InnerProductSpaceable
open InnerProductSpaceable
/-- **Fréchet–von Neumann–Jordan Theorem**. A normed space `E` whose norm satisfies the
parallelogram identity can be given a compatible inner product. -/
noncomputable def InnerProductSpace.ofNorm
(h : ∀ x y : E, ‖x + y‖ * ‖x + y‖ + ‖x - y‖ * ‖x - y‖ = 2 * (‖x‖ * ‖x‖ + ‖y‖ * ‖y‖)) :
InnerProductSpace 𝕜 E :=
haveI : InnerProductSpaceable E := ⟨h⟩
{ inner := inner_ 𝕜
norm_sq_eq_re_inner := inner_.norm_sq
conj_inner_symm := inner_.conj_symm
add_left := InnerProductSpaceable.add_left
smul_left := fun _ _ _ => innerProp _ _ _ }
variable (E)
variable [InnerProductSpaceable E]
/-- **Fréchet–von Neumann–Jordan Theorem**. A normed space `E` whose norm satisfies the
parallelogram identity can be given a compatible inner product. Do
`casesI nonempty_innerProductSpace 𝕜 E` to locally upgrade `InnerProductSpaceable E` to
`InnerProductSpace 𝕜 E`. -/
theorem nonempty_innerProductSpace : Nonempty (InnerProductSpace 𝕜 E) :=
⟨{ inner := inner_ 𝕜
norm_sq_eq_re_inner := inner_.norm_sq
conj_inner_symm := inner_.conj_symm
add_left := add_left
smul_left := fun _ _ _ => innerProp _ _ _ }⟩
variable {𝕜 E}
variable [NormedSpace ℝ E]
-- TODO: Replace `InnerProductSpace.toUniformConvexSpace`
-- See note [lower instance priority]
instance (priority := 100) InnerProductSpaceable.to_uniformConvexSpace : UniformConvexSpace E := by
cases nonempty_innerProductSpace ℝ E; infer_instance |
.lake/packages/mathlib/Mathlib/Analysis/InnerProductSpace/l2Space.lean | import Mathlib.Analysis.InnerProductSpace.Projection.Basic
import Mathlib.Analysis.Normed.Lp.lpSpace
import Mathlib.Analysis.InnerProductSpace.PiL2
/-!
# Hilbert sum of a family of inner product spaces
Given a family `(G : ι → Type*) [Π i, InnerProductSpace 𝕜 (G i)]` of inner product spaces, this
file equips `lp G 2` with an inner product space structure, where `lp G 2` consists of those
dependent functions `f : Π i, G i` for which `∑' i, ‖f i‖ ^ 2`, the sum of the norms-squared, is
summable. This construction is sometimes called the *Hilbert sum* of the family `G`. By choosing
`G` to be `ι → 𝕜`, the Hilbert space `ℓ²(ι, 𝕜)` may be seen as a special case of this construction.
We also define a *predicate* `IsHilbertSum 𝕜 G V`, where `V : Π i, G i →ₗᵢ[𝕜] E`, expressing that
`V` is an `OrthogonalFamily` and that the associated map `lp G 2 →ₗᵢ[𝕜] E` is surjective.
## Main definitions
* `OrthogonalFamily.linearIsometry`: Given a Hilbert space `E`, a family `G` of inner product
spaces and a family `V : Π i, G i →ₗᵢ[𝕜] E` of isometric embeddings of the `G i` into `E` with
mutually-orthogonal images, there is an induced isometric embedding of the Hilbert sum of `G`
into `E`.
* `IsHilbertSum`: Given a Hilbert space `E`, a family `G` of inner product
spaces and a family `V : Π i, G i →ₗᵢ[𝕜] E` of isometric embeddings of the `G i` into `E`,
`IsHilbertSum 𝕜 G V` means that `V` is an `OrthogonalFamily` and that the above
linear isometry is surjective.
* `IsHilbertSum.linearIsometryEquiv`: If a Hilbert space `E` is a Hilbert sum of the
inner product spaces `G i` with respect to the family `V : Π i, G i →ₗᵢ[𝕜] E`, then the
corresponding `OrthogonalFamily.linearIsometry` can be upgraded to a `LinearIsometryEquiv`.
* `HilbertBasis`: We define a *Hilbert basis* of a Hilbert space `E` to be a structure whose single
field `HilbertBasis.repr` is an isometric isomorphism of `E` with `ℓ²(ι, 𝕜)` (i.e., the Hilbert
sum of `ι` copies of `𝕜`). This parallels the definition of `Basis`, in `LinearAlgebra.Basis`,
as an isomorphism of an `R`-module with `ι →₀ R`.
* `HilbertBasis.instCoeFun`: More conventionally a Hilbert basis is thought of as a family
`ι → E` of vectors in `E` satisfying certain properties (orthonormality, completeness). We obtain
this interpretation of a Hilbert basis `b` by defining `⇑b`, of type `ι → E`, to be the image
under `b.repr` of `lp.single 2 i (1:𝕜)`. This parallels the definition `Basis.coeFun` in
`LinearAlgebra.Basis`.
* `HilbertBasis.mk`: Make a Hilbert basis of `E` from an orthonormal family `v : ι → E` of vectors
in `E` whose span is dense. This parallels the definition `Basis.mk` in `LinearAlgebra.Basis`.
* `HilbertBasis.mkOfOrthogonalEqBot`: Make a Hilbert basis of `E` from an orthonormal family
`v : ι → E` of vectors in `E` whose span has trivial orthogonal complement.
## Main results
* `lp.instInnerProductSpace`: Construction of the inner product space instance on the Hilbert sum
`lp G 2`. Note that from the file `Analysis.Normed.Lp.lpSpace`, the space `lp G 2` already
held a normed space instance (`lp.normedSpace`), and if each `G i` is a Hilbert space (i.e.,
complete), then `lp G 2` was already known to be complete (`lp.completeSpace`). So the work
here is to define the inner product and show it is compatible.
* `OrthogonalFamily.range_linearIsometry`: Given a family `G` of inner product spaces and a family
`V : Π i, G i →ₗᵢ[𝕜] E` of isometric embeddings of the `G i` into `E` with mutually-orthogonal
images, the image of the embedding `OrthogonalFamily.linearIsometry` of the Hilbert sum of `G`
into `E` is the closure of the span of the images of the `G i`.
* `HilbertBasis.repr_apply_apply`: Given a Hilbert basis `b` of `E`, the entry `b.repr x i` of
`x`'s representation in `ℓ²(ι, 𝕜)` is the inner product `⟪b i, x⟫`.
* `HilbertBasis.hasSum_repr`: Given a Hilbert basis `b` of `E`, a vector `x` in `E` can be
expressed as the "infinite linear combination" `∑' i, b.repr x i • b i` of the basis vectors
`b i`, with coefficients given by the entries `b.repr x i` of `x`'s representation in `ℓ²(ι, 𝕜)`.
* `exists_hilbertBasis`: A Hilbert space admits a Hilbert basis.
## Keywords
Hilbert space, Hilbert sum, l2, Hilbert basis, unitary equivalence, isometric isomorphism
-/
open RCLike Submodule Filter
open scoped NNReal ENNReal ComplexConjugate Topology
noncomputable section
variable {ι 𝕜 : Type*} [RCLike 𝕜] {E : Type*}
variable [NormedAddCommGroup E] [InnerProductSpace 𝕜 E]
variable {G : ι → Type*} [∀ i, NormedAddCommGroup (G i)] [∀ i, InnerProductSpace 𝕜 (G i)]
local notation "⟪" x ", " y "⟫" => inner 𝕜 x y
/-- `ℓ²(ι, 𝕜)` is the Hilbert space of square-summable functions `ι → 𝕜`, herein implemented
as `lp (fun i : ι => 𝕜) 2`. -/
notation "ℓ²(" ι ", " 𝕜 ")" => lp (fun i : ι => 𝕜) 2
/-! ### Inner product space structure on `lp G 2` -/
namespace lp
theorem summable_inner (f g : lp G 2) : Summable fun i => ⟪f i, g i⟫ := by
-- Apply the Direct Comparison Test, comparing with ∑' i, ‖f i‖ * ‖g i‖ (summable by Hölder)
refine .of_norm_bounded (lp.summable_mul ?_ f g) ?_
· rw [Real.holderConjugate_iff]; norm_num
intro i
-- Then apply Cauchy-Schwarz pointwise
exact norm_inner_le_norm (𝕜 := 𝕜) _ _
instance instInnerProductSpace : InnerProductSpace 𝕜 (lp G 2) :=
{ lp.normedAddCommGroup (E := G) (p := 2) with
inner := fun f g => ∑' i, ⟪f i, g i⟫
norm_sq_eq_re_inner := fun f => by
calc
‖f‖ ^ 2 = ‖f‖ ^ (2 : ℝ≥0∞).toReal := by norm_cast
_ = ∑' i, ‖f i‖ ^ (2 : ℝ≥0∞).toReal := lp.norm_rpow_eq_tsum ?_ f
_ = ∑' i, ‖f i‖ ^ (2 : ℕ) := by norm_cast
_ = ∑' i, re ⟪f i, f i⟫ := by simp
_ = re (∑' i, ⟪f i, f i⟫) := (RCLike.reCLM.map_tsum ?_).symm
· norm_num
· exact summable_inner f f
conj_inner_symm := fun f g => by
calc
conj _ = conj (∑' i, ⟪g i, f i⟫) := by congr
_ = ∑' i, conj ⟪g i, f i⟫ := RCLike.conjCLE.map_tsum
_ = ∑' i, ⟪f i, g i⟫ := by simp only [inner_conj_symm]
_ = _ := by congr
add_left := fun f₁ f₂ g => by
calc
_ = ∑' i, ⟪(f₁ + f₂) i, g i⟫ := ?_
_ = ∑' i, (⟪f₁ i, g i⟫ + ⟪f₂ i, g i⟫) := by
simp only [inner_add_left, Pi.add_apply, coeFn_add]
_ = (∑' i, ⟪f₁ i, g i⟫) + ∑' i, ⟪f₂ i, g i⟫ := Summable.tsum_add ?_ ?_
_ = _ := by congr
· congr
· exact summable_inner f₁ g
· exact summable_inner f₂ g
smul_left := fun f g c => by
calc
_ = ∑' i, ⟪c • f i, g i⟫ := ?_
_ = ∑' i, conj c * ⟪f i, g i⟫ := by simp only [inner_smul_left]
_ = conj c * ∑' i, ⟪f i, g i⟫ := tsum_mul_left
_ = _ := ?_
· simp only [coeFn_smul, Pi.smul_apply]
· congr }
theorem inner_eq_tsum (f g : lp G 2) : ⟪f, g⟫ = ∑' i, ⟪f i, g i⟫ :=
rfl
theorem hasSum_inner (f g : lp G 2) : HasSum (fun i => ⟪f i, g i⟫) ⟪f, g⟫ :=
(summable_inner f g).hasSum
theorem inner_single_left [DecidableEq ι] (i : ι) (a : G i) (f : lp G 2) :
⟪lp.single 2 i a, f⟫ = ⟪a, f i⟫ := by
refine (hasSum_inner (lp.single 2 i a) f).unique ?_
simp_rw [lp.coeFn_single]
convert hasSum_ite_eq i ⟪a, f i⟫ using 1
ext j
split_ifs with h
· subst h; rw [Pi.single_eq_same]
· simp [Pi.single_eq_of_ne h]
theorem inner_single_right [DecidableEq ι] (i : ι) (a : G i) (f : lp G 2) :
⟪f, lp.single 2 i a⟫ = ⟪f i, a⟫ := by
simpa [inner_conj_symm] using congr_arg conj (inner_single_left (𝕜 := 𝕜) i a f)
end lp
/-! ### Identification of a general Hilbert space `E` with a Hilbert sum -/
namespace OrthogonalFamily
variable [CompleteSpace E] {V : ∀ i, G i →ₗᵢ[𝕜] E} (hV : OrthogonalFamily 𝕜 G V)
include hV
protected theorem summable_of_lp (f : lp G 2) :
Summable fun i => V i (f i) := by
rw [hV.summable_iff_norm_sq_summable]
convert (lp.memℓp f).summable _
· norm_cast
· norm_num
/-- A mutually orthogonal family of subspaces of `E` induce a linear isometry from `lp 2` of the
subspaces into `E`. -/
protected def linearIsometry (hV : OrthogonalFamily 𝕜 G V) : lp G 2 →ₗᵢ[𝕜] E where
toFun f := ∑' i, V i (f i)
map_add' f g := by
simp only [(hV.summable_of_lp f).tsum_add (hV.summable_of_lp g), lp.coeFn_add, Pi.add_apply,
LinearIsometry.map_add]
map_smul' c f := by
simpa only [LinearIsometry.map_smul, Pi.smul_apply, lp.coeFn_smul] using
(hV.summable_of_lp f).tsum_const_smul c
norm_map' f := by
classical
-- needed for lattice instance on `Finset ι`, for `Filter.atTop_neBot`
have H : 0 < (2 : ℝ≥0∞).toReal := by simp
suffices ‖∑' i : ι, V i (f i)‖ ^ (2 : ℝ≥0∞).toReal = ‖f‖ ^ (2 : ℝ≥0∞).toReal by
exact Real.rpow_left_injOn H.ne' (norm_nonneg _) (norm_nonneg _) this
refine tendsto_nhds_unique ?_ (lp.hasSum_norm H f)
convert (hV.summable_of_lp f).hasSum.norm.rpow_const (Or.inr H.le) using 1
ext s
exact mod_cast (hV.norm_sum f s).symm
protected theorem linearIsometry_apply (f : lp G 2) : hV.linearIsometry f = ∑' i, V i (f i) :=
rfl
protected theorem hasSum_linearIsometry (f : lp G 2) :
HasSum (fun i => V i (f i)) (hV.linearIsometry f) :=
(hV.summable_of_lp f).hasSum
@[simp]
protected theorem linearIsometry_apply_single [DecidableEq ι] {i : ι} (x : G i) :
hV.linearIsometry (lp.single 2 i x) = V i x := by
rw [hV.linearIsometry_apply, ← tsum_ite_eq i (fun _ ↦ V i x)]
congr
ext j
rw [lp.single_apply]
split_ifs with h
· subst h; simp
· simp [h]
protected theorem linearIsometry_apply_dfinsupp_sum_single [DecidableEq ι] [∀ i, DecidableEq (G i)]
(W₀ : Π₀ i : ι, G i) : hV.linearIsometry (W₀.sum (lp.single 2)) = W₀.sum fun i => V i := by
simp
/-- The canonical linear isometry from the `lp 2` of a mutually orthogonal family of subspaces of
`E` into E, has range the closure of the span of the subspaces. -/
protected theorem range_linearIsometry [∀ i, CompleteSpace (G i)] :
LinearMap.range hV.linearIsometry.toLinearMap =
(⨆ i, LinearMap.range (V i).toLinearMap).topologicalClosure := by
classical
refine le_antisymm ?_ ?_
· rintro x ⟨f, rfl⟩
refine mem_closure_of_tendsto (hV.hasSum_linearIsometry f) (Eventually.of_forall ?_)
intro s
rw [SetLike.mem_coe]
refine sum_mem ?_
intro i _
refine mem_iSup_of_mem i ?_
exact LinearMap.mem_range_self _ (f i)
· apply topologicalClosure_minimal
· refine iSup_le ?_
rintro i x ⟨x, rfl⟩
use lp.single 2 i x
exact hV.linearIsometry_apply_single x
exact hV.linearIsometry.isometry.isUniformInducing.isComplete_range.isClosed
end OrthogonalFamily
section IsHilbertSum
variable (𝕜 G)
variable [CompleteSpace E] (V : ∀ i, G i →ₗᵢ[𝕜] E) (F : ι → Submodule 𝕜 E)
/-- Given a family of Hilbert spaces `G : ι → Type*`, a Hilbert sum of `G` consists of a Hilbert
space `E` and an orthogonal family `V : Π i, G i →ₗᵢ[𝕜] E` such that the induced isometry
`Φ : lp G 2 → E` is surjective.
Keeping in mind that `lp G 2` is "the" external Hilbert sum of `G : ι → Type*`, this is analogous
to `DirectSum.IsInternal`, except that we don't express it in terms of actual submodules. -/
structure IsHilbertSum : Prop where
ofSurjective ::
/-- The orthogonal family constituting the summands in the Hilbert sum. -/
protected OrthogonalFamily : OrthogonalFamily 𝕜 G V
/-- The isometry `lp G 2 → E` induced by the orthogonal family is surjective. -/
protected surjective_isometry : Function.Surjective OrthogonalFamily.linearIsometry
variable {𝕜 G V}
/-- If `V : Π i, G i →ₗᵢ[𝕜] E` is an orthogonal family such that the supremum of the ranges of
`V i` is dense, then `(E, V)` is a Hilbert sum of `G`. -/
theorem IsHilbertSum.mk [∀ i, CompleteSpace <| G i] (hVortho : OrthogonalFamily 𝕜 G V)
(hVtotal : ⊤ ≤ (⨆ i, LinearMap.range (V i).toLinearMap).topologicalClosure) :
IsHilbertSum 𝕜 G V :=
{ OrthogonalFamily := hVortho
surjective_isometry := by
rw [← LinearIsometry.coe_toLinearMap]
exact LinearMap.range_eq_top.mp
(eq_top_iff.mpr <| hVtotal.trans_eq hVortho.range_linearIsometry.symm) }
/-- This is `Orthonormal.isHilbertSum` in the case of actual inclusions from subspaces. -/
theorem IsHilbertSum.mkInternal [∀ i, CompleteSpace <| F i]
(hFortho : OrthogonalFamily 𝕜 (fun i => F i) fun i => (F i).subtypeₗᵢ)
(hFtotal : ⊤ ≤ (⨆ i, F i).topologicalClosure) :
IsHilbertSum 𝕜 (fun i => F i) fun i => (F i).subtypeₗᵢ :=
IsHilbertSum.mk hFortho (by simpa [subtypeₗᵢ_toLinearMap, range_subtype] using hFtotal)
/-- *A* Hilbert sum `(E, V)` of `G` is canonically isomorphic to *the* Hilbert sum of `G`,
i.e `lp G 2`.
Note that this goes in the opposite direction from `OrthogonalFamily.linearIsometry`. -/
noncomputable def IsHilbertSum.linearIsometryEquiv (hV : IsHilbertSum 𝕜 G V) : E ≃ₗᵢ[𝕜] lp G 2 :=
LinearIsometryEquiv.symm <|
LinearIsometryEquiv.ofSurjective hV.OrthogonalFamily.linearIsometry hV.surjective_isometry
/-- In the canonical isometric isomorphism between a Hilbert sum `E` of `G` and `lp G 2`,
a vector `w : lp G 2` is the image of the infinite sum of the associated elements in `E`. -/
protected theorem IsHilbertSum.linearIsometryEquiv_symm_apply (hV : IsHilbertSum 𝕜 G V)
(w : lp G 2) : hV.linearIsometryEquiv.symm w = ∑' i, V i (w i) := by
simp [IsHilbertSum.linearIsometryEquiv, OrthogonalFamily.linearIsometry_apply]
/-- In the canonical isometric isomorphism between a Hilbert sum `E` of `G` and `lp G 2`,
a vector `w : lp G 2` is the image of the infinite sum of the associated elements in `E`, and this
sum indeed converges. -/
protected theorem IsHilbertSum.hasSum_linearIsometryEquiv_symm (hV : IsHilbertSum 𝕜 G V)
(w : lp G 2) : HasSum (fun i => V i (w i)) (hV.linearIsometryEquiv.symm w) := by
simp [IsHilbertSum.linearIsometryEquiv, OrthogonalFamily.hasSum_linearIsometry]
/-- In the canonical isometric isomorphism between a Hilbert sum `E` of `G : ι → Type*` and
`lp G 2`, an "elementary basis vector" in `lp G 2` supported at `i : ι` is the image of the
associated element in `E`. -/
@[simp]
protected theorem IsHilbertSum.linearIsometryEquiv_symm_apply_single
[DecidableEq ι] (hV : IsHilbertSum 𝕜 G V) {i : ι} (x : G i) :
hV.linearIsometryEquiv.symm (lp.single 2 i x) = V i x := by
simp [IsHilbertSum.linearIsometryEquiv, OrthogonalFamily.linearIsometry_apply_single]
/-- In the canonical isometric isomorphism between a Hilbert sum `E` of `G : ι → Type*` and
`lp G 2`, a finitely-supported vector in `lp G 2` is the image of the associated finite sum of
elements of `E`. -/
protected theorem IsHilbertSum.linearIsometryEquiv_symm_apply_dfinsupp_sum_single
[DecidableEq ι] [∀ i, DecidableEq (G i)] (hV : IsHilbertSum 𝕜 G V) (W₀ : Π₀ i : ι, G i) :
hV.linearIsometryEquiv.symm (W₀.sum (lp.single 2)) = W₀.sum fun i => V i := by
simp only [map_dfinsuppSum, IsHilbertSum.linearIsometryEquiv_symm_apply_single]
/-- In the canonical isometric isomorphism between a Hilbert sum `E` of `G : ι → Type*` and
`lp G 2`, a finitely-supported vector in `lp G 2` is the image of the associated finite sum of
elements of `E`. -/
@[simp]
protected theorem IsHilbertSum.linearIsometryEquiv_apply_dfinsupp_sum_single
[DecidableEq ι] [∀ i, DecidableEq (G i)] (hV : IsHilbertSum 𝕜 G V) (W₀ : Π₀ i : ι, G i) :
((W₀.sum (γ := lp G 2) fun a b ↦ hV.linearIsometryEquiv (V a b)) : ∀ i, G i) = W₀ := by
rw [← map_dfinsuppSum]
rw [← hV.linearIsometryEquiv_symm_apply_dfinsupp_sum_single]
rw [LinearIsometryEquiv.apply_symm_apply]
ext i
simp +contextual [DFinsupp.sum, lp.single_apply]
/-- Given a total orthonormal family `v : ι → E`, `E` is a Hilbert sum of `fun i : ι => 𝕜`
relative to the family of linear isometries `fun i k => k • v i`. -/
theorem Orthonormal.isHilbertSum {v : ι → E} (hv : Orthonormal 𝕜 v)
(hsp : ⊤ ≤ (span 𝕜 (Set.range v)).topologicalClosure) :
IsHilbertSum 𝕜 (fun _ : ι => 𝕜) fun i => LinearIsometry.toSpanSingleton 𝕜 E (hv.1 i) :=
IsHilbertSum.mk hv.orthogonalFamily (by
convert hsp
simp [← LinearMap.span_singleton_eq_range, ← Submodule.span_iUnion])
theorem Submodule.isHilbertSumOrthogonal (K : Submodule 𝕜 E) [hK : CompleteSpace K] :
IsHilbertSum 𝕜 (fun b => ↥(cond b K Kᗮ)) fun b => (cond b K Kᗮ).subtypeₗᵢ := by
have : ∀ b, CompleteSpace (↥(cond b K Kᗮ)) := by
intro b
cases b <;> first | exact instOrthogonalCompleteSpace K | assumption
refine IsHilbertSum.mkInternal _ K.orthogonalFamily_self ?_
refine le_trans ?_ (Submodule.le_topologicalClosure _)
rw [iSup_bool_eq, cond, cond]
refine Codisjoint.top_le ?_
exact Submodule.isCompl_orthogonal_of_hasOrthogonalProjection.codisjoint
end IsHilbertSum
/-! ### Hilbert bases -/
section
variable (ι) (𝕜) (E)
/-- A Hilbert basis on `ι` for an inner product space `E` is an identification of `E` with the `lp`
space `ℓ²(ι, 𝕜)`. -/
structure HilbertBasis where ofRepr ::
/-- The linear isometric equivalence implementing identifying the Hilbert space with `ℓ²`. -/
repr : E ≃ₗᵢ[𝕜] ℓ²(ι, 𝕜)
end
namespace HilbertBasis
instance {ι : Type*} : Inhabited (HilbertBasis ι 𝕜 ℓ²(ι, 𝕜)) :=
⟨ofRepr (LinearIsometryEquiv.refl 𝕜 _)⟩
open Classical in
/-- `b i` is the `i`th basis vector. -/
instance instFunLike : FunLike (HilbertBasis ι 𝕜 E) ι E where
coe b i := b.repr.symm (lp.single 2 i (1 : 𝕜))
coe_injective'
| ⟨b₁⟩, ⟨b₂⟩, h => by
congr
apply LinearIsometryEquiv.symm_bijective.injective
apply LinearIsometryEquiv.toContinuousLinearEquiv_injective
apply ContinuousLinearEquiv.coe_injective
refine lp.ext_continuousLinearMap ( ENNReal.ofNat_ne_top (n := nat_lit 2)) fun i => ?_
ext
exact congr_fun h i
@[simp]
protected theorem repr_symm_single [DecidableEq ι] (b : HilbertBasis ι 𝕜 E) (i : ι) :
b.repr.symm (lp.single 2 i (1 : 𝕜)) = b i := by
dsimp [instFunLike]
convert rfl
protected theorem repr_self [DecidableEq ι] (b : HilbertBasis ι 𝕜 E) (i : ι) :
b.repr (b i) = lp.single 2 i (1 : 𝕜) := by
simp only [LinearIsometryEquiv.apply_symm_apply, ← b.repr_symm_single]
protected theorem repr_apply_apply (b : HilbertBasis ι 𝕜 E) (v : E) (i : ι) :
b.repr v i = ⟪b i, v⟫ := by
classical
rw [← b.repr.inner_map_map (b i) v, b.repr_self, lp.inner_single_left]
simp
@[simp]
protected theorem orthonormal (b : HilbertBasis ι 𝕜 E) : Orthonormal 𝕜 b := by
classical
rw [orthonormal_iff_ite]
intro i j
rw [← b.repr.inner_map_map (b i) (b j), b.repr_self, b.repr_self, lp.inner_single_left,
lp.single_apply, Pi.single_apply]
simp
protected theorem hasSum_repr_symm (b : HilbertBasis ι 𝕜 E) (f : ℓ²(ι, 𝕜)) :
HasSum (fun i => f i • b i) (b.repr.symm f) := by
classical
suffices H : (fun i : ι => f i • b i) = fun b_1 : ι => b.repr.symm.toContinuousLinearEquiv <|
(fun i : ι => lp.single 2 i (f i) (E := (fun _ : ι => 𝕜))) b_1 by
rw [H]
have : HasSum (fun i : ι => lp.single 2 i (f i)) f := lp.hasSum_single ENNReal.ofNat_ne_top f
exact (↑b.repr.symm.toContinuousLinearEquiv : ℓ²(ι, 𝕜) →L[𝕜] E).hasSum this
ext i
apply b.repr.injective
letI : NormedSpace 𝕜 (lp (fun _i : ι => 𝕜) 2) := by infer_instance
have : lp.single (E := (fun _ : ι => 𝕜)) 2 i (f i * 1) = f i • lp.single 2 i 1 :=
lp.single_smul (E := (fun _ : ι => 𝕜)) 2 i (f i) (1 : 𝕜)
rw [mul_one] at this
rw [LinearIsometryEquiv.map_smul, b.repr_self, ← this,
LinearIsometryEquiv.coe_toContinuousLinearEquiv]
exact (b.repr.apply_symm_apply (lp.single 2 i (f i))).symm
protected theorem hasSum_repr (b : HilbertBasis ι 𝕜 E) (x : E) :
HasSum (fun i => b.repr x i • b i) x := by simpa using b.hasSum_repr_symm (b.repr x)
@[simp]
protected theorem dense_span (b : HilbertBasis ι 𝕜 E) :
(span 𝕜 (Set.range b)).topologicalClosure = ⊤ := by
classical
rw [eq_top_iff]
rintro x -
refine mem_closure_of_tendsto (b.hasSum_repr x) (Eventually.of_forall ?_)
intro s
simp only [SetLike.mem_coe]
refine sum_mem ?_
rintro i -
refine smul_mem _ _ ?_
exact subset_span ⟨i, rfl⟩
protected theorem hasSum_inner_mul_inner (b : HilbertBasis ι 𝕜 E) (x y : E) :
HasSum (fun i => ⟪x, b i⟫ * ⟪b i, y⟫) ⟪x, y⟫ := by
convert (b.hasSum_repr y).mapL (innerSL 𝕜 x) using 1
ext i
rw [innerSL_apply_apply, b.repr_apply_apply, inner_smul_right, mul_comm]
protected theorem summable_inner_mul_inner (b : HilbertBasis ι 𝕜 E) (x y : E) :
Summable fun i => ⟪x, b i⟫ * ⟪b i, y⟫ :=
(b.hasSum_inner_mul_inner x y).summable
protected theorem tsum_inner_mul_inner (b : HilbertBasis ι 𝕜 E) (x y : E) :
∑' i, ⟪x, b i⟫ * ⟪b i, y⟫ = ⟪x, y⟫ :=
(b.hasSum_inner_mul_inner x y).tsum_eq
-- Note: this should be `b.repr` composed with an identification of `lp (fun i : ι => 𝕜) p` with
-- `PiLp p (fun i : ι => 𝕜)` (in this case with `p = 2`), but we don't have this yet (July 2022).
/-- A finite Hilbert basis is an orthonormal basis. -/
protected def toOrthonormalBasis [Fintype ι] (b : HilbertBasis ι 𝕜 E) : OrthonormalBasis ι 𝕜 E :=
OrthonormalBasis.mk b.orthonormal
(by
refine Eq.ge ?_
classical
have := (span 𝕜 (Finset.univ.image b : Set E)).closed_of_finiteDimensional
simpa only [Finset.coe_image, Finset.coe_univ, Set.image_univ, HilbertBasis.dense_span] using
this.submodule_topologicalClosure_eq.symm)
@[simp]
theorem coe_toOrthonormalBasis [Fintype ι] (b : HilbertBasis ι 𝕜 E) :
(b.toOrthonormalBasis : ι → E) = b :=
OrthonormalBasis.coe_mk _ _
protected theorem hasSum_orthogonalProjection {U : Submodule 𝕜 E} [CompleteSpace U]
(b : HilbertBasis ι 𝕜 U) (x : E) :
HasSum (fun i => ⟪(b i : E), x⟫ • b i) (U.orthogonalProjection x) := by
simpa only [b.repr_apply_apply, inner_orthogonalProjection_eq_of_mem_left] using
b.hasSum_repr (U.orthogonalProjection x)
theorem finite_spans_dense [DecidableEq E] (b : HilbertBasis ι 𝕜 E) :
(⨆ J : Finset ι, span 𝕜 (J.image b : Set E)).topologicalClosure = ⊤ :=
eq_top_iff.mpr <| b.dense_span.ge.trans (by
simp_rw [← Submodule.span_iUnion]
exact topologicalClosure_mono (span_mono <| Set.range_subset_iff.mpr fun i =>
Set.mem_iUnion_of_mem {i} <| Finset.mem_coe.mpr <| Finset.mem_image_of_mem _ <|
Finset.mem_singleton_self i))
variable [CompleteSpace E]
section
variable {v : ι → E} (hv : Orthonormal 𝕜 v)
include hv
/-- An orthonormal family of vectors whose span is dense in the whole module is a Hilbert basis. -/
protected def mk (hsp : ⊤ ≤ (span 𝕜 (Set.range v)).topologicalClosure) : HilbertBasis ι 𝕜 E :=
HilbertBasis.ofRepr <| (hv.isHilbertSum hsp).linearIsometryEquiv
theorem _root_.Orthonormal.linearIsometryEquiv_symm_apply_single_one [DecidableEq ι] (h i) :
(hv.isHilbertSum h).linearIsometryEquiv.symm (lp.single 2 i 1) = v i := by
rw [IsHilbertSum.linearIsometryEquiv_symm_apply_single, LinearIsometry.toSpanSingleton_apply,
one_smul]
@[simp]
protected theorem coe_mk (hsp : ⊤ ≤ (span 𝕜 (Set.range v)).topologicalClosure) :
⇑(HilbertBasis.mk hv hsp) = v := by
classical
apply funext <| Orthonormal.linearIsometryEquiv_symm_apply_single_one hv hsp
/-- An orthonormal family of vectors whose span has trivial orthogonal complement is a Hilbert
basis. -/
protected def mkOfOrthogonalEqBot (hsp : (span 𝕜 (Set.range v))ᗮ = ⊥) : HilbertBasis ι 𝕜 E :=
HilbertBasis.mk hv
(by rw [← orthogonal_orthogonal_eq_closure, ← eq_top_iff, orthogonal_eq_top_iff, hsp])
@[simp]
protected theorem coe_mkOfOrthogonalEqBot (hsp : (span 𝕜 (Set.range v))ᗮ = ⊥) :
⇑(HilbertBasis.mkOfOrthogonalEqBot hv hsp) = v :=
HilbertBasis.coe_mk hv _
-- Note : this should be `b.repr` composed with an identification of `lp (fun i : ι => 𝕜) p` with
-- `PiLp p (fun i : ι => 𝕜)` (in this case with `p = 2`), but we don't have this yet (July 2022).
/-- An orthonormal basis is a Hilbert basis. -/
protected def _root_.OrthonormalBasis.toHilbertBasis [Fintype ι] (b : OrthonormalBasis ι 𝕜 E) :
HilbertBasis ι 𝕜 E :=
HilbertBasis.mk b.orthonormal <| by
simpa only [← OrthonormalBasis.coe_toBasis, b.toBasis.span_eq, eq_top_iff] using
@subset_closure E _ _
end
@[simp]
theorem _root_.OrthonormalBasis.coe_toHilbertBasis [Fintype ι] (b : OrthonormalBasis ι 𝕜 E) :
(b.toHilbertBasis : ι → E) = b :=
HilbertBasis.coe_mk _ _
/-- A Hilbert space admits a Hilbert basis extending a given orthonormal subset. -/
theorem _root_.Orthonormal.exists_hilbertBasis_extension {s : Set E}
(hs : Orthonormal 𝕜 ((↑) : s → E)) :
∃ (w : Set E) (b : HilbertBasis w 𝕜 E), s ⊆ w ∧ ⇑b = ((↑) : w → E) :=
let ⟨w, hws, hw_ortho, hw_max⟩ := exists_maximal_orthonormal hs
⟨w, HilbertBasis.mkOfOrthogonalEqBot hw_ortho
(by simpa only [Subtype.range_coe_subtype, Set.setOf_mem_eq,
maximal_orthonormal_iff_orthogonalComplement_eq_bot hw_ortho] using hw_max),
hws, HilbertBasis.coe_mkOfOrthogonalEqBot _ _⟩
variable (𝕜 E)
/-- A Hilbert space admits a Hilbert basis. -/
theorem _root_.exists_hilbertBasis : ∃ (w : Set E) (b : HilbertBasis w 𝕜 E), ⇑b = ((↑) : w → E) :=
let ⟨w, hw, _, hw''⟩ := (orthonormal_empty 𝕜 E).exists_hilbertBasis_extension
⟨w, hw, hw''⟩
end HilbertBasis |
.lake/packages/mathlib/Mathlib/Analysis/InnerProductSpace/Defs.lean | import Mathlib.Algebra.QuadraticDiscriminant
import Mathlib.Analysis.LocallyConvex.WithSeminorms
import Mathlib.Analysis.RCLike.Basic
import Mathlib.Data.Complex.Basic
/-!
# Inner product spaces
This file defines inner product spaces.
Hilbert spaces can be obtained using the set of assumptions
`[RCLike 𝕜] [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] [CompleteSpace E]`.
For convenience, a variable alias `HilbertSpace` is provided so that one can write
`variable? [HilbertSpace 𝕜 E]` and get this as a suggestion.
An inner product space is a vector space endowed with an inner product. It generalizes the notion of
dot product in `ℝ^n` and provides the means of defining the length of a vector and the angle between
two vectors. In particular vectors `x` and `y` are orthogonal if their inner product equals zero.
We define both the real and complex cases at the same time using the `RCLike` typeclass.
Rather than defining the norm on an inner product space to be `√(re ⟪x, x⟫)`, we assume that a norm
is given, and add a hypothesis stating that `‖x‖ ^ 2 = re ⟪x, x⟫`. This makes it possible to
handle spaces where the norm is equal, but not defeq, to the square root of the
inner product. Defining a norm starting from an inner product is handled via the
`InnerProductSpace.Core` structure.
This file is intended to contain the minimal amount of machinery needed to define inner product
spaces, and to construct a normed space from an inner product space. Many more general lemmas can
be found in `Analysis.InnerProductSpace.Basic`. For the specific construction of an inner product
structure on `n → 𝕜` for `𝕜 = ℝ` or `ℂ`, see `EuclideanSpace` in
`Analysis.InnerProductSpace.PiL2`.
## Main results
- We define the class `InnerProductSpace 𝕜 E` extending `NormedSpace 𝕜 E` with a number of basic
properties, most notably the Cauchy-Schwarz inequality. Here `𝕜` is understood to be either `ℝ`
or `ℂ`, through the `RCLike` typeclass.
## Notation
We globally denote the real and complex inner products by `⟪·, ·⟫_ℝ` and `⟪·, ·⟫_ℂ` respectively.
We also provide two notation namespaces: `RealInnerProductSpace`, `ComplexInnerProductSpace`,
which respectively introduce the plain notation `⟪·, ·⟫` for the real and complex inner product.
## Implementation notes
We choose the convention that inner products are conjugate linear in the first argument and linear
in the second.
## Tags
inner product space, Hilbert space, norm
## References
* [Clément & Martin, *The Lax-Milgram Theorem. A detailed proof to be formalized in Coq*]
* [Clément & Martin, *A Coq formal proof of the Lax–Milgram theorem*]
The Coq code is available at the following address: <http://www.lri.fr/~sboldo/elfic/index.html>
-/
noncomputable section
open RCLike Real Filter Topology ComplexConjugate Finsupp Bornology
open LinearMap (BilinForm)
variable {𝕜 E F : Type*} [RCLike 𝕜]
/-- Syntactic typeclass for types endowed with an inner product -/
class Inner (𝕜 E : Type*) where
/-- The inner product function. -/
inner (𝕜) : E → E → 𝕜
export Inner (inner)
/-- The inner product with values in `𝕜`. -/
scoped[InnerProductSpace] notation:max "⟪" x ", " y "⟫_" 𝕜:max => inner 𝕜 x y
section Notations
/-- The inner product with values in `ℝ`. -/
scoped[RealInnerProductSpace] notation "⟪" x ", " y "⟫" => inner ℝ x y
/-- The inner product with values in `ℂ`. -/
scoped[ComplexInnerProductSpace] notation "⟪" x ", " y "⟫" => inner ℂ x y
end Notations
/-- A (pre) inner product space is a vector space with an additional operation called inner product.
The (semi)norm could be derived from the inner product, instead we require the existence of a
seminorm and the fact that `‖x‖^2 = re ⟪x, x⟫` to be able to put instances on `𝕂` or product spaces.
Note that `NormedSpace` does not assume that `‖x‖=0` implies `x=0` (it is rather a seminorm).
To construct a seminorm from an inner product, see `PreInnerProductSpace.ofCore`.
-/
class InnerProductSpace (𝕜 : Type*) (E : Type*) [RCLike 𝕜] [SeminormedAddCommGroup E] extends
NormedSpace 𝕜 E, Inner 𝕜 E where
/-- The inner product induces the norm. -/
norm_sq_eq_re_inner : ∀ x : E, ‖x‖ ^ 2 = re (inner x x)
/-- The inner product is *Hermitian*, taking the `conj` swaps the arguments. -/
conj_inner_symm : ∀ x y, conj (inner y x) = inner x y
/-- The inner product is additive in the first coordinate. -/
add_left : ∀ x y z, inner (x + y) z = inner x z + inner y z
/-- The inner product is conjugate linear in the first coordinate. -/
smul_left : ∀ x y r, inner (r • x) y = conj r * inner x y
/-!
### Constructing a normed space structure from an inner product
In the definition of an inner product space, we require the existence of a norm, which is equal
(but maybe not defeq) to the square root of the scalar product. This makes it possible to put
an inner product space structure on spaces with a preexisting norm (for instance `ℝ`), with good
properties. However, sometimes, one would like to define the norm starting only from a well-behaved
scalar product. This is what we implement in this paragraph, starting from a structure
`InnerProductSpace.Core` stating that we have a nice scalar product.
Our goal here is not to develop a whole theory with all the supporting API, as this will be done
below for `InnerProductSpace`. Instead, we implement the bare minimum to go as directly as
possible to the construction of the norm and the proof of the triangular inequality.
Warning: Do not use this `Core` structure if the space you are interested in already has a norm
instance defined on it, otherwise this will create a second non-defeq norm instance!
-/
/-- A structure requiring that a scalar product is positive semidefinite and symmetric. -/
structure PreInnerProductSpace.Core (𝕜 : Type*) (F : Type*) [RCLike 𝕜] [AddCommGroup F]
[Module 𝕜 F] extends Inner 𝕜 F where
/-- The inner product is *Hermitian*, taking the `conj` swaps the arguments. -/
conj_inner_symm x y : conj (inner y x) = inner x y
/-- The inner product is positive (semi)definite. -/
re_inner_nonneg x : 0 ≤ re (inner x x)
/-- The inner product is additive in the first coordinate. -/
add_left x y z : inner (x + y) z = inner x z + inner y z
/-- The inner product is conjugate linear in the first coordinate. -/
smul_left x y r : inner (r • x) y = conj r * inner x y
@[deprecated (since := "2025-04-22")]
alias PreInnerProductSpace.Core.conj_symm := PreInnerProductSpace.Core.conj_inner_symm
@[deprecated (since := "2025-04-22")]
alias PreInnerProductSpace.Core.inner_nonneg := PreInnerProductSpace.Core.re_inner_nonneg
attribute [class] PreInnerProductSpace.Core
/-- A structure requiring that a scalar product is positive definite. Some theorems that
require this assumptions are put under section `InnerProductSpace.Core`. -/
structure InnerProductSpace.Core (𝕜 : Type*) (F : Type*) [RCLike 𝕜] [AddCommGroup F]
[Module 𝕜 F] extends PreInnerProductSpace.Core 𝕜 F where
/-- The inner product is positive definite. -/
definite : ∀ x, inner x x = 0 → x = 0
/- We set `InnerProductSpace.Core` to be a class as we will use it as such in the construction
of the normed space structure that it produces. However, all the instances we will use will be
local to this proof. -/
attribute [class] InnerProductSpace.Core
instance (𝕜 : Type*) (F : Type*) [RCLike 𝕜] [AddCommGroup F]
[Module 𝕜 F] [cd : InnerProductSpace.Core 𝕜 F] : PreInnerProductSpace.Core 𝕜 F where
inner := cd.inner
conj_inner_symm := cd.conj_inner_symm
re_inner_nonneg := cd.re_inner_nonneg
add_left := cd.add_left
smul_left := cd.smul_left
/-- Define `PreInnerProductSpace.Core` from `InnerProductSpace`. Defined to reuse lemmas about
`PreInnerProductSpace.Core` for `PreInnerProductSpace`s. Note that the `Seminorm` instance provided
by `PreInnerProductSpace.Core.norm` is propositionally but not definitionally equal to the original
norm. -/
def PreInnerProductSpace.toCore [SeminormedAddCommGroup E] [c : InnerProductSpace 𝕜 E] :
PreInnerProductSpace.Core 𝕜 E where
__ := c
re_inner_nonneg x := by rw [← InnerProductSpace.norm_sq_eq_re_inner]; apply sq_nonneg
/-- Define `InnerProductSpace.Core` from `InnerProductSpace`. Defined to reuse lemmas about
`InnerProductSpace.Core` for `InnerProductSpace`s. Note that the `Norm` instance provided by
`InnerProductSpace.Core.norm` is propositionally but not definitionally equal to the original
norm. -/
def InnerProductSpace.toCore [NormedAddCommGroup E] [c : InnerProductSpace 𝕜 E] :
InnerProductSpace.Core 𝕜 E :=
{ c with
re_inner_nonneg := fun x => by
rw [← InnerProductSpace.norm_sq_eq_re_inner]
apply sq_nonneg
definite := fun x hx =>
norm_eq_zero.1 <| eq_zero_of_pow_eq_zero (n := 2) <| by
rw [InnerProductSpace.norm_sq_eq_re_inner (𝕜 := 𝕜) x, hx, map_zero] }
namespace InnerProductSpace.Core
section PreInnerProductSpace.Core
variable [AddCommGroup F] [Module 𝕜 F] [c : PreInnerProductSpace.Core 𝕜 F]
local notation "⟪" x ", " y "⟫" => inner 𝕜 x y
/-- Local notation for `RCLike.ext_iff 𝕜` -/
local notation "ext_iff" => @RCLike.ext_iff 𝕜 _
/-- Local notation for `starRingEnd _` -/
local postfix:90 "†" => starRingEnd _
/-- Inner product defined by the `PreInnerProductSpace.Core` structure. We can't reuse
`PreInnerProductSpace.Core.toInner` because it takes `PreInnerProductSpace.Core` as an explicit
argument. -/
def toPreInner' : Inner 𝕜 F :=
c.toInner
attribute [local instance] toPreInner'
/-- The norm squared function for `PreInnerProductSpace.Core` structure. -/
def normSq (x : F) :=
re ⟪x, x⟫
/-- The norm squared function for `PreInnerProductSpace.Core` structure. -/
local notation "normSqF" => @normSq 𝕜 F _ _ _ _
theorem inner_conj_symm (x y : F) : ⟪y, x⟫† = ⟪x, y⟫ :=
c.conj_inner_symm x y
theorem inner_self_nonneg {x : F} : 0 ≤ re ⟪x, x⟫ :=
c.re_inner_nonneg _
theorem inner_self_im (x : F) : im ⟪x, x⟫ = 0 := by
rw [← @ofReal_inj 𝕜, im_eq_conj_sub]
simp [inner_conj_symm]
theorem inner_add_left (x y z : F) : ⟪x + y, z⟫ = ⟪x, z⟫ + ⟪y, z⟫ :=
c.add_left _ _ _
theorem inner_add_right (x y z : F) : ⟪x, y + z⟫ = ⟪x, y⟫ + ⟪x, z⟫ := by
rw [← inner_conj_symm, inner_add_left, RingHom.map_add]; simp only [inner_conj_symm]
theorem ofReal_normSq_eq_inner_self (x : F) : (normSqF x : 𝕜) = ⟪x, x⟫ := by
rw [ext_iff]
exact ⟨by simp only [ofReal_re, normSq], by simp only [inner_self_im, ofReal_im]⟩
theorem inner_re_symm (x y : F) : re ⟪x, y⟫ = re ⟪y, x⟫ := by rw [← inner_conj_symm, conj_re]
theorem inner_im_symm (x y : F) : im ⟪x, y⟫ = -im ⟪y, x⟫ := by rw [← inner_conj_symm, conj_im]
theorem inner_smul_left (x y : F) {r : 𝕜} : ⟪r • x, y⟫ = r† * ⟪x, y⟫ :=
c.smul_left _ _ _
theorem inner_smul_right (x y : F) {r : 𝕜} : ⟪x, r • y⟫ = r * ⟪x, y⟫ := by
rw [← inner_conj_symm, inner_smul_left]
simp only [conj_conj, inner_conj_symm, RingHom.map_mul]
theorem inner_zero_left (x : F) : ⟪0, x⟫ = 0 := by
rw [← zero_smul 𝕜 (0 : F), inner_smul_left]
simp only [zero_mul, RingHom.map_zero]
theorem inner_zero_right (x : F) : ⟪x, 0⟫ = 0 := by
rw [← inner_conj_symm, inner_zero_left]; simp only [RingHom.map_zero]
theorem inner_self_of_eq_zero {x : F} : x = 0 → ⟪x, x⟫ = 0 := by
rintro rfl
exact inner_zero_left _
theorem normSq_eq_zero_of_eq_zero {x : F} : x = 0 → normSqF x = 0 := by
rintro rfl
simp [normSq, inner_self_of_eq_zero]
theorem ne_zero_of_inner_self_ne_zero {x : F} : ⟪x, x⟫ ≠ 0 → x ≠ 0 :=
mt inner_self_of_eq_zero
theorem inner_self_ofReal_re (x : F) : (re ⟪x, x⟫ : 𝕜) = ⟪x, x⟫ := by
norm_num [ext_iff, inner_self_im]
theorem norm_inner_symm (x y : F) : ‖⟪x, y⟫‖ = ‖⟪y, x⟫‖ := by rw [← inner_conj_symm, norm_conj]
theorem inner_neg_left (x y : F) : ⟪-x, y⟫ = -⟪x, y⟫ := by
rw [← neg_one_smul 𝕜 x, inner_smul_left]
simp
theorem inner_neg_right (x y : F) : ⟪x, -y⟫ = -⟪x, y⟫ := by
rw [← inner_conj_symm, inner_neg_left]; simp only [RingHom.map_neg, inner_conj_symm]
theorem inner_sub_left (x y z : F) : ⟪x - y, z⟫ = ⟪x, z⟫ - ⟪y, z⟫ := by
simp [sub_eq_add_neg, inner_add_left, inner_neg_left]
theorem inner_sub_right (x y z : F) : ⟪x, y - z⟫ = ⟪x, y⟫ - ⟪x, z⟫ := by
simp [sub_eq_add_neg, inner_add_right, inner_neg_right]
theorem inner_mul_symm_re_eq_norm (x y : F) : re (⟪x, y⟫ * ⟪y, x⟫) = ‖⟪x, y⟫ * ⟪y, x⟫‖ := by
rw [← inner_conj_symm, mul_comm]
exact re_eq_norm_of_mul_conj ⟪y, x⟫
/-- Expand `⟪x + y, x + y⟫` -/
theorem inner_add_add_self (x y : F) : ⟪x + y, x + y⟫ = ⟪x, x⟫ + ⟪x, y⟫ + ⟪y, x⟫ + ⟪y, y⟫ := by
simp only [inner_add_left, inner_add_right]; ring
-- Expand `⟪x - y, x - y⟫`
theorem inner_sub_sub_self (x y : F) : ⟪x - y, x - y⟫ = ⟪x, x⟫ - ⟪x, y⟫ - ⟪y, x⟫ + ⟪y, y⟫ := by
simp only [inner_sub_left, inner_sub_right]; ring
theorem inner_smul_ofReal_left (x y : F) {t : ℝ} : ⟪(t : 𝕜) • x, y⟫ = ⟪x, y⟫ * t := by
rw [inner_smul_left, conj_ofReal, mul_comm]
theorem inner_smul_ofReal_right (x y : F) {t : ℝ} : ⟪x, (t : 𝕜) • y⟫ = ⟪x, y⟫ * t := by
rw [inner_smul_right, mul_comm]
theorem re_inner_smul_ofReal_smul_self (x : F) {t : ℝ} :
re ⟪(t : 𝕜) • x, (t : 𝕜) • x⟫ = normSqF x * t * t := by
simp [inner_smul_ofReal_left, inner_smul_ofReal_right, normSq]
/-- An auxiliary equality useful to prove the **Cauchy–Schwarz inequality**. Here we use the
standard argument involving the discriminant of quadratic form. -/
lemma cauchy_schwarz_aux' (x y : F) (t : ℝ) : 0 ≤ normSqF x * t * t + 2 * re ⟪x, y⟫ * t
+ normSqF y := by
calc 0 ≤ re ⟪(ofReal t : 𝕜) • x + y, (ofReal t : 𝕜) • x + y⟫ := inner_self_nonneg
_ = re (⟪(ofReal t : 𝕜) • x, (ofReal t : 𝕜) • x⟫ + ⟪(ofReal t : 𝕜) • x, y⟫
+ ⟪y, (ofReal t : 𝕜) • x⟫ + ⟪y, y⟫) := by rw [inner_add_add_self ((ofReal t : 𝕜) • x) y]
_ = re ⟪(ofReal t : 𝕜) • x, (ofReal t : 𝕜) • x⟫
+ re ⟪(ofReal t : 𝕜) • x, y⟫ + re ⟪y, (ofReal t : 𝕜) • x⟫ + re ⟪y, y⟫ := by
simp only [map_add]
_ = normSq x * t * t + re (⟪x, y⟫ * t) + re (⟪y, x⟫ * t) + re ⟪y, y⟫ := by rw
[re_inner_smul_ofReal_smul_self, inner_smul_ofReal_left, inner_smul_ofReal_right]
_ = normSq x * t * t + re ⟪x, y⟫ * t + re ⟪y, x⟫ * t + re ⟪y, y⟫ := by rw [mul_comm ⟪x,y⟫ _,
RCLike.re_ofReal_mul, mul_comm t _, mul_comm ⟪y,x⟫ _, RCLike.re_ofReal_mul, mul_comm t _]
_ = normSq x * t * t + re ⟪x, y⟫ * t + re ⟪y, x⟫ * t + normSq y := by rw [← normSq]
_ = normSq x * t * t + re ⟪x, y⟫ * t + re ⟪x, y⟫ * t + normSq y := by rw [inner_re_symm]
_ = normSq x * t * t + 2 * re ⟪x, y⟫ * t + normSq y := by ring
/-- Another auxiliary equality related with the **Cauchy–Schwarz inequality**: the square of the
seminorm of `⟪x, y⟫ • x - ⟪x, x⟫ • y` is equal to `‖x‖ ^ 2 * (‖x‖ ^ 2 * ‖y‖ ^ 2 - ‖⟪x, y⟫‖ ^ 2)`.
We use `InnerProductSpace.ofCore.normSq x` etc. (defeq to `is_R_or_C.re ⟪x, x⟫`) instead of
`‖x‖ ^ 2` etc. to avoid extra rewrites when applying it to an `InnerProductSpace`. -/
theorem cauchy_schwarz_aux (x y : F) : normSqF (⟪x, y⟫ • x - ⟪x, x⟫ • y)
= normSqF x * (normSqF x * normSqF y - ‖⟪x, y⟫‖ ^ 2) := by
rw [← @ofReal_inj 𝕜, ofReal_normSq_eq_inner_self]
simp only [inner_sub_sub_self, inner_smul_left, inner_smul_right, conj_ofReal, mul_sub, ←
ofReal_normSq_eq_inner_self x, ← ofReal_normSq_eq_inner_self y]
rw [← mul_assoc, mul_conj, RCLike.conj_mul, mul_left_comm, ← inner_conj_symm y, mul_conj]
push_cast
ring
/-- **Cauchy–Schwarz inequality**.
We need this for the `PreInnerProductSpace.Core` structure to prove the triangle inequality below
when showing the core is a normed group and to take the quotient.
(This is not intended for general use; see `Analysis.InnerProductSpace.Basic` for a variety of
versions of Cauchy-Schwarz for an inner product space, rather than a `PreInnerProductSpace.Core`).
-/
theorem inner_mul_inner_self_le (x y : F) : ‖⟪x, y⟫‖ * ‖⟪y, x⟫‖ ≤ re ⟪x, x⟫ * re ⟪y, y⟫ := by
suffices discrim (normSqF x) (2 * ‖⟪x, y⟫_𝕜‖) (normSqF y) ≤ 0 by
rw [norm_inner_symm y x]
rw [discrim, normSq, normSq, sq] at this
linarith
refine discrim_le_zero fun t ↦ ?_
by_cases hzero : ⟪x, y⟫ = 0
· simp only [← sq, hzero, norm_zero, mul_zero, zero_mul, add_zero]
obtain ⟨hx, hy⟩ : (0 ≤ normSqF x ∧ 0 ≤ normSqF y) := ⟨inner_self_nonneg, inner_self_nonneg⟩
positivity
· have hzero' : ‖⟪x, y⟫‖ ≠ 0 := norm_ne_zero_iff.2 hzero
convert cauchy_schwarz_aux' (𝕜 := 𝕜) (⟪x, y⟫ • x) y (t / ‖⟪x, y⟫‖) using 3
· field_simp
rw [normSq, normSq, inner_smul_right, inner_smul_left, ← mul_assoc _ _ ⟪x, x⟫,
mul_conj]
rw [← ofReal_pow, re_ofReal_mul]
ring
· field_simp
rw [inner_smul_left, mul_comm _ ⟪x, y⟫_𝕜, mul_conj, ← ofReal_pow, ofReal_re]
ring
/-- (Semi)norm constructed from a `PreInnerProductSpace.Core` structure, defined to be the square
root of the scalar product. -/
def toNorm : Norm F where norm x := √(re ⟪x, x⟫)
attribute [local instance] toNorm
theorem norm_eq_sqrt_re_inner (x : F) : ‖x‖ = √(re ⟪x, x⟫) := rfl
@[deprecated (since := "2025-04-22")] alias norm_eq_sqrt_inner := norm_eq_sqrt_re_inner
theorem inner_self_eq_norm_mul_norm (x : F) : re ⟪x, x⟫ = ‖x‖ * ‖x‖ := by
rw [norm_eq_sqrt_re_inner, ← sqrt_mul inner_self_nonneg, sqrt_mul_self inner_self_nonneg]
theorem sqrt_normSq_eq_norm (x : F) : √(normSqF x) = ‖x‖ := rfl
/-- Cauchy–Schwarz inequality with norm -/
theorem norm_inner_le_norm (x y : F) : ‖⟪x, y⟫‖ ≤ ‖x‖ * ‖y‖ :=
nonneg_le_nonneg_of_sq_le_sq (mul_nonneg (sqrt_nonneg _) (sqrt_nonneg _)) <|
calc
‖⟪x, y⟫‖ * ‖⟪x, y⟫‖ = ‖⟪x, y⟫‖ * ‖⟪y, x⟫‖ := by rw [norm_inner_symm]
_ ≤ re ⟪x, x⟫ * re ⟪y, y⟫ := inner_mul_inner_self_le x y
_ = ‖x‖ * ‖y‖ * (‖x‖ * ‖y‖) := by simp only [inner_self_eq_norm_mul_norm]; ring
/-- Seminormed group structure constructed from a `PreInnerProductSpace.Core` structure -/
def toSeminormedAddCommGroup : SeminormedAddCommGroup F :=
AddGroupSeminorm.toSeminormedAddCommGroup
{ toFun := fun x => √(re ⟪x, x⟫)
map_zero' := by simp only [sqrt_zero, inner_zero_right, map_zero]
neg' := fun x => by simp only [inner_neg_left, neg_neg, inner_neg_right]
add_le' := fun x y => by
have h₁ : ‖⟪x, y⟫‖ ≤ ‖x‖ * ‖y‖ := norm_inner_le_norm _ _
have h₂ : re ⟪x, y⟫ ≤ ‖⟪x, y⟫‖ := re_le_norm _
have h₃ : re ⟪x, y⟫ ≤ ‖x‖ * ‖y‖ := h₂.trans h₁
have h₄ : re ⟪y, x⟫ ≤ ‖x‖ * ‖y‖ := by rwa [← inner_conj_symm, conj_re]
have : ‖x + y‖ * ‖x + y‖ ≤ (‖x‖ + ‖y‖) * (‖x‖ + ‖y‖) := by
simp only [← inner_self_eq_norm_mul_norm, inner_add_add_self, mul_add, mul_comm, map_add]
linarith
exact nonneg_le_nonneg_of_sq_le_sq (add_nonneg (sqrt_nonneg _) (sqrt_nonneg _)) this }
attribute [local instance] toSeminormedAddCommGroup
/-- Normed space (which is actually a seminorm in general) structure constructed from a
`PreInnerProductSpace.Core` structure -/
def toNormedSpace : NormedSpace 𝕜 F where
norm_smul_le r x := by
rw [norm_eq_sqrt_re_inner, inner_smul_left, inner_smul_right, ← mul_assoc]
rw [RCLike.conj_mul, ← ofReal_pow, re_ofReal_mul, sqrt_mul, ← ofReal_normSq_eq_inner_self,
ofReal_re]
· simp [sqrt_normSq_eq_norm]
· positivity
@[deprecated (since := "2025-06-03")] alias toSeminormedSpace := toNormedSpace
omit c in
/-- Seminormed space core structure constructed from a `PreInnerProductSpace.Core` structure -/
lemma toSeminormedSpaceCore (c : PreInnerProductSpace.Core 𝕜 F) : SeminormedSpace.Core 𝕜 F where
norm_nonneg x := norm_nonneg x
norm_smul c x := by
letI : NormedSpace 𝕜 F := toNormedSpace
exact _root_.norm_smul c x
norm_triangle x y := norm_add_le x y
end PreInnerProductSpace.Core
section InnerProductSpace.Core
variable [AddCommGroup F] [Module 𝕜 F] [cd : InnerProductSpace.Core 𝕜 F]
local notation "⟪" x ", " y "⟫" => inner 𝕜 x y
local notation "ext_iff" => @RCLike.ext_iff 𝕜 _
/-- Inner product defined by the `InnerProductSpace.Core` structure. We can't reuse
`InnerProductSpace.Core.toInner` because it takes `InnerProductSpace.Core` as an explicit
argument. -/
def toInner' : Inner 𝕜 F :=
cd.toInner
attribute [local instance] toInner'
local notation "normSqF" => @normSq 𝕜 F _ _ _ _
theorem inner_self_eq_zero {x : F} : ⟪x, x⟫ = 0 ↔ x = 0 :=
⟨cd.definite _, inner_self_of_eq_zero⟩
theorem normSq_eq_zero {x : F} : normSqF x = 0 ↔ x = 0 :=
Iff.trans
(by simp only [normSq, ext_iff, map_zero, inner_self_im, and_true])
(inner_self_eq_zero (𝕜 := 𝕜))
theorem inner_self_ne_zero {x : F} : ⟪x, x⟫ ≠ 0 ↔ x ≠ 0 :=
inner_self_eq_zero.not
attribute [local instance] toNorm
/-- Normed group structure constructed from an `InnerProductSpace.Core` structure -/
def toNormedAddCommGroup : NormedAddCommGroup F :=
AddGroupNorm.toNormedAddCommGroup
{ toFun := fun x => √(re ⟪x, x⟫)
map_zero' := by simp only [sqrt_zero, inner_zero_right, map_zero]
neg' := fun x => by simp only [inner_neg_left, neg_neg, inner_neg_right]
add_le' := fun x y => by
have h₁ : ‖⟪x, y⟫‖ ≤ ‖x‖ * ‖y‖ := norm_inner_le_norm _ _
have h₂ : re ⟪x, y⟫ ≤ ‖⟪x, y⟫‖ := re_le_norm _
have h₃ : re ⟪x, y⟫ ≤ ‖x‖ * ‖y‖ := h₂.trans h₁
have h₄ : re ⟪y, x⟫ ≤ ‖x‖ * ‖y‖ := by rwa [← inner_conj_symm, conj_re]
have : ‖x + y‖ * ‖x + y‖ ≤ (‖x‖ + ‖y‖) * (‖x‖ + ‖y‖) := by
simp only [← inner_self_eq_norm_mul_norm, inner_add_add_self, mul_add, mul_comm, map_add]
linarith
exact nonneg_le_nonneg_of_sq_le_sq (add_nonneg (sqrt_nonneg _) (sqrt_nonneg _)) this
eq_zero_of_map_eq_zero' := fun _ hx =>
normSq_eq_zero.1 <| (sqrt_eq_zero inner_self_nonneg).1 hx }
section
attribute [local instance] toNormedAddCommGroup
omit cd in
/-- Normed space core structure constructed from an `InnerProductSpace.Core` structure -/
lemma toNormedSpaceCore (cd : InnerProductSpace.Core 𝕜 F) : NormedSpace.Core 𝕜 F where
norm_nonneg x := norm_nonneg x
norm_eq_zero_iff x := norm_eq_zero
norm_smul c x := by
letI : NormedSpace 𝕜 F := toNormedSpace
exact _root_.norm_smul c x
norm_triangle x y := norm_add_le x y
end
/-- In a topological vector space, if the unit ball of a continuous inner product is von Neumann
bounded, then the inner product defines the same topology as the original one. -/
lemma topology_eq
[tF : TopologicalSpace F] [IsTopologicalAddGroup F] [ContinuousConstSMul 𝕜 F]
(h : ContinuousAt (fun (v : F) ↦ cd.inner v v) 0)
(h' : IsVonNBounded 𝕜 {v : F | re (cd.inner v v) < 1}) :
tF = cd.toNormedAddCommGroup.toMetricSpace.toUniformSpace.toTopologicalSpace := by
let p : Seminorm 𝕜 F := @normSeminorm 𝕜 F _ cd.toNormedAddCommGroup.toSeminormedAddCommGroup
InnerProductSpace.Core.toNormedSpace
suffices WithSeminorms (fun (i : Fin 1) ↦ p) by
rw [(SeminormFamily.withSeminorms_iff_topologicalSpace_eq_iInf _).1 this]
simp
have : p.ball 0 1 = {v | re (cd.inner v v) < 1} := by
ext v
simp only [ball_normSeminorm, Metric.mem_ball, dist_eq_norm, sub_zero, Set.mem_setOf_eq, p]
change √(re (cd.inner v v)) < 1 ↔ re (cd.inner v v) < 1
conv_lhs => rw [show (1 : ℝ) = √ 1 by simp]
rw [sqrt_lt_sqrt_iff]
exact InnerProductSpace.Core.inner_self_nonneg
rw [withSeminorms_iff_mem_nhds_isVonNBounded, this]
refine ⟨?_, h'⟩
have A : ContinuousAt (fun (v : F) ↦ re (cd.inner v v)) 0 := by fun_prop
have B : Set.Iio 1 ∈ 𝓝 (re (cd.inner 0 0)) := by
simp only [InnerProductSpace.Core.inner_zero_left, map_zero]
exact Iio_mem_nhds (by positivity)
exact A B
/-- Normed space structure constructed from an `InnerProductSpace.Core` structure, adjusting the
topology to make sure it is defeq to an already existing topology. -/
@[reducible] def toNormedAddCommGroupOfTopology
[tF : TopologicalSpace F] [IsTopologicalAddGroup F] [ContinuousConstSMul 𝕜 F]
(h : ContinuousAt (fun (v : F) ↦ cd.inner v v) 0)
(h' : IsVonNBounded 𝕜 {v : F | re (cd.inner v v) < 1}) :
NormedAddCommGroup F :=
NormedAddCommGroup.ofCoreReplaceTopology cd.toNormedSpaceCore (cd.topology_eq h h')
/-- Normed space structure constructed from an `InnerProductSpace.Core` structure, adjusting the
topology to make sure it is defeq to an already existing topology. -/
@[reducible] def toNormedSpaceOfTopology
[tF : TopologicalSpace F] [IsTopologicalAddGroup F] [ContinuousConstSMul 𝕜 F]
(h : ContinuousAt (fun (v : F) ↦ cd.inner v v) 0)
(h' : IsVonNBounded 𝕜 {v : F | re (cd.inner v v) < 1}) :
letI : NormedAddCommGroup F := cd.toNormedAddCommGroupOfTopology h h';
NormedSpace 𝕜 F :=
letI : NormedAddCommGroup F := cd.toNormedAddCommGroupOfTopology h h'
{ norm_smul_le r x := by
rw [norm_eq_sqrt_re_inner, inner_smul_left, inner_smul_right, ← mul_assoc]
rw [RCLike.conj_mul, ← ofReal_pow, re_ofReal_mul, sqrt_mul, ← ofReal_normSq_eq_inner_self,
ofReal_re]
· simp [sqrt_normSq_eq_norm]
· positivity }
end InnerProductSpace.Core
end InnerProductSpace.Core
section
attribute [local instance] InnerProductSpace.Core.toSeminormedAddCommGroup
/-- Given a `PreInnerProductSpace.Core` structure on a space, one can use it to turn
the space into a pre-inner product space (i.e., `SeminormedAddCommGroup` and `InnerProductSpace`).
The `SeminormedAddCommGroup` structure is expected to already be defined with
`InnerProductSpace.ofCore.toSeminormedAddCommGroup`. -/
def InnerProductSpace.ofCore [AddCommGroup F] [Module 𝕜 F] (cd : PreInnerProductSpace.Core 𝕜 F) :
InnerProductSpace 𝕜 F :=
letI : NormedSpace 𝕜 F := InnerProductSpace.Core.toNormedSpace
{ cd with
norm_sq_eq_re_inner := fun x => by
have h₁ : ‖x‖ ^ 2 = √(re (cd.inner x x)) ^ 2 := rfl
have h₂ : 0 ≤ re (cd.inner x x) := InnerProductSpace.Core.inner_self_nonneg
simp [h₁, sq_sqrt, h₂] }
end
/-- Given an `InnerProductSpace.Core` structure on a space with a topology, one can use it to turn
the space into an inner product space. The `NormedAddCommGroup` structure is expected
to already be defined with `InnerProductSpace.ofCore.toNormedAddCommGroupOfTopology`. -/
def InnerProductSpace.ofCoreOfTopology [AddCommGroup F] [hF : Module 𝕜 F] [TopologicalSpace F]
[IsTopologicalAddGroup F] [ContinuousConstSMul 𝕜 F]
(cd : InnerProductSpace.Core 𝕜 F)
(h : ContinuousAt (fun (v : F) ↦ cd.inner v v) 0)
(h' : IsVonNBounded 𝕜 {v : F | re (cd.inner v v) < 1}) :
letI : NormedAddCommGroup F := cd.toNormedAddCommGroupOfTopology h h';
InnerProductSpace 𝕜 F :=
letI : NormedAddCommGroup F := cd.toNormedAddCommGroupOfTopology h h'
letI : NormedSpace 𝕜 F := cd.toNormedSpaceOfTopology h h'
{ cd with
norm_sq_eq_re_inner := fun x => by
have h₁ : ‖x‖ ^ 2 = √(re (cd.inner x x)) ^ 2 := rfl
have h₂ : 0 ≤ re (cd.inner x x) := InnerProductSpace.Core.inner_self_nonneg
simp [h₁, sq_sqrt, h₂] }
/-- A Hilbert space is a complete normed inner product space. -/
@[variable_alias]
structure HilbertSpace (𝕜 E : Type*) [RCLike 𝕜]
[NormedAddCommGroup E] [InnerProductSpace 𝕜 E] [CompleteSpace E]
end |
.lake/packages/mathlib/Mathlib/Analysis/InnerProductSpace/PiL2.lean | import Mathlib.Analysis.InnerProductSpace.Projection.FiniteDimensional
import Mathlib.Analysis.Normed.Lp.PiLp
import Mathlib.LinearAlgebra.FiniteDimensional.Lemmas
import Mathlib.LinearAlgebra.UnitaryGroup
import Mathlib.Util.Superscript
/-!
# `L²` inner product space structure on finite products of inner product spaces
The `L²` norm on a finite product of inner product spaces is compatible with an inner product
$$
\langle x, y\rangle = \sum \langle x_i, y_i \rangle.
$$
This is recorded in this file as an inner product space instance on `PiLp 2`.
This file develops the notion of a finite-dimensional Hilbert space over `𝕜 = ℂ, ℝ`, referred to as
`E`. We define an `OrthonormalBasis 𝕜 ι E` as a linear isometric equivalence
between `E` and `EuclideanSpace 𝕜 ι`. Then `stdOrthonormalBasis` shows that such an equivalence
always exists if `E` is finite dimensional. We provide language for converting between a basis
that is orthonormal and an orthonormal basis (e.g. `Basis.toOrthonormalBasis`). We show that
orthonormal bases for each summand in a direct sum of spaces can be combined into an orthonormal
basis for the whole sum in `DirectSum.IsInternal.subordinateOrthonormalBasis`. In
the last section, various properties of matrices are explored.
## Main definitions
- `EuclideanSpace 𝕜 n`: defined to be `PiLp 2 (n → 𝕜)` for any `Fintype n`, i.e., the space
from functions to `n` to `𝕜` with the `L²` norm. We register several instances on it (notably
that it is a finite-dimensional inner product space), and provide a `!ₚ[]` notation (for numeric
subscripts like `₂`) for the case when the indexing type is `Fin n`.
- `OrthonormalBasis 𝕜 ι`: defined to be an isometry to Euclidean space from a given
finite-dimensional inner product space, `E ≃ₗᵢ[𝕜] EuclideanSpace 𝕜 ι`.
- `Basis.toOrthonormalBasis`: constructs an `OrthonormalBasis` for a finite-dimensional
Euclidean space from a `Basis` which is `Orthonormal`.
- `Orthonormal.exists_orthonormalBasis_extension`: provides an existential result of an
`OrthonormalBasis` extending a given orthonormal set
- `exists_orthonormalBasis`: provides an orthonormal basis on a finite-dimensional vector space
- `stdOrthonormalBasis`: provides an arbitrarily-chosen `OrthonormalBasis` of a given
finite-dimensional inner product space
For consequences in infinite dimension (Hilbert bases, etc.), see the file
`Analysis.InnerProductSpace.L2Space`.
-/
open Module Real Set Filter RCLike Submodule Function Uniformity Topology NNReal ENNReal
ComplexConjugate DirectSum WithLp
noncomputable section
variable {ι ι' 𝕜 : Type*} [RCLike 𝕜]
variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace 𝕜 E]
variable {F : Type*} [NormedAddCommGroup F] [InnerProductSpace ℝ F]
variable {F' : Type*} [NormedAddCommGroup F'] [InnerProductSpace ℝ F']
local notation "⟪" x ", " y "⟫" => inner 𝕜 x y
/-
If `ι` is a finite type and each space `f i`, `i : ι`, is an inner product space,
then `Π i, f i` is an inner product space as well. Since `Π i, f i` is endowed with the sup norm,
we use instead `PiLp 2 f` for the product space, which is endowed with the `L^2` norm.
-/
instance PiLp.innerProductSpace {ι : Type*} [Fintype ι] (f : ι → Type*)
[∀ i, NormedAddCommGroup (f i)] [∀ i, InnerProductSpace 𝕜 (f i)] :
InnerProductSpace 𝕜 (PiLp 2 f) where
inner x y := ∑ i, ⟪x i, y i⟫
norm_sq_eq_re_inner x := by
simp only [PiLp.norm_sq_eq_of_L2, map_sum, ← norm_sq_eq_re_inner]
conj_inner_symm := by
intro x y
unfold inner
rw [map_sum]
apply Finset.sum_congr rfl
rintro z -
apply inner_conj_symm
add_left x y z :=
show (∑ i, ⟪x i + y i, z i⟫ = ∑ i, ⟪x i, z i⟫ + ∑ i, ⟪y i, z i⟫) by
simp only [inner_add_left, Finset.sum_add_distrib]
smul_left x y r :=
show (∑ i : ι, ⟪r • x i, y i⟫ = conj r * ∑ i, ⟪x i, y i⟫) by
simp only [Finset.mul_sum, inner_smul_left]
theorem PiLp.inner_apply {ι : Type*} [Fintype ι] {f : ι → Type*} [∀ i, NormedAddCommGroup (f i)]
[∀ i, InnerProductSpace 𝕜 (f i)] (x y : PiLp 2 f) : ⟪x, y⟫ = ∑ i, ⟪x i, y i⟫ :=
rfl
/-- The standard real/complex Euclidean space, functions on a finite type. For an `n`-dimensional
space use `EuclideanSpace 𝕜 (Fin n)`.
For the case when `n = Fin _`, there is `!₂[x, y, ...]` notation for building elements of this type,
analogous to `![x, y, ...]` notation. -/
abbrev EuclideanSpace (𝕜 : Type*) (n : Type*) : Type _ :=
PiLp 2 fun _ : n => 𝕜
section Notation
open Lean Meta Elab Term Macro TSyntax PrettyPrinter.Delaborator SubExpr
open Mathlib.Tactic (subscriptTerm)
/-- Notation for vectors in Lp space. `!₂[x, y, ...]` is a shorthand for
`WithLp.toLp 2 ![x, y, ...]`, of type `EuclideanSpace _ (Fin _)`.
This also works for other subscripts. -/
syntax (name := PiLp.vecNotation) "!" noWs subscriptTerm noWs "[" term,* "]" : term
macro_rules | `(!$p:subscript[$e:term,*]) => do
-- override the `Fin n.succ` to a literal
let n := e.getElems.size
`(WithLp.toLp $p (V := ∀ _ : Fin $(quote n), _) ![$e,*])
/-- Unexpander for the `!₂[x, y, ...]` notation. -/
@[app_delab WithLp.toLp]
def EuclideanSpace.delabVecNotation : Delab :=
whenNotPPOption getPPExplicit <| whenPPOption getPPNotation <| withOverApp 3 do
-- check that the `WithLp.toLp _` is present
let p : Term ← withNaryArg 0 <| delab
-- to be conservative, only allow subscripts which are numerals
guard <| p matches `($_:num)
let `(![$elems,*]) := ← withNaryArg 2 delab | failure
`(!$p[$elems,*])
end Notation
theorem EuclideanSpace.nnnorm_eq {𝕜 : Type*} [RCLike 𝕜] {n : Type*} [Fintype n]
(x : EuclideanSpace 𝕜 n) : ‖x‖₊ = NNReal.sqrt (∑ i, ‖x i‖₊ ^ 2) :=
PiLp.nnnorm_eq_of_L2 x
theorem EuclideanSpace.norm_eq {𝕜 : Type*} [RCLike 𝕜] {n : Type*} [Fintype n]
(x : EuclideanSpace 𝕜 n) : ‖x‖ = √(∑ i, ‖x i‖ ^ 2) := by
simpa only [Real.coe_sqrt, NNReal.coe_sum] using congr_arg ((↑) : ℝ≥0 → ℝ) x.nnnorm_eq
theorem EuclideanSpace.norm_sq_eq {𝕜 : Type*} [RCLike 𝕜] {n : Type*} [Fintype n]
(x : EuclideanSpace 𝕜 n) : ‖x‖ ^ 2 = ∑ i, ‖x i‖ ^ 2 :=
PiLp.norm_sq_eq_of_L2 _ x
theorem EuclideanSpace.dist_eq {𝕜 : Type*} [RCLike 𝕜] {n : Type*} [Fintype n]
(x y : EuclideanSpace 𝕜 n) : dist x y = √(∑ i, dist (x i) (y i) ^ 2) :=
PiLp.dist_eq_of_L2 x y
theorem EuclideanSpace.dist_sq_eq {𝕜 : Type*} [RCLike 𝕜] {n : Type*} [Fintype n]
(x y : EuclideanSpace 𝕜 n) : dist x y ^ 2 = ∑ i, dist (x i) (y i) ^ 2 :=
PiLp.dist_sq_eq_of_L2 x y
theorem EuclideanSpace.nndist_eq {𝕜 : Type*} [RCLike 𝕜] {n : Type*} [Fintype n]
(x y : EuclideanSpace 𝕜 n) : nndist x y = NNReal.sqrt (∑ i, nndist (x i) (y i) ^ 2) :=
PiLp.nndist_eq_of_L2 x y
theorem EuclideanSpace.edist_eq {𝕜 : Type*} [RCLike 𝕜] {n : Type*} [Fintype n]
(x y : EuclideanSpace 𝕜 n) : edist x y = (∑ i, edist (x i) (y i) ^ 2) ^ (1 / 2 : ℝ) :=
PiLp.edist_eq_of_L2 x y
theorem EuclideanSpace.ball_zero_eq {n : Type*} [Fintype n] (r : ℝ) (hr : 0 ≤ r) :
Metric.ball (0 : EuclideanSpace ℝ n) r = {x | ∑ i, x i ^ 2 < r ^ 2} := by
ext x
have : (0 : ℝ) ≤ ∑ i, x i ^ 2 := Finset.sum_nonneg fun _ _ => sq_nonneg _
simp_rw [mem_setOf, mem_ball_zero_iff, norm_eq, norm_eq_abs, sq_abs, sqrt_lt this hr]
theorem EuclideanSpace.closedBall_zero_eq {n : Type*} [Fintype n] (r : ℝ) (hr : 0 ≤ r) :
Metric.closedBall (0 : EuclideanSpace ℝ n) r = {x | ∑ i, x i ^ 2 ≤ r ^ 2} := by
ext
simp_rw [mem_setOf, mem_closedBall_zero_iff, norm_eq, norm_eq_abs, sq_abs, sqrt_le_left hr]
theorem EuclideanSpace.sphere_zero_eq {n : Type*} [Fintype n] (r : ℝ) (hr : 0 ≤ r) :
Metric.sphere (0 : EuclideanSpace ℝ n) r = {x | ∑ i, x i ^ 2 = r ^ 2} := by
ext x
have : (0 : ℝ) ≤ ∑ i, x i ^ 2 := Finset.sum_nonneg fun _ _ => sq_nonneg _
simp_rw [mem_setOf, mem_sphere_zero_iff_norm, norm_eq, norm_eq_abs, sq_abs,
Real.sqrt_eq_iff_eq_sq this hr]
section
variable [Fintype ι]
@[simp]
theorem finrank_euclideanSpace :
Module.finrank 𝕜 (EuclideanSpace 𝕜 ι) = Fintype.card ι := by
convert (WithLp.linearEquiv 2 𝕜 (ι → 𝕜)).finrank_eq
simp
theorem finrank_euclideanSpace_fin {n : ℕ} :
Module.finrank 𝕜 (EuclideanSpace 𝕜 (Fin n)) = n := by simp
theorem EuclideanSpace.inner_eq_star_dotProduct (x y : EuclideanSpace 𝕜 ι) :
⟪x, y⟫ = ofLp y ⬝ᵥ star (ofLp x) := rfl
lemma EuclideanSpace.inner_toLp_toLp (x y : ι → 𝕜) :
⟪toLp 2 x, toLp 2 y⟫ = dotProduct y (star x) := rfl
/-- A finite, mutually orthogonal family of subspaces of `E`, which span `E`, induce an isometry
from `E` to `PiLp 2` of the subspaces equipped with the `L2` inner product. -/
def DirectSum.IsInternal.isometryL2OfOrthogonalFamily [DecidableEq ι] {V : ι → Submodule 𝕜 E}
(hV : DirectSum.IsInternal V)
(hV' : OrthogonalFamily 𝕜 (fun i => V i) fun i => (V i).subtypeₗᵢ) :
E ≃ₗᵢ[𝕜] PiLp 2 fun i => V i := by
let e₁ := DirectSum.linearEquivFunOnFintype 𝕜 ι fun i => V i
let e₂ := LinearEquiv.ofBijective (DirectSum.coeLinearMap V) hV
refine LinearEquiv.isometryOfInner ((e₂.symm.trans e₁).trans
(WithLp.linearEquiv 2 𝕜 (Π i, V i)).symm) ?_
suffices ∀ (v w : PiLp 2 fun i => V i), ⟪v, w⟫ = ⟪e₂ (e₁.symm v), e₂ (e₁.symm w)⟫ by
intro v₀ w₀
simp only [LinearEquiv.trans_apply, linearEquiv_symm_apply]
convert this (toLp 2 (e₁ (e₂.symm v₀))) (toLp 2 (e₁ (e₂.symm w₀))) <;> simp
intro v w
trans ⟪∑ i, (V i).subtypeₗᵢ (v i), ∑ i, (V i).subtypeₗᵢ (w i)⟫
· simp only [sum_inner, hV'.inner_right_fintype, PiLp.inner_apply]
· congr <;> simp
@[simp]
theorem DirectSum.IsInternal.isometryL2OfOrthogonalFamily_symm_apply [DecidableEq ι]
{V : ι → Submodule 𝕜 E} (hV : DirectSum.IsInternal V)
(hV' : OrthogonalFamily 𝕜 (fun i => V i) fun i => (V i).subtypeₗᵢ) (w : PiLp 2 fun i => V i) :
(hV.isometryL2OfOrthogonalFamily hV').symm w = ∑ i, (w i : E) := by
classical
let e₁ := DirectSum.linearEquivFunOnFintype 𝕜 ι fun i => V i
let e₂ := LinearEquiv.ofBijective (DirectSum.coeLinearMap V) hV
suffices ∀ v : ⨁ i, V i, e₂ v = ∑ i, e₁ v i by exact this (e₁.symm w)
intro v
simp [e₁, e₂, DirectSum.coeLinearMap, DirectSum.toModule, DFinsupp.lsum,
DFinsupp.sumAddHom_apply]
end
variable (ι 𝕜)
/-- A shorthand for `PiLp.continuousLinearEquiv`. -/
abbrev EuclideanSpace.equiv : EuclideanSpace 𝕜 ι ≃L[𝕜] ι → 𝕜 :=
PiLp.continuousLinearEquiv 2 𝕜 _
variable {ι 𝕜}
/-- The projection on the `i`-th coordinate of `EuclideanSpace 𝕜 ι`, as a linear map. -/
abbrev EuclideanSpace.projₗ (i : ι) : EuclideanSpace 𝕜 ι →ₗ[𝕜] 𝕜 := PiLp.projₗ _ _ i
/-- The projection on the `i`-th coordinate of `EuclideanSpace 𝕜 ι`, as a continuous linear map. -/
abbrev EuclideanSpace.proj (i : ι) : StrongDual 𝕜 (EuclideanSpace 𝕜 ι) := PiLp.proj _ _ i
section DecEq
variable [DecidableEq ι]
-- TODO : This should be generalized to `PiLp`.
/-- The vector given in Euclidean space by being `a : 𝕜` at coordinate `i : ι` and `0 : 𝕜` at
all other coordinates. -/
def EuclideanSpace.single (i : ι) (a : 𝕜) : EuclideanSpace 𝕜 ι :=
toLp _ (Pi.single i a)
@[simp] lemma EuclideanSpace.ofLp_single (i : ι) (a : 𝕜) : ofLp (single i a) = Pi.single i a := rfl
@[simp]
lemma EuclideanSpace.toLp_single (i : ι) (a : 𝕜) : toLp _ (Pi.single i a) = single i a := rfl
@[simp]
theorem EuclideanSpace.single_apply (i : ι) (a : 𝕜) (j : ι) :
(EuclideanSpace.single i a) j = ite (j = i) a 0 := by
rw [EuclideanSpace.single, PiLp.toLp_apply, ← Pi.single_apply i a j]
@[simp]
theorem EuclideanSpace.single_eq_zero_iff {i : ι} {a : 𝕜} :
EuclideanSpace.single i a = 0 ↔ a = 0 := (toLp_eq_zero 2).trans Pi.single_eq_zero_iff
variable [Fintype ι]
theorem EuclideanSpace.inner_single_left (i : ι) (a : 𝕜) (v : EuclideanSpace 𝕜 ι) :
⟪EuclideanSpace.single i (a : 𝕜), v⟫ = conj a * v i := by
simp [PiLp.inner_apply, apply_ite conj, mul_comm]
theorem EuclideanSpace.inner_single_right (i : ι) (a : 𝕜) (v : EuclideanSpace 𝕜 ι) :
⟪v, EuclideanSpace.single i (a : 𝕜)⟫ = a * conj (v i) := by simp [PiLp.inner_apply]
@[simp]
theorem EuclideanSpace.norm_single (i : ι) (a : 𝕜) :
‖EuclideanSpace.single i (a : 𝕜)‖ = ‖a‖ :=
PiLp.norm_toLp_single 2 (fun _ => 𝕜) i a
@[simp]
theorem EuclideanSpace.nnnorm_single (i : ι) (a : 𝕜) :
‖EuclideanSpace.single i (a : 𝕜)‖₊ = ‖a‖₊ :=
PiLp.nnnorm_toLp_single 2 (fun _ => 𝕜) i a
@[simp]
theorem EuclideanSpace.dist_single_same (i : ι) (a b : 𝕜) :
dist (EuclideanSpace.single i (a : 𝕜)) (EuclideanSpace.single i (b : 𝕜)) = dist a b :=
PiLp.dist_toLp_single_same 2 (fun _ => 𝕜) i a b
@[simp]
theorem EuclideanSpace.nndist_single_same (i : ι) (a b : 𝕜) :
nndist (EuclideanSpace.single i (a : 𝕜)) (EuclideanSpace.single i (b : 𝕜)) = nndist a b :=
PiLp.nndist_toLp_single_same 2 (fun _ => 𝕜) i a b
@[simp]
theorem EuclideanSpace.edist_single_same (i : ι) (a b : 𝕜) :
edist (EuclideanSpace.single i (a : 𝕜)) (EuclideanSpace.single i (b : 𝕜)) = edist a b :=
PiLp.edist_toLp_single_same 2 (fun _ => 𝕜) i a b
/-- `EuclideanSpace.single` forms an orthonormal family. -/
theorem EuclideanSpace.orthonormal_single :
Orthonormal 𝕜 fun i : ι => EuclideanSpace.single i (1 : 𝕜) := by
simp_rw [orthonormal_iff_ite, EuclideanSpace.inner_single_left, map_one, one_mul,
EuclideanSpace.single_apply]
intros
trivial
theorem EuclideanSpace.piLpCongrLeft_single
{ι' : Type*} [Fintype ι'] [DecidableEq ι'] (e : ι' ≃ ι) (i' : ι') (v : 𝕜) :
LinearIsometryEquiv.piLpCongrLeft 2 𝕜 𝕜 e (EuclideanSpace.single i' v) =
EuclideanSpace.single (e i') v :=
LinearIsometryEquiv.piLpCongrLeft_single e i' _
end DecEq
section finAddEquivProd
/-- The canonical linear homeomorphism between `EuclideanSpace 𝕜 (ι ⊕ κ)` and
`EuclideanSpace 𝕜 ι × EuclideanSpace 𝕜 κ`.
See `PiLp.sumPiLpEquivProdLpPiLp` for the isometry version,
where the RHS is equipped with the Euclidean norm rather than the supremum norm. -/
abbrev EuclideanSpace.sumEquivProd {𝕜 : Type*} [RCLike 𝕜] {ι κ : Type*} [Fintype ι] [Fintype κ] :
EuclideanSpace 𝕜 (ι ⊕ κ) ≃L[𝕜] EuclideanSpace 𝕜 ι × EuclideanSpace 𝕜 κ :=
(PiLp.sumPiLpEquivProdLpPiLp 2 _).toContinuousLinearEquiv.trans <|
WithLp.prodContinuousLinearEquiv _ _ _ _
/-- The canonical linear homeomorphism between `EuclideanSpace 𝕜 (Fin (n + m))` and
`EuclideanSpace 𝕜 (Fin n) × EuclideanSpace 𝕜 (Fin m)`. -/
abbrev EuclideanSpace.finAddEquivProd {𝕜 : Type*} [RCLike 𝕜] {n m : ℕ} :
EuclideanSpace 𝕜 (Fin (n + m)) ≃L[𝕜] EuclideanSpace 𝕜 (Fin n) × EuclideanSpace 𝕜 (Fin m) :=
(LinearIsometryEquiv.piLpCongrLeft 2 𝕜 𝕜 finSumFinEquiv.symm).toContinuousLinearEquiv.trans
sumEquivProd
end finAddEquivProd
variable (ι 𝕜 E)
variable [Fintype ι]
/-- An orthonormal basis on E is an identification of `E` with its dimensional-matching
`EuclideanSpace 𝕜 ι`. -/
structure OrthonormalBasis where ofRepr ::
/-- Linear isometry between `E` and `EuclideanSpace 𝕜 ι` representing the orthonormal basis. -/
repr : E ≃ₗᵢ[𝕜] EuclideanSpace 𝕜 ι
variable {ι 𝕜 E}
namespace OrthonormalBasis
theorem repr_injective :
Injective (repr : OrthonormalBasis ι 𝕜 E → E ≃ₗᵢ[𝕜] EuclideanSpace 𝕜 ι) := fun f g h => by
cases f
cases g
congr
/-- `b i` is the `i`th basis vector. -/
instance instFunLike : FunLike (OrthonormalBasis ι 𝕜 E) ι E where
coe b i := by classical exact b.repr.symm (EuclideanSpace.single i (1 : 𝕜))
coe_injective' b b' h := repr_injective <| LinearIsometryEquiv.toLinearEquiv_injective <|
LinearEquiv.symm_bijective.injective <| LinearEquiv.toLinearMap_injective <| by
classical
rw [← LinearMap.cancel_right (WithLp.linearEquiv 2 𝕜 (_ → 𝕜)).symm.surjective]
simp only
refine LinearMap.pi_ext fun i k => ?_
have : k = k • (1 : 𝕜) := by rw [smul_eq_mul, mul_one]
rw [this, Pi.single_smul]
replace h := congr_fun h i
simp only [LinearEquiv.comp_coe, map_smul, LinearEquiv.coe_coe,
LinearEquiv.trans_apply, WithLp.linearEquiv_symm_apply, EuclideanSpace.toLp_single,
LinearIsometryEquiv.coe_symm_toLinearEquiv] at h ⊢
rw [h]
@[simp]
theorem coe_ofRepr [DecidableEq ι] (e : E ≃ₗᵢ[𝕜] EuclideanSpace 𝕜 ι) :
⇑(OrthonormalBasis.ofRepr e) = fun i => e.symm (EuclideanSpace.single i (1 : 𝕜)) := by
dsimp only [DFunLike.coe]
funext
congr!
@[simp]
protected theorem repr_symm_single [DecidableEq ι] (b : OrthonormalBasis ι 𝕜 E) (i : ι) :
b.repr.symm (EuclideanSpace.single i (1 : 𝕜)) = b i := by
dsimp only [DFunLike.coe]
congr!
@[simp]
protected theorem repr_self [DecidableEq ι] (b : OrthonormalBasis ι 𝕜 E) (i : ι) :
b.repr (b i) = EuclideanSpace.single i (1 : 𝕜) := by
rw [← b.repr_symm_single i, LinearIsometryEquiv.apply_symm_apply]
protected theorem repr_apply_apply (b : OrthonormalBasis ι 𝕜 E) (v : E) (i : ι) :
b.repr v i = ⟪b i, v⟫ := by
classical
rw [← b.repr.inner_map_map (b i) v, b.repr_self i, EuclideanSpace.inner_single_left]
simp only [one_mul, map_one]
@[simp]
protected theorem orthonormal (b : OrthonormalBasis ι 𝕜 E) : Orthonormal 𝕜 b := by
classical
rw [orthonormal_iff_ite]
intro i j
rw [← b.repr.inner_map_map (b i) (b j), b.repr_self i, b.repr_self j,
EuclideanSpace.inner_single_left, EuclideanSpace.single_apply, map_one, one_mul]
@[simp]
lemma norm_eq_one (b : OrthonormalBasis ι 𝕜 E) (i : ι) :
‖b i‖ = 1 := b.orthonormal.norm_eq_one i
@[simp]
lemma nnnorm_eq_one (b : OrthonormalBasis ι 𝕜 E) (i : ι) :
‖b i‖₊ = 1 := b.orthonormal.nnnorm_eq_one i
@[simp]
lemma enorm_eq_one (b : OrthonormalBasis ι 𝕜 E) (i : ι) :
‖b i‖ₑ = 1 := b.orthonormal.enorm_eq_one i
@[simp]
lemma inner_eq_zero (b : OrthonormalBasis ι 𝕜 E) {i j : ι} (hij : i ≠ j) :
⟪b i, b j⟫ = 0 := b.orthonormal.inner_eq_zero hij
lemma inner_eq_one (b : OrthonormalBasis ι 𝕜 E) (i : ι) : ⟪b i, b i⟫ = 1 := by
simp
lemma inner_eq_ite [DecidableEq ι] (b : OrthonormalBasis ι 𝕜 E) (i j : ι) :
⟪b i, b j⟫ = if i = j then 1 else 0 := by
by_cases h : i = j <;> simp [h]
/-- The `Basis ι 𝕜 E` underlying the `OrthonormalBasis` -/
protected def toBasis (b : OrthonormalBasis ι 𝕜 E) : Basis ι 𝕜 E :=
Basis.ofEquivFun (b.repr.toLinearEquiv.trans (WithLp.linearEquiv 2 𝕜 (ι → 𝕜)))
@[simp]
protected theorem coe_toBasis (b : OrthonormalBasis ι 𝕜 E) : (⇑b.toBasis : ι → E) = ⇑b := rfl
@[simp]
protected theorem coe_toBasis_repr (b : OrthonormalBasis ι 𝕜 E) :
b.toBasis.equivFun = b.repr.toLinearEquiv.trans (WithLp.linearEquiv 2 𝕜 (ι → 𝕜)) :=
Basis.equivFun_ofEquivFun _
@[simp]
protected theorem coe_toBasis_repr_apply (b : OrthonormalBasis ι 𝕜 E) (x : E) (i : ι) :
b.toBasis.repr x i = b.repr x i := by
rw [← Basis.equivFun_apply, OrthonormalBasis.coe_toBasis_repr]
rfl
protected theorem sum_repr (b : OrthonormalBasis ι 𝕜 E) (x : E) : ∑ i, b.repr x i • b i = x := by
simp_rw [← b.coe_toBasis_repr_apply, ← b.coe_toBasis]
exact b.toBasis.sum_repr x
open scoped InnerProductSpace in
protected theorem sum_repr' (b : OrthonormalBasis ι 𝕜 E) (x : E) : ∑ i, ⟪b i, x⟫_𝕜 • b i = x := by
nth_rw 2 [← (b.sum_repr x)]
simp_rw [b.repr_apply_apply x]
protected theorem sum_repr_symm (b : OrthonormalBasis ι 𝕜 E) (v : EuclideanSpace 𝕜 ι) :
∑ i, v i • b i = b.repr.symm v := by simpa using (b.toBasis.equivFun_symm_apply v).symm
protected theorem sum_inner_mul_inner (b : OrthonormalBasis ι 𝕜 E) (x y : E) :
∑ i, ⟪x, b i⟫ * ⟪b i, y⟫ = ⟪x, y⟫ := by
have := congr_arg (innerSL 𝕜 x) (b.sum_repr y)
rw [map_sum] at this
convert this
rw [map_smul, b.repr_apply_apply, mul_comm]
simp
lemma sum_sq_norm_inner_right (b : OrthonormalBasis ι 𝕜 E) (x : E) :
∑ i, ‖⟪b i, x⟫‖ ^ 2 = ‖x‖ ^ 2 := by
rw [@norm_eq_sqrt_re_inner 𝕜, ← OrthonormalBasis.sum_inner_mul_inner b x x, map_sum]
simp_rw [inner_mul_symm_re_eq_norm, norm_mul, ← inner_conj_symm x, starRingEnd_apply,
norm_star, ← pow_two]
rw [Real.sq_sqrt]
exact Fintype.sum_nonneg fun _ ↦ by positivity
@[deprecated (since := "2025-06-23")] alias sum_sq_norm_inner := sum_sq_norm_inner_right
lemma sum_sq_norm_inner_left (b : OrthonormalBasis ι 𝕜 E) (x : E) :
∑ i, ‖⟪x, b i⟫‖ ^ 2 = ‖x‖ ^ 2 := by
convert sum_sq_norm_inner_right b x using 2 with i -
rw [← inner_conj_symm, RCLike.norm_conj]
open scoped RealInnerProductSpace in
theorem sum_sq_inner_right {E : Type*} [NormedAddCommGroup E]
[InnerProductSpace ℝ E] (b : OrthonormalBasis ι ℝ E) (x : E) :
∑ i : ι, ⟪b i, x⟫ ^ 2 = ‖x‖ ^ 2 := by
rw [← b.sum_sq_norm_inner_right]
simp
open scoped RealInnerProductSpace in
theorem sum_sq_inner_left {ι E : Type*} [NormedAddCommGroup E]
[InnerProductSpace ℝ E] [Fintype ι] (b : OrthonormalBasis ι ℝ E) (x : E) :
∑ i : ι, ⟪x, b i⟫ ^ 2 = ‖x‖ ^ 2 := by
simp_rw [← b.sum_sq_inner_right, real_inner_comm]
lemma norm_le_card_mul_iSup_norm_inner (b : OrthonormalBasis ι 𝕜 E) (x : E) :
‖x‖ ≤ √(Fintype.card ι) * ⨆ i, ‖⟪b i, x⟫‖ := by
calc ‖x‖
_ = √(∑ i, ‖⟪b i, x⟫‖ ^ 2) := by rw [sum_sq_norm_inner_right, Real.sqrt_sq (by positivity)]
_ ≤ √(∑ _ : ι, (⨆ j, ‖⟪b j, x⟫‖) ^ 2) := by
gcongr with i
exact le_ciSup (f := fun j ↦ ‖⟪b j, x⟫‖) (by simp) i
_ = √(Fintype.card ι) * ⨆ i, ‖⟪b i, x⟫‖ := by
simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul, Nat.cast_nonneg, Real.sqrt_mul]
congr
rw [Real.sqrt_sq]
cases isEmpty_or_nonempty ι
· simp
· exact le_ciSup_of_le (by simp) (Nonempty.some inferInstance) (by positivity)
protected theorem orthogonalProjection_eq_sum {U : Submodule 𝕜 E} [CompleteSpace U]
(b : OrthonormalBasis ι 𝕜 U) (x : E) :
U.orthogonalProjection x = ∑ i, ⟪(b i : E), x⟫ • b i := by
simpa only [b.repr_apply_apply, inner_orthogonalProjection_eq_of_mem_left] using
(b.sum_repr (U.orthogonalProjection x)).symm
/-- Mapping an orthonormal basis along a `LinearIsometryEquiv`. -/
protected def map {G : Type*} [NormedAddCommGroup G] [InnerProductSpace 𝕜 G]
(b : OrthonormalBasis ι 𝕜 E) (L : E ≃ₗᵢ[𝕜] G) : OrthonormalBasis ι 𝕜 G where
repr := L.symm.trans b.repr
@[simp]
protected theorem map_apply {G : Type*} [NormedAddCommGroup G] [InnerProductSpace 𝕜 G]
(b : OrthonormalBasis ι 𝕜 E) (L : E ≃ₗᵢ[𝕜] G) (i : ι) : b.map L i = L (b i) :=
rfl
@[simp]
protected theorem toBasis_map {G : Type*} [NormedAddCommGroup G] [InnerProductSpace 𝕜 G]
(b : OrthonormalBasis ι 𝕜 E) (L : E ≃ₗᵢ[𝕜] G) :
(b.map L).toBasis = b.toBasis.map L.toLinearEquiv :=
rfl
/-- A basis that is orthonormal is an orthonormal basis. -/
def _root_.Module.Basis.toOrthonormalBasis (v : Basis ι 𝕜 E) (hv : Orthonormal 𝕜 v) :
OrthonormalBasis ι 𝕜 E :=
OrthonormalBasis.ofRepr <|
LinearEquiv.isometryOfInner (v.equivFun.trans (WithLp.linearEquiv 2 𝕜 (ι → 𝕜)).symm)
(by
intro x y
let p : EuclideanSpace 𝕜 ι := toLp 2 (v.equivFun x)
let q : EuclideanSpace 𝕜 ι := toLp 2 (v.equivFun y)
have key : ⟪p, q⟫ = ⟪∑ i, p i • v i, ∑ i, q i • v i⟫ := by
simp [inner_sum, inner_smul_right, hv.inner_left_fintype, PiLp.inner_apply]
convert key
· rw [← v.equivFun.symm_apply_apply x, v.equivFun_symm_apply]
· rw [← v.equivFun.symm_apply_apply y, v.equivFun_symm_apply])
@[simp]
theorem _root_.Module.Basis.coe_toOrthonormalBasis_repr (v : Basis ι 𝕜 E) (hv : Orthonormal 𝕜 v) :
((v.toOrthonormalBasis hv).repr : E → EuclideanSpace 𝕜 ι) =
v.equivFun.trans (WithLp.linearEquiv 2 𝕜 (ι → 𝕜)).symm :=
rfl
@[simp]
theorem _root_.Module.Basis.coe_toOrthonormalBasis_repr_symm
(v : Basis ι 𝕜 E) (hv : Orthonormal 𝕜 v) :
((v.toOrthonormalBasis hv).repr.symm : EuclideanSpace 𝕜 ι → E) =
(WithLp.linearEquiv 2 𝕜 (ι → 𝕜)).trans v.equivFun.symm :=
rfl
@[simp]
theorem _root_.Module.Basis.toBasis_toOrthonormalBasis (v : Basis ι 𝕜 E) (hv : Orthonormal 𝕜 v) :
(v.toOrthonormalBasis hv).toBasis = v := by
simp only [OrthonormalBasis.toBasis, Basis.toOrthonormalBasis,
LinearEquiv.isometryOfInner_toLinearEquiv]
exact v.ofEquivFun_equivFun
@[simp]
theorem _root_.Module.Basis.coe_toOrthonormalBasis (v : Basis ι 𝕜 E) (hv : Orthonormal 𝕜 v) :
(v.toOrthonormalBasis hv : ι → E) = (v : ι → E) :=
calc
(v.toOrthonormalBasis hv : ι → E) = ((v.toOrthonormalBasis hv).toBasis : ι → E) := by
classical rw [OrthonormalBasis.coe_toBasis]
_ = (v : ι → E) := by simp
section Singleton
variable {ι 𝕜 : Type*} [Unique ι] [RCLike 𝕜]
variable (ι 𝕜) in
/-- `OrthonormalBasis.singleton ι 𝕜` is the orthonormal basis sending the unique element of `ι` to
`1 : 𝕜`. -/
protected noncomputable def singleton : OrthonormalBasis ι 𝕜 𝕜 :=
(Basis.singleton ι 𝕜).toOrthonormalBasis (by simp [orthonormal_iff_ite, Unique.eq_default])
@[simp]
theorem singleton_apply (i) : OrthonormalBasis.singleton ι 𝕜 i = 1 := Basis.singleton_apply _ _ _
@[simp]
theorem singleton_repr (x i) : (OrthonormalBasis.singleton ι 𝕜).repr x i = x :=
Basis.singleton_repr _ _ _ _
@[simp]
theorem coe_singleton : ⇑(OrthonormalBasis.singleton ι 𝕜) = 1 := by
ext; simp
@[simp]
theorem toBasis_singleton : (OrthonormalBasis.singleton ι 𝕜).toBasis = Basis.singleton ι 𝕜 :=
Basis.toBasis_toOrthonormalBasis _ _
end Singleton
/-- `Pi.orthonormalBasis (B : ∀ i, OrthonormalBasis (ι i) 𝕜 (E i))` is the
`Σ i, ι i`-indexed orthonormal basis on `Π i, E i` given by `B i` on each component. -/
protected def _root_.Pi.orthonormalBasis {η : Type*} [Fintype η] {ι : η → Type*}
[∀ i, Fintype (ι i)] {𝕜 : Type*} [RCLike 𝕜] {E : η → Type*} [∀ i, NormedAddCommGroup (E i)]
[∀ i, InnerProductSpace 𝕜 (E i)] (B : ∀ i, OrthonormalBasis (ι i) 𝕜 (E i)) :
OrthonormalBasis ((i : η) × ι i) 𝕜 (PiLp 2 E) where
repr := .trans
(.piLpCongrRight 2 fun i => (B i).repr)
(.symm <| .piLpCurry 𝕜 2 fun _ _ => 𝕜)
theorem _root_.Pi.orthonormalBasis.toBasis {η : Type*} [Fintype η] {ι : η → Type*}
[∀ i, Fintype (ι i)] {𝕜 : Type*} [RCLike 𝕜] {E : η → Type*} [∀ i, NormedAddCommGroup (E i)]
[∀ i, InnerProductSpace 𝕜 (E i)] (B : ∀ i, OrthonormalBasis (ι i) 𝕜 (E i)) :
(Pi.orthonormalBasis B).toBasis =
((Pi.basis fun i : η ↦ (B i).toBasis).map (WithLp.linearEquiv 2 _ _).symm) := by ext; rfl
@[simp]
theorem _root_.Pi.orthonormalBasis_apply {η : Type*} [Fintype η] [DecidableEq η] {ι : η → Type*}
[∀ i, Fintype (ι i)] {𝕜 : Type*} [RCLike 𝕜] {E : η → Type*} [∀ i, NormedAddCommGroup (E i)]
[∀ i, InnerProductSpace 𝕜 (E i)] (B : ∀ i, OrthonormalBasis (ι i) 𝕜 (E i))
(j : (i : η) × (ι i)) :
Pi.orthonormalBasis B j = toLp _ (Pi.single _ (B j.fst j.snd)) := by
classical
ext k
obtain ⟨i, j⟩ := j
simp only [Pi.orthonormalBasis, coe_ofRepr, LinearIsometryEquiv.symm_trans,
LinearIsometryEquiv.symm_symm, LinearIsometryEquiv.piLpCongrRight_symm,
LinearIsometryEquiv.trans_apply, LinearIsometryEquiv.piLpCongrRight_apply,
LinearIsometryEquiv.piLpCurry_apply, EuclideanSpace.ofLp_single, PiLp.toLp_apply,
Sigma.curry_single (γ := fun _ _ => 𝕜)]
obtain rfl | hi := Decidable.eq_or_ne i k
· simp only [Pi.single_eq_same, EuclideanSpace.toLp_single, OrthonormalBasis.repr_symm_single]
· simp only [Pi.single_eq_of_ne' hi, toLp_zero, map_zero]
@[simp]
theorem _root_.Pi.orthonormalBasis_repr {η : Type*} [Fintype η] {ι : η → Type*}
[∀ i, Fintype (ι i)] {𝕜 : Type*} [RCLike 𝕜] {E : η → Type*} [∀ i, NormedAddCommGroup (E i)]
[∀ i, InnerProductSpace 𝕜 (E i)] (B : ∀ i, OrthonormalBasis (ι i) 𝕜 (E i)) (x : (i : η) → E i)
(j : (i : η) × (ι i)) :
(Pi.orthonormalBasis B).repr (toLp 2 x) j = (B j.fst).repr (x j.fst) j.snd := rfl
variable {v : ι → E}
/-- A finite orthonormal set that spans is an orthonormal basis -/
protected def mk (hon : Orthonormal 𝕜 v) (hsp : ⊤ ≤ Submodule.span 𝕜 (Set.range v)) :
OrthonormalBasis ι 𝕜 E :=
(Basis.mk (Orthonormal.linearIndependent hon) hsp).toOrthonormalBasis (by rwa [Basis.coe_mk])
@[simp]
protected theorem coe_mk (hon : Orthonormal 𝕜 v) (hsp : ⊤ ≤ Submodule.span 𝕜 (Set.range v)) :
⇑(OrthonormalBasis.mk hon hsp) = v := by
classical rw [OrthonormalBasis.mk, _root_.Module.Basis.coe_toOrthonormalBasis, Basis.coe_mk]
/-- Any finite subset of an orthonormal family is an `OrthonormalBasis` for its span. -/
protected def span [DecidableEq E] {v' : ι' → E} (h : Orthonormal 𝕜 v') (s : Finset ι') :
OrthonormalBasis s 𝕜 (span 𝕜 (s.image v' : Set E)) :=
let e₀' : Basis s 𝕜 _ :=
Basis.span (h.linearIndependent.comp ((↑) : s → ι') Subtype.val_injective)
let e₀ : OrthonormalBasis s 𝕜 _ :=
OrthonormalBasis.mk
(by
convert orthonormal_span (h.comp ((↑) : s → ι') Subtype.val_injective)
simp [e₀', Basis.span_apply])
e₀'.span_eq.ge
let φ : span 𝕜 (s.image v' : Set E) ≃ₗᵢ[𝕜] span 𝕜 (range (v' ∘ ((↑) : s → ι'))) :=
LinearIsometryEquiv.ofEq _ _
(by
rw [Finset.coe_image, image_eq_range]
rfl)
e₀.map φ.symm
@[simp]
protected theorem span_apply [DecidableEq E] {v' : ι' → E} (h : Orthonormal 𝕜 v') (s : Finset ι')
(i : s) : (OrthonormalBasis.span h s i : E) = v' i := by
simp only [OrthonormalBasis.span, Basis.span_apply, LinearIsometryEquiv.ofEq_symm,
OrthonormalBasis.map_apply, OrthonormalBasis.coe_mk, LinearIsometryEquiv.coe_ofEq_apply,
comp_apply]
open Submodule
/-- A finite orthonormal family of vectors whose span has trivial orthogonal complement is an
orthonormal basis. -/
protected def mkOfOrthogonalEqBot (hon : Orthonormal 𝕜 v) (hsp : (span 𝕜 (Set.range v))ᗮ = ⊥) :
OrthonormalBasis ι 𝕜 E :=
OrthonormalBasis.mk hon
(by
refine Eq.ge ?_
haveI : FiniteDimensional 𝕜 (span 𝕜 (range v)) :=
FiniteDimensional.span_of_finite 𝕜 (finite_range v)
haveI : CompleteSpace (span 𝕜 (range v)) := FiniteDimensional.complete 𝕜 _
rwa [orthogonal_eq_bot_iff] at hsp)
@[simp]
protected theorem coe_of_orthogonal_eq_bot_mk (hon : Orthonormal 𝕜 v)
(hsp : (span 𝕜 (Set.range v))ᗮ = ⊥) : ⇑(OrthonormalBasis.mkOfOrthogonalEqBot hon hsp) = v :=
OrthonormalBasis.coe_mk hon _
variable [Fintype ι']
/-- `b.reindex (e : ι ≃ ι')` is an `OrthonormalBasis` indexed by `ι'` -/
def reindex (b : OrthonormalBasis ι 𝕜 E) (e : ι ≃ ι') : OrthonormalBasis ι' 𝕜 E :=
OrthonormalBasis.ofRepr (b.repr.trans (LinearIsometryEquiv.piLpCongrLeft 2 𝕜 𝕜 e))
protected theorem reindex_apply (b : OrthonormalBasis ι 𝕜 E) (e : ι ≃ ι') (i' : ι') :
(b.reindex e) i' = b (e.symm i') := by
classical
dsimp [reindex]
rw [coe_ofRepr]
dsimp
rw [← b.repr_symm_single, LinearIsometryEquiv.piLpCongrLeft_symm,
EuclideanSpace.piLpCongrLeft_single]
@[simp]
theorem reindex_toBasis (b : OrthonormalBasis ι 𝕜 E) (e : ι ≃ ι') :
(b.reindex e).toBasis = b.toBasis.reindex e := Basis.eq_ofRepr_eq_repr fun _ ↦ congr_fun rfl
@[simp]
protected theorem coe_reindex (b : OrthonormalBasis ι 𝕜 E) (e : ι ≃ ι') :
⇑(b.reindex e) = b ∘ e.symm :=
funext (b.reindex_apply e)
@[simp]
protected theorem repr_reindex (b : OrthonormalBasis ι 𝕜 E) (e : ι ≃ ι') (x : E) (i' : ι') :
(b.reindex e).repr x i' = b.repr x (e.symm i') := by
classical
rw [OrthonormalBasis.repr_apply_apply, b.repr_apply_apply, OrthonormalBasis.coe_reindex,
comp_apply]
end OrthonormalBasis
namespace EuclideanSpace
variable (𝕜 ι)
/-- The basis `Pi.basisFun`, bundled as an orthornormal basis of `EuclideanSpace 𝕜 ι`. -/
noncomputable def basisFun : OrthonormalBasis ι 𝕜 (EuclideanSpace 𝕜 ι) :=
⟨LinearIsometryEquiv.refl _ _⟩
@[simp]
theorem basisFun_apply [DecidableEq ι] (i : ι) : basisFun ι 𝕜 i = EuclideanSpace.single i 1 :=
PiLp.basisFun_apply _ _ _ _
@[simp]
theorem basisFun_repr (x : EuclideanSpace 𝕜 ι) (i : ι) : (basisFun ι 𝕜).repr x i = x i := rfl
@[simp]
theorem basisFun_inner (x : EuclideanSpace 𝕜 ι) (i : ι) : ⟪basisFun ι 𝕜 i, x⟫ = x i := by
simp [← OrthonormalBasis.repr_apply_apply]
@[simp]
theorem inner_basisFun_real (x : EuclideanSpace ℝ ι) (i : ι) :
inner ℝ x (basisFun ι ℝ i) = x i := by
rw [real_inner_comm, basisFun_inner]
theorem basisFun_toBasis : (basisFun ι 𝕜).toBasis = PiLp.basisFun _ 𝕜 ι := rfl
end EuclideanSpace
instance OrthonormalBasis.instInhabited : Inhabited (OrthonormalBasis ι 𝕜 (EuclideanSpace 𝕜 ι)) :=
⟨EuclideanSpace.basisFun ι 𝕜⟩
namespace OrthonormalBasis
variable {E' : Type*} [Fintype ι'] [NormedAddCommGroup E'] [InnerProductSpace 𝕜 E']
(b : OrthonormalBasis ι 𝕜 E) (b' : OrthonormalBasis ι' 𝕜 E') (e : ι ≃ ι')
/-- The `LinearIsometryEquiv` which maps an orthonormal basis to another. This is a convenience
wrapper around `Orthonormal.equiv`. -/
protected def equiv : E ≃ₗᵢ[𝕜] E' :=
b.repr.trans <| .trans (.piLpCongrLeft _ _ _ e) b'.repr.symm
@[simp]
lemma equiv_symm : (b.equiv b' e).symm = b'.equiv b e.symm := by
apply b'.toBasis.ext_linearIsometryEquiv
simp [OrthonormalBasis.equiv]
@[simp]
lemma equiv_apply_basis (i : ι) : b.equiv b' e (b i) = b' (e i) := by
classical
simp only [OrthonormalBasis.equiv, LinearIsometryEquiv.trans_apply, OrthonormalBasis.repr_self]
refine DFunLike.congr rfl ?_
ext j
simp [Pi.single_apply, Equiv.symm_apply_eq]
@[simp]
lemma equiv_self_rfl : b.equiv b (.refl ι) = .refl 𝕜 E := by
apply b.toBasis.ext_linearIsometryEquiv
simp
lemma equiv_apply (x : E) : b.equiv b' e x = ∑ i, b.repr x i • b' (e i) := by
nth_rw 1 [← b.sum_repr x, map_sum]
simp_rw [map_smul, equiv_apply_basis]
lemma equiv_apply_euclideanSpace (x : EuclideanSpace 𝕜 ι) :
(EuclideanSpace.basisFun ι 𝕜).equiv b (Equiv.refl ι) x = ∑ i, x i • b i := by
simp_rw [equiv_apply, EuclideanSpace.basisFun_repr, Equiv.refl_apply]
lemma coe_equiv_euclideanSpace :
⇑((EuclideanSpace.basisFun ι 𝕜).equiv b (Equiv.refl ι)) = fun x ↦ ∑ i, x i • b i := by
simp_rw [← equiv_apply_euclideanSpace]
end OrthonormalBasis
section Complex
/-- `![1, I]` is an orthonormal basis for `ℂ` considered as a real inner product space. -/
def Complex.orthonormalBasisOneI : OrthonormalBasis (Fin 2) ℝ ℂ :=
Complex.basisOneI.toOrthonormalBasis
(by
rw [orthonormal_iff_ite]
intro i; fin_cases i <;> intro j <;> fin_cases j <;> simp [real_inner_eq_re_inner])
@[simp]
theorem Complex.orthonormalBasisOneI_repr_apply (z : ℂ) :
Complex.orthonormalBasisOneI.repr z = ![z.re, z.im] :=
rfl
@[simp]
theorem Complex.orthonormalBasisOneI_repr_symm_apply (x : EuclideanSpace ℝ (Fin 2)) :
Complex.orthonormalBasisOneI.repr.symm x = x 0 + x 1 * I :=
rfl
@[simp]
theorem Complex.toBasis_orthonormalBasisOneI :
Complex.orthonormalBasisOneI.toBasis = Complex.basisOneI :=
Basis.toBasis_toOrthonormalBasis _ _
@[simp]
theorem Complex.coe_orthonormalBasisOneI :
(Complex.orthonormalBasisOneI : Fin 2 → ℂ) = ![1, I] := by
simp [Complex.orthonormalBasisOneI]
/-- The isometry between `ℂ` and a two-dimensional real inner product space given by a basis. -/
def Complex.isometryOfOrthonormal (v : OrthonormalBasis (Fin 2) ℝ F) : ℂ ≃ₗᵢ[ℝ] F :=
Complex.orthonormalBasisOneI.repr.trans v.repr.symm
@[simp]
theorem Complex.map_isometryOfOrthonormal (v : OrthonormalBasis (Fin 2) ℝ F) (f : F ≃ₗᵢ[ℝ] F') :
Complex.isometryOfOrthonormal (v.map f) = (Complex.isometryOfOrthonormal v).trans f := by
simp only [isometryOfOrthonormal, OrthonormalBasis.map, LinearIsometryEquiv.symm_trans,
LinearIsometryEquiv.symm_symm]
-- Porting note: `LinearIsometryEquiv.trans_assoc` doesn't trigger in the `simp` above
rw [LinearIsometryEquiv.trans_assoc]
theorem Complex.isometryOfOrthonormal_symm_apply (v : OrthonormalBasis (Fin 2) ℝ F) (f : F) :
(Complex.isometryOfOrthonormal v).symm f =
(v.toBasis.coord 0 f : ℂ) + (v.toBasis.coord 1 f : ℂ) * I := by
simp [Complex.isometryOfOrthonormal]
theorem Complex.isometryOfOrthonormal_apply (v : OrthonormalBasis (Fin 2) ℝ F) (z : ℂ) :
Complex.isometryOfOrthonormal v z = z.re • v 0 + z.im • v 1 := by
simp [Complex.isometryOfOrthonormal, ← v.sum_repr_symm]
end Complex
open Module
/-! ### Matrix representation of an orthonormal basis with respect to another -/
section ToMatrix
variable [DecidableEq ι]
section
open scoped Matrix
/-- A version of `OrthonormalBasis.toMatrix_orthonormalBasis_mem_unitary` that works for bases with
different index types. -/
@[simp]
theorem OrthonormalBasis.toMatrix_orthonormalBasis_conjTranspose_mul_self [Fintype ι']
(a : OrthonormalBasis ι' 𝕜 E) (b : OrthonormalBasis ι 𝕜 E) :
(a.toBasis.toMatrix b)ᴴ * a.toBasis.toMatrix b = 1 := by
ext i j
convert a.repr.inner_map_map (b i) (b j)
· simp only [Matrix.mul_apply, Matrix.conjTranspose_apply, star_def, PiLp.inner_apply,
inner_apply']
congr
· rw [orthonormal_iff_ite.mp b.orthonormal i j, Matrix.one_apply]
/-- A version of `OrthonormalBasis.toMatrix_orthonormalBasis_mem_unitary` that works for bases with
different index types. -/
@[simp]
theorem OrthonormalBasis.toMatrix_orthonormalBasis_self_mul_conjTranspose [Fintype ι']
(a : OrthonormalBasis ι 𝕜 E) (b : OrthonormalBasis ι' 𝕜 E) :
a.toBasis.toMatrix b * (a.toBasis.toMatrix b)ᴴ = 1 := by
classical
rw [Matrix.mul_eq_one_comm_of_equiv (a.toBasis.indexEquiv b.toBasis),
a.toMatrix_orthonormalBasis_conjTranspose_mul_self b]
variable (a b : OrthonormalBasis ι 𝕜 E)
/-- The change-of-basis matrix between two orthonormal bases `a`, `b` is a unitary matrix. -/
theorem OrthonormalBasis.toMatrix_orthonormalBasis_mem_unitary :
a.toBasis.toMatrix b ∈ Matrix.unitaryGroup ι 𝕜 := by
rw [Matrix.mem_unitaryGroup_iff']
exact a.toMatrix_orthonormalBasis_conjTranspose_mul_self b
/-- The determinant of the change-of-basis matrix between two orthonormal bases `a`, `b` has
unit length. -/
@[simp]
theorem OrthonormalBasis.det_to_matrix_orthonormalBasis : ‖a.toBasis.det b‖ = 1 := by
have := (Matrix.det_of_mem_unitary (a.toMatrix_orthonormalBasis_mem_unitary b)).2
rw [star_def, RCLike.mul_conj] at this
norm_cast at this
rwa [pow_eq_one_iff_of_nonneg (norm_nonneg _) two_ne_zero] at this
end
section Real
variable (a b : OrthonormalBasis ι ℝ F)
/-- The change-of-basis matrix between two orthonormal bases `a`, `b` is an orthogonal matrix. -/
theorem OrthonormalBasis.toMatrix_orthonormalBasis_mem_orthogonal :
a.toBasis.toMatrix b ∈ Matrix.orthogonalGroup ι ℝ :=
a.toMatrix_orthonormalBasis_mem_unitary b
/-- The determinant of the change-of-basis matrix between two orthonormal bases `a`, `b` is ±1. -/
theorem OrthonormalBasis.det_to_matrix_orthonormalBasis_real :
a.toBasis.det b = 1 ∨ a.toBasis.det b = -1 := by
rw [← sq_eq_one_iff]
simpa [unitary, sq] using Matrix.det_of_mem_unitary (a.toMatrix_orthonormalBasis_mem_unitary b)
end Real
end ToMatrix
/-! ### Existence of orthonormal basis, etc. -/
section FiniteDimensional
variable {v : Set E}
variable {A : ι → Submodule 𝕜 E}
/-- Given an internal direct sum decomposition of a module `M`, and an orthonormal basis for each
of the components of the direct sum, the disjoint union of these orthonormal bases is an
orthonormal basis for `M`. -/
noncomputable def DirectSum.IsInternal.collectedOrthonormalBasis
(hV : OrthogonalFamily 𝕜 (fun i => A i) fun i => (A i).subtypeₗᵢ) [DecidableEq ι]
(hV_sum : DirectSum.IsInternal fun i => A i) {α : ι → Type*} [∀ i, Fintype (α i)]
(v_family : ∀ i, OrthonormalBasis (α i) 𝕜 (A i)) : OrthonormalBasis (Σ i, α i) 𝕜 E :=
(hV_sum.collectedBasis fun i => (v_family i).toBasis).toOrthonormalBasis <| by
simpa using
hV.orthonormal_sigma_orthonormal (show ∀ i, Orthonormal 𝕜 (v_family i).toBasis by simp)
theorem DirectSum.IsInternal.collectedOrthonormalBasis_mem [DecidableEq ι]
(h : DirectSum.IsInternal A) {α : ι → Type*} [∀ i, Fintype (α i)]
(hV : OrthogonalFamily 𝕜 (fun i => A i) fun i => (A i).subtypeₗᵢ)
(v : ∀ i, OrthonormalBasis (α i) 𝕜 (A i)) (a : Σ i, α i) :
h.collectedOrthonormalBasis hV v a ∈ A a.1 := by
simp [DirectSum.IsInternal.collectedOrthonormalBasis]
variable [FiniteDimensional 𝕜 E]
/-- In a finite-dimensional `InnerProductSpace`, any orthonormal subset can be extended to an
orthonormal basis. -/
theorem Orthonormal.exists_orthonormalBasis_extension (hv : Orthonormal 𝕜 ((↑) : v → E)) :
∃ (u : Finset E) (b : OrthonormalBasis u 𝕜 E), v ⊆ u ∧ ⇑b = ((↑) : u → E) := by
obtain ⟨u₀, hu₀s, hu₀, hu₀_max⟩ := exists_maximal_orthonormal hv
rw [maximal_orthonormal_iff_orthogonalComplement_eq_bot hu₀] at hu₀_max
have hu₀_finite : u₀.Finite := hu₀.linearIndependent.setFinite
let u : Finset E := hu₀_finite.toFinset
let fu : ↥u ≃ ↥u₀ := hu₀_finite.subtypeEquivToFinset.symm
have hu : Orthonormal 𝕜 ((↑) : u → E) := by simpa using hu₀.comp _ fu.injective
refine ⟨u, OrthonormalBasis.mkOfOrthogonalEqBot hu ?_, ?_, ?_⟩
· simpa [u] using hu₀_max
· simpa [u] using hu₀s
· simp
theorem Orthonormal.exists_orthonormalBasis_extension_of_card_eq {ι : Type*} [Fintype ι]
(card_ι : finrank 𝕜 E = Fintype.card ι) {v : ι → E} {s : Set ι}
(hv : Orthonormal 𝕜 (s.restrict v)) : ∃ b : OrthonormalBasis ι 𝕜 E, ∀ i ∈ s, b i = v i := by
have hsv : Injective (s.restrict v) := hv.linearIndependent.injective
have hX : Orthonormal 𝕜 ((↑) : Set.range (s.restrict v) → E) := by
rwa [orthonormal_subtype_range hsv]
obtain ⟨Y, b₀, hX, hb₀⟩ := hX.exists_orthonormalBasis_extension
have hιY : Fintype.card ι = Y.card := by
refine card_ι.symm.trans ?_
exact Module.finrank_eq_card_finset_basis b₀.toBasis
have hvsY : s.MapsTo v Y := (s.mapsTo_image v).mono_right (by rwa [← range_restrict])
have hsv' : Set.InjOn v s := by
rw [Set.injOn_iff_injective]
exact hsv
obtain ⟨g, hg⟩ := hvsY.exists_equiv_extend_of_card_eq hιY hsv'
use b₀.reindex g.symm
intro i hi
simp [hb₀, hg i hi]
variable (𝕜 E)
/-- A finite-dimensional inner product space admits an orthonormal basis. -/
theorem _root_.exists_orthonormalBasis :
∃ (w : Finset E) (b : OrthonormalBasis w 𝕜 E), ⇑b = ((↑) : w → E) :=
let ⟨w, hw, _, hw''⟩ := (orthonormal_empty 𝕜 E).exists_orthonormalBasis_extension
⟨w, hw, hw''⟩
/-- A finite-dimensional `InnerProductSpace` has an orthonormal basis. -/
irreducible_def stdOrthonormalBasis : OrthonormalBasis (Fin (finrank 𝕜 E)) 𝕜 E := by
let b := Classical.choose (Classical.choose_spec <| exists_orthonormalBasis 𝕜 E)
rw [finrank_eq_card_basis b.toBasis]
exact b.reindex (Fintype.equivFinOfCardEq rfl)
/-- An orthonormal basis of `ℝ` is made either of the vector `1`, or of the vector `-1`. -/
theorem orthonormalBasis_one_dim (b : OrthonormalBasis ι ℝ ℝ) :
(⇑b = fun _ => (1 : ℝ)) ∨ ⇑b = fun _ => (-1 : ℝ) := by
have : Unique ι := b.toBasis.unique
have : b default = 1 ∨ b default = -1 := by
have : ‖b default‖ = 1 := b.orthonormal.1 _
rwa [Real.norm_eq_abs, abs_eq (zero_le_one' ℝ)] at this
rw [eq_const_of_unique b]
grind
variable {𝕜 E}
section SubordinateOrthonormalBasis
open DirectSum
variable {n : ℕ} (hn : finrank 𝕜 E = n) [DecidableEq ι] {V : ι → Submodule 𝕜 E} (hV : IsInternal V)
/-- Exhibit a bijection between `Fin n` and the index set of a certain basis of an `n`-dimensional
inner product space `E`. This should not be accessed directly, but only via the subsequent API. -/
irreducible_def DirectSum.IsInternal.sigmaOrthonormalBasisIndexEquiv
(hV' : OrthogonalFamily 𝕜 (fun i => V i) fun i => (V i).subtypeₗᵢ) :
(Σ i, Fin (finrank 𝕜 (V i))) ≃ Fin n :=
let b := hV.collectedOrthonormalBasis hV' fun i => stdOrthonormalBasis 𝕜 (V i)
Fintype.equivFinOfCardEq <| (Module.finrank_eq_card_basis b.toBasis).symm.trans hn
/-- An `n`-dimensional `InnerProductSpace` equipped with a decomposition as an internal direct
sum has an orthonormal basis indexed by `Fin n` and subordinate to that direct sum. -/
irreducible_def DirectSum.IsInternal.subordinateOrthonormalBasis
(hV' : OrthogonalFamily 𝕜 (fun i => V i) fun i => (V i).subtypeₗᵢ) :
OrthonormalBasis (Fin n) 𝕜 E :=
(hV.collectedOrthonormalBasis hV' fun i => stdOrthonormalBasis 𝕜 (V i)).reindex
(hV.sigmaOrthonormalBasisIndexEquiv hn hV')
/-- An `n`-dimensional `InnerProductSpace` equipped with a decomposition as an internal direct
sum has an orthonormal basis indexed by `Fin n` and subordinate to that direct sum. This function
provides the mapping by which it is subordinate. -/
irreducible_def DirectSum.IsInternal.subordinateOrthonormalBasisIndex (a : Fin n)
(hV' : OrthogonalFamily 𝕜 (fun i => V i) fun i => (V i).subtypeₗᵢ) : ι :=
((hV.sigmaOrthonormalBasisIndexEquiv hn hV').symm a).1
/-- The basis constructed in `DirectSum.IsInternal.subordinateOrthonormalBasis` is subordinate to
the `OrthogonalFamily` in question. -/
theorem DirectSum.IsInternal.subordinateOrthonormalBasis_subordinate (a : Fin n)
(hV' : OrthogonalFamily 𝕜 (fun i => V i) fun i => (V i).subtypeₗᵢ) :
hV.subordinateOrthonormalBasis hn hV' a ∈ V (hV.subordinateOrthonormalBasisIndex hn a hV') := by
simpa only [DirectSum.IsInternal.subordinateOrthonormalBasis, OrthonormalBasis.coe_reindex,
DirectSum.IsInternal.subordinateOrthonormalBasisIndex] using
hV.collectedOrthonormalBasis_mem hV' (fun i => stdOrthonormalBasis 𝕜 (V i))
((hV.sigmaOrthonormalBasisIndexEquiv hn hV').symm a)
end SubordinateOrthonormalBasis
end FiniteDimensional
/-- Given a natural number `n` one less than the `finrank` of a finite-dimensional inner product
space, there exists an isometry from the orthogonal complement of a nonzero singleton to
`EuclideanSpace 𝕜 (Fin n)`. -/
def OrthonormalBasis.fromOrthogonalSpanSingleton (n : ℕ) [Fact (finrank 𝕜 E = n + 1)] {v : E}
(hv : v ≠ 0) : OrthonormalBasis (Fin n) 𝕜 (𝕜 ∙ v)ᗮ :=
have : FiniteDimensional 𝕜 E := .of_fact_finrank_eq_succ (K := 𝕜) (V := E) n
(stdOrthonormalBasis _ _).reindex <| finCongr <| finrank_orthogonal_span_singleton hv
section LinearIsometry
variable {V : Type*} [NormedAddCommGroup V] [InnerProductSpace 𝕜 V] [FiniteDimensional 𝕜 V]
variable {S : Submodule 𝕜 V} {L : S →ₗᵢ[𝕜] V}
open Module
/-- Let `S` be a subspace of a finite-dimensional complex inner product space `V`. A linear
isometry mapping `S` into `V` can be extended to a full isometry of `V`.
TODO: The case when `S` is a finite-dimensional subspace of an infinite-dimensional `V`. -/
noncomputable def LinearIsometry.extend (L : S →ₗᵢ[𝕜] V) : V →ₗᵢ[𝕜] V := by
-- Build an isometry from Sᗮ to L(S)ᗮ through `EuclideanSpace`
let d := finrank 𝕜 Sᗮ
let LS := LinearMap.range L.toLinearMap
have E : Sᗮ ≃ₗᵢ[𝕜] LSᗮ := by
have dim_LS_perp : finrank 𝕜 LSᗮ = d :=
calc
finrank 𝕜 LSᗮ = finrank 𝕜 V - finrank 𝕜 LS := by
simp only [← LS.finrank_add_finrank_orthogonal, add_tsub_cancel_left]
_ = finrank 𝕜 V - finrank 𝕜 S := by
simp only [LS, LinearMap.finrank_range_of_inj L.injective]
_ = finrank 𝕜 Sᗮ := by simp only [← S.finrank_add_finrank_orthogonal, add_tsub_cancel_left]
exact
(stdOrthonormalBasis 𝕜 Sᗮ).repr.trans
((stdOrthonormalBasis 𝕜 LSᗮ).reindex <| finCongr dim_LS_perp).repr.symm
let L3 := LSᗮ.subtypeₗᵢ.comp E.toLinearIsometry
-- Project onto S and Sᗮ
haveI : CompleteSpace S := FiniteDimensional.complete 𝕜 S
haveI : CompleteSpace V := FiniteDimensional.complete 𝕜 V
let p1 := S.orthogonalProjection.toLinearMap
let p2 := Sᗮ.orthogonalProjection.toLinearMap
-- Build a linear map from the isometries on S and Sᗮ
let M := L.toLinearMap.comp p1 + L3.toLinearMap.comp p2
-- Prove that M is an isometry
have M_norm_map : ∀ x : V, ‖M x‖ = ‖x‖ := by
intro x
-- Apply M to the orthogonal decomposition of x
have Mx_decomp : M x = L (p1 x) + L3 (p2 x) := by
simp only [M, LinearMap.add_apply, LinearMap.comp_apply, LinearMap.comp_apply,
LinearIsometry.coe_toLinearMap]
-- Mx_decomp is the orthogonal decomposition of M x
have Mx_orth : ⟪L (p1 x), L3 (p2 x)⟫ = 0 := by
have Lp1x : L (p1 x) ∈ LinearMap.range L.toLinearMap :=
LinearMap.mem_range_self L.toLinearMap (p1 x)
have Lp2x : L3 (p2 x) ∈ (LinearMap.range L.toLinearMap)ᗮ := by
simp only [LS,
← Submodule.range_subtype LSᗮ]
apply LinearMap.mem_range_self
apply Submodule.inner_right_of_mem_orthogonal Lp1x Lp2x
-- Apply the Pythagorean theorem and simplify
rw [← sq_eq_sq₀ (norm_nonneg _) (norm_nonneg _), norm_sq_eq_add_norm_sq_projection x S]
simp only [sq, Mx_decomp]
rw [norm_add_sq_eq_norm_sq_add_norm_sq_of_inner_eq_zero (L (p1 x)) (L3 (p2 x)) Mx_orth]
simp only [p1, p2, LinearIsometry.norm_map,
ContinuousLinearMap.coe_coe, Submodule.coe_norm]
exact
{ toLinearMap := M
norm_map' := M_norm_map }
theorem LinearIsometry.extend_apply (L : S →ₗᵢ[𝕜] V) (s : S) : L.extend s = L s := by
haveI : CompleteSpace S := FiniteDimensional.complete 𝕜 S
simp only [LinearIsometry.extend, ← LinearIsometry.coe_toLinearMap]
simp only [add_eq_left, LinearIsometry.coe_toLinearMap,
LinearIsometryEquiv.coe_toLinearIsometry, LinearIsometry.coe_comp, Function.comp_apply,
orthogonalProjection_mem_subspace_eq_self, LinearMap.coe_comp, ContinuousLinearMap.coe_coe,
Submodule.coe_subtype, LinearMap.add_apply, Submodule.coe_eq_zero,
LinearIsometryEquiv.map_eq_zero_iff, Submodule.coe_subtypeₗᵢ,
orthogonalProjection_mem_subspace_orthogonalComplement_eq_zero, Submodule.orthogonal_orthogonal,
Submodule.coe_mem]
end LinearIsometry
section Matrix
open Matrix
variable {m n : Type*}
namespace Matrix
variable [Fintype n] [DecidableEq n]
/-- `Matrix.toLin'` adapted for `EuclideanSpace 𝕜 _`. -/
def toEuclideanLin : Matrix m n 𝕜 ≃ₗ[𝕜] EuclideanSpace 𝕜 n →ₗ[𝕜] EuclideanSpace 𝕜 m :=
Matrix.toLin' ≪≫ₗ
LinearEquiv.arrowCongr (WithLp.linearEquiv _ 𝕜 (n → 𝕜)).symm
(WithLp.linearEquiv _ 𝕜 (m → 𝕜)).symm
@[simp]
lemma toEuclideanLin_toLp (A : Matrix m n 𝕜) (x : n → 𝕜) :
Matrix.toEuclideanLin A (toLp _ x) = toLp _ (Matrix.toLin' A x) := rfl
@[simp]
theorem piLp_ofLp_toEuclideanLin (A : Matrix m n 𝕜) (x : EuclideanSpace 𝕜 n) :
ofLp (Matrix.toEuclideanLin A x) = Matrix.toLin' A (ofLp x) :=
rfl
theorem toEuclideanLin_apply (M : Matrix m n 𝕜) (v : EuclideanSpace 𝕜 n) :
toEuclideanLin M v = toLp _ (M *ᵥ ofLp v) := rfl
@[simp]
theorem ofLp_toEuclideanLin_apply (M : Matrix m n 𝕜) (v : EuclideanSpace 𝕜 n) :
ofLp (toEuclideanLin M v) = M *ᵥ ofLp v :=
rfl
@[simp]
theorem toEuclideanLin_apply_piLp_toLp (M : Matrix m n 𝕜) (v : n → 𝕜) :
toEuclideanLin M (toLp _ v) = toLp _ (M *ᵥ v) :=
rfl
-- `Matrix.toEuclideanLin` is the same as `Matrix.toLin` applied to `PiLp.basisFun`,
theorem toEuclideanLin_eq_toLin [Finite m] :
(toEuclideanLin : Matrix m n 𝕜 ≃ₗ[𝕜] _) =
Matrix.toLin (PiLp.basisFun _ _ _) (PiLp.basisFun _ _ _) :=
rfl
open EuclideanSpace in
lemma toEuclideanLin_eq_toLin_orthonormal [Fintype m] :
toEuclideanLin = toLin (basisFun n 𝕜).toBasis (basisFun m 𝕜).toBasis :=
rfl
end Matrix
local notation "⟪" x ", " y "⟫ₑ" => inner 𝕜 (toLp 2 x) (toLp 2 y)
/-- The inner product of a row of `A` and a row of `B` is an entry of `B * Aᴴ`. -/
theorem inner_matrix_row_row [Fintype n] (A B : Matrix m n 𝕜) (i j : m) :
⟪A i, B j⟫ₑ = (B * Aᴴ) j i := by
simp [PiLp.inner_apply, dotProduct, mul_apply']
/-- The inner product of a column of `A` and a column of `B` is an entry of `Aᴴ * B`. -/
theorem inner_matrix_col_col [Fintype m] (A B : Matrix m n 𝕜) (i j : n) :
⟪Aᵀ i, Bᵀ j⟫ₑ = (Aᴴ * B) i j := by
simp [PiLp.inner_apply, dotProduct, mul_apply', mul_comm]
/-- The matrix representation of `innerSL 𝕜 x` given by an orthonormal basis `b` and `b₂`
is equal to `vecMulVec (star b₂) (star (b.repr x))`. -/
theorem toMatrix_innerSL_apply [Fintype n] [DecidableEq n] [Fintype m]
(b : OrthonormalBasis n 𝕜 E) (b₂ : OrthonormalBasis m 𝕜 𝕜) (x : E) :
(innerSL 𝕜 x).toMatrix b.toBasis b₂.toBasis = vecMulVec (star b₂) (star (b.repr x)) := by
ext; simp [LinearMap.toMatrix_apply, vecMulVec_apply, OrthonormalBasis.repr_apply_apply, mul_comm]
end Matrix |
.lake/packages/mathlib/Mathlib/Analysis/InnerProductSpace/Positive.lean | import Mathlib.Analysis.InnerProductSpace.Spectrum
import Mathlib.LinearAlgebra.Matrix.PosDef
/-!
# Positive operators
In this file we define when an operator in a Hilbert space is positive. We follow Bourbaki's choice
of requiring self adjointness in the definition.
## Main definitions
* `LinearMap.IsPositive` : a linear map is positive if it is symmetric and
`∀ x, 0 ≤ re ⟪T x, x⟫`.
* `ContinuousLinearMap.IsPositive` : a continuous linear map is positive if it is symmetric and
`∀ x, 0 ≤ re ⟪T x, x⟫`.
## Main statements
* `ContinuousLinearMap.IsPositive.conj_adjoint` : if `T : E →L[𝕜] E` is positive,
then for any `S : E →L[𝕜] F`, `S ∘L T ∘L S†` is also positive.
* `ContinuousLinearMap.isPositive_iff_complex` : in a ***complex*** Hilbert space,
checking that `⟪T x, x⟫` is a nonnegative real number for all `x` suffices to prove that
`T` is positive.
## References
* [Bourbaki, *Topological Vector Spaces*][bourbaki1987]
## Tags
Positive operator
-/
open InnerProductSpace RCLike LinearMap ContinuousLinearMap
open scoped InnerProduct ComplexConjugate
variable {𝕜 E F : Type*} [RCLike 𝕜]
variable [NormedAddCommGroup E] [NormedAddCommGroup F]
variable [InnerProductSpace 𝕜 E] [InnerProductSpace 𝕜 F]
local notation "⟪" x ", " y "⟫" => inner 𝕜 x y
namespace LinearMap
/-- A linear operator `T` on a Hilbert space is **positive** if it is symmetric and
`∀ x, 0 ≤ re ⟪T x, x⟫`. -/
def IsPositive (T : E →ₗ[𝕜] E) : Prop :=
IsSymmetric T ∧ ∀ x, 0 ≤ re ⟪T x, x⟫
theorem IsPositive.isSymmetric {T : E →ₗ[𝕜] E} (hT : IsPositive T) :
IsSymmetric T := hT.1
theorem IsPositive.re_inner_nonneg_left {T : E →ₗ[𝕜] E} (hT : IsPositive T)
(x : E) : 0 ≤ re ⟪T x, x⟫ :=
hT.2 x
theorem IsPositive.re_inner_nonneg_right {T : E →ₗ[𝕜] E} (hT : IsPositive T)
(x : E) : 0 ≤ re ⟪x, T x⟫ :=
inner_re_symm (𝕜 := 𝕜) _ x ▸ hT.re_inner_nonneg_left x
section Complex
variable {E' : Type*} [NormedAddCommGroup E'] [InnerProductSpace ℂ E']
theorem isPositive_iff_complex (T : E' →ₗ[ℂ] E') :
IsPositive T ↔ ∀ x, (re ⟪T x, x⟫_ℂ : ℂ) = ⟪T x, x⟫_ℂ ∧ 0 ≤ re ⟪T x, x⟫_ℂ := by
simp_rw [IsPositive, forall_and, isSymmetric_iff_inner_map_self_real,
conj_eq_iff_re, re_to_complex, Complex.coe_algebraMap]
end Complex
theorem IsPositive.isSelfAdjoint [FiniteDimensional 𝕜 E] {T : E →ₗ[𝕜] E} (hT : IsPositive T) :
IsSelfAdjoint T := (isSymmetric_iff_isSelfAdjoint _).mp hT.isSymmetric
theorem IsPositive.adjoint_eq [FiniteDimensional 𝕜 E] {T : E →ₗ[𝕜] E} (hT : IsPositive T) :
T.adjoint = T := hT.isSelfAdjoint
open ComplexOrder in
theorem isPositive_iff (T : E →ₗ[𝕜] E) :
IsPositive T ↔ IsSymmetric T ∧ ∀ x, 0 ≤ ⟪T x, x⟫ := by
simp_rw [IsPositive, and_congr_right_iff, ← RCLike.ofReal_nonneg (K := 𝕜)]
intro hT
simp [hT]
open ComplexOrder in
theorem IsPositive.inner_nonneg_left {T : E →ₗ[𝕜] E} (hT : IsPositive T) (x : E) : 0 ≤ ⟪T x, x⟫ :=
(T.isPositive_iff.mp hT).right x
open ComplexOrder in
theorem IsPositive.inner_nonneg_right {T : E →ₗ[𝕜] E} (hT : IsPositive T) (x : E) :
0 ≤ ⟪x, T x⟫ :=
hT.isSymmetric _ _ ▸ hT.inner_nonneg_left x
@[simp]
theorem isPositive_zero : IsPositive (0 : E →ₗ[𝕜] E) := ⟨.zero, by simp⟩
@[simp]
theorem isPositive_one : IsPositive (1 : E →ₗ[𝕜] E) := ⟨.id, fun _ => inner_self_nonneg⟩
@[simp]
theorem isPositive_id : IsPositive (id : E →ₗ[𝕜] E) := isPositive_one
@[simp]
theorem isPositive_natCast {n : ℕ} : IsPositive (n : E →ₗ[𝕜] E) := by
refine ⟨IsSymmetric.natCast n, fun x => ?_⟩
simp only [Module.End.natCast_apply, ← Nat.cast_smul_eq_nsmul 𝕜, inner_smul_left, map_natCast,
mul_re, natCast_re, inner_self_im, mul_zero, sub_zero]
exact mul_nonneg n.cast_nonneg' inner_self_nonneg
@[simp]
theorem isPositive_ofNat {n : ℕ} [n.AtLeastTwo] : IsPositive (ofNat(n) : E →ₗ[𝕜] E) :=
isPositive_natCast
@[aesop safe apply]
theorem IsPositive.add {T S : E →ₗ[𝕜] E} (hT : T.IsPositive) (hS : S.IsPositive) :
(T + S).IsPositive := by
refine ⟨hT.isSymmetric.add hS.isSymmetric, fun x => ?_⟩
rw [add_apply, inner_add_left, map_add]
exact add_nonneg (hT.re_inner_nonneg_left x) (hS.re_inner_nonneg_left x)
open ComplexOrder in
@[aesop safe apply]
theorem IsPositive.smul_of_nonneg {T : E →ₗ[𝕜] E} (hT : T.IsPositive) {c : 𝕜} (hc : 0 ≤ c) :
(c • T).IsPositive := by
have hc' : starRingEnd 𝕜 c = c := by
simp [conj_eq_iff_im, ← (le_iff_re_im.mp hc).right]
refine ⟨hT.left.smul hc', fun x => ?_⟩
rw [smul_apply, inner_smul_left, hc', mul_re, conj_eq_iff_im.mp hc', zero_mul, sub_zero]
exact mul_nonneg ((re_nonneg_of_nonneg hc').mpr hc) (re_inner_nonneg_left hT x)
theorem IsPositive.nonneg_eigenvalues [FiniteDimensional 𝕜 E]
{T : E →ₗ[𝕜] E} {n : ℕ} (hT : T.IsPositive)
(hn : Module.finrank 𝕜 E = n) (i : Fin n) : 0 ≤ hT.isSymmetric.eigenvalues hn i := by
simpa only [hT.isSymmetric.apply_eigenvectorBasis, inner_smul_real_left, RCLike.smul_re,
inner_self_eq_norm_sq, OrthonormalBasis.norm_eq_one, one_pow, mul_one]
using hT.right (hT.isSymmetric.eigenvectorBasis hn i)
section PartialOrder
/-- The (Loewner) partial order on linear maps on a Hilbert space determined by `f ≤ g`
if and only if `g - f` is a positive linear map (in the sense of `LinearMap.IsPositive`). -/
instance instLoewnerPartialOrder : PartialOrder (E →ₗ[𝕜] E) where
le f g := (g - f).IsPositive
le_refl _ := by simp
le_trans _ _ _ h₁ h₂ := by simpa using h₁.add h₂
le_antisymm f₁ f₂ h₁ h₂ := by
rw [← sub_eq_zero, ← h₂.isSymmetric.inner_map_self_eq_zero]
intro x
have hba2 := h₁.2 x
rw [← neg_le_neg_iff, ← map_neg, ← inner_neg_left, ← neg_apply, neg_sub, neg_zero] at hba2
rw [← h₂.isSymmetric.coe_re_inner_apply_self, RCLike.ofReal_eq_zero]
exact le_antisymm hba2 (h₂.2 _)
lemma le_def (f g : E →ₗ[𝕜] E) : f ≤ g ↔ (g - f).IsPositive := Iff.rfl
lemma nonneg_iff_isPositive (f : E →ₗ[𝕜] E) : 0 ≤ f ↔ f.IsPositive := by
simpa using le_def 0 f
end PartialOrder
/-- An idempotent linear map is positive iff it is symmetric. -/
theorem IsIdempotentElem.isPositive_iff_isSymmetric {T : E →ₗ[𝕜] E} (hT : IsIdempotentElem T) :
T.IsPositive ↔ T.IsSymmetric := by
refine ⟨fun h => h.isSymmetric, fun h => ⟨h, fun x => ?_⟩⟩
rw [← hT.eq, Module.End.mul_apply, h]
exact inner_self_nonneg
theorem isPositive_linearIsometryEquiv_conj_iff {T : E →ₗ[𝕜] E} (f : E ≃ₗᵢ[𝕜] F) :
IsPositive (f.toLinearMap ∘ₗ T ∘ₗ f.symm.toLinearMap) ↔ IsPositive T := by
simp_rw [IsPositive, isSymmetric_linearIsometryEquiv_conj_iff, and_congr_right_iff,
LinearIsometryEquiv.toLinearEquiv_symm, coe_comp, LinearEquiv.coe_coe,
LinearIsometryEquiv.coe_toLinearEquiv, LinearIsometryEquiv.coe_symm_toLinearEquiv,
Function.comp_apply, LinearIsometryEquiv.inner_map_eq_flip]
exact fun _ => ⟨fun h x => by simpa using h (f x), fun h x => h _⟩
open scoped ComplexOrder in
/-- `A.toEuclideanLin` is positive if and only if `A` is positive semi-definite. -/
@[simp] theorem _root_.Matrix.isPositive_toEuclideanLin_iff {n : Type*} [Fintype n] [DecidableEq n]
{A : Matrix n n 𝕜} : A.toEuclideanLin.IsPositive ↔ A.PosSemidef := by
simp_rw [LinearMap.IsPositive, ← Matrix.isHermitian_iff_isSymmetric, inner_re_symm,
EuclideanSpace.inner_eq_star_dotProduct, Matrix.piLp_ofLp_toEuclideanLin, Matrix.toLin'_apply,
dotProduct_comm (A.mulVec _), Matrix.PosSemidef, and_congr_right_iff,
RCLike.nonneg_iff (K := 𝕜)]
refine fun hA ↦ (EuclideanSpace.equiv n 𝕜).forall_congr' fun x ↦ ?_
simp [hA.im_star_dotProduct_mulVec_self]
open ComplexOrder in
/-- `A.toMatrix` is positive semi-definite if and only if `A` is positive. -/
@[simp] theorem posSemidef_toMatrix_iff {ι : Type*} [Fintype ι] [DecidableEq ι]
{A : E →ₗ[𝕜] E} (b : OrthonormalBasis ι 𝕜 E) :
(A.toMatrix b.toBasis b.toBasis).PosSemidef ↔ A.IsPositive := by
rw [← Matrix.isPositive_toEuclideanLin_iff]
convert isPositive_linearIsometryEquiv_conj_iff b.repr
ext
simp [LinearMap.toMatrix]
/-- A symmetric projection is positive. -/
@[aesop 10% apply, grind →]
theorem IsSymmetricProjection.isPositive {p : E →ₗ[𝕜] E} (hp : p.IsSymmetricProjection) :
p.IsPositive :=
hp.isIdempotentElem.isPositive_iff_isSymmetric.mpr hp.isSymmetric
@[deprecated (since := "2025-10-17")] alias IsPositive.of_isSymmetricProjection :=
IsSymmetricProjection.isPositive
/-- A star projection operator is positive. -/
@[deprecated (since := "2025-08-19")]
alias IsPositive.of_isStarProjection := IsSymmetricProjection.isPositive
theorem IsSymmetricProjection.le_iff_range_le_range {p q : E →ₗ[𝕜] E}
(hp : p.IsSymmetricProjection) (hq : q.IsSymmetricProjection) : p ≤ q ↔ range p ≤ range q := by
refine ⟨fun ⟨h1, h2⟩ a ha ↦ ?_, fun hpq ↦ (hp.sub_of_range_le_range hq hpq).isPositive⟩
specialize h2 a
have hh {T : E →ₗ[𝕜] E} (hT : T.IsSymmetricProjection) : RCLike.re ⟪T a, a⟫_𝕜 = ‖T a‖ ^ 2 := by
conv_lhs => rw [← hT.isIdempotentElem]
rw [Module.End.mul_apply, hT.isSymmetric]
exact inner_self_eq_norm_sq _
simp_rw [sub_apply, inner_sub_left, map_sub, hh hq, hh hp,
hp.isIdempotentElem.mem_range_iff.mp ha, sub_nonneg, sq_le_sq, abs_norm] at h2
obtain ⟨U, _, rfl⟩ := isSymmetricProjection_iff_eq_coe_starProjection.mp hq
simpa [Submodule.starProjection_coe_eq_isCompl_projection] using
U.mem_iff_norm_starProjection _ |>.mpr <| le_antisymm (U.norm_starProjection_apply_le a) h2
end LinearMap
namespace ContinuousLinearMap
/-- A continuous linear endomorphism `T` of a Hilbert space is **positive** if it is symmetric
and `∀ x, 0 ≤ re ⟪T x, x⟫`. -/
def IsPositive (T : E →L[𝕜] E) : Prop :=
T.IsSymmetric ∧ ∀ x, 0 ≤ T.reApplyInnerSelf x
theorem isPositive_def {T : E →L[𝕜] E} :
T.IsPositive ↔ T.IsSymmetric ∧ ∀ x, 0 ≤ T.reApplyInnerSelf x := Iff.rfl
/-- In a complete space, a continuous linear endomorphism `T` is **positive** if it is
symmetric and `∀ x, 0 ≤ re ⟪T x, x⟫`. -/
theorem isPositive_def' [CompleteSpace E] {T : E →L[𝕜] E} :
T.IsPositive ↔ IsSelfAdjoint T ∧ ∀ x, 0 ≤ T.reApplyInnerSelf x := by
simp [IsPositive, isSelfAdjoint_iff_isSymmetric, LinearMap.IsSymmetric]
theorem IsPositive.isSymmetric {T : E →L[𝕜] E} (hT : T.IsPositive) :
T.IsSymmetric := hT.1
theorem IsPositive.isSelfAdjoint [CompleteSpace E] {T : E →L[𝕜] E} (hT : IsPositive T) :
IsSelfAdjoint T := hT.isSymmetric.isSelfAdjoint
theorem IsPositive.inner_left_eq_inner_right {T : E →L[𝕜] E} (hT : IsPositive T) (x y : E) :
⟪T x, y⟫ = ⟪x, T y⟫ := hT.isSymmetric _ _
theorem IsPositive.re_inner_nonneg_left {T : E →L[𝕜] E} (hT : IsPositive T) (x : E) :
0 ≤ re ⟪T x, x⟫ := hT.2 x
lemma _root_.LinearMap.isPositive_toContinuousLinearMap_iff
[FiniteDimensional 𝕜 E] (T : E →ₗ[𝕜] E) :
T.toContinuousLinearMap.IsPositive ↔ T.IsPositive := Iff.rfl
lemma isPositive_toLinearMap_iff (T : E →L[𝕜] E) :
(T : E →ₗ[𝕜] E).IsPositive ↔ T.IsPositive := Iff.rfl
alias ⟨_, IsPositive.toLinearMap⟩ := isPositive_toLinearMap_iff
theorem IsPositive.re_inner_nonneg_right {T : E →L[𝕜] E} (hT : IsPositive T) (x : E) :
0 ≤ re ⟪x, T x⟫ := hT.toLinearMap.re_inner_nonneg_right x
open ComplexOrder in
/-- An operator is positive iff it is symmetric and `0 ≤ ⟪T x, x⟫`.
For the version with `IsSelfAdjoint` instead of `IsSymmetric`, see
`ContinuousLinearMap.isPositive_iff'`. -/
theorem isPositive_iff (T : E →L[𝕜] E) :
IsPositive T ↔ T.IsSymmetric ∧ ∀ x, 0 ≤ ⟪T x, x⟫ := LinearMap.isPositive_iff _
open ComplexOrder in
/-- An operator is positive iff it is self-adjoint and `0 ≤ ⟪T x, x⟫`.
For the version with `IsSymmetric` instead of `IsSelfAdjoint`, see
`ContinuousLinearMap.isPositive_iff`. -/
theorem isPositive_iff' [CompleteSpace E] (T : E →L[𝕜] E) :
IsPositive T ↔ IsSelfAdjoint T ∧ ∀ x, 0 ≤ ⟪T x, x⟫ := by
simp [isSelfAdjoint_iff_isSymmetric, isPositive_iff]
open ComplexOrder in
theorem IsPositive.inner_nonneg_left {T : E →L[𝕜] E} (hT : IsPositive T) (x : E) :
0 ≤ ⟪T x, x⟫ := hT.toLinearMap.inner_nonneg_left x
open ComplexOrder in
theorem IsPositive.inner_nonneg_right {T : E →L[𝕜] E} (hT : IsPositive T) (x : E) :
0 ≤ ⟪x, T x⟫ := hT.toLinearMap.inner_nonneg_right x
@[simp]
theorem isPositive_zero : IsPositive (0 : E →L[𝕜] E) := LinearMap.isPositive_zero
@[simp]
theorem isPositive_id : IsPositive (.id 𝕜 E : E →L[𝕜] E) := LinearMap.isPositive_id
@[simp]
theorem isPositive_one : IsPositive (1 : E →L[𝕜] E) := LinearMap.isPositive_one
@[simp]
theorem isPositive_natCast {n : ℕ} : IsPositive (n : E →L[𝕜] E) :=
(isPositive_toLinearMap_iff _).mp LinearMap.isPositive_natCast
@[simp]
theorem isPositive_ofNat {n : ℕ} [n.AtLeastTwo] : IsPositive (ofNat(n) : E →L[𝕜] E) :=
isPositive_natCast
@[aesop safe apply]
theorem IsPositive.add {T S : E →L[𝕜] E} (hT : T.IsPositive) (hS : S.IsPositive) :
(T + S).IsPositive :=
(isPositive_toLinearMap_iff _).mp (hT.toLinearMap.add hS.toLinearMap)
open ComplexOrder in
@[aesop safe apply]
theorem IsPositive.smul_of_nonneg {T : E →L[𝕜] E} (hT : T.IsPositive) {c : 𝕜} (hc : 0 ≤ c) :
(c • T).IsPositive :=
(isPositive_toLinearMap_iff _).mp (hT.toLinearMap.smul_of_nonneg hc)
@[aesop safe apply]
theorem IsPositive.conj_adjoint [CompleteSpace E] [CompleteSpace F] {T : E →L[𝕜] E}
(hT : T.IsPositive) (S : E →L[𝕜] F) : (S ∘L T ∘L S†).IsPositive := by
refine isPositive_def'.mpr ⟨hT.isSelfAdjoint.conj_adjoint S, fun x => ?_⟩
rw [reApplyInnerSelf, comp_apply, ← adjoint_inner_right]
exact hT.re_inner_nonneg_left _
theorem isPositive_self_comp_adjoint [CompleteSpace E] [CompleteSpace F] (S : E →L[𝕜] F) :
(S ∘L S†).IsPositive := by
simpa using isPositive_one.conj_adjoint S
@[aesop safe apply]
theorem IsPositive.adjoint_conj [CompleteSpace E] [CompleteSpace F] {T : E →L[𝕜] E}
(hT : T.IsPositive) (S : F →L[𝕜] E) : (S† ∘L T ∘L S).IsPositive := by
convert hT.conj_adjoint (S†)
rw [adjoint_adjoint]
theorem isPositive_adjoint_comp_self [CompleteSpace E] [CompleteSpace F] (S : E →L[𝕜] F) :
(S† ∘L S).IsPositive := by
simpa using isPositive_one.adjoint_conj S
section LinearMap
variable [FiniteDimensional 𝕜 E] [FiniteDimensional 𝕜 F]
@[aesop safe apply]
theorem _root_.LinearMap.IsPositive.conj_adjoint {T : E →ₗ[𝕜] E}
(hT : T.IsPositive) (S : E →ₗ[𝕜] F) : (S ∘ₗ T ∘ₗ S.adjoint).IsPositive := by
have := FiniteDimensional.complete 𝕜 E
have := FiniteDimensional.complete 𝕜 F
simpa [← isPositive_toContinuousLinearMap_iff] using
((T.isPositive_toContinuousLinearMap_iff.mpr hT).conj_adjoint S.toContinuousLinearMap)
theorem _root_.LinearMap.isPositive_self_comp_adjoint (S : E →ₗ[𝕜] F) :
(S ∘ₗ S.adjoint).IsPositive := by
simpa using LinearMap.isPositive_one.conj_adjoint S
@[aesop safe apply]
theorem _root_.LinearMap.IsPositive.adjoint_conj {T : E →ₗ[𝕜] E}
(hT : T.IsPositive) (S : F →ₗ[𝕜] E) : (S.adjoint ∘ₗ T ∘ₗ S).IsPositive := by
convert hT.conj_adjoint S.adjoint
rw [LinearMap.adjoint_adjoint]
theorem _root_.LinearMap.isPositive_adjoint_comp_self (S : E →ₗ[𝕜] F) :
(S.adjoint ∘ₗ S).IsPositive := by
simpa using LinearMap.isPositive_one.adjoint_conj S
end LinearMap
theorem IsPositive.conj_starProjection (U : Submodule 𝕜 E) {T : E →L[𝕜] E} (hT : T.IsPositive)
[U.HasOrthogonalProjection] :
(U.starProjection ∘L T ∘L U.starProjection).IsPositive := by
simp only [isPositive_iff, IsSymmetric, coe_comp, LinearMap.coe_comp, coe_coe,
Function.comp_apply, coe_comp']
simp_rw [← coe_coe, U.starProjection_isSymmetric _ , hT.isSymmetric _,
U.starProjection_isSymmetric _, ← U.starProjection_isSymmetric _, coe_coe,
hT.inner_nonneg_right, implies_true, and_self]
theorem IsPositive.orthogonalProjection_comp {T : E →L[𝕜] E} (hT : T.IsPositive) (U : Submodule 𝕜 E)
[U.HasOrthogonalProjection] : (U.orthogonalProjection ∘L T ∘L U.subtypeL).IsPositive := by
simp only [isPositive_iff, IsSymmetric, coe_comp, LinearMap.coe_comp, coe_coe,
Function.comp_apply, coe_comp']
simp_rw [U.inner_orthogonalProjection_eq_of_mem_right, Submodule.subtypeL_apply,
U.inner_orthogonalProjection_eq_of_mem_left, ← coe_coe, hT.isSymmetric _, coe_coe,
hT.inner_nonneg_right, implies_true, and_self]
open scoped NNReal
lemma antilipschitz_of_forall_le_inner_map {H : Type*} [NormedAddCommGroup H]
[InnerProductSpace 𝕜 H] (f : H →L[𝕜] H) {c : ℝ≥0} (hc : 0 < c)
(h : ∀ x, ‖x‖ ^ 2 * c ≤ ‖⟪f x, x⟫_𝕜‖) : AntilipschitzWith c⁻¹ f := by
refine f.antilipschitz_of_bound (K := c⁻¹) fun x ↦ ?_
rw [NNReal.coe_inv, inv_mul_eq_div, le_div_iff₀ (by exact_mod_cast hc)]
simp_rw [sq, mul_assoc] at h
by_cases hx0 : x = 0
· simp [hx0]
· apply (map_le_map_iff <| OrderIso.mulLeft₀ ‖x‖ (norm_pos_iff.mpr hx0)).mp
exact (h x).trans <| (norm_inner_le_norm _ _).trans <| (mul_comm _ _).le
lemma isUnit_of_forall_le_norm_inner_map [CompleteSpace E] (f : E →L[𝕜] E) {c : ℝ≥0} (hc : 0 < c)
(h : ∀ x, ‖x‖ ^ 2 * c ≤ ‖⟪f x, x⟫_𝕜‖) : IsUnit f := by
rw [isUnit_iff_bijective, bijective_iff_dense_range_and_antilipschitz]
have h_anti : AntilipschitzWith c⁻¹ f := antilipschitz_of_forall_le_inner_map f hc h
refine ⟨?_, ⟨_, h_anti⟩⟩
rw [Submodule.topologicalClosure_eq_top_iff, Submodule.eq_bot_iff]
intro x hx
have : ‖x‖ ^ 2 * c = 0 := le_antisymm (by simpa only [hx (f x) ⟨x, rfl⟩, norm_zero] using h x)
(by positivity)
aesop
section Complex
variable {E' : Type*} [NormedAddCommGroup E'] [InnerProductSpace ℂ E']
theorem isPositive_iff_complex (T : E' →L[ℂ] E') :
IsPositive T ↔ ∀ x, (re ⟪T x, x⟫_ℂ : ℂ) = ⟪T x, x⟫_ℂ ∧ 0 ≤ re ⟪T x, x⟫_ℂ := by
simp [← isPositive_toLinearMap_iff, LinearMap.isPositive_iff_complex]
end Complex
section PartialOrder
/-- The (Loewner) partial order on continuous linear maps on a Hilbert space determined by
`f ≤ g` if and only if `g - f` is a positive linear map (in the sense of
`ContinuousLinearMap.IsPositive`). With this partial order, the continuous linear maps form a
`StarOrderedRing`. -/
instance instLoewnerPartialOrder : PartialOrder (E →L[𝕜] E) where
le f g := (g - f).IsPositive
le_refl _ := by simp
le_trans _ _ _ h₁ h₂ := by simpa using h₁.add h₂
le_antisymm _ _ h₁ h₂ := coe_inj.mp (le_antisymm h₁.toLinearMap h₂.toLinearMap)
lemma le_def (f g : E →L[𝕜] E) : f ≤ g ↔ (g - f).IsPositive := Iff.rfl
lemma coe_le_coe_iff (f g : E →L[𝕜] E) :
(f : E →ₗ[𝕜] E) ≤ g ↔ f ≤ g :=
isPositive_toLinearMap_iff (g - f)
lemma nonneg_iff_isPositive (f : E →L[𝕜] E) : 0 ≤ f ↔ f.IsPositive := by
simpa using le_def 0 f
end PartialOrder
/-- An idempotent operator is positive if and only if it is self-adjoint. -/
@[grind →]
theorem IsIdempotentElem.isPositive_iff_isSelfAdjoint [CompleteSpace E]
{p : E →L[𝕜] E} (hp : IsIdempotentElem p) : p.IsPositive ↔ IsSelfAdjoint p := by
rw [← isPositive_toLinearMap_iff, IsIdempotentElem.isPositive_iff_isSymmetric hp.toLinearMap]
exact isSelfAdjoint_iff_isSymmetric.symm
/-- A star projection operator is positive.
The proof of this will soon be simplified to `IsStarProjection.nonneg` when we
have `StarOrderedRing (E →L[𝕜] E)`. -/
@[aesop 10% apply, grind →]
theorem IsPositive.of_isStarProjection [CompleteSpace E] {p : E →L[𝕜] E}
(hp : IsStarProjection p) : p.IsPositive :=
hp.isIdempotentElem.isPositive_iff_isSelfAdjoint.mpr hp.isSelfAdjoint
/-- For an idempotent operator `p`, TFAE:
* `(range p)ᗮ = ker p`
* `p` is normal
* `p` is self-adjoint
* `p` is positive -/
theorem IsIdempotentElem.TFAE [CompleteSpace E] {p : E →L[𝕜] E} (hp : IsIdempotentElem p) :
[(LinearMap.range p)ᗮ = LinearMap.ker p,
IsStarNormal p,
IsSelfAdjoint p,
p.IsPositive].TFAE := by
tfae_have 2 ↔ 3 := hp.isSelfAdjoint_iff_isStarNormal.symm
tfae_have 3 ↔ 4 := hp.isPositive_iff_isSelfAdjoint.symm
tfae_have 3 ↔ 1 := p.isSelfAdjoint_iff_isSymmetric.eq ▸
(ContinuousLinearMap.IsIdempotentElem.isSymmetric_iff_orthogonal_range hp)
tfae_finish
end ContinuousLinearMap
/-- `U.starProjection ≤ V.starProjection` iff `U ≤ V`. -/
theorem Submodule.starProjection_le_starProjection_iff {U V : Submodule 𝕜 E}
[U.HasOrthogonalProjection] [V.HasOrthogonalProjection] :
U.starProjection ≤ V.starProjection ↔ U ≤ V := by
simp_rw [← coe_le_coe_iff, isSymmetricProjection_starProjection _
|>.le_iff_range_le_range <| isSymmetricProjection_starProjection _,
starProjection_coe_eq_isCompl_projection, IsCompl.projection_range]
/-- `U.starProjection = V.starProjection` iff `U = V`. -/
theorem Submodule.starProjection_inj {U V : Submodule 𝕜 E}
[U.HasOrthogonalProjection] [V.HasOrthogonalProjection] :
U.starProjection = V.starProjection ↔ U = V := by
simp only [le_antisymm_iff, ← starProjection_le_starProjection_iff] |
.lake/packages/mathlib/Mathlib/Analysis/InnerProductSpace/LaxMilgram.lean | import Mathlib.Analysis.InnerProductSpace.Dual
/-!
# The Lax-Milgram Theorem
We consider a Hilbert space `V` over `ℝ`
equipped with a bounded bilinear form `B : V →L[ℝ] V →L[ℝ] ℝ`.
Recall that a bilinear form `B : V →L[ℝ] V →L[ℝ] ℝ` is *coercive*
iff `∃ C, (0 < C) ∧ ∀ u, C * ‖u‖ * ‖u‖ ≤ B u u`.
Under the hypothesis that `B` is coercive we prove the Lax-Milgram theorem:
that is, the map `InnerProductSpace.continuousLinearMapOfBilin` from
`Analysis.InnerProductSpace.Dual` can be upgraded to a continuous equivalence
`IsCoercive.continuousLinearEquivOfBilin : V ≃L[ℝ] V`.
## References
* We follow the notes of Peter Howard's Spring 2020 *M612: Partial Differential Equations* lecture,
see[howard]
## Tags
dual, Lax-Milgram
-/
noncomputable section
open RCLike LinearMap ContinuousLinearMap InnerProductSpace
open LinearMap (ker range)
open RealInnerProductSpace NNReal
universe u
namespace IsCoercive
variable {V : Type u} [NormedAddCommGroup V] [InnerProductSpace ℝ V] [CompleteSpace V]
variable {B : V →L[ℝ] V →L[ℝ] ℝ}
local postfix:1024 "♯" => continuousLinearMapOfBilin (𝕜 := ℝ)
theorem bounded_below (coercive : IsCoercive B) : ∃ C, 0 < C ∧ ∀ v, C * ‖v‖ ≤ ‖B♯ v‖ := by
rcases coercive with ⟨C, C_ge_0, coercivity⟩
refine ⟨C, C_ge_0, ?_⟩
intro v
by_cases h : 0 < ‖v‖
· refine (mul_le_mul_iff_left₀ h).mp ?_
calc
C * ‖v‖ * ‖v‖ ≤ B v v := coercivity v
_ = ⟪B♯ v, v⟫_ℝ := (continuousLinearMapOfBilin_apply B v v).symm
_ ≤ ‖B♯ v‖ * ‖v‖ := real_inner_le_norm (B♯ v) v
· have : v = 0 := by simpa using h
simp [this]
theorem antilipschitz (coercive : IsCoercive B) : ∃ C : ℝ≥0, 0 < C ∧ AntilipschitzWith C B♯ := by
rcases coercive.bounded_below with ⟨C, C_pos, below_bound⟩
refine ⟨C⁻¹.toNNReal, Real.toNNReal_pos.mpr (inv_pos.mpr C_pos), ?_⟩
refine ContinuousLinearMap.antilipschitz_of_bound B♯ ?_
simp_rw [Real.coe_toNNReal', max_eq_left_of_lt (inv_pos.mpr C_pos), ←
inv_mul_le_iff₀ (inv_pos.mpr C_pos)]
simpa using below_bound
theorem ker_eq_bot (coercive : IsCoercive B) : ker B♯ = ⊥ := by
rw [LinearMapClass.ker_eq_bot]
rcases coercive.antilipschitz with ⟨_, _, antilipschitz⟩
exact antilipschitz.injective
theorem isClosed_range (coercive : IsCoercive B) : IsClosed (range B♯ : Set V) := by
rcases coercive.antilipschitz with ⟨_, _, antilipschitz⟩
exact antilipschitz.isClosed_range B♯.uniformContinuous
theorem range_eq_top (coercive : IsCoercive B) : range B♯ = ⊤ := by
haveI := coercive.isClosed_range.completeSpace_coe
rw [← (range B♯).orthogonal_orthogonal]
rw [Submodule.eq_top_iff']
intro v w mem_w_orthogonal
rcases coercive with ⟨C, C_pos, coercivity⟩
obtain rfl : w = 0 := by
rw [← norm_eq_zero, ← mul_self_eq_zero, ← mul_right_inj' C_pos.ne', mul_zero, ←
mul_assoc]
apply le_antisymm
· calc
C * ‖w‖ * ‖w‖ ≤ B w w := coercivity w
_ = ⟪B♯ w, w⟫_ℝ := (continuousLinearMapOfBilin_apply B w w).symm
_ = 0 := mem_w_orthogonal _ ⟨w, rfl⟩
· positivity
exact inner_zero_left _
/-- The Lax-Milgram equivalence of a coercive bounded bilinear operator:
for all `v : V`, `continuousLinearEquivOfBilin B v` is the unique element `V`
such that `continuousLinearEquivOfBilin B v, w⟫ = B v w`.
The Lax-Milgram theorem states that this is a continuous equivalence.
-/
def continuousLinearEquivOfBilin (coercive : IsCoercive B) : V ≃L[ℝ] V :=
ContinuousLinearEquiv.ofBijective B♯ coercive.ker_eq_bot coercive.range_eq_top
@[simp]
theorem continuousLinearEquivOfBilin_apply (coercive : IsCoercive B) (v w : V) :
⟪coercive.continuousLinearEquivOfBilin v, w⟫_ℝ = B v w :=
continuousLinearMapOfBilin_apply B v w
theorem unique_continuousLinearEquivOfBilin (coercive : IsCoercive B) {v f : V}
(is_lax_milgram : ∀ w, ⟪f, w⟫_ℝ = B v w) : f = coercive.continuousLinearEquivOfBilin v :=
unique_continuousLinearMapOfBilin B is_lax_milgram
end IsCoercive |
.lake/packages/mathlib/Mathlib/Analysis/InnerProductSpace/Trace.lean | import Mathlib.Analysis.InnerProductSpace.PiL2
import Mathlib.Analysis.InnerProductSpace.Spectrum
import Mathlib.LinearAlgebra.Trace
/-!
# Traces in inner product spaces
This file contains various results about traces of linear operators in inner product spaces.
-/
namespace LinearMap
variable {𝕜 E ι : Type*} [RCLike 𝕜] [Fintype ι]
variable [NormedAddCommGroup E] [InnerProductSpace 𝕜 E]
open scoped InnerProductSpace
lemma trace_eq_sum_inner (T : E →ₗ[𝕜] E) (b : OrthonormalBasis ι 𝕜 E) :
T.trace 𝕜 E = ∑ i, ⟪b i, T (b i)⟫_𝕜 := by
classical
rw [LinearMap.trace_eq_matrix_trace 𝕜 b.toBasis T]
apply Fintype.sum_congr
intro i
rw [Matrix.diag_apply, T.toMatrix_apply, b.coe_toBasis, b.coe_toBasis_repr_apply,
b.repr_apply_apply]
variable [FiniteDimensional 𝕜 E]
variable {n : ℕ} (hn : Module.finrank 𝕜 E = n)
lemma IsSymmetric.trace_eq_sum_eigenvalues {T : E →ₗ[𝕜] E} (hT : T.IsSymmetric) :
T.trace 𝕜 E = ∑ i, hT.eigenvalues hn i := by
let b := hT.eigenvectorBasis hn
rw [T.trace_eq_sum_inner b, RCLike.ofReal_sum]
apply Fintype.sum_congr
intro i
rw [hT.apply_eigenvectorBasis, inner_smul_real_right, inner_self_eq_norm_sq_to_K, b.norm_eq_one]
simp [RCLike.ofReal_alg]
lemma IsSymmetric.re_trace_eq_sum_eigenvalues {T : E →ₗ[𝕜] E} (hT : T.IsSymmetric) :
RCLike.re (T.trace 𝕜 E) = ∑ i, hT.eigenvalues hn i := by
rw [hT.trace_eq_sum_eigenvalues]
exact RCLike.ofReal_re_ax _
end LinearMap |
.lake/packages/mathlib/Mathlib/Analysis/InnerProductSpace/ConformalLinearMap.lean | import Mathlib.Analysis.Normed.Operator.Conformal
import Mathlib.Analysis.InnerProductSpace.LinearMap
/-!
# Conformal maps between inner product spaces
In an inner product space, a map is conformal iff it preserves inner products up to a scalar factor.
-/
variable {E F : Type*}
variable [NormedAddCommGroup E] [NormedAddCommGroup F]
variable [InnerProductSpace ℝ E] [InnerProductSpace ℝ F]
open LinearIsometry ContinuousLinearMap
open RealInnerProductSpace
/-- A map between two inner product spaces is a conformal map if and only if it preserves inner
products up to a scalar factor, i.e., there exists a positive `c : ℝ` such that
`⟪f u, f v⟫ = c * ⟪u, v⟫` for all `u`, `v`. -/
theorem isConformalMap_iff (f : E →L[ℝ] F) :
IsConformalMap f ↔ ∃ c : ℝ, 0 < c ∧ ∀ u v : E, ⟪f u, f v⟫ = c * ⟪u, v⟫ := by
constructor
· rintro ⟨c₁, hc₁, li, rfl⟩
refine ⟨c₁ * c₁, mul_self_pos.2 hc₁, fun u v => ?_⟩
simp only [real_inner_smul_left, real_inner_smul_right, mul_assoc, coe_smul',
coe_toContinuousLinearMap, Pi.smul_apply, inner_map_map]
· rintro ⟨c₁, hc₁, huv⟩
obtain ⟨c, hc, rfl⟩ : ∃ c : ℝ, 0 < c ∧ c₁ = c * c :=
⟨√c₁, Real.sqrt_pos.2 hc₁, (Real.mul_self_sqrt hc₁.le).symm⟩
refine ⟨c, hc.ne', (c⁻¹ • f : E →ₗ[ℝ] F).isometryOfInner fun u v => ?_, ?_⟩
· simp only [real_inner_smul_left, real_inner_smul_right, huv, mul_assoc,
inv_mul_cancel_left₀ hc.ne', LinearMap.smul_apply, ContinuousLinearMap.coe_coe]
· ext1 x
exact (smul_inv_smul₀ hc.ne' (f x)).symm |
.lake/packages/mathlib/Mathlib/Analysis/InnerProductSpace/Adjoint.lean | import Mathlib.Analysis.InnerProductSpace.Dual
import Mathlib.Analysis.InnerProductSpace.PiL2
/-!
# Adjoint of operators on Hilbert spaces
Given an operator `A : E →L[𝕜] F`, where `E` and `F` are Hilbert spaces, its adjoint
`adjoint A : F →L[𝕜] E` is the unique operator such that `⟪x, A y⟫ = ⟪adjoint A x, y⟫` for all
`x` and `y`.
We then use this to put a C⋆-algebra structure on `E →L[𝕜] E` with the adjoint as the star
operation.
This construction is used to define an adjoint for linear maps (i.e. not continuous) between
finite-dimensional spaces.
## Main definitions
* `ContinuousLinearMap.adjoint : (E →L[𝕜] F) ≃ₗᵢ⋆[𝕜] (F →L[𝕜] E)`: the adjoint of a continuous
linear map, bundled as a conjugate-linear isometric equivalence.
* `LinearMap.adjoint : (E →ₗ[𝕜] F) ≃ₗ⋆[𝕜] (F →ₗ[𝕜] E)`: the adjoint of a linear map between
finite-dimensional spaces, this time only as a conjugate-linear equivalence, since there is no
norm defined on these maps.
## Implementation notes
* The continuous conjugate-linear version `adjointAux` is only an intermediate
definition and is not meant to be used outside this file.
## Tags
adjoint
-/
noncomputable section
open Module RCLike
open scoped ComplexConjugate
variable {𝕜 E F G : Type*} [RCLike 𝕜]
variable [NormedAddCommGroup E] [NormedAddCommGroup F] [NormedAddCommGroup G]
variable [InnerProductSpace 𝕜 E] [InnerProductSpace 𝕜 F] [InnerProductSpace 𝕜 G]
local notation "⟪" x ", " y "⟫" => inner 𝕜 x y
/-! ### Adjoint operator -/
open InnerProductSpace
namespace ContinuousLinearMap
variable [CompleteSpace E] [CompleteSpace G]
-- Note: made noncomputable to stop excess compilation
-- https://github.com/leanprover-community/mathlib4/issues/7103
/-- The adjoint, as a continuous conjugate-linear map. This is only meant as an auxiliary
definition for the main definition `adjoint`, where this is bundled as a conjugate-linear isometric
equivalence. -/
noncomputable def adjointAux : (E →L[𝕜] F) →L⋆[𝕜] F →L[𝕜] E :=
(ContinuousLinearMap.compSL _ _ _ _ _ ((toDual 𝕜 E).symm : StrongDual 𝕜 E →L⋆[𝕜] E)).comp
(toSesqForm : (E →L[𝕜] F) →L[𝕜] F →L⋆[𝕜] StrongDual 𝕜 E)
@[simp]
theorem adjointAux_apply (A : E →L[𝕜] F) (x : F) :
adjointAux A x = ((toDual 𝕜 E).symm : StrongDual 𝕜 E → E) ((toSesqForm A) x) :=
rfl
theorem adjointAux_inner_left (A : E →L[𝕜] F) (x : E) (y : F) : ⟪adjointAux A y, x⟫ = ⟪y, A x⟫ := by
rw [adjointAux_apply, toDual_symm_apply, toSesqForm_apply_coe, coe_comp', coe_innerSL_apply,
Function.comp_apply]
theorem adjointAux_inner_right (A : E →L[𝕜] F) (x : E) (y : F) :
⟪x, adjointAux A y⟫ = ⟪A x, y⟫ := by
rw [← inner_conj_symm, adjointAux_inner_left, inner_conj_symm]
variable [CompleteSpace F]
theorem adjointAux_adjointAux (A : E →L[𝕜] F) : adjointAux (adjointAux A) = A := by
ext v
refine ext_inner_left 𝕜 fun w => ?_
rw [adjointAux_inner_right, adjointAux_inner_left]
@[simp]
theorem adjointAux_norm (A : E →L[𝕜] F) : ‖adjointAux A‖ = ‖A‖ := by
refine le_antisymm ?_ ?_
· refine ContinuousLinearMap.opNorm_le_bound _ (norm_nonneg _) fun x => ?_
rw [adjointAux_apply, LinearIsometryEquiv.norm_map]
exact toSesqForm_apply_norm_le
· nth_rw 1 [← adjointAux_adjointAux A]
refine ContinuousLinearMap.opNorm_le_bound _ (norm_nonneg _) fun x => ?_
rw [adjointAux_apply, LinearIsometryEquiv.norm_map]
exact toSesqForm_apply_norm_le
/-- The adjoint of a bounded operator `A` from a Hilbert space `E` to another Hilbert space `F`,
denoted as `A†`. -/
def adjoint : (E →L[𝕜] F) ≃ₗᵢ⋆[𝕜] F →L[𝕜] E :=
LinearIsometryEquiv.ofSurjective { adjointAux with norm_map' := adjointAux_norm } fun A =>
⟨adjointAux A, adjointAux_adjointAux A⟩
@[inherit_doc]
scoped[InnerProduct] postfix:1000 "†" => ContinuousLinearMap.adjoint
open InnerProduct
/-- The fundamental property of the adjoint. -/
theorem adjoint_inner_left (A : E →L[𝕜] F) (x : E) (y : F) : ⟪(A†) y, x⟫ = ⟪y, A x⟫ :=
adjointAux_inner_left A x y
/-- The fundamental property of the adjoint. -/
theorem adjoint_inner_right (A : E →L[𝕜] F) (x : E) (y : F) : ⟪x, (A†) y⟫ = ⟪A x, y⟫ :=
adjointAux_inner_right A x y
/-- The adjoint is involutive. -/
@[simp]
theorem adjoint_adjoint (A : E →L[𝕜] F) : A†† = A :=
adjointAux_adjointAux A
/-- The adjoint of the composition of two operators is the composition of the two adjoints
in reverse order. -/
@[simp]
theorem adjoint_comp (A : F →L[𝕜] G) (B : E →L[𝕜] F) : (A ∘L B)† = B† ∘L A† := by
ext v
refine ext_inner_left 𝕜 fun w => ?_
simp only [adjoint_inner_right, ContinuousLinearMap.coe_comp', Function.comp_apply]
theorem apply_norm_sq_eq_inner_adjoint_left (A : E →L[𝕜] F) (x : E) :
‖A x‖ ^ 2 = re ⟪(A† ∘L A) x, x⟫ := by
have h : ⟪(A† ∘L A) x, x⟫ = ⟪A x, A x⟫ := by rw [← adjoint_inner_left]; rfl
rw [h, ← inner_self_eq_norm_sq (𝕜 := 𝕜) _]
theorem apply_norm_eq_sqrt_inner_adjoint_left (A : E →L[𝕜] F) (x : E) :
‖A x‖ = √(re ⟪(A† ∘L A) x, x⟫) := by
rw [← apply_norm_sq_eq_inner_adjoint_left, Real.sqrt_sq (norm_nonneg _)]
theorem apply_norm_sq_eq_inner_adjoint_right (A : E →L[𝕜] F) (x : E) :
‖A x‖ ^ 2 = re ⟪x, (A† ∘L A) x⟫ := by
have h : ⟪x, (A† ∘L A) x⟫ = ⟪A x, A x⟫ := by rw [← adjoint_inner_right]; rfl
rw [h, ← inner_self_eq_norm_sq (𝕜 := 𝕜) _]
theorem apply_norm_eq_sqrt_inner_adjoint_right (A : E →L[𝕜] F) (x : E) :
‖A x‖ = √(re ⟪x, (A† ∘L A) x⟫) := by
rw [← apply_norm_sq_eq_inner_adjoint_right, Real.sqrt_sq (norm_nonneg _)]
/-- The adjoint is unique: a map `A` is the adjoint of `B` iff it satisfies `⟪A x, y⟫ = ⟪x, B y⟫`
for all `x` and `y`. -/
theorem eq_adjoint_iff (A : E →L[𝕜] F) (B : F →L[𝕜] E) : A = B† ↔ ∀ x y, ⟪A x, y⟫ = ⟪x, B y⟫ := by
refine ⟨fun h x y => by rw [h, adjoint_inner_left], fun h => ?_⟩
ext x
exact ext_inner_right 𝕜 fun y => by simp only [adjoint_inner_left, h x y]
@[simp]
theorem _root_.LinearMap.IsSymmetric.clm_adjoint_eq {A : E →L[𝕜] E} (hA : A.IsSymmetric) :
A† = A := by
rwa [eq_comm, eq_adjoint_iff A A]
theorem adjoint_id : (ContinuousLinearMap.id 𝕜 E)† = ContinuousLinearMap.id 𝕜 E := by
simp
theorem _root_.Submodule.adjoint_subtypeL (U : Submodule 𝕜 E) [CompleteSpace U] :
U.subtypeL† = U.orthogonalProjection := by
symm
simp [eq_adjoint_iff]
theorem _root_.Submodule.adjoint_orthogonalProjection (U : Submodule 𝕜 E) [CompleteSpace U] :
(U.orthogonalProjection : E →L[𝕜] U)† = U.subtypeL := by
rw [← U.adjoint_subtypeL, adjoint_adjoint]
theorem orthogonal_ker (T : E →L[𝕜] F) :
(LinearMap.ker T)ᗮ = (LinearMap.range (T†)).topologicalClosure := by
rw [← Submodule.orthogonal_orthogonal_eq_closure]
apply le_antisymm
all_goals refine Submodule.orthogonal_le fun x hx ↦ ?_
· refine ext_inner_left 𝕜 fun y ↦ ?_
simp [← T.adjoint_inner_left, hx _ (LinearMap.mem_range_self (T†) y)]
· rintro _ ⟨y, rfl⟩
simp_all [T.adjoint_inner_left]
theorem orthogonal_range (T : E →L[𝕜] F) :
(LinearMap.range T)ᗮ = LinearMap.ker (T†) := by
rw [← (LinearMap.ker (T†)).orthogonal_orthogonal, (T†).orthogonal_ker]
simp
omit [CompleteSpace E] in
theorem ker_le_ker_iff_range_le_range [FiniteDimensional 𝕜 E] {T U : E →L[𝕜] E}
(hT : T.IsSymmetric) (hU : U.IsSymmetric) :
LinearMap.ker U ≤ LinearMap.ker T ↔ LinearMap.range T ≤ LinearMap.range U := by
refine ⟨fun h ↦ ?_, LinearMap.ker_le_ker_of_range hT hU⟩
have := FiniteDimensional.complete 𝕜 E
simpa [orthogonal_ker, hT, hU] using Submodule.orthogonal_le h
/-- `E →L[𝕜] E` is a star algebra with the adjoint as the star operation. -/
instance : Star (E →L[𝕜] E) :=
⟨adjoint⟩
instance : InvolutiveStar (E →L[𝕜] E) :=
⟨adjoint_adjoint⟩
instance : StarMul (E →L[𝕜] E) :=
⟨adjoint_comp⟩
instance : StarRing (E →L[𝕜] E) :=
⟨LinearIsometryEquiv.map_add adjoint⟩
instance : StarModule 𝕜 (E →L[𝕜] E) :=
⟨LinearIsometryEquiv.map_smulₛₗ adjoint⟩
theorem star_eq_adjoint (A : E →L[𝕜] E) : star A = A† :=
rfl
/-- A continuous linear operator is self-adjoint iff it is equal to its adjoint. -/
theorem isSelfAdjoint_iff' {A : E →L[𝕜] E} : IsSelfAdjoint A ↔ A† = A :=
Iff.rfl
theorem norm_adjoint_comp_self (A : E →L[𝕜] F) :
‖A† ∘L A‖ = ‖A‖ * ‖A‖ := by
refine le_antisymm ?_ ?_
· calc
‖A† ∘L A‖ ≤ ‖A†‖ * ‖A‖ := opNorm_comp_le _ _
_ = ‖A‖ * ‖A‖ := by rw [LinearIsometryEquiv.norm_map]
· rw [← sq, ← Real.sqrt_le_sqrt_iff (norm_nonneg _), Real.sqrt_sq (norm_nonneg _)]
refine opNorm_le_bound _ (Real.sqrt_nonneg _) fun x => ?_
have :=
calc
re ⟪(A† ∘L A) x, x⟫ ≤ ‖(A† ∘L A) x‖ * ‖x‖ := re_inner_le_norm _ _
_ ≤ ‖A† ∘L A‖ * ‖x‖ * ‖x‖ := mul_le_mul_of_nonneg_right (le_opNorm _ _) (norm_nonneg _)
calc
‖A x‖ = √(re ⟪(A† ∘L A) x, x⟫) := by rw [apply_norm_eq_sqrt_inner_adjoint_left]
_ ≤ √(‖A† ∘L A‖ * ‖x‖ * ‖x‖) := Real.sqrt_le_sqrt this
_ = √‖A† ∘L A‖ * ‖x‖ := by
simp_rw [mul_assoc, Real.sqrt_mul (norm_nonneg _) (‖x‖ * ‖x‖),
Real.sqrt_mul_self (norm_nonneg x)]
/-- The C⋆-algebra instance when `𝕜 := ℂ` can be found in
`Mathlib/Analysis/CStarAlgebra/ContinuousLinearMap.lean`. -/
instance : CStarRing (E →L[𝕜] E) where
norm_mul_self_le x := le_of_eq <| Eq.symm <| norm_adjoint_comp_self x
theorem isAdjointPair_inner (A : E →L[𝕜] F) :
LinearMap.IsAdjointPair (sesqFormOfInner : E →ₗ[𝕜] E →ₗ⋆[𝕜] 𝕜)
(sesqFormOfInner : F →ₗ[𝕜] F →ₗ⋆[𝕜] 𝕜) A (A†) := by
intro x y
simp only [sesqFormOfInner_apply_apply, adjoint_inner_left]
theorem adjoint_innerSL_apply (x : E) :
adjoint (innerSL 𝕜 x) = toSpanSingleton 𝕜 x :=
ext_ring <| ext_inner_left 𝕜 <| fun _ => by simp [adjoint_inner_right]
theorem adjoint_toSpanSingleton (x : E) :
adjoint (toSpanSingleton 𝕜 x) = innerSL 𝕜 x := by
simp [← adjoint_innerSL_apply]
theorem innerSL_apply_comp (x : F) (f : E →L[𝕜] F) :
innerSL 𝕜 x ∘L f = innerSL 𝕜 (adjoint f x) := by
ext; simp [adjoint_inner_left]
omit [CompleteSpace E] in
theorem innerSL_apply_comp_of_isSymmetric (x : E) {f : E →L[𝕜] E} (hf : f.IsSymmetric) :
innerSL 𝕜 x ∘L f = innerSL 𝕜 (f x) := by
ext; simp [hf]
end ContinuousLinearMap
/-! ### Self-adjoint operators -/
namespace IsSelfAdjoint
open ContinuousLinearMap
variable [CompleteSpace E] [CompleteSpace F]
theorem adjoint_eq {A : E →L[𝕜] E} (hA : IsSelfAdjoint A) : A.adjoint = A :=
hA
/-- Every self-adjoint operator on an inner product space is symmetric. -/
theorem isSymmetric {A : E →L[𝕜] E} (hA : IsSelfAdjoint A) : (A : E →ₗ[𝕜] E).IsSymmetric := by
intro x y
rw_mod_cast [← A.adjoint_inner_right, hA.adjoint_eq]
/-- Conjugating preserves self-adjointness. -/
theorem conj_adjoint {T : E →L[𝕜] E} (hT : IsSelfAdjoint T) (S : E →L[𝕜] F) :
IsSelfAdjoint (S ∘L T ∘L S.adjoint) := by
rw [isSelfAdjoint_iff'] at hT ⊢
simp only [hT, adjoint_comp, adjoint_adjoint]
exact ContinuousLinearMap.comp_assoc _ _ _
/-- Conjugating preserves self-adjointness. -/
theorem adjoint_conj {T : E →L[𝕜] E} (hT : IsSelfAdjoint T) (S : F →L[𝕜] E) :
IsSelfAdjoint (S.adjoint ∘L T ∘L S) := by
rw [isSelfAdjoint_iff'] at hT ⊢
simp only [hT, adjoint_comp, adjoint_adjoint]
exact ContinuousLinearMap.comp_assoc _ _ _
theorem _root_.ContinuousLinearMap.isSelfAdjoint_iff_isSymmetric {A : E →L[𝕜] E} :
IsSelfAdjoint A ↔ (A : E →ₗ[𝕜] E).IsSymmetric :=
⟨fun hA => hA.isSymmetric, fun hA =>
ext fun x => ext_inner_right 𝕜 fun y => (A.adjoint_inner_left y x).symm ▸ (hA x y).symm⟩
theorem _root_.LinearMap.IsSymmetric.isSelfAdjoint {A : E →L[𝕜] E}
(hA : (A : E →ₗ[𝕜] E).IsSymmetric) : IsSelfAdjoint A := by
rwa [← ContinuousLinearMap.isSelfAdjoint_iff_isSymmetric] at hA
/-- The orthogonal projection is self-adjoint. -/
@[simp]
theorem _root_.isSelfAdjoint_starProjection
(U : Submodule 𝕜 E) [U.HasOrthogonalProjection] :
IsSelfAdjoint U.starProjection :=
U.starProjection_isSymmetric.isSelfAdjoint
@[deprecated (since := "2025-07-05")] alias _root_.orthogonalProjection_isSelfAdjoint :=
isSelfAdjoint_starProjection
theorem conj_starProjection {T : E →L[𝕜] E} (hT : IsSelfAdjoint T)
(U : Submodule 𝕜 E) [U.HasOrthogonalProjection] :
IsSelfAdjoint (U.starProjection ∘L T ∘L U.starProjection) := by
rw [← mul_def, ← mul_def, ← mul_assoc]
exact hT.conjugate_self <| isSelfAdjoint_starProjection U
@[deprecated (since := "2025-07-05")] alias conj_orthogonalProjection := conj_starProjection
end IsSelfAdjoint
namespace ContinuousLinearMap
variable {T : E →L[𝕜] E} [CompleteSpace E]
/-- An operator `T` is normal iff `‖T v‖ = ‖(adjoint T) v‖` for all `v`. -/
theorem isStarNormal_iff_norm_eq_adjoint :
IsStarNormal T ↔ ∀ v : E, ‖T v‖ = ‖adjoint T v‖ := by
rw [isStarNormal_iff, Commute, SemiconjBy, ← sub_eq_zero]
simp_rw [ContinuousLinearMap.ext_iff, ← coe_coe, coe_sub, ← LinearMap.ext_iff, coe_zero]
have := star_eq_adjoint T ▸ coe_sub (star _ * T) _ ▸
((IsSelfAdjoint.star_mul_self T).sub (IsSelfAdjoint.mul_star_self T)).isSymmetric
simp_rw [star_eq_adjoint, ← LinearMap.IsSymmetric.inner_map_self_eq_zero this,
LinearMap.sub_apply, inner_sub_left, coe_coe, mul_apply, adjoint_inner_left,
inner_self_eq_norm_sq_to_K, ← adjoint_inner_right T, inner_self_eq_norm_sq_to_K,
sub_eq_zero, ← sq_eq_sq₀ (norm_nonneg _) (norm_nonneg _)]
norm_cast
lemma IsStarNormal.adjoint_apply_eq_zero_iff (hT : IsStarNormal T) (x : E) :
adjoint T x = 0 ↔ T x = 0 := by
simp_rw [← norm_eq_zero (E := E), ← isStarNormal_iff_norm_eq_adjoint.mp hT]
open ContinuousLinearMap
theorem IsStarNormal.ker_adjoint_eq_ker (hT : IsStarNormal T) :
LinearMap.ker (adjoint T) = LinearMap.ker T :=
Submodule.ext hT.adjoint_apply_eq_zero_iff
/-- The range of a normal operator is pairwise orthogonal to its kernel.
This is a weaker version of `LinearMap.IsSymmetric.orthogonal_range`
but with stronger type class assumptions (i.e., `CompleteSpace`). -/
theorem IsStarNormal.orthogonal_range (hT : IsStarNormal T) :
(LinearMap.range T)ᗮ = LinearMap.ker T :=
T.orthogonal_range ▸ hT.ker_adjoint_eq_ker
/- TODO: As we have a more general result of this for elements in non-unital C⋆-algebras
(see `Mathlib/Analysis/CStarAlgebra/Projection.lean`), we will want to simplify the proof
by using the complexification of an inner product space over `𝕜`. -/
/-- An idempotent operator is self-adjoint iff it is normal. -/
theorem IsIdempotentElem.isSelfAdjoint_iff_isStarNormal (hT : IsIdempotentElem T) :
IsSelfAdjoint T ↔ IsStarNormal T := by
refine ⟨fun h => by rw [isStarNormal_iff, h], fun h => ?_⟩
suffices T = star T * T from this ▸ IsSelfAdjoint.star_mul_self _
rw [← sub_eq_zero, ContinuousLinearMap.ext_iff]
simp_rw [zero_apply, ← norm_eq_zero (E := E)]
have :=
calc (∀ x : E, ‖(T - star T * T) x‖ = 0) ↔ ∀ x, ‖(adjoint (1 - T)) (T x)‖ = 0 := by
simp [coe_sub', coe_mul, Pi.sub_apply, Function.comp_apply, norm_eq_zero,
← star_eq_adjoint, star_sub, star_one, one_apply]
_ ↔ ∀ x, ‖(1 - T) (T x)‖ = 0 := by
simp only [isStarNormal_iff_norm_eq_adjoint.mp h.one_sub]
_ ↔ ∀ x, ‖(T - T * T) x‖ = 0 := by simp
_ ↔ T - T * T = 0 := by simp only [norm_eq_zero, ContinuousLinearMap.ext_iff, zero_apply]
_ ↔ IsIdempotentElem T := by simp only [sub_eq_zero, IsIdempotentElem, eq_comm]
exact this.mpr hT
/-- A continuous linear map is a star projection iff it is idempotent and normal. -/
theorem isStarProjection_iff_isIdempotentElem_and_isStarNormal :
IsStarProjection T ↔ IsIdempotentElem T ∧ IsStarNormal T := by
rw [isStarProjection_iff, and_congr_right_iff]
exact fun h => IsIdempotentElem.isSelfAdjoint_iff_isStarNormal h
theorem isStarProjection_iff_isSymmetricProjection :
IsStarProjection T ↔ T.IsSymmetricProjection := by
simp [isStarProjection_iff, LinearMap.isSymmetricProjection_iff,
isSelfAdjoint_iff_isSymmetric, IsIdempotentElem, End.mul_eq_comp, ← coe_comp, mul_def]
/-- Star projection operators are equal iff their range are. -/
theorem IsStarProjection.ext_iff {S : E →L[𝕜] E}
(hS : IsStarProjection S) (hT : IsStarProjection T) :
S = T ↔ LinearMap.range S = LinearMap.range T := by
simpa using LinearMap.IsSymmetricProjection.ext_iff
(isStarProjection_iff_isSymmetricProjection.mp hS)
(isStarProjection_iff_isSymmetricProjection.mp hT)
alias ⟨_, IsStarProjection.ext⟩ := IsStarProjection.ext_iff
end ContinuousLinearMap
/-- `U.starProjection` is a star projection. -/
@[simp]
theorem isStarProjection_starProjection [CompleteSpace E] {U : Submodule 𝕜 E}
[U.HasOrthogonalProjection] : IsStarProjection U.starProjection :=
⟨U.isIdempotentElem_starProjection, isSelfAdjoint_starProjection U⟩
open ContinuousLinearMap in
/-- An operator is a star projection if and only if it is an orthogonal projection. -/
theorem isStarProjection_iff_eq_starProjection_range [CompleteSpace E] {p : E →L[𝕜] E} :
IsStarProjection p ↔ ∃ (_ : (LinearMap.range p).HasOrthogonalProjection),
p = (LinearMap.range p).starProjection := by
simp_rw [← p.isStarProjection_iff_isSymmetricProjection.symm.eq,
LinearMap.isSymmetricProjection_iff_eq_coe_starProjection_range, coe_inj]
rfl
lemma isStarProjection_iff_eq_starProjection [CompleteSpace E] {p : E →L[𝕜] E} :
IsStarProjection p
↔ ∃ (K : Submodule 𝕜 E) (_ : K.HasOrthogonalProjection), p = K.starProjection :=
⟨fun h ↦ ⟨LinearMap.range p, isStarProjection_iff_eq_starProjection_range.mp h⟩,
by rintro ⟨_, _, rfl⟩; simp⟩
namespace LinearMap
variable [CompleteSpace E]
variable {T : E →ₗ[𝕜] E}
/-- The **Hellinger--Toeplitz theorem**: Construct a self-adjoint operator from an everywhere
defined symmetric operator. -/
def IsSymmetric.toSelfAdjoint (hT : IsSymmetric T) : selfAdjoint (E →L[𝕜] E) :=
⟨⟨T, hT.continuous⟩, ContinuousLinearMap.isSelfAdjoint_iff_isSymmetric.mpr hT⟩
theorem IsSymmetric.coe_toSelfAdjoint (hT : IsSymmetric T) : (hT.toSelfAdjoint : E →ₗ[𝕜] E) = T :=
rfl
theorem IsSymmetric.toSelfAdjoint_apply (hT : IsSymmetric T) {x : E} :
(hT.toSelfAdjoint : E → E) x = T x :=
rfl
end LinearMap
namespace LinearMap
variable [FiniteDimensional 𝕜 E] [FiniteDimensional 𝕜 F] [FiniteDimensional 𝕜 G]
/-- The adjoint of an operator from the finite-dimensional inner product space `E` to the
finite-dimensional inner product space `F`. -/
def adjoint : (E →ₗ[𝕜] F) ≃ₗ⋆[𝕜] F →ₗ[𝕜] E :=
haveI := FiniteDimensional.complete 𝕜 E
haveI := FiniteDimensional.complete 𝕜 F
/- Note: Instead of the two instances above, the following works:
```
haveI := FiniteDimensional.complete 𝕜
haveI := FiniteDimensional.complete 𝕜
```
But removing one of the `have`s makes it fail. The reason is that `E` and `F` don't live
in the same universe, so the first `have` can no longer be used for `F` after its universe
metavariable has been assigned to that of `E`!
-/
((LinearMap.toContinuousLinearMap : (E →ₗ[𝕜] F) ≃ₗ[𝕜] E →L[𝕜] F).trans
ContinuousLinearMap.adjoint.toLinearEquiv).trans
LinearMap.toContinuousLinearMap.symm
theorem adjoint_toContinuousLinearMap (A : E →ₗ[𝕜] F) :
haveI := FiniteDimensional.complete 𝕜 E
haveI := FiniteDimensional.complete 𝕜 F
A.adjoint.toContinuousLinearMap = A.toContinuousLinearMap.adjoint :=
rfl
theorem adjoint_eq_toCLM_adjoint (A : E →ₗ[𝕜] F) :
haveI := FiniteDimensional.complete 𝕜 E
haveI := FiniteDimensional.complete 𝕜 F
A.adjoint = A.toContinuousLinearMap.adjoint :=
rfl
/-- The fundamental property of the adjoint. -/
theorem adjoint_inner_left (A : E →ₗ[𝕜] F) (x : E) (y : F) : ⟪adjoint A y, x⟫ = ⟪y, A x⟫ := by
have := FiniteDimensional.complete 𝕜 E
have := FiniteDimensional.complete 𝕜 F
rw [← coe_toContinuousLinearMap A, adjoint_eq_toCLM_adjoint]
exact ContinuousLinearMap.adjoint_inner_left _ x y
/-- The fundamental property of the adjoint. -/
theorem adjoint_inner_right (A : E →ₗ[𝕜] F) (x : E) (y : F) : ⟪x, adjoint A y⟫ = ⟪A x, y⟫ := by
have := FiniteDimensional.complete 𝕜 E
have := FiniteDimensional.complete 𝕜 F
rw [← coe_toContinuousLinearMap A, adjoint_eq_toCLM_adjoint]
exact ContinuousLinearMap.adjoint_inner_right _ x y
/-- The adjoint is involutive. -/
@[simp]
theorem adjoint_adjoint (A : E →ₗ[𝕜] F) : A.adjoint.adjoint = A := by
ext v
refine ext_inner_left 𝕜 fun w => ?_
rw [adjoint_inner_right, adjoint_inner_left]
/-- The adjoint of the composition of two operators is the composition of the two adjoints
in reverse order. -/
@[simp]
theorem adjoint_comp (A : F →ₗ[𝕜] G) (B : E →ₗ[𝕜] F) :
(A ∘ₗ B).adjoint = B.adjoint ∘ₗ A.adjoint := by
ext v
refine ext_inner_left 𝕜 fun w => ?_
simp only [adjoint_inner_right, LinearMap.coe_comp, Function.comp_apply]
/-- The adjoint is unique: a map `A` is the adjoint of `B` iff it satisfies `⟪A x, y⟫ = ⟪x, B y⟫`
for all `x` and `y`. -/
theorem eq_adjoint_iff (A : E →ₗ[𝕜] F) (B : F →ₗ[𝕜] E) :
A = B.adjoint ↔ ∀ x y, ⟪A x, y⟫ = ⟪x, B y⟫ := by
refine ⟨fun h x y => by rw [h, adjoint_inner_left], fun h => ?_⟩
ext x
exact ext_inner_right 𝕜 fun y => by simp only [adjoint_inner_left, h x y]
@[simp]
theorem IsSymmetric.adjoint_eq {A : E →ₗ[𝕜] E} (hA : A.IsSymmetric) :
A.adjoint = A := by
rwa [eq_comm, eq_adjoint_iff A A]
theorem adjoint_id : (LinearMap.id (R := 𝕜) (M := E)).adjoint = LinearMap.id := by
simp
/-- The adjoint is unique: a map `A` is the adjoint of `B` iff it satisfies `⟪A x, y⟫ = ⟪x, B y⟫`
for all basis vectors `x` and `y`. -/
theorem eq_adjoint_iff_basis {ι₁ : Type*} {ι₂ : Type*} (b₁ : Basis ι₁ 𝕜 E) (b₂ : Basis ι₂ 𝕜 F)
(A : E →ₗ[𝕜] F) (B : F →ₗ[𝕜] E) :
A = B.adjoint ↔ ∀ (i₁ : ι₁) (i₂ : ι₂), ⟪A (b₁ i₁), b₂ i₂⟫ = ⟪b₁ i₁, B (b₂ i₂)⟫ := by
refine ⟨fun h x y => by rw [h, adjoint_inner_left], fun h => ?_⟩
refine Basis.ext b₁ fun i₁ => ?_
exact ext_inner_right_basis b₂ fun i₂ => by simp only [adjoint_inner_left, h i₁ i₂]
theorem eq_adjoint_iff_basis_left {ι : Type*} (b : Basis ι 𝕜 E) (A : E →ₗ[𝕜] F) (B : F →ₗ[𝕜] E) :
A = B.adjoint ↔ ∀ i y, ⟪A (b i), y⟫ = ⟪b i, B y⟫ := by
refine ⟨fun h x y => by rw [h, adjoint_inner_left], fun h => Basis.ext b fun i => ?_⟩
exact ext_inner_right 𝕜 fun y => by simp only [h i, adjoint_inner_left]
theorem eq_adjoint_iff_basis_right {ι : Type*} (b : Basis ι 𝕜 F) (A : E →ₗ[𝕜] F) (B : F →ₗ[𝕜] E) :
A = B.adjoint ↔ ∀ i x, ⟪A x, b i⟫ = ⟪x, B (b i)⟫ := by
refine ⟨fun h x y => by rw [h, adjoint_inner_left], fun h => ?_⟩
ext x
exact ext_inner_right_basis b fun i => by simp only [h i, adjoint_inner_left]
/-- `E →ₗ[𝕜] E` is a star algebra with the adjoint as the star operation. -/
instance : Star (E →ₗ[𝕜] E) :=
⟨adjoint⟩
instance : InvolutiveStar (E →ₗ[𝕜] E) :=
⟨adjoint_adjoint⟩
instance : StarMul (E →ₗ[𝕜] E) :=
⟨adjoint_comp⟩
instance : StarRing (E →ₗ[𝕜] E) :=
⟨LinearEquiv.map_add adjoint⟩
instance : StarModule 𝕜 (E →ₗ[𝕜] E) :=
⟨LinearEquiv.map_smulₛₗ adjoint⟩
theorem star_eq_adjoint (A : E →ₗ[𝕜] E) : star A = A.adjoint :=
rfl
/-- A continuous linear operator is self-adjoint iff it is equal to its adjoint. -/
theorem isSelfAdjoint_iff' {A : E →ₗ[𝕜] E} : IsSelfAdjoint A ↔ A.adjoint = A :=
Iff.rfl
theorem isSymmetric_iff_isSelfAdjoint (A : E →ₗ[𝕜] E) : IsSymmetric A ↔ IsSelfAdjoint A := by
rw [isSelfAdjoint_iff', IsSymmetric, ← LinearMap.eq_adjoint_iff]
exact eq_comm
theorem isAdjointPair_inner (A : E →ₗ[𝕜] F) :
IsAdjointPair (sesqFormOfInner : E →ₗ[𝕜] E →ₗ⋆[𝕜] 𝕜) (sesqFormOfInner : F →ₗ[𝕜] F →ₗ⋆[𝕜] 𝕜) A
A.adjoint := by
intro x y
simp only [sesqFormOfInner_apply_apply, adjoint_inner_left]
/-- The Gram operator T†T is symmetric. -/
theorem isSymmetric_adjoint_mul_self (T : E →ₗ[𝕜] E) : IsSymmetric (T.adjoint * T) := by
intro x y
simp [adjoint_inner_left, adjoint_inner_right]
/-- The Gram operator T†T is a positive operator. -/
theorem re_inner_adjoint_mul_self_nonneg (T : E →ₗ[𝕜] E) (x : E) :
0 ≤ re ⟪x, (T.adjoint * T) x⟫ := by
simp only [Module.End.mul_apply, adjoint_inner_right, inner_self_eq_norm_sq_to_K]
norm_cast
exact sq_nonneg _
@[simp]
theorem im_inner_adjoint_mul_self_eq_zero (T : E →ₗ[𝕜] E) (x : E) :
im ⟪x, T.adjoint (T x)⟫ = 0 := by
simp only [adjoint_inner_right, inner_self_eq_norm_sq_to_K]
norm_cast
theorem isSelfAdjoint_toContinuousLinearMap_iff (T : E →ₗ[𝕜] E) :
have := FiniteDimensional.complete 𝕜 E
IsSelfAdjoint T.toContinuousLinearMap ↔ IsSelfAdjoint T := by
simp [IsSelfAdjoint, star, adjoint,
ContinuousLinearMap.toLinearMap_eq_iff_eq_toContinuousLinearMap]
theorem _root_.ContinuousLinearMap.isSelfAdjoint_toLinearMap_iff (T : E →L[𝕜] E) :
have := FiniteDimensional.complete 𝕜 E
IsSelfAdjoint T.toLinearMap ↔ IsSelfAdjoint T := by
simp only [IsSelfAdjoint, star, adjoint, LinearEquiv.trans_apply,
coe_toContinuousLinearMap_symm,
ContinuousLinearMap.toLinearMap_eq_iff_eq_toContinuousLinearMap]
rfl
theorem isStarProjection_toContinuousLinearMap_iff {T : E →ₗ[𝕜] E} :
have := FiniteDimensional.complete 𝕜 E
IsStarProjection (toContinuousLinearMap T) ↔ IsStarProjection T := by
simp [isStarProjection_iff, isSelfAdjoint_toContinuousLinearMap_iff,
← ContinuousLinearMap.isIdempotentElem_toLinearMap_iff]
theorem isStarProjection_iff_isSymmetricProjection {T : E →ₗ[𝕜] E} :
IsStarProjection T ↔ T.IsSymmetricProjection := by
simp [← isStarProjection_toContinuousLinearMap_iff,
ContinuousLinearMap.isStarProjection_iff_isSymmetricProjection]
open LinearMap in
/-- Star projection operators are equal iff their range are. -/
theorem IsStarProjection.ext_iff {S T : E →ₗ[𝕜] E}
(hS : IsStarProjection S) (hT : IsStarProjection T) :
S = T ↔ LinearMap.range S = LinearMap.range T := by
have := FiniteDimensional.complete 𝕜 E
simpa using ContinuousLinearMap.IsStarProjection.ext_iff
(S.isStarProjection_toContinuousLinearMap_iff.mpr hS)
(T.isStarProjection_toContinuousLinearMap_iff.mpr hT)
alias ⟨_, IsStarProjection.ext⟩ := IsStarProjection.ext_iff
end LinearMap
section Unitary
variable {H : Type*} [NormedAddCommGroup H] [InnerProductSpace 𝕜 H] [CompleteSpace H]
namespace ContinuousLinearMap
variable {K : Type*} [NormedAddCommGroup K] [InnerProductSpace 𝕜 K] [CompleteSpace K]
theorem inner_map_map_iff_adjoint_comp_self (u : H →L[𝕜] K) :
(∀ x y : H, ⟪u x, u y⟫_𝕜 = ⟪x, y⟫_𝕜) ↔ adjoint u ∘L u = 1 := by
refine ⟨fun h ↦ ext fun x ↦ ?_, fun h ↦ ?_⟩
· refine ext_inner_right 𝕜 fun y ↦ ?_
simpa [star_eq_adjoint, adjoint_inner_left] using h x y
· simp [← adjoint_inner_left, ← comp_apply, h]
theorem norm_map_iff_adjoint_comp_self (u : H →L[𝕜] K) :
(∀ x : H, ‖u x‖ = ‖x‖) ↔ adjoint u ∘L u = 1 := by
rw [LinearMap.norm_map_iff_inner_map_map u, u.inner_map_map_iff_adjoint_comp_self]
@[simp]
lemma _root_.LinearIsometryEquiv.adjoint_eq_symm (e : H ≃ₗᵢ[𝕜] K) :
adjoint (e : H →L[𝕜] K) = e.symm :=
let e' := (e : H →L[𝕜] K)
calc
adjoint e' = adjoint e' ∘L (e' ∘L e.symm) := by
convert (adjoint e').comp_id.symm
ext
simp [e']
_ = e.symm := by
rw [← comp_assoc, norm_map_iff_adjoint_comp_self e' |>.mp e.norm_map]
exact (e.symm : K →L[𝕜] H).id_comp
@[simp]
lemma _root_.LinearIsometryEquiv.star_eq_symm (e : H ≃ₗᵢ[𝕜] H) :
star (e : H →L[𝕜] H) = e.symm :=
e.adjoint_eq_symm
theorem norm_map_of_mem_unitary {u : H →L[𝕜] H} (hu : u ∈ unitary (H →L[𝕜] H)) (x : H) :
‖u x‖ = ‖x‖ :=
-- Elaborates faster with this broken out https://github.com/leanprover-community/mathlib4/issues/11299
have := Unitary.star_mul_self_of_mem hu
u.norm_map_iff_adjoint_comp_self.mpr this x
theorem inner_map_map_of_mem_unitary {u : H →L[𝕜] H} (hu : u ∈ unitary (H →L[𝕜] H)) (x y : H) :
⟪u x, u y⟫_𝕜 = ⟪x, y⟫_𝕜 :=
-- Elaborates faster with this broken out https://github.com/leanprover-community/mathlib4/issues/11299
have := Unitary.star_mul_self_of_mem hu
u.inner_map_map_iff_adjoint_comp_self.mpr this x y
end ContinuousLinearMap
namespace Unitary
theorem norm_map (u : unitary (H →L[𝕜] H)) (x : H) : ‖(u : H →L[𝕜] H) x‖ = ‖x‖ :=
u.val.norm_map_of_mem_unitary u.property x
theorem inner_map_map (u : unitary (H →L[𝕜] H)) (x y : H) :
⟪(u : H →L[𝕜] H) x, (u : H →L[𝕜] H) y⟫_𝕜 = ⟪x, y⟫_𝕜 :=
u.val.inner_map_map_of_mem_unitary u.property x y
/-- The unitary elements of continuous linear maps on a Hilbert space coincide with the linear
isometric equivalences on that Hilbert space. -/
noncomputable def linearIsometryEquiv : unitary (H →L[𝕜] H) ≃* (H ≃ₗᵢ[𝕜] H) where
toFun u :=
{ (u : H →L[𝕜] H) with
norm_map' := norm_map u
invFun := ↑(star u)
left_inv := fun x ↦ congr($(star_mul_self u).val x)
right_inv := fun x ↦ congr($(mul_star_self u).val x) }
invFun e :=
{ val := e
property := by
let e' : (H →L[𝕜] H)ˣ :=
{ val := (e : H →L[𝕜] H)
inv := (e.symm : H →L[𝕜] H)
val_inv := by ext; simp
inv_val := by ext; simp }
exact IsUnit.mem_unitary_of_star_mul_self ⟨e', rfl⟩ <|
(e : H →L[𝕜] H).norm_map_iff_adjoint_comp_self.mp e.norm_map }
map_mul' u v := by ext; rfl
@[simp]
lemma linearIsometryEquiv_coe_apply (u : unitary (H →L[𝕜] H)) :
linearIsometryEquiv u = (u : H →L[𝕜] H) :=
rfl
@[simp]
lemma linearIsometryEquiv_coe_symm_apply (e : H ≃ₗᵢ[𝕜] H) :
linearIsometryEquiv.symm e = (e : H →L[𝕜] H) :=
rfl
end Unitary
namespace unitary
@[deprecated (since := "2025-10-29")] alias norm_map := Unitary.norm_map
@[deprecated (since := "2025-10-29")] alias inner_map_map := Unitary.inner_map_map
@[deprecated (since := "2025-10-29")] alias linearIsometryEquiv := Unitary.linearIsometryEquiv
@[deprecated (since := "2025-10-29")] alias linearIsometryEquiv_coe_apply :=
Unitary.linearIsometryEquiv_coe_apply
@[deprecated (since := "2025-10-29")] alias linearIsometryEquiv_coe_symm_apply :=
Unitary.linearIsometryEquiv_coe_symm_apply
end unitary
end Unitary
section Matrix
open Matrix LinearMap
variable {m n : Type*} [Fintype m] [DecidableEq m] [Fintype n] [DecidableEq n]
variable [FiniteDimensional 𝕜 E] [FiniteDimensional 𝕜 F]
variable (v₁ : OrthonormalBasis n 𝕜 E) (v₂ : OrthonormalBasis m 𝕜 F)
/-- The linear map associated to the conjugate transpose of a matrix corresponding to two
orthonormal bases is the adjoint of the linear map associated to the matrix. -/
lemma Matrix.toLin_conjTranspose (A : Matrix m n 𝕜) :
toLin v₂.toBasis v₁.toBasis Aᴴ = adjoint (toLin v₁.toBasis v₂.toBasis A) := by
refine eq_adjoint_iff_basis v₂.toBasis v₁.toBasis _ _ |>.mpr fun i j ↦ ?_
simp_rw [toLin_self]
simp [sum_inner, inner_smul_left, inner_sum, inner_smul_right,
orthonormal_iff_ite.mp v₁.orthonormal, orthonormal_iff_ite.mp v₂.orthonormal]
/-- The matrix associated to the adjoint of a linear map corresponding to two orthonormal bases
is the conjugate transpose of the matrix associated to the linear map. -/
lemma LinearMap.toMatrix_adjoint (f : E →ₗ[𝕜] F) :
toMatrix v₂.toBasis v₁.toBasis (adjoint f) = (toMatrix v₁.toBasis v₂.toBasis f)ᴴ :=
toLin v₂.toBasis v₁.toBasis |>.injective <| by simp [toLin_conjTranspose]
/-- The star algebra equivalence between the linear endomorphisms of finite-dimensional inner
product space and square matrices induced by the choice of an orthonormal basis. -/
@[simps]
def LinearMap.toMatrixOrthonormal : (E →ₗ[𝕜] E) ≃⋆ₐ[𝕜] Matrix n n 𝕜 :=
{ LinearMap.toMatrix v₁.toBasis v₁.toBasis with
map_mul' := LinearMap.toMatrix_mul v₁.toBasis
map_star' := LinearMap.toMatrix_adjoint v₁ v₁ }
lemma LinearMap.toMatrixOrthonormal_apply_apply (f : E →ₗ[𝕜] E) (i j : n) :
toMatrixOrthonormal v₁ f i j = ⟪v₁ i, f (v₁ j)⟫_𝕜 :=
calc
_ = v₁.repr (f (v₁ j)) i := f.toMatrix_apply ..
_ = ⟪v₁ i, f (v₁ j)⟫_𝕜 := v₁.repr_apply_apply ..
lemma LinearMap.toMatrixOrthonormal_reindex (e : n ≃ m) (f : E →ₗ[𝕜] E) :
toMatrixOrthonormal (v₁.reindex e) f = (toMatrixOrthonormal v₁ f).reindex e e :=
Matrix.ext fun i j =>
calc toMatrixOrthonormal (v₁.reindex e) f i j
_ = (v₁.reindex e).repr (f (v₁.reindex e j)) i := f.toMatrix_apply ..
_ = v₁.repr (f (v₁ (e.symm j))) (e.symm i) := by simp
_ = toMatrixOrthonormal v₁ f (e.symm i) (e.symm j) := Eq.symm (f.toMatrix_apply ..)
open scoped ComplexConjugate
/-- The adjoint of the linear map associated to a matrix is the linear map associated to the
conjugate transpose of that matrix. -/
theorem Matrix.toEuclideanLin_conjTranspose_eq_adjoint (A : Matrix m n 𝕜) :
A.conjTranspose.toEuclideanLin = A.toEuclideanLin.adjoint :=
A.toLin_conjTranspose (EuclideanSpace.basisFun n 𝕜) (EuclideanSpace.basisFun m 𝕜)
end Matrix |
.lake/packages/mathlib/Mathlib/Analysis/InnerProductSpace/LinearMap.lean | import Mathlib.Analysis.InnerProductSpace.Continuous
/-!
# Linear maps on inner product spaces
This file studies linear maps on inner product spaces.
## Main results
- We define `innerSL` as the inner product bundled as a continuous sesquilinear map, and
`innerₛₗ` for the non-continuous version.
- We prove a general polarization identity for linear maps (`inner_map_polarization`)
- We show that a linear map preserving the inner product is an isometry
(`LinearMap.isometryOfInner`) and conversely an isometry preserves the inner product
(`LinearIsometry.inner_map_map`).
## Tags
inner product space, Hilbert space, norm
-/
noncomputable section
open RCLike Real Filter Topology ComplexConjugate Finsupp
open LinearMap (BilinForm)
variable {𝕜 E F : Type*} [RCLike 𝕜]
section Norm_Seminormed
open scoped InnerProductSpace
variable [SeminormedAddCommGroup E] [InnerProductSpace 𝕜 E]
variable [SeminormedAddCommGroup F] [InnerProductSpace ℝ F]
local notation "⟪" x ", " y "⟫" => inner 𝕜 x y
section Complex_Seminormed
variable {V : Type*} [SeminormedAddCommGroup V] [InnerProductSpace ℂ V]
/-- A complex polarization identity, with a linear map. -/
theorem inner_map_polarization (T : V →ₗ[ℂ] V) (x y : V) :
⟪T y, x⟫_ℂ =
(⟪T (x + y), x + y⟫_ℂ - ⟪T (x - y), x - y⟫_ℂ +
Complex.I * ⟪T (x + Complex.I • y), x + Complex.I • y⟫_ℂ -
Complex.I * ⟪T (x - Complex.I • y), x - Complex.I • y⟫_ℂ) /
4 := by
simp only [map_add, map_sub, inner_add_left, inner_add_right, LinearMap.map_smul, inner_smul_left,
inner_smul_right, Complex.conj_I, ← pow_two, Complex.I_sq, inner_sub_left, inner_sub_right,
mul_add, ← mul_assoc, mul_neg, neg_neg, one_mul, neg_one_mul, mul_sub, sub_sub]
ring
theorem inner_map_polarization' (T : V →ₗ[ℂ] V) (x y : V) :
⟪T x, y⟫_ℂ =
(⟪T (x + y), x + y⟫_ℂ - ⟪T (x - y), x - y⟫_ℂ -
Complex.I * ⟪T (x + Complex.I • y), x + Complex.I • y⟫_ℂ +
Complex.I * ⟪T (x - Complex.I • y), x - Complex.I • y⟫_ℂ) /
4 := by
simp only [map_add, map_sub, inner_add_left, inner_add_right, LinearMap.map_smul, inner_smul_left,
inner_smul_right, Complex.conj_I, ← pow_two, Complex.I_sq, inner_sub_left, inner_sub_right,
mul_add, ← mul_assoc, mul_neg, neg_neg, one_mul, neg_one_mul, mul_sub, sub_sub]
ring
end Complex_Seminormed
section Complex
variable {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℂ V]
/-- A linear map `T` is zero, if and only if the identity `⟪T x, x⟫_ℂ = 0` holds for all `x`.
-/
theorem inner_map_self_eq_zero (T : V →ₗ[ℂ] V) : (∀ x : V, ⟪T x, x⟫_ℂ = 0) ↔ T = 0 := by
constructor
· intro hT
ext x
rw [LinearMap.zero_apply, ← @inner_self_eq_zero ℂ V, inner_map_polarization]
simp only [hT]
simp
· rintro rfl x
simp only [LinearMap.zero_apply, inner_zero_left]
/--
Two linear maps `S` and `T` are equal, if and only if the identity `⟪S x, x⟫_ℂ = ⟪T x, x⟫_ℂ` holds
for all `x`.
-/
theorem ext_inner_map (S T : V →ₗ[ℂ] V) : (∀ x : V, ⟪S x, x⟫_ℂ = ⟪T x, x⟫_ℂ) ↔ S = T := by
rw [← sub_eq_zero, ← inner_map_self_eq_zero]
refine forall_congr' fun x => ?_
rw [LinearMap.sub_apply, inner_sub_left, sub_eq_zero]
end Complex
section
variable {ι : Type*} {ι' : Type*} {ι'' : Type*}
variable {E' : Type*} [SeminormedAddCommGroup E'] [InnerProductSpace 𝕜 E']
variable {E'' : Type*} [SeminormedAddCommGroup E''] [InnerProductSpace 𝕜 E'']
/-- A linear isometry preserves the inner product. -/
@[simp]
theorem LinearIsometry.inner_map_map (f : E →ₗᵢ[𝕜] E') (x y : E) : ⟪f x, f y⟫ = ⟪x, y⟫ := by
simp [inner_eq_sum_norm_sq_div_four, ← f.norm_map]
/-- A linear isometric equivalence preserves the inner product. -/
@[simp]
theorem LinearIsometryEquiv.inner_map_map (f : E ≃ₗᵢ[𝕜] E') (x y : E) : ⟪f x, f y⟫ = ⟪x, y⟫ :=
f.toLinearIsometry.inner_map_map x y
/-- The adjoint of a linear isometric equivalence is its inverse. -/
theorem LinearIsometryEquiv.inner_map_eq_flip (f : E ≃ₗᵢ[𝕜] E') (x : E) (y : E') :
⟪f x, y⟫_𝕜 = ⟪x, f.symm y⟫_𝕜 := by
conv_lhs => rw [← f.apply_symm_apply y, f.inner_map_map]
/-- A linear map that preserves the inner product is a linear isometry. -/
def LinearMap.isometryOfInner (f : E →ₗ[𝕜] E') (h : ∀ x y, ⟪f x, f y⟫ = ⟪x, y⟫) : E →ₗᵢ[𝕜] E' :=
⟨f, fun x => by simp only [@norm_eq_sqrt_re_inner 𝕜, h]⟩
@[simp]
theorem LinearMap.coe_isometryOfInner (f : E →ₗ[𝕜] E') (h) : ⇑(f.isometryOfInner h) = f :=
rfl
@[simp]
theorem LinearMap.isometryOfInner_toLinearMap (f : E →ₗ[𝕜] E') (h) :
(f.isometryOfInner h).toLinearMap = f :=
rfl
/-- A linear equivalence that preserves the inner product is a linear isometric equivalence. -/
def LinearEquiv.isometryOfInner (f : E ≃ₗ[𝕜] E') (h : ∀ x y, ⟪f x, f y⟫ = ⟪x, y⟫) : E ≃ₗᵢ[𝕜] E' :=
⟨f, ((f : E →ₗ[𝕜] E').isometryOfInner h).norm_map⟩
@[simp]
theorem LinearEquiv.coe_isometryOfInner (f : E ≃ₗ[𝕜] E') (h) : ⇑(f.isometryOfInner h) = f :=
rfl
@[simp]
theorem LinearEquiv.isometryOfInner_toLinearEquiv (f : E ≃ₗ[𝕜] E') (h) :
(f.isometryOfInner h).toLinearEquiv = f :=
rfl
/-- A linear map is an isometry if and it preserves the inner product. -/
theorem LinearMap.norm_map_iff_inner_map_map {F : Type*} [FunLike F E E'] [LinearMapClass F 𝕜 E E']
(f : F) : (∀ x, ‖f x‖ = ‖x‖) ↔ (∀ x y, ⟪f x, f y⟫_𝕜 = ⟪x, y⟫_𝕜) :=
⟨({ toLinearMap := LinearMapClass.linearMap f, norm_map' := · : E →ₗᵢ[𝕜] E' }.inner_map_map),
(LinearMapClass.linearMap f |>.isometryOfInner · |>.norm_map)⟩
end
variable (𝕜)
/-- The inner product as a sesquilinear map. -/
def innerₛₗ : E →ₗ⋆[𝕜] E →ₗ[𝕜] 𝕜 :=
LinearMap.mk₂'ₛₗ _ _ (fun v w => ⟪v, w⟫) inner_add_left (fun _ _ _ => inner_smul_left _ _ _)
inner_add_right fun _ _ _ => inner_smul_right _ _ _
@[simp]
theorem coe_innerₛₗ_apply (v : E) : ⇑(innerₛₗ 𝕜 v) = fun w => ⟪v, w⟫ :=
rfl
@[simp]
theorem innerₛₗ_apply_apply (v w : E) : innerₛₗ 𝕜 v w = ⟪v, w⟫ :=
rfl
variable (F)
/-- The inner product as a bilinear map in the real case. -/
def innerₗ : F →ₗ[ℝ] F →ₗ[ℝ] ℝ := innerₛₗ ℝ
@[simp] lemma flip_innerₗ : (innerₗ F).flip = innerₗ F := by
ext v w
exact real_inner_comm v w
variable {F}
@[simp] lemma innerₗ_apply_apply (v w : F) : innerₗ F v w = ⟪v, w⟫_ℝ := rfl
/-- The inner product as a continuous sesquilinear map. Note that `toDualMap` (resp. `toDual`)
in `InnerProductSpace.Dual` is a version of this given as a linear isometry (resp. linear
isometric equivalence). -/
def innerSL : E →L⋆[𝕜] E →L[𝕜] 𝕜 :=
LinearMap.mkContinuous₂ (innerₛₗ 𝕜) 1 fun x y => by
simp only [norm_inner_le_norm, one_mul, innerₛₗ_apply_apply]
@[simp]
theorem coe_innerSL_apply (v : E) : ⇑(innerSL 𝕜 v) = fun w => ⟪v, w⟫ :=
rfl
@[simp]
theorem innerSL_apply_apply (v w : E) : innerSL 𝕜 v w = ⟪v, w⟫ :=
rfl
/-- The inner product as a continuous sesquilinear map, with the two arguments flipped. -/
def innerSLFlip : E →L[𝕜] E →L⋆[𝕜] 𝕜 :=
@ContinuousLinearMap.flipₗᵢ' 𝕜 𝕜 𝕜 E E 𝕜 _ _ _ _ _ _ _ _ _ (RingHom.id 𝕜) (starRingEnd 𝕜) _ _
(innerSL 𝕜)
@[simp]
theorem innerSLFlip_apply_apply (x y : E) : innerSLFlip 𝕜 x y = ⟪y, x⟫ :=
rfl
variable (F) in
@[simp] lemma flip_innerSL_real : (innerSL ℝ (E := F)).flip = innerSL ℝ (E := F) := by
ext v w
exact real_inner_comm _ _
@[deprecated (since := "2025-11-15")] alias innerₛₗ_apply_coe := coe_innerₛₗ_apply
@[deprecated (since := "2025-11-15")] alias innerₛₗ_apply := innerₛₗ_apply_apply
@[deprecated (since := "2025-11-15")] alias innerₗ_apply := innerₗ_apply_apply
@[deprecated (since := "2025-11-15")] alias innerSL_apply_coe := coe_innerSL_apply
@[deprecated (since := "2025-11-15")] alias innerSL_apply := innerSL_apply_apply
@[deprecated (since := "2025-11-15")] alias innerSLFlip_apply := innerSLFlip_apply_apply
@[deprecated (since := "2025-11-15")] alias innerSL_real_flip := flip_innerSL_real
variable {𝕜}
namespace ContinuousLinearMap
variable {E' : Type*} [SeminormedAddCommGroup E'] [InnerProductSpace 𝕜 E']
-- Note: odd and expensive build behavior is explicitly turned off using `noncomputable`
/-- Given `f : E →L[𝕜] E'`, construct the continuous sesquilinear form `fun x y ↦ ⟪x, A y⟫`, given
as a continuous linear map. -/
noncomputable def toSesqForm : (E →L[𝕜] E') →L[𝕜] E' →L⋆[𝕜] E →L[𝕜] 𝕜 :=
(ContinuousLinearMap.flipₗᵢ' E E' 𝕜 (starRingEnd 𝕜) (RingHom.id 𝕜)).toContinuousLinearEquiv ∘L
ContinuousLinearMap.compSL E E' (E' →L⋆[𝕜] 𝕜) (RingHom.id 𝕜) (RingHom.id 𝕜) (innerSLFlip 𝕜)
@[simp]
theorem toSesqForm_apply_coe (f : E →L[𝕜] E') (x : E') : toSesqForm f x = (innerSL 𝕜 x).comp f :=
rfl
theorem toSesqForm_apply_norm_le {f : E →L[𝕜] E'} {v : E'} : ‖toSesqForm f v‖ ≤ ‖f‖ * ‖v‖ := by
refine opNorm_le_bound _ (by positivity) fun x ↦ ?_
have h₁ : ‖f x‖ ≤ ‖f‖ * ‖x‖ := le_opNorm _ _
have h₂ := @norm_inner_le_norm 𝕜 E' _ _ _ v (f x)
calc
‖⟪v, f x⟫‖ ≤ ‖v‖ * ‖f x‖ := h₂
_ ≤ ‖v‖ * (‖f‖ * ‖x‖) := mul_le_mul_of_nonneg_left h₁ (norm_nonneg v)
_ = ‖f‖ * ‖v‖ * ‖x‖ := by ring
end ContinuousLinearMap
variable (𝕜)
/-- `innerSL` is an isometry. Note that the associated `LinearIsometry` is defined in
`InnerProductSpace.Dual` as `toDualMap`. -/
@[simp]
theorem innerSL_apply_norm (x : E) : ‖innerSL 𝕜 x‖ = ‖x‖ := by
refine
le_antisymm ((innerSL 𝕜 x).opNorm_le_bound (norm_nonneg _) fun y => norm_inner_le_norm _ _) ?_
rcases (norm_nonneg x).eq_or_lt' with (h | h)
· simp [h]
· refine (mul_le_mul_iff_left₀ h).mp ?_
calc
‖x‖ * ‖x‖ = ‖(⟪x, x⟫ : 𝕜)‖ := by
rw [← sq, inner_self_eq_norm_sq_to_K, norm_pow, norm_ofReal, abs_norm]
_ ≤ ‖innerSL 𝕜 x‖ * ‖x‖ := (innerSL 𝕜 x).le_opNorm _
lemma norm_innerSL_le : ‖innerSL 𝕜 (E := E)‖ ≤ 1 :=
ContinuousLinearMap.opNorm_le_bound _ zero_le_one (by simp)
end Norm_Seminormed
section RCLikeToReal
open scoped InnerProductSpace
variable {G : Type*}
/-- The inner product on an inner product space of dimension 2 can be evaluated in terms
of a complex-number representation of the space. -/
theorem inner_map_complex [SeminormedAddCommGroup G] [InnerProductSpace ℝ G] (f : G ≃ₗᵢ[ℝ] ℂ)
(x y : G) : ⟪x, y⟫_ℝ = (f y * conj (f x)).re := by rw [← Complex.inner, f.inner_map_map]
end RCLikeToReal
section ReApplyInnerSelf
variable [SeminormedAddCommGroup E] [InnerProductSpace 𝕜 E]
local notation "⟪" x ", " y "⟫" => inner 𝕜 x y
/-- Extract a real bilinear form from an operator `T`,
by taking the pairing `fun x ↦ re ⟪T x, x⟫`. -/
def ContinuousLinearMap.reApplyInnerSelf (T : E →L[𝕜] E) (x : E) : ℝ :=
re ⟪T x, x⟫
theorem ContinuousLinearMap.reApplyInnerSelf_apply (T : E →L[𝕜] E) (x : E) :
T.reApplyInnerSelf x = re ⟪T x, x⟫ :=
rfl
end ReApplyInnerSelf
section ReApplyInnerSelf_Seminormed
variable [SeminormedAddCommGroup E] [InnerProductSpace 𝕜 E]
local notation "⟪" x ", " y "⟫" => inner 𝕜 x y
theorem ContinuousLinearMap.reApplyInnerSelf_continuous (T : E →L[𝕜] E) :
Continuous T.reApplyInnerSelf :=
reCLM.continuous.comp <| T.continuous.inner continuous_id
theorem ContinuousLinearMap.reApplyInnerSelf_smul (T : E →L[𝕜] E) (x : E) {c : 𝕜} :
T.reApplyInnerSelf (c • x) = ‖c‖ ^ 2 * T.reApplyInnerSelf x := by
simp only [ContinuousLinearMap.map_smul, ContinuousLinearMap.reApplyInnerSelf_apply,
inner_smul_left, inner_smul_right, ← mul_assoc, mul_conj, ← ofReal_pow, ← smul_re,
Algebra.smul_def (‖c‖ ^ 2) ⟪T x, x⟫, algebraMap_eq_ofReal]
end ReApplyInnerSelf_Seminormed |
.lake/packages/mathlib/Mathlib/Analysis/InnerProductSpace/GramMatrix.lean | import Mathlib.LinearAlgebra.Matrix.PosDef
/-! # Gram Matrices
This file defines Gram matrices and proves their positive semidefiniteness.
Results require `RCLike 𝕜`.
## Main definition
* `Matrix.gram` : the `Matrix n n 𝕜` with `⟪v i, v j⟫` at `i j : n`, where `v : n → E` for an
`Inner 𝕜 E`.
## Main results
* `Matrix.posSemidef_gram`: Gram matrices are positive semidefinite.
* `Matrix.posDef_gram_iff_linearIndependent`: Linear independence of `v` is
equivalent to positive definiteness of `gram 𝕜 v`.
-/
open RCLike Real Matrix
open scoped InnerProductSpace ComplexOrder ComplexConjugate
variable {E n α 𝕜 : Type*}
namespace Matrix
/-- The entries of a Gram matrix are inner products of vectors in an inner product space. -/
def gram (𝕜 : Type*) [Inner 𝕜 E] (v : n → E) : Matrix n n 𝕜 := of fun i j ↦ ⟪v i, v j⟫_𝕜
@[simp]
lemma gram_apply [Inner 𝕜 E] (v : n → E) (i j : n) :
(gram 𝕜 v) i j = ⟪v i, v j⟫_𝕜 := rfl
variable [RCLike 𝕜]
section SemiInnerProductSpace
variable [SeminormedAddCommGroup E] [InnerProductSpace 𝕜 E]
@[simp]
lemma gram_zero : gram 𝕜 (0 : n → E) = 0 := Matrix.ext fun _ _ ↦ inner_zero_left _
@[simp]
lemma gram_single [DecidableEq n] (i : n) (x : E) :
gram 𝕜 (Pi.single i x) = Matrix.single i i ⟪x, x⟫_𝕜 := by
ext j k
obtain hij | rfl := ne_or_eq i j
· simp [hij]
obtain hik | rfl := ne_or_eq i k
· simp [hik]
simp
lemma submatrix_gram (v : n → E) {m : Set n} (f : m → n) :
(gram 𝕜 v).submatrix f f = gram 𝕜 (v ∘ f) := rfl
variable (𝕜) in
/-- A Gram matrix is Hermitian. -/
lemma isHermitian_gram (v : n → E) : (gram 𝕜 v).IsHermitian :=
Matrix.ext fun _ _ ↦ inner_conj_symm _ _
variable [Fintype n]
theorem star_dotProduct_gram_mulVec (v : n → E) (x y : n → 𝕜) :
star x ⬝ᵥ (gram 𝕜 v) *ᵥ y = ⟪∑ i, x i • v i, ∑ i, y i • v i⟫_𝕜 := by
trans ∑ i, ∑ j, conj (x i) * y j * ⟪v i, v j⟫_𝕜
· simp_rw [dotProduct, mul_assoc, ← Finset.mul_sum, mulVec, dotProduct, mul_comm, ← star_def,
gram_apply, Pi.star_apply]
· simp_rw [sum_inner, inner_sum, inner_smul_left, inner_smul_right, mul_assoc]
variable (𝕜) in
/-- A Gram matrix is positive semidefinite. -/
theorem posSemidef_gram (v : n → E) :
PosSemidef (gram 𝕜 v) := by
refine ⟨isHermitian_gram _ _, fun x ↦ ?_⟩
rw [star_dotProduct_gram_mulVec, le_iff_re_im]
simp
/-- In a normed space, positive definiteness of `gram 𝕜 v` implies linear independence of `v`. -/
theorem linearIndependent_of_posDef_gram {v : n → E} (h_gram : PosDef (gram 𝕜 v)) :
LinearIndependent 𝕜 v := by
rw [Fintype.linearIndependent_iff]
intro y hy
obtain ⟨h1, h2⟩ := h_gram
specialize h2 y
simp_all [star_dotProduct_gram_mulVec]
end SemiInnerProductSpace
section NormedInnerProductSpace
variable [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] [Fintype n]
/-- In a normed space, linear independence of `v` implies positive definiteness of `gram 𝕜 v`. -/
theorem posDef_gram_of_linearIndependent
{v : n → E} (h_li : LinearIndependent 𝕜 v) : PosDef (gram 𝕜 v) := by
rw [Fintype.linearIndependent_iff] at h_li
obtain ⟨h0, h1⟩ := posSemidef_gram 𝕜 v
refine ⟨h0, fun x hx ↦ (h1 x).lt_of_ne' ?_⟩
rw [star_dotProduct_gram_mulVec, inner_self_eq_zero.ne]
exact mt (h_li x) (mt funext hx)
/-- In a normed space, linear independence of `v` is equivalent to positive definiteness of
`gram 𝕜 v`. -/
theorem posDef_gram_iff_linearIndependent {v : n → E} :
PosDef (gram 𝕜 v) ↔ LinearIndependent 𝕜 v :=
⟨linearIndependent_of_posDef_gram, posDef_gram_of_linearIndependent⟩
end NormedInnerProductSpace
end Matrix |
.lake/packages/mathlib/Mathlib/Analysis/InnerProductSpace/Orthogonal.lean | import Mathlib.Analysis.InnerProductSpace.Subspace
import Mathlib.LinearAlgebra.SesquilinearForm.Basic
/-!
# Orthogonal complements of submodules
In this file, the `orthogonal` complement of a submodule `K` is defined, and basic API established.
Some of the more subtle results about the orthogonal complement are delayed to
`Analysis.InnerProductSpace.Projection`.
See also `BilinForm.orthogonal` for orthogonality with respect to a general bilinear form.
## Notation
The orthogonal complement of a submodule `K` is denoted by `Kᗮ`.
The proposition that two submodules are orthogonal, `Submodule.IsOrtho`, is denoted by `U ⟂ V`.
Note this is not the same unicode symbol as `⊥` (`Bot`).
-/
variable {𝕜 E F : Type*} [RCLike 𝕜]
variable [NormedAddCommGroup E] [InnerProductSpace 𝕜 E]
variable [NormedAddCommGroup F] [InnerProductSpace 𝕜 F]
local notation "⟪" x ", " y "⟫" => inner 𝕜 x y
namespace Submodule
variable (K : Submodule 𝕜 E)
/-- The subspace of vectors orthogonal to a given subspace, denoted `Kᗮ`. -/
def orthogonal : Submodule 𝕜 E where
carrier := { v | ∀ u ∈ K, ⟪u, v⟫ = 0 }
zero_mem' _ _ := inner_zero_right _
add_mem' hx hy u hu := by rw [inner_add_right, hx u hu, hy u hu, add_zero]
smul_mem' c x hx u hu := by rw [inner_smul_right, hx u hu, mul_zero]
@[inherit_doc]
notation:1200 K "ᗮ" => orthogonal K
/-- When a vector is in `Kᗮ`. -/
theorem mem_orthogonal (v : E) : v ∈ Kᗮ ↔ ∀ u ∈ K, ⟪u, v⟫ = 0 :=
Iff.rfl
/-- When a vector is in `Kᗮ`, with the inner product the
other way round. -/
theorem mem_orthogonal' (v : E) : v ∈ Kᗮ ↔ ∀ u ∈ K, ⟪v, u⟫ = 0 := by
simp_rw [mem_orthogonal, inner_eq_zero_symm]
variable {K}
/-- A vector in `K` is orthogonal to one in `Kᗮ`. -/
theorem inner_right_of_mem_orthogonal {u v : E} (hu : u ∈ K) (hv : v ∈ Kᗮ) : ⟪u, v⟫ = 0 :=
(K.mem_orthogonal v).1 hv u hu
/-- A vector in `Kᗮ` is orthogonal to one in `K`. -/
theorem inner_left_of_mem_orthogonal {u v : E} (hu : u ∈ K) (hv : v ∈ Kᗮ) : ⟪v, u⟫ = 0 := by
rw [inner_eq_zero_symm]; exact inner_right_of_mem_orthogonal hu hv
/-- A vector is in `(𝕜 ∙ u)ᗮ` iff it is orthogonal to `u`. -/
theorem mem_orthogonal_singleton_iff_inner_right {u v : E} : v ∈ (𝕜 ∙ u)ᗮ ↔ ⟪u, v⟫ = 0 := by
refine ⟨inner_right_of_mem_orthogonal (mem_span_singleton_self u), ?_⟩
intro hv w hw
rw [mem_span_singleton] at hw
obtain ⟨c, rfl⟩ := hw
simp [inner_smul_left, hv]
/-- A vector in `(𝕜 ∙ u)ᗮ` is orthogonal to `u`. -/
theorem mem_orthogonal_singleton_iff_inner_left {u v : E} : v ∈ (𝕜 ∙ u)ᗮ ↔ ⟪v, u⟫ = 0 := by
rw [mem_orthogonal_singleton_iff_inner_right, inner_eq_zero_symm]
theorem sub_mem_orthogonal_of_inner_left {x y : E} (h : ∀ v : K, ⟪x, v⟫ = ⟪y, v⟫) : x - y ∈ Kᗮ := by
rw [mem_orthogonal']
intro u hu
rw [inner_sub_left, sub_eq_zero]
exact h ⟨u, hu⟩
theorem sub_mem_orthogonal_of_inner_right {x y : E} (h : ∀ v : K, ⟪(v : E), x⟫ = ⟪(v : E), y⟫) :
x - y ∈ Kᗮ := by
intro u hu
rw [inner_sub_right, sub_eq_zero]
exact h ⟨u, hu⟩
variable (K)
/-- `K` and `Kᗮ` have trivial intersection. -/
theorem inf_orthogonal_eq_bot : K ⊓ Kᗮ = ⊥ := by
rw [eq_bot_iff]
intro x
rw [mem_inf]
exact fun ⟨hx, ho⟩ => inner_self_eq_zero.1 (ho x hx)
/-- `K` and `Kᗮ` have trivial intersection. -/
theorem orthogonal_disjoint : Disjoint K Kᗮ := by simp [disjoint_iff, K.inf_orthogonal_eq_bot]
/-- `Kᗮ` can be characterized as the intersection of the kernels of the operations of
inner product with each of the elements of `K`. -/
theorem orthogonal_eq_inter : Kᗮ = ⨅ v : K, LinearMap.ker (innerSL 𝕜 (v : E)) := by
apply le_antisymm
· rw [le_iInf_iff]
rintro ⟨v, hv⟩ w hw
simpa using hw _ hv
· intro v hv w hw
simp only [mem_iInf] at hv
exact hv ⟨w, hw⟩
/-- The orthogonal complement of any submodule `K` is closed. -/
theorem isClosed_orthogonal : IsClosed (Kᗮ : Set E) := by
rw [orthogonal_eq_inter K]
convert isClosed_iInter <| fun v : K => ContinuousLinearMap.isClosed_ker (innerSL 𝕜 (v : E))
simp only [coe_iInf]
/-- In a complete space, the orthogonal complement of any submodule `K` is complete. -/
instance instOrthogonalCompleteSpace [CompleteSpace E] : CompleteSpace Kᗮ :=
K.isClosed_orthogonal.completeSpace_coe
variable (𝕜 E)
/-- `orthogonal` gives a `GaloisConnection` between
`Submodule 𝕜 E` and its `OrderDual`. -/
theorem orthogonal_gc :
@GaloisConnection (Submodule 𝕜 E) (Submodule 𝕜 E)ᵒᵈ _ _ orthogonal orthogonal := fun _K₁ _K₂ =>
⟨fun h _v hv _u hu => inner_left_of_mem_orthogonal hv (h hu), fun h _v hv _u hu =>
inner_left_of_mem_orthogonal hv (h hu)⟩
variable {𝕜 E}
/-- `orthogonal` reverses the `≤` ordering of two
subspaces. -/
theorem orthogonal_le {K₁ K₂ : Submodule 𝕜 E} (h : K₁ ≤ K₂) : K₂ᗮ ≤ K₁ᗮ :=
(orthogonal_gc 𝕜 E).monotone_l h
/-- `orthogonal.orthogonal` preserves the `≤` ordering of two
subspaces. -/
theorem orthogonal_orthogonal_monotone {K₁ K₂ : Submodule 𝕜 E} (h : K₁ ≤ K₂) : K₁ᗮᗮ ≤ K₂ᗮᗮ :=
orthogonal_le (orthogonal_le h)
/-- `K` is contained in `Kᗮᗮ`. -/
theorem le_orthogonal_orthogonal : K ≤ Kᗮᗮ :=
(orthogonal_gc 𝕜 E).le_u_l _
/-- The inf of two orthogonal subspaces equals the subspace orthogonal
to the sup. -/
theorem inf_orthogonal (K₁ K₂ : Submodule 𝕜 E) : K₁ᗮ ⊓ K₂ᗮ = (K₁ ⊔ K₂)ᗮ :=
(orthogonal_gc 𝕜 E).l_sup.symm
/-- The inf of an indexed family of orthogonal subspaces equals the
subspace orthogonal to the sup. -/
theorem iInf_orthogonal {ι : Type*} (K : ι → Submodule 𝕜 E) : ⨅ i, (K i)ᗮ = (iSup K)ᗮ :=
(orthogonal_gc 𝕜 E).l_iSup.symm
/-- The inf of a set of orthogonal subspaces equals the subspace orthogonal to the sup. -/
theorem sInf_orthogonal (s : Set <| Submodule 𝕜 E) : ⨅ K ∈ s, Kᗮ = (sSup s)ᗮ :=
(orthogonal_gc 𝕜 E).l_sSup.symm
@[simp]
theorem top_orthogonal_eq_bot : (⊤ : Submodule 𝕜 E)ᗮ = ⊥ := by
ext x
rw [mem_bot, mem_orthogonal]
exact
⟨fun h => inner_self_eq_zero.mp (h x mem_top), by
rintro rfl
simp⟩
@[simp]
theorem bot_orthogonal_eq_top : (⊥ : Submodule 𝕜 E)ᗮ = ⊤ := by
rw [← top_orthogonal_eq_bot, eq_top_iff]
exact le_orthogonal_orthogonal ⊤
@[simp]
theorem orthogonal_eq_top_iff : Kᗮ = ⊤ ↔ K = ⊥ := by
refine
⟨?_, by
rintro rfl
exact bot_orthogonal_eq_top⟩
intro h
have : K ⊓ Kᗮ = ⊥ := K.orthogonal_disjoint.eq_bot
rwa [h, inf_comm, top_inf_eq] at this
/-- The closure of a submodule has the same orthogonal complement and the submodule itself. -/
@[simp]
lemma orthogonal_closure (K : Submodule 𝕜 E) : K.topologicalClosureᗮ = Kᗮ :=
le_antisymm (orthogonal_le <| le_topologicalClosure _)
fun x hx y hy ↦ closure_minimal hx (isClosed_eq (by fun_prop) (by fun_prop)) hy
theorem orthogonalFamily_self :
OrthogonalFamily 𝕜 (fun b => ↥(cond b K Kᗮ)) fun b => (cond b K Kᗮ).subtypeₗᵢ
| true, true => absurd rfl
| true, false => fun _ x y => inner_right_of_mem_orthogonal x.prop y.prop
| false, true => fun _ x y => inner_left_of_mem_orthogonal y.prop x.prop
| false, false => absurd rfl
end Submodule
@[simp]
theorem bilinFormOfRealInner_orthogonal {E} [NormedAddCommGroup E] [InnerProductSpace ℝ E]
(K : Submodule ℝ E) : K.orthogonalBilin bilinFormOfRealInner = Kᗮ :=
rfl
/-!
### Orthogonality of submodules
In this section we define `Submodule.IsOrtho U V`, denoted as `U ⟂ V`.
The API roughly matches that of `Disjoint`.
-/
namespace Submodule
/-- The proposition that two submodules are orthogonal, denoted as `U ⟂ V`. -/
def IsOrtho (U V : Submodule 𝕜 E) : Prop :=
U ≤ Vᗮ
@[inherit_doc]
infixl:50 " ⟂ " => Submodule.IsOrtho
theorem isOrtho_iff_le {U V : Submodule 𝕜 E} : U ⟂ V ↔ U ≤ Vᗮ :=
Iff.rfl
@[symm]
theorem IsOrtho.symm {U V : Submodule 𝕜 E} (h : U ⟂ V) : V ⟂ U :=
(le_orthogonal_orthogonal _).trans (orthogonal_le h)
theorem isOrtho_comm {U V : Submodule 𝕜 E} : U ⟂ V ↔ V ⟂ U :=
⟨IsOrtho.symm, IsOrtho.symm⟩
theorem symmetric_isOrtho : Symmetric (IsOrtho : Submodule 𝕜 E → Submodule 𝕜 E → Prop) := fun _ _ =>
IsOrtho.symm
theorem IsOrtho.inner_eq {U V : Submodule 𝕜 E} (h : U ⟂ V) {u v : E} (hu : u ∈ U) (hv : v ∈ V) :
⟪u, v⟫ = 0 :=
h.symm hv _ hu
theorem isOrtho_iff_inner_eq {U V : Submodule 𝕜 E} : U ⟂ V ↔ ∀ u ∈ U, ∀ v ∈ V, ⟪u, v⟫ = 0 :=
forall₄_congr fun _u _hu _v _hv => inner_eq_zero_symm
/- TODO: generalize `Submodule.map₂` to semilinear maps, so that we can state
`U ⟂ V ↔ Submodule.map₂ (innerₛₗ 𝕜) U V ≤ ⊥`. -/
@[simp]
theorem isOrtho_bot_left {V : Submodule 𝕜 E} : ⊥ ⟂ V :=
bot_le
@[simp]
theorem isOrtho_bot_right {U : Submodule 𝕜 E} : U ⟂ ⊥ :=
isOrtho_bot_left.symm
theorem IsOrtho.mono_left {U₁ U₂ V : Submodule 𝕜 E} (hU : U₂ ≤ U₁) (h : U₁ ⟂ V) : U₂ ⟂ V :=
hU.trans h
theorem IsOrtho.mono_right {U V₁ V₂ : Submodule 𝕜 E} (hV : V₂ ≤ V₁) (h : U ⟂ V₁) : U ⟂ V₂ :=
(h.symm.mono_left hV).symm
theorem IsOrtho.mono {U₁ V₁ U₂ V₂ : Submodule 𝕜 E} (hU : U₂ ≤ U₁) (hV : V₂ ≤ V₁) (h : U₁ ⟂ V₁) :
U₂ ⟂ V₂ :=
(h.mono_right hV).mono_left hU
@[simp]
theorem isOrtho_self {U : Submodule 𝕜 E} : U ⟂ U ↔ U = ⊥ :=
⟨fun h => eq_bot_iff.mpr fun x hx => inner_self_eq_zero.mp (h hx x hx), fun h =>
h.symm ▸ isOrtho_bot_left⟩
@[simp]
theorem isOrtho_orthogonal_right (U : Submodule 𝕜 E) : U ⟂ Uᗮ :=
le_orthogonal_orthogonal _
@[simp]
theorem isOrtho_orthogonal_left (U : Submodule 𝕜 E) : Uᗮ ⟂ U :=
(isOrtho_orthogonal_right U).symm
theorem IsOrtho.le {U V : Submodule 𝕜 E} (h : U ⟂ V) : U ≤ Vᗮ :=
h
theorem IsOrtho.ge {U V : Submodule 𝕜 E} (h : U ⟂ V) : V ≤ Uᗮ :=
h.symm
@[simp]
theorem isOrtho_top_right {U : Submodule 𝕜 E} : U ⟂ ⊤ ↔ U = ⊥ :=
⟨fun h => eq_bot_iff.mpr fun _x hx => inner_self_eq_zero.mp (h hx _ mem_top), fun h =>
h.symm ▸ isOrtho_bot_left⟩
@[simp]
theorem isOrtho_top_left {V : Submodule 𝕜 E} : ⊤ ⟂ V ↔ V = ⊥ :=
isOrtho_comm.trans isOrtho_top_right
/-- Orthogonal submodules are disjoint. -/
theorem IsOrtho.disjoint {U V : Submodule 𝕜 E} (h : U ⟂ V) : Disjoint U V :=
(Submodule.orthogonal_disjoint _).mono_right h.symm
@[simp]
theorem isOrtho_sup_left {U₁ U₂ V : Submodule 𝕜 E} : U₁ ⊔ U₂ ⟂ V ↔ U₁ ⟂ V ∧ U₂ ⟂ V :=
sup_le_iff
@[simp]
theorem isOrtho_sup_right {U V₁ V₂ : Submodule 𝕜 E} : U ⟂ V₁ ⊔ V₂ ↔ U ⟂ V₁ ∧ U ⟂ V₂ :=
isOrtho_comm.trans <| isOrtho_sup_left.trans <| isOrtho_comm.and isOrtho_comm
@[simp]
theorem isOrtho_sSup_left {U : Set (Submodule 𝕜 E)} {V : Submodule 𝕜 E} :
sSup U ⟂ V ↔ ∀ Uᵢ ∈ U, Uᵢ ⟂ V :=
sSup_le_iff
@[simp]
theorem isOrtho_sSup_right {U : Submodule 𝕜 E} {V : Set (Submodule 𝕜 E)} :
U ⟂ sSup V ↔ ∀ Vᵢ ∈ V, U ⟂ Vᵢ :=
isOrtho_comm.trans <| isOrtho_sSup_left.trans <| by simp_rw [isOrtho_comm]
@[simp]
theorem isOrtho_iSup_left {ι : Sort*} {U : ι → Submodule 𝕜 E} {V : Submodule 𝕜 E} :
iSup U ⟂ V ↔ ∀ i, U i ⟂ V :=
iSup_le_iff
@[simp]
theorem isOrtho_iSup_right {ι : Sort*} {U : Submodule 𝕜 E} {V : ι → Submodule 𝕜 E} :
U ⟂ iSup V ↔ ∀ i, U ⟂ V i :=
isOrtho_comm.trans <| isOrtho_iSup_left.trans <| by simp_rw [isOrtho_comm]
@[simp]
theorem isOrtho_span {s t : Set E} :
span 𝕜 s ⟂ span 𝕜 t ↔ ∀ ⦃u⦄, u ∈ s → ∀ ⦃v⦄, v ∈ t → ⟪u, v⟫ = 0 := by
simp_rw [span_eq_iSup_of_singleton_spans s, span_eq_iSup_of_singleton_spans t, isOrtho_iSup_left,
isOrtho_iSup_right, isOrtho_iff_le, span_le, Set.subset_def, SetLike.mem_coe,
mem_orthogonal_singleton_iff_inner_left, Set.mem_singleton_iff, forall_eq]
theorem IsOrtho.map (f : E →ₗᵢ[𝕜] F) {U V : Submodule 𝕜 E} (h : U ⟂ V) : U.map f ⟂ V.map f := by
rw [isOrtho_iff_inner_eq] at *
simp_rw [mem_map, forall_exists_index, and_imp, forall_apply_eq_imp_iff₂,
LinearIsometry.inner_map_map]
exact h
theorem IsOrtho.comap (f : E →ₗᵢ[𝕜] F) {U V : Submodule 𝕜 F} (h : U ⟂ V) :
U.comap f ⟂ V.comap f := by
rw [isOrtho_iff_inner_eq] at *
simp_rw [mem_comap, ← f.inner_map_map]
intro u hu v hv
exact h _ hu _ hv
@[simp]
theorem IsOrtho.map_iff (f : E ≃ₗᵢ[𝕜] F) {U V : Submodule 𝕜 E} : U.map f ⟂ V.map f ↔ U ⟂ V :=
⟨fun h => by
have hf : ∀ p : Submodule 𝕜 E, (p.map f).comap f.toLinearIsometry = p :=
comap_map_eq_of_injective f.injective
simpa only [hf] using h.comap f.toLinearIsometry, IsOrtho.map f.toLinearIsometry⟩
@[simp]
theorem IsOrtho.comap_iff (f : E ≃ₗᵢ[𝕜] F) {U V : Submodule 𝕜 F} : U.comap f ⟂ V.comap f ↔ U ⟂ V :=
⟨fun h => by
have hf : ∀ p : Submodule 𝕜 F, (p.comap f).map f.toLinearIsometry = p :=
map_comap_eq_of_surjective f.surjective
simpa only [hf] using h.map f.toLinearIsometry, IsOrtho.comap f.toLinearIsometry⟩
end Submodule
open scoped Function in -- required for scoped `on` notation
theorem orthogonalFamily_iff_pairwise {ι} {V : ι → Submodule 𝕜 E} :
(OrthogonalFamily 𝕜 (fun i => V i) fun i => (V i).subtypeₗᵢ) ↔ Pairwise ((· ⟂ ·) on V) :=
forall₃_congr fun _i _j _hij =>
Subtype.forall.trans <|
forall₂_congr fun _x _hx => Subtype.forall.trans <|
forall₂_congr fun _y _hy => inner_eq_zero_symm
alias ⟨OrthogonalFamily.pairwise, OrthogonalFamily.of_pairwise⟩ := orthogonalFamily_iff_pairwise
/-- Two submodules in an orthogonal family with different indices are orthogonal. -/
theorem OrthogonalFamily.isOrtho {ι} {V : ι → Submodule 𝕜 E}
(hV : OrthogonalFamily 𝕜 (fun i => V i) fun i => (V i).subtypeₗᵢ) {i j : ι} (hij : i ≠ j) :
V i ⟂ V j :=
hV.pairwise hij |
.lake/packages/mathlib/Mathlib/Analysis/InnerProductSpace/Continuous.lean | import Mathlib.Analysis.InnerProductSpace.Basic
import Mathlib.Analysis.Normed.Operator.BoundedLinearMaps
/-!
# Continuity of inner product
We show that the inner product is continuous, `continuous_inner`.
## Tags
inner product space, Hilbert space, norm
-/
noncomputable section
open RCLike Real Filter Topology ComplexConjugate Finsupp
open LinearMap renaming BilinForm → BilinForm
variable {𝕜 E F : Type*} [RCLike 𝕜]
section Continuous
variable [SeminormedAddCommGroup E] [InnerProductSpace 𝕜 E]
local notation "⟪" x ", " y "⟫" => inner 𝕜 x y
/-!
### Continuity of the inner product
-/
/-- When an inner product space `E` over `𝕜` is considered as a real normed space, its inner
product satisfies `IsBoundedBilinearMap`.
In order to state these results, we need a `NormedSpace ℝ E` instance. We will later establish
such an instance by restriction-of-scalars, `InnerProductSpace.rclikeToReal 𝕜 E`, but this
instance may be not definitionally equal to some other “natural” instance. So, we assume
`[NormedSpace ℝ E]`.
-/
theorem _root_.isBoundedBilinearMap_inner [NormedSpace ℝ E] [IsScalarTower ℝ 𝕜 E] :
IsBoundedBilinearMap ℝ fun p : E × E => ⟪p.1, p.2⟫ :=
{ add_left := inner_add_left
smul_left := fun r x y => by
simp only [← algebraMap_smul 𝕜 r x, algebraMap_eq_ofReal, inner_smul_real_left]
add_right := inner_add_right
smul_right := fun r x y => by
simp only [← algebraMap_smul 𝕜 r y, algebraMap_eq_ofReal, inner_smul_real_right]
bound :=
⟨1, zero_lt_one, fun x y => by
rw [one_mul]
exact norm_inner_le_norm x y⟩ }
theorem continuous_inner : Continuous fun p : E × E => ⟪p.1, p.2⟫ :=
letI : InnerProductSpace ℝ E := InnerProductSpace.rclikeToReal 𝕜 E
letI : IsScalarTower ℝ 𝕜 E := RestrictScalars.isScalarTower _ _ _
isBoundedBilinearMap_inner.continuous
variable {α : Type*}
theorem Filter.Tendsto.inner {f g : α → E} {l : Filter α} {x y : E} (hf : Tendsto f l (𝓝 x))
(hg : Tendsto g l (𝓝 y)) : Tendsto (fun t => ⟪f t, g t⟫) l (𝓝 ⟪x, y⟫) :=
(continuous_inner.tendsto _).comp (hf.prodMk_nhds hg)
variable [TopologicalSpace α] {f g : α → E} {x : α} {s : Set α}
theorem ContinuousWithinAt.inner (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) :
ContinuousWithinAt (fun t => ⟪f t, g t⟫) s x :=
Filter.Tendsto.inner hf hg
@[fun_prop]
theorem ContinuousAt.inner (hf : ContinuousAt f x) (hg : ContinuousAt g x) :
ContinuousAt (fun t => ⟪f t, g t⟫) x :=
Filter.Tendsto.inner hf hg
@[fun_prop]
theorem ContinuousOn.inner (hf : ContinuousOn f s) (hg : ContinuousOn g s) :
ContinuousOn (fun t => ⟪f t, g t⟫) s := fun x hx => (hf x hx).inner (hg x hx)
@[continuity, fun_prop]
theorem Continuous.inner (hf : Continuous f) (hg : Continuous g) : Continuous fun t => ⟪f t, g t⟫ :=
continuous_iff_continuousAt.2 fun _x => by fun_prop
end Continuous |
.lake/packages/mathlib/Mathlib/Analysis/InnerProductSpace/NormPow.lean | import Mathlib.Analysis.InnerProductSpace.Calculus
import Mathlib.Analysis.SpecialFunctions.Pow.Deriv
/-!
# Properties about the powers of the norm
In this file we prove that `x ↦ ‖x‖ ^ p` is continuously differentiable for
an inner product space and for a real number `p > 1`.
## TODO
* `x ↦ ‖x‖ ^ p` should be `C^n` for `p > n`.
-/
section ContDiffNormPow
open Asymptotics Real Topology
open scoped NNReal
variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E]
variable {F : Type*} [NormedAddCommGroup F] [NormedSpace ℝ F]
theorem hasFDerivAt_norm_rpow (x : E) {p : ℝ} (hp : 1 < p) :
HasFDerivAt (fun x : E ↦ ‖x‖ ^ p) ((p * ‖x‖ ^ (p - 2)) • innerSL ℝ x) x := by
by_cases hx : x = 0
· simp only [hx, norm_zero, map_zero, smul_zero]
have h2p : 0 < p - 1 := sub_pos.mpr hp
rw [HasFDerivAt, hasFDerivAtFilter_iff_isLittleO]
calc (fun x : E ↦ ‖x‖ ^ p - ‖(0 : E)‖ ^ p - 0)
= (fun x : E ↦ ‖x‖ ^ p) := by simp [zero_lt_one.trans hp |>.ne']
_ = (fun x : E ↦ ‖x‖ * ‖x‖ ^ (p - 1)) := by
ext x
rw [← rpow_one_add' (norm_nonneg x) (by positivity)]
ring_nf
_ =o[𝓝 0] (fun x : E ↦ ‖x‖ * 1) := by
refine (isBigO_refl _ _).mul_isLittleO <| (isLittleO_const_iff <| by simp).mpr ?_
convert continuousAt_id.norm.rpow_const (.inr h2p.le) |>.tendsto
simp [h2p.ne']
_ =O[𝓝 0] (fun (x : E) ↦ x - 0) := by
simp_rw [mul_one, isBigO_norm_left (f' := fun x ↦ x), sub_zero, isBigO_refl]
· apply HasStrictFDerivAt.hasFDerivAt
convert (hasStrictFDerivAt_norm_sq x).rpow_const (p := p / 2) (by simp [hx]) using 0
simp_rw [← Real.rpow_natCast_mul (norm_nonneg _), ← Nat.cast_smul_eq_nsmul ℝ, smul_smul]
ring_nf
theorem differentiable_norm_rpow {p : ℝ} (hp : 1 < p) :
Differentiable ℝ (fun x : E ↦ ‖x‖ ^ p) :=
fun x ↦ hasFDerivAt_norm_rpow x hp |>.differentiableAt
theorem hasDerivAt_norm_rpow (x : ℝ) {p : ℝ} (hp : 1 < p) :
HasDerivAt (fun x : ℝ ↦ ‖x‖ ^ p) (p * ‖x‖ ^ (p - 2) * x) x := by
convert hasFDerivAt_norm_rpow x hp |>.hasDerivAt using 1; simp
theorem hasDerivAt_abs_rpow (x : ℝ) {p : ℝ} (hp : 1 < p) :
HasDerivAt (fun x : ℝ ↦ |x| ^ p) (p * |x| ^ (p - 2) * x) x := by
simpa using hasDerivAt_norm_rpow x hp
theorem fderiv_norm_rpow (x : E) {p : ℝ} (hp : 1 < p) :
fderiv ℝ (fun x ↦ ‖x‖ ^ p) x = (p * ‖x‖ ^ (p - 2)) • innerSL ℝ x :=
hasFDerivAt_norm_rpow x hp |>.fderiv
theorem Differentiable.fderiv_norm_rpow {f : F → E} (hf : Differentiable ℝ f)
{x : F} {p : ℝ} (hp : 1 < p) :
fderiv ℝ (fun x ↦ ‖f x‖ ^ p) x =
(p * ‖f x‖ ^ (p - 2)) • (innerSL ℝ (f x)).comp (fderiv ℝ f x) :=
hasFDerivAt_norm_rpow (f x) hp |>.comp x (hf x).hasFDerivAt |>.fderiv
theorem norm_fderiv_norm_rpow_le {f : F → E} (hf : Differentiable ℝ f) {x : F}
{p : ℝ} (hp : 1 < p) :
‖fderiv ℝ (fun x ↦ ‖f x‖ ^ p) x‖ ≤ p * ‖f x‖ ^ (p - 1) * ‖fderiv ℝ f x‖ := by
rw [hf.fderiv_norm_rpow hp, norm_smul, norm_mul]
simp_rw [norm_rpow_of_nonneg (norm_nonneg _), norm_norm, norm_eq_abs,
abs_eq_self.mpr <| zero_le_one.trans hp.le, mul_assoc]
gcongr _ * ?_
refine mul_le_mul_of_nonneg_left (ContinuousLinearMap.opNorm_comp_le ..) (by positivity)
|>.trans_eq ?_
rw [innerSL_apply_norm, ← mul_assoc, ← Real.rpow_add_one' (by positivity) (by linarith)]
ring_nf
theorem norm_fderiv_norm_id_rpow (x : E) {p : ℝ} (hp : 1 < p) :
‖fderiv ℝ (fun x ↦ ‖x‖ ^ p) x‖ = p * ‖x‖ ^ (p - 1) := by
rw [fderiv_norm_rpow x hp, norm_smul, norm_mul]
simp_rw [norm_rpow_of_nonneg (norm_nonneg _), norm_norm, norm_eq_abs,
abs_eq_self.mpr <| zero_le_one.trans hp.le, mul_assoc, innerSL_apply_norm]
rw [← Real.rpow_add_one' (by positivity) (by linarith)]
ring_nf
theorem nnnorm_fderiv_norm_rpow_le {f : F → E} (hf : Differentiable ℝ f)
{x : F} {p : ℝ≥0} (hp : 1 < p) :
‖fderiv ℝ (fun x ↦ ‖f x‖ ^ (p : ℝ)) x‖₊ ≤ p * ‖f x‖₊ ^ ((p : ℝ) - 1) * ‖fderiv ℝ f x‖₊ :=
norm_fderiv_norm_rpow_le hf hp
lemma enorm_fderiv_norm_rpow_le {f : F → E} (hf : Differentiable ℝ f)
{x : F} {p : ℝ≥0} (hp : 1 < p) :
‖fderiv ℝ (fun x ↦ ‖f x‖ ^ (p : ℝ)) x‖ₑ ≤ p * ‖f x‖ₑ ^ ((p : ℝ) - 1) * ‖fderiv ℝ f x‖ₑ := by
simpa [enorm, ← ENNReal.coe_rpow_of_nonneg _ (sub_nonneg.2 <| NNReal.one_le_coe.2 hp.le),
← ENNReal.coe_mul] using nnnorm_fderiv_norm_rpow_le hf hp
theorem contDiff_norm_rpow {p : ℝ} (hp : 1 < p) : ContDiff ℝ 1 (fun x : E ↦ ‖x‖ ^ p) := by
rw [contDiff_one_iff_fderiv]
refine ⟨fun x ↦ hasFDerivAt_norm_rpow x hp |>.differentiableAt, ?_⟩
simp_rw [continuous_iff_continuousAt]
intro x
by_cases hx : x = 0
· simp_rw [hx, ContinuousAt, fderiv_norm_rpow (0 : E) hp, norm_zero, map_zero, smul_zero]
rw [tendsto_zero_iff_norm_tendsto_zero]
refine tendsto_of_tendsto_of_tendsto_of_le_of_le (tendsto_const_nhds) ?_
(fun _ ↦ norm_nonneg _) (fun _ ↦ norm_fderiv_norm_id_rpow _ hp |>.le)
suffices ContinuousAt (fun x : E ↦ p * ‖x‖ ^ (p - 1)) 0 by
simpa [ContinuousAt, sub_ne_zero_of_ne hp.ne'] using this
fun_prop (discharger := simp [hp.le])
· simp_rw [funext fun x ↦ fderiv_norm_rpow (E := E) (x := x) hp]
fun_prop (discharger := simp [hx])
theorem ContDiff.norm_rpow {f : F → E} (hf : ContDiff ℝ 1 f) {p : ℝ} (hp : 1 < p) :
ContDiff ℝ 1 (fun x ↦ ‖f x‖ ^ p) :=
contDiff_norm_rpow hp |>.comp hf
theorem Differentiable.norm_rpow {f : F → E} (hf : Differentiable ℝ f) {p : ℝ} (hp : 1 < p) :
Differentiable ℝ (fun x ↦ ‖f x‖ ^ p) :=
contDiff_norm_rpow hp |>.differentiable le_rfl |>.comp hf
end ContDiffNormPow |
.lake/packages/mathlib/Mathlib/Analysis/InnerProductSpace/Dual.lean | import Mathlib.Analysis.InnerProductSpace.Projection.Submodule
import Mathlib.Analysis.Normed.Group.NullSubmodule
import Mathlib.Topology.Algebra.Module.PerfectPairing
/-!
# The Fréchet-Riesz representation theorem
We consider an inner product space `E` over `𝕜`, which is either `ℝ` or `ℂ`. We define
`toDualMap`, a conjugate-linear isometric embedding of `E` into its dual, which maps an element `x`
of the space to `fun y => ⟪x, y⟫`.
Under the hypothesis of completeness (i.e., for Hilbert spaces), we upgrade this to `toDual`, a
conjugate-linear isometric *equivalence* of `E` onto its dual; that is, we establish the
surjectivity of `toDualMap`. This is the Fréchet-Riesz representation theorem: every element of the
dual of a Hilbert space `E` has the form `fun u => ⟪x, u⟫` for some `x : E`.
For a bounded sesquilinear form `B : E →L⋆[𝕜] E →L[𝕜] 𝕜`,
we define a map `InnerProductSpace.continuousLinearMapOfBilin B : E →L[𝕜] E`,
given by substituting `E →L[𝕜] 𝕜` with `E` using `toDual`.
## References
* [M. Einsiedler and T. Ward, *Functional Analysis, Spectral Theory, and Applications*]
[EinsiedlerWard2017]
## Tags
dual, Fréchet-Riesz
-/
noncomputable section
open ComplexConjugate Module
universe u v
namespace InnerProductSpace
open RCLike ContinuousLinearMap
variable (𝕜 E : Type*)
section Seminormed
variable [RCLike 𝕜] [SeminormedAddCommGroup E] [InnerProductSpace 𝕜 E]
local notation "⟪" x ", " y "⟫" => inner 𝕜 x y
local postfix:90 "†" => starRingEnd _
/-- An element `x` of an inner product space `E` induces an element of the strong dual space
`StrongDual 𝕜 E`, the map `fun y => ⟪x, y⟫`; moreover this operation is a conjugate-linear isometric
embedding of `E` into `StrongDual 𝕜 E`.
If `E` is complete, this operation is surjective, hence a conjugate-linear isometric equivalence;
see `toDual`.
-/
def toDualMap : E →ₗᵢ⋆[𝕜] StrongDual 𝕜 E :=
{ innerSL 𝕜 with norm_map' := innerSL_apply_norm _ }
variable {E}
@[simp]
theorem toDualMap_apply_apply {x y : E} : toDualMap 𝕜 E x y = ⟪x, y⟫ := rfl
@[deprecated (since := "2025-11-15")] alias toDualMap_apply := toDualMap_apply_apply
variable {𝕜} in
@[simp]
theorem _root_.innerSL_inj {E : Type*} [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] {x y : E} :
innerSL 𝕜 x = innerSL 𝕜 y ↔ x = y :=
(toDualMap 𝕜 E).injective.eq_iff
section NullSubmodule
open LinearMap
/-- For each `x : E`, the kernel of `⟪x, ⬝⟫` includes the null space. -/
lemma nullSubmodule_le_ker_toDualMap_right (x : E) : nullSubmodule 𝕜 E ≤ ker (toDualMap 𝕜 E x) :=
fun _ hx ↦ inner_eq_zero_of_right x ((mem_nullSubmodule_iff).mp hx)
/-- The kernel of the map `x ↦ ⟪·, x⟫` includes the null space. -/
lemma nullSubmodule_le_ker_toDualMap_left : nullSubmodule 𝕜 E ≤ ker (toDualMap 𝕜 E) :=
fun _ hx ↦ ContinuousLinearMap.ext <| fun y ↦ inner_eq_zero_of_left y hx
end NullSubmodule
end Seminormed
section Normed
variable [RCLike 𝕜] [NormedAddCommGroup E] [InnerProductSpace 𝕜 E]
local notation "⟪" x ", " y "⟫" => inner 𝕜 x y
local postfix:90 "†" => starRingEnd _
theorem innerSL_norm [Nontrivial E] : ‖(innerSL 𝕜 : E →L⋆[𝕜] E →L[𝕜] 𝕜)‖ = 1 :=
show ‖(toDualMap 𝕜 E).toContinuousLinearMap‖ = 1 from LinearIsometry.norm_toContinuousLinearMap _
variable {E 𝕜}
theorem ext_inner_left_basis {ι : Type*} {x y : E} (b : Basis ι 𝕜 E)
(h : ∀ i : ι, ⟪b i, x⟫ = ⟪b i, y⟫) : x = y := by
apply (toDualMap 𝕜 E).map_eq_iff.mp
refine (Function.Injective.eq_iff ContinuousLinearMap.coe_injective).mp (b.ext ?_)
intro i
simp only [ContinuousLinearMap.coe_coe, toDualMap_apply_apply]
rw [← inner_conj_symm]
conv_rhs => rw [← inner_conj_symm]
exact congr_arg conj (h i)
theorem ext_inner_right_basis {ι : Type*} {x y : E} (b : Basis ι 𝕜 E)
(h : ∀ i : ι, ⟪x, b i⟫ = ⟪y, b i⟫) : x = y := by
refine ext_inner_left_basis b fun i => ?_
rw [← inner_conj_symm]
conv_rhs => rw [← inner_conj_symm]
exact congr_arg conj (h i)
variable (𝕜) (E)
variable [CompleteSpace E]
/-- **Fréchet-Riesz representation**: any `ℓ` in the dual of a Hilbert space `E` is of the form
`fun u => ⟪y, u⟫` for some `y : E`, i.e. `toDualMap` is surjective.
-/
def toDual : E ≃ₗᵢ⋆[𝕜] StrongDual 𝕜 E :=
LinearIsometryEquiv.ofSurjective (toDualMap 𝕜 E)
(by
intro ℓ
set Y := LinearMap.ker ℓ
by_cases htriv : Y = ⊤
· have hℓ : ℓ = 0 := by
have h' := LinearMap.ker_eq_top.mp htriv
rw [← coe_zero] at h'
apply coe_injective
exact h'
exact ⟨0, by simp [hℓ]⟩
· rw [← Submodule.orthogonal_eq_bot_iff] at htriv
change Yᗮ ≠ ⊥ at htriv
rw [Submodule.ne_bot_iff] at htriv
obtain ⟨z : E, hz : z ∈ Yᗮ, z_ne_0 : z ≠ 0⟩ := htriv
refine ⟨(starRingEnd (R := 𝕜) (ℓ z) / ⟪z, z⟫) • z, ?_⟩
apply ContinuousLinearMap.ext
intro x
have h₁ : ℓ z • x - ℓ x • z ∈ Y := by
rw [LinearMap.mem_ker, map_sub, ContinuousLinearMap.map_smul,
ContinuousLinearMap.map_smul, Algebra.id.smul_eq_mul, Algebra.id.smul_eq_mul, mul_comm]
exact sub_self (ℓ x * ℓ z)
have h₂ : ℓ z * ⟪z, x⟫ = ℓ x * ⟪z, z⟫ :=
haveI h₃ :=
calc
0 = ⟪z, ℓ z • x - ℓ x • z⟫ := by
rw [(Y.mem_orthogonal' z).mp hz]
exact h₁
_ = ⟪z, ℓ z • x⟫ - ⟪z, ℓ x • z⟫ := by rw [inner_sub_right]
_ = ℓ z * ⟪z, x⟫ - ℓ x * ⟪z, z⟫ := by simp [inner_smul_right]
sub_eq_zero.mp h₃.symm
calc
⟪(ℓ z† / ⟪z, z⟫) • z, x⟫ = ℓ z / ⟪z, z⟫ * ⟪z, x⟫ := by simp [inner_smul_left]
_ = ℓ z * ⟪z, x⟫ / ⟪z, z⟫ := by rw [← div_mul_eq_mul_div]
_ = ℓ x * ⟪z, z⟫ / ⟪z, z⟫ := by rw [h₂]
_ = ℓ x := by have : ⟪z, z⟫ ≠ 0 := inner_self_ne_zero.mpr z_ne_0; field)
variable {𝕜} {E}
@[simp]
theorem toDual_apply_apply {x y : E} : toDual 𝕜 E x y = ⟪x, y⟫ := rfl
@[deprecated (since := "2025-11-15")] alias toDual_apply := toDual_apply_apply
@[simp]
theorem toDual_symm_apply {x : E} {y : StrongDual 𝕜 E} : ⟪(toDual 𝕜 E).symm y, x⟫ = y x := by
rw [← toDual_apply_apply]
simp only [LinearIsometryEquiv.apply_symm_apply]
/-- Maps a bounded sesquilinear form to its continuous linear map,
given by interpreting the form as a map `B : E →L⋆[𝕜] StrongDual 𝕜 E`
and dualizing the result using `toDual`.
-/
def continuousLinearMapOfBilin (B : E →L⋆[𝕜] E →L[𝕜] 𝕜) : E →L[𝕜] E :=
(toDual 𝕜 E).symm.toContinuousLinearEquiv.toContinuousLinearMap.comp B
local postfix:1024 "♯" => continuousLinearMapOfBilin
variable (B : E →L⋆[𝕜] E →L[𝕜] 𝕜)
@[simp]
theorem continuousLinearMapOfBilin_zero : (0 : E →L⋆[𝕜] E →L[𝕜] 𝕜)♯ = 0 := by
simp [continuousLinearMapOfBilin]
@[simp]
theorem continuousLinearMapOfBilin_apply (v w : E) : ⟪B♯ v, w⟫ = B v w := by
rw [continuousLinearMapOfBilin, coe_comp', ContinuousLinearEquiv.coe_coe,
LinearIsometryEquiv.coe_toContinuousLinearEquiv, Function.comp_apply, toDual_symm_apply]
theorem unique_continuousLinearMapOfBilin {v f : E} (is_lax_milgram : ∀ w, ⟪f, w⟫ = B v w) :
f = B♯ v := by
refine ext_inner_right 𝕜 ?_
intro w
rw [continuousLinearMapOfBilin_apply]
exact is_lax_milgram w
end Normed
instance [NormedAddCommGroup E] [CompleteSpace E] [InnerProductSpace ℝ E] :
(innerₗ E).IsContPerfPair where
continuous_uncurry := continuous_inner
bijective_left := (toDual ℝ E).bijective
bijective_right := by
convert (toDual ℝ E).bijective
ext y
simp
end InnerProductSpace |
.lake/packages/mathlib/Mathlib/Analysis/InnerProductSpace/LinearPMap.lean | import Mathlib.Analysis.InnerProductSpace.Adjoint
import Mathlib.Analysis.InnerProductSpace.ProdL2
import Mathlib.Analysis.Normed.Operator.Extend
import Mathlib.Topology.Algebra.Module.Equiv
import Mathlib.Topology.Algebra.Module.LinearPMap
/-!
# Partially defined linear operators on Hilbert spaces
We will develop the basics of the theory of unbounded operators on Hilbert spaces.
## Main definitions
* `LinearPMap.IsFormalAdjoint`: An operator `T` is a formal adjoint of `S` if for all `x` in the
domain of `T` and `y` in the domain of `S`, we have that `⟪T x, y⟫ = ⟪x, S y⟫`.
* `LinearPMap.adjoint`: The adjoint of a map `E →ₗ.[𝕜] F` as a map `F →ₗ.[𝕜] E`.
## Main statements
* `LinearPMap.adjoint_isFormalAdjoint`: The adjoint is a formal adjoint
* `LinearPMap.IsFormalAdjoint.le_adjoint`: Every formal adjoint is contained in the adjoint
* `ContinuousLinearMap.toPMap_adjoint_eq_adjoint_toPMap_of_dense`: The adjoint on
`ContinuousLinearMap` and `LinearPMap` coincide.
* `LinearPMap.adjoint_isClosed`: The adjoint is a closed operator.
* `IsSelfAdjoint.isClosed`: Every self-adjoint operator is closed.
## Notation
* For `T : E →ₗ.[𝕜] F` the adjoint can be written as `T†`.
This notation is localized in `LinearPMap`.
## Implementation notes
We use the junk value pattern to define the adjoint for all `LinearPMap`s. In the case that
`T : E →ₗ.[𝕜] F` is not densely defined the adjoint `T†` is the zero map from `T.adjoint.domain` to
`E`.
## References
* [J. Weidmann, *Linear Operators in Hilbert Spaces*][weidmann_linear]
## Tags
Unbounded operators, closed operators
-/
noncomputable section
open RCLike LinearPMap WithLp
open scoped ComplexConjugate
variable {𝕜 E F : Type*} [RCLike 𝕜]
variable [NormedAddCommGroup E] [InnerProductSpace 𝕜 E]
variable [NormedAddCommGroup F] [InnerProductSpace 𝕜 F]
local notation "⟪" x ", " y "⟫" => inner 𝕜 x y
namespace LinearPMap
/-- An operator `T` is a formal adjoint of `S` if for all `x` in the domain of `T` and `y` in the
domain of `S`, we have that `⟪T x, y⟫ = ⟪x, S y⟫`. -/
def IsFormalAdjoint (T : E →ₗ.[𝕜] F) (S : F →ₗ.[𝕜] E) : Prop :=
∀ (x : T.domain) (y : S.domain), ⟪T x, y⟫ = ⟪(x : E), S y⟫
variable {T : E →ₗ.[𝕜] F} {S : F →ₗ.[𝕜] E}
@[symm]
protected theorem IsFormalAdjoint.symm (h : T.IsFormalAdjoint S) :
S.IsFormalAdjoint T := fun y _ => by
rw [← inner_conj_symm, ← inner_conj_symm (y : F), h]
variable (T)
/-- The domain of the adjoint operator.
This definition is needed to construct the adjoint operator and the preferred version to use is
`T.adjoint.domain` instead of `T.adjointDomain`. -/
def adjointDomain : Submodule 𝕜 F where
carrier := {y | Continuous ((innerₛₗ 𝕜 y).comp T.toFun)}
zero_mem' := by
rw [Set.mem_setOf_eq, LinearMap.map_zero, LinearMap.zero_comp]
exact continuous_zero
add_mem' hx hy := by rw [Set.mem_setOf_eq, LinearMap.map_add] at *; exact hx.add hy
smul_mem' a x hx := by
rw [Set.mem_setOf_eq, LinearMap.map_smulₛₗ] at *
exact hx.const_smul (conj a)
/-- The operator `fun x ↦ ⟪y, T x⟫` considered as a continuous linear operator
from `T.adjointDomain` to `𝕜`. -/
def adjointDomainMkCLM (y : T.adjointDomain) : StrongDual 𝕜 T.domain :=
⟨(innerₛₗ 𝕜 (y : F)).comp T.toFun, y.prop⟩
theorem adjointDomainMkCLM_apply (y : T.adjointDomain) (x : T.domain) :
adjointDomainMkCLM T y x = ⟪(y : F), T x⟫ :=
rfl
variable {T}
variable (hT : Dense (T.domain : Set E))
/-- The unique continuous extension of the operator `adjointDomainMkCLM` to `E`. -/
def adjointDomainMkCLMExtend (y : T.adjointDomain) : StrongDual 𝕜 E :=
(T.adjointDomainMkCLM y).extend (Submodule.subtypeL T.domain) hT.denseRange_val
isUniformEmbedding_subtype_val.isUniformInducing
@[simp]
theorem adjointDomainMkCLMExtend_apply (y : T.adjointDomain) (x : T.domain) :
adjointDomainMkCLMExtend hT y (x : E) = ⟪(y : F), T x⟫ :=
ContinuousLinearMap.extend_eq _ _ _ _ _
variable [CompleteSpace E]
/-- The adjoint as a linear map from its domain to `E`.
This is an auxiliary definition needed to define the adjoint operator as a `LinearPMap` without
the assumption that `T.domain` is dense. -/
def adjointAux : T.adjointDomain →ₗ[𝕜] E where
toFun y := (InnerProductSpace.toDual 𝕜 E).symm (adjointDomainMkCLMExtend hT y)
map_add' x y :=
hT.eq_of_inner_left fun _ => by
simp only [inner_add_left, Submodule.coe_add, InnerProductSpace.toDual_symm_apply,
adjointDomainMkCLMExtend_apply]
map_smul' _ _ :=
hT.eq_of_inner_left fun _ => by
simp only [inner_smul_left, Submodule.coe_smul_of_tower, RingHom.id_apply,
InnerProductSpace.toDual_symm_apply, adjointDomainMkCLMExtend_apply]
theorem adjointAux_inner (y : T.adjointDomain) (x : T.domain) :
⟪adjointAux hT y, x⟫ = ⟪(y : F), T x⟫ := by
simp [adjointAux]
theorem adjointAux_unique (y : T.adjointDomain) {x₀ : E}
(hx₀ : ∀ x : T.domain, ⟪x₀, x⟫ = ⟪(y : F), T x⟫) : adjointAux hT y = x₀ :=
hT.eq_of_inner_left fun v => (adjointAux_inner hT _ _).trans (hx₀ v).symm
variable (T)
open scoped Classical in
/-- The adjoint operator as a partially defined linear operator, denoted as `T†`. -/
def adjoint : F →ₗ.[𝕜] E where
domain := T.adjointDomain
toFun := if hT : Dense (T.domain : Set E) then adjointAux hT else 0
@[inherit_doc]
scoped postfix:1024 "†" => LinearPMap.adjoint
theorem mem_adjoint_domain_iff (y : F) : y ∈ T†.domain ↔ Continuous ((innerₛₗ 𝕜 y).comp T.toFun) :=
Iff.rfl
variable {T}
theorem mem_adjoint_domain_of_exists (y : F) (h : ∃ w : E, ∀ x : T.domain, ⟪w, x⟫ = ⟪y, T x⟫) :
y ∈ T†.domain := by
obtain ⟨w, hw⟩ := h
rw [T.mem_adjoint_domain_iff]
have : Continuous ((innerSL 𝕜 w).comp T.domain.subtypeL) := by fun_prop
convert this using 1
exact funext fun x => (hw x).symm
theorem adjoint_apply_of_not_dense (hT : ¬Dense (T.domain : Set E)) (y : T†.domain) : T† y = 0 := by
classical
change (if hT : Dense (T.domain : Set E) then adjointAux hT else 0) y = _
simp only [hT, not_false_iff, dif_neg, LinearMap.zero_apply]
theorem adjoint_apply_of_dense (y : T†.domain) : T† y = adjointAux hT y := by
classical
change (if hT : Dense (T.domain : Set E) then adjointAux hT else 0) y = _
simp only [hT, dif_pos]
include hT in
theorem adjoint_apply_eq (y : T†.domain) {x₀ : E} (hx₀ : ∀ x : T.domain, ⟪x₀, x⟫ = ⟪(y : F), T x⟫) :
T† y = x₀ :=
(adjoint_apply_of_dense hT y).symm ▸ adjointAux_unique hT _ hx₀
include hT in
/-- The fundamental property of the adjoint. -/
theorem adjoint_isFormalAdjoint : T†.IsFormalAdjoint T := fun x =>
(adjoint_apply_of_dense hT x).symm ▸ adjointAux_inner hT x
include hT in
/-- The adjoint is maximal in the sense that it contains every formal adjoint. -/
theorem IsFormalAdjoint.le_adjoint (h : T.IsFormalAdjoint S) : S ≤ T† :=
⟨-- Trivially, every `x : S.domain` is in `T.adjoint.domain`
fun x hx =>
mem_adjoint_domain_of_exists _
⟨S ⟨x, hx⟩, h.symm ⟨x, hx⟩⟩,-- Equality on `S.domain` follows from equality
-- `⟪v, S x⟫ = ⟪v, T.adjoint y⟫` for all `v : T.domain`:
fun _ _ hxy => (adjoint_apply_eq hT _ fun _ => by rw [h.symm, hxy]).symm⟩
end LinearPMap
namespace ContinuousLinearMap
variable [CompleteSpace E] [CompleteSpace F]
variable (A : E →L[𝕜] F) {p : Submodule 𝕜 E}
/-- Restricting `A` to a dense submodule and taking the `LinearPMap.adjoint` is the same
as taking the `ContinuousLinearMap.adjoint` interpreted as a `LinearPMap`. -/
theorem toPMap_adjoint_eq_adjoint_toPMap_of_dense (hp : Dense (p : Set E)) :
(A.toPMap p).adjoint = A.adjoint.toPMap ⊤ := by
ext x y hxy
· simp only [LinearMap.toPMap_domain, Submodule.mem_top, iff_true,
LinearPMap.mem_adjoint_domain_iff, LinearMap.coe_comp, coe_innerₛₗ_apply]
exact ((innerSL 𝕜 x).comp <| A.comp <| Submodule.subtypeL _).cont
refine LinearPMap.adjoint_apply_eq hp _ fun v => ?_
simp only [adjoint_inner_left, LinearMap.toPMap_apply, coe_coe]
end ContinuousLinearMap
section Star
namespace LinearPMap
variable [CompleteSpace E]
instance instStar : Star (E →ₗ.[𝕜] E) where
star := fun A ↦ A.adjoint
variable {A : E →ₗ.[𝕜] E}
theorem isSelfAdjoint_def : IsSelfAdjoint A ↔ A† = A := Iff.rfl
/-- Every self-adjoint `LinearPMap` has dense domain.
This is not true by definition since we define the adjoint without the assumption that the
domain is dense, but the choice of the junk value implies that a `LinearPMap` cannot be self-adjoint
if it does not have dense domain. -/
theorem _root_.IsSelfAdjoint.dense_domain (hA : IsSelfAdjoint A) : Dense (A.domain : Set E) := by
by_contra h
rw [isSelfAdjoint_def] at hA
have h' : A.domain = ⊤ := by
rw [← hA, Submodule.eq_top_iff']
intro x
rw [mem_adjoint_domain_iff, ← hA]
refine (innerSL 𝕜 x).cont.comp ?_
simp only [adjoint, h]
exact continuous_const
simp [h'] at h
end LinearPMap
end Star
/-! ### The graph of the adjoint -/
namespace Submodule
/-- The adjoint of a submodule
Note that the adjoint is taken with respect to the L^2 inner product on `E × F`, which is defined
as `WithLp 2 (E × F)`. -/
protected noncomputable
def adjoint (g : Submodule 𝕜 (E × F)) : Submodule 𝕜 (F × E) :=
(g.map <| (LinearEquiv.skewSwap 𝕜 F E).symm.trans
(WithLp.linearEquiv 2 𝕜 (F × E)).symm).orthogonal.map (WithLp.linearEquiv 2 𝕜 (F × E))
@[simp]
theorem mem_adjoint_iff (g : Submodule 𝕜 (E × F)) (x : F × E) :
x ∈ g.adjoint ↔
∀ a b, (a, b) ∈ g → inner 𝕜 b x.fst - inner 𝕜 a x.snd = 0 := by
simp only [Submodule.adjoint, mem_map, mem_orthogonal, LinearEquiv.trans_apply,
LinearEquiv.skewSwap_symm_apply, WithLp.linearEquiv_symm_apply, Prod.exists,
WithLp.prod_inner_apply, WithLp.ofLp_fst, WithLp.ofLp_snd, forall_exists_index, and_imp,
WithLp.linearEquiv_apply]
constructor
· rintro ⟨y, h1, h2⟩ a b hab
rw [← h2, WithLp.ofLp_fst, WithLp.ofLp_snd]
specialize h1 (toLp 2 (b, -a)) a b hab rfl
dsimp at h1
simp only [inner_neg_left, ← sub_eq_add_neg] at h1
exact h1
· intro h
refine ⟨toLp 2 x, ?_, rfl⟩
intro u a b hab hu
simp [← hu, ← sub_eq_add_neg, h a b hab]
variable {T : E →ₗ.[𝕜] F} [CompleteSpace E]
theorem _root_.LinearPMap.adjoint_graph_eq_graph_adjoint (hT : Dense (T.domain : Set E)) :
T†.graph = T.graph.adjoint := by
ext x
simp only [mem_graph_iff, Subtype.exists, exists_and_left, exists_eq_left, mem_adjoint_iff,
forall_exists_index, forall_apply_eq_imp_iff]
constructor
· rintro ⟨hx, h⟩ a ha
rw [← h, (adjoint_isFormalAdjoint hT).symm ⟨a, ha⟩ ⟨x.fst, hx⟩, sub_self]
· intro h
simp_rw [sub_eq_zero] at h
have hx : x.fst ∈ T†.domain := by
apply mem_adjoint_domain_of_exists
use x.snd
rintro ⟨a, ha⟩
rw [← inner_conj_symm, ← h a ha, inner_conj_symm]
use hx
apply hT.eq_of_inner_right
rintro ⟨a, ha⟩
rw [← h a ha, (adjoint_isFormalAdjoint hT).symm ⟨a, ha⟩ ⟨x.fst, hx⟩]
@[simp]
theorem _root_.LinearPMap.graph_adjoint_toLinearPMap_eq_adjoint (hT : Dense (T.domain : Set E)) :
T.graph.adjoint.toLinearPMap = T† := by
apply eq_of_eq_graph
rw [adjoint_graph_eq_graph_adjoint hT]
apply Submodule.toLinearPMap_graph_eq
intro x hx hx'
simp only [mem_adjoint_iff, mem_graph_iff, Subtype.exists, exists_and_left, exists_eq_left, hx',
inner_zero_right, zero_sub, neg_eq_zero, forall_exists_index, forall_apply_eq_imp_iff] at hx
apply hT.eq_zero_of_inner_right
rintro ⟨a, ha⟩
exact hx a ha
end Submodule
/-! ### Closedness -/
namespace LinearPMap
variable {T : E →ₗ.[𝕜] F} [CompleteSpace E]
theorem adjoint_isClosed (hT : Dense (T.domain : Set E)) :
T†.IsClosed := by
rw [IsClosed, adjoint_graph_eq_graph_adjoint hT, Submodule.adjoint]
simp only [Submodule.map_coe]
rw [LinearEquiv.image_eq_preimage_symm]
exact (Submodule.isClosed_orthogonal _).preimage (WithLp.prod_continuous_toLp _ _ _)
/-- Every self-adjoint `LinearPMap` is closed. -/
theorem _root_.IsSelfAdjoint.isClosed {A : E →ₗ.[𝕜] E} (hA : IsSelfAdjoint A) : A.IsClosed := by
rw [← isSelfAdjoint_def.mp hA]
exact adjoint_isClosed hA.dense_domain
end LinearPMap |
.lake/packages/mathlib/Mathlib/Analysis/InnerProductSpace/Symmetric.lean | import Mathlib.Analysis.InnerProductSpace.Subspace
import Mathlib.Analysis.Normed.Operator.Banach
import Mathlib.LinearAlgebra.SesquilinearForm.Basic
import Mathlib.Analysis.InnerProductSpace.Orthogonal
/-!
# Symmetric linear maps in an inner product space
This file defines and proves basic theorems about symmetric **not necessarily bounded** operators
on an inner product space, i.e linear maps `T : E → E` such that `∀ x y, ⟪T x, y⟫ = ⟪x, T y⟫`.
In comparison to `IsSelfAdjoint`, this definition works for non-continuous linear maps, and
doesn't rely on the definition of the adjoint, which allows it to be stated in non-complete space.
## Main definitions
* `LinearMap.IsSymmetric`: a (not necessarily bounded) operator on an inner product space is
symmetric, if for all `x`, `y`, we have `⟪T x, y⟫ = ⟪x, T y⟫`
## Main statements
* `IsSymmetric.continuous`: if a symmetric operator is defined on a complete space, then
it is automatically continuous.
## Tags
self-adjoint, symmetric
-/
open RCLike
open ComplexConjugate
section Seminormed
variable {𝕜 E : Type*} [RCLike 𝕜]
variable [SeminormedAddCommGroup E] [InnerProductSpace 𝕜 E]
local notation "⟪" x ", " y "⟫" => inner 𝕜 x y
namespace LinearMap
/-! ### Symmetric operators -/
/-- A (not necessarily bounded) operator on an inner product space is symmetric, if for all
`x`, `y`, we have `⟪T x, y⟫ = ⟪x, T y⟫`. -/
def IsSymmetric (T : E →ₗ[𝕜] E) : Prop :=
∀ x y, ⟪T x, y⟫ = ⟪x, T y⟫
section Real
/-- An operator `T` on an inner product space is symmetric if and only if it is
`LinearMap.IsSelfAdjoint` with respect to the sesquilinear form given by the inner product. -/
theorem isSymmetric_iff_sesqForm (T : E →ₗ[𝕜] E) :
T.IsSymmetric ↔ LinearMap.IsSelfAdjoint (R := 𝕜) (M := E) sesqFormOfInner T :=
⟨fun h x y => (h y x).symm, fun h x y => (h y x).symm⟩
end Real
theorem IsSymmetric.conj_inner_sym {T : E →ₗ[𝕜] E} (hT : IsSymmetric T) (x y : E) :
conj ⟪T x, y⟫ = ⟪T y, x⟫ := by rw [hT x y, inner_conj_symm]
@[simp]
theorem IsSymmetric.apply_clm {T : E →L[𝕜] E} (hT : IsSymmetric (T : E →ₗ[𝕜] E)) (x y : E) :
⟪T x, y⟫ = ⟪x, T y⟫ :=
hT x y
@[simp]
protected theorem IsSymmetric.zero : (0 : E →ₗ[𝕜] E).IsSymmetric := fun x y =>
(inner_zero_right x : ⟪x, 0⟫ = 0).symm ▸ (inner_zero_left y : ⟪0, y⟫ = 0)
@[simp]
protected theorem IsSymmetric.id : (LinearMap.id : E →ₗ[𝕜] E).IsSymmetric := fun _ _ => rfl
@[aesop safe apply]
theorem IsSymmetric.add {T S : E →ₗ[𝕜] E} (hT : T.IsSymmetric) (hS : S.IsSymmetric) :
(T + S).IsSymmetric := by
intro x y
rw [add_apply, inner_add_left, hT x y, hS x y, ← inner_add_right, add_apply]
@[aesop safe apply]
theorem IsSymmetric.sub {T S : E →ₗ[𝕜] E} (hT : T.IsSymmetric) (hS : S.IsSymmetric) :
(T - S).IsSymmetric := by
intro x y
rw [sub_apply, inner_sub_left, hT x y, hS x y, ← inner_sub_right, sub_apply]
@[aesop safe apply]
theorem IsSymmetric.smul {c : 𝕜} (hc : conj c = c) {T : E →ₗ[𝕜] E} (hT : T.IsSymmetric) :
c • T |>.IsSymmetric := by
intro x y
simp only [smul_apply, inner_smul_left, hc, hT x y, inner_smul_right]
theorem IsSymmetric.natCast (n : ℕ) : IsSymmetric (n : E →ₗ[𝕜] E) := fun x y => by
simp [← Nat.cast_smul_eq_nsmul 𝕜, inner_smul_left, inner_smul_right]
theorem IsSymmetric.intCast (n : ℤ) : IsSymmetric (n : E →ₗ[𝕜] E) := fun x y => by
simp [← Int.cast_smul_eq_zsmul 𝕜, inner_smul_left, inner_smul_right]
@[aesop 30% apply]
lemma IsSymmetric.mul_of_commute {S T : E →ₗ[𝕜] E} (hS : S.IsSymmetric) (hT : T.IsSymmetric)
(hST : Commute S T) : (S * T).IsSymmetric :=
fun _ _ ↦ by rw [Module.End.mul_apply, hS, hT, hST, Module.End.mul_apply]
@[aesop safe apply]
lemma IsSymmetric.pow {T : E →ₗ[𝕜] E} (hT : T.IsSymmetric) (n : ℕ) : (T ^ n).IsSymmetric := by
refine Nat.le_induction (by simp [Module.End.one_eq_id]) (fun k _ ih ↦ ?_) n n.zero_le
rw [Module.End.iterate_succ, ← Module.End.mul_eq_comp]
exact ih.mul_of_commute hT <| .pow_left rfl k
/-- For a symmetric operator `T`, the function `fun x ↦ ⟪T x, x⟫` is real-valued. -/
@[simp]
theorem IsSymmetric.coe_reApplyInnerSelf_apply {T : E →L[𝕜] E} (hT : IsSymmetric (T : E →ₗ[𝕜] E))
(x : E) : (T.reApplyInnerSelf x : 𝕜) = ⟪T x, x⟫ := by
rsuffices ⟨r, hr⟩ : ∃ r : ℝ, ⟪T x, x⟫ = r
· simp [hr, T.reApplyInnerSelf_apply]
rw [← conj_eq_iff_real]
exact hT.conj_inner_sym x x
/-- If a symmetric operator preserves a submodule, its restriction to that submodule is
symmetric. -/
theorem IsSymmetric.restrict_invariant {T : E →ₗ[𝕜] E} (hT : IsSymmetric T) {V : Submodule 𝕜 E}
(hV : ∀ v ∈ V, T v ∈ V) : IsSymmetric (T.restrict hV) := fun v w => hT v w
theorem IsSymmetric.restrictScalars {T : E →ₗ[𝕜] E} (hT : T.IsSymmetric) :
letI := InnerProductSpace.rclikeToReal 𝕜 E
letI : IsScalarTower ℝ 𝕜 E := RestrictScalars.isScalarTower _ _ _
(T.restrictScalars ℝ).IsSymmetric :=
fun x y => by simp [hT x y, real_inner_eq_re_inner, LinearMap.coe_restrictScalars ℝ]
@[simp]
theorem IsSymmetric.im_inner_apply_self {T : E →ₗ[𝕜] E} (hT : T.IsSymmetric) (x : E) :
im ⟪T x, x⟫ = 0 :=
conj_eq_iff_im.mp <| hT.conj_inner_sym x x
@[simp]
theorem IsSymmetric.im_inner_self_apply {T : E →ₗ[𝕜] E} (hT : T.IsSymmetric) (x : E) :
im ⟪x, T x⟫ = 0 := by
simp [← hT x x, hT]
@[simp]
theorem IsSymmetric.coe_re_inner_apply_self {T : E →ₗ[𝕜] E} (hT : T.IsSymmetric) (x : E) :
re ⟪T x, x⟫ = ⟪T x, x⟫ :=
conj_eq_iff_re.mp <| hT.conj_inner_sym x x
@[simp]
theorem IsSymmetric.coe_re_inner_self_apply {T : E →ₗ[𝕜] E} (hT : T.IsSymmetric) (x : E) :
re ⟪x, T x⟫ = ⟪x, T x⟫ := by
simp [← hT x x, hT]
/-- A symmetric projection is a symmetric idempotent. -/
@[mk_iff]
structure IsSymmetricProjection (T : E →ₗ[𝕜] E) : Prop where
isIdempotentElem : IsIdempotentElem T
isSymmetric : T.IsSymmetric
section Complex
variable {V : Type*} [SeminormedAddCommGroup V] [InnerProductSpace ℂ V]
attribute [local simp] map_ofNat in -- use `ofNat` simp theorem with bad keys
open scoped InnerProductSpace in
/-- A linear operator on a complex inner product space is symmetric precisely when
`⟪T v, v⟫_ℂ` is real for all v. -/
theorem isSymmetric_iff_inner_map_self_real (T : V →ₗ[ℂ] V) :
IsSymmetric T ↔ ∀ v : V, conj ⟪T v, v⟫_ℂ = ⟪T v, v⟫_ℂ := by
constructor
· intro hT v
apply IsSymmetric.conj_inner_sym hT
· intro h x y
rw [← inner_conj_symm x (T y)]
rw [inner_map_polarization T x y]
simp only [starRingEnd_apply, star_div₀, star_sub, star_add, star_mul]
simp only [← starRingEnd_apply]
rw [h (x + y), h (x - y), h (x + Complex.I • y), h (x - Complex.I • y)]
simp only [Complex.conj_I]
rw [inner_map_polarization']
norm_num
ring
end Complex
/-- Polarization identity for symmetric linear maps.
See `inner_map_polarization` for the complex version without the symmetric assumption. -/
theorem IsSymmetric.inner_map_polarization {T : E →ₗ[𝕜] E} (hT : T.IsSymmetric) (x y : E) :
⟪T x, y⟫ =
(⟪T (x + y), x + y⟫ - ⟪T (x - y), x - y⟫ - I * ⟪T (x + (I : 𝕜) • y), x + (I : 𝕜) • y⟫ +
I * ⟪T (x - (I : 𝕜) • y), x - (I : 𝕜) • y⟫) /
4 := by
rcases@I_mul_I_ax 𝕜 _ with (h | h)
· simp_rw [h, zero_mul, sub_zero, add_zero, map_add, map_sub, inner_add_left,
inner_add_right, inner_sub_left, inner_sub_right, hT x, ← inner_conj_symm x (T y)]
suffices (re ⟪T y, x⟫ : 𝕜) = ⟪T y, x⟫ by
rw [conj_eq_iff_re.mpr this]
ring
rw [← re_add_im ⟪T y, x⟫]
simp_rw [h, mul_zero, add_zero]
norm_cast
· simp_rw [map_add, map_sub, inner_add_left, inner_add_right, inner_sub_left, inner_sub_right,
LinearMap.map_smul, inner_smul_left, inner_smul_right, RCLike.conj_I, mul_add, mul_sub,
sub_sub, ← mul_assoc, mul_neg, h, neg_neg, one_mul, neg_one_mul]
ring
theorem isSymmetric_linearIsometryEquiv_conj_iff {F : Type*} [SeminormedAddCommGroup F]
[InnerProductSpace 𝕜 F] (T : E →ₗ[𝕜] E) (f : E ≃ₗᵢ[𝕜] F) :
(f.toLinearMap ∘ₗ T ∘ₗ f.symm.toLinearMap).IsSymmetric ↔ T.IsSymmetric := by
refine ⟨fun h x y => ?_, fun h x y => ?_⟩
· simpa [LinearIsometryEquiv.inner_map_eq_flip] using h (f x) (f y)
· simp [LinearIsometryEquiv.inner_map_eq_flip, h _ (f.symm y)]
end LinearMap
end Seminormed
section Normed
variable {𝕜 E : Type*} [RCLike 𝕜]
variable [NormedAddCommGroup E] [InnerProductSpace 𝕜 E]
local notation "⟪" x ", " y "⟫" => inner 𝕜 x y
namespace LinearMap
/-- The **Hellinger--Toeplitz theorem**: if a symmetric operator is defined on a complete space,
then it is automatically continuous. -/
theorem IsSymmetric.continuous [CompleteSpace E] {T : E →ₗ[𝕜] E} (hT : IsSymmetric T) :
Continuous T := by
-- We prove it by using the closed graph theorem
refine T.continuous_of_seq_closed_graph fun u x y hu hTu => ?_
rw [← sub_eq_zero, ← @inner_self_eq_zero 𝕜]
have hlhs : ∀ k : ℕ, ⟪T (u k) - T x, y - T x⟫ = ⟪u k - x, T (y - T x)⟫ := by
intro k
rw [← T.map_sub, hT]
refine tendsto_nhds_unique ((hTu.sub_const _).inner tendsto_const_nhds) ?_
simp_rw [Function.comp_apply, hlhs]
rw [← inner_zero_left (T (y - T x))]
refine Filter.Tendsto.inner ?_ tendsto_const_nhds
rw [← sub_self x]
exact hu.sub_const _
/-- A symmetric linear map `T` is zero if and only if `⟪T x, x⟫_ℝ = 0` for all `x`.
See `inner_map_self_eq_zero` for the complex version without the symmetric assumption. -/
theorem IsSymmetric.inner_map_self_eq_zero {T : E →ₗ[𝕜] E} (hT : T.IsSymmetric) :
(∀ x, ⟪T x, x⟫ = 0) ↔ T = 0 := by
simp_rw [LinearMap.ext_iff, zero_apply]
refine ⟨fun h x => ?_, fun h => by simp_rw [h, inner_zero_left, forall_const]⟩
rw [← @inner_self_eq_zero 𝕜, hT.inner_map_polarization]
simp_rw [h _]
ring
theorem ker_le_ker_of_range {S T : E →ₗ[𝕜] E} (hS : S.IsSymmetric) (hT : T.IsSymmetric)
(h : range S ≤ range T) : ker T ≤ ker S := by
intro v hv
rw [mem_ker] at hv ⊢
obtain ⟨y, hy⟩ : ∃ y, T y = S (S v) := by simpa using @h (S (S v))
rw [← inner_self_eq_zero (𝕜 := 𝕜), ← hS, ← hy, hT, hv, inner_zero_right]
open Submodule in
/-- A linear projection onto `U` along its complement `V` is symmetric if
and only if `U` and `V` are pairwise orthogonal. -/
theorem _root_.Submodule.IsCompl.projection_isSymmetric_iff
{U V : Submodule 𝕜 E} (hUV : IsCompl U V) :
hUV.projection.IsSymmetric ↔ U ⟂ V := by
rw [IsCompl.projection]
refine ⟨fun h u hu v hv => ?_, fun h x y => ?_⟩
· rw [← Subtype.coe_mk u hu, ← Subtype.coe_mk v hv,
← Submodule.linearProjOfIsCompl_apply_left hUV ⟨u, hu⟩, ← U.subtype_apply, ← comp_apply,
← h, comp_apply, Submodule.linearProjOfIsCompl_apply_right hUV ⟨v, hv⟩,
map_zero, inner_zero_left]
· nth_rw 2 [← hUV.projection_add_projection_eq_self x]
nth_rw 1 [← hUV.projection_add_projection_eq_self y]
rw [isOrtho_iff_inner_eq] at h
simp [inner_add_right, inner_add_left, h, inner_eq_zero_symm]
open Submodule in
theorem _root_.Submodule.IsCompl.projection_isSymmetricProjection_iff
{U V : Submodule 𝕜 E} (hUV : IsCompl U V) :
hUV.projection.IsSymmetricProjection ↔ U ⟂ V := by
simp [isSymmetricProjection_iff, hUV.projection_isSymmetric_iff, hUV.projection_isIdempotentElem]
alias ⟨_, _root_.Submodule.IsCompl.projection_isSymmetricProjection_of_isOrtho⟩ :=
_root_.Submodule.IsCompl.projection_isSymmetricProjection_iff
open Submodule LinearMap in
/-- An idempotent operator is symmetric if and only if its range is
pairwise orthogonal to its kernel. -/
theorem IsIdempotentElem.isSymmetric_iff_isOrtho_range_ker {T : E →ₗ[𝕜] E}
(hT : IsIdempotentElem T) : T.IsSymmetric ↔ (LinearMap.range T) ⟂ (LinearMap.ker T) := by
rw [← IsCompl.projection_isSymmetric_iff hT.isProj_range.isCompl, ← hT.eq_isCompl_projection]
theorem IsSymmetric.orthogonal_range {T : E →ₗ[𝕜] E} (hT : LinearMap.IsSymmetric T) :
(LinearMap.range T)ᗮ = LinearMap.ker T := by
ext x
constructor
· simpa [Submodule.mem_orthogonal, hT _ x] using ext_inner_left 𝕜 (x := T x) (y := 0)
· simp_all [Submodule.mem_orthogonal, hT _ x]
open Submodule LinearMap in
theorem IsIdempotentElem.isSymmetric_iff_orthogonal_range {T : E →ₗ[𝕜] E}
(h : IsIdempotentElem T) : T.IsSymmetric ↔ (LinearMap.range T)ᗮ = (LinearMap.ker T) :=
⟨fun hT => hT.orthogonal_range, fun hT =>
h.isSymmetric_iff_isOrtho_range_ker.eq ▸ hT.symm ▸ isOrtho_orthogonal_right _⟩
open LinearMap in
/-- Symmetric projections are equal iff their range are. -/
theorem IsSymmetricProjection.ext_iff {S T : E →ₗ[𝕜] E}
(hS : S.IsSymmetricProjection) (hT : T.IsSymmetricProjection) :
S = T ↔ LinearMap.range S = LinearMap.range T := by
refine ⟨fun h => h ▸ rfl, fun h => ?_⟩
rw [hS.isIdempotentElem.ext_iff hT.isIdempotentElem,
← hT.isIdempotentElem.isSymmetric_iff_orthogonal_range.mp hT.isSymmetric,
← hS.isIdempotentElem.isSymmetric_iff_orthogonal_range.mp hS.isSymmetric]
simp [h]
alias ⟨_, IsSymmetricProjection.ext⟩ := IsSymmetricProjection.ext_iff
open LinearMap in
theorem IsSymmetricProjection.sub_of_range_le_range {p q : E →ₗ[𝕜] E}
(hp : p.IsSymmetricProjection) (hq : q.IsSymmetricProjection) (hqp : range p ≤ range q) :
(q - p).IsSymmetricProjection := by
rw [← hq.isIdempotentElem.comp_eq_right_iff] at hqp
refine ⟨hp.isIdempotentElem.sub hq.isIdempotentElem (LinearMap.ext fun x => ext_inner_left 𝕜
fun y => ?_) hqp, hq.isSymmetric.sub hp.isSymmetric⟩
simp_rw [Module.End.mul_apply, ← hp.isSymmetric _, ← hq.isSymmetric _, ← comp_apply, hqp]
end LinearMap
open ContinuousLinearMap in
/-- An idempotent operator `T` is symmetric iff `(range T)ᗮ = ker T`. -/
theorem ContinuousLinearMap.IsIdempotentElem.isSymmetric_iff_orthogonal_range
{T : E →L[𝕜] E} (h : IsIdempotentElem T) :
T.IsSymmetric ↔ (LinearMap.range T)ᗮ = LinearMap.ker T :=
LinearMap.IsIdempotentElem.isSymmetric_iff_orthogonal_range h.toLinearMap
end Normed |
.lake/packages/mathlib/Mathlib/Analysis/InnerProductSpace/Projection.lean | import Mathlib.Analysis.InnerProductSpace.Projection.Basic
import Mathlib.Analysis.InnerProductSpace.Projection.FiniteDimensional
import Mathlib.Analysis.InnerProductSpace.Projection.Minimal
import Mathlib.Analysis.InnerProductSpace.Projection.Reflection
import Mathlib.Analysis.InnerProductSpace.Projection.Submodule
deprecated_module (since := "2025-08-08") |
.lake/packages/mathlib/Mathlib/Analysis/InnerProductSpace/CanonicalTensor.lean | import Mathlib.Analysis.InnerProductSpace.PiL2
/-!
# Canonical tensors in real inner product spaces
Given an `InnerProductSpace ℝ E`, this file defines two canonical tensors.
* `InnerProductSpace.canonicalContravariantTensor E : E ⊗[ℝ] E →ₗ[ℝ] ℝ`. This is the element
corresponding to the inner product.
* If `E` is finite-dimensional, then `E ⊗[ℝ] E` is canonically isomorphic to its dual. Accordingly,
there exists an element `InnerProductSpace.canonicalCovariantTensor E : E ⊗[ℝ] E` that
corresponds to `InnerProductSpace.canonicalContravariantTensor E` under this identification.
The theorem `canonicalCovariantTensor_eq_sum` shows that
`InnerProductSpace.canonicalCovariantTensor E` can be computed from any orthonormal basis `v` as
`∑ i, (v i) ⊗ₜ[ℝ] (v i)`.
-/
open InnerProductSpace TensorProduct
variable (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ℝ E]
/-- The canonical contravariant tensor corresponding to the inner product -/
noncomputable def InnerProductSpace.canonicalContravariantTensor :
E ⊗[ℝ] E →ₗ[ℝ] ℝ := lift bilinFormOfRealInner
/--
The canonical covariant tensor corresponding to `InnerProductSpace.canonicalContravariantTensor`
under the identification of `E` with its dual.
-/
noncomputable def InnerProductSpace.canonicalCovariantTensor [FiniteDimensional ℝ E] :
E ⊗[ℝ] E := ∑ i, ((stdOrthonormalBasis ℝ E) i) ⊗ₜ[ℝ] ((stdOrthonormalBasis ℝ E) i)
/-- Representation of the canonical covariant tensor in terms of an orthonormal basis. -/
theorem InnerProductSpace.canonicalCovariantTensor_eq_sum [FiniteDimensional ℝ E]
{ι : Type*} [Fintype ι] (v : OrthonormalBasis ι ℝ E) :
InnerProductSpace.canonicalCovariantTensor E = ∑ i, (v i) ⊗ₜ[ℝ] (v i) := by
let w := stdOrthonormalBasis ℝ E
calc ∑ m, w m ⊗ₜ[ℝ] w m
_ = ∑ m, ∑ n, ⟪w m, w n⟫_ℝ • w m ⊗ₜ[ℝ] w n := by
congr 1 with m
rw [Fintype.sum_eq_single m _, orthonormal_iff_ite.1 w.orthonormal]
· simp only [↓reduceIte, one_smul]
simp only [orthonormal_iff_ite.1 w.orthonormal, ite_smul, one_smul, zero_smul,
ite_eq_right_iff]
tauto
_ = ∑ m, ∑ n, (∑ i, ⟪w m, v i⟫_ℝ * ⟪v i, w n⟫_ℝ) • w m ⊗ₜ[ℝ] w n := by
simp_rw [OrthonormalBasis.sum_inner_mul_inner v]
_ = ∑ m, ∑ n, (∑ i, ⟪w m, v i⟫_ℝ * ⟪w n, v i⟫_ℝ) • w m ⊗ₜ[ℝ] w n := by
simp only [real_inner_comm (w _)]
_ = ∑ i, (∑ m, ⟪w m, v i⟫_ℝ • w m) ⊗ₜ[ℝ] ∑ n, ⟪w n, v i⟫_ℝ • w n := by
simp only [sum_tmul, tmul_sum, smul_tmul_smul, Finset.sum_comm (γ := ι), Finset.sum_smul]
rw [Finset.sum_comm]
_ = ∑ i, v i ⊗ₜ[ℝ] v i := by
simp only [w.sum_repr' (v _)] |
.lake/packages/mathlib/Mathlib/Analysis/InnerProductSpace/ProdL2.lean | import Mathlib.Analysis.InnerProductSpace.PiL2
import Mathlib.Analysis.Normed.Lp.ProdLp
/-!
# `L²` inner product space structure on products of inner product spaces
The `L²` norm on product of two inner product spaces is compatible with an inner product
$$
\langle x, y\rangle = \langle x_1, y_1 \rangle + \langle x_2, y_2 \rangle.
$$
This is recorded in this file as an inner product space instance on `WithLp 2 (E × F)`.
-/
open Module
open scoped InnerProductSpace
variable {𝕜 ι₁ ι₂ E F : Type*}
variable [RCLike 𝕜] [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] [NormedAddCommGroup F]
[InnerProductSpace 𝕜 F]
namespace WithLp
noncomputable instance instProdInnerProductSpace :
InnerProductSpace 𝕜 (WithLp 2 (E × F)) where
inner x y := ⟪x.fst, y.fst⟫_𝕜 + ⟪x.snd, y.snd⟫_𝕜
norm_sq_eq_re_inner x := by
simp [prod_norm_sq_eq_of_L2]
conj_inner_symm x y := by
simp
add_left x y z := by
simp only [add_fst, add_snd, inner_add_left]
ring
smul_left x y r := by
simp only [smul_fst, inner_smul_left, smul_snd]
ring
@[simp]
theorem prod_inner_apply (x y : WithLp 2 (E × F)) :
⟪x, y⟫_𝕜 = ⟪(ofLp x).fst, (ofLp y).fst⟫_𝕜 + ⟪(ofLp x).snd, (ofLp y).snd⟫_𝕜 := rfl
end WithLp
noncomputable section
namespace OrthonormalBasis
variable [Fintype ι₁] [Fintype ι₂]
/-- The product of two orthonormal bases is a basis for the L2-product. -/
def prod (v : OrthonormalBasis ι₁ 𝕜 E) (w : OrthonormalBasis ι₂ 𝕜 F) :
OrthonormalBasis (ι₁ ⊕ ι₂) 𝕜 (WithLp 2 (E × F)) :=
((v.toBasis.prod w.toBasis).map (WithLp.linearEquiv 2 𝕜 (E × F)).symm).toOrthonormalBasis
(by
constructor
· simp
· unfold Pairwise
simp only [ne_eq, Basis.map_apply, Basis.prod_apply, LinearMap.coe_inl,
OrthonormalBasis.coe_toBasis, LinearMap.coe_inr, WithLp.linearEquiv_symm_apply,
WithLp.prod_inner_apply, Sum.forall, Sum.elim_inl, Function.comp_apply, inner_zero_right,
add_zero, Sum.elim_inr, zero_add, Sum.inl.injEq, reduceCtorEq, not_false_eq_true,
inner_zero_left, imp_self, implies_true, and_true, Sum.inr.injEq, true_and]
exact ⟨v.orthonormal.2, w.orthonormal.2⟩)
@[simp] theorem prod_apply (v : OrthonormalBasis ι₁ 𝕜 E) (w : OrthonormalBasis ι₂ 𝕜 F) :
∀ i : ι₁ ⊕ ι₂, v.prod w i =
Sum.elim ((WithLp.toLp 2) ∘ (LinearMap.inl 𝕜 E F) ∘ v)
((WithLp.toLp 2) ∘ (LinearMap.inr 𝕜 E F) ∘ w) i := by
rw [Sum.forall]
unfold OrthonormalBasis.prod
aesop
end OrthonormalBasis
end |
.lake/packages/mathlib/Mathlib/Analysis/InnerProductSpace/Affine.lean | import Mathlib.Analysis.InnerProductSpace.Basic
import Mathlib.Analysis.Normed.Group.AddTorsor
/-!
# Normed affine spaces over an inner product space
-/
variable {𝕜 V P : Type*}
section RCLike
variable [RCLike 𝕜] [NormedAddCommGroup V] [InnerProductSpace 𝕜 V] [MetricSpace P]
variable [NormedAddTorsor V P]
open scoped InnerProductSpace
theorem inner_vsub_left_eq_zero_symm {a b : P} {v : V} :
⟪a -ᵥ b, v⟫_𝕜 = 0 ↔ ⟪b -ᵥ a, v⟫_𝕜 = 0 := by
rw [← neg_vsub_eq_vsub_rev, inner_neg_left, neg_eq_zero]
theorem inner_vsub_right_eq_zero_symm {v : V} {a b : P} :
⟪v, a -ᵥ b⟫_𝕜 = 0 ↔ ⟪v, b -ᵥ a⟫_𝕜 = 0 := by
rw [← neg_vsub_eq_vsub_rev, inner_neg_right, neg_eq_zero]
end RCLike
section Real
variable [NormedAddCommGroup V] [InnerProductSpace ℝ V] [MetricSpace P]
variable [NormedAddTorsor V P]
open scoped RealInnerProductSpace
/-!
In this section, the first `left`/`right` indicates where the common argument to `vsub` is,
and the section refers to the argument of `inner` that ends up in the `dist`.
The lemma shapes are such that the relevant argument of `inner` remains unchanged,
and that the other `vsub` preserves the position of the unchanging argument. -/
theorem inner_vsub_vsub_left_eq_dist_sq_left_iff {a b c : P} :
⟪a -ᵥ b, a -ᵥ c⟫ = dist a b ^ 2 ↔ ⟪a -ᵥ b, b -ᵥ c⟫ = 0 := by
rw [dist_eq_norm_vsub V, inner_eq_norm_sq_left_iff, vsub_sub_vsub_cancel_left,
inner_vsub_right_eq_zero_symm]
theorem inner_vsub_vsub_left_eq_dist_sq_right_iff {a b c : P} :
⟪a -ᵥ b, a -ᵥ c⟫ = dist a c ^ 2 ↔ ⟪c -ᵥ b, a -ᵥ c⟫ = 0 := by
rw [real_inner_comm, inner_vsub_vsub_left_eq_dist_sq_left_iff, real_inner_comm]
theorem inner_vsub_vsub_right_eq_dist_sq_left_iff {a b c : P} :
⟪a -ᵥ c, b -ᵥ c⟫ = dist a c ^ 2 ↔ ⟪a -ᵥ c, b -ᵥ a⟫ = 0 := by
rw [dist_eq_norm_vsub V, inner_eq_norm_sq_left_iff, vsub_sub_vsub_cancel_right,
inner_vsub_right_eq_zero_symm]
theorem inner_vsub_vsub_right_eq_dist_sq_right_iff {a b c : P} :
⟪a -ᵥ c, b -ᵥ c⟫ = dist b c ^ 2 ↔ ⟪a -ᵥ b, b -ᵥ c⟫ = 0 := by
rw [real_inner_comm, inner_vsub_vsub_right_eq_dist_sq_left_iff, real_inner_comm]
end Real |
.lake/packages/mathlib/Mathlib/Analysis/InnerProductSpace/Semisimple.lean | import Mathlib.Analysis.InnerProductSpace.Projection.Submodule
import Mathlib.LinearAlgebra.Semisimple
/-!
# Semisimple operators on inner product spaces
This file is a place to gather results related to semisimplicity of linear operators on inner
product spaces.
-/
variable {𝕜 E : Type*} [RCLike 𝕜] [NormedAddCommGroup E] [InnerProductSpace 𝕜 E]
namespace LinearMap.IsSymmetric
variable {T : Module.End 𝕜 E} {p : Submodule 𝕜 E} (hT : T.IsSymmetric)
include hT
/-- The orthogonal complement of an invariant submodule is invariant. -/
lemma orthogonalComplement_mem_invtSubmodule (hp : p ∈ T.invtSubmodule) :
pᗮ ∈ T.invtSubmodule :=
fun x hx y hy ↦ hT y x ▸ hx (T y) (hp hy)
/-- Symmetric operators are semisimple on finite-dimensional subspaces. -/
theorem isFinitelySemisimple :
T.IsFinitelySemisimple := by
refine Module.End.isFinitelySemisimple_iff.mpr fun p hp₁ hp₂ q hq₁ hq₂ ↦
⟨qᗮ ⊓ p, inf_le_right, Module.End.invtSubmodule.inf_mem ?_ hp₁, ?_, ?_⟩
· exact orthogonalComplement_mem_invtSubmodule hT hq₁
· simp [disjoint_iff, ← inf_assoc, Submodule.inf_orthogonal_eq_bot q]
· suffices q ⊔ qᗮ = ⊤ by rw [← sup_inf_assoc_of_le _ hq₂, this, top_inf_eq p]
replace hp₂ : Module.Finite 𝕜 q := Submodule.finiteDimensional_of_le hq₂
exact Submodule.sup_orthogonal_of_hasOrthogonalProjection
end LinearMap.IsSymmetric |
.lake/packages/mathlib/Mathlib/Analysis/InnerProductSpace/Spectrum.lean | import Mathlib.Analysis.InnerProductSpace.Rayleigh
import Mathlib.Analysis.InnerProductSpace.PiL2
import Mathlib.Algebra.DirectSum.Decomposition
import Mathlib.LinearAlgebra.Eigenspace.Minpoly
import Mathlib.Data.Fin.Tuple.Sort
/-! # Spectral theory of self-adjoint operators
This file covers the spectral theory of self-adjoint operators on an inner product space.
The first part of the file covers general properties, true without any condition on boundedness or
compactness of the operator or finite-dimensionality of the underlying space, notably:
* `LinearMap.IsSymmetric.conj_eigenvalue_eq_self`: the eigenvalues are real
* `LinearMap.IsSymmetric.orthogonalFamily_eigenspaces`: the eigenspaces are orthogonal
* `LinearMap.IsSymmetric.orthogonalComplement_iSup_eigenspaces`: the restriction of the operator to
the mutual orthogonal complement of the eigenspaces has, itself, no eigenvectors
The second part of the file covers properties of self-adjoint operators in finite dimension.
Letting `T` be a self-adjoint operator on a finite-dimensional inner product space `T`,
* The definition `LinearMap.IsSymmetric.diagonalization` provides a linear isometry equivalence `E`
to the direct sum of the eigenspaces of `T`. The theorem
`LinearMap.IsSymmetric.diagonalization_apply_self_apply` states that, when `T` is transferred via
this equivalence to an operator on the direct sum, it acts diagonally.
* The definition `LinearMap.IsSymmetric.eigenvectorBasis` provides an orthonormal basis for `E`
consisting of eigenvectors of `T`, with `LinearMap.IsSymmetric.eigenvalues` giving the
corresponding list of eigenvalues, as real numbers. The definition
`LinearMap.IsSymmetric.eigenvectorBasis` gives the associated linear isometry equivalence
from `E` to Euclidean space, and the theorem
`LinearMap.IsSymmetric.eigenvectorBasis_apply_self_apply` states that, when `T` is
transferred via this equivalence to an operator on Euclidean space, it acts diagonally.
* `LinearMap.IsSymmetric.eigenvalues` gives the eigenvalues in decreasing order. This is
done for several reasons: (i) This agrees with the standard convention of listing singular
values in decreasing order, with the operator norm as the first singular value
(ii) For positive compact operators on an infinite-dimensional space, one can list the nonzero
eigenvalues in decreasing (but not increasing) order since they converge to zero. (iii) This
simplifies several theorem statements. For example the Schur-Horn theorem states that the diagonal
of the matrix representation of a selfadjoint linear map is majorized by the eigenvalue sequence
listed in decreasing order.
These are forms of the *diagonalization theorem* for self-adjoint operators on finite-dimensional
inner product spaces.
## TODO
Spectral theory for compact self-adjoint operators, bounded self-adjoint operators.
## Tags
self-adjoint operator, spectral theorem, diagonalization theorem
-/
variable {𝕜 : Type*} [RCLike 𝕜]
variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace 𝕜 E]
local notation "⟪" x ", " y "⟫" => inner 𝕜 x y
open scoped ComplexConjugate
open Module.End WithLp
namespace LinearMap
namespace IsSymmetric
variable {T : E →ₗ[𝕜] E}
/-- A self-adjoint operator preserves orthogonal complements of its eigenspaces. -/
theorem invariant_orthogonalComplement_eigenspace (hT : T.IsSymmetric) (μ : 𝕜)
(v : E) (hv : v ∈ (eigenspace T μ)ᗮ) : T v ∈ (eigenspace T μ)ᗮ := by
intro w hw
have : T w = (μ : 𝕜) • w := by rwa [mem_eigenspace_iff] at hw
simp [← hT w, this, inner_smul_left, hv w hw]
/-- The eigenvalues of a self-adjoint operator are real. -/
theorem conj_eigenvalue_eq_self (hT : T.IsSymmetric) {μ : 𝕜} (hμ : HasEigenvalue T μ) :
conj μ = μ := by
obtain ⟨v, hv₁, hv₂⟩ := hμ.exists_hasEigenvector
rw [mem_eigenspace_iff] at hv₁
simpa [hv₂, inner_smul_left, inner_smul_right, hv₁] using hT v v
/-- The eigenspaces of a self-adjoint operator are mutually orthogonal. -/
theorem orthogonalFamily_eigenspaces (hT : T.IsSymmetric) :
OrthogonalFamily 𝕜 (fun μ => eigenspace T μ) fun μ => (eigenspace T μ).subtypeₗᵢ := by
rintro μ ν hμν ⟨v, hv⟩ ⟨w, hw⟩
by_cases hv' : v = 0
· simp [hv']
have H := hT.conj_eigenvalue_eq_self (hasEigenvalue_of_hasEigenvector ⟨hv, hv'⟩)
rw [mem_eigenspace_iff] at hv hw
refine Or.resolve_left ?_ hμν.symm
simpa [inner_smul_left, inner_smul_right, hv, hw, H] using (hT v w).symm
theorem orthogonalFamily_eigenspaces' (hT : T.IsSymmetric) :
OrthogonalFamily 𝕜 (fun μ : Eigenvalues T => eigenspace T μ) fun μ =>
(eigenspace T μ).subtypeₗᵢ :=
hT.orthogonalFamily_eigenspaces.comp Subtype.coe_injective
/-- The mutual orthogonal complement of the eigenspaces of a self-adjoint operator on an inner
product space is an invariant subspace of the operator. -/
theorem orthogonalComplement_iSup_eigenspaces_invariant (hT : T.IsSymmetric)
⦃v : E⦄ (hv : v ∈ (⨆ μ, eigenspace T μ)ᗮ) : T v ∈ (⨆ μ, eigenspace T μ)ᗮ := by
rw [← Submodule.iInf_orthogonal] at hv ⊢
exact T.iInf_invariant hT.invariant_orthogonalComplement_eigenspace v hv
/-- The mutual orthogonal complement of the eigenspaces of a self-adjoint operator on an inner
product space has no eigenvalues. -/
theorem orthogonalComplement_iSup_eigenspaces (hT : T.IsSymmetric) (μ : 𝕜) :
eigenspace (T.restrict hT.orthogonalComplement_iSup_eigenspaces_invariant) μ = ⊥ := by
set p : Submodule 𝕜 E := (⨆ μ, eigenspace T μ)ᗮ
refine eigenspace_restrict_eq_bot hT.orthogonalComplement_iSup_eigenspaces_invariant ?_
have H₂ : eigenspace T μ ⟂ p := (Submodule.isOrtho_orthogonal_right _).mono_left (le_iSup _ _)
exact H₂.disjoint
/-! ### Finite-dimensional theory -/
variable [FiniteDimensional 𝕜 E]
/-- The mutual orthogonal complement of the eigenspaces of a self-adjoint operator on a
finite-dimensional inner product space is trivial. -/
theorem orthogonalComplement_iSup_eigenspaces_eq_bot (hT : T.IsSymmetric) :
(⨆ μ, eigenspace T μ)ᗮ = ⊥ := by
have hT' : IsSymmetric _ :=
hT.restrict_invariant hT.orthogonalComplement_iSup_eigenspaces_invariant
-- a self-adjoint operator on a nontrivial inner product space has an eigenvalue
haveI :=
hT'.subsingleton_of_no_eigenvalue_finiteDimensional hT.orthogonalComplement_iSup_eigenspaces
exact Submodule.eq_bot_of_subsingleton
theorem orthogonalComplement_iSup_eigenspaces_eq_bot' (hT : T.IsSymmetric) :
(⨆ μ : Eigenvalues T, eigenspace T μ)ᗮ = ⊥ :=
show (⨆ μ : { μ // eigenspace T μ ≠ ⊥ }, eigenspace T μ)ᗮ = ⊥ by
rw [iSup_ne_bot_subtype, hT.orthogonalComplement_iSup_eigenspaces_eq_bot]
/-- The eigenspaces of a self-adjoint operator on a finite-dimensional inner product space `E` gives
an internal direct sum decomposition of `E`.
Note this takes `hT` as a `Fact` to allow it to be an instance. -/
noncomputable instance directSumDecomposition [hT : Fact T.IsSymmetric] :
DirectSum.Decomposition fun μ : Eigenvalues T => eigenspace T μ :=
haveI h : ∀ μ : Eigenvalues T, CompleteSpace (eigenspace T μ) := fun μ => by infer_instance
hT.out.orthogonalFamily_eigenspaces'.decomposition
(Submodule.orthogonal_eq_bot_iff.mp hT.out.orthogonalComplement_iSup_eigenspaces_eq_bot')
theorem directSum_decompose_apply [_hT : Fact T.IsSymmetric] (x : E) (μ : Eigenvalues T) :
DirectSum.decompose (fun μ : Eigenvalues T => eigenspace T μ) x μ =
(eigenspace T μ).orthogonalProjection x :=
rfl
/-- The eigenspaces of a self-adjoint operator on a finite-dimensional inner product space `E` gives
an internal direct sum decomposition of `E`. -/
theorem direct_sum_isInternal (hT : T.IsSymmetric) :
DirectSum.IsInternal fun μ : Eigenvalues T => eigenspace T μ :=
hT.orthogonalFamily_eigenspaces'.isInternal_iff.mpr
hT.orthogonalComplement_iSup_eigenspaces_eq_bot'
section Version1
/-- Isometry from an inner product space `E` to the direct sum of the eigenspaces of some
self-adjoint operator `T` on `E`. -/
noncomputable def diagonalization (hT : T.IsSymmetric) : E ≃ₗᵢ[𝕜] PiLp 2 fun μ :
Eigenvalues T => eigenspace T μ :=
hT.direct_sum_isInternal.isometryL2OfOrthogonalFamily hT.orthogonalFamily_eigenspaces'
@[simp]
theorem diagonalization_symm_apply (hT : T.IsSymmetric)
(w : PiLp 2 fun μ : Eigenvalues T => eigenspace T μ) :
hT.diagonalization.symm w = ∑ μ, w μ :=
hT.direct_sum_isInternal.isometryL2OfOrthogonalFamily_symm_apply
hT.orthogonalFamily_eigenspaces' w
/-- *Diagonalization theorem*, *spectral theorem*; version 1: A self-adjoint operator `T` on a
finite-dimensional inner product space `E` acts diagonally on the decomposition of `E` into the
direct sum of the eigenspaces of `T`. -/
theorem diagonalization_apply_self_apply (hT : T.IsSymmetric) (v : E) (μ : Eigenvalues T) :
hT.diagonalization (T v) μ = (μ : 𝕜) • hT.diagonalization v μ := by
suffices
∀ w : PiLp 2 fun μ : Eigenvalues T => eigenspace T μ,
T (hT.diagonalization.symm w) = hT.diagonalization.symm (toLp 2 fun μ => (μ : 𝕜) • w μ) by
simpa only [LinearIsometryEquiv.symm_apply_apply, LinearIsometryEquiv.apply_symm_apply] using
congr_arg (fun w => hT.diagonalization w μ) (this (hT.diagonalization v))
intro w
have hwT : ∀ μ, T (w μ) = (μ : 𝕜) • w μ := fun μ => mem_eigenspace_iff.1 (w μ).2
simp only [diagonalization_symm_apply, map_sum, hwT, SetLike.val_smul]
end Version1
section Version2
variable {n : ℕ}
/-- Unsorted eigenvalues and eigenvectors. These private definitions should not be used directly.
Instead use the functions eigenvalues and eigenvectorBasis defined below. -/
private noncomputable def unsortedEigenvalues (hT : T.IsSymmetric) (hn : Module.finrank 𝕜 E = n)
(i : Fin n) : ℝ :=
@RCLike.re 𝕜 _ <| (hT.direct_sum_isInternal.subordinateOrthonormalBasisIndex hn i
hT.orthogonalFamily_eigenspaces').val
private noncomputable def unsortedEigenvectorBasis (hT : T.IsSymmetric)
(hn : Module.finrank 𝕜 E = n) : OrthonormalBasis (Fin n) 𝕜 E :=
hT.direct_sum_isInternal.subordinateOrthonormalBasis hn hT.orthogonalFamily_eigenspaces'
private theorem hasEigenvector_eigenvectorBasis_helper (hT : T.IsSymmetric)
(hn : Module.finrank 𝕜 E = n) (i : Fin n) :
HasEigenvector T (hT.unsortedEigenvalues hn i) (hT.unsortedEigenvectorBasis hn i) := by
let v : E := hT.unsortedEigenvectorBasis hn i
let μ : 𝕜 :=
(hT.direct_sum_isInternal.subordinateOrthonormalBasisIndex hn i
hT.orthogonalFamily_eigenspaces').val
simp_rw [unsortedEigenvalues]
change HasEigenvector T (RCLike.re μ) v
have key : HasEigenvector T μ v := by
have H₁ : v ∈ eigenspace T μ := by
simp_rw [v, unsortedEigenvectorBasis]
exact
hT.direct_sum_isInternal.subordinateOrthonormalBasis_subordinate hn i
hT.orthogonalFamily_eigenspaces'
have H₂ : v ≠ 0 := by simpa using (hT.unsortedEigenvectorBasis hn).toBasis.ne_zero i
exact ⟨H₁, H₂⟩
have re_μ : ↑(RCLike.re μ) = μ := by
rw [← RCLike.conj_eq_iff_re]
exact hT.conj_eigenvalue_eq_self (hasEigenvalue_of_hasEigenvector key)
simpa [re_μ] using key
/-- The eigenvalues for a self-adjoint operator `T` on a
finite-dimensional inner product space `E`, sorted in decreasing order -/
noncomputable irreducible_def eigenvalues (hT : T.IsSymmetric) (hn : Module.finrank 𝕜 E = n) :
Fin n → ℝ :=
(hT.unsortedEigenvalues hn) ∘ Tuple.sort (hT.unsortedEigenvalues hn) ∘ @Fin.revPerm n
/-- A choice of orthonormal basis of eigenvectors for self-adjoint operator `T` on a
finite-dimensional inner product space `E`. Eigenvectors are sorted in decreasing
order of their eigenvalues. -/
noncomputable irreducible_def eigenvectorBasis (hT : T.IsSymmetric) (hn : Module.finrank 𝕜 E = n) :
OrthonormalBasis (Fin n) 𝕜 E :=
(hT.direct_sum_isInternal.subordinateOrthonormalBasis
hn hT.orthogonalFamily_eigenspaces').reindex
(Tuple.sort (hT.unsortedEigenvalues hn) * @Fin.revPerm n).symm
theorem hasEigenvector_eigenvectorBasis (hT : T.IsSymmetric) (hn : Module.finrank 𝕜 E = n)
(i : Fin n) : HasEigenvector T (hT.eigenvalues hn i) (hT.eigenvectorBasis hn i) := by
rw [eigenvalues_def, eigenvectorBasis_def, OrthonormalBasis.reindex_apply]
apply hasEigenvector_eigenvectorBasis_helper
/-- Eigenvalues are sorted in decreasing order. -/
theorem eigenvalues_antitone (hT : T.IsSymmetric) (hn : Module.finrank 𝕜 E = n) :
Antitone (hT.eigenvalues hn) := by
rw [eigenvalues_def, ← Function.comp_assoc]
refine Monotone.comp_antitone ?_ ?_
· apply Tuple.monotone_sort
intro _ _ h
exact Fin.rev_le_rev.mpr h
theorem hasEigenvalue_eigenvalues (hT : T.IsSymmetric) (hn : Module.finrank 𝕜 E = n) (i : Fin n) :
HasEigenvalue T (hT.eigenvalues hn i) :=
Module.End.hasEigenvalue_of_hasEigenvector (hT.hasEigenvector_eigenvectorBasis hn i)
@[simp]
theorem apply_eigenvectorBasis (hT : T.IsSymmetric) (hn : Module.finrank 𝕜 E = n) (i : Fin n) :
T (hT.eigenvectorBasis hn i) = (hT.eigenvalues hn i : 𝕜) • hT.eigenvectorBasis hn i :=
mem_eigenspace_iff.mp (hT.hasEigenvector_eigenvectorBasis hn i).1
/-- *Diagonalization theorem*, *spectral theorem*; version 2: A self-adjoint operator `T` on a
finite-dimensional inner product space `E` acts diagonally on the identification of `E` with
Euclidean space induced by an orthonormal basis of eigenvectors of `T`. -/
theorem eigenvectorBasis_apply_self_apply (hT : T.IsSymmetric) (hn : Module.finrank 𝕜 E = n)
(v : E) (i : Fin n) :
(hT.eigenvectorBasis hn).repr (T v) i =
hT.eigenvalues hn i * (hT.eigenvectorBasis hn).repr v i := by
suffices
∀ w : EuclideanSpace 𝕜 (Fin n),
T ((hT.eigenvectorBasis hn).repr.symm w) =
(hT.eigenvectorBasis hn).repr.symm (toLp 2 fun i ↦ hT.eigenvalues hn i * w i) by
simpa [OrthonormalBasis.sum_repr_symm] using
congr_arg (fun v => (hT.eigenvectorBasis hn).repr v i)
(this ((hT.eigenvectorBasis hn).repr v))
intro w
simp_rw [← OrthonormalBasis.sum_repr_symm, map_sum, map_smul, apply_eigenvectorBasis]
apply Fintype.sum_congr
intro a
rw [smul_smul, mul_comm, ofLp_toLp]
end Version2
end IsSymmetric
end LinearMap
section Nonneg
-- Cannot be @[simp] because the LHS is not in simp normal form
theorem inner_product_apply_eigenvector {μ : 𝕜} {v : E} {T : E →ₗ[𝕜] E}
(h : T v = μ • v) : ⟪v, T v⟫ = μ * (‖v‖ : 𝕜) ^ 2 := by
simp only [h, inner_smul_right, inner_self_eq_norm_sq_to_K]
theorem eigenvalue_nonneg_of_nonneg {μ : ℝ} {T : E →ₗ[𝕜] E} (hμ : HasEigenvalue T μ)
(hnn : ∀ x : E, 0 ≤ RCLike.re ⟪x, T x⟫) : 0 ≤ μ := by
obtain ⟨v, hv₁, hv₂⟩ := hμ.exists_hasEigenvector
have hpos : (0 : ℝ) < ‖v‖ ^ 2 := by simpa only [sq_pos_iff, norm_ne_zero_iff] using hv₂
simp only [mem_genEigenspace_one] at hv₁
have : RCLike.re ⟪v, T v⟫ = μ * ‖v‖ ^ 2 :=
mod_cast congr_arg RCLike.re (inner_product_apply_eigenvector hv₁)
exact (mul_nonneg_iff_of_pos_right hpos).mp (this ▸ hnn v)
theorem eigenvalue_pos_of_pos {μ : ℝ} {T : E →ₗ[𝕜] E} (hμ : HasEigenvalue T μ)
(hnn : ∀ x : E, 0 < RCLike.re ⟪x, T x⟫) : 0 < μ := by
obtain ⟨v, hv₁, hv₂⟩ := hμ.exists_hasEigenvector
have hpos : (0 : ℝ) < ‖v‖ ^ 2 := by simpa only [sq_pos_iff, norm_ne_zero_iff] using hv₂
simp only [mem_genEigenspace_one] at hv₁
have : RCLike.re ⟪v, T v⟫ = μ * ‖v‖ ^ 2 :=
mod_cast congr_arg RCLike.re (inner_product_apply_eigenvector hv₁)
exact (mul_pos_iff_of_pos_right hpos).mp (this ▸ hnn v)
end Nonneg |
.lake/packages/mathlib/Mathlib/Analysis/InnerProductSpace/Harmonic/Analytic.lean | import Mathlib.Analysis.Complex.Harmonic.Analytic
deprecated_module (since := "2025-09-16") |
.lake/packages/mathlib/Mathlib/Analysis/InnerProductSpace/Harmonic/Basic.lean | import Mathlib.Analysis.InnerProductSpace.Laplacian
/-!
# Harmonic Functions
This file defines harmonic functions on real, finite-dimensional, inner product spaces `E`.
-/
variable
{E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E]
{F : Type*} [NormedAddCommGroup F] [NormedSpace ℝ F]
{G : Type*} [NormedAddCommGroup G] [NormedSpace ℝ G]
{f f₁ f₂ : E → F}
{x : E} {s t : Set E} {c : ℝ}
open Topology
namespace InnerProductSpace
/-!
## Definition
-/
variable (f x) in
/--
Let `E` be a real, finite-dimensional, inner product space and `x` be a point of `E`. A function `f`
on `E` is harmonic at `x` if it is two times continuously `ℝ`-differentiable and if its Laplacian
vanishes in a neighborhood of `x`.
-/
def HarmonicAt := (ContDiffAt ℝ 2 f x) ∧ (Δ f =ᶠ[𝓝 x] 0)
variable (f s) in
/--
Let `E` be a real, finite-dimensional, inner product space and `s` be a subset of `E`. A function
`f` on `E` is harmonic in a neighborhood of `s` if it is harmonic at every point of `s`.
-/
def HarmonicOnNhd := ∀ x ∈ s, HarmonicAt f x
/-!
## Elementary Properties
-/
/--
If two functions agree in a neighborhood of `x`, then one is harmonic at `x` iff so is the other.
-/
theorem harmonicAt_congr_nhds {f₁ f₂ : E → F} {x : E} (h : f₁ =ᶠ[𝓝 x] f₂) :
HarmonicAt f₁ x ↔ HarmonicAt f₂ x := by
constructor <;> intro hf
· exact ⟨hf.1.congr_of_eventuallyEq h.symm, (laplacian_congr_nhds h.symm).trans hf.2⟩
· exact ⟨hf.1.congr_of_eventuallyEq h, (laplacian_congr_nhds h).trans hf.2⟩
/--
If `f` is harmonic at `x`, then it is harmonic at all points in a neighborhood of `x`.
-/
theorem HarmonicAt.eventually {f : E → F} {x : E} (h : HarmonicAt f x) :
∀ᶠ y in 𝓝 x, HarmonicAt f y := by
filter_upwards [h.1.eventually (by simp), h.2.eventually_nhds] with a h₁a h₂a
exact ⟨h₁a, h₂a⟩
variable (f) in
/--
Harmonicity is an open property.
-/
theorem isOpen_setOf_harmonicAt : IsOpen { x : E | HarmonicAt f x } :=
isOpen_iff_mem_nhds.2 (fun _ hx ↦ hx.eventually)
/--
If `f` is harmonic in a neighborhood of `s`, it is harmonic in a neighborhood of every subset.
-/
lemma HarmonicOnNhd.mono (h : HarmonicOnNhd f s) (hst : t ⊆ s) :
HarmonicOnNhd f t := fun x hx ↦ h x (hst hx)
/-!
## Vector Space Structure
-/
/--
Sums of harmonic functions are harmonic.
-/
theorem HarmonicAt.add (h₁ : HarmonicAt f₁ x) (h₂ : HarmonicAt f₂ x) :
HarmonicAt (f₁ + f₂) x := by
constructor
· exact h₁.1.add h₂.1
· filter_upwards [h₁.1.laplacian_add_nhds h₂.1, h₁.2, h₂.2]
simp_all
/--
Sums of harmonic functions are harmonic.
-/
theorem HarmonicOnNhd.add (h₁ : HarmonicOnNhd f₁ s) (h₂ : HarmonicOnNhd f₂ s) :
HarmonicOnNhd (f₁ + f₂) s := fun x hx ↦ (h₁ x hx).add (h₂ x hx)
/--
Scalar multiples of harmonic functions are harmonic.
-/
theorem HarmonicAt.const_smul (h : HarmonicAt f x) :
HarmonicAt (c • f) x := by
constructor
· exact h.1.const_smul c
· filter_upwards [laplacian_smul_nhds c h.1, h.2]
simp_all
/--
Scalar multiples of harmonic functions are harmonic.
-/
theorem HarmonicOnNhd.const_smul (h : HarmonicOnNhd f s) :
HarmonicOnNhd (c • f) s := fun x hx ↦ (h x hx).const_smul
/-!
## Compatibility with Linear Maps
-/
/--
Compositions of continuous `ℝ`-linear maps with harmonic functions are harmonic.
-/
theorem HarmonicAt.comp_CLM (h : HarmonicAt f x) (l : F →L[ℝ] G) :
HarmonicAt (l ∘ f) x := by
constructor
· exact h.1.continuousLinearMap_comp l
· filter_upwards [h.1.laplacian_CLM_comp_left_nhds (l := l), h.2]
simp_all
/--
Compositions of continuous linear maps with harmonic functions are harmonic.
-/
theorem HarmonicOnNhd.comp_CLM (h : HarmonicOnNhd f s) (l : F →L[ℝ] G) :
HarmonicOnNhd (l ∘ f) s := fun x hx ↦ (h x hx).comp_CLM l
/--
Functions are harmonic iff their compositions with continuous linear equivalences are harmonic.
-/
theorem harmonicAt_comp_CLE_iff (l : F ≃L[ℝ] G) :
HarmonicAt (l ∘ f) x ↔ HarmonicAt f x := by
constructor <;> intro h
· simpa [Function.comp_def] using h.comp_CLM l.symm.toContinuousLinearMap
· exact h.comp_CLM l.toContinuousLinearMap
/--
Functions are harmonic iff their compositions with continuous linear equivalences are harmonic.
-/
theorem harmonicOnNhd_comp_CLE_iff (l : F ≃L[ℝ] G) :
HarmonicOnNhd (l ∘ f) s ↔ HarmonicOnNhd f s :=
forall₂_congr fun _ _ ↦ harmonicAt_comp_CLE_iff l
end InnerProductSpace |
.lake/packages/mathlib/Mathlib/Analysis/InnerProductSpace/Harmonic/Constructions.lean | import Mathlib.Analysis.InnerProductSpace.Harmonic.Basic
import Mathlib.Analysis.Calculus.ContDiff.RestrictScalars
import Mathlib.Analysis.SpecialFunctions.Complex.Analytic
/-!
# Construction of Harmonic Functions
This file constructs examples of harmonic functions.
If `f : ℂ → F` is complex-differentiable, then `f` is harmonic. If `F = ℂ`, then so is its real
part, imaginary part, and complex conjugate. If `f` has no zero, then `log ‖f‖` is harmonic.
-/
open Complex ComplexConjugate InnerProductSpace Topology
variable
{F : Type*} [NormedAddCommGroup F] [NormedSpace ℂ F]
{f : ℂ → F} {x : ℂ}
/-!
## Harmonicity of Analytic Functions on the Complex Plane
-/
/--
Continuously complex-differentiable functions on ℂ are harmonic.
-/
theorem ContDiffAt.harmonicAt (h : ContDiffAt ℂ 2 f x) : HarmonicAt f x := by
refine ⟨h.restrict_scalars ℝ, ?_⟩
filter_upwards [h.restrictScalars_iteratedFDeriv_eventuallyEq (𝕜 := ℝ)] with a ha
have : (iteratedFDeriv ℂ 2 f a) (I • ![1, 1])
= (∏ i, I) • ((iteratedFDeriv ℂ 2 f a) ![1, 1]) :=
(iteratedFDeriv ℂ 2 f a).map_smul_univ (fun _ ↦ I) ![1, 1]
simp_all [laplacian_eq_iteratedFDeriv_complexPlane f, ← ha,
ContinuousMultilinearMap.coe_restrictScalars]
/-- Analytic functions on ℂ are harmonic. -/
theorem AnalyticAt.harmonicAt [CompleteSpace F] (h : AnalyticAt ℂ f x) : HarmonicAt f x :=
h.contDiffAt.harmonicAt
/--
If `f : ℂ → ℂ` is complex-analytic, then its real part is harmonic.
-/
theorem AnalyticAt.harmonicAt_re {f : ℂ → ℂ} (h : AnalyticAt ℂ f x) :
HarmonicAt (fun z ↦ (f z).re) x := h.harmonicAt.comp_CLM reCLM
/--
If `f : ℂ → ℂ` is complex-analytic, then its imaginary part is harmonic.
-/
theorem AnalyticAt.harmonicAt_im {f : ℂ → ℂ} (h : AnalyticAt ℂ f x) :
HarmonicAt (fun z ↦ (f z).im) x :=
h.harmonicAt.comp_CLM imCLM
/--
If `f : ℂ → ℂ` is complex-analytic, then its complex conjugate is harmonic.
-/
theorem AnalyticAt.harmonicAt_conj {f : ℂ → ℂ} (h : AnalyticAt ℂ f x) : HarmonicAt (conj f) x :=
(harmonicAt_comp_CLE_iff conjCLE).2 h.harmonicAt
/-!
## Harmonicity of `log ‖analytic‖`
-/
/- Helper lemma for AnalyticAt.harmonicAt_log_norm -/
private lemma analyticAt_harmonicAt_log_normSq {z : ℂ} {g : ℂ → ℂ} (h₁g : AnalyticAt ℂ g z)
(h₂g : g z ≠ 0) (h₃g : g z ∈ slitPlane) :
HarmonicAt (Real.log ∘ normSq ∘ g) z := by
rw [harmonicAt_congr_nhds (f₂ := reCLM ∘ (conjCLE ∘ log ∘ g + log ∘ g))]
· exact (((harmonicAt_comp_CLE_iff conjCLE).2 ((analyticAt_clog h₃g).comp h₁g).harmonicAt).add
((analyticAt_clog h₃g).comp h₁g).harmonicAt).comp_CLM reCLM
· have t₀ := h₁g.differentiableAt.continuousAt.preimage_mem_nhds
((isOpen_slitPlane.inter isOpen_ne).mem_nhds ⟨h₃g, h₂g⟩)
calc Real.log ∘ normSq ∘ g
_ =ᶠ[𝓝 z] reCLM ∘ ofRealCLM ∘ Real.log ∘ normSq ∘ g := by aesop
_ =ᶠ[𝓝 z] reCLM ∘ log ∘ ((conjCLE ∘ g) * g) := by
filter_upwards with x
simp only [Function.comp_apply, ofRealCLM_apply, Pi.mul_apply, conjCLE_apply]
rw [ofReal_log, normSq_eq_conj_mul_self]
exact normSq_nonneg (g x)
_ =ᶠ[𝓝 z] reCLM ∘ (log ∘ conjCLE ∘ g + log ∘ g) := by
filter_upwards [t₀] with x hx
simp only [Function.comp_apply, Pi.mul_apply, conjCLE_apply, Pi.add_apply]
congr
rw [Complex.log_mul_eq_add_log_iff _ hx.2, Complex.arg_conj]
· simp [Complex.slitPlane_arg_ne_pi hx.1, Real.pi_pos, Real.pi_nonneg]
· simpa [ne_eq, map_eq_zero] using hx.2
_ =ᶠ[𝓝 z] ⇑reCLM ∘ (⇑conjCLE ∘ log ∘ g + log ∘ g) := by
apply Filter.eventuallyEq_iff_exists_mem.2
use g⁻¹' (Complex.slitPlane ∩ {0}ᶜ), t₀
intro x hx
simp only [Function.comp_apply, Pi.add_apply, conjCLE_apply]
congr 1
rw [← Complex.log_conj]
simp [Complex.slitPlane_arg_ne_pi hx.1]
/--
If `f : ℂ → ℂ` is complex-analytic without zero, then `log ‖f‖` is harmonic.
-/
theorem AnalyticAt.harmonicAt_log_norm {f : ℂ → ℂ} {z : ℂ} (h₁f : AnalyticAt ℂ f z)
(h₂f : f z ≠ 0) :
HarmonicAt (Real.log ‖f ·‖) z := by
have : (Real.log ‖f ·‖) = (2 : ℝ)⁻¹ • (Real.log ∘ Complex.normSq ∘ f) := by
funext z
simp only [Pi.smul_apply, Function.comp_apply, smul_eq_mul]
rw [Complex.norm_def, Real.log_sqrt]
· linarith
exact (f z).normSq_nonneg
rw [this]
apply HarmonicAt.const_smul
by_cases h₃f : f z ∈ Complex.slitPlane
· exact analyticAt_harmonicAt_log_normSq h₁f h₂f h₃f
· rw [(by aesop : Complex.normSq ∘ f = Complex.normSq ∘ (-f))]
exact analyticAt_harmonicAt_log_normSq h₁f.neg (by simpa)
((mem_slitPlane_or_neg_mem_slitPlane h₂f).resolve_left h₃f) |
.lake/packages/mathlib/Mathlib/Analysis/InnerProductSpace/Projection/Reflection.lean | import Mathlib.Analysis.InnerProductSpace.Projection.Basic
/-!
# Reflection
A linear isometry equivalence `K.reflection : E ≃ₗᵢ[𝕜] E` in constructed, by choosing
for each `u : E`, `K.reflection u = 2 • K.starProjection u - u`.
-/
noncomputable section
namespace Submodule
section reflection
open Submodule RCLike
variable {𝕜 E F : Type*} [RCLike 𝕜]
variable [NormedAddCommGroup E] [NormedAddCommGroup F]
variable [InnerProductSpace 𝕜 E] [InnerProductSpace ℝ F]
local notation "⟪" x ", " y "⟫" => inner 𝕜 x y
variable (K : Submodule 𝕜 E)
variable [K.HasOrthogonalProjection]
/-- Auxiliary definition for `reflection`: the reflection as a linear equivalence. -/
def reflectionLinearEquiv : E ≃ₗ[𝕜] E :=
LinearEquiv.ofInvolutive
(2 • (K.starProjection.toLinearMap) - LinearMap.id) fun x => by
simp [two_smul, starProjection_eq_self_iff.mpr]
/-- Reflection in a complete subspace of an inner product space. The word "reflection" is
sometimes understood to mean specifically reflection in a codimension-one subspace, and sometimes
more generally to cover operations such as reflection in a point. The definition here, of
reflection in a subspace, is a more general sense of the word that includes both those common
cases. -/
def reflection : E ≃ₗᵢ[𝕜] E :=
{ K.reflectionLinearEquiv with
norm_map' := by
intro x
let w : K := K.orthogonalProjection x
let v := x - w
have : ⟪v, w⟫ = 0 := starProjection_inner_eq_zero x w w.2
convert norm_sub_eq_norm_add this using 2
· dsimp [reflectionLinearEquiv, v, w]
abel
· simp only [v, add_sub_cancel] }
variable {K}
/-- The result of reflecting. -/
theorem reflection_apply (p : E) : K.reflection p = 2 • K.starProjection p - p :=
rfl
/-- Reflection is its own inverse. -/
@[simp]
theorem reflection_symm : K.reflection.symm = K.reflection :=
rfl
/-- Reflection is its own inverse. -/
@[simp]
theorem reflection_inv : K.reflection⁻¹ = K.reflection :=
rfl
variable (K)
/-- Reflecting twice in the same subspace. -/
@[simp]
theorem reflection_reflection (p : E) : K.reflection (K.reflection p) = p :=
K.reflection.left_inv p
/-- Reflection is involutive. -/
theorem reflection_involutive : Function.Involutive K.reflection :=
K.reflection_reflection
/-- Reflection is involutive. -/
@[simp]
theorem reflection_trans_reflection :
K.reflection.trans K.reflection = LinearIsometryEquiv.refl 𝕜 E :=
LinearIsometryEquiv.ext <| reflection_involutive K
/-- Reflection is involutive. -/
@[simp]
theorem reflection_mul_reflection : K.reflection * K.reflection = 1 :=
reflection_trans_reflection _
theorem reflection_orthogonal_apply (v : E) : Kᗮ.reflection v = -K.reflection v := by
simp [reflection_apply]; abel
theorem reflection_orthogonal : Kᗮ.reflection = .trans K.reflection (.neg _) := by
ext; apply reflection_orthogonal_apply
variable {K}
theorem reflection_singleton_apply (u v : E) :
reflection (𝕜 ∙ u) v = 2 • (⟪u, v⟫ / ((‖u‖ : 𝕜) ^ 2)) • u - v := by
rw [reflection_apply, starProjection_singleton, ofReal_pow]
/-- A point is its own reflection if and only if it is in the subspace. -/
theorem reflection_eq_self_iff (x : E) : K.reflection x = x ↔ x ∈ K := by
rw [← starProjection_eq_self_iff, reflection_apply, sub_eq_iff_eq_add', ← two_smul 𝕜,
two_smul ℕ, ← two_smul 𝕜]
refine (smul_right_injective E ?_).eq_iff
exact two_ne_zero
theorem reflection_mem_subspace_eq_self {x : E} (hx : x ∈ K) : K.reflection x = x :=
(reflection_eq_self_iff x).mpr hx
/-- Reflection in the `Submodule.map` of a subspace. -/
theorem reflection_map_apply {E E' : Type*} [NormedAddCommGroup E] [NormedAddCommGroup E']
[InnerProductSpace 𝕜 E] [InnerProductSpace 𝕜 E'] (f : E ≃ₗᵢ[𝕜] E') (K : Submodule 𝕜 E)
[K.HasOrthogonalProjection] (x : E') :
reflection (K.map (f.toLinearEquiv : E →ₗ[𝕜] E')) x = f (K.reflection (f.symm x)) := by
simp [two_smul, reflection_apply, starProjection_map_apply f K x]
/-- Reflection in the `Submodule.map` of a subspace. -/
theorem reflection_map {E E' : Type*} [NormedAddCommGroup E] [NormedAddCommGroup E']
[InnerProductSpace 𝕜 E] [InnerProductSpace 𝕜 E'] (f : E ≃ₗᵢ[𝕜] E') (K : Submodule 𝕜 E)
[K.HasOrthogonalProjection] :
reflection (K.map (f.toLinearEquiv : E →ₗ[𝕜] E')) = f.symm.trans (K.reflection.trans f) :=
LinearIsometryEquiv.ext <| reflection_map_apply f K
/-- Reflection through the trivial subspace {0} is just negation. -/
@[simp]
theorem reflection_bot : reflection (⊥ : Submodule 𝕜 E) = LinearIsometryEquiv.neg 𝕜 := by
ext; simp [reflection_apply]
/-- The reflection in `K` of an element of `Kᗮ` is its negation. -/
theorem reflection_mem_subspace_orthogonalComplement_eq_neg {v : E}
(hv : v ∈ Kᗮ) : K.reflection v = -v := by
simp [starProjection_apply, reflection_apply,
orthogonalProjection_mem_subspace_orthogonalComplement_eq_zero hv]
/-- The reflection in `Kᗮ` of an element of `K` is its negation. -/
theorem reflection_mem_subspace_orthogonal_precomplement_eq_neg {v : E}
(hv : v ∈ K) : Kᗮ.reflection v = -v :=
reflection_mem_subspace_orthogonalComplement_eq_neg (K.le_orthogonal_orthogonal hv)
/-- The reflection in `(𝕜 ∙ v)ᗮ` of `v` is `-v`. -/
theorem reflection_orthogonalComplement_singleton_eq_neg (v : E) : reflection (𝕜 ∙ v)ᗮ v = -v :=
reflection_mem_subspace_orthogonal_precomplement_eq_neg (Submodule.mem_span_singleton_self v)
theorem reflection_sub {v w : F} (h : ‖v‖ = ‖w‖) : reflection (ℝ ∙ (v - w))ᗮ v = w := by
set R : F ≃ₗᵢ[ℝ] F := reflection (ℝ ∙ v - w)ᗮ
suffices R v + R v = w + w by
apply smul_right_injective F (by simp : (2 : ℝ) ≠ 0)
simpa [two_smul] using this
have h₁ : R (v - w) = -(v - w) := reflection_orthogonalComplement_singleton_eq_neg (v - w)
have h₂ : R (v + w) = v + w := by
apply reflection_mem_subspace_eq_self
rw [Submodule.mem_orthogonal_singleton_iff_inner_left]
rw [real_inner_add_sub_eq_zero_iff]
exact h
convert congr_arg₂ (· + ·) h₂ h₁ using 1
· simp
· abel
end reflection
end Submodule
end |
.lake/packages/mathlib/Mathlib/Analysis/InnerProductSpace/Projection/Basic.lean | import Mathlib.Analysis.InnerProductSpace.Projection.Minimal
import Mathlib.Analysis.InnerProductSpace.Symmetric
import Mathlib.Analysis.RCLike.Lemmas
/-!
# The orthogonal projection
Given a nonempty subspace `K` of an inner product space `E` such that `K`
admits an orthogonal projection, this file constructs
`K.orthogonalProjection : E →L[𝕜] K`, the orthogonal projection of `E` onto `K`. This map
satisfies: for any point `u` in `E`, the point `v = K.orthogonalProjection u` in `K` minimizes the
distance `‖u - v‖` to `u`.
This file also defines `K.starProjection : E →L[𝕜] E` which is the
orthogonal projection of `E` onto `K` but as a map from `E` to `E` instead of `E` to `K`.
Basic API for `orthogonalProjection` and `starProjection` is developed.
## References
The orthogonal projection construction is adapted from
* [Clément & Martin, *The Lax-Milgram Theorem. A detailed proof to be formalized in Coq*]
* [Clément & Martin, *A Coq formal proof of the Lax–Milgram theorem*]
The Coq code is available at the following address: <http://www.lri.fr/~sboldo/elfic/index.html>
-/
variable {𝕜 E F : Type*} [RCLike 𝕜]
variable [NormedAddCommGroup E] [NormedAddCommGroup F]
variable [InnerProductSpace 𝕜 E] [InnerProductSpace ℝ F]
local notation "⟪" x ", " y "⟫" => inner 𝕜 x y
local notation "absR" => @abs ℝ _ _
namespace Submodule
/-- A subspace `K : Submodule 𝕜 E` has an orthogonal projection if every vector `v : E` admits an
orthogonal projection to `K`. -/
class HasOrthogonalProjection (K : Submodule 𝕜 E) : Prop where
exists_orthogonal (v : E) : ∃ w ∈ K, v - w ∈ Kᗮ
variable (K : Submodule 𝕜 E)
instance (priority := 100) HasOrthogonalProjection.ofCompleteSpace [CompleteSpace K] :
K.HasOrthogonalProjection where
exists_orthogonal v := by
rcases K.exists_norm_eq_iInf_of_complete_subspace (completeSpace_coe_iff_isComplete.mp ‹_›) v
with ⟨w, hwK, hw⟩
refine ⟨w, hwK, (K.mem_orthogonal' _).2 ?_⟩
rwa [← K.norm_eq_iInf_iff_inner_eq_zero hwK]
instance [K.HasOrthogonalProjection] : Kᗮ.HasOrthogonalProjection where
exists_orthogonal v := by
rcases HasOrthogonalProjection.exists_orthogonal (K := K) v with ⟨w, hwK, hw⟩
refine ⟨_, hw, ?_⟩
rw [sub_sub_cancel]
exact K.le_orthogonal_orthogonal hwK
instance HasOrthogonalProjection.map_linearIsometryEquiv [K.HasOrthogonalProjection]
{E' : Type*} [NormedAddCommGroup E'] [InnerProductSpace 𝕜 E'] (f : E ≃ₗᵢ[𝕜] E') :
(K.map (f.toLinearEquiv : E →ₗ[𝕜] E')).HasOrthogonalProjection where
exists_orthogonal v := by
rcases HasOrthogonalProjection.exists_orthogonal (K := K) (f.symm v) with ⟨w, hwK, hw⟩
refine ⟨f w, Submodule.mem_map_of_mem hwK, Set.forall_mem_image.2 fun u hu ↦ ?_⟩
erw [← f.symm.inner_map_map, f.symm_apply_apply, map_sub, f.symm_apply_apply, hw u hu]
instance HasOrthogonalProjection.map_linearIsometryEquiv' [K.HasOrthogonalProjection]
{E' : Type*} [NormedAddCommGroup E'] [InnerProductSpace 𝕜 E'] (f : E ≃ₗᵢ[𝕜] E') :
(K.map f.toLinearIsometry).HasOrthogonalProjection :=
HasOrthogonalProjection.map_linearIsometryEquiv K f
instance : (⊤ : Submodule 𝕜 E).HasOrthogonalProjection := ⟨fun v ↦ ⟨v, trivial, by simp⟩⟩
noncomputable section
section orthogonalProjection
variable [K.HasOrthogonalProjection]
/-- The orthogonal projection onto a complete subspace, as an
unbundled function. This definition is only intended for use in
setting up the bundled version `orthogonalProjection` and should not
be used once that is defined. -/
def orthogonalProjectionFn (v : E) :=
(HasOrthogonalProjection.exists_orthogonal (K := K) v).choose
variable {K}
/-- The unbundled orthogonal projection is in the given subspace.
This lemma is only intended for use in setting up the bundled version
and should not be used once that is defined. -/
theorem orthogonalProjectionFn_mem (v : E) : K.orthogonalProjectionFn v ∈ K :=
(HasOrthogonalProjection.exists_orthogonal (K := K) v).choose_spec.left
/-- The characterization of the unbundled orthogonal projection. This
lemma is only intended for use in setting up the bundled version
and should not be used once that is defined. -/
theorem orthogonalProjectionFn_inner_eq_zero (v : E) :
∀ w ∈ K, ⟪v - K.orthogonalProjectionFn v, w⟫ = 0 :=
(K.mem_orthogonal' _).1 (HasOrthogonalProjection.exists_orthogonal (K := K) v).choose_spec.right
/-- The unbundled orthogonal projection is the unique point in `K`
with the orthogonality property. This lemma is only intended for use
in setting up the bundled version and should not be used once that is
defined. -/
theorem eq_orthogonalProjectionFn_of_mem_of_inner_eq_zero {u v : E} (hvm : v ∈ K)
(hvo : ∀ w ∈ K, ⟪u - v, w⟫ = 0) : K.orthogonalProjectionFn u = v := by
rw [← sub_eq_zero, ← @inner_self_eq_zero 𝕜]
have hvs : K.orthogonalProjectionFn u - v ∈ K :=
Submodule.sub_mem K (orthogonalProjectionFn_mem u) hvm
have huo : ⟪u - K.orthogonalProjectionFn u, K.orthogonalProjectionFn u - v⟫ = 0 :=
orthogonalProjectionFn_inner_eq_zero u _ hvs
have huv : ⟪u - v, K.orthogonalProjectionFn u - v⟫ = 0 := hvo _ hvs
have houv : ⟪u - v - (u - K.orthogonalProjectionFn u), K.orthogonalProjectionFn u - v⟫ = 0 := by
rw [inner_sub_left, huo, huv, sub_zero]
rwa [sub_sub_sub_cancel_left] at houv
variable (K)
theorem orthogonalProjectionFn_norm_sq (v : E) :
‖v‖ * ‖v‖ =
‖v - K.orthogonalProjectionFn v‖ * ‖v - K.orthogonalProjectionFn v‖ +
‖K.orthogonalProjectionFn v‖ * ‖K.orthogonalProjectionFn v‖ := by
set p := K.orthogonalProjectionFn v
have h' : ⟪v - p, p⟫ = 0 :=
orthogonalProjectionFn_inner_eq_zero _ _ (orthogonalProjectionFn_mem v)
convert norm_add_sq_eq_norm_sq_add_norm_sq_of_inner_eq_zero (v - p) p h' using 2 <;> simp
/-- The orthogonal projection onto a complete subspace. -/
def orthogonalProjection : E →L[𝕜] K :=
LinearMap.mkContinuous
{ toFun := fun v => ⟨K.orthogonalProjectionFn v, orthogonalProjectionFn_mem v⟩
map_add' := fun x y => by
have hm : K.orthogonalProjectionFn x + K.orthogonalProjectionFn y ∈ K :=
Submodule.add_mem K (orthogonalProjectionFn_mem x) (orthogonalProjectionFn_mem y)
have ho :
∀ w ∈ K, ⟪x + y - (K.orthogonalProjectionFn x + K.orthogonalProjectionFn y), w⟫ = 0 := by
intro w hw
rw [add_sub_add_comm, inner_add_left, orthogonalProjectionFn_inner_eq_zero _ w hw,
orthogonalProjectionFn_inner_eq_zero _ w hw, add_zero]
ext
simp [eq_orthogonalProjectionFn_of_mem_of_inner_eq_zero hm ho]
map_smul' := fun c x => by
have hm : c • K.orthogonalProjectionFn x ∈ K :=
Submodule.smul_mem K _ (orthogonalProjectionFn_mem x)
have ho : ∀ w ∈ K, ⟪c • x - c • K.orthogonalProjectionFn x, w⟫ = 0 := by
intro w hw
rw [← smul_sub, inner_smul_left, orthogonalProjectionFn_inner_eq_zero _ w hw,
mul_zero]
ext
simp [eq_orthogonalProjectionFn_of_mem_of_inner_eq_zero hm ho] }
1 fun x => by
simp only [one_mul, LinearMap.coe_mk]
refine le_of_pow_le_pow_left₀ two_ne_zero (norm_nonneg _) ?_
change ‖K.orthogonalProjectionFn x‖ ^ 2 ≤ ‖x‖ ^ 2
nlinarith [K.orthogonalProjectionFn_norm_sq x]
variable {K}
@[simp]
theorem orthogonalProjectionFn_eq (v : E) :
K.orthogonalProjectionFn v = (K.orthogonalProjection v : E) :=
rfl
/-- The orthogonal projection onto a subspace as a map from the full space to itself,
as opposed to `Submodule.orthogonalProjection`, which maps into the subtype. This
version is important as it satisfies `IsStarProjection`. -/
def starProjection (U : Submodule 𝕜 E) [U.HasOrthogonalProjection] :
E →L[𝕜] E := U.subtypeL ∘L U.orthogonalProjection
lemma starProjection_apply (U : Submodule 𝕜 E) [U.HasOrthogonalProjection] (v : E) :
U.starProjection v = U.orthogonalProjection v := rfl
@[simp]
lemma coe_orthogonalProjection_apply (U : Submodule 𝕜 E) [U.HasOrthogonalProjection] (v : E) :
U.orthogonalProjection v = U.starProjection v := rfl
@[simp]
lemma starProjection_apply_mem (U : Submodule 𝕜 E) [U.HasOrthogonalProjection] (x : E) :
U.starProjection x ∈ U := by
simp only [starProjection_apply, SetLike.coe_mem]
/-- The characterization of the orthogonal projection. -/
@[simp]
theorem starProjection_inner_eq_zero (v : E) :
∀ w ∈ K, ⟪v - K.starProjection v, w⟫ = 0 :=
orthogonalProjectionFn_inner_eq_zero v
@[deprecated (since := "2025-07-07")] alias orthogonalProjection_inner_eq_zero :=
starProjection_inner_eq_zero
/-- The difference of `v` from its orthogonal projection onto `K` is in `Kᗮ`. -/
@[simp]
theorem sub_starProjection_mem_orthogonal (v : E) : v - K.starProjection v ∈ Kᗮ := by
intro w hw
rw [inner_eq_zero_symm]
exact starProjection_inner_eq_zero _ _ hw
@[deprecated (since := "2025-07-07")] alias sub_orthogonalProjection_mem_orthogonal :=
sub_starProjection_mem_orthogonal
/-- The orthogonal projection is the unique point in `K` with the
orthogonality property. -/
theorem eq_starProjection_of_mem_of_inner_eq_zero {u v : E} (hvm : v ∈ K)
(hvo : ∀ w ∈ K, ⟪u - v, w⟫ = 0) : K.starProjection u = v :=
eq_orthogonalProjectionFn_of_mem_of_inner_eq_zero hvm hvo
@[deprecated (since := "2025-07-07")] alias eq_orthogonalProjection_of_mem_of_inner_eq_zero :=
eq_starProjection_of_mem_of_inner_eq_zero
/-- A point in `K` with the orthogonality property (here characterized in terms of `Kᗮ`) must be the
orthogonal projection. -/
theorem eq_starProjection_of_mem_orthogonal {u v : E} (hv : v ∈ K)
(hvo : u - v ∈ Kᗮ) : K.starProjection u = v :=
eq_orthogonalProjectionFn_of_mem_of_inner_eq_zero hv <| (Submodule.mem_orthogonal' _ _).1 hvo
@[deprecated (since := "2025-07-07")] alias eq_orthogonalProjection_of_mem_orthogonal :=
eq_starProjection_of_mem_orthogonal
/-- A point in `K` with the orthogonality property (here characterized in terms of `Kᗮ`) must be the
orthogonal projection. -/
theorem eq_starProjection_of_mem_orthogonal' {u v z : E}
(hv : v ∈ K) (hz : z ∈ Kᗮ) (hu : u = v + z) : K.starProjection u = v :=
eq_starProjection_of_mem_orthogonal hv (by simpa [hu] )
@[deprecated (since := "2025-07-07")] alias eq_orthogonalProjection_of_mem_orthogonal' :=
eq_starProjection_of_mem_orthogonal'
@[simp]
theorem starProjection_orthogonal_val (u : E) :
Kᗮ.starProjection u = u - K.starProjection u :=
eq_starProjection_of_mem_orthogonal' (sub_starProjection_mem_orthogonal _)
(K.le_orthogonal_orthogonal (K.orthogonalProjection u).2) <| (sub_add_cancel _ _).symm
@[deprecated (since := "2025-07-07")] alias orthogonalProjection_orthogonal_val :=
starProjection_orthogonal_val
theorem orthogonalProjection_orthogonal (u : E) :
Kᗮ.orthogonalProjection u =
⟨u - K.starProjection u, sub_starProjection_mem_orthogonal _⟩ :=
Subtype.eq <| starProjection_orthogonal_val _
lemma starProjection_orthogonal (U : Submodule 𝕜 E) [U.HasOrthogonalProjection] :
Uᗮ.starProjection = ContinuousLinearMap.id 𝕜 E - U.starProjection := by
ext
simp only [starProjection, ContinuousLinearMap.comp_apply,
orthogonalProjection_orthogonal]
simp
lemma starProjection_orthogonal' (U : Submodule 𝕜 E) [U.HasOrthogonalProjection] :
Uᗮ.starProjection = 1 - U.starProjection := starProjection_orthogonal U
/-- The orthogonal projection of `y` on `U` minimizes the distance `‖y - x‖` for `x ∈ U`. -/
theorem starProjection_minimal {U : Submodule 𝕜 E} [U.HasOrthogonalProjection] (y : E) :
‖y - U.starProjection y‖ = ⨅ x : U, ‖y - x‖ := by
rw [starProjection_apply, U.norm_eq_iInf_iff_inner_eq_zero (Submodule.coe_mem _)]
exact starProjection_inner_eq_zero _
@[deprecated (since := "2025-07-07")] alias orthogonalProjection_minimal := starProjection_minimal
/-- The orthogonal projections onto equal subspaces are coerced back to the same point in `E`. -/
@[deprecated "As there are no subtypes causing dependent type issues, there is no need for this
result as `simp` will suffice" (since := "12-07-2025")]
theorem eq_starProjection_of_eq_submodule {K' : Submodule 𝕜 E} [K'.HasOrthogonalProjection]
(h : K = K') (u : E) : K.starProjection u = K'.starProjection u := by
simp [h]
@[deprecated (since := "2025-07-07")] alias eq_orthogonalProjection_of_eq_submodule :=
eq_starProjection_of_eq_submodule
/-- The orthogonal projection sends elements of `K` to themselves. -/
@[simp]
theorem orthogonalProjection_mem_subspace_eq_self (v : K) : K.orthogonalProjection v = v := by
ext
apply eq_starProjection_of_mem_of_inner_eq_zero <;> simp
@[simp]
theorem starProjection_mem_subspace_eq_self (v : K) :
K.starProjection v = v := by simp [starProjection_apply]
/-- A point equals its orthogonal projection if and only if it lies in the subspace. -/
theorem starProjection_eq_self_iff {v : E} : K.starProjection v = v ↔ v ∈ K := by
refine ⟨fun h => ?_, fun h => eq_starProjection_of_mem_of_inner_eq_zero h ?_⟩
· rw [← h]
simp
· simp
@[deprecated (since := "2025-07-07")] alias orthogonalProjection_eq_self_iff :=
starProjection_eq_self_iff
variable (K) in
@[simp]
lemma isIdempotentElem_starProjection : IsIdempotentElem K.starProjection :=
ContinuousLinearMap.ext fun x ↦ starProjection_eq_self_iff.mpr <| by simp
@[simp]
lemma range_starProjection (U : Submodule 𝕜 E) [U.HasOrthogonalProjection] :
LinearMap.range U.starProjection = U := by
ext x
exact ⟨fun ⟨y, hy⟩ ↦ hy ▸ coe_mem (U.orthogonalProjection y),
fun h ↦ ⟨x, starProjection_eq_self_iff.mpr h⟩⟩
lemma starProjection_top : (⊤ : Submodule 𝕜 E).starProjection = ContinuousLinearMap.id 𝕜 E := by
ext
exact starProjection_eq_self_iff.mpr trivial
lemma starProjection_top' : (⊤ : Submodule 𝕜 E).starProjection = 1 :=
starProjection_top
@[simp]
theorem orthogonalProjection_eq_zero_iff {v : E} : K.orthogonalProjection v = 0 ↔ v ∈ Kᗮ := by
refine ⟨fun h ↦ ?_, fun h ↦ Subtype.eq <| eq_starProjection_of_mem_orthogonal
(zero_mem _) ?_⟩
· rw [← sub_zero v, ← coe_zero (p := K), ← h]
exact sub_starProjection_mem_orthogonal (K := K) v
· simpa
@[simp]
theorem ker_orthogonalProjection : LinearMap.ker K.orthogonalProjection = Kᗮ := by
ext; exact orthogonalProjection_eq_zero_iff
open ContinuousLinearMap in
@[simp]
lemma ker_starProjection (U : Submodule 𝕜 E) [U.HasOrthogonalProjection] :
LinearMap.ker U.starProjection = Uᗮ := by
rw [(isIdempotentElem_starProjection U).ker_eq_range, ← starProjection_orthogonal',
range_starProjection]
theorem _root_.LinearIsometry.map_starProjection {E E' : Type*} [NormedAddCommGroup E]
[NormedAddCommGroup E'] [InnerProductSpace 𝕜 E] [InnerProductSpace 𝕜 E'] (f : E →ₗᵢ[𝕜] E')
(p : Submodule 𝕜 E) [p.HasOrthogonalProjection] [(p.map f.toLinearMap).HasOrthogonalProjection]
(x : E) : f (p.starProjection x) = (p.map f.toLinearMap).starProjection (f x) := by
refine (eq_starProjection_of_mem_of_inner_eq_zero ?_ fun y hy => ?_).symm
· refine Submodule.apply_coe_mem_map _ _
rcases hy with ⟨x', hx', rfl : f x' = y⟩
rw [← f.map_sub, f.inner_map_map, starProjection_inner_eq_zero x x' hx']
@[deprecated (since := "2025-07-07")] alias _root_.LinearIsometry.map_orthogonalProjection :=
LinearIsometry.map_starProjection
theorem _root_.LinearIsometry.map_starProjection' {E E' : Type*} [NormedAddCommGroup E]
[NormedAddCommGroup E'] [InnerProductSpace 𝕜 E] [InnerProductSpace 𝕜 E'] (f : E →ₗᵢ[𝕜] E')
(p : Submodule 𝕜 E) [p.HasOrthogonalProjection] [(p.map f).HasOrthogonalProjection] (x : E) :
f (p.starProjection x) = (p.map f).starProjection (f x) :=
have : (p.map f.toLinearMap).HasOrthogonalProjection := ‹_›
f.map_starProjection p x
@[deprecated (since := "2025-07-07")] alias _root_.LinearIsometry.map_orthogonalProjection' :=
LinearIsometry.map_starProjection'
/-- Orthogonal projection onto the `Submodule.map` of a subspace. -/
theorem starProjection_map_apply {E E' : Type*} [NormedAddCommGroup E]
[NormedAddCommGroup E'] [InnerProductSpace 𝕜 E] [InnerProductSpace 𝕜 E'] (f : E ≃ₗᵢ[𝕜] E')
(p : Submodule 𝕜 E) [p.HasOrthogonalProjection] (x : E') :
(p.map (f.toLinearEquiv : E →ₗ[𝕜] E')).starProjection x =
f (p.starProjection (f.symm x)) := by
simpa only [f.coe_toLinearIsometry, f.apply_symm_apply] using
(f.toLinearIsometry.map_starProjection' p (f.symm x)).symm
@[deprecated (since := "2025-07-07")] alias orthogonalProjection_map_apply :=
starProjection_map_apply
/-- The orthogonal projection onto the trivial submodule is the zero map. -/
@[simp]
theorem orthogonalProjection_bot : (⊥ : Submodule 𝕜 E).orthogonalProjection = 0 := by ext
@[simp]
lemma starProjection_bot : (⊥ : Submodule 𝕜 E).starProjection = 0 := by
rw [starProjection, orthogonalProjection_bot, ContinuousLinearMap.comp_zero]
variable (K)
/-- The orthogonal projection has norm `≤ 1`. -/
theorem orthogonalProjection_norm_le : ‖K.orthogonalProjection‖ ≤ 1 :=
LinearMap.mkContinuous_norm_le _ (by simp) _
theorem starProjection_norm_le : ‖K.starProjection‖ ≤ 1 :=
K.orthogonalProjection_norm_le
theorem norm_orthogonalProjection_apply {v : E} (hv : v ∈ K) :
‖orthogonalProjection K v‖ = ‖v‖ :=
congr(‖$(K.starProjection_eq_self_iff.mpr hv)‖)
theorem norm_starProjection_apply {v : E} (hv : v ∈ K) :
‖K.starProjection v‖ = ‖v‖ :=
norm_orthogonalProjection_apply _ hv
/-- The orthogonal projection onto a closed subspace is norm non-increasing. -/
theorem norm_orthogonalProjection_apply_le (v : E) :
‖orthogonalProjection K v‖ ≤ ‖v‖ := by calc
‖orthogonalProjection K v‖ ≤ ‖orthogonalProjection K‖ * ‖v‖ := K.orthogonalProjection.le_opNorm _
_ ≤ 1 * ‖v‖ := by gcongr; exact orthogonalProjection_norm_le K
_ = _ := by simp
theorem norm_starProjection_apply_le (v : E) :
‖K.starProjection v‖ ≤ ‖v‖ := K.norm_orthogonalProjection_apply_le v
/-- The orthogonal projection onto a closed subspace is a `1`-Lipschitz map. -/
theorem lipschitzWith_orthogonalProjection :
LipschitzWith 1 (orthogonalProjection K) :=
ContinuousLinearMap.lipschitzWith_of_opNorm_le (orthogonalProjection_norm_le K)
theorem lipschitzWith_starProjection :
LipschitzWith 1 K.starProjection :=
ContinuousLinearMap.lipschitzWith_of_opNorm_le (starProjection_norm_le K)
/-- The operator norm of the orthogonal projection onto a nontrivial subspace is `1`. -/
theorem norm_orthogonalProjection (hK : K ≠ ⊥) :
‖K.orthogonalProjection‖ = 1 := by
refine le_antisymm K.orthogonalProjection_norm_le ?_
obtain ⟨x, hxK, hx_ne_zero⟩ := Submodule.exists_mem_ne_zero_of_ne_bot hK
simpa [K.norm_orthogonalProjection_apply hxK, norm_eq_zero, hx_ne_zero]
using K.orthogonalProjection.ratio_le_opNorm x
theorem norm_starProjection (hK : K ≠ ⊥) :
‖K.starProjection‖ = 1 :=
K.norm_orthogonalProjection hK
variable (𝕜)
theorem smul_starProjection_singleton {v : E} (w : E) :
((‖v‖ ^ 2 : ℝ) : 𝕜) • (𝕜 ∙ v).starProjection w = ⟪v, w⟫ • v := by
suffices ((𝕜 ∙ v).starProjection (((‖v‖ : 𝕜) ^ 2) • w)) = ⟪v, w⟫ • v by
simpa using this
apply eq_starProjection_of_mem_of_inner_eq_zero
· rw [Submodule.mem_span_singleton]
use ⟪v, w⟫
· rw [← Submodule.mem_orthogonal', Submodule.mem_orthogonal_singleton_iff_inner_left]
simp [inner_sub_left, inner_smul_left, inner_self_eq_norm_sq_to_K, mul_comm]
@[deprecated (since := "2025-07-07")] alias smul_orthogonalProjection_singleton :=
smul_starProjection_singleton
/-- Formula for orthogonal projection onto a single vector. -/
theorem starProjection_singleton {v : E} (w : E) :
(𝕜 ∙ v).starProjection w = (⟪v, w⟫ / ((‖v‖ ^ 2 : ℝ) : 𝕜)) • v := by
by_cases hv : v = 0
· rw [hv]
simp [Submodule.span_zero_singleton 𝕜]
have hv' : ‖v‖ ≠ 0 := ne_of_gt (norm_pos_iff.mpr hv)
have key :
(((‖v‖ ^ 2 : ℝ) : 𝕜)⁻¹ * ((‖v‖ ^ 2 : ℝ) : 𝕜)) • ((𝕜 ∙ v).starProjection w) =
(((‖v‖ ^ 2 : ℝ) : 𝕜)⁻¹ * ⟪v, w⟫) • v := by
simp [mul_smul, smul_starProjection_singleton 𝕜 w, -map_pow]
convert key using 1 <;> match_scalars <;> field_simp [hv']
@[deprecated (since := "2025-07-07")] alias orthogonalProjection_singleton :=
starProjection_singleton
/-- Formula for orthogonal projection onto a single unit vector. -/
theorem starProjection_unit_singleton {v : E} (hv : ‖v‖ = 1) (w : E) :
(𝕜 ∙ v).starProjection w = ⟪v, w⟫ • v := by
rw [← smul_starProjection_singleton 𝕜 w]
simp [hv]
@[deprecated (since := "2025-07-07")] alias orthogonalProjection_unit_singleton :=
starProjection_unit_singleton
end orthogonalProjection
variable {K}
/-- If `K` is complete, any `v` in `E` can be expressed as a sum of elements of `K` and `Kᗮ`. -/
theorem exists_add_mem_mem_orthogonal [K.HasOrthogonalProjection] (v : E) :
∃ y ∈ K, ∃ z ∈ Kᗮ, v = y + z :=
⟨K.orthogonalProjection v, Subtype.coe_prop _, v - K.orthogonalProjection v,
sub_starProjection_mem_orthogonal _, by simp⟩
/-- The orthogonal projection onto `K` of an element of `Kᗮ` is zero. -/
theorem orthogonalProjection_mem_subspace_orthogonalComplement_eq_zero [K.HasOrthogonalProjection]
{v : E} (hv : v ∈ Kᗮ) : K.orthogonalProjection v = 0 := orthogonalProjection_eq_zero_iff.mpr hv
/-- The projection into `U` from an orthogonal submodule `V` is the zero map. -/
theorem IsOrtho.orthogonalProjection_comp_subtypeL {U V : Submodule 𝕜 E}
[U.HasOrthogonalProjection] (h : U ⟂ V) : U.orthogonalProjection ∘L V.subtypeL = 0 :=
ContinuousLinearMap.ext fun v =>
orthogonalProjection_mem_subspace_orthogonalComplement_eq_zero <| h.symm v.prop
theorem IsOrtho.starProjection_comp_starProjection {U V : Submodule 𝕜 E}
[U.HasOrthogonalProjection] [V.HasOrthogonalProjection] (h : U ⟂ V) :
U.starProjection ∘L V.starProjection = 0 :=
calc _ = U.subtypeL ∘L (U.orthogonalProjection ∘L V.subtypeL) ∘L V.orthogonalProjection := by
simp only [starProjection, ContinuousLinearMap.comp_assoc]
_ = 0 := by simp [h.orthogonalProjection_comp_subtypeL]
/-- The projection into `U` from `V` is the zero map if and only if `U` and `V` are orthogonal. -/
theorem orthogonalProjection_comp_subtypeL_eq_zero_iff {U V : Submodule 𝕜 E}
[U.HasOrthogonalProjection] : U.orthogonalProjection ∘L V.subtypeL = 0 ↔ U ⟂ V :=
⟨fun h u hu v hv => by
convert starProjection_inner_eq_zero v u hu using 2
have : U.orthogonalProjection v = 0 := DFunLike.congr_fun h (⟨_, hv⟩ : V)
rw [starProjection_apply, this, Submodule.coe_zero, sub_zero],
Submodule.IsOrtho.orthogonalProjection_comp_subtypeL⟩
/-- `U.starProjection ∘ V.starProjection = 0` iff `U` and `V` are pairwise orthogonal. -/
theorem starProjection_comp_starProjection_eq_zero_iff {U V : Submodule 𝕜 E}
[U.HasOrthogonalProjection] [V.HasOrthogonalProjection] :
U.starProjection ∘L V.starProjection = 0 ↔ U ⟂ V := by
refine ⟨fun h => ?_, fun h => h.starProjection_comp_starProjection⟩
rw [← orthogonalProjection_comp_subtypeL_eq_zero_iff]
simp only [ContinuousLinearMap.ext_iff, ContinuousLinearMap.comp_apply, subtypeL_apply,
starProjection_apply, ContinuousLinearMap.zero_apply, coe_eq_zero] at h ⊢
intro x
simpa using h (x : E)
/-- The orthogonal projection onto `Kᗮ` of an element of `K` is zero. -/
theorem orthogonalProjection_orthogonal_apply_eq_zero
[Kᗮ.HasOrthogonalProjection] {v : E} (hv : v ∈ K) : Kᗮ.orthogonalProjection v = 0 :=
orthogonalProjection_mem_subspace_orthogonalComplement_eq_zero (K.le_orthogonal_orthogonal hv)
@[deprecated (since := "22-07-2025")] alias
orthogonalProjection_mem_subspace_orthogonal_precomplement_eq_zero :=
orthogonalProjection_orthogonal_apply_eq_zero
theorem starProjection_orthogonal_apply_eq_zero
[Kᗮ.HasOrthogonalProjection] {v : E} (hv : v ∈ K) :
Kᗮ.starProjection v = 0 := by
rw [starProjection_apply, coe_eq_zero]
exact orthogonalProjection_orthogonal_apply_eq_zero hv
/-- If `U ≤ V`, then projecting on `V` and then on `U` is the same as projecting on `U`. -/
theorem orthogonalProjection_starProjection_of_le {U V : Submodule 𝕜 E}
[U.HasOrthogonalProjection] [V.HasOrthogonalProjection] (h : U ≤ V) (x : E) :
U.orthogonalProjection (V.starProjection x) = U.orthogonalProjection x :=
Eq.symm <| by
simpa only [sub_eq_zero, map_sub] using
orthogonalProjection_mem_subspace_orthogonalComplement_eq_zero
(Submodule.orthogonal_le h (sub_starProjection_mem_orthogonal x))
@[deprecated (since := "2025-07-07")] alias orthogonalProjection_orthogonalProjection_of_le :=
orthogonalProjection_starProjection_of_le
theorem starProjection_comp_starProjection_of_le {U V : Submodule 𝕜 E}
[U.HasOrthogonalProjection] [V.HasOrthogonalProjection] (h : U ≤ V) :
U.starProjection ∘L V.starProjection = U.starProjection := ContinuousLinearMap.ext fun _ => by
nth_rw 1 [starProjection]
simp [orthogonalProjection_starProjection_of_le h]
open ContinuousLinearMap in
theorem _root_.ContinuousLinearMap.IsIdempotentElem.hasOrthogonalProjection_range [CompleteSpace E]
{p : E →L[𝕜] E} (hp : IsIdempotentElem p) : (LinearMap.range p).HasOrthogonalProjection :=
have := hp.isClosed_range.completeSpace_coe
.ofCompleteSpace _
open LinearMap in
theorem _root_.LinearMap.IsSymmetricProjection.hasOrthogonalProjection_range
{p : E →ₗ[𝕜] E} (hp : p.IsSymmetricProjection) :
(range p).HasOrthogonalProjection :=
⟨fun v => ⟨p v, by
simp [hp.isIdempotentElem.isSymmetric_iff_orthogonal_range.mp hp.isSymmetric,
← Module.End.mul_apply, hp.isIdempotentElem.eq]⟩⟩
/-- The orthogonal projection onto `(𝕜 ∙ v)ᗮ` of `v` is zero. -/
theorem orthogonalProjection_orthogonalComplement_singleton_eq_zero (v : E) :
(𝕜 ∙ v)ᗮ.orthogonalProjection v = 0 :=
orthogonalProjection_orthogonal_apply_eq_zero
(Submodule.mem_span_singleton_self v)
theorem starProjection_orthogonalComplement_singleton_eq_zero (v : E) :
(𝕜 ∙ v)ᗮ.starProjection v = 0 := by
rw [starProjection_apply, coe_eq_zero]
exact orthogonalProjection_orthogonalComplement_singleton_eq_zero v
/-- If the orthogonal projection to `K` is well-defined, then a vector splits as the sum of its
orthogonal projections onto a complete submodule `K` and onto the orthogonal complement of `K`. -/
theorem starProjection_add_starProjection_orthogonal [K.HasOrthogonalProjection]
(w : E) : K.starProjection w + Kᗮ.starProjection w = w := by
simp
@[deprecated (since := "2025-07-07")] alias
orthogonalProjection_add_orthogonalProjection_orthogonal :=
starProjection_add_starProjection_orthogonal
/-- The Pythagorean theorem, for an orthogonal projection. -/
theorem norm_sq_eq_add_norm_sq_projection (x : E) (S : Submodule 𝕜 E) [S.HasOrthogonalProjection] :
‖x‖ ^ 2 = ‖S.orthogonalProjection x‖ ^ 2 + ‖Sᗮ.orthogonalProjection x‖ ^ 2 :=
calc
‖x‖ ^ 2 = ‖S.starProjection x + Sᗮ.starProjection x‖ ^ 2 := by
rw [starProjection_add_starProjection_orthogonal]
_ = ‖S.orthogonalProjection x‖ ^ 2 + ‖Sᗮ.orthogonalProjection x‖ ^ 2 := by
simp only [sq]
exact norm_add_sq_eq_norm_sq_add_norm_sq_of_inner_eq_zero _ _ <|
(S.mem_orthogonal _).1 (Sᗮ.orthogonalProjection x).2 _ (S.orthogonalProjection x).2
theorem norm_sq_eq_add_norm_sq_starProjection (x : E) (S : Submodule 𝕜 E)
[S.HasOrthogonalProjection] :
‖x‖ ^ 2 = ‖S.starProjection x‖ ^ 2 + ‖Sᗮ.starProjection x‖ ^ 2 :=
norm_sq_eq_add_norm_sq_projection x S
theorem mem_iff_norm_starProjection (U : Submodule 𝕜 E)
[U.HasOrthogonalProjection] (v : E) :
v ∈ U ↔ ‖U.starProjection v‖ = ‖v‖ := by
refine ⟨fun h => norm_starProjection_apply _ h, fun h => ?_⟩
simpa [h, sub_eq_zero, eq_comm (a := v), starProjection_eq_self_iff] using
U.norm_sq_eq_add_norm_sq_starProjection v
/-- In a complete space `E`, the projection maps onto a complete subspace `K` and its orthogonal
complement sum to the identity. -/
theorem id_eq_sum_starProjection_self_orthogonalComplement [K.HasOrthogonalProjection] :
ContinuousLinearMap.id 𝕜 E =
K.starProjection + Kᗮ.starProjection := by
ext w
exact (K.starProjection_add_starProjection_orthogonal w).symm
@[deprecated (since := "2025-07-07")] alias
id_eq_sum_orthogonalProjection_self_orthogonalComplement :=
id_eq_sum_starProjection_self_orthogonalComplement
-- The priority should be higher than `Submodule.coe_inner`.
@[simp high]
theorem inner_orthogonalProjection_eq_of_mem_right [K.HasOrthogonalProjection] (u : K) (v : E) :
⟪K.orthogonalProjection v, u⟫ = ⟪v, u⟫ :=
calc
⟪K.orthogonalProjection v, u⟫ = ⟪K.starProjection v, u⟫ := K.coe_inner _ _
_ = ⟪K.starProjection v, u⟫ + ⟪v - K.starProjection v, u⟫ := by
rw [starProjection_inner_eq_zero _ _ (Submodule.coe_mem _), add_zero]
_ = ⟪v, u⟫ := by rw [← inner_add_left, add_sub_cancel]
-- The priority should be higher than `Submodule.coe_inner`.
@[simp high]
theorem inner_orthogonalProjection_eq_of_mem_left [K.HasOrthogonalProjection] (u : K) (v : E) :
⟪u, K.orthogonalProjection v⟫ = ⟪(u : E), v⟫ := by
rw [← inner_conj_symm, ← inner_conj_symm (u : E), inner_orthogonalProjection_eq_of_mem_right]
variable (K)
/-- The orthogonal projection is self-adjoint. -/
theorem inner_starProjection_left_eq_right [K.HasOrthogonalProjection] (u v : E) :
⟪K.starProjection u, v⟫ = ⟪u, K.starProjection v⟫ := by
simp_rw [starProjection_apply, ← inner_orthogonalProjection_eq_of_mem_left,
inner_orthogonalProjection_eq_of_mem_right]
@[deprecated (since := "2025-07-07")] alias
inner_orthogonalProjection_left_eq_right := inner_starProjection_left_eq_right
/-- The orthogonal projection is symmetric. -/
theorem starProjection_isSymmetric [K.HasOrthogonalProjection] :
(K.starProjection : E →ₗ[𝕜] E).IsSymmetric :=
inner_starProjection_left_eq_right K
@[deprecated (since := "2025-07-07")] alias
orthogonalProjection_isSymmetric := starProjection_isSymmetric
open ContinuousLinearMap in
/-- `U.starProjection` is a symmetric projection. -/
@[simp]
theorem isSymmetricProjection_starProjection
(U : Submodule 𝕜 E) [U.HasOrthogonalProjection] :
U.starProjection.IsSymmetricProjection :=
⟨U.isIdempotentElem_starProjection.toLinearMap, U.starProjection_isSymmetric⟩
open LinearMap in
/-- An operator is a symmetric projection if and only if it is an orthogonal projection. -/
theorem _root_.LinearMap.isSymmetricProjection_iff_eq_coe_starProjection_range {p : E →ₗ[𝕜] E} :
p.IsSymmetricProjection ↔ ∃ (_ : (LinearMap.range p).HasOrthogonalProjection),
p = (LinearMap.range p).starProjection := by
refine ⟨fun hp ↦ ?_, fun ⟨h, hp⟩ ↦ hp ▸ isSymmetricProjection_starProjection _⟩
have : (LinearMap.range p).HasOrthogonalProjection := hp.hasOrthogonalProjection_range
refine ⟨this, Eq.symm ?_⟩
ext x
refine Submodule.eq_starProjection_of_mem_orthogonal (by simp) ?_
rw [hp.isIdempotentElem.isSymmetric_iff_orthogonal_range.mp hp.isSymmetric]
simpa using congr($hp.isIdempotentElem.mul_one_sub_self x)
lemma _root_.LinearMap.isSymmetricProjection_iff_eq_coe_starProjection {p : E →ₗ[𝕜] E} :
p.IsSymmetricProjection
↔ ∃ (K : Submodule 𝕜 E) (_ : K.HasOrthogonalProjection), p = K.starProjection :=
⟨fun h ↦ ⟨LinearMap.range p, p.isSymmetricProjection_iff_eq_coe_starProjection_range.mp h⟩,
by rintro ⟨_, _, rfl⟩; exact isSymmetricProjection_starProjection _⟩
theorem starProjection_apply_eq_zero_iff [K.HasOrthogonalProjection] {v : E} :
K.starProjection v = 0 ↔ v ∈ Kᗮ := by
refine ⟨fun h w hw => ?_, fun hv => ?_⟩
· rw [← starProjection_eq_self_iff.mpr hw, inner_starProjection_left_eq_right, h,
inner_zero_right]
· simp [starProjection_apply, orthogonalProjection_mem_subspace_orthogonalComplement_eq_zero hv]
open RCLike
lemma re_inner_starProjection_eq_normSq [K.HasOrthogonalProjection] (v : E) :
re ⟪K.starProjection v, v⟫ = ‖K.orthogonalProjection v‖^2 := by
rw [starProjection_apply,
re_inner_eq_norm_mul_self_add_norm_mul_self_sub_norm_sub_mul_self_div_two,
div_eq_iff (NeZero.ne' 2).symm, pow_two, add_sub_assoc, ← eq_sub_iff_add_eq', coe_norm,
← mul_sub_one, show (2 : ℝ) - 1 = 1 by norm_num, mul_one, sub_eq_iff_eq_add', norm_sub_rev]
exact orthogonalProjectionFn_norm_sq K v
@[deprecated (since := "2025-07-07")] alias
re_inner_orthogonalProjection_eq_normSq := re_inner_starProjection_eq_normSq
lemma re_inner_starProjection_nonneg [K.HasOrthogonalProjection] (v : E) :
0 ≤ re ⟪K.starProjection v, v⟫ := by
rw [re_inner_starProjection_eq_normSq K v]
exact sq_nonneg ‖K.orthogonalProjection v‖
@[deprecated (since := "2025-07-07")] alias
re_inner_orthogonalProjection_nonneg := re_inner_starProjection_nonneg
end
end Submodule |
.lake/packages/mathlib/Mathlib/Analysis/InnerProductSpace/Projection/Minimal.lean | import Mathlib.Analysis.InnerProductSpace.Basic
import Mathlib.Analysis.SpecificLimits.Basic
/-!
# Existence of minimizers (Hilbert projection theorem)
This file shows the existence of minimizers (also known as the Hilbert projection theorem).
This is the key tool that is used to define `Submodule.orthogonalProjection` in
`Mathlib/Analysis/InnerProductSpace/Projection/Basic.lean`.
-/
variable {𝕜 E F : Type*} [RCLike 𝕜]
variable [NormedAddCommGroup E] [NormedAddCommGroup F]
variable [InnerProductSpace 𝕜 E] [InnerProductSpace ℝ F]
local notation "⟪" x ", " y "⟫" => inner 𝕜 x y
local notation "absR" => @abs ℝ _ _
open Topology RCLike Real Filter InnerProductSpace
/-- **Existence of minimizers**, aka the **Hilbert projection theorem**.
Let `u` be a point in a real inner product space, and let `K` be a nonempty complete convex subset.
Then there exists a (unique) `v` in `K` that minimizes the distance `‖u - v‖` to `u`. -/
theorem exists_norm_eq_iInf_of_complete_convex {K : Set F} (ne : K.Nonempty) (h₁ : IsComplete K)
(h₂ : Convex ℝ K) : ∀ u : F, ∃ v ∈ K, ‖u - v‖ = ⨅ w : K, ‖u - w‖ := fun u => by
let δ := ⨅ w : K, ‖u - w‖
letI : Nonempty K := ne.to_subtype
have zero_le_δ : 0 ≤ δ := le_ciInf fun _ => norm_nonneg _
have δ_le : ∀ w : K, δ ≤ ‖u - w‖ := ciInf_le ⟨0, Set.forall_mem_range.2 fun _ => norm_nonneg _⟩
have δ_le' : ∀ w ∈ K, δ ≤ ‖u - w‖ := fun w hw => δ_le ⟨w, hw⟩
-- Step 1: since `δ` is the infimum, can find a sequence `w : ℕ → K` in `K`
-- such that `‖u - w n‖ < δ + 1 / (n + 1)` (which implies `‖u - w n‖ --> δ`);
-- maybe this should be a separate lemma
have exists_seq : ∃ w : ℕ → K, ∀ n, ‖u - w n‖ < δ + 1 / (n + 1) := by
have hδ : ∀ n : ℕ, δ < δ + 1 / (n + 1) := fun n =>
lt_add_of_le_of_pos le_rfl Nat.one_div_pos_of_nat
have h := fun n => exists_lt_of_ciInf_lt (hδ n)
let w : ℕ → K := fun n => Classical.choose (h n)
exact ⟨w, fun n => Classical.choose_spec (h n)⟩
rcases exists_seq with ⟨w, hw⟩
have norm_tendsto : Tendsto (fun n => ‖u - w n‖) atTop (𝓝 δ) := by
have h : Tendsto (fun _ : ℕ => δ) atTop (𝓝 δ) := tendsto_const_nhds
have h' : Tendsto (fun n : ℕ => δ + 1 / (n + 1)) atTop (𝓝 δ) := by
convert h.add tendsto_one_div_add_atTop_nhds_zero_nat
simp only [add_zero]
exact tendsto_of_tendsto_of_tendsto_of_le_of_le h h' (fun x => δ_le _) fun x => le_of_lt (hw _)
-- Step 2: Prove that the sequence `w : ℕ → K` is a Cauchy sequence
have seq_is_cauchy : CauchySeq fun n => (w n : F) := by
rw [cauchySeq_iff_le_tendsto_0]
-- splits into three goals
let b := fun n : ℕ => 8 * δ * (1 / (n + 1)) + 4 * (1 / (n + 1)) * (1 / (n + 1))
use fun n => √(b n)
constructor
-- first goal : `∀ (n : ℕ), 0 ≤ √(b n)`
· intro n
exact sqrt_nonneg _
constructor
-- second goal : `∀ (n m N : ℕ), N ≤ n → N ≤ m → dist ↑(w n) ↑(w m) ≤ √(b N)`
· intro p q N hp hq
let wp := (w p : F)
let wq := (w q : F)
let a := u - wq
let b := u - wp
let half := 1 / (2 : ℝ)
let div := 1 / ((N : ℝ) + 1)
have :
4 * ‖u - half • (wq + wp)‖ * ‖u - half • (wq + wp)‖ + ‖wp - wq‖ * ‖wp - wq‖ =
2 * (‖a‖ * ‖a‖ + ‖b‖ * ‖b‖) :=
calc
4 * ‖u - half • (wq + wp)‖ * ‖u - half • (wq + wp)‖ + ‖wp - wq‖ * ‖wp - wq‖ =
2 * ‖u - half • (wq + wp)‖ * (2 * ‖u - half • (wq + wp)‖) + ‖wp - wq‖ * ‖wp - wq‖ :=
by ring
_ =
absR 2 * ‖u - half • (wq + wp)‖ * (absR 2 * ‖u - half • (wq + wp)‖) +
‖wp - wq‖ * ‖wp - wq‖ := by
rw [abs_of_nonneg]
exact zero_le_two
_ =
‖(2 : ℝ) • (u - half • (wq + wp))‖ * ‖(2 : ℝ) • (u - half • (wq + wp))‖ +
‖wp - wq‖ * ‖wp - wq‖ := by simp [norm_smul]
_ = ‖a + b‖ * ‖a + b‖ + ‖a - b‖ * ‖a - b‖ := by
rw [smul_sub, smul_smul, mul_one_div_cancel (_root_.two_ne_zero : (2 : ℝ) ≠ 0), ←
one_add_one_eq_two, add_smul]
simp only [one_smul]
have eq₁ : wp - wq = a - b := (sub_sub_sub_cancel_left _ _ _).symm
have eq₂ : u + u - (wq + wp) = a + b := by
change u + u - (wq + wp) = u - wq + (u - wp)
abel
rw [eq₁, eq₂]
_ = 2 * (‖a‖ * ‖a‖ + ‖b‖ * ‖b‖) := parallelogram_law_with_norm ℝ _ _
have eq : δ ≤ ‖u - half • (wq + wp)‖ := by
rw [smul_add]
apply δ_le'
apply h₂
repeat' exact Subtype.mem _
repeat' exact le_of_lt one_half_pos
exact add_halves 1
have eq₂ : ‖a‖ ≤ δ + div := by grw [hw, Nat.one_div_le_one_div hq]
have eq₂' : ‖b‖ ≤ δ + div := by grw [hw, Nat.one_div_le_one_div hp]
rw [dist_eq_norm]
apply nonneg_le_nonneg_of_sq_le_sq
· exact sqrt_nonneg _
rw [mul_self_sqrt]
· calc
‖wp - wq‖ * ‖wp - wq‖ =
2 * (‖a‖ * ‖a‖ + ‖b‖ * ‖b‖) - 4 * ‖u - half • (wq + wp)‖ * ‖u - half • (wq + wp)‖ := by
simp [← this]
_ ≤ 2 * (‖a‖ * ‖a‖ + ‖b‖ * ‖b‖) - 4 * δ * δ := by gcongr
_ ≤ 2 * ((δ + div) * (δ + div) + (δ + div) * (δ + div)) - 4 * δ * δ := by gcongr
_ = 8 * δ * div + 4 * div * div := by ring
positivity
-- third goal : `Tendsto (fun (n : ℕ) => √(b n)) atTop (𝓝 0)`
suffices Tendsto (fun x ↦ √(8 * δ * x + 4 * x * x) : ℝ → ℝ) (𝓝 0) (𝓝 0)
from this.comp tendsto_one_div_add_atTop_nhds_zero_nat
exact Continuous.tendsto' (by fun_prop) _ _ (by simp)
-- Step 3: By completeness of `K`, let `w : ℕ → K` converge to some `v : K`.
-- Prove that it satisfies all requirements.
rcases cauchySeq_tendsto_of_isComplete h₁ (fun n => Subtype.mem _) seq_is_cauchy with
⟨v, hv, w_tendsto⟩
use v
use hv
have h_cont : Continuous fun v => ‖u - v‖ :=
Continuous.comp continuous_norm (Continuous.sub continuous_const continuous_id)
have : Tendsto (fun n => ‖u - w n‖) atTop (𝓝 ‖u - v‖) := by
convert Tendsto.comp h_cont.continuousAt w_tendsto
exact tendsto_nhds_unique this norm_tendsto
/-- Characterization of minimizers for the projection on a convex set in a real inner product
space. -/
theorem norm_eq_iInf_iff_real_inner_le_zero {K : Set F} (h : Convex ℝ K) {u : F} {v : F}
(hv : v ∈ K) : (‖u - v‖ = ⨅ w : K, ‖u - w‖) ↔ ∀ w ∈ K, ⟪u - v, w - v⟫_ℝ ≤ 0 := by
letI : Nonempty K := ⟨⟨v, hv⟩⟩
constructor
· intro eq w hw
let δ := ⨅ w : K, ‖u - w‖
let p := ⟪u - v, w - v⟫_ℝ
let q := ‖w - v‖ ^ 2
have δ_le (w : K) : δ ≤ ‖u - w‖ := ciInf_le ⟨0, fun _ ⟨_, h⟩ => h ▸ norm_nonneg _⟩ _
have δ_le' (w) (hw : w ∈ K) : δ ≤ ‖u - w‖ := δ_le ⟨w, hw⟩
have (θ : ℝ) (hθ₁ : 0 < θ) (hθ₂ : θ ≤ 1) : 2 * p ≤ θ * q := by
have : ‖u - v‖ ^ 2 ≤ ‖u - v‖ ^ 2 - 2 * θ * ⟪u - v, w - v⟫_ℝ + θ * θ * ‖w - v‖ ^ 2 :=
calc ‖u - v‖ ^ 2
_ ≤ ‖u - (θ • w + (1 - θ) • v)‖ ^ 2 := by
simp only [sq]; apply mul_self_le_mul_self (norm_nonneg _)
rw [eq]; apply δ_le'
apply h hw hv
exacts [le_of_lt hθ₁, sub_nonneg.2 hθ₂, add_sub_cancel _ _]
_ = ‖u - v - θ • (w - v)‖ ^ 2 := by
have : u - (θ • w + (1 - θ) • v) = u - v - θ • (w - v) := by
rw [smul_sub, sub_smul, one_smul]
simp only [sub_eq_add_neg, add_comm, add_left_comm, add_assoc, neg_add_rev]
rw [this]
_ = ‖u - v‖ ^ 2 - 2 * θ * ⟪u - v, w - v⟫_ℝ + θ * θ * ‖w - v‖ ^ 2 := by
rw [@norm_sub_sq ℝ, inner_smul_right, norm_smul]
simp only [sq]
change
‖u - v‖ * ‖u - v‖ - 2 * (θ * ⟪u - v, w - v⟫_ℝ) +
absR θ * ‖w - v‖ * (absR θ * ‖w - v‖) =
‖u - v‖ * ‖u - v‖ - 2 * θ * ⟪u - v, w - v⟫_ℝ + θ * θ * (‖w - v‖ * ‖w - v‖)
rw [abs_of_pos hθ₁]; ring
have eq₁ :
‖u - v‖ ^ 2 - 2 * θ * ⟪u - v, w - v⟫_ℝ + θ * θ * ‖w - v‖ ^ 2 =
‖u - v‖ ^ 2 + (θ * θ * ‖w - v‖ ^ 2 - 2 * θ * ⟪u - v, w - v⟫_ℝ) := by
abel
rw [eq₁, le_add_iff_nonneg_right] at this
have eq₂ :
θ * θ * ‖w - v‖ ^ 2 - 2 * θ * ⟪u - v, w - v⟫_ℝ =
θ * (θ * ‖w - v‖ ^ 2 - 2 * ⟪u - v, w - v⟫_ℝ) := by ring
rw [eq₂] at this
exact le_of_sub_nonneg (nonneg_of_mul_nonneg_right this hθ₁)
by_cases hq : q = 0
· rw [hq] at this
have : p ≤ 0 := by
have := this (1 : ℝ) (by simp) (by simp)
linarith
exact this
· have q_pos : 0 < q := lt_of_le_of_ne (sq_nonneg _) fun h ↦ hq h.symm
by_contra hp
rw [not_le] at hp
let θ := min (1 : ℝ) (p / q)
have eq₁ : θ * q ≤ p :=
calc
θ * q ≤ p / q * q := mul_le_mul_of_nonneg_right (min_le_right _ _) (sq_nonneg _)
_ = p := div_mul_cancel₀ _ hq
have : 2 * p ≤ p :=
calc
2 * p ≤ θ * q := by
exact this θ (lt_min (by simp) (div_pos hp q_pos)) (by simp [θ])
_ ≤ p := eq₁
linarith
· intro h
apply le_antisymm
· apply le_ciInf
intro w
apply nonneg_le_nonneg_of_sq_le_sq (norm_nonneg _)
have := h w w.2
calc
‖u - v‖ * ‖u - v‖ ≤ ‖u - v‖ * ‖u - v‖ - 2 * ⟪u - v, w - v⟫_ℝ := by linarith
_ ≤ ‖u - v‖ ^ 2 - 2 * ⟪u - v, w - v⟫_ℝ + ‖w - v‖ ^ 2 := by
rw [sq]
refine le_add_of_nonneg_right ?_
exact sq_nonneg _
_ = ‖u - v - (w - v)‖ ^ 2 := (@norm_sub_sq ℝ _ _ _ _ _ _).symm
_ = ‖u - w‖ * ‖u - w‖ := by
have : u - v - (w - v) = u - w := by abel
rw [this, sq]
· change ⨅ w : K, ‖u - w‖ ≤ (fun w : K => ‖u - w‖) ⟨v, hv⟩
apply ciInf_le
use 0
rintro y ⟨z, rfl⟩
exact norm_nonneg _
namespace Submodule
variable (K : Submodule 𝕜 E)
/-- Existence of projections on complete subspaces.
Let `u` be a point in an inner product space, and let `K` be a nonempty complete subspace.
Then there exists a (unique) `v` in `K` that minimizes the distance `‖u - v‖` to `u`.
This point `v` is usually called the orthogonal projection of `u` onto `K`.
-/
theorem exists_norm_eq_iInf_of_complete_subspace (h : IsComplete (↑K : Set E)) :
∀ u : E, ∃ v ∈ K, ‖u - v‖ = ⨅ w : (K : Set E), ‖u - w‖ := by
letI : InnerProductSpace ℝ E := InnerProductSpace.rclikeToReal 𝕜 E
letI : Module ℝ E := RestrictScalars.module ℝ 𝕜 E
let K' : Submodule ℝ E := Submodule.restrictScalars ℝ K
exact exists_norm_eq_iInf_of_complete_convex ⟨0, K'.zero_mem⟩ h K'.convex
/-- Characterization of minimizers in the projection on a subspace, in the real case.
Let `u` be a point in a real inner product space, and let `K` be a nonempty subspace.
Then point `v` minimizes the distance `‖u - v‖` over points in `K` if and only if
for all `w ∈ K`, `⟪u - v, w⟫ = 0` (i.e., `u - v` is orthogonal to the subspace `K`).
This is superseded by `norm_eq_iInf_iff_inner_eq_zero` that gives the same conclusion over
any `RCLike` field.
-/
theorem norm_eq_iInf_iff_real_inner_eq_zero (K : Submodule ℝ F) {u : F} {v : F} (hv : v ∈ K) :
(‖u - v‖ = ⨅ w : (↑K : Set F), ‖u - w‖) ↔ ∀ w ∈ K, ⟪u - v, w⟫_ℝ = 0 :=
Iff.intro
(by
intro h
have h : ∀ w ∈ K, ⟪u - v, w - v⟫_ℝ ≤ 0 := by
rwa [norm_eq_iInf_iff_real_inner_le_zero] at h
exacts [K.convex, hv]
intro w hw
have le : ⟪u - v, w⟫_ℝ ≤ 0 := by
let w' := w + v
have : w' ∈ K := Submodule.add_mem _ hw hv
have h₁ := h w' this
have h₂ : w' - v = w := by
simp only [w', add_neg_cancel_right, sub_eq_add_neg]
rw [h₂] at h₁
exact h₁
have ge : ⟪u - v, w⟫_ℝ ≥ 0 := by
let w'' := -w + v
have : w'' ∈ K := Submodule.add_mem _ (Submodule.neg_mem _ hw) hv
have h₁ := h w'' this
have h₂ : w'' - v = -w := by
simp only [w'', add_neg_cancel_right, sub_eq_add_neg]
rw [h₂, inner_neg_right] at h₁
linarith
exact le_antisymm le ge)
(by
intro h
have : ∀ w ∈ K, ⟪u - v, w - v⟫_ℝ ≤ 0 := by
intro w hw
let w' := w - v
have : w' ∈ K := Submodule.sub_mem _ hw hv
have h₁ := h w' this
exact le_of_eq h₁
rwa [norm_eq_iInf_iff_real_inner_le_zero]
exacts [Submodule.convex _, hv])
/-- Characterization of minimizers in the projection on a subspace.
Let `u` be a point in an inner product space, and let `K` be a nonempty subspace.
Then point `v` minimizes the distance `‖u - v‖` over points in `K` if and only if
for all `w ∈ K`, `⟪u - v, w⟫ = 0` (i.e., `u - v` is orthogonal to the subspace `K`)
-/
theorem norm_eq_iInf_iff_inner_eq_zero {u : E} {v : E} (hv : v ∈ K) :
(‖u - v‖ = ⨅ w : K, ‖u - w‖) ↔ ∀ w ∈ K, ⟪u - v, w⟫ = 0 := by
letI : InnerProductSpace ℝ E := InnerProductSpace.rclikeToReal 𝕜 E
letI : Module ℝ E := RestrictScalars.module ℝ 𝕜 E
let K' : Submodule ℝ E := K.restrictScalars ℝ
constructor
· intro H
have A : ∀ w ∈ K, re ⟪u - v, w⟫ = 0 := (K'.norm_eq_iInf_iff_real_inner_eq_zero hv).1 H
intro w hw
apply RCLike.ext
· simp [A w hw]
· symm
calc
im (0 : 𝕜) = 0 := im.map_zero
_ = re ⟪u - v, (-I : 𝕜) • w⟫ := (A _ (K.smul_mem (-I) hw)).symm
_ = re (-I * ⟪u - v, w⟫) := by rw [inner_smul_right]
_ = im ⟪u - v, w⟫ := by simp
· intro H
have : ∀ w ∈ K', ⟪u - v, w⟫_ℝ = 0 := by
intro w hw
rw [real_inner_eq_re_inner, H w hw]
exact zero_re
exact (K'.norm_eq_iInf_iff_real_inner_eq_zero hv).2 this
end Submodule |
.lake/packages/mathlib/Mathlib/Analysis/InnerProductSpace/Projection/Submodule.lean | import Mathlib.Analysis.InnerProductSpace.Projection.Basic
/-!
# Subspaces associated with orthogonal projections
Here, the orthogonal projection is used to prove a series of more subtle lemmas about the
orthogonal complement of subspaces of `E` (the orthogonal complement itself was
defined in `Mathlib/Analysis/InnerProductSpace/Orthogonal.lean`) such that they admit
orthogonal projections; the lemma
`Submodule.sup_orthogonal_of_hasOrthogonalProjection`,
stating that for a subspace `K` of `E` such that `K` admits an orthogonal projection we have
`K ⊔ Kᗮ = ⊤`, is a typical example.
-/
variable {𝕜 E F : Type*} [RCLike 𝕜]
variable [NormedAddCommGroup E] [NormedAddCommGroup F]
variable [InnerProductSpace 𝕜 E] [InnerProductSpace ℝ F]
local notation "⟪" x ", " y "⟫" => inner 𝕜 x y
variable (K : Submodule 𝕜 E)
namespace Submodule
/-- If `K₁` admits an orthogonal projection and is contained in `K₂`,
then `K₁` and `K₁ᗮ ⊓ K₂` span `K₂`. -/
theorem sup_orthogonal_inf_of_hasOrthogonalProjection {K₁ K₂ : Submodule 𝕜 E} (h : K₁ ≤ K₂)
[K₁.HasOrthogonalProjection] : K₁ ⊔ K₁ᗮ ⊓ K₂ = K₂ := by
ext x
rw [Submodule.mem_sup]
let v : K₁ := orthogonalProjection K₁ x
have hvm : x - v ∈ K₁ᗮ := sub_starProjection_mem_orthogonal x
constructor
· rintro ⟨y, hy, z, hz, rfl⟩
exact K₂.add_mem (h hy) hz.2
· exact fun hx => ⟨v, v.prop, x - v, ⟨hvm, K₂.sub_mem hx (h v.prop)⟩, add_sub_cancel _ _⟩
@[deprecated (since := "2025-07-27")] alias sup_orthogonal_inf_of_completeSpace :=
sup_orthogonal_inf_of_hasOrthogonalProjection
variable {K} in
/-- If `K` admits an orthogonal projection, then `K` and `Kᗮ` span the whole space. -/
theorem sup_orthogonal_of_hasOrthogonalProjection [K.HasOrthogonalProjection] : K ⊔ Kᗮ = ⊤ := by
convert Submodule.sup_orthogonal_inf_of_hasOrthogonalProjection (le_top : K ≤ ⊤) using 2
simp
@[deprecated (since := "2025-07-27")] alias sup_orthogonal_of_completeSpace :=
sup_orthogonal_of_hasOrthogonalProjection
/-- If `K` admits an orthogonal projection, then the orthogonal complement of its orthogonal
complement is itself. -/
@[simp]
theorem orthogonal_orthogonal [K.HasOrthogonalProjection] : Kᗮᗮ = K := by
ext v
constructor
· obtain ⟨y, hy, z, hz, rfl⟩ := K.exists_add_mem_mem_orthogonal v
intro hv
have hz' : z = 0 := by
have hyz : ⟪z, y⟫ = 0 := by simp [hz y hy, inner_eq_zero_symm]
simpa [inner_add_right, hyz] using hv z hz
simp [hy, hz']
· intro hv w hw
rw [inner_eq_zero_symm]
exact hw v hv
lemma orthogonal_le_orthogonal_iff {K₀ K₁ : Submodule 𝕜 E} [K₀.HasOrthogonalProjection]
[K₁.HasOrthogonalProjection] : K₀ᗮ ≤ K₁ᗮ ↔ K₁ ≤ K₀ :=
⟨fun h ↦ by simpa using orthogonal_le h, orthogonal_le⟩
lemma orthogonal_le_iff_orthogonal_le {K₀ K₁ : Submodule 𝕜 E} [K₀.HasOrthogonalProjection]
[K₁.HasOrthogonalProjection] : K₀ᗮ ≤ K₁ ↔ K₁ᗮ ≤ K₀ := by
rw [← orthogonal_le_orthogonal_iff, orthogonal_orthogonal]
lemma le_orthogonal_iff_le_orthogonal {K₀ K₁ : Submodule 𝕜 E} [K₀.HasOrthogonalProjection]
[K₁.HasOrthogonalProjection] : K₀ ≤ K₁ᗮ ↔ K₁ ≤ K₀ᗮ := by
rw [← orthogonal_le_orthogonal_iff, orthogonal_orthogonal]
/-- In a Hilbert space, the orthogonal complement of the orthogonal complement of a subspace `K`
is the topological closure of `K`.
Note that the completeness assumption is necessary. Let `E` be the space `ℕ →₀ ℝ` with inner space
structure inherited from `PiLp 2 (fun _ : ℕ ↦ ℝ)`. Let `K` be the subspace of sequences with the sum
of all elements equal to zero. Then `Kᗮ = ⊥`, `Kᗮᗮ = ⊤`. -/
theorem orthogonal_orthogonal_eq_closure [CompleteSpace E] :
Kᗮᗮ = K.topologicalClosure := by
refine le_antisymm ?_ ?_
· convert Submodule.orthogonal_orthogonal_monotone K.le_topologicalClosure using 1
rw [K.topologicalClosure.orthogonal_orthogonal]
· exact K.topologicalClosure_minimal K.le_orthogonal_orthogonal Kᗮ.isClosed_orthogonal
variable {K}
/-- If `K` admits an orthogonal projection, `K` and `Kᗮ` are complements of each other. -/
theorem isCompl_orthogonal_of_hasOrthogonalProjection [K.HasOrthogonalProjection] : IsCompl K Kᗮ :=
⟨K.orthogonal_disjoint, codisjoint_iff.2 Submodule.sup_orthogonal_of_hasOrthogonalProjection⟩
@[deprecated (since := "2025-07-27")] alias isCompl_orthogonal_of_completeSpace :=
isCompl_orthogonal_of_hasOrthogonalProjection
@[simp]
theorem orthogonalComplement_eq_orthogonalComplement {L : Submodule 𝕜 E} [K.HasOrthogonalProjection]
[L.HasOrthogonalProjection] : Kᗮ = Lᗮ ↔ K = L :=
⟨fun h ↦ by simpa using congr(Submodule.orthogonal $(h)),
fun h ↦ congr(Submodule.orthogonal $(h))⟩
@[simp]
theorem orthogonal_eq_bot_iff [K.HasOrthogonalProjection] : Kᗮ = ⊥ ↔ K = ⊤ := by
refine ⟨?_, fun h => by rw [h, Submodule.top_orthogonal_eq_bot]⟩
intro h
have : K ⊔ Kᗮ = ⊤ := Submodule.sup_orthogonal_of_hasOrthogonalProjection
rwa [h, sup_comm, bot_sup_eq] at this
open Topology Finsupp RCLike Real Filter
/-- Given a monotone family `U` of complete submodules of `E` and a fixed `x : E`,
the orthogonal projection of `x` on `U i` tends to the orthogonal projection of `x` on
`(⨆ i, U i).topologicalClosure` along `atTop`. -/
theorem starProjection_tendsto_closure_iSup {ι : Type*} [Preorder ι]
(U : ι → Submodule 𝕜 E) [∀ i, (U i).HasOrthogonalProjection]
[(⨆ i, U i).topologicalClosure.HasOrthogonalProjection] (hU : Monotone U) (x : E) :
Filter.Tendsto (fun i => (U i).starProjection x) atTop
(𝓝 ((⨆ i, U i).topologicalClosure.starProjection x)) := by
refine .of_neBot_imp fun h ↦ ?_
cases atTop_neBot_iff.mp h
let y := (⨆ i, U i).topologicalClosure.starProjection x
have proj_x : ∀ i, (U i).orthogonalProjection x = (U i).orthogonalProjection y := fun i =>
(orthogonalProjection_starProjection_of_le
((le_iSup U i).trans (iSup U).le_topologicalClosure) _).symm
suffices ∀ ε > 0, ∃ I, ∀ i ≥ I, ‖(U i).starProjection y - y‖ < ε by
simpa only [starProjection_apply, proj_x, NormedAddCommGroup.tendsto_atTop] using this
intro ε hε
obtain ⟨a, ha, hay⟩ : ∃ a ∈ ⨆ i, U i, dist y a < ε := by
have y_mem : y ∈ (⨆ i, U i).topologicalClosure := Submodule.coe_mem _
rw [← SetLike.mem_coe, Submodule.topologicalClosure_coe, Metric.mem_closure_iff] at y_mem
exact y_mem ε hε
rw [dist_eq_norm] at hay
obtain ⟨I, hI⟩ : ∃ I, a ∈ U I := by rwa [Submodule.mem_iSup_of_directed _ hU.directed_le] at ha
refine ⟨I, fun i (hi : I ≤ i) => ?_⟩
rw [norm_sub_rev, starProjection_minimal]
refine lt_of_le_of_lt ?_ hay
change _ ≤ ‖y - (⟨a, hU hi hI⟩ : U i)‖
exact ciInf_le ⟨0, Set.forall_mem_range.mpr fun _ => norm_nonneg _⟩ _
@[deprecated (since := "2025-07-07")] alias orthogonalProjection_tendsto_closure_iSup :=
starProjection_tendsto_closure_iSup
/-- Given a monotone family `U` of complete submodules of `E` with dense span supremum,
and a fixed `x : E`, the orthogonal projection of `x` on `U i` tends to `x` along `at_top`. -/
theorem starProjection_tendsto_self {ι : Type*} [Preorder ι]
(U : ι → Submodule 𝕜 E) [∀ t, (U t).HasOrthogonalProjection] (hU : Monotone U) (x : E)
(hU' : ⊤ ≤ (⨆ t, U t).topologicalClosure) :
Filter.Tendsto (fun t => (U t).starProjection x) atTop (𝓝 x) := by
have : (⨆ i, U i).topologicalClosure.HasOrthogonalProjection := by
rw [top_unique hU']
infer_instance
convert starProjection_tendsto_closure_iSup U hU x
rw [eq_comm, starProjection_eq_self_iff, top_unique hU']
trivial
@[deprecated (since := "2025-07-07")] alias
orthogonalProjection_tendsto_self := starProjection_tendsto_self
/-- The orthogonal complement satisfies `Kᗮᗮᗮ = Kᗮ`. -/
theorem triorthogonal_eq_orthogonal [CompleteSpace E] : Kᗮᗮᗮ = Kᗮ := by
rw [Kᗮ.orthogonal_orthogonal_eq_closure]
exact K.isClosed_orthogonal.submodule_topologicalClosure_eq
/-- The closure of `K` is the full space iff `Kᗮ` is trivial. -/
theorem topologicalClosure_eq_top_iff [CompleteSpace E] :
K.topologicalClosure = ⊤ ↔ Kᗮ = ⊥ := by
rw [← K.orthogonal_orthogonal_eq_closure]
constructor <;> intro h
· rw [← Submodule.triorthogonal_eq_orthogonal, h, Submodule.top_orthogonal_eq_bot]
· rw [h, Submodule.bot_orthogonal_eq_top]
theorem orthogonalProjection_eq_linearProjOfIsCompl [K.HasOrthogonalProjection] (x : E) :
K.orthogonalProjection x =
K.linearProjOfIsCompl _ Submodule.isCompl_orthogonal_of_hasOrthogonalProjection x := by
have : IsCompl K Kᗮ := Submodule.isCompl_orthogonal_of_hasOrthogonalProjection
conv_lhs => rw [← IsCompl.projection_add_projection_eq_self this x]
simp_rw [IsCompl.projection_apply]
rw [map_add, orthogonalProjection_mem_subspace_eq_self,
orthogonalProjection_mem_subspace_orthogonalComplement_eq_zero (Submodule.coe_mem _), add_zero]
@[deprecated (since := "2025-07-11")] alias orthogonalProjection_eq_linear_proj :=
orthogonalProjection_eq_linearProjOfIsCompl
theorem orthogonalProjection_coe_eq_linearProjOfIsCompl [K.HasOrthogonalProjection] :
(K.orthogonalProjection : E →ₗ[𝕜] K) =
K.linearProjOfIsCompl _ Submodule.isCompl_orthogonal_of_hasOrthogonalProjection :=
LinearMap.ext <| orthogonalProjection_eq_linearProjOfIsCompl
@[deprecated (since := "2025-07-11")] alias orthogonalProjection_coe_linearMap_eq_linearProj :=
orthogonalProjection_coe_eq_linearProjOfIsCompl
open Submodule in
theorem starProjection_coe_eq_isCompl_projection [K.HasOrthogonalProjection] :
K.starProjection.toLinearMap = K.isCompl_orthogonal_of_hasOrthogonalProjection.projection := by
simp [starProjection, orthogonalProjection_coe_eq_linearProjOfIsCompl, IsCompl.projection]
end Submodule
namespace Dense
open Submodule
variable {K} {x y : E}
theorem eq_zero_of_inner_left (hK : Dense (K : Set E)) (h : ∀ v : K, ⟪x, v⟫ = 0) : x = 0 := by
have : (⟪x, ·⟫) = 0 := (continuous_const.inner continuous_id).ext_on
hK continuous_const (Subtype.forall.1 h)
simpa using congr_fun this x
theorem eq_zero_of_mem_orthogonal (hK : Dense (K : Set E)) (h : x ∈ Kᗮ) : x = 0 :=
eq_zero_of_inner_left hK fun v ↦ (mem_orthogonal' _ _).1 h _ v.2
/-- If `S` is dense and `x - y ∈ Kᗮ`, then `x = y`. -/
theorem eq_of_sub_mem_orthogonal (hK : Dense (K : Set E)) (h : x - y ∈ Kᗮ) : x = y :=
sub_eq_zero.1 <| eq_zero_of_mem_orthogonal hK h
theorem eq_of_inner_left (hK : Dense (K : Set E)) (h : ∀ v : K, ⟪x, v⟫ = ⟪y, v⟫) : x = y :=
hK.eq_of_sub_mem_orthogonal (Submodule.sub_mem_orthogonal_of_inner_left h)
theorem eq_of_inner_right (hK : Dense (K : Set E)) (h : ∀ v : K, ⟪(v : E), x⟫ = ⟪(v : E), y⟫) :
x = y :=
hK.eq_of_sub_mem_orthogonal (Submodule.sub_mem_orthogonal_of_inner_right h)
theorem eq_zero_of_inner_right (hK : Dense (K : Set E)) (h : ∀ v : K, ⟪(v : E), x⟫ = 0) : x = 0 :=
hK.eq_of_inner_right fun v => by rw [inner_zero_right, h v]
end Dense |
.lake/packages/mathlib/Mathlib/Analysis/InnerProductSpace/Projection/FiniteDimensional.lean | import Mathlib.Analysis.InnerProductSpace.Projection.Basic
import Mathlib.Analysis.InnerProductSpace.Projection.Reflection
import Mathlib.Analysis.InnerProductSpace.Projection.Submodule
import Mathlib.Algebra.DirectSum.Decomposition
import Mathlib.Analysis.Normed.Module.RCLike.Basic
/-!
# Orthogonal projections in finite-dimensional spaces
This file contains results about orthogonal projections in finite-dimensional spaces.
## Main results
* `Submodule.det_reflection`: The determinant of `K.reflection` is `(-1) ^ finrank 𝕜 Kᗮ`.
* `LinearIsometryEquiv.reflections_generate`: The orthogonal group of `F` is
generated by reflections.
## Results that do not use finite dimensionality:
* `OrthogonalFamily.isInternal_iff_of_isComplete`
* `OrthogonalFamily.sum_projection_of_mem_iSup`
* `OrthogonalFamily.projection_directSum_coeAddHom`
* `OrthogonalFamily.decomposition`
* `maximal_orthonormal_iff_orthogonalComplement_eq_bot`
-/
variable {𝕜 E F : Type*} [RCLike 𝕜]
variable [NormedAddCommGroup E] [NormedAddCommGroup F]
variable [InnerProductSpace 𝕜 E] [InnerProductSpace ℝ F]
local notation "⟪" x ", " y "⟫" => inner 𝕜 x y
local notation "absR" => @abs ℝ _ _
open Topology Finsupp Submodule RCLike Real Filter InnerProductSpace
open LinearMap (ker range)
variable (K : Submodule 𝕜 E)
namespace Submodule
section FiniteDimensional
open Module
variable [FiniteDimensional 𝕜 K]
@[simp]
theorem topologicalClosure_eq_self : K.topologicalClosure = K :=
K.closed_of_finiteDimensional.submodule_topologicalClosure_eq
@[simp]
theorem det_reflection : LinearMap.det K.reflection.toLinearMap = (-1) ^ finrank 𝕜 Kᗮ := by
by_cases hK : FiniteDimensional 𝕜 Kᗮ
swap
· rw [finrank_of_infinite_dimensional hK, pow_zero, LinearMap.det_eq_one_of_finrank_eq_zero]
exact finrank_of_infinite_dimensional fun h ↦ hK (h.finiteDimensional_submodule _)
let e := K.prodEquivOfIsCompl _ K.isCompl_orthogonal_of_hasOrthogonalProjection
let b := (finBasis 𝕜 K).prod (finBasis 𝕜 Kᗮ)
have : LinearMap.toMatrix b b (e.symm ∘ₗ K.reflection.toLinearMap ∘ₗ e.symm.symm) =
Matrix.fromBlocks 1 0 0 (-1) := by
ext (_ | _) (_ | _) <;>
simp [LinearMap.toMatrix_apply, b, Matrix.one_apply, Finsupp.single_apply, e, eq_comm,
reflection_mem_subspace_eq_self, reflection_mem_subspace_orthogonalComplement_eq_neg]
rw [← LinearMap.det_conj _ e.symm, ← LinearMap.det_toMatrix b, this, Matrix.det_fromBlocks_zero₂₁,
Matrix.det_one, one_mul, Matrix.det_neg, Fintype.card_fin, Matrix.det_one, mul_one]
@[simp]
theorem linearEquiv_det_reflection : K.reflection.det = (-1) ^ finrank 𝕜 Kᗮ := by
ext
rw [LinearEquiv.coe_det, Units.val_pow_eq_pow_val]
exact K.det_reflection
end FiniteDimensional
variable {K}
open Module
/-- Given a finite-dimensional subspace `K₂`, and a subspace `K₁`
contained in it, the dimensions of `K₁` and the intersection of its
orthogonal subspace with `K₂` add to that of `K₂`. -/
theorem finrank_add_inf_finrank_orthogonal {K₁ K₂ : Submodule 𝕜 E}
[FiniteDimensional 𝕜 K₂] (h : K₁ ≤ K₂) :
finrank 𝕜 K₁ + finrank 𝕜 (K₁ᗮ ⊓ K₂ : Submodule 𝕜 E) = finrank 𝕜 K₂ := by
haveI : FiniteDimensional 𝕜 K₁ := Submodule.finiteDimensional_of_le h
haveI := FiniteDimensional.proper_rclike 𝕜 K₁
have hd := Submodule.finrank_sup_add_finrank_inf_eq K₁ (K₁ᗮ ⊓ K₂)
rw [← inf_assoc, (Submodule.orthogonal_disjoint K₁).eq_bot, bot_inf_eq, finrank_bot,
Submodule.sup_orthogonal_inf_of_hasOrthogonalProjection h] at hd
rw [add_zero] at hd
exact hd.symm
/-- Given a finite-dimensional subspace `K₂`, and a subspace `K₁`
contained in it, the dimensions of `K₁` and the intersection of its
orthogonal subspace with `K₂` add to that of `K₂`. -/
theorem finrank_add_inf_finrank_orthogonal' {K₁ K₂ : Submodule 𝕜 E}
[FiniteDimensional 𝕜 K₂] (h : K₁ ≤ K₂) {n : ℕ} (h_dim : finrank 𝕜 K₁ + n = finrank 𝕜 K₂) :
finrank 𝕜 (K₁ᗮ ⊓ K₂ : Submodule 𝕜 E) = n := by
rw [← add_right_inj (finrank 𝕜 K₁)]
simp [Submodule.finrank_add_inf_finrank_orthogonal h, h_dim]
/-- Given a finite-dimensional space `E` and subspace `K`, the dimensions of `K` and `Kᗮ` add to
that of `E`. -/
theorem finrank_add_finrank_orthogonal [FiniteDimensional 𝕜 E] (K : Submodule 𝕜 E) :
finrank 𝕜 K + finrank 𝕜 Kᗮ = finrank 𝕜 E := by
convert Submodule.finrank_add_inf_finrank_orthogonal (le_top : K ≤ ⊤) using 1
· rw [inf_top_eq]
· simp
/-- Given a finite-dimensional space `E` and subspace `K`, the dimensions of `K` and `Kᗮ` add to
that of `E`. -/
theorem finrank_add_finrank_orthogonal' [FiniteDimensional 𝕜 E] {K : Submodule 𝕜 E}
{n : ℕ} (h_dim : finrank 𝕜 K + n = finrank 𝕜 E) : finrank 𝕜 Kᗮ = n := by
rw [← add_right_inj (finrank 𝕜 K)]
simp [Submodule.finrank_add_finrank_orthogonal, h_dim]
/-- In a finite-dimensional inner product space, the dimension of the orthogonal complement of the
span of a nonzero vector is one less than the dimension of the space. -/
theorem finrank_orthogonal_span_singleton {n : ℕ} [_i : Fact (finrank 𝕜 E = n + 1)] {v : E}
(hv : v ≠ 0) : finrank 𝕜 (𝕜 ∙ v)ᗮ = n := by
haveI : FiniteDimensional 𝕜 E := .of_fact_finrank_eq_succ n
exact finrank_add_finrank_orthogonal' <| by
simp [finrank_span_singleton hv, _i.elim, add_comm]
end Submodule
open Module Submodule
/-- An element `φ` of the orthogonal group of `F` can be factored as a product of reflections, and
specifically at most as many reflections as the dimension of the complement of the fixed subspace
of `φ`. -/
theorem LinearIsometryEquiv.reflections_generate_dim_aux [FiniteDimensional ℝ F] {n : ℕ}
(φ : F ≃ₗᵢ[ℝ] F) (hn : finrank ℝ (ker (ContinuousLinearMap.id ℝ F - φ))ᗮ ≤ n) :
∃ l : List F, l.length ≤ n ∧ φ = (l.map fun v => (ℝ ∙ v)ᗮ.reflection).prod := by
-- We prove this by strong induction on `n`, the dimension of the orthogonal complement of the
-- fixed subspace of the endomorphism `φ`
induction n generalizing φ with
| zero => -- Base case: `n = 0`, the fixed subspace is the whole space, so `φ = id`
refine ⟨[], rfl.le, show φ = 1 from ?_⟩
have : ker (ContinuousLinearMap.id ℝ F - φ) = ⊤ := by
rwa [le_zero_iff, finrank_eq_zero, orthogonal_eq_bot_iff] at hn
symm
ext x
have := LinearMap.congr_fun (LinearMap.ker_eq_top.mp this) x
simpa only [sub_eq_zero, ContinuousLinearMap.coe_sub, LinearMap.sub_apply,
LinearMap.zero_apply] using this
| succ n IH =>
-- Inductive step. Let `W` be the fixed subspace of `φ`. We suppose its complement to have
-- dimension at most n + 1.
let W := ker (ContinuousLinearMap.id ℝ F - φ)
have hW : ∀ w ∈ W, φ w = w := fun w hw => (sub_eq_zero.mp hw).symm
by_cases hn' : finrank ℝ Wᗮ ≤ n
· obtain ⟨V, hV₁, hV₂⟩ := IH φ hn'
exact ⟨V, hV₁.trans n.le_succ, hV₂⟩
-- Take a nonzero element `v` of the orthogonal complement of `W`.
haveI : Nontrivial Wᗮ := nontrivial_of_finrank_pos (by cutsat : 0 < finrank ℝ Wᗮ)
obtain ⟨v, hv⟩ := exists_ne (0 : Wᗮ)
have hφv : φ v ∈ Wᗮ := by
intro w hw
rw [← hW w hw, LinearIsometryEquiv.inner_map_map]
exact v.prop w hw
have hv' : (v : F) ∉ W := by
intro h
exact hv ((mem_left_iff_eq_zero_of_disjoint W.orthogonal_disjoint).mp h)
-- Let `ρ` be the reflection in `v - φ v`; this is designed to swap `v` and `φ v`
let x : F := v - φ v
let ρ := (ℝ ∙ x)ᗮ.reflection
-- Notation: Let `V` be the fixed subspace of `φ.trans ρ`
let V := ker (ContinuousLinearMap.id ℝ F - φ.trans ρ)
have hV : ∀ w, ρ (φ w) = w → w ∈ V := by
intro w hw
change w - ρ (φ w) = 0
rw [sub_eq_zero, hw]
-- Everything fixed by `φ` is fixed by `φ.trans ρ`
have H₂V : W ≤ V := by
intro w hw
apply hV
rw [hW w hw]
refine reflection_mem_subspace_eq_self ?_
rw [mem_orthogonal_singleton_iff_inner_left]
exact Submodule.sub_mem _ v.prop hφv _ hw
-- `v` is also fixed by `φ.trans ρ`
have H₁V : (v : F) ∈ V := by
apply hV
have : ρ v = φ v := reflection_sub (φ.norm_map v).symm
rw [← this]
exact reflection_reflection _ _
-- By dimension-counting, the complement of the fixed subspace of `φ.trans ρ` has dimension at
-- most `n`
have : finrank ℝ Vᗮ ≤ n := by
change finrank ℝ Wᗮ ≤ n + 1 at hn
have : finrank ℝ W + 1 ≤ finrank ℝ V :=
finrank_lt_finrank_of_lt (SetLike.lt_iff_le_and_exists.2 ⟨H₂V, v, H₁V, hv'⟩)
have : finrank ℝ V + finrank ℝ Vᗮ = finrank ℝ F := V.finrank_add_finrank_orthogonal
have : finrank ℝ W + finrank ℝ Wᗮ = finrank ℝ F := W.finrank_add_finrank_orthogonal
omega
-- So apply the inductive hypothesis to `φ.trans ρ`
obtain ⟨l, hl, hφl⟩ := IH (ρ * φ) this
-- Prepend `ρ` to the factorization into reflections obtained for `φ.trans ρ`; this gives a
-- factorization into reflections for `φ`.
refine ⟨x::l, Nat.succ_le_succ hl, ?_⟩
rw [List.map_cons, List.prod_cons]
have := congr_arg (ρ * ·) hφl
dsimp only at this
rwa [← mul_assoc, reflection_mul_reflection, one_mul] at this
/-- The orthogonal group of `F` is generated by reflections; specifically each element `φ` of the
orthogonal group is a product of at most as many reflections as the dimension of `F`.
Special case of the **Cartan–Dieudonné theorem**. -/
theorem LinearIsometryEquiv.reflections_generate_dim [FiniteDimensional ℝ F] (φ : F ≃ₗᵢ[ℝ] F) :
∃ l : List F, l.length ≤ finrank ℝ F ∧ φ = (l.map fun v => reflection (ℝ ∙ v)ᗮ).prod :=
let ⟨l, hl₁, hl₂⟩ := φ.reflections_generate_dim_aux le_rfl
⟨l, hl₁.trans (finrank_le _), hl₂⟩
/-- The orthogonal group of `F` is generated by reflections. -/
theorem LinearIsometryEquiv.reflections_generate [FiniteDimensional ℝ F] :
Subgroup.closure (Set.range fun v : F => reflection (ℝ ∙ v)ᗮ) = ⊤ := by
rw [Subgroup.eq_top_iff']
intro φ
rcases φ.reflections_generate_dim with ⟨l, _, rfl⟩
apply (Subgroup.closure _).list_prod_mem
intro x hx
rcases List.mem_map.mp hx with ⟨a, _, hax⟩
exact Subgroup.subset_closure ⟨a, hax⟩
section OrthogonalFamily
open Submodule
variable {ι : Type*}
/-- An orthogonal family of subspaces of `E` satisfies `DirectSum.IsInternal` (that is,
they provide an internal direct sum decomposition of `E`) if and only if their span has trivial
orthogonal complement. -/
theorem OrthogonalFamily.isInternal_iff_of_isComplete [DecidableEq ι] {V : ι → Submodule 𝕜 E}
(hV : OrthogonalFamily 𝕜 (fun i => V i) fun i => (V i).subtypeₗᵢ)
(hc : IsComplete (↑(iSup V) : Set E)) : DirectSum.IsInternal V ↔ (iSup V)ᗮ = ⊥ := by
haveI : CompleteSpace (↥(iSup V)) := hc.completeSpace_coe
simp only [DirectSum.isInternal_submodule_iff_iSupIndep_and_iSup_eq_top, hV.independent,
true_and, orthogonal_eq_bot_iff]
/-- An orthogonal family of subspaces of `E` satisfies `DirectSum.IsInternal` (that is,
they provide an internal direct sum decomposition of `E`) if and only if their span has trivial
orthogonal complement. -/
theorem OrthogonalFamily.isInternal_iff [DecidableEq ι] [FiniteDimensional 𝕜 E]
{V : ι → Submodule 𝕜 E} (hV : OrthogonalFamily 𝕜 (fun i => V i) fun i => (V i).subtypeₗᵢ) :
DirectSum.IsInternal V ↔ (iSup V)ᗮ = ⊥ :=
haveI := FiniteDimensional.proper_rclike 𝕜 (↥(iSup V))
hV.isInternal_iff_of_isComplete (completeSpace_coe_iff_isComplete.mp inferInstance)
open DirectSum
/-- If `x` lies within an orthogonal family `v`, it can be expressed as a sum of projections. -/
theorem OrthogonalFamily.sum_projection_of_mem_iSup [Fintype ι] {V : ι → Submodule 𝕜 E}
[∀ i, CompleteSpace (V i)] (hV : OrthogonalFamily 𝕜 (fun i => V i) fun i => (V i).subtypeₗᵢ)
(x : E) (hx : x ∈ iSup V) : (∑ i, (V i).starProjection x) = x := by
induction hx using iSup_induction' with
| mem i x hx =>
refine
(Finset.sum_eq_single_of_mem i (Finset.mem_univ _) fun j _ hij => ?_).trans
(starProjection_eq_self_iff.mpr hx)
rw [starProjection_apply, orthogonalProjection_mem_subspace_orthogonalComplement_eq_zero,
Submodule.coe_zero]
exact hV.isOrtho hij.symm hx
| zero =>
simp_rw [map_zero, Finset.sum_const_zero]
| add x y _ _ hx hy =>
simp_rw [map_add, Finset.sum_add_distrib]
exact congr_arg₂ (· + ·) hx hy
/-- If a family of submodules is orthogonal, then the `orthogonalProjection` on a direct sum
is just the coefficient of that direct sum. -/
theorem OrthogonalFamily.projection_directSum_coeAddHom [DecidableEq ι] {V : ι → Submodule 𝕜 E}
(hV : OrthogonalFamily 𝕜 (fun i => V i) fun i => (V i).subtypeₗᵢ) (x : ⨁ i, V i) (i : ι)
[CompleteSpace (V i)] :
(V i).orthogonalProjection (DirectSum.coeAddMonoidHom V x) = x i := by
induction x using DirectSum.induction_on with
| zero => simp
| of j x =>
simp_rw [DirectSum.coeAddMonoidHom_of, DirectSum.of,
-- Need to unfold `DirectSum` to see through the defeq abuse.
DirectSum, DFinsupp.singleAddHom_apply]
obtain rfl | hij := Decidable.eq_or_ne i j
· rw [orthogonalProjection_mem_subspace_eq_self, DFinsupp.single_eq_same]
· rw [orthogonalProjection_mem_subspace_orthogonalComplement_eq_zero,
DFinsupp.single_eq_of_ne hij]
exact hV.isOrtho hij.symm x.prop
| add x y hx hy =>
simp_rw [map_add]
exact congr_arg₂ (· + ·) hx hy
/-- If a family of submodules is orthogonal and they span the whole space, then the orthogonal
projection provides a means to decompose the space into its submodules.
The projection function is `decompose V x i = (V i).orthogonalProjection x`.
See note [reducible non-instances]. -/
noncomputable abbrev OrthogonalFamily.decomposition
[DecidableEq ι] [Fintype ι] {V : ι → Submodule 𝕜 E}
[∀ i, CompleteSpace (V i)] (hV : OrthogonalFamily 𝕜 (fun i => V i) fun i => (V i).subtypeₗᵢ)
(h : iSup V = ⊤) : DirectSum.Decomposition V where
decompose' x := DFinsupp.equivFunOnFintype.symm fun i => (V i).orthogonalProjection x
left_inv x := by
dsimp only
letI := fun i => Classical.decEq (V i)
rw [DirectSum.coeAddMonoidHom, DirectSum.toAddMonoid, DFinsupp.liftAddHom_apply]
-- This used to be `rw`, but we need `erw` after https://github.com/leanprover/lean4/pull/2644
erw [DFinsupp.sumAddHom_apply]; rw [DFinsupp.sum_eq_sum_fintype]
· simp_rw [Equiv.apply_symm_apply, AddSubmonoidClass.coe_subtype]
exact hV.sum_projection_of_mem_iSup _ ((h.ge :) Submodule.mem_top)
· intro i
exact map_zero _
right_inv x := by
dsimp only
simp_rw [hV.projection_directSum_coeAddHom, DFinsupp.equivFunOnFintype_symm_coe]
end OrthogonalFamily
section OrthonormalBasis
variable {v : Set E}
open Module Submodule Set
/-- An orthonormal set in an `InnerProductSpace` is maximal, if and only if the orthogonal
complement of its span is empty. -/
theorem maximal_orthonormal_iff_orthogonalComplement_eq_bot (hv : Orthonormal 𝕜 ((↑) : v → E)) :
(∀ u ⊇ v, Orthonormal 𝕜 ((↑) : u → E) → u = v) ↔ (span 𝕜 v)ᗮ = ⊥ := by
rw [Submodule.eq_bot_iff]
constructor
· contrapose!
-- ** direction 1: nonempty orthogonal complement implies nonmaximal
rintro ⟨x, hx', hx⟩
-- take a nonzero vector and normalize it
let e := (‖x‖⁻¹ : 𝕜) • x
have he : ‖e‖ = 1 := by simp [e, norm_smul_inv_norm hx]
have he' : e ∈ (span 𝕜 v)ᗮ := smul_mem' _ _ hx'
have he'' : e ∉ v := by
intro hev
have : e = 0 := by
have : e ∈ span 𝕜 v ⊓ (span 𝕜 v)ᗮ := ⟨subset_span hev, he'⟩
simpa [(span 𝕜 v).inf_orthogonal_eq_bot] using this
have : e ≠ 0 := hv.ne_zero ⟨e, hev⟩
contradiction
-- put this together with `v` to provide a candidate orthonormal basis for the whole space
refine ⟨insert e v, v.subset_insert e, ⟨?_, ?_⟩, (ne_insert_of_notMem v he'').symm⟩
· -- show that the elements of `insert e v` have unit length
rintro ⟨a, ha'⟩
rcases eq_or_mem_of_mem_insert ha' with ha | ha
· simp [ha, he]
· exact hv.1 ⟨a, ha⟩
· -- show that the elements of `insert e v` are orthogonal
have h_end : ∀ a ∈ v, ⟪a, e⟫ = 0 := by
intro a ha
exact he' a (Submodule.subset_span ha)
rintro ⟨a, ha'⟩
rcases eq_or_mem_of_mem_insert ha' with ha | ha
· rintro ⟨b, hb'⟩ hab'
have hb : b ∈ v := by grind
rw [inner_eq_zero_symm]
simpa [ha] using h_end b hb
rintro ⟨b, hb'⟩ hab'
rcases eq_or_mem_of_mem_insert hb' with hb | hb
· simpa [hb] using h_end a ha
have : (⟨a, ha⟩ : v) ≠ ⟨b, hb⟩ := by
intro hab''
apply hab'
simpa using hab''
exact hv.2 this
· -- ** direction 2: empty orthogonal complement implies maximal
simp only [Subset.antisymm_iff]
rintro h u (huv : v ⊆ u) hu
refine ⟨?_, huv⟩
intro x hxu
refine ((mt (h x)) (hu.ne_zero ⟨x, hxu⟩)).imp_symm ?_
intro hxv y hy
have hxv' : (⟨x, hxu⟩ : u) ∉ ((↑) ⁻¹' v : Set u) := by simp [hxv]
obtain ⟨l, hl, rfl⟩ :
∃ l ∈ supported 𝕜 𝕜 ((↑) ⁻¹' v : Set u), (linearCombination 𝕜 ((↑) : u → E)) l = y := by
rw [← Finsupp.mem_span_image_iff_linearCombination]
simp [huv, inter_eq_self_of_subset_right, hy]
exact hu.inner_finsupp_eq_zero hxv' hl
variable [FiniteDimensional 𝕜 E]
/-- An orthonormal set in a finite-dimensional `InnerProductSpace` is maximal, if and only if it
is a basis. -/
theorem maximal_orthonormal_iff_basis_of_finiteDimensional (hv : Orthonormal 𝕜 ((↑) : v → E)) :
(∀ u ⊇ v, Orthonormal 𝕜 ((↑) : u → E) → u = v) ↔ ∃ b : Basis v 𝕜 E, ⇑b = ((↑) : v → E) := by
haveI := FiniteDimensional.proper_rclike 𝕜 (span 𝕜 v)
rw [maximal_orthonormal_iff_orthogonalComplement_eq_bot hv]
rw [Submodule.orthogonal_eq_bot_iff]
have hv_coe : range ((↑) : v → E) = v := by simp
constructor
· refine fun h => ⟨Basis.mk hv.linearIndependent _, Basis.coe_mk _ ?_⟩
convert h.ge
· rintro ⟨h, coe_h⟩
rw [← h.span_eq, coe_h, hv_coe]
end OrthonormalBasis |
.lake/packages/mathlib/Mathlib/Analysis/CStarAlgebra/ContinuousLinearMap.lean | import Mathlib.Analysis.CStarAlgebra.Classes
import Mathlib.Analysis.InnerProductSpace.Adjoint
/-! # `E →L[ℂ] E` as a C⋆-algebra
We place this here because, for reasons related to the import hierarchy, it should not be placed
in earlier files.
-/
noncomputable
instance {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℂ E] [CompleteSpace E] :
CStarAlgebra (E →L[ℂ] E) where |
.lake/packages/mathlib/Mathlib/Analysis/CStarAlgebra/Matrix.lean | import Mathlib.Analysis.InnerProductSpace.Adjoint
import Mathlib.Analysis.Matrix.Normed
import Mathlib.Analysis.RCLike.Basic
import Mathlib.LinearAlgebra.UnitaryGroup
import Mathlib.Topology.UniformSpace.Matrix
/-!
# Analytic properties of the `star` operation on matrices
This transports the operator norm on `EuclideanSpace 𝕜 n →L[𝕜] EuclideanSpace 𝕜 m` to
`Matrix m n 𝕜`. See the file `Analysis.Matrix` for many other matrix norms.
## Main definitions
* `Matrix.instNormedRingL2Op`: the (necessarily unique) normed ring structure on `Matrix n n 𝕜`
which ensure it is a `CStarRing` in `Matrix.instCStarRing`. This is a scoped instance in the
namespace `Matrix.Norms.L2Operator` in order to avoid choosing a global norm for `Matrix`.
## Main statements
* `entry_norm_bound_of_unitary`: the entries of a unitary matrix are uniformly bound by `1`.
## Implementation details
We take care to ensure the topology and uniformity induced by `Matrix.instMetricSpaceL2Op`
coincide with the existing topology and uniformity on matrices.
## TODO
* Show that `‖diagonal (v : n → 𝕜)‖ = ‖v‖`.
-/
open WithLp
open scoped Matrix
variable {𝕜 m n l E : Type*}
section EntrywiseSupNorm
variable [RCLike 𝕜] [Fintype n] [DecidableEq n]
theorem entry_norm_bound_of_unitary {U : Matrix n n 𝕜} (hU : U ∈ Matrix.unitaryGroup n 𝕜)
(i j : n) : ‖U i j‖ ≤ 1 := by
-- The norm squared of an entry is at most the L2 norm of its row.
have norm_sum : ‖U i j‖ ^ 2 ≤ ∑ x, ‖U i x‖ ^ 2 := by
apply Multiset.single_le_sum
· intro x h_x
rw [Multiset.mem_map] at h_x
obtain ⟨a, h_a⟩ := h_x
rw [← h_a.2]
apply sq_nonneg
· rw [Multiset.mem_map]
use j
simp only [Finset.mem_univ_val, and_self_iff]
-- The L2 norm of a row is a diagonal entry of U * Uᴴ
have diag_eq_norm_sum : (U * Uᴴ) i i = (∑ x : n, ‖U i x‖ ^ 2 : ℝ) := by
simp only [Matrix.mul_apply, Matrix.conjTranspose_apply, ← starRingEnd_apply, RCLike.mul_conj]
norm_cast
-- The L2 norm of a row is a diagonal entry of U * Uᴴ, real part
have re_diag_eq_norm_sum : RCLike.re ((U * Uᴴ) i i) = ∑ x : n, ‖U i x‖ ^ 2 := by
rw [RCLike.ext_iff] at diag_eq_norm_sum
rw [diag_eq_norm_sum.1]
norm_cast
-- Since U is unitary, the diagonal entries of U * Uᴴ are all 1
have mul_eq_one : U * Uᴴ = 1 := Unitary.mul_star_self_of_mem hU
have diag_eq_one : RCLike.re ((U * Uᴴ) i i) = 1 := by
simp only [mul_eq_one, Matrix.one_apply_eq, RCLike.one_re]
-- Putting it all together
rw [← sq_le_one_iff₀ (norm_nonneg (U i j)), ← diag_eq_one, re_diag_eq_norm_sum]
exact norm_sum
open scoped Matrix.Norms.Elementwise in
/-- The entrywise sup norm of a unitary matrix is at most 1. -/
theorem entrywise_sup_norm_bound_of_unitary {U : Matrix n n 𝕜} (hU : U ∈ Matrix.unitaryGroup n 𝕜) :
‖U‖ ≤ 1 := by
simp_rw [pi_norm_le_iff_of_nonneg zero_le_one]
intros
exact entry_norm_bound_of_unitary hU _ _
end EntrywiseSupNorm
noncomputable section L2OpNorm
namespace Matrix
open LinearMap
variable [RCLike 𝕜]
variable [Fintype m] [Fintype n] [DecidableEq n] [Fintype l] [DecidableEq l]
/-- The natural star algebra equivalence between matrices and continuous linear endomorphisms
of Euclidean space induced by the orthonormal basis `EuclideanSpace.basisFun`.
This is a more-bundled version of `Matrix.toEuclideanLin`, for the special case of square matrices,
followed by a more-bundled version of `LinearMap.toContinuousLinearMap`. -/
def toEuclideanCLM :
Matrix n n 𝕜 ≃⋆ₐ[𝕜] (EuclideanSpace 𝕜 n →L[𝕜] EuclideanSpace 𝕜 n) :=
toMatrixOrthonormal (EuclideanSpace.basisFun n 𝕜) |>.symm.trans <|
{ toContinuousLinearMap with
map_mul' := fun _ _ ↦ rfl
map_star' := adjoint_toContinuousLinearMap }
lemma coe_toEuclideanCLM_eq_toEuclideanLin (A : Matrix n n 𝕜) :
(toEuclideanCLM (n := n) (𝕜 := 𝕜) A : _ →ₗ[𝕜] _) = toEuclideanLin A :=
rfl
@[simp]
lemma toEuclideanCLM_toLp (A : Matrix n n 𝕜) (x : n → 𝕜) :
toEuclideanCLM (n := n) (𝕜 := 𝕜) A (toLp _ x) = toLp _ (A *ᵥ x) := rfl
@[deprecated toEuclideanCLM_toLp (since := "2025-05-07")]
lemma toEuclideanCLM_piLp_equiv_symm (A : Matrix n n 𝕜) (x : n → 𝕜) :
toEuclideanCLM (n := n) (𝕜 := 𝕜) A ((WithLp.equiv _ _).symm x) =
(WithLp.equiv _ _).symm (A *ᵥ x) := rfl
@[simp]
lemma ofLp_toEuclideanCLM (A : Matrix n n 𝕜) (x : EuclideanSpace 𝕜 n) :
ofLp (toEuclideanCLM (n := n) (𝕜 := 𝕜) A x) = A *ᵥ ofLp x := rfl
@[deprecated ofLp_toEuclideanCLM (since := "2025-05-07")]
lemma piLp_equiv_toEuclideanCLM (A : Matrix n n 𝕜) (x : EuclideanSpace 𝕜 n) :
WithLp.equiv _ _ (toEuclideanCLM (n := n) (𝕜 := 𝕜) A x) = A *ᵥ (WithLp.equiv _ _ x) :=
rfl
/-- An auxiliary definition used only to construct the true `NormedAddCommGroup` (and `Metric`)
structure provided by `Matrix.instMetricSpaceL2Op` and `Matrix.instNormedAddCommGroupL2Op`. -/
def l2OpNormedAddCommGroupAux : NormedAddCommGroup (Matrix m n 𝕜) :=
@NormedAddCommGroup.induced ((Matrix m n 𝕜) ≃ₗ[𝕜] (EuclideanSpace 𝕜 n →L[𝕜] EuclideanSpace 𝕜 m)) _
_ _ _ ContinuousLinearMap.toNormedAddCommGroup.toNormedAddGroup _ _ <|
(toEuclideanLin.trans toContinuousLinearMap).injective
/-- An auxiliary definition used only to construct the true `NormedRing` (and `Metric`) structure
provided by `Matrix.instMetricSpaceL2Op` and `Matrix.instNormedRingL2Op`. -/
def l2OpNormedRingAux : NormedRing (Matrix n n 𝕜) :=
@NormedRing.induced ((Matrix n n 𝕜) ≃⋆ₐ[𝕜] (EuclideanSpace 𝕜 n →L[𝕜] EuclideanSpace 𝕜 n)) _
_ _ _ ContinuousLinearMap.toNormedRing _ _ toEuclideanCLM.injective
open Bornology Filter
open scoped Topology Uniformity
/-- The metric on `Matrix m n 𝕜` arising from the operator norm given by the identification with
(continuous) linear maps of `EuclideanSpace`. -/
def instL2OpMetricSpace : MetricSpace (Matrix m n 𝕜) := by
/- We first replace the topology so that we can automatically replace the uniformity using
`IsUniformAddGroup.toUniformSpace_eq`. -/
letI normed_add_comm_group : NormedAddCommGroup (Matrix m n 𝕜) :=
{ l2OpNormedAddCommGroupAux.replaceTopology <|
(toEuclideanLin (𝕜 := 𝕜) (m := m) (n := n)).trans toContinuousLinearMap
|>.toContinuousLinearEquiv.toHomeomorph.isInducing.eq_induced with
norm := l2OpNormedAddCommGroupAux.norm
dist_eq := l2OpNormedAddCommGroupAux.dist_eq }
exact normed_add_comm_group.replaceUniformity <| by
congr
rw [← @IsUniformAddGroup.rightUniformSpace_eq _ (Matrix.instUniformSpace m n 𝕜) _ _]
rw [@IsUniformAddGroup.rightUniformSpace_eq _ PseudoEMetricSpace.toUniformSpace _ _]
scoped[Matrix.Norms.L2Operator] attribute [instance] Matrix.instL2OpMetricSpace
open scoped Matrix.Norms.L2Operator
/-- The norm structure on `Matrix m n 𝕜` arising from the operator norm given by the identification
with (continuous) linear maps of `EuclideanSpace`. -/
def instL2OpNormedAddCommGroup : NormedAddCommGroup (Matrix m n 𝕜) where
norm := l2OpNormedAddCommGroupAux.norm
dist_eq := l2OpNormedAddCommGroupAux.dist_eq
scoped[Matrix.Norms.L2Operator] attribute [instance] Matrix.instL2OpNormedAddCommGroup
lemma l2_opNorm_def (A : Matrix m n 𝕜) :
‖A‖ = ‖(toEuclideanLin (𝕜 := 𝕜) (m := m) (n := n)).trans toContinuousLinearMap A‖ := rfl
lemma l2_opNNNorm_def (A : Matrix m n 𝕜) :
‖A‖₊ = ‖(toEuclideanLin (𝕜 := 𝕜) (m := m) (n := n)).trans toContinuousLinearMap A‖₊ := rfl
lemma l2_opNorm_conjTranspose [DecidableEq m] (A : Matrix m n 𝕜) : ‖Aᴴ‖ = ‖A‖ := by
rw [l2_opNorm_def, toEuclideanLin_eq_toLin_orthonormal, LinearEquiv.trans_apply,
toLin_conjTranspose, adjoint_toContinuousLinearMap]
exact ContinuousLinearMap.adjoint.norm_map _
lemma l2_opNNNorm_conjTranspose [DecidableEq m] (A : Matrix m n 𝕜) : ‖Aᴴ‖₊ = ‖A‖₊ :=
Subtype.ext <| l2_opNorm_conjTranspose _
lemma l2_opNorm_conjTranspose_mul_self (A : Matrix m n 𝕜) : ‖Aᴴ * A‖ = ‖A‖ * ‖A‖ := by
classical
rw [l2_opNorm_def, toEuclideanLin_eq_toLin_orthonormal, LinearEquiv.trans_apply,
Matrix.toLin_mul (v₂ := (EuclideanSpace.basisFun m 𝕜).toBasis), toLin_conjTranspose]
exact ContinuousLinearMap.norm_adjoint_comp_self _
lemma l2_opNNNorm_conjTranspose_mul_self (A : Matrix m n 𝕜) : ‖Aᴴ * A‖₊ = ‖A‖₊ * ‖A‖₊ :=
Subtype.ext <| l2_opNorm_conjTranspose_mul_self _
-- note: with only a type ascription in the left-hand side, Lean picks the wrong norm.
lemma l2_opNorm_mulVec (A : Matrix m n 𝕜) (x : EuclideanSpace 𝕜 n) :
‖(EuclideanSpace.equiv m 𝕜).symm <| A *ᵥ x‖ ≤ ‖A‖ * ‖x‖ :=
toEuclideanLin (n := n) (m := m) (𝕜 := 𝕜) |>.trans toContinuousLinearMap A |>.le_opNorm x
lemma l2_opNNNorm_mulVec (A : Matrix m n 𝕜) (x : EuclideanSpace 𝕜 n) :
‖(EuclideanSpace.equiv m 𝕜).symm <| A *ᵥ x‖₊ ≤ ‖A‖₊ * ‖x‖₊ :=
A.l2_opNorm_mulVec x
lemma l2_opNorm_mul (A : Matrix m n 𝕜) (B : Matrix n l 𝕜) :
‖A * B‖ ≤ ‖A‖ * ‖B‖ := by
simp only [l2_opNorm_def]
have := (toEuclideanLin (n := n) (m := m) (𝕜 := 𝕜) ≪≫ₗ toContinuousLinearMap) A
|>.opNorm_comp_le <| (toEuclideanLin (n := l) (m := n) (𝕜 := 𝕜) ≪≫ₗ toContinuousLinearMap) B
convert this
ext1 x
exact congr(toLp 2 ($(Matrix.toLin'_mul A B) x))
lemma l2_opNNNorm_mul (A : Matrix m n 𝕜) (B : Matrix n l 𝕜) : ‖A * B‖₊ ≤ ‖A‖₊ * ‖B‖₊ :=
l2_opNorm_mul A B
/-- The normed algebra structure on `Matrix n n 𝕜` arising from the operator norm given by the
identification with (continuous) linear endmorphisms of `EuclideanSpace 𝕜 n`. -/
def instL2OpNormedSpace : NormedSpace 𝕜 (Matrix m n 𝕜) where
norm_smul_le r x := by
rw [l2_opNorm_def, LinearEquiv.map_smul]
exact norm_smul_le r ((toEuclideanLin (𝕜 := 𝕜) (m := m) (n := n)).trans toContinuousLinearMap x)
scoped[Matrix.Norms.L2Operator] attribute [instance] Matrix.instL2OpNormedSpace
/-- The normed ring structure on `Matrix n n 𝕜` arising from the operator norm given by the
identification with (continuous) linear endmorphisms of `EuclideanSpace 𝕜 n`. -/
def instL2OpNormedRing : NormedRing (Matrix n n 𝕜) where
dist_eq := l2OpNormedRingAux.dist_eq
norm_mul_le := l2OpNormedRingAux.norm_mul_le
scoped[Matrix.Norms.L2Operator] attribute [instance] Matrix.instL2OpNormedRing
/-- This is the same as `Matrix.l2_opNorm_def`, but with a more bundled RHS for square matrices. -/
lemma cstar_norm_def (A : Matrix n n 𝕜) : ‖A‖ = ‖toEuclideanCLM (n := n) (𝕜 := 𝕜) A‖ := rfl
/-- This is the same as `Matrix.l2_opNNNorm_def`, but with a more bundled RHS for square
matrices. -/
lemma cstar_nnnorm_def (A : Matrix n n 𝕜) : ‖A‖₊ = ‖toEuclideanCLM (n := n) (𝕜 := 𝕜) A‖₊ := rfl
/-- The normed algebra structure on `Matrix n n 𝕜` arising from the operator norm given by the
identification with (continuous) linear endmorphisms of `EuclideanSpace 𝕜 n`. -/
def instL2OpNormedAlgebra : NormedAlgebra 𝕜 (Matrix n n 𝕜) where
norm_smul_le := norm_smul_le
scoped[Matrix.Norms.L2Operator] attribute [instance] Matrix.instL2OpNormedAlgebra
/-- The operator norm on `Matrix n n 𝕜` given by the identification with (continuous) linear
endmorphisms of `EuclideanSpace 𝕜 n` makes it into a `L2OpRing`. -/
lemma instCStarRing : CStarRing (Matrix n n 𝕜) where
norm_mul_self_le M := le_of_eq <| Eq.symm <| l2_opNorm_conjTranspose_mul_self M
scoped[Matrix.Norms.L2Operator] attribute [instance] Matrix.instCStarRing
end Matrix
end L2OpNorm |
.lake/packages/mathlib/Mathlib/Analysis/CStarAlgebra/PositiveLinearMap.lean | import Mathlib.Algebra.Order.Module.PositiveLinearMap
import Mathlib.Analysis.CStarAlgebra.Classes
import Mathlib.Analysis.CStarAlgebra.ContinuousFunctionalCalculus.Order
import Mathlib.Analysis.CStarAlgebra.SpecialFunctions.PosPart
/-! # Positive linear maps in C⋆-algebras
This file develops the API for positive linear maps over C⋆-algebras.
## Main results
* `PositiveLinearMap.exists_norm_apply_le`: positive maps are bounded (and therefore continuous)
on non-unital C⋆-algebras.
## References
* The proof that positive maps are bounded was taken from
https://math.stackexchange.com/questions/426487/why-is-every-positive-linear-map-between-c-algebras-bounded
-/
open scoped NNReal
variable {A₁ A₂ B₁ B₂ : Type*}
section CFC
variable [NonUnitalRing A₁] [Module ℂ A₁] [SMulCommClass ℝ A₁ A₁] [IsScalarTower ℝ A₁ A₁]
[StarRing A₁] [TopologicalSpace A₁] [NonUnitalContinuousFunctionalCalculus ℝ A₁ IsSelfAdjoint]
[PartialOrder A₁] [StarOrderedRing A₁]
variable [NonUnitalRing A₂] [Module ℂ A₂] [StarRing A₂] [PartialOrder A₂] [StarOrderedRing A₂]
@[aesop safe apply (rule_sets := [CStarAlgebra])]
lemma map_isSelfAdjoint (f : A₁ →ₚ[ℂ] A₂) (a : A₁) (ha : IsSelfAdjoint a) :
IsSelfAdjoint (f a) := by
rw [← CFC.posPart_sub_negPart a ha]
cfc_tac
end CFC
section CStarAlgebra
namespace PositiveLinearMap
variable [NonUnitalCStarAlgebra A₁] [NonUnitalCStarAlgebra A₂] [PartialOrder A₁]
[StarOrderedRing A₁] [PartialOrder A₂] [StarOrderedRing A₂]
[CStarAlgebra B₁] [CStarAlgebra B₂] [PartialOrder B₁] [PartialOrder B₂]
[StarOrderedRing B₁]
lemma apply_le_of_isSelfAdjoint (f : B₁ →ₚ[ℂ] B₂) (x : B₁) (hx : IsSelfAdjoint x) :
f x ≤ f (algebraMap ℝ B₁ ‖x‖) := by
gcongr
exact IsSelfAdjoint.le_algebraMap_norm_self hx
lemma norm_apply_le_of_nonneg [StarOrderedRing B₂] (f : B₁ →ₚ[ℂ] B₂) (x : B₁) (hx : 0 ≤ x) :
‖f x‖ ≤ ‖f 1‖ * ‖x‖ := by
have h : ‖‖x‖‖ = ‖x‖ := by simp
rw [mul_comm, ← h, ← norm_smul ‖x‖ (f 1)]
clear h
refine CStarAlgebra.norm_le_norm_of_nonneg_of_le (f.map_nonneg hx) ?_
rw [← Complex.coe_smul, ← LinearMapClass.map_smul f]
gcongr
rw [← Algebra.algebraMap_eq_smul_one]
exact IsSelfAdjoint.le_algebraMap_norm_self <| .of_nonneg hx
open Complex Filter in
/--
If `f` is a positive map, then it is bounded (and therefore continuous).
-/
lemma exists_norm_apply_le (f : A₁ →ₚ[ℂ] A₂) : ∃ C : ℝ≥0, ∀ a, ‖f a‖ ≤ C * ‖a‖ := by
/- It suffices to only consider for positive `a`, by decomposing `a` into positive and negative
parts of the real and imaginary parts. -/
suffices h_nonneg : ∃ C : ℝ≥0, ∀ a, 0 ≤ a → ‖f a‖ ≤ C * ‖a‖ by
obtain ⟨C, hmain⟩ := h_nonneg
refine ⟨4 * C, fun x ↦ ?_⟩
obtain ⟨y, hy_nonneg, hy_norm, hy⟩ := CStarAlgebra.exists_sum_four_nonneg x
conv_lhs => rw [hy]
simp only [map_sum, map_smul]
apply norm_sum_le _ _ |>.trans
simp only [norm_smul, norm_pow, norm_I, one_pow, one_mul]
apply Finset.sum_le_sum (g := fun _ ↦ C * ‖x‖) (fun i _ ↦ ?_) |>.trans <| by simp [mul_assoc]
apply hmain _ (hy_nonneg i) |>.trans
simp only
gcongr
exact hy_norm i
-- Let's proceed by contradiction
by_contra! hcontra
-- Given `n : ℕ`, we can always choose a positive element of norm one with `2 ^ (2 * n) < ‖f x‖`
have (n : ℕ) : ∃ x, 0 ≤ x ∧ ‖x‖ = 1 ∧ 2 ^ (2 * n) < ‖f x‖ := by
obtain ⟨hx₁, hx₂⟩ := Classical.choose_spec (hcontra (2 ^ (2 * n)))
set x := Classical.choose (hcontra (2 ^ (2 * n)))
have hx := (eq_zero_or_norm_pos x).resolve_left (fun hx ↦ by simp_all)
refine ⟨‖x‖⁻¹ • x, smul_nonneg (by positivity) hx₁, ?_, ?_⟩
· simp [norm_smul, inv_mul_cancel₀ hx.ne']
· simpa [norm_smul] using (lt_inv_mul_iff₀' hx).mpr hx₂
-- Let `x n` be a sequence of nonnegative elements such that `‖x n‖ = 1` and `‖f (x n)‖ ≥ 4 ^ n`.
choose x hx using this
simp only [forall_and] at hx
obtain ⟨hx_nonneg, hx_norm, hx⟩ := hx
-- `∑ n, 2 ^ (-n) • x n` converges
have x_summable : Summable fun n : ℕ => (2 : ℝ) ^ (-(n : ℤ)) • x n := by
refine Summable.of_norm ?_
have : (2 : ℝ)⁻¹ < 1 := by norm_num
simp [norm_smul, hx_norm, ← inv_pow, this]
-- There is some `n` such that `‖f (∑' m, 2 ^ (-m) • x m)‖ < 2 ^ n`
obtain ⟨n, hn⟩ : ∃ n : ℕ, ‖f (∑' (n : ℕ), (2 : ℝ) ^ (-(n : ℤ)) • x n)‖ < (2 : ℝ) ^ n :=
tendsto_pow_atTop_atTop_of_one_lt one_lt_two |>.eventually_gt_atTop _
|>.exists
-- But `2 ^ n ≤ ‖f (2 ^ (-n) • x n)‖ ≤ ‖f (∑' m, 2 ^ (-m) • x m)‖`, which is a contradiction.
apply hn.not_ge
trans ‖f ((2 : ℝ) ^ (-n : ℤ) • x n)‖
· have := hx n |>.le
rw [pow_mul', sq] at this
simpa [norm_smul] using (le_inv_mul_iff₀' (show 0 < (2 : ℝ) ^ n by positivity)).mpr this
· have (m : ℕ) : 0 ≤ ((2 : ℝ) ^ (-(m : ℤ)) • x m) := smul_nonneg (by positivity) (hx_nonneg m)
refine CStarAlgebra.norm_le_norm_of_nonneg_of_le (f.map_nonneg (this n)) ?_
gcongr
exact x_summable.le_tsum n fun m _ ↦ this m
instance {F : Type*} [FunLike F A₁ A₂] [LinearMapClass F ℂ A₁ A₂] [OrderHomClass F A₁ A₂] :
ContinuousLinearMapClass F ℂ A₁ A₂ where
map_continuous f := by
have hbound : ∃ C : ℝ, ∀ a, ‖f a‖ ≤ C * ‖a‖ := by
obtain ⟨C, h⟩ := exists_norm_apply_le (f : A₁ →ₚ[ℂ] A₂)
exact ⟨C, h⟩
exact (LinearMap.mkContinuousOfExistsBound (f : A₁ →ₗ[ℂ] A₂) hbound).continuous
instance {F : Type*} [FunLike F A₁ A₂] [LinearMapClass F ℂ A₁ A₂] [OrderHomClass F A₁ A₂] :
StarHomClass F A₁ A₂ where
map_star f a := by
obtain ⟨y, hy_nonneg, hy_norm, hy⟩ := CStarAlgebra.exists_sum_four_nonneg a
have hy' : ∀ x : Fin 4, star (y x) = y x := fun x => by
rw [IsSelfAdjoint.star_eq (hy_nonneg x).isSelfAdjoint]
have hy'' : ∀ x : Fin 4, star (f (y x)) = f (y x) := fun x => by
rw [IsSelfAdjoint.star_eq (map_nonneg f (hy_nonneg x)).isSelfAdjoint]
simp [hy, hy', hy'']
end PositiveLinearMap
end CStarAlgebra |
.lake/packages/mathlib/Mathlib/Analysis/CStarAlgebra/CompletelyPositiveMap.lean | import Mathlib.Analysis.CStarAlgebra.PositiveLinearMap
import Mathlib.Analysis.CStarAlgebra.CStarMatrix
/-! # Completely positive maps
A linear map `φ : A₁ →ₗ[ℂ] A₂` (where `A₁` and `A₂` are C⋆-algebras) is called
*completely positive (CP)* if `CStarMatrix.map (Fin k) (Fin k) φ` (i.e. applying `φ` to all
entries of a k × k matrix) is also positive for every `k : ℕ`.
This file defines completely positive maps and develops their basic API.
## Main results
+ `NonUnitalStarAlgHomClass.instCompletelyPositiveMapClass`: Non-unital star algebra
homomorphisms are completely positive.
## Notation
+ `A₁ →CP A₂` denotes the type of CP maps from `A₁` to `A₂`. This notation is scoped to
`CStarAlgebra`.
## Implementation notes
The morphism class `CompletelyPositiveMapClass` is designed to be part of the order hierarchy,
and only includes the order property; linearity is not mentioned at all. It is therefore meant
to be used in conjunction with `LinearMapClass`. This is meant to avoid mixing order and algebra
as much as possible.
-/
open scoped CStarAlgebra
/--
A linear map `φ : A₁ →ₗ[ℂ] A₂` is called *completely positive (CP)* if
`CStarMatrix.mapₗ (Fin k) (Fin k) φ` (i.e. applying `φ` to all entries of a k × k matrix) is also
positive for every `k ∈ ℕ`.
Note that `Fin k` here is hardcoded to avoid having to quantify over types and introduce a new
universe parameter. See `CompletelyPositiveMap.map_cstarMatrix_nonneg` for a version of the
property that holds for matrices indexed by any finite type.
-/
structure CompletelyPositiveMap (A₁ : Type*) (A₂ : Type*) [NonUnitalCStarAlgebra A₁]
[NonUnitalCStarAlgebra A₂] [PartialOrder A₁] [PartialOrder A₂] [StarOrderedRing A₁]
[StarOrderedRing A₂] extends A₁ →ₗ[ℂ] A₂ where
map_cstarMatrix_nonneg' (k : ℕ) (M : CStarMatrix (Fin k) (Fin k) A₁) (hM : 0 ≤ M) :
0 ≤ M.map toLinearMap
/--
A linear map `φ : A₁ →ₗ[ℂ] A₂` is called *completely positive (CP)* if
`CStarMatrix.mapₗ (Fin k) (Fin k) φ` (i.e. applying `φ` to all entries of a k × k matrix) is also
positive for every `k ∈ ℕ`.
Note that `Fin k` here is hardcoded to avoid having to quantify over types and introduce a new
universe parameter. See `CompletelyPositiveMap.map_cstarMatrix_nonneg` for a version of the
property that holds for matrices indexed by any finite type.
-/
class CompletelyPositiveMapClass (F : Type*) (A₁ : Type*) (A₂ : Type*)
[NonUnitalCStarAlgebra A₁] [NonUnitalCStarAlgebra A₂] [PartialOrder A₁]
[PartialOrder A₂] [StarOrderedRing A₁] [StarOrderedRing A₂] [FunLike F A₁ A₂] where
map_cstarMatrix_nonneg' (φ : F) (k : ℕ) (M : CStarMatrix (Fin k) (Fin k) A₁) (hM : 0 ≤ M) :
0 ≤ M.map φ
/-- Notation for a `CompletelyPositiveMap`. -/
scoped[CStarAlgebra] notation:25 A₁ " →CP " A₂:0 => CompletelyPositiveMap A₁ A₂
namespace CompletelyPositiveMapClass
variable {F A₁ A₂ : Type*} [NonUnitalCStarAlgebra A₁]
[NonUnitalCStarAlgebra A₂] [PartialOrder A₁] [PartialOrder A₂] [StarOrderedRing A₁]
[StarOrderedRing A₂] [FunLike F A₁ A₂] [LinearMapClass F ℂ A₁ A₂]
/-- Reinterpret an element of a type of completely positive maps as a completely positive linear
map. -/
@[coe]
def toCompletelyPositiveLinearMap [CompletelyPositiveMapClass F A₁ A₂] (f : F) : A₁ →CP A₂ :=
{ (f : A₁ →ₗ[ℂ] A₂) with
map_cstarMatrix_nonneg' := CompletelyPositiveMapClass.map_cstarMatrix_nonneg' f }
/-- Reinterpret an element of a type of completely positive maps as a completely positive linear
map. -/
instance instCoeToCompletelyPositiveMap [CompletelyPositiveMapClass F A₁ A₂] :
CoeHead F (A₁ →CP A₂) where
coe f := toCompletelyPositiveLinearMap f
open CStarMatrix in
/-- Linear maps which are completely positive are order homomorphisms (i.e., positive maps). -/
lemma _root_.OrderHomClass.of_map_cstarMatrix_nonneg
(h : ∀ (φ : F) (k : ℕ) (M : CStarMatrix (Fin k) (Fin k) A₁), 0 ≤ M → 0 ≤ M.map φ) :
OrderHomClass F A₁ A₂ := .of_addMonoidHom <| by
intro φ a ha
let Ma := toOneByOne (Fin 1) ℂ A₁ a
have h₁ : 0 ≤ Ma := map_nonneg (toOneByOne (Fin 1) ℂ A₁) ha
have h₂ : 0 ≤ Ma.map φ := h φ 1 Ma h₁
have h₃ : φ a = (toOneByOne (Fin 1) ℂ A₂).symm (toOneByOne (Fin 1) ℂ A₂ (φ a)) := rfl
rw [h₃]
exact map_nonneg (toOneByOne (Fin 1) ℂ A₂).symm h₂
instance [CompletelyPositiveMapClass F A₁ A₂] : OrderHomClass F A₁ A₂ :=
.of_map_cstarMatrix_nonneg CompletelyPositiveMapClass.map_cstarMatrix_nonneg'
end CompletelyPositiveMapClass
namespace CompletelyPositiveMap
variable {A₁ A₂ : Type*} [NonUnitalCStarAlgebra A₁]
[NonUnitalCStarAlgebra A₂] [PartialOrder A₁] [PartialOrder A₂] [StarOrderedRing A₁]
[StarOrderedRing A₂]
instance : FunLike (A₁ →CP A₂) A₁ A₂ where
coe f := f.toFun
coe_injective' f g h := by
cases f
cases g
congr
apply DFunLike.coe_injective'
exact h
instance : LinearMapClass (A₁ →CP A₂) ℂ A₁ A₂ where
map_add f := map_add f.toLinearMap
map_smulₛₗ f := map_smulₛₗ f.toLinearMap
instance : CompletelyPositiveMapClass (A₁ →CP A₂) A₁ A₂ where
map_cstarMatrix_nonneg' f := f.map_cstarMatrix_nonneg'
open CStarMatrix in
lemma map_cstarMatrix_nonneg {n : Type*} [Fintype n] (φ : A₁ →CP A₂) (M : CStarMatrix n n A₁)
(hM : 0 ≤ M) : 0 ≤ M.map φ := by
let k := Fintype.card n
let e := Fintype.equivFinOfCardEq (rfl : Fintype.card n = k)
have hmain : 0 ≤ (reindexₐ ℂ A₁ e M).mapₗ (φ : A₁ →ₗ[ℂ] A₂) := by
simp only [mapₗ, LinearMap.coe_coe, LinearMap.coe_mk, AddHom.coe_mk]
exact CompletelyPositiveMapClass.map_cstarMatrix_nonneg' _ k _ (map_nonneg _ hM)
rw [← mapₗ_reindexₐ] at hmain
have hrw :
reindexₐ ℂ A₂ e.symm ((reindexₐ ℂ A₂ e) (M.map (φ : A₁ → A₂))) = M.map (φ : A₁ → A₂) := by
simp
rw [← hrw]
exact map_nonneg _ hmain
end CompletelyPositiveMap
namespace NonUnitalStarAlgHomClass
variable {F A₁ A₂ : Type*} [NonUnitalCStarAlgebra A₁] [NonUnitalCStarAlgebra A₂] [PartialOrder A₁]
[PartialOrder A₂] [StarOrderedRing A₁] [StarOrderedRing A₂] [FunLike F A₁ A₂]
[NonUnitalAlgHomClass F ℂ A₁ A₂] [StarHomClass F A₁ A₂]
open CStarMatrix CFC in
/-- Non-unital star algebra homomorphisms are completely positive. -/
instance instCompletelyPositiveMapClass : CompletelyPositiveMapClass F A₁ A₂ where
map_cstarMatrix_nonneg' φ k M hM := by
change 0 ≤ (mapₙₐ (φ : A₁ →⋆ₙₐ[ℂ] A₂)) M
exact map_nonneg _ hM
end NonUnitalStarAlgHomClass |
.lake/packages/mathlib/Mathlib/Analysis/CStarAlgebra/Exponential.lean | import Mathlib.Analysis.Normed.Algebra.Exponential
/-! # The exponential map from selfadjoint to unitary
In this file, we establish various properties related to the map
`fun a ↦ NormedSpace.exp ℂ A (I • a)` between the subtypes `selfAdjoint A` and `unitary A`.
## TODO
* Show that any exponential unitary is path-connected in `unitary A` to `1 : unitary A`.
* Prove any unitary whose distance to `1 : unitary A` is less than `1` can be expressed as an
exponential unitary.
* A unitary is in the path component of `1` if and only if it is a finite product of exponential
unitaries.
-/
open NormedSpace -- For `NormedSpace.exp`.
section Star
variable {A : Type*} [NormedRing A] [NormedAlgebra ℂ A] [StarRing A] [ContinuousStar A]
[CompleteSpace A] [StarModule ℂ A]
open Complex
/-- The map from the selfadjoint real subspace to the unitary group. This map only makes sense
over ℂ. -/
@[simps]
noncomputable def selfAdjoint.expUnitary (a : selfAdjoint A) : unitary A :=
⟨exp ℂ ((I • a.val) : A),
exp_mem_unitary_of_mem_skewAdjoint _ (a.prop.smul_mem_skewAdjoint conj_I)⟩
open selfAdjoint
@[simp]
lemma selfAdjoint.expUnitary_zero : expUnitary (0 : selfAdjoint A) = 1 := by
ext
simp
@[fun_prop]
lemma selfAdjoint.continuous_expUnitary : Continuous (expUnitary : selfAdjoint A → unitary A) := by
simp only [continuous_induced_rng, Function.comp_def, selfAdjoint.expUnitary_coe]
fun_prop
theorem Commute.expUnitary_add {a b : selfAdjoint A} (h : Commute (a : A) (b : A)) :
expUnitary (a + b) = expUnitary a * expUnitary b := by
ext
have hcomm : Commute (I • (a : A)) (I • (b : A)) := by
unfold Commute SemiconjBy
simp only [h.eq, Algebra.smul_mul_assoc, Algebra.mul_smul_comm]
simpa only [expUnitary_coe, AddSubgroup.coe_add, smul_add] using exp_add_of_commute hcomm
theorem Commute.expUnitary {a b : selfAdjoint A} (h : Commute (a : A) (b : A)) :
Commute (expUnitary a) (expUnitary b) :=
calc
selfAdjoint.expUnitary a * selfAdjoint.expUnitary b =
selfAdjoint.expUnitary b * selfAdjoint.expUnitary a := by
rw [← h.expUnitary_add, ← h.symm.expUnitary_add, add_comm]
end Star |
.lake/packages/mathlib/Mathlib/Analysis/CStarAlgebra/Basic.lean | import Mathlib.Analysis.Normed.Group.Hom
import Mathlib.Analysis.Normed.Module.Basic
import Mathlib.Analysis.Normed.Operator.LinearIsometry
import Mathlib.Algebra.Star.Pi
import Mathlib.Algebra.Star.SelfAdjoint
import Mathlib.Algebra.Star.Subalgebra
import Mathlib.Algebra.Star.Unitary
import Mathlib.Data.Real.Star
import Mathlib.Topology.Algebra.Module.Star
/-!
# Normed star rings and algebras
A normed star group is a normed group with a compatible `star` which is isometric.
A C⋆-ring is a normed star group that is also a ring and that verifies the stronger
condition `‖x‖^2 ≤ ‖x⋆ * x‖` for all `x` (which actually implies equality). If a C⋆-ring is also
a star algebra, then it is a C⋆-algebra.
Note that the type classes corresponding to C⋆-algebras are defined in
`Mathlib/Analysis/CStarAlgebra/Classes`.
## TODO
- Show that `‖x⋆ * x‖ = ‖x‖^2` is equivalent to `‖x⋆ * x‖ = ‖x⋆‖ * ‖x‖`, which is used as the
definition of C*-algebras in some sources (e.g. Wikipedia).
-/
assert_not_exists ContinuousLinearMap.hasOpNorm
open Topology
local postfix:max "⋆" => star
/-- A normed star group is a normed group with a compatible `star` which is isometric. -/
class NormedStarGroup (E : Type*) [SeminormedAddCommGroup E] [StarAddMonoid E] : Prop where
norm_star_le : ∀ x : E, ‖x⋆‖ ≤ ‖x‖
variable {𝕜 E α : Type*}
section NormedStarGroup
variable [SeminormedAddCommGroup E] [StarAddMonoid E] [NormedStarGroup E]
@[simp]
lemma norm_star (x : E) : ‖x⋆‖ = ‖x‖ :=
le_antisymm (NormedStarGroup.norm_star_le x) (by simpa using NormedStarGroup.norm_star_le x⋆)
@[simp]
theorem nnnorm_star (x : E) : ‖star x‖₊ = ‖x‖₊ :=
Subtype.ext <| norm_star _
/-- The `star` map in a normed star group is a normed group homomorphism. -/
def starNormedAddGroupHom : NormedAddGroupHom E E :=
{ starAddEquiv with bound' := ⟨1, fun _ => le_trans (norm_star _).le (one_mul _).symm.le⟩ }
/-- The `star` map in a normed star group is an isometry -/
theorem star_isometry : Isometry (star : E → E) :=
show Isometry starAddEquiv from
AddMonoidHomClass.isometry_of_norm starAddEquiv (show ∀ x, ‖x⋆‖ = ‖x‖ from norm_star)
instance (priority := 100) NormedStarGroup.to_continuousStar : ContinuousStar E :=
⟨star_isometry.continuous⟩
noncomputable
instance [NormedField 𝕜] [NormedSpace 𝕜 E] [Star 𝕜] [TrivialStar 𝕜] [StarModule 𝕜 E] :
NormedSpace 𝕜 (selfAdjoint E) where
norm_smul_le _ _ := norm_smul_le _ (_ : E)
end NormedStarGroup
instance RingHomIsometric.starRingEnd [NormedCommRing E] [StarRing E] [NormedStarGroup E] :
RingHomIsometric (starRingEnd E) :=
⟨@norm_star _ _ _ _⟩
/-- A C*-ring is a normed star ring that satisfies the stronger condition `‖x‖ ^ 2 ≤ ‖x⋆ * x‖`
for every `x`. Note that this condition actually implies equality, as is shown in
`norm_star_mul_self` below. -/
class CStarRing (E : Type*) [NonUnitalNormedRing E] [StarRing E] : Prop where
norm_mul_self_le : ∀ x : E, ‖x‖ * ‖x‖ ≤ ‖x⋆ * x‖
instance : CStarRing ℝ where
norm_mul_self_le x := by
simp only [Real.norm_eq_abs, abs_mul_abs_self, star, id, norm_mul, le_refl]
namespace CStarRing
section NonUnital
lemma of_le_norm_mul_star_self
[NonUnitalNormedRing E] [StarRing E]
(h : ∀ x : E, ‖x‖ * ‖x‖ ≤ ‖x * x⋆‖) : CStarRing E :=
have : NormedStarGroup E :=
{ norm_star_le x := by
obtain (hx | hx) := eq_zero_or_norm_pos x⋆
· simp [hx]
· refine le_of_mul_le_mul_right ?_ hx
simpa [sq, mul_comm ‖x⋆‖] using h x⋆ |>.trans <| norm_mul_le _ _ }
⟨star_involutive.surjective.forall.mpr <| by simpa⟩
variable [NonUnitalNormedRing E] [StarRing E] [CStarRing E]
-- see Note [lower instance priority]
/-- In a C*-ring, star preserves the norm. -/
instance (priority := 100) to_normedStarGroup : NormedStarGroup E where
norm_star_le x := by
obtain (hx | hx) := eq_zero_or_norm_pos x⋆
· simp [hx]
· refine le_of_mul_le_mul_right ?_ hx
simpa using norm_mul_self_le (x := x⋆) |>.trans <| norm_mul_le _ _
theorem norm_star_mul_self {x : E} : ‖x⋆ * x‖ = ‖x‖ * ‖x‖ :=
le_antisymm ((norm_mul_le _ _).trans (by rw [norm_star])) (CStarRing.norm_mul_self_le x)
theorem norm_self_mul_star {x : E} : ‖x * x⋆‖ = ‖x‖ * ‖x‖ := by
nth_rw 1 [← star_star x]
simp only [norm_star_mul_self, norm_star]
theorem norm_star_mul_self' {x : E} : ‖x⋆ * x‖ = ‖x⋆‖ * ‖x‖ := by rw [norm_star_mul_self, norm_star]
theorem nnnorm_self_mul_star {x : E} : ‖x * x⋆‖₊ = ‖x‖₊ * ‖x‖₊ :=
Subtype.ext norm_self_mul_star
theorem nnnorm_star_mul_self {x : E} : ‖x⋆ * x‖₊ = ‖x‖₊ * ‖x‖₊ :=
Subtype.ext norm_star_mul_self
lemma _root_.IsSelfAdjoint.norm_mul_self {x : E} (hx : IsSelfAdjoint x) :
‖x * x‖ = ‖x‖ ^ 2 := by
simpa [sq, hx.star_eq] using CStarRing.norm_star_mul_self (x := x)
lemma _root_.IsSelfAdjoint.nnnorm_mul_self {x : E} (hx : IsSelfAdjoint x) :
‖x * x‖₊ = ‖x‖₊ ^ 2 :=
Subtype.ext hx.norm_mul_self
@[simp]
theorem star_mul_self_eq_zero_iff (x : E) : x⋆ * x = 0 ↔ x = 0 := by
rw [← norm_eq_zero, norm_star_mul_self]
exact mul_self_eq_zero.trans norm_eq_zero
theorem star_mul_self_ne_zero_iff (x : E) : x⋆ * x ≠ 0 ↔ x ≠ 0 := by
simp only [Ne, star_mul_self_eq_zero_iff]
@[simp]
theorem mul_star_self_eq_zero_iff (x : E) : x * x⋆ = 0 ↔ x = 0 := by
simpa only [star_eq_zero, star_star] using @star_mul_self_eq_zero_iff _ _ _ _ (star x)
theorem mul_star_self_ne_zero_iff (x : E) : x * x⋆ ≠ 0 ↔ x ≠ 0 := by
simp only [Ne, mul_star_self_eq_zero_iff]
end NonUnital
section ProdPi
variable {ι R₁ R₂ : Type*} {R : ι → Type*}
variable [NonUnitalNormedRing R₁] [StarRing R₁] [CStarRing R₁]
variable [NonUnitalNormedRing R₂] [StarRing R₂] [CStarRing R₂]
variable [∀ i, NonUnitalNormedRing (R i)] [∀ i, StarRing (R i)]
/-- This instance exists to short circuit type class resolution because of problems with
inference involving Π-types. -/
instance _root_.Pi.starRing' : StarRing (∀ i, R i) :=
inferInstance
variable [Fintype ι] [∀ i, CStarRing (R i)]
instance _root_.Prod.cstarRing : CStarRing (R₁ × R₂) where
norm_mul_self_le x := by
dsimp only [norm]
simp only [Prod.fst_mul, Prod.fst_star, Prod.snd_mul, Prod.snd_star, norm_star_mul_self, ← sq]
rw [le_sup_iff]
rcases le_total ‖x.fst‖ ‖x.snd‖ with (h | h) <;> simp [h]
instance _root_.Pi.cstarRing : CStarRing (∀ i, R i) where
norm_mul_self_le x := by
refine le_of_eq (Eq.symm ?_)
simp only [norm, Pi.mul_apply, Pi.star_apply, nnnorm_star_mul_self, ← sq]
norm_cast
exact
(Finset.comp_sup_eq_sup_comp_of_is_total (fun x : NNReal => x ^ 2)
(fun x y h => by simpa only [sq] using mul_le_mul' h h) (by simp)).symm
instance _root_.Pi.cstarRing' : CStarRing (ι → R₁) :=
Pi.cstarRing
end ProdPi
namespace MulOpposite
instance {E : Type*} [NonUnitalNormedRing E] [StarRing E] [CStarRing E] : CStarRing Eᵐᵒᵖ where
norm_mul_self_le x := CStarRing.norm_self_mul_star (x := MulOpposite.unop x) |>.symm.le
end MulOpposite
section Unital
variable [NormedRing E] [StarRing E] [CStarRing E]
theorem norm_one [Nontrivial E] : ‖(1 : E)‖ = 1 := by
have : 0 < ‖(1 : E)‖ := norm_pos_iff.mpr one_ne_zero
rw [← mul_left_inj' this.ne', ← norm_star_mul_self, mul_one, star_one, one_mul]
-- see Note [lower instance priority]
instance (priority := 100) [Nontrivial E] : NormOneClass E :=
⟨norm_one⟩
theorem norm_coe_unitary [Nontrivial E] (U : unitary E) : ‖(U : E)‖ = 1 := by
rw [← sq_eq_sq₀ (norm_nonneg _) zero_le_one, one_pow 2, sq, ← CStarRing.norm_star_mul_self,
Unitary.coe_star_mul_self, CStarRing.norm_one]
@[simp]
theorem norm_of_mem_unitary [Nontrivial E] {U : E} (hU : U ∈ unitary E) : ‖U‖ = 1 :=
norm_coe_unitary ⟨U, hU⟩
@[simp]
theorem norm_coe_unitary_mul (U : unitary E) (A : E) : ‖(U : E) * A‖ = ‖A‖ := by
nontriviality E
refine le_antisymm ?_ ?_
· calc
_ ≤ ‖(U : E)‖ * ‖A‖ := norm_mul_le _ _
_ = ‖A‖ := by rw [norm_coe_unitary, one_mul]
· calc
_ = ‖(U : E)⋆ * U * A‖ := by rw [Unitary.coe_star_mul_self U, one_mul]
_ ≤ ‖(U : E)⋆‖ * ‖(U : E) * A‖ := by
rw [mul_assoc]
exact norm_mul_le _ _
_ = ‖(U : E) * A‖ := by rw [norm_star, norm_coe_unitary, one_mul]
@[simp]
theorem norm_unitary_smul (U : unitary E) (A : E) : ‖U • A‖ = ‖A‖ :=
norm_coe_unitary_mul U A
theorem norm_mem_unitary_mul {U : E} (A : E) (hU : U ∈ unitary E) : ‖U * A‖ = ‖A‖ :=
norm_coe_unitary_mul ⟨U, hU⟩ A
@[simp]
theorem norm_mul_coe_unitary (A : E) (U : unitary E) : ‖A * U‖ = ‖A‖ :=
calc
_ = ‖((U : E)⋆ * A⋆)⋆‖ := by simp only [star_star, star_mul]
_ = ‖(U : E)⋆ * A⋆‖ := by rw [norm_star]
_ = ‖A⋆‖ := norm_mem_unitary_mul (star A) (Unitary.star_mem U.prop)
_ = ‖A‖ := norm_star _
theorem norm_mul_mem_unitary (A : E) {U : E} (hU : U ∈ unitary E) : ‖A * U‖ = ‖A‖ :=
norm_mul_coe_unitary A ⟨U, hU⟩
end Unital
end CStarRing
section SelfAdjoint
variable [NormedRing E] [StarRing E] [CStarRing E]
theorem IsSelfAdjoint.nnnorm_pow_two_pow {x : E} (hx : IsSelfAdjoint x) (n : ℕ) :
‖x ^ 2 ^ n‖₊ = ‖x‖₊ ^ 2 ^ n := by
induction n with
| zero => simp only [pow_zero, pow_one]
| succ k hk =>
rw [pow_succ', pow_mul', sq, (hx.pow (2 ^ k)).nnnorm_mul_self, hk, pow_mul']
@[deprecated (since := "2025-10-07")]
alias selfAdjoint.nnnorm_pow_two_pow := IsSelfAdjoint.nnnorm_pow_two_pow
theorem IsSelfAdjoint.norm_pow_two_pow {x : E} (hx : IsSelfAdjoint x) (n : ℕ) :
‖x ^ 2 ^ n‖ = ‖x‖ ^ 2 ^ n :=
congr($(hx.nnnorm_pow_two_pow n))
end SelfAdjoint
section starₗᵢ
variable [CommSemiring 𝕜] [StarRing 𝕜]
variable [SeminormedAddCommGroup E] [StarAddMonoid E] [NormedStarGroup E]
variable [Module 𝕜 E] [StarModule 𝕜 E]
variable (𝕜) in
/-- `star` bundled as a linear isometric equivalence -/
def starₗᵢ : E ≃ₗᵢ⋆[𝕜] E :=
{ starAddEquiv with
map_smul' := star_smul
norm_map' := norm_star }
@[simp]
theorem coe_starₗᵢ : (starₗᵢ 𝕜 : E → E) = star :=
rfl
theorem starₗᵢ_apply {x : E} : starₗᵢ 𝕜 x = star x :=
rfl
@[simp]
theorem starₗᵢ_toContinuousLinearEquiv :
(starₗᵢ 𝕜 : E ≃ₗᵢ⋆[𝕜] E).toContinuousLinearEquiv = (starL 𝕜 : E ≃L⋆[𝕜] E) :=
ContinuousLinearEquiv.ext rfl
end starₗᵢ
namespace StarSubalgebra
instance toNormedAlgebra {𝕜 A : Type*} [NormedField 𝕜] [StarRing 𝕜] [SeminormedRing A] [StarRing A]
[NormedAlgebra 𝕜 A] [StarModule 𝕜 A] (S : StarSubalgebra 𝕜 A) : NormedAlgebra 𝕜 S :=
NormedAlgebra.induced 𝕜 S A S.subtype
instance to_cstarRing {R A} [CommRing R] [StarRing R] [NormedRing A] [StarRing A] [CStarRing A]
[Algebra R A] [StarModule R A] (S : StarSubalgebra R A) : CStarRing S where
norm_mul_self_le x := @CStarRing.norm_mul_self_le A _ _ _ x
end StarSubalgebra |
.lake/packages/mathlib/Mathlib/Analysis/CStarAlgebra/ApproximateUnit.lean | import Mathlib.Analysis.CStarAlgebra.ContinuousFunctionalCalculus.Order
import Mathlib.Analysis.CStarAlgebra.SpecialFunctions.PosPart
import Mathlib.Analysis.SpecialFunctions.ContinuousFunctionalCalculus.Rpow.Basic
import Mathlib.Topology.ApproximateUnit
/-! # Nonnegative contractions in a C⋆-algebra form an approximate unit
This file shows that the collection of positive contractions (of norm strictly less than one)
in a possibly non-unital C⋆-algebra form a directed set. The key step uses the continuous functional
calculus applied with the functions `fun x : ℝ≥0, 1 - (1 + x)⁻¹` and `fun x : ℝ≥0, x * (1 - x)⁻¹`,
which are inverses on the interval `{x : ℝ≥0 | x < 1}`.
In addition, this file defines `IsIncreasingApproximateUnit` to be a filter `l` that is an
approximate unit contained in the closed unit ball of nonnegative elements. Every C⋆-algebra has
a filter generated by the sections `{x | a ≤ x} ∩ closedBall 0 1` for `0 ≤ a` and `‖a‖ < 1`, and
moreover, this filter is an increasing approximate unit.
## Main declarations
+ `CFC.monotoneOn_one_sub_one_add_inv`: the function `f := fun x : ℝ≥0, 1 - (1 + x)⁻¹` is
*operator monotone* on `Set.Ici (0 : A)` (i.e., `cfcₙ f` is monotone on `{x : A | 0 ≤ x}`).
+ `Set.InvOn.one_sub_one_add_inv`: the functions `f := fun x : ℝ≥0, 1 - (1 + x)⁻¹` and
`g := fun x : ℝ≥0, x * (1 - x)⁻¹` are inverses on `{x : ℝ≥0 | x < 1}`.
+ `CStarAlgebra.directedOn_nonneg_ball`: the set `{x : A | 0 ≤ x} ∩ Metric.ball 0 1` is directed.
+ `Filter.IsIncreasingApproximateUnit`: a filter `l` is an *increasing approximate unit* if it is an
approximate unit contained in the closed unit ball of nonnegative elements.
+ `CStarAlgebra.approximateUnit`: the filter generated by the sections
`{x | a ≤ x} ∩ closedBall 0 1` for `0 ≤ a` with `‖a‖ < 1`.
+ `CStarAlgebra.increasingApproximateUnit`: the filter `CStarAlgebra.approximateUnit` is an
increasing approximate unit.
-/
variable {A : Type*} [NonUnitalCStarAlgebra A]
local notation "σₙ" => quasispectrum
local notation "σ" => spectrum
open Unitization NNReal CStarAlgebra
variable [PartialOrder A] [StarOrderedRing A]
lemma CFC.monotoneOn_one_sub_one_add_inv :
MonotoneOn (cfcₙ (fun x : ℝ≥0 ↦ 1 - (1 + x)⁻¹)) (Set.Ici (0 : A)) := by
intro a ha b hb hab
simp only [Set.mem_Ici] at ha hb
rw [← inr_le_iff .., nnreal_cfcₙ_eq_cfc_inr a _, nnreal_cfcₙ_eq_cfc_inr b _]
rw [← inr_le_iff a b (.of_nonneg ha) (.of_nonneg hb)] at hab
rw [← inr_nonneg_iff] at ha hb
have h_cfc_one_sub (c : A⁺¹) (hc : 0 ≤ c := by cfc_tac) :
cfc (fun x : ℝ≥0 ↦ 1 - (1 + x)⁻¹) c = 1 - cfc (·⁻¹ : ℝ≥0 → ℝ≥0) (1 + c) := by
rw [cfc_tsub _ _ _ (fun x _ ↦ by simp) (hg := by fun_prop (disch := intro _ _; positivity)),
cfc_const_one ℝ≥0 c, cfc_comp' (·⁻¹) (1 + ·) c ?_, cfc_add .., cfc_const_one ℝ≥0 c,
cfc_id' ℝ≥0 c]
exact continuousOn_id.inv₀ (Set.forall_mem_image.mpr fun x _ ↦ by dsimp only [id]; positivity)
rw [h_cfc_one_sub (a : A⁺¹), h_cfc_one_sub (b : A⁺¹)]
gcongr
rw [← CFC.rpow_neg_one_eq_cfc_inv, ← CFC.rpow_neg_one_eq_cfc_inv]
exact rpow_neg_one_le_rpow_neg_one (by gcongr)
lemma CFC.monotoneOn_one_sub_one_add_inv_real :
MonotoneOn (cfcₙ (fun x : ℝ => 1 - (1 + x)⁻¹)) (Set.Ici (0 : A)) := by
intro a (ha : 0 ≤ a) b (hb : 0 ≤ b) hab
calc _ = cfcₙ (fun x : ℝ≥0 => 1 - (1 + x)⁻¹) a := by
rw [cfcₙ_nnreal_eq_real _ _ ha]
refine cfcₙ_congr ?_
intro x hx
have hx' : 0 ≤ x := by grind
simp [hx']
_ ≤ cfcₙ (fun x : ℝ≥0 => 1 - (1 + x)⁻¹) b :=
CFC.monotoneOn_one_sub_one_add_inv ha hb hab
_ = cfcₙ (fun x : ℝ => 1 - (1 + x)⁻¹) b := by
rw [cfcₙ_nnreal_eq_real _ _ hb]
refine cfcₙ_congr ?_
intro x hx
have hx' : 0 ≤ x := by grind
simp [hx']
lemma Set.InvOn.one_sub_one_add_inv : Set.InvOn (fun x ↦ 1 - (1 + x)⁻¹) (fun x ↦ x * (1 - x)⁻¹)
{x : ℝ≥0 | x < 1} {x : ℝ≥0 | x < 1} := by
have : (fun x : ℝ≥0 ↦ x * (1 + x)⁻¹) = fun x ↦ 1 - (1 + x)⁻¹ := by
ext x : 1
simp [field, mul_tsub]
rw [← this]
constructor <;> intro x (hx : x < 1)
· have : 0 < 1 - x := tsub_pos_of_lt hx
simp [field, tsub_add_cancel_of_le hx.le]
· simp [mul_assoc, ← mul_inv, mul_tsub]
field_simp
simp
lemma norm_cfcₙ_one_sub_one_add_inv_lt_one (a : A) :
‖cfcₙ (fun x : ℝ≥0 ↦ 1 - (1 + x)⁻¹) a‖ < 1 :=
nnnorm_cfcₙ_nnreal_lt fun x _ ↦ tsub_lt_self zero_lt_one (by positivity)
-- the calls to `fun_prop` with a discharger set off the linter
set_option linter.style.multiGoal false in
lemma CStarAlgebra.directedOn_nonneg_ball :
DirectedOn (· ≤ ·) ({x : A | 0 ≤ x} ∩ Metric.ball 0 1) := by
let f : ℝ≥0 → ℝ≥0 := fun x => 1 - (1 + x)⁻¹
let g : ℝ≥0 → ℝ≥0 := fun x => x * (1 - x)⁻¹
suffices ∀ a b : A, 0 ≤ a → 0 ≤ b → ‖a‖ < 1 → ‖b‖ < 1 →
a ≤ cfcₙ f (cfcₙ g a + cfcₙ g b) by
rintro a ⟨(ha₁ : 0 ≤ a), ha₂⟩ b ⟨(hb₁ : 0 ≤ b), hb₂⟩
simp only [Metric.mem_ball, dist_zero_right] at ha₂ hb₂
refine ⟨cfcₙ f (cfcₙ g a + cfcₙ g b), ⟨by simp, ?_⟩, ?_, ?_⟩
· simpa only [Metric.mem_ball, dist_zero_right] using norm_cfcₙ_one_sub_one_add_inv_lt_one _
· exact this a b ha₁ hb₁ ha₂ hb₂
· exact add_comm (cfcₙ g a) (cfcₙ g b) ▸ this b a hb₁ ha₁ hb₂ ha₂
rintro a b ha₁ - ha₂ -
calc
a = cfcₙ (f ∘ g) a := by
conv_lhs => rw [← cfcₙ_id ℝ≥0 a]
refine cfcₙ_congr (Set.InvOn.one_sub_one_add_inv.1.eqOn.symm.mono fun x hx ↦ ?_)
exact lt_of_le_of_lt (le_nnnorm_of_mem_quasispectrum hx) ha₂
_ = cfcₙ f (cfcₙ g a) := by
rw [cfcₙ_comp f g a ?_ (by simp [f, tsub_self]) ?_ (by simp [g]) ha₁]
· fun_prop (disch := intro _ _; positivity)
· have (x) (hx : x ∈ σₙ ℝ≥0 a) : 1 - x ≠ 0 := by
refine tsub_pos_of_lt ?_ |>.ne'
exact lt_of_le_of_lt (le_nnnorm_of_mem_quasispectrum hx) ha₂
fun_prop (disch := assumption)
_ ≤ cfcₙ f (cfcₙ g a + cfcₙ g b) := by
have hab' : cfcₙ g a ≤ cfcₙ g a + cfcₙ g b := le_add_of_nonneg_right cfcₙ_nonneg_of_predicate
exact CFC.monotoneOn_one_sub_one_add_inv cfcₙ_nonneg_of_predicate
(cfcₙ_nonneg_of_predicate.trans hab') hab'
section ApproximateUnit
open Metric Filter Topology
/-- An *increasing approximate unit* in a C⋆-algebra is an approximate unit contained in the
closed unit ball of nonnegative elements. -/
structure Filter.IsIncreasingApproximateUnit (l : Filter A) : Prop extends l.IsApproximateUnit where
eventually_nonneg : ∀ᶠ x in l, 0 ≤ x
eventually_norm : ∀ᶠ x in l, ‖x‖ ≤ 1
namespace Filter.IsIncreasingApproximateUnit
omit [StarOrderedRing A] in
lemma eventually_nnnorm {l : Filter A} (hl : l.IsIncreasingApproximateUnit) :
∀ᶠ x in l, ‖x‖₊ ≤ 1 :=
hl.eventually_norm
lemma eventually_isSelfAdjoint {l : Filter A} (hl : l.IsIncreasingApproximateUnit) :
∀ᶠ x in l, IsSelfAdjoint x :=
hl.eventually_nonneg.mp <| .of_forall fun _ ↦ IsSelfAdjoint.of_nonneg
lemma eventually_star_eq {l : Filter A} (hl : l.IsIncreasingApproximateUnit) :
∀ᶠ x in l, star x = x :=
hl.eventually_isSelfAdjoint.mp <| .of_forall fun _ ↦ IsSelfAdjoint.star_eq
end Filter.IsIncreasingApproximateUnit
namespace CStarAlgebra
open Submodule in
/-- To show that `l` is a one-sided approximate unit for `A`, it suffices to verify it only for
`m : A` with `0 ≤ m` and `‖m‖ < 1`. -/
lemma tendsto_mul_right_of_forall_nonneg_tendsto {l : Filter A}
(h : ∀ m, 0 ≤ m → ‖m‖ < 1 → Tendsto (· * m) l (𝓝 m)) (m : A) :
Tendsto (· * m) l (𝓝 m) := by
obtain ⟨n, c, x, rfl⟩ := mem_span_set'.mp <| by
change m ∈ span ℂ ({x | 0 ≤ x} ∩ ball 0 1)
simp [span_nonneg_inter_unitBall]
simp_rw [Finset.mul_sum]
refine tendsto_finset_sum _ fun i _ ↦ ?_
simp_rw [mul_smul_comm]
exact tendsto_const_nhds.smul <| h (x i) (x i).2.1 <| by simpa using (x i).2.2
omit [PartialOrder A] in
/-- Multiplication on the left by `m` tends to `𝓝 m` if and only if multiplication on the right
does, provided the elements are eventually selfadjoint along the filter `l`. -/
lemma tendsto_mul_left_iff_tendsto_mul_right {l : Filter A} (hl : ∀ᶠ x in l, IsSelfAdjoint x) :
(∀ m, Tendsto (m * ·) l (𝓝 m)) ↔ (∀ m, Tendsto (· * m) l (𝓝 m)) := by
refine ⟨fun h m ↦ ?_, fun h m ↦ ?_⟩
all_goals
apply (star_star m ▸ (continuous_star.tendsto _ |>.comp <| h (star m))).congr'
filter_upwards [hl] with x hx
simp [hx.star_eq]
variable (A)
/-- The sections of positive strict contractions form a filter basis. -/
lemma isBasis_nonneg_sections :
IsBasis (fun x : A ↦ 0 ≤ x ∧ ‖x‖ < 1) ({x | · ≤ x}) where
nonempty := ⟨0, by simp⟩
inter {x y} hx hy := by
peel directedOn_nonneg_ball x (by simpa) y (by simpa) with z hz
exact ⟨by simpa using hz.1, fun a ha ↦ ⟨hz.2.1.trans ha, hz.2.2.trans ha⟩⟩
/-- The canonical approximate unit in a C⋆-algebra generated by the basis of sets
`{x | a ≤ x} ∩ closedBall 0 1` for `0 ≤ a`. See also `CStarAlgebra.hasBasis_approximateUnit`. -/
def approximateUnit : Filter A :=
(isBasis_nonneg_sections A).filter ⊓ 𝓟 (closedBall 0 1)
/-- The canonical approximate unit in a C⋆-algebra has a basis of sets
`{x | a ≤ x} ∩ closedBall 0 1` for `0 ≤ a`. -/
lemma hasBasis_approximateUnit :
(approximateUnit A).HasBasis (fun x : A ↦ 0 ≤ x ∧ ‖x‖ < 1) ({x | · ≤ x} ∩ closedBall 0 1) :=
isBasis_nonneg_sections A |>.hasBasis.inf_principal (closedBall 0 1)
/-- This is a common reasoning sequence in C⋆-algebra theory. If `0 ≤ x ≤ y ≤ 1`, then the norm of
`z - y * z` is controlled by the norm of `star z * (1 - x) * z`, which is advantageous because the
latter is nonnegative. This is a key step in establishing the existence of an increasing approximate
unit in general C⋆-algebras. -/
lemma nnnorm_sub_mul_self_le {A : Type*} [CStarAlgebra A] [PartialOrder A] [StarOrderedRing A]
{x y : A} (z : A) (hx₀ : 0 ≤ x) (hy : y ∈ Set.Icc x 1) {c : ℝ≥0}
(h : ‖star z * (1 - x) * z‖₊ ≤ c ^ 2) :
‖z - y * z‖₊ ≤ c := by
nth_rw 1 [← one_mul z]
rw [← sqrt_sq c, le_sqrt_iff_sq_le, ← sub_mul, sq, ← CStarRing.nnnorm_star_mul_self]
simp only [star_mul, star_sub, star_one]
have hy₀ : y ∈ Set.Icc 0 1 := ⟨hx₀.trans hy.1, hy.2⟩
have hy' : 1 - y ∈ Set.Icc 0 1 := Set.sub_mem_Icc_zero_iff_right.mpr hy₀
rw [hy₀.1.star_eq, ← mul_assoc, mul_assoc (star _), ← sq]
refine nnnorm_le_nnnorm_of_nonneg_of_le (star_left_conjugate_nonneg (pow_nonneg hy'.1 2) _) ?_
|>.trans h
refine star_left_conjugate_le_conjugate ?_ _
trans (1 - y)
· simpa using pow_antitone hy'.1 hy'.2 one_le_two
· gcongr
exact hy.1
/-- A variant of `nnnorm_sub_mul_self_le` which uses `‖·‖` instead of `‖·‖₊`. -/
lemma norm_sub_mul_self_le {A : Type*} [CStarAlgebra A] [PartialOrder A] [StarOrderedRing A]
{x y : A} (z : A) (hx₀ : 0 ≤ x) (hy : y ∈ Set.Icc x 1)
{c : ℝ} (hc : 0 ≤ c) (h : ‖star z * (1 - x) * z‖ ≤ c ^ 2) :
‖z - y * z‖ ≤ c :=
nnnorm_sub_mul_self_le z hx₀ hy h (c := ⟨c, hc⟩)
variable {A} in
/-- A variant of `norm_sub_mul_self_le` for non-unital algebras that passes to the unitization. -/
lemma norm_sub_mul_self_le_of_inr {x y : A} (z : A) (hx₀ : 0 ≤ x) (hxy : x ≤ y) (hy₁ : ‖y‖ ≤ 1)
{c : ℝ} (hc : 0 ≤ c) (h : ‖star (z : A⁺¹) * (1 - x) * z‖ ≤ c ^ 2) :
‖z - y * z‖ ≤ c := by
rw [← norm_inr (𝕜 := ℂ), inr_sub, inr_mul]
refine norm_sub_mul_self_le _ ?_ ?_ hc h
· rwa [inr_nonneg_iff]
· have hy := hx₀.trans hxy
rw [Set.mem_Icc, inr_le_iff _ _ hx₀.isSelfAdjoint hy.isSelfAdjoint,
← norm_le_one_iff_of_nonneg _, norm_inr]
exact ⟨hxy, hy₁⟩
variable {A} in
/-- This shows `CStarAlgebra.approximateUnit` is a one-sided approximate unit, but this is marked
`private` because it is only used to prove `CStarAlgebra.increasingApproximateUnit`. -/
private lemma tendsto_mul_right_approximateUnit (m : A) :
Tendsto (· * m) (approximateUnit A) (𝓝 m) := by
refine tendsto_mul_right_of_forall_nonneg_tendsto (fun m hm₁ hm₂ ↦ ?_) m
rw [(hasBasis_approximateUnit A).tendsto_iff nhds_basis_closedBall]
intro ε hε
lift ε to ℝ≥0 using hε.le
rw [coe_pos] at hε
refine ⟨cfcₙ (fun y : ℝ≥0 ↦ 1 - (1 + y)⁻¹) (ε⁻¹ ^ 2 • m),
⟨cfcₙ_nonneg_of_predicate, norm_cfcₙ_one_sub_one_add_inv_lt_one (ε⁻¹ ^ 2 • m)⟩, ?_⟩
rintro x ⟨(hx₁ : _ ≤ x), hx₂⟩
simp only [mem_closedBall, dist_eq_norm', zero_sub, norm_neg] at hx₂ ⊢
rw [← coe_nnnorm, coe_le_coe]
have hx₀ : 0 ≤ x := cfcₙ_nonneg_of_predicate.trans hx₁
rw [← inr_le_iff _ _ (.of_nonneg cfcₙ_nonneg_of_predicate) (.of_nonneg hx₀),
nnreal_cfcₙ_eq_cfc_inr _ _ (by simp [tsub_self]), inr_smul] at hx₁
rw [← norm_inr (𝕜 := ℂ)] at hm₂ hx₂
rw [← inr_nonneg_iff] at hx₀ hm₁
rw [← nnnorm_inr (𝕜 := ℂ), inr_sub, inr_mul]
generalize (x : A⁺¹) = x, (m : A⁺¹) = m at *
set g : ℝ≥0 → ℝ≥0 := fun y ↦ 1 - (1 + y)⁻¹
have hg : Continuous g := by
rw [← continuousOn_univ]
fun_prop (disch := intro _ _; positivity)
have hg' : ContinuousOn (fun y ↦ (1 + ε⁻¹ ^ 2 • y)⁻¹) (spectrum ℝ≥0 m) :=
ContinuousOn.inv₀ (by fun_prop) fun _ _ ↦ by positivity
have hx : x ∈ Set.Icc 0 1 := mem_Icc_iff_norm_le_one.mpr ⟨hx₀, hx₂⟩
have hx' : x ∈ Set.Icc _ 1 := ⟨hx₁, hx.2⟩
refine nnnorm_sub_mul_self_le m cfc_nonneg_of_predicate hx' ?_
suffices star m * (1 - cfc g (ε⁻¹ ^ 2 • m)) * m =
cfc (fun y : ℝ≥0 ↦ y * (1 + ε⁻¹ ^ 2 • y)⁻¹ * y) m by
rw [this]
refine nnnorm_cfc_nnreal_le fun y hy ↦ ?_
calc
y * (1 + ε⁻¹ ^ 2 • y)⁻¹ * y = y * ε ^ 2 * (y / (ε ^ 2 + y)) := by simp [field]
_ ≤ ε ^ 2 * 1 := by
gcongr
· refine mul_le_of_le_one_left (zero_le _) ?_
have hm' := hm₂.le
rw [norm_le_one_iff_of_nonneg m hm₁, ← cfc_id' ℝ≥0 m, ← cfc_one (R := ℝ≥0) m,
cfc_nnreal_le_iff _ _ _ (QuasispectrumRestricts.nnreal_of_nonneg hm₁)] at hm'
exact hm' y hy
· exact div_le_one (by positivity) |>.mpr le_add_self
_ = ε ^ 2 := mul_one _
rw [cfc_mul _ _ m (continuousOn_id' _ |>.mul hg') (continuousOn_id' _),
cfc_mul _ _ m (continuousOn_id' _) hg', cfc_id' .., hm₁.star_eq]
congr
rw [← cfc_one (R := ℝ≥0) m, ← cfc_comp_smul _ _ _ hg.continuousOn hm₁,
← cfc_tsub _ _ m (by simp [g]) hm₁ (by fun_prop) (Continuous.continuousOn <| by fun_prop)]
refine cfc_congr (fun y _ ↦ ?_)
simp [g, tsub_tsub_cancel_of_le]
/-- The filter `CStarAlgebra.approximateUnit` generated by the sections
`{x | a ≤ x} ∩ closedBall 0 1` for `0 ≤ a` forms an increasing approximate unit. -/
lemma increasingApproximateUnit :
IsIncreasingApproximateUnit (approximateUnit A) where
tendsto_mul_left := by
rw [tendsto_mul_left_iff_tendsto_mul_right]
· exact tendsto_mul_right_approximateUnit
· rw [(hasBasis_approximateUnit A).eventually_iff]
peel (hasBasis_approximateUnit A).ex_mem with x hx
exact ⟨hx, fun y hy ↦ (hx.1.trans hy.1).isSelfAdjoint⟩
tendsto_mul_right := tendsto_mul_right_approximateUnit
eventually_nonneg := .filter_mono inf_le_left <|
(isBasis_nonneg_sections A).hasBasis.eventually_iff.mpr ⟨0, by simp⟩
eventually_norm := .filter_mono inf_le_right <| by simp
neBot := hasBasis_approximateUnit A |>.neBot_iff.mpr
fun hx ↦ ⟨_, ⟨le_rfl, by simpa using hx.2.le⟩⟩
end CStarAlgebra
end ApproximateUnit |
.lake/packages/mathlib/Mathlib/Analysis/CStarAlgebra/ContinuousMap.lean | import Mathlib.Analysis.CStarAlgebra.Classes
import Mathlib.Topology.ContinuousMap.Compact
import Mathlib.Topology.ContinuousMap.ZeroAtInfty
/-! # C⋆-algebras of continuous functions
We place these here because, for reasons related to the import hierarchy, they cannot be placed in
earlier files.
-/
variable {α A : Type*}
noncomputable section
namespace BoundedContinuousFunction
variable [TopologicalSpace α]
instance [NonUnitalCStarAlgebra A] : NonUnitalCStarAlgebra (α →ᵇ A) where
instance [NonUnitalCommCStarAlgebra A] : NonUnitalCommCStarAlgebra (α →ᵇ A) where
instance [CStarAlgebra A] : CStarAlgebra (α →ᵇ A) where
instance [CommCStarAlgebra A] : CommCStarAlgebra (α →ᵇ A) where
end BoundedContinuousFunction
namespace ContinuousMap
variable [TopologicalSpace α] [CompactSpace α]
instance [NonUnitalCStarAlgebra A] : NonUnitalCStarAlgebra C(α, A) where
instance [NonUnitalCommCStarAlgebra A] : NonUnitalCommCStarAlgebra C(α, A) where
instance [CStarAlgebra A] : CStarAlgebra C(α, A) where
instance [CommCStarAlgebra A] : CommCStarAlgebra C(α, A) where
end ContinuousMap
namespace ZeroAtInftyContinuousMap
open ZeroAtInfty
instance [TopologicalSpace α] [NonUnitalCStarAlgebra A] : NonUnitalCStarAlgebra C₀(α, A) where
instance [TopologicalSpace α] [NonUnitalCommCStarAlgebra A] :
NonUnitalCommCStarAlgebra C₀(α, A) where
end ZeroAtInftyContinuousMap |
.lake/packages/mathlib/Mathlib/Analysis/CStarAlgebra/lpSpace.lean | import Mathlib.Analysis.CStarAlgebra.Classes
import Mathlib.Analysis.Normed.Lp.lpSpace
/-! # `lp ∞ A` as a C⋆-algebra
We place these here because, for reasons related to the import hierarchy, they should not be placed
in earlier files.
-/
open scoped ENNReal
noncomputable section
variable {I : Type*} {A : I → Type*}
instance [∀ i, NonUnitalCStarAlgebra (A i)] : NonUnitalCStarAlgebra (lp A ∞) where
instance [∀ i, NonUnitalCommCStarAlgebra (A i)] : NonUnitalCommCStarAlgebra (lp A ∞) where
-- it's slightly weird that we need the `Nontrivial` instance here
-- it's because we have no way to say that `‖(1 : A i)‖` is uniformly bounded as a type class
-- aside from `∀ i, NormOneClass (A i)`, this holds automatically for C⋆-algebras though.
instance [∀ i, Nontrivial (A i)] [∀ i, CStarAlgebra (A i)] : NormedRing (lp A ∞) where
dist_eq := dist_eq_norm
norm_mul_le := norm_mul_le
instance [∀ i, Nontrivial (A i)] [∀ i, CommCStarAlgebra (A i)] : CommCStarAlgebra (lp A ∞) where
end |
.lake/packages/mathlib/Mathlib/Analysis/CStarAlgebra/Multiplier.lean | import Mathlib.Analysis.CStarAlgebra.Unitization
import Mathlib.Analysis.CStarAlgebra.Classes
import Mathlib.Analysis.SpecialFunctions.Pow.NNReal
/-!
# Multiplier Algebra of a C⋆-algebra
Define the multiplier algebra of a C⋆-algebra as the algebra (over `𝕜`) of double centralizers,
for which we provide the localized notation `𝓜(𝕜, A)`. A double centralizer is a pair of
continuous linear maps `L R : A →L[𝕜] A` satisfying the intertwining condition `R x * y = x * L y`.
There is a natural embedding `A → 𝓜(𝕜, A)` which sends `a : A` to the continuous linear maps
`L R : A →L[𝕜] A` given by left and right multiplication by `a`, and we provide this map as a
coercion.
The multiplier algebra corresponds to a non-commutative Stone–Čech compactification in the sense
that when the algebra `A` is commutative, it can be identified with `C₀(X, ℂ)` for some locally
compact Hausdorff space `X`, and in that case `𝓜(𝕜, A)` can be identified with `C(β X, ℂ)`.
## Implementation notes
We make the hypotheses on `𝕜` as weak as possible so that, in particular, this construction works
for both `𝕜 = ℝ` and `𝕜 = ℂ`.
The reader familiar with C⋆-algebra theory may recognize that one
only needs `L` and `R` to be functions instead of continuous linear maps, at least when `A` is a
C⋆-algebra. Our intention is simply to eventually provide a constructor for this situation.
We pull back the `NormedAlgebra` structure (and everything contained therein) through the
ring (even algebra) homomorphism
`DoubleCentralizer.toProdMulOppositeHom : 𝓜(𝕜, A) →+* (A →L[𝕜] A) × (A →L[𝕜] A)ᵐᵒᵖ` which
sends `a : 𝓜(𝕜, A)` to `(a.fst, MulOpposite.op a.snd)`. The star structure is provided
separately.
## References
* https://en.wikipedia.org/wiki/Multiplier_algebra
## TODO
+ Define a type synonym for `𝓜(𝕜, A)` which is equipped with the strict uniform space structure
and show it is complete
+ Show that the image of `A` in `𝓜(𝕜, A)` is an essential ideal
+ Prove the universal property of `𝓜(𝕜, A)`
+ Construct a double centralizer from a pair of maps (not necessarily linear or continuous)
`L : A → A`, `R : A → A` satisfying the centrality condition `∀ x y, R x * y = x * L y`.
+ Show that if `A` is unital, then `A ≃⋆ₐ[𝕜] 𝓜(𝕜, A)`.
-/
open NNReal ENNReal ContinuousLinearMap MulOpposite
universe u v
/-- The type of *double centralizers*, also known as the *multiplier algebra* and denoted by
`𝓜(𝕜, A)`, of a non-unital normed algebra.
If `x : 𝓜(𝕜, A)`, then `x.fst` and `x.snd` are what is usually referred to as $L$ and $R$. -/
structure DoubleCentralizer (𝕜 : Type u) (A : Type v) [NontriviallyNormedField 𝕜]
[NonUnitalNormedRing A] [NormedSpace 𝕜 A] [SMulCommClass 𝕜 A A] [IsScalarTower 𝕜 A A] extends
(A →L[𝕜] A) × (A →L[𝕜] A) where
/-- The centrality condition that the maps linear maps intertwine one another. -/
central : ∀ x y : A, snd x * y = x * fst y
@[inherit_doc]
scoped[MultiplierAlgebra] notation "𝓜(" 𝕜 ", " A ")" => DoubleCentralizer 𝕜 A
open MultiplierAlgebra
@[ext]
lemma DoubleCentralizer.ext (𝕜 : Type u) (A : Type v) [NontriviallyNormedField 𝕜]
[NonUnitalNormedRing A] [NormedSpace 𝕜 A] [SMulCommClass 𝕜 A A] [IsScalarTower 𝕜 A A]
(a b : 𝓜(𝕜, A)) (h : a.toProd = b.toProd) : a = b := by
cases a
cases b
simpa using h
namespace DoubleCentralizer
section NontriviallyNormed
variable (𝕜 A : Type*) [NontriviallyNormedField 𝕜] [NonUnitalNormedRing A]
variable [NormedSpace 𝕜 A] [SMulCommClass 𝕜 A A] [IsScalarTower 𝕜 A A]
/-!
### Algebraic structure
Because the multiplier algebra is defined as the algebra of double centralizers, there is a natural
injection `DoubleCentralizer.toProdMulOpposite : 𝓜(𝕜, A) → (A →L[𝕜] A) × (A →L[𝕜] A)ᵐᵒᵖ`
defined by `fun a ↦ (a.fst, MulOpposite.op a.snd)`. We use this map to pull back the ring, module
and algebra structure from `(A →L[𝕜] A) × (A →L[𝕜] A)ᵐᵒᵖ` to `𝓜(𝕜, A)`. -/
variable {𝕜 A}
theorem range_toProd :
Set.range toProd = { lr : (A →L[𝕜] A) × (A →L[𝕜] A) | ∀ x y, lr.2 x * y = x * lr.1 y } :=
Set.ext fun x =>
⟨by
rintro ⟨a, rfl⟩
exact a.central, fun hx => ⟨⟨x, hx⟩, rfl⟩⟩
instance instAdd : Add 𝓜(𝕜, A) where
add a b :=
{ toProd := a.toProd + b.toProd
central := fun x y =>
show (a.snd + b.snd) x * y = x * (a.fst + b.fst) y by
simp only [ContinuousLinearMap.add_apply, mul_add, add_mul, central] }
instance instZero : Zero 𝓜(𝕜, A) where
zero :=
{ toProd := 0
central := fun x y => (zero_mul y).trans (mul_zero x).symm }
instance instNeg : Neg 𝓜(𝕜, A) where
neg a :=
{ toProd := -a.toProd
central := fun x y =>
show -a.snd x * y = x * -a.fst y by
simp only [neg_mul, mul_neg, central] }
instance instSub : Sub 𝓜(𝕜, A) where
sub a b :=
{ toProd := a.toProd - b.toProd
central := fun x y =>
show (a.snd - b.snd) x * y = x * (a.fst - b.fst) y by
simp only [ContinuousLinearMap.sub_apply, _root_.sub_mul, _root_.mul_sub, central] }
section Scalars
variable {S : Type*} [Monoid S] [DistribMulAction S A] [SMulCommClass 𝕜 S A]
[ContinuousConstSMul S A] [IsScalarTower S A A] [SMulCommClass S A A]
instance instSMul : SMul S 𝓜(𝕜, A) where
smul s a :=
{ toProd := s • a.toProd
central := fun x y =>
show (s • a.snd) x * y = x * (s • a.fst) y by
simp only [ContinuousLinearMap.smul_apply, mul_smul_comm, smul_mul_assoc, central] }
@[simp]
theorem smul_toProd (s : S) (a : 𝓜(𝕜, A)) : (s • a).toProd = s • a.toProd :=
rfl
theorem smul_fst (s : S) (a : 𝓜(𝕜, A)) : (s • a).fst = s • a.fst :=
rfl
theorem smul_snd (s : S) (a : 𝓜(𝕜, A)) : (s • a).snd = s • a.snd :=
rfl
variable {T : Type*} [Monoid T] [DistribMulAction T A] [SMulCommClass 𝕜 T A]
[ContinuousConstSMul T A] [IsScalarTower T A A] [SMulCommClass T A A]
instance instIsScalarTower [SMul S T] [IsScalarTower S T A] : IsScalarTower S T 𝓜(𝕜, A) where
smul_assoc _ _ a := ext (𝕜 := 𝕜) (A := A) _ _ <| smul_assoc _ _ a.toProd
instance instSMulCommClass [SMulCommClass S T A] : SMulCommClass S T 𝓜(𝕜, A) where
smul_comm _ _ a := ext (𝕜 := 𝕜) (A := A) _ _ <| smul_comm _ _ a.toProd
instance instIsCentralScalar {R : Type*} [Semiring R] [Module R A] [SMulCommClass 𝕜 R A]
[ContinuousConstSMul R A] [IsScalarTower R A A] [SMulCommClass R A A] [Module Rᵐᵒᵖ A]
[IsCentralScalar R A] : IsCentralScalar R 𝓜(𝕜, A) where
op_smul_eq_smul _ a := ext (𝕜 := 𝕜) (A := A) _ _ <| op_smul_eq_smul _ a.toProd
end Scalars
instance instOne : One 𝓜(𝕜, A) :=
⟨⟨1, fun _x _y => rfl⟩⟩
instance instMul : Mul 𝓜(𝕜, A) where
mul a b :=
{ toProd := (a.fst.comp b.fst, b.snd.comp a.snd)
central := fun x y => show b.snd (a.snd x) * y = x * a.fst (b.fst y) by simp only [central] }
instance instNatCast : NatCast 𝓜(𝕜, A) where
natCast n :=
⟨n, fun x y => by
rw [Prod.snd_natCast, Prod.fst_natCast]
simp only [← Nat.smul_one_eq_cast, smul_apply, one_apply, mul_smul_comm, smul_mul_assoc]⟩
instance instIntCast : IntCast 𝓜(𝕜, A) where
intCast n :=
⟨n, fun x y => by
rw [Prod.snd_intCast, Prod.fst_intCast]
simp only [← Int.smul_one_eq_cast, smul_apply, one_apply, mul_smul_comm, smul_mul_assoc]⟩
instance instPow : Pow 𝓜(𝕜, A) ℕ where
pow a n :=
⟨a.toProd ^ n, fun x y => by
induction n generalizing x y with
| zero => rfl
| succ k hk =>
rw [Prod.pow_snd, Prod.pow_fst] at hk ⊢
rw [pow_succ' a.snd, mul_apply, a.central, hk, pow_succ a.fst, mul_apply]⟩
instance instInhabited : Inhabited 𝓜(𝕜, A) :=
⟨0⟩
@[simp]
theorem add_toProd (a b : 𝓜(𝕜, A)) : (a + b).toProd = a.toProd + b.toProd :=
rfl
@[simp]
theorem zero_toProd : (0 : 𝓜(𝕜, A)).toProd = 0 :=
rfl
@[simp]
theorem neg_toProd (a : 𝓜(𝕜, A)) : (-a).toProd = -a.toProd :=
rfl
@[simp]
theorem sub_toProd (a b : 𝓜(𝕜, A)) : (a - b).toProd = a.toProd - b.toProd :=
rfl
@[simp]
theorem one_toProd : (1 : 𝓜(𝕜, A)).toProd = 1 :=
rfl
@[simp]
theorem natCast_toProd (n : ℕ) : (n : 𝓜(𝕜, A)).toProd = n :=
rfl
@[simp]
theorem intCast_toProd (n : ℤ) : (n : 𝓜(𝕜, A)).toProd = n :=
rfl
@[simp]
theorem pow_toProd (n : ℕ) (a : 𝓜(𝕜, A)) : (a ^ n).toProd = a.toProd ^ n :=
rfl
theorem add_fst (a b : 𝓜(𝕜, A)) : (a + b).fst = a.fst + b.fst :=
rfl
theorem add_snd (a b : 𝓜(𝕜, A)) : (a + b).snd = a.snd + b.snd :=
rfl
theorem zero_fst : (0 : 𝓜(𝕜, A)).fst = 0 :=
rfl
theorem zero_snd : (0 : 𝓜(𝕜, A)).snd = 0 :=
rfl
theorem neg_fst (a : 𝓜(𝕜, A)) : (-a).fst = -a.fst :=
rfl
theorem neg_snd (a : 𝓜(𝕜, A)) : (-a).snd = -a.snd :=
rfl
theorem sub_fst (a b : 𝓜(𝕜, A)) : (a - b).fst = a.fst - b.fst :=
rfl
theorem sub_snd (a b : 𝓜(𝕜, A)) : (a - b).snd = a.snd - b.snd :=
rfl
theorem one_fst : (1 : 𝓜(𝕜, A)).fst = 1 :=
rfl
theorem one_snd : (1 : 𝓜(𝕜, A)).snd = 1 :=
rfl
@[simp]
theorem mul_fst (a b : 𝓜(𝕜, A)) : (a * b).fst = a.fst * b.fst :=
rfl
@[simp]
theorem mul_snd (a b : 𝓜(𝕜, A)) : (a * b).snd = b.snd * a.snd :=
rfl
theorem natCast_fst (n : ℕ) : (n : 𝓜(𝕜, A)).fst = n :=
rfl
theorem natCast_snd (n : ℕ) : (n : 𝓜(𝕜, A)).snd = n :=
rfl
theorem intCast_fst (n : ℤ) : (n : 𝓜(𝕜, A)).fst = n :=
rfl
theorem intCast_snd (n : ℤ) : (n : 𝓜(𝕜, A)).snd = n :=
rfl
theorem pow_fst (n : ℕ) (a : 𝓜(𝕜, A)) : (a ^ n).fst = a.fst ^ n :=
rfl
theorem pow_snd (n : ℕ) (a : 𝓜(𝕜, A)) : (a ^ n).snd = a.snd ^ n :=
rfl
/-- The natural injection from `DoubleCentralizer.toProd` except the second coordinate inherits
`MulOpposite.op`. The ring structure on `𝓜(𝕜, A)` is the pullback under this map. -/
def toProdMulOpposite : 𝓜(𝕜, A) → (A →L[𝕜] A) × (A →L[𝕜] A)ᵐᵒᵖ := fun a =>
(a.fst, MulOpposite.op a.snd)
theorem toProdMulOpposite_injective :
Function.Injective (toProdMulOpposite : 𝓜(𝕜, A) → (A →L[𝕜] A) × (A →L[𝕜] A)ᵐᵒᵖ) :=
fun _a _b h =>
let h' := Prod.ext_iff.mp h
ext (𝕜 := 𝕜) (A := A) _ _ <| Prod.ext h'.1 <| MulOpposite.op_injective h'.2
theorem range_toProdMulOpposite :
Set.range toProdMulOpposite =
{ lr : (A →L[𝕜] A) × (A →L[𝕜] A)ᵐᵒᵖ | ∀ x y, unop lr.2 x * y = x * lr.1 y } :=
Set.ext fun x =>
⟨by
rintro ⟨a, rfl⟩
exact a.central, fun hx => ⟨⟨(x.1, unop x.2), hx⟩, Prod.ext rfl rfl⟩⟩
/-- The ring structure is inherited as the pullback under the injective map
`DoubleCentralizer.toProdMulOpposite : 𝓜(𝕜, A) → (A →L[𝕜] A) × (A →L[𝕜] A)ᵐᵒᵖ` -/
instance instRing : Ring 𝓜(𝕜, A) :=
toProdMulOpposite_injective.ring _ rfl rfl (fun _ _ => rfl) (fun _ _ => rfl) (fun _ => rfl)
(fun _ _ => rfl) (fun _x _n => Prod.ext rfl <| MulOpposite.op_smul _ _)
(fun _x _n => Prod.ext rfl <| MulOpposite.op_smul _ _)
(fun _x _n => Prod.ext rfl <| MulOpposite.op_pow _ _) (fun _ => rfl) fun _ => rfl
/-- The canonical map `DoubleCentralizer.toProd` as an additive group homomorphism. -/
@[simps]
noncomputable def toProdHom : 𝓜(𝕜, A) →+ (A →L[𝕜] A) × (A →L[𝕜] A) where
toFun := toProd
map_zero' := rfl
map_add' _x _y := rfl
/-- The canonical map `DoubleCentralizer.toProdMulOpposite` as a ring homomorphism. -/
@[simps]
def toProdMulOppositeHom : 𝓜(𝕜, A) →+* (A →L[𝕜] A) × (A →L[𝕜] A)ᵐᵒᵖ where
toFun := toProdMulOpposite
map_zero' := rfl
map_one' := rfl
map_add' _x _y := rfl
map_mul' _x _y := rfl
/-- The module structure is inherited as the pullback under the additive group monomorphism
`DoubleCentralizer.toProd : 𝓜(𝕜, A) →+ (A →L[𝕜] A) × (A →L[𝕜] A)` -/
noncomputable instance instModule {S : Type*} [Semiring S] [Module S A] [SMulCommClass 𝕜 S A]
[ContinuousConstSMul S A] [IsScalarTower S A A] [SMulCommClass S A A] : Module S 𝓜(𝕜, A) :=
Function.Injective.module S toProdHom (ext (𝕜 := 𝕜) (A := A)) fun _x _y => rfl
-- TODO: generalize to `Algebra S 𝓜(𝕜, A)` once `ContinuousLinearMap.algebra` is generalized.
instance instAlgebra : Algebra 𝕜 𝓜(𝕜, A) where
algebraMap :=
{ toFun k :=
{ toProd := algebraMap 𝕜 ((A →L[𝕜] A) × (A →L[𝕜] A)) k
central := fun x y => by
simp_rw [Prod.algebraMap_apply, Algebra.algebraMap_eq_smul_one, smul_apply, one_apply,
mul_smul_comm, smul_mul_assoc] }
map_one' := ext (𝕜 := 𝕜) (A := A) _ _ <| map_one <| algebraMap 𝕜 ((A →L[𝕜] A) × (A →L[𝕜] A))
map_mul' _ _ :=
ext (𝕜 := 𝕜) (A := A) _ _ <|
Prod.ext (map_mul (algebraMap 𝕜 (A →L[𝕜] A)) _ _)
((map_mul (algebraMap 𝕜 (A →L[𝕜] A)) _ _).trans (Algebra.commutes _ _))
map_zero' := ext (𝕜 := 𝕜) (A := A) _ _ <| map_zero <| algebraMap 𝕜 ((A →L[𝕜] A) × (A →L[𝕜] A))
map_add' _ _ := ext (𝕜 := 𝕜) (A := A) _ _ <|
map_add (algebraMap 𝕜 ((A →L[𝕜] A) × (A →L[𝕜] A))) _ _ }
commutes' _ _ := ext (𝕜 := 𝕜) (A := A) _ _ <|
Prod.ext (Algebra.commutes _ _) (Algebra.commutes _ _).symm
smul_def' _ _ := ext (𝕜 := 𝕜) (A := A) _ _ <|
Prod.ext (Algebra.smul_def _ _) ((Algebra.smul_def _ _).trans <| Algebra.commutes _ _)
@[simp]
theorem algebraMap_toProd (k : 𝕜) : (algebraMap 𝕜 𝓜(𝕜, A) k).toProd = algebraMap 𝕜 _ k :=
rfl
theorem algebraMap_fst (k : 𝕜) : (algebraMap 𝕜 𝓜(𝕜, A) k).fst = algebraMap 𝕜 _ k :=
rfl
theorem algebraMap_snd (k : 𝕜) : (algebraMap 𝕜 𝓜(𝕜, A) k).snd = algebraMap 𝕜 _ k :=
rfl
/-!
### Star structure
-/
section Star
variable [StarRing 𝕜] [StarRing A] [StarModule 𝕜 A] [NormedStarGroup A]
/-- The star operation on `a : 𝓜(𝕜, A)` is given by
`(star a).toProd = (star ∘ a.snd ∘ star, star ∘ a.fst ∘ star)`. -/
instance instStar : Star 𝓜(𝕜, A) where
star a :=
{ fst :=
(((starₗᵢ 𝕜 : A ≃ₗᵢ⋆[𝕜] A) : A →L⋆[𝕜] A).comp a.snd).comp
((starₗᵢ 𝕜 : A ≃ₗᵢ⋆[𝕜] A) : A →L⋆[𝕜] A)
snd :=
(((starₗᵢ 𝕜 : A ≃ₗᵢ⋆[𝕜] A) : A →L⋆[𝕜] A).comp a.fst).comp
((starₗᵢ 𝕜 : A ≃ₗᵢ⋆[𝕜] A) : A →L⋆[𝕜] A)
central := fun x y => by
simpa only [star_mul, star_star] using (congr_arg star (a.central (star y) (star x))).symm }
@[simp]
theorem star_fst (a : 𝓜(𝕜, A)) (b : A) : (star a).fst b = star (a.snd (star b)) :=
rfl
@[simp]
theorem star_snd (a : 𝓜(𝕜, A)) (b : A) : (star a).snd b = star (a.fst (star b)) :=
rfl
instance instStarAddMonoid : StarAddMonoid 𝓜(𝕜, A) :=
{ DoubleCentralizer.instStar with
star_involutive := fun x => by ext <;> simp only [star_fst, star_snd, star_star]
star_add := fun x y => by
ext <;>
simp only [star_fst, star_snd, add_fst, add_snd, ContinuousLinearMap.add_apply, star_add] }
instance instStarRing : StarRing 𝓜(𝕜, A) :=
{ DoubleCentralizer.instStarAddMonoid with
star_mul := fun a b => by
ext <;>
simp only [star_fst, star_snd, mul_fst, mul_snd, star_star, ContinuousLinearMap.coe_mul,
Function.comp_apply] }
instance instStarModule : StarModule 𝕜 𝓜(𝕜, A) :=
{ DoubleCentralizer.instStarAddMonoid (𝕜 := 𝕜) (A := A) with
star_smul := fun k a => by ext <;> exact star_smul _ _ }
end Star
/-!
### Coercion from an algebra into its multiplier algebra
-/
variable (𝕜) in
/-- The natural coercion of `A` into `𝓜(𝕜, A)` given by sending `a : A` to the pair of linear
maps `Lₐ Rₐ : A →L[𝕜] A` given by left- and right-multiplication by `a`, respectively.
Warning: if `A = 𝕜`, then this is a coercion which is not definitionally equal to the
`algebraMap 𝕜 𝓜(𝕜, 𝕜)` coercion, but these are propositionally equal. See
`DoubleCentralizer.coe_eq_algebraMap` below. -/
@[coe]
protected noncomputable def coe (a : A) : 𝓜(𝕜, A) :=
{ fst := ContinuousLinearMap.mul 𝕜 A a
snd := (ContinuousLinearMap.mul 𝕜 A).flip a
central := fun _x _y => mul_assoc _ _ _ }
/-- The natural coercion of `A` into `𝓜(𝕜, A)` given by sending `a : A` to the pair of linear
maps `Lₐ Rₐ : A →L[𝕜] A` given by left- and right-multiplication by `a`, respectively.
Warning: if `A = 𝕜`, then this is a coercion which is not definitionally equal to the
`algebraMap 𝕜 𝓜(𝕜, 𝕜)` coercion, but these are propositionally equal. See
`DoubleCentralizer.coe_eq_algebraMap` below. -/
noncomputable instance : CoeTC A 𝓜(𝕜, A) where
coe := DoubleCentralizer.coe 𝕜
@[simp, norm_cast]
theorem coe_fst (a : A) : (a : 𝓜(𝕜, A)).fst = ContinuousLinearMap.mul 𝕜 A a :=
rfl
@[simp, norm_cast]
theorem coe_snd (a : A) : (a : 𝓜(𝕜, A)).snd = (ContinuousLinearMap.mul 𝕜 A).flip a :=
rfl
theorem coe_eq_algebraMap : (DoubleCentralizer.coe 𝕜 : 𝕜 → 𝓜(𝕜, 𝕜)) = algebraMap 𝕜 𝓜(𝕜, 𝕜) := by
ext x : 3
· rfl -- `fst` is defeq
· refine ContinuousLinearMap.ext fun y => ?_
exact mul_comm y x -- `snd` multiplies on the wrong side
/-- The coercion of an algebra into its multiplier algebra as a non-unital star algebra
homomorphism. -/
@[simps]
noncomputable def coeHom [StarRing 𝕜] [StarRing A] [StarModule 𝕜 A] [NormedStarGroup A] :
A →⋆ₙₐ[𝕜] 𝓜(𝕜, A) where
toFun a := a
map_smul' _ _ := ext _ _ _ _ <| Prod.ext (map_smul _ _ _) (map_smul _ _ _)
map_zero' := ext _ _ _ _ <| Prod.ext (map_zero _) (map_zero _)
map_add' _ _ := ext _ _ _ _ <| Prod.ext (map_add _ _ _) (map_add _ _ _)
map_mul' _ _ := ext _ _ _ _ <| Prod.ext
(ContinuousLinearMap.ext fun _ => (mul_assoc _ _ _))
(ContinuousLinearMap.ext fun _ => (mul_assoc _ _ _).symm)
map_star' _ := ext _ _ _ _ <| Prod.ext
(ContinuousLinearMap.ext fun _ => (star_star_mul _ _).symm)
(ContinuousLinearMap.ext fun _ => (star_mul_star _ _).symm)
/-!
### Norm structures
We define the norm structure on `𝓜(𝕜, A)` as the pullback under
`DoubleCentralizer.toProdMulOppositeHom : 𝓜(𝕜, A) →+* (A →L[𝕜] A) × (A →L[𝕜] A)ᵐᵒᵖ`, which
provides a definitional isometric embedding. Consequently, completeness of `𝓜(𝕜, A)` is obtained
by proving that the range of this map is closed.
In addition, we prove that `𝓜(𝕜, A)` is a normed algebra, and, when `A` is a C⋆-algebra, we show
that `𝓜(𝕜, A)` is also a C⋆-algebra. Moreover, in this case, for `a : 𝓜(𝕜, A)`,
`‖a‖ = ‖a.fst‖ = ‖a.snd‖`. -/
/-- The normed group structure is inherited as the pullback under the ring monomorphism
`DoubleCentralizer.toProdMulOppositeHom : 𝓜(𝕜, A) →+* (A →L[𝕜] A) × (A →L[𝕜] A)ᵐᵒᵖ`. -/
noncomputable instance : NormedRing 𝓜(𝕜, A) :=
NormedRing.induced _ _ (toProdMulOppositeHom : 𝓜(𝕜, A) →+* (A →L[𝕜] A) × (A →L[𝕜] A)ᵐᵒᵖ)
(by simpa using toProdMulOpposite_injective)
-- even though the definition is actually in terms of `DoubleCentralizer.toProdMulOpposite`, we
-- choose to see through that here to avoid `MulOpposite.op` appearing.
theorem norm_def (a : 𝓜(𝕜, A)) : ‖a‖ = ‖toProdHom a‖ :=
rfl
theorem nnnorm_def (a : 𝓜(𝕜, A)) : ‖a‖₊ = ‖toProdHom a‖₊ :=
rfl
theorem norm_def' (a : 𝓜(𝕜, A)) : ‖a‖ = ‖toProdMulOppositeHom a‖ :=
rfl
theorem nnnorm_def' (a : 𝓜(𝕜, A)) : ‖a‖₊ = ‖toProdMulOppositeHom a‖₊ :=
rfl
noncomputable instance instNormedSpace : NormedSpace 𝕜 𝓜(𝕜, A) :=
{ DoubleCentralizer.instModule with
norm_smul_le := fun k a => (norm_smul_le k a.toProdMulOpposite :) }
noncomputable instance instNormedAlgebra : NormedAlgebra 𝕜 𝓜(𝕜, A) :=
{ DoubleCentralizer.instAlgebra, DoubleCentralizer.instNormedSpace with }
theorem isUniformEmbedding_toProdMulOpposite :
IsUniformEmbedding (toProdMulOpposite (𝕜 := 𝕜) (A := A)) :=
isUniformEmbedding_comap toProdMulOpposite_injective
instance [CompleteSpace A] : CompleteSpace 𝓜(𝕜, A) := by
rw [completeSpace_iff_isComplete_range isUniformEmbedding_toProdMulOpposite.isUniformInducing]
apply IsClosed.isComplete
simp only [range_toProdMulOpposite, Set.setOf_forall]
refine isClosed_iInter fun x => isClosed_iInter fun y => isClosed_eq ?_ ?_
· exact
((ContinuousLinearMap.apply 𝕜 A _).continuous.comp <| continuous_unop.comp continuous_snd).mul
continuous_const
exact continuous_const.mul ((ContinuousLinearMap.apply 𝕜 A _).continuous.comp continuous_fst)
variable [StarRing A] [CStarRing A]
/-- For `a : 𝓜(𝕜, A)`, the norms of `a.fst` and `a.snd` coincide, and hence these
also coincide with `‖a‖` which is `max (‖a.fst‖) (‖a.snd‖)`. -/
theorem norm_fst_eq_snd (a : 𝓜(𝕜, A)) : ‖a.fst‖ = ‖a.snd‖ := by
-- a handy lemma for this proof
have h0 : ∀ f : A →L[𝕜] A, ∀ C : ℝ≥0, (∀ b : A, ‖f b‖₊ ^ 2 ≤ C * ‖f b‖₊ * ‖b‖₊) → ‖f‖₊ ≤ C := by
intro f C h
have h1 b : C * ‖f b‖₊ * ‖b‖₊ ≤ C * ‖f‖₊ * ‖b‖₊ ^ 2 := by grw [f.le_opNNNorm b]; ring_nf; rfl
have := NNReal.div_le_of_le_mul <| f.opNNNorm_le_bound _ <| by
simpa only [sqrt_sq, sqrt_mul] using fun b ↦ sqrt_le_sqrt.2 <| (h b).trans (h1 b)
convert NNReal.rpow_le_rpow this two_pos.le
· simp only [NNReal.rpow_two, div_pow, sq_sqrt]
simp only [sq, mul_self_div_self]
· simp only [NNReal.rpow_two, sq_sqrt]
have h1 : ∀ b, ‖a.fst b‖₊ ^ 2 ≤ ‖a.snd‖₊ * ‖a.fst b‖₊ * ‖b‖₊ := by
intro b
calc
‖a.fst b‖₊ ^ 2 = ‖star (a.fst b) * a.fst b‖₊ := by
simpa only [← sq] using CStarRing.nnnorm_star_mul_self.symm
_ ≤ ‖a.snd (star (a.fst b))‖₊ * ‖b‖₊ := (a.central (star (a.fst b)) b ▸ nnnorm_mul_le _ _)
_ ≤ ‖a.snd‖₊ * ‖a.fst b‖₊ * ‖b‖₊ :=
nnnorm_star (a.fst b) ▸ mul_le_mul_right' (a.snd.le_opNNNorm _) _
have h2 : ∀ b, ‖a.snd b‖₊ ^ 2 ≤ ‖a.fst‖₊ * ‖a.snd b‖₊ * ‖b‖₊ := by
intro b
calc
‖a.snd b‖₊ ^ 2 = ‖a.snd b * star (a.snd b)‖₊ := by
simpa only [← sq] using CStarRing.nnnorm_self_mul_star.symm
_ ≤ ‖b‖₊ * ‖a.fst (star (a.snd b))‖₊ :=
((a.central b (star (a.snd b))).symm ▸ nnnorm_mul_le _ _)
_ = ‖a.fst (star (a.snd b))‖₊ * ‖b‖₊ := mul_comm _ _
_ ≤ ‖a.fst‖₊ * ‖a.snd b‖₊ * ‖b‖₊ :=
nnnorm_star (a.snd b) ▸ mul_le_mul_right' (a.fst.le_opNNNorm _) _
exact le_antisymm (h0 _ _ h1) (h0 _ _ h2)
theorem nnnorm_fst_eq_snd (a : 𝓜(𝕜, A)) : ‖a.fst‖₊ = ‖a.snd‖₊ :=
Subtype.ext <| norm_fst_eq_snd a
@[simp]
theorem norm_fst (a : 𝓜(𝕜, A)) : ‖a.fst‖ = ‖a‖ := by
simp only [norm_def, toProdHom_apply, Prod.norm_def, norm_fst_eq_snd, max_eq_right le_rfl]
@[simp]
theorem norm_snd (a : 𝓜(𝕜, A)) : ‖a.snd‖ = ‖a‖ := by rw [← norm_fst, norm_fst_eq_snd]
@[simp]
theorem nnnorm_fst (a : 𝓜(𝕜, A)) : ‖a.fst‖₊ = ‖a‖₊ :=
Subtype.ext (norm_fst a)
@[simp]
theorem nnnorm_snd (a : 𝓜(𝕜, A)) : ‖a.snd‖₊ = ‖a‖₊ :=
Subtype.ext (norm_snd a)
end NontriviallyNormed
section DenselyNormed
variable {𝕜 A : Type*} [DenselyNormedField 𝕜] [StarRing 𝕜]
variable [NonUnitalNormedRing A] [StarRing A] [CStarRing A]
variable [NormedSpace 𝕜 A] [SMulCommClass 𝕜 A A] [IsScalarTower 𝕜 A A] [StarModule 𝕜 A]
instance instCStarRing : CStarRing 𝓜(𝕜, A) where
norm_mul_self_le := fun (a : 𝓜(𝕜, A)) => le_of_eq <| Eq.symm <| congr_arg ((↑) : ℝ≥0 → ℝ) <|
show ‖star a * a‖₊ = ‖a‖₊ * ‖a‖₊ by
/- The essence of the argument is this: let `a = (L,R)` and recall `‖a‖ = ‖L‖`.
`star a = (star ∘ R ∘ star, star ∘ L ∘ star)`. Then for any `x y : A`, we have
`‖star a * a‖ = ‖(star a * a).snd‖ = ‖R (star (L (star x))) * y‖ = ‖star (L (star x)) * L y‖`
Now, on the one hand,
`‖star (L (star x)) * L y‖ ≤ ‖star (L (star x))‖ * ‖L y‖ = ‖L (star x)‖ * ‖L y‖ ≤ ‖L‖ ^ 2`
whenever `‖x‖, ‖y‖ ≤ 1`, so the supremum over all such `x, y` is at most `‖L‖ ^ 2`.
On the other hand, for any `‖z‖ ≤ 1`, we may choose `x := star z` and `y := z` to get:
`‖star (L (star x)) * L y‖ = ‖star (L z) * (L z)‖ = ‖L z‖ ^ 2`, and taking the supremum over
all such `z` yields that the supremum is at least `‖L‖ ^ 2`. It is the latter part of the
argument where `DenselyNormedField 𝕜` is required (for `sSup_unitClosedBall_eq_nnnorm`). -/
have hball : (Metric.closedBall (0 : A) 1).Nonempty :=
Metric.nonempty_closedBall.2 zero_le_one
have key :
∀ x y, ‖x‖₊ ≤ 1 → ‖y‖₊ ≤ 1 → ‖a.snd (star (a.fst (star x))) * y‖₊ ≤ ‖a‖₊ * ‖a‖₊ := by
intro x y hx hy
rw [a.central]
calc
‖star (a.fst (star x)) * a.fst y‖₊ ≤ ‖a.fst (star x)‖₊ * ‖a.fst y‖₊ :=
nnnorm_star (a.fst (star x)) ▸ nnnorm_mul_le _ _
_ ≤ ‖a.fst‖₊ * 1 * (‖a.fst‖₊ * 1) :=
(mul_le_mul' (a.fst.le_opNorm_of_le ((nnnorm_star x).trans_le hx))
(a.fst.le_opNorm_of_le hy))
_ ≤ ‖a‖₊ * ‖a‖₊ := by simp only [mul_one, nnnorm_fst, le_rfl]
rw [← nnnorm_snd]
simp only [mul_snd, ← sSup_unitClosedBall_eq_nnnorm, star_snd, mul_apply]
simp only [← @opNNNorm_mul_apply 𝕜 _ A]
simp only [← sSup_unitClosedBall_eq_nnnorm, mul_apply']
refine csSup_eq_of_forall_le_of_forall_lt_exists_gt (hball.image _) ?_ fun r hr => ?_
· rintro - ⟨x, hx, rfl⟩
refine csSup_le (hball.image _) ?_
rintro - ⟨y, hy, rfl⟩
exact key x y (mem_closedBall_zero_iff.1 hx) (mem_closedBall_zero_iff.1 hy)
· simp only [Set.mem_image, exists_exists_and_eq_and]
have hr' : NNReal.sqrt r < ‖a‖₊ := ‖a‖₊.sqrt_mul_self ▸ NNReal.sqrt_lt_sqrt.2 hr
simp_rw [← nnnorm_fst, ← sSup_unitClosedBall_eq_nnnorm] at hr'
obtain ⟨_, ⟨x, hx, rfl⟩, hxr⟩ := exists_lt_of_lt_csSup (hball.image _) hr'
have hx' : ‖x‖₊ ≤ 1 := mem_closedBall_zero_iff.1 hx
refine ⟨star x, mem_closedBall_zero_iff.2 ((nnnorm_star x).trans_le hx'), ?_⟩
refine lt_csSup_of_lt ?_ ⟨x, hx, rfl⟩ ?_
· refine ⟨‖a‖₊ * ‖a‖₊, ?_⟩
rintro - ⟨y, hy, rfl⟩
exact key (star x) y ((nnnorm_star x).trans_le hx') (mem_closedBall_zero_iff.1 hy)
· simpa only [a.central, star_star, CStarRing.nnnorm_star_mul_self, NNReal.sq_sqrt, ← sq]
using pow_lt_pow_left₀ hxr zero_le' two_ne_zero
end DenselyNormed
noncomputable instance {A : Type*} [NonUnitalCStarAlgebra A] : CStarAlgebra 𝓜(ℂ, A) where
end DoubleCentralizer |
.lake/packages/mathlib/Mathlib/Analysis/CStarAlgebra/Unitization.lean | import Mathlib.Analysis.CStarAlgebra.Classes
import Mathlib.Analysis.Normed.Algebra.Unitization
/-! # The minimal unitization of a C⋆-algebra
This file shows that when `E` is a C⋆-algebra (over a densely normed field `𝕜`), that the minimal
`Unitization` is as well. In order to ensure that the norm structure is available, we must first
show that every C⋆-algebra is a `RegularNormedAlgebra`.
In addition, we show that in a `RegularNormedAlgebra` which is a `StarRing` for which the
involution is isometric, that multiplication on the right is also an isometry (i.e.,
`Isometry (ContinuousLinearMap.mul 𝕜 E).flip`).
-/
open ContinuousLinearMap
local postfix:max "⋆" => star
variable (𝕜 : Type*) {E : Type*}
namespace ContinuousLinearMap
variable [NontriviallyNormedField 𝕜] [NonUnitalNormedRing E] [StarRing E] [NormedStarGroup E]
variable [NormedSpace 𝕜 E] [IsScalarTower 𝕜 E E] [SMulCommClass 𝕜 E E] [RegularNormedAlgebra 𝕜 E]
lemma opNorm_mul_flip_apply (a : E) : ‖(mul 𝕜 E).flip a‖ = ‖a‖ := by
refine le_antisymm
(opNorm_le_bound _ (norm_nonneg _) fun b => by simpa only [mul_comm] using norm_mul_le b a) ?_
suffices ‖mul 𝕜 E (star a)‖ ≤ ‖(mul 𝕜 E).flip a‖ by
simpa only [ge_iff_le, opNorm_mul_apply, norm_star] using this
refine opNorm_le_bound _ (norm_nonneg _) fun b => ?_
calc ‖mul 𝕜 E (star a) b‖ = ‖(mul 𝕜 E).flip a (star b)‖ := by
simpa only [mul_apply', flip_apply, star_mul, star_star] using norm_star (star b * a)
_ ≤ ‖(mul 𝕜 E).flip a‖ * ‖b‖ := by
simpa only [flip_apply, mul_apply', norm_star] using le_opNorm ((mul 𝕜 E).flip a) (star b)
lemma opNNNorm_mul_flip_apply (a : E) : ‖(mul 𝕜 E).flip a‖₊ = ‖a‖₊ :=
Subtype.ext (opNorm_mul_flip_apply 𝕜 a)
variable (E)
lemma isometry_mul_flip : Isometry (mul 𝕜 E).flip :=
AddMonoidHomClass.isometry_of_norm _ (opNorm_mul_flip_apply 𝕜)
end ContinuousLinearMap
variable [DenselyNormedField 𝕜] [NonUnitalNormedRing E] [StarRing E] [CStarRing E]
variable [NormedSpace 𝕜 E] [IsScalarTower 𝕜 E E] [SMulCommClass 𝕜 E E]
variable (E)
/-- A C⋆-algebra over a densely normed field is a regular normed algebra. -/
instance CStarRing.instRegularNormedAlgebra : RegularNormedAlgebra 𝕜 E where
isometry_mul' := AddMonoidHomClass.isometry_of_norm (mul 𝕜 E) fun a => NNReal.eq_iff.mp <|
show ‖mul 𝕜 E a‖₊ = ‖a‖₊ by
rw [← sSup_unitClosedBall_eq_nnnorm]
refine csSup_eq_of_forall_le_of_forall_lt_exists_gt ?_ ?_ fun r hr => ?_
· exact (Metric.nonempty_closedBall.mpr zero_le_one).image _
· rintro - ⟨x, hx, rfl⟩
exact
((mul 𝕜 E a).unit_le_opNorm x <| mem_closedBall_zero_iff.mp hx).trans
(opNorm_mul_apply_le 𝕜 E a)
· have ha : 0 < ‖a‖₊ := zero_le'.trans_lt hr
rw [← inv_inv ‖a‖₊, NNReal.lt_inv_iff_mul_lt (inv_ne_zero ha.ne')] at hr
obtain ⟨k, hk₁, hk₂⟩ :=
NormedField.exists_lt_nnnorm_lt 𝕜 (mul_lt_mul_of_pos_right hr <| inv_pos.2 ha)
refine ⟨_, ⟨k • star a, ?_, rfl⟩, ?_⟩
· simpa only [mem_closedBall_zero_iff, norm_smul, one_mul, norm_star] using
(NNReal.le_inv_iff_mul_le ha.ne').1 (one_mul ‖a‖₊⁻¹ ▸ hk₂.le : ‖k‖₊ ≤ ‖a‖₊⁻¹)
· simp only [map_smul, nnnorm_smul, mul_apply', CStarRing.nnnorm_self_mul_star]
rwa [← div_lt_iff₀ (mul_pos ha ha), div_eq_mul_inv, mul_inv, ← mul_assoc]
section CStarProperty
variable [StarRing 𝕜] [StarModule 𝕜 E]
variable {E}
/-- This is the key lemma used to establish the instance `Unitization.instCStarRing`
(i.e., proving that the norm on `Unitization 𝕜 E` satisfies the C⋆-property). We split this one
out so that declaring the `CStarRing` instance doesn't time out. -/
theorem Unitization.norm_splitMul_snd_sq (x : Unitization 𝕜 E) :
‖(Unitization.splitMul 𝕜 E x).snd‖ ^ 2 ≤ ‖(Unitization.splitMul 𝕜 E (star x * x)).snd‖ := by
/- The key idea is that we can use `sSup_unitClosedBall_eq_norm` to make this about
applying this linear map to elements of norm at most one. There is a bit of `sqrt` and `sq`
shuffling that needs to occur, which is primarily just an annoyance. -/
refine (Real.le_sqrt (norm_nonneg _) (norm_nonneg _)).mp ?_
simp only [Unitization.splitMul_apply]
rw [← sSup_unitClosedBall_eq_norm]
refine csSup_le ((Metric.nonempty_closedBall.2 zero_le_one).image _) ?_
rintro - ⟨b, hb, rfl⟩
simp only
-- rewrite to a more convenient form; this is where we use the C⋆-property
rw [← Real.sqrt_sq (norm_nonneg _), Real.sqrt_le_sqrt_iff (norm_nonneg _), sq,
← CStarRing.norm_star_mul_self, ContinuousLinearMap.add_apply, star_add, mul_apply',
Algebra.algebraMap_eq_smul_one, ContinuousLinearMap.smul_apply,
ContinuousLinearMap.one_apply, star_mul, star_smul, add_mul, smul_mul_assoc, ← mul_smul_comm,
mul_assoc, ← mul_add, ← sSup_unitClosedBall_eq_norm]
refine (norm_mul_le _ _).trans ?_
calc
_ ≤ ‖star x.fst • (x.fst • b + x.snd * b) + star x.snd * (x.fst • b + x.snd * b)‖ := by
nth_rewrite 2 [← one_mul ‖_ + _‖]
gcongr
exact (norm_star b).symm ▸ mem_closedBall_zero_iff.1 hb
_ ≤ sSup (_ '' Metric.closedBall 0 1) := le_csSup ?_ ⟨b, hb, ?_⟩
-- now we just check the side conditions for `le_csSup`. There is nothing of interest here.
· refine ⟨‖(star x * x).fst‖ + ‖(star x * x).snd‖, ?_⟩
rintro _ ⟨y, hy, rfl⟩
refine (norm_add_le _ _).trans ?_
gcongr
· rw [Algebra.algebraMap_eq_smul_one]
refine (norm_smul _ _).trans_le ?_
simpa only [mul_one] using
mul_le_mul_of_nonneg_left (mem_closedBall_zero_iff.1 hy) (norm_nonneg (star x * x).fst)
· exact (unit_le_opNorm _ y <| mem_closedBall_zero_iff.1 hy).trans (opNorm_mul_apply_le _ _ _)
· simp only [ContinuousLinearMap.add_apply, mul_apply', Unitization.snd_star, Unitization.snd_mul,
Unitization.fst_mul, Unitization.fst_star, Algebra.algebraMap_eq_smul_one, smul_apply,
one_apply, smul_add, mul_add, add_mul]
simp only [smul_smul, smul_mul_assoc, ← add_assoc, ← mul_assoc, mul_smul_comm]
variable {𝕜}
variable [CStarRing 𝕜]
/-- The norm on `Unitization 𝕜 E` satisfies the C⋆-property -/
instance Unitization.instCStarRing : CStarRing (Unitization 𝕜 E) where
norm_mul_self_le x := by
-- rewrite both sides as a `⊔`
simp only [Unitization.norm_def, Prod.norm_def]
-- Show that `(Unitization.splitMul 𝕜 E x).snd` satisfies the C⋆-property, in two stages:
have h₁ : ∀ x : Unitization 𝕜 E,
‖(Unitization.splitMul 𝕜 E x).snd‖ ≤ ‖(Unitization.splitMul 𝕜 E (star x)).snd‖ := by
simp only [Unitization.splitMul_apply, Unitization.snd_star, Unitization.fst_star]
intro x
/- split based on whether the term inside the norm is zero or not. If so, it's trivial.
If not, then apply `norm_splitMul_snd_sq` and cancel one copy of the norm -/
by_cases h : algebraMap 𝕜 (E →L[𝕜] E) x.fst + mul 𝕜 E x.snd = 0
· simp only [h, norm_zero]
exact norm_nonneg _
· have : ‖(Unitization.splitMul 𝕜 E x).snd‖ ^ 2 ≤
‖(Unitization.splitMul 𝕜 E (star x)).snd‖ * ‖(Unitization.splitMul 𝕜 E x).snd‖ :=
(norm_splitMul_snd_sq 𝕜 x).trans <| by
rw [map_mul, Prod.snd_mul]
exact norm_mul_le _ _
rw [sq] at this
rw [← Ne, ← norm_pos_iff] at h
simp only [Unitization.splitMul_apply, Unitization.snd_star,
Unitization.fst_star] at this
exact (mul_le_mul_iff_left₀ h).mp this
-- in this step we make use of the key lemma `norm_splitMul_snd_sq`
have h₂ : ‖(Unitization.splitMul 𝕜 E (star x * x)).snd‖
= ‖(Unitization.splitMul 𝕜 E x).snd‖ ^ 2 := by
refine le_antisymm ?_ (norm_splitMul_snd_sq 𝕜 x)
rw [map_mul, Prod.snd_mul]
exact (norm_mul_le _ _).trans <| by
rw [sq]
gcongr
simpa only [star_star] using h₁ (star x)
-- Show that `(Unitization.splitMul 𝕜 E x).fst` satisfies the C⋆-property
have h₃ : ‖(Unitization.splitMul 𝕜 E (star x * x)).fst‖
= ‖(Unitization.splitMul 𝕜 E x).fst‖ ^ 2 := by
simp only [Unitization.splitMul_apply, Unitization.fst_mul, Unitization.fst_star,
norm_mul, norm_star, sq]
rw [h₂, h₃]
/- use the definition of the norm, and split into cases based on whether the norm in the first
coordinate is bigger or smaller than the norm in the second coordinate. -/
by_cases! h : ‖(Unitization.splitMul 𝕜 E x).fst‖ ≤ ‖(Unitization.splitMul 𝕜 E x).snd‖
· rw [sq, sq, sup_eq_right.mpr h, sup_eq_right.mpr (mul_self_le_mul_self (norm_nonneg _) h)]
· replace h := h.le
rw [sq, sq, sup_eq_left.mpr h, sup_eq_left.mpr (mul_self_le_mul_self (norm_nonneg _) h)]
/-- The minimal unitization (over `ℂ`) of a C⋆-algebra, equipped with the C⋆-norm. When `A` is
unital, `A⁺¹ ≃⋆ₐ[ℂ] (ℂ × A)`. -/
scoped[CStarAlgebra] postfix:max "⁺¹" => Unitization ℂ
noncomputable instance Unitization.instCStarAlgebra {A : Type*} [NonUnitalCStarAlgebra A] :
CStarAlgebra (Unitization ℂ A) where
noncomputable instance Unitization.instCommCStarAlgebra {A : Type*} [NonUnitalCommCStarAlgebra A] :
CommCStarAlgebra (Unitization ℂ A) where
end CStarProperty |
.lake/packages/mathlib/Mathlib/Analysis/CStarAlgebra/Classes.lean | import Mathlib.Analysis.Complex.Basic
import Mathlib.Topology.Algebra.NonUnitalStarAlgebra
import Mathlib.Topology.Algebra.StarSubalgebra
/-! # Classes of C⋆-algebras
This file defines classes for complex C⋆-algebras. These are (unital or non-unital, commutative or
noncommutative) Banach algebra over `ℂ` with an antimultiplicative conjugate-linear involution
(`star`) satisfying the C⋆-identity `∥star x * x∥ = ∥x∥ ^ 2`.
## Notes
These classes are not defined in `Mathlib/Analysis/CStarAlgebra/Basic.lean` because they require
heavier imports.
-/
/-- The class of non-unital (complex) C⋆-algebras. -/
class NonUnitalCStarAlgebra (A : Type*) extends NonUnitalNormedRing A, StarRing A, CompleteSpace A,
CStarRing A, NormedSpace ℂ A, IsScalarTower ℂ A A, SMulCommClass ℂ A A, StarModule ℂ A where
/-- The class of non-unital commutative (complex) C⋆-algebras. -/
class NonUnitalCommCStarAlgebra (A : Type*) extends
NonUnitalNormedCommRing A, NonUnitalCStarAlgebra A
/-- The class of unital (complex) C⋆-algebras. -/
class CStarAlgebra (A : Type*) extends NormedRing A, StarRing A, CompleteSpace A, CStarRing A,
NormedAlgebra ℂ A, StarModule ℂ A where
/-- The class of unital commutative (complex) C⋆-algebras. -/
class CommCStarAlgebra (A : Type*) extends NormedCommRing A, CStarAlgebra A
instance (priority := 100) CStarAlgebra.toNonUnitalCStarAlgebra (A : Type*) [CStarAlgebra A] :
NonUnitalCStarAlgebra A where
instance (priority := 100) CommCStarAlgebra.toNonUnitalCommCStarAlgebra (A : Type*)
[CommCStarAlgebra A] : NonUnitalCommCStarAlgebra A where
instance StarSubalgebra.cstarAlgebra {S A : Type*} [CStarAlgebra A]
[SetLike S A] [SubringClass S A] [SMulMemClass S ℂ A] [StarMemClass S A]
(s : S) [h_closed : IsClosed (s : Set A)] : CStarAlgebra s where
toCompleteSpace := h_closed.completeSpace_coe
norm_mul_self_le x := CStarRing.norm_star_mul_self (x := (x : A)) |>.symm.le
instance StarSubalgebra.commCStarAlgebra {S A : Type*} [CommCStarAlgebra A]
[SetLike S A] [SubringClass S A] [SMulMemClass S ℂ A] [StarMemClass S A]
(s : S) [h_closed : IsClosed (s : Set A)] : CommCStarAlgebra s where
toCompleteSpace := h_closed.completeSpace_coe
norm_mul_self_le x := CStarRing.norm_star_mul_self (x := (x : A)) |>.symm.le
mul_comm _ _ := Subtype.ext <| mul_comm _ _
instance NonUnitalStarSubalgebra.nonUnitalCStarAlgebra {S A : Type*}
[NonUnitalCStarAlgebra A] [SetLike S A] [NonUnitalSubringClass S A] [SMulMemClass S ℂ A]
[StarMemClass S A] (s : S) [h_closed : IsClosed (s : Set A)] : NonUnitalCStarAlgebra s where
toCompleteSpace := h_closed.completeSpace_coe
norm_mul_self_le x := CStarRing.norm_star_mul_self (x := (x : A)) |>.symm.le
instance NonUnitalStarSubalgebra.nonUnitalCommCStarAlgebra {S A : Type*}
[NonUnitalCommCStarAlgebra A] [SetLike S A] [NonUnitalSubringClass S A] [SMulMemClass S ℂ A]
[StarMemClass S A] (s : S) [h_closed : IsClosed (s : Set A)] : NonUnitalCommCStarAlgebra s where
toCompleteSpace := h_closed.completeSpace_coe
norm_mul_self_le x := CStarRing.norm_star_mul_self (x := (x : A)) |>.symm.le
mul_comm _ _ := Subtype.ext <| mul_comm _ _
noncomputable instance : CommCStarAlgebra ℂ where
section Elemental
variable {A : Type*}
noncomputable instance [CStarAlgebra A] (x : A) :
CStarAlgebra (StarAlgebra.elemental ℂ x) :=
StarSubalgebra.cstarAlgebra _ (h_closed := StarAlgebra.elemental.isClosed ℂ x)
noncomputable instance [NonUnitalCStarAlgebra A] (x : A) :
NonUnitalCStarAlgebra (NonUnitalStarAlgebra.elemental ℂ x) :=
NonUnitalStarSubalgebra.nonUnitalCStarAlgebra _
(h_closed := NonUnitalStarAlgebra.elemental.isClosed ℂ x)
noncomputable instance [CStarAlgebra A] (x : A) [IsStarNormal x] :
CommCStarAlgebra (StarAlgebra.elemental ℂ x) where
noncomputable instance [NonUnitalCStarAlgebra A] (x : A) [IsStarNormal x] :
NonUnitalCommCStarAlgebra (NonUnitalStarAlgebra.elemental ℂ x) where
end Elemental
section Pi
variable {ι : Type*} {A : ι → Type*} [Fintype ι]
instance [(i : ι) → NonUnitalCStarAlgebra (A i)] : NonUnitalCStarAlgebra (Π i, A i) where
instance [(i : ι) → NonUnitalCommCStarAlgebra (A i)] : NonUnitalCommCStarAlgebra (Π i, A i) where
instance [(i : ι) → CStarAlgebra (A i)] : CStarAlgebra (Π i, A i) where
instance [(i : ι) → CommCStarAlgebra (A i)] : CommCStarAlgebra (Π i, A i) where
end Pi
section Prod
variable {A B : Type*}
instance [NonUnitalCStarAlgebra A] [NonUnitalCStarAlgebra B] : NonUnitalCStarAlgebra (A × B) where
instance [NonUnitalCommCStarAlgebra A] [NonUnitalCommCStarAlgebra B] :
NonUnitalCommCStarAlgebra (A × B) where
instance [CStarAlgebra A] [CStarAlgebra B] : CStarAlgebra (A × B) where
instance [CommCStarAlgebra A] [CommCStarAlgebra B] : CommCStarAlgebra (A × B) where
end Prod
namespace MulOpposite
variable {A : Type*}
instance [NonUnitalCStarAlgebra A] : NonUnitalCStarAlgebra Aᵐᵒᵖ where
instance [NonUnitalCommCStarAlgebra A] : NonUnitalCommCStarAlgebra Aᵐᵒᵖ where
instance [CStarAlgebra A] : CStarAlgebra Aᵐᵒᵖ where
instance [CommCStarAlgebra A] : CommCStarAlgebra Aᵐᵒᵖ where
end MulOpposite |
.lake/packages/mathlib/Mathlib/Analysis/CStarAlgebra/GelfandDuality.lean | import Mathlib.Analysis.CStarAlgebra.Spectrum
import Mathlib.Analysis.CStarAlgebra.ContinuousMap
import Mathlib.Analysis.Normed.Group.Quotient
import Mathlib.Analysis.Normed.Algebra.Basic
import Mathlib.Topology.ContinuousMap.Units
import Mathlib.Topology.ContinuousMap.Compact
import Mathlib.Topology.Algebra.Algebra
import Mathlib.Topology.ContinuousMap.Ideals
import Mathlib.Topology.ContinuousMap.StoneWeierstrass
/-!
# Gelfand Duality
The `gelfandTransform` is an algebra homomorphism from a topological `𝕜`-algebra `A` to
`C(characterSpace 𝕜 A, 𝕜)`. In the case where `A` is a commutative complex Banach algebra, then
the Gelfand transform is actually spectrum-preserving (`spectrum.gelfandTransform_eq`). Moreover,
when `A` is a commutative C⋆-algebra over `ℂ`, then the Gelfand transform is a surjective isometry,
and even an equivalence between C⋆-algebras.
Consider the contravariant functors between compact Hausdorff spaces and commutative unital
C⋆algebras `F : Cpct → CommCStarAlg := X ↦ C(X, ℂ)` and
`G : CommCStarAlg → Cpct := A → characterSpace ℂ A` whose actions on morphisms are given by
`WeakDual.CharacterSpace.compContinuousMap` and `ContinuousMap.compStarAlgHom'`, respectively.
Then `η₁ : id → F ∘ G := gelfandStarTransform` and
`η₂ : id → G ∘ F := WeakDual.CharacterSpace.homeoEval` are the natural isomorphisms implementing
**Gelfand Duality**, i.e., the (contravariant) equivalence of these categories.
## Main definitions
* `Ideal.toCharacterSpace` : constructs an element of the character space from a maximal ideal in
a commutative complex Banach algebra
* `WeakDual.CharacterSpace.compContinuousMap`: The functorial map taking `ψ : A →⋆ₐ[𝕜] B` to a
continuous function `characterSpace 𝕜 B → characterSpace 𝕜 A` given by pre-composition with `ψ`.
## Main statements
* `spectrum.gelfandTransform_eq` : the Gelfand transform is spectrum-preserving when the algebra is
a commutative complex Banach algebra.
* `gelfandTransform_isometry` : the Gelfand transform is an isometry when the algebra is a
commutative (unital) C⋆-algebra over `ℂ`.
* `gelfandTransform_bijective` : the Gelfand transform is bijective when the algebra is a
commutative (unital) C⋆-algebra over `ℂ`.
* `gelfandStarTransform_naturality`: The `gelfandStarTransform` is a natural isomorphism
* `WeakDual.CharacterSpace.homeoEval_naturality`: This map implements a natural isomorphism
## TODO
* After defining the category of commutative unital C⋆-algebras, bundle the existing unbundled
**Gelfand duality** into an actual equivalence (duality) of categories associated to the
functors `C(·, ℂ)` and `characterSpace ℂ ·` and the natural isomorphisms `gelfandStarTransform`
and `WeakDual.CharacterSpace.homeoEval`.
## Tags
Gelfand transform, character space, C⋆-algebra
-/
open WeakDual
open scoped NNReal
section ComplexBanachAlgebra
open Ideal
variable {A : Type*} [NormedCommRing A] [NormedAlgebra ℂ A] [CompleteSpace A] (I : Ideal A)
[Ideal.IsMaximal I]
/-- Every maximal ideal in a commutative complex Banach algebra gives rise to a character on that
algebra. In particular, the character, which may be identified as an algebra homomorphism due to
`WeakDual.CharacterSpace.equivAlgHom`, is given by the composition of the quotient map and
the Gelfand-Mazur isomorphism `NormedRing.algEquivComplexOfComplete`. -/
noncomputable def Ideal.toCharacterSpace : characterSpace ℂ A :=
CharacterSpace.equivAlgHom.symm <|
((NormedRing.algEquivComplexOfComplete
(letI := Quotient.field I; isUnit_iff_ne_zero (G₀ := A ⧸ I))).symm : A ⧸ I →ₐ[ℂ] ℂ).comp <|
Quotient.mkₐ ℂ I
theorem Ideal.toCharacterSpace_apply_eq_zero_of_mem {a : A} (ha : a ∈ I) :
I.toCharacterSpace a = 0 := by
unfold Ideal.toCharacterSpace
simp only [CharacterSpace.equivAlgHom_symm_coe, AlgHom.coe_comp, AlgHom.coe_coe,
Quotient.mkₐ_eq_mk, Function.comp_apply, NormedRing.algEquivComplexOfComplete_symm_apply]
simp_rw [Quotient.eq_zero_iff_mem.mpr ha, spectrum.zero_eq]
exact Set.eq_of_mem_singleton (Set.singleton_nonempty (0 : ℂ)).some_mem
/-- If `a : A` is not a unit, then some character takes the value zero at `a`. This is equivalent
to `gelfandTransform ℂ A a` takes the value zero at some character. -/
theorem WeakDual.CharacterSpace.exists_apply_eq_zero {a : A} (ha : ¬IsUnit a) :
∃ f : characterSpace ℂ A, f a = 0 := by
obtain ⟨M, hM, haM⟩ := (span {a}).exists_le_maximal (span_singleton_ne_top ha)
exact
⟨M.toCharacterSpace,
M.toCharacterSpace_apply_eq_zero_of_mem
(haM (mem_span_singleton.mpr ⟨1, (mul_one a).symm⟩))⟩
theorem WeakDual.CharacterSpace.mem_spectrum_iff_exists {a : A} {z : ℂ} :
z ∈ spectrum ℂ a ↔ ∃ f : characterSpace ℂ A, f a = z := by
refine ⟨fun hz => ?_, ?_⟩
· obtain ⟨f, hf⟩ := WeakDual.CharacterSpace.exists_apply_eq_zero hz
simp only [map_sub, sub_eq_zero, AlgHomClass.commutes] at hf
exact ⟨_, hf.symm⟩
· rintro ⟨f, rfl⟩
exact AlgHom.apply_mem_spectrum f a
/-- The Gelfand transform is spectrum-preserving. -/
theorem spectrum.gelfandTransform_eq (a : A) :
spectrum ℂ (gelfandTransform ℂ A a) = spectrum ℂ a := by
ext z
rw [ContinuousMap.spectrum_eq_range, WeakDual.CharacterSpace.mem_spectrum_iff_exists]
exact Iff.rfl
instance [Nontrivial A] : Nonempty (characterSpace ℂ A) :=
⟨Classical.choose <|
WeakDual.CharacterSpace.exists_apply_eq_zero <| zero_mem_nonunits.2 zero_ne_one⟩
end ComplexBanachAlgebra
section ComplexCStarAlgebra
variable {A : Type*} [CommCStarAlgebra A]
theorem gelfandTransform_map_star (a : A) :
gelfandTransform ℂ A (star a) = star (gelfandTransform ℂ A a) :=
ContinuousMap.ext fun φ => map_star φ a
variable (A)
/-- The Gelfand transform is an isometry when the algebra is a C⋆-algebra over `ℂ`. -/
theorem gelfandTransform_isometry : Isometry (gelfandTransform ℂ A) := by
nontriviality A
refine AddMonoidHomClass.isometry_of_norm (gelfandTransform ℂ A) fun a => ?_
/- By `spectrum.gelfandTransform_eq`, the spectra of `star a * a` and its
`gelfandTransform` coincide. Therefore, so do their spectral radii, and since they are
self-adjoint, so also do their norms. Applying the C⋆-property of the norm and taking square
roots shows that the norm is preserved. -/
have : spectralRadius ℂ (gelfandTransform ℂ A (star a * a)) = spectralRadius ℂ (star a * a) := by
unfold spectralRadius; rw [spectrum.gelfandTransform_eq]
rw [map_mul, (IsSelfAdjoint.star_mul_self a).spectralRadius_eq_nnnorm, gelfandTransform_map_star,
(IsSelfAdjoint.star_mul_self (gelfandTransform ℂ A a)).spectralRadius_eq_nnnorm] at this
simp only [ENNReal.coe_inj, CStarRing.nnnorm_star_mul_self, ← sq] at this
simpa only [Function.comp_apply, NNReal.sqrt_sq] using
congr_arg (((↑) : ℝ≥0 → ℝ) ∘ ⇑NNReal.sqrt) this
/-- The Gelfand transform is bijective when the algebra is a C⋆-algebra over `ℂ`. -/
theorem gelfandTransform_bijective : Function.Bijective (gelfandTransform ℂ A) := by
refine ⟨(gelfandTransform_isometry A).injective, ?_⟩
/- The range of `gelfandTransform ℂ A` is actually a `StarSubalgebra`. The key lemma below may be
hard to spot; it's `map_star` coming from `WeakDual.Complex.instStarHomClass`, which is a
nontrivial result. -/
let rng : StarSubalgebra ℂ C(characterSpace ℂ A, ℂ) :=
{ toSubalgebra := (gelfandTransform ℂ A).range
star_mem' := by
rintro - ⟨a, rfl⟩
use star a
ext1 φ
dsimp
simp only [map_star, RCLike.star_def] }
suffices rng = ⊤ from
fun x => show x ∈ rng from this.symm ▸ StarSubalgebra.mem_top
/- Because the `gelfandTransform ℂ A` is an isometry, it has closed range, and so by the
Stone-Weierstrass theorem, it suffices to show that the image of the Gelfand transform separates
points in `C(characterSpace ℂ A, ℂ)` and is closed under `star`. -/
have h : rng.topologicalClosure = rng := le_antisymm
(StarSubalgebra.topologicalClosure_minimal le_rfl
(gelfandTransform_isometry A).isClosedEmbedding.isClosed_range)
(StarSubalgebra.le_topologicalClosure _)
refine h ▸ ContinuousMap.starSubalgebra_topologicalClosure_eq_top_of_separatesPoints
_ (fun _ _ => ?_)
/- Separating points just means that elements of the `characterSpace` which agree at all points
of `A` are the same functional, which is just extensionality. -/
contrapose!
exact fun h => Subtype.ext (ContinuousLinearMap.ext fun a =>
h (gelfandTransform ℂ A a) ⟨gelfandTransform ℂ A a, ⟨a, rfl⟩, rfl⟩)
/-- The Gelfand transform as a `StarAlgEquiv` between a commutative unital C⋆-algebra over `ℂ`
and the continuous functions on its `characterSpace`. -/
@[simps!]
noncomputable def gelfandStarTransform : A ≃⋆ₐ[ℂ] C(characterSpace ℂ A, ℂ) :=
StarAlgEquiv.ofBijective
(show A →⋆ₐ[ℂ] C(characterSpace ℂ A, ℂ) from
{ gelfandTransform ℂ A with map_star' := fun x => gelfandTransform_map_star x })
(gelfandTransform_bijective A)
end ComplexCStarAlgebra
section Functoriality
namespace WeakDual
namespace CharacterSpace
variable {A B C 𝕜 : Type*} [NontriviallyNormedField 𝕜]
variable [NormedRing A] [NormedAlgebra 𝕜 A] [CompleteSpace A] [StarRing A]
variable [NormedRing B] [NormedAlgebra 𝕜 B] [CompleteSpace B] [StarRing B]
variable [NormedRing C] [NormedAlgebra 𝕜 C] [CompleteSpace C] [StarRing C]
/-- The functorial map taking `ψ : A →⋆ₐ[ℂ] B` to a continuous function
`characterSpace ℂ B → characterSpace ℂ A` obtained by pre-composition with `ψ`. -/
@[simps]
noncomputable def compContinuousMap (ψ : A →⋆ₐ[𝕜] B) :
C(characterSpace 𝕜 B, characterSpace 𝕜 A) where
toFun φ := equivAlgHom.symm ((equivAlgHom φ).comp ψ.toAlgHom)
continuous_toFun :=
Continuous.subtype_mk
(continuous_of_continuous_eval fun a => map_continuous <| gelfandTransform 𝕜 B (ψ a)) _
variable (A) in
/-- `WeakDual.CharacterSpace.compContinuousMap` sends the identity to the identity. -/
@[simp]
theorem compContinuousMap_id :
compContinuousMap (StarAlgHom.id 𝕜 A) = ContinuousMap.id (characterSpace 𝕜 A) :=
ContinuousMap.ext fun _a => ext fun _x => rfl
/-- `WeakDual.CharacterSpace.compContinuousMap` is functorial. -/
@[simp]
theorem compContinuousMap_comp (ψ₂ : B →⋆ₐ[𝕜] C) (ψ₁ : A →⋆ₐ[𝕜] B) :
compContinuousMap (ψ₂.comp ψ₁) = (compContinuousMap ψ₁).comp (compContinuousMap ψ₂) :=
ContinuousMap.ext fun _a => ext fun _x => rfl
end CharacterSpace
end WeakDual
end Functoriality
open CharacterSpace in
/--
Consider the contravariant functors between compact Hausdorff spaces and commutative unital
C⋆algebras `F : Cpct → CommCStarAlg := X ↦ C(X, ℂ)` and
`G : CommCStarAlg → Cpct := A → characterSpace ℂ A` whose actions on morphisms are given by
`WeakDual.CharacterSpace.compContinuousMap` and `ContinuousMap.compStarAlgHom'`, respectively.
Then `η : id → F ∘ G := gelfandStarTransform` is a natural isomorphism implementing (half of)
the duality between these categories. That is, for commutative unital C⋆-algebras `A` and `B` and
`φ : A →⋆ₐ[ℂ] B` the following diagram commutes:
```
A --- η A ---> C(characterSpace ℂ A, ℂ)
| |
φ (F ∘ G) φ
| |
V V
B --- η B ---> C(characterSpace ℂ B, ℂ)
```
-/
theorem gelfandStarTransform_naturality {A B : Type*} [CommCStarAlgebra A] [CommCStarAlgebra B]
(φ : A →⋆ₐ[ℂ] B) :
(gelfandStarTransform B : _ →⋆ₐ[ℂ] _).comp φ =
(compContinuousMap φ |>.compStarAlgHom' ℂ ℂ).comp (gelfandStarTransform A : _ →⋆ₐ[ℂ] _) := by
rfl
/--
Consider the contravariant functors between compact Hausdorff spaces and commutative unital
C⋆algebras `F : Cpct → CommCStarAlg := X ↦ C(X, ℂ)` and
`G : CommCStarAlg → Cpct := A → characterSpace ℂ A` whose actions on morphisms are given by
`WeakDual.CharacterSpace.compContinuousMap` and `ContinuousMap.compStarAlgHom'`, respectively.
Then `η : id → G ∘ F := WeakDual.CharacterSpace.homeoEval` is a natural isomorphism implementing
(half of) the duality between these categories. That is, for compact Hausdorff spaces `X` and `Y`,
`f : C(X, Y)` the following diagram commutes:
```
X --- η X ---> characterSpace ℂ C(X, ℂ)
| |
f (G ∘ F) f
| |
V V
Y --- η Y ---> characterSpace ℂ C(Y, ℂ)
```
-/
lemma WeakDual.CharacterSpace.homeoEval_naturality {X Y 𝕜 : Type*} [RCLike 𝕜] [TopologicalSpace X]
[CompactSpace X] [T2Space X] [TopologicalSpace Y] [CompactSpace Y] [T2Space Y] (f : C(X, Y)) :
(homeoEval Y 𝕜 : C(_, _)).comp f =
(f.compStarAlgHom' 𝕜 𝕜 |> compContinuousMap).comp (homeoEval X 𝕜 : C(_, _)) :=
rfl |
.lake/packages/mathlib/Mathlib/Analysis/CStarAlgebra/CStarMatrix.lean | import Mathlib.Analysis.CStarAlgebra.Module.Constructions
import Mathlib.Analysis.Matrix.Normed
import Mathlib.Topology.UniformSpace.Matrix
/-!
# Matrices with entries in a C⋆-algebra
This file creates a type copy of `Matrix m n A` called `CStarMatrix m n A` meant for matrices with
entries in a C⋆-algebra `A`. Its action on `C⋆ᵐᵒᵈ (n → A)` (via `Matrix.mulVec`) gives
it the operator norm, and this norm makes `CStarMatrix n n A` a C⋆-algebra.
## Main declarations
+ `CStarMatrix m n A`: the type copy
+ `CStarMatrix.instNonUnitalCStarAlgebra`: square matrices with entries in a non-unital C⋆-algebra
form a non-unital C⋆-algebra
+ `CStarMatrix.instCStarAlgebra`: square matrices with entries in a unital C⋆-algebra form a
unital C⋆-algebra
## Implementation notes
The norm on this type induces the product uniformity and bornology, but these are not defeq to
`Pi.uniformSpace` and `Pi.instBornology`. Hence, we prove the equality to the Pi instances and
replace the uniformity and bornology by the Pi ones when registering the
`NormedAddCommGroup (CStarMatrix m n A)` instance. See the docstring of the `TopologyAux` section
below for more details.
-/
open scoped ComplexOrder Topology Uniformity Bornology Matrix NNReal InnerProductSpace
WithCStarModule
/-- Type copy `Matrix m n A` meant for matrices with entries in a C⋆-algebra. This is
a C⋆-algebra when `m = n`. -/
def CStarMatrix (m : Type*) (n : Type*) (A : Type*) := Matrix m n A
namespace CStarMatrix
variable {m n R S A B : Type*}
section basic
variable (m n A) in
/-- The equivalence between `Matrix m n A` and `CStarMatrix m n A`. -/
def ofMatrix {m n A : Type*} : Matrix m n A ≃ CStarMatrix m n A := Equiv.refl _
@[simp]
lemma ofMatrix_apply {M : Matrix m n A} {i : m} : (ofMatrix M) i = M i := rfl
@[simp]
lemma ofMatrix_symm_apply {M : CStarMatrix m n A} {i : m} : (ofMatrix.symm M) i = M i := rfl
theorem ext_iff {M N : CStarMatrix m n A} : (∀ i j, M i j = N i j) ↔ M = N :=
⟨fun h => funext fun i => funext <| h i, fun h => by simp [h]⟩
@[ext]
lemma ext {M₁ M₂ : CStarMatrix m n A} (h : ∀ i j, M₁ i j = M₂ i j) : M₁ = M₂ := ext_iff.mp h
/-- `M.map f` is the matrix obtained by applying `f` to each entry of the matrix `M`. -/
def map (M : CStarMatrix m n A) (f : A → B) : CStarMatrix m n B :=
ofMatrix fun i j => f (M i j)
@[simp]
theorem map_apply {M : CStarMatrix m n A} {f : A → B} {i : m} {j : n} : M.map f i j = f (M i j) :=
rfl
@[simp]
theorem map_id (M : CStarMatrix m n A) : M.map id = M := by
ext
rfl
@[simp]
theorem map_id' (M : CStarMatrix m n A) : M.map (·) = M := map_id M
theorem map_map {C : Type*} {M : Matrix m n A} {f : A → B} {g : B → C} :
(M.map f).map g = M.map (g ∘ f) := by ext; rfl
theorem map_injective {f : A → B} (hf : Function.Injective f) :
Function.Injective fun M : CStarMatrix m n A => M.map f := fun _ _ h =>
ext fun i j => hf <| ext_iff.mpr h i j
/-- The transpose of a matrix. -/
def transpose (M : CStarMatrix m n A) : CStarMatrix n m A :=
ofMatrix fun x y => M y x
@[simp]
theorem transpose_apply (M : CStarMatrix m n A) (i j) : transpose M i j = M j i :=
rfl
/-- The conjugate transpose of a matrix defined in term of `star`. -/
def conjTranspose [Star A] (M : CStarMatrix m n A) : CStarMatrix n m A :=
M.transpose.map star
@[simp]
theorem conjTranspose_apply [Star A] (M : CStarMatrix m n A) (i j) :
conjTranspose M i j = star (M j i) := rfl
instance instStar [Star A] : Star (CStarMatrix n n A) where
star M := M.conjTranspose
lemma star_eq_conjTranspose [Star A] {M : CStarMatrix n n A} : star M = M.conjTranspose := rfl
instance instInvolutiveStar [InvolutiveStar A] : InvolutiveStar (CStarMatrix n n A) where
star_involutive := star_involutive (R := Matrix n n A)
instance instInhabited [Inhabited A] : Inhabited (CStarMatrix m n A) :=
inferInstanceAs <| Inhabited <| m → n → A
instance instDecidableEq [DecidableEq A] [Fintype m] [Fintype n] :
DecidableEq (CStarMatrix m n A) :=
Fintype.decidablePiFintype
instance {n m} [Fintype m] [DecidableEq m] [Fintype n] [DecidableEq n] (α) [Fintype α] :
Fintype (CStarMatrix m n α) := inferInstanceAs (Fintype (m → n → α))
instance {n m} [Finite m] [Finite n] (α) [Finite α] :
Finite (CStarMatrix m n α) := inferInstanceAs (Finite (m → n → α))
instance instAdd [Add A] : Add (CStarMatrix m n A) :=
Pi.instAdd
instance instAddSemigroup [AddSemigroup A] : AddSemigroup (CStarMatrix m n A) :=
Pi.addSemigroup
instance instAddCommSemigroup [AddCommSemigroup A] : AddCommSemigroup (CStarMatrix m n A) :=
Pi.addCommSemigroup
instance instZero [Zero A] : Zero (CStarMatrix m n A) :=
Pi.instZero
instance instAddZeroClass [AddZeroClass A] : AddZeroClass (CStarMatrix m n A) :=
Pi.addZeroClass
instance instAddMonoid [AddMonoid A] : AddMonoid (CStarMatrix m n A) :=
Pi.addMonoid
instance instAddCommMonoid [AddCommMonoid A] : AddCommMonoid (CStarMatrix m n A) :=
Pi.addCommMonoid
instance instNeg [Neg A] : Neg (CStarMatrix m n A) :=
Pi.instNeg
instance instSub [Sub A] : Sub (CStarMatrix m n A) :=
Pi.instSub
instance instAddGroup [AddGroup A] : AddGroup (CStarMatrix m n A) :=
Pi.addGroup
instance instAddCommGroup [AddCommGroup A] : AddCommGroup (CStarMatrix m n A) :=
Pi.addCommGroup
instance instUnique [Unique A] : Unique (CStarMatrix m n A) :=
Pi.unique
instance instSubsingleton [Subsingleton A] : Subsingleton (CStarMatrix m n A) :=
inferInstanceAs <| Subsingleton <| m → n → A
instance instNontrivial [Nonempty m] [Nonempty n] [Nontrivial A] : Nontrivial (CStarMatrix m n A) :=
Function.nontrivial
instance instSMul [SMul R A] : SMul R (CStarMatrix m n A) :=
Pi.instSMul
instance instSMulCommClass [SMul R A] [SMul S A] [SMulCommClass R S A] :
SMulCommClass R S (CStarMatrix m n A) :=
Pi.smulCommClass
instance instIsScalarTower [SMul R S] [SMul R A] [SMul S A] [IsScalarTower R S A] :
IsScalarTower R S (CStarMatrix m n A) :=
Pi.isScalarTower
instance instIsCentralScalar [SMul R A] [SMul Rᵐᵒᵖ A] [IsCentralScalar R A] :
IsCentralScalar R (CStarMatrix m n A) :=
Pi.isCentralScalar
instance instMulAction [Monoid R] [MulAction R A] : MulAction R (CStarMatrix m n A) :=
Pi.mulAction _
instance instDistribMulAction [Monoid R] [AddMonoid A] [DistribMulAction R A] :
DistribMulAction R (CStarMatrix m n A) :=
Pi.distribMulAction _
instance instModule [Semiring R] [AddCommMonoid A] [Module R A] : Module R (CStarMatrix m n A) :=
Pi.module _ _ _
@[simp]
theorem zero_apply [Zero A] (i : m) (j : n) : (0 : CStarMatrix m n A) i j = 0 := rfl
@[simp] theorem add_apply [Add A] (M N : CStarMatrix m n A) (i : m) (j : n) :
(M + N) i j = (M i j) + (N i j) := rfl
@[simp] theorem smul_apply [SMul B A] (r : B) (M : CStarMatrix m n A) (i : m) (j : n) :
(r • M) i j = r • (M i j) := rfl
@[simp] theorem sub_apply [Sub A] (M N : CStarMatrix m n A) (i : m) (j : n) :
(M - N) i j = (M i j) - (N i j) := rfl
@[simp] theorem neg_apply [Neg A] (M : CStarMatrix m n A) (i : m) (j : n) :
(-M) i j = -(M i j) := rfl
@[simp]
theorem conjTranspose_zero [AddMonoid A] [StarAddMonoid A] :
conjTranspose (0 : CStarMatrix m n A) = 0 := by ext; simp
/-! simp-normal form pulls `of` to the outside, to match the `Matrix` API. -/
@[simp] theorem of_zero [Zero A] : ofMatrix (0 : Matrix m n A) = 0 := rfl
@[simp] theorem of_add_of [Add A] (f g : Matrix m n A) :
ofMatrix f + ofMatrix g = ofMatrix (f + g) := rfl
@[simp]
theorem of_sub_of [Sub A] (f g : Matrix m n A) : ofMatrix f - ofMatrix g = ofMatrix (f - g) :=
rfl
@[simp] theorem neg_of [Neg A] (f : Matrix m n A) : -ofMatrix f = ofMatrix (-f) := rfl
@[simp] theorem smul_of [SMul R A] (r : R) (f : Matrix m n A) :
r • ofMatrix f = ofMatrix (r • f) := rfl
theorem star_apply [Star A] {f : CStarMatrix n n A} {i j : n} :
(star f) i j = star (f j i) := by
rw [star_eq_conjTranspose, conjTranspose_apply]
theorem star_apply_of_isSelfAdjoint [Star A] {f : CStarMatrix n n A} (hf : IsSelfAdjoint f)
{i j : n} : star (f i j) = f j i := by
rw [← star_apply, IsSelfAdjoint.star_eq hf]
instance instStarAddMonoid [AddMonoid A] [StarAddMonoid A] : StarAddMonoid (CStarMatrix n n A) where
star_add := star_add (R := Matrix n n A)
instance instStarModule [Star R] [Star A] [SMul R A] [StarModule R A] :
StarModule R (CStarMatrix n n A) where
star_smul := star_smul (A := Matrix n n A)
/-- The equivalence to matrices, bundled as a linear equivalence. -/
def ofMatrixₗ [AddCommMonoid A] [Semiring R] [Module R A] :
(Matrix m n A) ≃ₗ[R] CStarMatrix m n A := LinearEquiv.refl _ _
/-- The semilinear map constructed by applying a semilinear map to all the entries of the matrix. -/
@[simps]
def mapₗ [Semiring R] [Semiring S] {σ : R →+* S} [AddCommMonoid A] [AddCommMonoid B]
[Module R A] [Module S B] (f : A →ₛₗ[σ] B) : CStarMatrix m n A →ₛₗ[σ] CStarMatrix m n B where
toFun := fun M => M.map f
map_add' M N := by ext; simp
map_smul' r M := by ext; simp
section zero_one
variable [Zero A] [One A] [DecidableEq n]
instance instOne : One (CStarMatrix n n A) := inferInstanceAs <| One (Matrix n n A)
theorem one_apply {i j} : (1 : CStarMatrix n n A) i j = if i = j then 1 else 0 := rfl
@[simp]
theorem one_apply_eq (i) : (1 : CStarMatrix n n A) i i = 1 := Matrix.one_apply_eq _
@[simp] theorem one_apply_ne {i j} : i ≠ j → (1 : CStarMatrix n n A) i j = 0 := Matrix.one_apply_ne
theorem one_apply_ne' {i j} : j ≠ i → (1 : CStarMatrix n n A) i j = 0 := Matrix.one_apply_ne'
instance instAddMonoidWithOne [AddMonoidWithOne A] : AddMonoidWithOne (CStarMatrix n n A) where
instance instAddGroupWithOne [AddGroupWithOne A] : AddGroupWithOne (CStarMatrix n n A) where
__ := instAddGroup
__ := instAddMonoidWithOne
instance instAddCommMonoidWithOne [AddCommMonoidWithOne A] :
AddCommMonoidWithOne (CStarMatrix n n A) where
__ := instAddCommMonoid
__ := instAddMonoidWithOne
instance instAddCommGroupWithOne [AddCommGroupWithOne A] :
AddCommGroupWithOne (CStarMatrix n n A) where
__ := instAddCommGroup
__ := instAddGroupWithOne
-- We want to be lower priority than `instHMul`, but without this we can't have operands with
-- implicit dimensions.
@[default_instance 100]
instance {l : Type*} [Fintype m] [Mul A] [AddCommMonoid A] :
HMul (CStarMatrix l m A) (CStarMatrix m n A) (CStarMatrix l n A) where
hMul M N := ofMatrix (ofMatrix.symm M * ofMatrix.symm N)
instance [Fintype n] [Mul A] [AddCommMonoid A] : Mul (CStarMatrix n n A) where mul M N := M * N
end zero_one
theorem mul_apply {l : Type*} [Fintype m] [Mul A] [AddCommMonoid A] {M : CStarMatrix l m A}
{N : CStarMatrix m n A} {i k} : (M * N) i k = ∑ j, M i j * N j k := rfl
theorem mul_apply' {l : Type*} [Fintype m] [Mul A] [AddCommMonoid A] {M : CStarMatrix l m A}
{N : CStarMatrix m n A} {i k} : (M * N) i k = (fun j => M i j) ⬝ᵥ fun j => N j k := rfl
@[simp]
theorem smul_mul {l : Type*} [Fintype n] [Monoid R] [AddCommMonoid A] [Mul A] [DistribMulAction R A]
[IsScalarTower R A A] (a : R) (M : CStarMatrix m n A) (N : CStarMatrix n l A) :
(a • M) * N = a • (M * N) := Matrix.smul_mul a M N
theorem mul_smul {l : Type*} [Fintype n] [Monoid R] [AddCommMonoid A] [Mul A] [DistribMulAction R A]
[SMulCommClass R A A] (M : CStarMatrix m n A) (a : R) (N : CStarMatrix n l A) :
M * (a • N) = a • (M * N) := Matrix.mul_smul M a N
@[simp]
protected theorem mul_zero {o : Type*} [Fintype n] [NonUnitalNonAssocSemiring A]
(M : CStarMatrix m n A) : M * (0 : CStarMatrix n o A) = 0 := Matrix.mul_zero _
@[simp]
protected theorem zero_mul {l : Type*} [Fintype m] [NonUnitalNonAssocSemiring A]
(M : CStarMatrix m n A) : (0 : CStarMatrix l m A) * M = 0 := Matrix.zero_mul _
protected theorem mul_add {o : Type*} [Fintype n] [NonUnitalNonAssocSemiring A]
(L : CStarMatrix m n A) (M N : CStarMatrix n o A) :
L * (M + N) = L * M + L * N := Matrix.mul_add _ _ _
protected theorem add_mul {l : Type*} [Fintype m] [NonUnitalNonAssocSemiring A]
(L M : CStarMatrix l m A) (N : CStarMatrix m n A) :
(L + M) * N = L * N + M * N := Matrix.add_mul _ _ _
instance instNonUnitalNonAssocSemiring [Fintype n] [NonUnitalNonAssocSemiring A] :
NonUnitalNonAssocSemiring (CStarMatrix n n A) :=
inferInstanceAs <| NonUnitalNonAssocSemiring (Matrix n n A)
instance instNonUnitalNonAssocRing [Fintype n] [NonUnitalNonAssocRing A] :
NonUnitalNonAssocRing (CStarMatrix n n A) :=
inferInstanceAs <| NonUnitalNonAssocRing (Matrix n n A)
instance instNonUnitalSemiring [Fintype n] [NonUnitalSemiring A] :
NonUnitalSemiring (CStarMatrix n n A) :=
inferInstanceAs <| NonUnitalSemiring (Matrix n n A)
instance instNonAssocSemiring [Fintype n] [DecidableEq n] [NonAssocSemiring A] :
NonAssocSemiring (CStarMatrix n n A) :=
inferInstanceAs <| NonAssocSemiring (Matrix n n A)
instance instNonUnitalRing [Fintype n] [NonUnitalRing A] :
NonUnitalRing (CStarMatrix n n A) :=
inferInstanceAs <| NonUnitalRing (Matrix n n A)
instance instNonAssocRing [Fintype n] [DecidableEq n] [NonAssocRing A] :
NonAssocRing (CStarMatrix n n A) :=
inferInstanceAs <| NonAssocRing (Matrix n n A)
instance instSemiring [Fintype n] [DecidableEq n] [Semiring A] :
Semiring (CStarMatrix n n A) :=
inferInstanceAs <| Semiring (Matrix n n A)
instance instRing [Fintype n] [DecidableEq n] [Ring A] : Ring (CStarMatrix n n A) :=
inferInstanceAs <| Ring (Matrix n n A)
/-- `ofMatrix` bundled as a ring equivalence. -/
def ofMatrixRingEquiv [Fintype n] [Semiring A] :
Matrix n n A ≃+* CStarMatrix n n A :=
{ ofMatrix with
map_mul' := fun _ _ => rfl
map_add' := fun _ _ => rfl }
instance instStarRing [Fintype n] [NonUnitalSemiring A] [StarRing A] :
StarRing (CStarMatrix n n A) := inferInstanceAs <| StarRing (Matrix n n A)
instance instAlgebra [Fintype n] [DecidableEq n] [CommSemiring R] [Semiring A] [Algebra R A] :
Algebra R (CStarMatrix n n A) := inferInstanceAs <| Algebra R (Matrix n n A)
/-- `ofMatrix` bundled as a star algebra equivalence. -/
def ofMatrixStarAlgEquiv [Fintype n] [SMul ℂ A] [Semiring A] [StarRing A] :
Matrix n n A ≃⋆ₐ[ℂ] CStarMatrix n n A :=
{ ofMatrixRingEquiv with
map_star' := fun _ => rfl
map_smul' := fun _ _ => rfl }
lemma ofMatrix_eq_ofMatrixStarAlgEquiv [Fintype n] [SMul ℂ A] [Semiring A] [StarRing A] :
(ofMatrix : Matrix n n A → CStarMatrix n n A)
= (ofMatrixStarAlgEquiv : Matrix n n A → CStarMatrix n n A) := rfl
variable (R) (A) in
/-- The natural map that reindexes a matrix's rows and columns with equivalent types is an
equivalence. -/
def reindexₗ {l o : Type*} [Semiring R] [AddCommMonoid A] [Module R A]
(eₘ : m ≃ l) (eₙ : n ≃ o) : CStarMatrix m n A ≃ₗ[R] CStarMatrix l o A :=
{ Matrix.reindex eₘ eₙ with
map_add' M N := by ext; simp
map_smul' r M := by ext; simp }
@[simp]
lemma reindexₗ_apply {l o : Type*} [Semiring R] [AddCommMonoid A] [Module R A]
{eₘ : m ≃ l} {eₙ : n ≃ o} {M : CStarMatrix m n A} {i : l} {j : o} :
reindexₗ R A eₘ eₙ M i j = Matrix.reindex eₘ eₙ M i j := rfl
/-- The natural map that reindexes a matrix's rows and columns with equivalent types is an
equivalence. -/
def reindexₐ (R) (A) [Fintype m] [Fintype n] [Semiring R] [AddCommMonoid A] [Mul A] [Module R A]
[Star A] (e : m ≃ n) : CStarMatrix m m A ≃⋆ₐ[R] CStarMatrix n n A :=
{ reindexₗ R A e e with
map_mul' M N := by
ext i j
simp only [mul_apply]
refine Fintype.sum_equiv e _ _ ?_
intro k
simp
map_star' M := by
ext
unfold reindexₗ
dsimp only [Equiv.toFun_as_coe, Equiv.invFun_as_coe, Matrix.reindex_symm, AddHom.toFun_eq_coe,
AddHom.coe_mk, Matrix.reindex_apply, Matrix.submatrix_apply]
rw [Matrix.star_apply, Matrix.star_apply]
simp [Matrix.submatrix_apply] }
@[simp]
lemma reindexₐ_apply [Fintype m] [Fintype n] [Semiring R] [AddCommMonoid A] [Mul A] [Star A]
[Module R A] {e : m ≃ n} {M : CStarMatrix m m A}
{i : n} {j : n} : reindexₐ R A e M i j = Matrix.reindex e e M i j := rfl
lemma mapₗ_reindexₐ [Fintype m] [Fintype n] [Semiring R] [AddCommMonoid A] [Mul A] [Module R A]
[Star A] [AddCommMonoid B] [Mul B] [Module R B] [Star B] {e : m ≃ n} {M : CStarMatrix m m A}
(φ : A →ₗ[R] B) : reindexₐ R B e (M.mapₗ φ) = ((reindexₐ R A e M).mapₗ φ) := rfl
@[simp]
lemma reindexₐ_symm [Fintype m] [Fintype n] [Semiring R] [AddCommMonoid A] [Mul A] [Module R A]
[Star A] {e : m ≃ n} : reindexₐ R A e.symm = (reindexₐ R A e).symm := by
simp [reindexₐ, reindexₗ]
/-- Applying a non-unital ⋆-algebra homomorphism to every entry of a matrix is itself a
⋆-algebra homomorphism on matrices. -/
@[simps]
def mapₙₐ [Fintype n] [Semiring R] [NonUnitalNonAssocSemiring A] [Module R A]
[Star A] [NonUnitalNonAssocSemiring B] [Module R B] [Star B] (f : A →⋆ₙₐ[R] B) :
CStarMatrix n n A →⋆ₙₐ[R] CStarMatrix n n B where
toFun := fun M => M.mapₗ (f : A →ₗ[R] B)
map_smul' := by simp
map_zero' := by simp [map_zero]
map_add' := by simp [map_add]
map_mul' M N := by
ext
-- Un-squeezing this `simp` seems to add about half a second elaboration time.
simp only [mapₗ_apply, map, LinearMap.coe_coe, ofMatrix_apply, mul_apply, map_sum, map_mul,
ofMatrix_apply]
map_star' M := by ext; simp [map, star_apply, map_star]
theorem algebraMap_apply [Fintype n] [DecidableEq n] [CommSemiring R] [Semiring A]
[Algebra R A] {r : R} {i j : n} :
(algebraMap R (CStarMatrix n n A) r) i j = if i = j then algebraMap R A r else 0 := rfl
variable (n) (R) (A) in
/-- The ⋆-algebra equivalence between `A` and 1×1 matrices with its entry in `A`. -/
def toOneByOne [Unique n] [Semiring R] [AddCommMonoid A] [Mul A] [Star A] [Module R A] :
A ≃⋆ₐ[R] CStarMatrix n n A where
toFun a := fun x y => a
invFun M := M default default
left_inv := by intro; simp
right_inv := by
intro
ext i j
simp [Subsingleton.elim i default, Subsingleton.elim j default]
map_mul' _ _ := by ext; simp [mul_apply]
map_add' _ _ := by ext; simp
map_star' _ := by ext; simp [star_eq_conjTranspose]
map_smul' _ _ := by ext; simp
end basic
variable [Fintype m] [NonUnitalCStarAlgebra A] [PartialOrder A] [StarOrderedRing A]
/-- Interpret a `CStarMatrix m n A` as a continuous linear map acting on `C⋆ᵐᵒᵈ (n → A)`. -/
noncomputable def toCLM : CStarMatrix m n A →ₗ[ℂ] C⋆ᵐᵒᵈ(A, m → A) →L[ℂ] C⋆ᵐᵒᵈ(A, n → A) where
toFun M := { toFun := (WithCStarModule.equivL ℂ).symm ∘ M.vecMul ∘ WithCStarModule.equivL ℂ
map_add' := M.add_vecMul
map_smul' := M.smul_vecMul
cont := Continuous.comp (by fun_prop) (by fun_prop) }
map_add' M₁ M₂ := by
ext
simp only [ContinuousLinearMap.coe_mk', LinearMap.coe_mk, AddHom.coe_mk, Function.comp_apply,
WithCStarModule.equivL_apply, WithCStarModule.equivL_symm_apply,
WithCStarModule.equiv_symm_pi_apply, ContinuousLinearMap.add_apply, WithCStarModule.add_apply]
rw [Matrix.vecMul_add, Pi.add_apply]
map_smul' c M := by
ext x i
simp only [ContinuousLinearMap.coe_mk', LinearMap.coe_mk, AddHom.coe_mk, Function.comp_apply,
WithCStarModule.equivL_apply, WithCStarModule.equivL_symm_apply,
WithCStarModule.equiv_symm_pi_apply, ContinuousLinearMap.smul_apply,
WithCStarModule.smul_apply, RingHom.id_apply]
rw [Matrix.vecMul_smul, Pi.smul_apply]
lemma toCLM_apply {M : CStarMatrix m n A} {v : C⋆ᵐᵒᵈ(A, m → A)} :
toCLM M v = (WithCStarModule.equiv _ _).symm (M.vecMul v) := rfl
lemma toCLM_apply_eq_sum {M : CStarMatrix m n A} {v : C⋆ᵐᵒᵈ(A, m → A)} :
toCLM M v = (WithCStarModule.equiv _ _).symm (fun j => ∑ i, v i * M i j) := by
ext i
simp [toCLM_apply, Matrix.vecMul, dotProduct]
/-- Interpret a `CStarMatrix m n A` as a continuous linear map acting on `C⋆ᵐᵒᵈ (n → A)`. This
version is specialized to the case `m = n` and is bundled as a non-unital algebra homomorphism. -/
noncomputable def toCLMNonUnitalAlgHom [Fintype n] :
CStarMatrix n n A →ₙₐ[ℂ] (C⋆ᵐᵒᵈ(A, n → A) →L[ℂ] C⋆ᵐᵒᵈ(A, n → A))ᵐᵒᵖ :=
{ (MulOpposite.opLinearEquiv ℂ).toLinearMap ∘ₗ (toCLM (n := n) (m := n)) with
map_zero' := by simp
map_mul' := by
intros
simp only [AddHom.toFun_eq_coe, LinearMap.coe_toAddHom, LinearMap.coe_comp,
LinearEquiv.coe_coe, MulOpposite.coe_opLinearEquiv, Function.comp_apply,
← MulOpposite.op_mul, MulOpposite.op_inj]
ext
simp [toCLM] }
lemma toCLMNonUnitalAlgHom_eq_toCLM [Fintype n] {M : CStarMatrix n n A} :
toCLMNonUnitalAlgHom (A := A) M = MulOpposite.op (toCLM M) := rfl
open WithCStarModule in
@[simp high]
lemma toCLM_apply_single [DecidableEq m] {M : CStarMatrix m n A} {i : m} (a : A) :
(toCLM M) (equiv _ _ |>.symm <| Pi.single i a) = (equiv _ _).symm (fun j => a * M i j) := by
ext
simp [toCLM_apply, equiv, Equiv.refl]
open WithCStarModule in
lemma toCLM_apply_single_apply [DecidableEq m] {M : CStarMatrix m n A} {i : m} {j : n} (a : A) :
(toCLM M) (equiv _ _ |>.symm <| Pi.single i a) j = a * M i j := by simp
open WithCStarModule in
lemma mul_entry_mul_eq_inner_toCLM [Fintype n] [DecidableEq m] [DecidableEq n]
{M : CStarMatrix m n A} {i : m} {j : n} (a b : A) :
a * M i j * star b
= ⟪equiv _ _ |>.symm (Pi.single j b), toCLM M (equiv _ _ |>.symm <| Pi.single i a)⟫_A := by
simp [mul_assoc, inner_def]
lemma toCLM_injective : Function.Injective (toCLM (A := A) (m := m) (n := n)) := by
classical
rw [injective_iff_map_eq_zero]
intro M h
ext i j
rw [Matrix.zero_apply, ← norm_eq_zero, ← sq_eq_zero_iff, sq, ← CStarRing.norm_star_mul_self,
← toCLM_apply_single_apply]
simp [h]
variable [Fintype n]
open WithCStarModule in
lemma inner_toCLM_conjTranspose_left {M : CStarMatrix m n A} {v : C⋆ᵐᵒᵈ(A, n → A)}
{w : C⋆ᵐᵒᵈ(A, m → A)} : ⟪toCLM Mᴴ v, w⟫_A = ⟪v, toCLM M w⟫_A := by
simp only [toCLM_apply_eq_sum, pi_inner, equiv_symm_pi_apply, inner_def, Finset.mul_sum,
Matrix.conjTranspose_apply, star_sum, star_mul, star_star, Finset.sum_mul]
rw [Finset.sum_comm]
simp_rw [mul_assoc]
lemma inner_toCLM_conjTranspose_right {M : CStarMatrix m n A} {v : C⋆ᵐᵒᵈ(A, m → A)}
{w : C⋆ᵐᵒᵈ(A, n → A)} : ⟪v, toCLM Mᴴ w⟫_A = ⟪toCLM M v, w⟫_A := by
apply Eq.symm
simpa using inner_toCLM_conjTranspose_left (M := Mᴴ) (v := v) (w := w)
/-- The operator norm on `CStarMatrix m n A`. -/
noncomputable instance instNorm : Norm (CStarMatrix m n A) where
norm M := ‖toCLM M‖
lemma norm_def {M : CStarMatrix m n A} : ‖M‖ = ‖toCLM M‖ := rfl
lemma norm_def' {M : CStarMatrix n n A} : ‖M‖ = ‖toCLMNonUnitalAlgHom (A := A) M‖ := rfl
lemma normedSpaceCore : NormedSpace.Core ℂ (CStarMatrix m n A) where
norm_nonneg M := (toCLM M).opNorm_nonneg
norm_smul c M := by rw [norm_def, norm_def, map_smul, norm_smul _ (toCLM M)]
norm_triangle M₁ M₂ := by simpa [← map_add] using norm_add_le (toCLM M₁) (toCLM M₂)
norm_eq_zero_iff := by
simpa only [norm_def, norm_eq_zero, ← injective_iff_map_eq_zero'] using toCLM_injective
open WithCStarModule in
lemma norm_entry_le_norm {M : CStarMatrix m n A} {i : m} {j : n} :
‖M i j‖ ≤ ‖M‖ := by
classical
suffices ‖M i j‖ * ‖M i j‖ ≤ ‖M‖ * ‖M i j‖ by
obtain (h | h) := eq_zero_or_norm_pos (M i j)
· simp [h, norm_def]
· exact le_of_mul_le_mul_right this h
rw [← CStarRing.norm_star_mul_self, ← toCLM_apply_single_apply]
apply norm_apply_le_norm _ _ |>.trans
apply (toCLM M).le_opNorm _ |>.trans
simp [norm_def]
open CStarModule in
lemma norm_le_of_forall_inner_le {M : CStarMatrix m n A} {C : ℝ≥0}
(h : ∀ v w, ‖⟪w, toCLM M v⟫_A‖ ≤ C * ‖v‖ * ‖w‖) : ‖M‖ ≤ C := by
refine (toCLM M).opNorm_le_bound (by simp) fun v ↦ ?_
obtain (h₀ | h₀) := (norm_nonneg (toCLM M v)).eq_or_lt
· rw [← h₀]
positivity
· refine le_of_mul_le_mul_right ?_ h₀
simpa [← sq, norm_sq_eq A] using h ..
end CStarMatrix
section TopologyAux
/-
## Replacing the uniformity and bornology
Note that while the norm that we have defined on `CStarMatrix m n A` induces the product uniformity,
it is not defeq to `Pi.uniformSpace`. In this section, we show that the norm indeed does induce
the product topology and use this fact to properly set up the
`NormedAddCommGroup (CStarMatrix m n A)` instance such that the uniformity is still
`Pi.uniformSpace` and the bornology is `Pi.instBornology`.
To do this, we locally register a `NormedAddCommGroup` instance on `CStarMatrix` which registers
the "bad" topology, and we also locally use the matrix norm `Matrix.normedAddCommGroup`
(which takes the norm of the biggest entry as the norm of the matrix)
in order to show that the map `ofMatrix` is bilipschitz. We then finally register the
`NormedAddCommGroup (C⋆ᵐᵒᵈ (n → A))` instance via `NormedAddCommGroup.ofCoreReplaceAll`.
-/
namespace CStarMatrix
variable {m n A : Type*} [Fintype m] [Fintype n]
[NonUnitalCStarAlgebra A] [PartialOrder A] [StarOrderedRing A]
private noncomputable def normedAddCommGroupAux : NormedAddCommGroup (CStarMatrix m n A) :=
.ofCore CStarMatrix.normedSpaceCore
attribute [local instance] normedAddCommGroupAux
private noncomputable def normedSpaceAux : NormedSpace ℂ (CStarMatrix m n A) :=
.ofCore CStarMatrix.normedSpaceCore
/- In this `Aux` section, we locally activate the following instances: a norm on `CStarMatrix`
which induces a topology that is not defeq with the matrix one, and the elementwise norm on
matrices, in order to show that the two topologies are in fact equal -/
open scoped Matrix.Norms.Elementwise
private lemma nnnorm_le_of_forall_inner_le {M : CStarMatrix m n A} {C : ℝ≥0}
(h : ∀ v w, ‖⟪w, CStarMatrix.toCLM M v⟫_A‖₊ ≤ C * ‖v‖₊ * ‖w‖₊) : ‖M‖₊ ≤ C :=
CStarMatrix.norm_le_of_forall_inner_le fun v w => h v w
open Finset in
private lemma lipschitzWith_toMatrixAux :
LipschitzWith 1 (ofMatrixₗ.symm (R := ℂ) : CStarMatrix m n A → Matrix m n A) := by
refine AddMonoidHomClass.lipschitz_of_bound_nnnorm _ _ fun M => ?_
rw [one_mul, ← NNReal.coe_le_coe, coe_nnnorm, coe_nnnorm, Matrix.norm_le_iff (norm_nonneg _)]
exact fun _ _ ↦ CStarMatrix.norm_entry_le_norm
open CStarMatrix WithCStarModule in
private lemma antilipschitzWith_toMatrixAux :
AntilipschitzWith (Fintype.card n * Fintype.card m)
(ofMatrixₗ.symm (R := ℂ) : CStarMatrix m n A → Matrix m n A) := by
refine AddMonoidHomClass.antilipschitz_of_bound _ fun M => ?_
calc
‖M‖ ≤ ∑ j, ∑ i, ‖M i j‖ := by
rw [norm_def]
refine (toCLM M).opNorm_le_bound (by positivity) fun v => ?_
simp only [toCLM_apply_eq_sum, Finset.sum_mul]
apply pi_norm_le_sum_norm _ |>.trans
gcongr with i _
apply norm_sum_le _ _ |>.trans
gcongr with j _
apply norm_mul_le _ _ |>.trans
rw [mul_comm]
gcongr
exact norm_apply_le_norm v j
_ ≤ ∑ _ : n, ∑ _ : m, ‖ofMatrixₗ.symm (R := ℂ) M‖ := by
gcongr with j _ i _
exact ofMatrixₗ.symm (R := ℂ) M |>.norm_entry_le_entrywise_sup_norm
_ = _ := by simp [mul_assoc]
private lemma uniformInducing_toMatrixAux :
IsUniformInducing (ofMatrix.symm : CStarMatrix m n A → Matrix m n A) :=
AntilipschitzWith.isUniformInducing antilipschitzWith_toMatrixAux
lipschitzWith_toMatrixAux.uniformContinuous
private lemma uniformity_eq_aux :
𝓤 (CStarMatrix m n A) = (𝓤[Pi.uniformSpace _] :
Filter (CStarMatrix m n A × CStarMatrix m n A)) := by
have :
(fun x : CStarMatrix m n A × CStarMatrix m n A => ⟨ofMatrix.symm x.1, ofMatrix.symm x.2⟩)
= id := by
ext i <;> rfl
rw [← uniformInducing_toMatrixAux.comap_uniformity, this, Filter.comap_id]
rfl
open Bornology in
private lemma cobounded_eq_aux :
cobounded (CStarMatrix m n A) = @cobounded _ Pi.instBornology := by
have : cobounded (CStarMatrix m n A) = Filter.comap ofMatrix.symm (cobounded _) := by
refine le_antisymm ?_ ?_
· exact antilipschitzWith_toMatrixAux.tendsto_cobounded.le_comap
· exact lipschitzWith_toMatrixAux.comap_cobounded_le
exact this.trans Filter.comap_id
end CStarMatrix
end TopologyAux
namespace CStarMatrix
section non_unital
variable {A : Type*} [NonUnitalCStarAlgebra A] [PartialOrder A] [StarOrderedRing A]
variable {m n : Type*} [Fintype m] [Fintype n]
instance instTopologicalSpace : TopologicalSpace (CStarMatrix m n A) := Pi.topologicalSpace
instance instUniformSpace : UniformSpace (CStarMatrix m n A) := Pi.uniformSpace _
instance instBornology : Bornology (CStarMatrix m n A) := Pi.instBornology
instance instCompleteSpace : CompleteSpace (CStarMatrix m n A) := Pi.complete _
instance instT2Space : T2Space (CStarMatrix m n A) := Pi.t2Space
instance instT3Space : T3Space (CStarMatrix m n A) := _root_.instT3Space
instance instIsTopologicalAddGroup : IsTopologicalAddGroup (CStarMatrix m n A) :=
Pi.topologicalAddGroup
instance instIsUniformAddGroup : IsUniformAddGroup (CStarMatrix m n A) :=
Pi.instIsUniformAddGroup
instance instContinuousSMul {R : Type*} [SMul R A] [TopologicalSpace R] [ContinuousSMul R A] :
ContinuousSMul R (CStarMatrix m n A) := instContinuousSMulForall
noncomputable instance instNormedAddCommGroup :
NormedAddCommGroup (CStarMatrix m n A) :=
.ofCoreReplaceAll CStarMatrix.normedSpaceCore
CStarMatrix.uniformity_eq_aux.symm
fun _ => Filter.ext_iff.1 CStarMatrix.cobounded_eq_aux.symm _
noncomputable instance instNormedSpace : NormedSpace ℂ (CStarMatrix m n A) :=
.ofCore CStarMatrix.normedSpaceCore
noncomputable instance instNonUnitalNormedRing :
NonUnitalNormedRing (CStarMatrix n n A) where
__ : NormedAddCommGroup (CStarMatrix n n A) := inferInstance
__ : NonUnitalRing (CStarMatrix n n A) := inferInstance
norm_mul_le _ _ := by simpa only [norm_def', map_mul] using norm_mul_le _ _
open ContinuousLinearMap CStarModule in
/-- Matrices with entries in a C⋆-algebra form a C⋆-algebra. -/
instance instCStarRing : CStarRing (CStarMatrix n n A) :=
.of_le_norm_mul_star_self fun M ↦ by
have hmain : ‖M‖ ≤ √‖M * star M‖ := by
change ‖toCLM M‖ ≤ √‖M * star M‖
rw [opNorm_le_iff (by positivity)]
intro v
rw [norm_eq_sqrt_norm_inner_self (A := A), ← inner_toCLM_conjTranspose_right]
have h₁ : ‖⟪v, (toCLM Mᴴ) ((toCLM M) v)⟫_A‖ ≤ ‖M * star M‖ * ‖v‖ ^ 2 := calc
_ ≤ ‖v‖ * ‖(toCLM Mᴴ) (toCLM M v)‖ := norm_inner_le (C⋆ᵐᵒᵈ(A, n → A))
_ ≤ ‖v‖ * ‖(toCLM Mᴴ).comp (toCLM M)‖ * ‖v‖ := by
rw [mul_assoc]
gcongr
rw [← ContinuousLinearMap.comp_apply]
exact le_opNorm ((toCLM Mᴴ).comp (toCLM M)) v
_ = ‖(toCLM Mᴴ).comp (toCLM M)‖ * ‖v‖ ^ 2 := by ring
_ = ‖M * star M‖ * ‖v‖ ^ 2 := by
congr
apply MulOpposite.op_injective
simp only [← toCLMNonUnitalAlgHom_eq_toCLM, map_mul]
rfl
have h₂ : ‖v‖ = √(‖v‖ ^ 2) := by simp
rw [h₂, ← Real.sqrt_mul]
· gcongr
positivity
rw [← Real.sqrt_le_sqrt_iff (by positivity)]
simp [hmain]
/-- Matrices with entries in a non-unital C⋆-algebra form a non-unital C⋆-algebra. -/
noncomputable instance instNonUnitalCStarAlgebra :
NonUnitalCStarAlgebra (CStarMatrix n n A) where
smul_assoc x y z := by simp
smul_comm m a b := (Matrix.mul_smul _ _ _).symm
noncomputable instance instPartialOrder :
PartialOrder (CStarMatrix n n A) := CStarAlgebra.spectralOrder _
instance instStarOrderedRing :
StarOrderedRing (CStarMatrix n n A) := CStarAlgebra.spectralOrderedRing _
end non_unital
section unital
variable {A : Type*} [CStarAlgebra A] [PartialOrder A] [StarOrderedRing A]
variable {n : Type*} [Fintype n] [DecidableEq n]
noncomputable instance instNormedRing : NormedRing (CStarMatrix n n A) where
dist_eq _ _ := rfl
norm_mul_le := norm_mul_le
noncomputable instance instNormedAlgebra : NormedAlgebra ℂ (CStarMatrix n n A) where
norm_smul_le r M := by simpa only [norm_def, map_smul] using (toCLM M).opNorm_smul_le r
/-- Matrices with entries in a unital C⋆-algebra form a unital C⋆-algebra. -/
noncomputable instance instCStarAlgebra [DecidableEq n] : CStarAlgebra (CStarMatrix n n A) where
end unital
section
variable {m n A : Type*} [NonUnitalCStarAlgebra A]
lemma uniformEmbedding_ofMatrix :
IsUniformEmbedding (ofMatrix : Matrix m n A → CStarMatrix m n A) where
comap_uniformity := Filter.comap_id'
injective := fun ⦃_ _⦄ a ↦ a
/-- `ofMatrix` bundled as a continuous linear equivalence. -/
def ofMatrixL : Matrix m n A ≃L[ℂ] CStarMatrix m n A :=
{ ofMatrixₗ with
continuous_toFun := continuous_id
continuous_invFun := continuous_id }
lemma ofMatrix_eq_ofMatrixL :
(ofMatrix : Matrix m n A → CStarMatrix m n A)
= (ofMatrixL : Matrix m n A → CStarMatrix m n A) := rfl
end
end CStarMatrix |
.lake/packages/mathlib/Mathlib/Analysis/CStarAlgebra/Projection.lean | import Mathlib.Analysis.CStarAlgebra.ContinuousFunctionalCalculus.Instances
/-!
# Projections in C⋆-algebras
To show that an element is a star projection in a non-unital C⋆-algebra,
it is enough to show that it is idempotent and normal,
because self-adjointedness and normality are equivalent for idempotent
elements in non-unital C⋆-algebras.
-/
variable {A : Type*} [TopologicalSpace A]
[NonUnitalRing A] [StarRing A] [Module ℂ A] [IsScalarTower ℂ A A] [SMulCommClass ℂ A A]
[NonUnitalContinuousFunctionalCalculus ℂ A IsStarNormal]
/-- An idempotent element in a non-unital C⋆-algebra is self-adjoint iff it is normal. -/
theorem IsIdempotentElem.isSelfAdjoint_iff_isStarNormal {p : A} (hp : IsIdempotentElem p) :
IsSelfAdjoint p ↔ IsStarNormal p := by
simp only [isSelfAdjoint_iff_isStarNormal_and_quasispectrumRestricts,
QuasispectrumRestricts.real_iff, and_iff_left_iff_imp]
intro h x hx
rcases hp.quasispectrum_subset hx with (hx | hx) <;> simp [Set.mem_singleton_iff.mp hx]
/-- An element in a non-unital C⋆-algebra is a star projection
if and only if it is idempotent and normal. -/
theorem isStarProjection_iff_isIdempotentElem_and_isStarNormal {p : A} :
IsStarProjection p ↔ IsIdempotentElem p ∧ IsStarNormal p :=
(isStarProjection_iff p).eq ▸ and_congr_right_iff.eq ▸ fun h => h.isSelfAdjoint_iff_isStarNormal |
.lake/packages/mathlib/Mathlib/Analysis/CStarAlgebra/Hom.lean | import Mathlib.Analysis.CStarAlgebra.ContinuousFunctionalCalculus.Order
/-! # Properties of C⋆-algebra homomorphisms
Here we collect properties of C⋆-algebra homomorphisms.
## Main declarations
+ `NonUnitalStarAlgHom.norm_map`: A non-unital star algebra monomorphism of complex C⋆-algebras
is isometric.
-/
open CStarAlgebra in
lemma IsSelfAdjoint.map_spectrum_real {F A B : Type*} [CStarAlgebra A] [CStarAlgebra B]
[FunLike F A B] [AlgHomClass F ℂ A B] [StarHomClass F A B]
{a : A} (ha : IsSelfAdjoint a) (φ : F) (hφ : Function.Injective φ) :
spectrum ℝ (φ a) = spectrum ℝ a := by
have h_spec := AlgHom.spectrum_apply_subset ((φ : A →⋆ₐ[ℂ] B).restrictScalars ℝ) a
refine Set.eq_of_subset_of_subset h_spec fun x hx ↦ ?_
/- we prove the reverse inclusion by contradiction, so assume that `x ∈ spectrum ℝ a`, but
`x ∉ spectrum ℝ (φ a)`. Then by Urysohn's lemma we can get a function for which `f x = 1`, but
`f = 0` on `spectrum ℝ a`. -/
by_contra hx'
obtain ⟨f, h_eqOn, h_eqOn_x, -⟩ := exists_continuous_zero_one_of_isClosed
(spectrum.isClosed (𝕜 := ℝ) (φ a)) (isClosed_singleton (x := x)) <| by simpa
/- it suffices to show that `φ (f a) = 0`, for if so, then `f a = 0` by injectivity of `φ`, and
hence `f = 0` on `spectrum ℝ a`, contradicting the fact that `f x = 1`. -/
suffices φ (cfc f a) = 0 by
rw [map_eq_zero_iff φ hφ, ← cfc_zero ℝ a, cfc_eq_cfc_iff_eqOn] at this
exact zero_ne_one <| calc
0 = f x := (this hx).symm
_ = 1 := h_eqOn_x <| Set.mem_singleton x
/- Finally, `φ (f a) = f (φ a) = 0`, where the last equality follows since `f = 0` on
`spectrum ℝ (φ a)`. -/
calc φ (cfc f a) = cfc f (φ a) := StarAlgHomClass.map_cfc φ f a
_ = cfc (0 : ℝ → ℝ) (φ a) := cfc_congr h_eqOn
_ = 0 := by simp
namespace NonUnitalStarAlgHom
variable {F A B : Type*} [NonUnitalCStarAlgebra A] [NonUnitalCStarAlgebra B]
variable [FunLike F A B] [NonUnitalAlgHomClass F ℂ A B] [StarHomClass F A B]
open CStarAlgebra Unitization in
/-- A non-unital star algebra monomorphism of complex C⋆-algebras is isometric. -/
lemma norm_map (φ : F) (hφ : Function.Injective φ) (a : A) : ‖φ a‖ = ‖a‖ := by
/- Since passing to the unitization is functorial, and it is an isometric embedding, we may assume
that `φ` is a unital star algebra monomorphism and that `A` and `B` are unital C⋆-algebras. -/
suffices ∀ {ψ : Unitization ℂ A →⋆ₐ[ℂ] Unitization ℂ B} (_ : Function.Injective ψ)
(a : Unitization ℂ A), ‖ψ a‖ = ‖a‖ by
simpa [norm_inr] using this (starMap_injective (φ := (φ : A →⋆ₙₐ[ℂ] B)) hφ) a
intro ψ hψ a
-- to show `‖ψ a‖ = ‖a‖`, by the C⋆-property it suffices to show `‖ψ (star a * a)‖ = ‖star a * a‖`
rw [← sq_eq_sq₀ (by positivity) (by positivity)]
simp only [sq, ← CStarRing.norm_star_mul_self, ← map_star, ← map_mul]
/- since `star a * a` is selfadjoint, it has the same `ℝ`-spectrum as `ψ (star a * a)`.
Since the spectral radius over `ℝ` coincides with the norm, `‖ψ (star a * a)‖ = ‖star a * a‖`. -/
have ha : IsSelfAdjoint (star a * a) := .star_mul_self a
calc ‖ψ (star a * a)‖ = (spectralRadius ℝ (ψ (star a * a))).toReal :=
ha.map ψ |>.toReal_spectralRadius_eq_norm.symm
_ = (spectralRadius ℝ (star a * a)).toReal := by
simp only [spectralRadius, ha.map_spectrum_real ψ hψ]
_ = ‖star a * a‖ := ha.toReal_spectralRadius_eq_norm
/-- A non-unital star algebra monomorphism of complex C⋆-algebras is isometric. -/
lemma nnnorm_map (φ : F) (hφ : Function.Injective φ) (a : A) : ‖φ a‖₊ = ‖a‖₊ :=
Subtype.ext <| norm_map φ hφ a
lemma isometry (φ : F) (hφ : Function.Injective φ) : Isometry φ :=
AddMonoidHomClass.isometry_of_norm φ (norm_map φ hφ)
end NonUnitalStarAlgHom |
.lake/packages/mathlib/Mathlib/Analysis/CStarAlgebra/Spectrum.lean | import Mathlib.Analysis.CStarAlgebra.Unitization
import Mathlib.Analysis.Complex.Convex
import Mathlib.Analysis.Normed.Algebra.GelfandFormula
import Mathlib.Analysis.SpecialFunctions.Exponential
import Mathlib.Algebra.Star.StarAlgHom
/-! # Spectral properties in C⋆-algebras
In this file, we establish various properties related to the spectrum of elements in C⋆-algebras.
In particular, we show that the spectrum of a unitary element is contained in the unit circle in
`ℂ`, the spectrum of a selfadjoint element is real, the spectral radius of a selfadjoint element
or normal element is its norm, among others.
An essential feature of C⋆-algebras is **spectral permanence**. This is the property that the
spectrum of an element in a closed subalgebra is the same as the spectrum of the element in the
whole algebra. For Banach algebras more generally, and even for Banach ⋆-algebras, this fails.
A consequence of spectral permanence is that one may always enlarge the C⋆-algebra (via a unital
embedding) while preserving the spectrum of any element. In addition, it allows us to make sense of
the spectrum of elements in non-unital C⋆-algebras by considering them as elements in the
`Unitization` of the C⋆-algebra, or indeed *any* unital C⋆-algebra. Of course, one may do this
(that is, consider the spectrum of an element in a non-unital by embedding it in a unital algebra)
for any Banach algebra, but the downside in that setting is that embedding in different unital
algebras results in varying spectra.
In Mathlib, we don't *define* the spectrum of an element in a non-unital C⋆-algebra, and instead
simply consider the `quasispectrum` so as to avoid depending on a choice of unital algebra. However,
we can still establish a form of spectral permanence.
## Main statements
+ `Unitary.spectrum_subset_circle`: The spectrum of a unitary element is contained in the unit
sphere in `ℂ`.
+ `IsSelfAdjoint.spectralRadius_eq_nnnorm`: The spectral radius of a selfadjoint element is equal
to its norm.
+ `IsStarNormal.spectralRadius_eq_nnnorm`: The spectral radius of a normal element is equal to
its norm.
+ `IsSelfAdjoint.mem_spectrum_eq_re`: Any element of the spectrum of a selfadjoint element is real.
* `StarSubalgebra.coe_isUnit`: for `x : S` in a C⋆-Subalgebra `S` of `A`, then `↑x : A` is a Unit
if and only if `x` is a unit.
* `StarSubalgebra.spectrum_eq`: **spectral_permanence** for `x : S`, where `S` is a C⋆-Subalgebra
of `A`, `spectrum ℂ x = spectrum ℂ (x : A)`.
## TODO
+ prove a variation of spectral permanence using `StarAlgHom` instead of `StarSubalgebra`.
+ prove a variation of spectral permanence for `quasispectrum`.
-/
local notation "σ" => spectrum
local postfix:max "⋆" => star
section
open scoped Topology ENNReal
open Filter ENNReal spectrum CStarRing NormedSpace
section UnitarySpectrum
variable {𝕜 : Type*} [NormedField 𝕜] {E : Type*} [NormedRing E] [StarRing E] [CStarRing E]
[NormedAlgebra 𝕜 E] [CompleteSpace E]
theorem Unitary.spectrum_subset_circle (u : unitary E) :
spectrum 𝕜 (u : E) ⊆ Metric.sphere 0 1 := by
nontriviality E
refine fun k hk => mem_sphere_zero_iff_norm.mpr (le_antisymm ?_ ?_)
· simpa only [CStarRing.norm_coe_unitary u] using norm_le_norm_of_mem hk
· rw [← Unitary.val_toUnits_apply u] at hk
have hnk := ne_zero_of_mem_of_unit hk
rw [← inv_inv (Unitary.toUnits u), ← spectrum.map_inv, Set.mem_inv] at hk
have : ‖k‖⁻¹ ≤ ‖(↑(Unitary.toUnits u)⁻¹ : E)‖ := by
simpa only [norm_inv] using norm_le_norm_of_mem hk
simpa using inv_le_of_inv_le₀ (norm_pos_iff.mpr hnk) this
@[deprecated (since := "2025-10-29")] alias unitary.spectrum_subset_circle :=
Unitary.spectrum_subset_circle
theorem spectrum.subset_circle_of_unitary {u : E} (h : u ∈ unitary E) :
spectrum 𝕜 u ⊆ Metric.sphere 0 1 :=
Unitary.spectrum_subset_circle ⟨u, h⟩
theorem spectrum.norm_eq_one_of_unitary {u : E} (hu : u ∈ unitary E)
⦃z : 𝕜⦄ (hz : z ∈ spectrum 𝕜 u) : ‖z‖ = 1 := by
simpa using spectrum.subset_circle_of_unitary hu hz
end UnitarySpectrum
section Quasispectrum
open scoped NNReal in
lemma CStarAlgebra.le_nnnorm_of_mem_quasispectrum {A : Type*} [NonUnitalCStarAlgebra A]
{a : A} {x : ℝ≥0} (hx : x ∈ quasispectrum ℝ≥0 a) : x ≤ ‖a‖₊ := by
rw [Unitization.quasispectrum_eq_spectrum_inr' ℝ≥0 ℂ] at hx
simpa [Unitization.nnnorm_inr] using spectrum.le_nnnorm_of_mem hx
end Quasispectrum
section ComplexScalars
open Complex
variable {A : Type*} [CStarAlgebra A]
local notation "↑ₐ" => algebraMap ℂ A
theorem IsSelfAdjoint.spectralRadius_eq_nnnorm {a : A} (ha : IsSelfAdjoint a) :
spectralRadius ℂ a = ‖a‖₊ := by
have hconst : Tendsto (fun _n : ℕ => (‖a‖₊ : ℝ≥0∞)) atTop _ := tendsto_const_nhds
refine tendsto_nhds_unique ?_ hconst
convert
(spectrum.pow_nnnorm_pow_one_div_tendsto_nhds_spectralRadius (a : A)).comp
(tendsto_pow_atTop_atTop_of_one_lt one_lt_two) using 1
refine funext fun n => ?_
rw [Function.comp_apply, ha.nnnorm_pow_two_pow, ENNReal.coe_pow, ← rpow_natCast, ← rpow_mul]
simp
/-- In a C⋆-algebra, the spectral radius of a self-adjoint element is equal to its norm.
See `IsSelfAdjoint.toReal_spectralRadius_eq_norm` for a version involving
`spectralRadius ℝ a`. -/
lemma IsSelfAdjoint.toReal_spectralRadius_complex_eq_norm {a : A} (ha : IsSelfAdjoint a) :
(spectralRadius ℂ a).toReal = ‖a‖ := by
simp [ha.spectralRadius_eq_nnnorm]
theorem IsStarNormal.spectralRadius_eq_nnnorm (a : A) [IsStarNormal a] :
spectralRadius ℂ a = ‖a‖₊ := by
refine (ENNReal.pow_right_strictMono two_ne_zero).injective ?_
have heq :
(fun n : ℕ => (‖(a⋆ * a) ^ n‖₊ : ℝ≥0∞) ^ (1 / n : ℝ)) =
(fun x => x ^ 2) ∘ fun n : ℕ => (‖a ^ n‖₊ : ℝ≥0∞) ^ (1 / n : ℝ) := by
funext n
rw [Function.comp_apply, ← rpow_natCast, ← rpow_mul, mul_comm, rpow_mul, rpow_natCast, ←
coe_pow, sq, ← nnnorm_star_mul_self, Commute.mul_pow (star_comm_self' a), star_pow]
have h₂ :=
((ENNReal.continuous_pow 2).tendsto (spectralRadius ℂ a)).comp
(spectrum.pow_nnnorm_pow_one_div_tendsto_nhds_spectralRadius a)
rw [← heq] at h₂
convert tendsto_nhds_unique h₂ (pow_nnnorm_pow_one_div_tendsto_nhds_spectralRadius (a⋆ * a))
rw [(IsSelfAdjoint.star_mul_self a).spectralRadius_eq_nnnorm, sq, nnnorm_star_mul_self, coe_mul]
variable [StarModule ℂ A]
/-- Any element of the spectrum of a selfadjoint is real. -/
theorem IsSelfAdjoint.mem_spectrum_eq_re {a : A} (ha : IsSelfAdjoint a) {z : ℂ}
(hz : z ∈ spectrum ℂ a) : z = z.re := by
have hu := exp_mem_unitary_of_mem_skewAdjoint ℂ (ha.smul_mem_skewAdjoint conj_I)
let Iu := Units.mk0 I I_ne_zero
have : NormedSpace.exp ℂ (I • z) ∈ spectrum ℂ (NormedSpace.exp ℂ (I • a)) := by
simpa only [Units.smul_def, Units.val_mk0] using
spectrum.exp_mem_exp (Iu • a) (smul_mem_smul_iff.mpr hz)
exact Complex.ext (ofReal_re _) <| by
simpa only [← Complex.exp_eq_exp_ℂ, mem_sphere_zero_iff_norm, norm_exp, Real.exp_eq_one_iff,
smul_eq_mul, I_mul, neg_eq_zero] using
spectrum.subset_circle_of_unitary hu this
/-- Any element of the spectrum of a selfadjoint is real. -/
theorem selfAdjoint.mem_spectrum_eq_re (a : selfAdjoint A) {z : ℂ}
(hz : z ∈ spectrum ℂ (a : A)) : z = z.re :=
a.prop.mem_spectrum_eq_re hz
/-- Any element of the spectrum of a selfadjoint is real. -/
theorem IsSelfAdjoint.im_eq_zero_of_mem_spectrum {a : A} (ha : IsSelfAdjoint a)
{z : ℂ} (hz : z ∈ spectrum ℂ a) : z.im = 0 := by
rw [ha.mem_spectrum_eq_re hz, ofReal_im]
/-- The spectrum of a selfadjoint is real -/
theorem IsSelfAdjoint.val_re_map_spectrum {a : A} (ha : IsSelfAdjoint a) :
spectrum ℂ a = ((↑) ∘ re '' spectrum ℂ a : Set ℂ) :=
le_antisymm (fun z hz => ⟨z, hz, (ha.mem_spectrum_eq_re hz).symm⟩) fun z => by
rintro ⟨z, hz, rfl⟩
simpa only [(ha.mem_spectrum_eq_re hz).symm, Function.comp_apply] using hz
/-- The spectrum of a selfadjoint is real -/
theorem selfAdjoint.val_re_map_spectrum (a : selfAdjoint A) :
spectrum ℂ (a : A) = ((↑) ∘ re '' spectrum ℂ (a : A) : Set ℂ) :=
a.property.val_re_map_spectrum
/-- The complement of the spectrum of a selfadjoint element in a C⋆-algebra is connected. -/
lemma IsSelfAdjoint.isConnected_spectrum_compl {a : A} (ha : IsSelfAdjoint a) :
IsConnected (σ ℂ a)ᶜ := by
suffices IsConnected (((σ ℂ a)ᶜ ∩ {z | 0 ≤ z.im}) ∪ (σ ℂ a)ᶜ ∩ {z | z.im ≤ 0}) by
rw [← Set.inter_union_distrib_left, ← Set.setOf_or] at this
rw [← Set.inter_univ (σ ℂ a)ᶜ]
convert this using 2
exact Eq.symm <| Set.eq_univ_of_forall (fun z ↦ le_total 0 z.im)
refine IsConnected.union ?nonempty ?upper ?lower
case nonempty =>
have := Filter.NeBot.nonempty_of_mem inferInstance <| Filter.mem_map.mp <|
Complex.isometry_ofReal.antilipschitz.tendsto_cobounded (spectrum.isBounded a |>.compl)
exact this.image Complex.ofReal |>.mono <| by simp
case' upper => apply Complex.isConnected_of_upperHalfPlane ?_ <| Set.inter_subset_right
case' lower => apply Complex.isConnected_of_lowerHalfPlane ?_ <| Set.inter_subset_right
all_goals
refine Set.subset_inter (fun z hz hz' ↦ ?_) (fun _ ↦ by simpa using le_of_lt)
rw [Set.mem_setOf_eq, ha.im_eq_zero_of_mem_spectrum hz'] at hz
simp_all
namespace StarSubalgebra
variable (S : StarSubalgebra ℂ A) [hS : IsClosed (S : Set A)]
/-- For a unital C⋆-subalgebra `S` of `A` and `x : S`, if `↑x : A` is invertible in `A`, then
`x` is invertible in `S`. -/
lemma coe_isUnit {a : S} : IsUnit (a : A) ↔ IsUnit a := by
refine ⟨fun ha ↦ ?_, IsUnit.map S.subtype⟩
have ha₁ := ha.star.mul ha
have ha₂ := ha.mul ha.star
have spec_eq {x : S} (hx : IsSelfAdjoint x) : spectrum ℂ x = spectrum ℂ (x : A) :=
Subalgebra.spectrum_eq_of_isPreconnected_compl S _ <|
(hx.map S.subtype).isConnected_spectrum_compl.isPreconnected
rw [← StarMemClass.coe_star, ← MulMemClass.coe_mul, ← spectrum.zero_notMem_iff ℂ, ← spec_eq,
spectrum.zero_notMem_iff] at ha₁ ha₂
· have h₁ : ha₁.unit⁻¹ * star a * a = 1 := mul_assoc _ _ a ▸ ha₁.val_inv_mul
have h₂ : a * (star a * ha₂.unit⁻¹) = 1 := (mul_assoc a _ _).symm ▸ ha₂.mul_val_inv
exact ⟨⟨a, ha₁.unit⁻¹ * star a, left_inv_eq_right_inv h₁ h₂ ▸ h₂, h₁⟩, rfl⟩
· exact IsSelfAdjoint.mul_star_self a
· exact IsSelfAdjoint.star_mul_self a
lemma mem_spectrum_iff {a : S} {z : ℂ} : z ∈ spectrum ℂ a ↔ z ∈ spectrum ℂ (a : A) :=
not_iff_not.mpr S.coe_isUnit.symm
/-- **Spectral permanence.** The spectrum of an element is invariant of the (closed)
`StarSubalgebra` in which it is contained. -/
lemma spectrum_eq {a : S} : spectrum ℂ a = spectrum ℂ (a : A) :=
Set.ext fun _ ↦ S.mem_spectrum_iff
end StarSubalgebra
end ComplexScalars
namespace NonUnitalStarAlgHom
variable {F A B : Type*} [NonUnitalCStarAlgebra A] [NonUnitalCStarAlgebra B]
variable [FunLike F A B] [NonUnitalAlgHomClass F ℂ A B] [StarHomClass F A B]
open Unitization
/-- A non-unital star algebra homomorphism of complex C⋆-algebras is norm contractive. -/
lemma nnnorm_apply_le (φ : F) (a : A) : ‖φ a‖₊ ≤ ‖a‖₊ := by
have h (ψ : Unitization ℂ A →⋆ₐ[ℂ] Unitization ℂ B) (x : Unitization ℂ A) :
‖ψ x‖₊ ≤ ‖x‖₊ := by
suffices ∀ {s}, IsSelfAdjoint s → ‖ψ s‖₊ ≤ ‖s‖₊ by
refine nonneg_le_nonneg_of_sq_le_sq zero_le' ?_
simp_rw [← nnnorm_star_mul_self, ← map_star, ← map_mul]
exact this <| .star_mul_self x
intro s hs
suffices this : spectralRadius ℂ (ψ s) ≤ spectralRadius ℂ s by
rwa [(hs.map ψ).spectralRadius_eq_nnnorm, hs.spectralRadius_eq_nnnorm, coe_le_coe]
at this
exact iSup_le_iSup_of_subset (AlgHom.spectrum_apply_subset ψ s)
simpa [nnnorm_inr] using h (starLift (inrNonUnitalStarAlgHom ℂ B |>.comp (φ : A →⋆ₙₐ[ℂ] B))) a
/-- A non-unital star algebra homomorphism of complex C⋆-algebras is norm contractive. -/
lemma norm_apply_le (φ : F) (a : A) : ‖φ a‖ ≤ ‖a‖ := by
exact_mod_cast nnnorm_apply_le φ a
/-- Non-unital star algebra homomorphisms between C⋆-algebras are continuous linear maps.
See note [lower instance priority] -/
lemma instContinuousLinearMapClassComplex : ContinuousLinearMapClass F ℂ A B :=
{ NonUnitalAlgHomClass.instLinearMapClass with
map_continuous := fun φ =>
AddMonoidHomClass.continuous_of_bound φ 1 (by simpa only [one_mul] using nnnorm_apply_le φ) }
scoped[CStarAlgebra] attribute [instance] NonUnitalStarAlgHom.instContinuousLinearMapClassComplex
end NonUnitalStarAlgHom
namespace StarAlgEquiv
variable {F A B : Type*} [NonUnitalCStarAlgebra A] [NonUnitalCStarAlgebra B] [EquivLike F A B]
variable [NonUnitalAlgEquivClass F ℂ A B] [StarHomClass F A B]
lemma nnnorm_map (φ : F) (a : A) : ‖φ a‖₊ = ‖a‖₊ :=
le_antisymm (NonUnitalStarAlgHom.nnnorm_apply_le φ a) <| by
simpa using NonUnitalStarAlgHom.nnnorm_apply_le (symm (φ : A ≃⋆ₐ[ℂ] B)) ((φ : A ≃⋆ₐ[ℂ] B) a)
lemma norm_map (φ : F) (a : A) : ‖φ a‖ = ‖a‖ :=
congr_arg NNReal.toReal (nnnorm_map φ a)
lemma isometry (φ : F) : Isometry φ :=
AddMonoidHomClass.isometry_of_norm φ (norm_map φ)
end StarAlgEquiv
end
namespace WeakDual
open ContinuousMap Complex
open scoped ComplexStarModule
variable {F A : Type*} [CStarAlgebra A] [FunLike F A ℂ] [hF : AlgHomClass F ℂ A ℂ]
/-- This instance is provided instead of `StarHomClass` to avoid type class inference loops.
See note [lower instance priority] -/
noncomputable instance (priority := 100) Complex.instStarHomClass : StarHomClass F A ℂ where
map_star φ a := by
suffices hsa : ∀ s : selfAdjoint A, (φ s)⋆ = φ s by
rw [← realPart_add_I_smul_imaginaryPart a]
simp only [map_add, map_smul, star_add, star_smul, hsa, selfAdjoint.star_val_eq]
intro s
have := AlgHom.apply_mem_spectrum φ (s : A)
rw [selfAdjoint.val_re_map_spectrum s] at this
rcases this with ⟨⟨_, _⟩, _, heq⟩
simp only [Function.comp_apply] at heq
rw [← heq, RCLike.star_def]
exact RCLike.conj_ofReal _
/-- This is not an instance to avoid type class inference loops. See
`WeakDual.Complex.instStarHomClass`. -/
lemma _root_.AlgHomClass.instStarHomClass : StarHomClass F A ℂ :=
{ WeakDual.Complex.instStarHomClass, hF with }
namespace CharacterSpace
noncomputable instance instStarHomClass : StarHomClass (characterSpace ℂ A) A ℂ :=
{ AlgHomClass.instStarHomClass with }
end CharacterSpace
end WeakDual |
.lake/packages/mathlib/Mathlib/Analysis/CStarAlgebra/Unitary/Span.lean | import Mathlib.Analysis.CStarAlgebra.ContinuousFunctionalCalculus.Order
import Mathlib.Analysis.CStarAlgebra.ContinuousFunctionalCalculus.Unitary
import Mathlib.Analysis.NormedSpace.Normalize
/-! # Unitary elements span C⋆-algebras
## Main results
+ `CStarAlgebra.exists_sum_four_unitary`: every element `x` in a unital C⋆-algebra is a linear
combination of four unitary elements, and the norm of each coefficient does not exceed `‖x‖ / 2`.
+ `CStarAlgebra.span_unitary`: a unital C⋆-algebra is spanned by its unitary elements.
-/
variable {A : Type*} [CStarAlgebra A]
open scoped ComplexStarModule
open Complex
section Ordered
variable [PartialOrder A] [StarOrderedRing A]
/-- If `a : A` is a selfadjoint element in a C⋆-algebra with `‖a‖ ≤ 1`,
then `a + I • CFC.sqrt (1 - a ^ 2)` is unitary.
This is the key tool to show that a C⋆-algebra is spanned by its unitary elements. -/
lemma IsSelfAdjoint.self_add_I_smul_cfcSqrt_sub_sq_mem_unitary (a : A) (ha : IsSelfAdjoint a)
(ha_norm : ‖a‖ ≤ 1) : a + I • CFC.sqrt (1 - a ^ 2) ∈ unitary A := by
obtain (_ | _) := subsingleton_or_nontrivial A
· simp [Subsingleton.elim (a + I • CFC.sqrt (1 - a ^ 2)) 1, one_mem (unitary A)]
have key : a + I • CFC.sqrt (1 - a ^ 2) = cfc (fun x : ℂ ↦ x.re + I * √(1 - x.re ^ 2)) a := by
rw [CFC.sqrt_eq_real_sqrt (1 - a ^ 2) ?nonneg]
case nonneg =>
rwa [sub_nonneg, ← CStarAlgebra.norm_le_one_iff_of_nonneg (a ^ 2), sq, ha.norm_mul_self,
sq_le_one_iff₀ (by positivity)]
rw [cfc_add .., cfc_const_mul .., ← cfc_real_eq_complex (fun x ↦ x) ha, cfc_id' ℝ a,
← cfc_real_eq_complex (fun x ↦ √(1 - x ^2)) ha, cfcₙ_eq_cfc, cfc_comp' (√·) (1 - · ^ 2) a,
cfc_sub .., cfc_pow .., cfc_const_one .., cfc_id' ..]
rw [key, cfc_unitary_iff ..]
intro x hx
rw [← starRingEnd_apply, ← Complex.normSq_eq_conj_mul_self,
Complex.normSq_ofReal_add_I_mul_sqrt_one_sub, Complex.ofReal_one]
exact spectrum.norm_le_norm_of_mem (ha.spectrumRestricts.apply_mem hx) |>.trans ha_norm
/-- For `a` selfadjoint with `‖a‖ ≤ 1`, this is the unitary `a + I • √(1 - a ^ 2)`. -/
@[simps]
noncomputable def selfAdjoint.unitarySelfAddISMul (a : selfAdjoint A) (ha_norm : ‖a‖ ≤ 1) :
unitary A :=
⟨(a : A) + I • CFC.sqrt (1 - a ^ 2 : A), a.2.self_add_I_smul_cfcSqrt_sub_sq_mem_unitary _ ha_norm⟩
lemma selfAdjoint.star_coe_unitarySelfAddISMul (a : selfAdjoint A) (ha_norm : ‖a‖ ≤ 1) :
(star (unitarySelfAddISMul a ha_norm) : A) = a - I • CFC.sqrt (1 - a ^ 2 : A) := by
simp [IsSelfAdjoint.star_eq, ← sub_eq_add_neg, (CFC.sqrt_nonneg (1 - a ^ 2 : A)).isSelfAdjoint]
lemma selfAdjoint.realPart_unitarySelfAddISMul (a : selfAdjoint A) (ha_norm : ‖a‖ ≤ 1) :
ℜ (unitarySelfAddISMul a ha_norm : A) = a := by
simp [IsSelfAdjoint.imaginaryPart (x := CFC.sqrt (1 - a ^ 2 : A)) (by cfc_tac)]
/-- A stepping stone to `CStarAlgebra.exists_sum_four_unitary` that specifies the unitary
elements precisely. The `let`s in the statement are intentional. -/
lemma CStarAlgebra.norm_smul_two_inv_smul_add_four_unitary (x : A) (hx : x ≠ 0) :
let u₁ : unitary A := selfAdjoint.unitarySelfAddISMul (ℜ (‖x‖⁻¹ • x))
(by simpa [norm_smul, inv_mul_le_one₀ (norm_pos_iff.2 hx)] using realPart.norm_le x)
let u₂ : unitary A := selfAdjoint.unitarySelfAddISMul (ℑ (‖x‖⁻¹ • x))
(by simpa [norm_smul, inv_mul_le_one₀ (norm_pos_iff.2 hx)] using imaginaryPart.norm_le x)
x = ‖x‖ • (2⁻¹ : ℝ) • (u₁ + star u₁ + I • (u₂ + star u₂) : A) := by
intro u₁ u₂
rw [smul_add, smul_comm _ I, Unitary.coe_star, Unitary.coe_star,
← realPart_apply_coe (u₁ : A), ← realPart_apply_coe (u₂ : A)]
simpa only [u₁, u₂, selfAdjoint.realPart_unitarySelfAddISMul, realPart_add_I_smul_imaginaryPart]
using Eq.symm <| NormedSpace.norm_smul_normalize x
end Ordered
/-- Every element `x` in a unital C⋆-algebra is a linear combination of four unitary elements,
and the norm of each coefficient does not exceed `‖x‖ / 2`. -/
lemma CStarAlgebra.exists_sum_four_unitary (x : A) :
∃ u : Fin 4 → unitary A, ∃ c : Fin 4 → ℂ, x = ∑ i, c i • (u i : A) ∧ ∀ i, ‖c i‖ ≤ ‖x‖ / 2 := by
let _ := CStarAlgebra.spectralOrder
let _ := CStarAlgebra.spectralOrderedRing
obtain (rfl | hx) := eq_or_ne x 0
· exact ⟨![1, -1, 1, -1], 0, by simp⟩
· have := norm_smul_two_inv_smul_add_four_unitary x hx
extract_lets u₁ u₂ at this
use ![u₁, star u₁, u₂, star u₂], ![‖x‖ * 2⁻¹, ‖x‖ * 2⁻¹, ‖x‖ * 2⁻¹ * I, ‖x‖ * 2⁻¹ * I]
constructor
· conv_lhs => rw [this]
simp [Fin.sum_univ_four, ← Complex.coe_smul]
module
· intro i
fin_cases i
all_goals simp [div_eq_mul_inv]
variable (A) in
open Submodule in
/-- A unital C⋆-algebra is spanned by its unitary elements. -/
lemma CStarAlgebra.span_unitary : span ℂ (unitary A : Set A) = ⊤ := by
rw [eq_top_iff]
rintro x -
obtain ⟨u, c, rfl, h⟩ := CStarAlgebra.exists_sum_four_unitary x
exact sum_mem fun i _ ↦ smul_mem _ _ (subset_span (u i).2) |
.lake/packages/mathlib/Mathlib/Analysis/CStarAlgebra/Unitary/Connected.lean | import Mathlib.Analysis.CStarAlgebra.ContinuousFunctionalCalculus.Continuity
import Mathlib.Analysis.CStarAlgebra.ContinuousFunctionalCalculus.Order
import Mathlib.Analysis.CStarAlgebra.Exponential
import Mathlib.Analysis.SpecialFunctions.Complex.Circle
import Mathlib.Analysis.SpecialFunctions.ContinuousFunctionalCalculus.ExpLog.Basic
/-! # The unitary group in a unital C⋆-algebra is locally path connected
When `A` is a unital C⋆-algebra and `u : unitary A` is a unitary element whose distance to `1` is
less that `2`, the spectrum of `u` is contained in the slit plane, so the principal branch of the
logarithm is continuous on the spectrum of `u` (or equivalently, `Complex.arg` is continuous on the
spectrum). The continuous functional calculus can then be used to define a selfadjoint element `x`
such that `u = exp (I • x)`. Moreover, there is a relatively nice relationship between the norm of
`x` and the norm of `u - 1`, namely `‖u - 1‖ ^ 2 = 2 * (1 - cos ‖x‖)`. In fact, these maps `u ↦ x`
and `x ↦ u` establish a partial homeomorphism between `ball (1 : unitary A) 2` and
`ball (0 : selfAdjoint A) π`.
The map `t ↦ exp (t • (I • x))` constitutes a path from `1` to `u`, showing that unitary elements
sufficiently close (i.e., within a distance `2`) to `1 : unitary A` are path connected to `1`.
This property can be translated around the unitary group to show that if `u v : unitary A` are
unitary elements with `‖u - v‖ < 2`, then there is a path joining them. In fact, this path has the
property that it lies within `closedBall u ‖u - v‖`, and consequently any ball of radius `δ < 2` in
`unitary A` is path connected. Therefore, the unitary group is locally path connected.
Finally, we provide the standard characterization of the path component of `1 : unitary A` as finite
products of exponential unitaries.
## Main results
+ `Unitary.argSelfAdjoint`: the selfadjoint element obtained by taking the argument (using the
principal branch and the continuous functional calculus) of a unitary. This returns `0` if
the principal branch of the logarithm is not continuous on the spectrum of the unitary element.
+ `selfAdjoint.norm_sq_expUnitary_sub_one`:
`‖(selfAdjoint.expUnitary x - 1 : A)‖ ^ 2 = 2 * (1 - Real.cos ‖x‖)`
+ `Unitary.norm_argSelfAdjoint`:
`‖Unitary.argSelfAdjoint u‖ = Real.arccos (1 - ‖(u - 1 : A)‖ ^ 2 / 2)`
+ `Unitary.openPartialHomeomorph`: the maps `Unitary.argSelfAdjoint` and `selfAdjoint.expUnitary`
form a partial homeomorphism between `ball (1 : unitary A) 2` and `ball (0 : selfAdjoint A) π`.
+ `selfAdjoint.expUnitaryPathToOne`: the path `t ↦ expUnitary (t • x)` from `1` to
`expUnitary x` for a selfadjoint element `x`.
+ `Unitary.isPathConnected_ball`: any ball of radius `δ < 2` in the unitary group of a unital
C⋆-algebra is path connected.
+ `Unitary.instLocPathConnectedSpace`: the unitary group of a C⋆-algebra is locally path connected.
+ `Unitary.mem_pathComponentOne_iff`: The path component of the identity in the unitary group of a
C⋆-algebra is the set of unitaries that can be expressed as a product of exponentials of
selfadjoint elements.
-/
variable {A : Type*} [CStarAlgebra A]
open Complex Metric NormedSpace selfAdjoint Unitary
open scoped Real
lemma Unitary.two_mul_one_sub_le_norm_sub_one_sq {u : A} (hu : u ∈ unitary A)
{z : ℂ} (hz : z ∈ spectrum ℂ u) :
2 * (1 - z.re) ≤ ‖u - 1‖ ^ 2 := by
rw [← Real.sqrt_le_left (by positivity)]
have := spectrum.subset_circle_of_unitary hu hz
simp only [mem_sphere_iff_norm, sub_zero] at this
rw [← cfc_id' ℂ u, ← cfc_one ℂ u, ← cfc_sub ..]
convert norm_apply_le_norm_cfc (fun z ↦ z - 1) u hz
simpa using congr(Real.sqrt $(norm_sub_one_sq_eq_of_norm_eq_one this)).symm
@[deprecated (since := "2025-10-29")] alias unitary.two_mul_one_sub_le_norm_sub_one_sq :=
Unitary.two_mul_one_sub_le_norm_sub_one_sq
lemma Unitary.norm_sub_one_sq_eq {u : A} (hu : u ∈ unitary A) {x : ℝ}
(hz : IsLeast (re '' (spectrum ℂ u)) x) :
‖u - 1‖ ^ 2 = 2 * (1 - x) := by
obtain (_ | _) := subsingleton_or_nontrivial A
· exfalso; apply hz.nonempty.of_image.ne_empty; simp
rw [← cfc_id' ℂ u, ← cfc_one ℂ u, ← cfc_sub ..]
have h_eqOn : (spectrum ℂ u).EqOn (fun z ↦ ‖z - 1‖ ^ 2) (fun z ↦ 2 * (1 - z.re)) :=
Complex.norm_sub_one_sq_eqOn_sphere.mono <| spectrum.subset_circle_of_unitary (𝕜 := ℂ) hu
have h₂ : IsGreatest ((fun z ↦ 2 * (1 - z.re)) '' (spectrum ℂ u)) (2 * (1 - x)) := by
have : Antitone (fun y : ℝ ↦ 2 * (1 - y)) := by intro _ _ _; simp only; gcongr
simpa [Set.image_image] using this.map_isLeast hz
have h₃ : IsGreatest ((‖· - 1‖ ^ 2) '' spectrum ℂ u) (‖cfc (· - 1 : ℂ → ℂ) u‖ ^ 2) := by
have := pow_left_monotoneOn (n := 2) |>.mono (s₂ := ((‖· - 1‖) '' spectrum ℂ u)) (by aesop)
simpa [Set.image_image] using this.map_isGreatest (IsGreatest.norm_cfc (fun z : ℂ ↦ z - 1) u)
exact h₃.unique (h_eqOn.image_eq ▸ h₂)
@[deprecated (since := "2025-10-29")] alias unitary.norm_sub_one_sq_eq := Unitary.norm_sub_one_sq_eq
lemma Unitary.norm_sub_one_lt_two_iff {u : A} (hu : u ∈ unitary A) :
‖u - 1‖ < 2 ↔ -1 ∉ spectrum ℂ u := by
nontriviality A
rw [← sq_lt_sq₀ (by positivity) (by positivity)]
constructor
· intro h h1
have := two_mul_one_sub_le_norm_sub_one_sq hu h1 |>.trans_lt h
norm_num at this
· contrapose!
obtain ⟨x, hx⟩ := spectrum.isCompact (𝕜 := ℂ) u |>.image continuous_re |>.exists_isLeast <|
(spectrum.nonempty _).image _
rw [norm_sub_one_sq_eq hu hx]
obtain ⟨z, hz, rfl⟩ := hx.1
intro key
replace key : z.re ≤ -1 := by linarith
have hz_norm : ‖z‖ = 1 := spectrum.norm_eq_one_of_unitary hu hz
rw [← hz_norm, ← RCLike.re_eq_complex_re, RCLike.re_le_neg_norm_iff_eq_neg_norm, hz_norm] at key
exact key ▸ hz
@[deprecated (since := "2025-10-29")] alias unitary.norm_sub_one_lt_two_iff :=
Unitary.norm_sub_one_lt_two_iff
lemma Unitary.spectrum_subset_slitPlane_iff_norm_lt_two {u : A} (hu : u ∈ unitary A) :
spectrum ℂ u ⊆ slitPlane ↔ ‖u - 1‖ < 2 := by
simp [subset_slitPlane_iff_of_subset_sphere (spectrum.subset_circle_of_unitary hu),
norm_sub_one_lt_two_iff hu]
@[deprecated (since := "2025-10-29")] alias unitary.spectrum_subset_slitPlane_iff_norm_lt_two :=
Unitary.spectrum_subset_slitPlane_iff_norm_lt_two
@[aesop safe apply (rule_sets := [CStarAlgebra])]
lemma IsSelfAdjoint.cfc_arg (u : A) : IsSelfAdjoint (cfc (ofReal ∘ arg : ℂ → ℂ) u) := by
simp [isSelfAdjoint_iff, ← cfc_star, Function.comp_def]
/-- The selfadjoint element obtained by taking the argument (using the principal branch and the
continuous functional calculus) of a unitary whose spectrum does not contain `-1`. This returns
`0` if the principal branch of the logarithm is not continuous on the spectrum of the unitary
element. -/
@[simps]
noncomputable def Unitary.argSelfAdjoint (u : unitary A) : selfAdjoint A :=
⟨cfc (arg · : ℂ → ℂ) (u : A), .cfc_arg (u : A)⟩
@[deprecated (since := "2025-10-29")] alias unitary.argSelfAdjoint := Unitary.argSelfAdjoint
lemma selfAdjoint.norm_sq_expUnitary_sub_one {x : selfAdjoint A} (hx : ‖x‖ ≤ π) :
‖(expUnitary x - 1 : A)‖ ^ 2 = 2 * (1 - Real.cos ‖x‖) := by
nontriviality A
apply norm_sub_one_sq_eq (expUnitary x).2
simp only [expUnitary_coe, AddSubgroupClass.coe_norm]
rw [← CFC.exp_eq_normedSpace_exp, ← cfc_comp_smul I _ (x : A), cfc_map_spectrum ..,
← x.2.spectrumRestricts.algebraMap_image]
simp only [Set.image_image, coe_algebraMap, smul_eq_mul, mul_comm I, ← exp_eq_exp_ℂ,
exp_ofReal_mul_I_re]
refine ⟨?_, ?_⟩
· cases CStarAlgebra.norm_or_neg_norm_mem_spectrum x.2 with
| inl h => exact ⟨_, h, rfl⟩
| inr h => exact ⟨_, h, by simp⟩
· rintro - ⟨y, hy, rfl⟩
exact Real.cos_abs y ▸ Real.cos_le_cos_of_nonneg_of_le_pi (by positivity) hx <|
spectrum.norm_le_norm_of_mem hy
lemma argSelfAdjoint_expUnitary {x : selfAdjoint A} (hx : ‖x‖ < π) :
argSelfAdjoint (expUnitary x) = x := by
nontriviality A
ext
have : spectrum ℂ (expUnitary x : A) ⊆ slitPlane := by
rw [spectrum_subset_slitPlane_iff_norm_lt_two (expUnitary x).2,
← sq_lt_sq₀ (by positivity) (by positivity), norm_sq_expUnitary_sub_one hx.le]
calc
2 * (1 - Real.cos ‖x‖) < 2 * (1 - Real.cos π) := by
gcongr
exact Real.cos_lt_cos_of_nonneg_of_le_pi (by positivity) le_rfl hx
_ = 2 ^ 2 := by norm_num
simp only [argSelfAdjoint_coe, expUnitary_coe]
rw [← CFC.exp_eq_normedSpace_exp, ← cfc_comp_smul .., ← cfc_comp' (hg := ?hg)]
case hg =>
refine continuous_ofReal.comp_continuousOn <| continuousOn_arg.mono ?_
rwa [expUnitary_coe, ← CFC.exp_eq_normedSpace_exp, ← cfc_comp_smul ..,
cfc_map_spectrum ..] at this
conv_rhs => rw [← cfc_id' ℂ (x : A)]
refine cfc_congr fun y hy ↦ ?_
rw [← x.2.spectrumRestricts.algebraMap_image] at hy
obtain ⟨y, hy, rfl⟩ := hy
simp only [coe_algebraMap, smul_eq_mul, mul_comm I, ← exp_eq_exp_ℂ, ofReal_inj]
replace hy : ‖y‖ < π := spectrum.norm_le_norm_of_mem hy |>.trans_lt hx
simp only [Real.norm_eq_abs, abs_lt] at hy
rw [← Circle.coe_exp, Circle.arg_exp hy.1 hy.2.le]
lemma expUnitary_argSelfAdjoint {u : unitary A} (hu : ‖(u - 1 : A)‖ < 2) :
expUnitary (argSelfAdjoint u) = u := by
ext
have : ContinuousOn arg (spectrum ℂ (u : A)) :=
continuousOn_arg.mono <| (spectrum_subset_slitPlane_iff_norm_lt_two u.2).mpr hu
rw [expUnitary_coe, argSelfAdjoint_coe, ← CFC.exp_eq_normedSpace_exp,
← cfc_comp_smul .., ← cfc_comp' ..]
conv_rhs => rw [← cfc_id' ℂ (u : A)]
refine cfc_congr fun y hy ↦ ?_
have hy₁ : ‖y‖ = 1 := spectrum.norm_eq_one_of_unitary u.2 hy
have : I * y.arg = log y :=
Complex.ext (by simp [log_re, spectrum.norm_eq_one_of_unitary u.2 hy]) (by simp [log_im])
simpa [← exp_eq_exp_ℂ, this] using exp_log (by aesop)
lemma Unitary.norm_argSelfAdjoint_le_pi (u : unitary A) :
‖argSelfAdjoint u‖ ≤ π :=
norm_cfc_le (by positivity) fun y hy ↦ by simpa using abs_arg_le_pi y
@[deprecated (since := "2025-10-29")] alias unitary.norm_argSelfAdjoint_le_pi :=
Unitary.norm_argSelfAdjoint_le_pi
lemma Unitary.two_mul_one_sub_cos_norm_argSelfAdjoint {u : unitary A} (hu : ‖(u - 1 : A)‖ < 2) :
2 * (1 - Real.cos ‖argSelfAdjoint u‖) = ‖(u - 1 : A)‖ ^ 2 := by
conv_rhs => rw [← expUnitary_argSelfAdjoint hu]
exact Eq.symm <| norm_sq_expUnitary_sub_one <| norm_argSelfAdjoint_le_pi u
@[deprecated (since := "2025-10-29")] alias unitary.two_mul_one_sub_cos_norm_argSelfAdjoint :=
Unitary.two_mul_one_sub_cos_norm_argSelfAdjoint
lemma Unitary.norm_argSelfAdjoint {u : unitary A} (hu : ‖(u - 1 : A)‖ < 2) :
‖argSelfAdjoint u‖ = Real.arccos (1 - ‖(u - 1 : A)‖ ^ 2 / 2) := by
refine Real.arccos_eq_of_eq_cos (by positivity) (norm_argSelfAdjoint_le_pi u) ?_ |>.symm
linarith [two_mul_one_sub_cos_norm_argSelfAdjoint hu]
@[deprecated (since := "2025-10-29")] alias unitary.norm_argSelfAdjoint :=
Unitary.norm_argSelfAdjoint
lemma Unitary.norm_expUnitary_smul_argSelfAdjoint_sub_one_le (u : unitary A)
{t : ℝ} (ht : t ∈ Set.Icc 0 1) (hu : ‖(u - 1 : A)‖ < 2) :
‖(expUnitary (t • argSelfAdjoint u) - 1 : A)‖ ≤ ‖(u - 1 : A)‖ := by
have key : ‖t • argSelfAdjoint u‖ ≤ ‖argSelfAdjoint u‖ := by
rw [← one_mul ‖argSelfAdjoint u‖]
simp_rw [AddSubgroupClass.coe_norm, val_smul, norm_smul, Real.norm_eq_abs, abs_of_nonneg ht.1]
gcongr
exact ht.2
rw [← sq_le_sq₀ (by positivity) (by positivity)]
rw [norm_sq_expUnitary_sub_one (key.trans <| norm_argSelfAdjoint_le_pi u)]
trans 2 * (1 - Real.cos ‖argSelfAdjoint u‖)
· gcongr
exact Real.cos_le_cos_of_nonneg_of_le_pi (by positivity) (norm_argSelfAdjoint_le_pi u) key
· exact (two_mul_one_sub_cos_norm_argSelfAdjoint hu).le
@[deprecated (since := "2025-10-29")] alias
unitary.norm_expUnitary_smul_argSelfAdjoint_sub_one_le :=
Unitary.norm_expUnitary_smul_argSelfAdjoint_sub_one_le
@[fun_prop]
lemma Unitary.continuousOn_argSelfAdjoint :
ContinuousOn (argSelfAdjoint : unitary A → selfAdjoint A) (ball (1 : unitary A) 2) := by
rw [Topology.IsInducing.subtypeVal.continuousOn_iff]
simp only [SetLike.coe_sort_coe, Function.comp_def, argSelfAdjoint_coe]
rw [isOpen_ball.continuousOn_iff]
intro u (hu : dist u 1 < 2)
obtain ⟨ε, huε, hε2⟩ := exists_between (sq_lt_sq₀ (by positivity) (by positivity) |>.mpr hu)
have hε : 0 < ε := lt_of_le_of_lt (by positivity) huε
have huε' : dist u 1 < √ε := Real.lt_sqrt_of_sq_lt huε
apply ContinuousOn.continuousAt ?_ (closedBall_mem_nhds_of_mem huε')
apply ContinuousOn.image_comp_continuous ?_ continuous_subtype_val
apply continuousOn_cfc A (s := sphere 0 1 ∩ {z | 2 * (1 - z.re) ≤ ε}) ?_ _ ?_ |>.mono
· rintro - ⟨v, hv, rfl⟩
simp only [Set.subset_inter_iff, Set.mem_setOf_eq]
refine ⟨inferInstance, spectrum_subset_circle v, ?_⟩
intro z hz
simp only [Set.mem_setOf_eq]
trans ‖(v - 1 : A)‖ ^ 2
· exact two_mul_one_sub_le_norm_sub_one_sq v.2 hz
· refine Real.le_sqrt (by positivity) (by positivity) |>.mp ?_
simpa [Subtype.dist_eq, dist_eq_norm] using hv
· exact isCompact_sphere 0 1 |>.inter_right <| isClosed_le (by fun_prop) (by fun_prop)
· refine continuous_ofReal.comp_continuousOn <| continuousOn_arg.mono ?_
apply subset_slitPlane_iff_of_subset_sphere Set.inter_subset_left |>.mpr
norm_num at hε2 ⊢
exact hε2
@[deprecated (since := "2025-10-29")] alias unitary.continuousOn_argSelfAdjoint :=
Unitary.continuousOn_argSelfAdjoint
/-- the maps `unitary.argSelfAdjoint` and `selfAdjoint.expUnitary` form a partial
homeomorphism between `ball (1 : unitary A) 2` and `ball (0 : selfAdjoint A) π`. -/
@[simps]
noncomputable def Unitary.openPartialHomeomorph :
OpenPartialHomeomorph (unitary A) (selfAdjoint A) where
toFun := argSelfAdjoint
invFun := expUnitary
source := ball 1 2
target := ball 0 π
map_source' u hu := by
simp only [mem_ball, Subtype.dist_eq, OneMemClass.coe_one, dist_eq_norm, sub_zero] at hu ⊢
rw [norm_argSelfAdjoint hu]
calc
Real.arccos (1 - ‖(u - 1 : A)‖ ^ 2 / 2) < Real.arccos (1 - 2 ^ 2 / 2) := by
apply Real.arccos_lt_arccos (by norm_num) (by gcongr)
linarith [(by positivity : 0 ≤ ‖(u - 1 : A)‖ ^ 2 / 2)]
_ = π := by norm_num
map_target' x hx := by
simp only [mem_ball, Subtype.dist_eq, OneMemClass.coe_one, dist_eq_norm, sub_zero] at hx ⊢
rw [← sq_lt_sq₀ (by positivity) (by positivity), norm_sq_expUnitary_sub_one hx.le]
have : -1 < Real.cos ‖(x : A)‖ :=
Real.cos_pi ▸ Real.cos_lt_cos_of_nonneg_of_le_pi (by positivity) le_rfl hx
simp only [AddSubgroupClass.coe_norm, mul_sub, mul_one, sq, gt_iff_lt]
linarith
left_inv' u hu := expUnitary_argSelfAdjoint <| by
simpa [Subtype.dist_eq, dist_eq_norm] using hu
right_inv' x hx := argSelfAdjoint_expUnitary <| by simpa using hx
open_source := isOpen_ball
open_target := isOpen_ball
continuousOn_toFun := by fun_prop
continuousOn_invFun := by fun_prop
@[deprecated (since := "2025-10-29")] alias unitary.openPartialHomeomorph :=
Unitary.openPartialHomeomorph
lemma Unitary.norm_sub_eq (u v : unitary A) :
‖(u - v : A)‖ = ‖((u * star v : unitary A) - 1 : A)‖ := calc
‖(u - v : A)‖ = ‖(u * star v - 1 : A) * v‖ := by simp [sub_mul, mul_assoc]
_ = ‖((u * star v : unitary A) - 1 : A)‖ := by simp
@[deprecated (since := "2025-10-29")] alias unitary.norm_sub_eq := Unitary.norm_sub_eq
lemma Unitary.expUnitary_eq_mul_inv (u v : unitary A) (huv : ‖(u - v : A)‖ < 2) :
expUnitary (argSelfAdjoint (u * star v)) = u * star v :=
expUnitary_argSelfAdjoint <| norm_sub_eq u v ▸ huv
@[deprecated (since := "2025-10-29")] alias unitary.expUnitary_eq_mul_inv :=
Unitary.expUnitary_eq_mul_inv
/-- For a selfadjoint element `x` in a C⋆-algebra, this is the path from `1` to `expUnitary x`
given by `t ↦ expUnitary (t • x)`. -/
@[simps]
noncomputable def selfAdjoint.expUnitaryPathToOne (x : selfAdjoint A) :
Path 1 (expUnitary x) where
toFun t := expUnitary ((t : ℝ) • x)
continuous_toFun := by fun_prop
source' := by simp
target' := by simp
@[simp]
lemma selfAdjoint.joined_one_expUnitary (x : selfAdjoint A) :
Joined (1 : unitary A) (expUnitary x) :=
⟨expUnitaryPathToOne x⟩
/-- The path `t ↦ expUnitary (t • argSelfAdjoint (v * star u)) * u`
from `u : unitary A` to `v` when `‖v - u‖ < 2`. -/
@[simps]
noncomputable def Unitary.path (u v : unitary A) (huv : ‖(v - u : A)‖ < 2) :
Path u v where
toFun t := expUnitary ((t : ℝ) • argSelfAdjoint (v * star u)) * u
continuous_toFun := by fun_prop
source' := by ext; simp
target' := by simp [expUnitary_eq_mul_inv v u huv, mul_assoc]
@[deprecated (since := "2025-10-29")] alias unitary.path := Unitary.path
/-- Two unitary elements `u` and `v` in a unital C⋆-algebra are joined by a path if the
distance between them is less than `2`. -/
lemma Unitary.joined (u v : unitary A) (huv : ‖(v - u : A)‖ < 2) :
Joined u v :=
⟨path u v huv⟩
@[deprecated (since := "2025-10-29")] alias unitary.joined := Unitary.joined
/-- Any ball of radius `δ < 2` in the unitary group of a unital C⋆-algebra is path connected. -/
lemma Unitary.isPathConnected_ball (u : unitary A) (δ : ℝ) (hδ₀ : 0 < δ) (hδ₂ : δ < 2) :
IsPathConnected (ball (u : unitary A) δ) := by
suffices IsPathConnected (ball (1 : unitary A) δ) by
convert this |>.image (f := (u * ·)) (by fun_prop)
ext v
rw [← inv_mul_cancel u]
simp [- inv_mul_cancel, Subtype.dist_eq, dist_eq_norm, ← mul_sub]
refine ⟨1, by simpa, fun {u} hu ↦ ?_⟩
have hu : ‖(u - 1 : A)‖ < δ := by simpa [Subtype.dist_eq, dist_eq_norm] using hu
refine ⟨path 1 u (hu.trans hδ₂), fun t ↦ ?_⟩
simpa [Subtype.dist_eq, dist_eq_norm] using
norm_expUnitary_smul_argSelfAdjoint_sub_one_le u t.2 (hu.trans hδ₂) |>.trans_lt hu
@[deprecated (since := "2025-10-29")] alias unitary.isPathConnected_ball :=
Unitary.isPathConnected_ball
/-- The unitary group in a C⋆-algebra is locally path connected. -/
instance Unitary.instLocPathConnectedSpace : LocPathConnectedSpace (unitary A) :=
.of_bases (fun _ ↦ nhds_basis_uniformity <| uniformity_basis_dist_lt zero_lt_two) <| by
simpa using isPathConnected_ball
/-- The path component of the identity in the unitary group of a C⋆-algebra is the set of
unitaries that can be expressed as a product of exponential unitaries. -/
lemma Unitary.mem_pathComponentOne_iff {u : unitary A} :
u ∈ pathComponent 1 ↔ ∃ l : List (selfAdjoint A), (l.map expUnitary).prod = u := by
constructor
· revert u
simp_rw [← Set.mem_range, ← Set.subset_def, pathComponent_eq_connectedComponent]
refine IsClopen.connectedComponent_subset ?_ ⟨[], by simp⟩
refine .of_thickening_subset_self zero_lt_two ?_
intro u hu
rw [mem_thickening_iff] at hu
obtain ⟨v, ⟨⟨l, (hlv : (l.map expUnitary).prod = v)⟩, huv⟩⟩ := hu
refine ⟨argSelfAdjoint (u * star v) :: l, ?_⟩
simp [hlv, mul_assoc,
expUnitary_eq_mul_inv u v (by simpa [Subtype.dist_eq, dist_eq_norm] using huv)]
· rintro ⟨l, rfl⟩
induction l with
| nil => simp
| cons x xs ih => simpa using (joined_one_expUnitary x).mul ih
@[deprecated (since := "2025-10-29")] alias unitary.mem_pathComponentOne_iff :=
Unitary.mem_pathComponentOne_iff |
.lake/packages/mathlib/Mathlib/Analysis/CStarAlgebra/Module/Synonym.lean | import Mathlib.RingTheory.Finiteness.Defs
import Mathlib.Topology.Bornology.Constructions
import Mathlib.Topology.UniformSpace.Equiv
import Mathlib.Topology.Algebra.Module.Equiv
import Mathlib.Topology.Algebra.IsUniformGroup.Constructions
/-! # Type synonym for types with a `CStarModule` structure
It is often the case that we want to construct a `CStarModule` instance on a type that is already
endowed with a norm, but this norm is not the one associated to its `CStarModule` structure. For
this reason, we create a type synonym `WithCStarModule` which is endowed with the requisite
`CStarModule` instance. We also introduce the scoped notation `C⋆ᵐᵒᵈ` for this type synonym.
The common use cases are, when `A` is a C⋆-algebra:
+ `E × F` where `E` and `F` are `CStarModule`s over `A`
+ `Π i, E i` where `E i` is a `CStarModule` over `A` and `i : ι` with `ι` a `Fintype`
In this way, the set up is very similar to the `WithLp` type synonym, although there is no way to
reuse `WithLp` because the norms *do not* coincide in general.
The `WithCStarModule` synonym is of vital importance, especially because the `CStarModule` class
marks `A` as an `outParam`. Indeed, we want to infer `A` from the type of `E`, but, as with modules,
a type `E` can be a `CStarModule` over different C⋆-algebras. For example, note that if `A` is a
C⋆-algebra, then so is `A × A`, and therefore we may consider both `A` and `A × A` as `CStarModule`s
over themselves, respectively. However, we may *also* consider `A × A` as a `CStarModule` over `A`.
However, by utilizing the type synonym, these actually correspond to *different types*, namely:
+ `A` as a `CStarModule` over `A` corresponds to `A`
+ `A × A` as a `CStarModule` over `A × A` corresponds to `A × A`
+ `A × A` as a `CStarModule` over `A` corresponds to `C⋆ᵐᵒᵈ (A × A)`
## Main definitions
* `WithCStarModule A E`: a copy of `E` to be equipped with a `CStarModule A` structure.
* `WithCStarModule.equiv A E`: the canonical equivalence between `WithCStarModule A E` and `E`.
* `WithCStarModule.linearEquiv ℂ A E`: the canonical `ℂ`-module isomorphism between
`WithCStarModule A E` and `E`.
## Implementation notes
The pattern here is the same one as is used by `Lex` for order structures; it avoids having a
separate synonym for each type, and allows all the structure-copying code to be shared.
-/
set_option linter.unusedVariables false in
/-- A type synonym for endowing a given type with a `CStarModule` structure. This has the scoped
notation `C⋆ᵐᵒᵈ`. -/
@[nolint unusedArguments]
def WithCStarModule (A E : Type*) := E
namespace WithCStarModule
@[inherit_doc]
scoped notation "C⋆ᵐᵒᵈ(" A ", " E ")" => WithCStarModule A E
section Basic
variable (R R' A E : Type*)
/-- The canonical equivalence between `C⋆ᵐᵒᵈ(A, E)` and `E`. This should always be used to
convert back and forth between the representations. -/
def equiv : WithCStarModule A E ≃ E := Equiv.refl _
instance instNontrivial [Nontrivial E] : Nontrivial C⋆ᵐᵒᵈ(A, E) := ‹Nontrivial E›
instance instInhabited [Inhabited E] : Inhabited C⋆ᵐᵒᵈ(A, E) := ‹Inhabited E›
instance instNonempty [Nonempty E] : Nonempty C⋆ᵐᵒᵈ(A, E) := ‹Nonempty E›
instance instUnique [Unique E] : Unique C⋆ᵐᵒᵈ(A, E) := ‹Unique E›
/-! ## `C⋆ᵐᵒᵈ(A, E)` inherits various module-adjacent structures from `E`. -/
instance instZero [Zero E] : Zero C⋆ᵐᵒᵈ(A, E) := ‹Zero E›
instance instAdd [Add E] : Add C⋆ᵐᵒᵈ(A, E) := ‹Add E›
instance instSub [Sub E] : Sub C⋆ᵐᵒᵈ(A, E) := ‹Sub E›
instance instNeg [Neg E] : Neg C⋆ᵐᵒᵈ(A, E) := ‹Neg E›
instance instAddMonoid [AddMonoid E] : AddMonoid C⋆ᵐᵒᵈ(A, E) := ‹AddMonoid E›
instance instSubNegMonoid [SubNegMonoid E] : SubNegMonoid C⋆ᵐᵒᵈ(A, E) := ‹SubNegMonoid E›
instance instSubNegZeroMonoid [SubNegZeroMonoid E] : SubNegZeroMonoid C⋆ᵐᵒᵈ(A, E) :=
‹SubNegZeroMonoid E›
instance instAddCommGroup [AddCommGroup E] : AddCommGroup C⋆ᵐᵒᵈ(A, E) := ‹AddCommGroup E›
instance instSMul {R : Type*} [SMul R E] : SMul R C⋆ᵐᵒᵈ(A, E) := ‹SMul R E›
instance instModule {R : Type*} [Semiring R] [AddCommGroup E] [Module R E] :
Module R C⋆ᵐᵒᵈ(A, E) :=
‹Module R E›
instance instIsScalarTower [SMul R R'] [SMul R E] [SMul R' E]
[IsScalarTower R R' E] : IsScalarTower R R' C⋆ᵐᵒᵈ(A, E) :=
‹IsScalarTower R R' E›
instance instSMulCommClass [SMul R E] [SMul R' E] [SMulCommClass R R' E] :
SMulCommClass R R' C⋆ᵐᵒᵈ(A, E) :=
‹SMulCommClass R R' E›
section Equiv
variable {R A E}
variable [SMul R E] (c : R) (x y : C⋆ᵐᵒᵈ(A, E)) (x' y' : E)
/-! `WithCStarModule.equiv` preserves the module structure. -/
section AddCommGroup
variable [AddCommGroup E]
@[simp]
theorem equiv_zero : equiv A E 0 = 0 :=
rfl
@[simp]
theorem equiv_symm_zero : (equiv A E).symm 0 = 0 :=
rfl
@[simp]
theorem equiv_add : equiv A E (x + y) = equiv A E x + equiv A E y :=
rfl
@[simp]
theorem equiv_symm_add :
(equiv A E).symm (x' + y') = (equiv A E).symm x' + (equiv A E).symm y' :=
rfl
@[simp]
theorem equiv_sub : equiv A E (x - y) = equiv A E x - equiv A E y :=
rfl
@[simp]
theorem equiv_symm_sub :
(equiv A E).symm (x' - y') = (equiv A E).symm x' - (equiv A E).symm y' :=
rfl
@[simp]
theorem equiv_neg : equiv A E (-x) = -equiv A E x :=
rfl
@[simp]
theorem equiv_symm_neg : (equiv A E).symm (-x') = -(equiv A E).symm x' :=
rfl
end AddCommGroup
@[simp]
theorem equiv_smul : equiv A E (c • x) = c • equiv A E x :=
rfl
@[simp]
theorem equiv_symm_smul : (equiv A E).symm (c • x') = c • (equiv A E).symm x' :=
rfl
end Equiv
/-- `WithCStarModule.equiv` as an additive equivalence. -/
def addEquiv [AddCommGroup E] : C⋆ᵐᵒᵈ(A, E) ≃+ E :=
{ AddEquiv.refl _ with
toFun := equiv _ _
invFun := (equiv _ _).symm }
/-- `WithCStarModule.equiv` as a linear equivalence. -/
@[simps -fullyApplied]
def linearEquiv [Semiring R] [AddCommGroup E] [Module R E] : C⋆ᵐᵒᵈ(A, E) ≃ₗ[R] E :=
{ LinearEquiv.refl _ _ with
toFun := equiv _ _
invFun := (equiv _ _).symm }
lemma map_top_submodule {R : Type*} [Semiring R] [AddCommGroup E] [Module R E] :
(⊤ : Submodule R E).map (linearEquiv R A E).symm = ⊤ := Submodule.map_eq_top_iff.mpr rfl
instance instModuleFinite [Semiring R] [AddCommGroup E] [Module R E] [Module.Finite R E] :
Module.Finite R C⋆ᵐᵒᵈ(A, E) := ‹Module.Finite R E›
/-! ## `C⋆ᵐᵒᵈ(A, E)` inherits the uniformity and bornology from `E`. -/
variable {A E}
instance [u : UniformSpace E] : UniformSpace C⋆ᵐᵒᵈ(A, E) := u.comap <| equiv A E
instance [Bornology E] : Bornology C⋆ᵐᵒᵈ(A, E) := Bornology.induced <| equiv A E
/-- `WithCStarModule.equiv` as a uniform equivalence between `C⋆ᵐᵒᵈ(A, E)` and `E`. -/
def uniformEquiv [UniformSpace E] : C⋆ᵐᵒᵈ(A, E) ≃ᵤ E :=
equiv A E |>.toUniformEquivOfIsUniformInducing ⟨rfl⟩
/-- `WithCStarModule.equiv` as a continuous linear equivalence between `C⋆ᵐᵒᵈ E` and `E`. -/
@[simps! apply symm_apply]
def equivL [Semiring R] [AddCommGroup E] [UniformSpace E] [Module R E] : C⋆ᵐᵒᵈ(A, E) ≃L[R] E :=
{ linearEquiv R A E with
continuous_toFun := UniformEquiv.continuous uniformEquiv
continuous_invFun := UniformEquiv.continuous uniformEquiv.symm }
instance [UniformSpace E] [CompleteSpace E] : CompleteSpace C⋆ᵐᵒᵈ(A, E) :=
uniformEquiv.completeSpace_iff.mpr inferInstance
instance [AddCommGroup E] [UniformSpace E] [ContinuousAdd E] : ContinuousAdd C⋆ᵐᵒᵈ(A, E) :=
ContinuousAdd.induced (addEquiv A E)
instance [AddCommGroup E] [UniformSpace E] [IsUniformAddGroup E] : IsUniformAddGroup C⋆ᵐᵒᵈ(A, E) :=
IsUniformAddGroup.comap (addEquiv A E)
instance [Semiring R] [TopologicalSpace R] [AddCommGroup E] [UniformSpace E] [Module R E]
[ContinuousSMul R E] : ContinuousSMul R C⋆ᵐᵒᵈ(A, E) :=
ContinuousSMul.induced (linearEquiv R A E)
end Basic
/-! ## Prod
Register simplification lemmas for the applications of `WithCStarModule (E × F)` elements, as
the usual lemmas for `Prod` will not trigger. -/
section Prod
variable {R A E F : Type*}
variable [SMul R E] [SMul R F]
variable (x y : C⋆ᵐᵒᵈ(A, E × F)) (c : R)
section AddCommGroup
variable [AddCommGroup E] [AddCommGroup F]
@[simp]
theorem zero_fst : (0 : C⋆ᵐᵒᵈ(A, E × F)).fst = 0 :=
rfl
@[simp]
theorem zero_snd : (0 : C⋆ᵐᵒᵈ(A, E × F)).snd = 0 :=
rfl
@[simp]
theorem add_fst : (x + y).fst = x.fst + y.fst :=
rfl
@[simp]
theorem add_snd : (x + y).snd = x.snd + y.snd :=
rfl
@[simp]
theorem sub_fst : (x - y).fst = x.fst - y.fst :=
rfl
@[simp]
theorem sub_snd : (x - y).snd = x.snd - y.snd :=
rfl
@[simp]
theorem neg_fst : (-x).fst = -x.fst :=
rfl
@[simp]
theorem neg_snd : (-x).snd = -x.snd :=
rfl
end AddCommGroup
@[simp]
theorem smul_fst : (c • x).fst = c • x.fst :=
rfl
@[simp]
theorem smul_snd : (c • x).snd = c • x.snd :=
rfl
/-! Note that the unapplied versions of these lemmas are deliberately omitted, as they break
the use of the type synonym. -/
@[simp]
theorem equiv_fst (x : C⋆ᵐᵒᵈ(A, E × F)) : (equiv A (E × F) x).fst = x.fst :=
rfl
@[simp]
theorem equiv_snd (x : C⋆ᵐᵒᵈ(A, E × F)) : (equiv A (E × F) x).snd = x.snd :=
rfl
@[simp]
theorem equiv_symm_fst (x : E × F) : ((equiv A (E × F)).symm x).fst = x.fst :=
rfl
@[simp]
theorem equiv_symm_snd (x : E × F) : ((equiv A (E × F)).symm x).snd = x.snd :=
rfl
end Prod
/-! ## Pi
Register simplification lemmas for the applications of `WithCStarModule (Π i, E i)` elements, as
the usual lemmas for `Pi` will not trigger.
We also provide a `CoeFun` instance for `WithCStarModule (Π i, E i)`. -/
section Pi
/- The following should not be a `FunLike` instance because then the coercion `⇑` would get
unfolded to `FunLike.coe` instead of `WithCStarModule.equiv`. -/
instance {A ι : Type*} (E : ι → Type*) : CoeFun (C⋆ᵐᵒᵈ(A, Π i, E i)) (fun _ ↦ Π i, E i) where
coe := equiv _ _
@[ext]
protected theorem ext {A ι : Type*} {E : ι → Type*} {x y : C⋆ᵐᵒᵈ(A, Π i, E i)}
(h : ∀ i, x i = y i) : x = y :=
funext h
variable {R A ι : Type*} {E : ι → Type*}
variable [∀ i, SMul R (E i)]
variable (c : R) (x y : C⋆ᵐᵒᵈ(A, Π i, E i)) (i : ι)
section AddCommGroup
variable [∀ i, AddCommGroup (E i)]
@[simp]
theorem zero_apply : (0 : C⋆ᵐᵒᵈ(A, Π i, E i)) i = 0 :=
rfl
@[simp]
theorem add_apply : (x + y) i = x i + y i :=
rfl
@[simp]
theorem sub_apply : (x - y) i = x i - y i :=
rfl
@[simp]
theorem neg_apply : (-x) i = -x i :=
rfl
end AddCommGroup
@[simp]
theorem smul_apply : (c • x) i = c • x i :=
rfl
/-! Note that the unapplied versions of these lemmas are deliberately omitted, as they break
the use of the type synonym. -/
@[simp]
theorem equiv_pi_apply (i : ι) : equiv _ _ x i = x i :=
rfl
@[simp]
theorem equiv_symm_pi_apply (x : ∀ i, E i) (i : ι) :
(equiv A _).symm x i = x i :=
rfl
end Pi
end WithCStarModule |
.lake/packages/mathlib/Mathlib/Analysis/CStarAlgebra/Module/Constructions.lean | import Mathlib.Analysis.CStarAlgebra.Module.Defs
import Mathlib.Analysis.CStarAlgebra.Module.Synonym
import Mathlib.Topology.MetricSpace.Bilipschitz
/-! # Constructions of Hilbert C⋆-modules
In this file we define the following constructions of `CStarModule`s where `A` denotes a C⋆-algebra.
For some of the types listed below, the instance is declared on the type synonym `WithCStarModule E`
(with the notation `C⋆ᵐᵒᵈ E`), instead of on `E` itself; we explain the reasoning behind each
decision below.
1. `A` as a `CStarModule` over itself.
2. `C⋆ᵐᵒᵈ(A, E × F)` as a `CStarModule` over `A`, when `E` and `F` are themselves `CStarModule`s
over `A`.
3. `C⋆ᵐᵒᵈ (A, Π i : ι, E i)` as a `CStarModule` over `A`, when each `E i` is a `CStarModule` over
`A` and `ι` is a `Fintype`.
4. `E` as a `CStarModule` over `ℂ`, when `E` is an `InnerProductSpace` over `ℂ`.
For `E × F` and `Π i : ι, E i`, we are required to declare the instance on a type synonym rather
than on the product or pi-type itself because the existing norm on these types does not agree with
the one induced by the C⋆-module structure. Moreover, the norm induced by the C⋆-module structure
doesn't agree with any other natural norm on these types (e.g., `WithLp 2 (E × F)` unless `A := ℂ`),
so we need a new synonym.
On `A` (a C⋆-algebra) and `E` (an inner product space), we declare the instances on the types
themselves to ease the use of the C⋆-module structure. This does have the potential to cause
inconvenience (as sometimes Lean will see terms of type `A` and apply lemmas pertaining to
C⋆-modules to those terms, when the lemmas were actually intended for terms of some other
C⋆-module in context, say `F`, in which case the arguments must be provided explicitly; see for
instance the application of `CStarModule.norm_eq_sqrt_norm_inner_self` in the proof of
`WithCStarModule.max_le_prod_norm` below). However, we believe that this, hopefully rare,
inconvenience is outweighed by avoiding translating between type synonyms where possible.
For more details on the importance of the `WithCStarModule` type synonym, see the module
documentation for `Analysis.CStarAlgebra.Module.Synonym`.
## Implementation notes
When `A := ℂ` and `E := ℂ`, then `ℂ` is both a C⋆-algebra (so it inherits a `CStarModule` instance
via (1) above) and an inner product space (so it inherits a `CStarModule` instance via (4) above).
We provide a sanity check ensuring that these two instances are definitionally equal. We also ensure
that the `Inner ℂ ℂ` instance from `InnerProductSpace` is definitionally equal to the one inherited
from the `CStarModule` instances.
Note that `C⋆ᵐᵒᵈ(A, E)` is *already* equipped with a bornology and uniformity whenever `E` is
(namely, the pullback of the respective structures through `WithCStarModule.equiv`), so in each of
the above cases, it is necessary to temporarily instantiate `C⋆ᵐᵒᵈ(A, E)` with
`CStarModule.normedAddCommGroup`, show the resulting type is bilipschitz equivalent to `E` via
`WithCStarModule.equiv` (in the first and last case, this map is actually trivially an isometry),
and then replace the uniformity and bornology with the correct ones.
-/
open CStarModule CStarRing
namespace WithCStarModule
variable {A : Type*} [NonUnitalCStarAlgebra A] [PartialOrder A]
/-! ## A C⋆-algebra as a C⋆-module over itself -/
section Self
variable [StarOrderedRing A]
/-- Reinterpret a C⋆-algebra `A` as a `CStarModule` over itself. -/
instance : CStarModule A A where
inner x y := y * star x
inner_add_right := add_mul ..
inner_self_nonneg := mul_star_self_nonneg _
inner_self := CStarRing.mul_star_self_eq_zero_iff _
inner_op_smul_right := mul_assoc ..
inner_smul_right_complex := smul_mul_assoc ..
star_inner x y := by simp
norm_eq_sqrt_norm_inner_self {x} := by
rw [← sq_eq_sq₀ (norm_nonneg _) (by positivity)]
simpa [sq] using Eq.symm <| CStarRing.norm_self_mul_star
open scoped InnerProductSpace in
lemma inner_def (x y : A) : ⟪x, y⟫_A = y * star x := rfl
end Self
/-! ## Products of C⋆-modules -/
section Prod
open scoped InnerProductSpace
variable {E F : Type*}
variable [NormedAddCommGroup E] [Module ℂ E] [SMul A E]
variable [NormedAddCommGroup F] [Module ℂ F] [SMul A F]
variable [CStarModule A E] [CStarModule A F]
noncomputable instance : Norm C⋆ᵐᵒᵈ(A, E × F) where
norm x := √‖⟪x.1, x.1⟫_A + ⟪x.2, x.2⟫_A‖
lemma prod_norm (x : C⋆ᵐᵒᵈ(A, E × F)) : ‖x‖ = √‖⟪x.1, x.1⟫_A + ⟪x.2, x.2⟫_A‖ := rfl
lemma prod_norm_sq (x : C⋆ᵐᵒᵈ(A, E × F)) : ‖x‖ ^ 2 = ‖⟪x.1, x.1⟫_A + ⟪x.2, x.2⟫_A‖ := by
simp [prod_norm]
lemma prod_norm_le_norm_add (x : C⋆ᵐᵒᵈ(A, E × F)) : ‖x‖ ≤ ‖x.1‖ + ‖x.2‖ := by
refine abs_le_of_sq_le_sq' ?_ (by positivity) |>.2
calc ‖x‖ ^ 2 ≤ ‖⟪x.1, x.1⟫_A‖ + ‖⟪x.2, x.2⟫_A‖ := prod_norm_sq x ▸ norm_add_le _ _
_ = ‖x.1‖ ^ 2 + 0 + ‖x.2‖ ^ 2 := by simp [norm_sq_eq A]
_ ≤ ‖x.1‖ ^ 2 + 2 * ‖x.1‖ * ‖x.2‖ + ‖x.2‖ ^ 2 := by gcongr; positivity
_ = (‖x.1‖ + ‖x.2‖) ^ 2 := by ring
variable [StarOrderedRing A]
noncomputable instance : CStarModule A C⋆ᵐᵒᵈ(A, E × F) where
inner x y := ⟪x.1, y.1⟫_A + ⟪x.2, y.2⟫_A
inner_add_right {x y z} := by simpa using add_add_add_comm ..
inner_self_nonneg := add_nonneg CStarModule.inner_self_nonneg CStarModule.inner_self_nonneg
inner_self {x} := by
refine ⟨fun h ↦ ?_, fun h ↦ by simp [h]⟩
apply equiv A (E × F) |>.injective
ext
· refine inner_self.mp <| le_antisymm ?_ (inner_self_nonneg (A := A))
exact le_add_of_nonneg_right CStarModule.inner_self_nonneg |>.trans_eq h
· refine inner_self.mp <| le_antisymm ?_ (inner_self_nonneg (A := A))
exact le_add_of_nonneg_left CStarModule.inner_self_nonneg |>.trans_eq h
inner_op_smul_right := by simp [mul_add]
inner_smul_right_complex := by simp [smul_add]
star_inner x y := by simp
norm_eq_sqrt_norm_inner_self {x} := by with_reducible_and_instances rfl
lemma prod_inner (x y : C⋆ᵐᵒᵈ(A, E × F)) : ⟪x, y⟫_A = ⟪x.1, y.1⟫_A + ⟪x.2, y.2⟫_A := rfl
lemma max_le_prod_norm (x : C⋆ᵐᵒᵈ(A, E × F)) : max ‖x.1‖ ‖x.2‖ ≤ ‖x‖ := by
rw [prod_norm]
simp only [norm_eq_sqrt_norm_inner_self (A := A) (E := E),
norm_eq_sqrt_norm_inner_self (A := A) (E := F), max_le_iff, norm_nonneg,
Real.sqrt_le_sqrt_iff]
constructor
all_goals
refine CStarAlgebra.norm_le_norm_of_nonneg_of_le (A := A) ?_ ?_
all_goals
aesop (add safe apply CStarModule.inner_self_nonneg)
lemma norm_equiv_le_norm_prod (x : C⋆ᵐᵒᵈ(A, E × F)) : ‖equiv A (E × F) x‖ ≤ ‖x‖ :=
max_le_prod_norm x
section Aux
-- We temporarily disable the uniform space and bornology on `C⋆ᵐᵒᵈ A` while proving
-- that those induced by the new norm are equal to the old ones.
attribute [-instance] WithCStarModule.instUniformSpace WithCStarModule.instBornology
/-- A normed additive commutative group structure on `C⋆ᵐᵒᵈ(A, E × F)` with the wrong topology,
uniformity and bornology. This is only used to build the instance with the correct forgetful
inheritance data. -/
noncomputable def normedAddCommGroupProdAux : NormedAddCommGroup C⋆ᵐᵒᵈ(A, E × F) :=
NormedAddCommGroup.ofCore (CStarModule.normedSpaceCore A)
attribute [local instance] normedAddCommGroupProdAux
open Filter Uniformity Bornology
private lemma antilipschitzWith_two_equiv_prod_aux : AntilipschitzWith 2 (equiv A (E × F)) :=
AddMonoidHomClass.antilipschitz_of_bound (linearEquiv ℂ A (E × F)) fun x ↦ by
apply prod_norm_le_norm_add x |>.trans
simp only [NNReal.coe_ofNat, linearEquiv_apply, two_mul]
gcongr
· exact norm_fst_le x
· exact norm_snd_le x
private lemma lipschitzWith_one_equiv_prod_aux : LipschitzWith 1 (equiv A (E × F)) :=
AddMonoidHomClass.lipschitz_of_bound_nnnorm (linearEquiv ℂ A (E × F)) 1 <| by
simpa using norm_equiv_le_norm_prod
private lemma uniformity_prod_eq_aux :
𝓤[(inferInstance : UniformSpace (E × F)).comap <| equiv _ _] = 𝓤 C⋆ᵐᵒᵈ(A, E × F) :=
uniformity_eq_of_bilipschitz antilipschitzWith_two_equiv_prod_aux lipschitzWith_one_equiv_prod_aux
private lemma isBounded_prod_iff_aux (s : Set C⋆ᵐᵒᵈ(A, E × F)) :
@IsBounded _ (induced <| equiv A (E × F)) s ↔ IsBounded s :=
isBounded_iff_of_bilipschitz antilipschitzWith_two_equiv_prod_aux
lipschitzWith_one_equiv_prod_aux s
end Aux
noncomputable instance : NormedAddCommGroup C⋆ᵐᵒᵈ(A, E × F) :=
.ofCoreReplaceAll (normedSpaceCore A) uniformity_prod_eq_aux isBounded_prod_iff_aux
noncomputable instance : NormedSpace ℂ C⋆ᵐᵒᵈ(A, E × F) := .ofCore (normedSpaceCore A)
end Prod
/-! ## Pi-types of C⋆-modules -/
section Pi
open scoped InnerProductSpace
variable {ι : Type*} {E : ι → Type*} [Fintype ι]
variable [∀ i, NormedAddCommGroup (E i)] [∀ i, Module ℂ (E i)] [∀ i, SMul A (E i)]
variable [∀ i, CStarModule A (E i)]
noncomputable instance : Norm C⋆ᵐᵒᵈ(A, Π i, E i) where
norm x := √‖∑ i, ⟪x i, x i⟫_A‖
lemma pi_norm (x : C⋆ᵐᵒᵈ(A, Π i, E i)) : ‖x‖ = √‖∑ i, ⟪x i, x i⟫_A‖ := by
with_reducible_and_instances rfl
lemma pi_norm_sq (x : C⋆ᵐᵒᵈ(A, Π i, E i)) : ‖x‖ ^ 2 = ‖∑ i, ⟪x i, x i⟫_A‖ := by
simp [pi_norm]
open Finset in
lemma pi_norm_le_sum_norm (x : C⋆ᵐᵒᵈ(A, Π i, E i)) : ‖x‖ ≤ ∑ i, ‖x i‖ := by
refine abs_le_of_sq_le_sq' ?_ (by positivity) |>.2
calc ‖x‖ ^ 2 ≤ ∑ i, ‖⟪x i, x i⟫_A‖ := pi_norm_sq x ▸ norm_sum_le _ _
_ = ∑ i, ‖x i‖ ^ 2 := by simp only [norm_sq_eq A]
_ ≤ (∑ i, ‖x i‖) ^ 2 := sum_sq_le_sq_sum_of_nonneg (fun _ _ ↦ norm_nonneg _)
variable [StarOrderedRing A]
open Finset in
noncomputable instance : CStarModule A C⋆ᵐᵒᵈ(A, Π i, E i) where
inner x y := ∑ i, ⟪x i, y i⟫_A
inner_add_right {x y z} := by simp [sum_add_distrib]
inner_self_nonneg := sum_nonneg <| fun _ _ ↦ CStarModule.inner_self_nonneg
inner_self {x} := by
refine ⟨fun h ↦ ?_, fun h ↦ by simp [h]⟩
ext i
refine inner_self.mp <| le_antisymm (le_of_le_of_eq ?_ h) inner_self_nonneg
exact single_le_sum (fun i _ ↦ CStarModule.inner_self_nonneg (A := A) (x := x i)) (mem_univ _)
inner_op_smul_right := by simp [mul_sum]
inner_smul_right_complex := by simp [smul_sum]
star_inner x y := by simp
norm_eq_sqrt_norm_inner_self {x} := by with_reducible_and_instances rfl
lemma pi_inner (x y : C⋆ᵐᵒᵈ(A, Π i, E i)) : ⟪x, y⟫_A = ∑ i, ⟪x i, y i⟫_A := rfl
@[simp]
lemma inner_single_left [DecidableEq ι] (x : C⋆ᵐᵒᵈ(A, Π i, E i)) {i : ι} (y : E i) :
⟪equiv _ _ |>.symm <| Pi.single i y, x⟫_A = ⟪y, x i⟫_A := by
simp only [pi_inner, equiv_symm_pi_apply]
rw [Finset.sum_eq_single i]
all_goals simp_all
@[simp]
lemma inner_single_right [DecidableEq ι] (x : C⋆ᵐᵒᵈ(A, Π i, E i)) {i : ι} (y : E i) :
⟪x, equiv _ _ |>.symm <| Pi.single i y⟫_A = ⟪x i, y⟫_A := by
simp only [pi_inner, equiv_symm_pi_apply]
rw [Finset.sum_eq_single i]
all_goals simp_all
@[simp]
lemma norm_single [DecidableEq ι] (i : ι) (y : E i) :
‖equiv A _ |>.symm <| Pi.single i y‖ = ‖y‖ := by
let _ : NormedAddCommGroup C⋆ᵐᵒᵈ(A, Π i, E i) := normedAddCommGroup A
rw [← sq_eq_sq₀ (by positivity) (by positivity)]
simp [norm_sq_eq A]
lemma norm_apply_le_norm (x : C⋆ᵐᵒᵈ(A, Π i, E i)) (i : ι) : ‖x i‖ ≤ ‖x‖ := by
let _ : NormedAddCommGroup C⋆ᵐᵒᵈ(A, Π i, E i) := normedAddCommGroup A
refine abs_le_of_sq_le_sq' ?_ (by positivity) |>.2
rw [pi_norm_sq, norm_sq_eq A]
refine CStarAlgebra.norm_le_norm_of_nonneg_of_le inner_self_nonneg ?_
exact Finset.single_le_sum (fun j _ ↦ inner_self_nonneg (A := A) (x := x j)) (Finset.mem_univ i)
open Finset in
lemma norm_equiv_le_norm_pi (x : C⋆ᵐᵒᵈ(A, Π i, E i)) : ‖equiv _ _ x‖ ≤ ‖x‖ := by
let _ : NormedAddCommGroup C⋆ᵐᵒᵈ(A, Π i, E i) := normedAddCommGroup A
rw [pi_norm_le_iff_of_nonneg (by positivity)]
simpa using norm_apply_le_norm x
section Aux
-- We temporarily disable the uniform space and bornology on `C⋆ᵐᵒᵈ A` while proving
-- that those induced by the new norm are equal to the old ones.
attribute [-instance] WithCStarModule.instUniformSpace WithCStarModule.instBornology
/-- A normed additive commutative group structure on `C⋆ᵐᵒᵈ(A, Π i, E i)` with the wrong topology,
uniformity and bornology. This is only used to build the instance with the correct forgetful
inheritance data. -/
noncomputable def normedAddCommGroupPiAux : NormedAddCommGroup C⋆ᵐᵒᵈ(A, Π i, E i) :=
NormedAddCommGroup.ofCore (CStarModule.normedSpaceCore A)
attribute [local instance] normedAddCommGroupPiAux
open Uniformity Bornology
private lemma antilipschitzWith_card_equiv_pi_aux :
AntilipschitzWith (Fintype.card ι) (equiv A (Π i, E i)) :=
AddMonoidHomClass.antilipschitz_of_bound (linearEquiv ℂ A (Π i, E i)) fun x ↦ by
simp only [NNReal.coe_natCast, linearEquiv_apply]
calc ‖x‖ ≤ ∑ i, ‖x i‖ := pi_norm_le_sum_norm x
_ ≤ ∑ _, ‖⇑x‖ := Finset.sum_le_sum fun _ _ ↦ norm_le_pi_norm ..
_ ≤ Fintype.card ι * ‖⇑x‖ := by simp
private lemma lipschitzWith_one_equiv_pi_aux : LipschitzWith 1 (equiv A (Π i, E i)) :=
AddMonoidHomClass.lipschitz_of_bound_nnnorm (linearEquiv ℂ A (Π i, E i)) 1 <| by
simpa using norm_equiv_le_norm_pi
private lemma uniformity_pi_eq_aux :
𝓤[(inferInstance : UniformSpace (Π i, E i)).comap <| equiv A _] = 𝓤 C⋆ᵐᵒᵈ(A, Π i, E i) :=
uniformity_eq_of_bilipschitz antilipschitzWith_card_equiv_pi_aux lipschitzWith_one_equiv_pi_aux
private lemma isBounded_pi_iff_aux (s : Set C⋆ᵐᵒᵈ(A, Π i, E i)) :
@IsBounded _ (induced <| equiv A (Π i, E i)) s ↔ IsBounded s :=
isBounded_iff_of_bilipschitz antilipschitzWith_card_equiv_pi_aux lipschitzWith_one_equiv_pi_aux s
end Aux
noncomputable instance : NormedAddCommGroup C⋆ᵐᵒᵈ(A, Π i, E i) :=
.ofCoreReplaceAll (normedSpaceCore A) uniformity_pi_eq_aux isBounded_pi_iff_aux
noncomputable instance : NormedSpace ℂ C⋆ᵐᵒᵈ(A, Π i, E i) := .ofCore (normedSpaceCore A)
end Pi
/-! ## Inner product spaces as C⋆-modules -/
section InnerProductSpace
open ComplexOrder
variable {E : Type*}
variable [NormedAddCommGroup E] [InnerProductSpace ℂ E]
open scoped InnerProductSpace in
/-- Reinterpret an inner product space `E` over `ℂ` as a `CStarModule` over `ℂ`.
Note: this instance requires `SMul ℂᵐᵒᵖ E` and `IsCentralScalar ℂ E` instances to exist on `E`,
which is unlikely to occur in practice. However, in practice one could either add those instances
to the type `E` in question, or else supply them to this instance manually, which is reason behind
the naming of these two instance arguments. -/
instance instCStarModuleComplex : CStarModule ℂ E where
inner x y := ⟪x, y⟫_ℂ
inner_add_right := by simp [_root_.inner_add_right]
inner_self_nonneg {x} := by
rw [← inner_self_ofReal_re, RCLike.ofReal_nonneg]
exact inner_self_nonneg
inner_self := by simp
inner_op_smul_right := by simp [inner_smul_right]
inner_smul_right_complex := by simp [inner_smul_right, smul_eq_mul]
star_inner _ _ := by simp
norm_eq_sqrt_norm_inner_self {x} := by
simpa only [← inner_self_re_eq_norm] using norm_eq_sqrt_re_inner x
-- Ensures that the two ways to obtain `CStarModule ℂᵐᵒᵖ ℂ` are definitionally equal.
example : instCStarModule (A := ℂ) = instCStarModuleComplex := by with_reducible_and_instances rfl
/- Ensures that the two `Inner ℂ ℂ` instances are definitionally equal. Note that this cannot be at
reducible and instances transparency because the one from `InnerProductSpace` uses `StarRingEnd`
whereas `WithCStarModule.instCStarModule.toInner` uses `star` since `A` may not be commutative. -/
example : (toInner : Inner ℂ ℂ) = WithCStarModule.instCStarModule.toInner := rfl
end InnerProductSpace
end WithCStarModule |
.lake/packages/mathlib/Mathlib/Analysis/CStarAlgebra/Module/Defs.lean | import Mathlib.Analysis.CStarAlgebra.ContinuousFunctionalCalculus.Order
/-!
# Hilbert C⋆-modules
A Hilbert C⋆-module is a complex module `E` together with a right `A`-module structure, where `A`
is a C⋆-algebra, and with an `A`-valued inner product. This inner product satisfies the
Cauchy-Schwarz inequality, and induces a norm that makes `E` a normed vector space over `ℂ`.
## Main declarations
+ `CStarModule`: The class containing the Hilbert C⋆-module structure
+ `CStarModule.normedSpaceCore`: The proof that a Hilbert C⋆-module is a normed vector
space. This can be used with `NormedAddCommGroup.ofCore` and `NormedSpace.ofCore` to create
the relevant instances on a type of interest.
+ `CStarModule.inner_mul_inner_swap_le`: The statement that
`⟪y, x⟫ * ⟪x, y⟫ ≤ ‖x‖ ^ 2 • ⟪y, y⟫`, which can be viewed as a version of the Cauchy-Schwarz
inequality for Hilbert C⋆-modules.
+ `CStarModule.norm_inner_le`, which states that `‖⟪x, y⟫‖ ≤ ‖x‖ * ‖y‖`, i.e. the
Cauchy-Schwarz inequality.
## Implementation notes
The class `CStarModule A E` requires `E` to already have a `Norm E` instance on it, but
no other norm-related instances. We then include the fact that this norm agrees with the norm
induced by the inner product among the axioms of the class. Furthermore, instead of registering
`NormedAddCommGroup E` and `NormedSpace ℂ E` instances (which might already be present on the type,
and which would send the type class search algorithm on a chase for `A`), we provide a
`NormedSpace.Core` structure which enables downstream users of the class to easily register
these instances themselves on a particular type.
Although the `Norm` is passed as a parameter, it almost never coincides with the norm on the
underlying type, unless that it is a purpose built type, as with the *standard Hilbert C⋆-module*.
However, with generic types already equipped with a norm, the norm as a Hilbert C⋆-module almost
never coincides with the norm on the underlying type. The two notable exceptions to this are when
we view `A` as a C⋆-module over itself, or when `A := ℂ`. For this reason we will later use the
type synonym `WithCStarModule`.
As an example of just how different the norm can be, consider `CStarModule`s `E` and `F` over `A`.
One would like to put a `CStarModule` structure on (a type synonym of) `E × F`, where the `A`-valued
inner product is given, for `x y : E × F`, `⟪x, y⟫_A := ⟪x.1, y.1⟫_A + ⟪x.2, y.2⟫_A`. The norm this
induces satisfies `‖x‖ ^ 2 = ‖⟪x.1, y.1⟫ + ⟪x.2, y.2⟫‖`, but this doesn't coincide with *any*
natural norm on `E × F` unless `A := ℂ`, in which case it is `WithLp 2 (E × F)` because `E × F` is
then an `InnerProductSpace` over `ℂ`.
## References
+ Erin Wittlich. *Formalizing Hilbert Modules in C⋆-algebras with the Lean Proof Assistant*,
December 2022. Master's thesis, Southern Illinois University Edwardsville.
-/
open scoped ComplexOrder RightActions
/-- A *Hilbert C⋆-module* is a complex module `E` endowed with a right `A`-module structure
(where `A` is typically a C⋆-algebra) and an inner product `⟪x, y⟫_A` which satisfies the
following properties. -/
class CStarModule (A E : Type*) [NonUnitalSemiring A] [StarRing A]
[Module ℂ A] [AddCommGroup E] [Module ℂ E] [PartialOrder A] [SMul A E] [Norm A] [Norm E]
extends Inner A E where
inner_add_right {x} {y} {z} : inner x (y + z) = inner x y + inner x z
inner_self_nonneg {x} : 0 ≤ inner x x
inner_self {x} : inner x x = 0 ↔ x = 0
inner_op_smul_right {a : A} {x y : E} : inner x (a • y) = a * inner x y
inner_smul_right_complex {z : ℂ} {x} {y} : inner x (z • y) = z • inner x y
star_inner x y : star (inner x y) = inner y x
norm_eq_sqrt_norm_inner_self x : ‖x‖ = √‖inner x x‖
attribute [simp] CStarModule.inner_add_right CStarModule.star_inner
CStarModule.inner_op_smul_right CStarModule.inner_smul_right_complex
namespace CStarModule
section general
variable {A E : Type*} [NonUnitalRing A] [StarRing A] [AddCommGroup E] [Module ℂ A]
[Module ℂ E] [PartialOrder A] [SMul A E] [Norm A] [Norm E] [CStarModule A E]
local notation "⟪" x ", " y "⟫" => inner A x y
@[simp]
lemma inner_add_left {x y z : E} : ⟪x + y, z⟫ = ⟪x, z⟫ + ⟪y, z⟫ := by
rw [← star_star (r := ⟪x + y, z⟫)]
simp only [inner_add_right, star_add, star_inner]
@[simp]
lemma inner_op_smul_left {a : A} {x y : E} : ⟪a • x, y⟫ = ⟪x, y⟫ * star a := by
rw [← star_inner]; simp
section StarModule
variable [StarModule ℂ A]
@[simp]
lemma inner_smul_left_complex {z : ℂ} {x y : E} : ⟪z • x, y⟫ = star z • ⟪x, y⟫ := by
rw [← star_inner]
simp
@[simp]
lemma inner_smul_left_real {z : ℝ} {x y : E} : ⟪z • x, y⟫ = z • ⟪x, y⟫ := by
have h₁ : z • x = (z : ℂ) • x := by simp
rw [h₁, ← star_inner, inner_smul_right_complex]
simp
@[simp]
lemma inner_smul_right_real {z : ℝ} {x y : E} : ⟪x, z • y⟫ = z • ⟪x, y⟫ := by
have h₁ : z • y = (z : ℂ) • y := by simp
rw [h₁, ← star_inner, inner_smul_left_complex]
simp
/-- The function `⟨x, y⟩ ↦ ⟪x, y⟫` bundled as a sesquilinear map. -/
def innerₛₗ : E →ₗ⋆[ℂ] E →ₗ[ℂ] A where
toFun x := { toFun := fun y => ⟪x, y⟫
map_add' := fun z y => by simp
map_smul' := fun z y => by simp }
map_add' z y := by ext; simp
map_smul' z y := by ext; simp
lemma innerₛₗ_apply {x y : E} : innerₛₗ x y = ⟪x, y⟫ := rfl
@[simp] lemma inner_zero_right {x : E} : ⟪x, 0⟫ = 0 := by simp [← innerₛₗ_apply]
@[simp] lemma inner_zero_left {x : E} : ⟪0, x⟫ = 0 := by simp [← innerₛₗ_apply]
@[simp] lemma inner_neg_right {x y : E} : ⟪x, -y⟫ = -⟪x, y⟫ := by simp [← innerₛₗ_apply]
@[simp] lemma inner_neg_left {x y : E} : ⟪-x, y⟫ = -⟪x, y⟫ := by simp [← innerₛₗ_apply]
@[simp] lemma inner_sub_right {x y z : E} : ⟪x, y - z⟫ = ⟪x, y⟫ - ⟪x, z⟫ := by
simp [← innerₛₗ_apply]
@[simp] lemma inner_sub_left {x y z : E} : ⟪x - y, z⟫ = ⟪x, z⟫ - ⟪y, z⟫ := by
simp [← innerₛₗ_apply]
@[simp]
lemma inner_sum_right {ι : Type*} {s : Finset ι} {x : E} {y : ι → E} :
⟪x, ∑ i ∈ s, y i⟫ = ∑ i ∈ s, ⟪x, y i⟫ :=
map_sum (innerₛₗ x) ..
@[simp]
lemma inner_sum_left {ι : Type*} {s : Finset ι} {x : ι → E} {y : E} :
⟪∑ i ∈ s, x i, y⟫ = ∑ i ∈ s, ⟪x i, y⟫ :=
map_sum (innerₛₗ.flip y) ..
end StarModule
@[simp]
lemma isSelfAdjoint_inner_self {x : E} : IsSelfAdjoint ⟪x, x⟫ := star_inner _ _
end general
section norm
variable {A E : Type*} [NonUnitalCStarAlgebra A] [PartialOrder A] [AddCommGroup E]
[Module ℂ E] [SMul A E] [Norm E] [CStarModule A E]
local notation "⟪" x ", " y "⟫" => inner A x y
open scoped InnerProductSpace in
/-- The norm associated with a Hilbert C⋆-module. It is not registered as a norm, since a type
might already have a norm defined on it. -/
noncomputable def norm (A : Type*) {E : Type*} [Norm A] [Inner A E] : Norm E where
norm x := √‖⟪x, x⟫_A‖
section
include A
variable (A)
lemma norm_sq_eq {x : E} : ‖x‖ ^ 2 = ‖⟪x, x⟫‖ := by simp [norm_eq_sqrt_norm_inner_self (A := A)]
protected lemma norm_nonneg {x : E} : 0 ≤ ‖x‖ := by simp [norm_eq_sqrt_norm_inner_self (A := A)]
protected lemma norm_pos {x : E} (hx : x ≠ 0) : 0 < ‖x‖ := by
simp only [norm_eq_sqrt_norm_inner_self (A := A), Real.sqrt_pos, norm_pos_iff]
intro H
rw [inner_self] at H
exact hx H
protected lemma norm_zero : ‖(0 : E)‖ = 0 := by simp [norm_eq_sqrt_norm_inner_self (A := A)]
lemma norm_zero_iff (x : E) : ‖x‖ = 0 ↔ x = 0 :=
⟨fun h => by simpa [norm_eq_sqrt_norm_inner_self (A := A), inner_self] using h,
fun h => by simp [h, norm_eq_sqrt_norm_inner_self (A := A)]⟩
end
variable [StarOrderedRing A]
open scoped InnerProductSpace in
/-- The C⋆-algebra-valued Cauchy-Schwarz inequality for Hilbert C⋆-modules. -/
lemma inner_mul_inner_swap_le {x y : E} : ⟪x, y⟫ * ⟪y, x⟫ ≤ ‖x‖ ^ 2 • ⟪y, y⟫ := by
rcases eq_or_ne x 0 with h|h
· simp [h, CStarModule.norm_zero A (E := E)]
· have h₁ : ∀ (a : A),
(0 : A) ≤ ‖x‖ ^ 2 • (a * star a) - ‖x‖ ^ 2 • (a * ⟪y, x⟫)
- ‖x‖ ^ 2 • (⟪x, y⟫ * star a) + ‖x‖ ^ 2 • (‖x‖ ^ 2 • ⟪y, y⟫) := fun a => by
calc (0 : A) ≤ ⟪a • x - ‖x‖ ^ 2 • y, a • x - ‖x‖ ^ 2 • y⟫_A := by
exact inner_self_nonneg
_ = a * ⟪x, x⟫ * star a - ‖x‖ ^ 2 • (a * ⟪y, x⟫)
- ‖x‖ ^ 2 • (⟪x, y⟫ * star a) + ‖x‖ ^ 2 • (‖x‖ ^ 2 • ⟪y, y⟫) := by
simp only [inner_sub_right, inner_op_smul_right, inner_sub_left,
inner_op_smul_left, inner_smul_left_real, mul_sub, mul_smul_comm,
inner_smul_right_real, smul_sub, mul_assoc]
abel
_ ≤ ‖x‖ ^ 2 • (a * star a) - ‖x‖ ^ 2 • (a * ⟪y, x⟫)
- ‖x‖ ^ 2 • (⟪x, y⟫ * star a) + ‖x‖ ^ 2 • (‖x‖ ^ 2 • ⟪y, y⟫) := by
gcongr
calc _ ≤ ‖⟪x, x⟫_A‖ • (a * star a) :=
CStarAlgebra.star_right_conjugate_le_norm_smul
_ = (√‖⟪x, x⟫_A‖) ^ 2 • (a * star a) := by
rw [Real.sq_sqrt]
positivity
_ = ‖x‖ ^ 2 • (a * star a) := by rw [← norm_eq_sqrt_norm_inner_self]
specialize h₁ ⟪x, y⟫
simp only [star_inner, sub_self, zero_sub, le_neg_add_iff_add_le, add_zero] at h₁
rwa [smul_le_smul_iff_of_pos_left (pow_pos (CStarModule.norm_pos A h) _)] at h₁
open scoped InnerProductSpace in
variable (E) in
/-- The Cauchy-Schwarz inequality for Hilbert C⋆-modules. -/
lemma norm_inner_le {x y : E} : ‖⟪x, y⟫‖ ≤ ‖x‖ * ‖y‖ := by
have := calc ‖⟪x, y⟫‖ ^ 2 = ‖⟪x, y⟫ * ⟪y, x⟫‖ := by
rw [← star_inner x, CStarRing.norm_self_mul_star, pow_two]
_ ≤ ‖‖x‖^ 2 • ⟪y, y⟫‖ := by
refine CStarAlgebra.norm_le_norm_of_nonneg_of_le ?_ inner_mul_inner_swap_le
rw [← star_inner x]
exact mul_star_self_nonneg ⟪x, y⟫_A
_ = ‖x‖ ^ 2 * ‖⟪y, y⟫‖ := by simp [norm_smul]
_ = ‖x‖ ^ 2 * ‖y‖ ^ 2 := by
simp only [norm_eq_sqrt_norm_inner_self (A := A), norm_nonneg, Real.sq_sqrt]
_ = (‖x‖ * ‖y‖) ^ 2 := by simp only [mul_pow]
refine (pow_le_pow_iff_left₀ (norm_nonneg ⟪x, y⟫_A) ?_ (by simp)).mp this
exact mul_nonneg (CStarModule.norm_nonneg A) (CStarModule.norm_nonneg A)
include A in
variable (A) in
protected lemma norm_triangle (x y : E) : ‖x + y‖ ≤ ‖x‖ + ‖y‖ := by
have h : ‖x + y‖ ^ 2 ≤ (‖x‖ + ‖y‖) ^ 2 := by
calc _ ≤ ‖⟪x, x⟫ + ⟪y, x⟫‖ + ‖⟪x, y⟫‖ + ‖⟪y, y⟫‖ := by
simp only [norm_eq_sqrt_norm_inner_self (A := A), inner_add_right, inner_add_left,
← add_assoc, norm_nonneg, Real.sq_sqrt]
exact norm_add₃_le
_ ≤ ‖⟪x, x⟫‖ + ‖⟪y, x⟫‖ + ‖⟪x, y⟫‖ + ‖⟪y, y⟫‖ := by gcongr; exact norm_add_le _ _
_ ≤ ‖⟪x, x⟫‖ + ‖y‖ * ‖x‖ + ‖x‖ * ‖y‖ + ‖⟪y, y⟫‖ := by gcongr <;> exact norm_inner_le E
_ = ‖x‖ ^ 2 + ‖y‖ * ‖x‖ + ‖x‖ * ‖y‖ + ‖y‖ ^ 2 := by
simp [norm_eq_sqrt_norm_inner_self (A := A)]
_ = (‖x‖ + ‖y‖) ^ 2 := by simp only [add_pow_two, add_left_inj]; ring
refine (pow_le_pow_iff_left₀ (CStarModule.norm_nonneg A) ?_ (by simp)).mp h
exact add_nonneg (CStarModule.norm_nonneg A) (CStarModule.norm_nonneg A)
include A in
variable (A) in
/-- This allows us to get `NormedAddCommGroup` and `NormedSpace` instances on `E` via
`NormedAddCommGroup.ofCore` and `NormedSpace.ofCore`. -/
lemma normedSpaceCore : NormedSpace.Core ℂ E where
norm_nonneg _ := (CStarModule.norm_nonneg A)
norm_eq_zero_iff x := norm_zero_iff A x
norm_smul c x := by simp [norm_eq_sqrt_norm_inner_self (A := A), norm_smul, ← mul_assoc]
norm_triangle x y := CStarModule.norm_triangle A x y
variable (A) in
/-- This is not listed as an instance because we often want to replace the topology, uniformity
and bornology instead of inheriting them from the norm. -/
abbrev normedAddCommGroup : NormedAddCommGroup E :=
NormedAddCommGroup.ofCore (CStarModule.normedSpaceCore A)
open scoped InnerProductSpace in
lemma norm_eq_csSup (v : E) :
‖v‖ = sSup { ‖⟪w, v⟫_A‖ | (w : E) (_ : ‖w‖ ≤ 1) } := by
let instNACG : NormedAddCommGroup E := NormedAddCommGroup.ofCore (normedSpaceCore A)
let instNS : NormedSpace ℂ E := .ofCore (normedSpaceCore A)
refine Eq.symm <| IsGreatest.csSup_eq ⟨⟨‖v‖⁻¹ • v, ?_, ?_⟩, ?_⟩
· simpa only [norm_smul, norm_inv, norm_norm] using inv_mul_le_one_of_le₀ le_rfl (by positivity)
· simp [norm_smul, ← norm_sq_eq, pow_two, ← mul_assoc]
· rintro - ⟨w, hw, rfl⟩
calc _ ≤ ‖w‖ * ‖v‖ := norm_inner_le E
_ ≤ 1 * ‖v‖ := by gcongr
_ = ‖v‖ := by simp
end norm
section NormedAddCommGroup
open scoped InnerProductSpace
/- Note: one generally creates a `CStarModule` instance for a type `E` first before getting the
`NormedAddCommGroup` and `NormedSpace` instances via `CStarModule.normedSpaceCore`, especially by
using `NormedAddCommGroup.ofCoreReplaceAll` and `NormedSpace.ofCore`. See
`Analysis.CStarAlgebra.Module.Constructions` for examples. -/
variable {A E : Type*} [NonUnitalCStarAlgebra A] [PartialOrder A] [StarOrderedRing A] [SMul A E]
[NormedAddCommGroup E] [NormedSpace ℂ E] [CStarModule A E]
/-- The function `⟨x, y⟩ ↦ ⟪x, y⟫` bundled as a continuous sesquilinear map. -/
noncomputable def innerSL : E →L⋆[ℂ] E →L[ℂ] A :=
LinearMap.mkContinuous₂ (innerₛₗ : E →ₗ⋆[ℂ] E →ₗ[ℂ] A) 1 <| fun x y => by
simp [innerₛₗ_apply, norm_inner_le E]
lemma innerSL_apply {x y : E} : innerSL x y = ⟪x, y⟫_A := rfl
@[continuity, fun_prop]
lemma continuous_inner : Continuous (fun x : E × E => ⟪x.1, x.2⟫_A) := by
simp_rw [← innerSL_apply]
fun_prop
end NormedAddCommGroup
end CStarModule |
.lake/packages/mathlib/Mathlib/Analysis/CStarAlgebra/SpecialFunctions/PosPart.lean | import Mathlib.Analysis.SpecialFunctions.ContinuousFunctionalCalculus.PosPart.Isometric
import Mathlib.Analysis.CStarAlgebra.ContinuousFunctionalCalculus.Basic
/-! # C⋆-algebraic facts about `a⁺` and `a⁻`. -/
variable {A : Type*} [NonUnitalCStarAlgebra A] [PartialOrder A] [StarOrderedRing A]
namespace CStarAlgebra
section SpanNonneg
open Submodule
/-- A C⋆-algebra is spanned by nonnegative elements of norm at most `r` -/
lemma span_nonneg_inter_closedBall {r : ℝ} (hr : 0 < r) :
span ℂ ({x : A | 0 ≤ x} ∩ Metric.closedBall 0 r) = ⊤ := by
rw [eq_top_iff, ← span_nonneg, span_le]
intro x hx
obtain (rfl | hx_pos) := eq_zero_or_norm_pos x
· exact zero_mem _
· suffices (r * ‖x‖⁻¹ : ℂ)⁻¹ • ((r * ‖x‖⁻¹ : ℂ) • x) = x by
rw [← this]
refine smul_mem _ _ (subset_span <| Set.mem_inter ?_ ?_)
· norm_cast
exact smul_nonneg (by positivity) hx
· simp [mul_smul, norm_smul, abs_of_pos hr, inv_mul_cancel₀ hx_pos.ne']
apply inv_smul_smul₀
norm_cast
positivity
/-- A C⋆-algebra is spanned by nonnegative elements of norm less than `r`. -/
lemma span_nonneg_inter_ball {r : ℝ} (hr : 0 < r) :
span ℂ ({x : A | 0 ≤ x} ∩ Metric.ball 0 r) = ⊤ := by
rw [eq_top_iff, ← span_nonneg_inter_closedBall (half_pos hr)]
gcongr
exact Metric.closedBall_subset_ball <| half_lt_self hr
/-- A C⋆-algebra is spanned by nonnegative contractions. -/
lemma span_nonneg_inter_unitClosedBall :
span ℂ ({x : A | 0 ≤ x} ∩ Metric.closedBall 0 1) = ⊤ :=
span_nonneg_inter_closedBall zero_lt_one
/-- A C⋆-algebra is spanned by nonnegative strict contractions. -/
lemma span_nonneg_inter_unitBall :
span ℂ ({x : A | 0 ≤ x} ∩ Metric.ball 0 1) = ⊤ :=
span_nonneg_inter_ball zero_lt_one
end SpanNonneg
open Complex in
lemma exists_sum_four_nonneg {A : Type*} [NonUnitalCStarAlgebra A] [PartialOrder A]
[StarOrderedRing A] (a : A) :
∃ x : Fin 4 → A, (∀ i, 0 ≤ x i) ∧ (∀ i, ‖x i‖ ≤ ‖a‖) ∧ a = ∑ i : Fin 4, I ^ (i : ℕ) • x i := by
use ![(realPart a)⁺, (imaginaryPart a)⁺, (realPart a)⁻, (imaginaryPart a)⁻]
rw [← and_assoc, ← forall_and]
constructor
· intro i
fin_cases i
all_goals
constructor
· simp
cfc_tac
· exact CStarAlgebra.norm_posPart_le _ |>.trans <| realPart.norm_le a
· exact CStarAlgebra.norm_posPart_le _ |>.trans <| imaginaryPart.norm_le a
· exact CStarAlgebra.norm_negPart_le _ |>.trans <| realPart.norm_le a
· exact CStarAlgebra.norm_negPart_le _ |>.trans <| imaginaryPart.norm_le a
· nth_rw 1 [← CStarAlgebra.linear_combination_nonneg a]
simp only [Fin.sum_univ_four, Fin.coe_ofNat_eq_mod, Matrix.cons_val, Nat.reduceMod, I_sq,
I_pow_three]
module
end CStarAlgebra |
.lake/packages/mathlib/Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Isometric.lean | import Mathlib.Analysis.CStarAlgebra.ContinuousFunctionalCalculus.Instances
/-! # Isometric continuous functional calculus
This file adds a class for an *isometric* continuous functional calculus. This is separate from the
usual `ContinuousFunctionalCalculus` class because we prefer not to require a metric (or a norm) on
the algebra for reasons discussed in the module documentation for that file.
Of course, with a metric on the algebra and an isometric continuous functional calculus, the
algebra must *be* a C⋆-algebra already. As such, it may seem like this class is not useful. However,
the main purpose is to allow for the continuous functional calculus to be a isometric for the other
scalar rings `ℝ` and `ℝ≥0` too.
-/
local notation "σ" => spectrum
local notation "σₙ" => quasispectrum
/-! ### Isometric continuous functional calculus for unital algebras -/
section Unital
/-- An extension of the `ContinuousFunctionalCalculus` requiring that `cfcHom` is an isometry. -/
class IsometricContinuousFunctionalCalculus (R A : Type*) (p : outParam (A → Prop))
[CommSemiring R] [StarRing R] [MetricSpace R] [IsTopologicalSemiring R] [ContinuousStar R]
[Ring A] [StarRing A] [MetricSpace A] [Algebra R A] : Prop
extends ContinuousFunctionalCalculus R A p where
isometric (a : A) (ha : p a) : Isometry (cfcHom ha (R := R))
section MetricSpace
open scoped ContinuousFunctionalCalculus
lemma isometry_cfcHom {R A : Type*} {p : outParam (A → Prop)} [CommSemiring R] [StarRing R]
[MetricSpace R] [IsTopologicalSemiring R] [ContinuousStar R] [Ring A] [StarRing A]
[MetricSpace A] [Algebra R A] [IsometricContinuousFunctionalCalculus R A p]
(a : A) (ha : p a := by cfc_tac) :
Isometry (cfcHom (show p a from ha) (R := R)) :=
IsometricContinuousFunctionalCalculus.isometric a ha
end MetricSpace
section NormedRing
open scoped ContinuousFunctionalCalculus
variable {𝕜 A : Type*} {p : outParam (A → Prop)}
variable [RCLike 𝕜] [NormedRing A] [StarRing A] [NormedAlgebra 𝕜 A]
variable [IsometricContinuousFunctionalCalculus 𝕜 A p]
lemma norm_cfcHom (a : A) (f : C(σ 𝕜 a, 𝕜)) (ha : p a := by cfc_tac) :
‖cfcHom (show p a from ha) f‖ = ‖f‖ := by
refine isometry_cfcHom a |>.norm_map_of_map_zero (map_zero _) f
lemma nnnorm_cfcHom (a : A) (f : C(σ 𝕜 a, 𝕜)) (ha : p a := by cfc_tac) :
‖cfcHom (show p a from ha) f‖₊ = ‖f‖₊ :=
Subtype.ext <| norm_cfcHom a f ha
lemma IsGreatest.norm_cfc [Nontrivial A] (f : 𝕜 → 𝕜) (a : A)
(hf : ContinuousOn f (σ 𝕜 a) := by cfc_cont_tac) (ha : p a := by cfc_tac) :
IsGreatest ((fun x ↦ ‖f x‖) '' spectrum 𝕜 a) ‖cfc f a‖ := by
obtain ⟨x, hx⟩ := ContinuousFunctionalCalculus.isCompact_spectrum a
|>.image_of_continuousOn hf.norm |>.exists_isGreatest <|
(ContinuousFunctionalCalculus.spectrum_nonempty a ha).image _
obtain ⟨x, hx', rfl⟩ := hx.1
convert hx
rw [cfc_apply f a, norm_cfcHom a _]
apply le_antisymm
· apply ContinuousMap.norm_le _ (norm_nonneg _) |>.mpr
rintro ⟨y, hy⟩
exact hx.2 ⟨y, hy, rfl⟩
· exact le_trans (by simp) <| ContinuousMap.norm_coe_le_norm _ (⟨x, hx'⟩ : σ 𝕜 a)
lemma IsGreatest.nnnorm_cfc [Nontrivial A] (f : 𝕜 → 𝕜) (a : A)
(hf : ContinuousOn f (σ 𝕜 a) := by cfc_cont_tac) (ha : p a := by cfc_tac) :
IsGreatest ((fun x ↦ ‖f x‖₊) '' σ 𝕜 a) ‖cfc f a‖₊ := by
convert Real.toNNReal_monotone.map_isGreatest (.norm_cfc f a)
all_goals simp [Set.image_image, norm_toNNReal]
lemma norm_apply_le_norm_cfc (f : 𝕜 → 𝕜) (a : A) ⦃x : 𝕜⦄ (hx : x ∈ σ 𝕜 a)
(hf : ContinuousOn f (σ 𝕜 a) := by cfc_cont_tac) (ha : p a := by cfc_tac) :
‖f x‖ ≤ ‖cfc f a‖ := by
revert hx
nontriviality A
exact (IsGreatest.norm_cfc f a hf ha |>.2 ⟨x, ·, rfl⟩)
lemma nnnorm_apply_le_nnnorm_cfc (f : 𝕜 → 𝕜) (a : A) ⦃x : 𝕜⦄ (hx : x ∈ σ 𝕜 a)
(hf : ContinuousOn f (σ 𝕜 a) := by cfc_cont_tac) (ha : p a := by cfc_tac) :
‖f x‖₊ ≤ ‖cfc f a‖₊ :=
norm_apply_le_norm_cfc f a hx
lemma norm_cfc_le {f : 𝕜 → 𝕜} {a : A} {c : ℝ} (hc : 0 ≤ c) (h : ∀ x ∈ σ 𝕜 a, ‖f x‖ ≤ c) :
‖cfc f a‖ ≤ c := by
obtain (_ | _) := subsingleton_or_nontrivial A
· simpa [Subsingleton.elim (cfc f a) 0]
· refine cfc_cases (‖·‖ ≤ c) a f (by simpa) fun hf ha ↦ ?_
simp only [← cfc_apply f a, isLUB_le_iff (IsGreatest.norm_cfc f a hf ha |>.isLUB)]
rintro - ⟨x, hx, rfl⟩
exact h x hx
lemma norm_cfc_le_iff (f : 𝕜 → 𝕜) (a : A) {c : ℝ} (hc : 0 ≤ c)
(hf : ContinuousOn f (σ 𝕜 a) := by cfc_cont_tac)
(ha : p a := by cfc_tac) : ‖cfc f a‖ ≤ c ↔ ∀ x ∈ σ 𝕜 a, ‖f x‖ ≤ c :=
⟨fun h _ hx ↦ norm_apply_le_norm_cfc f a hx hf ha |>.trans h, norm_cfc_le hc⟩
lemma norm_cfc_lt {f : 𝕜 → 𝕜} {a : A} {c : ℝ} (hc : 0 < c) (h : ∀ x ∈ σ 𝕜 a, ‖f x‖ < c) :
‖cfc f a‖ < c := by
obtain (_ | _) := subsingleton_or_nontrivial A
· simpa [Subsingleton.elim (cfc f a) 0]
· refine cfc_cases (‖·‖ < c) a f (by simpa) fun hf ha ↦ ?_
simp only [← cfc_apply f a, (IsGreatest.norm_cfc f a hf ha |>.lt_iff)]
rintro - ⟨x, hx, rfl⟩
exact h x hx
lemma norm_cfc_lt_iff (f : 𝕜 → 𝕜) (a : A) {c : ℝ} (hc : 0 < c)
(hf : ContinuousOn f (σ 𝕜 a) := by cfc_cont_tac)
(ha : p a := by cfc_tac) : ‖cfc f a‖ < c ↔ ∀ x ∈ σ 𝕜 a, ‖f x‖ < c :=
⟨fun h _ hx ↦ norm_apply_le_norm_cfc f a hx hf ha |>.trans_lt h, norm_cfc_lt hc⟩
open NNReal
lemma nnnorm_cfc_le {f : 𝕜 → 𝕜} {a : A} (c : ℝ≥0) (h : ∀ x ∈ σ 𝕜 a, ‖f x‖₊ ≤ c) :
‖cfc f a‖₊ ≤ c :=
norm_cfc_le c.2 h
lemma nnnorm_cfc_le_iff (f : 𝕜 → 𝕜) (a : A) (c : ℝ≥0)
(hf : ContinuousOn f (σ 𝕜 a) := by cfc_cont_tac)
(ha : p a := by cfc_tac) : ‖cfc f a‖₊ ≤ c ↔ ∀ x ∈ σ 𝕜 a, ‖f x‖₊ ≤ c :=
norm_cfc_le_iff f a c.2
lemma nnnorm_cfc_lt {f : 𝕜 → 𝕜} {a : A} {c : ℝ≥0} (hc : 0 < c) (h : ∀ x ∈ σ 𝕜 a, ‖f x‖₊ < c) :
‖cfc f a‖₊ < c :=
norm_cfc_lt hc h
lemma nnnorm_cfc_lt_iff (f : 𝕜 → 𝕜) (a : A) {c : ℝ≥0} (hc : 0 < c)
(hf : ContinuousOn f (σ 𝕜 a) := by cfc_cont_tac)
(ha : p a := by cfc_tac) : ‖cfc f a‖₊ < c ↔ ∀ x ∈ σ 𝕜 a, ‖f x‖₊ < c :=
norm_cfc_lt_iff f a hc
namespace IsometricContinuousFunctionalCalculus
lemma isGreatest_norm_spectrum [Nontrivial A] (a : A) (ha : p a := by cfc_tac) :
IsGreatest ((‖·‖) '' spectrum 𝕜 a) ‖a‖ := by
simpa only [cfc_id 𝕜 a] using IsGreatest.norm_cfc (id : 𝕜 → 𝕜) a
lemma norm_spectrum_le (a : A) ⦃x : 𝕜⦄ (hx : x ∈ σ 𝕜 a) (ha : p a := by cfc_tac) :
‖x‖ ≤ ‖a‖ := by
simpa only [cfc_id 𝕜 a] using norm_apply_le_norm_cfc (id : 𝕜 → 𝕜) a hx
lemma isGreatest_nnnorm_spectrum [Nontrivial A] (a : A) (ha : p a := by cfc_tac) :
IsGreatest ((‖·‖₊) '' spectrum 𝕜 a) ‖a‖₊ := by
simpa only [cfc_id 𝕜 a] using IsGreatest.nnnorm_cfc (id : 𝕜 → 𝕜) a
lemma nnnorm_spectrum_le (a : A) ⦃x : 𝕜⦄ (hx : x ∈ σ 𝕜 a) (ha : p a := by cfc_tac) :
‖x‖₊ ≤ ‖a‖₊ := by
simpa only [cfc_id 𝕜 a] using nnnorm_apply_le_nnnorm_cfc (id : 𝕜 → 𝕜) a hx
end IsometricContinuousFunctionalCalculus
end NormedRing
namespace SpectrumRestricts
variable {R S A : Type*} {p q : A → Prop}
variable [Semifield R] [StarRing R] [MetricSpace R] [IsTopologicalSemiring R] [ContinuousStar R]
variable [Semifield S] [StarRing S] [MetricSpace S] [IsTopologicalSemiring S] [ContinuousStar S]
variable [Ring A] [StarRing A] [Algebra S A]
variable [Algebra R S] [Algebra R A] [IsScalarTower R S A] [StarModule R S] [ContinuousSMul R S]
variable [MetricSpace A] [IsometricContinuousFunctionalCalculus S A q]
variable [CompleteSpace R] [ContinuousMap.UniqueHom R A]
open scoped ContinuousFunctionalCalculus in
protected theorem isometric_cfc (f : C(S, R)) (halg : Isometry (algebraMap R S)) (h0 : p 0)
(h : ∀ a, p a ↔ q a ∧ SpectrumRestricts a f) :
IsometricContinuousFunctionalCalculus R A p where
toContinuousFunctionalCalculus := SpectrumRestricts.cfc f halg.isUniformEmbedding h0 h
isometric a ha := by
obtain ⟨ha', haf⟩ := h a |>.mp ha
have := SpectrumRestricts.cfc f halg.isUniformEmbedding h0 h
rw [cfcHom_eq_restrict f halg.isUniformEmbedding ha ha' haf]
refine .of_dist_eq fun g₁ g₂ ↦ ?_
simp only [starAlgHom_apply, isometry_cfcHom a ha' |>.dist_eq]
refine le_antisymm ?_ ?_
all_goals refine ContinuousMap.dist_le dist_nonneg |>.mpr fun x ↦ ?_
· simpa [halg.dist_eq] using ContinuousMap.dist_apply_le_dist _
· let x' : σ S a := Subtype.map (algebraMap R S) (fun _ ↦ spectrum.algebraMap_mem S) x
apply le_of_eq_of_le ?_ <| ContinuousMap.dist_apply_le_dist x'
simp only [ContinuousMap.comp_apply, ContinuousMap.coe_mk, StarAlgHom.ofId_apply,
halg.dist_eq, x']
congr!
all_goals ext; exact haf.left_inv _ |>.symm
end SpectrumRestricts
end Unital
/-! ### Isometric continuous functional calculus for non-unital algebras -/
section NonUnital
/-- An extension of the `NonUnitalContinuousFunctionalCalculus` requiring that `cfcₙHom` is an
isometry. -/
class NonUnitalIsometricContinuousFunctionalCalculus (R A : Type*) (p : outParam (A → Prop))
[CommSemiring R] [Nontrivial R] [StarRing R] [MetricSpace R] [IsTopologicalSemiring R]
[ContinuousStar R] [NonUnitalRing A] [StarRing A] [MetricSpace A] [Module R A]
[IsScalarTower R A A] [SMulCommClass R A A] : Prop
extends NonUnitalContinuousFunctionalCalculus R A p where
isometric (a : A) (ha : p a) : Isometry (cfcₙHom ha (R := R))
section MetricSpace
variable {R A : Type*} {p : outParam (A → Prop)}
variable [CommSemiring R] [Nontrivial R] [StarRing R] [MetricSpace R] [IsTopologicalSemiring R]
variable [ContinuousStar R]
variable [NonUnitalRing A] [StarRing A] [MetricSpace A] [Module R A]
variable [IsScalarTower R A A] [SMulCommClass R A A]
open scoped NonUnitalContinuousFunctionalCalculus
variable [NonUnitalIsometricContinuousFunctionalCalculus R A p]
lemma isometry_cfcₙHom (a : A) (ha : p a := by cfc_tac) :
Isometry (cfcₙHom (show p a from ha) (R := R)) :=
NonUnitalIsometricContinuousFunctionalCalculus.isometric a ha
end MetricSpace
section NormedRing
variable {𝕜 A : Type*} {p : outParam (A → Prop)}
variable [RCLike 𝕜] [NonUnitalNormedRing A] [StarRing A] [NormedSpace 𝕜 A] [IsScalarTower 𝕜 A A]
variable [SMulCommClass 𝕜 A A]
variable [NonUnitalIsometricContinuousFunctionalCalculus 𝕜 A p]
open NonUnitalIsometricContinuousFunctionalCalculus
open scoped ContinuousMapZero NonUnitalContinuousFunctionalCalculus
lemma norm_cfcₙHom (a : A) (f : C(σₙ 𝕜 a, 𝕜)₀) (ha : p a := by cfc_tac) :
‖cfcₙHom (show p a from ha) f‖ = ‖f‖ := by
refine isometry_cfcₙHom a |>.norm_map_of_map_zero (map_zero _) f
lemma nnnorm_cfcₙHom (a : A) (f : C(σₙ 𝕜 a, 𝕜)₀) (ha : p a := by cfc_tac) :
‖cfcₙHom (show p a from ha) f‖₊ = ‖f‖₊ :=
Subtype.ext <| norm_cfcₙHom a f ha
lemma IsGreatest.norm_cfcₙ (f : 𝕜 → 𝕜) (a : A)
(hf : ContinuousOn f (σₙ 𝕜 a) := by cfc_cont_tac) (hf₀ : f 0 = 0 := by cfc_zero_tac)
(ha : p a := by cfc_tac) : IsGreatest ((fun x ↦ ‖f x‖) '' σₙ 𝕜 a) ‖cfcₙ f a‖ := by
obtain ⟨x, hx⟩ := NonUnitalContinuousFunctionalCalculus.isCompact_quasispectrum a
|>.image_of_continuousOn hf.norm |>.exists_isGreatest <|
(quasispectrum.nonempty 𝕜 a).image _
obtain ⟨x, hx', rfl⟩ := hx.1
convert hx
rw [cfcₙ_apply f a, norm_cfcₙHom a _]
apply le_antisymm
· apply ContinuousMap.norm_le _ (norm_nonneg _) |>.mpr
rintro ⟨y, hy⟩
exact hx.2 ⟨y, hy, rfl⟩
· exact le_trans (by simp) <| ContinuousMap.norm_coe_le_norm _ (⟨x, hx'⟩ : σₙ 𝕜 a)
lemma IsGreatest.nnnorm_cfcₙ (f : 𝕜 → 𝕜) (a : A)
(hf : ContinuousOn f (σₙ 𝕜 a) := by cfc_cont_tac) (hf₀ : f 0 = 0 := by cfc_zero_tac)
(ha : p a := by cfc_tac) : IsGreatest ((fun x ↦ ‖f x‖₊) '' σₙ 𝕜 a) ‖cfcₙ f a‖₊ := by
convert Real.toNNReal_monotone.map_isGreatest (.norm_cfcₙ f a)
all_goals simp [Set.image_image, norm_toNNReal]
lemma norm_apply_le_norm_cfcₙ (f : 𝕜 → 𝕜) (a : A) ⦃x : 𝕜⦄ (hx : x ∈ σₙ 𝕜 a)
(hf : ContinuousOn f (σₙ 𝕜 a) := by cfc_cont_tac) (hf₀ : f 0 = 0 := by cfc_zero_tac)
(ha : p a := by cfc_tac) : ‖f x‖ ≤ ‖cfcₙ f a‖ :=
IsGreatest.norm_cfcₙ f a hf hf₀ ha |>.2 ⟨x, hx, rfl⟩
lemma nnnorm_apply_le_nnnorm_cfcₙ (f : 𝕜 → 𝕜) (a : A) ⦃x : 𝕜⦄ (hx : x ∈ σₙ 𝕜 a)
(hf : ContinuousOn f (σₙ 𝕜 a) := by cfc_cont_tac) (hf₀ : f 0 = 0 := by cfc_zero_tac)
(ha : p a := by cfc_tac) : ‖f x‖₊ ≤ ‖cfcₙ f a‖₊ :=
IsGreatest.nnnorm_cfcₙ f a hf hf₀ ha |>.2 ⟨x, hx, rfl⟩
lemma norm_cfcₙ_le {f : 𝕜 → 𝕜} {a : A} {c : ℝ} (h : ∀ x ∈ σₙ 𝕜 a, ‖f x‖ ≤ c) :
‖cfcₙ f a‖ ≤ c := by
refine cfcₙ_cases (‖·‖ ≤ c) a f ?_ fun hf hf0 ha ↦ ?_
· simpa using (norm_nonneg _).trans <| h 0 (quasispectrum.zero_mem 𝕜 a)
· simp only [← cfcₙ_apply f a, isLUB_le_iff (IsGreatest.norm_cfcₙ f a hf hf0 ha |>.isLUB)]
rintro - ⟨x, hx, rfl⟩
exact h x hx
lemma norm_cfcₙ_le_iff (f : 𝕜 → 𝕜) (a : A) (c : ℝ)
(hf : ContinuousOn f (σₙ 𝕜 a) := by cfc_cont_tac) (hf₀ : f 0 = 0 := by cfc_zero_tac)
(ha : p a := by cfc_tac) : ‖cfcₙ f a‖ ≤ c ↔ ∀ x ∈ σₙ 𝕜 a, ‖f x‖ ≤ c :=
⟨fun h _ hx ↦ norm_apply_le_norm_cfcₙ f a hx hf hf₀ ha |>.trans h, norm_cfcₙ_le⟩
lemma norm_cfcₙ_lt {f : 𝕜 → 𝕜} {a : A} {c : ℝ} (h : ∀ x ∈ σₙ 𝕜 a, ‖f x‖ < c) :
‖cfcₙ f a‖ < c := by
refine cfcₙ_cases (‖·‖ < c) a f ?_ fun hf hf0 ha ↦ ?_
· simpa using (norm_nonneg _).trans_lt <| h 0 (quasispectrum.zero_mem 𝕜 a)
· simp only [← cfcₙ_apply f a, (IsGreatest.norm_cfcₙ f a hf hf0 ha |>.lt_iff)]
rintro - ⟨x, hx, rfl⟩
exact h x hx
lemma norm_cfcₙ_lt_iff (f : 𝕜 → 𝕜) (a : A) (c : ℝ)
(hf : ContinuousOn f (σₙ 𝕜 a) := by cfc_cont_tac) (hf₀ : f 0 = 0 := by cfc_zero_tac)
(ha : p a := by cfc_tac) : ‖cfcₙ f a‖ < c ↔ ∀ x ∈ σₙ 𝕜 a, ‖f x‖ < c :=
⟨fun h _ hx ↦ norm_apply_le_norm_cfcₙ f a hx hf hf₀ ha |>.trans_lt h, norm_cfcₙ_lt⟩
open NNReal
lemma nnnorm_cfcₙ_le {f : 𝕜 → 𝕜} {a : A} {c : ℝ≥0} (h : ∀ x ∈ σₙ 𝕜 a, ‖f x‖₊ ≤ c) :
‖cfcₙ f a‖₊ ≤ c :=
norm_cfcₙ_le h
lemma nnnorm_cfcₙ_le_iff (f : 𝕜 → 𝕜) (a : A) (c : ℝ≥0)
(hf : ContinuousOn f (σₙ 𝕜 a) := by cfc_cont_tac) (hf₀ : f 0 = 0 := by cfc_zero_tac)
(ha : p a := by cfc_tac) : ‖cfcₙ f a‖₊ ≤ c ↔ ∀ x ∈ σₙ 𝕜 a, ‖f x‖₊ ≤ c :=
norm_cfcₙ_le_iff f a c.1 hf hf₀ ha
lemma nnnorm_cfcₙ_lt {f : 𝕜 → 𝕜} {a : A} {c : ℝ≥0} (h : ∀ x ∈ σₙ 𝕜 a, ‖f x‖₊ < c) :
‖cfcₙ f a‖₊ < c :=
norm_cfcₙ_lt h
lemma nnnorm_cfcₙ_lt_iff (f : 𝕜 → 𝕜) (a : A) (c : ℝ≥0)
(hf : ContinuousOn f (σₙ 𝕜 a) := by cfc_cont_tac) (hf₀ : f 0 = 0 := by cfc_zero_tac)
(ha : p a := by cfc_tac) : ‖cfcₙ f a‖₊ < c ↔ ∀ x ∈ σₙ 𝕜 a, ‖f x‖₊ < c :=
norm_cfcₙ_lt_iff f a c.1 hf hf₀ ha
namespace NonUnitalIsometricContinuousFunctionalCalculus
lemma isGreatest_norm_quasispectrum (a : A) (ha : p a := by cfc_tac) :
IsGreatest ((‖·‖) '' σₙ 𝕜 a) ‖a‖ := by
simpa only [cfcₙ_id 𝕜 a] using IsGreatest.norm_cfcₙ (id : 𝕜 → 𝕜) a
lemma norm_quasispectrum_le (a : A) ⦃x : 𝕜⦄ (hx : x ∈ σₙ 𝕜 a) (ha : p a := by cfc_tac) :
‖x‖ ≤ ‖a‖ := by
simpa only [cfcₙ_id 𝕜 a] using norm_apply_le_norm_cfcₙ (id : 𝕜 → 𝕜) a hx
lemma isGreatest_nnnorm_quasispectrum (a : A) (ha : p a := by cfc_tac) :
IsGreatest ((‖·‖₊) '' σₙ 𝕜 a) ‖a‖₊ := by
simpa only [cfcₙ_id 𝕜 a] using IsGreatest.nnnorm_cfcₙ (id : 𝕜 → 𝕜) a
lemma nnnorm_quasispectrum_le (a : A) ⦃x : 𝕜⦄ (hx : x ∈ σₙ 𝕜 a) (ha : p a := by cfc_tac) :
‖x‖₊ ≤ ‖a‖₊ := by
simpa only [cfcₙ_id 𝕜 a] using nnnorm_apply_le_nnnorm_cfcₙ (id : 𝕜 → 𝕜) a hx
end NonUnitalIsometricContinuousFunctionalCalculus
end NormedRing
namespace QuasispectrumRestricts
open NonUnitalIsometricContinuousFunctionalCalculus
variable {R S A : Type*} {p q : A → Prop}
variable [Semifield R] [StarRing R] [MetricSpace R] [IsTopologicalSemiring R] [ContinuousStar R]
variable [Field S] [StarRing S] [MetricSpace S] [IsTopologicalRing S] [ContinuousStar S]
variable [NonUnitalRing A] [StarRing A] [Module S A] [IsScalarTower S A A]
variable [SMulCommClass S A A]
variable [Algebra R S] [Module R A] [IsScalarTower R S A] [StarModule R S] [ContinuousSMul R S]
variable [IsScalarTower R A A] [SMulCommClass R A A]
variable [MetricSpace A] [NonUnitalIsometricContinuousFunctionalCalculus S A q]
variable [CompleteSpace R] [ContinuousMapZero.UniqueHom R A]
open scoped NonUnitalContinuousFunctionalCalculus in
protected theorem isometric_cfc (f : C(S, R)) (halg : Isometry (algebraMap R S)) (h0 : p 0)
(h : ∀ a, p a ↔ q a ∧ QuasispectrumRestricts a f) :
NonUnitalIsometricContinuousFunctionalCalculus R A p where
toNonUnitalContinuousFunctionalCalculus := QuasispectrumRestricts.cfc f
halg.isUniformEmbedding h0 h
isometric a ha := by
obtain ⟨ha', haf⟩ := h a |>.mp ha
have := QuasispectrumRestricts.cfc f halg.isUniformEmbedding h0 h
rw [cfcₙHom_eq_restrict f halg.isUniformEmbedding ha ha' haf]
refine .of_dist_eq fun g₁ g₂ ↦ ?_
simp only [nonUnitalStarAlgHom_apply, isometry_cfcₙHom a ha' |>.dist_eq]
refine le_antisymm ?_ ?_
all_goals refine ContinuousMap.dist_le dist_nonneg |>.mpr fun x ↦ ?_
· simpa [halg.dist_eq] using ContinuousMap.dist_apply_le_dist _
· let x' : σₙ S a := Subtype.map (algebraMap R S) (fun _ ↦ quasispectrum.algebraMap_mem S) x
apply le_of_eq_of_le ?_ <| ContinuousMap.dist_apply_le_dist x'
simp only [ContinuousMap.coe_coe, ContinuousMapZero.comp_apply, ContinuousMapZero.coe_mk,
ContinuousMap.coe_mk, StarAlgHom.ofId_apply, halg.dist_eq, x']
congr! 2
all_goals ext; exact haf.left_inv _ |>.symm
end QuasispectrumRestricts
end NonUnital
/-! ### Instances of isometric continuous functional calculi
The instances for `ℝ` and `ℂ` can be found in
`Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Basic.lean`, as those require an actual
`CStarAlgebra` instance on `A`, whereas the one for `ℝ≥0` is simply inherited from an existing
instance for `ℝ`.
-/
section Instances
section Unital
variable {A : Type*} [NormedRing A] [PartialOrder A] [StarRing A] [StarOrderedRing A]
variable [NormedAlgebra ℝ A] [IsometricContinuousFunctionalCalculus ℝ A IsSelfAdjoint]
variable [NonnegSpectrumClass ℝ A]
open NNReal in
instance Nonneg.instIsometricContinuousFunctionalCalculus :
IsometricContinuousFunctionalCalculus ℝ≥0 A (0 ≤ ·) :=
SpectrumRestricts.isometric_cfc (q := IsSelfAdjoint) ContinuousMap.realToNNReal
isometry_subtype_coe le_rfl (fun _ ↦ nonneg_iff_isSelfAdjoint_and_quasispectrumRestricts)
end Unital
section NonUnital
variable {A : Type*} [NonUnitalNormedRing A] [PartialOrder A] [StarRing A] [StarOrderedRing A]
variable [NormedSpace ℝ A] [IsScalarTower ℝ A A] [SMulCommClass ℝ A A]
variable [NonUnitalIsometricContinuousFunctionalCalculus ℝ A IsSelfAdjoint]
variable [NonnegSpectrumClass ℝ A]
open NNReal in
instance Nonneg.instNonUnitalIsometricContinuousFunctionalCalculus :
NonUnitalIsometricContinuousFunctionalCalculus ℝ≥0 A (0 ≤ ·) :=
QuasispectrumRestricts.isometric_cfc (q := IsSelfAdjoint) ContinuousMap.realToNNReal
isometry_subtype_coe le_rfl (fun _ ↦ nonneg_iff_isSelfAdjoint_and_quasispectrumRestricts)
end NonUnital
end Instances
/-! ### Properties specific to `ℝ≥0` -/
section NNReal
open NNReal
section Unital
variable {A : Type*} [NormedRing A] [StarRing A] [NormedAlgebra ℝ A] [PartialOrder A]
variable [StarOrderedRing A] [IsometricContinuousFunctionalCalculus ℝ A IsSelfAdjoint]
variable [NonnegSpectrumClass ℝ A]
lemma IsGreatest.nnnorm_cfc_nnreal [Nontrivial A] (f : ℝ≥0 → ℝ≥0) (a : A)
(hf : ContinuousOn f (σ ℝ≥0 a) := by cfc_cont_tac) (ha : 0 ≤ a := by cfc_tac) :
IsGreatest (f '' σ ℝ≥0 a) ‖cfc f a‖₊ := by
rw [cfc_nnreal_eq_real ..]
obtain ⟨-, ha'⟩ := nonneg_iff_isSelfAdjoint_and_quasispectrumRestricts.mp ha
rw [← SpectrumRestricts] at ha'
convert IsGreatest.nnnorm_cfc (fun x : ℝ ↦ (f x.toNNReal : ℝ)) a ?hf_cont
case hf_cont => exact continuous_subtype_val.comp_continuousOn <|
ContinuousOn.comp ‹_› continuous_real_toNNReal.continuousOn <| ha'.image ▸ Set.mapsTo_image ..
ext x
constructor
all_goals rintro ⟨x, hx, rfl⟩
· exact ⟨x, spectrum.algebraMap_mem ℝ hx, by simp⟩
· exact ⟨x.toNNReal, ha'.apply_mem hx, by simp⟩
lemma apply_le_nnnorm_cfc_nnreal (f : ℝ≥0 → ℝ≥0) (a : A) ⦃x : ℝ≥0⦄ (hx : x ∈ σ ℝ≥0 a)
(hf : ContinuousOn f (σ ℝ≥0 a) := by cfc_cont_tac) (ha : 0 ≤ a := by cfc_tac) :
f x ≤ ‖cfc f a‖₊ := by
revert hx
nontriviality A
exact (IsGreatest.nnnorm_cfc_nnreal f a hf ha |>.2 ⟨x, ·, rfl⟩)
lemma nnnorm_cfc_nnreal_le {f : ℝ≥0 → ℝ≥0} {a : A} {c : ℝ≥0} (h : ∀ x ∈ σ ℝ≥0 a, f x ≤ c) :
‖cfc f a‖₊ ≤ c := by
obtain (_ | _) := subsingleton_or_nontrivial A
· rw [Subsingleton.elim (cfc f a) 0]
simp
· refine cfc_cases (‖·‖₊ ≤ c) a f (by simp) fun hf ha ↦ ?_
simp only [← cfc_apply f a, isLUB_le_iff (IsGreatest.nnnorm_cfc_nnreal f a hf ha |>.isLUB)]
rintro - ⟨x, hx, rfl⟩
exact h x hx
lemma nnnorm_cfc_nnreal_le_iff (f : ℝ≥0 → ℝ≥0) (a : A) (c : ℝ≥0)
(hf : ContinuousOn f (σ ℝ≥0 a) := by cfc_cont_tac)
(ha : 0 ≤ a := by cfc_tac) : ‖cfc f a‖₊ ≤ c ↔ ∀ x ∈ σ ℝ≥0 a, f x ≤ c :=
⟨fun h _ hx ↦ apply_le_nnnorm_cfc_nnreal f a hx hf ha |>.trans h, nnnorm_cfc_nnreal_le⟩
lemma nnnorm_cfc_nnreal_lt {f : ℝ≥0 → ℝ≥0} {a : A} {c : ℝ≥0} (hc : 0 < c)
(h : ∀ x ∈ σ ℝ≥0 a, f x < c) : ‖cfc f a‖₊ < c := by
obtain (_ | _) := subsingleton_or_nontrivial A
· rw [Subsingleton.elim (cfc f a) 0]
simpa
· refine cfc_cases (‖·‖₊ < c) a f (by simpa) fun hf ha ↦ ?_
simp only [← cfc_apply f a, (IsGreatest.nnnorm_cfc_nnreal f a hf ha |>.lt_iff)]
rintro - ⟨x, hx, rfl⟩
exact h x hx
lemma nnnorm_cfc_nnreal_lt_iff (f : ℝ≥0 → ℝ≥0) (a : A) {c : ℝ≥0} (hc : 0 < c)
(hf : ContinuousOn f (σ ℝ≥0 a) := by cfc_cont_tac)
(ha : 0 ≤ a := by cfc_tac) : ‖cfc f a‖₊ < c ↔ ∀ x ∈ σ ℝ≥0 a, f x < c :=
⟨fun h _ hx ↦ apply_le_nnnorm_cfc_nnreal f a hx hf ha |>.trans_lt h, nnnorm_cfc_nnreal_lt hc⟩
namespace IsometricContinuousFunctionalCalculus
lemma isGreatest_spectrum [Nontrivial A] (a : A) (ha : 0 ≤ a := by cfc_tac) :
IsGreatest (σ ℝ≥0 a) ‖a‖₊ := by
simpa [cfc_id ℝ≥0 a] using IsGreatest.nnnorm_cfc_nnreal id a
lemma spectrum_le (a : A) ⦃x : ℝ≥0⦄ (hx : x ∈ σ ℝ≥0 a) (ha : 0 ≤ a := by cfc_tac) :
x ≤ ‖a‖₊ := by
simpa [cfc_id ℝ≥0 a] using apply_le_nnnorm_cfc_nnreal id a hx
end IsometricContinuousFunctionalCalculus
open IsometricContinuousFunctionalCalculus in
lemma MonotoneOn.nnnorm_cfc [Nontrivial A] (f : ℝ≥0 → ℝ≥0) (a : A)
(hf : MonotoneOn f (σ ℝ≥0 a)) (hf₂ : ContinuousOn f (σ ℝ≥0 a) := by cfc_cont_tac)
(ha : 0 ≤ a := by cfc_tac) : ‖cfc f a‖₊ = f ‖a‖₊ :=
IsGreatest.nnnorm_cfc_nnreal f a |>.unique <| hf.map_isGreatest (isGreatest_spectrum a)
end Unital
section NonUnital
variable {A : Type*} [NonUnitalNormedRing A] [StarRing A] [NormedSpace ℝ A]
variable [IsScalarTower ℝ A A] [SMulCommClass ℝ A A] [PartialOrder A]
variable [StarOrderedRing A] [NonUnitalIsometricContinuousFunctionalCalculus ℝ A IsSelfAdjoint]
variable [NonnegSpectrumClass ℝ A]
lemma IsGreatest.nnnorm_cfcₙ_nnreal (f : ℝ≥0 → ℝ≥0) (a : A)
(hf : ContinuousOn f (σₙ ℝ≥0 a) := by cfc_cont_tac) (hf0 : f 0 = 0 := by cfc_zero_tac)
(ha : 0 ≤ a := by cfc_tac) : IsGreatest (f '' σₙ ℝ≥0 a) ‖cfcₙ f a‖₊ := by
rw [cfcₙ_nnreal_eq_real ..]
obtain ⟨-, ha'⟩ := nonneg_iff_isSelfAdjoint_and_quasispectrumRestricts.mp ha
convert IsGreatest.nnnorm_cfcₙ (fun x : ℝ ↦ (f x.toNNReal : ℝ)) a ?hf_cont (by simpa)
case hf_cont => exact continuous_subtype_val.comp_continuousOn <|
ContinuousOn.comp ‹_› continuous_real_toNNReal.continuousOn <| ha'.image ▸ Set.mapsTo_image ..
ext x
constructor
all_goals rintro ⟨x, hx, rfl⟩
· exact ⟨x, quasispectrum.algebraMap_mem ℝ hx, by simp⟩
· exact ⟨x.toNNReal, ha'.apply_mem hx, by simp⟩
lemma apply_le_nnnorm_cfcₙ_nnreal (f : ℝ≥0 → ℝ≥0) (a : A) ⦃x : ℝ≥0⦄ (hx : x ∈ σₙ ℝ≥0 a)
(hf : ContinuousOn f (σₙ ℝ≥0 a) := by cfc_cont_tac) (hf0 : f 0 = 0 := by cfc_zero_tac)
(ha : 0 ≤ a := by cfc_tac) : f x ≤ ‖cfcₙ f a‖₊ := by
revert hx
exact (IsGreatest.nnnorm_cfcₙ_nnreal f a hf hf0 ha |>.2 ⟨x, ·, rfl⟩)
lemma nnnorm_cfcₙ_nnreal_le {f : ℝ≥0 → ℝ≥0} {a : A} {c : ℝ≥0} (h : ∀ x ∈ σₙ ℝ≥0 a, f x ≤ c) :
‖cfcₙ f a‖₊ ≤ c := by
refine cfcₙ_cases (‖·‖₊ ≤ c) a f (by simp) fun hf hf0 ha ↦ ?_
simp only [← cfcₙ_apply f a, isLUB_le_iff (IsGreatest.nnnorm_cfcₙ_nnreal f a hf hf0 ha |>.isLUB)]
rintro - ⟨x, hx, rfl⟩
exact h x hx
lemma nnnorm_cfcₙ_nnreal_le_iff (f : ℝ≥0 → ℝ≥0) (a : A) (c : ℝ≥0)
(hf : ContinuousOn f (σₙ ℝ≥0 a) := by cfc_cont_tac) (hf₀ : f 0 = 0 := by cfc_zero_tac)
(ha : 0 ≤ a := by cfc_tac) : ‖cfcₙ f a‖₊ ≤ c ↔ ∀ x ∈ σₙ ℝ≥0 a, f x ≤ c :=
⟨fun h _ hx ↦ apply_le_nnnorm_cfcₙ_nnreal f a hx hf hf₀ ha |>.trans h, nnnorm_cfcₙ_nnreal_le⟩
lemma nnnorm_cfcₙ_nnreal_lt {f : ℝ≥0 → ℝ≥0} {a : A} {c : ℝ≥0} (h : ∀ x ∈ σₙ ℝ≥0 a, f x < c) :
‖cfcₙ f a‖₊ < c := by
refine cfcₙ_cases (‖·‖₊ < c) a f ?_ fun hf hf0 ha ↦ ?_
· simpa using zero_le (f 0) |>.trans_lt <| h 0 (quasispectrum.zero_mem ℝ≥0 _)
· simp only [← cfcₙ_apply f a, (IsGreatest.nnnorm_cfcₙ_nnreal f a hf hf0 ha |>.lt_iff)]
rintro - ⟨x, hx, rfl⟩
exact h x hx
lemma nnnorm_cfcₙ_nnreal_lt_iff (f : ℝ≥0 → ℝ≥0) (a : A) (c : ℝ≥0)
(hf : ContinuousOn f (σₙ ℝ≥0 a) := by cfc_cont_tac) (hf₀ : f 0 = 0 := by cfc_zero_tac)
(ha : 0 ≤ a := by cfc_tac) : ‖cfcₙ f a‖₊ < c ↔ ∀ x ∈ σₙ ℝ≥0 a, f x < c :=
⟨fun h _ hx ↦ apply_le_nnnorm_cfcₙ_nnreal f a hx hf hf₀ ha |>.trans_lt h, nnnorm_cfcₙ_nnreal_lt⟩
namespace NonUnitalIsometricContinuousFunctionalCalculus
lemma isGreatest_quasispectrum (a : A) (ha : 0 ≤ a := by cfc_tac) :
IsGreatest (σₙ ℝ≥0 a) ‖a‖₊ := by
simpa [cfcₙ_id ℝ≥0 a] using IsGreatest.nnnorm_cfcₙ_nnreal id a
lemma quasispectrum_le (a : A) ⦃x : ℝ≥0⦄ (hx : x ∈ σₙ ℝ≥0 a) (ha : 0 ≤ a := by cfc_tac) :
x ≤ ‖a‖₊ := by
simpa [cfcₙ_id ℝ≥0 a] using apply_le_nnnorm_cfcₙ_nnreal id a hx
end NonUnitalIsometricContinuousFunctionalCalculus
open NonUnitalIsometricContinuousFunctionalCalculus in
lemma MonotoneOn.nnnorm_cfcₙ (f : ℝ≥0 → ℝ≥0) (a : A)
(hf : MonotoneOn f (σₙ ℝ≥0 a)) (hf₂ : ContinuousOn f (σₙ ℝ≥0 a) := by cfc_cont_tac)
(hf0 : f 0 = 0 := by cfc_zero_tac) (ha : 0 ≤ a := by cfc_tac) :
‖cfcₙ f a‖₊ = f ‖a‖₊ :=
IsGreatest.nnnorm_cfcₙ_nnreal f a |>.unique <| hf.map_isGreatest (isGreatest_quasispectrum a)
end NonUnital
end NNReal
/-! ### Non-unital instance for unital algebras -/
namespace IsometricContinuousFunctionalCalculus
variable {𝕜 A : Type*} {p : outParam (A → Prop)}
variable [RCLike 𝕜] [NormedRing A] [StarRing A] [NormedAlgebra 𝕜 A]
variable [IsometricContinuousFunctionalCalculus 𝕜 A p]
open scoped ContinuousFunctionalCalculus in
/-- An isometric continuous functional calculus on a unital algebra yields to a non-unital one. -/
instance toNonUnital : NonUnitalIsometricContinuousFunctionalCalculus 𝕜 A p where
isometric a ha := by
have : CompactSpace (σₙ 𝕜 a) := by
have h_cpct : CompactSpace (spectrum 𝕜 a) := inferInstance
simp only [← isCompact_iff_compactSpace, quasispectrum_eq_spectrum_union_zero] at h_cpct ⊢
exact h_cpct |>.union isCompact_singleton
rw [cfcₙHom_eq_cfcₙHom_of_cfcHom, cfcₙHom_of_cfcHom]
refine isometry_cfcHom a |>.comp ?_
simp only [MulHom.coe_coe, NonUnitalStarAlgHom.coe_toNonUnitalAlgHom]
refine AddMonoidHomClass.isometry_of_norm _ fun f ↦ ?_
let ι : C(σ 𝕜 a, σₙ 𝕜 a) := ⟨_, continuous_inclusion <| spectrum_subset_quasispectrum 𝕜 a⟩
change ‖(f : C(σₙ 𝕜 a, 𝕜)).comp ι‖ = ‖(f : C(σₙ 𝕜 a, 𝕜))‖
apply le_antisymm (ContinuousMap.norm_le _ (by positivity) |>.mpr ?_)
(ContinuousMap.norm_le _ (by positivity) |>.mpr ?_)
· rintro ⟨x, hx⟩
exact (f : C(σₙ 𝕜 a, 𝕜)).norm_coe_le_norm ⟨x, spectrum_subset_quasispectrum 𝕜 a hx⟩
· rintro ⟨x, hx⟩
obtain (rfl | hx') : x = 0 ∨ x ∈ σ 𝕜 a := by
simpa [quasispectrum_eq_spectrum_union_zero] using hx
· change ‖f 0‖ ≤ _
simp
· exact (f : C(σₙ 𝕜 a, 𝕜)).comp ι |>.norm_coe_le_norm ⟨x, hx'⟩
end IsometricContinuousFunctionalCalculus |
.lake/packages/mathlib/Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Instances.lean | import Mathlib.Analysis.Complex.Spectrum
import Mathlib.Analysis.CStarAlgebra.ContinuousFunctionalCalculus.Restrict
import Mathlib.Analysis.CStarAlgebra.ContinuousFunctionalCalculus.Unique
import Mathlib.Analysis.CStarAlgebra.Unitization
import Mathlib.Analysis.Normed.Algebra.Spectrum
import Mathlib.Analysis.RCLike.Lemmas
/-! # Instances of the continuous functional calculus
## Main theorems
* `IsSelfAdjoint.instContinuousFunctionalCalculus`: the continuous functional calculus for
selfadjoint elements in a `ℂ`-algebra with a continuous functional calculus for normal elements
and where every element has compact spectrum. In particular, this includes unital C⋆-algebras
over `ℂ`.
* `Nonneg.instContinuousFunctionalCalculus`: the continuous functional calculus for nonnegative
elements in an `ℝ`-algebra with a continuous functional calculus for selfadjoint elements,
where every element has compact spectrum, and where nonnegative elements have nonnegative
spectrum. In particular, this includes unital C⋆-algebras over `ℝ`.
## Tags
continuous functional calculus, normal, selfadjoint
-/
open Topology
noncomputable section
local notation "σₙ" => quasispectrum
local notation "σ" => spectrum
/-!
### Pull back a non-unital instance from a unital one on the unitization
-/
section RCLike
variable {𝕜 A : Type*} [RCLike 𝕜] [NonUnitalNormedRing A] [StarRing A]
variable [NormedSpace 𝕜 A] [IsScalarTower 𝕜 A A] [SMulCommClass 𝕜 A A]
variable [StarModule 𝕜 A] {p : A → Prop} {p₁ : Unitization 𝕜 A → Prop}
local postfix:max "⁺¹" => Unitization 𝕜
variable (hp₁ : ∀ {x : A}, p₁ x ↔ p x) (a : A) (ha : p a)
variable [ContinuousFunctionalCalculus 𝕜 (Unitization 𝕜 A) p₁]
open scoped ContinuousMapZero
open Unitization in
/--
This is an auxiliary definition used for constructing an instance of the non-unital continuous
functional calculus given a instance of the unital one on the unitization.
This is the natural non-unital star homomorphism obtained from the chain
```lean
calc
C(σₙ 𝕜 a, 𝕜)₀ →⋆ₙₐ[𝕜] C(σₙ 𝕜 a, 𝕜) := ContinuousMapZero.toContinuousMapHom
_ ≃⋆[𝕜] C(σ 𝕜 (↑a : A⁺¹), 𝕜) := Homeomorph.compStarAlgEquiv'
_ →⋆ₐ[𝕜] A⁺¹ := cfcHom
```
This range of this map is contained in the range of `(↑) : A → A⁺¹` (see `cfcₙAux_mem_range_inr`),
and so we may restrict it to `A` to get the necessary homomorphism for the non-unital continuous
functional calculus.
-/
noncomputable def cfcₙAux : C(σₙ 𝕜 a, 𝕜)₀ →⋆ₙₐ[𝕜] A⁺¹ :=
(cfcHom (R := 𝕜) (hp₁.mpr ha) : C(σ 𝕜 (a : A⁺¹), 𝕜) →⋆ₙₐ[𝕜] A⁺¹) |>.comp
(Homeomorph.compStarAlgEquiv' 𝕜 𝕜 <| .setCongr <| (quasispectrum_eq_spectrum_inr' 𝕜 𝕜 a).symm)
|>.comp ContinuousMapZero.toContinuousMapHom
lemma cfcₙAux_id : cfcₙAux hp₁ a ha (.id _) = a := cfcHom_id (hp₁.mpr ha)
open Unitization in
lemma isClosedEmbedding_cfcₙAux : IsClosedEmbedding (cfcₙAux hp₁ a ha) := by
simp only [cfcₙAux, NonUnitalStarAlgHom.coe_comp]
refine ((cfcHom_isClosedEmbedding (hp₁.mpr ha)).comp ?_).comp
ContinuousMapZero.isClosedEmbedding_toContinuousMap
let e : C(σₙ 𝕜 a, 𝕜) ≃ₜ C(σ 𝕜 (a : A⁺¹), 𝕜) :=
(Homeomorph.setCongr (quasispectrum_eq_spectrum_inr' 𝕜 𝕜 a)).arrowCongr (.refl _)
exact e.isClosedEmbedding
lemma spec_cfcₙAux (f : C(σₙ 𝕜 a, 𝕜)₀) : σ 𝕜 (cfcₙAux hp₁ a ha f) = Set.range f := by
rw [cfcₙAux, NonUnitalStarAlgHom.comp_assoc, NonUnitalStarAlgHom.comp_apply]
simp only [NonUnitalStarAlgHom.comp_apply, NonUnitalStarAlgHom.coe_coe]
rw [cfcHom_map_spectrum (hp₁.mpr ha) (R := 𝕜) _]
simp
variable [CompleteSpace A]
lemma cfcₙAux_mem_range_inr (f : C(σₙ 𝕜 a, 𝕜)₀) :
cfcₙAux hp₁ a ha f ∈ NonUnitalStarAlgHom.range (Unitization.inrNonUnitalStarAlgHom 𝕜 A) := by
have h₁ := (isClosedEmbedding_cfcₙAux hp₁ a ha).continuous.range_subset_closure_image_dense
(ContinuousMapZero.adjoin_id_dense (σₙ 𝕜 a)) ⟨f, rfl⟩
rw [← SetLike.mem_coe]
refine closure_minimal ?_ ?_ h₁
· rw [← NonUnitalStarSubalgebra.coe_map, SetLike.coe_subset_coe, NonUnitalStarSubalgebra.map_le]
apply NonUnitalStarAlgebra.adjoin_le
apply Set.singleton_subset_iff.mpr
rw [SetLike.mem_coe, NonUnitalStarSubalgebra.mem_comap, cfcₙAux_id hp₁ a ha]
exact ⟨a, rfl⟩
· have : Continuous (Unitization.fst (R := 𝕜) (A := A)) :=
Unitization.uniformEquivProd.continuous.fst
simp only [NonUnitalStarAlgHom.coe_range]
convert IsClosed.preimage this (isClosed_singleton (x := 0))
aesop
variable [CStarRing A]
include hp₁ in
open Unitization NonUnitalStarAlgHom in
theorem RCLike.nonUnitalContinuousFunctionalCalculus :
NonUnitalContinuousFunctionalCalculus 𝕜 A p where
predicate_zero := by
rw [← hp₁, Unitization.inr_zero 𝕜]
exact cfc_predicate_zero 𝕜
exists_cfc_of_predicate a ha := by
let ψ : C(σₙ 𝕜 a, 𝕜)₀ →⋆ₙₐ[𝕜] A := comp (inrRangeEquiv 𝕜 A).symm <|
codRestrict (cfcₙAux hp₁ a ha) _ (cfcₙAux_mem_range_inr hp₁ a ha)
have coe_ψ (f : C(σₙ 𝕜 a, 𝕜)₀) : ψ f = cfcₙAux hp₁ a ha f :=
congr_arg Subtype.val <| (inrRangeEquiv 𝕜 A).apply_symm_apply
⟨cfcₙAux hp₁ a ha f, cfcₙAux_mem_range_inr hp₁ a ha f⟩
refine ⟨ψ, ?isClosedEmbedding, ?map_id, fun f ↦ ?map_spec, fun f ↦ ?isStarNormal⟩
case isClosedEmbedding =>
apply isometry_inr (𝕜 := 𝕜) (A := A) |>.isClosedEmbedding |>.of_comp_iff.mp
have : inr ∘ ψ = cfcₙAux hp₁ a ha := by ext1; rw [Function.comp_apply, coe_ψ]
exact this ▸ isClosedEmbedding_cfcₙAux hp₁ a ha
case map_id => exact inr_injective (R := 𝕜) <| coe_ψ _ ▸ cfcₙAux_id hp₁ a ha
case map_spec =>
exact quasispectrum_eq_spectrum_inr' 𝕜 𝕜 (ψ f) ▸ coe_ψ _ ▸ spec_cfcₙAux hp₁ a ha f
case isStarNormal => exact hp₁.mp <| coe_ψ _ ▸ cfcHom_predicate (R := 𝕜) (hp₁.mpr ha) _
end RCLike
/-!
### Continuous functional calculus for selfadjoint elements
-/
section SelfAdjointNonUnital
variable {A : Type*} [TopologicalSpace A] [NonUnitalRing A] [StarRing A] [Module ℂ A]
[IsScalarTower ℂ A A] [SMulCommClass ℂ A A]
[NonUnitalContinuousFunctionalCalculus ℂ A IsStarNormal]
/-- An element in a non-unital C⋆-algebra is selfadjoint if and only if it is normal and its
quasispectrum is contained in `ℝ`. -/
lemma isSelfAdjoint_iff_isStarNormal_and_quasispectrumRestricts {a : A} :
IsSelfAdjoint a ↔ IsStarNormal a ∧ QuasispectrumRestricts a Complex.reCLM := by
refine ⟨fun ha ↦ ⟨ha.isStarNormal, ⟨fun x hx ↦ ?_, Complex.ofReal_re⟩⟩, ?_⟩
· have := eqOn_of_cfcₙ_eq_cfcₙ <|
(cfcₙ_star (id : ℂ → ℂ) a).symm ▸ (cfcₙ_id ℂ a).symm ▸ ha.star_eq
exact Complex.conj_eq_iff_re.mp (by simpa using this hx)
· rintro ⟨ha₁, ha₂⟩
rw [isSelfAdjoint_iff]
nth_rw 2 [← cfcₙ_id ℂ a]
rw [← cfcₙ_star_id a (R := ℂ)]
refine cfcₙ_congr fun x hx ↦ ?_
obtain ⟨x, -, rfl⟩ := ha₂.algebraMap_image.symm ▸ hx
exact Complex.conj_ofReal _
lemma IsSelfAdjoint.quasispectrumRestricts {a : A} (ha : IsSelfAdjoint a) :
QuasispectrumRestricts a Complex.reCLM :=
isSelfAdjoint_iff_isStarNormal_and_quasispectrumRestricts |>.mp ha |>.2
@[deprecated (since := "2025-09-16")]
alias isSelfAdjoint_iff_isStarNormal_and_spectrumRestricts :=
isSelfAdjoint_iff_isStarNormal_and_quasispectrumRestricts
/-- A normal element whose `ℂ`-quasispectrum is contained in `ℝ` is selfadjoint. -/
lemma QuasispectrumRestricts.isSelfAdjoint (a : A) (ha : QuasispectrumRestricts a Complex.reCLM)
[IsStarNormal a] : IsSelfAdjoint a :=
isSelfAdjoint_iff_isStarNormal_and_quasispectrumRestricts.mpr ⟨‹_›, ha⟩
@[deprecated (since := "2025-09-16")]
alias SpectrumRestricts.isSelfAdjoint := QuasispectrumRestricts.isSelfAdjoint
instance IsSelfAdjoint.instNonUnitalContinuousFunctionalCalculus :
NonUnitalContinuousFunctionalCalculus ℝ A IsSelfAdjoint :=
QuasispectrumRestricts.cfc (q := IsStarNormal) (p := IsSelfAdjoint) Complex.reCLM
Complex.isometry_ofReal.isUniformEmbedding (.zero _)
(fun _ ↦ isSelfAdjoint_iff_isStarNormal_and_quasispectrumRestricts)
end SelfAdjointNonUnital
section SelfAdjointUnital
variable {A : Type*} [TopologicalSpace A] [Ring A] [StarRing A] [Algebra ℂ A]
[ContinuousFunctionalCalculus ℂ A IsStarNormal]
lemma IsSelfAdjoint.spectrumRestricts {a : A} (ha : IsSelfAdjoint a) :
SpectrumRestricts a Complex.reCLM :=
ha.quasispectrumRestricts
instance IsSelfAdjoint.instContinuousFunctionalCalculus :
ContinuousFunctionalCalculus ℝ A IsSelfAdjoint :=
SpectrumRestricts.cfc (q := IsStarNormal) (p := IsSelfAdjoint) Complex.reCLM
Complex.isometry_ofReal.isUniformEmbedding (.zero _)
(fun _ ↦ isSelfAdjoint_iff_isStarNormal_and_quasispectrumRestricts)
lemma IsSelfAdjoint.spectrum_nonempty {A : Type*} [Ring A] [StarRing A]
[TopologicalSpace A] [Algebra ℝ A] [ContinuousFunctionalCalculus ℝ A IsSelfAdjoint]
[Nontrivial A] {a : A} (ha : IsSelfAdjoint a) : (σ ℝ a).Nonempty :=
CFC.spectrum_nonempty ℝ a ha
end SelfAdjointUnital
/-!
### Continuous functional calculus for nonnegative elements
-/
section Nonneg
lemma CFC.exists_sqrt_of_isSelfAdjoint_of_quasispectrumRestricts {A : Type*} [NonUnitalRing A]
[StarRing A] [TopologicalSpace A] [Module ℝ A] [IsScalarTower ℝ A A] [SMulCommClass ℝ A A]
[NonUnitalContinuousFunctionalCalculus ℝ A IsSelfAdjoint]
{a : A} (ha₁ : IsSelfAdjoint a) (ha₂ : QuasispectrumRestricts a ContinuousMap.realToNNReal) :
∃ x : A, IsSelfAdjoint x ∧ QuasispectrumRestricts x ContinuousMap.realToNNReal ∧ x * x = a := by
use cfcₙ (√·) a, cfcₙ_predicate (√·) a
constructor
· simpa only [QuasispectrumRestricts.nnreal_iff, cfcₙ_map_quasispectrum (√·) a,
Set.mem_image, forall_exists_index, and_imp, forall_apply_eq_imp_iff₂]
using fun x _ ↦ Real.sqrt_nonneg x
· rw [← cfcₙ_mul ..]
nth_rw 2 [← cfcₙ_id ℝ a]
apply cfcₙ_congr fun x hx ↦ ?_
rw [QuasispectrumRestricts.nnreal_iff] at ha₂
apply ha₂ x at hx
simp [← sq, Real.sq_sqrt hx]
@[deprecated (since := "2025-09-16")]
alias CFC.exists_sqrt_of_isSelfAdjoint_of_spectrumRestricts :=
CFC.exists_sqrt_of_isSelfAdjoint_of_quasispectrumRestricts
variable {A : Type*} [NonUnitalRing A] [PartialOrder A] [StarRing A] [StarOrderedRing A]
variable [TopologicalSpace A] [Module ℝ A] [IsScalarTower ℝ A A] [SMulCommClass ℝ A A]
variable [NonUnitalContinuousFunctionalCalculus ℝ A IsSelfAdjoint]
variable [NonnegSpectrumClass ℝ A]
lemma nonneg_iff_isSelfAdjoint_and_quasispectrumRestricts {a : A} :
0 ≤ a ↔ IsSelfAdjoint a ∧ QuasispectrumRestricts a ContinuousMap.realToNNReal := by
refine ⟨fun ha ↦ ⟨.of_nonneg ha, .nnreal_of_nonneg ha⟩, ?_⟩
rintro ⟨ha₁, ha₂⟩
obtain ⟨x, hx, -, rfl⟩ := CFC.exists_sqrt_of_isSelfAdjoint_of_quasispectrumRestricts ha₁ ha₂
simpa [sq, hx.star_eq] using star_mul_self_nonneg x
@[deprecated (since := "2025-09-16")]
alias nonneg_iff_isSelfAdjoint_and_spectrumRestricts :=
nonneg_iff_isSelfAdjoint_and_quasispectrumRestricts
open NNReal in
instance Nonneg.instNonUnitalContinuousFunctionalCalculus :
NonUnitalContinuousFunctionalCalculus ℝ≥0 A (0 ≤ ·) :=
QuasispectrumRestricts.cfc (q := IsSelfAdjoint) ContinuousMap.realToNNReal
isUniformEmbedding_subtype_val le_rfl
(fun _ ↦ nonneg_iff_isSelfAdjoint_and_quasispectrumRestricts)
/-- In a C⋆-algebra, commuting nonnegative elements have nonnegative products. -/
lemma Commute.mul_nonneg {a b : A} (ha : 0 ≤ a) (hb : 0 ≤ b) (h : Commute a b) :
0 ≤ a * b := by
rw [nonneg_iff_isSelfAdjoint_and_quasispectrumRestricts]
refine ⟨ha.isSelfAdjoint.commute_iff hb.isSelfAdjoint |>.mp h, ?_⟩
rw [nonneg_iff_isSelfAdjoint_and_quasispectrumRestricts] at hb
obtain ⟨x, hx₁, hx₂, rfl⟩ := CFC.exists_sqrt_of_isSelfAdjoint_of_quasispectrumRestricts hb.1 hb.2
have hx := nonneg_iff_isSelfAdjoint_and_quasispectrumRestricts.mpr ⟨hx₁, hx₂⟩
rw [← mul_assoc, quasispectrumRestricts_iff, quasispectrum.mul_comm,
← quasispectrumRestricts_iff, ← mul_assoc]
exact QuasispectrumRestricts.nnreal_of_nonneg <| conjugate_nonneg_of_nonneg ha hx
lemma commute_iff_mul_nonneg {a b : A} (ha : 0 ≤ a) (hb : 0 ≤ b) :
Commute a b ↔ 0 ≤ a * b :=
⟨Commute.mul_nonneg ha hb,
fun h => ha.isSelfAdjoint.commute_iff hb.isSelfAdjoint |>.mpr h.isSelfAdjoint⟩
open NNReal in
lemma NNReal.spectrum_nonempty {A : Type*} [Ring A] [StarRing A] [LE A]
[TopologicalSpace A] [Algebra ℝ≥0 A] [ContinuousFunctionalCalculus ℝ≥0 A (0 ≤ ·)]
[Nontrivial A] {a : A} (ha : 0 ≤ a) : (spectrum ℝ≥0 a).Nonempty :=
CFC.spectrum_nonempty ℝ≥0 a ha
end Nonneg
section Nonneg
variable {A : Type*} [Ring A] [PartialOrder A] [StarRing A] [StarOrderedRing A] [TopologicalSpace A]
variable [Algebra ℝ A] [ContinuousFunctionalCalculus ℝ A IsSelfAdjoint]
variable [NonnegSpectrumClass ℝ A]
open NNReal in
instance Nonneg.instContinuousFunctionalCalculus :
ContinuousFunctionalCalculus ℝ≥0 A (0 ≤ ·) :=
SpectrumRestricts.cfc (q := IsSelfAdjoint) ContinuousMap.realToNNReal
isUniformEmbedding_subtype_val le_rfl
(fun _ ↦ nonneg_iff_isSelfAdjoint_and_quasispectrumRestricts)
theorem IsStrictlyPositive.commute_iff {a b : A} (ha : IsStrictlyPositive a)
(hb : IsStrictlyPositive b) : Commute a b ↔ IsStrictlyPositive (a * b) := by
rw [commute_iff_mul_nonneg ha.nonneg hb.nonneg]
exact ⟨fun h => ha.isUnit.mul hb.isUnit |>.isStrictlyPositive h, fun h => h.nonneg⟩
end Nonneg
/-!
### The restriction of a continuous functional calculus is equal to the original one
-/
section RealEqComplex
variable {A : Type*} [TopologicalSpace A] [Ring A] [StarRing A] [Algebra ℂ A]
[ContinuousFunctionalCalculus ℂ A IsStarNormal] [T2Space A]
lemma cfcHom_real_eq_restrict {a : A} (ha : IsSelfAdjoint a) :
cfcHom ha =
ha.spectrumRestricts.starAlgHom (R := ℝ) (S := ℂ)
(cfcHom ha.isStarNormal) (f := Complex.reCLM) :=
ha.spectrumRestricts.cfcHom_eq_restrict _ Complex.isometry_ofReal.isUniformEmbedding
ha ha.isStarNormal
lemma cfc_real_eq_complex {a : A} (f : ℝ → ℝ) (ha : IsSelfAdjoint a := by cfc_tac) :
cfc f a = cfc (fun x ↦ f x.re : ℂ → ℂ) a := by
exact ha.spectrumRestricts.cfc_eq_restrict (f := Complex.reCLM)
Complex.isometry_ofReal.isUniformEmbedding ha ha.isStarNormal f
lemma cfc_complex_eq_real {f : ℂ → ℂ} (a : A) (hf_real : ∀ x ∈ spectrum ℂ a, star (f x) = f x)
(ha : IsSelfAdjoint a := by cfc_tac) :
cfc f a = cfc (fun x : ℝ ↦ (f x).re) a := by
rw [cfc_real_eq_complex ..]
refine cfc_congr fun x hx ↦ ?_
simp_rw [RCLike.star_def, RCLike.conj_eq_iff_re, RCLike.re_eq_complex_re,
RCLike.ofReal_eq_complex_ofReal] at hf_real
rw [← SpectrumRestricts.real_iff.mp ha.spectrumRestricts _ hx, hf_real _ hx]
end RealEqComplex
section RealEqComplexNonUnital
variable {A : Type*} [TopologicalSpace A] [NonUnitalRing A] [StarRing A] [Module ℂ A]
[IsScalarTower ℂ A A] [SMulCommClass ℂ A A] [T2Space A]
[NonUnitalContinuousFunctionalCalculus ℂ A IsStarNormal]
lemma cfcₙHom_real_eq_restrict {a : A} (ha : IsSelfAdjoint a) :
cfcₙHom ha = ha.quasispectrumRestricts.nonUnitalStarAlgHom (cfcₙHom ha.isStarNormal)
(R := ℝ) (S := ℂ) (f := Complex.reCLM) :=
ha.quasispectrumRestricts.cfcₙHom_eq_restrict _ Complex.isometry_ofReal.isUniformEmbedding
ha ha.isStarNormal
lemma cfcₙ_real_eq_complex {a : A} (f : ℝ → ℝ) (ha : IsSelfAdjoint a := by cfc_tac) :
cfcₙ f a = cfcₙ (fun x ↦ f x.re : ℂ → ℂ) a := by
exact ha.quasispectrumRestricts.cfcₙ_eq_restrict (f := Complex.reCLM)
Complex.isometry_ofReal.isUniformEmbedding ha ha.isStarNormal f
lemma cfcₙ_complex_eq_real {f : ℂ → ℂ} (a : A) (hf_real : ∀ x ∈ σₙ ℂ a, star (f x) = f x)
(ha : IsSelfAdjoint a := by cfc_tac) :
cfcₙ f a = cfcₙ (fun x : ℝ ↦ (f x).re) a := by
rw [cfcₙ_real_eq_complex ..]
refine cfcₙ_congr fun x hx ↦ ?_
simp_rw [RCLike.star_def, RCLike.conj_eq_iff_re, RCLike.re_eq_complex_re,
RCLike.ofReal_eq_complex_ofReal] at hf_real
rw [← QuasispectrumRestricts.real_iff.mp ha.quasispectrumRestricts _ hx, hf_real _ hx]
end RealEqComplexNonUnital
section NNRealEqReal
open NNReal
variable {A : Type*} [TopologicalSpace A] [Ring A] [PartialOrder A] [StarRing A]
[StarOrderedRing A] [Algebra ℝ A] [IsTopologicalRing A] [T2Space A]
[ContinuousFunctionalCalculus ℝ A IsSelfAdjoint]
[NonnegSpectrumClass ℝ A]
lemma cfcHom_nnreal_eq_restrict {a : A} (ha : 0 ≤ a) :
cfcHom ha = (SpectrumRestricts.nnreal_of_nonneg ha).starAlgHom
(cfcHom (IsSelfAdjoint.of_nonneg ha)) := by
apply (SpectrumRestricts.nnreal_of_nonneg ha).cfcHom_eq_restrict _ isUniformEmbedding_subtype_val
lemma cfc_nnreal_eq_real (f : ℝ≥0 → ℝ≥0) (a : A) (ha : 0 ≤ a := by cfc_tac) :
cfc f a = cfc (fun x ↦ f x.toNNReal : ℝ → ℝ) a := by
apply (SpectrumRestricts.nnreal_of_nonneg ha).cfc_eq_restrict _
isUniformEmbedding_subtype_val ha (.of_nonneg ha)
lemma cfc_real_eq_nnreal {f : ℝ → ℝ} (a : A) (hf_nonneg : ∀ x ∈ spectrum ℝ a, 0 ≤ f x)
(ha : 0 ≤ a := by cfc_tac) : cfc f a = cfc (fun x : ℝ≥0 ↦ (f x).toNNReal) a := by
rw [cfc_nnreal_eq_real ..]
refine cfc_congr fun x hx ↦ ?_
rw [x.coe_toNNReal (spectrum_nonneg_of_nonneg ha hx), (f x).coe_toNNReal (hf_nonneg x hx)]
end NNRealEqReal
section NNRealEqRealNonUnital
open NNReal
variable {A : Type*} [TopologicalSpace A] [NonUnitalRing A] [PartialOrder A] [StarRing A]
[StarOrderedRing A] [Module ℝ A] [IsTopologicalRing A] [IsScalarTower ℝ A A] [SMulCommClass ℝ A A]
[T2Space A] [NonUnitalContinuousFunctionalCalculus ℝ A IsSelfAdjoint]
[NonnegSpectrumClass ℝ A]
lemma cfcₙHom_nnreal_eq_restrict {a : A} (ha : 0 ≤ a) :
cfcₙHom ha = (QuasispectrumRestricts.nnreal_of_nonneg ha).nonUnitalStarAlgHom
(cfcₙHom (IsSelfAdjoint.of_nonneg ha)) := by
apply (QuasispectrumRestricts.nnreal_of_nonneg ha).cfcₙHom_eq_restrict _
isUniformEmbedding_subtype_val
lemma cfcₙ_nnreal_eq_real (f : ℝ≥0 → ℝ≥0) (a : A) (ha : 0 ≤ a := by cfc_tac) :
cfcₙ f a = cfcₙ (fun x ↦ f x.toNNReal : ℝ → ℝ) a := by
apply (QuasispectrumRestricts.nnreal_of_nonneg ha).cfcₙ_eq_restrict _
isUniformEmbedding_subtype_val ha (.of_nonneg ha)
lemma cfcₙ_real_eq_nnreal {f : ℝ → ℝ} (a : A) (hf_nonneg : ∀ x ∈ σₙ ℝ a, 0 ≤ f x)
(ha : 0 ≤ a := by cfc_tac) : cfcₙ f a = cfcₙ (fun x : ℝ≥0 ↦ (f x).toNNReal) a := by
rw [cfcₙ_nnreal_eq_real ..]
refine cfcₙ_congr fun x hx ↦ ?_
rw [x.coe_toNNReal (quasispectrum_nonneg_of_nonneg _ ha _ hx),
(f x).coe_toNNReal (hf_nonneg x hx)]
end NNRealEqRealNonUnital
end |
.lake/packages/mathlib/Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Integral.lean | import Mathlib.Analysis.Normed.Algebra.Spectrum
import Mathlib.Analysis.CStarAlgebra.ContinuousFunctionalCalculus.NonUnital
import Mathlib.Analysis.RCLike.Lemmas
import Mathlib.MeasureTheory.SpecificCodomains.ContinuousMapZero
import Mathlib.MeasureTheory.Integral.Bochner.ContinuousLinearMap
/-!
# Integrals and the continuous functional calculus
This file gives results about integrals of the form `∫ x, cfc (f x) a`. Most notably, we show
that the integral commutes with the continuous functional calculus under appropriate conditions.
## Main declarations
+ `cfc_setIntegral` (resp. `cfc_integral`): given a function `f : X → 𝕜 → 𝕜`, we have that
`cfc (fun r => ∫ x in s, f x r ∂μ) a = ∫ x in s, cfc (f x) a ∂μ`
under appropriate conditions (resp. with `s = univ`)
+ `cfcₙ_setIntegral`, `cfcₙ_integral`: the same for the non-unital continuous functional calculus
+ `integrableOn_cfc`, `integrableOn_cfcₙ`, `integrable_cfc`, `integrable_cfcₙ`:
functions of the form `fun x => cfc (f x) a` are integrable.
## Implementation Notes
The lemmas mentioned above are stated under much stricter hypotheses than necessary
(typically, simultaneous continuity of `f` in the parameter and the spectrum element).
They all come with primed version which only assume what's needed, and may be used together
with the API developed in `Mathlib.MeasureTheory.SpecificCodomains.ContinuousMap`.
## TODO
+ Lift this to the case where the CFC is over `ℝ≥0`
+ Use this to prove operator monotonicity and concavity/convexity of `rpow` and `log`
-/
open MeasureTheory Topology
open scoped ContinuousMapZero
section unital
open ContinuousMap
variable {X : Type*} {𝕜 : Type*} {A : Type*} {p : A → Prop} [RCLike 𝕜]
[MeasurableSpace X] {μ : Measure X}
[NormedRing A] [StarRing A] [NormedAlgebra 𝕜 A]
[ContinuousFunctionalCalculus 𝕜 A p]
[CompleteSpace A]
lemma cfcL_integral [NormedSpace ℝ A] (a : A) (f : X → C(spectrum 𝕜 a, 𝕜)) (hf₁ : Integrable f μ)
(ha : p a := by cfc_tac) :
∫ x, cfcL (a := a) ha (f x) ∂μ = cfcL (a := a) ha (∫ x, f x ∂μ) := by
rw [ContinuousLinearMap.integral_comp_comm _ hf₁]
lemma cfcL_integrable (a : A) (f : X → C(spectrum 𝕜 a, 𝕜))
(hf₁ : Integrable f μ) (ha : p a := by cfc_tac) :
Integrable (fun x ↦ cfcL (a := a) ha (f x)) μ :=
ContinuousLinearMap.integrable_comp _ hf₁
lemma cfcHom_integral [NormedSpace ℝ A] (a : A) (f : X → C(spectrum 𝕜 a, 𝕜))
(hf₁ : Integrable f μ) (ha : p a := by cfc_tac) :
∫ x, cfcHom (a := a) ha (f x) ∂μ = cfcHom (a := a) ha (∫ x, f x ∂μ) :=
cfcL_integral a f hf₁ ha
/-- An integrability criterion for the continuous functional calculus.
For a version with stronger assumptions which in practice are often easier to verify, see
`integrable_cfc`. -/
lemma integrable_cfc' (f : X → 𝕜 → 𝕜) (a : A)
(hf : Integrable
(fun x : X => mkD ((spectrum 𝕜 a).restrict (f x)) 0) μ)
(ha : p a := by cfc_tac) :
Integrable (fun x => cfc (f x) a) μ := by
conv in cfc _ _ => rw [cfc_eq_cfcL_mkD _ a]
exact cfcL_integrable _ _ hf ha
/-- An integrability criterion for the continuous functional calculus.
For a version with stronger assumptions which in practice are often easier to verify, see
`integrableOn_cfc`. -/
lemma integrableOn_cfc' {s : Set X} (f : X → 𝕜 → 𝕜) (a : A)
(hf : IntegrableOn
(fun x : X => mkD ((spectrum 𝕜 a).restrict (f x)) 0) s μ)
(ha : p a := by cfc_tac) :
IntegrableOn (fun x => cfc (f x) a) s μ := by
exact integrable_cfc' _ _ hf ha
open Set Function in
/-- An integrability criterion for the continuous functional calculus.
This version assumes joint continuity of `f`, see `integrable_cfc'` for a statement
with weaker assumptions. -/
lemma integrable_cfc [TopologicalSpace X] [OpensMeasurableSpace X] (f : X → 𝕜 → 𝕜)
(bound : X → ℝ) (a : A) [SecondCountableTopologyEither X C(spectrum 𝕜 a, 𝕜)]
(hf : ContinuousOn (uncurry f) (univ ×ˢ spectrum 𝕜 a))
(bound_ge : ∀ᵐ x ∂μ, ∀ z ∈ spectrum 𝕜 a, ‖f x z‖ ≤ bound x)
(bound_int : HasFiniteIntegral bound μ) (ha : p a := by cfc_tac) :
Integrable (fun x => cfc (f x) a) μ := by
refine integrable_cfc' _ _ ⟨?_, ?_⟩ ha
· exact aeStronglyMeasurable_mkD_restrict_of_uncurry _ _ hf
· refine hasFiniteIntegral_mkD_restrict_of_bound f _ ?_ bound bound_int bound_ge
exact .of_forall fun x ↦
hf.comp (Continuous.prodMk_right x).continuousOn fun _ hz ↦ ⟨Set.mem_univ _, hz⟩
open Set Function in
/-- An integrability criterion for the continuous functional calculus.
This version assumes joint continuity of `f`, see `integrableOn_cfc'` for a statement
with weaker assumptions. -/
lemma integrableOn_cfc [TopologicalSpace X] [OpensMeasurableSpace X] {s : Set X}
(hs : MeasurableSet s) (f : X → 𝕜 → 𝕜) (bound : X → ℝ) (a : A)
[SecondCountableTopologyEither X C(spectrum 𝕜 a, 𝕜)]
(hf : ContinuousOn (uncurry f) (s ×ˢ spectrum 𝕜 a))
(bound_ge : ∀ᵐ x ∂(μ.restrict s), ∀ z ∈ spectrum 𝕜 a, ‖f x z‖ ≤ bound x)
(bound_int : HasFiniteIntegral bound (μ.restrict s)) (ha : p a := by cfc_tac) :
IntegrableOn (fun x => cfc (f x) a) s μ := by
refine integrableOn_cfc' _ _ ⟨?_, ?_⟩ ha
· exact aeStronglyMeasurable_restrict_mkD_restrict_of_uncurry hs _ _ hf
· refine hasFiniteIntegral_mkD_restrict_of_bound f _ ?_ bound bound_int bound_ge
exact ae_restrict_of_forall_mem hs fun x hx ↦
hf.comp (Continuous.prodMk_right x).continuousOn fun _ hz ↦ ⟨hx, hz⟩
open Set in
/-- The continuous functional calculus commutes with integration.
For a version with stronger assumptions which in practice are often easier to verify, see
`cfc_integral`. -/
lemma cfc_integral' [NormedSpace ℝ A] (f : X → 𝕜 → 𝕜) (a : A)
(hf₁ : ∀ᵐ x ∂μ, ContinuousOn (f x) (spectrum 𝕜 a))
(hf₂ : Integrable
(fun x : X => mkD ((spectrum 𝕜 a).restrict (f x)) 0) μ)
(ha : p a := by cfc_tac) :
cfc (fun z => ∫ x, f x z ∂μ) a = ∫ x, cfc (f x) a ∂μ := by
have key₁ (z : spectrum 𝕜 a) :
∫ x, f x z ∂μ = (∫ x, mkD ((spectrum 𝕜 a).restrict (f x)) 0 ∂μ) z := by
rw [integral_apply hf₂]
refine integral_congr_ae ?_
filter_upwards [hf₁] with x cont_x
rw [mkD_apply_of_continuousOn cont_x]
have key₂ (z : spectrum 𝕜 a) :
∫ x, f x z ∂μ = mkD ((spectrum 𝕜 a).restrict (fun z ↦ ∫ x, f x z ∂μ)) 0 z := by
rw [mkD_apply_of_continuousOn]
rw [continuousOn_iff_continuous_restrict]
refine continuous_congr key₁ |>.mpr ?_
exact map_continuous (∫ x, mkD ((spectrum 𝕜 a).restrict (f x)) 0 ∂μ)
simp_rw [cfc_eq_cfcL_mkD _ a, cfcL_integral a _ hf₂ ha]
congr
ext z
rw [← key₁, key₂]
open Set in
/-- The continuous functional calculus commutes with integration.
For a version with stronger assumptions which in practice are often easier to verify, see
`cfc_setIntegral`. -/
lemma cfc_setIntegral' {s : Set X} [NormedSpace ℝ A] (f : X → 𝕜 → 𝕜) (a : A)
(hf₁ : ∀ᵐ x ∂(μ.restrict s), ContinuousOn (f x) (spectrum 𝕜 a))
(hf₂ : IntegrableOn
(fun x : X => mkD ((spectrum 𝕜 a).restrict (f x)) 0) s μ)
(ha : p a := by cfc_tac) :
cfc (fun z => ∫ x in s, f x z ∂μ) a = ∫ x in s, cfc (f x) a ∂μ :=
cfc_integral' _ _ hf₁ hf₂ ha
open Function Set in
/-- The continuous functional calculus commutes with integration.
This version assumes joint continuity of `f`, see `cfc_integral'` for a statement
with weaker assumptions. -/
lemma cfc_integral [NormedSpace ℝ A] [TopologicalSpace X] [OpensMeasurableSpace X]
(f : X → 𝕜 → 𝕜) (bound : X → ℝ) (a : A) [SecondCountableTopologyEither X C(spectrum 𝕜 a, 𝕜)]
(hf : ContinuousOn (uncurry f) (univ ×ˢ spectrum 𝕜 a))
(bound_ge : ∀ᵐ x ∂μ, ∀ z ∈ spectrum 𝕜 a, ‖f x z‖ ≤ bound x)
(bound_int : HasFiniteIntegral bound μ) (ha : p a := by cfc_tac) :
cfc (fun r => ∫ x, f x r ∂μ) a = ∫ x, cfc (f x) a ∂μ := by
have : ∀ᵐ (x : X) ∂μ, ContinuousOn (f x) (spectrum 𝕜 a) := .of_forall fun x ↦
hf.comp (Continuous.prodMk_right x).continuousOn fun _ hz ↦ ⟨Set.mem_univ _, hz⟩
refine cfc_integral' _ _ this ⟨?_, ?_⟩ ha
· exact aeStronglyMeasurable_mkD_restrict_of_uncurry _ _ hf
· exact hasFiniteIntegral_mkD_restrict_of_bound f _ this bound bound_int bound_ge
open Function Set in
/-- The continuous functional calculus commutes with integration.
This version assumes joint continuity of `f`, see `cfc_setIntegral'` for a statement
with weaker assumptions. -/
lemma cfc_setIntegral [NormedSpace ℝ A] [TopologicalSpace X] [OpensMeasurableSpace X] {s : Set X}
(hs : MeasurableSet s) (f : X → 𝕜 → 𝕜) (bound : X → ℝ) (a : A)
[SecondCountableTopologyEither X C(spectrum 𝕜 a, 𝕜)]
(hf : ContinuousOn (uncurry f) (s ×ˢ spectrum 𝕜 a))
(bound_ge : ∀ᵐ x ∂(μ.restrict s), ∀ z ∈ spectrum 𝕜 a, ‖f x z‖ ≤ bound x)
(bound_int : HasFiniteIntegral bound (μ.restrict s)) (ha : p a := by cfc_tac) :
cfc (fun r => ∫ x in s, f x r ∂μ) a = ∫ x in s, cfc (f x) a ∂μ := by
have : ∀ᵐ (x : X) ∂(μ.restrict s), ContinuousOn (f x) (spectrum 𝕜 a) :=
ae_restrict_of_forall_mem hs fun x hx ↦
hf.comp (Continuous.prodMk_right x).continuousOn fun _ hz ↦ ⟨hx, hz⟩
refine cfc_setIntegral' _ _ this ⟨?_, ?_⟩ ha
· exact aeStronglyMeasurable_restrict_mkD_restrict_of_uncurry hs _ _ hf
· exact hasFiniteIntegral_mkD_restrict_of_bound f _ this bound bound_int bound_ge
end unital
section nonunital
open ContinuousMapZero
variable {X : Type*} {𝕜 : Type*} {A : Type*} {p : A → Prop} [RCLike 𝕜]
[MeasurableSpace X] {μ : Measure X} [NonUnitalNormedRing A] [StarRing A]
[NormedSpace 𝕜 A] [IsScalarTower 𝕜 A A] [SMulCommClass 𝕜 A A]
[NonUnitalContinuousFunctionalCalculus 𝕜 A p]
[CompleteSpace A]
lemma cfcₙL_integral [NormedSpace ℝ A] (a : A) (f : X → C(quasispectrum 𝕜 a, 𝕜)₀)
(hf₁ : Integrable f μ) (ha : p a := by cfc_tac) :
∫ x, cfcₙL (a := a) ha (f x) ∂μ = cfcₙL (a := a) ha (∫ x, f x ∂μ) := by
rw [ContinuousLinearMap.integral_comp_comm _ hf₁]
lemma cfcₙHom_integral [NormedSpace ℝ A] (a : A) (f : X → C(quasispectrum 𝕜 a, 𝕜)₀)
(hf₁ : Integrable f μ) (ha : p a := by cfc_tac) :
∫ x, cfcₙHom (a := a) ha (f x) ∂μ = cfcₙHom (a := a) ha (∫ x, f x ∂μ) :=
cfcₙL_integral a f hf₁ ha
lemma cfcₙL_integrable (a : A) (f : X → C(quasispectrum 𝕜 a, 𝕜)₀)
(hf₁ : Integrable f μ) (ha : p a := by cfc_tac) :
Integrable (fun x ↦ cfcₙL (a := a) ha (f x)) μ :=
ContinuousLinearMap.integrable_comp _ hf₁
/-- An integrability criterion for the continuous functional calculus.
For a version with stronger assumptions which in practice are often easier to verify, see
`integrable_cfcₙ`. -/
lemma integrable_cfcₙ' (f : X → 𝕜 → 𝕜) (a : A)
(hf : Integrable
(fun x : X => mkD ((quasispectrum 𝕜 a).restrict (f x)) 0) μ)
(ha : p a := by cfc_tac) :
Integrable (fun x => cfcₙ (f x) a) μ := by
conv in cfcₙ _ _ => rw [cfcₙ_eq_cfcₙL_mkD _ a]
exact cfcₙL_integrable _ _ hf ha
/-- An integrability criterion for the continuous functional calculus.
For a version with stronger assumptions which in practice are often easier to verify, see
`integrableOn_cfcₙ`. -/
lemma integrableOn_cfcₙ' {s : Set X} (f : X → 𝕜 → 𝕜) (a : A)
(hf : IntegrableOn
(fun x : X => mkD ((quasispectrum 𝕜 a).restrict (f x)) 0) s μ)
(ha : p a := by cfc_tac) :
IntegrableOn (fun x => cfcₙ (f x) a) s μ := by
exact integrable_cfcₙ' _ _ hf ha
open Set Function in
/-- An integrability criterion for the continuous functional calculus.
This version assumes joint continuity of `f`, see `integrable_cfcₙ'` for a statement
with weaker assumptions. -/
lemma integrable_cfcₙ [TopologicalSpace X] [OpensMeasurableSpace X] (f : X → 𝕜 → 𝕜)
(bound : X → ℝ) (a : A)
[SecondCountableTopologyEither X C(quasispectrum 𝕜 a, 𝕜)]
(hf : ContinuousOn (uncurry f) (univ ×ˢ quasispectrum 𝕜 a))
(f_zero : ∀ᵐ x ∂μ, f x 0 = 0)
(bound_ge : ∀ᵐ x ∂μ, ∀ z ∈ quasispectrum 𝕜 a, ‖f x z‖ ≤ bound x)
(bound_int : HasFiniteIntegral bound μ) (ha : p a := by cfc_tac) :
Integrable (fun x => cfcₙ (f x) a) μ := by
refine integrable_cfcₙ' _ _ ⟨?_, ?_⟩ ha
· exact aeStronglyMeasurable_mkD_restrict_of_uncurry _ _ hf f_zero
· refine hasFiniteIntegral_mkD_restrict_of_bound f _ ?_ f_zero bound bound_int bound_ge
exact .of_forall fun x ↦
hf.comp (Continuous.prodMk_right x).continuousOn fun _ hz ↦ ⟨Set.mem_univ _, hz⟩
open Set Function in
/-- An integrability criterion for the continuous functional calculus.
This version assumes joint continuity of `f`, see `integrableOn_cfcₙ'` for a statement
with weaker assumptions. -/
lemma integrableOn_cfcₙ [TopologicalSpace X] [OpensMeasurableSpace X] {s : Set X}
(hs : MeasurableSet s) (f : X → 𝕜 → 𝕜) (bound : X → ℝ) (a : A)
[SecondCountableTopologyEither X C(quasispectrum 𝕜 a, 𝕜)]
(hf : ContinuousOn (uncurry f) (s ×ˢ quasispectrum 𝕜 a))
(f_zero : ∀ᵐ x ∂(μ.restrict s), f x 0 = 0)
(bound_ge : ∀ᵐ x ∂(μ.restrict s), ∀ z ∈ quasispectrum 𝕜 a, ‖f x z‖ ≤ bound x)
(bound_int : HasFiniteIntegral bound (μ.restrict s)) (ha : p a := by cfc_tac) :
IntegrableOn (fun x => cfcₙ (f x) a) s μ := by
refine integrableOn_cfcₙ' _ _ ⟨?_, ?_⟩ ha
· exact aeStronglyMeasurable_restrict_mkD_restrict_of_uncurry hs _ _ hf f_zero
· refine hasFiniteIntegral_mkD_restrict_of_bound f _ ?_ f_zero bound bound_int bound_ge
exact ae_restrict_of_forall_mem hs fun x hx ↦
hf.comp (Continuous.prodMk_right x).continuousOn fun _ hz ↦ ⟨hx, hz⟩
open Set in
/-- The continuous functional calculus commutes with integration.
For a version with stronger assumptions which in practice are often easier to verify, see
`cfcₙ_integral`. -/
lemma cfcₙ_integral' [NormedSpace ℝ A] (f : X → 𝕜 → 𝕜) (a : A)
(hf₁ : ∀ᵐ x ∂μ, ContinuousOn (f x) (quasispectrum 𝕜 a))
(hf₂ : ∀ᵐ x ∂μ, f x 0 = 0)
(hf₃ : Integrable
(fun x : X => mkD ((quasispectrum 𝕜 a).restrict (f x)) 0) μ)
(ha : p a := by cfc_tac) :
cfcₙ (fun z => ∫ x, f x z ∂μ) a = ∫ x, cfcₙ (f x) a ∂μ := by
have key₁ (z : quasispectrum 𝕜 a) :
∫ x, f x z ∂μ = (∫ x, mkD ((quasispectrum 𝕜 a).restrict (f x)) 0 ∂μ) z := by
rw [integral_apply hf₃]
refine integral_congr_ae ?_
filter_upwards [hf₁, hf₂] with x cont_x zero_x
rw [mkD_apply_of_continuousOn cont_x zero_x]
have key₂ (z : quasispectrum 𝕜 a) :
∫ x, f x z ∂μ = mkD ((quasispectrum 𝕜 a).restrict (fun z ↦ ∫ x, f x z ∂μ)) 0 z := by
rw [mkD_apply_of_continuousOn]
· rw [continuousOn_iff_continuous_restrict]
refine continuous_congr key₁ |>.mpr ?_
exact map_continuous (∫ x, mkD ((quasispectrum 𝕜 a).restrict (f x)) 0 ∂μ)
· exact integral_eq_zero_of_ae hf₂
simp_rw [cfcₙ_eq_cfcₙL_mkD _ a, cfcₙL_integral a _ hf₃ ha]
congr
ext z
rw [← key₁, key₂]
open Set in
/-- The continuous functional calculus commutes with integration.
For a version with stronger assumptions which in practice are often easier to verify, see
`cfcₙ_setIntegral`. -/
lemma cfcₙ_setIntegral' {s : Set X} [NormedSpace ℝ A] (f : X → 𝕜 → 𝕜) (a : A)
(hf₁ : ∀ᵐ x ∂(μ.restrict s), ContinuousOn (f x) (quasispectrum 𝕜 a))
(hf₂ : ∀ᵐ x ∂(μ.restrict s), f x 0 = 0)
(hf₃ : IntegrableOn
(fun x : X => mkD ((quasispectrum 𝕜 a).restrict (f x)) 0) s μ)
(ha : p a := by cfc_tac) :
cfcₙ (fun z => ∫ x in s, f x z ∂μ) a = ∫ x in s, cfcₙ (f x) a ∂μ :=
cfcₙ_integral' _ _ hf₁ hf₂ hf₃ ha
open Function Set in
/-- The continuous functional calculus commutes with integration.
This version assumes joint continuity of `f`, see `cfcₙ_integral'` for a statement
with weaker assumptions. -/
lemma cfcₙ_integral [NormedSpace ℝ A] [TopologicalSpace X] [OpensMeasurableSpace X]
(f : X → 𝕜 → 𝕜) (bound : X → ℝ) (a : A)
[SecondCountableTopologyEither X C(quasispectrum 𝕜 a, 𝕜)]
(hf : ContinuousOn (uncurry f) (univ ×ˢ quasispectrum 𝕜 a))
(f_zero : ∀ᵐ x ∂μ, f x 0 = 0)
(bound_ge : ∀ᵐ x ∂μ, ∀ z ∈ quasispectrum 𝕜 a, ‖f x z‖ ≤ bound x)
(bound_int : HasFiniteIntegral bound μ) (ha : p a := by cfc_tac) :
cfcₙ (fun r => ∫ x, f x r ∂μ) a = ∫ x, cfcₙ (f x) a ∂μ := by
have : ∀ᵐ (x : X) ∂μ, ContinuousOn (f x) (quasispectrum 𝕜 a) := .of_forall fun x ↦
hf.comp (Continuous.prodMk_right x).continuousOn fun _ hz ↦ ⟨Set.mem_univ _, hz⟩
refine cfcₙ_integral' _ _ this f_zero ⟨?_, ?_⟩ ha
· exact aeStronglyMeasurable_mkD_restrict_of_uncurry _ _ hf f_zero
· exact hasFiniteIntegral_mkD_restrict_of_bound f _ this f_zero bound bound_int bound_ge
open Function Set in
/-- The continuous functional calculus commutes with integration.
This version assumes joint continuity of `f`, see `cfcₙ_setIntegral'` for a statement
with weaker assumptions. -/
lemma cfcₙ_setIntegral [NormedSpace ℝ A] [TopologicalSpace X] [OpensMeasurableSpace X] {s : Set X}
(hs : MeasurableSet s) (f : X → 𝕜 → 𝕜) (bound : X → ℝ) (a : A)
[SecondCountableTopologyEither X C(quasispectrum 𝕜 a, 𝕜)]
(hf : ContinuousOn (uncurry f) (s ×ˢ quasispectrum 𝕜 a))
(f_zero : ∀ᵐ x ∂(μ.restrict s), f x 0 = 0)
(bound_ge : ∀ᵐ x ∂(μ.restrict s), ∀ z ∈ quasispectrum 𝕜 a, ‖f x z‖ ≤ bound x)
(bound_int : HasFiniteIntegral bound (μ.restrict s)) (ha : p a := by cfc_tac) :
cfcₙ (fun r => ∫ x in s, f x r ∂μ) a = ∫ x in s, cfcₙ (f x) a ∂μ := by
have : ∀ᵐ (x : X) ∂(μ.restrict s), ContinuousOn (f x) (quasispectrum 𝕜 a) :=
ae_restrict_of_forall_mem hs fun x hx ↦
hf.comp (Continuous.prodMk_right x).continuousOn fun _ hz ↦ ⟨hx, hz⟩
refine cfcₙ_setIntegral' _ _ this f_zero ⟨?_, ?_⟩ ha
· exact aeStronglyMeasurable_restrict_mkD_restrict_of_uncurry hs _ _ hf f_zero
· exact hasFiniteIntegral_mkD_restrict_of_bound f _ this f_zero bound bound_int bound_ge
end nonunital |
.lake/packages/mathlib/Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Order.lean | import Mathlib.Analysis.CStarAlgebra.ContinuousFunctionalCalculus.Basic
import Mathlib.Analysis.CStarAlgebra.Unitization
import Mathlib.Analysis.SpecialFunctions.ContinuousFunctionalCalculus.Rpow.Basic
import Mathlib.Analysis.CStarAlgebra.ContinuousFunctionalCalculus.Isometric
import Mathlib.Topology.ContinuousMap.ContinuousSqrt
/-! # Facts about star-ordered rings that depend on the continuous functional calculus
This file contains various basic facts about star-ordered rings (i.e. mainly C⋆-algebras)
that depend on the continuous functional calculus.
We also put an order instance on `A⁺¹ := Unitization ℂ A` when `A` is a C⋆-algebra via
the spectral order.
## Main theorems
* `IsSelfAdjoint.le_algebraMap_norm_self` and `IsSelfAdjoint.le_algebraMap_norm_self`,
which respectively show that `a ≤ algebraMap ℝ A ‖a‖` and `-(algebraMap ℝ A ‖a‖) ≤ a` in a
C⋆-algebra.
* `mul_star_le_algebraMap_norm_sq` and `star_mul_le_algebraMap_norm_sq`, which give similar
statements for `a * star a` and `star a * a`.
* `CStarAlgebra.norm_le_norm_of_nonneg_of_le`: in a non-unital C⋆-algebra, if `0 ≤ a ≤ b`, then
`‖a‖ ≤ ‖b‖`.
* `CStarAlgebra.conjugate_le_norm_smul`: in a non-unital C⋆-algebra, we have that
`star a * b * a ≤ ‖b‖ • (star a * a)` (and a primed version for the `a * b * star a` case).
* `CStarAlgebra.inv_le_inv_iff`: in a unital C⋆-algebra, `b⁻¹ ≤ a⁻¹` iff `a ≤ b`.
## Tags
continuous functional calculus, normal, selfadjoint
-/
open scoped NNReal CStarAlgebra
local notation "σₙ" => quasispectrum
theorem cfc_tsub {A : Type*} [TopologicalSpace A] [Ring A] [PartialOrder A] [StarRing A]
[StarOrderedRing A] [Algebra ℝ A] [IsTopologicalRing A] [T2Space A]
[ContinuousFunctionalCalculus ℝ A IsSelfAdjoint]
[NonnegSpectrumClass ℝ A] (f g : ℝ≥0 → ℝ≥0)
(a : A) (hfg : ∀ x ∈ spectrum ℝ≥0 a, g x ≤ f x) (ha : 0 ≤ a := by cfc_tac)
(hf : ContinuousOn f (spectrum ℝ≥0 a) := by cfc_cont_tac)
(hg : ContinuousOn g (spectrum ℝ≥0 a) := by cfc_cont_tac) :
cfc (fun x ↦ f x - g x) a = cfc f a - cfc g a := by
have ha' := SpectrumRestricts.nnreal_of_nonneg ha
have : (spectrum ℝ a).EqOn (fun x ↦ ((f x.toNNReal - g x.toNNReal : ℝ≥0) : ℝ))
(fun x ↦ f x.toNNReal - g x.toNNReal) :=
fun x hx ↦ NNReal.coe_sub <| hfg _ <| ha'.apply_mem hx
rw [cfc_nnreal_eq_real .., cfc_nnreal_eq_real .., cfc_nnreal_eq_real .., cfc_congr this]
refine cfc_sub _ _ a ?_ ?_
all_goals
exact continuous_subtype_val.comp_continuousOn <|
ContinuousOn.comp ‹_› continuous_real_toNNReal.continuousOn <| ha'.image ▸ Set.mapsTo_image ..
theorem cfcₙ_tsub {A : Type*} [TopologicalSpace A] [NonUnitalRing A] [PartialOrder A] [StarRing A]
[StarOrderedRing A] [Module ℝ A] [IsScalarTower ℝ A A] [SMulCommClass ℝ A A]
[IsTopologicalRing A] [T2Space A] [NonUnitalContinuousFunctionalCalculus ℝ A IsSelfAdjoint]
[NonnegSpectrumClass ℝ A] (f g : ℝ≥0 → ℝ≥0)
(a : A) (hfg : ∀ x ∈ σₙ ℝ≥0 a, g x ≤ f x) (ha : 0 ≤ a := by cfc_tac)
(hf : ContinuousOn f (σₙ ℝ≥0 a) := by cfc_cont_tac) (hf0 : f 0 = 0 := by cfc_zero_tac)
(hg : ContinuousOn g (σₙ ℝ≥0 a) := by cfc_cont_tac) (hg0 : g 0 = 0 := by cfc_zero_tac) :
cfcₙ (fun x ↦ f x - g x) a = cfcₙ f a - cfcₙ g a := by
have ha' := QuasispectrumRestricts.nnreal_of_nonneg ha
have : (σₙ ℝ a).EqOn (fun x ↦ ((f x.toNNReal - g x.toNNReal : ℝ≥0) : ℝ))
(fun x ↦ f x.toNNReal - g x.toNNReal) :=
fun x hx ↦ NNReal.coe_sub <| hfg _ <| ha'.apply_mem hx
rw [cfcₙ_nnreal_eq_real .., cfcₙ_nnreal_eq_real .., cfcₙ_nnreal_eq_real .., cfcₙ_congr this]
refine cfcₙ_sub _ _ a ?_ (by simpa) ?_
all_goals
exact continuous_subtype_val.comp_continuousOn <|
ContinuousOn.comp ‹_› continuous_real_toNNReal.continuousOn <| ha'.image ▸ Set.mapsTo_image ..
namespace Unitization
variable {A : Type*} [NonUnitalCStarAlgebra A] [PartialOrder A] [StarOrderedRing A]
noncomputable instance instPartialOrder : PartialOrder A⁺¹ :=
CStarAlgebra.spectralOrder _
instance instStarOrderedRing : StarOrderedRing A⁺¹ :=
CStarAlgebra.spectralOrderedRing _
lemma inr_le_iff (a b : A) (ha : IsSelfAdjoint a := by cfc_tac)
(hb : IsSelfAdjoint b := by cfc_tac) :
(a : A⁺¹) ≤ (b : A⁺¹) ↔ a ≤ b := by
-- TODO: prove the more general result for star monomorphisms and use it here.
rw [← sub_nonneg, ← sub_nonneg (a := b), StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) _,
← inr_sub ℂ b a, ← Unitization.quasispectrum_eq_spectrum_inr' ℝ ℂ]
exact StarOrderedRing.nonneg_iff_quasispectrum_nonneg _ |>.symm
@[simp, norm_cast]
lemma inr_nonneg_iff {a : A} : 0 ≤ (a : A⁺¹) ↔ 0 ≤ a := by
by_cases ha : IsSelfAdjoint a
· exact inr_zero ℂ (A := A) ▸ inr_le_iff 0 a
· refine ⟨?_, ?_⟩
all_goals refine fun h ↦ (ha ?_).elim
· exact isSelfAdjoint_inr (R := ℂ) |>.mp <| .of_nonneg h
· exact .of_nonneg h
lemma nnreal_cfcₙ_eq_cfc_inr (a : A) (f : ℝ≥0 → ℝ≥0)
(hf₀ : f 0 = 0 := by cfc_zero_tac) : cfcₙ f a = cfc f (a : A⁺¹) :=
cfcₙ_eq_cfc_inr inr_nonneg_iff ..
end Unitization
/-- `cfc_le_iff` only applies to a scalar ring where `R` is an actual `Ring`, and not a `Semiring`.
However, this theorem still holds for `ℝ≥0` as long as the algebra `A` itself is an `ℝ`-algebra. -/
lemma cfc_nnreal_le_iff {A : Type*} [TopologicalSpace A] [Ring A] [StarRing A] [PartialOrder A]
[StarOrderedRing A] [Algebra ℝ A] [IsTopologicalRing A] [NonnegSpectrumClass ℝ A]
[T2Space A] [ContinuousFunctionalCalculus ℝ A IsSelfAdjoint]
(f : ℝ≥0 → ℝ≥0) (g : ℝ≥0 → ℝ≥0) (a : A)
(ha_spec : SpectrumRestricts a ContinuousMap.realToNNReal)
(hf : ContinuousOn f (spectrum ℝ≥0 a) := by cfc_cont_tac)
(hg : ContinuousOn g (spectrum ℝ≥0 a) := by cfc_cont_tac)
(ha : 0 ≤ a := by cfc_tac) :
cfc f a ≤ cfc g a ↔ ∀ x ∈ spectrum ℝ≥0 a, f x ≤ g x := by
have hf' := hf.ofReal_map_toNNReal <| ha_spec.image ▸ Set.mapsTo_image ..
have hg' := hg.ofReal_map_toNNReal <| ha_spec.image ▸ Set.mapsTo_image ..
rw [cfc_nnreal_eq_real .., cfc_nnreal_eq_real .., cfc_le_iff ..]
simp [NNReal.coe_le_coe, ← ha_spec.image]
open ContinuousFunctionalCalculus in
/-- In a unital `ℝ`-algebra `A` with a continuous functional calculus, an element `a : A` is larger
than some `algebraMap ℝ A r` if and only if every element of the `ℝ`-spectrum is nonnegative. -/
lemma CFC.exists_pos_algebraMap_le_iff {A : Type*} [TopologicalSpace A] [Ring A] [StarRing A]
[PartialOrder A] [StarOrderedRing A] [Algebra ℝ A] [NonnegSpectrumClass ℝ A] [Nontrivial A]
[ContinuousFunctionalCalculus ℝ A IsSelfAdjoint]
{a : A} (ha : IsSelfAdjoint a := by cfc_tac) :
(∃ r > 0, algebraMap ℝ A r ≤ a) ↔ (∀ x ∈ spectrum ℝ a, 0 < x) := by
have h_cpct : IsCompact (spectrum ℝ a) := isCompact_iff_compactSpace.mpr inferInstance
simp_rw [algebraMap_le_iff_le_spectrum (a := a)]
refine ⟨?_, fun h ↦ ?_⟩
· rintro ⟨r, hr, hr_le⟩
exact (hr.trans_le <| hr_le · ·)
· obtain ⟨r, hr, hr_min⟩ := h_cpct.exists_isMinOn (spectrum_nonempty ℝ a ha) continuousOn_id
exact ⟨r, h _ hr, hr_min⟩
section CStar_unital
variable {A : Type*} [CStarAlgebra A]
section StarOrderedRing
variable [PartialOrder A] [StarOrderedRing A]
lemma IsSelfAdjoint.le_algebraMap_norm_self {a : A} (ha : IsSelfAdjoint a := by cfc_tac) :
a ≤ algebraMap ℝ A ‖a‖ := by
by_cases! nontriv : Nontrivial A
· refine le_algebraMap_of_spectrum_le fun r hr => ?_
calc r ≤ ‖r‖ := Real.le_norm_self r
_ ≤ ‖a‖ := spectrum.norm_le_norm_of_mem hr
· simp
lemma IsSelfAdjoint.neg_algebraMap_norm_le_self {a : A} (ha : IsSelfAdjoint a := by cfc_tac) :
- (algebraMap ℝ A ‖a‖) ≤ a := by
rw [neg_le, ← norm_neg]
exact ha.neg.le_algebraMap_norm_self
lemma CStarAlgebra.mul_star_le_algebraMap_norm_sq {a : A} :
a * star a ≤ algebraMap ℝ A (‖a‖ ^ 2) := by
have : a * star a ≤ algebraMap ℝ A ‖a * star a‖ := IsSelfAdjoint.le_algebraMap_norm_self
rwa [CStarRing.norm_self_mul_star, ← pow_two] at this
lemma CStarAlgebra.star_mul_le_algebraMap_norm_sq {a : A} :
star a * a ≤ algebraMap ℝ A (‖a‖ ^ 2) := by
have : star a * a ≤ algebraMap ℝ A ‖star a * a‖ := IsSelfAdjoint.le_algebraMap_norm_self
rwa [CStarRing.norm_star_mul_self, ← pow_two] at this
end StarOrderedRing
lemma IsSelfAdjoint.toReal_spectralRadius_eq_norm {a : A} (ha : IsSelfAdjoint a) :
(spectralRadius ℝ a).toReal = ‖a‖ := by
simp [ha.spectrumRestricts.spectralRadius_eq, ha.spectralRadius_eq_nnnorm]
namespace CStarAlgebra
lemma norm_or_neg_norm_mem_spectrum [Nontrivial A] {a : A}
(ha : IsSelfAdjoint a := by cfc_tac) : ‖a‖ ∈ spectrum ℝ a ∨ -‖a‖ ∈ spectrum ℝ a := by
have ha' : SpectrumRestricts a Complex.reCLM := ha.spectrumRestricts
rw [← ha.toReal_spectralRadius_eq_norm]
exact Real.spectralRadius_mem_spectrum_or (ha'.image ▸ (spectrum.nonempty a).image _)
variable [PartialOrder A] [StarOrderedRing A]
lemma nnnorm_mem_spectrum_of_nonneg [Nontrivial A] {a : A} (ha : 0 ≤ a := by cfc_tac) :
‖a‖₊ ∈ spectrum ℝ≥0 a := by
have : IsSelfAdjoint a := .of_nonneg ha
convert NNReal.spectralRadius_mem_spectrum (a := a) ?_ (.nnreal_of_nonneg ha)
· simp [this.spectrumRestricts.spectralRadius_eq, this.spectralRadius_eq_nnnorm]
· exact this.spectrumRestricts.image ▸ (spectrum.nonempty a).image _
lemma norm_mem_spectrum_of_nonneg [Nontrivial A] {a : A} (ha : 0 ≤ a := by cfc_tac) :
‖a‖ ∈ spectrum ℝ a := by
simpa using spectrum.algebraMap_mem ℝ <| nnnorm_mem_spectrum_of_nonneg ha
lemma norm_le_iff_le_algebraMap (a : A) {r : ℝ} (hr : 0 ≤ r) (ha : 0 ≤ a := by cfc_tac) :
‖a‖ ≤ r ↔ a ≤ algebraMap ℝ A r := by
rw [le_algebraMap_iff_spectrum_le]
obtain (h | _) := subsingleton_or_nontrivial A
· simp [Subsingleton.elim a 0, hr]
· exact ⟨fun h x hx ↦ Real.le_norm_self x |>.trans (spectrum.norm_le_norm_of_mem hx) |>.trans h,
fun h ↦ h ‖a‖ <| norm_mem_spectrum_of_nonneg⟩
lemma nnnorm_le_iff_of_nonneg (a : A) (r : ℝ≥0) (ha : 0 ≤ a := by cfc_tac) :
‖a‖₊ ≤ r ↔ a ≤ algebraMap ℝ≥0 A r := by
rw [← NNReal.coe_le_coe]
exact norm_le_iff_le_algebraMap a r.2
lemma norm_le_one_iff_of_nonneg (a : A) (ha : 0 ≤ a := by cfc_tac) :
‖a‖ ≤ 1 ↔ a ≤ 1 := by
simpa using norm_le_iff_le_algebraMap a zero_le_one
lemma nnnorm_le_one_iff_of_nonneg (a : A) (ha : 0 ≤ a := by cfc_tac) :
‖a‖₊ ≤ 1 ↔ a ≤ 1 := by
rw [← NNReal.coe_le_coe]
exact norm_le_one_iff_of_nonneg a
lemma norm_le_natCast_iff_of_nonneg (a : A) (n : ℕ) (ha : 0 ≤ a := by cfc_tac) :
‖a‖ ≤ n ↔ a ≤ n := by
simpa using norm_le_iff_le_algebraMap a n.cast_nonneg
lemma nnnorm_le_natCast_iff_of_nonneg (a : A) (n : ℕ) (ha : 0 ≤ a := by cfc_tac) :
‖a‖₊ ≤ n ↔ a ≤ n := by
simpa using nnnorm_le_iff_of_nonneg a n
section Icc
open Set
lemma mem_Icc_algebraMap_iff_norm_le {x : A} {r : ℝ} (hr : 0 ≤ r) :
x ∈ Icc 0 (algebraMap ℝ A r) ↔ 0 ≤ x ∧ ‖x‖ ≤ r := by
rw [mem_Icc, and_congr_right_iff, iff_comm]
exact (norm_le_iff_le_algebraMap _ hr ·)
lemma mem_Icc_algebraMap_iff_nnnorm_le {x : A} {r : ℝ≥0} :
x ∈ Icc 0 (algebraMap ℝ≥0 A r) ↔ 0 ≤ x ∧ ‖x‖₊ ≤ r :=
mem_Icc_algebraMap_iff_norm_le (hr := r.2)
lemma mem_Icc_iff_norm_le_one {x : A} :
x ∈ Icc 0 1 ↔ 0 ≤ x ∧ ‖x‖ ≤ 1 := by
simpa only [map_one] using mem_Icc_algebraMap_iff_norm_le zero_le_one (A := A)
lemma mem_Icc_iff_nnnorm_le_one {x : A} :
x ∈ Icc 0 1 ↔ 0 ≤ x ∧ ‖x‖₊ ≤ 1 :=
mem_Icc_iff_norm_le_one
end Icc
end CStarAlgebra
section Inv
open CFC
variable [PartialOrder A] [StarOrderedRing A]
lemma CFC.conjugate_rpow_neg_one_half (a : A) (ha : IsStrictlyPositive a := by cfc_tac) :
a ^ (-(1 / 2) : ℝ) * a * a ^ (-(1 / 2) : ℝ) = 1 := by
lift a to Aˣ using ha.isUnit
nth_rw 2 [← rpow_one (a : A)]
simp only [← rpow_add a.isUnit]
norm_num
exact rpow_zero _
/-- In a unital C⋆-algebra, if `a` is strictly positive, and `a ≤ b`, then `b` is
invertible. -/
lemma CStarAlgebra.isUnit_of_le (a : A) {b : A} (hab : a ≤ b)
(h : IsStrictlyPositive a := by cfc_tac) : IsUnit b := by
have h₀ := h.isUnit
have ha := h.nonneg
rw [← spectrum.zero_notMem_iff ℝ≥0] at h₀ ⊢
nontriviality A
have hb := (show 0 ≤ a from ha).trans hab
rw [zero_notMem_iff, SpectrumRestricts.nnreal_lt_iff (.nnreal_of_nonneg ‹_›),
NNReal.coe_zero, ← CFC.exists_pos_algebraMap_le_iff (.of_nonneg ‹_›)] at h₀ ⊢
peel h₀ with r hr _
exact this.trans hab
lemma le_iff_norm_sqrt_mul_rpow (a b : A) (ha : 0 ≤ a := by cfc_tac)
(hb : IsStrictlyPositive b := by cfc_tac) :
a ≤ b ↔ ‖sqrt a * (b : A) ^ (-(1 / 2) : ℝ)‖ ≤ 1 := by
lift b to Aˣ using hb.isUnit
have hbab : 0 ≤ (b : A) ^ (-(1 / 2) : ℝ) * a * (b : A) ^ (-(1 / 2) : ℝ) :=
conjugate_nonneg_of_nonneg ha rpow_nonneg
conv_rhs =>
rw [← sq_le_one_iff₀ (norm_nonneg _), sq, ← CStarRing.norm_star_mul_self, star_mul,
IsSelfAdjoint.of_nonneg (sqrt_nonneg a), IsSelfAdjoint.of_nonneg rpow_nonneg,
← mul_assoc, mul_assoc _ _ (sqrt a), sqrt_mul_sqrt_self a,
CStarAlgebra.norm_le_one_iff_of_nonneg _ hbab]
refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩
· calc
_ ≤ ↑b ^ (-(1 / 2) : ℝ) * (b : A) * ↑b ^ (-(1 / 2) : ℝ) :=
IsSelfAdjoint.of_nonneg rpow_nonneg |>.conjugate_le_conjugate h
_ = 1 := conjugate_rpow_neg_one_half (b : A)
· calc
a = (sqrt ↑b * ↑b ^ (-(1 / 2) : ℝ)) * a * (↑b ^ (-(1 / 2) : ℝ) * sqrt ↑b) := by
simp only [CFC.sqrt_eq_rpow .., ← CFC.rpow_add b.isUnit]
norm_num
simp [CFC.rpow_zero (b : A)]
_ = sqrt ↑b * (↑b ^ (-(1 / 2) : ℝ) * a * ↑b ^ (-(1 / 2) : ℝ)) * sqrt ↑b := by
simp only [mul_assoc]
_ ≤ b := conjugate_le_conjugate_of_nonneg h (sqrt_nonneg _) |>.trans <| by
simp [CFC.sqrt_mul_sqrt_self (b : A)]
lemma le_iff_norm_sqrt_mul_sqrt_inv {a : A} {b : Aˣ} (ha : 0 ≤ a) (hb : 0 ≤ (b : A)) :
a ≤ b ↔ ‖sqrt a * sqrt (↑b⁻¹ : A)‖ ≤ 1 := by
rw [CFC.sqrt_eq_rpow (a := (↑b⁻¹ : A)), ← CFC.rpow_neg_one_eq_inv b,
CFC.rpow_rpow (b : A) _ _ (by simp) (by simp),
le_iff_norm_sqrt_mul_rpow a (hb := b.isUnit.isStrictlyPositive hb)]
simp
namespace CStarAlgebra
/-- In a unital C⋆-algebra, if `0 ≤ a ≤ b` and `a` and `b` are units, then `b⁻¹ ≤ a⁻¹`. -/
protected lemma inv_le_inv {a b : Aˣ} (ha : 0 ≤ (a : A))
(hab : (a : A) ≤ b) : (↑b⁻¹ : A) ≤ a⁻¹ := by
have hb := ha.trans hab
have hb_inv : (0 : A) ≤ b⁻¹ := inv_nonneg_of_nonneg b hb
have ha_inv : (0 : A) ≤ a⁻¹ := inv_nonneg_of_nonneg a ha
rw [le_iff_norm_sqrt_mul_sqrt_inv ha hb, ← sq_le_one_iff₀ (norm_nonneg _), sq,
← CStarRing.norm_star_mul_self] at hab
rw [le_iff_norm_sqrt_mul_sqrt_inv hb_inv ha_inv, inv_inv, ← sq_le_one_iff₀ (norm_nonneg _), sq,
← CStarRing.norm_self_mul_star]
rwa [star_mul, IsSelfAdjoint.of_nonneg (sqrt_nonneg _),
IsSelfAdjoint.of_nonneg (sqrt_nonneg _)] at hab ⊢
/-- In a unital C⋆-algebra, if `0 ≤ a` and `0 ≤ b` and `a` and `b` are units, then `a⁻¹ ≤ b⁻¹`
if and only if `b ≤ a`. -/
protected lemma inv_le_inv_iff {a b : Aˣ} (ha : 0 ≤ (a : A)) (hb : 0 ≤ (b : A)) :
(↑a⁻¹ : A) ≤ b⁻¹ ↔ (b : A) ≤ a :=
⟨CStarAlgebra.inv_le_inv (inv_nonneg_of_nonneg a ha), CStarAlgebra.inv_le_inv hb⟩
lemma inv_le_iff {a b : Aˣ} (ha : 0 ≤ (a : A)) (hb : 0 ≤ (↑b : A)) :
(↑a⁻¹ : A) ≤ b ↔ (↑b⁻¹ : A) ≤ a := by
simpa using CStarAlgebra.inv_le_inv_iff ha (inv_nonneg_of_nonneg b hb)
lemma le_inv_iff {a b : Aˣ} (ha : 0 ≤ (a : A)) (hb : 0 ≤ (↑b : A)) :
a ≤ (↑b⁻¹ : A) ↔ b ≤ (↑a⁻¹ : A) := by
simpa using CStarAlgebra.inv_le_inv_iff (inv_nonneg_of_nonneg a ha) hb
lemma one_le_inv_iff_le_one {a : Aˣ} (ha : 0 ≤ (a : A)) :
1 ≤ (↑a⁻¹ : A) ↔ a ≤ 1 := by
simpa using CStarAlgebra.le_inv_iff (a := 1) (by simp) ha
lemma inv_le_one_iff_one_le {a : Aˣ} (ha : 0 ≤ (a : A)) :
(↑a⁻¹ : A) ≤ 1 ↔ 1 ≤ a := by
simpa using CStarAlgebra.inv_le_iff ha (b := 1) (by simp)
lemma inv_le_one {a : Aˣ} (ha : 1 ≤ a) : (↑a⁻¹ : A) ≤ 1 :=
CStarAlgebra.inv_le_one_iff_one_le (zero_le_one.trans ha) |>.mpr ha
lemma le_one_of_one_le_inv {a : Aˣ} (ha : 1 ≤ (↑a⁻¹ : A)) : (a : A) ≤ 1 := by
simpa using CStarAlgebra.inv_le_one ha
lemma rpow_neg_one_le_rpow_neg_one {a b : A} (hab : a ≤ b)
(ha : IsStrictlyPositive a := by cfc_tac) :
b ^ (-1 : ℝ) ≤ a ^ (-1 : ℝ) := by
lift b to Aˣ using isUnit_of_le a hab
lift a to Aˣ using ha.isUnit
rw [rpow_neg_one_eq_inv a, rpow_neg_one_eq_inv b (ha.nonneg.trans hab)]
exact CStarAlgebra.inv_le_inv ha.nonneg hab
lemma rpow_neg_one_le_one {a : A} (ha : 1 ≤ a) : a ^ (-1 : ℝ) ≤ 1 := by
lift a to Aˣ using isUnit_of_le 1 ha
rw [rpow_neg_one_eq_inv a (zero_le_one.trans ha)]
exact inv_le_one ha
protected lemma _root_.IsStrictlyPositive.of_le {a b : A} (ha : IsStrictlyPositive a)
(hab : a ≤ b) : IsStrictlyPositive b :=
⟨ha.nonneg.trans hab, CStarAlgebra.isUnit_of_le a hab⟩
theorem _root_.IsStrictlyPositive.add_nonneg {a b : A}
(ha : IsStrictlyPositive a) (hb : 0 ≤ b) : IsStrictlyPositive (a + b) :=
IsStrictlyPositive.of_le ha ((le_add_iff_nonneg_right a).mpr hb)
theorem _root_.IsStrictlyPositive.nonneg_add {a b : A}
(ha : 0 ≤ a) (hb : IsStrictlyPositive b) : IsStrictlyPositive (a + b) :=
add_comm a b ▸ hb.add_nonneg ha
@[grind ←, aesop 90% apply]
lemma _root_.isStrictlyPositive_add {a b : A}
(h : IsStrictlyPositive a ∧ 0 ≤ b ∨ 0 ≤ a ∧ IsStrictlyPositive b) :
IsStrictlyPositive (a + b) := by
grind [IsStrictlyPositive.add_nonneg, IsStrictlyPositive.nonneg_add]
end CStarAlgebra
end Inv
end CStar_unital
section CStar_nonunital
variable {A : Type*} [NonUnitalCStarAlgebra A] [PartialOrder A] [StarOrderedRing A]
namespace CStarAlgebra
open ComplexOrder in
instance instNonnegSpectrumClassComplexNonUnital : NonnegSpectrumClass ℂ A where
quasispectrum_nonneg_of_nonneg a ha x hx := by
rw [Unitization.quasispectrum_eq_spectrum_inr' ℂ ℂ a] at hx
exact spectrum_nonneg_of_nonneg (Unitization.inr_nonneg_iff.mpr ha) hx
lemma norm_le_norm_of_nonneg_of_le {a b : A} (ha : 0 ≤ a := by cfc_tac) (hab : a ≤ b) :
‖a‖ ≤ ‖b‖ := by
suffices ∀ a b : A⁺¹, 0 ≤ a → a ≤ b → ‖a‖ ≤ ‖b‖ by
have hb := ha.trans hab
simpa only [ge_iff_le, Unitization.norm_inr] using
this a b (by simpa) (by rwa [Unitization.inr_le_iff a b])
intro a b ha hab
have hb : 0 ≤ b := ha.trans hab
-- these two `have`s are just for performance
have := IsSelfAdjoint.of_nonneg ha; have := IsSelfAdjoint.of_nonneg hb
have h₂ : cfc (id : ℝ → ℝ) a ≤ cfc (fun _ => ‖b‖) a := by
calc _ = a := by rw [cfc_id ℝ a]
_ ≤ cfc id b := (cfc_id ℝ b) ▸ hab
_ ≤ cfc (fun _ => ‖b‖) b := by
refine cfc_mono fun x hx => ?_
calc x = ‖x‖ := (Real.norm_of_nonneg (spectrum_nonneg_of_nonneg hb hx)).symm
_ ≤ ‖b‖ := spectrum.norm_le_norm_of_mem hx
_ = _ := by rw [cfc_const _ _, cfc_const _ _]
rw [cfc_le_iff id (fun _ => ‖b‖) a] at h₂
exact h₂ ‖a‖ <| norm_mem_spectrum_of_nonneg ha
theorem nnnorm_le_nnnorm_of_nonneg_of_le {a : A} {b : A} (ha : 0 ≤ a := by cfc_tac) (hab : a ≤ b) :
‖a‖₊ ≤ ‖b‖₊ :=
norm_le_norm_of_nonneg_of_le ha hab
lemma star_left_conjugate_le_norm_smul {a b : A} (hb : IsSelfAdjoint b := by cfc_tac) :
star a * b * a ≤ ‖b‖ • (star a * a) := by
suffices ∀ a b : A⁺¹, IsSelfAdjoint b → star a * b * a ≤ ‖b‖ • (star a * a) by
rw [← Unitization.inr_le_iff _ _ (by aesop) ((IsSelfAdjoint.all _).smul (.star_mul_self a))]
simpa [Unitization.norm_inr] using this a b <| hb.inr ℂ
intro a b hb
calc
star a * b * a ≤ star a * (algebraMap ℝ A⁺¹ ‖b‖) * a :=
star_left_conjugate_le_conjugate hb.le_algebraMap_norm_self _
_ = ‖b‖ • (star a * a) := by simp [Algebra.algebraMap_eq_smul_one]
@[deprecated (since := "2025-10-20")] alias conjugate_le_norm_smul :=
star_left_conjugate_le_norm_smul
lemma star_right_conjugate_le_norm_smul {a b : A} (hb : IsSelfAdjoint b := by cfc_tac) :
a * b * star a ≤ ‖b‖ • (a * star a) := by
simpa using star_left_conjugate_le_norm_smul (a := star a)
@[deprecated (since := "2025-10-20")] alias conjugate_le_norm_smul' :=
star_right_conjugate_le_norm_smul
/-- The set of nonnegative elements in a C⋆-algebra is closed. -/
lemma isClosed_nonneg : IsClosed {a : A | 0 ≤ a} := by
suffices IsClosed {a : A⁺¹ | 0 ≤ a} by
rw [Unitization.isometry_inr (𝕜 := ℂ) |>.isClosedEmbedding.isClosed_iff_image_isClosed]
convert this.inter <| (Unitization.isometry_inr (𝕜 := ℂ)).isClosedEmbedding.isClosed_range
ext a
simp only [Set.mem_image, Set.mem_setOf_eq, Set.mem_inter_iff, Set.mem_range, ← exists_and_left]
congr! 2 with x
exact and_congr_left fun h ↦ by simp [← h]
simp only [nonneg_iff_isSelfAdjoint_and_quasispectrumRestricts,
and_congr_right (SpectrumRestricts.nnreal_iff_nnnorm · le_rfl), Set.setOf_and]
refine isClosed_eq ?_ ?_ |>.inter <| isClosed_le ?_ ?_
all_goals fun_prop
instance : OrderClosedTopology A where
isClosed_le' := isClosed_le_of_isClosed_nonneg isClosed_nonneg
section Icc
open Unitization Set Metric
lemma inr_mem_Icc_iff_norm_le {x : A} :
(x : A⁺¹) ∈ Icc 0 1 ↔ 0 ≤ x ∧ ‖x‖ ≤ 1 := by
simp only [mem_Icc, inr_nonneg_iff, and_congr_right_iff]
rw [← norm_inr (𝕜 := ℂ), ← inr_nonneg_iff, iff_comm]
exact (norm_le_one_iff_of_nonneg _ ·)
lemma inr_mem_Icc_iff_nnnorm_le {x : A} :
(x : A⁺¹) ∈ Icc 0 1 ↔ 0 ≤ x ∧ ‖x‖₊ ≤ 1 :=
inr_mem_Icc_iff_norm_le
lemma preimage_inr_Icc_zero_one :
((↑) : A → A⁺¹) ⁻¹' Icc 0 1 = {x : A | 0 ≤ x} ∩ closedBall 0 1 := by
ext
simp [- mem_Icc, inr_mem_Icc_iff_norm_le]
end Icc
end CStarAlgebra
end CStar_nonunital
section Pow
namespace CStarAlgebra
variable {A : Type*} {B : Type*} [CStarAlgebra A] [PartialOrder A] [StarOrderedRing A]
[NonUnitalCStarAlgebra B] [PartialOrder B] [StarOrderedRing B]
lemma pow_nonneg {a : A} (ha : 0 ≤ a := by cfc_tac) (n : ℕ) : 0 ≤ a ^ n := by
rw [← cfc_pow_id (R := ℝ≥0) a]
exact cfc_nonneg_of_predicate
lemma pow_monotone {a : A} (ha : 1 ≤ a) : Monotone (a ^ · : ℕ → A) := by
have ha' : 0 ≤ a := zero_le_one.trans ha
intro n m hnm
simp only
rw [← cfc_pow_id (R := ℝ) a, ← cfc_pow_id (R := ℝ) a, cfc_le_iff ..]
rw [CFC.one_le_iff (R := ℝ) a] at ha
peel ha with x hx _
exact pow_le_pow_right₀ (ha x hx) hnm
lemma pow_antitone {a : A} (ha₀ : 0 ≤ a := by cfc_tac) (ha₁ : a ≤ 1) :
Antitone (a ^ · : ℕ → A) := by
intro n m hnm
simp only
rw [← cfc_pow_id (R := ℝ) a, ← cfc_pow_id (R := ℝ) a, cfc_le_iff ..]
rw [CFC.le_one_iff (R := ℝ) a] at ha₁
peel ha₁ with x hx _
exact pow_le_pow_of_le_one (spectrum_nonneg_of_nonneg ha₀ hx) (ha₁ x hx) hnm
end CStarAlgebra
end Pow |
.lake/packages/mathlib/Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Pi.lean | import Mathlib.Analysis.CStarAlgebra.ContinuousFunctionalCalculus.Unique
import Mathlib.Algebra.Algebra.Spectrum.Pi
import Mathlib.Algebra.Star.StarAlgHom
/-! # The continuous functional calculus on product types
This file contains results about the continuous functional calculus on (indexed) product types.
## Main theorems
+ `cfc_map_pi` and `cfcₙ_map_pi`: given `a : ∀ i, A i`, then `cfc f a = fun i => cfc f (a i)`
(and likewise for the non-unital version)
+ `cfc_map_prod` and `cfcₙ_map_prod`: given `a : A` and `b : B`, then
`cfc f (a, b) = (cfc f a, cfc f b)` (and likewise for the non-unital version)
-/
section nonunital_pi
variable {ι R S : Type*} {A : ι → Type*} [CommSemiring R] [Nontrivial R] [StarRing R]
[MetricSpace R]
[IsTopologicalSemiring R] [ContinuousStar R] [CommRing S] [Algebra R S]
[∀ i, NonUnitalRing (A i)] [∀ i, Module S (A i)] [∀ i, Module R (A i)]
[∀ i, IsScalarTower R S (A i)] [∀ i, SMulCommClass R (A i) (A i)]
[∀ i, IsScalarTower R (A i) (A i)]
[∀ i, StarRing (A i)] [∀ i, TopologicalSpace (A i)] {p : (∀ i, A i) → Prop}
{q : (i : ι) → A i → Prop}
[NonUnitalContinuousFunctionalCalculus R (∀ i, A i) p]
[∀ i, NonUnitalContinuousFunctionalCalculus R (A i) (q i)]
[∀ i, ContinuousMapZero.UniqueHom R (A i)]
include S in
lemma cfcₙ_map_pi (f : R → R) (a : ∀ i, A i)
(hf : ContinuousOn f (⋃ i, quasispectrum R (a i)) := by cfc_cont_tac)
(ha : p a := by cfc_tac) (ha' : ∀ i, q i (a i) := by cfc_tac) :
cfcₙ f a = fun i => cfcₙ f (a i) := by
cases isEmpty_or_nonempty ι with
| inr h =>
by_cases hf₀ : f 0 = 0
· ext i
let φ := Pi.evalNonUnitalStarAlgHom S A i
exact φ.map_cfcₙ f a (by rwa [Pi.quasispectrum_eq]) hf₀ (continuous_apply i) ha (ha' i)
· simp only [cfcₙ_apply_of_not_map_zero _ hf₀, Pi.zero_def]
| inl h =>
exact Subsingleton.elim _ _
end nonunital_pi
section nonunital_prod
variable {A B R S : Type*} [CommSemiring R] [CommRing S] [Nontrivial R] [StarRing R]
[MetricSpace R] [IsTopologicalSemiring R] [ContinuousStar R] [Algebra R S] [NonUnitalRing A]
[NonUnitalRing B] [Module S A] [Module R A] [Module R B] [Module S B]
[SMulCommClass R A A] [SMulCommClass R B B] [IsScalarTower R A A] [IsScalarTower R B B]
[StarRing A] [StarRing B] [TopologicalSpace A] [TopologicalSpace B]
[IsScalarTower R S A] [IsScalarTower R S B]
{pab : A × B → Prop} {pa : A → Prop} {pb : B → Prop}
[NonUnitalContinuousFunctionalCalculus R (A × B) pab]
[NonUnitalContinuousFunctionalCalculus R A pa]
[NonUnitalContinuousFunctionalCalculus R B pb]
[ContinuousMapZero.UniqueHom R A] [ContinuousMapZero.UniqueHom R B]
include S in
lemma cfcₙ_map_prod (f : R → R) (a : A) (b : B)
(hf : ContinuousOn f (quasispectrum R a ∪ quasispectrum R b) := by cfc_cont_tac)
(hab : pab (a, b) := by cfc_tac) (ha : pa a := by cfc_tac) (hb : pb b := by cfc_tac) :
cfcₙ f (a, b) = (cfcₙ f a, cfcₙ f b) := by
by_cases hf₀ : f 0 = 0
case pos =>
ext
case fst =>
let φ := NonUnitalStarAlgHom.fst S A B
exact φ.map_cfcₙ f (a, b) (by rwa [Prod.quasispectrum_eq]) hf₀ continuous_fst hab ha
case snd =>
let φ := NonUnitalStarAlgHom.snd S A B
exact φ.map_cfcₙ f (a, b) (by rwa [Prod.quasispectrum_eq]) hf₀ continuous_snd hab hb
case neg =>
simpa [cfcₙ_apply_of_not_map_zero _ hf₀] using Prod.mk_zero_zero.symm
end nonunital_prod
section unital_pi
variable {ι R S : Type*} {A : ι → Type*} [CommSemiring R] [StarRing R] [MetricSpace R]
[IsTopologicalSemiring R] [ContinuousStar R] [CommRing S] [Algebra R S]
[∀ i, Ring (A i)] [∀ i, Algebra S (A i)] [∀ i, Algebra R (A i)] [∀ i, IsScalarTower R S (A i)]
[hinst : IsScalarTower R S (∀ i, A i)]
[∀ i, StarRing (A i)] [∀ i, TopologicalSpace (A i)] {p : (∀ i, A i) → Prop}
{q : (i : ι) → A i → Prop}
[ContinuousFunctionalCalculus R (∀ i, A i) p]
[∀ i, ContinuousFunctionalCalculus R (A i) (q i)]
[∀ i, ContinuousMap.UniqueHom R (A i)]
include S in
lemma cfc_map_pi (f : R → R) (a : ∀ i, A i)
(hf : ContinuousOn f (⋃ i, spectrum R (a i)) := by cfc_cont_tac)
(ha : p a := by cfc_tac) (ha' : ∀ i, q i (a i) := by cfc_tac) :
cfc f a = fun i => cfc f (a i) := by
ext i
let φ := Pi.evalStarAlgHom S A i
exact φ.map_cfc f a (by rwa [Pi.spectrum_eq]) (continuous_apply i) ha (ha' i)
end unital_pi
section unital_prod
variable {A B R S : Type*} [CommSemiring R] [StarRing R] [MetricSpace R]
[IsTopologicalSemiring R] [ContinuousStar R] [CommRing S] [Algebra R S]
[Ring A] [Ring B] [Algebra S A] [Algebra S B] [Algebra R A] [Algebra R B]
[IsScalarTower R S A] [IsScalarTower R S B]
[StarRing A] [StarRing B] [TopologicalSpace A] [TopologicalSpace B] {pab : A × B → Prop}
{pa : A → Prop} {pb : B → Prop}
[ContinuousFunctionalCalculus R (A × B) pab]
[ContinuousFunctionalCalculus R A pa] [ContinuousFunctionalCalculus R B pb]
[ContinuousMap.UniqueHom R A] [ContinuousMap.UniqueHom R B]
include S in
lemma cfc_map_prod (f : R → R) (a : A) (b : B)
(hf : ContinuousOn f (spectrum R a ∪ spectrum R b) := by cfc_cont_tac)
(hab : pab (a, b) := by cfc_tac) (ha : pa a := by cfc_tac) (hb : pb b := by cfc_tac) :
cfc f (a, b) = (cfc f a, cfc f b) := by
ext
case fst =>
let φ := StarAlgHom.fst S A B
exact φ.map_cfc f (a, b) (by rwa [Prod.spectrum_eq]) continuous_fst hab ha
case snd =>
let φ := StarAlgHom.snd S A B
exact φ.map_cfc f (a, b) (by rwa [Prod.spectrum_eq]) continuous_snd hab hb
end unital_prod |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.