source
stringlengths
17
118
lean4
stringlengths
0
335k
.lake/packages/mathlib/Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Restrict.lean
import Mathlib.Topology.Algebra.Algebra import Mathlib.Analysis.CStarAlgebra.ContinuousFunctionalCalculus.NonUnital /-! # Restriction of the continuous functional calculus to a scalar subring The main declaration in this file is: + `SpectrumRestricts.cfc`: builds a continuous functional calculus over a subring of scalars. This is used for automatically deriving the continuous functional calculi on selfadjoint or positive elements from the one for normal elements. This will allow us to take an instance of the `ContinuousFunctionalCalculus ℂ A IsStarNormal` and produce both of the instances `ContinuousFunctionalCalculus ℝ A IsSelfAdjoint` and `ContinuousFunctionalCalculus ℝ≥0 A (0 ≤ ·)` simply by proving: 1. `IsSelfAdjoint x ↔ IsStarNormal x ∧ SpectrumRestricts Complex.re x`, 2. `0 ≤ x ↔ IsSelfAdjoint x ∧ SpectrumRestricts Real.toNNReal x`. -/ open Set Topology namespace SpectrumRestricts /-- The homeomorphism `spectrum S a ≃ₜ spectrum R a` induced by `SpectrumRestricts a f`. -/ def homeomorph {R S A : Type*} [Semifield R] [Semifield S] [Ring A] [Algebra R S] [Algebra R A] [Algebra S A] [IsScalarTower R S A] [TopologicalSpace R] [TopologicalSpace S] [ContinuousSMul R S] {a : A} {f : C(S, R)} (h : SpectrumRestricts a f) : spectrum S a ≃ₜ spectrum R a where toFun := MapsTo.restrict f _ _ h.subset_preimage invFun := MapsTo.restrict (algebraMap R S) _ _ (image_subset_iff.mp h.algebraMap_image.subset) left_inv x := Subtype.ext <| h.rightInvOn x.2 right_inv x := Subtype.ext <| h.left_inv x lemma compactSpace {R S A : Type*} [Semifield R] [Semifield S] [Ring A] [Algebra R S] [Algebra R A] [Algebra S A] [IsScalarTower R S A] [TopologicalSpace R] [TopologicalSpace S] {a : A} (f : C(S, R)) (h : SpectrumRestricts a f) [h_cpct : CompactSpace (spectrum S a)] : CompactSpace (spectrum R a) := by rw [← isCompact_iff_compactSpace] at h_cpct ⊢ exact h.image ▸ h_cpct.image (map_continuous f) universe u v w /-- If the spectrum of an element restricts to a smaller scalar ring, then a continuous functional calculus over the larger scalar ring descends to the smaller one. -/ @[simps!] def starAlgHom {R : Type u} {S : Type v} {A : Type w} [Semifield R] [StarRing R] [TopologicalSpace R] [IsTopologicalSemiring R] [ContinuousStar R] [Semifield S] [StarRing S] [TopologicalSpace S] [IsTopologicalSemiring S] [ContinuousStar S] [Ring A] [StarRing A] [Algebra R S] [Algebra R A] [Algebra S A] [IsScalarTower R S A] [StarModule R S] [ContinuousSMul R S] {a : A} (φ : C(spectrum S a, S) →⋆ₐ[S] A) {f : C(S, R)} (h : SpectrumRestricts a f) : C(spectrum R a, R) →⋆ₐ[R] A := (φ.restrictScalars R).comp <| (ContinuousMap.compStarAlgHom (spectrum S a) (.ofId R S) (algebraMapCLM R S).continuous).comp <| ContinuousMap.compStarAlgHom' R R ⟨Subtype.map f h.subset_preimage, (map_continuous f).subtype_map fun x (hx : x ∈ spectrum S a) => h.subset_preimage hx⟩ 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] lemma starAlgHom_id {a : A} {φ : C(spectrum S a, S) →⋆ₐ[S] A} {f : C(S, R)} (h : SpectrumRestricts a f) (h_id : φ (.restrict (spectrum S a) <| .id S) = a) : h.starAlgHom φ (.restrict (spectrum R a) <| .id R) = a := by simp only [SpectrumRestricts.starAlgHom_apply] convert h_id ext x exact h.rightInvOn x.2 variable [TopologicalSpace A] [ContinuousFunctionalCalculus S A q] variable [CompleteSpace R] lemma isClosedEmbedding_starAlgHom {a : A} {φ : C(spectrum S a, S) →⋆ₐ[S] A} (hφ : IsClosedEmbedding φ) {f : C(S, R)} (h : SpectrumRestricts a f) (halg : IsUniformEmbedding (algebraMap R S)) : IsClosedEmbedding (h.starAlgHom φ) := hφ.comp <| IsUniformEmbedding.isClosedEmbedding <| .comp (ContinuousMap.isUniformEmbedding_comp _ halg) (UniformEquiv.arrowCongr h.homeomorph.symm (.refl _) |>.isUniformEmbedding) /-- Given a `ContinuousFunctionalCalculus S A q`. If we form the predicate `p` for `a : A` characterized by: `q a` and the spectrum of `a` restricts to the scalar subring `R` via `f : C(S, R)`, then we can get a restricted functional calculus `ContinuousFunctionalCalculus R A p`. -/ protected theorem cfc (f : C(S, R)) (halg : IsUniformEmbedding (algebraMap R S)) (h0 : p 0) (h : ∀ a, p a ↔ q a ∧ SpectrumRestricts a f) : ContinuousFunctionalCalculus R A p where predicate_zero := h0 spectrum_nonempty a ha := ((h a).mp ha).2.image ▸ (ContinuousFunctionalCalculus.spectrum_nonempty a ((h a).mp ha).1 |>.image f) compactSpace_spectrum a := by have := ContinuousFunctionalCalculus.compactSpace_spectrum (R := S) a rw [← isCompact_iff_compactSpace] at this ⊢ simpa using halg.isClosedEmbedding.isCompact_preimage this exists_cfc_of_predicate a ha := by refine ⟨((h a).mp ha).2.starAlgHom (cfcHom ((h a).mp ha).1 (R := S)), ?hom_isClosedEmbedding, ?hom_id, ?hom_map_spectrum, ?predicate_hom⟩ case hom_isClosedEmbedding => exact ((h a).mp ha).2.isClosedEmbedding_starAlgHom (cfcHom_isClosedEmbedding ((h a).mp ha).1) halg case hom_id => exact ((h a).mp ha).2.starAlgHom_id <| cfcHom_id ((h a).mp ha).1 case hom_map_spectrum => intro g rw [SpectrumRestricts.starAlgHom_apply] simp only [← @spectrum.preimage_algebraMap (R := R) S, cfcHom_map_spectrum] ext x constructor · rintro ⟨y, hy⟩ have := congr_arg f hy simp only [ContinuousMap.coe_mk, ContinuousMap.comp_apply, StarAlgHom.ofId_apply] at this rw [((h a).mp ha).2.left_inv _, ((h a).mp ha).2.left_inv _] at this exact ⟨_, this⟩ · rintro ⟨y, rfl⟩ rw [Set.mem_preimage] refine ⟨⟨algebraMap R S y, spectrum.algebraMap_mem S y.prop⟩, ?_⟩ simp only [ContinuousMap.coe_mk, ContinuousMap.comp_apply, StarAlgHom.ofId_apply] congr exact Subtype.ext (((h a).mp ha).2.left_inv y) case predicate_hom => intro g rw [h] refine ⟨cfcHom_predicate _ _, ?_⟩ refine .of_rightInvOn (((h a).mp ha).2.left_inv) fun s hs ↦ ?_ rw [SpectrumRestricts.starAlgHom_apply, cfcHom_map_spectrum] at hs obtain ⟨r, rfl⟩ := hs simp [((h a).mp ha).2.left_inv _] variable [ContinuousFunctionalCalculus R A p] [ContinuousMap.UniqueHom R A] lemma cfcHom_eq_restrict (f : C(S, R)) (halg : IsUniformEmbedding (algebraMap R S)) {a : A} (hpa : p a) (hqa : q a) (h : SpectrumRestricts a f) : cfcHom hpa = h.starAlgHom (cfcHom hqa) := by apply cfcHom_eq_of_continuous_of_map_id · exact h.isClosedEmbedding_starAlgHom (cfcHom_isClosedEmbedding hqa) halg |>.continuous · exact h.starAlgHom_id (cfcHom_id hqa) lemma cfc_eq_restrict (f : C(S, R)) (halg : IsUniformEmbedding (algebraMap R S)) {a : A} (hpa : p a) (hqa : q a) (h : SpectrumRestricts a f) (g : R → R) : cfc g a = cfc (fun x ↦ algebraMap R S (g (f x))) a := by by_cases hg : ContinuousOn g (spectrum R a) · rw [cfc_apply g a, cfcHom_eq_restrict f halg hpa hqa h, SpectrumRestricts.starAlgHom_apply, cfcHom_eq_cfc_extend 0] apply cfc_congr fun x hx ↦ ?_ lift x to spectrum S a using hx simp [Function.comp] · have : ¬ ContinuousOn (fun x ↦ algebraMap R S (g (f x)) : S → S) (spectrum S a) := by refine fun hg' ↦ hg ?_ rw [halg.isEmbedding.continuousOn_iff] simpa [halg.isEmbedding.continuousOn_iff, Function.comp_def, h.left_inv _] using hg'.comp halg.isEmbedding.continuous.continuousOn (fun _ : R ↦ spectrum.algebraMap_mem S) rw [cfc_apply_of_not_continuousOn a hg, cfc_apply_of_not_continuousOn a this] end SpectrumRestricts namespace QuasispectrumRestricts local notation "σₙ" => quasispectrum open ContinuousMapZero Set /-- The homeomorphism `quasispectrum S a ≃ₜ quasispectrum R a` induced by `QuasispectrumRestricts a f`. -/ def homeomorph {R S A : Type*} [Semifield R] [Field S] [NonUnitalRing A] [Algebra R S] [Module R A] [Module S A] [IsScalarTower R S A] [TopologicalSpace R] [TopologicalSpace S] [ContinuousSMul R S] [IsScalarTower S A A] [SMulCommClass S A A] {a : A} {f : C(S, R)} (h : QuasispectrumRestricts a f) : σₙ S a ≃ₜ σₙ R a where toFun := MapsTo.restrict f _ _ h.subset_preimage invFun := MapsTo.restrict (algebraMap R S) _ _ (image_subset_iff.mp h.algebraMap_image.subset) left_inv x := Subtype.ext <| h.rightInvOn x.2 right_inv x := Subtype.ext <| h.left_inv x universe u v w open ContinuousMapZero /-- If the quasispectrum of an element restricts to a smaller scalar ring, then a non-unital continuous functional calculus over the larger scalar ring descends to the smaller one. -/ @[simps!] def nonUnitalStarAlgHom {R : Type u} {S : Type v} {A : Type w} [Semifield R] [StarRing R] [TopologicalSpace R] [IsTopologicalSemiring R] [ContinuousStar R] [Field S] [StarRing S] [TopologicalSpace S] [IsTopologicalRing S] [ContinuousStar S] [NonUnitalRing A] [StarRing A] [Algebra R S] [Module R A] [Module S A] [IsScalarTower S A A] [SMulCommClass S A A] [IsScalarTower R S A] [StarModule R S] [ContinuousSMul R S] {a : A} (φ : C(σₙ S a, S)₀ →⋆ₙₐ[S] A) {f : C(S, R)} (h : QuasispectrumRestricts a f) : C(σₙ R a, R)₀ →⋆ₙₐ[R] A := (φ.restrictScalars R).comp <| (nonUnitalStarAlgHom_postcomp (σₙ S a) (StarAlgHom.ofId R S) (algebraMapCLM R S).continuous) |>.comp <| nonUnitalStarAlgHom_precomp R ⟨⟨Subtype.map f h.subset_preimage, (map_continuous f).subtype_map fun x (hx : x ∈ σₙ S a) => h.subset_preimage hx⟩, Subtype.ext h.map_zero⟩ 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] lemma nonUnitalStarAlgHom_id {a : A} {φ : C(σₙ S a, S)₀ →⋆ₙₐ[S] A} {f : C(S, R)} (h : QuasispectrumRestricts a f) (h_id : φ (.id _) = a) : h.nonUnitalStarAlgHom φ (.id _) = a := by simp only [QuasispectrumRestricts.nonUnitalStarAlgHom_apply] convert h_id ext x exact h.rightInvOn x.2 variable [TopologicalSpace A] [NonUnitalContinuousFunctionalCalculus S A q] variable [CompleteSpace R] lemma isClosedEmbedding_nonUnitalStarAlgHom {a : A} {φ : C(σₙ S a, S)₀ →⋆ₙₐ[S] A} (hφ : IsClosedEmbedding φ) {f : C(S, R)} (h : QuasispectrumRestricts a f) (halg : IsUniformEmbedding (algebraMap R S)) : IsClosedEmbedding (h.nonUnitalStarAlgHom φ) := by have : h.homeomorph.symm 0 = 0 := Subtype.ext (map_zero <| algebraMap _ _) refine hφ.comp <| IsUniformEmbedding.isClosedEmbedding <| .comp (ContinuousMapZero.isUniformEmbedding_comp _ halg) (UniformEquiv.arrowCongrLeft₀ h.homeomorph.symm this |>.isUniformEmbedding) variable [IsScalarTower R A A] [SMulCommClass R A A] /-- Given a `NonUnitalContinuousFunctionalCalculus S A q`. If we form the predicate `p` for `a : A` characterized by: `q a` and the quasispectrum of `a` restricts to the scalar subring `R` via `f : C(S, R)`, then we can get a restricted functional calculus `NonUnitalContinuousFunctionalCalculus R A p`. -/ protected theorem cfc (f : C(S, R)) (halg : IsUniformEmbedding (algebraMap R S)) (h0 : p 0) (h : ∀ a, p a ↔ q a ∧ QuasispectrumRestricts a f) : NonUnitalContinuousFunctionalCalculus R A p where predicate_zero := h0 compactSpace_quasispectrum a := by have := NonUnitalContinuousFunctionalCalculus.compactSpace_quasispectrum (R := S) a rw [← isCompact_iff_compactSpace] at this ⊢ simpa using halg.isClosedEmbedding.isCompact_preimage this exists_cfc_of_predicate a ha := by refine ⟨((h a).mp ha).2.nonUnitalStarAlgHom (cfcₙHom ((h a).mp ha).1 (R := S)), ?hom_isClosedEmbedding, ?hom_id, ?hom_map_spectrum, ?predicate_hom⟩ case hom_isClosedEmbedding => exact ((h a).mp ha).2.isClosedEmbedding_nonUnitalStarAlgHom (cfcₙHom_isClosedEmbedding ((h a).mp ha).1) halg case hom_id => exact ((h a).mp ha).2.nonUnitalStarAlgHom_id <| cfcₙHom_id ((h a).mp ha).1 case hom_map_spectrum => intro g rw [nonUnitalStarAlgHom_apply] simp only [← @quasispectrum.preimage_algebraMap (R := R) S, cfcₙHom_map_quasispectrum] ext x constructor · rintro ⟨y, hy⟩ have := congr_arg f hy simp only [comp_apply, coe_mk, ContinuousMap.coe_mk, StarAlgHom.ofId_apply] at this rw [((h a).mp ha).2.left_inv _, ((h a).mp ha).2.left_inv _] at this exact ⟨_, this⟩ · rintro ⟨y, rfl⟩ rw [Set.mem_preimage] refine ⟨⟨algebraMap R S y, quasispectrum.algebraMap_mem S y.prop⟩, ?_⟩ simp only [comp_apply, coe_mk, ContinuousMap.coe_mk, StarAlgHom.ofId_apply] congr exact Subtype.ext (((h a).mp ha).2.left_inv y) case predicate_hom => intro g rw [h] refine ⟨cfcₙHom_predicate _ _, ?_⟩ refine { rightInvOn := fun s hs ↦ ?_, left_inv := ((h a).mp ha).2.left_inv } rw [nonUnitalStarAlgHom_apply, cfcₙHom_map_quasispectrum] at hs obtain ⟨r, rfl⟩ := hs simp [((h a).mp ha).2.left_inv _] variable [NonUnitalContinuousFunctionalCalculus R A p] variable [ContinuousMapZero.UniqueHom R A] lemma cfcₙHom_eq_restrict (f : C(S, R)) (halg : IsUniformEmbedding (algebraMap R S)) {a : A} (hpa : p a) (hqa : q a) (h : QuasispectrumRestricts a f) : cfcₙHom hpa = h.nonUnitalStarAlgHom (cfcₙHom hqa) := by apply cfcₙHom_eq_of_continuous_of_map_id · exact h.isClosedEmbedding_nonUnitalStarAlgHom (cfcₙHom_isClosedEmbedding hqa) halg |>.continuous · exact h.nonUnitalStarAlgHom_id (cfcₙHom_id hqa) lemma cfcₙ_eq_restrict (f : C(S, R)) (halg : IsUniformEmbedding (algebraMap R S)) {a : A} (hpa : p a) (hqa : q a) (h : QuasispectrumRestricts a f) (g : R → R) : cfcₙ g a = cfcₙ (fun x ↦ algebraMap R S (g (f x))) a := by by_cases hg : ContinuousOn g (σₙ R a) ∧ g 0 = 0 · obtain ⟨hg, hg0⟩ := hg rw [cfcₙ_apply g a, cfcₙHom_eq_restrict f halg hpa hqa h, nonUnitalStarAlgHom_apply, cfcₙHom_eq_cfcₙ_extend 0] apply cfcₙ_congr fun x hx ↦ ?_ lift x to σₙ S a using hx simp · simp only [not_and_or] at hg obtain (hg | hg) := hg · have : ¬ ContinuousOn (fun x ↦ algebraMap R S (g (f x)) : S → S) (σₙ S a) := by refine fun hg' ↦ hg ?_ rw [halg.isEmbedding.continuousOn_iff] simpa [halg.isEmbedding.continuousOn_iff, Function.comp_def, h.left_inv _] using hg'.comp halg.isEmbedding.continuous.continuousOn (fun _ : R ↦ quasispectrum.algebraMap_mem S) rw [cfcₙ_apply_of_not_continuousOn a hg, cfcₙ_apply_of_not_continuousOn a this] · rw [cfcₙ_apply_of_not_map_zero a hg, cfcₙ_apply_of_not_map_zero a (by simpa [h.map_zero])] end QuasispectrumRestricts
.lake/packages/mathlib/Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Commute.lean
import Mathlib.Analysis.CStarAlgebra.ContinuousFunctionalCalculus.Instances /-! # Commuting with applications of the continuous functional calculus This file shows that if an element `b` commutes with both `a` and `star a`, then it commutes with `cfc f a` (or `cfcₙ f a`). In the case where `a` is selfadjoint, we may reduce the hypotheses. ## Main results * `Commute.cfc` and `Commute.cfcₙ`: an element commutes with `cfc f a` or `cfcₙ f a` if it commutes with both `a` and `star a`. Specialized versions for `ℝ` and `ℝ≥0` or for `IsSelfAdjoint a` which do not require the user to show the element commutes with `star a` are provided for convenience. ## Implementation notes The proof of `Commute.cfcHom` and `Commute.cfcₙHom` could be made simpler by appealing to basic facts about double commutants, but doing so would require extra type class assumptions so that we can talk about topological star algebras. Instead, we avoid this to minimize the work Lean must do to call these lemmas, and give a straightforward proof by induction. -/ variable {𝕜 A : Type*} open scoped NNReal section Unital section RCLike variable {p : A → Prop} [RCLike 𝕜] [Ring A] [StarRing A] [Algebra 𝕜 A] variable [TopologicalSpace A] [ContinuousFunctionalCalculus 𝕜 A p] [IsTopologicalRing A] [T2Space A] open StarAlgebra.elemental in protected theorem Commute.cfcHom {a b : A} (ha : p a) (hb₁ : Commute a b) (hb₂ : Commute (star a) b) (f : C(spectrum 𝕜 a, 𝕜)) : Commute (cfcHom ha f) b := by open scoped ContinuousFunctionalCalculus in induction f using ContinuousMap.induction_on_of_compact with | const r => conv => enter [1, 2] equals algebraMap 𝕜 _ r => rfl rw [AlgHomClass.commutes] exact Algebra.commute_algebraMap_left r b | id => rwa [cfcHom_id ha] | star_id => rwa [map_star, cfcHom_id] | add f g hf hg => rw [map_add]; exact hf.add_left hg | mul f g hf hg => rw [map_mul]; exact mul_left hf hg | frequently f hf => rw [commute_iff_eq, ← Set.mem_setOf (p := fun x => x * b = b * x), ← (isClosed_eq (by fun_prop) (by fun_prop)).closure_eq] apply mem_closure_of_frequently_of_tendsto hf exact cfcHom_continuous ha |>.tendsto _ protected theorem IsSelfAdjoint.commute_cfcHom {a b : A} (ha : p a) (ha' : IsSelfAdjoint a) (hb : Commute a b) (f : C(spectrum 𝕜 a, 𝕜)) : Commute (cfcHom ha f) b := hb.cfcHom ha (ha'.star_eq.symm ▸ hb) f /-- An element commutes with `cfc f a` if it commutes with both `a` and `star a`. If the base ring is `ℝ` or `ℝ≥0`, see `Commute.cfc_real` or `Commute.cfc_nnreal` which don't require the `Commute (star a) b` hypothesis. -/ @[grind ←] protected theorem Commute.cfc {a b : A} (hb₁ : Commute a b) (hb₂ : Commute (star a) b) (f : 𝕜 → 𝕜) : Commute (cfc f a) b := cfc_cases (fun x ↦ Commute x b) a f (Commute.zero_left _) fun hf ha ↦ hb₁.cfcHom ha hb₂ ⟨_, hf.restrict⟩ /-- For `a` selfadjoint, an element commutes with `cfc f a` if it commutes with `a`. If the base ring is `ℝ` or `ℝ≥0`, see `Commute.cfc_real` or `Commute.cfc_nnreal` which don't require the `IsSelfAdjoint` hypothesis on `a` (due to the junk value `cfc f a = 0`). -/ protected theorem IsSelfAdjoint.commute_cfc {a b : A} (ha : IsSelfAdjoint a) (hb₁ : Commute a b) (f : 𝕜 → 𝕜) : Commute (cfc f a) b := hb₁.cfc (ha.star_eq.symm ▸ hb₁) f end RCLike section NNReal variable [Ring A] [StarRing A] [Algebra ℝ A] [TopologicalSpace A] variable [ContinuousFunctionalCalculus ℝ A IsSelfAdjoint] [IsTopologicalRing A] [T2Space A] /-- A version of `Commute.cfc` or `IsSelfAdjoint.commute_cfc` which does not require any interaction with `star` when the base ring is `ℝ`. -/ @[grind ←] protected theorem Commute.cfc_real {a b : A} (hb : Commute a b) (f : ℝ → ℝ) : Commute (cfc f a) b := cfc_cases (fun x ↦ Commute x b) a f (Commute.zero_left _) fun hf ha ↦ by rw [← cfc_apply ..] exact hb.cfc (ha.star_eq.symm ▸ hb) _ variable [PartialOrder A] [NonnegSpectrumClass ℝ A] [StarOrderedRing A] /-- A version of `Commute.cfc` or `IsSelfAdjoint.commute_cfc` which does not require any interaction with `star` when the base ring is `ℝ≥0`. -/ @[grind ←] protected theorem Commute.cfc_nnreal {a b : A} (hb : Commute a b) (f : ℝ≥0 → ℝ≥0) : Commute (cfc f a) b := by by_cases ha : 0 ≤ a · rw [cfc_nnreal_eq_real ..] exact hb.cfc_real _ · simp [cfc_apply_of_not_predicate a ha] end NNReal end Unital section NonUnital section RCLike variable {p : A → Prop} [RCLike 𝕜] [NonUnitalRing A] [StarRing A] variable [Module 𝕜 A] [IsScalarTower 𝕜 A A] [SMulCommClass 𝕜 A A] [TopologicalSpace A] variable [NonUnitalContinuousFunctionalCalculus 𝕜 A p] [IsTopologicalRing A] [T2Space A] open ContinuousMapZero open NonUnitalStarAlgebra.elemental in protected theorem Commute.cfcₙHom {a b : A} (ha : p a) (hb₁ : Commute a b) (hb₂ : Commute (star a) b) (f : C(quasispectrum 𝕜 a, 𝕜)₀) : Commute (cfcₙHom ha f) b := by open scoped NonUnitalContinuousFunctionalCalculus in induction f using ContinuousMapZero.induction_on_of_compact with | zero => simp | smul r f hf => rw [map_smul]; exact hf.smul_left r | id => rwa [cfcₙHom_id ha] | star_id => rwa [map_star, cfcₙHom_id] | add f g hf hg => rw [map_add]; exact hf.add_left hg | mul f g hf hg => rw [map_mul]; exact mul_left hf hg | frequently f hf => rw [commute_iff_eq, ← Set.mem_setOf (p := fun x => x * b = b * x), ← (isClosed_eq (by fun_prop) (by fun_prop)).closure_eq] apply mem_closure_of_frequently_of_tendsto hf exact cfcₙHom_continuous ha |>.tendsto _ protected theorem IsSelfAdjoint.commute_cfcₙHom {a b : A} (ha : p a) (ha' : IsSelfAdjoint a) (hb : Commute a b) (f : C(quasispectrum 𝕜 a, 𝕜)₀) : Commute (cfcₙHom ha f) b := hb.cfcₙHom ha (ha'.star_eq.symm ▸ hb) f /-- An element commutes with `cfcₙ f a` if it commutes with both `a` and `star a`. If the base ring is `ℝ` or `ℝ≥0`, see `Commute.cfcₙ_real` or `Commute.cfcₙ_nnreal` which don't require the `Commute (star a) b` hypothesis. -/ @[grind ←] protected theorem Commute.cfcₙ {a b : A} (hb₁ : Commute a b) (hb₂ : Commute (star a) b) (f : 𝕜 → 𝕜) : Commute (cfcₙ f a) b := cfcₙ_cases (fun x ↦ Commute x b) a f (Commute.zero_left _) fun hf hf₀ ha ↦ hb₁.cfcₙHom ha hb₂ ⟨⟨_, hf.restrict⟩, hf₀⟩ /-- For `a` selfadjoint, an element commutes with `cfcₙ f a` if it commutes with `a`. If the base ring is `ℝ` or `ℝ≥0`, see `Commute.cfcₙ_real` or `Commute.cfcₙ_nnreal` which don't require the `IsSelfAdjoint` hypothesis on `a` (due to the junk value `cfcₙ f a = 0`). -/ protected theorem IsSelfAdjoint.commute_cfcₙ {a b : A} (ha : IsSelfAdjoint a) (hb₁ : Commute a b) (f : 𝕜 → 𝕜) : Commute (cfcₙ f a) b := hb₁.cfcₙ (ha.star_eq.symm ▸ hb₁) f end RCLike section NNReal variable [NonUnitalRing A] [StarRing A] [Module ℝ A] [IsScalarTower ℝ A A] variable [SMulCommClass ℝ A A] [TopologicalSpace A] variable [NonUnitalContinuousFunctionalCalculus ℝ A IsSelfAdjoint] [IsTopologicalRing A] [T2Space A] /-- A version of `Commute.cfcₙ` or `IsSelfAdjoint.commute_cfcₙ` which does not require any interaction with `star` when the base ring is `ℝ`. -/ @[grind ←] protected theorem Commute.cfcₙ_real {a b : A} (hb : Commute a b) (f : ℝ → ℝ) : Commute (cfcₙ f a) b := cfcₙ_cases (fun x ↦ Commute x b) a f (Commute.zero_left _) fun hf hf0 ha ↦ by rw [← cfcₙ_apply ..] exact hb.cfcₙ (ha.star_eq.symm ▸ hb) _ variable [PartialOrder A] [NonnegSpectrumClass ℝ A] [StarOrderedRing A] /-- A version of `Commute.cfcₙ` or `IsSelfAdjoint.commute_cfcₙ` which does not require any interaction with `star` when the base ring is `ℝ≥0`. -/ @[grind ←] protected theorem Commute.cfcₙ_nnreal {a b : A} (hb : Commute a b) (f : ℝ≥0 → ℝ≥0) : Commute (cfcₙ f a) b := by by_cases ha : 0 ≤ a · rw [cfcₙ_nnreal_eq_real ..] exact hb.cfcₙ_real _ · simp [cfcₙ_apply_of_not_predicate a ha] end NNReal end NonUnital
.lake/packages/mathlib/Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Basic.lean
import Mathlib.Analysis.CStarAlgebra.ContinuousFunctionalCalculus.Isometric import Mathlib.Analysis.CStarAlgebra.GelfandDuality import Mathlib.Analysis.CStarAlgebra.Unitization import Mathlib.Analysis.SpecialFunctions.ContinuousFunctionalCalculus.PosPart.Basic /-! # Continuous functional calculus In this file we construct the `continuousFunctionalCalculus` for a normal element `a` of a (unital) C⋆-algebra over `ℂ`. This is a star algebra equivalence `C(spectrum ℂ a, ℂ) ≃⋆ₐ[ℂ] elemental ℂ a` which sends the (restriction of) the identity map `ContinuousMap.id ℂ` to the (unique) preimage of `a` under the coercion of `elemental ℂ a` to `A`. Being a star algebra equivalence between C⋆-algebras, this map is continuous (even an isometry), and by the Stone-Weierstrass theorem it is the unique star algebra equivalence which extends the polynomial functional calculus (i.e., `Polynomial.aeval`). For any continuous function `f : spectrum ℂ a → ℂ`, this makes it possible to define an element `f a` (not valid notation) in the original algebra, which heuristically has the same eigenspaces as `a` and acts on eigenvector of `a` for an eigenvalue `λ` as multiplication by `f λ`. This description is perfectly accurate in finite dimension, but only heuristic in infinite dimension as there might be no genuine eigenvector. In particular, when `f` is a polynomial `∑ cᵢ Xⁱ`, then `f a` is `∑ cᵢ aⁱ`. Also, `id a = a`. The result we have established here is the strongest possible, but it is not the version which is most useful in practice. The generic API for the continuous functional calculus can be found in `Analysis.CStarAlgebra.ContinuousFunctionalCalculus` in the `Unital` and `NonUnital` files. The relevant instances on C⋆-algebra can be found in the `Instances` file. ## Main definitions * `continuousFunctionalCalculus : C(spectrum ℂ a, ℂ) ≃⋆ₐ[ℂ] elemental ℂ a`: this is the composition of the inverse of the `gelfandStarTransform` with the natural isomorphism induced by the homeomorphism `elemental.characterSpaceHomeo`. * `elemental.characterSpaceHomeo` : `characterSpace ℂ (elemental ℂ a) ≃ₜ spectrum ℂ a`: this homeomorphism is defined by evaluating a character `φ` at `a`, and noting that `φ a ∈ spectrum ℂ a` since `φ` is an algebra homomorphism. Moreover, this map is continuous and bijective and since the spaces involved are compact Hausdorff, it is a homeomorphism. * `IsStarNormal.instContinuousFunctionalCalculus`: the continuous functional calculus for normal elements in a unital C⋆-algebra over `ℂ`. * `CStarAlgebra.instNonnegSpectrumClass`: In a unital C⋆-algebra over `ℂ` which is also a `StarOrderedRing`, the spectrum of a nonnegative element is nonnegative. -/ open scoped Pointwise ENNReal NNReal ComplexOrder open WeakDual WeakDual.CharacterSpace variable {A : Type*} [CStarAlgebra A] namespace StarAlgebra.elemental instance {R A : Type*} [CommRing R] [StarRing R] [NormedRing A] [Algebra R A] [StarRing A] [ContinuousStar A] [StarModule R A] (a : A) [IsStarNormal a] : NormedCommRing (elemental R a) := { SubringClass.toNormedRing (elemental R a) with mul_comm := mul_comm } noncomputable instance (a : A) [IsStarNormal a] : CommCStarAlgebra (elemental ℂ a) where variable (a : A) [IsStarNormal a] /-- The natural map from `characterSpace ℂ (elemental ℂ x)` to `spectrum ℂ x` given by evaluating `φ` at `x`. This is essentially just evaluation of the `gelfandTransform` of `x`, but because we want something in `spectrum ℂ x`, as opposed to `spectrum ℂ ⟨x, elemental.self_mem ℂ x⟩` there is slightly more work to do. -/ @[simps] noncomputable def characterSpaceToSpectrum (x : A) (φ : characterSpace ℂ (elemental ℂ x)) : spectrum ℂ x where val := φ ⟨x, self_mem ℂ x⟩ property := by simpa only [StarSubalgebra.spectrum_eq (hS := isClosed ℂ x) (a := ⟨x, self_mem ℂ x⟩)] using AlgHom.apply_mem_spectrum φ ⟨x, self_mem ℂ x⟩ theorem continuous_characterSpaceToSpectrum (x : A) : Continuous (characterSpaceToSpectrum x) := continuous_induced_rng.2 (map_continuous <| gelfandTransform ℂ (elemental ℂ x) ⟨x, self_mem ℂ x⟩) theorem bijective_characterSpaceToSpectrum : Function.Bijective (characterSpaceToSpectrum a) := by refine ⟨fun φ ψ h => starAlgHomClass_ext ℂ ?_ ?_ ?_, ?_⟩ · exact (map_continuous φ) · exact (map_continuous ψ) · simpa only [characterSpaceToSpectrum, Subtype.mk_eq_mk, ContinuousMap.coe_mk] using h · rintro ⟨z, hz⟩ have hz' := (StarSubalgebra.spectrum_eq (hS := isClosed ℂ a) (a := ⟨a, self_mem ℂ a⟩) ▸ hz) rw [CharacterSpace.mem_spectrum_iff_exists] at hz' obtain ⟨φ, rfl⟩ := hz' exact ⟨φ, rfl⟩ /-- The homeomorphism between the character space of the unital C⋆-subalgebra generated by a single normal element `a : A` and `spectrum ℂ a`. -/ noncomputable def characterSpaceHomeo : characterSpace ℂ (elemental ℂ a) ≃ₜ spectrum ℂ a := @Continuous.homeoOfEquivCompactToT2 _ _ _ _ _ _ (Equiv.ofBijective (characterSpaceToSpectrum a) (bijective_characterSpaceToSpectrum a)) (continuous_characterSpaceToSpectrum a) end StarAlgebra.elemental open StarAlgebra elemental variable (a : A) [IsStarNormal a] /-- **Continuous functional calculus.** Given a normal element `a : A` of a unital C⋆-algebra, the continuous functional calculus is a `StarAlgEquiv` from the complex-valued continuous functions on the spectrum of `a` to the unital C⋆-subalgebra generated by `a`. Moreover, this equivalence identifies `(ContinuousMap.id ℂ).restrict (spectrum ℂ a))` with `a`; see `continuousFunctionalCalculus_map_id`. As such it extends the polynomial functional calculus. -/ noncomputable def continuousFunctionalCalculus : C(spectrum ℂ a, ℂ) ≃⋆ₐ[ℂ] elemental ℂ a := ((characterSpaceHomeo a).compStarAlgEquiv' ℂ ℂ).trans (gelfandStarTransform (elemental ℂ a)).symm theorem continuousFunctionalCalculus_map_id : continuousFunctionalCalculus a ((ContinuousMap.id ℂ).restrict (spectrum ℂ a)) = ⟨a, self_mem ℂ a⟩ := (gelfandStarTransform (elemental ℂ a)).symm_apply_apply _ /-! ### Continuous functional calculus for normal elements -/ local notation "σₙ" => quasispectrum section Normal instance IsStarNormal.instContinuousFunctionalCalculus {A : Type*} [CStarAlgebra A] : ContinuousFunctionalCalculus ℂ A IsStarNormal where predicate_zero := .zero spectrum_nonempty a _ := spectrum.nonempty a exists_cfc_of_predicate a ha := by refine ⟨(StarAlgebra.elemental ℂ a).subtype.comp <| continuousFunctionalCalculus a, ?hom_isClosedEmbedding, ?hom_id, ?hom_map_spectrum, ?predicate_hom⟩ case hom_isClosedEmbedding => exact Isometry.isClosedEmbedding <| isometry_subtype_coe.comp <| StarAlgEquiv.isometry (continuousFunctionalCalculus a) case hom_id => exact congr_arg Subtype.val <| continuousFunctionalCalculus_map_id a case hom_map_spectrum => intro f simp only [StarAlgHom.comp_apply, StarAlgHom.coe_coe, StarSubalgebra.coe_subtype] rw [← StarSubalgebra.spectrum_eq (hS := StarAlgebra.elemental.isClosed ℂ a), AlgEquiv.spectrum_eq (continuousFunctionalCalculus a), ContinuousMap.spectrum_eq_range] case predicate_hom => exact fun f ↦ ⟨by rw [← map_star]; exact Commute.all (star f) f |>.map _⟩ lemma cfcHom_eq_of_isStarNormal {A : Type*} [CStarAlgebra A] (a : A) [ha : IsStarNormal a] : cfcHom ha = (StarAlgebra.elemental ℂ a).subtype.comp (continuousFunctionalCalculus a) := by refine cfcHom_eq_of_continuous_of_map_id ha _ ?_ ?_ · exact continuous_subtype_val.comp <| (StarAlgEquiv.isometry (continuousFunctionalCalculus a)).continuous · simp [continuousFunctionalCalculus_map_id a] instance IsStarNormal.instNonUnitalContinuousFunctionalCalculus {A : Type*} [NonUnitalCStarAlgebra A] : NonUnitalContinuousFunctionalCalculus ℂ A IsStarNormal := RCLike.nonUnitalContinuousFunctionalCalculus Unitization.isStarNormal_inr open Unitization CStarAlgebra in lemma inr_comp_cfcₙHom_eq_cfcₙAux {A : Type*} [NonUnitalCStarAlgebra A] (a : A) [ha : IsStarNormal a] : (inrNonUnitalStarAlgHom ℂ A).comp (cfcₙHom ha) = cfcₙAux (isStarNormal_inr (R := ℂ) (A := A)) a ha := by have h (a : A) := isStarNormal_inr (R := ℂ) (A := A) (a := a) refine @ContinuousMapZero.UniqueHom.eq_of_continuous_of_map_id _ _ _ _ _ _ _ _ _ _ _ inferInstance inferInstance _ (σₙ ℂ a) _ _ _ _ ?_ ?_ ?_ · change Continuous (fun f ↦ (cfcₙHom ha f : A⁺¹)); fun_prop · exact isClosedEmbedding_cfcₙAux @(h) a ha |>.continuous · trans (a : A⁺¹) · congrm(inr $(cfcₙHom_id ha)) · exact cfcₙAux_id @(h) a ha |>.symm end Normal /-! ### The spectrum of a nonnegative element is nonnegative -/ section SpectrumRestricts open NNReal ENNReal variable {A : Type*} [CStarAlgebra A] lemma SpectrumRestricts.nnreal_iff_nnnorm {a : A} {t : ℝ≥0} (ha : IsSelfAdjoint a) (ht : ‖a‖₊ ≤ t) : SpectrumRestricts a ContinuousMap.realToNNReal ↔ ‖algebraMap ℝ A t - a‖₊ ≤ t := by have : IsSelfAdjoint (algebraMap ℝ A t - a) := IsSelfAdjoint.algebraMap A (.all (t : ℝ)) |>.sub ha rw [← ENNReal.coe_le_coe, ← IsSelfAdjoint.spectralRadius_eq_nnnorm, ← SpectrumRestricts.spectralRadius_eq (f := Complex.reCLM)] at ht ⊢ · exact SpectrumRestricts.nnreal_iff_spectralRadius_le ht all_goals try apply IsSelfAdjoint.spectrumRestricts assumption lemma SpectrumRestricts.nnreal_add {a b : A} (ha₁ : IsSelfAdjoint a) (hb₁ : IsSelfAdjoint b) (ha₂ : SpectrumRestricts a ContinuousMap.realToNNReal) (hb₂ : SpectrumRestricts b ContinuousMap.realToNNReal) : SpectrumRestricts (a + b) ContinuousMap.realToNNReal := by rw [SpectrumRestricts.nnreal_iff_nnnorm (ha₁.add hb₁) (nnnorm_add_le a b), NNReal.coe_add, map_add, add_sub_add_comm] refine nnnorm_add_le _ _ |>.trans ?_ gcongr all_goals rw [← SpectrumRestricts.nnreal_iff_nnnorm] <;> first | rfl | assumption lemma IsSelfAdjoint.sq_spectrumRestricts {a : A} (ha : IsSelfAdjoint a) : SpectrumRestricts (a ^ 2) ContinuousMap.realToNNReal := by rw [SpectrumRestricts.nnreal_iff, ← cfc_id (R := ℝ) a, ← cfc_pow .., cfc_map_spectrum ..] rintro - ⟨x, -, rfl⟩ exact sq_nonneg x open ComplexStarModule lemma SpectrumRestricts.eq_zero_of_neg {a : A} (ha : IsSelfAdjoint a) (ha₁ : SpectrumRestricts a ContinuousMap.realToNNReal) (ha₂ : SpectrumRestricts (-a) ContinuousMap.realToNNReal) : a = 0 := by nontriviality A rw [SpectrumRestricts.nnreal_iff] at ha₁ ha₂ apply CFC.eq_zero_of_spectrum_subset_zero (R := ℝ) a rw [Set.subset_singleton_iff] simp only [← spectrum.neg_eq, Set.mem_neg] at ha₂ peel ha₁ with x hx _ linarith [ha₂ (-x) ((neg_neg x).symm ▸ hx)] lemma SpectrumRestricts.smul_of_nonneg {A : Type*} [Ring A] [Algebra ℝ A] {a : A} (ha : SpectrumRestricts a ContinuousMap.realToNNReal) {r : ℝ} (hr : 0 ≤ r) : SpectrumRestricts (r • a) ContinuousMap.realToNNReal := by rw [SpectrumRestricts.nnreal_iff] at ha ⊢ nontriviality A intro x hx by_cases hr' : r = 0 · simp [hr'] at hx ⊢ exact hx.symm.le · lift r to ℝˣ using IsUnit.mk0 r hr' rw [← Units.smul_def, spectrum.unit_smul_eq_smul, Set.mem_smul_set_iff_inv_smul_mem] at hx refine le_of_smul_le_smul_left ?_ (inv_pos.mpr <| lt_of_le_of_ne hr <| ne_comm.mpr hr') simpa [Units.smul_def] using ha _ hx /-- The `ℝ`-spectrum of an element of the form `star b * b` in a C⋆-algebra is nonnegative. This is the key result used to establish `CStarAlgebra.instNonnegSpectrumClass`. -/ lemma spectrum_star_mul_self_nonneg {b : A} : ∀ x ∈ spectrum ℝ (star b * b), 0 ≤ x := by -- for convenience we'll work with `a := star b * b`, which is selfadjoint. set a := star b * b with a_def have ha : IsSelfAdjoint a := by simp [a_def] -- the key element to consider is `c := b * a⁻`, which satisfies `- (star c * c) = a⁻ ^ 3`. set c := b * a⁻ have h_eq_negPart_a : - (star c * c) = a⁻ ^ 3 := calc -(star c * c) = - a⁻ * a * a⁻ := by simp only [star_mul, c, mul_assoc, ← mul_assoc (star b), ← a_def, CFC.negPart_def, neg_mul, IsSelfAdjoint.cfcₙ (f := (·⁻)).star_eq] _ = - a⁻ * (a⁺ - a⁻) * a⁻ := congr(- a⁻ * $(CFC.posPart_sub_negPart a ha) * a⁻).symm _ = a⁻ ^ 3 := by simp [mul_sub, pow_succ] -- the spectrum of `- (star c * c) = a⁻ ^ 3` is nonnegative, since the function on the right -- is nonnegative on the spectrum of `a`. have h_c_spec₀ : SpectrumRestricts (- (star c * c)) (ContinuousMap.realToNNReal ·) := by simp only [SpectrumRestricts.nnreal_iff, h_eq_negPart_a, CFC.negPart_def] rw [cfcₙ_eq_cfc (hf0 := by simp), ← cfc_pow (ha := ha) .., cfc_map_spectrum (ha := ha) ..] rintro - ⟨x, -, rfl⟩ positivity -- the spectrum of `c * star c` is nonnegative, since squares of selfadjoint elements have -- nonnegative spectrum, and `c * star c = 2 • (ℜ c ^ 2 + ℑ c ^ 2) + (- (star c * c))`, -- and selfadjoint elements with nonnegative spectrum are closed under addition. have h_c_spec₁ : SpectrumRestricts (c * star c) ContinuousMap.realToNNReal := by rw [eq_sub_iff_add_eq'.mpr <| star_mul_self_add_self_mul_star c, sub_eq_add_neg, ← sq, ← sq] refine SpectrumRestricts.nnreal_add ?_ ?_ ?_ h_c_spec₀ · exact .smul (star_trivial _) <| ((ℜ c).prop.pow 2).add ((ℑ c).prop.pow 2) · exact .neg <| .star_mul_self c · rw [← Nat.cast_smul_eq_nsmul ℝ] refine (ℜ c).2.sq_spectrumRestricts.nnreal_add ((ℜ c).2.pow 2) ((ℑ c).2.pow 2) (ℑ c).2.sq_spectrumRestricts |>.smul_of_nonneg <| by simp -- therefore `- (star c * c) = 0` and so `a⁻ ^ 3 = 0`. By properties of the continuous functional -- calculus, `fun x ↦ x⁻ ^ 3` is zero on the spectrum of `a`, `0 ≤ x` for `x ∈ spectrum ℝ a`. rw [h_c_spec₁.mul_comm.eq_zero_of_neg (.star_mul_self c) h_c_spec₀, neg_zero, CFC.negPart_def, cfcₙ_eq_cfc (hf0 := by simp), ← cfc_pow _ _ (ha := ha), ← cfc_zero a (R := ℝ)] at h_eq_negPart_a have h_eqOn := eqOn_of_cfc_eq_cfc (ha := ha) h_eq_negPart_a exact fun x hx ↦ negPart_eq_zero.mp <| eq_zero_of_pow_eq_zero (h_eqOn hx).symm lemma IsSelfAdjoint.coe_mem_spectrum_complex {A : Type*} [TopologicalSpace A] [Ring A] [StarRing A] [Algebra ℂ A] [ContinuousFunctionalCalculus ℂ A IsStarNormal] {a : A} {x : ℝ} (ha : IsSelfAdjoint a := by cfc_tac) : (x : ℂ) ∈ spectrum ℂ a ↔ x ∈ spectrum ℝ a := by simp [← ha.spectrumRestricts.algebraMap_image] end SpectrumRestricts section NonnegSpectrumClass variable {A : Type*} [CStarAlgebra A] [PartialOrder A] [StarOrderedRing A] instance CStarAlgebra.instNonnegSpectrumClass : NonnegSpectrumClass ℝ A := .of_spectrum_nonneg fun a ha ↦ by rw [StarOrderedRing.nonneg_iff] at ha induction ha using AddSubmonoid.closure_induction with | mem x hx => obtain ⟨b, rfl⟩ := hx exact spectrum_star_mul_self_nonneg | zero => nontriviality A simp | add x y x_mem y_mem hx hy => rw [← SpectrumRestricts.nnreal_iff] at hx hy ⊢ rw [← StarOrderedRing.nonneg_iff] at x_mem y_mem exact hx.nnreal_add (.of_nonneg x_mem) (.of_nonneg y_mem) hy open ComplexOrder in instance CStarAlgebra.instNonnegSpectrumClassComplexUnital : NonnegSpectrumClass ℂ A where quasispectrum_nonneg_of_nonneg a ha x := by rw [mem_quasispectrum_iff] refine (Or.elim · ge_of_eq fun hx ↦ ?_) obtain ⟨y, hy, rfl⟩ := (IsSelfAdjoint.of_nonneg ha).spectrumRestricts.algebraMap_image ▸ hx simpa using spectrum_nonneg_of_nonneg ha hy end NonnegSpectrumClass section SpectralOrder variable (A : Type*) [NonUnitalCStarAlgebra A] open scoped CStarAlgebra /-- The partial order on a C⋆-algebra defined by `x ≤ y` if and only if `y - x` is selfadjoint and has nonnegative spectrum. This is not declared as an instance because one may already have a partial order with better definitional properties. However, it can be useful to invoke this as an instance in proofs. -/ @[reducible] def CStarAlgebra.spectralOrder : PartialOrder A where le x y := IsSelfAdjoint (y - x) ∧ QuasispectrumRestricts (y - x) ContinuousMap.realToNNReal le_refl := by simp only [sub_self, IsSelfAdjoint.zero, true_and, forall_const] rw [quasispectrumRestricts_iff_spectrumRestricts_inr' ℂ, SpectrumRestricts.nnreal_iff] nontriviality A simp le_antisymm x y hxy hyx := by rw [← Unitization.isSelfAdjoint_inr (R := ℂ), quasispectrumRestricts_iff_spectrumRestricts_inr' ℂ, Unitization.inr_sub ℂ] at hxy hyx rw [← sub_eq_zero] apply Unitization.inr_injective (R := ℂ) rw [Unitization.inr_zero, Unitization.inr_sub] exact hyx.2.eq_zero_of_neg hyx.1 (neg_sub (x : A⁺¹) (y : A⁺¹) ▸ hxy.2) le_trans x y z hxy hyz := by simp +singlePass only [← Unitization.isSelfAdjoint_inr (R := ℂ), quasispectrumRestricts_iff_spectrumRestricts_inr' ℂ] at hxy hyz ⊢ exact ⟨by simpa using hyz.1.add hxy.1, by simpa using hyz.2.nnreal_add hyz.1 hxy.1 hxy.2⟩ /-- The `CStarAlgebra.spectralOrder` on a C⋆-algebra is a `StarOrderedRing`. -/ lemma CStarAlgebra.spectralOrderedRing : @StarOrderedRing A _ (CStarAlgebra.spectralOrder A) _ := let _ := CStarAlgebra.spectralOrder A { le_iff := by intro x y constructor · intro h obtain ⟨s, hs₁, _, hs₂⟩ := CFC.exists_sqrt_of_isSelfAdjoint_of_quasispectrumRestricts h.1 h.2 refine ⟨s * s, ?_, by rwa [eq_sub_iff_add_eq', eq_comm] at hs₂⟩ exact AddSubmonoid.subset_closure ⟨s, by simp [hs₁.star_eq]⟩ · rintro ⟨p, hp, rfl⟩ simp only [spectralOrder, add_sub_cancel_left] induction hp using AddSubmonoid.closure_induction with | mem x hx => obtain ⟨s, rfl⟩ := hx refine ⟨IsSelfAdjoint.star_mul_self s, ?_⟩ rw [quasispectrumRestricts_iff_spectrumRestricts_inr' ℂ, SpectrumRestricts.nnreal_iff, Unitization.inr_mul, Unitization.inr_star] exact spectrum_star_mul_self_nonneg | zero => rw [quasispectrumRestricts_iff_spectrumRestricts_inr' ℂ, SpectrumRestricts.nnreal_iff] nontriviality A simp | add x y _ _ hx hy => simp +singlePass only [← Unitization.isSelfAdjoint_inr (R := ℂ), quasispectrumRestricts_iff_spectrumRestricts_inr' ℂ] at hx hy ⊢ rw [Unitization.inr_add] exact ⟨hx.1.add hy.1, hx.2.nnreal_add hx.1 hy.1 hy.2⟩ } end SpectralOrder section NonnegSpectrumClass variable {A : Type*} [NonUnitalCStarAlgebra A] [PartialOrder A] [StarOrderedRing A] open scoped CStarAlgebra in instance CStarAlgebra.instNonnegSpectrumClass' : NonnegSpectrumClass ℝ A where quasispectrum_nonneg_of_nonneg a ha := by rw [Unitization.quasispectrum_eq_spectrum_inr' _ ℂ] -- should this actually be an instance on the `Unitization`? (probably scoped) let _ := CStarAlgebra.spectralOrder A⁺¹ have := CStarAlgebra.spectralOrderedRing A⁺¹ apply spectrum_nonneg_of_nonneg rw [StarOrderedRing.nonneg_iff] at ha ⊢ have := AddSubmonoid.mem_map_of_mem (Unitization.inrNonUnitalStarAlgHom ℂ A) ha rw [AddMonoidHom.map_mclosure, ← Set.range_comp] at this apply AddSubmonoid.closure_mono ?_ this rintro _ ⟨s, rfl⟩ exact ⟨s, by simp⟩ end NonnegSpectrumClass section cfc_inr open CStarAlgebra variable {A : Type*} [NonUnitalCStarAlgebra A] open scoped NonUnitalContinuousFunctionalCalculus in /-- This lemma requires a lot from type class synthesis, and so one should instead favor the bespoke versions for `ℝ≥0`, `ℝ`, and `ℂ`. -/ lemma Unitization.cfcₙ_eq_cfc_inr {R : Type*} [Semifield R] [StarRing R] [MetricSpace R] [IsTopologicalSemiring R] [ContinuousStar R] [Module R A] [IsScalarTower R A A] [SMulCommClass R A A] [CompleteSpace R] [Algebra R ℂ] [IsScalarTower R ℂ A] {p : A → Prop} {p' : A⁺¹ → Prop} [NonUnitalContinuousFunctionalCalculus R A p] [ContinuousFunctionalCalculus R A⁺¹ p'] [ContinuousMapZero.UniqueHom R (Unitization ℂ A)] (hp : ∀ {a : A}, p' (a : A⁺¹) ↔ p a) (a : A) (f : R → R) (hf₀ : f 0 = 0 := by cfc_zero_tac) : cfcₙ f a = cfc f (a : A⁺¹) := by by_cases h : ContinuousOn f (σₙ R a) ∧ p a · obtain ⟨hf, ha⟩ := h rw [← cfcₙ_eq_cfc (quasispectrum_inr_eq R ℂ a ▸ hf)] exact (inrNonUnitalStarAlgHom ℂ A).map_cfcₙ f a · obtain (hf | ha) := not_and_or.mp h · rw [cfcₙ_apply_of_not_continuousOn a hf, inr_zero, cfc_apply_of_not_continuousOn _ (quasispectrum_eq_spectrum_inr' R ℂ a ▸ hf)] · rw [cfcₙ_apply_of_not_predicate a ha, inr_zero, cfc_apply_of_not_predicate _ (not_iff_not.mpr hp |>.mpr ha)] lemma Unitization.complex_cfcₙ_eq_cfc_inr (a : A) (f : ℂ → ℂ) (hf₀ : f 0 = 0 := by cfc_zero_tac) : cfcₙ f a = cfc f (a : A⁺¹) := Unitization.cfcₙ_eq_cfc_inr isStarNormal_inr .. /-- note: the version for `ℝ≥0`, `Unitization.nnreal_cfcₙ_eq_cfc_inr`, can be found in `Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Order.lean` -/ lemma Unitization.real_cfcₙ_eq_cfc_inr (a : A) (f : ℝ → ℝ) (hf₀ : f 0 = 0 := by cfc_zero_tac) : cfcₙ f a = cfc f (a : A⁺¹) := Unitization.cfcₙ_eq_cfc_inr isSelfAdjoint_inr .. end cfc_inr /-! ### Instances of isometric continuous functional calculi -/ section Unital variable {A : Type*} [CStarAlgebra A] instance IsStarNormal.instIsometricContinuousFunctionalCalculus : IsometricContinuousFunctionalCalculus ℂ A IsStarNormal where isometric a ha := by rw [cfcHom_eq_of_isStarNormal] exact isometry_subtype_coe.comp <| StarAlgEquiv.isometry (continuousFunctionalCalculus a) instance IsSelfAdjoint.instIsometricContinuousFunctionalCalculus : IsometricContinuousFunctionalCalculus ℝ A IsSelfAdjoint := SpectrumRestricts.isometric_cfc Complex.reCLM Complex.isometry_ofReal (.zero _) fun _ ↦ isSelfAdjoint_iff_isStarNormal_and_quasispectrumRestricts end Unital section NonUnital variable {A : Type*} [NonUnitalCStarAlgebra A] open Unitization open ContinuousMapZero in instance IsStarNormal.instNonUnitalIsometricContinuousFunctionalCalculus : NonUnitalIsometricContinuousFunctionalCalculus ℂ A IsStarNormal where isometric a ha := by refine AddMonoidHomClass.isometry_of_norm _ fun f ↦ ?_ rw [← norm_inr (𝕜 := ℂ), ← inrNonUnitalStarAlgHom_apply, ← NonUnitalStarAlgHom.comp_apply, inr_comp_cfcₙHom_eq_cfcₙAux a, cfcₙAux] simp only [NonUnitalStarAlgHom.comp_assoc, NonUnitalStarAlgHom.comp_apply, toContinuousMapHom_apply, NonUnitalStarAlgHom.coe_coe] rw [norm_cfcHom (a : Unitization ℂ A), StarAlgEquiv.norm_map] rfl instance IsSelfAdjoint.instNonUnitalIsometricContinuousFunctionalCalculus : NonUnitalIsometricContinuousFunctionalCalculus ℝ A IsSelfAdjoint := QuasispectrumRestricts.isometric_cfc Complex.reCLM Complex.isometry_ofReal (.zero _) fun _ ↦ isSelfAdjoint_iff_isStarNormal_and_quasispectrumRestricts end NonUnital
.lake/packages/mathlib/Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Unital.lean
import Mathlib.Algebra.Algebra.Spectrum.Quasispectrum import Mathlib.Algebra.Algebra.StrictPositivity import Mathlib.Tactic.ContinuousFunctionalCalculus import Mathlib.Topology.Algebra.Polynomial import Mathlib.Topology.Algebra.Star.Real import Mathlib.Topology.ContinuousMap.StarOrdered /-! # The continuous functional calculus This file defines a generic API for the *continuous functional calculus* which is suitable in a wide range of settings. A continuous functional calculus for an element `a : A` in a topological `R`-algebra is a continuous extension of the polynomial functional calculus (i.e., `Polynomial.aeval`) to continuous `R`-valued functions on `spectrum R a`. More precisely, it is a continuous star algebra homomorphism `C(spectrum R a, R) →⋆ₐ[R] A` that sends `(ContinuousMap.id R).restrict (spectrum R a)` to `a`. In all cases of interest (e.g., when `spectrum R a` is compact and `R` is `ℝ≥0`, `ℝ`, or `ℂ`), this is sufficient to uniquely determine the continuous functional calculus which is encoded in the `ContinuousMap.UniqueHom` class. Although these properties suffice to uniquely determine the continuous functional calculus, we choose to bundle more information into the class itself. Namely, we include that the star algebra homomorphism is a closed embedding, and also that the spectrum of the image of `f : C(spectrum R a, R)` under this morphism is the range of `f`. In addition, the class specifies a collection of continuous functional calculi for elements satisfying a given predicate `p : A → Prop`, and we require that this predicate is preserved by the functional calculus. Although `cfcHom : p a → C(spectrum R a, R) →*ₐ[R] A` is a necessity for getting the full power out of the continuous functional calculus, this declaration will generally not be accessed directly by the user. One reason for this is that `cfcHom` requires a proof of `p a` (indeed, if the spectrum is empty, there cannot exist a star algebra homomorphism like this). Instead, we provide the completely unbundled `cfc : (R → R) → A → A` which operates on bare functions and provides junk values when either `a` does not satisfy the property `p`, or else when the function which is the argument to `cfc` is not continuous on the spectrum of `a`. This completely unbundled approach may give up some conveniences, but it allows for tremendous freedom. In particular, `cfc f a` makes sense for *any* `a : A` and `f : R → R`. This is quite useful in a variety of settings, but perhaps the most important is the following. Besides being a star algebra homomorphism sending the identity to `a`, the key property enjoyed by the continuous functional calculus is the *composition property*, which guarantees that `cfc (g ∘ f) a = cfc g (cfc f a)` under suitable hypotheses on `a`, `f` and `g`. Note that this theorem is nearly impossible to state nicely in terms of `cfcHom` (see `cfcHom_comp`). An additional advantage of the unbundled approach is that expressions like `fun x : R ↦ x⁻¹` are valid arguments to `cfc`, and a bundled continuous counterpart can only make sense when the spectrum of `a` does not contain zero and when we have an `⁻¹` operation on the domain. A reader familiar with C⋆-algebra theory may be somewhat surprised at the level of abstraction here. For instance, why not require `A` to be an actual C⋆-algebra? Why define separate continuous functional calculi for `R := ℂ`, `ℝ` or `ℝ≥0` instead of simply using the continuous functional calculus for normal elements? The reason for both can be explained with a simple example, `A := Matrix n n ℝ`. In Mathlib, matrices are not equipped with a norm (nor even a metric), and so requiring `A` to be a C⋆-algebra is far too stringent. Likewise, `A` is not a `ℂ`-algebra, and so it is impossible to consider the `ℂ`-spectrum of `a : Matrix n n ℝ`. There is another, more practical reason to define separate continuous functional calculi for different scalar rings. It gives us the ability to use functions defined on these types, and the algebra of functions on them. For example, for `R := ℝ` it is quite natural to consider the functions `(·⁺ : ℝ → ℝ)` and `(·⁻ : ℝ → ℝ)` because the functions `ℝ → ℝ` form a lattice ordered group. If `a : A` is selfadjoint, and we define `a⁺ := cfc (·⁺ : ℝ → ℝ) a`, and likewise for `a⁻`, then the properties `a⁺ * a⁻ = 0 = a⁻ * a⁺` and `a = a⁺ - a⁻` are trivial consequences of the corresponding facts for functions. In contrast, if we had to do this using functions on `ℂ`, the proofs of these facts would be much more cumbersome. ## Example The canonical example of the continuous functional calculus is when `A := Matrix n n ℂ`, `R := ℂ` and `p := IsStarNormal`. In this case, `spectrum ℂ a` consists of the eigenvalues of the normal matrix `a : Matrix n n ℂ`, and, because this set is discrete, any function is continuous on the spectrum. The continuous functional calculus allows us to make sense of expressions like `log a` (`:= cfc log a`), and when `0 ∉ spectrum ℂ a`, we get the nice property `exp (log a) = a`, which arises from the composition property `cfc exp (cfc log a) = cfc (exp ∘ log) a = cfc id a = a`, since `exp ∘ log = id` *on the spectrum of `a`*. Of course, there are other ways to make sense of `exp` and `log` for matrices (power series), and these agree with the continuous functional calculus. In fact, given `f : C(spectrum ℂ a, ℂ)`, `cfc f a` amounts to diagonalizing `a` (possible since `a` is normal), and applying `f` to the resulting diagonal entries. That is, if `a = u * d * star u` with `u` a unitary matrix and `d` diagonal, then `cfc f a = u * d.map f * star u`. In addition, if `a : Matrix n n ℂ` is positive semidefinite, then the `ℂ`-spectrum of `a` is contained in (the range of the coercion of) `ℝ≥0`. In this case, we get a continuous functional calculus with `R := ℝ≥0`. From this we can define `√a := cfc a NNReal.sqrt`, which is also positive semidefinite (because `cfc` preserves the predicate), and this is truly a square root since ``` √a * √a = cfc NNReal.sqrt a * cfc NNReal.sqrt a = cfc (NNReal.sqrt ^ 2) a = cfc id a = a ``` The composition property allows us to show that, in fact, this is the *unique* positive semidefinite square root of `a` because, if `b` is any positive semidefinite square root, then ``` b = cfc id b = cfc (NNReal.sqrt ∘ (· ^ 2)) b = cfc NNReal.sqrt (cfc b (· ^ 2)) = cfc NNReal.sqrt a = √a ``` ## Main declarations + `ContinuousFunctionalCalculus R A (p : A → Prop)`: a class stating that every `a : A` satisfying `p a` has a star algebra homomorphism from the continuous `R`-valued functions on the `R`-spectrum of `a` into the algebra `A`. This map is a closed embedding, and satisfies the **spectral mapping theorem**. + `cfcHom : p a → C(spectrum R a, R) →⋆ₐ[R] A`: the underlying star algebra homomorphism for an element satisfying property `p`. + `cfc : (R → R) → A → A`: an unbundled version of `cfcHom` which takes the junk value `0` when `cfcHom` is not defined. + `cfcUnits`: builds a unit from `cfc f a` when `f` is nonzero and continuous on the spectrum of `a`. ## Main theorems + `cfc_comp : cfc (x ↦ g (f x)) a = cfc g (cfc f a)` + `cfc_polynomial`: the continuous functional calculus extends the polynomial functional calculus. ## Implementation details Instead of defining a class depending on a term `a : A`, we register it for an `outParam` predicate `p : A → Prop`, and then any element of `A` satisfying this predicate has the associated star algebra homomorphism with the specified properties. In so doing we avoid a common pitfall: dependence of the class on a term. This avoids annoying situations where `a b : A` are propositionally equal, but not definitionally so, and hence Lean would not be able to automatically identify the continuous functional calculi associated to these elements. In order to guarantee the necessary properties, we require that the continuous functional calculus preserves this predicate. That is, `p a → p (cfc f a)` for any function `f` continuous on the spectrum of `a`. As stated above, the unbundled approach to `cfc` has its advantages. For instance, given an expression `cfc f a`, the user is free to rewrite either `a` or `f` as desired with no possibility of the expression ceasing to be defined. However, this unbundling also has some potential downsides. In particular, by unbundling, proof requirements are deferred until the user calls the lemmas, most of which have hypotheses both of `p a` and of `ContinuousOn f (spectrum R a)`. In order to minimize burden to the user, we provide `autoParams` in terms of two tactics. Goals related to continuity are dispatched by (a small wrapper around) `fun_prop`. As for goals involving the predicate `p`, it should be noted that these will only ever be of the form `IsStarNormal a`, `IsSelfAdjoint a` or `0 ≤ a`. For the moment we provide a rudimentary tactic to deal with these goals, but it can be modified to become more sophisticated as the need arises. -/ open Topology ContinuousMap section Basic /-- A star `R`-algebra `A` has a *continuous functional calculus* for elements satisfying the property `p : A → Prop` if + for every such element `a : A` there is a star algebra homomorphism `cfcHom : C(spectrum R a, R) →⋆ₐ[R] A` sending the (restriction of) the identity map to `a`. + `cfcHom` is a closed embedding for which the spectrum of the image of function `f` is its range. + `cfcHom` preserves the property `p`. + `p 0` is true, which ensures among other things that `p ≠ fun _ ↦ False`. The property `p` is marked as an `outParam` so that the user need not specify it. In practice, + for `R := ℂ`, we choose `p := IsStarNormal`, + for `R := ℝ`, we choose `p := IsSelfAdjoint`, + for `R := ℝ≥0`, we choose `p := (0 ≤ ·)`. Instead of directly providing the data we opt instead for a `Prop` class. In all relevant cases, the continuous functional calculus is uniquely determined, and utilizing this approach prevents diamonds or problems arising from multiple instances. -/ class ContinuousFunctionalCalculus (R A : Type*) (p : outParam (A → Prop)) [CommSemiring R] [StarRing R] [MetricSpace R] [IsTopologicalSemiring R] [ContinuousStar R] [Ring A] [StarRing A] [TopologicalSpace A] [Algebra R A] : Prop where predicate_zero : p 0 [compactSpace_spectrum (a : A) : CompactSpace (spectrum R a)] spectrum_nonempty [Nontrivial A] (a : A) (ha : p a) : (spectrum R a).Nonempty exists_cfc_of_predicate : ∀ a, p a → ∃ φ : C(spectrum R a, R) →⋆ₐ[R] A, IsClosedEmbedding φ ∧ φ ((ContinuousMap.id R).restrict <| spectrum R a) = a ∧ (∀ f, spectrum R (φ f) = Set.range f) ∧ ∀ f, p (φ f) -- this instance should not be activated everywhere but it is useful when developing generic API -- for the continuous functional calculus scoped[ContinuousFunctionalCalculus] attribute [instance] ContinuousFunctionalCalculus.compactSpace_spectrum /-- A class guaranteeing that the continuous functional calculus is uniquely determined by the properties that it is a continuous star algebra homomorphism mapping the (restriction of) the identity to `a`. This is the necessary tool used to establish `cfcHom_comp` and the more common variant `cfc_comp`. This class has instances, which can be found in `Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Unique.lean`, in each of the common cases `ℂ`, `ℝ` and `ℝ≥0` as a consequence of the Stone-Weierstrass theorem. This class is separate from `ContinuousFunctionalCalculus` primarily because we will later use `SpectrumRestricts` to derive an instance of `ContinuousFunctionalCalculus` on a scalar subring from one on a larger ring (i.e., to go from a continuous functional calculus over `ℂ` for normal elements to one over `ℝ` for selfadjoint elements), and proving this additional property is preserved would be burdensome or impossible. -/ class ContinuousMap.UniqueHom (R A : Type*) [CommSemiring R] [StarRing R] [MetricSpace R] [IsTopologicalSemiring R] [ContinuousStar R] [Ring A] [StarRing A] [TopologicalSpace A] [Algebra R A] : Prop where eq_of_continuous_of_map_id (s : Set R) [CompactSpace s] (φ ψ : C(s, R) →⋆ₐ[R] A) (hφ : Continuous φ) (hψ : Continuous ψ) (h : φ (.restrict s <| .id R) = ψ (.restrict s <| .id R)) : φ = ψ variable {R A : Type*} {p : A → Prop} [CommSemiring R] [StarRing R] [MetricSpace R] variable [IsTopologicalSemiring R] [ContinuousStar R] [TopologicalSpace A] [Ring A] [StarRing A] variable [Algebra R A] [instCFC : ContinuousFunctionalCalculus R A p] include instCFC in lemma ContinuousFunctionalCalculus.isCompact_spectrum (a : A) : IsCompact (spectrum R a) := isCompact_iff_compactSpace.mpr inferInstance lemma StarAlgHom.ext_continuousMap [UniqueHom R A] (a : A) [CompactSpace (spectrum R a)] (φ ψ : C(spectrum R a, R) →⋆ₐ[R] A) (hφ : Continuous φ) (hψ : Continuous ψ) (h : φ (.restrict (spectrum R a) <| .id R) = ψ (.restrict (spectrum R a) <| .id R)) : φ = ψ := UniqueHom.eq_of_continuous_of_map_id (spectrum R a) φ ψ hφ hψ h section cfcHom variable {a : A} (ha : p a) -- Note: since `spectrum R a` is closed, we may always extend `f : C(spectrum R a, R)` to a function -- of type `C(R, R)` by the Tietze extension theorem (assuming `R` is either `ℝ`, `ℂ` or `ℝ≥0`). /-- The star algebra homomorphism underlying a instance of the continuous functional calculus; a version for continuous functions on the spectrum. In this case, the user must supply the fact that `a` satisfies the predicate `p`, for otherwise it may be the case that no star algebra homomorphism exists. For instance if `R := ℝ` and `a` is an element whose spectrum (in `ℂ`) is disjoint from `ℝ`, then `spectrum ℝ a = ∅` and so there can be no star algebra homomorphism between these spaces. While `ContinuousFunctionalCalculus` is stated in terms of these homomorphisms, in practice the user should instead prefer `cfc` over `cfcHom`. -/ noncomputable def cfcHom : C(spectrum R a, R) →⋆ₐ[R] A := (ContinuousFunctionalCalculus.exists_cfc_of_predicate a ha).choose lemma cfcHom_isClosedEmbedding : IsClosedEmbedding <| (cfcHom ha : C(spectrum R a, R) →⋆ₐ[R] A) := (ContinuousFunctionalCalculus.exists_cfc_of_predicate a ha).choose_spec.1 @[fun_prop] lemma cfcHom_continuous : Continuous (cfcHom ha : C(spectrum R a, R) →⋆ₐ[R] A) := cfcHom_isClosedEmbedding ha |>.continuous lemma cfcHom_id : cfcHom ha ((ContinuousMap.id R).restrict <| spectrum R a) = a := (ContinuousFunctionalCalculus.exists_cfc_of_predicate a ha).choose_spec.2.1 /-- The **spectral mapping theorem** for the continuous functional calculus. -/ lemma cfcHom_map_spectrum (f : C(spectrum R a, R)) : spectrum R (cfcHom ha f) = Set.range f := (ContinuousFunctionalCalculus.exists_cfc_of_predicate a ha).choose_spec.2.2.1 f lemma cfcHom_predicate (f : C(spectrum R a, R)) : p (cfcHom ha f) := (ContinuousFunctionalCalculus.exists_cfc_of_predicate a ha).choose_spec.2.2.2 f open scoped ContinuousFunctionalCalculus in lemma cfcHom_eq_of_continuous_of_map_id [UniqueHom R A] (φ : C(spectrum R a, R) →⋆ₐ[R] A) (hφ₁ : Continuous φ) (hφ₂ : φ (.restrict (spectrum R a) <| .id R) = a) : cfcHom ha = φ := (cfcHom ha).ext_continuousMap a φ (cfcHom_isClosedEmbedding ha).continuous hφ₁ <| by rw [cfcHom_id ha, hφ₂] theorem cfcHom_comp [UniqueHom R A] (f : C(spectrum R a, R)) (f' : C(spectrum R a, spectrum R (cfcHom ha f))) (hff' : ∀ x, f x = f' x) (g : C(spectrum R (cfcHom ha f), R)) : cfcHom ha (g.comp f') = cfcHom (cfcHom_predicate ha f) g := by let φ : C(spectrum R (cfcHom ha f), R) →⋆ₐ[R] A := (cfcHom ha).comp <| ContinuousMap.compStarAlgHom' R R f' suffices cfcHom (cfcHom_predicate ha f) = φ from DFunLike.congr_fun this.symm g refine cfcHom_eq_of_continuous_of_map_id (cfcHom_predicate ha f) φ ?_ ?_ · exact (cfcHom_isClosedEmbedding ha).continuous.comp f'.continuous_precomp · simp only [φ, StarAlgHom.comp_apply, ContinuousMap.compStarAlgHom'_apply] congr ext x simp [hff'] end cfcHom section cfcL /-- `cfcHom` bundled as a continuous linear map. -/ @[simps apply] noncomputable def cfcL {a : A} (ha : p a) : C(spectrum R a, R) →L[R] A := { cfcHom ha with toFun := cfcHom ha map_smul' := map_smul _ cont := (cfcHom_isClosedEmbedding ha).continuous } end cfcL section CFC open scoped Classical in /-- This is the *continuous functional calculus* of an element `a : A` applied to bare functions. When either `a` does not satisfy the predicate `p` (i.e., `a` is not `IsStarNormal`, `IsSelfAdjoint`, or `0 ≤ a` when `R` is `ℂ`, `ℝ`, or `ℝ≥0`, respectively), or when `f : R → R` is not continuous on the spectrum of `a`, then `cfc f a` returns the junk value `0`. This is the primary declaration intended for widespread use of the continuous functional calculus, and all the API applies to this declaration. For more information, see the module documentation for `Analysis.CStarAlgebra.ContinuousFunctionalCalculus.Unital`. -/ noncomputable irreducible_def cfc (f : R → R) (a : A) : A := if h : p a ∧ ContinuousOn f (spectrum R a) then cfcHom h.1 ⟨_, h.2.restrict⟩ else 0 variable (f g : R → R) (a : A) (ha : p a := by cfc_tac) variable (hf : ContinuousOn f (spectrum R a) := by cfc_cont_tac) variable (hg : ContinuousOn g (spectrum R a) := by cfc_cont_tac) lemma cfc_apply : cfc f a = cfcHom (a := a) ha ⟨_, hf.restrict⟩ := by rw [cfc_def, dif_pos ⟨ha, hf⟩] lemma cfc_apply_pi {ι : Type*} (f : ι → R → R) (a : A) (ha : p a := by cfc_tac) (hf : ∀ i, ContinuousOn (f i) (spectrum R a) := by cfc_cont_tac) : (fun i => cfc (f i) a) = (fun i => cfcHom (a := a) ha ⟨_, (hf i).restrict⟩) := by ext i simp only [cfc_apply (f i) a ha (hf i)] lemma cfc_apply_of_not_and {f : R → R} (a : A) (ha : ¬ (p a ∧ ContinuousOn f (spectrum R a))) : cfc f a = 0 := by rw [cfc_def, dif_neg ha] lemma cfc_apply_of_not_predicate {f : R → R} (a : A) (ha : ¬ p a) : cfc f a = 0 := by rw [cfc_def, dif_neg (not_and_of_not_left _ ha)] lemma cfc_apply_of_not_continuousOn {f : R → R} (a : A) (hf : ¬ ContinuousOn f (spectrum R a)) : cfc f a = 0 := by rw [cfc_def, dif_neg (not_and_of_not_right _ hf)] lemma cfcHom_eq_cfc_extend {a : A} (g : R → R) (ha : p a) (f : C(spectrum R a, R)) : cfcHom ha f = cfc (Function.extend Subtype.val f g) a := by have h : f = (spectrum R a).restrict (Function.extend Subtype.val f g) := by ext; simp have hg : ContinuousOn (Function.extend Subtype.val f g) (spectrum R a) := continuousOn_iff_continuous_restrict.mpr <| h ▸ map_continuous f rw [cfc_apply ..] congr! lemma cfc_eq_cfcL {a : A} {f : R → R} (ha : p a) (hf : ContinuousOn f (spectrum R a)) : cfc f a = cfcL ha ⟨_, hf.restrict⟩ := by rw [cfc_def, dif_pos ⟨ha, hf⟩, cfcL_apply] /-- A version of `cfc_apply` in terms of `ContinuousMap.mkD` -/ lemma cfc_apply_mkD : cfc f a = cfcHom (a := a) ha (mkD ((spectrum R a).restrict f) 0) := by by_cases hf : ContinuousOn f (spectrum R a) · rw [cfc_apply f a, mkD_of_continuousOn hf] · rw [cfc_apply_of_not_continuousOn a hf, mkD_of_not_continuousOn hf, map_zero] /-- A version of `cfc_eq_cfcL` in terms of `ContinuousMapZero.mkD` -/ lemma cfc_eq_cfcL_mkD : cfc f a = cfcL (a := a) ha (mkD ((spectrum R a).restrict f) 0) := cfc_apply_mkD _ _ lemma cfc_cases (P : A → Prop) (a : A) (f : R → R) (h₀ : P 0) (haf : (hf : ContinuousOn f (spectrum R a)) → (ha : p a) → P (cfcHom ha ⟨_, hf.restrict⟩)) : P (cfc f a) := by by_cases h : p a ∧ ContinuousOn f (spectrum R a) · rw [cfc_apply f a h.1 h.2] exact haf h.2 h.1 · simp only [not_and_or] at h obtain (h | h) := h · rwa [cfc_apply_of_not_predicate _ h] · rwa [cfc_apply_of_not_continuousOn _ h] lemma cfc_commute_cfc (f g : R → R) (a : A) : Commute (cfc f a) (cfc g a) := by refine cfc_cases (fun x ↦ Commute x (cfc g a)) a f (by simp) fun hf ha ↦ ?_ refine cfc_cases (fun x ↦ Commute _ x) a g (by simp) fun hg _ ↦ ?_ exact Commute.all _ _ |>.map _ variable (R) in lemma cfc_id (ha : p a := by cfc_tac) : cfc (id : R → R) a = a := cfc_apply (id : R → R) a ▸ cfcHom_id (p := p) ha variable (R) in lemma cfc_id' (ha : p a := by cfc_tac) : cfc (fun x : R ↦ x) a = a := cfc_id R a /-- The **spectral mapping theorem** for the continuous functional calculus. -/ lemma cfc_map_spectrum (ha : p a := by cfc_tac) (hf : ContinuousOn f (spectrum R a) := by cfc_cont_tac) : spectrum R (cfc f a) = f '' spectrum R a := by simp [cfc_apply f a, cfcHom_map_spectrum (p := p)] lemma cfc_const (r : R) (a : A) (ha : p a := by cfc_tac) : cfc (fun _ ↦ r) a = algebraMap R A r := by rw [cfc_apply (fun _ : R ↦ r) a, ← AlgHomClass.commutes (cfcHom ha (p := p)) r] congr variable (R) in include R in lemma cfc_predicate_zero : p 0 := ContinuousFunctionalCalculus.predicate_zero (R := R) lemma cfc_predicate (f : R → R) (a : A) : p (cfc f a) := cfc_cases p a f (cfc_predicate_zero R) fun _ _ ↦ cfcHom_predicate .. lemma cfc_predicate_algebraMap (r : R) : p (algebraMap R A r) := cfc_const r (0 : A) (cfc_predicate_zero R) ▸ cfc_predicate (fun _ ↦ r) 0 variable (R) in include R in lemma cfc_predicate_one : p 1 := map_one (algebraMap R A) ▸ cfc_predicate_algebraMap (1 : R) lemma cfc_congr {f g : R → R} {a : A} (hfg : (spectrum R a).EqOn f g) : cfc f a = cfc g a := by by_cases h : p a ∧ ContinuousOn g (spectrum R a) · rw [cfc_apply (ha := h.1) (hf := h.2.congr hfg), cfc_apply (ha := h.1) (hf := h.2)] congr 2 exact Set.restrict_eq_iff.mpr hfg · obtain (ha | hg) := not_and_or.mp h · simp [cfc_apply_of_not_predicate a ha] · rw [cfc_apply_of_not_continuousOn a hg, cfc_apply_of_not_continuousOn] exact fun hf ↦ hg (hf.congr hfg.symm) lemma eqOn_of_cfc_eq_cfc {f g : R → R} {a : A} (h : cfc f a = cfc g a) (hf : ContinuousOn f (spectrum R a) := by cfc_cont_tac) (hg : ContinuousOn g (spectrum R a) := by cfc_cont_tac) (ha : p a := by cfc_tac) : (spectrum R a).EqOn f g := by rw [cfc_apply f a, cfc_apply g a] at h have := (cfcHom_isClosedEmbedding (show p a from ha) (R := R)).injective h intro x hx congrm($(this) ⟨x, hx⟩) variable {a f g} in include ha hf hg in lemma cfc_eq_cfc_iff_eqOn : cfc f a = cfc g a ↔ (spectrum R a).EqOn f g := ⟨eqOn_of_cfc_eq_cfc, cfc_congr⟩ variable (R) include ha in lemma cfc_one : cfc (1 : R → R) a = 1 := cfc_apply (1 : R → R) a ▸ map_one (cfcHom (show p a from ha)) include ha in lemma cfc_const_one : cfc (fun _ : R ↦ 1) a = 1 := cfc_one R a @[simp] lemma cfc_zero : cfc (0 : R → R) a = 0 := by by_cases ha : p a · exact cfc_apply (0 : R → R) a ▸ map_zero (cfcHom ha) · rw [cfc_apply_of_not_predicate a ha] @[simp] lemma cfc_const_zero : cfc (fun _ : R ↦ 0) a = 0 := cfc_zero R a variable {R} lemma cfc_mul (f g : R → R) (a : A) (hf : ContinuousOn f (spectrum R a) := by cfc_cont_tac) (hg : ContinuousOn g (spectrum R a) := by cfc_cont_tac) : cfc (fun x ↦ f x * g x) a = cfc f a * cfc g a := by by_cases ha : p a · rw [cfc_apply f a, cfc_apply g a, ← map_mul, cfc_apply _ a] congr · simp [cfc_apply_of_not_predicate a ha] lemma cfc_pow (f : R → R) (n : ℕ) (a : A) (hf : ContinuousOn f (spectrum R a) := by cfc_cont_tac) (ha : p a := by cfc_tac) : cfc (fun x ↦ (f x) ^ n) a = cfc f a ^ n := by rw [cfc_apply f a, ← map_pow, cfc_apply _ a] congr lemma cfc_add (f g : R → R) (hf : ContinuousOn f (spectrum R a) := by cfc_cont_tac) (hg : ContinuousOn g (spectrum R a) := by cfc_cont_tac) : cfc (fun x ↦ f x + g x) a = cfc f a + cfc g a := by by_cases ha : p a · rw [cfc_apply f a, cfc_apply g a, ← map_add, cfc_apply _ a] congr · simp [cfc_apply_of_not_predicate a ha] lemma cfc_const_add (r : R) (f : R → R) (a : A) (hf : ContinuousOn f (spectrum R a) := by cfc_cont_tac) (ha : p a := by cfc_tac) : cfc (fun x => r + f x) a = algebraMap R A r + cfc f a := by have : (fun z => r + f z) = (fun z => (fun _ => r) z + f z) := by ext; simp rw [this, cfc_add a _ _ (continuousOn_const (c := r)) hf, cfc_const r a ha] lemma cfc_add_const (r : R) (f : R → R) (a : A) (hf : ContinuousOn f (spectrum R a) := by cfc_cont_tac) (ha : p a := by cfc_tac) : cfc (fun x => f x + r) a = cfc f a + algebraMap R A r := by rw [add_comm (cfc f a)] conv_lhs => simp only [add_comm] exact cfc_const_add r f a hf ha open Finset in lemma cfc_sum {ι : Type*} (f : ι → R → R) (a : A) (s : Finset ι) (hf : ∀ i ∈ s, ContinuousOn (f i) (spectrum R a) := by cfc_cont_tac) : cfc (∑ i ∈ s, f i) a = ∑ i ∈ s, cfc (f i) a := by by_cases ha : p a · have hsum : s.sum f = fun z => ∑ i ∈ s, f i z := by ext; simp have hf' : ContinuousOn (∑ i : s, f i) (spectrum R a) := by rw [sum_coe_sort s, hsum] exact continuousOn_finset_sum s fun i hi => hf i hi rw [← sum_coe_sort s, ← sum_coe_sort s] rw [cfc_apply_pi _ a ha (fun ⟨i, hi⟩ => hf i hi), ← map_sum, cfc_apply _ a ha hf'] congr 1 ext simp · simp [cfc_apply_of_not_predicate a ha] open Finset in lemma cfc_sum_univ {ι : Type*} [Fintype ι] (f : ι → R → R) (a : A) (hf : ∀ i, ContinuousOn (f i) (spectrum R a) := by cfc_cont_tac) : cfc (∑ i, f i) a = ∑ i, cfc (f i) a := cfc_sum f a _ fun i _ ↦ hf i lemma cfc_smul {S : Type*} [SMul S R] [ContinuousConstSMul S R] [SMulZeroClass S A] [IsScalarTower S R A] [IsScalarTower S R (R → R)] (s : S) (f : R → R) (a : A) (hf : ContinuousOn f (spectrum R a) := by cfc_cont_tac) : cfc (fun x ↦ s • f x) a = s • cfc f a := by by_cases ha : p a · rw [cfc_apply f a, cfc_apply _ a] simp_rw [← Pi.smul_def, ← smul_one_smul R s _] rw [← map_smul] congr · simp [cfc_apply_of_not_predicate a ha] lemma cfc_const_mul (r : R) (f : R → R) (a : A) (hf : ContinuousOn f (spectrum R a) := by cfc_cont_tac) : cfc (fun x ↦ r * f x) a = r • cfc f a := cfc_smul r f a lemma cfc_star (f : R → R) (a : A) : cfc (fun x ↦ star (f x)) a = star (cfc f a) := by by_cases h : p a ∧ ContinuousOn f (spectrum R a) · obtain ⟨ha, hf⟩ := h rw [cfc_apply f a, ← map_star, cfc_apply _ a] congr · obtain (ha | hf) := not_and_or.mp h · simp [cfc_apply_of_not_predicate a ha] · rw [cfc_apply_of_not_continuousOn a hf, cfc_apply_of_not_continuousOn, star_zero] exact fun hf_star ↦ hf <| by simpa using hf_star.star lemma cfc_pow_id (a : A) (n : ℕ) (ha : p a := by cfc_tac) : cfc (· ^ n : R → R) a = a ^ n := by rw [cfc_pow .., cfc_id' ..] lemma cfc_smul_id {S : Type*} [SMul S R] [ContinuousConstSMul S R] [SMulZeroClass S A] [IsScalarTower S R A] [IsScalarTower S R (R → R)] (s : S) (a : A) (ha : p a := by cfc_tac) : cfc (s • · : R → R) a = s • a := by rw [cfc_smul .., cfc_id' ..] lemma cfc_const_mul_id (r : R) (a : A) (ha : p a := by cfc_tac) : cfc (r * ·) a = r • a := cfc_smul_id r a include ha in lemma cfc_star_id : cfc (star · : R → R) a = star a := by rw [cfc_star .., cfc_id' ..] variable (R) in theorem range_cfc_eq_range_cfcHom [StarModule R A] {a : A} (ha : p a) : Set.range (cfc (R := R) · a) = (cfcHom ha (R := R)).range := by ext constructor all_goals rintro ⟨f, rfl⟩ · exact cfc_cases _ a f (zero_mem _) fun hf ha ↦ ⟨_, rfl⟩ · exact ⟨Subtype.val.extend f 0, cfcHom_eq_cfc_extend _ ha _ |>.symm⟩ section Polynomial open Polynomial lemma cfc_eval_X (ha : p a := by cfc_tac) : cfc (X : R[X]).eval a = a := by simpa using cfc_id R a lemma cfc_eval_C (r : R) (a : A) (ha : p a := by cfc_tac) : cfc (C r).eval a = algebraMap R A r := by simp [cfc_const r a] lemma cfc_map_polynomial (q : R[X]) (f : R → R) (a : A) (ha : p a := by cfc_tac) (hf : ContinuousOn f (spectrum R a) := by cfc_cont_tac) : cfc (fun x ↦ q.eval (f x)) a = aeval (cfc f a) q := by induction q using Polynomial.induction_on with | C r => simp [cfc_const r a] | add q₁ q₂ hq₁ hq₂ => simp only [eval_add, map_add, ← hq₁, ← hq₂, cfc_add a (q₁.eval <| f ·) (q₂.eval <| f ·)] | monomial n r _ => simp only [eval_mul, eval_C, eval_X_pow, map_mul, aeval_C, map_pow, aeval_X] rw [cfc_const_mul .., cfc_pow _ (n + 1) _, ← smul_eq_mul, algebraMap_smul] lemma cfc_polynomial (q : R[X]) (a : A) (ha : p a := by cfc_tac) : cfc q.eval a = aeval a q := by rw [cfc_map_polynomial .., cfc_id' ..] end Polynomial section Comp variable [UniqueHom R A] lemma cfc_comp (g f : R → R) (a : A) (ha : p a := by cfc_tac) (hg : ContinuousOn g (f '' spectrum R a) := by cfc_cont_tac) (hf : ContinuousOn f (spectrum R a) := by cfc_cont_tac) : cfc (g ∘ f) a = cfc g (cfc f a) := by have := hg.comp hf <| (spectrum R a).mapsTo_image f have sp_eq : spectrum R (cfcHom (show p a from ha) (ContinuousMap.mk _ hf.restrict)) = f '' (spectrum R a) := by rw [cfcHom_map_spectrum (by exact ha) _] ext simp rw [cfc_apply .., cfc_apply f a, cfc_apply _ _ (cfcHom_predicate (show p a from ha) _) (by convert hg), ← cfcHom_comp _ _] swap · exact ContinuousMap.mk _ <| hf.restrict.codRestrict fun x ↦ by rw [sp_eq]; use x.1; simp · congr · exact fun _ ↦ rfl lemma cfc_comp' (g f : R → R) (a : A) (hg : ContinuousOn g (f '' spectrum R a) := by cfc_cont_tac) (hf : ContinuousOn f (spectrum R a) := by cfc_cont_tac) (ha : p a := by cfc_tac) : cfc (g <| f ·) a = cfc g (cfc f a) := cfc_comp g f a lemma cfc_comp_pow (f : R → R) (n : ℕ) (a : A) (hf : ContinuousOn f ((· ^ n) '' (spectrum R a)) := by cfc_cont_tac) (ha : p a := by cfc_tac) : cfc (f <| · ^ n) a = cfc f (a ^ n) := by rw [cfc_comp' .., cfc_pow_id ..] lemma cfc_comp_smul {S : Type*} [SMul S R] [ContinuousConstSMul S R] [SMulZeroClass S A] [IsScalarTower S R A] [IsScalarTower S R (R → R)] (s : S) (f : R → R) (a : A) (hf : ContinuousOn f ((s • ·) '' (spectrum R a)) := by cfc_cont_tac) (ha : p a := by cfc_tac) : cfc (f <| s • ·) a = cfc f (s • a) := by rw [cfc_comp' .., cfc_smul_id ..] lemma cfc_comp_const_mul (r : R) (f : R → R) (a : A) (hf : ContinuousOn f ((r * ·) '' (spectrum R a)) := by cfc_cont_tac) (ha : p a := by cfc_tac) : cfc (f <| r * ·) a = cfc f (r • a) := by rw [cfc_comp' .., cfc_const_mul_id ..] lemma cfc_comp_star (f : R → R) (a : A) (hf : ContinuousOn f (star '' (spectrum R a)) := by cfc_cont_tac) (ha : p a := by cfc_tac) : cfc (f <| star ·) a = cfc f (star a) := by rw [cfc_comp' .., cfc_star_id ..] open Polynomial in lemma cfc_comp_polynomial (q : R[X]) (f : R → R) (a : A) (hf : ContinuousOn f (q.eval '' (spectrum R a)) := by cfc_cont_tac) (ha : p a := by cfc_tac) : cfc (f <| q.eval ·) a = cfc f (aeval a q) := by rw [cfc_comp' .., cfc_polynomial ..] end Comp lemma CFC.eq_algebraMap_of_spectrum_subset_singleton (r : R) (h_spec : spectrum R a ⊆ {r}) (ha : p a := by cfc_tac) : a = algebraMap R A r := by simpa [cfc_id R a, cfc_const r a] using cfc_congr (f := id) (g := fun _ : R ↦ r) (a := a) fun x hx ↦ by simpa using h_spec hx lemma CFC.eq_zero_of_spectrum_subset_zero (h_spec : spectrum R a ⊆ {0}) (ha : p a := by cfc_tac) : a = 0 := by simpa using eq_algebraMap_of_spectrum_subset_singleton a 0 h_spec lemma CFC.eq_one_of_spectrum_subset_one (h_spec : spectrum R a ⊆ {1}) (ha : p a := by cfc_tac) : a = 1 := by simpa using eq_algebraMap_of_spectrum_subset_singleton a 1 h_spec include instCFC in lemma CFC.spectrum_algebraMap_subset (r : R) : spectrum R (algebraMap R A r) ⊆ {r} := by rw [← cfc_const r 0 (cfc_predicate_zero R), cfc_map_spectrum (fun _ ↦ r) 0 (cfc_predicate_zero R)] rintro - ⟨x, -, rfl⟩ simp include instCFC in lemma CFC.spectrum_algebraMap_eq [Nontrivial A] (r : R) : spectrum R (algebraMap R A r) = {r} := by have hp : p 0 := cfc_predicate_zero R rw [← cfc_const r 0 hp, cfc_map_spectrum (fun _ => r) 0 hp] exact Set.Nonempty.image_const (⟨0, spectrum.zero_mem (R := R) not_isUnit_zero⟩) _ include instCFC in lemma CFC.spectrum_zero_eq [Nontrivial A] : spectrum R (0 : A) = {0} := by have : (0 : A) = algebraMap R A 0 := Eq.symm (RingHom.map_zero (algebraMap R A)) rw [this, spectrum_algebraMap_eq] include instCFC in lemma CFC.spectrum_one_eq [Nontrivial A] : spectrum R (1 : A) = {1} := by have : (1 : A) = algebraMap R A 1 := Eq.symm (RingHom.map_one (algebraMap R A)) rw [this, spectrum_algebraMap_eq] @[simp] lemma cfc_algebraMap (r : R) (f : R → R) : cfc f (algebraMap R A r) = algebraMap R A (f r) := by have h₁ : ContinuousOn f (spectrum R (algebraMap R A r)) := continuousOn_singleton _ _ |>.mono <| CFC.spectrum_algebraMap_subset r rw [cfc_apply f (algebraMap R A r) (cfc_predicate_algebraMap r), ← AlgHomClass.commutes (cfcHom (p := p) (cfc_predicate_algebraMap r)) (f r)] congr ext ⟨x, hx⟩ apply CFC.spectrum_algebraMap_subset r at hx simp_all @[simp] lemma cfc_apply_zero {f : R → R} : cfc f (0 : A) = algebraMap R A (f 0) := by simpa using cfc_algebraMap (A := A) 0 f @[simp] lemma cfc_apply_one {f : R → R} : cfc f (1 : A) = algebraMap R A (f 1) := by simpa using cfc_algebraMap (A := A) 1 f @[simp] instance IsStarNormal.cfc_map (f : R → R) (a : A) : IsStarNormal (cfc f a) where star_comm_self := by rw [Commute, SemiconjBy] by_cases h : ContinuousOn f (spectrum R a) · rw [← cfc_star, ← cfc_mul .., ← cfc_mul ..] congr! 2 exact mul_comm _ _ · simp [cfc_apply_of_not_continuousOn a h] -- The following two lemmas are just `cfc_predicate`, but specific enough for the `@[simp]` tag. @[simp] protected lemma IsSelfAdjoint.cfc [ContinuousFunctionalCalculus R A IsSelfAdjoint] {f : R → R} {a : A} : IsSelfAdjoint (cfc f a) := cfc_predicate _ _ @[simp] lemma cfc_nonneg_of_predicate [LE A] [ContinuousFunctionalCalculus R A (0 ≤ ·)] {f : R → R} {a : A} : 0 ≤ cfc f a := cfc_predicate _ _ variable (R) in /-- In an `R`-algebra with a continuous functional calculus, every element satisfying the predicate has nonempty `R`-spectrum. -/ lemma CFC.spectrum_nonempty [Nontrivial A] (a : A) (ha : p a := by cfc_tac) : (spectrum R a).Nonempty := by by_contra! h apply one_ne_zero (α := A) rw [← cfc_one R a, ← cfc_zero R a] exact cfc_congr fun x hx ↦ by simp_all end CFC end Basic section Inv variable {R A : Type*} {p : A → Prop} [Semifield R] [StarRing R] [MetricSpace R] variable [IsTopologicalSemiring R] [ContinuousStar R] [TopologicalSpace A] variable [Ring A] [StarRing A] [Algebra R A] [ContinuousFunctionalCalculus R A p] lemma isUnit_cfc_iff (f : R → R) (a : A) (hf : ContinuousOn f (spectrum R a) := by cfc_cont_tac) (ha : p a := by cfc_tac) : IsUnit (cfc f a) ↔ ∀ x ∈ spectrum R a, f x ≠ 0 := by rw [← spectrum.zero_notMem_iff R, cfc_map_spectrum ..] simp alias ⟨_, isUnit_cfc⟩ := isUnit_cfc_iff variable [ContinuousInv₀ R] (f : R → R) (a : A) /-- Bundle `cfc f a` into a unit given a proof that `f` is nonzero on the spectrum of `a`. -/ @[simps] noncomputable def cfcUnits (hf' : ∀ x ∈ spectrum R a, f x ≠ 0) (hf : ContinuousOn f (spectrum R a) := by cfc_cont_tac) (ha : p a := by cfc_tac) : Aˣ where val := cfc f a inv := cfc (fun x ↦ (f x)⁻¹) a val_inv := by rw [← cfc_mul .., ← cfc_one R a] exact cfc_congr fun _ _ ↦ by aesop inv_val := by rw [← cfc_mul .., ← cfc_one R a] exact cfc_congr fun _ _ ↦ by aesop lemma cfcUnits_pow (hf' : ∀ x ∈ spectrum R a, f x ≠ 0) (n : ℕ) (hf : ContinuousOn f (spectrum R a) := by cfc_cont_tac) (ha : p a := by cfc_tac) : (cfcUnits f a hf') ^ n = cfcUnits _ _ (forall₂_imp (fun _ _ ↦ pow_ne_zero n) hf') (hf := hf.pow n) := by ext cases n with | zero => simp [cfc_const_one R a] | succ n => simp [cfc_pow f _ a] lemma cfc_inv (hf' : ∀ x ∈ spectrum R a, f x ≠ 0) (hf : ContinuousOn f (spectrum R a) := by cfc_cont_tac) (ha : p a := by cfc_tac) : cfc (fun x ↦ (f x) ⁻¹) a = Ring.inverse (cfc f a) := by rw [← val_inv_cfcUnits f a hf', ← val_cfcUnits f a hf', Ring.inverse_unit] lemma cfc_inv_id (a : Aˣ) (ha : p a := by cfc_tac) : cfc (fun x ↦ x⁻¹ : R → R) (a : A) = a⁻¹ := by rw [← Ring.inverse_unit] convert cfc_inv (id : R → R) (a : A) ?_ · exact (cfc_id R (a : A)).symm · rintro x hx rfl exact spectrum.zero_notMem R a.isUnit hx lemma cfc_map_div (f g : R → R) (a : A) (hg' : ∀ x ∈ spectrum R a, g x ≠ 0) (hf : ContinuousOn f (spectrum R a) := by cfc_cont_tac) (hg : ContinuousOn g (spectrum R a) := by cfc_cont_tac) (ha : p a := by cfc_tac) : cfc (fun x ↦ f x / g x) a = cfc f a * Ring.inverse (cfc g a) := by simp only [div_eq_mul_inv] rw [cfc_mul .., cfc_inv g a hg'] section ContinuousOnInvSpectrum -- TODO: this section should probably be moved to another file altogether variable {R A : Type*} [Semifield R] [Ring A] [TopologicalSpace R] [ContinuousInv₀ R] variable [Algebra R A] @[fun_prop] lemma Units.continuousOn_inv₀_spectrum (a : Aˣ) : ContinuousOn (· ⁻¹) (spectrum R (a : A)) := continuousOn_inv₀.mono <| by simpa only [Set.subset_compl_singleton_iff] using spectrum.zero_notMem R a.isUnit @[fun_prop] lemma Units.continuousOn_zpow₀_spectrum [ContinuousMul R] (a : Aˣ) (n : ℤ) : ContinuousOn (· ^ n) (spectrum R (a : A)) := (continuousOn_zpow₀ n).mono <| by simpa only [Set.subset_compl_singleton_iff] using spectrum.zero_notMem R a.isUnit end ContinuousOnInvSpectrum lemma cfcUnits_zpow (hf' : ∀ x ∈ spectrum R a, f x ≠ 0) (n : ℤ) (hf : ContinuousOn f (spectrum R a) := by cfc_cont_tac) (ha : p a := by cfc_tac) : (cfcUnits f a hf') ^ n = cfcUnits (f ^ n) a (forall₂_imp (fun _ _ ↦ zpow_ne_zero n) hf') (hf.zpow₀ n (forall₂_imp (fun _ _ ↦ Or.inl) hf')) := by cases n with | ofNat _ => simpa using cfcUnits_pow f a hf' _ | negSucc n => simp only [zpow_negSucc, ← inv_pow] ext exact cfc_pow (hf := hf.inv₀ hf') .. |>.symm lemma cfc_zpow (a : Aˣ) (n : ℤ) (ha : p a := by cfc_tac) : cfc (fun x : R ↦ x ^ n) (a : A) = ↑(a ^ n) := by cases n with | ofNat n => simpa using cfc_pow_id (a : A) n | negSucc n => simp only [zpow_negSucc, ← inv_pow, Units.val_pow_eq_pow_val] have := cfc_pow (fun x ↦ x⁻¹ : R → R) (n + 1) (a : A) exact this.trans <| congr($(cfc_inv_id a) ^ (n + 1)) variable [UniqueHom R A] lemma cfc_comp_inv (f : R → R) (a : Aˣ) (hf : ContinuousOn f ((·⁻¹) '' (spectrum R (a : A))) := by cfc_cont_tac) (ha : p a := by cfc_tac) : cfc (fun x ↦ f x⁻¹) (a : A) = cfc f (↑a⁻¹ : A) := by rw [cfc_comp' .., cfc_inv_id _] lemma cfc_comp_zpow (f : R → R) (n : ℤ) (a : Aˣ) (hf : ContinuousOn f ((· ^ n) '' (spectrum R (a : A))) := by cfc_cont_tac) (ha : p a := by cfc_tac) : cfc (fun x ↦ f (x ^ n)) (a : A) = cfc f (↑(a ^ n) : A) := by rw [cfc_comp' .., cfc_zpow a] end Inv section Neg variable {R A : Type*} {p : A → Prop} [CommRing R] [StarRing R] [MetricSpace R] variable [IsTopologicalRing R] [ContinuousStar R] [TopologicalSpace A] variable [Ring A] [StarRing A] [Algebra R A] [ContinuousFunctionalCalculus R A p] variable (f g : R → R) (a : A) (hf : ContinuousOn f (spectrum R a) := by cfc_cont_tac) variable (hg : ContinuousOn g (spectrum R a) := by cfc_cont_tac) include hf hg in lemma cfc_sub : cfc (fun x ↦ f x - g x) a = cfc f a - cfc g a := by by_cases ha : p a · rw [cfc_apply f a, cfc_apply g a, ← map_sub, cfc_apply ..] congr · simp [cfc_apply_of_not_predicate a ha] lemma cfc_neg : cfc (fun x ↦ - (f x)) a = - (cfc f a) := by by_cases h : p a ∧ ContinuousOn f (spectrum R a) · obtain ⟨ha, hf⟩ := h rw [cfc_apply f a, ← map_neg, cfc_apply ..] congr · obtain (ha | hf) := not_and_or.mp h · simp [cfc_apply_of_not_predicate a ha] · rw [cfc_apply_of_not_continuousOn a hf, cfc_apply_of_not_continuousOn, neg_zero] exact fun hf_neg ↦ hf <| by simpa using hf_neg.neg lemma cfc_neg_id (ha : p a := by cfc_tac) : cfc (- · : R → R) a = -a := by rw [cfc_neg _ a, cfc_id' R a] variable [UniqueHom R A] lemma cfc_comp_neg (hf : ContinuousOn f ((-·) '' (spectrum R (a : A))) := by cfc_cont_tac) (ha : p a := by cfc_tac) : cfc (f <| - ·) a = cfc f (-a) := by rw [cfc_comp' .., cfc_neg_id _] end Neg section Order section Semiring variable {R A : Type*} {p : A → Prop} [CommSemiring R] [PartialOrder R] [StarRing R] [MetricSpace R] variable [IsTopologicalSemiring R] [ContinuousStar R] [ContinuousSqrt R] [StarOrderedRing R] variable [TopologicalSpace A] [Ring A] [StarRing A] [PartialOrder A] [StarOrderedRing A] variable [Algebra R A] [instCFC : ContinuousFunctionalCalculus R A p] lemma cfcHom_mono {a : A} (ha : p a) {f g : C(spectrum R a, R)} (hfg : f ≤ g) : cfcHom ha f ≤ cfcHom ha g := OrderHomClass.mono (cfcHom ha) hfg lemma cfcHom_nonneg_iff [NonnegSpectrumClass R A] {a : A} (ha : p a) {f : C(spectrum R a, R)} : 0 ≤ cfcHom ha f ↔ 0 ≤ f := by constructor · exact fun hf x ↦ (cfcHom_map_spectrum ha (R := R) _ ▸ spectrum_nonneg_of_nonneg hf) ⟨x, rfl⟩ · simpa using (cfcHom_mono ha (f := 0) (g := f) ·) lemma cfcHom_isStrictlyPositive_iff [NonnegSpectrumClass R A] {a : A} (ha : p a) {f : C(spectrum R a, R)} : IsStrictlyPositive (cfcHom ha f) ↔ ∀ x, 0 < f x := by refine ⟨fun hf x => hf.spectrum_pos <| cfcHom_map_spectrum (R := R) ha _ ▸ Set.mem_range_self x, fun h => ⟨cfcHom_nonneg_iff _ |>.mpr fun x => le_of_lt (h x), ?_⟩⟩ apply spectrum.isUnit_of_zero_notMem (R := R) grind [cfcHom_map_spectrum, ne_of_lt] lemma cfc_mono {f g : R → R} {a : A} (h : ∀ x ∈ spectrum R a, f x ≤ g x) (hf : ContinuousOn f (spectrum R a) := by cfc_cont_tac) (hg : ContinuousOn g (spectrum R a) := by cfc_cont_tac) : cfc f a ≤ cfc g a := by by_cases ha : p a · rw [cfc_apply f a, cfc_apply g a] exact cfcHom_mono ha fun x ↦ h x.1 x.2 · simp only [cfc_apply_of_not_predicate _ ha, le_rfl] lemma cfc_nonneg_iff [NonnegSpectrumClass R A] (f : R → R) (a : A) (hf : ContinuousOn f (spectrum R a) := by cfc_cont_tac) (ha : p a := by cfc_tac) : 0 ≤ cfc f a ↔ ∀ x ∈ spectrum R a, 0 ≤ f x := by rw [cfc_apply .., cfcHom_nonneg_iff, ContinuousMap.le_def] simp lemma StarOrderedRing.nonneg_iff_spectrum_nonneg [NonnegSpectrumClass R A] (a : A) (ha : p a := by cfc_tac) : 0 ≤ a ↔ ∀ x ∈ spectrum R a, 0 ≤ x := by have := cfc_nonneg_iff (id : R → R) a (by fun_prop) ha simpa [cfc_id _ a ha] using this lemma cfc_isStrictlyPositive_iff [NonnegSpectrumClass R A] (f : R → R) (a : A) (hf : ContinuousOn f (spectrum R a) := by cfc_cont_tac) (ha : p a := by cfc_tac) : IsStrictlyPositive (cfc f a) ↔ ∀ x ∈ spectrum R a, 0 < f x := by rw [cfc_apply .., cfcHom_isStrictlyPositive_iff] simp lemma StarOrderedRing.isStrictlyPositive_iff_spectrum_pos [NonnegSpectrumClass R A] (a : A) (ha : p a := by cfc_tac) : IsStrictlyPositive a ↔ ∀ x ∈ spectrum R a, 0 < x := by have := cfc_isStrictlyPositive_iff (id : R → R) a (by fun_prop) ha simpa [cfc_id _ a ha] using this lemma cfc_nonneg {f : R → R} {a : A} (h : ∀ x ∈ spectrum R a, 0 ≤ f x) : 0 ≤ cfc f a := by by_cases hf : ContinuousOn f (spectrum R a) · simpa using cfc_mono h · simp only [cfc_apply_of_not_continuousOn _ hf, le_rfl] lemma cfc_nonpos (f : R → R) (a : A) (h : ∀ x ∈ spectrum R a, f x ≤ 0) : cfc f a ≤ 0 := by by_cases hf : ContinuousOn f (spectrum R a) · simpa using cfc_mono h · simp only [cfc_apply_of_not_continuousOn _ hf, le_rfl] lemma cfc_le_algebraMap (f : R → R) (r : R) (a : A) (h : ∀ x ∈ spectrum R a, f x ≤ r) (hf : ContinuousOn f (spectrum R a) := by cfc_cont_tac) (ha : p a := by cfc_tac) : cfc f a ≤ algebraMap R A r := cfc_const r a ▸ cfc_mono h lemma algebraMap_le_cfc (f : R → R) (r : R) (a : A) (h : ∀ x ∈ spectrum R a, r ≤ f x) (hf : ContinuousOn f (spectrum R a) := by cfc_cont_tac) (ha : p a := by cfc_tac) : algebraMap R A r ≤ cfc f a := cfc_const r a ▸ cfc_mono h lemma le_algebraMap_of_spectrum_le {r : R} {a : A} (h : ∀ x ∈ spectrum R a, x ≤ r) (ha : p a := by cfc_tac) : a ≤ algebraMap R A r := by rw [← cfc_id R a] exact cfc_le_algebraMap id r a h lemma algebraMap_le_of_le_spectrum {r : R} {a : A} (h : ∀ x ∈ spectrum R a, r ≤ x) (ha : p a := by cfc_tac) : algebraMap R A r ≤ a := by rw [← cfc_id R a] exact algebraMap_le_cfc id r a h lemma cfc_le_one (f : R → R) (a : A) (h : ∀ x ∈ spectrum R a, f x ≤ 1) : cfc f a ≤ 1 := by apply cfc_cases (· ≤ 1) _ _ (by simp) fun hf ha ↦ ?_ rw [← map_one (cfcHom ha (R := R))] apply cfcHom_mono ha simpa [ContinuousMap.le_def] using h lemma one_le_cfc (f : R → R) (a : A) (h : ∀ x ∈ spectrum R a, 1 ≤ f x) (hf : ContinuousOn f (spectrum R a) := by cfc_cont_tac) (ha : p a := by cfc_tac) : 1 ≤ cfc f a := by simpa using algebraMap_le_cfc f 1 a h lemma CFC.le_one {a : A} (h : ∀ x ∈ spectrum R a, x ≤ 1) (ha : p a := by cfc_tac) : a ≤ 1 := by simpa using le_algebraMap_of_spectrum_le h lemma CFC.one_le {a : A} (h : ∀ x ∈ spectrum R a, 1 ≤ x) (ha : p a := by cfc_tac) : 1 ≤ a := by simpa using algebraMap_le_of_le_spectrum h end Semiring section NNReal open scoped NNReal variable {A : Type*} [TopologicalSpace A] [Ring A] [StarRing A] [PartialOrder A] [Algebra ℝ≥0 A] [ContinuousFunctionalCalculus ℝ≥0 A (0 ≤ ·)] lemma CFC.inv_nonneg_of_nonneg (a : Aˣ) (ha : (0 : A) ≤ a := by cfc_tac) : (0 : A) ≤ a⁻¹ := cfc_inv_id (R := ℝ≥0) a ▸ cfc_predicate _ (a : A) lemma CFC.inv_nonneg (a : Aˣ) : (0 : A) ≤ a⁻¹ ↔ (0 : A) ≤ a := ⟨fun _ ↦ inv_inv a ▸ inv_nonneg_of_nonneg a⁻¹, fun _ ↦ inv_nonneg_of_nonneg a⟩ end NNReal section Ring variable {R A : Type*} {p : A → Prop} [CommRing R] [PartialOrder R] [StarRing R] [MetricSpace R] variable [IsTopologicalRing R] [ContinuousStar R] [ContinuousSqrt R] [StarOrderedRing R] variable [TopologicalSpace A] [Ring A] [StarRing A] [PartialOrder A] [StarOrderedRing A] variable [Algebra R A] [instCFC : ContinuousFunctionalCalculus R A p] variable [NonnegSpectrumClass R A] lemma cfcHom_le_iff {a : A} (ha : p a) {f g : C(spectrum R a, R)} : cfcHom ha f ≤ cfcHom ha g ↔ f ≤ g := by rw [← sub_nonneg, ← map_sub, cfcHom_nonneg_iff, sub_nonneg] lemma cfc_le_iff (f g : R → R) (a : A) (hf : ContinuousOn f (spectrum R a) := by cfc_cont_tac) (hg : ContinuousOn g (spectrum R a) := by cfc_cont_tac) (ha : p a := by cfc_tac) : cfc f a ≤ cfc g a ↔ ∀ x ∈ spectrum R a, f x ≤ g x := by rw [cfc_apply f a, cfc_apply g a, cfcHom_le_iff (show p a from ha), ContinuousMap.le_def] simp lemma cfc_nonpos_iff (f : R → R) (a : A) (hf : ContinuousOn f (spectrum R a) := by cfc_cont_tac) (ha : p a := by cfc_tac) : cfc f a ≤ 0 ↔ ∀ x ∈ spectrum R a, f x ≤ 0 := by simp_rw [← neg_nonneg, ← cfc_neg] exact cfc_nonneg_iff (fun x ↦ -f x) a lemma cfc_le_algebraMap_iff (f : R → R) (r : R) (a : A) (hf : ContinuousOn f (spectrum R a) := by cfc_cont_tac) (ha : p a := by cfc_tac) : cfc f a ≤ algebraMap R A r ↔ ∀ x ∈ spectrum R a, f x ≤ r := by rw [← cfc_const r a, cfc_le_iff ..] lemma algebraMap_le_cfc_iff (f : R → R) (r : R) (a : A) (hf : ContinuousOn f (spectrum R a) := by cfc_cont_tac) (ha : p a := by cfc_tac) : algebraMap R A r ≤ cfc f a ↔ ∀ x ∈ spectrum R a, r ≤ f x := by rw [← cfc_const r a, cfc_le_iff ..] lemma le_algebraMap_iff_spectrum_le {r : R} {a : A} (ha : p a := by cfc_tac) : a ≤ algebraMap R A r ↔ ∀ x ∈ spectrum R a, x ≤ r := by nth_rw 1 [← cfc_id R a] exact cfc_le_algebraMap_iff id r a lemma algebraMap_le_iff_le_spectrum {r : R} {a : A} (ha : p a := by cfc_tac) : algebraMap R A r ≤ a ↔ ∀ x ∈ spectrum R a, r ≤ x:= by nth_rw 1 [← cfc_id R a] exact algebraMap_le_cfc_iff id r a lemma cfc_le_one_iff (f : R → R) (a : A) (hf : ContinuousOn f (spectrum R a) := by cfc_cont_tac) (ha : p a := by cfc_tac) : cfc f a ≤ 1 ↔ ∀ x ∈ spectrum R a, f x ≤ 1 := by simpa using cfc_le_algebraMap_iff f 1 a lemma one_le_cfc_iff (f : R → R) (a : A) (hf : ContinuousOn f (spectrum R a) := by cfc_cont_tac) (ha : p a := by cfc_tac) : 1 ≤ cfc f a ↔ ∀ x ∈ spectrum R a, 1 ≤ f x := by simpa using algebraMap_le_cfc_iff f 1 a lemma CFC.le_one_iff (a : A) (ha : p a := by cfc_tac) : a ≤ 1 ↔ ∀ x ∈ spectrum R a, x ≤ 1 := by simpa using le_algebraMap_iff_spectrum_le (r := (1 : R)) (a := a) lemma CFC.one_le_iff (a : A) (ha : p a := by cfc_tac) : 1 ≤ a ↔ ∀ x ∈ spectrum R a, 1 ≤ x := by simpa using algebraMap_le_iff_le_spectrum (r := (1 : R)) (a := a) end Ring end Order /-! ### `cfcHom` on a superset of the spectrum -/ section Superset variable {R A : Type*} {p : A → Prop} [CommSemiring R] [StarRing R] [MetricSpace R] [IsTopologicalSemiring R] [ContinuousStar R] [Ring A] [StarRing A] [TopologicalSpace A] [Algebra R A] [instCFC : ContinuousFunctionalCalculus R A p] /-- The composition of `cfcHom` with the natural embedding `C(s, R) → C(spectrum R a, R)` whenever `spectrum R a ⊆ s`. This is sometimes necessary in order to consider the same continuous functions applied to multiple distinct elements, with the added constraint that `cfc` does not suffice. This can occur, for example, if it is necessary to use uniqueness of this continuous functional calculus. -/ @[simps!] noncomputable def cfcHomSuperset {a : A} (ha : p a) {s : Set R} (hs : spectrum R a ⊆ s) : C(s, R) →⋆ₐ[R] A := cfcHom ha |>.comp <| ContinuousMap.compStarAlgHom' R R <| ⟨_, continuous_id.subtype_map hs⟩ lemma cfcHomSuperset_continuous {a : A} (ha : p a) {s : Set R} (hs : spectrum R a ⊆ s) : Continuous (cfcHomSuperset ha hs) := (cfcHom_continuous ha).comp <| ContinuousMap.continuous_precomp _ lemma cfcHomSuperset_id {a : A} (ha : p a) {s : Set R} (hs : spectrum R a ⊆ s) : cfcHomSuperset ha hs (.restrict s <| .id R) = a := cfcHom_id ha end Superset
.lake/packages/mathlib/Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Unique.lean
import Mathlib.Analysis.Complex.Basic import Mathlib.Analysis.CStarAlgebra.ContinuousFunctionalCalculus.NonUnital import Mathlib.Topology.ContinuousMap.StoneWeierstrass /-! # Uniqueness of the continuous functional calculus Let `s : Set 𝕜` be compact where `𝕜` is either `ℝ` or `ℂ`. By the Stone-Weierstrass theorem, the (star) subalgebra generated by polynomial functions on `s` is dense in `C(s, 𝕜)`. Moreover, this star subalgebra is generated by `X : 𝕜[X]` (i.e., `ContinuousMap.restrict s (.id 𝕜)`) alone. Consequently, any continuous star `𝕜`-algebra homomorphism with domain `C(s, 𝕜)`, is uniquely determined by its value on `X : 𝕜[X]`. The same is true for `𝕜 := ℝ≥0`, so long as the algebra `A` is an `ℝ`-algebra, which we establish by upgrading a map `C((s : Set ℝ≥0), ℝ≥0) →⋆ₐ[ℝ≥0] A` to `C(((↑) '' s : Set ℝ), ℝ) →⋆ₐ[ℝ] A` in the natural way, and then applying the uniqueness for `ℝ`-algebra homomorphisms. This is the reason the `ContinuousMap.UniqueHom` class exists in the first place, as opposed to simply appealing directly to Stone-Weierstrass to prove `StarAlgHom.ext_continuousMap`. -/ open Topology section UniqueUnital section RCLike variable {𝕜 A : Type*} [RCLike 𝕜] instance (priority := 100) RCLike.instContinuousMapUniqueHom [TopologicalSpace A] [T2Space A] [Ring A] [StarRing A] [Algebra 𝕜 A] : ContinuousMap.UniqueHom 𝕜 A where eq_of_continuous_of_map_id s _ φ ψ hφ hψ h := ContinuousMap.starAlgHom_ext_map_X hφ hψ <| by convert h using 1 all_goals exact congr_arg _ (by ext; simp) instance Real.instContinuousMapUniqueHom [TopologicalSpace A] [T2Space A] [Ring A] [StarRing A] [Algebra ℝ A] : ContinuousMap.UniqueHom ℝ A := inferInstance instance Complex.instContinuousMapUniqueHom [TopologicalSpace A] [T2Space A] [Ring A] [StarRing A] [Algebra ℂ A] : ContinuousMap.UniqueHom ℂ A := inferInstance end RCLike section NNReal open NNReal variable {X : Type*} [TopologicalSpace X] namespace ContinuousMap /-- This map sends `f : C(X, ℝ)` to `Real.toNNReal ∘ f`, bundled as a continuous map `C(X, ℝ≥0)`. -/ noncomputable def toNNReal (f : C(X, ℝ)) : C(X, ℝ≥0) := .realToNNReal |>.comp f @[fun_prop] lemma continuous_toNNReal : Continuous (toNNReal (X := X)) := continuous_postcomp _ @[simp] lemma toNNReal_apply (f : C(X, ℝ)) (x : X) : f.toNNReal x = (f x).toNNReal := rfl lemma toNNReal_add_add_neg_add_neg_eq (f g : C(X, ℝ)) : (f + g).toNNReal + (-f).toNNReal + (-g).toNNReal = (-(f + g)).toNNReal + f.toNNReal + g.toNNReal := by ext x simp [max_neg_zero, -neg_add_rev] abel lemma toNNReal_mul_add_neg_mul_add_mul_neg_eq (f g : C(X, ℝ)) : (f * g).toNNReal + (-f).toNNReal * g.toNNReal + f.toNNReal * (-g).toNNReal = (-(f * g)).toNNReal + f.toNNReal * g.toNNReal + (-f).toNNReal * (-g).toNNReal := by ext x simp [max_neg_zero, add_mul, mul_add] abel @[simp] lemma toNNReal_algebraMap (r : ℝ≥0) : (algebraMap ℝ C(X, ℝ) r).toNNReal = algebraMap ℝ≥0 C(X, ℝ≥0) r := by ext; simp @[simp] lemma toNNReal_neg_algebraMap (r : ℝ≥0) : (- algebraMap ℝ C(X, ℝ) r).toNNReal = 0 := by ext; simp @[simp] lemma toNNReal_one : (1 : C(X, ℝ)).toNNReal = 1 := toNNReal_algebraMap 1 @[simp] lemma toNNReal_neg_one : (-1 : C(X, ℝ)).toNNReal = 0 := toNNReal_neg_algebraMap 1 end ContinuousMap variable {A : Type*} [Ring A] [StarRing A] [Algebra ℝ A] namespace StarAlgHom section IsTopologicalRing variable [TopologicalSpace A] [IsTopologicalRing A] /-- Given a star `ℝ≥0`-algebra homomorphism `φ` from `C(X, ℝ≥0)` into an `ℝ`-algebra `A`, this is the unique extension of `φ` from `C(X, ℝ)` to `A` as a star `ℝ`-algebra homomorphism. -/ @[simps] noncomputable def realContinuousMapOfNNReal (φ : C(X, ℝ≥0) →⋆ₐ[ℝ≥0] A) : C(X, ℝ) →⋆ₐ[ℝ] A where toFun f := φ f.toNNReal - φ (-f).toNNReal map_one' := by simp map_zero' := by simp map_mul' f g := by have := congr(φ $(f.toNNReal_mul_add_neg_mul_add_mul_neg_eq g)) simp only [map_add, map_mul, sub_mul, mul_sub] at this ⊢ rw [← sub_eq_zero] at this ⊢ convert this using 1 abel map_add' f g := by have := congr(φ $(f.toNNReal_add_add_neg_add_neg_eq g)) simp only [map_add] at this ⊢ rw [← sub_eq_zero] at this ⊢ convert this using 1 abel commutes' r := by obtain (hr | hr) := le_total 0 r · lift r to ℝ≥0 using hr simpa only [ContinuousMap.toNNReal_algebraMap, ContinuousMap.toNNReal_neg_algebraMap, map_zero, sub_zero] using AlgHomClass.commutes φ r · rw [← neg_neg r, ← map_neg, neg_neg (-r)] rw [← neg_nonneg] at hr lift -r to ℝ≥0 using hr with r simpa only [map_neg, ContinuousMap.toNNReal_neg_algebraMap, map_zero, ContinuousMap.toNNReal_algebraMap, zero_sub, neg_inj] using AlgHomClass.commutes φ r map_star' f := by simp only [star_trivial, star_sub, ← map_star] @[fun_prop] lemma continuous_realContinuousMapOfNNReal (φ : C(X, ℝ≥0) →⋆ₐ[ℝ≥0] A) (hφ : Continuous φ) : Continuous φ.realContinuousMapOfNNReal := by dsimp [realContinuousMapOfNNReal] fun_prop end IsTopologicalRing @[simp high] lemma realContinuousMapOfNNReal_apply_comp_toReal (φ : C(X, ℝ≥0) →⋆ₐ[ℝ≥0] A) (f : C(X, ℝ≥0)) : φ.realContinuousMapOfNNReal ((ContinuousMap.mk toReal continuous_coe).comp f) = φ f := by simp only [realContinuousMapOfNNReal_apply] convert_to φ f - φ 0 = φ f using 2 on_goal -1 => rw [map_zero, sub_zero] all_goals congr ext x simp lemma realContinuousMapOfNNReal_injective : Function.Injective (realContinuousMapOfNNReal (X := X) (A := A)) := by intro φ ψ h ext f simpa using congr($(h) ((ContinuousMap.mk toReal continuous_coe).comp f)) end StarAlgHom variable [TopologicalSpace A] [IsTopologicalRing A] instance NNReal.instContinuousMap.UniqueHom [T2Space A] : ContinuousMap.UniqueHom ℝ≥0 A where eq_of_continuous_of_map_id s hs φ ψ hφ hψ h := by let s' : Set ℝ := (↑) '' s let e : s ≃ₜ s' := { toFun := Subtype.map (↑) (by simp [s']) invFun := Subtype.map Real.toNNReal (by simp [s']) left_inv := fun _ ↦ by ext; simp right_inv := fun x ↦ by ext obtain ⟨y, -, hy⟩ := x.2 simpa using hy ▸ NNReal.coe_nonneg y continuous_toFun := continuous_coe.subtype_map (by simp [s']) continuous_invFun := continuous_real_toNNReal.subtype_map (by simp [s']) } have (ξ : C(s, ℝ≥0) →⋆ₐ[ℝ≥0] A) (hξ : Continuous ξ) : (let ξ' := ξ.realContinuousMapOfNNReal.comp <| ContinuousMap.compStarAlgHom' ℝ ℝ e Continuous ξ' ∧ ξ' (.restrict s' <| .id ℝ) = ξ (.restrict s <| .id ℝ≥0)) := by intro ξ' refine ⟨ξ.continuous_realContinuousMapOfNNReal hξ |>.comp <| ContinuousMap.continuous_precomp _, ?_⟩ exact ξ.realContinuousMapOfNNReal_apply_comp_toReal (.restrict s <| .id ℝ≥0) obtain ⟨hφ', hφ_id⟩ := this φ hφ obtain ⟨hψ', hψ_id⟩ := this ψ hψ have hs' : CompactSpace s' := e.compactSpace have h' := ContinuousMap.UniqueHom.eq_of_continuous_of_map_id s' _ _ hφ' hψ' (hφ_id ▸ hψ_id ▸ h) have h'' := congr($(h').comp <| ContinuousMap.compStarAlgHom' ℝ ℝ (e.symm : C(s', s))) have : (ContinuousMap.compStarAlgHom' ℝ ℝ (e : C(s, s'))).comp (ContinuousMap.compStarAlgHom' ℝ ℝ (e.symm : C(s', s))) = StarAlgHom.id _ _ := by ext1; simp simp only [StarAlgHom.comp_assoc, this, StarAlgHom.comp_id] at h'' exact StarAlgHom.realContinuousMapOfNNReal_injective h'' end NNReal end UniqueUnital section UniqueNonUnital section RCLike variable {𝕜 A : Type*} [RCLike 𝕜] open NonUnitalStarAlgebra in instance RCLike.uniqueNonUnitalContinuousFunctionalCalculus [TopologicalSpace A] [T2Space A] [NonUnitalRing A] [StarRing A] [Module 𝕜 A] [IsScalarTower 𝕜 A A] [SMulCommClass 𝕜 A A] : ContinuousMapZero.UniqueHom 𝕜 A where eq_of_continuous_of_map_id s hs h0 φ ψ hφ hψ h := by rw [DFunLike.ext'_iff, ← Set.eqOn_univ, ← (ContinuousMapZero.adjoin_id_dense _).closure_eq] refine Set.EqOn.closure (fun f hf ↦ ?_) hφ hψ rw [← NonUnitalStarAlgHom.mem_equalizer] apply adjoin_le ?_ hf rw [Set.singleton_subset_iff] exact h end RCLike section NNReal open NNReal variable {X : Type*} [TopologicalSpace X] [Zero X] namespace ContinuousMapZero /-- This map sends `f : C(X, ℝ)` to `Real.toNNReal ∘ f`, bundled as a continuous map `C(X, ℝ≥0)`. -/ noncomputable def toNNReal (f : C(X, ℝ)₀) : C(X, ℝ≥0)₀ := ⟨.realToNNReal |>.comp f, by simp⟩ @[simp] lemma toNNReal_apply (f : C(X, ℝ)₀) (x : X) : f.toNNReal x = Real.toNNReal (f x) := rfl @[fun_prop] lemma continuous_toNNReal : Continuous (toNNReal (X := X)) := by rw [continuous_induced_rng] convert_to Continuous (ContinuousMap.toNNReal ∘ ((↑) : C(X, ℝ)₀ → C(X, ℝ))) using 1 exact ContinuousMap.continuous_postcomp _ |>.comp continuous_induced_dom lemma toContinuousMapHom_toNNReal (f : C(X, ℝ)₀) : (toContinuousMapHom (X := X) (R := ℝ) f).toNNReal = toContinuousMapHom (X := X) (R := ℝ≥0) f.toNNReal := rfl @[simp] lemma toNNReal_smul (r : ℝ≥0) (f : C(X, ℝ)₀) : (r • f).toNNReal = r • f.toNNReal := by ext x by_cases! h : 0 ≤ f x · simpa [max_eq_left h, NNReal.smul_def] using mul_nonneg r.coe_nonneg h · simpa [max_eq_right h.le, NNReal.smul_def] using mul_nonpos_of_nonneg_of_nonpos r.coe_nonneg h.le @[simp] lemma toNNReal_neg_smul (r : ℝ≥0) (f : C(X, ℝ)₀) : (-(r • f)).toNNReal = r • (-f).toNNReal := by rw [NNReal.smul_def, ← smul_neg, ← NNReal.smul_def, toNNReal_smul] lemma toNNReal_mul_add_neg_mul_add_mul_neg_eq (f g : C(X, ℝ)₀) : ((f * g).toNNReal + (-f).toNNReal * g.toNNReal + f.toNNReal * (-g).toNNReal) = ((-(f * g)).toNNReal + f.toNNReal * g.toNNReal + (-f).toNNReal * (-g).toNNReal) := by apply toContinuousMap_injective simpa only [← toContinuousMapHom_apply, map_add, map_mul, map_neg, toContinuousMapHom_toNNReal] using (f : C(X, ℝ)).toNNReal_mul_add_neg_mul_add_mul_neg_eq g lemma toNNReal_add_add_neg_add_neg_eq (f g : C(X, ℝ)₀) : ((f + g).toNNReal + (-f).toNNReal + (-g).toNNReal) = ((-(f + g)).toNNReal + f.toNNReal + g.toNNReal) := by apply toContinuousMap_injective simpa only [← toContinuousMapHom_apply, map_add, map_mul, map_neg, toContinuousMapHom_toNNReal] using (f : C(X, ℝ)).toNNReal_add_add_neg_add_neg_eq g end ContinuousMapZero variable {A : Type*} [NonUnitalRing A] [StarRing A] [Module ℝ A] namespace NonUnitalStarAlgHom open ContinuousMapZero section IsTopologicalRing variable [TopologicalSpace A] [IsTopologicalRing A] /-- Given a non-unital star `ℝ≥0`-algebra homomorphism `φ` from `C(X, ℝ≥0)₀` into a non-unital `ℝ`-algebra `A`, this is the unique extension of `φ` from `C(X, ℝ)₀` to `A` as a non-unital star `ℝ`-algebra homomorphism. -/ @[simps] noncomputable def realContinuousMapZeroOfNNReal (φ : C(X, ℝ≥0)₀ →⋆ₙₐ[ℝ≥0] A) : C(X, ℝ)₀ →⋆ₙₐ[ℝ] A where toFun f := φ f.toNNReal - φ (-f).toNNReal map_zero' := by simp map_mul' f g := by have := congr(φ $(f.toNNReal_mul_add_neg_mul_add_mul_neg_eq g)) simp only [map_add, map_mul, sub_mul, mul_sub] at this ⊢ rw [← sub_eq_zero] at this ⊢ rw [← this] abel map_add' f g := by have := congr(φ $(f.toNNReal_add_add_neg_add_neg_eq g)) simp only [map_add] at this ⊢ rw [← sub_eq_zero] at this ⊢ rw [← this] abel map_smul' r f := by simp only [MonoidHom.id_apply] by_cases! hr : 0 ≤ r · lift r to ℝ≥0 using hr simp only [← smul_def, toNNReal_smul, map_smul, toNNReal_neg_smul, smul_sub] · rw [← neg_pos] at hr rw [← neg_smul] nth_rw 1 [← neg_neg r] nth_rw 3 [← neg_neg r] lift -r to ℝ≥0 using hr.le with r simp only [neg_smul, ← smul_def, toNNReal_neg_smul, map_smul, toNNReal_smul, smul_sub, sub_neg_eq_add] rw [sub_eq_add_neg, add_comm] map_star' f := by simp only [star_trivial, star_sub, ← map_star] @[fun_prop] lemma continuous_realContinuousMapZeroOfNNReal (φ : C(X, ℝ≥0)₀ →⋆ₙₐ[ℝ≥0] A) (hφ : Continuous φ) : Continuous φ.realContinuousMapZeroOfNNReal := by dsimp [realContinuousMapZeroOfNNReal] fun_prop end IsTopologicalRing @[simp high] lemma realContinuousMapZeroOfNNReal_apply_comp_toReal (φ : C(X, ℝ≥0)₀ →⋆ₙₐ[ℝ≥0] A) (f : C(X, ℝ≥0)₀) : φ.realContinuousMapZeroOfNNReal ((ContinuousMapZero.mk ⟨toReal, continuous_coe⟩ rfl).comp f) = φ f := by simp only [realContinuousMapZeroOfNNReal_apply] convert_to φ f - φ 0 = φ f using 2 on_goal -1 => rw [map_zero, sub_zero] all_goals congr ext x simp lemma realContinuousMapZeroOfNNReal_injective : Function.Injective (realContinuousMapZeroOfNNReal (X := X) (A := A)) := by intro φ ψ h ext f simpa using congr($(h) ((ContinuousMapZero.mk ⟨toReal, continuous_coe⟩ rfl).comp f)) end NonUnitalStarAlgHom open ContinuousMapZero instance NNReal.instContinuousMapZero.UniqueHom [TopologicalSpace A] [IsTopologicalRing A] [IsScalarTower ℝ A A] [SMulCommClass ℝ A A] [T2Space A] : ContinuousMapZero.UniqueHom ℝ≥0 A where eq_of_continuous_of_map_id s hs h0 φ ψ hφ hψ h := by let s' : Set ℝ := (↑) '' s let e : s ≃ₜ s' := { toFun := Subtype.map (↑) (by simp [s']) invFun := Subtype.map Real.toNNReal (by simp [s']) left_inv := fun _ ↦ by ext; simp right_inv := fun x ↦ by ext obtain ⟨y, -, hy⟩ := x.2 simpa using hy ▸ NNReal.coe_nonneg y continuous_toFun := continuous_coe.subtype_map (by simp [s']) continuous_invFun := continuous_real_toNNReal.subtype_map (by simp [s']) } have : Fact (0 ∈ s') := ⟨0, Fact.out, coe_zero⟩ have e0 : e 0 = 0 := by ext; simp [e]; rfl have e0' : e.symm 0 = 0 := by simpa only [Homeomorph.symm_apply_apply] using congr(e.symm $(e0)).symm have (ξ : C(s, ℝ≥0)₀ →⋆ₙₐ[ℝ≥0] A) (hξ : Continuous ξ) : (let ξ' := ξ.realContinuousMapZeroOfNNReal.comp <| ContinuousMapZero.nonUnitalStarAlgHom_precomp ℝ ⟨e, e0⟩; Continuous ξ' ∧ ξ' (.id s') = ξ (.id s)) := by intro ξ' refine ⟨ξ.continuous_realContinuousMapZeroOfNNReal hξ |>.comp <| ?_, ?_⟩ · rw [continuous_induced_rng] exact ContinuousMap.continuous_precomp _ |>.comp continuous_induced_dom · exact ξ.realContinuousMapZeroOfNNReal_apply_comp_toReal (.id _) obtain ⟨hφ', hφ_id⟩ := this φ hφ obtain ⟨hψ', hψ_id⟩ := this ψ hψ have hs' : CompactSpace s' := e.compactSpace have : ContinuousMapZero.UniqueHom ℝ A := inferInstance have h' := ContinuousMapZero.UniqueHom.eq_of_continuous_of_map_id s' _ _ hφ' hψ' (hφ_id ▸ hψ_id ▸ h) have h'' := congr($(h').comp <| ContinuousMapZero.nonUnitalStarAlgHom_precomp ℝ ⟨(e.symm : C(s', s)), e0'⟩) have : (ContinuousMapZero.nonUnitalStarAlgHom_precomp ℝ ⟨(e : C(s, s')), e0⟩).comp (ContinuousMapZero.nonUnitalStarAlgHom_precomp ℝ ⟨(e.symm : C(s', s)), e0'⟩) = NonUnitalStarAlgHom.id _ _ := by ext; simp simp only [NonUnitalStarAlgHom.comp_assoc, this, NonUnitalStarAlgHom.comp_id] at h'' exact NonUnitalStarAlgHom.realContinuousMapZeroOfNNReal_injective h'' end NNReal end UniqueNonUnital section NonUnitalStarAlgHom open scoped ContinuousMapZero NonUnitalContinuousFunctionalCalculus variable {F R S A B : Type*} {p : A → Prop} {q : B → Prop} [CommSemiring R] [Nontrivial R] [StarRing R] [MetricSpace R] [IsTopologicalSemiring R] [ContinuousStar R] [CommRing S] [Algebra R S] [NonUnitalRing A] [StarRing A] [TopologicalSpace A] [Module R A] [IsScalarTower R A A] [SMulCommClass R A A] [NonUnitalRing B] [StarRing B] [TopologicalSpace B] [Module R B] [IsScalarTower R B B] [SMulCommClass R B B] [Module S A] [Module S B] [IsScalarTower R S A] [IsScalarTower R S B] [NonUnitalContinuousFunctionalCalculus R A p] [NonUnitalContinuousFunctionalCalculus R B q] [ContinuousMapZero.UniqueHom R B] [FunLike F A B] [NonUnitalAlgHomClass F S A B] [StarHomClass F A B] include S in /-- Non-unital star algebra homomorphisms commute with the non-unital continuous functional calculus. -/ lemma NonUnitalStarAlgHomClass.map_cfcₙ (φ : F) (f : R → R) (a : A) (hf : ContinuousOn f (quasispectrum R a) := by cfc_cont_tac) (hf₀ : f 0 = 0 := by cfc_zero_tac) (hφ : Continuous φ := by fun_prop) (ha : p a := by cfc_tac) (hφa : q (φ a) := by cfc_tac) : φ (cfcₙ f a) = cfcₙ f (φ a) := by let ψ : A →⋆ₙₐ[R] B := (φ : A →⋆ₙₐ[S] B).restrictScalars R have : Continuous ψ := hφ have h_spec := NonUnitalAlgHom.quasispectrum_apply_subset' (R := R) S φ a have hψa : q (ψ a) := hφa let ι : C(quasispectrum R (ψ a), quasispectrum R a)₀ := ⟨⟨Set.inclusion h_spec, continuous_id.subtype_map h_spec⟩, rfl⟩ suffices ψ.comp (cfcₙHom ha) = (cfcₙHom hψa).comp (ContinuousMapZero.nonUnitalStarAlgHom_precomp R ι) by have hf' : ContinuousOn f (quasispectrum R (ψ a)) := hf.mono h_spec rw [cfcₙ_apply .., cfcₙ_apply ..] exact DFunLike.congr_fun this _ refine ContinuousMapZero.UniqueHom.eq_of_continuous_of_map_id _ _ _ ?_ ?_ ?apply_id case apply_id => trans cfcₙHom hψa (.id (quasispectrum R (ψ a))) · simp [cfcₙHom_id] · congr all_goals dsimp [ContinuousMapZero.nonUnitalStarAlgHom_precomp] fun_prop /-- Non-unital star algebra homomorphisms commute with the non-unital continuous functional calculus. This version is specialized to `A →⋆ₙₐ[S] B` to allow for dot notation. -/ lemma NonUnitalStarAlgHom.map_cfcₙ (φ : A →⋆ₙₐ[S] B) (f : R → R) (a : A) (hf : ContinuousOn f (quasispectrum R a) := by cfc_cont_tac) (hf₀ : f 0 = 0 := by cfc_zero_tac) (hφ : Continuous φ := by fun_prop) (ha : p a := by cfc_tac) (hφa : q (φ a) := by cfc_tac) : φ (cfcₙ f a) = cfcₙ f (φ a) := NonUnitalStarAlgHomClass.map_cfcₙ φ f a end NonUnitalStarAlgHom section StarAlgHom open scoped ContinuousFunctionalCalculus variable {F R S A B : Type*} {p : A → Prop} {q : B → Prop} [CommSemiring R] [StarRing R] [MetricSpace R] [IsTopologicalSemiring R] [ContinuousStar R] [Ring A] [StarRing A] [TopologicalSpace A] [Algebra R A] [Ring B] [StarRing B] [TopologicalSpace B] [Algebra R B] [CommSemiring S] [Algebra R S] [Algebra S A] [Algebra S B] [IsScalarTower R S A] [IsScalarTower R S B] [ContinuousFunctionalCalculus R A p] [ContinuousFunctionalCalculus R B q] [ContinuousMap.UniqueHom R B] [FunLike F A B] [AlgHomClass F S A B] [StarHomClass F A B] include S in /-- Star algebra homomorphisms commute with the continuous functional calculus. -/ lemma StarAlgHomClass.map_cfc (φ : F) (f : R → R) (a : A) (hf : ContinuousOn f (spectrum R a) := by cfc_cont_tac) (hφ : Continuous φ := by fun_prop) (ha : p a := by cfc_tac) (hφa : q (φ a) := by cfc_tac) : φ (cfc f a) = cfc f (φ a) := by let ψ : A →⋆ₐ[R] B := (φ : A →⋆ₐ[S] B).restrictScalars R have : Continuous ψ := hφ have h_spec := AlgHom.spectrum_apply_subset ψ a have hψa : q (ψ a) := hφa let ι : C(spectrum R (ψ a), spectrum R a) := ⟨Set.inclusion h_spec, continuous_id.subtype_map h_spec⟩ suffices ψ.comp (cfcHom ha) = (cfcHom hψa).comp (ContinuousMap.compStarAlgHom' R R ι) by have hf' : ContinuousOn f (spectrum R (ψ a)) := hf.mono h_spec rw [cfc_apply .., cfc_apply ..] congrm($(this) ⟨_, hf.restrict⟩) refine ContinuousMap.UniqueHom.eq_of_continuous_of_map_id _ _ _ ?_ ?_ ?apply_id case apply_id => trans cfcHom hψa (.restrict (spectrum R (ψ a)) (.id R)) · simp [cfcHom_id] · congr all_goals dsimp [ContinuousMap.compStarAlgHom'] fun_prop /-- Star algebra homomorphisms commute with the continuous functional calculus. This version is specialized to `A →⋆ₐ[S] B` to allow for dot notation. -/ lemma StarAlgHom.map_cfc (φ : A →⋆ₐ[S] B) (f : R → R) (a : A) (hf : ContinuousOn f (spectrum R a) := by cfc_cont_tac) (hφ : Continuous φ := by fun_prop) (ha : p a := by cfc_tac) (hφa : q (φ a) := by cfc_tac) : φ (cfc f a) = cfc f (φ a) := StarAlgHomClass.map_cfc φ f a end StarAlgHom
.lake/packages/mathlib/Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/NonUnital.lean
import Mathlib.Algebra.Algebra.Spectrum.Quasispectrum import Mathlib.Topology.ContinuousMap.Compact import Mathlib.Analysis.CStarAlgebra.ContinuousFunctionalCalculus.Unital import Mathlib.Topology.UniformSpace.CompactConvergence /-! # The continuous functional calculus for non-unital algebras This file defines a generic API for the *continuous functional calculus* in *non-unital* algebras which is suitable in a wide range of settings. The design is intended to match as closely as possible that for unital algebras in `Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Unital.lean`. Changes to either file should be mirrored in its counterpart whenever possible. The underlying reasons for the design decisions in the unital case apply equally in the non-unital case. See the module documentation in that file for more information. A continuous functional calculus for an element `a : A` in a non-unital topological `R`-algebra is a continuous extension of the polynomial functional calculus (i.e., `Polynomial.aeval`) for polynomials with no constant term to continuous `R`-valued functions on `quasispectrum R a` which vanish at zero. More precisely, it is a continuous star algebra homomorphism `C(quasispectrum R a, R)₀ →⋆ₙₐ[R] A` that sends `(ContinuousMap.id R).restrict (quasispectrum R a)` to `a`. In all cases of interest (e.g., when `quasispectrum R a` is compact and `R` is `ℝ≥0`, `ℝ`, or `ℂ`), this is sufficient to uniquely determine the continuous functional calculus which is encoded in the `ContinuousMapZero.UniqueHom` class. ## Main declarations + `NonUnitalContinuousFunctionalCalculus R A (p : A → Prop)`: a class stating that every `a : A` satisfying `p a` has a non-unital star algebra homomorphism from the continuous `R`-valued functions on the `R`-quasispectrum of `a` vanishing at zero into the algebra `A`. This map is a closed embedding, and satisfies the **spectral mapping theorem**. + `cfcₙHom : p a → C(quasispectrum R a, R)₀ →⋆ₐ[R] A`: the underlying non-unital star algebra homomorphism for an element satisfying property `p`. + `cfcₙ : (R → R) → A → A`: an unbundled version of `cfcₙHom` which takes the junk value `0` when `cfcₙHom` is not defined. ## Main theorems + `cfcₙ_comp : cfcₙ (x ↦ g (f x)) a = cfcₙ g (cfcₙ f a)` -/ local notation "σₙ" => quasispectrum open Topology ContinuousMapZero /-- A non-unital star `R`-algebra `A` has a *continuous functional calculus* for elements satisfying the property `p : A → Prop` if + for every such element `a : A` there is a non-unital star algebra homomorphism `cfcₙHom : C(quasispectrum R a, R)₀ →⋆ₙₐ[R] A` sending the (restriction of) the identity map to `a`. + `cfcₙHom` is a closed embedding for which the quasispectrum of the image of function `f` is its range. + `cfcₙHom` preserves the property `p`. The property `p` is marked as an `outParam` so that the user need not specify it. In practice, + for `R := ℂ`, we choose `p := IsStarNormal`, + for `R := ℝ`, we choose `p := IsSelfAdjoint`, + for `R := ℝ≥0`, we choose `p := (0 ≤ ·)`. Instead of directly providing the data we opt instead for a `Prop` class. In all relevant cases, the continuous functional calculus is uniquely determined, and utilizing this approach prevents diamonds or problems arising from multiple instances. -/ class NonUnitalContinuousFunctionalCalculus (R A : Type*) (p : outParam (A → Prop)) [CommSemiring R] [Nontrivial R] [StarRing R] [MetricSpace R] [IsTopologicalSemiring R] [ContinuousStar R] [NonUnitalRing A] [StarRing A] [TopologicalSpace A] [Module R A] [IsScalarTower R A A] [SMulCommClass R A A] : Prop where predicate_zero : p 0 [compactSpace_quasispectrum : ∀ a : A, CompactSpace (σₙ R a)] exists_cfc_of_predicate : ∀ a, p a → ∃ φ : C(σₙ R a, R)₀ →⋆ₙₐ[R] A, IsClosedEmbedding φ ∧ φ ⟨(ContinuousMap.id R).restrict <| σₙ R a, rfl⟩ = a ∧ (∀ f, σₙ R (φ f) = Set.range f) ∧ ∀ f, p (φ f) -- this instance should not be activated everywhere but it is useful when developing generic API -- for the continuous functional calculus scoped[NonUnitalContinuousFunctionalCalculus] attribute [instance] NonUnitalContinuousFunctionalCalculus.compactSpace_quasispectrum /-- A class guaranteeing that the non-unital continuous functional calculus is uniquely determined by the properties that it is a continuous non-unital star algebra homomorphism mapping the (restriction of) the identity to `a`. This is the necessary tool used to establish `cfcₙHom_comp` and the more common variant `cfcₙ_comp`. This class will have instances in each of the common cases `ℂ`, `ℝ` and `ℝ≥0` as a consequence of the Stone-Weierstrass theorem. -/ class ContinuousMapZero.UniqueHom (R A : Type*) [CommSemiring R] [StarRing R] [MetricSpace R] [IsTopologicalSemiring R] [ContinuousStar R] [NonUnitalRing A] [StarRing A] [TopologicalSpace A] [Module R A] [IsScalarTower R A A] [SMulCommClass R A A] : Prop where eq_of_continuous_of_map_id (s : Set R) [CompactSpace s] [Fact (0 ∈ s)] (φ ψ : C(s, R)₀ →⋆ₙₐ[R] A) (hφ : Continuous φ) (hψ : Continuous ψ) (h : φ (.id s) = ψ (.id s)) : φ = ψ instance {R A : Type*} [CommSemiring R] [NonUnitalRing A] [Module R A] [Nontrivial R] (a : A) : Fact (0 ∈ σₙ R a) := ⟨quasispectrum.zero_mem R a⟩ section Main variable {R A : Type*} {p : A → Prop} [CommSemiring R] [Nontrivial R] [StarRing R] [MetricSpace R] variable [IsTopologicalSemiring R] [ContinuousStar R] [NonUnitalRing A] [StarRing A] variable [TopologicalSpace A] [Module R A] [IsScalarTower R A A] [SMulCommClass R A A] variable [instCFCₙ : NonUnitalContinuousFunctionalCalculus R A p] include instCFCₙ in lemma NonUnitalContinuousFunctionalCalculus.isCompact_quasispectrum (a : A) : IsCompact (σₙ R a) := isCompact_iff_compactSpace.mpr inferInstance lemma NonUnitalStarAlgHom.ext_continuousMap [UniqueHom R A] (a : A) [CompactSpace (σₙ R a)] (φ ψ : C(σₙ R a, R)₀ →⋆ₙₐ[R] A) (hφ : Continuous φ) (hψ : Continuous ψ) (h : φ (.id (σₙ R a)) = ψ (.id (σₙ R a))) : φ = ψ := UniqueHom.eq_of_continuous_of_map_id _ φ ψ hφ hψ h section cfcₙHom variable {a : A} (ha : p a) /-- The non-unital star algebra homomorphism underlying a instance of the continuous functional calculus for non-unital algebras; a version for continuous functions on the quasispectrum. In this case, the user must supply the fact that `a` satisfies the predicate `p`. While `NonUnitalContinuousFunctionalCalculus` is stated in terms of these homomorphisms, in practice the user should instead prefer `cfcₙ` over `cfcₙHom`. -/ noncomputable def cfcₙHom : C(σₙ R a, R)₀ →⋆ₙₐ[R] A := (NonUnitalContinuousFunctionalCalculus.exists_cfc_of_predicate a ha).choose lemma cfcₙHom_isClosedEmbedding : IsClosedEmbedding <| (cfcₙHom ha : C(σₙ R a, R)₀ →⋆ₙₐ[R] A) := (NonUnitalContinuousFunctionalCalculus.exists_cfc_of_predicate a ha).choose_spec.1 @[fun_prop] lemma cfcₙHom_continuous : Continuous (cfcₙHom ha : C(σₙ R a, R)₀ →⋆ₙₐ[R] A) := cfcₙHom_isClosedEmbedding ha |>.continuous lemma cfcₙHom_id : cfcₙHom ha (.id (σₙ R a)) = a := (NonUnitalContinuousFunctionalCalculus.exists_cfc_of_predicate a ha).choose_spec.2.1 /-- The **spectral mapping theorem** for the non-unital continuous functional calculus. -/ lemma cfcₙHom_map_quasispectrum (f : C(σₙ R a, R)₀) : σₙ R (cfcₙHom ha f) = Set.range f := (NonUnitalContinuousFunctionalCalculus.exists_cfc_of_predicate a ha).choose_spec.2.2.1 f lemma cfcₙHom_predicate (f : C(σₙ R a, R)₀) : p (cfcₙHom ha f) := (NonUnitalContinuousFunctionalCalculus.exists_cfc_of_predicate a ha).choose_spec.2.2.2 f open scoped NonUnitalContinuousFunctionalCalculus in lemma cfcₙHom_eq_of_continuous_of_map_id [UniqueHom R A] (φ : C(σₙ R a, R)₀ →⋆ₙₐ[R] A) (hφ₁ : Continuous φ) (hφ₂ : φ (.id _) = a) : cfcₙHom ha = φ := (cfcₙHom ha).ext_continuousMap a φ (cfcₙHom_isClosedEmbedding ha).continuous hφ₁ <| by rw [cfcₙHom_id ha, hφ₂] theorem cfcₙHom_comp [UniqueHom R A] (f : C(σₙ R a, R)₀) (f' : C(σₙ R a, σₙ R (cfcₙHom ha f))₀) (hff' : ∀ x, f x = f' x) (g : C(σₙ R (cfcₙHom ha f), R)₀) : cfcₙHom ha (g.comp f') = cfcₙHom (cfcₙHom_predicate ha f) g := by let ψ : C(σₙ R (cfcₙHom ha f), R)₀ →⋆ₙₐ[R] C(σₙ R a, R)₀ := { toFun := (ContinuousMapZero.comp · f') map_smul' := fun _ _ ↦ rfl map_add' := fun _ _ ↦ rfl map_mul' := fun _ _ ↦ rfl map_zero' := rfl map_star' := fun _ ↦ rfl } let φ : C(σₙ R (cfcₙHom ha f), R)₀ →⋆ₙₐ[R] A := (cfcₙHom ha).comp ψ suffices cfcₙHom (cfcₙHom_predicate ha f) = φ from DFunLike.congr_fun this.symm g refine cfcₙHom_eq_of_continuous_of_map_id (cfcₙHom_predicate ha f) φ ?_ ?_ · refine (cfcₙHom_isClosedEmbedding ha).continuous.comp <| continuous_induced_rng.mpr ?_ exact f'.toContinuousMap.continuous_precomp.comp continuous_induced_dom · simp only [φ, ψ, NonUnitalStarAlgHom.comp_apply, NonUnitalStarAlgHom.coe_mk', NonUnitalAlgHom.coe_mk] congr ext x simp [hff'] end cfcₙHom section cfcₙL /-- `cfcₙHom` bundled as a continuous linear map. -/ @[simps apply] noncomputable def cfcₙL {a : A} (ha : p a) : C(σₙ R a, R)₀ →L[R] A := { cfcₙHom ha with toFun := cfcₙHom ha map_smul' := map_smul _ cont := (cfcₙHom_isClosedEmbedding ha).continuous } end cfcₙL section CFCn open Classical in /-- This is the *continuous functional calculus* of an element `a : A` in a non-unital algebra applied to bare functions. When either `a` does not satisfy the predicate `p` (i.e., `a` is not `IsStarNormal`, `IsSelfAdjoint`, or `0 ≤ a` when `R` is `ℂ`, `ℝ`, or `ℝ≥0`, respectively), or when `f : R → R` is not continuous on the quasispectrum of `a` or `f 0 ≠ 0`, then `cfcₙ f a` returns the junk value `0`. This is the primary declaration intended for widespread use of the continuous functional calculus for non-unital algebras, and all the API applies to this declaration. For more information, see the module documentation for `Analysis.CStarAlgebra.ContinuousFunctionalCalculus.Unital`. -/ noncomputable irreducible_def cfcₙ (f : R → R) (a : A) : A := if h : p a ∧ ContinuousOn f (σₙ R a) ∧ f 0 = 0 then cfcₙHom h.1 ⟨⟨_, h.2.1.restrict⟩, h.2.2⟩ else 0 variable (f g : R → R) (a : A) variable (hf : ContinuousOn f (σₙ R a) := by cfc_cont_tac) (hf0 : f 0 = 0 := by cfc_zero_tac) variable (hg : ContinuousOn g (σₙ R a) := by cfc_cont_tac) (hg0 : g 0 = 0 := by cfc_zero_tac) variable (ha : p a := by cfc_tac) lemma cfcₙ_apply : cfcₙ f a = cfcₙHom (a := a) ha ⟨⟨_, hf.restrict⟩, hf0⟩ := by rw [cfcₙ_def, dif_pos ⟨ha, hf, hf0⟩] lemma cfcₙ_apply_pi {ι : Type*} (f : ι → R → R) (a : A) (ha := by cfc_tac) (hf : ∀ i, ContinuousOn (f i) (σₙ R a) := by cfc_cont_tac) (hf0 : ∀ i, f i 0 = 0 := by cfc_zero_tac) : (fun i => cfcₙ (f i) a) = (fun i => cfcₙHom (a := a) ha ⟨⟨_, (hf i).restrict⟩, hf0 i⟩) := by ext i simp only [cfcₙ_apply (f i) a (hf i) (hf0 i)] lemma cfcₙ_apply_of_not_and_and {f : R → R} (a : A) (ha : ¬ (p a ∧ ContinuousOn f (σₙ R a) ∧ f 0 = 0)) : cfcₙ f a = 0 := by rw [cfcₙ_def, dif_neg ha] lemma cfcₙ_apply_of_not_predicate {f : R → R} (a : A) (ha : ¬ p a) : cfcₙ f a = 0 := by rw [cfcₙ_def, dif_neg (not_and_of_not_left _ ha)] lemma cfcₙ_apply_of_not_continuousOn {f : R → R} (a : A) (hf : ¬ ContinuousOn f (σₙ R a)) : cfcₙ f a = 0 := by rw [cfcₙ_def, dif_neg (not_and_of_not_right _ (not_and_of_not_left _ hf))] lemma cfcₙ_apply_of_not_map_zero {f : R → R} (a : A) (hf : ¬ f 0 = 0) : cfcₙ f a = 0 := by rw [cfcₙ_def, dif_neg (not_and_of_not_right _ (not_and_of_not_right _ hf))] lemma cfcₙHom_eq_cfcₙ_extend {a : A} (g : R → R) (ha : p a) (f : C(σₙ R a, R)₀) : cfcₙHom ha f = cfcₙ (Function.extend Subtype.val f g) a := by have h : f = (σₙ R a).restrict (Function.extend Subtype.val f g) := by ext; simp have hg : ContinuousOn (Function.extend Subtype.val f g) (σₙ R a) := continuousOn_iff_continuous_restrict.mpr <| h ▸ map_continuous f have hg0 : (Function.extend Subtype.val f g) 0 = 0 := by rw [← quasispectrum.coe_zero (R := R) a, Subtype.val_injective.extend_apply] exact map_zero f rw [cfcₙ_apply ..] congr! lemma cfcₙ_eq_cfcₙL {a : A} {f : R → R} (ha : p a) (hf : ContinuousOn f (σₙ R a)) (hf0 : f 0 = 0) : cfcₙ f a = cfcₙL ha ⟨⟨_, hf.restrict⟩, hf0⟩ := by rw [cfcₙ_def, dif_pos ⟨ha, hf, hf0⟩, cfcₙL_apply] /-- A version of `cfcₙ_apply` in terms of `ContinuousMapZero.mkD` -/ lemma cfcₙ_apply_mkD : cfcₙ f a = cfcₙHom (a := a) ha (mkD ((quasispectrum R a).restrict f) 0) := by by_cases f_cont : ContinuousOn f (quasispectrum R a) · by_cases f_zero : f 0 = 0 · rw [cfcₙ_apply f a, mkD_of_continuousOn f_cont f_zero] · rw [cfcₙ_apply_of_not_map_zero a f_zero, mkD_of_not_zero, map_zero] exact f_zero · rw [cfcₙ_apply_of_not_continuousOn a f_cont, mkD_of_not_continuousOn f_cont, map_zero] /-- A version of `cfcₙ_eq_cfcₙL` in terms of `ContinuousMapZero.mkD` -/ lemma cfcₙ_eq_cfcₙL_mkD : cfcₙ f a = cfcₙL (a := a) ha (mkD ((quasispectrum R a).restrict f) 0) := cfcₙ_apply_mkD _ _ lemma cfcₙ_cases (P : A → Prop) (a : A) (f : R → R) (h₀ : P 0) (haf : ∀ (hf : ContinuousOn f (σₙ R a)) h0 ha, P (cfcₙHom ha ⟨⟨_, hf.restrict⟩, h0⟩)) : P (cfcₙ f a) := by by_cases h : ContinuousOn f (σₙ R a) ∧ f 0 = 0 ∧ p a · rw [cfcₙ_apply f a h.1 h.2.1 h.2.2] exact haf h.1 h.2.1 h.2.2 · simp only [not_and_or] at h obtain (h | h | h) := h · rwa [cfcₙ_apply_of_not_continuousOn _ h] · rwa [cfcₙ_apply_of_not_map_zero _ h] · rwa [cfcₙ_apply_of_not_predicate _ h] lemma cfcₙ_commute_cfcₙ (f g : R → R) (a : A) : Commute (cfcₙ f a) (cfcₙ g a) := by refine cfcₙ_cases (fun x ↦ Commute x (cfcₙ g a)) a f (by simp) fun hf hf0 ha ↦ ?_ refine cfcₙ_cases (fun x ↦ Commute _ x) a g (by simp) fun hg hg0 _ ↦ ?_ exact Commute.all _ _ |>.map _ variable (R) in include ha in lemma cfcₙ_id : cfcₙ (id : R → R) a = a := cfcₙ_apply (id : R → R) a ▸ cfcₙHom_id (p := p) ha variable (R) in include ha in lemma cfcₙ_id' : cfcₙ (fun x : R ↦ x) a = a := cfcₙ_id R a include ha hf hf0 in /-- The **spectral mapping theorem** for the non-unital continuous functional calculus. -/ lemma cfcₙ_map_quasispectrum : σₙ R (cfcₙ f a) = f '' σₙ R a := by simp [cfcₙ_apply f a, cfcₙHom_map_quasispectrum (p := p)] variable (R) in include R in lemma cfcₙ_predicate_zero : p 0 := NonUnitalContinuousFunctionalCalculus.predicate_zero (R := R) lemma cfcₙ_predicate (f : R → R) (a : A) : p (cfcₙ f a) := cfcₙ_cases p a f (cfcₙ_predicate_zero R) fun _ _ _ ↦ cfcₙHom_predicate .. lemma cfcₙ_congr {f g : R → R} {a : A} (hfg : (σₙ R a).EqOn f g) : cfcₙ f a = cfcₙ g a := by by_cases h : p a ∧ ContinuousOn g (σₙ R a) ∧ g 0 = 0 · rw [cfcₙ_apply f a (h.2.1.congr hfg) (hfg (quasispectrum.zero_mem R a) ▸ h.2.2) h.1, cfcₙ_apply g a h.2.1 h.2.2 h.1] congr 3 exact Set.restrict_eq_iff.mpr hfg · simp only [not_and_or] at h obtain (ha | hg | h0) := h · simp [cfcₙ_apply_of_not_predicate a ha] · rw [cfcₙ_apply_of_not_continuousOn a hg, cfcₙ_apply_of_not_continuousOn] exact fun hf ↦ hg (hf.congr hfg.symm) · rw [cfcₙ_apply_of_not_map_zero a h0, cfcₙ_apply_of_not_map_zero] exact fun hf ↦ h0 (hfg (quasispectrum.zero_mem R a) ▸ hf) lemma eqOn_of_cfcₙ_eq_cfcₙ {f g : R → R} {a : A} (h : cfcₙ f a = cfcₙ g a) (ha : p a := by cfc_tac) (hf : ContinuousOn f (σₙ R a) := by cfc_cont_tac) (hf0 : f 0 = 0 := by cfc_zero_tac) (hg : ContinuousOn g (σₙ R a) := by cfc_cont_tac) (hg0 : g 0 = 0 := by cfc_zero_tac) : (σₙ R a).EqOn f g := by rw [cfcₙ_apply f a, cfcₙ_apply g a] at h have := (cfcₙHom_isClosedEmbedding (show p a from ha) (R := R)).injective h intro x hx congrm($(this) ⟨x, hx⟩) lemma cfcₙ_eq_cfcₙ_iff_eqOn {f g : R → R} {a : A} (ha : p a := by cfc_tac) (hf : ContinuousOn f (σₙ R a) := by cfc_cont_tac) (hf0 : f 0 = 0 := by cfc_zero_tac) (hg : ContinuousOn g (σₙ R a) := by cfc_cont_tac) (hg0 : g 0 = 0 := by cfc_zero_tac) : cfcₙ f a = cfcₙ g a ↔ (σₙ R a).EqOn f g := ⟨eqOn_of_cfcₙ_eq_cfcₙ, cfcₙ_congr⟩ variable (R) @[simp] lemma cfcₙ_zero : cfcₙ (0 : R → R) a = 0 := by by_cases ha : p a · exact cfcₙ_apply (0 : R → R) a ▸ map_zero (cfcₙHom ha) · rw [cfcₙ_apply_of_not_predicate a ha] @[simp] lemma cfcₙ_const_zero : cfcₙ (fun _ : R ↦ 0) a = 0 := cfcₙ_zero R a variable {R} include hf hf0 hg hg0 in lemma cfcₙ_mul : cfcₙ (fun x ↦ f x * g x) a = cfcₙ f a * cfcₙ g a := by by_cases ha : p a · rw [cfcₙ_apply f a, cfcₙ_apply g a, ← map_mul, cfcₙ_apply _ a] congr · simp [cfcₙ_apply_of_not_predicate a ha] include hf hf0 hg hg0 in lemma cfcₙ_add : cfcₙ (fun x ↦ f x + g x) a = cfcₙ f a + cfcₙ g a := by by_cases ha : p a · rw [cfcₙ_apply f a, cfcₙ_apply g a, cfcₙ_apply _ a] simp_rw [← map_add] congr · simp [cfcₙ_apply_of_not_predicate a ha] open Finset in lemma cfcₙ_sum {ι : Type*} (f : ι → R → R) (a : A) (s : Finset ι) (hf : ∀ i ∈ s, ContinuousOn (f i) (σₙ R a) := by cfc_cont_tac) (hf0 : ∀ i ∈ s, f i 0 = 0 := by cfc_zero_tac) : cfcₙ (∑ i ∈ s, f i) a = ∑ i ∈ s, cfcₙ (f i) a := by by_cases ha : p a · have hsum : s.sum f = fun z => ∑ i ∈ s, f i z := by ext; simp have hf' : ContinuousOn (∑ i : s, f i) (σₙ R a) := by rw [sum_coe_sort s, hsum] exact continuousOn_finset_sum s fun i hi => hf i hi rw [← sum_coe_sort s, ← sum_coe_sort s] rw [cfcₙ_apply_pi _ a ha (fun ⟨i, hi⟩ => hf i hi), ← map_sum, cfcₙ_apply _ a hf'] congr 1 ext simp · simp [cfcₙ_apply_of_not_predicate a ha] open Finset in lemma cfcₙ_sum_univ {ι : Type*} [Fintype ι] (f : ι → R → R) (a : A) (hf : ∀ i, ContinuousOn (f i) (σₙ R a) := by cfc_cont_tac) (hf0 : ∀ i, f i 0 = 0 := by cfc_zero_tac) : cfcₙ (∑ i, f i) a = ∑ i, cfcₙ (f i) a := cfcₙ_sum f a _ (fun i _ ↦ hf i) (fun i _ ↦ hf0 i) lemma cfcₙ_smul {S : Type*} [SMulZeroClass S R] [ContinuousConstSMul S R] [SMulZeroClass S A] [IsScalarTower S R A] [IsScalarTower S R (R → R)] (s : S) (f : R → R) (a : A) (hf : ContinuousOn f (σₙ R a) := by cfc_cont_tac) (h0 : f 0 = 0 := by cfc_zero_tac) : cfcₙ (fun x ↦ s • f x) a = s • cfcₙ f a := by by_cases ha : p a · rw [cfcₙ_apply f a, cfcₙ_apply _ a] simp_rw [← Pi.smul_def, ← smul_one_smul R s _] rw [← map_smul] congr · simp [cfcₙ_apply_of_not_predicate a ha] lemma cfcₙ_const_mul (r : R) (f : R → R) (a : A) (hf : ContinuousOn f (σₙ R a) := by cfc_cont_tac) (h0 : f 0 = 0 := by cfc_zero_tac) : cfcₙ (fun x ↦ r * f x) a = r • cfcₙ f a := cfcₙ_smul r f a lemma cfcₙ_star : cfcₙ (fun x ↦ star (f x)) a = star (cfcₙ f a) := by by_cases h : p a ∧ ContinuousOn f (σₙ R a) ∧ f 0 = 0 · obtain ⟨ha, hf, h0⟩ := h rw [cfcₙ_apply f a, ← map_star, cfcₙ_apply _ a] congr · simp only [not_and_or] at h obtain (ha | hf | h0) := h · simp [cfcₙ_apply_of_not_predicate a ha] · rw [cfcₙ_apply_of_not_continuousOn a hf, cfcₙ_apply_of_not_continuousOn, star_zero] exact fun hf_star ↦ hf <| by simpa using hf_star.star · rw [cfcₙ_apply_of_not_map_zero a h0, cfcₙ_apply_of_not_map_zero, star_zero] exact fun hf0 ↦ h0 <| by simpa using congr(star $(hf0)) lemma cfcₙ_smul_id {S : Type*} [SMulZeroClass S R] [ContinuousConstSMul S R] [SMulZeroClass S A] [IsScalarTower S R A] [IsScalarTower S R (R → R)] (s : S) (a : A) (ha : p a := by cfc_tac) : cfcₙ (s • · : R → R) a = s • a := by rw [cfcₙ_smul s _ a, cfcₙ_id' R a] lemma cfcₙ_const_mul_id (r : R) (a : A) (ha : p a := by cfc_tac) : cfcₙ (r * ·) a = r • a := cfcₙ_smul_id r a include ha in lemma cfcₙ_star_id : cfcₙ (star · : R → R) a = star a := by rw [cfcₙ_star _ a, cfcₙ_id' R a] variable (R) in theorem range_cfcₙ_eq_range_cfcₙHom {a : A} (ha : p a) : Set.range (cfcₙ (R := R) · a) = NonUnitalStarAlgHom.range (cfcₙHom ha (R := R)) := by ext constructor all_goals rintro ⟨f, rfl⟩ · exact cfcₙ_cases _ a f (zero_mem _) fun hf hf₀ ha ↦ ⟨_, rfl⟩ · exact ⟨Subtype.val.extend f 0, cfcₙHom_eq_cfcₙ_extend _ ha _ |>.symm⟩ section Comp variable [UniqueHom R A] lemma cfcₙ_comp (g f : R → R) (a : A) (hg : ContinuousOn g (f '' σₙ R a) := by cfc_cont_tac) (hg0 : g 0 = 0 := by cfc_zero_tac) (hf : ContinuousOn f (σₙ R a) := by cfc_cont_tac) (hf0 : f 0 = 0 := by cfc_zero_tac) (ha : p a := by cfc_tac) : cfcₙ (g ∘ f) a = cfcₙ g (cfcₙ f a) := by have := hg.comp hf <| (σₙ R a).mapsTo_image f have sp_eq : σₙ R (cfcₙHom (show p a from ha) ⟨ContinuousMap.mk _ hf.restrict, hf0⟩) = f '' (σₙ R a) := by rw [cfcₙHom_map_quasispectrum (by exact ha) _] ext simp rw [cfcₙ_apply .., cfcₙ_apply f a, cfcₙ_apply _ _ (by convert hg) (ha := cfcₙHom_predicate (show p a from ha) _), ← cfcₙHom_comp _ _] swap · exact ⟨.mk _ <| hf.restrict.codRestrict fun x ↦ by rw [sp_eq]; use x.1; simp, Subtype.ext hf0⟩ · congr · exact fun _ ↦ rfl lemma cfcₙ_comp' (g f : R → R) (a : A) (hg : ContinuousOn g (f '' σₙ R a) := by cfc_cont_tac) (hg0 : g 0 = 0 := by cfc_zero_tac) (hf : ContinuousOn f (σₙ R a) := by cfc_cont_tac) (hf0 : f 0 = 0 := by cfc_zero_tac) (ha : p a := by cfc_tac) : cfcₙ (g <| f ·) a = cfcₙ g (cfcₙ f a) := cfcₙ_comp g f a lemma cfcₙ_comp_smul {S : Type*} [SMulZeroClass S R] [ContinuousConstSMul S R] [SMulZeroClass S A] [IsScalarTower S R A] [IsScalarTower S R (R → R)] (s : S) (f : R → R) (a : A) (hf : ContinuousOn f ((s • ·) '' (σₙ R a)) := by cfc_cont_tac) (hf0 : f 0 = 0 := by cfc_zero_tac) (ha : p a := by cfc_tac) : cfcₙ (f <| s • ·) a = cfcₙ f (s • a) := by rw [cfcₙ_comp' f (s • ·) a, cfcₙ_smul_id s a] lemma cfcₙ_comp_const_mul (r : R) (f : R → R) (a : A) (hf : ContinuousOn f ((r * ·) '' (σₙ R a)) := by cfc_cont_tac) (hf0 : f 0 = 0 := by cfc_zero_tac) (ha : p a := by cfc_tac) : cfcₙ (f <| r * ·) a = cfcₙ f (r • a) := by rw [cfcₙ_comp' f (r * ·) a, cfcₙ_const_mul_id r a] lemma cfcₙ_comp_star (hf : ContinuousOn f (star '' (σₙ R a)) := by cfc_cont_tac) (hf0 : f 0 = 0 := by cfc_zero_tac) (ha : p a := by cfc_tac) : cfcₙ (f <| star ·) a = cfcₙ f (star a) := by rw [cfcₙ_comp' f star a, cfcₙ_star_id a] end Comp lemma CFC.eq_zero_of_quasispectrum_eq_zero (h_spec : σₙ R a ⊆ {0}) (ha : p a := by cfc_tac) : a = 0 := by simpa [cfcₙ_id R a] using cfcₙ_congr (a := a) (f := id) (g := fun _ : R ↦ 0) fun x ↦ by simp_all include instCFCₙ in lemma CFC.quasispectrum_zero_eq : σₙ R (0 : A) = {0} := by refine Set.eq_singleton_iff_unique_mem.mpr ⟨quasispectrum.zero_mem R 0, fun x hx ↦ ?_⟩ rw [← cfcₙ_zero R (0 : A), cfcₙ_map_quasispectrum _ _ (by cfc_cont_tac) (by cfc_zero_tac) (cfcₙ_predicate_zero R)] at hx simp_all @[simp] lemma cfcₙ_apply_zero {f : R → R} : cfcₙ f (0 : A) = 0 := by by_cases hf0 : f 0 = 0 · nth_rw 2 [← cfcₙ_zero R 0] apply cfcₙ_congr simpa [CFC.quasispectrum_zero_eq] · exact cfcₙ_apply_of_not_map_zero _ hf0 @[simp] instance IsStarNormal.cfcₙ_map (f : R → R) (a : A) : IsStarNormal (cfcₙ f a) where star_comm_self := by refine cfcₙ_cases (fun x ↦ Commute (star x) x) _ _ (Commute.zero_right _) fun _ _ _ ↦ ?_ simp only [Commute, SemiconjBy] rw [← cfcₙ_apply f a, ← cfcₙ_star, ← cfcₙ_mul .., ← cfcₙ_mul ..] congr! 2 exact mul_comm _ _ -- The following two lemmas are just `cfcₙ_predicate`, but specific enough for the `@[simp]` tag. @[simp] protected lemma IsSelfAdjoint.cfcₙ [NonUnitalContinuousFunctionalCalculus R A IsSelfAdjoint] {f : R → R} {a : A} : IsSelfAdjoint (cfcₙ f a) := cfcₙ_predicate _ _ @[simp] lemma cfcₙ_nonneg_of_predicate [LE A] [NonUnitalContinuousFunctionalCalculus R A (0 ≤ ·)] {f : R → R} {a : A} : 0 ≤ cfcₙ f a := cfcₙ_predicate _ _ end CFCn end Main section Neg variable {R A : Type*} {p : A → Prop} [CommRing R] [Nontrivial R] [StarRing R] [MetricSpace R] variable [IsTopologicalRing R] [ContinuousStar R] [TopologicalSpace A] [NonUnitalRing A] variable [StarRing A] [Module R A] [IsScalarTower R A A] [SMulCommClass R A A] variable [NonUnitalContinuousFunctionalCalculus R A p] variable (f g : R → R) (a : A) variable (hf : ContinuousOn f (σₙ R a) := by cfc_cont_tac) (hf0 : f 0 = 0 := by cfc_zero_tac) variable (hg : ContinuousOn g (σₙ R a) := by cfc_cont_tac) (hg0 : g 0 = 0 := by cfc_zero_tac) include hf hf0 hg hg0 in lemma cfcₙ_sub : cfcₙ (fun x ↦ f x - g x) a = cfcₙ f a - cfcₙ g a := by by_cases ha : p a · rw [cfcₙ_apply f a, cfcₙ_apply g a, ← map_sub, cfcₙ_apply ..] congr · simp [cfcₙ_apply_of_not_predicate a ha] lemma cfcₙ_neg : cfcₙ (fun x ↦ - (f x)) a = - (cfcₙ f a) := by by_cases h : p a ∧ ContinuousOn f (σₙ R a) ∧ f 0 = 0 · obtain ⟨ha, hf, h0⟩ := h rw [cfcₙ_apply f a, ← map_neg, cfcₙ_apply ..] congr · simp only [not_and_or] at h obtain (ha | hf | h0) := h · simp [cfcₙ_apply_of_not_predicate a ha] · rw [cfcₙ_apply_of_not_continuousOn a hf, cfcₙ_apply_of_not_continuousOn, neg_zero] exact fun hf_neg ↦ hf <| by simpa using hf_neg.neg · rw [cfcₙ_apply_of_not_map_zero a h0, cfcₙ_apply_of_not_map_zero, neg_zero] exact (h0 <| neg_eq_zero.mp ·) lemma cfcₙ_neg_id (ha : p a := by cfc_tac) : cfcₙ (- · : R → R) a = -a := by rw [cfcₙ_neg .., cfcₙ_id' R a] variable [UniqueHom R A] lemma cfcₙ_comp_neg (hf : ContinuousOn f ((-·) '' (σₙ R a)) := by cfc_cont_tac) (h0 : f 0 = 0 := by cfc_zero_tac) (ha : p a := by cfc_tac) : cfcₙ (f <| - ·) a = cfcₙ f (-a) := by rw [cfcₙ_comp' .., cfcₙ_neg_id _] end Neg section Order section Semiring variable {R A : Type*} {p : A → Prop} [CommSemiring R] [PartialOrder R] [Nontrivial R] variable [StarRing R] [MetricSpace R] [IsTopologicalSemiring R] [ContinuousStar R] variable [ContinuousSqrt R] [StarOrderedRing R] [NoZeroDivisors R] variable [TopologicalSpace A] [NonUnitalRing A] [StarRing A] [PartialOrder A] [StarOrderedRing A] variable [Module R A] [IsScalarTower R A A] [SMulCommClass R A A] variable [NonUnitalContinuousFunctionalCalculus R A p] lemma cfcₙHom_mono {a : A} (ha : p a) {f g : C(σₙ R a, R)₀} (hfg : f ≤ g) : cfcₙHom ha f ≤ cfcₙHom ha g := OrderHomClass.mono (cfcₙHom ha) hfg lemma cfcₙHom_nonneg_iff [NonnegSpectrumClass R A] {a : A} (ha : p a) {f : C(σₙ R a, R)₀} : 0 ≤ cfcₙHom ha f ↔ 0 ≤ f := by constructor · exact fun hf x ↦ (cfcₙHom_map_quasispectrum ha (R := R) _ ▸ quasispectrum_nonneg_of_nonneg (cfcₙHom ha f) hf) _ ⟨x, rfl⟩ · simpa using (cfcₙHom_mono ha (f := 0) (g := f) ·) lemma cfcₙ_mono {f g : R → R} {a : A} (h : ∀ x ∈ σₙ R a, f x ≤ g x) (hf : ContinuousOn f (σₙ R a) := by cfc_cont_tac) (hg : ContinuousOn g (σₙ R a) := by cfc_cont_tac) (hf0 : f 0 = 0 := by cfc_zero_tac) (hg0 : g 0 = 0 := by cfc_zero_tac) : cfcₙ f a ≤ cfcₙ g a := by by_cases ha : p a · rw [cfcₙ_apply f a, cfcₙ_apply g a] exact cfcₙHom_mono ha fun x ↦ h x.1 x.2 · simp only [cfcₙ_apply_of_not_predicate _ ha, le_rfl] lemma cfcₙ_nonneg_iff [NonnegSpectrumClass R A] (f : R → R) (a : A) (hf : ContinuousOn f (σₙ R a) := by cfc_cont_tac) (h0 : f 0 = 0 := by cfc_zero_tac) (ha : p a := by cfc_tac) : 0 ≤ cfcₙ f a ↔ ∀ x ∈ σₙ R a, 0 ≤ f x := by rw [cfcₙ_apply .., cfcₙHom_nonneg_iff, ContinuousMapZero.le_def] simp only [ContinuousMapZero.coe_mk, ContinuousMap.coe_mk, Set.restrict_apply, Subtype.forall] congr! lemma StarOrderedRing.nonneg_iff_quasispectrum_nonneg [NonnegSpectrumClass R A] (a : A) (ha : p a := by cfc_tac) : 0 ≤ a ↔ ∀ x ∈ quasispectrum R a, 0 ≤ x := by have := cfcₙ_nonneg_iff (id : R → R) a (by fun_prop) simpa [cfcₙ_id _ a ha] using this lemma cfcₙ_nonneg {f : R → R} {a : A} (h : ∀ x ∈ σₙ R a, 0 ≤ f x) : 0 ≤ cfcₙ f a := by by_cases hf : ContinuousOn f (σₙ R a) ∧ f 0 = 0 · obtain ⟨h₁, h₂⟩ := hf simpa using cfcₙ_mono h · simp only [not_and_or] at hf obtain (hf | hf) := hf · simp only [cfcₙ_apply_of_not_continuousOn _ hf, le_rfl] · simp only [cfcₙ_apply_of_not_map_zero _ hf, le_rfl] lemma cfcₙ_nonpos (f : R → R) (a : A) (h : ∀ x ∈ σₙ R a, f x ≤ 0) : cfcₙ f a ≤ 0 := by by_cases hf : ContinuousOn f (σₙ R a) ∧ f 0 = 0 · obtain ⟨h₁, h₂⟩ := hf simpa using cfcₙ_mono h · simp only [not_and_or] at hf obtain (hf | hf) := hf · simp only [cfcₙ_apply_of_not_continuousOn _ hf, le_rfl] · simp only [cfcₙ_apply_of_not_map_zero _ hf, le_rfl] end Semiring section Ring variable {R A : Type*} {p : A → Prop} [CommRing R] [PartialOrder R] [Nontrivial R] variable [StarRing R] [MetricSpace R] [IsTopologicalRing R] [ContinuousStar R] variable [ContinuousSqrt R] [StarOrderedRing R] [NoZeroDivisors R] variable [TopologicalSpace A] [NonUnitalRing A] [StarRing A] [PartialOrder A] [StarOrderedRing A] variable [Module R A] [IsScalarTower R A A] [SMulCommClass R A A] variable [NonUnitalContinuousFunctionalCalculus R A p] [NonnegSpectrumClass R A] lemma cfcₙHom_le_iff {a : A} (ha : p a) {f g : C(σₙ R a, R)₀} : cfcₙHom ha f ≤ cfcₙHom ha g ↔ f ≤ g := by rw [← sub_nonneg, ← map_sub, cfcₙHom_nonneg_iff, sub_nonneg] lemma cfcₙ_le_iff (f g : R → R) (a : A) (hf : ContinuousOn f (σₙ R a) := by cfc_cont_tac) (hg : ContinuousOn g (σₙ R a) := by cfc_cont_tac) (hf0 : f 0 = 0 := by cfc_zero_tac) (hg0 : g 0 = 0 := by cfc_zero_tac) (ha : p a := by cfc_tac) : cfcₙ f a ≤ cfcₙ g a ↔ ∀ x ∈ σₙ R a, f x ≤ g x := by rw [cfcₙ_apply f a, cfcₙ_apply g a, cfcₙHom_le_iff (show p a from ha), ContinuousMapZero.le_def] simp lemma cfcₙ_nonpos_iff (f : R → R) (a : A) (hf : ContinuousOn f (σₙ R a) := by cfc_cont_tac) (h0 : f 0 = 0 := by cfc_zero_tac) (ha : p a := by cfc_tac) : cfcₙ f a ≤ 0 ↔ ∀ x ∈ σₙ R a, f x ≤ 0 := by simp_rw [← neg_nonneg, ← cfcₙ_neg] exact cfcₙ_nonneg_iff (fun x ↦ -f x) a end Ring end Order /-! ### `cfcₙHom` on a superset of the quasispectrum -/ section Superset open ContinuousMapZero variable {R A : Type*} {p : A → Prop} [CommSemiring R] [Nontrivial R] [StarRing R] [MetricSpace R] [IsTopologicalSemiring R] [ContinuousStar R] [NonUnitalRing A] [StarRing A] [TopologicalSpace A] [Module R A] [IsScalarTower R A A] [SMulCommClass R A A] [instCFCₙ : NonUnitalContinuousFunctionalCalculus R A p] /-- The composition of `cfcₙHom` with the natural embedding `C(s, R)₀ → C(quasispectrum R a, R)₀` whenever `quasispectrum R a ⊆ s`. This is sometimes necessary in order to consider the same continuous functions applied to multiple distinct elements, with the added constraint that `cfcₙ` does not suffice. This can occur, for example, if it is necessary to use uniqueness of this continuous functional calculus. A practical example can be found in the proof of `CFC.posPart_negPart_unique`. -/ @[simps!] noncomputable def cfcₙHomSuperset {a : A} (ha : p a) {s : Set R} (hs : σₙ R a ⊆ s) : haveI : Fact (0 ∈ s) := ⟨hs (quasispectrum.zero_mem R a)⟩ C(s, R)₀ →⋆ₙₐ[R] A := have : Fact (0 ∈ s) := ⟨hs (quasispectrum.zero_mem R a)⟩ cfcₙHom ha (R := R) |>.comp <| ContinuousMapZero.nonUnitalStarAlgHom_precomp R <| ⟨⟨_, continuous_id.subtype_map hs⟩, rfl⟩ lemma cfcₙHomSuperset_continuous {a : A} (ha : p a) {s : Set R} (hs : σₙ R a ⊆ s) : Continuous (cfcₙHomSuperset ha hs) := have : Fact (0 ∈ s) := ⟨hs (quasispectrum.zero_mem R a)⟩ (cfcₙHom_continuous ha).comp <| ContinuousMapZero.continuous_comp_left _ lemma cfcₙHomSuperset_id {a : A} (ha : p a) {s : Set R} (hs : σₙ R a ⊆ s) : haveI : Fact (0 ∈ s) := ⟨hs (quasispectrum.zero_mem R a)⟩ cfcₙHomSuperset ha hs (.id s) = a := cfcₙHom_id ha end Superset /-! ### Obtain a non-unital continuous functional calculus from a unital one -/ section UnitalToNonUnital open ContinuousMapZero Set Uniformity ContinuousMap variable {R A : Type*} {p : A → Prop} [Semifield R] [StarRing R] [MetricSpace R] variable [IsTopologicalSemiring R] [ContinuousStar R] [Ring A] [StarRing A] [TopologicalSpace A] variable [Algebra R A] [ContinuousFunctionalCalculus R A p] variable (R) in /-- The non-unital continuous functional calculus obtained by restricting a unital calculus to functions that map zero to zero. This is an auxiliary definition and is not intended for use outside this file. The equality between the non-unital and unital calculi in this case is encoded in the lemma `cfcₙ_eq_cfc`. -/ noncomputable def cfcₙHom_of_cfcHom {a : A} (ha : p a) : C(σₙ R a, R)₀ →⋆ₙₐ[R] A := let e := ContinuousMapZero.toContinuousMapHom (X := σₙ R a) (R := R) let f : C(spectrum R a, quasispectrum R a) := ⟨_, continuous_inclusion <| spectrum_subset_quasispectrum R a⟩ let ψ := ContinuousMap.compStarAlgHom' R R f (cfcHom ha (R := R) : C(spectrum R a, R) →⋆ₙₐ[R] A).comp <| (ψ : C(σₙ R a, R) →⋆ₙₐ[R] C(spectrum R a, R)).comp e lemma cfcₙHom_of_cfcHom_map_quasispectrum {a : A} (ha : p a) : ∀ f : C(σₙ R a, R)₀, σₙ R (cfcₙHom_of_cfcHom R ha f) = range f := by intro f simp only [cfcₙHom_of_cfcHom] rw [quasispectrum_eq_spectrum_union_zero] simp only [NonUnitalStarAlgHom.comp_apply, NonUnitalStarAlgHom.coe_coe] rw [cfcHom_map_spectrum ha] ext x constructor · rintro (⟨x, rfl⟩ | rfl) · exact ⟨⟨x.1, spectrum_subset_quasispectrum R a x.2⟩, rfl⟩ · exact ⟨0, map_zero f⟩ · rintro ⟨x, rfl⟩ have hx := x.2 simp_rw [quasispectrum_eq_spectrum_union_zero R a] at hx obtain (hx | hx) := hx · exact Or.inl ⟨⟨x.1, hx⟩, rfl⟩ · apply Or.inr simp only [Set.mem_singleton_iff] at hx ⊢ rw [show x = 0 from Subtype.val_injective hx, map_zero] variable [CompleteSpace R] -- gives access to the `ContinuousFunctionalCalculus.compactSpace_spectrum` instance open scoped ContinuousFunctionalCalculus lemma isClosedEmbedding_cfcₙHom_of_cfcHom {a : A} (ha : p a) : IsClosedEmbedding (cfcₙHom_of_cfcHom R ha) := by let f : C(spectrum R a, σₙ R a) := ⟨_, continuous_inclusion <| spectrum_subset_quasispectrum R a⟩ refine (cfcHom_isClosedEmbedding ha).comp <| (IsUniformInducing.isUniformEmbedding ⟨?_⟩).isClosedEmbedding have := uniformSpace_eq_inf_precomp_of_cover (β := R) f (0 : C(Unit, σₙ R a)) (map_continuous f).isProperMap (map_continuous 0).isProperMap <| by simp only [← Subtype.val_injective.image_injective.eq_iff, f, ContinuousMap.coe_mk, ContinuousMap.coe_zero, range_zero, image_union, image_singleton, quasispectrum.coe_zero, ← range_comp, val_comp_inclusion, image_univ, Subtype.range_coe, quasispectrum_eq_spectrum_union_zero] simp_rw [ContinuousMapZero.instUniformSpace, this, uniformity_comap, @inf_uniformity _ (.comap _ _) (.comap _ _), uniformity_comap, Filter.comap_inf, Filter.comap_comap] refine .symm <| inf_eq_left.mpr <| le_top.trans <| eq_top_iff.mp ?_ have : ∀ U ∈ 𝓤 (C(Unit, R)), (0, 0) ∈ U := fun U hU ↦ refl_mem_uniformity hU convert Filter.comap_const_of_mem this with ⟨u, v⟩ <;> ext ⟨x, rfl⟩ <;> [exact map_zero u; exact map_zero v] instance ContinuousFunctionalCalculus.toNonUnital : NonUnitalContinuousFunctionalCalculus R A p where predicate_zero := cfc_predicate_zero R compactSpace_quasispectrum a := by have h_cpct : CompactSpace (spectrum R a) := inferInstance simp only [← isCompact_iff_compactSpace, quasispectrum_eq_spectrum_union_zero] at h_cpct ⊢ exact h_cpct |>.union isCompact_singleton exists_cfc_of_predicate _ ha := ⟨cfcₙHom_of_cfcHom R ha, isClosedEmbedding_cfcₙHom_of_cfcHom ha, cfcHom_id ha, cfcₙHom_of_cfcHom_map_quasispectrum ha, fun _ ↦ cfcHom_predicate ha _⟩ open scoped NonUnitalContinuousFunctionalCalculus in lemma cfcₙHom_eq_cfcₙHom_of_cfcHom [ContinuousMapZero.UniqueHom R A] {a : A} (ha : p a) : cfcₙHom (R := R) ha = cfcₙHom_of_cfcHom R ha := by refine ContinuousMapZero.UniqueHom.eq_of_continuous_of_map_id (σₙ R a) _ _ ?_ ?_ ?_ · exact (cfcₙHom_isClosedEmbedding (R := R) ha).continuous · exact (isClosedEmbedding_cfcₙHom_of_cfcHom ha).continuous · simpa only [cfcₙHom_id (R := R) ha] using (cfcHom_id ha).symm /-- When `cfc` is applied to a function that maps zero to zero, it is equivalent to using `cfcₙ`. -/ lemma cfcₙ_eq_cfc [ContinuousMapZero.UniqueHom R A] {f : R → R} {a : A} (hf : ContinuousOn f (σₙ R a) := by cfc_cont_tac) (hf0 : f 0 = 0 := by cfc_zero_tac) : cfcₙ f a = cfc f a := by by_cases ha : p a · have hf' := hf.mono <| spectrum_subset_quasispectrum R a rw [cfc_apply f a ha hf', cfcₙ_apply f a hf, cfcₙHom_eq_cfcₙHom_of_cfcHom, cfcₙHom_of_cfcHom] dsimp only [NonUnitalStarAlgHom.comp_apply, toContinuousMapHom_apply, NonUnitalStarAlgHom.coe_coe, compStarAlgHom'_apply] congr · simp [cfc_apply_of_not_predicate a ha, cfcₙ_apply_of_not_predicate (R := R) a ha] end UnitalToNonUnital
.lake/packages/mathlib/Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Continuity.lean
import Mathlib.Analysis.CStarAlgebra.ContinuousFunctionalCalculus.Isometric import Mathlib.Topology.MetricSpace.UniformConvergence import Mathlib.Topology.UniformSpace.CompactConvergence /-! # Continuity of the continuous functional calculus in each variable The continuous functional calculus is a map which takes a pair `a : A` (`A` is a C⋆-algebra) and a function `f : C(spectrum R a, R)` where `a` satisfies some predicate `p`, depending on `R` and returns another element of the algebra `A`. This is the map `cfcHom`. The class `ContinuousFunctionalCalculus` declares that `cfcHom` is a continuous map from `C(spectrum R a, R)` to `A`. However, users generally interact with the continuous functional calculus through `cfc`, which operates on bare functions `f : R → R` instead and takes a junk value when `f` is not continuous on the spectrum of `a`. In this file we provide some lemma concerning the continuity of `cfc`, subject to natural hypotheses. However, the continuous functional calculus is *also* continuous in the variable `a`, but there are some conditions that must be satisfied. In particular, given a function `f : R → R` the map `a ↦ cfc f a` is continuous so long as `a` varies over a collection of elements satisfying the predicate `p` and their spectra are collectively contained in a compact set on which `f` is continuous. Moreover, it is required that the continuous functional calculus be the isometric variant. Under the assumption of `IsometricContinuousFunctionalCalculus`, we show that the continuous functional calculus is Lipschitz with constant 1 in the variable `f : R →ᵤ[{spectrum R a}] R` on the set of functions which are continuous on the spectrum of `a`. Combining this with the continuity of the continuous functional calculus in the variable `a`, we obtain a joint continuity result for `cfc` in both variables. Finally, all of this is developed for both the unital and non-unital functional calculi. The continuity results in the function variable are valid for all scalar rings, but the continuity results in the variable `a` come in two flavors: those for `RCLike 𝕜` and those for `ℝ≥0`. ## Main results + `tendsto_cfc_fun`: If `F : X → R → R` tends to `f : R → R` uniformly on the spectrum of `a`, and all these functions are continuous on the spectrum, then `fun x ↦ cfc (F x) a` tends to `cfc f a`. + `Filter.Tendsto.cfc`: If `f : 𝕜 → 𝕜` is continuous on a compact set `s` and `a : X → A` tends to `a₀ : A` along a filter `l` (such that eventually `a x` satisfies the predicate `p` associated to `𝕜` and has spectrum contained in `s`, as does `a₀`), then `fun x ↦ cfc f (a x)` tends to `cfc f a₀`. + `lipschitzOnWith_cfc_fun`: The function `f ↦ cfc f a` is Lipschitz with constant with constant 1 with respect to supremum metric (on `R →ᵤ[{spectrum R a}] R`) on those functions which are continuous on the spectrum. + `continuousOn_cfc`: For `f : 𝕜 → 𝕜` continuous on a compact set `s`, `cfc f` is continuous on the set of `a : A` satisfying the predicate `p` (associated to `𝕜`) and whose `𝕜`-spectrum is contained in `s`. + `continuousOn_cfc_setProd`: Let `s : Set 𝕜` be a compact set and consider pairs `(f, a) : (𝕜 → 𝕜) × A` where `f` is continuous on `s` and `spectrum 𝕜 a ⊆ s` and `a` satisfies the predicate `p a` for the continuous functional calculus. Then `cfc` is jointly continuous in both variables (i.e., continuous in its uncurried form) on this set of pairs when the function space is equipped with the topology of uniform convergence on `s`. + Versions of all of the above for non-unital algebras, and versions over `ℝ≥0` as well. -/ open scoped UniformConvergence NNReal open Filter Topology section Unital section Left section Generic variable {X R A : Type*} {p : A → Prop} [CommSemiring R] [StarRing R] [MetricSpace R] [IsTopologicalSemiring R] [ContinuousStar R] [Ring A] [StarRing A] [TopologicalSpace A] [Algebra R A] [ContinuousFunctionalCalculus R A p] /-- If `F : X → R → R` tends to `f : R → R` uniformly on the spectrum of `a`, and all these functions are continuous on the spectrum, then `fun x ↦ cfc (F x) a` tends to `cfc f a`. -/ theorem tendsto_cfc_fun {l : Filter X} {F : X → R → R} {f : R → R} {a : A} (h_tendsto : TendstoUniformlyOn F f l (spectrum R a)) (hF : ∀ᶠ x in l, ContinuousOn (F x) (spectrum R a)) : Tendsto (fun x ↦ cfc (F x) a) l (𝓝 (cfc f a)) := by open scoped ContinuousFunctionalCalculus in obtain (rfl | hl) := l.eq_or_neBot · simp have hf := h_tendsto.continuousOn hF by_cases ha : p a · let s : Set X := {x | ContinuousOn (F x) (spectrum R a)} rw [← tendsto_comap'_iff (i := ((↑) : s → X)) (by simpa)] conv => enter [1, x] rw [Function.comp_apply, cfc_apply (hf := x.2)] rw [cfc_apply ..] apply cfcHom_continuous _ |>.tendsto _ |>.comp rw [hf.tendsto_restrict_iff_tendstoUniformlyOn Subtype.property] intro t simp only [eventually_comap, Subtype.forall] peel h_tendsto t with ht x _ simp_all · simpa [cfc_apply_of_not_predicate a ha] using tendsto_const_nhds /-- If `f : X → R → R` tends to `f x₀` uniformly (along `𝓝 x₀`) on the spectrum of `a`, and each `f x` is continuous on the spectrum of `a`, then `fun x ↦ cfc (f x) a` is continuous at `x₀`. -/ theorem continuousAt_cfc_fun [TopologicalSpace X] {f : X → R → R} {a : A} {x₀ : X} (h_tendsto : TendstoUniformlyOn f (f x₀) (𝓝 x₀) (spectrum R a)) (hf : ∀ᶠ x in 𝓝 x₀, ContinuousOn (f x) (spectrum R a)) : ContinuousAt (fun x ↦ cfc (f x) a) x₀ := tendsto_cfc_fun h_tendsto hf /-- If `f : X → R → R` tends to `f x₀` uniformly (along `𝓝[s] x₀`) on the spectrum of `a`, and eventually each `f x` is continuous on the spectrum of `a`, then `fun x ↦ cfc (f x) a` is continuous at `x₀` within `s`. -/ theorem continuousWithinAt_cfc_fun [TopologicalSpace X] {f : X → R → R} {a : A} {x₀ : X} {s : Set X} (h_tendsto : TendstoUniformlyOn f (f x₀) (𝓝[s] x₀) (spectrum R a)) (hf : ∀ᶠ x in 𝓝[s] x₀, ContinuousOn (f x) (spectrum R a)) : ContinuousWithinAt (fun x ↦ cfc (f x) a) s x₀ := tendsto_cfc_fun h_tendsto hf open UniformOnFun in /-- If `f : X → R → R` is continuous on `s : Set X` in the topology on `X → R →ᵤ[{spectrum R a}] → R`, and each `f` is continuous on the spectrum, then `x ↦ cfc (f x) a` is continuous on `s` also. -/ theorem ContinuousOn.cfc_fun [TopologicalSpace X] {f : X → R → R} {a : A} {s : Set X} (h_cont : ContinuousOn (fun x ↦ ofFun {spectrum R a} (f x)) s) (hf : ∀ x ∈ s, ContinuousOn (f x) (spectrum R a) := by cfc_cont_tac) : ContinuousOn (fun x ↦ cfc (f x) a) s := by rw [ContinuousOn] at h_cont ⊢ simp only [ContinuousWithinAt, UniformOnFun.tendsto_iff_tendstoUniformlyOn, Set.mem_singleton_iff, Function.comp_def, toFun_ofFun, forall_eq] at h_cont refine fun x hx ↦ continuousWithinAt_cfc_fun (h_cont x hx) ?_ filter_upwards [self_mem_nhdsWithin] with x hx exact hf x hx open UniformOnFun in /-- If `f : X → R → R` is continuous in the topology on `X → R →ᵤ[{spectrum R a}] → R`, and each `f` is continuous on the spectrum, then `x ↦ cfc (f x) a` is continuous. -/ theorem Continuous.cfc_fun [TopologicalSpace X] (f : X → R → R) (a : A) (h_cont : Continuous (fun x ↦ ofFun {spectrum R a} (f x))) (hf : ∀ x, ContinuousOn (f x) (spectrum R a) := by cfc_cont_tac) : Continuous fun x ↦ cfc (f x) a := by rw [← continuousOn_univ] at h_cont ⊢ exact h_cont.cfc_fun (fun x _ ↦ hf x) end Generic section Isometric variable {X R A : Type*} {p : 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] variable (R) in open UniformOnFun in open scoped ContinuousFunctionalCalculus in /-- The function `f ↦ cfc f a` is Lipschitz with constant 1 with respect to supremum metric (on `R →ᵤ[{spectrum R a}] R`) on those functions which are continuous on the spectrum. -/ lemma lipschitzOnWith_cfc_fun (a : A) : LipschitzOnWith 1 (fun f ↦ cfc (toFun {spectrum R a} f) a) {f | ContinuousOn (toFun {spectrum R a} f) (spectrum R a)} := by by_cases ha : p a · intro f hf g hg simp only rw [cfc_apply .., cfc_apply .., isometry_cfcHom (R := R) a ha |>.edist_eq] simp only [ENNReal.coe_one, one_mul] rw [edist_continuousRestrict_of_singleton hf hg] · simpa [cfc_apply_of_not_predicate a ha] using LipschitzWith.const' 0 |>.lipschitzOnWith open UniformOnFun in open scoped ContinuousFunctionalCalculus in /-- The function `f ↦ cfc f a` is Lipschitz with constant 1 with respect to supremum metric (on `R →ᵤ[{s}] R`) on those functions which are continuous on a set `s` containing the spectrum. -/ lemma lipschitzOnWith_cfc_fun_of_subset (a : A) {s : Set R} (hs : spectrum R a ⊆ s) : LipschitzOnWith 1 (fun f ↦ cfc (toFun {s} f) a) {f | ContinuousOn (toFun {s} f) (s)} := by have h₁ := lipschitzOnWith_cfc_fun R a have h₂ := lipschitzWith_one_ofFun_toFun' (𝔖 := {spectrum R a}) (𝔗 := {s}) (β := R) (by simpa) have h₃ := h₂.lipschitzOnWith (s := {f | ContinuousOn (toFun {s} f) (s)}) simpa using h₁.comp h₃ (fun f hf ↦ hf.mono hs) end Isometric end Left section Right section RCLike variable {X 𝕜 A : Type*} {p : A → Prop} [RCLike 𝕜] [NormedRing A] [StarRing A] [NormedAlgebra 𝕜 A] [IsometricContinuousFunctionalCalculus 𝕜 A p] [ContinuousStar A] /-- `cfcHomSuperset` is continuous in the variable `a : A` when `s : Set 𝕜` is compact and `a` varies over elements whose spectrum is contained in `s`, all of which satisfy the predicate `p`. -/ theorem continuous_cfcHomSuperset_left [TopologicalSpace X] {s : Set 𝕜} (hs : IsCompact s) (f : C(s, 𝕜)) (a : X → A) (ha_cont : Continuous a) (ha : ∀ x, spectrum 𝕜 (a x) ⊆ s) (ha' : ∀ x, p (a x) := by cfc_tac) : Continuous (fun x ↦ cfcHomSuperset (ha' x) (ha x) f) := by open scoped ContinuousFunctionalCalculus in have : CompactSpace s := by rwa [isCompact_iff_compactSpace] at hs induction f using ContinuousMap.induction_on_of_compact with | const r => have : ContinuousMap.const s r = algebraMap 𝕜 C(s, 𝕜) r := rfl simpa only [this, AlgHomClass.commutes] using continuous_const | id => simp only [cfcHomSuperset_id] fun_prop | star_id => simp only [map_star, cfcHomSuperset_id] fun_prop | add f g hf hg => simpa using hf.add hg | mul f g hf hg => simpa using hf.mul hg | frequently f hf => apply continuous_of_uniform_approx_of_continuous rw [Metric.uniformity_basis_dist_le.forall_iff (by aesop)] intro ε hε simp only [Set.mem_setOf_eq, dist_eq_norm] obtain ⟨g, hg, g_cont⟩ := frequently_iff.mp hf (Metric.closedBall_mem_nhds f hε) simp only [Metric.mem_closedBall, dist_comm g, dist_eq_norm] at hg refine ⟨_, g_cont, fun x ↦ ?_⟩ rw [← map_sub, cfcHomSuperset_apply] rw [isometry_cfcHom (R := 𝕜) _ (ha' x) |>.norm_map_of_map_zero (map_zero (cfcHom (ha' x)))] rw [ContinuousMap.norm_le _ hε.le] at hg ⊢ aesop variable (A) in /-- For `f : 𝕜 → 𝕜` continuous on a compact set `s`, `cfc f` is continuous on the set of `a : A` satisfying the predicate `p` (associated to `𝕜`) and whose `𝕜`-spectrum is contained in `s`. -/ theorem continuousOn_cfc {s : Set 𝕜} (hs : IsCompact s) (f : 𝕜 → 𝕜) (hf : ContinuousOn f s := by cfc_cont_tac) : ContinuousOn (cfc f) {a | p a ∧ spectrum 𝕜 a ⊆ s} := continuousOn_iff_continuous_restrict.mpr <| by convert continuous_cfcHomSuperset_left hs ⟨_, hf.restrict⟩ ((↑) : {a | p a ∧ spectrum 𝕜 a ⊆ s} → A) continuous_subtype_val (fun x ↦ x.2.2) with x rw [cfcHomSuperset_apply, Set.restrict_apply, cfc_apply _ _ x.2.1 (hf.mono x.2.2)] congr! open UniformOnFun in /-- Let `s : Set 𝕜` be a compact set and consider pairs `(f, a) : (𝕜 → 𝕜) × A` where `f` is continuous on `s` and `spectrum 𝕜 a ⊆ s` and `a` satisfies the predicate `p a` for the continuous functional calculus. Then `cfc` is jointly continuous in both variables (i.e., continuous in its uncurried form) on this set of pairs when the function space is equipped with the topology of uniform convergence on `s`. -/ theorem continuousOn_cfc_setProd {s : Set 𝕜} (hs : IsCompact s) : ContinuousOn (fun fa : (𝕜 →ᵤ[{s}] 𝕜) × A ↦ cfc (toFun {s} fa.1) fa.2) ({f | ContinuousOn (toFun {s} f) s} ×ˢ {a | p a ∧ spectrum 𝕜 a ⊆ s}) := continuousOn_prod_of_continuousOn_lipschitzOnWith _ 1 (fun f hf ↦ continuousOn_cfc A hs ((toFun {s}) f) hf) (fun a ⟨_, ha'⟩ ↦ lipschitzOnWith_cfc_fun_of_subset a ha') /-- If `f : 𝕜 → 𝕜` is continuous on a compact set `s` and `a : X → A` tends to `a₀ : A` along a filter `l` (such that eventually `a x` satisfies the predicate `p` associated to `𝕜` and has spectrum contained in `s`, as does `a₀`), then `fun x ↦ cfc f (a x)` tends to `cfc f a₀`. -/ protected theorem Filter.Tendsto.cfc {s : Set 𝕜} (hs : IsCompact s) (f : 𝕜 → 𝕜) {a : X → A} {a₀ : A} {l : Filter X} (ha_tendsto : Tendsto a l (𝓝 a₀)) (ha : ∀ᶠ x in l, spectrum 𝕜 (a x) ⊆ s) (ha' : ∀ᶠ x in l, p (a x)) (ha₀ : spectrum 𝕜 a₀ ⊆ s) (ha₀' : p a₀) (hf : ContinuousOn f s := by cfc_cont_tac) : Tendsto (fun x ↦ cfc f (a x)) l (𝓝 (cfc f a₀)) := by apply continuousOn_cfc A hs f |>.continuousWithinAt ⟨ha₀', ha₀⟩ |>.tendsto.comp rw [tendsto_nhdsWithin_iff] exact ⟨ha_tendsto, ha'.and ha⟩ /-- If `f : 𝕜 → 𝕜` is continuous on a compact set `s` and `a : X → A` is continuous at `x₀`, and eventually `a x` satisfies the predicate `p` associated to `𝕜` and has spectrum contained in `s`), then `fun x ↦ cfc f (a x)` is continuous at `x₀`. -/ protected theorem ContinuousAt.cfc [TopologicalSpace X] {s : Set 𝕜} (hs : IsCompact s) (f : 𝕜 → 𝕜) {a : X → A} {x₀ : X} (ha_cont : ContinuousAt a x₀) (ha : ∀ᶠ x in 𝓝 x₀, spectrum 𝕜 (a x) ⊆ s) (ha' : ∀ᶠ x in 𝓝 x₀, p (a x)) (hf : ContinuousOn f s := by cfc_cont_tac) : ContinuousAt (fun x ↦ cfc f (a x)) x₀ := ha_cont.tendsto.cfc hs f ha ha' ha.self_of_nhds ha'.self_of_nhds /-- If `f : 𝕜 → 𝕜` is continuous on a compact set `s` and `a : X → A` is continuous at `x₀` within a set `t : Set X`, and eventually `a x` satisfies the predicate `p` associated to `𝕜` and has spectrum contained in `s`), then `fun x ↦ cfc f (a x)` is continuous at `x₀` within `t`. -/ protected theorem ContinuousWithinAt.cfc [TopologicalSpace X] {s : Set 𝕜} (hs : IsCompact s) (f : 𝕜 → 𝕜) {a : X → A} {x₀ : X} {t : Set X} (hx₀ : x₀ ∈ t) (ha_cont : ContinuousWithinAt a t x₀) (ha : ∀ᶠ x in 𝓝[t] x₀, spectrum 𝕜 (a x) ⊆ s) (ha' : ∀ᶠ x in 𝓝[t] x₀, p (a x)) (hf : ContinuousOn f s := by cfc_cont_tac) : ContinuousWithinAt (fun x ↦ cfc f (a x)) t x₀ := ha_cont.tendsto.cfc hs f ha ha' (ha.self_of_nhdsWithin hx₀) (ha'.self_of_nhdsWithin hx₀) /-- Suppose `a : X → Set A` is continuous on `t : Set X` and `a x` satisfies the predicate `p` for all `x ∈ t`. Suppose further that `s : X → Set 𝕜` is a family of sets with `s x` compact when `x ∈ t` such that `s x₀` contains the spectrum of `a x` for all sufficiently close `x ∈ t`. If `f : 𝕜 → 𝕜` is continuous on `s x`, for each `x ∈ t`, then `fun x ↦ cfc f (a x)` is continuous on `t`. -/ protected theorem ContinuousOn.cfc [TopologicalSpace X] {s : X → Set 𝕜} (f : 𝕜 → 𝕜) {a : X → A} {t : Set X} (hs : ∀ x ∈ t, IsCompact (s x)) (ha_cont : ContinuousOn a t) (ha : ∀ x₀ ∈ t, ∀ᶠ x in 𝓝[t] x₀, spectrum 𝕜 (a x) ⊆ s x₀) (ha' : ∀ x ∈ t, p (a x)) (hf : ∀ x ∈ t, ContinuousOn f (s x) := by cfc_cont_tac) : ContinuousOn (fun x ↦ cfc f (a x)) t := by rw [ContinuousOn] at ha_cont ⊢ refine fun x hx ↦ (ha_cont x hx).cfc (hs x hx) f hx ?_ ?_ (hf x hx) all_goals filter_upwards [ha x hx, self_mem_nhdsWithin] with x hx hxt exacts [hx, ha' x hxt] /-- If `f : 𝕜 → 𝕜` is continuous on a compact set `s` and `a : X → A` is continuous on `t : Set X`, and `a x` satisfies the predicate `p` associated to `𝕜` and has spectrum contained in `s` for all `x ∈ t`, then `fun x ↦ cfc f (a x)` is continuous on `t`. -/ theorem ContinuousOn.cfc' [TopologicalSpace X] {s : Set 𝕜} (hs : IsCompact s) (f : 𝕜 → 𝕜) {a : X → A} {t : Set X} (ha_cont : ContinuousOn a t) (ha : ∀ x ∈ t, spectrum 𝕜 (a x) ⊆ s) (ha' : ∀ x ∈ t, p (a x)) (hf : ContinuousOn f s := by cfc_cont_tac) : ContinuousOn (fun x ↦ cfc f (a x)) t := by refine ContinuousOn.cfc _ (fun _ _ ↦ hs) ha_cont (fun _ _ ↦ ?_) ha' filter_upwards [self_mem_nhdsWithin] with x hx exact ha x hx /-- Suppose `a : X → Set A` is continuous and `a x` satisfies the predicate `p` for all `x`. Suppose further that `s : X → Set 𝕜` is a family of compact sets `s x₀` contains the spectrum of `a x` for all sufficiently close `x`. If `f : 𝕜 → 𝕜` is continuous on each `s x`, then `fun x ↦ cfc f (a x)` is continuous. -/ protected theorem Continuous.cfc [TopologicalSpace X] {s : X → Set 𝕜} (f : 𝕜 → 𝕜) {a : X → A} (ha_cont : Continuous a) (hs : ∀ x, IsCompact (s x)) (ha : ∀ x₀, ∀ᶠ x in 𝓝 x₀, spectrum 𝕜 (a x) ⊆ s x₀) (hf : ∀ x, ContinuousOn f (s x) := by cfc_cont_tac) (ha' : ∀ x, p (a x) := by cfc_tac) : Continuous (fun x ↦ cfc f (a x)) := by rw [← continuousOn_univ] at ha_cont ⊢ exact ha_cont.cfc f (fun x _ ↦ hs x) (fun x _ ↦ by simpa using ha x) (fun x _ ↦ ha' x) /-- `cfc` is continuous in the variable `a : A` when `s : Set 𝕜` is compact and `a` varies over elements whose spectrum is contained in `s`, all of which satisfy the predicate `p`, and the function `f` is continuous on the spectrum of `a`. -/ theorem Continuous.cfc' [TopologicalSpace X] {s : Set 𝕜} (hs : IsCompact s) (f : 𝕜 → 𝕜) {a : X → A} (ha_cont : Continuous a) (ha : ∀ x, spectrum 𝕜 (a x) ⊆ s) (hf : ContinuousOn f s := by cfc_cont_tac) (ha' : ∀ x, p (a x) := by cfc_tac) : Continuous (fun x ↦ cfc f (a x)) := by rw [← continuousOn_univ] at ha_cont ⊢ exact ha_cont.cfc' hs f (fun x _ ↦ ha x) (fun x _ ↦ ha' x) end RCLike section NNReal variable {X A : Type*} [NormedRing A] [StarRing A] [NormedAlgebra ℝ A] [IsometricContinuousFunctionalCalculus ℝ A IsSelfAdjoint] [ContinuousStar A] [PartialOrder A] [StarOrderedRing A] [NonnegSpectrumClass ℝ A] [T2Space A] [IsTopologicalRing A] variable (A) in /-- A version of `continuousOn_cfc` over `ℝ≥0` instead of `RCLike 𝕜`. -/ theorem continuousOn_cfc_nnreal {s : Set ℝ≥0} (hs : IsCompact s) (f : ℝ≥0 → ℝ≥0) (hf : ContinuousOn f s := by cfc_cont_tac) : ContinuousOn (cfc f) {a : A | 0 ≤ a ∧ spectrum ℝ≥0 a ⊆ s} := by have : {a : A | 0 ≤ a ∧ spectrum ℝ≥0 a ⊆ s}.EqOn (cfc f) (cfc (fun x : ℝ ↦ f x.toNNReal)) := fun a ha ↦ cfc_nnreal_eq_real _ _ ha.1 refine ContinuousOn.congr ?_ this replace hf : ContinuousOn (fun x ↦ f x.toNNReal : ℝ → ℝ) (NNReal.toReal '' s) := by apply hf.ofReal_map_toNNReal rw [Set.mapsTo_image_iff] intro x hx simpa refine continuousOn_cfc A (hs.image NNReal.continuous_coe) _ hf |>.mono fun a ha ↦ ?_ simp only [Set.mem_setOf_eq, nonneg_iff_isSelfAdjoint_and_quasispectrumRestricts] at ha ⊢ rw [← SpectrumRestricts] at ha refine ⟨ha.1.1, ?_⟩ rw [← ha.1.2.algebraMap_image] exact Set.image_mono ha.2 open UniformOnFun in /-- Let `s : Set ℝ≥0` be a compact set and consider pairs `(f, a) : (ℝ≥0 → ℝ≥0) × A` where `f` is continuous on `s` and `spectrum ℝ≥0 a ⊆ s` and `0 ≤ a`. Then `cfc` is jointly continuous in both variables (i.e., continuous in its uncurried form) on this set of pairs when the function space is equipped with the topology of uniform convergence on `s`. -/ theorem continuousOn_cfc_nnreal_setProd {s : Set ℝ≥0} (hs : IsCompact s) : ContinuousOn (fun fa : (ℝ≥0 →ᵤ[{s}] ℝ≥0) × A ↦ cfc (toFun {s} fa.1) fa.2) ({f | ContinuousOn (toFun {s} f) s} ×ˢ {a | 0 ≤ a ∧ spectrum ℝ≥0 a ⊆ s}) := continuousOn_prod_of_continuousOn_lipschitzOnWith _ 1 (fun f hf ↦ continuousOn_cfc_nnreal A hs ((toFun {s}) f) hf) (fun a ⟨_, ha'⟩ ↦ lipschitzOnWith_cfc_fun_of_subset a ha') /-- If `f : ℝ≥0 → ℝ≥0` is continuous on a compact set `s` and `a : X → A` tends to `a₀ : A` along a filter `l` (such that eventually `0 ≤ a x` and has spectrum contained in `s`, as does `a₀`), then `fun x ↦ cfc f (a x)` tends to `cfc f a₀`. -/ theorem Filter.Tendsto.cfc_nnreal {s : Set ℝ≥0} (hs : IsCompact s) (f : ℝ≥0 → ℝ≥0) {a : X → A} {a₀ : A} {l : Filter X} (ha_tendsto : Tendsto a l (𝓝 a₀)) (ha : ∀ᶠ x in l, spectrum ℝ≥0 (a x) ⊆ s) (ha' : ∀ᶠ x in l, 0 ≤ a x) (ha₀ : spectrum ℝ≥0 a₀ ⊆ s) (ha₀' : 0 ≤ a₀) (hf : ContinuousOn f s := by cfc_cont_tac) : Tendsto (fun x ↦ cfc f (a x)) l (𝓝 (cfc f a₀)) := by apply continuousOn_cfc_nnreal A hs f |>.continuousWithinAt ⟨ha₀', ha₀⟩ |>.tendsto.comp rw [tendsto_nhdsWithin_iff] exact ⟨ha_tendsto, ha'.and ha⟩ /-- If `f : ℝ≥0 → ℝ≥0` is continuous on a compact set `s` and `a : X → A` is continuous at `x₀`, and eventually `0 ≤ a x` and has spectrum contained in `s`), then `fun x ↦ cfc f (a x)` is continuous at `x₀`. -/ theorem ContinuousAt.cfc_nnreal [TopologicalSpace X] {s : Set ℝ≥0} (hs : IsCompact s) (f : ℝ≥0 → ℝ≥0) {a : X → A} {x₀ : X} (ha_cont : ContinuousAt a x₀) (ha : ∀ᶠ x in 𝓝 x₀, spectrum ℝ≥0 (a x) ⊆ s) (ha' : ∀ᶠ x in 𝓝 x₀, 0 ≤ a x) (hf : ContinuousOn f s := by cfc_cont_tac) : ContinuousAt (fun x ↦ cfc f (a x)) x₀ := ha_cont.tendsto.cfc_nnreal hs f ha ha' ha.self_of_nhds ha'.self_of_nhds /-- If `f : ℝ≥0 → ℝ≥0` is continuous on a compact set `s` and `a : X → A` is continuous at `x₀` within a set `t : Set X`, and eventually `0 ≤ a x` and has spectrum contained in `s`), then `fun x ↦ cfc f (a x)` is continuous at `x₀` within `t`. -/ theorem ContinuousWithinAt.cfc_nnreal [TopologicalSpace X] {s : Set ℝ≥0} (hs : IsCompact s) (f : ℝ≥0 → ℝ≥0) {a : X → A} {x₀ : X} {t : Set X} (hx₀ : x₀ ∈ t) (ha_cont : ContinuousWithinAt a t x₀) (ha : ∀ᶠ x in 𝓝[t] x₀, spectrum ℝ≥0 (a x) ⊆ s) (ha' : ∀ᶠ x in 𝓝[t] x₀, 0 ≤ a x) (hf : ContinuousOn f s := by cfc_cont_tac) : ContinuousWithinAt (fun x ↦ cfc f (a x)) t x₀ := ha_cont.tendsto.cfc_nnreal hs f ha ha' (ha.self_of_nhdsWithin hx₀) (ha'.self_of_nhdsWithin hx₀) /-- Suppose `a : X → Set A` is continuous on `t : Set X` and `0 ≤ a x` for all `x ∈ t`. Suppose further that `s : X → Set ℝ≥0` is a family of sets with `s x` compact when `x ∈ t` such that `s x₀` contains the spectrum of `a x` for all sufficiently close `x ∈ t`. If `f : ℝ≥0 → ℝ≥0` is continuous on `s x`, for each `x ∈ t`, then `fun x ↦ cfc f (a x)` is continuous on `t`. -/ theorem ContinuousOn.cfc_nnreal [TopologicalSpace X] {s : X → Set ℝ≥0} (f : ℝ≥0 → ℝ≥0) {a : X → A} {t : Set X} (hs : ∀ x ∈ t, IsCompact (s x)) (ha_cont : ContinuousOn a t) (ha : ∀ x₀ ∈ t, ∀ᶠ x in 𝓝[t] x₀, spectrum ℝ≥0 (a x) ⊆ s x₀) (ha' : ∀ x ∈ t, 0 ≤ a x) (hf : ∀ x ∈ t, ContinuousOn f (s x) := by cfc_cont_tac) : ContinuousOn (fun x ↦ cfc f (a x)) t := by rw [ContinuousOn] at ha_cont ⊢ refine fun x hx ↦ (ha_cont x hx).cfc_nnreal (hs x hx) f hx ?_ ?_ (hf x hx) all_goals filter_upwards [ha x hx, self_mem_nhdsWithin] with x hx hxt exacts [hx, ha' x hxt] /-- If `f : ℝ≥0 → ℝ≥0` is continuous on a compact set `s` and `a : X → A` is continuous on `t : Set X`, and `0 ≤ a x` and has spectrum contained in `s` for all `x ∈ t`, then `fun x ↦ cfc f (a x)` is continuous on `t`. -/ theorem ContinuousOn.cfc_nnreal' [TopologicalSpace X] {s : Set ℝ≥0} (hs : IsCompact s) (f : ℝ≥0 → ℝ≥0) {a : X → A} {t : Set X} (ha_cont : ContinuousOn a t) (ha : ∀ x ∈ t, spectrum ℝ≥0 (a x) ⊆ s) (ha' : ∀ x ∈ t, 0 ≤ a x) (hf : ContinuousOn f s := by cfc_cont_tac) : ContinuousOn (fun x ↦ cfc f (a x)) t := by refine ContinuousOn.cfc_nnreal _ (fun _ _ ↦ hs) ha_cont (fun _ _ ↦ ?_) ha' filter_upwards [self_mem_nhdsWithin] with x hx exact ha x hx /-- Suppose `a : X → Set A` is a continuous family of nonnegative elements. Suppose further that `s : X → Set ℝ≥0` is a family of compact sets such that `s x₀` contains the spectrum of `a x` for all sufficiently close `x`. If `f : ℝ≥0 → ℝ≥0` is continuous on each `s x`, then `fun x ↦ cfc f (a x)` is continuous. -/ theorem Continuous.cfc_nnreal [TopologicalSpace X] {s : X → Set ℝ≥0} (f : ℝ≥0 → ℝ≥0) {a : X → A} (ha_cont : Continuous a) (hs : ∀ x, IsCompact (s x)) (ha : ∀ x₀, ∀ᶠ x in 𝓝 x₀, spectrum ℝ≥0 (a x) ⊆ s x₀) (hf : ∀ x, ContinuousOn f (s x) := by cfc_cont_tac) (ha' : ∀ x, 0 ≤ a x := by cfc_tac) : Continuous (fun x ↦ cfc f (a x)) := by rw [← continuousOn_univ] at ha_cont ⊢ exact ha_cont.cfc_nnreal f (fun x _ ↦ hs x) (fun x _ ↦ by simpa using ha x) (fun x _ ↦ ha' x) /-- `cfc` is continuous in the variable `a : A` when `s : Set ℝ≥0` is compact and `a` varies over nonnegative elements whose spectrum is contained in `s`, and the function `f` is continuous on `s`. -/ theorem Continuous.cfc_nnreal' [TopologicalSpace X] {s : Set ℝ≥0} (hs : IsCompact s) (f : ℝ≥0 → ℝ≥0) {a : X → A} (ha_cont : Continuous a) (ha : ∀ x, spectrum ℝ≥0 (a x) ⊆ s) (hf : ContinuousOn f s := by cfc_cont_tac) (ha' : ∀ x, 0 ≤ a x := by cfc_tac) : Continuous (fun x ↦ cfc f (a x)) := by rw [← continuousOn_univ] at ha_cont ⊢ exact ha_cont.cfc_nnreal' hs f (fun x _ ↦ ha x) (fun x _ ↦ ha' x) end NNReal end Right end Unital section NonUnital section Left section Generic variable {X R A : Type*} {p : A → Prop} [CommSemiring R] [StarRing R] [MetricSpace R] [Nontrivial R] [IsTopologicalSemiring R] [ContinuousStar R] [NonUnitalRing A] [StarRing A] [TopologicalSpace A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [NonUnitalContinuousFunctionalCalculus R A p] /-- If `F : X → R → R` tends to `f : R → R` uniformly on the spectrum of `a`, and all these functions are continuous on the spectrum and map zero to itself, then `fun x ↦ cfcₙ (F x) a` tends to `cfcₙ f a`. -/ theorem tendsto_cfcₙ_fun {l : Filter X} {F : X → R → R} {f : R → R} {a : A} (h_tendsto : TendstoUniformlyOn F f l (quasispectrum R a)) (hF : ∀ᶠ x in l, ContinuousOn (F x) (quasispectrum R a)) (hF0 : ∀ᶠ x in l, F x 0 = 0) : Tendsto (fun x ↦ cfcₙ (F x) a) l (𝓝 (cfcₙ f a)) := by open scoped NonUnitalContinuousFunctionalCalculus in obtain (rfl | hl) := l.eq_or_neBot · simp have hf := h_tendsto.continuousOn hF have hf0 : f 0 = 0 := Eq.symm <| tendsto_nhds_unique (tendsto_const_nhds.congr' <| .symm hF0) <| h_tendsto.tendsto_at (quasispectrum.zero_mem R a) by_cases ha : p a · let s : Set X := {x | ContinuousOn (F x) (quasispectrum R a) ∧ F x 0 = 0} have hs : s ∈ l := hF.and hF0 rw [← tendsto_comap'_iff (i := ((↑) : s → X)) (by simpa)] conv => enter [1, x] rw [Function.comp_apply, cfcₙ_apply (hf := x.2.1) (hf0 := x.2.2)] rw [cfcₙ_apply ..] apply cfcₙHom_continuous _ |>.tendsto _ |>.comp rw [ContinuousMapZero.isEmbedding_toContinuousMap.isInducing.tendsto_nhds_iff] change Tendsto (fun x : s ↦ (⟨_, x.2.1.restrict⟩ : C(quasispectrum R a, R))) _ (𝓝 ⟨_, hf.restrict⟩) rw [hf.tendsto_restrict_iff_tendstoUniformlyOn (fun x ↦ x.2.1)] intro t simp only [eventually_comap, Subtype.forall] peel h_tendsto t with ht x _ simp_all · simpa [cfcₙ_apply_of_not_predicate a ha] using tendsto_const_nhds /-- If `f : X → R → R` tends to `f x₀` uniformly (along `𝓝 x₀`) on the spectrum of `a`, and each `f x` is continuous on the spectrum of `a` and maps zero to itself, then `fun x ↦ cfcₙ (f x) a` is continuous at `x₀`. -/ theorem continuousAt_cfcₙ_fun [TopologicalSpace X] {f : X → R → R} {a : A} {x₀ : X} (h_tendsto : TendstoUniformlyOn f (f x₀) (𝓝 x₀) (quasispectrum R a)) (hf : ∀ᶠ x in 𝓝 x₀, ContinuousOn (f x) (quasispectrum R a)) (hf0 : ∀ᶠ x in 𝓝 x₀, f x 0 = 0) : ContinuousAt (fun x ↦ cfcₙ (f x) a) x₀ := tendsto_cfcₙ_fun h_tendsto hf hf0 /-- If `f : X → R → R` tends to `f x₀` uniformly (along `𝓝[s] x₀`) on the spectrum of `a`, and eventually each `f x` is continuous on the spectrum of `a` and maps zero to itself, then `fun x ↦ cfcₙ (f x) a` is continuous at `x₀` within `s`. -/ theorem continuousWithinAt_cfcₙ_fun [TopologicalSpace X] {f : X → R → R} {a : A} {x₀ : X} {s : Set X} (h_tendsto : TendstoUniformlyOn f (f x₀) (𝓝[s] x₀) (quasispectrum R a)) (hf : ∀ᶠ x in 𝓝[s] x₀, ContinuousOn (f x) (quasispectrum R a)) (hf0 : ∀ᶠ x in 𝓝[s] x₀, f x 0 = 0 := by cfc_zero_tac) : ContinuousWithinAt (fun x ↦ cfcₙ (f x) a) s x₀ := tendsto_cfcₙ_fun h_tendsto hf hf0 open UniformOnFun in /-- If `f : X → R → R` is continuous on `s : Set X` in the topology on `X → R →ᵤ[{spectrum R a}] → R`, and for each `x ∈ s`, `f x` is continuous on the spectrum and maps zero to itself, then `x ↦ cfcₙ (f x) a` is continuous on `s` also. -/ theorem ContinuousOn.cfcₙ_fun [TopologicalSpace X] {f : X → R → R} {a : A} {s : Set X} (h_cont : ContinuousOn (fun x ↦ ofFun {quasispectrum R a} (f x)) s) (hf : ∀ x ∈ s, ContinuousOn (f x) (quasispectrum R a)) (hf0 : ∀ x ∈ s, f x 0 = 0) : ContinuousOn (fun x ↦ cfcₙ (f x) a) s := by rw [ContinuousOn] at h_cont ⊢ simp only [ContinuousWithinAt, UniformOnFun.tendsto_iff_tendstoUniformlyOn, Set.mem_singleton_iff, Function.comp_def, toFun_ofFun, forall_eq] at h_cont refine fun x hx ↦ continuousWithinAt_cfcₙ_fun (h_cont x hx) ?_ ?_ all_goals filter_upwards [self_mem_nhdsWithin] with x hx exacts [hf x hx, hf0 x hx] open UniformOnFun in /-- If `f : X → R → R` is continuous in the topology on `X → R →ᵤ[{spectrum R a}] → R`, and each `f` is continuous on the spectrum and maps zero to itself, then `x ↦ cfcₙ (f x) a` is continuous. -/ theorem Continuous.cfcₙ_fun [TopologicalSpace X] (f : X → R → R) (a : A) (h_cont : Continuous (fun x ↦ ofFun {quasispectrum R a} (f x))) (hf : ∀ x, ContinuousOn (f x) (quasispectrum R a) := by cfc_cont_tac) (hf0 : ∀ x, f x 0 = 0 := by cfc_zero_tac) : Continuous fun x ↦ cfcₙ (f x) a := by rw [← continuousOn_univ] at h_cont ⊢ exact h_cont.cfcₙ_fun (fun x _ ↦ hf x) (fun x _ ↦ hf0 x) end Generic section Isometric variable {X R A : Type*} {p : A → Prop} [CommSemiring R] [StarRing R] [MetricSpace R] [Nontrivial R] [IsTopologicalSemiring R] [ContinuousStar R] [NonUnitalRing A] [StarRing A] [MetricSpace A] [Module R A] [SMulCommClass R A A] [IsScalarTower R A A] [NonUnitalIsometricContinuousFunctionalCalculus R A p] variable (R) in open UniformOnFun in open scoped NonUnitalContinuousFunctionalCalculus in /-- The function `f ↦ cfcₙ f a` is Lipschitz with constant 1 with respect to supremum metric (on `R →ᵤ[{quasispectrum R a}] R`) on those functions which are continuous on the quasispectrum and map zero to itself. -/ lemma lipschitzOnWith_cfcₙ_fun (a : A) : LipschitzOnWith 1 (fun f ↦ cfcₙ (toFun {quasispectrum R a} f) a) {f | ContinuousOn (toFun {quasispectrum R a} f) (quasispectrum R a) ∧ f 0 = 0} := by by_cases ha : p a · rintro f ⟨hf, hf0⟩ g ⟨hg, hg0⟩ simp only rw [cfcₙ_apply .., cfcₙ_apply .., isometry_cfcₙHom (R := R) a ha |>.edist_eq] simp only [ENNReal.coe_one, one_mul] rw [← ContinuousMapZero.isometry_toContinuousMap.edist_eq, edist_continuousRestrict_of_singleton hf hg] · simpa [cfcₙ_apply_of_not_predicate a ha] using LipschitzWith.const' 0 |>.lipschitzOnWith open UniformOnFun in open scoped ContinuousFunctionalCalculus in /-- The function `f ↦ cfcₙ f a` is Lipschitz with constant 1 with respect to supremum metric (on `R →ᵤ[{s}] R`) on those functions which are continuous on a set `s` containing the quasispectrum and map zero to itself. -/ lemma lipschitzOnWith_cfcₙ_fun_of_subset (a : A) {s : Set R} (hs : quasispectrum R a ⊆ s) : LipschitzOnWith 1 (fun f ↦ cfcₙ (toFun {s} f) a) {f | ContinuousOn (toFun {s} f) (s) ∧ f 0 = 0} := by have h₂ := lipschitzWith_one_ofFun_toFun' (𝔖 := {quasispectrum R a}) (𝔗 := {s}) (β := R) (by simpa) have h₃ := h₂.lipschitzOnWith (s := {f | ContinuousOn (toFun {s} f) (s) ∧ f 0 = 0}) simpa using lipschitzOnWith_cfcₙ_fun R a |>.comp h₃ (fun f ↦ .imp_left fun hf ↦ hf.mono hs) end Isometric end Left section Right section RCLike variable {X 𝕜 A : Type*} {p : A → Prop} [RCLike 𝕜] [NonUnitalNormedRing A] [StarRing A] [NormedSpace 𝕜 A] [IsScalarTower 𝕜 A A] [SMulCommClass 𝕜 A A] [ContinuousStar A] [NonUnitalIsometricContinuousFunctionalCalculus 𝕜 A p] open scoped NonUnitalContinuousFunctionalCalculus ContinuousMapZero in /-- `cfcₙHomSuperset` is continuous in the variable `a : A` when `s : Set 𝕜` is compact and `a` varies over elements whose spectrum is contained in `s`, all of which satisfy the predicate `p`. -/ theorem continuous_cfcₙHomSuperset_left [TopologicalSpace X] {s : Set 𝕜} (hs : IsCompact s) [hs0 : Fact (0 ∈ s)] (f : C(s, 𝕜)₀) {a : X → A} (ha_cont : Continuous a) (ha : ∀ x, quasispectrum 𝕜 (a x) ⊆ s) (ha' : ∀ x, p (a x) := by cfc_tac) : Continuous (fun x ↦ cfcₙHomSuperset (ha' x) (ha x) f) := by have : CompactSpace s := by rwa [isCompact_iff_compactSpace] at hs induction f using ContinuousMapZero.induction_on_of_compact with | zero => simpa [map_zero] using continuous_const | id => simpa only [cfcₙHomSuperset_id] | star_id => simp only [map_star, cfcₙHomSuperset_id]; fun_prop | add f g hf hg => simpa only [map_add] using hf.add hg | mul f g hf hg => simpa only [map_mul] using hf.mul hg | smul r f hf => simpa only [map_smul] using hf.const_smul r | frequently f hf => apply continuous_of_uniform_approx_of_continuous rw [Metric.uniformity_basis_dist_le.forall_iff (by aesop)] intro ε hε simp only [Set.mem_setOf_eq, dist_eq_norm] obtain ⟨g, hg, g_cont⟩ := frequently_iff.mp hf (Metric.closedBall_mem_nhds f hε) simp only [Metric.mem_closedBall, dist_comm g, dist_eq_norm] at hg refine ⟨_, g_cont, fun x ↦ ?_⟩ rw [← map_sub, cfcₙHomSuperset_apply] rw [isometry_cfcₙHom (R := 𝕜) _ (ha' x) |>.norm_map_of_map_zero (map_zero (cfcₙHom (ha' x)))] rw [ContinuousMapZero.norm_def, ContinuousMap.norm_le _ hε.le] at hg ⊢ aesop variable (A) in /-- For `f : 𝕜 → 𝕜` continuous on a set `s` for which `f 0 = 0`, `cfcₙ f` is continuous on the set of `a : A` satisfying the predicate `p` (associated to `𝕜`) and whose `𝕜`-quasispectrum is contained in `s`. -/ theorem continuousOn_cfcₙ {s : Set 𝕜} (hs : IsCompact s) (f : 𝕜 → 𝕜) (hf : ContinuousOn f s := by cfc_cont_tac) (hf0 : f 0 = 0 := by cfc_zero_tac) : ContinuousOn (cfcₙ f · : A → A) {a | p a ∧ quasispectrum 𝕜 a ⊆ s} := by by_cases hs0 : 0 ∈ s · rw [continuousOn_iff_continuous_restrict] convert continuous_cfcₙHomSuperset_left hs (hs0 := ⟨hs0⟩) ⟨⟨_, hf.restrict⟩, hf0⟩ (X := {a : A | p a ∧ quasispectrum 𝕜 a ⊆ s}) continuous_subtype_val (fun x ↦ x.2.2) with x rw [cfcₙHomSuperset_apply, Set.restrict_apply, cfcₙ_apply _ _ (hf.mono x.2.2) hf0 x.2.1] congr! · convert continuousOn_empty _ rw [Set.eq_empty_iff_forall_notMem] exact fun a ha ↦ hs0 <| ha.2 <| quasispectrum.zero_mem 𝕜 a open UniformOnFun in /-- Let `s : Set 𝕜` be a compact set and consider pairs `(f, a) : (𝕜 → 𝕜) × A` where `f` is continuous on `s`, maps zero itself, and `quasispectrum 𝕜 a ⊆ s` and `a` satisfies the predicate `p a` for the continuous functional calculus. Then `cfcₙ` is jointly continuous in both variables (i.e., continuous in its uncurried form) on this set of pairs when the function space is equipped with the topology of uniform convergence on `s`. -/ theorem continuousOn_cfcₙ_setProd {s : Set 𝕜} (hs : IsCompact s) : ContinuousOn (fun fa : (𝕜 →ᵤ[{s}] 𝕜) × A ↦ cfcₙ (toFun {s} fa.1) fa.2) ({f | ContinuousOn (toFun {s} f) s ∧ f 0 = 0} ×ˢ {a | p a ∧ quasispectrum 𝕜 a ⊆ s}) := continuousOn_prod_of_continuousOn_lipschitzOnWith _ 1 (fun f hf ↦ continuousOn_cfcₙ A hs ((toFun {s}) f) hf.1 hf.2) (fun a ⟨_, ha'⟩ ↦ lipschitzOnWith_cfcₙ_fun_of_subset a ha') /-- If `f : 𝕜 → 𝕜` is continuous on a compact set `s` and `f 0 = 0` and `a : X → A` tends to `a₀ : A` along a filter `l` (such that eventually `a x` satisfies the predicate `p` associated to `𝕜` and has quasispectrum contained in `s`, as does `a₀`), then `fun x ↦ cfcₙ f (a x)` tends to `cfcₙ f a₀`. -/ protected theorem Filter.Tendsto.cfcₙ {s : Set 𝕜} (hs : IsCompact s) (f : 𝕜 → 𝕜) {a : X → A} {a₀ : A} {l : Filter X} (ha_tendsto : Tendsto a l (𝓝 a₀)) (ha : ∀ᶠ x in l, quasispectrum 𝕜 (a x) ⊆ s) (ha' : ∀ᶠ x in l, p (a x)) (ha₀ : quasispectrum 𝕜 a₀ ⊆ s) (ha₀' : p a₀) (hf : ContinuousOn f s := by cfc_cont_tac) (hf0 : f 0 = 0 := by cfc_zero_tac) : Tendsto (fun x ↦ cfcₙ f (a x)) l (𝓝 (cfcₙ f a₀)) := by apply continuousOn_cfcₙ A hs f |>.continuousWithinAt ⟨ha₀', ha₀⟩ |>.tendsto.comp rw [tendsto_nhdsWithin_iff] exact ⟨ha_tendsto, ha'.and ha⟩ /-- If `f : 𝕜 → 𝕜` is continuous on a compact set `s` and `f 0 = 0` and `a : X → A` is continuous at `x₀`, and eventually `a x` satisfies the predicate `p` associated to `𝕜` and has quasispectrum contained in `s`), then `fun x ↦ cfcₙ f (a x)` is continuous at `x₀`. -/ protected theorem ContinuousAt.cfcₙ [TopologicalSpace X] {s : Set 𝕜} (hs : IsCompact s) (f : 𝕜 → 𝕜) {a : X → A} {x₀ : X} (ha_cont : ContinuousAt a x₀) (ha : ∀ᶠ x in 𝓝 x₀, quasispectrum 𝕜 (a x) ⊆ s) (ha' : ∀ᶠ x in 𝓝 x₀, p (a x)) (hf : ContinuousOn f s := by cfc_cont_tac) (hf0 : f 0 = 0 := by cfc_zero_tac) : ContinuousAt (fun x ↦ cfcₙ f (a x)) x₀ := ha_cont.tendsto.cfcₙ hs f ha ha' ha.self_of_nhds ha'.self_of_nhds /-- If `f : 𝕜 → 𝕜` is continuous on a compact set `s` and `f 0 = 0` and `a : X → A` is continuous at `x₀` within a set `t : Set X`, and eventually `a x` satisfies the predicate `p` associated to `𝕜` and has quasispectrum contained in `s`), then `fun x ↦ cfcₙ f (a x)` is continuous at `x₀` within `t`. -/ protected theorem ContinuousWithinAt.cfcₙ [TopologicalSpace X] {s : Set 𝕜} (hs : IsCompact s) (f : 𝕜 → 𝕜) {a : X → A} {x₀ : X} {t : Set X} (hx₀ : x₀ ∈ t) (ha_cont : ContinuousWithinAt a t x₀) (ha : ∀ᶠ x in 𝓝[t] x₀, quasispectrum 𝕜 (a x) ⊆ s) (ha' : ∀ᶠ x in 𝓝[t] x₀, p (a x)) (hf : ContinuousOn f s := by cfc_cont_tac) (hf0 : f 0 = 0 := by cfc_zero_tac) : ContinuousWithinAt (fun x ↦ cfcₙ f (a x)) t x₀ := ha_cont.tendsto.cfcₙ hs f ha ha' (ha.self_of_nhdsWithin hx₀) (ha'.self_of_nhdsWithin hx₀) /-- Suppose `a : X → Set A` is continuous on `t : Set X` and `a x` satisfies the predicate `p` for all `x ∈ t`. Suppose further that `s : X → Set 𝕜` is a family of sets with `s x` compact when `x ∈ t` such that `s x₀` contains the spectrum of `a x` for all sufficiently close `x ∈ t`. If `f : 𝕜 → 𝕜` is continuous on `s x` for each `x ∈ t`, and `f 0 = 0` then `fun x ↦ cfcₙ f (a x)` is continuous on `t`. -/ protected theorem ContinuousOn.cfcₙ [TopologicalSpace X] {s : X → Set 𝕜} (f : 𝕜 → 𝕜) {a : X → A} {t : Set X} (hs : ∀ x ∈ t, IsCompact (s x)) (ha_cont : ContinuousOn a t) (ha : ∀ x₀ ∈ t, ∀ᶠ x in 𝓝[t] x₀, quasispectrum 𝕜 (a x) ⊆ s x₀) (ha' : ∀ x ∈ t, p (a x)) (hf : ∀ x ∈ t, ContinuousOn f (s x) := by cfc_cont_tac) (hf0 : f 0 = 0 := by cfc_zero_tac) : ContinuousOn (fun x ↦ cfcₙ f (a x)) t := by rw [ContinuousOn] at ha_cont ⊢ refine fun x hx ↦ (ha_cont x hx).cfcₙ (hs x hx) f hx ?_ ?_ (hf x hx) all_goals filter_upwards [ha x hx, self_mem_nhdsWithin] with x hx hxt exacts [hx, ha' x hxt] /-- If `f : 𝕜 → 𝕜` is continuous on a compact set `s` and `f 0 = 0` and `a : X → A` is continuous on `t : Set X`, and `a x` satisfies the predicate `p` associated to `𝕜` and has quasispectrum contained in `s` for all `x ∈ t`, then `fun x ↦ cfcₙ f (a x)` is continuous on `t`. -/ theorem ContinuousOn.cfcₙ' [TopologicalSpace X] {s : Set 𝕜} (hs : IsCompact s) (f : 𝕜 → 𝕜) {a : X → A} {t : Set X} (ha_cont : ContinuousOn a t) (ha : ∀ x ∈ t, quasispectrum 𝕜 (a x) ⊆ s) (ha' : ∀ x ∈ t, p (a x)) (hf : ContinuousOn f s := by cfc_cont_tac) (hf0 : f 0 = 0 := by cfc_zero_tac) : ContinuousOn (fun x ↦ cfcₙ f (a x)) t := by refine ContinuousOn.cfcₙ _ (fun _ _ ↦ hs) ha_cont (fun _ _ ↦ ?_) ha' filter_upwards [self_mem_nhdsWithin] with x hx exact ha x hx /-- Suppose `a : X → Set A` is continuous and `a x` satisfies the predicate `p` for all `x`. Suppose further that `s : X → Set 𝕜` is a family of compact sets `s x₀` contains the spectrum of `a x` for all sufficiently close `x`. If `f : 𝕜 → 𝕜` is continuous on each `s x` and `f 0 = 0`, then `fun x ↦ cfc f (a x)` is continuous. -/ protected theorem Continuous.cfcₙ [TopologicalSpace X] {s : X → Set 𝕜} (f : 𝕜 → 𝕜) {a : X → A} (ha_cont : Continuous a) (hs : ∀ x, IsCompact (s x)) (ha : ∀ x₀, ∀ᶠ x in 𝓝 x₀, quasispectrum 𝕜 (a x) ⊆ s x₀) (hf : ∀ x, ContinuousOn f (s x) := by cfc_cont_tac) (hf0 : f 0 = 0 := by cfc_zero_tac) (ha' : ∀ x, p (a x) := by cfc_tac) : Continuous (fun x ↦ cfcₙ f (a x)) := by rw [← continuousOn_univ] at ha_cont ⊢ exact ha_cont.cfcₙ f (fun x _ ↦ hs x) (fun x _ ↦ by simpa using ha x) (fun x _ ↦ ha' x) /-- `cfcₙ` is continuous in the variable `a : A` when `s : Set 𝕜` is compact and `a` varies over elements whose quasispectrum is contained in `s`, all of which satisfy the predicate `p`, and the function `f` is continuous `s` and `f 0 = 0`. -/ theorem Continuous.cfcₙ' [TopologicalSpace X] {s : Set 𝕜} (hs : IsCompact s) (f : 𝕜 → 𝕜) {a : X → A} (ha_cont : Continuous a) (ha : ∀ x, quasispectrum 𝕜 (a x) ⊆ s) (hf : ContinuousOn f s := by cfc_cont_tac) (hf0 : f 0 = 0 := by cfc_zero_tac) (ha' : ∀ x, p (a x) := by cfc_tac) : Continuous (fun x ↦ cfcₙ f (a x)) := by rw [← continuousOn_univ] at ha_cont ⊢ exact ha_cont.cfcₙ' hs f (fun x _ ↦ ha x) (fun x _ ↦ ha' x) end RCLike section NNReal variable {X A : Type*} [NonUnitalNormedRing A] [StarRing A] [NormedSpace ℝ A] [IsScalarTower ℝ A A] [SMulCommClass ℝ A A] [ContinuousStar A] [NonUnitalIsometricContinuousFunctionalCalculus ℝ A IsSelfAdjoint] [PartialOrder A] [StarOrderedRing A] [NonnegSpectrumClass ℝ A] [T2Space A] [IsTopologicalRing A] variable (A) in /-- A version of `continuousOn_cfcₙ` over `ℝ≥0` instead of `RCLike 𝕜`. -/ theorem continuousOn_cfcₙ_nnreal {s : Set ℝ≥0} (hs : IsCompact s) (f : ℝ≥0 → ℝ≥0) (hf : ContinuousOn f s := by cfc_cont_tac) (hf0 : f 0 = 0 := by cfc_zero_tac) : ContinuousOn (cfcₙ f · : A → A) {a : A | 0 ≤ a ∧ quasispectrum ℝ≥0 a ⊆ s} := by have : {a : A | 0 ≤ a ∧ quasispectrum ℝ≥0 a ⊆ s}.EqOn (cfcₙ f) (cfcₙ (fun x : ℝ ↦ f x.toNNReal)) := fun a ha ↦ cfcₙ_nnreal_eq_real _ _ ha.1 refine ContinuousOn.congr ?_ this replace hf : ContinuousOn (fun x ↦ f x.toNNReal : ℝ → ℝ) (NNReal.toReal '' s) := by apply hf.ofReal_map_toNNReal rw [Set.mapsTo_image_iff] intro x hx simpa refine continuousOn_cfcₙ A (hs.image NNReal.continuous_coe) _ hf |>.mono fun a ha ↦ ?_ simp only [Set.mem_setOf_eq, nonneg_iff_isSelfAdjoint_and_quasispectrumRestricts] at ha ⊢ refine ⟨ha.1.1, ?_⟩ rw [← ha.1.2.algebraMap_image] exact Set.image_mono ha.2 open UniformOnFun in /-- Let `s : Set ℝ≥0` be a compact set and consider pairs `(f, a) : (ℝ≥0 → ℝ≥0) × A` where `f` is continuous on `s`, maps zero to itself, `spectrum ℝ≥0 a ⊆ s` and `0 ≤ a`. Then `cfcₙ` is jointly continuous in both variables (i.e., continuous in its uncurried form) on this set of pairs when the function space is equipped with the topology of uniform convergence on `s`. -/ theorem continuousOn_cfcₙ_nnreal_setProd {s : Set ℝ≥0} (hs : IsCompact s) : ContinuousOn (fun fa : (ℝ≥0 →ᵤ[{s}] ℝ≥0) × A ↦ cfcₙ (toFun {s} fa.1) fa.2) ({f | ContinuousOn (toFun {s} f) s ∧ f 0 = 0} ×ˢ {a | 0 ≤ a ∧ quasispectrum ℝ≥0 a ⊆ s}) := continuousOn_prod_of_continuousOn_lipschitzOnWith _ 1 (fun f hf ↦ continuousOn_cfcₙ_nnreal A hs ((toFun {s}) f) hf.1 hf.2) (fun a ⟨_, ha'⟩ ↦ lipschitzOnWith_cfcₙ_fun_of_subset a ha') /-- If `f : ℝ≥0 → ℝ≥0` is continuous on a compact set `s` and `f 0 = 0` and `a : X → A` tends to `a₀ : A` along a filter `l` (such that eventually `0 ≤ a x` and has quasispectrum contained in `s`, as does `a₀`), then `fun x ↦ cfcₙ f (a x)` tends to `cfcₙ f a₀`. -/ theorem Filter.Tendsto.cfcₙ_nnreal {s : Set ℝ≥0} (hs : IsCompact s) (f : ℝ≥0 → ℝ≥0) {a : X → A} {a₀ : A} {l : Filter X} (ha_tendsto : Tendsto a l (𝓝 a₀)) (ha : ∀ᶠ x in l, quasispectrum ℝ≥0 (a x) ⊆ s) (ha' : ∀ᶠ x in l, 0 ≤ a x) (ha₀ : quasispectrum ℝ≥0 a₀ ⊆ s) (ha₀' : 0 ≤ a₀) (hf : ContinuousOn f s := by cfc_cont_tac) (hf0 : f 0 = 0 := by cfc_zero_tac) : Tendsto (fun x ↦ cfcₙ f (a x)) l (𝓝 (cfcₙ f a₀)) := by apply continuousOn_cfcₙ_nnreal A hs f |>.continuousWithinAt ⟨ha₀', ha₀⟩ |>.tendsto.comp rw [tendsto_nhdsWithin_iff] exact ⟨ha_tendsto, ha'.and ha⟩ /-- If `f : ℝ≥0 → ℝ≥0` is continuous on a compact set `s` and `f 0 = 0` and `a : X → A` is continuous at `x₀`, and eventually `0 ≤ a x` and has quasispectrum contained in `s`), then `fun x ↦ cfcₙ f (a x)` is continuous at `x₀`. -/ theorem ContinuousAt.cfcₙ_nnreal [TopologicalSpace X] {s : Set ℝ≥0} (hs : IsCompact s) (f : ℝ≥0 → ℝ≥0) {a : X → A} {x₀ : X} (ha_cont : ContinuousAt a x₀) (ha : ∀ᶠ x in 𝓝 x₀, quasispectrum ℝ≥0 (a x) ⊆ s) (ha' : ∀ᶠ x in 𝓝 x₀, 0 ≤ a x) (hf : ContinuousOn f s := by cfc_cont_tac) (hf0 : f 0 = 0 := by cfc_zero_tac) : ContinuousAt (fun x ↦ cfcₙ f (a x)) x₀ := ha_cont.tendsto.cfcₙ_nnreal hs f ha ha' ha.self_of_nhds ha'.self_of_nhds /-- If `f : ℝ≥0 → ℝ≥0` is continuous on a compact set `s` and `f 0 = 0` and `a : X → A` is continuous at `x₀` within a set `t : Set X`, and eventually `0 ≤ a x` and has quasispectrum contained in `s`), then `fun x ↦ cfcₙ f (a x)` is continuous at `x₀` within `t`. -/ theorem ContinuousWithinAt.cfcₙ_nnreal [TopologicalSpace X] {s : Set ℝ≥0} (hs : IsCompact s) (f : ℝ≥0 → ℝ≥0) {a : X → A} {x₀ : X} {t : Set X} (hx₀ : x₀ ∈ t) (ha_cont : ContinuousWithinAt a t x₀) (ha : ∀ᶠ x in 𝓝[t] x₀, quasispectrum ℝ≥0 (a x) ⊆ s) (ha' : ∀ᶠ x in 𝓝[t] x₀, 0 ≤ a x) (hf : ContinuousOn f s := by cfc_cont_tac) (hf0 : f 0 = 0 := by cfc_zero_tac) : ContinuousWithinAt (fun x ↦ cfcₙ f (a x)) t x₀ := ha_cont.tendsto.cfcₙ_nnreal hs f ha ha' (ha.self_of_nhdsWithin hx₀) (ha'.self_of_nhdsWithin hx₀) /-- Suppose `a : X → Set A` is continuous on `t : Set X` and `0 ≤ a x` for all `x ∈ t`. Suppose further that `s : X → Set ℝ≥0` is a family of sets with `s x` compact when `x ∈ t` such that `s x₀` contains the spectrum of `a x` for all sufficiently close `x ∈ t`. If `f : ℝ≥0 → ℝ≥0` is continuous on `s x` for each `x ∈ t` and `f 0 = 0`, then `fun x ↦ cfc f (a x)` is continuous on `t`. -/ theorem ContinuousOn.cfcₙ_nnreal [TopologicalSpace X] {s : X → Set ℝ≥0} (f : ℝ≥0 → ℝ≥0) {a : X → A} {t : Set X} (hs : ∀ x ∈ t, IsCompact (s x)) (ha_cont : ContinuousOn a t) (ha : ∀ x₀ ∈ t, ∀ᶠ x in 𝓝[t] x₀, quasispectrum ℝ≥0 (a x) ⊆ s x₀) (ha' : ∀ x ∈ t, 0 ≤ a x) (hf : ∀ x ∈ t, ContinuousOn f (s x) := by cfc_cont_tac) (hf0 : f 0 = 0 := by cfc_zero_tac) : ContinuousOn (fun x ↦ cfcₙ f (a x)) t := by rw [ContinuousOn] at ha_cont ⊢ refine fun x hx ↦ (ha_cont x hx).cfcₙ_nnreal (hs x hx) f hx ?_ ?_ (hf x hx) all_goals filter_upwards [ha x hx, self_mem_nhdsWithin] with x hx hxt exacts [hx, ha' x hxt] /-- If `f : ℝ≥0 → ℝ≥0` is continuous on a compact set `s` and `f 0 = 0` and `a : X → A` is continuous on `t : Set X`, and `0 ≤ a x` and has quasispectrum contained in `s` for all `x ∈ t`, then `fun x ↦ cfcₙ f (a x)` is continuous on `t`. -/ theorem ContinuousOn.cfcₙ_nnreal' [TopologicalSpace X] {s : Set ℝ≥0} (hs : IsCompact s) (f : ℝ≥0 → ℝ≥0) {a : X → A} {t : Set X} (ha_cont : ContinuousOn a t) (ha : ∀ x ∈ t, quasispectrum ℝ≥0 (a x) ⊆ s) (ha' : ∀ x ∈ t, 0 ≤ a x) (hf : ContinuousOn f s := by cfc_cont_tac) (hf0 : f 0 = 0 := by cfc_zero_tac) : ContinuousOn (fun x ↦ cfcₙ f (a x)) t := by refine ContinuousOn.cfcₙ_nnreal _ (fun _ _ ↦ hs) ha_cont (fun _ _ ↦ ?_) ha' filter_upwards [self_mem_nhdsWithin] with x hx exact ha x hx /-- Suppose `a : X → Set A` is a continuous family of nonnegative elements. Suppose further that `s : X → Set ℝ≥0` is a family of compact sets such that `s x₀` contains the spectrum of `a x` for all sufficiently close `x`. If `f : ℝ≥0 → ℝ≥0` is continuous on each `s x` and `f 0 = 0`, then `fun x ↦ cfc f (a x)` is continuous. -/ theorem Continuous.cfcₙ_nnreal [TopologicalSpace X] {s : X → Set ℝ≥0} (f : ℝ≥0 → ℝ≥0) {a : X → A} (ha_cont : Continuous a) (hs : ∀ x, IsCompact (s x)) (ha : ∀ x₀, ∀ᶠ x in 𝓝 x₀, quasispectrum ℝ≥0 (a x) ⊆ s x₀) (hf : ∀ x, ContinuousOn f (s x) := by cfc_cont_tac) (hf0 : f 0 = 0 := by cfc_zero_tac) (ha' : ∀ x, 0 ≤ a x := by cfc_tac) : Continuous (fun x ↦ cfcₙ f (a x)) := by rw [← continuousOn_univ] at ha_cont ⊢ exact ha_cont.cfcₙ_nnreal f (fun x _ ↦ hs x) (fun x _ ↦ by simpa using ha x) (fun x _ ↦ ha' x) /-- `cfcₙ` is continuous in the variable `a : A` when `s : Set ℝ≥0` is compact and `a` varies over nonnegative elements whose quasispectrum is contained in `s`, and the function `f` is continuous on `s` and `f 0 = 0`. -/ theorem Continuous.cfcₙ_nnreal' [TopologicalSpace X] {s : Set ℝ≥0} (hs : IsCompact s) (f : ℝ≥0 → ℝ≥0) {a : X → A} (ha_cont : Continuous a) (ha : ∀ x, quasispectrum ℝ≥0 (a x) ⊆ s) (hf : ContinuousOn f s := by cfc_cont_tac) (hf0 : f 0 = 0 := by cfc_zero_tac) (ha' : ∀ x, 0 ≤ a x := by cfc_tac) : Continuous (fun x ↦ cfcₙ f (a x)) := by rw [← continuousOn_univ] at ha_cont ⊢ exact ha_cont.cfcₙ_nnreal' hs f (fun x _ ↦ ha x) (fun x _ ↦ ha' x) end NNReal end Right end NonUnital
.lake/packages/mathlib/Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Unitary.lean
import Mathlib.Tactic.Peel import Mathlib.Analysis.CStarAlgebra.ContinuousFunctionalCalculus.Unital import Mathlib.Analysis.Complex.Basic /-! # Conditions on unitary elements imposed by the continuous functional calculus ## Main theorems * `unitary_iff_isStarNormal_and_spectrum_subset_unitary`: An element is unitary if and only if it is star-normal and its spectrum lies on the unit circle. -/ section Generic variable {R A : Type*} {p : A → Prop} [CommRing R] [StarRing R] [MetricSpace R] variable [IsTopologicalRing R] [ContinuousStar R] [TopologicalSpace A] [Ring A] [StarRing A] variable [Algebra R A] [ContinuousFunctionalCalculus R A p] lemma cfc_unitary_iff (f : R → R) (a : A) (ha : p a := by cfc_tac) (hf : ContinuousOn f (spectrum R a) := by cfc_cont_tac) : cfc f a ∈ unitary A ↔ ∀ x ∈ spectrum R a, star (f x) * f x = 1 := by simp only [unitary, Submonoid.mem_mk, Subsemigroup.mem_mk, Set.mem_setOf_eq] rw [← IsStarNormal.cfc_map (p := p) f a |>.star_comm_self |>.eq, and_self, ← cfc_one R a, ← cfc_star, ← cfc_mul .., cfc_eq_cfc_iff_eqOn] exact Iff.rfl end Generic section Complex variable {A : Type*} [TopologicalSpace A] [Ring A] [StarRing A] [Algebra ℂ A] [ContinuousFunctionalCalculus ℂ A IsStarNormal] lemma unitary_iff_isStarNormal_and_spectrum_subset_unitary {u : A} : u ∈ unitary A ↔ IsStarNormal u ∧ spectrum ℂ u ⊆ unitary ℂ := by rw [← and_iff_right_of_imp isStarNormal_of_mem_unitary] refine and_congr_right fun hu ↦ ?_ nth_rw 1 [← cfc_id ℂ u] rw [cfc_unitary_iff id u, Set.subset_def] simp only [id_eq, RCLike.star_def, SetLike.mem_coe, Unitary.mem_iff_star_mul_self] lemma mem_unitary_of_spectrum_subset_unitary {u : A} [IsStarNormal u] (hu : spectrum ℂ u ⊆ unitary ℂ) : u ∈ unitary A := unitary_iff_isStarNormal_and_spectrum_subset_unitary.mpr ⟨‹_›, hu⟩ lemma spectrum_subset_unitary_of_mem_unitary {u : A} (hu : u ∈ unitary A) : spectrum ℂ u ⊆ unitary ℂ := unitary_iff_isStarNormal_and_spectrum_subset_unitary.mp hu |>.right end Complex
.lake/packages/mathlib/Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Range.lean
import Mathlib.Analysis.CStarAlgebra.ContinuousFunctionalCalculus.Instances import Mathlib.Topology.ContinuousMap.ContinuousSqrt /-! # Range of the continuous functional calculus This file contains results about the range of the continuous functional calculus, and consequences thereof. ## Main results * `range_cfcHom` and `range_cfcₙHom`: for `RCLike` scalar rings, the range of the continuous functional calculus homomorphism is the elemental subalgebra generated by the given element. * `range_cfc_nnreal` and `range_cfcₙ_nnreal`: over the scalar semiring `ℝ≥0`, the range of the continuous functional calculus consists of the nonnegative elements in the elemental `ℝ`-algebra generated by the given element. -/ open Topology open scoped CStarAlgebra section Unital section RCLike variable (𝕜 : Type*) {A : Type*} {p : A → Prop} [RCLike 𝕜] [Ring A] [StarRing A] [Algebra 𝕜 A] variable [TopologicalSpace A] [StarModule 𝕜 A] [ContinuousFunctionalCalculus 𝕜 A p] variable [IsTopologicalRing A] [ContinuousStar A] open StarAlgebra open scoped ContinuousFunctionalCalculus in theorem range_cfcHom {a : A} (ha : p a) : (cfcHom ha (R := 𝕜)).range = elemental 𝕜 a := by rw [StarAlgHom.range_eq_map_top, ← ContinuousMap.elemental_id_eq_top, StarAlgebra.elemental, ← StarSubalgebra.topologicalClosure_map _ _ (cfcHom_isClosedEmbedding ha (R := 𝕜)).isClosedMap (cfcHom_continuous ha), StarAlgHom.map_adjoin] congr simpa using cfcHom_id ha lemma range_cfc {a : A} (ha : p a) : Set.range (cfc (R := 𝕜) · a) = elemental 𝕜 a := by rw [range_cfc_eq_range_cfcHom 𝕜 ha, range_cfcHom 𝕜 ha] variable {𝕜} theorem cfcHom_apply_mem_elemental {a : A} (ha : p a) (f : C(spectrum 𝕜 a, 𝕜)) : cfcHom ha f ∈ elemental 𝕜 a := range_cfcHom 𝕜 ha ▸ ⟨f, rfl⟩ @[simp, grind ←] theorem cfc_apply_mem_elemental (f : 𝕜 → 𝕜) (a : A) : cfc f a ∈ elemental 𝕜 a := cfc_cases _ a f (zero_mem _) fun hf ha ↦ cfcHom_apply_mem_elemental ha ⟨_, hf.restrict⟩ end RCLike open scoped NNReal variable {A : Type*} [Ring A] [StarRing A] [Algebra ℝ A] [TopologicalSpace A] variable [ContinuousFunctionalCalculus ℝ A IsSelfAdjoint] [IsTopologicalRing A] [T2Space A] variable [PartialOrder A] [NonnegSpectrumClass ℝ A] [StarOrderedRing A] lemma range_cfc_nnreal_eq_image_cfc_real (a : A) (ha : 0 ≤ a) : Set.range (cfc (R := ℝ≥0) · a) = (cfc · a) '' {f | ∀ x ∈ spectrum ℝ a, 0 ≤ f x} := by ext constructor · rintro ⟨f, rfl⟩ simp only [cfc_nnreal_eq_real f a ha] exact ⟨_, fun _ _ ↦ by positivity, rfl⟩ · rintro ⟨f, hf, rfl⟩ simp only [cfc_real_eq_nnreal a hf] exact ⟨_, rfl⟩ variable [ContinuousStar A] [StarModule ℝ A] lemma range_cfc_nnreal (a : A) (ha : 0 ≤ a) : Set.range (cfc (R := ℝ≥0) · a) = {x | x ∈ StarAlgebra.elemental ℝ a ∧ 0 ≤ x} := by rw [range_cfc_nnreal_eq_image_cfc_real a ha, Set.setOf_and, SetLike.setOf_mem_eq, ← range_cfc _ ha.isSelfAdjoint, Set.inter_comm, ← Set.image_preimage_eq_inter_range] refine Set.Subset.antisymm (Set.image_mono (fun _ ↦ cfc_nonneg)) ?_ rintro _ ⟨f, hf, rfl⟩ simp only [Set.preimage_setOf_eq, Set.mem_setOf_eq, Set.mem_image] at hf ⊢ obtain (⟨h₁, h₂⟩ | h | h) := by simpa only [not_and_or] using em (ContinuousOn f (spectrum ℝ a) ∧ IsSelfAdjoint a) · refine ⟨f, ?_, rfl⟩ rwa [cfc_nonneg_iff f a] at hf · exact ⟨0, by simp, by simp [cfc_apply_of_not_continuousOn a h]⟩ · exact ⟨0, by simp, by simp [cfc_apply_of_not_predicate a h]⟩ end Unital section NonUnital section RCLike variable (𝕜 : Type*) {A : Type*} {p : A → Prop} [RCLike 𝕜] [NonUnitalRing A] [StarRing A] variable [Module 𝕜 A] [IsScalarTower 𝕜 A A] [SMulCommClass 𝕜 A A] variable [TopologicalSpace A] [NonUnitalContinuousFunctionalCalculus 𝕜 A p] variable [ContinuousConstSMul 𝕜 A] [StarModule 𝕜 A] [IsTopologicalRing A] [ContinuousStar A] open NonUnitalStarAlgebra open scoped NonUnitalContinuousFunctionalCalculus in theorem range_cfcₙHom {a : A} (ha : p a) : NonUnitalStarAlgHom.range (cfcₙHom ha (R := 𝕜)) = elemental 𝕜 a := by rw [← NonUnitalStarAlgebra.map_top, ← ContinuousMapZero.elemental_eq_top, NonUnitalStarAlgebra.elemental, ← NonUnitalStarSubalgebra.topologicalClosure_map _ (cfcₙHom_isClosedEmbedding ha (R := 𝕜)).isClosedMap (cfcₙHom_continuous ha), NonUnitalStarAlgHom.map_adjoin] congr simpa using cfcₙHom_id ha theorem range_cfcₙ {a : A} (ha : p a) : Set.range (cfcₙ (R := 𝕜) · a) = elemental 𝕜 a := by rw [range_cfcₙ_eq_range_cfcₙHom 𝕜 ha, range_cfcₙHom 𝕜 ha] variable {𝕜} open scoped ContinuousMapZero theorem cfcₙHom_apply_mem_elemental {a : A} (ha : p a) (f : C(quasispectrum 𝕜 a, 𝕜)₀) : cfcₙHom ha f ∈ elemental 𝕜 a := range_cfcₙHom 𝕜 ha ▸ ⟨f, rfl⟩ @[simp, grind ←] theorem cfcₙ_apply_mem_elemental (f : 𝕜 → 𝕜) (a : A) : cfcₙ f a ∈ elemental 𝕜 a := cfcₙ_cases _ a f (zero_mem _) fun hf hf₀ ha ↦ cfcₙHom_apply_mem_elemental ha ⟨⟨_, hf.restrict⟩, hf₀⟩ end RCLike open scoped NNReal variable {A : Type*} [NonUnitalRing A] [StarRing A] [Module ℝ A] [IsScalarTower ℝ A A] variable [SMulCommClass ℝ A A] [TopologicalSpace A] variable [NonUnitalContinuousFunctionalCalculus ℝ A IsSelfAdjoint] [IsTopologicalRing A] [T2Space A] variable [PartialOrder A] [NonnegSpectrumClass ℝ A] [StarOrderedRing A] lemma range_cfcₙ_nnreal_eq_image_cfcₙ_real (a : A) (ha : 0 ≤ a) : Set.range (cfcₙ (R := ℝ≥0) · a) = (cfcₙ · a) '' {f | ∀ x ∈ quasispectrum ℝ a, 0 ≤ f x} := by ext constructor · rintro ⟨f, rfl⟩ simp only [cfcₙ_nnreal_eq_real f a] exact ⟨_, fun _ _ ↦ by positivity, rfl⟩ · rintro ⟨f, hf, rfl⟩ simp only [cfcₙ_real_eq_nnreal a hf] exact ⟨_, rfl⟩ variable [StarModule ℝ A] [ContinuousStar A] [ContinuousConstSMul ℝ A] lemma range_cfcₙ_nnreal (a : A) (ha : 0 ≤ a) : Set.range (cfcₙ (R := ℝ≥0) · a) = {x | x ∈ NonUnitalStarAlgebra.elemental ℝ a ∧ 0 ≤ x} := by rw [range_cfcₙ_nnreal_eq_image_cfcₙ_real a ha, Set.setOf_and, SetLike.setOf_mem_eq, ← range_cfcₙ _ ha.isSelfAdjoint, Set.inter_comm, ← Set.image_preimage_eq_inter_range] refine Set.Subset.antisymm (Set.image_mono (fun _ ↦ cfcₙ_nonneg)) ?_ rintro _ ⟨f, hf, rfl⟩ simp only [Set.preimage_setOf_eq, Set.mem_setOf_eq, Set.mem_image] at hf ⊢ obtain (⟨h₁, h₂, h₃⟩ | h | h | h) := by simpa only [not_and_or] using em (ContinuousOn f (quasispectrum ℝ a) ∧ f 0 = 0 ∧ IsSelfAdjoint a) · refine ⟨f, ?_, rfl⟩ rwa [cfcₙ_nonneg_iff f a] at hf · exact ⟨0, by simp, by simp [cfcₙ_apply_of_not_continuousOn a h]⟩ · exact ⟨0, by simp, by simp [cfcₙ_apply_of_not_map_zero a h]⟩ · exact ⟨0, by simp, by simp [cfcₙ_apply_of_not_predicate a h]⟩ end NonUnital
.lake/packages/mathlib/Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Note.lean
import Mathlib.Init import Mathlib.Tactic.Basic /-! # Documentation concerning the continuous functional calculus A library note giving advice on developing and using the continuous functional calculus, as well as the organizational structure within Mathlib. -/ library_note2 «continuous functional calculus» /-- # The continuous functional calculus In Mathlib, there are two classes --- `NonUnitalContinuousFunctionalCalculus` and `ContinuousFunctionalCalculus`, indexed by the scalar ring `R` and the predicate `p : A → Prop` which must be satisfied --- which are used to provide the interface to the continuous functional calculus. This allows us to reason about the continuous functional calculus in both unital and non-unital algebras, using functions, `ℂ → ℂ`, `ℝ → ℝ`, or `ℝ≥0 → ℝ≥0`, as appropriate. These classes are designed to be used even in contexts where no norm is present, such as for `Matrix n n ℝ`, and indeed, an instance of `ContinuousFunctionalCalculus ℝ A IsSelfAdjoint` already exists in this context. However, when a norm is present (i.e., in the context of C⋆-algebras), the continuous functional calculus is an isometry. In order not to lose this information, we provide two additional classes `IsometricNonUnitalContinuousFunctionalCalculus` and `IsometricContinuousFunctionalCalculus`, extending the classes above. We encode this as a class for two reasons: 1. to provide a uniform interface for multiple scalar rings 2. to allow for generalization to real C⋆-algebras This means that there are twelve different classes, corresponding to the choices of scalar ring (`ℂ`, `ℝ`, or `ℝ≥0`), unital or non-unital algebras, isometric or not. The relationship between these is documented in the diagram below, with arrows indicating always available instances. The dotted arrow requires the presence of instances `PartialOrder A`, `StarOrderedRing A` and `NonnegSpectrumClass ℝ A`. Note that the instances which change scalar rings occur *within* each class (i.e., `ContinuousFunctionalCalculus`, `IsometricContinuousFunctionalCalculus`, etc.), so a more accurate diagram would have the chain on the left embedded within each node of the graph on the right. ``` ┌─────────┐ ┌──────────────────────┐ │ │ │ │ │ Complex │ │ Isometric unital ├──────────┐ │ │ │ │ │ └────┬────┘ └───────────┬──────────┘ │ │ │ │ │ │ │ ▼ ▼ ▼ ┌─────────┐ ┌──────────────────────┐ ┌────────┐ │ │ │ │ │ │ │ Real │ │ Isometric non-unital │ │ Unital │ │ │ │ │ │ │ └────┬────┘ └───────────┬──────────┘ └────┬───┘ : │ │ : │ │ ▼ ▼ │ ┌─────────┐ ┌──────────────────────┐ │ │ │ │ │ │ │ NNReal │ │ Non-unital │◄─────────┘ │ │ │ │ └─────────┘ └──────────────────────┘ ``` ## Developing general theory When developing general theory of the continuous functional calculus, users should work in the appropriate general class. For example, the positive and negative parts of a selfadjoint element are defined using the continuous functional calculus via the functions `(·⁺ : ℝ → ℝ)` and `(·⁻ : ℝ → ℝ)`. These functions both take the value `0` at `0`, and so work equally well in the non-unital setting. Moreover, the only scalar ring needed is `ℝ`, not `ℂ`. Therefore, the correct context in which to develop the basic theory of positive and negative parts is: ```lean variable {A : Type*} [NonUnitalRing A] [Module ℝ A] [SMulCommClass ℝ A A] [IsScalarTower ℝ A A] [StarRing A] [TopologicalSpace A] [NonUnitalContinuousFunctionalCalculus ℝ A IsSelfAdjoint] ``` One pattern that should *never* be used is to directly assume `ContinuousFunctionalCalculus` (or the non-unital version) over the scalar ring `ℝ≥0`. Doing so only complicates the setup, for no benefit. Indeed, in practice the only available instance of `ContinuousFunctionalCalculus ℝ≥0 A (0 ≤ ·)` is the one stemming from an instance over `ℝ`, along with `NonnegSpectrumClass ℝ A`, `PartialOrder A`, `StarOrderedRing A`. Therefore, directly assuming the `ℝ≥0` version makes Lean do more work in type class inference, and makes the structure of the source code less readable. Instead, the correct pattern is to assume the version over `ℝ`, and then add these extra three classes as needed to get the instance over `ℝ≥0`. There are three questions that an author should ask themselves when developing general theory in order to determine the correct `variable`s to have in context. These are: 1. Does this work for arbitrary scalar (semi)rings? Only `ℂ`, or is `ℝ` sufficient? For arbitrary scalar rings, use `R` with a predicate `p : A → Prop`, and assume that `A` is an `R`-algebra. For `ℂ` use `IsStarNormal` and assume `A` is a `ℂ`-algebra. For `ℝ` use `IsSelfAdjoint` and assume `A` is an `ℝ`-algebra. Reminder, if you need the functional calculus over `ℝ≥0`, simply use the `ℝ` setup with the three extra classes. 2. Does this work in non-unital algebras? This determines whether you should use the unital or `NonUnital` variation, and whether your algebra should be unital or non-unital. 3. Does this require norm properties of the algebra? This determines whether you should use the standard version or the `Isometric` variation. If you are not using the `Isometric` variation, you should generally only assume that `A` is a `TopologicalSpace` (or potentially a topological algebra). If you are using the `Isometric` variation, you should assume that `A` is a `NormedAlgebra` (in the unital case) or a `NormedSpace` (in the non-unital case). Of course, sometimes one needs to have different sections which make different assumptions, even for the same functions considered. For instance, although theory of positive and negative parts should be developed in the maximum generality of non-unital `ℝ`-algebras without a norm, certain results require stronger assumptions. A typical example is that there should be lemmas which say `cfcₙ (·⁺ : ℝ → ℝ) (1 : A) = 1` and `cfcₙ (·⁻ : ℝ → ℝ) (1 : A) = 0`, but obviously these lemmas require `A` to be a unital algebra. For these results (which work over `ℝ`, only in unital algebras, and don't reference the norm), the correct context is (note the unital version of the functional calculus despite the fact that the lemmas are about `cfcₙ`): ```lean variable {A : Type*} [Ring A] [Algebra ℝ A] [StarRing A] [TopologicalSpace A] [ContinuousFunctionalCalculus ℝ A IsSelfAdjoint] ``` The only context in which general theory should be developed with a `NonUnitalCStarAlgebra` or `CStarAlgebra` hypothesis is when the norm structure is required and the only scalar ring which works is `ℂ`. ## Uniqueness Unless you are developing theory over arbitrary scalar rings, it should never be necessary to assume `ContinuousMap.UniqueHom` or `ContinuousMapZero.UniqueHom`, despite the fact that these hypotheses are necessary for certain lemmas (in particular, `cfc_comp`). Over `ℝ` and `ℂ`, this instance should always be available, and for `ℝ≥0`, one needs only to have the additional assumptions `T2Space A` and `IsTopologicalRing A` (as before, the algebra `A` should still be an `ℝ`-algebra). ## Using `autoParam` Mathlib makes heavy use of `autoParam`s in the continuous functional calculus. There are three different tactics which are used: 1. `cfc_tac` for proving goals of the form `IsStarNormal a`, `IsSelfAdjoint a` or `0 ≤ a`. 2. `cfc_cont_tac` for proving goals of the form `ContinuousOn (spectrum R a) f`. 3. `cfc_zero_tac` for proving goals of the form `f 0 = 0`. In general, lemmas about the continuous functional calculus should be written using `autoParam`s wherever possible for these kinds of goals. These arguments should be placed *last*, at least among the explicit arguments. Moreover, if the arguments `f` and `a` cannot be inferred from other explicit arguments (i.e., those which are not `autoParam`s), then they should also be *explicit* rather than implicit, despite the fact that they appear in the types of the `autoParam` arguments. The reason is that it is often necessary to supply these arguments in order for the `autoParam` arguments to fire. As to argument order, we generally prefer functions before elements of the algebra (i.e., `f` and then `a`) to match the order of application (i.e., `cfc f a`). Likewise, we generally place the `autoParam`s for the continuity conditions before the others because these are the most likely to require manual intervention. ## Location in Mathlib The criterion for determining where to place files about general theory of functions pertaining to the continuous functional calculus is whether the import `Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Basic.lean` is needed, which contains the instances of the continuous functional calculus for `CStarAlgebra`, and therefore pulls in many imports. If this import is not needed, then the file should be placed in the directory `Mathlib/Analysis/SpecialFunctions/ContinuousFunctionalCalculus.lean`. If this import is needed then the appropriate location is `Mathlib/Analysis/CStarAlgebra/SpecialFunctions.lean`. If, as is often thecase, some results need the import and others do not, there should be two files, one in each location. -/
.lake/packages/mathlib/Mathlib/Analysis/FunctionalSpaces/SobolevInequality.lean
import Mathlib.Analysis.Calculus.Deriv.Pi import Mathlib.Analysis.InnerProductSpace.EuclideanDist import Mathlib.Analysis.InnerProductSpace.NormPow import Mathlib.Data.Finset.Interval import Mathlib.MeasureTheory.Integral.IntegralEqImproper /-! # Gagliardo-Nirenberg-Sobolev inequality In this file we prove the Gagliardo-Nirenberg-Sobolev inequality. This states that for compactly supported `C¹`-functions between finite-dimensional vector spaces, we can bound the `L^p`-norm of `u` by the `L^q` norm of the derivative of `u`. The bound is up to a constant that is independent of the function `u`. Let `n` be the dimension of the domain. The main step in the proof, which we dubbed the "grid-lines lemma" below, is a complicated inductive argument that involves manipulating an `n+1`-fold iterated integral and a product of `n+2` factors. In each step, one pushes one of the integral inside (all but one of) the factors of the product using Hölder's inequality. The precise formulation of the induction hypothesis (`MeasureTheory.GridLines.T_insert_le_T_lmarginal_singleton`) is tricky, and none of the 5 sources we referenced stated it. In the formalization we use the operation `MeasureTheory.lmarginal` to work with the iterated integrals, and use `MeasureTheory.lmarginal_insert'` to conveniently push one of the integrals inside. The Hölder's inequality step is done using `ENNReal.lintegral_mul_prod_norm_pow_le`. The conclusions of the main results below are an estimation up to a constant multiple. We don't really care about this constant, other than that it only depends on some pieces of data, typically `E`, `μ`, `p` and sometimes also the codomain of `u` or the support of `u`. We state these constants as separate definitions. ## Main results * `MeasureTheory.eLpNorm_le_eLpNorm_fderiv_of_eq`: The bound holds for `1 ≤ p`, `0 < n` and `q⁻¹ = p⁻¹ - n⁻¹` * `MeasureTheory.eLpNorm_le_eLpNorm_fderiv_of_le`: The bound holds when `1 ≤ p < n`, `0 ≤ q` and `p⁻¹ - n⁻¹ ≤ q⁻¹`. Note that in this case the constant depends on the support of `u`. Potentially also useful: * `MeasureTheory.eLpNorm_le_eLpNorm_fderiv_one`: this is the inequality for `q = 1`. In this version, the codomain can be an arbitrary Banach space. * `MeasureTheory.eLpNorm_le_eLpNorm_fderiv_of_eq_inner`: in this version, the codomain is assumed to be a Hilbert space, without restrictions on its dimension. -/ open scoped ENNReal NNReal open Set Function Finset MeasureTheory Measure Filter noncomputable section variable {ι : Type*} local prefix:max "#" => Fintype.card /-! ## The grid-lines lemma -/ variable {A : ι → Type*} [∀ i, MeasurableSpace (A i)] (μ : ∀ i, Measure (A i)) namespace MeasureTheory section DecidableEq variable [DecidableEq ι] namespace GridLines /-- The "grid-lines operation" (not a standard name) which is central in the inductive proof of the Sobolev inequality. For a finite dependent product `Π i : ι, A i` of sigma-finite measure spaces, a finite set `s` of indices from `ι`, and a (later assumed nonnegative) real number `p`, this operation acts on a function `f` from `Π i, A i` into the extended nonnegative reals. The operation is to partially integrate, in the `s` co-ordinates, the function whose value at `x : Π i, A i` is obtained by multiplying a certain power of `f` with the product, for each co-ordinate `i` in `s`, of a certain power of the integral of `f` along the "grid line" in the `i` direction through `x`. We are most interested in this operation when the set `s` is the universe in `ι`, but as a proxy for "induction on dimension" we define it for a general set `s` of co-ordinates: the `s`-grid-lines operation on a function `f` which is constant along the co-ordinates in `sᶜ` is morally (that is, up to type-theoretic nonsense) the same thing as the universe-grid-lines operation on the associated function on the "lower-dimensional" space `Π i : s, A i`. -/ def T (p : ℝ) (f : (∀ i, A i) → ℝ≥0∞) (s : Finset ι) : (∀ i, A i) → ℝ≥0∞ := ∫⋯∫⁻_s, f ^ (1 - (s.card - 1 : ℝ) * p) * ∏ i ∈ s, (∫⋯∫⁻_{i}, f ∂μ) ^ p ∂μ variable {p : ℝ} @[simp] lemma T_univ [Fintype ι] [∀ i, SigmaFinite (μ i)] (f : (∀ i, A i) → ℝ≥0∞) (x : ∀ i, A i) : T μ p f univ x = ∫⁻ (x : ∀ i, A i), (f x ^ (1 - (#ι - 1 : ℝ) * p) * ∏ i : ι, (∫⁻ t : A i, f (update x i t) ∂(μ i)) ^ p) ∂(.pi μ) := by simp [T, lmarginal_singleton] @[simp] lemma T_empty (f : (∀ i, A i) → ℝ≥0∞) (x : ∀ i, A i) : T μ p f ∅ x = f x ^ (1 + p) := by simp [T] /-- The main inductive step in the grid-lines lemma for the Gagliardo-Nirenberg-Sobolev inequality. The grid-lines operation `GridLines.T` on a nonnegative function on a finitary product type is less than or equal to the grid-lines operation of its partial integral in one co-ordinate (the latter intuitively considered as a function on a space "one dimension down"). -/ theorem T_insert_le_T_lmarginal_singleton [∀ i, SigmaFinite (μ i)] (hp₀ : 0 ≤ p) (s : Finset ι) (hp : (s.card : ℝ) * p ≤ 1) (i : ι) (hi : i ∉ s) {f : (∀ i, A i) → ℝ≥0∞} (hf : Measurable f) : T μ p f (insert i s) ≤ T μ p (∫⋯∫⁻_{i}, f ∂μ) s := by /- The proof is a tricky computation that relies on Hölder's inequality at its heart. The left-hand-side is an `|s|+1`-times iterated integral. Let `xᵢ` denote the `i`-th variable. We first push the integral over the `i`-th variable as the innermost integral. This is done in a single step with `MeasureTheory.lmarginal_insert'`, but in fact hides a repeated application of Fubini's theorem. The integrand is a product of `|s|+2` factors, in `|s|+1` of them we integrate over one additional variable. We split off the factor that integrates over `xᵢ`, and apply Hölder's inequality to the remaining factors (whose powers sum exactly to 1). After reordering factors, and combining two factors into one we obtain the right-hand side. -/ calc T μ p f (insert i s) = ∫⋯∫⁻_insert i s, f ^ (1 - (s.card : ℝ) * p) * ∏ j ∈ insert i s, (∫⋯∫⁻_{j}, f ∂μ) ^ p ∂μ := by -- unfold `T` and reformulate the exponents simp_rw [T, card_insert_of_notMem hi] congr! push_cast ring _ = ∫⋯∫⁻_s, (fun x ↦ ∫⁻ (t : A i), (f (update x i t) ^ (1 - (s.card : ℝ) * p) * ∏ j ∈ insert i s, (∫⋯∫⁻_{j}, f ∂μ) (update x i t) ^ p) ∂ (μ i)) ∂μ := by -- pull out the integral over `xᵢ` rw [lmarginal_insert' _ _ hi] · simp only [Pi.mul_apply, Pi.pow_apply, Finset.prod_apply] · change Measurable (fun x ↦ _) simp only [Pi.mul_apply, Pi.pow_apply, Finset.prod_apply] refine (hf.pow_const _).mul <| Finset.measurable_fun_prod _ ?_ exact fun _ _ ↦ hf.lmarginal μ |>.pow_const _ _ ≤ T μ p (∫⋯∫⁻_{i}, f ∂μ) s := lmarginal_mono (s := s) (fun x ↦ ?_) -- The remainder of the computation happens within an `|s|`-fold iterated integral simp only [Pi.mul_apply, Pi.pow_apply, Finset.prod_apply] set X := update x i have hF₁ : ∀ {j : ι}, Measurable fun t ↦ (∫⋯∫⁻_{j}, f ∂μ) (X t) := fun {_} ↦ hf.lmarginal μ |>.comp <| measurable_update _ have hF₀ : Measurable fun t ↦ f (X t) := hf.comp <| measurable_update _ let k : ℝ := s.card have hk' : 0 ≤ 1 - k * p := by linarith only [hp] calc ∫⁻ t, f (X t) ^ (1 - k * p) * ∏ j ∈ insert i s, (∫⋯∫⁻_{j}, f ∂μ) (X t) ^ p ∂ (μ i) = ∫⁻ t, (∫⋯∫⁻_{i}, f ∂μ) (X t) ^ p * (f (X t) ^ (1 - k * p) * ∏ j ∈ s, ((∫⋯∫⁻_{j}, f ∂μ) (X t) ^ p)) ∂(μ i) := by -- rewrite integrand so that `(∫⋯∫⁻_insert i s, f ∂μ) ^ p` comes first clear_value X congr! 2 with t simp_rw [prod_insert hi] ring_nf _ = (∫⋯∫⁻_{i}, f ∂μ) x ^ p * ∫⁻ t, f (X t) ^ (1 - k * p) * ∏ j ∈ s, ((∫⋯∫⁻_{j}, f ∂μ) (X t)) ^ p ∂(μ i) := by -- pull out this constant factor have : ∀ t, (∫⋯∫⁻_{i}, f ∂μ) (X t) = (∫⋯∫⁻_{i}, f ∂μ) x := by intro t rw [lmarginal_update_of_mem] exact Iff.mpr Finset.mem_singleton rfl simp_rw [this] rw [lintegral_const_mul] exact (hF₀.pow_const _).mul <| Finset.measurable_fun_prod _ fun _ _ ↦ hF₁.pow_const _ _ ≤ (∫⋯∫⁻_{i}, f ∂μ) x ^ p * ((∫⁻ t, f (X t) ∂μ i) ^ (1 - k * p) * ∏ j ∈ s, (∫⁻ t, (∫⋯∫⁻_{j}, f ∂μ) (X t) ∂μ i) ^ p) := by -- apply Hölder's inequality gcongr apply ENNReal.lintegral_mul_prod_norm_pow_le · exact hF₀.aemeasurable · intros exact hF₁.aemeasurable · simp only [sum_const, nsmul_eq_mul] ring · exact hk' · exact fun _ _ ↦ hp₀ _ = (∫⋯∫⁻_{i}, f ∂μ) x ^ p * ((∫⋯∫⁻_{i}, f ∂μ) x ^ (1 - k * p) * ∏ j ∈ s, (∫⋯∫⁻_{i, j}, f ∂μ) x ^ p) := by -- absorb the newly-created integrals into `∫⋯∫` congr! 2 · rw [lmarginal_singleton] refine prod_congr rfl fun j hj => ?_ have hi' : i ∉ ({j} : Finset ι) := by simp only [Finset.mem_singleton] at hj ⊢ exact fun h ↦ hi (h ▸ hj) rw [lmarginal_insert _ hf hi'] _ = (∫⋯∫⁻_{i}, f ∂μ) x ^ (p + (1 - k * p)) * ∏ j ∈ s, (∫⋯∫⁻_{i, j}, f ∂μ) x ^ p := by -- combine two `(∫⋯∫⁻_insert i s, f ∂μ) x` terms rw [ENNReal.rpow_add_of_nonneg] · ring · exact hp₀ · exact hk' _ ≤ (∫⋯∫⁻_{i}, f ∂μ) x ^ (1 - (s.card - 1 : ℝ) * p) * ∏ j ∈ s, (∫⋯∫⁻_{j}, (∫⋯∫⁻_{i}, f ∂μ) ∂μ) x ^ p := by -- identify the result with the RHS integrand congr! 2 with j hj · ring · congr! 1 rw [← lmarginal_union μ f hf] · congr rw [Finset.union_comm] rfl · rw [Finset.disjoint_singleton] simp only at hj exact fun h ↦ hi (h ▸ hj) /-- Auxiliary result for the grid-lines lemma. Given a nonnegative function on a finitary product type indexed by `ι`, and a set `s` in `ι`, consider partially integrating over the variables in `sᶜ` and performing the "grid-lines operation" (see `GridLines.T`) to the resulting function in the variables `s`. This theorem states that this operation decreases as the number of grid-lines taken increases. -/ theorem T_lmarginal_antitone [Fintype ι] [∀ i, SigmaFinite (μ i)] (hp₀ : 0 ≤ p) (hp : (#ι - 1 : ℝ) * p ≤ 1) {f : (∀ i, A i) → ℝ≥0∞} (hf : Measurable f) : Antitone (fun s ↦ T μ p (∫⋯∫⁻_sᶜ, f ∂μ) s) := by -- Reformulate (by induction): a function is decreasing on `Finset ι` if it decreases under the -- insertion of any element to any set. rw [Finset.antitone_iff_forall_insert_le] intro s i hi -- apply the lemma designed to encapsulate the inductive step convert T_insert_le_T_lmarginal_singleton μ hp₀ s ?_ i hi (hf.lmarginal μ) using 2 · rw [← lmarginal_union μ f hf] · rw [← insert_compl_insert hi] rfl rw [Finset.disjoint_singleton_left, notMem_compl] exact mem_insert_self i s · -- the main nontrivial point is to check that an exponent `p` satisfying `0 ≤ p` and -- `(#ι - 1) * p ≤ 1` is in the valid range for the inductive-step lemma refine le_trans ?_ hp gcongr suffices (s.card : ℝ) + 1 ≤ #ι by linarith rw [← card_add_card_compl s] norm_cast gcongr have hi' : sᶜ.Nonempty := ⟨i, by rwa [Finset.mem_compl]⟩ rwa [← card_pos] at hi' end GridLines /-- The "grid-lines lemma" (not a standard name), stated with a general parameter `p` as the exponent. Compare with `lintegral_prod_lintegral_pow_le`. For any finite dependent product `Π i : ι, A i` of sigma-finite measure spaces, for any nonnegative real number `p` such that `(#ι - 1) * p ≤ 1`, for any function `f` from `Π i, A i` into the extended nonnegative reals, we consider an associated "grid-lines quantity", the integral of an associated function from `Π i, A i` into the extended nonnegative reals. The value of this function at `x : Π i, A i` is obtained by multiplying a certain power of `f` with the product, for each co-ordinate `i`, of a certain power of the integral of `f` along the "grid line" in the `i` direction through `x`. This lemma bounds the Lebesgue integral of the grid-lines quantity by a power of the Lebesgue integral of `f`. -/ theorem lintegral_mul_prod_lintegral_pow_le [Fintype ι] [∀ i, SigmaFinite (μ i)] {p : ℝ} (hp₀ : 0 ≤ p) (hp : (#ι - 1 : ℝ) * p ≤ 1) {f : (∀ i : ι, A i) → ℝ≥0∞} (hf : Measurable f) : ∫⁻ x, f x ^ (1 - (#ι - 1 : ℝ) * p) * ∏ i, (∫⁻ xᵢ, f (update x i xᵢ) ∂μ i) ^ p ∂.pi μ ≤ (∫⁻ x, f x ∂.pi μ) ^ (1 + p) := by cases isEmpty_or_nonempty (∀ i, A i) · simp_rw [lintegral_of_isEmpty]; refine zero_le _ inhabit ∀ i, A i have H : (∅ : Finset ι) ≤ Finset.univ := Finset.empty_subset _ simpa [lmarginal_univ] using GridLines.T_lmarginal_antitone μ hp₀ hp hf H default /-- Special case of the grid-lines lemma `lintegral_mul_prod_lintegral_pow_le`, taking the extremal exponent `p = (#ι - 1)⁻¹`. -/ theorem lintegral_prod_lintegral_pow_le [Fintype ι] [∀ i, SigmaFinite (μ i)] {p : ℝ} (hp : Real.HolderConjugate #ι p) {f} (hf : Measurable f) : ∫⁻ x, ∏ i, (∫⁻ xᵢ, f (update x i xᵢ) ∂μ i) ^ ((1 : ℝ) / (#ι - 1 : ℝ)) ∂.pi μ ≤ (∫⁻ x, f x ∂.pi μ) ^ p := by have : Nontrivial ι := Fintype.one_lt_card_iff_nontrivial.mp (by exact_mod_cast hp.lt) have h0 : (1 : ℝ) < #ι := by norm_cast; exact Fintype.one_lt_card have h1 : (0 : ℝ) < #ι - 1 := by linarith have h2 : 0 ≤ ((1 : ℝ) / (#ι - 1 : ℝ)) := by positivity have h3 : (#ι - 1 : ℝ) * ((1 : ℝ) / (#ι - 1 : ℝ)) ≤ 1 := by field_simp; rfl have h4 : p = 1 + 1 / (↑#ι - 1) := by simp [field]; rw [mul_comm, hp.sub_one_mul_conj] rw [h4] convert lintegral_mul_prod_lintegral_pow_le μ h2 h3 hf using 2 field_simp simp end DecidableEq /-! ## The Gagliardo-Nirenberg-Sobolev inequality -/ variable {F : Type*} [NormedAddCommGroup F] [NormedSpace ℝ F] /-- The **Gagliardo-Nirenberg-Sobolev inequality**. Let `u` be a continuously differentiable compactly-supported function `u` on `ℝⁿ`, for `n ≥ 2`. (More literally we encode `ℝⁿ` as `ι → ℝ` where `n := #ι` is finite and at least 2.) Then the Lebesgue integral of the pointwise expression `|u x| ^ (n / (n - 1))` is bounded above by the `n / (n - 1)`-th power of the Lebesgue integral of the Fréchet derivative of `u`. For a basis-free version, see `lintegral_pow_le_pow_lintegral_fderiv`. -/ theorem lintegral_pow_le_pow_lintegral_fderiv_aux [Fintype ι] {p : ℝ} (hp : Real.HolderConjugate #ι p) {u : (ι → ℝ) → F} (hu : ContDiff ℝ 1 u) (h2u : HasCompactSupport u) : ∫⁻ x, ‖u x‖ₑ ^ p ≤ (∫⁻ x, ‖fderiv ℝ u x‖ₑ) ^ p := by classical /- For a function `f` in one variable and `t ∈ ℝ` we have `|f(t)| = `|∫_{-∞}^t Df(s)∂s| ≤ ∫_ℝ |Df(s)| ∂s` where we use the fundamental theorem of calculus. For each `x ∈ ℝⁿ` we let `u` vary in one of the `n` coordinates and apply the inequality above. By taking the product over these `n` factors, raising them to the power `(n-1)⁻¹` and integrating, we get the inequality `∫ |u| ^ (n/(n-1)) ≤ ∫ x, ∏ i, (∫ xᵢ, |Du(update x i xᵢ)|)^(n-1)⁻¹`. The result then follows from the grid-lines lemma. -/ have : (1 : ℝ) ≤ ↑#ι - 1 := by have hι : (2 : ℝ) ≤ #ι := by exact_mod_cast hp.lt linarith calc ∫⁻ x, ‖u x‖ₑ ^ p = ∫⁻ x, (‖u x‖ₑ ^ (1 / (#ι - 1 : ℝ))) ^ (#ι : ℝ) := by -- a little algebraic manipulation of the exponent congr! 2 with x rw [← ENNReal.rpow_mul, hp.conjugate_eq] field_simp _ = ∫⁻ x, ∏ _i : ι, ‖u x‖ₑ ^ (1 / (#ι - 1 : ℝ)) := by -- express the left-hand integrand as a product of identical factors congr! 2 with x simp_rw [prod_const] norm_cast _ ≤ ∫⁻ x, ∏ i, (∫⁻ xᵢ, ‖fderiv ℝ u (update x i xᵢ)‖ₑ) ^ ((1 : ℝ) / (#ι - 1 : ℝ)) := ?_ _ ≤ (∫⁻ x, ‖fderiv ℝ u x‖ₑ) ^ p := by -- apply the grid-lines lemma apply lintegral_prod_lintegral_pow_le _ hp fun_prop -- we estimate |u x| using the fundamental theorem of calculus. gcongr with x i calc ‖u x‖ₑ _ ≤ ∫⁻ xᵢ in Iic (x i), ‖deriv (u ∘ update x i) xᵢ‖ₑ := by apply le_trans (by simp) (HasCompactSupport.enorm_le_lintegral_Ici_deriv _ _ _) · exact hu.comp (by convert contDiff_update 1 x i) · exact h2u.comp_isClosedEmbedding (isClosedEmbedding_update x i) _ ≤ ∫⁻ xᵢ, ‖fderiv ℝ u (update x i xᵢ)‖ₑ := ?_ gcongr with y · exact Measure.restrict_le_self -- bound the derivative which appears calc ‖deriv (u ∘ update x i) y‖ₑ = ‖fderiv ℝ u (update x i y) (deriv (update x i) y)‖ₑ := by rw [fderiv_comp_deriv _ (hu.differentiable le_rfl).differentiableAt (hasDerivAt_update x i y).differentiableAt] _ ≤ ‖fderiv ℝ u (update x i y)‖ₑ * ‖deriv (update x i) y‖ₑ := ContinuousLinearMap.le_opENorm _ _ _ ≤ ‖fderiv ℝ u (update x i y)‖ₑ := by simp [deriv_update, Pi.enorm_single] variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [MeasurableSpace E] [BorelSpace E] [FiniteDimensional ℝ E] (μ : Measure E) [IsAddHaarMeasure μ] open Module /-- The constant factor occurring in the conclusion of `lintegral_pow_le_pow_lintegral_fderiv`. It only depends on `E`, `μ` and `p`. It is determined by the ratio of the measures on `E` and `ℝⁿ` and the operator norm of a chosen equivalence `E ≃ ℝⁿ` (raised to suitable powers involving `p`). -/ irreducible_def lintegralPowLePowLIntegralFDerivConst (p : ℝ) : ℝ≥0 := by let ι := Fin (finrank ℝ E) have : finrank ℝ E = finrank ℝ (ι → ℝ) := by rw [finrank_fintype_fun_eq_card, Fintype.card_fin (finrank ℝ E)] let e : E ≃L[ℝ] ι → ℝ := ContinuousLinearEquiv.ofFinrankEq this let c := addHaarScalarFactor μ ((volume : Measure (ι → ℝ)).map e.symm) exact (c * ‖(e.symm : (ι → ℝ) →L[ℝ] E)‖₊ ^ p) * (c ^ p)⁻¹ /-- The **Gagliardo-Nirenberg-Sobolev inequality**. Let `u` be a continuously differentiable compactly-supported function `u` on a normed space `E` of finite dimension `n ≥ 2`, equipped with Haar measure. Then the Lebesgue integral of the pointwise expression `|u x| ^ (n / (n - 1))` is bounded above by a constant times the `n / (n - 1)`-th power of the Lebesgue integral of the Fréchet derivative of `u`. -/ theorem lintegral_pow_le_pow_lintegral_fderiv {u : E → F} (hu : ContDiff ℝ 1 u) (h2u : HasCompactSupport u) {p : ℝ} (hp : Real.HolderConjugate (finrank ℝ E) p) : ∫⁻ x, ‖u x‖ₑ ^ p ∂μ ≤ lintegralPowLePowLIntegralFDerivConst μ p * (∫⁻ x, ‖fderiv ℝ u x‖ₑ ∂μ) ^ p := by /- We reduce to the case where `E` is `ℝⁿ`, for which we have already proved the result using an explicit basis in `MeasureTheory.lintegral_pow_le_pow_lintegral_fderiv_aux`. This proof is not too hard, but takes quite some steps, reasoning about the equivalence `e : E ≃ ℝⁿ`, relating the measures on each sides of the equivalence, and estimating the derivative using the chain rule. -/ set C := lintegralPowLePowLIntegralFDerivConst μ p let ι := Fin (finrank ℝ E) have hιcard : #ι = finrank ℝ E := Fintype.card_fin (finrank ℝ E) have : finrank ℝ E = finrank ℝ (ι → ℝ) := by simp [hιcard] let e : E ≃L[ℝ] ι → ℝ := ContinuousLinearEquiv.ofFinrankEq this have hp : Real.HolderConjugate #ι p := by rwa [hιcard] have h0p : 0 ≤ p := hp.symm.nonneg let c := addHaarScalarFactor μ ((volume : Measure (ι → ℝ)).map e.symm) have hc : 0 < c := addHaarScalarFactor_pos_of_isAddHaarMeasure .. have h2c : μ = c • ((volume : Measure (ι → ℝ)).map e.symm) := isAddLeftInvariant_eq_smul .. have h3c : (c : ℝ≥0∞) ≠ 0 := by simp_rw [ne_eq, ENNReal.coe_eq_zero, hc.ne', not_false_eq_true] have h0C : C = (c * ‖(e.symm : (ι → ℝ) →L[ℝ] E)‖₊ ^ p) * (c ^ p)⁻¹ := by simp_rw [c, ι, C, e, lintegralPowLePowLIntegralFDerivConst] have hC : C * c ^ p = c * ‖(e.symm : (ι → ℝ) →L[ℝ] E)‖₊ ^ p := by rw [h0C, inv_mul_cancel_right₀ (NNReal.rpow_pos hc).ne'] simp only [h2c, ENNReal.smul_def, lintegral_smul_measure, smul_eq_mul] let v : (ι → ℝ) → F := u ∘ e.symm have hv : ContDiff ℝ 1 v := hu.comp e.symm.contDiff have h2v : HasCompactSupport v := h2u.comp_homeomorph e.symm.toHomeomorph have := calc ∫⁻ x, ‖u x‖ₑ ^ p ∂(volume : Measure (ι → ℝ)).map e.symm = ∫⁻ y, ‖v y‖ₑ ^ p := by refine lintegral_map ?_ e.symm.continuous.measurable borelize F exact hu.continuous.measurable.nnnorm.coe_nnreal_ennreal.pow_const _ _ ≤ (∫⁻ y, ‖fderiv ℝ v y‖ₑ) ^ p := lintegral_pow_le_pow_lintegral_fderiv_aux hp hv h2v _ = (∫⁻ y, ‖(fderiv ℝ u (e.symm y)).comp (fderiv ℝ e.symm y)‖ₑ) ^ p := by congr! with y apply fderiv_comp _ (hu.differentiable le_rfl _) exact e.symm.differentiableAt _ ≤ (∫⁻ y, ‖fderiv ℝ u (e.symm y)‖ₑ * ‖(e.symm : (ι → ℝ) →L[ℝ] E)‖ₑ) ^ p := by gcongr with y rw [e.symm.fderiv] apply ContinuousLinearMap.opENorm_comp_le _ = (‖(e.symm : (ι → ℝ) →L[ℝ] E)‖ₑ * ∫⁻ y, ‖fderiv ℝ u (e.symm y)‖ₑ) ^ p := by rw [lintegral_mul_const, mul_comm] fun_prop _ = (‖(e.symm : (ι → ℝ) →L[ℝ] E)‖₊ ^ p : ℝ≥0) * (∫⁻ y, ‖fderiv ℝ u (e.symm y)‖ₑ) ^ p := by rw [ENNReal.mul_rpow_of_nonneg _ _ h0p, enorm_eq_nnnorm, ← ENNReal.coe_rpow_of_nonneg _ h0p] _ = (‖(e.symm : (ι → ℝ) →L[ℝ] E)‖₊ ^ p : ℝ≥0) * (∫⁻ x, ‖fderiv ℝ u x‖ₑ ∂(volume : Measure (ι → ℝ)).map e.symm) ^ p := by congr rw [lintegral_map _ e.symm.continuous.measurable] fun_prop rw [← ENNReal.mul_le_mul_left h3c ENNReal.coe_ne_top, ← mul_assoc, ← ENNReal.coe_mul, ← hC, ENNReal.coe_mul] at this rw [ENNReal.mul_rpow_of_nonneg _ _ h0p, ← mul_assoc, ← ENNReal.coe_rpow_of_ne_zero hc.ne'] exact this /-- The constant factor occurring in the conclusion of `eLpNorm_le_eLpNorm_fderiv_one`. It only depends on `E`, `μ` and `p`. -/ irreducible_def eLpNormLESNormFDerivOneConst (p : ℝ) : ℝ≥0 := lintegralPowLePowLIntegralFDerivConst μ p ^ p⁻¹ /-- The **Gagliardo-Nirenberg-Sobolev inequality**. Let `u` be a continuously differentiable compactly-supported function `u` on a normed space `E` of finite dimension `n ≥ 2`, equipped with Haar measure. Then the `Lᵖ` norm of `u`, where `p := n / (n - 1)`, is bounded above by a constant times the `L¹` norm of the Fréchet derivative of `u`. -/ theorem eLpNorm_le_eLpNorm_fderiv_one {u : E → F} (hu : ContDiff ℝ 1 u) (h2u : HasCompactSupport u) {p : ℝ≥0} (hp : NNReal.HolderConjugate (finrank ℝ E) p) : eLpNorm u p μ ≤ eLpNormLESNormFDerivOneConst μ p * eLpNorm (fderiv ℝ u) 1 μ := by have h0p : 0 < (p : ℝ) := hp.coe.symm.pos rw [eLpNorm_one_eq_lintegral_enorm, ← ENNReal.rpow_le_rpow_iff h0p, ENNReal.mul_rpow_of_nonneg _ _ h0p.le, ← ENNReal.coe_rpow_of_nonneg _ h0p.le, eLpNormLESNormFDerivOneConst, ← NNReal.rpow_mul, eLpNorm_nnreal_pow_eq_lintegral hp.symm.pos.ne', inv_mul_cancel₀ h0p.ne', NNReal.rpow_one] exact lintegral_pow_le_pow_lintegral_fderiv μ hu h2u hp.coe /-- The constant factor occurring in the conclusion of `eLpNorm_le_eLpNorm_fderiv_of_eq_inner`. It only depends on `E`, `μ` and `p`. -/ def eLpNormLESNormFDerivOfEqInnerConst (p : ℝ) : ℝ≥0 := let n := finrank ℝ E eLpNormLESNormFDerivOneConst μ (NNReal.conjExponent n) * (p * (n - 1) / (n - p)).toNNReal variable {F' : Type*} [NormedAddCommGroup F'] [InnerProductSpace ℝ F'] /-- The **Gagliardo-Nirenberg-Sobolev inequality**. Let `u` be a continuously differentiable compactly-supported function `u` on a normed space `E` of finite dimension `n`, equipped with Haar measure, let `1 ≤ p < n` and let `p'⁻¹ := p⁻¹ - n⁻¹`. Then the `Lᵖ'` norm of `u` is bounded above by a constant times the `Lᵖ` norm of the Fréchet derivative of `u`. Note: The codomain of `u` needs to be a Hilbert space. -/ theorem eLpNorm_le_eLpNorm_fderiv_of_eq_inner {u : E → F'} (hu : ContDiff ℝ 1 u) (h2u : HasCompactSupport u) {p p' : ℝ≥0} (hp : 1 ≤ p) (hn : 0 < finrank ℝ E) (hp' : (p' : ℝ)⁻¹ = p⁻¹ - (finrank ℝ E : ℝ)⁻¹) : eLpNorm u p' μ ≤ eLpNormLESNormFDerivOfEqInnerConst μ p * eLpNorm (fderiv ℝ u) p μ := by /- Here we derive the GNS-inequality for `p ≥ 1` from the version with `p = 1`. For `p > 1` we apply the previous version to the function `|u|^γ` for a suitably chosen `γ`. The proof requires that `x ↦ |x|^p` is smooth in the codomain, so we require that it is a Hilbert space. -/ by_cases hp'0 : p' = 0 · simp [hp'0] set n := finrank ℝ E let n' := NNReal.conjExponent n have h2p : (p : ℝ) < n := by have : 0 < p⁻¹ - (n : ℝ)⁻¹ := NNReal.coe_lt_coe.mpr (pos_iff_ne_zero.mpr (inv_ne_zero hp'0)) |>.trans_eq hp' rwa [NNReal.coe_inv, sub_pos, inv_lt_inv₀ _ (zero_lt_one.trans_le (NNReal.coe_le_coe.mpr hp))] at this exact_mod_cast hn have h0n : 2 ≤ n := Nat.succ_le_of_lt <| Nat.one_lt_cast.mp <| hp.trans_lt h2p have hn : NNReal.HolderConjugate n n' := .conjExponent (by norm_cast) have h1n : 1 ≤ (n : ℝ≥0) := hn.lt.le have h2n : (0 : ℝ) < n - 1 := by simp_rw [sub_pos]; exact hn.coe.lt have hnp : (0 : ℝ) < n - p := by simp_rw [sub_pos]; exact h2p rcases hp.eq_or_lt with rfl | hp -- the case `p = 1` · convert eLpNorm_le_eLpNorm_fderiv_one μ hu h2u hn using 2 · suffices (p' : ℝ) = n' by simpa using this rw [← inv_inj, hp'] simp [field, n', NNReal.conjExponent, *] · norm_cast simp_rw [n', n, eLpNormLESNormFDerivOfEqInnerConst] simp only [n, NNReal.coe_one] at hnp field_simp simp -- the case `p > 1` let q := Real.conjExponent p have hq : Real.HolderConjugate p q := .conjExponent hp have h0p : p ≠ 0 := zero_lt_one.trans hp |>.ne' have h1p : (p : ℝ) ≠ 1 := hq.lt.ne' have h3p : (p : ℝ) - 1 ≠ 0 := sub_ne_zero_of_ne h1p have h2q : 1 / n' - 1 / q = 1 / p' := by simp_rw -zeta [one_div, hp'] rw [← hq.one_sub_inv, ← hn.coe.one_sub_inv, sub_sub_sub_cancel_left] simp only [NNReal.coe_natCast, NNReal.coe_inv] let γ : ℝ≥0 := ⟨p * (n - 1) / (n - p), by positivity⟩ have h0γ : (γ : ℝ) = p * (n - 1) / (n - p) := rfl have h1γ : 1 < (γ : ℝ) := by rwa [h0γ, one_lt_div hnp, mul_sub, mul_one, sub_lt_sub_iff_right, lt_mul_iff_one_lt_left] exact hn.coe.pos have h2γ : γ * n' = p' := by rw [← NNReal.coe_inj, ← inv_inj, hp', NNReal.coe_mul, h0γ, hn.coe.conjugate_eq] simp [field] have h3γ : (γ - 1) * q = p' := by rw [← inv_inj, hp', h0γ, hq.conjugate_eq] have : (p : ℝ) * (n - 1) - (n - p) = n * (p - 1) := by ring simp [field, this] have h4γ : (γ : ℝ) ≠ 0 := (zero_lt_one.trans h1γ).ne' by_cases h3u : ∫⁻ x, ‖u x‖ₑ ^ (p' : ℝ) ∂μ = 0 · rw [eLpNorm_nnreal_eq_lintegral hp'0, h3u, ENNReal.zero_rpow_of_pos] <;> positivity have h4u : ∫⁻ x, ‖u x‖ₑ ^ (p' : ℝ) ∂μ ≠ ∞ := by refine lintegral_rpow_enorm_lt_top_of_eLpNorm'_lt_top ((NNReal.coe_pos.trans pos_iff_ne_zero).mpr hp'0) ?_ |>.ne rw [← eLpNorm_nnreal_eq_eLpNorm' hp'0] exact hu.continuous.memLp_of_hasCompactSupport (μ := μ) h2u |>.eLpNorm_lt_top have h5u : (∫⁻ x, ‖u x‖ₑ ^ (p' : ℝ) ∂μ) ^ (1 / q) ≠ 0 := ENNReal.rpow_pos (pos_iff_ne_zero.mpr h3u) h4u |>.ne' have h6u : (∫⁻ x, ‖u x‖ₑ ^ (p' : ℝ) ∂μ) ^ (1 / q) ≠ ∞ := by finiteness have h7u := hu.continuous -- for fun_prop let v : E → ℝ := fun x ↦ ‖u x‖ ^ (γ : ℝ) have hv : ContDiff ℝ 1 v := hu.norm_rpow h1γ have h2v : HasCompactSupport v := h2u.norm.rpow_const h4γ set C := eLpNormLESNormFDerivOneConst μ n' have := calc (∫⁻ x, ‖u x‖ₑ ^ (p' : ℝ) ∂μ) ^ (1 / (n' : ℝ)) = eLpNorm v n' μ := by rw [← h2γ, eLpNorm_nnreal_eq_lintegral hn.symm.pos.ne'] simp (discharger := positivity) [v, Real.enorm_rpow_of_nonneg, ENNReal.rpow_mul] _ ≤ C * eLpNorm (fderiv ℝ v) 1 μ := eLpNorm_le_eLpNorm_fderiv_one μ hv h2v hn _ = C * ∫⁻ x, ‖fderiv ℝ v x‖ₑ ∂μ := by rw [eLpNorm_one_eq_lintegral_enorm] _ ≤ C * γ * ∫⁻ x, ‖u x‖ₑ ^ ((γ : ℝ) - 1) * ‖fderiv ℝ u x‖ₑ ∂μ := by rw [mul_assoc, ← lintegral_const_mul γ] · gcongr simp_rw [← mul_assoc] exact enorm_fderiv_norm_rpow_le (hu.differentiable le_rfl) h1γ dsimp [enorm] fun_prop _ ≤ C * γ * ((∫⁻ x, ‖u x‖ₑ ^ (p' : ℝ) ∂μ) ^ (1 / q) * (∫⁻ x, ‖fderiv ℝ u x‖ₑ ^ (p : ℝ) ∂μ) ^ (1 / (p : ℝ))) := by gcongr convert ENNReal.lintegral_mul_le_Lp_mul_Lq μ (.symm <| .conjExponent <| show 1 < (p : ℝ) from hp) ?_ ?_ using 5 · simp [γ, n, q, ← ENNReal.rpow_mul, ← h3γ] · borelize F' fun_prop · fun_prop _ = C * γ * (∫⁻ x, ‖fderiv ℝ u x‖ₑ ^ (p : ℝ) ∂μ) ^ (1 / (p : ℝ)) * (∫⁻ x, ‖u x‖ₑ ^ (p' : ℝ) ∂μ) ^ (1 / q) := by ring calc eLpNorm u p' μ = (∫⁻ x, ‖u x‖ₑ ^ (p' : ℝ) ∂μ) ^ (1 / (p' : ℝ)) := eLpNorm_nnreal_eq_lintegral hp'0 _ ≤ C * γ * (∫⁻ x, ‖fderiv ℝ u x‖ₑ ^ (p : ℝ) ∂μ) ^ (1 / (p : ℝ)) := by rwa [← h2q, ENNReal.rpow_sub _ _ h3u h4u, ENNReal.div_le_iff h5u h6u] _ = eLpNormLESNormFDerivOfEqInnerConst μ p * eLpNorm (fderiv ℝ u) (↑p) μ := by suffices (C : ℝ) * γ = eLpNormLESNormFDerivOfEqInnerConst μ p by rw [eLpNorm_nnreal_eq_lintegral h0p] congr norm_cast at this ⊢ simp_rw [eLpNormLESNormFDerivOfEqInnerConst, γ] refold_let n n' C rw [NNReal.coe_mul, NNReal.coe_mk, Real.coe_toNNReal', mul_eq_mul_left_iff, eq_comm, max_eq_left_iff] left positivity variable (F) in /-- The constant factor occurring in the conclusion of `eLpNorm_le_eLpNorm_fderiv_of_eq`. It only depends on `E`, `F`, `μ` and `p`. -/ irreducible_def SNormLESNormFDerivOfEqConst [FiniteDimensional ℝ F] (p : ℝ) : ℝ≥0 := let F' := EuclideanSpace ℝ <| Fin <| finrank ℝ F let e : F ≃L[ℝ] F' := toEuclidean ‖(e.symm : F' →L[ℝ] F)‖₊ * eLpNormLESNormFDerivOfEqInnerConst μ p * ‖(e : F →L[ℝ] F')‖₊ /-- The **Gagliardo-Nirenberg-Sobolev inequality**. Let `u` be a continuously differentiable compactly-supported function `u` on a normed space `E` of finite dimension `n`, equipped with Haar measure, let `1 < p < n` and let `p'⁻¹ := p⁻¹ - n⁻¹`. Then the `Lᵖ'` norm of `u` is bounded above by a constant times the `Lᵖ` norm of the Fréchet derivative of `u`. This is the version where the codomain of `u` is a finite-dimensional normed space. -/ theorem eLpNorm_le_eLpNorm_fderiv_of_eq [FiniteDimensional ℝ F] {u : E → F} (hu : ContDiff ℝ 1 u) (h2u : HasCompactSupport u) {p p' : ℝ≥0} (hp : 1 ≤ p) (hn : 0 < finrank ℝ E) (hp' : (p' : ℝ)⁻¹ = p⁻¹ - (finrank ℝ E : ℝ)⁻¹) : eLpNorm u p' μ ≤ SNormLESNormFDerivOfEqConst F μ p * eLpNorm (fderiv ℝ u) p μ := by /- Here we reduce the GNS-inequality with a Hilbert space as codomain to the case with a finite-dimensional normed space as codomain, by transferring the result along the equivalence `F ≃ ℝᵐ`. -/ let F' := EuclideanSpace ℝ <| Fin <| finrank ℝ F let e : F ≃L[ℝ] F' := toEuclidean let C₁ : ℝ≥0 := ‖(e.symm : F' →L[ℝ] F)‖₊ let C : ℝ≥0 := eLpNormLESNormFDerivOfEqInnerConst μ p let C₂ : ℝ≥0 := ‖(e : F →L[ℝ] F')‖₊ let v := e ∘ u have hv : ContDiff ℝ 1 v := e.contDiff.comp hu have h2v : HasCompactSupport v := h2u.comp_left e.map_zero have := eLpNorm_le_eLpNorm_fderiv_of_eq_inner μ hv h2v hp hn hp' have h4v : ∀ x, ‖fderiv ℝ v x‖ ≤ C₂ * ‖fderiv ℝ u x‖ := fun x ↦ calc ‖fderiv ℝ v x‖ = ‖(fderiv ℝ e (u x)).comp (fderiv ℝ u x)‖ := by rw [fderiv_comp x e.differentiableAt (hu.differentiable le_rfl x)] _ ≤ ‖fderiv ℝ e (u x)‖ * ‖fderiv ℝ u x‖ := (fderiv ℝ e (u x)).opNorm_comp_le (fderiv ℝ u x) _ = C₂ * ‖fderiv ℝ u x‖ := by simp_rw [e.fderiv, C₂, coe_nnnorm] calc eLpNorm u p' μ = eLpNorm (e.symm ∘ v) p' μ := by simp_rw [v, Function.comp_def, e.symm_apply_apply] _ ≤ C₁ • eLpNorm v p' μ := by apply eLpNorm_le_nnreal_smul_eLpNorm_of_ae_le_mul exact Eventually.of_forall (fun x ↦ (e.symm : F' →L[ℝ] F).le_opNNNorm _) _ = C₁ * eLpNorm v p' μ := rfl _ ≤ C₁ * C * eLpNorm (fderiv ℝ v) p μ := by rw [mul_assoc]; gcongr _ ≤ C₁ * C * (C₂ * eLpNorm (fderiv ℝ u) p μ) := by gcongr; exact eLpNorm_le_nnreal_smul_eLpNorm_of_ae_le_mul (Eventually.of_forall h4v) p _ = SNormLESNormFDerivOfEqConst F μ p * eLpNorm (fderiv ℝ u) p μ := by simp_rw [C₂, C₁, C, e, SNormLESNormFDerivOfEqConst] push_cast simp_rw [mul_assoc] variable (F) in /-- The constant factor occurring in the conclusion of `eLpNorm_le_eLpNorm_fderiv_of_le`. It only depends on `F`, `μ`, `s`, `p` and `q`. -/ irreducible_def eLpNormLESNormFDerivOfLeConst [FiniteDimensional ℝ F] (s : Set E) (p q : ℝ≥0) : ℝ≥0 := let p' : ℝ≥0 := (p⁻¹ - (finrank ℝ E : ℝ≥0)⁻¹)⁻¹ (μ s).toNNReal ^ (1 / q - 1 / p' : ℝ) * SNormLESNormFDerivOfEqConst F μ p /-- The **Gagliardo-Nirenberg-Sobolev inequality**. Let `u` be a continuously differentiable function `u` supported in a bounded set `s` in a normed space `E` of finite dimension `n`, equipped with Haar measure, and let `1 < p < n` and `0 < q ≤ (p⁻¹ - (finrank ℝ E : ℝ)⁻¹)⁻¹`. Then the `L^q` norm of `u` is bounded above by a constant times the `Lᵖ` norm of the Fréchet derivative of `u`. Note: The codomain of `u` needs to be a finite-dimensional normed space. -/ theorem eLpNorm_le_eLpNorm_fderiv_of_le [FiniteDimensional ℝ F] {u : E → F} {s : Set E} (hu : ContDiff ℝ 1 u) (h2u : u.support ⊆ s) {p q : ℝ≥0} (hp : 1 ≤ p) (h2p : p < finrank ℝ E) (hpq : p⁻¹ - (finrank ℝ E : ℝ)⁻¹ ≤ (q : ℝ)⁻¹) (hs : Bornology.IsBounded s) : eLpNorm u q μ ≤ eLpNormLESNormFDerivOfLeConst F μ s p q * eLpNorm (fderiv ℝ u) p μ := by by_cases hq0 : q = 0 · simp [hq0] let p' : ℝ≥0 := (p⁻¹ - (finrank ℝ E : ℝ≥0)⁻¹)⁻¹ have hp' : p'⁻¹ = p⁻¹ - (finrank ℝ E : ℝ)⁻¹ := by rw [inv_inv, NNReal.coe_sub] · simp · gcongr have : (q : ℝ≥0∞) ≤ p' := by have H : (p' : ℝ)⁻¹ ≤ (↑q)⁻¹ := trans hp' hpq norm_cast at H ⊢ rwa [inv_le_inv₀] at H · dsimp have : 0 < p⁻¹ - (finrank ℝ E : ℝ≥0)⁻¹ := by simp only [tsub_pos_iff_lt] gcongr positivity · positivity set t := (μ s).toNNReal ^ (1 / q - 1 / p' : ℝ) let C := SNormLESNormFDerivOfEqConst F μ p calc eLpNorm u q μ = eLpNorm u q (μ.restrict s) := by rw [eLpNorm_restrict_eq_of_support_subset h2u] _ ≤ eLpNorm u p' (μ.restrict s) * t := by convert eLpNorm_le_eLpNorm_mul_rpow_measure_univ this hu.continuous.aestronglyMeasurable rw [ENNReal.coe_rpow_of_nonneg] · simp [ENNReal.coe_toNNReal hs.measure_lt_top.ne] · rw [one_div, one_div] norm_cast rw [hp'] simpa using hpq _ = eLpNorm u p' μ * t := by rw [eLpNorm_restrict_eq_of_support_subset h2u] _ ≤ (C * eLpNorm (fderiv ℝ u) p μ) * t := by have h2u' : HasCompactSupport u := by apply HasCompactSupport.of_support_subset_isCompact hs.isCompact_closure exact h2u.trans subset_closure rel [eLpNorm_le_eLpNorm_fderiv_of_eq μ hu h2u' hp (mod_cast (zero_le p).trans_lt h2p) hp'] _ = eLpNormLESNormFDerivOfLeConst F μ s p q * eLpNorm (fderiv ℝ u) p μ := by simp_rw [eLpNormLESNormFDerivOfLeConst, ENNReal.coe_mul]; ring /-- The **Gagliardo-Nirenberg-Sobolev inequality**. Let `u` be a continuously differentiable function `u` supported in a bounded set `s` in a normed space `E` of finite dimension `n`, equipped with Haar measure, and let `1 < p < n`. Then the `Lᵖ` norm of `u` is bounded above by a constant times the `Lᵖ` norm of the Fréchet derivative of `u`. Note: The codomain of `u` needs to be a finite-dimensional normed space. -/ theorem eLpNorm_le_eLpNorm_fderiv [FiniteDimensional ℝ F] {u : E → F} {s : Set E} (hu : ContDiff ℝ 1 u) (h2u : u.support ⊆ s) {p : ℝ≥0} (hp : 1 ≤ p) (h2p : p < finrank ℝ E) (hs : Bornology.IsBounded s) : eLpNorm u p μ ≤ eLpNormLESNormFDerivOfLeConst F μ s p p * eLpNorm (fderiv ℝ u) p μ := by refine eLpNorm_le_eLpNorm_fderiv_of_le μ hu h2u hp h2p ?_ hs norm_cast simp only [tsub_le_iff_right, le_add_iff_nonneg_right] positivity end MeasureTheory
.lake/packages/mathlib/Mathlib/Analysis/RCLike/Lemmas.lean
import Mathlib.Analysis.Normed.Module.FiniteDimension import Mathlib.Analysis.RCLike.Basic import Mathlib.Topology.Instances.RealVectorSpace /-! # Further lemmas about `RCLike` -/ open scoped Finset variable {K E : Type*} [RCLike K] open ComplexOrder RCLike in lemma convex_RCLike_iff_convex_real [AddCommMonoid E] [Module K E] [Module ℝ E] [IsScalarTower ℝ K E] {s : Set E} : Convex K s ↔ Convex ℝ s := ⟨Convex.lift ℝ, fun hs => convex_of_nonneg_surjective_algebraMap _ (fun _ => nonneg_iff_exists_ofReal.mp) hs⟩ namespace Polynomial theorem ofReal_eval (p : ℝ[X]) (x : ℝ) : (↑(p.eval x) : K) = aeval (↑x) p := (@aeval_algebraMap_apply_eq_algebraMap_eval ℝ K _ _ _ x p).symm end Polynomial variable (K) in lemma RCLike.span_one_I : Submodule.span ℝ (M := K) {1, I} = ⊤ := by suffices ∀ x : K, ∃ a b : ℝ, a • 1 + b • I = x by simpa [Submodule.eq_top_iff', Submodule.mem_span_pair] exact fun x ↦ ⟨re x, im x, by simp [real_smul_eq_coe_mul]⟩ variable (K) in lemma RCLike.rank_le_two : Module.rank ℝ K ≤ 2 := calc _ = Module.rank ℝ ↥(Submodule.span ℝ ({1, I} : Set K)) := by rw [span_one_I]; simp _ ≤ #({1, I} : Finset K) := by -- TODO: `simp` doesn't rewrite inside the type argument to `Module.rank`, but `rw` does. -- We should introduce `Submodule.rank` to fix this. have := rank_span_finset_le (R := ℝ) (M := K) {1, I} rw [Finset.coe_pair] at this simpa [span_one_I] using this _ ≤ 2 := mod_cast Finset.card_le_two variable (K) in lemma RCLike.finrank_le_two : Module.finrank ℝ K ≤ 2 := Module.finrank_le_of_rank_le <| rank_le_two _ namespace FiniteDimensional open RCLike library_note2 «RCLike instance» /-- This instance generates a type-class problem with a metavariable `?m` that should satisfy `RCLike ?m`. Since this can only be satisfied by `ℝ` or `ℂ`, this does not cause problems. -/ /-- An `RCLike` field is finite-dimensional over `ℝ`, since it is spanned by `{1, I}`. -/ instance rclike_to_real : FiniteDimensional ℝ K := ⟨{1, I}, by simp [span_one_I]⟩ variable (K E) variable [NormedAddCommGroup E] [NormedSpace K E] /-- A finite-dimensional vector space over an `RCLike` is a proper metric space. This is not an instance because it would cause a search for `FiniteDimensional ?x E` before `RCLike ?x`. -/ theorem proper_rclike [FiniteDimensional K E] : ProperSpace E := by -- Using `have` not `let` since it is only existence of `NormedSpace` structure that we need. have : NormedSpace ℝ E := RestrictScalars.normedSpace ℝ K E have : FiniteDimensional ℝ E := FiniteDimensional.trans ℝ K E infer_instance variable {E} instance RCLike.properSpace_submodule (S : Submodule K E) [FiniteDimensional K S] : ProperSpace S := proper_rclike K S end FiniteDimensional namespace RCLike @[simp, rclike_simps] theorem reCLM_norm : ‖(reCLM : StrongDual ℝ K)‖ = 1 := by apply le_antisymm (LinearMap.mkContinuous_norm_le _ zero_le_one _) convert ContinuousLinearMap.ratio_le_opNorm (reCLM : StrongDual ℝ K) (1 : K) simp @[simp, rclike_simps] theorem conjCLE_norm : ‖(@conjCLE K _ : K →L[ℝ] K)‖ = 1 := (@conjLIE K _).toLinearIsometry.norm_toContinuousLinearMap @[simp, rclike_simps] theorem ofRealCLM_norm : ‖(ofRealCLM : ℝ →L[ℝ] K)‖ = 1 := LinearIsometry.norm_toContinuousLinearMap _ end RCLike namespace Polynomial open ComplexConjugate in lemma aeval_conj (p : ℝ[X]) (z : K) : aeval (conj z) p = conj (aeval z p) := aeval_algHom_apply (RCLike.conjAe (K := K)) z p lemma aeval_ofReal (p : ℝ[X]) (x : ℝ) : aeval (RCLike.ofReal x : K) p = eval x p := aeval_algHom_apply RCLike.ofRealAm x p end Polynomial
.lake/packages/mathlib/Mathlib/Analysis/RCLike/Inner.lean
import Mathlib.Analysis.InnerProductSpace.PiL2 /-! # L2 inner product of finite sequences This file defines the weighted L2 inner product of functions `f g : ι → R` where `ι` is a fintype as `∑ i, conj (f i) * g i`. This convention (conjugation on the left) matches the inner product coming from `RCLike.innerProductSpace`. ## TODO * Build a non-instance `InnerProductSpace` from `wInner`. * `cWeight` is a poor name. Can we find better? It doesn't hugely matter for typing, since it's hidden behind the `⟪f, g⟫ₙ_[𝕝] `notation, but it does show up in lemma names `⟪f, g⟫_[𝕝, cWeight]` is called `wInner_cWeight`. Maybe we should introduce some naming convention, similarly to `MeasureTheory.average`? -/ open Finset Function Real WithLp open scoped BigOperators ComplexConjugate ComplexOrder InnerProductSpace variable {ι κ 𝕜 : Type*} {E : ι → Type*} [Fintype ι] namespace RCLike variable [RCLike 𝕜] section Pi variable [∀ i, SeminormedAddCommGroup (E i)] [∀ i, InnerProductSpace 𝕜 (E i)] {w : ι → ℝ} /-- Weighted inner product giving rise to the L2 norm, denoted as `⟪g, f⟫_[𝕜, w]`. -/ def wInner (w : ι → ℝ) (f g : ∀ i, E i) : 𝕜 := ∑ i, w i • ⟪f i, g i⟫_𝕜 /-- The weight function making `wInner` into the compact inner product. -/ noncomputable abbrev cWeight : ι → ℝ := Function.const _ (Fintype.card ι)⁻¹ @[inherit_doc] notation "⟪" f ", " g "⟫_[" 𝕝 ", " w "]" => wInner (𝕜 := 𝕝) w f g /-- Discrete inner product giving rise to the discrete L2 norm. -/ notation "⟪" f ", " g "⟫_[" 𝕝 "]" => ⟪f, g⟫_[𝕝, 1] /-- Compact inner product giving rise to the compact L2 norm. -/ notation "⟪" f ", " g "⟫ₙ_[" 𝕝 "]" => ⟪f, g⟫_[𝕝, cWeight] lemma wInner_cWeight_eq_smul_wInner_one (f g : ∀ i, E i) : ⟪f, g⟫ₙ_[𝕜] = (Fintype.card ι : ℚ≥0)⁻¹ • ⟪f, g⟫_[𝕜] := by simp [wInner, smul_sum, ← NNRat.cast_smul_eq_nnqsmul ℝ] @[simp] lemma conj_wInner_symm (w : ι → ℝ) (f g : ∀ i, E i) : conj ⟪f, g⟫_[𝕜, w] = ⟪g, f⟫_[𝕜, w] := by simp [wInner, map_sum, inner_conj_symm, rclike_simps] @[simp] lemma wInner_zero_left (w : ι → ℝ) (g : ∀ i, E i) : ⟪0, g⟫_[𝕜, w] = 0 := by simp [wInner] @[simp] lemma wInner_zero_right (w : ι → ℝ) (f : ∀ i, E i) : ⟪f, 0⟫_[𝕜, w] = 0 := by simp [wInner] lemma wInner_add_left (w : ι → ℝ) (f₁ f₂ g : ∀ i, E i) : ⟪f₁ + f₂, g⟫_[𝕜, w] = ⟪f₁, g⟫_[𝕜, w] + ⟪f₂, g⟫_[𝕜, w] := by simp [wInner, inner_add_left, smul_add, sum_add_distrib] lemma wInner_add_right (w : ι → ℝ) (f g₁ g₂ : ∀ i, E i) : ⟪f, g₁ + g₂⟫_[𝕜, w] = ⟪f, g₁⟫_[𝕜, w] + ⟪f, g₂⟫_[𝕜, w] := by simp [wInner, inner_add_right, smul_add, sum_add_distrib] @[simp] lemma wInner_neg_left (w : ι → ℝ) (f g : ∀ i, E i) : ⟪-f, g⟫_[𝕜, w] = -⟪f, g⟫_[𝕜, w] := by simp [wInner] @[simp] lemma wInner_neg_right (w : ι → ℝ) (f g : ∀ i, E i) : ⟪f, -g⟫_[𝕜, w] = -⟪f, g⟫_[𝕜, w] := by simp [wInner] lemma wInner_sub_left (w : ι → ℝ) (f₁ f₂ g : ∀ i, E i) : ⟪f₁ - f₂, g⟫_[𝕜, w] = ⟪f₁, g⟫_[𝕜, w] - ⟪f₂, g⟫_[𝕜, w] := by simp_rw [sub_eq_add_neg, wInner_add_left, wInner_neg_left] lemma wInner_sub_right (w : ι → ℝ) (f g₁ g₂ : ∀ i, E i) : ⟪f, g₁ - g₂⟫_[𝕜, w] = ⟪f, g₁⟫_[𝕜, w] - ⟪f, g₂⟫_[𝕜, w] := by simp_rw [sub_eq_add_neg, wInner_add_right, wInner_neg_right] @[simp] lemma wInner_of_isEmpty [IsEmpty ι] (w : ι → ℝ) (f g : ∀ i, E i) : ⟪f, g⟫_[𝕜, w] = 0 := by simp [Subsingleton.elim f 0] lemma wInner_smul_left {𝕝 : Type*} [CommSemiring 𝕝] [StarRing 𝕝] [Algebra 𝕝 𝕜] [StarModule 𝕝 𝕜] [SMulCommClass ℝ 𝕝 𝕜] [∀ i, Module 𝕝 (E i)] [∀ i, IsScalarTower 𝕝 𝕜 (E i)] (c : 𝕝) (w : ι → ℝ) (f g : ∀ i, E i) : ⟪c • f, g⟫_[𝕜, w] = star c • ⟪f, g⟫_[𝕜, w] := by simp_rw [wInner, Pi.smul_apply, inner_smul_left_eq_star_smul, starRingEnd_apply, smul_sum, smul_comm (w _)] lemma wInner_smul_right {𝕝 : Type*} [CommSemiring 𝕝] [StarRing 𝕝] [Algebra 𝕝 𝕜] [StarModule 𝕝 𝕜] [∀ i, Module 𝕝 (E i)] [∀ i, IsScalarTower 𝕝 𝕜 (E i)] (c : 𝕝) (w : ι → ℝ) (f g : ∀ i, E i) : ⟪f, c • g⟫_[𝕜, w] = c • ⟪f, g⟫_[𝕜, w] := by simp_rw [wInner, Pi.smul_apply, inner_smul_right_eq_smul, smul_sum, smul_comm c] lemma mul_wInner_left (c : 𝕜) (w : ι → ℝ) (f g : ∀ i, E i) : c * ⟪f, g⟫_[𝕜, w] = ⟪star c • f, g⟫_[𝕜, w] := by rw [wInner_smul_left, star_star, smul_eq_mul] lemma wInner_one_eq_sum (f g : ∀ i, E i) : ⟪f, g⟫_[𝕜] = ∑ i, ⟪f i, g i⟫_𝕜 := by simp [wInner] lemma wInner_cWeight_eq_expect (f g : ∀ i, E i) : ⟪f, g⟫ₙ_[𝕜] = 𝔼 i, ⟪f i, g i⟫_𝕜 := by simp [wInner, expect, smul_sum, ← NNRat.cast_smul_eq_nnqsmul ℝ] end Pi section Function variable {w : ι → ℝ} {f g : ι → 𝕜} lemma wInner_const_left (a : 𝕜) (f : ι → 𝕜) : ⟪const _ a, f⟫_[𝕜, w] = (∑ i, w i • f i) * conj a := by simp [wInner, const_apply, sum_mul] lemma wInner_const_right (f : ι → 𝕜) (a : 𝕜) : ⟪f, const _ a⟫_[𝕜, w] = a * (∑ i, w i • conj (f i)) := by simp [wInner, const_apply, mul_sum] @[simp] lemma wInner_one_const_left (a : 𝕜) (f : ι → 𝕜) : ⟪const _ a, f⟫_[𝕜] = (∑ i, f i) * conj a := by simp [wInner_one_eq_sum, sum_mul] @[simp] lemma wInner_one_const_right (f : ι → 𝕜) (a : 𝕜) : ⟪f, const _ a⟫_[𝕜] = a * (∑ i, conj (f i)) := by simp [wInner_one_eq_sum, mul_sum] @[simp] lemma wInner_cWeight_const_left (a : 𝕜) (f : ι → 𝕜) : ⟪const _ a, f⟫ₙ_[𝕜] = 𝔼 i, f i * conj a := by simp [wInner_cWeight_eq_expect] @[simp] lemma wInner_cWeight_const_right (f : ι → 𝕜) (a : 𝕜) : ⟪f, const _ a⟫ₙ_[𝕜] = a * (𝔼 i, conj (f i)) := by simp [wInner_cWeight_eq_expect, mul_expect] lemma wInner_one_eq_inner (f g : ι → 𝕜) : ⟪f, g⟫_[𝕜, 1] = ⟪toLp 2 f, toLp 2 g⟫_𝕜 := by simp [PiLp.inner_apply, wInner] lemma inner_eq_wInner_one (f g : PiLp 2 fun _i : ι ↦ 𝕜) : ⟪f, g⟫_𝕜 = ⟪ofLp f, ofLp g⟫_[𝕜, 1] := by simp [PiLp.inner_apply, wInner] lemma linearIndependent_of_ne_zero_of_wInner_one_eq_zero {f : κ → ι → 𝕜} (hf : ∀ k, f k ≠ 0) (hinner : Pairwise fun k₁ k₂ ↦ ⟪f k₁, f k₂⟫_[𝕜] = 0) : LinearIndependent 𝕜 f := by simp_rw [wInner_one_eq_inner] at hinner have := linearIndependent_of_ne_zero_of_inner_eq_zero ?_ hinner exacts [(WithLp.linearEquiv 2 𝕜 (ι → 𝕜)).symm.toLinearMap.linearIndependent_iff_of_injOn (toLp_injective 2).injOn |>.1 this, fun i ↦ (toLp_eq_zero 2).ne.2 (hf i)] lemma linearIndependent_of_ne_zero_of_wInner_cWeight_eq_zero {f : κ → ι → 𝕜} (hf : ∀ k, f k ≠ 0) (hinner : Pairwise fun k₁ k₂ ↦ ⟪f k₁, f k₂⟫ₙ_[𝕜] = 0) : LinearIndependent 𝕜 f := by cases isEmpty_or_nonempty ι · have : IsEmpty κ := ⟨fun k ↦ hf k <| Subsingleton.elim ..⟩ exact linearIndependent_empty_type · exact linearIndependent_of_ne_zero_of_wInner_one_eq_zero hf <| by simpa [wInner_cWeight_eq_smul_wInner_one, ← NNRat.cast_smul_eq_nnqsmul 𝕜] using hinner lemma wInner_nonneg (hw : 0 ≤ w) (hf : 0 ≤ f) (hg : 0 ≤ g) : 0 ≤ ⟪f, g⟫_[𝕜, w] := sum_nonneg fun _ _ ↦ smul_nonneg (hw _) <| mul_nonneg (hg _) (star_nonneg_iff.2 (hf _)) lemma norm_wInner_le (hw : 0 ≤ w) : ‖⟪f, g⟫_[𝕜, w]‖ ≤ ⟪fun i ↦ ‖f i‖, fun i ↦ ‖g i‖⟫_[ℝ, w] := (norm_sum_le ..).trans_eq <| sum_congr rfl fun i _ ↦ by simp [Algebra.smul_def, norm_mul, abs_of_nonneg (hw i)] end Function section Real variable {w f g : ι → ℝ} lemma abs_wInner_le (hw : 0 ≤ w) : |⟪f, g⟫_[ℝ, w]| ≤ ⟪|f|, |g|⟫_[ℝ, w] := by simpa using norm_wInner_le (𝕜 := ℝ) hw end Real end RCLike
.lake/packages/mathlib/Mathlib/Analysis/RCLike/Basic.lean
import Mathlib.Algebra.Algebra.IsSimpleRing import Mathlib.Algebra.BigOperators.Balance import Mathlib.Algebra.Order.BigOperators.Expect import Mathlib.Algebra.Order.Star.Basic import Mathlib.Analysis.CStarAlgebra.Basic import Mathlib.Analysis.Normed.Operator.ContinuousLinearMap import Mathlib.Analysis.Normed.Ring.Finite import Mathlib.Data.Real.Sqrt /-! # `RCLike`: a typeclass for ℝ or ℂ This file defines the typeclass `RCLike` intended to have only two instances: ℝ and ℂ. It is meant for definitions and theorems which hold for both the real and the complex case, and in particular when the real case follows directly from the complex case by setting `re` to `id`, `im` to zero and so on. Its API follows closely that of ℂ. Applications include defining inner products and Hilbert spaces for both the real and complex case. One typically produces the definitions and proof for an arbitrary field of this typeclass, which basically amounts to doing the complex case, and the two cases then fall out immediately from the two instances of the class. The instance for `ℝ` is registered in this file. The instance for `ℂ` is declared in `Mathlib/Analysis/Complex/Basic.lean`. ## Implementation notes The coercion from reals into an `RCLike` field is done by registering `RCLike.ofReal` as a `CoeTC`. For this to work, we must proceed carefully to avoid problems involving circular coercions in the case `K=ℝ`; in particular, we cannot use the plain `Coe` and must set priorities carefully. This problem was already solved for `ℕ`, and we copy the solution detailed in `Mathlib/Data/Nat/Cast/Defs.lean`. See also Note [coercion into rings] for more details. In addition, several lemmas need to be set at priority 900 to make sure that they do not override their counterparts in `Mathlib/Analysis/Complex/Basic.lean` (which causes linter errors). A few lemmas requiring heavier imports are in `Mathlib/Analysis/RCLike/Lemmas.lean`. -/ open Fintype open scoped BigOperators ComplexConjugate section local notation "𝓚" => algebraMap ℝ _ /-- This typeclass captures properties shared by ℝ and ℂ, with an API that closely matches that of ℂ. -/ class RCLike (K : semiOutParam Type*) extends DenselyNormedField K, StarRing K, NormedAlgebra ℝ K, CompleteSpace K where /-- The real part as an additive monoid homomorphism -/ re : K →+ ℝ /-- The imaginary part as an additive monoid homomorphism -/ im : K →+ ℝ /-- Imaginary unit in `K`. Meant to be set to `0` for `K = ℝ`. -/ I : K I_re_ax : re I = 0 I_mul_I_ax : I = 0 ∨ I * I = -1 re_add_im_ax : ∀ z : K, 𝓚 (re z) + 𝓚 (im z) * I = z ofReal_re_ax : ∀ r : ℝ, re (𝓚 r) = r ofReal_im_ax : ∀ r : ℝ, im (𝓚 r) = 0 mul_re_ax : ∀ z w : K, re (z * w) = re z * re w - im z * im w mul_im_ax : ∀ z w : K, im (z * w) = re z * im w + im z * re w conj_re_ax : ∀ z : K, re (conj z) = re z conj_im_ax : ∀ z : K, im (conj z) = -im z conj_I_ax : conj I = -I norm_sq_eq_def_ax : ∀ z : K, ‖z‖ ^ 2 = re z * re z + im z * im z mul_im_I_ax : ∀ z : K, im z * im I = im z /-- only an instance in the `ComplexOrder` scope -/ [toPartialOrder : PartialOrder K] le_iff_re_im {z w : K} : z ≤ w ↔ re z ≤ re w ∧ im z = im w -- note we cannot put this in the `extends` clause [toDecidableEq : DecidableEq K] scoped[ComplexOrder] attribute [instance 100] RCLike.toPartialOrder attribute [instance 100] RCLike.toDecidableEq end variable {K E : Type*} [RCLike K] namespace RCLike /-- Coercion from `ℝ` to an `RCLike` field. -/ @[coe] abbrev ofReal : ℝ → K := Algebra.cast /- The priority must be set at 900 to ensure that coercions are tried in the right order. See Note [coercion into rings], or `Mathlib/Data/Nat/Cast/Basic.lean` for more details. -/ noncomputable instance (priority := 900) algebraMapCoe : CoeTC ℝ K := ⟨ofReal⟩ theorem ofReal_alg (x : ℝ) : (x : K) = x • (1 : K) := Algebra.algebraMap_eq_smul_one x theorem real_smul_eq_coe_mul (r : ℝ) (z : K) : r • z = (r : K) * z := Algebra.smul_def r z theorem real_smul_eq_coe_smul [AddCommGroup E] [Module K E] [Module ℝ E] [IsScalarTower ℝ K E] (r : ℝ) (x : E) : r • x = (r : K) • x := by rw [RCLike.ofReal_alg, smul_one_smul] theorem algebraMap_eq_ofReal : ⇑(algebraMap ℝ K) = ofReal := rfl @[simp, rclike_simps] theorem re_add_im (z : K) : (re z : K) + im z * I = z := RCLike.re_add_im_ax z @[simp, norm_cast, rclike_simps] theorem ofReal_re : ∀ r : ℝ, re (r : K) = r := RCLike.ofReal_re_ax @[simp, norm_cast, rclike_simps] theorem ofReal_im : ∀ r : ℝ, im (r : K) = 0 := RCLike.ofReal_im_ax @[simp, rclike_simps] theorem mul_re : ∀ z w : K, re (z * w) = re z * re w - im z * im w := RCLike.mul_re_ax @[simp, rclike_simps] theorem mul_im : ∀ z w : K, im (z * w) = re z * im w + im z * re w := RCLike.mul_im_ax theorem ext_iff {z w : K} : z = w ↔ re z = re w ∧ im z = im w := ⟨fun h => h ▸ ⟨rfl, rfl⟩, fun ⟨h₁, h₂⟩ => re_add_im z ▸ re_add_im w ▸ h₁ ▸ h₂ ▸ rfl⟩ theorem ext {z w : K} (hre : re z = re w) (him : im z = im w) : z = w := ext_iff.2 ⟨hre, him⟩ @[norm_cast] theorem ofReal_zero : ((0 : ℝ) : K) = 0 := algebraMap.coe_zero @[rclike_simps] theorem zero_re : re (0 : K) = (0 : ℝ) := map_zero re @[deprecated (since := "2025-05-29")] alias zero_re' := zero_re @[rclike_simps] theorem zero_im : im (0 : K) = (0 : ℝ) := map_zero im @[norm_cast] theorem ofReal_one : ((1 : ℝ) : K) = 1 := map_one (algebraMap ℝ K) @[simp, rclike_simps] theorem one_re : re (1 : K) = 1 := by rw [← ofReal_one, ofReal_re] @[simp, rclike_simps] theorem one_im : im (1 : K) = 0 := by rw [← ofReal_one, ofReal_im] theorem ofReal_injective : Function.Injective ((↑) : ℝ → K) := (algebraMap ℝ K).injective @[norm_cast] theorem ofReal_inj {z w : ℝ} : (z : K) = (w : K) ↔ z = w := algebraMap.coe_inj _ _ theorem ofReal_eq_zero {x : ℝ} : (x : K) = 0 ↔ x = 0 := algebraMap.coe_eq_zero_iff _ _ _ theorem ofReal_ne_zero {x : ℝ} : (x : K) ≠ 0 ↔ x ≠ 0 := ofReal_eq_zero.not @[rclike_simps, norm_cast] theorem ofReal_add (r s : ℝ) : ((r + s : ℝ) : K) = r + s := algebraMap.coe_add _ _ @[rclike_simps, norm_cast] theorem ofReal_neg (r : ℝ) : ((-r : ℝ) : K) = -r := algebraMap.coe_neg r @[rclike_simps, norm_cast] theorem ofReal_sub (r s : ℝ) : ((r - s : ℝ) : K) = r - s := map_sub (algebraMap ℝ K) r s @[rclike_simps, norm_cast] theorem ofReal_sum {α : Type*} (s : Finset α) (f : α → ℝ) : ((∑ i ∈ s, f i : ℝ) : K) = ∑ i ∈ s, (f i : K) := map_sum (algebraMap ℝ K) _ _ @[simp, rclike_simps, norm_cast] theorem ofReal_finsupp_sum {α M : Type*} [Zero M] (f : α →₀ M) (g : α → M → ℝ) : ((f.sum fun a b => g a b : ℝ) : K) = f.sum fun a b => (g a b : K) := map_finsuppSum (algebraMap ℝ K) f g @[rclike_simps, norm_cast] theorem ofReal_mul (r s : ℝ) : ((r * s : ℝ) : K) = r * s := algebraMap.coe_mul _ _ @[rclike_simps, norm_cast] theorem ofReal_pow (r : ℝ) (n : ℕ) : ((r ^ n : ℝ) : K) = (r : K) ^ n := map_pow (algebraMap ℝ K) r n @[rclike_simps, norm_cast] theorem ofReal_prod {α : Type*} (s : Finset α) (f : α → ℝ) : ((∏ i ∈ s, f i : ℝ) : K) = ∏ i ∈ s, (f i : K) := map_prod (algebraMap ℝ K) _ _ @[simp, rclike_simps, norm_cast] theorem ofReal_finsuppProd {α M : Type*} [Zero M] (f : α →₀ M) (g : α → M → ℝ) : ((f.prod fun a b => g a b : ℝ) : K) = f.prod fun a b => (g a b : K) := map_finsuppProd _ f g @[simp, norm_cast, rclike_simps] theorem real_smul_ofReal (r x : ℝ) : r • (x : K) = (r : K) * (x : K) := real_smul_eq_coe_mul _ _ @[rclike_simps] theorem re_ofReal_mul (r : ℝ) (z : K) : re (↑r * z) = r * re z := by simp only [mul_re, ofReal_im, zero_mul, ofReal_re, sub_zero] @[rclike_simps] theorem im_ofReal_mul (r : ℝ) (z : K) : im (↑r * z) = r * im z := by simp only [add_zero, ofReal_im, zero_mul, ofReal_re, mul_im] @[rclike_simps] theorem smul_re (r : ℝ) (z : K) : re (r • z) = r * re z := by rw [real_smul_eq_coe_mul, re_ofReal_mul] @[rclike_simps] theorem smul_im (r : ℝ) (z : K) : im (r • z) = r * im z := by rw [real_smul_eq_coe_mul, im_ofReal_mul] @[rclike_simps, norm_cast] theorem norm_ofReal (r : ℝ) : ‖(r : K)‖ = |r| := norm_algebraMap' K r @[simp] theorem re_ofReal_pow (a : ℝ) (n : ℕ) : re ((a : K) ^ n) = a ^ n := by rw [← ofReal_pow, @ofReal_re] @[simp] theorem im_ofReal_pow (a : ℝ) (n : ℕ) : im ((a : K) ^ n) = 0 := by rw [← @ofReal_pow, @ofReal_im_ax] /-! ### Characteristic zero -/ -- see Note [lower instance priority] /-- ℝ and ℂ are both of characteristic zero. -/ instance (priority := 100) charZero_rclike : CharZero K := (RingHom.charZero_iff (algebraMap ℝ K).injective).1 inferInstance @[rclike_simps, norm_cast] lemma ofReal_expect {α : Type*} (s : Finset α) (f : α → ℝ) : 𝔼 i ∈ s, f i = 𝔼 i ∈ s, (f i : K) := map_expect (algebraMap ..) .. @[norm_cast] lemma ofReal_balance {ι : Type*} [Fintype ι] (f : ι → ℝ) (i : ι) : ((balance f i : ℝ) : K) = balance ((↑) ∘ f) i := map_balance (algebraMap ..) .. @[simp] lemma ofReal_comp_balance {ι : Type*} [Fintype ι] (f : ι → ℝ) : ofReal ∘ balance f = balance (ofReal ∘ f : ι → K) := funext <| ofReal_balance _ /-! ### The imaginary unit, `I` -/ /-- The imaginary unit. -/ @[simp, rclike_simps] theorem I_re : re (I : K) = 0 := I_re_ax @[simp, rclike_simps] theorem I_im (z : K) : im z * im (I : K) = im z := mul_im_I_ax z @[simp, rclike_simps] theorem I_im' (z : K) : im (I : K) * im z = im z := by rw [mul_comm, I_im] -- Not `@[simp]` since `simp` can prove this. @[rclike_simps] theorem I_mul_re (z : K) : re (I * z) = -im z := by simp only [I_re, zero_sub, I_im', zero_mul, mul_re] theorem I_mul_I : (I : K) = 0 ∨ (I : K) * I = -1 := I_mul_I_ax variable (𝕜) in lemma I_eq_zero_or_im_I_eq_one : (I : K) = 0 ∨ im (I : K) = 1 := I_mul_I (K := K) |>.imp_right fun h ↦ by simpa [h] using (I_mul_re (I : K)).symm @[simp, rclike_simps] theorem conj_re (z : K) : re (conj z) = re z := RCLike.conj_re_ax z @[simp, rclike_simps] theorem conj_im (z : K) : im (conj z) = -im z := RCLike.conj_im_ax z @[simp, rclike_simps] theorem conj_I : conj (I : K) = -I := RCLike.conj_I_ax @[simp, rclike_simps] theorem conj_ofReal (r : ℝ) : conj (r : K) = (r : K) := by rw [ext_iff] simp only [ofReal_im, conj_im, conj_re, and_self_iff, neg_zero] theorem conj_nat_cast (n : ℕ) : conj (n : K) = n := map_natCast _ _ theorem conj_ofNat (n : ℕ) [n.AtLeastTwo] : conj (ofNat(n) : K) = ofNat(n) := map_ofNat _ _ @[rclike_simps, simp] theorem conj_neg_I : conj (-I) = (I : K) := by rw [map_neg, conj_I, neg_neg] theorem conj_eq_re_sub_im (z : K) : conj z = re z - im z * I := (congr_arg conj (re_add_im z).symm).trans <| by rw [map_add, map_mul, conj_I, conj_ofReal, conj_ofReal, mul_neg, sub_eq_add_neg] theorem sub_conj (z : K) : z - conj z = 2 * im z * I := calc z - conj z = re z + im z * I - (re z - im z * I) := by rw [re_add_im, ← conj_eq_re_sub_im] _ = 2 * im z * I := by rw [add_sub_sub_cancel, ← two_mul, mul_assoc] @[rclike_simps] theorem conj_smul (r : ℝ) (z : K) : conj (r • z) = r • conj z := by rw [conj_eq_re_sub_im, conj_eq_re_sub_im, smul_re, smul_im, ofReal_mul, ofReal_mul, real_smul_eq_coe_mul r (_ - _), mul_sub, mul_assoc] theorem add_conj (z : K) : z + conj z = 2 * re z := calc z + conj z = re z + im z * I + (re z - im z * I) := by rw [re_add_im, conj_eq_re_sub_im] _ = 2 * re z := by rw [add_add_sub_cancel, two_mul] theorem re_eq_add_conj (z : K) : ↑(re z) = (z + conj z) / 2 := by rw [add_conj, mul_div_cancel_left₀ (re z : K) two_ne_zero] theorem im_eq_conj_sub (z : K) : ↑(im z) = I * (conj z - z) / 2 := by rw [← neg_inj, ← ofReal_neg, ← I_mul_re, re_eq_add_conj, map_mul, conj_I, ← neg_div, ← mul_neg, neg_sub, mul_sub, neg_mul, sub_eq_add_neg] open List in /-- There are several equivalent ways to say that a number `z` is in fact a real number. -/ theorem is_real_TFAE (z : K) : TFAE [conj z = z, ∃ r : ℝ, (r : K) = z, ↑(re z) = z, im z = 0, IsSelfAdjoint z] := by tfae_have 1 → 4 | h => by rw [← @ofReal_inj K, im_eq_conj_sub, h, sub_self, mul_zero, zero_div, ofReal_zero] tfae_have 4 → 3 | h => by conv_rhs => rw [← re_add_im z, h, ofReal_zero, zero_mul, add_zero] tfae_have 3 → 2 := fun h => ⟨_, h⟩ tfae_have 2 → 1 := fun ⟨r, hr⟩ => hr ▸ conj_ofReal _ tfae_have 1 → 5 := fun _ => by rwa [isSelfAdjoint_iff] tfae_have 5 → 1 := fun hz => by rwa [isSelfAdjoint_iff] at hz tfae_finish theorem conj_eq_iff_real {z : K} : conj z = z ↔ ∃ r : ℝ, z = (r : K) := calc _ ↔ ∃ r : ℝ, (r : K) = z := (is_real_TFAE z).out 0 1 _ ↔ _ := by simp only [eq_comm] theorem conj_eq_iff_re {z : K} : conj z = z ↔ (re z : K) = z := (is_real_TFAE z).out 0 2 theorem conj_eq_iff_im {z : K} : conj z = z ↔ im z = 0 := (is_real_TFAE z).out 0 3 @[simp] theorem star_def : (Star.star : K → K) = conj := rfl lemma im_eq_zero_iff_isSelfAdjoint {x : K} : im x = 0 ↔ IsSelfAdjoint x := is_real_TFAE x |>.out 3 4 lemma re_eq_ofReal_of_isSelfAdjoint {x : K} {y : ℝ} (hx : IsSelfAdjoint x) : re x = y ↔ x = y := by simp [RCLike.ext_iff (K := K), hx, im_eq_zero_iff_isSelfAdjoint] lemma ofReal_eq_re_of_isSelfAdjoint {x : K} {y : ℝ} (hx : IsSelfAdjoint x) : y = re x ↔ y = x := by simpa [eq_comm] using re_eq_ofReal_of_isSelfAdjoint hx variable (K) /-- Conjugation as a ring equivalence. This is used to convert the inner product into a sesquilinear product. -/ abbrev conjToRingEquiv : K ≃+* Kᵐᵒᵖ := starRingEquiv variable {K} {z : K} /-- The norm squared function. -/ def normSq : K →*₀ ℝ where toFun z := re z * re z + im z * im z map_zero' := by simp only [add_zero, mul_zero, map_zero] map_one' := by simp only [one_im, add_zero, mul_one, one_re, mul_zero] map_mul' z w := by simp only [mul_im, mul_re] ring theorem normSq_apply (z : K) : normSq z = re z * re z + im z * im z := rfl theorem norm_sq_eq_def {z : K} : ‖z‖ ^ 2 = re z * re z + im z * im z := norm_sq_eq_def_ax z theorem normSq_eq_def' (z : K) : normSq z = ‖z‖ ^ 2 := norm_sq_eq_def.symm @[rclike_simps] theorem normSq_zero : normSq (0 : K) = 0 := normSq.map_zero @[rclike_simps] theorem normSq_one : normSq (1 : K) = 1 := normSq.map_one theorem normSq_nonneg (z : K) : 0 ≤ normSq z := add_nonneg (mul_self_nonneg _) (mul_self_nonneg _) -- Not `@[simp]` since `simp` can prove this. @[rclike_simps] theorem normSq_eq_zero {z : K} : normSq z = 0 ↔ z = 0 := map_eq_zero _ @[simp, rclike_simps] theorem normSq_pos {z : K} : 0 < normSq z ↔ z ≠ 0 := by rw [lt_iff_le_and_ne, Ne, eq_comm]; simp [normSq_nonneg] @[simp, rclike_simps] theorem normSq_neg (z : K) : normSq (-z) = normSq z := by simp only [normSq_eq_def', norm_neg] @[simp, rclike_simps] theorem normSq_conj (z : K) : normSq (conj z) = normSq z := by simp only [normSq_apply, neg_mul, mul_neg, neg_neg, rclike_simps] -- Not `@[simp]` since `simp` can prove this. @[rclike_simps] theorem normSq_mul (z w : K) : normSq (z * w) = normSq z * normSq w := map_mul _ z w theorem normSq_add (z w : K) : normSq (z + w) = normSq z + normSq w + 2 * re (z * conj w) := by simp only [normSq_apply, map_add, rclike_simps] ring theorem re_sq_le_normSq (z : K) : re z * re z ≤ normSq z := le_add_of_nonneg_right (mul_self_nonneg _) theorem im_sq_le_normSq (z : K) : im z * im z ≤ normSq z := le_add_of_nonneg_left (mul_self_nonneg _) theorem mul_conj (z : K) : z * conj z = ‖z‖ ^ 2 := by apply ext <;> simp [← ofReal_pow, norm_sq_eq_def, mul_comm] theorem conj_mul (z : K) : conj z * z = ‖z‖ ^ 2 := by rw [mul_comm, mul_conj] lemma inv_eq_conj (hz : ‖z‖ = 1) : z⁻¹ = conj z := inv_eq_of_mul_eq_one_left <| by simp_rw [conj_mul, hz, algebraMap.coe_one, one_pow] theorem normSq_sub (z w : K) : normSq (z - w) = normSq z + normSq w - 2 * re (z * conj w) := by simp only [normSq_add, sub_eq_add_neg, map_neg, mul_neg, normSq_neg, map_neg] theorem sqrt_normSq_eq_norm {z : K} : √(normSq z) = ‖z‖ := by rw [normSq_eq_def', Real.sqrt_sq (norm_nonneg _)] /-! ### Inversion -/ @[rclike_simps, norm_cast] theorem ofReal_inv (r : ℝ) : ((r⁻¹ : ℝ) : K) = (r : K)⁻¹ := map_inv₀ _ r theorem inv_def (z : K) : z⁻¹ = conj z * ((‖z‖ ^ 2)⁻¹ : ℝ) := by rcases eq_or_ne z 0 with (rfl | h₀) · simp · apply inv_eq_of_mul_eq_one_right rw [← mul_assoc, mul_conj, ofReal_inv, ofReal_pow, mul_inv_cancel₀] simpa @[simp, rclike_simps] theorem inv_re (z : K) : re z⁻¹ = re z / normSq z := by rw [inv_def, normSq_eq_def', mul_comm, re_ofReal_mul, conj_re, div_eq_inv_mul] @[simp, rclike_simps] theorem inv_im (z : K) : im z⁻¹ = -im z / normSq z := by rw [inv_def, normSq_eq_def', mul_comm, im_ofReal_mul, conj_im, div_eq_inv_mul] theorem div_re (z w : K) : re (z / w) = re z * re w / normSq w + im z * im w / normSq w := by simp only [div_eq_mul_inv, mul_assoc, sub_eq_add_neg, neg_mul, mul_neg, neg_neg, rclike_simps] theorem div_im (z w : K) : im (z / w) = im z * re w / normSq w - re z * im w / normSq w := by simp only [div_eq_mul_inv, mul_assoc, sub_eq_add_neg, add_comm, neg_mul, mul_neg, rclike_simps] -- Not `@[simp]` since `simp` can prove this @[rclike_simps] theorem conj_inv (x : K) : conj x⁻¹ = (conj x)⁻¹ := star_inv₀ _ lemma conj_div (x y : K) : conj (x / y) = conj x / conj y := map_div' conj conj_inv _ _ --TODO: Do we rather want the map as an explicit definition? lemma exists_norm_eq_mul_self (x : K) : ∃ c, ‖c‖ = 1 ∧ ↑‖x‖ = c * x := by obtain rfl | hx := eq_or_ne x 0 · exact ⟨1, by simp⟩ · exact ⟨‖x‖ / x, by simp [norm_ne_zero_iff.2, hx]⟩ lemma exists_norm_mul_eq_self (x : K) : ∃ c, ‖c‖ = 1 ∧ c * ‖x‖ = x := by obtain rfl | hx := eq_or_ne x 0 · exact ⟨1, by simp⟩ · exact ⟨x / ‖x‖, by simp [norm_ne_zero_iff.2, hx]⟩ @[rclike_simps, norm_cast] theorem ofReal_div (r s : ℝ) : ((r / s : ℝ) : K) = r / s := map_div₀ (algebraMap ℝ K) r s theorem div_re_ofReal {z : K} {r : ℝ} : re (z / r) = re z / r := by rw [div_eq_inv_mul, div_eq_inv_mul, ← ofReal_inv, re_ofReal_mul] @[rclike_simps, norm_cast] theorem ofReal_zpow (r : ℝ) (n : ℤ) : ((r ^ n : ℝ) : K) = (r : K) ^ n := map_zpow₀ (algebraMap ℝ K) r n theorem I_mul_I_of_nonzero : (I : K) ≠ 0 → (I : K) * I = -1 := I_mul_I_ax.resolve_left @[simp, rclike_simps] theorem inv_I : (I : K)⁻¹ = -I := by by_cases h : (I : K) = 0 · simp [h] · field_simp linear_combination I_mul_I_of_nonzero h @[simp, rclike_simps] theorem div_I (z : K) : z / I = -(z * I) := by rw [div_eq_mul_inv, inv_I, mul_neg] -- Not `@[simp]` since `simp` can prove this. @[rclike_simps] theorem normSq_inv (z : K) : normSq z⁻¹ = (normSq z)⁻¹ := map_inv₀ normSq z -- Not `@[simp]` since `simp` can prove this. @[rclike_simps] theorem normSq_div (z w : K) : normSq (z / w) = normSq z / normSq w := map_div₀ normSq z w @[simp 1100, rclike_simps] theorem norm_conj (z : K) : ‖conj z‖ = ‖z‖ := by simp only [← sqrt_normSq_eq_norm, normSq_conj] @[simp 1100, rclike_simps] lemma nnnorm_conj (z : K) : ‖conj z‖₊ = ‖z‖₊ := by simp [nnnorm] @[simp 1100, rclike_simps] lemma enorm_conj (z : K) : ‖conj z‖ₑ = ‖z‖ₑ := by simp [enorm] instance (priority := 100) : CStarRing K where norm_mul_self_le x := le_of_eq <| ((norm_mul _ _).trans <| congr_arg (· * ‖x‖) (norm_conj _)).symm instance : StarModule ℝ K where star_smul r a := by apply RCLike.ext <;> simp [RCLike.smul_re, RCLike.smul_im] /-! ### Cast lemmas -/ @[rclike_simps, norm_cast] theorem ofReal_natCast (n : ℕ) : ((n : ℝ) : K) = n := map_natCast (algebraMap ℝ K) n @[rclike_simps, norm_cast] lemma ofReal_nnratCast (q : ℚ≥0) : ((q : ℝ) : K) = q := map_nnratCast (algebraMap ℝ K) _ @[simp, rclike_simps] theorem natCast_re (n : ℕ) : re (n : K) = n := by rw [← ofReal_natCast, ofReal_re] @[simp, rclike_simps, norm_cast] theorem natCast_im (n : ℕ) : im (n : K) = 0 := by rw [← ofReal_natCast, ofReal_im] @[simp, rclike_simps] theorem ofNat_re (n : ℕ) [n.AtLeastTwo] : re (ofNat(n) : K) = ofNat(n) := natCast_re n @[simp, rclike_simps] theorem ofNat_im (n : ℕ) [n.AtLeastTwo] : im (ofNat(n) : K) = 0 := natCast_im n @[rclike_simps, norm_cast] theorem ofReal_ofNat (n : ℕ) [n.AtLeastTwo] : ((ofNat(n) : ℝ) : K) = ofNat(n) := ofReal_natCast n theorem ofNat_mul_re (n : ℕ) [n.AtLeastTwo] (z : K) : re (ofNat(n) * z) = ofNat(n) * re z := by rw [← ofReal_ofNat, re_ofReal_mul] theorem ofNat_mul_im (n : ℕ) [n.AtLeastTwo] (z : K) : im (ofNat(n) * z) = ofNat(n) * im z := by rw [← ofReal_ofNat, im_ofReal_mul] @[rclike_simps, norm_cast] theorem ofReal_intCast (n : ℤ) : ((n : ℝ) : K) = n := map_intCast _ n @[simp, rclike_simps] theorem intCast_re (n : ℤ) : re (n : K) = n := by rw [← ofReal_intCast, ofReal_re] @[simp, rclike_simps, norm_cast] theorem intCast_im (n : ℤ) : im (n : K) = 0 := by rw [← ofReal_intCast, ofReal_im] @[rclike_simps, norm_cast] theorem ofReal_ratCast (n : ℚ) : ((n : ℝ) : K) = n := map_ratCast _ n @[simp, rclike_simps] theorem ratCast_re (q : ℚ) : re (q : K) = q := by rw [← ofReal_ratCast, ofReal_re] @[simp, rclike_simps, norm_cast] theorem ratCast_im (q : ℚ) : im (q : K) = 0 := by rw [← ofReal_ratCast, ofReal_im] /-! ### Norm -/ theorem norm_of_nonneg {r : ℝ} (h : 0 ≤ r) : ‖(r : K)‖ = r := (norm_ofReal _).trans (abs_of_nonneg h) @[simp 1100, rclike_simps, norm_cast] theorem norm_natCast (n : ℕ) : ‖(n : K)‖ = n := by rw [← ofReal_natCast] exact norm_of_nonneg (Nat.cast_nonneg n) @[simp, rclike_simps, norm_cast] lemma nnnorm_natCast (n : ℕ) : ‖(n : K)‖₊ = n := by simp [nnnorm] @[simp, rclike_simps] theorem norm_ofNat (n : ℕ) [n.AtLeastTwo] : ‖(ofNat(n) : K)‖ = ofNat(n) := norm_natCast n @[simp, rclike_simps] lemma nnnorm_ofNat (n : ℕ) [n.AtLeastTwo] : ‖(ofNat(n) : K)‖₊ = ofNat(n) := nnnorm_natCast n lemma norm_two : ‖(2 : K)‖ = 2 := norm_ofNat 2 lemma nnnorm_two : ‖(2 : K)‖₊ = 2 := nnnorm_ofNat 2 @[simp, rclike_simps, norm_cast] lemma norm_nnratCast (q : ℚ≥0) : ‖(q : K)‖ = q := by rw [← ofReal_nnratCast]; exact norm_of_nonneg q.cast_nonneg @[simp, rclike_simps, norm_cast] lemma nnnorm_nnratCast (q : ℚ≥0) : ‖(q : K)‖₊ = q := by simp [nnnorm] variable (K) in lemma norm_nsmul [NormedAddCommGroup E] [NormedSpace K E] (n : ℕ) (x : E) : ‖n • x‖ = n • ‖x‖ := by simpa [Nat.cast_smul_eq_nsmul] using norm_smul (n : K) x variable (K) in lemma nnnorm_nsmul [NormedAddCommGroup E] [NormedSpace K E] (n : ℕ) (x : E) : ‖n • x‖₊ = n • ‖x‖₊ := by simpa [Nat.cast_smul_eq_nsmul] using nnnorm_smul (n : K) x section NormedField variable [NormedField E] [CharZero E] [NormedSpace K E] include K variable (K) in lemma norm_nnqsmul (q : ℚ≥0) (x : E) : ‖q • x‖ = q • ‖x‖ := by simpa [NNRat.cast_smul_eq_nnqsmul] using norm_smul (q : K) x variable (K) in lemma nnnorm_nnqsmul (q : ℚ≥0) (x : E) : ‖q • x‖₊ = q • ‖x‖₊ := by simpa [NNRat.cast_smul_eq_nnqsmul] using nnnorm_smul (q : K) x @[bound] lemma norm_expect_le {ι : Type*} {s : Finset ι} {f : ι → E} : ‖𝔼 i ∈ s, f i‖ ≤ 𝔼 i ∈ s, ‖f i‖ := Finset.le_expect_of_subadditive norm_zero norm_add_le fun _ _ ↦ by rw [norm_nnqsmul K] end NormedField theorem mul_self_norm (z : K) : ‖z‖ * ‖z‖ = normSq z := by rw [normSq_eq_def', sq] attribute [rclike_simps] norm_zero norm_one norm_eq_zero abs_norm norm_inv norm_div theorem abs_re_le_norm (z : K) : |re z| ≤ ‖z‖ := by rw [mul_self_le_mul_self_iff (abs_nonneg _) (norm_nonneg _), abs_mul_abs_self, mul_self_norm] apply re_sq_le_normSq theorem abs_im_le_norm (z : K) : |im z| ≤ ‖z‖ := by rw [mul_self_le_mul_self_iff (abs_nonneg _) (norm_nonneg _), abs_mul_abs_self, mul_self_norm] apply im_sq_le_normSq theorem norm_re_le_norm (z : K) : ‖re z‖ ≤ ‖z‖ := abs_re_le_norm z theorem norm_im_le_norm (z : K) : ‖im z‖ ≤ ‖z‖ := abs_im_le_norm z theorem re_le_norm (z : K) : re z ≤ ‖z‖ := (abs_le.1 (abs_re_le_norm z)).2 theorem im_le_norm (z : K) : im z ≤ ‖z‖ := (abs_le.1 (abs_im_le_norm _)).2 theorem im_eq_zero_of_le {a : K} (h : ‖a‖ ≤ re a) : im a = 0 := by simpa only [mul_self_norm a, normSq_apply, left_eq_add, mul_self_eq_zero] using congr_arg (fun z => z * z) ((re_le_norm a).antisymm h) theorem re_eq_self_of_le {a : K} (h : ‖a‖ ≤ re a) : (re a : K) = a := by rw [← conj_eq_iff_re, conj_eq_iff_im, im_eq_zero_of_le h] open IsAbsoluteValue theorem abs_re_div_norm_le_one (z : K) : |re z / ‖z‖| ≤ 1 := by rw [abs_div, abs_norm] exact div_le_one_of_le₀ (abs_re_le_norm _) (norm_nonneg _) theorem abs_im_div_norm_le_one (z : K) : |im z / ‖z‖| ≤ 1 := by rw [abs_div, abs_norm] exact div_le_one_of_le₀ (abs_im_le_norm _) (norm_nonneg _) theorem norm_I_of_ne_zero (hI : (I : K) ≠ 0) : ‖(I : K)‖ = 1 := by rw [← mul_self_inj_of_nonneg (norm_nonneg I) zero_le_one, one_mul, ← norm_mul, I_mul_I_of_nonzero hI, norm_neg, norm_one] theorem re_eq_norm_of_mul_conj (x : K) : re (x * conj x) = ‖x * conj x‖ := by rw [mul_conj, ← ofReal_pow]; simp [-map_pow] theorem norm_sq_re_add_conj (x : K) : ‖x + conj x‖ ^ 2 = re (x + conj x) ^ 2 := by rw [add_conj, ← ofReal_ofNat, ← ofReal_mul, norm_ofReal, sq_abs, ofReal_re] theorem norm_sq_re_conj_add (x : K) : ‖conj x + x‖ ^ 2 = re (conj x + x) ^ 2 := by rw [add_comm, norm_sq_re_add_conj] instance : NormSMulClass ℤ K where norm_smul r x := by rw [zsmul_eq_mul, norm_mul, ← ofReal_intCast, norm_ofReal, Int.norm_eq_abs] /-! ### Cauchy sequences -/ theorem isCauSeq_re (f : CauSeq K norm) : IsCauSeq abs fun n => re (f n) := fun _ ε0 => (f.cauchy ε0).imp fun i H j ij => lt_of_le_of_lt (by simpa only [map_sub] using abs_re_le_norm (f j - f i)) (H _ ij) theorem isCauSeq_im (f : CauSeq K norm) : IsCauSeq abs fun n => im (f n) := fun _ ε0 => (f.cauchy ε0).imp fun i H j ij => lt_of_le_of_lt (by simpa only [map_sub] using abs_im_le_norm (f j - f i)) (H _ ij) /-- The real part of a K Cauchy sequence, as a real Cauchy sequence. -/ noncomputable def cauSeqRe (f : CauSeq K norm) : CauSeq ℝ abs := ⟨_, isCauSeq_re f⟩ /-- The imaginary part of a K Cauchy sequence, as a real Cauchy sequence. -/ noncomputable def cauSeqIm (f : CauSeq K norm) : CauSeq ℝ abs := ⟨_, isCauSeq_im f⟩ theorem isCauSeq_norm {f : ℕ → K} (hf : IsCauSeq norm f) : IsCauSeq abs (norm ∘ f) := fun ε ε0 => let ⟨i, hi⟩ := hf ε ε0 ⟨i, fun j hj => lt_of_le_of_lt (abs_norm_sub_norm_le _ _) (hi j hj)⟩ end RCLike section Instances noncomputable instance Real.instRCLike : RCLike ℝ where re := AddMonoidHom.id ℝ im := 0 I := 0 I_re_ax := by simp only [AddMonoidHom.map_zero] I_mul_I_ax := Or.intro_left _ rfl re_add_im_ax z := by simp only [add_zero, mul_zero, Algebra.algebraMap_self, RingHom.id_apply, AddMonoidHom.id_apply] ofReal_re_ax _ := rfl ofReal_im_ax _ := rfl mul_re_ax z w := by simp only [sub_zero, mul_zero, AddMonoidHom.zero_apply, AddMonoidHom.id_apply] mul_im_ax z w := by simp only [add_zero, zero_mul, mul_zero, AddMonoidHom.zero_apply] conj_re_ax z := by simp only [starRingEnd_apply, star_id_of_comm] conj_im_ax _ := by simp only [neg_zero, AddMonoidHom.zero_apply] conj_I_ax := by simp only [RingHom.map_zero, neg_zero] norm_sq_eq_def_ax z := by simp only [sq, Real.norm_eq_abs, ← abs_mul, abs_mul_self z, add_zero, mul_zero, AddMonoidHom.zero_apply, AddMonoidHom.id_apply] mul_im_I_ax _ := by simp only [mul_zero, AddMonoidHom.zero_apply] le_iff_re_im := (and_iff_left rfl).symm end Instances namespace RCLike section Order open scoped ComplexOrder variable {z w : K} theorem lt_iff_re_im : z < w ↔ re z < re w ∧ im z = im w := by simp_rw [lt_iff_le_and_ne, @RCLike.le_iff_re_im K] constructor · rintro ⟨⟨hr, hi⟩, heq⟩ exact ⟨⟨hr, mt (fun hreq => ext hreq hi) heq⟩, hi⟩ · rintro ⟨⟨hr, hrn⟩, hi⟩ exact ⟨⟨hr, hi⟩, ne_of_apply_ne _ hrn⟩ theorem nonneg_iff : 0 ≤ z ↔ 0 ≤ re z ∧ im z = 0 := by simpa only [map_zero, eq_comm] using le_iff_re_im (z := 0) (w := z) theorem pos_iff : 0 < z ↔ 0 < re z ∧ im z = 0 := by simpa only [map_zero, eq_comm] using lt_iff_re_im (z := 0) (w := z) theorem nonpos_iff : z ≤ 0 ↔ re z ≤ 0 ∧ im z = 0 := by simpa only [map_zero] using le_iff_re_im (z := z) (w := 0) theorem neg_iff : z < 0 ↔ re z < 0 ∧ im z = 0 := by simpa only [map_zero] using lt_iff_re_im (z := z) (w := 0) lemma nonneg_iff_exists_ofReal : 0 ≤ z ↔ ∃ x ≥ (0 : ℝ), x = z := by simp_rw [nonneg_iff (K := K), ext_iff (K := K)]; aesop lemma pos_iff_exists_ofReal : 0 < z ↔ ∃ x > (0 : ℝ), x = z := by simp_rw [pos_iff (K := K), ext_iff (K := K)]; aesop lemma nonpos_iff_exists_ofReal : z ≤ 0 ↔ ∃ x ≤ (0 : ℝ), x = z := by simp_rw [nonpos_iff (K := K), ext_iff (K := K)]; aesop lemma neg_iff_exists_ofReal : z < 0 ↔ ∃ x < (0 : ℝ), x = z := by simp_rw [neg_iff (K := K), ext_iff (K := K)]; aesop @[simp, norm_cast] lemma ofReal_le_ofReal {x y : ℝ} : (x : K) ≤ (y : K) ↔ x ≤ y := by rw [le_iff_re_im] simp @[simp, norm_cast] lemma ofReal_lt_ofReal {x y : ℝ} : (x : K) < (y : K) ↔ x < y := by rw [lt_iff_re_im] simp @[simp, norm_cast] lemma ofReal_nonneg {x : ℝ} : 0 ≤ (x : K) ↔ 0 ≤ x := by rw [← ofReal_zero, ofReal_le_ofReal] @[simp, norm_cast] lemma ofReal_nonpos {x : ℝ} : (x : K) ≤ 0 ↔ x ≤ 0 := by rw [← ofReal_zero, ofReal_le_ofReal] @[simp, norm_cast] lemma ofReal_pos {x : ℝ} : 0 < (x : K) ↔ 0 < x := by rw [← ofReal_zero, ofReal_lt_ofReal] @[simp, norm_cast] lemma ofReal_lt_zero {x : ℝ} : (x : K) < 0 ↔ x < 0 := by rw [← ofReal_zero, ofReal_lt_ofReal] lemma norm_le_re_iff_eq_norm {z : K} : ‖z‖ ≤ re z ↔ z = ‖z‖ := by refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩ · have h' : ‖z‖ = re z := (le_antisymm (re_le_norm z) h).symm rw [h', re_eq_self_of_le h] · rw [h] simp lemma re_le_neg_norm_iff_eq_neg_norm {z : K} : re z ≤ -‖z‖ ↔ z = -‖z‖ := by simpa [neg_eq_iff_eq_neg, le_neg] using norm_le_re_iff_eq_norm (z := -z) lemma norm_of_nonneg' {x : K} (hx : 0 ≤ x) : ‖x‖ = x := by rw [eq_comm, ← norm_le_re_iff_eq_norm, ← sqrt_normSq_eq_norm, normSq_apply] simp [nonneg_iff.mp hx] lemma re_nonneg_of_nonneg {x : K} (hx : IsSelfAdjoint x) : 0 ≤ re x ↔ 0 ≤ x := by simp [nonneg_iff (K := K), conj_eq_iff_im.mp hx] @[gcongr] lemma re_le_re {x y : K} (h : x ≤ y) : re x ≤ re y := by rw [RCLike.le_iff_re_im] at h exact h.1 lemma re_monotone : Monotone (re : K → ℝ) := fun _ _ => re_le_re protected lemma inv_pos_of_pos (hz : 0 < z) : 0 < z⁻¹ := by rw [pos_iff_exists_ofReal] at hz obtain ⟨x, hx, hx'⟩ := hz rw [← hx', ← ofReal_inv, ofReal_pos] exact inv_pos_of_pos hx protected lemma inv_pos : 0 < z⁻¹ ↔ 0 < z := by refine ⟨fun h => ?_, fun h => RCLike.inv_pos_of_pos h⟩ rw [← inv_inv z] exact RCLike.inv_pos_of_pos h /-- With `z ≤ w` iff `w - z` is real and nonnegative, `ℝ` and `ℂ` are star ordered rings. (That is, a star ring in which the nonnegative elements are those of the form `star z * z`.) Note this is only an instance with `open scoped ComplexOrder`. -/ lemma toStarOrderedRing : StarOrderedRing K := StarOrderedRing.of_nonneg_iff' (h_add := fun {x y} hxy z => by rw [RCLike.le_iff_re_im] at * simpa [map_add, add_le_add_iff_left, add_right_inj] using hxy) (h_nonneg_iff := fun x => by rw [nonneg_iff] refine ⟨fun h ↦ ⟨√(re x), by simp [ext_iff (K := K), h.1, h.2]⟩, ?_⟩ rintro ⟨s, rfl⟩ simp [mul_comm, mul_self_nonneg, add_nonneg]) scoped[ComplexOrder] attribute [instance] RCLike.toStarOrderedRing lemma toZeroLEOneClass : ZeroLEOneClass K where zero_le_one := by simp [@RCLike.le_iff_re_im K] scoped[ComplexOrder] attribute [instance] RCLike.toZeroLEOneClass lemma toIsOrderedAddMonoid : IsOrderedAddMonoid K where add_le_add_left _ _ := add_le_add_left scoped[ComplexOrder] attribute [instance] RCLike.toIsOrderedAddMonoid /-- With `z ≤ w` iff `w - z` is real and nonnegative, `ℝ` and `ℂ` are strictly ordered rings. Note this is only an instance with `open scoped ComplexOrder`. -/ lemma toIsStrictOrderedRing : IsStrictOrderedRing K := .of_mul_pos fun z w hz hw ↦ by rw [lt_iff_re_im, map_zero] at hz hw ⊢ simp [mul_re, mul_im, ← hz.2, ← hw.2, mul_pos hz.1 hw.1] scoped[ComplexOrder] attribute [instance] RCLike.toIsStrictOrderedRing lemma toPosMulReflectLT : PosMulReflectLT K where elim := by rintro ⟨x, hx⟩ y z hyz dsimp at * rw [RCLike.le_iff_re_im, map_zero, map_zero, eq_comm] at hx obtain ⟨r, rfl⟩ := ((is_real_TFAE x).out 3 1).1 hx.2 simp only [RCLike.lt_iff_re_im (K := K), mul_re, ofReal_re, ofReal_im, zero_mul, sub_zero, mul_im, add_zero, mul_eq_mul_left_iff] at hyz ⊢ refine ⟨lt_of_mul_lt_mul_of_nonneg_left hyz.1 <| by simpa using hx, hyz.2.resolve_right ?_⟩ rintro rfl simp at hyz scoped[ComplexOrder] attribute [instance] RCLike.toPosMulReflectLT theorem toIsStrictOrderedModule : IsStrictOrderedModule ℝ K where smul_lt_smul_of_pos_left r hr a b hab := by simpa [RCLike.lt_iff_re_im (K := K), smul_re, smul_im, hr, hr.ne'] using hab smul_lt_smul_of_pos_right a ha r₁ r₂ hr := by obtain ⟨hare, haim⟩ := RCLike.lt_iff_re_im.1 ha simp_all [RCLike.lt_iff_re_im (K := K), smul_re, smul_im] scoped[ComplexOrder] attribute [instance] RCLike.toIsStrictOrderedModule theorem ofReal_mul_pos_iff (x : ℝ) (z : K) : 0 < x * z ↔ (x < 0 ∧ z < 0) ∨ (0 < x ∧ 0 < z) := by simp only [pos_iff (K := K), neg_iff (K := K), re_ofReal_mul, im_ofReal_mul] obtain hx | hx | hx := lt_trichotomy x 0 · simp only [mul_pos_iff, not_lt_of_gt hx, false_and, hx, true_and, false_or, mul_eq_zero, hx.ne, or_false] · simp only [hx, zero_mul, lt_self_iff_false, false_and, false_or] · simp only [mul_pos_iff, hx, true_and, not_lt_of_gt hx, false_and, or_false, mul_eq_zero, hx.ne', false_or] theorem ofReal_mul_neg_iff (x : ℝ) (z : K) : x * z < 0 ↔ (x < 0 ∧ 0 < z) ∨ (0 < x ∧ z < 0) := by simpa only [mul_neg, neg_pos, neg_neg_iff_pos] using ofReal_mul_pos_iff x (-z) lemma instPosMulReflectLE : PosMulReflectLE K where elim a b c h := by obtain ⟨a', ha1, ha2⟩ := pos_iff_exists_ofReal.mp a.2 rw [← sub_nonneg] #adaptation_note /-- 2025-03-29 need beta reduce for https://github.com/leanprover/lean4/issues/7717 -/ beta_reduce at h rw [← ha2, ← sub_nonneg, ← mul_sub, le_iff_lt_or_eq] at h rcases h with h | h · rw [ofReal_mul_pos_iff] at h exact le_of_lt <| h.rec (False.elim <| not_lt_of_gt ·.1 ha1) (·.2) · exact ((mul_eq_zero_iff_left <| ofReal_ne_zero.mpr ha1.ne').mp h.symm).ge scoped[ComplexOrder] attribute [instance] RCLike.instPosMulReflectLE end Order section CleanupLemmas local notation "reR" => @RCLike.re ℝ _ local notation "imR" => @RCLike.im ℝ _ local notation "IR" => @RCLike.I ℝ _ local notation "normSqR" => @RCLike.normSq ℝ _ @[simp, rclike_simps] theorem re_to_real {x : ℝ} : reR x = x := rfl @[simp, rclike_simps] theorem im_to_real {x : ℝ} : imR x = 0 := rfl @[rclike_simps] theorem conj_to_real {x : ℝ} : conj x = x := rfl @[simp, rclike_simps] theorem I_to_real : IR = 0 := rfl @[simp, rclike_simps] theorem normSq_to_real {x : ℝ} : normSq x = x * x := by simp [RCLike.normSq] @[simp] theorem ofReal_real_eq_id : @ofReal ℝ _ = id := rfl end CleanupLemmas section LinearMaps /-- The real part in an `RCLike` field, as a linear map. -/ def reLm : K →ₗ[ℝ] ℝ := { re with map_smul' := smul_re } @[simp, rclike_simps] theorem reLm_coe : (reLm : K → ℝ) = re := rfl /-- The real part in an `RCLike` field, as a continuous linear map. -/ noncomputable def reCLM : StrongDual ℝ K := reLm.mkContinuous 1 fun x => by rw [one_mul] exact abs_re_le_norm x @[simp, rclike_simps, norm_cast] theorem reCLM_coe : ((reCLM : StrongDual ℝ K) : K →ₗ[ℝ] ℝ) = reLm := rfl @[simp, rclike_simps] theorem reCLM_apply : ((reCLM : StrongDual ℝ K) : K → ℝ) = re := rfl @[continuity, fun_prop] theorem continuous_re : Continuous (re : K → ℝ) := reCLM.continuous /-- The imaginary part in an `RCLike` field, as a linear map. -/ def imLm : K →ₗ[ℝ] ℝ := { im with map_smul' := smul_im } @[simp, rclike_simps] theorem imLm_coe : (imLm : K → ℝ) = im := rfl /-- The imaginary part in an `RCLike` field, as a continuous linear map. -/ noncomputable def imCLM : StrongDual ℝ K := imLm.mkContinuous 1 fun x => by rw [one_mul] exact abs_im_le_norm x @[simp, rclike_simps, norm_cast] theorem imCLM_coe : ((imCLM : StrongDual ℝ K) : K →ₗ[ℝ] ℝ) = imLm := rfl @[simp, rclike_simps] theorem imCLM_apply : ((imCLM : StrongDual ℝ K) : K → ℝ) = im := rfl @[continuity, fun_prop] theorem continuous_im : Continuous (im : K → ℝ) := imCLM.continuous /-- Conjugate as an `ℝ`-algebra equivalence -/ def conjAe : K ≃ₐ[ℝ] K := { conj with invFun := conj left_inv := conj_conj right_inv := conj_conj commutes' := conj_ofReal } @[simp, rclike_simps] theorem conjAe_coe : (conjAe : K → K) = conj := rfl /-- Conjugate as a linear isometry -/ noncomputable def conjLIE : K ≃ₗᵢ[ℝ] K := ⟨conjAe.toLinearEquiv, norm_conj⟩ @[simp, rclike_simps] theorem conjLIE_apply : (conjLIE : K → K) = conj := rfl /-- Conjugate as a continuous linear equivalence -/ noncomputable def conjCLE : K ≃L[ℝ] K := @conjLIE K _ @[simp, rclike_simps] theorem conjCLE_coe : (@conjCLE K _).toLinearEquiv = conjAe.toLinearEquiv := rfl @[simp, rclike_simps] theorem conjCLE_apply : (conjCLE : K → K) = conj := rfl instance (priority := 100) : ContinuousStar K := ⟨conjLIE.continuous⟩ @[continuity] theorem continuous_conj : Continuous (conj : K → K) := continuous_star /-- The `ℝ → K` coercion, as a linear map -/ noncomputable def ofRealAm : ℝ →ₐ[ℝ] K := Algebra.ofId ℝ K @[simp, rclike_simps] theorem ofRealAm_coe : (ofRealAm : ℝ → K) = ofReal := rfl /-- The ℝ → K coercion, as a linear isometry -/ noncomputable def ofRealLI : ℝ →ₗᵢ[ℝ] K where toLinearMap := ofRealAm.toLinearMap norm_map' := norm_ofReal @[simp, rclike_simps] theorem ofRealLI_apply : (ofRealLI : ℝ → K) = ofReal := rfl /-- The `ℝ → K` coercion, as a continuous linear map -/ noncomputable def ofRealCLM : ℝ →L[ℝ] K := ofRealLI.toContinuousLinearMap @[simp, rclike_simps] theorem ofRealCLM_coe : (@ofRealCLM K _ : ℝ →ₗ[ℝ] K) = ofRealAm.toLinearMap := rfl @[simp, rclike_simps] theorem ofRealCLM_apply : (ofRealCLM : ℝ → K) = ofReal := rfl @[continuity, fun_prop] theorem continuous_ofReal : Continuous (ofReal : ℝ → K) := ofRealLI.continuous @[continuity] theorem continuous_normSq : Continuous (normSq : K → ℝ) := (continuous_re.mul continuous_re).add (continuous_im.mul continuous_im) theorem lipschitzWith_ofReal : LipschitzWith 1 (ofReal : ℝ → K) := ofRealLI.lipschitz lemma lipschitzWith_re : LipschitzWith 1 (re (K := K)) := by intro x y simp only [ENNReal.coe_one, one_mul, edist_eq_enorm_sub] calc ‖re x - re y‖ₑ _ = ‖re (x - y)‖ₑ := by rw [ AddMonoidHom.map_sub re x y] _ ≤ ‖x - y‖ₑ := by rw [enorm_le_iff_norm_le]; exact norm_re_le_norm (x - y) lemma lipschitzWith_im : LipschitzWith 1 (im (K := K)) := by intro x y simp only [ENNReal.coe_one, one_mul, edist_eq_enorm_sub] calc ‖im x - im y‖ₑ _ = ‖im (x - y)‖ₑ := by rw [ AddMonoidHom.map_sub im x y] _ ≤ ‖x - y‖ₑ := by rw [enorm_le_iff_norm_le]; exact norm_im_le_norm (x - y) end LinearMaps /-! ### ℝ-dependent results Here we gather results that depend on whether `K` is `ℝ`. -/ section CaseSpecific lemma im_eq_zero (h : I = (0 : K)) (z : K) : im z = 0 := by rw [← re_add_im z, h] simp /-- The natural isomorphism between `𝕜` satisfying `RCLike 𝕜` and `ℝ` when `RCLike.I = 0`. -/ @[simps] def realRingEquiv (h : I = (0 : K)) : K ≃+* ℝ where toFun := re invFun := (↑) left_inv x := by nth_rw 2 [← re_add_im x]; simp [h] right_inv := ofReal_re map_add' := map_add re map_mul' := by simp [im_eq_zero h] /-- The natural `ℝ`-linear isometry equivalence between `𝕜` satisfying `RCLike 𝕜` and `ℝ` when `RCLike.I = 0`. -/ @[simps] noncomputable def realLinearIsometryEquiv (h : I = (0 : K)) : K ≃ₗᵢ[ℝ] ℝ where map_smul' := smul_re norm_map' z := by rw [← re_add_im z]; simp [- re_add_im, h] __ := realRingEquiv h end CaseSpecific lemma norm_le_im_iff_eq_I_mul_norm {z : K} : ‖z‖ ≤ im z ↔ z = I * ‖z‖ := by obtain (h | h) := I_eq_zero_or_im_I_eq_one (K := K) · simp [h, im_eq_zero] · have : (I : K) ≠ 0 := fun _ ↦ by simp_all rw [← mul_right_inj' (neg_ne_zero.mpr this)] convert norm_le_re_iff_eq_norm (z := -I * z) using 2 all_goals simp [neg_mul, ← mul_assoc, I_mul_I_of_nonzero this, norm_I_of_ne_zero this] lemma im_le_neg_norm_iff_eq_neg_I_mul_norm {z : K} : im z ≤ -‖z‖ ↔ z = -(I * ‖z‖) := by simpa [neg_eq_iff_eq_neg, le_neg] using norm_le_im_iff_eq_I_mul_norm (z := -z) end RCLike namespace AddChar variable {G : Type*} [Finite G] lemma inv_apply_eq_conj [AddLeftCancelMonoid G] (ψ : AddChar G K) (x : G) : (ψ x)⁻¹ = conj (ψ x) := RCLike.inv_eq_conj <| norm_apply _ _ lemma map_neg_eq_conj [AddCommGroup G] (ψ : AddChar G K) (x : G) : ψ (-x) = conj (ψ x) := by rw [map_neg_eq_inv, inv_apply_eq_conj] end AddChar section /-- A mixin over a normed field, saying that the norm field structure is the same as `ℝ` or `ℂ`. To endow such a field with a compatible `RCLike` structure in a proof, use `letI := IsRCLikeNormedField.rclike 𝕜`. -/ class IsRCLikeNormedField (𝕜 : Type*) [hk : NormedField 𝕜] : Prop where out : ∃ h : RCLike 𝕜, hk = h.toNormedField instance (priority := 100) (𝕜 : Type*) [h : RCLike 𝕜] : IsRCLikeNormedField 𝕜 := ⟨⟨h, rfl⟩⟩ /-- A copy of an `RCLike` field in which the `NormedField` field is adjusted to be become defeq to a propeq one. -/ noncomputable def RCLike.copy_of_normedField {𝕜 : Type*} (h : RCLike 𝕜) (hk : NormedField 𝕜) (h'' : hk = h.toNormedField) : RCLike 𝕜 where __ := hk toPartialOrder := h.toPartialOrder toDecidableEq := h.toDecidableEq complete := by subst h''; exact h.complete lt_norm_lt := by subst h''; exact h.lt_norm_lt -- star fields star := (@StarMul.toInvolutiveStar _ (_) (@StarRing.toStarMul _ (_) h.toStarRing)).star star_involutive := by subst h''; exact h.star_involutive star_mul := by subst h''; exact h.star_mul star_add := by subst h''; exact h.star_add -- algebra fields smul := (@Algebra.toSMul _ _ _ (_) (@NormedAlgebra.toAlgebra _ _ _ (_) h.toNormedAlgebra)).smul algebraMap := { toFun := @Algebra.algebraMap _ _ _ (_) (@NormedAlgebra.toAlgebra _ _ _ (_) h.toNormedAlgebra) map_one' := by subst h''; exact h.algebraMap.map_one' map_mul' := by subst h''; exact h.algebraMap.map_mul' map_zero' := by subst h''; exact h.algebraMap.map_zero' map_add' := by subst h''; exact h.algebraMap.map_add' } commutes' := by subst h''; exact h.commutes' smul_def' := by subst h''; exact h.smul_def' norm_smul_le := by subst h''; exact h.norm_smul_le -- RCLike fields re := by subst h''; exact h.re im := by subst h''; exact h.im I := h.I I_re_ax := by subst h''; exact h.I_re_ax I_mul_I_ax := by subst h''; exact h.I_mul_I_ax re_add_im_ax := by subst h''; exact h.re_add_im_ax ofReal_re_ax := by subst h''; exact h.ofReal_re_ax ofReal_im_ax := by subst h''; exact h.ofReal_im_ax mul_re_ax := by subst h''; exact h.mul_re_ax mul_im_ax := by subst h''; exact h.mul_im_ax conj_re_ax := by subst h''; exact h.conj_re_ax conj_im_ax := by subst h''; exact h.conj_im_ax conj_I_ax := by subst h''; exact h.conj_I_ax norm_sq_eq_def_ax := by subst h''; exact h.norm_sq_eq_def_ax mul_im_I_ax := by subst h''; exact h.mul_im_I_ax le_iff_re_im := by subst h''; exact h.le_iff_re_im /-- Given a normed field `𝕜` satisfying `IsRCLikeNormedField 𝕜`, build an associated `RCLike 𝕜` structure on `𝕜` which is definitionally compatible with the given normed field structure. -/ noncomputable def IsRCLikeNormedField.rclike (𝕜 : Type*) [hk : NormedField 𝕜] [h : IsRCLikeNormedField 𝕜] : RCLike 𝕜 := by choose p hp using h.out exact p.copy_of_normedField hk hp end
.lake/packages/mathlib/Mathlib/Analysis/RCLike/Extend.lean
import Mathlib.Algebra.Algebra.RestrictScalars import Mathlib.Analysis.RCLike.Basic import Mathlib.LinearAlgebra.Dual.Defs /-! # Extending an `ℝ`-linear functional to a `𝕜`-linear functional In this file we provide a way to extend a (optionally, continuous) `ℝ`-linear map to a (continuous) `𝕜`-linear map in a way that bounds the norm by the norm of the original map, when `𝕜` is either `ℝ` (the extension is trivial) or `ℂ`. We formulate the extension uniformly, by assuming `RCLike 𝕜`. We motivate the form of the extension as follows. Note that `fc : F →ₗ[𝕜] 𝕜` is determined fully by `re fc`: for all `x : F`, `fc (I • x) = I * fc x`, so `im (fc x) = -re (fc (I • x))`. Therefore, given an `fr : F →ₗ[ℝ] ℝ`, we define `fc x = fr x - fr (I • x) * I`. In `Mathlib/Analysis/Normed/Module/RCLike/Extend.lean` we show that this extension is isometric. This is separate to avoid importing material about the operator norm into files about more elementary properties, like locally convex spaces. ## Main definitions * `LinearMap.extendTo𝕜` * `ContinuousLinearMap.extendTo𝕜` ## Implementation details For convenience, the main definitions above operate in terms of `RestrictScalars ℝ 𝕜 F`. Alternate forms which operate on `[IsScalarTower ℝ 𝕜 F]` instead are provided with a primed name. -/ open RCLike open ComplexConjugate variable {𝕜 : Type*} [RCLike 𝕜] {F : Type*} namespace LinearMap open Module section ScalarTower variable [AddCommGroup F] [Module ℝ F] [Module 𝕜 F] [IsScalarTower ℝ 𝕜 F] /-- Extend `fr : Dual ℝ F` to `Dual 𝕜 F` in a way that will also be continuous and have its norm (as a continuous linear map) equal to `‖fr‖` when `fr` is itself continuous on a normed space. -/ noncomputable def extendTo𝕜' (fr : Dual ℝ F) : Dual 𝕜 F := letI fc : F → 𝕜 := fun x => (fr x : 𝕜) - (I : 𝕜) * fr ((I : 𝕜) • x) have add (x y) : fc (x + y) = fc x + fc y := by simp only [fc, smul_add, map_add, mul_add] abel have A (c : ℝ) (x : F) : (fr ((c : 𝕜) • x) : 𝕜) = (c : 𝕜) * (fr x : 𝕜) := by simp have smul_ℝ (c : ℝ) (x : F) : fc ((c : 𝕜) • x) = (c : 𝕜) * fc x := by simp only [fc, A, smul_comm I, mul_comm I, mul_sub, mul_assoc] have smul_I (x : F) : fc ((I : 𝕜) • x) = (I : 𝕜) * fc x := by obtain (h | h) := @I_mul_I_ax 𝕜 _ · simp [fc, h] · simp [fc, mul_sub, ← mul_assoc, smul_smul, h, add_comm] have smul_𝕜 (c : 𝕜) (x : F) : fc (c • x) = c • fc x := by rw [← re_add_im c] simp only [add_smul, ← smul_smul, add, smul_ℝ, smul_I, ← mul_assoc, smul_eq_mul, add_mul] { toFun := fc map_add' := add map_smul' := smul_𝕜 } theorem extendTo𝕜'_apply (fr : Dual ℝ F) (x : F) : fr.extendTo𝕜' x = (fr x : 𝕜) - (I : 𝕜) * (fr ((I : 𝕜) • x) : 𝕜) := rfl @[simp] theorem extendTo𝕜'_apply_re (fr : Dual ℝ F) (x : F) : re (fr.extendTo𝕜' x : 𝕜) = fr x := by simp only [extendTo𝕜'_apply, map_sub, zero_mul, mul_zero, sub_zero, rclike_simps] theorem norm_extendTo𝕜'_apply_sq (fr : Dual ℝ F) (x : F) : ‖(fr.extendTo𝕜' x : 𝕜)‖ ^ 2 = fr (conj (fr.extendTo𝕜' x : 𝕜) • x) := calc ‖(fr.extendTo𝕜' x : 𝕜)‖ ^ 2 = re (conj (fr.extendTo𝕜' x) * fr.extendTo𝕜' x : 𝕜) := by rw [RCLike.conj_mul, ← ofReal_pow, ofReal_re] _ = fr (conj (fr.extendTo𝕜' x : 𝕜) • x) := by rw [← smul_eq_mul, ← map_smul, extendTo𝕜'_apply_re] end ScalarTower section RestrictScalars variable [SeminormedAddCommGroup F] [NormedSpace 𝕜 F] instance : NormedSpace 𝕜 (RestrictScalars ℝ 𝕜 F) := inferInstanceAs (NormedSpace 𝕜 F) /-- Extend `fr : Dual ℝ (RestrictScalars ℝ 𝕜 F)` to `Dual 𝕜 F`. -/ noncomputable def extendTo𝕜 (fr : Dual ℝ (RestrictScalars ℝ 𝕜 F)) : Dual 𝕜 F := fr.extendTo𝕜' theorem extendTo𝕜_apply (fr : RestrictScalars ℝ 𝕜 F →ₗ[ℝ] ℝ) (x : F) : fr.extendTo𝕜 x = (fr x : 𝕜) - (I : 𝕜) * (fr ((I : 𝕜) • x) : 𝕜) := rfl end RestrictScalars end LinearMap namespace ContinuousLinearMap variable [SeminormedAddCommGroup F] [NormedSpace 𝕜 F] section ScalarTower variable [NormedSpace ℝ F] [IsScalarTower ℝ 𝕜 F] /-- Extend `fr : StrongDual ℝ F` to `StrongDual 𝕜 F`. It would be possible to use `LinearMap.mkContinuous` here, but we would need to know that the continuity of `fr` implies it has bounded norm and we want to avoid that dependency here. Norm properties of this extension can be found in `Mathlib/Analysis/Normed/Module/RCLike/Extend.lean`. -/ noncomputable def extendTo𝕜' (fr : StrongDual ℝ F) : StrongDual 𝕜 F where __ := fr.toLinearMap.extendTo𝕜' cont := show Continuous fun x ↦ (fr x : 𝕜) - (I : 𝕜) * (fr ((I : 𝕜) • x) : 𝕜) by fun_prop theorem extendTo𝕜'_apply (fr : StrongDual ℝ F) (x : F) : fr.extendTo𝕜' x = (fr x : 𝕜) - (I : 𝕜) * (fr ((I : 𝕜) • x) : 𝕜) := rfl end ScalarTower /-- Extend `fr : StrongDual ℝ (RestrictScalars ℝ 𝕜 F)` to `StrongDual 𝕜 F`. -/ noncomputable def extendTo𝕜 (fr : StrongDual ℝ (RestrictScalars ℝ 𝕜 F)) : StrongDual 𝕜 F := fr.extendTo𝕜' theorem extendTo𝕜_apply (fr : StrongDual ℝ (RestrictScalars ℝ 𝕜 F)) (x : F) : fr.extendTo𝕜 x = (fr x : 𝕜) - (I : 𝕜) * (fr ((I : 𝕜) • x) : 𝕜) := rfl end ContinuousLinearMap
.lake/packages/mathlib/Mathlib/Analysis/RCLike/BoundedContinuous.lean
import Mathlib.Algebra.Algebra.Subalgebra.Tower import Mathlib.Analysis.Normed.Operator.NNNorm import Mathlib.Analysis.RCLike.Basic import Mathlib.Topology.ContinuousMap.Bounded.Star /-! # Results on bounded continuous functions with `RCLike` values -/ open Filter Real RCLike BoundedContinuousFunction open scoped Topology variable (𝕜 E : Type*) [RCLike 𝕜] [PseudoEMetricSpace E] namespace RCLike /-- On a star subalgebra of bounded continuous functions, the operations "restrict scalars to ℝ" and "forget that a bounded continuous function is a bounded" commute. -/ theorem restrict_toContinuousMap_eq_toContinuousMapStar_restrict {A : StarSubalgebra 𝕜 (E →ᵇ 𝕜)} : ((A.restrictScalars ℝ).comap (AlgHom.compLeftContinuousBounded ℝ ofRealAm lipschitzWith_ofReal)).map (toContinuousMapₐ ℝ) = ((A.map (toContinuousMapStarₐ 𝕜)).restrictScalars ℝ).comap (ofRealAm.compLeftContinuous ℝ continuous_ofReal) := by ext g simp only [Subalgebra.mem_map, Subalgebra.mem_comap, Subalgebra.mem_restrictScalars, StarSubalgebra.mem_toSubalgebra, toContinuousMapₐ_apply, StarSubalgebra.mem_map] constructor · intro ⟨x, hxA, hxg⟩ use (@ofRealAm 𝕜 _).compLeftContinuousBounded ℝ lipschitzWith_ofReal x, hxA ext a simp only [toContinuousMapStarₐ_apply_apply, AlgHom.compLeftContinuousBounded_apply_apply, ofRealAm_coe, AlgHom.compLeftContinuous_apply_apply, algebraMap.coe_inj] exact DFunLike.congr_fun hxg a · intro ⟨x, hxA, hxg⟩ have hg_apply (a : E) := DFunLike.congr_fun hxg a simp only [toContinuousMapStarₐ_apply_apply, AlgHom.compLeftContinuous_apply_apply, ofRealAm_coe] at hg_apply have h_comp_eq : (@ofRealAm 𝕜 _).compLeftContinuousBounded ℝ lipschitzWith_ofReal (x.comp reCLM (@reCLM 𝕜 _).lipschitz) = x := by ext a simp [hg_apply] use x.comp reCLM (@reCLM 𝕜 _).lipschitz refine ⟨by rwa [h_comp_eq], ?_⟩ ext a simp [hg_apply] end RCLike
.lake/packages/mathlib/Mathlib/Analysis/RCLike/TangentCone.lean
import Mathlib.Analysis.RCLike.Basic import Mathlib.Topology.Instances.RealVectorSpace import Mathlib.Analysis.Calculus.TangentCone.Real /-! # Relationships between unique differentiability over `ℝ` and `ℂ` A set of unique differentiability for `ℝ` is also a set of unique differentiability for `ℂ` (or for a general field satisfying `IsRCLikeNormedField 𝕜`). -/ variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] [h𝕜 : IsRCLikeNormedField 𝕜] {E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E] [NormedSpace ℝ E] {s : Set E} {x : E} theorem tangentConeAt_real_subset_isRCLikeNormedField : tangentConeAt ℝ s x ⊆ tangentConeAt 𝕜 s x := by letI := h𝕜.rclike exact tangentConeAt_mono_field theorem UniqueDiffWithinAt.of_real (hs : UniqueDiffWithinAt ℝ s x) : UniqueDiffWithinAt 𝕜 s x := by letI := h𝕜.rclike exact hs.mono_field theorem UniqueDiffOn.of_real (hs : UniqueDiffOn ℝ s) : UniqueDiffOn 𝕜 s := fun x hx ↦ (hs x hx).of_real /-- In a real or complex vector space, a convex set with nonempty interior is a set of unique differentiability. -/ theorem uniqueDiffWithinAt_convex_of_isRCLikeNormedField (conv : Convex ℝ s) (hs : (interior s).Nonempty) (hx : x ∈ closure s) : UniqueDiffWithinAt 𝕜 s x := UniqueDiffWithinAt.of_real (uniqueDiffWithinAt_convex conv hs hx) /-- In a real or complex vector space, a convex set with nonempty interior is a set of unique differentiability. -/ theorem uniqueDiffOn_convex_of_isRCLikeNormedField (conv : Convex ℝ s) (hs : (interior s).Nonempty) : UniqueDiffOn 𝕜 s := UniqueDiffOn.of_real (uniqueDiffOn_convex conv hs)
.lake/packages/mathlib/Mathlib/Analysis/VonNeumannAlgebra/Basic.lean
import Mathlib.Analysis.CStarAlgebra.Classes import Mathlib.Analysis.InnerProductSpace.Adjoint /-! # Von Neumann algebras We give the "abstract" and "concrete" definitions of a von Neumann algebra. We still have a major project ahead of us to show the equivalence between these definitions! An abstract von Neumann algebra `WStarAlgebra M` is a C^* algebra with a Banach space predual, per Sakai (1971). A concrete von Neumann algebra `VonNeumannAlgebra H` (where `H` is a Hilbert space) is a *-closed subalgebra of bounded operators on `H` which is equal to its double commutant. We'll also need to prove the von Neumann double commutant theorem, that the concrete definition is equivalent to a *-closed subalgebra which is weakly closed. -/ universe u v /-- Sakai's definition of a von Neumann algebra as a C^* algebra with a Banach space predual. So that we can unambiguously talk about these "abstract" von Neumann algebras in parallel with the "concrete" ones (weakly closed *-subalgebras of B(H)), we name this definition `WStarAlgebra`. Note that for now we only assert the mere existence of predual, rather than picking one. This may later prove problematic, and need to be revisited. Picking one may cause problems with definitional unification of different instances. One the other hand, not picking one means that the weak-* topology (which depends on a choice of predual) must be defined using the choice, and we may be unhappy with the resulting opaqueness of the definition. -/ class WStarAlgebra (M : Type u) [CStarAlgebra M] : Prop where /-- There is a Banach space `X` whose dual is isometrically (conjugate-linearly) isomorphic to the `WStarAlgebra`. -/ exists_predual : ∃ (X : Type u) (_ : NormedAddCommGroup X) (_ : NormedSpace ℂ X) (_ : CompleteSpace X), Nonempty (StrongDual ℂ X ≃ₗᵢ⋆[ℂ] M) -- TODO: Without this, `VonNeumannAlgebra` times out. Why? /-- The double commutant definition of a von Neumann algebra, as a *-closed subalgebra of bounded operators on a Hilbert space, which is equal to its double commutant. Note that this definition is parameterised by the Hilbert space on which the algebra faithfully acts, as is standard in the literature. See `WStarAlgebra` for the abstract notion (a C^*-algebra with Banach space predual). Note this is a bundled structure, parameterised by the Hilbert space `H`, rather than a typeclass on the type of elements. Thus we can't say that the bounded operators `H →L[ℂ] H` form a `VonNeumannAlgebra` (although we will later construct the instance `WStarAlgebra (H →L[ℂ] H)`), and instead will use `⊤ : VonNeumannAlgebra H`. -/ structure VonNeumannAlgebra (H : Type u) [NormedAddCommGroup H] [InnerProductSpace ℂ H] [CompleteSpace H] extends StarSubalgebra ℂ (H →L[ℂ] H) where /-- The double commutant (a.k.a. centralizer) of a `VonNeumannAlgebra` is itself. -/ centralizer_centralizer' : Set.centralizer (Set.centralizer carrier) = carrier /-- Consider a von Neumann algebra acting on a Hilbert space `H` as a *-subalgebra of `H →L[ℂ] H`. (That is, we forget that it is equal to its double commutant or equivalently that it is closed in the weak and strong operator topologies.) -/ add_decl_doc VonNeumannAlgebra.toStarSubalgebra namespace VonNeumannAlgebra variable {H : Type u} [NormedAddCommGroup H] [InnerProductSpace ℂ H] [CompleteSpace H] instance instSetLike : SetLike (VonNeumannAlgebra H) (H →L[ℂ] H) where coe S := S.carrier coe_injective' S T h := by obtain ⟨⟨⟨⟨⟨⟨_, _⟩, _⟩, _⟩, _⟩, _⟩, _⟩ := S; cases T; congr noncomputable instance instStarMemClass : StarMemClass (VonNeumannAlgebra H) (H →L[ℂ] H) where star_mem {s} := s.star_mem' instance instSubringClass : SubringClass (VonNeumannAlgebra H) (H →L[ℂ] H) where add_mem {s} := s.add_mem' mul_mem {s} := s.mul_mem' one_mem {s} := s.one_mem' zero_mem {s} := s.zero_mem' neg_mem {s} a ha := show -a ∈ s.toStarSubalgebra from neg_mem ha @[simp] theorem mem_carrier {S : VonNeumannAlgebra H} {x : H →L[ℂ] H} : x ∈ S.toStarSubalgebra ↔ x ∈ (S : Set (H →L[ℂ] H)) := Iff.rfl @[simp] theorem coe_toStarSubalgebra (S : VonNeumannAlgebra H) : (S.toStarSubalgebra : Set (H →L[ℂ] H)) = S := rfl @[simp] theorem coe_mk (S : StarSubalgebra ℂ (H →L[ℂ] H)) (h) : ((⟨S, h⟩ : VonNeumannAlgebra H) : Set (H →L[ℂ] H)) = S := rfl @[ext] theorem ext {S T : VonNeumannAlgebra H} (h : ∀ x, x ∈ S ↔ x ∈ T) : S = T := SetLike.ext h @[simp] theorem centralizer_centralizer (S : VonNeumannAlgebra H) : Set.centralizer (Set.centralizer (S : Set (H →L[ℂ] H))) = S := S.centralizer_centralizer' /-- The centralizer of a `VonNeumannAlgebra`, as a `VonNeumannAlgebra`. -/ noncomputable def commutant (S : VonNeumannAlgebra H) : VonNeumannAlgebra H where toStarSubalgebra := StarSubalgebra.centralizer ℂ (S : Set (H →L[ℂ] H)) centralizer_centralizer' := by simp @[simp] theorem coe_commutant (S : VonNeumannAlgebra H) : ↑S.commutant = Set.centralizer (S : Set (H →L[ℂ] H)) := by simp [commutant] @[simp] theorem mem_commutant_iff {S : VonNeumannAlgebra H} {z : H →L[ℂ] H} : z ∈ S.commutant ↔ ∀ g ∈ S, g * z = z * g := by rw [← SetLike.mem_coe, coe_commutant] rfl @[simp] theorem commutant_commutant (S : VonNeumannAlgebra H) : S.commutant.commutant = S := SetLike.coe_injective <| by simp open ContinuousLinearMap in /-- An idempotent is an element in a von Neumann algebra if and only if its range and kernel are invariant under the commutant. -/ theorem IsIdempotentElem.mem_iff {e : H →L[ℂ] H} (h : IsIdempotentElem e) (S : VonNeumannAlgebra H) : e ∈ S ↔ ∀ y ∈ S.commutant, LinearMap.range e ∈ Module.End.invtSubmodule y ∧ LinearMap.ker e ∈ Module.End.invtSubmodule y := by conv_rhs => simp [← h.commute_iff, Commute.symm_iff (a := e), commute_iff_eq, ← mem_commutant_iff] open VonNeumannAlgebra ContinuousLinearMap in /-- A star projection is an element in a von Neumann algebra if and only if its range is invariant under the commutant. -/ theorem IsStarProjection.mem_iff {e : H →L[ℂ] H} (he : IsStarProjection e) (S : VonNeumannAlgebra H) : e ∈ S ↔ ∀ y ∈ S.commutant, LinearMap.range e ∈ Module.End.invtSubmodule y := by simp_rw [he.isIdempotentElem.mem_iff, he.isIdempotentElem.range_mem_invtSubmodule_iff, he.isIdempotentElem.ker_mem_invtSubmodule_iff, forall_and, and_iff_left_iff_imp, ← mul_def] intro h x hx simpa [he.isSelfAdjoint.star_eq] using congr(star $(h _ (star_mem hx))) end VonNeumannAlgebra
.lake/packages/mathlib/Mathlib/Analysis/Complex/HasPrimitives.lean
import Mathlib.Analysis.Complex.CauchyIntegral import Mathlib.Analysis.Complex.Convex /-! # Primitives of Holomorphic Functions In this file, we give conditions under which holomorphic functions have primitives. The main goal is to prove that holomorphic functions on simply connected domains have primitives. As a first step, we prove that holomorphic functions on disks have primitives. The approach is based on Morera's theorem, that a continuous function (on a disk) whose integral round a rectangle vanishes on all rectangles contained in the disk has a primitive. (Coupled with the fact that holomorphic functions satisfy this property.) To prove Morera's theorem, we first define the `Complex.wedgeIntegral`, which is the integral of a function over a "wedge" (a horizontal segment followed by a vertical segment in the disk), and compute its derivative. ## Main results * `Complex.IsConservativeOn.isExactOn_ball`: **Morera's Theorem**: On a disk, a continuous function whose integrals on rectangles vanish, has primitives. * `DifferentiableOn.isExactOn_ball`: On a disk, a holomorphic function has primitives. TODO: Extend to holomorphic functions on simply connected domains. -/ noncomputable section open Complex MeasureTheory Metric Set Topology open scoped Interval namespace Complex section AuxiliaryLemmata variable {c z : ℂ} {r x y : ℝ} private lemma re_add_im_mul_mem_ball (hz : z ∈ ball c r) : z.re + c.im * I ∈ ball c r := by suffices dist (z.re + c.im * I) c ≤ dist z c from lt_of_le_of_lt this hz rw [dist_eq_re_im, dist_eq_re_im, Real.le_sqrt (by positivity) (by positivity), Real.sq_sqrt (by positivity)] simp [sq_nonneg _] private lemma mem_ball_re_aux (hx : x ∈ Ioo (z.re - (r - dist z c)) (z.re + (r - dist z c))) : x + z.im * I ∈ ball c r := by set r₁ := r - dist z c set s := Ioo (z.re - r₁) (z.re + r₁) have s_ball₁ : s ×ℂ {z.im} ⊆ ball z r₁ := by rintro y ⟨yRe : y.re ∈ s, yIm : y.im = z.im⟩ rw [mem_ball, dist_eq_re_im, yIm, sub_self, zero_pow two_ne_zero, add_zero, Real.sqrt_sq_eq_abs] grind [abs_lt] suffices s ×ℂ {z.im} ⊆ ball c r from this <| by simp [mem_reProdIm, hx] exact s_ball₁.trans <| ball_subset_ball' <| by simp [r₁] private lemma mem_closedBall_aux (z_in_ball : z ∈ closedBall c r) (y_in_I : y ∈ Ι c.im z.im) : z.re + y * I ∈ closedBall c r := by refine le_trans ?_ (mem_closedBall.mp z_in_ball) rw [dist_eq_re_im, dist_eq_re_im, Real.le_sqrt (by positivity) (by positivity), Real.sq_sqrt (by positivity)] suffices (y - c.im) ^ 2 ≤ (z.im - c.im) ^ 2 by simpa cases mem_uIoc.mp y_in_I <;> nlinarith private lemma mem_ball_of_map_re_aux {a₁ a₂ b : ℝ} (ha₁ : a₁ + b * I ∈ ball c r) (ha₂ : a₂ + b * I ∈ ball c r) : (fun (x : ℝ) ↦ x + b * I) '' [[a₁, a₂]] ⊆ ball c r := by convert Convex.rectangle_subset (convex_ball c r) ha₁ ha₂ ?_ ?_ using 1 <;> simp [horizontalSegment_eq a₁ a₂ b, ha₁, ha₂, Rectangle] private lemma mem_ball_of_map_im_aux₁ {a b₁ b₂ : ℝ} (hb₁ : a + b₁ * I ∈ ball c r) (hb₂ : a + b₂ * I ∈ ball c r) : (fun (y : ℝ) ↦ a + y * I) '' [[b₁, b₂]] ⊆ ball c r := by convert Convex.rectangle_subset (convex_ball c r) hb₁ hb₂ ?_ ?_ using 1 <;> simp [verticalSegment_eq a b₁ b₂, hb₁, hb₂, Rectangle] private lemma mem_ball_of_map_im_aux₂ {w : ℂ} (hw : w ∈ ball z (r - dist z c)) : (fun (y : ℝ) ↦ w.re + y * I) '' [[z.im, w.im]] ⊆ ball c r := by apply mem_ball_of_map_im_aux₁ <;> apply mem_of_subset_of_mem (ball_subset_ball' (by simp) : ball z (r - dist z c) ⊆ ball c r) · exact re_add_im_mul_mem_ball hw · simpa using hw end AuxiliaryLemmata variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℂ E] /-- The `(z, w)`-wedge-integral of `f`, is the integral of `f` over two sides of the rectangle determined by `z` and `w`. -/ def wedgeIntegral (z w : ℂ) (f : ℂ → E) : E := (∫ x : ℝ in z.re..w.re, f (x + z.im * I)) + I • (∫ y : ℝ in z.im..w.im, f (w.re + y * I)) lemma wedgeIntegral_add_wedgeIntegral_eq (z w : ℂ) (f : ℂ → E) : wedgeIntegral z w f + wedgeIntegral w z f = (∫ x : ℝ in z.re..w.re, f (x + z.im * I)) - (∫ x : ℝ in z.re..w.re, f (x + w.im * I)) + I • (∫ y : ℝ in z.im..w.im, f (w.re + y * I)) - I • (∫ y : ℝ in z.im..w.im, f (z.re + y * I)) := by simp only [wedgeIntegral, intervalIntegral.integral_symm z.re w.re, intervalIntegral.integral_symm z.im w.im, smul_neg] abel /-- A function `f` `IsConservativeOn` in `U` if, for any rectangle contained in `U` the integral of `f` over the rectangle is zero. -/ def IsConservativeOn (f : ℂ → E) (U : Set ℂ) : Prop := ∀ z w, Rectangle z w ⊆ U → wedgeIntegral z w f = - wedgeIntegral w z f /-- A function `f` `IsExactOn` in `U` if it is the complex derivative of a function on `U`. In complex variable theory, this is also referred to as "having a primitive". -/ def IsExactOn (f : ℂ → E) (U : Set ℂ) : Prop := ∃ g, ∀ z ∈ U, HasDerivAt g (f z) z variable {c : ℂ} {r : ℝ} {f : ℂ → E} lemma IsConservativeOn.mono {U V : Set ℂ} (h : U ⊆ V) (hf : IsConservativeOn f V) : IsConservativeOn f U := fun z w hzw ↦ hf z w (hzw.trans h) theorem _root_.DifferentiableOn.isConservativeOn {U : Set ℂ} (hf : DifferentiableOn ℂ f U) : IsConservativeOn f U := by rintro z w hzw rw [← add_eq_zero_iff_eq_neg, wedgeIntegral_add_wedgeIntegral_eq] exact integral_boundary_rect_eq_zero_of_differentiableOn f z w <| hf.mono hzw variable [CompleteSpace E] lemma IsExactOn.differentiableOn {U : Set ℂ} (hU : IsOpen U) (hf : IsExactOn f U) : DifferentiableOn ℂ f U := by obtain ⟨g, hg⟩ := hf have hg' : DifferentiableOn ℂ g U := fun z hz ↦ (hg z hz).differentiableAt.differentiableWithinAt exact (differentiableOn_congr <| fun z hz ↦ (hg z hz).deriv).mp <| hg'.deriv hU section ContinuousOnBall variable (f_cont : ContinuousOn f (ball c r)) {z : ℂ} (hz : z ∈ ball c r) include f_cont hz omit [CompleteSpace E] in /-- If a function `f` `IsConservativeOn` on a disk of center `c`, then for points `z` in this disk, the wedge integral from `c` to `z` is additive under a detour through a nearby point `w`. -/ lemma IsConservativeOn.eventually_nhds_wedgeIntegral_sub_wedgeIntegral (hf : IsConservativeOn f (ball c r)) : ∀ᶠ w in 𝓝 z, wedgeIntegral c w f - wedgeIntegral c z f = wedgeIntegral z w f := by refine eventually_nhds_iff_ball.mpr ⟨r - dist z c, by simpa using hz, fun w w_in_z_ball ↦ ?_⟩ set I₁ := ∫ x in c.re..w.re, f (x + c.im * I) set I₂ := I • ∫ y in c.im..w.im, f (w.re + y * I) set I₃ := ∫ x in c.re..z.re, f (x + c.im * I) set I₄ := I • ∫ y in c.im..z.im, f (z.re + y * I) set I₅ := ∫ x in z.re..w.re, f (x + z.im * I) set I₆ := I • ∫ y in z.im..w.im, f (w.re + y * I) set I₇ := ∫ x in z.re..w.re, f (x + c.im * I) set I₈ := I • ∫ y in c.im..z.im, f (w.re + y * I) have z_ball : ball z (r - dist z c) ⊆ ball c r := ball_subset_ball' (by simp) have w_mem : w ∈ ball c r := mem_of_subset_of_mem z_ball w_in_z_ball have integrableHoriz (a₁ a₂ b : ℝ) (ha₁ : a₁ + b * I ∈ ball c r) (ha₂ : a₂ + b * I ∈ ball c r) : IntervalIntegrable (fun x ↦ f (x + b * I)) volume a₁ a₂ := ((f_cont.mono (mem_ball_of_map_re_aux ha₁ ha₂)).comp (by fun_prop) (mapsTo_image _ _)).intervalIntegrable have integrableVert (a b₁ b₂ : ℝ) (hb₁ : a + b₁ * I ∈ ball c r) (hb₂ : a + b₂ * I ∈ ball c r) : IntervalIntegrable (fun y ↦ f (a + y * I)) volume b₁ b₂ := ((f_cont.mono (mem_ball_of_map_im_aux₁ hb₁ hb₂)).comp (by fun_prop) (mapsTo_image _ _)).intervalIntegrable have hI₁ : I₁ = I₃ + I₇ := by rw [intervalIntegral.integral_add_adjacent_intervals] <;> apply integrableHoriz · exact re_add_im_mul_mem_ball <| mem_ball_self (pos_of_mem_ball hz) · exact re_add_im_mul_mem_ball hz · exact re_add_im_mul_mem_ball hz · exact re_add_im_mul_mem_ball w_mem have hI₂ : I₂ = I₈ + I₆ := by rw [← smul_add, intervalIntegral.integral_add_adjacent_intervals] <;> apply integrableVert · exact re_add_im_mul_mem_ball w_mem · exact mem_of_subset_of_mem z_ball (re_add_im_mul_mem_ball w_in_z_ball) · exact mem_of_subset_of_mem z_ball (re_add_im_mul_mem_ball w_in_z_ball) · simpa using w_mem have hI₀ : I₇ - I₅ + I₈ - I₄ = 0 := by have wzInBall : w.re + z.im * I ∈ ball c r := mem_of_subset_of_mem z_ball (re_add_im_mul_mem_ball w_in_z_ball) have wcInBall : w.re + c.im * I ∈ ball c r := re_add_im_mul_mem_ball w_mem have hU : Rectangle (z.re + c.im * I) (w.re + z.im * I) ⊆ ball c r := (convex_ball c r).rectangle_subset (re_add_im_mul_mem_ball hz) wzInBall (by simpa using hz) (by simpa using wcInBall) simpa [← add_eq_zero_iff_eq_neg, wedgeIntegral_add_wedgeIntegral_eq] using hf (z.re + c.im * I) (w.re + z.im * I) hU grind [wedgeIntegral] /- The horizontal integral of `f` from `z` to `z.re + w.im * I` is equal to `(w - z).re * f z` up to `o(w - z)`, as `w` tends to `z`. -/ private lemma hasDerivAt_wedgeIntegral_re_aux : (fun w ↦ (∫ x in z.re..w.re, f (x + z.im * I)) - (w - z).re • f z) =o[𝓝 z] fun w ↦ w - z := by suffices (fun x ↦ (∫ t in z.re..x, f (t + z.im * I)) - (x - z.re) • f z) =o[𝓝 z.re] fun x ↦ x - z.re from this.comp_tendsto (continuous_re.tendsto z) |>.trans_isBigO isBigO_re_sub_re let r₁ := r - dist z c have r₁_pos : 0 < r₁ := by simpa only [mem_ball, sub_pos, r₁] using hz let s : Set ℝ := Ioo (z.re - r₁) (z.re + r₁) have zRe_mem_s : z.re ∈ s := by simp [s, r₁_pos] have f_contOn : ContinuousOn (fun (x : ℝ) ↦ f (x + z.im * I)) s := f_cont.comp ((continuous_add_right _).comp continuous_ofReal).continuousOn <| fun _ ↦ mem_ball_re_aux have int1 : IntervalIntegrable (fun (x : ℝ) ↦ f (x + z.im * I)) volume z.re z.re := ContinuousOn.intervalIntegrable <| f_contOn.mono <| by simpa have int2 : StronglyMeasurableAtFilter (fun (x : ℝ) ↦ f (x + z.im * I)) (𝓝 z.re) := f_contOn.stronglyMeasurableAtFilter isOpen_Ioo _ zRe_mem_s have int3 : ContinuousAt (fun (x : ℝ) ↦ f (x + z.im * I)) z.re := isOpen_Ioo.continuousOn_iff.mp f_contOn zRe_mem_s simpa [HasDerivAt, HasDerivAtFilter, hasFDerivAtFilter_iff_isLittleO] using intervalIntegral.integral_hasDerivAt_right int1 int2 int3 /-- The vertical integral of `f` from `w.re + z.im * I` to `w` is equal to `(w - z).im * f z` up to `o(w - z)`, as `w` tends to `z`. -/ private lemma hasDerivAt_wedgeIntegral_im_aux : (fun w ↦ (∫ y in z.im..w.im, f (w.re + y * I)) - (w - z).im • f z) =o[𝓝 z] fun w ↦ w - z := by suffices (fun w ↦ ∫ y in z.im..w.im, f (w.re + y * I) - f z) =o[𝓝 z] fun w ↦ w - z by calc _ = fun w ↦ (∫ y in z.im..w.im, f (w.re + y * I)) - (∫ _ in z.im..w.im, f z) := by simp _ =ᶠ[𝓝 z] fun w ↦ ∫ y in z.im..w.im, f (w.re + y * I) - f z := ?_ _ =o[𝓝 z] fun w ↦ w - z := this refine eventually_nhds_iff_ball.mpr ⟨r - dist z c, by simpa using hz, fun w hw ↦ ?_⟩ exact (intervalIntegral.integral_sub ((f_cont.mono (mem_ball_of_map_im_aux₂ hw)).comp (by fun_prop) (mapsTo_image _ _)).intervalIntegrable intervalIntegrable_const).symm have : (fun w ↦ f w - f z) =o[𝓝 z] fun _ ↦ (1 : ℝ) := by rw [Asymptotics.isLittleO_one_iff, tendsto_sub_nhds_zero_iff] exact f_cont.continuousAt <| _root_.mem_nhds_iff.mpr ⟨ball c r, le_refl _, isOpen_ball, hz⟩ rw [Asymptotics.IsLittleO] at this ⊢ intro ε ε_pos replace := this ε_pos simp only [Asymptotics.isBigOWith_iff, norm_one, mul_one] at this ⊢ replace this : ∀ᶠ w in 𝓝 z, ∀ y ∈ Ι z.im w.im, ‖f (w.re + y * I) - f z‖ ≤ ε := by rw [Metric.nhds_basis_closedBall.eventually_iff] at this ⊢ obtain ⟨i, i_pos, hi⟩ := this exact ⟨i, i_pos, fun w w_in_ball y y_in_I ↦ hi (mem_closedBall_aux w_in_ball y_in_I)⟩ filter_upwards [this] with w hw calc _ ≤ ε * ‖w.im - z.im‖ := intervalIntegral.norm_integral_le_of_norm_le_const hw _ = ε * ‖(w - z).im‖ := by simp _ ≤ ε * ‖w - z‖ := (mul_le_mul_iff_of_pos_left ε_pos).mpr (abs_im_le_norm _) /-- The `wedgeIntegral` has derivative at `z` equal to `f z`. -/ theorem IsConservativeOn.hasDerivAt_wedgeIntegral (h : IsConservativeOn f (ball c r)) : HasDerivAt (fun w ↦ wedgeIntegral c w f) (f z) z := by rw [hasDerivAt_iff_isLittleO] calc _ =ᶠ[𝓝 z] (fun w ↦ wedgeIntegral z w f - (w - z) • f z) := ?_ _ = (fun w ↦ (∫ x in z.re..w.re, f (x + z.im * I)) - (w - z).re • f z) + I • (fun w ↦ (∫ y in z.im..w.im, f (w.re + y * I)) - (w - z).im • f z) := ?_ _ =o[𝓝 z] fun w ↦ w - z := (hasDerivAt_wedgeIntegral_re_aux f_cont hz).add ((hasDerivAt_wedgeIntegral_im_aux f_cont hz).const_smul_left I) · exact (h.eventually_nhds_wedgeIntegral_sub_wedgeIntegral f_cont hz).mono <| by simp ext w set I₁ := ∫ x in z.re..w.re, f (x + z.im * I) set I₂ := ∫ y in z.im..w.im, f (w.re + y * I) calc _ = I₁ + I • I₂ - ((w - z).re + (w - z).im * I) • f z := by congr; rw [re_add_im] _ = I₁ + I • I₂ - ((w.re - z.re : ℂ) + (w.im - z.im) * I) • f z := by simp _ = I₁ - (w.re - z.re : ℂ) • f z + I • (I₂ - (w.im - z.im : ℂ) • f z) := ?_ · rw [add_smul, smul_sub, smul_smul, mul_comm I]; abel · congr <;> simp end ContinuousOnBall /-- **Morera's theorem for a disk** On a disk, a continuous function whose integrals on rectangles vanish, has primitives. -/ theorem IsConservativeOn.isExactOn_ball (hf' : ContinuousOn f (ball c r)) (hf : IsConservativeOn f (ball c r)) : IsExactOn f (ball c r) := ⟨fun z ↦ wedgeIntegral c z f, fun _ ↦ hf.hasDerivAt_wedgeIntegral hf'⟩ theorem isConservativeOn_and_continuousOn_iff_isDifferentiableOn {U : Set ℂ} (hU : IsOpen U) : IsConservativeOn f U ∧ ContinuousOn f U ↔ DifferentiableOn ℂ f U := by refine ⟨fun ⟨hf, hf'⟩ z hz ↦ ?_, fun hf ↦ ⟨hf.isConservativeOn, hf.continuousOn⟩⟩ obtain ⟨r, h₀, h₁⟩ : ∃ r > 0, ball z r ⊆ U := Metric.isOpen_iff.mp hU z hz have : DifferentiableOn ℂ f (ball z r) := (IsConservativeOn.isExactOn_ball (hf'.mono h₁) (hf.mono h₁)).differentiableOn isOpen_ball apply (this z (mem_ball_self h₀)).mono_of_mem_nhdsWithin exact mem_nhdsWithin.mpr ⟨ball z r, isOpen_ball, mem_ball_self h₀, inter_subset_left⟩ /-- **Morera's theorem for a disk** On a disk, a holomorphic function has primitives. -/ theorem _root_.DifferentiableOn.isExactOn_ball (hf : DifferentiableOn ℂ f (ball c r)) : IsExactOn f (ball c r) := hf.isConservativeOn.isExactOn_ball hf.continuousOn end Complex
.lake/packages/mathlib/Mathlib/Analysis/Complex/Tietze.lean
import Mathlib.Analysis.Complex.Basic import Mathlib.Analysis.RCLike.Lemmas import Mathlib.Topology.TietzeExtension import Mathlib.Analysis.Normed.Module.Ball.Homeomorph import Mathlib.Analysis.Normed.Module.RCLike.Basic /-! # Finite-dimensional topological vector spaces over `ℝ` satisfy the Tietze extension property There are two main results here: - `RCLike.instTietzeExtensionTVS`: finite-dimensional topological vector spaces over `ℝ` (or `ℂ`) have the Tietze extension property. - `BoundedContinuousFunction.exists_norm_eq_restrict_eq`: when mapping into a finite-dimensional normed vector space over `ℝ` (or `ℂ`), the extension can be chosen to preserve the norm of the bounded continuous function it extends. -/ universe u u₁ v w -- this is not an instance because Lean cannot determine `𝕜`. theorem TietzeExtension.of_tvs (𝕜 : Type v) [NontriviallyNormedField 𝕜] {E : Type w} [AddCommGroup E] [Module 𝕜 E] [TopologicalSpace E] [IsTopologicalAddGroup E] [ContinuousSMul 𝕜 E] [T2Space E] [FiniteDimensional 𝕜 E] [CompleteSpace 𝕜] [TietzeExtension.{u, v} 𝕜] : TietzeExtension.{u, w} E := Module.Basis.ofVectorSpace 𝕜 E |>.equivFun.toContinuousLinearEquiv.toHomeomorph |> .of_homeo instance Complex.instTietzeExtension : TietzeExtension ℂ := TietzeExtension.of_tvs ℝ instance (priority := 900) RCLike.instTietzeExtension {𝕜 : Type*} [RCLike 𝕜] : TietzeExtension 𝕜 := TietzeExtension.of_tvs ℝ instance RCLike.instTietzeExtensionTVS {𝕜 : Type v} [RCLike 𝕜] {E : Type w} [AddCommGroup E] [Module 𝕜 E] [TopologicalSpace E] [IsTopologicalAddGroup E] [ContinuousSMul 𝕜 E] [T2Space E] [FiniteDimensional 𝕜 E] : TietzeExtension.{u, w} E := TietzeExtension.of_tvs 𝕜 instance Set.instTietzeExtensionUnitBall {𝕜 : Type v} [RCLike 𝕜] {E : Type w} [NormedAddCommGroup E] [NormedSpace 𝕜 E] [FiniteDimensional 𝕜 E] : TietzeExtension.{u, w} (Metric.ball (0 : E) 1) := have : NormedSpace ℝ E := NormedSpace.restrictScalars ℝ 𝕜 E .of_homeo Homeomorph.unitBall.symm instance Set.instTietzeExtensionUnitClosedBall {𝕜 : Type v} [RCLike 𝕜] {E : Type w} [NormedAddCommGroup E] [NormedSpace 𝕜 E] [FiniteDimensional 𝕜 E] : TietzeExtension.{u, w} (Metric.closedBall (0 : E) 1) := by have : NormedSpace ℝ E := NormedSpace.restrictScalars ℝ 𝕜 E have : IsScalarTower ℝ 𝕜 E := Real.isScalarTower -- I didn't find this retract in Mathlib. let g : E → E := fun x ↦ ‖x‖⁻¹ • x classical suffices this : Continuous (piecewise (Metric.closedBall 0 1) id g) by refine .of_retract ⟨Subtype.val, by fun_prop⟩ ⟨_, this.codRestrict fun x ↦ ?_⟩ ?_ · by_cases hx : x ∈ Metric.closedBall 0 1 · simpa [piecewise_eq_of_mem (hi := hx)] using hx · simp only [g, piecewise_eq_of_notMem (hi := hx), RCLike.real_smul_eq_coe_smul (K := 𝕜)] by_cases hx' : x = 0 <;> simp [hx'] · ext x simp refine continuous_piecewise (fun x hx ↦ ?_) continuousOn_id ?_ · replace hx : ‖x‖ = 1 := by simpa [frontier_closedBall (0 : E) one_ne_zero] using hx simp [g, hx] · refine continuousOn_id.norm.inv₀ ?_ |>.smul continuousOn_id simp only [closure_compl, interior_closedBall (0 : E) one_ne_zero, mem_compl_iff, Metric.mem_ball, dist_zero_right, not_lt, id_eq, ne_eq, norm_eq_zero] exact fun x hx ↦ norm_pos_iff.mp <| one_pos.trans_le hx theorem Metric.instTietzeExtensionBall {𝕜 : Type v} [RCLike 𝕜] {E : Type w} [NormedAddCommGroup E] [NormedSpace 𝕜 E] [FiniteDimensional 𝕜 E] {r : ℝ} (hr : 0 < r) : TietzeExtension.{u, w} (Metric.ball (0 : E) r) := have : NormedSpace ℝ E := NormedSpace.restrictScalars ℝ 𝕜 E .of_homeo <| show (Metric.ball (0 : E) r) ≃ₜ (Metric.ball (0 : E) 1) from OpenPartialHomeomorph.unitBallBall (0 : E) r hr |>.toHomeomorphSourceTarget.symm theorem Metric.instTietzeExtensionClosedBall (𝕜 : Type v) [RCLike 𝕜] {E : Type w} [NormedAddCommGroup E] [NormedSpace 𝕜 E] [FiniteDimensional 𝕜 E] (y : E) {r : ℝ} (hr : 0 < r) : TietzeExtension.{u, w} (Metric.closedBall y r) := .of_homeo <| by change (Metric.closedBall y r) ≃ₜ (Metric.closedBall (0 : E) 1) symm apply (DilationEquiv.smulTorsor y (k := (r : 𝕜)) <| by exact_mod_cast hr.ne').toHomeomorph.sets ext x simp only [mem_closedBall, dist_zero_right, DilationEquiv.coe_toHomeomorph, Set.mem_preimage, DilationEquiv.smulTorsor_apply, vadd_eq_add, dist_add_self_left, norm_smul, RCLike.norm_ofReal, abs_of_nonneg hr.le] exact (mul_le_iff_le_one_right hr).symm variable {X : Type u} [TopologicalSpace X] [NormalSpace X] {s : Set X} (hs : IsClosed s) variable (𝕜 : Type v) [RCLike 𝕜] variable {E : Type w} [NormedAddCommGroup E] [NormedSpace 𝕜 E] [FiniteDimensional 𝕜 E] namespace BoundedContinuousFunction include 𝕜 hs in /-- **Tietze extension theorem** for real-valued bounded continuous maps, a version with a closed embedding and bundled composition. If `e : C(X, Y)` is a closed embedding of a topological space into a normal topological space and `f : X →ᵇ ℝ` is a bounded continuous function, then there exists a bounded continuous function `g : Y →ᵇ ℝ` of the same norm such that `g ∘ e = f`. -/ theorem exists_norm_eq_restrict_eq (f : s →ᵇ E) : ∃ g : X →ᵇ E, ‖g‖ = ‖f‖ ∧ g.restrict s = f := by by_cases hf : ‖f‖ = 0; · exact ⟨0, by aesop⟩ have := Metric.instTietzeExtensionClosedBall.{u, v} 𝕜 (0 : E) (by simp_all : 0 < ‖f‖) have hf' x : f x ∈ Metric.closedBall 0 ‖f‖ := by simpa using f.norm_coe_le_norm x obtain ⟨g, hg_mem, hg⟩ := (f : C(s, E)).exists_forall_mem_restrict_eq hs hf' simp only [Metric.mem_closedBall, dist_zero_right] at hg_mem let g' : X →ᵇ E := .ofNormedAddCommGroup g (map_continuous g) ‖f‖ hg_mem refine ⟨g', ?_, by ext x; congrm($(hg) x)⟩ apply le_antisymm ((g'.norm_le <| by positivity).mpr hg_mem) refine (f.norm_le <| by positivity).mpr fun x ↦ ?_ have hx : f x = g' x := by simpa using congr($(hg) x).symm rw [hx] exact g'.norm_le (norm_nonneg g') |>.mp le_rfl x end BoundedContinuousFunction
.lake/packages/mathlib/Mathlib/Analysis/Complex/Convex.lean
import Mathlib.Analysis.Complex.ReImTopology import Mathlib.Analysis.Convex.Combination import Mathlib.Analysis.Convex.PathConnected /-! # Theorems about convexity on the complex plane We show that the open and closed half-spaces in ℂ given by an inequality on either the real or imaginary part are all convex over ℝ. We also prove some results on star-convexity for the slit plane. -/ open Set open scoped ComplexOrder namespace Complex /-- A version of `convexHull_prod` for `Set.reProdIm`. -/ lemma convexHull_reProdIm (s t : Set ℝ) : convexHull ℝ (s ×ℂ t) = convexHull ℝ s ×ℂ convexHull ℝ t := calc convexHull ℝ (equivRealProdLm ⁻¹' (s ×ˢ t)) = equivRealProdLm ⁻¹' convexHull ℝ (s ×ˢ t) := by simpa only [← LinearEquiv.image_symm_eq_preimage] using ((equivRealProdLm.symm.toLinearMap).image_convexHull (s ×ˢ t)).symm _ = convexHull ℝ s ×ℂ convexHull ℝ t := by rw [convexHull_prod]; rfl /-- The slit plane is star-convex at a positive number. -/ lemma starConvex_slitPlane {z : ℂ} (hz : 0 < z) : StarConvex ℝ z slitPlane := Complex.compl_Iic_zero ▸ starConvex_compl_Iic hz /-- The slit plane is star-shaped at a positive real number. -/ lemma starConvex_ofReal_slitPlane {x : ℝ} (hx : 0 < x) : StarConvex ℝ ↑x slitPlane := starConvex_slitPlane <| zero_lt_real.2 hx /-- The slit plane is star-shaped at `1`. -/ lemma starConvex_one_slitPlane : StarConvex ℝ 1 slitPlane := starConvex_slitPlane one_pos end Complex open Complex variable (r : ℝ) theorem convex_halfSpace_re_lt : Convex ℝ { c : ℂ | c.re < r } := convex_halfSpace_lt (.mk add_re smul_re) _ theorem convex_halfSpace_re_le : Convex ℝ { c : ℂ | c.re ≤ r } := convex_halfSpace_le (.mk add_re smul_re) _ theorem convex_halfSpace_re_gt : Convex ℝ { c : ℂ | r < c.re } := convex_halfSpace_gt (.mk add_re smul_re) _ theorem convex_halfSpace_re_ge : Convex ℝ { c : ℂ | r ≤ c.re } := convex_halfSpace_ge (.mk add_re smul_re) _ theorem convex_halfSpace_im_lt : Convex ℝ { c : ℂ | c.im < r } := convex_halfSpace_lt (.mk add_im smul_im) _ theorem convex_halfSpace_im_le : Convex ℝ { c : ℂ | c.im ≤ r } := convex_halfSpace_le (.mk add_im smul_im) _ theorem convex_halfSpace_im_gt : Convex ℝ { c : ℂ | r < c.im } := convex_halfSpace_gt (.mk add_im smul_im) _ theorem convex_halfSpace_im_ge : Convex ℝ { c : ℂ | r ≤ c.im } := convex_halfSpace_ge (.mk add_im smul_im) _ namespace Complex lemma isConnected_of_upperHalfPlane {r} {s : Set ℂ} (hs₁ : {z | r < z.im} ⊆ s) (hs₂ : s ⊆ {z | r ≤ z.im}) : IsConnected s := by refine .subset_closure ?_ hs₁ (by simpa only [closure_setOf_lt_im] using hs₂) exact (convex_halfSpace_im_gt r).isConnected ⟨(r + 1) * I, by simp⟩ lemma isConnected_of_lowerHalfPlane {r} {s : Set ℂ} (hs₁ : {z | z.im < r} ⊆ s) (hs₂ : s ⊆ {z | z.im ≤ r}) : IsConnected s := by refine .subset_closure ?_ hs₁ (by simpa only [closure_setOf_im_lt] using hs₂) exact (convex_halfSpace_im_lt r).isConnected ⟨(r - 1) * I, by simp⟩ lemma rectangle_eq_convexHull (z w : ℂ) : Rectangle z w = convexHull ℝ {z, z.re + w.im * I, w.re + z.im * I, w} := by simp_rw [Rectangle, ← segment_eq_uIcc, ← convexHull_pair, ← convexHull_reProdIm, ← preimage_equivRealProd_prod, insert_prod, singleton_prod, image_pair, insert_union, ← insert_eq, ← Equiv.image_symm_eq_preimage, image_insert_eq, image_singleton, equivRealProd_symm_apply, re_add_im] /-- If opposite corners of a rectangle are contained in a convex set, the whole rectangle is. -/ lemma Convex.rectangle_subset {U : Set ℂ} (U_convex : Convex ℝ U) {z w : ℂ} (hz : z ∈ U) (hw : w ∈ U) (hzw : (z.re + w.im * I) ∈ U) (hwz : (w.re + z.im * I) ∈ U) : Rectangle z w ⊆ U := by simpa only [rectangle_eq_convexHull] using convexHull_min (by grind) U_convex -- This also follows easily from `isPathConnected_compl_singleton_of_one_lt_rank`, -- or that `Complex.range_exp` and `Complex.continuous_exp`, -- but both of them requires a lot more import. instance : PathConnectedSpace ℂˣ := have : PathConnectedSpace { z : ℂ // z ≠ 0 } := (isPathConnected_iff_pathConnectedSpace (F := {0}ᶜ)).mp (by convert (((convex_halfSpace_im_gt 0).isPathConnected ⟨.I, by simp⟩).union ((convex_halfSpace_re_gt 0).isPathConnected ⟨1, by simp⟩) ⟨1 + .I, by simp⟩).union (((convex_halfSpace_im_lt 0).isPathConnected ⟨-.I, by simp⟩).union ((convex_halfSpace_re_lt 0).isPathConnected ⟨-1, by simp⟩) ⟨-1 - .I, by simp⟩) ⟨1 - .I, by simp⟩ using 1 ext x refine ⟨?_, by aesop⟩ simp +contextual [Complex.ext_iff, -not_and, not_and_or, or_imp, ← ne_eq, ← lt_or_lt_iff_ne]) let e := unitsHomeomorphNeZero (G₀ := ℂ) e.symm.surjective.pathConnectedSpace e.symm.continuous end Complex
.lake/packages/mathlib/Mathlib/Analysis/Complex/OperatorNorm.lean
import Mathlib.Analysis.Complex.Basic import Mathlib.Analysis.Normed.Operator.NormedSpace import Mathlib.LinearAlgebra.Complex.Determinant /-! # The basic continuous linear maps associated to `ℂ` The continuous linear maps `Complex.reCLM` (real part), `Complex.imCLM` (imaginary part), `Complex.conjCLE` (conjugation), and `Complex.ofRealCLM` (inclusion of `ℝ`) were introduced in `Analysis.Complex.Basic`. This file contains a few calculations requiring more imports: the operator norm and (for `Complex.conjCLE`) the determinant. -/ open ContinuousLinearMap namespace Complex /-- The determinant of `conjLIE`, as a linear map. -/ @[simp] theorem det_conjLIE : LinearMap.det (conjLIE.toLinearEquiv : ℂ →ₗ[ℝ] ℂ) = -1 := det_conjAe /-- The determinant of `conjLIE`, as a linear equiv. -/ @[simp] theorem linearEquiv_det_conjLIE : LinearEquiv.det conjLIE.toLinearEquiv = -1 := linearEquiv_det_conjAe @[simp] theorem reCLM_norm : ‖reCLM‖ = 1 := le_antisymm (LinearMap.mkContinuous_norm_le _ zero_le_one _) <| calc 1 = ‖reCLM 1‖ := by simp _ ≤ ‖reCLM‖ := unit_le_opNorm _ _ (by simp) @[simp] theorem reCLM_enorm : ‖reCLM‖ₑ = 1 := by simp [← ofReal_norm] @[simp] theorem reCLM_nnnorm : ‖reCLM‖₊ = 1 := Subtype.ext reCLM_norm @[simp] theorem imCLM_norm : ‖imCLM‖ = 1 := le_antisymm (LinearMap.mkContinuous_norm_le _ zero_le_one _) <| calc 1 = ‖imCLM I‖ := by simp _ ≤ ‖imCLM‖ := unit_le_opNorm _ _ (by simp) @[simp] theorem imCLM_enorm : ‖imCLM‖ₑ = 1 := by simp [← ofReal_norm] @[simp] theorem imCLM_nnnorm : ‖imCLM‖₊ = 1 := Subtype.ext imCLM_norm @[simp] theorem conjCLE_norm : ‖(conjCLE : ℂ →L[ℝ] ℂ)‖ = 1 := conjLIE.toLinearIsometry.norm_toContinuousLinearMap @[simp] theorem conjCLE_enorm : ‖(conjCLE : ℂ →L[ℝ] ℂ)‖ₑ = 1 := by simp [← ofReal_norm] @[simp] theorem conjCLE_nnorm : ‖(conjCLE : ℂ →L[ℝ] ℂ)‖₊ = 1 := Subtype.ext conjCLE_norm @[simp] theorem ofRealCLM_norm : ‖ofRealCLM‖ = 1 := ofRealLI.norm_toContinuousLinearMap @[simp] theorem ofRealCLM_enorm : ‖ofRealCLM‖ₑ = 1 := by simp [← ofReal_norm] @[simp] theorem ofRealCLM_nnnorm : ‖ofRealCLM‖₊ = 1 := Subtype.ext <| ofRealCLM_norm end Complex
.lake/packages/mathlib/Mathlib/Analysis/Complex/OpenMapping.lean
import Mathlib.Analysis.Analytic.IsolatedZeros import Mathlib.Analysis.Complex.CauchyIntegral import Mathlib.Analysis.Complex.AbsMax import Mathlib.Topology.MetricSpace.ProperSpace.Lemmas /-! # The open mapping theorem for holomorphic functions This file proves the open mapping theorem for holomorphic functions, namely that an analytic function on a preconnected set of the complex plane is either constant or open. The main step is to show a local version of the theorem that states that if `f` is analytic at a point `z₀`, then either it is constant in a neighborhood of `z₀` or it maps any neighborhood of `z₀` to a neighborhood of its image `f z₀`. The results extend in higher dimension to `g : E → ℂ`. The proof of the local version on `ℂ` goes through two main steps: first, assuming that the function is not constant around `z₀`, use the isolated zero principle to show that `‖f z‖` is bounded below on a small `sphere z₀ r` around `z₀`, and then use the maximum principle applied to the auxiliary function `(fun z ↦ ‖f z - v‖)` to show that any `v` close enough to `f z₀` is in `f '' ball z₀ r`. That second step is implemented in `DiffContOnCl.ball_subset_image_closedBall`. ## Main results * `AnalyticAt.eventually_constant_or_nhds_le_map_nhds` is the local version of the open mapping theorem around a point; * `AnalyticOnNhd.is_constant_or_isOpen` is the open mapping theorem on a connected open set. -/ open Set Filter Metric Complex open scoped Topology variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℂ E] {U : Set E} {f : ℂ → ℂ} {g : E → ℂ} {z₀ : ℂ} {ε r : ℝ} /-- If the modulus of a holomorphic function `f` is bounded below by `ε` on a circle, then its range contains a disk of radius `ε / 2`. -/ theorem DiffContOnCl.ball_subset_image_closedBall (h : DiffContOnCl ℂ f (ball z₀ r)) (hr : 0 < r) (hf : ∀ z ∈ sphere z₀ r, ε ≤ ‖f z - f z₀‖) (hz₀ : ∃ᶠ z in 𝓝 z₀, f z ≠ f z₀) : ball (f z₀) (ε / 2) ⊆ f '' closedBall z₀ r := by /- This is a direct application of the maximum principle. Pick `v` close to `f z₀`, and look at the function `fun z ↦ ‖f z - v‖`: it is bounded below on the circle, and takes a small value at `z₀` so it is not constant on the disk, which implies that its infimum is equal to `0` and hence that `v` is in the range of `f`. -/ rintro v hv have h1 : DiffContOnCl ℂ (fun z => f z - v) (ball z₀ r) := h.sub_const v have h2 : ContinuousOn (fun z => ‖f z - v‖) (closedBall z₀ r) := continuous_norm.comp_continuousOn (closure_ball z₀ hr.ne.symm ▸ h1.continuousOn) have h3 : AnalyticOnNhd ℂ f (ball z₀ r) := h.differentiableOn.analyticOnNhd isOpen_ball have h4 : ∀ z ∈ sphere z₀ r, ε / 2 ≤ ‖f z - v‖ := fun z hz => by linarith [hf z hz, show ‖v - f z₀‖ < ε / 2 from mem_ball.mp hv, norm_sub_sub_norm_sub_le_norm_sub (f z) v (f z₀)] have h5 : ‖f z₀ - v‖ < ε / 2 := by simpa [← dist_eq_norm, dist_comm] using mem_ball.mp hv obtain ⟨z, hz1, hz2⟩ : ∃ z ∈ ball z₀ r, IsLocalMin (fun z => ‖f z - v‖) z := exists_isLocalMin_mem_ball h2 (mem_closedBall_self hr.le) fun z hz => h5.trans_le (h4 z hz) refine ⟨z, ball_subset_closedBall hz1, sub_eq_zero.mp ?_⟩ have h6 := h1.differentiableOn.eventually_differentiableAt (isOpen_ball.mem_nhds hz1) refine (eventually_eq_or_eq_zero_of_isLocalMin_norm h6 hz2).resolve_left fun key => ?_ have h7 : ∀ᶠ w in 𝓝 z, f w = f z := by filter_upwards [key] with h; simp replace h7 : ∃ᶠ w in 𝓝[≠] z, f w = f z := (h7.filter_mono nhdsWithin_le_nhds).frequently have h8 : IsPreconnected (ball z₀ r) := (convex_ball z₀ r).isPreconnected have h9 := h3.eqOn_of_preconnected_of_frequently_eq analyticOnNhd_const h8 hz1 h7 have h10 : f z = f z₀ := (h9 (mem_ball_self hr)).symm exact not_eventually.mpr hz₀ (mem_of_superset (ball_mem_nhds z₀ hr) (h10 ▸ h9)) /-- A function `f : ℂ → ℂ` which is analytic at a point `z₀` is either constant in a neighborhood of `z₀`, or behaves locally like an open function (in the sense that the image of every neighborhood of `z₀` is a neighborhood of `f z₀`, as in `isOpenMap_iff_nhds_le`). For a function `f : E → ℂ` the same result holds, see `AnalyticAt.eventually_constant_or_nhds_le_map_nhds`. -/ theorem AnalyticAt.eventually_constant_or_nhds_le_map_nhds_aux (hf : AnalyticAt ℂ f z₀) : (∀ᶠ z in 𝓝 z₀, f z = f z₀) ∨ 𝓝 (f z₀) ≤ map f (𝓝 z₀) := by /- The function `f` is analytic in a neighborhood of `z₀`; by the isolated zeros principle, if `f` is not constant in a neighborhood of `z₀`, then it is nonzero, and therefore bounded below, on every small enough circle around `z₀` and then `DiffContOnCl.ball_subset_image_closedBall` provides an explicit ball centered at `f z₀` contained in the range of `f`. -/ refine or_iff_not_imp_left.mpr fun h => ?_ refine (nhds_basis_ball.le_basis_iff (nhds_basis_closedBall.map f)).mpr fun R hR => ?_ have h1 := (hf.eventually_eq_or_eventually_ne analyticAt_const).resolve_left h have h2 : ∀ᶠ z in 𝓝 z₀, AnalyticAt ℂ f z := (isOpen_analyticAt ℂ f).eventually_mem hf obtain ⟨ρ, hρ, h3, h4⟩ : ∃ ρ > 0, AnalyticOnNhd ℂ f (closedBall z₀ ρ) ∧ ∀ z ∈ closedBall z₀ ρ, z ≠ z₀ → f z ≠ f z₀ := by simpa only [setOf_and, subset_inter_iff] using nhds_basis_closedBall.mem_iff.mp (h2.and (eventually_nhdsWithin_iff.mp h1)) replace h3 : DiffContOnCl ℂ f (ball z₀ ρ) := ⟨h3.differentiableOn.mono ball_subset_closedBall, (closure_ball z₀ hρ.lt.ne.symm).symm ▸ h3.continuousOn⟩ let r := ρ ⊓ R have hr : 0 < r := lt_inf_iff.mpr ⟨hρ, hR⟩ have h5 : closedBall z₀ r ⊆ closedBall z₀ ρ := closedBall_subset_closedBall inf_le_left have h6 : DiffContOnCl ℂ f (ball z₀ r) := h3.mono (ball_subset_ball inf_le_left) have h7 : ∀ z ∈ sphere z₀ r, f z ≠ f z₀ := fun z hz => h4 z (h5 (sphere_subset_closedBall hz)) (ne_of_mem_sphere hz hr.ne.symm) have h8 : (sphere z₀ r).Nonempty := NormedSpace.sphere_nonempty.mpr hr.le have h9 : ContinuousOn (fun x => ‖f x - f z₀‖) (sphere z₀ r) := continuous_norm.comp_continuousOn ((h6.sub_const (f z₀)).continuousOn_ball.mono sphere_subset_closedBall) obtain ⟨x, hx, hfx⟩ := (isCompact_sphere z₀ r).exists_isMinOn h8 h9 refine ⟨‖f x - f z₀‖ / 2, half_pos (norm_sub_pos_iff.mpr (h7 x hx)), ?_⟩ exact (h6.ball_subset_image_closedBall hr (fun z hz => hfx hz) (not_eventually.mp h)).trans (by gcongr; exact inf_le_right) /-- The *open mapping theorem* for holomorphic functions, local version: is a function `g : E → ℂ` is analytic at a point `z₀`, then either it is constant in a neighborhood of `z₀`, or it maps every neighborhood of `z₀` to a neighborhood of `z₀`. For the particular case of a holomorphic function on `ℂ`, see `AnalyticAt.eventually_constant_or_nhds_le_map_nhds_aux`. -/ theorem AnalyticAt.eventually_constant_or_nhds_le_map_nhds {z₀ : E} (hg : AnalyticAt ℂ g z₀) : (∀ᶠ z in 𝓝 z₀, g z = g z₀) ∨ 𝓝 (g z₀) ≤ map g (𝓝 z₀) := by /- The idea of the proof is to use the one-dimensional version applied to the restriction of `g` to lines going through `z₀` (indexed by `sphere (0 : E) 1`). If the restriction is eventually constant along each of these lines, then the identity theorem implies that `g` is constant on any ball centered at `z₀` on which it is analytic, and in particular `g` is eventually constant. If on the other hand there is one line along which `g` is not eventually constant, then the one-dimensional version of the open mapping theorem can be used to conclude. -/ let ray : E → ℂ → E := fun z t => z₀ + t • z let gray : E → ℂ → ℂ := fun z => g ∘ ray z obtain ⟨r, hr, hgr⟩ := isOpen_iff.mp (isOpen_analyticAt ℂ g) z₀ hg have h1 : ∀ z ∈ sphere (0 : E) 1, AnalyticOnNhd ℂ (gray z) (ball 0 r) := by refine fun z hz t ht => AnalyticAt.comp ?_ ?_ · exact hgr (by simpa [ray, norm_smul, mem_sphere_zero_iff_norm.mp hz] using ht) · exact analyticAt_const.add ((ContinuousLinearMap.smulRight (ContinuousLinearMap.id ℂ ℂ) z).analyticAt t) by_cases! h : ∀ z ∈ sphere (0 : E) 1, ∀ᶠ t in 𝓝 0, gray z t = gray z 0 · left -- If g is eventually constant along every direction, then it is eventually constant refine eventually_of_mem (ball_mem_nhds z₀ hr) fun z hz => ?_ refine (eq_or_ne z z₀).casesOn (congr_arg g) fun h' => ?_ replace h' : ‖z - z₀‖ ≠ 0 := by simpa only [Ne, norm_eq_zero, sub_eq_zero] let w : E := ‖z - z₀‖⁻¹ • (z - z₀) have h3 : ∀ t ∈ ball (0 : ℂ) r, gray w t = g z₀ := by have e1 : IsPreconnected (ball (0 : ℂ) r) := (convex_ball 0 r).isPreconnected have e2 : w ∈ sphere (0 : E) 1 := by simp [w, norm_smul, inv_mul_cancel₀ h'] specialize h1 w e2 apply h1.eqOn_of_preconnected_of_eventuallyEq analyticOnNhd_const e1 (mem_ball_self hr) simpa [ray, gray] using h w e2 have h4 : ‖z - z₀‖ < r := by simpa [dist_eq_norm] using mem_ball.mp hz replace h4 : ↑‖z - z₀‖ ∈ ball (0 : ℂ) r := by simpa simpa only [ray, gray, w, smul_smul, mul_inv_cancel₀ h', one_smul, add_sub_cancel, Function.comp_apply, coe_smul] using h3 (↑‖z - z₀‖) h4 · right -- Otherwise, it is open along at least one direction and that implies the result obtain ⟨z, hz, hrz⟩ := h specialize h1 z hz 0 (mem_ball_self hr) have h7 := h1.eventually_constant_or_nhds_le_map_nhds_aux.resolve_left hrz rw [show gray z 0 = g z₀ by simp [gray, ray], ← map_compose] at h7 refine h7.trans (map_mono ?_) have h10 : Continuous fun t : ℂ => z₀ + t • z := continuous_const.add (continuous_id'.smul continuous_const) simpa using h10.tendsto 0 /-- The *open mapping theorem* for holomorphic functions, global version: if a function `g : E → ℂ` is analytic on a connected set `U`, then either it is constant on `U`, or it is open on `U` (in the sense that it maps any open set contained in `U` to an open set in `ℂ`). -/ theorem AnalyticOnNhd.is_constant_or_isOpen (hg : AnalyticOnNhd ℂ g U) (hU : IsPreconnected U) : (∃ w, ∀ z ∈ U, g z = w) ∨ ∀ s ⊆ U, IsOpen s → IsOpen (g '' s) := by by_cases! h : ∃ z₀ ∈ U, ∀ᶠ z in 𝓝 z₀, g z = g z₀ · obtain ⟨z₀, hz₀, h⟩ := h exact Or.inl ⟨g z₀, hg.eqOn_of_preconnected_of_eventuallyEq analyticOnNhd_const hU hz₀ h⟩ · refine Or.inr fun s hs1 hs2 => isOpen_iff_mem_nhds.mpr ?_ rintro z ⟨w, hw1, rfl⟩ exact (hg w (hs1 hw1)).eventually_constant_or_nhds_le_map_nhds.resolve_left (h w (hs1 hw1)) (image_mem_map (hs2.mem_nhds hw1))
.lake/packages/mathlib/Mathlib/Analysis/Complex/ExponentialBounds.lean
import Mathlib.Analysis.Complex.Exponential import Mathlib.Analysis.SpecialFunctions.Log.Deriv /-! # Bounds on specific values of the exponential -/ namespace Real open IsAbsoluteValue Finset CauSeq Complex theorem exp_one_near_10 : |exp 1 - 2244083 / 825552| ≤ 1 / 10 ^ 10 := by apply exp_approx_start iterate 13 refine exp_1_approx_succ_eq (by norm_num1; rfl) (by norm_cast) ?_ refine exp_approx_end' _ (by norm_num1; rfl) _ (by norm_cast) (by simp) ?_ norm_num1 theorem exp_one_near_20 : |exp 1 - 363916618873 / 133877442384| ≤ 1 / 10 ^ 20 := by apply exp_approx_start iterate 21 refine exp_1_approx_succ_eq (by norm_num1; rfl) (by norm_cast) ?_ refine exp_approx_end' _ (by norm_num1; rfl) _ (by norm_cast) (by simp) ?_ norm_num1 theorem exp_one_gt_d9 : 2.7182818283 < exp 1 := lt_of_lt_of_le (by norm_num) (sub_le_comm.1 (abs_sub_le_iff.1 exp_one_near_10).2) theorem exp_one_lt_d9 : exp 1 < 2.7182818286 := lt_of_le_of_lt (sub_le_iff_le_add.1 (abs_sub_le_iff.1 exp_one_near_10).1) (by norm_num) theorem exp_neg_one_gt_d9 : 0.36787944116 < exp (-1) := by rw [exp_neg, lt_inv_comm₀ _ (exp_pos _)] · refine lt_of_le_of_lt (sub_le_iff_le_add.1 (abs_sub_le_iff.1 exp_one_near_10).1) ?_ norm_num · norm_num theorem exp_neg_one_lt_d9 : exp (-1) < 0.3678794412 := by rw [exp_neg, inv_lt_comm₀ (exp_pos _) (by norm_num)] exact lt_of_lt_of_le (by norm_num) (sub_le_comm.1 (abs_sub_le_iff.1 exp_one_near_10).2) theorem log_two_near_10 : |log 2 - 287209 / 414355| ≤ 1 / 10 ^ 10 := by suffices |log 2 - 287209 / 414355| ≤ 1 / 17179869184 + (1 / 10 ^ 10 - 1 / 2 ^ 34) by norm_num1 at * assumption have t : |(2⁻¹ : ℝ)| = 2⁻¹ := by rw [abs_of_pos]; norm_num have z := Real.abs_log_sub_add_sum_range_le (show |(2⁻¹ : ℝ)| < 1 by rw [t]; norm_num) 34 rw [t] at z norm_num1 at z rw [one_div (2 : ℝ), log_inv, ← sub_eq_add_neg, _root_.abs_sub_comm] at z apply le_trans (_root_.abs_sub_le _ _ _) (add_le_add z _) simp_rw [sum_range_succ] norm_num theorem log_two_gt_d9 : 0.6931471803 < log 2 := lt_of_lt_of_le (by norm_num1) (sub_le_comm.1 (abs_sub_le_iff.1 log_two_near_10).2) theorem log_two_lt_d9 : log 2 < 0.6931471808 := lt_of_le_of_lt (sub_le_iff_le_add.1 (abs_sub_le_iff.1 log_two_near_10).1) (by norm_num) end Real
.lake/packages/mathlib/Mathlib/Analysis/Complex/Asymptotics.lean
import Mathlib.Analysis.Complex.Basic import Mathlib.Analysis.Asymptotics.Theta /-! # Lemmas about asymptotics and the natural embedding `ℝ → ℂ` In this file we prove several trivial lemmas about `Asymptotics.IsBigO` etc. and `(↑) : ℝ → ℂ`. -/ namespace Complex variable {α E : Type*} [Norm E] {l : Filter α} theorem isTheta_ofReal (f : α → ℝ) (l : Filter α) : (f · : α → ℂ) =Θ[l] f := .of_norm_left <| by simpa using (Asymptotics.isTheta_rfl (f := f)).norm_left @[simp, norm_cast] theorem isLittleO_ofReal_left {f : α → ℝ} {g : α → E} : (f · : α → ℂ) =o[l] g ↔ f =o[l] g := (isTheta_ofReal f l).isLittleO_congr_left @[simp, norm_cast] theorem isLittleO_ofReal_right {f : α → E} {g : α → ℝ} : f =o[l] (g · : α → ℂ) ↔ f =o[l] g := (isTheta_ofReal g l).isLittleO_congr_right @[simp, norm_cast] theorem isBigO_ofReal_left {f : α → ℝ} {g : α → E} : (f · : α → ℂ) =O[l] g ↔ f =O[l] g := (isTheta_ofReal f l).isBigO_congr_left @[simp, norm_cast] theorem isBigO_ofReal_right {f : α → E} {g : α → ℝ} : f =O[l] (g · : α → ℂ) ↔ f =O[l] g := (isTheta_ofReal g l).isBigO_congr_right @[simp, norm_cast] theorem isTheta_ofReal_left {f : α → ℝ} {g : α → E} : (f · : α → ℂ) =Θ[l] g ↔ f =Θ[l] g := (isTheta_ofReal f l).isTheta_congr_left @[simp, norm_cast] theorem isTheta_ofReal_right {f : α → E} {g : α → ℝ} : f =Θ[l] (g · : α → ℂ) ↔ f =Θ[l] g := (isTheta_ofReal g l).isTheta_congr_right open Topology lemma isBigO_comp_ofReal_nhds {f g : ℂ → ℂ} {x : ℝ} (h : f =O[𝓝 (x : ℂ)] g) : (fun y : ℝ ↦ f y) =O[𝓝 x] (fun y : ℝ ↦ g y) := h.comp_tendsto <| continuous_ofReal.tendsto x lemma isBigO_comp_ofReal_nhds_ne {f g : ℂ → ℂ} {x : ℝ} (h : f =O[𝓝[≠] (x : ℂ)] g) : (fun y : ℝ ↦ f y) =O[𝓝[≠] x] (fun y : ℝ ↦ g y) := h.comp_tendsto <| continuous_ofReal.continuousWithinAt.tendsto_nhdsWithin fun _ _ ↦ by simp_all lemma isBigO_re_sub_re {z : ℂ} : (fun (w : ℂ) ↦ w.re - z.re) =O[𝓝 z] fun w ↦ w - z := Asymptotics.isBigO_of_le _ fun w ↦ abs_re_le_norm (w - z) lemma isBigO_im_sub_im {z : ℂ} : (fun (w : ℂ) ↦ w.im - z.im) =O[𝓝 z] fun w ↦ w - z := Asymptotics.isBigO_of_le _ fun w ↦ abs_im_le_norm (w - z) end Complex section Int open Filter in lemma Int.cast_complex_isTheta_cast_real : Int.cast (R := ℂ) =Θ[cofinite] Int.cast (R := ℝ) := by apply Asymptotics.IsTheta.of_norm_eventuallyEq_norm filter_upwards with n using by simp end Int
.lake/packages/mathlib/Mathlib/Analysis/Complex/Hadamard.lean
import Mathlib.Analysis.SpecialFunctions.Pow.Deriv import Mathlib.Analysis.Complex.PhragmenLindelof /-! # Hadamard three-lines Theorem In this file we present a proof of Hadamard's three-lines Theorem. ## Main result - `norm_le_interp_of_mem_verticalClosedStrip` : Hadamard three-line theorem: If `f` is a bounded function, continuous on `re ⁻¹' [l, u]` and differentiable on `re ⁻¹' (l, u)`, then for `M(x) := sup ((norm ∘ f) '' (re ⁻¹' {x}))`, that is `M(x)` is the supremum of the absolute value of `f` along the vertical lines `re z = x`, we have that `∀ z ∈ re ⁻¹' [l, u]` the inequality `‖f(z)‖ ≤ M(0) ^ (1 - ((z.re - l) / (u - l))) * M(1) ^ ((z.re - l) / (u - l))` holds. This can be seen to be equivalent to the statement that `log M(re z)` is a convex function on `[0, 1]`. - `norm_le_interp_of_mem_verticalClosedStrip'` : Variant of the above lemma in simpler terms. In particular, it makes no mention of the helper functions defined in this file. ## Main definitions - `Complex.HadamardThreeLines.verticalStrip` : The vertical strip defined by : `re ⁻¹' Ioo a b` - `Complex.HadamardThreeLines.verticalClosedStrip` : The vertical strip defined by : `re ⁻¹' Icc a b` - `Complex.HadamardThreeLines.sSupNormIm` : The supremum function on vertical lines defined by : `sSup {|f(z)| : z.re = x}` - `Complex.HadamardThreeLines.interpStrip` : The interpolation between the `sSupNormIm` on the edges of the vertical strip `re⁻¹ [0, 1]`. - `Complex.HadamardThreeLines.interpStrip` : The interpolation between the `sSupNormIm` on the edges of any vertical strip. - `Complex.HadamardThreeLines.invInterpStrip` : Inverse of the interpolation between the `sSupNormIm` on the edges of the vertical strip `re⁻¹ [0, 1]`. - `Complex.HadamardThreeLines.F` : Function defined by `f` times `invInterpStrip`. Convenient form for proofs. ## Note The proof follows from Phragmén-Lindelöf when both frontiers are not everywhere zero. We then use a limit argument to cover the case when either of the sides are `0`. -/ open Set Filter Function Complex Topology namespace Complex namespace HadamardThreeLines /-- The vertical strip in the complex plane containing all `z ∈ ℂ` such that `z.re ∈ Ioo a b`. -/ def verticalStrip (a : ℝ) (b : ℝ) : Set ℂ := re ⁻¹' Ioo a b /-- The vertical strip in the complex plane containing all `z ∈ ℂ` such that `z.re ∈ Icc a b`. -/ def verticalClosedStrip (a : ℝ) (b : ℝ) : Set ℂ := re ⁻¹' Icc a b /-- The supremum of the norm of `f` on imaginary lines. (Fixed real part) This is also known as the function `M` -/ noncomputable def sSupNormIm {E : Type*} [NormedAddCommGroup E] (f : ℂ → E) (x : ℝ) : ℝ := sSup ((norm ∘ f) '' (re ⁻¹' {x})) section invInterpStrip variable {E : Type*} [NormedAddCommGroup E] (f : ℂ → E) (z : ℂ) /-- The inverse of the interpolation of `sSupNormIm` on the two boundaries. In other words, this is the inverse of the right side of the target inequality: `|f(z)| ≤ |M(0) ^ (1-z)| * |M(1) ^ z|`. Shifting this by a positive epsilon allows us to prove the case when either of the boundaries is zero. -/ noncomputable def invInterpStrip (ε : ℝ) : ℂ := (ε + sSupNormIm f 0) ^ (z - 1) * (ε + sSupNormIm f 1) ^ (-z) /-- A function useful for the proofs steps. We will aim to show that it is bounded by 1. -/ noncomputable def F [NormedSpace ℂ E] (ε : ℝ) := fun z ↦ invInterpStrip f z ε • f z /-- `sSup` of `norm` is nonneg applied to the image of `f` on the vertical line `re z = x` -/ lemma sSupNormIm_nonneg (x : ℝ) : 0 ≤ sSupNormIm f x := by apply Real.sSup_nonneg rintro y ⟨z1, _, hz2⟩ simp only [← hz2, comp, norm_nonneg] /-- `sSup` of `norm` translated by `ε > 0` is positive applied to the image of `f` on the vertical line `re z = x` -/ lemma sSupNormIm_eps_pos {ε : ℝ} (hε : ε > 0) (x : ℝ) : 0 < ε + sSupNormIm f x := by linarith [sSupNormIm_nonneg f x] /-- Useful rewrite for the absolute value of `invInterpStrip` -/ lemma norm_invInterpStrip {ε : ℝ} (hε : ε > 0) : ‖invInterpStrip f z ε‖ = (ε + sSupNormIm f 0) ^ (z.re - 1) * (ε + sSupNormIm f 1) ^ (-z.re) := by simp only [invInterpStrip, norm_mul] repeat rw [← ofReal_add] repeat rw [norm_cpow_eq_rpow_re_of_pos (sSupNormIm_eps_pos f hε _) _] simp /-- The function `invInterpStrip` is `diffContOnCl`. -/ lemma diffContOnCl_invInterpStrip {ε : ℝ} (hε : ε > 0) : DiffContOnCl ℂ (fun z ↦ invInterpStrip f z ε) (verticalStrip 0 1) := by apply Differentiable.diffContOnCl apply Differentiable.mul · apply Differentiable.const_cpow (Differentiable.sub_const differentiable_id 1) _ left rw [← ofReal_add, ofReal_ne_zero] simp only [ne_eq, ne_of_gt (sSupNormIm_eps_pos f hε 0), not_false_eq_true] · apply Differentiable.const_cpow (Differentiable.neg differentiable_id) apply Or.inl rw [← ofReal_add, ofReal_ne_zero] exact (ne_of_gt (sSupNormIm_eps_pos f hε 1)) /-- If `f` is bounded on the unit vertical strip, then `f` is bounded by `sSupNormIm` there. -/ lemma norm_le_sSupNormIm (f : ℂ → E) (z : ℂ) (hD : z ∈ verticalClosedStrip 0 1) (hB : BddAbove ((norm ∘ f) '' verticalClosedStrip 0 1)) : ‖f z‖ ≤ sSupNormIm f (z.re) := by refine le_csSup ?_ ?_ · revert hB; gcongr exact preimage_mono (singleton_subset_iff.mpr hD) · apply mem_image_of_mem (norm ∘ f) simp only [mem_preimage, mem_singleton] /-- Alternative version of `norm_le_sSupNormIm` with a strict inequality and a positive `ε`. -/ lemma norm_lt_sSupNormIm_eps (f : ℂ → E) (ε : ℝ) (hε : ε > 0) (z : ℂ) (hD : z ∈ verticalClosedStrip 0 1) (hB : BddAbove ((norm ∘ f) '' verticalClosedStrip 0 1)) : ‖f z‖ < ε + sSupNormIm f (z.re) := lt_add_of_pos_of_le hε (norm_le_sSupNormIm f z hD hB) variable [NormedSpace ℂ E] /-- When the function `f` is bounded above on a vertical strip, then so is `F`. -/ lemma F_BddAbove (f : ℂ → E) (ε : ℝ) (hε : ε > 0) (hB : BddAbove ((norm ∘ f) '' verticalClosedStrip 0 1)) : BddAbove ((norm ∘ (F f ε)) '' verticalClosedStrip 0 1) := by -- Rewriting goal simp only [F, comp_apply, invInterpStrip] rw [bddAbove_def] at * rcases hB with ⟨B, hB⟩ -- Using bound use ((max 1 ((ε + sSupNormIm f 0) ^ (-(1 : ℝ)))) * max 1 ((ε + sSupNormIm f 1) ^ (-(1 : ℝ)))) * B simp only [mem_image, forall_exists_index, and_imp, forall_apply_eq_imp_iff₂] intro z hset specialize hB (‖f z‖) (by simpa [image_congr, mem_image, comp_apply] using ⟨z, hset, rfl⟩) -- Proof that the bound is correct simp only [norm_smul, norm_mul, ← ofReal_add] gcongr -- Bounding individual terms · by_cases hM0_one : 1 ≤ ε + sSupNormIm f 0 -- `1 ≤ sSupNormIm f 0` · apply le_trans _ (le_max_left _ _) simp only [norm_cpow_eq_rpow_re_of_pos (sSupNormIm_eps_pos f hε 0), sub_re, one_re, Real.rpow_le_one_of_one_le_of_nonpos hM0_one (sub_nonpos.mpr hset.2)] -- `0 < sSupNormIm f 0 < 1` · rw [not_le] at hM0_one; apply le_trans _ (le_max_right _ _) simp only [norm_cpow_eq_rpow_re_of_pos (sSupNormIm_eps_pos f hε 0), sub_re, one_re] apply Real.rpow_le_rpow_of_exponent_ge (sSupNormIm_eps_pos f hε 0) (le_of_lt hM0_one) _ simp only [neg_le_sub_iff_le_add, le_add_iff_nonneg_left, hset.1] · by_cases hM1_one : 1 ≤ ε + sSupNormIm f 1 -- `1 ≤ sSupNormIm f 1` · apply le_trans _ (le_max_left _ _) simp only [norm_cpow_eq_rpow_re_of_pos (sSupNormIm_eps_pos f hε 1), neg_re, Real.rpow_le_one_of_one_le_of_nonpos hM1_one (Right.neg_nonpos_iff.mpr hset.1)] -- `0 < sSupNormIm f 1 < 1` · rw [not_le] at hM1_one; apply le_trans _ (le_max_right _ _) simp only [norm_cpow_eq_rpow_re_of_pos (sSupNormIm_eps_pos f hε 1), neg_re, Real.rpow_le_rpow_of_exponent_ge (sSupNormIm_eps_pos f hε 1) (le_of_lt hM1_one) (neg_le_neg_iff.mpr hset.2)] /-- Proof that `F` is bounded by one on the edges. -/ lemma F_edge_le_one (f : ℂ → E) (ε : ℝ) (hε : ε > 0) (z : ℂ) (hB : BddAbove ((norm ∘ f) '' verticalClosedStrip 0 1)) (hz : z ∈ re ⁻¹' {0, 1}) : ‖F f ε z‖ ≤ 1 := by simp only [F, norm_smul, norm_invInterpStrip f z hε] rcases hz with hz0 | hz1 -- `z.re = 0` · simp only [hz0, zero_sub, Real.rpow_neg_one, neg_zero, Real.rpow_zero, mul_one, inv_mul_le_iff₀ (sSupNormIm_eps_pos f hε 0)] rw [← hz0] apply le_of_lt (norm_lt_sSupNormIm_eps f ε hε _ _ hB) simp only [verticalClosedStrip, mem_preimage, zero_le_one, left_mem_Icc, hz0] -- `z.re = 1` · rw [mem_singleton_iff] at hz1 simp only [hz1, one_mul, Real.rpow_zero, sub_self, Real.rpow_neg_one, inv_mul_le_iff₀ (sSupNormIm_eps_pos f hε 1), mul_one] rw [← hz1] apply le_of_lt (norm_lt_sSupNormIm_eps f ε hε _ _ hB) simp only [verticalClosedStrip, mem_preimage, zero_le_one, hz1, right_mem_Icc] theorem norm_mul_invInterpStrip_le_one_of_mem_verticalClosedStrip (f : ℂ → E) (ε : ℝ) (hε : 0 < ε) (z : ℂ) (hd : DiffContOnCl ℂ f (verticalStrip 0 1)) (hB : BddAbove ((norm ∘ f) '' verticalClosedStrip 0 1)) (hz : z ∈ verticalClosedStrip 0 1) : ‖F f ε z‖ ≤ 1 := by apply PhragmenLindelof.vertical_strip (DiffContOnCl.smul (diffContOnCl_invInterpStrip f hε) hd) _ (fun x hx ↦ F_edge_le_one f ε hε x hB (Or.inl hx)) (fun x hx ↦ F_edge_le_one f ε hε x hB (Or.inr hx)) hz.1 hz.2 use 0 rw [sub_zero, div_one] refine ⟨ Real.pi_pos, ?_⟩ obtain ⟨BF, hBF⟩ := F_BddAbove f ε hε hB simp only [comp_apply, mem_upperBounds, mem_image, forall_exists_index, and_imp, forall_apply_eq_imp_iff₂] at hBF use BF rw [Asymptotics.isBigO_iff] use 1 rw [eventually_inf_principal] apply Eventually.of_forall intro x hx norm_num exact (hBF x ((preimage_mono Ioo_subset_Icc_self) hx)).trans ((le_of_lt (lt_add_one BF)).trans (Real.add_one_le_exp BF)) end invInterpStrip ----- variable {E : Type*} [NormedAddCommGroup E] (f : ℂ → E) /-- The interpolation of `sSupNormIm` on the two boundaries. In other words, this is the right side of the target inequality: `|f(z)| ≤ |M(0) ^ (1-z)| * |M(1) ^ z|`. Note that if `sSupNormIm f 0 = 0 ∨ sSupNormIm f 1 = 0` then the power is not continuous since `0 ^ 0 = 1`. Hence the use of `ite`. -/ noncomputable def interpStrip (z : ℂ) : ℂ := if sSupNormIm f 0 = 0 ∨ sSupNormIm f 1 = 0 then 0 else sSupNormIm f 0 ^ (1 - z) * sSupNormIm f 1 ^ z /-- Rewrite for `InterpStrip` when `0 < sSupNormIm f 0` and `0 < sSupNormIm f 1`. -/ lemma interpStrip_eq_of_pos (z : ℂ) (h0 : 0 < sSupNormIm f 0) (h1 : 0 < sSupNormIm f 1) : interpStrip f z = sSupNormIm f 0 ^ (1 - z) * sSupNormIm f 1 ^ z := by simp only [ne_of_gt h0, ne_of_gt h1, interpStrip, if_false, or_false] /-- Rewrite for `InterpStrip` when `0 = sSupNormIm f 0` or `0 = sSupNormIm f 1`. -/ lemma interpStrip_eq_of_zero (z : ℂ) (h : sSupNormIm f 0 = 0 ∨ sSupNormIm f 1 = 0) : interpStrip f z = 0 := if_pos h /-- Rewrite for `InterpStrip` on the open vertical strip. -/ lemma interpStrip_eq_of_mem_verticalStrip (z : ℂ) (hz : z ∈ verticalStrip 0 1) : interpStrip f z = sSupNormIm f 0 ^ (1 - z) * sSupNormIm f 1 ^ z := by by_cases! h : sSupNormIm f 0 = 0 ∨ sSupNormIm f 1 = 0 · rw [interpStrip_eq_of_zero _ z h] rcases h with h0 | h1 · simp only [h0, ofReal_zero, zero_eq_mul, cpow_eq_zero_iff, ne_eq, true_and, ofReal_eq_zero] left rw [sub_eq_zero, eq_comm] simp only [Complex.ext_iff, one_re, ne_of_lt hz.2, false_and, not_false_eq_true] · simp only [h1, ofReal_zero, zero_eq_mul, cpow_eq_zero_iff, ofReal_eq_zero, ne_eq, true_and] right rw [eq_comm] simp only [Complex.ext_iff, zero_re, ne_of_lt hz.1, false_and, not_false_eq_true] · replace h : (0 < sSupNormIm f 0) ∧ (0 < sSupNormIm f 1) := ⟨(lt_of_le_of_ne (sSupNormIm_nonneg f 0) (ne_comm.mp h.1)), (lt_of_le_of_ne (sSupNormIm_nonneg f 1) (ne_comm.mp h.2))⟩ exact interpStrip_eq_of_pos f z h.1 h.2 lemma diffContOnCl_interpStrip : DiffContOnCl ℂ (interpStrip f) (verticalStrip 0 1) := by by_cases! h : sSupNormIm f 0 = 0 ∨ sSupNormIm f 1 = 0 -- Case everywhere 0 · eta_expand; simp_rw [interpStrip_eq_of_zero f _ h]; exact diffContOnCl_const -- Case nowhere 0 · rcases h with ⟨h0, h1⟩ rw [ne_comm] at h0 h1 apply Differentiable.diffContOnCl intro z eta_expand simp_rw [interpStrip_eq_of_pos f _ (lt_of_le_of_ne (sSupNormIm_nonneg f 0) h0) (lt_of_le_of_ne (sSupNormIm_nonneg f 1) h1)] refine DifferentiableAt.mul ?_ ?_ · apply DifferentiableAt.const_cpow (DifferentiableAt.const_sub differentiableAt_id 1) _ left; simp only [Ne, ofReal_eq_zero]; rwa [eq_comm] · refine DifferentiableAt.const_cpow ?_ ?_ · apply differentiableAt_id · left; simp only [Ne, ofReal_eq_zero]; rwa [eq_comm] /-- The correct generalization of `interpStrip` to produce bounds in the general case. -/ noncomputable def interpStrip' (f : ℂ → E) (l u : ℝ) (z : ℂ) : ℂ := if sSupNormIm f l = 0 ∨ sSupNormIm f u = 0 then 0 else sSupNormIm f l ^ (1 - ((z - l) / (u - l))) * sSupNormIm f u ^ ((z - l) / (u - l)) /-- An auxiliary function to prove the general statement of Hadamard's three lines theorem. -/ def scale (f : ℂ → E) (l u : ℝ) : ℂ → E := fun z ↦ f (l + z • (u - l)) /-- The transformation on ℂ that is used for `scale` maps the closed strip ``re ⁻¹' [l, u]`` to the closed strip ``re ⁻¹' [0, 1]``. -/ lemma scale_id_mem_verticalClosedStrip_of_mem_verticalClosedStrip {l u : ℝ} (hul : l < u) {z : ℂ} (hz : z ∈ verticalClosedStrip 0 1) : l + z * (u - l) ∈ verticalClosedStrip l u := by simp only [verticalClosedStrip, mem_preimage, add_re, ofReal_re, mul_re, sub_re, sub_im, ofReal_im, sub_self, mul_zero, sub_zero, mem_Icc, le_add_iff_nonneg_right] simp only [verticalClosedStrip, mem_preimage, mem_Icc] at hz obtain ⟨hz₁, hz₂⟩ := hz simp only [sub_pos, hul, mul_nonneg_iff_of_pos_right, hz₁, true_and] rw [add_comm, ← sub_le_sub_iff_right l, add_sub_assoc, sub_self, add_zero] nth_rewrite 2 [← one_mul (u - l)] have := sub_nonneg.2 hul.le gcongr /-- The norm of the function `scale f l u` is bounded above on the closed strip `re⁻¹' [0, 1]`. -/ lemma scale_bddAbove {f : ℂ → E} {l u : ℝ} (hul : l < u) (hB : BddAbove ((norm ∘ f) '' verticalClosedStrip l u)) : BddAbove ((norm ∘ scale f l u) '' verticalClosedStrip 0 1) := by obtain ⟨R, hR⟩ := bddAbove_def.mp hB rw [bddAbove_def] use R intro r hr obtain ⟨w, hw₁, hw₂, _⟩ := hr simp only [comp_apply, scale, smul_eq_mul] have : ‖f (↑l + w * (↑u - ↑l))‖ ∈ norm ∘ f '' verticalClosedStrip l u := by simp only [comp_apply, mem_image] use ↑l + w * (↑u - ↑l) simp only [and_true] exact scale_id_mem_verticalClosedStrip_of_mem_verticalClosedStrip hul hw₁ exact hR ‖f (↑l + w * (↑u - ↑l))‖ this /-- A bound to the norm of `f` on the line `z.re = l` induces a bound to the norm of `scale f l u z` on the line `z.re = 0`. -/ lemma scale_bound_left {f : ℂ → E} {l u a : ℝ} (ha : ∀ z ∈ re ⁻¹' {l}, ‖f z‖ ≤ a) : ∀ z ∈ re ⁻¹' {0}, ‖scale f l u z‖ ≤ a := by simp only [mem_preimage, mem_singleton_iff, scale, smul_eq_mul] intro z hz exact ha (↑l + z * (↑u - ↑l)) (by simp [hz]) /-- A bound to the norm of `f` on the line `z.re = u` induces a bound to the norm of `scale f l u z` on the line `z.re = 1`. -/ lemma scale_bound_right {f : ℂ → E} {l u b : ℝ} (hb : ∀ z ∈ re ⁻¹' {u}, ‖f z‖ ≤ b) : ∀ z ∈ re ⁻¹' {1}, ‖scale f l u z‖ ≤ b := by simp only [scale, mem_preimage, mem_singleton_iff, smul_eq_mul] intro z hz exact hb (↑l + z * (↑u - ↑l)) (by simp [hz]) /-- The supremum of the norm of `scale f l u` on the line `z.re = 0` is the same as the supremum of `f` on the line `z.re = l`. -/ lemma sSupNormIm_scale_left (f : ℂ → E) {l u : ℝ} (hul : l < u) : sSupNormIm (scale f l u) 0 = sSupNormIm f l := by simp_rw [sSupNormIm, image_comp] have : scale f l u '' (re ⁻¹' {0}) = f '' (re ⁻¹' {l}) := by ext e simp only [scale, smul_eq_mul, mem_image, mem_preimage, mem_singleton_iff] constructor · intro h obtain ⟨z, hz₁, hz₂⟩ := h use ↑l + z * (↑u - ↑l) simp [hz₁, hz₂] · intro h obtain ⟨z, hz₁, hz₂⟩ := h use ((z - l) / (u - l)) constructor · norm_cast rw [Complex.div_re, Complex.normSq_ofReal, Complex.ofReal_re] simp [hz₁] · rw [div_mul_comm, div_self (by norm_cast; linarith)] simp [hz₂] rw [this] /-- The supremum of the norm of `scale f l u` on the line `z.re = 1` is the same as the supremum of `f` on the line `z.re = u`. -/ lemma sSupNormIm_scale_right (f : ℂ → E) {l u : ℝ} (hul : l < u) : sSupNormIm (scale f l u) 1 = sSupNormIm f u := by simp_rw [sSupNormIm, image_comp] have : scale f l u '' (re ⁻¹' {1}) = f '' (re ⁻¹' {u}) := by ext e simp only [scale, smul_eq_mul, mem_image, mem_preimage, mem_singleton_iff] constructor · intro h obtain ⟨z, hz₁, hz₂⟩ := h use ↑l + z * (↑u - ↑l) simp only [add_re, ofReal_re, mul_re, hz₁, sub_re, one_mul, sub_im, ofReal_im, sub_self, mul_zero, sub_zero, add_sub_cancel, hz₂, and_self] · intro h obtain ⟨z, hz₁, hz₂⟩ := h use ((z - l) / (u - l)) constructor · norm_cast rw [Complex.div_re, Complex.normSq_ofReal, Complex.ofReal_re] simp only [sub_re, hz₁, ofReal_re, sub_im, ofReal_im, sub_zero, ofReal_sub, sub_self, mul_zero, zero_div, add_zero] rw [div_mul_eq_div_div_swap, mul_div_assoc, div_self (by norm_cast; linarith), mul_one, div_self (by norm_cast; linarith)] · rw [div_mul_comm, div_self (by norm_cast; linarith)] simp only [one_mul, add_sub_cancel, hz₂] rw [this] /-- A technical lemma relating the bounds given by the three lines lemma on a general strip to the bounds for its scaled version on the strip `re ⁻¹' [0, 1]`. -/ lemma interpStrip_scale (f : ℂ → E) {l u : ℝ} (hul : l < u) (z : ℂ) : interpStrip (scale f l u) ((z - ↑l) / (↑u - ↑l)) = interpStrip' f l u z := by simp only [interpStrip, interpStrip'] simp_rw [sSupNormIm_scale_left f hul, sSupNormIm_scale_right f hul] variable [NormedSpace ℂ E] lemma norm_le_interpStrip_of_mem_verticalClosedStrip_eps (ε : ℝ) (hε : ε > 0) (z : ℂ) (hB : BddAbove ((norm ∘ f) '' verticalClosedStrip 0 1)) (hd : DiffContOnCl ℂ f (verticalStrip 0 1)) (hz : z ∈ verticalClosedStrip 0 1) : ‖f z‖ ≤ ‖((ε + sSupNormIm f 0) ^ (1 - z) * (ε + sSupNormIm f 1) ^ z : ℂ)‖ := by simp only [norm_mul, ← ofReal_add, norm_cpow_eq_rpow_re_of_pos (sSupNormIm_eps_pos f hε _) _, sub_re, one_re] rw [← mul_inv_le_iff₀', ← one_mul (((ε + sSupNormIm f 1) ^ z.re)), ← mul_inv_le_iff₀, ← Real.rpow_neg_one, ← Real.rpow_neg_one] · simp only [← Real.rpow_mul (le_of_lt (sSupNormIm_eps_pos f hε _)), mul_neg, mul_one, neg_sub, mul_assoc] simpa [F, norm_invInterpStrip _ _ hε, norm_smul, mul_comm] using norm_mul_invInterpStrip_le_one_of_mem_verticalClosedStrip f ε hε z hd hB hz · simp only [Real.rpow_pos_of_pos (sSupNormIm_eps_pos f hε _) z.re] · simp only [Real.rpow_pos_of_pos (sSupNormIm_eps_pos f hε _) (1 - z.re)] lemma eventuallyle (z : ℂ) (hB : BddAbove ((norm ∘ f) '' verticalClosedStrip 0 1)) (hd : DiffContOnCl ℂ f (verticalStrip 0 1)) (hz : z ∈ verticalStrip 0 1) : (fun _ : ℝ ↦ ‖f z‖) ≤ᶠ[𝓝[>] 0] (fun ε ↦ ‖((ε + sSupNormIm f 0) ^ (1 - z) * (ε + sSupNormIm f 1) ^ z : ℂ)‖) := by filter_upwards [self_mem_nhdsWithin] with ε (hε : 0 < ε) using norm_le_interpStrip_of_mem_verticalClosedStrip_eps f ε hε z hB hd (mem_of_mem_of_subset hz (preimage_mono Ioo_subset_Icc_self)) lemma norm_le_interpStrip_of_mem_verticalStrip_zero (z : ℂ) (hd : DiffContOnCl ℂ f (verticalStrip 0 1)) (hB : BddAbove ((norm ∘ f) '' verticalClosedStrip 0 1)) (hz : z ∈ verticalStrip 0 1) : ‖f z‖ ≤ ‖interpStrip f z‖ := by apply tendsto_le_of_eventuallyLE _ _ (eventuallyle f z hB hd hz) · simp only [tendsto_const_nhds_iff] -- Proof that we can let epsilon tend to zero. · rw [interpStrip_eq_of_mem_verticalStrip _ _ hz] convert ContinuousWithinAt.tendsto _ using 2 · simp only [ofReal_zero, zero_add] · simp_rw [← ofReal_add] have : ∀ x ∈ Ioi 0, (x + sSupNormIm f 0) ^ (1 - z.re) * (x + sSupNormIm f 1) ^ z.re = ‖((x + sSupNormIm f 0 : ℝ) ^ (1 - z) * (x + sSupNormIm f 1 : ℝ) ^ z : ℂ)‖ := by intro x hx simp only [norm_mul] repeat rw [norm_cpow_eq_rpow_re_of_nonneg (le_of_lt (sSupNormIm_eps_pos f hx _)) _] · simp only [sub_re, one_re] · simpa using (ne_comm.mpr (ne_of_lt hz.1)) · simpa [sub_eq_zero] using (ne_comm.mpr (ne_of_lt hz.2)) apply tendsto_nhdsWithin_congr this _ simp only [zero_add] rw [norm_mul, norm_cpow_eq_rpow_re_of_nonneg (sSupNormIm_nonneg _ _) _, norm_cpow_eq_rpow_re_of_nonneg (sSupNormIm_nonneg _ _) _] · apply Tendsto.mul · apply Tendsto.rpow_const · nth_rw 2 [← zero_add (sSupNormIm f 0)] exact Tendsto.add_const (sSupNormIm f 0) (tendsto_nhdsWithin_of_tendsto_nhds (Continuous.tendsto continuous_id' _)) · right; simp only [sub_nonneg, le_of_lt hz.2] · apply Tendsto.rpow_const · nth_rw 2 [← zero_add (sSupNormIm f 1)] exact Tendsto.add_const (sSupNormIm f 1) (tendsto_nhdsWithin_of_tendsto_nhds (Continuous.tendsto continuous_id' _)) · right; simp only [le_of_lt hz.1] · simpa using (ne_comm.mpr (ne_of_lt hz.1)) · simpa [sub_eq_zero] using (ne_comm.mpr (ne_of_lt hz.2)) /-- **Hadamard three-line theorem** on `re ⁻¹' [0, 1]`: If `f` is a bounded function, continuous on the closed strip `re ⁻¹' [0, 1]` and differentiable on open strip `re ⁻¹' (0, 1)`, then for `M(x) := sup ((norm ∘ f) '' (re ⁻¹' {x}))` we have that for all `z` in the closed strip `re ⁻¹' [0, 1]` the inequality `‖f(z)‖ ≤ M(0) ^ (1 - z.re) * M(1) ^ z.re` holds. -/ lemma norm_le_interpStrip_of_mem_verticalClosedStrip₀₁ (f : ℂ → E) {z : ℂ} (hz : z ∈ verticalClosedStrip 0 1) (hd : DiffContOnCl ℂ f (verticalStrip 0 1)) (hB : BddAbove ((norm ∘ f) '' verticalClosedStrip 0 1)) : ‖f z‖ ≤ ‖interpStrip f z‖ := by apply le_on_closure (fun w hw ↦ norm_le_interpStrip_of_mem_verticalStrip_zero f w hd hB hw) (Continuous.comp_continuousOn' continuous_norm hd.2) (Continuous.comp_continuousOn' continuous_norm (diffContOnCl_interpStrip f).2) rwa [verticalClosedStrip, ← closure_Ioo zero_ne_one, ← closure_preimage_re] at hz /-- **Hadamard three-line theorem** on `re ⁻¹' [0, 1]` (Variant in simpler terms): Let `f` be a bounded function, continuous on the closed strip `re ⁻¹' [0, 1]` and differentiable on open strip `re ⁻¹' (0, 1)`. If, for all `z.re = 0`, `‖f z‖ ≤ a` for some `a ∈ ℝ` and, similarly, for all `z.re = 1`, `‖f z‖ ≤ b` for some `b ∈ ℝ` then for all `z` in the closed strip `re ⁻¹' [0, 1]` the inequality `‖f(z)‖ ≤ a ^ (1 - z.re) * b ^ z.re` holds. -/ lemma norm_le_interp_of_mem_verticalClosedStrip₀₁' (f : ℂ → E) {z : ℂ} {a b : ℝ} (hz : z ∈ verticalClosedStrip 0 1) (hd : DiffContOnCl ℂ f (verticalStrip 0 1)) (hB : BddAbove ((norm ∘ f) '' verticalClosedStrip 0 1)) (ha : ∀ z ∈ re ⁻¹' {0}, ‖f z‖ ≤ a) (hb : ∀ z ∈ re ⁻¹' {1}, ‖f z‖ ≤ b) : ‖f z‖ ≤ a ^ (1 - z.re) * b ^ z.re := by have : ‖interpStrip f z‖ ≤ sSupNormIm f 0 ^ (1 - z.re) * sSupNormIm f 1 ^ z.re := by by_cases! h : sSupNormIm f 0 = 0 ∨ sSupNormIm f 1 = 0 · rw [interpStrip_eq_of_zero f z h, norm_zero, mul_nonneg_iff] left exact ⟨Real.rpow_nonneg (sSupNormIm_nonneg f _) _, Real.rpow_nonneg (sSupNormIm_nonneg f _) _ ⟩ · rcases h with ⟨h0, h1⟩ rw [ne_comm] at h0 h1 simp_rw [interpStrip_eq_of_pos f _ (lt_of_le_of_ne (sSupNormIm_nonneg f 0) h0) (lt_of_le_of_ne (sSupNormIm_nonneg f 1) h1)] simp only [norm_mul] rw [norm_cpow_eq_rpow_re_of_pos ((Ne.le_iff_lt h0).mp (sSupNormIm_nonneg f _)) _] rw [norm_cpow_eq_rpow_re_of_pos ((Ne.le_iff_lt h1).mp (sSupNormIm_nonneg f _)) _] simp only [sub_re, one_re, le_refl] apply (norm_le_interpStrip_of_mem_verticalClosedStrip₀₁ f hz hd hB).trans (this.trans _) apply mul_le_mul_of_nonneg _ _ (Real.rpow_nonneg (sSupNormIm_nonneg f _) _) · apply (Real.rpow_nonneg _ _) specialize hb 1 simp only [mem_preimage, one_re, mem_singleton_iff, forall_true_left] at hb exact (norm_nonneg _).trans hb · apply Real.rpow_le_rpow (sSupNormIm_nonneg f _) _ (sub_nonneg.mpr hz.2) · rw [sSupNormIm] apply csSup_le _ · simpa [comp_apply, mem_image, forall_exists_index, and_imp, forall_apply_eq_imp_iff₂] using ha · use ‖(f 0)‖, 0 simp only [mem_preimage, zero_re, mem_singleton_iff, comp_apply, and_self] · apply Real.rpow_le_rpow (sSupNormIm_nonneg f _) _ hz.1 · rw [sSupNormIm] apply csSup_le _ · simpa [comp_apply, mem_image, forall_exists_index, and_imp, forall_apply_eq_imp_iff₂] using hb · use ‖(f 1)‖, 1 simp only [mem_preimage, one_re, mem_singleton_iff, comp_apply, and_self] /-- The transformation on ℂ that is used for `scale` maps the strip ``re ⁻¹' (l, u)`` to the strip ``re ⁻¹' (0, 1)``. -/ lemma scale_id_mem_verticalStrip_of_mem_verticalStrip {l u : ℝ} (hul : l < u) {z : ℂ} (hz : z ∈ verticalStrip 0 1) : l + z * (u - l) ∈ verticalStrip l u := by simp only [verticalStrip, mem_preimage, mem_Ioo] at hz simp only [verticalStrip, mem_preimage, add_re, ofReal_re, mul_re, sub_re, sub_im, ofReal_im, sub_self, mul_zero, sub_zero, mem_Ioo, lt_add_iff_pos_right] obtain ⟨hz₁, hz₂⟩ := hz simp only [hz₁, mul_pos_iff_of_pos_left, sub_pos, hul, true_and] rw [add_comm, ← sub_lt_sub_iff_right l, add_sub_assoc, sub_self, add_zero] nth_rewrite 2 [← one_mul (u - l)] gcongr simp only [sub_pos] exact hul /-- If z is on the closed strip `re ⁻¹' [l, u]`, then `(z - l) / (u - l)` is on the closed strip `re ⁻¹' [0, 1]`. -/ lemma mem_verticalClosedStrip_of_scale_id_mem_verticalClosedStrip {z : ℂ} {l u : ℝ} (hul : l < u) (hz : z ∈ verticalClosedStrip l u) : z / (u - l) - l / (u - l) ∈ verticalClosedStrip 0 1 := by simp only [verticalClosedStrip, Complex.div_re, mem_preimage, sub_re, mem_Icc, sub_nonneg, tsub_le_iff_right, ofReal_re, ofReal_im, sub_im, sub_self, mul_zero, zero_div, add_zero] simp only [verticalClosedStrip] at hz norm_cast simp_rw [Complex.normSq_ofReal, mul_div_assoc, div_mul_eq_div_div_swap, div_self (by linarith : u - l ≠ 0), ← div_eq_mul_one_div] constructor · gcongr · apply le_of_lt; simp [hul] · exact hz.1 · rw [← sub_le_sub_iff_right (l / (u - l)), add_sub_assoc, sub_self, add_zero, div_sub_div_same, div_le_one (by simp [hul]), sub_le_sub_iff_right l] exact hz.2 /-- The function `scale f l u` is `diffContOnCl`. -/ lemma scale_diffContOnCl {f : ℂ → E} {l u : ℝ} (hul : l < u) (hd : DiffContOnCl ℂ f (verticalStrip l u)) : DiffContOnCl ℂ (scale f l u) (verticalStrip 0 1) := by unfold scale apply DiffContOnCl.comp (s := verticalStrip l u) hd · apply DiffContOnCl.const_add apply DiffContOnCl.smul_const exact Differentiable.diffContOnCl differentiable_id · rw [MapsTo] intro z hz exact scale_id_mem_verticalStrip_of_mem_verticalStrip hul hz /-- A technical lemma needed in the proof. -/ private lemma fun_arg_eq {l u : ℝ} (hul : l < u) (z : ℂ) : (↑l + (z / (↑u - ↑l) - ↑l / (↑u - ↑l)) * (↑u - ↑l)) = z := by rw [sub_mul, div_mul_comm, div_self (by norm_cast; linarith), div_mul_comm, div_self (by norm_cast; linarith)] simp /-- Another technical lemma needed in the proof. -/ private lemma bound_exp_eq {l u : ℝ} (hul : l < u) (z : ℂ) : (z / (↑u - ↑l)).re - ((l : ℂ) / (↑u - ↑l)).re = (z.re - l) / (u - l) := by norm_cast rw [Complex.div_re, Complex.normSq_ofReal, Complex.ofReal_re, Complex.ofReal_im, mul_div_assoc, div_mul_eq_div_div_swap, div_self (by norm_cast; linarith), ← div_eq_mul_one_div] simp only [mul_zero, zero_div, add_zero] rw [← div_sub_div_same] /-- **Hadamard three-line theorem**: If `f` is a bounded function, continuous on the closed strip `re ⁻¹' [l, u]` and differentiable on open strip `re ⁻¹' (l, u)`, then for `M(x) := sup ((norm ∘ f) '' (re ⁻¹' {x}))` we have that for all `z` in the closed strip `re ⁻¹' [a,b]` the inequality `‖f(z)‖ ≤ M(0) ^ (1 - ((z.re - l) / (u - l))) * M(1) ^ ((z.re - l) / (u - l))` holds. -/ lemma norm_le_interpStrip_of_mem_verticalClosedStrip {l u : ℝ} (hul : l < u) {f : ℂ → E} {z : ℂ} (hz : z ∈ verticalClosedStrip l u) (hd : DiffContOnCl ℂ f (verticalStrip l u)) (hB : BddAbove ((norm ∘ f) '' verticalClosedStrip l u)) : ‖f z‖ ≤ ‖interpStrip' f l u z‖ := by have hgoal := norm_le_interpStrip_of_mem_verticalClosedStrip₀₁ (scale f l u) (mem_verticalClosedStrip_of_scale_id_mem_verticalClosedStrip hul hz) (scale_diffContOnCl hul hd) (scale_bddAbove hul hB) simp only [scale, smul_eq_mul] at hgoal rw [fun_arg_eq hul, div_sub_div_same, interpStrip_scale f hul z] at hgoal exact hgoal /-- **Hadamard three-line theorem** (Variant in simpler terms): Let `f` be a bounded function, continuous on the closed strip `re ⁻¹' [l, u]` and differentiable on open strip `re ⁻¹' (l, u)`. If, for all `z.re = l`, `‖f z‖ ≤ a` for some `a ∈ ℝ` and, similarly, for all `z.re = u`, `‖f z‖ ≤ b` for some `b ∈ ℝ` then for all `z` in the closed strip `re ⁻¹' [l, u]` the inequality `‖f(z)‖ ≤ a ^ (1 - (z.re - l) / (u - l)) * b ^ ((z.re - l) / (u - l))` holds. -/ lemma norm_le_interp_of_mem_verticalClosedStrip' {f : ℂ → E} {z : ℂ} {a b l u : ℝ} (hul : l < u) (hz : z ∈ verticalClosedStrip l u) (hd : DiffContOnCl ℂ f (verticalStrip l u)) (hB : BddAbove ((norm ∘ f) '' verticalClosedStrip l u)) (ha : ∀ z ∈ re ⁻¹' {l}, ‖f z‖ ≤ a) (hb : ∀ z ∈ re ⁻¹' {u}, ‖f z‖ ≤ b) : ‖f z‖ ≤ a ^ (1 - (z.re - l) / (u - l)) * b ^ ((z.re - l) / (u - l)) := by have hgoal := norm_le_interp_of_mem_verticalClosedStrip₀₁' (scale f l u) (mem_verticalClosedStrip_of_scale_id_mem_verticalClosedStrip hul hz) (scale_diffContOnCl hul hd) (scale_bddAbove hul hB) (scale_bound_left ha) (scale_bound_right hb) simp only [scale, smul_eq_mul, sub_re] at hgoal rw [fun_arg_eq hul, bound_exp_eq hul] at hgoal exact hgoal end HadamardThreeLines end Complex
.lake/packages/mathlib/Mathlib/Analysis/Complex/TaylorSeries.lean
import Mathlib.Analysis.Complex.CauchyIntegral /-! # Convergence of Taylor series of holomorphic functions We show that the Taylor series around some point `c : ℂ` of a function `f` that is complex differentiable on the open ball of radius `r` around `c` converges to `f` on that open ball; see `Complex.hasSum_taylorSeries_on_ball` and `Complex.taylorSeries_eq_on_ball` for versions (in terms of `HasSum` and `tsum`, respectively) for functions to a complete normed space over `ℂ`, and `Complex.taylorSeries_eq_on_ball'` for a variant when `f : ℂ → ℂ`. There are corresponding statements for `EMEtric.ball`s; see `Complex.hasSum_taylorSeries_on_emetric_ball`, `Complex.taylorSeries_eq_on_emetric_ball` and `Complex.taylorSeries_eq_on_ball'`. We also show that the Taylor series around some point `c : ℂ` of a function `f` that is complex differentiable on all of `ℂ` converges to `f` on `ℂ`; see `Complex.hasSum_taylorSeries_of_entire`, `Complex.taylorSeries_eq_of_entire` and `Complex.taylorSeries_eq_of_entire'`. -/ namespace Complex open Nat variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℂ E] [CompleteSpace E] ⦃f : ℂ → E⦄ section ball variable ⦃c : ℂ⦄ ⦃r : ℝ⦄ (hf : DifferentiableOn ℂ f (Metric.ball c r)) variable ⦃z : ℂ⦄ (hz : z ∈ Metric.ball c r) include hf hz in /-- A function that is complex differentiable on the open ball of radius `r` around `c` is given by evaluating its Taylor series at `c` on this open ball. -/ lemma hasSum_taylorSeries_on_ball : HasSum (fun n : ℕ ↦ (n ! : ℂ)⁻¹ • (z - c) ^ n • iteratedDeriv n f c) (f z) := by obtain ⟨r', hr', hr'₀, hzr'⟩ : ∃ r' < r, 0 < r' ∧ z ∈ Metric.ball c r' := by obtain ⟨r', h₁, h₂⟩ := exists_between (Metric.mem_ball'.mp hz) exact ⟨r', h₂, Metric.pos_of_mem_ball h₁, Metric.mem_ball'.mpr h₁⟩ lift r' to NNReal using hr'₀.le have hz' : z - c ∈ EMetric.ball 0 r' := by rw [Metric.emetric_ball_nnreal] exact mem_ball_zero_iff.mpr hzr' have H := (hf.mono <| Metric.closedBall_subset_ball hr').hasFPowerSeriesOnBall hr'₀ |>.hasSum_iteratedFDeriv hz' simp only [add_sub_cancel] at H convert H using 4 with n simpa only [iteratedDeriv_eq_iteratedFDeriv, smul_eq_mul, mul_one, Finset.prod_const, Finset.card_fin] using ((iteratedFDeriv ℂ n f c).map_smul_univ (fun _ ↦ z - c) (fun _ ↦ 1)).symm include hf hz in /-- A function that is complex differentiable on the open ball of radius `r` around `c` is given by evaluating its Taylor series at `c` on this open ball. -/ lemma taylorSeries_eq_on_ball : ∑' n : ℕ, (n ! : ℂ)⁻¹ • (z - c) ^ n • iteratedDeriv n f c = f z := (hasSum_taylorSeries_on_ball hf hz).tsum_eq include hz in /-- A function that is complex differentiable on the open ball of radius `r` around `c` is given by evaluating its Taylor series at `c` on this open ball. -/ lemma taylorSeries_eq_on_ball' {f : ℂ → ℂ} (hf : DifferentiableOn ℂ f (Metric.ball c r)) : ∑' n : ℕ, (n ! : ℂ)⁻¹ * iteratedDeriv n f c * (z - c) ^ n = f z := by convert taylorSeries_eq_on_ball hf hz using 3 with n rw [mul_right_comm, smul_eq_mul, smul_eq_mul, mul_assoc] end ball section emetric variable ⦃c : ℂ⦄ ⦃r : ENNReal⦄ (hf : DifferentiableOn ℂ f (EMetric.ball c r)) variable ⦃z : ℂ⦄ (hz : z ∈ EMetric.ball c r) include hf hz in /-- A function that is complex differentiable on the open ball of radius `r ≤ ∞` around `c` is given by evaluating its Taylor series at `c` on this open ball. -/ lemma hasSum_taylorSeries_on_emetric_ball : HasSum (fun n : ℕ ↦ (n ! : ℂ)⁻¹ • (z - c) ^ n • iteratedDeriv n f c) (f z) := by obtain ⟨r', hzr', hr'⟩ := exists_between (EMetric.mem_ball'.mp hz) lift r' to NNReal using ne_top_of_lt hr' rw [← EMetric.mem_ball', Metric.emetric_ball_nnreal] at hzr' refine hasSum_taylorSeries_on_ball ?_ hzr' rw [← Metric.emetric_ball_nnreal] exact hf.mono <| EMetric.ball_subset_ball hr'.le include hf hz in /-- A function that is complex differentiable on the open ball of radius `r ≤ ∞` around `c` is given by evaluating its Taylor series at `c` on this open ball. -/ lemma taylorSeries_eq_on_emetric_ball : ∑' n : ℕ, (n ! : ℂ)⁻¹ • (z - c) ^ n • iteratedDeriv n f c = f z := (hasSum_taylorSeries_on_emetric_ball hf hz).tsum_eq include hz in /-- A function that is complex differentiable on the open ball of radius `r ≤ ∞` around `c` is given by evaluating its Taylor series at `c` on this open ball. -/ lemma taylorSeries_eq_on_emetric_ball' {f : ℂ → ℂ} (hf : DifferentiableOn ℂ f (EMetric.ball c r)) : ∑' n : ℕ, (n ! : ℂ)⁻¹ * iteratedDeriv n f c * (z - c) ^ n = f z := by convert taylorSeries_eq_on_emetric_ball hf hz using 3 with n rw [mul_right_comm, smul_eq_mul, smul_eq_mul, mul_assoc] end emetric section entire variable ⦃f : ℂ → E⦄ (hf : Differentiable ℂ f) (c z : ℂ) include hf in /-- A function that is complex differentiable on the complex plane is given by evaluating its Taylor series at any point `c`. -/ lemma hasSum_taylorSeries_of_entire : HasSum (fun n : ℕ ↦ (n ! : ℂ)⁻¹ • (z - c) ^ n • iteratedDeriv n f c) (f z) := hasSum_taylorSeries_on_emetric_ball hf.differentiableOn <| EMetric.mem_ball.mpr <| edist_lt_top .. include hf in /-- A function that is complex differentiable on the complex plane is given by evaluating its Taylor series at any point `c`. -/ lemma taylorSeries_eq_of_entire : ∑' n : ℕ, (n ! : ℂ)⁻¹ • (z - c) ^ n • iteratedDeriv n f c = f z := (hasSum_taylorSeries_of_entire hf c z).tsum_eq /-- A function that is complex differentiable on the complex plane is given by evaluating its Taylor series at any point `c`. -/ lemma taylorSeries_eq_of_entire' {f : ℂ → ℂ} (hf : Differentiable ℂ f) : ∑' n : ℕ, (n ! : ℂ)⁻¹ * iteratedDeriv n f c * (z - c) ^ n = f z := by convert taylorSeries_eq_of_entire hf c z using 3 with n rw [mul_right_comm, smul_eq_mul, smul_eq_mul, mul_assoc] end entire end Complex
.lake/packages/mathlib/Mathlib/Analysis/Complex/Isometry.lean
import Mathlib.Analysis.Complex.Circle import Mathlib.LinearAlgebra.Determinant import Mathlib.LinearAlgebra.Matrix.GeneralLinearGroup.Basic /-! # Isometries of the Complex Plane The lemma `linear_isometry_complex` states the classification of isometries in the complex plane. Specifically, isometries with rotations but without translation. The proof involves: 1. creating a linear isometry `g` with two fixed points, `g(0) = 0`, `g(1) = 1` 2. applying `linear_isometry_complex_aux` to `g` The proof of `linear_isometry_complex_aux` is separated in the following parts: 1. show that the real parts match up: `LinearIsometry.re_apply_eq_re` 2. show that I maps to either I or -I 3. every z is a linear combination of a + b * I ## References * [Isometries of the Complex Plane](http://helmut.knaust.info/mediawiki/images/b/b5/Iso.pdf) -/ noncomputable section open Complex open CharZero open ComplexConjugate local notation "|" x "|" => Complex.abs x /-- An element of the unit circle defines a `LinearIsometryEquiv` from `ℂ` to itself, by rotation. -/ def rotation : Circle →* ℂ ≃ₗᵢ[ℝ] ℂ where toFun a := { DistribMulAction.toLinearEquiv ℝ ℂ a with norm_map' x := show ‖a * x‖ = ‖x‖ by rw [norm_mul, Circle.norm_coe, one_mul] } map_one' := LinearIsometryEquiv.ext <| by simp map_mul' a b := LinearIsometryEquiv.ext <| mul_smul a b @[simp] theorem rotation_apply (a : Circle) (z : ℂ) : rotation a z = a * z := rfl @[simp] theorem rotation_symm (a : Circle) : (rotation a).symm = rotation a⁻¹ := LinearIsometryEquiv.ext fun _ => rfl @[simp] theorem rotation_trans (a b : Circle) : (rotation a).trans (rotation b) = rotation (b * a) := by ext1 simp theorem rotation_ne_conjLIE (a : Circle) : rotation a ≠ conjLIE := by intro h have h1 : rotation a 1 = conj 1 := LinearIsometryEquiv.congr_fun h 1 have hI : rotation a I = conj I := LinearIsometryEquiv.congr_fun h I rw [rotation_apply, RingHom.map_one, mul_one] at h1 rw [rotation_apply, conj_I, ← neg_one_mul, mul_left_inj' I_ne_zero, h1, eq_neg_self_iff] at hI exact one_ne_zero hI /-- Takes an element of `ℂ ≃ₗᵢ[ℝ] ℂ` and checks if it is a rotation, returns an element of the unit circle. -/ @[simps] def rotationOf (e : ℂ ≃ₗᵢ[ℝ] ℂ) : Circle := ⟨e 1 / ‖e 1‖, by simp [Submonoid.unitSphere]⟩ @[simp] theorem rotationOf_rotation (a : Circle) : rotationOf (rotation a) = a := Subtype.ext <| by simp theorem rotation_injective : Function.Injective rotation := Function.LeftInverse.injective rotationOf_rotation theorem LinearIsometry.re_apply_eq_re_of_add_conj_eq (f : ℂ →ₗᵢ[ℝ] ℂ) (h₃ : ∀ z, z + conj z = f z + conj (f z)) (z : ℂ) : (f z).re = z.re := by simpa [Complex.ext_iff, add_re, add_im, conj_re, conj_im, ← two_mul, show (2 : ℝ) ≠ 0 by simp] using (h₃ z).symm theorem LinearIsometry.im_apply_eq_im_or_neg_of_re_apply_eq_re {f : ℂ →ₗᵢ[ℝ] ℂ} (h₂ : ∀ z, (f z).re = z.re) (z : ℂ) : (f z).im = z.im ∨ (f z).im = -z.im := by have h₁ := f.norm_map z simp only [norm_def] at h₁ rwa [Real.sqrt_inj (normSq_nonneg _) (normSq_nonneg _), normSq_apply (f z), normSq_apply z, h₂, add_left_cancel_iff, mul_self_eq_mul_self_iff] at h₁ theorem LinearIsometry.im_apply_eq_im {f : ℂ →ₗᵢ[ℝ] ℂ} (h : f 1 = 1) (z : ℂ) : z + conj z = f z + conj (f z) := by have : ‖f z - 1‖ = ‖z - 1‖ := by rw [← f.norm_map (z - 1), f.map_sub, h] apply_fun fun x => x ^ 2 at this simp only [← normSq_eq_norm_sq] at this rw [← ofReal_inj, ← mul_conj, ← mul_conj] at this rw [RingHom.map_sub, RingHom.map_sub] at this simp only [sub_mul, mul_sub, one_mul] at this rw [mul_conj, normSq_eq_norm_sq, LinearIsometry.norm_map] at this rw [mul_conj, normSq_eq_norm_sq] at this simp only [sub_sub, sub_right_inj, mul_one, ofReal_pow, RingHom.map_one] at this simp only [add_sub, sub_left_inj] at this rw [add_comm, ← this, add_comm] theorem LinearIsometry.re_apply_eq_re {f : ℂ →ₗᵢ[ℝ] ℂ} (h : f 1 = 1) (z : ℂ) : (f z).re = z.re := by apply LinearIsometry.re_apply_eq_re_of_add_conj_eq intro z apply LinearIsometry.im_apply_eq_im h theorem linear_isometry_complex_aux {f : ℂ ≃ₗᵢ[ℝ] ℂ} (h : f 1 = 1) : f = LinearIsometryEquiv.refl ℝ ℂ ∨ f = conjLIE := by have h0 : f I = I ∨ f I = -I := by simp only [Complex.ext_iff, ← and_or_left, neg_re, I_re, neg_im, neg_zero] constructor · rw [← I_re] exact @LinearIsometry.re_apply_eq_re f.toLinearIsometry h I · apply @LinearIsometry.im_apply_eq_im_or_neg_of_re_apply_eq_re f.toLinearIsometry intro z rw [@LinearIsometry.re_apply_eq_re f.toLinearIsometry h] refine h0.imp (fun h' : f I = I => ?_) fun h' : f I = -I => ?_ <;> · apply LinearIsometryEquiv.toLinearEquiv_injective apply Complex.basisOneI.ext' intro i fin_cases i <;> simp [h, h'] theorem linear_isometry_complex (f : ℂ ≃ₗᵢ[ℝ] ℂ) : ∃ a : Circle, f = rotation a ∨ f = conjLIE.trans (rotation a) := by let a : Circle := ⟨f 1, by simp [Submonoid.unitSphere, f.norm_map]⟩ use a have : (f.trans (rotation a).symm) 1 = 1 := by simpa [a] using rotation_apply a⁻¹ (f 1) refine (linear_isometry_complex_aux this).imp (fun h₁ => ?_) fun h₂ => ?_ · simpa using eq_mul_of_inv_mul_eq h₁ · exact eq_mul_of_inv_mul_eq h₂ /-- The matrix representation of `rotation a` is equal to the conformal matrix `!![re a, -im a; im a, re a]`. -/ theorem toMatrix_rotation (a : Circle) : LinearMap.toMatrix basisOneI basisOneI (rotation a).toLinearEquiv = Matrix.planeConformalMatrix (re a) (im a) (by simp [pow_two, ← normSq_apply]) := by ext i j simp only [LinearMap.toMatrix_apply, coe_basisOneI, LinearEquiv.coe_coe, LinearIsometryEquiv.coe_toLinearEquiv, rotation_apply, coe_basisOneI_repr, mul_re, mul_im, Matrix.val_planeConformalMatrix, Matrix.of_apply, Matrix.cons_val', Matrix.empty_val', Matrix.cons_val_fin_one] fin_cases i <;> fin_cases j <;> simp /-- The determinant of `rotation` (as a linear map) is equal to `1`. -/ @[simp] theorem det_rotation (a : Circle) : LinearMap.det ((rotation a).toLinearEquiv : ℂ →ₗ[ℝ] ℂ) = 1 := by rw [← LinearMap.det_toMatrix basisOneI, toMatrix_rotation, Matrix.det_fin_two] simp [← normSq_apply] /-- The determinant of `rotation` (as a linear equiv) is equal to `1`. -/ @[simp] theorem linearEquiv_det_rotation (a : Circle) : LinearEquiv.det (rotation a).toLinearEquiv = 1 := by rw [← Units.val_inj, LinearEquiv.coe_det, det_rotation, Units.val_one]
.lake/packages/mathlib/Mathlib/Analysis/Complex/Angle.lean
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Bounds import Mathlib.Geometry.Euclidean.Angle.Unoriented.Basic /-! # Angle between complex numbers This file relates the Euclidean geometric notion of angle between complex numbers to the argument of their quotient. It also shows that the arc and chord distances between two unit complex numbers are equivalent up to a factor of `π / 2`. ## TODO Prove the corresponding results for oriented angles. ## Tags arc-length, arc-distance -/ open InnerProductGeometry Set open scoped Real namespace Complex variable {a x y : ℂ} /-- The angle between two non-zero complex numbers is the absolute value of the argument of their quotient. Note that this does not hold when `x` or `y` is `0` as the LHS is `π / 2` while the RHS is `0`. -/ lemma angle_eq_abs_arg (hx : x ≠ 0) (hy : y ≠ 0) : angle x y = |(x / y).arg| := by refine Real.arccos_eq_of_eq_cos (abs_nonneg _) (abs_arg_le_pi _) ?_ rw [Real.cos_abs, Complex.cos_arg (div_ne_zero hx hy)] simp [div_eq_mul_inv, Complex.normSq_eq_norm_sq] field lemma angle_one_left (hy : y ≠ 0) : angle 1 y = |y.arg| := by simp [angle_eq_abs_arg, hy] lemma angle_one_right (hx : x ≠ 0) : angle x 1 = |x.arg| := by simp [angle_eq_abs_arg, hx] @[simp] lemma angle_mul_left (ha : a ≠ 0) (x y : ℂ) : angle (a * x) (a * y) = angle x y := by obtain rfl | hx := eq_or_ne x 0 <;> obtain rfl | hy := eq_or_ne y 0 <;> simp [angle_eq_abs_arg, mul_div_mul_left, *] @[simp] lemma angle_mul_right (ha : a ≠ 0) (x y : ℂ) : angle (x * a) (y * a) = angle x y := by simp [mul_comm, angle_mul_left ha] lemma angle_div_left_eq_angle_mul_right (a x y : ℂ) : angle (x / a) y = angle x (y * a) := by obtain rfl | ha := eq_or_ne a 0 · simp · rw [← angle_mul_right ha, div_mul_cancel₀ _ ha] lemma angle_div_right_eq_angle_mul_left (a x y : ℂ) : angle x (y / a) = angle (x * a) y := by rw [angle_comm, angle_div_left_eq_angle_mul_right, angle_comm] lemma angle_exp_exp (x y : ℝ) : angle (exp (x * I)) (exp (y * I)) = |toIocMod Real.two_pi_pos (-π) (x - y)| := by simp_rw [angle_eq_abs_arg (exp_ne_zero _) (exp_ne_zero _), ← exp_sub, ← sub_mul, ← ofReal_sub, arg_exp_mul_I] lemma angle_exp_one (x : ℝ) : angle (exp (x * I)) 1 = |toIocMod Real.two_pi_pos (-π) x| := by simpa using angle_exp_exp x 0 /-! ### Arc-length and chord-length are equivalent This section shows that the arc and chord distances between two unit complex numbers are equivalent up to a factor of `π / 2`. -/ /-- Chord-length is a multiple of arc-length up to constants. -/ lemma norm_sub_mem_Icc_angle (hx : ‖x‖ = 1) (hy : ‖y‖ = 1) : ‖x - y‖ ∈ Icc (2 / π * angle x y) (angle x y) := by wlog h : y = 1 · have := @this (x / y) 1 (by simp only [norm_div, hx, hy, div_one]) norm_one rfl rwa [angle_div_left_eq_angle_mul_right, div_sub_one, norm_div, hy, div_one, one_mul] at this rintro rfl simp at hy subst y rw [norm_eq_one_iff'] at hx obtain ⟨θ, hθ, rfl⟩ := hx rw [angle_exp_one, exp_mul_I, add_sub_right_comm, (toIocMod_eq_self _).2] · norm_cast rw [norm_add_mul_I] refine ⟨Real.le_sqrt_of_sq_le ?_, ?_⟩ · rw [mul_pow, ← abs_pow, abs_sq] calc _ = 2 * (1 - (1 - 2 / π ^ 2 * θ ^ 2)) := by ring _ ≤ 2 * (1 - θ.cos) := by gcongr; exact Real.cos_le_one_sub_mul_cos_sq <| abs_le.2 <| Ioc_subset_Icc_self hθ _ = _ := by linear_combination -θ.cos_sq_add_sin_sq · rw [Real.sqrt_le_left (by positivity), ← abs_pow, abs_sq] calc _ = 2 * (1 - θ.cos) := by linear_combination θ.cos_sq_add_sin_sq _ ≤ 2 * (1 - (1 - θ ^ 2 / 2)) := by gcongr; exact Real.one_sub_sq_div_two_le_cos _ = _ := by ring · convert hθ ring /-- Chord-length is always less than arc-length. -/ lemma norm_sub_le_angle (hx : ‖x‖ = 1) (hy : ‖y‖ = 1) : ‖x - y‖ ≤ angle x y := (norm_sub_mem_Icc_angle hx hy).2 /-- Chord-length is always greater than a multiple of arc-length. -/ lemma mul_angle_le_norm_sub (hx : ‖x‖ = 1) (hy : ‖y‖ = 1) : 2 / π * angle x y ≤ ‖x - y‖ := (norm_sub_mem_Icc_angle hx hy).1 /-- Arc-length is always less than a multiple of chord-length. -/ lemma angle_le_mul_norm_sub (hx : ‖x‖ = 1) (hy : ‖y‖ = 1) : angle x y ≤ π / 2 * ‖x - y‖ := by rw [← div_le_iff₀' <| by positivity, div_eq_inv_mul, inv_div]; exact mul_angle_le_norm_sub hx hy end Complex
.lake/packages/mathlib/Mathlib/Analysis/Complex/Norm.lean
import Mathlib.Analysis.Normed.Group.Basic import Mathlib.Data.Complex.Basic import Mathlib.Data.Real.Sqrt /-! # Norm on the complex numbers -/ noncomputable section open ComplexConjugate Topology Filter Set namespace Complex variable {z : ℂ} instance instNorm : Norm ℂ where norm z := √(normSq z) theorem norm_def (z : ℂ) : ‖z‖ = √(normSq z) := rfl theorem norm_mul_self_eq_normSq (z : ℂ) : ‖z‖ * ‖z‖ = normSq z := Real.mul_self_sqrt (normSq_nonneg _) private theorem norm_nonneg (z : ℂ) : 0 ≤ ‖z‖ := Real.sqrt_nonneg _ @[bound] theorem abs_re_le_norm (z : ℂ) : |z.re| ≤ ‖z‖ := by rw [mul_self_le_mul_self_iff (abs_nonneg z.re) (norm_nonneg _), abs_mul_abs_self, norm_mul_self_eq_normSq] apply re_sq_le_normSq theorem re_le_norm (z : ℂ) : z.re ≤ ‖z‖ := (abs_le.1 (abs_re_le_norm _)).2 private theorem norm_add_le' (z w : ℂ) : ‖z + w‖ ≤ ‖z‖ + ‖w‖ := (mul_self_le_mul_self_iff (norm_nonneg (z + w)) (add_nonneg (norm_nonneg z) (norm_nonneg w))).2 <| by rw [norm_mul_self_eq_normSq, add_mul_self_eq, norm_mul_self_eq_normSq, norm_mul_self_eq_normSq, add_right_comm, normSq_add, mul_assoc, norm_def, norm_def, ← Real.sqrt_mul <| normSq_nonneg z, ← normSq_conj w, ← map_mul] gcongr exact re_le_norm (z * conj w) private theorem norm_eq_zero_iff {z : ℂ} : ‖z‖ = 0 ↔ z = 0 := (Real.sqrt_eq_zero <| normSq_nonneg _).trans normSq_eq_zero private theorem norm_map_zero' : ‖(0 : ℂ)‖ = 0 := norm_eq_zero_iff.mpr rfl private theorem norm_neg' (z : ℂ) : ‖-z‖ = ‖z‖ := by rw [Complex.norm_def, norm_def, normSq_neg] instance instNormedAddCommGroup : NormedAddCommGroup ℂ := AddGroupNorm.toNormedAddCommGroup { toFun := norm map_zero' := norm_map_zero' add_le' := norm_add_le' neg' := norm_neg' eq_zero_of_map_eq_zero' := fun _ ↦ norm_eq_zero_iff.mp } @[simp 1100] protected theorem norm_mul (z w : ℂ) : ‖z * w‖ = ‖z‖ * ‖w‖ := by rw [norm_def, norm_def, norm_def, normSq_mul, Real.sqrt_mul (normSq_nonneg _)] @[simp 1100] protected theorem norm_div (z w : ℂ) : ‖z / w‖ = ‖z‖ / ‖w‖ := by rw [norm_def, norm_def, norm_def, normSq_div, Real.sqrt_div (normSq_nonneg _)] instance isAbsoluteValueNorm : IsAbsoluteValue (‖·‖ : ℂ → ℝ) where abv_nonneg' := norm_nonneg abv_eq_zero' := norm_eq_zero_iff abv_add' := norm_add_le abv_mul' := Complex.norm_mul protected theorem norm_pow (z : ℂ) (n : ℕ) : ‖z ^ n‖ = ‖z‖ ^ n := map_pow isAbsoluteValueNorm.abvHom _ _ protected theorem norm_zpow (z : ℂ) (n : ℤ) : ‖z ^ n‖ = ‖z‖ ^ n := map_zpow₀ isAbsoluteValueNorm.abvHom _ _ protected theorem norm_prod {ι : Type*} (s : Finset ι) (f : ι → ℂ) : ‖s.prod f‖ = s.prod fun i ↦ ‖f i‖ := map_prod isAbsoluteValueNorm.abvHom _ _ theorem norm_conj (z : ℂ) : ‖conj z‖ = ‖z‖ := by simp [norm_def] @[simp] lemma norm_I : ‖I‖ = 1 := by simp [norm] @[simp] lemma nnnorm_I : ‖I‖₊ = 1 := by simp [nnnorm] @[simp 1100, norm_cast] lemma norm_real (r : ℝ) : ‖(r : ℂ)‖ = ‖r‖ := by simp [norm_def, Real.sqrt_mul_self_eq_abs] protected theorem norm_of_nonneg {r : ℝ} (h : 0 ≤ r) : ‖(r : ℂ)‖ = r := (norm_real _).trans (abs_of_nonneg h) @[simp, norm_cast] lemma nnnorm_real (r : ℝ) : ‖(r : ℂ)‖₊ = ‖r‖₊ := by ext; exact norm_real _ @[norm_cast] lemma norm_natCast (n : ℕ) : ‖(n : ℂ)‖ = n := Complex.norm_of_nonneg n.cast_nonneg @[simp 1100] lemma norm_ofNat (n : ℕ) [n.AtLeastTwo] : ‖(ofNat(n) : ℂ)‖ = OfNat.ofNat n := norm_natCast n protected lemma norm_two : ‖(2 : ℂ)‖ = 2 := norm_ofNat 2 @[simp 1100, norm_cast] lemma nnnorm_natCast (n : ℕ) : ‖(n : ℂ)‖₊ = n := Subtype.ext <| by simp [norm_natCast] @[simp 1100] lemma nnnorm_ofNat (n : ℕ) [n.AtLeastTwo] : ‖(ofNat(n) : ℂ)‖₊ = OfNat.ofNat n := nnnorm_natCast n @[simp 1100, norm_cast] lemma norm_intCast (n : ℤ) : ‖(n : ℂ)‖ = |(n : ℝ)| := by rw [← ofReal_intCast, norm_real, Real.norm_eq_abs] theorem norm_int_of_nonneg {n : ℤ} (hn : 0 ≤ n) : ‖(n : ℂ)‖ = n := by rw [norm_intCast, ← Int.cast_abs, abs_of_nonneg hn] @[simp 1100, norm_cast] lemma norm_ratCast (q : ℚ) : ‖(q : ℂ)‖ = |(q : ℝ)| := norm_real _ @[simp 1100, norm_cast] lemma norm_nnratCast (q : ℚ≥0) : ‖(q : ℂ)‖ = q := Complex.norm_of_nonneg q.cast_nonneg @[simp 1100, norm_cast] lemma nnnorm_ratCast (q : ℚ) : ‖(q : ℂ)‖₊ = ‖(q : ℝ)‖₊ := nnnorm_real q @[simp 1100, norm_cast] lemma nnnorm_nnratCast (q : ℚ≥0) : ‖(q : ℂ)‖₊ = q := by simp [nnnorm] lemma normSq_eq_norm_sq (z : ℂ) : normSq z = ‖z‖ ^ 2 := by simp [norm_def, sq, Real.mul_self_sqrt (normSq_nonneg _)] protected theorem sq_norm (z : ℂ) : ‖z‖ ^ 2 = normSq z := (normSq_eq_norm_sq z).symm @[simp] theorem sq_norm_sub_sq_re (z : ℂ) : ‖z‖ ^ 2 - z.re ^ 2 = z.im ^ 2 := by rw [Complex.sq_norm, normSq_apply, ← sq, ← sq, add_sub_cancel_left] @[simp] theorem sq_norm_sub_sq_im (z : ℂ) : ‖z‖ ^ 2 - z.im ^ 2 = z.re ^ 2 := by rw [← sq_norm_sub_sq_re, sub_sub_cancel] lemma norm_add_mul_I (x y : ℝ) : ‖x + y * I‖ = √(x ^ 2 + y ^ 2) := by rw [← normSq_add_mul_I]; rfl lemma norm_eq_sqrt_sq_add_sq (z : ℂ) : ‖z‖ = √(z.re ^ 2 + z.im ^ 2) := by rw [norm_def, normSq_apply, sq, sq] @[simp 1100] protected theorem range_norm : range (‖·‖ : ℂ → ℝ) = Set.Ici 0 := Subset.antisymm (range_subset_iff.2 norm_nonneg) fun x hx ↦ ⟨x, Complex.norm_of_nonneg hx⟩ @[simp] theorem range_normSq : range normSq = Ici 0 := Subset.antisymm (range_subset_iff.2 normSq_nonneg) fun x hx => ⟨√x, by rw [normSq_ofReal, Real.mul_self_sqrt hx]⟩ theorem norm_le_abs_re_add_abs_im (z : ℂ) : ‖z‖ ≤ |z.re| + |z.im| := by simpa [re_add_im] using norm_add_le (z.re : ℂ) (z.im * I) @[bound] theorem abs_im_le_norm (z : ℂ) : |z.im| ≤ ‖z‖ := Real.abs_le_sqrt <| by rw [normSq_apply, ← sq, ← sq] exact le_add_of_nonneg_left (sq_nonneg _) theorem im_le_norm (z : ℂ) : z.im ≤ ‖z‖ := (abs_le.1 (abs_im_le_norm _)).2 @[simp] theorem abs_re_lt_norm {z : ℂ} : |z.re| < ‖z‖ ↔ z.im ≠ 0 := by rw [norm_def, Real.lt_sqrt (abs_nonneg _), normSq_apply, sq_abs, ← sq, lt_add_iff_pos_right, mul_self_pos] @[simp] theorem abs_im_lt_norm {z : ℂ} : |z.im| < ‖z‖ ↔ z.re ≠ 0 := by simpa using @abs_re_lt_norm (z * I) @[simp] lemma abs_re_eq_norm {z : ℂ} : |z.re| = ‖z‖ ↔ z.im = 0 := not_iff_not.1 <| (abs_re_le_norm z).lt_iff_ne.symm.trans abs_re_lt_norm @[simp] lemma abs_im_eq_norm {z : ℂ} : |z.im| = ‖z‖ ↔ z.re = 0 := not_iff_not.1 <| (abs_im_le_norm z).lt_iff_ne.symm.trans abs_im_lt_norm theorem norm_le_sqrt_two_mul_max (z : ℂ) : ‖z‖ ≤ √2 * max |z.re| |z.im| := by obtain ⟨x, y⟩ := z simp only [norm_def, normSq_mk, norm_def, ← sq] set m := max |x| |y| have hm₀ : 0 ≤ m := by positivity calc √(x ^ 2 + y ^ 2) ≤ √(m ^ 2 + m ^ 2) := by gcongr √(?_ + ?_) <;> rw [sq_le_sq, abs_of_nonneg hm₀] exacts [le_max_left _ _, le_max_right _ _] _ = √2 * m := by rw [← two_mul, Real.sqrt_mul, Real.sqrt_sq] <;> positivity theorem abs_re_div_norm_le_one (z : ℂ) : |z.re / ‖z‖| ≤ 1 := if hz : z = 0 then by simp [hz, zero_le_one] else by simp_rw [abs_div, abs_norm, div_le_iff₀ (norm_pos_iff.mpr hz), one_mul, abs_re_le_norm] theorem abs_im_div_norm_le_one (z : ℂ) : |z.im / ‖z‖| ≤ 1 := if hz : z = 0 then by simp [hz, zero_le_one] else by simp_rw [_root_.abs_div, abs_norm, div_le_iff₀ (norm_pos_iff.mpr hz), one_mul, abs_im_le_norm] theorem dist_eq (z w : ℂ) : dist z w = ‖z - w‖ := rfl theorem dist_eq_re_im (z w : ℂ) : dist z w = √((z.re - w.re) ^ 2 + (z.im - w.im) ^ 2) := by rw [sq, sq] rfl @[simp] theorem dist_mk (x₁ y₁ x₂ y₂ : ℝ) : dist (mk x₁ y₁) (mk x₂ y₂) = √((x₁ - x₂) ^ 2 + (y₁ - y₂) ^ 2) := dist_eq_re_im _ _ theorem dist_of_re_eq {z w : ℂ} (h : z.re = w.re) : dist z w = dist z.im w.im := by rw [dist_eq_re_im, h, sub_self, zero_pow two_ne_zero, zero_add, Real.sqrt_sq_eq_abs, Real.dist_eq] theorem nndist_of_re_eq {z w : ℂ} (h : z.re = w.re) : nndist z w = nndist z.im w.im := NNReal.eq <| dist_of_re_eq h theorem edist_of_re_eq {z w : ℂ} (h : z.re = w.re) : edist z w = edist z.im w.im := by rw [edist_nndist, edist_nndist, nndist_of_re_eq h] theorem dist_of_im_eq {z w : ℂ} (h : z.im = w.im) : dist z w = dist z.re w.re := by rw [dist_eq_re_im, h, sub_self, zero_pow two_ne_zero, add_zero, Real.sqrt_sq_eq_abs, Real.dist_eq] theorem nndist_of_im_eq {z w : ℂ} (h : z.im = w.im) : nndist z w = nndist z.re w.re := NNReal.eq <| dist_of_im_eq h theorem edist_of_im_eq {z w : ℂ} (h : z.im = w.im) : edist z w = edist z.re w.re := by rw [edist_nndist, edist_nndist, nndist_of_im_eq h] theorem dist_conj_self (z : ℂ) : dist (conj z) z = 2 * |z.im| := by rw [dist_of_re_eq (conj_re z), conj_im, dist_comm, Real.dist_eq, sub_neg_eq_add, ← two_mul, _root_.abs_mul, abs_of_pos (zero_lt_two' ℝ)] theorem nndist_conj_self (z : ℂ) : nndist (conj z) z = 2 * Real.nnabs z.im := NNReal.eq <| by rw [← dist_nndist, NNReal.coe_mul, NNReal.coe_two, Real.coe_nnabs, dist_conj_self] theorem dist_self_conj (z : ℂ) : dist z (conj z) = 2 * |z.im| := by rw [dist_comm, dist_conj_self] theorem nndist_self_conj (z : ℂ) : nndist z (conj z) = 2 * Real.nnabs z.im := by rw [nndist_comm, nndist_conj_self] /-! ### Cauchy sequences -/ theorem isCauSeq_re (f : CauSeq ℂ (‖·‖)) : IsCauSeq abs fun n ↦ (f n).re := fun _ ε0 ↦ (f.cauchy ε0).imp fun i H j ij ↦ lt_of_le_of_lt (by simpa using abs_re_le_norm (f j - f i)) (H _ ij) theorem isCauSeq_im (f : CauSeq ℂ (‖·‖)) : IsCauSeq abs fun n ↦ (f n).im := fun ε ε0 ↦ (f.cauchy ε0).imp fun i H j ij ↦ by simpa only [← ofReal_sub, norm_real, sub_re] using (abs_im_le_norm _).trans_lt <| H _ ij /-- The real part of a complex Cauchy sequence, as a real Cauchy sequence. -/ noncomputable def cauSeqRe (f : CauSeq ℂ (‖·‖)) : CauSeq ℝ abs := ⟨_, isCauSeq_re f⟩ /-- The imaginary part of a complex Cauchy sequence, as a real Cauchy sequence. -/ noncomputable def cauSeqIm (f : CauSeq ℂ (‖·‖)) : CauSeq ℝ abs := ⟨_, isCauSeq_im f⟩ theorem isCauSeq_norm {f : ℕ → ℂ} (hf : IsCauSeq (‖·‖) f) : IsCauSeq abs ((‖·‖) ∘ f) := fun ε ε0 ↦ let ⟨i, hi⟩ := hf ε ε0 ⟨i, fun j hj ↦ lt_of_le_of_lt (abs_norm_sub_norm_le _ _) (hi j hj)⟩ /-- The limit of a Cauchy sequence of complex numbers. -/ noncomputable def limAux (f : CauSeq ℂ (‖·‖)) : ℂ := ⟨CauSeq.lim (cauSeqRe f), CauSeq.lim (cauSeqIm f)⟩ theorem equiv_limAux (f : CauSeq ℂ (‖·‖)) : f ≈ CauSeq.const (‖·‖) (limAux f) := fun ε ε0 ↦ (exists_forall_ge_and (CauSeq.equiv_lim ⟨_, isCauSeq_re f⟩ _ (half_pos ε0)) (CauSeq.equiv_lim ⟨_, isCauSeq_im f⟩ _ (half_pos ε0))).imp fun _ H j ij ↦ by obtain ⟨H₁, H₂⟩ := H _ ij apply lt_of_le_of_lt (norm_le_abs_re_add_abs_im _) dsimp [limAux] at * have := add_lt_add H₁ H₂ rwa [add_halves] at this instance instIsComplete : CauSeq.IsComplete ℂ (‖·‖) := ⟨fun f ↦ ⟨limAux f, equiv_limAux f⟩⟩ open CauSeq theorem lim_eq_lim_im_add_lim_re (f : CauSeq ℂ (‖·‖)) : lim f = ↑(lim (cauSeqRe f)) + ↑(lim (cauSeqIm f)) * I := lim_eq_of_equiv_const <| letI : IsAbsoluteValue (‖·‖ : ℂ → ℝ) := inferInstance calc f ≈ _ := equiv_limAux f _ = CauSeq.const (‖·‖) (↑(lim (cauSeqRe f)) + ↑(lim (cauSeqIm f)) * I) := CauSeq.ext fun _ ↦ Complex.ext (by simp [limAux, cauSeqRe, ofReal]) (by simp [limAux, cauSeqIm, ofReal]) theorem lim_re (f : CauSeq ℂ (‖·‖)) : lim (cauSeqRe f) = (lim f).re := by rw [lim_eq_lim_im_add_lim_re]; simp [ofReal] theorem lim_im (f : CauSeq ℂ (‖·‖)) : lim (cauSeqIm f) = (lim f).im := by rw [lim_eq_lim_im_add_lim_re]; simp [ofReal] theorem isCauSeq_conj (f : CauSeq ℂ (‖·‖)) : IsCauSeq (‖·‖) fun n ↦ conj (f n) := fun ε ε0 ↦ let ⟨i, hi⟩ := f.2 ε ε0 ⟨i, fun j hj => by simp_rw [← RingHom.map_sub, norm_conj]; exact hi j hj⟩ /-- The complex conjugate of a complex Cauchy sequence, as a complex Cauchy sequence. -/ noncomputable def cauSeqConj (f : CauSeq ℂ (‖·‖)) : CauSeq ℂ (‖·‖) := ⟨_, isCauSeq_conj f⟩ theorem lim_conj (f : CauSeq ℂ (‖·‖)) : lim (cauSeqConj f) = conj (lim f) := Complex.ext (by simp [cauSeqConj, (lim_re _).symm, cauSeqRe]) (by simp [cauSeqConj, (lim_im _).symm, cauSeqIm, (lim_neg _).symm]; rfl) /-- The norm of a complex Cauchy sequence, as a real Cauchy sequence. -/ noncomputable def cauSeqNorm (f : CauSeq ℂ (‖·‖)) : CauSeq ℝ abs := ⟨_, isCauSeq_norm f.2⟩ theorem lim_norm (f : CauSeq ℂ (‖·‖)) : lim (cauSeqNorm f) = ‖lim f‖ := lim_eq_of_equiv_const fun ε ε0 ↦ let ⟨i, hi⟩ := equiv_lim f ε ε0 ⟨i, fun j hj => lt_of_le_of_lt (abs_norm_sub_norm_le _ _) (hi j hj)⟩ lemma ne_zero_of_re_pos {s : ℂ} (hs : 0 < s.re) : s ≠ 0 := fun h ↦ (zero_re ▸ h ▸ hs).false lemma ne_zero_of_one_lt_re {s : ℂ} (hs : 1 < s.re) : s ≠ 0 := ne_zero_of_re_pos <| zero_lt_one.trans hs lemma re_neg_ne_zero_of_re_pos {s : ℂ} (hs : 0 < s.re) : (-s).re ≠ 0 := ne_iff_lt_or_gt.mpr <| Or.inl <| neg_re s ▸ (neg_lt_zero.mpr hs) lemma re_neg_ne_zero_of_one_lt_re {s : ℂ} (hs : 1 < s.re) : (-s).re ≠ 0 := re_neg_ne_zero_of_re_pos <| zero_lt_one.trans hs lemma norm_sub_one_sq_eq_of_norm_eq_one {z : ℂ} (hz : ‖z‖ = 1) : ‖z - 1‖ ^ 2 = 2 * (1 - z.re) := by have : z.im * z.im = 1 - z.re * z.re := by replace hz := sq_eq_one_iff.mpr (.inl hz) rw [Complex.sq_norm, normSq_apply] at hz linarith simp [Complex.sq_norm, normSq_apply, this] ring @[deprecated (since := "2025-11-15")] alias norm_sub_one_sq_eq_of_norm_one := norm_sub_one_sq_eq_of_norm_eq_one lemma norm_sub_one_sq_eqOn_sphere : (Metric.sphere (0 : ℂ) 1).EqOn (‖· - 1‖ ^ 2) (fun z ↦ 2 * (1 - z.re)) := fun z hz ↦ norm_sub_one_sq_eq_of_norm_eq_one (by simpa using hz) lemma normSq_ofReal_add_I_mul_sqrt_one_sub {x : ℝ} (hx : ‖x‖ ≤ 1) : normSq (x + I * √(1 - x ^ 2)) = 1 := by simp [mul_comm I, normSq_add_mul_I, Real.sq_sqrt (x := 1 - x ^ 2) (by nlinarith [abs_le.mp hx])] lemma normSq_ofReal_sub_I_mul_sqrt_one_sub {x : ℝ} (hx : ‖x‖ ≤ 1) : normSq (x - I * √(1 - x ^ 2)) = 1 := by rw [← normSq_neg, neg_sub', sub_neg_eq_add] simpa using normSq_ofReal_add_I_mul_sqrt_one_sub (x := -x) (by simpa) end Complex
.lake/packages/mathlib/Mathlib/Analysis/Complex/RemovableSingularity.lean
import Mathlib.Analysis.Calculus.FDeriv.Analytic import Mathlib.Analysis.Asymptotics.SpecificAsymptotics import Mathlib.Analysis.Complex.CauchyIntegral /-! # Removable singularity theorem In this file we prove Riemann's removable singularity theorem: if `f : ℂ → E` is complex differentiable in a punctured neighborhood of a point `c` and is bounded in a punctured neighborhood of `c` (or, more generally, $f(z) - f(c)=o((z-c)^{-1})$), then it has a limit at `c` and the function `update f c (limUnder (𝓝[≠] c) f)` is complex differentiable in a neighborhood of `c`. -/ open TopologicalSpace Metric Set Filter Asymptotics Function open scoped Topology Filter NNReal Real universe u variable {E : Type u} [NormedAddCommGroup E] [NormedSpace ℂ E] [CompleteSpace E] namespace Complex /-- **Removable singularity** theorem, weak version. If `f : ℂ → E` is differentiable in a punctured neighborhood of a point and is continuous at this point, then it is analytic at this point. -/ theorem analyticAt_of_differentiable_on_punctured_nhds_of_continuousAt {f : ℂ → E} {c : ℂ} (hd : ∀ᶠ z in 𝓝[≠] c, DifferentiableAt ℂ f z) (hc : ContinuousAt f c) : AnalyticAt ℂ f c := by rcases (nhdsWithin_hasBasis nhds_basis_closedBall _).mem_iff.1 hd with ⟨R, hR0, hRs⟩ lift R to ℝ≥0 using hR0.le replace hc : ContinuousOn f (closedBall c R) := by refine fun z hz => ContinuousAt.continuousWithinAt ?_ rcases eq_or_ne z c with (rfl | hne) exacts [hc, (hRs ⟨hz, hne⟩).continuousAt] exact (hasFPowerSeriesOnBall_of_differentiable_off_countable (countable_singleton c) hc (fun z hz => hRs (diff_subset_diff_left ball_subset_closedBall hz)) hR0).analyticAt theorem differentiableOn_compl_singleton_and_continuousAt_iff {f : ℂ → E} {s : Set ℂ} {c : ℂ} (hs : s ∈ 𝓝 c) : DifferentiableOn ℂ f (s \ {c}) ∧ ContinuousAt f c ↔ DifferentiableOn ℂ f s := by refine ⟨?_, fun hd => ⟨hd.mono diff_subset, (hd.differentiableAt hs).continuousAt⟩⟩ rintro ⟨hd, hc⟩ x hx rcases eq_or_ne x c with (rfl | hne) · refine (analyticAt_of_differentiable_on_punctured_nhds_of_continuousAt ?_ hc).differentiableAt.differentiableWithinAt refine eventually_nhdsWithin_iff.2 ((eventually_mem_nhds_iff.2 hs).mono fun z hz hzx => ?_) exact hd.differentiableAt (inter_mem hz (isOpen_ne.mem_nhds hzx)) · simpa only [DifferentiableWithinAt, HasFDerivWithinAt, hne.nhdsWithin_diff_singleton] using hd x ⟨hx, hne⟩ theorem differentiableOn_dslope {f : ℂ → E} {s : Set ℂ} {c : ℂ} (hc : s ∈ 𝓝 c) : DifferentiableOn ℂ (dslope f c) s ↔ DifferentiableOn ℂ f s := ⟨fun h => h.of_dslope, fun h => (differentiableOn_compl_singleton_and_continuousAt_iff hc).mp <| ⟨Iff.mpr (differentiableOn_dslope_of_notMem fun h => h.2 rfl) (h.mono diff_subset), continuousAt_dslope_same.2 <| h.differentiableAt hc⟩⟩ /-- **Removable singularity** theorem: if `s` is a neighborhood of `c : ℂ`, a function `f : ℂ → E` is complex differentiable on `s \ {c}`, and $f(z) - f(c)=o((z-c)^{-1})$, then `f` redefined to be equal to `limUnder (𝓝[≠] c) f` at `c` is complex differentiable on `s`. -/ theorem differentiableOn_update_limUnder_of_isLittleO {f : ℂ → E} {s : Set ℂ} {c : ℂ} (hc : s ∈ 𝓝 c) (hd : DifferentiableOn ℂ f (s \ {c})) (ho : (fun z => f z - f c) =o[𝓝[≠] c] fun z => (z - c)⁻¹) : DifferentiableOn ℂ (update f c (limUnder (𝓝[≠] c) f)) s := by set F : ℂ → E := fun z => (z - c) • f z suffices DifferentiableOn ℂ F (s \ {c}) ∧ ContinuousAt F c by rw [differentiableOn_compl_singleton_and_continuousAt_iff hc, ← differentiableOn_dslope hc, dslope_sub_smul] at this have hc : Tendsto f (𝓝[≠] c) (𝓝 (deriv F c)) := continuousAt_update_same.mp (this.continuousOn.continuousAt hc) rwa [hc.limUnder_eq] refine ⟨(differentiableOn_id.sub_const _).smul hd, ?_⟩ rw [← continuousWithinAt_compl_self] have H := ho.tendsto_inv_smul_nhds_zero have H' : Tendsto (fun z => (z - c) • f c) (𝓝[≠] c) (𝓝 (F c)) := (continuousWithinAt_id.tendsto.sub tendsto_const_nhds).smul tendsto_const_nhds simpa [← smul_add, ContinuousWithinAt] using H.add H' /-- **Removable singularity** theorem: if `s` is a punctured neighborhood of `c : ℂ`, a function `f : ℂ → E` is complex differentiable on `s`, and $f(z) - f(c)=o((z-c)^{-1})$, then `f` redefined to be equal to `limUnder (𝓝[≠] c) f` at `c` is complex differentiable on `{c} ∪ s`. -/ theorem differentiableOn_update_limUnder_insert_of_isLittleO {f : ℂ → E} {s : Set ℂ} {c : ℂ} (hc : s ∈ 𝓝[≠] c) (hd : DifferentiableOn ℂ f s) (ho : (fun z => f z - f c) =o[𝓝[≠] c] fun z => (z - c)⁻¹) : DifferentiableOn ℂ (update f c (limUnder (𝓝[≠] c) f)) (insert c s) := differentiableOn_update_limUnder_of_isLittleO (insert_mem_nhds_iff.2 hc) (hd.mono fun _ hz => hz.1.resolve_left hz.2) ho /-- **Removable singularity** theorem: if `s` is a neighborhood of `c : ℂ`, a function `f : ℂ → E` is complex differentiable and is bounded on `s \ {c}`, then `f` redefined to be equal to `limUnder (𝓝[≠] c) f` at `c` is complex differentiable on `s`. -/ theorem differentiableOn_update_limUnder_of_bddAbove {f : ℂ → E} {s : Set ℂ} {c : ℂ} (hc : s ∈ 𝓝 c) (hd : DifferentiableOn ℂ f (s \ {c})) (hb : BddAbove (norm ∘ f '' (s \ {c}))) : DifferentiableOn ℂ (update f c (limUnder (𝓝[≠] c) f)) s := differentiableOn_update_limUnder_of_isLittleO hc hd <| IsBoundedUnder.isLittleO_sub_self_inv <| let ⟨C, hC⟩ := hb ⟨C + ‖f c‖, eventually_map.2 <| mem_nhdsWithin_iff_exists_mem_nhds_inter.2 ⟨s, hc, fun _ hz => norm_sub_le_of_le (hC <| mem_image_of_mem _ hz) le_rfl⟩⟩ /-- **Removable singularity** theorem: if a function `f : ℂ → E` is complex differentiable on a punctured neighborhood of `c` and $f(z) - f(c)=o((z-c)^{-1})$, then `f` has a limit at `c`. -/ theorem tendsto_limUnder_of_differentiable_on_punctured_nhds_of_isLittleO {f : ℂ → E} {c : ℂ} (hd : ∀ᶠ z in 𝓝[≠] c, DifferentiableAt ℂ f z) (ho : (fun z => f z - f c) =o[𝓝[≠] c] fun z => (z - c)⁻¹) : Tendsto f (𝓝[≠] c) (𝓝 <| limUnder (𝓝[≠] c) f) := by rw [eventually_nhdsWithin_iff] at hd have : DifferentiableOn ℂ f ({z | z ≠ c → DifferentiableAt ℂ f z} \ {c}) := fun z hz => (hz.1 hz.2).differentiableWithinAt have H := differentiableOn_update_limUnder_of_isLittleO hd this ho exact continuousAt_update_same.1 (H.differentiableAt hd).continuousAt /-- **Removable singularity** theorem: if a function `f : ℂ → E` is complex differentiable and bounded on a punctured neighborhood of `c`, then `f` has a limit at `c`. -/ theorem tendsto_limUnder_of_differentiable_on_punctured_nhds_of_bounded_under {f : ℂ → E} {c : ℂ} (hd : ∀ᶠ z in 𝓝[≠] c, DifferentiableAt ℂ f z) (hb : IsBoundedUnder (· ≤ ·) (𝓝[≠] c) fun z => ‖f z - f c‖) : Tendsto f (𝓝[≠] c) (𝓝 <| limUnder (𝓝[≠] c) f) := tendsto_limUnder_of_differentiable_on_punctured_nhds_of_isLittleO hd hb.isLittleO_sub_self_inv /-- The Cauchy formula for the derivative of a holomorphic function. -/ theorem two_pi_I_inv_smul_circleIntegral_sub_sq_inv_smul_of_differentiable {U : Set ℂ} (hU : IsOpen U) {c w₀ : ℂ} {R : ℝ} {f : ℂ → E} (hc : closedBall c R ⊆ U) (hf : DifferentiableOn ℂ f U) (hw₀ : w₀ ∈ ball c R) : ((2 * π * I : ℂ)⁻¹ • ∮ z in C(c, R), ((z - w₀) ^ 2)⁻¹ • f z) = deriv f w₀ := by -- We apply the removable singularity theorem and the Cauchy formula to `dslope f w₀` have hf' : DifferentiableOn ℂ (dslope f w₀) U := (differentiableOn_dslope (hU.mem_nhds ((ball_subset_closedBall.trans hc) hw₀))).mpr hf have h0 := (hf'.diffContOnCl_ball hc).two_pi_i_inv_smul_circleIntegral_sub_inv_smul hw₀ rw [← dslope_same, ← h0] congr 1 trans ∮ z in C(c, R), ((z - w₀) ^ 2)⁻¹ • (f z - f w₀) · have h1 : ContinuousOn (fun z : ℂ => ((z - w₀) ^ 2)⁻¹) (sphere c R) := by refine ((continuous_id'.sub continuous_const).pow 2).continuousOn.inv₀ fun w hw h => ?_ exact sphere_disjoint_ball.ne_of_mem hw hw₀ (sub_eq_zero.mp (sq_eq_zero_iff.mp h)) have h2 : CircleIntegrable (fun z : ℂ => ((z - w₀) ^ 2)⁻¹ • f z) c R := by refine ContinuousOn.circleIntegrable (pos_of_mem_ball hw₀).le ?_ exact h1.smul (hf.continuousOn.mono (sphere_subset_closedBall.trans hc)) have h3 : CircleIntegrable (fun z : ℂ => ((z - w₀) ^ 2)⁻¹ • f w₀) c R := ContinuousOn.circleIntegrable (pos_of_mem_ball hw₀).le (h1.smul continuousOn_const) have h4 : (∮ z : ℂ in C(c, R), ((z - w₀) ^ 2)⁻¹) = 0 := by simpa using circleIntegral.integral_sub_zpow_of_ne (by decide : (-2 : ℤ) ≠ -1) c w₀ R simp only [smul_sub, circleIntegral.integral_sub h2 h3, h4, circleIntegral.integral_smul_const, zero_smul, sub_zero] · refine circleIntegral.integral_congr (pos_of_mem_ball hw₀).le fun z hz => ?_ simp only [dslope_of_ne, Metric.sphere_disjoint_ball.ne_of_mem hz hw₀, slope, ← smul_assoc, sq, mul_inv, Ne, not_false_iff, vsub_eq_sub, Algebra.id.smul_eq_mul] end Complex
.lake/packages/mathlib/Mathlib/Analysis/Complex/AbsMax.lean
import Mathlib.Analysis.Complex.CauchyIntegral import Mathlib.Analysis.InnerProductSpace.Convex import Mathlib.Analysis.Normed.Affine.AddTorsor import Mathlib.Analysis.NormedSpace.Extr import Mathlib.LinearAlgebra.Complex.FiniteDimensional import Mathlib.Topology.Order.ExtrClosure /-! # Maximum modulus principle In this file we prove several versions of the maximum modulus principle. There are several statements that can be called "the maximum modulus principle" for maps between normed complex spaces. They differ by assumptions on the domain (any space, a nontrivial space, a finite dimensional space), assumptions on the codomain (any space, a strictly convex space), and by conclusion (either equality of norms or of the values of the function). ## Main results ### Theorems for any codomain Consider a function `f : E → F` that is complex differentiable on a set `s`, is continuous on its closure, and `‖f x‖` has a maximum on `s` at `c`. We prove the following theorems. - `Complex.norm_eqOn_closedBall_of_isMaxOn`: if `s = Metric.ball c r`, then `‖f x‖ = ‖f c‖` for any `x` from the corresponding closed ball; - `Complex.norm_eq_norm_of_isMaxOn_of_ball_subset`: if `Metric.ball c (dist w c) ⊆ s`, then `‖f w‖ = ‖f c‖`; - `Complex.norm_eqOn_of_isPreconnected_of_isMaxOn`: if `U` is an open (pre)connected set, `f` is complex differentiable on `U`, and `‖f x‖` has a maximum on `U` at `c ∈ U`, then `‖f x‖ = ‖f c‖` for all `x ∈ U`; - `Complex.norm_eqOn_closure_of_isPreconnected_of_isMaxOn`: if `s` is open and (pre)connected and `c ∈ s`, then `‖f x‖ = ‖f c‖` for all `x ∈ closure s`; - `Complex.norm_eventually_eq_of_isLocalMax`: if `f` is complex differentiable in a neighborhood of `c` and `‖f x‖` has a local maximum at `c`, then `‖f x‖` is locally a constant in a neighborhood of `c`. ### Theorems for a strictly convex codomain If the codomain `F` is a strictly convex space, then in the lemmas from the previous section we can prove `f w = f c` instead of `‖f w‖ = ‖f c‖`, see `Complex.eqOn_of_isPreconnected_of_isMaxOn_norm`, `Complex.eqOn_closure_of_isPreconnected_of_isMaxOn_norm`, `Complex.eq_of_isMaxOn_of_ball_subset`, `Complex.eqOn_closedBall_of_isMaxOn_norm`, and `Complex.eventually_eq_of_isLocalMax_norm`. ### Values on the frontier Finally, we prove some corollaries that relate the (norm of the) values of a function on a set to its values on the frontier of the set. All these lemmas assume that `E` is a nontrivial space. In this section `f g : E → F` are functions that are complex differentiable on a bounded set `s` and are continuous on its closure. We prove the following theorems. - `Complex.exists_mem_frontier_isMaxOn_norm`: If `E` is a finite-dimensional space and `s` is a nonempty bounded set, then there exists a point `z ∈ frontier s` such that `(‖f ·‖)` takes it maximum value on `closure s` at `z`. - `Complex.norm_le_of_forall_mem_frontier_norm_le`: if `‖f z‖ ≤ C` for all `z ∈ frontier s`, then `‖f z‖ ≤ C` for all `z ∈ s`; note that this theorem does not require `E` to be a finite-dimensional space. - `Complex.eqOn_closure_of_eqOn_frontier`: if `f x = g x` on the frontier of `s`, then `f x = g x` on `closure s`; - `Complex.eqOn_of_eqOn_frontier`: if `f x = g x` on the frontier of `s`, then `f x = g x` on `s`. ## Tags maximum modulus principle, complex analysis -/ open TopologicalSpace Metric Set Filter Asymptotics Function MeasureTheory AffineMap Bornology open scoped Topology Filter NNReal Real universe u v w variable {E : Type u} [NormedAddCommGroup E] [NormedSpace ℂ E] {F : Type v} [NormedAddCommGroup F] [NormedSpace ℂ F] local postfix:100 "̂" => UniformSpace.Completion namespace Complex /-! ### Auxiliary lemmas We split the proof into a series of lemmas. First we prove the principle for a function `f : ℂ → F` with an additional assumption that `F` is a complete space, then drop unneeded assumptions one by one. The lemmas with names `*_auxₙ` are considered to be private and should not be used outside of this file. -/ theorem norm_max_aux₁ [CompleteSpace F] {f : ℂ → F} {z w : ℂ} (hd : DiffContOnCl ℂ f (ball z (dist w z))) (hz : IsMaxOn (norm ∘ f) (closedBall z (dist w z)) z) : ‖f w‖ = ‖f z‖ := by -- Consider a circle of radius `r = dist w z`. set r : ℝ := dist w z have hw : w ∈ closedBall z r := mem_closedBall.2 le_rfl -- Assume the converse. Since `‖f w‖ ≤ ‖f z‖`, we have `‖f w‖ < ‖f z‖`. refine (isMaxOn_iff.1 hz _ hw).antisymm (not_lt.1 ?_) rintro hw_lt : ‖f w‖ < ‖f z‖ have hr : 0 < r := dist_pos.2 (ne_of_apply_ne (norm ∘ f) hw_lt.ne) -- Due to Cauchy integral formula, it suffices to prove the following inequality. suffices ‖∮ ζ in C(z, r), (ζ - z)⁻¹ • f ζ‖ < 2 * π * ‖f z‖ by refine this.ne ?_ have A : (∮ ζ in C(z, r), (ζ - z)⁻¹ • f ζ) = (2 * π * I : ℂ) • f z := hd.circleIntegral_sub_inv_smul (mem_ball_self hr) simp [A, norm_smul, Real.pi_pos.le] suffices ‖∮ ζ in C(z, r), (ζ - z)⁻¹ • f ζ‖ < 2 * π * r * (‖f z‖ / r) by rwa [mul_assoc, mul_div_cancel₀ _ hr.ne'] at this /- This inequality is true because `‖(ζ - z)⁻¹ • f ζ‖ ≤ ‖f z‖ / r` for all `ζ` on the circle and this inequality is strict at `ζ = w`. -/ have hsub : sphere z r ⊆ closedBall z r := sphere_subset_closedBall refine circleIntegral.norm_integral_lt_of_norm_le_const_of_lt hr ?_ ?_ ⟨w, rfl, ?_⟩ · show ContinuousOn (fun ζ : ℂ => (ζ - z)⁻¹ • f ζ) (sphere z r) refine ((continuousOn_id.sub continuousOn_const).inv₀ ?_).smul (hd.continuousOn_ball.mono hsub) exact fun ζ hζ => sub_ne_zero.2 (ne_of_mem_sphere hζ hr.ne') · show ∀ ζ ∈ sphere z r, ‖(ζ - z)⁻¹ • f ζ‖ ≤ ‖f z‖ / r rintro ζ (hζ : ‖ζ - z‖ = r) rw [le_div_iff₀ hr, norm_smul, norm_inv, hζ, mul_comm, mul_inv_cancel_left₀ hr.ne'] exact hz (hsub hζ) show ‖(w - z)⁻¹ • f w‖ < ‖f z‖ / r rw [norm_smul, norm_inv, ← div_eq_inv_mul] exact (div_lt_div_iff_of_pos_right hr).2 hw_lt /-! Now we drop the assumption `CompleteSpace F` by embedding `F` into its completion. -/ theorem norm_max_aux₂ {f : ℂ → F} {z w : ℂ} (hd : DiffContOnCl ℂ f (ball z (dist w z))) (hz : IsMaxOn (norm ∘ f) (closedBall z (dist w z)) z) : ‖f w‖ = ‖f z‖ := by set e : F →L[ℂ] F̂ := UniformSpace.Completion.toComplL have he : ∀ x, ‖e x‖ = ‖x‖ := UniformSpace.Completion.norm_coe replace hz : IsMaxOn (norm ∘ e ∘ f) (closedBall z (dist w z)) z := by simpa only [IsMaxOn, Function.comp_def, he] using hz simpa only [he, Function.comp_def] using norm_max_aux₁ (e.differentiable.comp_diffContOnCl hd) hz /-! Then we replace the assumption `IsMaxOn (norm ∘ f) (Metric.closedBall z r) z` with a seemingly weaker assumption `IsMaxOn (norm ∘ f) (Metric.ball z r) z`. -/ theorem norm_max_aux₃ {f : ℂ → F} {z w : ℂ} {r : ℝ} (hr : dist w z = r) (hd : DiffContOnCl ℂ f (ball z r)) (hz : IsMaxOn (norm ∘ f) (ball z r) z) : ‖f w‖ = ‖f z‖ := by subst r rcases eq_or_ne w z with (rfl | hne); · rfl rw [← dist_ne_zero] at hne exact norm_max_aux₂ hd (closure_ball z hne ▸ hz.closure hd.continuousOn.norm) /-! ### Maximum modulus principle for any codomain If we do not assume that the codomain is a strictly convex space, then we can only claim that the **norm** `‖f x‖` is locally constant. -/ /-! Finally, we generalize the theorem from a disk in `ℂ` to a closed ball in any normed space. -/ /-- **Maximum modulus principle** on a closed ball: if `f : E → F` is continuous on a closed ball, is complex differentiable on the corresponding open ball, and the norm `‖f w‖` takes its maximum value on the open ball at its center, then the norm `‖f w‖` is constant on the closed ball. -/ theorem norm_eqOn_closedBall_of_isMaxOn {f : E → F} {z : E} {r : ℝ} (hd : DiffContOnCl ℂ f (ball z r)) (hz : IsMaxOn (norm ∘ f) (ball z r) z) : EqOn (norm ∘ f) (const E ‖f z‖) (closedBall z r) := by intro w hw rw [mem_closedBall, dist_comm] at hw rcases eq_or_ne z w with (rfl | hne); · rfl set e := (lineMap z w : ℂ → E) have hde : Differentiable ℂ e := (differentiable_id.smul_const (w - z)).add_const z suffices ‖(f ∘ e) (1 : ℂ)‖ = ‖(f ∘ e) (0 : ℂ)‖ by simpa [e] have hr : dist (1 : ℂ) 0 = 1 := by simp have hball : MapsTo e (ball 0 1) (ball z r) := by refine ((lipschitzWith_lineMap z w).mapsTo_ball (mt nndist_eq_zero.1 hne) 0 1).mono Subset.rfl ?_ simpa only [lineMap_apply_zero, mul_one, coe_nndist] using ball_subset_ball hw exact norm_max_aux₃ hr (hd.comp hde.diffContOnCl hball) (hz.comp_mapsTo hball (lineMap_apply_zero z w)) /-- **Maximum modulus principle**: if `f : E → F` is complex differentiable on a set `s`, the norm of `f` takes it maximum on `s` at `z`, and `w` is a point such that the closed ball with center `z` and radius `dist w z` is included in `s`, then `‖f w‖ = ‖f z‖`. -/ theorem norm_eq_norm_of_isMaxOn_of_ball_subset {f : E → F} {s : Set E} {z w : E} (hd : DiffContOnCl ℂ f s) (hz : IsMaxOn (norm ∘ f) s z) (hsub : ball z (dist w z) ⊆ s) : ‖f w‖ = ‖f z‖ := norm_eqOn_closedBall_of_isMaxOn (hd.mono hsub) (hz.on_subset hsub) (mem_closedBall.2 le_rfl) /-- **Maximum modulus principle**: if `f : E → F` is complex differentiable in a neighborhood of `c` and the norm `‖f z‖` has a local maximum at `c`, then `‖f z‖` is locally constant in a neighborhood of `c`. -/ theorem norm_eventually_eq_of_isLocalMax {f : E → F} {c : E} (hd : ∀ᶠ z in 𝓝 c, DifferentiableAt ℂ f z) (hc : IsLocalMax (norm ∘ f) c) : ∀ᶠ y in 𝓝 c, ‖f y‖ = ‖f c‖ := by rcases nhds_basis_closedBall.eventually_iff.1 (hd.and hc) with ⟨r, hr₀, hr⟩ exact nhds_basis_closedBall.eventually_iff.2 ⟨r, hr₀, norm_eqOn_closedBall_of_isMaxOn (DifferentiableOn.diffContOnCl fun x hx => (hr <| closure_ball_subset_closedBall hx).1.differentiableWithinAt) fun x hx => (hr <| ball_subset_closedBall hx).2⟩ theorem isOpen_setOf_mem_nhds_and_isMaxOn_norm {f : E → F} {s : Set E} (hd : DifferentiableOn ℂ f s) : IsOpen {z | s ∈ 𝓝 z ∧ IsMaxOn (norm ∘ f) s z} := by refine isOpen_iff_mem_nhds.2 fun z hz => (eventually_eventually_nhds.2 hz.1).and ?_ replace hd : ∀ᶠ w in 𝓝 z, DifferentiableAt ℂ f w := hd.eventually_differentiableAt hz.1 exact (norm_eventually_eq_of_isLocalMax hd <| hz.2.isLocalMax hz.1).mono fun x hx y hy => le_trans (hz.2 hy).out hx.ge /-- **Maximum modulus principle** on a connected set. Let `U` be a (pre)connected open set in a complex normed space. Let `f : E → F` be a function that is complex differentiable on `U`. Suppose that `‖f x‖` takes its maximum value on `U` at `c ∈ U`. Then `‖f x‖ = ‖f c‖` for all `x ∈ U`. -/ theorem norm_eqOn_of_isPreconnected_of_isMaxOn {f : E → F} {U : Set E} {c : E} (hc : IsPreconnected U) (ho : IsOpen U) (hd : DifferentiableOn ℂ f U) (hcU : c ∈ U) (hm : IsMaxOn (norm ∘ f) U c) : EqOn (norm ∘ f) (const E ‖f c‖) U := by set V := U ∩ {z | IsMaxOn (norm ∘ f) U z} have hV : ∀ x ∈ V, ‖f x‖ = ‖f c‖ := fun x hx => le_antisymm (hm hx.1) (hx.2 hcU) suffices U ⊆ V from fun x hx => hV x (this hx) have hVo : IsOpen V := by simpa only [ho.mem_nhds_iff, setOf_and, setOf_mem_eq] using isOpen_setOf_mem_nhds_and_isMaxOn_norm hd have hVne : (U ∩ V).Nonempty := ⟨c, hcU, hcU, hm⟩ set W := U ∩ {z | ‖f z‖ ≠ ‖f c‖} have hWo : IsOpen W := hd.continuousOn.norm.isOpen_inter_preimage ho isOpen_ne have hdVW : Disjoint V W := disjoint_left.mpr fun x hxV hxW => hxW.2 (hV x hxV) have hUVW : U ⊆ V ∪ W := fun x hx => (eq_or_ne ‖f x‖ ‖f c‖).imp (fun h => ⟨hx, fun y hy => (hm hy).out.trans_eq h.symm⟩) (And.intro hx) exact hc.subset_left_of_subset_union hVo hWo hdVW hUVW hVne /-- **Maximum modulus principle** on a connected set. Let `U` be a (pre)connected open set in a complex normed space. Let `f : E → F` be a function that is complex differentiable on `U` and is continuous on its closure. Suppose that `‖f x‖` takes its maximum value on `U` at `c ∈ U`. Then `‖f x‖ = ‖f c‖` for all `x ∈ closure U`. -/ theorem norm_eqOn_closure_of_isPreconnected_of_isMaxOn {f : E → F} {U : Set E} {c : E} (hc : IsPreconnected U) (ho : IsOpen U) (hd : DiffContOnCl ℂ f U) (hcU : c ∈ U) (hm : IsMaxOn (norm ∘ f) U c) : EqOn (norm ∘ f) (const E ‖f c‖) (closure U) := (norm_eqOn_of_isPreconnected_of_isMaxOn hc ho hd.differentiableOn hcU hm).of_subset_closure hd.continuousOn.norm continuousOn_const subset_closure Subset.rfl section StrictConvex /-! ### The case of a strictly convex codomain If the codomain `F` is a strictly convex space, then we can claim equalities like `f w = f z` instead of `‖f w‖ = ‖f z‖`. Instead of repeating the proof starting with lemmas about integrals, we apply a corresponding lemma above twice: for `f` and for `(f · + f c)`. Then we have `‖f w‖ = ‖f z‖` and `‖f w + f z‖ = ‖f z + f z‖`, thus `‖f w + f z‖ = ‖f w‖ + ‖f z‖`. This is only possible if `f w = f z`, see `eq_of_norm_eq_of_norm_add_eq`. -/ variable [StrictConvexSpace ℝ F] /-- **Maximum modulus principle** on a connected set. Let `U` be a (pre)connected open set in a complex normed space. Let `f : E → F` be a function that is complex differentiable on `U`. Suppose that `‖f x‖` takes its maximum value on `U` at `c ∈ U`. Then `f x = f c` for all `x ∈ U`. TODO: change assumption from `IsMaxOn` to `IsLocalMax`. -/ theorem eqOn_of_isPreconnected_of_isMaxOn_norm {f : E → F} {U : Set E} {c : E} (hc : IsPreconnected U) (ho : IsOpen U) (hd : DifferentiableOn ℂ f U) (hcU : c ∈ U) (hm : IsMaxOn (norm ∘ f) U c) : EqOn f (const E (f c)) U := fun x hx => have H₁ : ‖f x‖ = ‖f c‖ := norm_eqOn_of_isPreconnected_of_isMaxOn hc ho hd hcU hm hx have H₂ : ‖f x + f c‖ = ‖f c + f c‖ := norm_eqOn_of_isPreconnected_of_isMaxOn hc ho (hd.add_const _) hcU hm.norm_add_self hx eq_of_norm_eq_of_norm_add_eq H₁ <| by simp only [H₂, SameRay.rfl.norm_add, H₁, Function.const] /-- **Maximum modulus principle** on a connected set. Let `U` be a (pre)connected open set in a complex normed space. Let `f : E → F` be a function that is complex differentiable on `U` and is continuous on its closure. Suppose that `‖f x‖` takes its maximum value on `U` at `c ∈ U`. Then `f x = f c` for all `x ∈ closure U`. -/ theorem eqOn_closure_of_isPreconnected_of_isMaxOn_norm {f : E → F} {U : Set E} {c : E} (hc : IsPreconnected U) (ho : IsOpen U) (hd : DiffContOnCl ℂ f U) (hcU : c ∈ U) (hm : IsMaxOn (norm ∘ f) U c) : EqOn f (const E (f c)) (closure U) := (eqOn_of_isPreconnected_of_isMaxOn_norm hc ho hd.differentiableOn hcU hm).of_subset_closure hd.continuousOn continuousOn_const subset_closure Subset.rfl /-- **Maximum modulus principle**. Let `f : E → F` be a function between complex normed spaces. Suppose that the codomain `F` is a strictly convex space, `f` is complex differentiable on a set `s`, `f` is continuous on the closure of `s`, the norm of `f` takes it maximum on `s` at `z`, and `w` is a point such that the closed ball with center `z` and radius `dist w z` is included in `s`, then `f w = f z`. -/ theorem eq_of_isMaxOn_of_ball_subset {f : E → F} {s : Set E} {z w : E} (hd : DiffContOnCl ℂ f s) (hz : IsMaxOn (norm ∘ f) s z) (hsub : ball z (dist w z) ⊆ s) : f w = f z := have H₁ : ‖f w‖ = ‖f z‖ := norm_eq_norm_of_isMaxOn_of_ball_subset hd hz hsub have H₂ : ‖f w + f z‖ = ‖f z + f z‖ := norm_eq_norm_of_isMaxOn_of_ball_subset (hd.add_const _) hz.norm_add_self hsub eq_of_norm_eq_of_norm_add_eq H₁ <| by simp only [H₂, SameRay.rfl.norm_add, H₁] /-- **Maximum modulus principle** on a closed ball. Suppose that a function `f : E → F` from a normed complex space to a strictly convex normed complex space has the following properties: - it is continuous on a closed ball `Metric.closedBall z r`, - it is complex differentiable on the corresponding open ball; - the norm `‖f w‖` takes its maximum value on the open ball at its center. Then `f` is a constant on the closed ball. -/ theorem eqOn_closedBall_of_isMaxOn_norm {f : E → F} {z : E} {r : ℝ} (hd : DiffContOnCl ℂ f (ball z r)) (hz : IsMaxOn (norm ∘ f) (ball z r) z) : EqOn f (const E (f z)) (closedBall z r) := fun _x hx => eq_of_isMaxOn_of_ball_subset hd hz <| ball_subset_ball hx /-- If `f` is differentiable on the open unit ball `{z : ℂ | ‖z‖ < 1}`, and `‖f‖` attains a maximum in this open ball, then `f` is constant. -/ lemma eq_const_of_exists_max {f : E → F} {b : ℝ} (h_an : DifferentiableOn ℂ f (ball 0 b)) {v : E} (hv : v ∈ ball 0 b) (hv_max : IsMaxOn (norm ∘ f) (ball 0 b) v) : Set.EqOn f (Function.const E (f v)) (ball 0 b) := Complex.eqOn_of_isPreconnected_of_isMaxOn_norm (convex_ball 0 b).isPreconnected isOpen_ball h_an hv hv_max /-- If `f` is a function differentiable on the open unit ball, and there exists an `r < 1` such that any value of `‖f‖` on the open ball is bounded above by some value on the closed ball of radius `r`, then `f` is constant. -/ lemma eq_const_of_exists_le [ProperSpace E] {f : E → F} {r b : ℝ} (h_an : DifferentiableOn ℂ f (ball 0 b)) (hr_nn : 0 ≤ r) (hr_lt : r < b) (hr : ∀ z, z ∈ (ball 0 b) → ∃ w, w ∈ closedBall 0 r ∧ ‖f z‖ ≤ ‖f w‖) : Set.EqOn f (Function.const E (f 0)) (ball 0 b) := by obtain ⟨x, hx_mem, hx_max⟩ := isCompact_closedBall (0 : E) r |>.exists_isMaxOn (nonempty_closedBall.mpr hr_nn) (h_an.continuousOn.mono <| closedBall_subset_ball hr_lt).norm suffices Set.EqOn f (Function.const E (f x)) (ball 0 b) by rwa [this (mem_ball_self (hr_nn.trans_lt hr_lt))] apply eq_const_of_exists_max h_an (closedBall_subset_ball hr_lt hx_mem) (fun z hz ↦ ?_) obtain ⟨w, hw, hw'⟩ := hr z hz exact hw'.trans (hx_max hw) /-- **Maximum modulus principle**: if `f : E → F` is complex differentiable in a neighborhood of `c` and the norm `‖f z‖` has a local maximum at `c`, then `f` is locally constant in a neighborhood of `c`. -/ theorem eventually_eq_of_isLocalMax_norm {f : E → F} {c : E} (hd : ∀ᶠ z in 𝓝 c, DifferentiableAt ℂ f z) (hc : IsLocalMax (norm ∘ f) c) : ∀ᶠ y in 𝓝 c, f y = f c := by rcases nhds_basis_closedBall.eventually_iff.1 (hd.and hc) with ⟨r, hr₀, hr⟩ exact nhds_basis_closedBall.eventually_iff.2 ⟨r, hr₀, eqOn_closedBall_of_isMaxOn_norm (DifferentiableOn.diffContOnCl fun x hx => (hr <| closure_ball_subset_closedBall hx).1.differentiableWithinAt) fun x hx => (hr <| ball_subset_closedBall hx).2⟩ theorem eventually_eq_or_eq_zero_of_isLocalMin_norm {f : E → ℂ} {c : E} (hf : ∀ᶠ z in 𝓝 c, DifferentiableAt ℂ f z) (hc : IsLocalMin (norm ∘ f) c) : (∀ᶠ z in 𝓝 c, f z = f c) ∨ f c = 0 := by refine or_iff_not_imp_right.mpr fun h => ?_ have h1 : ∀ᶠ z in 𝓝 c, f z ≠ 0 := hf.self_of_nhds.continuousAt.eventually_ne h have h2 : IsLocalMax (norm ∘ f)⁻¹ c := hc.inv (h1.mono fun z => norm_pos_iff.mpr) have h3 : IsLocalMax (norm ∘ f⁻¹) c := by refine h2.congr (Eventually.of_forall ?_); simp have h4 : ∀ᶠ z in 𝓝 c, DifferentiableAt ℂ f⁻¹ z := by filter_upwards [hf, h1] with z h using h.inv filter_upwards [eventually_eq_of_isLocalMax_norm h4 h3] with z using inv_inj.mp end StrictConvex /-! ### Maximum on a set vs maximum on its frontier In this section we prove corollaries of the maximum modulus principle that relate the values of a function on a set to its values on the frontier of this set. -/ variable [Nontrivial E] /-- **Maximum modulus principle**: if `f : E → F` is complex differentiable on a nonempty bounded set `U` and is continuous on its closure, then there exists a point `z ∈ frontier U` such that `(‖f ·‖)` takes it maximum value on `closure U` at `z`. -/ theorem exists_mem_frontier_isMaxOn_norm [FiniteDimensional ℂ E] {f : E → F} {U : Set E} (hb : IsBounded U) (hne : U.Nonempty) (hd : DiffContOnCl ℂ f U) : ∃ z ∈ frontier U, IsMaxOn (norm ∘ f) (closure U) z := by have hc : IsCompact (closure U) := hb.isCompact_closure obtain ⟨w, hwU, hle⟩ : ∃ w ∈ closure U, IsMaxOn (norm ∘ f) (closure U) w := hc.exists_isMaxOn hne.closure hd.continuousOn.norm rw [closure_eq_interior_union_frontier, mem_union] at hwU rcases hwU with hwU | hwU; rotate_left; · exact ⟨w, hwU, hle⟩ have : interior U ≠ univ := ne_top_of_le_ne_top hc.ne_univ interior_subset_closure rcases exists_mem_frontier_infDist_compl_eq_dist hwU this with ⟨z, hzU, hzw⟩ refine ⟨z, frontier_interior_subset hzU, fun x hx => (hle hx).out.trans_eq ?_⟩ refine (norm_eq_norm_of_isMaxOn_of_ball_subset hd (hle.on_subset subset_closure) ?_).symm rw [dist_comm, ← hzw] exact ball_infDist_compl_subset.trans interior_subset /-- **Maximum modulus principle**: if `f : E → F` is complex differentiable on a bounded set `U` and `‖f z‖ ≤ C` for any `z ∈ frontier U`, then the same is true for any `z ∈ closure U`. -/ theorem norm_le_of_forall_mem_frontier_norm_le {f : E → F} {U : Set E} (hU : IsBounded U) (hd : DiffContOnCl ℂ f U) {C : ℝ} (hC : ∀ z ∈ frontier U, ‖f z‖ ≤ C) {z : E} (hz : z ∈ closure U) : ‖f z‖ ≤ C := by rw [closure_eq_self_union_frontier, union_comm, mem_union] at hz rcases hz with hz | hz; · exact hC z hz /- In case of a finite-dimensional domain, one can just apply `Complex.exists_mem_frontier_isMaxOn_norm`. To make it work in any Banach space, we restrict the function to a line first. -/ rcases exists_ne z with ⟨w, hne⟩ set e := (lineMap z w : ℂ → E) have hde : Differentiable ℂ e := (differentiable_id.smul_const (w - z)).add_const z have hL : AntilipschitzWith (nndist z w)⁻¹ e := antilipschitzWith_lineMap hne.symm replace hd : DiffContOnCl ℂ (f ∘ e) (e ⁻¹' U) := hd.comp hde.diffContOnCl (mapsTo_preimage _ _) have h₀ : (0 : ℂ) ∈ e ⁻¹' U := by simpa only [e, mem_preimage, lineMap_apply_zero] rcases exists_mem_frontier_isMaxOn_norm (hL.isBounded_preimage hU) ⟨0, h₀⟩ hd with ⟨ζ, hζU, hζ⟩ calc ‖f z‖ = ‖f (e 0)‖ := by simp only [e, lineMap_apply_zero] _ ≤ ‖f (e ζ)‖ := hζ (subset_closure h₀) _ ≤ C := hC _ (hde.continuous.frontier_preimage_subset _ hζU) /-- If two complex differentiable functions `f g : E → F` are equal on the boundary of a bounded set `U`, then they are equal on `closure U`. -/ theorem eqOn_closure_of_eqOn_frontier {f g : E → F} {U : Set E} (hU : IsBounded U) (hf : DiffContOnCl ℂ f U) (hg : DiffContOnCl ℂ g U) (hfg : EqOn f g (frontier U)) : EqOn f g (closure U) := by suffices H : ∀ z ∈ closure U, ‖(f - g) z‖ ≤ 0 by simpa [sub_eq_zero] using H refine fun z hz => norm_le_of_forall_mem_frontier_norm_le hU (hf.sub hg) (fun w hw => ?_) hz simp [hfg hw] /-- If two complex differentiable functions `f g : E → F` are equal on the boundary of a bounded set `U`, then they are equal on `U`. -/ theorem eqOn_of_eqOn_frontier {f g : E → F} {U : Set E} (hU : IsBounded U) (hf : DiffContOnCl ℂ f U) (hg : DiffContOnCl ℂ g U) (hfg : EqOn f g (frontier U)) : EqOn f g U := (eqOn_closure_of_eqOn_frontier hU hf hg hfg).mono subset_closure end Complex
.lake/packages/mathlib/Mathlib/Analysis/Complex/ReImTopology.lean
import Mathlib.Analysis.Complex.Basic import Mathlib.Topology.FiberBundle.IsHomeomorphicTrivialBundle /-! # Closure, interior, and frontier of preimages under `re` and `im` In this fact we use the fact that `ℂ` is naturally homeomorphic to `ℝ × ℝ` to deduce some topological properties of `Complex.re` and `Complex.im`. ## Main statements Each statement about `Complex.re` listed below has a counterpart about `Complex.im`. * `Complex.isHomeomorphicTrivialFiberBundle_re`: `Complex.re` turns `ℂ` into a trivial topological fiber bundle over `ℝ`; * `Complex.isOpenMap_re`, `Complex.isQuotientMap_re`: in particular, `Complex.re` is an open map and is a quotient map; * `Complex.interior_preimage_re`, `Complex.closure_preimage_re`, `Complex.frontier_preimage_re`: formulas for `interior (Complex.re ⁻¹' s)` etc; * `Complex.interior_setOf_re_le` etc: particular cases of the above formulas in the cases when `s` is one of the infinite intervals `Set.Ioi a`, `Set.Ici a`, `Set.Iio a`, and `Set.Iic a`, formulated as `interior {z : ℂ | z.re ≤ a} = {z | z.re < a}` etc. ## Tags complex, real part, imaginary part, closure, interior, frontier -/ open Set Topology noncomputable section namespace Complex /-- `Complex.re` turns `ℂ` into a trivial topological fiber bundle over `ℝ`. -/ theorem isHomeomorphicTrivialFiberBundle_re : IsHomeomorphicTrivialFiberBundle ℝ re := ⟨equivRealProdCLM.toHomeomorph, fun _ => rfl⟩ /-- `Complex.im` turns `ℂ` into a trivial topological fiber bundle over `ℝ`. -/ theorem isHomeomorphicTrivialFiberBundle_im : IsHomeomorphicTrivialFiberBundle ℝ im := ⟨equivRealProdCLM.toHomeomorph.trans (Homeomorph.prodComm ℝ ℝ), fun _ => rfl⟩ theorem isOpenMap_re : IsOpenMap re := isHomeomorphicTrivialFiberBundle_re.isOpenMap_proj theorem isOpenMap_im : IsOpenMap im := isHomeomorphicTrivialFiberBundle_im.isOpenMap_proj theorem isQuotientMap_re : IsQuotientMap re := isHomeomorphicTrivialFiberBundle_re.isQuotientMap_proj theorem isQuotientMap_im : IsQuotientMap im := isHomeomorphicTrivialFiberBundle_im.isQuotientMap_proj theorem interior_preimage_re (s : Set ℝ) : interior (re ⁻¹' s) = re ⁻¹' interior s := (isOpenMap_re.preimage_interior_eq_interior_preimage continuous_re _).symm theorem interior_preimage_im (s : Set ℝ) : interior (im ⁻¹' s) = im ⁻¹' interior s := (isOpenMap_im.preimage_interior_eq_interior_preimage continuous_im _).symm theorem closure_preimage_re (s : Set ℝ) : closure (re ⁻¹' s) = re ⁻¹' closure s := (isOpenMap_re.preimage_closure_eq_closure_preimage continuous_re _).symm theorem closure_preimage_im (s : Set ℝ) : closure (im ⁻¹' s) = im ⁻¹' closure s := (isOpenMap_im.preimage_closure_eq_closure_preimage continuous_im _).symm theorem frontier_preimage_re (s : Set ℝ) : frontier (re ⁻¹' s) = re ⁻¹' frontier s := (isOpenMap_re.preimage_frontier_eq_frontier_preimage continuous_re _).symm theorem frontier_preimage_im (s : Set ℝ) : frontier (im ⁻¹' s) = im ⁻¹' frontier s := (isOpenMap_im.preimage_frontier_eq_frontier_preimage continuous_im _).symm @[simp] theorem interior_setOf_re_le (a : ℝ) : interior { z : ℂ | z.re ≤ a } = { z | z.re < a } := by simpa only [interior_Iic] using interior_preimage_re (Iic a) @[simp] theorem interior_setOf_im_le (a : ℝ) : interior { z : ℂ | z.im ≤ a } = { z | z.im < a } := by simpa only [interior_Iic] using interior_preimage_im (Iic a) @[simp] theorem interior_setOf_le_re (a : ℝ) : interior { z : ℂ | a ≤ z.re } = { z | a < z.re } := by simpa only [interior_Ici] using interior_preimage_re (Ici a) @[simp] theorem interior_setOf_le_im (a : ℝ) : interior { z : ℂ | a ≤ z.im } = { z | a < z.im } := by simpa only [interior_Ici] using interior_preimage_im (Ici a) @[simp] theorem closure_setOf_re_lt (a : ℝ) : closure { z : ℂ | z.re < a } = { z | z.re ≤ a } := by simpa only [closure_Iio] using closure_preimage_re (Iio a) @[simp] theorem closure_setOf_im_lt (a : ℝ) : closure { z : ℂ | z.im < a } = { z | z.im ≤ a } := by simpa only [closure_Iio] using closure_preimage_im (Iio a) @[simp] theorem closure_setOf_lt_re (a : ℝ) : closure { z : ℂ | a < z.re } = { z | a ≤ z.re } := by simpa only [closure_Ioi] using closure_preimage_re (Ioi a) @[simp] theorem closure_setOf_lt_im (a : ℝ) : closure { z : ℂ | a < z.im } = { z | a ≤ z.im } := by simpa only [closure_Ioi] using closure_preimage_im (Ioi a) @[simp] theorem frontier_setOf_re_le (a : ℝ) : frontier { z : ℂ | z.re ≤ a } = { z | z.re = a } := by simpa only [frontier_Iic] using frontier_preimage_re (Iic a) @[simp] theorem frontier_setOf_im_le (a : ℝ) : frontier { z : ℂ | z.im ≤ a } = { z | z.im = a } := by simpa only [frontier_Iic] using frontier_preimage_im (Iic a) @[simp] theorem frontier_setOf_le_re (a : ℝ) : frontier { z : ℂ | a ≤ z.re } = { z | z.re = a } := by simpa only [frontier_Ici] using frontier_preimage_re (Ici a) @[simp] theorem frontier_setOf_le_im (a : ℝ) : frontier { z : ℂ | a ≤ z.im } = { z | z.im = a } := by simpa only [frontier_Ici] using frontier_preimage_im (Ici a) @[simp] theorem frontier_setOf_re_lt (a : ℝ) : frontier { z : ℂ | z.re < a } = { z | z.re = a } := by simpa only [frontier_Iio] using frontier_preimage_re (Iio a) @[simp] theorem frontier_setOf_im_lt (a : ℝ) : frontier { z : ℂ | z.im < a } = { z | z.im = a } := by simpa only [frontier_Iio] using frontier_preimage_im (Iio a) @[simp] theorem frontier_setOf_lt_re (a : ℝ) : frontier { z : ℂ | a < z.re } = { z | z.re = a } := by simpa only [frontier_Ioi] using frontier_preimage_re (Ioi a) @[simp] theorem frontier_setOf_lt_im (a : ℝ) : frontier { z : ℂ | a < z.im } = { z | z.im = a } := by simpa only [frontier_Ioi] using frontier_preimage_im (Ioi a) theorem closure_reProdIm (s t : Set ℝ) : closure (s ×ℂ t) = closure s ×ℂ closure t := by simpa only [← preimage_eq_preimage equivRealProdCLM.symm.toHomeomorph.surjective, equivRealProdCLM.symm.toHomeomorph.preimage_closure] using @closure_prod_eq _ _ _ _ s t theorem interior_reProdIm (s t : Set ℝ) : interior (s ×ℂ t) = interior s ×ℂ interior t := by rw [reProdIm, reProdIm, interior_inter, interior_preimage_re, interior_preimage_im] theorem frontier_reProdIm (s t : Set ℝ) : frontier (s ×ℂ t) = closure s ×ℂ frontier t ∪ frontier s ×ℂ closure t := by simpa only [← preimage_eq_preimage equivRealProdCLM.symm.toHomeomorph.surjective, equivRealProdCLM.symm.toHomeomorph.preimage_frontier] using frontier_prod_eq s t theorem frontier_setOf_le_re_and_le_im (a b : ℝ) : frontier { z | a ≤ re z ∧ b ≤ im z } = { z | a ≤ re z ∧ im z = b ∨ re z = a ∧ b ≤ im z } := by simpa only [closure_Ici, frontier_Ici] using frontier_reProdIm (Ici a) (Ici b) theorem frontier_setOf_le_re_and_im_le (a b : ℝ) : frontier { z | a ≤ re z ∧ im z ≤ b } = { z | a ≤ re z ∧ im z = b ∨ re z = a ∧ im z ≤ b } := by simpa only [closure_Ici, closure_Iic, frontier_Ici, frontier_Iic] using frontier_reProdIm (Ici a) (Iic b) end Complex open Complex Metric variable {s t : Set ℝ} theorem IsOpen.reProdIm (hs : IsOpen s) (ht : IsOpen t) : IsOpen (s ×ℂ t) := (hs.preimage continuous_re).inter (ht.preimage continuous_im) theorem IsClosed.reProdIm (hs : IsClosed s) (ht : IsClosed t) : IsClosed (s ×ℂ t) := (hs.preimage continuous_re).inter (ht.preimage continuous_im) theorem Bornology.IsBounded.reProdIm (hs : IsBounded s) (ht : IsBounded t) : IsBounded (s ×ℂ t) := antilipschitz_equivRealProd.isBounded_preimage (hs.prod ht) section continuity variable {α ι : Type*} protected lemma TendstoUniformlyOn.re {f : ι → α → ℂ} {p : Filter ι} {g : α → ℂ} {K : Set α} (hf : TendstoUniformlyOn f g p K) : TendstoUniformlyOn (fun n x => (f n x).re) (fun y => (g y).re) p K := by apply UniformContinuous.comp_tendstoUniformlyOn uniformlyContinuous_re hf protected lemma TendstoUniformly.re {f : ι → α → ℂ} {p : Filter ι} {g : α → ℂ} (hf : TendstoUniformly f g p) : TendstoUniformly (fun n x => (f n x).re) (fun y => (g y).re) p := by apply UniformContinuous.comp_tendstoUniformly uniformlyContinuous_re hf protected lemma TendstoUniformlyOn.im {f : ι → α → ℂ} {p : Filter ι} {g : α → ℂ} {K : Set α} (hf : TendstoUniformlyOn f g p K) : TendstoUniformlyOn (fun n x => (f n x).im) (fun y => (g y).im) p K := by apply UniformContinuous.comp_tendstoUniformlyOn uniformlyContinuous_im hf protected lemma TendstoUniformly.im {f : ι → α → ℂ} {p : Filter ι} {g : α → ℂ} (hf : TendstoUniformly f g p) : TendstoUniformly (fun n x => (f n x).im) (fun y => (g y).im) p := by apply UniformContinuous.comp_tendstoUniformly uniformlyContinuous_im hf end continuity
.lake/packages/mathlib/Mathlib/Analysis/Complex/Exponential.lean
import Mathlib.Algebra.CharP.Defs import Mathlib.Analysis.Complex.Norm import Mathlib.Algebra.Order.CauSeq.BigOperators import Mathlib.Algebra.Order.Star.Basic import Mathlib.Data.Complex.BigOperators import Mathlib.Data.Nat.Choose.Sum /-! # Exponential Function This file contains the definitions of the real and complex exponential function. ## Main definitions * `Complex.exp`: The complex exponential function, defined via its Taylor series * `Real.exp`: The real exponential function, defined as the real part of the complex exponential -/ open CauSeq Finset IsAbsoluteValue open scoped ComplexConjugate namespace Complex theorem isCauSeq_norm_exp (z : ℂ) : IsCauSeq abs fun n => ∑ m ∈ range n, ‖z ^ m / m.factorial‖ := let ⟨n, hn⟩ := exists_nat_gt ‖z‖ have hn0 : (0 : ℝ) < n := lt_of_le_of_lt (norm_nonneg _) hn IsCauSeq.series_ratio_test n (‖z‖ / n) (div_nonneg (norm_nonneg _) (le_of_lt hn0)) (by rwa [div_lt_iff₀ hn0, one_mul]) fun m hm => by rw [abs_norm, abs_norm, Nat.factorial_succ, pow_succ', mul_comm m.succ, Nat.cast_mul, ← div_div, mul_div_assoc, mul_div_right_comm, Complex.norm_mul, Complex.norm_div, norm_natCast] gcongr exact le_trans hm (Nat.le_succ _) noncomputable section theorem isCauSeq_exp (z : ℂ) : IsCauSeq (‖·‖) fun n => ∑ m ∈ range n, z ^ m / m.factorial := (isCauSeq_norm_exp z).of_abv /-- The Cauchy sequence consisting of partial sums of the Taylor series of the complex exponential function -/ @[pp_nodot] def exp' (z : ℂ) : CauSeq ℂ (‖·‖) := ⟨fun n => ∑ m ∈ range n, z ^ m / m.factorial, isCauSeq_exp z⟩ /-- The complex exponential function, defined via its Taylor series -/ @[pp_nodot] def exp (z : ℂ) : ℂ := CauSeq.lim (exp' z) /-- scoped notation for the complex exponential function -/ scoped notation "cexp" => Complex.exp end end Complex namespace Real open Complex noncomputable section /-- The real exponential function, defined as the real part of the complex exponential -/ @[pp_nodot] nonrec def exp (x : ℝ) : ℝ := (exp x).re /-- scoped notation for the real exponential function -/ scoped notation "rexp" => Real.exp end end Real namespace Complex variable (x y : ℂ) @[simp] theorem exp_zero : exp 0 = 1 := by rw [exp] refine lim_eq_of_equiv_const fun ε ε0 => ⟨1, fun j hj => ?_⟩ convert (config := .unfoldSameFun) ε0 -- ε0 : ε > 0 but goal is _ < ε rcases j with - | j · exact absurd hj (not_le_of_gt zero_lt_one) · dsimp [exp'] induction j with | zero => simp | succ j ih => rw [← ih (by simp)] simp only [sum_range_succ, pow_succ] simp theorem exp_add : exp (x + y) = exp x * exp y := by have hj : ∀ j : ℕ, (∑ m ∈ range j, (x + y) ^ m / m.factorial) = ∑ i ∈ range j, ∑ k ∈ range (i + 1), x ^ k / k.factorial * (y ^ (i - k) / (i - k).factorial) := by intro j refine Finset.sum_congr rfl fun m _ => ?_ rw [add_pow, div_eq_mul_inv, sum_mul] refine Finset.sum_congr rfl fun I hi => ?_ have h₁ : (m.choose I : ℂ) ≠ 0 := Nat.cast_ne_zero.2 (pos_iff_ne_zero.1 (Nat.choose_pos (Nat.le_of_lt_succ (mem_range.1 hi)))) have h₂ := Nat.choose_mul_factorial_mul_factorial (Nat.le_of_lt_succ <| Finset.mem_range.1 hi) rw [← h₂, Nat.cast_mul, Nat.cast_mul, mul_inv, mul_inv] simp only [mul_left_comm (m.choose I : ℂ), mul_assoc, mul_left_comm (m.choose I : ℂ)⁻¹, mul_comm (m.choose I : ℂ)] rw [inv_mul_cancel₀ h₁] simp [div_eq_mul_inv, mul_assoc, mul_left_comm] simp_rw [exp, exp', lim_mul_lim] apply (lim_eq_lim_of_equiv _).symm simp only [hj] exact cauchy_product (isCauSeq_norm_exp x) (isCauSeq_exp y) /-- the exponential function as a monoid hom from `Multiplicative ℂ` to `ℂ` -/ @[simps] noncomputable def expMonoidHom : MonoidHom (Multiplicative ℂ) ℂ := { toFun := fun z => exp z.toAdd, map_one' := by simp, map_mul' := by simp [exp_add] } theorem exp_list_sum (l : List ℂ) : exp l.sum = (l.map exp).prod := map_list_prod (M := Multiplicative ℂ) expMonoidHom l theorem exp_multiset_sum (s : Multiset ℂ) : exp s.sum = (s.map exp).prod := @MonoidHom.map_multiset_prod (Multiplicative ℂ) ℂ _ _ expMonoidHom s theorem exp_sum {α : Type*} (s : Finset α) (f : α → ℂ) : exp (∑ x ∈ s, f x) = ∏ x ∈ s, exp (f x) := map_prod (M := Multiplicative ℂ) expMonoidHom f s lemma exp_nsmul (x : ℂ) (n : ℕ) : exp (n • x) = exp x ^ n := @MonoidHom.map_pow (Multiplicative ℂ) ℂ _ _ expMonoidHom _ _ /-- This is a useful version of `exp_nsmul` for q-expansions of modular forms. -/ lemma exp_nsmul' (x a p : ℂ) (n : ℕ) : exp (a * n * x / p) = exp (a * x / p) ^ n := by rw [← Complex.exp_nsmul] ring_nf theorem exp_nat_mul (x : ℂ) : ∀ n : ℕ, exp (n * x) = exp x ^ n | 0 => by rw [Nat.cast_zero, zero_mul, exp_zero, pow_zero] | Nat.succ n => by rw [pow_succ, Nat.cast_add_one, add_mul, exp_add, ← exp_nat_mul _ n, one_mul] @[simp] theorem exp_ne_zero : exp x ≠ 0 := fun h => zero_ne_one (α := ℂ) <| by rw [← exp_zero, ← add_neg_cancel x, exp_add, h]; simp theorem exp_neg : exp (-x) = (exp x)⁻¹ := by rw [← mul_right_inj' (exp_ne_zero x), ← exp_add]; simp theorem exp_sub : exp (x - y) = exp x / exp y := by simp [sub_eq_add_neg, exp_add, exp_neg, div_eq_mul_inv] theorem exp_int_mul (z : ℂ) (n : ℤ) : Complex.exp (n * z) = Complex.exp z ^ n := by cases n · simp [exp_nat_mul] · simp [exp_add, add_mul, pow_add, exp_neg, exp_nat_mul] @[simp] theorem exp_conj : exp (conj x) = conj (exp x) := by dsimp [exp] rw [← lim_conj] refine congr_arg CauSeq.lim (CauSeq.ext fun _ => ?_) dsimp [exp', Function.comp_def, cauSeqConj] rw [map_sum (starRingEnd _)] refine sum_congr rfl fun n _ => ?_ rw [map_div₀, map_pow, ← ofReal_natCast, conj_ofReal] @[simp] theorem ofReal_exp_ofReal_re (x : ℝ) : ((exp x).re : ℂ) = exp x := conj_eq_iff_re.1 <| by rw [← exp_conj, conj_ofReal] @[simp, norm_cast] theorem ofReal_exp (x : ℝ) : (Real.exp x : ℂ) = exp x := ofReal_exp_ofReal_re _ @[simp] theorem exp_ofReal_im (x : ℝ) : (exp x).im = 0 := by rw [← ofReal_exp_ofReal_re, ofReal_im] theorem exp_ofReal_re (x : ℝ) : (exp x).re = Real.exp x := rfl end Complex namespace Real open Complex variable (x y : ℝ) @[simp] theorem exp_zero : exp 0 = 1 := by simp [Real.exp] nonrec theorem exp_add : exp (x + y) = exp x * exp y := by simp [exp_add, exp] /-- the exponential function as a monoid hom from `Multiplicative ℝ` to `ℝ` -/ @[simps] noncomputable def expMonoidHom : MonoidHom (Multiplicative ℝ) ℝ := { toFun := fun x => exp x.toAdd, map_one' := by simp, map_mul' := by simp [exp_add] } theorem exp_list_sum (l : List ℝ) : exp l.sum = (l.map exp).prod := map_list_prod (M := Multiplicative ℝ) expMonoidHom l theorem exp_multiset_sum (s : Multiset ℝ) : exp s.sum = (s.map exp).prod := @MonoidHom.map_multiset_prod (Multiplicative ℝ) ℝ _ _ expMonoidHom s theorem exp_sum {α : Type*} (s : Finset α) (f : α → ℝ) : exp (∑ x ∈ s, f x) = ∏ x ∈ s, exp (f x) := map_prod (M := Multiplicative ℝ) expMonoidHom f s lemma exp_nsmul (x : ℝ) (n : ℕ) : exp (n • x) = exp x ^ n := @MonoidHom.map_pow (Multiplicative ℝ) ℝ _ _ expMonoidHom _ _ nonrec theorem exp_nat_mul (x : ℝ) (n : ℕ) : exp (n * x) = exp x ^ n := ofReal_injective (by simp [exp_nat_mul]) @[simp] nonrec theorem exp_ne_zero : exp x ≠ 0 := fun h => exp_ne_zero x <| by rw [exp, ← ofReal_inj] at h; simp_all nonrec theorem exp_neg : exp (-x) = (exp x)⁻¹ := ofReal_injective <| by simp [exp_neg] theorem exp_sub : exp (x - y) = exp x / exp y := by simp [sub_eq_add_neg, exp_add, exp_neg, div_eq_mul_inv] open IsAbsoluteValue Nat theorem sum_le_exp_of_nonneg {x : ℝ} (hx : 0 ≤ x) (n : ℕ) : ∑ i ∈ range n, x ^ i / i ! ≤ exp x := calc ∑ i ∈ range n, x ^ i / i ! ≤ lim (⟨_, isCauSeq_re (exp' x)⟩ : CauSeq ℝ abs) := by refine le_lim (CauSeq.le_of_exists ⟨n, fun j hj => ?_⟩) simp only [exp', const_apply, re_sum] norm_cast refine sum_le_sum_of_subset_of_nonneg (range_mono hj) fun _ _ _ ↦ ?_ positivity _ = exp x := by rw [exp, Complex.exp, ← cauSeqRe, lim_re] lemma pow_div_factorial_le_exp (hx : 0 ≤ x) (n : ℕ) : x ^ n / n ! ≤ exp x := calc x ^ n / n ! ≤ ∑ k ∈ range (n + 1), x ^ k / k ! := single_le_sum (f := fun k ↦ x ^ k / k !) (fun k _ ↦ by positivity) (self_mem_range_succ n) _ ≤ exp x := sum_le_exp_of_nonneg hx _ theorem quadratic_le_exp_of_nonneg {x : ℝ} (hx : 0 ≤ x) : 1 + x + x ^ 2 / 2 ≤ exp x := calc 1 + x + x ^ 2 / 2 = ∑ i ∈ range 3, x ^ i / i ! := by simp only [sum_range_succ, range_one, sum_singleton, _root_.pow_zero, factorial, pow_one, mul_one, Nat.mul_one, cast_succ] ring_nf _ ≤ exp x := sum_le_exp_of_nonneg hx 3 private theorem add_one_lt_exp_of_pos {x : ℝ} (hx : 0 < x) : x + 1 < exp x := (by nlinarith : x + 1 < 1 + x + x ^ 2 / 2).trans_le (quadratic_le_exp_of_nonneg hx.le) private theorem add_one_le_exp_of_nonneg {x : ℝ} (hx : 0 ≤ x) : x + 1 ≤ exp x := by rcases eq_or_lt_of_le hx with (rfl | h) · simp exact (add_one_lt_exp_of_pos h).le theorem one_le_exp {x : ℝ} (hx : 0 ≤ x) : 1 ≤ exp x := by linarith [add_one_le_exp_of_nonneg hx] @[bound] theorem exp_pos (x : ℝ) : 0 < exp x := (le_total 0 x).elim (lt_of_lt_of_le zero_lt_one ∘ one_le_exp) fun h => by rw [← neg_neg x, Real.exp_neg] exact inv_pos.2 (lt_of_lt_of_le zero_lt_one (one_le_exp (neg_nonneg.2 h))) @[bound] lemma exp_nonneg (x : ℝ) : 0 ≤ exp x := x.exp_pos.le @[simp] theorem abs_exp (x : ℝ) : |exp x| = exp x := abs_of_pos (exp_pos _) lemma exp_abs_le (x : ℝ) : exp |x| ≤ exp x + exp (-x) := by cases le_total x 0 <;> simp [abs_of_nonpos, abs_of_nonneg, exp_nonneg, *] @[mono, gcongr] theorem exp_strictMono : StrictMono exp := fun x y h => by rw [← sub_add_cancel y x, Real.exp_add] exact (lt_mul_iff_one_lt_left (exp_pos _)).2 (lt_of_lt_of_le (by linarith) (add_one_le_exp_of_nonneg (by linarith))) @[deprecated exp_strictMono (since := "2025-10-20")] theorem exp_lt_exp_of_lt {x y : ℝ} (h : x < y) : exp x < exp y := exp_strictMono h @[gcongr, mono] theorem exp_monotone : Monotone exp := exp_strictMono.monotone @[bound] -- temporary lemma for the `bound` tactic theorem exp_le_exp_of_le {x y : ℝ} (h : x ≤ y) : exp x ≤ exp y := exp_monotone h @[simp] theorem exp_lt_exp {x y : ℝ} : exp x < exp y ↔ x < y := exp_strictMono.lt_iff_lt @[simp] theorem exp_le_exp {x y : ℝ} : exp x ≤ exp y ↔ x ≤ y := exp_strictMono.le_iff_le theorem exp_injective : Function.Injective exp := exp_strictMono.injective @[simp] theorem exp_eq_exp {x y : ℝ} : exp x = exp y ↔ x = y := exp_injective.eq_iff @[simp] theorem exp_eq_one_iff : exp x = 1 ↔ x = 0 := exp_injective.eq_iff' exp_zero @[simp] theorem one_lt_exp_iff {x : ℝ} : 1 < exp x ↔ 0 < x := by rw [← exp_zero, exp_lt_exp] @[bound] private alias ⟨_, Bound.one_lt_exp_of_pos⟩ := one_lt_exp_iff @[simp] theorem exp_lt_one_iff {x : ℝ} : exp x < 1 ↔ x < 0 := by rw [← exp_zero, exp_lt_exp] @[simp] theorem exp_le_one_iff {x : ℝ} : exp x ≤ 1 ↔ x ≤ 0 := exp_zero ▸ exp_le_exp @[simp] theorem one_le_exp_iff {x : ℝ} : 1 ≤ exp x ↔ 0 ≤ x := exp_zero ▸ exp_le_exp end Real namespace Complex theorem sum_div_factorial_le {α : Type*} [Field α] [LinearOrder α] [IsStrictOrderedRing α] (n j : ℕ) (hn : 0 < n) : (∑ m ∈ range j with n ≤ m, (1 / m.factorial : α)) ≤ n.succ / (n.factorial * n) := calc (∑ m ∈ range j with n ≤ m, (1 / m.factorial : α)) = ∑ m ∈ range (j - n), (1 / ((m + n).factorial : α)) := by refine sum_nbij' (· - n) (· + n) ?_ ?_ ?_ ?_ ?_ <;> simp +contextual [lt_tsub_iff_right, tsub_add_cancel_of_le] _ ≤ ∑ m ∈ range (j - n), ((n.factorial : α) * (n.succ : α) ^ m)⁻¹ := by simp_rw [one_div] gcongr rw [← Nat.cast_pow, ← Nat.cast_mul, Nat.cast_le, add_comm] exact Nat.factorial_mul_pow_le_factorial _ = (n.factorial : α)⁻¹ * ∑ m ∈ range (j - n), (n.succ : α)⁻¹ ^ m := by simp [← mul_sum, mul_comm, inv_pow] _ = ((n.succ : α) - n.succ * (n.succ : α)⁻¹ ^ (j - n)) / (n.factorial * n) := by have h₁ : (n.succ : α) ≠ 1 := @Nat.cast_one α _ ▸ mt Nat.cast_inj.1 (mt Nat.succ.inj (pos_iff_ne_zero.1 hn)) have h₂ : (n.succ : α) ≠ 0 := by positivity have h₃ : (n.factorial * n : α) ≠ 0 := by positivity have h₄ : (n.succ - 1 : α) = n := by simp rw [geom_sum_inv h₁ h₂, eq_div_iff_mul_eq h₃, mul_comm _ (n.factorial * n : α), ← mul_assoc (n.factorial⁻¹ : α), ← mul_inv_rev, h₄, ← mul_assoc (n.factorial * n : α), mul_comm (n : α) n.factorial, mul_inv_cancel₀ h₃, one_mul, mul_comm] _ ≤ n.succ / (n.factorial * n : α) := by gcongr; apply sub_le_self; positivity theorem exp_bound {x : ℂ} (hx : ‖x‖ ≤ 1) {n : ℕ} (hn : 0 < n) : ‖exp x - ∑ m ∈ range n, x ^ m / m.factorial‖ ≤ ‖x‖ ^ n * ((n.succ : ℝ) * (n.factorial * n : ℝ)⁻¹) := by rw [← lim_const (abv := norm) (∑ m ∈ range n, _), exp, sub_eq_add_neg, ← lim_neg, lim_add, ← lim_norm] refine lim_le (CauSeq.le_of_exists ⟨n, fun j hj => ?_⟩) simp_rw [← sub_eq_add_neg] change ‖(∑ m ∈ range j, x ^ m / m.factorial) - ∑ m ∈ range n, x ^ m / m.factorial‖ ≤ ‖x‖ ^ n * ((n.succ : ℝ) * (n.factorial * n : ℝ)⁻¹) rw [sum_range_sub_sum_range hj] calc ‖∑ m ∈ range j with n ≤ m, (x ^ m / m.factorial : ℂ)‖ = ‖∑ m ∈ range j with n ≤ m, (x ^ n * (x ^ (m - n) / m.factorial) : ℂ)‖ := by refine congr_arg norm (sum_congr rfl fun m hm => ?_) rw [mem_filter, mem_range] at hm rw [← mul_div_assoc, ← pow_add, add_tsub_cancel_of_le hm.2] _ ≤ ∑ m ∈ range j with n ≤ m, ‖x ^ n * (x ^ (m - n) / m.factorial)‖ := IsAbsoluteValue.abv_sum norm .. _ ≤ ∑ m ∈ range j with n ≤ m, ‖x‖ ^ n * (1 / m.factorial) := by simp_rw [Complex.norm_mul, Complex.norm_pow, Complex.norm_div, norm_natCast] gcongr rw [Complex.norm_pow] exact pow_le_one₀ (norm_nonneg _) hx _ = ‖x‖ ^ n * ∑ m ∈ range j with n ≤ m, (1 / m.factorial : ℝ) := by simp [← mul_sum] _ ≤ ‖x‖ ^ n * (n.succ * (n.factorial * n : ℝ)⁻¹) := by gcongr exact sum_div_factorial_le _ _ hn theorem exp_bound' {x : ℂ} {n : ℕ} (hx : ‖x‖ / n.succ ≤ 1 / 2) : ‖exp x - ∑ m ∈ range n, x ^ m / m.factorial‖ ≤ ‖x‖ ^ n / n.factorial * 2 := by rw [← lim_const (abv := norm) (∑ m ∈ range n, _), exp, sub_eq_add_neg, ← lim_neg, lim_add, ← lim_norm] refine lim_le (CauSeq.le_of_exists ⟨n, fun j hj => ?_⟩) simp_rw [← sub_eq_add_neg] change ‖(∑ m ∈ range j, x ^ m / m.factorial) - ∑ m ∈ range n, x ^ m / m.factorial‖ ≤ ‖x‖ ^ n / n.factorial * 2 let k := j - n have hj : j = n + k := (add_tsub_cancel_of_le hj).symm rw [hj, sum_range_add_sub_sum_range] calc ‖∑ i ∈ range k, x ^ (n + i) / ((n + i).factorial : ℂ)‖ ≤ ∑ i ∈ range k, ‖x ^ (n + i) / ((n + i).factorial : ℂ)‖ := IsAbsoluteValue.abv_sum _ _ _ _ ≤ ∑ i ∈ range k, ‖x‖ ^ (n + i) / (n + i).factorial := by simp [norm_natCast, Complex.norm_pow] _ ≤ ∑ i ∈ range k, ‖x‖ ^ (n + i) / ((n.factorial : ℝ) * (n.succ : ℝ) ^ i) := ?_ _ = ∑ i ∈ range k, ‖x‖ ^ n / n.factorial * (‖x‖ ^ i / (n.succ : ℝ) ^ i) := ?_ _ ≤ ‖x‖ ^ n / ↑n.factorial * 2 := ?_ · gcongr exact mod_cast Nat.factorial_mul_pow_le_factorial · simp only [pow_add, div_eq_inv_mul, mul_inv, mul_left_comm, mul_assoc] · rw [← mul_sum] gcongr simp_rw [← div_pow] rw [geom_sum_eq, div_le_iff_of_neg] · trans (-1 : ℝ) · linarith · simp only [neg_le_sub_iff_le_add, div_pow, Nat.cast_succ, le_add_iff_nonneg_left] positivity · linarith · linarith theorem norm_exp_sub_one_le {x : ℂ} (hx : ‖x‖ ≤ 1) : ‖exp x - 1‖ ≤ 2 * ‖x‖ := calc ‖exp x - 1‖ = ‖exp x - ∑ m ∈ range 1, x ^ m / m.factorial‖ := by simp _ ≤ ‖x‖ ^ 1 * ((Nat.succ 1 : ℝ) * ((Nat.factorial 1) * (1 : ℕ) : ℝ)⁻¹) := (exp_bound hx (by decide)) _ = 2 * ‖x‖ := by simp [mul_two, mul_add, mul_comm, Nat.factorial] theorem norm_exp_sub_one_sub_id_le {x : ℂ} (hx : ‖x‖ ≤ 1) : ‖exp x - 1 - x‖ ≤ ‖x‖ ^ 2 := calc ‖exp x - 1 - x‖ = ‖exp x - ∑ m ∈ range 2, x ^ m / m.factorial‖ := by simp [sub_eq_add_neg, sum_range_succ_comm, add_assoc, Nat.factorial] _ ≤ ‖x‖ ^ 2 * ((Nat.succ 2 : ℝ) * (Nat.factorial 2 * (2 : ℕ) : ℝ)⁻¹) := (exp_bound hx (by decide)) _ ≤ ‖x‖ ^ 2 * 1 := by gcongr; norm_num [Nat.factorial] _ = ‖x‖ ^ 2 := by rw [mul_one] lemma norm_exp_sub_sum_le_exp_norm_sub_sum (x : ℂ) (n : ℕ) : ‖exp x - ∑ m ∈ range n, x ^ m / m.factorial‖ ≤ Real.exp ‖x‖ - ∑ m ∈ range n, ‖x‖ ^ m / m.factorial := by rw [← CauSeq.lim_const (abv := norm) (∑ m ∈ range n, _), Complex.exp, sub_eq_add_neg, ← CauSeq.lim_neg, CauSeq.lim_add, ← lim_norm] refine CauSeq.lim_le (CauSeq.le_of_exists ⟨n, fun j hj => ?_⟩) simp_rw [← sub_eq_add_neg] calc ‖(∑ m ∈ range j, x ^ m / m.factorial) - ∑ m ∈ range n, x ^ m / m.factorial‖ _ ≤ (∑ m ∈ range j, ‖x‖ ^ m / m.factorial) - ∑ m ∈ range n, ‖x‖ ^ m / m.factorial := by rw [sum_range_sub_sum_range hj, sum_range_sub_sum_range hj] refine (IsAbsoluteValue.abv_sum norm ..).trans_eq ?_ congr with i simp [Complex.norm_pow, Complex.norm_natCast] _ ≤ Real.exp ‖x‖ - ∑ m ∈ range n, ‖x‖ ^ m / m.factorial := by gcongr exact Real.sum_le_exp_of_nonneg (norm_nonneg _) _ lemma norm_exp_le_exp_norm (x : ℂ) : ‖exp x‖ ≤ Real.exp ‖x‖ := by convert norm_exp_sub_sum_le_exp_norm_sub_sum x 0 using 1 <;> simp lemma norm_exp_sub_sum_le_norm_mul_exp (x : ℂ) (n : ℕ) : ‖exp x - ∑ m ∈ range n, x ^ m / m.factorial‖ ≤ ‖x‖ ^ n * Real.exp ‖x‖ := by rw [← CauSeq.lim_const (abv := norm) (∑ m ∈ range n, _), Complex.exp, sub_eq_add_neg, ← CauSeq.lim_neg, CauSeq.lim_add, ← lim_norm] refine CauSeq.lim_le (CauSeq.le_of_exists ⟨n, fun j hj => ?_⟩) simp_rw [← sub_eq_add_neg] change ‖(∑ m ∈ range j, x ^ m / m.factorial) - ∑ m ∈ range n, x ^ m / m.factorial‖ ≤ _ rw [sum_range_sub_sum_range hj] calc ‖∑ m ∈ range j with n ≤ m, (x ^ m / m.factorial : ℂ)‖ = ‖∑ m ∈ range j with n ≤ m, (x ^ n * (x ^ (m - n) / m.factorial) : ℂ)‖ := by refine congr_arg norm (sum_congr rfl fun m hm => ?_) rw [mem_filter, mem_range] at hm rw [← mul_div_assoc, ← pow_add, add_tsub_cancel_of_le hm.2] _ ≤ ∑ m ∈ range j with n ≤ m, ‖x ^ n * (x ^ (m - n) / m.factorial)‖ := IsAbsoluteValue.abv_sum norm .. _ ≤ ∑ m ∈ range j with n ≤ m, ‖x‖ ^ n * (‖x‖ ^ (m - n) / (m - n).factorial) := by simp_rw [Complex.norm_mul, Complex.norm_pow, Complex.norm_div, norm_natCast] gcongr with i hi · rw [Complex.norm_pow] · simp _ = ‖x‖ ^ n * ∑ m ∈ range j with n ≤ m, (‖x‖ ^ (m - n) / (m - n).factorial) := by rw [← mul_sum] _ = ‖x‖ ^ n * ∑ m ∈ range (j - n), (‖x‖ ^ m / m.factorial) := by congr 1 refine (sum_bij (fun m hm ↦ m + n) ?_ ?_ ?_ ?_).symm · grind · intro a ha b hb hab simpa using hab · intro b hb simp only [mem_range, exists_prop] simp only [mem_filter, mem_range] at hb refine ⟨b - n, ?_, ?_⟩ · rw [tsub_lt_tsub_iff_right hb.2] exact hb.1 · rw [tsub_add_cancel_of_le hb.2] · simp _ ≤ ‖x‖ ^ n * Real.exp ‖x‖ := by gcongr refine Real.sum_le_exp_of_nonneg ?_ _ exact norm_nonneg _ end Complex namespace Real open Complex Finset nonrec theorem exp_bound {x : ℝ} (hx : |x| ≤ 1) {n : ℕ} (hn : 0 < n) : |exp x - ∑ m ∈ range n, x ^ m / m.factorial| ≤ |x| ^ n * (n.succ / (n.factorial * n)) := by have hxc : ‖(x : ℂ)‖ ≤ 1 := mod_cast hx convert exp_bound hxc hn using 2 <;> norm_cast theorem exp_bound' {x : ℝ} (h1 : 0 ≤ x) (h2 : x ≤ 1) {n : ℕ} (hn : 0 < n) : Real.exp x ≤ (∑ m ∈ Finset.range n, x ^ m / m.factorial) + x ^ n * (n + 1) / (n.factorial * n) := by have h3 : |x| = x := by simpa have h4 : |x| ≤ 1 := by rwa [h3] have h' := Real.exp_bound h4 hn rw [h3] at h' have h'' := (abs_sub_le_iff.1 h').1 have t := sub_le_iff_le_add'.1 h'' simpa [mul_div_assoc] using t theorem abs_exp_sub_one_le {x : ℝ} (hx : |x| ≤ 1) : |exp x - 1| ≤ 2 * |x| := by have : ‖(x : ℂ)‖ ≤ 1 := mod_cast hx exact_mod_cast Complex.norm_exp_sub_one_le (x := x) this theorem abs_exp_sub_one_sub_id_le {x : ℝ} (hx : |x| ≤ 1) : |exp x - 1 - x| ≤ x ^ 2 := by rw [← sq_abs] have : ‖(x : ℂ)‖ ≤ 1 := mod_cast hx exact_mod_cast Complex.norm_exp_sub_one_sub_id_le this /-- A finite initial segment of the exponential series, followed by an arbitrary tail. For fixed `n` this is just a linear map w.r.t. `r`, and each map is a simple linear function of the previous (see `expNear_succ`), with `expNear n x r ⟶ exp x` as `n ⟶ ∞`, for any `r`. -/ noncomputable def expNear (n : ℕ) (x r : ℝ) : ℝ := (∑ m ∈ range n, x ^ m / m.factorial) + x ^ n / n.factorial * r @[simp] theorem expNear_zero (x r) : expNear 0 x r = r := by simp [expNear] @[simp] theorem expNear_succ (n x r) : expNear (n + 1) x r = expNear n x (1 + x / (n + 1) * r) := by simp [expNear, range_add_one, mul_add, add_left_comm, add_assoc, pow_succ, div_eq_mul_inv, Nat.factorial] ac_rfl theorem expNear_sub (n x r₁ r₂) : expNear n x r₁ - expNear n x r₂ = x ^ n / n.factorial * (r₁ - r₂) := by simp [expNear, mul_sub] theorem exp_approx_end (n m : ℕ) (x : ℝ) (e₁ : n + 1 = m) (h : |x| ≤ 1) : |exp x - expNear m x 0| ≤ |x| ^ m / m.factorial * ((m + 1) / m) := by simp only [expNear, mul_zero, add_zero] convert exp_bound (n := m) h ?_ using 1 · simp [field] · cutsat theorem exp_approx_succ {n} {x a₁ b₁ : ℝ} (m : ℕ) (e₁ : n + 1 = m) (a₂ b₂ : ℝ) (e : |1 + x / m * a₂ - a₁| ≤ b₁ - |x| / m * b₂) (h : |exp x - expNear m x a₂| ≤ |x| ^ m / m.factorial * b₂) : |exp x - expNear n x a₁| ≤ |x| ^ n / n.factorial * b₁ := by grw [abs_sub_le, h] subst e₁; rw [expNear_succ, expNear_sub, abs_mul] convert mul_le_mul_of_nonneg_left (a := |x| ^ n / ↑(Nat.factorial n)) (le_sub_iff_add_le'.1 e) ?_ using 1 · simp [mul_add, pow_succ', div_eq_mul_inv, abs_mul, abs_inv, Nat.factorial] ac_rfl · simp [div_nonneg, abs_nonneg] theorem exp_approx_end' {n} {x a b : ℝ} (m : ℕ) (e₁ : n + 1 = m) (rm : ℝ) (er : ↑m = rm) (h : |x| ≤ 1) (e : |1 - a| ≤ b - |x| / rm * ((rm + 1) / rm)) : |exp x - expNear n x a| ≤ |x| ^ n / n.factorial * b := by subst er exact exp_approx_succ _ e₁ _ _ (by simpa using e) (exp_approx_end _ _ _ e₁ h) theorem exp_1_approx_succ_eq {n} {a₁ b₁ : ℝ} {m : ℕ} (en : n + 1 = m) {rm : ℝ} (er : ↑m = rm) (h : |exp 1 - expNear m 1 ((a₁ - 1) * rm)| ≤ |1| ^ m / m.factorial * (b₁ * rm)) : |exp 1 - expNear n 1 a₁| ≤ |1| ^ n / n.factorial * b₁ := by subst er refine exp_approx_succ _ en _ _ ?_ h simp field_simp [show (m : ℝ) ≠ 0 by norm_cast; cutsat] simp theorem exp_approx_start (x a b : ℝ) (h : |exp x - expNear 0 x a| ≤ |x| ^ 0 / Nat.factorial 0 * b) : |exp x - a| ≤ b := by simpa using h theorem exp_bound_div_one_sub_of_interval' {x : ℝ} (h1 : 0 < x) (h2 : x < 1) : Real.exp x < 1 / (1 - x) := by have H : 0 < 1 - (1 + x + x ^ 2) * (1 - x) := calc 0 < x ^ 3 := by positivity _ = 1 - (1 + x + x ^ 2) * (1 - x) := by ring calc exp x ≤ _ := exp_bound' h1.le h2.le zero_lt_three _ ≤ 1 + x + x ^ 2 := by -- Porting note: was `norm_num [Finset.sum] <;> nlinarith` -- This proof should be restored after the norm_num plugin for big operators is ported. -- (It may also need the positivity extensions in https://github.com/leanprover-community/mathlib4/pull/3907.) rw [show 3 = 1 + 1 + 1 from rfl] repeat rw [Finset.sum_range_succ] norm_num [Nat.factorial] nlinarith _ < 1 / (1 - x) := by rw [lt_div_iff₀] <;> nlinarith theorem exp_bound_div_one_sub_of_interval {x : ℝ} (h1 : 0 ≤ x) (h2 : x < 1) : Real.exp x ≤ 1 / (1 - x) := by rcases eq_or_lt_of_le h1 with (rfl | h1) · simp · exact (exp_bound_div_one_sub_of_interval' h1 h2).le theorem add_one_lt_exp {x : ℝ} (hx : x ≠ 0) : x + 1 < Real.exp x := by obtain hx | hx := hx.symm.lt_or_gt · exact add_one_lt_exp_of_pos hx obtain h' | h' := le_or_gt 1 (-x) · linarith [x.exp_pos] have hx' : 0 < x + 1 := by linarith simpa [add_comm, exp_neg, inv_lt_inv₀ (exp_pos _) hx'] using exp_bound_div_one_sub_of_interval' (neg_pos.2 hx) h' theorem add_one_le_exp (x : ℝ) : x + 1 ≤ Real.exp x := by obtain rfl | hx := eq_or_ne x 0 · simp · exact (add_one_lt_exp hx).le lemma one_sub_lt_exp_neg {x : ℝ} (hx : x ≠ 0) : 1 - x < exp (-x) := (sub_eq_neg_add _ _).trans_lt <| add_one_lt_exp <| neg_ne_zero.2 hx lemma one_sub_le_exp_neg (x : ℝ) : 1 - x ≤ exp (-x) := (sub_eq_neg_add _ _).trans_le <| add_one_le_exp _ theorem one_sub_div_pow_le_exp_neg {n : ℕ} {t : ℝ} (ht' : t ≤ n) : (1 - t / n) ^ n ≤ exp (-t) := by rcases eq_or_ne n 0 with (rfl | hn) · simp rwa [Nat.cast_zero] at ht' calc (1 - t / n) ^ n ≤ rexp (-(t / n)) ^ n := by gcongr · exact sub_nonneg.2 <| div_le_one_of_le₀ ht' n.cast_nonneg · exact one_sub_le_exp_neg _ _ = rexp (-t) := by rw [← Real.exp_nat_mul, mul_neg, mul_comm, div_mul_cancel₀]; positivity lemma le_inv_mul_exp (x : ℝ) {c : ℝ} (hc : 0 < c) : x ≤ c⁻¹ * exp (c * x) := by rw [le_inv_mul_iff₀ hc] calc c * x _ ≤ c * x + 1 := le_add_of_nonneg_right zero_le_one _ ≤ _ := Real.add_one_le_exp (c * x) end Real namespace Mathlib.Meta.Positivity open Lean.Meta Qq /-- Extension for the `positivity` tactic: `Real.exp` is always positive. -/ @[positivity Real.exp _] def evalExp : PositivityExt where eval {u α} _ _ e := do match u, α, e with | 0, ~q(ℝ), ~q(Real.exp $a) => assertInstancesCommute pure (.positive q(Real.exp_pos $a)) | _, _, _ => throwError "not Real.exp" end Mathlib.Meta.Positivity namespace Complex @[simp] theorem norm_exp_ofReal (x : ℝ) : ‖exp x‖ = Real.exp x := by rw [← ofReal_exp] exact Complex.norm_of_nonneg (le_of_lt (Real.exp_pos _)) end Complex
.lake/packages/mathlib/Mathlib/Analysis/Complex/Order.lean
import Mathlib.Analysis.Complex.Norm /-! # The partial order on the complex numbers This order is defined by `z ≤ w ↔ z.re ≤ w.re ∧ z.im = w.im`. This is a natural order on `ℂ` because, as is well-known, there does not exist an order on `ℂ` making it into a `LinearOrderedField`. However, the order described above is the canonical order stemming from the structure of `ℂ` as a ⋆-ring (i.e., it becomes a `StarOrderedRing`). Moreover, with this order `ℂ` is a `StrictOrderedCommRing` and the coercion `(↑) : ℝ → ℂ` is an order embedding. This file only provides `Complex.partialOrder` and lemmas about it. Further structural classes are provided in `Mathlib/Analysis/RCLike/Basic.lean` as * `RCLike.toStrictOrderedCommRing` * `RCLike.toStarOrderedRing` * `RCLike.toOrderedSMul` These are all only available with `open scoped ComplexOrder`. -/ namespace Complex /-- We put a partial order on ℂ so that `z ≤ w` exactly if `w - z` is real and nonnegative. Complex numbers with different imaginary parts are incomparable. -/ protected def partialOrder : PartialOrder ℂ where le z w := z.re ≤ w.re ∧ z.im = w.im lt z w := z.re < w.re ∧ z.im = w.im lt_iff_le_not_ge z w := by rw [lt_iff_le_not_ge] tauto le_refl _ := ⟨le_rfl, rfl⟩ le_trans _ _ _ h₁ h₂ := ⟨h₁.1.trans h₂.1, h₁.2.trans h₂.2⟩ le_antisymm _ _ h₁ h₂ := ext (h₁.1.antisymm h₂.1) h₁.2 namespace _root_.ComplexOrder scoped[ComplexOrder] attribute [instance] Complex.partialOrder end _root_.ComplexOrder open ComplexOrder theorem le_def {z w : ℂ} : z ≤ w ↔ z.re ≤ w.re ∧ z.im = w.im := Iff.rfl theorem lt_def {z w : ℂ} : z < w ↔ z.re < w.re ∧ z.im = w.im := Iff.rfl theorem nonneg_iff {z : ℂ} : 0 ≤ z ↔ 0 ≤ z.re ∧ 0 = z.im := le_def theorem pos_iff {z : ℂ} : 0 < z ↔ 0 < z.re ∧ 0 = z.im := lt_def theorem nonpos_iff {z : ℂ} : z ≤ 0 ↔ z.re ≤ 0 ∧ z.im = 0 := le_def theorem neg_iff {z : ℂ} : z < 0 ↔ z.re < 0 ∧ z.im = 0 := lt_def @[simp, norm_cast] theorem real_le_real {x y : ℝ} : (x : ℂ) ≤ (y : ℂ) ↔ x ≤ y := by simp [le_def, ofReal] @[simp, norm_cast] theorem real_lt_real {x y : ℝ} : (x : ℂ) < (y : ℂ) ↔ x < y := by simp [lt_def, ofReal] @[simp, norm_cast] theorem zero_le_real {x : ℝ} : (0 : ℂ) ≤ (x : ℂ) ↔ 0 ≤ x := real_le_real @[simp, norm_cast] theorem zero_lt_real {x : ℝ} : (0 : ℂ) < (x : ℂ) ↔ 0 < x := real_lt_real theorem not_le_iff {z w : ℂ} : ¬z ≤ w ↔ w.re < z.re ∨ z.im ≠ w.im := by rw [le_def, not_and_or, not_le] theorem not_lt_iff {z w : ℂ} : ¬z < w ↔ w.re ≤ z.re ∨ z.im ≠ w.im := by rw [lt_def, not_and_or, not_lt] theorem not_le_zero_iff {z : ℂ} : ¬z ≤ 0 ↔ 0 < z.re ∨ z.im ≠ 0 := not_le_iff theorem not_lt_zero_iff {z : ℂ} : ¬z < 0 ↔ 0 ≤ z.re ∨ z.im ≠ 0 := not_lt_iff theorem eq_re_of_ofReal_le {r : ℝ} {z : ℂ} (hz : (r : ℂ) ≤ z) : z = z.re := by rw [eq_comm, ← conj_eq_iff_re, conj_eq_iff_im, ← (Complex.le_def.1 hz).2, Complex.ofReal_im] @[simp] lemma re_eq_norm {z : ℂ} : z.re = ‖z‖ ↔ 0 ≤ z := have : 0 ≤ ‖z‖ := norm_nonneg z ⟨fun h ↦ ⟨h.symm ▸ this, (abs_re_eq_norm.1 <| h.symm ▸ abs_of_nonneg this).symm⟩, fun ⟨h₁, h₂⟩ ↦ by rw [← abs_re_eq_norm.2 h₂.symm, abs_of_nonneg h₁]⟩ @[simp] lemma neg_re_eq_norm {z : ℂ} : -z.re = ‖z‖ ↔ z ≤ 0 := by rw [← neg_re, ← norm_neg z, re_eq_norm] exact neg_nonneg.and <| eq_comm.trans neg_eq_zero @[simp] lemma re_eq_neg_norm {z : ℂ} : z.re = -‖z‖ ↔ z ≤ 0 := by rw [← neg_eq_iff_eq_neg, neg_re_eq_norm] lemma monotone_ofReal : Monotone ofReal := by intro x y hxy simp only [real_le_real, hxy] end Complex namespace Mathlib.Meta.Positivity open Lean Meta Qq Complex open scoped ComplexOrder private alias ⟨_, ofReal_pos⟩ := zero_lt_real private alias ⟨_, ofReal_nonneg⟩ := zero_le_real private alias ⟨_, ofReal_ne_zero_of_ne_zero⟩ := ofReal_ne_zero /-- Extension for the `positivity` tactic: `Complex.ofReal` is positive/nonnegative/nonzero if its input is. -/ @[positivity Complex.ofReal _, Complex.ofReal _] def evalComplexOfReal : PositivityExt where eval {u α} _ _ e := do -- TODO: Can we avoid duplicating the code? match u, α, e with | 0, ~q(ℂ), ~q(Complex.ofReal $a) => assumeInstancesCommute match ← core q(inferInstance) q(inferInstance) a with | .positive pa => return .positive q(ofReal_pos $pa) | .nonnegative pa => return .nonnegative q(ofReal_nonneg $pa) | .nonzero pa => return .nonzero q(ofReal_ne_zero_of_ne_zero $pa) | _ => return .none | 0, ~q(ℂ), ~q(Complex.ofReal $a) => assumeInstancesCommute match ← core q(inferInstance) q(inferInstance) a with | .positive pa => return .positive q(ofReal_pos $pa) | .nonnegative pa => return .nonnegative q(ofReal_nonneg $pa) | .nonzero pa => return .nonzero q(ofReal_ne_zero_of_ne_zero $pa) | _ => return .none | _, _ => throwError "not Complex.ofReal" example (x : ℝ) (hx : 0 < x) : 0 < (x : ℂ) := by positivity example (x : ℝ) (hx : 0 ≤ x) : 0 ≤ (x : ℂ) := by positivity example (x : ℝ) (hx : x ≠ 0) : (x : ℂ) ≠ 0 := by positivity end Mathlib.Meta.Positivity
.lake/packages/mathlib/Mathlib/Analysis/Complex/Arg.lean
import Mathlib.Analysis.InnerProductSpace.Convex import Mathlib.Analysis.SpecialFunctions.Complex.Arg /-! # Rays in the complex numbers This file links the definition `SameRay ℝ x y` with the equality of arguments of complex numbers, the usual way this is considered. ## Main statements * `Complex.sameRay_iff` : Two complex numbers are on the same ray iff one of them is zero, or they have the same argument. * `Complex.abs_add_eq/Complex.abs_sub_eq`: If two nonzero complex numbers have the same argument, then the triangle inequality is an equality. -/ variable {x y : ℂ} namespace Complex -- see https://github.com/leanprover-community/mathlib4/issues/29041 set_option linter.unusedSimpArgs false in theorem sameRay_iff : SameRay ℝ x y ↔ x = 0 ∨ y = 0 ∨ x.arg = y.arg := by rcases eq_or_ne x 0 with (rfl | hx) · simp rcases eq_or_ne y 0 with (rfl | hy) · simp simp only [hx, hy, sameRay_iff_norm_smul_eq, arg_eq_arg_iff hx hy] simp [field, hx] rw [mul_comm, eq_comm] theorem sameRay_iff_arg_div_eq_zero : SameRay ℝ x y ↔ arg (x / y) = 0 := by rw [← Real.Angle.toReal_zero, ← arg_coe_angle_eq_iff_eq_toReal, sameRay_iff] by_cases hx : x = 0; · simp [hx] by_cases hy : y = 0; · simp [hy] simp [hx, hy, arg_div_coe_angle, sub_eq_zero] theorem norm_add_eq_iff : ‖x + y‖ = ‖x‖ + ‖y‖ ↔ x = 0 ∨ y = 0 ∨ x.arg = y.arg := sameRay_iff_norm_add.symm.trans sameRay_iff theorem norm_sub_eq_iff : ‖x - y‖ = |‖x‖ - ‖y‖| ↔ x = 0 ∨ y = 0 ∨ x.arg = y.arg := sameRay_iff_norm_sub.symm.trans sameRay_iff theorem sameRay_of_arg_eq (h : x.arg = y.arg) : SameRay ℝ x y := sameRay_iff.mpr <| Or.inr <| Or.inr h theorem norm_add_eq (h : x.arg = y.arg) : ‖x + y‖ = ‖x‖ + ‖y‖ := (sameRay_of_arg_eq h).norm_add theorem norm_sub_eq (h : x.arg = y.arg) : ‖x - y‖ = ‖‖x‖ - ‖y‖‖ := (sameRay_of_arg_eq h).norm_sub end Complex
.lake/packages/mathlib/Mathlib/Analysis/Complex/IntegerCompl.lean
import Mathlib.Analysis.Complex.UpperHalfPlane.Basic /-! # Integer Complement We define the complement of the integers in the complex plane and give some basic lemmas about it. We also show that the upper half plane embeds into the integer complement. -/ open UpperHalfPlane /-- The complement of the integers in `ℂ` -/ def Complex.integerComplement := (Set.range ((↑) : ℤ → ℂ))ᶜ namespace Complex local notation "ℂ_ℤ" => integerComplement lemma integerComplement_eq : ℂ_ℤ = {z : ℂ | ¬ ∃ (n : ℤ), n = z} := rfl lemma integerComplement.mem_iff {x : ℂ} : x ∈ ℂ_ℤ ↔ ¬ ∃ (n : ℤ), n = x := Iff.rfl lemma UpperHalfPlane.coe_mem_integerComplement (z : ℍ) : ↑z ∈ ℂ_ℤ := not_exists.mpr fun x hx ↦ ne_int z x hx.symm lemma integerComplement.add_coe_int_mem {x : ℂ} (a : ℤ) : x + (a : ℂ) ∈ ℂ_ℤ ↔ x ∈ ℂ_ℤ := by simp only [mem_iff, not_iff_not] exact ⟨(Exists.elim · fun n hn ↦ ⟨n - a, by simp [hn]⟩), (Exists.elim · fun n hn ↦ ⟨n + a, by simp [hn]⟩)⟩ lemma integerComplement.ne_zero {x : ℂ} (hx : x ∈ ℂ_ℤ) : x ≠ 0 := fun hx' ↦ hx ⟨0, by exact_mod_cast hx'.symm⟩ lemma integerComplement_add_ne_zero {x : ℂ} (hx : x ∈ ℂ_ℤ) (a : ℤ) : x + (a : ℂ) ≠ 0 := integerComplement.ne_zero ((integerComplement.add_coe_int_mem a).mpr hx) lemma integerComplement.ne_one {x : ℂ} (hx : x ∈ ℂ_ℤ) : x ≠ 1 := fun hx' ↦ hx ⟨1, by exact_mod_cast hx'.symm⟩ lemma integerComplement_pow_two_ne_pow_two {x : ℂ} (hx : x ∈ ℂ_ℤ) (n : ℤ) : x ^ 2 ≠ n ^ 2 := by have := not_exists.mp hx n have := not_exists.mp hx (-n) simp_all [sq_eq_sq_iff_eq_or_eq_neg, eq_comm] lemma upperHalfPlane_inter_integerComplement : {z : ℂ | 0 < z.im} ∩ ℂ_ℤ = {z : ℂ | 0 < z.im} := by ext z simp only [Set.mem_inter_iff, Set.mem_setOf_eq, and_iff_left_iff_imp] exact fun hz ↦ UpperHalfPlane.coe_mem_integerComplement ⟨z, hz⟩ end Complex
.lake/packages/mathlib/Mathlib/Analysis/Complex/HalfPlane.lean
import Mathlib.Analysis.Complex.Basic import Mathlib.Topology.Instances.EReal.Lemmas /-! # Half-planes in ℂ are open We state that open left, right, upper and lower half-planes in the complex numbers are open sets, where the bounding value of the real or imaginary part is given by an `EReal` `x`. So this includes the full plane and the empty set for `x = ⊤`/`x = ⊥`. -/ namespace Complex /-- An open left half-plane (with boundary real part given by an `EReal`) is an open set in the complex plane. -/ lemma isOpen_re_lt_EReal (x : EReal) : IsOpen {z : ℂ | z.re < x} := isOpen_lt (EReal.continuous_coe_iff.mpr continuous_re) continuous_const /-- An open right half-plane (with boundary real part given by an `EReal`) is an open set in the complex plane. -/ lemma isOpen_re_gt_EReal (x : EReal) : IsOpen {z : ℂ | x < z.re} := isOpen_lt continuous_const <| EReal.continuous_coe_iff.mpr continuous_re /-- An open lower half-plane (with boundary imaginary part given by an `EReal`) is an open set in the complex plane. -/ lemma isOpen_im_lt_EReal (x : EReal) : IsOpen {z : ℂ | z.im < x} := isOpen_lt (EReal.continuous_coe_iff.mpr continuous_im) continuous_const /-- An open upper half-plane (with boundary imaginary part given by an `EReal`) is an open set in the complex plane. -/ lemma isOpen_im_gt_EReal (x : EReal) : IsOpen {z : ℂ | x < z.im} := isOpen_lt continuous_const <| EReal.continuous_coe_iff.mpr continuous_im end Complex
.lake/packages/mathlib/Mathlib/Analysis/Complex/Basic.lean
import Mathlib.Analysis.Complex.Order import Mathlib.Analysis.RCLike.Basic import Mathlib.Data.Complex.BigOperators import Mathlib.LinearAlgebra.Complex.Module import Mathlib.Topology.Algebra.InfiniteSum.Module import Mathlib.Topology.Instances.RealVectorSpace import Mathlib.Topology.MetricSpace.ProperSpace.Real /-! # Normed space structure on `ℂ`. This file gathers basic facts of analytic nature on the complex numbers. ## Main results This file registers `ℂ` as a normed field, expresses basic properties of the norm, and gives tools on the real vector space structure of `ℂ`. Notably, it defines the following functions in the namespace `Complex`. |Name |Type |Description | |------------------|-------------|--------------------------------------------------------| |`equivRealProdCLM`|ℂ ≃L[ℝ] ℝ × ℝ|The natural `ContinuousLinearEquiv` from `ℂ` to `ℝ × ℝ` | |`reCLM` |ℂ →L[ℝ] ℝ |Real part function as a `ContinuousLinearMap` | |`imCLM` |ℂ →L[ℝ] ℝ |Imaginary part function as a `ContinuousLinearMap` | |`ofRealCLM` |ℝ →L[ℝ] ℂ |Embedding of the reals as a `ContinuousLinearMap` | |`ofRealLI` |ℝ →ₗᵢ[ℝ] ℂ |Embedding of the reals as a `LinearIsometry` | |`conjCLE` |ℂ ≃L[ℝ] ℂ |Complex conjugation as a `ContinuousLinearEquiv` | |`conjLIE` |ℂ ≃ₗᵢ[ℝ] ℂ |Complex conjugation as a `LinearIsometryEquiv` | We also register the fact that `ℂ` is an `RCLike` field. -/ assert_not_exists Absorbs /-- A shortcut instance to ensure computability; otherwise we get the noncomputable instance `Complex.instNormedField.toNormedModule.toModule`. -/ instance Complex.instModuleSelf : Module ℂ ℂ := delta% inferInstance noncomputable section namespace Complex variable {z : ℂ} open ComplexConjugate Topology Filter instance : NormedField ℂ where dist_eq _ _ := rfl norm_mul := Complex.norm_mul instance : DenselyNormedField ℂ where lt_norm_lt r₁ r₂ h₀ hr := let ⟨x, h⟩ := exists_between hr ⟨x, by rwa [norm_real, Real.norm_of_nonneg (h₀.trans_lt h.1).le]⟩ instance {R : Type*} [NormedField R] [NormedAlgebra R ℝ] : NormedAlgebra R ℂ where norm_smul_le r x := by rw [← algebraMap_smul ℝ r x, real_smul, norm_mul, norm_real, norm_algebraMap'] variable {E : Type*} [SeminormedAddCommGroup E] [NormedSpace ℂ E] -- see Note [lower instance priority] /-- The module structure from `Module.complexToReal` is a normed space. -/ instance (priority := 900) _root_.NormedSpace.complexToReal : NormedSpace ℝ E := NormedSpace.restrictScalars ℝ ℂ E -- see Note [lower instance priority] /-- The algebra structure from `Algebra.complexToReal` is a normed algebra. -/ instance (priority := 900) _root_.NormedAlgebra.complexToReal {A : Type*} [SeminormedRing A] [NormedAlgebra ℂ A] : NormedAlgebra ℝ A := NormedAlgebra.restrictScalars ℝ ℂ A -- This result cannot be moved to `Data/Complex/Norm` since `ℤ` gets its norm from its -- normed ring structure and that file does not know about rings @[simp 1100, norm_cast] lemma nnnorm_intCast (n : ℤ) : ‖(n : ℂ)‖₊ = ‖n‖₊ := by ext; exact norm_intCast n @[continuity, fun_prop] theorem continuous_normSq : Continuous normSq := by simpa [← Complex.normSq_eq_norm_sq] using continuous_norm (E := ℂ).pow 2 theorem nnnorm_eq_one_of_pow_eq_one {ζ : ℂ} {n : ℕ} (h : ζ ^ n = 1) (hn : n ≠ 0) : ‖ζ‖₊ = 1 := (pow_left_inj₀ zero_le' zero_le' hn).1 <| by rw [← nnnorm_pow, h, nnnorm_one, one_pow] theorem norm_eq_one_of_pow_eq_one {ζ : ℂ} {n : ℕ} (h : ζ ^ n = 1) (hn : n ≠ 0) : ‖ζ‖ = 1 := congr_arg Subtype.val (nnnorm_eq_one_of_pow_eq_one h hn) lemma le_of_eq_sum_of_eq_sum_norm {ι : Type*} {a b : ℝ} (f : ι → ℂ) (s : Finset ι) (ha₀ : 0 ≤ a) (ha : a = ∑ i ∈ s, f i) (hb : b = ∑ i ∈ s, (‖f i‖ : ℂ)) : a ≤ b := by norm_cast at hb; rw [← Complex.norm_of_nonneg ha₀, ha, hb]; exact norm_sum_le s f theorem equivRealProd_apply_le (z : ℂ) : ‖equivRealProd z‖ ≤ ‖z‖ := by simp [Prod.norm_def, abs_re_le_norm, abs_im_le_norm] theorem equivRealProd_apply_le' (z : ℂ) : ‖equivRealProd z‖ ≤ 1 * ‖z‖ := by simpa using equivRealProd_apply_le z theorem lipschitz_equivRealProd : LipschitzWith 1 equivRealProd := by simpa using AddMonoidHomClass.lipschitz_of_bound equivRealProdLm 1 equivRealProd_apply_le' theorem antilipschitz_equivRealProd : AntilipschitzWith (NNReal.sqrt 2) equivRealProd := AddMonoidHomClass.antilipschitz_of_bound equivRealProdLm fun z ↦ by simpa only [Real.coe_sqrt, NNReal.coe_ofNat] using norm_le_sqrt_two_mul_max z theorem isUniformEmbedding_equivRealProd : IsUniformEmbedding equivRealProd := antilipschitz_equivRealProd.isUniformEmbedding lipschitz_equivRealProd.uniformContinuous instance : CompleteSpace ℂ := (completeSpace_congr isUniformEmbedding_equivRealProd).mpr inferInstance instance instT2Space : T2Space ℂ := TopologicalSpace.t2Space_of_metrizableSpace /-- The natural `ContinuousLinearEquiv` from `ℂ` to `ℝ × ℝ`. -/ @[simps! +simpRhs apply symm_apply_re symm_apply_im] def equivRealProdCLM : ℂ ≃L[ℝ] ℝ × ℝ := equivRealProdLm.toContinuousLinearEquivOfBounds 1 (√2) equivRealProd_apply_le' fun p => norm_le_sqrt_two_mul_max (equivRealProd.symm p) theorem equivRealProdCLM_symm_apply (p : ℝ × ℝ) : Complex.equivRealProdCLM.symm p = p.1 + p.2 * Complex.I := Complex.equivRealProd_symm_apply p instance : ProperSpace ℂ := lipschitz_equivRealProd.properSpace equivRealProdCLM.toHomeomorph.isProperMap /-- The `normSq` function on `ℂ` is proper. -/ theorem tendsto_normSq_cocompact_atTop : Tendsto normSq (cocompact ℂ) atTop := by simpa [norm_mul_self_eq_normSq] using tendsto_norm_cocompact_atTop.atTop_mul_atTop₀ (tendsto_norm_cocompact_atTop (E := ℂ)) open ContinuousLinearMap /-- Continuous linear map version of the real part function, from `ℂ` to `ℝ`. -/ def reCLM : ℂ →L[ℝ] ℝ := reLm.mkContinuous 1 fun x => by simp [abs_re_le_norm] @[continuity, fun_prop] theorem continuous_re : Continuous re := reCLM.continuous lemma uniformlyContinuous_re : UniformContinuous re := reCLM.uniformContinuous @[simp] theorem reCLM_coe : (reCLM : ℂ →ₗ[ℝ] ℝ) = reLm := rfl @[simp] theorem reCLM_apply (z : ℂ) : (reCLM : ℂ → ℝ) z = z.re := rfl /-- Continuous linear map version of the imaginary part function, from `ℂ` to `ℝ`. -/ def imCLM : ℂ →L[ℝ] ℝ := imLm.mkContinuous 1 fun x => by simp [abs_im_le_norm] @[continuity, fun_prop] theorem continuous_im : Continuous im := imCLM.continuous lemma uniformlyContinuous_im : UniformContinuous im := imCLM.uniformContinuous @[simp] theorem imCLM_coe : (imCLM : ℂ →ₗ[ℝ] ℝ) = imLm := rfl @[simp] theorem imCLM_apply (z : ℂ) : (imCLM : ℂ → ℝ) z = z.im := rfl theorem restrictScalars_one_smulRight' (x : E) : ContinuousLinearMap.restrictScalars ℝ ((1 : ℂ →L[ℂ] ℂ).smulRight x : ℂ →L[ℂ] E) = reCLM.smulRight x + I • imCLM.smulRight x := by ext ⟨a, b⟩ simp [map_add, mk_eq_add_mul_I, mul_smul, smul_comm I b x] theorem restrictScalars_one_smulRight (x : ℂ) : ContinuousLinearMap.restrictScalars ℝ ((1 : ℂ →L[ℂ] ℂ).smulRight x : ℂ →L[ℂ] ℂ) = x • (1 : ℂ →L[ℝ] ℂ) := by ext1 z dsimp apply mul_comm /-- The complex-conjugation function from `ℂ` to itself is an isometric linear equivalence. -/ def conjLIE : ℂ ≃ₗᵢ[ℝ] ℂ := ⟨conjAe.toLinearEquiv, norm_conj⟩ @[simp] theorem conjLIE_apply (z : ℂ) : conjLIE z = conj z := rfl @[simp] theorem conjLIE_symm : conjLIE.symm = conjLIE := rfl theorem isometry_conj : Isometry (conj : ℂ → ℂ) := conjLIE.isometry @[simp] theorem dist_conj_conj (z w : ℂ) : dist (conj z) (conj w) = dist z w := isometry_conj.dist_eq z w @[simp] theorem nndist_conj_conj (z w : ℂ) : nndist (conj z) (conj w) = nndist z w := isometry_conj.nndist_eq z w theorem dist_conj_comm (z w : ℂ) : dist (conj z) w = dist z (conj w) := by rw [← dist_conj_conj, conj_conj] theorem nndist_conj_comm (z w : ℂ) : nndist (conj z) w = nndist z (conj w) := Subtype.ext <| dist_conj_comm _ _ instance : ContinuousStar ℂ := ⟨conjLIE.continuous⟩ @[continuity, fun_prop] theorem continuous_conj : Continuous (conj : ℂ → ℂ) := continuous_star /-- The only continuous ring homomorphisms from `ℂ` to `ℂ` are the identity and the complex conjugation. -/ theorem ringHom_eq_id_or_conj_of_continuous {f : ℂ →+* ℂ} (hf : Continuous f) : f = RingHom.id ℂ ∨ f = conj := by simpa only [DFunLike.ext_iff] using real_algHom_eq_id_or_conj (AlgHom.mk' f (map_real_smul f hf)) /-- Continuous linear equiv version of the conj function, from `ℂ` to `ℂ`. -/ def conjCLE : ℂ ≃L[ℝ] ℂ := conjLIE @[simp] theorem conjCLE_coe : conjCLE.toLinearEquiv = conjAe.toLinearEquiv := rfl @[simp] theorem conjCLE_apply (z : ℂ) : conjCLE z = conj z := rfl /-- Linear isometry version of the canonical embedding of `ℝ` in `ℂ`. -/ def ofRealLI : ℝ →ₗᵢ[ℝ] ℂ := ⟨ofRealAm.toLinearMap, norm_real⟩ @[simp] theorem ofRealLI_apply (x : ℝ) : ofRealLI x = x := rfl theorem isometry_ofReal : Isometry ((↑) : ℝ → ℂ) := ofRealLI.isometry @[continuity, fun_prop] theorem continuous_ofReal : Continuous ((↑) : ℝ → ℂ) := ofRealLI.continuous theorem isUniformEmbedding_ofReal : IsUniformEmbedding ((↑) : ℝ → ℂ) := ofRealLI.isometry.isUniformEmbedding lemma _root_.RCLike.isUniformEmbedding_ofReal {𝕜 : Type*} [RCLike 𝕜] : IsUniformEmbedding ((↑) : ℝ → 𝕜) := RCLike.ofRealLI.isometry.isUniformEmbedding theorem _root_.Filter.tendsto_ofReal_iff {α : Type*} {l : Filter α} {f : α → ℝ} {x : ℝ} : Tendsto (fun x ↦ (f x : ℂ)) l (𝓝 (x : ℂ)) ↔ Tendsto f l (𝓝 x) := isUniformEmbedding_ofReal.isClosedEmbedding.tendsto_nhds_iff.symm lemma _root_.Filter.tendsto_ofReal_iff' {α 𝕜 : Type*} [RCLike 𝕜] {l : Filter α} {f : α → ℝ} {x : ℝ} : Tendsto (fun x ↦ (f x : 𝕜)) l (𝓝 (x : 𝕜)) ↔ Tendsto f l (𝓝 x) := RCLike.isUniformEmbedding_ofReal.isClosedEmbedding.tendsto_nhds_iff.symm lemma _root_.Filter.Tendsto.ofReal {α : Type*} {l : Filter α} {f : α → ℝ} {x : ℝ} (hf : Tendsto f l (𝓝 x)) : Tendsto (fun x ↦ (f x : ℂ)) l (𝓝 (x : ℂ)) := tendsto_ofReal_iff.mpr hf /-- The only continuous ring homomorphism from `ℝ` to `ℂ` is the identity. -/ theorem ringHom_eq_ofReal_of_continuous {f : ℝ →+* ℂ} (h : Continuous f) : f = ofRealHom := by convert congr_arg AlgHom.toRingHom <| Subsingleton.elim (AlgHom.mk' f <| map_real_smul f h) (Algebra.ofId ℝ ℂ) /-- Continuous linear map version of the canonical embedding of `ℝ` in `ℂ`. -/ def ofRealCLM : ℝ →L[ℝ] ℂ := ofRealLI.toContinuousLinearMap @[simp] theorem ofRealCLM_coe : (ofRealCLM : ℝ →ₗ[ℝ] ℂ) = ofRealAm.toLinearMap := rfl @[simp] theorem ofRealCLM_apply (x : ℝ) : ofRealCLM x = x := rfl noncomputable instance : RCLike ℂ where re := ⟨⟨Complex.re, Complex.zero_re⟩, Complex.add_re⟩ im := ⟨⟨Complex.im, Complex.zero_im⟩, Complex.add_im⟩ I := Complex.I I_re_ax := I_re I_mul_I_ax := .inr Complex.I_mul_I re_add_im_ax := re_add_im ofReal_re_ax := ofReal_re ofReal_im_ax := ofReal_im mul_re_ax := mul_re mul_im_ax := mul_im conj_re_ax _ := rfl conj_im_ax _ := rfl conj_I_ax := conj_I norm_sq_eq_def_ax z := (normSq_eq_norm_sq z).symm mul_im_I_ax _ := mul_one _ toPartialOrder := Complex.partialOrder le_iff_re_im := Iff.rfl theorem _root_.RCLike.re_eq_complex_re : ⇑(RCLike.re : ℂ →+ ℝ) = Complex.re := rfl theorem _root_.RCLike.im_eq_complex_im : ⇑(RCLike.im : ℂ →+ ℝ) = Complex.im := rfl theorem _root_.RCLike.ofReal_eq_complex_ofReal : (RCLike.ofReal : ℝ → ℂ) = Complex.ofReal := rfl -- TODO: Replace `mul_conj` and `conj_mul` once `norm` has replaced `abs` lemma mul_conj' (z : ℂ) : z * conj z = ‖z‖ ^ 2 := RCLike.mul_conj z lemma conj_mul' (z : ℂ) : conj z * z = ‖z‖ ^ 2 := RCLike.conj_mul z lemma inv_eq_conj (hz : ‖z‖ = 1) : z⁻¹ = conj z := RCLike.inv_eq_conj hz lemma exists_norm_eq_mul_self (z : ℂ) : ∃ c, ‖c‖ = 1 ∧ ‖z‖ = c * z := RCLike.exists_norm_eq_mul_self _ lemma exists_norm_mul_eq_self (z : ℂ) : ∃ c, ‖c‖ = 1 ∧ c * ‖z‖ = z := RCLike.exists_norm_mul_eq_self _ lemma im_eq_zero_iff_isSelfAdjoint (x : ℂ) : Complex.im x = 0 ↔ IsSelfAdjoint x := by rw [← RCLike.im_eq_complex_im] exact RCLike.im_eq_zero_iff_isSelfAdjoint lemma re_eq_ofReal_of_isSelfAdjoint {x : ℂ} {y : ℝ} (hx : IsSelfAdjoint x) : Complex.re x = y ↔ x = y := by rw [← RCLike.re_eq_complex_re] exact RCLike.re_eq_ofReal_of_isSelfAdjoint hx lemma ofReal_eq_re_of_isSelfAdjoint {x : ℂ} {y : ℝ} (hx : IsSelfAdjoint x) : y = Complex.re x ↔ y = x := by rw [← RCLike.re_eq_complex_re] exact RCLike.ofReal_eq_re_of_isSelfAdjoint hx /-- The natural isomorphism between `𝕜` satisfying `RCLike 𝕜` and `ℂ` when `RCLike.im RCLike.I = 1`. -/ @[simps] def _root_.RCLike.complexRingEquiv {𝕜 : Type*} [RCLike 𝕜] (h : RCLike.im (RCLike.I : 𝕜) = 1) : 𝕜 ≃+* ℂ where toFun x := RCLike.re x + RCLike.im x * I invFun x := re x + im x * RCLike.I left_inv x := by simp right_inv x := by simp [h] map_add' x y := by simp only [map_add, ofReal_add]; ring map_mul' x y := by simp only [RCLike.mul_re, ofReal_sub, ofReal_mul, RCLike.mul_im, ofReal_add] ring_nf rw [I_sq] ring /-- The natural `ℝ`-linear isometry equivalence between `𝕜` satisfying `RCLike 𝕜` and `ℂ` when `RCLike.im RCLike.I = 1`. -/ @[simps] def _root_.RCLike.complexLinearIsometryEquiv {𝕜 : Type*} [RCLike 𝕜] (h : RCLike.im (RCLike.I : 𝕜) = 1) : 𝕜 ≃ₗᵢ[ℝ] ℂ where map_smul' _ _ := by simp [RCLike.smul_re, RCLike.smul_im, ofReal_mul]; ring norm_map' _ := by rw [← sq_eq_sq₀ (by positivity) (by positivity), ← normSq_eq_norm_sq, ← RCLike.normSq_eq_def', RCLike.normSq_apply] simp [normSq_add] __ := RCLike.complexRingEquiv h theorem isometry_intCast : Isometry ((↑) : ℤ → ℂ) := Isometry.of_dist_eq <| by simp_rw [← Complex.ofReal_intCast, Complex.isometry_ofReal.dist_eq, Int.dist_cast_real, implies_true] theorem closedEmbedding_intCast : IsClosedEmbedding ((↑) : ℤ → ℂ) := isometry_intCast.isClosedEmbedding lemma isClosed_range_intCast : IsClosed (Set.range ((↑) : ℤ → ℂ)) := Complex.closedEmbedding_intCast.isClosed_range lemma isOpen_compl_range_intCast : IsOpen (Set.range ((↑) : ℤ → ℂ))ᶜ := Complex.isClosed_range_intCast.isOpen_compl section ComplexOrder open ComplexOrder theorem eq_coe_norm_of_nonneg {z : ℂ} (hz : 0 ≤ z) : z = ↑‖z‖ := by lift z to ℝ using hz.2.symm rw [norm_real, Real.norm_of_nonneg (id hz.1 : 0 ≤ z)] /-- We show that the partial order and the topology on `ℂ` are compatible. We turn this into an instance scoped to `ComplexOrder`. -/ lemma orderClosedTopology : OrderClosedTopology ℂ where isClosed_le' := by simp_rw [le_def, Set.setOf_and] refine IsClosed.inter (isClosed_le ?_ ?_) (isClosed_eq ?_ ?_) <;> continuity scoped[ComplexOrder] attribute [instance] Complex.orderClosedTopology theorem norm_of_nonneg' {x : ℂ} (hx : 0 ≤ x) : ‖x‖ = x := by rw [← RCLike.ofReal_eq_complex_ofReal] exact RCLike.norm_of_nonneg' hx lemma re_nonneg_iff_nonneg {x : ℂ} (hx : IsSelfAdjoint x) : 0 ≤ re x ↔ 0 ≤ x := by rw [← RCLike.re_eq_complex_re] exact RCLike.re_nonneg_of_nonneg hx @[gcongr] lemma re_le_re {x y : ℂ} (h : x ≤ y) : re x ≤ re y := by rw [RCLike.le_iff_re_im] at h exact h.1 end ComplexOrder end Complex namespace RCLike open ComplexConjugate local notation "reC" => @RCLike.re ℂ _ local notation "imC" => @RCLike.im ℂ _ local notation "IC" => @RCLike.I ℂ _ local notation "norm_sqC" => @RCLike.normSq ℂ _ @[simp] theorem re_to_complex {x : ℂ} : reC x = x.re := rfl @[simp] theorem im_to_complex {x : ℂ} : imC x = x.im := rfl @[simp] theorem I_to_complex : IC = Complex.I := rfl @[simp] theorem normSq_to_complex {x : ℂ} : norm_sqC x = Complex.normSq x := rfl section tsum variable {α : Type*} (𝕜 : Type*) [RCLike 𝕜] {L : SummationFilter α} @[simp] theorem hasSum_conj {f : α → 𝕜} {x : 𝕜} : HasSum (fun x => conj (f x)) x L ↔ HasSum f (conj x) L := conjCLE.hasSum theorem hasSum_conj' {f : α → 𝕜} {x : 𝕜} : HasSum (fun x => conj (f x)) (conj x) L ↔ HasSum f x L := conjCLE.hasSum' @[simp] theorem summable_conj {f : α → 𝕜} : Summable (fun x => conj (f x)) L ↔ Summable f L := summable_star_iff variable {𝕜} in theorem conj_tsum (f : α → 𝕜) : conj (∑'[L] a, f a) = ∑'[L] a, conj (f a) := tsum_star @[simp, norm_cast] theorem hasSum_ofReal {f : α → ℝ} {x : ℝ} : HasSum (fun x => (f x : 𝕜)) x L ↔ HasSum f x L := ⟨fun h => by simpa only [RCLike.reCLM_apply, RCLike.ofReal_re] using reCLM.hasSum h, ofRealCLM.hasSum⟩ @[simp, norm_cast] theorem summable_ofReal {f : α → ℝ} : Summable (fun x => (f x : 𝕜)) L ↔ Summable f L := ⟨fun h => by simpa only [RCLike.reCLM_apply, RCLike.ofReal_re] using reCLM.summable h, ofRealCLM.summable⟩ @[norm_cast] theorem ofReal_tsum (f : α → ℝ) : (↑(∑'[L] a, f a) : 𝕜) = ∑'[L] a, (f a : 𝕜) := Function.LeftInverse.map_tsum f ofRealCLM.continuous continuous_re (fun _ ↦ by simp) theorem hasSum_re {f : α → 𝕜} {x : 𝕜} (h : HasSum f x L) : HasSum (fun x => re (f x)) (re x) L := reCLM.hasSum h theorem hasSum_im {f : α → 𝕜} {x : 𝕜} (h : HasSum f x L) : HasSum (fun x => im (f x)) (im x) L := imCLM.hasSum h theorem re_tsum [L.NeBot] {f : α → 𝕜} (h : Summable f L) : re (∑'[L] a, f a) = ∑'[L] a, re (f a) := reCLM.map_tsum h theorem im_tsum [L.NeBot] {f : α → 𝕜} (h : Summable f L) : im (∑'[L] a, f a) = ∑'[L] a, im (f a) := imCLM.map_tsum h variable {𝕜} theorem hasSum_iff (f : α → 𝕜) (c : 𝕜) : HasSum f c L ↔ HasSum (fun x => re (f x)) (re c) L ∧ HasSum (fun x => im (f x)) (im c) L := by refine ⟨fun h => ⟨hasSum_re _ h, hasSum_im _ h⟩, ?_⟩ rintro ⟨h₁, h₂⟩ simpa only [re_add_im] using ((hasSum_ofReal 𝕜).mpr h₁).add (((hasSum_ofReal 𝕜).mpr h₂).mul_right I) end tsum end RCLike namespace Complex /-! We have to repeat the lemmas about `RCLike.re` and `RCLike.im` as they are not syntactic matches for `Complex.re` and `Complex.im`. We do not have this problem with `ofReal` and `conj`, although we repeat them anyway for discoverability and to avoid the need to unify `𝕜`. -/ section tsum variable {α : Type*} {L : SummationFilter α} open ComplexConjugate theorem hasSum_conj {f : α → ℂ} {x : ℂ} : HasSum (fun x => conj (f x)) x L ↔ HasSum f (conj x) L := RCLike.hasSum_conj _ theorem hasSum_conj' {f : α → ℂ} {x : ℂ} : HasSum (fun x => conj (f x)) (conj x) L ↔ HasSum f x L := RCLike.hasSum_conj' _ theorem summable_conj {f : α → ℂ} : (Summable fun x => conj (f x)) ↔ Summable f := RCLike.summable_conj _ theorem conj_tsum (f : α → ℂ) : conj (∑'[L] a, f a) = ∑'[L] a, conj (f a) := RCLike.conj_tsum _ @[simp, norm_cast] theorem hasSum_ofReal {f : α → ℝ} {x : ℝ} : HasSum (fun x => (f x : ℂ)) x L ↔ HasSum f x L := RCLike.hasSum_ofReal _ @[simp, norm_cast] theorem summable_ofReal {f : α → ℝ} : (Summable (fun x => (f x : ℂ)) L) ↔ Summable f L := RCLike.summable_ofReal _ @[norm_cast] theorem ofReal_tsum (f : α → ℝ) : (↑(∑'[L] a, f a) : ℂ) = ∑'[L] a, ↑(f a) := RCLike.ofReal_tsum _ _ theorem hasSum_re {f : α → ℂ} {x : ℂ} (h : HasSum f x L) : HasSum (fun x => (f x).re) x.re L := RCLike.hasSum_re ℂ h theorem hasSum_im {f : α → ℂ} {x : ℂ} (h : HasSum f x L) : HasSum (fun x => (f x).im) x.im L := RCLike.hasSum_im ℂ h theorem re_tsum [L.NeBot] {f : α → ℂ} (h : Summable f L) : (∑'[L] a, f a).re = ∑'[L] a, (f a).re := RCLike.re_tsum _ h theorem im_tsum [L.NeBot] {f : α → ℂ} (h : Summable f L) : (∑'[L] a, f a).im = ∑'[L] a, (f a).im := RCLike.im_tsum _ h theorem hasSum_iff (f : α → ℂ) (c : ℂ) : HasSum f c L ↔ HasSum (fun x => (f x).re) c.re L ∧ HasSum (fun x => (f x).im) c.im L := RCLike.hasSum_iff _ _ end tsum section slitPlane /-! ### Define the "slit plane" `ℂ ∖ ℝ≤0` and provide some API -/ open scoped ComplexOrder /-- The *slit plane* is the complex plane with the closed negative real axis removed. -/ def slitPlane : Set ℂ := {z | 0 < z.re ∨ z.im ≠ 0} lemma mem_slitPlane_iff {z : ℂ} : z ∈ slitPlane ↔ 0 < z.re ∨ z.im ≠ 0 := Set.mem_setOf /- If `z` is non-zero, then either `z` or `-z` is in `slitPlane`. -/ lemma mem_slitPlane_or_neg_mem_slitPlane {z : ℂ} (hz : z ≠ 0) : z ∈ slitPlane ∨ -z ∈ slitPlane := by rw [mem_slitPlane_iff, mem_slitPlane_iff] rw [ne_eq, Complex.ext_iff] at hz push_neg at hz simp_all only [ne_eq, zero_re, zero_im, neg_re, Left.neg_pos_iff, neg_im, neg_eq_zero] by_contra! contra exact hz (le_antisymm contra.1.1 contra.2.1) contra.1.2 lemma slitPlane_eq_union : slitPlane = {z | 0 < z.re} ∪ {z | z.im ≠ 0} := Set.setOf_or.symm lemma isOpen_slitPlane : IsOpen slitPlane := (isOpen_lt continuous_const continuous_re).union (isOpen_ne_fun continuous_im continuous_const) @[simp] lemma ofReal_mem_slitPlane {x : ℝ} : ↑x ∈ slitPlane ↔ 0 < x := by simp [mem_slitPlane_iff] @[simp] lemma neg_ofReal_mem_slitPlane {x : ℝ} : -↑x ∈ slitPlane ↔ x < 0 := by simpa using ofReal_mem_slitPlane (x := -x) @[simp] lemma one_mem_slitPlane : 1 ∈ slitPlane := ofReal_mem_slitPlane.2 one_pos @[simp] lemma zero_notMem_slitPlane : 0 ∉ slitPlane := mt ofReal_mem_slitPlane.1 (lt_irrefl _) @[deprecated (since := "2025-05-23")] alias zero_not_mem_slitPlane := zero_notMem_slitPlane @[simp] lemma natCast_mem_slitPlane {n : ℕ} : ↑n ∈ slitPlane ↔ n ≠ 0 := by simpa [pos_iff_ne_zero] using @ofReal_mem_slitPlane n @[simp] lemma ofNat_mem_slitPlane (n : ℕ) [n.AtLeastTwo] : ofNat(n) ∈ slitPlane := natCast_mem_slitPlane.2 (NeZero.ne n) lemma mem_slitPlane_iff_not_le_zero {z : ℂ} : z ∈ slitPlane ↔ ¬z ≤ 0 := mem_slitPlane_iff.trans not_le_zero_iff.symm protected lemma compl_Iic_zero : (Set.Iic 0)ᶜ = slitPlane := Set.ext fun _ ↦ mem_slitPlane_iff_not_le_zero.symm lemma slitPlane_ne_zero {z : ℂ} (hz : z ∈ slitPlane) : z ≠ 0 := ne_of_mem_of_not_mem hz zero_notMem_slitPlane /-- The slit plane includes the open unit ball of radius `1` around `1`. -/ lemma ball_one_subset_slitPlane : Metric.ball 1 1 ⊆ slitPlane := fun z hz ↦ .inl <| have : -1 < z.re - 1 := neg_lt_of_abs_lt <| (abs_re_le_norm _).trans_lt hz by linarith /-- The slit plane includes the open unit ball of radius `1` around `1`. -/ lemma mem_slitPlane_of_norm_lt_one {z : ℂ} (hz : ‖z‖ < 1) : 1 + z ∈ slitPlane := ball_one_subset_slitPlane <| by simpa open Metric in /-- A subset of the circle centered at the origin in `ℂ` of radius `r` is a subset of the `slitPlane` if it does not contain `-r`. -/ lemma subset_slitPlane_iff_of_subset_sphere {r : ℝ} {s : Set ℂ} (hs : s ⊆ sphere 0 r) : s ⊆ slitPlane ↔ (-r : ℂ) ∉ s := by simp_rw +singlePass [← not_iff_not, Set.subset_def, mem_slitPlane_iff_not_le_zero] push ¬ _ refine ⟨?_, fun hr ↦ ⟨_, hr, by simpa using hs hr⟩⟩ rintro ⟨z, hzs, hz⟩ have : ‖z‖ = r := by simpa using hs hzs simpa [← this, ← norm_neg z ▸ eq_coe_norm_of_nonneg (neg_nonneg.mpr hz)] end slitPlane lemma _root_.IsCompact.reProdIm {s t : Set ℝ} (hs : IsCompact s) (ht : IsCompact t) : IsCompact (s ×ℂ t) := equivRealProdCLM.toHomeomorph.isCompact_preimage.2 (hs.prod ht) end Complex section realPart_imaginaryPart variable {A : Type*} [SeminormedAddCommGroup A] [StarAddMonoid A] [NormedSpace ℂ A] [StarModule ℂ A] [NormedStarGroup A] lemma realPart.norm_le (x : A) : ‖realPart x‖ ≤ ‖x‖ := by rw [← inv_mul_cancel_left₀ two_ne_zero ‖x‖, ← AddSubgroup.norm_coe, realPart_apply_coe, norm_smul, norm_inv, Real.norm_ofNat] gcongr exact norm_add_le _ _ |>.trans <| by simp [two_mul] lemma imaginaryPart.norm_le (x : A) : ‖imaginaryPart x‖ ≤ ‖x‖ := by calc ‖imaginaryPart x‖ = ‖realPart (Complex.I • (-x))‖ := by simp _ ≤ ‖x‖ := by simpa only [smul_neg, map_neg, realPart_I_smul, neg_neg, AddSubgroupClass.coe_norm, norm_neg, norm_smul, Complex.norm_I, one_mul] using realPart.norm_le (Complex.I • (-x)) end realPart_imaginaryPart
.lake/packages/mathlib/Mathlib/Analysis/Complex/LocallyUniformLimit.lean
import Mathlib.Analysis.Complex.RemovableSingularity import Mathlib.Analysis.Calculus.UniformLimitsDeriv import Mathlib.Analysis.Normed.Group.FunctionSeries /-! # Locally uniform limits of holomorphic functions This file gathers some results about locally uniform limits of holomorphic functions on an open subset of the complex plane. ## Main results * `TendstoLocallyUniformlyOn.differentiableOn`: A locally uniform limit of holomorphic functions is holomorphic. * `TendstoLocallyUniformlyOn.deriv`: Locally uniform convergence implies locally uniform convergence of the derivatives to the derivative of the limit. -/ open Set Metric MeasureTheory Filter Complex intervalIntegral open scoped Real Topology variable {E ι : Type*} [NormedAddCommGroup E] [NormedSpace ℂ E] {U K : Set ℂ} {z : ℂ} {M r δ : ℝ} {φ : Filter ι} {F : ι → ℂ → E} {f g : ℂ → E} namespace Complex section Cderiv /-- A circle integral which coincides with `deriv f z` whenever one can apply the Cauchy formula for the derivative. It is useful in the proof that locally uniform limits of holomorphic functions are holomorphic, because it depends continuously on `f` for the uniform topology. -/ noncomputable def cderiv (r : ℝ) (f : ℂ → E) (z : ℂ) : E := (2 * π * I : ℂ)⁻¹ • ∮ w in C(z, r), ((w - z) ^ 2)⁻¹ • f w theorem cderiv_eq_deriv [CompleteSpace E] (hU : IsOpen U) (hf : DifferentiableOn ℂ f U) (hr : 0 < r) (hzr : closedBall z r ⊆ U) : cderiv r f z = deriv f z := two_pi_I_inv_smul_circleIntegral_sub_sq_inv_smul_of_differentiable hU hzr hf (mem_ball_self hr) theorem norm_cderiv_le (hr : 0 < r) (hf : ∀ w ∈ sphere z r, ‖f w‖ ≤ M) : ‖cderiv r f z‖ ≤ M / r := by have hM : 0 ≤ M := by obtain ⟨w, hw⟩ : (sphere z r).Nonempty := NormedSpace.sphere_nonempty.mpr hr.le exact (norm_nonneg _).trans (hf w hw) have h1 : ∀ w ∈ sphere z r, ‖((w - z) ^ 2)⁻¹ • f w‖ ≤ M / r ^ 2 := by intro w hw simp only [mem_sphere_iff_norm] at hw simp only [norm_smul, inv_mul_eq_div, hw, norm_inv, norm_pow] exact div_le_div₀ hM (hf w hw) (sq_pos_of_pos hr) le_rfl have h2 := circleIntegral.norm_integral_le_of_norm_le_const hr.le h1 simp only [cderiv, norm_smul] refine (mul_le_mul le_rfl h2 (norm_nonneg _) (norm_nonneg _)).trans (le_of_eq ?_) simp [field, abs_of_nonneg Real.pi_pos.le] theorem cderiv_sub (hr : 0 < r) (hf : ContinuousOn f (sphere z r)) (hg : ContinuousOn g (sphere z r)) : cderiv r (f - g) z = cderiv r f z - cderiv r g z := by have h1 : ContinuousOn (fun w : ℂ => ((w - z) ^ 2)⁻¹) (sphere z r) := by refine ((continuous_id'.sub continuous_const).pow 2).continuousOn.inv₀ fun w hw h => hr.ne ?_ rwa [mem_sphere_iff_norm, sq_eq_zero_iff.mp h, norm_zero] at hw simp_rw [cderiv, ← smul_sub] congr 1 simpa only [Pi.sub_apply, smul_sub] using circleIntegral.integral_sub ((h1.smul hf).circleIntegrable hr.le) ((h1.smul hg).circleIntegrable hr.le) theorem norm_cderiv_lt (hr : 0 < r) (hfM : ∀ w ∈ sphere z r, ‖f w‖ < M) (hf : ContinuousOn f (sphere z r)) : ‖cderiv r f z‖ < M / r := by obtain ⟨L, hL1, hL2⟩ : ∃ L < M, ∀ w ∈ sphere z r, ‖f w‖ ≤ L := by have e1 : (sphere z r).Nonempty := NormedSpace.sphere_nonempty.mpr hr.le have e2 : ContinuousOn (fun w => ‖f w‖) (sphere z r) := continuous_norm.comp_continuousOn hf obtain ⟨x, hx, hx'⟩ := (isCompact_sphere z r).exists_isMaxOn e1 e2 exact ⟨‖f x‖, hfM x hx, hx'⟩ exact (norm_cderiv_le hr hL2).trans_lt ((div_lt_div_iff_of_pos_right hr).mpr hL1) theorem norm_cderiv_sub_lt (hr : 0 < r) (hfg : ∀ w ∈ sphere z r, ‖f w - g w‖ < M) (hf : ContinuousOn f (sphere z r)) (hg : ContinuousOn g (sphere z r)) : ‖cderiv r f z - cderiv r g z‖ < M / r := cderiv_sub hr hf hg ▸ norm_cderiv_lt hr hfg (hf.sub hg) theorem _root_.TendstoUniformlyOn.cderiv (hF : TendstoUniformlyOn F f φ (cthickening δ K)) (hδ : 0 < δ) (hFn : ∀ᶠ n in φ, ContinuousOn (F n) (cthickening δ K)) : TendstoUniformlyOn (cderiv δ ∘ F) (cderiv δ f) φ K := by rcases φ.eq_or_neBot with rfl | hne · simp only [TendstoUniformlyOn, eventually_bot, imp_true_iff] have e1 : ContinuousOn f (cthickening δ K) := TendstoUniformlyOn.continuousOn hF hFn rw [tendstoUniformlyOn_iff] at hF ⊢ rintro ε hε filter_upwards [hF (ε * δ) (mul_pos hε hδ), hFn] with n h h' z hz simp_rw [dist_eq_norm] at h ⊢ have e2 : ∀ w ∈ sphere z δ, ‖f w - F n w‖ < ε * δ := fun w hw1 => h w (closedBall_subset_cthickening hz δ (sphere_subset_closedBall hw1)) have e3 := sphere_subset_closedBall.trans (closedBall_subset_cthickening hz δ) have hf : ContinuousOn f (sphere z δ) := e1.mono (sphere_subset_closedBall.trans (closedBall_subset_cthickening hz δ)) simpa only [mul_div_cancel_right₀ _ hδ.ne.symm] using norm_cderiv_sub_lt hδ e2 hf (h'.mono e3) end Cderiv variable [CompleteSpace E] section Weierstrass theorem tendstoUniformlyOn_deriv_of_cthickening_subset (hf : TendstoLocallyUniformlyOn F f φ U) (hF : ∀ᶠ n in φ, DifferentiableOn ℂ (F n) U) {δ : ℝ} (hδ : 0 < δ) (hK : IsCompact K) (hU : IsOpen U) (hKU : cthickening δ K ⊆ U) : TendstoUniformlyOn (deriv ∘ F) (cderiv δ f) φ K := by have h1 : ∀ᶠ n in φ, ContinuousOn (F n) (cthickening δ K) := by filter_upwards [hF] with n h using h.continuousOn.mono hKU have h2 : IsCompact (cthickening δ K) := hK.cthickening have h3 : TendstoUniformlyOn F f φ (cthickening δ K) := (tendstoLocallyUniformlyOn_iff_forall_isCompact hU).mp hf (cthickening δ K) hKU h2 apply (h3.cderiv hδ h1).congr filter_upwards [hF] with n h z hz exact cderiv_eq_deriv hU h hδ ((closedBall_subset_cthickening hz δ).trans hKU) theorem exists_cthickening_tendstoUniformlyOn (hf : TendstoLocallyUniformlyOn F f φ U) (hF : ∀ᶠ n in φ, DifferentiableOn ℂ (F n) U) (hK : IsCompact K) (hU : IsOpen U) (hKU : K ⊆ U) : ∃ δ > 0, cthickening δ K ⊆ U ∧ TendstoUniformlyOn (deriv ∘ F) (cderiv δ f) φ K := by obtain ⟨δ, hδ, hKδ⟩ := hK.exists_cthickening_subset_open hU hKU exact ⟨δ, hδ, hKδ, tendstoUniformlyOn_deriv_of_cthickening_subset hf hF hδ hK hU hKδ⟩ /-- A locally uniform limit of holomorphic functions on an open domain of the complex plane is holomorphic (the derivatives converge locally uniformly to that of the limit, which is proved as `TendstoLocallyUniformlyOn.deriv`). -/ theorem _root_.TendstoLocallyUniformlyOn.differentiableOn [φ.NeBot] (hf : TendstoLocallyUniformlyOn F f φ U) (hF : ∀ᶠ n in φ, DifferentiableOn ℂ (F n) U) (hU : IsOpen U) : DifferentiableOn ℂ f U := by rintro x hx obtain ⟨K, ⟨hKx, hK⟩, hKU⟩ := (compact_basis_nhds x).mem_iff.mp (hU.mem_nhds hx) obtain ⟨δ, _, _, h1⟩ := exists_cthickening_tendstoUniformlyOn hf hF hK hU hKU have h2 : interior K ⊆ U := interior_subset.trans hKU have h3 : ∀ᶠ n in φ, DifferentiableOn ℂ (F n) (interior K) := by filter_upwards [hF] with n h using h.mono h2 have h4 : TendstoLocallyUniformlyOn F f φ (interior K) := hf.mono h2 have h5 : TendstoLocallyUniformlyOn (deriv ∘ F) (cderiv δ f) φ (interior K) := h1.tendstoLocallyUniformlyOn.mono interior_subset have h6 : ∀ x ∈ interior K, HasDerivAt f (cderiv δ f x) x := fun x h => hasDerivAt_of_tendsto_locally_uniformly_on' isOpen_interior h5 h3 (fun _ => h4.tendsto_at) h have h7 : DifferentiableOn ℂ f (interior K) := fun x hx => (h6 x hx).differentiableAt.differentiableWithinAt exact (h7.differentiableAt (interior_mem_nhds.mpr hKx)).differentiableWithinAt theorem _root_.TendstoLocallyUniformlyOn.deriv (hf : TendstoLocallyUniformlyOn F f φ U) (hF : ∀ᶠ n in φ, DifferentiableOn ℂ (F n) U) (hU : IsOpen U) : TendstoLocallyUniformlyOn (deriv ∘ F) (deriv f) φ U := by rw [tendstoLocallyUniformlyOn_iff_forall_isCompact hU] rcases φ.eq_or_neBot with rfl | hne · simp only [TendstoUniformlyOn, eventually_bot, imp_true_iff] rintro K hKU hK obtain ⟨δ, hδ, hK4, h⟩ := exists_cthickening_tendstoUniformlyOn hf hF hK hU hKU refine h.congr_right fun z hz => cderiv_eq_deriv hU (hf.differentiableOn hF hU) hδ ?_ exact (closedBall_subset_cthickening hz δ).trans hK4 end Weierstrass section Tsums /-- If the terms in the sum `∑' (i : ι), F i` are uniformly bounded on `U` by a summable function, and each term in the sum is differentiable on `U`, then so is the sum. -/ theorem differentiableOn_tsum_of_summable_norm {u : ι → ℝ} (hu : Summable u) (hf : ∀ i : ι, DifferentiableOn ℂ (F i) U) (hU : IsOpen U) (hF_le : ∀ (i : ι) (w : ℂ), w ∈ U → ‖F i w‖ ≤ u i) : DifferentiableOn ℂ (fun w : ℂ => ∑' i : ι, F i w) U := by classical have hc := (tendstoUniformlyOn_tsum hu hF_le).tendstoLocallyUniformlyOn refine hc.differentiableOn (Eventually.of_forall fun s => ?_) hU exact DifferentiableOn.fun_sum fun i _ => hf i /-- If the terms in the sum `∑' (i : ι), F i` are uniformly bounded on `U` by a summable function, then the sum of `deriv F i` at a point in `U` is the derivative of the sum. -/ theorem hasSum_deriv_of_summable_norm {u : ι → ℝ} (hu : Summable u) (hf : ∀ i : ι, DifferentiableOn ℂ (F i) U) (hU : IsOpen U) (hF_le : ∀ (i : ι) (w : ℂ), w ∈ U → ‖F i w‖ ≤ u i) (hz : z ∈ U) : HasSum (fun i : ι => deriv (F i) z) (deriv (fun w : ℂ => ∑' i : ι, F i w) z) := by rw [HasSum] have hc := (tendstoUniformlyOn_tsum hu hF_le).tendstoLocallyUniformlyOn convert (hc.deriv (Eventually.of_forall fun s => DifferentiableOn.fun_sum fun i _ => hf i) hU).tendsto_at hz using 1 ext1 s exact (deriv_fun_sum fun i _ => (hf i).differentiableAt (hU.mem_nhds hz)).symm end Tsums section LogDeriv /-- The logarithmic derivative of a sequence of functions converging locally uniformly to a function is the logarithmic derivative of the limit function. -/ theorem logDeriv_tendsto {ι : Type*} {p : Filter ι} {f : ι → ℂ → ℂ} {g : ℂ → ℂ} {s : Set ℂ} (hs : IsOpen s) (x : s) (hF : TendstoLocallyUniformlyOn f g p s) (hf : ∀ᶠ n : ι in p, DifferentiableOn ℂ (f n) s) (hg : g x ≠ 0) : Tendsto (fun n : ι => logDeriv (f n) x) p (𝓝 ((logDeriv g) x)) := by simp_rw [logDeriv] apply Tendsto.div ((hF.deriv hf hs).tendsto_at x.2) (hF.tendsto_at x.2) hg end LogDeriv end Complex
.lake/packages/mathlib/Mathlib/Analysis/Complex/Cardinality.lean
import Mathlib.Analysis.Real.Cardinality import Mathlib.Data.Complex.Basic /-! # The cardinality of the complex numbers This file shows that the complex numbers have cardinality continuum, i.e. `#ℂ = 𝔠`. -/ open Cardinal Set open Cardinal /-- The cardinality of the complex numbers, as a type. -/ @[simp] theorem Cardinal.mk_complex : #ℂ = 𝔠 := by rw [mk_congr Complex.equivRealProd, mk_prod, lift_id, mk_real, continuum_mul_self] /-- The cardinality of the complex numbers, as a set. -/ theorem Cardinal.mk_univ_complex : #(Set.univ : Set ℂ) = 𝔠 := by rw [mk_univ, mk_complex] /-- The complex numbers are not countable. -/ theorem not_countable_complex : ¬(Set.univ : Set ℂ).Countable := by rw [← le_aleph0_iff_set_countable, not_le, Cardinal.mk_univ_complex] apply cantor
.lake/packages/mathlib/Mathlib/Analysis/Complex/IsIntegral.lean
import Mathlib.Algebra.Algebra.Rat import Mathlib.Data.Complex.Basic import Mathlib.RingTheory.IntegralClosure.IsIntegral.Basic /-! # Integral elements of ℂ This file proves that `Complex.I` is integral over ℤ and ℚ. -/ open Polynomial namespace Complex theorem isIntegral_int_I : IsIntegral ℤ I := by refine ⟨X ^ 2 + C 1, monic_X_pow_add_C _ two_ne_zero, ?_⟩ rw [eval₂_add, eval₂_X_pow, eval₂_C, I_sq, eq_intCast, Int.cast_one, neg_add_cancel] theorem isIntegral_rat_I : IsIntegral ℚ I := isIntegral_int_I.tower_top end Complex
.lake/packages/mathlib/Mathlib/Analysis/Complex/Trigonometric.lean
import Mathlib.Analysis.Complex.Exponential /-! # Trigonometric and hyperbolic trigonometric functions This file contains the definitions of the sine, cosine, tangent, hyperbolic sine, hyperbolic cosine, and hyperbolic tangent functions. -/ open CauSeq Finset IsAbsoluteValue open scoped ComplexConjugate namespace Complex noncomputable section /-- The complex sine function, defined via `exp` -/ @[pp_nodot] def sin (z : ℂ) : ℂ := (exp (-z * I) - exp (z * I)) * I / 2 /-- The complex cosine function, defined via `exp` -/ @[pp_nodot] def cos (z : ℂ) : ℂ := (exp (z * I) + exp (-z * I)) / 2 /-- The complex tangent function, defined as `sin z / cos z` -/ @[pp_nodot] def tan (z : ℂ) : ℂ := sin z / cos z /-- The complex cotangent function, defined as `cos z / sin z` -/ def cot (z : ℂ) : ℂ := cos z / sin z /-- The complex hyperbolic sine function, defined via `exp` -/ @[pp_nodot] def sinh (z : ℂ) : ℂ := (exp z - exp (-z)) / 2 /-- The complex hyperbolic cosine function, defined via `exp` -/ @[pp_nodot] def cosh (z : ℂ) : ℂ := (exp z + exp (-z)) / 2 /-- The complex hyperbolic tangent function, defined as `sinh z / cosh z` -/ @[pp_nodot] def tanh (z : ℂ) : ℂ := sinh z / cosh z end end Complex namespace Real open Complex noncomputable section /-- The real sine function, defined as the real part of the complex sine -/ @[pp_nodot] nonrec def sin (x : ℝ) : ℝ := (sin x).re /-- The real cosine function, defined as the real part of the complex cosine -/ @[pp_nodot] nonrec def cos (x : ℝ) : ℝ := (cos x).re /-- The real tangent function, defined as the real part of the complex tangent -/ @[pp_nodot] nonrec def tan (x : ℝ) : ℝ := (tan x).re /-- The real cotangent function, defined as the real part of the complex cotangent -/ nonrec def cot (x : ℝ) : ℝ := (cot x).re /-- The real hypebolic sine function, defined as the real part of the complex hyperbolic sine -/ @[pp_nodot] nonrec def sinh (x : ℝ) : ℝ := (sinh x).re /-- The real hypebolic cosine function, defined as the real part of the complex hyperbolic cosine -/ @[pp_nodot] nonrec def cosh (x : ℝ) : ℝ := (cosh x).re /-- The real hypebolic tangent function, defined as the real part of the complex hyperbolic tangent -/ @[pp_nodot] nonrec def tanh (x : ℝ) : ℝ := (tanh x).re end end Real namespace Complex variable (x y : ℂ) theorem two_sinh : 2 * sinh x = exp x - exp (-x) := mul_div_cancel₀ _ two_ne_zero theorem two_cosh : 2 * cosh x = exp x + exp (-x) := mul_div_cancel₀ _ two_ne_zero @[simp] theorem sinh_zero : sinh 0 = 0 := by simp [sinh] @[simp] theorem sinh_neg : sinh (-x) = -sinh x := by simp [sinh, exp_neg, (neg_div _ _).symm] private theorem sinh_add_aux {a b c d : ℂ} : (a - b) * (c + d) + (a + b) * (c - d) = 2 * (a * c - b * d) := by ring theorem sinh_add : sinh (x + y) = sinh x * cosh y + cosh x * sinh y := by rw [← mul_right_inj' (two_ne_zero' ℂ), two_sinh, exp_add, neg_add, exp_add, eq_comm, mul_add, ← mul_assoc, two_sinh, mul_left_comm, two_sinh, ← mul_right_inj' (two_ne_zero' ℂ), mul_add, mul_left_comm, two_cosh, ← mul_assoc, two_cosh] exact sinh_add_aux @[simp] theorem cosh_zero : cosh 0 = 1 := by simp [cosh] @[simp] theorem cosh_neg : cosh (-x) = cosh x := by simp [add_comm, cosh, exp_neg] private theorem cosh_add_aux {a b c d : ℂ} : (a + b) * (c + d) + (a - b) * (c - d) = 2 * (a * c + b * d) := by ring theorem cosh_add : cosh (x + y) = cosh x * cosh y + sinh x * sinh y := by rw [← mul_right_inj' (two_ne_zero' ℂ), two_cosh, exp_add, neg_add, exp_add, eq_comm, mul_add, ← mul_assoc, two_cosh, ← mul_assoc, two_sinh, ← mul_right_inj' (two_ne_zero' ℂ), mul_add, mul_left_comm, two_cosh, mul_left_comm, two_sinh] exact cosh_add_aux theorem sinh_sub : sinh (x - y) = sinh x * cosh y - cosh x * sinh y := by simp [sub_eq_add_neg, sinh_add, sinh_neg, cosh_neg] theorem cosh_sub : cosh (x - y) = cosh x * cosh y - sinh x * sinh y := by simp [sub_eq_add_neg, cosh_add, sinh_neg, cosh_neg] theorem sinh_conj : sinh (conj x) = conj (sinh x) := by rw [sinh, ← RingHom.map_neg, exp_conj, exp_conj, ← RingHom.map_sub, sinh, map_div₀, map_ofNat] @[simp] theorem ofReal_sinh_ofReal_re (x : ℝ) : ((sinh x).re : ℂ) = sinh x := conj_eq_iff_re.1 <| by rw [← sinh_conj, conj_ofReal] @[simp, norm_cast] theorem ofReal_sinh (x : ℝ) : (Real.sinh x : ℂ) = sinh x := ofReal_sinh_ofReal_re _ @[simp] theorem sinh_ofReal_im (x : ℝ) : (sinh x).im = 0 := by rw [← ofReal_sinh_ofReal_re, ofReal_im] theorem sinh_ofReal_re (x : ℝ) : (sinh x).re = Real.sinh x := rfl theorem cosh_conj : cosh (conj x) = conj (cosh x) := by rw [cosh, ← RingHom.map_neg, exp_conj, exp_conj, ← RingHom.map_add, cosh, map_div₀, map_ofNat] theorem ofReal_cosh_ofReal_re (x : ℝ) : ((cosh x).re : ℂ) = cosh x := conj_eq_iff_re.1 <| by rw [← cosh_conj, conj_ofReal] @[simp, norm_cast] theorem ofReal_cosh (x : ℝ) : (Real.cosh x : ℂ) = cosh x := ofReal_cosh_ofReal_re _ @[simp] theorem cosh_ofReal_im (x : ℝ) : (cosh x).im = 0 := by rw [← ofReal_cosh_ofReal_re, ofReal_im] @[simp] theorem cosh_ofReal_re (x : ℝ) : (cosh x).re = Real.cosh x := rfl theorem tanh_eq_sinh_div_cosh : tanh x = sinh x / cosh x := rfl @[simp] theorem tanh_zero : tanh 0 = 0 := by simp [tanh] @[simp] theorem tanh_neg : tanh (-x) = -tanh x := by simp [tanh, neg_div] theorem tanh_conj : tanh (conj x) = conj (tanh x) := by rw [tanh, sinh_conj, cosh_conj, ← map_div₀, tanh] @[simp] theorem ofReal_tanh_ofReal_re (x : ℝ) : ((tanh x).re : ℂ) = tanh x := conj_eq_iff_re.1 <| by rw [← tanh_conj, conj_ofReal] @[simp, norm_cast] theorem ofReal_tanh (x : ℝ) : (Real.tanh x : ℂ) = tanh x := ofReal_tanh_ofReal_re _ @[simp] theorem tanh_ofReal_im (x : ℝ) : (tanh x).im = 0 := by rw [← ofReal_tanh_ofReal_re, ofReal_im] theorem tanh_ofReal_re (x : ℝ) : (tanh x).re = Real.tanh x := rfl @[simp] theorem cosh_add_sinh : cosh x + sinh x = exp x := by rw [← mul_right_inj' (two_ne_zero' ℂ), mul_add, two_cosh, two_sinh, add_add_sub_cancel, two_mul] @[simp] theorem sinh_add_cosh : sinh x + cosh x = exp x := by rw [add_comm, cosh_add_sinh] @[simp] theorem exp_sub_cosh : exp x - cosh x = sinh x := sub_eq_iff_eq_add.2 (sinh_add_cosh x).symm @[simp] theorem exp_sub_sinh : exp x - sinh x = cosh x := sub_eq_iff_eq_add.2 (cosh_add_sinh x).symm @[simp] theorem cosh_sub_sinh : cosh x - sinh x = exp (-x) := by rw [← mul_right_inj' (two_ne_zero' ℂ), mul_sub, two_cosh, two_sinh, add_sub_sub_cancel, two_mul] @[simp] theorem sinh_sub_cosh : sinh x - cosh x = -exp (-x) := by rw [← neg_sub, cosh_sub_sinh] @[simp] theorem cosh_sq_sub_sinh_sq : cosh x ^ 2 - sinh x ^ 2 = 1 := by rw [sq_sub_sq, cosh_add_sinh, cosh_sub_sinh, ← exp_add, add_neg_cancel, exp_zero] theorem cosh_sq : cosh x ^ 2 = sinh x ^ 2 + 1 := by rw [← cosh_sq_sub_sinh_sq x] ring theorem sinh_sq : sinh x ^ 2 = cosh x ^ 2 - 1 := by rw [← cosh_sq_sub_sinh_sq x] ring theorem cosh_two_mul : cosh (2 * x) = cosh x ^ 2 + sinh x ^ 2 := by rw [two_mul, cosh_add, sq, sq] theorem sinh_two_mul : sinh (2 * x) = 2 * sinh x * cosh x := by rw [two_mul, sinh_add] ring theorem cosh_three_mul : cosh (3 * x) = 4 * cosh x ^ 3 - 3 * cosh x := by have h1 : x + 2 * x = 3 * x := by ring rw [← h1, cosh_add x (2 * x)] simp only [cosh_two_mul, sinh_two_mul] have h2 : sinh x * (2 * sinh x * cosh x) = 2 * cosh x * sinh x ^ 2 := by ring rw [h2, sinh_sq] ring theorem sinh_three_mul : sinh (3 * x) = 4 * sinh x ^ 3 + 3 * sinh x := by have h1 : x + 2 * x = 3 * x := by ring rw [← h1, sinh_add x (2 * x)] simp only [cosh_two_mul, sinh_two_mul] have h2 : cosh x * (2 * sinh x * cosh x) = 2 * sinh x * cosh x ^ 2 := by ring rw [h2, cosh_sq] ring @[simp] theorem sin_zero : sin 0 = 0 := by simp [sin] @[simp] theorem sin_neg : sin (-x) = -sin x := by simp [sin, sub_eq_add_neg, exp_neg, (neg_div _ _).symm, add_mul] theorem two_sin : 2 * sin x = (exp (-x * I) - exp (x * I)) * I := mul_div_cancel₀ _ two_ne_zero theorem two_cos : 2 * cos x = exp (x * I) + exp (-x * I) := mul_div_cancel₀ _ two_ne_zero theorem sinh_mul_I : sinh (x * I) = sin x * I := by rw [← mul_right_inj' (two_ne_zero' ℂ), two_sinh, ← mul_assoc, two_sin, mul_assoc, I_mul_I, mul_neg_one, neg_sub, neg_mul_eq_neg_mul] theorem cosh_mul_I : cosh (x * I) = cos x := by rw [← mul_right_inj' (two_ne_zero' ℂ), two_cosh, two_cos, neg_mul_eq_neg_mul] theorem tanh_mul_I : tanh (x * I) = tan x * I := by rw [tanh_eq_sinh_div_cosh, cosh_mul_I, sinh_mul_I, mul_div_right_comm, tan] theorem cos_mul_I : cos (x * I) = cosh x := by rw [← cosh_mul_I]; ring_nf; simp theorem sin_mul_I : sin (x * I) = sinh x * I := by have h : I * sin (x * I) = -sinh x := by rw [mul_comm, ← sinh_mul_I] ring_nf simp rw [← neg_neg (sinh x), ← h] apply Complex.ext <;> simp theorem tan_mul_I : tan (x * I) = tanh x * I := by rw [tan, sin_mul_I, cos_mul_I, mul_div_right_comm, tanh_eq_sinh_div_cosh] theorem sin_add : sin (x + y) = sin x * cos y + cos x * sin y := by rw [← mul_left_inj' I_ne_zero, ← sinh_mul_I, add_mul, add_mul, mul_right_comm, ← sinh_mul_I, mul_assoc, ← sinh_mul_I, ← cosh_mul_I, ← cosh_mul_I, sinh_add] @[simp] theorem cos_zero : cos 0 = 1 := by simp [cos] @[simp] theorem cos_neg : cos (-x) = cos x := by simp [cos, exp_neg, add_comm] theorem cos_add : cos (x + y) = cos x * cos y - sin x * sin y := by rw [← cosh_mul_I, add_mul, cosh_add, cosh_mul_I, cosh_mul_I, sinh_mul_I, sinh_mul_I, mul_mul_mul_comm, I_mul_I, mul_neg_one, sub_eq_add_neg] theorem sin_sub : sin (x - y) = sin x * cos y - cos x * sin y := by simp [sub_eq_add_neg, sin_add, sin_neg, cos_neg] theorem cos_sub : cos (x - y) = cos x * cos y + sin x * sin y := by simp [sub_eq_add_neg, cos_add, sin_neg, cos_neg] theorem sin_add_mul_I (x y : ℂ) : sin (x + y * I) = sin x * cosh y + cos x * sinh y * I := by rw [sin_add, cos_mul_I, sin_mul_I, mul_assoc] theorem sin_eq (z : ℂ) : sin z = sin z.re * cosh z.im + cos z.re * sinh z.im * I := by convert sin_add_mul_I z.re z.im; exact (re_add_im z).symm theorem cos_add_mul_I (x y : ℂ) : cos (x + y * I) = cos x * cosh y - sin x * sinh y * I := by rw [cos_add, cos_mul_I, sin_mul_I, mul_assoc] theorem cos_eq (z : ℂ) : cos z = cos z.re * cosh z.im - sin z.re * sinh z.im * I := by convert cos_add_mul_I z.re z.im; exact (re_add_im z).symm theorem sin_sub_sin : sin x - sin y = 2 * sin ((x - y) / 2) * cos ((x + y) / 2) := by have s1 := sin_add ((x + y) / 2) ((x - y) / 2) have s2 := sin_sub ((x + y) / 2) ((x - y) / 2) rw [← add_div, add_sub, add_right_comm, add_sub_cancel_right, add_self_div_two] at s1 rw [div_sub_div_same, ← sub_add, add_sub_cancel_left, add_self_div_two] at s2 rw [s1, s2] ring theorem cos_sub_cos : cos x - cos y = -2 * sin ((x + y) / 2) * sin ((x - y) / 2) := by have s1 := cos_add ((x + y) / 2) ((x - y) / 2) have s2 := cos_sub ((x + y) / 2) ((x - y) / 2) rw [← add_div, add_sub, add_right_comm, add_sub_cancel_right, add_self_div_two] at s1 rw [div_sub_div_same, ← sub_add, add_sub_cancel_left, add_self_div_two] at s2 rw [s1, s2] ring theorem sin_add_sin : sin x + sin y = 2 * sin ((x + y) / 2) * cos ((x - y) / 2) := by simpa using sin_sub_sin x (-y) theorem cos_add_cos : cos x + cos y = 2 * cos ((x + y) / 2) * cos ((x - y) / 2) := by calc cos x + cos y = cos ((x + y) / 2 + (x - y) / 2) + cos ((x + y) / 2 - (x - y) / 2) := ?_ _ = cos ((x + y) / 2) * cos ((x - y) / 2) - sin ((x + y) / 2) * sin ((x - y) / 2) + (cos ((x + y) / 2) * cos ((x - y) / 2) + sin ((x + y) / 2) * sin ((x - y) / 2)) := ?_ _ = 2 * cos ((x + y) / 2) * cos ((x - y) / 2) := ?_ · congr <;> field · rw [cos_add, cos_sub] ring theorem sin_conj : sin (conj x) = conj (sin x) := by rw [← mul_left_inj' I_ne_zero, ← sinh_mul_I, ← conj_neg_I, ← RingHom.map_mul, ← RingHom.map_mul, sinh_conj, mul_neg, sinh_neg, sinh_mul_I, mul_neg] @[simp] theorem ofReal_sin_ofReal_re (x : ℝ) : ((sin x).re : ℂ) = sin x := conj_eq_iff_re.1 <| by rw [← sin_conj, conj_ofReal] @[simp, norm_cast] theorem ofReal_sin (x : ℝ) : (Real.sin x : ℂ) = sin x := ofReal_sin_ofReal_re _ @[simp] theorem sin_ofReal_im (x : ℝ) : (sin x).im = 0 := by rw [← ofReal_sin_ofReal_re, ofReal_im] theorem sin_ofReal_re (x : ℝ) : (sin x).re = Real.sin x := rfl theorem cos_conj : cos (conj x) = conj (cos x) := by rw [← cosh_mul_I, ← conj_neg_I, ← RingHom.map_mul, ← cosh_mul_I, cosh_conj, mul_neg, cosh_neg] @[simp] theorem ofReal_cos_ofReal_re (x : ℝ) : ((cos x).re : ℂ) = cos x := conj_eq_iff_re.1 <| by rw [← cos_conj, conj_ofReal] @[simp, norm_cast] theorem ofReal_cos (x : ℝ) : (Real.cos x : ℂ) = cos x := ofReal_cos_ofReal_re _ @[simp] theorem cos_ofReal_im (x : ℝ) : (cos x).im = 0 := by rw [← ofReal_cos_ofReal_re, ofReal_im] theorem cos_ofReal_re (x : ℝ) : (cos x).re = Real.cos x := rfl @[simp] theorem tan_zero : tan 0 = 0 := by simp [tan] theorem tan_eq_sin_div_cos : tan x = sin x / cos x := rfl theorem cot_eq_cos_div_sin : cot x = cos x / sin x := rfl theorem tan_mul_cos {x : ℂ} (hx : cos x ≠ 0) : tan x * cos x = sin x := by rw [tan_eq_sin_div_cos, div_mul_cancel₀ _ hx] @[simp] theorem tan_neg : tan (-x) = -tan x := by simp [tan, neg_div] theorem tan_conj : tan (conj x) = conj (tan x) := by rw [tan, sin_conj, cos_conj, ← map_div₀, tan] theorem cot_conj : cot (conj x) = conj (cot x) := by rw [cot, sin_conj, cos_conj, ← map_div₀, cot] @[simp] theorem ofReal_tan_ofReal_re (x : ℝ) : ((tan x).re : ℂ) = tan x := conj_eq_iff_re.1 <| by rw [← tan_conj, conj_ofReal] @[simp] theorem ofReal_cot_ofReal_re (x : ℝ) : ((cot x).re : ℂ) = cot x := conj_eq_iff_re.1 <| by rw [← cot_conj, conj_ofReal] @[simp, norm_cast] theorem ofReal_tan (x : ℝ) : (Real.tan x : ℂ) = tan x := ofReal_tan_ofReal_re _ @[simp, norm_cast] theorem ofReal_cot (x : ℝ) : (Real.cot x : ℂ) = cot x := ofReal_cot_ofReal_re _ @[simp] theorem tan_ofReal_im (x : ℝ) : (tan x).im = 0 := by rw [← ofReal_tan_ofReal_re, ofReal_im] theorem tan_ofReal_re (x : ℝ) : (tan x).re = Real.tan x := rfl theorem cos_add_sin_I : cos x + sin x * I = exp (x * I) := by rw [← cosh_add_sinh, sinh_mul_I, cosh_mul_I] theorem cos_sub_sin_I : cos x - sin x * I = exp (-x * I) := by rw [neg_mul, ← cosh_sub_sinh, sinh_mul_I, cosh_mul_I] @[simp] theorem sin_sq_add_cos_sq : sin x ^ 2 + cos x ^ 2 = 1 := Eq.trans (by rw [cosh_mul_I, sinh_mul_I, mul_pow, I_sq, mul_neg_one, sub_neg_eq_add, add_comm]) (cosh_sq_sub_sinh_sq (x * I)) @[simp] theorem cos_sq_add_sin_sq : cos x ^ 2 + sin x ^ 2 = 1 := by rw [add_comm, sin_sq_add_cos_sq] theorem cos_two_mul' : cos (2 * x) = cos x ^ 2 - sin x ^ 2 := by rw [two_mul, cos_add, ← sq, ← sq] theorem cos_two_mul : cos (2 * x) = 2 * cos x ^ 2 - 1 := by rw [cos_two_mul', eq_sub_iff_add_eq.2 (sin_sq_add_cos_sq x), ← sub_add, sub_add_eq_add_sub, two_mul] theorem sin_two_mul : sin (2 * x) = 2 * sin x * cos x := by rw [two_mul, sin_add, two_mul, add_mul, mul_comm] theorem cos_sq : cos x ^ 2 = 1 / 2 + cos (2 * x) / 2 := by simp [cos_two_mul, ← add_div, mul_div_cancel_left₀, -one_div] theorem cos_sq' : cos x ^ 2 = 1 - sin x ^ 2 := by rw [← sin_sq_add_cos_sq x, add_sub_cancel_left] theorem sin_sq : sin x ^ 2 = 1 - cos x ^ 2 := by rw [← sin_sq_add_cos_sq x, add_sub_cancel_right] theorem one_add_tan_sq_mul_cos_sq_eq_one {x : ℂ} (h : cos x ≠ 0) : (1 + tan x ^ 2) * cos x ^ 2 = 1 := by conv_rhs => rw [← sin_sq_add_cos_sq x, ← tan_mul_cos h] ring theorem inv_one_add_tan_sq {x : ℂ} (hx : cos x ≠ 0) : (1 + tan x ^ 2)⁻¹ = cos x ^ 2 := by rw [tan_eq_sin_div_cos, div_pow] simp [field] theorem tan_sq_div_one_add_tan_sq {x : ℂ} (hx : cos x ≠ 0) : tan x ^ 2 / (1 + tan x ^ 2) = sin x ^ 2 := by simp only [← tan_mul_cos hx, mul_pow, ← inv_one_add_tan_sq hx, div_eq_mul_inv] theorem cos_three_mul : cos (3 * x) = 4 * cos x ^ 3 - 3 * cos x := by have h1 : x + 2 * x = 3 * x := by ring rw [← h1, cos_add x (2 * x)] simp only [cos_two_mul, sin_two_mul, mul_sub, mul_one, sq] have h2 : 4 * cos x ^ 3 = 2 * cos x * cos x * cos x + 2 * cos x * cos x ^ 2 := by ring rw [h2, cos_sq'] ring theorem sin_three_mul : sin (3 * x) = 3 * sin x - 4 * sin x ^ 3 := by have h1 : x + 2 * x = 3 * x := by ring rw [← h1, sin_add x (2 * x)] simp only [cos_two_mul, sin_two_mul, cos_sq'] have h2 : cos x * (2 * sin x * cos x) = 2 * sin x * cos x ^ 2 := by ring rw [h2, cos_sq'] ring theorem exp_mul_I : exp (x * I) = cos x + sin x * I := (cos_add_sin_I _).symm theorem exp_add_mul_I : exp (x + y * I) = exp x * (cos y + sin y * I) := by rw [exp_add, exp_mul_I] theorem exp_eq_exp_re_mul_sin_add_cos : exp x = exp x.re * (cos x.im + sin x.im * I) := by rw [← exp_add_mul_I, re_add_im] theorem exp_re : (exp x).re = Real.exp x.re * Real.cos x.im := by rw [exp_eq_exp_re_mul_sin_add_cos] simp [exp_ofReal_re, cos_ofReal_re] theorem exp_im : (exp x).im = Real.exp x.re * Real.sin x.im := by rw [exp_eq_exp_re_mul_sin_add_cos] simp [exp_ofReal_re, sin_ofReal_re] @[simp] theorem exp_ofReal_mul_I_re (x : ℝ) : (exp (x * I)).re = Real.cos x := by simp [exp_mul_I, cos_ofReal_re] @[simp] theorem exp_ofReal_mul_I_im (x : ℝ) : (exp (x * I)).im = Real.sin x := by simp [exp_mul_I, sin_ofReal_re] /-- **De Moivre's formula** -/ theorem cos_add_sin_mul_I_pow (n : ℕ) (z : ℂ) : (cos z + sin z * I) ^ n = cos (↑n * z) + sin (↑n * z) * I := by rw [← exp_mul_I, ← exp_mul_I, ← exp_nat_mul, mul_assoc] end Complex namespace Real open Complex variable (x y : ℝ) @[simp] theorem sin_zero : sin 0 = 0 := by simp [sin] @[simp] theorem sin_neg : sin (-x) = -sin x := by simp [sin] nonrec theorem sin_add : sin (x + y) = sin x * cos y + cos x * sin y := ofReal_injective <| by simp [sin_add] @[simp] theorem cos_zero : cos 0 = 1 := by simp [cos] @[simp] theorem cos_neg : cos (-x) = cos x := by simp [cos] @[simp] theorem cos_abs : cos |x| = cos x := by cases le_total x 0 <;> simp only [*, abs_of_nonneg, abs_of_nonpos, cos_neg] nonrec theorem cos_add : cos (x + y) = cos x * cos y - sin x * sin y := ofReal_injective <| by simp [cos_add] theorem sin_sub : sin (x - y) = sin x * cos y - cos x * sin y := by simp [sub_eq_add_neg, sin_add, sin_neg, cos_neg] theorem cos_sub : cos (x - y) = cos x * cos y + sin x * sin y := by simp [sub_eq_add_neg, cos_add, sin_neg, cos_neg] nonrec theorem sin_add_sin : sin x + sin y = 2 * sin ((x + y) / 2) * cos ((x - y) / 2) := ofReal_injective <| by simp [sin_add_sin] nonrec theorem sin_sub_sin : sin x - sin y = 2 * sin ((x - y) / 2) * cos ((x + y) / 2) := ofReal_injective <| by simp [sin_sub_sin] nonrec theorem cos_add_cos : cos x + cos y = 2 * cos ((x + y) / 2) * cos ((x - y) / 2) := ofReal_injective <| by simp [cos_add_cos] nonrec theorem cos_sub_cos : cos x - cos y = -2 * sin ((x + y) / 2) * sin ((x - y) / 2) := ofReal_injective <| by simp [cos_sub_cos] theorem two_mul_sin_mul_sin (x y : ℝ) : 2 * sin x * sin y = cos (x - y) - cos (x + y) := by simp [cos_add, cos_sub] ring theorem two_mul_cos_mul_cos (x y : ℝ) : 2 * cos x * cos y = cos (x - y) + cos (x + y) := by simp [cos_add, cos_sub] ring theorem two_mul_sin_mul_cos (x y : ℝ) : 2 * sin x * cos y = sin (x - y) + sin (x + y) := by simp [sin_add, sin_sub] ring nonrec theorem tan_eq_sin_div_cos : tan x = sin x / cos x := ofReal_injective <| by simp only [ofReal_tan, tan_eq_sin_div_cos, ofReal_div, ofReal_sin, ofReal_cos] nonrec theorem cot_eq_cos_div_sin : cot x = cos x / sin x := ofReal_injective <| by simp [cot_eq_cos_div_sin] theorem tan_mul_cos {x : ℝ} (hx : cos x ≠ 0) : tan x * cos x = sin x := by rw [tan_eq_sin_div_cos, div_mul_cancel₀ _ hx] @[simp] theorem tan_zero : tan 0 = 0 := by simp [tan] @[simp] theorem tan_neg : tan (-x) = -tan x := by simp [tan] @[simp] nonrec theorem sin_sq_add_cos_sq : sin x ^ 2 + cos x ^ 2 = 1 := ofReal_injective (by simp [sin_sq_add_cos_sq]) @[simp] theorem cos_sq_add_sin_sq : cos x ^ 2 + sin x ^ 2 = 1 := by rw [add_comm, sin_sq_add_cos_sq] theorem sin_sq_le_one : sin x ^ 2 ≤ 1 := by rw [← sin_sq_add_cos_sq x]; exact le_add_of_nonneg_right (sq_nonneg _) theorem cos_sq_le_one : cos x ^ 2 ≤ 1 := by rw [← sin_sq_add_cos_sq x]; exact le_add_of_nonneg_left (sq_nonneg _) theorem abs_sin_le_one : |sin x| ≤ 1 := abs_le_one_iff_mul_self_le_one.2 <| by simp only [← sq, sin_sq_le_one] theorem abs_cos_le_one : |cos x| ≤ 1 := abs_le_one_iff_mul_self_le_one.2 <| by simp only [← sq, cos_sq_le_one] theorem sin_le_one : sin x ≤ 1 := (abs_le.1 (abs_sin_le_one _)).2 theorem cos_le_one : cos x ≤ 1 := (abs_le.1 (abs_cos_le_one _)).2 theorem neg_one_le_sin : -1 ≤ sin x := (abs_le.1 (abs_sin_le_one _)).1 theorem neg_one_le_cos : -1 ≤ cos x := (abs_le.1 (abs_cos_le_one _)).1 nonrec theorem cos_two_mul : cos (2 * x) = 2 * cos x ^ 2 - 1 := ofReal_injective <| by simp [cos_two_mul] nonrec theorem cos_two_mul' : cos (2 * x) = cos x ^ 2 - sin x ^ 2 := ofReal_injective <| by simp [cos_two_mul'] nonrec theorem sin_two_mul : sin (2 * x) = 2 * sin x * cos x := ofReal_injective <| by simp [sin_two_mul] nonrec theorem cos_sq : cos x ^ 2 = 1 / 2 + cos (2 * x) / 2 := ofReal_injective <| by simp [cos_sq] theorem cos_sq' : cos x ^ 2 = 1 - sin x ^ 2 := by rw [← sin_sq_add_cos_sq x, add_sub_cancel_left] theorem sin_sq : sin x ^ 2 = 1 - cos x ^ 2 := eq_sub_iff_add_eq.2 <| sin_sq_add_cos_sq _ lemma sin_sq_eq_half_sub : sin x ^ 2 = 1 / 2 - cos (2 * x) / 2 := by rw [sin_sq, cos_sq, ← sub_sub, sub_half] theorem abs_sin_eq_sqrt_one_sub_cos_sq (x : ℝ) : |sin x| = √(1 - cos x ^ 2) := by rw [← sin_sq, sqrt_sq_eq_abs] theorem abs_cos_eq_sqrt_one_sub_sin_sq (x : ℝ) : |cos x| = √(1 - sin x ^ 2) := by rw [← cos_sq', sqrt_sq_eq_abs] theorem one_add_tan_sq_mul_cos_sq_eq_one {x : ℝ} (h : cos x ≠ 0) : (1 + tan x ^ 2) * cos x ^ 2 = 1 := mod_cast @Complex.one_add_tan_sq_mul_cos_sq_eq_one x (mod_cast h) theorem inv_one_add_tan_sq {x : ℝ} (hx : cos x ≠ 0) : (1 + tan x ^ 2)⁻¹ = cos x ^ 2 := have : Complex.cos x ≠ 0 := mt (congr_arg re) hx ofReal_inj.1 <| by simpa using Complex.inv_one_add_tan_sq this theorem tan_sq_div_one_add_tan_sq {x : ℝ} (hx : cos x ≠ 0) : tan x ^ 2 / (1 + tan x ^ 2) = sin x ^ 2 := by simp only [← tan_mul_cos hx, mul_pow, ← inv_one_add_tan_sq hx, div_eq_mul_inv] theorem inv_sqrt_one_add_tan_sq {x : ℝ} (hx : 0 < cos x) : (√(1 + tan x ^ 2))⁻¹ = cos x := by rw [← sqrt_sq hx.le, ← sqrt_inv, inv_one_add_tan_sq hx.ne'] theorem tan_div_sqrt_one_add_tan_sq {x : ℝ} (hx : 0 < cos x) : tan x / √(1 + tan x ^ 2) = sin x := by rw [← tan_mul_cos hx.ne', ← inv_sqrt_one_add_tan_sq hx, div_eq_mul_inv] nonrec theorem cos_three_mul : cos (3 * x) = 4 * cos x ^ 3 - 3 * cos x := by rw [← ofReal_inj]; simp [cos_three_mul] nonrec theorem sin_three_mul : sin (3 * x) = 3 * sin x - 4 * sin x ^ 3 := by rw [← ofReal_inj]; simp [sin_three_mul] /-- The definition of `sinh` in terms of `exp`. -/ nonrec theorem sinh_eq (x : ℝ) : sinh x = (exp x - exp (-x)) / 2 := ofReal_injective <| by simp [Complex.sinh] @[simp] theorem sinh_zero : sinh 0 = 0 := by simp [sinh] @[simp] theorem sinh_neg : sinh (-x) = -sinh x := by simp [sinh] nonrec theorem sinh_add : sinh (x + y) = sinh x * cosh y + cosh x * sinh y := by rw [← ofReal_inj]; simp [sinh_add] /-- The definition of `cosh` in terms of `exp`. -/ theorem cosh_eq (x : ℝ) : cosh x = (exp x + exp (-x)) / 2 := eq_div_of_mul_eq two_ne_zero <| by rw [cosh, exp, exp, Complex.ofReal_neg, Complex.cosh, mul_two, ← Complex.add_re, ← mul_two, div_mul_cancel₀ _ (two_ne_zero' ℂ), Complex.add_re] @[simp] theorem cosh_zero : cosh 0 = 1 := by simp [cosh] @[simp] theorem cosh_neg : cosh (-x) = cosh x := ofReal_inj.1 <| by simp @[simp] theorem cosh_abs : cosh |x| = cosh x := by cases le_total x 0 <;> simp [*, abs_of_nonneg, abs_of_nonpos] nonrec theorem cosh_add : cosh (x + y) = cosh x * cosh y + sinh x * sinh y := by rw [← ofReal_inj]; simp [cosh_add] theorem sinh_sub : sinh (x - y) = sinh x * cosh y - cosh x * sinh y := by simp [sub_eq_add_neg, sinh_add, sinh_neg, cosh_neg] theorem cosh_sub : cosh (x - y) = cosh x * cosh y - sinh x * sinh y := by simp [sub_eq_add_neg, cosh_add, sinh_neg, cosh_neg] nonrec theorem tanh_eq_sinh_div_cosh : tanh x = sinh x / cosh x := ofReal_inj.1 <| by simp [tanh_eq_sinh_div_cosh] @[simp] theorem tanh_zero : tanh 0 = 0 := by simp [tanh] @[simp] theorem tanh_neg : tanh (-x) = -tanh x := by simp [tanh] @[simp] theorem cosh_add_sinh : cosh x + sinh x = exp x := by rw [← ofReal_inj]; simp @[simp] theorem sinh_add_cosh : sinh x + cosh x = exp x := by rw [add_comm, cosh_add_sinh] @[simp] theorem exp_sub_cosh : exp x - cosh x = sinh x := sub_eq_iff_eq_add.2 (sinh_add_cosh x).symm @[simp] theorem exp_sub_sinh : exp x - sinh x = cosh x := sub_eq_iff_eq_add.2 (cosh_add_sinh x).symm @[simp] theorem cosh_sub_sinh : cosh x - sinh x = exp (-x) := by rw [← ofReal_inj] simp @[simp] theorem sinh_sub_cosh : sinh x - cosh x = -exp (-x) := by rw [← neg_sub, cosh_sub_sinh] @[simp] theorem cosh_sq_sub_sinh_sq (x : ℝ) : cosh x ^ 2 - sinh x ^ 2 = 1 := by rw [← ofReal_inj]; simp nonrec theorem cosh_sq : cosh x ^ 2 = sinh x ^ 2 + 1 := by rw [← ofReal_inj]; simp [cosh_sq] theorem cosh_sq' : cosh x ^ 2 = 1 + sinh x ^ 2 := (cosh_sq x).trans (add_comm _ _) nonrec theorem sinh_sq : sinh x ^ 2 = cosh x ^ 2 - 1 := by rw [← ofReal_inj]; simp [sinh_sq] nonrec theorem cosh_two_mul : cosh (2 * x) = cosh x ^ 2 + sinh x ^ 2 := by rw [← ofReal_inj]; simp [cosh_two_mul] nonrec theorem sinh_two_mul : sinh (2 * x) = 2 * sinh x * cosh x := by rw [← ofReal_inj]; simp [sinh_two_mul] nonrec theorem cosh_three_mul : cosh (3 * x) = 4 * cosh x ^ 3 - 3 * cosh x := by rw [← ofReal_inj]; simp [cosh_three_mul] nonrec theorem sinh_three_mul : sinh (3 * x) = 4 * sinh x ^ 3 + 3 * sinh x := by rw [← ofReal_inj]; simp [sinh_three_mul] open IsAbsoluteValue Nat /-- `Real.cosh` is always positive -/ theorem cosh_pos (x : ℝ) : 0 < Real.cosh x := (cosh_eq x).symm ▸ half_pos (add_pos (exp_pos x) (exp_pos (-x))) theorem sinh_lt_cosh : sinh x < cosh x := lt_of_pow_lt_pow_left₀ 2 (cosh_pos _).le <| (cosh_sq x).symm ▸ lt_add_one _ end Real namespace Real open Complex Finset theorem cos_bound {x : ℝ} (hx : |x| ≤ 1) : |cos x - (1 - x ^ 2 / 2)| ≤ |x| ^ 4 * (5 / 96) := calc |cos x - (1 - x ^ 2 / 2)| = ‖Complex.cos x - (1 - (x : ℂ) ^ 2 / 2)‖ := by rw [← Real.norm_eq_abs, ← norm_real]; simp _ = ‖(Complex.exp (x * I) + Complex.exp (-x * I) - (2 - (x : ℂ) ^ 2)) / 2‖ := by simp [Complex.cos, sub_div, add_div] _ = ‖((Complex.exp (x * I) - ∑ m ∈ range 4, (x * I) ^ m / m.factorial) + (Complex.exp (-x * I) - ∑ m ∈ range 4, (-x * I) ^ m / m.factorial)) / 2‖ := (congr_arg (‖·‖ : ℂ → ℝ) (congr_arg (fun x : ℂ => x / 2) (by simp only [neg_mul, pow_succ, pow_zero, sum_range_succ, range_zero, sum_empty, Nat.factorial, Nat.cast_succ, zero_add, mul_one, Nat.mul_one, mul_neg, neg_neg] apply Complex.ext <;> simp [div_eq_mul_inv, normSq] <;> ring_nf))) _ ≤ ‖(Complex.exp (x * I) - ∑ m ∈ range 4, (x * I) ^ m / m.factorial) / 2‖ + ‖(Complex.exp (-x * I) - ∑ m ∈ range 4, (-x * I) ^ m / m.factorial) / 2‖ := by rw [add_div]; exact norm_add_le _ _ _ = ‖Complex.exp (x * I) - ∑ m ∈ range 4, (x * I) ^ m / m.factorial‖ / 2 + ‖Complex.exp (-x * I) - ∑ m ∈ range 4, (-x * I) ^ m / m.factorial‖ / 2 := by simp _ ≤ ‖x * I‖ ^ 4 * (Nat.succ 4 * ((Nat.factorial 4) * (4 : ℕ) : ℝ)⁻¹) / 2 + ‖-x * I‖ ^ 4 * (Nat.succ 4 * ((Nat.factorial 4) * (4 : ℕ) : ℝ)⁻¹) / 2 := by gcongr · exact Complex.exp_bound (by simpa) (by decide) · exact Complex.exp_bound (by simpa) (by decide) _ ≤ |x| ^ 4 * (5 / 96) := by norm_num [Nat.factorial] theorem sin_bound {x : ℝ} (hx : |x| ≤ 1) : |sin x - (x - x ^ 3 / 6)| ≤ |x| ^ 4 * (5 / 96) := calc |sin x - (x - x ^ 3 / 6)| = ‖Complex.sin x - (x - x ^ 3 / 6 : ℝ)‖ := by rw [← Real.norm_eq_abs, ← norm_real]; simp _ = ‖((Complex.exp (-x * I) - Complex.exp (x * I)) * I - (2 * x - x ^ 3 / 3 : ℝ)) / 2‖ := by simp [Complex.sin, sub_div, mul_div_cancel_left₀ _ (two_ne_zero' ℂ), div_div, show (3 : ℂ) * 2 = 6 by norm_num] _ = ‖((Complex.exp (-x * I) - ∑ m ∈ range 4, (-x * I) ^ m / m.factorial) - (Complex.exp (x * I) - ∑ m ∈ range 4, (x * I) ^ m / m.factorial)) * I / 2‖ := (congr_arg (‖·‖ : ℂ → ℝ) (congr_arg (fun x : ℂ => x / 2) (by simp only [neg_mul, pow_succ, pow_zero, ofReal_sub, ofReal_mul, ofReal_ofNat, ofReal_div, sum_range_succ, range_zero, sum_empty, Nat.factorial, Nat.cast_succ, zero_add, mul_neg, mul_one, neg_neg, Nat.mul_one] apply Complex.ext <;> simp [div_eq_mul_inv, normSq]; ring))) _ ≤ ‖(Complex.exp (-x * I) - ∑ m ∈ range 4, (-x * I) ^ m / m.factorial) * I / 2‖ + ‖-((Complex.exp (x * I) - ∑ m ∈ range 4, (x * I) ^ m / m.factorial) * I) / 2‖ := by rw [sub_mul, sub_eq_add_neg, add_div]; exact norm_add_le _ _ _ = ‖Complex.exp (x * I) - ∑ m ∈ range 4, (x * I) ^ m / m.factorial‖ / 2 + ‖Complex.exp (-x * I) - ∑ m ∈ range 4, (-x * I) ^ m / m.factorial‖ / 2 := by simp [add_comm] _ ≤ ‖x * I‖ ^ 4 * (Nat.succ 4 * (Nat.factorial 4 * (4 : ℕ) : ℝ)⁻¹) / 2 + ‖-x * I‖ ^ 4 * (Nat.succ 4 * (Nat.factorial 4 * (4 : ℕ) : ℝ)⁻¹) / 2 := by gcongr · exact Complex.exp_bound (by simpa) (by decide) · exact Complex.exp_bound (by simpa) (by decide) _ ≤ |x| ^ 4 * (5 / 96) := by norm_num [Nat.factorial] theorem cos_pos_of_le_one {x : ℝ} (hx : |x| ≤ 1) : 0 < cos x := calc 0 < 1 - x ^ 2 / 2 - |x| ^ 4 * (5 / 96) := sub_pos.2 <| lt_sub_iff_add_lt.2 (calc |x| ^ 4 * (5 / 96) + x ^ 2 / 2 ≤ 1 * (5 / 96) + 1 / 2 := by gcongr · exact pow_le_one₀ (abs_nonneg _) hx · rw [sq, ← abs_mul_self, abs_mul] exact mul_le_one₀ hx (abs_nonneg _) hx _ < 1 := by norm_num) _ ≤ cos x := sub_le_comm.1 (abs_sub_le_iff.1 (cos_bound hx)).2 theorem sin_pos_of_pos_of_le_one {x : ℝ} (hx0 : 0 < x) (hx : x ≤ 1) : 0 < sin x := calc 0 < x - x ^ 3 / 6 - |x| ^ 4 * (5 / 96) := sub_pos.2 <| lt_sub_iff_add_lt.2 (calc |x| ^ 4 * (5 / 96) + x ^ 3 / 6 ≤ x * (5 / 96) + x / 6 := by gcongr · calc |x| ^ 4 ≤ |x| ^ 1 := pow_le_pow_of_le_one (abs_nonneg _) (by rwa [abs_of_nonneg (le_of_lt hx0)]) (by decide) _ = x := by simp [abs_of_nonneg (le_of_lt hx0)] · calc x ^ 3 ≤ x ^ 1 := pow_le_pow_of_le_one (le_of_lt hx0) hx (by decide) _ = x := pow_one _ _ < x := by linarith) _ ≤ sin x := sub_le_comm.1 (abs_sub_le_iff.1 (sin_bound (by rwa [abs_of_nonneg (le_of_lt hx0)]))).2 theorem sin_pos_of_pos_of_le_two {x : ℝ} (hx0 : 0 < x) (hx : x ≤ 2) : 0 < sin x := have : x / 2 ≤ 1 := (div_le_iff₀ (by simp)).mpr (by simpa) calc 0 < 2 * sin (x / 2) * cos (x / 2) := mul_pos (mul_pos (by simp) (sin_pos_of_pos_of_le_one (half_pos hx0) this)) (cos_pos_of_le_one (by rwa [abs_of_nonneg (le_of_lt (half_pos hx0))])) _ = sin x := by rw [← sin_two_mul, two_mul, add_halves] theorem cos_one_le : cos 1 ≤ 5 / 9 := calc cos 1 ≤ |(1 : ℝ)| ^ 4 * (5 / 96) + (1 - 1 ^ 2 / 2) := sub_le_iff_le_add.1 (abs_sub_le_iff.1 (cos_bound (by simp))).1 _ ≤ 5 / 9 := by norm_num theorem cos_one_pos : 0 < cos 1 := cos_pos_of_le_one (le_of_eq abs_one) theorem cos_two_neg : cos 2 < 0 := calc cos 2 = cos (2 * 1) := congr_arg cos (mul_one _).symm _ = _ := Real.cos_two_mul 1 _ ≤ 2 * (5 / 9) ^ 2 - 1 := by gcongr · exact cos_one_pos.le · apply cos_one_le _ < 0 := by norm_num end Real namespace Mathlib.Meta.Positivity open Lean.Meta Qq /-- Extension for the `positivity` tactic: `Real.cosh` is always positive. -/ @[positivity Real.cosh _] def evalCosh : PositivityExt where eval {u α} _ _ e := do match u, α, e with | 0, ~q(ℝ), ~q(Real.cosh $a) => assertInstancesCommute return .positive q(Real.cosh_pos $a) | _, _, _ => throwError "not Real.cosh" example (x : ℝ) : 0 < x.cosh := by positivity end Mathlib.Meta.Positivity namespace Complex @[simp] theorem norm_cos_add_sin_mul_I (x : ℝ) : ‖cos x + sin x * I‖ = 1 := by have := Real.sin_sq_add_cos_sq x simp_all [add_comm, norm_def, normSq, sq, sin_ofReal_re, cos_ofReal_re, mul_re] @[simp] theorem norm_exp_ofReal_mul_I (x : ℝ) : ‖exp (x * I)‖ = 1 := by rw [exp_mul_I, norm_cos_add_sin_mul_I] @[simp] theorem norm_exp_I_mul_ofReal (x : ℝ) : ‖exp (I * x)‖ = 1 := by rw [mul_comm, norm_exp_ofReal_mul_I] @[simp] theorem nnnorm_exp_ofReal_mul_I (x : ℝ) : ‖exp (x * I)‖₊ = 1 := by rw [← nnnorm_norm, norm_exp_ofReal_mul_I, ← NNReal.coe_eq_one]; simp @[simp] theorem nnnorm_exp_I_mul_ofReal (x : ℝ) : ‖exp (I * x)‖₊ = 1 := by rw [← nnnorm_norm, norm_exp_I_mul_ofReal, ← NNReal.coe_eq_one]; simp @[simp] theorem enorm_exp_ofReal_mul_I (x : ℝ) : ‖exp (x * I)‖ₑ = 1 := by simp [← ENNReal.toReal_eq_one_iff] @[simp] theorem enorm_exp_I_mul_ofReal (x : ℝ) : ‖exp (I * x)‖ₑ = 1 := by simp [← ENNReal.toReal_eq_one_iff] theorem norm_exp_I_mul_ofReal_sub_one (x : ℝ) : ‖exp (I * x) - 1‖ = ‖2 * Real.sin (x / 2)‖ := by rw [show ‖2 * Real.sin (x / 2)‖ = ‖2 * sin (x / 2)‖ by norm_cast, two_sin] nth_rw 2 [← one_mul (_ - _), ← exp_zero] rw [← neg_add_cancel (x / 2 * I), exp_add, mul_assoc _ _ (_ - _), mul_sub, ← exp_add, ← exp_add, ← add_mul, ← add_mul]; norm_cast rw [add_neg_cancel, ofReal_zero, zero_mul, exp_zero, add_halves, ← neg_mul, Complex.norm_mul, norm_I, mul_one, Complex.norm_mul, show -(ofReal (x / 2)) = ofReal (-x / 2) by norm_cast; exact neg_div' 2 x, norm_exp_ofReal_mul_I, one_mul, ← norm_neg, neg_sub, mul_comm] theorem norm_exp (z : ℂ) : ‖exp z‖ = Real.exp z.re := by rw [exp_eq_exp_re_mul_sin_add_cos, Complex.norm_mul, norm_exp_ofReal, norm_cos_add_sin_mul_I, mul_one] theorem norm_exp_eq_iff_re_eq {x y : ℂ} : ‖exp x‖ = ‖exp y‖ ↔ x.re = y.re := by rw [norm_exp, norm_exp, Real.exp_eq_exp] end Complex
.lake/packages/mathlib/Mathlib/Analysis/Complex/JensenFormula.lean
import Mathlib.Analysis.SpecialFunctions.Integrals.PosLogEqCircleAverage /-! # Jensen's Formula of Complex Analysis If a function `g : ℂ → ℂ` is analytic without zero on the closed ball with center `c` and radius `R`, then `log ‖g ·‖` is harmonic, and the mean value theorem of harmonic functions asserts that the circle average `circleAverage (log ‖g ·‖) c R` equals `log ‖g c‖`. Note that `g c` equals `meromorphicTrailingCoeffAt g c` and see `AnalyticOnNhd.circleAverage_log_norm_of_ne_zero` for the precise statement. Jensen's Formula, formulated in `MeromorphicOn.circleAverage_log_norm` below, generalizes this to the setting where `g` is merely meromorphic. In that case, the `circleAverage (log ‖g ·‖) c R` equals `log ‖meromorphicTrailingCoeffAt g c‖` plus a correction term that accounts for the zeros and poles of `g` within the ball. -/ open Filter MeromorphicAt MeromorphicOn Metric Real /-! ## Preparatory Material In preparation to the proof of Jensen's formula, compute several circle averages and reformulate some of the terms that appear in the formula and its proof. -/ /-- Let `D : ℂ → ℤ` be a function with locally finite support within the closed ball with center `c` and radius `R`, such as the zero- and pole divisor of a meromorphic function. Then, the circle average of the function `∑ᶠ u, (D u * log ‖· - u‖)` over the boundary of the ball equals `∑ᶠ u, D u * log R`. -/ @[simp] lemma circleAverage_log_norm_factorizedRational {R : ℝ} {c : ℂ} (D : Function.locallyFinsuppWithin (closedBall c |R|) ℤ) : circleAverage (∑ᶠ u, (D u * log ‖· - u‖)) c R = ∑ᶠ u, D u * log R := by have h := D.finiteSupport (isCompact_closedBall c |R|) calc circleAverage (∑ᶠ u, (D u * log ‖· - u‖)) c R _ = circleAverage (∑ u ∈ h.toFinset, (D u * log ‖· - u‖)) c R := by rw [finsum_eq_sum_of_support_subset] intro u contrapose aesop _ = ∑ i ∈ h.toFinset, circleAverage (fun x ↦ D i * log ‖x - i‖) c R := by rw [circleAverage_sum] intro u hu apply IntervalIntegrable.const_mul apply circleIntegrable_log_norm_meromorphicOn (f := (· - u)) apply (analyticOnNhd_id.sub analyticOnNhd_const).meromorphicOn _ = ∑ u ∈ h.toFinset, D u * log R := by apply Finset.sum_congr rfl intro u hu simp_rw [← smul_eq_mul, circleAverage_fun_smul] congr rw [circleAverage_log_norm_sub_const_of_mem_closedBall] apply D.supportWithinDomain simp_all _ = ∑ᶠ u, D u * log R := by rw [finsum_eq_sum_of_support_subset] intro u aesop /-- If `g : ℂ → ℂ` is analytic without zero on the closed ball with center `c` and radius `R`, then the circle average `circleAverage (log ‖g ·‖) c R` equals `log ‖g c‖`. -/ @[simp] lemma AnalyticOnNhd.circleAverage_log_norm_of_ne_zero {R : ℝ} {c : ℂ} {g : ℂ → ℂ} (h₁g : AnalyticOnNhd ℂ g (closedBall c |R|)) (h₂g : ∀ u ∈ closedBall c |R|, g u ≠ 0) : circleAverage (Real.log ‖g ·‖) c R = Real.log ‖g c‖ := HarmonicOnNhd.circleAverage_eq (fun x hx ↦ (h₁g x hx).harmonicAt_log_norm (h₂g x hx)) /-- Reformulation of a finsum that appears in Jensen's formula and in the definition of the counting function of Value Distribution Theory, as discussed in `Mathlib/Analysis/Complex/ValueDistribution/CountingFunction.lean`. -/ lemma countingFunction_finsum_eq_finsum_add {c : ℂ} {R : ℝ} {D : ℂ → ℤ} (hR : R ≠ 0) (hD : D.support.Finite) : ∑ᶠ u, D u * (log R - log ‖c - u‖) = ∑ᶠ u, D u * log (R * ‖c - u‖⁻¹) + D c * log R := by by_cases h : c ∈ D.support · have {g : ℂ → ℝ} : (fun u ↦ D u * g u).support ⊆ hD.toFinset := fun x ↦ by simp +contextual simp only [finsum_eq_sum_of_support_subset _ this, Finset.sum_eq_sum_diff_singleton_add ((Set.Finite.mem_toFinset hD).mpr h), sub_self, norm_zero, log_zero, sub_zero, inv_zero, mul_zero, add_zero, add_left_inj] refine Finset.sum_congr rfl fun x hx ↦ ?_ simp only [Finset.mem_sdiff, Finset.notMem_singleton] at hx rw [log_mul hR (inv_ne_zero (norm_ne_zero_iff.mpr (sub_eq_zero.not.2 hx.2.symm))), log_inv] ring · simp_all only [Function.mem_support, Decidable.not_not, Int.cast_zero, zero_mul, add_zero] refine finsum_congr fun x ↦ ?_ by_cases h₁ : c = x · simp_all · rw [log_mul hR (inv_ne_zero (norm_ne_zero_iff.mpr (sub_eq_zero.not.2 h₁))), log_inv] ring /-! ## Jensen's Formula -/ /-! **Jensen's Formula**: If `f : ℂ → ℂ` is meromorphic on the closed ball with center `c` and radius `R`, then the `circleAverage (log ‖f ·‖) c R` equals `log ‖meromorphicTrailingCoeffAt f c‖` plus a correction term that accounts for the zeros and poles of `f` within the ball. -/ theorem MeromorphicOn.circleAverage_log_norm {c : ℂ} {R : ℝ} {f : ℂ → ℂ} (hR : R ≠ 0) (h₁f : MeromorphicOn f (closedBall c |R|)) : circleAverage (log ‖f ·‖) c R = ∑ᶠ u, divisor f (closedBall c |R|) u * log (R * ‖c - u‖⁻¹) + divisor f (closedBall c |R|) c * log R + log ‖meromorphicTrailingCoeffAt f c‖ := by -- Shorthand notation to keep line size in check let CB := closedBall c |R| by_cases h₂f : ∀ u ∈ CB, meromorphicOrderAt f u ≠ ⊤ · have h₃f := (divisor f CB).finiteSupport (isCompact_closedBall c |R|) -- Extract zeros & poles and compute obtain ⟨g, h₁g, h₂g, h₃g⟩ := h₁f.extract_zeros_poles (by simp_all) h₃f calc circleAverage (log ‖f ·‖) c R _ = circleAverage ((∑ᶠ u, (divisor f CB u * log ‖· - u‖)) + (log ‖g ·‖)) c R := by have h₄g := extract_zeros_poles_log h₂g h₃g rw [circleAverage_congr_codiscreteWithin (codiscreteWithin.mono sphere_subset_closedBall h₄g) hR] _ = circleAverage (∑ᶠ u, (divisor f CB u * log ‖· - u‖)) c R + circleAverage (log ‖g ·‖) c R := circleAverage_add (circleIntegrable_log_norm_factorizedRational (divisor f CB)) (circleIntegrable_log_norm_meromorphicOn (h₁g.mono sphere_subset_closedBall).meromorphicOn) _ = ∑ᶠ u, divisor f CB u * log R + log ‖g c‖ := by simp [h₁g] rw [h₁g.circleAverage_log_norm_of_ne_zero] exact fun u hu ↦ h₂g ⟨u, hu⟩ _ = ∑ᶠ u, divisor f CB u * log R + (log ‖meromorphicTrailingCoeffAt f c‖ - ∑ᶠ u, divisor f CB u * log ‖c - u‖) := by have t₀ : c ∈ CB := by simp [CB] have t₁ : AccPt c (𝓟 CB) := by apply accPt_iff_frequently_nhdsNE.mpr apply compl_notMem apply mem_nhdsWithin.mpr use ball c |R| simpa [hR] using fun _ ⟨h, _⟩ ↦ ball_subset_closedBall h simp [MeromorphicOn.log_norm_meromorphicTrailingCoeffAt_extract_zeros_poles h₃f t₀ t₁ (h₁f c t₀) (h₁g c t₀) (h₂g ⟨c, t₀⟩) h₃g] _ = ∑ᶠ u, divisor f CB u * log R - ∑ᶠ u, divisor f CB u * log ‖c - u‖ + log ‖meromorphicTrailingCoeffAt f c‖ := by ring _ = (∑ᶠ u, divisor f CB u * (log R - log ‖c - u‖)) + log ‖meromorphicTrailingCoeffAt f c‖ := by rw [← finsum_sub_distrib] · simp_rw [← mul_sub] repeat apply h₃f.subset (fun _ ↦ (by simp_all)) _ = ∑ᶠ u, divisor f CB u * log (R * ‖c - u‖⁻¹) + divisor f CB c * log R + log ‖meromorphicTrailingCoeffAt f c‖ := by rw [countingFunction_finsum_eq_finsum_add hR h₃f] · -- Trivial case: `f` vanishes on a codiscrete set have h₂f : ¬∀ (u : ↑(closedBall c |R|)), meromorphicOrderAt f ↑u ≠ ⊤ := by aesop rw [← h₁f.exists_meromorphicOrderAt_ne_top_iff_forall ⟨nonempty_closedBall.mpr (abs_nonneg R), (convex_closedBall c |R|).isPreconnected⟩] at h₂f push_neg at h₂f have : divisor f CB = 0 := by ext x by_cases h : x ∈ CB <;> simp_all [CB] simp only [CB, this, Function.locallyFinsuppWithin.coe_zero, Pi.zero_apply, Int.cast_zero, zero_mul, finsum_zero, add_zero, zero_add] rw [MeromorphicAt.meromorphicTrailingCoeffAt_of_order_eq_top (by aesop), norm_zero, log_zero] have : f =ᶠ[codiscreteWithin CB] 0 := by filter_upwards [h₁f.meromorphicNFAt_mem_codiscreteWithin, self_mem_codiscreteWithin CB] with z h₁z h₂z simpa [h₂f ⟨z, h₂z⟩] using (not_iff_not.2 h₁z.meromorphicOrderAt_eq_zero_iff) rw [circleAverage_congr_codiscreteWithin (f₂ := 0) _ hR] · simp only [circleAverage, mul_inv_rev, Pi.zero_apply, intervalIntegral.integral_zero, smul_eq_mul, mul_zero] apply Filter.codiscreteWithin.mono (U := CB) sphere_subset_closedBall filter_upwards [this] with z hz simp_all
.lake/packages/mathlib/Mathlib/Analysis/Complex/CauchyIntegral.lean
import Mathlib.Analysis.Analytic.Uniqueness import Mathlib.Analysis.Calculus.DiffContOnCl import Mathlib.Analysis.Calculus.DSlope import Mathlib.Analysis.Calculus.FDeriv.Analytic import Mathlib.Analysis.Complex.ReImTopology import Mathlib.Analysis.Real.Cardinality import Mathlib.MeasureTheory.Integral.CircleIntegral import Mathlib.MeasureTheory.Integral.DivergenceTheorem import Mathlib.MeasureTheory.Measure.Lebesgue.Complex /-! # Cauchy integral formula In this file we prove the Cauchy-Goursat theorem and the Cauchy integral formula for integrals over circles. Most results are formulated for a function `f : ℂ → E` that takes values in a complex Banach space with second countable topology. ## Main statements In the following theorems, if the name ends with `off_countable`, then the actual theorem assumes differentiability at all but countably many points of the set mentioned below. ### Rectangle integrals * `Complex.integral_boundary_rect_of_hasFDerivAt_real_off_countable`: If a function `f : ℂ → E` is continuous on a closed rectangle and *real* differentiable on its interior, then its integral over the boundary of this rectangle is equal to the integral of `I • f' (x + y * I) 1 - f' (x + y * I) I` over the rectangle, where `f' z w : E` is the derivative of `f` at `z` in the direction `w` and `I = Complex.I` is the imaginary unit. * `Complex.integral_boundary_rect_eq_zero_of_differentiable_on_off_countable`: If a function `f : ℂ → E` is continuous on a closed rectangle and is *complex* differentiable on its interior, then its integral over the boundary of this rectangle is equal to zero. ### Annuli and circles * `Complex.circleIntegral_sub_center_inv_smul_eq_of_differentiable_on_annulus_off_countable`: If a function `f : ℂ → E` is continuous on a closed annulus `{z | r ≤ |z - c| ≤ R}` and is complex differentiable on its interior `{z | r < |z - c| < R}`, then the integrals of `(z - c)⁻¹ • f z` over the outer boundary and over the inner boundary are equal. * `Complex.circleIntegral_sub_center_inv_smul_of_differentiable_on_off_countable_of_tendsto`, `Complex.circleIntegral_sub_center_inv_smul_of_differentiable_on_off_countable`: If a function `f : ℂ → E` is continuous on a punctured closed disc `{z | |z - c| ≤ R ∧ z ≠ c}`, is complex differentiable on the corresponding punctured open disc, and tends to `y` as `z → c`, `z ≠ c`, then the integral of `(z - c)⁻¹ • f z` over the circle `|z - c| = R` is equal to `2πiy`. In particular, if `f` is continuous on the whole closed disc and is complex differentiable on the corresponding open disc, then this integral is equal to `2πif(c)`. * `Complex.circleIntegral_sub_inv_smul_of_differentiable_on_off_countable`, `Complex.two_pi_I_inv_smul_circleIntegral_sub_inv_smul_of_differentiable_on_off_countable` **Cauchy integral formula**: if `f : ℂ → E` is continuous on a closed disc of radius `R` and is complex differentiable on the corresponding open disc, then for any `w` in the corresponding open disc the integral of `(z - w)⁻¹ • f z` over the boundary of the disc is equal to `2πif(w)`. Two versions of the lemma put the multiplier `2πi` at the different sides of the equality. ### Analyticity * `Complex.hasFPowerSeriesOnBall_of_differentiable_off_countable`: If `f : ℂ → E` is continuous on a closed disc of positive radius and is complex differentiable on the corresponding open disc, then it is analytic on the corresponding open disc, and the coefficients of the power series are given by Cauchy integral formulas. * `DifferentiableOn.hasFPowerSeriesOnBall`: If `f : ℂ → E` is complex differentiable on a closed disc of positive radius, then it is analytic on the corresponding open disc, and the coefficients of the power series are given by Cauchy integral formulas. * `DifferentiableOn.analyticAt`, `Differentiable.analyticAt`: If `f : ℂ → E` is differentiable on a neighborhood of a point, then it is analytic at this point. In particular, if `f : ℂ → E` is differentiable on the whole `ℂ`, then it is analytic at every point `z : ℂ`. * `Differentiable.hasFPowerSeriesOnBall`: If `f : ℂ → E` is differentiable everywhere then the `cauchyPowerSeries f z R` is a formal power series representing `f` at `z` with infinite radius of convergence (this holds for any choice of `0 < R`). ### Higher derivatives * `Complex.circleIntegral_one_div_sub_center_pow_smul_of_differentiable_on_off_countable` **Cauchy integral formula for derivatives**: formula for the higher derivatives of `f` at the centre `c` of a disc in terms of circle integrals of `f w / (w - c) ^ (n + 1)` around the boundary circle. ## Implementation details The proof of the Cauchy integral formula in this file is based on a very general version of the divergence theorem, see `MeasureTheory.integral_divergence_of_hasFDerivWithinAt_off_countable` (a version for functions defined on `Fin (n + 1) → ℝ`), `MeasureTheory.integral_divergence_prod_Icc_of_hasFDerivWithinAt_off_countable_of_le`, and `MeasureTheory.integral2_divergence_prod_of_hasFDerivWithinAt_off_countable` (versions for functions defined on `ℝ × ℝ`). Usually, the divergence theorem is formulated for a $C^1$ smooth function. The theorems formulated above deal with a function that is * continuous on a closed box/rectangle; * differentiable at all but countably many points of its interior; * have divergence integrable over the closed box/rectangle. First, we reformulate the theorem for a *real*-differentiable map `ℂ → E`, and relate the integral of `f` over the boundary of a rectangle in `ℂ` to the integral of the derivative $\frac{\partial f}{\partial \bar z}$ over the interior of this box. In particular, for a *complex* differentiable function, the latter derivative is zero, hence the integral over the boundary of a rectangle is zero. Thus we get the Cauchy-Goursat theorem for a rectangle in `ℂ`. Next, we apply this theorem to the function $F(z)=f(c+e^{z})$ on the rectangle $[\ln r, \ln R]\times [0, 2\pi]$ to prove that $$ \oint_{|z-c|=r}\frac{f(z)\,dz}{z-c}=\oint_{|z-c|=R}\frac{f(z)\,dz}{z-c} $$ provided that `f` is continuous on the closed annulus `r ≤ |z - c| ≤ R` and is complex differentiable on its interior `r < |z - c| < R` (possibly, at all but countably many points). Here and below, we write $\frac{f(z)}{z-c}$ in the documentation while the actual lemmas use `(z - c)⁻¹ • f z` because `f z` belongs to some Banach space over `ℂ` and `f z / (z - c)` is undefined. Taking the limit of this equality as `r` tends to `𝓝[>] 0`, we prove $$ \oint_{|z-c|=R}\frac{f(z)\,dz}{z-c}=2\pi if(c) $$ provided that `f` is continuous on the closed disc `|z - c| ≤ R` and is differentiable at all but countably many points of its interior. This is the Cauchy integral formula for the center of a circle. In particular, if we apply this function to `F z = (z - c) • f z`, then we get $$ \oint_{|z-c|=R} f(z)\,dz=0. $$ In order to deduce the Cauchy integral formula for any point `w`, `|w - c| < R`, we consider the slope function `g : ℂ → E` given by `g z = (z - w)⁻¹ • (f z - f w)` if `z ≠ w` and `g w = f' w`. This function satisfies assumptions of the previous theorem, so we have $$ \oint_{|z-c|=R} \frac{f(z)\,dz}{z-w}=\oint_{|z-c|=R} \frac{f(w)\,dz}{z-w}= \left(\oint_{|z-c|=R} \frac{dz}{z-w}\right)f(w). $$ The latter integral was computed in `circleIntegral.integral_sub_inv_of_mem_ball` and is equal to `2 * π * Complex.I`. There is one more step in the actual proof. Since we allow `f` to be non-differentiable on a countable set `s`, we cannot immediately claim that `g` is continuous at `w` if `w ∈ s`. So, we use the proof outlined in the previous paragraph for `w ∉ s` (see `Complex.circleIntegral_sub_inv_smul_of_differentiable_on_off_countable_aux`), then use continuity of both sides of the formula and density of `sᶜ` to prove the formula for all points of the open ball, see `Complex.circleIntegral_sub_inv_smul_of_differentiable_on_off_countable`. Finally, we use the properties of the Cauchy integrals established elsewhere (see `hasFPowerSeriesOn_cauchy_integral`) and Cauchy integral formula to prove that the original function is analytic on the open ball. ## Tags Cauchy-Goursat theorem, Cauchy integral formula -/ open TopologicalSpace Set MeasureTheory intervalIntegral Metric Filter Function open scoped Interval Real NNReal ENNReal Topology noncomputable section universe u variable {E : Type u} [NormedAddCommGroup E] [NormedSpace ℂ E] namespace Complex section rectangle /-! ## Functions on rectangles -/ /-- Suppose that a function `f : ℂ → E` is continuous on a closed rectangle with opposite corners at `z w : ℂ`, is *real* differentiable at all but countably many points of the corresponding open rectangle, and $\frac{\partial f}{\partial \bar z}$ is integrable on this rectangle. Then the integral of `f` over the boundary of the rectangle is equal to the integral of $2i\frac{\partial f}{\partial \bar z}=i\frac{\partial f}{\partial x}-\frac{\partial f}{\partial y}$ over the rectangle. -/ theorem integral_boundary_rect_of_hasFDerivAt_real_off_countable (f : ℂ → E) (f' : ℂ → ℂ →L[ℝ] E) (z w : ℂ) (s : Set ℂ) (hs : s.Countable) (Hc : ContinuousOn f ([[z.re, w.re]] ×ℂ [[z.im, w.im]])) (Hd : ∀ x ∈ Ioo (min z.re w.re) (max z.re w.re) ×ℂ Ioo (min z.im w.im) (max z.im w.im) \ s, HasFDerivAt f (f' x) x) (Hi : IntegrableOn (fun z => I • f' z 1 - f' z I) ([[z.re, w.re]] ×ℂ [[z.im, w.im]])) : (∫ x : ℝ in z.re..w.re, f (x + z.im * I)) - (∫ x : ℝ in z.re..w.re, f (x + w.im * I)) + I • (∫ y : ℝ in z.im..w.im, f (re w + y * I)) - I • ∫ y : ℝ in z.im..w.im, f (re z + y * I) = ∫ x : ℝ in z.re..w.re, ∫ y : ℝ in z.im..w.im, I • f' (x + y * I) 1 - f' (x + y * I) I := by set e : (ℝ × ℝ) ≃L[ℝ] ℂ := equivRealProdCLM.symm have he : ∀ x y : ℝ, ↑x + ↑y * I = e (x, y) := fun x y => (mk_eq_add_mul_I x y).symm have he₁ : e (1, 0) = 1 := rfl; have he₂ : e (0, 1) = I := rfl simp only [he] at * set F : ℝ × ℝ → E := f ∘ e set F' : ℝ × ℝ → ℝ × ℝ →L[ℝ] E := fun p => (f' (e p)).comp (e : ℝ × ℝ →L[ℝ] ℂ) have hF' : ∀ p : ℝ × ℝ, (-(I • F' p)) (1, 0) + F' p (0, 1) = -(I • f' (e p) 1 - f' (e p) I) := by rintro ⟨x, y⟩ simp only [F', ContinuousLinearMap.neg_apply, ContinuousLinearMap.smul_apply, ContinuousLinearMap.comp_apply, ContinuousLinearEquiv.coe_coe, he₁, he₂, neg_add_eq_sub, neg_sub] set R : Set (ℝ × ℝ) := [[z.re, w.re]] ×ˢ [[w.im, z.im]] set t : Set (ℝ × ℝ) := e ⁻¹' s rw [uIcc_comm z.im] at Hc Hi; rw [min_comm z.im, max_comm z.im] at Hd have hR : e ⁻¹' ([[z.re, w.re]] ×ℂ [[w.im, z.im]]) = R := rfl have htc : ContinuousOn F R := Hc.comp e.continuousOn hR.ge have htd : ∀ p ∈ Ioo (min z.re w.re) (max z.re w.re) ×ˢ Ioo (min w.im z.im) (max w.im z.im) \ t, HasFDerivAt F (F' p) p := fun p hp => (Hd (e p) hp).comp p e.hasFDerivAt simp_rw [← intervalIntegral.integral_smul, intervalIntegral.integral_symm w.im z.im, ← intervalIntegral.integral_neg, ← hF'] refine (integral2_divergence_prod_of_hasFDerivAt_off_countable (fun p => -(I • F p)) F (fun p => -(I • F' p)) F' z.re w.im w.re z.im t (hs.preimage e.injective) (htc.const_smul _).neg htc (fun p hp => ((htd p hp).const_smul I).neg) htd ?_).symm rw [← (volume_preserving_equiv_real_prod.symm _).integrableOn_comp_preimage (MeasurableEquiv.measurableEmbedding _)] at Hi simpa only [hF'] using Hi.neg /-- Suppose that a function `f : ℂ → E` is continuous on a closed rectangle with opposite corners at `z w : ℂ`, is *real* differentiable on the corresponding open rectangle, and $\frac{\partial f}{\partial \bar z}$ is integrable on this rectangle. Then the integral of `f` over the boundary of the rectangle is equal to the integral of $2i\frac{\partial f}{\partial \bar z}=i\frac{\partial f}{\partial x}-\frac{\partial f}{\partial y}$ over the rectangle. -/ theorem integral_boundary_rect_of_continuousOn_of_hasFDerivAt_real (f : ℂ → E) (f' : ℂ → ℂ →L[ℝ] E) (z w : ℂ) (Hc : ContinuousOn f ([[z.re, w.re]] ×ℂ [[z.im, w.im]])) (Hd : ∀ x ∈ Ioo (min z.re w.re) (max z.re w.re) ×ℂ Ioo (min z.im w.im) (max z.im w.im), HasFDerivAt f (f' x) x) (Hi : IntegrableOn (fun z => I • f' z 1 - f' z I) ([[z.re, w.re]] ×ℂ [[z.im, w.im]])) : (∫ x : ℝ in z.re..w.re, f (x + z.im * I)) - (∫ x : ℝ in z.re..w.re, f (x + w.im * I)) + I • (∫ y : ℝ in z.im..w.im, f (re w + y * I)) - I • (∫ y : ℝ in z.im..w.im, f (re z + y * I)) = ∫ x : ℝ in z.re..w.re, ∫ y : ℝ in z.im..w.im, I • f' (x + y * I) 1 - f' (x + y * I) I := integral_boundary_rect_of_hasFDerivAt_real_off_countable f f' z w ∅ countable_empty Hc (fun x hx => Hd x hx.1) Hi /-- Suppose that a function `f : ℂ → E` is *real* differentiable on a closed rectangle with opposite corners at `z w : ℂ` and $\frac{\partial f}{\partial \bar z}$ is integrable on this rectangle. Then the integral of `f` over the boundary of the rectangle is equal to the integral of $2i\frac{\partial f}{\partial \bar z}=i\frac{\partial f}{\partial x}-\frac{\partial f}{\partial y}$ over the rectangle. -/ theorem integral_boundary_rect_of_differentiableOn_real (f : ℂ → E) (z w : ℂ) (Hd : DifferentiableOn ℝ f ([[z.re, w.re]] ×ℂ [[z.im, w.im]])) (Hi : IntegrableOn (fun z => I • fderiv ℝ f z 1 - fderiv ℝ f z I) ([[z.re, w.re]] ×ℂ [[z.im, w.im]])) : (∫ x : ℝ in z.re..w.re, f (x + z.im * I)) - (∫ x : ℝ in z.re..w.re, f (x + w.im * I)) + I • (∫ y : ℝ in z.im..w.im, f (re w + y * I)) - I • (∫ y : ℝ in z.im..w.im, f (re z + y * I)) = ∫ x : ℝ in z.re..w.re, ∫ y : ℝ in z.im..w.im, I • fderiv ℝ f (x + y * I) 1 - fderiv ℝ f (x + y * I) I := integral_boundary_rect_of_hasFDerivAt_real_off_countable f (fderiv ℝ f) z w ∅ countable_empty Hd.continuousOn (fun x hx => Hd.hasFDerivAt <| by simpa only [← mem_interior_iff_mem_nhds, interior_reProdIm, uIcc, interior_Icc] using hx.1) Hi /-- **Cauchy-Goursat theorem** for a rectangle: the integral of a complex differentiable function over the boundary of a rectangle equals zero. More precisely, if `f` is continuous on a closed rectangle and is complex differentiable at all but countably many points of the corresponding open rectangle, then its integral over the boundary of the rectangle equals zero. -/ theorem integral_boundary_rect_eq_zero_of_differentiable_on_off_countable (f : ℂ → E) (z w : ℂ) (s : Set ℂ) (hs : s.Countable) (Hc : ContinuousOn f ([[z.re, w.re]] ×ℂ [[z.im, w.im]])) (Hd : ∀ x ∈ Ioo (min z.re w.re) (max z.re w.re) ×ℂ Ioo (min z.im w.im) (max z.im w.im) \ s, DifferentiableAt ℂ f x) : (∫ x : ℝ in z.re..w.re, f (x + z.im * I)) - (∫ x : ℝ in z.re..w.re, f (x + w.im * I)) + I • (∫ y : ℝ in z.im..w.im, f (re w + y * I)) - I • (∫ y : ℝ in z.im..w.im, f (re z + y * I)) = 0 := by refine (integral_boundary_rect_of_hasFDerivAt_real_off_countable f (fun z => (fderiv ℂ f z).restrictScalars ℝ) z w s hs Hc (fun x hx => (Hd x hx).hasFDerivAt.restrictScalars ℝ) ?_).trans ?_ <;> simp /-- **Cauchy-Goursat theorem for a rectangle**: the integral of a complex differentiable function over the boundary of a rectangle equals zero. More precisely, if `f` is continuous on a closed rectangle and is complex differentiable on the corresponding open rectangle, then its integral over the boundary of the rectangle equals zero. -/ theorem integral_boundary_rect_eq_zero_of_continuousOn_of_differentiableOn (f : ℂ → E) (z w : ℂ) (Hc : ContinuousOn f ([[z.re, w.re]] ×ℂ [[z.im, w.im]])) (Hd : DifferentiableOn ℂ f (Ioo (min z.re w.re) (max z.re w.re) ×ℂ Ioo (min z.im w.im) (max z.im w.im))) : (∫ x : ℝ in z.re..w.re, f (x + z.im * I)) - (∫ x : ℝ in z.re..w.re, f (x + w.im * I)) + I • (∫ y : ℝ in z.im..w.im, f (re w + y * I)) - I • (∫ y : ℝ in z.im..w.im, f (re z + y * I)) = 0 := integral_boundary_rect_eq_zero_of_differentiable_on_off_countable f z w ∅ countable_empty Hc fun _x hx => Hd.differentiableAt <| (isOpen_Ioo.reProdIm isOpen_Ioo).mem_nhds hx.1 /-- **Cauchy-Goursat theorem** for a rectangle: the integral of a complex differentiable function over the boundary of a rectangle equals zero. More precisely, if `f` is complex differentiable on a closed rectangle, then its integral over the boundary of the rectangle equals zero. -/ theorem integral_boundary_rect_eq_zero_of_differentiableOn (f : ℂ → E) (z w : ℂ) (H : DifferentiableOn ℂ f ([[z.re, w.re]] ×ℂ [[z.im, w.im]])) : (∫ x : ℝ in z.re..w.re, f (x + z.im * I)) - (∫ x : ℝ in z.re..w.re, f (x + w.im * I)) + I • (∫ y : ℝ in z.im..w.im, f (re w + y * I)) - I • (∫ y : ℝ in z.im..w.im, f (re z + y * I)) = 0 := integral_boundary_rect_eq_zero_of_continuousOn_of_differentiableOn f z w H.continuousOn <| H.mono <| inter_subset_inter (preimage_mono Ioo_subset_Icc_self) (preimage_mono Ioo_subset_Icc_self) end rectangle section annulus /-! ## Functions on annuli -/ /-- If `f : ℂ → E` is continuous on the closed annulus `r ≤ ‖z - c‖ ≤ R`, `0 < r ≤ R`, and is complex differentiable at all but countably many points of its interior, then the integrals of `f z / (z - c)` (formally, `(z - c)⁻¹ • f z`) over the circles `‖z - c‖ = r` and `‖z - c‖ = R` are equal to each other. -/ theorem circleIntegral_sub_center_inv_smul_eq_of_differentiable_on_annulus_off_countable {c : ℂ} {r R : ℝ} (h0 : 0 < r) (hle : r ≤ R) {f : ℂ → E} {s : Set ℂ} (hs : s.Countable) (hc : ContinuousOn f (closedBall c R \ ball c r)) (hd : ∀ z ∈ (ball c R \ closedBall c r) \ s, DifferentiableAt ℂ f z) : (∮ z in C(c, R), (z - c)⁻¹ • f z) = ∮ z in C(c, r), (z - c)⁻¹ • f z := by /- We apply the previous lemma to `fun z ↦ f (c + exp z)` on the rectangle `[log r, log R] × [0, 2 * π]`. -/ set A := closedBall c R \ ball c r obtain ⟨a, rfl⟩ : ∃ a, Real.exp a = r := ⟨Real.log r, Real.exp_log h0⟩ obtain ⟨b, rfl⟩ : ∃ b, Real.exp b = R := ⟨Real.log R, Real.exp_log (h0.trans_le hle)⟩ rw [Real.exp_le_exp] at hle -- Unfold definition of `circleIntegral` and cancel some terms. suffices (∫ θ in 0..2 * π, I • f (circleMap c (Real.exp b) θ)) = ∫ θ in 0..2 * π, I • f (circleMap c (Real.exp a) θ) by simpa only [circleIntegral, add_sub_cancel_left, ofReal_exp, ← exp_add, smul_smul, ← div_eq_mul_inv, mul_div_cancel_left₀ _ (circleMap_ne_center (Real.exp_pos _).ne'), circleMap_sub_center, deriv_circleMap] set R := [[a, b]] ×ℂ [[0, 2 * π]] set g : ℂ → ℂ := (c + exp ·) have hdg : Differentiable ℂ g := differentiable_exp.const_add _ replace hs : (g ⁻¹' s).Countable := (hs.preimage (add_right_injective c)).preimage_cexp have h_maps : MapsTo g R A := by rintro z ⟨h, -⟩; simpa [g, A, dist_eq, norm_exp, hle] using h.symm replace hc : ContinuousOn (f ∘ g) R := hc.comp hdg.continuous.continuousOn h_maps replace hd : ∀ z ∈ Ioo (min a b) (max a b) ×ℂ Ioo (min 0 (2 * π)) (max 0 (2 * π)) \ g ⁻¹' s, DifferentiableAt ℂ (f ∘ g) z := by refine fun z hz => (hd (g z) ⟨?_, hz.2⟩).comp z (hdg _) simpa [g, dist_eq, norm_exp, hle, and_comm] using hz.1.1 simpa [g, circleMap, exp_periodic _, sub_eq_zero, ← exp_add] using integral_boundary_rect_eq_zero_of_differentiable_on_off_countable _ ⟨a, 0⟩ ⟨b, 2 * π⟩ _ hs hc hd /-- **Cauchy-Goursat theorem** for an annulus. If `f : ℂ → E` is continuous on the closed annulus `r ≤ ‖z - c‖ ≤ R`, `0 < r ≤ R`, and is complex differentiable at all but countably many points of its interior, then the integrals of `f` over the circles `‖z - c‖ = r` and `‖z - c‖ = R` are equal to each other. -/ theorem circleIntegral_eq_of_differentiable_on_annulus_off_countable {c : ℂ} {r R : ℝ} (h0 : 0 < r) (hle : r ≤ R) {f : ℂ → E} {s : Set ℂ} (hs : s.Countable) (hc : ContinuousOn f (closedBall c R \ ball c r)) (hd : ∀ z ∈ (ball c R \ closedBall c r) \ s, DifferentiableAt ℂ f z) : (∮ z in C(c, R), f z) = ∮ z in C(c, r), f z := calc (∮ z in C(c, R), f z) = ∮ z in C(c, R), (z - c)⁻¹ • (z - c) • f z := (circleIntegral.integral_sub_inv_smul_sub_smul _ _ _ _).symm _ = ∮ z in C(c, r), (z - c)⁻¹ • (z - c) • f z := (circleIntegral_sub_center_inv_smul_eq_of_differentiable_on_annulus_off_countable h0 hle hs ((continuousOn_id.sub continuousOn_const).smul hc) fun z hz => (differentiableAt_id.sub_const _).smul (hd z hz)) _ = ∮ z in C(c, r), f z := circleIntegral.integral_sub_inv_smul_sub_smul _ _ _ _ end annulus variable [CompleteSpace E] section circle /-! ## Circle integrals -/ /-- **Cauchy integral formula** for the value at the center of a disc. If `f` is continuous on a punctured closed disc of radius `R`, is differentiable at all but countably many points of the interior of this disc, and has a limit `y` at the center of the disc, then the integral $\oint_{‖z-c‖=R} \frac{f(z)}{z-c}\,dz$ is equal to `2πiy`. -/ theorem circleIntegral_sub_center_inv_smul_of_differentiable_on_off_countable_of_tendsto {c : ℂ} {R : ℝ} (h0 : 0 < R) {f : ℂ → E} {y : E} {s : Set ℂ} (hs : s.Countable) (hc : ContinuousOn f (closedBall c R \ {c})) (hd : ∀ z ∈ (ball c R \ {c}) \ s, DifferentiableAt ℂ f z) (hy : Tendsto f (𝓝[{c}ᶜ] c) (𝓝 y)) : (∮ z in C(c, R), (z - c)⁻¹ • f z) = (2 * π * I : ℂ) • y := by rw [← sub_eq_zero, ← norm_le_zero_iff] refine le_of_forall_gt_imp_ge_of_dense fun ε ε0 => ?_ obtain ⟨δ, δ0, hδ⟩ : ∃ δ > (0 : ℝ), ∀ z ∈ closedBall c δ \ {c}, dist (f z) y < ε / (2 * π) := ((nhdsWithin_hasBasis nhds_basis_closedBall _).tendsto_iff nhds_basis_ball).1 hy _ (div_pos ε0 Real.two_pi_pos) obtain ⟨r, hr0, hrδ, hrR⟩ : ∃ r, 0 < r ∧ r ≤ δ ∧ r ≤ R := ⟨min δ R, lt_min δ0 h0, min_le_left _ _, min_le_right _ _⟩ have hsub : closedBall c R \ ball c r ⊆ closedBall c R \ {c} := diff_subset_diff_right (singleton_subset_iff.2 <| mem_ball_self hr0) have hsub' : ball c R \ closedBall c r ⊆ ball c R \ {c} := diff_subset_diff_right (singleton_subset_iff.2 <| mem_closedBall_self hr0.le) have hzne : ∀ z ∈ sphere c r, z ≠ c := fun z hz => ne_of_mem_of_not_mem hz fun h => hr0.ne' <| dist_self c ▸ Eq.symm h /- The integral `∮ z in C(c, r), f z / (z - c)` does not depend on `0 < r ≤ R` and tends to `2πIy` as `r → 0`. -/ calc ‖(∮ z in C(c, R), (z - c)⁻¹ • f z) - (2 * ↑π * I) • y‖ = ‖(∮ z in C(c, r), (z - c)⁻¹ • f z) - ∮ z in C(c, r), (z - c)⁻¹ • y‖ := by congr 2 · exact circleIntegral_sub_center_inv_smul_eq_of_differentiable_on_annulus_off_countable hr0 hrR hs (hc.mono hsub) fun z hz => hd z ⟨hsub' hz.1, hz.2⟩ · simp [hr0.ne'] _ = ‖∮ z in C(c, r), (z - c)⁻¹ • (f z - y)‖ := by simp only [smul_sub] have hc' : ContinuousOn (fun z => (z - c)⁻¹) (sphere c r) := (continuousOn_id.sub continuousOn_const).inv₀ fun z hz => sub_ne_zero.2 <| hzne _ hz rw [circleIntegral.integral_sub] <;> refine (hc'.smul ?_).circleIntegrable hr0.le · exact hc.mono <| subset_inter (sphere_subset_closedBall.trans <| closedBall_subset_closedBall hrR) hzne · exact continuousOn_const _ ≤ 2 * π * r * (r⁻¹ * (ε / (2 * π))) := by refine circleIntegral.norm_integral_le_of_norm_le_const hr0.le fun z hz => ?_ specialize hzne z hz rw [mem_sphere, dist_eq_norm] at hz rw [norm_smul, norm_inv, hz, ← dist_eq_norm] refine mul_le_mul_of_nonneg_left (hδ _ ⟨?_, hzne⟩).le (inv_nonneg.2 hr0.le) rwa [mem_closedBall_iff_norm, hz] _ = ε := by field /-- **Cauchy integral formula** for the value at the center of a disc. If `f : ℂ → E` is continuous on a closed disc of radius `R` and center `c`, and is complex differentiable at all but countably many points of its interior, then the integral $\oint_{|z-c|=R} \frac{f(z)}{z-c}\,dz$ is equal to `2πi • f c`. -/ theorem circleIntegral_sub_center_inv_smul_of_differentiable_on_off_countable {R : ℝ} (h0 : 0 < R) {f : ℂ → E} {c : ℂ} {s : Set ℂ} (hs : s.Countable) (hc : ContinuousOn f (closedBall c R)) (hd : ∀ z ∈ ball c R \ s, DifferentiableAt ℂ f z) : (∮ z in C(c, R), (z - c)⁻¹ • f z) = (2 * π * I) • f c := circleIntegral_sub_center_inv_smul_of_differentiable_on_off_countable_of_tendsto h0 hs (hc.mono diff_subset) (fun z hz => hd z ⟨hz.1.1, hz.2⟩) (hc.continuousAt <| closedBall_mem_nhds _ h0).continuousWithinAt omit [CompleteSpace E] in /-- **Cauchy-Goursat theorem** for a disk: if `f : ℂ → E` is continuous on a closed disk `{z | ‖z - c‖ ≤ R}` and is complex differentiable at all but countably many points of its interior, then the integral $\oint_{|z-c|=R}f(z)\,dz$ equals zero. -/ theorem circleIntegral_eq_zero_of_differentiable_on_off_countable {R : ℝ} (h0 : 0 ≤ R) {f : ℂ → E} {c : ℂ} {s : Set ℂ} (hs : s.Countable) (hc : ContinuousOn f (closedBall c R)) (hd : ∀ z ∈ ball c R \ s, DifferentiableAt ℂ f z) : (∮ z in C(c, R), f z) = 0 := by wlog hE : CompleteSpace E generalizing · simp [circleIntegral, intervalIntegral, integral, hE] rcases h0.eq_or_lt with (rfl | h0); · apply circleIntegral.integral_radius_zero calc (∮ z in C(c, R), f z) = ∮ z in C(c, R), (z - c)⁻¹ • (z - c) • f z := (circleIntegral.integral_sub_inv_smul_sub_smul _ _ _ _).symm _ = (2 * ↑π * I : ℂ) • (c - c) • f c := (circleIntegral_sub_center_inv_smul_of_differentiable_on_off_countable h0 hs ((continuousOn_id.sub continuousOn_const).smul hc) fun z hz => (differentiableAt_id.sub_const _).smul (hd z hz)) _ = 0 := by rw [sub_self, zero_smul, smul_zero] /-- An auxiliary lemma for `Complex.circleIntegral_sub_inv_smul_of_differentiable_on_off_countable`. This lemma assumes `w ∉ s` while the main lemma drops this assumption. -/ theorem circleIntegral_sub_inv_smul_of_differentiable_on_off_countable_aux {R : ℝ} {c w : ℂ} {f : ℂ → E} {s : Set ℂ} (hs : s.Countable) (hw : w ∈ ball c R \ s) (hc : ContinuousOn f (closedBall c R)) (hd : ∀ x ∈ ball c R \ s, DifferentiableAt ℂ f x) : (∮ z in C(c, R), (z - w)⁻¹ • f z) = (2 * π * I : ℂ) • f w := by have hR : 0 < R := dist_nonneg.trans_lt hw.1 set F : ℂ → E := dslope f w have hws : (insert w s).Countable := hs.insert w have hcF : ContinuousOn F (closedBall c R) := (continuousOn_dslope <| closedBall_mem_nhds_of_mem hw.1).2 ⟨hc, hd _ hw⟩ have hdF : ∀ z ∈ ball (c : ℂ) R \ insert w s, DifferentiableAt ℂ F z := fun z hz => (differentiableAt_dslope_of_ne (ne_of_mem_of_not_mem (mem_insert _ _) hz.2).symm).2 (hd _ (diff_subset_diff_right (subset_insert _ _) hz)) have HI := circleIntegral_eq_zero_of_differentiable_on_off_countable hR.le hws hcF hdF have hne : ∀ z ∈ sphere c R, z ≠ w := fun z hz => ne_of_mem_of_not_mem hz (ne_of_lt hw.1) have hFeq : EqOn F (fun z => (z - w)⁻¹ • f z - (z - w)⁻¹ • f w) (sphere c R) := fun z hz ↦ calc F z = (z - w)⁻¹ • (f z - f w) := update_of_ne (hne z hz) .. _ = (z - w)⁻¹ • f z - (z - w)⁻¹ • f w := smul_sub _ _ _ have hc' : ContinuousOn (fun z => (z - w)⁻¹) (sphere c R) := (continuousOn_id.sub continuousOn_const).inv₀ fun z hz => sub_ne_zero.2 <| hne z hz rw [← circleIntegral.integral_sub_inv_of_mem_ball hw.1, ← circleIntegral.integral_smul_const, ← sub_eq_zero, ← circleIntegral.integral_sub, ← circleIntegral.integral_congr hR.le hFeq, HI] exacts [(hc'.smul (hc.mono sphere_subset_closedBall)).circleIntegrable hR.le, (hc'.smul continuousOn_const).circleIntegrable hR.le] /-- **Cauchy integral formula**: if `f : ℂ → E` is continuous on a closed disc of radius `R` and is complex differentiable at all but countably many points of its interior, then for any `w` in this interior we have $\frac{1}{2πi}\oint_{|z-c|=R}(z-w)^{-1}f(z)\,dz=f(w)$. -/ theorem two_pi_I_inv_smul_circleIntegral_sub_inv_smul_of_differentiable_on_off_countable {R : ℝ} {c w : ℂ} {f : ℂ → E} {s : Set ℂ} (hs : s.Countable) (hw : w ∈ ball c R) (hc : ContinuousOn f (closedBall c R)) (hd : ∀ x ∈ ball c R \ s, DifferentiableAt ℂ f x) : ((2 * π * I : ℂ)⁻¹ • ∮ z in C(c, R), (z - w)⁻¹ • f z) = f w := by have hR : 0 < R := dist_nonneg.trans_lt hw suffices w ∈ closure (ball c R \ s) by lift R to ℝ≥0 using hR.le have A : ContinuousAt (fun w => (2 * π * I : ℂ)⁻¹ • ∮ z in C(c, R), (z - w)⁻¹ • f z) w := by have := hasFPowerSeriesOn_cauchy_integral ((hc.mono sphere_subset_closedBall).circleIntegrable R.coe_nonneg) hR refine this.continuousOn.continuousAt (EMetric.isOpen_ball.mem_nhds ?_) rwa [Metric.emetric_ball_nnreal] have B : ContinuousAt f w := hc.continuousAt (closedBall_mem_nhds_of_mem hw) refine tendsto_nhds_unique_of_frequently_eq A B ((mem_closure_iff_frequently.1 this).mono ?_) intro z hz rw [circleIntegral_sub_inv_smul_of_differentiable_on_off_countable_aux hs hz hc hd, inv_smul_smul₀] simp [Real.pi_ne_zero, I_ne_zero] refine mem_closure_iff_nhds.2 fun t ht => ?_ -- TODO: generalize to any vector space over `ℝ` set g : ℝ → ℂ := fun x => w + ofReal x have : Tendsto g (𝓝 0) (𝓝 w) := (continuous_const.add continuous_ofReal).tendsto' 0 w (add_zero _) rcases mem_nhds_iff_exists_Ioo_subset.1 (this <| inter_mem ht <| isOpen_ball.mem_nhds hw) with ⟨l, u, hlu₀, hlu_sub⟩ obtain ⟨x, hx⟩ : (Ioo l u \ g ⁻¹' s).Nonempty := by refine diff_nonempty.2 fun hsub => ?_ have : (Ioo l u).Countable := (hs.preimage ((add_right_injective w).comp ofReal_injective)).mono hsub rw [← Cardinal.le_aleph0_iff_set_countable, Cardinal.mk_Ioo_real (hlu₀.1.trans hlu₀.2)] at this exact this.not_gt Cardinal.aleph0_lt_continuum exact ⟨g x, (hlu_sub hx.1).1, (hlu_sub hx.1).2, hx.2⟩ /-- **Cauchy integral formula**: if `f : ℂ → E` is continuous on a closed disc of radius `R` and is complex differentiable at all but countably many points of its interior, then for any `w` in this interior we have $\oint_{|z-c|=R}(z-w)^{-1}f(z)\,dz=2πif(w)$. -/ theorem circleIntegral_sub_inv_smul_of_differentiable_on_off_countable {R : ℝ} {c w : ℂ} {f : ℂ → E} {s : Set ℂ} (hs : s.Countable) (hw : w ∈ ball c R) (hc : ContinuousOn f (closedBall c R)) (hd : ∀ x ∈ ball c R \ s, DifferentiableAt ℂ f x) : (∮ z in C(c, R), (z - w)⁻¹ • f z) = (2 * π * I : ℂ) • f w := by rw [← two_pi_I_inv_smul_circleIntegral_sub_inv_smul_of_differentiable_on_off_countable hs hw hc hd, smul_inv_smul₀] simp [Real.pi_ne_zero, I_ne_zero] /-- **Cauchy integral formula**: if `f : ℂ → E` is complex differentiable on an open disc and is continuous on its closure, then for any `w` in this open ball we have $\oint_{|z-c|=R}(z-w)^{-1}f(z)\,dz=2πif(w)$. -/ theorem _root_.DiffContOnCl.circleIntegral_sub_inv_smul {R : ℝ} {c w : ℂ} {f : ℂ → E} (h : DiffContOnCl ℂ f (ball c R)) (hw : w ∈ ball c R) : (∮ z in C(c, R), (z - w)⁻¹ • f z) = (2 * π * I : ℂ) • f w := circleIntegral_sub_inv_smul_of_differentiable_on_off_countable countable_empty hw h.continuousOn_ball fun _x hx => h.differentiableAt isOpen_ball hx.1 /-- **Cauchy integral formula**: if `f : ℂ → E` is complex differentiable on an open disc and is continuous on its closure, then for any `w` in this open ball we have $\frac{1}{2πi}\oint_{|z-c|=R}(z-w)^{-1}f(z)\,dz=f(w)$. -/ theorem _root_.DiffContOnCl.two_pi_i_inv_smul_circleIntegral_sub_inv_smul {R : ℝ} {c w : ℂ} {f : ℂ → E} (hf : DiffContOnCl ℂ f (ball c R)) (hw : w ∈ ball c R) : ((2 * π * I : ℂ)⁻¹ • ∮ z in C(c, R), (z - w)⁻¹ • f z) = f w := by have hR : 0 < R := not_le.mp (ball_eq_empty.not.mp (Set.nonempty_of_mem hw).ne_empty) refine two_pi_I_inv_smul_circleIntegral_sub_inv_smul_of_differentiable_on_off_countable countable_empty hw ?_ ?_ · simpa only [closure_ball c hR.ne.symm] using hf.continuousOn · simpa only [diff_empty] using fun z hz => hf.differentiableAt isOpen_ball hz /-- **Cauchy integral formula**: if `f : ℂ → E` is complex differentiable on a closed disc of radius `R`, then for any `w` in its interior we have $\oint_{|z-c|=R}(z-w)^{-1}f(z)\,dz=2πif(w)$. -/ theorem _root_.DifferentiableOn.circleIntegral_sub_inv_smul {R : ℝ} {c w : ℂ} {f : ℂ → E} (hd : DifferentiableOn ℂ f (closedBall c R)) (hw : w ∈ ball c R) : (∮ z in C(c, R), (z - w)⁻¹ • f z) = (2 * π * I : ℂ) • f w := (hd.mono closure_ball_subset_closedBall).diffContOnCl.circleIntegral_sub_inv_smul hw /-- **Cauchy integral formula**: if `f : ℂ → ℂ` is continuous on a closed disc of radius `R` and is complex differentiable at all but countably many points of its interior, then for any `w` in this interior we have $\oint_{|z-c|=R}\frac{f(z)}{z-w}dz=2\pi i\,f(w)$. -/ theorem circleIntegral_div_sub_of_differentiable_on_off_countable {R : ℝ} {c w : ℂ} {s : Set ℂ} (hs : s.Countable) (hw : w ∈ ball c R) {f : ℂ → ℂ} (hc : ContinuousOn f (closedBall c R)) (hd : ∀ z ∈ ball c R \ s, DifferentiableAt ℂ f z) : (∮ z in C(c, R), f z / (z - w)) = 2 * π * I * f w := by simpa only [smul_eq_mul, div_eq_inv_mul] using circleIntegral_sub_inv_smul_of_differentiable_on_off_countable hs hw hc hd end circle section analyticity /-! ## Applications to analyticity -/ /-- If `f : ℂ → E` is continuous on a closed ball of positive radius and is differentiable at all but countably many points of the corresponding open ball, then it is analytic on the open ball with coefficients of the power series given by Cauchy integral formulas. -/ theorem hasFPowerSeriesOnBall_of_differentiable_off_countable {R : ℝ≥0} {c : ℂ} {f : ℂ → E} {s : Set ℂ} (hs : s.Countable) (hc : ContinuousOn f (closedBall c R)) (hd : ∀ z ∈ ball c R \ s, DifferentiableAt ℂ f z) (hR : 0 < R) : HasFPowerSeriesOnBall f (cauchyPowerSeries f c R) c R where r_le := le_radius_cauchyPowerSeries _ _ _ r_pos := ENNReal.coe_pos.2 hR hasSum := fun {w} hw => by have hw' : c + w ∈ ball c R := by simpa only [add_mem_ball_iff_norm, ← coe_nnnorm, mem_emetric_ball_zero_iff, NNReal.coe_lt_coe, enorm_lt_coe] using hw rw [← two_pi_I_inv_smul_circleIntegral_sub_inv_smul_of_differentiable_on_off_countable hs hw' hc hd] exact (hasFPowerSeriesOn_cauchy_integral ((hc.mono sphere_subset_closedBall).circleIntegrable R.2) hR).hasSum hw /-- If `f : ℂ → E` is complex differentiable on an open disc of positive radius and is continuous on its closure, then it is analytic on the open disc with coefficients of the power series given by Cauchy integral formulas. -/ theorem _root_.DiffContOnCl.hasFPowerSeriesOnBall {R : ℝ≥0} {c : ℂ} {f : ℂ → E} (hf : DiffContOnCl ℂ f (ball c R)) (hR : 0 < R) : HasFPowerSeriesOnBall f (cauchyPowerSeries f c R) c R := hasFPowerSeriesOnBall_of_differentiable_off_countable countable_empty hf.continuousOn_ball (fun _z hz => hf.differentiableAt isOpen_ball hz.1) hR /-- If `f : ℂ → E` is complex differentiable on a closed disc of positive radius, then it is analytic on the corresponding open disc, and the coefficients of the power series are given by Cauchy integral formulas. See also `Complex.hasFPowerSeriesOnBall_of_differentiable_off_countable` for a version of this lemma with weaker assumptions. -/ protected theorem _root_.DifferentiableOn.hasFPowerSeriesOnBall {R : ℝ≥0} {c : ℂ} {f : ℂ → E} (hd : DifferentiableOn ℂ f (closedBall c R)) (hR : 0 < R) : HasFPowerSeriesOnBall f (cauchyPowerSeries f c R) c R := (hd.mono closure_ball_subset_closedBall).diffContOnCl.hasFPowerSeriesOnBall hR /-- If `f : ℂ → E` is complex differentiable on some set `s`, then it is analytic at any point `z` such that `s ∈ 𝓝 z` (equivalently, `z ∈ interior s`). -/ protected theorem _root_.DifferentiableOn.analyticAt {s : Set ℂ} {f : ℂ → E} {z : ℂ} (hd : DifferentiableOn ℂ f s) (hz : s ∈ 𝓝 z) : AnalyticAt ℂ f z := by rcases nhds_basis_closedBall.mem_iff.1 hz with ⟨R, hR0, hRs⟩ lift R to ℝ≥0 using hR0.le exact ((hd.mono hRs).hasFPowerSeriesOnBall hR0).analyticAt theorem _root_.DifferentiableOn.analyticOnNhd {s : Set ℂ} {f : ℂ → E} (hd : DifferentiableOn ℂ f s) (hs : IsOpen s) : AnalyticOnNhd ℂ f s := fun _z hz => hd.analyticAt (hs.mem_nhds hz) theorem _root_.DifferentiableOn.analyticOn {s : Set ℂ} {f : ℂ → E} (hd : DifferentiableOn ℂ f s) (hs : IsOpen s) : AnalyticOn ℂ f s := (hd.analyticOnNhd hs).analyticOn /-- If `f : ℂ → E` is complex differentiable on some open set `s`, then it is continuously differentiable on `s`. -/ protected theorem _root_.DifferentiableOn.contDiffOn {s : Set ℂ} {f : ℂ → E} {n : WithTop ℕ∞} (hd : DifferentiableOn ℂ f s) (hs : IsOpen s) : ContDiffOn ℂ n f s := (hd.analyticOnNhd hs).contDiffOn_of_completeSpace theorem _root_.DifferentiableOn.deriv {s : Set ℂ} {f : ℂ → E} (hd : DifferentiableOn ℂ f s) (hs : IsOpen s) : DifferentiableOn ℂ (deriv f) s := (hd.analyticOnNhd hs).deriv.differentiableOn /-- A complex differentiable function `f : ℂ → E` is analytic at every point. -/ protected theorem _root_.Differentiable.analyticAt {f : ℂ → E} (hf : Differentiable ℂ f) (z : ℂ) : AnalyticAt ℂ f z := hf.differentiableOn.analyticAt univ_mem /-- A complex differentiable function `f : ℂ → E` is continuously differentiable at every point. -/ protected theorem _root_.Differentiable.contDiff {f : ℂ → E} (hf : Differentiable ℂ f) {n : WithTop ℕ∞} : ContDiff ℂ n f := contDiff_iff_contDiffAt.mpr fun z ↦ (hf.analyticAt z).contDiffAt /-- When `f : ℂ → E` is differentiable, the `cauchyPowerSeries f z R` represents `f` as a power series centered at `z` in the entirety of `ℂ`, regardless of `R : ℝ≥0`, with `0 < R`. -/ protected theorem _root_.Differentiable.hasFPowerSeriesOnBall {f : ℂ → E} (h : Differentiable ℂ f) (z : ℂ) {R : ℝ≥0} (hR : 0 < R) : HasFPowerSeriesOnBall f (cauchyPowerSeries f z R) z ∞ := (h.differentiableOn.hasFPowerSeriesOnBall hR).r_eq_top_of_exists fun _r hr => ⟨_, h.differentiableOn.hasFPowerSeriesOnBall hr⟩ /-- On an open set, `f : ℂ → E` is analytic iff it is differentiable -/ theorem analyticOnNhd_iff_differentiableOn {f : ℂ → E} {s : Set ℂ} (o : IsOpen s) : AnalyticOnNhd ℂ f s ↔ DifferentiableOn ℂ f s := ⟨AnalyticOnNhd.differentiableOn, fun d _ zs ↦ d.analyticAt (o.mem_nhds zs)⟩ /-- On an open set, `f : ℂ → E` is analytic iff it is differentiable -/ theorem analyticOn_iff_differentiableOn {f : ℂ → E} {s : Set ℂ} (o : IsOpen s) : AnalyticOn ℂ f s ↔ DifferentiableOn ℂ f s := by rw [o.analyticOn_iff_analyticOnNhd] exact analyticOnNhd_iff_differentiableOn o /-- `f : ℂ → E` is entire iff it's differentiable -/ theorem analyticOnNhd_univ_iff_differentiable {f : ℂ → E} : AnalyticOnNhd ℂ f univ ↔ Differentiable ℂ f := by simp only [← differentiableOn_univ] exact analyticOnNhd_iff_differentiableOn isOpen_univ theorem analyticOn_univ_iff_differentiable {f : ℂ → E} : AnalyticOn ℂ f univ ↔ Differentiable ℂ f := by rw [analyticOn_univ] exact analyticOnNhd_univ_iff_differentiable /-- `f : ℂ → E` is analytic at `z` iff it's differentiable near `z` -/ theorem analyticAt_iff_eventually_differentiableAt {f : ℂ → E} {c : ℂ} : AnalyticAt ℂ f c ↔ ∀ᶠ z in 𝓝 c, DifferentiableAt ℂ f z := by constructor · intro fa filter_upwards [fa.eventually_analyticAt] apply AnalyticAt.differentiableAt · intro d rcases _root_.eventually_nhds_iff.mp d with ⟨s, d, o, m⟩ have h : AnalyticOnNhd ℂ f s := by refine DifferentiableOn.analyticOnNhd ?_ o intro z m exact (d z m).differentiableWithinAt exact h _ m end analyticity section derivatives /-! ## Circle integrals for higher derivatives TODO: add a version for `w ∈ Metric.ball c R`. -/ variable {R : ℝ} {f : ℂ → E} {c : ℂ} {s : Set ℂ} /-- **Cauchy integral formula for derivatives**, assuming `f` is continuous on a closed ball and differentiable on its interior away from a countable set. -/ lemma circleIntegral_one_div_sub_center_pow_smul_of_differentiable_on_off_countable (h0 : 0 < R) (n : ℕ) (hs : s.Countable) (hc : ContinuousOn f (closedBall c R)) (hd : ∀ z ∈ ball c R \ s, DifferentiableAt ℂ f z) : ∮ z in C(c, R), (1 / (z - c) ^ (n + 1)) • f z = (2 * π * I / n.factorial) • iteratedDeriv n f c := by have := hasFPowerSeriesOnBall_of_differentiable_off_countable (R := ⟨R, h0.le⟩) hs hc hd h0 |>.factorial_smul 1 n rw [iteratedFDeriv_apply_eq_iteratedDeriv_mul_prod, Finset.prod_const_one, one_smul] at this rw [← this, cauchyPowerSeries_apply, ← Nat.cast_smul_eq_nsmul ℂ, ← mul_smul, ← mul_smul, div_mul_cancel₀ _ (mod_cast n.factorial_ne_zero), mul_inv_cancel₀ two_pi_I_ne_zero] simp [← mul_smul, pow_succ, mul_comm] /-- **Cauchy integral formula for the first order derivative**, assuming `f` is continuous on a closed ball and differentiable on its interior away from a countable set. -/ lemma differentiable_on_off_countable_deriv_eq_smul_circleIntegral (h0 : 0 < R) (hs : s.Countable) (hc : ContinuousOn f (closedBall c R)) (hd : ∀ z ∈ ball c R \ s, DifferentiableAt ℂ f z) : ∮ z in C(c, R), (1 / (z - c) ^ 2) • f z = (2 * π * I) • deriv f c := by simpa using circleIntegral_one_div_sub_center_pow_smul_of_differentiable_on_off_countable h0 1 hs hc hd /-- **Cauchy integral formula for derivatives**, assuming `f` is continuous on a closed ball and differentiable on its interior. -/ lemma _root_.DiffContOnCl.circleIntegral_one_div_sub_center_pow_smul (h0 : 0 < R) (n : ℕ) (hc : DiffContOnCl ℂ f (ball c R)) : ∮ z in C(c, R), (1 / (z - c) ^ (n + 1)) • f z = (2 * π * I / n.factorial) • iteratedDeriv n f c := c.circleIntegral_one_div_sub_center_pow_smul_of_differentiable_on_off_countable h0 n Set.countable_empty hc.continuousOn_ball fun _ hx ↦ hc.differentiableAt isOpen_ball hx.1 /-- **Cauchy integral formula for the first order derivative**, assuming `f` is continuous on a closed ball and differentiable on its interior. -/ lemma _root_.DiffContOnCl.deriv_eq_smul_circleIntegral (h0 : 0 < R) (hc : DiffContOnCl ℂ f (ball c R)) : ∮ z in C(c, R), (1 / (z - c) ^ 2) • f z = (2 * π * I) • deriv f c := by simpa using DiffContOnCl.circleIntegral_one_div_sub_center_pow_smul h0 1 hc /-- **Cauchy integral formula for derivatives**, assuming `f` is differentiable on a closed ball. -/ lemma _root_.DifferentiableOn.circleIntegral_one_div_sub_center_pow_smul (h0 : 0 < R) (n : ℕ) (hc : DifferentiableOn ℂ f (closedBall c R)) : ∮ z in C(c, R), (1 / (z - c) ^ (n + 1)) • f z = (2 * π * I / n.factorial) • iteratedDeriv n f c := (hc.mono closure_ball_subset_closedBall).diffContOnCl |>.circleIntegral_one_div_sub_center_pow_smul h0 n /-- **Cauchy integral formula for the first order derivative**, assuming `f` is differentiable on a closed ball. -/ lemma _root_.DifferentiableOn.deriv_eq_smul_circleIntegral (h0 : 0 < R) (hc : DifferentiableOn ℂ f (closedBall c R)) : ∮ z in C(c, R), (1 / (z - c) ^ 2) • f z = (2 * π * I) • deriv f c := by simpa using DifferentiableOn.circleIntegral_one_div_sub_center_pow_smul h0 1 hc end derivatives end Complex
.lake/packages/mathlib/Mathlib/Analysis/Complex/Positivity.lean
import Mathlib.Analysis.Complex.TaylorSeries /-! # Nonnegativity of values of holomorphic functions We show that if `f` is holomorphic on an open disk `B(c,r)` and all iterated derivatives of `f` at `c` are nonnegative real, then `f z ≥ 0` for all `z ≥ c` in the disk; see `DifferentiableOn.nonneg_of_iteratedDeriv_nonneg`. We also provide a variant `Differentiable.nonneg_of_iteratedDeriv_nonneg` for entire functions and versions showing `f z ≥ f c` when all iterated derivatives except `f` itseld are nonnegative. -/ open Complex open scoped ComplexOrder namespace DifferentiableOn /-- A function that is holomorphic on the open disk around `c` with radius `r` and whose iterated derivatives at `c` are all nonnegative real has nonnegative real values on `c + [0,r)`. -/ theorem nonneg_of_iteratedDeriv_nonneg {f : ℂ → ℂ} {c : ℂ} {r : ℝ} (hf : DifferentiableOn ℂ f (Metric.ball c r)) (h : ∀ n, 0 ≤ iteratedDeriv n f c) ⦃z : ℂ⦄ (hz₁ : c ≤ z) (hz₂ : z ∈ Metric.ball c r) : 0 ≤ f z := by have H := taylorSeries_eq_on_ball' hz₂ hf rw [← sub_nonneg] at hz₁ have hz' := eq_re_of_ofReal_le hz₁ rw [hz'] at hz₁ H refine H ▸ tsum_nonneg fun n ↦ ?_ rw [← ofReal_natCast, ← ofReal_pow, ← ofReal_inv, eq_re_of_ofReal_le (h n), ← ofReal_mul, ← ofReal_mul] norm_cast at hz₁ ⊢ positivity [zero_re ▸ (Complex.le_def.mp (h n)).1] end DifferentiableOn namespace Differentiable /-- An entire function whose iterated derivatives at `c` are all nonnegative real has nonnegative real values on `c + ℝ≥0`. -/ theorem nonneg_of_iteratedDeriv_nonneg {f : ℂ → ℂ} (hf : Differentiable ℂ f) {c : ℂ} (h : ∀ n, 0 ≤ iteratedDeriv n f c) ⦃z : ℂ⦄ (hz : c ≤ z) : 0 ≤ f z := by refine hf.differentiableOn.nonneg_of_iteratedDeriv_nonneg (r := (z - c).re + 1) h hz ?_ rw [← sub_nonneg] at hz rw [Metric.mem_ball, dist_eq, eq_re_of_ofReal_le hz] simpa only [Complex.norm_of_nonneg (nonneg_iff.mp hz).1] using lt_add_one _ /-- An entire function whose iterated derivatives at `c` are all nonnegative real (except possibly the value itself) has values of the form `f c + nonneg. real` on the set `c + ℝ≥0`. -/ theorem apply_le_of_iteratedDeriv_nonneg {f : ℂ → ℂ} {c : ℂ} (hf : Differentiable ℂ f) (h : ∀ n ≠ 0, 0 ≤ iteratedDeriv n f c) ⦃z : ℂ⦄ (hz : c ≤ z) : f c ≤ f z := by have h' (n : ℕ) : 0 ≤ iteratedDeriv n (f · - f c) c := by cases n with | zero => simp only [iteratedDeriv_zero, sub_self, le_refl] | succ n => specialize h (n + 1) n.succ_ne_zero rw [iteratedDeriv_succ'] at h ⊢ rwa [funext fun x ↦ deriv_sub_const (f := f) (x := x) (f c)] exact sub_nonneg.mp <| nonneg_of_iteratedDeriv_nonneg (hf.sub_const _) h' hz /-- An entire function whose iterated derivatives at `c` are all real with alternating signs (except possibly the value itself) has values of the form `f c + nonneg. real` along the set `c - ℝ≥0`. -/ theorem apply_le_of_iteratedDeriv_alternating {f : ℂ → ℂ} {c : ℂ} (hf : Differentiable ℂ f) (h : ∀ n ≠ 0, 0 ≤ (-1) ^ n * iteratedDeriv n f c) ⦃z : ℂ⦄ (hz : z ≤ c) : f c ≤ f z := by convert apply_le_of_iteratedDeriv_nonneg (f := fun z ↦ f (-z)) (hf.comp <| differentiable_neg) (fun n hn ↦ ?_) (neg_le_neg_iff.mpr hz) using 1 · simp only [neg_neg] · simp only [neg_neg] · simpa only [iteratedDeriv_comp_neg, neg_neg, smul_eq_mul] using h n hn end Differentiable
.lake/packages/mathlib/Mathlib/Analysis/Complex/PhragmenLindelof.lean
import Mathlib.Analysis.Complex.AbsMax import Mathlib.Analysis.Asymptotics.SuperpolynomialDecay /-! # Phragmen-Lindelöf principle In this file we prove several versions of the Phragmen-Lindelöf principle, a version of the maximum modulus principle for an unbounded domain. ## Main statements * `PhragmenLindelof.horizontal_strip`: the Phragmen-Lindelöf principle in a horizontal strip `{z : ℂ | a < complex.im z < b}`; * `PhragmenLindelof.eq_zero_on_horizontal_strip`, `PhragmenLindelof.eqOn_horizontal_strip`: extensionality lemmas based on the Phragmen-Lindelöf principle in a horizontal strip; * `PhragmenLindelof.vertical_strip`: the Phragmen-Lindelöf principle in a vertical strip `{z : ℂ | a < complex.re z < b}`; * `PhragmenLindelof.eq_zero_on_vertical_strip`, `PhragmenLindelof.eqOn_vertical_strip`: extensionality lemmas based on the Phragmen-Lindelöf principle in a vertical strip; * `PhragmenLindelof.quadrant_I`, `PhragmenLindelof.quadrant_II`, `PhragmenLindelof.quadrant_III`, `PhragmenLindelof.quadrant_IV`: the Phragmen-Lindelöf principle in the coordinate quadrants; * `PhragmenLindelof.right_half_plane_of_tendsto_zero_on_real`, `PhragmenLindelof.right_half_plane_of_bounded_on_real`: two versions of the Phragmen-Lindelöf principle in the right half-plane; * `PhragmenLindelof.eq_zero_on_right_half_plane_of_superexponential_decay`, `PhragmenLindelof.eqOn_right_half_plane_of_superexponential_decay`: extensionality lemmas based on the Phragmen-Lindelöf principle in the right half-plane. In the case of the right half-plane, we prove a version of the Phragmen-Lindelöf principle that is useful for Ilyashenko's proof of the individual finiteness theorem (a polynomial vector field on the real plane has only finitely many limit cycles). -/ open Set Function Filter Asymptotics Metric Complex Bornology open scoped Topology Filter Real local notation "expR" => Real.exp namespace PhragmenLindelof /-! ### Auxiliary lemmas -/ variable {E : Type*} [NormedAddCommGroup E] /-- An auxiliary lemma that combines two double exponential estimates into a similar estimate on the difference of the functions. -/ theorem isBigO_sub_exp_exp {a : ℝ} {f g : ℂ → E} {l : Filter ℂ} {u : ℂ → ℝ} (hBf : ∃ c < a, ∃ B, f =O[l] fun z => expR (B * expR (c * |u z|))) (hBg : ∃ c < a, ∃ B, g =O[l] fun z => expR (B * expR (c * |u z|))) : ∃ c < a, ∃ B, (f - g) =O[l] fun z => expR (B * expR (c * |u z|)) := by have : ∀ {c₁ c₂ B₁ B₂}, c₁ ≤ c₂ → 0 ≤ B₂ → B₁ ≤ B₂ → ∀ z, ‖expR (B₁ * expR (c₁ * |u z|))‖ ≤ ‖expR (B₂ * expR (c₂ * |u z|))‖ := fun hc hB₀ hB z ↦ by simp only [Real.norm_eq_abs, Real.abs_exp]; gcongr rcases hBf with ⟨cf, hcf, Bf, hOf⟩; rcases hBg with ⟨cg, hcg, Bg, hOg⟩ refine ⟨max cf cg, max_lt hcf hcg, max 0 (max Bf Bg), ?_⟩ refine (hOf.trans_le <| this ?_ ?_ ?_).sub (hOg.trans_le <| this ?_ ?_ ?_) exacts [le_max_left _ _, le_max_left _ _, (le_max_left _ _).trans (le_max_right _ _), le_max_right _ _, le_max_left _ _, (le_max_right _ _).trans (le_max_right _ _)] /-- An auxiliary lemma that combines two “exponential of a power” estimates into a similar estimate on the difference of the functions. -/ theorem isBigO_sub_exp_rpow {a : ℝ} {f g : ℂ → E} {l : Filter ℂ} (hBf : ∃ c < a, ∃ B, f =O[cobounded ℂ ⊓ l] fun z => expR (B * ‖z‖ ^ c)) (hBg : ∃ c < a, ∃ B, g =O[cobounded ℂ ⊓ l] fun z => expR (B * ‖z‖ ^ c)) : ∃ c < a, ∃ B, (f - g) =O[cobounded ℂ ⊓ l] fun z => expR (B * ‖z‖ ^ c) := by have : ∀ {c₁ c₂ B₁ B₂ : ℝ}, c₁ ≤ c₂ → 0 ≤ B₂ → B₁ ≤ B₂ → (fun z : ℂ => expR (B₁ * ‖z‖ ^ c₁)) =O[cobounded ℂ ⊓ l] fun z => expR (B₂ * ‖z‖ ^ c₂) := fun hc hB₀ hB ↦ .of_norm_eventuallyLE <| by filter_upwards [(eventually_cobounded_le_norm 1).filter_mono inf_le_left] with z hz simp only [Real.norm_eq_abs, Real.abs_exp] gcongr; assumption rcases hBf with ⟨cf, hcf, Bf, hOf⟩; rcases hBg with ⟨cg, hcg, Bg, hOg⟩ refine ⟨max cf cg, max_lt hcf hcg, max 0 (max Bf Bg), ?_⟩ refine (hOf.trans <| this ?_ ?_ ?_).sub (hOg.trans <| this ?_ ?_ ?_) exacts [le_max_left _ _, le_max_left _ _, (le_max_left _ _).trans (le_max_right _ _), le_max_right _ _, le_max_left _ _, (le_max_right _ _).trans (le_max_right _ _)] variable [NormedSpace ℂ E] {a b C : ℝ} {f g : ℂ → E} {z : ℂ} /-! ### Phragmen-Lindelöf principle in a horizontal strip -/ /-- **Phragmen-Lindelöf principle** in a strip `U = {z : ℂ | a < im z < b}`. Let `f : ℂ → E` be a function such that * `f` is differentiable on `U` and is continuous on its closure; * `‖f z‖` is bounded from above by `A * exp(B * exp(c * |re z|))` on `U` for some `c < π / (b - a)`; * `‖f z‖` is bounded from above by a constant `C` on the boundary of `U`. Then `‖f z‖` is bounded by the same constant on the closed strip `{z : ℂ | a ≤ im z ≤ b}`. Moreover, it suffices to verify the second assumption only for sufficiently large values of `|re z|`. -/ theorem horizontal_strip (hfd : DiffContOnCl ℂ f (im ⁻¹' Ioo a b)) (hB : ∃ c < π / (b - a), ∃ B, f =O[comap (_root_.abs ∘ re) atTop ⊓ 𝓟 (im ⁻¹' Ioo a b)] fun z ↦ expR (B * expR (c * |z.re|))) (hle_a : ∀ z : ℂ, im z = a → ‖f z‖ ≤ C) (hle_b : ∀ z, im z = b → ‖f z‖ ≤ C) (hza : a ≤ im z) (hzb : im z ≤ b) : ‖f z‖ ≤ C := by -- If `im z = a` or `im z = b`, then we apply `hle_a` or `hle_b`, otherwise `im z ∈ Ioo a b`. rw [le_iff_eq_or_lt] at hza hzb rcases hza with hza | hza; · exact hle_a _ hza.symm rcases hzb with hzb | hzb; · exact hle_b _ hzb wlog hC₀ : 0 < C generalizing C · refine le_of_forall_gt_imp_ge_of_dense fun C' hC' => this (fun w hw => ?_) (fun w hw => ?_) ?_ · exact (hle_a _ hw).trans hC'.le · exact (hle_b _ hw).trans hC'.le · refine ((norm_nonneg (f (a * I))).trans (hle_a _ ?_)).trans_lt hC' rw [mul_I_im, ofReal_re] -- After a change of variables, we deal with the strip `a - b < im z < a + b` instead -- of `a < im z < b` obtain ⟨a, b, rfl, rfl⟩ : ∃ a' b', a = a' - b' ∧ b = a' + b' := ⟨(a + b) / 2, (b - a) / 2, by ring, by ring⟩ have hab : a - b < a + b := hza.trans hzb have hb : 0 < b := by simpa only [sub_eq_add_neg, add_lt_add_iff_left, neg_lt_self_iff] using hab rw [add_sub_sub_cancel, ← two_mul, div_mul_eq_div_div] at hB have hπb : 0 < π / 2 / b := div_pos Real.pi_div_two_pos hb -- Choose some `c B : ℝ` satisfying `hB`, then choose `max c 0 < d < π / 2 / b`. rcases hB with ⟨c, hc, B, hO⟩ obtain ⟨d, ⟨hcd, hd₀⟩, hd⟩ : ∃ d, (c < d ∧ 0 < d) ∧ d < π / 2 / b := by simpa only [max_lt_iff] using exists_between (max_lt hc hπb) have hb' : d * b < π / 2 := (lt_div_iff₀ hb).1 hd set aff := (fun w => d * (w - a * I) : ℂ → ℂ) set g := fun (ε : ℝ) (w : ℂ) => exp (ε * (exp (aff w) + exp (-aff w))) /- Since `g ε z → 1` as `ε → 0⁻`, it suffices to prove that `‖g ε z • f z‖ ≤ C` for all negative `ε`. -/ suffices ∀ᶠ ε : ℝ in 𝓝[<] (0 : ℝ), ‖g ε z • f z‖ ≤ C by refine le_of_tendsto (Tendsto.mono_left ?_ nhdsWithin_le_nhds) this apply ((continuous_ofReal.mul continuous_const).cexp.smul continuous_const).norm.tendsto' simp filter_upwards [self_mem_nhdsWithin] with ε ε₀; change ε < 0 at ε₀ -- An upper estimate on `‖g ε w‖` that will be used in two branches of the proof. obtain ⟨δ, δ₀, hδ⟩ : ∃ δ : ℝ, δ < 0 ∧ ∀ ⦃w⦄, im w ∈ Icc (a - b) (a + b) → ‖g ε w‖ ≤ expR (δ * expR (d * |re w|)) := by refine ⟨ε * Real.cos (d * b), mul_neg_of_neg_of_pos ε₀ (Real.cos_pos_of_mem_Ioo <| abs_lt.1 <| (abs_of_pos (mul_pos hd₀ hb)).symm ▸ hb'), fun w hw => ?_⟩ replace hw : |im (aff w)| ≤ d * b := by rw [← Real.closedBall_eq_Icc, mem_closedBall, Real.dist_eq] at hw rw [im_ofReal_mul, sub_im, mul_I_im, ofReal_re, _root_.abs_mul, abs_of_pos hd₀] gcongr simpa only [aff, re_ofReal_mul, _root_.abs_mul, abs_of_pos hd₀, sub_re, mul_I_re, ofReal_im, zero_mul, neg_zero, sub_zero] using norm_exp_mul_exp_add_exp_neg_le_of_abs_im_le ε₀.le hw hb'.le -- `abs (g ε w) ≤ 1` on the lines `w.im = a ± b` (actually, it holds everywhere in the strip) have hg₁ : ∀ w, im w = a - b ∨ im w = a + b → ‖g ε w‖ ≤ 1 := by refine fun w hw => (hδ <| hw.by_cases ?_ ?_).trans (Real.exp_le_one_iff.2 ?_) exacts [fun h => h.symm ▸ left_mem_Icc.2 hab.le, fun h => h.symm ▸ right_mem_Icc.2 hab.le, mul_nonpos_of_nonpos_of_nonneg δ₀.le (Real.exp_pos _).le] /- Our a priori estimate on `f` implies that `g ε w • f w → 0` as `|w.re| → ∞` along the strip. In particular, its norm is less than or equal to `C` for sufficiently large `|w.re|`. -/ obtain ⟨R, hzR, hR⟩ : ∃ R : ℝ, |z.re| < R ∧ ∀ w, |re w| = R → im w ∈ Ioo (a - b) (a + b) → ‖g ε w • f w‖ ≤ C := by refine ((eventually_gt_atTop _).and ?_).exists rcases hO.exists_pos with ⟨A, hA₀, hA⟩ simp only [isBigOWith_iff, eventually_inf_principal, eventually_comap, mem_Ioo, mem_preimage, (· ∘ ·), Real.norm_eq_abs, abs_of_pos (Real.exp_pos _)] at hA suffices Tendsto (fun R => expR (δ * expR (d * R) + B * expR (c * R) + Real.log A)) atTop (𝓝 0) by filter_upwards [this.eventually (ge_mem_nhds hC₀), hA] with R hR Hle w hre him calc ‖g ε w • f w‖ ≤ expR (δ * expR (d * R) + B * expR (c * R) + Real.log A) := ?_ _ ≤ C := hR rw [norm_smul, Real.exp_add, ← hre, Real.exp_add, Real.exp_log hA₀, mul_assoc, mul_comm _ A] gcongr exacts [hδ <| Ioo_subset_Icc_self him, Hle _ hre him] refine Real.tendsto_exp_atBot.comp ?_ suffices H : Tendsto (fun R => δ + B * (expR ((d - c) * R))⁻¹) atTop (𝓝 (δ + B * 0)) by rw [mul_zero, add_zero] at H refine Tendsto.atBot_add ?_ tendsto_const_nhds simpa only [id, (· ∘ ·), add_mul, mul_assoc, ← div_eq_inv_mul, ← Real.exp_sub, ← sub_mul, sub_sub_cancel] using H.neg_mul_atTop δ₀ <| Real.tendsto_exp_atTop.comp <| tendsto_id.const_mul_atTop hd₀ refine tendsto_const_nhds.add (tendsto_const_nhds.mul ?_) exact tendsto_inv_atTop_zero.comp <| Real.tendsto_exp_atTop.comp <| tendsto_id.const_mul_atTop (sub_pos.2 hcd) have hR₀ : 0 < R := (_root_.abs_nonneg _).trans_lt hzR /- Finally, we apply the bounded version of the maximum modulus principle to the rectangle `(-R, R) × (a - b, a + b)`. The function is bounded by `C` on the horizontal sides by assumption (and because `‖g ε w‖ ≤ 1`) and on the vertical sides by the choice of `R`. -/ have hgd : Differentiable ℂ (g ε) := ((((differentiable_id.sub_const _).const_mul _).cexp.add ((differentiable_id.sub_const _).const_mul _).neg.cexp).const_mul _).cexp replace hd : DiffContOnCl ℂ (fun w => g ε w • f w) (Ioo (-R) R ×ℂ Ioo (a - b) (a + b)) := (hgd.diffContOnCl.smul hfd).mono inter_subset_right convert norm_le_of_forall_mem_frontier_norm_le ((isBounded_Ioo _ _).reProdIm (isBounded_Ioo _ _)) hd (fun w hw => _) _ · rw [frontier_reProdIm, closure_Ioo (neg_lt_self hR₀).ne, frontier_Ioo hab, closure_Ioo hab.ne, frontier_Ioo (neg_lt_self hR₀)] at hw by_cases him : w.im = a - b ∨ w.im = a + b · rw [norm_smul, ← one_mul C] exact mul_le_mul (hg₁ _ him) (him.by_cases (hle_a _) (hle_b _)) (norm_nonneg _) zero_le_one · replace hw : w ∈ {-R, R} ×ℂ Icc (a - b) (a + b) := hw.resolve_left fun h ↦ him h.2 have hw' := eq_endpoints_or_mem_Ioo_of_mem_Icc hw.2; rw [← or_assoc] at hw' exact hR _ ((abs_eq hR₀.le).2 hw.1.symm) (hw'.resolve_left him) · rw [closure_reProdIm, closure_Ioo hab.ne, closure_Ioo (neg_lt_self hR₀).ne] exact ⟨abs_le.1 hzR.le, ⟨hza.le, hzb.le⟩⟩ /-- **Phragmen-Lindelöf principle** in a strip `U = {z : ℂ | a < im z < b}`. Let `f : ℂ → E` be a function such that * `f` is differentiable on `U` and is continuous on its closure; * `‖f z‖` is bounded from above by `A * exp(B * exp(c * |re z|))` on `U` for some `c < π / (b - a)`; * `f z = 0` on the boundary of `U`. Then `f` is equal to zero on the closed strip `{z : ℂ | a ≤ im z ≤ b}`. -/ theorem eq_zero_on_horizontal_strip (hd : DiffContOnCl ℂ f (im ⁻¹' Ioo a b)) (hB : ∃ c < π / (b - a), ∃ B, f =O[comap (_root_.abs ∘ re) atTop ⊓ 𝓟 (im ⁻¹' Ioo a b)] fun z ↦ expR (B * expR (c * |z.re|))) (ha : ∀ z : ℂ, z.im = a → f z = 0) (hb : ∀ z : ℂ, z.im = b → f z = 0) : EqOn f 0 (im ⁻¹' Icc a b) := fun _z hz => norm_le_zero_iff.1 <| horizontal_strip hd hB (fun z hz => (ha z hz).symm ▸ norm_zero.le) (fun z hz => (hb z hz).symm ▸ norm_zero.le) hz.1 hz.2 /-- **Phragmen-Lindelöf principle** in a strip `U = {z : ℂ | a < im z < b}`. Let `f g : ℂ → E` be functions such that * `f` and `g` are differentiable on `U` and are continuous on its closure; * `‖f z‖` and `‖g z‖` are bounded from above by `A * exp(B * exp(c * |re z|))` on `U` for some `c < π / (b - a)`; * `f z = g z` on the boundary of `U`. Then `f` is equal to `g` on the closed strip `{z : ℂ | a ≤ im z ≤ b}`. -/ theorem eqOn_horizontal_strip {g : ℂ → E} (hdf : DiffContOnCl ℂ f (im ⁻¹' Ioo a b)) (hBf : ∃ c < π / (b - a), ∃ B, f =O[comap (_root_.abs ∘ re) atTop ⊓ 𝓟 (im ⁻¹' Ioo a b)] fun z ↦ expR (B * expR (c * |z.re|))) (hdg : DiffContOnCl ℂ g (im ⁻¹' Ioo a b)) (hBg : ∃ c < π / (b - a), ∃ B, g =O[comap (_root_.abs ∘ re) atTop ⊓ 𝓟 (im ⁻¹' Ioo a b)] fun z ↦ expR (B * expR (c * |z.re|))) (ha : ∀ z : ℂ, z.im = a → f z = g z) (hb : ∀ z : ℂ, z.im = b → f z = g z) : EqOn f g (im ⁻¹' Icc a b) := fun _z hz => sub_eq_zero.1 (eq_zero_on_horizontal_strip (hdf.sub hdg) (isBigO_sub_exp_exp hBf hBg) (fun w hw => sub_eq_zero.2 (ha w hw)) (fun w hw => sub_eq_zero.2 (hb w hw)) hz) /-! ### Phragmen-Lindelöf principle in a vertical strip -/ /-- **Phragmen-Lindelöf principle** in a strip `U = {z : ℂ | a < re z < b}`. Let `f : ℂ → E` be a function such that * `f` is differentiable on `U` and is continuous on its closure; * `‖f z‖` is bounded from above by `A * exp(B * exp(c * |im z|))` on `U` for some `c < π / (b - a)`; * `‖f z‖` is bounded from above by a constant `C` on the boundary of `U`. Then `‖f z‖` is bounded by the same constant on the closed strip `{z : ℂ | a ≤ re z ≤ b}`. Moreover, it suffices to verify the second assumption only for sufficiently large values of `|im z|`. -/ theorem vertical_strip (hfd : DiffContOnCl ℂ f (re ⁻¹' Ioo a b)) (hB : ∃ c < π / (b - a), ∃ B, f =O[comap (_root_.abs ∘ im) atTop ⊓ 𝓟 (re ⁻¹' Ioo a b)] fun z ↦ expR (B * expR (c * |z.im|))) (hle_a : ∀ z : ℂ, re z = a → ‖f z‖ ≤ C) (hle_b : ∀ z, re z = b → ‖f z‖ ≤ C) (hza : a ≤ re z) (hzb : re z ≤ b) : ‖f z‖ ≤ C := by suffices ‖f (z * I * -I)‖ ≤ C by simpa [mul_assoc] using this have H : MapsTo (· * -I) (im ⁻¹' Ioo a b) (re ⁻¹' Ioo a b) := fun z hz ↦ by simpa using hz refine horizontal_strip (f := fun z ↦ f (z * -I)) (hfd.comp (differentiable_id.mul_const _).diffContOnCl H) ?_ (fun z hz => hle_a _ ?_) (fun z hz => hle_b _ ?_) ?_ ?_ · rcases hB with ⟨c, hc, B, hO⟩ refine ⟨c, hc, B, ?_⟩ have : Tendsto (· * -I) (comap (|re ·|) atTop ⊓ 𝓟 (im ⁻¹' Ioo a b)) (comap (|im ·|) atTop ⊓ 𝓟 (re ⁻¹' Ioo a b)) := by refine (tendsto_comap_iff.2 ?_).inf H.tendsto simpa [Function.comp_def] using tendsto_comap simpa [Function.comp_def] using hO.comp_tendsto this all_goals simpa /-- **Phragmen-Lindelöf principle** in a strip `U = {z : ℂ | a < re z < b}`. Let `f : ℂ → E` be a function such that * `f` is differentiable on `U` and is continuous on its closure; * `‖f z‖` is bounded from above by `A * exp(B * exp(c * |im z|))` on `U` for some `c < π / (b - a)`; * `f z = 0` on the boundary of `U`. Then `f` is equal to zero on the closed strip `{z : ℂ | a ≤ re z ≤ b}`. -/ theorem eq_zero_on_vertical_strip (hd : DiffContOnCl ℂ f (re ⁻¹' Ioo a b)) (hB : ∃ c < π / (b - a), ∃ B, f =O[comap (_root_.abs ∘ im) atTop ⊓ 𝓟 (re ⁻¹' Ioo a b)] fun z ↦ expR (B * expR (c * |z.im|))) (ha : ∀ z : ℂ, re z = a → f z = 0) (hb : ∀ z : ℂ, re z = b → f z = 0) : EqOn f 0 (re ⁻¹' Icc a b) := fun _z hz => norm_le_zero_iff.1 <| vertical_strip hd hB (fun z hz => (ha z hz).symm ▸ norm_zero.le) (fun z hz => (hb z hz).symm ▸ norm_zero.le) hz.1 hz.2 /-- **Phragmen-Lindelöf principle** in a strip `U = {z : ℂ | a < re z < b}`. Let `f g : ℂ → E` be functions such that * `f` and `g` are differentiable on `U` and are continuous on its closure; * `‖f z‖` and `‖g z‖` are bounded from above by `A * exp(B * exp(c * |im z|))` on `U` for some `c < π / (b - a)`; * `f z = g z` on the boundary of `U`. Then `f` is equal to `g` on the closed strip `{z : ℂ | a ≤ re z ≤ b}`. -/ theorem eqOn_vertical_strip {g : ℂ → E} (hdf : DiffContOnCl ℂ f (re ⁻¹' Ioo a b)) (hBf : ∃ c < π / (b - a), ∃ B, f =O[comap (_root_.abs ∘ im) atTop ⊓ 𝓟 (re ⁻¹' Ioo a b)] fun z ↦ expR (B * expR (c * |z.im|))) (hdg : DiffContOnCl ℂ g (re ⁻¹' Ioo a b)) (hBg : ∃ c < π / (b - a), ∃ B, g =O[comap (_root_.abs ∘ im) atTop ⊓ 𝓟 (re ⁻¹' Ioo a b)] fun z ↦ expR (B * expR (c * |z.im|))) (ha : ∀ z : ℂ, re z = a → f z = g z) (hb : ∀ z : ℂ, re z = b → f z = g z) : EqOn f g (re ⁻¹' Icc a b) := fun _z hz => sub_eq_zero.1 (eq_zero_on_vertical_strip (hdf.sub hdg) (isBigO_sub_exp_exp hBf hBg) (fun w hw => sub_eq_zero.2 (ha w hw)) (fun w hw => sub_eq_zero.2 (hb w hw)) hz) /-! ### Phragmen-Lindelöf principle in coordinate quadrants -/ /-- **Phragmen-Lindelöf principle** in the first quadrant. Let `f : ℂ → E` be a function such that * `f` is differentiable in the open first quadrant and is continuous on its closure; * `‖f z‖` is bounded from above by `A * exp(B * ‖z‖ ^ c)` on the open first quadrant for some `c < 2`; * `‖f z‖` is bounded from above by a constant `C` on the boundary of the first quadrant. Then `‖f z‖` is bounded from above by the same constant on the closed first quadrant. -/ nonrec theorem quadrant_I (hd : DiffContOnCl ℂ f (Ioi 0 ×ℂ Ioi 0)) (hB : ∃ c < (2 : ℝ), ∃ B, f =O[cobounded ℂ ⊓ 𝓟 (Ioi 0 ×ℂ Ioi 0)] fun z => expR (B * ‖z‖ ^ c)) (hre : ∀ x : ℝ, 0 ≤ x → ‖f x‖ ≤ C) (him : ∀ x : ℝ, 0 ≤ x → ‖f (x * I)‖ ≤ C) (hz_re : 0 ≤ z.re) (hz_im : 0 ≤ z.im) : ‖f z‖ ≤ C := by -- The case `z = 0` is trivial. rcases eq_or_ne z 0 with (rfl | hzne) · exact hre 0 le_rfl -- Otherwise, `z = e ^ ζ` for some `ζ : ℂ`, `0 < Im ζ < π / 2`. obtain ⟨ζ, hζ, rfl⟩ : ∃ ζ : ℂ, ζ.im ∈ Icc 0 (π / 2) ∧ exp ζ = z := by refine ⟨log z, ?_, exp_log hzne⟩ rw [log_im] exact ⟨arg_nonneg_iff.2 hz_im, arg_le_pi_div_two_iff.2 (Or.inl hz_re)⟩ -- We are going to apply `PhragmenLindelof.horizontal_strip` to `f ∘ Complex.exp` and `ζ`. change ‖(f ∘ exp) ζ‖ ≤ C have H : MapsTo exp (im ⁻¹' Ioo 0 (π / 2)) (Ioi 0 ×ℂ Ioi 0) := fun z hz ↦ by rw [mem_reProdIm, exp_re, exp_im, mem_Ioi, mem_Ioi] have : 0 < Real.cos z.im := Real.cos_pos_of_mem_Ioo ⟨by linarith [hz.1, hz.2], hz.2⟩ have : 0 < Real.sin z.im := Real.sin_pos_of_mem_Ioo ⟨hz.1, hz.2.trans (half_lt_self Real.pi_pos)⟩ constructor <;> positivity refine horizontal_strip (hd.comp differentiable_exp.diffContOnCl H) ?_ ?_ ?_ hζ.1 hζ.2 · -- The estimate `hB` on `f` implies the required estimate on -- `f ∘ exp` with the same `c` and `B' = max B 0`. rw [sub_zero, div_div_cancel₀ Real.pi_pos.ne'] rcases hB with ⟨c, hc, B, hO⟩ refine ⟨c, hc, max B 0, ?_⟩ rw [← comap_comap, comap_abs_atTop, comap_sup, inf_sup_right] -- We prove separately the estimates as `ζ.re → ∞` and as `ζ.re → -∞` refine IsBigO.sup ?_ <| (hO.comp_tendsto <| tendsto_exp_comap_re_atTop.inf H.tendsto).trans <| .of_norm_eventuallyLE ?_ · -- For the estimate as `ζ.re → -∞`, note that `f` is continuous within the first quadrant at -- zero, hence `f (exp ζ)` has a limit as `ζ.re → -∞`, `0 < ζ.im < π / 2`. have hc : ContinuousWithinAt f (Ioi 0 ×ℂ Ioi 0) 0 := by refine (hd.continuousOn _ ?_).mono subset_closure simp [closure_reProdIm, mem_reProdIm] refine ((hc.tendsto.comp <| tendsto_exp_comap_re_atBot.inf H.tendsto).isBigO_one ℝ).trans (isBigO_of_le _ fun w => ?_) rw [norm_one, Real.norm_of_nonneg (Real.exp_pos _).le, Real.one_le_exp_iff] positivity · -- For the estimate as `ζ.re → ∞`, we reuse the upper estimate on `f` simp only [EventuallyLE, eventually_inf_principal, eventually_comap, comp_apply, Real.norm_of_nonneg (Real.exp_pos _).le, norm_exp, ← Real.exp_mul, Real.exp_le_exp] filter_upwards [eventually_ge_atTop 0] with x hx z hz _ rw [hz, abs_of_nonneg hx, mul_comm _ c] gcongr; apply le_max_left · -- If `ζ.im = 0`, then `Complex.exp ζ` is a positive real number intro ζ hζ; lift ζ to ℝ using hζ rw [comp_apply, ← ofReal_exp] exact hre _ (Real.exp_pos _).le · -- If `ζ.im = π / 2`, then `Complex.exp ζ` is a purely imaginary number with positive `im` intro ζ hζ rw [← re_add_im ζ, hζ, comp_apply, exp_add_mul_I, ← ofReal_cos, ← ofReal_sin, Real.cos_pi_div_two, Real.sin_pi_div_two, ofReal_zero, ofReal_one, one_mul, zero_add, ← ofReal_exp] exact him _ (Real.exp_pos _).le /-- **Phragmen-Lindelöf principle** in the first quadrant. Let `f : ℂ → E` be a function such that * `f` is differentiable in the open first quadrant and is continuous on its closure; * `‖f z‖` is bounded from above by `A * exp(B * ‖z‖ ^ c)` on the open first quadrant for some `A`, `B`, and `c < 2`; * `f` is equal to zero on the boundary of the first quadrant. Then `f` is equal to zero on the closed first quadrant. -/ theorem eq_zero_on_quadrant_I (hd : DiffContOnCl ℂ f (Ioi 0 ×ℂ Ioi 0)) (hB : ∃ c < (2 : ℝ), ∃ B, f =O[cobounded ℂ ⊓ 𝓟 (Ioi 0 ×ℂ Ioi 0)] fun z => expR (B * ‖z‖ ^ c)) (hre : ∀ x : ℝ, 0 ≤ x → f x = 0) (him : ∀ x : ℝ, 0 ≤ x → f (x * I) = 0) : EqOn f 0 {z | 0 ≤ z.re ∧ 0 ≤ z.im} := fun _z hz => norm_le_zero_iff.1 <| quadrant_I hd hB (fun x hx => norm_le_zero_iff.2 <| hre x hx) (fun x hx => norm_le_zero_iff.2 <| him x hx) hz.1 hz.2 /-- **Phragmen-Lindelöf principle** in the first quadrant. Let `f g : ℂ → E` be functions such that * `f` and `g` are differentiable in the open first quadrant and are continuous on its closure; * `‖f z‖` and `‖g z‖` are bounded from above by `A * exp(B * ‖z‖ ^ c)` on the open first quadrant for some `A`, `B`, and `c < 2`; * `f` is equal to `g` on the boundary of the first quadrant. Then `f` is equal to `g` on the closed first quadrant. -/ theorem eqOn_quadrant_I (hdf : DiffContOnCl ℂ f (Ioi 0 ×ℂ Ioi 0)) (hBf : ∃ c < (2 : ℝ), ∃ B, f =O[cobounded ℂ ⊓ 𝓟 (Ioi 0 ×ℂ Ioi 0)] fun z => expR (B * ‖z‖ ^ c)) (hdg : DiffContOnCl ℂ g (Ioi 0 ×ℂ Ioi 0)) (hBg : ∃ c < (2 : ℝ), ∃ B, g =O[cobounded ℂ ⊓ 𝓟 (Ioi 0 ×ℂ Ioi 0)] fun z => expR (B * ‖z‖ ^ c)) (hre : ∀ x : ℝ, 0 ≤ x → f x = g x) (him : ∀ x : ℝ, 0 ≤ x → f (x * I) = g (x * I)) : EqOn f g {z | 0 ≤ z.re ∧ 0 ≤ z.im} := fun _z hz => sub_eq_zero.1 <| eq_zero_on_quadrant_I (hdf.sub hdg) (isBigO_sub_exp_rpow hBf hBg) (fun x hx => sub_eq_zero.2 <| hre x hx) (fun x hx => sub_eq_zero.2 <| him x hx) hz /-- **Phragmen-Lindelöf principle** in the second quadrant. Let `f : ℂ → E` be a function such that * `f` is differentiable in the open second quadrant and is continuous on its closure; * `‖f z‖` is bounded from above by `A * exp(B * ‖z‖ ^ c)` on the open second quadrant for some `c < 2`; * `‖f z‖` is bounded from above by a constant `C` on the boundary of the second quadrant. Then `‖f z‖` is bounded from above by the same constant on the closed second quadrant. -/ theorem quadrant_II (hd : DiffContOnCl ℂ f (Iio 0 ×ℂ Ioi 0)) (hB : ∃ c < (2 : ℝ), ∃ B, f =O[cobounded ℂ ⊓ 𝓟 (Iio 0 ×ℂ Ioi 0)] fun z => expR (B * ‖z‖ ^ c)) (hre : ∀ x : ℝ, x ≤ 0 → ‖f x‖ ≤ C) (him : ∀ x : ℝ, 0 ≤ x → ‖f (x * I)‖ ≤ C) (hz_re : z.re ≤ 0) (hz_im : 0 ≤ z.im) : ‖f z‖ ≤ C := by obtain ⟨z, rfl⟩ : ∃ z', z' * I = z := ⟨z / I, div_mul_cancel₀ _ I_ne_zero⟩ simp only [mul_I_re, mul_I_im, neg_nonpos] at hz_re hz_im change ‖(f ∘ (· * I)) z‖ ≤ C have H : MapsTo (· * I) (Ioi 0 ×ℂ Ioi 0) (Iio 0 ×ℂ Ioi 0) := fun w hw ↦ by simpa only [mem_reProdIm, mul_I_re, mul_I_im, neg_lt_zero, mem_Iio] using hw.symm rcases hB with ⟨c, hc, B, hO⟩ refine quadrant_I (hd.comp (differentiable_id.mul_const _).diffContOnCl H) ⟨c, hc, B, ?_⟩ him (fun x hx => ?_) hz_im hz_re · simpa only [Function.comp_def, norm_mul, norm_I, mul_one] using hO.comp_tendsto ((tendsto_mul_right_cobounded I_ne_zero).inf H.tendsto) · rw [comp_apply, mul_assoc, I_mul_I, mul_neg_one, ← ofReal_neg] exact hre _ (neg_nonpos.2 hx) /-- **Phragmen-Lindelöf principle** in the second quadrant. Let `f : ℂ → E` be a function such that * `f` is differentiable in the open second quadrant and is continuous on its closure; * `‖f z‖` is bounded from above by `A * exp(B * ‖z‖ ^ c)` on the open second quadrant for some `A`, `B`, and `c < 2`; * `f` is equal to zero on the boundary of the second quadrant. Then `f` is equal to zero on the closed second quadrant. -/ theorem eq_zero_on_quadrant_II (hd : DiffContOnCl ℂ f (Iio 0 ×ℂ Ioi 0)) (hB : ∃ c < (2 : ℝ), ∃ B, f =O[cobounded ℂ ⊓ 𝓟 (Iio 0 ×ℂ Ioi 0)] fun z => expR (B * ‖z‖ ^ c)) (hre : ∀ x : ℝ, x ≤ 0 → f x = 0) (him : ∀ x : ℝ, 0 ≤ x → f (x * I) = 0) : EqOn f 0 {z | z.re ≤ 0 ∧ 0 ≤ z.im} := fun _z hz => norm_le_zero_iff.1 <| quadrant_II hd hB (fun x hx => norm_le_zero_iff.2 <| hre x hx) (fun x hx => norm_le_zero_iff.2 <| him x hx) hz.1 hz.2 /-- **Phragmen-Lindelöf principle** in the second quadrant. Let `f g : ℂ → E` be functions such that * `f` and `g` are differentiable in the open second quadrant and are continuous on its closure; * `‖f z‖` and `‖g z‖` are bounded from above by `A * exp(B * ‖z‖ ^ c)` on the open second quadrant for some `A`, `B`, and `c < 2`; * `f` is equal to `g` on the boundary of the second quadrant. Then `f` is equal to `g` on the closed second quadrant. -/ theorem eqOn_quadrant_II (hdf : DiffContOnCl ℂ f (Iio 0 ×ℂ Ioi 0)) (hBf : ∃ c < (2 : ℝ), ∃ B, f =O[cobounded ℂ ⊓ 𝓟 (Iio 0 ×ℂ Ioi 0)] fun z => expR (B * ‖z‖ ^ c)) (hdg : DiffContOnCl ℂ g (Iio 0 ×ℂ Ioi 0)) (hBg : ∃ c < (2 : ℝ), ∃ B, g =O[cobounded ℂ ⊓ 𝓟 (Iio 0 ×ℂ Ioi 0)] fun z => expR (B * ‖z‖ ^ c)) (hre : ∀ x : ℝ, x ≤ 0 → f x = g x) (him : ∀ x : ℝ, 0 ≤ x → f (x * I) = g (x * I)) : EqOn f g {z | z.re ≤ 0 ∧ 0 ≤ z.im} := fun _z hz => sub_eq_zero.1 <| eq_zero_on_quadrant_II (hdf.sub hdg) (isBigO_sub_exp_rpow hBf hBg) (fun x hx => sub_eq_zero.2 <| hre x hx) (fun x hx => sub_eq_zero.2 <| him x hx) hz /-- **Phragmen-Lindelöf principle** in the third quadrant. Let `f : ℂ → E` be a function such that * `f` is differentiable in the open third quadrant and is continuous on its closure; * `‖f z‖` is bounded from above by `A * exp (B * ‖z‖ ^ c)` on the open third quadrant for some `c < 2`; * `‖f z‖` is bounded from above by a constant `C` on the boundary of the third quadrant. Then `‖f z‖` is bounded from above by the same constant on the closed third quadrant. -/ theorem quadrant_III (hd : DiffContOnCl ℂ f (Iio 0 ×ℂ Iio 0)) (hB : ∃ c < (2 : ℝ), ∃ B, f =O[cobounded ℂ ⊓ 𝓟 (Iio 0 ×ℂ Iio 0)] fun z => expR (B * ‖z‖ ^ c)) (hre : ∀ x : ℝ, x ≤ 0 → ‖f x‖ ≤ C) (him : ∀ x : ℝ, x ≤ 0 → ‖f (x * I)‖ ≤ C) (hz_re : z.re ≤ 0) (hz_im : z.im ≤ 0) : ‖f z‖ ≤ C := by obtain ⟨z, rfl⟩ : ∃ z', -z' = z := ⟨-z, neg_neg z⟩ simp only [neg_re, neg_im, neg_nonpos] at hz_re hz_im change ‖(f ∘ Neg.neg) z‖ ≤ C have H : MapsTo Neg.neg (Ioi 0 ×ℂ Ioi 0) (Iio 0 ×ℂ Iio 0) := by intro w hw simpa only [mem_reProdIm, neg_re, neg_im, neg_lt_zero, mem_Iio] using hw refine quadrant_I (hd.comp differentiable_neg.diffContOnCl H) ?_ (fun x hx => ?_) (fun x hx => ?_) hz_re hz_im · rcases hB with ⟨c, hc, B, hO⟩ refine ⟨c, hc, B, ?_⟩ simpa only [Function.comp_def, norm_neg] using hO.comp_tendsto (Filter.tendsto_neg_cobounded.inf H.tendsto) · rw [comp_apply, ← ofReal_neg] exact hre (-x) (neg_nonpos.2 hx) · rw [comp_apply, ← neg_mul, ← ofReal_neg] exact him (-x) (neg_nonpos.2 hx) /-- **Phragmen-Lindelöf principle** in the third quadrant. Let `f : ℂ → E` be a function such that * `f` is differentiable in the open third quadrant and is continuous on its closure; * `‖f z‖` is bounded from above by `A * exp(B * ‖z‖ ^ c)` on the open third quadrant for some `A`, `B`, and `c < 2`; * `f` is equal to zero on the boundary of the third quadrant. Then `f` is equal to zero on the closed third quadrant. -/ theorem eq_zero_on_quadrant_III (hd : DiffContOnCl ℂ f (Iio 0 ×ℂ Iio 0)) (hB : ∃ c < (2 : ℝ), ∃ B, f =O[cobounded ℂ ⊓ 𝓟 (Iio 0 ×ℂ Iio 0)] fun z => expR (B * ‖z‖ ^ c)) (hre : ∀ x : ℝ, x ≤ 0 → f x = 0) (him : ∀ x : ℝ, x ≤ 0 → f (x * I) = 0) : EqOn f 0 {z | z.re ≤ 0 ∧ z.im ≤ 0} := fun _z hz => norm_le_zero_iff.1 <| quadrant_III hd hB (fun x hx => norm_le_zero_iff.2 <| hre x hx) (fun x hx => norm_le_zero_iff.2 <| him x hx) hz.1 hz.2 /-- **Phragmen-Lindelöf principle** in the third quadrant. Let `f g : ℂ → E` be functions such that * `f` and `g` are differentiable in the open third quadrant and are continuous on its closure; * `‖f z‖` and `‖g z‖` are bounded from above by `A * exp(B * ‖z‖ ^ c)` on the open third quadrant for some `A`, `B`, and `c < 2`; * `f` is equal to `g` on the boundary of the third quadrant. Then `f` is equal to `g` on the closed third quadrant. -/ theorem eqOn_quadrant_III (hdf : DiffContOnCl ℂ f (Iio 0 ×ℂ Iio 0)) (hBf : ∃ c < (2 : ℝ), ∃ B, f =O[cobounded ℂ ⊓ 𝓟 (Iio 0 ×ℂ Iio 0)] fun z => expR (B * ‖z‖ ^ c)) (hdg : DiffContOnCl ℂ g (Iio 0 ×ℂ Iio 0)) (hBg : ∃ c < (2 : ℝ), ∃ B, g =O[cobounded ℂ ⊓ 𝓟 (Iio 0 ×ℂ Iio 0)] fun z => expR (B * ‖z‖ ^ c)) (hre : ∀ x : ℝ, x ≤ 0 → f x = g x) (him : ∀ x : ℝ, x ≤ 0 → f (x * I) = g (x * I)) : EqOn f g {z | z.re ≤ 0 ∧ z.im ≤ 0} := fun _z hz => sub_eq_zero.1 <| eq_zero_on_quadrant_III (hdf.sub hdg) (isBigO_sub_exp_rpow hBf hBg) (fun x hx => sub_eq_zero.2 <| hre x hx) (fun x hx => sub_eq_zero.2 <| him x hx) hz /-- **Phragmen-Lindelöf principle** in the fourth quadrant. Let `f : ℂ → E` be a function such that * `f` is differentiable in the open fourth quadrant and is continuous on its closure; * `‖f z‖` is bounded from above by `A * exp(B * ‖z‖ ^ c)` on the open fourth quadrant for some `c < 2`; * `‖f z‖` is bounded from above by a constant `C` on the boundary of the fourth quadrant. Then `‖f z‖` is bounded from above by the same constant on the closed fourth quadrant. -/ theorem quadrant_IV (hd : DiffContOnCl ℂ f (Ioi 0 ×ℂ Iio 0)) (hB : ∃ c < (2 : ℝ), ∃ B, f =O[cobounded ℂ ⊓ 𝓟 (Ioi 0 ×ℂ Iio 0)] fun z => expR (B * ‖z‖ ^ c)) (hre : ∀ x : ℝ, 0 ≤ x → ‖f x‖ ≤ C) (him : ∀ x : ℝ, x ≤ 0 → ‖f (x * I)‖ ≤ C) (hz_re : 0 ≤ z.re) (hz_im : z.im ≤ 0) : ‖f z‖ ≤ C := by obtain ⟨z, rfl⟩ : ∃ z', -z' = z := ⟨-z, neg_neg z⟩ simp only [neg_re, neg_im, neg_nonpos, neg_nonneg] at hz_re hz_im change ‖(f ∘ Neg.neg) z‖ ≤ C have H : MapsTo Neg.neg (Iio 0 ×ℂ Ioi 0) (Ioi 0 ×ℂ Iio 0) := fun w hw ↦ by simpa only [mem_reProdIm, neg_re, neg_im, neg_lt_zero, neg_pos, mem_Ioi, mem_Iio] using hw refine quadrant_II (hd.comp differentiable_neg.diffContOnCl H) ?_ (fun x hx => ?_) (fun x hx => ?_) hz_re hz_im · rcases hB with ⟨c, hc, B, hO⟩ refine ⟨c, hc, B, ?_⟩ simpa only [Function.comp_def, norm_neg] using hO.comp_tendsto (Filter.tendsto_neg_cobounded.inf H.tendsto) · rw [comp_apply, ← ofReal_neg] exact hre (-x) (neg_nonneg.2 hx) · rw [comp_apply, ← neg_mul, ← ofReal_neg] exact him (-x) (neg_nonpos.2 hx) /-- **Phragmen-Lindelöf principle** in the fourth quadrant. Let `f : ℂ → E` be a function such that * `f` is differentiable in the open fourth quadrant and is continuous on its closure; * `‖f z‖` is bounded from above by `A * exp(B * ‖z‖ ^ c)` on the open fourth quadrant for some `A`, `B`, and `c < 2`; * `f` is equal to zero on the boundary of the fourth quadrant. Then `f` is equal to zero on the closed fourth quadrant. -/ theorem eq_zero_on_quadrant_IV (hd : DiffContOnCl ℂ f (Ioi 0 ×ℂ Iio 0)) (hB : ∃ c < (2 : ℝ), ∃ B, f =O[cobounded ℂ ⊓ 𝓟 (Ioi 0 ×ℂ Iio 0)] fun z => expR (B * ‖z‖ ^ c)) (hre : ∀ x : ℝ, 0 ≤ x → f x = 0) (him : ∀ x : ℝ, x ≤ 0 → f (x * I) = 0) : EqOn f 0 {z | 0 ≤ z.re ∧ z.im ≤ 0} := fun _z hz => norm_le_zero_iff.1 <| quadrant_IV hd hB (fun x hx => norm_le_zero_iff.2 <| hre x hx) (fun x hx => norm_le_zero_iff.2 <| him x hx) hz.1 hz.2 /-- **Phragmen-Lindelöf principle** in the fourth quadrant. Let `f g : ℂ → E` be functions such that * `f` and `g` are differentiable in the open fourth quadrant and are continuous on its closure; * `‖f z‖` and `‖g z‖` are bounded from above by `A * exp(B * ‖z‖ ^ c)` on the open fourth quadrant for some `A`, `B`, and `c < 2`; * `f` is equal to `g` on the boundary of the fourth quadrant. Then `f` is equal to `g` on the closed fourth quadrant. -/ theorem eqOn_quadrant_IV (hdf : DiffContOnCl ℂ f (Ioi 0 ×ℂ Iio 0)) (hBf : ∃ c < (2 : ℝ), ∃ B, f =O[cobounded ℂ ⊓ 𝓟 (Ioi 0 ×ℂ Iio 0)] fun z => expR (B * ‖z‖ ^ c)) (hdg : DiffContOnCl ℂ g (Ioi 0 ×ℂ Iio 0)) (hBg : ∃ c < (2 : ℝ), ∃ B, g =O[cobounded ℂ ⊓ 𝓟 (Ioi 0 ×ℂ Iio 0)] fun z => expR (B * ‖z‖ ^ c)) (hre : ∀ x : ℝ, 0 ≤ x → f x = g x) (him : ∀ x : ℝ, x ≤ 0 → f (x * I) = g (x * I)) : EqOn f g {z | 0 ≤ z.re ∧ z.im ≤ 0} := fun _z hz => sub_eq_zero.1 <| eq_zero_on_quadrant_IV (hdf.sub hdg) (isBigO_sub_exp_rpow hBf hBg) (fun x hx => sub_eq_zero.2 <| hre x hx) (fun x hx => sub_eq_zero.2 <| him x hx) hz /-! ### Phragmen-Lindelöf principle in the right half-plane -/ /-- **Phragmen-Lindelöf principle** in the right half-plane. Let `f : ℂ → E` be a function such that * `f` is differentiable in the open right half-plane and is continuous on its closure; * `‖f z‖` is bounded from above by `A * exp(B * ‖z‖ ^ c)` on the open right half-plane for some `c < 2`; * `‖f z‖` is bounded from above by a constant `C` on the imaginary axis; * `f x → 0` as `x : ℝ` tends to infinity. Then `‖f z‖` is bounded from above by the same constant on the closed right half-plane. See also `PhragmenLindelof.right_half_plane_of_bounded_on_real` for a stronger version. -/ theorem right_half_plane_of_tendsto_zero_on_real (hd : DiffContOnCl ℂ f {z | 0 < z.re}) (hexp : ∃ c < (2 : ℝ), ∃ B, f =O[cobounded ℂ ⊓ 𝓟 {z | 0 < z.re}] fun z => expR (B * ‖z‖ ^ c)) (hre : Tendsto (fun x : ℝ => f x) atTop (𝓝 0)) (him : ∀ x : ℝ, ‖f (x * I)‖ ≤ C) (hz : 0 ≤ z.re) : ‖f z‖ ≤ C := by /- We are going to apply the Phragmen-Lindelöf principle in the first and fourth quadrants. The lemmas immediately imply that for any upper estimate `C'` on `‖f x‖`, `x : ℝ`, `0 ≤ x`, the number `max C C'` is an upper estimate on `f` in the whole right half-plane. -/ revert z have hle : ∀ C', (∀ x : ℝ, 0 ≤ x → ‖f x‖ ≤ C') → ∀ z : ℂ, 0 ≤ z.re → ‖f z‖ ≤ max C C' := fun C' hC' z hz ↦ by rcases hexp with ⟨c, hc, B, hO⟩ rcases le_total z.im 0 with h | h · refine quadrant_IV (hd.mono fun _ => And.left) ⟨c, hc, B, ?_⟩ (fun x hx => (hC' x hx).trans <| le_max_right _ _) (fun x _ => (him x).trans (le_max_left _ _)) hz h exact hO.mono (inf_le_inf_left _ <| principal_mono.2 fun _ => And.left) · refine quadrant_I (hd.mono fun _ => And.left) ⟨c, hc, B, ?_⟩ (fun x hx => (hC' x hx).trans <| le_max_right _ _) (fun x _ => (him x).trans (le_max_left _ _)) hz h exact hO.mono (inf_le_inf_left _ <| principal_mono.2 fun _ => And.left) -- Since `f` is continuous on `Ici 0` and `‖f x‖` tends to zero as `x → ∞`, -- the norm `‖f x‖` takes its maximum value at some `x₀ : ℝ`. obtain ⟨x₀, hx₀, hmax⟩ : ∃ x : ℝ, 0 ≤ x ∧ ∀ y : ℝ, 0 ≤ y → ‖f y‖ ≤ ‖f x‖ := by have hfc : ContinuousOn (fun x : ℝ => f x) (Ici 0) := by refine hd.continuousOn.comp continuous_ofReal.continuousOn fun x hx => ?_ rwa [closure_setOf_lt_re] by_cases! h₀ : ∀ x : ℝ, 0 ≤ x → f x = 0 · refine ⟨0, le_rfl, fun y hy => ?_⟩; rw [h₀ y hy, h₀ 0 le_rfl] rcases h₀ with ⟨x₀, hx₀, hne⟩ have hlt : ‖(0 : E)‖ < ‖f x₀‖ := by rwa [norm_zero, norm_pos_iff] suffices ∀ᶠ x : ℝ in cocompact ℝ ⊓ 𝓟 (Ici 0), ‖f x‖ ≤ ‖f x₀‖ by simpa only [exists_prop] using hfc.norm.exists_isMaxOn' isClosed_Ici hx₀ this rw [cocompact_eq_atBot_atTop, inf_sup_right, (disjoint_atBot_principal_Ici (0 : ℝ)).eq_bot, bot_sup_eq] exact (hre.norm.eventually <| ge_mem_nhds hlt).filter_mono inf_le_left rcases le_or_gt ‖f x₀‖ C with h | h ·-- If `‖f x₀‖ ≤ C`, then `hle` implies the required estimate simpa only [max_eq_left h] using hle _ hmax · -- Otherwise, `‖f z‖ ≤ ‖f x₀‖` for all `z` in the right half-plane due to `hle`. replace hmax : IsMaxOn (norm ∘ f) {z | 0 < z.re} x₀ := by rintro z (hz : 0 < z.re) simpa [max_eq_right h.le] using hle _ hmax _ hz.le -- Due to the maximum modulus principle applied to the closed ball of radius `x₀.re`, -- `‖f 0‖ = ‖f x₀‖`. have : ‖f 0‖ = ‖f x₀‖ := by apply norm_eq_norm_of_isMaxOn_of_ball_subset hd hmax -- move to a lemma? intro z hz rw [mem_ball, dist_zero_left, dist_eq, Complex.norm_of_nonneg hx₀] at hz rw [mem_setOf_eq] contrapose! hz calc x₀ ≤ x₀ - z.re := (le_sub_self_iff _).2 hz _ ≤ |x₀ - z.re| := le_abs_self _ _ = |(z - x₀).re| := by rw [sub_re, ofReal_re, _root_.abs_sub_comm] _ ≤ ‖z - x₀‖ := abs_re_le_norm _ -- Thus we have `C < ‖f x₀‖ = ‖f 0‖ ≤ C`. Contradiction completes the proof. refine (h.not_ge <| this ▸ ?_).elim simpa using him 0 /-- **Phragmen-Lindelöf principle** in the right half-plane. Let `f : ℂ → E` be a function such that * `f` is differentiable in the open right half-plane and is continuous on its closure; * `‖f z‖` is bounded from above by `A * exp(B * ‖z‖ ^ c)` on the open right half-plane for some `c < 2`; * `‖f z‖` is bounded from above by a constant `C` on the imaginary axis; * `‖f x‖` is bounded from above by a constant for large real values of `x`. Then `‖f z‖` is bounded from above by `C` on the closed right half-plane. See also `PhragmenLindelof.right_half_plane_of_tendsto_zero_on_real` for a weaker version. -/ theorem right_half_plane_of_bounded_on_real (hd : DiffContOnCl ℂ f {z | 0 < z.re}) (hexp : ∃ c < (2 : ℝ), ∃ B, f =O[cobounded ℂ ⊓ 𝓟 {z | 0 < z.re}] fun z => expR (B * ‖z‖ ^ c)) (hre : IsBoundedUnder (· ≤ ·) atTop fun x : ℝ => ‖f x‖) (him : ∀ x : ℝ, ‖f (x * I)‖ ≤ C) (hz : 0 ≤ z.re) : ‖f z‖ ≤ C := by -- For each `ε < 0`, the function `fun z ↦ exp (ε * z) • f z` satisfies assumptions of -- `right_half_plane_of_tendsto_zero_on_real`, hence `‖exp (ε * z) • f z‖ ≤ C` for all `ε < 0`. -- Taking the limit as `ε → 0`, we obtain the required inequality. suffices ∀ᶠ ε : ℝ in 𝓝[<] 0, ‖exp (ε * z) • f z‖ ≤ C by refine le_of_tendsto (Tendsto.mono_left ?_ nhdsWithin_le_nhds) this apply ((continuous_ofReal.mul continuous_const).cexp.smul continuous_const).norm.tendsto' simp filter_upwards [self_mem_nhdsWithin] with ε ε₀; change ε < 0 at ε₀ set g : ℂ → E := fun z => exp (ε * z) • f z; change ‖g z‖ ≤ C replace hd : DiffContOnCl ℂ g {z : ℂ | 0 < z.re} := (differentiable_id.const_mul _).cexp.diffContOnCl.smul hd have hgn : ∀ z, ‖g z‖ = expR (ε * z.re) * ‖f z‖ := fun z ↦ by rw [norm_smul, norm_exp, re_ofReal_mul] refine right_half_plane_of_tendsto_zero_on_real hd ?_ ?_ (fun y => ?_) hz · rcases hexp with ⟨c, hc, B, hO⟩ refine ⟨c, hc, B, .trans (.of_bound' ?_) hO⟩ refine eventually_inf_principal.2 <| Eventually.of_forall fun z hz => ?_ rw [hgn] refine mul_le_of_le_one_left (norm_nonneg _) (Real.exp_le_one_iff.2 ?_) exact mul_nonpos_of_nonpos_of_nonneg ε₀.le (le_of_lt hz) · simp_rw [g, ← ofReal_mul, ← ofReal_exp, coe_smul] have h₀ : Tendsto (fun x : ℝ => expR (ε * x)) atTop (𝓝 0) := Real.tendsto_exp_atBot.comp (tendsto_const_nhds.neg_mul_atTop ε₀ tendsto_id) exact h₀.zero_smul_isBoundedUnder_le hre · rw [hgn, re_ofReal_mul, I_re, mul_zero, mul_zero, Real.exp_zero, one_mul] exact him y /-- **Phragmen-Lindelöf principle** in the right half-plane. Let `f : ℂ → E` be a function such that * `f` is differentiable in the open right half-plane and is continuous on its closure; * `‖f z‖` is bounded from above by `A * exp(B * ‖z‖ ^ c)` on the open right half-plane for some `c < 2`; * `‖f z‖` is bounded from above by a constant on the imaginary axis; * `f x`, `x : ℝ`, tends to zero superexponentially fast as `x → ∞`: for any natural `n`, `exp (n * x) * ‖f x‖` tends to zero as `x → ∞`. Then `f` is equal to zero on the closed right half-plane. -/ theorem eq_zero_on_right_half_plane_of_superexponential_decay (hd : DiffContOnCl ℂ f {z | 0 < z.re}) (hexp : ∃ c < (2 : ℝ), ∃ B, f =O[cobounded ℂ ⊓ 𝓟 {z | 0 < z.re}] fun z => expR (B * ‖z‖ ^ c)) (hre : SuperpolynomialDecay atTop expR fun x => ‖f x‖) (him : ∃ C, ∀ x : ℝ, ‖f (x * I)‖ ≤ C) : EqOn f 0 {z : ℂ | 0 ≤ z.re} := by rcases him with ⟨C, hC⟩ -- Due to continuity, it suffices to prove the equality on the open right half-plane. suffices ∀ z : ℂ, 0 < z.re → f z = 0 by simpa only [closure_setOf_lt_re] using EqOn.of_subset_closure this hd.continuousOn continuousOn_const subset_closure Subset.rfl -- Consider $g_n(z)=e^{nz}f(z)$. set g : ℕ → ℂ → E := fun (n : ℕ) (z : ℂ) => exp z ^ n • f z have hg : ∀ n z, ‖g n z‖ = expR z.re ^ n * ‖f z‖ := fun n z ↦ by simp only [g, norm_smul, norm_pow, norm_exp] intro z hz -- Since `e^{nz} → ∞` as `n → ∞`, it suffices to show that each `g_n` is bounded from above by `C` suffices H : ∀ n : ℕ, ‖g n z‖ ≤ C by contrapose! H simp only [hg] exact (((tendsto_pow_atTop_atTop_of_one_lt (Real.one_lt_exp_iff.2 hz)).atTop_mul_const (norm_pos_iff.2 H)).eventually (eventually_gt_atTop C)).exists intro n -- This estimate follows from the Phragmen-Lindelöf principle in the right half-plane. refine right_half_plane_of_tendsto_zero_on_real ((differentiable_exp.pow n).diffContOnCl.smul hd) ?_ ?_ (fun y => ?_) hz.le · rcases hexp with ⟨c, hc, B, hO⟩ refine ⟨max c 1, max_lt hc one_lt_two, n + max B 0, .of_norm_left ?_⟩ simp only [hg] refine ((isBigO_refl (fun z : ℂ => expR z.re ^ n) _).mul hO.norm_left).trans (.of_bound' ?_) filter_upwards [(eventually_cobounded_le_norm 1).filter_mono inf_le_left] with z hz simp only [← Real.exp_nat_mul, ← Real.exp_add, Real.norm_eq_abs, Real.abs_exp, add_mul] gcongr · calc z.re ≤ ‖z‖ := re_le_norm _ _ = ‖z‖ ^ (1 : ℝ) := (Real.rpow_one _).symm _ ≤ ‖z‖ ^ max c 1 := Real.rpow_le_rpow_of_exponent_le hz (le_max_right _ _) exacts [le_max_left _ _, hz, le_max_left _ _] · rw [tendsto_zero_iff_norm_tendsto_zero]; simp only [hg] exact hre n · rw [hg, re_ofReal_mul, I_re, mul_zero, Real.exp_zero, one_pow, one_mul] exact hC y /-- **Phragmen-Lindelöf principle** in the right half-plane. Let `f g : ℂ → E` be functions such that * `f` and `g` are differentiable in the open right half-plane and are continuous on its closure; * `‖f z‖` and `‖g z‖` are bounded from above by `A * exp(B * ‖z‖ ^ c)` on the open right half-plane for some `c < 2`; * `‖f z‖` and `‖g z‖` are bounded from above by constants on the imaginary axis; * `f x - g x`, `x : ℝ`, tends to zero superexponentially fast as `x → ∞`: for any natural `n`, `exp (n * x) * ‖f x - g x‖` tends to zero as `x → ∞`. Then `f` is equal to `g` on the closed right half-plane. -/ theorem eqOn_right_half_plane_of_superexponential_decay {g : ℂ → E} (hfd : DiffContOnCl ℂ f {z | 0 < z.re}) (hgd : DiffContOnCl ℂ g {z | 0 < z.re}) (hfexp : ∃ c < (2 : ℝ), ∃ B, f =O[cobounded ℂ ⊓ 𝓟 {z | 0 < z.re}] fun z => expR (B * ‖z‖ ^ c)) (hgexp : ∃ c < (2 : ℝ), ∃ B, g =O[cobounded ℂ ⊓ 𝓟 {z | 0 < z.re}] fun z => expR (B * ‖z‖ ^ c)) (hre : SuperpolynomialDecay atTop expR fun x => ‖f x - g x‖) (hfim : ∃ C, ∀ x : ℝ, ‖f (x * I)‖ ≤ C) (hgim : ∃ C, ∀ x : ℝ, ‖g (x * I)‖ ≤ C) : EqOn f g {z : ℂ | 0 ≤ z.re} := by suffices EqOn (f - g) 0 {z : ℂ | 0 ≤ z.re} by simpa only [EqOn, Pi.sub_apply, Pi.zero_apply, sub_eq_zero] using this refine eq_zero_on_right_half_plane_of_superexponential_decay (hfd.sub hgd) ?_ hre ?_ · exact isBigO_sub_exp_rpow hfexp hgexp · rcases hfim with ⟨Cf, hCf⟩; rcases hgim with ⟨Cg, hCg⟩ exact ⟨Cf + Cg, fun x => norm_sub_le_of_le (hCf x) (hCg x)⟩ end PhragmenLindelof
.lake/packages/mathlib/Mathlib/Analysis/Complex/RealDeriv.lean
import Mathlib.Analysis.Calculus.ContDiff.Operations import Mathlib.Analysis.Calculus.Deriv.Linear import Mathlib.Analysis.Complex.Basic /-! # Real differentiability of complex-differentiable functions `HasDerivAt.real_of_complex` expresses that, if a function on `ℂ` is differentiable (over `ℂ`), then its restriction to `ℝ` is differentiable over `ℝ`, with derivative the real part of the complex derivative. -/ assert_not_exists IsConformalMap Conformal section RealDerivOfComplex /-! ### Differentiability of the restriction to `ℝ` of complex functions -/ open Complex variable {e : ℂ → ℂ} {e' : ℂ} {z : ℝ} /-- If a complex function is differentiable at a real point, then the induced real function is also differentiable at this point, with a derivative equal to the real part of the complex derivative. -/ theorem HasStrictDerivAt.real_of_complex (h : HasStrictDerivAt e e' z) : HasStrictDerivAt (fun x : ℝ => (e x).re) e'.re z := by have A : HasStrictFDerivAt ((↑) : ℝ → ℂ) ofRealCLM z := ofRealCLM.hasStrictFDerivAt have B : HasStrictFDerivAt e ((ContinuousLinearMap.smulRight 1 e' : ℂ →L[ℂ] ℂ).restrictScalars ℝ) (ofRealCLM z) := h.hasStrictFDerivAt.restrictScalars ℝ have C : HasStrictFDerivAt re reCLM (e (ofRealCLM z)) := reCLM.hasStrictFDerivAt simpa using (C.comp z (B.comp z A)).hasStrictDerivAt /-- If a complex function `e` is differentiable at a real point, then the function `ℝ → ℝ` given by the real part of `e` is also differentiable at this point, with a derivative equal to the real part of the complex derivative. -/ theorem HasDerivAt.real_of_complex (h : HasDerivAt e e' z) : HasDerivAt (fun x : ℝ => (e x).re) e'.re z := by have A : HasFDerivAt ((↑) : ℝ → ℂ) ofRealCLM z := ofRealCLM.hasFDerivAt have B : HasFDerivAt e ((ContinuousLinearMap.smulRight 1 e' : ℂ →L[ℂ] ℂ).restrictScalars ℝ) (ofRealCLM z) := h.hasFDerivAt.restrictScalars ℝ have C : HasFDerivAt re reCLM (e (ofRealCLM z)) := reCLM.hasFDerivAt simpa using (C.comp z (B.comp z A)).hasDerivAt theorem ContDiffAt.real_of_complex {n : WithTop ℕ∞} (h : ContDiffAt ℂ n e z) : ContDiffAt ℝ n (fun x : ℝ => (e x).re) z := by have A : ContDiffAt ℝ n ((↑) : ℝ → ℂ) z := ofRealCLM.contDiff.contDiffAt have B : ContDiffAt ℝ n e z := h.restrict_scalars ℝ have C : ContDiffAt ℝ n re (e z) := reCLM.contDiff.contDiffAt exact C.comp z (B.comp z A) theorem ContDiff.real_of_complex {n : WithTop ℕ∞} (h : ContDiff ℂ n e) : ContDiff ℝ n fun x : ℝ => (e x).re := contDiff_iff_contDiffAt.2 fun _ => h.contDiffAt.real_of_complex variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℂ E] theorem HasStrictDerivAt.complexToReal_fderiv' {f : ℂ → E} {x : ℂ} {f' : E} (h : HasStrictDerivAt f f' x) : HasStrictFDerivAt f (reCLM.smulRight f' + I • imCLM.smulRight f') x := by simpa only [Complex.restrictScalars_one_smulRight'] using h.hasStrictFDerivAt.restrictScalars ℝ theorem HasDerivAt.complexToReal_fderiv' {f : ℂ → E} {x : ℂ} {f' : E} (h : HasDerivAt f f' x) : HasFDerivAt f (reCLM.smulRight f' + I • imCLM.smulRight f') x := by simpa only [Complex.restrictScalars_one_smulRight'] using h.hasFDerivAt.restrictScalars ℝ theorem HasDerivWithinAt.complexToReal_fderiv' {f : ℂ → E} {s : Set ℂ} {x : ℂ} {f' : E} (h : HasDerivWithinAt f f' s x) : HasFDerivWithinAt f (reCLM.smulRight f' + I • imCLM.smulRight f') s x := by simpa only [Complex.restrictScalars_one_smulRight'] using h.hasFDerivWithinAt.restrictScalars ℝ theorem HasStrictDerivAt.complexToReal_fderiv {f : ℂ → ℂ} {f' x : ℂ} (h : HasStrictDerivAt f f' x) : HasStrictFDerivAt f (f' • (1 : ℂ →L[ℝ] ℂ)) x := by simpa only [Complex.restrictScalars_one_smulRight] using h.hasStrictFDerivAt.restrictScalars ℝ theorem HasDerivAt.complexToReal_fderiv {f : ℂ → ℂ} {f' x : ℂ} (h : HasDerivAt f f' x) : HasFDerivAt f (f' • (1 : ℂ →L[ℝ] ℂ)) x := by simpa only [Complex.restrictScalars_one_smulRight] using h.hasFDerivAt.restrictScalars ℝ theorem HasDerivWithinAt.complexToReal_fderiv {f : ℂ → ℂ} {s : Set ℂ} {f' x : ℂ} (h : HasDerivWithinAt f f' s x) : HasFDerivWithinAt f (f' • (1 : ℂ →L[ℝ] ℂ)) s x := by simpa only [Complex.restrictScalars_one_smulRight] using h.hasFDerivWithinAt.restrictScalars ℝ /-- If a complex function `e` is differentiable at a real point, then its restriction to `ℝ` is differentiable there as a function `ℝ → ℂ`, with the same derivative. -/ theorem HasDerivAt.comp_ofReal (hf : HasDerivAt e e' ↑z) : HasDerivAt (fun y : ℝ => e ↑y) e' z := by simpa only [ofRealCLM_apply, ofReal_one, mul_one] using hf.comp z ofRealCLM.hasDerivAt /-- If a function `f : ℝ → ℝ` is differentiable at a (real) point `x`, then it is also differentiable as a function `ℝ → ℂ`. -/ theorem HasDerivAt.ofReal_comp {f : ℝ → ℝ} {u : ℝ} (hf : HasDerivAt f u z) : HasDerivAt (fun y : ℝ => ↑(f y) : ℝ → ℂ) u z := by simpa only [ofRealCLM_apply, ofReal_one, real_smul, mul_one] using ofRealCLM.hasDerivAt.scomp z hf end RealDerivOfComplex
.lake/packages/mathlib/Mathlib/Analysis/Complex/Periodic.lean
import Mathlib.Analysis.Complex.RemovableSingularity import Mathlib.Analysis.Calculus.InverseFunctionTheorem.Deriv import Mathlib.Order.Filter.ZeroAndBoundedAtFilter /-! # Periodic holomorphic functions We show that if `f : ℂ → ℂ` satisfies `f (z + h) = f z`, for some nonzero real `h`, then there is a function `F` such that `f z = F (exp (2 * π * I * z / h))` for all `z`; and if `f` is holomorphic at some `z`, then `F` is holomorphic at `exp (2 * π * I * z / h)`. We also show (using Riemann's removable singularity theorem) that if `f` is holomorphic and bounded for all sufficiently large `im z`, then `F` extends to a holomorphic function on a neighbourhood of `0`. As a consequence, if `f` tends to zero as `im z → ∞`, then in fact it decays *exponentially* to zero. These results are important in the theory of modular forms. -/ open Complex Filter Asymptotics open scoped Real Topology noncomputable section local notation "I∞" => comap im atTop variable (h : ℝ) namespace Function.Periodic /-- Parameter for q-expansions, `qParam h z = exp (2 * π * I * z / h)` -/ def qParam (z : ℂ) : ℂ := exp (2 * π * I * z / h) /-- One-sided inverse of `qParam h`. -/ def invQParam (q : ℂ) : ℂ := h / (2 * π * I) * log q local notation "𝕢" => qParam section qParam theorem norm_qParam (z : ℂ) : ‖𝕢 h z‖ = Real.exp (-2 * π * im z / h) := by simp only [qParam, norm_exp, div_ofReal_re, mul_re, re_ofNat, ofReal_re, im_ofNat, ofReal_im, mul_zero, sub_zero, I_re, mul_im, zero_mul, add_zero, I_im, mul_one, sub_self, zero_sub, neg_mul] theorem im_invQParam (q : ℂ) : im (invQParam h q) = -h / (2 * π) * Real.log ‖q‖ := by simp only [invQParam, ← div_div, div_I, neg_mul, neg_im, mul_im, mul_re, div_ofReal_re, div_ofNat_re, ofReal_re, I_re, mul_zero, div_ofReal_im, div_ofNat_im, ofReal_im, zero_div, I_im, mul_one, sub_self, zero_mul, add_zero, log_re, zero_add, neg_div] variable {h} -- next few theorems all assume h ≠ 0 or 0 < h theorem qParam_right_inv (hh : h ≠ 0) {q : ℂ} (hq : q ≠ 0) : 𝕢 h (invQParam h q) = q := by simp only [qParam, invQParam, ← mul_assoc, mul_div_cancel₀ _ two_pi_I_ne_zero, mul_div_cancel_left₀ _ (ofReal_ne_zero.mpr hh), exp_log hq] theorem qParam_left_inv_mod_period (hh : h ≠ 0) (z : ℂ) : ∃ m : ℤ, invQParam h (𝕢 h z) = z + m * h := by dsimp only [qParam, invQParam] obtain ⟨m, hm⟩ := log_exp_exists (2 * ↑π * I * z / ↑h) refine ⟨m, by rw [hm, mul_div_assoc, mul_comm (m : ℂ), ← mul_add, ← mul_assoc, div_mul_cancel₀ _ two_pi_I_ne_zero, mul_add, mul_div_cancel₀ _ (mod_cast hh), mul_comm]⟩ theorem norm_qParam_lt_iff (hh : 0 < h) (A : ℝ) (z : ℂ) : ‖qParam h z‖ < Real.exp (-2 * π * A / h) ↔ A < im z := by rw [norm_qParam, Real.exp_lt_exp, div_lt_div_iff_of_pos_right hh, mul_lt_mul_left_of_neg] simpa using Real.pi_pos lemma qParam_ne_zero (z : ℂ) : 𝕢 h z ≠ 0 := by simp [qParam, exp_ne_zero] @[fun_prop] lemma differentiable_qParam : Differentiable ℂ (𝕢 h) := by unfold qParam fun_prop @[fun_prop] lemma contDiff_qParam (m : WithTop ℕ∞) : ContDiff ℂ m (𝕢 h) := by unfold qParam fun_prop theorem qParam_tendsto (hh : 0 < h) : Tendsto (qParam h) I∞ (𝓝[≠] 0) := by refine tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within _ ?_ (.of_forall fun q ↦ exp_ne_zero _) rw [tendsto_zero_iff_norm_tendsto_zero] simp only [norm_qParam] apply (tendsto_comap'_iff (m := fun y ↦ Real.exp (-2 * π * y / h)) (range_im ▸ univ_mem)).mpr refine Real.tendsto_exp_atBot.comp (.atBot_div_const hh (tendsto_id.const_mul_atTop_of_neg ?_)) simpa using Real.pi_pos theorem invQParam_tendsto (hh : 0 < h) : Tendsto (invQParam h) (𝓝[≠] 0) I∞ := by simp only [tendsto_comap_iff, comp_def, im_invQParam] apply Tendsto.const_mul_atBot_of_neg (div_neg_of_neg_of_pos (neg_lt_zero.mpr hh) (by positivity)) exact Real.tendsto_log_nhdsGT_zero.comp tendsto_norm_nhdsNE_zero end qParam section PeriodicOnℂ variable (h : ℝ) (f : ℂ → ℂ) /-- The function `q ↦ f (invQParam h q)`, extended by a non-canonical choice of limit at 0. -/ def cuspFunction : ℂ → ℂ := update (f ∘ invQParam h) 0 (limUnder (𝓝[≠] 0) (f ∘ invQParam h)) theorem cuspFunction_eq_of_nonzero {q : ℂ} (hq : q ≠ 0) : cuspFunction h f q = f (invQParam h q) := update_of_ne hq .. theorem cuspFunction_zero_eq_limUnder_nhds_ne : cuspFunction h f 0 = limUnder (𝓝[≠] 0) (cuspFunction h f) := by conv_lhs => simp only [cuspFunction, update_self] refine congr_arg lim (Filter.map_congr <| eventuallyEq_nhdsWithin_of_eqOn fun r hr ↦ ?_) rw [cuspFunction, update_of_ne hr] variable {f h} theorem eq_cuspFunction (hh : h ≠ 0) (hf : Periodic f h) (z : ℂ) : (cuspFunction h f) (𝕢 h z) = f z := by have : (cuspFunction h f) (𝕢 h z) = f (invQParam h (𝕢 h z)) := by rw [cuspFunction, update_of_ne, comp_apply] exact exp_ne_zero _ obtain ⟨m, hm⟩ := qParam_left_inv_mod_period hh z simpa only [this, hm] using hf.int_mul m z end PeriodicOnℂ section HoloOnC variable {h : ℝ} {f : ℂ → ℂ} /-- Key technical lemma: the function `cuspFunction h f` is differentiable at the images of differentiability points of `f` (even if `invQParam` is not differentiable there). -/ theorem differentiableAt_cuspFunction (hh : h ≠ 0) (hf : Periodic f h) {z : ℂ} (hol_z : DifferentiableAt ℂ f z) : DifferentiableAt ℂ (cuspFunction h f) (𝕢 h z) := by let q := 𝕢 h z have qdiff : HasStrictDerivAt (𝕢 h) (q * (2 * π * I / h)) z := by simpa only [id_eq, mul_one] using (((hasStrictDerivAt_id z).const_mul _).div_const _).cexp -- Now show that the q-map has a differentiable local inverse at z, say L : ℂ → ℂ with L q = z. have diff_ne : q * (2 * π * I / h) ≠ 0 := mul_ne_zero (exp_ne_zero _) (div_ne_zero two_pi_I_ne_zero <| mod_cast hh) let L := (qdiff.localInverse (𝕢 h) _ z) diff_ne have diff_L : DifferentiableAt ℂ L q := (qdiff.to_localInverse diff_ne).differentiableAt have hL : 𝕢 h ∘ L =ᶠ[𝓝 q] (id : ℂ → ℂ) := (qdiff.hasStrictFDerivAt_equiv diff_ne).eventually_right_inverse -- Thus, if F = cuspFunction h f, we have F q' = f (L q') for q' near q. -- Since L is differentiable at q, and f is diff'ble at L q [ = z], we conclude -- that F is differentiable at q. have hF := hL.fun_comp (cuspFunction h f) have : cuspFunction h f ∘ 𝕢 h ∘ L = f ∘ L := funext fun z ↦ eq_cuspFunction hh hf (L z) rw [this] at hF rw [← EventuallyEq.eq_of_nhds (qdiff.hasStrictFDerivAt_equiv diff_ne).eventually_left_inverse] at hol_z exact (hol_z.comp q diff_L).congr_of_eventuallyEq hF.symm theorem eventually_differentiableAt_cuspFunction_nhds_ne_zero (hh : 0 < h) (hf : Periodic f h) (h_hol : ∀ᶠ z in I∞, DifferentiableAt ℂ f z) : ∀ᶠ q in 𝓝[≠] 0, DifferentiableAt ℂ (cuspFunction h f) q := by refine ((invQParam_tendsto hh).eventually h_hol).mp ?_ refine eventually_nhdsWithin_of_forall (fun q hq h_diff ↦ ?_) rw [← qParam_right_inv hh.ne' hq] exact differentiableAt_cuspFunction hh.ne' hf h_diff end HoloOnC section HoloAtInfC variable {h : ℝ} {f : ℂ → ℂ} theorem boundedAtFilter_cuspFunction (hh : 0 < h) (h_bd : BoundedAtFilter I∞ f) : BoundedAtFilter (𝓝[≠] 0) (cuspFunction h f) := by refine (h_bd.comp_tendsto <| invQParam_tendsto hh).congr' ?_ (by simp) refine eventually_nhdsWithin_of_forall fun q hq ↦ ?_ rw [cuspFunction_eq_of_nonzero _ _ hq, comp_def] theorem cuspFunction_zero_of_zero_at_inf (hh : 0 < h) (h_zer : ZeroAtFilter I∞ f) : cuspFunction h f 0 = 0 := by simpa only [cuspFunction, update_self] using (h_zer.comp (invQParam_tendsto hh)).limUnder_eq theorem differentiableAt_cuspFunction_zero (hh : 0 < h) (hf : Periodic f h) (h_hol : ∀ᶠ z in I∞, DifferentiableAt ℂ f z) (h_bd : BoundedAtFilter I∞ f) : DifferentiableAt ℂ (cuspFunction h f) 0 := by obtain ⟨c, t⟩ := (boundedAtFilter_cuspFunction hh h_bd).bound replace t := (eventually_differentiableAt_cuspFunction_nhds_ne_zero hh hf h_hol).and t simp only [norm_one, Pi.one_apply, mul_one] at t obtain ⟨S, hS1, hS2, hS3⟩ := eventually_nhds_iff.mp (eventually_nhdsWithin_iff.mp t) have h_diff : DifferentiableOn ℂ (cuspFunction h f) (S \ {0}) := fun x hx ↦ (hS1 x hx.1 hx.2).1.differentiableWithinAt have hF_bd : BddAbove (norm ∘ cuspFunction h f '' (S \ {0})) := by use c simp only [mem_upperBounds, Set.mem_image, Set.mem_diff, forall_exists_index, and_imp] intro y q hq hq2 hy simpa only [← hy, norm_one, mul_one] using (hS1 q hq hq2).2 have := differentiableOn_update_limUnder_of_bddAbove (IsOpen.mem_nhds hS2 hS3) h_diff hF_bd rw [← cuspFunction_zero_eq_limUnder_nhds_ne, update_eq_self] at this exact this.differentiableAt (IsOpen.mem_nhds hS2 hS3) /-- If `f` is periodic, and holomorphic and bounded near `I∞`, then it tends to a limit at `I∞`, and this limit is the value of its cusp function at 0. -/ theorem tendsto_at_I_inf (hh : 0 < h) (hf : Periodic f h) (h_hol : ∀ᶠ z in I∞, DifferentiableAt ℂ f z) (h_bd : BoundedAtFilter I∞ f) : Tendsto f I∞ (𝓝 <| cuspFunction h f 0) := by suffices Tendsto (cuspFunction h f) (𝓝[≠] 0) (𝓝 <| cuspFunction h f 0) by simpa only [Function.comp_def, eq_cuspFunction hh.ne' hf] using this.comp (qParam_tendsto hh) exact tendsto_nhdsWithin_of_tendsto_nhds (differentiableAt_cuspFunction_zero hh hf h_hol h_bd).continuousAt.tendsto /-- If `f` is periodic, holomorphic near `I∞`, and tends to zero at `I∞`, then in fact it tends to zero exponentially fast. -/ theorem exp_decay_of_zero_at_inf (hh : 0 < h) (hf : Periodic f h) (h_hol : ∀ᶠ z in I∞, DifferentiableAt ℂ f z) (h_zer : ZeroAtFilter I∞ f) : f =O[I∞] fun z ↦ Real.exp (-2 * π * im z / h) := by suffices cuspFunction h f =O[_] id by simpa only [comp_def, eq_cuspFunction hh.ne' hf, id_eq, norm_qParam] using (this.comp_tendsto (qParam_tendsto hh)).norm_right simpa only [cuspFunction_zero_of_zero_at_inf hh h_zer, sub_zero] using (differentiableAt_cuspFunction_zero hh hf h_hol h_zer.boundedAtFilter).isBigO_sub.mono nhdsWithin_le_nhds end HoloAtInfC end Function.Periodic
.lake/packages/mathlib/Mathlib/Analysis/Complex/Liouville.lean
import Mathlib.Analysis.Complex.CauchyIntegral import Mathlib.Analysis.Calculus.FDeriv.Analytic import Mathlib.Analysis.Normed.Module.Completion /-! # Liouville's theorem In this file we prove Liouville's theorem: if `f : E → F` is complex differentiable on the whole space and its range is bounded, then the function is a constant. Various versions of this theorem are formalized in `Differentiable.apply_eq_apply_of_bounded`, `Differentiable.exists_const_forall_eq_of_bounded`, and `Differentiable.exists_eq_const_of_bounded`. The proof is based on the Cauchy integral formula for the derivative of an analytic function, see `Complex.deriv_eq_smul_circleIntegral`. -/ open TopologicalSpace Metric Set Filter Asymptotics Function MeasureTheory Bornology open scoped Topology Filter NNReal Real universe u v variable {E : Type u} [NormedAddCommGroup E] [NormedSpace ℂ E] {F : Type v} [NormedAddCommGroup F] [NormedSpace ℂ F] local postfix:100 "̂" => UniformSpace.Completion namespace Complex /-- **Cauchy's estimate for derivatives**: If `f` is complex differentiable on an open disc of radius `R > 0`, is continuous on its closure, and its values on the boundary circle of this disc are bounded from above by `C`, then the norm of its `n`-th derivative at the center is at most `n.factorial * C / R ^ n`. -/ theorem norm_iteratedDeriv_le_of_forall_mem_sphere_norm_le [CompleteSpace F] {c : ℂ} {R C : ℝ} {f : ℂ → F} (n : ℕ) (hR : 0 < R) (hf : DiffContOnCl ℂ f (ball c R)) (hC : ∀ z ∈ sphere c R, ‖f z‖ ≤ C) : ‖iteratedDeriv n f c‖ ≤ n.factorial * C / R ^ n := by have hp (z) (hz : ‖z - c‖ = R) : ‖(z - c)⁻¹ ^ (n + 1) • f z‖ ≤ C / (R ^ n * R) := by simpa [norm_smul, norm_pow, norm_inv, hz, ← div_eq_inv_mul] using (div_le_div_iff_of_pos_right (mul_pos (pow_pos hR n) hR)).2 (hC z hz) have hq : iteratedDeriv n f c = n.factorial • (2 * π * I)⁻¹ • ∮ z in C(c, R), (z - c)⁻¹ ^ (n + 1) • f z := by have : (2 * π * I / n.factorial) ≠ 0 := by simp [Nat.factorial_ne_zero] rw [← inv_smul_smul₀ this (iteratedDeriv n f c), inv_div, div_eq_inv_mul, mul_comm, ← nsmul_eq_mul, smul_assoc] simp [← DiffContOnCl.circleIntegral_one_div_sub_center_pow_smul hR n hf] calc ‖iteratedDeriv n f c‖ = ‖n.factorial • (2 * π * I)⁻¹ • ∮ z in C(c, R), (z - c)⁻¹ ^ (n + 1) • f z‖ := by rw [hq] _ ≤ n.factorial * (R * (C / (R ^ (n + 1)))) := by rw [RCLike.norm_nsmul (K := ℂ), nsmul_eq_mul, mul_le_mul_iff_right₀ (by positivity)] exact circleIntegral.norm_two_pi_i_inv_smul_integral_le_of_norm_le_const hR.le hp _ = n.factorial * C / R ^ n := by grind private theorem norm_deriv_le_aux [CompleteSpace F] {c : ℂ} {R C : ℝ} {f : ℂ → F} (hR : 0 < R) (hf : DiffContOnCl ℂ f (ball c R)) (hC : ∀ z ∈ sphere c R, ‖f z‖ ≤ C) : ‖deriv f c‖ ≤ C / R := by simpa using norm_iteratedDeriv_le_of_forall_mem_sphere_norm_le 1 hR hf hC /-- **Cauchy's estimate for the first order derivative**: If `f` is complex differentiable on an open disc of radius `R > 0`, is continuous on its closure, and its values on the boundary circle of this disc are bounded from above by `C`, then the norm of its derivative at the center is at most `C / R`. Note that this theorem does not require the completeness of the codomain of `f`. In contrast, the completeness is needed for `norm_iteratedDeriv_le_of_forall_mem_sphere_norm_le`. -/ theorem norm_deriv_le_of_forall_mem_sphere_norm_le {c : ℂ} {R C : ℝ} {f : ℂ → F} (hR : 0 < R) (hd : DiffContOnCl ℂ f (ball c R)) (hC : ∀ z ∈ sphere c R, ‖f z‖ ≤ C) : ‖deriv f c‖ ≤ C / R := by set e : F →L[ℂ] F̂ := UniformSpace.Completion.toComplL have : HasDerivAt (e ∘ f) (e (deriv f c)) c := e.hasFDerivAt.comp_hasDerivAt c (hd.differentiableAt isOpen_ball <| mem_ball_self hR).hasDerivAt calc ‖deriv f c‖ = ‖deriv (e ∘ f) c‖ := by rw [this.deriv] exact (UniformSpace.Completion.norm_coe _).symm _ ≤ C / R := norm_deriv_le_aux hR (e.differentiable.comp_diffContOnCl hd) fun z hz => (UniformSpace.Completion.norm_coe _).trans_le (hC z hz) /-- An auxiliary lemma for Liouville's theorem `Differentiable.apply_eq_apply_of_bounded`. -/ theorem liouville_theorem_aux {f : ℂ → F} (hf : Differentiable ℂ f) (hb : IsBounded (range f)) (z w : ℂ) : f z = f w := by suffices ∀ c, deriv f c = 0 from is_const_of_deriv_eq_zero hf this z w clear z w; intro c obtain ⟨C, C₀, hC⟩ : ∃ C > (0 : ℝ), ∀ z, ‖f z‖ ≤ C := by rcases isBounded_iff_forall_norm_le.1 hb with ⟨C, hC⟩ exact ⟨max C 1, lt_max_iff.2 (Or.inr zero_lt_one), fun z => (hC (f z) (mem_range_self _)).trans (le_max_left _ _)⟩ refine norm_le_zero_iff.1 (le_of_forall_gt_imp_ge_of_dense fun ε ε₀ => ?_) calc ‖deriv f c‖ ≤ C / (C / ε) := norm_deriv_le_of_forall_mem_sphere_norm_le (div_pos C₀ ε₀) hf.diffContOnCl fun z _ => hC z _ = ε := div_div_cancel₀ C₀.lt.ne' end Complex namespace Differentiable open Complex /-- **Liouville's theorem**: a complex differentiable bounded function `f : E → F` is a constant. -/ theorem apply_eq_apply_of_bounded {f : E → F} (hf : Differentiable ℂ f) (hb : IsBounded (range f)) (z w : E) : f z = f w := by set g : ℂ → F := f ∘ fun t : ℂ => t • (w - z) + z suffices g 0 = g 1 by simpa [g] apply liouville_theorem_aux exacts [hf.comp ((differentiable_id.smul_const (w - z)).add_const z), hb.subset (range_comp_subset_range _ _)] /-- **Liouville's theorem**: a complex differentiable bounded function is a constant. -/ theorem exists_const_forall_eq_of_bounded {f : E → F} (hf : Differentiable ℂ f) (hb : IsBounded (range f)) : ∃ c, ∀ z, f z = c := ⟨f 0, fun _ => hf.apply_eq_apply_of_bounded hb _ _⟩ /-- **Liouville's theorem**: a complex differentiable bounded function is a constant. -/ theorem exists_eq_const_of_bounded {f : E → F} (hf : Differentiable ℂ f) (hb : IsBounded (range f)) : ∃ c, f = const E c := (hf.exists_const_forall_eq_of_bounded hb).imp fun _ => funext /-- A corollary of Liouville's theorem where the function tends to a finite value at infinity (i.e., along `Filter.cocompact`, which in proper spaces coincides with `Bornology.cobounded`). -/ theorem eq_const_of_tendsto_cocompact [Nontrivial E] {f : E → F} (hf : Differentiable ℂ f) {c : F} (hb : Tendsto f (cocompact E) (𝓝 c)) : f = Function.const E c := by have h_bdd : Bornology.IsBounded (Set.range f) := by obtain ⟨s, hs, hs_bdd⟩ := Metric.exists_isBounded_image_of_tendsto hb obtain ⟨t, ht, hts⟩ := mem_cocompact.mp hs apply ht.image hf.continuous |>.isBounded.union hs_bdd |>.subset simpa [Set.image_union, Set.image_univ] using Set.image_mono <| calc Set.univ = t ∪ tᶜ := t.union_compl_self.symm _ ⊆ t ∪ s := by gcongr obtain ⟨c', hc'⟩ := hf.exists_eq_const_of_bounded h_bdd convert hc' exact tendsto_nhds_unique hb (by simpa [hc'] using tendsto_const_nhds) /-- A corollary of Liouville's theorem where the function tends to a finite value at infinity (i.e., along `Filter.cocompact`, which in proper spaces coincides with `Bornology.cobounded`). -/ theorem apply_eq_of_tendsto_cocompact [Nontrivial E] {f : E → F} (hf : Differentiable ℂ f) {c : F} (x : E) (hb : Tendsto f (cocompact E) (𝓝 c)) : f x = c := congr($(hf.eq_const_of_tendsto_cocompact hb) x) end Differentiable
.lake/packages/mathlib/Mathlib/Analysis/Complex/Conformal.lean
import Mathlib.Analysis.Calculus.Conformal.NormedSpace import Mathlib.Analysis.Calculus.Deriv.Basic import Mathlib.Analysis.Calculus.FDeriv.Equiv import Mathlib.Analysis.Calculus.FDeriv.RestrictScalars import Mathlib.Analysis.Complex.Isometry import Mathlib.Analysis.Normed.Module.FiniteDimension import Mathlib.LinearAlgebra.Complex.FiniteDimensional import Mathlib.LinearAlgebra.Complex.Module /-! # Conformal maps between complex vector spaces We prove the sufficient and necessary conditions for a real-linear map between complex vector spaces to be conformal. ## Main results * `isConformalMap_complex_linear`: a nonzero complex linear map into an arbitrary complex normed space is conformal. * `isConformalMap_complex_linear_conj`: the composition of a nonzero complex linear map with `conj` is complex linear. * `isConformalMap_iff_is_complex_or_conj_linear`: a real linear map between the complex plane is conformal iff it's complex linear or the composition of some complex linear map and `conj`. * `DifferentiableAt.conformalAt` states that a real-differentiable function with a nonvanishing differential from the complex plane into an arbitrary complex-normed space is conformal at a point if it's holomorphic at that point. This is a version of Cauchy-Riemann equations. * `conformalAt_iff_differentiableAt_or_differentiableAt_comp_conj` proves that a real-differential function with a nonvanishing differential between the complex plane is conformal at a point if and only if it's holomorphic or antiholomorphic at that point. * `differentiableWithinAt_complex_iff_differentiableWithinAt_real` and `differentiableAt_complex_iff_differentiableAt_real` characterize complex differentiability in terms of the classic Cauchy-Riemann equation. ## Warning Antiholomorphic functions such as the complex conjugate are considered as conformal functions in this file. ## TODO * On a connected open set `u`, a function which is `ConformalAt` each point is either holomorphic throughout or antiholomorphic throughout. -/ noncomputable section open Complex ContinuousLinearMap ComplexConjugate theorem isConformalMap_conj : IsConformalMap (conjLIE : ℂ →L[ℝ] ℂ) := conjLIE.toLinearIsometry.isConformalMap section ConformalIntoComplexNormed variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [NormedSpace ℂ E] theorem isConformalMap_complex_linear {map : ℂ →L[ℂ] E} (nonzero : map ≠ 0) : IsConformalMap (map.restrictScalars ℝ) := by have minor₁ : ‖map 1‖ ≠ 0 := by simpa only [ContinuousLinearMap.ext_ring_iff, Ne, norm_eq_zero] using nonzero refine ⟨‖map 1‖, minor₁, ⟨‖map 1‖⁻¹ • ((map : ℂ →ₗ[ℂ] E) : ℂ →ₗ[ℝ] E), ?_⟩, ?_⟩ · intro x simp only [LinearMap.smul_apply] have : x = x • (1 : ℂ) := by rw [smul_eq_mul, mul_one] nth_rw 1 [this] rw [LinearMap.coe_restrictScalars] simp only [map.coe_coe, map.map_smul, norm_smul, norm_inv, norm_norm] field · ext1 simp [minor₁] theorem isConformalMap_complex_linear_conj {map : ℂ →L[ℂ] E} (nonzero : map ≠ 0) : IsConformalMap ((map.restrictScalars ℝ).comp (conjCLE : ℂ →L[ℝ] ℂ)) := (isConformalMap_complex_linear nonzero).comp isConformalMap_conj end ConformalIntoComplexNormed section ConformalIntoComplexPlane open ContinuousLinearMap variable {g : ℂ →L[ℝ] ℂ} theorem IsConformalMap.is_complex_or_conj_linear (h : IsConformalMap g) : (∃ map : ℂ →L[ℂ] ℂ, map.restrictScalars ℝ = g) ∨ ∃ map : ℂ →L[ℂ] ℂ, map.restrictScalars ℝ = g ∘L ↑conjCLE := by rcases h with ⟨c, -, li, rfl⟩ obtain ⟨li, rfl⟩ : ∃ li' : ℂ ≃ₗᵢ[ℝ] ℂ, li'.toLinearIsometry = li := ⟨li.toLinearIsometryEquiv rfl, by ext1; rfl⟩ rcases linear_isometry_complex li with ⟨a, rfl | rfl⟩ -- let rot := c • (a : ℂ) • ContinuousLinearMap.id ℂ ℂ, · refine Or.inl ⟨c • (a : ℂ) • ContinuousLinearMap.id ℂ ℂ, ?_⟩ ext1 simp · refine Or.inr ⟨c • (a : ℂ) • ContinuousLinearMap.id ℂ ℂ, ?_⟩ ext1 simp /-- A real continuous linear map on the complex plane is conformal if and only if the map or its conjugate is complex linear, and the map is nonvanishing. -/ theorem isConformalMap_iff_is_complex_or_conj_linear : IsConformalMap g ↔ ((∃ map : ℂ →L[ℂ] ℂ, map.restrictScalars ℝ = g) ∨ ∃ map : ℂ →L[ℂ] ℂ, map.restrictScalars ℝ = g ∘L ↑conjCLE) ∧ g ≠ 0 := by constructor · exact fun h => ⟨h.is_complex_or_conj_linear, h.ne_zero⟩ · rintro ⟨⟨map, rfl⟩ | ⟨map, hmap⟩, h₂⟩ · refine isConformalMap_complex_linear ?_ contrapose! h₂ with w simp only [w, restrictScalars_zero] · have minor₁ : g = map.restrictScalars ℝ ∘L ↑conjCLE := by ext1 simp only [hmap, coe_comp', ContinuousLinearEquiv.coe_coe, Function.comp_apply, conjCLE_apply, starRingEnd_self_apply] rw [minor₁] at h₂ ⊢ refine isConformalMap_complex_linear_conj ?_ contrapose! h₂ with w simp only [w, restrictScalars_zero, zero_comp] end ConformalIntoComplexPlane /-! ### Conformality of real-differentiable complex maps -/ section Conformality variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℂ E] {z : ℂ} {f : ℂ → E} /-- A real differentiable function of the complex plane into some complex normed space `E` is conformal at a point `z` if it is holomorphic at that point with a nonvanishing differential. This is a version of the Cauchy-Riemann equations. -/ theorem DifferentiableAt.conformalAt (h : DifferentiableAt ℂ f z) (hf' : deriv f z ≠ 0) : ConformalAt f z := by rw [conformalAt_iff_isConformalMap_fderiv, (h.hasFDerivAt.restrictScalars ℝ).fderiv] apply isConformalMap_complex_linear simpa only [Ne, ContinuousLinearMap.ext_ring_iff] /-- A complex function is conformal if and only if the function is holomorphic or antiholomorphic with a nonvanishing differential. -/ theorem conformalAt_iff_differentiableAt_or_differentiableAt_comp_conj {f : ℂ → ℂ} {z : ℂ} : ConformalAt f z ↔ (DifferentiableAt ℂ f z ∨ DifferentiableAt ℂ (f ∘ conj) (conj z)) ∧ fderiv ℝ f z ≠ 0 := by rw [conformalAt_iff_isConformalMap_fderiv] rw [isConformalMap_iff_is_complex_or_conj_linear] apply and_congr_left intro h have h_diff := h.imp_symm fderiv_zero_of_not_differentiableAt apply or_congr · rw [differentiableAt_iff_restrictScalars ℝ h_diff] rw [← conj_conj z] at h_diff rw [differentiableAt_iff_restrictScalars ℝ (h_diff.comp _ conjCLE.differentiableAt)] refine exists_congr fun g => rfl.congr ?_ have : fderiv ℝ conj (conj z) = _ := conjCLE.fderiv simp [fderiv_comp _ h_diff conjCLE.differentiableAt, this] end Conformality /-! ### The Cauchy-Riemann Equation for Complex-Differentiable Functions -/ section CauchyRiemann open Complex variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℂ E] {f : ℂ → E} {x : ℂ} {s : Set ℂ} /-- A real linear map `ℓ : ℂ →ₗ[ℝ] E` respects complex scalar multiplication if it maps `I` to `I • ℓ 1`. -/ lemma real_linearMap_map_smul_complex {ℓ : ℂ →ₗ[ℝ] E} (h : ℓ I = I • ℓ 1) (a b : ℂ) : ℓ (a • b) = a • ℓ b := by rw [← re_add_im a, ← re_add_im b, ← smul_eq_mul _ I, ← smul_eq_mul _ I] have t₀ : ((a.im : ℂ) • I) • (b.re : ℂ) = (↑(a.im * b.re) : ℂ) • I := by simp only [smul_eq_mul, ofReal_mul, ← mul_assoc, mul_comm _ I] have t₁ : ((a.im : ℂ) • I) • (b.im : ℂ) • I = (↑(- a.im * b.im) : ℂ) • (1 : ℂ) := by simp [mul_mul_mul_comm _ I] simp only [add_smul, smul_add, ℓ.map_add, t₀, t₁] repeat rw [Complex.coe_smul, ℓ.map_smul] have t₂ {r : ℝ} : ℓ (r : ℂ) = r • ℓ (1 : ℂ) := by simp [← ℓ.map_smul] simp only [t₂, h] match_scalars simp [mul_mul_mul_comm _ I] ring /-- Construct a complex-linear map from a real-linear map `ℓ` that maps `I` to `I • ℓ 1`. -/ def LinearMap.complexOfReal (ℓ : ℂ →ₗ[ℝ] E) (h : ℓ I = I • ℓ 1) : ℂ →ₗ[ℂ] E where __ := ℓ map_smul' := real_linearMap_map_smul_complex h @[simp] lemma LinearMap.coe_complexOfReal {ℓ : ℂ →ₗ[ℝ] E} (h) : ℓ.complexOfReal h = (ℓ : ℂ → E) := rfl /-- Construct a continuous complex-linear map from a continuous real-linear map `ℓ` that maps `I` to `I • ℓ 1`. -/ def ContinuousLinearMap.complexOfReal (ℓ : ℂ →L[ℝ] E) (h : ℓ I = I • ℓ 1) : ℂ →L[ℂ] E where __ := ℓ map_smul' := real_linearMap_map_smul_complex h @[simp] lemma ContinuousLinearMap.coe_complexOfReal {ℓ : ℂ →L[ℝ] E} (h) : ℓ.complexOfReal h = (ℓ : ℂ → E) := rfl /-- The **Cauchy-Riemann Equation**: A real-differentiable function `f` on `ℂ` is complex-differentiable at `x` within `s` iff the derivative `fderivWithin ℝ f s x` maps `I` to `I • (fderivWithin ℝ f s x) 1`. -/ theorem differentiableWithinAt_complex_iff_differentiableWithinAt_real (hs : UniqueDiffWithinAt ℝ s x) : DifferentiableWithinAt ℂ f s x ↔ DifferentiableWithinAt ℝ f s x ∧ (fderivWithin ℝ f s x I = I • fderivWithin ℝ f s x 1) := by refine ⟨fun h ↦ ⟨h.restrictScalars ℝ, ?_⟩, fun ⟨h₁, h₂⟩ ↦ ?_⟩ · simp only [← h.restrictScalars_fderivWithin ℝ hs, ContinuousLinearMap.coe_restrictScalars'] rw [(by simp : I = I • 1), (fderivWithin ℂ f s x).map_smul] simp · apply (differentiableWithinAt_iff_restrictScalars ℝ h₁ hs).2 use (fderivWithin ℝ f s x).complexOfReal h₂ rfl /-- In cases where the **Cauchy-Riemann Equation** guarantees complex differentiability at `x`, the complex derivative equals `ContinuousLinearMap.complexOfReal` of the real derivative. -/ protected theorem HasFDerivWithinAt.complexOfReal {f' : ℂ →L[ℝ] E} (h₁ : HasFDerivWithinAt f f' s x) (h₂ : f' I = I • f' 1) : HasFDerivWithinAt f (f'.complexOfReal h₂) s x := .of_restrictScalars ℝ h₁ rfl /-- In cases where the **Cauchy-Riemann Equation** guarantees complex differentiability at `x`, the complex derivative equals `ContinuousLinearMap.complexOfReal` of the real derivative. -/ theorem complexOfReal_fderivWithin (h₁ : DifferentiableWithinAt ℝ f s x) (h₂ : fderivWithin ℝ f s x I = I • fderivWithin ℝ f s x 1) (hs : UniqueDiffWithinAt ℝ s x) : fderivWithin ℂ f s x = (fderivWithin ℝ f s x).complexOfReal h₂ := by have := ((differentiableWithinAt_complex_iff_differentiableWithinAt_real hs).2 ⟨h₁, h₂⟩).restrictScalars_fderivWithin ℝ hs simpa [DFunLike.ext_iff] /-- In cases where the **Cauchy-Riemann Equation** guarantees complex differentiability at `x`, the complex derivative equals `ContinuousLinearMap.complexOfReal` of the real derivative. -/ theorem complexOfReal_hasDerivWithinAt (h₁ : DifferentiableWithinAt ℝ f s x) (h₂ : fderivWithin ℝ f s x I = I • fderivWithin ℝ f s x 1) : HasDerivWithinAt f ((fderivWithin ℝ f s x).complexOfReal h₂ 1) s x := by rw [hasDerivWithinAt_iff_hasFDerivWithinAt, smulRight_one_one] exact h₁.hasFDerivWithinAt.complexOfReal h₂ /-- In cases where the **Cauchy-Riemann Equation** guarantees complex differentiability at `x`, the complex derivative equals the real derivative. -/ theorem complexOfReal_derivWithin (h₁ : DifferentiableWithinAt ℝ f s x) (h₂ : fderivWithin ℝ f s x I = I • fderivWithin ℝ f s x 1) (hs : UniqueDiffWithinAt ℂ s x) : derivWithin f s x = fderivWithin ℝ f s x 1 := HasDerivWithinAt.derivWithin (complexOfReal_hasDerivWithinAt h₁ h₂) hs /-- The **Cauchy-Riemann Equation**: A real-differentiable function `f` on `ℂ` is complex-differentiable at `x` if and only if the derivative `fderiv ℝ f x` maps `I` to `I • (fderiv ℝ f x) 1`. -/ theorem differentiableAt_complex_iff_differentiableAt_real : DifferentiableAt ℂ f x ↔ DifferentiableAt ℝ f x ∧ fderiv ℝ f x I = I • fderiv ℝ f x 1 := ⟨fun h ↦ by simp [h.restrictScalars ℝ, h.fderiv_restrictScalars ℝ], fun ⟨h₁, h₂⟩ ↦ (differentiableAt_iff_restrictScalars ℝ h₁).2 ⟨(fderiv ℝ f x).complexOfReal h₂, rfl⟩⟩ /-- In cases where the **Cauchy-Riemann Equation** guarantees complex differentiability at `x`, the complex derivative equals `ContinuousLinearMap.complexOfReal` of the real derivative. -/ protected theorem HasFDerivAt.complexOfReal_hasFDerivAt {f' : ℂ →L[ℝ] E} (h₁ : HasFDerivAt f f' x) (h₂ : f' I = I • f' 1) : HasFDerivAt f (f'.complexOfReal h₂) x := hasFDerivAt_of_restrictScalars ℝ h₁ rfl /-- In cases where the **Cauchy-Riemann Equation** guarantees complex differentiability at `x`, the complex derivative equals `ContinuousLinearMap.complexOfReal` of the real derivative. -/ theorem complexOfReal_hasDerivAt (h₁ : DifferentiableAt ℝ f x) (h₂ : fderiv ℝ f x I = I • fderiv ℝ f x 1) : HasDerivAt f ((fderiv ℝ f x).complexOfReal h₂ 1) x := by rw [hasDerivAt_iff_hasFDerivAt, smulRight_one_one] exact hasFDerivAt_of_restrictScalars ℝ h₁.hasFDerivAt rfl /-- In cases where the **Cauchy-Riemann Equation** guarantees complex differentiability at `x`, the complex derivative equals the real derivative. -/ theorem complexOfReal_deriv (h₁ : DifferentiableAt ℝ f x) (h₂ : fderiv ℝ f x I = I • fderiv ℝ f x 1) : deriv f x = fderiv ℝ f x 1 := HasDerivAt.deriv (complexOfReal_hasDerivAt h₁ h₂) /-- In cases where the **Cauchy-Riemann Equation** guarantees complex differentiability at `x`, the complex derivative equals `ContinuousLinearMap.complexOfReal` of the real derivative. -/ theorem complexOfReal_fderiv (h₁ : DifferentiableAt ℝ f x) (h₂ : fderiv ℝ f x I = I • fderiv ℝ f x 1) : (fderiv ℝ f x).complexOfReal h₂ = fderiv ℂ f x := (h₁.hasFDerivAt.complexOfReal_hasFDerivAt h₂).fderiv.symm end CauchyRiemann
.lake/packages/mathlib/Mathlib/Analysis/Complex/SummableUniformlyOn.lean
import Mathlib.Analysis.CStarAlgebra.Classes import Mathlib.Analysis.Complex.LocallyUniformLimit import Mathlib.Topology.Algebra.InfiniteSum.UniformOn /-! # Differentiability of uniformly convergent series sums of functions We collect some results about the differentiability of infinite sums. -/ lemma SummableLocallyUniformlyOn.differentiableOn {ι E : Type*} [NormedAddCommGroup E] [NormedSpace ℂ E] [CompleteSpace E] {f : ι → ℂ → E} {s : Set ℂ} (hs : IsOpen s) (h : SummableLocallyUniformlyOn f s) (hf2 : ∀ n r, r ∈ s → DifferentiableAt ℂ (f n) r) : DifferentiableOn ℂ (fun z ↦ ∑' n , f n z) s := by obtain ⟨g, hg⟩ := h have hc := (hasSumLocallyUniformlyOn_iff_tendstoLocallyUniformlyOn.mp hg).differentiableOn ?_ hs · apply hc.congr apply hg.tsum_eqOn · filter_upwards with t r hr using DifferentiableWithinAt.fun_sum fun a ha ↦ (hf2 a r hr).differentiableWithinAt
.lake/packages/mathlib/Mathlib/Analysis/Complex/AbelLimit.lean
import Mathlib.Analysis.Complex.Basic import Mathlib.Analysis.SpecificLimits.Normed import Mathlib.Tactic.Peel import Mathlib.Tactic.Positivity /-! # Abel's limit theorem If a real or complex power series for a function has radius of convergence 1 and the series is only known to converge conditionally at 1, Abel's limit theorem gives the value at 1 as the limit of the function at 1 from the left. "Left" for complex numbers means within a fixed cone opening to the left with angle less than `π`. ## Main theorems * `Complex.tendsto_tsum_powerSeries_nhdsWithin_stolzCone`: Abel's limit theorem for complex power series. * `Real.tendsto_tsum_powerSeries_nhdsWithin_lt`: Abel's limit theorem for real power series. ## References * https://planetmath.org/proofofabelslimittheorem * https://en.wikipedia.org/wiki/Abel%27s_theorem -/ open Filter Finset open scoped Topology namespace Complex section StolzSet open Real /-- The Stolz set for a given `M`, roughly teardrop-shaped with the tip at 1 but tending to the open unit disc as `M` tends to infinity. -/ def stolzSet (M : ℝ) : Set ℂ := {z | ‖z‖ < 1 ∧ ‖1 - z‖ < M * (1 - ‖z‖)} /-- The cone to the left of `1` with angle `2θ` such that `tan θ = s`. -/ def stolzCone (s : ℝ) : Set ℂ := {z | |z.im| < s * (1 - z.re)} theorem stolzSet_empty {M : ℝ} (hM : M ≤ 1) : stolzSet M = ∅ := by ext z rw [stolzSet, Set.mem_setOf, Set.mem_empty_iff_false, iff_false, not_and, not_lt, ← sub_pos] intro zn calc _ ≤ 1 * (1 - ‖z‖) := mul_le_mul_of_nonneg_right hM zn.le _ = ‖(1 : ℂ)‖ - ‖z‖ := by rw [one_mul, norm_one] _ ≤ _ := norm_sub_norm_le _ _ theorem nhdsWithin_lt_le_nhdsWithin_stolzSet {M : ℝ} (hM : 1 < M) : (𝓝[<] 1).map ofReal ≤ 𝓝[stolzSet M] 1 := by rw [← tendsto_id'] refine tendsto_map' <| tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within ofReal (tendsto_nhdsWithin_of_tendsto_nhds <| ofRealCLM.continuous.tendsto' 1 1 rfl) ?_ simp only [eventually_iff, mem_nhdsWithin] refine ⟨Set.Ioo 0 2, isOpen_Ioo, by simp, fun x hx ↦ ?_⟩ simp only [Set.mem_inter_iff, Set.mem_Ioo, Set.mem_Iio] at hx simp only [Set.mem_setOf_eq, stolzSet, ← ofReal_one, ← ofReal_sub, norm_real, norm_of_nonneg hx.1.1.le, norm_of_nonneg <| (sub_pos.mpr hx.2).le] exact ⟨hx.2, lt_mul_left (sub_pos.mpr hx.2) hM⟩ -- An ugly technical lemma private lemma stolzCone_subset_stolzSet_aux' (s : ℝ) : ∃ M ε, 0 < M ∧ 0 < ε ∧ ∀ x y, 0 < x → x < ε → |y| < s * x → √(x ^ 2 + y ^ 2) < M * (1 - √((1 - x) ^ 2 + y ^ 2)) := by refine ⟨2 * √(1 + s ^ 2) + 1, 1 / (1 + s ^ 2), by positivity, by positivity, fun x y hx₀ hx₁ hy ↦ ?_⟩ have H : √((1 - x) ^ 2 + y ^ 2) ≤ 1 - x / 2 := by calc √((1 - x) ^ 2 + y ^ 2) _ ≤ √((1 - x) ^ 2 + (s * x) ^ 2) := sqrt_le_sqrt <| by rw [← sq_abs y]; gcongr _ = √(1 - 2 * x + (1 + s ^ 2) * x * x) := by congr 1; ring _ ≤ √(1 - 2 * x + (1 + s ^ 2) * (1 / (1 + s ^ 2)) * x) := by gcongr _ = √(1 - x) := by congr 1; field _ ≤ 1 - x / 2 := by simp_rw [sub_eq_add_neg, ← neg_div] refine sqrt_one_add_le <| neg_le_neg_iff.mpr (hx₁.trans_le ?_).le rw [div_le_one (by positivity)] exact le_add_of_nonneg_right <| sq_nonneg s calc √(x ^ 2 + y ^ 2) _ ≤ √(x ^ 2 + (s * x) ^ 2) := by rw [← sq_abs y]; gcongr _ = √((1 + s ^ 2) * x ^ 2) := by congr; ring _ = √(1 + s ^ 2) * x := by rw [sqrt_mul' _ (sq_nonneg x), sqrt_sq hx₀.le] _ = 2 * √(1 + s ^ 2) * (x / 2) := by ring _ < (2 * √(1 + s ^ 2) + 1) * (x / 2) := by gcongr; exact lt_add_one _ _ ≤ _ := by gcongr; exact le_sub_comm.mpr H lemma stolzCone_subset_stolzSet_aux {s : ℝ} (hs : 0 < s) : ∃ M ε, 0 < M ∧ 0 < ε ∧ {z : ℂ | 1 - ε < z.re} ∩ stolzCone s ⊆ stolzSet M := by peel stolzCone_subset_stolzSet_aux' s with M ε hM hε H rintro z ⟨hzl, hzr⟩ rw [Set.mem_setOf_eq, sub_lt_comm, ← one_re, ← sub_re] at hzl rw [stolzCone, Set.mem_setOf_eq, ← one_re, ← sub_re] at hzr replace H := H (1 - z).re z.im ((mul_pos_iff_of_pos_left hs).mp <| (abs_nonneg z.im).trans_lt hzr) hzl hzr have h : z.im ^ 2 = (1 - z).im ^ 2 := by simp only [sub_im, one_im, zero_sub, neg_sq] rw [h, ← norm_eq_sqrt_sq_add_sq, ← h, sub_re, one_re, sub_sub_cancel, ← norm_eq_sqrt_sq_add_sq] at H exact ⟨sub_pos.mp <| (mul_pos_iff_of_pos_left hM).mp <| (norm_nonneg _).trans_lt H, H⟩ lemma nhdsWithin_stolzCone_le_nhdsWithin_stolzSet {s : ℝ} (hs : 0 < s) : ∃ M, 𝓝[stolzCone s] 1 ≤ 𝓝[stolzSet M] 1 := by obtain ⟨M, ε, _, hε, H⟩ := stolzCone_subset_stolzSet_aux hs use M rw [nhdsWithin_le_iff, mem_nhdsWithin] refine ⟨{w | 1 - ε < w.re}, isOpen_lt continuous_const continuous_re, ?_, H⟩ simp only [Set.mem_setOf_eq, one_re, sub_lt_self_iff, hε] end StolzSet variable {f : ℕ → ℂ} {l : ℂ} /-- Auxiliary lemma for Abel's limit theorem. The difference between the sum `l` at 1 and the power series's value at a point `z` away from 1 can be rewritten as `1 - z` times a power series whose coefficients are tail sums of `l`. -/ lemma abel_aux (h : Tendsto (fun n ↦ ∑ i ∈ range n, f i) atTop (𝓝 l)) {z : ℂ} (hz : ‖z‖ < 1) : Tendsto (fun n ↦ (1 - z) * ∑ i ∈ range n, (l - ∑ j ∈ range (i + 1), f j) * z ^ i) atTop (𝓝 (l - ∑' n, f n * z ^ n)) := by let s := fun n ↦ ∑ i ∈ range n, f i have k := h.sub (summable_powerSeries_of_norm_lt_one h.cauchySeq hz).hasSum.tendsto_sum_nat simp_rw [← sum_sub_distrib, ← mul_one_sub, ← geom_sum_mul_neg, ← mul_assoc, ← sum_mul, mul_comm, mul_sum _ _ (f _), range_eq_Ico, ← sum_Ico_Ico_comm', ← range_eq_Ico, ← sum_mul] at k conv at k => enter [1, n] rw [sum_congr (g := fun j ↦ (∑ k ∈ range n, f k - ∑ k ∈ range (j + 1), f k) * z ^ j) rfl (fun j hj ↦ by congr 1; exact sum_Ico_eq_sub _ (mem_range.mp hj))] suffices Tendsto (fun n ↦ (l - s n) * ∑ i ∈ range n, z ^ i) atTop (𝓝 0) by simp_rw [mul_sum] at this replace this := (this.const_mul (1 - z)).add k conv at this => enter [1, n] rw [← mul_add, ← sum_add_distrib] enter [2, 2, i] rw [← add_mul, sub_add_sub_cancel] rwa [mul_zero, zero_add] at this rw [← zero_mul (-1 / (z - 1))] apply Tendsto.mul · simpa only [neg_zero, neg_sub] using (tendsto_sub_nhds_zero_iff.mpr h).neg · conv => enter [1, n] rw [geom_sum_eq (by contrapose! hz; simp [hz]), sub_div, sub_eq_add_neg, ← neg_div] rw [← zero_add (-1 / (z - 1)), ← zero_div (z - 1)] apply Tendsto.add (Tendsto.div_const (tendsto_pow_atTop_nhds_zero_of_norm_lt_one hz) (z - 1)) simp only [zero_div, zero_add, tendsto_const_nhds_iff] /-- **Abel's limit theorem**. Given a power series converging at 1, the corresponding function is continuous at 1 when approaching 1 within a fixed Stolz set. -/ theorem tendsto_tsum_powerSeries_nhdsWithin_stolzSet (h : Tendsto (fun n ↦ ∑ i ∈ range n, f i) atTop (𝓝 l)) {M : ℝ} : Tendsto (fun z ↦ ∑' n, f n * z ^ n) (𝓝[stolzSet M] 1) (𝓝 l) := by -- If `M ≤ 1` the Stolz set is empty and the statement is trivial rcases le_or_gt M 1 with hM | hM · simp_rw [stolzSet_empty hM, nhdsWithin_empty, tendsto_bot] -- Abbreviations let s := fun n ↦ ∑ i ∈ range n, f i let g := fun z ↦ ∑' n, f n * z ^ n have hm := Metric.tendsto_atTop.mp h rw [Metric.tendsto_nhdsWithin_nhds] simp only [dist_eq_norm] at hm ⊢ -- Introduce the "challenge" `ε` intro ε εpos -- First bound, handles the tail obtain ⟨B₁, hB₁⟩ := hm (ε / 4 / M) (by positivity) -- Second bound, handles the head let F := ∑ i ∈ range B₁, ‖l - s (i + 1)‖ use ε / 4 / (F + 1), by positivity intro z ⟨zn, zm⟩ zd have p := abel_aux h zn simp_rw [Metric.tendsto_atTop, dist_eq_norm, norm_sub_rev] at p -- Third bound, regarding the distance between `l - g z` and the rearranged sum obtain ⟨B₂, hB₂⟩ := p (ε / 2) (by positivity) clear hm p replace hB₂ := hB₂ (max B₁ B₂) (by simp) suffices ‖(1 - z) * ∑ i ∈ range (max B₁ B₂), (l - s (i + 1)) * z ^ i‖ < ε / 2 by calc _ = ‖l - g z‖ := by rw [norm_sub_rev] _ = ‖l - g z - (1 - z) * ∑ i ∈ range (max B₁ B₂), (l - s (i + 1)) * z ^ i + (1 - z) * ∑ i ∈ range (max B₁ B₂), (l - s (i + 1)) * z ^ i‖ := by rw [sub_add_cancel _] _ ≤ ‖l - g z - (1 - z) * ∑ i ∈ range (max B₁ B₂), (l - s (i + 1)) * z ^ i‖ + ‖(1 - z) * ∑ i ∈ range (max B₁ B₂), (l - s (i + 1)) * z ^ i‖ := norm_add_le _ _ _ < ε / 2 + ε / 2 := add_lt_add hB₂ this _ = _ := add_halves ε -- We break the rearranged sum along `B₁` calc _ = ‖(1 - z) * ∑ i ∈ range B₁, (l - s (i + 1)) * z ^ i + (1 - z) * ∑ i ∈ Ico B₁ (max B₁ B₂), (l - s (i + 1)) * z ^ i‖ := by rw [← mul_add, sum_range_add_sum_Ico _ (le_max_left B₁ B₂)] _ ≤ ‖(1 - z) * ∑ i ∈ range B₁, (l - s (i + 1)) * z ^ i‖ + ‖(1 - z) * ∑ i ∈ Ico B₁ (max B₁ B₂), (l - s (i + 1)) * z ^ i‖ := norm_add_le _ _ _ = ‖1 - z‖ * ‖∑ i ∈ range B₁, (l - s (i + 1)) * z ^ i‖ + ‖1 - z‖ * ‖∑ i ∈ Ico B₁ (max B₁ B₂), (l - s (i + 1)) * z ^ i‖ := by rw [norm_mul, norm_mul] _ ≤ ‖1 - z‖ * ∑ i ∈ range B₁, ‖l - s (i + 1)‖ * ‖z‖ ^ i + ‖1 - z‖ * ∑ i ∈ Ico B₁ (max B₁ B₂), ‖l - s (i + 1)‖ * ‖z‖ ^ i := by gcongr <;> simp_rw [← norm_pow, ← norm_mul, norm_sum_le] -- then prove that the two pieces are each less than `ε / 4` have S₁ : ‖1 - z‖ * ∑ i ∈ range B₁, ‖l - s (i + 1)‖ * ‖z‖ ^ i < ε / 4 := calc _ ≤ ‖1 - z‖ * ∑ i ∈ range B₁, ‖l - s (i + 1)‖ := by gcongr; nth_rw 3 [← mul_one ‖_‖] gcongr; exact pow_le_one₀ (norm_nonneg _) zn.le _ ≤ ‖1 - z‖ * (F + 1) := by gcongr; linarith only _ < _ := by rwa [norm_sub_rev, lt_div_iff₀ (by positivity)] at zd have S₂ : ‖1 - z‖ * ∑ i ∈ Ico B₁ (max B₁ B₂), ‖l - s (i + 1)‖ * ‖z‖ ^ i < ε / 4 := calc _ ≤ ‖1 - z‖ * ∑ i ∈ Ico B₁ (max B₁ B₂), ε / 4 / M * ‖z‖ ^ i := by gcongr with i hi have := hB₁ (i + 1) (by linarith only [(mem_Ico.mp hi).1]) rw [norm_sub_rev] at this exact this.le _ = ‖1 - z‖ * (ε / 4 / M) * ∑ i ∈ Ico B₁ (max B₁ B₂), ‖z‖ ^ i := by rw [← mul_sum, ← mul_assoc] _ ≤ ‖1 - z‖ * (ε / 4 / M) * ∑' i, ‖z‖ ^ i := by gcongr exact Summable.sum_le_tsum _ (fun _ _ ↦ by positivity) (summable_geometric_of_lt_one (by positivity) zn) _ = ‖1 - z‖ * (ε / 4 / M) / (1 - ‖z‖) := by rw [tsum_geometric_of_lt_one (by positivity) zn, ← div_eq_mul_inv] _ < M * (1 - ‖z‖) * (ε / 4 / M) / (1 - ‖z‖) := by gcongr; linarith only [zn] _ = _ := by rw [← mul_rotate, mul_div_cancel_right₀ _ (by linarith only [zn]), div_mul_cancel₀ _ (by linarith only [hM])] convert add_lt_add S₁ S₂ using 1 linarith only /-- **Abel's limit theorem**. Given a power series converging at 1, the corresponding function is continuous at 1 when approaching 1 within any fixed Stolz cone. -/ theorem tendsto_tsum_powerSeries_nhdsWithin_stolzCone (h : Tendsto (fun n ↦ ∑ i ∈ range n, f i) atTop (𝓝 l)) {s : ℝ} (hs : 0 < s) : Tendsto (fun z ↦ ∑' n, f n * z ^ n) (𝓝[stolzCone s] 1) (𝓝 l) := (tendsto_tsum_powerSeries_nhdsWithin_stolzSet h).mono_left (nhdsWithin_stolzCone_le_nhdsWithin_stolzSet hs).choose_spec theorem tendsto_tsum_powerSeries_nhdsWithin_lt (h : Tendsto (fun n ↦ ∑ i ∈ range n, f i) atTop (𝓝 l)) : Tendsto (fun z ↦ ∑' n, f n * z ^ n) ((𝓝[<] 1).map ofReal) (𝓝 l) := (tendsto_tsum_powerSeries_nhdsWithin_stolzSet (M := 2) h).mono_left (nhdsWithin_lt_le_nhdsWithin_stolzSet one_lt_two) end Complex namespace Real open Complex variable {f : ℕ → ℝ} {l : ℝ} /-- **Abel's limit theorem**. Given a real power series converging at 1, the corresponding function is continuous at 1 when approaching 1 from the left. -/ theorem tendsto_tsum_powerSeries_nhdsWithin_lt (h : Tendsto (fun n ↦ ∑ i ∈ range n, f i) atTop (𝓝 l)) : Tendsto (fun x ↦ ∑' n, f n * x ^ n) (𝓝[<] 1) (𝓝 l) := by have m : (𝓝 l).map ofReal ≤ 𝓝 ↑l := ofRealCLM.continuous.tendsto l replace h := (tendsto_map.comp h).mono_right m rw [Function.comp_def] at h push_cast at h replace h := Complex.tendsto_tsum_powerSeries_nhdsWithin_lt h rw [tendsto_map'_iff] at h rw [Metric.tendsto_nhdsWithin_nhds] at h ⊢ convert h simp_rw [Function.comp_apply, dist_eq_norm] norm_cast end Real
.lake/packages/mathlib/Mathlib/Analysis/Complex/MeanValue.lean
import Mathlib.Analysis.Complex.CauchyIntegral import Mathlib.MeasureTheory.Integral.CircleAverage /-! # The Mean Value Property of Complex Differentiable Functions -/ open Complex Metric Real variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℂ E] [CompleteSpace E] {f : ℂ → E} {R : ℝ} {c : ℂ} {s : Set ℂ} -- Helper lemma: proof of `circleAverage_of_differentiable_on_off_countable` in case `0 < R`. private theorem circleAverage_of_differentiable_on_off_countable_posRadius (hR : 0 < R) (hs : s.Countable) (h₁f : ContinuousOn f (closedBall c R)) (h₂f : ∀ z ∈ ball c R \ s, DifferentiableAt ℂ f z) : circleAverage f c R = f c := by calc circleAverage f c R _ = (2 * π * I)⁻¹ • (∮ z in C(c, R), (z - c)⁻¹ • f z) := circleAverage_eq_circleIntegral hR.ne' _ = f c := by rw [circleIntegral_sub_center_inv_smul_of_differentiable_on_off_countable hR hs h₁f h₂f, ← smul_assoc] match_scalars simp [field] /-- The **Mean Value Property** of complex differentiable functions: If `f : ℂ → E` is continuous on a closed disc of radius `R` and center `c`, and is complex differentiable at all but countably many points of its interior, then the circle average `circleAverage f c R` equals `f c`. -/ theorem circleAverage_of_differentiable_on_off_countable (hs : s.Countable) (h₁f : ContinuousOn f (closedBall c |R|)) (h₂f : ∀ z ∈ ball c |R| \ s, DifferentiableAt ℂ f z) : circleAverage f c R = f c := by rcases lt_trichotomy 0 R with h | rfl | h · rw [← abs_of_pos h] exact circleAverage_of_differentiable_on_off_countable_posRadius (abs_pos_of_pos h) hs h₁f h₂f · simp · rw [← circleAverage_neg_radius, ← abs_of_neg h] exact circleAverage_of_differentiable_on_off_countable_posRadius (abs_pos_of_neg h) hs h₁f h₂f /-- The **Mean Value Property** of complex differentiable functions: If `f : ℂ → E` is complex differentiable at all points of a closed disc of radius `R` and center `c`, then the circle average `circleAverage f c R` equals `f c`. -/ theorem circleAverage_of_differentiable_on (hf : ∀ z ∈ closedBall c |R|, DifferentiableAt ℂ f z) : circleAverage f c R = f c := circleAverage_of_differentiable_on_off_countable Set.countable_empty (fun x hx ↦ (hf x hx).continuousAt.continuousWithinAt) fun z hz ↦ hf z (by simp_all [le_of_lt])
.lake/packages/mathlib/Mathlib/Analysis/Complex/Schwarz.lean
import Mathlib.Analysis.Complex.AbsMax import Mathlib.Analysis.Complex.RemovableSingularity /-! # Schwarz lemma In this file we prove several versions of the Schwarz lemma. * `Complex.norm_deriv_le_div_of_mapsTo_ball`, `Complex.abs_deriv_le_div_of_mapsTo_ball`: if `f : ℂ → E` sends an open disk with center `c` and a positive radius `R₁` to an open ball with center `f c` and radius `R₂`, then the norm of the derivative of `f` at `c` is at most the ratio `R₂ / R₁`; * `Complex.dist_le_div_mul_dist_of_mapsTo_ball`: if `f : ℂ → E` sends an open disk with center `c` and radius `R₁` to an open disk with center `f c` and radius `R₂`, then for any `z` in the former disk we have `dist (f z) (f c) ≤ (R₂ / R₁) * dist z c`; * `Complex.abs_deriv_le_one_of_mapsTo_ball`: if `f : ℂ → ℂ` sends an open disk of positive radius to itself and the center of this disk to itself, then the norm of the derivative of `f` at the center of this disk is at most `1`; * `Complex.dist_le_dist_of_mapsTo_ball_self`: if `f : ℂ → ℂ` sends an open disk to itself and the center `c` of this disk to itself, then for any point `z` of this disk we have `dist (f z) c ≤ dist z c`; * `Complex.norm_le_norm_of_mapsTo_ball_self`: if `f : ℂ → ℂ` sends an open disk with center `0` to itself, then for any point `z` of this disk we have `abs (f z) ≤ abs z`. ## Implementation notes We prove some versions of the Schwarz lemma for a map `f : ℂ → E` taking values in any normed space over complex numbers. ## TODO * Prove that these inequalities are strict unless `f` is an affine map. * Prove that any diffeomorphism of the unit disk to itself is a Möbius map. ## Tags Schwarz lemma -/ open Metric Set Function Filter TopologicalSpace open scoped Topology namespace Complex section Space variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℂ E] {R₁ R₂ : ℝ} {f : ℂ → E} {c z z₀ : ℂ} /-- An auxiliary lemma for `Complex.norm_dslope_le_div_of_mapsTo_ball`. -/ theorem schwarz_aux {f : ℂ → ℂ} (hd : DifferentiableOn ℂ f (ball c R₁)) (h_maps : MapsTo f (ball c R₁) (ball (f c) R₂)) (hz : z ∈ ball c R₁) : ‖dslope f c z‖ ≤ R₂ / R₁ := by have hR₁ : 0 < R₁ := nonempty_ball.1 ⟨z, hz⟩ suffices ∀ᶠ r in 𝓝[<] R₁, ‖dslope f c z‖ ≤ R₂ / r by refine ge_of_tendsto ?_ this exact (tendsto_const_nhds.div tendsto_id hR₁.ne').mono_left nhdsWithin_le_nhds rw [mem_ball] at hz filter_upwards [Ioo_mem_nhdsLT hz] with r hr have hr₀ : 0 < r := dist_nonneg.trans_lt hr.1 replace hd : DiffContOnCl ℂ (dslope f c) (ball c r) := by refine DifferentiableOn.diffContOnCl ?_ rw [closure_ball c hr₀.ne'] exact ((differentiableOn_dslope <| ball_mem_nhds _ hR₁).mpr hd).mono (closedBall_subset_ball hr.2) refine norm_le_of_forall_mem_frontier_norm_le isBounded_ball hd ?_ ?_ · rw [frontier_ball c hr₀.ne'] intro z hz have hz' : z ≠ c := ne_of_mem_sphere hz hr₀.ne' rw [dslope_of_ne _ hz', slope_def_module, norm_smul, norm_inv, mem_sphere_iff_norm.1 hz, ← div_eq_inv_mul, div_le_div_iff_of_pos_right hr₀, ← dist_eq_norm] exact le_of_lt (h_maps (mem_ball.2 (by rw [mem_sphere.1 hz]; exact hr.2))) · rw [closure_ball c hr₀.ne', mem_closedBall] exact hr.1.le /-- Two cases of the **Schwarz Lemma** (derivative and distance), merged together. -/ theorem norm_dslope_le_div_of_mapsTo_ball (hd : DifferentiableOn ℂ f (ball c R₁)) (h_maps : MapsTo f (ball c R₁) (ball (f c) R₂)) (hz : z ∈ ball c R₁) : ‖dslope f c z‖ ≤ R₂ / R₁ := by have hR₁ : 0 < R₁ := nonempty_ball.1 ⟨z, hz⟩ have hR₂ : 0 < R₂ := nonempty_ball.1 ⟨f z, h_maps hz⟩ rcases eq_or_ne (dslope f c z) 0 with hc | hc · rw [hc, norm_zero]; exact div_nonneg hR₂.le hR₁.le rcases exists_dual_vector ℂ _ hc with ⟨g, hg, hgf⟩ have hg' : ‖g‖₊ = 1 := NNReal.eq hg have hg₀ : ‖g‖₊ ≠ 0 := by simpa only [hg'] using one_ne_zero calc ‖dslope f c z‖ = ‖dslope (g ∘ f) c z‖ := by rw [g.dslope_comp, hgf, RCLike.norm_ofReal, abs_norm] exact fun _ => hd.differentiableAt (ball_mem_nhds _ hR₁) _ ≤ R₂ / R₁ := by refine schwarz_aux (g.differentiable.comp_differentiableOn hd) (MapsTo.comp ?_ h_maps) hz simpa only [hg', NNReal.coe_one, one_mul] using g.lipschitz.mapsTo_ball hg₀ (f c) R₂ /-- Equality case in the **Schwarz Lemma**: in the setup of `norm_dslope_le_div_of_mapsTo_ball`, if `‖dslope f c z₀‖ = R₂ / R₁` holds at a point in the ball then the map `f` is affine. -/ theorem affine_of_mapsTo_ball_of_exists_norm_dslope_eq_div [CompleteSpace E] [StrictConvexSpace ℝ E] (hd : DifferentiableOn ℂ f (ball c R₁)) (h_maps : Set.MapsTo f (ball c R₁) (ball (f c) R₂)) (h_z₀ : z₀ ∈ ball c R₁) (h_eq : ‖dslope f c z₀‖ = R₂ / R₁) : Set.EqOn f (fun z => f c + (z - c) • dslope f c z₀) (ball c R₁) := by set g := dslope f c rintro z hz by_cases h : z = c; · simp [h] have h_R₁ : 0 < R₁ := nonempty_ball.mp ⟨_, h_z₀⟩ have g_le_div : ∀ z ∈ ball c R₁, ‖g z‖ ≤ R₂ / R₁ := fun z hz => norm_dslope_le_div_of_mapsTo_ball hd h_maps hz have g_max : IsMaxOn (norm ∘ g) (ball c R₁) z₀ := isMaxOn_iff.mpr fun z hz => by simpa [h_eq] using g_le_div z hz have g_diff : DifferentiableOn ℂ g (ball c R₁) := (differentiableOn_dslope (isOpen_ball.mem_nhds (mem_ball_self h_R₁))).mpr hd have : g z = g z₀ := eqOn_of_isPreconnected_of_isMaxOn_norm (convex_ball c R₁).isPreconnected isOpen_ball g_diff h_z₀ g_max hz simp only [g] at this simp [g, ← this] theorem affine_of_mapsTo_ball_of_exists_norm_dslope_eq_div' [CompleteSpace E] [StrictConvexSpace ℝ E] (hd : DifferentiableOn ℂ f (ball c R₁)) (h_maps : Set.MapsTo f (ball c R₁) (ball (f c) R₂)) (h_z₀ : ∃ z₀ ∈ ball c R₁, ‖dslope f c z₀‖ = R₂ / R₁) : ∃ C : E, ‖C‖ = R₂ / R₁ ∧ Set.EqOn f (fun z => f c + (z - c) • C) (ball c R₁) := let ⟨z₀, h_z₀, h_eq⟩ := h_z₀ ⟨dslope f c z₀, h_eq, affine_of_mapsTo_ball_of_exists_norm_dslope_eq_div hd h_maps h_z₀ h_eq⟩ /-- The **Schwarz Lemma**: if `f : ℂ → E` sends an open disk with center `c` and a positive radius `R₁` to an open ball with center `f c` and radius `R₂`, then the norm of the derivative of `f` at `c` is at most the ratio `R₂ / R₁`. -/ theorem norm_deriv_le_div_of_mapsTo_ball (hd : DifferentiableOn ℂ f (ball c R₁)) (h_maps : MapsTo f (ball c R₁) (ball (f c) R₂)) (h₀ : 0 < R₁) : ‖deriv f c‖ ≤ R₂ / R₁ := by simpa only [dslope_same] using norm_dslope_le_div_of_mapsTo_ball hd h_maps (mem_ball_self h₀) /-- The **Schwarz Lemma**: if `f : ℂ → E` sends an open disk with center `c` and radius `R₁` to an open ball with center `f c` and radius `R₂`, then for any `z` in the former disk we have `dist (f z) (f c) ≤ (R₂ / R₁) * dist z c`. -/ theorem dist_le_div_mul_dist_of_mapsTo_ball (hd : DifferentiableOn ℂ f (ball c R₁)) (h_maps : MapsTo f (ball c R₁) (ball (f c) R₂)) (hz : z ∈ ball c R₁) : dist (f z) (f c) ≤ R₂ / R₁ * dist z c := by rcases eq_or_ne z c with (rfl | hne) · simp only [dist_self, mul_zero, le_rfl] simpa only [dslope_of_ne _ hne, slope_def_module, norm_smul, norm_inv, ← div_eq_inv_mul, ← dist_eq_norm, div_le_iff₀ (dist_pos.2 hne)] using norm_dslope_le_div_of_mapsTo_ball hd h_maps hz end Space variable {f : ℂ → ℂ} {c z : ℂ} {R R₁ R₂ : ℝ} /-- The **Schwarz Lemma**: if `f : ℂ → ℂ` sends an open disk of positive radius to itself and the center of this disk to itself, then the norm of the derivative of `f` at the center of this disk is at most `1`. -/ theorem norm_deriv_le_one_of_mapsTo_ball (hd : DifferentiableOn ℂ f (ball c R)) (h_maps : MapsTo f (ball c R) (ball c R)) (hc : f c = c) (h₀ : 0 < R) : ‖deriv f c‖ ≤ 1 := (norm_deriv_le_div_of_mapsTo_ball hd (by rwa [hc]) h₀).trans_eq (div_self h₀.ne') /-- The **Schwarz Lemma**: if `f : ℂ → ℂ` sends an open disk to itself and the center `c` of this disk to itself, then for any point `z` of this disk we have `dist (f z) c ≤ dist z c`. -/ theorem dist_le_dist_of_mapsTo_ball_self (hd : DifferentiableOn ℂ f (ball c R)) (h_maps : MapsTo f (ball c R) (ball c R)) (hc : f c = c) (hz : z ∈ ball c R) : dist (f z) c ≤ dist z c := by have := dist_le_div_mul_dist_of_mapsTo_ball hd (by rwa [hc]) hz rwa [hc, div_self, one_mul] at this exact (nonempty_ball.1 ⟨z, hz⟩).ne' /-- The **Schwarz Lemma**: if `f : ℂ → ℂ` sends an open disk with center `0` to itself, then for any point `z` of this disk we have `‖f z‖ ≤ ‖z‖`. -/ theorem norm_le_norm_of_mapsTo_ball_self (hd : DifferentiableOn ℂ f (ball 0 R)) (h_maps : MapsTo f (ball 0 R) (ball 0 R)) (h₀ : f 0 = 0) (hz : ‖z‖ < R) : ‖f z‖ ≤ ‖z‖ := by replace hz : z ∈ ball (0 : ℂ) R := mem_ball_zero_iff.2 hz simpa only [dist_zero_right] using dist_le_dist_of_mapsTo_ball_self hd h_maps h₀ hz end Complex
.lake/packages/mathlib/Mathlib/Analysis/Complex/Circle.lean
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Basic import Mathlib.Analysis.Normed.Field.UnitBall /-! # The circle This file defines `circle` to be the metric sphere (`Metric.sphere`) in `ℂ` centred at `0` of radius `1`. We equip it with the following structure: * a submonoid of `ℂ` * a group * a topological group We furthermore define `Circle.exp` to be the natural map `fun t ↦ exp (t * I)` from `ℝ` to `circle`, and show that this map is a group homomorphism. We define two additive characters onto the circle: * `Real.fourierChar`: The character `fun x ↦ exp ((2 * π * x) * I)` (for which we introduce the notation `𝐞` in the scope `FourierTransform`). This uses the analyst convention that there is a `2 * π` in the exponent. * `Real.probChar`: The character `fun x ↦ exp (x * I)`, which uses the probabilist convention that there is no `2 * π` in the exponent. ## Implementation notes Because later (in `Geometry.Manifold.Instances.Sphere`) one wants to equip the circle with a smooth manifold structure borrowed from `Metric.sphere`, the underlying set is `{z : ℂ | abs (z - 0) = 1}`. This prevents certain algebraic facts from working definitionally -- for example, the circle is not defeq to `{z : ℂ | abs z = 1}`, which is the kernel of `Complex.abs` considered as a homomorphism from `ℂ` to `ℝ`, nor is it defeq to `{z : ℂ | normSq z = 1}`, which is the kernel of the homomorphism `Complex.normSq` from `ℂ` to `ℝ`. -/ noncomputable section open Complex Function Metric open ComplexConjugate /-- The unit circle in `ℂ`. -/ def Circle : Type := Submonoid.unitSphere ℂ deriving TopologicalSpace namespace Circle variable {x y : Circle} instance instCoeOut : CoeOut Circle ℂ := subtypeCoe instance instCommGroup : CommGroup Circle := Metric.sphere.instCommGroup instance instMetricSpace : MetricSpace Circle := Subtype.metricSpace @[ext] lemma ext : (x : ℂ) = y → x = y := Subtype.ext lemma coe_injective : Injective ((↑) : Circle → ℂ) := fun _ _ ↦ ext -- Not simp because `SetLike.coe_eq_coe` already proves it lemma coe_inj : (x : ℂ) = y ↔ x = y := coe_injective.eq_iff lemma norm_coe (z : Circle) : ‖(z : ℂ)‖ = 1 := mem_sphere_zero_iff_norm.1 z.2 @[simp] lemma normSq_coe (z : Circle) : normSq z = 1 := by simp [normSq_eq_norm_sq] @[simp] lemma coe_ne_zero (z : Circle) : (z : ℂ) ≠ 0 := ne_zero_of_mem_unit_sphere z @[simp, norm_cast] lemma coe_one : ↑(1 : Circle) = (1 : ℂ) := rfl -- Not simp because `OneMemClass.coe_eq_one` already proves it @[norm_cast] lemma coe_eq_one : (x : ℂ) = 1 ↔ x = 1 := by rw [← coe_inj, coe_one] @[simp, norm_cast] lemma coe_mul (z w : Circle) : ↑(z * w) = (z : ℂ) * w := rfl @[simp, norm_cast] lemma coe_inv (z : Circle) : ↑z⁻¹ = (z : ℂ)⁻¹ := rfl lemma coe_inv_eq_conj (z : Circle) : ↑z⁻¹ = conj (z : ℂ) := by rw [coe_inv, inv_def, normSq_coe, inv_one, ofReal_one, mul_one] @[simp, norm_cast] lemma coe_div (z w : Circle) : ↑(z / w) = (z : ℂ) / w := rfl /-- The coercion `Circle → ℂ` as a monoid homomorphism. -/ @[simps] def coeHom : Circle →* ℂ where toFun := (↑) map_one' := coe_one map_mul' := coe_mul /-- The elements of the circle embed into the units. -/ def toUnits : Circle →* Units ℂ := unitSphereToUnits ℂ -- written manually because `@[simps]` generated the wrong lemma @[simp] lemma toUnits_apply (z : Circle) : toUnits z = Units.mk0 ↑z z.coe_ne_zero := rfl instance : CompactSpace Circle := Metric.sphere.compactSpace _ _ instance : IsTopologicalGroup Circle := Metric.sphere.instIsTopologicalGroup instance instUniformSpace : UniformSpace Circle := instUniformSpaceSubtype instance : IsUniformGroup Circle := inferInstance /-- If `z` is a nonzero complex number, then `conj z / z` belongs to the unit circle. -/ @[simps] def ofConjDivSelf (z : ℂ) (hz : z ≠ 0) : Circle where val := conj z / z property := mem_sphere_zero_iff_norm.2 <| by rw [norm_div, RCLike.norm_conj, div_self]; exact norm_ne_zero_iff.mpr hz /-- The map `fun t => exp (t * I)` from `ℝ` to the unit circle in `ℂ`. -/ def exp : C(ℝ, Circle) where toFun t := ⟨(t * I).exp, by simp [Submonoid.unitSphere, exp_mul_I, norm_cos_add_sin_mul_I]⟩ continuous_toFun := Continuous.subtype_mk (by fun_prop) (by simp [Submonoid.unitSphere, exp_mul_I, norm_cos_add_sin_mul_I]) @[simp, norm_cast] theorem coe_exp (t : ℝ) : exp t = Complex.exp (t * Complex.I) := rfl @[simp] theorem exp_zero : exp 0 = 1 := Subtype.ext <| by rw [coe_exp, ofReal_zero, zero_mul, Complex.exp_zero, coe_one] @[simp] theorem exp_add (x y : ℝ) : exp (x + y) = exp x * exp y := Subtype.ext <| by simp only [coe_exp, ofReal_add, add_mul, Complex.exp_add, coe_mul] /-- The map `fun t => exp (t * I)` from `ℝ` to the unit circle in `ℂ`, considered as a homomorphism of groups. -/ @[simps] def expHom : ℝ →+ Additive Circle where toFun := Additive.ofMul ∘ exp map_zero' := exp_zero map_add' := exp_add @[simp] lemma exp_sub (x y : ℝ) : exp (x - y) = exp x / exp y := expHom.map_sub x y @[simp] lemma exp_neg (x : ℝ) : exp (-x) = (exp x)⁻¹ := expHom.map_neg x lemma exp_pi_ne_one : Circle.exp Real.pi ≠ 1 := by intro h have heq : (Circle.exp Real.pi : ℂ) = 1 := by simp [h] rw [Circle.coe_exp, exp_pi_mul_I] at heq norm_num at heq variable {e : AddChar ℝ Circle} @[simp] lemma star_addChar (x : ℝ) : star ((e x) : ℂ) = e (-x) := by have h := Circle.coe_inv_eq_conj ⟨e x, ?_⟩ · simp [← h, e.map_neg_eq_inv] · simp only [Submonoid.unitSphere, SetLike.coe_mem] @[simp] lemma starRingEnd_addChar (x : ℝ) : starRingEnd ℂ (e x) = e (-x) := star_addChar x variable {α β M : Type*} instance instSMul [SMul ℂ α] : SMul Circle α := Submonoid.smul _ instance instSMulCommClass_left [SMul ℂ β] [SMul α β] [SMulCommClass ℂ α β] : SMulCommClass Circle α β := Submonoid.smulCommClass_left _ instance instSMulCommClass_right [SMul ℂ β] [SMul α β] [SMulCommClass α ℂ β] : SMulCommClass α Circle β := Submonoid.smulCommClass_right _ instance instIsScalarTower [SMul ℂ α] [SMul ℂ β] [SMul α β] [IsScalarTower ℂ α β] : IsScalarTower Circle α β := Submonoid.isScalarTower _ instance instMulAction [MulAction ℂ α] : MulAction Circle α := Submonoid.mulAction _ instance instDistribMulAction [AddMonoid M] [DistribMulAction ℂ M] : DistribMulAction Circle M := Submonoid.distribMulAction _ lemma smul_def [SMul ℂ α] (z : Circle) (a : α) : z • a = (z : ℂ) • a := rfl instance instContinuousSMul [TopologicalSpace α] [MulAction ℂ α] [ContinuousSMul ℂ α] : ContinuousSMul Circle α := Submonoid.continuousSMul @[simp] protected lemma norm_smul {E : Type*} [SeminormedAddCommGroup E] [NormedSpace ℂ E] (u : Circle) (v : E) : ‖u • v‖ = ‖v‖ := by rw [Submonoid.smul_def, norm_smul, norm_eq_of_mem_sphere, one_mul] end Circle namespace Real /-- The additive character from `ℝ` onto the circle, given by `fun x ↦ exp (2 * π * x * I)`. Denoted as `𝐞` within the `Real.FourierTransform` namespace. This uses the analyst convention that there is a `2 * π` in the exponent. -/ def fourierChar : AddChar ℝ Circle where toFun z := .exp (2 * π * z) map_zero_eq_one' := by rw [mul_zero, Circle.exp_zero] map_add_eq_mul' x y := by rw [mul_add, Circle.exp_add] @[inherit_doc] scoped[FourierTransform] notation "𝐞" => Real.fourierChar open FourierTransform theorem fourierChar_apply' (x : ℝ) : 𝐞 x = Circle.exp (2 * π * x) := rfl theorem fourierChar_apply (x : ℝ) : 𝐞 x = Complex.exp (↑(2 * π * x) * Complex.I) := rfl @[continuity, fun_prop] theorem continuous_fourierChar : Continuous 𝐞 := Circle.exp.continuous.comp (continuous_mul_left _) theorem fourierChar_ne_one : fourierChar ≠ 1 := by rw [DFunLike.ne_iff] use 2⁻¹ simp only [fourierChar_apply', AddChar.one_apply] rw [mul_comm, ← mul_assoc, inv_mul_cancel₀ (by positivity), one_mul] exact Circle.exp_pi_ne_one /-- The additive character from `ℝ` onto the circle, given by `fun x ↦ exp (x * I)`. This uses the probabilist convention that there is no `2 * π` in the exponent. -/ def probChar : AddChar ℝ Circle where toFun := Circle.exp map_zero_eq_one' := Circle.exp_zero map_add_eq_mul' := Circle.exp_add theorem probChar_apply' (x : ℝ) : probChar x = Circle.exp x := rfl theorem probChar_apply (x : ℝ) : probChar x = Complex.exp (x * Complex.I) := rfl @[continuity, fun_prop] theorem continuous_probChar : Continuous probChar := map_continuous Circle.exp theorem probChar_ne_one : probChar ≠ 1 := by rw [DFunLike.ne_iff] use Real.pi simpa only [probChar_apply'] using Circle.exp_pi_ne_one end Real
.lake/packages/mathlib/Mathlib/Analysis/Complex/Spectrum.lean
import Mathlib.Algebra.Algebra.Spectrum.Quasispectrum import Mathlib.Analysis.Complex.Basic /-! # Some lemmas on the spectrum and quasispectrum of elements and positivity on `ℂ` -/ namespace SpectrumRestricts variable {A : Type*} [Ring A] lemma real_iff [Algebra ℂ A] {a : A} : SpectrumRestricts a Complex.reCLM ↔ ∀ x ∈ spectrum ℂ a, x = x.re := by refine ⟨fun h x hx ↦ ?_, fun h ↦ ?_⟩ · obtain ⟨x, -, rfl⟩ := h.algebraMap_image.symm ▸ hx simp · exact .of_subset_range_algebraMap Complex.ofReal_re fun x hx ↦ ⟨x.re, (h x hx).symm⟩ end SpectrumRestricts namespace QuasispectrumRestricts local notation "σₙ" => quasispectrum variable {A : Type*} [NonUnitalRing A] lemma real_iff [Module ℂ A] [IsScalarTower ℂ A A] [SMulCommClass ℂ A A] {a : A} : QuasispectrumRestricts a Complex.reCLM ↔ ∀ x ∈ σₙ ℂ a, x = x.re := by rw [quasispectrumRestricts_iff_spectrumRestricts_inr, Unitization.quasispectrum_eq_spectrum_inr' _ ℂ, SpectrumRestricts.real_iff] end QuasispectrumRestricts
.lake/packages/mathlib/Mathlib/Analysis/Complex/Harmonic/Analytic.lean
import Mathlib.Analysis.Calculus.FDeriv.Symmetric import Mathlib.Analysis.Complex.Conformal import Mathlib.Analysis.Complex.HasPrimitives import Mathlib.Analysis.InnerProductSpace.Harmonic.Basic /-! # Analyticity of Harmonic Functions If `f : ℂ → ℝ` is harmonic at `x`, we show that `∂f/∂1 - I • ∂f/∂I` is complex-analytic at `x`. If `f` is harmonic on an open ball, then it is the real part of a function `F : ℂ → ℂ` that is holomorphic on the ball. This implies in particular that harmonic functions are real-analytic. -/ open Complex InnerProductSpace Metric Topology variable {f : ℂ → ℝ} {x : ℂ} /-- If `f : ℂ → ℝ` is harmonic at `x`, then `∂f/∂1 - I • ∂f/∂I` is complex differentiable at `x`. -/ theorem HarmonicAt.differentiableAt_complex_partial (hf : HarmonicAt f x) : DifferentiableAt ℂ (fun z ↦ fderiv ℝ f z 1 - I * fderiv ℝ f z I) x := by have : (fun z ↦ fderiv ℝ f z 1 - I * fderiv ℝ f z I) = (ofRealCLM ∘ (fderiv ℝ f · 1) - I • ofRealCLM ∘ (fderiv ℝ f · I)) := by ext; simp rw [this] have h₁f := hf.1 refine differentiableAt_complex_iff_differentiableAt_real.2 ⟨by fun_prop, ?_⟩ rw [fderiv_sub (by fun_prop) (by fun_prop), fderiv_const_smul (by fun_prop)] repeat rw [fderiv_comp]; all_goals try fun_prop simp only [ContinuousLinearMap.fderiv, ContinuousLinearMap.coe_sub', ContinuousLinearMap.coe_comp', ContinuousLinearMap.coe_smul', Pi.sub_apply, Function.comp_apply, ofRealCLM_apply, Pi.smul_apply, smul_eq_mul, mul_sub] ring_nf rw [fderiv_clm_apply (by fun_prop) (by fun_prop), fderiv_clm_apply (by fun_prop) (by fun_prop)] simp only [fderiv_fun_const, Pi.zero_apply, ContinuousLinearMap.comp_zero, zero_add, ContinuousLinearMap.flip_apply, I_sq, neg_mul, one_mul, sub_neg_eq_add] rw [add_comm, sub_eq_add_neg] congr 1 · norm_cast apply h₁f.isSymmSndFDerivAt (by simp) · have h₂f := hf.2.eq_of_nhds simp only [laplacian_eq_iteratedFDeriv_complexPlane, iteratedFDeriv_two_apply, Fin.isValue, Matrix.cons_val_zero, Matrix.cons_val_one, Matrix.cons_val_fin_one, Pi.zero_apply, add_eq_zero_iff_eq_neg] at h₂f simp [h₂f] /-- If `f : ℂ → ℝ` is harmonic at `x`, then `∂f/∂1 - I • ∂f/∂I` is complex analytic at `x`. -/ theorem HarmonicAt.analyticAt_complex_partial (hf : HarmonicAt f x) : AnalyticAt ℂ (fun z ↦ fderiv ℝ f z 1 - I * fderiv ℝ f z I) x := DifferentiableOn.analyticAt (s := { x | HarmonicAt f x }) (fun _ hy ↦ (HarmonicAt.differentiableAt_complex_partial hy).differentiableWithinAt) ((isOpen_setOf_harmonicAt f).mem_nhds hf) /- If a function `f : ℂ → ℝ` is harmonic on an open ball, then `f` is the real part of a function `F : ℂ → ℂ` that is holomorphic on the ball. -/ theorem harmonic_is_realOfHolomorphic {z : ℂ} {R : ℝ} (hf : HarmonicOnNhd f (ball z R)) : ∃ F : ℂ → ℂ, (AnalyticOnNhd ℂ F (ball z R)) ∧ ((ball z R).EqOn (fun z ↦ (F z).re) f) := by by_cases hR : R ≤ 0 · simp [ball_eq_empty.2 hR] let g := ofRealCLM ∘ (fderiv ℝ f · 1) - I • ofRealCLM ∘ (fderiv ℝ f · I) have hg : DifferentiableOn ℂ g (ball z R) := fun x hx ↦ (HarmonicAt.differentiableAt_complex_partial (hf x hx)).differentiableWithinAt obtain ⟨F₀, hF₀⟩ := hg.isExactOn_ball let F := fun x ↦ F₀ x - F₀ z + f z have h₁F : ∀ z₁ ∈ ball z R, HasDerivAt F (g z₁) z₁ := by simp_all [F] have h₂F : DifferentiableOn ℂ F (ball z R) := fun x hx ↦ (h₁F x hx).differentiableAt.differentiableWithinAt have h₃F : DifferentiableOn ℝ F (ball z R) := h₂F.restrictScalars (𝕜 := ℝ) (𝕜' := ℂ) use F, h₂F.analyticOnNhd isOpen_ball rw [(by aesop : (fun z ↦ (F z).re) = Complex.reCLM ∘ F)] intro x hx apply (convex_ball z R).eqOn_of_fderivWithin_eq (𝕜 := ℝ) (x := z) · exact reCLM.differentiable.comp_differentiableOn h₃F · exact fun y hy ↦ (ContDiffAt.differentiableAt (hf y hy).1 one_le_two).differentiableWithinAt · exact isOpen_ball.uniqueDiffOn · intro y hy have h₄F := (h₁F y hy).differentiableAt have h₅F := h₄F.restrictScalars (𝕜 := ℝ) (𝕜' := ℂ) rw [fderivWithin_eq_fderiv (isOpen_ball.uniqueDiffWithinAt hy) (reCLM.differentiableAt.comp y h₅F), fderivWithin_eq_fderiv (isOpen_ball.uniqueDiffWithinAt hy) ((hf y hy).1.differentiableAt one_le_two), fderiv_comp y (by fun_prop) h₅F, ContinuousLinearMap.fderiv, h₄F.fderiv_restrictScalars (𝕜 := ℝ)] ext a nth_rw 2 [(by simp : a = a.re • (1 : ℂ) + a.im • (I : ℂ))] rw [ContinuousLinearMap.map_add, ContinuousLinearMap.map_smul, ContinuousLinearMap.map_smul] simp [HasDerivAt.deriv (h₁F y hy), g] · simp_all · simp [F] · assumption /- Harmonic functions are real analytic. TODO: Prove this for harmonic functions on an arbitrary f.d. inner product space (not just on `ℂ`). -/ theorem HarmonicAt.analyticAt (hf : HarmonicAt f x) : AnalyticAt ℝ f x := by obtain ⟨ε, h₁ε, h₂ε⟩ := isOpen_iff.1 (isOpen_setOf_harmonicAt (f := f)) x hf obtain ⟨F, h₁F, h₂F⟩ := harmonic_is_realOfHolomorphic (fun _ hy ↦ h₂ε hy) rw [analyticAt_congr (Filter.eventually_of_mem (ball_mem_nhds x h₁ε) (fun y hy ↦ h₂F.symm hy))] exact (reCLM.analyticAt (F x)).comp (h₁F x (mem_ball_self h₁ε)).restrictScalars
.lake/packages/mathlib/Mathlib/Analysis/Complex/Harmonic/MeanValue.lean
import Mathlib.Analysis.Complex.Harmonic.Analytic import Mathlib.Analysis.Complex.MeanValue /-! # The Mean Value Property of Harmonic Functions on the Complex Plane -/ open InnerProductSpace Metric Real variable {f : ℂ → ℝ} {c : ℂ} {R : ℝ} /-- The **Mean Value Property** of harmonic functions: If `f : ℂ → ℝ` is harmonic in a neighborhood of a closed disc of radius `R` and center `c`, then the circle average `circleAverage f c R` equals `f c`. -/ theorem HarmonicOnNhd.circleAverage_eq (hf : HarmonicOnNhd f (closedBall c |R|)) : circleAverage f c R = f c := by obtain ⟨e, h₁e, h₂e⟩ := (isCompact_closedBall c |R|).exists_thickening_subset_open (isOpen_setOf_harmonicAt f) hf rw [thickening_closedBall h₁e (abs_nonneg R)] at h₂e obtain ⟨F, h₁F, h₂F⟩ := harmonic_is_realOfHolomorphic h₂e have h₃F : ∀ z ∈ closedBall c |R|, DifferentiableAt ℂ F z := fun x hx ↦ (h₁F x (by simp_all [lt_add_of_pos_of_le h₁e hx])).differentiableAt have h₄F : Set.EqOn (Complex.reCLM ∘ F) f (sphere c |R|) := fun x hx ↦ h₂F (sphere_subset_ball (lt_add_of_pos_left |R| h₁e) hx) rw [← circleAverage_congr_sphere h₄F, Complex.reCLM.circleAverage_comp_comm, circleAverage_of_differentiable_on h₃F] · apply h₂F simp [mem_ball, dist_self, add_pos_of_pos_of_nonneg h₁e (abs_nonneg R)] · exact (continuousOn_of_forall_continuousAt (fun x hx ↦ (h₃F x (sphere_subset_closedBall hx)).continuousAt)).circleIntegrable'
.lake/packages/mathlib/Mathlib/Analysis/Complex/UnitDisc/Basic.lean
import Mathlib.Analysis.Complex.Circle import Mathlib.Analysis.Normed.Module.Ball.Action /-! # Poincaré disc In this file we define `Complex.UnitDisc` to be the unit disc in the complex plane. We also introduce some basic operations on this disc. -/ open Set Function Metric noncomputable section local notation "conj'" => starRingEnd ℂ namespace Complex /-- The complex unit disc, denoted as `𝔻` withinin the Complex namespace -/ def UnitDisc : Type := ball (0 : ℂ) 1 deriving TopologicalSpace @[inherit_doc] scoped[UnitDisc] notation "𝔻" => Complex.UnitDisc open UnitDisc namespace UnitDisc /-- Coercion to `ℂ`. -/ @[coe] protected def coe : 𝔻 → ℂ := Subtype.val instance instCommSemigroup : CommSemigroup UnitDisc := by unfold UnitDisc; infer_instance instance instSemigroupWithZero : SemigroupWithZero UnitDisc := by unfold UnitDisc; infer_instance instance instIsCancelMulZero : IsCancelMulZero UnitDisc := by unfold UnitDisc; infer_instance instance instHasDistribNeg : HasDistribNeg UnitDisc := by unfold UnitDisc; infer_instance instance instCoe : Coe UnitDisc ℂ := ⟨UnitDisc.coe⟩ theorem coe_injective : Injective ((↑) : 𝔻 → ℂ) := Subtype.coe_injective @[simp, norm_cast] theorem coe_inj {z w : 𝔻} : (z : ℂ) = w ↔ z = w := Subtype.val_inj theorem norm_lt_one (z : 𝔻) : ‖(z : ℂ)‖ < 1 := mem_ball_zero_iff.1 z.2 theorem norm_ne_one (z : 𝔻) : ‖(z : ℂ)‖ ≠ 1 := z.norm_lt_one.ne theorem normSq_lt_one (z : 𝔻) : normSq z < 1 := by convert (Real.sqrt_lt' one_pos).1 z.norm_lt_one exact (one_pow 2).symm theorem coe_ne_one (z : 𝔻) : (z : ℂ) ≠ 1 := ne_of_apply_ne (‖·‖) <| by simp [z.norm_ne_one] theorem coe_ne_neg_one (z : 𝔻) : (z : ℂ) ≠ -1 := ne_of_apply_ne (‖·‖) <| by simpa [norm_neg] using z.norm_ne_one theorem one_add_coe_ne_zero (z : 𝔻) : (1 + z : ℂ) ≠ 0 := mt neg_eq_iff_add_eq_zero.2 z.coe_ne_neg_one.symm @[simp, norm_cast] theorem coe_mul (z w : 𝔻) : ↑(z * w) = (z * w : ℂ) := rfl /-- A constructor that assumes `‖z‖ < 1` instead of `dist z 0 < 1` and returns an element of `𝔻` instead of `↥Metric.ball (0 : ℂ) 1`. -/ def mk (z : ℂ) (hz : ‖z‖ < 1) : 𝔻 := ⟨z, mem_ball_zero_iff.2 hz⟩ @[simp] theorem coe_mk (z : ℂ) (hz : ‖z‖ < 1) : (mk z hz : ℂ) = z := rfl @[simp] theorem mk_coe (z : 𝔻) (hz : ‖(z : ℂ)‖ < 1 := z.norm_lt_one) : mk z hz = z := Subtype.eta _ _ @[simp] theorem mk_neg (z : ℂ) (hz : ‖-z‖ < 1) : mk (-z) hz = -mk z (norm_neg z ▸ hz) := rfl @[simp] theorem coe_zero : ((0 : 𝔻) : ℂ) = 0 := rfl @[simp] theorem coe_eq_zero {z : 𝔻} : (z : ℂ) = 0 ↔ z = 0 := coe_injective.eq_iff' coe_zero @[simp] theorem mk_zero : mk 0 (by simp) = 0 := rfl @[simp] theorem mk_eq_zero {z : ℂ} (hz : ‖z‖ < 1) : mk z hz = 0 ↔ z = 0 := by simp [← coe_inj] instance : Inhabited 𝔻 := ⟨0⟩ instance circleAction : MulAction Circle 𝔻 := mulActionSphereBall instance isScalarTower_circle_circle : IsScalarTower Circle Circle 𝔻 := isScalarTower_sphere_sphere_ball instance isScalarTower_circle : IsScalarTower Circle 𝔻 𝔻 := isScalarTower_sphere_ball_ball instance instSMulCommClass_circle : SMulCommClass Circle 𝔻 𝔻 := instSMulCommClass_sphere_ball_ball instance instSMulCommClass_circle' : SMulCommClass 𝔻 Circle 𝔻 := SMulCommClass.symm _ _ _ @[simp, norm_cast] theorem coe_smul_circle (z : Circle) (w : 𝔻) : ↑(z • w) = (z * w : ℂ) := rfl instance closedBallAction : MulAction (closedBall (0 : ℂ) 1) 𝔻 := mulActionClosedBallBall instance isScalarTower_closedBall_closedBall : IsScalarTower (closedBall (0 : ℂ) 1) (closedBall (0 : ℂ) 1) 𝔻 := isScalarTower_closedBall_closedBall_ball instance isScalarTower_closedBall : IsScalarTower (closedBall (0 : ℂ) 1) 𝔻 𝔻 := isScalarTower_closedBall_ball_ball instance instSMulCommClass_closedBall : SMulCommClass (closedBall (0 : ℂ) 1) 𝔻 𝔻 := ⟨fun _ _ _ => Subtype.ext <| mul_left_comm _ _ _⟩ instance instSMulCommClass_closedBall' : SMulCommClass 𝔻 (closedBall (0 : ℂ) 1) 𝔻 := SMulCommClass.symm _ _ _ instance instSMulCommClass_circle_closedBall : SMulCommClass Circle (closedBall (0 : ℂ) 1) 𝔻 := instSMulCommClass_sphere_closedBall_ball instance instSMulCommClass_closedBall_circle : SMulCommClass (closedBall (0 : ℂ) 1) Circle 𝔻 := SMulCommClass.symm _ _ _ @[simp, norm_cast] theorem coe_smul_closedBall (z : closedBall (0 : ℂ) 1) (w : 𝔻) : ↑(z • w) = (z * w : ℂ) := rfl /-- Real part of a point of the unit disc. -/ def re (z : 𝔻) : ℝ := Complex.re z /-- Imaginary part of a point of the unit disc. -/ def im (z : 𝔻) : ℝ := Complex.im z @[simp, norm_cast] theorem re_coe (z : 𝔻) : (z : ℂ).re = z.re := rfl @[simp, norm_cast] theorem im_coe (z : 𝔻) : (z : ℂ).im = z.im := rfl @[simp] theorem re_neg (z : 𝔻) : (-z).re = -z.re := rfl @[simp] theorem im_neg (z : 𝔻) : (-z).im = -z.im := rfl /-- Conjugate point of the unit disc. -/ def conj (z : 𝔻) : 𝔻 := mk (conj' ↑z) <| (norm_conj z).symm ▸ z.norm_lt_one @[simp] theorem coe_conj (z : 𝔻) : (z.conj : ℂ) = conj' ↑z := rfl @[simp] theorem conj_zero : conj 0 = 0 := coe_injective (map_zero conj') @[simp] theorem conj_conj (z : 𝔻) : conj (conj z) = z := coe_injective <| Complex.conj_conj (z : ℂ) @[simp] theorem conj_neg (z : 𝔻) : (-z).conj = -z.conj := rfl @[simp] theorem re_conj (z : 𝔻) : z.conj.re = z.re := rfl @[simp] theorem im_conj (z : 𝔻) : z.conj.im = -z.im := rfl @[simp] theorem conj_mul (z w : 𝔻) : (z * w).conj = z.conj * w.conj := Subtype.ext <| map_mul _ _ _ end UnitDisc end Complex
.lake/packages/mathlib/Mathlib/Analysis/Complex/ValueDistribution/FirstMainTheorem.lean
import Mathlib.Analysis.Complex.JensenFormula import Mathlib.Analysis.Complex.ValueDistribution.CharacteristicFunction /-! # The First Main Theorem of Value Distribution Theory The First Main Theorem of Value Distribution Theory is a two-part statement, establishing invariance of the characteristic function `characteristic f ⊤` under modifications of `f`. - If `f` is meromorphic on the complex plane, then the characteristic functions for the value `⊤` of the function `f` and `f⁻¹` agree up to a constant, see Proposition 2.1 on p. 168 of [Lang, *Introduction to Complex Hyperbolic Spaces*][MR886677]. - If `f` is meromorphic on the complex plane, then the characteristic functions for the value `⊤` of the function `f` and `f - const` agree up to a constant, see Proposition 2.2 on p. 168 of [Lang, *Introduction to Complex Hyperbolic Spaces*][MR886677] See Section VI.2 of [Lang, *Introduction to Complex Hyperbolic Spaces*][MR886677] or Section 1.1 of [Noguchi-Winkelmann, *Nevanlinna Theory in Several Complex Variables and Diophantine Approximation*][MR3156076] for a detailed discussion. -/ namespace ValueDistribution open Asymptotics Filter Function.locallyFinsuppWithin MeromorphicAt MeromorphicOn Metric Real section FirstPart variable {f : ℂ → ℂ} {R : ℝ} /-! ## First Part of the First Main Theorem -/ /-- Helper lemma for the first part of the First Main Theorem: Given a meromorphic function `f`, compute difference between the characteristic functions of `f` and of its inverse. -/ lemma characteristic_sub_characteristic_inv (h : MeromorphicOn f ⊤) : characteristic f ⊤ - characteristic f⁻¹ ⊤ = circleAverage (log ‖f ·‖) 0 - (divisor f Set.univ).logCounting := by calc characteristic f ⊤ - characteristic f⁻¹ ⊤ _ = proximity f ⊤ - proximity f⁻¹ ⊤ - (logCounting f⁻¹ ⊤ - logCounting f ⊤) := by unfold characteristic ring _ = circleAverage (log ‖f ·‖) 0 - (logCounting f⁻¹ ⊤ - logCounting f ⊤) := by rw [proximity_sub_proximity_inv_eq_circleAverage h] _ = circleAverage (log ‖f ·‖) 0 - (logCounting f 0 - logCounting f ⊤) := by rw [logCounting_inv] _ = circleAverage (log ‖f ·‖) 0 - (divisor f Set.univ).logCounting := by rw [← ValueDistribution.log_counting_zero_sub_logCounting_top] /-- Helper lemma for the first part of the First Main Theorem: Away from zero, the difference between the characteristic functions of `f` and `f⁻¹` equals `log ‖meromorphicTrailingCoeffAt f 0‖`. -/ lemma characteristic_sub_characteristic_inv_of_ne_zero (hf : MeromorphicOn f Set.univ) (hR : R ≠ 0) : characteristic f ⊤ R - characteristic f⁻¹ ⊤ R = log ‖meromorphicTrailingCoeffAt f 0‖ := by calc characteristic f ⊤ R - characteristic f⁻¹ ⊤ R _ = (characteristic f ⊤ - characteristic f⁻¹ ⊤) R := by simp _ = circleAverage (log ‖f ·‖) 0 R - (divisor f Set.univ).logCounting R := by rw [characteristic_sub_characteristic_inv hf, Pi.sub_apply] _ = log ‖meromorphicTrailingCoeffAt f 0‖ := by rw [MeromorphicOn.circleAverage_log_norm hR (hf.mono_set (by tauto))] unfold Function.locallyFinsuppWithin.logCounting have : (divisor f (closedBall 0 |R|)) = (divisor f Set.univ).toClosedBall R := (divisor_restrict hf (by tauto)).symm simp [this, toClosedBall, restrictMonoidHom, restrict_apply] /-- Helper lemma for the first part of the First Main Theorem: At 0, the difference between the characteristic functions of `f` and `f⁻¹` equals `log ‖f 0‖`. -/ lemma characteristic_sub_characteristic_inv_at_zero (h : MeromorphicOn f Set.univ) : characteristic f ⊤ 0 - characteristic f⁻¹ ⊤ 0 = log ‖f 0‖ := by calc characteristic f ⊤ 0 - characteristic f⁻¹ ⊤ 0 _ = (characteristic f ⊤ - characteristic f⁻¹ ⊤) 0 := by simp _ = circleAverage (log ‖f ·‖) 0 0 - (divisor f Set.univ).logCounting 0 := by rw [ValueDistribution.characteristic_sub_characteristic_inv h, Pi.sub_apply] _ = log ‖f 0‖ := by simp /-- First part of the First Main Theorem, quantitative version: If `f` is meromorphic on the complex plane, then the difference between the characteristic functions of `f` and `f⁻¹` is bounded by an explicit constant. -/ theorem characteristic_sub_characteristic_inv_le (hf : MeromorphicOn f Set.univ) : |characteristic f ⊤ R - characteristic f⁻¹ ⊤ R| ≤ max |log ‖f 0‖| |log ‖meromorphicTrailingCoeffAt f 0‖| := by by_cases h : R = 0 · simp [h, characteristic_sub_characteristic_inv_at_zero hf] · simp [characteristic_sub_characteristic_inv_of_ne_zero hf h] /-- First part of the First Main Theorem, qualitative version: If `f` is meromorphic on the complex plane, then the characteristic functions of `f` and `f⁻¹` agree asymptotically up to a bounded function. -/ theorem isBigO_characteristic_sub_characteristic_inv (h : MeromorphicOn f ⊤) : (characteristic f ⊤ - characteristic f⁻¹ ⊤) =O[atTop] (1 : ℝ → ℝ) := isBigO_of_le' (c := max |log ‖f 0‖| |log ‖meromorphicTrailingCoeffAt f 0‖|) _ (fun R ↦ by simpa using characteristic_sub_characteristic_inv_le h (R := R)) end FirstPart section SecondPart variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℂ E] {a₀ : E} {f : ℂ → E} /-! ## Second Part of the First Main Theorem -/ /-- Second part of the First Main Theorem of Value Distribution Theory, quantitative version: If `f` is meromorphic on the complex plane, then the characteristic functions (for value `⊤`) of `f` and `f - a₀` differ at most by `log⁺ ‖a₀‖ + log 2`. -/ theorem abs_characteristic_sub_characteristic_shift_le {r : ℝ} (h : MeromorphicOn f ⊤) : |characteristic f ⊤ r - characteristic (f · - a₀) ⊤ r| ≤ log⁺ ‖a₀‖ + log 2 := by have h₁f : CircleIntegrable (fun x ↦ log⁺ ‖f x‖) 0 r := circleIntegrable_posLog_norm_meromorphicOn (fun x a ↦ h x trivial) have h₂f : CircleIntegrable (fun x ↦ log⁺ ‖f x - a₀‖) 0 r := by apply circleIntegrable_posLog_norm_meromorphicOn apply MeromorphicOn.sub (fun x a => h x trivial) (MeromorphicOn.const a₀) rw [← Pi.sub_apply, characteristic_sub_characteristic_eq_proximity_sub_proximity h] simp only [proximity, reduceDIte, Pi.sub_apply, ← circleAverage_sub h₁f h₂f] apply le_trans abs_circleAverage_le_circleAverage_abs apply circleAverage_mono_on_of_le_circle · apply (h₁f.sub h₂f).abs · intro θ hθ simp only [Pi.abs_apply, Pi.sub_apply] by_cases h : 0 ≤ log⁺ ‖f θ‖ - log⁺ ‖f θ - a₀‖ · simpa [abs_of_nonneg h, sub_le_iff_le_add, add_comm (log⁺ ‖a₀‖ + log 2), ← add_assoc] using (posLog_norm_add_le (f θ - a₀) a₀) · simp only [abs_of_nonpos (le_of_not_ge h), neg_sub, tsub_le_iff_right, add_comm (log⁺ ‖a₀‖ + log 2), ← add_assoc] convert posLog_norm_add_le (-f θ) (a₀) using 2 · rw [← norm_neg] abel_nf · simp /-- Second part of the First Main Theorem of Value Distribution Theory, qualitative version: If `f` is meromorphic on the complex plane, then the characteristic functions for the value `⊤` of the function `f` and `f - a₀` agree asymptotically up to a bounded function. -/ theorem isBigO_characteristic_sub_characteristic_shift (h : MeromorphicOn f ⊤) : (characteristic f ⊤ - characteristic (f · - a₀) ⊤) =O[atTop] (1 : ℝ → ℝ) := isBigO_of_le' (c := log⁺ ‖a₀‖ + log 2) _ (fun R ↦ by simpa using abs_characteristic_sub_characteristic_shift_le h) @[deprecated (since := "2025-10-06")] alias abs_characteristic_sub_characteristic_shift_eqO := isBigO_characteristic_sub_characteristic_shift end SecondPart end ValueDistribution
.lake/packages/mathlib/Mathlib/Analysis/Complex/ValueDistribution/CharacteristicFunction.lean
import Mathlib.Analysis.Complex.ValueDistribution.CountingFunction import Mathlib.Analysis.Complex.ValueDistribution.ProximityFunction /-! # The Characteristic Function of Value Distribution Theory This file defines the "characteristic function" attached to a meromorphic function defined on the complex plane. Also known as "Nevanlinna Height", this is one of the three main functions used in Value Distribution Theory. The characteristic function plays a role analogous to the height function in number theory: both measure the "complexity" of objects. For rational functions, the characteristic function grows like the degree times the logarithm, much like the logarithmic height in number theory reflects the degree of an algebraic number. See Section VI.2 of [Lang, *Introduction to Complex Hyperbolic Spaces*][MR886677] or Section 1.1 of [Noguchi-Winkelmann, *Nevanlinna Theory in Several Complex Variables and Diophantine Approximation*][MR3156076] for a detailed discussion. ### TODO - Characterize rational functions in terms of the growth rate of their characteristic function, as discussed in Theorem 2.6 on p. 170 of [Lang, *Introduction to Complex Hyperbolic Spaces*][MR886677]. -/ open Metric Real Set namespace ValueDistribution variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℂ E] {f : ℂ → E} {a : WithTop E} variable (f a) in /-- The Characteristic Function of Value Distribution Theory If `f : ℂ → E` is meromorphic and `a : WithTop E` is any value, the characteristic function of `f` is defined as the sum of two terms: the proximity function, which quantifies how close `f` gets to `a` on the circle `∣z∣ = r`, and the counting function, which counts the number times that `f` attains the value `a` inside the disk `∣z∣ ≤ r`, weighted by multiplicity. -/ noncomputable def characteristic : ℝ → ℝ := proximity f a + logCounting f a /-! ## Elementary Properties -/ /-- The difference between the characteristic functions of `f` and `f - const` simplifies to the difference between the proximity functions. -/ @[simp] lemma characteristic_sub_characteristic_eq_proximity_sub_proximity (h : MeromorphicOn f Set.univ) (a₀ : E) : characteristic f ⊤ - characteristic (f · - a₀) ⊤ = proximity f ⊤ - proximity (f · - a₀) ⊤ := by simp [← Pi.sub_def, characteristic, logCounting_sub_const h] /-! ## Behaviour under Arithmetic Operations -/ /-- For `1 ≤ r`, the characteristic function of `f * g` at zero is less than or equal to the sum of the characteristic functions of `f` and `g`, respectively. -/ theorem characteristic_zero_mul_le {f₁ f₂ : ℂ → ℂ} {r : ℝ} (hr : 1 ≤ r) (h₁f₁ : MeromorphicOn f₁ Set.univ) (h₂f₁ : ∀ z, meromorphicOrderAt f₁ z ≠ ⊤) (h₁f₂ : MeromorphicOn f₂ Set.univ) (h₂f₂ : ∀ z, meromorphicOrderAt f₂ z ≠ ⊤) : characteristic (f₁ * f₂) 0 r ≤ (characteristic f₁ 0 + characteristic f₂ 0) r := by simp only [characteristic, Pi.add_apply] rw [add_add_add_comm] apply add_le_add (proximity_zero_mul_le h₁f₁ h₁f₂ r) (logCounting_zero_mul_le hr h₁f₁ h₂f₁ h₁f₂ h₂f₂) /-- Asymptotically, the characteristic function of `f * g` at zero is less than or equal to the sum of the characteristic functions of `f` and `g`, respectively. -/ theorem characteristic_zero_mul_eventually_le {f₁ f₂ : ℂ → ℂ} (h₁f₁ : MeromorphicOn f₁ Set.univ) (h₂f₁ : ∀ z, meromorphicOrderAt f₁ z ≠ ⊤) (h₁f₂ : MeromorphicOn f₂ Set.univ) (h₂f₂ : ∀ z, meromorphicOrderAt f₂ z ≠ ⊤) : characteristic (f₁ * f₂) 0 ≤ᶠ[Filter.atTop] characteristic f₁ 0 + characteristic f₂ 0 := by filter_upwards [Filter.eventually_ge_atTop 1] exact fun _ hr ↦ characteristic_zero_mul_le hr h₁f₁ h₂f₁ h₁f₂ h₂f₂ /-- For `1 ≤ r`, the characteristic function of `f * g` at `⊤` is less than or equal to the sum of the characteristic functions of `f` and `g`, respectively. -/ theorem characteristic_top_mul_le {f₁ f₂ : ℂ → ℂ} {r : ℝ} (hr : 1 ≤ r) (h₁f₁ : MeromorphicOn f₁ Set.univ) (h₂f₁ : ∀ z, meromorphicOrderAt f₁ z ≠ ⊤) (h₁f₂ : MeromorphicOn f₂ Set.univ) (h₂f₂ : ∀ z, meromorphicOrderAt f₂ z ≠ ⊤) : characteristic (f₁ * f₂) ⊤ r ≤ (characteristic f₁ ⊤ + characteristic f₂ ⊤) r := by simp only [characteristic, Pi.add_apply] rw [add_add_add_comm] apply add_le_add (proximity_top_mul_le h₁f₁ h₁f₂ r) (logCounting_top_mul_le hr h₁f₁ h₂f₁ h₁f₂ h₂f₂) /-- Asymptotically, the characteristic function of `f * g` at `⊤` is less than or equal to the sum of the characteristic functions of `f` and `g`, respectively. -/ theorem characteristic_top_mul_eventually_le {f₁ f₂ : ℂ → ℂ} (h₁f₁ : MeromorphicOn f₁ Set.univ) (h₂f₁ : ∀ z, meromorphicOrderAt f₁ z ≠ ⊤) (h₁f₂ : MeromorphicOn f₂ Set.univ) (h₂f₂ : ∀ z, meromorphicOrderAt f₂ z ≠ ⊤) : characteristic (f₁ * f₂) ⊤ ≤ᶠ[Filter.atTop] characteristic f₁ ⊤ + characteristic f₂ ⊤ := by filter_upwards [Filter.eventually_ge_atTop 1] exact fun _ hr ↦ characteristic_top_mul_le hr h₁f₁ h₂f₁ h₁f₂ h₂f₂ /-- For natural numbers `n`, the characteristic function counting zeros of `f ^ n` equals `n` times the counting function counting zeros of `f`. -/ @[simp] theorem characteristic_pow_zero {f : ℂ → ℂ} {n : ℕ} (hf : MeromorphicOn f Set.univ) : characteristic (f ^ n) 0 = n • characteristic f 0 := by simp_all [characteristic] /-- For natural numbers `n`, the characteristic function counting poles of `f ^ n` equals `n` times the counting function counting poles of `f`. -/ @[simp] theorem characteristic_pow_top {f : ℂ → ℂ} {n : ℕ} (hf : MeromorphicOn f Set.univ) : characteristic (f ^ n) ⊤ = n • characteristic f ⊤ := by simp_all [characteristic] end ValueDistribution
.lake/packages/mathlib/Mathlib/Analysis/Complex/ValueDistribution/CountingFunction.lean
import Mathlib.Analysis.Meromorphic.Divisor import Mathlib.Analysis.SpecialFunctions.Log.Basic /-! # The Counting Function of Value Distribution Theory For nontrivially normed fields `𝕜`, this file defines the logarithmic counting function of a meromorphic function defined on `𝕜`. Also known as the `Nevanlinna counting function`, this is one of the three main functions used in Value Distribution Theory. The counting function of a meromorphic function `f` is a logarithmically weighted measure of the number of times the function `f` takes a given value `a` within the disk `∣z∣ ≤ r`, counting multiplicities. See Section VI.1 of [Lang, *Introduction to Complex Hyperbolic Spaces*][MR886677] or Section 1.1 of [Noguchi-Winkelmann, *Nevanlinna Theory in Several Complex Variables and Diophantine Approximation*][MR3156076] for a detailed discussion. ## Implementation Notes - This file defines the logarithmic counting function first for functions with locally finite support on `𝕜` and then specializes to the setting where the function with locally finite support is the pole or zero-divisor of a meromorphic function. - Even though value distribution theory is best developed for meromorphic functions on the complex plane (and therefore placed in the complex analysis section of Mathlib), we introduce the counting function for arbitrary normed fields. ## TODO - For `𝕜 = ℂ`, add the integral presentation of the logarithmic counting function - Discuss the counting function for rational functions, add a forward reference to the upcoming converse, formulated in terms of the Nevanlinna height. -/ open MeromorphicOn Metric Real Set /-! ## Supporting Notation -/ namespace Function.locallyFinsuppWithin variable {E : Type*} [NormedAddCommGroup E] /-- Shorthand notation for the restriction of a function with locally finite support within `Set.univ` to the closed unit ball of radius `r`. -/ noncomputable def toClosedBall (r : ℝ) : locallyFinsuppWithin (univ : Set E) ℤ →+ locallyFinsuppWithin (closedBall (0 : E) |r|) ℤ := by apply restrictMonoidHom tauto @[simp] lemma toClosedBall_eval_within {r : ℝ} {z : E} (f : locallyFinsuppWithin (univ : Set E) ℤ) (ha : z ∈ closedBall 0 |r|) : toClosedBall r f z = f z := by unfold toClosedBall simp_all [restrict_apply] /-! ## The Logarithmic Counting Function of a Function with Locally Finite Support -/ /-- Definition of the logarithmic counting function, as a group morphism mapping functions `D` with locally finite support to maps `ℝ → ℝ`. Given `D`, the result map `logCounting D` takes `r : ℝ` to a logarithmically weighted measure of values that `D` takes within the disk `∣z∣ ≤ r`. Implementation Note: In case where `z = 0`, the term `log (r * ‖z‖⁻¹)` evaluates to zero, which is typically different from `log r - log ‖z‖ = log r`. The summand `(D 0) * log r` compensates this, producing cleaner formulas when the logarithmic counting function is used in the main theorems of Value Distribution Theory. We refer the reader to page 164 of [Lang: Introduction to Complex Hyperbolic Spaces](https://link.springer.com/book/10.1007/978-1-4757-1945-1) for more details, and to the lemma `countingFunction_finsum_eq_finsum_add` in `Mathlib/Analysis/Complex/JensenFormula.lean` for a formal statement. -/ noncomputable def logCounting {E : Type*} [NormedAddCommGroup E] [ProperSpace E] : locallyFinsuppWithin (univ : Set E) ℤ →+ (ℝ → ℝ) where toFun D := fun r ↦ ∑ᶠ z, D.toClosedBall r z * log (r * ‖z‖⁻¹) + (D 0) * log r map_zero' := by aesop map_add' D₁ D₂ := by simp only [map_add, coe_add, Pi.add_apply, Int.cast_add] ext r have {A B C D : ℝ} : A + B + (C + D) = A + C + (B + D) := by ring rw [Pi.add_apply, this] congr 1 · have h₁s : ((D₁.toClosedBall r).support ∪ (D₂.toClosedBall r).support).Finite := by apply Set.finite_union.2 constructor <;> apply finiteSupport _ (isCompact_closedBall 0 |r|) repeat rw [finsum_eq_sum_of_support_subset (s := h₁s.toFinset)] try simp_rw [← Finset.sum_add_distrib, ← add_mul] repeat intro x hx by_contra simp_all · ring /-- Evaluation of the logarithmic counting function at zero yields zero. -/ @[simp] lemma logCounting_eval_zero {E : Type*} [NormedAddCommGroup E] [ProperSpace E] (D : locallyFinsuppWithin (univ : Set E) ℤ) : logCounting D 0 = 0 := by simp [logCounting] /-- For `1 ≤ r`, the counting function is non-negative. -/ theorem logCounting_nonneg {E : Type*} [NormedAddCommGroup E] [ProperSpace E] {f : locallyFinsuppWithin (univ : Set E) ℤ} {r : ℝ} (h : 0 ≤ f) (hr : 1 ≤ r) : 0 ≤ logCounting f r := by have h₃r : 0 < r := by linarith suffices ∀ z, 0 ≤ (((toClosedBall r) f) z) * log (r * ‖z‖⁻¹) from add_nonneg (finsum_nonneg this) <| mul_nonneg (by simpa using h 0) (log_nonneg hr) intro a by_cases h₁a : a = 0 · simp_all by_cases h₂a : a ∈ closedBall 0 |r| · refine mul_nonneg ?_ <| log_nonneg ?_ · simpa [h₂a] using h a · simpa [mul_comm r, one_le_inv_mul₀ (norm_pos_iff.mpr h₁a), abs_of_pos h₃r] using h₂a · simp [apply_eq_zero_of_notMem ((toClosedBall r) _) h₂a] /-- For `1 ≤ r`, the counting function respects the `≤` relation. -/ theorem logCounting_le {E : Type*} [NormedAddCommGroup E] [ProperSpace E] {f₁ f₂ : locallyFinsuppWithin (univ : Set E) ℤ} {r : ℝ} (h : f₁ ≤ f₂) (hr : 1 ≤ r) : logCounting f₁ r ≤ logCounting f₂ r := by rw [← sub_nonneg] at h ⊢ simpa using logCounting_nonneg h hr /-- The counting function respects the `≤` relation asymptotically. -/ theorem logCounting_eventually_le {E : Type*} [NormedAddCommGroup E] [ProperSpace E] {f₁ f₂ : locallyFinsuppWithin (univ : Set E) ℤ} (h : f₁ ≤ f₂) : logCounting f₁ ≤ᶠ[Filter.atTop] logCounting f₂ := by filter_upwards [Filter.eventually_ge_atTop 1] exact fun _ hr ↦ logCounting_le h hr end Function.locallyFinsuppWithin /-! ## The Logarithmic Counting Function of a Meromorphic Function -/ namespace ValueDistribution variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] [ProperSpace 𝕜] {E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E] {U : Set 𝕜} {f g : 𝕜 → E} {a : WithTop E} {a₀ : E} variable (f a) in /-- The logarithmic counting function of a meromorphic function. If `f : 𝕜 → E` is meromorphic and `a : WithTop E` is any value, this is a logarithmically weighted measure of the number of times the function `f` takes a given value `a` within the disk `∣z∣ ≤ r`, counting multiplicities. In the special case where `a = ⊤`, it counts the poles of `f`. -/ noncomputable def logCounting : ℝ → ℝ := by by_cases h : a = ⊤ · exact (divisor f univ)⁻.logCounting · exact (divisor (fun z ↦ f z - a.untop₀) univ)⁺.logCounting /-- For finite values `a₀`, the logarithmic counting function `logCounting f a₀` is the counting function associated with the zero-divisor of the meromorphic function `f - a₀`. -/ lemma logCounting_coe : logCounting f a₀ = (divisor (fun z ↦ f z - a₀) univ)⁺.logCounting := by simp [logCounting] /-- For finite values `a₀`, the logarithmic counting function `logCounting f a₀` equals the logarithmic counting function for the value zero of the shifted function `f - a₀`. -/ lemma logCounting_coe_eq_logCounting_sub_const_zero : logCounting f a₀ = logCounting (f - fun _ ↦ a₀) 0 := by simp [logCounting] /-- The logarithmic counting function `logCounting f 0` is the counting function associated with the zero-divisor of `f`. -/ lemma logCounting_zero : logCounting f 0 = (divisor f univ)⁺.logCounting := by simp [logCounting] /-- The logarithmic counting function `logCounting f ⊤` is the counting function associated with the pole-divisor of `f`. -/ lemma logCounting_top : logCounting f ⊤ = (divisor f univ)⁻.logCounting := by simp [logCounting] /-- Evaluation of the logarithmic counting function at zero yields zero. -/ @[simp] lemma logCounting_eval_zero : logCounting f a 0 = 0 := by by_cases h : a = ⊤ <;> simp [logCounting, h] /-- The counting function associated with the divisor of `f` is the difference between `logCounting f 0` and `logCounting f ⊤`. -/ theorem log_counting_zero_sub_logCounting_top {f : 𝕜 → E} : (divisor f univ).logCounting = logCounting f 0 - logCounting f ⊤ := by rw [← posPart_sub_negPart (divisor f univ), logCounting_zero, logCounting_top, map_sub] /-! ## Elementary Properties of the Counting Function -/ /-- Relation between the logarithmic counting function of `f` and of `f⁻¹`. -/ @[simp] theorem logCounting_inv {f : 𝕜 → 𝕜} : logCounting f⁻¹ ⊤ = logCounting f 0 := by simp [logCounting_zero, logCounting_top] /-- Adding an analytic function does not change the counting function counting poles. -/ theorem logCounting_add_analyticOn (hf : MeromorphicOn f univ) (hg : AnalyticOn 𝕜 g univ) : logCounting (f + g) ⊤ = logCounting f ⊤ := by simp only [logCounting, ↓reduceDIte] rw [hf.negPart_divisor_add_of_analyticNhdOn_right (isOpen_univ.analyticOn_iff_analyticOnNhd.1 hg)] /-- Special case of `logCounting_add_analyticOn`: Adding a constant does not change the counting function counting poles. -/ @[simp] theorem logCounting_add_const (hf : MeromorphicOn f univ) : logCounting (f + fun _ ↦ a₀) ⊤ = logCounting f ⊤ := by apply logCounting_add_analyticOn hf analyticOn_const /-- Special case of `logCounting_add_analyticOn`: Subtracting a constant does not change the counting function counting poles. -/ @[simp] theorem logCounting_sub_const (hf : MeromorphicOn f univ) : logCounting (f - fun _ ↦ a₀) ⊤ = logCounting f ⊤ := by simpa [sub_eq_add_neg] using logCounting_add_const hf /-! ## Behaviour under Arithmetic Operations -/ /-- For `1 ≤ r`, the counting function counting zeros of `f * g` is less than or equal to the sum of the counting functions counting zeros of `f` and `g`, respectively. Note: The statement proven here is found at the top of page 169 of [Lang: Introduction to Complex Hyperbolic Spaces](https://link.springer.com/book/10.1007/978-1-4757-1945-1) where it is written as an inequality between functions. This could be interpreted as claiming that the inequality holds for ALL values of `r`, which is not true. For a counterexample, take `f₁ : z → z` and `f₂ : z → z⁻¹`. Then, - `logCounting f₁ 0 = log` - `logCounting f₂ 0 = 0` - `logCounting (f₁ * f₂) 0 = 0` But `log r` is negative for small `r`. -/ theorem logCounting_zero_mul_le {f₁ f₂ : 𝕜 → 𝕜} {r : ℝ} (hr : 1 ≤ r) (h₁f₁ : MeromorphicOn f₁ Set.univ) (h₂f₁ : ∀ z, meromorphicOrderAt f₁ z ≠ ⊤) (h₁f₂ : MeromorphicOn f₂ Set.univ) (h₂f₂ : ∀ z, meromorphicOrderAt f₂ z ≠ ⊤) : logCounting (f₁ * f₂) 0 r ≤ (logCounting f₁ 0 + logCounting f₂ 0) r := by simp only [logCounting, WithTop.zero_ne_top, reduceDIte, WithTop.untop₀_zero, sub_zero] rw [divisor_mul h₁f₁ h₁f₂ (fun z _ ↦ h₂f₁ z) (fun z _ ↦ h₂f₂ z), ← Function.locallyFinsuppWithin.logCounting.map_add] apply Function.locallyFinsuppWithin.logCounting_le _ hr apply Function.locallyFinsuppWithin.posPart_add /-- Asymptotically, the counting function counting zeros of `f * g` is less than or equal to the sum of the counting functions counting zeros of `f` and `g`, respectively. -/ theorem logCounting_zero_mul_eventually_le {f₁ f₂ : 𝕜 → 𝕜} (h₁f₁ : MeromorphicOn f₁ Set.univ) (h₂f₁ : ∀ z, meromorphicOrderAt f₁ z ≠ ⊤) (h₁f₂ : MeromorphicOn f₂ Set.univ) (h₂f₂ : ∀ z, meromorphicOrderAt f₂ z ≠ ⊤) : logCounting (f₁ * f₂) 0 ≤ᶠ[Filter.atTop] logCounting f₁ 0 + logCounting f₂ 0 := by filter_upwards [Filter.eventually_ge_atTop 1] exact fun _ hr ↦ logCounting_zero_mul_le hr h₁f₁ h₂f₁ h₁f₂ h₂f₂ /-- For `1 ≤ r`, the counting function counting poles of `f * g` is less than or equal to the sum of the counting functions counting poles of `f` and `g`, respectively. -/ theorem logCounting_top_mul_le {f₁ f₂ : 𝕜 → 𝕜} {r : ℝ} (hr : 1 ≤ r) (h₁f₁ : MeromorphicOn f₁ Set.univ) (h₂f₁ : ∀ z, meromorphicOrderAt f₁ z ≠ ⊤) (h₁f₂ : MeromorphicOn f₂ Set.univ) (h₂f₂ : ∀ z, meromorphicOrderAt f₂ z ≠ ⊤) : logCounting (f₁ * f₂) ⊤ r ≤ (logCounting f₁ ⊤ + logCounting f₂ ⊤) r := by simp only [logCounting, reduceDIte] rw [divisor_mul h₁f₁ h₁f₂ (fun z _ ↦ h₂f₁ z) (fun z _ ↦ h₂f₂ z), ← Function.locallyFinsuppWithin.logCounting.map_add] apply Function.locallyFinsuppWithin.logCounting_le _ hr apply Function.locallyFinsuppWithin.negPart_add /-- Asymptotically, the counting function counting zeros of `f * g` is less than or equal to the sum of the counting functions counting zeros of `f` and `g`, respectively. -/ theorem logCounting_top_mul_eventually_le {f₁ f₂ : 𝕜 → 𝕜} (h₁f₁ : MeromorphicOn f₁ Set.univ) (h₂f₁ : ∀ z, meromorphicOrderAt f₁ z ≠ ⊤) (h₁f₂ : MeromorphicOn f₂ Set.univ) (h₂f₂ : ∀ z, meromorphicOrderAt f₂ z ≠ ⊤) : logCounting (f₁ * f₂) ⊤ ≤ᶠ[Filter.atTop] logCounting f₁ ⊤ + logCounting f₂ ⊤ := by filter_upwards [Filter.eventually_ge_atTop 1] exact fun _ hr ↦ logCounting_top_mul_le hr h₁f₁ h₂f₁ h₁f₂ h₂f₂ /-- For natural numbers `n`, the counting function counting zeros of `f ^ n` equals `n` times the counting function counting zeros of `f`. -/ @[simp] theorem logCounting_pow_zero {f : 𝕜 → 𝕜} {n : ℕ} (hf : MeromorphicOn f Set.univ) : logCounting (f ^ n) 0 = n • logCounting f 0 := by simp [logCounting, divisor_fun_pow hf n] /-- For natural numbers `n`, the counting function counting poles of `f ^ n` equals `n` times the counting function counting poles of `f`. -/ @[simp] theorem logCounting_pow_top {f : 𝕜 → 𝕜} {n : ℕ} (hf : MeromorphicOn f Set.univ) : logCounting (f ^ n) ⊤ = n • logCounting f ⊤ := by simp [logCounting, divisor_pow hf n] end ValueDistribution
.lake/packages/mathlib/Mathlib/Analysis/Complex/ValueDistribution/ProximityFunction.lean
import Mathlib.Algebra.Order.WithTop.Untop0 import Mathlib.Analysis.SpecialFunctions.Integrability.LogMeromorphic import Mathlib.MeasureTheory.Integral.CircleAverage /-! # The Proximity Function of Value Distribution Theory This file defines the "proximity function" attached to a meromorphic function defined on the complex plane. Also known as the `Nevanlinna Proximity Function`, this is one of the three main functions used in Value Distribution Theory. The proximity function is a logarithmically weighted measure quantifying how well a meromorphic function `f` approximates the constant function `a` on the circle of radius `R` in the complex plane. The definition ensures that large values correspond to good approximation. See Section VI.2 of [Lang, *Introduction to Complex Hyperbolic Spaces*][MR886677] or Section 1.1 of [Noguchi-Winkelmann, *Nevanlinna Theory in Several Complex Variables and Diophantine Approximation*][MR3156076] for a detailed discussion. -/ open Metric Real Set namespace ValueDistribution variable {E : Type*} [NormedAddCommGroup E] {f g : ℂ → E} {a : WithTop E} {a₀ : E} open Real variable (f a) in /-- The Proximity Function of Value Distribution Theory If `f : ℂ → E` is meromorphic and `a : WithTop E` is any value, the proximity function is a logarithmically weighted measure quantifying how well a meromorphic function `f` approximates the constant function `a` on the circle of radius `R` in the complex plane. In the special case where `a = ⊤`, it quantifies how well `f` approximates infinity. -/ noncomputable def proximity : ℝ → ℝ := by by_cases h : a = ⊤ · exact circleAverage (log⁺ ‖f ·‖) 0 · exact circleAverage (log⁺ ‖f · - a.untop₀‖⁻¹) 0 /-- Expand the definition of `proximity f a₀` in case where `a₀` is finite. -/ lemma proximity_coe : proximity f a₀ = circleAverage (log⁺ ‖f · - a₀‖⁻¹) 0 := by simp [proximity] /-- Expand the definition of `proximity f a₀` in case where `a₀` is zero. -/ lemma proximity_zero : proximity f 0 = circleAverage (log⁺ ‖f ·‖⁻¹) 0 := by simp [proximity] /-- For complex-valued functions, expand the definition of `proximity f a₀` in case where `a₀` is zero. This is a simple variant of `proximity_zero` defined above. -/ lemma proximity_zero_of_complexValued {f : ℂ → ℂ} : proximity f 0 = circleAverage (log⁺ ‖f⁻¹ ·‖) 0 := by simp [proximity] /-- Expand the definition of `proximity f a` in case where `a₀ = ⊤`. -/ lemma proximity_top : proximity f ⊤ = circleAverage (log⁺ ‖f ·‖) 0 := by simp [proximity] /-! ## Elementary Properties of the Proximity Function -/ /-- For finite values `a₀`, the proximity function `proximity f a₀` equals the proximity function for the value zero of the shifted function `f - a₀`. -/ lemma proximity_coe_eq_proximity_sub_const_zero : proximity f a₀ = proximity (f - fun _ ↦ a₀) 0 := by simp [proximity] /-- For complex-valued `f`, establish a simple relation between the proximity functions of `f` and of `f⁻¹`. -/ theorem proximity_inv {f : ℂ → ℂ} : proximity f⁻¹ ⊤ = proximity f 0 := by simp [proximity_zero, proximity_top] /-- For complex-valued `f`, the difference between `proximity f ⊤` and `proximity f⁻¹ ⊤` is the circle average of `log ‖f ·‖`. -/ theorem proximity_sub_proximity_inv_eq_circleAverage {f : ℂ → ℂ} (h₁f : MeromorphicOn f ⊤) : proximity f ⊤ - proximity f⁻¹ ⊤ = circleAverage (log ‖f ·‖) 0 := by ext R simp only [proximity, ↓reduceDIte, Pi.inv_apply, norm_inv, Pi.sub_apply] rw [← circleAverage_sub] · simp_rw [← posLog_sub_posLog_inv, Pi.sub_def] · apply circleIntegrable_posLog_norm_meromorphicOn (h₁f.mono_set (by tauto)) · simp_rw [← norm_inv] apply circleIntegrable_posLog_norm_meromorphicOn (h₁f.inv.mono_set (by tauto)) /-! ## Behaviour under Arithmetic Operations -/ /-- The proximity function `f * g` at `⊤` is less than or equal to the sum of the proximity functions of `f` and `g`, respectively. -/ theorem proximity_top_mul_le {f₁ f₂ : ℂ → ℂ} (h₁f₁ : MeromorphicOn f₁ Set.univ) (h₁f₂ : MeromorphicOn f₂ Set.univ) : proximity (f₁ * f₂) ⊤ ≤ (proximity f₁ ⊤) + (proximity f₂ ⊤) := by calc proximity (f₁ * f₂) ⊤ _ = circleAverage (fun x ↦ log⁺ (‖f₁ x‖ * ‖f₂ x‖)) 0 := by simp [proximity] _ ≤ circleAverage (fun x ↦ log⁺ ‖f₁ x‖ + log⁺ ‖f₂ x‖) 0 := by intro r apply circleAverage_mono · simp_rw [← norm_mul] apply circleIntegrable_posLog_norm_meromorphicOn exact MeromorphicOn.fun_mul (fun x a ↦ h₁f₁ x trivial) fun x a ↦ h₁f₂ x trivial · apply (circleIntegrable_posLog_norm_meromorphicOn (fun x a ↦ h₁f₁ x trivial)).add (circleIntegrable_posLog_norm_meromorphicOn (fun x a ↦ h₁f₂ x trivial)) · exact fun _ _ ↦ posLog_mul _ = circleAverage (log⁺ ‖f₁ ·‖) 0 + circleAverage (log⁺ ‖f₂ ·‖) 0:= by ext r apply circleAverage_add · exact circleIntegrable_posLog_norm_meromorphicOn (fun x a ↦ h₁f₁ x trivial) · exact circleIntegrable_posLog_norm_meromorphicOn (fun x a ↦ h₁f₂ x trivial) _ = (proximity f₁ ⊤) + (proximity f₂ ⊤) := rfl /-- The proximity function `f * g` at `0` is less than or equal to the sum of the proximity functions of `f` and `g`, respectively. -/ theorem proximity_zero_mul_le {f₁ f₂ : ℂ → ℂ} (h₁f₁ : MeromorphicOn f₁ Set.univ) (h₁f₂ : MeromorphicOn f₂ Set.univ) : proximity (f₁ * f₂) 0 ≤ (proximity f₁ 0) + (proximity f₂ 0) := by calc proximity (f₁ * f₂) 0 _ ≤ (proximity f₁⁻¹ ⊤) + (proximity f₂⁻¹ ⊤) := by rw [← proximity_inv, mul_inv] apply proximity_top_mul_le (MeromorphicOn.inv_iff.mpr h₁f₁) (MeromorphicOn.inv_iff.mpr h₁f₂) _ = (proximity f₁ 0) + (proximity f₂ 0) := by rw [proximity_inv, proximity_inv] /-- For natural numbers `n`, the proximity function of `f ^ n` at `⊤` equals `n` times the proximity function of `f` at `⊤`. -/ @[simp] theorem proximity_pow_top {f : ℂ → ℂ} {n : ℕ} : proximity (f ^ n) ⊤ = n • (proximity f ⊤) := by simp only [proximity, reduceDIte, Pi.pow_apply, norm_pow, posLog_pow, nsmul_eq_mul] ext _ rw [Pi.mul_apply, Pi.natCast_apply, ← smul_eq_mul, ← circleAverage_fun_smul] rfl /-- For natural numbers `n`, the proximity function of `f ^ n` at `0` equals `n` times the proximity function of `f` at `0`. -/ @[simp] theorem proximity_pow_zero {f : ℂ → ℂ} {n : ℕ} : proximity (f ^ n) 0 = n • (proximity f 0) := by rw [← proximity_inv, ← proximity_inv, (by aesop : (f ^ n)⁻¹ = f⁻¹ ^ n), proximity_pow_top] end ValueDistribution
.lake/packages/mathlib/Mathlib/Analysis/Complex/UpperHalfPlane/Exp.lean
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Basic import Mathlib.Analysis.Complex.Periodic import Mathlib.Analysis.Complex.UpperHalfPlane.Basic /-! # Exp on the upper half plane This file contains lemmas about the exponential function on the upper half plane. Useful for q-expansions of modular forms. -/ open Real Complex UpperHalfPlane Function local notation "𝕢" => Periodic.qParam theorem Function.Periodic.im_invQParam_pos_of_norm_lt_one {h : ℝ} (hh : 0 < h) {q : ℂ} (hq : ‖q‖ < 1) (hq_ne : q ≠ 0) : 0 < im (Periodic.invQParam h q) := im_invQParam .. ▸ mul_pos_of_neg_of_neg (div_neg_of_neg_of_pos (neg_lt_zero.mpr hh) Real.two_pi_pos) ((Real.log_neg_iff (norm_pos_iff.mpr hq_ne)).mpr hq) lemma Function.Periodic.norm_qParam_le_of_one_half_le_im {ξ : ℂ} (hξ : 1 / 2 ≤ ξ.im) : ‖𝕢 1 ξ‖ ≤ rexp (-π) := by rwa [Periodic.qParam, ofReal_one, div_one, Complex.norm_exp, Real.exp_le_exp, mul_right_comm, mul_I_re, neg_le_neg_iff, ← ofReal_ofNat, ← ofReal_mul, im_ofReal_mul, mul_comm _ π, mul_assoc, le_mul_iff_one_le_right Real.pi_pos, ← div_le_iff₀' two_pos] theorem UpperHalfPlane.norm_qParam_lt_one (n : ℕ) [NeZero n] (τ : ℍ) : ‖𝕢 n τ‖ < 1 := by rw [Periodic.norm_qParam, Real.exp_lt_one_iff, neg_mul, coe_im, neg_mul, neg_div, neg_lt_zero, div_pos_iff_of_pos_right (mod_cast Nat.pos_of_ne_zero <| NeZero.ne _)] positivity theorem UpperHalfPlane.norm_exp_two_pi_I_lt_one (τ : ℍ) : ‖(Complex.exp (2 * π * Complex.I * τ))‖ < 1 := by simpa [Function.Periodic.norm_qParam, Complex.norm_exp] using τ.norm_qParam_lt_one 1
.lake/packages/mathlib/Mathlib/Analysis/Complex/UpperHalfPlane/Metric.lean
import Mathlib.Analysis.Complex.UpperHalfPlane.Topology import Mathlib.Analysis.SpecialFunctions.Arsinh import Mathlib.Geometry.Euclidean.Inversion.Basic /-! # Metric on the upper half-plane In this file we define a `MetricSpace` structure on the `UpperHalfPlane`. We use hyperbolic (Poincaré) distance given by `dist z w = 2 * arsinh (dist (z : ℂ) w / (2 * √(z.im * w.im)))` instead of the induced Euclidean distance because the hyperbolic distance is invariant under holomorphic automorphisms of the upper half-plane. However, we ensure that the projection to `TopologicalSpace` is definitionally equal to the induced topological space structure. We also prove that a metric ball/closed ball/sphere in Poincaré metric is a Euclidean ball/closed ball/sphere with another center and radius. -/ noncomputable section open Filter Metric Real Set Topology open scoped UpperHalfPlane ComplexConjugate NNReal Topology MatrixGroups variable {z w : ℍ} {r : ℝ} namespace UpperHalfPlane instance : Dist ℍ := ⟨fun z w => 2 * arsinh (dist (z : ℂ) w / (2 * √(z.im * w.im)))⟩ theorem dist_eq (z w : ℍ) : dist z w = 2 * arsinh (dist (z : ℂ) w / (2 * √(z.im * w.im))) := rfl theorem sinh_half_dist (z w : ℍ) : sinh (dist z w / 2) = dist (z : ℂ) w / (2 * √(z.im * w.im)) := by rw [dist_eq, mul_div_cancel_left₀ (arsinh _) two_ne_zero, sinh_arsinh] theorem cosh_half_dist (z w : ℍ) : cosh (dist z w / 2) = dist (z : ℂ) (conj (w : ℂ)) / (2 * √(z.im * w.im)) := by rw [← sq_eq_sq₀, cosh_sq', sinh_half_dist, div_pow, div_pow, one_add_div, mul_pow, sq_sqrt] · congr 1 simp only [Complex.dist_eq, Complex.sq_norm, Complex.normSq_sub, Complex.normSq_conj, Complex.conj_conj, Complex.mul_re, Complex.conj_re, Complex.conj_im, coe_im] ring all_goals positivity theorem tanh_half_dist (z w : ℍ) : tanh (dist z w / 2) = dist (z : ℂ) w / dist (z : ℂ) (conj ↑w) := by rw [tanh_eq_sinh_div_cosh, sinh_half_dist, cosh_half_dist, div_div_div_comm, div_self, div_one] positivity theorem exp_half_dist (z w : ℍ) : exp (dist z w / 2) = (dist (z : ℂ) w + dist (z : ℂ) (conj ↑w)) / (2 * √(z.im * w.im)) := by rw [← sinh_add_cosh, sinh_half_dist, cosh_half_dist, add_div] theorem cosh_dist (z w : ℍ) : cosh (dist z w) = 1 + dist (z : ℂ) w ^ 2 / (2 * z.im * w.im) := by rw [dist_eq, cosh_two_mul, cosh_sq', add_assoc, ← two_mul, sinh_arsinh, div_pow, mul_pow, sq_sqrt, sq (2 : ℝ), mul_assoc, ← mul_div_assoc, mul_assoc, mul_div_mul_left] <;> positivity theorem sinh_half_dist_add_dist (a b c : ℍ) : sinh ((dist a b + dist b c) / 2) = (dist (a : ℂ) b * dist (c : ℂ) (conj ↑b) + dist (b : ℂ) c * dist (a : ℂ) (conj ↑b)) / (2 * √(a.im * c.im) * dist (b : ℂ) (conj ↑b)) := by simp only [add_div _ _ (2 : ℝ), sinh_add, sinh_half_dist, cosh_half_dist, div_mul_div_comm] rw [← add_div, Complex.dist_self_conj, coe_im, abs_of_pos b.im_pos, mul_comm (dist (b : ℂ) _), dist_comm (b : ℂ), Complex.dist_conj_comm, mul_mul_mul_comm, mul_mul_mul_comm _ _ _ b.im] congr 2 rw [sqrt_mul, sqrt_mul, sqrt_mul, mul_comm (√a.im), mul_mul_mul_comm, mul_self_sqrt, mul_comm] <;> exact (im_pos _).le protected theorem dist_comm (z w : ℍ) : dist z w = dist w z := by simp only [dist_eq, dist_comm (z : ℂ), mul_comm] theorem dist_le_iff_le_sinh : dist z w ≤ r ↔ dist (z : ℂ) w / (2 * √(z.im * w.im)) ≤ sinh (r / 2) := by rw [← div_le_div_iff_of_pos_right (zero_lt_two' ℝ), ← sinh_le_sinh, sinh_half_dist] theorem dist_eq_iff_eq_sinh : dist z w = r ↔ dist (z : ℂ) w / (2 * √(z.im * w.im)) = sinh (r / 2) := by rw [← div_left_inj' (two_ne_zero' ℝ), ← sinh_inj, sinh_half_dist] theorem dist_eq_iff_eq_sq_sinh (hr : 0 ≤ r) : dist z w = r ↔ dist (z : ℂ) w ^ 2 / (4 * z.im * w.im) = sinh (r / 2) ^ 2 := by rw [dist_eq_iff_eq_sinh, ← sq_eq_sq₀, div_pow, mul_pow, sq_sqrt, mul_assoc] · norm_num all_goals positivity protected theorem dist_triangle (a b c : ℍ) : dist a c ≤ dist a b + dist b c := by rw [dist_le_iff_le_sinh, sinh_half_dist_add_dist, div_mul_eq_div_div _ _ (dist _ _), le_div_iff₀, div_mul_eq_mul_div] · gcongr exact EuclideanGeometry.mul_dist_le_mul_dist_add_mul_dist (a : ℂ) b c (conj (b : ℂ)) · rw [dist_comm, dist_pos, Ne, Complex.conj_eq_iff_im] exact b.im_ne_zero theorem dist_le_dist_coe_div_sqrt (z w : ℍ) : dist z w ≤ dist (z : ℂ) w / √(z.im * w.im) := by rw [dist_le_iff_le_sinh, ← div_mul_eq_div_div_swap, self_le_sinh_iff] positivity /-- An auxiliary `MetricSpace` instance on the upper half-plane. This instance has bad projection to `TopologicalSpace`. We replace it later. -/ def metricSpaceAux : MetricSpace ℍ where dist := dist dist_self z := by rw [dist_eq, dist_self, zero_div, arsinh_zero, mul_zero] dist_comm := UpperHalfPlane.dist_comm dist_triangle := UpperHalfPlane.dist_triangle eq_of_dist_eq_zero {z w} h := by simpa [dist_eq, Real.sqrt_eq_zero', (mul_pos z.im_pos w.im_pos).not_ge, Set.ext_iff] using h open Complex theorem cosh_dist' (z w : ℍ) : Real.cosh (dist z w) = ((z.re - w.re) ^ 2 + z.im ^ 2 + w.im ^ 2) / (2 * z.im * w.im) := by simp [field, cosh_dist, Complex.dist_eq, Complex.sq_norm, normSq_apply] ring /-- Euclidean center of the circle with center `z` and radius `r` in the hyperbolic metric. -/ def center (z : ℍ) (r : ℝ) : ℍ := ⟨⟨z.re, z.im * Real.cosh r⟩, by positivity⟩ @[simp] theorem center_re (z r) : (center z r).re = z.re := rfl @[simp] theorem center_im (z r) : (center z r).im = z.im * Real.cosh r := rfl @[simp] theorem center_zero (z : ℍ) : center z 0 = z := ext' rfl <| by rw [center_im, Real.cosh_zero, mul_one] theorem dist_coe_center_sq (z w : ℍ) (r : ℝ) : dist (z : ℂ) (w.center r) ^ 2 = 2 * z.im * w.im * (Real.cosh (dist z w) - Real.cosh r) + (w.im * Real.sinh r) ^ 2 := by have H : 2 * z.im * w.im ≠ 0 := by positivity simp only [Complex.dist_eq, Complex.sq_norm, normSq_apply, coe_re, coe_im, center_re, center_im, cosh_dist', mul_div_cancel₀ _ H, sub_sq z.im, mul_pow, Real.cosh_sq, sub_re, sub_im, mul_sub, ← sq] ring theorem dist_coe_center (z w : ℍ) (r : ℝ) : dist (z : ℂ) (w.center r) = √(2 * z.im * w.im * (Real.cosh (dist z w) - Real.cosh r) + (w.im * Real.sinh r) ^ 2) := by rw [← sqrt_sq dist_nonneg, dist_coe_center_sq] theorem cmp_dist_eq_cmp_dist_coe_center (z w : ℍ) (r : ℝ) : cmp (dist z w) r = cmp (dist (z : ℂ) (w.center r)) (w.im * Real.sinh r) := by letI := metricSpaceAux rcases lt_or_ge r 0 with hr₀ | hr₀ · trans Ordering.gt exacts [(hr₀.trans_le dist_nonneg).cmp_eq_gt, ((mul_neg_of_pos_of_neg w.im_pos (sinh_neg_iff.2 hr₀)).trans_le dist_nonneg).cmp_eq_gt.symm] have hr₀' : 0 ≤ w.im * Real.sinh r := by positivity have hzw₀ : 0 < 2 * z.im * w.im := by positivity simp only [← cosh_strictMonoOn.cmp_map_eq dist_nonneg hr₀, ← (pow_left_strictMonoOn₀ (M₀ := ℝ) two_ne_zero).cmp_map_eq dist_nonneg hr₀', dist_coe_center_sq] rw [← cmp_mul_pos_left hzw₀, ← cmp_sub_zero, ← mul_sub, ← cmp_add_right, zero_add] theorem dist_eq_iff_dist_coe_center_eq : dist z w = r ↔ dist (z : ℂ) (w.center r) = w.im * Real.sinh r := eq_iff_eq_of_cmp_eq_cmp (cmp_dist_eq_cmp_dist_coe_center z w r) @[simp] theorem dist_self_center (z : ℍ) (r : ℝ) : dist (z : ℂ) (z.center r) = z.im * (Real.cosh r - 1) := by rw [dist_of_re_eq (z.center_re r).symm, dist_comm, Real.dist_eq, mul_sub, mul_one] exact abs_of_nonneg (sub_nonneg.2 <| le_mul_of_one_le_right z.im_pos.le (one_le_cosh _)) @[simp] theorem dist_center_dist (z w : ℍ) : dist (z : ℂ) (w.center (dist z w)) = w.im * Real.sinh (dist z w) := dist_eq_iff_dist_coe_center_eq.1 rfl theorem dist_lt_iff_dist_coe_center_lt : dist z w < r ↔ dist (z : ℂ) (w.center r) < w.im * Real.sinh r := lt_iff_lt_of_cmp_eq_cmp (cmp_dist_eq_cmp_dist_coe_center z w r) theorem lt_dist_iff_lt_dist_coe_center : r < dist z w ↔ w.im * Real.sinh r < dist (z : ℂ) (w.center r) := lt_iff_lt_of_cmp_eq_cmp (cmp_eq_cmp_symm.1 <| cmp_dist_eq_cmp_dist_coe_center z w r) theorem dist_le_iff_dist_coe_center_le : dist z w ≤ r ↔ dist (z : ℂ) (w.center r) ≤ w.im * Real.sinh r := le_iff_le_of_cmp_eq_cmp (cmp_dist_eq_cmp_dist_coe_center z w r) theorem le_dist_iff_le_dist_coe_center : r < dist z w ↔ w.im * Real.sinh r < dist (z : ℂ) (w.center r) := lt_iff_lt_of_cmp_eq_cmp (cmp_eq_cmp_symm.1 <| cmp_dist_eq_cmp_dist_coe_center z w r) /-- For two points on the same vertical line, the distance is equal to the distance between the logarithms of their imaginary parts. -/ nonrec theorem dist_of_re_eq (h : z.re = w.re) : dist z w = dist (log z.im) (log w.im) := by have h₀ : 0 < z.im / w.im := by positivity rw [dist_eq_iff_dist_coe_center_eq, Real.dist_eq, ← abs_sinh, ← log_div z.im_ne_zero w.im_ne_zero, sinh_log h₀, dist_of_re_eq, coe_im, coe_im, center_im, cosh_abs, cosh_log h₀, inv_div] <;> [skip; exact h] nth_rw 4 [← abs_of_pos w.im_pos] simp only [← _root_.abs_mul, Real.dist_eq] congr 1 field /-- Hyperbolic distance between two points is greater than or equal to the distance between the logarithms of their imaginary parts. -/ theorem dist_log_im_le (z w : ℍ) : dist (log z.im) (log w.im) ≤ dist z w := calc dist (log z.im) (log w.im) = dist (mk ⟨0, z.im⟩ z.im_pos) (mk ⟨0, w.im⟩ w.im_pos) := Eq.symm <| dist_of_re_eq rfl _ ≤ dist z w := by simp_rw [dist_eq] dsimp only [coe_mk, mk_im] gcongr simpa [sqrt_sq_eq_abs] using Complex.abs_im_le_norm (z - w) theorem im_le_im_mul_exp_dist (z w : ℍ) : z.im ≤ w.im * Real.exp (dist z w) := by rw [← div_le_iff₀' w.im_pos, ← exp_log z.im_pos, ← exp_log w.im_pos, ← Real.exp_sub, exp_le_exp] exact (le_abs_self _).trans (dist_log_im_le z w) theorem im_div_exp_dist_le (z w : ℍ) : z.im / Real.exp (dist z w) ≤ w.im := (div_le_iff₀ (exp_pos _)).2 (im_le_im_mul_exp_dist z w) /-- An upper estimate on the complex distance between two points in terms of the hyperbolic distance and the imaginary part of one of the points. -/ theorem dist_coe_le (z w : ℍ) : dist (z : ℂ) w ≤ w.im * (Real.exp (dist z w) - 1) := calc dist (z : ℂ) w ≤ dist (z : ℂ) (w.center (dist z w)) + dist (w : ℂ) (w.center (dist z w)) := dist_triangle_right _ _ _ _ = w.im * (Real.exp (dist z w) - 1) := by rw [dist_center_dist, dist_self_center, ← mul_add, ← add_sub_assoc, Real.sinh_add_cosh] /-- An upper estimate on the complex distance between two points in terms of the hyperbolic distance and the imaginary part of one of the points. -/ theorem le_dist_coe (z w : ℍ) : w.im * (1 - Real.exp (-dist z w)) ≤ dist (z : ℂ) w := calc w.im * (1 - Real.exp (-dist z w)) = dist (z : ℂ) (w.center (dist z w)) - dist (w : ℂ) (w.center (dist z w)) := by rw [dist_center_dist, dist_self_center, ← Real.cosh_sub_sinh]; ring _ ≤ dist (z : ℂ) w := sub_le_iff_le_add.2 <| dist_triangle _ _ _ /-- The hyperbolic metric on the upper half plane. We ensure that the projection to `TopologicalSpace` is definitionally equal to the subtype topology. -/ instance : MetricSpace ℍ := metricSpaceAux.replaceTopology <| by refine le_antisymm (continuous_id_iff_le.1 ?_) ?_ · refine (@continuous_iff_continuous_dist ℍ ℍ metricSpaceAux.toPseudoMetricSpace _ _).2 ?_ have : ∀ x : ℍ × ℍ, 2 * √(x.1.im * x.2.im) ≠ 0 := fun x => by positivity -- `continuity` fails to apply `Continuous.div` apply_rules [Continuous.div, Continuous.mul, continuous_const, Continuous.arsinh, Continuous.dist, continuous_coe.comp, continuous_fst, continuous_snd, Real.continuous_sqrt.comp, continuous_im.comp] · letI : MetricSpace ℍ := metricSpaceAux refine le_of_nhds_le_nhds fun z => ?_ rw [nhds_induced] refine (nhds_basis_ball.le_basis_iff (nhds_basis_ball.comap _)).2 fun R hR => ?_ have h₁ : 1 < R / im z + 1 := lt_add_of_pos_left _ (div_pos hR z.im_pos) have h₀ : 0 < R / im z + 1 := one_pos.trans h₁ refine ⟨log (R / im z + 1), Real.log_pos h₁, ?_⟩ refine fun w hw => (dist_coe_le w z).trans_lt ?_ rwa [← lt_div_iff₀' z.im_pos, sub_lt_iff_lt_add, ← Real.lt_log_iff_exp_lt h₀] theorem im_pos_of_dist_center_le {z : ℍ} {r : ℝ} {w : ℂ} (h : dist w (center z r) ≤ z.im * Real.sinh r) : 0 < w.im := calc 0 < z.im * (Real.cosh r - Real.sinh r) := mul_pos z.im_pos (sub_pos.2 <| sinh_lt_cosh _) _ = (z.center r).im - z.im * Real.sinh r := mul_sub _ _ _ _ ≤ (z.center r).im - dist (z.center r : ℂ) w := sub_le_sub_left (by rwa [dist_comm]) _ _ ≤ w.im := sub_le_comm.1 <| (le_abs_self _).trans (abs_im_le_norm <| z.center r - w) theorem image_coe_closedBall (z : ℍ) (r : ℝ) : ((↑) : ℍ → ℂ) '' closedBall (α := ℍ) z r = closedBall ↑(z.center r) (z.im * Real.sinh r) := by ext w; constructor · rintro ⟨w, hw, rfl⟩ exact dist_le_iff_dist_coe_center_le.1 hw · intro hw lift w to ℍ using im_pos_of_dist_center_le hw exact mem_image_of_mem _ (dist_le_iff_dist_coe_center_le.2 hw) theorem image_coe_ball (z : ℍ) (r : ℝ) : ((↑) : ℍ → ℂ) '' ball (α := ℍ) z r = ball ↑(z.center r) (z.im * Real.sinh r) := by ext w; constructor · rintro ⟨w, hw, rfl⟩ exact dist_lt_iff_dist_coe_center_lt.1 hw · intro hw lift w to ℍ using im_pos_of_dist_center_le (ball_subset_closedBall hw) exact mem_image_of_mem _ (dist_lt_iff_dist_coe_center_lt.2 hw) theorem image_coe_sphere (z : ℍ) (r : ℝ) : ((↑) : ℍ → ℂ) '' sphere (α := ℍ) z r = sphere ↑(z.center r) (z.im * Real.sinh r) := by ext w; constructor · rintro ⟨w, hw, rfl⟩ exact dist_eq_iff_dist_coe_center_eq.1 hw · intro hw lift w to ℍ using im_pos_of_dist_center_le (sphere_subset_closedBall hw) exact mem_image_of_mem _ (dist_eq_iff_dist_coe_center_eq.2 hw) instance : ProperSpace ℍ := by refine ⟨fun z r => ?_⟩ rw [IsInducing.subtypeVal.isCompact_iff (f := ((↑) : ℍ → ℂ)), image_coe_closedBall] apply isCompact_closedBall theorem isometry_vertical_line (a : ℝ) : Isometry fun y => mk ⟨a, exp y⟩ (exp_pos y) := by refine Isometry.of_dist_eq fun y₁ y₂ => ?_ rw [dist_of_re_eq] exacts [congr_arg₂ _ (log_exp _) (log_exp _), rfl] theorem isometry_real_vadd (a : ℝ) : Isometry (a +ᵥ · : ℍ → ℍ) := Isometry.of_dist_eq fun y₁ y₂ => by simp only [dist_eq, coe_vadd, vadd_im, dist_add_left] theorem isometry_pos_mul (a : { x : ℝ // 0 < x }) : Isometry (a • · : ℍ → ℍ) := by refine Isometry.of_dist_eq fun y₁ y₂ => ?_ simp only [dist_eq, coe_pos_real_smul, pos_real_im]; congr 2 rw [dist_smul₀, mul_mul_mul_comm, Real.sqrt_mul (mul_self_nonneg _), Real.sqrt_mul_self_eq_abs, Real.norm_eq_abs, mul_left_comm] exact mul_div_mul_left _ _ (mt _root_.abs_eq_zero.1 a.2.ne') /-- `SL(2, ℝ)` acts on the upper half plane as an isometry. -/ instance : IsIsometricSMul SL(2, ℝ) ℍ := ⟨fun g => by have h₀ : Isometry (fun z => ModularGroup.S • z : ℍ → ℍ) := Isometry.of_dist_eq fun y₁ y₂ => by have h₁ : 0 ≤ im y₁ * im y₂ := mul_nonneg y₁.property.le y₂.property.le have h₂ : ‖(y₁ * y₂ : ℂ)‖ ≠ 0 := by simp [y₁.ne_zero, y₂.ne_zero] simp_rw [modular_S_smul, inv_neg, dist_eq, coe_mk, dist_neg_neg, dist_inv_inv₀ y₁.ne_zero y₂.ne_zero, mk_im, neg_im, inv_im, coe_im, neg_div, neg_neg, div_mul_div_comm, ← normSq_mul, Real.sqrt_div h₁, ← norm_def, mul_div (2 : ℝ)] rw [div_div_div_comm, ← norm_mul, div_self h₂, div_one] by_cases hc : g 1 0 = 0 · obtain ⟨u, v, h⟩ := exists_SL2_smul_eq_of_apply_zero_one_eq_zero g hc rw [h] exact (isometry_real_vadd v).comp (isometry_pos_mul u) · obtain ⟨u, v, w, h⟩ := exists_SL2_smul_eq_of_apply_zero_one_ne_zero g hc rw [h] exact (isometry_real_vadd w).comp (h₀.comp <| (isometry_real_vadd v).comp <| isometry_pos_mul u)⟩ end UpperHalfPlane
.lake/packages/mathlib/Mathlib/Analysis/Complex/UpperHalfPlane/Topology.lean
import Mathlib.Analysis.Complex.UpperHalfPlane.MoebiusAction import Mathlib.Analysis.Convex.Contractible import Mathlib.Analysis.LocallyConvex.WithSeminorms import Mathlib.Analysis.Complex.Convex import Mathlib.Analysis.Complex.ReImTopology import Mathlib.Topology.Homotopy.Contractible import Mathlib.Topology.OpenPartialHomeomorph /-! # Topology on the upper half plane In this file we introduce a `TopologicalSpace` structure on the upper half plane and provide various instances. -/ noncomputable section open Complex Filter Function Set TopologicalSpace Topology namespace UpperHalfPlane instance : TopologicalSpace ℍ := instTopologicalSpaceSubtype theorem isOpenEmbedding_coe : IsOpenEmbedding ((↑) : ℍ → ℂ) := IsOpen.isOpenEmbedding_subtypeVal <| isOpen_upperHalfPlaneSet theorem isEmbedding_coe : IsEmbedding ((↑) : ℍ → ℂ) := IsEmbedding.subtypeVal @[fun_prop] theorem continuous_coe : Continuous ((↑) : ℍ → ℂ) := isEmbedding_coe.continuous @[fun_prop] theorem continuous_re : Continuous re := Complex.continuous_re.comp continuous_coe @[fun_prop] theorem continuous_im : Continuous im := Complex.continuous_im.comp continuous_coe instance : SecondCountableTopology ℍ := TopologicalSpace.Subtype.secondCountableTopology _ instance : T3Space ℍ := Subtype.t3Space instance : T4Space ℍ := inferInstance instance : ContractibleSpace ℍ := (convex_halfSpace_im_gt 0).contractibleSpace ⟨I, one_pos.trans_eq I_im.symm⟩ instance : LocPathConnectedSpace ℍ := isOpenEmbedding_coe.locPathConnectedSpace instance : NoncompactSpace ℍ := by refine ⟨fun h => ?_⟩ have : IsCompact (Complex.im ⁻¹' Ioi 0) := isCompact_iff_isCompact_univ.2 h replace := this.isClosed.closure_eq rw [closure_preimage_im, closure_Ioi, Set.ext_iff] at this exact absurd ((this 0).1 (@left_mem_Ici ℝ _ 0)) (@lt_irrefl ℝ _ 0) instance : LocallyCompactSpace ℍ := isOpenEmbedding_coe.locallyCompactSpace /-- Each element of `GL(2, ℝ)` defines a continuous map `ℍ → ℍ`. -/ instance instContinuousGLSMul : ContinuousConstSMul (GL (Fin 2) ℝ) ℍ where continuous_const_smul g := by simp_rw [continuous_induced_rng (f := UpperHalfPlane.coe), Function.comp_def, UpperHalfPlane.coe_smul, UpperHalfPlane.σ] refine .comp ?_ ?_ · split_ifs exacts [continuous_id, continuous_conj] · refine .div ?_ ?_ (fun x ↦ denom_ne_zero g x) <;> exact (continuous_const.mul continuous_coe).add continuous_const section strips /-- The vertical strip of width `A` and height `B`, defined by elements whose real part has absolute value less than or equal to `A` and imaginary part is at least `B`. -/ def verticalStrip (A B : ℝ) := {z : ℍ | |z.re| ≤ A ∧ B ≤ z.im} theorem mem_verticalStrip_iff (A B : ℝ) (z : ℍ) : z ∈ verticalStrip A B ↔ |z.re| ≤ A ∧ B ≤ z.im := Iff.rfl @[gcongr] lemma verticalStrip_mono {A B A' B' : ℝ} (hA : A ≤ A') (hB : B' ≤ B) : verticalStrip A B ⊆ verticalStrip A' B' := by rintro z ⟨hzre, hzim⟩ exact ⟨hzre.trans hA, hB.trans hzim⟩ lemma verticalStrip_mono_left {A A'} (h : A ≤ A') (B) : verticalStrip A B ⊆ verticalStrip A' B := verticalStrip_mono h le_rfl lemma verticalStrip_anti_right (A) {B B'} (h : B' ≤ B) : verticalStrip A B ⊆ verticalStrip A B' := verticalStrip_mono le_rfl h lemma subset_verticalStrip_of_isCompact {K : Set ℍ} (hK : IsCompact K) : ∃ A B : ℝ, 0 < B ∧ K ⊆ verticalStrip A B := by rcases K.eq_empty_or_nonempty with rfl | hne · exact ⟨1, 1, Real.zero_lt_one, empty_subset _⟩ obtain ⟨u, _, hu⟩ := hK.exists_isMaxOn hne (_root_.continuous_abs.comp continuous_re).continuousOn obtain ⟨v, _, hv⟩ := hK.exists_isMinOn hne continuous_im.continuousOn exact ⟨|re u|, im v, v.im_pos, fun k hk ↦ ⟨isMaxOn_iff.mp hu _ hk, isMinOn_iff.mp hv _ hk⟩⟩ theorem ModularGroup_T_zpow_mem_verticalStrip (z : ℍ) {N : ℕ} (hn : 0 < N) : ∃ n : ℤ, ModularGroup.T ^ (N * n) • z ∈ verticalStrip N z.im := by let n := Int.floor (z.re/N) use -n rw [modular_T_zpow_smul z (N * -n)] refine ⟨?_, (by simp only [mul_neg, Int.cast_neg, Int.cast_mul, Int.cast_natCast, vadd_im, le_refl])⟩ have h : (N * (-n : ℝ) +ᵥ z).re = -N * Int.floor (z.re / N) + z.re := by simp only [n, mul_neg, vadd_re, neg_mul] norm_cast at * rw [h, add_comm] simp only [neg_mul, Int.cast_neg, Int.cast_mul, Int.cast_natCast] have hnn : (0 : ℝ) < (N : ℝ) := by norm_cast at * have h2 : z.re + -(N * n) = z.re - n * N := by ring rw [h2, abs_eq_self.2 (Int.sub_floor_div_mul_nonneg (z.re : ℝ) hnn)] apply (Int.sub_floor_div_mul_lt (z.re : ℝ) hnn).le end strips section ofComplex /-- A section `ℂ → ℍ` of the natural inclusion map, bundled as an `OpenPartialHomeomorph`. -/ def ofComplex : OpenPartialHomeomorph ℂ ℍ := (isOpenEmbedding_coe.toOpenPartialHomeomorph _).symm /-- Extend a function on `ℍ` arbitrarily to a function on all of `ℂ`. -/ scoped notation "↑ₕ" f => f ∘ ofComplex @[simp] lemma ofComplex_apply (z : ℍ) : ofComplex (z : ℂ) = z := IsOpenEmbedding.toOpenPartialHomeomorph_left_inv .. lemma ofComplex_apply_eq_ite (w : ℂ) : ofComplex w = if hw : 0 < w.im then ⟨w, hw⟩ else Classical.choice inferInstance := by split_ifs with hw · exact ofComplex_apply ⟨w, hw⟩ · change (Function.invFunOn UpperHalfPlane.coe Set.univ w) = _ simp only [invFunOn, dite_eq_right_iff, mem_univ, true_and] rintro ⟨a, rfl⟩ exact (a.prop.not_ge (by simpa using hw)).elim lemma ofComplex_apply_of_im_pos {z : ℂ} (hz : 0 < z.im) : ofComplex z = ⟨z, hz⟩ := by simpa only [coe_mk_subtype] using ofComplex_apply ⟨z, hz⟩ lemma ofComplex_apply_of_im_nonpos {w : ℂ} (hw : w.im ≤ 0) : ofComplex w = Classical.choice inferInstance := by simp [ofComplex_apply_eq_ite w, hw] lemma ofComplex_apply_eq_of_im_nonpos {w w' : ℂ} (hw : w.im ≤ 0) (hw' : w'.im ≤ 0) : ofComplex w = ofComplex w' := by simp [ofComplex_apply_of_im_nonpos, hw, hw'] lemma comp_ofComplex (f : ℍ → ℂ) (z : ℍ) : (↑ₕ f) z = f z := congrArg _ <| ofComplex_apply z lemma comp_ofComplex_of_im_pos (f : ℍ → ℂ) (z : ℂ) (hz : 0 < z.im) : (↑ₕ f) z = f ⟨z, hz⟩ := congrArg _ <| ofComplex_apply ⟨z, hz⟩ lemma comp_ofComplex_of_im_le_zero (f : ℍ → ℂ) (z z' : ℂ) (hz : z.im ≤ 0) (hz' : z'.im ≤ 0) : (↑ₕ f) z = (↑ₕ f) z' := by simp [ofComplex_apply_of_im_nonpos, hz, hz'] lemma eventuallyEq_coe_comp_ofComplex {z : ℂ} (hz : 0 < z.im) : UpperHalfPlane.coe ∘ ofComplex =ᶠ[𝓝 z] id := by filter_upwards [isOpen_upperHalfPlaneSet.mem_nhds hz] with x hx simp only [Function.comp_apply, ofComplex_apply_of_im_pos hx, id_eq, coe_mk_subtype] end ofComplex end UpperHalfPlane
.lake/packages/mathlib/Mathlib/Analysis/Complex/UpperHalfPlane/Basic.lean
import Mathlib.Analysis.Complex.Basic /-! # The upper half plane This file defines `UpperHalfPlane` to be the upper half plane in `ℂ`. We define the notation `ℍ` for the upper half plane available in the locale `UpperHalfPlane` so as not to conflict with the quaternions. -/ noncomputable section /-- The open upper half plane, denoted as `ℍ` within the `UpperHalfPlane` namespace -/ def UpperHalfPlane := { point : ℂ // 0 < point.im } @[inherit_doc] scoped[UpperHalfPlane] notation "ℍ" => UpperHalfPlane open UpperHalfPlane namespace UpperHalfPlane /-- Canonical embedding of the upper half-plane into `ℂ`. -/ @[coe] protected def coe (z : ℍ) : ℂ := z.1 instance : CoeOut ℍ ℂ := ⟨UpperHalfPlane.coe⟩ instance : Inhabited ℍ := ⟨⟨Complex.I, by simp⟩⟩ @[ext] theorem ext {a b : ℍ} (h : (a : ℂ) = b) : a = b := Subtype.eq h @[simp, norm_cast] theorem ext_iff' {a b : ℍ} : (a : ℂ) = b ↔ a = b := UpperHalfPlane.ext_iff.symm instance canLift : CanLift ℂ ℍ ((↑) : ℍ → ℂ) fun z => 0 < z.im := Subtype.canLift fun (z : ℂ) => 0 < z.im /-- Imaginary part -/ def im (z : ℍ) := (z : ℂ).im /-- Real part -/ def re (z : ℍ) := (z : ℂ).re /-- Extensionality lemma in terms of `UpperHalfPlane.re` and `UpperHalfPlane.im`. -/ theorem ext' {a b : ℍ} (hre : a.re = b.re) (him : a.im = b.im) : a = b := ext <| Complex.ext hre him /-- Constructor for `UpperHalfPlane`. It is useful if `⟨z, h⟩` makes Lean use a wrong typeclass instance. -/ def mk (z : ℂ) (h : 0 < z.im) : ℍ := ⟨z, h⟩ @[simp] theorem coe_im (z : ℍ) : (z : ℂ).im = z.im := rfl @[simp] theorem coe_re (z : ℍ) : (z : ℂ).re = z.re := rfl @[simp] theorem mk_re (z : ℂ) (h : 0 < z.im) : (mk z h).re = z.re := rfl @[simp] theorem mk_im (z : ℂ) (h : 0 < z.im) : (mk z h).im = z.im := rfl @[simp] theorem coe_mk (z : ℂ) (h : 0 < z.im) : (mk z h : ℂ) = z := rfl @[simp] lemma coe_mk_subtype {z : ℂ} (hz : 0 < z.im) : UpperHalfPlane.coe ⟨z, hz⟩ = z := by rfl @[simp] theorem mk_coe (z : ℍ) (h : 0 < (z : ℂ).im := z.2) : mk z h = z := rfl theorem re_add_im (z : ℍ) : (z.re + z.im * Complex.I : ℂ) = z := Complex.re_add_im z theorem im_pos (z : ℍ) : 0 < z.im := z.2 theorem im_ne_zero (z : ℍ) : z.im ≠ 0 := z.im_pos.ne' theorem ne_zero (z : ℍ) : (z : ℂ) ≠ 0 := mt (congr_arg Complex.im) z.im_ne_zero /-- Define I := √-1 as an element on the upper half plane. -/ def I : ℍ := ⟨Complex.I, by simp⟩ @[simp] lemma I_im : I.im = 1 := rfl @[simp] lemma I_re : I.re = 0 := rfl @[simp, norm_cast] lemma coe_I : I = Complex.I := rfl end UpperHalfPlane namespace Mathlib.Meta.Positivity open Lean Meta Qq /-- Extension for the `positivity` tactic: `UpperHalfPlane.im`. -/ @[positivity UpperHalfPlane.im _] def evalUpperHalfPlaneIm : PositivityExt where eval {u α} _zα _pα e := do match u, α, e with | 0, ~q(ℝ), ~q(UpperHalfPlane.im $a) => assertInstancesCommute pure (.positive q(@UpperHalfPlane.im_pos $a)) | _, _, _ => throwError "not UpperHalfPlane.im" /-- Extension for the `positivity` tactic: `UpperHalfPlane.coe`. -/ @[positivity UpperHalfPlane.coe _] def evalUpperHalfPlaneCoe : PositivityExt where eval {u α} _zα _pα e := do match u, α, e with | 0, ~q(ℂ), ~q(UpperHalfPlane.coe $a) => assertInstancesCommute pure (.nonzero q(@UpperHalfPlane.ne_zero $a)) | _, _, _ => throwError "not UpperHalfPlane.coe" end Mathlib.Meta.Positivity namespace UpperHalfPlane theorem normSq_pos (z : ℍ) : 0 < Complex.normSq (z : ℂ) := by rw [Complex.normSq_pos]; exact z.ne_zero theorem normSq_ne_zero (z : ℍ) : Complex.normSq (z : ℂ) ≠ 0 := (normSq_pos z).ne' theorem im_inv_neg_coe_pos (z : ℍ) : 0 < (-z : ℂ)⁻¹.im := by simpa [neg_div] using div_pos z.property (normSq_pos z) lemma ne_nat (z : ℍ) : ∀ n : ℕ, z.1 ≠ n := by intro n have h1 := z.2 aesop lemma ne_int (z : ℍ) : ∀ n : ℤ, z.1 ≠ n := by intro n have h1 := z.2 aesop section PosRealAction instance posRealAction : MulAction { x : ℝ // 0 < x } ℍ where smul x z := mk ((x : ℝ) • (z : ℂ)) <| by simpa using mul_pos x.2 z.2 one_smul _ := Subtype.ext <| one_smul _ _ mul_smul x y z := Subtype.ext <| mul_smul (x : ℝ) y (z : ℂ) variable (x : { x : ℝ // 0 < x }) (z : ℍ) @[simp] theorem coe_pos_real_smul : ↑(x • z) = (x : ℝ) • (z : ℂ) := rfl @[simp] theorem pos_real_im : (x • z).im = x * z.im := Complex.smul_im _ _ @[simp] theorem pos_real_re : (x • z).re = x * z.re := Complex.smul_re _ _ end PosRealAction section RealAddAction instance : AddAction ℝ ℍ where vadd x z := mk (x + z) <| by simpa using z.im_pos zero_vadd _ := Subtype.ext <| by simp [HVAdd.hVAdd] add_vadd x y z := Subtype.ext <| by simp [HVAdd.hVAdd, add_assoc] variable (x : ℝ) (z : ℍ) @[simp] theorem coe_vadd : ↑(x +ᵥ z) = (x + z : ℂ) := rfl @[simp] theorem vadd_re : (x +ᵥ z).re = x + z.re := rfl @[simp] theorem vadd_im : (x +ᵥ z).im = z.im := zero_add _ end RealAddAction section upperHalfPlaneSet /-- The upper half plane as a subset of `ℂ`. This is convenient for taking derivatives of functions on the upper half plane. -/ abbrev upperHalfPlaneSet := {z : ℂ | 0 < z.im} local notation "ℍₒ" => upperHalfPlaneSet lemma isOpen_upperHalfPlaneSet : IsOpen ℍₒ := isOpen_lt continuous_const Complex.continuous_im end upperHalfPlaneSet end UpperHalfPlane
.lake/packages/mathlib/Mathlib/Analysis/Complex/UpperHalfPlane/FunctionsBoundedAtInfty.lean
import Mathlib.Algebra.Module.Submodule.Basic import Mathlib.Analysis.Complex.UpperHalfPlane.Topology import Mathlib.Order.Filter.ZeroAndBoundedAtFilter /-! # Bounded at infinity For complex-valued functions on the upper half plane, this file defines the filter `UpperHalfPlane.atImInfty` required for defining when functions are bounded at infinity and zero at infinity. Both of which are relevant for defining modular forms. -/ open Complex Filter open scoped Topology UpperHalfPlane noncomputable section namespace UpperHalfPlane /-- Filter for approaching `i∞`. -/ def atImInfty := Filter.atTop.comap UpperHalfPlane.im theorem atImInfty_basis : atImInfty.HasBasis (fun _ => True) fun i : ℝ => im ⁻¹' Set.Ici i := Filter.HasBasis.comap UpperHalfPlane.im Filter.atTop_basis theorem atImInfty_mem (S : Set ℍ) : S ∈ atImInfty ↔ ∃ A : ℝ, ∀ z : ℍ, A ≤ im z → z ∈ S := by simp only [atImInfty_basis.mem_iff, true_and]; rfl /-- A function `f : ℍ → α` is bounded at infinity if it is bounded along `atImInfty`. -/ def IsBoundedAtImInfty {α : Type*} [Norm α] (f : ℍ → α) : Prop := BoundedAtFilter atImInfty f /-- A function `f : ℍ → α` is zero at infinity it is zero along `atImInfty`. -/ def IsZeroAtImInfty {α : Type*} [Zero α] [TopologicalSpace α] (f : ℍ → α) : Prop := ZeroAtFilter atImInfty f theorem zero_form_isBoundedAtImInfty {α : Type*} [NormedField α] : IsBoundedAtImInfty (0 : ℍ → α) := const_boundedAtFilter atImInfty (0 : α) /-- Module of functions that are zero at infinity. -/ def zeroAtImInftySubmodule (α : Type*) [NormedField α] : Submodule α (ℍ → α) := zeroAtFilterSubmodule _ atImInfty /-- Subalgebra of functions that are bounded at infinity. -/ def boundedAtImInftySubalgebra (α : Type*) [NormedField α] : Subalgebra α (ℍ → α) := boundedFilterSubalgebra _ atImInfty theorem isBoundedAtImInfty_iff {α : Type*} [Norm α] {f : ℍ → α} : IsBoundedAtImInfty f ↔ ∃ M A : ℝ, ∀ z : ℍ, A ≤ im z → ‖f z‖ ≤ M := by simp [IsBoundedAtImInfty, BoundedAtFilter, Asymptotics.isBigO_iff, Filter.Eventually, atImInfty_mem] theorem isZeroAtImInfty_iff {α : Type*} [SeminormedAddGroup α] {f : ℍ → α} : IsZeroAtImInfty f ↔ ∀ ε : ℝ, 0 < ε → ∃ A : ℝ, ∀ z : ℍ, A ≤ im z → ‖f z‖ ≤ ε := (atImInfty_basis.tendsto_iff Metric.nhds_basis_closedBall).trans <| by simp theorem IsZeroAtImInfty.isBoundedAtImInfty {α : Type*} [SeminormedAddGroup α] {f : ℍ → α} (hf : IsZeroAtImInfty f) : IsBoundedAtImInfty f := hf.boundedAtFilter lemma tendsto_comap_im_ofComplex : Tendsto ofComplex (comap Complex.im atTop) atImInfty := by simp only [atImInfty, tendsto_comap_iff, Function.comp_def] refine tendsto_comap.congr' ?_ filter_upwards [preimage_mem_comap (Ioi_mem_atTop 0)] with z hz simp only [ofComplex_apply_of_im_pos hz, ← UpperHalfPlane.coe_im, coe_mk_subtype] lemma tendsto_coe_atImInfty : Tendsto UpperHalfPlane.coe atImInfty (comap Complex.im atTop) := by simpa only [atImInfty, tendsto_comap_iff, Function.comp_def, funext UpperHalfPlane.coe_im] using tendsto_comap lemma tendsto_smul_atImInfty {g : GL (Fin 2) ℝ} (hg : g 1 0 = 0) : Tendsto (fun τ ↦ g • τ) atImInfty atImInfty := by suffices Tendsto (fun τ ↦ |g 0 0 / g 1 1| * τ.im) atImInfty atTop by simpa [atImInfty, Function.comp_def, im_smul, num, denom, hg, abs_div, abs_mul, abs_of_pos (UpperHalfPlane.im_pos _), mul_div_right_comm] apply tendsto_comap.const_mul_atTop simpa [Matrix.det_fin_two, hg] using g.det_ne_zero end UpperHalfPlane
.lake/packages/mathlib/Mathlib/Analysis/Complex/UpperHalfPlane/MoebiusAction.lean
import Mathlib.Analysis.Complex.UpperHalfPlane.Basic import Mathlib.Data.Fintype.Parity import Mathlib.LinearAlgebra.Matrix.GeneralLinearGroup.Defs /-! # Group action on the upper half-plane We equip the upper half-plane with the structure of a `GL (Fin 2) ℝ` action by fractional linear transformations (composing with complex conjugation when needed to extend the action from the positive-determinant subgroup, so that `!![-1, 0; 0, 1]` acts as `z ↦ -conj z`.) -/ noncomputable section open Matrix Matrix.SpecialLinearGroup UpperHalfPlane open scoped MatrixGroups ComplexConjugate namespace UpperHalfPlane /-- The coercion first into an element of `GL(2, ℝ)⁺`, then `GL(2, ℝ)` and finally a 2 × 2 matrix. This notation is scoped in namespace `UpperHalfPlane`. -/ scoped notation:1024 "↑ₘ" A:1024 => (((A : GL(2, ℝ)⁺) : GL (Fin 2) ℝ) : Matrix (Fin 2) (Fin 2) _) instance instCoeFun : CoeFun GL(2, ℝ)⁺ fun _ => Fin 2 → Fin 2 → ℝ where coe A := ↑ₘA /-- The coercion into an element of `GL(2, R)` and finally a 2 × 2 matrix over `R`. This is similar to `↑ₘ`, but without positivity requirements, and allows the user to specify the ring `R`, which can be useful to help Lean elaborate correctly. This notation is scoped in namespace `UpperHalfPlane`. -/ scoped notation:1024 "↑ₘ[" R "]" A:1024 => ((A : GL (Fin 2) R) : Matrix (Fin 2) (Fin 2) R) /-- Numerator of the formula for a fractional linear transformation -/ def num (g : GL (Fin 2) ℝ) (z : ℂ) : ℂ := g 0 0 * z + g 0 1 /-- Denominator of the formula for a fractional linear transformation -/ def denom (g : GL (Fin 2) ℝ) (z : ℂ) : ℂ := g 1 0 * z + g 1 1 @[simp] lemma num_neg (g : GL (Fin 2) ℝ) (z : ℂ) : num (-g) z = -(num g z) := by simp [num]; ring @[simp] lemma denom_neg (g : GL (Fin 2) ℝ) (z : ℂ) : denom (-g) z = -(denom g z) := by simp [denom]; ring theorem linear_ne_zero_of_im {cd : Fin 2 → ℝ} {z : ℂ} (hz : z.im ≠ 0) (h : cd ≠ 0) : (cd 0 : ℂ) * z + cd 1 ≠ 0 := by contrapose! h have : cd 0 = 0 := by -- we will need this twice apply_fun Complex.im at h simpa only [Complex.add_im, Complex.mul_im, Complex.ofReal_im, zero_mul, add_zero, Complex.zero_im, mul_eq_zero, hz, or_false] using h simp only [this, zero_mul, Complex.ofReal_zero, zero_add, Complex.ofReal_eq_zero] at h ext i fin_cases i <;> assumption theorem linear_ne_zero {cd : Fin 2 → ℝ} (τ : ℍ) (h : cd ≠ 0) : (cd 0 : ℂ) * τ + cd 1 ≠ 0 := linear_ne_zero_of_im τ.im_ne_zero h theorem denom_ne_zero_of_im (g : GL (Fin 2) ℝ) {z : ℂ} (hz : z.im ≠ 0) : denom g z ≠ 0 := by refine linear_ne_zero_of_im hz fun H ↦ g.det.ne_zero ?_ simp [Matrix.det_fin_two, H] theorem denom_ne_zero (g : GL (Fin 2) ℝ) (z : ℍ) : denom g z ≠ 0 := denom_ne_zero_of_im g z.im_ne_zero theorem normSq_denom_pos (g : GL (Fin 2) ℝ) {z : ℂ} (hz : z.im ≠ 0) : 0 < Complex.normSq (denom g z) := Complex.normSq_pos.mpr (denom_ne_zero_of_im g hz) theorem normSq_denom_ne_zero (g : GL (Fin 2) ℝ) {z : ℂ} (hz : z.im ≠ 0) : Complex.normSq (denom g z) ≠ 0 := ne_of_gt (normSq_denom_pos g hz) lemma denom_cocycle (g h : GL (Fin 2) ℝ) {z : ℂ} (hz : z.im ≠ 0) : denom (g * h) z = denom g (num h z / denom h z) * denom h z := by change _ = (_ * (_ / _) + _) * _ field_simp [denom_ne_zero_of_im h hz] simp only [denom, Units.val_mul, mul_apply, Fin.sum_univ_succ, Finset.univ_unique, Fin.default_eq_zero, Finset.sum_singleton, Fin.succ_zero_eq_one, Complex.ofReal_add, Complex.ofReal_mul, num] ring lemma moebius_im (g : GL (Fin 2) ℝ) (z : ℂ) : (num g z / denom g z).im = g.det.val * z.im / Complex.normSq (denom g z) := by simp only [num, denom, Complex.div_im, Complex.add_im, Complex.mul_im, Complex.ofReal_re, Complex.ofReal_im, zero_mul, add_zero, Complex.add_re, Complex.mul_re, sub_zero, ← sub_div, GeneralLinearGroup.val_det_apply, g.1.det_fin_two] ring /-- Automorphism of `ℂ`: the identity if `0 < det g` and conjugation otherwise. -/ noncomputable def σ (g : GL (Fin 2) ℝ) : ℂ →+* ℂ := if 0 < g.det.val then RingHom.id ℂ else starRingEnd ℂ lemma σ_conj (g : GL (Fin 2) ℝ) (z : ℂ) : σ g (conj z) = conj (σ g z) := by simp only [σ] split_ifs <;> simp @[simp] lemma σ_ofReal (g : GL (Fin 2) ℝ) (y : ℝ) : σ g y = y := by simp only [σ] split_ifs <;> simp lemma σ_num (g h : GL (Fin 2) ℝ) (z : ℂ) : σ g (num h z) = num h (σ g z) := by simp [num] lemma σ_denom (g h : GL (Fin 2) ℝ) (z : ℂ) : σ g (denom h z) = denom h (σ g z) := by simp [denom] @[simp] lemma σ_neg (g : GL (Fin 2) ℝ) : σ (-g) = σ g := by simp [σ, det_neg] @[simp] lemma σ_sq (g : GL (Fin 2) ℝ) (z : ℂ) : σ g (σ g z) = z := by simp only [σ] split_ifs <;> simp lemma σ_im_ne_zero {g z} : (σ g z).im ≠ 0 ↔ z.im ≠ 0 := by simp only [σ] split_ifs <;> simp lemma σ_mul (g g' : GL (Fin 2) ℝ) (z : ℂ) : σ (g * g') z = σ g (σ g' z) := by simp only [σ, map_mul, Units.val_mul] rcases g.det_ne_zero.lt_or_gt with (h | h) <;> rcases g'.det_ne_zero.lt_or_gt with (h' | h') · simp [mul_pos_of_neg_of_neg h h', h.not_gt, h'.not_gt] · simp [(mul_neg_of_neg_of_pos h h').not_gt, h.not_gt, h'] · simp [(mul_neg_of_pos_of_neg h h').not_gt, h, h'.not_gt] · simp [mul_pos h h', h, h'] lemma σ_mul_comm (g h : GL (Fin 2) ℝ) (z : ℂ) : σ g (σ h z) = σ h (σ g z) := by simp only [σ] split_ifs <;> simp @[simp] lemma norm_σ (g : GL (Fin 2) ℝ) (z : ℂ) : ‖σ g z‖ = ‖z‖ := by simp only [σ] split_ifs <;> simp /-- Fractional linear transformation, also known as the Moebius transformation -/ def smulAux' (g : GL (Fin 2) ℝ) (z : ℂ) : ℂ := σ g (num g z / denom g z) lemma smulAux'_im (g : GL (Fin 2) ℝ) (z : ℂ) : (smulAux' g z).im = |g.det.val| * z.im / Complex.normSq (denom g z) := by simp only [smulAux', σ] split_ifs with h <;> [rw [abs_of_pos h]; rw [abs_of_nonpos (not_lt.mp h)]] <;> simpa only [starRingAut_apply, Complex.star_def, Complex.conj_im, neg_mul, neg_div, neg_inj] using moebius_im g z /-- Fractional linear transformation, also known as the Moebius transformation -/ def smulAux (g : GL (Fin 2) ℝ) (z : ℍ) : ℍ := mk (smulAux' g z) <| by rw [smulAux'_im] exact div_pos (mul_pos (abs_pos.mpr g.det.ne_zero) z.im_pos) (normSq_denom_pos _ z.im_ne_zero) lemma denom_cocycle' (g h : GL (Fin 2) ℝ) (z : ℍ) : denom (g * h) z = σ h (denom g (smulAux h z)) * denom h z := by simp only [smulAux, smulAux', coe_mk, map_div₀, σ_num, σ_denom, σ_sq] change _ = (_ * (_ / _) + _) * _ field_simp [denom_ne_zero h z] simp only [denom, Units.val_mul, mul_apply, Fin.sum_univ_succ, Finset.univ_unique, Fin.default_eq_zero, Finset.sum_singleton, Fin.succ_zero_eq_one, Complex.ofReal_add, Complex.ofReal_mul, num] ring theorem mul_smul' (g h : GL (Fin 2) ℝ) (z : ℍ) : smulAux (g * h) z = smulAux g (smulAux h z) := by ext : 1 simp only [smulAux, coe_mk, smulAux', map_div₀, σ_num, σ_denom, σ_mul] generalize hu : σ g (σ h z) = u have hu : u.im ≠ 0 := by simpa only [← hu, σ_im_ne_zero] using z.im_ne_zero have hu' : (num h u / denom h u).im ≠ 0 := by rw [moebius_im] exact div_ne_zero (mul_ne_zero h.det_ne_zero hu) (normSq_denom_ne_zero _ hu) rw [div_eq_div_iff (denom_ne_zero_of_im _ hu) (denom_ne_zero_of_im _ hu'), denom, mul_div, div_add' _ _ _ (denom_ne_zero_of_im _ hu), mul_div] conv_rhs => rw [num] rw [mul_div, div_add' _ _ _ (denom_ne_zero_of_im _ hu), div_mul_eq_mul_div] congr 1 simp only [num, denom, Units.val_mul, mul_apply, Fin.sum_univ_succ, Finset.univ_unique, Fin.default_eq_zero, Finset.sum_singleton, Fin.succ_zero_eq_one, Complex.ofReal_add, Complex.ofReal_mul] ring /-- Action of `GL (Fin 2) ℝ` on the upper half-plane, with `GL(2, ℝ)⁺` acting by Moebius transformations in the usual way, extended to all of `GL (Fin 2) ℝ` using complex conjugation. -/ instance glAction : MulAction (GL (Fin 2) ℝ) ℍ where smul := smulAux one_smul z := by change smulAux 1 z = z simp [smulAux, smulAux', num, denom, σ] mul_smul := mul_smul' lemma coe_smul (g : GL (Fin 2) ℝ) (z : ℍ) : ↑(g • z) = σ g (num g z / denom g z) := rfl lemma coe_smul_of_det_pos {g : GL (Fin 2) ℝ} (hg : 0 < g.det.val) (z : ℍ) : ↑(g • z) = num g z / denom g z := by change smulAux' g z = _ rw [smulAux', σ, if_pos hg, RingHom.id_apply, num, denom] lemma denom_cocycle_σ (g h : GL (Fin 2) ℝ) (z : ℍ) : denom (g * h) z = σ h (denom g ↑(h • z)) * denom h z := denom_cocycle' g h z lemma glPos_smul_def {g : GL (Fin 2) ℝ} (hg : 0 < g.det.val) (z : ℍ) : g • z = mk (num g z / denom g z) (coe_smul_of_det_pos hg z ▸ (g • z).property) := by ext; simp [coe_smul_of_det_pos hg] variable (g : GL (Fin 2) ℝ) (z : ℍ) theorem re_smul : (g • z).re = (num g z / denom g z).re := by change (smulAux' g z).re = _ simp +contextual [smulAux', σ, DFunLike.ite_apply, apply_ite, Complex.div_re] theorem im_smul : (g • z).im = |(num g z / denom g z).im| := by change (smulAux' g z).im = _ simp only [smulAux', σ, DFunLike.ite_apply, RingHom.id_apply, apply_ite, moebius_im, Complex.conj_im, ← neg_div, ← neg_mul, abs_div, abs_mul, abs_of_pos (show 0 < (z : ℂ).im from z.coe_im ▸ z.im_pos), abs_of_nonneg <| Complex.normSq_nonneg _] split_ifs with h <;> [rw [abs_of_pos h]; rw [abs_of_nonpos (not_lt.mp h)]] lemma im_smul_eq_div_normSq : (g • z).im = |g.det.val| * z.im / Complex.normSq (denom g z) := smulAux'_im g z theorem c_mul_im_sq_le_normSq_denom : (g 1 0 * z.im) ^ 2 ≤ Complex.normSq (denom g z) := by set c := g 1 0 set d := g 1 1 calc (c * z.im) ^ 2 ≤ (c * z.im) ^ 2 + (c * z.re + d) ^ 2 := by nlinarith _ = Complex.normSq (denom g z) := by dsimp [c, d, denom, Complex.normSq]; ring @[simp] theorem neg_smul : -g • z = g • z := by ext1 simp [coe_smul] lemma denom_one : denom 1 z = 1 := by simp [denom] section SLAction noncomputable instance SLAction {R : Type*} [CommRing R] [Algebra R ℝ] : MulAction SL(2, R) ℍ := MulAction.compHom ℍ <| SpecialLinearGroup.mapGL ℝ theorem coe_specialLinearGroup_apply {R : Type*} [CommRing R] [Algebra R ℝ] (g : SL(2, R)) (z : ℍ) : ↑(g • z) = (((algebraMap R ℝ (g 0 0) : ℂ) * z + (algebraMap R ℝ (g 0 1) : ℂ)) / ((algebraMap R ℝ (g 1 0) : ℂ) * z + (algebraMap R ℝ (g 1 1) : ℂ))) := by rw [MulAction.compHom_smul_def, coe_smul_of_det_pos (by simp)] rfl theorem specialLinearGroup_apply {R : Type*} [CommRing R] [Algebra R ℝ] (g : SL(2, R)) (z : ℍ) : g • z = mk (((algebraMap R ℝ (g 0 0) : ℂ) * z + (algebraMap R ℝ (g 0 1) : ℂ)) / ((algebraMap R ℝ (g 1 0) : ℂ) * z + (algebraMap R ℝ (g 1 1) : ℂ))) (coe_specialLinearGroup_apply g z ▸ (g • z).property) := by ext; simp [coe_specialLinearGroup_apply] /- these next few lemmas are *not* flagged `@simp` because of the constructors on the RHS; instead we use the versions with coercions to `ℂ` as simp lemmas instead. -/ theorem modular_S_smul (z : ℍ) : ModularGroup.S • z = mk (-z : ℂ)⁻¹ z.im_inv_neg_coe_pos := by rw [specialLinearGroup_apply] simp [ModularGroup.S, neg_div, inv_neg] theorem modular_T_zpow_smul (z : ℍ) (n : ℤ) : ModularGroup.T ^ n • z = (n : ℝ) +ᵥ z := by rw [UpperHalfPlane.ext_iff, coe_vadd, add_comm, coe_specialLinearGroup_apply] simp [ModularGroup.coe_T_zpow, of_apply, cons_val_zero, Complex.ofReal_one, one_mul, cons_val_one, zero_mul, zero_add, div_one] theorem modular_T_smul (z : ℍ) : ModularGroup.T • z = (1 : ℝ) +ᵥ z := by simpa only [zpow_one, Int.cast_one] using modular_T_zpow_smul z 1 theorem exists_SL2_smul_eq_of_apply_zero_one_eq_zero (g : SL(2, ℝ)) (hc : g 1 0 = 0) : ∃ (u : { x : ℝ // 0 < x }) (v : ℝ), (g • · : ℍ → ℍ) = (v +ᵥ ·) ∘ (u • ·) := by obtain ⟨a, b, ha, rfl⟩ := g.fin_two_exists_eq_mk_of_apply_zero_one_eq_zero hc refine ⟨⟨_, mul_self_pos.mpr ha⟩, b * a, ?_⟩ ext1 ⟨z, hz⟩; ext1 suffices ↑a * z * a + b * a = b * a + a * a * z by simpa [specialLinearGroup_apply, add_mul] ring theorem exists_SL2_smul_eq_of_apply_zero_one_ne_zero (g : SL(2, ℝ)) (hc : g 1 0 ≠ 0) : ∃ (u : { x : ℝ // 0 < x }) (v w : ℝ), (g • · : ℍ → ℍ) = (w +ᵥ ·) ∘ (ModularGroup.S • · : ℍ → ℍ) ∘ (v +ᵥ · : ℍ → ℍ) ∘ (u • · : ℍ → ℍ) := by have h_denom (z : ℍ) := denom_ne_zero g z induction g using Matrix.SpecialLinearGroup.fin_two_induction with | _ a b c d h => ?_ replace hc : c ≠ 0 := by simpa using hc refine ⟨⟨_, mul_self_pos.mpr hc⟩, c * d, a / c, ?_⟩ ext1 ⟨z, hz⟩; ext1 suffices (↑a * z + b) / (↑c * z + d) = a / c - (c * d + ↑c * ↑c * z)⁻¹ by simpa [modular_S_smul, coe_specialLinearGroup_apply] replace hc : (c : ℂ) ≠ 0 := by norm_cast replace h_denom : ↑c * z + d ≠ 0 := by simpa using h_denom ⟨z, hz⟩ replace h : (a * d - b * c : ℂ) = (1 : ℂ) := by norm_cast grind end SLAction end UpperHalfPlane namespace ModularGroup -- results specific to `SL(2, ℤ)` -- TODO: Move these elsewhere, maybe somewhere in the algebra or number theory hierarchies? section ModularScalarTowers /-- Canonical embedding of `SL(2, ℤ)` into `GL(2, ℝ)⁺`. -/ @[coe] def coe (g : SL(2, ℤ)) : GL(2, ℝ)⁺ := ((g : SL(2, ℝ)) : GL(2, ℝ)⁺) @[simp] lemma coe_inj (a b : SL(2, ℤ)) : coe a = coe b ↔ a = b := by refine ⟨fun h ↦ a.ext b fun i j ↦ ?_, congr_arg _⟩ simp only [Subtype.ext_iff, GeneralLinearGroup.ext_iff] at h simpa [coe] using h i j instance : Coe SL(2, ℤ) GL(2, ℝ)⁺ := ⟨coe⟩ /-- Canonical embedding of `SL(2, ℤ)` into `GL(2, ℝ)⁺`, bundled as a group hom. -/ def coeHom : SL(2, ℤ) →* GL(2, ℝ)⁺ := toGLPos.comp <| map <| Int.castRingHom _ @[simp] lemma coeHom_apply (g : SL(2, ℤ)) : coeHom g = coe g := rfl @[simp] theorem coe_apply_complex {g : SL(2, ℤ)} {i j : Fin 2} : (Units.val <| Subtype.val <| coe g) i j = (Subtype.val g i j : ℂ) := rfl @[simp] theorem det_coe {g : SL(2, ℤ)} : det (Units.val <| Subtype.val <| coe g) = 1 := by simp only [SpecialLinearGroup.coe_GLPos_coe_GL_coe_matrix, SpecialLinearGroup.det_coe, coe] lemma coe_one : coe 1 = 1 := by simp only [coe, map_one] instance SLOnGLPos : SMul SL(2, ℤ) GL(2, ℝ)⁺ := ⟨fun s g => s * g⟩ theorem SLOnGLPos_smul_apply (s : SL(2, ℤ)) (g : GL(2, ℝ)⁺) (z : ℍ) : (s • g) • z = ((s : GL(2, ℝ)⁺) * g) • z := rfl instance SL_to_GL_tower : IsScalarTower SL(2, ℤ) GL(2, ℝ)⁺ ℍ where smul_assoc s g z := by simp only [SLOnGLPos_smul_apply] apply mul_smul' end ModularScalarTowers section SLModularAction variable (g : SL(2, ℤ)) (z : ℍ) @[simp] theorem sl_moeb : g • z = (g : GL (Fin 2) ℝ) • z := rfl @[simp high] theorem SL_neg_smul : -g • z = g • z := by rw [sl_moeb, ← z.neg_smul] congr 1 with i j simp [toGL] theorem im_smul_eq_div_normSq : (g • z).im = z.im / Complex.normSq (denom g z) := by simpa using z.im_smul_eq_div_normSq g theorem denom_apply : denom g z = g 1 0 * z + g 1 1 := rfl @[simp] lemma denom_S : denom S z = z := by simp [S, denom_apply] end SLModularAction end ModularGroup
.lake/packages/mathlib/Mathlib/Analysis/Complex/UpperHalfPlane/Manifold.lean
import Mathlib.Analysis.Complex.CauchyIntegral import Mathlib.Analysis.Complex.UpperHalfPlane.Topology import Mathlib.Geometry.Manifold.Algebra.Structures import Mathlib.Geometry.Manifold.ContMDiff.Atlas import Mathlib.Geometry.Manifold.MFDeriv.FDeriv /-! # Manifold structure on the upper half plane. In this file we define the complex manifold structure on the upper half-plane. -/ open Filter open scoped Manifold ContDiff MatrixGroups variable {n : WithTop ℕ∞} namespace UpperHalfPlane noncomputable instance : ChartedSpace ℂ ℍ := UpperHalfPlane.isOpenEmbedding_coe.singletonChartedSpace instance : IsManifold 𝓘(ℂ) ω ℍ := UpperHalfPlane.isOpenEmbedding_coe.isManifold_singleton /-- The inclusion map `ℍ → ℂ` is a map of `C^n` manifolds. -/ theorem contMDiff_coe : ContMDiff 𝓘(ℂ) 𝓘(ℂ) n ((↑) : ℍ → ℂ) := fun _ => contMDiffAt_extChartAt /-- The inclusion map `ℍ → ℂ` is a differentiable map of manifolds. -/ theorem mdifferentiable_coe : MDifferentiable 𝓘(ℂ) 𝓘(ℂ) ((↑) : ℍ → ℂ) := contMDiff_coe.mdifferentiable le_top lemma contMDiffAt_ofComplex {z : ℂ} (hz : 0 < z.im) : ContMDiffAt 𝓘(ℂ) 𝓘(ℂ) n ofComplex z := by rw [contMDiffAt_iff] constructor · -- continuity at z rw [ContinuousAt, nhds_induced, tendsto_comap_iff] refine Tendsto.congr' (eventuallyEq_coe_comp_ofComplex hz).symm ?_ simpa [ofComplex_apply_of_im_pos hz] using tendsto_id · -- smoothness in local chart simpa using contDiffAt_id.congr_of_eventuallyEq (eventuallyEq_coe_comp_ofComplex hz) lemma mdifferentiableAt_ofComplex {z : ℂ} (hz : 0 < z.im) : MDifferentiableAt 𝓘(ℂ) 𝓘(ℂ) ofComplex z := (contMDiffAt_ofComplex hz).mdifferentiableAt le_top lemma contMDiffAt_iff {f : ℍ → ℂ} {τ : ℍ} : ContMDiffAt 𝓘(ℂ) 𝓘(ℂ) n f τ ↔ ContDiffAt ℂ n (f ∘ ofComplex) τ := by rw [← contMDiffAt_iff_contDiffAt] refine ⟨fun hf ↦ ?_, fun hf ↦ ?_⟩ · exact (ofComplex_apply τ ▸ hf).comp _ (contMDiffAt_ofComplex τ.im_pos) · simpa only [Function.comp_def, ofComplex_apply] using hf.comp τ (contMDiff_coe τ) lemma mdifferentiableAt_iff {f : ℍ → ℂ} {τ : ℍ} : MDifferentiableAt 𝓘(ℂ) 𝓘(ℂ) f τ ↔ DifferentiableAt ℂ (f ∘ ofComplex) ↑τ := by rw [← mdifferentiableAt_iff_differentiableAt] refine ⟨fun hf ↦ ?_, fun hf ↦ ?_⟩ · exact (ofComplex_apply τ ▸ hf).comp _ (mdifferentiableAt_ofComplex τ.im_pos) · simpa only [Function.comp_def, ofComplex_apply] using hf.comp τ (mdifferentiable_coe τ) lemma mdifferentiable_iff {f : ℍ → ℂ} : MDifferentiable 𝓘(ℂ) 𝓘(ℂ) f ↔ DifferentiableOn ℂ (f ∘ ofComplex) {z | 0 < z.im} := ⟨fun h z hz ↦ (mdifferentiableAt_iff.mp (h ⟨z, hz⟩)).differentiableWithinAt, fun h ⟨z, hz⟩ ↦ mdifferentiableAt_iff.mpr <| (h z hz).differentiableAt <| isOpen_upperHalfPlaneSet.mem_nhds hz⟩ lemma contMDiff_num (g : GL (Fin 2) ℝ) : ContMDiff 𝓘(ℂ) 𝓘(ℂ) n (fun τ : ℍ ↦ num g τ) := (contMDiff_const.smul contMDiff_coe).add contMDiff_const lemma contMDiff_denom (g : GL (Fin 2) ℝ) : ContMDiff 𝓘(ℂ) 𝓘(ℂ) n (fun τ : ℍ ↦ denom g τ) := (contMDiff_const.smul contMDiff_coe).add contMDiff_const lemma contMDiff_denom_zpow (g : GL (Fin 2) ℝ) (k : ℤ) : ContMDiff 𝓘(ℂ) 𝓘(ℂ) n (denom g · ^ k : ℍ → ℂ) := fun τ ↦ by have : AnalyticAt ℂ (· ^ k) (denom g τ) := (differentiableOn_zpow k _ (by tauto)).analyticOnNhd isOpen_compl_singleton _ (denom_ne_zero g τ) exact this.contDiffAt.contMDiffAt.comp τ (contMDiff_denom g τ) lemma contMDiff_inv_denom (g : GL (Fin 2) ℝ) : ContMDiff 𝓘(ℂ) 𝓘(ℂ) n (fun τ : ℍ ↦ (denom g τ)⁻¹) := by simpa using contMDiff_denom_zpow g (-1) /-- Each element of `GL(2, ℝ)⁺` defines a map of `C ^ n` manifolds `ℍ → ℍ`. -/ lemma contMDiff_smul {g : GL (Fin 2) ℝ} (hg : 0 < g.det.val) : ContMDiff 𝓘(ℂ) 𝓘(ℂ) n (fun τ : ℍ ↦ g • τ) := fun τ ↦ by refine contMDiffAt_iff_target.mpr ⟨(continuous_const_smul g).continuousAt, ?_⟩ simpa [glPos_smul_def hg] using (contMDiff_num g τ).mul (contMDiff_inv_denom g τ) lemma mdifferentiable_num (g : GL (Fin 2) ℝ) : MDifferentiable 𝓘(ℂ) 𝓘(ℂ) (fun τ : ℍ ↦ num g τ) := (contMDiff_num g).mdifferentiable le_top lemma mdifferentiable_denom (g : GL (Fin 2) ℝ) : MDifferentiable 𝓘(ℂ) 𝓘(ℂ) (fun τ : ℍ ↦ denom g τ) := (contMDiff_denom g).mdifferentiable le_top lemma mdifferentiable_denom_zpow (g : GL (Fin 2) ℝ) (k : ℤ) : MDifferentiable 𝓘(ℂ) 𝓘(ℂ) (denom g · ^ k : ℍ → ℂ) := (contMDiff_denom_zpow g k).mdifferentiable le_top lemma mdifferentiable_inv_denom (g : GL (Fin 2) ℝ) : MDifferentiable 𝓘(ℂ) 𝓘(ℂ) (fun τ : ℍ ↦ (denom g τ)⁻¹) := (contMDiff_inv_denom g).mdifferentiable le_top /-- Each element of `GL(2, ℝ)⁺` defines a complex-differentiable map `ℍ → ℍ`. -/ lemma mdifferentiable_smul {g : GL (Fin 2) ℝ} (hg : 0 < g.det.val) : MDifferentiable 𝓘(ℂ) 𝓘(ℂ) (fun τ : ℍ ↦ g • τ) := (contMDiff_smul hg).mdifferentiable le_top end UpperHalfPlane
.lake/packages/mathlib/Mathlib/Analysis/Complex/Polynomial/GaussLucas.lean
import Mathlib.Analysis.Complex.Polynomial.Basic /-! # Gauss-Lucas Theorem In this file we prove Gauss-Lucas Theorem: the roots of the derivative of a nonconstant complex polynomial are included in the convex hull of the roots of the polynomial. -/ open scoped BigOperators Polynomial ComplexConjugate namespace Polynomial /-- Given a polynomial `P` of positive degree and a root `z` of its derivative, `derivRootWeight P z w` gives the weight of a root `w` of `P` in a convex combination that is equal to `z`. -/ noncomputable def derivRootWeight (P : ℂ[X]) (z w : ℂ) : ℝ := if P.eval z = 0 then (Pi.single z 1 : ℂ → ℝ) w else P.rootMultiplicity w / ‖z - w‖ ^ 2 theorem derivRootWeight_nonneg (P : ℂ[X]) (z w : ℂ) : 0 ≤ derivRootWeight P z w := by simp only [derivRootWeight, Pi.single, Function.update_apply] split_ifs <;> first | positivity | simp variable {P : ℂ[X]} {z : ℂ} /-- The sum of the weights `derivRootWeight P z w` of all the roots `w` of `P` is positive, provided that `P` is not a constant polynomial. -/ theorem sum_derivRootWeight_pos (hP : 0 < degree P) (z : ℂ) : 0 < ∑ w ∈ P.roots.toFinset, derivRootWeight P z w := by have hP₀ : P ≠ 0 := by rintro rfl; simp at hP by_cases hPz : P.eval z = 0 · simp [derivRootWeight, hPz, hP₀] · simp only [derivRootWeight, if_neg hPz] apply Finset.sum_pos · intro w hw apply div_pos (by simp_all) suffices z ≠ w by simpa [sq_pos_iff, sub_eq_zero] rintro rfl simp_all · rw [Multiset.toFinset_nonempty, ← P.map_id] apply P.roots_ne_zero_of_splits _ (IsAlgClosed.splits _) rwa [← pos_iff_ne_zero, natDegree_pos_iff_degree_pos] /-- *Gauss-Lucas Theorem*: if $P$ is a nonconstant polynomial with complex coefficients, then all zeros of $P'$ belong to the convex hull of the set of zeros of $P$. This version provides explicit formulas for the coefficients of the convex combination. See also `rootSet_derivative_subset_convexHull_rootSet` below. -/ theorem eq_centerMass_of_eval_derivative_eq_zero (hP : 0 < P.degree) (hz : P.derivative.eval z = 0) : z = P.roots.toFinset.centerMass (P.derivRootWeight z) id := by have hP₀ : P ≠ 0 := by rintro rfl; simp at hP set weight : ℂ → ℝ := P.derivRootWeight z set s := P.roots.toFinset suffices ∑ x ∈ s, weight x • (z - x) = 0 by calc z = s.centerMass weight fun _ ↦ z := by rw [Finset.centerMass, ← Finset.sum_smul, inv_smul_smul₀] exact (sum_derivRootWeight_pos hP z).ne' _ = s.centerMass weight (z - ·) + s.centerMass weight id := by simp only [Finset.centerMass, ← smul_add, ← Finset.sum_add_distrib, id, sub_add_cancel] _ = s.centerMass weight id := by simp only [add_eq_right, Finset.centerMass, this, smul_zero] by_cases hzP : P.eval z = 0 · simp only [weight, derivRootWeight, if_pos hzP] rw [Finset.sum_eq_single z] <;> simp_all calc ∑ x ∈ s, weight x • (z - x) = conj (∑ x ∈ s, P.rootMultiplicity x • (1 / (z - x))) := by simp only [map_sum, weight, derivRootWeight, if_neg hzP] refine Finset.sum_congr rfl fun x hx ↦ ?_ have : z - x ≠ 0 := by rw [sub_ne_zero] rintro rfl simp_all [s] simp [← Complex.conj_mul', field] _ = conj (P.roots.map fun x ↦ 1 / (z - x)).sum := by simp only [Finset.sum_multiset_map_count, P.count_roots, s] _ = 0 := by rw [← eval_derivative_div_eval_of_ne_zero_of_splits (IsAlgClosed.splits _) hzP] simp [hz] /-- *Gauss-Lucas Theorem*: if $P$ is a nonconstant polynomial with complex coefficients, then all zeros of $P'$ belong to the convex hull of the set of zeros of $P$. See also `eq_centerMass_of_eval_derivative_eq_zero` for a version that provides explicit coefficients of the convex combination. -/ theorem rootSet_derivative_subset_convexHull_rootSet (h₀ : 0 < P.degree) : P.derivative.rootSet ℂ ⊆ convexHull ℝ (P.rootSet ℂ) := by intro z hz rw [mem_rootSet, coe_aeval_eq_eval] at hz rw [eq_centerMass_of_eval_derivative_eq_zero h₀ hz.2] apply Finset.centerMass_mem_convexHull · simp [derivRootWeight_nonneg] · apply sum_derivRootWeight_pos h₀ · simp [mem_rootSet] end Polynomial
.lake/packages/mathlib/Mathlib/Analysis/Complex/Polynomial/Basic.lean
import Mathlib.Analysis.Calculus.Deriv.Polynomial import Mathlib.Analysis.Complex.Liouville import Mathlib.FieldTheory.PolynomialGaloisGroup import Mathlib.LinearAlgebra.Complex.FiniteDimensional import Mathlib.Topology.Algebra.Polynomial /-! # The fundamental theorem of algebra This file proves that every nonconstant complex polynomial has a root using Liouville's theorem. As a consequence, the complex numbers are algebraically closed. We also provide some specific results about the Galois groups of ℚ-polynomials with specific numbers of non-real roots. We also show that an irreducible real polynomial has degree at most two. -/ open Polynomial Bornology Complex open scoped ComplexConjugate namespace Complex /-- **Fundamental theorem of algebra**: every nonconstant complex polynomial has a root. -/ theorem exists_root {f : ℂ[X]} (hf : 0 < degree f) : ∃ z : ℂ, IsRoot f z := by by_contra! hf' /- Since `f` has no roots, `f⁻¹` is differentiable. And since `f` is a polynomial, it tends to infinity at infinity, thus `f⁻¹` tends to zero at infinity. By Liouville's theorem, `f⁻¹ = 0`. -/ have (z : ℂ) : (f.eval z)⁻¹ = 0 := (f.differentiable.inv hf').apply_eq_of_tendsto_cocompact z <| Metric.cobounded_eq_cocompact (α := ℂ) ▸ (Filter.tendsto_inv₀_cobounded.comp <| by simpa only [tendsto_norm_atTop_iff_cobounded] using f.tendsto_norm_atTop hf tendsto_norm_cobounded_atTop) -- Thus `f = 0`, contradicting the fact that `0 < degree f`. obtain rfl : f = C 0 := Polynomial.funext fun z ↦ inv_injective <| by simp [this] simp at hf instance isAlgClosed : IsAlgClosed ℂ := IsAlgClosed.of_exists_root _ fun _p _ hp => Complex.exists_root <| degree_pos_of_irreducible hp end Complex /-- An algebraic extension of ℝ is isomorphic to either ℝ or ℂ as an ℝ-algebra. -/ theorem Real.nonempty_algEquiv_or (F : Type*) [Field F] [Algebra ℝ F] [Algebra.IsAlgebraic ℝ F] : Nonempty (F ≃ₐ[ℝ] ℝ) ∨ Nonempty (F ≃ₐ[ℝ] ℂ) := IsAlgClosed.nonempty_algEquiv_or_of_finrank_eq_two F Complex.finrank_real_complex namespace Polynomial.Gal section Rationals theorem splits_ℚ_ℂ {p : ℚ[X]} : Fact (p.Splits (algebraMap ℚ ℂ)) := ⟨IsAlgClosed.splits_codomain p⟩ attribute [local instance] splits_ℚ_ℂ attribute [local ext] Complex.ext /-- The number of complex roots equals the number of real roots plus the number of roots not fixed by complex conjugation (i.e. with some imaginary component). -/ theorem card_complex_roots_eq_card_real_add_card_not_gal_inv (p : ℚ[X]) : (p.rootSet ℂ).toFinset.card = (p.rootSet ℝ).toFinset.card + (galActionHom p ℂ (restrict p ℂ (AlgEquiv.restrictScalars ℚ Complex.conjAe))).support.card := by by_cases hp : p = 0 · haveI : IsEmpty (p.rootSet ℂ) := by rw [hp, rootSet_zero]; infer_instance simp_rw [(galActionHom p ℂ _).support.eq_empty_of_isEmpty, hp, rootSet_zero, Set.toFinset_empty, Finset.card_empty] have inj : Function.Injective (IsScalarTower.toAlgHom ℚ ℝ ℂ) := (algebraMap ℝ ℂ).injective rw [← Finset.card_image_of_injective _ Subtype.coe_injective, ← Finset.card_image_of_injective _ inj] let a : Finset ℂ := ?_ on_goal 1 => let b : Finset ℂ := ?_ on_goal 1 => let c : Finset ℂ := ?_ change a.card = b.card + c.card have ha : ∀ z : ℂ, z ∈ a ↔ aeval z p = 0 := by intro z; rw [Set.mem_toFinset, mem_rootSet_of_ne hp] have hb : ∀ z : ℂ, z ∈ b ↔ aeval z p = 0 ∧ z.im = 0 := by intro z simp_rw [b, Finset.mem_image, Set.mem_toFinset, mem_rootSet_of_ne hp] constructor · rintro ⟨w, hw, rfl⟩ exact ⟨by rw [aeval_algHom_apply, hw, map_zero], rfl⟩ · rintro ⟨hz1, hz2⟩ have key : IsScalarTower.toAlgHom ℚ ℝ ℂ z.re = z := by ext · rfl · rw [hz2]; rfl exact ⟨z.re, inj (by rwa [← aeval_algHom_apply, key, map_zero]), key⟩ have hc0 : ∀ w : p.rootSet ℂ, galActionHom p ℂ (restrict p ℂ (Complex.conjAe.restrictScalars ℚ)) w = w ↔ w.val.im = 0 := by intro w rw [Subtype.ext_iff, galActionHom_restrict] exact Complex.conj_eq_iff_im have hc : ∀ z : ℂ, z ∈ c ↔ aeval z p = 0 ∧ z.im ≠ 0 := by intro z simp_rw [c, Finset.mem_image] constructor · rintro ⟨w, hw, rfl⟩ exact ⟨(mem_rootSet.mp w.2).2, mt (hc0 w).mpr (Equiv.Perm.mem_support.mp hw)⟩ · rintro ⟨hz1, hz2⟩ exact ⟨⟨z, mem_rootSet.mpr ⟨hp, hz1⟩⟩, Equiv.Perm.mem_support.mpr (mt (hc0 _).mp hz2), rfl⟩ rw [← Finset.card_union_of_disjoint] · apply congr_arg Finset.card simp_rw [Finset.ext_iff, Finset.mem_union, ha, hb, hc] tauto · rw [Finset.disjoint_left] intro z rw [hb, hc] tauto /-- An irreducible polynomial of prime degree with two non-real roots has full Galois group. -/ theorem galActionHom_bijective_of_prime_degree {p : ℚ[X]} (p_irr : Irreducible p) (p_deg : p.natDegree.Prime) (p_roots : Fintype.card (p.rootSet ℂ) = Fintype.card (p.rootSet ℝ) + 2) : Function.Bijective (galActionHom p ℂ) := by classical have h1 : Fintype.card (p.rootSet ℂ) = p.natDegree := by simp_rw [rootSet_def, Finset.coe_sort_coe, Fintype.card_coe] rw [Multiset.toFinset_card_of_nodup, ← natDegree_eq_card_roots] · exact IsAlgClosed.splits_codomain p · exact nodup_roots ((separable_map (algebraMap ℚ ℂ)).mpr p_irr.separable) let conj' := restrict p ℂ (Complex.conjAe.restrictScalars ℚ) refine ⟨galActionHom_injective p ℂ, fun x => (congr_arg (x ∈ ·) (show (galActionHom p ℂ).range = ⊤ from ?_)).mpr (Subgroup.mem_top x)⟩ apply Equiv.Perm.subgroup_eq_top_of_swap_mem · rwa [h1] · rw [h1] simpa only [Fintype.card_eq_nat_card, Nat.card_congr (MonoidHom.ofInjective (galActionHom_injective p ℂ)).toEquiv.symm] using prime_degree_dvd_card p_irr p_deg · exact ⟨conj', rfl⟩ · rw [← Equiv.Perm.card_support_eq_two] apply Nat.add_left_cancel rw [← p_roots, ← Set.toFinset_card (rootSet p ℝ), ← Set.toFinset_card (rootSet p ℂ)] exact (card_complex_roots_eq_card_real_add_card_not_gal_inv p).symm /-- An irreducible polynomial of prime degree with 1-3 non-real roots has full Galois group. -/ theorem galActionHom_bijective_of_prime_degree' {p : ℚ[X]} (p_irr : Irreducible p) (p_deg : p.natDegree.Prime) (p_roots1 : Fintype.card (p.rootSet ℝ) + 1 ≤ Fintype.card (p.rootSet ℂ)) (p_roots2 : Fintype.card (p.rootSet ℂ) ≤ Fintype.card (p.rootSet ℝ) + 3) : Function.Bijective (galActionHom p ℂ) := by apply galActionHom_bijective_of_prime_degree p_irr p_deg let n := (galActionHom p ℂ (restrict p ℂ (Complex.conjAe.restrictScalars ℚ))).support.card have hn : 2 ∣ n := Equiv.Perm.two_dvd_card_support (by rw [← MonoidHom.map_pow, ← MonoidHom.map_pow, show AlgEquiv.restrictScalars ℚ Complex.conjAe ^ 2 = 1 from AlgEquiv.ext Complex.conj_conj, MonoidHom.map_one, MonoidHom.map_one]) have key := card_complex_roots_eq_card_real_add_card_not_gal_inv p simp_rw [Set.toFinset_card] at key omega end Rationals end Polynomial.Gal lemma Polynomial.mul_star_dvd_of_aeval_eq_zero_im_ne_zero (p : ℝ[X]) {z : ℂ} (h0 : aeval z p = 0) (hz : z.im ≠ 0) : (X - C ((starRingEnd ℂ) z)) * (X - C z) ∣ map (algebraMap ℝ ℂ) p := by apply IsCoprime.mul_dvd · exact isCoprime_X_sub_C_of_isUnit_sub <| .mk0 _ <| sub_ne_zero.2 <| mt conj_eq_iff_im.1 hz · simpa [dvd_iff_isRoot, aeval_conj] · simpa [dvd_iff_isRoot] /-- If `z` is a non-real complex root of a real polynomial, then `p` is divisible by a quadratic polynomial. -/ lemma Polynomial.quadratic_dvd_of_aeval_eq_zero_im_ne_zero (p : ℝ[X]) {z : ℂ} (h0 : aeval z p = 0) (hz : z.im ≠ 0) : X ^ 2 - C (2 * z.re) * X + C (‖z‖ ^ 2) ∣ p := by rw [← map_dvd_map' (algebraMap ℝ ℂ)] convert p.mul_star_dvd_of_aeval_eq_zero_im_ne_zero h0 hz calc map (algebraMap ℝ ℂ) (X ^ 2 - C (2 * z.re) * X + C (‖z‖ ^ 2)) _ = X ^ 2 - C (↑(2 * z.re) : ℂ) * X + C (‖z‖ ^ 2 : ℂ) := by simp _ = (X - C (conj z)) * (X - C z) := by rw [← add_conj, map_add, ← mul_conj', map_mul] ring /-- An irreducible real polynomial has natural degree at most two. -/ lemma Irreducible.natDegree_le_two {p : ℝ[X]} (hp : Irreducible p) : natDegree p ≤ 2 := by obtain ⟨z, hz⟩ : ∃ z : ℂ, aeval z p = 0 := IsAlgClosed.exists_aeval_eq_zero _ p (degree_pos_of_irreducible hp).ne' rw [← finrank_real_complex] convert minpoly.natDegree_le z using 1 · rw [← minpoly.eq_of_irreducible hp hz, natDegree_mul hp.ne_zero (by simpa using hp.ne_zero), natDegree_C, add_zero] infer_instance /-- An irreducible real polynomial has degree at most two. -/ lemma Irreducible.degree_le_two {p : ℝ[X]} (hp : Irreducible p) : degree p ≤ 2 := natDegree_le_iff_degree_le.1 hp.natDegree_le_two
.lake/packages/mathlib/Mathlib/Analysis/Complex/Polynomial/UnitTrinomial.lean
import Mathlib.Algebra.Polynomial.UnitTrinomial import Mathlib.Analysis.Complex.Polynomial.Basic /-! # Irreducibility of unit trinomials ## TODO Develop more theory (e.g., it suffices to check that `aeval z p ≠ 0` for `z = 0` and `z` a root of unity). -/ namespace Polynomial.IsUnitTrinomial variable {p : ℤ[X]} /-- A unit trinomial is irreducible if it has no complex roots in common with its mirror. -/ theorem irreducible_of_coprime' (hp : IsUnitTrinomial p) (h : ∀ z : ℂ, ¬(aeval z p = 0 ∧ aeval z (mirror p) = 0)) : Irreducible p := by refine hp.irreducible_of_coprime fun q hq hq' => ?_ suffices ¬0 < q.natDegree by rcases hq with ⟨p, rfl⟩ replace hp := hp.leadingCoeff_isUnit rw [leadingCoeff_mul] at hp replace hp := isUnit_of_mul_isUnit_left hp rw [not_lt, Nat.le_zero] at this rwa [eq_C_of_natDegree_eq_zero this, isUnit_C, ← this] intro hq'' rw [natDegree_pos_iff_degree_pos] at hq'' rw [← degree_map_eq_of_injective (algebraMap ℤ ℂ).injective_int] at hq'' obtain ⟨z, hz⟩ := Complex.exists_root hq'' rw [IsRoot, eval_map, ← aeval_def] at hz refine h z ⟨?_, ?_⟩ · obtain ⟨g', hg'⟩ := hq rw [hg', aeval_mul, hz, zero_mul] · obtain ⟨g', hg'⟩ := hq' rw [hg', aeval_mul, hz, zero_mul] end Polynomial.IsUnitTrinomial
.lake/packages/mathlib/Mathlib/Analysis/Asymptotics/Theta.lean
import Mathlib.Analysis.Asymptotics.Lemmas import Mathlib.Analysis.Normed.Module.Basic /-! # Asymptotic equivalence up to a constant In this file we define `Asymptotics.IsTheta l f g` (notation: `f =Θ[l] g`) as `f =O[l] g ∧ g =O[l] f`, then prove basic properties of this equivalence relation. -/ open Filter open Topology namespace Asymptotics variable {α : Type*} {β : Type*} {E : Type*} {F : Type*} {G : Type*} {E' : Type*} {F' : Type*} {G' : Type*} {E'' : Type*} {F'' : Type*} {G'' : Type*} {R : Type*} {R' : Type*} {𝕜 : Type*} {𝕜' : Type*} variable [Norm E] [Norm F] [Norm G] variable [SeminormedAddCommGroup E'] [SeminormedAddCommGroup F'] [SeminormedAddCommGroup G'] [NormedAddCommGroup E''] [NormedAddCommGroup F''] [NormedAddCommGroup G''] [SeminormedRing R] [SeminormedRing R'] variable [NormedField 𝕜] [NormedField 𝕜'] variable {c c' c₁ c₂ : ℝ} {f : α → E} {g : α → F} {k : α → G} variable {f' : α → E'} {g' : α → F'} {k' : α → G'} variable {f'' : α → E''} {g'' : α → F''} variable {l l' : Filter α} /-- We say that `f` is `Θ(g)` along a filter `l` (notation: `f =Θ[l] g`) if `f =O[l] g` and `g =O[l] f`. -/ def IsTheta (l : Filter α) (f : α → E) (g : α → F) : Prop := IsBigO l f g ∧ IsBigO l g f @[inherit_doc] notation:100 f " =Θ[" l "] " g:100 => IsTheta l f g theorem IsBigO.antisymm (h₁ : f =O[l] g) (h₂ : g =O[l] f) : f =Θ[l] g := ⟨h₁, h₂⟩ lemma IsTheta.isBigO (h : f =Θ[l] g) : f =O[l] g := h.1 lemma IsTheta.isBigO_symm (h : f =Θ[l] g) : g =O[l] f := h.2 @[refl] theorem isTheta_refl (f : α → E) (l : Filter α) : f =Θ[l] f := ⟨isBigO_refl _ _, isBigO_refl _ _⟩ theorem isTheta_rfl : f =Θ[l] f := isTheta_refl _ _ @[symm] nonrec theorem IsTheta.symm (h : f =Θ[l] g) : g =Θ[l] f := h.symm theorem isTheta_comm : f =Θ[l] g ↔ g =Θ[l] f := ⟨fun h ↦ h.symm, fun h ↦ h.symm⟩ @[trans] theorem IsTheta.trans {f : α → E} {g : α → F'} {k : α → G} (h₁ : f =Θ[l] g) (h₂ : g =Θ[l] k) : f =Θ[l] k := ⟨h₁.1.trans h₂.1, h₂.2.trans h₁.2⟩ instance : Trans (α := α → E) (β := α → F') (γ := α → G) (IsTheta l) (IsTheta l) (IsTheta l) := ⟨IsTheta.trans⟩ @[trans] theorem IsBigO.trans_isTheta {f : α → E} {g : α → F'} {k : α → G} (h₁ : f =O[l] g) (h₂ : g =Θ[l] k) : f =O[l] k := h₁.trans h₂.1 instance : Trans (α := α → E) (β := α → F') (γ := α → G) (IsBigO l) (IsTheta l) (IsBigO l) := ⟨IsBigO.trans_isTheta⟩ @[trans] theorem IsTheta.trans_isBigO {f : α → E} {g : α → F'} {k : α → G} (h₁ : f =Θ[l] g) (h₂ : g =O[l] k) : f =O[l] k := h₁.1.trans h₂ instance : Trans (α := α → E) (β := α → F') (γ := α → G) (IsTheta l) (IsBigO l) (IsBigO l) := ⟨IsTheta.trans_isBigO⟩ @[trans] theorem IsLittleO.trans_isTheta {f : α → E} {g : α → F} {k : α → G'} (h₁ : f =o[l] g) (h₂ : g =Θ[l] k) : f =o[l] k := h₁.trans_isBigO h₂.1 instance : Trans (α := α → E) (β := α → F') (γ := α → G') (IsLittleO l) (IsTheta l) (IsLittleO l) := ⟨IsLittleO.trans_isTheta⟩ @[trans] theorem IsTheta.trans_isLittleO {f : α → E} {g : α → F'} {k : α → G} (h₁ : f =Θ[l] g) (h₂ : g =o[l] k) : f =o[l] k := h₁.1.trans_isLittleO h₂ instance : Trans (α := α → E) (β := α → F') (γ := α → G) (IsTheta l) (IsLittleO l) (IsLittleO l) := ⟨IsTheta.trans_isLittleO⟩ @[trans] theorem IsTheta.trans_eventuallyEq {f : α → E} {g₁ g₂ : α → F} (h : f =Θ[l] g₁) (hg : g₁ =ᶠ[l] g₂) : f =Θ[l] g₂ := ⟨h.1.trans_eventuallyEq hg, hg.symm.trans_isBigO h.2⟩ instance : Trans (α := α → E) (β := α → F) (γ := α → F) (IsTheta l) (EventuallyEq l) (IsTheta l) := ⟨IsTheta.trans_eventuallyEq⟩ @[trans] theorem _root_.Filter.EventuallyEq.trans_isTheta {f₁ f₂ : α → E} {g : α → F} (hf : f₁ =ᶠ[l] f₂) (h : f₂ =Θ[l] g) : f₁ =Θ[l] g := ⟨hf.trans_isBigO h.1, h.2.trans_eventuallyEq hf.symm⟩ instance : Trans (α := α → E) (β := α → E) (γ := α → F) (EventuallyEq l) (IsTheta l) (IsTheta l) := ⟨EventuallyEq.trans_isTheta⟩ lemma _root_.Filter.EventuallyEq.isTheta {f g : α → E} (h : f =ᶠ[l] g) : f =Θ[l] g := h.trans_isTheta isTheta_rfl @[simp] theorem isTheta_bot : f =Θ[⊥] g := by simp [IsTheta] @[simp] theorem isTheta_norm_left : (fun x ↦ ‖f' x‖) =Θ[l] g ↔ f' =Θ[l] g := by simp [IsTheta] @[simp] theorem isTheta_norm_right : (f =Θ[l] fun x ↦ ‖g' x‖) ↔ f =Θ[l] g' := by simp [IsTheta] alias ⟨IsTheta.of_norm_left, IsTheta.norm_left⟩ := isTheta_norm_left alias ⟨IsTheta.of_norm_right, IsTheta.norm_right⟩ := isTheta_norm_right theorem IsTheta.of_norm_eventuallyEq_norm (h : (fun x ↦ ‖f x‖) =ᶠ[l] fun x ↦ ‖g x‖) : f =Θ[l] g := ⟨.of_bound' h.le, .of_bound' h.symm.le⟩ theorem IsTheta.of_norm_eventuallyEq {g : α → ℝ} (h : (fun x ↦ ‖f' x‖) =ᶠ[l] g) : f' =Θ[l] g := of_norm_eventuallyEq_norm <| h.mono fun x hx ↦ by simp only [← hx, norm_norm] theorem IsTheta.isLittleO_congr_left (h : f' =Θ[l] g') : f' =o[l] k ↔ g' =o[l] k := ⟨h.symm.trans_isLittleO, h.trans_isLittleO⟩ theorem IsTheta.isLittleO_congr_right (h : g' =Θ[l] k') : f =o[l] g' ↔ f =o[l] k' := ⟨fun H ↦ H.trans_isTheta h, fun H ↦ H.trans_isTheta h.symm⟩ theorem IsTheta.isBigO_congr_left (h : f' =Θ[l] g') : f' =O[l] k ↔ g' =O[l] k := ⟨h.symm.trans_isBigO, h.trans_isBigO⟩ theorem IsTheta.isBigO_congr_right (h : g' =Θ[l] k') : f =O[l] g' ↔ f =O[l] k' := ⟨fun H ↦ H.trans_isTheta h, fun H ↦ H.trans_isTheta h.symm⟩ lemma IsTheta.isTheta_congr_left (h : f' =Θ[l] g') : f' =Θ[l] k ↔ g' =Θ[l] k := h.isBigO_congr_left.and h.isBigO_congr_right lemma IsTheta.isTheta_congr_right (h : f' =Θ[l] g') : k =Θ[l] f' ↔ k =Θ[l] g' := h.isBigO_congr_right.and h.isBigO_congr_left theorem IsTheta.mono (h : f =Θ[l] g) (hl : l' ≤ l) : f =Θ[l'] g := ⟨h.1.mono hl, h.2.mono hl⟩ theorem IsTheta.sup (h : f' =Θ[l] g') (h' : f' =Θ[l'] g') : f' =Θ[l ⊔ l'] g' := ⟨h.1.sup h'.1, h.2.sup h'.2⟩ @[simp] theorem isTheta_sup : f' =Θ[l ⊔ l'] g' ↔ f' =Θ[l] g' ∧ f' =Θ[l'] g' := ⟨fun h ↦ ⟨h.mono le_sup_left, h.mono le_sup_right⟩, fun h ↦ h.1.sup h.2⟩ theorem IsTheta.eq_zero_iff (h : f'' =Θ[l] g'') : ∀ᶠ x in l, f'' x = 0 ↔ g'' x = 0 := h.1.eq_zero_imp.mp <| h.2.eq_zero_imp.mono fun _ ↦ Iff.intro theorem IsTheta.tendsto_zero_iff (h : f'' =Θ[l] g'') : Tendsto f'' l (𝓝 0) ↔ Tendsto g'' l (𝓝 0) := by simp only [← isLittleO_one_iff ℝ, h.isLittleO_congr_left] theorem IsTheta.tendsto_norm_atTop_iff (h : f' =Θ[l] g') : Tendsto (norm ∘ f') l atTop ↔ Tendsto (norm ∘ g') l atTop := by simp only [Function.comp_def, ← isLittleO_const_left_of_ne (one_ne_zero' ℝ), h.isLittleO_congr_right] theorem IsTheta.isBoundedUnder_le_iff (h : f' =Θ[l] g') : IsBoundedUnder (· ≤ ·) l (norm ∘ f') ↔ IsBoundedUnder (· ≤ ·) l (norm ∘ g') := by simp only [← isBigO_const_of_ne (one_ne_zero' ℝ), h.isBigO_congr_left] theorem IsTheta.smul [NormedSpace 𝕜 E'] [NormedSpace 𝕜' F'] {f₁ : α → 𝕜} {f₂ : α → 𝕜'} {g₁ : α → E'} {g₂ : α → F'} (hf : f₁ =Θ[l] f₂) (hg : g₁ =Θ[l] g₂) : (fun x ↦ f₁ x • g₁ x) =Θ[l] fun x ↦ f₂ x • g₂ x := ⟨hf.1.smul hg.1, hf.2.smul hg.2⟩ theorem IsTheta.mul {f₁ f₂ : α → 𝕜} {g₁ g₂ : α → 𝕜'} (h₁ : f₁ =Θ[l] g₁) (h₂ : f₂ =Θ[l] g₂) : (fun x ↦ f₁ x * f₂ x) =Θ[l] fun x ↦ g₁ x * g₂ x := h₁.smul h₂ theorem IsTheta.listProd {ι : Type*} {L : List ι} {f : ι → α → 𝕜} {g : ι → α → 𝕜'} (h : ∀ i ∈ L, f i =Θ[l] g i) : (fun x ↦ (L.map (f · x)).prod) =Θ[l] (fun x ↦ (L.map (g · x)).prod) := ⟨.listProd fun i hi ↦ (h i hi).isBigO, .listProd fun i hi ↦ (h i hi).symm.isBigO⟩ theorem IsTheta.multisetProd {ι : Type*} {s : Multiset ι} {f : ι → α → 𝕜} {g : ι → α → 𝕜'} (h : ∀ i ∈ s, f i =Θ[l] g i) : (fun x ↦ (s.map (f · x)).prod) =Θ[l] (fun x ↦ (s.map (g · x)).prod) := ⟨.multisetProd fun i hi ↦ (h i hi).isBigO, .multisetProd fun i hi ↦ (h i hi).symm.isBigO⟩ theorem IsTheta.finsetProd {ι : Type*} {s : Finset ι} {f : ι → α → 𝕜} {g : ι → α → 𝕜'} (h : ∀ i ∈ s, f i =Θ[l] g i) : (∏ i ∈ s, f i ·) =Θ[l] (∏ i ∈ s, g i ·) := ⟨.finsetProd fun i hi ↦ (h i hi).isBigO, .finsetProd fun i hi ↦ (h i hi).symm.isBigO⟩ theorem IsTheta.inv {f : α → 𝕜} {g : α → 𝕜'} (h : f =Θ[l] g) : (fun x ↦ (f x)⁻¹) =Θ[l] fun x ↦ (g x)⁻¹ := ⟨h.2.inv_rev h.1.eq_zero_imp, h.1.inv_rev h.2.eq_zero_imp⟩ @[simp] theorem isTheta_inv {f : α → 𝕜} {g : α → 𝕜'} : ((fun x ↦ (f x)⁻¹) =Θ[l] fun x ↦ (g x)⁻¹) ↔ f =Θ[l] g := ⟨fun h ↦ by simpa only [inv_inv] using h.inv, IsTheta.inv⟩ theorem IsTheta.div {f₁ f₂ : α → 𝕜} {g₁ g₂ : α → 𝕜'} (h₁ : f₁ =Θ[l] g₁) (h₂ : f₂ =Θ[l] g₂) : (fun x ↦ f₁ x / f₂ x) =Θ[l] fun x ↦ g₁ x / g₂ x := by simpa only [div_eq_mul_inv] using h₁.mul h₂.inv theorem IsTheta.pow {f : α → 𝕜} {g : α → 𝕜'} (h : f =Θ[l] g) (n : ℕ) : (fun x ↦ f x ^ n) =Θ[l] fun x ↦ g x ^ n := ⟨h.1.pow n, h.2.pow n⟩ theorem IsTheta.zpow {f : α → 𝕜} {g : α → 𝕜'} (h : f =Θ[l] g) (n : ℤ) : (fun x ↦ f x ^ n) =Θ[l] fun x ↦ g x ^ n := by cases n · simpa only [Int.ofNat_eq_coe, zpow_natCast] using h.pow _ · simpa only [zpow_negSucc] using (h.pow _).inv theorem isTheta_const_const {c₁ : E''} {c₂ : F''} (h₁ : c₁ ≠ 0) (h₂ : c₂ ≠ 0) : (fun _ : α ↦ c₁) =Θ[l] fun _ ↦ c₂ := ⟨isBigO_const_const _ h₂ _, isBigO_const_const _ h₁ _⟩ @[simp] theorem isTheta_const_const_iff [NeBot l] {c₁ : E''} {c₂ : F''} : ((fun _ : α ↦ c₁) =Θ[l] fun _ ↦ c₂) ↔ (c₁ = 0 ↔ c₂ = 0) := by simpa only [IsTheta, isBigO_const_const_iff, ← iff_def] using Iff.comm @[simp] theorem isTheta_zero_left : (fun _ ↦ (0 : E')) =Θ[l] g'' ↔ g'' =ᶠ[l] 0 := by simp only [IsTheta, isBigO_zero, isBigO_zero_right_iff, true_and] @[simp] theorem isTheta_zero_right : (f'' =Θ[l] fun _ ↦ (0 : F')) ↔ f'' =ᶠ[l] 0 := isTheta_comm.trans isTheta_zero_left theorem isTheta_const_smul_left [NormedSpace 𝕜 E'] {c : 𝕜} (hc : c ≠ 0) : (fun x ↦ c • f' x) =Θ[l] g ↔ f' =Θ[l] g := and_congr (isBigO_const_smul_left hc) (isBigO_const_smul_right hc) alias ⟨IsTheta.of_const_smul_left, IsTheta.const_smul_left⟩ := isTheta_const_smul_left theorem isTheta_const_smul_right [NormedSpace 𝕜 F'] {c : 𝕜} (hc : c ≠ 0) : (f =Θ[l] fun x ↦ c • g' x) ↔ f =Θ[l] g' := and_congr (isBigO_const_smul_right hc) (isBigO_const_smul_left hc) alias ⟨IsTheta.of_const_smul_right, IsTheta.const_smul_right⟩ := isTheta_const_smul_right theorem isTheta_const_mul_left {c : 𝕜} {f : α → 𝕜} (hc : c ≠ 0) : (fun x ↦ c * f x) =Θ[l] g ↔ f =Θ[l] g := by simpa only [← smul_eq_mul] using isTheta_const_smul_left hc alias ⟨IsTheta.of_const_mul_left, IsTheta.const_mul_left⟩ := isTheta_const_mul_left theorem isTheta_const_mul_right {c : 𝕜} {g : α → 𝕜} (hc : c ≠ 0) : (f =Θ[l] fun x ↦ c * g x) ↔ f =Θ[l] g := by simpa only [← smul_eq_mul] using isTheta_const_smul_right hc alias ⟨IsTheta.of_const_mul_right, IsTheta.const_mul_right⟩ := isTheta_const_mul_right theorem IsLittleO.right_isTheta_add {f₁ f₂ : α → E'} (h : f₁ =o[l] f₂) : f₂ =Θ[l] (f₁ + f₂) := ⟨h.right_isBigO_add, h.add_isBigO (isBigO_refl _ _)⟩ theorem IsLittleO.right_isTheta_add' {f₁ f₂ : α → E'} (h : f₁ =o[l] f₂) : f₂ =Θ[l] (f₂ + f₁) := add_comm f₁ f₂ ▸ h.right_isTheta_add lemma IsTheta.add_isLittleO {f₁ f₂ : α → E'} {g : α → F} (hΘ : f₁ =Θ[l] g) (ho : f₂ =o[l] g) : (f₁ + f₂) =Θ[l] g := (ho.trans_isTheta hΘ.symm).right_isTheta_add'.symm.trans hΘ lemma IsLittleO.add_isTheta {f₁ f₂ : α → E'} {g : α → F} (ho : f₁ =o[l] g) (hΘ : f₂ =Θ[l] g) : (f₁ + f₂) =Θ[l] g := add_comm f₁ f₂ ▸ hΘ.add_isLittleO ho section variable {f : α × β → E} {g : α × β → F} {l' : Filter β} protected theorem IsTheta.fiberwise_right : f =Θ[l ×ˢ l'] g → ∀ᶠ x in l, (f ⟨x, ·⟩) =Θ[l'] (g ⟨x, ·⟩) := by simp only [IsTheta, eventually_and] exact fun ⟨h₁, h₂⟩ ↦ ⟨h₁.fiberwise_right, h₂.fiberwise_right⟩ protected theorem IsTheta.fiberwise_left : f =Θ[l ×ˢ l'] g → ∀ᶠ y in l', (f ⟨·, y⟩) =Θ[l] (g ⟨·, y⟩) := by simp only [IsTheta, eventually_and] exact fun ⟨h₁, h₂⟩ ↦ ⟨h₁.fiberwise_left, h₂.fiberwise_left⟩ end section variable (l' : Filter β) protected theorem IsTheta.comp_fst : f =Θ[l] g → (f ∘ Prod.fst) =Θ[l ×ˢ l'] (g ∘ Prod.fst) := by simp only [IsTheta] exact fun ⟨h₁, h₂⟩ ↦ ⟨h₁.comp_fst l', h₂.comp_fst l'⟩ protected theorem IsTheta.comp_snd : f =Θ[l] g → (f ∘ Prod.snd) =Θ[l' ×ˢ l] (g ∘ Prod.snd) := by simp only [IsTheta] exact fun ⟨h₁, h₂⟩ ↦ ⟨h₁.comp_snd l', h₂.comp_snd l'⟩ end end Asymptotics namespace ContinuousOn variable {α E F : Type*} [NormedAddGroup E] [SeminormedAddGroup F] [TopologicalSpace α] {s : Set α} {f : α → E} {c : F} protected theorem isTheta_principal (hf : ContinuousOn f s) (hs : IsCompact s) (hc : ‖c‖ ≠ 0) (hC : ∀ i ∈ s, f i ≠ 0) : f =Θ[𝓟 s] fun _ => c := ⟨hf.isBigO_principal hs hc, hf.isBigO_rev_principal hs hC c⟩ end ContinuousOn
.lake/packages/mathlib/Mathlib/Analysis/Asymptotics/Lemmas.lean
import Mathlib.Analysis.Asymptotics.Defs import Mathlib.Analysis.Normed.Group.Bounded import Mathlib.Analysis.Normed.Group.InfiniteSum import Mathlib.Analysis.Normed.MulAction import Mathlib.Topology.OpenPartialHomeomorph /-! # Further basic lemmas about asymptotics -/ open Set Topology Filter NNReal namespace Asymptotics variable {α : Type*} {β : Type*} {E : Type*} {F : Type*} {G : Type*} {E' : Type*} {F' : Type*} {G' : Type*} {E'' : Type*} {F'' : Type*} {G'' : Type*} {E''' : Type*} {R : Type*} {R' : Type*} {𝕜 : Type*} {𝕜' : Type*} variable [Norm E] [Norm F] [Norm G] variable [SeminormedAddCommGroup E'] [SeminormedAddCommGroup F'] [SeminormedAddCommGroup G'] [NormedAddCommGroup E''] [NormedAddCommGroup F''] [NormedAddCommGroup G''] [SeminormedRing R] [SeminormedAddGroup E'''] [SeminormedRing R'] variable [NormedDivisionRing 𝕜] [NormedDivisionRing 𝕜'] variable {c c' c₁ c₂ : ℝ} {f : α → E} {g : α → F} {k : α → G} variable {f' : α → E'} {g' : α → F'} {k' : α → G'} variable {f'' : α → E''} {g'' : α → F''} {k'' : α → G''} variable {l l' : Filter α} @[simp] theorem isBigOWith_principal {s : Set α} : IsBigOWith c (𝓟 s) f g ↔ ∀ x ∈ s, ‖f x‖ ≤ c * ‖g x‖ := by rw [IsBigOWith_def, eventually_principal] theorem isBigO_principal {s : Set α} : f =O[𝓟 s] g ↔ ∃ c, ∀ x ∈ s, ‖f x‖ ≤ c * ‖g x‖ := by simp_rw [isBigO_iff, eventually_principal] @[simp] theorem isLittleO_principal {s : Set α} : f'' =o[𝓟 s] g' ↔ ∀ x ∈ s, f'' x = 0 := by refine ⟨fun h x hx ↦ norm_le_zero_iff.1 ?_, fun h ↦ ?_⟩ · simp only [isLittleO_iff] at h have : Tendsto (fun c : ℝ => c * ‖g' x‖) (𝓝[>] 0) (𝓝 0) := ((continuous_id.mul continuous_const).tendsto' _ _ (zero_mul _)).mono_left inf_le_left apply le_of_tendsto_of_tendsto tendsto_const_nhds this apply eventually_nhdsWithin_iff.2 (Eventually.of_forall (fun c hc ↦ ?_)) exact eventually_principal.1 (h hc) x hx · apply (isLittleO_zero g' _).congr' ?_ EventuallyEq.rfl exact fun x hx ↦ (h x hx).symm @[simp] theorem isBigOWith_top : IsBigOWith c ⊤ f g ↔ ∀ x, ‖f x‖ ≤ c * ‖g x‖ := by rw [IsBigOWith_def, eventually_top] @[simp] theorem isBigO_top : f =O[⊤] g ↔ ∃ C, ∀ x, ‖f x‖ ≤ C * ‖g x‖ := by simp_rw [isBigO_iff, eventually_top] @[simp] theorem isLittleO_top : f'' =o[⊤] g' ↔ ∀ x, f'' x = 0 := by simp only [← principal_univ, isLittleO_principal, mem_univ, forall_true_left] section variable (F) variable [One F] [NormOneClass F] theorem isBigOWith_const_one (c : E) (l : Filter α) : IsBigOWith ‖c‖ l (fun _x : α => c) fun _x => (1 : F) := by simp [isBigOWith_iff] theorem isBigO_const_one (c : E) (l : Filter α) : (fun _x : α => c) =O[l] fun _x => (1 : F) := (isBigOWith_const_one F c l).isBigO theorem isLittleO_const_iff_isLittleO_one {c : F''} (hc : c ≠ 0) : (f =o[l] fun _x => c) ↔ f =o[l] fun _x => (1 : F) := ⟨fun h => h.trans_isBigOWith (isBigOWith_const_one _ _ _) (norm_pos_iff.2 hc), fun h => h.trans_isBigO <| isBigO_const_const _ hc _⟩ @[simp] theorem isLittleO_one_iff {f : α → E'''} : f =o[l] (fun _x => 1 : α → F) ↔ Tendsto f l (𝓝 0) := by simp only [isLittleO_iff, norm_one, mul_one, Metric.nhds_basis_closedBall.tendsto_right_iff, Metric.mem_closedBall, dist_zero_right] @[simp] theorem isBigO_one_iff : f =O[l] (fun _x => 1 : α → F) ↔ IsBoundedUnder (· ≤ ·) l fun x => ‖f x‖ := by simp only [isBigO_iff, norm_one, mul_one, IsBoundedUnder, IsBounded, eventually_map] alias ⟨_, _root_.Filter.IsBoundedUnder.isBigO_one⟩ := isBigO_one_iff @[simp] theorem isLittleO_one_left_iff : (fun _x => 1 : α → F) =o[l] f ↔ Tendsto (fun x => ‖f x‖) l atTop := calc (fun _x => 1 : α → F) =o[l] f ↔ ∀ n : ℕ, ∀ᶠ x in l, ↑n * ‖(1 : F)‖ ≤ ‖f x‖ := isLittleO_iff_nat_mul_le_aux <| Or.inl fun _x => by simp only [norm_one, zero_le_one] _ ↔ ∀ n : ℕ, True → ∀ᶠ x in l, ‖f x‖ ∈ Ici (n : ℝ) := by simp only [norm_one, mul_one, true_imp_iff, mem_Ici] _ ↔ Tendsto (fun x => ‖f x‖) l atTop := atTop_hasCountableBasis_of_archimedean.1.tendsto_right_iff.symm theorem _root_.Filter.Tendsto.isBigO_one {c : E'} (h : Tendsto f' l (𝓝 c)) : f' =O[l] (fun _x => 1 : α → F) := h.norm.isBoundedUnder_le.isBigO_one F theorem IsBigO.trans_tendsto_nhds (hfg : f =O[l] g') {y : F'} (hg : Tendsto g' l (𝓝 y)) : f =O[l] (fun _x => 1 : α → F) := hfg.trans <| hg.isBigO_one F /-- The condition `f = O[𝓝[≠] a] 1` is equivalent to `f = O[𝓝 a] 1`. -/ lemma isBigO_one_nhds_ne_iff [TopologicalSpace α] {a : α} : f =O[𝓝[≠] a] (fun _ ↦ 1 : α → F) ↔ f =O[𝓝 a] (fun _ ↦ 1 : α → F) := by refine ⟨fun h ↦ ?_, fun h ↦ h.mono nhdsWithin_le_nhds⟩ simp only [isBigO_one_iff, IsBoundedUnder, IsBounded, eventually_map] at h ⊢ obtain ⟨c, hc⟩ := h use max c ‖f a‖ filter_upwards [eventually_nhdsWithin_iff.mp hc] with b hb rcases eq_or_ne b a with rfl | hb' · apply le_max_right · exact (hb hb').trans (le_max_left ..) end theorem isLittleO_const_iff {c : F''} (hc : c ≠ 0) : (f'' =o[l] fun _x => c) ↔ Tendsto f'' l (𝓝 0) := (isLittleO_const_iff_isLittleO_one ℝ hc).trans (isLittleO_one_iff _) theorem isLittleO_id_const {c : F''} (hc : c ≠ 0) : (fun x : E'' => x) =o[𝓝 0] fun _x => c := (isLittleO_const_iff hc).mpr (continuous_id.tendsto 0) theorem _root_.Filter.IsBoundedUnder.isBigO_const (h : IsBoundedUnder (· ≤ ·) l (norm ∘ f)) {c : F''} (hc : c ≠ 0) : f =O[l] fun _x => c := (h.isBigO_one ℝ).trans (isBigO_const_const _ hc _) theorem isBigO_const_of_tendsto {y : E''} (h : Tendsto f'' l (𝓝 y)) {c : F''} (hc : c ≠ 0) : f'' =O[l] fun _x => c := h.norm.isBoundedUnder_le.isBigO_const hc theorem IsBigO.isBoundedUnder_le {c : F} (h : f =O[l] fun _x => c) : IsBoundedUnder (· ≤ ·) l (norm ∘ f) := let ⟨c', hc'⟩ := h.bound ⟨c' * ‖c‖, eventually_map.2 hc'⟩ theorem isBigO_const_of_ne {c : F''} (hc : c ≠ 0) : (f =O[l] fun _x => c) ↔ IsBoundedUnder (· ≤ ·) l (norm ∘ f) := ⟨fun h => h.isBoundedUnder_le, fun h => h.isBigO_const hc⟩ theorem isBigO_const_iff {c : F''} : (f'' =O[l] fun _x => c) ↔ (c = 0 → f'' =ᶠ[l] 0) ∧ IsBoundedUnder (· ≤ ·) l fun x => ‖f'' x‖ := by refine ⟨fun h => ⟨fun hc => isBigO_zero_right_iff.1 (by rwa [← hc]), h.isBoundedUnder_le⟩, ?_⟩ rintro ⟨hcf, hf⟩ rcases eq_or_ne c 0 with (hc | hc) exacts [(hcf hc).trans_isBigO (isBigO_zero _ _), hf.isBigO_const hc] theorem isBigO_iff_isBoundedUnder_le_div (h : ∀ᶠ x in l, g'' x ≠ 0) : f =O[l] g'' ↔ IsBoundedUnder (· ≤ ·) l fun x => ‖f x‖ / ‖g'' x‖ := by simp only [isBigO_iff, IsBoundedUnder, IsBounded, eventually_map] exact exists_congr fun c => eventually_congr <| h.mono fun x hx => (div_le_iff₀ <| norm_pos_iff.2 hx).symm /-- `(fun x ↦ c) =O[l] f` if and only if `f` is bounded away from zero. -/ theorem isBigO_const_left_iff_pos_le_norm {c : E''} (hc : c ≠ 0) : (fun _x => c) =O[l] f' ↔ ∃ b, 0 < b ∧ ∀ᶠ x in l, b ≤ ‖f' x‖ := by constructor · intro h rcases h.exists_pos with ⟨C, hC₀, hC⟩ refine ⟨‖c‖ / C, div_pos (norm_pos_iff.2 hc) hC₀, ?_⟩ exact hC.bound.mono fun x => (div_le_iff₀' hC₀).2 · rintro ⟨b, hb₀, hb⟩ refine IsBigO.of_bound (‖c‖ / b) (hb.mono fun x hx => ?_) rw [div_mul_eq_mul_div, mul_div_assoc] exact le_mul_of_one_le_right (norm_nonneg _) ((one_le_div hb₀).2 hx) theorem IsBigO.trans_tendsto (hfg : f'' =O[l] g'') (hg : Tendsto g'' l (𝓝 0)) : Tendsto f'' l (𝓝 0) := (isLittleO_one_iff ℝ).1 <| hfg.trans_isLittleO <| (isLittleO_one_iff ℝ).2 hg theorem IsLittleO.trans_tendsto (hfg : f'' =o[l] g'') (hg : Tendsto g'' l (𝓝 0)) : Tendsto f'' l (𝓝 0) := hfg.isBigO.trans_tendsto hg lemma isLittleO_id_one [One F''] [NeZero (1 : F'')] : (fun x : E'' => x) =o[𝓝 0] (1 : E'' → F'') := isLittleO_id_const one_ne_zero theorem continuousAt_iff_isLittleO {α : Type*} {E : Type*} [NormedRing E] [NormOneClass E] [TopologicalSpace α] {f : α → E} {x : α} : (ContinuousAt f x) ↔ (fun (y : α) ↦ f y - f x) =o[𝓝 x] (fun (_ : α) ↦ (1 : E)) := by simp [ContinuousAt, ← tendsto_sub_nhds_zero_iff] /-! ### Multiplication -/ theorem IsBigO.of_pow {f : α → 𝕜} {g : α → R} {n : ℕ} (hn : n ≠ 0) (h : (f ^ n) =O[l] (g ^ n)) : f =O[l] g := by rcases h.exists_pos with ⟨C, _hC₀, hC⟩ obtain ⟨c : ℝ, hc₀ : 0 ≤ c, hc : C ≤ c ^ n⟩ := ((eventually_ge_atTop _).and <| (tendsto_pow_atTop hn).eventually_ge_atTop C).exists exact (hC.of_pow hn hc hc₀).isBigO theorem IsBigO.pow_of_le_right {f : α → ℝ} (hf : 1 ≤ᶠ[l] f) {m n : ℕ} (h : n ≤ m) : (f ^ n) =O[l] (f ^ m) := by rw [IsBigO_def] refine ⟨1, ?_⟩ rw [IsBigOWith_def] exact hf.mono fun x hx ↦ by simp [abs_eq_self.mpr (zero_le_one.trans hx), pow_le_pow_right₀ hx h] /-! ### Scalar multiplication -/ section SMulConst variable [Module R E'] [IsBoundedSMul R E'] theorem IsBigOWith.const_smul_self (c' : R) : IsBigOWith (‖c'‖) l (fun x => c' • f' x) f' := isBigOWith_of_le' _ fun _ => norm_smul_le _ _ theorem IsBigO.const_smul_self (c' : R) : (fun x => c' • f' x) =O[l] f' := (IsBigOWith.const_smul_self _).isBigO theorem IsBigOWith.const_smul_left (h : IsBigOWith c l f' g) (c' : R) : IsBigOWith (‖c'‖ * c) l (fun x => c' • f' x) g := .trans (.const_smul_self _) h (norm_nonneg _) theorem IsBigO.const_smul_left (h : f' =O[l] g) (c : R) : (c • f') =O[l] g := let ⟨_b, hb⟩ := h.isBigOWith (hb.const_smul_left _).isBigO theorem IsLittleO.const_smul_left (h : f' =o[l] g) (c : R) : (c • f') =o[l] g := (IsBigO.const_smul_self _).trans_isLittleO h variable [Module 𝕜 E'] [NormSMulClass 𝕜 E'] theorem isBigO_const_smul_left {c : 𝕜} (hc : c ≠ 0) : (fun x => c • f' x) =O[l] g ↔ f' =O[l] g := by have cne0 : ‖c‖ ≠ 0 := norm_ne_zero_iff.mpr hc rw [← isBigO_norm_left] simp only [norm_smul] rw [isBigO_const_mul_left_iff cne0, isBigO_norm_left] theorem isLittleO_const_smul_left {c : 𝕜} (hc : c ≠ 0) : (fun x => c • f' x) =o[l] g ↔ f' =o[l] g := by have cne0 : ‖c‖ ≠ 0 := norm_ne_zero_iff.mpr hc rw [← isLittleO_norm_left] simp only [norm_smul] rw [isLittleO_const_mul_left_iff cne0, isLittleO_norm_left] theorem isBigO_const_smul_right {c : 𝕜} (hc : c ≠ 0) : (f =O[l] fun x => c • f' x) ↔ f =O[l] f' := by have cne0 : ‖c‖ ≠ 0 := norm_ne_zero_iff.mpr hc rw [← isBigO_norm_right] simp only [norm_smul] rw [isBigO_const_mul_right_iff cne0, isBigO_norm_right] theorem isLittleO_const_smul_right {c : 𝕜} (hc : c ≠ 0) : (f =o[l] fun x => c • f' x) ↔ f =o[l] f' := by have cne0 : ‖c‖ ≠ 0 := norm_ne_zero_iff.mpr hc rw [← isLittleO_norm_right] simp only [norm_smul] rw [isLittleO_const_mul_right_iff cne0, isLittleO_norm_right] end SMulConst section SMul variable [Module R E'] [IsBoundedSMul R E'] [Module 𝕜' F'] [NormSMulClass 𝕜' F'] variable {k₁ : α → R} {k₂ : α → 𝕜'} theorem IsBigOWith.smul (h₁ : IsBigOWith c l k₁ k₂) (h₂ : IsBigOWith c' l f' g') : IsBigOWith (c * c') l (fun x => k₁ x • f' x) fun x => k₂ x • g' x := by simp only [IsBigOWith_def] at * filter_upwards [h₁, h₂] with _ hx₁ hx₂ apply le_trans (norm_smul_le _ _) convert mul_le_mul hx₁ hx₂ (norm_nonneg _) (le_trans (norm_nonneg _) hx₁) using 1 rw [norm_smul, mul_mul_mul_comm] theorem IsBigO.smul (h₁ : k₁ =O[l] k₂) (h₂ : f' =O[l] g') : (fun x => k₁ x • f' x) =O[l] fun x => k₂ x • g' x := by obtain ⟨c₁, h₁⟩ := h₁.isBigOWith obtain ⟨c₂, h₂⟩ := h₂.isBigOWith exact (h₁.smul h₂).isBigO theorem IsBigO.smul_isLittleO (h₁ : k₁ =O[l] k₂) (h₂ : f' =o[l] g') : (fun x => k₁ x • f' x) =o[l] fun x => k₂ x • g' x := by simp only [IsLittleO_def] at * intro c cpos rcases h₁.exists_pos with ⟨c', c'pos, hc'⟩ exact (hc'.smul (h₂ (div_pos cpos c'pos))).congr_const (mul_div_cancel₀ _ (ne_of_gt c'pos)) theorem IsLittleO.smul_isBigO (h₁ : k₁ =o[l] k₂) (h₂ : f' =O[l] g') : (fun x => k₁ x • f' x) =o[l] fun x => k₂ x • g' x := by simp only [IsLittleO_def] at * intro c cpos rcases h₂.exists_pos with ⟨c', c'pos, hc'⟩ exact ((h₁ (div_pos cpos c'pos)).smul hc').congr_const (div_mul_cancel₀ _ (ne_of_gt c'pos)) theorem IsLittleO.smul (h₁ : k₁ =o[l] k₂) (h₂ : f' =o[l] g') : (fun x => k₁ x • f' x) =o[l] fun x => k₂ x • g' x := h₁.smul_isBigO h₂.isBigO end SMul section Prod variable {ι : Type*} theorem IsBigO.listProd {L : List ι} {f : ι → α → R} {g : ι → α → 𝕜} (hf : ∀ i ∈ L, f i =O[l] g i) : (fun x ↦ (L.map (f · x)).prod) =O[l] (fun x ↦ (L.map (g · x)).prod) := by induction L with | nil => simp [isBoundedUnder_const] | cons i L ihL => simp only [List.map_cons, List.prod_cons, List.forall_mem_cons] at hf ⊢ exact hf.1.mul (ihL hf.2) theorem IsBigO.multisetProd {R 𝕜 : Type*} [SeminormedCommRing R] [NormedField 𝕜] {s : Multiset ι} {f : ι → α → R} {g : ι → α → 𝕜} (hf : ∀ i ∈ s, f i =O[l] g i) : (fun x ↦ (s.map (f · x)).prod) =O[l] (fun x ↦ (s.map (g · x)).prod) := by obtain ⟨l, rfl⟩ : ∃ l : List ι, ↑l = s := Quotient.mk_surjective s exact mod_cast IsBigO.listProd hf theorem IsBigO.finsetProd {R 𝕜 : Type*} [SeminormedCommRing R] [NormedField 𝕜] {s : Finset ι} {f : ι → α → R} {g : ι → α → 𝕜} (hf : ∀ i ∈ s, f i =O[l] g i) : (∏ i ∈ s, f i ·) =O[l] (∏ i ∈ s, g i ·) := .multisetProd hf theorem IsLittleO.listProd {L : List ι} {f : ι → α → R} {g : ι → α → 𝕜} (h₁ : ∀ i ∈ L, f i =O[l] g i) (h₂ : ∃ i ∈ L, f i =o[l] g i) : (fun x ↦ (L.map (f · x)).prod) =o[l] (fun x ↦ (L.map (g · x)).prod) := by induction L with | nil => simp at h₂ | cons i L ihL => simp only [List.map_cons, List.prod_cons, List.forall_mem_cons, List.exists_mem_cons_iff] at h₁ h₂ ⊢ cases h₂ with | inl hi => exact hi.mul_isBigO <| .listProd h₁.2 | inr hL => exact h₁.1.mul_isLittleO <| ihL h₁.2 hL theorem IsLittleO.multisetProd {R 𝕜 : Type*} [SeminormedCommRing R] [NormedField 𝕜] {s : Multiset ι} {f : ι → α → R} {g : ι → α → 𝕜} (h₁ : ∀ i ∈ s, f i =O[l] g i) (h₂ : ∃ i ∈ s, f i =o[l] g i) : (fun x ↦ (s.map (f · x)).prod) =o[l] (fun x ↦ (s.map (g · x)).prod) := by obtain ⟨l, rfl⟩ : ∃ l : List ι, ↑l = s := Quotient.mk_surjective s exact mod_cast IsLittleO.listProd h₁ h₂ theorem IsLittleO.finsetProd {R 𝕜 : Type*} [SeminormedCommRing R] [NormedField 𝕜] {s : Finset ι} {f : ι → α → R} {g : ι → α → 𝕜} (h₁ : ∀ i ∈ s, f i =O[l] g i) (h₂ : ∃ i ∈ s, f i =o[l] g i) : (∏ i ∈ s, f i ·) =o[l] (∏ i ∈ s, g i ·) := .multisetProd h₁ h₂ end Prod /-! ### Relation between `f = o(g)` and `f / g → 0` -/ theorem IsLittleO.tendsto_div_nhds_zero {f g : α → 𝕜} (h : f =o[l] g) : Tendsto (fun x => f x / g x) l (𝓝 0) := (isLittleO_one_iff 𝕜).mp <| by calc (fun x => f x / g x) =o[l] fun x => g x / g x := by simpa only [div_eq_mul_inv] using h.mul_isBigO (isBigO_refl _ _) _ =O[l] fun _x => (1 : 𝕜) := isBigO_of_le _ fun x => by simp [div_self_le_one] theorem IsLittleO.tendsto_inv_smul_nhds_zero [Module 𝕜 E'] [NormSMulClass 𝕜 E'] {f : α → E'} {g : α → 𝕜} {l : Filter α} (h : f =o[l] g) : Tendsto (fun x => (g x)⁻¹ • f x) l (𝓝 0) := by simpa only [div_eq_inv_mul, ← norm_inv, ← norm_smul, ← tendsto_zero_iff_norm_tendsto_zero] using h.norm_norm.tendsto_div_nhds_zero theorem isLittleO_iff_tendsto' {f g : α → 𝕜} (hgf : ∀ᶠ x in l, g x = 0 → f x = 0) : f =o[l] g ↔ Tendsto (fun x => f x / g x) l (𝓝 0) := ⟨IsLittleO.tendsto_div_nhds_zero, fun h => (((isLittleO_one_iff _).mpr h).mul_isBigO (isBigO_refl g l)).congr' (hgf.mono fun _x => div_mul_cancel_of_imp) (Eventually.of_forall fun _x => one_mul _)⟩ theorem isLittleO_iff_tendsto {f g : α → 𝕜} (hgf : ∀ x, g x = 0 → f x = 0) : f =o[l] g ↔ Tendsto (fun x => f x / g x) l (𝓝 0) := isLittleO_iff_tendsto' (Eventually.of_forall hgf) alias ⟨_, isLittleO_of_tendsto'⟩ := isLittleO_iff_tendsto' alias ⟨_, isLittleO_of_tendsto⟩ := isLittleO_iff_tendsto theorem isLittleO_const_left_of_ne {c : E''} (hc : c ≠ 0) : (fun _x => c) =o[l] g ↔ Tendsto (fun x => ‖g x‖) l atTop := by simp only [← isLittleO_one_left_iff ℝ] exact ⟨(isBigO_const_const (1 : ℝ) hc l).trans_isLittleO, (isBigO_const_one ℝ c l).trans_isLittleO⟩ @[simp] theorem isLittleO_const_left {c : E''} : (fun _x => c) =o[l] g'' ↔ c = 0 ∨ Tendsto (norm ∘ g'') l atTop := by rcases eq_or_ne c 0 with (rfl | hc) · simp only [isLittleO_zero, true_or] · simp only [hc, false_or, isLittleO_const_left_of_ne hc]; rfl @[simp high] -- Increase priority so that this triggers before `isLittleO_const_left` theorem isLittleO_const_const_iff [NeBot l] {d : E''} {c : F''} : ((fun _x => d) =o[l] fun _x => c) ↔ d = 0 := by have : ¬Tendsto (Function.const α ‖c‖) l atTop := not_tendsto_atTop_of_tendsto_nhds tendsto_const_nhds simp only [isLittleO_const_left, or_iff_left_iff_imp] exact fun h => (this h).elim @[simp] theorem isLittleO_pure {x} : f'' =o[pure x] g'' ↔ f'' x = 0 := calc f'' =o[pure x] g'' ↔ (fun _y : α => f'' x) =o[pure x] fun _ => g'' x := isLittleO_congr rfl rfl _ ↔ f'' x = 0 := isLittleO_const_const_iff theorem isLittleO_const_id_cobounded (c : F'') : (fun _ => c) =o[Bornology.cobounded E''] id := isLittleO_const_left.2 <| .inr tendsto_norm_cobounded_atTop theorem isLittleO_const_id_atTop (c : E'') : (fun _x : ℝ => c) =o[atTop] id := isLittleO_const_left.2 <| Or.inr tendsto_abs_atTop_atTop theorem isLittleO_const_id_atBot (c : E'') : (fun _x : ℝ => c) =o[atBot] id := isLittleO_const_left.2 <| Or.inr tendsto_abs_atBot_atTop /-! ### Equivalent definitions of the form `∃ φ, u =ᶠ[l] φ * v` in a `NormedField`. -/ section ExistsMulEq variable {u v : α → 𝕜} /-- If `‖φ‖` is eventually bounded by `c`, and `u =ᶠ[l] φ * v`, then we have `IsBigOWith c u v l`. This does not require any assumptions on `c`, which is why we keep this version along with `IsBigOWith_iff_exists_eq_mul`. -/ theorem isBigOWith_of_eq_mul {u v : α → R} (φ : α → R) (hφ : ∀ᶠ x in l, ‖φ x‖ ≤ c) (h : u =ᶠ[l] φ * v) : IsBigOWith c l u v := by simp only [IsBigOWith_def] refine h.symm.rw (fun x a => ‖a‖ ≤ c * ‖v x‖) (hφ.mono fun x hx => ?_) simp only [Pi.mul_apply] refine (norm_mul_le _ _).trans ?_ gcongr theorem isBigOWith_iff_exists_eq_mul (hc : 0 ≤ c) : IsBigOWith c l u v ↔ ∃ φ : α → 𝕜, (∀ᶠ x in l, ‖φ x‖ ≤ c) ∧ u =ᶠ[l] φ * v := by constructor · intro h use fun x => u x / v x refine ⟨Eventually.mono h.bound fun y hy => ?_, h.eventually_mul_div_cancel.symm⟩ simpa using div_le_of_le_mul₀ (norm_nonneg _) hc hy · rintro ⟨φ, hφ, h⟩ exact isBigOWith_of_eq_mul φ hφ h theorem IsBigOWith.exists_eq_mul (h : IsBigOWith c l u v) (hc : 0 ≤ c) : ∃ φ : α → 𝕜, (∀ᶠ x in l, ‖φ x‖ ≤ c) ∧ u =ᶠ[l] φ * v := (isBigOWith_iff_exists_eq_mul hc).mp h theorem isBigO_iff_exists_eq_mul : u =O[l] v ↔ ∃ φ : α → 𝕜, l.IsBoundedUnder (· ≤ ·) (norm ∘ φ) ∧ u =ᶠ[l] φ * v := by constructor · rintro h rcases h.exists_nonneg with ⟨c, hnnc, hc⟩ rcases hc.exists_eq_mul hnnc with ⟨φ, hφ, huvφ⟩ exact ⟨φ, ⟨c, hφ⟩, huvφ⟩ · rintro ⟨φ, ⟨c, hφ⟩, huvφ⟩ exact isBigO_iff_isBigOWith.2 ⟨c, isBigOWith_of_eq_mul φ hφ huvφ⟩ alias ⟨IsBigO.exists_eq_mul, _⟩ := isBigO_iff_exists_eq_mul theorem isLittleO_iff_exists_eq_mul : u =o[l] v ↔ ∃ φ : α → 𝕜, Tendsto φ l (𝓝 0) ∧ u =ᶠ[l] φ * v := by constructor · exact fun h => ⟨fun x => u x / v x, h.tendsto_div_nhds_zero, h.eventually_mul_div_cancel.symm⟩ · simp only [IsLittleO_def] rintro ⟨φ, hφ, huvφ⟩ c hpos rw [NormedAddCommGroup.tendsto_nhds_zero] at hφ exact isBigOWith_of_eq_mul _ ((hφ c hpos).mono fun x => le_of_lt) huvφ alias ⟨IsLittleO.exists_eq_mul, _⟩ := isLittleO_iff_exists_eq_mul end ExistsMulEq /-! ### Miscellaneous lemmas -/ theorem div_isBoundedUnder_of_isBigO {α : Type*} {l : Filter α} {f g : α → 𝕜} (h : f =O[l] g) : IsBoundedUnder (· ≤ ·) l fun x => ‖f x / g x‖ := by obtain ⟨c, h₀, hc⟩ := h.exists_nonneg refine ⟨c, eventually_map.2 (hc.bound.mono fun x hx => ?_)⟩ rw [norm_div] exact div_le_of_le_mul₀ (norm_nonneg _) h₀ hx theorem isBigO_iff_div_isBoundedUnder {α : Type*} {l : Filter α} {f g : α → 𝕜} (hgf : ∀ᶠ x in l, g x = 0 → f x = 0) : f =O[l] g ↔ IsBoundedUnder (· ≤ ·) l fun x => ‖f x / g x‖ := by refine ⟨div_isBoundedUnder_of_isBigO, fun h => ?_⟩ obtain ⟨c, hc⟩ := h simp only [eventually_map, norm_div] at hc refine IsBigO.of_bound c (hc.mp <| hgf.mono fun x hx₁ hx₂ => ?_) by_cases hgx : g x = 0 · simp [hx₁ hgx, hgx] · exact (div_le_iff₀ (norm_pos_iff.2 hgx)).mp hx₂ theorem isBigO_of_div_tendsto_nhds {α : Type*} {l : Filter α} {f g : α → 𝕜} (hgf : ∀ᶠ x in l, g x = 0 → f x = 0) (c : 𝕜) (H : Filter.Tendsto (f / g) l (𝓝 c)) : f =O[l] g := (isBigO_iff_div_isBoundedUnder hgf).2 <| H.norm.isBoundedUnder_le theorem IsLittleO.tendsto_zero_of_tendsto {α E 𝕜 : Type*} [NormedAddCommGroup E] [NormedField 𝕜] {u : α → E} {v : α → 𝕜} {l : Filter α} {y : 𝕜} (huv : u =o[l] v) (hv : Tendsto v l (𝓝 y)) : Tendsto u l (𝓝 0) := by suffices h : u =o[l] fun _x => (1 : 𝕜) by rwa [isLittleO_one_iff] at h exact huv.trans_isBigO (hv.isBigO_one 𝕜) theorem isLittleO_pow_pow {m n : ℕ} (h : m < n) : (fun x : 𝕜 => x ^ n) =o[𝓝 0] fun x => x ^ m := by rcases lt_iff_exists_add.1 h with ⟨p, hp0 : 0 < p, rfl⟩ suffices (fun x : 𝕜 => x ^ m * x ^ p) =o[𝓝 0] fun x => x ^ m * 1 ^ p by simpa only [pow_add, one_pow, mul_one] exact IsBigO.mul_isLittleO (isBigO_refl _ _) (IsLittleO.pow ((isLittleO_one_iff _).2 tendsto_id) hp0) theorem isLittleO_norm_pow_norm_pow {m n : ℕ} (h : m < n) : (fun x : E' => ‖x‖ ^ n) =o[𝓝 0] fun x => ‖x‖ ^ m := (isLittleO_pow_pow h).comp_tendsto tendsto_norm_zero theorem isLittleO_pow_id {n : ℕ} (h : 1 < n) : (fun x : 𝕜 => x ^ n) =o[𝓝 0] fun x => x := by convert isLittleO_pow_pow h (𝕜 := 𝕜) simp only [pow_one] theorem isLittleO_norm_pow_id {n : ℕ} (h : 1 < n) : (fun x : E' => ‖x‖ ^ n) =o[𝓝 0] fun x => x := by have := @isLittleO_norm_pow_norm_pow E' _ _ _ h simp only [pow_one] at this exact isLittleO_norm_right.mp this theorem IsBigO.eq_zero_of_norm_pow_within {f : E'' → F''} {s : Set E''} {x₀ : E''} {n : ℕ} (h : f =O[𝓝[s] x₀] fun x => ‖x - x₀‖ ^ n) (hx₀ : x₀ ∈ s) (hn : n ≠ 0) : f x₀ = 0 := mem_of_mem_nhdsWithin hx₀ h.eq_zero_imp <| by simp_rw [sub_self, norm_zero, zero_pow hn] theorem IsBigO.eq_zero_of_norm_pow {f : E'' → F''} {x₀ : E''} {n : ℕ} (h : f =O[𝓝 x₀] fun x => ‖x - x₀‖ ^ n) (hn : n ≠ 0) : f x₀ = 0 := by rw [← nhdsWithin_univ] at h exact h.eq_zero_of_norm_pow_within (mem_univ _) hn theorem isLittleO_pow_sub_pow_sub (x₀ : E') {n m : ℕ} (h : n < m) : (fun x => ‖x - x₀‖ ^ m) =o[𝓝 x₀] fun x => ‖x - x₀‖ ^ n := (isLittleO_pow_pow h).comp_tendsto (tendsto_norm_sub_self x₀) theorem isLittleO_pow_sub_sub (x₀ : E') {m : ℕ} (h : 1 < m) : (fun x => ‖x - x₀‖ ^ m) =o[𝓝 x₀] fun x => x - x₀ := by simpa only [isLittleO_norm_right, pow_one] using isLittleO_pow_sub_pow_sub x₀ h theorem IsBigOWith.right_le_sub_of_lt_one {f₁ f₂ : α → E'} (h : IsBigOWith c l f₁ f₂) (hc : c < 1) : IsBigOWith (1 / (1 - c)) l f₂ fun x => f₂ x - f₁ x := IsBigOWith.of_bound <| mem_of_superset h.bound fun x hx => by simp only [mem_setOf_eq] at hx ⊢ rw [mul_comm, one_div, ← div_eq_mul_inv, le_div_iff₀, mul_sub, mul_one, mul_comm] · exact le_trans (sub_le_sub_left hx _) (norm_sub_norm_le _ _) · exact sub_pos.2 hc theorem IsBigOWith.right_le_add_of_lt_one {f₁ f₂ : α → E'} (h : IsBigOWith c l f₁ f₂) (hc : c < 1) : IsBigOWith (1 / (1 - c)) l f₂ fun x => f₁ x + f₂ x := (h.neg_right.right_le_sub_of_lt_one hc).neg_right.of_neg_left.congr rfl (fun _ ↦ rfl) fun x ↦ by rw [neg_sub, sub_neg_eq_add] theorem IsLittleO.right_isBigO_sub {f₁ f₂ : α → E'} (h : f₁ =o[l] f₂) : f₂ =O[l] fun x => f₂ x - f₁ x := ((h.def' one_half_pos).right_le_sub_of_lt_one one_half_lt_one).isBigO theorem IsLittleO.right_isBigO_add {f₁ f₂ : α → E'} (h : f₁ =o[l] f₂) : f₂ =O[l] fun x => f₁ x + f₂ x := ((h.def' one_half_pos).right_le_add_of_lt_one one_half_lt_one).isBigO theorem IsLittleO.right_isBigO_add' {f₁ f₂ : α → E'} (h : f₁ =o[l] f₂) : f₂ =O[l] (f₂ + f₁) := add_comm f₁ f₂ ▸ h.right_isBigO_add /-- If `f x = O(g x)` along `cofinite`, then there exists a positive constant `C` such that `‖f x‖ ≤ C * ‖g x‖` whenever `g x ≠ 0`. -/ theorem bound_of_isBigO_cofinite (h : f =O[cofinite] g'') : ∃ C > 0, ∀ ⦃x⦄, g'' x ≠ 0 → ‖f x‖ ≤ C * ‖g'' x‖ := by rcases h.exists_pos with ⟨C, C₀, hC⟩ rw [IsBigOWith_def, eventually_cofinite] at hC rcases (hC.toFinset.image fun x => ‖f x‖ / ‖g'' x‖).exists_le with ⟨C', hC'⟩ have : ∀ x, C * ‖g'' x‖ < ‖f x‖ → ‖f x‖ / ‖g'' x‖ ≤ C' := by simpa using hC' refine ⟨max C C', lt_max_iff.2 (Or.inl C₀), fun x h₀ => ?_⟩ rw [max_mul_of_nonneg _ _ (norm_nonneg _), le_max_iff, or_iff_not_imp_left, not_le] exact fun hx => (div_le_iff₀ (norm_pos_iff.2 h₀)).1 (this _ hx) theorem isBigO_cofinite_iff (h : ∀ x, g'' x = 0 → f'' x = 0) : f'' =O[cofinite] g'' ↔ ∃ C, ∀ x, ‖f'' x‖ ≤ C * ‖g'' x‖ := by classical exact ⟨fun h' => let ⟨C, _C₀, hC⟩ := bound_of_isBigO_cofinite h' ⟨C, fun x => if hx : g'' x = 0 then by simp [h _ hx, hx] else hC hx⟩, fun h => (isBigO_top.2 h).mono le_top⟩ theorem bound_of_isBigO_nat_atTop {f : ℕ → E} {g'' : ℕ → E''} (h : f =O[atTop] g'') : ∃ C > 0, ∀ ⦃x⦄, g'' x ≠ 0 → ‖f x‖ ≤ C * ‖g'' x‖ := bound_of_isBigO_cofinite <| by rwa [Nat.cofinite_eq_atTop] theorem isBigO_nat_atTop_iff {f : ℕ → E''} {g : ℕ → F''} (h : ∀ x, g x = 0 → f x = 0) : f =O[atTop] g ↔ ∃ C, ∀ x, ‖f x‖ ≤ C * ‖g x‖ := by rw [← Nat.cofinite_eq_atTop, isBigO_cofinite_iff h] theorem isBigO_one_nat_atTop_iff {f : ℕ → E''} : f =O[atTop] (fun _n => 1 : ℕ → ℝ) ↔ ∃ C, ∀ n, ‖f n‖ ≤ C := Iff.trans (isBigO_nat_atTop_iff fun _ h => (one_ne_zero h).elim) <| by simp only [norm_one, mul_one] theorem IsBigO.nat_of_atTop {f : ℕ → E''} {g : ℕ → F''} (hfg : f =O[atTop] g) {l : Filter ℕ} (h : ∀ᶠ n in l, g n = 0 → f n = 0) : f =O[l] g := by obtain ⟨C, hC_pos, hC⟩ := bound_of_isBigO_nat_atTop hfg refine isBigO_iff.mpr ⟨C, ?_⟩ filter_upwards [h] with x h by_cases hf : f x = 0 · simp [hf, hC_pos] exact hC fun a ↦ hf (h a) theorem isBigOWith_pi {ι : Type*} [Fintype ι] {E' : ι → Type*} [∀ i, NormedAddCommGroup (E' i)] {f : α → ∀ i, E' i} {C : ℝ} (hC : 0 ≤ C) : IsBigOWith C l f g' ↔ ∀ i, IsBigOWith C l (fun x => f x i) g' := by have : ∀ x, 0 ≤ C * ‖g' x‖ := fun x => mul_nonneg hC (norm_nonneg _) simp only [isBigOWith_iff, pi_norm_le_iff_of_nonneg (this _), eventually_all] @[simp] theorem isBigO_pi {ι : Type*} [Fintype ι] {E' : ι → Type*} [∀ i, NormedAddCommGroup (E' i)] {f : α → ∀ i, E' i} : f =O[l] g' ↔ ∀ i, (fun x => f x i) =O[l] g' := by simp only [isBigO_iff_eventually_isBigOWith, ← eventually_all] exact eventually_congr (eventually_atTop.2 ⟨0, fun c => isBigOWith_pi⟩) @[simp] theorem isLittleO_pi {ι : Type*} [Fintype ι] {E' : ι → Type*} [∀ i, NormedAddCommGroup (E' i)] {f : α → ∀ i, E' i} : f =o[l] g' ↔ ∀ i, (fun x => f x i) =o[l] g' := by simp +contextual only [IsLittleO_def, isBigOWith_pi, le_of_lt] exact ⟨fun h i c hc => h hc i, fun h c hc i => h i hc⟩ theorem IsBigO.natCast_atTop {R : Type*} [Semiring R] [PartialOrder R] [IsStrictOrderedRing R] [Archimedean R] {f : R → E} {g : R → F} (h : f =O[atTop] g) : (fun (n : ℕ) => f n) =O[atTop] (fun n => g n) := IsBigO.comp_tendsto h tendsto_natCast_atTop_atTop theorem IsLittleO.natCast_atTop {R : Type*} [Semiring R] [PartialOrder R] [IsStrictOrderedRing R] [Archimedean R] {f : R → E} {g : R → F} (h : f =o[atTop] g) : (fun (n : ℕ) => f n) =o[atTop] (fun n => g n) := IsLittleO.comp_tendsto h tendsto_natCast_atTop_atTop theorem isBigO_atTop_iff_eventually_exists {α : Type*} [SemilatticeSup α] [Nonempty α] {f : α → E} {g : α → F} : f =O[atTop] g ↔ ∀ᶠ n₀ in atTop, ∃ c, ∀ n ≥ n₀, ‖f n‖ ≤ c * ‖g n‖ := by rw [isBigO_iff, exists_eventually_atTop] theorem isBigO_atTop_iff_eventually_exists_pos {α : Type*} [SemilatticeSup α] [Nonempty α] {f : α → G} {g : α → G'} : f =O[atTop] g ↔ ∀ᶠ n₀ in atTop, ∃ c > 0, ∀ n ≥ n₀, c * ‖f n‖ ≤ ‖g n‖ := by simp_rw [isBigO_iff'', ← exists_prop, Subtype.exists', exists_eventually_atTop] lemma isBigO_mul_iff_isBigO_div {f g h : α → 𝕜} (hf : ∀ᶠ x in l, f x ≠ 0) : (fun x ↦ f x * g x) =O[l] h ↔ g =O[l] (fun x ↦ h x / f x) := by rw [isBigO_iff', isBigO_iff'] refine ⟨fun ⟨c, hc, H⟩ ↦ ⟨c, hc, ?_⟩, fun ⟨c, hc, H⟩ ↦ ⟨c, hc, ?_⟩⟩ <;> · refine H.congr <| Eventually.mp hf <| Eventually.of_forall fun x hx ↦ ?_ rw [norm_mul, norm_div, ← mul_div_assoc, le_div_iff₀' (norm_pos_iff.mpr hx)] end Asymptotics open Asymptotics theorem summable_of_isBigO {ι E} [SeminormedAddCommGroup E] [CompleteSpace E] {f : ι → E} {g : ι → ℝ} (hg : Summable g) (h : f =O[cofinite] g) : Summable f := let ⟨_, hC⟩ := h.isBigOWith .of_norm_bounded_eventually (hg.abs.mul_left _) hC.bound theorem summable_of_isBigO_nat {E} [SeminormedAddCommGroup E] [CompleteSpace E] {f : ℕ → E} {g : ℕ → ℝ} (hg : Summable g) (h : f =O[atTop] g) : Summable f := summable_of_isBigO hg <| Nat.cofinite_eq_atTop.symm ▸ h lemma Asymptotics.IsBigO.comp_summable_norm {ι E F : Type*} [SeminormedAddCommGroup E] [SeminormedAddCommGroup F] {f : E → F} {g : ι → E} (hf : f =O[𝓝 0] id) (hg : Summable (‖g ·‖)) : Summable (‖f <| g ·‖) := summable_of_isBigO hg <| hf.norm_norm.comp_tendsto <| tendsto_zero_iff_norm_tendsto_zero.2 hg.tendsto_cofinite_zero lemma Summable.mul_tendsto_const {F ι : Type*} [NormedRing F] [NormMulClass F] [NormOneClass F] [CompleteSpace F] {f g : ι → F} (hf : Summable fun n ↦ ‖f n‖) {c : F} (hg : Tendsto g cofinite (𝓝 c)) : Summable fun n ↦ f n * g n := by apply summable_of_isBigO hf simpa using (isBigO_const_mul_self 1 f _).mul (hg.isBigO_one F) namespace OpenPartialHomeomorph variable {α : Type*} {β : Type*} [TopologicalSpace α] [TopologicalSpace β] variable {E : Type*} [Norm E] {F : Type*} [Norm F] /-- Transfer `IsBigOWith` over an `OpenPartialHomeomorph`. -/ theorem isBigOWith_congr (e : OpenPartialHomeomorph α β) {b : β} (hb : b ∈ e.target) {f : β → E} {g : β → F} {C : ℝ} : IsBigOWith C (𝓝 b) f g ↔ IsBigOWith C (𝓝 (e.symm b)) (f ∘ e) (g ∘ e) := ⟨fun h => h.comp_tendsto <| by have := e.continuousAt (e.map_target hb) rwa [ContinuousAt, e.rightInvOn hb] at this, fun h => (h.comp_tendsto (e.continuousAt_symm hb)).congr' rfl ((e.eventually_right_inverse hb).mono fun _ hx => congr_arg f hx) ((e.eventually_right_inverse hb).mono fun _ hx => congr_arg g hx)⟩ /-- Transfer `IsBigO` over an `OpenPartialHomeomorph`. -/ theorem isBigO_congr (e : OpenPartialHomeomorph α β) {b : β} (hb : b ∈ e.target) {f : β → E} {g : β → F} : f =O[𝓝 b] g ↔ (f ∘ e) =O[𝓝 (e.symm b)] (g ∘ e) := by simp only [IsBigO_def] exact exists_congr fun C => e.isBigOWith_congr hb /-- Transfer `IsLittleO` over an `OpenPartialHomeomorph`. -/ theorem isLittleO_congr (e : OpenPartialHomeomorph α β) {b : β} (hb : b ∈ e.target) {f : β → E} {g : β → F} : f =o[𝓝 b] g ↔ (f ∘ e) =o[𝓝 (e.symm b)] (g ∘ e) := by simp only [IsLittleO_def] exact forall₂_congr fun c _hc => e.isBigOWith_congr hb end OpenPartialHomeomorph namespace Homeomorph variable {α : Type*} {β : Type*} [TopologicalSpace α] [TopologicalSpace β] variable {E : Type*} [Norm E] {F : Type*} [Norm F] open Asymptotics /-- Transfer `IsBigOWith` over a `Homeomorph`. -/ theorem isBigOWith_congr (e : α ≃ₜ β) {b : β} {f : β → E} {g : β → F} {C : ℝ} : IsBigOWith C (𝓝 b) f g ↔ IsBigOWith C (𝓝 (e.symm b)) (f ∘ e) (g ∘ e) := e.toOpenPartialHomeomorph.isBigOWith_congr trivial /-- Transfer `IsBigO` over a `Homeomorph`. -/ theorem isBigO_congr (e : α ≃ₜ β) {b : β} {f : β → E} {g : β → F} : f =O[𝓝 b] g ↔ (f ∘ e) =O[𝓝 (e.symm b)] (g ∘ e) := by simp only [IsBigO_def] exact exists_congr fun C => e.isBigOWith_congr /-- Transfer `IsLittleO` over a `Homeomorph`. -/ theorem isLittleO_congr (e : α ≃ₜ β) {b : β} {f : β → E} {g : β → F} : f =o[𝓝 b] g ↔ (f ∘ e) =o[𝓝 (e.symm b)] (g ∘ e) := by simp only [IsLittleO_def] exact forall₂_congr fun c _hc => e.isBigOWith_congr end Homeomorph namespace ContinuousOn variable {α E F : Type*} [TopologicalSpace α] {s : Set α} {f : α → E} {c : F} section IsBigO variable [SeminormedAddGroup E] [Norm F] protected theorem isBigOWith_principal (hf : ContinuousOn f s) (hs : IsCompact s) (hc : ‖c‖ ≠ 0) : IsBigOWith (sSup (Norm.norm '' (f '' s)) / ‖c‖) (𝓟 s) f fun _ => c := by rw [isBigOWith_principal, div_mul_cancel₀ _ hc] exact fun x hx ↦ hs.image_of_continuousOn hf |>.image continuous_norm |>.isLUB_sSup (Set.image_nonempty.mpr <| Set.image_nonempty.mpr ⟨x, hx⟩) |>.left <| Set.mem_image_of_mem _ <| Set.mem_image_of_mem _ hx protected theorem isBigO_principal (hf : ContinuousOn f s) (hs : IsCompact s) (hc : ‖c‖ ≠ 0) : f =O[𝓟 s] fun _ => c := (hf.isBigOWith_principal hs hc).isBigO end IsBigO section IsBigORev variable [NormedAddGroup E] [SeminormedAddGroup F] protected theorem isBigOWith_rev_principal (hf : ContinuousOn f s) (hs : IsCompact s) (hC : ∀ i ∈ s, f i ≠ 0) (c : F) : IsBigOWith (‖c‖ / sInf (Norm.norm '' (f '' s))) (𝓟 s) (fun _ => c) f := by refine isBigOWith_principal.mpr fun x hx ↦ ?_ rw [mul_comm_div] replace hs := hs.image_of_continuousOn hf |>.image continuous_norm have h_sInf := hs.isGLB_sInf <| Set.image_nonempty.mpr <| Set.image_nonempty.mpr ⟨x, hx⟩ refine le_mul_of_one_le_right (norm_nonneg c) <| (one_le_div ?_).mpr <| h_sInf.1 <| Set.mem_image_of_mem _ <| Set.mem_image_of_mem _ hx obtain ⟨_, ⟨x, hx, hCx⟩, hnormCx⟩ := hs.sInf_mem h_sInf.nonempty rw [← hnormCx, ← hCx] exact (norm_ne_zero_iff.mpr (hC x hx)).symm.lt_of_le (norm_nonneg _) protected theorem isBigO_rev_principal (hf : ContinuousOn f s) (hs : IsCompact s) (hC : ∀ i ∈ s, f i ≠ 0) (c : F) : (fun _ => c) =O[𝓟 s] f := (hf.isBigOWith_rev_principal hs hC c).isBigO end IsBigORev end ContinuousOn /-- The (scalar) product of a sequence that tends to zero with a bounded one also tends to zero. -/ lemma NormedField.tendsto_zero_smul_of_tendsto_zero_of_bounded {ι 𝕜 𝔸 : Type*} [NormedDivisionRing 𝕜] [NormedAddCommGroup 𝔸] [Module 𝕜 𝔸] [IsBoundedSMul 𝕜 𝔸] {l : Filter ι} {ε : ι → 𝕜} {f : ι → 𝔸} (hε : Tendsto ε l (𝓝 0)) (hf : IsBoundedUnder (· ≤ ·) l (norm ∘ f)) : Tendsto (ε • f) l (𝓝 0) := by rw [← isLittleO_one_iff 𝕜] at hε ⊢ simpa using IsLittleO.smul_isBigO hε (hf.isBigO_const (one_ne_zero : (1 : 𝕜) ≠ 0))
.lake/packages/mathlib/Mathlib/Analysis/Asymptotics/AsymptoticEquivalent.lean
import Mathlib.Analysis.Asymptotics.Theta /-! # Asymptotic equivalence In this file, we define the relation `IsEquivalent l u v`, which means that `u-v` is little o of `v` along the filter `l`. Unlike `Is(Little|Big)O` relations, this one requires `u` and `v` to have the same codomain `β`. While the definition only requires `β` to be a `NormedAddCommGroup`, most interesting properties require it to be a `NormedField`. ## Notation We introduce the notation `u ~[l] v := IsEquivalent l u v`, which you can use by opening the `Asymptotics` locale. ## Main results If `β` is a `NormedAddCommGroup` : - `_ ~[l] _` is an equivalence relation - Equivalent statements for `u ~[l] const _ c` : - If `c ≠ 0`, this is true iff `Tendsto u l (𝓝 c)` (see `isEquivalent_const_iff_tendsto`) - For `c = 0`, this is true iff `u =ᶠ[l] 0` (see `isEquivalent_zero_iff_eventually_zero`) If `β` is a `NormedField` : - Alternative characterization of the relation (see `isEquivalent_iff_exists_eq_mul`) : `u ~[l] v ↔ ∃ (φ : α → β) (hφ : Tendsto φ l (𝓝 1)), u =ᶠ[l] φ * v` - Provided some non-vanishing hypothesis, this can be seen as `u ~[l] v ↔ Tendsto (u/v) l (𝓝 1)` (see `isEquivalent_iff_tendsto_one`) - For any constant `c`, `u ~[l] v` implies `Tendsto u l (𝓝 c) ↔ Tendsto v l (𝓝 c)` (see `IsEquivalent.tendsto_nhds_iff`) - `*` and `/` are compatible with `_ ~[l] _` (see `IsEquivalent.mul` and `IsEquivalent.div`) If `β` is a `NormedLinearOrderedField` : - If `u ~[l] v`, we have `Tendsto u l atTop ↔ Tendsto v l atTop` (see `IsEquivalent.tendsto_atTop_iff`) ## Implementation Notes Note that `IsEquivalent` takes the parameters `(l : Filter α) (u v : α → β)` in that order. This is to enable `calc` support, as `calc` requires that the last two explicit arguments are `u v`. -/ namespace Asymptotics open Filter Function open Topology section NormedAddCommGroup variable {α β : Type*} [NormedAddCommGroup β] /-- Two functions `u` and `v` are said to be asymptotically equivalent along a filter `l` (denoted as `u ~[l] v` in the `Asymptotics` namespace) when `u x - v x = o(v x)` as `x` converges along `l`. -/ def IsEquivalent (l : Filter α) (u v : α → β) := (u - v) =o[l] v @[inherit_doc] scoped notation:50 u " ~[" l:50 "] " v:50 => Asymptotics.IsEquivalent l u v variable {u v w : α → β} {l : Filter α} theorem IsEquivalent.isLittleO (h : u ~[l] v) : (u - v) =o[l] v := h nonrec theorem IsEquivalent.isBigO (h : u ~[l] v) : u =O[l] v := (IsBigO.congr_of_sub h.isBigO.symm).mp (isBigO_refl _ _) theorem IsEquivalent.isBigO_symm (h : u ~[l] v) : v =O[l] u := by convert h.isLittleO.right_isBigO_add simp theorem IsEquivalent.isTheta (h : u ~[l] v) : u =Θ[l] v := ⟨h.isBigO, h.isBigO_symm⟩ theorem IsEquivalent.isTheta_symm (h : u ~[l] v) : v =Θ[l] u := ⟨h.isBigO_symm, h.isBigO⟩ @[refl] theorem IsEquivalent.refl : u ~[l] u := by rw [IsEquivalent, sub_self] exact isLittleO_zero _ _ @[symm] theorem IsEquivalent.symm (h : u ~[l] v) : v ~[l] u := (h.isLittleO.trans_isBigO h.isBigO_symm).symm @[trans] theorem IsEquivalent.trans {l : Filter α} {u v w : α → β} (huv : u ~[l] v) (hvw : v ~[l] w) : u ~[l] w := (huv.isLittleO.trans_isBigO hvw.isBigO).triangle hvw.isLittleO theorem IsEquivalent.congr_left {u v w : α → β} {l : Filter α} (huv : u ~[l] v) (huw : u =ᶠ[l] w) : w ~[l] v := huv.congr' (huw.sub (EventuallyEq.refl _ _)) (EventuallyEq.refl _ _) theorem IsEquivalent.congr_right {u v w : α → β} {l : Filter α} (huv : u ~[l] v) (hvw : v =ᶠ[l] w) : u ~[l] w := (huv.symm.congr_left hvw).symm theorem isEquivalent_zero_iff_eventually_zero : u ~[l] 0 ↔ u =ᶠ[l] 0 := by rw [IsEquivalent, sub_zero] exact isLittleO_zero_right_iff theorem isEquivalent_zero_iff_isBigO_zero : u ~[l] 0 ↔ u =O[l] (0 : α → β) := by refine ⟨IsEquivalent.isBigO, fun h ↦ ?_⟩ rw [isEquivalent_zero_iff_eventually_zero, eventuallyEq_iff_exists_mem] exact ⟨{ x : α | u x = 0 }, isBigO_zero_right_iff.mp h, fun x hx ↦ hx⟩ theorem isEquivalent_const_iff_tendsto {c : β} (h : c ≠ 0) : u ~[l] const _ c ↔ Tendsto u l (𝓝 c) := by simp +unfoldPartialApp only [IsEquivalent, const, isLittleO_const_iff h] constructor <;> intro h · have := h.sub (tendsto_const_nhds (x := -c)) simp only [Pi.sub_apply, sub_neg_eq_add, sub_add_cancel, zero_add] at this exact this · have := h.sub (tendsto_const_nhds (x := c)) rwa [sub_self] at this theorem IsEquivalent.tendsto_const {c : β} (hu : u ~[l] const _ c) : Tendsto u l (𝓝 c) := by rcases em <| c = 0 with rfl | h · exact (tendsto_congr' <| isEquivalent_zero_iff_eventually_zero.mp hu).mpr tendsto_const_nhds · exact (isEquivalent_const_iff_tendsto h).mp hu theorem IsEquivalent.tendsto_nhds {c : β} (huv : u ~[l] v) (hu : Tendsto u l (𝓝 c)) : Tendsto v l (𝓝 c) := by by_cases h : c = 0 · subst c rw [← isLittleO_one_iff ℝ] at hu ⊢ simpa using (huv.symm.isLittleO.trans hu).add hu · rw [← isEquivalent_const_iff_tendsto h] at hu ⊢ exact huv.symm.trans hu theorem IsEquivalent.tendsto_nhds_iff {c : β} (huv : u ~[l] v) : Tendsto u l (𝓝 c) ↔ Tendsto v l (𝓝 c) := ⟨huv.tendsto_nhds, huv.symm.tendsto_nhds⟩ theorem IsEquivalent.add_isLittleO (huv : u ~[l] v) (hwv : w =o[l] v) : u + w ~[l] v := by simpa only [IsEquivalent, add_sub_right_comm] using huv.add hwv theorem IsEquivalent.sub_isLittleO (huv : u ~[l] v) (hwv : w =o[l] v) : u - w ~[l] v := by simpa only [sub_eq_add_neg] using huv.add_isLittleO hwv.neg_left theorem IsLittleO.add_isEquivalent (hu : u =o[l] w) (hv : v ~[l] w) : u + v ~[l] w := add_comm v u ▸ hv.add_isLittleO hu theorem IsEquivalent.add_const_of_norm_tendsto_atTop {c : β} (huv : u ~[l] v) (hv : Tendsto (norm ∘ v) l atTop) : (u · + c) ~[l] v := huv.add_isLittleO <| isLittleO_const_left.mpr (Or.inr hv) theorem IsEquivalent.const_add_of_norm_tendsto_atTop {c : β} (huv : u ~[l] v) (hv : Tendsto (norm ∘ v) l atTop) : (c + u ·) ~[l] v := (isLittleO_const_left.mpr (Or.inr hv)).add_isEquivalent huv theorem IsLittleO.isEquivalent (huv : (u - v) =o[l] v) : u ~[l] v := huv theorem IsEquivalent.neg (huv : u ~[l] v) : (fun x ↦ -u x) ~[l] fun x ↦ -v x := by rw [IsEquivalent] convert huv.isLittleO.neg_left.neg_right simp [neg_add_eq_sub] end NormedAddCommGroup open Asymptotics section NormedField variable {α β : Type*} [NormedField β] {u v : α → β} {l : Filter α} theorem isEquivalent_iff_exists_eq_mul : u ~[l] v ↔ ∃ (φ : α → β) (_ : Tendsto φ l (𝓝 1)), u =ᶠ[l] φ * v := by rw [IsEquivalent, isLittleO_iff_exists_eq_mul] constructor <;> rintro ⟨φ, hφ, h⟩ <;> [refine ⟨φ + 1, ?_, ?_⟩; refine ⟨φ - 1, ?_, ?_⟩] · conv in 𝓝 _ => rw [← zero_add (1 : β)] exact hφ.add tendsto_const_nhds · convert h.fun_add (EventuallyEq.refl l v) <;> simp [add_mul] · conv in 𝓝 _ => rw [← sub_self (1 : β)] exact hφ.sub tendsto_const_nhds · convert h.fun_sub (EventuallyEq.refl l v); simp [sub_mul] theorem IsEquivalent.exists_eq_mul (huv : u ~[l] v) : ∃ (φ : α → β) (_ : Tendsto φ l (𝓝 1)), u =ᶠ[l] φ * v := isEquivalent_iff_exists_eq_mul.mp huv theorem isEquivalent_of_tendsto_one (hz : ∀ᶠ x in l, v x = 0 → u x = 0) (huv : Tendsto (u / v) l (𝓝 1)) : u ~[l] v := by rw [isEquivalent_iff_exists_eq_mul] exact ⟨u / v, huv, hz.mono fun x hz' ↦ (div_mul_cancel_of_imp hz').symm⟩ theorem isEquivalent_of_tendsto_one' (hz : ∀ x, v x = 0 → u x = 0) (huv : Tendsto (u / v) l (𝓝 1)) : u ~[l] v := isEquivalent_of_tendsto_one (Eventually.of_forall hz) huv theorem isEquivalent_iff_tendsto_one (hz : ∀ᶠ x in l, v x ≠ 0) : u ~[l] v ↔ Tendsto (u / v) l (𝓝 1) := by constructor · intro hequiv have := hequiv.isLittleO.tendsto_div_nhds_zero simp only [Pi.sub_apply, sub_div] at this have key : Tendsto (fun x ↦ v x / v x) l (𝓝 1) := (tendsto_congr' <| hz.mono fun x hnz ↦ @div_self _ _ (v x) hnz).mpr tendsto_const_nhds convert this.add key · simp · simp · exact isEquivalent_of_tendsto_one (hz.mono fun x hnvz hz ↦ (hnvz hz).elim) end NormedField section SMul theorem IsEquivalent.smul {α E 𝕜 : Type*} [NormedField 𝕜] [NormedAddCommGroup E] [NormedSpace 𝕜 E] {a b : α → 𝕜} {u v : α → E} {l : Filter α} (hab : a ~[l] b) (huv : u ~[l] v) : (fun x ↦ a x • u x) ~[l] fun x ↦ b x • v x := by rcases hab.exists_eq_mul with ⟨φ, hφ, habφ⟩ have : ((fun x ↦ a x • u x) - (fun x ↦ b x • v x)) =ᶠ[l] fun x ↦ b x • (φ x • u x - v x) := by convert (habφ.comp₂ (· • ·) <| EventuallyEq.refl _ u).fun_sub (EventuallyEq.refl _ fun x ↦ b x • v x) using 1 ext rw [Pi.mul_apply, mul_comm, mul_smul, ← smul_sub] refine (isLittleO_congr this.symm <| EventuallyEq.rfl).mp ((isBigO_refl b l).smul_isLittleO ?_) rcases huv.isBigO.exists_pos with ⟨C, hC, hCuv⟩ rw [IsEquivalent] at * rw [isLittleO_iff] at * rw [IsBigOWith] at hCuv simp only [Metric.tendsto_nhds, dist_eq_norm] at hφ intro c hc specialize hφ (c / 2 / C) (div_pos (div_pos hc zero_lt_two) hC) specialize huv (div_pos hc zero_lt_two) refine hφ.mp (huv.mp <| hCuv.mono fun x hCuvx huvx hφx ↦ ?_) have key := calc ‖φ x - 1‖ * ‖u x‖ ≤ c / 2 / C * ‖u x‖ := by gcongr _ ≤ c / 2 / C * (C * ‖v x‖) := by gcongr _ = c / 2 * ‖v x‖ := by field calc ‖((fun x : α ↦ φ x • u x) - v) x‖ = ‖(φ x - 1) • u x + (u x - v x)‖ := by simp [sub_smul, sub_add] _ ≤ ‖(φ x - 1) • u x‖ + ‖u x - v x‖ := norm_add_le _ _ _ = ‖φ x - 1‖ * ‖u x‖ + ‖u x - v x‖ := by rw [norm_smul] _ ≤ c / 2 * ‖v x‖ + ‖u x - v x‖ := by gcongr _ ≤ c / 2 * ‖v x‖ + c / 2 * ‖v x‖ := by gcongr; exact huvx _ = c * ‖v x‖ := by ring end SMul section mul_inv variable {α ι β : Type*} [NormedField β] {t u v w : α → β} {l : Filter α} protected theorem IsEquivalent.mul (htu : t ~[l] u) (hvw : v ~[l] w) : t * v ~[l] u * w := htu.smul hvw theorem IsEquivalent.listProd {L : List ι} {f g : ι → α → β} (h : ∀ i ∈ L, f i ~[l] g i) : (fun x ↦ (L.map (f · x)).prod) ~[l] (fun x ↦ (L.map (g · x)).prod) := by induction L with | nil => simp [IsEquivalent.refl] | cons i L ihL => simp only [List.forall_mem_cons, List.map_cons, List.prod_cons] at h ⊢ exact h.1.mul (ihL h.2) theorem IsEquivalent.multisetProd {s : Multiset ι} {f g : ι → α → β} (h : ∀ i ∈ s, f i ~[l] g i) : (fun x ↦ (s.map (f · x)).prod) ~[l] (fun x ↦ (s.map (g · x)).prod) := by obtain ⟨l, rfl⟩ : ∃ l : List ι, ↑l = s := Quotient.mk_surjective s exact listProd h theorem IsEquivalent.finsetProd {s : Finset ι} {f g : ι → α → β} (h : ∀ i ∈ s, f i ~[l] g i) : (∏ i ∈ s, f i ·) ~[l] (∏ i ∈ s, g i ·) := multisetProd h protected theorem IsEquivalent.inv (huv : u ~[l] v) : u⁻¹ ~[l] v⁻¹ := by rw [isEquivalent_iff_exists_eq_mul] at * rcases huv with ⟨φ, hφ, h⟩ rw [← inv_one] refine ⟨fun x ↦ (φ x)⁻¹, Tendsto.inv₀ hφ (by simp), ?_⟩ convert h.fun_inv simp [mul_comm] protected theorem IsEquivalent.div (htu : t ~[l] u) (hvw : v ~[l] w) : t / v ~[l] u / w := by simpa only [div_eq_mul_inv] using htu.mul hvw.inv protected theorem IsEquivalent.pow (h : t ~[l] u) (n : ℕ) : t ^ n ~[l] u ^ n := by induction n with | zero => simpa using IsEquivalent.refl | succ _ ih => simpa [pow_succ] using ih.mul h protected theorem IsEquivalent.zpow (h : t ~[l] u) (z : ℤ) : t ^ z ~[l] u ^ z := by match z with | Int.ofNat _ => simpa using h.pow _ | Int.negSucc _ => simpa using (h.pow _).inv end mul_inv section NormedLinearOrderedField variable {α β : Type*} [NormedField β] [LinearOrder β] [IsStrictOrderedRing β] {u v : α → β} {l : Filter α} theorem IsEquivalent.tendsto_atTop [OrderTopology β] (huv : u ~[l] v) (hu : Tendsto u l atTop) : Tendsto v l atTop := let ⟨φ, hφ, h⟩ := huv.symm.exists_eq_mul Tendsto.congr' h.symm (mul_comm u φ ▸ hu.atTop_mul_pos zero_lt_one hφ) theorem IsEquivalent.tendsto_atTop_iff [OrderTopology β] (huv : u ~[l] v) : Tendsto u l atTop ↔ Tendsto v l atTop := ⟨huv.tendsto_atTop, huv.symm.tendsto_atTop⟩ theorem IsEquivalent.tendsto_atBot [OrderTopology β] (huv : u ~[l] v) (hu : Tendsto u l atBot) : Tendsto v l atBot := by convert tendsto_neg_atTop_atBot.comp (huv.neg.tendsto_atTop <| tendsto_neg_atBot_atTop.comp hu) ext simp theorem IsEquivalent.tendsto_atBot_iff [OrderTopology β] (huv : u ~[l] v) : Tendsto u l atBot ↔ Tendsto v l atBot := ⟨huv.tendsto_atBot, huv.symm.tendsto_atBot⟩ end NormedLinearOrderedField section Real theorem IsEquivalent.add_add_of_nonneg {α : Type*} {u v t w : α → ℝ} {l : Filter α} (hu : 0 ≤ v) (hw : 0 ≤ w) (htu : u ~[l] v) (hvw : t ~[l] w) : u + t ~[l] v + w := by simp only [IsEquivalent, add_sub_add_comm] change (fun x ↦ (u - v) x + (t - w) x) =o[l] (fun x ↦ v x + w x) conv => enter [3, x]; rw [← abs_eq_self.mpr (hu x), ← abs_eq_self.mpr (hw x)] simpa [← Real.norm_eq_abs] using .add_add htu hvw end Real end Asymptotics open Filter Asymptotics open Asymptotics variable {α β β₂ : Type*} [NormedAddCommGroup β] [Norm β₂] {l : Filter α} theorem Filter.EventuallyEq.isEquivalent {u v : α → β} (h : u =ᶠ[l] v) : u ~[l] v := IsEquivalent.congr_right (isLittleO_refl_left _ _) h @[trans] theorem Filter.EventuallyEq.trans_isEquivalent {f g₁ g₂ : α → β} (h : f =ᶠ[l] g₁) (h₂ : g₁ ~[l] g₂) : f ~[l] g₂ := h.isEquivalent.trans h₂ namespace Asymptotics instance transIsEquivalentIsEquivalent : @Trans (α → β) (α → β) (α → β) (IsEquivalent l) (IsEquivalent l) (IsEquivalent l) where trans := IsEquivalent.trans instance transEventuallyEqIsEquivalent : @Trans (α → β) (α → β) (α → β) (EventuallyEq l) (IsEquivalent l) (IsEquivalent l) where trans := EventuallyEq.trans_isEquivalent @[trans] theorem IsEquivalent.trans_eventuallyEq {f g₁ g₂ : α → β} (h : f ~[l] g₁) (h₂ : g₁ =ᶠ[l] g₂) : f ~[l] g₂ := h.trans h₂.isEquivalent instance transIsEquivalentEventuallyEq : @Trans (α → β) (α → β) (α → β) (IsEquivalent l) (EventuallyEq l) (IsEquivalent l) where trans := IsEquivalent.trans_eventuallyEq @[trans] theorem IsEquivalent.trans_isBigO {f g₁ : α → β} {g₂ : α → β₂} (h : f ~[l] g₁) (h₂ : g₁ =O[l] g₂) : f =O[l] g₂ := IsBigO.trans h.isBigO h₂ instance transIsEquivalentIsBigO : @Trans (α → β) (α → β) (α → β₂) (IsEquivalent l) (IsBigO l) (IsBigO l) where trans := IsEquivalent.trans_isBigO @[trans] theorem IsBigO.trans_isEquivalent {f : α → β₂} {g₁ g₂ : α → β} (h : f =O[l] g₁) (h₂ : g₁ ~[l] g₂) : f =O[l] g₂ := IsBigO.trans h h₂.isBigO instance transIsBigOIsEquivalent : @Trans (α → β₂) (α → β) (α → β) (IsBigO l) (IsEquivalent l) (IsBigO l) where trans := IsBigO.trans_isEquivalent @[trans] theorem IsEquivalent.trans_isLittleO {f g₁ : α → β} {g₂ : α → β₂} (h : f ~[l] g₁) (h₂ : g₁ =o[l] g₂) : f =o[l] g₂ := IsBigO.trans_isLittleO h.isBigO h₂ instance transIsEquivalentIsLittleO : @Trans (α → β) (α → β) (α → β₂) (IsEquivalent l) (IsLittleO l) (IsLittleO l) where trans := IsEquivalent.trans_isLittleO @[trans] theorem IsLittleO.trans_isEquivalent {f : α → β₂} {g₁ g₂ : α → β} (h : f =o[l] g₁) (h₂ : g₁ ~[l] g₂) : f =o[l] g₂ := IsLittleO.trans_isBigO h h₂.isBigO instance transIsLittleOIsEquivalent : @Trans (α → β₂) (α → β) (α → β) (IsLittleO l) (IsEquivalent l) (IsLittleO l) where trans := IsLittleO.trans_isEquivalent @[trans] theorem IsEquivalent.trans_isTheta {f g₁ : α → β} {g₂ : α → β₂} (h : f ~[l] g₁) (h₂ : g₁ =Θ[l] g₂) : f =Θ[l] g₂ := IsTheta.trans h.isTheta h₂ instance transIsEquivalentIsTheta : @Trans (α → β) (α → β) (α → β₂) (IsEquivalent l) (IsTheta l) (IsTheta l) where trans := IsEquivalent.trans_isTheta @[trans] theorem IsTheta.trans_isEquivalent {f : α → β₂} {g₁ g₂ : α → β} (h : f =Θ[l] g₁) (h₂ : g₁ ~[l] g₂) : f =Θ[l] g₂ := IsTheta.trans h h₂.isTheta instance transIsThetaIsEquivalent : @Trans (α → β₂) (α → β) (α → β) (IsTheta l) (IsEquivalent l) (IsTheta l) where trans := IsTheta.trans_isEquivalent theorem IsEquivalent.comp_tendsto {α₂ : Type*} {f g : α₂ → β} {l' : Filter α₂} (hfg : f ~[l'] g) {k : α → α₂} (hk : Filter.Tendsto k l l') : (f ∘ k) ~[l] (g ∘ k) := IsLittleO.comp_tendsto hfg hk @[simp] theorem isEquivalent_map {α₂ : Type*} {f g : α₂ → β} {k : α → α₂} : f ~[Filter.map k l] g ↔ (f ∘ k) ~[l] (g ∘ k) := isLittleO_map theorem IsEquivalent.mono {f g : α → β} {l' : Filter α} (h : f ~[l'] g) (hl : l ≤ l') : f ~[l] g := IsLittleO.mono h hl end Asymptotics
.lake/packages/mathlib/Mathlib/Analysis/Asymptotics/Completion.lean
import Mathlib.Analysis.Asymptotics.Theta import Mathlib.Analysis.Normed.Group.Completion /-! # Asymptotics in the completion of a normed space In this file we prove lemmas relating `f = O(g)` etc for composition of functions with coercion of a seminormed group to its completion. -/ variable {α E F : Type*} [Norm E] [SeminormedAddCommGroup F] {f : α → E} {g : α → F} {l : Filter α} local postfix:100 "̂" => UniformSpace.Completion open UniformSpace.Completion namespace Asymptotics @[simp, norm_cast] lemma isBigO_completion_left : (fun x ↦ g x : α → F̂) =O[l] f ↔ g =O[l] f := by simp only [isBigO_iff, norm_coe] @[simp, norm_cast] lemma isBigO_completion_right : f =O[l] (fun x ↦ g x : α → F̂) ↔ f =O[l] g := by simp only [isBigO_iff, norm_coe] @[simp, norm_cast] lemma isTheta_completion_left : (fun x ↦ g x : α → F̂) =Θ[l] f ↔ g =Θ[l] f := and_congr isBigO_completion_left isBigO_completion_right @[simp, norm_cast] lemma isTheta_completion_right : f =Θ[l] (fun x ↦ g x : α → F̂) ↔ f =Θ[l] g := and_congr isBigO_completion_right isBigO_completion_left @[simp, norm_cast] lemma isLittleO_completion_left : (fun x ↦ g x : α → F̂) =o[l] f ↔ g =o[l] f := by simp only [isLittleO_iff, norm_coe] @[simp, norm_cast] lemma isLittleO_completion_right : f =o[l] (fun x ↦ g x : α → F̂) ↔ f =o[l] g := by simp only [isLittleO_iff, norm_coe] end Asymptotics
.lake/packages/mathlib/Mathlib/Analysis/Asymptotics/SpecificAsymptotics.lean
import Mathlib.Analysis.Asymptotics.AsymptoticEquivalent import Mathlib.Analysis.SpecialFunctions.Pow.Continuity /-! # A collection of specific asymptotic results This file contains specific lemmas about asymptotics which don't have their place in the general theory developed in `Mathlib/Analysis/Asymptotics/Defs.lean` and `Mathlib/Analysis/Asymptotics/Lemmas.lean`. -/ open Filter Asymptotics open Topology section NormedField /-- If `f : 𝕜 → E` is bounded in a punctured neighborhood of `a`, then `f(x) = o((x - a)⁻¹)` as `x → a`, `x ≠ a`. -/ theorem Filter.IsBoundedUnder.isLittleO_sub_self_inv {𝕜 E : Type*} [NormedField 𝕜] [Norm E] {a : 𝕜} {f : 𝕜 → E} (h : IsBoundedUnder (· ≤ ·) (𝓝[≠] a) (norm ∘ f)) : f =o[𝓝[≠] a] fun x => (x - a)⁻¹ := by refine (h.isBigO_const (one_ne_zero' ℝ)).trans_isLittleO (isLittleO_const_left.2 <| Or.inr ?_) simp only [Function.comp_def, norm_inv] exact (tendsto_norm_sub_self_nhdsNE a).inv_tendsto_nhdsGT_zero end NormedField section LinearOrderedField variable {𝕜 : Type*} [Field 𝕜] [LinearOrder 𝕜] [IsStrictOrderedRing 𝕜] theorem pow_div_pow_eventuallyEq_atTop {p q : ℕ} : (fun x : 𝕜 => x ^ p / x ^ q) =ᶠ[atTop] fun x => x ^ ((p : ℤ) - q) := by apply (eventually_gt_atTop (0 : 𝕜)).mono fun x hx => _ intro x hx simp [zpow_sub₀ hx.ne'] theorem pow_div_pow_eventuallyEq_atBot {p q : ℕ} : (fun x : 𝕜 => x ^ p / x ^ q) =ᶠ[atBot] fun x => x ^ ((p : ℤ) - q) := by apply (eventually_lt_atBot (0 : 𝕜)).mono fun x hx => _ intro x hx simp [zpow_sub₀ hx.ne] theorem tendsto_pow_div_pow_atTop_atTop {p q : ℕ} (hpq : q < p) : Tendsto (fun x : 𝕜 => x ^ p / x ^ q) atTop atTop := by rw [tendsto_congr' pow_div_pow_eventuallyEq_atTop] apply tendsto_zpow_atTop_atTop cutsat theorem tendsto_pow_div_pow_atTop_zero [TopologicalSpace 𝕜] [OrderTopology 𝕜] {p q : ℕ} (hpq : p < q) : Tendsto (fun x : 𝕜 => x ^ p / x ^ q) atTop (𝓝 0) := by rw [tendsto_congr' pow_div_pow_eventuallyEq_atTop] apply tendsto_zpow_atTop_zero cutsat end LinearOrderedField section NormedLinearOrderedField variable {𝕜 : Type*} [NormedField 𝕜] theorem Asymptotics.isLittleO_pow_pow_atTop_of_lt [LinearOrder 𝕜] [IsStrictOrderedRing 𝕜] [OrderTopology 𝕜] {p q : ℕ} (hpq : p < q) : (fun x : 𝕜 => x ^ p) =o[atTop] fun x => x ^ q := by refine (isLittleO_iff_tendsto' ?_).mpr (tendsto_pow_div_pow_atTop_zero hpq) exact (eventually_gt_atTop 0).mono fun x hx hxq => (pow_ne_zero q hx.ne' hxq).elim theorem Asymptotics.IsBigO.trans_tendsto_norm_atTop {α : Type*} {u v : α → 𝕜} {l : Filter α} (huv : u =O[l] v) (hu : Tendsto (fun x => ‖u x‖) l atTop) : Tendsto (fun x => ‖v x‖) l atTop := by rcases huv.exists_pos with ⟨c, hc, hcuv⟩ rw [IsBigOWith] at hcuv convert Tendsto.atTop_div_const hc (tendsto_atTop_mono' l hcuv hu) rw [mul_div_cancel_left₀ _ hc.ne.symm] end NormedLinearOrderedField section Real theorem Asymptotics.IsEquivalent.rpow {α : Type*} {u v : α → ℝ} {l : Filter α} (hv : 0 ≤ v) (h : u ~[l] v) {r : ℝ} : u ^ r ~[l] v ^ r := by obtain ⟨φ, hφ, huφv⟩ := IsEquivalent.exists_eq_mul h rw [isEquivalent_iff_exists_eq_mul] have hφr : Tendsto ((fun x ↦ x ^ r) ∘ φ) l (𝓝 1) := by rw [← Real.one_rpow r] exact Tendsto.comp (Real.continuousAt_rpow_const _ _ (by left; norm_num)) hφ use (· ^ r) ∘ φ, hφr conv => enter [3]; change fun x ↦ φ x ^ r * v x ^ r filter_upwards [Tendsto.eventually_const_lt (zero_lt_one) hφ, huφv] with x hφ_pos huv' simp [← Real.mul_rpow (le_of_lt hφ_pos) (hv x), huv'] open Finset theorem Asymptotics.IsLittleO.sum_range {α : Type*} [NormedAddCommGroup α] {f : ℕ → α} {g : ℕ → ℝ} (h : f =o[atTop] g) (hg : 0 ≤ g) (h'g : Tendsto (fun n => ∑ i ∈ range n, g i) atTop atTop) : (fun n => ∑ i ∈ range n, f i) =o[atTop] fun n => ∑ i ∈ range n, g i := by have A : ∀ i, ‖g i‖ = g i := fun i => Real.norm_of_nonneg (hg i) have B : ∀ n, ‖∑ i ∈ range n, g i‖ = ∑ i ∈ range n, g i := fun n => by rwa [Real.norm_eq_abs, abs_sum_of_nonneg'] apply isLittleO_iff.2 fun ε εpos => _ intro ε εpos obtain ⟨N, hN⟩ : ∃ N : ℕ, ∀ b : ℕ, N ≤ b → ‖f b‖ ≤ ε / 2 * g b := by simpa only [A, eventually_atTop] using isLittleO_iff.mp h (half_pos εpos) have : (fun _ : ℕ => ∑ i ∈ range N, f i) =o[atTop] fun n : ℕ => ∑ i ∈ range n, g i := by apply isLittleO_const_left.2 exact Or.inr (h'g.congr fun n => (B n).symm) filter_upwards [isLittleO_iff.1 this (half_pos εpos), Ici_mem_atTop N] with n hn Nn calc ‖∑ i ∈ range n, f i‖ = ‖(∑ i ∈ range N, f i) + ∑ i ∈ Ico N n, f i‖ := by rw [sum_range_add_sum_Ico _ Nn] _ ≤ ‖∑ i ∈ range N, f i‖ + ‖∑ i ∈ Ico N n, f i‖ := norm_add_le _ _ _ ≤ ‖∑ i ∈ range N, f i‖ + ∑ i ∈ Ico N n, ε / 2 * g i := (add_le_add le_rfl (norm_sum_le_of_le _ fun i hi => hN _ (mem_Ico.1 hi).1)) _ ≤ ‖∑ i ∈ range N, f i‖ + ∑ i ∈ range n, ε / 2 * g i := by gcongr · exact fun i _ _ ↦ mul_nonneg (half_pos εpos).le (hg i) · rw [range_eq_Ico] exact Ico_subset_Ico (zero_le _) le_rfl _ ≤ ε / 2 * ‖∑ i ∈ range n, g i‖ + ε / 2 * ∑ i ∈ range n, g i := by rw [← mul_sum]; gcongr _ = ε * ‖∑ i ∈ range n, g i‖ := by simp only [B] ring theorem Asymptotics.isLittleO_sum_range_of_tendsto_zero {α : Type*} [NormedAddCommGroup α] {f : ℕ → α} (h : Tendsto f atTop (𝓝 0)) : (fun n => ∑ i ∈ range n, f i) =o[atTop] fun n => (n : ℝ) := by have := ((isLittleO_one_iff ℝ).2 h).sum_range fun i => zero_le_one simp only [sum_const, card_range, Nat.smul_one_eq_cast] at this exact this tendsto_natCast_atTop_atTop /-- The Cesaro average of a converging sequence converges to the same limit. -/ theorem Filter.Tendsto.cesaro_smul {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] {u : ℕ → E} {l : E} (h : Tendsto u atTop (𝓝 l)) : Tendsto (fun n : ℕ => (n⁻¹ : ℝ) • ∑ i ∈ range n, u i) atTop (𝓝 l) := by rw [← tendsto_sub_nhds_zero_iff, ← isLittleO_one_iff ℝ] have := Asymptotics.isLittleO_sum_range_of_tendsto_zero (tendsto_sub_nhds_zero_iff.2 h) apply ((isBigO_refl (fun n : ℕ => (n : ℝ)⁻¹) atTop).smul_isLittleO this).congr' _ _ · filter_upwards [Ici_mem_atTop 1] with n npos have nposℝ : (0 : ℝ) < n := Nat.cast_pos.2 npos simp only [smul_sub, sum_sub_distrib, sum_const, card_range, sub_right_inj] rw [← Nat.cast_smul_eq_nsmul ℝ, smul_smul, inv_mul_cancel₀ nposℝ.ne', one_smul] · filter_upwards [Ici_mem_atTop 1] with n npos have nposℝ : (0 : ℝ) < n := Nat.cast_pos.2 npos rw [Algebra.id.smul_eq_mul, inv_mul_cancel₀ nposℝ.ne'] /-- The Cesaro average of a converging sequence converges to the same limit. -/ theorem Filter.Tendsto.cesaro {u : ℕ → ℝ} {l : ℝ} (h : Tendsto u atTop (𝓝 l)) : Tendsto (fun n : ℕ => (n⁻¹ : ℝ) * ∑ i ∈ range n, u i) atTop (𝓝 l) := h.cesaro_smul end Real section NormedLinearOrderedField variable {R : Type*} [NormedField R] [LinearOrder R] [IsStrictOrderedRing R] [OrderTopology R] [FloorRing R] theorem Asymptotics.isEquivalent_nat_floor : (fun (x : R) ↦ ↑⌊x⌋₊) ~[atTop] (fun x ↦ x) := by refine isEquivalent_of_tendsto_one ?_ tendsto_nat_floor_div_atTop filter_upwards with x hx using by rw [hx, Nat.floor_zero, Nat.cast_eq_zero] theorem Asymptotics.isEquivalent_nat_ceil : (fun (x : R) ↦ ↑⌈x⌉₊) ~[atTop] (fun x ↦ x) := by refine isEquivalent_of_tendsto_one ?_ tendsto_nat_ceil_div_atTop filter_upwards with x hx using by rw [hx, Nat.ceil_zero, Nat.cast_eq_zero] end NormedLinearOrderedField
.lake/packages/mathlib/Mathlib/Analysis/Asymptotics/Defs.lean
import Mathlib.Analysis.Normed.Field.Basic /-! # Asymptotics We introduce these relations: * `IsBigOWith c l f g` : "f is big O of g along l with constant c"; * `f =O[l] g` : "f is big O of g along l"; * `f =o[l] g` : "f is little o of g along l". Here `l` is any filter on the domain of `f` and `g`, which are assumed to be the same. The codomains of `f` and `g` do not need to be the same; all that is needed is that there is a norm associated with these types, and it is the norm that is compared asymptotically. The relation `IsBigOWith c` is introduced to factor out common algebraic arguments in the proofs of similar properties of `IsBigO` and `IsLittleO`. Usually proofs outside of this file should use `IsBigO` instead. Often the ranges of `f` and `g` will be the real numbers, in which case the norm is the absolute value. In general, we have `f =O[l] g ↔ (fun x ↦ ‖f x‖) =O[l] (fun x ↦ ‖g x‖)`, and similarly for `IsLittleO`. But our setup allows us to use the notions e.g. with functions to the integers, rationals, complex numbers, or any normed vector space without mentioning the norm explicitly. If `f` and `g` are functions to a normed field like the reals or complex numbers and `g` is always nonzero, we have `f =o[l] g ↔ Tendsto (fun x ↦ f x / (g x)) l (𝓝 0)`. In fact, the right-to-left direction holds without the hypothesis on `g`, and in the other direction it suffices to assume that `f` is zero wherever `g` is. (This generalization is useful in defining the Fréchet derivative.) -/ assert_not_exists IsBoundedSMul Summable OpenPartialHomeomorph BoundedLENhdsClass open Set Topology Filter NNReal namespace Asymptotics variable {α : Type*} {β : Type*} {E : Type*} {F : Type*} {G : Type*} {E' : Type*} {F' : Type*} {G' : Type*} {E'' : Type*} {F'' : Type*} {G'' : Type*} {E''' : Type*} {R : Type*} {R' : Type*} {𝕜 : Type*} {𝕜' : Type*} variable [Norm E] [Norm F] [Norm G] variable [SeminormedAddCommGroup E'] [SeminormedAddCommGroup F'] [SeminormedAddCommGroup G'] [NormedAddCommGroup E''] [NormedAddCommGroup F''] [NormedAddCommGroup G''] [SeminormedRing R] [SeminormedAddGroup E'''] [SeminormedRing R'] variable {S : Type*} [NormedRing S] [NormMulClass S] variable [NormedDivisionRing 𝕜] [NormedDivisionRing 𝕜'] variable {c c' c₁ c₂ : ℝ} {f : α → E} {g : α → F} {k : α → G} variable {f' : α → E'} {g' : α → F'} {k' : α → G'} variable {f'' : α → E''} {g'' : α → F''} {k'' : α → G''} variable {l l' : Filter α} section Defs /-! ### Definitions -/ /-- This version of the Landau notation `IsBigOWith C l f g` where `f` and `g` are two functions on a type `α` and `l` is a filter on `α`, means that eventually for `l`, `‖f‖` is bounded by `C * ‖g‖`. In other words, `‖f‖ / ‖g‖` is eventually bounded by `C`, modulo division by zero issues that are avoided by this definition. Probably you want to use `IsBigO` instead of this relation. -/ irreducible_def IsBigOWith (c : ℝ) (l : Filter α) (f : α → E) (g : α → F) : Prop := ∀ᶠ x in l, ‖f x‖ ≤ c * ‖g x‖ /-- Definition of `IsBigOWith`. We record it in a lemma as `IsBigOWith` is irreducible. -/ theorem isBigOWith_iff : IsBigOWith c l f g ↔ ∀ᶠ x in l, ‖f x‖ ≤ c * ‖g x‖ := by rw [IsBigOWith_def] alias ⟨IsBigOWith.bound, IsBigOWith.of_bound⟩ := isBigOWith_iff /-- The Landau notation `f =O[l] g` where `f` and `g` are two functions on a type `α` and `l` is a filter on `α`, means that eventually for `l`, `‖f‖` is bounded by a constant multiple of `‖g‖`. In other words, `‖f‖ / ‖g‖` is eventually bounded, modulo division by zero issues that are avoided by this definition. -/ irreducible_def IsBigO (l : Filter α) (f : α → E) (g : α → F) : Prop := ∃ c : ℝ, IsBigOWith c l f g @[inherit_doc] notation:100 f " =O[" l "] " g:100 => IsBigO l f g /-- Definition of `IsBigO` in terms of `IsBigOWith`. We record it in a lemma as `IsBigO` is irreducible. -/ theorem isBigO_iff_isBigOWith : f =O[l] g ↔ ∃ c : ℝ, IsBigOWith c l f g := by rw [IsBigO_def] /-- Definition of `IsBigO` in terms of filters. -/ theorem isBigO_iff : f =O[l] g ↔ ∃ c : ℝ, ∀ᶠ x in l, ‖f x‖ ≤ c * ‖g x‖ := by simp only [IsBigO_def, IsBigOWith_def] /-- Definition of `IsBigO` in terms of filters, with a positive constant. -/ theorem isBigO_iff' {g : α → E'''} : f =O[l] g ↔ ∃ c > 0, ∀ᶠ x in l, ‖f x‖ ≤ c * ‖g x‖ := by refine ⟨fun h => ?mp, fun h => ?mpr⟩ case mp => rw [isBigO_iff] at h obtain ⟨c, hc⟩ := h refine ⟨max c 1, zero_lt_one.trans_le (le_max_right _ _), ?_⟩ filter_upwards [hc] with x hx apply hx.trans gcongr exact le_max_left _ _ case mpr => rw [isBigO_iff] obtain ⟨c, ⟨_, hc⟩⟩ := h exact ⟨c, hc⟩ /-- Definition of `IsBigO` in terms of filters, with the constant in the lower bound. -/ theorem isBigO_iff'' {g : α → E'''} : f =O[l] g ↔ ∃ c > 0, ∀ᶠ x in l, c * ‖f x‖ ≤ ‖g x‖ := by refine ⟨fun h => ?mp, fun h => ?mpr⟩ case mp => rw [isBigO_iff'] at h obtain ⟨c, ⟨hc_pos, hc⟩⟩ := h refine ⟨c⁻¹, ⟨by positivity, ?_⟩⟩ filter_upwards [hc] with x hx rwa [inv_mul_le_iff₀ (by positivity)] case mpr => rw [isBigO_iff'] obtain ⟨c, ⟨hc_pos, hc⟩⟩ := h refine ⟨c⁻¹, ⟨by positivity, ?_⟩⟩ filter_upwards [hc] with x hx rwa [← inv_inv c, inv_mul_le_iff₀ (by positivity)] at hx theorem IsBigO.of_bound (c : ℝ) (h : ∀ᶠ x in l, ‖f x‖ ≤ c * ‖g x‖) : f =O[l] g := isBigO_iff.2 ⟨c, h⟩ theorem IsBigO.of_bound' (h : ∀ᶠ x in l, ‖f x‖ ≤ ‖g x‖) : f =O[l] g := .of_bound 1 <| by simpa only [one_mul] using h theorem IsBigO.bound : f =O[l] g → ∃ c : ℝ, ∀ᶠ x in l, ‖f x‖ ≤ c * ‖g x‖ := isBigO_iff.1 /-- See also `Filter.Eventually.isBigO`, which is the same lemma stated using `Filter.Eventually` instead of `Filter.EventuallyLE`. -/ theorem IsBigO.of_norm_eventuallyLE {g : α → ℝ} (h : (‖f ·‖) ≤ᶠ[l] g) : f =O[l] g := .of_bound' <| h.mono fun _ h ↦ h.trans <| le_abs_self _ theorem IsBigO.of_norm_le {g : α → ℝ} (h : ∀ x, ‖f x‖ ≤ g x) : f =O[l] g := .of_norm_eventuallyLE <| .of_forall h /-- The Landau notation `f =o[l] g` where `f` and `g` are two functions on a type `α` and `l` is a filter on `α`, means that eventually for `l`, `‖f‖` is bounded by an arbitrarily small constant multiple of `‖g‖`. In other words, `‖f‖ / ‖g‖` tends to `0` along `l`, modulo division by zero issues that are avoided by this definition. -/ irreducible_def IsLittleO (l : Filter α) (f : α → E) (g : α → F) : Prop := ∀ ⦃c : ℝ⦄, 0 < c → IsBigOWith c l f g @[inherit_doc] notation:100 f " =o[" l "] " g:100 => IsLittleO l f g /-- Definition of `IsLittleO` in terms of `IsBigOWith`. -/ theorem isLittleO_iff_forall_isBigOWith : f =o[l] g ↔ ∀ ⦃c : ℝ⦄, 0 < c → IsBigOWith c l f g := by rw [IsLittleO_def] alias ⟨IsLittleO.forall_isBigOWith, IsLittleO.of_isBigOWith⟩ := isLittleO_iff_forall_isBigOWith /-- Definition of `IsLittleO` in terms of filters. -/ theorem isLittleO_iff : f =o[l] g ↔ ∀ ⦃c : ℝ⦄, 0 < c → ∀ᶠ x in l, ‖f x‖ ≤ c * ‖g x‖ := by simp only [IsLittleO_def, IsBigOWith_def] alias ⟨IsLittleO.bound, IsLittleO.of_bound⟩ := isLittleO_iff theorem IsLittleO.def (h : f =o[l] g) (hc : 0 < c) : ∀ᶠ x in l, ‖f x‖ ≤ c * ‖g x‖ := isLittleO_iff.1 h hc theorem IsLittleO.def' (h : f =o[l] g) (hc : 0 < c) : IsBigOWith c l f g := isBigOWith_iff.2 <| isLittleO_iff.1 h hc theorem IsLittleO.eventuallyLE (h : f =o[l] g) : ∀ᶠ x in l, ‖f x‖ ≤ ‖g x‖ := by simpa using h.def zero_lt_one end Defs /-! ### Conversions -/ theorem IsBigOWith.isBigO (h : IsBigOWith c l f g) : f =O[l] g := by rw [IsBigO_def]; exact ⟨c, h⟩ theorem IsLittleO.isBigOWith (hgf : f =o[l] g) : IsBigOWith 1 l f g := hgf.def' zero_lt_one theorem IsLittleO.isBigO (hgf : f =o[l] g) : f =O[l] g := hgf.isBigOWith.isBigO theorem IsBigO.isBigOWith : f =O[l] g → ∃ c : ℝ, IsBigOWith c l f g := isBigO_iff_isBigOWith.1 theorem IsBigOWith.weaken (h : IsBigOWith c l f g') (hc : c ≤ c') : IsBigOWith c' l f g' := IsBigOWith.of_bound <| mem_of_superset h.bound fun x hx => calc ‖f x‖ ≤ c * ‖g' x‖ := hx _ ≤ _ := by gcongr theorem IsBigOWith.exists_pos (h : IsBigOWith c l f g') : ∃ c' > 0, IsBigOWith c' l f g' := ⟨max c 1, lt_of_lt_of_le zero_lt_one (le_max_right c 1), h.weaken <| le_max_left c 1⟩ theorem IsBigO.exists_pos (h : f =O[l] g') : ∃ c > 0, IsBigOWith c l f g' := let ⟨_c, hc⟩ := h.isBigOWith hc.exists_pos theorem IsBigOWith.exists_nonneg (h : IsBigOWith c l f g') : ∃ c' ≥ 0, IsBigOWith c' l f g' := let ⟨c, cpos, hc⟩ := h.exists_pos ⟨c, le_of_lt cpos, hc⟩ theorem IsBigO.exists_nonneg (h : f =O[l] g') : ∃ c ≥ 0, IsBigOWith c l f g' := let ⟨_c, hc⟩ := h.isBigOWith hc.exists_nonneg /-- `f = O(g)` if and only if `IsBigOWith c f g` for all sufficiently large `c`. -/ theorem isBigO_iff_eventually_isBigOWith : f =O[l] g' ↔ ∀ᶠ c in atTop, IsBigOWith c l f g' := isBigO_iff_isBigOWith.trans ⟨fun ⟨c, hc⟩ => mem_atTop_sets.2 ⟨c, fun _c' hc' => hc.weaken hc'⟩, fun h => h.exists⟩ /-- `f = O(g)` if and only if `∀ᶠ x in l, ‖f x‖ ≤ c * ‖g x‖` for all sufficiently large `c`. -/ theorem isBigO_iff_eventually : f =O[l] g' ↔ ∀ᶠ c in atTop, ∀ᶠ x in l, ‖f x‖ ≤ c * ‖g' x‖ := isBigO_iff_eventually_isBigOWith.trans <| by simp only [IsBigOWith_def] theorem IsBigO.exists_mem_basis {ι} {p : ι → Prop} {s : ι → Set α} (h : f =O[l] g') (hb : l.HasBasis p s) : ∃ c > 0, ∃ i : ι, p i ∧ ∀ x ∈ s i, ‖f x‖ ≤ c * ‖g' x‖ := flip Exists.imp h.exists_pos fun c h => by simpa only [isBigOWith_iff, hb.eventually_iff, exists_prop] using h theorem isBigOWith_inv (hc : 0 < c) : IsBigOWith c⁻¹ l f g ↔ ∀ᶠ x in l, c * ‖f x‖ ≤ ‖g x‖ := by simp only [IsBigOWith_def, ← div_eq_inv_mul, le_div_iff₀' hc] -- We prove this lemma with strange assumptions to get two lemmas below automatically theorem isLittleO_iff_nat_mul_le_aux (h₀ : (∀ x, 0 ≤ ‖f x‖) ∨ ∀ x, 0 ≤ ‖g x‖) : f =o[l] g ↔ ∀ n : ℕ, ∀ᶠ x in l, ↑n * ‖f x‖ ≤ ‖g x‖ := by constructor · rintro H (_ | n) · refine (H.def one_pos).mono fun x h₀' => ?_ rw [Nat.cast_zero, zero_mul] refine h₀.elim (fun hf => (hf x).trans ?_) fun hg => hg x rwa [one_mul] at h₀' · have : (0 : ℝ) < n.succ := Nat.cast_pos.2 n.succ_pos exact (isBigOWith_inv this).1 (H.def' <| inv_pos.2 this) · refine fun H => isLittleO_iff.2 fun ε ε0 => ?_ rcases exists_nat_gt ε⁻¹ with ⟨n, hn⟩ have hn₀ : (0 : ℝ) < n := (inv_pos.2 ε0).trans hn refine ((isBigOWith_inv hn₀).2 (H n)).bound.mono fun x hfg => ?_ refine hfg.trans (mul_le_mul_of_nonneg_right (inv_le_of_inv_le₀ ε0 hn.le) ?_) refine h₀.elim (fun hf => nonneg_of_mul_nonneg_right ((hf x).trans hfg) ?_) fun h => h x exact inv_pos.2 hn₀ theorem isLittleO_iff_nat_mul_le : f =o[l] g' ↔ ∀ n : ℕ, ∀ᶠ x in l, ↑n * ‖f x‖ ≤ ‖g' x‖ := isLittleO_iff_nat_mul_le_aux (Or.inr fun _x => norm_nonneg _) theorem isLittleO_iff_nat_mul_le' : f' =o[l] g ↔ ∀ n : ℕ, ∀ᶠ x in l, ↑n * ‖f' x‖ ≤ ‖g x‖ := isLittleO_iff_nat_mul_le_aux (Or.inl fun _x => norm_nonneg _) /-! ### Subsingleton -/ @[nontriviality] theorem isLittleO_of_subsingleton [Subsingleton E'] : f' =o[l] g' := IsLittleO.of_bound fun c hc => by simp [Subsingleton.elim (f' _) 0, mul_nonneg hc.le] @[nontriviality] theorem isBigO_of_subsingleton [Subsingleton E'] : f' =O[l] g' := isLittleO_of_subsingleton.isBigO section congr variable {f₁ f₂ : α → E} {g₁ g₂ : α → F} /-! ### Congruence -/ theorem isBigOWith_congr (hc : c₁ = c₂) (hf : f₁ =ᶠ[l] f₂) (hg : g₁ =ᶠ[l] g₂) : IsBigOWith c₁ l f₁ g₁ ↔ IsBigOWith c₂ l f₂ g₂ := by simp only [IsBigOWith_def] subst c₂ apply Filter.eventually_congr filter_upwards [hf, hg] with _ e₁ e₂ rw [e₁, e₂] theorem IsBigOWith.congr' (h : IsBigOWith c₁ l f₁ g₁) (hc : c₁ = c₂) (hf : f₁ =ᶠ[l] f₂) (hg : g₁ =ᶠ[l] g₂) : IsBigOWith c₂ l f₂ g₂ := (isBigOWith_congr hc hf hg).mp h theorem IsBigOWith.congr (h : IsBigOWith c₁ l f₁ g₁) (hc : c₁ = c₂) (hf : ∀ x, f₁ x = f₂ x) (hg : ∀ x, g₁ x = g₂ x) : IsBigOWith c₂ l f₂ g₂ := h.congr' hc (univ_mem' hf) (univ_mem' hg) theorem IsBigOWith.congr_left (h : IsBigOWith c l f₁ g) (hf : ∀ x, f₁ x = f₂ x) : IsBigOWith c l f₂ g := h.congr rfl hf fun _ => rfl theorem IsBigOWith.congr_right (h : IsBigOWith c l f g₁) (hg : ∀ x, g₁ x = g₂ x) : IsBigOWith c l f g₂ := h.congr rfl (fun _ => rfl) hg theorem IsBigOWith.congr_const (h : IsBigOWith c₁ l f g) (hc : c₁ = c₂) : IsBigOWith c₂ l f g := h.congr hc (fun _ => rfl) fun _ => rfl theorem isBigO_congr (hf : f₁ =ᶠ[l] f₂) (hg : g₁ =ᶠ[l] g₂) : f₁ =O[l] g₁ ↔ f₂ =O[l] g₂ := by simp only [IsBigO_def] exact exists_congr fun c => isBigOWith_congr rfl hf hg theorem IsBigO.congr' (h : f₁ =O[l] g₁) (hf : f₁ =ᶠ[l] f₂) (hg : g₁ =ᶠ[l] g₂) : f₂ =O[l] g₂ := (isBigO_congr hf hg).mp h theorem IsBigO.congr (h : f₁ =O[l] g₁) (hf : ∀ x, f₁ x = f₂ x) (hg : ∀ x, g₁ x = g₂ x) : f₂ =O[l] g₂ := h.congr' (univ_mem' hf) (univ_mem' hg) theorem IsBigO.congr_left (h : f₁ =O[l] g) (hf : ∀ x, f₁ x = f₂ x) : f₂ =O[l] g := h.congr hf fun _ => rfl theorem IsBigO.congr_right (h : f =O[l] g₁) (hg : ∀ x, g₁ x = g₂ x) : f =O[l] g₂ := h.congr (fun _ => rfl) hg theorem isLittleO_congr (hf : f₁ =ᶠ[l] f₂) (hg : g₁ =ᶠ[l] g₂) : f₁ =o[l] g₁ ↔ f₂ =o[l] g₂ := by simp only [IsLittleO_def] exact forall₂_congr fun c _hc => isBigOWith_congr (Eq.refl c) hf hg theorem IsLittleO.congr' (h : f₁ =o[l] g₁) (hf : f₁ =ᶠ[l] f₂) (hg : g₁ =ᶠ[l] g₂) : f₂ =o[l] g₂ := (isLittleO_congr hf hg).mp h theorem IsLittleO.congr (h : f₁ =o[l] g₁) (hf : ∀ x, f₁ x = f₂ x) (hg : ∀ x, g₁ x = g₂ x) : f₂ =o[l] g₂ := h.congr' (univ_mem' hf) (univ_mem' hg) theorem IsLittleO.congr_left (h : f₁ =o[l] g) (hf : ∀ x, f₁ x = f₂ x) : f₂ =o[l] g := h.congr hf fun _ => rfl theorem IsLittleO.congr_right (h : f =o[l] g₁) (hg : ∀ x, g₁ x = g₂ x) : f =o[l] g₂ := h.congr (fun _ => rfl) hg @[trans] theorem _root_.Filter.EventuallyEq.trans_isBigO {f₁ f₂ : α → E} {g : α → F} (hf : f₁ =ᶠ[l] f₂) (h : f₂ =O[l] g) : f₁ =O[l] g := h.congr' hf.symm EventuallyEq.rfl instance transEventuallyEqIsBigO : @Trans (α → E) (α → E) (α → F) (· =ᶠ[l] ·) (· =O[l] ·) (· =O[l] ·) where trans := Filter.EventuallyEq.trans_isBigO @[trans] theorem _root_.Filter.EventuallyEq.trans_isLittleO {f₁ f₂ : α → E} {g : α → F} (hf : f₁ =ᶠ[l] f₂) (h : f₂ =o[l] g) : f₁ =o[l] g := h.congr' hf.symm EventuallyEq.rfl instance transEventuallyEqIsLittleO : @Trans (α → E) (α → E) (α → F) (· =ᶠ[l] ·) (· =o[l] ·) (· =o[l] ·) where trans := Filter.EventuallyEq.trans_isLittleO @[trans] theorem IsBigO.trans_eventuallyEq {f : α → E} {g₁ g₂ : α → F} (h : f =O[l] g₁) (hg : g₁ =ᶠ[l] g₂) : f =O[l] g₂ := h.congr' EventuallyEq.rfl hg instance transIsBigOEventuallyEq : @Trans (α → E) (α → F) (α → F) (· =O[l] ·) (· =ᶠ[l] ·) (· =O[l] ·) where trans := IsBigO.trans_eventuallyEq @[trans] theorem IsLittleO.trans_eventuallyEq {f : α → E} {g₁ g₂ : α → F} (h : f =o[l] g₁) (hg : g₁ =ᶠ[l] g₂) : f =o[l] g₂ := h.congr' EventuallyEq.rfl hg instance transIsLittleOEventuallyEq : @Trans (α → E) (α → F) (α → F) (· =o[l] ·) (· =ᶠ[l] ·) (· =o[l] ·) where trans := IsLittleO.trans_eventuallyEq end congr /-! ### Filter operations and transitivity -/ theorem IsBigOWith.comp_tendsto (hcfg : IsBigOWith c l f g) {k : β → α} {l' : Filter β} (hk : Tendsto k l' l) : IsBigOWith c l' (f ∘ k) (g ∘ k) := IsBigOWith.of_bound <| hk hcfg.bound theorem IsBigO.comp_tendsto (hfg : f =O[l] g) {k : β → α} {l' : Filter β} (hk : Tendsto k l' l) : (f ∘ k) =O[l'] (g ∘ k) := isBigO_iff_isBigOWith.2 <| hfg.isBigOWith.imp fun _c h => h.comp_tendsto hk lemma IsBigO.comp_neg_int {f : ℤ → E} {g : ℤ → F} (hf : f =O[cofinite] g) : (fun n => f (-n)) =O[cofinite] fun n => g (-n) := by rw [← Equiv.neg_apply] exact hf.comp_tendsto (Equiv.neg ℤ).injective.tendsto_cofinite theorem IsLittleO.comp_tendsto (hfg : f =o[l] g) {k : β → α} {l' : Filter β} (hk : Tendsto k l' l) : (f ∘ k) =o[l'] (g ∘ k) := IsLittleO.of_isBigOWith fun _c cpos => (hfg.forall_isBigOWith cpos).comp_tendsto hk @[simp] theorem isBigOWith_map {k : β → α} {l : Filter β} : IsBigOWith c (map k l) f g ↔ IsBigOWith c l (f ∘ k) (g ∘ k) := by simp only [IsBigOWith_def] exact eventually_map @[simp] theorem isBigO_map {k : β → α} {l : Filter β} : f =O[map k l] g ↔ (f ∘ k) =O[l] (g ∘ k) := by simp only [IsBigO_def, isBigOWith_map] @[simp] theorem isLittleO_map {k : β → α} {l : Filter β} : f =o[map k l] g ↔ (f ∘ k) =o[l] (g ∘ k) := by simp only [IsLittleO_def, isBigOWith_map] theorem IsBigOWith.mono (h : IsBigOWith c l' f g) (hl : l ≤ l') : IsBigOWith c l f g := IsBigOWith.of_bound <| hl h.bound theorem IsBigO.mono (h : f =O[l'] g) (hl : l ≤ l') : f =O[l] g := isBigO_iff_isBigOWith.2 <| h.isBigOWith.imp fun _c h => h.mono hl theorem IsLittleO.mono (h : f =o[l'] g) (hl : l ≤ l') : f =o[l] g := IsLittleO.of_isBigOWith fun _c cpos => (h.forall_isBigOWith cpos).mono hl theorem IsBigOWith.trans (hfg : IsBigOWith c l f g) (hgk : IsBigOWith c' l g k) (hc : 0 ≤ c) : IsBigOWith (c * c') l f k := by simp only [IsBigOWith_def] at * filter_upwards [hfg, hgk] with x hx hx' calc ‖f x‖ ≤ c * ‖g x‖ := hx _ ≤ c * (c' * ‖k x‖) := by gcongr _ = c * c' * ‖k x‖ := (mul_assoc _ _ _).symm @[trans] theorem IsBigO.trans {f : α → E} {g : α → F'} {k : α → G} (hfg : f =O[l] g) (hgk : g =O[l] k) : f =O[l] k := let ⟨_c, cnonneg, hc⟩ := hfg.exists_nonneg let ⟨_c', hc'⟩ := hgk.isBigOWith (hc.trans hc' cnonneg).isBigO instance transIsBigOIsBigO : @Trans (α → E) (α → F') (α → G) (· =O[l] ·) (· =O[l] ·) (· =O[l] ·) where trans := IsBigO.trans theorem IsLittleO.trans_isBigOWith (hfg : f =o[l] g) (hgk : IsBigOWith c l g k) (hc : 0 < c) : f =o[l] k := by simp only [IsLittleO_def] at * intro c' c'pos have : 0 < c' / c := div_pos c'pos hc exact ((hfg this).trans hgk this.le).congr_const (div_mul_cancel₀ _ hc.ne') @[trans] theorem IsLittleO.trans_isBigO {f : α → E} {g : α → F} {k : α → G'} (hfg : f =o[l] g) (hgk : g =O[l] k) : f =o[l] k := let ⟨_c, cpos, hc⟩ := hgk.exists_pos hfg.trans_isBigOWith hc cpos instance transIsLittleOIsBigO : @Trans (α → E) (α → F) (α → G') (· =o[l] ·) (· =O[l] ·) (· =o[l] ·) where trans := IsLittleO.trans_isBigO theorem IsBigOWith.trans_isLittleO (hfg : IsBigOWith c l f g) (hgk : g =o[l] k) (hc : 0 < c) : f =o[l] k := by simp only [IsLittleO_def] at * intro c' c'pos have : 0 < c' / c := div_pos c'pos hc exact (hfg.trans (hgk this) hc.le).congr_const (mul_div_cancel₀ _ hc.ne') @[trans] theorem IsBigO.trans_isLittleO {f : α → E} {g : α → F'} {k : α → G} (hfg : f =O[l] g) (hgk : g =o[l] k) : f =o[l] k := let ⟨_c, cpos, hc⟩ := hfg.exists_pos hc.trans_isLittleO hgk cpos instance transIsBigOIsLittleO : @Trans (α → E) (α → F') (α → G) (· =O[l] ·) (· =o[l] ·) (· =o[l] ·) where trans := IsBigO.trans_isLittleO @[trans] theorem IsLittleO.trans {f : α → E} {g : α → F} {k : α → G} (hfg : f =o[l] g) (hgk : g =o[l] k) : f =o[l] k := hfg.trans_isBigOWith hgk.isBigOWith one_pos instance transIsLittleOIsLittleO : @Trans (α → E) (α → F) (α → G) (· =o[l] ·) (· =o[l] ·) (· =o[l] ·) where trans := IsLittleO.trans theorem _root_.Filter.Eventually.trans_isBigO {f : α → E} {g : α → F'} {k : α → G} (hfg : ∀ᶠ x in l, ‖f x‖ ≤ ‖g x‖) (hgk : g =O[l] k) : f =O[l] k := (IsBigO.of_bound' hfg).trans hgk /-- See also `Asymptotics.IsBigO.of_norm_eventuallyLE`, which is the same lemma stated using `Filter.EventuallyLE` instead of `Filter.Eventually`. -/ theorem _root_.Filter.Eventually.isBigO {f : α → E} {g : α → ℝ} {l : Filter α} (hfg : ∀ᶠ x in l, ‖f x‖ ≤ g x) : f =O[l] g := .of_norm_eventuallyLE hfg section variable (l) theorem isBigOWith_of_le' (hfg : ∀ x, ‖f x‖ ≤ c * ‖g x‖) : IsBigOWith c l f g := IsBigOWith.of_bound <| univ_mem' hfg theorem isBigOWith_of_le (hfg : ∀ x, ‖f x‖ ≤ ‖g x‖) : IsBigOWith 1 l f g := isBigOWith_of_le' l fun x => by rw [one_mul] exact hfg x theorem isBigO_of_le' (hfg : ∀ x, ‖f x‖ ≤ c * ‖g x‖) : f =O[l] g := (isBigOWith_of_le' l hfg).isBigO theorem isBigO_of_le (hfg : ∀ x, ‖f x‖ ≤ ‖g x‖) : f =O[l] g := (isBigOWith_of_le l hfg).isBigO end theorem isBigOWith_refl (f : α → E) (l : Filter α) : IsBigOWith 1 l f f := isBigOWith_of_le l fun _ => le_rfl theorem isBigO_refl (f : α → E) (l : Filter α) : f =O[l] f := (isBigOWith_refl f l).isBigO theorem _root_.Filter.EventuallyEq.isBigO {f₁ f₂ : α → E} (hf : f₁ =ᶠ[l] f₂) : f₁ =O[l] f₂ := hf.trans_isBigO (isBigO_refl _ _) theorem IsBigOWith.trans_le (hfg : IsBigOWith c l f g) (hgk : ∀ x, ‖g x‖ ≤ ‖k x‖) (hc : 0 ≤ c) : IsBigOWith c l f k := (hfg.trans (isBigOWith_of_le l hgk) hc).congr_const <| mul_one c theorem IsBigO.trans_le (hfg : f =O[l] g') (hgk : ∀ x, ‖g' x‖ ≤ ‖k x‖) : f =O[l] k := hfg.trans (isBigO_of_le l hgk) theorem IsLittleO.trans_le (hfg : f =o[l] g) (hgk : ∀ x, ‖g x‖ ≤ ‖k x‖) : f =o[l] k := hfg.trans_isBigOWith (isBigOWith_of_le _ hgk) zero_lt_one theorem isLittleO_irrefl' (h : ∃ᶠ x in l, ‖f' x‖ ≠ 0) : ¬f' =o[l] f' := by intro ho rcases ((ho.bound one_half_pos).and_frequently h).exists with ⟨x, hle, hne⟩ rw [one_div, ← div_eq_inv_mul] at hle exact (half_lt_self (lt_of_le_of_ne (norm_nonneg _) hne.symm)).not_ge hle theorem isLittleO_irrefl (h : ∃ᶠ x in l, f'' x ≠ 0) : ¬f'' =o[l] f'' := isLittleO_irrefl' <| h.mono fun _x => norm_ne_zero_iff.mpr theorem IsBigO.not_isLittleO (h : f'' =O[l] g') (hf : ∃ᶠ x in l, f'' x ≠ 0) : ¬g' =o[l] f'' := fun h' => isLittleO_irrefl hf (h.trans_isLittleO h') theorem IsLittleO.not_isBigO (h : f'' =o[l] g') (hf : ∃ᶠ x in l, f'' x ≠ 0) : ¬g' =O[l] f'' := fun h' => isLittleO_irrefl hf (h.trans_isBigO h') section Bot variable (c f g) @[simp] theorem isBigOWith_bot : IsBigOWith c ⊥ f g := IsBigOWith.of_bound <| trivial @[simp] theorem isBigO_bot : f =O[⊥] g := (isBigOWith_bot 1 f g).isBigO @[simp] theorem isLittleO_bot : f =o[⊥] g := IsLittleO.of_isBigOWith fun c _ => isBigOWith_bot c f g end Bot @[simp] theorem isBigOWith_pure {x} : IsBigOWith c (pure x) f g ↔ ‖f x‖ ≤ c * ‖g x‖ := isBigOWith_iff theorem IsBigOWith.sup (h : IsBigOWith c l f g) (h' : IsBigOWith c l' f g) : IsBigOWith c (l ⊔ l') f g := IsBigOWith.of_bound <| mem_sup.2 ⟨h.bound, h'.bound⟩ theorem IsBigOWith.sup' (h : IsBigOWith c l f g') (h' : IsBigOWith c' l' f g') : IsBigOWith (max c c') (l ⊔ l') f g' := IsBigOWith.of_bound <| mem_sup.2 ⟨(h.weaken <| le_max_left c c').bound, (h'.weaken <| le_max_right c c').bound⟩ theorem IsBigO.sup (h : f =O[l] g') (h' : f =O[l'] g') : f =O[l ⊔ l'] g' := let ⟨_c, hc⟩ := h.isBigOWith let ⟨_c', hc'⟩ := h'.isBigOWith (hc.sup' hc').isBigO theorem IsLittleO.sup (h : f =o[l] g) (h' : f =o[l'] g) : f =o[l ⊔ l'] g := IsLittleO.of_isBigOWith fun _c cpos => (h.forall_isBigOWith cpos).sup (h'.forall_isBigOWith cpos) @[simp] theorem isBigO_sup : f =O[l ⊔ l'] g' ↔ f =O[l] g' ∧ f =O[l'] g' := ⟨fun h => ⟨h.mono le_sup_left, h.mono le_sup_right⟩, fun h => h.1.sup h.2⟩ @[simp] theorem isLittleO_sup : f =o[l ⊔ l'] g ↔ f =o[l] g ∧ f =o[l'] g := ⟨fun h => ⟨h.mono le_sup_left, h.mono le_sup_right⟩, fun h => h.1.sup h.2⟩ theorem isBigOWith_insert [TopologicalSpace α] {x : α} {s : Set α} {C : ℝ} {g : α → E} {g' : α → F} (h : ‖g x‖ ≤ C * ‖g' x‖) : IsBigOWith C (𝓝[insert x s] x) g g' ↔ IsBigOWith C (𝓝[s] x) g g' := by simp_rw [IsBigOWith_def, nhdsWithin_insert, eventually_sup, eventually_pure, h, true_and] protected theorem IsBigOWith.insert [TopologicalSpace α] {x : α} {s : Set α} {C : ℝ} {g : α → E} {g' : α → F} (h1 : IsBigOWith C (𝓝[s] x) g g') (h2 : ‖g x‖ ≤ C * ‖g' x‖) : IsBigOWith C (𝓝[insert x s] x) g g' := (isBigOWith_insert h2).mpr h1 theorem isLittleO_insert [TopologicalSpace α] {x : α} {s : Set α} {g : α → E'} {g' : α → F'} (h : g x = 0) : g =o[𝓝[insert x s] x] g' ↔ g =o[𝓝[s] x] g' := by simp_rw [IsLittleO_def] refine forall_congr' fun c => forall_congr' fun hc => ?_ rw [isBigOWith_insert] rw [h, norm_zero] exact mul_nonneg hc.le (norm_nonneg _) protected theorem IsLittleO.insert [TopologicalSpace α] {x : α} {s : Set α} {g : α → E'} {g' : α → F'} (h1 : g =o[𝓝[s] x] g') (h2 : g x = 0) : g =o[𝓝[insert x s] x] g' := (isLittleO_insert h2).mpr h1 /-! ### Simplification: norm, abs -/ section NormAbs variable {u v : α → ℝ} @[simp] theorem isBigOWith_norm_right : (IsBigOWith c l f fun x => ‖g' x‖) ↔ IsBigOWith c l f g' := by simp only [IsBigOWith_def, norm_norm] @[simp] theorem isBigOWith_abs_right : (IsBigOWith c l f fun x => |u x|) ↔ IsBigOWith c l f u := @isBigOWith_norm_right _ _ _ _ _ _ f u l alias ⟨IsBigOWith.of_norm_right, IsBigOWith.norm_right⟩ := isBigOWith_norm_right alias ⟨IsBigOWith.of_abs_right, IsBigOWith.abs_right⟩ := isBigOWith_abs_right @[simp] theorem isBigO_norm_right : (f =O[l] fun x => ‖g' x‖) ↔ f =O[l] g' := by simp only [IsBigO_def] exact exists_congr fun _ => isBigOWith_norm_right @[simp] theorem isBigO_abs_right : (f =O[l] fun x => |u x|) ↔ f =O[l] u := @isBigO_norm_right _ _ ℝ _ _ _ _ _ alias ⟨IsBigO.of_norm_right, IsBigO.norm_right⟩ := isBigO_norm_right alias ⟨IsBigO.of_abs_right, IsBigO.abs_right⟩ := isBigO_abs_right @[simp] theorem isLittleO_norm_right : (f =o[l] fun x => ‖g' x‖) ↔ f =o[l] g' := by simp only [IsLittleO_def] exact forall₂_congr fun _ _ => isBigOWith_norm_right @[simp] theorem isLittleO_abs_right : (f =o[l] fun x => |u x|) ↔ f =o[l] u := @isLittleO_norm_right _ _ ℝ _ _ _ _ _ alias ⟨IsLittleO.of_norm_right, IsLittleO.norm_right⟩ := isLittleO_norm_right alias ⟨IsLittleO.of_abs_right, IsLittleO.abs_right⟩ := isLittleO_abs_right @[simp] theorem isBigOWith_norm_left : IsBigOWith c l (fun x => ‖f' x‖) g ↔ IsBigOWith c l f' g := by simp only [IsBigOWith_def, norm_norm] @[simp] theorem isBigOWith_abs_left : IsBigOWith c l (fun x => |u x|) g ↔ IsBigOWith c l u g := @isBigOWith_norm_left _ _ _ _ _ _ g u l alias ⟨IsBigOWith.of_norm_left, IsBigOWith.norm_left⟩ := isBigOWith_norm_left alias ⟨IsBigOWith.of_abs_left, IsBigOWith.abs_left⟩ := isBigOWith_abs_left @[simp] theorem isBigO_norm_left : (fun x => ‖f' x‖) =O[l] g ↔ f' =O[l] g := by simp only [IsBigO_def] exact exists_congr fun _ => isBigOWith_norm_left @[simp] theorem isBigO_abs_left : (fun x => |u x|) =O[l] g ↔ u =O[l] g := @isBigO_norm_left _ _ _ _ _ g u l alias ⟨IsBigO.of_norm_left, IsBigO.norm_left⟩ := isBigO_norm_left alias ⟨IsBigO.of_abs_left, IsBigO.abs_left⟩ := isBigO_abs_left @[simp] theorem isLittleO_norm_left : (fun x => ‖f' x‖) =o[l] g ↔ f' =o[l] g := by simp only [IsLittleO_def] exact forall₂_congr fun _ _ => isBigOWith_norm_left @[simp] theorem isLittleO_abs_left : (fun x => |u x|) =o[l] g ↔ u =o[l] g := @isLittleO_norm_left _ _ _ _ _ g u l alias ⟨IsLittleO.of_norm_left, IsLittleO.norm_left⟩ := isLittleO_norm_left alias ⟨IsLittleO.of_abs_left, IsLittleO.abs_left⟩ := isLittleO_abs_left theorem isBigOWith_norm_norm : (IsBigOWith c l (fun x => ‖f' x‖) fun x => ‖g' x‖) ↔ IsBigOWith c l f' g' := isBigOWith_norm_left.trans isBigOWith_norm_right theorem isBigOWith_abs_abs : (IsBigOWith c l (fun x => |u x|) fun x => |v x|) ↔ IsBigOWith c l u v := isBigOWith_abs_left.trans isBigOWith_abs_right alias ⟨IsBigOWith.of_norm_norm, IsBigOWith.norm_norm⟩ := isBigOWith_norm_norm alias ⟨IsBigOWith.of_abs_abs, IsBigOWith.abs_abs⟩ := isBigOWith_abs_abs theorem isBigO_norm_norm : ((fun x => ‖f' x‖) =O[l] fun x => ‖g' x‖) ↔ f' =O[l] g' := isBigO_norm_left.trans isBigO_norm_right theorem isBigO_abs_abs : ((fun x => |u x|) =O[l] fun x => |v x|) ↔ u =O[l] v := isBigO_abs_left.trans isBigO_abs_right alias ⟨IsBigO.of_norm_norm, IsBigO.norm_norm⟩ := isBigO_norm_norm alias ⟨IsBigO.of_abs_abs, IsBigO.abs_abs⟩ := isBigO_abs_abs theorem isLittleO_norm_norm : ((fun x => ‖f' x‖) =o[l] fun x => ‖g' x‖) ↔ f' =o[l] g' := isLittleO_norm_left.trans isLittleO_norm_right theorem isLittleO_abs_abs : ((fun x => |u x|) =o[l] fun x => |v x|) ↔ u =o[l] v := isLittleO_abs_left.trans isLittleO_abs_right alias ⟨IsLittleO.of_norm_norm, IsLittleO.norm_norm⟩ := isLittleO_norm_norm alias ⟨IsLittleO.of_abs_abs, IsLittleO.abs_abs⟩ := isLittleO_abs_abs end NormAbs /-! ### Simplification: negate -/ @[simp] theorem isBigOWith_neg_right : (IsBigOWith c l f fun x => -g' x) ↔ IsBigOWith c l f g' := by simp only [IsBigOWith_def, norm_neg] alias ⟨IsBigOWith.of_neg_right, IsBigOWith.neg_right⟩ := isBigOWith_neg_right @[simp] theorem isBigO_neg_right : (f =O[l] fun x => -g' x) ↔ f =O[l] g' := by simp only [IsBigO_def] exact exists_congr fun _ => isBigOWith_neg_right alias ⟨IsBigO.of_neg_right, IsBigO.neg_right⟩ := isBigO_neg_right @[simp] theorem isLittleO_neg_right : (f =o[l] fun x => -g' x) ↔ f =o[l] g' := by simp only [IsLittleO_def] exact forall₂_congr fun _ _ => isBigOWith_neg_right alias ⟨IsLittleO.of_neg_right, IsLittleO.neg_right⟩ := isLittleO_neg_right @[simp] theorem isBigOWith_neg_left : IsBigOWith c l (fun x => -f' x) g ↔ IsBigOWith c l f' g := by simp only [IsBigOWith_def, norm_neg] alias ⟨IsBigOWith.of_neg_left, IsBigOWith.neg_left⟩ := isBigOWith_neg_left @[simp] theorem isBigO_neg_left : (fun x => -f' x) =O[l] g ↔ f' =O[l] g := by simp only [IsBigO_def] exact exists_congr fun _ => isBigOWith_neg_left alias ⟨IsBigO.of_neg_left, IsBigO.neg_left⟩ := isBigO_neg_left @[simp] theorem isLittleO_neg_left : (fun x => -f' x) =o[l] g ↔ f' =o[l] g := by simp only [IsLittleO_def] exact forall₂_congr fun _ _ => isBigOWith_neg_left alias ⟨IsLittleO.of_neg_left, IsLittleO.neg_left⟩ := isLittleO_neg_left /-! ### Product of functions (right) -/ theorem isBigOWith_fst_prod : IsBigOWith 1 l f' fun x => (f' x, g' x) := isBigOWith_of_le l fun _x => le_max_left _ _ theorem isBigOWith_snd_prod : IsBigOWith 1 l g' fun x => (f' x, g' x) := isBigOWith_of_le l fun _x => le_max_right _ _ theorem isBigO_fst_prod : f' =O[l] fun x => (f' x, g' x) := isBigOWith_fst_prod.isBigO theorem isBigO_snd_prod : g' =O[l] fun x => (f' x, g' x) := isBigOWith_snd_prod.isBigO theorem isBigO_fst_prod' {f' : α → E' × F'} : (fun x => (f' x).1) =O[l] f' := by simpa [IsBigO_def, IsBigOWith_def] using isBigO_fst_prod (E' := E') (F' := F') theorem isBigO_snd_prod' {f' : α → E' × F'} : (fun x => (f' x).2) =O[l] f' := by simpa [IsBigO_def, IsBigOWith_def] using isBigO_snd_prod (E' := E') (F' := F') section variable (f' k') theorem IsBigOWith.prod_rightl (h : IsBigOWith c l f g') (hc : 0 ≤ c) : IsBigOWith c l f fun x => (g' x, k' x) := (h.trans isBigOWith_fst_prod hc).congr_const (mul_one c) theorem IsBigO.prod_rightl (h : f =O[l] g') : f =O[l] fun x => (g' x, k' x) := let ⟨_c, cnonneg, hc⟩ := h.exists_nonneg (hc.prod_rightl k' cnonneg).isBigO theorem IsLittleO.prod_rightl (h : f =o[l] g') : f =o[l] fun x => (g' x, k' x) := IsLittleO.of_isBigOWith fun _c cpos => (h.forall_isBigOWith cpos).prod_rightl k' cpos.le theorem IsBigOWith.prod_rightr (h : IsBigOWith c l f g') (hc : 0 ≤ c) : IsBigOWith c l f fun x => (f' x, g' x) := (h.trans isBigOWith_snd_prod hc).congr_const (mul_one c) theorem IsBigO.prod_rightr (h : f =O[l] g') : f =O[l] fun x => (f' x, g' x) := let ⟨_c, cnonneg, hc⟩ := h.exists_nonneg (hc.prod_rightr f' cnonneg).isBigO theorem IsLittleO.prod_rightr (h : f =o[l] g') : f =o[l] fun x => (f' x, g' x) := IsLittleO.of_isBigOWith fun _c cpos => (h.forall_isBigOWith cpos).prod_rightr f' cpos.le end section variable {f : α × β → E} {g : α × β → F} {l' : Filter β} protected theorem IsBigO.fiberwise_right : f =O[l ×ˢ l'] g → ∀ᶠ a in l, (f ⟨a, ·⟩) =O[l'] (g ⟨a, ·⟩) := by simp only [isBigO_iff, eventually_iff, mem_prod_iff] rintro ⟨c, t₁, ht₁, t₂, ht₂, ht⟩ exact mem_of_superset ht₁ fun _ ha ↦ ⟨c, mem_of_superset ht₂ fun _ hb ↦ ht ⟨ha, hb⟩⟩ protected theorem IsBigO.fiberwise_left : f =O[l ×ˢ l'] g → ∀ᶠ b in l', (f ⟨·, b⟩) =O[l] (g ⟨·, b⟩) := by simp only [isBigO_iff, eventually_iff, mem_prod_iff] rintro ⟨c, t₁, ht₁, t₂, ht₂, ht⟩ exact mem_of_superset ht₂ fun _ hb ↦ ⟨c, mem_of_superset ht₁ fun _ ha ↦ ht ⟨ha, hb⟩⟩ end section variable (l' : Filter β) protected theorem IsBigO.comp_fst : f =O[l] g → (f ∘ Prod.fst) =O[l ×ˢ l'] (g ∘ Prod.fst) := by simp only [isBigO_iff, eventually_prod_iff] exact fun ⟨c, hc⟩ ↦ ⟨c, _, hc, fun _ ↦ True, eventually_true l', fun {_} h {_} _ ↦ h⟩ protected theorem IsBigO.comp_snd : f =O[l] g → (f ∘ Prod.snd) =O[l' ×ˢ l] (g ∘ Prod.snd) := by simp only [isBigO_iff, eventually_prod_iff] exact fun ⟨c, hc⟩ ↦ ⟨c, fun _ ↦ True, eventually_true l', _, hc, fun _ ↦ id⟩ protected theorem IsLittleO.comp_fst : f =o[l] g → (f ∘ Prod.fst) =o[l ×ˢ l'] (g ∘ Prod.fst) := by simp only [isLittleO_iff, eventually_prod_iff] exact fun h _ hc ↦ ⟨_, h hc, fun _ ↦ True, eventually_true l', fun {_} h {_} _ ↦ h⟩ protected theorem IsLittleO.comp_snd : f =o[l] g → (f ∘ Prod.snd) =o[l' ×ˢ l] (g ∘ Prod.snd) := by simp only [isLittleO_iff, eventually_prod_iff] exact fun h _ hc ↦ ⟨fun _ ↦ True, eventually_true l', _, h hc, fun _ ↦ id⟩ end theorem IsBigOWith.prod_left_same (hf : IsBigOWith c l f' k') (hg : IsBigOWith c l g' k') : IsBigOWith c l (fun x => (f' x, g' x)) k' := by rw [isBigOWith_iff] at *; filter_upwards [hf, hg] with x using max_le theorem IsBigOWith.prod_left (hf : IsBigOWith c l f' k') (hg : IsBigOWith c' l g' k') : IsBigOWith (max c c') l (fun x => (f' x, g' x)) k' := (hf.weaken <| le_max_left c c').prod_left_same (hg.weaken <| le_max_right c c') theorem IsBigOWith.prod_left_fst (h : IsBigOWith c l (fun x => (f' x, g' x)) k') : IsBigOWith c l f' k' := (isBigOWith_fst_prod.trans h zero_le_one).congr_const <| one_mul c theorem IsBigOWith.prod_left_snd (h : IsBigOWith c l (fun x => (f' x, g' x)) k') : IsBigOWith c l g' k' := (isBigOWith_snd_prod.trans h zero_le_one).congr_const <| one_mul c theorem isBigOWith_prod_left : IsBigOWith c l (fun x => (f' x, g' x)) k' ↔ IsBigOWith c l f' k' ∧ IsBigOWith c l g' k' := ⟨fun h => ⟨h.prod_left_fst, h.prod_left_snd⟩, fun h => h.1.prod_left_same h.2⟩ theorem IsBigO.prod_left (hf : f' =O[l] k') (hg : g' =O[l] k') : (fun x => (f' x, g' x)) =O[l] k' := let ⟨_c, hf⟩ := hf.isBigOWith let ⟨_c', hg⟩ := hg.isBigOWith (hf.prod_left hg).isBigO theorem IsBigO.prod_left_fst : (fun x => (f' x, g' x)) =O[l] k' → f' =O[l] k' := IsBigO.trans isBigO_fst_prod theorem IsBigO.prod_left_snd : (fun x => (f' x, g' x)) =O[l] k' → g' =O[l] k' := IsBigO.trans isBigO_snd_prod @[simp] theorem isBigO_prod_left : (fun x => (f' x, g' x)) =O[l] k' ↔ f' =O[l] k' ∧ g' =O[l] k' := ⟨fun h => ⟨h.prod_left_fst, h.prod_left_snd⟩, fun h => h.1.prod_left h.2⟩ theorem IsLittleO.prod_left (hf : f' =o[l] k') (hg : g' =o[l] k') : (fun x => (f' x, g' x)) =o[l] k' := IsLittleO.of_isBigOWith fun _c hc => (hf.forall_isBigOWith hc).prod_left_same (hg.forall_isBigOWith hc) theorem IsLittleO.prod_left_fst : (fun x => (f' x, g' x)) =o[l] k' → f' =o[l] k' := IsBigO.trans_isLittleO isBigO_fst_prod theorem IsLittleO.prod_left_snd : (fun x => (f' x, g' x)) =o[l] k' → g' =o[l] k' := IsBigO.trans_isLittleO isBigO_snd_prod @[simp] theorem isLittleO_prod_left : (fun x => (f' x, g' x)) =o[l] k' ↔ f' =o[l] k' ∧ g' =o[l] k' := ⟨fun h => ⟨h.prod_left_fst, h.prod_left_snd⟩, fun h => h.1.prod_left h.2⟩ theorem IsBigOWith.eq_zero_imp (h : IsBigOWith c l f'' g'') : ∀ᶠ x in l, g'' x = 0 → f'' x = 0 := Eventually.mono h.bound fun x hx hg => norm_le_zero_iff.1 <| by simpa [hg] using hx theorem IsBigO.eq_zero_imp (h : f'' =O[l] g'') : ∀ᶠ x in l, g'' x = 0 → f'' x = 0 := let ⟨_C, hC⟩ := h.isBigOWith hC.eq_zero_imp /-! ### Addition and subtraction -/ section add_sub variable {f₁ f₂ : α → E'} {g₁ g₂ : α → F'} theorem IsBigOWith.add (h₁ : IsBigOWith c₁ l f₁ g) (h₂ : IsBigOWith c₂ l f₂ g) : IsBigOWith (c₁ + c₂) l (fun x => f₁ x + f₂ x) g := by rw [IsBigOWith_def] at * filter_upwards [h₁, h₂] with x hx₁ hx₂ using calc ‖f₁ x + f₂ x‖ ≤ c₁ * ‖g x‖ + c₂ * ‖g x‖ := norm_add_le_of_le hx₁ hx₂ _ = (c₁ + c₂) * ‖g x‖ := (add_mul _ _ _).symm theorem IsBigO.add (h₁ : f₁ =O[l] g) (h₂ : f₂ =O[l] g) : (fun x => f₁ x + f₂ x) =O[l] g := let ⟨_c₁, hc₁⟩ := h₁.isBigOWith let ⟨_c₂, hc₂⟩ := h₂.isBigOWith (hc₁.add hc₂).isBigO theorem IsLittleO.add (h₁ : f₁ =o[l] g) (h₂ : f₂ =o[l] g) : (fun x => f₁ x + f₂ x) =o[l] g := IsLittleO.of_isBigOWith fun c cpos => ((h₁.forall_isBigOWith <| half_pos cpos).add (h₂.forall_isBigOWith <| half_pos cpos)).congr_const (add_halves c) theorem IsLittleO.add_add (h₁ : f₁ =o[l] g₁) (h₂ : f₂ =o[l] g₂) : (fun x => f₁ x + f₂ x) =o[l] fun x => ‖g₁ x‖ + ‖g₂ x‖ := by refine (h₁.trans_le fun x => ?_).add (h₂.trans_le ?_) <;> simp [abs_of_nonneg, add_nonneg] theorem IsBigO.add_isLittleO (h₁ : f₁ =O[l] g) (h₂ : f₂ =o[l] g) : (fun x => f₁ x + f₂ x) =O[l] g := h₁.add h₂.isBigO theorem IsLittleO.add_isBigO (h₁ : f₁ =o[l] g) (h₂ : f₂ =O[l] g) : (fun x => f₁ x + f₂ x) =O[l] g := h₁.isBigO.add h₂ theorem IsBigOWith.add_isLittleO (h₁ : IsBigOWith c₁ l f₁ g) (h₂ : f₂ =o[l] g) (hc : c₁ < c₂) : IsBigOWith c₂ l (fun x => f₁ x + f₂ x) g := (h₁.add (h₂.forall_isBigOWith (sub_pos.2 hc))).congr_const (add_sub_cancel _ _) theorem IsLittleO.add_isBigOWith (h₁ : f₁ =o[l] g) (h₂ : IsBigOWith c₁ l f₂ g) (hc : c₁ < c₂) : IsBigOWith c₂ l (fun x => f₁ x + f₂ x) g := (h₂.add_isLittleO h₁ hc).congr_left fun _ => add_comm _ _ theorem IsBigOWith.sub (h₁ : IsBigOWith c₁ l f₁ g) (h₂ : IsBigOWith c₂ l f₂ g) : IsBigOWith (c₁ + c₂) l (fun x => f₁ x - f₂ x) g := by simpa only [sub_eq_add_neg] using h₁.add h₂.neg_left theorem IsBigOWith.sub_isLittleO (h₁ : IsBigOWith c₁ l f₁ g) (h₂ : f₂ =o[l] g) (hc : c₁ < c₂) : IsBigOWith c₂ l (fun x => f₁ x - f₂ x) g := by simpa only [sub_eq_add_neg] using h₁.add_isLittleO h₂.neg_left hc theorem IsBigO.sub (h₁ : f₁ =O[l] g) (h₂ : f₂ =O[l] g) : (fun x => f₁ x - f₂ x) =O[l] g := by simpa only [sub_eq_add_neg] using h₁.add h₂.neg_left theorem IsLittleO.sub (h₁ : f₁ =o[l] g) (h₂ : f₂ =o[l] g) : (fun x => f₁ x - f₂ x) =o[l] g := by simpa only [sub_eq_add_neg] using h₁.add h₂.neg_left theorem IsBigO.add_iff_left (h₂ : f₂ =O[l] g) : (fun x => f₁ x + f₂ x) =O[l] g ↔ (f₁ =O[l] g):= ⟨fun h ↦ h.sub h₂ |>.congr (fun _ ↦ add_sub_cancel_right _ _) (fun _ ↦ rfl), fun h ↦ h.add h₂⟩ theorem IsBigO.add_iff_right (h₁ : f₁ =O[l] g) : (fun x => f₁ x + f₂ x) =O[l] g ↔ (f₂ =O[l] g):= ⟨fun h ↦ h.sub h₁ |>.congr (fun _ ↦ (eq_sub_of_add_eq' rfl).symm) (fun _ ↦ rfl), fun h ↦ h₁.add h⟩ theorem IsLittleO.add_iff_left (h₂ : f₂ =o[l] g) : (fun x => f₁ x + f₂ x) =o[l] g ↔ (f₁ =o[l] g):= ⟨fun h ↦ h.sub h₂ |>.congr (fun _ ↦ add_sub_cancel_right _ _) (fun _ ↦ rfl), fun h ↦ h.add h₂⟩ theorem IsLittleO.add_iff_right (h₁ : f₁ =o[l] g) : (fun x => f₁ x + f₂ x) =o[l] g ↔ (f₂ =o[l] g):= ⟨fun h ↦ h.sub h₁ |>.congr (fun _ ↦ (eq_sub_of_add_eq' rfl).symm) (fun _ ↦ rfl), fun h ↦ h₁.add h⟩ theorem IsBigO.sub_iff_left (h₂ : f₂ =O[l] g) : (fun x => f₁ x - f₂ x) =O[l] g ↔ (f₁ =O[l] g):= ⟨fun h ↦ h.add h₂ |>.congr (fun _ ↦ sub_add_cancel ..) (fun _ ↦ rfl), fun h ↦ h.sub h₂⟩ theorem IsBigO.sub_iff_right (h₁ : f₁ =O[l] g) : (fun x => f₁ x - f₂ x) =O[l] g ↔ (f₂ =O[l] g):= ⟨fun h ↦ h₁.sub h |>.congr (fun _ ↦ sub_sub_self ..) (fun _ ↦ rfl), fun h ↦ h₁.sub h⟩ theorem IsLittleO.sub_iff_left (h₂ : f₂ =o[l] g) : (fun x => f₁ x - f₂ x) =o[l] g ↔ (f₁ =o[l] g):= ⟨fun h ↦ h.add h₂ |>.congr (fun _ ↦ sub_add_cancel ..) (fun _ ↦ rfl), fun h ↦ h.sub h₂⟩ theorem IsLittleO.sub_iff_right (h₁ : f₁ =o[l] g) : (fun x => f₁ x - f₂ x) =o[l] g ↔ (f₂ =o[l] g):= ⟨fun h ↦ h₁.sub h |>.congr (fun _ ↦ sub_sub_self ..) (fun _ ↦ rfl), fun h ↦ h₁.sub h⟩ end add_sub /-! ### Lemmas about `IsBigO (f₁ - f₂) g l` / `IsLittleO (f₁ - f₂) g l` treated as a binary relation -/ section IsBigOOAsRel variable {f₁ f₂ f₃ : α → E'} theorem IsBigOWith.symm (h : IsBigOWith c l (fun x => f₁ x - f₂ x) g) : IsBigOWith c l (fun x => f₂ x - f₁ x) g := h.neg_left.congr_left fun _x => neg_sub _ _ theorem isBigOWith_comm : IsBigOWith c l (fun x => f₁ x - f₂ x) g ↔ IsBigOWith c l (fun x => f₂ x - f₁ x) g := ⟨IsBigOWith.symm, IsBigOWith.symm⟩ theorem IsBigO.symm (h : (fun x => f₁ x - f₂ x) =O[l] g) : (fun x => f₂ x - f₁ x) =O[l] g := h.neg_left.congr_left fun _x => neg_sub _ _ theorem isBigO_comm : (fun x => f₁ x - f₂ x) =O[l] g ↔ (fun x => f₂ x - f₁ x) =O[l] g := ⟨IsBigO.symm, IsBigO.symm⟩ theorem IsLittleO.symm (h : (fun x => f₁ x - f₂ x) =o[l] g) : (fun x => f₂ x - f₁ x) =o[l] g := by simpa only [neg_sub] using h.neg_left theorem isLittleO_comm : (fun x => f₁ x - f₂ x) =o[l] g ↔ (fun x => f₂ x - f₁ x) =o[l] g := ⟨IsLittleO.symm, IsLittleO.symm⟩ theorem IsBigOWith.triangle (h₁ : IsBigOWith c l (fun x => f₁ x - f₂ x) g) (h₂ : IsBigOWith c' l (fun x => f₂ x - f₃ x) g) : IsBigOWith (c + c') l (fun x => f₁ x - f₃ x) g := (h₁.add h₂).congr_left fun _x => sub_add_sub_cancel _ _ _ theorem IsBigO.triangle (h₁ : (fun x => f₁ x - f₂ x) =O[l] g) (h₂ : (fun x => f₂ x - f₃ x) =O[l] g) : (fun x => f₁ x - f₃ x) =O[l] g := (h₁.add h₂).congr_left fun _x => sub_add_sub_cancel _ _ _ theorem IsLittleO.triangle (h₁ : (fun x => f₁ x - f₂ x) =o[l] g) (h₂ : (fun x => f₂ x - f₃ x) =o[l] g) : (fun x => f₁ x - f₃ x) =o[l] g := (h₁.add h₂).congr_left fun _x => sub_add_sub_cancel _ _ _ theorem IsBigO.congr_of_sub (h : (fun x => f₁ x - f₂ x) =O[l] g) : f₁ =O[l] g ↔ f₂ =O[l] g := ⟨fun h' => (h'.sub h).congr_left fun _x => sub_sub_cancel _ _, fun h' => (h.add h').congr_left fun _x => sub_add_cancel _ _⟩ theorem IsLittleO.congr_of_sub (h : (fun x => f₁ x - f₂ x) =o[l] g) : f₁ =o[l] g ↔ f₂ =o[l] g := ⟨fun h' => (h'.sub h).congr_left fun _x => sub_sub_cancel _ _, fun h' => (h.add h').congr_left fun _x => sub_add_cancel _ _⟩ end IsBigOOAsRel /-! ### Zero, one, and other constants -/ section ZeroConst variable (g g' l) theorem isLittleO_zero : (fun _x => (0 : E')) =o[l] g' := IsLittleO.of_bound fun c hc => univ_mem' fun x => by simpa using mul_nonneg hc.le (norm_nonneg <| g' x) theorem isBigOWith_zero (hc : 0 ≤ c) : IsBigOWith c l (fun _x => (0 : E')) g' := IsBigOWith.of_bound <| univ_mem' fun x => by simpa using mul_nonneg hc (norm_nonneg <| g' x) theorem isBigOWith_zero' : IsBigOWith 0 l (fun _x => (0 : E')) g := IsBigOWith.of_bound <| univ_mem' fun x => by simp theorem isBigO_zero : (fun _x => (0 : E')) =O[l] g := isBigO_iff_isBigOWith.2 ⟨0, isBigOWith_zero' _ _⟩ theorem isBigO_refl_left : (fun x => f' x - f' x) =O[l] g' := (isBigO_zero g' l).congr_left fun _x => (sub_self _).symm theorem isLittleO_refl_left : (fun x => f' x - f' x) =o[l] g' := (isLittleO_zero g' l).congr_left fun _x => (sub_self _).symm variable {g g' l} @[simp] theorem isBigOWith_zero_right_iff : (IsBigOWith c l f'' fun _x => (0 : F')) ↔ f'' =ᶠ[l] 0 := by simp only [IsBigOWith_def, norm_zero, mul_zero, norm_le_zero_iff, EventuallyEq, Pi.zero_apply] @[simp] theorem isBigO_zero_right_iff : (f'' =O[l] fun _x => (0 : F')) ↔ f'' =ᶠ[l] 0 := ⟨fun h => let ⟨_c, hc⟩ := h.isBigOWith isBigOWith_zero_right_iff.1 hc, fun h => (isBigOWith_zero_right_iff.2 h : IsBigOWith 1 _ _ _).isBigO⟩ @[simp] theorem isLittleO_zero_right_iff : (f'' =o[l] fun _x => (0 : F')) ↔ f'' =ᶠ[l] 0 := ⟨fun h => isBigO_zero_right_iff.1 h.isBigO, fun h => IsLittleO.of_isBigOWith fun _c _hc => isBigOWith_zero_right_iff.2 h⟩ theorem isBigOWith_const_const (c : E) {c' : F''} (hc' : c' ≠ 0) (l : Filter α) : IsBigOWith (‖c‖ / ‖c'‖) l (fun _x : α => c) fun _x => c' := by simp only [IsBigOWith_def] apply univ_mem' intro x rw [mem_setOf, div_mul_cancel₀ _ (norm_ne_zero_iff.mpr hc')] theorem isBigO_const_const (c : E) {c' : F''} (hc' : c' ≠ 0) (l : Filter α) : (fun _x : α => c) =O[l] fun _x => c' := (isBigOWith_const_const c hc' l).isBigO @[simp] theorem isBigO_const_const_iff {c : E''} {c' : F''} (l : Filter α) [l.NeBot] : ((fun _x : α => c) =O[l] fun _x => c') ↔ c' = 0 → c = 0 := by rcases eq_or_ne c' 0 with (rfl | hc') · simp [EventuallyEq] · simp [hc', isBigO_const_const _ hc'] @[simp] theorem isBigO_pure {x} : f'' =O[pure x] g'' ↔ g'' x = 0 → f'' x = 0 := calc f'' =O[pure x] g'' ↔ (fun _y : α => f'' x) =O[pure x] fun _ => g'' x := isBigO_congr rfl rfl _ ↔ g'' x = 0 → f'' x = 0 := isBigO_const_const_iff _ end ZeroConst /-! ### Multiplication by a constant -/ theorem isBigOWith_const_mul_self (c : R) (f : α → R) (l : Filter α) : IsBigOWith ‖c‖ l (fun x => c * f x) f := isBigOWith_of_le' _ fun _x => norm_mul_le _ _ theorem isBigO_const_mul_self (c : R) (f : α → R) (l : Filter α) : (fun x => c * f x) =O[l] f := (isBigOWith_const_mul_self c f l).isBigO theorem IsBigOWith.const_mul_left {f : α → R} (h : IsBigOWith c l f g) (c' : R) : IsBigOWith (‖c'‖ * c) l (fun x => c' * f x) g := (isBigOWith_const_mul_self c' f l).trans h (norm_nonneg c') theorem IsBigO.const_mul_left {f : α → R} (h : f =O[l] g) (c' : R) : (fun x => c' * f x) =O[l] g := let ⟨_c, hc⟩ := h.isBigOWith (hc.const_mul_left c').isBigO theorem isBigOWith_self_const_mul' (u : Rˣ) (f : α → R) (l : Filter α) : IsBigOWith ‖(↑u⁻¹ : R)‖ l f fun x => ↑u * f x := (isBigOWith_const_mul_self ↑u⁻¹ (fun x ↦ ↑u * f x) l).congr_left fun x ↦ u.inv_mul_cancel_left (f x) theorem isBigOWith_self_const_mul {c : S} (hc : c ≠ 0) (f : α → S) (l : Filter α) : IsBigOWith ‖c‖⁻¹ l f fun x ↦ c * f x := by simp [IsBigOWith, inv_mul_cancel_left₀ (norm_ne_zero_iff.mpr hc)] theorem isBigO_self_const_mul' {c : R} (hc : IsUnit c) (f : α → R) (l : Filter α) : f =O[l] fun x => c * f x := let ⟨u, hu⟩ := hc hu ▸ (isBigOWith_self_const_mul' u f l).isBigO theorem isBigO_self_const_mul {c : S} (hc : c ≠ 0) (f : α → S) (l : Filter α) : f =O[l] fun x ↦ c * f x := (isBigOWith_self_const_mul hc f l).isBigO theorem isBigO_const_mul_left_iff' {f : α → R} {c : R} (hc : IsUnit c) : (fun x => c * f x) =O[l] g ↔ f =O[l] g := ⟨(isBigO_self_const_mul' hc f l).trans, fun h => h.const_mul_left c⟩ theorem isBigO_const_mul_left_iff {f : α → S} {c : S} (hc : c ≠ 0) : (fun x => c * f x) =O[l] g ↔ f =O[l] g := ⟨(isBigO_self_const_mul hc f l).trans, (isBigO_const_mul_self c f l).trans⟩ theorem IsLittleO.const_mul_left {f : α → R} (h : f =o[l] g) (c : R) : (fun x => c * f x) =o[l] g := (isBigO_const_mul_self c f l).trans_isLittleO h theorem isLittleO_const_mul_left_iff' {f : α → R} {c : R} (hc : IsUnit c) : (fun x => c * f x) =o[l] g ↔ f =o[l] g := ⟨(isBigO_self_const_mul' hc f l).trans_isLittleO, fun h => h.const_mul_left c⟩ theorem isLittleO_const_mul_left_iff {f : α → S} {c : S} (hc : c ≠ 0) : (fun x => c * f x) =o[l] g ↔ f =o[l] g := ⟨(isBigO_self_const_mul hc f l).trans_isLittleO, (isBigO_const_mul_self c f l).trans_isLittleO⟩ theorem IsBigOWith.of_const_mul_right {g : α → R} {c : R} (hc' : 0 ≤ c') (h : IsBigOWith c' l f fun x => c * g x) : IsBigOWith (c' * ‖c‖) l f g := h.trans (isBigOWith_const_mul_self c g l) hc' theorem IsBigO.of_const_mul_right {g : α → R} {c : R} (h : f =O[l] fun x => c * g x) : f =O[l] g := let ⟨_c, cnonneg, hc⟩ := h.exists_nonneg (hc.of_const_mul_right cnonneg).isBigO theorem IsBigOWith.const_mul_right' {g : α → R} {u : Rˣ} {c' : ℝ} (hc' : 0 ≤ c') (h : IsBigOWith c' l f g) : IsBigOWith (c' * ‖(↑u⁻¹ : R)‖) l f fun x => ↑u * g x := h.trans (isBigOWith_self_const_mul' _ _ _) hc' theorem IsBigOWith.const_mul_right {g : α → S} {c : S} (hc : c ≠ 0) {c' : ℝ} (hc' : 0 ≤ c') (h : IsBigOWith c' l f g) : IsBigOWith (c' * ‖c‖⁻¹) l f fun x => c * g x := h.trans (isBigOWith_self_const_mul hc g l) hc' theorem IsBigO.const_mul_right' {g : α → R} {c : R} (hc : IsUnit c) (h : f =O[l] g) : f =O[l] fun x => c * g x := h.trans (isBigO_self_const_mul' hc g l) theorem IsBigO.const_mul_right {g : α → S} {c : S} (hc : c ≠ 0) (h : f =O[l] g) : f =O[l] fun x => c * g x := match h.exists_nonneg with | ⟨_, hd, hd'⟩ => (hd'.const_mul_right hc hd).isBigO theorem isBigO_const_mul_right_iff' {g : α → R} {c : R} (hc : IsUnit c) : (f =O[l] fun x => c * g x) ↔ f =O[l] g := ⟨fun h => h.of_const_mul_right, fun h => h.const_mul_right' hc⟩ theorem isBigO_const_mul_right_iff {g : α → S} {c : S} (hc : c ≠ 0) : (f =O[l] fun x => c * g x) ↔ f =O[l] g := ⟨fun h ↦ h.of_const_mul_right, fun h ↦ h.const_mul_right hc⟩ theorem IsLittleO.of_const_mul_right {g : α → R} {c : R} (h : f =o[l] fun x => c * g x) : f =o[l] g := h.trans_isBigO (isBigO_const_mul_self c g l) theorem IsLittleO.const_mul_right' {g : α → R} {c : R} (hc : IsUnit c) (h : f =o[l] g) : f =o[l] fun x => c * g x := h.trans_isBigO (isBigO_self_const_mul' hc g l) theorem IsLittleO.const_mul_right {g : α → S} {c : S} (hc : c ≠ 0) (h : f =o[l] g) : f =o[l] fun x => c * g x := h.trans_isBigO <| isBigO_self_const_mul hc g l theorem isLittleO_const_mul_right_iff' {g : α → R} {c : R} (hc : IsUnit c) : (f =o[l] fun x => c * g x) ↔ f =o[l] g := ⟨fun h => h.of_const_mul_right, fun h => h.const_mul_right' hc⟩ theorem isLittleO_const_mul_right_iff {g : α → S} {c : S} (hc : c ≠ 0) : (f =o[l] fun x => c * g x) ↔ f =o[l] g := ⟨fun h ↦ h.of_const_mul_right, fun h ↦ h.trans_isBigO (isBigO_self_const_mul hc g l)⟩ /-! ### Multiplication -/ theorem IsBigOWith.mul {f₁ f₂ : α → R} {g₁ g₂ : α → S} {c₁ c₂ : ℝ} (h₁ : IsBigOWith c₁ l f₁ g₁) (h₂ : IsBigOWith c₂ l f₂ g₂) : IsBigOWith (c₁ * c₂) l (fun x => f₁ x * f₂ x) fun x => g₁ x * g₂ x := by simp only [IsBigOWith_def] at * filter_upwards [h₁, h₂] with _ hx₁ hx₂ apply le_trans (norm_mul_le _ _) convert mul_le_mul hx₁ hx₂ (norm_nonneg _) (le_trans (norm_nonneg _) hx₁) using 1 rw [norm_mul, mul_mul_mul_comm] theorem IsBigO.mul {f₁ f₂ : α → R} {g₁ g₂ : α → S} (h₁ : f₁ =O[l] g₁) (h₂ : f₂ =O[l] g₂) : (fun x => f₁ x * f₂ x) =O[l] fun x => g₁ x * g₂ x := let ⟨_c, hc⟩ := h₁.isBigOWith let ⟨_c', hc'⟩ := h₂.isBigOWith (hc.mul hc').isBigO theorem IsBigO.mul_isLittleO {f₁ f₂ : α → R} {g₁ g₂ : α → S} (h₁ : f₁ =O[l] g₁) (h₂ : f₂ =o[l] g₂) : (fun x => f₁ x * f₂ x) =o[l] fun x => g₁ x * g₂ x := by simp only [IsLittleO_def] at * intro c cpos rcases h₁.exists_pos with ⟨c', c'pos, hc'⟩ exact (hc'.mul (h₂ (div_pos cpos c'pos))).congr_const (mul_div_cancel₀ _ (ne_of_gt c'pos)) theorem IsLittleO.mul_isBigO {f₁ f₂ : α → R} {g₁ g₂ : α → S} (h₁ : f₁ =o[l] g₁) (h₂ : f₂ =O[l] g₂) : (fun x ↦ f₁ x * f₂ x) =o[l] fun x ↦ g₁ x * g₂ x := by simp only [IsLittleO_def] at * intro c cpos rcases h₂.exists_pos with ⟨c', c'pos, hc'⟩ exact ((h₁ (div_pos cpos c'pos)).mul hc').congr_const (div_mul_cancel₀ _ (ne_of_gt c'pos)) theorem IsLittleO.mul {f₁ f₂ : α → R} {g₁ g₂ : α → S} (h₁ : f₁ =o[l] g₁) (h₂ : f₂ =o[l] g₂) : (fun x ↦ f₁ x * f₂ x) =o[l] fun x ↦ g₁ x * g₂ x := h₁.mul_isBigO h₂.isBigO theorem IsBigOWith.pow' [NormOneClass S] {f : α → R} {g : α → S} (h : IsBigOWith c l f g) : ∀ n : ℕ, IsBigOWith (Nat.casesOn n ‖(1 : R)‖ fun n ↦ c ^ (n + 1)) l (fun x => f x ^ n) fun x => g x ^ n | 0 => by have : Nontrivial S := NormOneClass.nontrivial simpa using isBigOWith_const_const (1 : R) (one_ne_zero' S) l | 1 => by simpa | n + 2 => by simpa [pow_succ] using (IsBigOWith.pow' h (n + 1)).mul h theorem IsBigOWith.pow [NormOneClass R] [NormOneClass S] {f : α → R} {g : α → S} (h : IsBigOWith c l f g) : ∀ n : ℕ, IsBigOWith (c ^ n) l (fun x => f x ^ n) fun x => g x ^ n | 0 => by simpa using h.pow' 0 | n + 1 => h.pow' (n + 1) theorem IsBigOWith.of_pow [NormOneClass S] {n : ℕ} {f : α → S} {g : α → R} (h : IsBigOWith c l (f ^ n) (g ^ n)) (hn : n ≠ 0) (hc : c ≤ c' ^ n) (hc' : 0 ≤ c') : IsBigOWith c' l f g := IsBigOWith.of_bound <| (h.weaken hc).bound.mono fun x hx ↦ le_of_pow_le_pow_left₀ hn (by positivity) <| calc ‖f x‖ ^ n = ‖f x ^ n‖ := (norm_pow _ _).symm _ ≤ c' ^ n * ‖g x ^ n‖ := hx _ ≤ c' ^ n * ‖g x‖ ^ n := by gcongr; exact norm_pow_le' _ hn.bot_lt _ = (c' * ‖g x‖) ^ n := (mul_pow _ _ _).symm theorem IsBigO.pow [NormOneClass S] {f : α → R} {g : α → S} (h : f =O[l] g) (n : ℕ) : (fun x => f x ^ n) =O[l] fun x => g x ^ n := let ⟨_C, hC⟩ := h.isBigOWith isBigO_iff_isBigOWith.2 ⟨_, hC.pow' n⟩ theorem IsLittleO.pow {f : α → R} {g : α → S} (h : f =o[l] g) {n : ℕ} (hn : 0 < n) : (fun x => f x ^ n) =o[l] fun x => g x ^ n := by obtain ⟨n, rfl⟩ := Nat.exists_eq_succ_of_ne_zero hn.ne'; clear hn induction n with | zero => simpa only [pow_one] | succ n ihn => convert ihn.mul h <;> simp [pow_succ] theorem IsLittleO.of_pow [NormOneClass S] {f : α → S} {g : α → R} {n : ℕ} (h : (f ^ n) =o[l] (g ^ n)) (hn : n ≠ 0) : f =o[l] g := IsLittleO.of_isBigOWith fun _c hc => (h.def' <| pow_pos hc _).of_pow hn le_rfl hc.le /-! ### Inverse -/ theorem IsBigOWith.inv_rev {f : α → 𝕜} {g : α → 𝕜'} (h : IsBigOWith c l f g) (h₀ : ∀ᶠ x in l, f x = 0 → g x = 0) : IsBigOWith c l (fun x => (g x)⁻¹) fun x => (f x)⁻¹ := by refine IsBigOWith.of_bound (h.bound.mp (h₀.mono fun x h₀ hle => ?_)) rcases eq_or_ne (f x) 0 with hx | hx · simp only [hx, h₀ hx, inv_zero, norm_zero, mul_zero, le_rfl] · have hc : 0 < c := pos_of_mul_pos_left ((norm_pos_iff.2 hx).trans_le hle) (norm_nonneg _) replace hle := inv_anti₀ (norm_pos_iff.2 hx) hle simpa only [norm_inv, mul_inv, ← div_eq_inv_mul, div_le_iff₀ hc] using hle theorem IsBigO.inv_rev {f : α → 𝕜} {g : α → 𝕜'} (h : f =O[l] g) (h₀ : ∀ᶠ x in l, f x = 0 → g x = 0) : (fun x => (g x)⁻¹) =O[l] fun x => (f x)⁻¹ := let ⟨_c, hc⟩ := h.isBigOWith (hc.inv_rev h₀).isBigO theorem IsLittleO.inv_rev {f : α → 𝕜} {g : α → 𝕜'} (h : f =o[l] g) (h₀ : ∀ᶠ x in l, f x = 0 → g x = 0) : (fun x => (g x)⁻¹) =o[l] fun x => (f x)⁻¹ := IsLittleO.of_isBigOWith fun _c hc => (h.def' hc).inv_rev h₀ /-! ### Sum -/ section Sum variable {ι : Type*} {A : ι → α → E'} {C : ι → ℝ} {s : Finset ι} theorem IsBigOWith.sum (h : ∀ i ∈ s, IsBigOWith (C i) l (A i) g) : IsBigOWith (∑ i ∈ s, C i) l (fun x => ∑ i ∈ s, A i x) g := by induction s using Finset.cons_induction with | empty => simp only [isBigOWith_zero', Finset.sum_empty] | cons i s is IH => simp only [Finset.sum_cons, Finset.forall_mem_cons] at h ⊢ exact h.1.add (IH h.2) theorem IsBigO.sum (h : ∀ i ∈ s, A i =O[l] g) : (fun x => ∑ i ∈ s, A i x) =O[l] g := by simp only [IsBigO_def] at * choose! C hC using h exact ⟨_, IsBigOWith.sum hC⟩ theorem IsLittleO.sum (h : ∀ i ∈ s, A i =o[l] g') : (fun x => ∑ i ∈ s, A i x) =o[l] g' := by simp only [← Finset.sum_apply] exact Finset.sum_induction A (· =o[l] g') (fun _ _ ↦ .add) (isLittleO_zero ..) h end Sum /-! ### Eventually (u / v) * v = u If `u` and `v` are linked by an `IsBigOWith` relation, then we eventually have `(u / v) * v = u`, even if `v` vanishes. -/ section EventuallyMulDivCancel variable {u v : α → 𝕜} theorem IsBigOWith.eventually_mul_div_cancel (h : IsBigOWith c l u v) : u / v * v =ᶠ[l] u := Eventually.mono h.bound fun y hy => div_mul_cancel_of_imp fun hv => by simpa [hv] using hy /-- If `u = O(v)` along `l`, then `(u / v) * v = u` eventually at `l`. -/ theorem IsBigO.eventually_mul_div_cancel (h : u =O[l] v) : u / v * v =ᶠ[l] u := let ⟨_c, hc⟩ := h.isBigOWith hc.eventually_mul_div_cancel /-- If `u = o(v)` along `l`, then `(u / v) * v = u` eventually at `l`. -/ theorem IsLittleO.eventually_mul_div_cancel (h : u =o[l] v) : u / v * v =ᶠ[l] u := (h.forall_isBigOWith zero_lt_one).eventually_mul_div_cancel end EventuallyMulDivCancel end Asymptotics
.lake/packages/mathlib/Mathlib/Analysis/Asymptotics/LinearGrowth.lean
import Mathlib.Analysis.SpecificLimits.Basic /-! # Linear growth This file defines the linear growth of a sequence `u : ℕ → R`. This notion comes in two versions, using a `liminf` and a `limsup` respectively. Most properties are developed for `R = EReal`. ## Main definitions - `linearGrowthInf`, `linearGrowthSup`: respectively, `liminf` and `limsup` of `(u n) / n`. - `linearGrowthInfTopHom`, `linearGrowthSupBotHom`: the functions `linearGrowthInf`, `linearGrowthSup` as homomorphisms preserving finitary `Inf`/`Sup` respectively. ## TODO Generalize statements from `EReal` to `ENNReal` (or others). This may need additional typeclasses. Lemma about coercion from `ENNReal` to `EReal`. This needs additional lemmas about `ENNReal.toEReal`. -/ namespace LinearGrowth open EReal Filter Function open scoped Topology /-! ### Definition -/ section definition variable {R : Type*} [ConditionallyCompleteLattice R] [Div R] [NatCast R] /-- Lower linear growth of a sequence. -/ noncomputable def linearGrowthInf (u : ℕ → R) : R := liminf (fun n ↦ u n / n) atTop /-- Upper linear growth of a sequence. -/ noncomputable def linearGrowthSup (u : ℕ → R) : R := limsup (fun n ↦ u n / n) atTop end definition /-! ### Basic properties -/ section basic_properties variable {R : Type*} [ConditionallyCompleteLattice R] [Div R] [NatCast R] {u v : ℕ → R} lemma linearGrowthInf_congr (h : u =ᶠ[atTop] v) : linearGrowthInf u = linearGrowthInf v := liminf_congr (h.mono fun _ uv ↦ uv ▸ rfl) lemma linearGrowthSup_congr (h : u =ᶠ[atTop] v) : linearGrowthSup u = linearGrowthSup v := limsup_congr (h.mono fun _ uv ↦ uv ▸ rfl) lemma linearGrowthInf_le_linearGrowthSup (h : IsBoundedUnder (· ≤ ·) atTop fun n ↦ u n / n := by isBoundedDefault) (h' : IsBoundedUnder (· ≥ ·) atTop fun n ↦ u n / n := by isBoundedDefault) : linearGrowthInf u ≤ linearGrowthSup u := liminf_le_limsup h h' end basic_properties section basic_properties variable {u v : ℕ → EReal} {a b : EReal} lemma linearGrowthInf_eventually_monotone (h : u ≤ᶠ[atTop] v) : linearGrowthInf u ≤ linearGrowthInf v := liminf_le_liminf (h.mono fun n u_v ↦ EReal.monotone_div_right_of_nonneg n.cast_nonneg' u_v) lemma linearGrowthInf_monotone (h : u ≤ v) : linearGrowthInf u ≤ linearGrowthInf v := linearGrowthInf_eventually_monotone (Eventually.of_forall h) lemma linearGrowthSup_eventually_monotone (h : u ≤ᶠ[atTop] v) : linearGrowthSup u ≤ linearGrowthSup v := limsup_le_limsup (h.mono fun n u_v ↦ monotone_div_right_of_nonneg n.cast_nonneg' u_v) lemma linearGrowthSup_monotone (h : u ≤ v) : linearGrowthSup u ≤ linearGrowthSup v := linearGrowthSup_eventually_monotone (Eventually.of_forall h) lemma linearGrowthInf_le_linearGrowthSup_of_frequently_le (h : ∃ᶠ n in atTop, u n ≤ v n) : linearGrowthInf u ≤ linearGrowthSup v := (liminf_le_limsup_of_frequently_le) <| h.mono fun n u_v ↦ by gcongr lemma linearGrowthInf_le_iff : linearGrowthInf u ≤ a ↔ ∀ b > a, ∃ᶠ n : ℕ in atTop, u n ≤ b * n := by rw [linearGrowthInf, liminf_le_iff'] refine forall₂_congr fun b _ ↦ frequently_congr (eventually_atTop.2 ⟨1, fun n _ ↦ ?_⟩) rw [div_le_iff_le_mul (by norm_cast) (natCast_ne_top n), mul_comm _ b] lemma le_linearGrowthInf_iff : a ≤ linearGrowthInf u ↔ ∀ b < a, ∀ᶠ n : ℕ in atTop, b * n ≤ u n := by rw [linearGrowthInf, le_liminf_iff'] refine forall₂_congr fun b _ ↦ eventually_congr (eventually_atTop.2 ⟨1, fun n _ ↦ ?_⟩) nth_rw 1 [le_div_iff_mul_le (by norm_cast) (natCast_ne_top n)] lemma linearGrowthSup_le_iff : linearGrowthSup u ≤ a ↔ ∀ b > a, ∀ᶠ n : ℕ in atTop, u n ≤ b * n := by rw [linearGrowthSup, limsup_le_iff'] refine forall₂_congr fun b _ ↦ eventually_congr (eventually_atTop.2 ⟨1, fun n _ ↦ ?_⟩) rw [div_le_iff_le_mul (by norm_cast) (natCast_ne_top n), mul_comm _ b] lemma le_linearGrowthSup_iff : a ≤ linearGrowthSup u ↔ ∀ b < a, ∃ᶠ n : ℕ in atTop, b * n ≤ u n := by rw [linearGrowthSup, le_limsup_iff'] refine forall₂_congr fun b _ ↦ frequently_congr (eventually_atTop.2 ⟨1, fun n _ ↦ ?_⟩) nth_rw 1 [le_div_iff_mul_le (by norm_cast) (natCast_ne_top n)] /- Forward direction of `linearGrowthInf_le_iff`. -/ lemma frequently_le_mul (h : linearGrowthInf u < a) : ∃ᶠ n : ℕ in atTop, u n ≤ a * n := linearGrowthInf_le_iff.1 (le_refl (linearGrowthInf u)) a h /- Forward direction of `le_linearGrowthInf_iff`. -/ lemma eventually_mul_le (h : a < linearGrowthInf u) : ∀ᶠ n : ℕ in atTop, a * n ≤ u n := le_linearGrowthInf_iff.1 (le_refl (linearGrowthInf u)) a h /- Forward direction of `linearGrowthSup_le_iff`. -/ lemma eventually_le_mul (h : linearGrowthSup u < a) : ∀ᶠ n : ℕ in atTop, u n ≤ a * n := linearGrowthSup_le_iff.1 (le_refl (linearGrowthSup u)) a h /- Forward direction of `le_linearGrowthSup_iff`. -/ lemma frequently_mul_le (h : a < linearGrowthSup u) : ∃ᶠ n : ℕ in atTop, a * n ≤ u n := le_linearGrowthSup_iff.1 (le_refl (linearGrowthSup u)) a h lemma _root_.Frequently.linearGrowthInf_le (h : ∃ᶠ n : ℕ in atTop, u n ≤ a * n) : linearGrowthInf u ≤ a := linearGrowthInf_le_iff.2 fun c c_u ↦ h.mono fun n hn ↦ hn.trans <| by gcongr lemma _root_.Eventually.le_linearGrowthInf (h : ∀ᶠ n : ℕ in atTop, a * n ≤ u n) : a ≤ linearGrowthInf u := le_linearGrowthInf_iff.2 fun c c_u ↦ h.mono fun n hn ↦ hn.trans' <| by gcongr lemma _root_.Eventually.linearGrowthSup_le (h : ∀ᶠ n : ℕ in atTop, u n ≤ a * n) : linearGrowthSup u ≤ a:= linearGrowthSup_le_iff.2 fun c c_u ↦ h.mono fun n hn ↦ hn.trans <| by gcongr lemma _root_.Frequently.le_linearGrowthSup (h : ∃ᶠ n : ℕ in atTop, a * n ≤ u n) : a ≤ linearGrowthSup u := le_linearGrowthSup_iff.2 fun c c_u ↦ h.mono fun n hn ↦ hn.trans' <| by gcongr /-! ### Special cases -/ lemma linearGrowthSup_bot : linearGrowthSup (⊥ : ℕ → EReal) = (⊥ : EReal) := by nth_rw 2 [← limsup_const (f := atTop (α := ℕ)) ⊥] refine limsup_congr <| (eventually_gt_atTop 0).mono fun n n_pos ↦ ?_ exact bot_div_of_pos_ne_top (by positivity) (natCast_ne_top n) lemma linearGrowthInf_bot : linearGrowthInf (⊥ : ℕ → EReal) = (⊥ : EReal) := by apply le_bot_iff.1 rw [← linearGrowthSup_bot] exact linearGrowthInf_le_linearGrowthSup lemma linearGrowthInf_top : linearGrowthInf ⊤ = (⊤ : EReal) := by nth_rw 2 [← liminf_const (f := atTop (α := ℕ)) ⊤] refine liminf_congr (eventually_atTop.2 ?_) exact ⟨1, fun n n_pos ↦ top_div_of_pos_ne_top (Nat.cast_pos'.2 n_pos) (natCast_ne_top n)⟩ lemma linearGrowthSup_top : linearGrowthSup (⊤ : ℕ → EReal) = (⊤ : EReal) := by apply top_le_iff.1 rw [← linearGrowthInf_top] exact linearGrowthInf_le_linearGrowthSup lemma linearGrowthInf_const (h : b ≠ ⊥) (h' : b ≠ ⊤) : linearGrowthInf (fun _ ↦ b) = 0 := (tendsto_const_div_atTop_nhds_zero_nat h h').liminf_eq lemma linearGrowthSup_const (h : b ≠ ⊥) (h' : b ≠ ⊤) : linearGrowthSup (fun _ ↦ b) = 0 := (tendsto_const_div_atTop_nhds_zero_nat h h').limsup_eq lemma linearGrowthInf_zero : linearGrowthInf 0 = (0 : EReal) := linearGrowthInf_const zero_ne_bot zero_ne_top lemma linearGrowthSup_zero : linearGrowthSup 0 = (0 : EReal) := linearGrowthSup_const zero_ne_bot zero_ne_top lemma linearGrowthInf_const_mul_self : linearGrowthInf (fun n ↦ a * n) = a := le_antisymm (Frequently.linearGrowthInf_le (Frequently.of_forall fun _ ↦ le_refl _)) (Eventually.le_linearGrowthInf (Eventually.of_forall fun _ ↦ le_refl _)) lemma linearGrowthSup_const_mul_self : linearGrowthSup (fun n ↦ a * n) = a := le_antisymm (Eventually.linearGrowthSup_le (Eventually.of_forall fun _ ↦ le_refl _)) (Frequently.le_linearGrowthSup (Frequently.of_forall fun _ ↦ le_refl _)) lemma linearGrowthInf_natCast_nonneg (v : ℕ → ℕ) : 0 ≤ linearGrowthInf fun n ↦ (v n : EReal) := (le_liminf_of_le) (Eventually.of_forall fun n ↦ div_nonneg (v n).cast_nonneg' n.cast_nonneg') lemma tendsto_atTop_of_linearGrowthInf_pos (h : 0 < linearGrowthInf u) : Tendsto u atTop (𝓝 ⊤) := by obtain ⟨a, a_0, a_v⟩ := exists_between h apply tendsto_nhds_top_mono _ ((le_linearGrowthInf_iff (u := u)).1 (le_refl _) a a_v) refine tendsto_nhds_top_iff_real.2 fun M ↦ eventually_atTop.2 ?_ lift a to ℝ using ⟨ne_top_of_lt a_v, ne_bot_of_gt a_0⟩ rw [EReal.coe_pos] at a_0 obtain ⟨n, hn⟩ := exists_nat_ge (M / a) refine ⟨n + 1, fun k k_n ↦ ?_⟩ rw [← coe_coe_eq_natCast, ← coe_mul, EReal.coe_lt_coe_iff, mul_comm] exact (div_lt_iff₀ a_0).1 (hn.trans_lt (Nat.cast_lt.2 k_n)) /-! ### Addition and negation -/ lemma le_linearGrowthInf_add : linearGrowthInf u + linearGrowthInf v ≤ linearGrowthInf (u + v) := by refine le_liminf_add.trans_eq (liminf_congr (Eventually.of_forall fun n ↦ ?_)) rw [Pi.add_apply, Pi.add_apply, ← add_div_of_nonneg_right n.cast_nonneg'] /-- See `linearGrowthInf_add_le'` for a version with swapped argument `u` and `v`. -/ lemma linearGrowthInf_add_le (h : linearGrowthSup u ≠ ⊥ ∨ linearGrowthInf v ≠ ⊤) (h' : linearGrowthSup u ≠ ⊤ ∨ linearGrowthInf v ≠ ⊥) : linearGrowthInf (u + v) ≤ linearGrowthSup u + linearGrowthInf v := by refine (liminf_add_le h h').trans_eq' (liminf_congr (Eventually.of_forall fun n ↦ ?_)) rw [Pi.add_apply, Pi.add_apply, ← add_div_of_nonneg_right n.cast_nonneg'] /-- See `linearGrowthInf_add_le` for a version with swapped argument `u` and `v`. -/ lemma linearGrowthInf_add_le' (h : linearGrowthInf u ≠ ⊥ ∨ linearGrowthSup v ≠ ⊤) (h' : linearGrowthInf u ≠ ⊤ ∨ linearGrowthSup v ≠ ⊥) : linearGrowthInf (u + v) ≤ linearGrowthInf u + linearGrowthSup v := by rw [add_comm u v, add_comm (linearGrowthInf u) (linearGrowthSup v)] exact linearGrowthInf_add_le h'.symm h.symm /-- See `le_linearGrowthSup_add'` for a version with swapped argument `u` and `v`. -/ lemma le_linearGrowthSup_add : linearGrowthSup u + linearGrowthInf v ≤ linearGrowthSup (u + v) := by refine le_limsup_add.trans_eq (limsup_congr (Eventually.of_forall fun n ↦ ?_)) rw [Pi.add_apply, Pi.add_apply, add_div_of_nonneg_right n.cast_nonneg'] /-- See `le_linearGrowthSup_add` for a version with swapped argument `u` and `v`. -/ lemma le_linearGrowthSup_add' : linearGrowthInf u + linearGrowthSup v ≤ linearGrowthSup (u + v) := by rw [add_comm u v, add_comm (linearGrowthInf u) (linearGrowthSup v)] exact le_linearGrowthSup_add lemma linearGrowthSup_add_le (h : linearGrowthSup u ≠ ⊥ ∨ linearGrowthSup v ≠ ⊤) (h' : linearGrowthSup u ≠ ⊤ ∨ linearGrowthSup v ≠ ⊥) : linearGrowthSup (u + v) ≤ linearGrowthSup u + linearGrowthSup v := by refine (limsup_add_le h h').trans_eq' (limsup_congr (Eventually.of_forall fun n ↦ ?_)) rw [Pi.add_apply, Pi.add_apply, add_div_of_nonneg_right n.cast_nonneg'] lemma linearGrowthInf_neg : linearGrowthInf (- u) = - linearGrowthSup u := by rw [linearGrowthSup, ← liminf_neg] refine liminf_congr (Eventually.of_forall fun n ↦ ?_) rw [Pi.neg_apply, Pi.neg_apply, div_eq_mul_inv, div_eq_mul_inv, ← neg_mul] lemma linearGrowthSup_inv : linearGrowthSup (- u) = - linearGrowthInf u := by rw [linearGrowthInf, ← limsup_neg] refine limsup_congr (Eventually.of_forall fun n ↦ ?_) rw [Pi.neg_apply, Pi.neg_apply, div_eq_mul_inv, div_eq_mul_inv, ← neg_mul] /-! ### Affine bounds -/ lemma linearGrowthInf_le_of_eventually_le (hb : b ≠ ⊤) (h : ∀ᶠ n in atTop, u n ≤ v n + b) : linearGrowthInf u ≤ linearGrowthInf v := by apply (linearGrowthInf_eventually_monotone h).trans rcases eq_bot_or_bot_lt b with rfl | b_bot · simp only [add_bot, ← Pi.bot_def, linearGrowthInf_bot, bot_le] · apply (linearGrowthInf_add_le' _ _).trans_eq <;> rw [linearGrowthSup_const b_bot.ne' hb] · exact add_zero (linearGrowthInf v) · exact Or.inr EReal.zero_ne_top · exact Or.inr EReal.zero_ne_bot lemma linearGrowthSup_le_of_eventually_le (hb : b ≠ ⊤) (h : ∀ᶠ n in atTop, u n ≤ v n + b) : linearGrowthSup u ≤ linearGrowthSup v := by apply (linearGrowthSup_eventually_monotone h).trans rcases eq_bot_or_bot_lt b with rfl | b_bot · simp only [add_bot, ← Pi.bot_def, linearGrowthSup_bot, bot_le] · apply (linearGrowthSup_add_le _ _).trans_eq <;> rw [linearGrowthSup_const b_bot.ne' hb] · exact add_zero (linearGrowthSup v) · exact Or.inr EReal.zero_ne_top · exact Or.inr EReal.zero_ne_bot /-! ### Infimum and supremum -/ lemma linearGrowthInf_inf : linearGrowthInf (u ⊓ v) = min (linearGrowthInf u) (linearGrowthInf v) := by rw [linearGrowthInf, linearGrowthInf, linearGrowthInf, ← liminf_min] refine liminf_congr (Eventually.of_forall fun n ↦ ?_) exact (monotone_div_right_of_nonneg n.cast_nonneg').map_min /-- Lower linear growth as an `InfTopHom`. -/ noncomputable def linearGrowthInfTopHom : InfTopHom (ℕ → EReal) EReal where toFun := linearGrowthInf map_inf' _ _ := linearGrowthInf_inf map_top' := linearGrowthInf_top lemma linearGrowthInf_biInf {α : Type*} (u : α → ℕ → EReal) {s : Set α} (hs : s.Finite) : linearGrowthInf (⨅ x ∈ s, u x) = ⨅ x ∈ s, linearGrowthInf (u x) := by have := map_finset_inf linearGrowthInfTopHom hs.toFinset u simpa only [linearGrowthInfTopHom, InfTopHom.coe_mk, InfHom.coe_mk, Finset.inf_eq_iInf, hs.mem_toFinset, comp_apply] lemma linearGrowthInf_iInf {ι : Type*} [Finite ι] (u : ι → ℕ → EReal) : linearGrowthInf (⨅ i, u i) = ⨅ i, linearGrowthInf (u i) := by rw [← iInf_univ, linearGrowthInf_biInf u Set.finite_univ, iInf_univ] lemma linearGrowthSup_sup : linearGrowthSup (u ⊔ v) = max (linearGrowthSup u) (linearGrowthSup v) := by rw [linearGrowthSup, linearGrowthSup, linearGrowthSup, ← limsup_max] refine limsup_congr (Eventually.of_forall fun n ↦ ?_) exact (monotone_div_right_of_nonneg n.cast_nonneg').map_max /-- Upper linear growth as a `SupBotHom`. -/ noncomputable def linearGrowthSupBotHom : SupBotHom (ℕ → EReal) EReal where toFun := linearGrowthSup map_sup' _ _ := linearGrowthSup_sup map_bot' := linearGrowthSup_bot lemma linearGrowthSup_biSup {α : Type*} (u : α → ℕ → EReal) {s : Set α} (hs : s.Finite) : linearGrowthSup (⨆ x ∈ s, u x) = ⨆ x ∈ s, linearGrowthSup (u x) := by have := map_finset_sup linearGrowthSupBotHom hs.toFinset u simpa only [linearGrowthSupBotHom, SupBotHom.coe_mk, SupHom.coe_mk, Finset.sup_eq_iSup, hs.mem_toFinset, comp_apply] lemma linearGrowthSup_iSup {ι : Type*} [Finite ι] (u : ι → ℕ → EReal) : linearGrowthSup (⨆ i, u i) = ⨆ i, linearGrowthSup (u i) := by rw [← iSup_univ, linearGrowthSup_biSup u Set.finite_univ, iSup_univ] end basic_properties /-! ### Composition -/ section composition variable {u : ℕ → EReal} {v : ℕ → ℕ} lemma Real.eventually_atTop_exists_int_between {a b : ℝ} (h : a < b) : ∀ᶠ x : ℝ in atTop, ∃ n : ℤ, a * x ≤ n ∧ n ≤ b * x := by refine (eventually_ge_atTop (b-a)⁻¹).mono fun x ab_x ↦ ?_ rw [inv_le_iff_one_le_mul₀ (sub_pos_of_lt h), mul_comm, sub_mul, le_sub_iff_add_le'] at ab_x obtain ⟨n, n_bx, hn⟩ := (b * x).exists_floor refine ⟨n, ?_, n_bx⟩ specialize hn (n + 1) simp only [Int.cast_add, Int.cast_one, add_le_iff_nonpos_right, Int.reduceLE, imp_false, not_le] at hn exact le_of_add_le_add_right (ab_x.trans hn.le) lemma Real.eventually_atTop_exists_nat_between {a b : ℝ} (h : a < b) (hb : 0 ≤ b) : ∀ᶠ x : ℝ in atTop, ∃ n : ℕ, a * x ≤ n ∧ n ≤ b * x := by filter_upwards [eventually_ge_atTop 0, Real.eventually_atTop_exists_int_between h] with x x_0 ⟨m, m_a, m_b⟩ refine ⟨m.toNat, m_a.trans (Int.cast_le.2 m.self_le_toNat), ?_⟩ apply le_of_eq_of_le _ (max_le m_b (mul_nonneg hb x_0)) norm_cast exact Int.toNat_eq_max m lemma EReal.eventually_atTop_exists_nat_between {a b : EReal} (h : a < b) (hb : 0 ≤ b) : ∀ᶠ n : ℕ in atTop, ∃ m : ℕ, a * n ≤ m ∧ m ≤ b * n := match a with | ⊤ => (not_top_lt h).rec | ⊥ => by refine Eventually.of_forall fun n ↦ ⟨0, ?_, ?_⟩ <;> rw [Nat.cast_zero] · apply mul_nonpos_iff.2 -- Split apply and exact for a 0.5s. gain exact .inr ⟨bot_le, n.cast_nonneg'⟩ · exact mul_nonneg hb n.cast_nonneg' | (a : ℝ) => match b with | ⊤ => by refine (eventually_gt_atTop 0).mono fun n n_0 ↦ ?_ obtain ⟨m, hm⟩ := exists_nat_ge_mul h.ne n exact ⟨m, hm, le_of_le_of_eq le_top (top_mul_of_pos (Nat.cast_pos'.2 n_0)).symm⟩ | ⊥ => (not_lt_bot h).rec | (b : ℝ) => by obtain ⟨x, hx⟩ := eventually_atTop.1 <| Real.eventually_atTop_exists_nat_between (EReal.coe_lt_coe_iff.1 h) (EReal.coe_nonneg.1 hb) obtain ⟨n, x_n⟩ := exists_nat_ge x refine eventually_atTop.2 ⟨n, fun k n_k ↦ ?_⟩ simp only [← coe_coe_eq_natCast, ← EReal.coe_mul, EReal.coe_le_coe_iff] exact hx k (x_n.trans (Nat.cast_le.2 n_k)) lemma tendsto_atTop_of_linearGrowthInf_natCast_pos (h : (linearGrowthInf fun n ↦ v n : EReal) ≠ 0) : Tendsto v atTop atTop := by refine tendsto_atTop.2 fun M ↦ ?_ have := tendsto_atTop_of_linearGrowthInf_pos (h.lt_of_le' (linearGrowthInf_natCast_nonneg v)) refine (tendsto_nhds_top_iff_real.1 this M).mono fun n ↦ ?_ rw [coe_coe_eq_natCast, Nat.cast_lt] exact le_of_lt lemma le_linearGrowthInf_comp (hu : 0 ≤ᶠ[atTop] u) (hv : Tendsto v atTop atTop) : (linearGrowthInf fun n ↦ v n : EReal) * linearGrowthInf u ≤ linearGrowthInf (u ∘ v) := by have uv_0 : 0 ≤ linearGrowthInf (u ∘ v) := by rw [← linearGrowthInf_const zero_ne_bot zero_ne_top] exact linearGrowthInf_eventually_monotone (hv.eventually hu) apply EReal.mul_le_of_forall_lt_of_nonneg (linearGrowthInf_natCast_nonneg v) uv_0 refine fun a ⟨_, a_v⟩ b ⟨b_0, b_u⟩ ↦ Eventually.le_linearGrowthInf ?_ have b_uv := eventually_map.1 ((eventually_mul_le b_u).filter_mono hv) filter_upwards [b_uv, eventually_lt_of_lt_liminf a_v, eventually_gt_atTop 0] with n b_uvn a_vn n_0 replace a_vn := ((lt_div_iff (Nat.cast_pos'.2 n_0) (natCast_ne_top n)).1 a_vn).le rw [comp_apply, mul_comm a b, mul_assoc b a] exact b_uvn.trans' <| by gcongr lemma linearGrowthSup_comp_le (hu : ∃ᶠ n in atTop, 0 ≤ u n) (hv₀ : (linearGrowthSup fun n ↦ v n : EReal) ≠ 0) (hv₁ : (linearGrowthSup fun n ↦ v n : EReal) ≠ ⊤) (hv₂ : Tendsto v atTop atTop) : linearGrowthSup (u ∘ v) ≤ (linearGrowthSup fun n ↦ v n : EReal) * linearGrowthSup u := by have v_0 := hv₀.symm.lt_of_le <| (linearGrowthInf_natCast_nonneg v).trans (liminf_le_limsup) refine le_mul_of_forall_lt (.inl v_0) (.inl hv₁) ?_ refine fun a v_a b u_b ↦ Eventually.linearGrowthSup_le ?_ have b_0 : 0 ≤ b := by rw [← linearGrowthInf_const zero_ne_bot zero_ne_top] exact (linearGrowthInf_le_linearGrowthSup_of_frequently_le hu).trans u_b.le have uv_b : ∀ᶠ n in atTop, u (v n) ≤ b * v n := eventually_map.1 ((eventually_le_mul u_b).filter_mono hv₂) filter_upwards [uv_b, eventually_lt_of_limsup_lt v_a, eventually_gt_atTop 0] with n uvn_b vn_a n_0 replace vn_a := ((div_lt_iff (Nat.cast_pos'.2 n_0) (natCast_ne_top n)).1 vn_a).le rw [comp_apply, mul_comm a b, mul_assoc b a] exact uvn_b.trans <| by gcongr /-! ### Monotone sequences -/ lemma _root_.Monotone.linearGrowthInf_nonneg (h : Monotone u) (h' : u ≠ ⊥) : 0 ≤ linearGrowthInf u := by simp only [ne_eq, funext_iff, not_forall] at h' obtain ⟨m, hm⟩ := h' have m_n : ∀ᶠ n in atTop, u m ≤ u n := eventually_atTop.2 ⟨m, fun _ hb ↦ h hb⟩ rcases eq_or_ne (u m) ⊤ with hm' | hm' · rw [hm'] at m_n exact le_top.trans (linearGrowthInf_top.symm.trans_le (linearGrowthInf_eventually_monotone m_n)) · rw [← linearGrowthInf_const hm hm'] exact linearGrowthInf_eventually_monotone m_n lemma _root_.Monotone.linearGrowthSup_nonneg (h : Monotone u) (h' : u ≠ ⊥) : 0 ≤ linearGrowthSup u := (h.linearGrowthInf_nonneg h').trans (linearGrowthInf_le_linearGrowthSup) lemma linearGrowthInf_comp_nonneg (h : Monotone u) (h' : u ≠ ⊥) (hv : Tendsto v atTop atTop) : 0 ≤ linearGrowthInf (u ∘ v) := by simp only [ne_eq, funext_iff, not_forall] at h' obtain ⟨m, hum⟩ := h' have um_uvn : ∀ᶠ n in atTop, u m ≤ (u ∘ v) n := by apply (eventually_map (P := fun n : ℕ ↦ u m ≤ u n)).2 exact (eventually_atTop.2 ⟨m, fun n m_n ↦ h m_n⟩).filter_mono hv apply (linearGrowthInf_eventually_monotone um_uvn).trans' rcases eq_or_ne (u m) ⊤ with hum' | hum' · rw [hum', ← Pi.top_def, linearGrowthInf_top]; exact le_top · rw [linearGrowthInf_const hum hum'] lemma linearGrowthSup_comp_nonneg (h : Monotone u) (h' : u ≠ ⊥) (hv : Tendsto v atTop atTop) : 0 ≤ linearGrowthSup (u ∘ v) := (linearGrowthInf_comp_nonneg h h' hv).trans linearGrowthInf_le_linearGrowthSup lemma _root_.Monotone.linearGrowthInf_comp_le (h : Monotone u) (hv₀ : (linearGrowthSup fun n ↦ v n : EReal) ≠ 0) (hv₁ : (linearGrowthSup fun n ↦ v n : EReal) ≠ ⊤) : linearGrowthInf (u ∘ v) ≤ (linearGrowthSup fun n ↦ v n : EReal) * linearGrowthInf u := by -- First we apply `le_mul_of_forall_lt`. by_cases u_0 : u = ⊥ · rw [u_0, Pi.bot_comp, linearGrowthInf_bot]; exact bot_le have v_0 := hv₀.symm.lt_of_le <| (linearGrowthInf_natCast_nonneg v).trans (liminf_le_limsup) refine le_mul_of_forall_lt (.inl v_0) (.inl hv₁) fun a v_a b u_b ↦ ?_ have a_0 := v_0.trans v_a have b_0 := (h.linearGrowthInf_nonneg u_0).trans_lt u_b rcases eq_or_ne a ⊤ with rfl | a_top · rw [top_mul_of_pos b_0]; exact le_top apply Frequently.linearGrowthInf_le obtain ⟨a', v_a', a_a'⟩ := exists_between v_a -- We get an epsilon of room: if `m` is large enough, then `v n ≤ a' * n < a * n`. -- Using `u_b`, we can find arbitrarily large values `n` such that `u n ≤ b * n`. -- If such an `n` is large enough, then we can find an integer `k` such that -- `a⁻¹ * n ≤ k ≤ a'⁻¹ * n`, or, in other words, `a' * k ≤ n ≤ a * k`. -- Then `v k ≤ a' * k ≤ n`, so `u (v k) ≤ u n ≤ b * n ≤ b * a * k`. have a_0' := v_0.trans v_a' have a_a_inv' : a⁻¹ < a'⁻¹ := inv_strictAntiOn (Set.mem_Ioi.2 a_0') (Set.mem_Ioi.2 a_0) a_a' replace v_a' : ∀ᶠ n : ℕ in atTop, v n ≤ a' * n := by filter_upwards [eventually_lt_of_limsup_lt v_a', eventually_gt_atTop 0] with n vn_a' n_0 rw [mul_comm] exact (div_le_iff_le_mul (Nat.cast_pos'.2 n_0) (natCast_ne_top n)).1 vn_a'.le suffices h : (∀ᶠ n : ℕ in atTop, v n ≤ a' * n) → ∃ᶠ n : ℕ in atTop, (u ∘ v) n ≤ a * b * n from h v_a' rw [← frequently_imp_distrib] replace u_b := ((frequently_le_mul u_b).and_eventually (eventually_gt_atTop 0)).and_eventually <| EReal.eventually_atTop_exists_nat_between a_a_inv' (inv_nonneg_of_nonneg a_0'.le) refine frequently_atTop.2 fun M ↦ ?_ obtain ⟨M', aM_M'⟩ := exists_nat_ge_mul a_top M obtain ⟨n, n_M', ⟨un_bn, _⟩, k, an_k, k_an'⟩ := frequently_atTop.1 u_b M' refine ⟨k, ?_, fun vk_ak' ↦ ?_⟩ · rw [mul_comm a, ← le_div_iff_mul_le a_0 a_top, EReal.div_eq_inv_mul] at aM_M' apply Nat.cast_le.1 <| aM_M'.trans <| an_k.trans' _ gcongr · rw [comp_apply, mul_comm a b, mul_assoc b a] rw [← EReal.div_eq_inv_mul, le_div_iff_mul_le a_0' (ne_top_of_lt a_a'), mul_comm] at k_an' rw [← EReal.div_eq_inv_mul, div_le_iff_le_mul a_0 a_top] at an_k have vk_n := Nat.cast_le.1 (vk_ak'.trans k_an') exact (h vk_n).trans <| un_bn.trans <| by gcongr lemma _root_.Monotone.le_linearGrowthSup_comp (h : Monotone u) (hv : (linearGrowthInf fun n ↦ v n : EReal) ≠ 0) : (linearGrowthInf fun n ↦ v n : EReal) * linearGrowthSup u ≤ linearGrowthSup (u ∘ v) := by have v_0 := hv.symm.lt_of_le (linearGrowthInf_natCast_nonneg v) -- WLOG, `u` is non-bot, and we can apply `mul_le_of_forall_lt_of_nonneg`. by_cases u_0 : u = ⊥ · rw [u_0, linearGrowthSup_bot, mul_bot_of_pos v_0]; exact bot_le apply EReal.mul_le_of_forall_lt_of_nonneg v_0.le (linearGrowthSup_comp_nonneg h u_0 (tendsto_atTop_of_linearGrowthInf_natCast_pos hv)) intro a ⟨a_0, a_v⟩ b ⟨b_0, b_u⟩ apply Frequently.le_linearGrowthSup obtain ⟨a', a_a', a_v'⟩ := exists_between a_v -- We get an epsilon of room: if `m` is large enough, then `a * n < a' * n ≤ v n`. -- Using `b_u`, we can find arbitrarily large values `n` such that `b * n ≤ u n`. -- If such an `n` is large enough, then we can find an integer `k` such that -- `a'⁻¹ * n ≤ k ≤ a⁻¹ * n`, or, in other words, `a * k ≤ n ≤ a' * k`. -- Then `v k ≥ a' * k ≥ n`, so `u (v k) ≥ u n ≥ b * n ≥ b * a * k`. have a_top' := ne_top_of_lt a_v' have a_0' := a_0.trans a_a' have a_a_inv' : a'⁻¹ < a⁻¹ := inv_strictAntiOn (Set.mem_Ioi.2 a_0) (Set.mem_Ioi.2 a_0') a_a' replace a_v' : ∀ᶠ n : ℕ in atTop, a' * n ≤ v n := by filter_upwards [eventually_lt_of_lt_liminf a_v', eventually_gt_atTop 0] with n a_vn' n_0 exact (le_div_iff_mul_le (Nat.cast_pos'.2 n_0) (natCast_ne_top n)).1 a_vn'.le suffices h : (∀ᶠ n : ℕ in atTop, a' * n ≤ v n) → ∃ᶠ n : ℕ in atTop, a * b * n ≤ (u ∘ v) n from h a_v' rw [← frequently_imp_distrib] replace b_u := ((frequently_mul_le b_u).and_eventually (eventually_gt_atTop 0)).and_eventually <| EReal.eventually_atTop_exists_nat_between a_a_inv' (inv_nonneg_of_nonneg a_0.le) refine frequently_atTop.2 fun M ↦ ?_ obtain ⟨M', aM_M'⟩ := exists_nat_ge_mul a_top' M obtain ⟨n, n_M', ⟨bn_un, _⟩, k, an_k', k_an⟩ := frequently_atTop.1 b_u M' refine ⟨k, ?_, fun ak_vk' ↦ ?_⟩ · rw [mul_comm a', ← le_div_iff_mul_le a_0' a_top', EReal.div_eq_inv_mul] at aM_M' apply Nat.cast_le.1 <| aM_M'.trans <| an_k'.trans' _ gcongr · rw [comp_apply, mul_comm a b, mul_assoc b a] rw [← EReal.div_eq_inv_mul, div_le_iff_le_mul a_0' a_top'] at an_k' rw [← EReal.div_eq_inv_mul, le_div_iff_mul_le a_0 (ne_top_of_lt a_a'), mul_comm] at k_an have n_vk := Nat.cast_le.1 (an_k'.trans ak_vk') exact le_trans (by gcongr) <| bn_un.trans (h n_vk) lemma _root_.Monotone.linearGrowthInf_comp {a : EReal} (h : Monotone u) (hv : Tendsto (fun n ↦ (v n : EReal) / n) atTop (𝓝 a)) (ha : a ≠ 0) (ha' : a ≠ ⊤) : linearGrowthInf (u ∘ v) = a * linearGrowthInf u := by have hv₁ : 0 < liminf (fun n ↦ (v n : EReal) / n) atTop := by rw [← hv.liminf_eq] at ha exact ha.symm.lt_of_le (linearGrowthInf_natCast_nonneg v) have v_top := tendsto_atTop_of_linearGrowthInf_natCast_pos hv₁.ne.symm -- Either `u = 0`, or `u` is non-zero and bounded by `1`, or `u` is eventually larger than one. -- In the latter case, we apply `le_linearGrowthInf_comp` and `linearGrowthInf_comp_le`. by_cases u_0 : u = ⊥ · rw [u_0, Pi.bot_comp, linearGrowthInf_bot, ← hv.liminf_eq, mul_bot_of_pos hv₁] by_cases h1 : ∃ᶠ n : ℕ in atTop, u n ≤ 0 · replace h' (n : ℕ) : u n ≤ 0 := by obtain ⟨m, n_m, um_1⟩ := (frequently_atTop.1 h1) n exact (h n_m).trans um_1 have u_0' : linearGrowthInf u = 0 := by apply le_antisymm _ (h.linearGrowthInf_nonneg u_0) exact (linearGrowthInf_monotone h').trans_eq (linearGrowthInf_const zero_ne_bot zero_ne_top) rw [u_0', mul_zero] apply le_antisymm _ (linearGrowthInf_comp_nonneg h u_0 v_top) apply (linearGrowthInf_monotone fun n ↦ h' (v n)).trans_eq exact linearGrowthInf_const zero_ne_bot zero_ne_top · replace h' := (not_frequently.1 h1).mono fun _ hn ↦ le_of_not_ge hn apply le_antisymm · rw [← hv.limsup_eq] at ha ha' ⊢ exact h.linearGrowthInf_comp_le ha ha' · rw [← hv.liminf_eq] exact le_linearGrowthInf_comp h' v_top lemma _root_.Monotone.linearGrowthSup_comp {a : EReal} (h : Monotone u) (hv : Tendsto (fun n ↦ (v n : EReal) / n) atTop (𝓝 a)) (ha : a ≠ 0) (ha' : a ≠ ⊤) : linearGrowthSup (u ∘ v) = a * linearGrowthSup u := by have hv₁ : 0 < liminf (fun n ↦ (v n : EReal) / n) atTop := by rw [← hv.liminf_eq] at ha exact ha.symm.lt_of_le (linearGrowthInf_natCast_nonneg v) have v_top := tendsto_atTop_of_linearGrowthInf_natCast_pos hv₁.ne.symm -- Either `u = 0`, or `u` is non-zero and bounded by `1`, or `u` is eventually larger than one. -- In the latter case, we apply `le_linearGrowthSup_comp` and `linearGrowthSup_comp_le`. by_cases u_0 : u = ⊥ · rw [u_0, Pi.bot_comp, linearGrowthSup_bot, ← hv.liminf_eq, mul_bot_of_pos hv₁] by_cases u_1 : ∀ᶠ n : ℕ in atTop, u n ≤ 0 · have u_0' : linearGrowthSup u = 0 := by apply le_antisymm _ (h.linearGrowthSup_nonneg u_0) apply (linearGrowthSup_eventually_monotone u_1).trans_eq exact (linearGrowthSup_const zero_ne_bot zero_ne_top) rw [u_0', mul_zero] apply le_antisymm _ (linearGrowthSup_comp_nonneg h u_0 v_top) apply (linearGrowthSup_eventually_monotone (v_top.eventually u_1)).trans_eq exact linearGrowthSup_const zero_ne_bot zero_ne_top · replace h' := (not_eventually.1 u_1).mono fun x hx ↦ (lt_of_not_ge hx).le apply le_antisymm · rw [← hv.limsup_eq] at ha ha' ⊢ exact linearGrowthSup_comp_le h' ha ha' v_top · rw [← hv.liminf_eq] exact h.le_linearGrowthSup_comp hv₁.ne.symm lemma _root_.Monotone.linearGrowthInf_comp_mul {m : ℕ} (h : Monotone u) (hm : m ≠ 0) : linearGrowthInf (fun n ↦ u (m * n)) = m * linearGrowthInf u := by have : Tendsto (fun n : ℕ ↦ ((m * n : ℕ) : EReal) / n) atTop (𝓝 m) := by refine tendsto_nhds_of_eventually_eq ((eventually_gt_atTop 0).mono fun x hx ↦ ?_) rw [mul_comm, natCast_mul x m, ← mul_div] exact mul_div_cancel (natCast_ne_bot x) (natCast_ne_top x) (Nat.cast_ne_zero.2 hx.ne.symm) exact h.linearGrowthInf_comp this (Nat.cast_ne_zero.2 hm) (natCast_ne_top m) lemma _root_.Monotone.linearGrowthSup_comp_mul {m : ℕ} (h : Monotone u) (hm : m ≠ 0) : linearGrowthSup (fun n ↦ u (m * n)) = m * linearGrowthSup u := by have : Tendsto (fun n : ℕ ↦ ((m * n : ℕ) : EReal) / n) atTop (𝓝 m) := by refine tendsto_nhds_of_eventually_eq ((eventually_gt_atTop 0).mono fun x hx ↦ ?_) rw [mul_comm, natCast_mul x m, ← mul_div] exact mul_div_cancel (natCast_ne_bot x) (natCast_ne_top x) (Nat.cast_ne_zero.2 hx.ne.symm) exact h.linearGrowthSup_comp this (Nat.cast_ne_zero.2 hm) (natCast_ne_top m) end composition end LinearGrowth
.lake/packages/mathlib/Mathlib/Analysis/Asymptotics/SuperpolynomialDecay.lean
import Mathlib.Algebra.Polynomial.Eval.Defs import Mathlib.Analysis.Asymptotics.Lemmas /-! # Super-Polynomial Function Decay This file defines a predicate `Asymptotics.SuperpolynomialDecay f` for a function satisfying one of the following equivalent definitions (the definition is in terms of the first condition): * `x ^ n * f` tends to `𝓝 0` for all (or sufficiently large) naturals `n` * `|x ^ n * f|` tends to `𝓝 0` for all naturals `n` (`superpolynomialDecay_iff_abs_tendsto_zero`) * `|x ^ n * f|` is bounded for all naturals `n` (`superpolynomialDecay_iff_abs_isBoundedUnder`) * `f` is `o(x ^ c)` for all integers `c` (`superpolynomialDecay_iff_isLittleO`) * `f` is `O(x ^ c)` for all integers `c` (`superpolynomialDecay_iff_isBigO`) These conditions are all equivalent to conditions in terms of polynomials, replacing `x ^ c` with `p(x)` or `p(x)⁻¹` as appropriate, since asymptotically `p(x)` behaves like `X ^ p.natDegree`. These further equivalences are not proven in mathlib but would be good future projects. The definition of superpolynomial decay for `f : α → β` is relative to a parameter `k : α → β`. Super-polynomial decay then means `f x` decays faster than `(k x) ^ c` for all integers `c`. Equivalently `f x` decays faster than `p.eval (k x)` for all polynomials `p : β[X]`. The definition is also relative to a filter `l : Filter α` where the decay rate is compared. When the map `k` is given by `n ↦ ↑n : ℕ → ℝ` this defines negligible functions: https://en.wikipedia.org/wiki/Negligible_function When the map `k` is given by `(r₁,...,rₙ) ↦ r₁*...*rₙ : ℝⁿ → ℝ` this is equivalent to the definition of rapidly decreasing functions given here: https://ncatlab.org/nlab/show/rapidly+decreasing+function ## Main statements * `SuperpolynomialDecay.polynomial_mul` says that if `f(x)` is negligible, then so is `p(x) * f(x)` for any polynomial `p`. * `superpolynomialDecay_iff_zpow_tendsto_zero` gives an equivalence between definitions in terms of decaying faster than `k(x) ^ n` for all naturals `n` or `k(x) ^ c` for all integer `c`. -/ namespace Asymptotics open Topology Polynomial open Filter /-- `f` has superpolynomial decay in parameter `k` along filter `l` if `k ^ n * f` tends to zero at `l` for all naturals `n` -/ def SuperpolynomialDecay {α β : Type*} [TopologicalSpace β] [CommSemiring β] (l : Filter α) (k : α → β) (f : α → β) := ∀ n : ℕ, Tendsto (fun a : α => k a ^ n * f a) l (𝓝 0) variable {α β : Type*} {l : Filter α} {k : α → β} {f g g' : α → β} section CommSemiring variable [TopologicalSpace β] [CommSemiring β] theorem SuperpolynomialDecay.congr' (hf : SuperpolynomialDecay l k f) (hfg : f =ᶠ[l] g) : SuperpolynomialDecay l k g := fun z => (hf z).congr' (EventuallyEq.mul (EventuallyEq.refl l _) hfg) theorem SuperpolynomialDecay.congr (hf : SuperpolynomialDecay l k f) (hfg : ∀ x, f x = g x) : SuperpolynomialDecay l k g := fun z => (hf z).congr fun x => (congr_arg fun a => k x ^ z * a) <| hfg x @[simp] theorem superpolynomialDecay_zero (l : Filter α) (k : α → β) : SuperpolynomialDecay l k 0 := fun z => by simpa only [Pi.zero_apply, mul_zero] using tendsto_const_nhds theorem SuperpolynomialDecay.add [ContinuousAdd β] (hf : SuperpolynomialDecay l k f) (hg : SuperpolynomialDecay l k g) : SuperpolynomialDecay l k (f + g) := fun z => by simpa only [mul_add, add_zero, Pi.add_apply] using (hf z).add (hg z) theorem SuperpolynomialDecay.mul [ContinuousMul β] (hf : SuperpolynomialDecay l k f) (hg : SuperpolynomialDecay l k g) : SuperpolynomialDecay l k (f * g) := fun z => by simpa only [mul_assoc, one_mul, mul_zero, pow_zero] using (hf z).mul (hg 0) theorem SuperpolynomialDecay.mul_const [ContinuousMul β] (hf : SuperpolynomialDecay l k f) (c : β) : SuperpolynomialDecay l k fun n => f n * c := fun z => by simpa only [← mul_assoc, zero_mul] using Tendsto.mul_const c (hf z) theorem SuperpolynomialDecay.const_mul [ContinuousMul β] (hf : SuperpolynomialDecay l k f) (c : β) : SuperpolynomialDecay l k fun n => c * f n := (hf.mul_const c).congr fun _ => mul_comm _ _ theorem SuperpolynomialDecay.param_mul (hf : SuperpolynomialDecay l k f) : SuperpolynomialDecay l k (k * f) := fun z => tendsto_nhds.2 fun s hs hs0 => l.sets_of_superset ((tendsto_nhds.1 (hf <| z + 1)) s hs hs0) fun x hx => by simpa only [Set.mem_preimage, Pi.mul_apply, ← mul_assoc, ← pow_succ] using hx theorem SuperpolynomialDecay.mul_param (hf : SuperpolynomialDecay l k f) : SuperpolynomialDecay l k (f * k) := hf.param_mul.congr fun _ => mul_comm _ _ theorem SuperpolynomialDecay.param_pow_mul (hf : SuperpolynomialDecay l k f) (n : ℕ) : SuperpolynomialDecay l k (k ^ n * f) := by induction n with | zero => simpa only [one_mul, pow_zero] using hf | succ n hn => simpa only [pow_succ', mul_assoc] using hn.param_mul theorem SuperpolynomialDecay.mul_param_pow (hf : SuperpolynomialDecay l k f) (n : ℕ) : SuperpolynomialDecay l k (f * k ^ n) := (hf.param_pow_mul n).congr fun _ => mul_comm _ _ theorem SuperpolynomialDecay.polynomial_mul [ContinuousAdd β] [ContinuousMul β] (hf : SuperpolynomialDecay l k f) (p : β[X]) : SuperpolynomialDecay l k fun x => (p.eval <| k x) * f x := Polynomial.induction_on' p (fun p q hp hq => by simpa [add_mul] using hp.add hq) fun n c => by simpa [mul_assoc] using (hf.param_pow_mul n).const_mul c theorem SuperpolynomialDecay.mul_polynomial [ContinuousAdd β] [ContinuousMul β] (hf : SuperpolynomialDecay l k f) (p : β[X]) : SuperpolynomialDecay l k fun x => f x * (p.eval <| k x) := (hf.polynomial_mul p).congr fun _ => mul_comm _ _ end CommSemiring section OrderedCommSemiring variable [TopologicalSpace β] [CommSemiring β] [PartialOrder β] [IsOrderedRing β] [OrderTopology β] theorem SuperpolynomialDecay.trans_eventuallyLE (hk : 0 ≤ᶠ[l] k) (hg : SuperpolynomialDecay l k g) (hg' : SuperpolynomialDecay l k g') (hfg : g ≤ᶠ[l] f) (hfg' : f ≤ᶠ[l] g') : SuperpolynomialDecay l k f := fun z => tendsto_of_tendsto_of_tendsto_of_le_of_le' (hg z) (hg' z) (by filter_upwards [hfg, hk] with x hx (hx' : 0 ≤ k x) using by gcongr) (by filter_upwards [hfg', hk] with x hx (hx' : 0 ≤ k x) using by gcongr) end OrderedCommSemiring section LinearOrderedCommRing variable [TopologicalSpace β] [CommRing β] [LinearOrder β] [IsStrictOrderedRing β] [OrderTopology β] variable (l k f) theorem superpolynomialDecay_iff_abs_tendsto_zero : SuperpolynomialDecay l k f ↔ ∀ n : ℕ, Tendsto (fun a : α => |k a ^ n * f a|) l (𝓝 0) := ⟨fun h z => (tendsto_zero_iff_abs_tendsto_zero _).1 (h z), fun h z => (tendsto_zero_iff_abs_tendsto_zero _).2 (h z)⟩ theorem superpolynomialDecay_iff_superpolynomialDecay_abs : SuperpolynomialDecay l k f ↔ SuperpolynomialDecay l (fun a => |k a|) fun a => |f a| := (superpolynomialDecay_iff_abs_tendsto_zero l k f).trans (by simp_rw [SuperpolynomialDecay, abs_mul, abs_pow]) variable {l k f} theorem SuperpolynomialDecay.trans_eventually_abs_le (hf : SuperpolynomialDecay l k f) (hfg : abs ∘ g ≤ᶠ[l] abs ∘ f) : SuperpolynomialDecay l k g := by rw [superpolynomialDecay_iff_abs_tendsto_zero] at hf ⊢ refine fun z => tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_const_nhds (hf z) (Eventually.of_forall fun x => abs_nonneg _) (hfg.mono fun x hx => ?_) calc |k x ^ z * g x| = |k x ^ z| * |g x| := abs_mul (k x ^ z) (g x) _ ≤ |k x ^ z| * |f x| := by gcongr _ * ?_; exact hx _ = |k x ^ z * f x| := (abs_mul (k x ^ z) (f x)).symm theorem SuperpolynomialDecay.trans_abs_le (hf : SuperpolynomialDecay l k f) (hfg : ∀ x, |g x| ≤ |f x|) : SuperpolynomialDecay l k g := hf.trans_eventually_abs_le (Eventually.of_forall hfg) end LinearOrderedCommRing section Field variable [TopologicalSpace β] [Field β] (l k f) theorem superpolynomialDecay_mul_const_iff [ContinuousMul β] {c : β} (hc0 : c ≠ 0) : (SuperpolynomialDecay l k fun n => f n * c) ↔ SuperpolynomialDecay l k f := ⟨fun h => (h.mul_const c⁻¹).congr fun x => by simp [mul_assoc, mul_inv_cancel₀ hc0], fun h => h.mul_const c⟩ theorem superpolynomialDecay_const_mul_iff [ContinuousMul β] {c : β} (hc0 : c ≠ 0) : (SuperpolynomialDecay l k fun n => c * f n) ↔ SuperpolynomialDecay l k f := ⟨fun h => (h.const_mul c⁻¹).congr fun x => by simp [← mul_assoc, inv_mul_cancel₀ hc0], fun h => h.const_mul c⟩ variable {l k f} end Field section LinearOrderedField variable [TopologicalSpace β] [Field β] [LinearOrder β] [IsStrictOrderedRing β] [OrderTopology β] variable (f) theorem superpolynomialDecay_iff_abs_isBoundedUnder (hk : Tendsto k l atTop) : SuperpolynomialDecay l k f ↔ ∀ z : ℕ, IsBoundedUnder (· ≤ ·) l fun a : α => |k a ^ z * f a| := by refine ⟨fun h z => Tendsto.isBoundedUnder_le (Tendsto.abs (h z)), fun h => (superpolynomialDecay_iff_abs_tendsto_zero l k f).2 fun z => ?_⟩ obtain ⟨m, hm⟩ := h (z + 1) have h1 : Tendsto (fun _ : α => (0 : β)) l (𝓝 0) := tendsto_const_nhds have h2 : Tendsto (fun a : α => |(k a)⁻¹| * m) l (𝓝 0) := zero_mul m ▸ Tendsto.mul_const m ((tendsto_zero_iff_abs_tendsto_zero _).1 hk.inv_tendsto_atTop) refine tendsto_of_tendsto_of_tendsto_of_le_of_le' h1 h2 (Eventually.of_forall fun x => abs_nonneg _) ((eventually_map.1 hm).mp ?_) refine (hk.eventually_ne_atTop 0).mono fun x hk0 hx => ?_ refine Eq.trans_le ?_ (mul_le_mul_of_nonneg_left hx <| abs_nonneg (k x)⁻¹) rw [← abs_mul, ← mul_assoc, pow_succ', ← mul_assoc, inv_mul_cancel₀ hk0, one_mul] theorem superpolynomialDecay_iff_zpow_tendsto_zero (hk : Tendsto k l atTop) : SuperpolynomialDecay l k f ↔ ∀ z : ℤ, Tendsto (fun a : α => k a ^ z * f a) l (𝓝 0) := by refine ⟨fun h z => ?_, fun h n => by simpa only [zpow_natCast] using h (n : ℤ)⟩ by_cases! hz : 0 ≤ z · unfold Tendsto lift z to ℕ using hz simpa using h z · have : Tendsto (fun a => k a ^ z) l (𝓝 0) := Tendsto.comp (tendsto_zpow_atTop_zero hz) hk have h : Tendsto f l (𝓝 0) := by simpa using h 0 exact zero_mul (0 : β) ▸ this.mul h variable {f} theorem SuperpolynomialDecay.param_zpow_mul (hk : Tendsto k l atTop) (hf : SuperpolynomialDecay l k f) (z : ℤ) : SuperpolynomialDecay l k fun a => k a ^ z * f a := by rw [superpolynomialDecay_iff_zpow_tendsto_zero _ hk] at hf ⊢ refine fun z' => (hf <| z' + z).congr' ((hk.eventually_ne_atTop 0).mono fun x hx => ?_) simp [zpow_add₀ hx, mul_assoc] theorem SuperpolynomialDecay.mul_param_zpow (hk : Tendsto k l atTop) (hf : SuperpolynomialDecay l k f) (z : ℤ) : SuperpolynomialDecay l k fun a => f a * k a ^ z := (hf.param_zpow_mul hk z).congr fun _ => mul_comm _ _ theorem SuperpolynomialDecay.inv_param_mul (hk : Tendsto k l atTop) (hf : SuperpolynomialDecay l k f) : SuperpolynomialDecay l k (k⁻¹ * f) := by simpa using hf.param_zpow_mul hk (-1) theorem SuperpolynomialDecay.param_inv_mul (hk : Tendsto k l atTop) (hf : SuperpolynomialDecay l k f) : SuperpolynomialDecay l k (f * k⁻¹) := (hf.inv_param_mul hk).congr fun _ => mul_comm _ _ variable (f) theorem superpolynomialDecay_param_mul_iff (hk : Tendsto k l atTop) : SuperpolynomialDecay l k (k * f) ↔ SuperpolynomialDecay l k f := ⟨fun h => (h.inv_param_mul hk).congr' ((hk.eventually_ne_atTop 0).mono fun x hx => by simp [← mul_assoc, inv_mul_cancel₀ hx]), fun h => h.param_mul⟩ theorem superpolynomialDecay_mul_param_iff (hk : Tendsto k l atTop) : SuperpolynomialDecay l k (f * k) ↔ SuperpolynomialDecay l k f := by simpa [mul_comm k] using superpolynomialDecay_param_mul_iff f hk theorem superpolynomialDecay_param_pow_mul_iff (hk : Tendsto k l atTop) (n : ℕ) : SuperpolynomialDecay l k (k ^ n * f) ↔ SuperpolynomialDecay l k f := by induction n with | zero => simp | succ n hn => simpa [pow_succ, ← mul_comm k, mul_assoc, superpolynomialDecay_param_mul_iff (k ^ n * f) hk] using hn theorem superpolynomialDecay_mul_param_pow_iff (hk : Tendsto k l atTop) (n : ℕ) : SuperpolynomialDecay l k (f * k ^ n) ↔ SuperpolynomialDecay l k f := by simpa [mul_comm f] using superpolynomialDecay_param_pow_mul_iff f hk n variable {f} end LinearOrderedField section NormedLinearOrderedField variable [NormedField β] variable (l k f) theorem superpolynomialDecay_iff_norm_tendsto_zero : SuperpolynomialDecay l k f ↔ ∀ n : ℕ, Tendsto (fun a : α => ‖k a ^ n * f a‖) l (𝓝 0) := ⟨fun h z => tendsto_zero_iff_norm_tendsto_zero.1 (h z), fun h z => tendsto_zero_iff_norm_tendsto_zero.2 (h z)⟩ theorem superpolynomialDecay_iff_superpolynomialDecay_norm : SuperpolynomialDecay l k f ↔ SuperpolynomialDecay l (fun a => ‖k a‖) fun a => ‖f a‖ := (superpolynomialDecay_iff_norm_tendsto_zero l k f).trans (by simp [SuperpolynomialDecay]) variable {l k} variable [LinearOrder β] [IsStrictOrderedRing β] [OrderTopology β] theorem superpolynomialDecay_iff_isBigO (hk : Tendsto k l atTop) : SuperpolynomialDecay l k f ↔ ∀ z : ℤ, f =O[l] fun a : α => k a ^ z := by refine (superpolynomialDecay_iff_zpow_tendsto_zero f hk).trans ?_ have hk0 : ∀ᶠ x in l, k x ≠ 0 := hk.eventually_ne_atTop 0 refine ⟨fun h z => ?_, fun h z => ?_⟩ · refine isBigO_of_div_tendsto_nhds (hk0.mono fun x hx hxz ↦ absurd hxz (zpow_ne_zero _ hx)) 0 ?_ have : (fun a : α => k a ^ z)⁻¹ = fun a : α => k a ^ (-z) := funext fun x => by simp rw [div_eq_mul_inv, mul_comm f, this] exact h (-z) · suffices (fun a : α => k a ^ z * f a) =O[l] fun a : α => (k a)⁻¹ from IsBigO.trans_tendsto this hk.inv_tendsto_atTop refine ((isBigO_refl (fun a => k a ^ z) l).mul (h (-(z + 1)))).trans ?_ refine .of_bound' <| hk0.mono fun a ha0 => ?_ simp [← zpow_add₀ ha0] theorem superpolynomialDecay_iff_isLittleO (hk : Tendsto k l atTop) : SuperpolynomialDecay l k f ↔ ∀ z : ℤ, f =o[l] fun a : α => k a ^ z := by refine ⟨fun h z => ?_, fun h => (superpolynomialDecay_iff_isBigO f hk).2 fun z => (h z).isBigO⟩ have hk0 : ∀ᶠ x in l, k x ≠ 0 := hk.eventually_ne_atTop 0 have : (fun _ : α => (1 : β)) =o[l] k := isLittleO_of_tendsto' (hk0.mono fun x hkx hkx' => absurd hkx' hkx) (by simpa using hk.inv_tendsto_atTop) have : f =o[l] fun x : α => k x * k x ^ (z - 1) := by simpa using this.mul_isBigO ((superpolynomialDecay_iff_isBigO f hk).1 h <| z - 1) refine this.trans_isBigO <| IsBigO.of_bound' <| hk0.mono fun x hkx => le_of_eq ?_ simp [← zpow_one_add₀ hkx] end NormedLinearOrderedField end Asymptotics
.lake/packages/mathlib/Mathlib/Analysis/Asymptotics/ExpGrowth.lean
import Mathlib.Analysis.Asymptotics.LinearGrowth import Mathlib.Analysis.SpecialFunctions.Log.ENNRealLogExp /-! # Exponential growth This file defines the exponential growth of a sequence `u : ℕ → ℝ≥0∞`. This notion comes in two versions, using a `liminf` and a `limsup` respectively. ## Main definitions - `expGrowthInf`, `expGrowthSup`: respectively, `liminf` and `limsup` of `log (u n) / n`. - `expGrowthInfTopHom`, `expGrowthSupBotHom`: the functions `expGrowthInf`, `expGrowthSup` as homomorphisms preserving finitary `Inf`/`Sup` respectively. ## Tags asymptotics, exponential -/ namespace ExpGrowth open ENNReal EReal Filter Function LinearGrowth open scoped Topology /-! ### Definition -/ /-- Lower exponential growth of a sequence of extended nonnegative real numbers. -/ noncomputable def expGrowthInf (u : ℕ → ℝ≥0∞) : EReal := liminf (fun n ↦ log (u n) / n) atTop /-- Upper exponential growth of a sequence of extended nonnegative real numbers. -/ noncomputable def expGrowthSup (u : ℕ → ℝ≥0∞) : EReal := limsup (fun n ↦ log (u n) / n) atTop lemma expGrowthInf_def {u : ℕ → ℝ≥0∞} : expGrowthInf u = linearGrowthInf (log ∘ u) := by rfl lemma expGrowthSup_def {u : ℕ → ℝ≥0∞} : expGrowthSup u = linearGrowthSup (log ∘ u) := by rfl /-! ### Basic properties -/ section basic_properties variable {u v : ℕ → ℝ≥0∞} {a : EReal} {b : ℝ≥0∞} lemma expGrowthInf_congr (h : u =ᶠ[atTop] v) : expGrowthInf u = expGrowthInf v := liminf_congr (h.mono fun _ uv ↦ uv ▸ rfl) lemma expGrowthSup_congr (h : u =ᶠ[atTop] v) : expGrowthSup u = expGrowthSup v := limsup_congr (h.mono fun _ uv ↦ uv ▸ rfl) lemma expGrowthInf_eventually_monotone (h : u ≤ᶠ[atTop] v) : expGrowthInf u ≤ expGrowthInf v := liminf_le_liminf (h.mono fun n uv ↦ monotone_div_right_of_nonneg n.cast_nonneg' (log_monotone uv)) lemma expGrowthInf_monotone : Monotone expGrowthInf := fun _ _ uv ↦ expGrowthInf_eventually_monotone (Eventually.of_forall uv) lemma expGrowthSup_eventually_monotone (h : u ≤ᶠ[atTop] v) : expGrowthSup u ≤ expGrowthSup v := limsup_le_limsup (h.mono fun n uv ↦ monotone_div_right_of_nonneg n.cast_nonneg' (log_monotone uv)) lemma expGrowthSup_monotone : Monotone expGrowthSup := fun _ _ uv ↦ expGrowthSup_eventually_monotone (Eventually.of_forall uv) lemma expGrowthInf_le_expGrowthSup : expGrowthInf u ≤ expGrowthSup u := liminf_le_limsup lemma expGrowthInf_le_expGrowthSup_of_frequently_le (h : ∃ᶠ n in atTop, u n ≤ v n) : expGrowthInf u ≤ expGrowthSup v := liminf_le_limsup_of_frequently_le <| h.mono fun n u_v ↦ by gcongr lemma expGrowthInf_le_iff : expGrowthInf u ≤ a ↔ ∀ b > a, ∃ᶠ n : ℕ in atTop, u n ≤ exp (b * n) := by rw [expGrowthInf, liminf_le_iff'] refine forall₂_congr fun b _ ↦ frequently_congr (eventually_atTop.2 ⟨1, fun n _ ↦ ?_⟩) rw [div_le_iff_le_mul (by norm_cast) (natCast_ne_top n), ← log_exp (n * b), mul_comm _ b] exact logOrderIso.le_iff_le lemma le_expGrowthInf_iff : a ≤ expGrowthInf u ↔ ∀ b < a, ∀ᶠ n : ℕ in atTop, exp (b * n) ≤ u n := by rw [expGrowthInf, le_liminf_iff'] refine forall₂_congr fun b _ ↦ eventually_congr (eventually_atTop.2 ⟨1, fun n _ ↦ ?_⟩) nth_rw 1 [le_div_iff_mul_le (by norm_cast) (natCast_ne_top n), ← log_exp (b * n)] exact logOrderIso.le_iff_le lemma expGrowthSup_le_iff : expGrowthSup u ≤ a ↔ ∀ b > a, ∀ᶠ n : ℕ in atTop, u n ≤ exp (b * n) := by rw [expGrowthSup, limsup_le_iff'] refine forall₂_congr fun b _ ↦ eventually_congr (eventually_atTop.2 ⟨1, fun n _ ↦ ?_⟩) rw [div_le_iff_le_mul (by norm_cast) (natCast_ne_top n), ← log_exp (n * b), mul_comm _ b] exact logOrderIso.le_iff_le lemma le_expGrowthSup_iff : a ≤ expGrowthSup u ↔ ∀ b < a, ∃ᶠ n : ℕ in atTop, exp (b * n) ≤ u n := by rw [expGrowthSup, le_limsup_iff'] refine forall₂_congr fun b _ ↦ frequently_congr (eventually_atTop.2 ⟨1, fun n _ ↦ ?_⟩) nth_rw 1 [le_div_iff_mul_le (by norm_cast) (natCast_ne_top n), ← log_exp (b * n)] exact logOrderIso.le_iff_le /- Forward direction of `expGrowthInf_le_iff`. -/ lemma frequently_le_exp (h : expGrowthInf u < a) : ∃ᶠ n : ℕ in atTop, u n ≤ exp (a * n) := expGrowthInf_le_iff.1 (le_refl (expGrowthInf u)) a h /- Forward direction of `le_expGrowthInf_iff`. -/ lemma eventually_exp_le (h : a < expGrowthInf u) : ∀ᶠ n : ℕ in atTop, exp (a * n) ≤ u n := le_expGrowthInf_iff.1 (le_refl (expGrowthInf u)) a h /- Forward direction of `expGrowthSup_le_iff`. -/ lemma eventually_le_exp (h : expGrowthSup u < a) : ∀ᶠ n : ℕ in atTop, u n ≤ exp (a * n) := expGrowthSup_le_iff.1 (le_refl (expGrowthSup u)) a h /- Forward direction of `le_expGrowthSup_iff`. -/ lemma frequently_exp_le (h : a < expGrowthSup u) : ∃ᶠ n : ℕ in atTop, exp (a * n) ≤ u n := le_expGrowthSup_iff.1 (le_refl (expGrowthSup u)) a h lemma _root_.Frequently.expGrowthInf_le (h : ∃ᶠ n : ℕ in atTop, u n ≤ exp (a * n)) : expGrowthInf u ≤ a := by apply expGrowthInf_le_iff.2 fun c c_u ↦ h.mono fun n hn ↦ hn.trans ?_ gcongr lemma _root_.Eventually.le_expGrowthInf (h : ∀ᶠ n : ℕ in atTop, exp (a * n) ≤ u n) : a ≤ expGrowthInf u := le_expGrowthInf_iff.2 fun c c_u ↦ h.mono fun n hn ↦ hn.trans' <| by gcongr lemma _root_.Eventually.expGrowthSup_le (h : ∀ᶠ n : ℕ in atTop, u n ≤ exp (a * n)) : expGrowthSup u ≤ a := expGrowthSup_le_iff.2 fun c c_u ↦ h.mono fun n hn ↦ hn.trans <| by gcongr lemma _root_.Frequently.le_expGrowthSup (h : ∃ᶠ n : ℕ in atTop, exp (a * n) ≤ u n) : a ≤ expGrowthSup u := le_expGrowthSup_iff.2 fun c c_u ↦ h.mono fun n hn ↦ hn.trans' <| by gcongr /-! ### Special cases -/ lemma expGrowthSup_zero : expGrowthSup 0 = ⊥ := by rw [← linearGrowthSup_bot, expGrowthSup_def] congr 1 ext _ rw [comp_apply, Pi.zero_apply, Pi.bot_apply, log_zero] lemma expGrowthInf_zero : expGrowthInf 0 = ⊥ := by apply le_bot_iff.1 rw [← expGrowthSup_zero] exact expGrowthInf_le_expGrowthSup lemma expGrowthInf_top : expGrowthInf ⊤ = ⊤ := by rw [← linearGrowthInf_top, expGrowthInf_def] rfl lemma expGrowthSup_top : expGrowthSup ⊤ = ⊤ := by apply top_le_iff.1 rw [← expGrowthInf_top] exact expGrowthInf_le_expGrowthSup lemma expGrowthInf_const (h : b ≠ 0) (h' : b ≠ ∞) : expGrowthInf (fun _ ↦ b) = 0 := (tendsto_const_div_atTop_nhds_zero_nat (fun k ↦ h (log_eq_bot_iff.1 k)) (fun k ↦ h' (log_eq_top_iff.1 k))).liminf_eq lemma expGrowthSup_const (h : b ≠ 0) (h' : b ≠ ∞) : expGrowthSup (fun _ ↦ b) = 0 := (tendsto_const_div_atTop_nhds_zero_nat (fun k ↦ h (log_eq_bot_iff.1 k)) (fun k ↦ h' (log_eq_top_iff.1 k))).limsup_eq lemma expGrowthInf_pow : expGrowthInf (fun n ↦ b ^ n) = log b := by rw [expGrowthInf, ← liminf_const (f := atTop (α := ℕ)) (log b)] refine liminf_congr (eventually_atTop.2 ⟨1, fun n n_1 ↦ ?_⟩) rw [EReal.div_eq_iff (natCast_ne_bot n) (natCast_ne_top n) (zero_lt_one.trans_le (Nat.one_le_cast.2 n_1)).ne.symm, log_pow, mul_comm] lemma expGrowthSup_pow : expGrowthSup (fun n ↦ b ^ n) = log b := by rw [expGrowthSup, ← limsup_const (f := atTop (α := ℕ)) (log b)] refine limsup_congr (eventually_atTop.2 ⟨1, fun n n_1 ↦ ?_⟩) rw [EReal.div_eq_iff (natCast_ne_bot n) (natCast_ne_top n) (zero_lt_one.trans_le (Nat.one_le_cast.2 n_1)).ne.symm, log_pow, mul_comm] lemma expGrowthInf_exp : expGrowthInf (fun n ↦ exp (a * n)) = a := le_antisymm (Frequently.expGrowthInf_le (Frequently.of_forall fun _ ↦ le_refl _)) (Eventually.le_expGrowthInf (Eventually.of_forall fun _ ↦ le_refl _)) lemma expGrowthSup_exp : expGrowthSup (fun n ↦ exp (a * n)) = a := le_antisymm (Eventually.expGrowthSup_le (Eventually.of_forall fun _ ↦ le_refl _)) (Frequently.le_expGrowthSup (Frequently.of_forall fun _ ↦ le_refl _)) /-! ### Multiplication and inversion -/ lemma le_expGrowthInf_mul : expGrowthInf u + expGrowthInf v ≤ expGrowthInf (u * v) := by refine le_liminf_add.trans_eq (liminf_congr (Eventually.of_forall fun n ↦ ?_)) rw [Pi.add_apply, Pi.mul_apply, ← add_div_of_nonneg_right n.cast_nonneg', log_mul_add] /-- See `expGrowthInf_mul_le'` for a version with swapped argument `u` and `v`. -/ lemma expGrowthInf_mul_le (h : expGrowthSup u ≠ ⊥ ∨ expGrowthInf v ≠ ⊤) (h' : expGrowthSup u ≠ ⊤ ∨ expGrowthInf v ≠ ⊥) : expGrowthInf (u * v) ≤ expGrowthSup u + expGrowthInf v := by refine (liminf_add_le h h').trans_eq' (liminf_congr (Eventually.of_forall fun n ↦ ?_)) rw [Pi.add_apply, Pi.mul_apply, ← add_div_of_nonneg_right n.cast_nonneg', log_mul_add] /-- See `expGrowthInf_mul_le` for a version with swapped argument `u` and `v`. -/ lemma expGrowthInf_mul_le' (h : expGrowthInf u ≠ ⊥ ∨ expGrowthSup v ≠ ⊤) (h' : expGrowthInf u ≠ ⊤ ∨ expGrowthSup v ≠ ⊥) : expGrowthInf (u * v) ≤ expGrowthInf u + expGrowthSup v := by rw [mul_comm, add_comm] exact expGrowthInf_mul_le h'.symm h.symm /-- See `le_expGrowthSup_mul'` for a version with swapped argument `u` and `v`. -/ lemma le_expGrowthSup_mul : expGrowthSup u + expGrowthInf v ≤ expGrowthSup (u * v) := by refine le_limsup_add.trans_eq (limsup_congr (Eventually.of_forall fun n ↦ ?_)) rw [Pi.add_apply, Pi.mul_apply, log_mul_add, add_div_of_nonneg_right n.cast_nonneg'] /-- See `le_expGrowthSup_mul` for a version with swapped argument `u` and `v`. -/ lemma le_expGrowthSup_mul' : expGrowthInf u + expGrowthSup v ≤ expGrowthSup (u * v) := by rw [mul_comm, add_comm] exact le_expGrowthSup_mul lemma expGrowthSup_mul_le (h : expGrowthSup u ≠ ⊥ ∨ expGrowthSup v ≠ ⊤) (h' : expGrowthSup u ≠ ⊤ ∨ expGrowthSup v ≠ ⊥) : expGrowthSup (u * v) ≤ expGrowthSup u + expGrowthSup v := by refine (limsup_add_le h h').trans_eq' (limsup_congr (Eventually.of_forall fun n ↦ ?_)) rw [Pi.add_apply, Pi.mul_apply, log_mul_add, add_div_of_nonneg_right n.cast_nonneg'] lemma expGrowthInf_inv : expGrowthInf u⁻¹ = - expGrowthSup u := by rw [expGrowthSup, ← liminf_neg] refine liminf_congr (Eventually.of_forall fun n ↦ ?_) rw [Pi.neg_apply, Pi.inv_apply, div_eq_mul_inv, div_eq_mul_inv, ← EReal.neg_mul, log_inv] lemma expGrowthSup_inv : expGrowthSup u⁻¹ = - expGrowthInf u := by rw [expGrowthInf, ← limsup_neg] refine limsup_congr (Eventually.of_forall fun n ↦ ?_) rw [Pi.neg_apply, Pi.inv_apply, div_eq_mul_inv, div_eq_mul_inv, ← EReal.neg_mul, log_inv] /-! ### Comparison -/ -- Bound on `expGrowthInf` under a `IsBigO` hypothesis. However, `ℝ≥0∞` is not normed, so the -- `IsBigO` property is spelt out. lemma expGrowthInf_le_of_eventually_le (hb : b ≠ ∞) (h : ∀ᶠ n in atTop, u n ≤ b * v n) : expGrowthInf u ≤ expGrowthInf v := by apply (expGrowthInf_eventually_monotone h).trans rcases eq_zero_or_pos b with rfl | b_pos · simp only [zero_mul, ← Pi.zero_def, expGrowthInf_zero, bot_le] · apply (expGrowthInf_mul_le _ _).trans_eq <;> rw [expGrowthSup_const b_pos.ne' hb] · exact zero_add (expGrowthInf v) · exact .inl zero_ne_bot · exact .inl zero_ne_top -- Bound on `expGrowthSup` under a `IsBigO` hypothesis. However, `ℝ≥0∞` is not normed, so the -- `IsBigO` property is spelt out. lemma expGrowthSup_le_of_eventually_le (hb : b ≠ ∞) (h : ∀ᶠ n in atTop, u n ≤ b * v n) : expGrowthSup u ≤ expGrowthSup v := by apply (expGrowthSup_eventually_monotone h).trans rcases eq_zero_or_pos b with rfl | b_pos · simp only [zero_mul, ← Pi.zero_def, expGrowthSup_zero, bot_le] · apply (expGrowthSup_mul_le _ _).trans_eq <;> rw [expGrowthSup_const b_pos.ne' hb] · exact zero_add (expGrowthSup v) · exact .inl zero_ne_bot · exact .inl zero_ne_top lemma expGrowthInf_of_eventually_ge (hb : b ≠ 0) (h : ∀ᶠ n in atTop, b * u n ≤ v n) : expGrowthInf u ≤ expGrowthInf v := by apply (expGrowthInf_eventually_monotone h).trans' (le_expGrowthInf_mul.trans' _) rcases eq_top_or_lt_top b with rfl | b_top · rw [← Pi.top_def, expGrowthInf_top] exact le_add_of_nonneg_left le_top · rw [expGrowthInf_const hb b_top.ne, zero_add] lemma expGrowthSup_of_eventually_ge (hb : b ≠ 0) (h : ∀ᶠ n in atTop, b * u n ≤ v n) : expGrowthSup u ≤ expGrowthSup v := by apply (expGrowthSup_eventually_monotone h).trans' (le_expGrowthSup_mul'.trans' _) rcases eq_top_or_lt_top b with rfl | b_top · exact expGrowthInf_top ▸ le_add_of_nonneg_left le_top · rw [expGrowthInf_const hb b_top.ne, zero_add] /-! ### Infimum and supremum -/ lemma expGrowthInf_inf : expGrowthInf (u ⊓ v) = expGrowthInf u ⊓ expGrowthInf v := by rw [expGrowthInf, expGrowthInf, expGrowthInf, ← liminf_min] refine liminf_congr (Eventually.of_forall fun n ↦ ?_) rw [Pi.inf_apply, log_monotone.map_min] exact (monotone_div_right_of_nonneg n.cast_nonneg').map_min /-- Lower exponential growth as an `InfTopHom`. -/ noncomputable def expGrowthInfTopHom : InfTopHom (ℕ → ℝ≥0∞) EReal where toFun := expGrowthInf map_inf' _ _ := expGrowthInf_inf map_top' := expGrowthInf_top lemma expGrowthInf_biInf {α : Type*} (u : α → ℕ → ℝ≥0∞) {s : Set α} (hs : s.Finite) : expGrowthInf (⨅ x ∈ s, u x) = ⨅ x ∈ s, expGrowthInf (u x) := by have := map_finset_inf expGrowthInfTopHom hs.toFinset u simpa only [expGrowthInfTopHom, InfTopHom.coe_mk, InfHom.coe_mk, Finset.inf_eq_iInf, hs.mem_toFinset, comp_apply] lemma expGrowthInf_iInf {ι : Type*} [Finite ι] (u : ι → ℕ → ℝ≥0∞) : expGrowthInf (⨅ i, u i) = ⨅ i, expGrowthInf (u i) := by rw [← iInf_univ, expGrowthInf_biInf u Set.finite_univ, iInf_univ] lemma expGrowthSup_sup : expGrowthSup (u ⊔ v) = expGrowthSup u ⊔ expGrowthSup v := by rw [expGrowthSup, expGrowthSup, expGrowthSup, ← limsup_max] refine limsup_congr (Eventually.of_forall fun n ↦ ?_) rw [Pi.sup_apply, log_monotone.map_max] exact (monotone_div_right_of_nonneg n.cast_nonneg').map_max /-- Upper exponential growth as a `SupBotHom`. -/ noncomputable def expGrowthSupBotHom : SupBotHom (ℕ → ℝ≥0∞) EReal where toFun := expGrowthSup map_sup' _ _ := expGrowthSup_sup map_bot' := expGrowthSup_zero lemma expGrowthSup_biSup {α : Type*} (u : α → ℕ → ℝ≥0∞) {s : Set α} (hs : s.Finite) : expGrowthSup (⨆ x ∈ s, u x) = ⨆ x ∈ s, expGrowthSup (u x) := by have := map_finset_sup expGrowthSupBotHom hs.toFinset u simpa only [expGrowthSupBotHom, SupBotHom.coe_mk, SupHom.coe_mk, Finset.sup_eq_iSup, hs.mem_toFinset, comp_apply] lemma expGrowthSup_iSup {ι : Type*} [Finite ι] (u : ι → ℕ → ℝ≥0∞) : expGrowthSup (⨆ i, u i) = ⨆ i, expGrowthSup (u i) := by rw [← iSup_univ, expGrowthSup_biSup u Set.finite_univ, iSup_univ] /-! ### Addition -/ lemma le_expGrowthInf_add : expGrowthInf u ⊔ expGrowthInf v ≤ expGrowthInf (u + v) := sup_le (expGrowthInf_monotone le_self_add) (expGrowthInf_monotone le_add_self) lemma expGrowthSup_add : expGrowthSup (u + v) = expGrowthSup u ⊔ expGrowthSup v := by rw [← expGrowthSup_sup] apply le_antisymm · refine expGrowthSup_le_of_eventually_le (b := 2) ofNat_ne_top (Eventually.of_forall fun n ↦ ?_) rw [Pi.sup_apply u v n, Pi.add_apply u v n, two_mul] exact add_le_add (le_max_left (u n) (v n)) (le_max_right (u n) (v n)) · refine expGrowthSup_monotone fun n ↦ ?_ exact sup_le (self_le_add_right (u n) (v n)) (self_le_add_left (v n) (u n)) -- By lemma `expGrowthSup_add`, `expGrowthSup` is an `AddMonoidHom` from `ℕ → ℝ≥0∞` to -- `Tropical ERealᵒᵈ`. Lemma `expGrowthSup_sum` is exactly `Finset.trop_inf`. We prove it from -- scratch to reduce imports. lemma expGrowthSup_sum {α : Type*} (u : α → ℕ → ℝ≥0∞) (s : Finset α) : expGrowthSup (∑ x ∈ s, u x) = ⨆ x ∈ s, expGrowthSup (u x) := by classical induction s using Finset.induction_on with | empty => rw [Finset.sum_empty, ← Finset.iSup_coe, Finset.coe_empty, iSup_emptyset, expGrowthSup_zero] | insert a t a_t ha => rw [Finset.sum_insert a_t, expGrowthSup_add, ← Finset.iSup_coe, Finset.coe_insert a t, iSup_insert, Finset.iSup_coe, ha] end basic_properties /-! ### Composition -/ section composition variable {u : ℕ → ℝ≥0∞} {v : ℕ → ℕ} lemma le_expGrowthInf_comp (hu : 1 ≤ᶠ[atTop] u) (hv : Tendsto v atTop atTop) : (linearGrowthInf fun n ↦ v n : EReal) * expGrowthInf u ≤ expGrowthInf (u ∘ v) := by apply le_linearGrowthInf_comp (hu.mono fun n h ↦ ?_) hv rw [Pi.one_apply] at h rwa [Pi.zero_apply, zero_le_log_iff] lemma expGrowthSup_comp_le (hu : ∃ᶠ n in atTop, 1 ≤ u n) (hv₀ : (linearGrowthSup fun n ↦ v n : EReal) ≠ 0) (hv₁ : (linearGrowthSup fun n ↦ v n : EReal) ≠ ⊤) (hv₂ : Tendsto v atTop atTop) : expGrowthSup (u ∘ v) ≤ (linearGrowthSup fun n ↦ v n : EReal) * expGrowthSup u := by apply linearGrowthSup_comp_le (u := log ∘ u) (hu.mono fun n h ↦ ?_) hv₀ hv₁ hv₂ rwa [comp_apply, zero_le_log_iff] /-! ### Monotone sequences -/ lemma _root_.Monotone.expGrowthInf_nonneg (h : Monotone u) (h' : u ≠ 0) : 0 ≤ expGrowthInf u := by apply (log_monotone.comp h).linearGrowthInf_nonneg simp only [ne_eq, funext_iff, comp_apply, Pi.bot_apply, log_eq_bot_iff, Pi.zero_apply] at h' ⊢ exact h' lemma _root_.Monotone.expGrowthSup_nonneg (h : Monotone u) (h' : u ≠ 0) : 0 ≤ expGrowthSup u := (h.expGrowthInf_nonneg h').trans expGrowthInf_le_expGrowthSup lemma expGrowthInf_comp_nonneg (h : Monotone u) (h' : u ≠ 0) (hv : Tendsto v atTop atTop) : 0 ≤ expGrowthInf (u ∘ v) := by apply linearGrowthInf_comp_nonneg (u := log ∘ u) (log_monotone.comp h) _ hv simp only [ne_eq, funext_iff, comp_apply, Pi.bot_apply, log_eq_bot_iff, Pi.zero_apply] at h' ⊢ exact h' lemma expGrowthSup_comp_nonneg (h : Monotone u) (h' : u ≠ 0) (hv : Tendsto v atTop atTop) : 0 ≤ expGrowthSup (u ∘ v) := (expGrowthInf_comp_nonneg h h' hv).trans expGrowthInf_le_expGrowthSup lemma _root_.Monotone.expGrowthInf_comp_le (h : Monotone u) (hv₀ : (linearGrowthSup fun n ↦ v n : EReal) ≠ 0) (hv₁ : (linearGrowthSup fun n ↦ v n : EReal) ≠ ⊤) : expGrowthInf (u ∘ v) ≤ (linearGrowthSup fun n ↦ v n : EReal) * expGrowthInf u := (log_monotone.comp h).linearGrowthInf_comp_le hv₀ hv₁ lemma _root_.Monotone.le_expGrowthSup_comp (h : Monotone u) (hv : (linearGrowthInf fun n ↦ v n : EReal) ≠ 0) : (linearGrowthInf fun n ↦ v n : EReal) * expGrowthSup u ≤ expGrowthSup (u ∘ v) := (log_monotone.comp h).le_linearGrowthSup_comp hv lemma _root_.Monotone.expGrowthInf_comp {a : EReal} (h : Monotone u) (hv : Tendsto (fun n ↦ (v n : EReal) / n) atTop (𝓝 a)) (ha : a ≠ 0) (ha' : a ≠ ⊤) : expGrowthInf (u ∘ v) = a * expGrowthInf u := (log_monotone.comp h).linearGrowthInf_comp hv ha ha' lemma _root_.Monotone.expGrowthSup_comp {a : EReal} (h : Monotone u) (hv : Tendsto (fun n ↦ (v n : EReal) / n) atTop (𝓝 a)) (ha : a ≠ 0) (ha' : a ≠ ⊤) : expGrowthSup (u ∘ v) = a * expGrowthSup u := (log_monotone.comp h).linearGrowthSup_comp hv ha ha' lemma _root_.Monotone.expGrowthInf_comp_mul {m : ℕ} (h : Monotone u) (hm : m ≠ 0) : expGrowthInf (fun n ↦ u (m * n)) = m * expGrowthInf u := (log_monotone.comp h).linearGrowthInf_comp_mul hm lemma _root_.Monotone.expGrowthSup_comp_mul {m : ℕ} (h : Monotone u) (hm : m ≠ 0) : expGrowthSup (fun n ↦ u (m * n)) = m * expGrowthSup u := (log_monotone.comp h).linearGrowthSup_comp_mul hm end composition end ExpGrowth
.lake/packages/mathlib/Mathlib/Analysis/Asymptotics/TVS.lean
import Mathlib.Analysis.Convex.EGauge import Mathlib.Analysis.LocallyConvex.BalancedCoreHull import Mathlib.Analysis.Seminorm import Mathlib.Tactic.Peel import Mathlib.Topology.Instances.ENNReal.Lemmas import Mathlib.Analysis.Asymptotics.Defs import Mathlib.Topology.Algebra.Module.LinearMapPiProd /-! # Asymptotics in a Topological Vector Space This file defines `Asymptotics.IsLittleOTVS` and `Asymptotics.IsBigOTVS` as generalizations of `Asymptotics.IsLittleO` and `Asymptotics.IsBigO` from normed spaces to topological spaces. Given two functions `f` and `g` taking values in topological vector spaces over a normed field `K`, we say that $f = o(g)$ (resp., $f = O(g)$) if for any neighborhood of zero `U` in the codomain of `f` there exists a neighborhood of zero `V` in the codomain of `g` such that $\operatorname{gauge}_{K, U} (f(x)) = o(\operatorname{gauge}_{K, V} (g(x)))$ (resp, $\operatorname{gauge}_{K, U} (f(x)) = O(\operatorname{gauge}_{K, V} (g(x)))$, where $\operatorname{gauge}_{K, U}(y) = \inf \{‖c‖ \mid y ∈ c • U\}$. In a normed space, we can use balls of positive radius as both `U` and `V`, thus reducing the definition to the classical one. This frees the user from having to chose a canonical norm, at the expense of having to pick a specific base field. This is exactly the tradeoff we want in `HasFDerivAtFilter`, as there the base field is already chosen, and this removes the choice of norm being part of the statement. These definitions were added to the library in order to migrate Fréchet derivatives from normed vector spaces to topological vector spaces. The definitions are motivated by https://en.wikipedia.org/wiki/Fr%C3%A9chet_derivative#Generalization_to_topological_vector_spaces but the definition there doesn't work for topological vector spaces over general normed fields. [This Zulip discussion](https://leanprover.zulipchat.com/#narrow/channel/116395-maths/topic/generalizing.20deriv.20to.20TVS) led to the current choice of the definition of `Asymptotics.IsLittleOTVS`, and `Asymptotics.IsBigOTVS` was defined in a similar manner. ## Main results * `isLittleOTVS_iff_isLittleO`: the equivalence between these two definitions in the case of a normed space. * `isLittleOTVS_iff_tendsto_inv_smul`: the equivalence to convergence of the ratio to zero in case of a topological vector space. ## TODO - Add `Asymptotics.IsThetaTVS` and `Asymptotics.IsEquivalentTVS`. - Prove equivalence of `IsBigOTVS` and `IsBigO`. - Prove a version of `Asymptotics.isBigO_One` for `IsBigOTVS`. -/ open Set Filter Asymptotics Metric open scoped Topology Pointwise ENNReal NNReal namespace Asymptotics section Defs variable (𝕜 : Type*) {α E F : Type*} [ENorm 𝕜] [TopologicalSpace E] [TopologicalSpace F] [Zero E] [Zero F] [SMul 𝕜 E] [SMul 𝕜 F] /-- `f =o[𝕜; l] g` (`IsLittleOTVS 𝕜 l f g`) is a generalization of `f =o[l] g` (`IsLittleO l f g`) that works in topological `𝕜`-vector spaces. Given two functions `f` and `g` taking values in topological vector spaces over a normed field `K`, we say that $f = o(g)$ if for any neighborhood of zero `U` in the codomain of `f` there exists a neighborhood of zero `V` in the codomain of `g` such that $\operatorname{gauge}_{K, U} (f(x)) = o(\operatorname{gauge}_{K, V} (g(x)))$, where $\operatorname{gauge}_{K, U}(y) = \inf \{‖c‖ \mid y ∈ c • U\}$. We use an `ENNReal`-valued function `egauge` for the gauge, so we unfold the definition of little o instead of reusing it. -/ @[mk_iff] structure IsLittleOTVS (l : Filter α) (f : α → E) (g : α → F) : Prop where exists_eventuallyLE_mul : ∀ U ∈ 𝓝 (0 : E), ∃ V ∈ 𝓝 (0 : F), ∀ ε ≠ (0 : ℝ≥0), (fun x ↦ egauge 𝕜 U (f x)) ≤ᶠ[l] (fun x ↦ ε * egauge 𝕜 V (g x)) @[inherit_doc] notation:100 f " =o[" 𝕜 "; " l "] " g:100 => IsLittleOTVS 𝕜 l f g /-- `f =O[𝕜; l] g` (`IsBigOTVS 𝕜 l f g`) is a generalization of `f =O[l] g` (`IsBigO l f g`) that works in topological `𝕜`-vector spaces. Given two functions `f` and `g` taking values in topological vector spaces over a normed field `𝕜`, we say that $f = O(g)$ if for any neighborhood of zero `U` in the codomain of `f` there exists a neighborhood of zero `V` in the codomain of `g` such that $\operatorname{gauge}_{K, U} (f(x)) \le \operatorname{gauge}_{K, V} (g(x))$, where $\operatorname{gauge}_{K, U}(y) = \inf \{‖c‖ \mid y ∈ c • U\}$. -/ @[mk_iff] structure IsBigOTVS (l : Filter α) (f : α → E) (g : α → F) : Prop where exists_eventuallyLE : ∀ U ∈ 𝓝 (0 : E), ∃ V ∈ 𝓝 (0 : F), (egauge 𝕜 U <| f ·) ≤ᶠ[l] (egauge 𝕜 V <| g ·) @[inherit_doc] notation:100 f " =O[" 𝕜 "; " l "] " g:100 => IsBigOTVS 𝕜 l f g end Defs variable {α β 𝕜 E F G : Type*} section TopologicalSpace variable [NontriviallyNormedField 𝕜] [AddCommGroup E] [TopologicalSpace E] [Module 𝕜 E] [AddCommGroup F] [TopologicalSpace F] [Module 𝕜 F] [AddCommGroup G] [TopologicalSpace G] [Module 𝕜 G] section congr variable {f f₁ f₂ : α → E} {g g₁ g₂ : α → F} {l : Filter α} theorem isLittleOTVS_iff_tendsto_div : f =o[𝕜; l] g ↔ ∀ U ∈ 𝓝 0, ∃ V ∈ 𝓝 0, Tendsto (fun x ↦ egauge 𝕜 U (f x) / egauge 𝕜 V (g x)) l (𝓝 0) := by simp only [isLittleOTVS_iff, ← ENNReal.coe_zero, ENNReal.nhds_coe, ← NNReal.bot_eq_zero, (nhds_bot_basis_Iic.map _).tendsto_right_iff] simp +contextual [ENNReal.div_le_iff_le_mul, pos_iff_ne_zero, EventuallyLE] alias ⟨IsLittleOTVS.tendsto_div, IsLittleOTVS.of_tendsto_div⟩ := isLittleOTVS_iff_tendsto_div /-- A version of `IsLittleOTVS.exists_eventuallyLE_mul` where `ε` is quantified over `ℝ≥0∞` instead of `ℝ≥0`. -/ theorem IsLittleOTVS.exists_eventuallyLE_mul_ennreal (h : f =o[𝕜; l] g) {U : Set E} (hU : U ∈ 𝓝 0) : ∃ V ∈ 𝓝 (0 : F), ∀ ε ≠ 0, (fun x ↦ egauge 𝕜 U (f x)) ≤ᶠ[l] (fun x ↦ ε * egauge 𝕜 V (g x)) := by obtain ⟨V, hV₀, hV⟩ := h.exists_eventuallyLE_mul U hU refine ⟨V, hV₀, fun ε hε ↦ ?_⟩ cases ε with | top => exact (hV 1 one_ne_zero).trans <| .of_forall fun _ ↦ by dsimp; grw [← le_top] | coe ε => exact hV ε (mod_cast hε) theorem isLittleOTVS_congr (hf : f₁ =ᶠ[l] f₂) (hg : g₁ =ᶠ[l] g₂) : f₁ =o[𝕜; l] g₁ ↔ f₂ =o[𝕜; l] g₂ := by simp only [isLittleOTVS_iff_tendsto_div] peel with U hU V hV exact tendsto_congr' (hf.comp₂ (egauge _ _ · / egauge _ _ ·) hg) /-- A stronger version of `IsLittleOTVS.congr` that requires the functions only agree along the filter. -/ theorem IsLittleOTVS.congr' (h : f₁ =o[𝕜; l] g₁) (hf : f₁ =ᶠ[l] f₂) (hg : g₁ =ᶠ[l] g₂) : f₂ =o[𝕜; l] g₂ := (isLittleOTVS_congr hf hg).mp h theorem IsLittleOTVS.congr (h : f₁ =o[𝕜; l] g₁) (hf : ∀ x, f₁ x = f₂ x) (hg : ∀ x, g₁ x = g₂ x) : f₂ =o[𝕜; l] g₂ := h.congr' (univ_mem' hf) (univ_mem' hg) theorem IsLittleOTVS.congr_left (h : f₁ =o[𝕜; l] g) (hf : ∀ x, f₁ x = f₂ x) : f₂ =o[𝕜; l] g := h.congr hf fun _ ↦ rfl theorem IsLittleOTVS.congr_right (h : f =o[𝕜; l] g₁) (hg : ∀ x, g₁ x = g₂ x) : f =o[𝕜; l] g₂ := h.congr (fun _ ↦ rfl) hg end congr variable {l l₁ l₂ : Filter α} {f : α → E} {g : α → F} theorem IsLittleOTVS.isBigOTVS (h : f =o[𝕜; l] g) : f =O[𝕜; l] g := by refine ⟨fun U hU ↦ ?_⟩ rcases h.1 U hU with ⟨V, hV₀, hV⟩ use V, hV₀ simpa using hV 1 one_ne_zero @[trans] theorem IsBigOTVS.trans {k : α → G} (hfg : f =O[𝕜; l] g) (hgk : g =O[𝕜; l] k) : f =O[𝕜; l] k := by refine ⟨fun U hU₀ ↦ ?_⟩ obtain ⟨V, hV₀, hV⟩ := hfg.1 U hU₀ obtain ⟨W, hW₀, hW⟩ := hgk.1 V hV₀ refine ⟨W, hW₀, ?_⟩ filter_upwards [hV, hW] with x hx₁ hx₂ using hx₁.trans hx₂ instance instTransIsBigOTVSIsBigOTVS : @Trans (α → E) (α → F) (α → G) (IsBigOTVS 𝕜 l) (IsBigOTVS 𝕜 l) (IsBigOTVS 𝕜 l) where trans := IsBigOTVS.trans theorem IsLittleOTVS.trans_isBigOTVS {k : α → G} (hfg : f =o[𝕜; l] g) (hgk : g =O[𝕜; l] k) : f =o[𝕜; l] k := by refine ⟨fun U hU₀ ↦ ?_⟩ obtain ⟨V, hV₀, hV⟩ := hfg.1 U hU₀ obtain ⟨W, hW₀, hW⟩ := hgk.1 V hV₀ refine ⟨W, hW₀, fun ε hε ↦ ?_⟩ filter_upwards [hV ε hε, hW] with x hx₁ hx₂ using hx₁.trans <| by gcongr instance instTransIsLittleOTVSIsBigOTVS : @Trans (α → E) (α → F) (α → G) (IsLittleOTVS 𝕜 l) (IsBigOTVS 𝕜 l) (IsLittleOTVS 𝕜 l) where trans := IsLittleOTVS.trans_isBigOTVS theorem IsBigOTVS.trans_isLittleOTVS {k : α → G} (hfg : f =O[𝕜; l] g) (hgk : g =o[𝕜; l] k) : f =o[𝕜; l] k := by refine ⟨fun U hU₀ ↦ ?_⟩ obtain ⟨V, hV₀, hV⟩ := hfg.1 U hU₀ obtain ⟨W, hW₀, hW⟩ := hgk.1 V hV₀ refine ⟨W, hW₀, fun ε hε ↦ ?_⟩ filter_upwards [hV, hW ε hε] with x hx₁ hx₂ using hx₁.trans hx₂ instance instTransIsBigOTVSIsLittleOTVS : @Trans (α → E) (α → F) (α → G) (IsBigOTVS 𝕜 l) (IsLittleOTVS 𝕜 l) (IsLittleOTVS 𝕜 l) where trans := IsBigOTVS.trans_isLittleOTVS @[trans] theorem IsLittleOTVS.trans {k : α → G} (hfg : f =o[𝕜; l] g) (hgk : g =o[𝕜; l] k) : f =o[𝕜; l] k := hfg.trans_isBigOTVS hgk.isBigOTVS instance instTransIsLittleOTVSIsLittleOTVS : @Trans (α → E) (α → F) (α → G) (IsLittleOTVS 𝕜 l) (IsLittleOTVS 𝕜 l) (IsLittleOTVS 𝕜 l) where trans := IsLittleOTVS.trans protected theorem _root_.Filter.HasBasis.isLittleOTVS_iff {ιE ιF : Sort*} {pE : ιE → Prop} {pF : ιF → Prop} {sE : ιE → Set E} {sF : ιF → Set F} (hE : HasBasis (𝓝 (0 : E)) pE sE) (hF : HasBasis (𝓝 (0 : F)) pF sF) : f =o[𝕜; l] g ↔ ∀ i, pE i → ∃ j, pF j ∧ ∀ ε ≠ (0 : ℝ≥0), ∀ᶠ x in l, egauge 𝕜 (sE i) (f x) ≤ ε * egauge 𝕜 (sF j) (g x) := by rw [isLittleOTVS_iff] refine (hE.forall_iff ?_).trans <| forall₂_congr fun _ _ ↦ hF.exists_iff ?_ · rintro s t hsub ⟨V, hV₀, hV⟩ exact ⟨V, hV₀, fun ε hε ↦ (hV ε hε).mono fun x ↦ le_trans <| egauge_anti _ hsub _⟩ · refine fun s t hsub h ε hε ↦ (h ε hε).mono fun x hx ↦ hx.trans ?_ simp only gcongr protected theorem _root_.Filter.HasBasis.isBigOTVS_iff {ιE ιF : Sort*} {pE : ιE → Prop} {pF : ιF → Prop} {sE : ιE → Set E} {sF : ιF → Set F} (hE : HasBasis (𝓝 (0 : E)) pE sE) (hF : HasBasis (𝓝 (0 : F)) pF sF) : f =O[𝕜; l] g ↔ ∀ i, pE i → ∃ j, pF j ∧ ∀ᶠ x in l, egauge 𝕜 (sE i) (f x) ≤ egauge 𝕜 (sF j) (g x) := by rw [isBigOTVS_iff] refine (hE.forall_iff ?_).trans <| forall₂_congr fun _ _ ↦ hF.exists_iff ?_ · rintro s t hsub ⟨V, hV₀, hV⟩ exact ⟨V, hV₀, hV.mono fun x ↦ le_trans <| egauge_anti _ hsub _⟩ · exact fun s t hsub h ↦ h.mono fun x hx ↦ hx.trans <| egauge_anti 𝕜 hsub (g x) theorem isLittleOTVS_iff_smallSets : f =o[𝕜; l] g ↔ ∀ U ∈ 𝓝 0, ∀ᶠ V in (𝓝 0).smallSets, ∀ ε ≠ (0 : ℝ≥0), ∀ᶠ x in l, egauge 𝕜 U (f x) ≤ ε * egauge 𝕜 V (g x) := (isLittleOTVS_iff ..).trans <| forall₂_congr fun U hU ↦ .symm <| eventually_smallSets' fun V₁ V₂ hV hV₂ ε hε ↦ (hV₂ ε hε).mono fun x hx ↦ hx.trans <| by gcongr alias ⟨IsLittleOTVS.eventually_smallSets, _⟩ := isLittleOTVS_iff_smallSets theorem isBigOTVS_iff_smallSets : f =O[𝕜; l] g ↔ ∀ U ∈ 𝓝 0, ∀ᶠ V in (𝓝 0).smallSets, ∀ᶠ x in l, egauge 𝕜 U (f x) ≤ egauge 𝕜 V (g x) := (isBigOTVS_iff ..).trans <| forall₂_congr fun U hU ↦ .symm <| eventually_smallSets' fun V₁ V₂ hV hV₂ ↦ hV₂.mono fun x hx ↦ hx.trans <| by gcongr alias ⟨IsBigOTVS.eventually_smallSets, _⟩ := isBigOTVS_iff_smallSets @[simp] theorem isLittleOTVS_map {k : β → α} {l : Filter β} : f =o[𝕜; map k l] g ↔ (f ∘ k) =o[𝕜; l] (g ∘ k) := by simp [isLittleOTVS_iff, EventuallyLE] @[simp] theorem isBigOTVS_map {k : β → α} {l : Filter β} : f =O[𝕜; map k l] g ↔ (f ∘ k) =O[𝕜; l] (g ∘ k) := by simp [isBigOTVS_iff, EventuallyLE] lemma IsLittleOTVS.mono (hf : f =o[𝕜; l₁] g) (h : l₂ ≤ l₁) : f =o[𝕜; l₂] g := ⟨fun U hU ↦ let ⟨V, hV0, hV⟩ := hf.1 U hU; ⟨V, hV0, fun ε hε ↦ (hV ε hε).filter_mono h⟩⟩ lemma IsBigOTVS.mono (hf : f =O[𝕜; l₁] g) (h : l₂ ≤ l₁) : f =O[𝕜; l₂] g := ⟨fun U hU ↦ let ⟨V, hV0, hV⟩ := hf.1 U hU; ⟨V, hV0, hV.filter_mono h⟩⟩ lemma IsLittleOTVS.comp_tendsto {k : β → α} {lb : Filter β} (h : f =o[𝕜; l] g) (hk : Tendsto k lb l) : (f ∘ k) =o[𝕜; lb] (g ∘ k) := isLittleOTVS_map.mp (h.mono hk) lemma IsBigOTVS.comp_tendsto {k : β → α} {lb : Filter β} (h : f =O[𝕜; l] g) (hk : Tendsto k lb l) : (f ∘ k) =O[𝕜; lb] (g ∘ k) := isBigOTVS_map.mp (h.mono hk) lemma isLittleOTVS_sup : f =o[𝕜; l₁ ⊔ l₂] g ↔ f =o[𝕜; l₁] g ∧ f =o[𝕜; l₂] g := by simp only [isLittleOTVS_iff_smallSets, ← forall_and, ← eventually_and, eventually_sup] lemma IsLittleOTVS.sup (hf₁ : f =o[𝕜; l₁] g) (hf₂ : f =o[𝕜; l₂] g) : f =o[𝕜; l₁ ⊔ l₂] g := isLittleOTVS_sup.mpr ⟨hf₁, hf₂⟩ lemma _root_.ContinuousLinearMap.isBigOTVS_id {l : Filter E} (f : E →L[𝕜] F) : f =O[𝕜; l] id := ⟨fun U hU ↦ ⟨f ⁻¹' U, (map_continuous f).tendsto' 0 0 (map_zero f) hU, .of_forall <| (mapsTo_preimage f U).egauge_le 𝕜 f⟩⟩ lemma _root_.ContinuousLinearMap.isBigOTVS_comp (g : E →L[𝕜] F) : (g ∘ f) =O[𝕜; l] f := g.isBigOTVS_id.comp_tendsto tendsto_top lemma _root_.ContinuousLinearMap.isBigOTVS_fun_comp (g : E →L[𝕜] F) : (g <| f ·) =O[𝕜; l] f := g.isBigOTVS_comp @[simp] lemma IsLittleOTVS.zero (g : α → F) (l : Filter α) : (0 : α → E) =o[𝕜; l] g := by refine ⟨fun U hU ↦ ?_⟩ use univ simp [egauge_zero_right _ (Filter.nonempty_of_mem hU), EventuallyLE] lemma isLittleOTVS_insert [TopologicalSpace α] {x : α} {s : Set α} (h : f x = 0) : f =o[𝕜; 𝓝[insert x s] x] g ↔ f =o[𝕜; (𝓝[s] x)] g := by rw [nhdsWithin_insert, isLittleOTVS_sup, and_iff_right] exact .congr' (.zero g _) h.symm .rfl lemma IsLittleOTVS.insert [TopologicalSpace α] {x : α} {s : Set α} (h : f =o[𝕜; 𝓝[s] x] g) (hf : f x = 0) : f =o[𝕜; 𝓝[insert x s] x] g := (isLittleOTVS_insert hf).2 h @[simp] lemma IsLittleOTVS.bot : f =o[𝕜; ⊥] g := ⟨fun u hU ↦ ⟨univ, by simp [EventuallyLE]⟩⟩ theorem IsLittleOTVS.prodMk [ContinuousSMul 𝕜 E] [ContinuousSMul 𝕜 F] {k : α → G} (hf : f =o[𝕜; l] k) (hg : g =o[𝕜; l] k) : (fun x ↦ (f x, g x)) =o[𝕜; l] k := by rw [((nhds_basis_balanced 𝕜 E).prod_nhds (nhds_basis_balanced 𝕜 F)).isLittleOTVS_iff (basis_sets _)] rintro ⟨U, V⟩ ⟨⟨hU, hUb⟩, hV, hVb⟩ rcases ((hf.eventually_smallSets U hU).and (hg.eventually_smallSets V hV)).exists_mem_of_smallSets with ⟨W, hW, hWf, hWg⟩ refine ⟨W, hW, fun ε hε ↦ ?_⟩ filter_upwards [hWf ε hε, hWg ε hε] with x hfx hgx simp [egauge_prod_mk, *] protected theorem IsLittleOTVS.fst {f : α → E × F} {g : α → G} (h : f =o[𝕜; l] g) : (f · |>.fst) =o[𝕜; l] g := ContinuousLinearMap.fst 𝕜 E F |>.isBigOTVS_comp |>.trans_isLittleOTVS h protected theorem IsLittleOTVS.snd {f : α → E × F} {g : α → G} (h : f =o[𝕜; l] g) : (f · |>.snd) =o[𝕜; l] g := ContinuousLinearMap.snd 𝕜 E F |>.isBigOTVS_comp |>.trans_isLittleOTVS h @[simp] theorem isLittleOTVS_prodMk_left [ContinuousSMul 𝕜 E] [ContinuousSMul 𝕜 F] {k : α → G} : (fun x ↦ (f x, g x)) =o[𝕜; l] k ↔ f =o[𝕜; l] k ∧ g =o[𝕜; l] k := ⟨fun h ↦ ⟨h.fst, h.snd⟩, fun h ↦ h.elim .prodMk⟩ theorem IsBigOTVS.prodMk [ContinuousSMul 𝕜 E] [ContinuousSMul 𝕜 F] {k : α → G} (hf : f =O[𝕜; l] k) (hg : g =O[𝕜; l] k) : (fun x ↦ (f x, g x)) =O[𝕜; l] k := by rw [((nhds_basis_balanced 𝕜 E).prod_nhds (nhds_basis_balanced 𝕜 F)).isBigOTVS_iff (basis_sets _)] rintro ⟨U, V⟩ ⟨⟨hU, hUb⟩, hV, hVb⟩ rcases ((hf.eventually_smallSets U hU).and (hg.eventually_smallSets V hV)).exists_mem_of_smallSets with ⟨W, hW, hWf, hWg⟩ refine ⟨W, hW, ?_⟩ filter_upwards [hWf, hWg] with x hfx hgx simp [egauge_prod_mk, *] protected theorem IsBigOTVS.fst {f : α → E × F} {g : α → G} (h : f =O[𝕜; l] g) : (f · |>.fst) =O[𝕜; l] g := ContinuousLinearMap.fst 𝕜 E F |>.isBigOTVS_comp |>.trans h protected theorem IsBigOTVS.snd {f : α → E × F} {g : α → G} (h : f =O[𝕜; l] g) : (f · |>.snd) =O[𝕜; l] g := ContinuousLinearMap.snd 𝕜 E F |>.isBigOTVS_comp |>.trans h @[simp] theorem isBigOTVS_prodMk_left [ContinuousSMul 𝕜 E] [ContinuousSMul 𝕜 F] {k : α → G} : (fun x ↦ (f x, g x)) =O[𝕜; l] k ↔ f =O[𝕜; l] k ∧ g =O[𝕜; l] k := ⟨fun h ↦ ⟨h.fst, h.snd⟩, fun h ↦ h.elim .prodMk⟩ theorem IsLittleOTVS.add [ContinuousAdd E] [ContinuousSMul 𝕜 E] {f₁ f₂ : α → E} {g : α → F} {l : Filter α} (h₁ : f₁ =o[𝕜; l] g) (h₂ : f₂ =o[𝕜; l] g) : (f₁ + f₂) =o[𝕜; l] g := ContinuousLinearMap.fst 𝕜 E E + ContinuousLinearMap.snd 𝕜 E E |>.isBigOTVS_comp |>.trans_isLittleOTVS <| h₁.prodMk h₂ theorem IsBigOTVS.add [ContinuousAdd E] [ContinuousSMul 𝕜 E] {f₁ f₂ : α → E} {g : α → F} {l : Filter α} (h₁ : f₁ =O[𝕜; l] g) (h₂ : f₂ =O[𝕜; l] g) : (f₁ + f₂) =O[𝕜; l] g := ContinuousLinearMap.fst 𝕜 E E + ContinuousLinearMap.snd 𝕜 E E |>.isBigOTVS_comp |>.trans <| h₁.prodMk h₂ protected theorem IsLittleOTVS.pi {ι : Type*} {E : ι → Type*} [∀ i, AddCommGroup (E i)] [∀ i, Module 𝕜 (E i)] [∀ i, TopologicalSpace (E i)] [∀ i, ContinuousSMul 𝕜 (E i)] {f : ∀ i, α → E i} (h : ∀ i, f i =o[𝕜; l] g) : (fun x i ↦ f i x) =o[𝕜; l] g := by have := hasBasis_pi fun i ↦ nhds_basis_balanced 𝕜 (E i) rw [← nhds_pi, ← Pi.zero_def] at this simp only [this.isLittleOTVS_iff (basis_sets _), forall_and, Prod.forall, id] rintro I U ⟨hIf, hU, Ub⟩ have := fun i hi ↦ (h i).eventually_smallSets (U i) (hU i hi) rcases (hIf.eventually_all.mpr this).exists_mem_of_smallSets with ⟨V, hV₀, hV⟩ refine ⟨V, hV₀, fun ε hε ↦ ?_⟩ refine (hIf.eventually_all.mpr (hV · · ε hε)).mono fun x hx ↦ ?_ simpa only [id, egauge_pi hIf Ub, iSup₂_le_iff] theorem IsLittleOTVS.proj {ι : Type*} {E : ι → Type*} [∀ i, AddCommGroup (E i)] [∀ i, Module 𝕜 (E i)] [∀ i, TopologicalSpace (E i)] {f : α → ∀ i, E i} (h : f =o[𝕜; l] g) (i : ι) : (f · i) =o[𝕜; l] g := ContinuousLinearMap.proj i |>.isBigOTVS_fun_comp |>.trans_isLittleOTVS h theorem isLittleOTVS_pi {ι : Type*} {E : ι → Type*} [∀ i, AddCommGroup (E i)] [∀ i, Module 𝕜 (E i)] [∀ i, TopologicalSpace (E i)] [∀ i, ContinuousSMul 𝕜 (E i)] {f : α → ∀ i, E i} : f =o[𝕜; l] g ↔ ∀ i, (f · i) =o[𝕜; l] g := ⟨.proj, .pi⟩ protected theorem IsBigOTVS.pi {ι : Type*} {E : ι → Type*} [∀ i, AddCommGroup (E i)] [∀ i, Module 𝕜 (E i)] [∀ i, TopologicalSpace (E i)] [∀ i, ContinuousSMul 𝕜 (E i)] {f : ∀ i, α → E i} (h : ∀ i, f i =O[𝕜; l] g) : (fun x i ↦ f i x) =O[𝕜; l] g := by have := hasBasis_pi fun i ↦ nhds_basis_balanced 𝕜 (E i) rw [← nhds_pi, ← Pi.zero_def] at this simp only [this.isBigOTVS_iff (basis_sets _), forall_and, Prod.forall, id] rintro I U ⟨hIf, hU, Ub⟩ have := fun i hi ↦ (h i).eventually_smallSets (U i) (hU i hi) rcases (hIf.eventually_all.mpr this).exists_mem_of_smallSets with ⟨V, hV₀, hV⟩ use V, hV₀ refine (hIf.eventually_all.mpr hV).mono fun x hx ↦ ?_ simpa only [id, egauge_pi hIf Ub, iSup₂_le_iff] theorem IsBigOTVS.proj {ι : Type*} {E : ι → Type*} [∀ i, AddCommGroup (E i)] [∀ i, Module 𝕜 (E i)] [∀ i, TopologicalSpace (E i)] {f : α → ∀ i, E i} (h : f =O[𝕜; l] g) (i : ι) : (f · i) =O[𝕜; l] g := ContinuousLinearMap.proj i |>.isBigOTVS_fun_comp |>.trans h theorem isBigOTVS_pi {ι : Type*} {E : ι → Type*} [∀ i, AddCommGroup (E i)] [∀ i, Module 𝕜 (E i)] [∀ i, TopologicalSpace (E i)] [∀ i, ContinuousSMul 𝕜 (E i)] {f : α → ∀ i, E i} : f =O[𝕜; l] g ↔ ∀ i, (f · i) =O[𝕜; l] g := ⟨.proj, .pi⟩ protected lemma IsLittleOTVS.smul_left (h : f =o[𝕜; l] g) (c : α → 𝕜) : (fun x ↦ c x • f x) =o[𝕜; l] (fun x ↦ c x • g x) := by simp only [isLittleOTVS_iff] at * peel h with U hU V hV ε hε x hx simp only at * rw [egauge_smul_right, egauge_smul_right, mul_left_comm] · gcongr all_goals exact fun _ ↦ Filter.nonempty_of_mem ‹_› lemma isLittleOTVS_one [ContinuousSMul 𝕜 E] : f =o[𝕜; l] (1 : α → 𝕜) ↔ Tendsto f l (𝓝 0) := by constructor · intro hf rw [(basis_sets _).isLittleOTVS_iff nhds_basis_ball] at hf rw [(nhds_basis_balanced 𝕜 E).tendsto_right_iff] rintro U ⟨hU, hUb⟩ rcases hf U hU with ⟨r, hr₀, hr⟩ lift r to ℝ≥0 using hr₀.le norm_cast at hr₀ rcases NormedField.exists_one_lt_norm 𝕜 with ⟨c, hc⟩ obtain ⟨ε, hε₀, hε⟩ : ∃ ε : ℝ≥0, 0 < ε ∧ (ε * ‖c‖₊ / r : ℝ≥0∞) < 1 := by apply Eventually.exists_gt refine Continuous.tendsto' ?_ _ _ (by simp) |>.eventually_lt_const zero_lt_one fun_prop (disch := intros; first | apply ENNReal.coe_ne_top | positivity) filter_upwards [hr ε hε₀.ne'] with x hx refine mem_of_egauge_lt_one hUb (hx.trans_lt ?_) calc (ε : ℝ≥0∞) * egauge 𝕜 (ball (0 : 𝕜) r) 1 ≤ (ε * ‖c‖₊ / r : ℝ≥0∞) := by rw [mul_div_assoc] gcongr simpa using egauge_ball_le_of_one_lt_norm (r := r) (x := (1 : 𝕜)) hc (by simp) _ < 1 := ‹_› · simp only [isLittleOTVS_iff] intro hf U hU refine ⟨ball 0 1, ball_mem_nhds _ one_pos, fun ε hε ↦ ?_⟩ rcases NormedField.exists_norm_lt 𝕜 hε.bot_lt with ⟨c, hc₀, hcε⟩ replace hc₀ : c ≠ 0 := by simpa using hc₀ filter_upwards [hf ((set_smul_mem_nhds_zero_iff hc₀).2 hU)] with a ha calc egauge 𝕜 U (f a) ≤ ‖c‖₊ := egauge_le_of_mem_smul ha _ ≤ ε := mod_cast hcε.le _ ≤ ε * egauge 𝕜 (ball (0 : 𝕜) 1) 1 := by apply le_mul_of_one_le_right' simpa using le_egauge_ball_one 𝕜 (1 : 𝕜) lemma IsLittleOTVS.tendsto_inv_smul [ContinuousSMul 𝕜 E] {f : α → 𝕜} {g : α → E} (h : g =o[𝕜; l] f) : Tendsto (fun x ↦ (f x)⁻¹ • g x) l (𝓝 0) := by rw [← isLittleOTVS_one (𝕜 := 𝕜), isLittleOTVS_iff] intro U hU rcases (h.smul_left f⁻¹).1 U hU with ⟨V, hV₀, hV⟩ refine ⟨V, hV₀, fun ε hε ↦ (hV ε hε).mono fun x hx ↦ hx.trans ?_⟩ by_cases hx₀ : f x = 0 <;> simp [hx₀, egauge_zero_right _ (Filter.nonempty_of_mem hV₀)] lemma isLittleOTVS_iff_tendsto_inv_smul [ContinuousSMul 𝕜 E] {f : α → 𝕜} {g : α → E} {l : Filter α} (h₀ : ∀ᶠ x in l, f x = 0 → g x = 0) : g =o[𝕜; l] f ↔ Tendsto (fun x ↦ (f x)⁻¹ • g x) l (𝓝 0) := by refine ⟨IsLittleOTVS.tendsto_inv_smul, fun h ↦ ?_⟩ refine (((isLittleOTVS_one (𝕜 := 𝕜)).mpr h).smul_left f).congr' (h₀.mono fun x hx ↦ ?_) (by simp) by_cases h : f x = 0 <;> simp [h, hx] variable (𝕜) in /-- If `f` converges along `l` to a finite limit `x`, then `f =O[𝕜, l] 1`. -/ lemma Filter.Tendsto.isBigOTVS_one [ContinuousAdd E] [ContinuousSMul 𝕜 E] {x : E} (h : Tendsto f l (𝓝 x)) : f =O[𝕜; l] (fun _ ↦ 1 : α → 𝕜) := by replace h : Tendsto (f · - x) l (𝓝 0) := by simpa [sub_eq_add_neg] using h.add (tendsto_const_nhds (x := -x)) rw [(nhds_basis_balanced 𝕜 E).add_self.isBigOTVS_iff nhds_basis_ball] rintro U ⟨hU₀, hUb⟩ obtain ⟨r, hr₀, hr₁, hr⟩ : ∃ r : ℝ≥0, 0 < r ∧ r ≤ 1 ∧ (r : ℝ≥0∞) ≤ (egauge 𝕜 U x)⁻¹ := by apply Eventually.exists_gt refine .and (eventually_le_nhds one_pos) ?_ refine (ENNReal.tendsto_coe.mpr tendsto_id).eventually_le_const ?_ suffices ∃ c : 𝕜, x ∈ c • U by simpa [egauge_eq_top] simpa using (absorbent_nhds_zero (𝕜 := 𝕜) hU₀ x).exists use r, by positivity filter_upwards [h.eventually_mem hU₀] with a ha calc egauge 𝕜 (U + U) (f a) ≤ max (egauge 𝕜 U (f a - x)) (egauge 𝕜 U x) := by simpa using egauge_add_add_le hUb hUb (f a - x) x _ ≤ (r : ℝ≥0∞)⁻¹ := by apply max_le · refine (egauge_le_one _ ha).trans ?_ simp [hr₁] · rwa [ENNReal.le_inv_iff_le_inv] _ ≤ egauge 𝕜 (ball (0 : 𝕜) _) 1 := by simpa using div_le_egauge_ball 𝕜 r (1 : 𝕜) end TopologicalSpace section NormedSpace variable [NontriviallyNormedField 𝕜] variable [SeminormedAddCommGroup E] [SeminormedAddCommGroup F] [NormedSpace 𝕜 E] [NormedSpace 𝕜 F] lemma isLittleOTVS_iff_isLittleO {f : α → E} {g : α → F} {l : Filter α} : f =o[𝕜; l] g ↔ f =o[l] g := by rcases NormedField.exists_one_lt_norm 𝕜 with ⟨c, hc : 1 < ‖c‖₊⟩ have hc₀ : 0 < ‖c‖₊ := one_pos.trans hc simp only [isLittleO_iff, nhds_basis_ball.isLittleOTVS_iff nhds_basis_ball] refine ⟨fun h ε hε ↦ ?_, fun h ε hε ↦ ⟨1, one_pos, fun δ hδ ↦ ?_⟩⟩ · rcases h ε hε with ⟨δ, hδ₀, hδ⟩ lift ε to ℝ≥0 using hε.le; lift δ to ℝ≥0 using hδ₀.le; norm_cast at hε hδ₀ filter_upwards [hδ (δ / ‖c‖₊) (div_pos hδ₀ hc₀).ne'] with x hx suffices (‖f x‖₊ / ε : ℝ≥0∞) ≤ ‖g x‖₊ by rw [← ENNReal.coe_div hε.ne'] at this rw [← div_le_iff₀' (NNReal.coe_pos.2 hε)] exact_mod_cast this calc (‖f x‖₊ / ε : ℝ≥0∞) ≤ egauge 𝕜 (ball 0 ε) (f x) := div_le_egauge_ball 𝕜 _ _ _ ≤ ↑(δ / ‖c‖₊) * egauge 𝕜 (ball 0 ↑δ) (g x) := hx _ ≤ (δ / ‖c‖₊) * (‖c‖₊ * ‖g x‖₊ / δ) := by gcongr exacts [ENNReal.coe_div_le, egauge_ball_le_of_one_lt_norm hc (.inl <| ne_of_gt hδ₀)] _ = (δ / δ) * (‖c‖₊ / ‖c‖₊) * ‖g x‖₊ := by simp only [div_eq_mul_inv]; ring _ ≤ 1 * 1 * ‖g x‖₊ := by gcongr <;> exact ENNReal.div_self_le_one _ = ‖g x‖₊ := by simp · filter_upwards [@h ↑(ε * δ / ‖c‖₊) (by positivity)] with x (hx : ‖f x‖₊ ≤ ε * δ / ‖c‖₊ * ‖g x‖₊) lift ε to ℝ≥0 using hε.le calc egauge 𝕜 (ball 0 ε) (f x) ≤ ‖c‖₊ * ‖f x‖₊ / ε := egauge_ball_le_of_one_lt_norm hc (.inl <| ne_of_gt hε) _ ≤ ‖c‖₊ * (↑(ε * δ / ‖c‖₊) * ‖g x‖₊) / ε := by gcongr; exact_mod_cast hx _ = (‖c‖₊ / ‖c‖₊) * (ε / ε) * δ * ‖g x‖₊ := by simp only [div_eq_mul_inv, ENNReal.coe_inv hc₀.ne', ENNReal.coe_mul]; ring _ ≤ 1 * 1 * δ * ‖g x‖₊ := by gcongr <;> exact ENNReal.div_self_le_one _ = δ * ‖g x‖₊ := by simp _ ≤ δ * egauge 𝕜 (ball 0 1) (g x) := by gcongr; apply le_egauge_ball_one alias ⟨isLittleOTVS.isLittleO, IsLittleO.isLittleOTVS⟩ := isLittleOTVS_iff_isLittleO end NormedSpace end Asymptotics
.lake/packages/mathlib/Mathlib/Analysis/Fourier/AddCircleMulti.lean
import Mathlib.Analysis.Fourier.AddCircle import Mathlib.MeasureTheory.Integral.Pi /-! # Multivariate Fourier series In this file we define the Fourier series of an L² function on the `d`-dimensional unit circle, and show that it converges to the function in the L² norm. We also prove uniform convergence of the Fourier series if `f` is continuous and the sequence of its Fourier coefficients is summable. -/ noncomputable section open scoped BigOperators ComplexConjugate ENNReal open Set Algebra Submodule MeasureTheory -- some instances for unit circle attribute [local instance] Real.fact_zero_lt_one /-- In this file we normalise the measure on `ℝ / ℤ` to have total volume 1. -/ local instance : MeasureSpace UnitAddCircle := ⟨AddCircle.haarAddCircle⟩ /-- The measure on `ℝ / ℤ` is a Haar measure. -/ local instance : Measure.IsAddHaarMeasure (volume : Measure UnitAddCircle) := inferInstanceAs (Measure.IsAddHaarMeasure AddCircle.haarAddCircle) /-- The measure on `ℝ / ℤ` is a probability measure. -/ local instance : IsProbabilityMeasure (volume : Measure UnitAddCircle) := inferInstanceAs (IsProbabilityMeasure AddCircle.haarAddCircle) /-- The product of finitely many copies of the unit circle, indexed by `d`. -/ abbrev UnitAddTorus (d : Type*) := d → UnitAddCircle namespace UnitAddTorus variable {d : Type*} [Fintype d] section Monomials variable (n : d → ℤ) /-- Exponential monomials in `d` variables. -/ def mFourier : C(UnitAddTorus d, ℂ) where toFun x := ∏ i : d, fourier (n i) (x i) continuous_toFun := by fun_prop variable {n} {x : UnitAddTorus d} lemma mFourier_neg : mFourier (-n) x = conj (mFourier n x) := by simp only [mFourier, Pi.neg_apply, fourier_neg, ContinuousMap.coe_mk, map_prod] lemma mFourier_add {m : d → ℤ} : mFourier (m + n) x = mFourier m x * mFourier n x := by simp only [mFourier, Pi.add_apply, fourier_add, ContinuousMap.coe_mk, ← Finset.prod_mul_distrib] lemma mFourier_zero : mFourier (0 : d → ℤ) = 1 := by ext x simp only [mFourier, Pi.zero_apply, fourier_zero, Finset.prod_const_one, ContinuousMap.coe_mk, ContinuousMap.one_apply] lemma mFourier_norm : ‖mFourier n‖ = 1 := by apply le_antisymm · refine (ContinuousMap.norm_le _ zero_le_one).mpr fun i ↦ ?_ simp only [mFourier, fourier_apply, ContinuousMap.coe_mk, norm_prod, Circle.norm_coe, Finset.prod_const_one, le_rfl] · refine (le_of_eq ?_).trans ((mFourier n).norm_coe_le_norm fun _ ↦ 0) simp only [mFourier, ContinuousMap.coe_mk, fourier_eval_zero, Finset.prod_const_one, CStarRing.norm_one] lemma mFourier_single [DecidableEq d] (z : d → AddCircle (1 : ℝ)) (i : d) : mFourier (Pi.single i 1) z = fourier 1 (z i) := by simp_rw [mFourier, ContinuousMap.coe_mk] have := Finset.prod_mul_prod_compl {i} (fun j ↦ fourier ((Pi.single i (1 : ℤ) : d → ℤ) j) (z j)) rw [Finset.prod_singleton, Finset.prod_congr rfl (fun j hj ↦ ?_)] at this · rw [← this, Finset.prod_const_one, mul_one, Pi.single_eq_same] · rw [Finset.mem_compl, Finset.mem_singleton] at hj simp only [Pi.single_eq_of_ne hj, fourier_zero] end Monomials section Algebra /-- The star subalgebra of `C(UnitAddTorus d, ℂ)` generated by `mFourier n` for `n ∈ ℤᵈ`. -/ def mFourierSubalgebra (d : Type*) [Fintype d] : StarSubalgebra ℂ C(UnitAddTorus d, ℂ) where toSubalgebra := Algebra.adjoin ℂ (range mFourier) star_mem' := by change Algebra.adjoin ℂ (range mFourier) ≤ star (Algebra.adjoin ℂ (range mFourier)) refine adjoin_le ?_ rintro _ ⟨n, rfl⟩ refine subset_adjoin ⟨-n, ?_⟩ ext1 x simp only [mFourier_neg, starRingEnd_apply, ContinuousMap.star_apply] /-- The star subalgebra of `C(UnitAddTorus d, ℂ)` generated by `mFourier n` for `n ∈ ℤᵈ` is in fact the linear span of these functions. -/ theorem mFourierSubalgebra_coe : (mFourierSubalgebra d).toSubalgebra.toSubmodule = span ℂ (range mFourier) := by apply adjoin_eq_span_of_subset refine .trans (fun x ↦ Submonoid.closure_induction (fun _ ↦ id) ⟨0, ?_⟩ ?_) subset_span · ext z simp only [mFourier, Pi.zero_apply, fourier_zero, Finset.prod_const, one_pow, ContinuousMap.coe_mk, ContinuousMap.one_apply] · rintro _ _ _ _ ⟨m, rfl⟩ ⟨n, rfl⟩ refine ⟨m + n, ?_⟩ ext z simp only [mFourier, Pi.add_apply, fourier_apply, fourier_add', Finset.prod_mul_distrib, ContinuousMap.coe_mk, ContinuousMap.mul_apply] /-- The subalgebra of `C(UnitAddTorus d, ℂ)` generated by `mFourier n` for `n ∈ ℤᵈ` separates points. -/ theorem mFourierSubalgebra_separatesPoints : (mFourierSubalgebra d).SeparatesPoints := by classical intro x y hxy rw [Ne, funext_iff, not_forall] at hxy obtain ⟨i, hi⟩ := hxy refine ⟨_, ⟨mFourier (Pi.single i 1), subset_adjoin ⟨Pi.single i 1, rfl⟩, rfl⟩, ?_⟩ dsimp only rw [mFourier_single, mFourier_single, fourier_one, fourier_one, Ne, Subtype.coe_inj] contrapose! hi exact AddCircle.injective_toCircle one_ne_zero hi /-- The subalgebra of `C(UnitAddTorus d, ℂ)` generated by `mFourier n` for `n : d → ℤ` is dense. -/ theorem mFourierSubalgebra_closure_eq_top : (mFourierSubalgebra d).topologicalClosure = ⊤ := ContinuousMap.starSubalgebra_topologicalClosure_eq_top_of_separatesPoints _ mFourierSubalgebra_separatesPoints /-- The linear span of the monomials `mFourier n` is dense in `C(UnitAddTorus d, ℂ)`. -/ theorem span_mFourier_closure_eq_top : (span ℂ (range <| mFourier (d := d))).topologicalClosure = ⊤ := by rw [← mFourierSubalgebra_coe] exact congr_arg (Subalgebra.toSubmodule <| StarSubalgebra.toSubalgebra ·) mFourierSubalgebra_closure_eq_top end Algebra section Lp /-- The family of monomials `mFourier n`, parametrized by `n : ℤᵈ` and considered as elements of the `Lp` space of functions `UnitAddTorus d → ℂ`. -/ abbrev mFourierLp (p : ℝ≥0∞) [Fact (1 ≤ p)] (n : d → ℤ) : Lp ℂ p (volume : Measure (UnitAddTorus d)) := ContinuousMap.toLp (E := ℂ) p volume ℂ (mFourier n) theorem coeFn_mFourierLp (p : ℝ≥0∞) [Fact (1 ≤ p)] (n : d → ℤ) : mFourierLp p n =ᵐ[volume] mFourier n := ContinuousMap.coeFn_toLp volume (mFourier n) -- shortcut instance: avoids `synthInstance.maxHeartbeats` issue in `span_mFourierLp_closure_eq_top` instance {p : ℝ≥0∞} [Fact (1 ≤ p)] : ContinuousSMul ℂ (Lp ℂ p (volume : Measure (UnitAddTorus d))) := inferInstance /-- For each `1 ≤ p < ∞`, the linear span of the monomials `mFourier n` is dense in the `Lᵖ` space of functions on `UnitAddTorus d`. -/ theorem span_mFourierLp_closure_eq_top {p : ℝ≥0∞} [Fact (1 ≤ p)] (hp : p ≠ ∞) : (span ℂ (range (@mFourierLp d _ p _))).topologicalClosure = ⊤ := by simpa only [map_span, ContinuousLinearMap.coe_coe, ← range_comp, Function.comp_def] using (ContinuousMap.toLp_denseRange ℂ volume ℂ hp).topologicalClosure_map_submodule span_mFourier_closure_eq_top /-- The monomials `mFourierLp 2 n` are an orthonormal set in `L²`. -/ theorem orthonormal_mFourier : Orthonormal ℂ (mFourierLp (d := d) 2) := by rw [orthonormal_iff_ite] intro m n simp only [ContinuousMap.inner_toLp, ← mFourier_neg, ← mFourier_add] split_ifs with h · simpa only [h, add_neg_cancel, mFourier_zero, measureReal_univ_eq_one, one_smul] using integral_const (α := UnitAddTorus d) (μ := volume) (1 : ℂ) rw [mFourier, ContinuousMap.coe_mk, MeasureTheory.integral_fintype_prod_volume_eq_prod] obtain ⟨i, hi⟩ := Function.ne_iff.mp h apply Finset.prod_eq_zero (Finset.mem_univ i) simpa only [eq_false_intro hi, if_false, ContinuousMap.inner_toLp, ← fourier_neg, ← fourier_add] using (orthonormal_iff_ite.mp <| orthonormal_fourier) (m i) (n i) end Lp section fourierCoeff variable {E : Type} [NormedAddCommGroup E] [NormedSpace ℂ E] /-- The `n`-th Fourier coefficient of a function `UnitAddTorus d → E`, for `E` a complete normed `ℂ`-vector space, defined as the integral over `UnitAddTorus d` of `mFourier (-n) t • f t`. -/ def mFourierCoeff (f : UnitAddTorus d → E) (n : d → ℤ) : E := ∫ t, mFourier (-n) t • f t end fourierCoeff section FourierL2 local notation "L²(" α ")" => Lp ℂ 2 (volume : Measure α) /-- We define `mFourierBasis` to be a `ℤᵈ`-indexed Hilbert basis for the `L²` space of functions on `UnitAddTorus d`, which by definition is an isometric isomorphism from `L²(UnitAddTorus d)` to `ℓ²(ℤᵈ, ℂ)`. -/ def mFourierBasis : HilbertBasis (d → ℤ) ℂ L²(UnitAddTorus d) := HilbertBasis.mk orthonormal_mFourier (span_mFourierLp_closure_eq_top (by simp)).ge /-- The elements of the Hilbert basis `mFourierBasis` are the functions `mFourierLp 2`, i.e. the monomials `mFourier n` on `UnitAddTorus d` considered as elements of `L²`. -/ @[simp] theorem coe_mFourierBasis : ⇑(mFourierBasis (d := d)) = mFourierLp 2 := HilbertBasis.coe_mk _ _ /-- Under the isometric isomorphism `mFourierBasis` from `L²(UnitAddTorus d)` to `ℓ²(ℤᵈ, ℂ)`, the `i`-th coefficient is `mFourierCoeff f i`. -/ theorem mFourierBasis_repr (f : L²(UnitAddTorus d)) (i : d → ℤ) : mFourierBasis.repr f i = mFourierCoeff f i := by trans ∫ t, conj (mFourierLp 2 i t) * f t · rw [mFourierBasis.repr_apply_apply f i, MeasureTheory.L2.inner_def, coe_mFourierBasis] simp only [RCLike.inner_apply, mul_comm] · apply integral_congr_ae filter_upwards [coeFn_mFourierLp 2 i] with _ ht rw [ht, ← mFourier_neg, smul_eq_mul] /-- The Fourier series of an `L2` function `f` sums to `f` in the `L²` norm. -/ theorem hasSum_mFourier_series_L2 (f : L²(UnitAddTorus d)) : HasSum (fun i ↦ mFourierCoeff f i • mFourierLp 2 i) f := by simpa [← coe_mFourierBasis, mFourierBasis_repr] using mFourierBasis.hasSum_repr f /-- **Parseval's identity** for inner products: for `L²` functions `f, g` on `UnitAddTorus d`, the inner product of the Fourier coefficients of `f` and `g` is the inner product of `f` and `g`. -/ theorem hasSum_prod_mFourierCoeff (f g : L²(UnitAddTorus d)) : HasSum (fun i ↦ conj (mFourierCoeff f i) * (mFourierCoeff g i)) (∫ t, conj (f t) * g t) := by simp_rw [mul_comm (conj _)] refine HasSum.congr_fun (mFourierBasis.hasSum_inner_mul_inner f g) (fun n ↦ ?_) simp only [← mFourierBasis_repr, HilbertBasis.repr_apply_apply, inner_conj_symm, mul_comm (inner ℂ f _)] /-- **Parseval's identity** for norms: for an `L²` function `f` on `UnitAddTorus d`, the sum of the squared norms of the Fourier coefficients equals the `L²` norm of `f`. -/ theorem hasSum_sq_mFourierCoeff (f : L²(UnitAddTorus d)) : HasSum (fun i ↦ ‖mFourierCoeff f i‖ ^ 2) (∫ t, ‖f t‖ ^ 2) := by simpa only [← RCLike.inner_apply', inner_self_eq_norm_sq, ← integral_re (L2.integrable_inner f f)] using RCLike.hasSum_re ℂ (hasSum_prod_mFourierCoeff f f) end FourierL2 section Convergence variable (f : C(UnitAddTorus d, ℂ)) theorem mFourierCoeff_toLp (n : d → ℤ) : mFourierCoeff (f.toLp 2 volume ℂ) n = mFourierCoeff f n := integral_congr_ae (ae_eq_rfl.mul <| f.coeFn_toAEEqFun _) variable {f} /-- If the sequence of Fourier coefficients of `f` is summable, then the Fourier series converges uniformly to `f`. -/ theorem hasSum_mFourier_series_of_summable (h : Summable (mFourierCoeff f)) : HasSum (fun i ↦ mFourierCoeff f i • mFourier i) f := by have sum_L2 := hasSum_mFourier_series_L2 (ContinuousMap.toLp 2 volume ℂ f) simp only [mFourierCoeff_toLp] at sum_L2 refine ContinuousMap.hasSum_of_hasSum_Lp (.of_norm ?_) sum_L2 simpa only [norm_smul, mFourier_norm, mul_one] using h.norm /-- If the sequence of Fourier coefficients of `f` is summable, then the Fourier series of `f` converges everywhere pointwise to `f`. -/ theorem hasSum_mFourier_series_apply_of_summable (h : Summable (mFourierCoeff f)) (x : UnitAddTorus d) : HasSum (fun i ↦ mFourierCoeff f i • mFourier i x) (f x) := by simpa only [map_smul] using (ContinuousMap.evalCLM ℂ x).hasSum (hasSum_mFourier_series_of_summable h) end Convergence end UnitAddTorus
.lake/packages/mathlib/Mathlib/Analysis/Fourier/BoundedContinuousFunctionChar.lean
import Mathlib.Algebra.MonoidAlgebra.Basic import Mathlib.Analysis.Complex.Circle import Mathlib.Analysis.InnerProductSpace.Basic import Mathlib.Topology.ContinuousMap.Bounded.Star /-! # Definition of BoundedContinuousFunction.char Definition and basic properties of `BoundedContinuousFunction.char he hL w := fun v ↦ e (L v w)`, where `e` is a continuous additive character and `L : V →ₗ[ℝ] W →ₗ[ℝ] ℝ` is a continuous bilinear map. In the special case `e = Circle.exp`, this is used to define the characteristic function of a measure. ## Main definitions - `char he hL w : V →ᵇ ℂ`: Bounded continuous mapping `fun v ↦ e (L v w)` from `V` to `ℂ`, where `e` is a continuous additive character and `L : V →ₗ[ℝ] W →ₗ[ℝ] ℝ` is a continuous bilinear map. - `charPoly he hL : W → ℂ`: The `StarSubalgebra ℂ (V →ᵇ ℂ)` consisting of `ℂ`-linear combinations of `char he hL w`, where `w : W`. ## Main statements - `ext_of_char_eq`: If `e` and `L` are non-trivial, then `char he hL w, w : W` separates points in `V`. - `star_mem_range_charAlgHom`: The family of `ℂ`-linear combinations of `char he hL w, w : W`, is closed under `star`. - `separatesPoints_charPoly`: The family `charPoly he hL w, w : W` separates points in `V`. -/ open Filter BoundedContinuousFunction Complex namespace BoundedContinuousFunction variable {V W : Type*} [AddCommGroup V] [Module ℝ V] [TopologicalSpace V] [AddCommGroup W] [Module ℝ W] [TopologicalSpace W] {e : AddChar ℝ Circle} {L : V →ₗ[ℝ] W →ₗ[ℝ] ℝ} {he : Continuous e} {hL : Continuous fun p : V × W ↦ L p.1 p.2} /-- The bounded continuous mapping `fun v ↦ e (L v w)` from `V` to `ℂ`. -/ noncomputable def char (he : Continuous e) (hL : Continuous fun p : V × W ↦ L p.1 p.2) (w : W) : V →ᵇ ℂ where toFun := fun v ↦ e (L v w) continuous_toFun := continuous_induced_dom.comp (he.comp (hL.comp (Continuous.prodMk_left w))) map_bounded' := by refine ⟨2, fun x y ↦ ?_⟩ calc dist _ _ ≤ (‖_‖ : ℝ) + ‖_‖ := dist_le_norm_add_norm _ _ _ ≤ 1 + 1 := add_le_add (by simp) (by simp) _ = 2 := by ring @[simp] lemma char_apply (w : W) (v : V) : char he hL w v = e (L v w) := rfl @[simp] lemma char_zero_eq_one : char he hL 0 = 1 := by ext; simp lemma char_add_eq_mul (x y : W) : char he hL (x + y) = char he hL x * char he hL y := by ext simp [e.map_add_eq_mul] lemma char_neg (w : W) : char he hL (-w) = star (char he hL w) := by ext; simp /-- If `e` and `L` are non-trivial, then `char he hL w, w : W` separates points in `V`. -/ theorem ext_of_char_eq (he : Continuous e) (he' : e ≠ 1) (hL : Continuous fun p : V × W ↦ L p.1 p.2) (hL' : ∀ v ≠ 0, L v ≠ 0) {v v' : V} (h : ∀ w, char he hL w v = char he hL w v') : v = v' := by contrapose! h obtain ⟨w, hw⟩ := DFunLike.ne_iff.mp (hL' (v - v') (sub_ne_zero_of_ne h)) obtain ⟨a, ha⟩ := DFunLike.ne_iff.mp he' use (a / (L (v - v') w)) • w simp only [map_sub, LinearMap.sub_apply, char_apply, ne_eq] rw [← div_eq_one_iff_eq (Circle.coe_ne_zero _), div_eq_inv_mul, ← Metric.unitSphere.coe_inv, ← e.map_neg_eq_inv, ← Submonoid.coe_mul, ← e.map_add_eq_mul, OneMemClass.coe_eq_one] calc e (- L v' ((a / (L v w - L v' w)) • w) + L v ((a / (L v w - L v' w)) • w)) _ = e (- (a / (L v w - L v' w)) • L v' w + (a / (L v w - L v' w)) • L v w) := by congr · rw [neg_smul, ← LinearMap.map_smul (L v')] · rw [← LinearMap.map_smul (L v)] _ = e ((a / (L (v - v') w)) • (L (v - v') w)) := by simp only [map_sub, LinearMap.sub_apply] congr module _ = e a := by congr exact div_mul_cancel₀ a hw _ ≠ 1 := ha /-- Monoid homomorphism mapping `w` to `fun v ↦ e (L v w)`. -/ noncomputable def charMonoidHom (he : Continuous e) (hL : Continuous fun p : V × W ↦ L p.1 p.2) : Multiplicative W →* (V →ᵇ ℂ) where toFun w := char he hL w map_one' := char_zero_eq_one map_mul' := char_add_eq_mul (he := he) (hL := hL) @[simp] lemma charMonoidHom_apply (w : Multiplicative W) (v : V) : charMonoidHom he hL w v = e (L v w) := by simp [charMonoidHom] /-- Algebra homomorphism mapping `w` to `fun v ↦ e (L v w)`. -/ noncomputable def charAlgHom (he : Continuous e) (hL : Continuous fun p : V × W ↦ L p.1 p.2) : AddMonoidAlgebra ℂ W →ₐ[ℂ] (V →ᵇ ℂ) := AddMonoidAlgebra.lift ℂ W (V →ᵇ ℂ) (charMonoidHom he hL) @[simp] lemma charAlgHom_apply (w : AddMonoidAlgebra ℂ W) (v : V) : charAlgHom he hL w v = ∑ a ∈ w.support, w a * (e (L v a) : ℂ) := by simp only [charAlgHom, AddMonoidAlgebra.lift_apply] rw [Finsupp.sum_of_support_subset w subset_rfl] · simp only [coe_sum, coe_smul, charMonoidHom_apply, smul_eq_mul, Finset.sum_apply] rfl · simp /-- The family of `ℂ`-linear combinations of `char he hL w, w : W`, is closed under `star`. -/ lemma star_mem_range_charAlgHom (he : Continuous e) (hL : Continuous fun p : V × W ↦ L p.1 p.2) {x : V →ᵇ ℂ} (hx : x ∈ (charAlgHom he hL).range) : star x ∈ (charAlgHom he hL).range := by simp only [AlgHom.mem_range] at hx ⊢ obtain ⟨y, rfl⟩ := hx let z := Finsupp.mapRange star (star_zero _) y let f : W ↪ W := ⟨fun x ↦ -x, (fun _ _ ↦ neg_inj.mp)⟩ refine ⟨z.embDomain f, ?_⟩ ext1 u simp only [charAlgHom_apply, Finsupp.support_embDomain, Finset.sum_map, Finsupp.embDomain_apply, star_apply, star_sum, star_mul', Circle.star_addChar] rw [Finsupp.support_mapRange_of_injective (star_zero _) y star_injective] simp [z, f] /-- The star-subalgebra of polynomials. -/ noncomputable def charPoly (he : Continuous e) (hL : Continuous fun p : V × W ↦ L p.1 p.2) : StarSubalgebra ℂ (V →ᵇ ℂ) where toSubalgebra := (charAlgHom he hL).range star_mem' hx := star_mem_range_charAlgHom he hL hx lemma mem_charPoly (f : V →ᵇ ℂ) : f ∈ charPoly he hL ↔ ∃ w : AddMonoidAlgebra ℂ W, f = fun x ↦ ∑ a ∈ w.support, w a * (e (L x a) : ℂ) := by change f ∈ (charAlgHom he hL).range ↔ _ simp [BoundedContinuousFunction.ext_iff, funext_iff, eq_comm] lemma char_mem_charPoly (w : W) : char he hL w ∈ charPoly he hL := by rw [mem_charPoly] refine ⟨AddMonoidAlgebra.single w 1, ?_⟩ ext v simp only [char_apply, AddMonoidAlgebra.single] rw [Finset.sum_eq_single w] · simp only [Finsupp.single_eq_same, one_mul] · simp [Finsupp.single_apply_ne_zero] · simp /-- The family `charPoly he hL w, w : W` separates points in `V`. -/ lemma separatesPoints_charPoly (he : Continuous e) (he' : e ≠ 1) (hL : Continuous fun p : V × W ↦ L p.1 p.2) (hL' : ∀ v ≠ 0, L v ≠ 0) : ((charPoly he hL).map (toContinuousMapStarₐ ℂ)).SeparatesPoints := by intro v v' hvv' obtain ⟨w, hw⟩ : ∃ w, char he hL w v ≠ char he hL w v' := by contrapose! hvv' exact ext_of_char_eq he he' hL hL' hvv' use char he hL w simp only [StarSubalgebra.coe_toSubalgebra, StarSubalgebra.coe_map, Set.mem_image, SetLike.mem_coe, exists_exists_and_eq_and, ne_eq] exact ⟨⟨char he hL w, char_mem_charPoly w, rfl⟩, hw⟩ end BoundedContinuousFunction
.lake/packages/mathlib/Mathlib/Analysis/Fourier/AddCircle.lean
import Mathlib.Analysis.SpecialFunctions.ExpDeriv import Mathlib.Analysis.SpecialFunctions.Complex.Circle import Mathlib.Analysis.InnerProductSpace.l2Space import Mathlib.MeasureTheory.Function.ContinuousMapDense import Mathlib.MeasureTheory.Function.L2Space import Mathlib.MeasureTheory.Group.Integral import Mathlib.MeasureTheory.Integral.IntervalIntegral.Periodic import Mathlib.Topology.ContinuousMap.StoneWeierstrass import Mathlib.MeasureTheory.Integral.IntervalIntegral.IntegrationByParts /-! # Fourier analysis on the additive circle This file contains basic results on Fourier series for functions on the additive circle `AddCircle T = ℝ / ℤ • T`. ## Main definitions * `haarAddCircle`, Haar measure on `AddCircle T`, normalized to have total measure `1`. Note that this is not the same normalisation as the standard measure defined in `IntervalIntegral.Periodic`, so we do not declare it as a `MeasureSpace` instance, to avoid confusion. * for `n : ℤ`, `fourier n` is the monomial `fun x => exp (2 π i n x / T)`, bundled as a continuous map from `AddCircle T` to `ℂ`. * `fourierBasis` is the Hilbert basis of `Lp ℂ 2 haarAddCircle` given by the images of the monomials `fourier n`. * `fourierCoeff f n`, for `f : AddCircle T → E` (with `E` a complete normed `ℂ`-vector space), is the `n`-th Fourier coefficient of `f`, defined as an integral over `AddCircle T`. The lemma `fourierCoeff_eq_intervalIntegral` expresses this as an integral over `[a, a + T]` for any real `a`. * `fourierCoeffOn`, for `f : ℝ → E` and `a < b` reals, is the `n`-th Fourier coefficient of the unique periodic function of period `b - a` which agrees with `f` on `(a, b]`. The lemma `fourierCoeffOn_eq_integral` expresses this as an integral over `[a, b]`. ## Main statements The theorem `span_fourier_closure_eq_top` states that the span of the monomials `fourier n` is dense in `C(AddCircle T, ℂ)`, i.e. that its `Submodule.topologicalClosure` is `⊤`. This follows from the Stone-Weierstrass theorem after checking that the span is a subalgebra, is closed under conjugation, and separates points. Using this and general theory on approximation of Lᵖ functions by continuous functions, we deduce (`span_fourierLp_closure_eq_top`) that for any `1 ≤ p < ∞`, the span of the Fourier monomials is dense in the Lᵖ space of `AddCircle T`. For `p = 2` we show (`orthonormal_fourier`) that the monomials are also orthonormal, so they form a Hilbert basis for L², which is named as `fourierBasis`; in particular, for `L²` functions `f`, the Fourier series of `f` converges to `f` in the `L²` topology (`hasSum_fourier_series_L2`). Parseval's identity, `hasSum_sq_fourierCoeff`, is a direct consequence. For continuous maps `f : AddCircle T → ℂ`, the theorem `hasSum_fourier_series_of_summable` states that if the sequence of Fourier coefficients of `f` is summable, then the Fourier series `∑ (i : ℤ), fourierCoeff f i * fourier i` converges to `f` in the uniform-convergence topology of `C(AddCircle T, ℂ)`. -/ noncomputable section open scoped ENNReal ComplexConjugate Real open TopologicalSpace ContinuousMap MeasureTheory MeasureTheory.Measure Algebra Submodule Set variable {T : ℝ} namespace AddCircle /-! ### Measure on `AddCircle T` In this file we use the Haar measure on `AddCircle T` normalised to have total measure 1 (which is **not** the same as the standard measure defined in `Topology.Instances.AddCircle`). -/ variable [hT : Fact (0 < T)] /-- Haar measure on the additive circle, normalised to have total measure 1. -/ def haarAddCircle : Measure (AddCircle T) := addHaarMeasure ⊤ deriving IsAddHaarMeasure instance : IsProbabilityMeasure (@haarAddCircle T _) := IsProbabilityMeasure.mk addHaarMeasure_self theorem volume_eq_smul_haarAddCircle : (volume : Measure (AddCircle T)) = ENNReal.ofReal T • (@haarAddCircle T _) := rfl lemma integral_haarAddCircle {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] {f : AddCircle T → E} : ∫ t, f t ∂haarAddCircle = T⁻¹ • ∫ t, f t := by rw [volume_eq_smul_haarAddCircle, integral_smul_measure, ENNReal.toReal_ofReal hT.out.le, inv_smul_smul₀ hT.out.ne'] end AddCircle namespace MeasureTheory lemma memLp_haarAddCircle_iff [hT : Fact (0 < T)] {f : AddCircle T → ℂ} {p : ℝ≥0∞} : MemLp f p AddCircle.haarAddCircle ↔ MemLp f p := by rw [AddCircle.volume_eq_smul_haarAddCircle] have hT' := hT.out refine ⟨fun h ↦ h.smul_measure (by finiteness), fun h ↦ ?_⟩ have := h.smul_measure (c := (ENNReal.ofReal T)⁻¹) (by finiteness) rwa [smul_smul, ENNReal.inv_mul_cancel (by positivity) (by finiteness), one_smul] at this alias ⟨MemLp.of_haarAddCircle, MemLp.haarAddCircle⟩ := memLp_haarAddCircle_iff end MeasureTheory open AddCircle section Monomials /-- The family of exponential monomials `fun x => exp (2 π i n x / T)`, parametrized by `n : ℤ` and considered as bundled continuous maps from `ℝ / ℤ • T` to `ℂ`. -/ def fourier (n : ℤ) : C(AddCircle T, ℂ) where toFun x := toCircle (n • x :) continuous_toFun := continuous_induced_dom.comp <| continuous_toCircle.comp <| continuous_zsmul _ @[simp] theorem fourier_apply {n : ℤ} {x : AddCircle T} : fourier n x = toCircle (n • x :) := rfl -- simp normal form is `fourier_coe_apply'` theorem fourier_coe_apply {n : ℤ} {x : ℝ} : fourier n (x : AddCircle T) = Complex.exp (2 * π * Complex.I * n * x / T) := by rw [fourier_apply, ← QuotientAddGroup.mk_zsmul, toCircle, Function.Periodic.lift_coe, Circle.coe_exp, Complex.ofReal_mul, Complex.ofReal_div, Complex.ofReal_mul, zsmul_eq_mul, Complex.ofReal_mul, Complex.ofReal_intCast] norm_num congr 1; ring @[simp] theorem fourier_coe_apply' {n : ℤ} {x : ℝ} : toCircle (n • (x : AddCircle T) :) = Complex.exp (2 * π * Complex.I * n * x / T) := by rw [← fourier_apply]; exact fourier_coe_apply -- simp normal form is `fourier_zero'` theorem fourier_zero {x : AddCircle T} : fourier 0 x = 1 := by simp theorem fourier_zero' : @toCircle T 0 = (1 : ℂ) := by simp -- simp normal form is *also* `fourier_zero'` theorem fourier_eval_zero (n : ℤ) : fourier n (0 : AddCircle T) = 1 := by rw [← QuotientAddGroup.mk_zero, fourier_coe_apply, Complex.ofReal_zero, mul_zero, zero_div, Complex.exp_zero] theorem fourier_one {x : AddCircle T} : fourier 1 x = toCircle x := by rw [fourier_apply, one_zsmul] -- simp normal form is `fourier_neg'` theorem fourier_neg {n : ℤ} {x : AddCircle T} : fourier (-n) x = conj (fourier n x) := by induction x using QuotientAddGroup.induction_on simp_rw [fourier_apply, toCircle] rw [← QuotientAddGroup.mk_zsmul, ← QuotientAddGroup.mk_zsmul] simp_rw [Function.Periodic.lift_coe, ← Circle.coe_inv_eq_conj, ← Circle.exp_neg, neg_smul, mul_neg] @[simp] theorem fourier_neg' {n : ℤ} {x : AddCircle T} : @toCircle T (-(n • x)) = conj (fourier n x) := by rw [← neg_smul, ← fourier_apply]; exact fourier_neg -- simp normal form is `fourier_add'` theorem fourier_add {m n : ℤ} {x : AddCircle T} : fourier (m+n) x = fourier m x * fourier n x := by simp_rw [fourier_apply, add_zsmul, toCircle_add, Circle.coe_mul] @[simp] theorem fourier_add' {m n : ℤ} {x : AddCircle T} : toCircle ((m + n) • x :) = fourier m x * fourier n x := by rw [← fourier_apply]; exact fourier_add theorem fourier_norm [Fact (0 < T)] (n : ℤ) : ‖@fourier T n‖ = 1 := by rw [ContinuousMap.norm_eq_iSup_norm] have : ∀ x : AddCircle T, ‖fourier n x‖ = 1 := fun x => Circle.norm_coe _ simp_rw [this] exact ciSup_const /-- For `n ≠ 0`, a translation by `T / 2 / n` negates the function `fourier n`. -/ theorem fourier_add_half_inv_index {n : ℤ} (hn : n ≠ 0) (hT : 0 < T) (x : AddCircle T) : @fourier T n (x + ↑(T / 2 / n)) = -fourier n x := by rw [fourier_apply, zsmul_add, ← QuotientAddGroup.mk_zsmul, toCircle_add, Metric.unitSphere.coe_mul] have : (@toCircle T (n • (T / 2 / n) : ℝ) : ℂ) = -1 := by rw [zsmul_eq_mul, toCircle, Function.Periodic.lift_coe, Circle.coe_exp] convert Complex.exp_pi_mul_I using 3 field_simp rw [this]; simp /-- The star subalgebra of `C(AddCircle T, ℂ)` generated by `fourier n` for `n ∈ ℤ` . -/ def fourierSubalgebra : StarSubalgebra ℂ C(AddCircle T, ℂ) where toSubalgebra := Algebra.adjoin ℂ (range fourier) star_mem' := by change Algebra.adjoin ℂ (range (fourier (T := T))) ≤ star (Algebra.adjoin ℂ (range (fourier (T := T)))) refine adjoin_le ?_ rintro - ⟨n, rfl⟩ exact subset_adjoin ⟨-n, ext fun _ => fourier_neg⟩ /-- The star subalgebra of `C(AddCircle T, ℂ)` generated by `fourier n` for `n ∈ ℤ` is in fact the linear span of these functions. -/ theorem fourierSubalgebra_coe : Subalgebra.toSubmodule (@fourierSubalgebra T).toSubalgebra = span ℂ (range (@fourier T)) := by apply adjoin_eq_span_of_subset refine Subset.trans ?_ Submodule.subset_span intro x hx refine Submonoid.closure_induction (fun _ => id) ⟨0, ?_⟩ ?_ hx · ext1 z; exact fourier_zero · rintro - - - - ⟨m, rfl⟩ ⟨n, rfl⟩ refine ⟨m + n, ?_⟩ ext1 z exact fourier_add /- a post-port refactor made `fourierSubalgebra` into a `StarSubalgebra`, and eliminated `conjInvariantSubalgebra` entirely, making this lemma irrelevant. -/ variable [hT : Fact (0 < T)] /-- The subalgebra of `C(AddCircle T, ℂ)` generated by `fourier n` for `n ∈ ℤ` separates points. -/ theorem fourierSubalgebra_separatesPoints : (@fourierSubalgebra T).SeparatesPoints := by intro x y hxy refine ⟨_, ⟨fourier 1, subset_adjoin ⟨1, rfl⟩, rfl⟩, ?_⟩ dsimp only; rw [fourier_one, fourier_one] contrapose! hxy rw [Subtype.coe_inj] at hxy exact injective_toCircle hT.elim.ne' hxy /-- The subalgebra of `C(AddCircle T, ℂ)` generated by `fourier n` for `n ∈ ℤ` is dense. -/ theorem fourierSubalgebra_closure_eq_top : (@fourierSubalgebra T).topologicalClosure = ⊤ := ContinuousMap.starSubalgebra_topologicalClosure_eq_top_of_separatesPoints fourierSubalgebra fourierSubalgebra_separatesPoints /-- The linear span of the monomials `fourier n` is dense in `C(AddCircle T, ℂ)`. -/ theorem span_fourier_closure_eq_top : (span ℂ (range <| @fourier T)).topologicalClosure = ⊤ := by rw [← fourierSubalgebra_coe] exact congr_arg (Subalgebra.toSubmodule <| StarSubalgebra.toSubalgebra ·) fourierSubalgebra_closure_eq_top /-- The family of monomials `fourier n`, parametrized by `n : ℤ` and considered as elements of the `Lp` space of functions `AddCircle T → ℂ`. -/ abbrev fourierLp (p : ℝ≥0∞) [Fact (1 ≤ p)] (n : ℤ) : Lp ℂ p (@haarAddCircle T hT) := toLp (E := ℂ) p haarAddCircle ℂ (fourier n) theorem coeFn_fourierLp (p : ℝ≥0∞) [Fact (1 ≤ p)] (n : ℤ) : @fourierLp T hT p _ n =ᵐ[haarAddCircle] fourier n := coeFn_toLp haarAddCircle (fourier n) /-- For each `1 ≤ p < ∞`, the linear span of the monomials `fourier n` is dense in `Lp ℂ p haarAddCircle`. -/ theorem span_fourierLp_closure_eq_top {p : ℝ≥0∞} [Fact (1 ≤ p)] (hp : p ≠ ∞) : (span ℂ (range (@fourierLp T _ p _))).topologicalClosure = ⊤ := by convert (ContinuousMap.toLp_denseRange ℂ (@haarAddCircle T hT) ℂ hp).topologicalClosure_map_submodule span_fourier_closure_eq_top rw [map_span] unfold fourierLp rw [range_comp'] simp only [ContinuousLinearMap.coe_coe] /-- The monomials `fourier n` are an orthonormal set with respect to normalised Haar measure. -/ theorem orthonormal_fourier : Orthonormal ℂ (@fourierLp T _ 2 _) := by rw [orthonormal_iff_ite] intro i j rw [ContinuousMap.inner_toLp (@haarAddCircle T hT) (fourier i) (fourier j)] simp_rw [← fourier_neg, ← fourier_add] split_ifs with h · simp_rw [h, add_neg_cancel] have : ⇑(@fourier T 0) = (fun _ => 1 : AddCircle T → ℂ) := by ext1; exact fourier_zero rw [this, integral_const, measureReal_univ_eq_one, Complex.real_smul, Complex.ofReal_one, mul_one] have hij : j + -i ≠ 0 := by exact sub_ne_zero.mpr (Ne.symm h) convert integral_eq_zero_of_add_right_eq_neg (μ := haarAddCircle) (fourier_add_half_inv_index hij hT.elim) end Monomials section ScopeHT -- everything from here on needs `0 < T` variable [hT : Fact (0 < T)] section fourierCoeff variable {E : Type} [NormedAddCommGroup E] [NormedSpace ℂ E] /-- The `n`-th Fourier coefficient of a function `AddCircle T → E`, for `E` a complete normed `ℂ`-vector space, defined as the integral over `AddCircle T` of `fourier (-n) t • f t`. -/ def fourierCoeff (f : AddCircle T → E) (n : ℤ) : E := ∫ t : AddCircle T, fourier (-n) t • f t ∂haarAddCircle /-- The Fourier coefficients of a function on `AddCircle T` can be computed as an integral over `[a, a + T]`, for any real `a`. -/ theorem fourierCoeff_eq_intervalIntegral (f : AddCircle T → E) (n : ℤ) (a : ℝ) : fourierCoeff f n = (1 / T) • ∫ x in a..a + T, @fourier T (-n) x • f x := by have : ∀ x : ℝ, @fourier T (-n) x • f x = (fun z : AddCircle T => @fourier T (-n) z • f z) x := by intro x; rfl simp_rw +singlePass [this] rw [fourierCoeff, AddCircle.intervalIntegral_preimage T a (fun z => _ • _), volume_eq_smul_haarAddCircle, integral_smul_measure, ENNReal.toReal_ofReal hT.out.le, ← smul_assoc, smul_eq_mul, one_div_mul_cancel hT.out.ne', one_smul] theorem fourierCoeff.const_smul (f : AddCircle T → E) (c : ℂ) (n : ℤ) : fourierCoeff (c • f :) n = c • fourierCoeff f n := by simp_rw [fourierCoeff, Pi.smul_apply, ← smul_assoc, smul_eq_mul, mul_comm, ← smul_eq_mul, smul_assoc, integral_smul] theorem fourierCoeff.const_mul (f : AddCircle T → ℂ) (c : ℂ) (n : ℤ) : fourierCoeff (fun x => c * f x) n = c * fourierCoeff f n := fourierCoeff.const_smul f c n lemma fourierCoeff_congr_ae {f g : AddCircle T → E} (h : f =ᵐ[haarAddCircle] g) : fourierCoeff f = fourierCoeff g := funext fun _ ↦ integral_congr_ae <| .smul (.refl _ _) h /-- For a function on `ℝ`, the Fourier coefficients of `f` on `[a, b]` are defined as the Fourier coefficients of the unique periodic function agreeing with `f` on `Ioc a b`. -/ def fourierCoeffOn {a b : ℝ} (hab : a < b) (f : ℝ → E) (n : ℤ) : E := haveI := Fact.mk (by linarith : 0 < b - a) fourierCoeff (AddCircle.liftIoc (b - a) a f) n theorem fourierCoeffOn_eq_integral {a b : ℝ} (f : ℝ → E) (n : ℤ) (hab : a < b) : fourierCoeffOn hab f n = (1 / (b - a)) • ∫ x in a..b, fourier (-n) (x : AddCircle (b - a)) • f x := by haveI := Fact.mk (by linarith : 0 < b - a) rw [fourierCoeffOn, fourierCoeff_eq_intervalIntegral _ _ a, add_sub, add_sub_cancel_left] congr 1 simp_rw [intervalIntegral.integral_of_le hab.le] refine setIntegral_congr_fun measurableSet_Ioc fun x hx => ?_ rw [liftIoc_coe_apply] rwa [add_sub, add_sub_cancel_left] theorem fourierCoeffOn.const_smul {a b : ℝ} (f : ℝ → E) (c : ℂ) (n : ℤ) (hab : a < b) : fourierCoeffOn hab (c • f) n = c • fourierCoeffOn hab f n := by haveI := Fact.mk (by linarith : 0 < b - a) apply fourierCoeff.const_smul theorem fourierCoeffOn.const_mul {a b : ℝ} (f : ℝ → ℂ) (c : ℂ) (n : ℤ) (hab : a < b) : fourierCoeffOn hab (fun x => c * f x) n = c * fourierCoeffOn hab f n := fourierCoeffOn.const_smul _ _ _ _ lemma fourierCoeffOn_congr_ae {a b : ℝ} (hab : a < b) {f g : ℝ → E} (h : f =ᵐ[volume.restrict (Ioc a b)] g) : fourierCoeffOn hab f = fourierCoeffOn hab g := by ext n rw [fourierCoeffOn_eq_integral, fourierCoeffOn_eq_integral] congr! 1 apply intervalIntegral.integral_congr_ae_restrict simp only [uIoc_of_le hab.le] filter_upwards [h] with x hx rw [hx] theorem fourierCoeff_liftIoc_eq {a : ℝ} (f : ℝ → ℂ) (n : ℤ) : fourierCoeff (AddCircle.liftIoc T a f) n = fourierCoeffOn (lt_add_of_pos_right a hT.out) f n := by rw [fourierCoeffOn_eq_integral, fourierCoeff_eq_intervalIntegral, add_sub_cancel_left a T] · congr 1 refine intervalIntegral.integral_congr_ae (ae_of_all _ fun x hx => ?_) rw [liftIoc_coe_apply] rwa [uIoc_of_le (lt_add_of_pos_right a hT.out).le] at hx theorem fourierCoeff_liftIco_eq {a : ℝ} (f : ℝ → ℂ) (n : ℤ) : fourierCoeff (AddCircle.liftIco T a f) n = fourierCoeffOn (lt_add_of_pos_right a hT.out) f n := by rw [fourierCoeffOn_eq_integral, fourierCoeff_eq_intervalIntegral _ _ a, add_sub_cancel_left a T] congr 1 simp_rw [intervalIntegral.integral_of_le (lt_add_of_pos_right a hT.out).le] iterate 2 rw [integral_Ioc_eq_integral_Ioo] refine setIntegral_congr_fun measurableSet_Ioo fun x hx => ?_ rw [liftIco_coe_apply (Ioo_subset_Ico_self hx)] end fourierCoeff section FourierL2 /-- We define `fourierBasis` to be a `ℤ`-indexed Hilbert basis for `Lp ℂ 2 haarAddCircle`, which by definition is an isometric isomorphism from `Lp ℂ 2 haarAddCircle` to `ℓ²(ℤ, ℂ)`. -/ def fourierBasis : HilbertBasis ℤ ℂ (Lp ℂ 2 <| @haarAddCircle T hT) := HilbertBasis.mk orthonormal_fourier (span_fourierLp_closure_eq_top (by simp)).ge /-- The elements of the Hilbert basis `fourierBasis` are the functions `fourierLp 2`, i.e. the monomials `fourier n` on the circle considered as elements of `L²`. -/ @[simp] theorem coe_fourierBasis : ⇑(@fourierBasis T hT) = @fourierLp T hT 2 _ := HilbertBasis.coe_mk _ _ /-- Under the isometric isomorphism `fourierBasis` from `Lp ℂ 2 haarAddCircle` to `ℓ²(ℤ, ℂ)`, the `i`-th coefficient is `fourierCoeff f i`, i.e., the integral over `AddCircle T` of `fun t => fourier (-i) t * f t` with respect to the Haar measure of total mass 1. -/ theorem fourierBasis_repr (f : Lp ℂ 2 <| @haarAddCircle T hT) (i : ℤ) : fourierBasis.repr f i = fourierCoeff f i := by trans ∫ t : AddCircle T, conj ((@fourierLp T hT 2 _ i : AddCircle T → ℂ) t) * f t ∂haarAddCircle · rw [fourierBasis.repr_apply_apply f i, MeasureTheory.L2.inner_def, coe_fourierBasis] simp only [RCLike.inner_apply'] · apply integral_congr_ae filter_upwards [coeFn_fourierLp 2 i] with _ ht rw [ht, ← fourier_neg, smul_eq_mul] /-- The Fourier series of an `L2` function `f` sums to `f`, in the `L²` space of `AddCircle T`. -/ theorem hasSum_fourier_series_L2 (f : Lp ℂ 2 <| @haarAddCircle T hT) : HasSum (fun i => fourierCoeff f i • fourierLp 2 i) f := by simp_rw [← fourierBasis_repr]; rw [← coe_fourierBasis] exact HilbertBasis.hasSum_repr fourierBasis f /-- **Parseval's identity**: for an `L²` function `f` on `AddCircle T`, the sum of the squared norms of the Fourier coefficients equals the `L²` norm of `f`. -/ theorem hasSum_sq_fourierCoeff (f : Lp ℂ 2 <| @haarAddCircle T hT) : HasSum (fun i => ‖fourierCoeff f i‖ ^ 2) (∫ t : AddCircle T, ‖f t‖ ^ 2 ∂haarAddCircle) := by simp_rw [← fourierBasis_repr] have H₁ : HasSum (fun i => ‖fourierBasis.repr f i‖ ^ 2) (‖fourierBasis.repr f‖ ^ 2) := by apply_mod_cast lp.hasSum_norm ?_ (fourierBasis.repr f) simp have H₂ : ‖fourierBasis.repr f‖ ^ 2 = ‖f‖ ^ 2 := by simp have H₃ := congr_arg RCLike.re (@L2.inner_def (AddCircle T) ℂ ℂ _ _ _ _ _ f f) rw [← integral_re] at H₃ · simp only [← norm_sq_eq_re_inner] at H₃ rwa [H₂, H₃] at H₁ · exact L2.integrable_inner f f theorem tsum_sq_fourierCoeff (f : Lp ℂ 2 <| @haarAddCircle T hT) : ∑' i : ℤ, ‖fourierCoeff f i‖ ^ 2 = ∫ t : AddCircle T, ‖f t‖ ^ 2 ∂haarAddCircle := (hasSum_sq_fourierCoeff _).tsum_eq /-- **Parseval's identity**: for a function `f` which is square integrable on (a,b], the sum of the squared norms of the Fourier coefficients equals the `L²` norm of `f`. -/ theorem hasSum_sq_fourierCoeffOn {a b : ℝ} {f : ℝ → ℂ} (hab : a < b) (hL2 : MemLp f 2 (volume.restrict (Ioc a b))) : HasSum (fun i => ‖fourierCoeffOn hab f i‖ ^ 2) ((b - a)⁻¹ • ∫ x in a..b, ‖f x‖ ^ 2) := by haveI := Fact.mk (by linarith : 0 < b - a) rw [← add_sub_cancel a b] at hL2 have h := hL2.memLp_liftIoc.haarAddCircle convert hasSum_sq_fourierCoeff h.toLp using 1 · simp [fourierCoeff_congr_ae h.coeFn_toLp, fourierCoeff_liftIoc_eq] · nth_rw 2 [← add_sub_cancel a b] rw [← AddCircle.integral_liftIoc_eq_intervalIntegral, ← Function.comp_def (f := (‖·‖ ^ 2))] simp only [liftIoc_comp_apply, ← AddCircle.integral_haarAddCircle] apply integral_congr_ae filter_upwards [h.coeFn_toLp] with x hx simp [hx] theorem tsum_sq_fourierCoeffOn {a b : ℝ} {f : ℝ → ℂ} (hab : a < b) (hL2 : MemLp f 2 (volume.restrict (Ioc a b))) : ∑' (i : ℤ), ‖fourierCoeffOn hab f i‖ ^ 2 = (b - a)⁻¹ • ∫ x in a..b, ‖f x‖ ^ 2 := (hasSum_sq_fourierCoeffOn _ hL2).tsum_eq end FourierL2 section Convergence variable (f : C(AddCircle T, ℂ)) theorem fourierCoeff_toLp (n : ℤ) : fourierCoeff (toLp (E := ℂ) 2 haarAddCircle ℂ f) n = fourierCoeff f n := integral_congr_ae (Filter.EventuallyEq.mul (Filter.Eventually.of_forall (by tauto)) (ContinuousMap.coeFn_toAEEqFun haarAddCircle f)) variable {f} /-- If the sequence of Fourier coefficients of `f` is summable, then the Fourier series converges uniformly to `f`. -/ theorem hasSum_fourier_series_of_summable (h : Summable (fourierCoeff f)) : HasSum (fun i => fourierCoeff f i • fourier i) f := by have sum_L2 := hasSum_fourier_series_L2 (toLp (E := ℂ) 2 haarAddCircle ℂ f) simp_rw [fourierCoeff_toLp] at sum_L2 refine ContinuousMap.hasSum_of_hasSum_Lp (.of_norm ?_) sum_L2 simp_rw [norm_smul, fourier_norm, mul_one] exact h.norm /-- If the sequence of Fourier coefficients of `f` is summable, then the Fourier series of `f` converges everywhere pointwise to `f`. -/ theorem has_pointwise_sum_fourier_series_of_summable (h : Summable (fourierCoeff f)) (x : AddCircle T) : HasSum (fun i => fourierCoeff f i • fourier i x) (f x) := by convert (ContinuousMap.evalCLM ℂ x).hasSum (hasSum_fourier_series_of_summable h) end Convergence end ScopeHT section deriv open Complex intervalIntegral open scoped Interval variable (T) theorem hasDerivAt_fourier (n : ℤ) (x : ℝ) : HasDerivAt (fun y : ℝ => fourier n (y : AddCircle T)) (2 * π * I * n / T * fourier n (x : AddCircle T)) x := by simp_rw [fourier_coe_apply] refine (?_ : HasDerivAt (fun y => exp (2 * π * I * n * y / T)) _ _).comp_ofReal rw [(fun α β => by ring : ∀ α β : ℂ, α * exp β = exp β * α)] refine (hasDerivAt_exp _).comp (x : ℂ) ?_ convert hasDerivAt_mul_const (2 * ↑π * I * ↑n / T) using 1 ext1 y; ring theorem hasDerivAt_fourier_neg (n : ℤ) (x : ℝ) : HasDerivAt (fun y : ℝ => fourier (-n) (y : AddCircle T)) (-2 * π * I * n / T * fourier (-n) (x : AddCircle T)) x := by simpa using hasDerivAt_fourier T (-n) x variable {T} theorem has_antideriv_at_fourier_neg (hT : Fact (0 < T)) {n : ℤ} (hn : n ≠ 0) (x : ℝ) : HasDerivAt (fun y : ℝ => (T : ℂ) / (-2 * π * I * n) * fourier (-n) (y : AddCircle T)) (fourier (-n) (x : AddCircle T)) x := by convert (hasDerivAt_fourier_neg T n x).div_const (-2 * π * I * n / T) using 1 · ext1 y; rw [div_div_eq_mul_div]; ring · simp [mul_div_cancel_left₀, hn, (Fact.out : 0 < T).ne', Real.pi_pos.ne'] /-- Express Fourier coefficients of `f` on an interval in terms of those of its derivative. -/ theorem fourierCoeffOn_of_hasDeriv_right {a b : ℝ} (hab : a < b) {f f' : ℝ → ℂ} {n : ℤ} (hn : n ≠ 0) (hf : ContinuousOn f [[a, b]]) (hff' : ∀ x, x ∈ Ioo (min a b) (max a b) → HasDerivWithinAt f (f' x) (Ioi x) x) (hf' : IntervalIntegrable f' volume a b) : fourierCoeffOn hab f n = 1 / (-2 * π * I * n) * (fourier (-n) (a : AddCircle (b - a)) * (f b - f a) - (b - a) * fourierCoeffOn hab f' n) := by rw [← ofReal_sub] have hT : Fact (0 < b - a) := ⟨by linarith⟩ simp_rw [fourierCoeffOn_eq_integral, smul_eq_mul, real_smul, ofReal_div, ofReal_one] conv => pattern (occs := 1 2 3) fourier _ _ * _ <;> (rw [mul_comm]) rw [integral_mul_deriv_eq_deriv_mul_of_hasDeriv_right hf (fun x _ ↦ has_antideriv_at_fourier_neg hT hn x |>.continuousAt |>.continuousWithinAt) hff' (fun x _ ↦ has_antideriv_at_fourier_neg hT hn x |>.hasDerivWithinAt) hf' (((map_continuous (fourier (-n))).comp (AddCircle.continuous_mk' _)).intervalIntegrable _ _)] have : ∀ u v w : ℂ, u * ((b - a : ℝ) / v * w) = (b - a : ℝ) / v * (u * w) := by intros; ring conv in intervalIntegral _ _ _ _ => congr; ext; rw [this] rw [(by ring : ((b - a : ℝ) : ℂ) / (-2 * π * I * n) = ((b - a : ℝ) : ℂ) * (1 / (-2 * π * I * n)))] have s2 : (b : AddCircle (b - a)) = (a : AddCircle (b - a)) := by simpa using coe_add_period (b - a) a rw [s2, intervalIntegral.integral_const_mul, ← sub_mul, mul_sub, mul_sub] congr 1 · conv_lhs => rw [mul_comm, mul_div, mul_one] rw [div_eq_iff (ofReal_ne_zero.mpr hT.out.ne')] ring · ring /-- Express Fourier coefficients of `f` on an interval in terms of those of its derivative. -/ theorem fourierCoeffOn_of_hasDerivAt_Ioo {a b : ℝ} (hab : a < b) {f f' : ℝ → ℂ} {n : ℤ} (hn : n ≠ 0) (hf : ContinuousOn f [[a, b]]) (hff' : ∀ x, x ∈ Ioo (min a b) (max a b) → HasDerivAt f (f' x) x) (hf' : IntervalIntegrable f' volume a b) : fourierCoeffOn hab f n = 1 / (-2 * π * I * n) * (fourier (-n) (a : AddCircle (b - a)) * (f b - f a) - (b - a) * fourierCoeffOn hab f' n) := fourierCoeffOn_of_hasDeriv_right hab hn hf (fun x hx ↦ hff' x hx |>.hasDerivWithinAt) hf' /-- Express Fourier coefficients of `f` on an interval in terms of those of its derivative. -/ theorem fourierCoeffOn_of_hasDerivAt {a b : ℝ} (hab : a < b) {f f' : ℝ → ℂ} {n : ℤ} (hn : n ≠ 0) (hf : ∀ x, x ∈ [[a, b]] → HasDerivAt f (f' x) x) (hf' : IntervalIntegrable f' volume a b) : fourierCoeffOn hab f n = 1 / (-2 * π * I * n) * (fourier (-n) (a : AddCircle (b - a)) * (f b - f a) - (b - a) * fourierCoeffOn hab f' n) := fourierCoeffOn_of_hasDerivAt_Ioo hab hn (fun x hx ↦ hf x hx |>.continuousAt.continuousWithinAt) (fun x hx ↦ hf x <| mem_Icc_of_Ioo hx) hf' end deriv
.lake/packages/mathlib/Mathlib/Analysis/Fourier/FourierTransformDeriv.lean
import Mathlib.Analysis.Calculus.ParametricIntegral import Mathlib.Analysis.Calculus.ContDiff.CPolynomial import Mathlib.Analysis.Fourier.AddCircle import Mathlib.Analysis.Fourier.FourierTransform import Mathlib.Analysis.Calculus.FDeriv.Analytic import Mathlib.Analysis.Calculus.LineDeriv.IntegrationByParts import Mathlib.Analysis.Calculus.ContDiff.Bounds /-! # Derivatives of the Fourier transform In this file we compute the Fréchet derivative of the Fourier transform of `f`, where `f` is a function such that both `f` and `v ↦ ‖v‖ * ‖f v‖` are integrable. Here the Fourier transform is understood as an operator `(V → E) → (W → E)`, where `V` and `W` are normed `ℝ`-vector spaces and the Fourier transform is taken with respect to a continuous `ℝ`-bilinear pairing `L : V × W → ℝ` and a given reference measure `μ`. We also investigate higher derivatives: Assuming that `‖v‖^n * ‖f v‖` is integrable, we show that the Fourier transform of `f` is `C^n`. We also study in a parallel way the Fourier transform of the derivative, which is obtained by tensoring the Fourier transform of the original function with the bilinear form. We also get results for iterated derivatives. A consequence of these results is that, if a function is smooth and all its derivatives are integrable when multiplied by `‖v‖^k`, then the same goes for its Fourier transform, with explicit bounds. We give specialized versions of these results on inner product spaces (where `L` is the scalar product) and on the real line, where we express the one-dimensional derivative in more concrete terms, as the Fourier transform of `-2πI x * f x` (or `(-2πI x)^n * f x` for higher derivatives). ## Main definitions and results We introduce two convenience definitions: * `VectorFourier.fourierSMulRight L f`: given `f : V → E` and `L` a bilinear pairing between `V` and `W`, then this is the function `fun v ↦ -(2 * π * I) (L v ⬝) • f v`, from `V` to `Hom (W, E)`. This is essentially `ContinuousLinearMap.smulRight`, up to the factor `- 2πI` designed to make sure that the Fourier integral of `fourierSMulRight L f` is the derivative of the Fourier integral of `f`. * `VectorFourier.fourierPowSMulRight` is the higher-order analogue for higher derivatives: `fourierPowSMulRight L f v n` is informally `(-(2 * π * I))^n (L v ⬝)^n • f v`, in the space of continuous multilinear maps `W [×n]→L[ℝ] E`. With these definitions, the statements read as follows, first in a general context (arbitrary `L` and `μ`): * `VectorFourier.hasFDerivAt_fourierIntegral`: the Fourier integral of `f` is differentiable, with derivative the Fourier integral of `fourierSMulRight L f`. * `VectorFourier.differentiable_fourierIntegral`: the Fourier integral of `f` is differentiable. * `VectorFourier.fderiv_fourierIntegral`: formula for the derivative of the Fourier integral of `f`. * `VectorFourier.fourierIntegral_fderiv`: formula for the Fourier integral of the derivative of `f`. * `VectorFourier.hasFTaylorSeriesUpTo_fourierIntegral`: under suitable integrability conditions, the Fourier integral of `f` has an explicit Taylor series up to order `N`, given by the Fourier integrals of `fun v ↦ fourierPowSMulRight L f v n`. * `VectorFourier.contDiff_fourierIntegral`: under suitable integrability conditions, the Fourier integral of `f` is `C^n`. * `VectorFourier.iteratedFDeriv_fourierIntegral`: under suitable integrability conditions, explicit formula for the `n`-th derivative of the Fourier integral of `f`, as the Fourier integral of `fun v ↦ fourierPowSMulRight L f v n`. * `VectorFourier.pow_mul_norm_iteratedFDeriv_fourierIntegral_le`: explicit bounds for the `n`-th derivative of the Fourier integral, multiplied by a power function, in terms of corresponding integrals for the original function. These statements are then specialized to the case of the usual Fourier transform on finite-dimensional inner product spaces with their canonical Lebesgue measure (covering in particular the case of the real line), replacing the namespace `VectorFourier` by the namespace `Real` in the above statements. We also give specialized versions of the one-dimensional real derivative (and iterated derivative) in `Real.deriv_fourierIntegral` and `Real.iteratedDeriv_fourierIntegral`. -/ noncomputable section open Real Complex MeasureTheory Filter TopologicalSpace open scoped FourierTransform Topology ContDiff -- without this local instance, Lean tries first the instance -- `secondCountableTopologyEither_of_right` (whose priority is 100) and takes a very long time to -- fail. Since we only use the left instance in this file, we make sure it is tried first. attribute [local instance 101] secondCountableTopologyEither_of_left namespace Real lemma hasDerivAt_fourierChar (x : ℝ) : HasDerivAt (𝐞 · : ℝ → ℂ) (2 * π * I * 𝐞 x) x := by have h1 (y : ℝ) : 𝐞 y = fourier 1 (y : UnitAddCircle) := by rw [fourierChar_apply, fourier_coe_apply] push_cast ring_nf simpa only [h1, Int.cast_one, ofReal_one, div_one, mul_one] using hasDerivAt_fourier 1 1 x lemma differentiable_fourierChar : Differentiable ℝ (𝐞 · : ℝ → ℂ) := fun x ↦ (Real.hasDerivAt_fourierChar x).differentiableAt lemma deriv_fourierChar (x : ℝ) : deriv (𝐞 · : ℝ → ℂ) x = 2 * π * I * 𝐞 x := (Real.hasDerivAt_fourierChar x).deriv variable {V W : Type*} [NormedAddCommGroup V] [NormedSpace ℝ V] [NormedAddCommGroup W] [NormedSpace ℝ W] (L : V →L[ℝ] W →L[ℝ] ℝ) lemma hasFDerivAt_fourierChar_neg_bilinear_right (v : V) (w : W) : HasFDerivAt (fun w ↦ (𝐞 (-L v w) : ℂ)) ((-2 * π * I * 𝐞 (-L v w)) • (ofRealCLM ∘L (L v))) w := by have ha : HasFDerivAt (fun w' : W ↦ L v w') (L v) w := ContinuousLinearMap.hasFDerivAt (L v) convert (hasDerivAt_fourierChar (-L v w)).hasFDerivAt.comp w ha.neg using 1 ext y simp only [neg_mul, ContinuousLinearMap.coe_smul', ContinuousLinearMap.coe_comp', Pi.smul_apply, Function.comp_apply, ofRealCLM_apply, smul_eq_mul, ContinuousLinearMap.comp_neg, ContinuousLinearMap.neg_apply, ContinuousLinearMap.smulRight_apply, ContinuousLinearMap.one_apply, real_smul, neg_inj] ring lemma fderiv_fourierChar_neg_bilinear_right_apply (v : V) (w y : W) : fderiv ℝ (fun w ↦ (𝐞 (-L v w) : ℂ)) w y = -2 * π * I * L v y * 𝐞 (-L v w) := by simp only [(hasFDerivAt_fourierChar_neg_bilinear_right L v w).fderiv, neg_mul, ContinuousLinearMap.coe_smul', ContinuousLinearMap.coe_comp', Pi.smul_apply, Function.comp_apply, ofRealCLM_apply, smul_eq_mul, neg_inj] ring lemma differentiable_fourierChar_neg_bilinear_right (v : V) : Differentiable ℝ (fun w ↦ (𝐞 (-L v w) : ℂ)) := fun w ↦ (hasFDerivAt_fourierChar_neg_bilinear_right L v w).differentiableAt lemma hasFDerivAt_fourierChar_neg_bilinear_left (v : V) (w : W) : HasFDerivAt (fun v ↦ (𝐞 (-L v w) : ℂ)) ((-2 * π * I * 𝐞 (-L v w)) • (ofRealCLM ∘L (L.flip w))) v := hasFDerivAt_fourierChar_neg_bilinear_right L.flip w v lemma fderiv_fourierChar_neg_bilinear_left_apply (v y : V) (w : W) : fderiv ℝ (fun v ↦ (𝐞 (-L v w) : ℂ)) v y = -2 * π * I * L y w * 𝐞 (-L v w) := by simp only [(hasFDerivAt_fourierChar_neg_bilinear_left L v w).fderiv, neg_mul, ContinuousLinearMap.coe_smul', ContinuousLinearMap.coe_comp', Pi.smul_apply, Function.comp_apply, ContinuousLinearMap.flip_apply, ofRealCLM_apply, smul_eq_mul, neg_inj] ring lemma differentiable_fourierChar_neg_bilinear_left (w : W) : Differentiable ℝ (fun v ↦ (𝐞 (-L v w) : ℂ)) := fun v ↦ (hasFDerivAt_fourierChar_neg_bilinear_left L v w).differentiableAt end Real variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℂ E] namespace VectorFourier variable {V W : Type*} [NormedAddCommGroup V] [NormedSpace ℝ V] [NormedAddCommGroup W] [NormedSpace ℝ W] (L : V →L[ℝ] W →L[ℝ] ℝ) (f : V → E) /-- Send a function `f : V → E` to the function `f : V → Hom (W, E)` given by `v ↦ (w ↦ -2 * π * I * L (v, w) • f v)`. This is designed so that the Fourier transform of `fourierSMulRight L f` is the derivative of the Fourier transform of `f`. -/ def fourierSMulRight (v : V) : (W →L[ℝ] E) := -(2 * π * I) • (L v).smulRight (f v) @[simp] lemma fourierSMulRight_apply (v : V) (w : W) : fourierSMulRight L f v w = -(2 * π * I) • L v w • f v := rfl /-- The `w`-derivative of the Fourier transform integrand. -/ lemma hasFDerivAt_fourierChar_smul (v : V) (w : W) : HasFDerivAt (fun w' ↦ 𝐞 (-L v w') • f v) (𝐞 (-L v w) • fourierSMulRight L f v) w := by have ha : HasFDerivAt (fun w' : W ↦ L v w') (L v) w := ContinuousLinearMap.hasFDerivAt (L v) convert ((hasDerivAt_fourierChar (-L v w)).hasFDerivAt.comp w ha.neg).smul_const (f v) ext w' : 1 simp_rw [fourierSMulRight, ContinuousLinearMap.smul_apply, ContinuousLinearMap.smulRight_apply] rw [ContinuousLinearMap.comp_apply, ContinuousLinearMap.neg_apply, ContinuousLinearMap.smulRight_apply, ContinuousLinearMap.one_apply, ← smul_assoc, smul_comm, ← smul_assoc, real_smul, real_smul, Submonoid.smul_def, smul_eq_mul] push_cast ring_nf lemma norm_fourierSMulRight (L : V →L[ℝ] W →L[ℝ] ℝ) (f : V → E) (v : V) : ‖fourierSMulRight L f v‖ = (2 * π) * ‖L v‖ * ‖f v‖ := by rw [fourierSMulRight, norm_smul _ (ContinuousLinearMap.smulRight (L v) (f v)), norm_neg, norm_mul, norm_mul, norm_I, mul_one, Complex.norm_of_nonneg pi_pos.le, Complex.norm_two, ContinuousLinearMap.norm_smulRight_apply, ← mul_assoc] lemma norm_fourierSMulRight_le (L : V →L[ℝ] W →L[ℝ] ℝ) (f : V → E) (v : V) : ‖fourierSMulRight L f v‖ ≤ 2 * π * ‖L‖ * ‖v‖ * ‖f v‖ := calc ‖fourierSMulRight L f v‖ = (2 * π) * ‖L v‖ * ‖f v‖ := norm_fourierSMulRight _ _ _ _ ≤ (2 * π) * (‖L‖ * ‖v‖) * ‖f v‖ := by gcongr; exact L.le_opNorm _ _ = 2 * π * ‖L‖ * ‖v‖ * ‖f v‖ := by ring lemma _root_.MeasureTheory.AEStronglyMeasurable.fourierSMulRight [SecondCountableTopologyEither V (W →L[ℝ] ℝ)] [MeasurableSpace V] [BorelSpace V] {L : V →L[ℝ] W →L[ℝ] ℝ} {f : V → E} {μ : Measure V} (hf : AEStronglyMeasurable f μ) : AEStronglyMeasurable (fun v ↦ fourierSMulRight L f v) μ := by apply AEStronglyMeasurable.const_smul' have aux0 : Continuous fun p : (W →L[ℝ] ℝ) × E ↦ p.1.smulRight p.2 := (ContinuousLinearMap.smulRightL ℝ W E).continuous₂ have aux1 : AEStronglyMeasurable (fun v ↦ (L v, f v)) μ := L.continuous.aestronglyMeasurable.prodMk hf -- Elaboration without the expected type is faster here: exact (aux0.comp_aestronglyMeasurable aux1 :) variable {f} /-- Main theorem of this section: if both `f` and `x ↦ ‖x‖ * ‖f x‖` are integrable, then the Fourier transform of `f` has a Fréchet derivative (everywhere in its domain) and its derivative is the Fourier transform of `smulRight L f`. -/ theorem hasFDerivAt_fourierIntegral [MeasurableSpace V] [BorelSpace V] [SecondCountableTopology V] {μ : Measure V} (hf : Integrable f μ) (hf' : Integrable (fun v : V ↦ ‖v‖ * ‖f v‖) μ) (w : W) : HasFDerivAt (fourierIntegral 𝐞 μ L.toLinearMap₁₂ f) (fourierIntegral 𝐞 μ L.toLinearMap₁₂ (fourierSMulRight L f) w) w := by let F : W → V → E := fun w' v ↦ 𝐞 (-L v w') • f v let F' : W → V → W →L[ℝ] E := fun w' v ↦ 𝐞 (-L v w') • fourierSMulRight L f v let B : V → ℝ := fun v ↦ 2 * π * ‖L‖ * ‖v‖ * ‖f v‖ have h0 (w' : W) : Integrable (F w') μ := (fourierIntegral_convergent_iff continuous_fourierChar (by apply L.continuous₂ : Continuous (fun p : V × W ↦ L.toLinearMap₁₂ p.1 p.2)) w').2 hf have h1 : ∀ᶠ w' in 𝓝 w, AEStronglyMeasurable (F w') μ := Eventually.of_forall (fun w' ↦ (h0 w').aestronglyMeasurable) have h3 : AEStronglyMeasurable (F' w) μ := by refine .smul ?_ hf.1.fourierSMulRight refine (continuous_fourierChar.comp ?_).aestronglyMeasurable fun_prop have h4 : (∀ᵐ v ∂μ, ∀ (w' : W), w' ∈ Metric.ball w 1 → ‖F' w' v‖ ≤ B v) := by filter_upwards with v w' _ rw [Circle.norm_smul _ (fourierSMulRight L f v)] exact norm_fourierSMulRight_le L f v have h5 : Integrable B μ := by simpa only [← mul_assoc] using hf'.const_mul (2 * π * ‖L‖) have h6 : ∀ᵐ v ∂μ, ∀ w', w' ∈ Metric.ball w 1 → HasFDerivAt (fun x ↦ F x v) (F' w' v) w' := ae_of_all _ (fun v w' _ ↦ hasFDerivAt_fourierChar_smul L f v w') exact hasFDerivAt_integral_of_dominated_of_fderiv_le one_pos h1 (h0 w) h3 h4 h5 h6 lemma fderiv_fourierIntegral [MeasurableSpace V] [BorelSpace V] [SecondCountableTopology V] {μ : Measure V} (hf : Integrable f μ) (hf' : Integrable (fun v : V ↦ ‖v‖ * ‖f v‖) μ) : fderiv ℝ (fourierIntegral 𝐞 μ L.toLinearMap₁₂ f) = fourierIntegral 𝐞 μ L.toLinearMap₁₂ (fourierSMulRight L f) := by ext w : 1 exact (hasFDerivAt_fourierIntegral L hf hf' w).fderiv lemma differentiable_fourierIntegral [MeasurableSpace V] [BorelSpace V] [SecondCountableTopology V] {μ : Measure V} (hf : Integrable f μ) (hf' : Integrable (fun v : V ↦ ‖v‖ * ‖f v‖) μ) : Differentiable ℝ (fourierIntegral 𝐞 μ L.toLinearMap₁₂ f) := fun w ↦ (hasFDerivAt_fourierIntegral L hf hf' w).differentiableAt /-- The Fourier integral of the derivative of a function is obtained by multiplying the Fourier integral of the original function by `-L w v`. -/ theorem fourierIntegral_fderiv [MeasurableSpace V] [BorelSpace V] [FiniteDimensional ℝ V] {μ : Measure V} [Measure.IsAddHaarMeasure μ] (hf : Integrable f μ) (h'f : Differentiable ℝ f) (hf' : Integrable (fderiv ℝ f) μ) : fourierIntegral 𝐞 μ L.toLinearMap₁₂ (fderiv ℝ f) = fourierSMulRight (-L.flip) (fourierIntegral 𝐞 μ L.toLinearMap₁₂ f) := by ext w y let g (v : V) : ℂ := 𝐞 (-L v w) /- First rewrite things in a simplified form, without any real change. -/ suffices ∫ x, g x • fderiv ℝ f x y ∂μ = ∫ x, (2 * ↑π * I * L y w * g x) • f x ∂μ by rw [fourierIntegral_continuousLinearMap_apply' hf'] simpa only [fourierIntegral, ContinuousLinearMap.toLinearMap₁₂_apply, fourierSMulRight_apply, ContinuousLinearMap.neg_apply, ContinuousLinearMap.flip_apply, ← integral_smul, neg_smul, smul_neg, ← smul_smul, coe_smul, neg_neg] -- Key step: integrate by parts with respect to `y` to switch the derivative from `f` to `g`. have A x : fderiv ℝ g x y = - 2 * ↑π * I * L y w * g x := fderiv_fourierChar_neg_bilinear_left_apply _ _ _ _ rw [integral_smul_fderiv_eq_neg_fderiv_smul_of_integrable, ← integral_neg] · simp only [A, neg_mul, neg_smul, neg_neg] · have : Integrable (fun x ↦ (-(2 * ↑π * I * ↑((L y) w)) • ((g x : ℂ) • f x))) μ := ((fourierIntegral_convergent_iff' _ _).2 hf).smul _ convert this using 2 with x simp only [A, neg_mul, neg_smul, smul_smul] · exact (fourierIntegral_convergent_iff' _ _).2 (hf'.apply_continuousLinearMap _) · exact (fourierIntegral_convergent_iff' _ _).2 hf · exact differentiable_fourierChar_neg_bilinear_left _ _ · exact h'f /-- The formal multilinear series whose `n`-th term is `(w₁, ..., wₙ) ↦ (-2πI)^n * L v w₁ * ... * L v wₙ • f v`, as a continuous multilinear map in the space `W [×n]→L[ℝ] E`. This is designed so that the Fourier transform of `v ↦ fourierPowSMulRight L f v n` is the `n`-th derivative of the Fourier transform of `f`. -/ def fourierPowSMulRight (f : V → E) (v : V) : FormalMultilinearSeries ℝ W E := fun n ↦ (- (2 * π * I))^n • ((ContinuousMultilinearMap.mkPiRing ℝ (Fin n) (f v)).compContinuousLinearMap (fun _ ↦ L v)) /- Increase the priority to make sure that this lemma is used instead of `FormalMultilinearSeries.apply_eq_prod_smul_coeff` even in dimension 1. -/ @[simp 1100] lemma fourierPowSMulRight_apply {f : V → E} {v : V} {n : ℕ} {m : Fin n → W} : fourierPowSMulRight L f v n m = (- (2 * π * I))^n • (∏ i, L v (m i)) • f v := by simp [fourierPowSMulRight] open ContinuousMultilinearMap /-- Decomposing `fourierPowSMulRight L f v n` as a composition of continuous bilinear and multilinear maps, to deduce easily its continuity and differentiability properties. -/ lemma fourierPowSMulRight_eq_comp {f : V → E} {v : V} {n : ℕ} : fourierPowSMulRight L f v n = (- (2 * π * I))^n • smulRightL ℝ (fun (_ : Fin n) ↦ W) E (compContinuousLinearMapLRight (ContinuousMultilinearMap.mkPiAlgebra ℝ (Fin n) ℝ) (fun _ ↦ L v)) (f v) := rfl @[continuity, fun_prop] lemma _root_.Continuous.fourierPowSMulRight {f : V → E} (hf : Continuous f) (n : ℕ) : Continuous (fun v ↦ fourierPowSMulRight L f v n) := by simp_rw [fourierPowSMulRight_eq_comp] apply Continuous.const_smul apply (smulRightL ℝ (fun (_ : Fin n) ↦ W) E).continuous₂.comp₂ _ hf exact Continuous.comp (map_continuous _) (continuous_pi (fun _ ↦ L.continuous)) lemma _root_.ContDiff.fourierPowSMulRight {f : V → E} {k : WithTop ℕ∞} (hf : ContDiff ℝ k f) (n : ℕ) : ContDiff ℝ k (fun v ↦ fourierPowSMulRight L f v n) := by simp_rw [fourierPowSMulRight_eq_comp] apply ContDiff.const_smul apply (smulRightL ℝ (fun (_ : Fin n) ↦ W) E).isBoundedBilinearMap.contDiff.comp₂ _ hf apply (ContinuousMultilinearMap.contDiff _).comp exact contDiff_pi.2 (fun _ ↦ L.contDiff) lemma norm_fourierPowSMulRight_le (f : V → E) (v : V) (n : ℕ) : ‖fourierPowSMulRight L f v n‖ ≤ (2 * π * ‖L‖) ^ n * ‖v‖ ^ n * ‖f v‖ := by apply ContinuousMultilinearMap.opNorm_le_bound (by positivity) (fun m ↦ ?_) calc ‖fourierPowSMulRight L f v n m‖ = (2 * π) ^ n * ((∏ x : Fin n, |(L v) (m x)|) * ‖f v‖) := by simp [abs_of_nonneg pi_nonneg, norm_smul] _ ≤ (2 * π) ^ n * ((∏ x : Fin n, ‖L‖ * ‖v‖ * ‖m x‖) * ‖f v‖) := by gcongr with i _hi exact L.le_opNorm₂ v (m i) _ = (2 * π * ‖L‖) ^ n * ‖v‖ ^ n * ‖f v‖ * ∏ i : Fin n, ‖m i‖ := by simp [Finset.prod_mul_distrib, mul_pow]; ring /-- The iterated derivative of a function multiplied by `(L v ⬝) ^ n` can be controlled in terms of the iterated derivatives of the initial function. -/ lemma norm_iteratedFDeriv_fourierPowSMulRight {f : V → E} {K : WithTop ℕ∞} {C : ℝ} (hf : ContDiff ℝ K f) {n : ℕ} {k : ℕ} (hk : k ≤ K) {v : V} (hv : ∀ i ≤ k, ∀ j ≤ n, ‖v‖ ^ j * ‖iteratedFDeriv ℝ i f v‖ ≤ C) : ‖iteratedFDeriv ℝ k (fun v ↦ fourierPowSMulRight L f v n) v‖ ≤ (2 * π) ^ n * (2 * n + 2) ^ k * ‖L‖ ^ n * C := by /- We write `fourierPowSMulRight L f v n` as a composition of bilinear and multilinear maps, thanks to `fourierPowSMulRight_eq_comp`, and then we control the iterated derivatives of these thanks to general bounds on derivatives of bilinear and multilinear maps. More precisely, `fourierPowSMulRight L f v n m = (- (2 * π * I))^n • (∏ i, L v (m i)) • f v`. Here, `(- (2 * π * I))^n` contributes `(2π)^n` to the bound. The second product is bilinear, so the iterated derivative is controlled as a weighted sum of those of `v ↦ ∏ i, L v (m i)` and of `f`. The harder part is to control the iterated derivatives of `v ↦ ∏ i, L v (m i)`. For this, one argues that this is multilinear in `v`, to apply general bounds for iterated derivatives of multilinear maps. More precisely, we write it as the composition of a multilinear map `T` (making the product operation) and the tuple of linear maps `v ↦ (L v ⬝, ..., L v ⬝)` -/ simp_rw [fourierPowSMulRight_eq_comp] -- first step: controlling the iterated derivatives of `v ↦ ∏ i, L v (m i)`, written below -- as `v ↦ T (fun _ ↦ L v)`, or `T ∘ (ContinuousLinearMap.pi (fun (_ : Fin n) ↦ L))`. let T : (W →L[ℝ] ℝ) [×n]→L[ℝ] (W [×n]→L[ℝ] ℝ) := compContinuousLinearMapLRight (ContinuousMultilinearMap.mkPiAlgebra ℝ (Fin n) ℝ) have I₁ m : ‖iteratedFDeriv ℝ m T (fun _ ↦ L v)‖ ≤ n.descFactorial m * 1 * (‖L‖ * ‖v‖) ^ (n - m) := by have : ‖T‖ ≤ 1 := by apply (norm_compContinuousLinearMapLRight_le _ _).trans simp only [norm_mkPiAlgebra, le_refl] apply (ContinuousMultilinearMap.norm_iteratedFDeriv_le _ _ _).trans simp only [Fintype.card_fin] gcongr refine (pi_norm_le_iff_of_nonneg (by positivity)).mpr (fun _ ↦ ?_) exact ContinuousLinearMap.le_opNorm _ _ have I₂ m : ‖iteratedFDeriv ℝ m (T ∘ (ContinuousLinearMap.pi (fun (_ : Fin n) ↦ L))) v‖ ≤ (n.descFactorial m * 1 * (‖L‖ * ‖v‖) ^ (n - m)) * ‖L‖ ^ m := by rw [ContinuousLinearMap.iteratedFDeriv_comp_right _ (ContinuousMultilinearMap.contDiff _) _ (mod_cast le_top)] apply (norm_compContinuousLinearMap_le _ _).trans simp only [Finset.prod_const, Finset.card_fin] gcongr · exact I₁ m · exact ContinuousLinearMap.norm_pi_le_of_le (fun _ ↦ le_rfl) (norm_nonneg _) have I₃ m : ‖iteratedFDeriv ℝ m (T ∘ (ContinuousLinearMap.pi (fun (_ : Fin n) ↦ L))) v‖ ≤ n.descFactorial m * ‖L‖ ^ n * ‖v‖ ^ (n - m) := by apply (I₂ m).trans (le_of_eq _) rcases le_or_gt m n with hm | hm · rw [show ‖L‖ ^ n = ‖L‖ ^ (m + (n - m)) by rw [Nat.add_sub_cancel' hm], pow_add] ring · simp only [Nat.descFactorial_eq_zero_iff_lt.mpr hm, CharP.cast_eq_zero, mul_one, zero_mul] -- second step: factor out the `(2 * π) ^ n` factor, and cancel it on both sides. have A : ContDiff ℝ K (fun y ↦ T (fun _ ↦ L y)) := (ContinuousMultilinearMap.contDiff _).comp (contDiff_pi.2 fun _ ↦ L.contDiff) rw [iteratedFDeriv_const_smul_apply' (hf := ((smulRightL ℝ (fun _ ↦ W) E).isBoundedBilinearMap.contDiff.comp₂ (A.of_le hk) (hf.of_le hk)).contDiffAt), norm_smul (β := V [×k]→L[ℝ] (W [×n]→L[ℝ] E))] simp only [mul_assoc, norm_pow, norm_neg, Complex.norm_mul, Complex.norm_ofNat, norm_real, Real.norm_eq_abs, abs_of_nonneg pi_nonneg, norm_I, mul_one, smulRightL_apply, ge_iff_le] gcongr -- third step: argue that the scalar multiplication is bilinear to bound the iterated derivatives -- of `v ↦ (∏ i, L v (m i)) • f v` in terms of those of `v ↦ (∏ i, L v (m i))` and of `f`. -- The former are controlled by the first step, the latter by the assumptions. apply (ContinuousLinearMap.norm_iteratedFDeriv_le_of_bilinear_of_le_one _ A hf _ hk ContinuousMultilinearMap.norm_smulRightL_le).trans calc ∑ i ∈ Finset.range (k + 1), k.choose i * ‖iteratedFDeriv ℝ i (fun (y : V) ↦ T (fun _ ↦ L y)) v‖ * ‖iteratedFDeriv ℝ (k - i) f v‖ ≤ ∑ i ∈ Finset.range (k + 1), k.choose i * (n.descFactorial i * ‖L‖ ^ n * ‖v‖ ^ (n - i)) * ‖iteratedFDeriv ℝ (k - i) f v‖ := by gcongr with i _hi exact I₃ i _ = ∑ i ∈ Finset.range (k + 1), (k.choose i * n.descFactorial i * ‖L‖ ^ n) * (‖v‖ ^ (n - i) * ‖iteratedFDeriv ℝ (k - i) f v‖) := by congr with i ring _ ≤ ∑ i ∈ Finset.range (k + 1), (k.choose i * (n + 1 : ℕ) ^ k * ‖L‖ ^ n) * C := by gcongr with i hi · rw [← Nat.cast_pow, Nat.cast_le] calc n.descFactorial i ≤ n ^ i := Nat.descFactorial_le_pow _ _ _ ≤ (n + 1) ^ i := by gcongr; cutsat _ ≤ (n + 1) ^ k := by gcongr; exacts [le_add_self, Finset.mem_range_succ_iff.mp hi] · exact hv _ (by cutsat) _ (by cutsat) _ = (2 * n + 2) ^ k * (‖L‖^n * C) := by simp only [← Finset.sum_mul, ← Nat.cast_sum, Nat.sum_range_choose, mul_one, ← mul_assoc, Nat.cast_pow, Nat.cast_ofNat, Nat.cast_add, Nat.cast_one, ← mul_pow, mul_add] variable [MeasurableSpace V] [BorelSpace V] {μ : Measure V} section SecondCountableTopology variable [SecondCountableTopology V] lemma _root_.MeasureTheory.AEStronglyMeasurable.fourierPowSMulRight (hf : AEStronglyMeasurable f μ) (n : ℕ) : AEStronglyMeasurable (fun v ↦ fourierPowSMulRight L f v n) μ := by simp_rw [fourierPowSMulRight_eq_comp] apply AEStronglyMeasurable.const_smul' apply (smulRightL ℝ (fun (_ : Fin n) ↦ W) E).continuous₂.comp_aestronglyMeasurable₂ _ hf apply Continuous.aestronglyMeasurable exact Continuous.comp (map_continuous _) (continuous_pi (fun _ ↦ L.continuous)) lemma integrable_fourierPowSMulRight {n : ℕ} (hf : Integrable (fun v ↦ ‖v‖ ^ n * ‖f v‖) μ) (h'f : AEStronglyMeasurable f μ) : Integrable (fun v ↦ fourierPowSMulRight L f v n) μ := by refine (hf.const_mul ((2 * π * ‖L‖) ^ n)).mono' (h'f.fourierPowSMulRight L n) ?_ filter_upwards with v exact (norm_fourierPowSMulRight_le L f v n).trans (le_of_eq (by ring)) lemma hasFTaylorSeriesUpTo_fourierIntegral {N : WithTop ℕ∞} (hf : ∀ (n : ℕ), n ≤ N → Integrable (fun v ↦ ‖v‖ ^ n * ‖f v‖) μ) (h'f : AEStronglyMeasurable f μ) : HasFTaylorSeriesUpTo N (fourierIntegral 𝐞 μ L.toLinearMap₁₂ f) (fun w n ↦ fourierIntegral 𝐞 μ L.toLinearMap₁₂ (fun v ↦ fourierPowSMulRight L f v n) w) := by constructor · intro w rw [curry0_apply, Matrix.zero_empty, fourierIntegral_continuousMultilinearMap_apply' (integrable_fourierPowSMulRight L (hf 0 bot_le) h'f)] simp only [fourierPowSMulRight_apply, pow_zero, Finset.univ_eq_empty, Finset.prod_empty, one_smul] · intro n hn w have I₁ : Integrable (fun v ↦ fourierPowSMulRight L f v n) μ := integrable_fourierPowSMulRight L (hf n hn.le) h'f have I₂ : Integrable (fun v ↦ ‖v‖ * ‖fourierPowSMulRight L f v n‖) μ := by apply ((hf (n + 1) (ENat.add_one_natCast_le_withTop_of_lt hn)).const_mul ((2 * π * ‖L‖) ^ n)).mono' (continuous_norm.aestronglyMeasurable.mul (h'f.fourierPowSMulRight L n).norm) filter_upwards with v simp only [Pi.mul_apply, norm_mul, norm_norm] calc ‖v‖ * ‖fourierPowSMulRight L f v n‖ ≤ ‖v‖ * ((2 * π * ‖L‖) ^ n * ‖v‖ ^ n * ‖f v‖) := by gcongr; apply norm_fourierPowSMulRight_le _ = (2 * π * ‖L‖) ^ n * (‖v‖ ^ (n + 1) * ‖f v‖) := by rw [pow_succ]; ring have I₃ : Integrable (fun v ↦ fourierPowSMulRight L f v (n + 1)) μ := integrable_fourierPowSMulRight L (hf (n + 1) (ENat.add_one_natCast_le_withTop_of_lt hn)) h'f have I₄ : Integrable (fun v ↦ fourierSMulRight L (fun v ↦ fourierPowSMulRight L f v n) v) μ := by apply (I₂.const_mul ((2 * π * ‖L‖))).mono' (h'f.fourierPowSMulRight L n).fourierSMulRight filter_upwards with v exact (norm_fourierSMulRight_le _ _ _).trans (le_of_eq (by ring)) have E : curryLeft (fourierIntegral 𝐞 μ L.toLinearMap₁₂ (fun v ↦ fourierPowSMulRight L f v (n + 1)) w) = fourierIntegral 𝐞 μ L.toLinearMap₁₂ (fourierSMulRight L fun v ↦ fourierPowSMulRight L f v n) w := by ext w' m rw [curryLeft_apply, fourierIntegral_continuousMultilinearMap_apply' I₃, fourierIntegral_continuousLinearMap_apply' I₄, fourierIntegral_continuousMultilinearMap_apply' (I₄.apply_continuousLinearMap _)] congr with v simp only [fourierPowSMulRight_apply, mul_comm, pow_succ, neg_mul, Fin.prod_univ_succ, Fin.cons_zero, Fin.cons_succ, neg_smul, fourierSMulRight_apply, neg_apply, smul_apply, smul_comm (M := ℝ) (N := ℂ) (α := E), smul_smul] exact E ▸ hasFDerivAt_fourierIntegral L I₁ I₂ w · intro n hn apply fourierIntegral_continuous Real.continuous_fourierChar (by apply L.continuous₂) exact integrable_fourierPowSMulRight L (hf n hn) h'f /-- Variant of `hasFTaylorSeriesUpTo_fourierIntegral` in which the smoothness index is restricted to `ℕ∞` (and so are the inequalities in the assumption `hf`). Avoids normcasting in some applications. -/ lemma hasFTaylorSeriesUpTo_fourierIntegral' {N : ℕ∞} (hf : ∀ (n : ℕ), n ≤ N → Integrable (fun v ↦ ‖v‖ ^ n * ‖f v‖) μ) (h'f : AEStronglyMeasurable f μ) : HasFTaylorSeriesUpTo N (fourierIntegral 𝐞 μ L.toLinearMap₁₂ f) (fun w n ↦ fourierIntegral 𝐞 μ L.toLinearMap₁₂ (fun v ↦ fourierPowSMulRight L f v n) w) := hasFTaylorSeriesUpTo_fourierIntegral _ (fun n hn ↦ hf n (mod_cast hn)) h'f /-- If `‖v‖^n * ‖f v‖` is integrable for all `n ≤ N`, then the Fourier transform of `f` is `C^N`. -/ theorem contDiff_fourierIntegral {N : ℕ∞} (hf : ∀ (n : ℕ), n ≤ N → Integrable (fun v ↦ ‖v‖ ^ n * ‖f v‖) μ) : ContDiff ℝ N (fourierIntegral 𝐞 μ L.toLinearMap₁₂ f) := by by_cases h'f : Integrable f μ · exact (hasFTaylorSeriesUpTo_fourierIntegral' L hf h'f.1).contDiff · have : fourierIntegral 𝐞 μ L.toLinearMap₁₂ f = 0 := by ext w; simp [fourierIntegral, integral, h'f] simpa [this] using contDiff_const /-- If `‖v‖^n * ‖f v‖` is integrable for all `n ≤ N`, then the `n`-th derivative of the Fourier transform of `f` is the Fourier transform of `fourierPowSMulRight L f v n`, i.e., `(L v ⬝) ^ n • f v`. -/ lemma iteratedFDeriv_fourierIntegral {N : ℕ∞} (hf : ∀ (n : ℕ), n ≤ N → Integrable (fun v ↦ ‖v‖ ^ n * ‖f v‖) μ) (h'f : AEStronglyMeasurable f μ) {n : ℕ} (hn : n ≤ N) : iteratedFDeriv ℝ n (fourierIntegral 𝐞 μ L.toLinearMap₁₂ f) = fourierIntegral 𝐞 μ L.toLinearMap₁₂ (fun v ↦ fourierPowSMulRight L f v n) := by ext w : 1 exact ((hasFTaylorSeriesUpTo_fourierIntegral' L hf h'f).eq_iteratedFDeriv (mod_cast hn) w).symm end SecondCountableTopology /-- The Fourier integral of the `n`-th derivative of a function is obtained by multiplying the Fourier integral of the original function by `(2πI L w ⬝ )^n`. -/ theorem fourierIntegral_iteratedFDeriv [FiniteDimensional ℝ V] {μ : Measure V} [Measure.IsAddHaarMeasure μ] {N : ℕ∞} (hf : ContDiff ℝ N f) (h'f : ∀ (n : ℕ), n ≤ N → Integrable (iteratedFDeriv ℝ n f) μ) {n : ℕ} (hn : n ≤ N) : fourierIntegral 𝐞 μ L.toLinearMap₁₂ (iteratedFDeriv ℝ n f) = (fun w ↦ fourierPowSMulRight (-L.flip) (fourierIntegral 𝐞 μ L.toLinearMap₁₂ f) w n) := by induction n with | zero => ext w m simp only [iteratedFDeriv_zero_apply, fourierPowSMulRight_apply, pow_zero, Finset.univ_eq_empty, ContinuousLinearMap.neg_apply, ContinuousLinearMap.flip_apply, Finset.prod_empty, one_smul, fourierIntegral_continuousMultilinearMap_apply' ((h'f 0 bot_le))] | succ n ih => ext w m have J : Integrable (fderiv ℝ (iteratedFDeriv ℝ n f)) μ := by specialize h'f (n + 1) hn rwa [iteratedFDeriv_succ_eq_comp_left, Function.comp_def, LinearIsometryEquiv.integrable_comp_iff (𝕜 := ℝ) (φ := fderiv ℝ (iteratedFDeriv ℝ n f))] at h'f suffices H : (fourierIntegral 𝐞 μ L.toLinearMap₁₂ (fderiv ℝ (iteratedFDeriv ℝ n f)) w) (m 0) (Fin.tail m) = (-(2 * π * I)) ^ (n + 1) • (∏ x : Fin (n + 1), -L (m x) w) • ∫ v, 𝐞 (-L v w) • f v ∂μ by rw [fourierIntegral_continuousMultilinearMap_apply' (h'f _ hn)] simp only [iteratedFDeriv_succ_apply_left, fourierPowSMulRight_apply, ContinuousLinearMap.neg_apply, ContinuousLinearMap.flip_apply] rw [← fourierIntegral_continuousMultilinearMap_apply' ((J.apply_continuousLinearMap _)), ← fourierIntegral_continuousLinearMap_apply' J] exact H have h'n : n < N := (Nat.cast_lt.mpr n.lt_succ_self).trans_le hn rw [fourierIntegral_fderiv _ (h'f n h'n.le) (hf.differentiable_iteratedFDeriv (mod_cast h'n)) J] simp only [ih h'n.le, fourierSMulRight_apply, ContinuousLinearMap.neg_apply, ContinuousLinearMap.flip_apply, neg_smul, smul_neg, neg_neg, smul_apply, fourierPowSMulRight_apply, ← coe_smul (E := E), smul_smul] congr 1 simp only [ofReal_prod, ofReal_neg, pow_succ, mul_neg, Fin.prod_univ_succ, neg_mul, ofReal_mul, neg_neg, Fin.tail_def] ring /-- The `k`-th derivative of the Fourier integral of `f`, multiplied by `(L v w) ^ n`, is the Fourier integral of the `n`-th derivative of `(L v w) ^ k * f`. -/ theorem fourierPowSMulRight_iteratedFDeriv_fourierIntegral [FiniteDimensional ℝ V] {μ : Measure V} [Measure.IsAddHaarMeasure μ] {K N : ℕ∞} (hf : ContDiff ℝ N f) (h'f : ∀ (k n : ℕ), k ≤ K → n ≤ N → Integrable (fun v ↦ ‖v‖ ^ k * ‖iteratedFDeriv ℝ n f v‖) μ) {k n : ℕ} (hk : k ≤ K) (hn : n ≤ N) {w : W} : fourierPowSMulRight (-L.flip) (iteratedFDeriv ℝ k (fourierIntegral 𝐞 μ L.toLinearMap₁₂ f)) w n = fourierIntegral 𝐞 μ L.toLinearMap₁₂ (iteratedFDeriv ℝ n (fun v ↦ fourierPowSMulRight L f v k)) w := by rw [fourierIntegral_iteratedFDeriv (N := N) _ (hf.fourierPowSMulRight _ _) _ hn] · congr rw [iteratedFDeriv_fourierIntegral (N := K) _ _ hf.continuous.aestronglyMeasurable hk] intro k hk simpa only [norm_iteratedFDeriv_zero] using h'f k 0 hk bot_le · intro m hm have I : Integrable (fun v ↦ ∑ p ∈ Finset.range (k + 1) ×ˢ Finset.range (m + 1), ‖v‖ ^ p.1 * ‖iteratedFDeriv ℝ p.2 f v‖) μ := by apply integrable_finset_sum _ (fun p hp ↦ ?_) simp only [Finset.mem_product, Finset.mem_range_succ_iff] at hp exact h'f _ _ ((Nat.cast_le.2 hp.1).trans hk) ((Nat.cast_le.2 hp.2).trans hm) apply (I.const_mul ((2 * π) ^ k * (2 * k + 2) ^ m * ‖L‖ ^ k)).mono' ((hf.fourierPowSMulRight L k).continuous_iteratedFDeriv (mod_cast hm)).aestronglyMeasurable filter_upwards with v refine norm_iteratedFDeriv_fourierPowSMulRight _ hf (mod_cast hm) (fun i hi j hj ↦ ?_) apply Finset.single_le_sum (f := fun p ↦ ‖v‖ ^ p.1 * ‖iteratedFDeriv ℝ p.2 f v‖) (a := (j, i)) · intro i _hi positivity · simpa only [Finset.mem_product, Finset.mem_range_succ_iff] using ⟨hj, hi⟩ /-- One can bound the `k`-th derivative of the Fourier integral of `f`, multiplied by `(L v w) ^ n`, in terms of integrals of iterated derivatives of `f` (of order up to `n`) multiplied by `‖v‖ ^ i` (for `i ≤ k`). Auxiliary version in terms of the operator norm of `fourierPowSMulRight (-L.flip) ⬝`. For a version in terms of `|L v w| ^ n * ⬝`, see `pow_mul_norm_iteratedFDeriv_fourierIntegral_le`. -/ theorem norm_fourierPowSMulRight_iteratedFDeriv_fourierIntegral_le [FiniteDimensional ℝ V] {μ : Measure V} [Measure.IsAddHaarMeasure μ] {K N : ℕ∞} (hf : ContDiff ℝ N f) (h'f : ∀ (k n : ℕ), k ≤ K → n ≤ N → Integrable (fun v ↦ ‖v‖ ^ k * ‖iteratedFDeriv ℝ n f v‖) μ) {k n : ℕ} (hk : k ≤ K) (hn : n ≤ N) {w : W} : ‖fourierPowSMulRight (-L.flip) (iteratedFDeriv ℝ k (fourierIntegral 𝐞 μ L.toLinearMap₁₂ f)) w n‖ ≤ (2 * π) ^ k * (2 * k + 2) ^ n * ‖L‖ ^ k * ∑ p ∈ Finset.range (k + 1) ×ˢ Finset.range (n + 1), ∫ v, ‖v‖ ^ p.1 * ‖iteratedFDeriv ℝ p.2 f v‖ ∂μ := by rw [fourierPowSMulRight_iteratedFDeriv_fourierIntegral L hf h'f hk hn] apply (norm_fourierIntegral_le_integral_norm _ _ _ _ _).trans have I p (hp : p ∈ Finset.range (k + 1) ×ˢ Finset.range (n + 1)) : Integrable (fun v ↦ ‖v‖ ^ p.1 * ‖iteratedFDeriv ℝ p.2 f v‖) μ := by simp only [Finset.mem_product, Finset.mem_range_succ_iff] at hp exact h'f _ _ (le_trans (by simpa using hp.1) hk) (le_trans (by simpa using hp.2) hn) rw [← integral_finset_sum _ I, ← integral_const_mul] apply integral_mono_of_nonneg · filter_upwards with v using norm_nonneg _ · exact (integrable_finset_sum _ I).const_mul _ · filter_upwards with v apply norm_iteratedFDeriv_fourierPowSMulRight _ hf (mod_cast hn) _ intro i hi j hj apply Finset.single_le_sum (f := fun p ↦ ‖v‖ ^ p.1 * ‖iteratedFDeriv ℝ p.2 f v‖) (a := (j, i)) · intro i _hi positivity · simp only [Finset.mem_product, Finset.mem_range_succ_iff] exact ⟨hj, hi⟩ /-- One can bound the `k`-th derivative of the Fourier integral of `f`, multiplied by `(L v w) ^ n`, in terms of integrals of iterated derivatives of `f` (of order up to `n`) multiplied by `‖v‖ ^ i` (for `i ≤ k`). -/ lemma pow_mul_norm_iteratedFDeriv_fourierIntegral_le [FiniteDimensional ℝ V] {μ : Measure V} [Measure.IsAddHaarMeasure μ] {K N : ℕ∞} (hf : ContDiff ℝ N f) (h'f : ∀ (k n : ℕ), k ≤ K → n ≤ N → Integrable (fun v ↦ ‖v‖ ^ k * ‖iteratedFDeriv ℝ n f v‖) μ) {k n : ℕ} (hk : k ≤ K) (hn : n ≤ N) (v : V) (w : W) : |L v w| ^ n * ‖(iteratedFDeriv ℝ k (fourierIntegral 𝐞 μ L.toLinearMap₁₂ f)) w‖ ≤ ‖v‖ ^ n * (2 * π * ‖L‖) ^ k * (2 * k + 2) ^ n * ∑ p ∈ Finset.range (k + 1) ×ˢ Finset.range (n + 1), ∫ v, ‖v‖ ^ p.1 * ‖iteratedFDeriv ℝ p.2 f v‖ ∂μ := calc |L v w| ^ n * ‖(iteratedFDeriv ℝ k (fourierIntegral 𝐞 μ L.toLinearMap₁₂ f)) w‖ _ ≤ (2 * π) ^ n * (|L v w| ^ n * ‖iteratedFDeriv ℝ k (fourierIntegral 𝐞 μ L.toLinearMap₁₂ f) w‖) := by apply le_mul_of_one_le_left (by positivity) apply one_le_pow₀ linarith [one_le_pi_div_two] _ = ‖fourierPowSMulRight (-L.flip) (iteratedFDeriv ℝ k (fourierIntegral 𝐞 μ L.toLinearMap₁₂ f)) w n (fun _ ↦ v)‖ := by simp [norm_smul, abs_of_nonneg pi_nonneg] _ ≤ ‖fourierPowSMulRight (-L.flip) (iteratedFDeriv ℝ k (fourierIntegral 𝐞 μ L.toLinearMap₁₂ f)) w n‖ * ∏ _ : Fin n, ‖v‖ := le_opNorm _ _ _ ≤ ((2 * π) ^ k * (2 * k + 2) ^ n * ‖L‖ ^ k * ∑ p ∈ Finset.range (k + 1) ×ˢ Finset.range (n + 1), ∫ v, ‖v‖ ^ p.1 * ‖iteratedFDeriv ℝ p.2 f v‖ ∂μ) * ‖v‖ ^ n := by gcongr · apply norm_fourierPowSMulRight_iteratedFDeriv_fourierIntegral_le _ hf h'f hk hn · simp _ = ‖v‖ ^ n * (2 * π * ‖L‖) ^ k * (2 * k + 2) ^ n * ∑ p ∈ Finset.range (k + 1) ×ˢ Finset.range (n + 1), ∫ v, ‖v‖ ^ p.1 * ‖iteratedFDeriv ℝ p.2 f v‖ ∂μ := by simp [mul_pow] ring end VectorFourier namespace Real open VectorFourier variable {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V] [FiniteDimensional ℝ V] [MeasurableSpace V] [BorelSpace V] {f : V → E} /-- The Fréchet derivative of the Fourier transform of `f` is the Fourier transform of `fun v ↦ -2 * π * I ⟪v, ⬝⟫ f v`. -/ theorem hasFDerivAt_fourierIntegral (hf_int : Integrable f) (hvf_int : Integrable (fun v ↦ ‖v‖ * ‖f v‖)) (x : V) : HasFDerivAt (𝓕 f) (𝓕 (fourierSMulRight (innerSL ℝ) f) x) x := VectorFourier.hasFDerivAt_fourierIntegral (innerSL ℝ) hf_int hvf_int x /-- The Fréchet derivative of the Fourier transform of `f` is the Fourier transform of `fun v ↦ -2 * π * I ⟪v, ⬝⟫ f v`. -/ theorem fderiv_fourierIntegral (hf_int : Integrable f) (hvf_int : Integrable (fun v ↦ ‖v‖ * ‖f v‖)) : fderiv ℝ (𝓕 f) = 𝓕 (fourierSMulRight (innerSL ℝ) f) := VectorFourier.fderiv_fourierIntegral (innerSL ℝ) hf_int hvf_int theorem differentiable_fourierIntegral (hf_int : Integrable f) (hvf_int : Integrable (fun v ↦ ‖v‖ * ‖f v‖)) : Differentiable ℝ (𝓕 f) := VectorFourier.differentiable_fourierIntegral (innerSL ℝ) hf_int hvf_int /-- The Fourier integral of the Fréchet derivative of a function is obtained by multiplying the Fourier integral of the original function by `2πI ⟪v, w⟫`. -/ theorem fourierIntegral_fderiv (hf : Integrable f) (h'f : Differentiable ℝ f) (hf' : Integrable (fderiv ℝ f)) : 𝓕 (fderiv ℝ f) = fourierSMulRight (-innerSL ℝ) (𝓕 f) := by rw [← flip_innerSL_real V] exact VectorFourier.fourierIntegral_fderiv (innerSL ℝ) hf h'f hf' /-- If `‖v‖^n * ‖f v‖` is integrable, then the Fourier transform of `f` is `C^n`. -/ theorem contDiff_fourierIntegral {N : ℕ∞} (hf : ∀ (n : ℕ), n ≤ N → Integrable (fun v ↦ ‖v‖ ^ n * ‖f v‖)) : ContDiff ℝ N (𝓕 f) := VectorFourier.contDiff_fourierIntegral (innerSL ℝ) hf /-- If `‖v‖^n * ‖f v‖` is integrable, then the `n`-th derivative of the Fourier transform of `f` is the Fourier transform of `fun v ↦ (-2 * π * I) ^ n ⟪v, ⬝⟫^n f v`. -/ theorem iteratedFDeriv_fourierIntegral {N : ℕ∞} (hf : ∀ (n : ℕ), n ≤ N → Integrable (fun v ↦ ‖v‖ ^ n * ‖f v‖)) (h'f : AEStronglyMeasurable f) {n : ℕ} (hn : n ≤ N) : iteratedFDeriv ℝ n (𝓕 f) = 𝓕 (fun v ↦ fourierPowSMulRight (innerSL ℝ) f v n) := VectorFourier.iteratedFDeriv_fourierIntegral (innerSL ℝ) hf h'f hn /-- The Fourier integral of the `n`-th derivative of a function is obtained by multiplying the Fourier integral of the original function by `(2πI L w ⬝ )^n`. -/ theorem fourierIntegral_iteratedFDeriv {N : ℕ∞} (hf : ContDiff ℝ N f) (h'f : ∀ (n : ℕ), n ≤ N → Integrable (iteratedFDeriv ℝ n f)) {n : ℕ} (hn : n ≤ N) : 𝓕 (iteratedFDeriv ℝ n f) = (fun w ↦ fourierPowSMulRight (-innerSL ℝ) (𝓕 f) w n) := by rw [← flip_innerSL_real V] exact VectorFourier.fourierIntegral_iteratedFDeriv (innerSL ℝ) hf h'f hn /-- One can bound `‖w‖^n * ‖D^k (𝓕 f) w‖` in terms of integrals of the derivatives of `f` (or order at most `n`) multiplied by powers of `v` (of order at most `k`). -/ lemma pow_mul_norm_iteratedFDeriv_fourierIntegral_le {K N : ℕ∞} (hf : ContDiff ℝ N f) (h'f : ∀ (k n : ℕ), k ≤ K → n ≤ N → Integrable (fun v ↦ ‖v‖ ^ k * ‖iteratedFDeriv ℝ n f v‖)) {k n : ℕ} (hk : k ≤ K) (hn : n ≤ N) (w : V) : ‖w‖ ^ n * ‖iteratedFDeriv ℝ k (𝓕 f) w‖ ≤ (2 * π) ^ k * (2 * k + 2) ^ n * ∑ p ∈ Finset.range (k + 1) ×ˢ Finset.range (n + 1), ∫ v, ‖v‖ ^ p.1 * ‖iteratedFDeriv ℝ p.2 f v‖ := by have Z : ‖w‖ ^ n * (‖w‖ ^ n * ‖iteratedFDeriv ℝ k (𝓕 f) w‖) ≤ ‖w‖ ^ n * ((2 * (π * ‖innerSL (E := V) ℝ‖)) ^ k * ((2 * k + 2) ^ n * ∑ p ∈ Finset.range (k + 1) ×ˢ Finset.range (n + 1), ∫ (v : V), ‖v‖ ^ p.1 * ‖iteratedFDeriv ℝ p.2 f v‖ ∂volume)) := by have := VectorFourier.pow_mul_norm_iteratedFDeriv_fourierIntegral_le (innerSL ℝ) hf h'f hk hn w w simp only [innerSL_apply_apply _ w w, real_inner_self_eq_norm_sq w, abs_pow, abs_norm, mul_assoc] at this rwa [pow_two, mul_pow, mul_assoc] at this rcases eq_or_ne n 0 with rfl | hn · simp only [pow_zero, one_mul, mul_one, zero_add, Finset.range_one, Finset.product_singleton, Finset.sum_map, Function.Embedding.coeFn_mk, norm_iteratedFDeriv_zero] at Z ⊢ apply Z.trans conv_rhs => rw [← mul_one π] gcongr exact norm_innerSL_le _ rcases eq_or_ne w 0 with rfl | hw · simp [hn] positivity rw [mul_le_mul_iff_right₀ (pow_pos (by simp [hw]) n)] at Z apply Z.trans conv_rhs => rw [← mul_one π] simp only [mul_assoc] gcongr exact norm_innerSL_le _ lemma hasDerivAt_fourierIntegral {f : ℝ → E} (hf : Integrable f) (hf' : Integrable (fun x : ℝ ↦ x • f x)) (w : ℝ) : HasDerivAt (𝓕 f) (𝓕 (fun x : ℝ ↦ (-2 * π * I * x) • f x) w) w := by have hf'' : Integrable (fun v : ℝ ↦ ‖v‖ * ‖f v‖) := by simpa only [norm_smul] using hf'.norm let L := ContinuousLinearMap.mul ℝ ℝ |>.flip have h_int : Integrable fun v ↦ fourierSMulRight L f v := by suffices Integrable fun v ↦ ContinuousLinearMap.smulRight (L v) (f v) by simpa only [fourierSMulRight, neg_smul, neg_mul, Pi.smul_apply] using this.smul (-2 * π * I) convert ((ContinuousLinearMap.ring_lmap_equiv_self ℝ E).symm.toContinuousLinearEquiv.toContinuousLinearMap).integrable_comp hf' using 2 with _ v apply ContinuousLinearMap.ext_ring rw [ContinuousLinearMap.smulRight_apply, ContinuousLinearMap.flip_apply, ContinuousLinearMap.mul_apply', one_mul, ContinuousLinearMap.map_smul] exact congr_arg (fun x ↦ v • x) (one_smul ℝ (f v)).symm rw [← VectorFourier.fourierIntegral_convergent_iff continuous_fourierChar L.continuous₂ w] at h_int convert (VectorFourier.hasFDerivAt_fourierIntegral L hf hf'' w).hasDerivAt using 1 erw [ContinuousLinearMap.integral_apply h_int] simp_rw [ContinuousLinearMap.smul_apply, fourierSMulRight, ContinuousLinearMap.smul_apply, ContinuousLinearMap.smulRight_apply, L, ContinuousLinearMap.flip_apply, ContinuousLinearMap.mul_apply', one_mul, ← neg_mul, mul_smul] rfl theorem deriv_fourierIntegral {f : ℝ → E} (hf : Integrable f) (hf' : Integrable (fun x : ℝ ↦ x • f x)) : deriv (𝓕 f) = 𝓕 (fun x : ℝ ↦ (-2 * π * I * x) • f x) := by ext x exact (hasDerivAt_fourierIntegral hf hf' x).deriv /-- The Fourier integral of the Fréchet derivative of a function is obtained by multiplying the Fourier integral of the original function by `2πI x`. -/ theorem fourierIntegral_deriv {f : ℝ → E} (hf : Integrable f) (h'f : Differentiable ℝ f) (hf' : Integrable (deriv f)) : 𝓕 (deriv f) = fun (x : ℝ) ↦ (2 * π * I * x) • (𝓕 f x) := by ext x have I : Integrable (fun x ↦ fderiv ℝ f x) := by simpa only [← deriv_fderiv] using (ContinuousLinearMap.smulRightL ℝ ℝ E 1).integrable_comp hf' have : 𝓕 (deriv f) x = 𝓕 (fderiv ℝ f) x 1 := by simp only [fourierIntegral_continuousLinearMap_apply I, fderiv_deriv] rw [this, fourierIntegral_fderiv hf h'f I] simp only [fourierSMulRight_apply, ContinuousLinearMap.neg_apply, innerSL_apply_apply, smul_smul, RCLike.inner_apply', conj_trivial, mul_one, neg_smul, smul_neg, neg_neg, neg_mul, ← coe_smul] theorem iteratedDeriv_fourierIntegral {f : ℝ → E} {N : ℕ∞} {n : ℕ} (hf : ∀ (n : ℕ), n ≤ N → Integrable (fun x ↦ x ^ n • f x)) (hn : n ≤ N) : iteratedDeriv n (𝓕 f) = 𝓕 (fun x : ℝ ↦ (-2 * π * I * x) ^ n • f x) := by ext x : 1 have A (n : ℕ) (hn : n ≤ N) : Integrable (fun v ↦ ‖v‖ ^ n * ‖f v‖) := by convert (hf n hn).norm with x simp [norm_smul] have B : AEStronglyMeasurable f := by simpa using (hf 0 (zero_le _)).1 rw [iteratedDeriv, iteratedFDeriv_fourierIntegral A B hn, fourierIntegral_continuousMultilinearMap_apply (integrable_fourierPowSMulRight _ (A n hn) B), fourierIntegral_eq, fourierIntegral_eq] congr with y suffices (-(2 * π * I)) ^ n • y ^ n • f y = (-(2 * π * I * y)) ^ n • f y by simpa [innerSL_apply_apply _] simp only [← neg_mul, ← coe_smul, smul_smul, mul_pow, ofReal_pow, mul_assoc] theorem fourierIntegral_iteratedDeriv {f : ℝ → E} {N : ℕ∞} {n : ℕ} (hf : ContDiff ℝ N f) (h'f : ∀ (n : ℕ), n ≤ N → Integrable (iteratedDeriv n f)) (hn : n ≤ N) : 𝓕 (iteratedDeriv n f) = fun (x : ℝ) ↦ (2 * π * I * x) ^ n • (𝓕 f x) := by ext x : 1 have A : ∀ (n : ℕ), n ≤ N → Integrable (iteratedFDeriv ℝ n f) := by intro n hn rw [iteratedFDeriv_eq_equiv_comp] exact (LinearIsometryEquiv.integrable_comp_iff _).2 (h'f n hn) change 𝓕 (fun x ↦ iteratedDeriv n f x) x = _ simp_rw [iteratedDeriv, ← fourierIntegral_continuousMultilinearMap_apply (A n hn), fourierIntegral_iteratedFDeriv hf A hn] simp [← coe_smul, smul_smul, ← mul_pow] end Real
.lake/packages/mathlib/Mathlib/Analysis/Fourier/FourierTransform.lean
import Mathlib.Algebra.Group.AddChar import Mathlib.Analysis.Complex.Circle import Mathlib.Analysis.Fourier.Notation import Mathlib.MeasureTheory.Group.Integral import Mathlib.MeasureTheory.Integral.Prod import Mathlib.MeasureTheory.Integral.Bochner.Set import Mathlib.MeasureTheory.Measure.Haar.InnerProductSpace import Mathlib.MeasureTheory.Measure.Haar.OfBasis /-! # The Fourier transform We set up the Fourier transform for complex-valued functions on finite-dimensional spaces. ## Design choices In namespace `VectorFourier`, we define the Fourier integral in the following context: * `𝕜` is a commutative ring. * `V` and `W` are `𝕜`-modules. * `e` is a unitary additive character of `𝕜`, i.e. an `AddChar 𝕜 Circle`. * `μ` is a measure on `V`. * `L` is a `𝕜`-bilinear form `V × W → 𝕜`. * `E` is a complete normed `ℂ`-vector space. With these definitions, we define `fourierIntegral` to be the map from functions `V → E` to functions `W → E` that sends `f` to `fun w ↦ ∫ v in V, e (-L v w) • f v ∂μ`, This includes the cases `W` is the dual of `V` and `L` is the canonical pairing, or `W = V` and `L` is a bilinear form (e.g. an inner product). In namespace `Fourier`, we consider the more familiar special case when `V = W = 𝕜` and `L` is the multiplication map (but still allowing `𝕜` to be an arbitrary ring equipped with a measure). The most familiar case of all is when `V = W = 𝕜 = ℝ`, `L` is multiplication, `μ` is volume, and `e` is `Real.fourierChar`, i.e. the character `fun x ↦ exp ((2 * π * x) * I)` (for which we introduced the notation `𝐞` in the scope `FourierTransform`). Another familiar case (which generalizes the previous one) is when `V = W` is an inner product space over `ℝ` and `L` is the scalar product. We introduce two notations `𝓕` for the Fourier transform in this case and `𝓕⁻ f (v) = 𝓕 f (-v)` for the inverse Fourier transform. These notations make in particular sense for `V = W = ℝ`. ## Main results At present the only nontrivial lemma we prove is `fourierIntegral_continuous`, stating that the Fourier transform of an integrable function is continuous (under mild assumptions). -/ noncomputable section local notation "𝕊" => Circle open MeasureTheory Filter open scoped Topology /-! ## Fourier theory for functions on general vector spaces -/ namespace VectorFourier variable {𝕜 : Type*} [CommRing 𝕜] {V : Type*} [AddCommGroup V] [Module 𝕜 V] [MeasurableSpace V] {W : Type*} [AddCommGroup W] [Module 𝕜 W] {E F G : Type*} [NormedAddCommGroup E] [NormedSpace ℂ E] [NormedAddCommGroup F] [NormedSpace ℂ F] [NormedAddCommGroup G] [NormedSpace ℂ G] section Defs /-- The Fourier transform integral for `f : V → E`, with respect to a bilinear form `L : V × W → 𝕜` and an additive character `e`. -/ def fourierIntegral (e : AddChar 𝕜 𝕊) (μ : Measure V) (L : V →ₗ[𝕜] W →ₗ[𝕜] 𝕜) (f : V → E) (w : W) : E := ∫ v, e (-L v w) • f v ∂μ theorem fourierIntegral_const_smul (e : AddChar 𝕜 𝕊) (μ : Measure V) (L : V →ₗ[𝕜] W →ₗ[𝕜] 𝕜) (f : V → E) (r : ℂ) : fourierIntegral e μ L (r • f) = r • fourierIntegral e μ L f := by ext1 w simp only [Pi.smul_apply, fourierIntegral, smul_comm _ r, integral_smul] /-- The uniform norm of the Fourier integral of `f` is bounded by the `L¹` norm of `f`. -/ theorem norm_fourierIntegral_le_integral_norm (e : AddChar 𝕜 𝕊) (μ : Measure V) (L : V →ₗ[𝕜] W →ₗ[𝕜] 𝕜) (f : V → E) (w : W) : ‖fourierIntegral e μ L f w‖ ≤ ∫ v : V, ‖f v‖ ∂μ := by refine (norm_integral_le_integral_norm _).trans (le_of_eq ?_) simp_rw [Circle.norm_smul] /-- The Fourier integral converts right-translation into scalar multiplication by a phase factor. -/ theorem fourierIntegral_comp_add_right [MeasurableAdd V] (e : AddChar 𝕜 𝕊) (μ : Measure V) [μ.IsAddRightInvariant] (L : V →ₗ[𝕜] W →ₗ[𝕜] 𝕜) (f : V → E) (v₀ : V) : fourierIntegral e μ L (f ∘ fun v ↦ v + v₀) = fun w ↦ e (L v₀ w) • fourierIntegral e μ L f w := by ext1 w dsimp only [fourierIntegral, Function.comp_apply, Circle.smul_def] conv in L _ => rw [← add_sub_cancel_right v v₀] rw [integral_add_right_eq_self fun v : V ↦ (e (-L (v - v₀) w) : ℂ) • f v, ← integral_smul] congr 1 with v rw [← smul_assoc, smul_eq_mul, ← Circle.coe_mul, ← e.map_add_eq_mul, ← LinearMap.neg_apply, ← sub_eq_add_neg, ← LinearMap.sub_apply, LinearMap.map_sub, neg_sub] end Defs section Continuous /-! In this section we assume 𝕜, `V`, `W` have topologies, and `L`, `e` are continuous (but `f` needn't be). This is used to ensure that `e (-L v w)` is (a.e. strongly) measurable. We could get away with imposing only a measurable-space structure on 𝕜 (it doesn't have to be the Borel sigma-algebra of a topology); but it seems hard to imagine cases where this extra generality would be useful, and allowing it would complicate matters in the most important use cases. -/ variable [TopologicalSpace 𝕜] [IsTopologicalRing 𝕜] [TopologicalSpace V] [BorelSpace V] [TopologicalSpace W] {e : AddChar 𝕜 𝕊} {μ : Measure V} {L : V →ₗ[𝕜] W →ₗ[𝕜] 𝕜} /-- For any `w`, the Fourier integral is convergent iff `f` is integrable. -/ theorem fourierIntegral_convergent_iff (he : Continuous e) (hL : Continuous fun p : V × W ↦ L p.1 p.2) {f : V → E} (w : W) : Integrable (fun v : V ↦ e (-L v w) • f v) μ ↔ Integrable f μ := by -- first prove one-way implication have aux {g : V → E} (hg : Integrable g μ) (x : W) : Integrable (fun v : V ↦ e (-L v x) • g v) μ := by have c : Continuous fun v ↦ e (-L v x) := he.comp (hL.comp (.prodMk_left _)).neg simp_rw [← integrable_norm_iff (c.aestronglyMeasurable.smul hg.1), Circle.norm_smul] exact hg.norm -- then use it for both directions refine ⟨fun hf ↦ ?_, fun hf ↦ aux hf w⟩ have := aux hf (-w) simp_rw [← mul_smul (e _) (e _) (f _), ← e.map_add_eq_mul, LinearMap.map_neg, neg_add_cancel, e.map_zero_eq_one, one_smul] at this -- the `(e _)` speeds up elaboration considerably exact this theorem fourierIntegral_add (he : Continuous e) (hL : Continuous fun p : V × W ↦ L p.1 p.2) {f g : V → E} (hf : Integrable f μ) (hg : Integrable g μ) : fourierIntegral e μ L (f + g) = fourierIntegral e μ L f + fourierIntegral e μ L g := by ext1 w dsimp only [Pi.add_apply, fourierIntegral] simp_rw [smul_add] rw [integral_add] · exact (fourierIntegral_convergent_iff he hL w).2 hf · exact (fourierIntegral_convergent_iff he hL w).2 hg /-- The Fourier integral of an `L^1` function is a continuous function. -/ theorem fourierIntegral_continuous [FirstCountableTopology W] (he : Continuous e) (hL : Continuous fun p : V × W ↦ L p.1 p.2) {f : V → E} (hf : Integrable f μ) : Continuous (fourierIntegral e μ L f) := by apply continuous_of_dominated · exact fun w ↦ ((fourierIntegral_convergent_iff he hL w).2 hf).1 · exact fun w ↦ ae_of_all _ fun v ↦ le_of_eq (Circle.norm_smul _ _) · exact hf.norm · refine ae_of_all _ fun v ↦ (he.comp ?_).smul continuous_const exact (hL.comp (.prodMk_right _)).neg end Continuous section Fubini variable [TopologicalSpace 𝕜] [IsTopologicalRing 𝕜] [TopologicalSpace V] [BorelSpace V] [TopologicalSpace W] [MeasurableSpace W] [BorelSpace W] {e : AddChar 𝕜 𝕊} {μ : Measure V} {L : V →ₗ[𝕜] W →ₗ[𝕜] 𝕜} {ν : Measure W} [SigmaFinite μ] [SigmaFinite ν] [SecondCountableTopology V] variable {σ : ℂ →+* ℂ} [RingHomIsometric σ] /-- Fubini's theorem for the Fourier integral. This is the main technical step in proving both Parseval's identity and self-adjointness of the Fourier transform. -/ theorem integral_fourierIntegral_swap {f : V → E} {g : W → F} (M : F →L[ℂ] E →SL[σ] G) (he : Continuous e) (hL : Continuous fun p : V × W ↦ L p.1 p.2) (hf : Integrable f μ) (hg : Integrable g ν) : ∫ ξ, (∫ x, M (g ξ) (e (-L x ξ) • f x) ∂μ) ∂ν = ∫ x, (∫ ξ, M (g ξ) (e (-L x ξ) • f x) ∂ν) ∂μ := by rw [integral_integral_swap] have : Integrable (fun (p : W × V) ↦ ‖M‖ * (‖g p.1‖ * ‖f p.2‖)) (ν.prod μ) := (hg.norm.mul_prod hf.norm).const_mul _ apply this.mono · change AEStronglyMeasurable (fun p : W × V ↦ (M (g p.1) (e (-(L p.2) p.1) • f p.2) )) _ have A : AEStronglyMeasurable (fun (p : W × V) ↦ e (-L p.2 p.1) • f p.2) (ν.prod μ) := by refine (Continuous.aestronglyMeasurable ?_).smul hf.1.comp_snd exact he.comp (hL.comp continuous_swap).neg have A' : AEStronglyMeasurable (fun p ↦ (g p.1, e (-(L p.2) p.1) • f p.2) : W × V → F × E) (Measure.prod ν μ) := hg.1.comp_fst.prodMk A have hM : Continuous (fun q ↦ M q.1 q.2 : F × E → G) := -- There is no `Continuous.clm_apply` for semilinear continuous maps (M.flip.cont.comp continuous_snd).clm_apply continuous_fst apply hM.comp_aestronglyMeasurable A' -- `exact` works, but `apply` is 10x faster! · filter_upwards with ⟨ξ, x⟩ simp only [Function.uncurry_apply_pair, norm_mul, norm_norm, ge_iff_le, ← mul_assoc] convert M.le_opNorm₂ (g ξ) (e (-L x ξ) • f x) using 2 simp variable [CompleteSpace E] [CompleteSpace F] /-- The Fourier transform satisfies `∫ 𝓕 f * g = ∫ f * 𝓕 g`, i.e., it is self-adjoint. Version where the multiplication is replaced by a general bilinear form `M`. -/ theorem integral_bilin_fourierIntegral_eq_flip {f : V → E} {g : W → F} (M : E →L[ℂ] F →L[ℂ] G) (he : Continuous e) (hL : Continuous fun p : V × W ↦ L p.1 p.2) (hf : Integrable f μ) (hg : Integrable g ν) : ∫ ξ, M (fourierIntegral e μ L f ξ) (g ξ) ∂ν = ∫ x, M (f x) (fourierIntegral e ν L.flip g x) ∂μ := by by_cases hG : CompleteSpace G; swap; · simp [integral, hG] calc ∫ ξ, M.flip (g ξ) (∫ x, e (-L x ξ) • f x ∂μ) ∂ν = ∫ ξ, (∫ x, M.flip (g ξ) (e (-L x ξ) • f x) ∂μ) ∂ν := by congr with ξ apply (ContinuousLinearMap.integral_comp_comm _ _).symm exact (fourierIntegral_convergent_iff he hL _).2 hf _ = ∫ x, (∫ ξ, M.flip (g ξ) (e (-L x ξ) • f x) ∂ν) ∂μ := integral_fourierIntegral_swap M.flip he hL hf hg _ = ∫ x, (∫ ξ, M (f x) (e (-L.flip ξ x) • g ξ) ∂ν) ∂μ := by simp only [ContinuousLinearMap.flip_apply, ContinuousLinearMap.map_smul_of_tower, ContinuousLinearMap.coe_smul', Pi.smul_apply, LinearMap.flip_apply] _ = ∫ x, M (f x) (∫ ξ, e (-L.flip ξ x) • g ξ ∂ν) ∂μ := by congr with x apply ContinuousLinearMap.integral_comp_comm apply (fourierIntegral_convergent_iff he _ _).2 hg exact hL.comp continuous_swap /-- The Fourier transform satisfies `∫ 𝓕 f * g = ∫ f * 𝓕 g`, i.e., it is self-adjoint. -/ theorem integral_fourierIntegral_smul_eq_flip {f : V → ℂ} {g : W → F} (he : Continuous e) (hL : Continuous fun p : V × W ↦ L p.1 p.2) (hf : Integrable f μ) (hg : Integrable g ν) : ∫ ξ, (fourierIntegral e μ L f ξ) • (g ξ) ∂ν = ∫ x, (f x) • (fourierIntegral e ν L.flip g x) ∂μ := integral_bilin_fourierIntegral_eq_flip (ContinuousLinearMap.lsmul ℂ ℂ) he hL hf hg /-- The Fourier transform satisfies `∫ 𝓕 f * conj g = ∫ f * conj (𝓕⁻¹ g)`, which together with the Fourier inversion theorem yields Plancherel's theorem. The stated version is more convenient since it does only require integrability of `f` and `g`. Version where the multiplication is replaced by a general bilinear form `M`. -/ theorem integral_sesq_fourierIntegral_eq_neg_flip {f : V → E} {g : W → F} (M : E →L⋆[ℂ] F →L[ℂ] G) (he : Continuous e) (hL : Continuous fun p : V × W ↦ L p.1 p.2) (hf : Integrable f μ) (hg : Integrable g ν) : ∫ ξ, M (fourierIntegral e μ L f ξ) (g ξ) ∂ν = ∫ x, M (f x) (fourierIntegral e ν (-L.flip) g x) ∂μ := by by_cases hG : CompleteSpace G; swap; · simp [integral, hG] calc ∫ ξ, M.flip (g ξ) (∫ x, e (-L x ξ) • f x ∂μ) ∂ν = ∫ ξ, (∫ x, M.flip (g ξ) (e (-L x ξ) • f x) ∂μ) ∂ν := by congr with ξ apply (ContinuousLinearMap.integral_comp_commSL RCLike.conj_smul _ _).symm exact (fourierIntegral_convergent_iff he hL _).2 hf _ = ∫ x, (∫ ξ, M.flip (g ξ) (e (-L x ξ) • f x) ∂ν) ∂μ := integral_fourierIntegral_swap M.flip he hL hf hg _ = ∫ x, (∫ ξ, M (f x) (e (L.flip ξ x) • g ξ) ∂ν) ∂μ := by congr with x congr with ξ rw [← smul_one_smul ℂ _ (f x), ← smul_one_smul ℂ _ (g ξ)] simp only [map_smulₛₗ, ContinuousLinearMap.flip_apply, LinearMap.flip_apply, RingHom.id_apply, Circle.smul_def, smul_eq_mul, mul_one, ← Circle.coe_inv_eq_conj, AddChar.map_neg_eq_inv, inv_inv] _ = ∫ x, (∫ ξ, M (f x) (e (-(-L.flip ξ) x) • g ξ) ∂ν) ∂μ := by simp only [LinearMap.flip_apply, ContinuousLinearMap.map_smul_of_tower, LinearMap.neg_apply, neg_neg] _ = ∫ x, M (f x) (∫ ξ, e (-(-L.flip ξ) x) • g ξ ∂ν) ∂μ := by congr with x apply ContinuousLinearMap.integral_comp_comm have hLflip : Continuous fun (p : W × V) => (-L.flip p.1) p.2 := (continuous_neg.comp hL).comp continuous_swap exact (fourierIntegral_convergent_iff (L := -L.flip) he hLflip x).2 hg end Fubini lemma fourierIntegral_probChar {V W : Type*} {_ : MeasurableSpace V} [AddCommGroup V] [Module ℝ V] [AddCommGroup W] [Module ℝ W] (L : V →ₗ[ℝ] W →ₗ[ℝ] ℝ) (μ : Measure V) (f : V → E) (w : W) : fourierIntegral Real.probChar μ L f w = ∫ v : V, Complex.exp (- L v w * Complex.I) • f v ∂μ := by simp_rw [fourierIntegral, Circle.smul_def, Real.probChar_apply, Complex.ofReal_neg] end VectorFourier namespace VectorFourier variable {𝕜 ι E F V W : Type*} [Fintype ι] [NontriviallyNormedField 𝕜] [NormedAddCommGroup V] [NormedSpace 𝕜 V] [MeasurableSpace V] [BorelSpace V] [NormedAddCommGroup W] [NormedSpace 𝕜 W] {e : AddChar 𝕜 𝕊} {μ : Measure V} {L : V →L[𝕜] W →L[𝕜] 𝕜} [NormedAddCommGroup F] [NormedSpace ℝ F] [NormedAddCommGroup E] [NormedSpace ℂ E] {M : ι → Type*} [∀ i, NormedAddCommGroup (M i)] [∀ i, NormedSpace ℝ (M i)] theorem fourierIntegral_continuousLinearMap_apply {f : V → (F →L[ℝ] E)} {a : F} {w : W} (he : Continuous e) (hf : Integrable f μ) : fourierIntegral e μ L.toLinearMap₁₂ f w a = fourierIntegral e μ L.toLinearMap₁₂ (fun x ↦ f x a) w := by rw [fourierIntegral, ContinuousLinearMap.integral_apply] · rfl · apply (fourierIntegral_convergent_iff he _ _).2 hf exact L.continuous₂ theorem fourierIntegral_continuousMultilinearMap_apply {f : V → (ContinuousMultilinearMap ℝ M E)} {m : (i : ι) → M i} {w : W} (he : Continuous e) (hf : Integrable f μ) : fourierIntegral e μ L.toLinearMap₁₂ f w m = fourierIntegral e μ L.toLinearMap₁₂ (fun x ↦ f x m) w := by rw [fourierIntegral, ContinuousMultilinearMap.integral_apply] · rfl · apply (fourierIntegral_convergent_iff he _ _).2 hf exact L.continuous₂ end VectorFourier /-! ## Fourier theory for functions on `𝕜` -/ namespace Fourier variable {𝕜 : Type*} [CommRing 𝕜] [MeasurableSpace 𝕜] {E : Type*} [NormedAddCommGroup E] [NormedSpace ℂ E] section Defs /-- The Fourier transform integral for `f : 𝕜 → E`, with respect to the measure `μ` and additive character `e`. -/ def fourierIntegral (e : AddChar 𝕜 𝕊) (μ : Measure 𝕜) (f : 𝕜 → E) (w : 𝕜) : E := VectorFourier.fourierIntegral e μ (LinearMap.mul 𝕜 𝕜) f w theorem fourierIntegral_def (e : AddChar 𝕜 𝕊) (μ : Measure 𝕜) (f : 𝕜 → E) (w : 𝕜) : fourierIntegral e μ f w = ∫ v : 𝕜, e (-(v * w)) • f v ∂μ := rfl theorem fourierIntegral_const_smul (e : AddChar 𝕜 𝕊) (μ : Measure 𝕜) (f : 𝕜 → E) (r : ℂ) : fourierIntegral e μ (r • f) = r • fourierIntegral e μ f := VectorFourier.fourierIntegral_const_smul _ _ _ _ _ /-- The uniform norm of the Fourier transform of `f` is bounded by the `L¹` norm of `f`. -/ theorem norm_fourierIntegral_le_integral_norm (e : AddChar 𝕜 𝕊) (μ : Measure 𝕜) (f : 𝕜 → E) (w : 𝕜) : ‖fourierIntegral e μ f w‖ ≤ ∫ x : 𝕜, ‖f x‖ ∂μ := VectorFourier.norm_fourierIntegral_le_integral_norm _ _ _ _ _ /-- The Fourier transform converts right-translation into scalar multiplication by a phase factor. -/ theorem fourierIntegral_comp_add_right [MeasurableAdd 𝕜] (e : AddChar 𝕜 𝕊) (μ : Measure 𝕜) [μ.IsAddRightInvariant] (f : 𝕜 → E) (v₀ : 𝕜) : fourierIntegral e μ (f ∘ fun v ↦ v + v₀) = fun w ↦ e (v₀ * w) • fourierIntegral e μ f w := VectorFourier.fourierIntegral_comp_add_right _ _ _ _ _ end Defs end Fourier open scoped Real namespace Real open FourierTransform variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℂ E] theorem vector_fourierIntegral_eq_integral_exp_smul {V : Type*} [AddCommGroup V] [Module ℝ V] [MeasurableSpace V] {W : Type*} [AddCommGroup W] [Module ℝ W] (L : V →ₗ[ℝ] W →ₗ[ℝ] ℝ) (μ : Measure V) (f : V → E) (w : W) : VectorFourier.fourierIntegral fourierChar μ L f w = ∫ v : V, Complex.exp (↑(-2 * π * L v w) * Complex.I) • f v ∂μ := by simp_rw [VectorFourier.fourierIntegral, Circle.smul_def, Real.fourierChar_apply, mul_neg, neg_mul] /-- The Fourier integral is well defined iff the function is integrable. Version with a general continuous bilinear function `L`. For the specialization to the inner product in an inner product space, see `Real.fourierIntegral_convergent_iff`. -/ @[simp] theorem fourierIntegral_convergent_iff' {V W : Type*} [NormedAddCommGroup V] [NormedSpace ℝ V] [NormedAddCommGroup W] [NormedSpace ℝ W] [MeasurableSpace V] [BorelSpace V] {μ : Measure V} {f : V → E} (L : V →L[ℝ] W →L[ℝ] ℝ) (w : W) : Integrable (fun v : V ↦ 𝐞 (- L v w) • f v) μ ↔ Integrable f μ := VectorFourier.fourierIntegral_convergent_iff (E := E) (L := L.toLinearMap₁₂) continuous_fourierChar L.continuous₂ _ section Apply variable {ι F V W : Type*} [Fintype ι] [NormedAddCommGroup V] [NormedSpace ℝ V] [MeasurableSpace V] [BorelSpace V] [NormedAddCommGroup W] [NormedSpace ℝ W] {μ : Measure V} {L : V →L[ℝ] W →L[ℝ] ℝ} [NormedAddCommGroup F] [NormedSpace ℝ F] {M : ι → Type*} [∀ i, NormedAddCommGroup (M i)] [∀ i, NormedSpace ℝ (M i)] theorem fourierIntegral_continuousLinearMap_apply' {f : V → (F →L[ℝ] E)} {a : F} {w : W} (hf : Integrable f μ) : VectorFourier.fourierIntegral 𝐞 μ L.toLinearMap₁₂ f w a = VectorFourier.fourierIntegral 𝐞 μ L.toLinearMap₁₂ (fun x ↦ f x a) w := VectorFourier.fourierIntegral_continuousLinearMap_apply continuous_fourierChar hf theorem fourierIntegral_continuousMultilinearMap_apply' {f : V → ContinuousMultilinearMap ℝ M E} {m : (i : ι) → M i} {w : W} (hf : Integrable f μ) : VectorFourier.fourierIntegral 𝐞 μ L.toLinearMap₁₂ f w m = VectorFourier.fourierIntegral 𝐞 μ L.toLinearMap₁₂ (fun x ↦ f x m) w := VectorFourier.fourierIntegral_continuousMultilinearMap_apply continuous_fourierChar hf end Apply variable {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V] [MeasurableSpace V] [BorelSpace V] {W : Type*} [NormedAddCommGroup W] [InnerProductSpace ℝ W] [MeasurableSpace W] [BorelSpace W] [FiniteDimensional ℝ W] open scoped RealInnerProductSpace @[simp] theorem fourierIntegral_convergent_iff {μ : Measure V} {f : V → E} (w : V) : Integrable (fun v : V ↦ 𝐞 (- ⟪v, w⟫) • f v) μ ↔ Integrable f μ := fourierIntegral_convergent_iff' (innerSL ℝ) w variable [FiniteDimensional ℝ V] instance FourierTransform : FourierTransform (V → E) (V → E) where fourierTransform f := VectorFourier.fourierIntegral 𝐞 volume (innerₗ V) f instance FourierTransformInv : FourierTransformInv (V → E) (V → E) where fourierTransformInv f w := VectorFourier.fourierIntegral 𝐞 volume (-innerₗ V) f w @[deprecated (since := "2025-11-12")] alias fourierIntegral := FourierTransform.fourierTransform @[deprecated (since := "2025-11-12")] alias fourierIntegralInv := FourierTransform.fourierTransformInv lemma fourierIntegral_eq (f : V → E) (w : V) : 𝓕 f w = ∫ v, 𝐞 (-⟪v, w⟫) • f v := rfl lemma fourierIntegral_eq' (f : V → E) (w : V) : 𝓕 f w = ∫ v, Complex.exp ((↑(-2 * π * ⟪v, w⟫) * Complex.I)) • f v := by simp_rw [fourierIntegral_eq, Circle.smul_def, Real.fourierChar_apply, mul_neg, neg_mul] lemma fourierIntegralInv_eq (f : V → E) (w : V) : 𝓕⁻ f w = ∫ v, 𝐞 ⟪v, w⟫ • f v := by simp [FourierTransformInv.fourierTransformInv, VectorFourier.fourierIntegral] lemma fourierIntegralInv_eq' (f : V → E) (w : V) : 𝓕⁻ f w = ∫ v, Complex.exp ((↑(2 * π * ⟪v, w⟫) * Complex.I)) • f v := by simp_rw [fourierIntegralInv_eq, Circle.smul_def, Real.fourierChar_apply] lemma fourierIntegral_comp_linearIsometry (A : W ≃ₗᵢ[ℝ] V) (f : V → E) (w : W) : 𝓕 (f ∘ A) w = (𝓕 f) (A w) := by simp only [fourierIntegral_eq, ← A.inner_map_map, Function.comp_apply, ← MeasurePreserving.integral_comp A.measurePreserving A.toHomeomorph.measurableEmbedding] lemma fourierIntegralInv_eq_fourierIntegral_neg (f : V → E) (w : V) : 𝓕⁻ f w = 𝓕 f (-w) := by simp [fourierIntegral_eq, fourierIntegralInv_eq] lemma fourierIntegralInv_eq_fourierIntegral_comp_neg (f : V → E) : 𝓕⁻ f = 𝓕 (fun x ↦ f (-x)) := by ext y rw [fourierIntegralInv_eq_fourierIntegral_neg] change 𝓕 f (LinearIsometryEquiv.neg ℝ y) = 𝓕 (f ∘ LinearIsometryEquiv.neg ℝ) y exact (fourierIntegral_comp_linearIsometry _ _ _).symm lemma fourierIntegralInv_comm (f : V → E) : 𝓕 (𝓕⁻ f) = 𝓕⁻ (𝓕 f) := by conv_rhs => rw [fourierIntegralInv_eq_fourierIntegral_comp_neg] simp_rw [← fourierIntegralInv_eq_fourierIntegral_neg] lemma fourierIntegralInv_comp_linearIsometry (A : W ≃ₗᵢ[ℝ] V) (f : V → E) (w : W) : 𝓕⁻ (f ∘ A) w = (𝓕⁻ f) (A w) := by simp [fourierIntegralInv_eq_fourierIntegral_neg, fourierIntegral_comp_linearIsometry] theorem fourierIntegral_real_eq (f : ℝ → E) (w : ℝ) : 𝓕 f w = ∫ v : ℝ, 𝐞 (-(v * w)) • f v := by simp_rw [mul_comm _ w] rfl theorem fourierIntegral_real_eq_integral_exp_smul (f : ℝ → E) (w : ℝ) : 𝓕 f w = ∫ v : ℝ, Complex.exp (↑(-2 * π * v * w) * Complex.I) • f v := by simp_rw [fourierIntegral_real_eq, Circle.smul_def, Real.fourierChar_apply, mul_neg, neg_mul, mul_assoc] theorem fourierIntegral_continuousLinearMap_apply {F : Type*} [NormedAddCommGroup F] [NormedSpace ℝ F] {f : V → (F →L[ℝ] E)} {a : F} {v : V} (hf : Integrable f) : 𝓕 f v a = 𝓕 (fun x ↦ f x a) v := fourierIntegral_continuousLinearMap_apply' (L := innerSL ℝ) hf theorem fourierIntegral_continuousMultilinearMap_apply {ι : Type*} [Fintype ι] {M : ι → Type*} [∀ i, NormedAddCommGroup (M i)] [∀ i, NormedSpace ℝ (M i)] {f : V → ContinuousMultilinearMap ℝ M E} {m : (i : ι) → M i} {v : V} (hf : Integrable f) : 𝓕 f v m = 𝓕 (fun x ↦ f x m) v := fourierIntegral_continuousMultilinearMap_apply' (L := innerSL ℝ) hf end Real
.lake/packages/mathlib/Mathlib/Analysis/Fourier/Notation.lean
import Mathlib.Algebra.Module.Equiv.Defs /-! # Type classes for the Fourier transform In this file we define type classes for the Fourier transform and the inverse Fourier transform. We introduce the notation `𝓕` and `𝓕⁻` in these classes to denote the Fourier transform and the inverse Fourier transform, respectively. Moreover, we provide type-classes that encode the linear structure and the Fourier inversion theorem. -/ universe u v w /-- The notation typeclass for the Fourier transform. While the Fourier transform is a linear operator, the notation is for the function `E → F` without any additional properties. This makes it possible to use the notation for functions where integrability is an issue. Moreover, including a scalar multiplication causes problems for inferring the notation type class. -/ class FourierTransform (E : Type u) (F : outParam (Type v)) where /-- `𝓕 f` is the Fourier transform of `f`. The meaning of this notation is type-dependent. -/ fourierTransform : E → F /-- The notation typeclass for the inverse Fourier transform. While the inverse Fourier transform is a linear operator, the notation is for the function `E → F` without any additional properties. This makes it possible to use the notation for functions where integrability is an issue. Moreover, including a scalar multiplication causes problems for inferring the notation type class. -/ class FourierTransformInv (E : Type u) (F : outParam (Type v)) where /-- `𝓕⁻ f` is the inverse Fourier transform of `f`. The meaning of this notation is type-dependent. -/ fourierTransformInv : E → F namespace FourierTransform export FourierTransformInv (fourierTransformInv) @[inherit_doc] scoped notation "𝓕" => fourierTransform @[inherit_doc] scoped notation "𝓕⁻" => fourierTransformInv end FourierTransform section Module open scoped FourierTransform /-- A `FourierModule` is a function space on which the Fourier transform is a linear map. -/ class FourierModule (R : Type*) (E : Type*) (F : outParam (Type*)) [Add E] [Add F] [SMul R E] [SMul R F] extends FourierTransform E F where fourier_add : ∀ (f g : E), 𝓕 (f + g) = 𝓕 f + 𝓕 g fourier_smul : ∀ (r : R) (f : E), 𝓕 (r • f) = r • 𝓕 f /-- A `FourierInvModule` is a function space on which the Fourier transform is a linear map. -/ class FourierInvModule (R : Type*) (E : Type*) (F : outParam (Type*)) [Add E] [Add F] [SMul R E] [SMul R F] extends FourierTransformInv E F where fourierInv_add : ∀ (f g : E), 𝓕⁻ (f + g) = 𝓕⁻ f + 𝓕⁻ g fourierInv_smul : ∀ (r : R) (f : E), 𝓕⁻ (r • f) = r • 𝓕⁻ f namespace FourierTransform export FourierModule (fourier_add fourier_smul) export FourierInvModule (fourierInv_add fourierInv_smul) attribute [simp] fourier_add attribute [simp] fourier_smul attribute [simp] FourierInvModule.fourierInv_add attribute [simp] FourierInvModule.fourierInv_smul variable {R E F : Type*} [Semiring R] [AddCommMonoid E] [AddCommMonoid F] [Module R E] [Module R F] section fourierₗ variable [FourierModule R E F] variable (R E F) in /-- The Fourier transform as a linear map. -/ def fourierₗ : E →ₗ[R] F where toFun := 𝓕 map_add' := fourier_add map_smul' := fourier_smul @[simp] lemma fourierₗ_apply (f : E) : fourierₗ R E F f = 𝓕 f := rfl @[simp] lemma fourier_zero : 𝓕 (0 : E) = 0 := (fourierₗ R E F).map_zero end fourierₗ section fourierInvₗ variable [FourierInvModule R E F] variable (R E F) in /-- The inverse Fourier transform as a linear map. -/ def fourierInvₗ : E →ₗ[R] F where toFun := 𝓕⁻ map_add' := fourierInv_add map_smul' := fourierInv_smul @[simp] lemma fourierInvₗ_apply (f : E) : fourierInvₗ R E F f = 𝓕⁻ f := rfl @[simp] lemma fourierInv_zero : 𝓕⁻ (0 : E) = 0 := (fourierInvₗ R E F).map_zero end fourierInvₗ end FourierTransform end Module section Pair open FourierTransform /-- A `FourierPair` is a pair of spaces `E` and `F` such that `𝓕⁻ ∘ 𝓕 = id` on `E`. -/ class FourierPair (E F : Type*) [FourierTransform E F] [FourierTransformInv F E] where inv_fourier : ∀ (f : E), 𝓕⁻ (𝓕 f) = f /-- A `FourierInvPair` is a pair of spaces `E` and `F` such that `𝓕 ∘ 𝓕⁻ = id` on `E`. -/ class FourierInvPair (E F : Type*) [FourierTransform F E] [FourierTransformInv E F] where fourier_inv : ∀ (f : E), 𝓕 (𝓕⁻ f) = f namespace FourierTransform export FourierPair (inv_fourier) export FourierInvPair (fourier_inv) attribute [simp] inv_fourier attribute [simp] fourier_inv variable {R E F : Type*} [Semiring R] [AddCommMonoid E] [AddCommMonoid F] [Module R E] [Module R F] [FourierModule R E F] [FourierInvModule R F E] [FourierPair E F] [FourierInvPair F E] variable (R E F) in /-- The Fourier transform as a linear equivalence. -/ def fourierEquiv : E ≃ₗ[R] F where __ := fourierₗ R E F invFun := 𝓕⁻ left_inv := inv_fourier right_inv := fourier_inv @[simp] lemma fourierEquiv_apply (f : E) : fourierEquiv R E F f = 𝓕 f := rfl @[simp] lemma fourierEquiv_symm_apply (f : F) : (fourierEquiv R E F).symm f = 𝓕⁻ f := rfl end FourierTransform end Pair
.lake/packages/mathlib/Mathlib/Analysis/Fourier/PoissonSummation.lean
import Mathlib.Analysis.Fourier.AddCircle import Mathlib.Analysis.Fourier.FourierTransform import Mathlib.Analysis.PSeries import Mathlib.Analysis.Distribution.FourierSchwartz import Mathlib.MeasureTheory.Measure.Lebesgue.Integral import Mathlib.Topology.ContinuousMap.Periodic /-! # Poisson's summation formula We prove Poisson's summation formula `∑ (n : ℤ), f n = ∑ (n : ℤ), 𝓕 f n`, where `𝓕 f` is the Fourier transform of `f`, under the following hypotheses: * `f` is a continuous function `ℝ → ℂ`. * The sum `∑ (n : ℤ), 𝓕 f n` is convergent. * For all compacts `K ⊂ ℝ`, the sum `∑ (n : ℤ), sup { ‖f(x + n)‖ | x ∈ K }` is convergent. See `Real.tsum_eq_tsum_fourierIntegral` for this formulation. These hypotheses are potentially a little awkward to apply, so we also provide the less general but easier-to-use result `Real.tsum_eq_tsum_fourierIntegral_of_rpow_decay`, in which we assume `f` and `𝓕 f` both decay as `|x| ^ (-b)` for some `b > 1`, and the even more specific result `SchwartzMap.tsum_eq_tsum_fourierIntegral`, where we assume that `f` is a Schwartz function. -/ noncomputable section open Function hiding comp_apply open Set hiding restrict_apply open Complex open Real open TopologicalSpace Filter MeasureTheory Asymptotics open scoped Real Filter FourierTransform open ContinuousMap /-- The key lemma for Poisson summation: the `m`-th Fourier coefficient of the periodic function `∑' n : ℤ, f (x + n)` is the value at `m` of the Fourier transform of `f`. -/ theorem Real.fourierCoeff_tsum_comp_add {f : C(ℝ, ℂ)} (hf : ∀ K : Compacts ℝ, Summable fun n : ℤ => ‖(f.comp (ContinuousMap.addRight n)).restrict K‖) (m : ℤ) : fourierCoeff (Periodic.lift <| f.periodic_tsum_comp_add_zsmul 1) m = 𝓕 (f : ℝ → ℂ) m := by -- NB: This proof can be shortened somewhat by telescoping together some of the steps in the calc -- block, but I think it's more legible this way. We start with preliminaries about the integrand. let e : C(ℝ, ℂ) := (fourier (-m)).comp ⟨((↑) : ℝ → UnitAddCircle), continuous_quotient_mk'⟩ have neK : ∀ (K : Compacts ℝ) (g : C(ℝ, ℂ)), ‖(e * g).restrict K‖ = ‖g.restrict K‖ := by have (x : ℝ) : ‖e x‖ = 1 := (AddCircle.toCircle (-m • x)).norm_coe intro K g simp_rw [norm_eq_iSup_norm, restrict_apply, mul_apply, norm_mul, this, one_mul] have eadd : ∀ (n : ℤ), e.comp (ContinuousMap.addRight n) = e := by intro n; ext1 x have : Periodic e 1 := Periodic.comp (fun x => AddCircle.coe_add_period 1 x) (fourier (-m)) simpa only [mul_one] using this.int_mul n x -- Now the main argument. First unwind some definitions. calc fourierCoeff (Periodic.lift <| f.periodic_tsum_comp_add_zsmul 1) m = ∫ x in (0 : ℝ)..1, e x * (∑' n : ℤ, f.comp (ContinuousMap.addRight n)) x := by simp_rw [fourierCoeff_eq_intervalIntegral _ m 0, div_one, one_smul, zero_add, e, comp_apply, coe_mk, Periodic.lift_coe, zsmul_one, smul_eq_mul] -- Transform sum in C(ℝ, ℂ) evaluated at x into pointwise sum of values. _ = ∫ x in (0 : ℝ)..1, ∑' n : ℤ, (e * f.comp (ContinuousMap.addRight n)) x := by simp_rw [coe_mul, Pi.mul_apply, ← ContinuousMap.tsum_apply (summable_of_locally_summable_norm hf), tsum_mul_left] -- Swap sum and integral. _ = ∑' n : ℤ, ∫ x in (0 : ℝ)..1, (e * f.comp (ContinuousMap.addRight n)) x := by refine (intervalIntegral.tsum_intervalIntegral_eq_of_summable_norm ?_).symm convert hf ⟨uIcc 0 1, isCompact_uIcc⟩ using 1 exact funext fun n => neK _ _ _ = ∑' n : ℤ, ∫ x in (0 : ℝ)..1, (e * f).comp (ContinuousMap.addRight n) x := by simp only [mul_comp] at eadd ⊢ simp_rw [eadd] -- Rearrange sum of interval integrals into an integral over `ℝ`. _ = ∫ x, e x * f x := by suffices Integrable (e * f) from this.hasSum_intervalIntegral_comp_add_int.tsum_eq apply integrable_of_summable_norm_Icc convert hf ⟨Icc 0 1, isCompact_Icc⟩ using 1 simp_rw [mul_comp] at eadd ⊢ simp_rw [eadd] exact funext fun n => neK ⟨Icc 0 1, isCompact_Icc⟩ _ -- Minor tidying to finish _ = 𝓕 (f : ℝ → ℂ) m := by rw [fourierIntegral_real_eq_integral_exp_smul] congr 1 with x : 1 rw [smul_eq_mul, comp_apply, coe_mk, coe_mk, ContinuousMap.toFun_eq_coe, fourier_coe_apply] congr 2 push_cast ring /-- **Poisson's summation formula**, most general form. -/ theorem Real.tsum_eq_tsum_fourierIntegral {f : C(ℝ, ℂ)} (h_norm : ∀ K : Compacts ℝ, Summable fun n : ℤ => ‖(f.comp <| ContinuousMap.addRight n).restrict K‖) (h_sum : Summable fun n : ℤ => 𝓕 (f : ℝ → ℂ) n) (x : ℝ) : ∑' n : ℤ, f (x + n) = ∑' n : ℤ, 𝓕 (f : ℝ → ℂ) n * fourier n (x : UnitAddCircle) := by let F : C(UnitAddCircle, ℂ) := ⟨(f.periodic_tsum_comp_add_zsmul 1).lift, continuous_coinduced_dom.mpr (map_continuous _)⟩ have : Summable (fourierCoeff F) := by convert h_sum exact Real.fourierCoeff_tsum_comp_add h_norm _ convert (has_pointwise_sum_fourier_series_of_summable this x).tsum_eq.symm using 1 · simpa only [F, coe_mk, ← QuotientAddGroup.mk_zero, Periodic.lift_coe, zsmul_one, comp_apply, coe_addRight, zero_add] using (hasSum_apply (summable_of_locally_summable_norm h_norm).hasSum x).tsum_eq · simp_rw [← Real.fourierCoeff_tsum_comp_add h_norm, smul_eq_mul, F, coe_mk] section RpowDecay variable {E : Type*} [NormedAddCommGroup E] /-- If `f` is `O(x ^ (-b))` at infinity, then so is the function `fun x ↦ ‖f.restrict (Icc (x + R) (x + S))‖` for any fixed `R` and `S`. -/ theorem isBigO_norm_Icc_restrict_atTop {f : C(ℝ, E)} {b : ℝ} (hb : 0 < b) (hf : f =O[atTop] fun x : ℝ => |x| ^ (-b)) (R S : ℝ) : (fun x : ℝ => ‖f.restrict (Icc (x + R) (x + S))‖) =O[atTop] fun x : ℝ => |x| ^ (-b) := by -- First establish an explicit estimate on decay of inverse powers. -- This is logically independent of the rest of the proof, but of no mathematical interest in -- itself, so it is proved in-line rather than being formulated as a separate lemma. have claim : ∀ x : ℝ, max 0 (-2 * R) < x → ∀ y : ℝ, x + R ≤ y → y ^ (-b) ≤ (1 / 2) ^ (-b) * x ^ (-b) := fun x hx y hy ↦ by rw [max_lt_iff] at hx obtain ⟨hx1, hx2⟩ := hx rw [← mul_rpow] <;> try positivity apply rpow_le_rpow_of_nonpos <;> linarith -- Now the main proof. obtain ⟨c, hc, hc'⟩ := hf.exists_pos simp only [IsBigO, IsBigOWith, eventually_atTop] at hc' ⊢ obtain ⟨d, hd⟩ := hc' refine ⟨c * (1 / 2) ^ (-b), ⟨max (1 + max 0 (-2 * R)) (d - R), fun x hx => ?_⟩⟩ rw [ge_iff_le, max_le_iff] at hx have hx' : max 0 (-2 * R) < x := by linarith rw [max_lt_iff] at hx' rw [norm_norm, ContinuousMap.norm_le _ (by positivity)] refine fun y => (hd y.1 (by linarith [hx.1, y.2.1])).trans ?_ have A : ∀ x : ℝ, 0 ≤ |x| ^ (-b) := fun x => by positivity rw [mul_assoc, mul_le_mul_iff_right₀ hc, norm_of_nonneg (A _), norm_of_nonneg (A _)] convert claim x (by linarith only [hx.1]) y.1 y.2.1 · apply abs_of_nonneg; linarith [y.2.1] · exact abs_of_pos hx'.1 theorem isBigO_norm_Icc_restrict_atBot {f : C(ℝ, E)} {b : ℝ} (hb : 0 < b) (hf : f =O[atBot] fun x : ℝ => |x| ^ (-b)) (R S : ℝ) : (fun x : ℝ => ‖f.restrict (Icc (x + R) (x + S))‖) =O[atBot] fun x : ℝ => |x| ^ (-b) := by have h1 : (f.comp (ContinuousMap.mk _ continuous_neg)) =O[atTop] fun x : ℝ => |x| ^ (-b) := by convert hf.comp_tendsto tendsto_neg_atTop_atBot using 1 ext1 x; simp only [Function.comp_apply, abs_neg] have h2 := (isBigO_norm_Icc_restrict_atTop hb h1 (-S) (-R)).comp_tendsto tendsto_neg_atBot_atTop have : (fun x : ℝ => |x| ^ (-b)) ∘ Neg.neg = fun x : ℝ => |x| ^ (-b) := by ext1 x; simp only [Function.comp_apply, abs_neg] rw [this] at h2 refine (isBigO_of_le _ fun x => ?_).trans h2 -- equality holds, but less work to prove `≤` alone rw [norm_norm, Function.comp_apply, norm_norm, ContinuousMap.norm_le _ (norm_nonneg _)] rintro ⟨x, hx⟩ rw [ContinuousMap.restrict_apply_mk] refine (le_of_eq ?_).trans (ContinuousMap.norm_coe_le_norm _ ⟨-x, ?_⟩) · rw [ContinuousMap.restrict_apply_mk, ContinuousMap.comp_apply, ContinuousMap.coe_mk, ContinuousMap.coe_mk, neg_neg] · exact ⟨by linarith [hx.2], by linarith [hx.1]⟩ theorem isBigO_norm_restrict_cocompact (f : C(ℝ, E)) {b : ℝ} (hb : 0 < b) (hf : f =O[cocompact ℝ] fun x : ℝ => |x| ^ (-b)) (K : Compacts ℝ) : (fun x => ‖(f.comp (ContinuousMap.addRight x)).restrict K‖) =O[cocompact ℝ] (|·| ^ (-b)) := by obtain ⟨r, hr⟩ := K.isCompact.isBounded.subset_closedBall 0 rw [closedBall_eq_Icc, zero_add, zero_sub] at hr have : ∀ x : ℝ, ‖(f.comp (ContinuousMap.addRight x)).restrict K‖ ≤ ‖f.restrict (Icc (x - r) (x + r))‖ := by intro x rw [ContinuousMap.norm_le _ (norm_nonneg _)] rintro ⟨y, hy⟩ refine (le_of_eq ?_).trans (ContinuousMap.norm_coe_le_norm _ ⟨y + x, ?_⟩) · simp_rw [ContinuousMap.restrict_apply, ContinuousMap.comp_apply, ContinuousMap.coe_addRight] · exact ⟨by linarith [(hr hy).1], by linarith [(hr hy).2]⟩ simp_rw [cocompact_eq_atBot_atTop, isBigO_sup] at hf ⊢ constructor · refine (isBigO_of_le atBot ?_).trans (isBigO_norm_Icc_restrict_atBot hb hf.1 (-r) r) simp_rw [norm_norm]; exact this · refine (isBigO_of_le atTop ?_).trans (isBigO_norm_Icc_restrict_atTop hb hf.2 (-r) r) simp_rw [norm_norm]; exact this /-- **Poisson's summation formula**, assuming that `f` decays as `|x| ^ (-b)` for some `1 < b` and its Fourier transform is summable. -/ theorem Real.tsum_eq_tsum_fourierIntegral_of_rpow_decay_of_summable {f : ℝ → ℂ} (hc : Continuous f) {b : ℝ} (hb : 1 < b) (hf : IsBigO (cocompact ℝ) f fun x : ℝ => |x| ^ (-b)) (hFf : Summable fun n : ℤ => 𝓕 f n) (x : ℝ) : ∑' n : ℤ, f (x + n) = ∑' n : ℤ, 𝓕 f n * fourier n (x : UnitAddCircle) := Real.tsum_eq_tsum_fourierIntegral (fun K => summable_of_isBigO (Real.summable_abs_int_rpow hb) ((isBigO_norm_restrict_cocompact ⟨_, hc⟩ (zero_lt_one.trans hb) hf K).comp_tendsto Int.tendsto_coe_cofinite)) hFf x /-- **Poisson's summation formula**, assuming that both `f` and its Fourier transform decay as `|x| ^ (-b)` for some `1 < b`. (This is the one-dimensional case of Corollary VII.2.6 of Stein and Weiss, *Introduction to Fourier analysis on Euclidean spaces*.) -/ theorem Real.tsum_eq_tsum_fourierIntegral_of_rpow_decay {f : ℝ → ℂ} (hc : Continuous f) {b : ℝ} (hb : 1 < b) (hf : f =O[cocompact ℝ] (|·| ^ (-b))) (hFf : (𝓕 f) =O[cocompact ℝ] (|·| ^ (-b))) (x : ℝ) : ∑' n : ℤ, f (x + n) = ∑' n : ℤ, 𝓕 f n * fourier n (x : UnitAddCircle) := Real.tsum_eq_tsum_fourierIntegral_of_rpow_decay_of_summable hc hb hf (summable_of_isBigO (Real.summable_abs_int_rpow hb) (hFf.comp_tendsto Int.tendsto_coe_cofinite)) x end RpowDecay section Schwartz open scoped SchwartzMap /-- **Poisson's summation formula** for Schwartz functions. -/ theorem SchwartzMap.tsum_eq_tsum_fourierIntegral (f : 𝓢(ℝ, ℂ)) (x : ℝ) : ∑' n : ℤ, f (x + n) = ∑' n : ℤ, 𝓕 f n * fourier n (x : UnitAddCircle) := by -- We know that Schwartz functions are `O(‖x ^ (-b)‖)` for *every* `b`; for this argument we take -- `b = 2` and work with that. apply Real.tsum_eq_tsum_fourierIntegral_of_rpow_decay f.continuous one_lt_two (f.isBigO_cocompact_rpow (-2)) ((𝓕 f).isBigO_cocompact_rpow (-2)) end Schwartz
.lake/packages/mathlib/Mathlib/Analysis/Fourier/RiemannLebesgueLemma.lean
import Mathlib.Analysis.Fourier.FourierTransform import Mathlib.Analysis.InnerProductSpace.Dual import Mathlib.Analysis.InnerProductSpace.EuclideanDist import Mathlib.MeasureTheory.Function.ContinuousMapDense import Mathlib.MeasureTheory.Group.Integral import Mathlib.MeasureTheory.Integral.Bochner.Set import Mathlib.Topology.EMetricSpace.Paracompact import Mathlib.MeasureTheory.Measure.Haar.Unique /-! # The Riemann-Lebesgue Lemma In this file we prove the Riemann-Lebesgue lemma, for functions on finite-dimensional real vector spaces `V`: if `f` is a function on `V` (valued in a complete normed space `E`), then the Fourier transform of `f`, viewed as a function on the dual space of `V`, tends to 0 along the cocompact filter. Here the Fourier transform is defined by `fun w : StrongDual ℝ V ↦ ∫ (v : V), exp (↑(2 * π * w v) * I) • f v`. This is true for arbitrary functions, but is only interesting for `L¹` functions (if `f` is not integrable then the integral is zero for all `w`). This is proved first for continuous compactly-supported functions on inner-product spaces; then we pass to arbitrary functions using the density of continuous compactly-supported functions in `L¹` space. Finally we generalise from inner-product spaces to arbitrary finite-dimensional spaces, by choosing a continuous linear equivalence to an inner-product space. ## Main results - `tendsto_integral_exp_inner_smul_cocompact` : for `V` a finite-dimensional real inner product space and `f : V → E`, the function `fun w : V ↦ ∫ v : V, exp (2 * π * ⟪w, v⟫ * I) • f v` tends to 0 along `cocompact V`. - `tendsto_integral_exp_smul_cocompact` : for `V` a finite-dimensional real vector space (endowed with its unique Hausdorff topological vector space structure), and `W` the dual of `V`, the function `fun w : W ↦ ∫ v : V, exp (2 * π * w v * I) • f v` tends to along `cocompact W`. - `Real.tendsto_integral_exp_smul_cocompact`: special case of functions on `ℝ`. - `Real.zero_at_infty_fourierIntegral` and `Real.zero_at_infty_vector_fourierIntegral`: reformulations explicitly using the Fourier integral. -/ noncomputable section open MeasureTheory Filter Complex Set Module open scoped Filter Topology Real ENNReal FourierTransform RealInnerProductSpace NNReal variable {E V : Type*} [NormedAddCommGroup E] [NormedSpace ℂ E] {f : V → E} section InnerProductSpace variable [NormedAddCommGroup V] [MeasurableSpace V] [BorelSpace V] [InnerProductSpace ℝ V] [FiniteDimensional ℝ V] local notation3 "i" => fun (w : V) => (1 / (2 * ‖w‖ ^ 2) : ℝ) • w /-- Shifting `f` by `(1 / (2 * ‖w‖ ^ 2)) • w` negates the integral in the Riemann-Lebesgue lemma. -/ theorem fourierIntegral_half_period_translate {w : V} (hw : w ≠ 0) : (∫ v : V, 𝐞 (-⟪v, w⟫) • f (v + i w)) = -∫ v : V, 𝐞 (-⟪v, w⟫) • f v := by have hiw : ⟪i w, w⟫ = 1 / 2 := by rw [inner_smul_left, inner_self_eq_norm_sq_to_K, RCLike.ofReal_real_eq_id, id, RCLike.conj_to_real, ← div_div, div_mul_cancel₀] rwa [Ne, sq_eq_zero_iff, norm_eq_zero] have : (fun v : V => 𝐞 (-⟪v, w⟫) • f (v + i w)) = fun v : V => (fun x : V => -(𝐞 (-⟪x, w⟫) • f x)) (v + i w) := by ext1 v simp_rw [inner_add_left, hiw, Circle.smul_def, Real.fourierChar_apply, neg_add, mul_add, ofReal_add, add_mul, exp_add] match_scalars have H : exp (- (π * I)) = (-1)⁻¹ := by rw [exp_neg, exp_pi_mul_I] linear_combination (norm := ring_nf) cexp (-2 * π * ⟪v, w⟫ * I) * H rw [this, integral_add_right_eq_self (fun (x : V) ↦ -(𝐞 (-⟪x, w⟫) • f x)) ((fun w ↦ (1 / (2 * ‖w‖ ^ (2 : ℕ))) • w) w)] simp only [integral_neg] /-- Rewrite the Fourier integral in a form that allows us to use uniform continuity. -/ theorem fourierIntegral_eq_half_sub_half_period_translate {w : V} (hw : w ≠ 0) (hf : Integrable f) : ∫ v : V, 𝐞 (-⟪v, w⟫) • f v = (1 / (2 : ℂ)) • ∫ v : V, 𝐞 (-⟪v, w⟫) • (f v - f (v + i w)) := by simp_rw [smul_sub] rw [integral_sub, fourierIntegral_half_period_translate hw, sub_eq_add_neg, neg_neg, ← two_smul ℂ _, ← @smul_assoc _ _ _ _ _ _ (IsScalarTower.left ℂ), smul_eq_mul] · simp exacts [(Real.fourierIntegral_convergent_iff w).2 hf, (Real.fourierIntegral_convergent_iff w).2 (hf.comp_add_right _)] /-- Riemann-Lebesgue Lemma for continuous and compactly-supported functions: the integral `∫ v, exp (-2 * π * ⟪w, v⟫ * I) • f v` tends to 0 w.r.t. `cocompact V`. Note that this is primarily of interest as a preparatory step for the more general result `tendsto_integral_exp_inner_smul_cocompact` in which `f` can be arbitrary. -/ theorem tendsto_integral_exp_inner_smul_cocompact_of_continuous_compact_support (hf1 : Continuous f) (hf2 : HasCompactSupport f) : Tendsto (fun w : V => ∫ v : V, 𝐞 (-⟪v, w⟫) • f v) (cocompact V) (𝓝 0) := by refine NormedAddCommGroup.tendsto_nhds_zero.mpr fun ε hε => ?_ suffices ∃ T : ℝ, ∀ w : V, T ≤ ‖w‖ → ‖∫ v : V, 𝐞 (-⟪v, w⟫) • f v‖ < ε by simp_rw [← comap_dist_left_atTop_eq_cocompact (0 : V), eventually_comap, eventually_atTop, dist_eq_norm', sub_zero] exact let ⟨T, hT⟩ := this ⟨T, fun b hb v hv => hT v (hv.symm ▸ hb)⟩ obtain ⟨R, -, hR_bd⟩ : ∃ R : ℝ, 0 < R ∧ ∀ x : V, R ≤ ‖x‖ → f x = 0 := hf2.exists_pos_le_norm let A := {v : V | ‖v‖ ≤ R + 1} have mA : MeasurableSet A := by suffices A = Metric.closedBall (0 : V) (R + 1) by rw [this] exact Metric.isClosed_closedBall.measurableSet simp_rw [A, Metric.closedBall, dist_eq_norm, sub_zero] obtain ⟨B, hB_pos, hB_vol⟩ : ∃ B : ℝ≥0, 0 < B ∧ volume A ≤ B := by have hc : IsCompact A := by simpa only [Metric.closedBall, dist_eq_norm, sub_zero] using isCompact_closedBall (0 : V) _ let B₀ := volume A replace hc : B₀ < ⊤ := hc.measure_lt_top refine ⟨B₀.toNNReal + 1, add_pos_of_nonneg_of_pos B₀.toNNReal.coe_nonneg one_pos, ?_⟩ rw [ENNReal.coe_add, ENNReal.coe_one, ENNReal.coe_toNNReal hc.ne] exact le_self_add --* Use uniform continuity to choose δ such that `‖x - y‖ < δ` implies `‖f x - f y‖ < ε / B`. obtain ⟨δ, hδ1, hδ2⟩ := Metric.uniformContinuous_iff.mp (hf2.uniformContinuous_of_continuous hf1) (ε / B) (div_pos hε hB_pos) refine ⟨1 / 2 + 1 / (2 * δ), fun w hw_bd => ?_⟩ have hw_ne : w ≠ 0 := by contrapose! hw_bd; rw [hw_bd, norm_zero] exact add_pos one_half_pos (one_div_pos.mpr <| mul_pos two_pos hδ1) have hw'_nm : ‖i w‖ = 1 / (2 * ‖w‖) := by rw [norm_smul, norm_div, Real.norm_of_nonneg (mul_nonneg two_pos.le <| sq_nonneg _), norm_one, sq, ← div_div, ← div_div, ← div_div, div_mul_cancel₀ _ (norm_eq_zero.not.mpr hw_ne)] --* Rewrite integral in terms of `f v - f (v + w')`. have : ‖(1 / 2 : ℂ)‖ = 2⁻¹ := by simp rw [fourierIntegral_eq_half_sub_half_period_translate hw_ne (hf1.integrable_of_hasCompactSupport hf2), norm_smul, this, inv_mul_eq_div, div_lt_iff₀' two_pos] refine lt_of_le_of_lt (norm_integral_le_integral_norm _) ?_ simp_rw [Circle.norm_smul] --* Show integral can be taken over A only. have int_A : ∫ v : V, ‖f v - f (v + i w)‖ = ∫ v in A, ‖f v - f (v + i w)‖ := by refine (setIntegral_eq_integral_of_forall_compl_eq_zero fun v hv => ?_).symm dsimp only [A] at hv simp only [mem_setOf, not_le] at hv rw [hR_bd v _, hR_bd (v + i w) _, sub_zero, norm_zero] · rw [← sub_neg_eq_add] refine le_trans ?_ (norm_sub_norm_le _ _) rw [le_sub_iff_add_le, norm_neg] refine le_trans ?_ hv.le rw [add_le_add_iff_left, hw'_nm, ← div_div] refine (div_le_one <| norm_pos_iff.mpr hw_ne).mpr ?_ refine le_trans (le_add_of_nonneg_right <| one_div_nonneg.mpr <| ?_) hw_bd exact (mul_pos (zero_lt_two' ℝ) hδ1).le · exact (le_add_of_nonneg_right zero_le_one).trans hv.le rw [int_A]; clear int_A --* Bound integral using fact that `‖f v - f (v + w')‖` is small. have bdA : ∀ v : V, v ∈ A → ‖‖f v - f (v + i w)‖‖ ≤ ε / B := by simp_rw [norm_norm] simp_rw [dist_eq_norm] at hδ2 refine fun x _ => (hδ2 ?_).le rw [sub_add_cancel_left, norm_neg, hw'_nm, ← div_div, div_lt_iff₀ (norm_pos_iff.mpr hw_ne), ← div_lt_iff₀' hδ1, div_div] exact (lt_add_of_pos_left _ one_half_pos).trans_le hw_bd have bdA2 := norm_setIntegral_le_of_norm_le_const (hB_vol.trans_lt ENNReal.coe_lt_top) bdA have : ‖_‖ = ∫ v : V in A, ‖f v - f (v + i w)‖ := Real.norm_of_nonneg (setIntegral_nonneg mA fun x _ => norm_nonneg _) rw [this] at bdA2 refine bdA2.trans_lt ?_ rw [div_mul_eq_mul_div, div_lt_iff₀ (NNReal.coe_pos.mpr hB_pos), mul_comm (2 : ℝ), mul_assoc, mul_lt_mul_iff_right₀ hε] refine (ENNReal.toReal_mono ENNReal.coe_ne_top hB_vol).trans_lt ?_ rw [ENNReal.coe_toReal, two_mul] exact lt_add_of_pos_left _ hB_pos variable (f) /-- Riemann-Lebesgue lemma for functions on a real inner-product space: the integral `∫ v, exp (-2 * π * ⟪w, v⟫ * I) • f v` tends to 0 as `w → ∞`. -/ theorem tendsto_integral_exp_inner_smul_cocompact : Tendsto (fun w : V => ∫ v, 𝐞 (-⟪v, w⟫) • f v) (cocompact V) (𝓝 0) := by by_cases hfi : Integrable f; swap · convert tendsto_const_nhds (x := (0 : E)) with w apply integral_undef rwa [Real.fourierIntegral_convergent_iff] refine Metric.tendsto_nhds.mpr fun ε hε => ?_ obtain ⟨g, hg_supp, hfg, hg_cont, -⟩ := hfi.exists_hasCompactSupport_integral_sub_le (div_pos hε two_pos) refine ((Metric.tendsto_nhds.mp (tendsto_integral_exp_inner_smul_cocompact_of_continuous_compact_support hg_cont hg_supp)) _ (div_pos hε two_pos)).mp (Eventually.of_forall fun w hI => ?_) rw [dist_eq_norm] at hI ⊢ have : ‖(∫ v, 𝐞 (-⟪v, w⟫) • f v) - ∫ v, 𝐞 (-⟪v, w⟫) • g v‖ ≤ ε / 2 := by refine le_trans ?_ hfg simp_rw [← integral_sub ((Real.fourierIntegral_convergent_iff w).2 hfi) ((Real.fourierIntegral_convergent_iff w).2 (hg_cont.integrable_of_hasCompactSupport hg_supp)), ← smul_sub, ← Pi.sub_apply] exact VectorFourier.norm_fourierIntegral_le_integral_norm 𝐞 _ bilinFormOfRealInner (f - g) w replace := add_lt_add_of_le_of_lt this hI rw [add_halves] at this refine ((le_of_eq ?_).trans (norm_add_le _ _)).trans_lt this simp only [sub_zero, sub_add_cancel] /-- The Riemann-Lebesgue lemma for functions on `ℝ`. -/ theorem Real.tendsto_integral_exp_smul_cocompact (f : ℝ → E) : Tendsto (fun w : ℝ => ∫ v : ℝ, 𝐞 (-(v * w)) • f v) (cocompact ℝ) (𝓝 0) := by simp_rw [mul_comm] exact tendsto_integral_exp_inner_smul_cocompact f /-- The Riemann-Lebesgue lemma for functions on `ℝ`, formulated via `Real.fourierIntegral`. -/ theorem Real.zero_at_infty_fourierIntegral (f : ℝ → E) : Tendsto (𝓕 f) (cocompact ℝ) (𝓝 0) := tendsto_integral_exp_inner_smul_cocompact f /-- Riemann-Lebesgue lemma for functions on a finite-dimensional inner-product space, formulated via dual space. **Do not use** -- it is only a stepping stone to `tendsto_integral_exp_smul_cocompact` where the inner-product-space structure isn't required. -/ theorem tendsto_integral_exp_smul_cocompact_of_inner_product (μ : Measure V) [μ.IsAddHaarMeasure] : Tendsto (fun w : StrongDual ℝ V => ∫ v, 𝐞 (-w v) • f v ∂μ) (cocompact (StrongDual ℝ V)) (𝓝 0) := by rw [μ.isAddLeftInvariant_eq_smul volume] simp_rw [integral_smul_nnreal_measure] rw [← (smul_zero _ : Measure.addHaarScalarFactor μ volume • (0 : E) = 0)] apply Tendsto.const_smul let A := (InnerProductSpace.toDual ℝ V).symm have : (fun w : StrongDual ℝ V ↦ ∫ v, 𝐞 (-w v) • f v) = (fun w : V ↦ ∫ v, 𝐞 (-⟪v, w⟫) • f v) ∘ A := by ext1 w congr 1 with v : 1 rw [← inner_conj_symm, RCLike.conj_to_real, InnerProductSpace.toDual_symm_apply] rw [this] exact (tendsto_integral_exp_inner_smul_cocompact f).comp A.toHomeomorph.toCocompactMap.cocompact_tendsto' end InnerProductSpace section NoInnerProduct variable (f) [AddCommGroup V] [TopologicalSpace V] [IsTopologicalAddGroup V] [T2Space V] [MeasurableSpace V] [BorelSpace V] [Module ℝ V] [ContinuousSMul ℝ V] [FiniteDimensional ℝ V] /-- Riemann-Lebesgue lemma for functions on a finite-dimensional real vector space, formulated via dual space. -/ theorem tendsto_integral_exp_smul_cocompact (μ : Measure V) [μ.IsAddHaarMeasure] : Tendsto (fun w : StrongDual ℝ V => ∫ v, 𝐞 (-w v) • f v ∂μ) (cocompact (StrongDual ℝ V)) (𝓝 0) := by -- We have already proved the result for inner-product spaces, formulated in a way which doesn't -- refer to the inner product. So we choose an arbitrary inner-product space isomorphic to V -- and port the result over from there. let V' := EuclideanSpace ℝ (Fin (finrank ℝ V)) have A : V ≃L[ℝ] V' := toEuclidean borelize V' -- various equivs derived from A let Aₘ : MeasurableEquiv V V' := A.toHomeomorph.toMeasurableEquiv -- isomorphism between duals derived from A let Adual : StrongDual ℝ V ≃L[ℝ] StrongDual ℝ V' := A.arrowCongrSL (.refl _ _) have : (μ.map Aₘ).IsAddHaarMeasure := A.isAddHaarMeasure_map _ convert (tendsto_integral_exp_smul_cocompact_of_inner_product (f ∘ A.symm) (μ.map Aₘ)).comp Adual.toHomeomorph.toCocompactMap.cocompact_tendsto' with w suffices ∫ v, 𝐞 (-w v) • f v ∂μ = ∫ (x : V), 𝐞 (-w (A.symm (Aₘ x))) • f (A.symm (Aₘ x)) ∂μ by simpa [Function.comp_apply, integral_map_equiv, Adual] simp [Aₘ] /-- The Riemann-Lebesgue lemma, formulated in terms of `VectorFourier.fourierIntegral` (with the pairing in the definition of `fourierIntegral` taken to be the canonical pairing between `V` and its dual space). -/ theorem Real.zero_at_infty_vector_fourierIntegral (μ : Measure V) [μ.IsAddHaarMeasure] : Tendsto (VectorFourier.fourierIntegral 𝐞 μ (topDualPairing ℝ V).flip f) (cocompact (StrongDual ℝ V)) (𝓝 0) := _root_.tendsto_integral_exp_smul_cocompact f μ end NoInnerProduct
.lake/packages/mathlib/Mathlib/Analysis/Fourier/ZMod.lean
import Mathlib.Algebra.Group.EvenFunction import Mathlib.Analysis.SpecialFunctions.Complex.CircleAddChar import Mathlib.Analysis.Fourier.FourierTransform import Mathlib.NumberTheory.DirichletCharacter.GaussSum /-! # Fourier theory on `ZMod N` Basic definitions and properties of the discrete Fourier transform for functions on `ZMod N` (taking values in an arbitrary `ℂ`-vector space). ### Main definitions and results * `ZMod.dft`: the Fourier transform, with respect to the standard additive character `ZMod.stdAddChar` (mapping `j mod N` to `exp (2 * π * I * j / N)`). The notation `𝓕`, scoped in namespace `ZMod`, is available for this. * `ZMod.dft_dft`: the Fourier inversion formula. * `DirichletCharacter.fourierTransform_eq_inv_mul_gaussSum`: the discrete Fourier transform of a primitive Dirichlet character `χ` is a Gauss sum times `χ⁻¹`. -/ open MeasureTheory Finset AddChar ZMod namespace ZMod variable {N : ℕ} [NeZero N] {E : Type*} [AddCommGroup E] [Module ℂ E] section private_defs /- It doesn't _quite_ work to define the Fourier transform as a `LinearEquiv` in one go, because that leads to annoying repetition between the proof fields. So we set up a private definition first, prove a minimal set of lemmas about it, and then define the `LinearEquiv` using that. **Do not add more lemmas about `auxDFT`**: it should be invisible to end-users. -/ /-- The discrete Fourier transform on `ℤ / N ℤ` (with the counting measure). This definition is private because it is superseded by the bundled `LinearEquiv` version. -/ private noncomputable def auxDFT (Φ : ZMod N → E) (k : ZMod N) : E := ∑ j : ZMod N, stdAddChar (-(j * k)) • Φ j private lemma auxDFT_neg (Φ : ZMod N → E) : auxDFT (fun j ↦ Φ (-j)) = fun k ↦ auxDFT Φ (-k) := by ext1 k; simpa only [auxDFT] using Fintype.sum_equiv (Equiv.neg _) _ _ (fun j ↦ by rw [Equiv.neg_apply, neg_mul_neg]) /-- Fourier inversion formula, discrete case. -/ private lemma auxDFT_auxDFT (Φ : ZMod N → E) : auxDFT (auxDFT Φ) = fun j ↦ (N : ℂ) • Φ (-j) := by ext1 j simp only [auxDFT, mul_comm _ j, smul_sum, ← smul_assoc, smul_eq_mul, ← map_add_eq_mul, ← neg_add, ← add_mul] rw [sum_comm] simp only [← sum_smul, ← neg_mul] have h1 (t : ZMod N) : ∑ i, stdAddChar (t * i) = if t = 0 then ↑N else 0 := by split_ifs with h · simp only [h, zero_mul, map_zero_eq_one, sum_const, card_univ, card, nsmul_eq_mul, mul_one] · exact sum_eq_zero_of_ne_one (isPrimitive_stdAddChar N h) have h2 (x j : ZMod N) : -(j + x) = 0 ↔ x = -j := by rw [neg_add, add_comm, add_eq_zero_iff_neg_eq, neg_neg] simp only [h1, h2, ite_smul, zero_smul, sum_ite_eq', mem_univ, ite_true] private lemma auxDFT_smul (c : ℂ) (Φ : ZMod N → E) : auxDFT (c • Φ) = c • auxDFT Φ := by ext; simp only [Pi.smul_def, auxDFT, smul_sum, smul_comm c] end private_defs section defs /-- The discrete Fourier transform on `ℤ / N ℤ` (with the counting measure), bundled as a linear equivalence. Denoted as `𝓕` within the `ZMod` namespace. -/ noncomputable def dft : (ZMod N → E) ≃ₗ[ℂ] (ZMod N → E) where toFun := auxDFT map_add' Φ₁ Φ₂ := by ext; simp only [auxDFT, Pi.add_def, smul_add, sum_add_distrib] map_smul' c Φ := by ext; simp only [auxDFT, Pi.smul_apply, RingHom.id_apply, smul_sum, smul_comm c] invFun Φ k := (N : ℂ)⁻¹ • auxDFT Φ (-k) left_inv Φ := by simp only [auxDFT_auxDFT, neg_neg, ← mul_smul, inv_mul_cancel₀ (NeZero.ne _), one_smul] right_inv Φ := by ext1 j simp only [← Pi.smul_def, auxDFT_smul, auxDFT_neg, auxDFT_auxDFT, neg_neg, ← mul_smul, inv_mul_cancel₀ (NeZero.ne _), one_smul] @[inherit_doc] scoped notation "𝓕" => dft /-- The inverse Fourier transform on `ZMod N`. -/ scoped notation "𝓕⁻" => LinearEquiv.symm dft lemma dft_apply (Φ : ZMod N → E) (k : ZMod N) : 𝓕 Φ k = ∑ j : ZMod N, stdAddChar (-(j * k)) • Φ j := rfl lemma dft_def (Φ : ZMod N → E) : 𝓕 Φ = fun k ↦ ∑ j : ZMod N, stdAddChar (-(j * k)) • Φ j := rfl lemma invDFT_apply (Ψ : ZMod N → E) (k : ZMod N) : 𝓕⁻ Ψ k = (N : ℂ)⁻¹ • ∑ j : ZMod N, stdAddChar (j * k) • Ψ j := by simp only [dft, LinearEquiv.coe_symm_mk, auxDFT, mul_neg, neg_neg] lemma invDFT_def (Ψ : ZMod N → E) : 𝓕⁻ Ψ = fun k ↦ (N : ℂ)⁻¹ • ∑ j : ZMod N, stdAddChar (j * k) • Ψ j := funext <| invDFT_apply Ψ lemma invDFT_apply' (Ψ : ZMod N → E) (k : ZMod N) : 𝓕⁻ Ψ k = (N : ℂ)⁻¹ • 𝓕 Ψ (-k) := rfl lemma invDFT_def' (Ψ : ZMod N → E) : 𝓕⁻ Ψ = fun k ↦ (N : ℂ)⁻¹ • 𝓕 Ψ (-k) := rfl lemma dft_apply_zero (Φ : ZMod N → E) : 𝓕 Φ 0 = ∑ j, Φ j := by simp only [dft_apply, mul_zero, neg_zero, map_zero_eq_one, one_smul] /-- The discrete Fourier transform agrees with the general one (assuming the target space is a complete normed space). -/ lemma dft_eq_fourier {E : Type*} [NormedAddCommGroup E] [NormedSpace ℂ E] [CompleteSpace E] (Φ : ZMod N → E) (k : ZMod N) : 𝓕 Φ k = Fourier.fourierIntegral toCircle Measure.count Φ k := by simp only [dft_apply, stdAddChar_apply, Fourier.fourierIntegral_def, Circle.smul_def, integral_countable' <| .of_finite .., count_real_singleton, one_smul, tsum_fintype] end defs section arith /-! ## Compatibility with scalar multiplication These lemmas are more general than `LinearEquiv.map_mul` etc, since they allow any scalars that commute with the `ℂ`-action, rather than just `ℂ` itself. -/ lemma dft_const_smul {R : Type*} [DistribSMul R E] [SMulCommClass R ℂ E] (r : R) (Φ : ZMod N → E) : 𝓕 (r • Φ) = r • 𝓕 Φ := by simp only [Pi.smul_def, dft_def, smul_sum, smul_comm] lemma dft_smul_const {R : Type*} [Ring R] [Module ℂ R] [Module R E] [IsScalarTower ℂ R E] (Φ : ZMod N → R) (e : E) : 𝓕 (fun j ↦ Φ j • e) = fun k ↦ 𝓕 Φ k • e := by simp only [dft_def, sum_smul, smul_assoc] lemma dft_const_mul {R : Type*} [Ring R] [Algebra ℂ R] (r : R) (Φ : ZMod N → R) : 𝓕 (fun j ↦ r * Φ j) = fun k ↦ r * 𝓕 Φ k := dft_const_smul r Φ lemma dft_mul_const {R : Type*} [Ring R] [Algebra ℂ R] (Φ : ZMod N → R) (r : R) : 𝓕 (fun j ↦ Φ j * r) = fun k ↦ 𝓕 Φ k * r := dft_smul_const Φ r end arith section inversion lemma dft_comp_neg (Φ : ZMod N → E) : 𝓕 (fun j ↦ Φ (-j)) = fun k ↦ 𝓕 Φ (-k) := auxDFT_neg .. /-- Fourier inversion formula, discrete case. -/ lemma dft_dft (Φ : ZMod N → E) : 𝓕 (𝓕 Φ) = fun j ↦ (N : ℂ) • Φ (-j) := auxDFT_auxDFT .. end inversion lemma dft_comp_unitMul (Φ : ZMod N → E) (u : (ZMod N)ˣ) (k : ZMod N) : 𝓕 (fun j ↦ Φ (u.val * j)) k = 𝓕 Φ (u⁻¹.val * k) := by refine Fintype.sum_equiv u.mulLeft _ _ fun x ↦ ?_ simp only [mul_comm u.val, u.mulLeft_apply, ← mul_assoc, u.mul_inv_cancel_right] section signs /-- The discrete Fourier transform of `Φ` is even if and only if `Φ` itself is. -/ lemma dft_even_iff {Φ : ZMod N → ℂ} : (𝓕 Φ).Even ↔ Φ.Even := by have h {f : ZMod N → ℂ} (hf : f.Even) : (𝓕 f).Even := by simp only [Function.Even, ← congr_fun (dft_comp_neg f), funext hf, implies_true] refine ⟨fun hΦ x ↦ ?_, h⟩ simpa only [neg_neg, smul_right_inj (NeZero.ne (N : ℂ)), dft_dft] using h hΦ (-x) /-- The discrete Fourier transform of `Φ` is odd if and only if `Φ` itself is. -/ lemma dft_odd_iff {Φ : ZMod N → ℂ} : (𝓕 Φ).Odd ↔ Φ.Odd := by have h {f : ZMod N → ℂ} (hf : f.Odd) : (𝓕 f).Odd := by simp only [Function.Odd, ← congr_fun (dft_comp_neg f), funext hf, ← Pi.neg_apply, map_neg, implies_true] refine ⟨fun hΦ x ↦ ?_, h⟩ simpa only [neg_neg, dft_dft, ← smul_neg, smul_right_inj (NeZero.ne (N : ℂ))] using h hΦ (-x) end signs end ZMod namespace DirichletCharacter variable {N : ℕ} [NeZero N] lemma fourierTransform_eq_gaussSum_mulShift (χ : DirichletCharacter ℂ N) (k : ZMod N) : 𝓕 χ k = gaussSum χ (stdAddChar.mulShift (-k)) := by simp only [dft_apply, smul_eq_mul] congr 1 with j rw [mulShift_apply, mul_comm j, neg_mul, stdAddChar_apply, mul_comm (χ _)] /-- For a primitive Dirichlet character `χ`, the Fourier transform of `χ` is a constant multiple of `χ⁻¹` (and the constant is essentially the Gauss sum). -/ lemma IsPrimitive.fourierTransform_eq_inv_mul_gaussSum {χ : DirichletCharacter ℂ N} (hχ : IsPrimitive χ) (k : ZMod N) : 𝓕 χ k = χ⁻¹ (-k) * gaussSum χ stdAddChar := by rw [fourierTransform_eq_gaussSum_mulShift, gaussSum_mulShift_of_isPrimitive _ hχ] end DirichletCharacter
.lake/packages/mathlib/Mathlib/Analysis/Fourier/Inversion.lean
import Mathlib.MeasureTheory.Integral.PeakFunction import Mathlib.Analysis.SpecialFunctions.Gaussian.FourierTransform /-! # Fourier inversion formula In a finite-dimensional real inner product space, we show the Fourier inversion formula, i.e., `𝓕⁻ (𝓕 f) v = f v` if `f` and `𝓕 f` are integrable, and `f` is continuous at `v`. This is proved in `MeasureTheory.Integrable.fourier_inversion`. See also `Continuous.fourier_inversion` giving `𝓕⁻ (𝓕 f) = f` under an additional continuity assumption for `f`. We use the following proof. A naïve computation gives `𝓕⁻ (𝓕 f) v = ∫_w exp (2 I π ⟪w, v⟫) 𝓕 f (w) dw = ∫_w exp (2 I π ⟪w, v⟫) ∫_x, exp (-2 I π ⟪w, x⟫) f x dx) dw = ∫_x (∫_ w, exp (2 I π ⟪w, v - x⟫ dw) f x dx ` However, the Fubini step does not make sense for lack of integrability, and the middle integral `∫_ w, exp (2 I π ⟪w, v - x⟫ dw` (which one would like to be a Dirac at `v - x`) is not defined. To gain integrability, one multiplies with a Gaussian function `exp (-c⁻¹ ‖w‖^2)`, with a large (but finite) `c`. As this function converges pointwise to `1` when `c → ∞`, we get `∫_w exp (2 I π ⟪w, v⟫) 𝓕 f (w) dw = lim_c ∫_w exp (-c⁻¹ ‖w‖^2 + 2 I π ⟪w, v⟫) 𝓕 f (w) dw`. One can perform Fubini on the right-hand side for fixed `c`, writing the integral as `∫_x (∫_w exp (-c⁻¹‖w‖^2 + 2 I π ⟪w, v - x⟫ dw)) f x dx`. The middle factor is the Fourier transform of a more and more flat function (converging to the constant `1`), hence it becomes more and more concentrated, around the point `v`. (Morally, it converges to the Dirac at `v`). Moreover, it has integral one. Therefore, multiplying by `f` and integrating, one gets a term converging to `f v` as `c → ∞`. Since it also converges to `𝓕⁻ (𝓕 f) v`, this proves the result. To check the concentration property of the middle factor and the fact that it has integral one, we rely on the explicit computation of the Fourier transform of Gaussians. -/ open Filter MeasureTheory Complex Module Metric Real Bornology open scoped Topology FourierTransform RealInnerProductSpace Complex variable {V E : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V] [MeasurableSpace V] [BorelSpace V] [FiniteDimensional ℝ V] [NormedAddCommGroup E] [NormedSpace ℂ E] {f : V → E} namespace Real lemma tendsto_integral_cexp_sq_smul (hf : Integrable f) : Tendsto (fun (c : ℝ) ↦ (∫ v : V, cexp (- c⁻¹ * ‖v‖^2) • f v)) atTop (𝓝 (∫ v : V, f v)) := by apply tendsto_integral_filter_of_dominated_convergence _ _ _ hf.norm · filter_upwards with v nth_rewrite 2 [show f v = cexp (- (0 : ℝ) * ‖v‖^2) • f v by simp] apply (Tendsto.cexp _).smul_const exact tendsto_inv_atTop_zero.ofReal.neg.mul_const _ · filter_upwards with c using AEStronglyMeasurable.smul (Continuous.aestronglyMeasurable (by fun_prop)) hf.1 · filter_upwards [Ici_mem_atTop (0 : ℝ)] with c (hc : 0 ≤ c) filter_upwards with v simp only [ofReal_inv, neg_mul, norm_smul] norm_cast conv_rhs => rw [← one_mul (‖f v‖)] gcongr simp only [norm_eq_abs, abs_exp, exp_le_one_iff, Left.neg_nonpos_iff] positivity variable [CompleteSpace E] lemma tendsto_integral_gaussian_smul (hf : Integrable f) (h'f : Integrable (𝓕 f)) (v : V) : Tendsto (fun (c : ℝ) ↦ ∫ w : V, ((π * c) ^ (finrank ℝ V / 2 : ℂ) * cexp (-π ^ 2 * c * ‖v - w‖ ^ 2)) • f w) atTop (𝓝 (𝓕⁻ (𝓕 f) v)) := by have A : Tendsto (fun (c : ℝ) ↦ (∫ w : V, cexp (- c⁻¹ * ‖w‖^2 + 2 * π * I * ⟪v, w⟫) • (𝓕 f) w)) atTop (𝓝 (𝓕⁻ (𝓕 f) v)) := by have : Integrable (fun w ↦ 𝐞 ⟪w, v⟫ • (𝓕 f) w) := by have B : Continuous fun p : V × V => (- innerₗ V) p.1 p.2 := continuous_inner.neg simpa using (VectorFourier.fourierIntegral_convergent_iff Real.continuous_fourierChar B v).2 h'f convert tendsto_integral_cexp_sq_smul this using 4 with c w · rw [Submonoid.smul_def, Real.fourierChar_apply, smul_smul, ← Complex.exp_add, real_inner_comm] congr 3 simp only [ofReal_mul, ofReal_ofNat] ring · simp [fourierIntegralInv_eq] have B : Tendsto (fun (c : ℝ) ↦ (∫ w : V, 𝓕 (fun w ↦ cexp (- c⁻¹ * ‖w‖^2 + 2 * π * I * ⟪v, w⟫)) w • f w)) atTop (𝓝 (𝓕⁻ (𝓕 f) v)) := by apply A.congr' filter_upwards [Ioi_mem_atTop 0] with c (hc : 0 < c) have J : Integrable (fun w ↦ cexp (- c⁻¹ * ‖w‖^2 + 2 * π * I * ⟪v, w⟫)) := GaussianFourier.integrable_cexp_neg_mul_sq_norm_add (by simpa) _ _ simpa using (VectorFourier.integral_fourierIntegral_smul_eq_flip (L := innerₗ V) Real.continuous_fourierChar continuous_inner J hf).symm apply B.congr' filter_upwards [Ioi_mem_atTop 0] with c (hc : 0 < c) congr with w rw [fourierIntegral_gaussian_innerProductSpace' (by simpa)] congr · simp · simp; ring lemma tendsto_integral_gaussian_smul' (hf : Integrable f) {v : V} (h'f : ContinuousAt f v) : Tendsto (fun (c : ℝ) ↦ ∫ w : V, ((π * c : ℂ) ^ (finrank ℝ V / 2 : ℂ) * cexp (-π ^ 2 * c * ‖v - w‖ ^ 2)) • f w) atTop (𝓝 (f v)) := by let φ : V → ℝ := fun w ↦ π ^ (finrank ℝ V / 2 : ℝ) * Real.exp (-π^2 * ‖w‖^2) have A : Tendsto (fun (c : ℝ) ↦ ∫ w : V, (c ^ finrank ℝ V * φ (c • (v - w))) • f w) atTop (𝓝 (f v)) := by apply tendsto_integral_comp_smul_smul_of_integrable' · exact fun x ↦ by positivity · rw [integral_const_mul, GaussianFourier.integral_rexp_neg_mul_sq_norm (by positivity)] nth_rewrite 2 [← pow_one π] rw [← rpow_natCast, ← rpow_natCast, ← rpow_sub pi_pos, ← rpow_mul pi_nonneg, ← rpow_add pi_pos] ring_nf exact rpow_zero _ · have A : Tendsto (fun (w : V) ↦ π^2 * ‖w‖^2) (cobounded V) atTop := by rw [tendsto_const_mul_atTop_of_pos (by positivity)] apply (tendsto_pow_atTop two_ne_zero).comp tendsto_norm_cobounded_atTop have B := tendsto_rpow_mul_exp_neg_mul_atTop_nhds_zero (finrank ℝ V / 2) 1 zero_lt_one |>.comp A |>.const_mul (π ^ (-finrank ℝ V / 2 : ℝ)) rw [mul_zero] at B convert B using 2 with x simp only [neg_mul, one_mul, Function.comp_apply, ← mul_assoc, ← rpow_natCast, φ] congr 1 rw [mul_rpow (by positivity) (by positivity), ← rpow_mul pi_nonneg, ← rpow_mul (norm_nonneg _), ← mul_assoc, ← rpow_add pi_pos, mul_comm] congr <;> ring · exact hf · exact h'f have B : Tendsto (fun (c : ℝ) ↦ ∫ w : V, ((c^(1/2 : ℝ)) ^ finrank ℝ V * φ ((c^(1/2 : ℝ)) • (v - w))) • f w) atTop (𝓝 (f v)) := A.comp (tendsto_rpow_atTop (by simp)) apply B.congr' filter_upwards [Ioi_mem_atTop 0] with c (hc : 0 < c) congr with w rw [← coe_smul] congr rw [ofReal_mul, ofReal_mul, ofReal_exp, ← mul_assoc] congr · rw [mul_cpow_ofReal_nonneg pi_nonneg hc.le, ← rpow_natCast, ← rpow_mul hc.le, mul_comm, ofReal_cpow pi_nonneg, ofReal_cpow hc.le] simp [div_eq_inv_mul] · norm_cast simp only [one_div, norm_smul, Real.norm_eq_abs, mul_pow, sq_abs, neg_mul, neg_inj, ← rpow_natCast, ← rpow_mul hc.le, mul_assoc] simp end Real variable [CompleteSpace E] /-- **Fourier inversion formula**: If a function `f` on a finite-dimensional real inner product space is integrable, and its Fourier transform `𝓕 f` is also integrable, then `𝓕⁻ (𝓕 f) = f` at continuity points of `f`. -/ theorem MeasureTheory.Integrable.fourier_inversion (hf : Integrable f) (h'f : Integrable (𝓕 f)) {v : V} (hv : ContinuousAt f v) : 𝓕⁻ (𝓕 f) v = f v := tendsto_nhds_unique (Real.tendsto_integral_gaussian_smul hf h'f v) (Real.tendsto_integral_gaussian_smul' hf hv) /-- **Fourier inversion formula**: If a function `f` on a finite-dimensional real inner product space is continuous, integrable, and its Fourier transform `𝓕 f` is also integrable, then `𝓕⁻ (𝓕 f) = f`. -/ theorem Continuous.fourier_inversion (h : Continuous f) (hf : Integrable f) (h'f : Integrable (𝓕 f)) : 𝓕⁻ (𝓕 f) = f := by ext v exact hf.fourier_inversion h'f h.continuousAt /-- **Fourier inversion formula**: If a function `f` on a finite-dimensional real inner product space is integrable, and its Fourier transform `𝓕 f` is also integrable, then `𝓕 (𝓕⁻ f) = f` at continuity points of `f`. -/ theorem MeasureTheory.Integrable.fourier_inversion_inv (hf : Integrable f) (h'f : Integrable (𝓕 f)) {v : V} (hv : ContinuousAt f v) : 𝓕 (𝓕⁻ f) v = f v := by rw [fourierIntegralInv_comm] exact fourier_inversion hf h'f hv /-- **Fourier inversion formula**: If a function `f` on a finite-dimensional real inner product space is continuous, integrable, and its Fourier transform `𝓕 f` is also integrable, then `𝓕 (𝓕⁻ f) = f`. -/ theorem Continuous.fourier_inversion_inv (h : Continuous f) (hf : Integrable f) (h'f : Integrable (𝓕 f)) : 𝓕 (𝓕⁻ f) = f := by ext v exact hf.fourier_inversion_inv h'f h.continuousAt
.lake/packages/mathlib/Mathlib/Analysis/Fourier/FiniteAbelian/Orthogonality.lean
import Mathlib.Algebra.BigOperators.Expect import Mathlib.Algebra.Group.AddChar import Mathlib.Analysis.RCLike.Inner /-! # Orthogonality of characters of a finite abelian group This file proves that characters of a finite abelian group are orthogonal, and in particular that there are at most as many characters as there are elements of the group. -/ open Finset hiding card open Fintype (card) open Function RCLike open scoped BigOperators ComplexConjugate DirectSum variable {G H R : Type*} namespace AddChar section AddGroup variable [AddGroup G] section Semifield variable [Fintype G] [Semifield R] [IsDomain R] [CharZero R] {ψ : AddChar G R} lemma expect_eq_ite (ψ : AddChar G R) : 𝔼 a, ψ a = if ψ = 0 then 1 else 0 := by simp [Fintype.expect_eq_sum_div_card, sum_eq_ite, ite_div] lemma expect_eq_zero_iff_ne_zero : 𝔼 x, ψ x = 0 ↔ ψ ≠ 0 := by rw [expect_eq_ite, one_ne_zero.ite_eq_right_iff] lemma expect_ne_zero_iff_eq_zero : 𝔼 x, ψ x ≠ 0 ↔ ψ = 0 := expect_eq_zero_iff_ne_zero.not_left end Semifield section RCLike variable [RCLike R] [Fintype G] lemma wInner_cWeight_self (ψ : AddChar G R) : ⟪(ψ : G → R), ψ⟫ₙ_[R] = 1 := by simp [wInner_cWeight_eq_expect, ψ.norm_apply] end RCLike end AddGroup section AddCommGroup variable [AddCommGroup G] section RCLike variable [RCLike R] {ψ₁ ψ₂ : AddChar G R} lemma wInner_cWeight_eq_boole [Fintype G] (ψ₁ ψ₂ : AddChar G R) : ⟪(ψ₁ : G → R), ψ₂⟫ₙ_[R] = if ψ₁ = ψ₂ then 1 else 0 := by split_ifs with h · rw [h, wInner_cWeight_self] have : ψ₂ * ψ₁⁻¹ ≠ 1 := by rwa [Ne, mul_inv_eq_one, eq_comm] simp_rw [wInner_cWeight_eq_expect, RCLike.inner_apply, ← inv_apply_eq_conj] simpa [map_neg_eq_inv] using expect_eq_zero_iff_ne_zero.2 this lemma wInner_cWeight_eq_zero_iff_ne [Fintype G] : ⟪(ψ₁ : G → R), ψ₂⟫ₙ_[R] = 0 ↔ ψ₁ ≠ ψ₂ := by rw [wInner_cWeight_eq_boole, one_ne_zero.ite_eq_right_iff] lemma wInner_cWeight_eq_one_iff_eq [Fintype G] : ⟪(ψ₁ : G → R), ψ₂⟫ₙ_[R] = 1 ↔ ψ₁ = ψ₂ := by rw [wInner_cWeight_eq_boole, one_ne_zero.ite_eq_left_iff] variable (G R) protected lemma linearIndependent [Finite G] : LinearIndependent R ((⇑) : AddChar G R → G → R) := by cases nonempty_fintype G exact linearIndependent_of_ne_zero_of_wInner_cWeight_eq_zero coe_ne_zero fun ψ₁ ψ₂ ↦ wInner_cWeight_eq_zero_iff_ne.2 noncomputable instance instFintype [Finite G] : Fintype (AddChar G R) := @Fintype.ofFinite _ (AddChar.linearIndependent G R).finite @[simp] lemma card_addChar_le [Fintype G] : card (AddChar G R) ≤ card G := by simpa only [Module.finrank_fintype_fun_eq_card] using (AddChar.linearIndependent G R).fintype_card_le_finrank end RCLike end AddCommGroup end AddChar
.lake/packages/mathlib/Mathlib/Analysis/Fourier/FiniteAbelian/PontryaginDuality.lean
import Mathlib.Algebra.DirectSum.AddChar import Mathlib.Analysis.Fourier.FiniteAbelian.Orthogonality import Mathlib.Analysis.SpecialFunctions.Complex.Circle import Mathlib.GroupTheory.FiniteAbelian.Basic import Mathlib.Topology.Instances.AddCircle.Real /-! # Pontryagin duality for finite abelian groups This file proves the Pontryagin duality in case of finite abelian groups. This states that any finite abelian group is canonically isomorphic to its double dual (the space of complex-valued characters of its space of complex-valued characters). We first prove it for `ZMod n` and then extend to all finite abelian groups using the Structure Theorem. ## TODO Reuse the work done in `Mathlib/GroupTheory/FiniteAbelian/Duality.lean`. This requires to write some more glue. -/ noncomputable section open Circle Finset Function Module Multiplicative open Fintype (card) open Real hiding exp open scoped BigOperators DirectSum variable {α : Type*} [AddCommGroup α] {n : ℕ} {a b : α} namespace AddChar variable (n : ℕ) [NeZero n] /-- Indexing of the complex characters of `ZMod n`. `AddChar.zmod n x` is the character sending `y` to `e ^ (2 * π * i * x * y / n)`. -/ def zmod (x : ZMod n) : AddChar (ZMod n) Circle := AddChar.compAddMonoidHom ⟨AddCircle.toCircle, AddCircle.toCircle_zero, AddCircle.toCircle_add⟩ <| ZMod.toAddCircle.comp <| .mulLeft x @[simp] lemma zmod_intCast (x y : ℤ) : zmod n x y = exp (2 * π * (x * y / n)) := by simp [zmod, ← Int.cast_mul x y, -Int.cast_mul, ZMod.toAddCircle_intCast, AddCircle.toCircle_apply_mk] @[simp] lemma zmod_zero : zmod n 0 = 1 := DFunLike.ext _ _ <| by simp [zmod] variable {n} @[simp] lemma zmod_add : ∀ x y : ZMod n, zmod n (x + y) = zmod n x * zmod n y := by simp [DFunLike.ext_iff, zmod, add_mul, map_add_eq_mul] lemma zmod_injective : Injective (zmod n) := by simp_rw [Injective, ZMod.intCast_surjective.forall] rintro x y h have hn : (n : ℝ) ≠ 0 := NeZero.ne _ simpa [pi_ne_zero, exp_inj, hn, CharP.intCast_eq_intCast (ZMod n) n] using (zmod_intCast ..).symm.trans <| (DFunLike.congr_fun h ((1 : ℤ) : ZMod n)).trans <| zmod_intCast .. @[simp] lemma zmod_inj {x y : ZMod n} : zmod n x = zmod n y ↔ x = y := zmod_injective.eq_iff /-- `AddChar.zmod` bundled as an `AddChar`. -/ def zmodHom : AddChar (ZMod n) (AddChar (ZMod n) Circle) where toFun := zmod n map_zero_eq_one' := by simp map_add_eq_mul' := by simp /-- Character on a product of `ZMod`s given by `x ↦ ∏ i, e ^ (2 * π * I * x i * y / n)`. -/ private def mkZModAux {ι : Type} [DecidableEq ι] (n : ι → ℕ) [∀ i, NeZero (n i)] (u : ∀ i, ZMod (n i)) : AddChar (⨁ i, ZMod (n i)) Circle := AddChar.directSum fun i ↦ zmod (n i) (u i) private lemma mkZModAux_injective {ι : Type} [DecidableEq ι] {n : ι → ℕ} [∀ i, NeZero (n i)] : Injective (mkZModAux n) := AddChar.directSum_injective.comp fun f g h ↦ by simpa [funext_iff] using h /-- The circle-valued characters of a finite abelian group are the same as its complex-valued characters. -/ def circleEquivComplex [Finite α] : AddChar α Circle ≃+ AddChar α ℂ where toFun ψ := toMonoidHomEquiv.symm <| coeHom.comp ψ.toMonoidHom invFun ψ := { toFun := fun a ↦ (⟨ψ a, mem_sphere_zero_iff_norm.2 <| ψ.norm_apply _⟩ : Circle) map_zero_eq_one' := by simp [Circle] map_add_eq_mul' := fun a b ↦ by ext : 1; simp [map_add_eq_mul] } left_inv ψ := by ext : 1; simp right_inv ψ := by ext : 1; simp map_add' ψ χ := rfl @[simp] lemma card_eq [Fintype α] : card (AddChar α ℂ) = card α := by obtain ⟨ι, _, n, hn, ⟨e⟩⟩ := AddCommGroup.equiv_directSum_zmod_of_finite' α classical have hn' i : NeZero (n i) := by have := hn i; exact ⟨by positivity⟩ let f : α → AddChar α ℂ := fun a ↦ coeHom.compAddChar ((mkZModAux n <| e a).compAddMonoidHom e) have hf : Injective f := circleEquivComplex.injective.comp ((compAddMonoidHom_injective_left _ e.surjective).comp <| mkZModAux_injective.comp <| DFunLike.coe_injective.comp <| e.injective.comp Additive.ofMul.injective) exact (card_addChar_le _ _).antisymm (Fintype.card_le_of_injective _ hf) /-- `ZMod n` is (noncanonically) isomorphic to its group of characters. -/ def zmodAddEquiv : ZMod n ≃+ AddChar (ZMod n) ℂ := by refine AddEquiv.ofBijective (circleEquivComplex.toAddMonoidHom.comp <| AddChar.toAddMonoidHom zmodHom) ?_ rw [Fintype.bijective_iff_injective_and_card, card_eq] exact ⟨circleEquivComplex.injective.comp zmod_injective, rfl⟩ @[simp] lemma zmodAddEquiv_apply (x : ZMod n) : zmodAddEquiv x = circleEquivComplex (zmod n x) := rfl section Finite variable (α) [Finite α] /-- Complex-valued characters of a finite abelian group `α` form a basis of `α → ℂ`. -/ def complexBasis : Basis (AddChar α ℂ) ℂ (α → ℂ) := basisOfLinearIndependentOfCardEqFinrank (AddChar.linearIndependent _ _) <| by cases nonempty_fintype α; rw [card_eq, Module.finrank_fintype_fun_eq_card] @[simp, norm_cast] lemma coe_complexBasis : ⇑(complexBasis α) = ((⇑) : AddChar α ℂ → α → ℂ) := by rw [complexBasis, coe_basisOfLinearIndependentOfCardEqFinrank] variable {α} @[simp] lemma complexBasis_apply (ψ : AddChar α ℂ) : complexBasis α ψ = ψ := by rw [coe_complexBasis] lemma exists_apply_ne_zero : (∃ ψ : AddChar α ℂ, ψ a ≠ 1) ↔ a ≠ 0 := by refine ⟨?_, fun ha ↦ ?_⟩ · rintro ⟨ψ, hψ⟩ rfl exact hψ ψ.map_zero_eq_one classical by_contra! h let f : α → ℂ := fun b ↦ if a = b then 1 else 0 have h₀ := congr_fun ((complexBasis α).sum_repr f) 0 have h₁ := congr_fun ((complexBasis α).sum_repr f) a simp only [complexBasis_apply, Fintype.sum_apply, Pi.smul_apply, h, smul_eq_mul, mul_one, map_zero_eq_one, if_pos rfl, if_neg ha, f] at h₀ h₁ exact one_ne_zero (h₁.symm.trans h₀) lemma forall_apply_eq_zero : (∀ ψ : AddChar α ℂ, ψ a = 1) ↔ a = 0 := by simpa using exists_apply_ne_zero.not lemma doubleDualEmb_injective : Injective (doubleDualEmb : α → AddChar (AddChar α ℂ) ℂ) := doubleDualEmb.ker_eq_bot_iff.1 <| eq_bot_iff.2 fun a ha ↦ forall_apply_eq_zero.1 fun ψ ↦ by simpa using DFunLike.congr_fun ha (Additive.ofMul ψ) lemma doubleDualEmb_bijective : Bijective (doubleDualEmb : α → AddChar (AddChar α ℂ) ℂ) := by cases nonempty_fintype α exact (Fintype.bijective_iff_injective_and_card _).2 ⟨doubleDualEmb_injective, card_eq.symm.trans card_eq.symm⟩ @[simp] lemma doubleDualEmb_inj : (doubleDualEmb a : AddChar (AddChar α ℂ) ℂ) = doubleDualEmb b ↔ a = b := doubleDualEmb_injective.eq_iff @[simp] lemma doubleDualEmb_eq_zero : (doubleDualEmb a : AddChar (AddChar α ℂ) ℂ) = 0 ↔ a = 0 := by rw [← map_zero doubleDualEmb, doubleDualEmb_inj] lemma doubleDualEmb_ne_zero : (doubleDualEmb a : AddChar (AddChar α ℂ) ℂ) ≠ 0 ↔ a ≠ 0 := doubleDualEmb_eq_zero.not /-- The double dual isomorphism of a finite abelian group. -/ def doubleDualEquiv : α ≃+ AddChar (AddChar α ℂ) ℂ := .ofBijective _ doubleDualEmb_bijective @[simp] lemma coe_doubleDualEquiv : ⇑(doubleDualEquiv : α ≃+ AddChar (AddChar α ℂ) ℂ) = doubleDualEmb := rfl @[simp] lemma doubleDualEmb_doubleDualEquiv_symm_apply (a : AddChar (AddChar α ℂ) ℂ) : doubleDualEmb (doubleDualEquiv.symm a) = a := doubleDualEquiv.apply_symm_apply _ @[simp] lemma doubleDualEquiv_symm_doubleDualEmb_apply (a : AddChar (AddChar α ℂ) ℂ) : doubleDualEquiv.symm (doubleDualEmb a) = a := doubleDualEquiv.symm_apply_apply _ end Finite lemma sum_apply_eq_ite [Fintype α] [DecidableEq α] (a : α) : ∑ ψ : AddChar α ℂ, ψ a = if a = 0 then (Fintype.card α : ℂ) else 0 := by simpa using sum_eq_ite (doubleDualEmb a : AddChar (AddChar α ℂ) ℂ) lemma expect_apply_eq_ite [Finite α] [DecidableEq α] (a : α) : 𝔼 ψ : AddChar α ℂ, ψ a = if a = 0 then 1 else 0 := by simpa using expect_eq_ite (doubleDualEmb a : AddChar (AddChar α ℂ) ℂ) lemma sum_apply_eq_zero_iff_ne_zero [Finite α] : ∑ ψ : AddChar α ℂ, ψ a = 0 ↔ a ≠ 0 := by classical cases nonempty_fintype α rw [sum_apply_eq_ite, Ne.ite_eq_right_iff] exact Nat.cast_ne_zero.2 Fintype.card_ne_zero lemma sum_apply_ne_zero_iff_eq_zero [Finite α] : ∑ ψ : AddChar α ℂ, ψ a ≠ 0 ↔ a = 0 := sum_apply_eq_zero_iff_ne_zero.not_left lemma expect_apply_eq_zero_iff_ne_zero [Finite α] : 𝔼 ψ : AddChar α ℂ, ψ a = 0 ↔ a ≠ 0 := by classical cases nonempty_fintype α rw [expect_apply_eq_ite, one_ne_zero.ite_eq_right_iff] lemma expect_apply_ne_zero_iff_eq_zero [Finite α] : 𝔼 ψ : AddChar α ℂ, ψ a ≠ 0 ↔ a = 0 := expect_apply_eq_zero_iff_ne_zero.not_left end AddChar
.lake/packages/mathlib/Mathlib/Analysis/Real/Cardinality.lean
import Mathlib.Algebra.Order.Group.Pointwise.Interval import Mathlib.Analysis.SpecificLimits.Basic import Mathlib.Data.Rat.Cardinal import Mathlib.SetTheory.Cardinal.Continuum /-! # The cardinality of the reals This file shows that the real numbers have cardinality continuum, i.e. `#ℝ = 𝔠`. We show that `#ℝ ≤ 𝔠` by noting that every real number is determined by a Cauchy-sequence of the form `ℕ → ℚ`, which has cardinality `𝔠`. To show that `#ℝ ≥ 𝔠` we define an injection from `{0, 1} ^ ℕ` to `ℝ` with `f ↦ Σ n, f n * (1 / 3) ^ n`. We conclude that all intervals with distinct endpoints have cardinality continuum. ## Main definitions * `Cardinal.cantorFunction` is the function that sends `f` in `{0, 1} ^ ℕ` to `ℝ` by `f ↦ Σ' n, f n * (1 / 3) ^ n` ## Main statements * `Cardinal.mk_real : #ℝ = 𝔠`: the reals have cardinality continuum. * `Cardinal.not_countable_real`: the universal set of real numbers is not countable. We can use this same proof to show that all the other sets in this file are not countable. * 8 lemmas of the form `mk_Ixy_real` for `x,y ∈ {i,o,c}` state that intervals on the reals have cardinality continuum. ## Notation * `𝔠` : notation for `Cardinal.continuum` in scope `Cardinal`, defined in `SetTheory.Continuum`. ## Tags continuum, cardinality, reals, cardinality of the reals -/ open Nat Set open Cardinal noncomputable section namespace Cardinal variable {c : ℝ} {f g : ℕ → Bool} {n : ℕ} /-- The body of the sum in `cantorFunction`. `cantorFunctionAux c f n = c ^ n` if `f n = true`; `cantorFunctionAux c f n = 0` if `f n = false`. -/ def cantorFunctionAux (c : ℝ) (f : ℕ → Bool) (n : ℕ) : ℝ := cond (f n) (c ^ n) 0 @[simp] theorem cantorFunctionAux_true (h : f n = true) : cantorFunctionAux c f n = c ^ n := by simp [cantorFunctionAux, h] @[simp] theorem cantorFunctionAux_false (h : f n = false) : cantorFunctionAux c f n = 0 := by simp [cantorFunctionAux, h] theorem cantorFunctionAux_nonneg (h : 0 ≤ c) : 0 ≤ cantorFunctionAux c f n := by cases h' : f n · simp [h'] · simpa [h'] using pow_nonneg h _ theorem cantorFunctionAux_eq (h : f n = g n) : cantorFunctionAux c f n = cantorFunctionAux c g n := by simp [cantorFunctionAux, h] theorem cantorFunctionAux_zero (f : ℕ → Bool) : cantorFunctionAux c f 0 = cond (f 0) 1 0 := by cases h : f 0 <;> simp [h] theorem cantorFunctionAux_succ (f : ℕ → Bool) : (fun n => cantorFunctionAux c f (n + 1)) = fun n => c * cantorFunctionAux c (fun n => f (n + 1)) n := by ext n cases h : f (n + 1) <;> simp [h, _root_.pow_succ'] theorem summable_cantor_function (f : ℕ → Bool) (h1 : 0 ≤ c) (h2 : c < 1) : Summable (cantorFunctionAux c f) := by apply (summable_geometric_of_lt_one h1 h2).summable_of_eq_zero_or_self intro n; cases h : f n <;> simp [h] /-- `cantorFunction c (f : ℕ → Bool)` is `Σ n, f n * c ^ n`, where `true` is interpreted as `1` and `false` is interpreted as `0`. It is implemented using `cantorFunctionAux`. -/ def cantorFunction (c : ℝ) (f : ℕ → Bool) : ℝ := ∑' n, cantorFunctionAux c f n theorem cantorFunction_le (h1 : 0 ≤ c) (h2 : c < 1) (h3 : ∀ n, f n → g n) : cantorFunction c f ≤ cantorFunction c g := by apply (summable_cantor_function f h1 h2).tsum_le_tsum _ (summable_cantor_function g h1 h2) intro n; cases h : f n · simp [h, cantorFunctionAux_nonneg h1] replace h3 : g n = true := h3 n h; simp [h, h3] theorem cantorFunction_succ (f : ℕ → Bool) (h1 : 0 ≤ c) (h2 : c < 1) : cantorFunction c f = cond (f 0) 1 0 + c * cantorFunction c fun n => f (n + 1) := by rw [cantorFunction, (summable_cantor_function f h1 h2).tsum_eq_zero_add] rw [cantorFunctionAux_succ, tsum_mul_left, cantorFunctionAux, pow_zero, cantorFunction] /-- `cantorFunction c` is strictly increasing with if `0 < c < 1/2`, if we endow `ℕ → Bool` with a lexicographic order. The lexicographic order doesn't exist for these infinitary products, so we explicitly write out what it means. -/ theorem increasing_cantorFunction (h1 : 0 < c) (h2 : c < 1 / 2) {n : ℕ} {f g : ℕ → Bool} (hn : ∀ k < n, f k = g k) (fn : f n = false) (gn : g n = true) : cantorFunction c f < cantorFunction c g := by have h3 : c < 1 := by apply h2.trans norm_num induction n generalizing f g with | zero => let f_max : ℕ → Bool := fun n => Nat.rec false (fun _ _ => true) n have hf_max : ∀ n, f n → f_max n := by intro n hn cases n · rw [fn] at hn contradiction simp [f_max] let g_min : ℕ → Bool := fun n => Nat.rec true (fun _ _ => false) n have hg_min : ∀ n, g_min n → g n := by intro n hn cases n · rw [gn] simp at hn apply (cantorFunction_le (le_of_lt h1) h3 hf_max).trans_lt refine lt_of_lt_of_le ?_ (cantorFunction_le (le_of_lt h1) h3 hg_min) have : c / (1 - c) < 1 := by rw [div_lt_one, lt_sub_iff_add_lt] · convert _root_.add_lt_add h2 h2 norm_num rwa [sub_pos] convert this · rw [cantorFunction_succ _ (le_of_lt h1) h3, div_eq_mul_inv, ← tsum_geometric_of_lt_one (le_of_lt h1) h3] apply zero_add · refine (tsum_eq_single 0 ?_).trans ?_ · intro n hn cases n · contradiction simp [g_min] · exact cantorFunctionAux_zero _ | succ n ih => rw [cantorFunction_succ f h1.le h3, cantorFunction_succ g h1.le h3] rw [hn 0 <| zero_lt_succ n] gcongr exact ih (fun k hk => hn _ <| Nat.succ_lt_succ hk) fn gn /-- `cantorFunction c` is injective if `0 < c < 1/2`. -/ theorem cantorFunction_injective (h1 : 0 < c) (h2 : c < 1 / 2) : Function.Injective (cantorFunction c) := by intro f g hfg classical contrapose hfg with h have : ∃ n, f n ≠ g n := Function.ne_iff.mp h let n := Nat.find this have hn : ∀ k : ℕ, k < n → f k = g k := by intro k hk apply of_not_not exact Nat.find_min this hk cases fn : f n · apply _root_.ne_of_lt refine increasing_cantorFunction h1 h2 hn fn ?_ apply Bool.eq_true_of_not_eq_false rw [← fn] apply Ne.symm exact Nat.find_spec this · apply _root_.ne_of_gt refine increasing_cantorFunction h1 h2 (fun k hk => (hn k hk).symm) ?_ fn apply Bool.eq_false_of_not_eq_true rw [← fn] apply Ne.symm exact Nat.find_spec this /-- The cardinality of the reals, as a type. -/ theorem mk_real : #ℝ = 𝔠 := by apply le_antisymm · rw [Real.equivCauchy.cardinal_eq] apply mk_quotient_le.trans apply (mk_subtype_le _).trans_eq rw [← power_def, mk_nat, mkRat, aleph0_power_aleph0] · convert mk_le_of_injective (cantorFunction_injective _ _) · rw [← power_def, mk_bool, mk_nat, two_power_aleph0] · exact 1 / 3 · simp · norm_num /-- The cardinality of the reals, as a set. -/ theorem mk_univ_real : #(Set.univ : Set ℝ) = 𝔠 := by rw [mk_univ, mk_real] /-- **Non-Denumerability of the Continuum**: The reals are not countable. -/ instance : Uncountable ℝ := by rw [← aleph0_lt_mk_iff, mk_real] exact aleph0_lt_continuum theorem not_countable_real : ¬(Set.univ : Set ℝ).Countable := not_countable_univ /-- The cardinality of the interval (a, ∞). -/ theorem mk_Ioi_real (a : ℝ) : #(Ioi a) = 𝔠 := by refine le_antisymm (mk_real ▸ mk_set_le _) ?_ rw [← not_lt] intro h refine _root_.ne_of_lt ?_ mk_univ_real have hu : Iio a ∪ {a} ∪ Ioi a = Set.univ := by convert @Iic_union_Ioi ℝ _ _ exact Iio_union_right rw [← hu] grw [mk_union_le, mk_union_le] have h2 : (fun x => a + a - x) '' Ioi a = Iio a := by convert @image_const_sub_Ioi ℝ _ _ _ simp rw [← h2] refine add_lt_of_lt (cantor _).le ?_ h refine add_lt_of_lt (cantor _).le (mk_image_le.trans_lt h) ?_ rw [mk_singleton] exact one_lt_aleph0.trans (cantor _) /-- The cardinality of the interval [a, ∞). -/ theorem mk_Ici_real (a : ℝ) : #(Ici a) = 𝔠 := le_antisymm (mk_real ▸ mk_set_le _) (mk_Ioi_real a ▸ mk_le_mk_of_subset Ioi_subset_Ici_self) /-- The cardinality of the interval (-∞, a). -/ theorem mk_Iio_real (a : ℝ) : #(Iio a) = 𝔠 := by refine le_antisymm (mk_real ▸ mk_set_le _) ?_ have h2 : (fun x => a + a - x) '' Iio a = Ioi a := by simp only [image_const_sub_Iio, add_sub_cancel_right] exact mk_Ioi_real a ▸ h2 ▸ mk_image_le /-- The cardinality of the interval (-∞, a]. -/ theorem mk_Iic_real (a : ℝ) : #(Iic a) = 𝔠 := le_antisymm (mk_real ▸ mk_set_le _) (mk_Iio_real a ▸ mk_le_mk_of_subset Iio_subset_Iic_self) /-- The cardinality of the interval (a, b). -/ theorem mk_Ioo_real {a b : ℝ} (h : a < b) : #(Ioo a b) = 𝔠 := by refine le_antisymm (mk_real ▸ mk_set_le _) ?_ have h1 : #((fun x => x - a) '' Ioo a b) ≤ #(Ioo a b) := mk_image_le refine le_trans ?_ h1 rw [image_sub_const_Ioo, sub_self] replace h := sub_pos_of_lt h have h2 : #(Inv.inv '' Ioo 0 (b - a)) ≤ #(Ioo 0 (b - a)) := mk_image_le refine le_trans ?_ h2 rw [image_inv_eq_inv, inv_Ioo_0_left h, mk_Ioi_real] /-- The cardinality of the interval [a, b). -/ theorem mk_Ico_real {a b : ℝ} (h : a < b) : #(Ico a b) = 𝔠 := le_antisymm (mk_real ▸ mk_set_le _) (mk_Ioo_real h ▸ mk_le_mk_of_subset Ioo_subset_Ico_self) /-- The cardinality of the interval [a, b]. -/ theorem mk_Icc_real {a b : ℝ} (h : a < b) : #(Icc a b) = 𝔠 := le_antisymm (mk_real ▸ mk_set_le _) (mk_Ioo_real h ▸ mk_le_mk_of_subset Ioo_subset_Icc_self) /-- The cardinality of the interval (a, b]. -/ theorem mk_Ioc_real {a b : ℝ} (h : a < b) : #(Ioc a b) = 𝔠 := le_antisymm (mk_real ▸ mk_set_le _) (mk_Ioo_real h ▸ mk_le_mk_of_subset Ioo_subset_Ioc_self) @[simp] lemma Real.Ioo_countable_iff {x y : ℝ} : (Ioo x y).Countable ↔ y ≤ x := by refine ⟨fun h ↦ ?_, fun h ↦ by simp [h]⟩ contrapose! h rw [← Cardinal.le_aleph0_iff_set_countable, Cardinal.mk_Ioo_real h, not_le] exact Cardinal.aleph0_lt_continuum @[simp] lemma Real.Ico_countable_iff {x y : ℝ} : (Ico x y).Countable ↔ y ≤ x := by refine ⟨fun h ↦ ?_, fun h ↦ by simp [h]⟩ contrapose! h rw [← Cardinal.le_aleph0_iff_set_countable, Cardinal.mk_Ico_real h, not_le] exact Cardinal.aleph0_lt_continuum @[simp] lemma Real.Ioc_countable_iff {x y : ℝ} : (Ioc x y).Countable ↔ y ≤ x := by refine ⟨fun h ↦ ?_, fun h ↦ by simp [h]⟩ contrapose! h rw [← Cardinal.le_aleph0_iff_set_countable, Cardinal.mk_Ioc_real h, not_le] exact Cardinal.aleph0_lt_continuum @[simp] lemma Real.Icc_countable_iff {x y : ℝ} : (Icc x y).Countable ↔ y ≤ x := by refine ⟨fun h ↦ ?_, fun h ↦ by rcases le_iff_eq_or_lt.mp h with heq | hlt · simp [heq] · simp [hlt]⟩ contrapose! h rw [← Cardinal.le_aleph0_iff_set_countable, Cardinal.mk_Icc_real h, not_le] exact Cardinal.aleph0_lt_continuum end Cardinal
.lake/packages/mathlib/Mathlib/Analysis/Real/Hyperreal.lean
import Mathlib.Analysis.SpecificLimits.Basic import Mathlib.Order.Filter.FilterProduct /-! # Construction of the hyperreal numbers as an ultraproduct of real sequences. -/ open Filter Germ Topology /-- Hyperreal numbers on the ultrafilter extending the cofinite filter -/ def Hyperreal : Type := Germ (hyperfilter ℕ : Filter ℕ) ℝ #adaptation_note /-- After nightly-2025-05-07 we had to remove `deriving Inhabited` on `Hyperreal` above, as there is a new error about this instance having to be noncomputable, and `deriving` doesn't allow for adding this! -/ namespace Hyperreal @[inherit_doc] notation "ℝ*" => Hyperreal noncomputable instance : Field ℝ* := inferInstanceAs (Field (Germ _ _)) noncomputable instance : LinearOrder ℝ* := inferInstanceAs (LinearOrder (Germ _ _)) instance : IsStrictOrderedRing ℝ* := inferInstanceAs (IsStrictOrderedRing (Germ _ _)) /-- Natural embedding `ℝ → ℝ*`. -/ @[coe] noncomputable def ofReal : ℝ → ℝ* := const noncomputable instance : CoeTC ℝ ℝ* := ⟨ofReal⟩ @[simp, norm_cast] theorem coe_eq_coe {x y : ℝ} : (x : ℝ*) = y ↔ x = y := Germ.const_inj theorem coe_ne_coe {x y : ℝ} : (x : ℝ*) ≠ y ↔ x ≠ y := coe_eq_coe.not @[simp, norm_cast] theorem coe_eq_zero {x : ℝ} : (x : ℝ*) = 0 ↔ x = 0 := coe_eq_coe @[simp, norm_cast] theorem coe_eq_one {x : ℝ} : (x : ℝ*) = 1 ↔ x = 1 := coe_eq_coe @[norm_cast] theorem coe_ne_zero {x : ℝ} : (x : ℝ*) ≠ 0 ↔ x ≠ 0 := coe_ne_coe @[norm_cast] theorem coe_ne_one {x : ℝ} : (x : ℝ*) ≠ 1 ↔ x ≠ 1 := coe_ne_coe @[simp, norm_cast] theorem coe_one : ↑(1 : ℝ) = (1 : ℝ*) := rfl @[simp, norm_cast] theorem coe_zero : ↑(0 : ℝ) = (0 : ℝ*) := rfl @[simp, norm_cast] theorem coe_inv (x : ℝ) : ↑x⁻¹ = (x⁻¹ : ℝ*) := rfl @[simp, norm_cast] theorem coe_neg (x : ℝ) : ↑(-x) = (-x : ℝ*) := rfl @[simp, norm_cast] theorem coe_add (x y : ℝ) : ↑(x + y) = (x + y : ℝ*) := rfl @[simp, norm_cast] theorem coe_ofNat (n : ℕ) [n.AtLeastTwo] : ((ofNat(n) : ℝ) : ℝ*) = OfNat.ofNat n := rfl @[simp, norm_cast] theorem coe_mul (x y : ℝ) : ↑(x * y) = (x * y : ℝ*) := rfl @[simp, norm_cast] theorem coe_div (x y : ℝ) : ↑(x / y) = (x / y : ℝ*) := rfl @[simp, norm_cast] theorem coe_sub (x y : ℝ) : ↑(x - y) = (x - y : ℝ*) := rfl @[simp, norm_cast] theorem coe_le_coe {x y : ℝ} : (x : ℝ*) ≤ y ↔ x ≤ y := Germ.const_le_iff @[simp, norm_cast] theorem coe_lt_coe {x y : ℝ} : (x : ℝ*) < y ↔ x < y := Germ.const_lt_iff @[simp, norm_cast] theorem coe_nonneg {x : ℝ} : 0 ≤ (x : ℝ*) ↔ 0 ≤ x := coe_le_coe @[simp, norm_cast] theorem coe_pos {x : ℝ} : 0 < (x : ℝ*) ↔ 0 < x := coe_lt_coe @[simp, norm_cast] theorem coe_abs (x : ℝ) : ((|x| : ℝ) : ℝ*) = |↑x| := const_abs x @[simp, norm_cast] theorem coe_max (x y : ℝ) : ((max x y : ℝ) : ℝ*) = max ↑x ↑y := Germ.const_max _ _ @[simp, norm_cast] theorem coe_min (x y : ℝ) : ((min x y : ℝ) : ℝ*) = min ↑x ↑y := Germ.const_min _ _ /-- Construct a hyperreal number from a sequence of real numbers. -/ noncomputable def ofSeq (f : ℕ → ℝ) : ℝ* := (↑f : Germ (hyperfilter ℕ : Filter ℕ) ℝ) theorem ofSeq_surjective : Function.Surjective ofSeq := Quot.exists_rep theorem ofSeq_lt_ofSeq {f g : ℕ → ℝ} : ofSeq f < ofSeq g ↔ ∀ᶠ n in hyperfilter ℕ, f n < g n := Germ.coe_lt /-- A sample infinitesimal hyperreal -/ noncomputable def epsilon : ℝ* := ofSeq fun n => n⁻¹ /-- A sample infinite hyperreal -/ noncomputable def omega : ℝ* := ofSeq Nat.cast @[inherit_doc] scoped notation "ε" => Hyperreal.epsilon @[inherit_doc] scoped notation "ω" => Hyperreal.omega @[simp] theorem inv_omega : ω⁻¹ = ε := rfl @[simp] theorem inv_epsilon : ε⁻¹ = ω := @inv_inv _ _ ω theorem omega_pos : 0 < ω := Germ.coe_pos.2 <| Nat.hyperfilter_le_atTop <| (eventually_gt_atTop 0).mono fun _ ↦ Nat.cast_pos.2 theorem epsilon_pos : 0 < ε := inv_pos_of_pos omega_pos theorem epsilon_ne_zero : ε ≠ 0 := epsilon_pos.ne' theorem omega_ne_zero : ω ≠ 0 := omega_pos.ne' theorem epsilon_mul_omega : ε * ω = 1 := @inv_mul_cancel₀ _ _ ω omega_ne_zero theorem lt_of_tendsto_zero_of_pos {f : ℕ → ℝ} (hf : Tendsto f atTop (𝓝 0)) : ∀ {r : ℝ}, 0 < r → ofSeq f < (r : ℝ*) := fun hr ↦ ofSeq_lt_ofSeq.2 <| (hf.eventually <| gt_mem_nhds hr).filter_mono Nat.hyperfilter_le_atTop theorem neg_lt_of_tendsto_zero_of_pos {f : ℕ → ℝ} (hf : Tendsto f atTop (𝓝 0)) : ∀ {r : ℝ}, 0 < r → (-r : ℝ*) < ofSeq f := fun hr => have hg := hf.neg neg_lt_of_neg_lt (by rw [neg_zero] at hg; exact lt_of_tendsto_zero_of_pos hg hr) theorem gt_of_tendsto_zero_of_neg {f : ℕ → ℝ} (hf : Tendsto f atTop (𝓝 0)) : ∀ {r : ℝ}, r < 0 → (r : ℝ*) < ofSeq f := fun {r} hr => by rw [← neg_neg r, coe_neg]; exact neg_lt_of_tendsto_zero_of_pos hf (neg_pos.mpr hr) theorem epsilon_lt_pos (x : ℝ) : 0 < x → ε < x := lt_of_tendsto_zero_of_pos tendsto_inv_atTop_nhds_zero_nat /-- Standard part predicate -/ def IsSt (x : ℝ*) (r : ℝ) := ∀ δ : ℝ, 0 < δ → (r - δ : ℝ*) < x ∧ x < r + δ open scoped Classical in /-- Standard part function: like a "round" to ℝ instead of ℤ -/ noncomputable def st : ℝ* → ℝ := fun x => if h : ∃ r, IsSt x r then Classical.choose h else 0 /-- A hyperreal number is infinitesimal if its standard part is 0 -/ def Infinitesimal (x : ℝ*) := IsSt x 0 /-- A hyperreal number is positive infinite if it is larger than all real numbers -/ def InfinitePos (x : ℝ*) := ∀ r : ℝ, ↑r < x /-- A hyperreal number is negative infinite if it is smaller than all real numbers -/ def InfiniteNeg (x : ℝ*) := ∀ r : ℝ, x < r /-- A hyperreal number is infinite if it is infinite positive or infinite negative -/ def Infinite (x : ℝ*) := InfinitePos x ∨ InfiniteNeg x /-! ### Some facts about `st` -/ theorem isSt_ofSeq_iff_tendsto {f : ℕ → ℝ} {r : ℝ} : IsSt (ofSeq f) r ↔ Tendsto f (hyperfilter ℕ) (𝓝 r) := Iff.trans (forall₂_congr fun _ _ ↦ (ofSeq_lt_ofSeq.and ofSeq_lt_ofSeq).trans eventually_and.symm) (nhds_basis_Ioo_pos _).tendsto_right_iff.symm theorem isSt_iff_tendsto {x : ℝ*} {r : ℝ} : IsSt x r ↔ x.Tendsto (𝓝 r) := by rcases ofSeq_surjective x with ⟨f, rfl⟩ exact isSt_ofSeq_iff_tendsto theorem isSt_of_tendsto {f : ℕ → ℝ} {r : ℝ} (hf : Tendsto f atTop (𝓝 r)) : IsSt (ofSeq f) r := isSt_ofSeq_iff_tendsto.2 <| hf.mono_left Nat.hyperfilter_le_atTop protected theorem IsSt.lt {x y : ℝ*} {r s : ℝ} (hxr : IsSt x r) (hys : IsSt y s) (hrs : r < s) : x < y := by rcases ofSeq_surjective x with ⟨f, rfl⟩ rcases ofSeq_surjective y with ⟨g, rfl⟩ rw [isSt_ofSeq_iff_tendsto] at hxr hys exact ofSeq_lt_ofSeq.2 <| hxr.eventually_lt hys hrs theorem IsSt.unique {x : ℝ*} {r s : ℝ} (hr : IsSt x r) (hs : IsSt x s) : r = s := by rcases ofSeq_surjective x with ⟨f, rfl⟩ rw [isSt_ofSeq_iff_tendsto] at hr hs exact tendsto_nhds_unique hr hs theorem IsSt.st_eq {x : ℝ*} {r : ℝ} (hxr : IsSt x r) : st x = r := by have h : ∃ r, IsSt x r := ⟨r, hxr⟩ rw [st, dif_pos h] exact (Classical.choose_spec h).unique hxr theorem IsSt.not_infinite {x : ℝ*} {r : ℝ} (h : IsSt x r) : ¬Infinite x := fun hi ↦ hi.elim (fun hp ↦ lt_asymm (h 1 one_pos).2 (hp (r + 1))) fun hn ↦ lt_asymm (h 1 one_pos).1 (hn (r - 1)) theorem not_infinite_of_exists_st {x : ℝ*} : (∃ r : ℝ, IsSt x r) → ¬Infinite x := fun ⟨_r, hr⟩ => hr.not_infinite theorem Infinite.st_eq {x : ℝ*} (hi : Infinite x) : st x = 0 := dif_neg fun ⟨_r, hr⟩ ↦ hr.not_infinite hi theorem isSt_sSup {x : ℝ*} (hni : ¬Infinite x) : IsSt x (sSup { y : ℝ | (y : ℝ*) < x }) := by set S : Set ℝ := { y : ℝ | (y : ℝ*) < x } set R : ℝ := sSup S have hS₀ : S.Nonempty := by obtain ⟨r₁, hr₁⟩ := not_forall.mp (not_or.mp hni).2 exact ⟨r₁ - 1, (coe_lt_coe.2 <| sub_one_lt _).trans_le (not_lt.mp hr₁)⟩ have hS : BddAbove S := by obtain ⟨r₂, hr₂⟩ := not_forall.mp (not_or.mp hni).1 exact ⟨r₂, fun _y hy => coe_le_coe.1 <| hy.le.trans <| not_lt.mp hr₂⟩ intro δ hδ constructor <;> refine lt_of_not_ge fun hx => ?_ · exact (sub_lt_self R hδ).not_ge <| csSup_le hS₀ fun _y hy => coe_le_coe.1 <| hy.le.trans hx · replace hx : ↑(R + δ / 2) < x := by grw [← hx]; norm_cast; linarith exact (le_csSup hS hx).not_gt <| by simpa [R] theorem exists_st_of_not_infinite {x : ℝ*} (hni : ¬Infinite x) : ∃ r : ℝ, IsSt x r := ⟨sSup { y : ℝ | (y : ℝ*) < x }, isSt_sSup hni⟩ theorem st_eq_sSup {x : ℝ*} : st x = sSup { y : ℝ | (y : ℝ*) < x } := by rcases _root_.em (Infinite x) with (hx|hx) · rw [hx.st_eq] cases hx with | inl hx => convert Real.sSup_univ.symm exact Set.eq_univ_of_forall hx | inr hx => convert Real.sSup_empty.symm exact Set.eq_empty_of_forall_notMem fun y hy ↦ hy.out.not_gt (hx _) · exact (isSt_sSup hx).st_eq theorem exists_st_iff_not_infinite {x : ℝ*} : (∃ r : ℝ, IsSt x r) ↔ ¬Infinite x := ⟨not_infinite_of_exists_st, exists_st_of_not_infinite⟩ theorem infinite_iff_not_exists_st {x : ℝ*} : Infinite x ↔ ¬∃ r : ℝ, IsSt x r := iff_not_comm.mp exists_st_iff_not_infinite theorem IsSt.isSt_st {x : ℝ*} {r : ℝ} (hxr : IsSt x r) : IsSt x (st x) := by rwa [hxr.st_eq] theorem isSt_st_of_exists_st {x : ℝ*} (hx : ∃ r : ℝ, IsSt x r) : IsSt x (st x) := let ⟨_r, hr⟩ := hx; hr.isSt_st theorem isSt_st' {x : ℝ*} (hx : ¬Infinite x) : IsSt x (st x) := (isSt_sSup hx).isSt_st theorem isSt_st {x : ℝ*} (hx : st x ≠ 0) : IsSt x (st x) := isSt_st' <| mt Infinite.st_eq hx theorem isSt_refl_real (r : ℝ) : IsSt r r := isSt_ofSeq_iff_tendsto.2 tendsto_const_nhds theorem st_id_real (r : ℝ) : st r = r := (isSt_refl_real r).st_eq theorem eq_of_isSt_real {r s : ℝ} : IsSt r s → r = s := (isSt_refl_real r).unique theorem isSt_real_iff_eq {r s : ℝ} : IsSt r s ↔ r = s := ⟨eq_of_isSt_real, fun hrs => hrs ▸ isSt_refl_real r⟩ theorem isSt_symm_real {r s : ℝ} : IsSt r s ↔ IsSt s r := by rw [isSt_real_iff_eq, isSt_real_iff_eq, eq_comm] theorem isSt_trans_real {r s t : ℝ} : IsSt r s → IsSt s t → IsSt r t := by rw [isSt_real_iff_eq, isSt_real_iff_eq, isSt_real_iff_eq]; exact Eq.trans theorem isSt_inj_real {r₁ r₂ s : ℝ} (h1 : IsSt r₁ s) (h2 : IsSt r₂ s) : r₁ = r₂ := Eq.trans (eq_of_isSt_real h1) (eq_of_isSt_real h2).symm theorem isSt_iff_abs_sub_lt_delta {x : ℝ*} {r : ℝ} : IsSt x r ↔ ∀ δ : ℝ, 0 < δ → |x - ↑r| < δ := by simp only [abs_sub_lt_iff, sub_lt_iff_lt_add, IsSt, and_comm, add_comm] theorem IsSt.map {x : ℝ*} {r : ℝ} (hxr : IsSt x r) {f : ℝ → ℝ} (hf : ContinuousAt f r) : IsSt (x.map f) (f r) := by rcases ofSeq_surjective x with ⟨g, rfl⟩ exact isSt_ofSeq_iff_tendsto.2 <| hf.tendsto.comp (isSt_ofSeq_iff_tendsto.1 hxr) theorem IsSt.map₂ {x y : ℝ*} {r s : ℝ} (hxr : IsSt x r) (hys : IsSt y s) {f : ℝ → ℝ → ℝ} (hf : ContinuousAt (Function.uncurry f) (r, s)) : IsSt (x.map₂ f y) (f r s) := by rcases ofSeq_surjective x with ⟨x, rfl⟩ rcases ofSeq_surjective y with ⟨y, rfl⟩ rw [isSt_ofSeq_iff_tendsto] at hxr hys exact isSt_ofSeq_iff_tendsto.2 <| hf.tendsto.comp (hxr.prodMk_nhds hys) theorem IsSt.add {x y : ℝ*} {r s : ℝ} (hxr : IsSt x r) (hys : IsSt y s) : IsSt (x + y) (r + s) := hxr.map₂ hys continuous_add.continuousAt theorem IsSt.neg {x : ℝ*} {r : ℝ} (hxr : IsSt x r) : IsSt (-x) (-r) := hxr.map continuous_neg.continuousAt theorem IsSt.sub {x y : ℝ*} {r s : ℝ} (hxr : IsSt x r) (hys : IsSt y s) : IsSt (x - y) (r - s) := hxr.map₂ hys continuous_sub.continuousAt theorem IsSt.le {x y : ℝ*} {r s : ℝ} (hrx : IsSt x r) (hsy : IsSt y s) (hxy : x ≤ y) : r ≤ s := not_lt.1 fun h ↦ hxy.not_gt <| hsy.lt hrx h theorem st_le_of_le {x y : ℝ*} (hix : ¬Infinite x) (hiy : ¬Infinite y) : x ≤ y → st x ≤ st y := (isSt_st' hix).le (isSt_st' hiy) theorem lt_of_st_lt {x y : ℝ*} (hix : ¬Infinite x) (hiy : ¬Infinite y) : st x < st y → x < y := (isSt_st' hix).lt (isSt_st' hiy) /-! ### Basic lemmas about infinite -/ theorem infinitePos_def {x : ℝ*} : InfinitePos x ↔ ∀ r : ℝ, ↑r < x := Iff.rfl theorem infiniteNeg_def {x : ℝ*} : InfiniteNeg x ↔ ∀ r : ℝ, x < r := Iff.rfl theorem InfinitePos.pos {x : ℝ*} (hip : InfinitePos x) : 0 < x := hip 0 theorem InfiniteNeg.lt_zero {x : ℝ*} : InfiniteNeg x → x < 0 := fun hin => hin 0 theorem Infinite.ne_zero {x : ℝ*} (hI : Infinite x) : x ≠ 0 := hI.elim (fun hip => hip.pos.ne') fun hin => hin.lt_zero.ne theorem not_infinite_zero : ¬Infinite 0 := fun hI => hI.ne_zero rfl theorem InfiniteNeg.not_infinitePos {x : ℝ*} : InfiniteNeg x → ¬InfinitePos x := fun hn hp => (hn 0).not_gt (hp 0) theorem InfinitePos.not_infiniteNeg {x : ℝ*} (hp : InfinitePos x) : ¬InfiniteNeg x := fun hn ↦ hn.not_infinitePos hp theorem InfinitePos.neg {x : ℝ*} : InfinitePos x → InfiniteNeg (-x) := fun hp r => neg_lt.mp (hp (-r)) theorem InfiniteNeg.neg {x : ℝ*} : InfiniteNeg x → InfinitePos (-x) := fun hp r => lt_neg.mp (hp (-r)) @[simp] theorem infiniteNeg_neg {x : ℝ*} : InfiniteNeg (-x) ↔ InfinitePos x := ⟨fun hin => neg_neg x ▸ hin.neg, InfinitePos.neg⟩ @[simp] theorem infinitePos_neg {x : ℝ*} : InfinitePos (-x) ↔ InfiniteNeg x := ⟨fun hin => neg_neg x ▸ hin.neg, InfiniteNeg.neg⟩ @[simp] theorem infinite_neg {x : ℝ*} : Infinite (-x) ↔ Infinite x := or_comm.trans <| infiniteNeg_neg.or infinitePos_neg nonrec theorem Infinitesimal.not_infinite {x : ℝ*} (h : Infinitesimal x) : ¬Infinite x := h.not_infinite theorem Infinite.not_infinitesimal {x : ℝ*} (h : Infinite x) : ¬Infinitesimal x := fun h' ↦ h'.not_infinite h theorem InfinitePos.not_infinitesimal {x : ℝ*} (h : InfinitePos x) : ¬Infinitesimal x := Infinite.not_infinitesimal (Or.inl h) theorem InfiniteNeg.not_infinitesimal {x : ℝ*} (h : InfiniteNeg x) : ¬Infinitesimal x := Infinite.not_infinitesimal (Or.inr h) theorem infinitePos_iff_infinite_and_pos {x : ℝ*} : InfinitePos x ↔ Infinite x ∧ 0 < x := ⟨fun hip => ⟨Or.inl hip, hip 0⟩, fun ⟨hi, hp⟩ => hi.casesOn id fun hin => False.elim (not_lt_of_gt hp (hin 0))⟩ theorem infiniteNeg_iff_infinite_and_neg {x : ℝ*} : InfiniteNeg x ↔ Infinite x ∧ x < 0 := ⟨fun hip => ⟨Or.inr hip, hip 0⟩, fun ⟨hi, hp⟩ => hi.casesOn (fun hin => False.elim (not_lt_of_gt hp (hin 0))) fun hip => hip⟩ theorem infinitePos_iff_infinite_of_nonneg {x : ℝ*} (hp : 0 ≤ x) : InfinitePos x ↔ Infinite x := .symm <| or_iff_left fun h ↦ h.lt_zero.not_ge hp theorem infinitePos_iff_infinite_of_pos {x : ℝ*} (hp : 0 < x) : InfinitePos x ↔ Infinite x := infinitePos_iff_infinite_of_nonneg hp.le theorem infiniteNeg_iff_infinite_of_neg {x : ℝ*} (hn : x < 0) : InfiniteNeg x ↔ Infinite x := .symm <| or_iff_right fun h ↦ h.pos.not_gt hn theorem infinitePos_abs_iff_infinite_abs {x : ℝ*} : InfinitePos |x| ↔ Infinite |x| := infinitePos_iff_infinite_of_nonneg (abs_nonneg _) @[simp] theorem infinite_abs_iff {x : ℝ*} : Infinite |x| ↔ Infinite x := by cases le_total 0 x <;> simp [*, abs_of_nonneg, abs_of_nonpos, infinite_neg] @[simp] theorem infinitePos_abs_iff_infinite {x : ℝ*} : InfinitePos |x| ↔ Infinite x := infinitePos_abs_iff_infinite_abs.trans infinite_abs_iff theorem infinite_iff_abs_lt_abs {x : ℝ*} : Infinite x ↔ ∀ r : ℝ, (|r| : ℝ*) < |x| := infinitePos_abs_iff_infinite.symm.trans ⟨fun hI r => coe_abs r ▸ hI |r|, fun hR r => (le_abs_self _).trans_lt (hR r)⟩ theorem infinitePos_add_not_infiniteNeg {x y : ℝ*} : InfinitePos x → ¬InfiniteNeg y → InfinitePos (x + y) := by intro hip hnin r obtain ⟨r₂, hr₂⟩ := not_forall.mp hnin convert add_lt_add_of_lt_of_le (hip (r + -r₂)) (not_lt.mp hr₂) using 1 simp theorem not_infiniteNeg_add_infinitePos {x y : ℝ*} : ¬InfiniteNeg x → InfinitePos y → InfinitePos (x + y) := fun hx hy => add_comm y x ▸ infinitePos_add_not_infiniteNeg hy hx theorem infiniteNeg_add_not_infinitePos {x y : ℝ*} : InfiniteNeg x → ¬InfinitePos y → InfiniteNeg (x + y) := by rw [← infinitePos_neg, ← infinitePos_neg, ← @infiniteNeg_neg y, neg_add] exact infinitePos_add_not_infiniteNeg theorem not_infinitePos_add_infiniteNeg {x y : ℝ*} : ¬InfinitePos x → InfiniteNeg y → InfiniteNeg (x + y) := fun hx hy => add_comm y x ▸ infiniteNeg_add_not_infinitePos hy hx theorem infinitePos_add_infinitePos {x y : ℝ*} : InfinitePos x → InfinitePos y → InfinitePos (x + y) := fun hx hy => infinitePos_add_not_infiniteNeg hx hy.not_infiniteNeg theorem infiniteNeg_add_infiniteNeg {x y : ℝ*} : InfiniteNeg x → InfiniteNeg y → InfiniteNeg (x + y) := fun hx hy => infiniteNeg_add_not_infinitePos hx hy.not_infinitePos theorem infinitePos_add_not_infinite {x y : ℝ*} : InfinitePos x → ¬Infinite y → InfinitePos (x + y) := fun hx hy => infinitePos_add_not_infiniteNeg hx (not_or.mp hy).2 theorem infiniteNeg_add_not_infinite {x y : ℝ*} : InfiniteNeg x → ¬Infinite y → InfiniteNeg (x + y) := fun hx hy => infiniteNeg_add_not_infinitePos hx (not_or.mp hy).1 theorem infinitePos_of_tendsto_top {f : ℕ → ℝ} (hf : Tendsto f atTop atTop) : InfinitePos (ofSeq f) := fun r => have hf' := tendsto_atTop_atTop.mp hf let ⟨i, hi⟩ := hf' (r + 1) have hi' : ∀ a : ℕ, f a < r + 1 → a < i := fun a => lt_imp_lt_of_le_imp_le (hi a) have hS : { a : ℕ | r < f a }ᶜ ⊆ { a : ℕ | a ≤ i } := by simp only [Set.compl_setOf, not_lt] exact fun a har => le_of_lt (hi' a (lt_of_le_of_lt har (lt_add_one _))) Germ.coe_lt.2 <| mem_hyperfilter_of_finite_compl <| (Set.finite_le_nat _).subset hS theorem infiniteNeg_of_tendsto_bot {f : ℕ → ℝ} (hf : Tendsto f atTop atBot) : InfiniteNeg (ofSeq f) := fun r => have hf' := tendsto_atTop_atBot.mp hf let ⟨i, hi⟩ := hf' (r - 1) have hi' : ∀ a : ℕ, r - 1 < f a → a < i := fun a => lt_imp_lt_of_le_imp_le (hi a) have hS : { a : ℕ | f a < r }ᶜ ⊆ { a : ℕ | a ≤ i } := by simp only [Set.compl_setOf, not_lt] exact fun a har => le_of_lt (hi' a (lt_of_lt_of_le (sub_one_lt _) har)) Germ.coe_lt.2 <| mem_hyperfilter_of_finite_compl <| (Set.finite_le_nat _).subset hS theorem not_infinite_neg {x : ℝ*} : ¬Infinite x → ¬Infinite (-x) := mt infinite_neg.mp theorem not_infinite_add {x y : ℝ*} (hx : ¬Infinite x) (hy : ¬Infinite y) : ¬Infinite (x + y) := have ⟨r, hr⟩ := exists_st_of_not_infinite hx have ⟨s, hs⟩ := exists_st_of_not_infinite hy not_infinite_of_exists_st <| ⟨r + s, hr.add hs⟩ theorem not_infinite_iff_exist_lt_gt {x : ℝ*} : ¬Infinite x ↔ ∃ r s : ℝ, (r : ℝ*) < x ∧ x < s := ⟨fun hni ↦ let ⟨r, hr⟩ := exists_st_of_not_infinite hni; ⟨r - 1, r + 1, hr 1 one_pos⟩, fun ⟨r, s, hr, hs⟩ hi ↦ hi.elim (fun hp ↦ (hp s).not_gt hs) (fun hn ↦ (hn r).not_gt hr)⟩ theorem not_infinite_real (r : ℝ) : ¬Infinite r := by rw [not_infinite_iff_exist_lt_gt] exact ⟨r - 1, r + 1, coe_lt_coe.2 <| sub_one_lt r, coe_lt_coe.2 <| lt_add_one r⟩ theorem Infinite.ne_real {x : ℝ*} : Infinite x → ∀ r : ℝ, x ≠ r := fun hi r hr => not_infinite_real r <| @Eq.subst _ Infinite _ _ hr hi /-! ### Facts about `st` that require some infinite machinery -/ theorem IsSt.mul {x y : ℝ*} {r s : ℝ} (hxr : IsSt x r) (hys : IsSt y s) : IsSt (x * y) (r * s) := hxr.map₂ hys continuous_mul.continuousAt --AN INFINITE LEMMA THAT REQUIRES SOME MORE ST MACHINERY theorem not_infinite_mul {x y : ℝ*} (hx : ¬Infinite x) (hy : ¬Infinite y) : ¬Infinite (x * y) := have ⟨_r, hr⟩ := exists_st_of_not_infinite hx have ⟨_s, hs⟩ := exists_st_of_not_infinite hy (hr.mul hs).not_infinite --- theorem st_add {x y : ℝ*} (hx : ¬Infinite x) (hy : ¬Infinite y) : st (x + y) = st x + st y := (isSt_st' (not_infinite_add hx hy)).unique ((isSt_st' hx).add (isSt_st' hy)) theorem st_neg (x : ℝ*) : st (-x) = -st x := by classical by_cases h : Infinite x · rw [h.st_eq, (infinite_neg.2 h).st_eq, neg_zero] · exact (isSt_st' (not_infinite_neg h)).unique (isSt_st' h).neg theorem st_mul {x y : ℝ*} (hx : ¬Infinite x) (hy : ¬Infinite y) : st (x * y) = st x * st y := have hx' := isSt_st' hx have hy' := isSt_st' hy have hxy := isSt_st' (not_infinite_mul hx hy) hxy.unique (hx'.mul hy') /-! ### Basic lemmas about infinitesimal -/ theorem infinitesimal_def {x : ℝ*} : Infinitesimal x ↔ ∀ r : ℝ, 0 < r → -(r : ℝ*) < x ∧ x < r := by simp [Infinitesimal, IsSt] theorem lt_of_pos_of_infinitesimal {x : ℝ*} : Infinitesimal x → ∀ r : ℝ, 0 < r → x < r := fun hi r hr => ((infinitesimal_def.mp hi) r hr).2 theorem lt_neg_of_pos_of_infinitesimal {x : ℝ*} : Infinitesimal x → ∀ r : ℝ, 0 < r → -↑r < x := fun hi r hr => ((infinitesimal_def.mp hi) r hr).1 theorem gt_of_neg_of_infinitesimal {x : ℝ*} (hi : Infinitesimal x) (r : ℝ) (hr : r < 0) : ↑r < x := neg_neg r ▸ (infinitesimal_def.1 hi (-r) (neg_pos.2 hr)).1 theorem abs_lt_real_iff_infinitesimal {x : ℝ*} : Infinitesimal x ↔ ∀ r : ℝ, r ≠ 0 → |x| < |↑r| := ⟨fun hi r hr ↦ abs_lt.mpr (coe_abs r ▸ infinitesimal_def.mp hi |r| (abs_pos.2 hr)), fun hR ↦ infinitesimal_def.mpr fun r hr => abs_lt.mp <| (abs_of_pos <| coe_pos.2 hr) ▸ hR r <| hr.ne'⟩ theorem infinitesimal_zero : Infinitesimal 0 := isSt_refl_real 0 theorem Infinitesimal.eq_zero {r : ℝ} : Infinitesimal r → r = 0 := eq_of_isSt_real @[simp] theorem infinitesimal_real_iff {r : ℝ} : Infinitesimal r ↔ r = 0 := isSt_real_iff_eq nonrec theorem Infinitesimal.add {x y : ℝ*} (hx : Infinitesimal x) (hy : Infinitesimal y) : Infinitesimal (x + y) := by simpa only [add_zero] using hx.add hy nonrec theorem Infinitesimal.neg {x : ℝ*} (hx : Infinitesimal x) : Infinitesimal (-x) := by simpa only [neg_zero] using hx.neg @[simp] theorem infinitesimal_neg {x : ℝ*} : Infinitesimal (-x) ↔ Infinitesimal x := ⟨fun h => neg_neg x ▸ h.neg, Infinitesimal.neg⟩ nonrec theorem Infinitesimal.mul {x y : ℝ*} (hx : Infinitesimal x) (hy : Infinitesimal y) : Infinitesimal (x * y) := by simpa only [mul_zero] using hx.mul hy theorem infinitesimal_of_tendsto_zero {f : ℕ → ℝ} (h : Tendsto f atTop (𝓝 0)) : Infinitesimal (ofSeq f) := isSt_of_tendsto h theorem infinitesimal_epsilon : Infinitesimal ε := infinitesimal_of_tendsto_zero tendsto_inv_atTop_nhds_zero_nat theorem not_real_of_infinitesimal_ne_zero (x : ℝ*) : Infinitesimal x → x ≠ 0 → ∀ r : ℝ, x ≠ r := fun hi hx r hr => hx <| hr.trans <| coe_eq_zero.2 <| IsSt.unique (hr.symm ▸ isSt_refl_real r : IsSt x r) hi theorem IsSt.infinitesimal_sub {x : ℝ*} {r : ℝ} (hxr : IsSt x r) : Infinitesimal (x - ↑r) := by simpa only [sub_self] using hxr.sub (isSt_refl_real r) theorem infinitesimal_sub_st {x : ℝ*} (hx : ¬Infinite x) : Infinitesimal (x - ↑(st x)) := (isSt_st' hx).infinitesimal_sub theorem infinitePos_iff_infinitesimal_inv_pos {x : ℝ*} : InfinitePos x ↔ Infinitesimal x⁻¹ ∧ 0 < x⁻¹ := ⟨fun hip => ⟨infinitesimal_def.mpr fun r hr => ⟨lt_trans (coe_lt_coe.2 (neg_neg_of_pos hr)) (inv_pos.2 (hip 0)), inv_lt_of_inv_lt₀ (coe_lt_coe.2 hr) (by convert hip r⁻¹)⟩, inv_pos.2 <| hip 0⟩, fun ⟨hi, hp⟩ r => @_root_.by_cases (r = 0) (↑r < x) (fun h => Eq.substr h (inv_pos.mp hp)) fun h => lt_of_le_of_lt (coe_le_coe.2 (le_abs_self r)) ((inv_lt_inv₀ (inv_pos.mp hp) (coe_lt_coe.2 (abs_pos.2 h))).mp ((infinitesimal_def.mp hi) |r|⁻¹ (inv_pos.2 (abs_pos.2 h))).2)⟩ theorem infiniteNeg_iff_infinitesimal_inv_neg {x : ℝ*} : InfiniteNeg x ↔ Infinitesimal x⁻¹ ∧ x⁻¹ < 0 := by rw [← infinitePos_neg, infinitePos_iff_infinitesimal_inv_pos, inv_neg, neg_pos, infinitesimal_neg] theorem infinitesimal_inv_of_infinite {x : ℝ*} : Infinite x → Infinitesimal x⁻¹ := fun hi => Or.casesOn hi (fun hip => (infinitePos_iff_infinitesimal_inv_pos.mp hip).1) fun hin => (infiniteNeg_iff_infinitesimal_inv_neg.mp hin).1 theorem infinite_of_infinitesimal_inv {x : ℝ*} (h0 : x ≠ 0) (hi : Infinitesimal x⁻¹) : Infinite x := by rcases lt_or_gt_of_ne h0 with hn | hp · exact Or.inr (infiniteNeg_iff_infinitesimal_inv_neg.mpr ⟨hi, inv_lt_zero.mpr hn⟩) · exact Or.inl (infinitePos_iff_infinitesimal_inv_pos.mpr ⟨hi, inv_pos.mpr hp⟩) theorem infinite_iff_infinitesimal_inv {x : ℝ*} (h0 : x ≠ 0) : Infinite x ↔ Infinitesimal x⁻¹ := ⟨infinitesimal_inv_of_infinite, infinite_of_infinitesimal_inv h0⟩ theorem infinitesimal_pos_iff_infinitePos_inv {x : ℝ*} : InfinitePos x⁻¹ ↔ Infinitesimal x ∧ 0 < x := infinitePos_iff_infinitesimal_inv_pos.trans <| by rw [inv_inv] theorem infinitesimal_neg_iff_infiniteNeg_inv {x : ℝ*} : InfiniteNeg x⁻¹ ↔ Infinitesimal x ∧ x < 0 := infiniteNeg_iff_infinitesimal_inv_neg.trans <| by rw [inv_inv] theorem infinitesimal_iff_infinite_inv {x : ℝ*} (h : x ≠ 0) : Infinitesimal x ↔ Infinite x⁻¹ := Iff.trans (by rw [inv_inv]) (infinite_iff_infinitesimal_inv (inv_ne_zero h)).symm /-! ### `Hyperreal.st` stuff that requires infinitesimal machinery -/ theorem IsSt.inv {x : ℝ*} {r : ℝ} (hi : ¬Infinitesimal x) (hr : IsSt x r) : IsSt x⁻¹ r⁻¹ := hr.map <| continuousAt_inv₀ <| by rintro rfl; exact hi hr theorem st_inv (x : ℝ*) : st x⁻¹ = (st x)⁻¹ := by by_cases h0 : x = 0 · rw [h0, inv_zero, ← coe_zero, st_id_real, inv_zero] by_cases h1 : Infinitesimal x · rw [((infinitesimal_iff_infinite_inv h0).mp h1).st_eq, h1.st_eq, inv_zero] by_cases h2 : Infinite x · rw [(infinitesimal_inv_of_infinite h2).st_eq, h2.st_eq, inv_zero] exact ((isSt_st' h2).inv h1).st_eq /-! ### Infinite stuff that requires infinitesimal machinery -/ theorem infinitePos_omega : InfinitePos ω := infinitePos_iff_infinitesimal_inv_pos.mpr ⟨infinitesimal_epsilon, epsilon_pos⟩ theorem infinite_omega : Infinite ω := (infinite_iff_infinitesimal_inv omega_ne_zero).mpr infinitesimal_epsilon theorem infinitePos_mul_of_infinitePos_not_infinitesimal_pos {x y : ℝ*} : InfinitePos x → ¬Infinitesimal y → 0 < y → InfinitePos (x * y) := fun hx hy₁ hy₂ r => by have hy₁' := not_forall.mp (mt infinitesimal_def.2 hy₁) let ⟨r₁, hy₁''⟩ := hy₁' have hyr : 0 < r₁ ∧ ↑r₁ ≤ y := by rwa [Classical.not_imp, ← abs_lt, not_lt, abs_of_pos hy₂] at hy₁'' rw [← div_mul_cancel₀ r (ne_of_gt hyr.1), coe_mul] exact mul_lt_mul (hx (r / r₁)) hyr.2 (coe_lt_coe.2 hyr.1) (le_of_lt (hx 0)) theorem infinitePos_mul_of_not_infinitesimal_pos_infinitePos {x y : ℝ*} : ¬Infinitesimal x → 0 < x → InfinitePos y → InfinitePos (x * y) := fun hx hp hy => mul_comm y x ▸ infinitePos_mul_of_infinitePos_not_infinitesimal_pos hy hx hp theorem infinitePos_mul_of_infiniteNeg_not_infinitesimal_neg {x y : ℝ*} : InfiniteNeg x → ¬Infinitesimal y → y < 0 → InfinitePos (x * y) := by rw [← infinitePos_neg, ← neg_pos, ← neg_mul_neg, ← infinitesimal_neg] exact infinitePos_mul_of_infinitePos_not_infinitesimal_pos theorem infinitePos_mul_of_not_infinitesimal_neg_infiniteNeg {x y : ℝ*} : ¬Infinitesimal x → x < 0 → InfiniteNeg y → InfinitePos (x * y) := fun hx hp hy => mul_comm y x ▸ infinitePos_mul_of_infiniteNeg_not_infinitesimal_neg hy hx hp theorem infiniteNeg_mul_of_infinitePos_not_infinitesimal_neg {x y : ℝ*} : InfinitePos x → ¬Infinitesimal y → y < 0 → InfiniteNeg (x * y) := by rw [← infinitePos_neg, ← neg_pos, neg_mul_eq_mul_neg, ← infinitesimal_neg] exact infinitePos_mul_of_infinitePos_not_infinitesimal_pos theorem infiniteNeg_mul_of_not_infinitesimal_neg_infinitePos {x y : ℝ*} : ¬Infinitesimal x → x < 0 → InfinitePos y → InfiniteNeg (x * y) := fun hx hp hy => mul_comm y x ▸ infiniteNeg_mul_of_infinitePos_not_infinitesimal_neg hy hx hp theorem infiniteNeg_mul_of_infiniteNeg_not_infinitesimal_pos {x y : ℝ*} : InfiniteNeg x → ¬Infinitesimal y → 0 < y → InfiniteNeg (x * y) := by rw [← infinitePos_neg, ← infinitePos_neg, neg_mul_eq_neg_mul] exact infinitePos_mul_of_infinitePos_not_infinitesimal_pos theorem infiniteNeg_mul_of_not_infinitesimal_pos_infiniteNeg {x y : ℝ*} : ¬Infinitesimal x → 0 < x → InfiniteNeg y → InfiniteNeg (x * y) := fun hx hp hy => by rw [mul_comm]; exact infiniteNeg_mul_of_infiniteNeg_not_infinitesimal_pos hy hx hp theorem infinitePos_mul_infinitePos {x y : ℝ*} : InfinitePos x → InfinitePos y → InfinitePos (x * y) := fun hx hy => infinitePos_mul_of_infinitePos_not_infinitesimal_pos hx hy.not_infinitesimal (hy 0) theorem infiniteNeg_mul_infiniteNeg {x y : ℝ*} : InfiniteNeg x → InfiniteNeg y → InfinitePos (x * y) := fun hx hy => infinitePos_mul_of_infiniteNeg_not_infinitesimal_neg hx hy.not_infinitesimal (hy 0) theorem infinitePos_mul_infiniteNeg {x y : ℝ*} : InfinitePos x → InfiniteNeg y → InfiniteNeg (x * y) := fun hx hy => infiniteNeg_mul_of_infinitePos_not_infinitesimal_neg hx hy.not_infinitesimal (hy 0) theorem infiniteNeg_mul_infinitePos {x y : ℝ*} : InfiniteNeg x → InfinitePos y → InfiniteNeg (x * y) := fun hx hy => infiniteNeg_mul_of_infiniteNeg_not_infinitesimal_pos hx hy.not_infinitesimal (hy 0) theorem infinite_mul_of_infinite_not_infinitesimal {x y : ℝ*} : Infinite x → ¬Infinitesimal y → Infinite (x * y) := fun hx hy => have h0 : y < 0 ∨ 0 < y := lt_or_gt_of_ne fun H0 => hy (Eq.substr H0 (isSt_refl_real 0)) hx.elim (h0.elim (fun H0 Hx => Or.inr (infiniteNeg_mul_of_infinitePos_not_infinitesimal_neg Hx hy H0)) fun H0 Hx => Or.inl (infinitePos_mul_of_infinitePos_not_infinitesimal_pos Hx hy H0)) (h0.elim (fun H0 Hx => Or.inl (infinitePos_mul_of_infiniteNeg_not_infinitesimal_neg Hx hy H0)) fun H0 Hx => Or.inr (infiniteNeg_mul_of_infiniteNeg_not_infinitesimal_pos Hx hy H0)) theorem infinite_mul_of_not_infinitesimal_infinite {x y : ℝ*} : ¬Infinitesimal x → Infinite y → Infinite (x * y) := fun hx hy => by rw [mul_comm]; exact infinite_mul_of_infinite_not_infinitesimal hy hx theorem Infinite.mul {x y : ℝ*} : Infinite x → Infinite y → Infinite (x * y) := fun hx hy => infinite_mul_of_infinite_not_infinitesimal hx hy.not_infinitesimal end Hyperreal /- Porting note (https://github.com/leanprover-community/mathlib4/issues/11215): TODO: restore `positivity` plugin namespace Tactic open Positivity private theorem hyperreal_coe_ne_zero {r : ℝ} : r ≠ 0 → (r : ℝ*) ≠ 0 := Hyperreal.coe_ne_zero.2 private theorem hyperreal_coe_nonneg {r : ℝ} : 0 ≤ r → 0 ≤ (r : ℝ*) := Hyperreal.coe_nonneg.2 private theorem hyperreal_coe_pos {r : ℝ} : 0 < r → 0 < (r : ℝ*) := Hyperreal.coe_pos.2 /-- Extension for the `positivity` tactic: cast from `ℝ` to `ℝ*`. -/ @[positivity] unsafe def positivity_coe_real_hyperreal : expr → tactic strictness | q(@coe _ _ $(inst) $(a)) => do unify inst q(@coeToLift _ _ Hyperreal.hasCoeT) let strictness_a ← core a match strictness_a with | positive p => positive <$> mk_app `` hyperreal_coe_pos [p] | nonnegative p => nonnegative <$> mk_app `` hyperreal_coe_nonneg [p] | nonzero p => nonzero <$> mk_app `` hyperreal_coe_ne_zero [p] | e => pp e >>= fail ∘ format.bracket "The expression " " is not of the form `(r : ℝ*)` for `r : ℝ`" end Tactic -/
.lake/packages/mathlib/Mathlib/Analysis/Real/OfDigits.lean
import Mathlib.Algebra.Order.Floor.Semifield import Mathlib.Analysis.Normed.Group.FunctionSeries import Mathlib.Analysis.SpecificLimits.Normed import Mathlib.Tactic.Rify /-! # Representation of reals in positional system This file defines `Real.ofDigits` and `Real.digits` functions which allows to work with the representations of reals as sequences of digits in positional system. ## Main Definitions * `ofDigits`: takes a sequence of digits `(d₀, d₁, ...)` (as an `ℕ → Fin b`), and returns the real number `0.d₀d₁d₂...`. * `digits`: takes a real number in [0,1) and returns the sequence of its digits. ## Main Statements * `ofDigits_digits` states that `ofDigits (digits x b) = x`. -/ namespace Real /-- `ofDigits` takes a sequence of digits `(d₀, d₁, ...)` in base `b` and returns the real number `0.d₀d₁d₂... = ∑ᵢ(dᵢ/bⁱ)`. This auxiliary definition `ofDigitsTerm` sends the sequence to the function sending `i` to `dᵢ/bⁱ`. -/ noncomputable def ofDigitsTerm {b : ℕ} (digits : ℕ → Fin b) : ℕ → ℝ := fun i ↦ (digits i) * ((b : ℝ) ^ (i + 1))⁻¹ theorem ofDigitsTerm_nonneg {b : ℕ} {digits : ℕ → Fin b} {n : ℕ} : 0 ≤ ofDigitsTerm digits n := by simp only [ofDigitsTerm] positivity private lemma b_pos {b : ℕ} (digits : ℕ → Fin b) : 0 < b := Fin.pos (digits 0) theorem ofDigitsTerm_le {b : ℕ} {digits : ℕ → Fin b} {n : ℕ} : ofDigitsTerm digits n ≤ (b - 1) * ((b : ℝ) ^ (n + 1))⁻¹ := by obtain ⟨c, rfl⟩ := Nat.exists_add_one_eq.mpr (b_pos digits) unfold ofDigitsTerm gcongr simp grind theorem summable_ofDigitsTerm {b : ℕ} {digits : ℕ → Fin b} : Summable (ofDigitsTerm digits) := by refine Summable.of_nonneg_of_le (fun _ ↦ ofDigitsTerm_nonneg) (fun _ ↦ ofDigitsTerm_le) ?_ obtain rfl | hb := (Nat.one_le_of_lt (b_pos digits)).eq_or_lt · simpa using summable_zero simp_rw [pow_succ', mul_inv, ← inv_pow, ← mul_assoc] refine Summable.mul_left _ (summable_geometric_of_lt_one (by positivity) ?_) simp [inv_lt_one_iff₀, hb] /-- `ofDigits d` is the real number `0.d₀d₁d₂...` in base `b`. We allow repeating representations like `0.999...` here. -/ noncomputable def ofDigits {b : ℕ} (digits : ℕ → Fin b) : ℝ := ∑' n, ofDigitsTerm digits n theorem ofDigits_nonneg {b : ℕ} (digits : ℕ → Fin b) : 0 ≤ ofDigits digits := by simp only [ofDigits] exact tsum_nonneg fun _ ↦ ofDigitsTerm_nonneg theorem ofDigits_le_one {b : ℕ} (digits : ℕ → Fin b) : ofDigits digits ≤ 1 := by obtain rfl | hb := (Nat.one_le_of_lt (b_pos digits)).eq_or_lt · simp [ofDigits, ofDigitsTerm] rify at hb convert Summable.tsum_mono summable_ofDigitsTerm _ (fun _ ↦ ofDigitsTerm_le) · simp_rw [pow_succ', mul_inv, ← inv_pow, ← mul_assoc] rw [tsum_mul_left, tsum_geometric_of_lt_one (by positivity) (by simp [inv_lt_one_iff₀, hb])] have := sub_pos.mpr hb field · simp_rw [pow_succ', mul_inv, ← inv_pow, ← mul_assoc] refine Summable.mul_left _ (summable_geometric_of_lt_one (by positivity) ?_) simp [inv_lt_one_iff₀, hb] theorem ofDigits_eq_sum_add_ofDigits {b : ℕ} (a : ℕ → Fin b) (n : ℕ) : ofDigits a = (∑ i ∈ Finset.range n, ofDigitsTerm a i) + ((b : ℝ) ^ n)⁻¹ * ofDigits (fun i ↦ a (i + n)) := by simp only [ofDigits] rw [← Summable.sum_add_tsum_nat_add n summable_ofDigitsTerm, ← Summable.tsum_mul_left _ summable_ofDigitsTerm] congr ext i simp only [ofDigitsTerm] ring theorem abs_ofDigits_sub_ofDigits_le {b : ℕ} {x y : ℕ → Fin b} {n : ℕ} (hxy : ∀ i < n, x i = y i) : |ofDigits x - ofDigits y| ≤ ((b : ℝ) ^ n)⁻¹ := by rw [ofDigits_eq_sum_add_ofDigits x n, ofDigits_eq_sum_add_ofDigits y n] have : ∑ i ∈ Finset.range n, ofDigitsTerm x i = ∑ i ∈ Finset.range n, ofDigitsTerm y i := Finset.sum_congr rfl fun i hi ↦ by simp [ofDigitsTerm, hxy i (Finset.mem_range.mp hi)] rw [this, add_sub_add_left_eq_sub, ← mul_sub, abs_mul, abs_of_nonneg (by positivity)] apply mul_le_of_le_one_right (by positivity) convert abs_sub_le_of_le_of_le (ofDigits_nonneg _) (ofDigits_le_one _) (ofDigits_nonneg _) (ofDigits_le_one _) simp /-- Converts a real number `x` from the interval `[0, 1)` into sequence of its digits in base `b`. -/ noncomputable def digits (x : ℝ) (b : ℕ) [NeZero b] : ℕ → Fin b := fun i ↦ Fin.ofNat _ <| ⌊x * b ^ (i + 1)⌋₊ theorem ofDigits_digits_sum_eq {x : ℝ} {b : ℕ} [NeZero b] (hx : x ∈ Set.Ico 0 1) (n : ℕ) : b ^ n * ∑ i ∈ Finset.range n, ofDigitsTerm (digits x b) i = ⌊b ^ n * x⌋₊ := by have := NeZero.ne b induction n with | zero => simp [Nat.floor_eq_zero.mpr hx.right] | succ n ih => rw [Finset.sum_range_succ, mul_add, pow_succ', mul_assoc, ih, ofDigitsTerm, digits, ← pow_succ', mul_left_comm, mul_inv_cancel₀ (by positivity), mul_one, mul_comm x, pow_succ', mul_assoc] set y := (b : ℝ) ^ n * x norm_cast rw [← Nat.cast_mul_floor_div_cancel (a := y) (show b ≠ 0 by cutsat), Fin.val_ofNat, Nat.div_add_mod] theorem le_sum_ofDigitsTerm_digits {x : ℝ} {b : ℕ} [NeZero b] (hb : 1 < b) (hx : x ∈ Set.Ico 0 1) (n : ℕ) : x - (b⁻¹ : ℝ) ^ n ≤ ∑ i ∈ Finset.range n, ofDigitsTerm (digits x b) i := by have := ofDigits_digits_sum_eq (b := b) hx n have h_le := Nat.lt_floor_add_one (b ^ n * x) rw [← this] at h_le rw [← mul_le_mul_iff_right₀ (show 0 < (b : ℝ) ^ n by positivity), mul_sub, inv_pow, mul_inv_cancel₀ (by positivity)] linarith theorem sum_ofDigitsTerm_digits_le {x : ℝ} {b : ℕ} [NeZero b] (hx : x ∈ Set.Ico 0 1) (n : ℕ) : ∑ i ∈ Finset.range n, ofDigitsTerm (digits x b) i ≤ x := by have := ofDigits_digits_sum_eq (b := b) hx n have h_le := Nat.floor_le (a := b ^ n * x) (by have := hx.left; positivity) have hb := NeZero.ne b rw [← this, mul_le_mul_iff_of_pos_left (by positivity)] at h_le exact h_le theorem hasSum_ofDigitsTerm_digits (x : ℝ) {b : ℕ} [NeZero b] (hb : 1 < b) (hx : x ∈ Set.Ico 0 1) : HasSum (ofDigitsTerm (digits x b)) x := by rw [hasSum_iff_tendsto_nat_of_summable_norm (by exact summable_ofDigitsTerm.abs)] refine tendsto_of_tendsto_of_tendsto_of_le_of_le ?_ tendsto_const_nhds (le_sum_ofDigitsTerm_digits hb hx) (sum_ofDigitsTerm_digits_le hx) convert tendsto_const_nhds.sub (tendsto_pow_atTop_nhds_zero_of_abs_lt_one _) · simp · simp [abs_of_nonneg, inv_lt_one_iff₀, hb] theorem ofDigits_digits {b : ℕ} [NeZero b] {x : ℝ} (hb : 1 < b) (hx : x ∈ Set.Ico 0 1) : ofDigits (digits x b) = x := by simp only [ofDigits] rw [← Summable.hasSum_iff] · exact hasSum_ofDigitsTerm_digits x hb hx · exact summable_ofDigitsTerm /-- A generalization of the identity `0.(9) = 1` to arbitrary positional numeral systems. -/ theorem ofDigits_const_last_eq_one {b : ℕ} (hb : 1 < b) : ofDigits (fun _ ↦ (⟨b - 1, Nat.sub_one_lt_of_lt hb⟩ : Fin b)) = 1 := by simp only [ofDigits, ofDigitsTerm, ← inv_pow] rw [Summable.tsum_mul_left] · rw [geom_series_succ _ (by simp [inv_lt_one_iff₀, hb]), tsum_geometric_of_lt_one (by positivity) (by simp [inv_lt_one_iff₀, hb])] push_cast [hb] have : 0 < (b : ℝ) - 1 := by rify at hb; linarith field_simp ring · rw [summable_nat_add_iff (f := fun n ↦ (b : ℝ)⁻¹ ^ n) 1] apply summable_geometric_of_lt_one (by positivity) (by simp [inv_lt_one_iff₀, hb]) theorem ofDigits_SurjOn {b : ℕ} (hb : 1 < b) : Set.SurjOn (ofDigits (b := b)) Set.univ (Set.Icc 0 1) := by have : NeZero b := ⟨by grind⟩ intro y hy by_cases hy' : y ∈ Set.Ico 0 1 · use digits y b simp [ofDigits_digits hb hy'] · simp only [Set.image_univ, show y = 1 by grind, Set.mem_range] exact ⟨_, ofDigits_const_last_eq_one hb⟩ theorem continuous_ofDigits {b : ℕ} : Continuous (@ofDigits b) := by match b with | 0 => fun_prop | 1 => fun_prop | n + 2 => obtain ⟨hb0, hb⟩ : 0 < n + 2 ∧ 1 < n + 2 := by grind generalize n + 2 = b at hb rify at hb0 hb refine continuous_tsum (u := fun i ↦ (b : ℝ)⁻¹ ^ i) ?_ ?_ fun n x ↦ ?_ · simp only [ofDigitsTerm] fun_prop · exact summable_geometric_of_lt_one (by positivity) ((inv_lt_one_of_one_lt₀ hb)) · simp only [norm_eq_abs, abs_of_nonneg ofDigitsTerm_nonneg, inv_pow] apply ofDigitsTerm_le.trans calc _ ≤ b * ((b : ℝ) ^ (n + 1))⁻¹ := by gcongr linarith _ = _ := by grind end Real
.lake/packages/mathlib/Mathlib/Analysis/Real/Spectrum.lean
import Mathlib.Algebra.Algebra.Spectrum.Quasispectrum import Mathlib.Topology.Instances.NNReal.Lemmas import Mathlib.Tactic.ContinuousFunctionalCalculus /-! # Some lemmas on the spectrum and quasispectrum of elements and positivity -/ namespace SpectrumRestricts open NNReal ENNReal variable {A : Type*} [Ring A] [Algebra ℝ A] lemma nnreal_iff {a : A} : SpectrumRestricts a ContinuousMap.realToNNReal ↔ ∀ x ∈ spectrum ℝ a, 0 ≤ x := by refine ⟨fun h x hx ↦ ?_, fun h ↦ ?_⟩ · obtain ⟨x, -, rfl⟩ := h.algebraMap_image.symm ▸ hx exact coe_nonneg x · exact .of_subset_range_algebraMap (fun _ ↦ Real.toNNReal_coe) fun x hx ↦ ⟨⟨x, h x hx⟩, rfl⟩ lemma nnreal_of_nonneg [PartialOrder A] [NonnegSpectrumClass ℝ A] {a : A} (ha : 0 ≤ a) : SpectrumRestricts a ContinuousMap.realToNNReal := nnreal_iff.mpr <| spectrum_nonneg_of_nonneg ha lemma nnreal_le_iff {a : A} (ha : SpectrumRestricts a ContinuousMap.realToNNReal) {r : ℝ≥0} : (∀ x ∈ spectrum ℝ≥0 a, r ≤ x) ↔ ∀ x ∈ spectrum ℝ a, r ≤ x := by simp [← ha.algebraMap_image] lemma nnreal_lt_iff {a : A} (ha : SpectrumRestricts a ContinuousMap.realToNNReal) {r : ℝ≥0} : (∀ x ∈ spectrum ℝ≥0 a, r < x) ↔ ∀ x ∈ spectrum ℝ a, r < x := by simp [← ha.algebraMap_image] lemma le_nnreal_iff {a : A} (ha : SpectrumRestricts a ContinuousMap.realToNNReal) {r : ℝ≥0} : (∀ x ∈ spectrum ℝ≥0 a, x ≤ r) ↔ ∀ x ∈ spectrum ℝ a, x ≤ r := by simp [← ha.algebraMap_image] lemma lt_nnreal_iff {a : A} (ha : SpectrumRestricts a ContinuousMap.realToNNReal) {r : ℝ≥0} : (∀ x ∈ spectrum ℝ≥0 a, x < r) ↔ ∀ x ∈ spectrum ℝ a, x < r := by simp [← ha.algebraMap_image] end SpectrumRestricts namespace QuasispectrumRestricts open NNReal ENNReal local notation "σₙ" => quasispectrum variable {A : Type*} [NonUnitalRing A] lemma nnreal_iff [Module ℝ A] [IsScalarTower ℝ A A] [SMulCommClass ℝ A A] {a : A} : QuasispectrumRestricts a ContinuousMap.realToNNReal ↔ ∀ x ∈ σₙ ℝ a, 0 ≤ x := by rw [quasispectrumRestricts_iff_spectrumRestricts_inr, Unitization.quasispectrum_eq_spectrum_inr' _ ℝ, SpectrumRestricts.nnreal_iff] lemma nnreal_of_nonneg [Module ℝ A] [IsScalarTower ℝ A A] [SMulCommClass ℝ A A] [PartialOrder A] [NonnegSpectrumClass ℝ A] {a : A} (ha : 0 ≤ a) : QuasispectrumRestricts a ContinuousMap.realToNNReal := nnreal_iff.mpr <| quasispectrum_nonneg_of_nonneg _ ha lemma le_nnreal_iff [Module ℝ A] [IsScalarTower ℝ A A] [SMulCommClass ℝ A A] {a : A} (ha : QuasispectrumRestricts a ContinuousMap.realToNNReal) {r : ℝ≥0} : (∀ x ∈ quasispectrum ℝ≥0 a, x ≤ r) ↔ ∀ x ∈ quasispectrum ℝ a, x ≤ r := by simp [← ha.algebraMap_image] lemma lt_nnreal_iff [Module ℝ A] [IsScalarTower ℝ A A] [SMulCommClass ℝ A A] {a : A} (ha : QuasispectrumRestricts a ContinuousMap.realToNNReal) {r : ℝ≥0} : (∀ x ∈ quasispectrum ℝ≥0 a, x < r) ↔ ∀ x ∈ quasispectrum ℝ a, x < r := by simp [← ha.algebraMap_image] end QuasispectrumRestricts variable {A : Type*} [Ring A] [PartialOrder A] open scoped NNReal lemma coe_mem_spectrum_real_of_nonneg [Algebra ℝ A] [NonnegSpectrumClass ℝ A] {a : A} {x : ℝ≥0} (ha : 0 ≤ a := by cfc_tac) : (x : ℝ) ∈ spectrum ℝ a ↔ x ∈ spectrum ℝ≥0 a := by simp [← (SpectrumRestricts.nnreal_of_nonneg ha).algebraMap_image, Set.mem_image, NNReal.algebraMap_eq_coe]