/- Portions of this file have been adapted from an external source. The source copyright header and license information are preserved below. -/ import Mathlib namespace OAI section open Set MeasureTheory open scoped ENNReal InnerProductSpace namespace LogBrunnMinkowski abbrev Space (n : ℕ) := EuclideanSpace ℝ (Fin n) def IsConvexBody {n : ℕ} (K : Set (Space n)) : Prop := IsCompact K ∧ Convex ℝ K ∧ (interior K).Nonempty def OriginSymmetric {n : ℕ} (K : Set (Space n)) : Prop := ∀ x, x ∈ K ↔ -x ∈ K noncomputable def support {n : ℕ} (K : Set (Space n)) (u : Space n) : ℝ := sSup ((fun x : Space n => ⟪x, u⟫_ℝ) '' K) def wulff {n : ℕ} (f : Space n → ℝ) : Set (Space n) := {x | ∀ u, ‖u‖ = 1 → ⟪x, u⟫_ℝ ≤ f u} noncomputable def logCombination {n : ℕ} (K L : Set (Space n)) (t : ℝ) : Set (Space n) := wulff (fun u => (support K u) ^ (1 - t) * (support L u) ^ t) end LogBrunnMinkowski end section open Set MeasureTheory Filter open scoped InnerProductSpace Topology NNReal namespace CompactMomentVariational noncomputable section variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] def conjugate (K : Set E) (u : E → ℝ) (z : E) : ℝ := sSup ((fun x => ⟪x,z⟫_ℝ-u x) '' K) lemma values_nonempty {K : Set E} (hK : K.Nonempty) (u : E → ℝ) (z : E) : ((fun x => ⟪x,z⟫_ℝ-u x) '' K).Nonempty := hK.image _ lemma values_bdd {K : Set E} {u : E → ℝ} {R m : ℝ} (hR : ∀ x ∈ K, ‖x‖ ≤ R) (hu : ∀ x ∈ K, m ≤ u x) (z : E) : BddAbove ((fun x => ⟪x,z⟫_ℝ-u x) '' K) := by refine ⟨R*‖z‖-m, ?_⟩ rintro _ ⟨x,hx,rfl⟩ have hi := real_inner_le_norm x z have hn := mul_le_mul_of_nonneg_right (hR x hx) (norm_nonneg z) have hm := hu x hx linarith lemma le_conjugate {K : Set E} {u : E → ℝ} {R m : ℝ} (hR : ∀ x ∈ K, ‖x‖ ≤ R) (hu : ∀ x ∈ K, m ≤ u x) {x : E} (hx : x ∈ K) (z : E) : ⟪x,z⟫_ℝ-u x ≤ conjugate K u z := le_csSup (values_bdd hR hu z) (mem_image_of_mem _ hx) lemma conjugate_le {K : Set E} (hK : K.Nonempty) {u : E → ℝ} {z : E} {b : ℝ} (h : ∀ x ∈ K, ⟪x,z⟫_ℝ-u x ≤ b) : conjugate K u z ≤ b := by apply csSup_le (values_nonempty hK u z) rintro _ ⟨x,hx,rfl⟩ exact h x hx lemma conjugate_upper {K : Set E} (hK : K.Nonempty) {u : E → ℝ} {R m : ℝ} (hR : ∀ x ∈ K, ‖x‖ ≤ R) (hu : ∀ x ∈ K, m ≤ u x) (z : E) : conjugate K u z ≤ R*‖z‖-m := by apply conjugate_le hK intro x hx have hi := real_inner_le_norm x z have hn := mul_le_mul_of_nonneg_right (hR x hx) (norm_nonneg z) have hm := hu x hx linarith lemma conjugate_nonneg {K : Set E} {u : E → ℝ} {R : ℝ} (hR : ∀ x ∈ K, ‖x‖ ≤ R) (hu : ∀ x ∈ K, 0 ≤ u x) (h0 : (0:E) ∈ K) (hu0 : u 0=0) (z : E) : 0 ≤ conjugate K u z := by simpa [hu0] using le_conjugate hR hu h0 z lemma conjugate_zero {K : Set E} {u : E → ℝ} {R : ℝ} (hR : ∀ x ∈ K, ‖x‖ ≤ R) (hu : ∀ x ∈ K, 0 ≤ u x) (h0 : (0:E) ∈ K) (hu0 : u 0=0) : conjugate K u 0=0 := by apply le_antisymm _ (conjugate_nonneg hR hu h0 hu0 0) simpa using conjugate_upper ⟨0,h0⟩ hR hu 0 lemma convexOn_conjugate {K : Set E} (hK : K.Nonempty) {u : E → ℝ} {R m : ℝ} (hR : ∀ x ∈ K, ‖x‖ ≤ R) (hu : ∀ x ∈ K, m ≤ u x) : ConvexOn ℝ univ (conjugate K u) := by refine ⟨convex_univ, ?_⟩ intro z _ w _ a b ha hb hab apply conjugate_le hK intro x hx have hz := le_conjugate hR hu hx z have hw := le_conjugate hR hu hx w dsimp only [smul_eq_mul] rw [inner_add_right, inner_smul_right, inner_smul_right] have habu : (a+b)*u x=u x := by rw [hab,one_mul] nlinarith [mul_le_mul_of_nonneg_left hz ha, mul_le_mul_of_nonneg_left hw hb] lemma conjugate_sub_le {K : Set E} (hK : K.Nonempty) {u : E → ℝ} {R m : ℝ} (hR : ∀ x ∈ K, ‖x‖ ≤ R) (hu : ∀ x ∈ K, m ≤ u x) (z w : E) : conjugate K u z-conjugate K u w ≤ R*‖z-w‖ := by apply sub_le_iff_le_add.mpr apply conjugate_le hK intro x hx have hw := le_conjugate hR hu hx w have hi := real_inner_le_norm x (z-w) rw [inner_sub_right] at hi have hn := mul_le_mul_of_nonneg_right (hR x hx) (norm_nonneg (z-w)) linarith lemma conjugate_lipschitz {K : Set E} (hK : K.Nonempty) {u : E → ℝ} {R : ℝ≥0} {m : ℝ} (hR : ∀ x ∈ K, ‖x‖ ≤ R) (hu : ∀ x ∈ K, m ≤ u x) : LipschitzWith R (conjugate K u) := by rw [lipschitzWith_iff_dist_le_mul] intro z w rw [Real.dist_eq, dist_eq_norm] apply abs_le.mpr constructor · have h := conjugate_sub_le hK hR hu w z rw [norm_sub_rev] at h linarith · exact conjugate_sub_le hK hR hu z w lemma conjugate_even {K : Set E} (hK : K.Nonempty) {u : E → ℝ} {R m : ℝ} (hR : ∀ x ∈ K, ‖x‖ ≤ R) (hu : ∀ x ∈ K, m ≤ u x) (hKe : ∀ x ∈ K, -x ∈ K) (hue : Function.Even u) : Function.Even (conjugate K u) := by have hle (z : E) : conjugate K u (-z) ≤ conjugate K u z := by apply conjugate_le hK intro x hx simpa only [inner_neg_left,inner_neg_right,hue x] using le_conjugate hR hu (hKe x hx) z intro z apply le_antisymm (hle z) simpa using hle (-z) lemma conjugate_coercive {K : Set E} {u : E → ℝ} {R m r B : ℝ} (hr : 0 ≤ r) (hR : ∀ x ∈ K, ‖x‖ ≤ R) (hu : ∀ x ∈ K, m ≤ u x) (hrK : Metric.closedBall (0:E) r ⊆ K) (hB : ∀ x ∈ Metric.closedBall (0:E) r, u x ≤ B) (z : E) : r*‖z‖-B ≤ conjugate K u z := by by_cases hz : z=0 · subst z have h0 : (0:E) ∈ Metric.closedBall 0 r := by simpa using hr have h := le_conjugate hR hu (hrK h0) (0:E) have hb := hB 0 h0 simp only [inner_zero_right,norm_zero,mul_zero] at * linarith · have hn : ‖z‖ ≠ 0 := norm_ne_zero_iff.mpr hz let x : E := (r/‖z‖) • z have hx : x ∈ Metric.closedBall (0:E) r := by simp [x,Metric.mem_closedBall,dist_zero_right,norm_smul,abs_of_nonneg hr,hn] have hi : ⟪x,z⟫_ℝ=r*‖z‖ := by simp only [x,real_inner_smul_left,real_inner_self_eq_norm_sq] field_simp have hl := le_conjugate hR hu (hrK hx) z rw [hi] at hl linarith [hB x hx] lemma convex_small_ball_bound {u : E → ℝ} {r M : ℝ} (hr : 0 < r) (hM : 0 ≤ M) (hu : ConvexOn ℝ (Metric.closedBall (0:E) r) u) (hu0 : u 0=0) (hB : ∀ x ∈ Metric.closedBall (0:E) r, u x ≤ M) : ∀ x ∈ Metric.closedBall (0:E) (r/(M+1)), u x ≤ 1 := by intro x hx have hMp : 0 < M+1 := by linarith let y : E := (M+1) • x have hy : y ∈ Metric.closedBall (0:E) r := by rw [Metric.mem_closedBall,dist_zero_right] at hx ⊢ rw [show y=(M+1) • x from rfl,norm_smul,Real.norm_eq_abs,abs_of_pos hMp] simpa only [mul_comm] using (le_div_iff₀ hMp).mp hx have h0 : (0:E) ∈ Metric.closedBall (0:E) r := by simpa using hr.le have ha : 0 ≤ (M+1)⁻¹ := inv_nonneg.mpr hMp.le have hb : 0 ≤ 1-(M+1)⁻¹ := sub_nonneg.mpr (inv_le_one_of_one_le₀ (by linarith)) have h := hu.2 hy h0 ha hb (by ring) have harg : (M+1)⁻¹ • y+(1-(M+1)⁻¹) • (0:E)=x := by simp [y,smul_smul,hMp.ne'] rw [harg,hu0,smul_eq_mul,smul_eq_mul,mul_zero,add_zero] at h have hm : (M+1)⁻¹*M ≤ 1 := by rw [inv_mul_le_iff₀ hMp] linarith exact h.trans ((mul_le_mul_of_nonneg_left (hB y hy) ha).trans hm) section MeanBound variable [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] (μ : Measure E) [μ.IsAddHaarMeasure] lemma convex_ball_mean_bound_at {u : E → ℝ} {r R : ℝ} (_hr : 0 < r) (hc : ConvexOn ℝ (Metric.closedBall (0:E) R) u) (hn : ∀ y ∈ Metric.closedBall (0:E) R, 0 ≤ u y) (hi : IntegrableOn u (Metric.closedBall (0:E) R) μ) {x : E} (hx : ‖x‖+r ≤ R) : μ.real (Metric.closedBall (0:E) r)*u x ≤ ∫ y in Metric.closedBall (0:E) R, u y ∂μ := by let K := Metric.closedBall (0:E) R let S := Metric.closedBall (0:E) r let f := K.indicator u have hi' : Integrable f μ := hi.integrable_indicator measurableSet_closedBall have hf : ∀ y, 0 ≤ f y := fun y => Set.indicator_nonneg (fun z hz => hn z hz) y have hia : Integrable (fun y => f (x+y)) μ := hi'.comp_add_left x have his : Integrable (fun y => f (x-y)) μ := hi'.comp_sub_left x have hmS : μ S < ⊤ := (isCompact_closedBall (0:E) r).measure_lt_top let : Fact (μ S < ⊤) := ⟨hmS⟩ have hmid : ∀ y ∈ S, 2*u x ≤ f (x+y)+f (x-y) := by intro y hy have hyn : ‖y‖ ≤ r := by simpa [S,Metric.mem_closedBall,dist_zero_right] using hy have hplus : x+y ∈ K := by rw [show K=Metric.closedBall (0:E) R from rfl,Metric.mem_closedBall,dist_zero_right] exact (norm_add_le x y).trans (by linarith) have hminus : x-y ∈ K := by rw [show K=Metric.closedBall (0:E) R from rfl,Metric.mem_closedBall,dist_zero_right] exact (norm_sub_le x y).trans (by linarith) have h := hc.2 hplus hminus (show (0:ℝ)≤1/2 by norm_num) (show (0:ℝ)≤1/2 by norm_num) (show (1:ℝ)/2+1/2=1 by norm_num) have havg : (1/2:ℝ) • (x+y)+(1/2:ℝ) • (x-y)=x := by module rw [havg] at h rw [show f (x+y)=u (x+y) from Set.indicator_of_mem hplus u, show f (x-y)=u (x-y) from Set.indicator_of_mem hminus u] dsimp only [smul_eq_mul] at h linarith have hh := setIntegral_mono_on (integrable_const (2*u x)) (hia.add his).integrableOn measurableSet_closedBall hmid simp only [Pi.add_apply] at hh rw [integral_add hia.integrableOn his.integrableOn,integral_const] at hh have hla : (∫ y in S, f (x+y) ∂μ) ≤ ∫ y, f y ∂μ := by calc _ ≤ ∫ y, f (x+y) ∂μ := integral_mono_measure Measure.restrict_le_self (Eventually.of_forall (fun y => hf (x+y))) hia _ = _ := integral_add_left_eq_self f x have hls : (∫ y in S, f (x-y) ∂μ) ≤ ∫ y, f y ∂μ := by calc _ ≤ ∫ y, f (x-y) ∂μ := integral_mono_measure Measure.restrict_le_self (Eventually.of_forall (fun y => hf (x-y))) his _ = _ := integral_sub_left_eq_self f μ x have hfint : (∫ y, f y ∂μ) = ∫ y in Metric.closedBall (0:E) R, u y ∂μ := integral_indicator measurableSet_closedBall simp only [Measure.restrict_apply_univ,Measure.real,smul_eq_mul] at hh rw [hfint] at hla hls change (μ S).toReal*u x ≤ _ linarith lemma convex_ball_mean_bound {u : E → ℝ} {r R : ℝ} (_hr : 0 < r) (hrR : 2*r ≤ R) (hc : ConvexOn ℝ (Metric.closedBall (0:E) R) u) (hn : ∀ y ∈ Metric.closedBall (0:E) R, 0 ≤ u y) (hi : IntegrableOn u (Metric.closedBall (0:E) R) μ) {x : E} (hx : x ∈ Metric.closedBall (0:E) r) : μ.real (Metric.closedBall (0:E) r)*u x ≤ ∫ y in Metric.closedBall (0:E) R, u y ∂μ := by let K := Metric.closedBall (0:E) R let S := Metric.closedBall (0:E) r let f := K.indicator u have hi' : Integrable f μ := hi.integrable_indicator measurableSet_closedBall have hf : ∀ y, 0 ≤ f y := fun y => Set.indicator_nonneg (fun z hz => hn z hz) y have hia : Integrable (fun y => f (x+y)) μ := hi'.comp_add_left x have his : Integrable (fun y => f (x-y)) μ := hi'.comp_sub_left x have hmS : μ S < ⊤ := (isCompact_closedBall (0:E) r).measure_lt_top let : Fact (μ S < ⊤) := ⟨hmS⟩ have hmid : ∀ y ∈ S, 2*u x ≤ f (x+y)+f (x-y) := by intro y hy have hxn : ‖x‖ ≤ r := by simpa [Metric.mem_closedBall,dist_zero_right] using hx have hyn : ‖y‖ ≤ r := by simpa [S,Metric.mem_closedBall,dist_zero_right] using hy have hplus : x+y ∈ K := by rw [show K=Metric.closedBall (0:E) R from rfl,Metric.mem_closedBall,dist_zero_right] exact (norm_add_le x y).trans (by linarith) have hminus : x-y ∈ K := by rw [show K=Metric.closedBall (0:E) R from rfl,Metric.mem_closedBall,dist_zero_right] exact (norm_sub_le x y).trans (by linarith) have h := hc.2 hplus hminus (show (0:ℝ)≤1/2 by norm_num) (show (0:ℝ)≤1/2 by norm_num) (show (1:ℝ)/2+1/2=1 by norm_num) have havg : (1/2:ℝ) • (x+y)+(1/2:ℝ) • (x-y)=x := by module rw [havg] at h rw [show f (x+y)=u (x+y) from Set.indicator_of_mem hplus u, show f (x-y)=u (x-y) from Set.indicator_of_mem hminus u] dsimp only [smul_eq_mul] at h linarith have hh := setIntegral_mono_on (integrable_const (2*u x)) (hia.add his).integrableOn measurableSet_closedBall hmid simp only [Pi.add_apply] at hh rw [integral_add hia.integrableOn his.integrableOn,integral_const] at hh have hla : (∫ y in S, f (x+y) ∂μ) ≤ ∫ y, f y ∂μ := by calc _ ≤ ∫ y, f (x+y) ∂μ := integral_mono_measure Measure.restrict_le_self (Eventually.of_forall (fun y => hf (x+y))) hia _ = _ := integral_add_left_eq_self f x have hls : (∫ y in S, f (x-y) ∂μ) ≤ ∫ y, f y ∂μ := by calc _ ≤ ∫ y, f (x-y) ∂μ := integral_mono_measure Measure.restrict_le_self (Eventually.of_forall (fun y => hf (x-y))) his _ = _ := integral_sub_left_eq_self f μ x have hfint : (∫ y, f y ∂μ) = ∫ y in Metric.closedBall (0:E) R, u y ∂μ := integral_indicator measurableSet_closedBall simp only [Measure.restrict_apply_univ,Measure.real,smul_eq_mul] at hh rw [hfint] at hla hls change (μ S).toReal*u x ≤ _ linarith lemma convex_ball_probability_bound {u : E → ℝ} {r R d : ℝ} (hr : 0 < r) (hrR : 2*r ≤ R) (hd : 0 < d) (hc : ConvexOn ℝ (Metric.closedBall (0:E) R) u) (hn : ∀ y, 0 ≤ u y) (ν : Measure E) (hν : ENNReal.ofReal d • μ.restrict (Metric.closedBall (0:E) R) ≤ ν) (hi : Integrable u ν) {x : E} (hx : x ∈ Metric.closedBall (0:E) r) : d*μ.real (Metric.closedBall (0:E) r)*u x ≤ ∫ y, u y ∂ν := by have hid := hi.mono_measure hν have hiBall : IntegrableOn u (Metric.closedBall (0:E) R) μ := by exact (integrable_smul_measure (ne_of_gt (ENNReal.ofReal_pos.mpr hd)) ENNReal.ofReal_ne_top).mp hid have hb := convex_ball_mean_bound μ hr hrR hc (fun y _ => hn y) hiBall hx calc d*μ.real (Metric.closedBall (0:E) r)*u x ≤ d*(∫ y in Metric.closedBall (0:E) R, u y ∂μ) := by nlinarith [mul_le_mul_of_nonneg_left hb hd.le] _ = ∫ y, u y ∂(ENNReal.ofReal d • μ.restrict (Metric.closedBall (0:E) R)) := by rw [integral_smul_measure,ENNReal.toReal_ofReal hd.le,smul_eq_mul] _ ≤ ∫ y, u y ∂ν := integral_mono_measure hν (Eventually.of_forall hn) hi lemma convex_ball_probability_bound_at {u : E → ℝ} {r R d : ℝ} (hr : 0 < r) (hd : 0 < d) (hc : ConvexOn ℝ (Metric.closedBall (0:E) R) u) (hn : ∀ y, 0 ≤ u y) (ν : Measure E) (hν : ENNReal.ofReal d • μ.restrict (Metric.closedBall (0:E) R) ≤ ν) (hi : Integrable u ν) {x : E} (hx : ‖x‖+r ≤ R) : d*μ.real (Metric.closedBall (0:E) r)*u x ≤ ∫ y, u y ∂ν := by have hid := hi.mono_measure hν have hiBall : IntegrableOn u (Metric.closedBall (0:E) R) μ := (integrable_smul_measure (ne_of_gt (ENNReal.ofReal_pos.mpr hd)) ENNReal.ofReal_ne_top).mp hid have hb := convex_ball_mean_bound_at μ hr hc (fun y _ => hn y) hiBall hx calc d*μ.real (Metric.closedBall (0:E) r)*u x ≤ d*(∫ y in Metric.closedBall (0:E) R, u y ∂μ) := by nlinarith [mul_le_mul_of_nonneg_left hb hd.le] _ = ∫ y, u y ∂(ENNReal.ofReal d • μ.restrict (Metric.closedBall (0:E) R)) := by rw [integral_smul_measure,ENNReal.toReal_ofReal hd.le,smul_eq_mul] _ ≤ ∫ y, u y ∂ν := integral_mono_measure hν (Eventually.of_forall hn) hi end MeanBound section Partition variable [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] (μ : Measure E) [μ.IsAddHaarMeasure] lemma integrable_exp_neg_norm {c : ℝ} (hc : 0 < c) : Integrable (fun x : E => Real.exp (-c*‖x‖)) μ := by let r : ℝ := Module.finrank ℝ E + 1 have hr : (Module.finrank ℝ E : ℝ) < r := by dsimp [r]; linarith have hi : Integrable (fun x : E => (1+‖x‖)^(-r)) μ := integrable_one_add_norm hr have hl : LocallyIntegrable (fun x : E => Real.exp (-c*‖x‖)) μ := (show Continuous (fun x : E => Real.exp (-c*‖x‖)) by fun_prop).locallyIntegrable have ht : Tendsto (fun x : E => (1:ℝ)+‖x‖) (cocompact E) atTop := tendsto_atTop_add_const_left _ 1 tendsto_norm_cocompact_atTop have hO := (isLittleO_exp_neg_mul_rpow_atTop hc (-r)).isBigO.comp_tendsto ht have hO' := hO.const_mul_left (Real.exp c) have hfn : (fun x : E => Real.exp c * Real.exp (-c * (1+‖x‖))) = (fun x : E => Real.exp (-c*‖x‖)) := by funext x rw [← Real.exp_add] congr 1 ring simp only [Function.comp_apply] at hO' rw [hfn] at hO' exact hl.integrable_of_isBigO_cocompact hO' (hi.integrableAtFilter (cocompact E)) lemma integral_exp_neg_norm_scale {c : ℝ} (hc : 0 < c) : (∫ x : E, Real.exp (-c*‖x‖) ∂μ) = (c^Module.finrank ℝ E)⁻¹ * ∫ x : E, Real.exp (-‖x‖) ∂μ := by simpa only [norm_smul, Real.norm_eq_abs, abs_of_pos hc, neg_mul, smul_eq_mul] using Measure.integral_comp_smul_of_nonneg μ (fun x : E => Real.exp (-‖x‖)) c (hR:=hc.le) lemma tail_integrable {φ : E → ℝ} (hφ : Continuous φ) {c b : ℝ} (hc : 0 < c) (hl : ∀ z, c*‖z‖-b ≤ φ z) : Integrable (fun z => Real.exp (-φ z)) μ := by refine ((integrable_exp_neg_norm μ hc).const_mul (Real.exp b)).mono' (Real.continuous_exp.comp hφ.neg).aestronglyMeasurable ?_ exact Eventually.of_forall fun z => by rw [Real.norm_eq_abs, abs_of_pos (Real.exp_pos _), ← Real.exp_add] exact Real.exp_le_exp.mpr (by linarith [hl z]) lemma partition_bound {φ : E → ℝ} (hφ : Continuous φ) {c b : ℝ} (hc : 0 < c) (hl : ∀ z, c*‖z‖-b ≤ φ z) : (∫ z, Real.exp (-φ z) ∂μ) ≤ Real.exp b * (c^Module.finrank ℝ E)⁻¹ * ∫ z : E, Real.exp (-‖z‖) ∂μ := by calc _ ≤ ∫ z, Real.exp b * Real.exp (-c*‖z‖) ∂μ := by apply integral_mono (tail_integrable μ hφ hc hl) ((integrable_exp_neg_norm μ hc).const_mul _) intro z dsimp only rw [← Real.exp_add] exact Real.exp_le_exp.mpr (by linarith [hl z]) _ = _ := by rw [integral_const_mul,integral_exp_neg_norm_scale μ hc]; ring lemma log_partition_bound {φ : E → ℝ} (hφ : Continuous φ) {c b : ℝ} (hc : 0 < c) (hl : ∀ z, c*‖z‖-b ≤ φ z) : Real.log (∫ z, Real.exp (-φ z) ∂μ) ≤ b - (Module.finrank ℝ E)*Real.log c + Real.log (∫ z : E, Real.exp (-‖z‖) ∂μ) := by have hI : 0 < ∫ z, Real.exp (-φ z) ∂μ := integral_exp_pos (tail_integrable μ hφ hc hl) have hN : 0 < ∫ z : E, Real.exp (-‖z‖) ∂μ := by exact integral_exp_pos (by simpa using integrable_exp_neg_norm μ (show (0:ℝ)<1 by norm_num)) have h := Real.log_le_log hI (partition_bound μ hφ hc hl) rw [Real.log_mul (mul_ne_zero (Real.exp_ne_zero _) (inv_ne_zero (pow_ne_zero _ hc.ne'))) hN.ne', Real.log_mul (Real.exp_ne_zero _) (inv_ne_zero (pow_ne_zero _ hc.ne')), Real.log_exp, Real.log_inv, Real.log_pow] at h simpa [sub_eq_add_neg] using h end Partition variable [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] (μ : Measure E) [μ.IsAddHaarMeasure] omit [BorelSpace E] in lemma ball_real_pos {r : ℝ} (hr : 0 < r) : 0 < μ.real (Metric.closedBall (0:E) r) := by apply ENNReal.toReal_pos · apply ne_of_gt exact (Metric.isOpen_ball.measure_pos μ ⟨0,by simpa using hr⟩).trans_le (measure_mono Metric.ball_subset_closedBall) · exact (isCompact_closedBall (0:E) r).measure_ne_top lemma mean_conjugate_lower {u : E → ℝ} {r R d : ℝ} (hr : 0 < r) (hrR : 2*r ≤ R) (hd : 0 < d) (hc : ConvexOn ℝ (Metric.closedBall (0:E) R) u) (hn : ∀ y, 0 ≤ u y) (hu0 : u 0=0) (ν : Measure E) (hν : ENNReal.ofReal d • μ.restrict (Metric.closedBall (0:E) R) ≤ ν) (hi : Integrable u ν) (z : E) : (r/((∫ y, u y ∂ν)/(d*μ.real (Metric.closedBall (0:E) r))+1))*‖z‖-1 ≤ conjugate (Metric.closedBall (0:E) R) u z := by let C := d*μ.real (Metric.closedBall (0:E) r) let M := (∫ y, u y ∂ν)/C have hC : 0 < C := mul_pos hd (ball_real_pos μ hr) have hM : 0 ≤ M := div_nonneg (integral_nonneg hn) hC.le have hMp : 0 < M+1 := by positivity have hrR' : r ≤ R := by linarith have hB : ∀ x ∈ Metric.closedBall (0:E) r, u x ≤ M := by intro x hx apply (le_div_iff₀ hC).mpr simpa [C,mul_comm] using convex_ball_probability_bound μ hr hrR hd hc hn ν hν hi hx have hSmall : ∀ x ∈ Metric.closedBall (0:E) (r/(M+1)), u x ≤ 1 := convex_small_ball_bound hr hM (hc.subset (Metric.closedBall_subset_closedBall hrR') (convex_closedBall _ _)) hu0 hB have hsr : r/(M+1) ≤ r := (div_le_iff₀ hMp).mpr (by nlinarith) apply conjugate_coercive (le_of_lt (div_pos hr hMp)) (fun x hx => by simpa [Metric.mem_closedBall,dist_zero_right] using hx) (fun x _ => hn x) (Metric.closedBall_subset_closedBall (hsr.trans hrR')) hSmall lemma logarithmic_growth_bound {N C m : ℝ} (hN : 0 ≤ N) (hC : 0 < C) (hm : 0 ≤ m) : N*Real.log (m/C+1) ≤ m/2+C/2+N*Real.log (2*(N+1)/C) := by have hA : 0 < 2*(N+1) := by positivity have hmC : 0 < m+C := by positivity have hq : 0 < (m+C)/(2*(N+1)) := div_pos hmC hA have hid : m/C+1 = (m+C)/(2*(N+1))*(2*(N+1)/C) := by field_simp rw [hid,Real.log_mul hq.ne' (div_ne_zero hA.ne' hC.ne'),mul_add] have hl := Real.log_le_sub_one_of_pos hq have hcoef : N*((m+C)/(2*(N+1))-1) ≤ (m+C)/2 := by have he : (2*(N+1))*((m+C)/(2*(N+1)))=m+C := mul_div_cancel₀ _ hA.ne' nlinarith [mul_nonneg hN hq.le] have hh := (mul_le_mul_of_nonneg_left hl hN).trans hcoef linarith def functional (ν : Measure E) (K : Set E) (u : E → ℝ) : ℝ := Real.log (∫ z, Real.exp (-conjugate K u z) ∂μ) - ∫ x, u x ∂ν def coercivityConstant (r d : ℝ) : ℝ := let C := d*μ.real (Metric.closedBall (0:E) r) let N : ℝ := Module.finrank ℝ E 1-N*Real.log r + Real.log (∫ z : E, Real.exp (-‖z‖) ∂μ) + C/2+N*Real.log (2*(N+1)/C) lemma functional_coercive {u : E → ℝ} {r R d : ℝ} (hr : 0 < r) (hrR : 2*r ≤ R) (hd : 0 < d) (hc : ConvexOn ℝ (Metric.closedBall (0:E) R) u) (hn : ∀ y, 0 ≤ u y) (hu0 : u 0=0) (ν : Measure E) (hν : ENNReal.ofReal d • μ.restrict (Metric.closedBall (0:E) R) ≤ ν) (hi : Integrable u ν) : functional μ ν (Metric.closedBall (0:E) R) u ≤ coercivityConstant μ r d - (∫ x, u x ∂ν)/2 := by let C := d*μ.real (Metric.closedBall (0:E) r) let m := ∫ x, u x ∂ν have hC : 0 < C := mul_pos hd (ball_real_pos μ hr) have hm : 0 ≤ m := integral_nonneg hn have hMp : 0 < m/C+1 := by positivity have hR : 0 < R := by linarith have hK : (Metric.closedBall (0:E) R).Nonempty := ⟨0,by simpa using hR.le⟩ have hRc : ∀ x ∈ Metric.closedBall (0:E) R, ‖x‖ ≤ (⟨R,hR.le⟩:ℝ≥0) := by intro x hx simpa only [NNReal.coe_mk,Metric.mem_closedBall,dist_zero_right] using hx have hcont := (conjugate_lipschitz hK hRc (fun x _ => hn x)).continuous have hl := mean_conjugate_lower μ hr hrR hd hc hn hu0 ν hν hi have hb := log_partition_bound μ hcont (div_pos hr hMp) hl change Real.log (∫ z, Real.exp (-conjugate (Metric.closedBall (0:E) R) u z) ∂μ) ≤ 1-(Module.finrank ℝ E)*Real.log (r/(m/C+1))+ Real.log (∫ z : E, Real.exp (-‖z‖) ∂μ) at hb rw [Real.log_div hr.ne' hMp.ne',mul_sub] at hb have hg := logarithmic_growth_bound (show (0:ℝ) ≤ Module.finrank ℝ E by positivity) hC hm dsimp only [functional,coercivityConstant] change Real.log (∫ z, Real.exp (-conjugate (Metric.closedBall (0:E) R) u z) ∂μ)-m ≤ 1-(Module.finrank ℝ E)*Real.log r+ Real.log (∫ z : E, Real.exp (-‖z‖) ∂μ)+C/2+ (Module.finrank ℝ E)*Real.log (2*((Module.finrank ℝ E)+1)/C)-m/2 linarith lemma functional_lower_mean_bound {u : E → ℝ} {r R d b : ℝ} (hr : 0 < r) (hrR : 2*r ≤ R) (hd : 0 < d) (hc : ConvexOn ℝ (Metric.closedBall (0:E) R) u) (hn : ∀ y, 0 ≤ u y) (hu0 : u 0=0) (ν : Measure E) (hν : ENNReal.ofReal d • μ.restrict (Metric.closedBall (0:E) R) ≤ ν) (hi : Integrable u ν) (hb : b ≤ functional μ ν (Metric.closedBall (0:E) R) u) : (∫ x, u x ∂ν) ≤ 2*(coercivityConstant μ r d-b) := by have hc' := functional_coercive μ hr hrR hd hc hn hu0 ν hν hi linarith end end CompactMomentVariational open Set Filter open scoped Topology NNReal noncomputable section namespace MomentCompactness variable {E : Type*} [NormedAddCommGroup E] def normalizedLipschitz (R : ℝ≥0) : Set C(E,ℝ) := {f | LipschitzWith R f ∧ f 0=0} lemma normalizedLipschitz_pointwise (R : ℝ≥0) : ContinuousMap.toFun '' (normalizedLipschitz (E:=E) R) = {f : E → ℝ | LipschitzWith R f ∧ f 0=0} := by ext f constructor · rintro ⟨g,hg,rfl⟩ exact hg · intro hf exact ⟨⟨f,hf.1.continuous⟩,hf,rfl⟩ lemma normalizedLipschitz_compact (R : ℝ≥0) : IsCompact (normalizedLipschitz (E:=E) R) := by apply ArzelaAscoli.isCompact_of_equicontinuous · rw [normalizedLipschitz_pointwise] apply (isCompact_pi_infinite (fun x : E => (isCompact_Icc : IsCompact (Icc (-(R:ℝ)*‖x‖) ((R:ℝ)*‖x‖))))).of_isClosed_subset · exact (isClosed_setOfPred_lipschitzWith R).inter (isClosed_eq (continuous_apply 0) continuous_const) · intro f hf x have h := hf.1.dist_le_mul x 0 rw [hf.2,Real.dist_eq,sub_zero,dist_zero_right] at h simpa only [Set.mem_Icc,neg_mul] using abs_le.mp h · exact Metric.equicontinuous_of_continuity_modulus (fun r : ℝ => (R:ℝ)*r) (by simpa using (show Continuous (fun r : ℝ => (R:ℝ)*r) by fun_prop).tendsto 0) _ (fun x y f => f.property.1.dist_le_mul x y) variable [NormedSpace ℝ E] lemma normalizedLipschitz_subsequence [FiniteDimensional ℝ E] {R : ℝ≥0} {f : ℕ → E → ℝ} (hl : ∀ k, LipschitzWith R (f k)) (h0 : ∀ k, f k 0=0) : ∃ (g : E → ℝ) (s : ℕ → ℕ), LipschitzWith R g ∧ g 0=0 ∧ StrictMono s ∧ TendstoLocallyUniformly (fun k => f (s k)) g atTop := by let F : ℕ → C(E,ℝ) := fun k => ⟨f k,(hl k).continuous⟩ have hm : ∀ k, F k ∈ normalizedLipschitz R := fun k => ⟨hl k,h0 k⟩ obtain ⟨g,hg,s,hs,ht⟩ := (normalizedLipschitz_compact (E:=E) R).tendsto_subseq hm refine ⟨g,s,hg.1,hg.2,hs,?_⟩ exact ContinuousMap.tendsto_iff_tendstoLocallyUniformly.mp ht end MomentCompactness namespace CompactMomentVariational section variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] structure Admissible (ν : Measure E) (R : ℝ) (u : E → ℝ) : Prop where convex : ConvexOn ℝ (Metric.ball (0:E) R) u nonneg : ∀ x, 0 ≤ u x zero : u 0=0 even : Function.Even u outside : ∀ x, x ∉ Metric.ball (0:E) R → u x=0 integrable : Integrable u ν omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in lemma conjugate_mono {K L : Set E} {u : E → ℝ} {R m : ℝ} (hK : K.Nonempty) (hKL : K ⊆ L) (hR : ∀ x ∈ L, ‖x‖ ≤ R) (hu : ∀ x ∈ L, m ≤ u x) (z : E) : conjugate K u z ≤ conjugate L u z := by apply conjugate_le hK intro x hx exact le_conjugate hR hu (hKL hx) z variable (μ : Measure E) [μ.IsAddHaarMeasure] lemma mean_conjugate_lower_ball {u : E → ℝ} {r S R d : ℝ} (hr : 0 < r) (hrS : 2*r ≤ S) (hSR : S < R) (hd : 0 < d) (ν : Measure E) (hu : Admissible ν R u) (hν : ENNReal.ofReal d • μ.restrict (Metric.closedBall (0:E) S) ≤ ν) (z : E) : (r/((∫ y, u y ∂ν)/(d*μ.real (Metric.closedBall (0:E) r))+1))*‖z‖-1 ≤ conjugate (Metric.ball (0:E) R) u z := by have hS : 0 ≤ S := by linarith have hs : Metric.closedBall (0:E) S ⊆ Metric.ball (0:E) R := by intro x hx exact lt_of_le_of_lt hx hSR exact (mean_conjugate_lower μ hr hrS hd (hu.convex.subset hs (convex_closedBall _ _)) hu.nonneg hu.zero ν hν hu.integrable z).trans (conjugate_mono ⟨0,by simpa using hS⟩ hs (fun x hx => le_of_lt (by simpa [Metric.mem_ball,dist_zero_right] using hx)) (fun x _ => hu.nonneg x) z) omit [FiniteDimensional ℝ E] [BorelSpace E] in lemma admissible_conjugate_lipschitz {ν : Measure E} {R : ℝ≥0} {u : E → ℝ} (hR : 0 < R) (hu : Admissible ν R u) : LipschitzWith R (conjugate (Metric.ball (0:E) R) u) := by apply conjugate_lipschitz ⟨0,by simpa using hR⟩ (fun x hx => le_of_lt (by simpa [Metric.mem_ball,dist_zero_right] using hx)) (fun x _ => hu.nonneg x) lemma functional_coercive_ball {u : E → ℝ} {r S R d : ℝ} (hr : 0 < r) (hrS : 2*r ≤ S) (hSR : S < R) (hd : 0 < d) (ν : Measure E) (hu : Admissible ν R u) (hν : ENNReal.ofReal d • μ.restrict (Metric.closedBall (0:E) S) ≤ ν) : functional μ ν (Metric.ball (0:E) R) u ≤ coercivityConstant μ r d - (∫ x, u x ∂ν)/2 := by let C := d*μ.real (Metric.closedBall (0:E) r) let m := ∫ x, u x ∂ν have hC : 0 < C := mul_pos hd (ball_real_pos μ hr) have hm : 0 ≤ m := integral_nonneg hu.nonneg have hMp : 0 < m/C+1 := by positivity have hR : 0 < R := by linarith have hcont := (admissible_conjugate_lipschitz (R:=⟨R,hR.le⟩) hR hu).continuous have hl := mean_conjugate_lower_ball μ hr hrS hSR hd ν hu hν have hb := log_partition_bound μ hcont (div_pos hr hMp) hl change Real.log (∫ z, Real.exp (-conjugate (Metric.ball (0:E) R) u z) ∂μ) ≤ 1-(Module.finrank ℝ E)*Real.log (r/(m/C+1))+ Real.log (∫ z : E, Real.exp (-‖z‖) ∂μ) at hb rw [Real.log_div hr.ne' hMp.ne',mul_sub] at hb have hg := logarithmic_growth_bound (show (0:ℝ) ≤ Module.finrank ℝ E by positivity) hC hm dsimp only [functional,coercivityConstant] change Real.log (∫ z, Real.exp (-conjugate (Metric.ball (0:E) R) u z) ∂μ)-m ≤ 1-(Module.finrank ℝ E)*Real.log r+ Real.log (∫ z : E, Real.exp (-‖z‖) ∂μ)+C/2+ (Module.finrank ℝ E)*Real.log (2*((Module.finrank ℝ E)+1)/C)-m/2 linarith lemma admissible_local_bound {ν : Measure E} {R r S d M : ℝ} {u : E → ℝ} (hr : 0 < r) (hSR : S < R) (hd : 0 < d) (hu : Admissible ν R u) (hν : ENNReal.ofReal d • μ.restrict (Metric.closedBall (0:E) S) ≤ ν) (hM : (∫ y, u y ∂ν) ≤ M) {x : E} (hx : ‖x‖+r ≤ S) : u x ≤ M/(d*μ.real (Metric.closedBall (0:E) r)) := by have hC : 0 < d*μ.real (Metric.closedBall (0:E) r) := mul_pos hd (ball_real_pos μ hr) apply (le_div_iff₀ hC).mpr have hs : Metric.closedBall (0:E) S ⊆ Metric.ball (0:E) R := fun _ hx => lt_of_le_of_lt hx hSR have hb := convex_ball_probability_bound_at μ hr hd (hu.convex.subset hs (convex_closedBall _ _)) hu.nonneg ν hν hu.integrable hx have hh : u x*(d*μ.real (Metric.closedBall (0:E) r)) ≤ ∫ y,u y ∂ν := by simpa [mul_comm] using hb exact hh.trans hM lemma uniform_conjugate_coercive {ν : Measure E} {R r S d M : ℝ} {u : E → ℝ} (hr : 0 < r) (hrS : 2*r ≤ S) (hSR : S < R) (hd : 0 < d) (_hM : 0 ≤ M) (hu : Admissible ν R u) (hν : ENNReal.ofReal d • μ.restrict (Metric.closedBall (0:E) S) ≤ ν) (hm : (∫ y, u y ∂ν) ≤ M) (z : E) : (r/(M/(d*μ.real (Metric.closedBall (0:E) r))+1))*‖z‖-1 ≤ conjugate (Metric.ball (0:E) R) u z := by have hC : 0 < d*μ.real (Metric.closedBall (0:E) r) := mul_pos hd (ball_real_pos μ hr) have hn : 0 ≤ ∫ y, u y ∂ν := integral_nonneg hu.nonneg have hmC := div_le_div_of_nonneg_right hm hC.le have hq := div_le_div_of_nonneg_left hr.le (by positivity : 0 < (∫ y,u y ∂ν)/ (d*μ.real (Metric.closedBall (0:E) r))+1) (by linarith : (∫ y,u y ∂ν)/(d*μ.real (Metric.closedBall (0:E) r))+1 ≤ M/(d*μ.real (Metric.closedBall (0:E) r))+1) exact (sub_le_sub_right (mul_le_mul_of_nonneg_right hq (norm_nonneg z)) 1).trans (mean_conjugate_lower_ball μ hr hrS hSR hd ν hu hν z) end section variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] structure NormalizedConvex (R : ℝ≥0) (φ : E → ℝ) : Prop where lipschitz : LipschitzWith R φ zero : φ 0=0 nonneg : ∀ x, 0 ≤ φ x even : Function.Even φ convex : ConvexOn ℝ univ φ omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in lemma convexOn_limit {f : ℕ → E → ℝ} {g : E → ℝ} (hc : ∀ n, ConvexOn ℝ univ (f n)) (ht : ∀ x, Tendsto (fun n => f n x) atTop (𝓝 (g x))) : ConvexOn ℝ univ g := by refine ⟨convex_univ, ?_⟩ intro x hx y hy a b ha hb hab exact le_of_tendsto_of_tendsto (ht (a • x+b • y)) (((ht x).const_mul a).add ((ht y).const_mul b)) (Eventually.of_forall fun n => (hc n).2 hx hy ha hb hab) omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] [InnerProductSpace ℝ E] in lemma even_limit {f : ℕ → E → ℝ} {g : E → ℝ} (he : ∀ n, Function.Even (f n)) (ht : ∀ x, Tendsto (fun n => f n x) atTop (𝓝 (g x))) : Function.Even g := by intro x apply tendsto_nhds_unique (ht (-x)) have hh : (fun n => f n (-x))=(fun n => f n x) := funext fun n => he n x rw [hh] exact ht x omit [FiniteDimensional ℝ E] [BorelSpace E] in lemma admissible_conjugate_normalized {ν : Measure E} {R : ℝ≥0} {u : E → ℝ} (hR : 0 < R) (hu : Admissible ν R u) : NormalizedConvex R (conjugate (Metric.ball (0:E) R) u) := by have h0 : (0:E) ∈ Metric.ball (0:E) (R:ℝ) := by simpa using hR have hKR : ∀ x ∈ Metric.ball (0:E) (R:ℝ), ‖x‖ ≤ R := fun x hx => (by simpa [Metric.mem_ball,dist_zero_right] using hx : ‖x‖ < R).le exact ⟨admissible_conjugate_lipschitz hR hu, conjugate_zero hKR (fun x _ => hu.nonneg x) h0 hu.zero, conjugate_nonneg hKR (fun x _ => hu.nonneg x) h0 hu.zero, conjugate_even ⟨0,h0⟩ hKR (fun x _ => hu.nonneg x) (fun x hx => by simpa [Metric.mem_ball,dist_zero_right] using hx) hu.even, convexOn_conjugate ⟨0,h0⟩ hKR (fun x _ => hu.nonneg x)⟩ omit [BorelSpace E] in lemma admissible_conjugate_subsequence {ν : Measure E} {R : ℝ≥0} {u : ℕ → E → ℝ} (hR : 0 < R) (hu : ∀ n, Admissible ν R (u n)) : ∃ (φ : E → ℝ) (s : ℕ → ℕ), NormalizedConvex R φ ∧ StrictMono s ∧ TendstoLocallyUniformly (fun n => conjugate (Metric.ball (0:E) R) (u (s n))) φ atTop := by have hp (n : ℕ) := admissible_conjugate_normalized hR (hu n) obtain ⟨φ,s,hl,h0,hs,ht⟩ := MomentCompactness.normalizedLipschitz_subsequence (fun n => (hp n).lipschitz) (fun n => (hp n).zero) have hpt (x : E) : Tendsto (fun n => conjugate (Metric.ball (0:E) R) (u (s n)) x) atTop (𝓝 (φ x)) := ht.tendsto_comp hl.continuous.continuousAt tendsto_const_nhds refine ⟨φ,s,⟨hl,h0,?_,even_limit (fun n => (hp (s n)).even) hpt, convexOn_limit (fun n => (hp (s n)).convex) hpt⟩,hs,ht⟩ intro x exact le_of_tendsto_of_tendsto tendsto_const_nhds (hpt x) (Eventually.of_forall fun n => (hp (s n)).nonneg x) omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in lemma conjugate_limit_bdd {K : Set E} {R : ℝ} {u : ℕ → E → ℝ} {φ : E → ℝ} (hKR : ∀ x ∈ K, ‖x‖ ≤ R) (hu : ∀ n, ∀ x ∈ K, 0 ≤ u n x) (hp : ∀ z, Tendsto (fun n => conjugate K (u n) z) atTop (𝓝 (φ z))) (hlocal : ∀ x ∈ K, ∃ B, ∀ n, u n x ≤ B) : ∀ x ∈ K, BddAbove ((fun z => ⟪z,x⟫_ℝ-φ z) '' univ) := by intro x hx obtain ⟨B,hB⟩ := hlocal x hx refine ⟨B,?_⟩ rintro _ ⟨z,_,rfl⟩ apply le_of_tendsto (tendsto_const_nhds.sub (hp z)) apply Eventually.of_forall intro n have h := le_conjugate hKR (hu n) hx z rw [real_inner_comm z x] at h linarith [hB n] end section variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] lemma convexOn_conjugate_of_bdd {K D : Set E} (hK : K.Nonempty) (hD : Convex ℝ D) {u : E → ℝ} (hb : ∀ z ∈ D, BddAbove ((fun x => ⟪x,z⟫_ℝ-u x) '' K)) : ConvexOn ℝ D (conjugate K u) := by refine ⟨hD, ?_⟩ intro z hz w hw a b ha hb' hab apply conjugate_le hK intro x hx have hz' := le_csSup (hb z hz) (mem_image_of_mem (fun x => ⟪x,z⟫_ℝ-u x) hx) have hw' := le_csSup (hb w hw) (mem_image_of_mem (fun x => ⟪x,w⟫_ℝ-u x) hx) change ⟪x,z⟫_ℝ-u x ≤ conjugate K u z at hz' change ⟪x,w⟫_ℝ-u x ≤ conjugate K u w at hw' simp only [smul_eq_mul] rw [inner_add_right,inner_smul_right,inner_smul_right] have habu : (a+b)*u x=u x := by rw [hab,one_mul] nlinarith [mul_le_mul_of_nonneg_left hz' ha,mul_le_mul_of_nonneg_left hw' hb'] lemma conjugate_even_univ {φ : E → ℝ} (he : Function.Even φ) : Function.Even (conjugate univ φ) := by intro x unfold conjugate congr 1 ext t constructor <;> rintro ⟨z,_,rfl⟩ · exact ⟨-z,mem_univ _,by simp [he z]⟩ · exact ⟨-z,mem_univ _,by simp [he z]⟩ def dualOn (K : Set E) (φ : E → ℝ) : E → ℝ := K.indicator (conjugate univ φ) lemma dualOn_eq {K : Set E} {φ : E → ℝ} {x : E} (hx : x ∈ K) : dualOn K φ x=conjugate univ φ x := indicator_of_mem hx _ lemma convexOn_dualOn {K : Set E} (hK : Convex ℝ K) {φ : E → ℝ} (hb : ∀ x ∈ K, BddAbove ((fun z => ⟪z,x⟫_ℝ-φ z) '' univ)) : ConvexOn ℝ K (dualOn K φ) := (convexOn_conjugate_of_bdd (univ_nonempty) hK hb).congr (fun _ hx => (dualOn_eq hx).symm) lemma dualOn_nonneg {K : Set E} {φ : E → ℝ} (h0 : φ 0=0) (hb : ∀ x ∈ K, BddAbove ((fun z => ⟪z,x⟫_ℝ-φ z) '' univ)) : ∀ x, 0 ≤ dualOn K φ x := by intro x by_cases hx : x ∈ K · rw [dualOn_eq hx] simpa [conjugate,h0] using le_csSup (hb x hx) (mem_image_of_mem (fun z => ⟪z,x⟫_ℝ-φ z) (mem_univ 0)) · simp [dualOn,indicator_of_notMem hx] lemma dualOn_zero {K : Set E} {φ : E → ℝ} (h0 : φ 0=0) (hn : ∀ x, 0 ≤ φ x) (hb : ∀ x ∈ K, BddAbove ((fun z => ⟪z,x⟫_ℝ-φ z) '' univ)) : dualOn K φ 0=0 := by by_cases hx : (0:E) ∈ K · apply le_antisymm _ (dualOn_nonneg h0 hb 0) rw [dualOn_eq hx] apply conjugate_le univ_nonempty intro z _ simpa using hn z · simp [dualOn,indicator_of_notMem hx] lemma dualOn_even_ball {R : ℝ} {φ : E → ℝ} (he : Function.Even φ) : Function.Even (dualOn (Metric.ball (0:E) R) φ) := by intro x by_cases hx : x ∈ Metric.ball (0:E) R · have hn : -x ∈ Metric.ball (0:E) R := by simpa [Metric.mem_ball,dist_zero_right] using hx rw [dualOn_eq hx,dualOn_eq hn,conjugate_even_univ he] · have hn : -x ∉ Metric.ball (0:E) R := by simpa [Metric.mem_ball,dist_zero_right] using hx simp [dualOn,indicator_of_notMem hx,indicator_of_notMem hn] lemma fenchel_dualOn {K : Set E} {φ : E → ℝ} (hb : ∀ x ∈ K, BddAbove ((fun z => ⟪z,x⟫_ℝ-φ z) '' univ)) {x : E} (hx : x ∈ K) (z : E) : ⟪x,z⟫_ℝ-dualOn K φ x ≤ φ z := by rw [dualOn_eq hx] have h := le_csSup (hb x hx) (mem_image_of_mem (fun z => ⟪z,x⟫_ℝ-φ z) (mem_univ z)) change ⟪z,x⟫_ℝ-φ z ≤ conjugate univ φ x at h rw [real_inner_comm x z] at h linarith lemma minorant_slope_norm {φ : E → ℝ} {R : ℝ≥0} (hl : LipschitzWith R φ) (h0 : φ 0=0) {p : E} {c : ℝ} (hm : ∀ z, ⟪p,z⟫_ℝ+c ≤ φ z) : ‖p‖ ≤ R := by have hc : c ≤ 0 := by simpa [h0] using hm 0 by_contra! hp have hn : 0 < ‖p‖ := lt_of_le_of_lt R.coe_nonneg hp let A := ‖p‖^2-(R:ℝ)*‖p‖ have hA : 0 < A := by dsimp [A]; nlinarith let t : ℝ := (1-c)/A have ht : 0 < t := div_pos (by linarith) hA have hdist := hl.dist_le_mul (t • p) 0 rw [h0,Real.dist_eq,sub_zero,dist_zero_right,norm_smul, Real.norm_eq_abs,abs_of_pos ht] at hdist have hu : φ (t • p) ≤ (R:ℝ)*(t*‖p‖) := (le_abs_self _).trans hdist have hm' := hm (t • p) rw [inner_smul_right,real_inner_self_eq_norm_sq] at hm' have he : t*A=1-c := div_mul_cancel₀ _ hA.ne' dsimp only [A] at he nlinarith variable [FiniteDimensional ℝ E] theorem conjugate_dualOn_ball {φ : E → ℝ} {R : ℝ≥0} (hR : 0 < R) (hl : LipschitzWith R φ) (h0 : φ 0=0) (hn : ∀ x, 0 ≤ φ x) (hc : ConvexOn ℝ univ φ) (hb : ∀ x ∈ Metric.ball (0:E) R, BddAbove ((fun z => ⟪z,x⟫_ℝ-φ z) '' univ)) : conjugate (Metric.ball (0:E) R) (dualOn (Metric.ball (0:E) R) φ)=φ := by have hK : (Metric.ball (0:E) (R:ℝ)).Nonempty := ⟨0,by simpa using hR⟩ have hKR : ∀ x ∈ Metric.ball (0:E) (R:ℝ), ‖x‖ ≤ R := fun x hx => (by simpa [Metric.mem_ball,dist_zero_right] using hx : ‖x‖ < R).le have hu := dualOn_nonneg h0 hb funext z apply le_antisymm (conjugate_le hK (fun x hx => fenchel_dualOn hb hx z)) suffices hh : ∀ a < φ z, a ≤ conjugate (Metric.ball (0:E) R) (dualOn (Metric.ball (0:E) R) φ) z by by_contra! hh' have hh'' := hh ((φ z+conjugate (Metric.ball (0:E) R) (dualOn (Metric.ball (0:E) R) φ) z)/2) (by linarith) linarith intro a ha obtain ⟨l,c,hm,he⟩ := hc.exists_affine_le_of_lt (𝕜:=ℝ) (mem_univ z) ha isClosed_univ (hl.continuous.lowerSemicontinuous.lowerSemicontinuousOn univ) let p : E := (InnerProductSpace.toDual ℝ E).symm l have hp (y : E) : ⟪p,y⟫_ℝ=l y := InnerProductSpace.toDual_symm_apply have hm' (y : E) : ⟪p,y⟫_ℝ+c ≤ φ y := by simpa [Function.comp_def,hp] using hm ⟨y,mem_univ y⟩ have he' : ⟪p,z⟫_ℝ+c=a := by simpa [hp] using he have hpn := minorant_slope_norm hl h0 hm' have hbnd {t : ℝ} (ht : 0 ≤ t) (ht1 : t < 1) : t*a ≤ conjugate (Metric.ball (0:E) R) (dualOn (Metric.ball (0:E) R) φ) z := by have htp : t • p ∈ Metric.ball (0:E) (R:ℝ) := by rw [Metric.mem_ball,dist_zero_right,norm_smul,Real.norm_eq_abs,abs_of_nonneg ht] exact (mul_le_mul_of_nonneg_left hpn ht).trans_lt (by nlinarith [R.coe_nonneg]) have hdu : dualOn (Metric.ball (0:E) R) φ (t • p) ≤ -t*c := by rw [dualOn_eq htp] apply conjugate_le univ_nonempty intro y _ rw [inner_smul_right,real_inner_comm p y] have hv := mul_le_mul_of_nonneg_left (hm' y) ht have hw := mul_le_mul_of_nonneg_right ht1.le (hn y) nlinarith have hle := le_conjugate hKR (fun x _ => hu x) htp z rw [real_inner_smul_left] at hle nlinarith have ht : Tendsto (fun n : ℕ => ((n:ℝ)/(n+1))*a) atTop (𝓝 a) := by simpa using (tendsto_natCast_div_add_atTop (1:ℝ)).mul_const a exact le_of_tendsto ht (Eventually.of_forall fun n => hbnd (div_nonneg (Nat.cast_nonneg n) (by positivity)) ((div_lt_one (by positivity)).mpr (by linarith))) end section variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] lemma dualOn_le_liminf {K : Set E} {R : ℝ} {u : ℕ → E → ℝ} {φ : E → ℝ} (hKR : ∀ x ∈ K, ‖x‖ ≤ R) (hu : ∀ n, ∀ x ∈ K, 0 ≤ u n x) (hp : ∀ z, Tendsto (fun n => conjugate K (u n) z) atTop (𝓝 (φ z))) (x : E) : ENNReal.ofReal (dualOn K φ x) ≤ liminf (fun n => ENNReal.ofReal (u n x)) atTop := by by_cases hx : x ∈ K · by_cases htop : liminf (fun n => ENNReal.ofReal (u n x)) atTop=⊤ · simp [htop] apply (ENNReal.ofReal_le_iff_le_toReal htop).mpr rw [dualOn_eq hx] apply conjugate_le univ_nonempty intro z _ apply (ENNReal.ofReal_le_iff_le_toReal htop).mp have ht : Tendsto (fun n => ENNReal.ofReal (⟪z,x⟫_ℝ-conjugate K (u n) z)) atTop (𝓝 (ENNReal.ofReal (⟪z,x⟫_ℝ-φ z))) := ENNReal.continuous_ofReal.continuousAt.tendsto.comp (tendsto_const_nhds.sub (hp z)) rw [← ht.liminf_eq] apply liminf_le_liminf (Eventually.of_forall fun n => ?_) apply ENNReal.ofReal_le_ofReal have h := le_conjugate hKR (hu n) hx z rw [real_inner_comm z x] at h linarith · simp [dualOn,indicator_of_notMem hx] variable [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] lemma dualOn_mean_lower_semicontinuous {ν : Measure E} {K : Set E} (hK : IsOpen K) (hc : Convex ℝ K) {R : ℝ} {u : ℕ → E → ℝ} {φ : E → ℝ} {m : ℝ} (hKR : ∀ x ∈ K, ‖x‖ ≤ R) (hu : ∀ n x, 0 ≤ u n x) (hi : ∀ n, Integrable (u n) ν) (h0 : φ 0=0) (hp : ∀ z, Tendsto (fun n => conjugate K (u n) z) atTop (𝓝 (φ z))) (hb : ∀ x ∈ K, BddAbove ((fun z => ⟪z,x⟫_ℝ-φ z) '' univ)) (hm : Tendsto (fun n => ∫ x, u n x ∂ν) atTop (𝓝 m)) : Integrable (dualOn K φ) ν ∧ (∫ x, dualOn K φ x ∂ν) ≤ m := by have ham : AEStronglyMeasurable (dualOn K φ) ν := (aestronglyMeasurable_indicator_iff hK.measurableSet).mpr ((ConvexOn.continuousOn hK (convexOn_conjugate_of_bdd univ_nonempty hc hb)).aestronglyMeasurable hK.measurableSet) have hnu := dualOn_nonneg h0 hb have hfat : (∫⁻ x, ENNReal.ofReal (dualOn K φ x) ∂ν) ≤ liminf (fun n => ∫⁻ x, ENNReal.ofReal (u n x) ∂ν) atTop := (lintegral_mono (dualOn_le_liminf hKR (fun n x _ => hu n x) hp)).trans (lintegral_liminf_le' (fun n => ENNReal.continuous_ofReal.measurable.comp_aemeasurable (hi n).aestronglyMeasurable.aemeasurable)) have hei : (fun n => ∫⁻ x, ENNReal.ofReal (u n x) ∂ν)= (fun n => ENNReal.ofReal (∫ x, u n x ∂ν)) := funext fun n => (ofReal_integral_eq_lintegral_ofReal (hi n) (Eventually.of_forall (hu n))).symm have hmt : Tendsto (fun n => ENNReal.ofReal (∫ x, u n x ∂ν)) atTop (𝓝 (ENNReal.ofReal m)) := ENNReal.continuous_ofReal.continuousAt.tendsto.comp hm rw [hei,hmt.liminf_eq] at hfat have hui : Integrable (dualOn K φ) ν := ⟨ham, (hasFiniteIntegral_iff_ofReal (Eventually.of_forall hnu)).mpr (hfat.trans_lt ENNReal.ofReal_lt_top)⟩ refine ⟨hui,?_⟩ have hm0 : 0 ≤ m := le_of_tendsto_of_tendsto tendsto_const_nhds hm (Eventually.of_forall fun n => integral_nonneg (hu n)) rw [← ofReal_integral_eq_lintegral_ofReal hui (Eventually.of_forall hnu)] at hfat exact (ENNReal.ofReal_le_ofReal_iff hm0).mp hfat variable (μ : Measure E) [μ.IsAddHaarMeasure] lemma partition_tendsto {f : ℕ → E → ℝ} {φ : E → ℝ} {c b : ℝ} (hc : 0 < c) (hf : ∀ n, Continuous (f n)) (ht : ∀ z, Tendsto (fun n => f n z) atTop (𝓝 (φ z))) (hl : ∀ n z, c*‖z‖-b ≤ f n z) : Tendsto (fun n => ∫ z, Real.exp (-f n z) ∂μ) atTop (𝓝 (∫ z, Real.exp (-φ z) ∂μ)) := by apply tendsto_integral_of_dominated_convergence (fun z => Real.exp b*Real.exp (-c*‖z‖)) (fun n => (Real.continuous_exp.comp (hf n).neg).aestronglyMeasurable) ((integrable_exp_neg_norm μ hc).const_mul (Real.exp b)) · intro n apply Eventually.of_forall intro z change |Real.exp (-f n z)| ≤ Real.exp b * Real.exp (-c * ‖z‖) rw [abs_of_pos (Real.exp_pos _),← Real.exp_add] exact Real.exp_le_exp.mpr (by linarith [hl n z]) · exact Eventually.of_forall fun z => (Real.continuous_exp.tendsto _).comp (ht z).neg end section variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] variable (μ : Measure E) [μ.IsAddHaarMeasure] omit [FiniteDimensional ℝ E] [BorelSpace E] in lemma admissible_zero (ν : Measure E) (R : ℝ) : Admissible ν R (fun _ => 0) := ⟨convexOn_const 0 (convex_ball _ _), fun _ => le_rfl, rfl, fun _ => rfl, fun _ _ => rfl, integrable_zero E ℝ ν⟩ lemma admissible_local_bounds {ν : Measure E} {R d M : ℝ} {u : ℕ → E → ℝ} (hd : 0 < d) (hu : ∀ n, Admissible ν R (u n)) (hν : ∀ S : ℝ, 0 ≤ S → S < R → ENNReal.ofReal d • μ.restrict (Metric.closedBall (0:E) S) ≤ ν) (hM : ∀ n, (∫ y, u n y ∂ν) ≤ M) : ∀ x ∈ Metric.ball (0:E) R, ∃ B, ∀ n, u n x ≤ B := by intro x hx have hxn : ‖x‖ < R := by simpa [Metric.mem_ball,dist_zero_right] using hx let r := (R-‖x‖)/4 let S := (R+‖x‖)/2 have hr : 0 < r := by dsimp [r]; linarith have hSR : S < R := by dsimp [S]; linarith have hS : 0 ≤ S := by dsimp [S]; linarith [norm_nonneg x] refine ⟨M/(d*μ.real (Metric.closedBall (0:E) r)),fun n => ?_⟩ exact admissible_local_bound μ hr hSR hd (hu n) (hν S hS hSR) (hM n) (by dsimp [r,S]; linarith) lemma limit_dual_admissible {ν : Measure E} {R : ℝ≥0} {d M m : ℝ} {u : ℕ → E → ℝ} {φ : E → ℝ} (hR : 0 < R) (hd : 0 < d) (hu : ∀ n, Admissible ν R (u n)) (hν : ∀ S : ℝ, 0 ≤ S → S < R → ENNReal.ofReal d • μ.restrict (Metric.closedBall (0:E) S) ≤ ν) (hM : ∀ n, (∫ y, u n y ∂ν) ≤ M) (hφ : NormalizedConvex R φ) (hp : ∀ z, Tendsto (fun n => conjugate (Metric.ball (0:E) R) (u n) z) atTop (𝓝 (φ z))) (hm : Tendsto (fun n => ∫ x, u n x ∂ν) atTop (𝓝 m)) : Admissible ν R (dualOn (Metric.ball (0:E) R) φ) ∧ (∫ x, dualOn (Metric.ball (0:E) R) φ x ∂ν) ≤ m ∧ conjugate (Metric.ball (0:E) R) (dualOn (Metric.ball (0:E) R) φ)=φ := by have hKR : ∀ x ∈ Metric.ball (0:E) (R:ℝ), ‖x‖ ≤ R := fun x hx => (by simpa [Metric.mem_ball,dist_zero_right] using hx : ‖x‖ < R).le have hb := conjugate_limit_bdd hKR (fun n x _ => (hu n).nonneg x) hp (admissible_local_bounds μ hd hu hν hM) obtain ⟨hi,him⟩ := dualOn_mean_lower_semicontinuous Metric.isOpen_ball (convex_ball _ _) hKR (fun n => (hu n).nonneg) (fun n => (hu n).integrable) hφ.zero hp hb hm refine ⟨⟨convexOn_dualOn (convex_ball _ _) hb, dualOn_nonneg hφ.zero hb, dualOn_zero hφ.zero hφ.nonneg hb,dualOn_even_ball hφ.even,?_,hi⟩,him,?_⟩ · intro x hx exact indicator_of_notMem hx _ · exact conjugate_dualOn_ball hR hφ.lipschitz hφ.zero hφ.nonneg hφ.convex hb lemma functional_limit_upper {ν : Measure E} {R : ℝ≥0} {d M m a : ℝ} {u : ℕ → E → ℝ} {φ : E → ℝ} (hR : 0 < R) (hd : 0 < d) (hM0 : 0 ≤ M) (hu : ∀ n, Admissible ν R (u n)) (hν : ∀ S : ℝ, 0 ≤ S → S < R → ENNReal.ofReal d • μ.restrict (Metric.closedBall (0:E) S) ≤ ν) (hM : ∀ n, (∫ y, u n y ∂ν) ≤ M) (hφ : NormalizedConvex R φ) (hp : ∀ z, Tendsto (fun n => conjugate (Metric.ball (0:E) R) (u n) z) atTop (𝓝 (φ z))) (hm : Tendsto (fun n => ∫ x, u n x ∂ν) atTop (𝓝 m)) (ha : Tendsto (fun n => functional μ ν (Metric.ball (0:E) R) (u n)) atTop (𝓝 a)) : Admissible ν R (dualOn (Metric.ball (0:E) R) φ) ∧ a ≤ functional μ ν (Metric.ball (0:E) R) (dualOn (Metric.ball (0:E) R) φ) := by obtain ⟨had,him,heq⟩ := limit_dual_admissible μ hR hd hu hν hM hφ hp hm let r : ℝ := R/4 let S : ℝ := R/2 have hRR : (0:ℝ) < R := hR have hr : 0 < r := by dsimp [r]; positivity have hS : 0 ≤ S := by dsimp [S]; positivity have hSR : S < R := by dsimp [S]; linarith have hrS : 2*r ≤ S := by dsimp [r,S]; linarith let c := r/(M/(d*μ.real (Metric.closedBall (0:E) r))+1) have hc : 0 < c := div_pos hr (add_pos_of_nonneg_of_pos (div_nonneg hM0 (mul_pos hd (ball_real_pos μ hr)).le) zero_lt_one) have hl (n : ℕ) (z : E) : c*‖z‖-1 ≤ conjugate (Metric.ball (0:E) R) (u n) z := uniform_conjugate_coercive μ hr hrS hSR hd hM0 (hu n) (hν S hS hSR) (hM n) z have hlφ (z : E) : c*‖z‖-1 ≤ φ z := ge_of_tendsto (hp z) (Eventually.of_forall fun n => hl n z) have hI : 0 < ∫ z, Real.exp (-φ z) ∂μ := integral_exp_pos (tail_integrable μ hφ.lipschitz.continuous hc hlφ) have ht := partition_tendsto μ hc (fun n => (admissible_conjugate_lipschitz hR (hu n)).continuous) hp hl have htlog : Tendsto (fun n => Real.log (∫ z, Real.exp (-conjugate (Metric.ball (0:E) R) (u n) z) ∂μ)) atTop (𝓝 (Real.log (∫ z,Real.exp (-φ z) ∂μ))) := (Real.continuousAt_log hI.ne').tendsto.comp ht have heqa : a=Real.log (∫ z,Real.exp (-φ z) ∂μ)-m := tendsto_nhds_unique ha (htlog.sub hm) refine ⟨had,?_⟩ rw [heqa,functional,heq] exact sub_le_sub_left him _ def valueSet (ν : Measure E) (R : ℝ) : Set ℝ := {a | ∃ u, Admissible ν R u ∧ functional μ ν (Metric.ball (0:E) R) u=a} lemma maximizing_sequence {ν : Measure E} {R : ℝ≥0} {d : ℝ} (hR : 0 < R) (hd : 0 < d) (hν : ∀ S : ℝ, 0 ≤ S → S < R → ENNReal.ofReal d • μ.restrict (Metric.closedBall (0:E) S) ≤ ν) : ∃ (u : ℕ → E → ℝ) (M : ℝ), 0 ≤ M ∧ (∀ n, Admissible ν R (u n)) ∧ (∀ n, (∫ y, u n y ∂ν) ≤ M) ∧ Tendsto (fun n => functional μ ν (Metric.ball (0:E) R) (u n)) atTop (𝓝 (sSup (valueSet μ ν R))) ∧ ∀ v, Admissible ν R v → functional μ ν (Metric.ball (0:E) R) v ≤ sSup (valueSet μ ν R) := by let r : ℝ := R/4 let S : ℝ := R/2 have hRR : (0:ℝ) < R := hR have hr : 0 < r := by dsimp [r]; positivity have hS : 0 ≤ S := by dsimp [S]; positivity have hSR : S < R := by dsimp [S]; linarith have hrS : 2*r ≤ S := by dsimp [r,S]; linarith let C := coercivityConstant μ r d have hco (v : E → ℝ) (hv : Admissible ν R v) : functional μ ν (Metric.ball (0:E) R) v ≤ C-(∫ x,v x ∂ν)/2 := functional_coercive_ball μ hr hrS hSR hd ν hv (hν S hS hSR) have hn : (valueSet μ ν R).Nonempty := ⟨_,fun _ => 0,admissible_zero ν R,rfl⟩ have hb : BddAbove (valueSet μ ν R) := by refine ⟨C,?_⟩ rintro a ⟨v,hv,rfl⟩ exact (hco v hv).trans (sub_le_self _ (div_nonneg (integral_nonneg hv.nonneg) (by norm_num))) obtain ⟨w,hw,hwt,hwin⟩ := exists_seq_tendsto_sSup hn hb choose u hu heq using hwin have hbnd (n : ℕ) : (∫ x,u n x ∂ν) ≤ 2*(C-w 0) := by have h1 := hco (u n) (hu n) rw [heq n] at h1 have h2 := hw (Nat.zero_le n) linarith refine ⟨u,2*(C-w 0),(integral_nonneg (hu 0).nonneg).trans (hbnd 0),hu,hbnd,?_,?_⟩ · simpa only [heq] using hwt · intro v hv exact le_csSup hb ⟨v,hv,rfl⟩ lemma maximizing_limit {ν : Measure E} {R : ℝ≥0} {d : ℝ} (hR : 0 < R) (hd : 0 < d) (hν : ∀ S : ℝ, 0 ≤ S → S < R → ENNReal.ofReal d • μ.restrict (Metric.closedBall (0:E) S) ≤ ν) : ∃ (φ : E → ℝ), NormalizedConvex R φ ∧ Admissible ν R (dualOn (Metric.ball (0:E) R) φ) ∧ ∀ v, Admissible ν R v → functional μ ν (Metric.ball (0:E) R) v ≤ functional μ ν (Metric.ball (0:E) R) (dualOn (Metric.ball (0:E) R) φ) := by obtain ⟨u,M,hM,hu,hb,ha,hupper⟩ := maximizing_sequence μ hR hd hν obtain ⟨m,_,s,hs,hsm⟩ := (isCompact_Icc : IsCompact (Icc (0:ℝ) M)).tendsto_subseq (fun n => ⟨integral_nonneg (hu n).nonneg,hb n⟩) obtain ⟨φ,t,hφ,ht,hpt⟩ := admissible_conjugate_subsequence hR (fun n => hu (s n)) have hp (z : E) : Tendsto (fun n => conjugate (Metric.ball (0:E) R) (u (s (t n))) z) atTop (𝓝 (φ z)) := hpt.tendsto_comp hφ.lipschitz.continuous.continuousAt tendsto_const_nhds obtain ⟨had,hval⟩ := functional_limit_upper μ hR hd hM (fun n => hu (s (t n))) hν (fun n => hb (s (t n))) hφ hp (hsm.comp ht.tendsto_atTop) (ha.comp (hs.tendsto_atTop.comp ht.tendsto_atTop)) exact ⟨φ,hφ,had,fun v hv => (hupper v hv).trans hval⟩ theorem exists_variational_maximizer {ν : Measure E} {R : ℝ≥0} {d : ℝ} (hR : 0 < R) (hd : 0 < d) (hν : ∀ S : ℝ, 0 ≤ S → S < R → ENNReal.ofReal d • μ.restrict (Metric.closedBall (0:E) S) ≤ ν) : ∃ u, Admissible ν R u ∧ ∀ v, Admissible ν R v → functional μ ν (Metric.ball (0:E) R) v ≤ functional μ ν (Metric.ball (0:E) R) u := by obtain ⟨φ,_,hu,hm⟩ := maximizing_limit μ hR hd hν exact ⟨_,hu,hm⟩ end section variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] lemma even_convex_minimum {φ : E → ℝ} (hc : ConvexOn ℝ univ φ) (he : Function.Even φ) (z : E) : φ 0 ≤ φ z := by have hh := hc.2 (mem_univ z) (mem_univ (-z)) (show (0:ℝ) ≤ 1/2 by norm_num) (show (0:ℝ) ≤ 1/2 by norm_num) (show (1/2:ℝ)+1/2=1 by norm_num) simp only [smul_neg,add_neg_cancel,smul_eq_mul,he z] at hh linarith lemma conjugate_perturb_le {K : Set E} (hK : K.Nonempty) {u v : E → ℝ} {R m A : ℝ} (hR : ∀ x ∈ K, ‖x‖ ≤ R) (hv : ∀ x ∈ K, m ≤ v x) (h : ∀ x ∈ K, v x-A ≤ u x) (z : E) : conjugate K u z ≤ conjugate K v z+A := by apply conjugate_le hK intro x hx have hh := le_conjugate hR hv hx z linarith [h x hx] lemma conjugate_perturb_abs {K : Set E} (hK : K.Nonempty) {u v : E → ℝ} {R m A : ℝ} (hR : ∀ x ∈ K, ‖x‖ ≤ R) (hu : ∀ x ∈ K, m ≤ u x) (h : ∀ x ∈ K, |v x-u x| ≤ A) (z : E) : |conjugate K v z-conjugate K u z| ≤ A := by have hv : ∀ x ∈ K, m-A ≤ v x := fun x hx => by have hh := (abs_le.mp (h x hx)).1 linarith [hu x hx] apply abs_le.mpr constructor · have hh := conjugate_perturb_le (u:=u) (v:=v) (A:=A) hK hR hv (fun x hx => by linarith [(abs_le.mp (h x hx)).2]) z linarith · have hh := conjugate_perturb_le (u:=v) (v:=u) (A:=A) hK hR hu (fun x hx => by linarith [(abs_le.mp (h x hx)).1]) z linarith variable [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in lemma normalized_conjugate {R : ℝ≥0} {w : E → ℝ} {m : ℝ} (hR : 0 < R) (hw : ∀ x ∈ Metric.ball (0:E) R, m ≤ w x) (he : Function.Even w) : NormalizedConvex R (fun z => conjugate (Metric.ball (0:E) R) w z-conjugate (Metric.ball (0:E) R) w 0) := by have hK : (Metric.ball (0:E) (R:ℝ)).Nonempty := ⟨0,by simpa using hR⟩ have hKR : ∀ x ∈ Metric.ball (0:E) (R:ℝ), ‖x‖ ≤ R := fun x hx => (by simpa [Metric.mem_ball,dist_zero_right] using hx : ‖x‖ < R).le have hc := convexOn_conjugate hK hKR hw have he' := conjugate_even hK hKR hw (fun x hx => by simpa [Metric.mem_ball,dist_zero_right] using hx) he refine ⟨?_,sub_self _,fun z => sub_nonneg.mpr (even_convex_minimum hc he' z), fun z => by rw [he' z],?_⟩ · simpa only [add_zero] using (conjugate_lipschitz hK hKR hw).sub (LipschitzWith.const (conjugate _ w 0)) · refine ⟨convex_univ,?_⟩ intro x hx y hy a b ha hb hab have hh := hc.2 hx hy ha hb hab simp only [smul_eq_mul] at hh ⊢ have hconst : (a+b)*conjugate (Metric.ball (0:E) R) w 0=conjugate (Metric.ball (0:E) R) w 0 := by rw [hab,one_mul] nlinarith omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in lemma normalized_conjugate_dual_bdd {R : ℝ≥0} {w : E → ℝ} {m : ℝ} (hw : ∀ x ∈ Metric.ball (0:E) R, m ≤ w x) : ∀ x ∈ Metric.ball (0:E) R, BddAbove ((fun z => ⟪z,x⟫_ℝ- (conjugate (Metric.ball (0:E) R) w z-conjugate (Metric.ball (0:E) R) w 0)) '' univ) := by intro x hx refine ⟨w x+conjugate (Metric.ball (0:E) R) w 0,?_⟩ rintro _ ⟨z,_,rfl⟩ have hh := le_conjugate (fun y hy => (by simpa [Metric.mem_ball,dist_zero_right] using hy : ‖y‖ < (R:ℝ)).le) hw hx z rw [real_inner_comm z x] at hh linarith omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in lemma normalized_envelope_le {R : ℝ≥0} {w : E → ℝ} {m : ℝ} {x : E} (hw : ∀ x ∈ Metric.ball (0:E) R, m ≤ w x) (hx : x ∈ Metric.ball (0:E) R) : dualOn (Metric.ball (0:E) R) (fun z => conjugate (Metric.ball (0:E) R) w z- conjugate (Metric.ball (0:E) R) w 0) x ≤ w x+conjugate (Metric.ball (0:E) R) w 0 := by rw [dualOn_eq hx] apply conjugate_le univ_nonempty intro z _ have hh := le_conjugate (fun y hy => (by simpa [Metric.mem_ball,dist_zero_right] using hy : ‖y‖ < (R:ℝ)).le) hw hx z rw [real_inner_comm z x] at hh linarith end section variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] lemma normalized_envelope_admissible {ν : Measure E} [IsProbabilityMeasure ν] {R : ℝ≥0} {w : E → ℝ} {m : ℝ} (hR : 0 < R) (hw : ∀ x ∈ Metric.ball (0:E) R, m ≤ w x) (he : Function.Even w) (hi : Integrable w ν) (hν : ∀ᵐ x ∂ν, x ∈ Metric.ball (0:E) R) : Admissible ν R (dualOn (Metric.ball (0:E) R) (fun z => conjugate (Metric.ball (0:E) R) w z- conjugate (Metric.ball (0:E) R) w 0)) := by let φ := fun z => conjugate (Metric.ball (0:E) R) w z-conjugate (Metric.ball (0:E) R) w 0 have hφ : NormalizedConvex R φ := normalized_conjugate hR hw he have hb := normalized_conjugate_dual_bdd hw have hn := dualOn_nonneg hφ.zero hb have hc := convexOn_dualOn (convex_ball (0:E) (R:ℝ)) hb have ham : AEStronglyMeasurable (dualOn (Metric.ball (0:E) R) φ) ν := (aestronglyMeasurable_indicator_iff Metric.isOpen_ball.measurableSet).mpr ((ConvexOn.continuousOn Metric.isOpen_ball (convexOn_conjugate_of_bdd univ_nonempty (convex_ball (0:E) (R:ℝ)) hb)).aestronglyMeasurable Metric.isOpen_ball.measurableSet) refine ⟨hc,hn,dualOn_zero hφ.zero hφ.nonneg hb,dualOn_even_ball hφ.even, fun x hx => indicator_of_notMem hx _,?_⟩ apply (hi.add (integrable_const (conjugate (Metric.ball (0:E) R) w 0))).mono' ham filter_upwards [hν] with x hx rw [Real.norm_eq_abs,abs_of_nonneg (hn x)] exact normalized_envelope_le hw hx variable (μ : Measure E) [μ.IsAddHaarMeasure] lemma normalized_envelope_functional_ge {ν : Measure E} [IsProbabilityMeasure ν] {R : ℝ≥0} {w : E → ℝ} {m : ℝ} (hR : 0 < R) (hw : ∀ x ∈ Metric.ball (0:E) R, m ≤ w x) (he : Function.Even w) (hi : Integrable w ν) (hν : ∀ᵐ x ∂ν, x ∈ Metric.ball (0:E) R) (hI : Integrable (fun z => Real.exp (-conjugate (Metric.ball (0:E) R) w z)) μ) : ∃ v, Admissible ν R v ∧ functional μ ν (Metric.ball (0:E) R) w ≤ functional μ ν (Metric.ball (0:E) R) v := by let K := Metric.ball (0:E) (R:ℝ) let c := conjugate K w 0 let φ := fun z => conjugate K w z-c let v := dualOn K φ have hφ : NormalizedConvex R φ := normalized_conjugate hR hw he have hb := normalized_conjugate_dual_bdd hw have hv : Admissible ν R v := normalized_envelope_admissible hR hw he hi hν have heq : conjugate K v=φ := conjugate_dualOn_ball hR hφ.lipschitz hφ.zero hφ.nonneg hφ.convex hb have hIp : 0 < ∫ z, Real.exp (-conjugate K w z) ∂μ := integral_exp_pos hI have hIeq : (∫ z, Real.exp (-conjugate K v z) ∂μ)= Real.exp c*(∫ z,Real.exp (-conjugate K w z) ∂μ) := by rw [heq,← integral_const_mul] apply integral_congr_ae exact Eventually.of_forall fun z => by change Real.exp (-φ z)=Real.exp c*Real.exp (-conjugate K w z) rw [← Real.exp_add] congr 1 dsimp only [φ] ring have hm : (∫ x,v x ∂ν) ≤ (∫ x,w x ∂ν)+c := by calc _ ≤ ∫ x,w x+c ∂ν := by apply integral_mono_ae hv.integrable (hi.add (integrable_const c)) filter_upwards [hν] with x hx exact normalized_envelope_le hw hx _ = _ := by simp [integral_add hi (integrable_const c)] refine ⟨v,hv,?_⟩ change Real.log (∫ z, Real.exp (-conjugate K w z) ∂μ)-(∫ x,w x ∂ν) ≤ Real.log (∫ z, Real.exp (-conjugate K v z) ∂μ)-(∫ x,v x ∂ν) rw [hIeq,Real.log_mul (Real.exp_ne_zero c) hIp.ne',Real.log_exp] linarith end section variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] lemma fenchel_gap_control {K : Set E} {u : E → ℝ} {R m : ℝ} (hR : ∀ x ∈ K, ‖x‖ ≤ R) (hu : ∀ x ∈ K, m ≤ u x) {z g : E} (hd : HasFDerivAt (conjugate K u) (innerSL ℝ g) z) {ε : ℝ} (hε : 0 < ε) : ∃ h > 0, ∀ x ∈ K, ‖x-g‖ ≤ ε+(conjugate K u z+u x-⟪x,z⟫_ℝ)/h := by obtain ⟨δ,hδ,hδb⟩ := Metric.eventually_nhds_iff.mp (hd.isLittleO.bound hε) refine ⟨δ/2,by positivity,?_⟩ intro x hx have hgap : 0 ≤ conjugate K u z+u x-⟪x,z⟫_ℝ := by linarith [le_conjugate hR hu hx z] by_cases hzero : x-g=0 · rw [hzero,norm_zero] positivity have hn : 0 < ‖x-g‖ := norm_pos_iff.mpr hzero let y := ((δ/2)/‖x-g‖) • (x-g) have hyn : ‖y‖=δ/2 := by dsimp only [y] rw [norm_smul,Real.norm_eq_abs,abs_of_pos (div_pos (by positivity) hn)] exact div_mul_cancel₀ _ hn.ne' have hyδ : dist (z+y) z < δ := by rw [dist_eq_norm,add_sub_cancel_left,hyn] linarith have hb := hδb hyδ change ‖conjugate K u (z+y)-conjugate K u z-(innerSL ℝ g) ((z+y)-z)‖ ≤ ε*‖(z+y)-z‖ at hb rw [add_sub_cancel_left,innerSL_apply_apply,hyn,Real.norm_eq_abs] at hb have hi : ⟪x-g,y⟫_ℝ=(δ/2)*‖x-g‖ := by dsimp only [y] rw [inner_smul_right,real_inner_self_eq_norm_sq] field_simp have hf := le_conjugate hR hu hx (z+y) rw [inner_add_right] at hf rw [inner_sub_left] at hi have hz := (abs_le.mp hb).2 have hh : (δ/2)*‖x-g‖ ≤ conjugate K u z+u x-⟪x,z⟫_ℝ+ε*(δ/2) := by linarith calc _ ≤ (conjugate K u z+u x-⟪x,z⟫_ℝ+ε*(δ/2))/(δ/2) := (le_div_iff₀ (show (0:ℝ)<δ/2 by positivity)).mpr (by nlinarith [hh]) _ = _ := by field_simp; ring omit [NormedAddCommGroup E] [InnerProductSpace ℝ E] in lemma tilt_lower {K : Set E} {u f : E → ℝ} {m B t : ℝ} (hu : ∀ x ∈ K, m ≤ u x) (hf : ∀ x ∈ K, |f x| ≤ B) : ∀ x ∈ K, m-|t| *B ≤ u x+t*f x := by intro x hx have hs := neg_abs_le (t*f x) rw [abs_mul] at hs have hb := mul_le_mul_of_nonneg_left (hf x hx) (abs_nonneg t) linarith [hu x hx] lemma tilted_conjugate_remainder_bound {K : Set E} (hK : K.Nonempty) {u f : E → ℝ} {R m B : ℝ} {C : ℝ≥0} (hR : ∀ x ∈ K, ‖x‖ ≤ R) (hu : ∀ x ∈ K, m ≤ u x) (hf : LipschitzWith C f) (hB : ∀ x ∈ K, |f x| ≤ B) {z g : E} {ε h t : ℝ} (hh : 0 < h) (hgap : ∀ x ∈ K, ‖x-g‖ ≤ ε+(conjugate K u z+u x-⟪x,z⟫_ℝ)/h) (ht : |t| *(C:ℝ) ≤ h) : |conjugate K (fun x => u x+t*f x) z-conjugate K u z+t*f g| ≤ |t| *(C:ℝ)*ε := by let a := |t| *(C:ℝ) have ha : 0 ≤ a := mul_nonneg (abs_nonneg t) C.coe_nonneg have ha1 : a/h ≤ 1 := (div_le_one hh).mpr ht have hg0 (x : E) (hx : x ∈ K) : 0 ≤ conjugate K u z+u x-⟪x,z⟫_ℝ := by linarith [le_conjugate hR hu hx z] have htlo := tilt_lower hu hB (t:=t) have hdist (x : E) (hx : x ∈ K) : |t*(f x-f g)| ≤ a*(ε+(conjugate K u z+u x-⟪x,z⟫_ℝ)/h) := by rw [abs_mul] have hf' : |f x-f g| ≤ (C:ℝ)*‖x-g‖ := by simpa only [Real.norm_eq_abs] using hf.norm_sub_le x g calc _ ≤ |t| *((C:ℝ)*‖x-g‖) := mul_le_mul_of_nonneg_left hf' (abs_nonneg t) _ = a*‖x-g‖ := by dsimp [a]; ring _ ≤ _ := mul_le_mul_of_nonneg_left (hgap x hx) ha have hup : conjugate K (fun x => u x+t*f x) z ≤ conjugate K u z-t*f g+a*ε := by apply conjugate_le hK intro x hx have h1 := (abs_le.mp (hdist x hx)).1 have h2 := mul_le_mul_of_nonneg_right ha1 (hg0 x hx) have heq : a*(ε+(conjugate K u z+u x-⟪x,z⟫_ℝ)/h)= a*ε+(a/h)*(conjugate K u z+u x-⟪x,z⟫_ℝ) := by ring rw [heq] at h1 nlinarith have hden : 0 < 1+a/h := by positivity have hlow : conjugate K u z ≤ (conjugate K (fun x => u x+t*f x) z+t*f g+a*ε+(a/h)*conjugate K u z)/(1+a/h) := by apply conjugate_le hK intro x hx apply (le_div_iff₀ hden).mpr have h1 := (abs_le.mp (hdist x hx)).2 have h2 := le_conjugate hR htlo hx z have heq : a*(ε+(conjugate K u z+u x-⟪x,z⟫_ℝ)/h)= a*ε+(a/h)*(conjugate K u z+u x-⟪x,z⟫_ℝ) := by ring rw [heq] at h1 nlinarith have hlow' := (le_div_iff₀ hden).mp hlow apply abs_le.mpr constructor <;> dsimp only [a] at * <;> nlinarith lemma hasDerivAt_conjugate_tilt {K : Set E} (hK : K.Nonempty) {u f : E → ℝ} {R m B : ℝ} {C : ℝ≥0} (hR : ∀ x ∈ K, ‖x‖ ≤ R) (hu : ∀ x ∈ K, m ≤ u x) (hf : LipschitzWith C f) (hB : ∀ x ∈ K, |f x| ≤ B) {z g : E} (hd : HasFDerivAt (conjugate K u) (innerSL ℝ g) z) : HasDerivAt (fun t : ℝ => conjugate K (fun x => u x+t*f x) z) (-f g) 0 := by rw [hasDerivAt_iff_isLittleO] apply Asymptotics.isLittleO_iff.mpr intro ε hε have hC : 0 < (C:ℝ)+1 := by positivity obtain ⟨h,hh,hgap⟩ := fenchel_gap_control hR hu hd (div_pos hε hC) refine Metric.eventually_nhds_iff.mpr ⟨h/((C:ℝ)+1),div_pos hh hC,?_⟩ intro t ht have ht' : |t| *((C:ℝ)+1) < h := (lt_div_iff₀ hC).mp (by simpa [Real.dist_eq] using ht) have htC : |t| *(C:ℝ) ≤ h := by nlinarith [abs_nonneg t] have he := tilted_conjugate_remainder_bound hK hR hu hf hB hh hgap htC have hfrac : (C:ℝ)*(ε/((C:ℝ)+1)) ≤ ε := by calc _ = ((C:ℝ)*ε)/((C:ℝ)+1) := by ring _ ≤ ε := (div_le_iff₀ hC).mpr (by nlinarith) have heq : (fun t => conjugate K (fun x => u x+t*f x) z) 0=conjugate K u z := by simp change conjugate K (fun x => u x+0*f x) z=conjugate K u z at heq rw [heq] simp only [sub_zero,smul_eq_mul,Real.norm_eq_abs] have halg : conjugate K (fun x => u x+t*f x) z-conjugate K u z-t*(-f g)= conjugate K (fun x => u x+t*f x) z-conjugate K u z+t*f g := by ring rw [halg] exact he.trans (by nlinarith [mul_le_mul_of_nonneg_left hfrac (abs_nonneg t)]) lemma conjugate_tilt_lipschitz {K : Set E} (hK : K.Nonempty) {u f : E → ℝ} {R m B : ℝ} (hR : ∀ x ∈ K, ‖x‖ ≤ R) (hu : ∀ x ∈ K, m ≤ u x) (hB : ∀ x ∈ K, |f x| ≤ B) (z : E) (s t : ℝ) : |conjugate K (fun x => u x+t*f x) z-conjugate K (fun x => u x+s*f x) z| ≤ |t-s| *B := by apply conjugate_perturb_abs hK hR (tilt_lower hu hB) intro x hx have heq : u x+t*f x-(u x+s*f x)=(t-s)*f x := by ring rw [heq,abs_mul] exact mul_le_mul_of_nonneg_left (hB x hx) (abs_nonneg _) lemma exp_sub_bound {x y A : ℝ} (hx : x ≤ A) (hy : y ≤ A) : |Real.exp x-Real.exp y| ≤ Real.exp A*|x-y| := by have hh := (convex_Iic A).norm_image_sub_le_of_norm_deriv_le (f:=Real.exp) (fun _ _ => Real.differentiableAt_exp) (fun b hb => by simpa only [Real.deriv_exp,Real.norm_eq_abs,abs_of_pos (Real.exp_pos b)] using Real.exp_le_exp.mpr hb) hy hx simpa only [Real.norm_eq_abs] using hh lemma tilt_density_lipschitz {K : Set E} (hK : K.Nonempty) {u f : E → ℝ} {R m B : ℝ} (hR : ∀ x ∈ K, ‖x‖ ≤ R) (hu : ∀ x ∈ K, m ≤ u x) (hB : ∀ x ∈ K, |f x| ≤ B) (z : E) : LipschitzOnWith (Real.nnabs (Real.exp B*B*Real.exp (-conjugate K u z))) (fun t : ℝ => Real.exp (-conjugate K (fun x => u x+t*f x) z)) (Metric.ball 0 1) := by have hB0 : 0 ≤ B := by obtain ⟨x,hx⟩ := hK; exact (abs_nonneg _).trans (hB x hx) have hb (t : ℝ) (ht : t ∈ Metric.ball (0:ℝ) 1) : -conjugate K (fun x => u x+t*f x) z ≤ B-conjugate K u z := by have h := conjugate_tilt_lipschitz hK hR hu hB z 0 t simp only [zero_mul,add_zero,sub_zero] at h have ht' : |t| ≤ 1 := (by simpa [Metric.mem_ball,Real.dist_eq] using ht : |t| < 1).le have hb' := mul_le_mul_of_nonneg_right ht' hB0 linarith [(abs_le.mp h).1] rw [lipschitzOnWith_iff_dist_le_mul] intro t ht s hs rw [Real.dist_eq,Real.dist_eq,Real.coe_nnabs] rw [abs_of_nonneg (show 0 ≤ Real.exp B*B*Real.exp (-conjugate K u z) by positivity)] calc _ ≤ Real.exp (B-conjugate K u z)*|(-conjugate K (fun x => u x+t*f x) z)-(-conjugate K (fun x => u x+s*f x) z)| := exp_sub_bound (hb t ht) (hb s hs) _ = Real.exp (B-conjugate K u z)*|conjugate K (fun x => u x+t*f x) z-conjugate K (fun x => u x+s*f x) z| := by congr 1 rw [neg_sub_neg,abs_sub_comm] _ ≤ Real.exp (B-conjugate K u z)*(|t-s| *B) := mul_le_mul_of_nonneg_left (conjugate_tilt_lipschitz hK hR hu hB z s t) (Real.exp_pos _).le _ = _ := by rw [sub_eq_add_neg,Real.exp_add]; ring variable [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] omit [FiniteDimensional ℝ E] in lemma hasDerivAt_tilt_partition {μ : Measure E} {K : Set E} (hK : K.Nonempty) {u f : E → ℝ} {R C : ℝ≥0} {m B : ℝ} (hR : ∀ x ∈ K, ‖x‖ ≤ R) (hu : ∀ x ∈ K, m ≤ u x) (hf : LipschitzWith C f) (hB : ∀ x ∈ K, |f x| ≤ B) {g : E → E} (hg : Measurable g) (hd : ∀ᵐ z ∂μ, HasFDerivAt (conjugate K u) (innerSL ℝ (g z)) z) (hI : Integrable (fun z => Real.exp (-conjugate K u z)) μ) : Integrable (fun z => f (g z)*Real.exp (-conjugate K u z)) μ ∧ HasDerivAt (fun t : ℝ => ∫ z, Real.exp (-conjugate K (fun x => u x+t*f x) z) ∂μ) (∫ z, f (g z)*Real.exp (-conjugate K u z) ∂μ) 0 := by have hc := (conjugate_lipschitz hK hR hu).continuous apply hasDerivAt_integral_of_dominated_loc_of_lip (bound:=fun z => Real.exp B*B*Real.exp (-conjugate K u z)) (Metric.ball_mem_nhds 0 (by norm_num : (0:ℝ)<1)) · exact Eventually.of_forall fun t => ((conjugate_lipschitz hK hR (tilt_lower hu hB (t:=t))).continuous.neg.rexp).aestronglyMeasurable · simpa using hI · exact ((hf.continuous.measurable.comp hg).mul hc.neg.rexp.measurable).aestronglyMeasurable · exact Eventually.of_forall (tilt_density_lipschitz hK hR hu hB) · exact hI.const_mul _ · filter_upwards [hd] with z hz have h := (hasDerivAt_conjugate_tilt hK hR hu hf hB hz).neg.exp simpa [mul_comm] using h end section variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] omit [FiniteDimensional ℝ E] in lemma tilt_partition_integrable {μ : Measure E} {K : Set E} (hK : K.Nonempty) {u f : E → ℝ} {R : ℝ≥0} {m B : ℝ} (hR : ∀ x ∈ K, ‖x‖ ≤ R) (hu : ∀ x ∈ K, m ≤ u x) (hB : ∀ x ∈ K, |f x| ≤ B) (hI : Integrable (fun z => Real.exp (-conjugate K u z)) μ) (t : ℝ) : Integrable (fun z => Real.exp (-conjugate K (fun x => u x+t*f x) z)) μ := by have hb (z : E) := (abs_le.mp (conjugate_tilt_lipschitz hK hR hu hB z 0 t)).1 simp only [zero_mul,add_zero,sub_zero] at hb apply (hI.const_mul (Real.exp (|t| *B))).mono' (conjugate_lipschitz hK hR (tilt_lower hu hB (t:=t))).continuous.neg.rexp.aestronglyMeasurable exact Eventually.of_forall fun z => by rw [Real.norm_eq_abs,abs_of_pos (Real.exp_pos _),← Real.exp_add] apply Real.exp_le_exp.mpr change -conjugate K (fun x => u x+t*f x) z ≤ |t| *B-conjugate K u z have hbz : -(|t| *B) ≤ conjugate K (fun x => u x+t*f x) z-conjugate K u z := hb z linarith lemma measurable_gradient (φ : E → ℝ) : Measurable (gradient φ) := (InnerProductSpace.toDual ℝ E).symm.continuous.measurable.comp (measurable_fderiv ℝ φ) variable (μ : Measure E) [μ.IsAddHaarMeasure] lemma admissible_tail {ν : Measure E} {R : ℝ≥0} {d : ℝ} {u : E → ℝ} (hR : 0 < R) (hd : 0 < d) (hu : Admissible ν R u) (hν : ∀ S : ℝ, 0 ≤ S → S < R → ENNReal.ofReal d • μ.restrict (Metric.closedBall (0:E) S) ≤ ν) : ∃ c > 0, ∀ z, c*‖z‖-1 ≤ conjugate (Metric.ball (0:E) R) u z := by have hR' : (0:ℝ) Real.exp (-conjugate (Metric.ball (0:E) R) u z)) μ := by obtain ⟨c,hc,hl⟩ := admissible_tail μ hR hd hu hν exact tail_integrable μ (admissible_conjugate_lipschitz hR hu).continuous hc hl lemma maximal_functional_tilt_le {ν : Measure E} [IsProbabilityMeasure ν] {R C : ℝ≥0} {u f : E → ℝ} {B : ℝ} (hR : 0 < R) (hu : Admissible ν R u) (hmax : ∀ v, Admissible ν R v → functional μ ν (Metric.ball (0:E) R) v ≤ functional μ ν (Metric.ball (0:E) R) u) (hν : ∀ᵐ x ∂ν, x ∈ Metric.ball (0:E) R) (hf : LipschitzWith C f) (he : Function.Even f) (hB : ∀ x ∈ Metric.ball (0:E) R, |f x| ≤ B) (hI : Integrable (fun z => Real.exp (-conjugate (Metric.ball (0:E) R) u z)) μ) (t : ℝ) : functional μ ν (Metric.ball (0:E) R) (fun x => u x+t*f x) ≤ functional μ ν (Metric.ball (0:E) R) u := by have hKR : ∀ x ∈ Metric.ball (0:E) (R:ℝ), ‖x‖ ≤ R := fun x hx => (by simpa [Metric.mem_ball,dist_zero_right] using hx : ‖x‖ < R).le have hfi : Integrable f ν := (integrable_const B).mono' hf.continuous.aestronglyMeasurable (hν.mono fun x hx => by simpa only [Real.norm_eq_abs] using hB x hx) obtain ⟨v,hv,hvge⟩ := normalized_envelope_functional_ge μ hR (tilt_lower (fun x _ => hu.nonneg x) hB (t:=t)) (fun x => by simp only [hu.even x,he x]) (hu.integrable.add (hfi.const_mul t)) hν (tilt_partition_integrable ⟨0,by simpa using hR⟩ hKR (fun x _ => hu.nonneg x) hB hI t) exact hvge.trans (hmax v hv) lemma first_variation_even {ν : Measure E} [IsProbabilityMeasure ν] {R C : ℝ≥0} {u f : E → ℝ} {B : ℝ} (hR : 0 < R) (hu : Admissible ν R u) (hmax : ∀ v, Admissible ν R v → functional μ ν (Metric.ball (0:E) R) v ≤ functional μ ν (Metric.ball (0:E) R) u) (hν : ∀ᵐ x ∂ν, x ∈ Metric.ball (0:E) R) (hf : LipschitzWith C f) (he : Function.Even f) (hB : ∀ x ∈ Metric.ball (0:E) R, |f x| ≤ B) (hI : Integrable (fun z => Real.exp (-conjugate (Metric.ball (0:E) R) u z)) μ) : (∫ z, f (gradient (conjugate (Metric.ball (0:E) R) u) z)*Real.exp (-conjugate (Metric.ball (0:E) R) u z) ∂μ) / (∫ z, Real.exp (-conjugate (Metric.ball (0:E) R) u z) ∂μ) = ∫ x,f x ∂ν := by let K := Metric.ball (0:E) (R:ℝ) let φ := conjugate K u let I := ∫ z,Real.exp (-φ z) ∂μ have hKR : ∀ x ∈ K, ‖x‖ ≤ R := fun x hx => (by simpa [K,Metric.mem_ball,dist_zero_right] using hx : ‖x‖ < R).le have hl : LipschitzWith R φ := admissible_conjugate_lipschitz hR hu have hdiff : ∀ᵐ z ∂μ, HasFDerivAt φ (innerSL ℝ (gradient φ z)) z := by filter_upwards [hl.ae_differentiableAt (μ:=μ)] with z hz exact hz.hasGradientAt.hasFDerivAt obtain ⟨_,hIp⟩ := hasDerivAt_tilt_partition ⟨0,by simpa [K] using hR⟩ hKR (fun x _ => hu.nonneg x) hf hB (measurable_gradient φ) hdiff hI have hIpos : 0 < I := integral_exp_pos hI have hfi : Integrable f ν := (integrable_const B).mono' hf.continuous.aestronglyMeasurable (hν.mono fun x hx => by simpa only [Real.norm_eq_abs] using hB x hx) have hzero : (∫ z, Real.exp (-conjugate K (fun x => u x+(0:ℝ)*f x) z) ∂μ)=I := by simp [I,φ] have hmean : HasDerivAt (fun t : ℝ => ∫ x,u x+t*f x ∂ν) (∫ x,f x ∂ν) 0 := by have heq : (fun t : ℝ => ∫ x,u x+t*f x ∂ν)=(fun t => (∫ x,u x ∂ν)+t*(∫ x,f x ∂ν)) := by funext t rw [integral_add hu.integrable (hfi.const_mul t),integral_const_mul] rw [heq] simpa using ((hasDerivAt_id (0:ℝ)).mul_const (∫ x,f x ∂ν)).const_add (∫ x,u x ∂ν) have hp := (hIp.log (by rw [hzero]; exact hIpos.ne')).sub hmean have hloc : IsLocalMax (fun t : ℝ => functional μ ν K (fun x => u x+t*f x)) 0 := by apply Eventually.of_forall intro t simpa only [zero_mul,add_zero] using maximal_functional_tilt_le μ hR hu hmax hν hf he hB hI t have hstat := hloc.hasDerivAt_eq_zero hp rw [hzero] at hstat exact sub_eq_zero.mp hstat end section variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] omit [MeasurableSpace E] [BorelSpace E] in lemma gradient_odd_of_even {φ : E → ℝ} (he : Function.Even φ) : Function.Odd (gradient φ) := by intro z have heq : φ ∘ (ContinuousLinearEquiv.neg ℝ (M:=E))=φ := funext he have hh := (ContinuousLinearEquiv.neg ℝ (M:=E)).comp_right_fderiv (f:=φ) (x:=z) rw [heq] at hh have hd : fderiv ℝ φ (-z) = -fderiv ℝ φ z := by ext v have hp := congrArg (fun L : E →L[ℝ] ℝ => L v) hh simp only [ContinuousLinearMap.comp_apply, ContinuousLinearEquiv.coe_coe, ContinuousLinearEquiv.neg_apply, map_neg] at hp simpa using (congrArg Neg.neg hp).symm simp only [gradient,hd,map_neg] omit [FiniteDimensional ℝ E] [InnerProductSpace ℝ E] in lemma measure_ext_bounded_lipschitz {μ ν : Measure E} [IsFiniteMeasure μ] [IsFiniteMeasure ν] (h : ∀ (f : E → ℝ) (C : ℝ≥0) (B : ℝ), LipschitzWith C f → (∀ x, |f x| ≤ B) → (∫ x,f x ∂μ)=(∫ x,f x ∂ν)) : μ=ν := by have hcl (s : Set E) (hs : IsClosed s) : μ s=ν s := by let fs (n : ℕ) (x : E) : ℝ := thickenedIndicator (δ:=(1:ℝ)/(n+1)) (by positivity) s x have hfs (n : ℕ) : (∫ x,fs n x ∂μ)=(∫ x,fs n x ∂ν) := by apply h (fs n) _ 1 · exact lipschitzWith_thickenedIndicator (by positivity) s · intro x dsimp only [fs] rw [abs_of_nonneg (by positivity)] exact_mod_cast thickenedIndicator_le_one (δ:=(1:ℝ)/(n+1)) (by positivity) s x have hμ := tendsto_integral_thickenedIndicator_of_isClosed μ hs (δs:=fun n : ℕ => (1:ℝ)/(n+1)) (fun _ => by positivity) tendsto_one_div_add_atTop_nhds_zero_nat have hν := tendsto_integral_thickenedIndicator_of_isClosed ν hs (δs:=fun n : ℕ => (1:ℝ)/(n+1)) (fun _ => by positivity) tendsto_one_div_add_atTop_nhds_zero_nat change Tendsto (fun n => ∫ x,fs n x ∂μ) atTop (𝓝 (μ.real s)) at hμ change Tendsto (fun n => ∫ x,fs n x ∂ν) atTop (𝓝 (ν.real s)) at hν simp_rw [hfs] at hμ exact (ENNReal.toReal_eq_toReal_iff' (measure_ne_top μ s) (measure_ne_top ν s)).mp (tendsto_nhds_unique hμ hν) apply MeasureTheory.ext_of_generate_finite {s | IsClosed s} (BorelSpace.measurable_eq.trans borel_eq_generateFrom_isClosed) isPiSystem_isClosed (fun s hs => hcl s hs) (hcl univ isClosed_univ) variable (μ : Measure E) [μ.IsAddHaarMeasure] lemma first_variation_bounded {ν : Measure E} [IsProbabilityMeasure ν] [Measure.IsNegInvariant ν] {R C : ℝ≥0} {u f : E → ℝ} {B : ℝ} (hR : 0 < R) (hu : Admissible ν R u) (hmax : ∀ v, Admissible ν R v → functional μ ν (Metric.ball (0:E) R) v ≤ functional μ ν (Metric.ball (0:E) R) u) (hν : ∀ᵐ x ∂ν, x ∈ Metric.ball (0:E) R) (hf : LipschitzWith C f) (hB : ∀ x, |f x| ≤ B) (hI : Integrable (fun z => Real.exp (-conjugate (Metric.ball (0:E) R) u z)) μ) : (∫ z, f (gradient (conjugate (Metric.ball (0:E) R) u) z)*Real.exp (-conjugate (Metric.ball (0:E) R) u z) ∂μ) / (∫ z, Real.exp (-conjugate (Metric.ball (0:E) R) u z) ∂μ) = ∫ x,f x ∂ν := by let φ := conjugate (Metric.ball (0:E) R) u let g := gradient φ let fs := fun x => f x+f (-x) have hφe : Function.Even φ := (admissible_conjugate_normalized hR hu).even have hg : Function.Odd g := gradient_odd_of_even hφe have hgmeas : Measurable g := measurable_gradient φ have hρc := (admissible_conjugate_lipschitz hR hu).continuous.neg.rexp have hfN : LipschitzWith C (fun x : E => f (-x)) := by apply LipschitzWith.of_dist_le_mul intro x y simpa only [dist_neg_neg] using hf.dist_le_mul (-x) (-y) have hfs : LipschitzWith (C+C) fs := hf.add hfN have hfse : Function.Even fs := fun x => by simp [fs,add_comm] have hfsB (x : E) : |fs x| ≤ 2*B := (abs_add_le _ _).trans (by linarith [hB x,hB (-x)]) have hs := first_variation_even μ hR hu hmax hν hfs hfse (fun x _ => hfsB x) hI have hfi : Integrable f ν := (integrable_const B).mono' hf.continuous.aestronglyMeasurable (Eventually.of_forall fun x => by simpa only [Real.norm_eq_abs] using hB x) have hfig : Integrable (fun z => f (g z)*Real.exp (-φ z)) μ := by apply (hI.const_mul B).mono' (((hf.continuous.measurable.comp hgmeas).mul hρc.measurable).aestronglyMeasurable) exact Eventually.of_forall fun z => by change ‖f (g z)*Real.exp (-φ z)‖ ≤ _ rw [norm_mul,Real.norm_eq_abs,Real.norm_eq_abs,abs_of_pos (Real.exp_pos _)] exact mul_le_mul_of_nonneg_right (hB _) (Real.exp_pos _).le have hfigN : Integrable (fun z => f (-g z)*Real.exp (-φ z)) μ := by simpa only [show ∀ x, g (-x) = -g x from hg, show ∀ x, φ (-x) = φ x from hφe] using hfig.comp_neg have hsμ : (∫ z,fs (g z)*Real.exp (-φ z) ∂μ)=2*(∫ z,f (g z)*Real.exp (-φ z) ∂μ) := by simp only [fs,add_mul] rw [integral_add hfig hfigN] have hn := integral_neg_eq_self (fun z => f (g z)*Real.exp (-φ z)) μ simp only [show ∀ x, g (-x) = -g x from hg, show ∀ x, φ (-x) = φ x from hφe] at hn rw [hn] ring have hsν : (∫ x,fs x ∂ν)=2*(∫ x,f x ∂ν) := by dsimp only [fs] rw [integral_add hfi hfi.comp_neg,integral_neg_eq_self] ring change (∫ z,fs (g z)*Real.exp (-φ z) ∂μ)/(∫ z,Real.exp (-φ z) ∂μ)=∫ x,fs x ∂ν at hs rw [hsμ,hsν,mul_div_assoc] at hs change (∫ z,f (g z)*Real.exp (-φ z) ∂μ)/(∫ z,Real.exp (-φ z) ∂μ)=_ linarith end variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] variable (μ : Measure E) [μ.IsAddHaarMeasure] def normalizedSource (φ : E → ℝ) : Measure E := μ.withDensity (fun z => ENNReal.ofReal (Real.exp (-φ z)/(∫ y,Real.exp (-φ y) ∂μ))) omit [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [BorelSpace E] in lemma normalizedSource_probability {φ : E → ℝ} (hI : Integrable (fun z => Real.exp (-φ z)) μ) : IsProbabilityMeasure (normalizedSource μ φ) := by have hIp := integral_exp_pos hI apply isProbabilityMeasure_iff.mpr rw [normalizedSource,withDensity_apply _ MeasurableSet.univ,Measure.restrict_univ, ← ofReal_integral_eq_lintegral_ofReal] · simp only [integral_div,div_self hIp.ne',ENNReal.ofReal_one] · exact hI.div_const _ · exact Eventually.of_forall fun z => div_nonneg (Real.exp_pos _).le hIp.le omit [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [BorelSpace E] in lemma integral_normalizedSource {φ : E → ℝ} (hφ : Measurable φ) (hI : Integrable (fun z => Real.exp (-φ z)) μ) (f : E → ℝ) : (∫ z,f z ∂normalizedSource μ φ) = (∫ z,f z*Real.exp (-φ z) ∂μ)/(∫ z,Real.exp (-φ z) ∂μ) := by have hIp := integral_exp_pos hI have hd : Measurable (fun z => ENNReal.ofReal (Real.exp (-φ z)/(∫ y,Real.exp (-φ y) ∂μ))) := (hφ.neg.exp.div_const _).ennreal_ofReal rw [normalizedSource,integral_withDensity_eq_integral_toReal_smul hd (Eventually.of_forall fun _ => ENNReal.ofReal_lt_top)] simp_rw [ENNReal.toReal_ofReal (div_nonneg (Real.exp_pos _).le hIp.le),smul_eq_mul] rw [← integral_div] congr 1 funext z ring lemma maximizer_pushforward {ν : Measure E} [IsProbabilityMeasure ν] [Measure.IsNegInvariant ν] {R : ℝ≥0} {u : E → ℝ} (hR : 0 < R) (hu : Admissible ν R u) (hmax : ∀ v, Admissible ν R v → functional μ ν (Metric.ball (0:E) R) v ≤ functional μ ν (Metric.ball (0:E) R) u) (hν : ∀ᵐ x ∂ν, x ∈ Metric.ball (0:E) R) (hI : Integrable (fun z => Real.exp (-conjugate (Metric.ball (0:E) R) u z)) μ) : Measure.map (gradient (conjugate (Metric.ball (0:E) R) u)) (normalizedSource μ (conjugate (Metric.ball (0:E) R) u)) = ν := by let φ := conjugate (Metric.ball (0:E) R) u let : IsProbabilityMeasure (normalizedSource μ φ) := normalizedSource_probability μ hI have hg := measurable_gradient φ let : IsProbabilityMeasure (Measure.map (gradient φ) (normalizedSource μ φ)) := inferInstance apply measure_ext_bounded_lipschitz intro f C B hf hB rw [integral_map hg.aemeasurable hf.continuous.aestronglyMeasurable, integral_normalizedSource μ (admissible_conjugate_lipschitz hR hu).continuous.measurable hI] exact first_variation_bounded μ hR hu hmax hν hf hB hI theorem exists_weak_compact_moment {ν : Measure E} [IsProbabilityMeasure ν] [Measure.IsNegInvariant ν] {R : ℝ≥0} {d : ℝ} (hR : 0 < R) (hd : 0 < d) (hν : ∀ S : ℝ, 0 ≤ S → S < R → ENNReal.ofReal d • μ.restrict (Metric.closedBall (0:E) S) ≤ ν) (hsupp : ∀ᵐ x ∂ν, x ∈ Metric.ball (0:E) R) : ∃ φ : E → ℝ, NormalizedConvex R φ ∧ (∃ c > 0, ∀ z, c*‖z‖-1 ≤ φ z) ∧ Integrable (fun z => Real.exp (-φ z)) μ ∧ IsProbabilityMeasure (normalizedSource μ φ) ∧ Measure.map (gradient φ) (normalizedSource μ φ) = ν := by obtain ⟨u,hu,hm⟩ := exists_variational_maximizer μ hR hd hν have hI := admissible_partition_integrable μ hR hd hu hν exact ⟨_,admissible_conjugate_normalized hR hu,admissible_tail μ hR hd hu hν,hI, normalizedSource_probability μ hI,maximizer_pushforward μ hR hu hm hsupp hI⟩ end CompactMomentVariational end open Set MeasureTheory Filter open scoped Topology NNReal ENNReal noncomputable section namespace TruncatedMoment variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] variable (μ : Measure E) [μ.IsAddHaarMeasure] def partition (R : ℝ) (V : E → ℝ) : ℝ := ∫ x in Metric.ball (0:E) R, Real.exp (-V x) ∂μ def target (R : ℝ) (V : E → ℝ) : Measure E := (μ.restrict (Metric.ball (0:E) R)).withDensity (fun x => ENNReal.ofReal (Real.exp (-V x) / partition μ R V)) lemma integrable_density {V : E → ℝ} (hV : Continuous V) (R : ℝ) : IntegrableOn (fun x => Real.exp (-V x)) (Metric.ball (0:E) R) μ := ((hV.neg.rexp.continuousOn).integrableOn_compact (isCompact_closedBall (0:E) R)).mono_set Metric.ball_subset_closedBall lemma partition_pos {V : E → ℝ} (hV : Continuous V) {R : ℝ} (hR : 0 < R) : 0 < partition μ R V := by let : NeZero (μ.restrict (Metric.ball (0:E) R)) := ⟨by intro he have hh := congrArg (fun m : Measure E => m univ) he simp only [Measure.restrict_apply MeasurableSet.univ,univ_inter,Measure.coe_zero,Pi.zero_apply] at hh exact (Metric.measure_ball_pos μ 0 hR).ne' hh⟩ exact integral_exp_pos (integrable_density μ hV R) lemma probability {V : E → ℝ} (hV : Continuous V) {R : ℝ} (hR : 0 < R) : IsProbabilityMeasure (target μ R V) := by have hZ := partition_pos μ hV hR apply isProbabilityMeasure_iff.mpr rw [target,withDensity_apply _ MeasurableSet.univ,Measure.restrict_univ, ← ofReal_integral_eq_lintegral_ofReal] · rw [integral_div] change ENNReal.ofReal (partition μ R V / partition μ R V) = 1 rw [div_self hZ.ne',ENNReal.ofReal_one] · exact (integrable_density μ hV R).div_const _ · exact Eventually.of_forall fun x => div_nonneg (Real.exp_pos _).le hZ.le omit [NormedSpace ℝ E] [FiniteDimensional ℝ E] [μ.IsAddHaarMeasure] in lemma ae_mem_ball (V : E → ℝ) (R : ℝ) : ∀ᵐ x ∂target μ R V, x ∈ Metric.ball (0:E) R := (withDensity_absolutelyContinuous _ _).ae_le (ae_restrict_mem measurableSet_ball) lemma density_lower {V : E → ℝ} (hV : Continuous V) {R : ℝ} (hR : 0 < R) : ∃ d > 0, ∀ S : ℝ, 0 ≤ S → S < R → ENNReal.ofReal d • μ.restrict (Metric.closedBall (0:E) S) ≤ target μ R V := by obtain ⟨M,hM⟩ := (isCompact_closedBall (0:E) R).bddAbove_image hV.continuousOn let d := Real.exp (-M)/partition μ R V have hZ := partition_pos μ hV hR have hd : 0 < d := div_pos (Real.exp_pos _) hZ refine ⟨d,hd,fun S _ hSR => ?_⟩ have hsub : Metric.closedBall (0:E) S ⊆ Metric.ball (0:E) R := by intro x hx exact (Metric.mem_ball.mpr ((Metric.mem_closedBall.mp hx).trans_lt hSR)) have hl : ENNReal.ofReal d • μ.restrict (Metric.ball (0:E) R) ≤ target μ R V := by rw [← withDensity_const] apply withDensity_mono filter_upwards [ae_restrict_mem measurableSet_ball] with x hx apply ENNReal.ofReal_le_ofReal apply div_le_div_of_nonneg_right _ hZ.le apply Real.exp_le_exp.mpr exact neg_le_neg (hM (mem_image_of_mem _ (Metric.ball_subset_closedBall hx))) apply le_trans _ hl intro s simp only [Measure.smul_apply,smul_eq_mul] gcongr lemma even_density_measure {w : E → ℝ≥0∞} (hw : Function.Even w) : (μ.withDensity w).IsNegInvariant := by constructor apply Measure.ext intro s hs rw [Measure.neg_apply,withDensity_apply _ hs.neg,withDensity_apply _ hs] rw [← lintegral_indicator hs.neg,← lintegral_indicator hs] have heq : (fun x => (-s).indicator w x)=(fun x => s.indicator w (-x)) := by funext x by_cases hx : -x ∈ s · simp [Set.mem_neg,hx,show w (-x)=w x from hw x] · simp [Set.mem_neg,hx] rw [heq,lintegral_neg_eq_self] lemma negInvariant {V : E → ℝ} (hV : Function.Even V) (R : ℝ) : (target μ R V).IsNegInvariant := by rw [target,← withDensity_indicator measurableSet_ball] apply even_density_measure μ intro x by_cases hx : x ∈ Metric.ball (0:E) R · have hnx : -x ∈ Metric.ball (0:E) R := by simpa [Metric.mem_ball,dist_zero_right] using hx simp only [Set.indicator_of_mem hx,Set.indicator_of_mem hnx,show V (-x)=V x from hV x] · have hnx : -x ∉ Metric.ball (0:E) R := by simpa [Metric.mem_ball,dist_zero_right] using hx simp only [Set.indicator_of_notMem hx,Set.indicator_of_notMem hnx] end TruncatedMoment namespace CompactMomentVariational variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] variable (μ : Measure E) [μ.IsAddHaarMeasure] omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in lemma gradient_add_constant [CompleteSpace E] (φ : E → ℝ) (a : ℝ) : gradient (fun z => φ z + a) = gradient φ := by funext z simp only [gradient,fderiv_add_const] omit [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [BorelSpace E] in lemma source_shift {φ : E → ℝ} (hI : Integrable (fun z => Real.exp (-φ z)) μ) : μ.withDensity (fun z => ENNReal.ofReal (Real.exp (-(φ z + Real.log (∫ y,Real.exp (-φ y) ∂μ))))) = normalizedSource μ φ := by congr 1 funext z congr 1 rw [neg_add,Real.exp_add,Real.exp_neg (Real.log _),Real.exp_log (integral_exp_pos hI),div_eq_mul_inv] theorem exists_weak_truncated {V : E → ℝ} (hV : Continuous V) (hVe : Function.Even V) {R : ℝ≥0} (hR : 0 < R) : ∃ φ : E → ℝ, ConvexOn ℝ univ φ ∧ Function.Even φ ∧ LipschitzWith R φ ∧ (∃ c > 0, ∃ b : ℝ, ∀ z, c*‖z‖-b ≤ φ z) ∧ IsProbabilityMeasure (μ.withDensity (fun z => ENNReal.ofReal (Real.exp (-φ z)))) ∧ Measure.map (gradient φ) (μ.withDensity (fun z => ENNReal.ofReal (Real.exp (-φ z)))) = TruncatedMoment.target μ R V := by let ν := TruncatedMoment.target μ R V let : IsProbabilityMeasure ν := TruncatedMoment.probability μ hV hR let : ν.IsNegInvariant := TruncatedMoment.negInvariant μ hVe R obtain ⟨d,hd,hl⟩ := TruncatedMoment.density_lower μ hV hR obtain ⟨f,hf,⟨c,hc,ht⟩,hI,hp,hm⟩ := exists_weak_compact_moment μ (ν:=ν) hR hd hl (TruncatedMoment.ae_mem_ball μ V R) let a := Real.log (∫ y,Real.exp (-f y) ∂μ) refine ⟨fun z => f z + a,hf.convex.add (convexOn_const a convex_univ), fun z => by dsimp only; rw [hf.even z],?_,⟨c,hc,1-a,fun z => ?_⟩,?_,?_⟩ · apply LipschitzWith.of_dist_le_mul intro z w simpa only [dist_add_right] using hf.lipschitz.dist_le_mul z w · have hh := ht z linarith · rw [source_shift μ hI] exact hp · rw [source_shift μ hI,gradient_add_constant f a] exact hm end CompactMomentVariational end open scoped ENNReal noncomputable section namespace CompactMomentVariational section variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] lemma convex_supporting_gradient {φ : E → ℝ} (hc : ConvexOn ℝ univ φ) {z : E} (hd : DifferentiableAt ℝ φ z) (w : E) : φ z + ⟪gradient φ z,w-z⟫_ℝ ≤ φ w := by let l : ℝ →ᵃ[ℝ] E := AffineMap.lineMap z w have hconv : ConvexOn ℝ univ (φ ∘ l) := by simpa only [Set.preimage_univ] using hc.comp_affineMap l have hder : HasDerivAt (φ ∘ l) ((fderiv ℝ φ z) (w-z)) 0 := by have hh : HasFDerivAt φ (fderiv ℝ φ z) (l (0:ℝ)) := by simpa only [l, AffineMap.lineMap_apply_zero] using hd.hasFDerivAt exact hh.comp_hasDerivAt (0:ℝ) (AffineMap.hasDerivAt_lineMap (a:=z) (b:=w) (x:=0)) have hh := hconv.le_slope_of_hasDerivAt (mem_univ 0) (mem_univ 1) (by norm_num : (0:ℝ)<1) hder simp only [slope,sub_zero,one_smul,Function.comp_apply,l,AffineMap.lineMap_apply_one, AffineMap.lineMap_apply_zero,inv_one,vsub_eq_sub] at hh rw [← toDual_gradient,InnerProductSpace.toDual_apply_apply] at hh linarith lemma fenchel_eq_at_gradient {φ : E → ℝ} (hc : ConvexOn ℝ univ φ) {z : E} (hd : DifferentiableAt ℝ φ z) : conjugate univ φ (gradient φ z) = ⟪gradient φ z,z⟫_ℝ-φ z := by have hb : BddAbove ((fun w => ⟪w,gradient φ z⟫_ℝ-φ w) '' univ) := by refine ⟨⟪gradient φ z,z⟫_ℝ-φ z,?_⟩ rintro _ ⟨w,_,rfl⟩ have hh := convex_supporting_gradient hc hd w rw [inner_sub_right] at hh dsimp only rw [real_inner_comm (gradient φ z) w] linarith apply le_antisymm · apply conjugate_le (Set.univ_nonempty) intro w _ have hh := convex_supporting_gradient hc hd w rw [inner_sub_right] at hh rw [real_inner_comm (gradient φ z) w] linarith · simpa only [conjugate,real_inner_comm (gradient φ z) z] using (le_csSup hb (mem_image_of_mem (fun w => ⟪w,gradient φ z⟫_ℝ-φ w) (mem_univ z))) lemma inverse_gradient {φ : E → ℝ} {K : Set E} (hK : IsOpen K) (hc : ConvexOn ℝ univ φ) {z : E} (hd : DifferentiableAt ℝ φ z) (hg : gradient φ z ∈ K) (hb : ∀ x ∈ K, BddAbove ((fun w => ⟪w,x⟫_ℝ-φ w) '' univ)) (hu : DifferentiableAt ℝ (dualOn K φ) (gradient φ z)) : gradient (dualOn K φ) (gradient φ z) = z := by let x := gradient φ z have he : dualOn K φ x = ⟪z,x⟫_ℝ-φ z := by rw [dualOn_eq hg,fenchel_eq_at_gradient hc hd,real_inner_comm] have hmin : IsLocalMin (fun y => dualOn K φ y-⟪z,y⟫_ℝ) x := by filter_upwards [hK.mem_nhds hg] with y hy have hh := fenchel_dualOn hb hy z rw [he,real_inner_comm y z] at * linarith have hz := hmin.hasFDerivAt_eq_zero (hu.hasFDerivAt.sub (innerSL ℝ z).hasFDerivAt) have hz' : fderiv ℝ (dualOn K φ) x = innerSL ℝ z := sub_eq_zero.mp hz rw [gradient,hz'] exact (InnerProductSpace.toDual ℝ E).symm_apply_apply z end section variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] lemma locallyLipschitz_ae_differentiable {μ : Measure E} [μ.IsAddHaarMeasure] {K : Set E} (hK : IsOpen K) {f : E → ℝ} (hf : LocallyLipschitzOn K f) : ∀ᵐ x ∂μ, x ∈ K → DifferentiableAt ℝ f x := by have hloc : ∀ x ∈ K, ∃ U : Set E, IsOpen U ∧ x ∈ U ∧ ∃ C : ℝ≥0, LipschitzOnWith C f U := by intro x hx obtain ⟨C,t,ht,hft⟩ := hf hx rw [hK.nhdsWithin_eq hx] at ht exact ⟨interior t,isOpen_interior,mem_interior_iff_mem_nhds.mpr ht,C, hft.mono interior_subset⟩ choose U hUo hUx C hC using hloc obtain ⟨t,ht,hcover⟩ := (HereditarilyLindelofSpace.isLindelof K).elim_nhds_subcover' U (fun x hx => (hUo x hx).mem_nhds (hUx x hx)) have hh : ∀ᵐ x ∂μ.restrict (⋃ z ∈ t, U z.val z.property), DifferentiableAt ℝ f x := by rw [ae_restrict_biUnion_iff _ ht] intro z _ rw [ae_restrict_iff' (hUo z.val z.property).measurableSet] filter_upwards [(hC z.val z.property).ae_differentiableWithinAt_of_mem (μ:=μ)] with x hx intro hxU exact (hx hxU).differentiableAt ((hUo z.val z.property).mem_nhds hxU) rw [← ae_restrict_iff' hK.measurableSet] exact (ae_mono (Measure.restrict_mono hcover le_rfl)) hh lemma convex_ae_differentiable {μ : Measure E} [μ.IsAddHaarMeasure] {K : Set E} (hK : IsOpen K) {f : E → ℝ} (hf : ConvexOn ℝ K f) : ∀ᵐ x ∂μ, x ∈ K → DifferentiableAt ℝ f x := locallyLipschitz_ae_differentiable hK (hf.locallyLipschitzOn hK) lemma gradient_measurable (φ : E → ℝ) : Measurable (gradient φ) := (InnerProductSpace.toDual ℝ E).symm.continuous.measurable.comp (measurable_fderiv ℝ φ) theorem weak_inverse {μ σ ν : Measure E} [μ.IsAddHaarMeasure] (hσ : σ ≪ μ) (hν : ν ≪ μ) {K : Set E} (hK : IsOpen K) (hcK : Convex ℝ K) {φ : E → ℝ} {R : ℝ≥0} (hc : ConvexOn ℝ univ φ) (hl : LipschitzWith R φ) (hb : ∀ x ∈ K, BddAbove ((fun w => ⟪w,x⟫_ℝ-φ w) '' univ)) (hs : ∀ᵐ x ∂ν, x ∈ K) (hm : Measure.map (gradient φ) σ = ν) : ∀ᵐ z ∂σ, gradient (dualOn K φ) (gradient φ z) = z := by have hd : ∀ᵐ x ∂ν, x ∈ K → DifferentiableAt ℝ (dualOn K φ) x := hν.ae_le (convex_ae_differentiable hK (convexOn_dualOn hcK hb)) have hg : ∀ᵐ x ∂ν, x ∈ K ∧ DifferentiableAt ℝ (dualOn K φ) x := by filter_upwards [hs,hd] with x hx hh exact ⟨hx,hh hx⟩ rw [← hm] at hg have hg' := ae_of_ae_map (gradient_measurable φ).aemeasurable hg filter_upwards [hσ.ae_le (hl.ae_differentiableAt (μ:=μ)),hg'] with z hz hg exact inverse_gradient hK hc hz hg.1 hb hg.2 theorem reverse_pushforward {μ σ ν : Measure E} [μ.IsAddHaarMeasure] (hσ : σ ≪ μ) (hν : ν ≪ μ) {K : Set E} (hK : IsOpen K) (hcK : Convex ℝ K) {φ : E → ℝ} {R : ℝ≥0} (hc : ConvexOn ℝ univ φ) (hl : LipschitzWith R φ) (hb : ∀ x ∈ K, BddAbove ((fun w => ⟪w,x⟫_ℝ-φ w) '' univ)) (hs : ∀ᵐ x ∂ν, x ∈ K) (hm : Measure.map (gradient φ) σ = ν) : Measure.map (gradient (dualOn K φ)) ν = σ := by rw [← hm,Measure.map_map (gradient_measurable _) (gradient_measurable _)] have he := weak_inverse hσ hν hK hcK hc hl hb hs hm exact (Measure.map_congr he).trans Measure.map_id end section lemma map_density_pullback {α : Type*} {β : Type*} [MeasurableSpace α] [MeasurableSpace β] (σ : Measure α) {g : α → β} (hg : Measurable g) {w : β → ℝ≥0∞} (hw : Measurable w) : Measure.map g (σ.withDensity (w ∘ g)) = (Measure.map g σ).withDensity w := by apply Measure.ext intro s hs rw [Measure.map_apply hg hs,withDensity_apply _ (hs.preimage hg),withDensity_apply _ hs, ← lintegral_indicator (hs.preimage hg),← lintegral_indicator hs, lintegral_map (hw.indicator hs) hg] congr 1 lemma reverse_weighted {α : Type*} {β : Type*} [MeasurableSpace α] [MeasurableSpace β] {σ : Measure α} {ν : Measure β} {g : α → β} {f : β → α} (hg : Measurable g) (hf : Measurable f) (hm : Measure.map g σ = ν) (hi : ∀ᵐ z ∂σ, f (g z)=z) {w : β → ℝ≥0∞} (hw : Measurable w) : Measure.map f (ν.withDensity w) = σ.withDensity (w ∘ g) := by rw [← hm,← map_density_pullback σ hg hw,Measure.map_map hf hg] exact (Measure.map_congr ((withDensity_absolutelyContinuous _ _).ae_le hi)).trans Measure.map_id variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] lemma dual_conjugate_bdd {K : Set E} {u : E → ℝ} {R m : ℝ} (hR : ∀ x ∈ K, ‖x‖ ≤ R) (hu : ∀ x ∈ K, m ≤ u x) {x : E} (hx : x ∈ K) : BddAbove ((fun z => ⟪z,x⟫_ℝ-conjugate K u z) '' univ) := by refine ⟨u x,?_⟩ rintro _ ⟨z,_,rfl⟩ have hh := le_conjugate hR hu hx z dsimp only rw [real_inner_comm z x] at hh linarith lemma dual_add_constant_bdd {φ : E → ℝ} {x : E} (hb : BddAbove ((fun z => ⟪z,x⟫_ℝ-φ z) '' univ)) (a : ℝ) : BddAbove ((fun z => ⟪z,x⟫_ℝ-(φ z+a)) '' univ) := by obtain ⟨b,hb⟩ := hb refine ⟨b-a,?_⟩ rintro _ ⟨z,hz,rfl⟩ have hh := hb (mem_image_of_mem (fun z => ⟪z,x⟫_ℝ-φ z) hz) dsimp only at * linarith end variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] variable (μ : Measure E) [μ.IsAddHaarMeasure] theorem weak_MA_of_transport {V φ : E → ℝ} (hV : Continuous V) {R : ℝ≥0} (hR : 0 < R) (hc : ConvexOn ℝ univ φ) (hl : LipschitzWith R φ) (hb : ∀ x ∈ Metric.ball (0:E) R, BddAbove ((fun z => ⟪z,x⟫_ℝ-φ z) '' univ)) (hm : Measure.map (gradient φ) (μ.withDensity (fun z => ENNReal.ofReal (Real.exp (-φ z)))) = TruncatedMoment.target μ R V) : Measure.map (gradient (dualOn (Metric.ball (0:E) R) φ)) (μ.restrict (Metric.ball (0:E) R)) = μ.withDensity (fun z => ENNReal.ofReal (TruncatedMoment.partition μ R V * Real.exp (V (gradient φ z)-φ z))) := by let K := Metric.ball (0:E) (R:ℝ) let Z := TruncatedMoment.partition μ R V let w := fun x => ENNReal.ofReal (Real.exp (-V x)/Z) let σ := μ.withDensity (fun z => ENNReal.ofReal (Real.exp (-φ z))) let ν := TruncatedMoment.target μ R V have hZ : 0 < Z := TruncatedMoment.partition_pos μ hV hR have hw : Measurable w := (hV.neg.rexp.measurable.div_const Z).ennreal_ofReal have hσ : σ ≪ μ := withDensity_absolutelyContinuous _ _ have hν : ν ≪ μ := (withDensity_absolutelyContinuous _ _).trans Measure.absolutelyContinuous_restrict have hi := weak_inverse hσ hν Metric.isOpen_ball (convex_ball (0:E) R) hc hl hb (TruncatedMoment.ae_mem_ball μ V R) hm have hinv : ν.withDensity (fun x => (w x)⁻¹) = μ.restrict K := by apply withDensity_inv_same₀ hw.aemeasurable · exact Eventually.of_forall fun x => ENNReal.ofReal_ne_zero_iff.mpr (div_pos (Real.exp_pos _) hZ) · exact Eventually.of_forall fun _ => ENNReal.ofReal_ne_top rw [← hinv] have hr := reverse_weighted (gradient_measurable _) (gradient_measurable _) hm hi (show Measurable (fun x => (w x)⁻¹) from hw.inv) exact hr.trans (by change σ.withDensity (fun z => (w (gradient φ z))⁻¹) = _ dsimp only [σ] refine (withDensity_mul μ (show Measurable (fun z => ENNReal.ofReal (Real.exp (-φ z))) from hl.continuous.neg.rexp.measurable.ennreal_ofReal) (show Measurable (fun z => (w (gradient φ z))⁻¹) from hw.inv.comp (gradient_measurable φ))).symm.trans ?_ congr 1 funext z dsimp only [Pi.mul_apply,w] rw [← ENNReal.ofReal_inv_of_pos (div_pos (Real.exp_pos _) hZ), ← ENNReal.ofReal_mul (Real.exp_pos _).le] congr 1 simp only [Real.exp_neg,inv_div,div_inv_eq_mul,Real.exp_sub] ring) theorem exists_weak_truncated_MA {V : E → ℝ} (hV : Continuous V) (hVe : Function.Even V) {R : ℝ≥0} (hR : 0 < R) : ∃ φ : E → ℝ, ConvexOn ℝ univ φ ∧ Function.Even φ ∧ LipschitzWith R φ ∧ (∃ c > 0, ∃ b : ℝ, ∀ z, c*‖z‖-b ≤ φ z) ∧ IsProbabilityMeasure (μ.withDensity (fun z => ENNReal.ofReal (Real.exp (-φ z)))) ∧ (∀ x ∈ Metric.ball (0:E) R, BddAbove ((fun z => ⟪z,x⟫_ℝ-φ z) '' univ)) ∧ Measure.map (gradient φ) (μ.withDensity (fun z => ENNReal.ofReal (Real.exp (-φ z)))) = TruncatedMoment.target μ R V ∧ Measure.map (gradient (dualOn (Metric.ball (0:E) R) φ)) (μ.restrict (Metric.ball (0:E) R)) = μ.withDensity (fun z => ENNReal.ofReal (TruncatedMoment.partition μ R V * Real.exp (V (gradient φ z)-φ z))) := by let ν := TruncatedMoment.target μ R V let : IsProbabilityMeasure ν := TruncatedMoment.probability μ hV hR let : ν.IsNegInvariant := TruncatedMoment.negInvariant μ hVe R obtain ⟨d,hd,hlow⟩ := TruncatedMoment.density_lower μ hV hR obtain ⟨u,hu,hmax⟩ := exists_variational_maximizer μ hR hd hlow let f := conjugate (Metric.ball (0:E) R) u have hf : NormalizedConvex R f := admissible_conjugate_normalized hR hu have hI := admissible_partition_integrable μ hR hd hu hlow have hmp := maximizer_pushforward μ (ν:=ν) hR hu hmax (TruncatedMoment.ae_mem_ball μ V R) hI let a := Real.log (∫ y,Real.exp (-f y) ∂μ) let φ := fun z => f z+a have hconv : ConvexOn ℝ univ φ := hf.convex.add (convexOn_const a convex_univ) have heven : Function.Even φ := fun z => by dsimp only [φ]; rw [hf.even z] have hl : LipschitzWith R φ := by apply LipschitzWith.of_dist_le_mul intro z w simpa only [φ,dist_add_right] using hf.lipschitz.dist_le_mul z w have hprob : IsProbabilityMeasure (μ.withDensity (fun z => ENNReal.ofReal (Real.exp (-φ z)))) := by rw [source_shift μ hI] exact normalizedSource_probability μ hI have hb : ∀ x ∈ Metric.ball (0:E) R, BddAbove ((fun z => ⟪z,x⟫_ℝ-φ z) '' univ) := by intro x hx apply dual_add_constant_bdd _ a exact dual_conjugate_bdd (fun y hy => (by simpa [Metric.mem_ball,dist_zero_right] using hy : ‖y‖ < (R:ℝ)).le) (fun y _ => hu.nonneg y) hx have hm : Measure.map (gradient φ) (μ.withDensity (fun z => ENNReal.ofReal (Real.exp (-φ z)))) = ν := by rw [source_shift μ hI,gradient_add_constant f a] exact hmp obtain ⟨c,hc,ht⟩ := admissible_tail μ hR hd hu hlow exact ⟨φ,hconv,heven,hl,⟨c,hc,1-a,fun z => by have hh := ht z; dsimp only [φ,f]; linarith⟩, hprob,hb,hm,weak_MA_of_transport μ hV hR hconv hl hb hm⟩ end CompactMomentVariational end open scoped InnerProductSpace ContDiff Topology noncomputable section namespace CompactMomentVariational section variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] def SupportingSlope (φ : E → ℝ) (z p : E) : Prop := ∀ w, φ z+⟪p,w-z⟫_ℝ ≤ φ w omit [FiniteDimensional ℝ E] in lemma fenchel_eq_of_support {φ : E → ℝ} {z p : E} (hs : SupportingSlope φ z p) : conjugate univ φ p = ⟪z,p⟫_ℝ-φ z := by have hb : BddAbove ((fun w => ⟪w,p⟫_ℝ-φ w) '' univ) := by refine ⟨⟪z,p⟫_ℝ-φ z,?_⟩ rintro _ ⟨w,_,rfl⟩ have h := hs w rw [inner_sub_right,real_inner_comm w p,real_inner_comm z p] at h dsimp only linarith apply le_antisymm · apply conjugate_le univ_nonempty intro w _ have h := hs w rw [inner_sub_right,real_inner_comm w p,real_inner_comm z p] at h linarith · exact le_csSup hb (mem_image_of_mem _ (mem_univ z)) lemma dual_gradient_of_support {φ : E → ℝ} {z p : E} {K : Set E} (hK : IsOpen K) (hp : p ∈ K) (hs : SupportingSlope φ z p) (hb : ∀ x ∈ K, BddAbove ((fun w => ⟪w,x⟫_ℝ-φ w) '' univ)) (hd : DifferentiableAt ℝ (dualOn K φ) p) : gradient (dualOn K φ) p=z := by have he : dualOn K φ p=⟪z,p⟫_ℝ-φ z := by rw [dualOn_eq hp,fenchel_eq_of_support hs] have hm : IsLocalMin (fun y => dualOn K φ y-⟪z,y⟫_ℝ) p := by filter_upwards [hK.mem_nhds hp] with y hy have h := fenchel_dualOn hb hy z rw [he,real_inner_comm y z] at * linarith have hh := hm.hasFDerivAt_eq_zero (hd.hasFDerivAt.sub (innerSL ℝ z).hasFDerivAt) rw [gradient,sub_eq_zero.mp hh] exact (InnerProductSpace.toDual ℝ E).symm_apply_apply z omit [FiniteDimensional ℝ E] in lemma supportingSlope_of_localMin {φ : E → ℝ} (hc : ConvexOn ℝ univ φ) {z p : E} (hm : IsLocalMin (fun w => φ w-⟪p,w⟫_ℝ) z) : SupportingSlope φ z p := by have hconv : ConvexOn ℝ univ (fun w => φ w-⟪p,w⟫_ℝ) := by refine ⟨convex_univ,?_⟩ intro x hx y hy a b ha hb hab have h := hc.2 hx hy ha hb hab simp only [inner_add_right,real_inner_smul_right,smul_eq_mul] at * nlinarith have hall := IsMinOn.of_isLocalMin_of_convex_univ hm hconv intro w have h := hall w rw [inner_sub_right] linarith omit [FiniteDimensional ℝ E] in theorem subgradient_comparison {φ q : E → ℝ} (hc : ConvexOn ℝ univ φ) (hφ : Continuous φ) {C : Set E} (hC : IsCompact C) (hboundary : ∀ y ∈ frontier C, q y ≤ φ y) {x p : E} (hx : x ∈ C) (hxq : φ x < q x) (hqs : ∀ y ∈ C, q x+⟪p,y-x⟫_ℝ ≤ q y) : ∃ y ∈ interior C, φ y < q y ∧ SupportingSlope φ y p := by obtain ⟨y,hy,hmin⟩ := hC.exists_isMinOn ⟨x,hx⟩ ((hφ.sub (continuous_const.inner continuous_id)).continuousOn) have hyx : φ y-⟪p,y⟫_ℝ ≤ φ x-⟪p,x⟫_ℝ := hmin hx have hqy := hqs y hy rw [inner_sub_right] at hqy have hyq : φ y < q y := by linarith have hyint : y ∈ interior C := by by_contra he have hyfr : y ∈ frontier C := by rw [frontier_eq_closure_inter_closure,closure_compl] exact ⟨subset_closure hy,he⟩ have hb := hboundary y hyfr linarith refine ⟨y,hyint,hyq,supportingSlope_of_localMin hc ?_⟩ filter_upwards [isOpen_interior.mem_nhds hyint] with w hw exact hmin (interior_subset hw) end section variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] lemma measure_support_image_le {μ σ ν : Measure E} [μ.IsAddHaarMeasure] (hν : ν ≪ μ) {φ : E → ℝ} {K D A : Set E} (hK : IsOpen K) (hcK : Convex ℝ K) (hb : ∀ p ∈ K, BddAbove ((fun z => ⟪z,p⟫_ℝ-φ z) '' univ)) (hD : MeasurableSet D) (hs : ∀ᵐ p ∂ν, p ∈ K) (hm : Measure.map (gradient (dualOn K φ)) ν=σ) (hA : ∀ p ∈ A, p ∈ K → ∃ z ∈ D, SupportingSlope φ z p) : ν A ≤ σ D := by rw [← hm,Measure.map_apply (gradient_measurable _) hD] have hdiff : ∀ᵐ p ∂ν, p ∈ K → DifferentiableAt ℝ (dualOn K φ) p := hν.ae_le (convex_ae_differentiable hK (convexOn_dualOn hcK hb)) apply measure_mono_ae filter_upwards [hdiff,hs] with p hp hpk intro hpA obtain ⟨z,hz,hsz⟩ := hA p hpA hpk change gradient (dualOn K φ) p ∈ D rw [dual_gradient_of_support hK hpk hsz hb (hp hpk)] exact hz theorem weighted_subgradient_comparison {μ σ ν : Measure E} [μ.IsAddHaarMeasure] (hν : ν ≪ μ) {φ q : E → ℝ} {K C : Set E} (hK : IsOpen K) (hcK : Convex ℝ K) (hb : ∀ p ∈ K, BddAbove ((fun z => ⟪z,p⟫_ℝ-φ z) '' univ)) (hs : ∀ᵐ p ∂ν, p ∈ K) (hm : Measure.map (gradient (dualOn K φ)) ν=σ) (hc : ConvexOn ℝ univ φ) (hφ : Continuous φ) (hqc : ConvexOn ℝ univ q) (hqd : Differentiable ℝ q) (hC : IsCompact C) (hboundary : ∀ y ∈ frontier C, q y ≤ φ y) : ν ((gradient q) '' {x | x ∈ interior C ∧ φ x < q x}) ≤ σ {x | x ∈ interior C ∧ φ x < q x} := by apply measure_support_image_le hν hK hcK hb (isOpen_interior.inter (isOpen_lt hφ hqd.continuous)).measurableSet hs hm rintro p ⟨x,hx,rfl⟩ _ obtain ⟨y,hy,hyq,hys⟩ := subgradient_comparison hc hφ hC hboundary (interior_subset hx.1) hx.2 (fun y _ => convex_supporting_gradient hqc (hqd x) y) exact ⟨y,⟨hy,hyq⟩,hys⟩ end variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] def proximalEnergy (φ : E → ℝ) (y z : E) : ℝ := φ z+(1/2)*‖z-y‖^2 lemma proximal_exists {φ : E → ℝ} {L : ℝ≥0} (hl : LipschitzWith L φ) (y : E) : ∃ z, ∀ w, proximalEnergy φ y z ≤ proximalEnergy φ y w := by have hc : Continuous (proximalEnergy φ y) := hl.continuous.add (continuous_const.mul ((continuous_id.sub continuous_const).norm.pow 2)) apply hc.exists_forall_le have hh (z : E) : (1/4)*‖z‖^2+φ 0-((L:ℝ)+‖y‖)^2 ≤ proximalEnergy φ y z := by have h := hl.dist_le_mul z 0 rw [Real.dist_eq,dist_zero_right] at h have he : φ 0-φ z ≤ |φ z-φ 0| := by simpa only [neg_sub] using neg_le_abs (φ z-φ 0) have hi := real_inner_le_norm z y dsimp only [proximalEnergy] rw [norm_sub_sq_real] nlinarith [sq_nonneg (‖z‖/2-((L:ℝ)+‖y‖)),sq_nonneg ‖y‖] apply tendsto_atTop_mono hh have hp := (tendsto_pow_atTop (by norm_num : (2:ℕ) ≠ 0)).comp (tendsto_norm_cocompact_atTop (E:=E)) have ht := Tendsto.const_mul_atTop (by norm_num : (0:ℝ)<1/4) hp convert tendsto_atTop_add_const_right (cocompact E) (φ 0-((L:ℝ)+‖y‖)^2) ht using 1 ext x simp only [Function.comp_apply] ring def proximal {φ : E → ℝ} {L : ℝ≥0} (hl : LipschitzWith L φ) (y : E) : E := Classical.choose (proximal_exists hl y) lemma proximal_min {φ : E → ℝ} {L : ℝ≥0} (hl : LipschitzWith L φ) (y w : E) : proximalEnergy φ y (proximal hl y) ≤ proximalEnergy φ y w := Classical.choose_spec (proximal_exists hl y) w omit [FiniteDimensional ℝ E] in lemma support_of_proximal_min {φ : E → ℝ} (hc : ConvexOn ℝ univ φ) {y z : E} (hm : ∀ w, proximalEnergy φ y z ≤ proximalEnergy φ y w) : SupportingSlope φ z (y-z) := by intro w have hab (t : ℝ) (ht : 0 < t) (ht1 : t < 1) : 0 ≤ φ w-φ z+⟪z-y,w-z⟫_ℝ+t*(‖w-z‖^2/2) := by have hh := hc.2 (mem_univ z) (mem_univ w) (by linarith : 0 ≤ 1-t) ht.le (by ring : (1-t)+t=1) have hmin := hm ((1-t) • z+t • w) have he : ‖(1-t) • z+t • w-y‖^2 = ‖z-y‖^2+2*t*⟪z-y,w-z⟫_ℝ+t^2*‖w-z‖^2 := by have hv : (1-t) • z+t • w-y = (z-y)+t • (w-z) := by module rw [hv,norm_add_sq_real,norm_smul,Real.norm_eq_abs,real_inner_smul_right] rw [mul_pow,sq_abs] ring dsimp only [proximalEnergy,smul_eq_mul] at hh hmin rw [he] at hmin have hm' : 0 ≤ t*(φ w-φ z+⟪z-y,w-z⟫_ℝ+t*(‖w-z‖^2/2)) := by nlinarith exact nonneg_of_mul_nonneg_right hm' ht have ht : Tendsto (fun t : ℝ => φ w-φ z+⟪z-y,w-z⟫_ℝ+t*(‖w-z‖^2/2)) (𝓝[>] (0:ℝ)) (𝓝 (φ w-φ z+⟪z-y,w-z⟫_ℝ)) := by have hcont : Continuous (fun t : ℝ => φ w-φ z+⟪z-y,w-z⟫_ℝ+t*(‖w-z‖^2/2)) := by fun_prop simpa only [zero_mul,add_zero] using (hcont.tendsto (0:ℝ)).mono_left (nhdsWithin_le_nhds (s:=Ioi (0:ℝ))) have hn : 0 ≤ φ w-φ z+⟪z-y,w-z⟫_ℝ := ge_of_tendsto ht (by filter_upwards [self_mem_nhdsWithin, (eventually_lt_nhds (by norm_num : (0:ℝ)<1)).filter_mono nhdsWithin_le_nhds] with t ht ht1 exact hab t ht ht1) have he : y-z=-(z-y) := by module rw [he,inner_neg_left] linarith lemma proximal_support {φ : E → ℝ} (hc : ConvexOn ℝ univ φ) {L : ℝ≥0} (hl : LipschitzWith L φ) (y : E) : SupportingSlope φ (proximal hl y) (y-proximal hl y) := support_of_proximal_min hc (proximal_min hl y) omit [FiniteDimensional ℝ E] in lemma supporting_monotone {φ : E → ℝ} {z w p q : E} (hsz : SupportingSlope φ z p) (hsw : SupportingSlope φ w q) : 0 ≤ ⟪p-q,z-w⟫_ℝ := by have hz := hsz w have hw := hsw z simp only [inner_sub_left,inner_sub_right] at * linarith omit [FiniteDimensional ℝ E] in lemma proximal_firm_of_support {φ : E → ℝ} {z w y x : E} (hz : SupportingSlope φ z (y-z)) (hw : SupportingSlope φ w (x-w)) : ‖z-w‖^2 ≤ ⟪y-x,z-w⟫_ℝ := by have ht := supporting_monotone hz hw have he : (y-z)-(x-w)=(y-x)-(z-w) := by module rw [he,inner_sub_left,real_inner_self_eq_norm_sq] at ht linarith lemma proximal_firm {φ : E → ℝ} (hc : ConvexOn ℝ univ φ) {L : ℝ≥0} (hl : LipschitzWith L φ) (y x : E) : ‖proximal hl y-proximal hl x‖^2 ≤ ⟪y-x,proximal hl y-proximal hl x⟫_ℝ := proximal_firm_of_support (proximal_support hc hl y) (proximal_support hc hl x) lemma proximal_lipschitz {φ : E → ℝ} (hc : ConvexOn ℝ univ φ) {L : ℝ≥0} (hl : LipschitzWith L φ) : LipschitzWith 1 (proximal hl) := by apply LipschitzWith.of_dist_le_mul intro y x simp only [NNReal.coe_one,one_mul,dist_eq_norm] have h := (proximal_firm hc hl y x).trans (real_inner_le_norm _ _) by_cases hn : ‖proximal hl y-proximal hl x‖=0 · rw [hn]; exact norm_nonneg _ · have hp : 0 < ‖proximal hl y-proximal hl x‖ := lt_of_le_of_ne (norm_nonneg _) (Ne.symm hn) nlinarith lemma proximal_eq_of_support {φ : E → ℝ} (hc : ConvexOn ℝ univ φ) {L : ℝ≥0} (hl : LipschitzWith L φ) {y z : E} (hz : SupportingSlope φ z (y-z)) : proximal hl y=z := by have h := proximal_firm_of_support (proximal_support hc hl y) hz simp only [sub_self,inner_zero_left] at h have hn : ‖proximal hl y-z‖=0 := by nlinarith [norm_nonneg (proximal hl y-z)] exact sub_eq_zero.mp (norm_eq_zero.mp hn) lemma proximal_add_slope {φ : E → ℝ} (hc : ConvexOn ℝ univ φ) {L : ℝ≥0} (hl : LipschitzWith L φ) {z p : E} (hz : SupportingSlope φ z p) : proximal hl (z+p)=z := by apply proximal_eq_of_support hc hl simpa only [add_sub_cancel_left] using hz lemma gradient_eq_of_support {φ : E → ℝ} {x p : E} (hd : DifferentiableAt ℝ φ x) (hs : SupportingSlope φ x p) : gradient φ x=p := by have hm : IsLocalMin (fun z => φ z-⟪p,z⟫_ℝ) x := by apply Eventually.of_forall intro z have h := hs z rw [inner_sub_right] at h linarith have he := hm.hasFDerivAt_eq_zero (hd.hasFDerivAt.sub (innerSL ℝ p).hasFDerivAt) rw [gradient,sub_eq_zero.mp he] exact (InnerProductSpace.toDual ℝ E).symm_apply_apply p lemma norm_gradient_le_lipschitz {φ : E → ℝ} {L : ℝ≥0} (hl : LipschitzWith L φ) (x : E) : ‖gradient φ x‖ ≤ (L:ℝ) := by rw [gradient,(InnerProductSpace.toDual ℝ E).symm.norm_map] exact norm_fderiv_le_of_lipschitz ℝ hl lemma gradient_continuousWithin_differentiability {φ : E → ℝ} (hc : ConvexOn ℝ univ φ) {L : ℝ≥0} (hl : LipschitzWith L φ) {x : E} (hd : DifferentiableAt ℝ φ x) : ContinuousWithinAt (gradient φ) {y | DifferentiableAt ℝ φ y} x := by let D := {y | DifferentiableAt ℝ φ y} apply (isCompact_closedBall (0:E) (L:ℝ)).tendsto_nhds_of_unique_mapClusterPt · exact Eventually.of_forall fun y => by simpa only [Metric.mem_closedBall,dist_zero_right] using norm_gradient_le_lipschitz hl y · intro p _ hp let F := Filter.comap (gradient φ) (𝓝 p) ⊓ 𝓝[D] x have : F.NeBot := neBot_inf_comap_iff_map'.mpr hp have hx : Tendsto (id : E → E) F (𝓝 x) := by exact inf_le_right.trans nhdsWithin_le_nhds have hp' : Tendsto (gradient φ) F (𝓝 p) := by exact map_le_iff_le_comap.mpr inf_le_left have hs : SupportingSlope φ x p := by intro w have ht : Tendsto (fun y => φ y+⟪gradient φ y,w-y⟫_ℝ) F (𝓝 (φ x+⟪p,w-x⟫_ℝ)) := (hl.continuous.tendsto x |>.comp hx).add (hp'.inner (tendsto_const_nhds.sub hx)) apply le_of_tendsto ht filter_upwards [show ∀ᶠ y in F, y ∈ D from (show ∀ᶠ y in 𝓝[D] x, y ∈ D from self_mem_nhdsWithin).filter_mono inf_le_right] with y hy exact convex_supporting_gradient hc hy w exact (gradient_eq_of_support hd hs).symm end CompactMomentVariational end open scoped ENNReal noncomputable section namespace ConvexRegularity variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] variable (μ : Measure E) [μ.IsAddHaarMeasure] lemma lipschitz_image_null {L : ℝ≥0} {f : E → E} (hl : LipschitzWith L f) {s : Set E} (hs : μ s=0) : μ (f '' s)=0 := by have ha : μ ≪ μH[Module.finrank ℝ E] := Measure.absolutelyContinuous_isAddHaarMeasure _ _ have hb : μH[Module.finrank ℝ E] ≪ μ := Measure.absolutelyContinuous_isAddHaarMeasure _ _ apply ha apply le_antisymm _ (zero_le) simpa only [hb hs,mul_zero] using hl.hausdorffMeasure_image_le (d:=(Module.finrank ℝ E : ℝ)) (by positivity) s lemma ae_regular_preimage {L : ℝ≥0} {f : E → E} (hl : LipschitzWith L f) : ∀ᵐ x ∂μ, ∀ y, f y=x → DifferentiableAt ℝ f y ∧ (fderiv ℝ f y).det ≠ 0 := by let A := {y | ¬ DifferentiableAt ℝ f y} let B := {y | DifferentiableAt ℝ f y ∧ (fderiv ℝ f y).det=0} have hA : μ (f '' A)=0 := lipschitz_image_null μ hl (ae_iff.mp (hl.ae_differentiableAt (μ:=μ))) have hB : μ (f '' B)=0 := addHaar_image_eq_zero_of_det_fderivWithin_eq_zero μ (fun y hy => hy.1.hasFDerivAt.hasFDerivWithinAt) (fun _ hy => hy.2) have ha : ∀ᵐ x ∂μ, x ∉ f '' A := by simpa only [ae_iff,not_not,Set.ofPred_mem_eq] using hA have hb : ∀ᵐ x ∂μ, x ∉ f '' B := by simpa only [ae_iff,not_not,Set.ofPred_mem_eq] using hB filter_upwards [ha,hb] with x hxA hxB intro y hy have hd : DifferentiableAt ℝ f y := by by_contra he exact hxA ⟨y,he,hy⟩ refine ⟨hd,?_⟩ intro he exact hxB ⟨y,⟨hd,he⟩,hy⟩ end ConvexRegularity namespace CompactMomentVariational section variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] variable (μ : Measure E) [μ.IsAddHaarMeasure] theorem ae_gradient_differentiableWithin {φ : E → ℝ} (hc : ConvexOn ℝ univ φ) {L : ℝ≥0} (hl : LipschitzWith L φ) : ∀ᵐ x ∂μ, DifferentiableAt ℝ φ x ∧ DifferentiableWithinAt ℝ (gradient φ) {y | DifferentiableAt ℝ φ y} x := by have hr := ConvexRegularity.ae_regular_preimage μ (proximal_lipschitz hc hl) filter_upwards [hr,hl.ae_differentiableAt (μ:=μ)] with x hx hd refine ⟨hd,?_⟩ let D := {y | DifferentiableAt ℝ φ y} let T := fun y : E => y+gradient φ y have hleft {y : E} (hy : y ∈ D) : proximal hl (T y)=y := proximal_add_slope hc hl (convex_supporting_gradient hc hy) obtain ⟨hp,hdet⟩ := hx (T x) (hleft hd) let e : E ≃L[ℝ] E := ((fderiv ℝ (proximal hl) (T x)).toLinearMap.equivOfDetNeZero hdet).toContinuousLinearEquiv have he : (e : E →L[ℝ] E)=fderiv ℝ (proximal hl) (T x) := rfl have ht : ContinuousWithinAt T D x := continuousWithinAt_id.add (gradient_continuousWithin_differentiability hc hl hd) have hprox : HasFDerivWithinAt (proximal hl) (e : E →L[ℝ] E) univ (T x) := by rw [he] exact hp.hasFDerivAt.hasFDerivWithinAt have hi : HasFDerivWithinAt T (e.symm : E →L[ℝ] E) D x := hprox.of_local_left_inverse (by simpa only [nhdsWithin_univ] using ht.tendsto) hd (by filter_upwards [self_mem_nhdsWithin] with y hy; exact hleft hy) have hg := hi.sub (hasFDerivWithinAt_id x D) have hh : T-id=gradient φ := by funext y exact add_sub_cancel_left y (gradient φ y) rw [hh] at hg exact hg.differentiableWithinAt end variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] omit [FiniteDimensional ℝ E] in lemma supportingSlope_limit {φ : E → ℝ} (hc : Continuous φ) {F : Filter E} [F.NeBot] {x p : E} {P : E → E} (hx : Tendsto (id : E → E) F (𝓝 x)) (hp : Tendsto P F (𝓝 p)) (hs : ∀ᶠ y in F, SupportingSlope φ y (P y)) : SupportingSlope φ x p := by intro w have ht : Tendsto (fun y => φ y+⟪P y,w-y⟫_ℝ) F (𝓝 (φ x+⟪p,w-x⟫_ℝ)) := ((hc.tendsto x).comp hx).add (hp.inner (tendsto_const_nhds.sub hx)) exact le_of_tendsto ht (hs.mono (fun _ h => h w)) variable [MeasurableSpace E] [BorelSpace E] variable (μ : Measure E) [μ.IsAddHaarMeasure] include μ in lemma exists_supportingSlope {φ : E → ℝ} (hc : ConvexOn ℝ univ φ) {L : ℝ≥0} (hl : LipschitzWith L φ) (x : E) : ∃ p, ‖p‖ ≤ (L:ℝ) ∧ SupportingSlope φ x p := by let D := {y | DifferentiableAt ℝ φ y} have hd : Dense D := Measure.dense_of_ae (hl.ae_differentiableAt (μ:=μ)) have : (𝓝[D] x).NeBot := mem_closure_iff_nhdsWithin_neBot.mp (hd x) obtain ⟨p,hp,hcluster⟩ := (isCompact_closedBall (0:E) (L:ℝ)).exists_mapClusterPt (f:=𝓝[D] x) (u:=gradient φ) (Filter.tendsto_principal.mpr (Eventually.of_forall (fun y => by simpa only [Metric.mem_closedBall,dist_zero_right] using norm_gradient_le_lipschitz hl y))) refine ⟨p,by simpa only [Metric.mem_closedBall,dist_zero_right] using hp,?_⟩ let F := Filter.comap (gradient φ) (𝓝 p) ⊓ 𝓝[D] x have : F.NeBot := neBot_inf_comap_iff_map'.mpr hcluster apply supportingSlope_limit hl.continuous (show Tendsto (id : E → E) F (𝓝 x) from inf_le_right.trans nhdsWithin_le_nhds) (show Tendsto (gradient φ) F (𝓝 p) from map_le_iff_le_comap.mpr inf_le_left) filter_upwards [(show ∀ᶠ y in 𝓝[D] x, y ∈ D from self_mem_nhdsWithin).filter_mono (show F ≤ 𝓝[D] x from inf_le_right)] with y hy exact convex_supporting_gradient hc hy def chosenSlope {φ : E → ℝ} (hc : ConvexOn ℝ univ φ) {L : ℝ≥0} (hl : LipschitzWith L φ) (x : E) : E := Classical.choose (exists_supportingSlope μ hc hl x) lemma norm_chosenSlope_le {φ : E → ℝ} (hc : ConvexOn ℝ univ φ) {L : ℝ≥0} (hl : LipschitzWith L φ) (x : E) : ‖chosenSlope μ hc hl x‖ ≤ (L:ℝ) := (Classical.choose_spec (exists_supportingSlope μ hc hl x)).1 lemma chosenSlope_support {φ : E → ℝ} (hc : ConvexOn ℝ univ φ) {L : ℝ≥0} (hl : LipschitzWith L φ) (x : E) : SupportingSlope φ x (chosenSlope μ hc hl x) := (Classical.choose_spec (exists_supportingSlope μ hc hl x)).2 lemma chosenSlope_eq_gradient {φ : E → ℝ} (hc : ConvexOn ℝ univ φ) {L : ℝ≥0} (hl : LipschitzWith L φ) {x : E} (hd : DifferentiableAt ℝ φ x) : chosenSlope μ hc hl x=gradient φ x := (gradient_eq_of_support hd (chosenSlope_support μ hc hl x)).symm lemma chosenSlope_continuousAt {φ : E → ℝ} (hc : ConvexOn ℝ univ φ) {L : ℝ≥0} (hl : LipschitzWith L φ) {x : E} (hd : DifferentiableAt ℝ φ x) : ContinuousAt (chosenSlope μ hc hl) x := by apply (isCompact_closedBall (0:E) (L:ℝ)).tendsto_nhds_of_unique_mapClusterPt · exact Eventually.of_forall fun y => by simpa only [Metric.mem_closedBall,dist_zero_right] using norm_chosenSlope_le μ hc hl y · intro p _ hp let P := chosenSlope μ hc hl let F := Filter.comap P (𝓝 p) ⊓ 𝓝 x have : F.NeBot := neBot_inf_comap_iff_map'.mpr hp have hs : SupportingSlope φ x p := supportingSlope_limit hl.continuous (show Tendsto (id : E → E) F (𝓝 x) from inf_le_right) (show Tendsto P F (𝓝 p) from map_le_iff_le_comap.mpr inf_le_left) (Eventually.of_forall (chosenSlope_support μ hc hl)) exact (gradient_eq_of_support hd hs).symm.trans (chosenSlope_eq_gradient μ hc hl hd).symm theorem ae_chosenSlope_differentiable {φ : E → ℝ} (hc : ConvexOn ℝ univ φ) {L : ℝ≥0} (hl : LipschitzWith L φ) : ∀ᵐ x ∂μ, DifferentiableAt ℝ φ x ∧ DifferentiableAt ℝ (chosenSlope μ hc hl) x := by have hr := ConvexRegularity.ae_regular_preimage μ (proximal_lipschitz hc hl) filter_upwards [hr,hl.ae_differentiableAt (μ:=μ)] with x hx hd refine ⟨hd,?_⟩ let P := chosenSlope μ hc hl let T := fun y : E => y+P y have hleft (y : E) : proximal hl (T y)=y := proximal_add_slope hc hl (chosenSlope_support μ hc hl y) obtain ⟨hp,hdet⟩ := hx (T x) (hleft x) let e : E ≃L[ℝ] E := ((fderiv ℝ (proximal hl) (T x)).toLinearMap.equivOfDetNeZero hdet).toContinuousLinearEquiv have he : (e : E →L[ℝ] E)=fderiv ℝ (proximal hl) (T x) := rfl have ht : ContinuousAt T x := continuousAt_id.add (chosenSlope_continuousAt μ hc hl hd) have hprox : HasFDerivAt (proximal hl) (e : E →L[ℝ] E) (T x) := by rw [he]; exact hp.hasFDerivAt have hi : HasFDerivAt T (e.symm : E →L[ℝ] E) x := hprox.of_local_left_inverse ht (Eventually.of_forall hleft) have hg := hi.sub (hasFDerivAt_id x) have hh : T-id=P := by funext y; exact add_sub_cancel_left y (P y) rw [hh] at hg exact hg.differentiableAt lemma ae_gradient_hasFDerivWithin {φ : E → ℝ} (hc : ConvexOn ℝ univ φ) {L : ℝ≥0} (hl : LipschitzWith L φ) : ∀ᵐ x ∂μ, DifferentiableAt ℝ φ x ∧ HasFDerivWithinAt (gradient φ) (fderiv ℝ (chosenSlope μ hc hl) x) {y | DifferentiableAt ℝ φ y} x := by filter_upwards [ae_chosenSlope_differentiable μ hc hl] with x hx exact ⟨hx.1,hx.2.hasFDerivAt.hasFDerivWithinAt.congr' (fun _ hy => (chosenSlope_eq_gradient μ hc hl hy).symm) hx.1⟩ end CompactMomentVariational end open Set MeasureTheory Filter open scoped ENNReal Topology noncomputable section namespace MomentJacobian variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] (μ : Measure E) [μ.IsAddHaarMeasure] theorem jacobian_of_ae_inverse_within {σ ν : Measure E} {K D : Set E} (_hK : MeasurableSet K) {g f : E → E} {g' : E → E →L[ℝ] E} (hgm : Measurable g) (hf : Measurable f) (hg : ∀ᵐ z ∂μ, z ∈ D ∧ HasFDerivWithinAt g (g' z) D z) (hm : Measure.map g σ = ν) (hμσ : μ ≪ σ) (hσμ : σ ≪ μ) (hKν : μ.restrict K ≪ ν) (hi : ∀ᵐ z ∂σ, f (g z)=z) (hk : ∀ᵐ z ∂σ, g z ∈ K) : μ.withDensity (fun z => ENNReal.ofReal |(g' z).det|) = Measure.map f (μ.restrict K) := by let s := {z | z ∈ D ∧ HasFDerivWithinAt g (g' z) D z ∧ f (g z)=z ∧ g z ∈ K} have hfull : ∀ᵐ z ∂μ, z ∈ s := by filter_upwards [hg,hμσ.ae_le hi,hμσ.ae_le hk] with z hz hi hk exact ⟨hz.1,hz.2,hi,hk⟩ have hsn : NullMeasurableSet s μ := by apply NullMeasurableSet.of_compl exact NullMeasurableSet.of_null (ae_iff.mp hfull) obtain ⟨t,hts,ht,heq⟩ := hsn.exists_measurable_subset_ae_eq have htfull : ∀ᵐ z ∂μ, z ∈ t := by filter_upwards [hfull,heq] with z hz he exact he.mpr hz have hsinj : InjOn g t := by intro z hz w hw he exact (hts hz).2.2.1.symm.trans ((congrArg f he).trans (hts hw).2.2.1) have hder (z) (hz : z ∈ t) : HasFDerivWithinAt g (g' z) t z := ((hts hz).2.1).mono (fun w hw => (hts hw).1) have him : MeasurableSet (g '' t) := measurable_image_of_fderivWithin ht hder hsinj have htfullσ : ∀ᵐ z ∂σ, z ∈ t := hσμ.ae_le htfull have himfullν : ∀ᵐ x ∂ν, x ∈ g '' t := by rw [← hm] exact (ae_map_iff hgm.aemeasurable him).mpr (htfullσ.mono (fun z hz => mem_image_of_mem g hz)) have himless : g '' t ⊆ K := by rintro _ ⟨z,hz,rfl⟩ exact (hts hz).2.2.2 have himrestrict : μ.restrict (g '' t)=μ.restrict K := by rw [← Measure.restrict_eq_self_of_ae_mem (hKν.ae_le himfullν), Measure.restrict_restrict him,inter_eq_left.mpr himless] have hj := map_withDensity_abs_det_fderiv_eq_addHaar μ ht.nullMeasurableSet hder hsinj rw [Measure.restrict_eq_self_of_ae_mem htfull,himrestrict] at hj rw [← hj,Measure.map_map hf hgm] have hie : ∀ᵐ z ∂μ.withDensity (fun z => ENNReal.ofReal |(g' z).det|), f (g z)=z := (withDensity_absolutelyContinuous _ _).ae_le (hμσ.ae_le hi) exact ((Measure.map_congr hie).trans Measure.map_id).symm end MomentJacobian namespace CompactMomentVariational section variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] variable (μ : Measure E) [μ.IsAddHaarMeasure] theorem ae_abs_det_of_weak_truncated {V φ : E → ℝ} (hV : Continuous V) {R : ℝ≥0} (hR : 0 < R) (hc : ConvexOn ℝ univ φ) (hl : LipschitzWith R φ) (hb : ∀ x ∈ Metric.ball (0:E) R, BddAbove ((fun z => ⟪z,x⟫_ℝ-φ z) '' univ)) (hm : Measure.map (gradient φ) (μ.withDensity (fun z => ENNReal.ofReal (Real.exp (-φ z)))) = TruncatedMoment.target μ R V) : ∀ᵐ z ∂μ, |(fderiv ℝ (chosenSlope μ hc hl) z).det| = TruncatedMoment.partition μ R V * Real.exp (V (gradient φ z)-φ z) := by let σ := μ.withDensity (fun z => ENNReal.ofReal (Real.exp (-φ z))) let ν := TruncatedMoment.target μ R V let K := Metric.ball (0:E) (R:ℝ) let Z := TruncatedMoment.partition μ R V have hZ : 0 < Z := TruncatedMoment.partition_pos μ hV hR have hμσ : μ ≪ σ := withDensity_absolutelyContinuous' hl.continuous.neg.rexp.measurable.ennreal_ofReal.aemeasurable (Eventually.of_forall (fun _ => ENNReal.ofReal_ne_zero_iff.mpr (Real.exp_pos _))) have hσμ : σ ≪ μ := withDensity_absolutelyContinuous _ _ have hνμ : ν ≪ μ := (withDensity_absolutelyContinuous _ _).trans Measure.absolutelyContinuous_restrict have hKν : μ.restrict K ≪ ν := withDensity_absolutelyContinuous' (hV.neg.rexp.measurable.div_const Z).ennreal_ofReal.aemeasurable (Eventually.of_forall (fun _ => ENNReal.ofReal_ne_zero_iff.mpr (div_pos (Real.exp_pos _) hZ))) have hinv := weak_inverse hσμ hνμ Metric.isOpen_ball (convex_ball (0:E) R) hc hl hb (TruncatedMoment.ae_mem_ball μ V R) hm have hs : ∀ᵐ z ∂σ, gradient φ z ∈ K := by have ht := TruncatedMoment.ae_mem_ball μ V R rw [← hm] at ht exact ae_of_ae_map (gradient_measurable _).aemeasurable ht have hdet := MomentJacobian.jacobian_of_ae_inverse_within μ Metric.isOpen_ball.measurableSet (gradient_measurable _) (gradient_measurable _) (ae_gradient_hasFDerivWithin μ hc hl) hm hμσ hσμ hKν hinv hs have he := hdet.trans (weak_MA_of_transport μ hV hR hc hl hb hm) have hJm : Measurable (fun z => |(fderiv ℝ (chosenSlope μ hc hl) z).det|) := (ContinuousLinearMap.continuous_det.measurable.comp (measurable_fderiv ℝ _)).abs have hWm : Measurable (fun z => Z * Real.exp (V (gradient φ z)-φ z)) := measurable_const.mul ((hV.measurable.comp (gradient_measurable _)).sub hl.continuous.measurable).exp have hae := (withDensity_eq_iff_of_sigmaFinite hJm.ennreal_ofReal.aemeasurable hWm.ennreal_ofReal.aemeasurable).mp he filter_upwards [hae] with z hz exact (ENNReal.ofReal_eq_ofReal_iff (abs_nonneg _) (mul_pos hZ (Real.exp_pos _)).le).mp hz end section variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] def proximalConjugate {φ : E → ℝ} {L : ℝ≥0} (hl : LipschitzWith L φ) (y : E) : ℝ := ⟪proximal hl y,y⟫_ℝ-φ (proximal hl y)-(1/2)*‖proximal hl y‖^2 lemma proximalConjugate_support {φ : E → ℝ} {L : ℝ≥0} (hl : LipschitzWith L φ) (y : E) : SupportingSlope (proximalConjugate hl) y (proximal hl y) := by intro w have hh := proximal_min hl w (proximal hl y) dsimp only [proximalEnergy] at hh rw [norm_sub_sq_real,norm_sub_sq_real] at hh dsimp only [proximalConjugate] rw [inner_sub_right] linarith lemma proximalConjugate_remainder {φ : E → ℝ} (hc : ConvexOn ℝ univ φ) {L : ℝ≥0} (hl : LipschitzWith L φ) (y w : E) : |proximalConjugate hl w-proximalConjugate hl y-⟪proximal hl y,w-y⟫_ℝ| ≤ ‖w-y‖^2 := by have hlow := proximalConjugate_support hl y w have hupp := proximalConjugate_support hl w y have hi := real_inner_le_norm (proximal hl w-proximal hl y) (w-y) have hp := (proximal_lipschitz hc hl).dist_le_mul w y simp only [NNReal.coe_one,one_mul,dist_eq_norm] at hp rw [abs_of_nonneg (by linarith)] have hbound := mul_le_mul_of_nonneg_right hp (norm_nonneg (w-y)) simp only [inner_sub_left,inner_sub_right] at hupp hi ⊢ nlinarith lemma proximalConjugate_hasFDerivAt {φ : E → ℝ} (hc : ConvexOn ℝ univ φ) {L : ℝ≥0} (hl : LipschitzWith L φ) (y : E) : HasFDerivAt (proximalConjugate hl) (innerSL ℝ (proximal hl y)) y := by rw [hasFDerivAt_iff_isLittleO] apply (Asymptotics.isBigO_of_le (𝓝 y) (fun w => ?_)).trans_isLittleO (Asymptotics.isLittleO_pow_sub_sub y (by norm_num : 1 < (2:ℕ))) simpa only [Real.norm_eq_abs,abs_of_nonneg (sq_nonneg ‖w-y‖),innerSL_apply_apply] using proximalConjugate_remainder hc hl y w lemma proximal_derivative_symmetric {φ : E → ℝ} (hc : ConvexOn ℝ univ φ) {L : ℝ≥0} (hl : LipschitzWith L φ) {y : E} {H : E →L[ℝ] E} (hH : HasFDerivAt (proximal hl) H y) (v w : E) : ⟪H v,w⟫_ℝ=⟪v,H w⟫_ℝ := by have hd := (InnerProductSpace.toDual ℝ E).toContinuousLinearEquiv.hasFDerivAt.comp y hH have hh := second_derivative_symmetric (proximalConjugate_hasFDerivAt hc hl) hd v w change ⟪H v,w⟫_ℝ=⟪H w,v⟫_ℝ at hh exact hh.trans (real_inner_comm _ _) omit [FiniteDimensional ℝ E] in lemma supporting_selection_monotone_line {φ : E → ℝ} {P : E → E} (hs : ∀ x, SupportingSlope φ x (P x)) (x v : E) : Monotone (fun t : ℝ => ⟪P (x+t • v),v⟫_ℝ) := by intro a b hab rcases hab.eq_or_lt with rfl | hab · exact le_rfl have hm := supporting_monotone (hs (x+b • v)) (hs (x+a • v)) have he : (x+b • v)-(x+a • v)=(b-a) • v := by module rw [he,real_inner_smul_right] at hm have hi := nonneg_of_mul_nonneg_right hm (sub_pos.mpr hab) simpa only [inner_sub_left,sub_nonneg] using hi omit [FiniteDimensional ℝ E] in lemma supporting_derivative_nonneg {φ : E → ℝ} {P : E → E} (hs : ∀ x, SupportingSlope φ x (P x)) {x : E} {H : E →L[ℝ] E} (hH : HasFDerivAt P H x) (v : E) : 0 ≤ ⟪H v,v⟫_ℝ := by have hline : HasDerivAt (fun t : ℝ => x+t • v) v 0 := by simpa only [one_smul,id_eq] using ((hasDerivAt_id (0:ℝ)).smul_const v).const_add x have hP : HasDerivAt (fun t : ℝ => P (x+t • v)) (H v) 0 := by have hh : HasFDerivAt P H (x+(0:ℝ) • v) := by simpa only [zero_smul,add_zero] using hH exact hh.comp_hasDerivAt (0:ℝ) hline have hh := hP.inner ℝ (hasDerivAt_const (0:ℝ) v) simp only [inner_zero_right,zero_add] at hh have hm := (supporting_selection_monotone_line hs x v).deriv_nonneg (x:=0) rwa [hh.deriv] at hm end section variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] variable (μ : Measure E) [μ.IsAddHaarMeasure] theorem ae_chosenSlope_positive {φ : E → ℝ} (hc : ConvexOn ℝ univ φ) {L : ℝ≥0} (hl : LipschitzWith L φ) : ∀ᵐ x ∂μ, (fderiv ℝ (chosenSlope μ hc hl) x).toLinearMap.IsPositive := by have hr := ConvexRegularity.ae_regular_preimage μ (proximal_lipschitz hc hl) filter_upwards [hr,hl.ae_differentiableAt (μ:=μ)] with x hx hd let P := chosenSlope μ hc hl let T := fun y : E => y+P y have hleft (y : E) : proximal hl (T y)=y := proximal_add_slope hc hl (chosenSlope_support μ hc hl y) obtain ⟨hp,hdet⟩ := hx (T x) (hleft x) let e : E ≃L[ℝ] E := ((fderiv ℝ (proximal hl) (T x)).toLinearMap.equivOfDetNeZero hdet).toContinuousLinearEquiv have he : (e : E →L[ℝ] E)=fderiv ℝ (proximal hl) (T x) := rfl have ht : ContinuousAt T x := continuousAt_id.add (chosenSlope_continuousAt μ hc hl hd) have hprox : HasFDerivAt (proximal hl) (e : E →L[ℝ] E) (T x) := by rw [he]; exact hp.hasFDerivAt have hi : HasFDerivAt T (e.symm : E →L[ℝ] E) x := hprox.of_local_left_inverse ht (Eventually.of_forall hleft) have hg := hi.sub (hasFDerivAt_id x) have hh : T-id=P := by funext y; exact add_sub_cancel_left y (P y) rw [hh] at hg have hsymm (v w : E) : ⟪e v,w⟫_ℝ=⟪v,e w⟫_ℝ := proximal_derivative_symmetric hc hl hprox v w have hsi (v w : E) : ⟪e.symm v,w⟫_ℝ=⟪v,e.symm w⟫_ℝ := by have h := hsymm (e.symm v) (e.symm w) simpa only [e.apply_symm_apply] using h.symm rw [hg.fderiv] refine ⟨?_,?_⟩ · intro v w change ⟪e.symm v-v,w⟫_ℝ=⟪v,e.symm w-w⟫_ℝ rw [inner_sub_left,inner_sub_right,hsi] · intro v change 0 ≤ ⟪((e.symm : E →L[ℝ] E)-ContinuousLinearMap.id ℝ E) v,v⟫_ℝ exact supporting_derivative_nonneg (chosenSlope_support μ hc hl) hg v end section variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] variable (μ : Measure E) [μ.IsAddHaarMeasure] variable {ι : Type*} [Fintype ι] [DecidableEq ι] def weakHessian (b : OrthonormalBasis ι ℝ E) {φ : E → ℝ} (hc : ConvexOn ℝ univ φ) {L : ℝ≥0} (hl : LipschitzWith L φ) (z : E) : Matrix ι ι ℝ := LinearMap.toMatrix b.toBasis b.toBasis (fderiv ℝ (chosenSlope μ hc hl) z).toLinearMap lemma det_weakHessian (b : OrthonormalBasis ι ℝ E) {φ : E → ℝ} (hc : ConvexOn ℝ univ φ) {L : ℝ≥0} (hl : LipschitzWith L φ) (z : E) : (weakHessian μ b hc hl z).det = (fderiv ℝ (chosenSlope μ hc hl) z).det := LinearMap.det_toMatrix b.toBasis _ theorem ae_positive_MA (b : OrthonormalBasis ι ℝ E) {V φ : E → ℝ} (hV : Continuous V) {R : ℝ≥0} (hR : 0 < R) (hc : ConvexOn ℝ univ φ) (hl : LipschitzWith R φ) (hb : ∀ x ∈ Metric.ball (0:E) R, BddAbove ((fun z => ⟪z,x⟫_ℝ-φ z) '' univ)) (hm : Measure.map (gradient φ) (μ.withDensity (fun z => ENNReal.ofReal (Real.exp (-φ z)))) = TruncatedMoment.target μ R V) : ∀ᵐ z ∂μ, DifferentiableAt ℝ φ z ∧ DifferentiableAt ℝ (chosenSlope μ hc hl) z ∧ (weakHessian μ b hc hl z).PosDef ∧ Real.log (weakHessian μ b hc hl z).det = V (chosenSlope μ hc hl z)+Real.log (TruncatedMoment.partition μ R V)-φ z ∧ chosenSlope μ hc hl z ∈ Metric.ball (0:E) R := by have hZ : 0 < TruncatedMoment.partition μ (R:ℝ) V := TruncatedMoment.partition_pos μ hV hR have hμσ := withDensity_absolutelyContinuous' (μ := μ) hl.continuous.neg.rexp.measurable.ennreal_ofReal.aemeasurable (Eventually.of_forall (fun _ : E => ENNReal.ofReal_ne_zero_iff.mpr (Real.exp_pos _))) have ht := TruncatedMoment.ae_mem_ball μ V R rw [← hm] at ht have hmem := hμσ.ae_le (ae_of_ae_map (gradient_measurable _).aemeasurable ht) filter_upwards [ae_chosenSlope_differentiable μ hc hl,ae_chosenSlope_positive μ hc hl, ae_abs_det_of_weak_truncated μ hV hR hc hl hb hm,hmem] with z hz hp hj hball have hps : (weakHessian μ b hc hl z).PosSemidef := (LinearMap.posSemidef_toMatrix_iff b).mpr hp rw [← det_weakHessian μ b hc hl z,abs_of_nonneg hps.det_nonneg] at hj have hd : (weakHessian μ b hc hl z).PosDef := hps.posDef_iff_det_ne_zero.mpr (by rw [hj]; exact (mul_pos hZ (Real.exp_pos _)).ne') refine ⟨hz.1,hz.2,hd,?_,?_⟩ · rw [chosenSlope_eq_gradient μ hc hl hz.1] calc Real.log (weakHessian μ b hc hl z).det = Real.log (TruncatedMoment.partition μ (R:ℝ) V * Real.exp (V (gradient φ z)-φ z)) := congrArg Real.log hj _ = Real.log (TruncatedMoment.partition μ (R:ℝ) V)+Real.log (Real.exp (V (gradient φ z)-φ z)) := Real.log_mul hZ.ne' (Real.exp_ne_zero _) _ = _ := by rw [Real.log_exp]; ring · rwa [chosenSlope_eq_gradient μ hc hl hz.1] end section variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] lemma supporting_selection_injective_at {q : E → ℝ} {P : E → E} (hs : ∀ x, SupportingSlope q x (P x)) {x y : E} {H : E →L[ℝ] E} (hH : HasFDerivAt P H x) (hpos : ∀ v ≠ 0, 0 < ⟪H v,v⟫_ℝ) (he : P x=P y) : x=y := by by_contra hne let v := y-x have hv : v ≠ 0 := sub_ne_zero.mpr (Ne.symm hne) let g := fun t : ℝ => ⟪P (x+t • v),v⟫_ℝ have hg : Monotone g := supporting_selection_monotone_line hs x v have h01 : g 0=g 1 := by have hxy : x+(y-x)=y := by abel simp only [g,zero_smul,add_zero,one_smul,v,hxy,he] have hconst : ∀ t ∈ Icc (0:ℝ) 1, g t=g 0 := by intro t ht apply le_antisymm · exact (hg ht.2).trans_eq h01.symm · exact hg ht.1 have hline : HasDerivAt (fun t : ℝ => x+t • v) v 0 := by simpa only [one_smul,id_eq] using ((hasDerivAt_id (0:ℝ)).smul_const v).const_add x have hP : HasDerivAt (fun t : ℝ => P (x+t • v)) (H v) 0 := by have hh : HasFDerivAt P H (x+(0:ℝ) • v) := by simpa only [zero_smul,add_zero] using hH exact hh.comp_hasDerivAt (0:ℝ) hline have hd : HasDerivAt g ⟪H v,v⟫_ℝ 0 := by simpa only [inner_zero_right,zero_add] using hP.inner ℝ (hasDerivAt_const (0:ℝ) v) have hc : HasDerivWithinAt g 0 (Icc (0:ℝ) 1) 0 := by apply (hasDerivWithinAt_const (0:ℝ) (Icc (0:ℝ) 1) (g 0)).congr · exact hconst · rfl have hzero := UniqueDiffWithinAt.eq_deriv (Icc (0:ℝ) 1) (uniqueDiffOn_Icc_zero_one 0 (by simp)) hd.hasDerivWithinAt hc exact (hpos v hv).ne' hzero end section variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] variable (μ : Measure E) [μ.IsAddHaarMeasure] theorem ae_weighted_jacobian_comparison {σ : Measure E} {w : E → ℝ≥0∞} {φ q : E → ℝ} {P : E → E} {K C : Set E} (hK : IsOpen K) (hcK : Convex ℝ K) (hb : ∀ p ∈ K, BddAbove ((fun z => ⟪z,p⟫_ℝ-φ z) '' univ)) (hm : Measure.map (gradient (dualOn K φ)) ((μ.restrict K).withDensity w)=σ) (hc : ConvexOn ℝ univ φ) (hφ : Continuous φ) (hq : Continuous q) (hP : ∀ x, SupportingSlope q x (P x)) (hC : IsCompact C) (hboundary : ∀ y ∈ frontier C, q y ≤ φ y) (hreg : ∀ᵐ x ∂μ, DifferentiableAt ℝ q x ∧ DifferentiableAt ℝ P x ∧ (∀ v ≠ 0, 0 < ⟪(fderiv ℝ P x) v,v⟫_ℝ) ∧ P x ∈ K) : (∫⁻ x in {x | x ∈ interior C ∧ φ x < q x}, ENNReal.ofReal |(fderiv ℝ P x).det| * w (gradient q x) ∂μ) ≤ σ {x | x ∈ interior C ∧ φ x < q x} := by let D := {x | x ∈ interior C ∧ φ x < q x} have hD : MeasurableSet D := (isOpen_interior.inter (isOpen_lt hφ hq)).measurableSet let A := {x | DifferentiableAt ℝ q x ∧ DifferentiableAt ℝ P x ∧ (∀ v ≠ 0, 0 < ⟪(fderiv ℝ P x) v,v⟫_ℝ) ∧ P x ∈ K} have hAn : NullMeasurableSet A μ := NullMeasurableSet.of_compl (NullMeasurableSet.of_null (ae_iff.mp hreg)) obtain ⟨T,hTA,hT,hTeq⟩ := hAn.exists_measurable_subset_ae_eq have hTfull : ∀ᵐ x ∂μ, x ∈ T := by filter_upwards [hreg,hTeq] with x hx he exact he.mpr hx let S := T ∩ D have hS : MeasurableSet S := hT.inter hD have hSeq : S =ᵐ[μ] D := by filter_upwards [hTfull] with x hx exact propext (and_iff_right hx) have hder (x) (hx : x ∈ S) : HasFDerivWithinAt (gradient q) (fderiv ℝ P x) S x := by apply (hTA hx.1).2.1.hasFDerivAt.hasFDerivWithinAt.congr' · intro y hy exact gradient_eq_of_support (hTA hy.1).1 (hP y) · exact hx have hinj : InjOn (gradient q) S := by intro x hx y hy he apply supporting_selection_injective_at hP (hTA hx.1).2.1.hasFDerivAt (hTA hx.1).2.2.1 rwa [gradient_eq_of_support (hTA hx.1).1 (hP x), gradient_eq_of_support (hTA hy.1).1 (hP y)] at he have hA : MeasurableSet ((gradient q) '' S) := measurable_image_of_fderivWithin hS hder hinj have him : (gradient q) '' S ⊆ K := by rintro _ ⟨x,hx,rfl⟩ rw [gradient_eq_of_support (hTA hx.1).1 (hP x)] exact (hTA hx.1).2.2.2 have hνμ : ((μ.restrict K).withDensity w) ≪ μ := (withDensity_absolutelyContinuous _ _).trans Measure.absolutelyContinuous_restrict have hs : ∀ᵐ p ∂(μ.restrict K).withDensity w, p ∈ K := (withDensity_absolutelyContinuous _ _).ae_le (ae_restrict_mem hK.measurableSet) have ht : ((μ.restrict K).withDensity w) ((gradient q) '' S) ≤ σ D := by apply measure_support_image_le hνμ hK hcK hb hD hs hm rintro p ⟨x,hx,rfl⟩ _ have hps : SupportingSlope q x (gradient q x) := by rw [gradient_eq_of_support (hTA hx.1).1 (hP x)] exact hP x obtain ⟨y,hy,hyq,hys⟩ := subgradient_comparison hc hφ hC hboundary (interior_subset hx.2.1) hx.2.2 (fun y _ => hps y) exact ⟨y,⟨hy,hyq⟩,hys⟩ rw [withDensity_apply w hA,Measure.restrict_restrict hA,inter_eq_left.mpr him, lintegral_image_eq_lintegral_abs_det_fderiv_mul μ hS hder hinj w, Measure.restrict_congr_set hSeq] at ht exact ht theorem ae_strict_weighted_comparison {r w : E → ℝ≥0∞} {φ q : E → ℝ} {P : E → E} {K C : Set E} (hK : IsOpen K) (hcK : Convex ℝ K) (hb : ∀ p ∈ K, BddAbove ((fun z => ⟪z,p⟫_ℝ-φ z) '' univ)) (hm : Measure.map (gradient (dualOn K φ)) ((μ.restrict K).withDensity w)=μ.withDensity r) (hc : ConvexOn ℝ univ φ) (hφ : Continuous φ) (hq : Continuous q) (hP : ∀ x, SupportingSlope q x (P x)) (hC : IsCompact C) (hboundary : ∀ y ∈ frontier C, q y ≤ φ y) (hreg : ∀ᵐ x ∂μ, DifferentiableAt ℝ q x ∧ DifferentiableAt ℝ P x ∧ (∀ v ≠ 0, 0 < ⟪(fderiv ℝ P x) v,v⟫_ℝ) ∧ P x ∈ K) (hfinite : (μ.withDensity r) C ≠ ⊤) (hw : Measurable w) (hstrict : ∀ᵐ x ∂μ, x ∈ interior C → φ x < q x → r x < ENNReal.ofReal |(fderiv ℝ P x).det| * w (gradient q x)) : ∀ x ∈ C, q x ≤ φ x := by intro x hx by_contra he have hxq : φ x < q x := lt_of_not_ge he have hxint : x ∈ interior C := by by_contra hh have hxf : x ∈ frontier C := by rw [frontier_eq_closure_inter_closure,closure_compl] exact ⟨subset_closure hx,hh⟩ exact (hboundary x hxf).not_gt hxq let D := {x | x ∈ interior C ∧ φ x < q x} have hDo : IsOpen D := isOpen_interior.inter (isOpen_lt hφ hq) have hDμ : μ D ≠ 0 := ne_of_gt (hDo.measure_pos μ ⟨x,hxint,hxq⟩) have hDsub : D ⊆ C := fun _ hz => interior_subset hz.1 have hDf : (∫⁻ z in D, r z ∂μ) ≠ ⊤ := by rw [← withDensity_apply r hDo.measurableSet] exact ne_of_lt (lt_of_le_of_lt (measure_mono hDsub) (lt_top_iff_ne_top.mpr hfinite)) have hJ : Measurable (fun x => ENNReal.ofReal |(fderiv ℝ P x).det| * w (gradient q x)) := ((ContinuousLinearMap.continuous_det.measurable.comp (measurable_fderiv ℝ P)).abs.ennreal_ofReal).mul (hw.comp (gradient_measurable q)) have hlt := setLIntegral_strict_mono hDo.measurableSet hDμ hJ hDf (hstrict.mono (fun z hz hzD => hz hzD.1 hzD.2)) have hle := ae_weighted_jacobian_comparison μ hK hcK hb hm hc hφ hq hP hC hboundary hreg rw [withDensity_apply r hDo.measurableSet] at hle exact (not_lt_of_ge hle) hlt end variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] lemma radial_lower_of_finite_dual {φ : E → ℝ} {R a : ℝ} (ha : 0 < a) (haR : a < R) (hb : ∀ x ∈ Metric.ball (0:E) R, BddAbove ((fun z => ⟪z,x⟫_ℝ-φ z) '' univ)) : ∃ b : ℝ, 0 ≤ b ∧ ∀ z, a*‖z‖-b ≤ φ z := by let u := dualOn (Metric.ball (0:E) R) φ have hsub : Metric.closedBall (0:E) a ⊆ Metric.ball (0:E) R := Metric.closedBall_subset_ball haR have hu : ContinuousOn u (Metric.closedBall (0:E) a) := ((convexOn_dualOn (convex_ball (0:E) R) hb).continuousOn Metric.isOpen_ball).mono hsub obtain ⟨x,hx,hmax⟩ := (isCompact_closedBall (0:E) a).exists_isMaxOn ⟨0,Metric.mem_closedBall_self ha.le⟩ hu let b := max (u x) 0 refine ⟨b,le_max_right _ _,?_⟩ intro z by_cases hz : z=0 · subst z have hf := fenchel_dualOn hb (hsub (Metric.mem_closedBall_self ha.le)) (0:E) have hle : u 0 ≤ b := (hmax (Metric.mem_closedBall_self ha.le)).trans (le_max_left _ _) simp only [inner_zero_right,norm_zero,mul_zero,zero_sub] at * linarith · have hn : 0 < ‖z‖ := norm_pos_iff.mpr hz let y := (a/‖z‖) • z have hyn : ‖y‖=a := by rw [norm_smul,Real.norm_eq_abs,abs_of_pos (div_pos ha hn),div_mul_cancel₀ _ hn.ne'] have hy : y ∈ Metric.closedBall (0:E) a := by rw [Metric.mem_closedBall,dist_zero_right,hyn] have hf := fenchel_dualOn hb (hsub hy) z have hle : u y ≤ b := (hmax hy).trans (le_max_left _ _) have hi : ⟪y,z⟫_ℝ=a*‖z‖ := by rw [real_inner_smul_left,real_inner_self_eq_norm_sq] field_simp rw [hi] at hf change a*‖z‖-u y ≤ φ z at hf linarith end CompactMomentVariational namespace WeakMomentBound open CompactMomentVariational variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] omit [FiniteDimensional ℝ E] in lemma ball_alignment {u v : E} {R d : ℝ} (hu : ‖u‖ = 1) (hR : 0 ≤ R) (hv : ‖v‖ ≤ R) (halign : R-d ≤ ⟪v,u⟫_ℝ) : ‖v - R • u‖^2 ≤ 2*R*d := by rw [norm_sub_sq_real, real_inner_smul_right, norm_smul, Real.norm_eq_abs, abs_of_nonneg hR, hu, mul_one] have hsq : ‖v‖^2 ≤ R^2 := pow_le_pow_left₀ (norm_nonneg _) hv 2 nlinarith omit [FiniteDimensional ℝ E] in lemma difference_alignment {u v w : E} {R d : ℝ} (hu : ‖u‖ = 1) (hR : 0 ≤ R) (hv : ‖v‖ ≤ R) (hw : ‖w‖ ≤ R) (hav : R-d ≤ ⟪v,u⟫_ℝ) (haw : R-d ≤ ⟪w,u⟫_ℝ) : ‖v-w‖^2 ≤ 8*R*d := by have hv' := ball_alignment hu hR hv hav have hw' := ball_alignment hu hR hw haw have htri : ‖v-w‖ ≤ ‖v-R • u‖ + ‖w-R • u‖ := by have := norm_sub_le (v-R • u) (w-R • u) simpa only [sub_sub_sub_cancel_right, norm_sub_rev] using this have hsq := pow_le_pow_left₀ (norm_nonneg (v-w)) htri 2 nlinarith [sq_nonneg (‖v-R • u‖-‖w-R • u‖)] def secondDiff (φ : E → ℝ) (h z : E) : ℝ := φ (z+h) + φ (z-h) - 2*φ z omit [FiniteDimensional ℝ E] in lemma secondDiff_nonneg {φ : E → ℝ} {G : E → E} (hG : ∀ x, SupportingSlope φ x (G x)) (h z : E) : 0 ≤ secondDiff φ h z := by have hp := hG z (z+h) have hm := hG z (z-h) simp only [add_sub_cancel_left, sub_sub_cancel_left, inner_neg_right] at hp hm dsimp [secondDiff] linarith omit [FiniteDimensional ℝ E] in lemma secondDiff_le_gradient {φ : E → ℝ} {G : E → E} (hG : ∀ x, SupportingSlope φ x (G x)) (h z : E) : secondDiff φ h z ≤ ‖G (z+h)-G (z-h)‖ * ‖h‖ := by have hp := hG (z+h) z have hm := hG (z-h) z simp only [sub_add_cancel_left, sub_sub_cancel, inner_neg_right] at hp hm have hi := real_inner_le_norm (G (z+h)-G (z-h)) h rw [inner_sub_left] at hi dsimp [secondDiff] linarith omit [FiniteDimensional ℝ E] in lemma slope_alignment {φ : E → ℝ} {G : E → E} {R a b η : ℝ} (hG : ∀ x, SupportingSlope φ x (G x)) (hbound : ∀ x, ‖G x‖ ≤ R) (ha : 0 ≤ a) (hlower : ∀ x, a*‖x‖-b ≤ φ x) {z k : E} (hz : 0 < ‖z‖) (hlarge : b + |φ 0| + (a+R)*‖k‖ ≤ η*‖z‖) : a-η ≤ ⟪G (z+k), ‖z‖⁻¹ • z⟫_ℝ := by have hs := hG (z+k) 0 simp only [zero_sub, inner_neg_right, inner_add_right] at hs have hn : ‖z‖ ≤ ‖z+k‖+‖k‖ := by simpa only [add_sub_cancel_right] using norm_sub_le (z+k) k have hi : ⟪G (z+k),k⟫_ℝ ≤ R*‖k‖ := (real_inner_le_norm _ _).trans (mul_le_mul_of_nonneg_right (hbound _) (norm_nonneg _)) have hl := hlower (z+k) have hn' := mul_le_mul_of_nonneg_left hn ha have hi' : (a-η)*‖z‖ ≤ ⟪G (z+k),z⟫_ℝ := by have habs := le_abs_self (φ (0:E)) nlinarith rw [real_inner_smul_right] apply (le_inv_mul_iff₀ hz).mpr nlinarith theorem secondDiff_vanishes {φ : E → ℝ} {G : E → E} {R : ℝ} (hG : ∀ x, SupportingSlope φ x (G x)) (hR : 0 < R) (hbound : ∀ x, ‖G x‖ ≤ R) (hdual : ∀ x ∈ Metric.ball (0:E) R, BddAbove ((fun z => ⟪z,x⟫_ℝ-φ z) '' univ)) (h : E) {e : ℝ} (he : 0 < e) : ∃ r : ℝ, 0 < r ∧ ∀ z, r ≤ ‖z‖ → secondDiff φ h z < e := by by_cases hh : h = 0 · subst h refine ⟨1,by norm_num,?_⟩ intro z _ dsimp [secondDiff] simpa only [add_zero, sub_zero, show φ z+φ z-2*φ z=0 by ring] using he have hhn : 0 < ‖h‖ := norm_pos_iff.mpr hh let c : ℝ := 8*R*‖h‖^2 have hcpos : 0 < c := by dsimp [c]; positivity obtain ⟨d,hd0,hd⟩ := exists_between (lt_min hR (div_pos (sq_pos_of_pos he) hcpos)) have hdR : d < R := hd.trans_le (min_le_left _ _) have hdsmall : c*d < e^2 := by have hd' := hd.trans_le (min_le_right _ _) simpa only [mul_comm] using (lt_div_iff₀ hcpos).mp hd' let a : ℝ := R-d/2 have ha : 0 < a := by dsimp [a]; linarith have haR : a < R := by dsimp [a]; linarith obtain ⟨b,hb,hlower⟩ := radial_lower_of_finite_dual ha haR hdual let C : ℝ := b+|φ 0|+2*R*‖h‖ have hC : 0 ≤ C := by dsimp [C]; positivity let r : ℝ := 2*C/d+1 have hr : 0 < r := by dsimp [r]; positivity refine ⟨r,hr,?_⟩ intro z hz have hzn : 0 < ‖z‖ := hr.trans_le hz have hlarge : C ≤ (d/2)*‖z‖ := by have hh' := mul_le_mul_of_nonneg_left hz (by positivity : 0 ≤ d/2) have heq : (d/2)*r = C+d/2 := by dsimp [r]; field_simp rw [heq] at hh' linarith have hlarge' (k : E) (hk : ‖k‖ = ‖h‖) : b+|φ 0|+(a+R)*‖k‖ ≤ (d/2)*‖z‖ := by rw [hk] dsimp [C, a] at hlarge ⊢ nlinarith [mul_nonneg hd0.le hhn.le] have hp := slope_alignment hG hbound ha.le hlower hzn (hlarge' h rfl) have hm := slope_alignment hG hbound ha.le hlower hzn (hlarge' (-h) (norm_neg h)) have hu : ‖‖z‖⁻¹ • z‖ = 1 := by simp only [norm_smul, norm_inv, Real.norm_eq_abs, abs_of_pos hzn] exact inv_mul_cancel₀ (ne_of_gt hzn) have hp' : R-d ≤ ⟪G (z+h),‖z‖⁻¹ • z⟫_ℝ := by dsimp [a] at hp; linarith have hm' : R-d ≤ ⟪G (z-h),‖z‖⁻¹ • z⟫_ℝ := by rw [show a-d/2=R-d by dsimp [a]; ring] at hm simpa only [sub_eq_add_neg] using hm have hdiff := difference_alignment hu hR.le (hbound (z+h)) (hbound (z-h)) hp' hm' have hnonneg := secondDiff_nonneg hG h z have hupper := secondDiff_le_gradient hG h z have hsq := pow_le_pow_left₀ hnonneg hupper 2 have hsq' := mul_le_mul_of_nonneg_right hdiff (sq_nonneg ‖h‖) dsimp [c] at hdsmall rw [mul_pow] at hsq nlinarith theorem secondDiff_attains_max {φ : E → ℝ} (hφ : Continuous φ) {G : E → E} {R : ℝ} (hG : ∀ x, SupportingSlope φ x (G x)) (hR : 0 < R) (hbound : ∀ x, ‖G x‖ ≤ R) (hdual : ∀ x ∈ Metric.ball (0:E) R, BddAbove ((fun z => ⟪z,x⟫_ℝ-φ z) '' univ)) (h : E) : ∃ z, ∀ w, secondDiff φ h w ≤ secondDiff φ h z := by by_cases hzero : ∀ z, secondDiff φ h z = 0 · exact ⟨0, fun w => by rw [hzero w, hzero 0]⟩ push Not at hzero obtain ⟨z₀,hz₀⟩ := hzero have hpos : 0 < secondDiff φ h z₀ := lt_of_le_of_ne (secondDiff_nonneg hG h z₀) (Ne.symm hz₀) obtain ⟨r,hr,hinf⟩ := secondDiff_vanishes hG hR hbound hdual h (by linarith : 0 < secondDiff φ h z₀/2) have hcont : Continuous (secondDiff φ h) := ((hφ.comp (continuous_id.add continuous_const)).add (hφ.comp (continuous_id.sub continuous_const))).sub (continuous_const.mul hφ) let s : ℝ := max r ‖z₀‖ have hzmem : z₀ ∈ Metric.closedBall (0:E) s := by simpa only [Metric.mem_closedBall, dist_zero_right] using le_max_right r ‖z₀‖ obtain ⟨z,hz,hmax⟩ := (isCompact_closedBall (0:E) s).exists_isMaxOn ⟨z₀,hzmem⟩ hcont.continuousOn refine ⟨z,?_⟩ intro w by_cases hw : w ∈ Metric.closedBall (0:E) s · exact hmax hw · have hw' : s < ‖w‖ := by simpa only [Metric.mem_closedBall, dist_zero_right, not_le] using hw have hwr : r ≤ ‖w‖ := (le_max_left _ _).trans hw'.le have hm : secondDiff φ h z₀ ≤ secondDiff φ h z := hmax hzmem exact (hinf w hwr).le.trans (by linarith) end WeakMomentBound namespace LogDetConcavity open Matrix open scoped MatrixOrder BigOperators variable {ι : Type*} [Fintype ι] [DecidableEq ι] lemma trace_mul_nonneg {A B : Matrix ι ι ℝ} (hA : A.PosSemidef) (hB : B.PosSemidef) : 0 ≤ (A * B).trace := by obtain ⟨Q,hQ⟩ := CStarAlgebra.nonneg_iff_eq_star_mul_self.mp hA.nonneg rw [hQ] change 0 ≤ (Qᴴ * Q * B).trace rw [← Matrix.trace_mul_cycle Q B Qᴴ] exact (hB.mul_mul_conjTranspose_same Q).trace_nonneg lemma logdet_le_trace {A : Matrix ι ι ℝ} (hA : A.PosDef) : Real.log A.det ≤ A.trace - Fintype.card ι := by rw [hA.isHermitian.det_eq_prod_eigenvalues, hA.isHermitian.trace_eq_sum_eigenvalues] simp only [RCLike.ofReal_real_eq_id, id_eq] rw [Real.log_prod (fun i _ => ne_of_gt (hA.eigenvalues_pos i))] calc _ ≤ ∑ i, (hA.isHermitian.eigenvalues i - 1) := Finset.sum_le_sum (fun i _ => Real.log_le_sub_one_of_pos (hA.eigenvalues_pos i)) _ = _ := by simp [Finset.sum_sub_distrib] theorem tangent {A B : Matrix ι ι ℝ} (hA : A.PosDef) (hB : B.PosDef) : Real.log B.det - Real.log A.det ≤ (A⁻¹ * (B-A)).trace := by obtain ⟨Q,hQ⟩ := CStarAlgebra.nonneg_iff_eq_star_mul_self.mp hA.inv.posSemidef.nonneg have hQ' : A⁻¹ = Qᴴ * Q := hQ have hdQ : Q.det ≠ 0 := by have hd := congrArg Matrix.det hQ' rw [Matrix.det_mul, Matrix.det_conjTranspose] at hd intro hz simp only [hz, mul_zero] at hd exact ne_of_gt hA.inv.det_pos hd have hunit : IsUnit Q := (Matrix.isUnit_iff_isUnit_det Q).mpr (isUnit_iff_ne_zero.mpr hdQ) have hK : (Q * B * Qᴴ).PosDef := hB.mul_mul_conjTranspose_same (Matrix.vecMul_injective_iff_isUnit.mpr hunit) have ht := logdet_le_trace hK have htrace : (Q * B * Qᴴ).trace = (A⁻¹ * B).trace := by rw [hQ', Matrix.trace_mul_cycle] have hdet : (Q * B * Qᴴ).det = B.det / A.det := by have hd := congrArg Matrix.det hQ' simp only [Matrix.det_mul, Matrix.det_conjTranspose, star_trivial, Matrix.det_nonsing_inv, Ring.inverse_eq_inv] at hd ⊢ rw [div_eq_mul_inv, hd] ring rw [htrace, hdet, Real.log_div (ne_of_gt hB.det_pos) (ne_of_gt hA.det_pos)] at ht simpa only [Matrix.mul_sub, Matrix.trace_sub, Matrix.nonsing_inv_mul A (isUnit_iff_ne_zero.mpr (ne_of_gt hA.det_pos)), Matrix.trace_one] using ht theorem midpoint_comparison {A B C : Matrix ι ι ℝ} (hA : A.PosDef) (hB : B.PosDef) (hC : C.PosDef) (hmid : (2 • A - B - C).PosSemidef) : Real.log B.det + Real.log C.det - 2 * Real.log A.det ≤ 0 := by have hb := tangent hA hB have hc := tangent hA hC have hn := trace_mul_nonneg hA.inv.posSemidef hmid have he : (A⁻¹ * (2 • A - B - C)).trace = -((A⁻¹ * (B-A)).trace + (A⁻¹ * (C-A)).trace) := by simp only [Matrix.mul_sub, Matrix.mul_smul, Matrix.trace_sub, Matrix.trace_smul, Matrix.nonsing_inv_mul A (isUnit_iff_ne_zero.mpr (ne_of_gt hA.det_pos))] ring rw [he] at hn linarith end LogDetConcavity namespace WeakMomentBound open CompactMomentVariational variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] def shiftedMean (φ : E → ℝ) (h : E) (T : ℝ) (z : E) : ℝ := (φ (z+h)+φ (z-h)-T)/2 def slopeMean (P : E → E) (h z : E) : E := (1/2:ℝ) • (P (z+h)+P (z-h)) lemma slopeMean_support {φ : E → ℝ} {P : E → E} (hs : ∀ z, SupportingSlope φ z (P z)) (h : E) (T : ℝ) (z : E) : SupportingSlope (shiftedMean φ h T) z (slopeMean P h z) := by intro y have hp := hs (z+h) (y+h) have hm := hs (z-h) (y-h) have ep : y+h-(z+h)=y-z := by abel have em : y-h-(z-h)=y-z := by abel rw [ep] at hp rw [em] at hm dsimp [shiftedMean,slopeMean] rw [real_inner_smul_left,inner_add_left] linarith omit [InnerProductSpace ℝ E] in lemma shiftedMean_continuous {φ : E → ℝ} (hc : Continuous φ) (h : E) (T : ℝ) : Continuous (shiftedMean φ h T) := (((hc.comp (continuous_id.add_const h)).add (hc.comp (continuous_id.sub continuous_const))).sub continuous_const).div_const 2 lemma slopeMean_hasFDerivAt {P : E → E} {h z : E} {A B : E →L[ℝ] E} (hp : HasFDerivAt P A (z+h)) (hm : HasFDerivAt P B (z-h)) : HasFDerivAt (slopeMean P h) ((1/2:ℝ) • (A+B)) z := by have hp' : HasFDerivAt (fun y => P (y+h)) A z := by simpa only [Function.comp_def,id_eq,ContinuousLinearMap.comp_id] using hp.comp z ((hasFDerivAt_id z).add_const h) have hm' : HasFDerivAt (fun y => P (y-h)) B z := by simpa only [Function.comp_def,id_eq,ContinuousLinearMap.comp_id] using hm.comp z ((hasFDerivAt_id z).sub_const h) exact (hp'.add hm').const_smul (1/2:ℝ) lemma shiftedMean_differentiableAt {φ : E → ℝ} {h z : E} (hp : DifferentiableAt ℝ φ (z+h)) (hm : DifferentiableAt ℝ φ (z-h)) (T : ℝ) : DifferentiableAt ℝ (shiftedMean φ h T) z := by have hh := (((hp.comp z ((differentiableAt_id (𝕜 := ℝ)).add_const h)).add (hm.comp z ((differentiableAt_id (𝕜 := ℝ)).sub_const h))).sub_const T).mul_const (1/2:ℝ) change DifferentiableAt ℝ (fun y => (φ (y+h)+φ (y-h)-T)/2) z simpa only [div_eq_mul_inv,Function.comp_def,Pi.add_apply,id_eq,one_mul] using hh variable [FiniteDimensional ℝ E] variable {ι : Type*} [Fintype ι] [DecidableEq ι] omit [FiniteDimensional ℝ E] in lemma inner_pos_of_matrix_posDef (b : OrthonormalBasis ι ℝ E) {H : E →L[ℝ] E} (hH : (LinearMap.toMatrix b.toBasis b.toBasis H.toLinearMap).PosDef) : ∀ v ≠ 0, 0 < ⟪H v,v⟫_ℝ := by intro v hv have hcoord : (b.toBasis.repr v : ι → ℝ) ≠ 0 := by intro he have hz : b.toBasis.repr v = 0 := DFunLike.coe_injective he exact hv (b.toBasis.repr.injective (by simpa using hz)) have hh := hH.dotProduct_mulVec_pos hcoord rw [LinearMap.toMatrix_mulVec_repr] at hh have he (w : E) : (b.toBasis.repr w : ι → ℝ) = WithLp.ofLp (b.repr w) := by ext i exact b.coe_toBasis_repr_apply w i rw [he v] at hh change 0 < star (b.repr v).ofLp ⬝ᵥ (b.toBasis.repr (H v) : ι → ℝ) at hh rw [he (H v)] at hh have hi := b.repr.inner_map_map v (H v) rw [EuclideanSpace.inner_eq_star_dotProduct] at hi simp only [star_trivial] at hh hi rw [dotProduct_comm] at hi rw [hi] at hh simpa only [real_inner_comm] using hh omit [Fintype ι] [DecidableEq ι] in lemma mean_matrix_posDef {A B : Matrix ι ι ℝ} (hA : A.PosDef) (hB : B.PosDef) : ((1/2:ℝ) • (A+B)).PosDef := (hA.add hB).smul (by norm_num) lemma logdet_mean {A B : Matrix ι ι ℝ} (hA : A.PosDef) (hB : B.PosDef) : (Real.log A.det+Real.log B.det)/2 ≤ Real.log ((1/2:ℝ) • (A+B)).det := by have he : 2 • ((1/2:ℝ) • (A+B))-A-B=0 := by module have ht := LogDetConcavity.midpoint_comparison (mean_matrix_posDef hA hB) hA hB (by rw [he]; exact Matrix.PosSemidef.zero) linarith omit [FiniteDimensional ℝ E] in lemma matrix_slopeMean (b : OrthonormalBasis ι ℝ E) {P : E → E} {h z : E} (hp : DifferentiableAt ℝ P (z+h)) (hm : DifferentiableAt ℝ P (z-h)) : LinearMap.toMatrix b.toBasis b.toBasis (fderiv ℝ (slopeMean P h) z).toLinearMap = (1/2:ℝ) • (LinearMap.toMatrix b.toBasis b.toBasis (fderiv ℝ P (z+h)).toLinearMap+ LinearMap.toMatrix b.toBasis b.toBasis (fderiv ℝ P (z-h)).toLinearMap) := by rw [(slopeMean_hasFDerivAt hp.hasFDerivAt hm.hasFDerivAt).fderiv] simp end WeakMomentBound end namespace WeakMomentBound lemma finite_difference_gain {ε r d δ : ℝ} (hε : 0 < ε) (hr : 0 ≤ r) (hδ : δ ≤ d*r) (hlarge : 4/ε*r^2 < δ) : δ/2 < ε/8*d^2 := by have hrpos : 0 < r := by by_contra he have hz : r=0 := le_antisymm (le_of_not_gt he) hr rw [hz] at hδ hlarge norm_num at hδ hlarge linarith have hdlarge : 4*r/ε ⟪z,x⟫_ℝ-φ z) '' univ)) (hm : Measure.map (gradient φ) (μ.withDensity (fun z => ENNReal.ofReal (Real.exp (-φ z)))) = TruncatedMoment.target μ R V) (h z : E) : secondDiff φ h z ≤ 4/ε*‖h‖^2 := by let P := chosenSlope μ hc hl let Z := TruncatedMoment.partition μ R V let K := Metric.ball (0:E) (R:ℝ) let σ := μ.withDensity (fun x => ENNReal.ofReal (Real.exp (-φ x))) let ν := TruncatedMoment.target μ R V have hZ : 0 < Z := TruncatedMoment.partition_pos μ hV hR have hPs : ∀ x, SupportingSlope φ x (P x) := chosenSlope_support μ hc hl have hPbound : ∀ x, ‖P x‖ ≤ (R:ℝ) := norm_chosenSlope_le μ hc hl have hσμ : σ ≪ μ := withDensity_absolutelyContinuous _ _ have hνμ : ν ≪ μ := (withDensity_absolutelyContinuous _ _).trans Measure.absolutelyContinuous_restrict have hback := reverse_pushforward hσμ hνμ Metric.isOpen_ball (convex_ball (0:E) R) hc hl hb (TruncatedMoment.ae_mem_ball μ V R) hm have : IsProbabilityMeasure ν := TruncatedMoment.probability μ hV hR have hσuniv : σ univ=1 := by rw [← hback,Measure.map_apply (gradient_measurable _) MeasurableSet.univ] exact measure_univ have ha := ae_positive_MA μ b hV hR hc hl hb hm have hap := (measurePreserving_add_right μ h).quasiMeasurePreserving.ae ha have ham' := (measurePreserving_add_right μ (-h)).quasiMeasurePreserving.ae ha have ham : ∀ᵐ x ∂μ, DifferentiableAt ℝ φ (x-h) ∧ DifferentiableAt ℝ P (x-h) ∧ (weakHessian μ b hc hl (x-h)).PosDef ∧ Real.log (weakHessian μ b hc hl (x-h)).det = V (P (x-h))+Real.log Z-φ (x-h) ∧ P (x-h) ∈ K := by simpa only [sub_eq_add_neg] using ham' by_contra hnot obtain ⟨T,hT,hTz⟩ := exists_between (lt_of_not_ge hnot) have hTpos : 0 < T := (by positivity : (0:ℝ) ≤ 4/ε*‖h‖^2).trans_lt hT obtain ⟨r,hr,hinf⟩ := secondDiff_vanishes hPs hR hPbound hb h hTpos let s : ℝ := max r (‖z‖+1) let C := Metric.closedBall (0:E) s have hC : IsCompact C := isCompact_closedBall _ _ let q := shiftedMean φ h T let Q := slopeMean P h have hqs : ∀ x, SupportingSlope q x (Q x) := slopeMean_support hPs h T have hqc : Continuous q := shiftedMean_continuous hl.continuous h T have hboundary : ∀ y ∈ frontier C, q y ≤ φ y := by intro y hy have hys : s ≤ ‖y‖ := by by_contra he have hym : y ∈ Metric.ball (0:E) s := by simpa only [Metric.mem_ball,dist_zero_right] using lt_of_not_ge he have hyint : y ∈ interior C := Metric.ball_subset_interior_closedBall hym exact (disjoint_interior_frontier (s := C)).notMem_of_mem_left hyint hy have hd := hinf y ((le_max_left _ _).trans hys) dsimp [q,shiftedMean,secondDiff] at hd ⊢ linarith have hreg : ∀ᵐ x ∂μ, DifferentiableAt ℝ q x ∧ DifferentiableAt ℝ Q x ∧ (∀ v ≠ 0, 0 < ⟪(fderiv ℝ Q x) v,v⟫_ℝ) ∧ Q x ∈ K := by filter_upwards [hap,ham] with x hp hm have hmtr := matrix_slopeMean b hp.2.1 hm.2.1 have hpd : (LinearMap.toMatrix b.toBasis b.toBasis (fderiv ℝ Q x).toLinearMap).PosDef := by rw [hmtr] exact mean_matrix_posDef hp.2.2.1 hm.2.2.1 refine ⟨shiftedMean_differentiableAt hp.1 hm.1 T, (slopeMean_hasFDerivAt hp.2.1.hasFDerivAt hm.2.1.hasFDerivAt).differentiableAt, inner_pos_of_matrix_posDef b hpd,?_⟩ have hconv := (convex_ball (0:E) (R:ℝ)) hp.2.2.2.2 hm.2.2.2.2 (by norm_num : (0:ℝ) ≤ 1/2) (by norm_num : (0:ℝ) ≤ 1/2) (by norm_num : (1:ℝ)/2+1/2=1) simpa only [Q,slopeMean,smul_add] using hconv have hstrict : ∀ᵐ x ∂μ, x ∈ interior C → φ x < q x → ENNReal.ofReal (Real.exp (-φ x)) < ENNReal.ofReal |(fderiv ℝ Q x).det| * ENNReal.ofReal (Real.exp (-V (gradient q x))/Z) := by filter_upwards [hap,ham] with x hp hm intro _ hx have hlarge : 4/ε*‖h‖^2 < secondDiff φ h x := by dsimp [q,shiftedMean] at hx dsimp [secondDiff] linarith have hgain := finite_difference_gain hε (norm_nonneg h) (secondDiff_le_gradient hPs h x) hlarge have hmtr := matrix_slopeMean b hp.2.1 hm.2.1 have hpd := mean_matrix_posDef hp.2.2.1 hm.2.2.1 have hld := logdet_mean hp.2.2.1 hm.2.2.1 have hdet : (LinearMap.toMatrix b.toBasis b.toBasis (fderiv ℝ Q x).toLinearMap).det = (fderiv ℝ Q x).det := LinearMap.det_toMatrix b.toBasis _ have hdetpos : 0 < (fderiv ℝ Q x).det := by rw [← hdet,hmtr] exact hpd.det_pos have hgradient : gradient q x=Q x := gradient_eq_of_support (shiftedMean_differentiableAt hp.1 hm.1 T) (hqs x) rw [hgradient] apply density_lt_of_logdet hdetpos hZ rw [← hdet,hmtr] have hcv := hcurv (P (x+h)) (P (x-h)) dsimp [secondDiff] at hgain have hlogp := hp.2.2.2.1 have hlogm := hm.2.2.2.1 change Real.log (weakHessian μ b hc hl (x+h)).det = V (P (x+h))+Real.log Z-φ (x+h) at hlogp change V ((1/2:ℝ) • (P (x+h)+P (x-h)))+Real.log Z-φ x < Real.log ((1/2:ℝ) • (weakHessian μ b hc hl (x+h)+weakHessian μ b hc hl (x-h))).det linarith have hfinite : σ C ≠ ⊤ := ne_of_lt (lt_of_le_of_lt (measure_mono (subset_univ C)) (by rw [hσuniv]; exact ENNReal.one_lt_top)) have hcomp := ae_strict_weighted_comparison μ Metric.isOpen_ball (convex_ball (0:E) R) hb hback hc hl.continuous hqc hqs hC hboundary hreg hfinite (hV.neg.rexp.measurable.div_const Z).ennreal_ofReal hstrict have hzC : z ∈ C := by change dist z 0 ≤ s rw [dist_zero_right] exact (by linarith : ‖z‖ ≤ ‖z‖+1).trans (le_max_right _ _) have hh := hcomp z hzC dsimp [q,shiftedMean,secondDiff] at hh hTz linarith end CompactMomentVariational namespace QuadraticRegularity open Filter open scoped Topology InnerProductSpace NNReal variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] lemma remainder_of_secondDiff {φ : E → ℝ} {P : E → E} {C : ℝ} (hs : ∀ x y, φ x+⟪P x,y-x⟫_ℝ ≤ φ y) (hc : ∀ x h, φ (x+h)+φ (x-h)-2*φ x ≤ C*‖h‖^2) (x y : E) : |φ y-φ x-⟪P x,y-x⟫_ℝ| ≤ C*‖y-x‖^2 := by have hh := hc x (y-x) have hu := hs x (x-(y-x)) have hl := hs x y have he : x+(y-x)=y := by abel have he' : x-(y-x)-x=-(y-x) := by abel rw [he] at hh rw [he',inner_neg_right] at hu rw [abs_of_nonneg (by linarith)] linarith lemma hasFDerivAt_of_remainder {φ : E → ℝ} {P : E → E} {C : ℝ} (hc : ∀ x y, |φ y-φ x-⟪P x,y-x⟫_ℝ| ≤ C*‖y-x‖^2) (x : E) : HasFDerivAt φ (innerSL ℝ (P x)) x := by rw [hasFDerivAt_iff_isLittleO] have hh : (fun y => φ y-φ x-(innerSL ℝ (P x)) (y-x)) =O[𝓝 x] (fun y => ‖y-x‖^2) := by rw [Asymptotics.isBigO_iff] refine ⟨C,Filter.Eventually.of_forall fun y => ?_⟩ simpa only [Real.norm_eq_abs,abs_of_nonneg (sq_nonneg ‖y-x‖),innerSL_apply_apply] using hc x y exact hh.trans_isLittleO (Asymptotics.isLittleO_pow_sub_sub x (by norm_num : 1 < (2:ℕ))) lemma slope_difference_bound {φ : E → ℝ} {P : E → E} {C : ℝ} (hC : 0 (hd x).differentiableAt,?_⟩ have he : fderiv ℝ φ = fun x => innerSL ℝ (P x) := funext fun x => (hd x).fderiv rw [he] exact (innerSL ℝ).continuous.comp (lipschitz_of_remainder hC hs hc).continuous end QuadraticRegularity namespace CompactMomentVariational open WeakMomentBound variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] variable (μ : Measure E) [μ.IsAddHaarMeasure] variable {ι : Type*} [Fintype ι] [DecidableEq ι] theorem weak_contDiff_one (b : OrthonormalBasis ι ℝ E) {V φ : E → ℝ} (hV : Continuous V) {ε : ℝ} (hε : 0 < ε) (hcurv : ∀ x y, ε/8*‖x-y‖^2 ≤ (V x+V y)/2-V ((1/2:ℝ) • (x+y))) {R : ℝ≥0} (hR : 0 < R) (hc : ConvexOn ℝ univ φ) (hl : LipschitzWith R φ) (hb : ∀ x ∈ Metric.ball (0:E) R, BddAbove ((fun z => ⟪z,x⟫_ℝ-φ z) '' univ)) (hm : Measure.map (gradient φ) (μ.withDensity (fun z => ENNReal.ofReal (Real.exp (-φ z)))) = TruncatedMoment.target μ R V) : ContDiff ℝ 1 φ ∧ LipschitzWith (Real.toNNReal (16/ε)) (gradient φ) := by let C : ℝ≥0 := Real.toNNReal (4/ε) have hC : 0 gradient_eq_of_support ((hf x).differentiableAt) (hs x) refine ⟨QuadraticRegularity.contDiff_one_of_remainder hC hs hr,?_⟩ rw [he] have hnum : 4*C=Real.toNNReal (16/ε) := by apply NNReal.coe_injective rw [NNReal.coe_mul,NNReal.coe_ofNat,heC,Real.coe_toNNReal _ (by positivity)] ring rw [← hnum] exact QuadraticRegularity.lipschitz_of_remainder hC hs hr theorem exists_C11_truncated (b : OrthonormalBasis ι ℝ E) {V : E → ℝ} (hV : Continuous V) (hVe : Function.Even V) {ε : ℝ} (hε : 0 < ε) (hcurv : ∀ x y, ε/8*‖x-y‖^2 ≤ (V x+V y)/2-V ((1/2:ℝ) • (x+y))) {R : ℝ≥0} (hR : 0 < R) : ∃ φ : E → ℝ, ConvexOn ℝ univ φ ∧ Function.Even φ ∧ LipschitzWith R φ ∧ ContDiff ℝ 1 φ ∧ LipschitzWith (Real.toNNReal (16/ε)) (gradient φ) ∧ (∀ h z, secondDiff φ h z ≤ 4/ε*‖h‖^2) ∧ (∃ c > 0, ∃ d : ℝ, ∀ z, c*‖z‖-d ≤ φ z) ∧ IsProbabilityMeasure (μ.withDensity (fun z => ENNReal.ofReal (Real.exp (-φ z)))) ∧ (∀ x ∈ Metric.ball (0:E) R, BddAbove ((fun z => ⟪z,x⟫_ℝ-φ z) '' univ)) ∧ Measure.map (gradient φ) (μ.withDensity (fun z => ENNReal.ofReal (Real.exp (-φ z)))) = TruncatedMoment.target μ R V := by obtain ⟨φ,hc,he,hl,ht,hp,hb,hm,_⟩ := exists_weak_truncated_MA μ hV hVe hR have hr := weak_contDiff_one μ b hV hε hcurv hR hc hl hb hm exact ⟨φ,hc,he,hl,hr.1,hr.2,weak_secondDiff_cap μ b hV hε hcurv hR hc hl hb hm, ht,hp,hb,hm⟩ end CompactMomentVariational namespace SourceIdentity open MeasureTheory Set Filter open scoped InnerProductSpace Topology variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] variable (μ : Measure E) [μ.IsAddHaarMeasure] lemma norm_exp_bound {c : ℝ} (hc : 0 Real.exp (-(c/2)*‖x‖)) μ) : Integrable (fun x => ‖x‖*Real.exp (-φ x)) μ := by apply (he.const_mul (Real.exp d*(2/c))).mono' (by fun_prop) filter_upwards [] with x rw [Real.norm_eq_abs,abs_of_nonneg (mul_nonneg (norm_nonneg _) (Real.exp_pos _).le)] calc ‖x‖*Real.exp (-φ x) ≤ ‖x‖*(Real.exp d*Real.exp (-c*‖x‖)) := by gcongr rw [← Real.exp_add] apply Real.exp_le_exp.mpr linarith [ht x] _ = Real.exp d*(‖x‖*Real.exp (-c*‖x‖)) := by ring _ ≤ Real.exp d*((2/c)*Real.exp (-(c/2)*‖x‖)) := mul_le_mul_of_nonneg_left (norm_exp_bound hc ‖x‖) (Real.exp_pos _).le _ = _ := by ring omit [μ.IsAddHaarMeasure] in lemma gradient_moment_integrable {φ : E → ℝ} {P : E → E} (hφ : Continuous φ) (hP : Continuous P) {R : ℝ} (hR : ∀ x, ‖P x‖≤R) (hi : Integrable (fun x => ‖x‖*Real.exp (-φ x)) μ) : Integrable (fun x => ⟪P x,x⟫_ℝ * Real.exp (-φ x)) μ := by apply (hi.const_mul R).mono' (by fun_prop) filter_upwards [] with x rw [Real.norm_eq_abs,abs_mul,abs_of_pos (Real.exp_pos _)] calc |⟪P x,x⟫_ℝ| * Real.exp (-φ x) ≤ (‖P x‖*‖x‖)*Real.exp (-φ x) := by gcongr exact abs_real_inner_le_norm _ _ _ ≤ (R*‖x‖)*Real.exp (-φ x) := by gcongr; exact hR x _ = _ := by ring lemma coordinate_identity {φ : E → ℝ} {P : E → E} (hφ : ∀ x, HasFDerivAt φ (innerSL ℝ (P x)) x) (hP : Continuous P) {R : ℝ} (hR : ∀ x, ‖P x‖≤R) (hI : Integrable (fun x => Real.exp (-φ x)) μ) (hi : Integrable (fun x => ‖x‖*Real.exp (-φ x)) μ) (v : E) : (∫ x, ⟪v,x⟫_ℝ * ⟪P x,v⟫_ℝ * Real.exp (-φ x) ∂μ) = ‖v‖^2*(∫ x, Real.exp (-φ x) ∂μ) := by have hφc : Continuous φ := continuous_iff_continuousAt.mpr fun x => (hφ x).continuousAt let ρ := fun x => Real.exp (-φ x) have hd (x w : E) : fderiv ℝ ρ x w = -⟪P x,w⟫_ℝ * ρ x := by have hh : HasFDerivAt ρ (Real.exp (-φ x) • -(innerSL ℝ (P x))) x := (hφ x).neg.exp rw [hh.fderiv] simp only [smul_apply,neg_apply, innerSL_apply_apply,smul_eq_mul,ρ] ring have hv (x w : E) : fderiv ℝ (fun y => ⟪v,y⟫_ℝ) x w= ⟪v,w⟫_ℝ := congrArg (fun f : E →L[ℝ] ℝ => f w) (innerSL ℝ v).hasFDerivAt.fderiv have hfg : Integrable (fun x => ⟪v,x⟫_ℝ * ρ x) μ := by apply (hi.const_mul ‖v‖).mono' (by dsimp [ρ]; fun_prop) filter_upwards [] with x rw [Real.norm_eq_abs,abs_mul,abs_of_pos (Real.exp_pos _)] have hh := mul_le_mul_of_nonneg_right (abs_real_inner_le_norm v x) (Real.exp_pos (-φ x)).le simpa only [ρ,mul_assoc] using hh have hfg' : Integrable (fun x => ⟪v,x⟫_ℝ * fderiv ℝ ρ x v) μ := by apply (hi.const_mul (R*‖v‖^2)).mono' (by simp_rw [hd]; dsimp [ρ]; fun_prop) filter_upwards [] with x rw [hd,Real.norm_eq_abs,abs_mul,abs_mul,abs_neg,abs_of_pos (Real.exp_pos _)] have hvx := abs_real_inner_le_norm v x have hpx : |⟪P x,v⟫_ℝ|≤R*‖v‖ := (abs_real_inner_le_norm _ _).trans (mul_le_mul_of_nonneg_right (hR x) (norm_nonneg _)) calc |⟪v,x⟫_ℝ| * (|⟪P x,v⟫_ℝ| * Real.exp (-φ x)) ≤ (‖v‖*‖x‖)*((R*‖v‖)*Real.exp (-φ x)) := by gcongr _ = _ := by ring have hf'g : Integrable (fun x => fderiv ℝ (fun y => ⟪v,y⟫_ℝ) x v*ρ x) μ := by simp_rw [hv] exact hI.const_mul _ have hh := integral_mul_fderiv_eq_neg_fderiv_mul_of_integrable hf'g hfg' hfg (fun x _ => (innerSL ℝ v).differentiableAt) (fun x _ => ((hφ x).neg.exp).differentiableAt) simp_rw [hd,hv,real_inner_self_eq_norm_sq] at hh have he : (fun x => ⟪v,x⟫_ℝ * (-⟪P x,v⟫_ℝ * ρ x)) = (fun x => -(⟪v,x⟫_ℝ * ⟪P x,v⟫_ℝ * ρ x)) := by funext x;ring rw [he,integral_neg,integral_const_mul,neg_inj] at hh exact hh omit [μ.IsAddHaarMeasure] in lemma coordinate_moment_integrable {φ : E → ℝ} {P : E → E} (hφ : Continuous φ) (hP : Continuous P) {R : ℝ} (hR : ∀ x, ‖P x‖≤R) (hi : Integrable (fun x => ‖x‖*Real.exp (-φ x)) μ) (v : E) : Integrable (fun x => ⟪v,x⟫_ℝ * ⟪P x,v⟫_ℝ * Real.exp (-φ x)) μ := by apply (hi.const_mul (R*‖v‖^2)).mono' (by fun_prop) filter_upwards [] with x rw [Real.norm_eq_abs,abs_mul,abs_mul,abs_of_pos (Real.exp_pos _)] have hvx := abs_real_inner_le_norm v x have hpx : |⟪P x,v⟫_ℝ|≤R*‖v‖ := (abs_real_inner_le_norm _ _).trans (mul_le_mul_of_nonneg_right (hR x) (norm_nonneg _)) calc |⟪v,x⟫_ℝ| * |⟪P x,v⟫_ℝ| * Real.exp (-φ x) ≤ (‖v‖*‖x‖)*(R*‖v‖)*Real.exp (-φ x) := by gcongr _ = _ := by ring variable {ι : Type*} [Fintype ι] lemma euclidean_identity (b : OrthonormalBasis ι ℝ E) {φ : E → ℝ} {P : E → E} (hφ : ∀ x, HasFDerivAt φ (innerSL ℝ (P x)) x) (hP : Continuous P) {R : ℝ} (hR : ∀ x, ‖P x‖≤R) (hI : Integrable (fun x => Real.exp (-φ x)) μ) (hi : Integrable (fun x => ‖x‖*Real.exp (-φ x)) μ) : (∫ x, ⟪P x,x⟫_ℝ * Real.exp (-φ x) ∂μ) = Fintype.card ι*(∫ x, Real.exp (-φ x) ∂μ) := by have hφc : Continuous φ := continuous_iff_continuousAt.mpr fun x => (hφ x).continuousAt have he : (fun x => ⟪P x,x⟫_ℝ * Real.exp (-φ x)) = (fun x => ∑ i, ⟪b i,x⟫_ℝ * ⟪P x,b i⟫_ℝ * Real.exp (-φ x)) := by funext x rw [← b.sum_inner_mul_inner (P x) x,Finset.sum_mul] apply Finset.sum_congr rfl intro i _ ring rw [he,integral_finsetSum _ (fun i _ => coordinate_moment_integrable μ hφc hP hR hi (b i))] simp_rw [coordinate_identity μ hφ hP hR hI hi,b.norm_eq_one] simp lemma weighted_identity (b : OrthonormalBasis ι ℝ E) {φ : E → ℝ} {P : E → E} (hφ : ∀ x, HasFDerivAt φ (innerSL ℝ (P x)) x) (hP : Continuous P) {R : ℝ} (hR : ∀ x, ‖P x‖≤R) (hI : Integrable (fun x => Real.exp (-φ x)) μ) (hi : Integrable (fun x => ‖x‖*Real.exp (-φ x)) μ) (hn : (∫ x, Real.exp (-φ x) ∂μ)=1) : (∫ x, ⟪P x,x⟫_ℝ ∂μ.withDensity (fun x => ENNReal.ofReal (Real.exp (-φ x)))) = Fintype.card ι := by have hφc : Continuous φ := continuous_iff_continuousAt.mpr fun x => (hφ x).continuousAt have hm : Measurable (fun x => ENNReal.ofReal (Real.exp (-φ x))) := by fun_prop rw [integral_withDensity_eq_integral_toReal_smul hm (Eventually.of_forall fun _ => ENNReal.ofReal_lt_top)] simp only [ENNReal.toReal_ofReal (Real.exp_pos _).le,smul_eq_mul] simp_rw [mul_comm (Real.exp _) _] rw [euclidean_identity μ b hφ hP hR hI hi,hn,mul_one] end SourceIdentity end open Set MeasureTheory Filter open scoped InnerProductSpace Topology noncomputable section namespace UniformMoment variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] lemma supporting_plane {φ : E → ℝ} {G : E → E} (hc : ConvexOn ℝ Set.univ φ) (hG : ∀ x, HasGradientAt φ (G x) x) (z x : E) : φ z + ⟪G z, x-z⟫_ℝ ≤ φ x := by let a : ℝ →ᵃ[ℝ] E := AffineMap.lineMap z x have hc' : ConvexOn ℝ Set.univ (φ ∘ a) := by simpa only [Set.preimage_univ] using hc.comp_affineMap a have hd : HasDerivAt (φ ∘ a) ⟪G z, x-z⟫_ℝ 0 := by have hz : HasFDerivAt φ ((InnerProductSpace.toDual ℝ E) (G z)) (a 0) := by simpa [a] using (hG z).hasFDerivAt exact hz.comp_hasDerivAt 0 AffineMap.hasDerivAt_lineMap have hh := hc'.le_slope_of_hasDerivAt (Set.mem_univ (0 : ℝ)) (Set.mem_univ (1 : ℝ)) (by norm_num) hd simp [slope, a] at hh linarith omit [FiniteDimensional ℝ E] in lemma even_convex_min {φ : E → ℝ} (hc : ConvexOn ℝ univ φ) (he : Function.Even φ) (z : E) : φ 0 ≤ φ z := by have h := hc.2 (mem_univ z) (mem_univ (-z)) (show (0:ℝ) ≤ 1/2 by norm_num) (show (0:ℝ) ≤ 1/2 by norm_num) (show (1:ℝ)/2+1/2=1 by norm_num) rw [smul_neg, add_neg_cancel, he, smul_eq_mul, ← add_mul] at h norm_num at h exact h lemma abs_inner_le {φ : E → ℝ} {G : E → E} (hc : ConvexOn ℝ univ φ) (he : Function.Even φ) (hG : ∀ x, HasGradientAt φ (G x) x) (z y : E) : |⟪G z,y⟫_ℝ| ≤ φ y - φ 0 + ⟪G z,z⟫_ℝ := by have h₁ := supporting_plane hc hG z y have h₂ := supporting_plane hc hG z (-y) have h₀ := even_convex_min hc he z rw [he] at h₂ simp only [inner_sub_right, inner_neg_right] at h₁ h₂ exact abs_le.mpr ⟨by linarith, by linarith⟩ section Measure variable [MeasurableSpace E] [BorelSpace E] (ν : Measure E) [IsProbabilityMeasure ν] lemma first_moment_bound {φ : E → ℝ} {G : E → E} (hc : ConvexOn ℝ univ φ) (he : Function.Even φ) (hG : ∀ x, HasGradientAt φ (G x) x) (hGc : Continuous G) (hi : Integrable (fun z => ⟪G z,z⟫_ℝ) ν) (y : E) : (∫ z, |⟪G z,y⟫_ℝ| ∂ν) ≤ φ y-φ 0 + ∫ z, ⟪G z,z⟫_ℝ ∂ν := by have hir : Integrable (fun z => φ y-φ 0 + ⟪G z,z⟫_ℝ) ν := (integrable_const _).add hi have hil : Integrable (fun z => |⟪G z,y⟫_ℝ|) ν := hir.mono' (hGc.inner continuous_const).abs.aestronglyMeasurable (Eventually.of_forall fun z => by simpa only [Real.norm_eq_abs, abs_abs] using (abs_inner_le hc he hG z y)) have h := integral_mono hil hir (abs_inner_le hc he hG · y) simpa [integral_add (integrable_const _) hi, integral_const, Measure.real] using h lemma uniform_coercivity {φ : E → ℝ} {G : E → E} (hc : ConvexOn ℝ univ φ) (he : Function.Even φ) (hG : ∀ x, HasGradientAt φ (G x) x) (hGc : Continuous G) (hi : Integrable (fun z => ⟪G z,z⟫_ℝ) ν) {c d : ℝ} (hd : (∫ z, ⟪G z,z⟫_ℝ ∂ν) = d) (hm : ∀ y, c*‖y‖ ≤ ∫ z, |⟪G z,y⟫_ℝ| ∂ν) (y : E) : c*‖y‖-d ≤ φ y-φ 0 := by have h := first_moment_bound ν hc he hG hGc hi y rw [hd] at h have := hm y linarith end Measure section Ball variable [MeasurableSpace E] [BorelSpace E] variable (μ : Measure E) [IsFiniteMeasureOnCompacts μ] def ballMoment (y : E) : ℝ := ∫ x in Metric.closedBall (0:E) 1, |⟪x,y⟫_ℝ| ∂μ lemma ballMoment_integrable (y : E) : IntegrableOn (fun x : E => |⟪x,y⟫_ℝ|) (Metric.closedBall 0 1) μ := ContinuousOn.integrableOn_compact (isCompact_closedBall _ _) (continuous_id.inner continuous_const).abs.continuousOn lemma continuous_ballMoment : Continuous (ballMoment μ) := by have hn : IntegrableOn (fun x : E => ‖x‖) (Metric.closedBall 0 1) μ := ContinuousOn.integrableOn_compact (isCompact_closedBall _ _) continuous_norm.continuousOn apply continuous_iff_continuousAt.mpr intro y₀ apply continuousAt_of_dominated (bound := fun x : E => (‖y₀‖+1)*‖x‖) · exact Eventually.of_forall fun y => (ballMoment_integrable μ y).aestronglyMeasurable · have hy : ∀ᶠ y : E in nhds y₀, ‖y‖ < ‖y₀‖+1 := (isOpen_lt continuous_norm continuous_const).mem_nhds (show ‖y₀‖ < ‖y₀‖ + 1 by linarith) filter_upwards [hy] with y hy exact Eventually.of_forall fun x => by simp only [Real.norm_eq_abs, abs_abs] calc |⟪x,y⟫_ℝ| ≤ ‖x‖*‖y‖ := abs_real_inner_le_norm x y _ ≤ (‖y₀‖+1)*‖x‖ := by nlinarith [norm_nonneg x] · exact hn.const_mul _ · exact Eventually.of_forall fun x => (continuous_const.inner continuous_id).abs.continuousAt omit [FiniteDimensional ℝ E] [BorelSpace E] [IsFiniteMeasureOnCompacts μ] in lemma ballMoment_smul (a : ℝ) (y : E) : ballMoment μ (a • y) = |a| * ballMoment μ y := by simp only [ballMoment, inner_smul_right, abs_mul, integral_const_mul] lemma ballMoment_pos_of_norm_one [μ.IsOpenPosMeasure] {y : E} (hy : ‖y‖=1) : 0 < ballMoment μ y := by apply (setIntegral_pos_iff_support_of_nonneg_ae (Eventually.of_forall fun x => abs_nonneg ⟪x,y⟫_ℝ) (ballMoment_integrable μ y)).mpr let U := {x : E | ⟪x,y⟫_ℝ ≠ 0} ∩ Metric.ball (0:E) 1 have hU : IsOpen U := (isOpen_ne.preimage (continuous_id.inner continuous_const)).inter Metric.isOpen_ball have hne : U.Nonempty := by refine ⟨(1/2:ℝ) • y, ?_, ?_⟩ · change ⟪(1/2:ℝ) • y,y⟫_ℝ ≠ 0 simp [real_inner_smul_left, hy] · simp [Metric.mem_ball, dist_zero_right, norm_smul, hy] norm_num have hm := hU.measure_pos μ hne exact lt_of_lt_of_le hm (measure_mono (by intro x hx exact ⟨by simpa only [Function.mem_support, abs_ne_zero, Set.mem_ofPred_eq] using hx.1, Metric.ball_subset_closedBall hx.2⟩)) lemma exists_ballMoment_lower [μ.IsOpenPosMeasure] [Nontrivial E] : ∃ c : ℝ, 0 < c ∧ ∀ y : E, c*‖y‖ ≤ ballMoment μ y := by have hne : (Metric.sphere (0:E) 1).Nonempty := by obtain ⟨y,hy⟩ := exists_norm_eq E (show (0:ℝ) ≤ 1 by norm_num) exact ⟨y, by simpa [Metric.mem_sphere, dist_zero_right] using hy⟩ obtain ⟨y,hy,hm⟩ := (isCompact_sphere (0:E) 1).exists_isMinOn hne (continuous_ballMoment μ).continuousOn have hyn : ‖y‖=1 := by simpa [Metric.mem_sphere, dist_zero_right] using hy refine ⟨ballMoment μ y, ballMoment_pos_of_norm_one μ hyn, ?_⟩ intro z by_cases hz : z=0 · simp [hz, ballMoment] have hnz : ‖z‖ ≠ 0 := norm_ne_zero_iff.mpr hz let w : E := ‖z‖⁻¹ • z have hwn : ‖w‖=1 := by simp [w, norm_smul, hnz] have hw : w ∈ Metric.sphere (0:E) 1 := by simpa [Metric.mem_sphere, dist_zero_right] using hwn have hh : ballMoment μ y ≤ ballMoment μ w := hm hw have hz' : ‖z‖ • w = z := by simp [w, smul_smul, hnz] calc ballMoment μ y*‖z‖ ≤ ‖z‖*ballMoment μ w := by nlinarith [norm_nonneg z] _ = ballMoment μ (‖z‖ • w) := by rw [ballMoment_smul μ ‖z‖ w, abs_of_nonneg (norm_nonneg z)] _ = ballMoment μ z := by rw [hz'] lemma exists_first_moment_lower [μ.IsOpenPosMeasure] [Nontrivial E] {d : ℝ} (hd : 0 < d) : ∃ c : ℝ, 0 < c ∧ ∀ (ρ : Measure E), ENNReal.ofReal d • μ.restrict (Metric.closedBall (0:E) 1) ≤ ρ → (∀ y : E, Integrable (fun x => |⟪x,y⟫_ℝ|) ρ) → ∀ y : E, c*‖y‖ ≤ ∫ x, |⟪x,y⟫_ℝ| ∂ρ := by obtain ⟨a,ha,ha'⟩ := exists_ballMoment_lower μ refine ⟨d*a, mul_pos hd ha, ?_⟩ intro ρ hρ hi y calc d*a*‖y‖ = d*(a*‖y‖) := by ring _ ≤ d*ballMoment μ y := mul_le_mul_of_nonneg_left (ha' y) hd.le _ = ∫ x, |⟪x,y⟫_ℝ| ∂(ENNReal.ofReal d • μ.restrict (Metric.closedBall (0:E) 1)) := by rw [integral_smul_measure, ENNReal.toReal_ofReal hd.le] rfl _ ≤ ∫ x, |⟪x,y⟫_ℝ| ∂ρ := integral_mono_measure hρ (Eventually.of_forall fun x => abs_nonneg _) (hi y) end Ball variable [MeasurableSpace E] [BorelSpace E] (μ : Measure E) [μ.IsAddHaarMeasure] lemma integrable_exp_neg_norm {c : ℝ} (hc : 0 < c) : Integrable (fun x : E => Real.exp (-c*‖x‖)) μ := by let r : ℝ := Module.finrank ℝ E + 1 have hr : (Module.finrank ℝ E : ℝ) < r := by dsimp [r]; linarith have hi : Integrable (fun x : E => (1+‖x‖)^(-r)) μ := integrable_one_add_norm hr have hl : LocallyIntegrable (fun x : E => Real.exp (-c*‖x‖)) μ := (show Continuous (fun x : E => Real.exp (-c*‖x‖)) by fun_prop).locallyIntegrable have ht : Tendsto (fun x : E => (1:ℝ)+‖x‖) (cocompact E) atTop := tendsto_atTop_add_const_left _ 1 tendsto_norm_cocompact_atTop have hO := (isLittleO_exp_neg_mul_rpow_atTop hc (-r)).isBigO.comp_tendsto ht have hO' := hO.const_mul_left (Real.exp c) have hfn : (fun x : E => Real.exp c * Real.exp (-c * (1+‖x‖))) = (fun x : E => Real.exp (-c*‖x‖)) := by funext x rw [← Real.exp_add] congr 1 ring simp only [Function.comp_apply] at hO' rw [hfn] at hO' exact hl.integrable_of_isBigO_cocompact hO' (hi.integrableAtFilter (cocompact E)) omit [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [BorelSpace E] [μ.IsAddHaarMeasure] in lemma centered_mass {φ : E → ℝ} (hn : (∫ x, Real.exp (-φ x) ∂μ)=1) : (∫ x, Real.exp (-(φ x-φ 0)) ∂μ) = Real.exp (φ 0) := by have he : (fun x => Real.exp (-(φ x-φ 0))) = (fun x => Real.exp (φ 0)*Real.exp (-φ x)) := by funext x rw [← Real.exp_add] congr 1 ring rw [he, integral_const_mul, hn, mul_one] lemma centered_integrable {φ : E → ℝ} (hφ : Continuous φ) {c d : ℝ} (hc : 0 Real.exp (-(φ x-φ 0))) μ := by refine ((integrable_exp_neg_norm μ hc).const_mul (Real.exp d)).mono' (Real.continuous_exp.comp (hφ.sub continuous_const).neg).aestronglyMeasurable ?_ exact Eventually.of_forall fun x => by rw [Real.norm_eq_abs, abs_of_pos (Real.exp_pos _), ← Real.exp_add] apply Real.exp_le_exp.mpr have := hl x linarith omit [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [BorelSpace E] [μ.IsAddHaarMeasure] in lemma centered_mass_lower {φ : E → ℝ} {S : Set E} (hS : MeasurableSet S) (hfin : μ S ≠ ⊤) {a : ℝ} (hu : ∀ x∈S, φ x-φ 0 ≤ a) (hi : Integrable (fun x => Real.exp (-(φ x-φ 0))) μ) : Real.exp (-a)*μ.real S ≤ ∫ x, Real.exp (-(φ x-φ 0)) ∂μ := by let : IsFiniteMeasure (μ.restrict S) := ⟨by simpa using lt_top_iff_ne_top.mpr hfin⟩ have h₁ : (∫ x in S, Real.exp (-a) ∂μ) ≤ ∫ x in S, Real.exp (-(φ x-φ 0)) ∂μ := by apply integral_mono_ae (integrable_const _) hi.restrict filter_upwards [ae_restrict_mem hS] with x hx exact Real.exp_le_exp.mpr (by linarith [hu x hx]) have h₂ : (∫ x in S, Real.exp (-(φ x-φ 0)) ∂μ) ≤ ∫ x, Real.exp (-(φ x-φ 0)) ∂μ := integral_mono_measure Measure.restrict_le_self (Eventually.of_forall fun x => (Real.exp_pos _).le) hi simpa [setIntegral_const, mul_comm] using h₁.trans h₂ lemma uniform_density_majorant {φ : E → ℝ} (hφ : Continuous φ) (hn : (∫ x, Real.exp (-φ x) ∂μ)=1) {S : Set E} (hS : MeasurableSet S) (hfin : μ S ≠ ⊤) (hpos : 0<μ.real S) {a c d : ℝ} (hc : 0 Real.exp (-V x)) μ) : ∃ d > 0, ∀ R : ℝ, 2 ≤ R → ENNReal.ofReal d • μ.restrict (Metric.closedBall (0:E) 1) ≤ target μ R V := by let Z := ∫ x, Real.exp (-V x) ∂μ have hZ : 0 ?_⟩ have hRp : 0 (Real.exp_pos (-V x)).le) hI rw [target,← withDensity_const,← withDensity_indicator measurableSet_closedBall, ← withDensity_indicator measurableSet_ball] apply withDensity_mono filter_upwards [] with x by_cases hx : x ∈ Metric.closedBall (0:E) 1 · have hxb : x ∈ Metric.ball (0:E) R := Metric.mem_ball.mpr ((Metric.mem_closedBall.mp hx).trans_lt (by linarith)) rw [indicator_of_mem hx,indicator_of_mem hxb] apply ENNReal.ofReal_le_ofReal exact (div_le_div_of_nonneg_right (Real.exp_le_exp.mpr (neg_le_neg (hM (mem_image_of_mem _ hx)))) hZ.le).trans (div_le_div_of_nonneg_left (Real.exp_pos _).le hZR hpart) · rw [indicator_of_notMem hx] exact bot_le end TruncatedMoment namespace CompactMomentVariational open MeasureTheory Set Filter open scoped InnerProductSpace variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] variable (μ : Measure E) [μ.IsAddHaarMeasure] variable {ι : Type*} [Fintype ι] omit [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [BorelSpace E] [μ.IsAddHaarMeasure] in lemma integral_density_one {φ : E → ℝ} (hI : Integrable (fun x => Real.exp (-φ x)) μ) [hp : IsProbabilityMeasure (μ.withDensity (fun x => ENNReal.ofReal (Real.exp (-φ x))))] : (∫ x, Real.exp (-φ x) ∂μ)=1 := by have he := measure_univ (μ:=μ.withDensity (fun x => ENNReal.ofReal (Real.exp (-φ x)))) rw [withDensity_apply _ MeasurableSet.univ,Measure.restrict_univ, ← ofReal_integral_eq_lintegral_ofReal hI (Eventually.of_forall fun x => (Real.exp_pos (-φ x)).le)] at he exact ENNReal.ofReal_eq_one.mp he lemma weighted_gradient_moment_integrable {φ : E → ℝ} (hφ : ContDiff ℝ 1 φ) {R : ℝ≥0} (hl : LipschitzWith R φ) (hcont : Continuous (gradient φ)) (hc : ∃ c > 0, ∃ d : ℝ, ∀ x, c*‖x‖-d ≤ φ x) : Integrable (fun x => ⟪gradient φ x,x⟫_ℝ) (μ.withDensity (fun x => ENNReal.ofReal (Real.exp (-φ x)))) := by obtain ⟨c,hc,d,ht⟩ := hc have hφc := hφ.continuous have hm : Measurable (fun x => ENNReal.ofReal (Real.exp (-φ x))) := by fun_prop rw [integrable_withDensity_iff hm (Eventually.of_forall fun _ => ENNReal.ofReal_lt_top)] simp only [ENNReal.toReal_ofReal (Real.exp_pos _).le] exact SourceIdentity.gradient_moment_integrable μ hφ.continuous hcont (norm_gradient_le_lipschitz hl) (SourceIdentity.integrable_norm_density μ hφ.continuous hc ht (integrable_exp_neg_norm μ (by positivity))) lemma weighted_gradient_identity (b : OrthonormalBasis ι ℝ E) {φ : E → ℝ} (hφ : ContDiff ℝ 1 φ) {R : ℝ≥0} (hl : LipschitzWith R φ) (hcont : Continuous (gradient φ)) (hc : ∃ c > 0, ∃ d : ℝ, ∀ x, c*‖x‖-d ≤ φ x) [IsProbabilityMeasure (μ.withDensity (fun x => ENNReal.ofReal (Real.exp (-φ x))))] : (∫ x, ⟪gradient φ x,x⟫_ℝ ∂μ.withDensity (fun x => ENNReal.ofReal (Real.exp (-φ x)))) = Fintype.card ι := by obtain ⟨c,hc,d,ht⟩ := hc have hI := tail_integrable μ hφ.continuous hc ht exact SourceIdentity.weighted_identity μ b (fun x => (hφ.differentiable (by norm_num) x).hasGradientAt.hasFDerivAt) hcont (norm_gradient_le_lipschitz hl) hI (SourceIdentity.integrable_norm_density μ hφ.continuous hc ht (integrable_exp_neg_norm μ (by positivity))) (integral_density_one μ hI) lemma target_first_moment_integrable {V : E → ℝ} (hV : Continuous V) {R : ℝ} (hR : 0 |⟪x,y⟫_ℝ|) (TruncatedMoment.target μ R V) := by let : IsProbabilityMeasure (TruncatedMoment.target μ R V) := TruncatedMoment.probability μ hV hR apply (integrable_const (R*‖y‖)).mono' (by fun_prop) filter_upwards [TruncatedMoment.ae_mem_ball μ V R] with x hx simp only [Real.norm_eq_abs,abs_abs] exact (abs_real_inner_le_norm _ _).trans (mul_le_mul_of_nonneg_right (by simpa [dist_zero_right] using (Metric.mem_ball.mp hx).le) (norm_nonneg _)) lemma uniform_centered_coercivity [Nontrivial E] (b : OrthonormalBasis ι ℝ E) {V : E → ℝ} (hV : Continuous V) (hI : Integrable (fun x => Real.exp (-V x)) μ) : ∃ c > 0, ∀ (R : ℝ≥0), 2 ≤ R → ∀ (φ : E → ℝ), ConvexOn ℝ univ φ → Function.Even φ → LipschitzWith R φ → ContDiff ℝ 1 φ → Continuous (gradient φ) → (∃ a > 0, ∃ d : ℝ, ∀ x, a*‖x‖-d ≤ φ x) → IsProbabilityMeasure (μ.withDensity (fun x => ENNReal.ofReal (Real.exp (-φ x)))) → Measure.map (gradient φ) (μ.withDensity (fun x => ENNReal.ofReal (Real.exp (-φ x)))) = TruncatedMoment.target μ R V → ∀ y, c*‖y‖-Fintype.card ι ≤ φ y-φ 0 := by obtain ⟨d,hd,hlow⟩ := TruncatedMoment.uniform_density_lower μ hV hI obtain ⟨c,hc,hc'⟩ := UniformMoment.exists_first_moment_lower μ hd refine ⟨c,hc,fun R hR φ hcv hev hl hφ hcont htail hp hm y => ?_⟩ let := hp apply UniformMoment.uniform_coercivity _ hcv hev (fun x => (hφ.differentiable (by norm_num) x).hasGradientAt) hcont (weighted_gradient_moment_integrable μ hφ hl hcont htail) (weighted_gradient_identity μ b hφ hl hcont htail) _ y intro z specialize hc' (TruncatedMoment.target μ R V) (hlow R hR) (target_first_moment_integrable μ hV (by positivity)) z rw [← hm,integral_map hcont.aemeasurable (by fun_prop)] at hc' exact hc' end CompactMomentVariational namespace UniformMoment open Set MeasureTheory Filter open scoped InnerProductSpace Topology variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] omit [InnerProductSpace ℝ E] in lemma centered_upper_of_secondDiff {φ : E → ℝ} (he : Function.Even φ) {C : ℝ} (hd : ∀ h z, φ (z+h)+φ (z-h)-2*φ z ≤ C*‖h‖^2) (x : E) : φ x-φ 0 ≤ C/2*‖x‖^2 := by have hh := hd x 0 simp only [zero_add,zero_sub,he x] at hh linarith variable [FiniteDimensional ℝ E] lemma gradient_zero_at_origin {φ : E → ℝ} (hc : ConvexOn ℝ univ φ) (he : Function.Even φ) : gradient φ 0=0 := by have hm : IsLocalMin φ 0 := Filter.Eventually.of_forall (even_convex_min hc he) simp only [gradient,hm.fderiv_eq_zero,map_zero] variable [MeasurableSpace E] [BorelSpace E] (μ : Measure E) [μ.IsAddHaarMeasure] lemma centered_normalization_bounds {c d C : ℝ} (hc : 0 uniform_density_majorant μ hφ hn hS hf hp hc hl hus x⟩ · simpa only [Real.log_exp] using Real.log_le_log hA hlow · simpa only [Real.log_exp] using Real.log_le_log (Real.exp_pos _) hupp end UniformMoment namespace C11Compactness open Set Filter open scoped Topology NNReal InnerProductSpace variable {E : Type*} {F : Type*} [NormedAddCommGroup E] [NormedAddCommGroup F] [ProperSpace F] def normalizedLipschitz (R : ℝ≥0) : Set C(E,F) := {f | LipschitzWith R f ∧ f 0=0} omit [ProperSpace F] in lemma normalizedLipschitz_pointwise (R : ℝ≥0) : ContinuousMap.toFun '' (normalizedLipschitz (E:=E) (F:=F) R) = {f : E → F | LipschitzWith R f ∧ f 0=0} := by ext f constructor · rintro ⟨g,hg,rfl⟩ exact hg · intro hf exact ⟨⟨f,hf.1.continuous⟩,hf,rfl⟩ lemma normalizedLipschitz_compact (R : ℝ≥0) : IsCompact (normalizedLipschitz (E:=E) (F:=F) R) := by apply ArzelaAscoli.isCompact_of_equicontinuous · rw [normalizedLipschitz_pointwise] apply (isCompact_pi_infinite (fun x : E => isCompact_closedBall (0:F) ((R:ℝ)*‖x‖))).of_isClosed_subset · exact (isClosed_setOfPred_lipschitzWith R).inter (isClosed_eq (continuous_apply 0) continuous_const) · intro f hf x have h := hf.1.dist_le_mul x 0 simpa only [hf.2,Metric.mem_closedBall,dist_zero_right] using h · exact Metric.equicontinuous_of_continuity_modulus (fun r : ℝ => (R:ℝ)*r) (by simpa using (show Continuous (fun r : ℝ => (R:ℝ)*r) by fun_prop).tendsto 0) _ (fun x y f => f.property.1.dist_le_mul x y) section Normed variable [NormedSpace ℝ E] lemma normalizedLipschitz_subsequence [FiniteDimensional ℝ E] {R : ℝ≥0} {f : ℕ → E → F} (hl : ∀ k, LipschitzWith R (f k)) (h0 : ∀ k, f k 0=0) : ∃ (g : E → F) (s : ℕ → ℕ), LipschitzWith R g ∧ g 0=0 ∧ StrictMono s ∧ TendstoLocallyUniformly (fun k => f (s k)) g atTop := by let Fs : ℕ → C(E,F) := fun k => ⟨f k,(hl k).continuous⟩ have hm : ∀ k, Fs k ∈ normalizedLipschitz R := fun k => ⟨hl k,h0 k⟩ obtain ⟨g,hg,s,hs,ht⟩ := (normalizedLipschitz_compact (E:=E) (F:=F) R).tendsto_subseq hm refine ⟨g,s,hg.1,hg.2,hs,?_⟩ exact ContinuousMap.tendsto_iff_tendstoLocallyUniformly.mp ht end Normed variable [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] omit [NormedAddCommGroup F] [ProperSpace F] in lemma pointwise_cauchy_of_gradient {fs : ℕ → E → ℝ} {Gs : ℕ → E → E} {G : E → E} (hd : ∀ n x, HasFDerivAt (fs n) (innerSL ℝ (Gs n x)) x) (ht : TendstoLocallyUniformly Gs G atTop) (h0 : CauchySeq (fun n => fs n 0)) (x : E) : CauchySeq (fun n => fs n x) := by have ht' := (innerSL ℝ (E:=E)).uniformContinuous.comp_tendstoLocallyUniformly ht have hh : TendstoUniformlyOn (fun n z => innerSL ℝ (Gs n z)) (fun z => innerSL ℝ (G z)) atTop (Metric.closedBall (0:E) (‖x‖+1)) := (tendstoLocallyUniformlyOn_iff_tendstoUniformlyOn_of_compact (isCompact_closedBall _ _)).mp ht'.tendstoLocallyUniformlyOn exact cauchy_map_of_uniformCauchySeqOn_fderiv Metric.isOpen_ball (convex_ball 0 (‖x‖+1)).isPreconnected (hh.uniformCauchySeqOn.mono Metric.ball_subset_closedBall) (fun n z _ => hd n z) (by simp [Metric.mem_ball]; positivity) (by simp [Metric.mem_ball,dist_zero_right]) h0 omit [NormedAddCommGroup F] [ProperSpace F] in lemma subsequence {fs : ℕ → E → ℝ} {Gs : ℕ → E → E} {L : ℝ≥0} {a b : ℝ} (hd : ∀ n x, HasFDerivAt (fs n) (innerSL ℝ (Gs n x)) x) (hl : ∀ n, LipschitzWith L (Gs n)) (h0 : ∀ n, Gs n 0=0) (hb : ∀ n, fs n 0 ∈ Icc a b) : ∃ (f : E → ℝ) (G : E → E) (s : ℕ → ℕ), StrictMono s ∧ LipschitzWith L G ∧ G 0=0 ∧ f 0 ∈ Icc a b ∧ (∀ x, HasFDerivAt f (innerSL ℝ (G x)) x) ∧ ContDiff ℝ 1 f ∧ (∀ x, Tendsto (fun n => fs (s n) x) atTop (𝓝 (f x))) ∧ TendstoLocallyUniformly (fun n => Gs (s n)) G atTop := by obtain ⟨m,hm,s₀,hs₀,ht₀⟩ := isCompact_Icc.tendsto_subseq hb obtain ⟨G,s₁,hG,hG0,hs₁,htG⟩ := normalizedLipschitz_subsequence (fun n => hl (s₀ n)) (fun n => h0 (s₀ n)) let s := s₀ ∘ s₁ have h0t : Tendsto (fun n => fs (s n) 0) atTop (𝓝 m) := ht₀.comp hs₁.tendsto_atTop have hf : ∀ x, ∃ y, Tendsto (fun n => fs (s n) x) atTop (𝓝 y) := fun x => cauchySeq_tendsto_of_complete (pointwise_cauchy_of_gradient (fun n z => hd (s n) z) htG h0t.cauchy_map x) choose f hft using hf have hdf : ∀ x, HasFDerivAt f (innerSL ℝ (G x)) x := by intro x exact hasFDerivAt_of_tendstoLocallyUniformlyOn isOpen_univ ((innerSL ℝ (E:=E)).uniformContinuous.comp_tendstoLocallyUniformly htG).tendstoLocallyUniformlyOn (fun n z _ => hd (s n) z) (fun z _ => hft z) (mem_univ x) refine ⟨f,G,s,hs₀.comp hs₁,hG,hG0,?_,hdf,?_,hft,htG⟩ · have he : f 0=m := tendsto_nhds_unique (hft 0) h0t simpa [he] using hm · rw [contDiff_one_iff_fderiv] refine ⟨fun x => (hdf x).differentiableAt,?_⟩ have he : fderiv ℝ f = fun x => innerSL ℝ (G x) := funext fun x => (hdf x).fderiv rw [he] exact (innerSL ℝ (E:=E)).continuous.comp hG.continuous end C11Compactness end open Set MeasureTheory Filter open scoped Topology BoundedContinuousFunction namespace MomentLimits noncomputable section variable {E : Type*} [NormedAddCommGroup E] [MeasurableSpace E] [BorelSpace E] (μ : Measure E) def density (φ : E → ℝ) (x : E) : ℝ := Real.exp (-φ x) def source (φ : E → ℝ) : Measure E := μ.withDensity (fun x => ENNReal.ofReal (density φ x)) omit [MeasurableSpace E] [BorelSpace E] in lemma continuous_density {φ : E → ℝ} (hφ : Continuous φ) : Continuous (density φ) := Real.continuous_exp.comp hφ.neg lemma integral_source {φ : E → ℝ} (hφ : Continuous φ) (f : E → ℝ) : (∫ x, f x ∂source μ φ) = ∫ x, density φ x*f x ∂μ := by rw [source, integral_withDensity_eq_integral_toReal_smul (continuous_density hφ).measurable.ennreal_ofReal (Eventually.of_forall fun _ => ENNReal.ofReal_lt_top)] simp only [density, ENNReal.toReal_ofReal (Real.exp_pos _).le, smul_eq_mul] omit [NormedAddCommGroup E] [BorelSpace E] in lemma source_finite {φ : E → ℝ} (hi : Integrable (density φ) μ) : IsFiniteMeasure (source μ φ) := isFiniteMeasure_withDensity_ofReal hi.2 lemma integral_density_tendsto {φs : ℕ → E → ℝ} {φ : E → ℝ} {M : E → ℝ} (hc : ∀ n, Continuous (φs n)) (hi : Integrable M μ) (hb : ∀ n x, density (φs n) x ≤ M x) (ht : ∀ x, Tendsto (fun n => φs n x) atTop (𝓝 (φ x))) : Tendsto (fun n => ∫ x, density (φs n) x ∂μ) atTop (𝓝 (∫ x, density φ x ∂μ)) := by apply tendsto_integral_of_dominated_convergence M (fun n => (continuous_density (hc n)).aestronglyMeasurable) hi · intro n exact Eventually.of_forall fun x => by simpa [density, Real.norm_eq_abs, abs_of_pos (Real.exp_pos _)] using hb n x · exact Eventually.of_forall fun x => Real.continuous_exp.continuousAt.tendsto.comp (ht x).neg omit [NormedAddCommGroup E] [MeasurableSpace E] [BorelSpace E] in lemma density_le_limit_bound {φs : ℕ → E → ℝ} {φ : E → ℝ} {M : E → ℝ} (hb : ∀ n x, density (φs n) x ≤ M x) (ht : ∀ x, Tendsto (fun n => φs n x) atTop (𝓝 (φ x))) (x : E) : density φ x ≤ M x := by apply le_of_tendsto' (Real.continuous_exp.continuousAt.tendsto.comp (ht x).neg) exact fun n => hb n x lemma density_integrable_limit {φs : ℕ → E → ℝ} {φ : E → ℝ} {M : E → ℝ} (hφ : Continuous φ) (hi : Integrable M μ) (hb : ∀ n x, density (φs n) x ≤ M x) (ht : ∀ x, Tendsto (fun n => φs n x) atTop (𝓝 (φ x))) : Integrable (density φ) μ := by apply hi.mono' (continuous_density hφ).aestronglyMeasurable exact Eventually.of_forall fun x => by simpa [density, Real.norm_eq_abs, abs_of_pos (Real.exp_pos _)] using density_le_limit_bound hb ht x lemma density_integral_one {φs : ℕ → E → ℝ} {φ : E → ℝ} {M : E → ℝ} (hc : ∀ n, Continuous (φs n)) (hi : Integrable M μ) (hb : ∀ n x, density (φs n) x ≤ M x) (ht : ∀ x, Tendsto (fun n => φs n x) atTop (𝓝 (φ x))) (hn : ∀ n, (∫ x, density (φs n) x ∂μ)=1) : (∫ x, density φ x ∂μ)=1 := by have h := integral_density_tendsto μ hc hi hb ht simp only [hn] at h exact tendsto_nhds_unique h tendsto_const_nhds omit [NormedAddCommGroup E] [BorelSpace E] in lemma source_probability {φ : E → ℝ} (hi : Integrable (density φ) μ) (hn : (∫ x, density φ x ∂μ)=1) : IsProbabilityMeasure (source μ φ) := by constructor rw [source, withDensity_apply _ MeasurableSet.univ, Measure.restrict_univ] rw [← ofReal_integral_eq_lintegral_ofReal hi (Eventually.of_forall fun x => (Real.exp_pos (-φ x)).le), hn] simp lemma integral_composed_tendsto {φs : ℕ → E → ℝ} {φ : E → ℝ} {Gs : ℕ → E → E} {G : E → E} {M : E → ℝ} (hc : ∀ n, Continuous (φs n)) (hGs : ∀ n, Continuous (Gs n)) (hi : Integrable M μ) (hb : ∀ n x, density (φs n) x ≤ M x) (ht : ∀ x, Tendsto (fun n => φs n x) atTop (𝓝 (φ x))) (hGt : ∀ x, Tendsto (fun n => Gs n x) atTop (𝓝 (G x))) (f : E →ᵇ ℝ) : Tendsto (fun n => ∫ x, density (φs n) x*f (Gs n x) ∂μ) atTop (𝓝 (∫ x, density φ x*f (G x) ∂μ)) := by apply tendsto_integral_of_dominated_convergence (fun x => M x*‖f‖) (fun n => ((continuous_density (hc n)).mul (f.continuous.comp (hGs n))).aestronglyMeasurable) (hi.mul_const ‖f‖) · intro n exact Eventually.of_forall fun x => by change ‖density (φs n) x * f (Gs n x)‖ ≤ M x * ‖f‖ rw [norm_mul, Real.norm_eq_abs] rw [abs_of_pos (show 0 < density (φs n) x from Real.exp_pos _)] exact mul_le_mul (hb n x) (f.norm_coe_le_norm _) (norm_nonneg _) ((Real.exp_pos _).le.trans (hb n x)) · exact Eventually.of_forall fun x => (Real.continuous_exp.continuousAt.tendsto.comp (ht x).neg).mul (f.continuous.continuousAt.tendsto.comp (hGt x)) theorem map_source_limit {φs : ℕ → E → ℝ} {φ : E → ℝ} {Gs : ℕ → E → E} {G : E → E} {M : E → ℝ} (hc : ∀ n, Continuous (φs n)) (hφ : Continuous φ) (hGs : ∀ n, Continuous (Gs n)) (hG : Continuous G) (hi : Integrable M μ) (hb : ∀ n x, density (φs n) x ≤ M x) (ht : ∀ x, Tendsto (fun n => φs n x) atTop (𝓝 (φ x))) (hGt : ∀ x, Tendsto (fun n => Gs n x) atTop (𝓝 (G x))) (νs : ℕ → Measure E) (ν : Measure E) [IsFiniteMeasure ν] (hm : ∀ n, Measure.map (Gs n) (source μ (φs n))=νs n) (hw : ∀ f : E →ᵇ ℝ, Tendsto (fun n => ∫ x, f x ∂νs n) atTop (𝓝 (∫ x, f x ∂ν))) : Measure.map G (source μ φ)=ν := by have hif := density_integrable_limit μ hφ hi hb ht let : IsFiniteMeasure (source μ φ) := source_finite μ hif have his n : Integrable (density (φs n)) μ := by apply hi.mono' (continuous_density (hc n)).aestronglyMeasurable exact Eventually.of_forall fun x => by simpa [density, Real.norm_eq_abs, abs_of_pos (Real.exp_pos _)] using hb n x apply ext_of_forall_integral_eq_of_IsFiniteMeasure intro f have hln := integral_composed_tendsto μ hc hGs hi hb ht hGt f have hneq (n : ℕ) : (∫ x, density (φs n) x*f (Gs n x) ∂μ) = ∫ x, f x ∂νs n := by let : IsFiniteMeasure (source μ (φs n)) := source_finite μ (his n) rw [← hm n, integral_map (hGs n).aemeasurable f.continuous.aestronglyMeasurable, integral_source μ (hc n)] have heq : (∫ x, density φ x*f (G x) ∂μ) = ∫ x, f x ∂ν := by simp only [hneq] at hln exact tendsto_nhds_unique hln (hw f) rw [integral_map hG.aemeasurable f.continuous.aestronglyMeasurable, integral_source μ hφ, heq] lemma normalized_exhaustion {w : E → ℝ} (hi : Integrable w μ) (hne : (∫ x, w x ∂μ) ≠ 0) (S : ℕ → Set E) (hS : ∀ n, MeasurableSet (S n)) (hinc : Monotone S) (hexh : (⋃ n, S n)=univ) (f : E →ᵇ ℝ) : Tendsto (fun n => (∫ x in S n, w x*f x ∂μ)/(∫ x in S n, w x ∂μ)) atTop (𝓝 ((∫ x, w x*f x ∂μ)/(∫ x, w x ∂μ))) := by have hif : Integrable (fun x => w x*f x) μ := by apply (hi.norm.mul_const ‖f‖).mono' (hi.aestronglyMeasurable.mul f.continuous.aestronglyMeasurable) exact Eventually.of_forall fun x => by change ‖w x * f x‖ ≤ ‖w x‖ * ‖f‖ rw [norm_mul] exact mul_le_mul_of_nonneg_left (f.norm_coe_le_norm x) (norm_nonneg _) have h₁ := tendsto_setIntegral_of_monotone hS hinc (hif.integrableOn (s:=⋃ n, S n)) have h₂ := tendsto_setIntegral_of_monotone hS hinc (hi.integrableOn (s:=⋃ n, S n)) simp only [hexh, Measure.restrict_univ] at h₁ h₂ exact h₁.div h₂ hne end end MomentLimits open Set MeasureTheory Filter open scoped InnerProductSpace Topology noncomputable section namespace GlobalMoment variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] lemma supporting_plane {φ : E → ℝ} {G : E → E} (hc : ConvexOn ℝ Set.univ φ) (hG : ∀ x, HasGradientAt φ (G x) x) (z x : E) : φ z + ⟪G z, x-z⟫_ℝ ≤ φ x := by let a : ℝ →ᵃ[ℝ] E := AffineMap.lineMap z x have hc' : ConvexOn ℝ Set.univ (φ ∘ a) := by simpa only [Set.preimage_univ] using hc.comp_affineMap a have hd : HasDerivAt (φ ∘ a) ⟪G z, x-z⟫_ℝ 0 := by have hz : HasFDerivAt φ ((InnerProductSpace.toDual ℝ E) (G z)) (a 0) := by simpa [a] using (hG z).hasFDerivAt exact hz.comp_hasDerivAt 0 AffineMap.hasDerivAt_lineMap have hh := hc'.le_slope_of_hasDerivAt (Set.mem_univ (0 : ℝ)) (Set.mem_univ (1 : ℝ)) (by norm_num) hd simp [slope, a] at hh linarith lemma tilted_potential_coercive {φ : E → ℝ} {G : E → E} (hc : ConvexOn ℝ univ φ) (hG : ∀ x, HasGradientAt φ (G x) x) (hd : DenseRange G) (x₀ : E) : ∃ b : ℝ, ∀ y : E, ‖y‖-b ≤ φ y-⟪x₀,y⟫_ℝ := by classical let U : E → Set E := fun z => {u | 1 < ⟪G z-x₀,u⟫_ℝ} have hU : ∀ z, IsOpen (U z) := fun z => isOpen_lt continuous_const (continuous_const.inner continuous_id) have hcover : Metric.sphere (0:E) 1 ⊆ ⋃ z, U z := by intro u hu have hun : ‖u‖=1 := by simpa [Metric.mem_sphere, dist_zero_right] using hu obtain ⟨z,hz⟩ := hd.exists_dist_lt (x₀+(2:ℝ) • u) (show (0:ℝ)<1/2 by norm_num) rw [dist_comm, dist_eq_norm] at hz have hh := abs_real_inner_le_norm (G z-(x₀+(2:ℝ) • u)) u rw [hun, mul_one, inner_sub_left, inner_add_left, real_inner_smul_left] at hh have huin : ⟪u,u⟫_ℝ=1 := by simp [hun] rw [huin] at hh refine mem_iUnion.mpr ⟨z, ?_⟩ change 1 < ⟪G z-x₀,u⟫_ℝ rw [inner_sub_left] have := (abs_le.mp hh).1 linarith obtain ⟨s,hs⟩ := (isCompact_sphere (0:E) 1).elim_finite_subcover U hU hcover let β : E → ℝ := fun z => φ z-⟪G z,z⟫_ℝ let b : ℝ := |φ 0| + ∑ z ∈ s, |β z| have hsum : 0 ≤ ∑ z ∈ s, |β z| := Finset.sum_nonneg fun _ _ => abs_nonneg _ refine ⟨b, ?_⟩ intro y by_cases hy : y=0 · subst y simp only [norm_zero, inner_zero_right, sub_zero, zero_sub] dsimp [b] nlinarith [neg_abs_le (φ 0)] have hn : ‖y‖ ≠ 0 := norm_ne_zero_iff.mpr hy let u : E := ‖y‖⁻¹ • y have hun : ‖u‖=1 := by simp [u, norm_smul, hn] have hu : u ∈ Metric.sphere (0:E) 1 := by simpa [Metric.mem_sphere, dist_zero_right] using hun obtain ⟨z,hz⟩ := mem_iUnion.mp (hs hu) obtain ⟨hzs,hzu⟩ := mem_iUnion.mp hz have hβ := Finset.single_le_sum (fun z _ => abs_nonneg (β z)) hzs have hβ' : -b ≤ β z := by dsimp [b] nlinarith [neg_abs_le (β z), abs_nonneg (φ 0)] have hsupport := supporting_plane hc hG z y rw [inner_sub_right] at hsupport have hyu : y = ‖y‖ • u := by simp [u, smul_smul, hn] have hg : ‖y‖ ≤ ⟪G z-x₀,y⟫_ℝ := by conv_rhs => rw [hyu, inner_smul_right] have hzu' : 1 < ⟪G z-x₀,u⟫_ℝ := hzu nlinarith [norm_nonneg y] rw [inner_sub_left] at hg dsimp [β] at hβ' linarith theorem gradient_surjective_of_dense {φ : E → ℝ} {G : E → E} (hc : ConvexOn ℝ univ φ) (hG : ∀ x, HasGradientAt φ (G x) x) (hd : DenseRange G) : Function.Surjective G := by intro x₀ obtain ⟨b,hb⟩ := tilted_potential_coercive hc hG hd x₀ let f : E → ℝ := fun y => φ y-⟪x₀,y⟫_ℝ have hφc : Continuous φ := continuous_iff_continuousAt.mpr fun x => (hG x).hasFDerivAt.continuousAt have hfc : Continuous f := hφc.sub (continuous_const.inner continuous_id) have hlarge : ∀ᶠ y : E in cocompact E, f 0 ≤ f y := by have hn : ∀ᶠ y : E in cocompact E, f 0+b ≤ ‖y‖ := tendsto_norm_cocompact_atTop.eventually (eventually_ge_atTop (f 0+b)) filter_upwards [hn] with y hy have := hb y change f 0 ≤ f y change ‖y‖-b ≤ f y at this linarith obtain ⟨z,hz⟩ := hfc.exists_forall_le' 0 hlarge have hmin : IsLocalMin f z := (isMinOn_univ_iff.mpr hz).isLocalMin (by simp) have hfder : HasFDerivAt f ((InnerProductSpace.toDual ℝ E) (G z) - (InnerProductSpace.toDual ℝ E) x₀) z := by exact (hG z).hasFDerivAt.sub ((InnerProductSpace.toDual ℝ E) x₀).hasFDerivAt have heq := hmin.hasFDerivAt_eq_zero hfder refine ⟨z, ?_⟩ exact (InnerProductSpace.toDual ℝ E).injective (sub_eq_zero.mp heq) variable [MeasurableSpace E] [BorelSpace E] omit [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] in lemma denseRange_of_pushforward (ν μ : Measure E) [μ.IsOpenPosMeasure] {G : E → E} (hG : Continuous G) (hm : Measure.map G ν = μ) : DenseRange G := by rw [Metric.denseRange_iff] intro x r hr have hpos : 0 < ν (G ⁻¹' Metric.ball x r) := by rw [← Measure.map_apply hG.measurable measurableSet_ball, hm] exact Metric.isOpen_ball.measure_pos μ (Metric.nonempty_ball.mpr hr) have hne : (G ⁻¹' Metric.ball x r).Nonempty := nonempty_of_measure_ne_zero hpos.ne' obtain ⟨z,hz⟩ := hne exact ⟨z, by simpa [Metric.mem_ball, dist_comm] using hz⟩ theorem gradient_surjective_of_pushforward (ν μ : Measure E) [μ.IsOpenPosMeasure] {φ : E → ℝ} {G : E → E} (hc : ConvexOn ℝ univ φ) (hG : ∀ x, HasGradientAt φ (G x) x) (hGc : Continuous G) (hm : Measure.map G ν = μ) : Function.Surjective G := gradient_surjective_of_dense hc hG (denseRange_of_pushforward ν μ hGc hm) end GlobalMoment namespace CompactMomentVariational section open MeasureTheory Set Filter open scoped InnerProductSpace Topology BoundedContinuousFunction NNReal variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] variable (μ : Measure E) [μ.IsAddHaarMeasure] variable {ι : Type*} [Fintype ι] [DecidableEq ι] omit [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] in lemma normalizedSource_openPos {V : E → ℝ} (hV : Continuous V) (hI : Integrable (fun x => Real.exp (-V x)) μ) : (normalizedSource μ V).IsOpenPosMeasure := by have hp := integral_exp_pos hI have hm : Measurable (fun x => ENNReal.ofReal (Real.exp (-V x)/(∫ y,Real.exp (-V y) ∂μ))) := by fun_prop have ha : μ ≪ normalizedSource μ V := withDensity_absolutelyContinuous' hm.aemeasurable (Eventually.of_forall fun x => (ENNReal.ofReal_pos.mpr (div_pos (Real.exp_pos _) hp)).ne') exact ⟨fun U hU hn hz => hU.measure_ne_zero μ hn (ha hz)⟩ lemma integral_truncated_target {V : E → ℝ} (hV : Continuous V) {R : ℝ} (hR : 0 ENNReal.ofReal (Real.exp (-V x)/TruncatedMoment.partition μ R V)) := by fun_prop rw [TruncatedMoment.target,integral_withDensity_eq_integral_toReal_smul hm (Eventually.of_forall fun _ => ENNReal.ofReal_lt_top)] simp_rw [ENNReal.toReal_ofReal (div_nonneg (Real.exp_pos _).le hZ.le),smul_eq_mul] rw [← integral_div] congr 1 funext x ring lemma truncated_target_tendsto {V : E → ℝ} (hV : Continuous V) (hI : Integrable (fun x => Real.exp (-V x)) μ) (f : E →ᵇ ℝ) : Tendsto (fun n : ℕ => ∫ x, f x ∂TruncatedMoment.target μ ((n:ℝ)+2) V) atTop (𝓝 (∫ x, f x ∂normalizedSource μ V)) := by have ht := MomentLimits.normalized_exhaustion μ hI (integral_exp_pos hI).ne' (fun n : ℕ => Metric.ball (0:E) ((n:ℝ)+2)) (fun _ => measurableSet_ball) (fun n m hnm => Metric.ball_subset_ball (by exact_mod_cast Nat.add_le_add_right hnm 2)) have he : (⋃ n : ℕ, Metric.ball (0:E) ((n:ℝ)+2))=univ := by apply eq_univ_of_forall intro x obtain ⟨n,hn⟩ := exists_nat_gt ‖x‖ apply mem_iUnion.mpr exact ⟨n,by simp only [Metric.mem_ball,dist_zero_right]; linarith⟩ specialize ht he f have heq (n : ℕ) := integral_truncated_target μ hV (show 0<(n:ℝ)+2 by positivity) f simp_rw [heq] rw [integral_normalizedSource μ hV.measurable hI] have hn : (∫ x, f x * Real.exp (-V x) ∂μ) = ∫ x, Real.exp (-V x) * f x ∂μ := integral_congr_ae (Eventually.of_forall fun x => mul_comm _ _) rw [hn] exact ht theorem exists_C11_global [Nontrivial E] (b : OrthonormalBasis ι ℝ E) {V : E → ℝ} (hV : Continuous V) (hVe : Function.Even V) (hI : Integrable (fun x => Real.exp (-V x)) μ) {ε : ℝ} (hε : 0<ε) (hcurv : ∀ x y, ε/8*‖x-y‖^2 ≤ (V x+V y)/2-V ((1/2:ℝ) • (x+y))) : ∃ φ : E → ℝ, ConvexOn ℝ univ φ ∧ Function.Even φ ∧ ContDiff ℝ 1 φ ∧ LipschitzWith (Real.toNNReal (16/ε)) (gradient φ) ∧ (∀ h z, WeakMomentBound.secondDiff φ h z ≤ 4/ε*‖h‖^2) ∧ (∃ c > 0, ∃ d : ℝ, ∀ z, c*‖z‖-d ≤ φ z) ∧ IsProbabilityMeasure (μ.withDensity (fun z => ENNReal.ofReal (Real.exp (-φ z)))) ∧ Measure.map (gradient φ) (μ.withDensity (fun z => ENNReal.ofReal (Real.exp (-φ z)))) = normalizedSource μ V ∧ Function.Surjective (gradient φ) := by classical let R : ℕ → ℝ≥0 := fun n => n+2 have hRp (n) : 0 exists_C11_truncated μ b hV hVe hε hcurv (hRp n)) obtain ⟨c,hc,hcoer⟩ := uniform_centered_coercivity μ b hV hI have hlow n x : c*‖x‖-Fintype.card ι ≤ fs n x-fs n 0 := hcoer (R n) (by change (2:ℝ) ≤ (n:ℝ)+2; linarith [Nat.cast_nonneg (α:=ℝ) n]) (fs n) (hcv n) (hev n) (hl n) (hC n) (hg n).continuous (htail n) (hprob n) (hm n) x have hup n x : fs n x-fs n 0 ≤ (4/ε)/2*‖x‖^2 := UniformMoment.centered_upper_of_secondDiff (hev n) (hcap n) x have hnorm n : (∫ x,Real.exp (-fs n x) ∂μ)=1 := by let := hprob n obtain ⟨c,hc,d,hd⟩ := htail n exact integral_density_one μ (tail_integrable μ (hC n).continuous hc hd) obtain ⟨a,a',D,hD,hbound⟩ := UniformMoment.centered_normalization_bounds μ hc (show 0≤4/ε by positivity) (d:=(Fintype.card ι:ℝ)) have hbound' n := hbound (fs n) (hC n).continuous (hnorm n) (hlow n) (hup n) obtain ⟨φ,G,s,hs,hG,hG0,hφ0,hdf,hφ,hft,hGt⟩ := C11Compactness.subsequence (fun n x => ((hC n).differentiable (by norm_num) x).hasGradientAt.hasFDerivAt) hg (fun n => UniformMoment.gradient_zero_at_origin (hcv n) (hev n)) (fun n => (hbound' n).1) have hge : gradient φ=G := funext fun x => (hasGradientAt_iff_hasFDerivAt.mpr (hdf x)).gradient have hφcv : ConvexOn ℝ univ φ := by refine ⟨convex_univ,fun x hx y hy a b ha hb hab => ?_⟩ apply le_of_tendsto_of_tendsto (hft (a • x+b • y)) (((hft x).const_mul a).add ((hft y).const_mul b)) exact Eventually.of_forall fun n => (hcv (s n)).2 hx hy ha hb hab have hφev : Function.Even φ := fun x => by have heq : (fun n => fs (s n) (-x))=(fun n => fs (s n) x) := funext fun n => hev (s n) x have ht := hft (-x) rw [heq] at ht exact tendsto_nhds_unique ht (hft x) have hcapφ : ∀ h z, WeakMomentBound.secondDiff φ h z ≤ 4/ε*‖h‖^2 := by intro h z apply le_of_tendsto' (((hft (z+h)).add (hft (z-h))).sub ((hft z).const_mul 2)) exact fun n => hcap (s n) h z have htailφ : ∀ x, c*‖x‖-((Fintype.card ι:ℝ)-φ 0) ≤ φ x := by intro x have h := ge_of_tendsto' ((hft x).sub (hft 0)) (fun n => hlow (s n) x) linarith let M : E → ℝ := fun x => D*Real.exp (-c*‖x‖) have hMI : Integrable M μ := (integrable_exp_neg_norm μ hc).const_mul D have hMb n x : MomentLimits.density (fs (s n)) x ≤ M x := (hbound' (s n)).2 x have hmass := MomentLimits.density_integral_one μ (fun n => (hC (s n)).continuous) hMI hMb hft (fun n => hnorm (s n)) have hφI := MomentLimits.density_integrable_limit μ hφ.continuous hMI hMb hft have hp := MomentLimits.source_probability μ hφI hmass let : IsProbabilityMeasure (normalizedSource μ V) := normalizedSource_probability μ hI have hmap : Measure.map G (MomentLimits.source μ φ)=normalizedSource μ V := MomentLimits.map_source_limit μ (fun n => (hC (s n)).continuous) hφ.continuous (fun n => (hg (s n)).continuous) hG.continuous hMI hMb hft (fun x => hGt.tendstoLocallyUniformlyOn.tendsto_at (mem_univ x)) (fun n => TruncatedMoment.target μ (R (s n)) V) (normalizedSource μ V) (fun n => hm (s n)) (fun f => (truncated_target_tendsto μ hV hI f).comp hs.tendsto_atTop) have honto : Function.Surjective G := by let := normalizedSource_openPos μ hV hI exact GlobalMoment.gradient_surjective_of_pushforward (MomentLimits.source μ φ) (normalizedSource μ V) hφcv (fun x => hasGradientAt_iff_hasFDerivAt.mpr (hdf x)) hG.continuous hmap refine ⟨φ,hφcv,hφev,hφ,?_,hcapφ,⟨c,hc,_,htailφ⟩,hp,?_,?_⟩ · rw [hge]; exact hG · rw [hge]; exact hmap · rw [hge]; exact honto end open MeasureTheory Set Filter open scoped InnerProductSpace Topology ENNReal variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] variable (μ : Measure E) [μ.IsAddHaarMeasure] variable {ι : Type*} [Fintype ι] [DecidableEq ι] omit [MeasurableSpace E] [BorelSpace E] in lemma finite_dual_of_surjective_gradient {φ : E → ℝ} (hc : ConvexOn ℝ univ φ) (hd : Differentiable ℝ φ) (hs : Function.Surjective (gradient φ)) : ∀ x ∈ (univ : Set E), BddAbove ((fun z => ⟪z,x⟫_ℝ-φ z) '' univ) := by intro x _ obtain ⟨z,rfl⟩ := hs x refine ⟨⟪z,gradient φ z⟫_ℝ-φ z,?_⟩ rintro _ ⟨w,_,rfl⟩ have hh := convex_supporting_gradient hc (hd z) w dsimp only rw [inner_sub_right] at hh have hw : ⟪gradient φ z,w⟫_ℝ=⟪w,gradient φ z⟫_ℝ := real_inner_comm _ _ have hz : ⟪gradient φ z,z⟫_ℝ=⟪z,gradient φ z⟫_ℝ := real_inner_comm _ _ rw [hw,hz] at hh linarith lemma C1_inverse {φ V : E → ℝ} (hc : ConvexOn ℝ univ φ) (hd : Differentiable ℝ φ) (hs : Function.Surjective (gradient φ)) (hm : Measure.map (gradient φ) (μ.withDensity (fun z => ENNReal.ofReal (Real.exp (-φ z)))) = normalizedSource μ V) : ∀ᵐ z ∂μ.withDensity (fun z => ENNReal.ofReal (Real.exp (-φ z))), gradient (dualOn univ φ) (gradient φ z)=z := by have hb := finite_dual_of_surjective_gradient hc hd hs have ha : ∀ᵐ x ∂normalizedSource μ V, DifferentiableAt ℝ (dualOn univ φ) x := by filter_upwards [(withDensity_absolutelyContinuous μ _).ae_le (convex_ae_differentiable isOpen_univ (convexOn_dualOn convex_univ hb))] with x hx exact hx (mem_univ x) rw [← hm] at ha filter_upwards [ae_of_ae_map (gradient_measurable φ).aemeasurable ha] with z hz exact inverse_gradient isOpen_univ hc (hd z) (mem_univ _) hb hz lemma C1_weak_MA {φ V : E → ℝ} (hc : ConvexOn ℝ univ φ) (hd : Differentiable ℝ φ) (hs : Function.Surjective (gradient φ)) (hV : Continuous V) (hI : Integrable (fun x => Real.exp (-V x)) μ) (hm : Measure.map (gradient φ) (μ.withDensity (fun z => ENNReal.ofReal (Real.exp (-φ z)))) = normalizedSource μ V) : Measure.map (gradient (dualOn univ φ)) μ = μ.withDensity (fun z => ENNReal.ofReal ((∫ x,Real.exp (-V x) ∂μ)*Real.exp (V (gradient φ z)-φ z))) := by let Z := ∫ x,Real.exp (-V x) ∂μ let w := fun x => ENNReal.ofReal (Real.exp (-V x)/Z) let σ := μ.withDensity (fun z => ENNReal.ofReal (Real.exp (-φ z))) let ν := normalizedSource μ V have hZ : 0 (w x)⁻¹)=μ := withDensity_inv_same₀ hw.aemeasurable (Eventually.of_forall fun x => ENNReal.ofReal_ne_zero_iff.mpr (div_pos (Real.exp_pos _) hZ)) (Eventually.of_forall fun _ => ENNReal.ofReal_ne_top) conv_lhs => rw [← hinv] have hr := reverse_weighted (gradient_measurable _) (gradient_measurable _) hm (C1_inverse μ hc hd hs hm) hw.inv exact hr.trans (by change σ.withDensity (fun z => (w (gradient φ z))⁻¹)=_ dsimp only [σ] refine (withDensity_mul μ hd.continuous.neg.rexp.measurable.ennreal_ofReal (hw.inv.comp (gradient_measurable φ))).symm.trans ?_ congr 1 funext z dsimp only [Pi.mul_apply,Pi.inv_apply,Pi.neg_apply,Function.comp_apply,w] rw [← ENNReal.ofReal_inv_of_pos (div_pos (Real.exp_pos _) hZ), ← ENNReal.ofReal_mul (Real.exp_pos _).le] congr 1 dsimp only [Z] simp only [Real.exp_neg,inv_div,div_inv_eq_mul,Real.exp_sub] ring) omit [MeasurableSpace E] [BorelSpace E] in lemma convex_gradient_derivative_positive {φ : E → ℝ} (hc : ConvexOn ℝ univ φ) (hd : Differentiable ℝ φ) {z : E} (hg : DifferentiableAt ℝ (gradient φ) z) : (fderiv ℝ (gradient φ) z).toLinearMap.IsPositive := by refine ⟨?_,fun v => supporting_derivative_nonneg (fun x w => convex_supporting_gradient hc (hd x) w) hg.hasFDerivAt v⟩ intro v w have hh := second_derivative_symmetric (fun x => (hd x).hasGradientAt.hasFDerivAt) ((InnerProductSpace.toDual ℝ E).toContinuousLinearEquiv.hasFDerivAt.comp z hg.hasFDerivAt) v w change ⟪(fderiv ℝ (gradient φ) z) v,w⟫_ℝ=⟪(fderiv ℝ (gradient φ) z) w,v⟫_ℝ at hh exact hh.trans (real_inner_comm _ _) theorem C11_ae_positive_MA (b : OrthonormalBasis ι ℝ E) {φ V : E → ℝ} (hc : ConvexOn ℝ univ φ) (hd : Differentiable ℝ φ) {L : ℝ≥0} (hl : LipschitzWith L (gradient φ)) (hs : Function.Surjective (gradient φ)) (hV : Continuous V) (hI : Integrable (fun x => Real.exp (-V x)) μ) (hm : Measure.map (gradient φ) (μ.withDensity (fun z => ENNReal.ofReal (Real.exp (-φ z)))) = normalizedSource μ V) : ∀ᵐ z ∂μ, DifferentiableAt ℝ (gradient φ) z ∧ (LinearMap.toMatrix b.toBasis b.toBasis (fderiv ℝ (gradient φ) z).toLinearMap).PosDef ∧ Real.log (fderiv ℝ (gradient φ) z).det = V (gradient φ z)+Real.log (∫ x,Real.exp (-V x) ∂μ)-φ z := by let σ := μ.withDensity (fun z => ENNReal.ofReal (Real.exp (-φ z))) let ν := normalizedSource μ V let Z := ∫ x,Real.exp (-V x) ∂μ have hZ : 0 ENNReal.ofReal_ne_zero_iff.mpr (Real.exp_pos _)) have hμν : μ.restrict univ ≪ ν := by rw [Measure.restrict_univ] exact withDensity_absolutelyContinuous' (hV.neg.rexp.measurable.div_const Z).ennreal_ofReal.aemeasurable (Eventually.of_forall fun _ => ENNReal.ofReal_ne_zero_iff.mpr (div_pos (Real.exp_pos _) hZ)) have ha : ∀ᵐ z ∂μ, z ∈ (univ : Set E) ∧ HasFDerivWithinAt (gradient φ) (fderiv ℝ (gradient φ) z) univ z := by filter_upwards [hl.ae_differentiableAt (μ:=μ)] with z hz exact ⟨mem_univ z,hz.hasFDerivAt.hasFDerivWithinAt⟩ have hj := MomentJacobian.jacobian_of_ae_inverse_within μ MeasurableSet.univ (gradient_measurable _) (gradient_measurable _) ha hm hμσ (withDensity_absolutelyContinuous _ _) hμν (C1_inverse μ hc hd hs hm) (Eventually.of_forall fun z => mem_univ (gradient φ z)) rw [Measure.restrict_univ] at hj have he := hj.trans (C1_weak_MA μ hc hd hs hV hI hm) have hJm : Measurable (fun z => |(fderiv ℝ (gradient φ) z).det|) := (ContinuousLinearMap.continuous_det.measurable.comp (measurable_fderiv ℝ _)).abs have hWm : Measurable (fun z => Z*Real.exp (V (gradient φ z)-φ z)) := measurable_const.mul ((hV.measurable.comp (gradient_measurable _)).sub hd.continuous.measurable).exp have hae := (withDensity_eq_iff_of_sigmaFinite hJm.ennreal_ofReal.aemeasurable hWm.ennreal_ofReal.aemeasurable).mp he filter_upwards [hl.ae_differentiableAt (μ:=μ),hae] with z hz hj have hps := (LinearMap.posSemidef_toMatrix_iff b).mpr (convex_gradient_derivative_positive hc hd hz) have hdeta : (LinearMap.toMatrix b.toBasis b.toBasis (fderiv ℝ (gradient φ) z).toLinearMap).det=(fderiv ℝ (gradient φ) z).det := LinearMap.det_toMatrix b.toBasis _ have hdet0 : 0 ≤ (fderiv ℝ (gradient φ) z).det := hdeta ▸ hps.det_nonneg have hdet : (fderiv ℝ (gradient φ) z).det=Z*Real.exp (V (gradient φ z)-φ z) := by have hh := (ENNReal.ofReal_eq_ofReal_iff (abs_nonneg _) (mul_nonneg hZ.le (Real.exp_pos _).le)).mp hj rwa [abs_of_nonneg hdet0] at hh refine ⟨hz,hps.posDef_iff_det_ne_zero.mpr ?_,?_⟩ · rw [hdeta,hdet]; exact (mul_pos hZ (Real.exp_pos _)).ne' · rw [hdet,Real.log_mul hZ.ne' (Real.exp_ne_zero _),Real.log_exp] ring end CompactMomentVariational namespace LocalEllipticity open Set Metric open scoped InnerProductSpace variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] variable {ι : Type*} [Fintype ι] [DecidableEq ι] lemma positive_closed : IsClosed {A : E →L[ℝ] E | A.toLinearMap.IsPositive} := by have hs : IsClosed {A : E →L[ℝ] E | ∀ v w, ⟪A v,w⟫_ℝ=⟪v,A w⟫_ℝ} := by simp only [ofPred_forall] apply isClosed_iInter intro v apply isClosed_iInter intro w exact isClosed_eq (by fun_prop) (by fun_prop) have hp : IsClosed {A : E →L[ℝ] E | ∀ v, 0 ≤ ⟪A v,v⟫_ℝ} := by simp only [ofPred_forall] apply isClosed_iInter intro v exact isClosed_le continuous_const (by fun_prop) exact hs.inter hp omit [FiniteDimensional ℝ E] in lemma positive_inner (b : OrthonormalBasis ι ℝ E) {A : E →L[ℝ] E} (hA : A.toLinearMap.IsPositive) (hd : A.det ≠ 0) (v : E) (hv : v ≠ 0) : 0 < ⟪A v,v⟫_ℝ := by have hm := (LinearMap.posSemidef_toMatrix_iff b).mpr hA have hpd := hm.posDef_iff_det_ne_zero.mpr ((LinearMap.det_toMatrix b.toBasis _).trans_ne hd) have hcoord : (b.toBasis.repr v : ι → ℝ) ≠ 0 := by intro he have hz : b.toBasis.repr v = 0 := DFunLike.coe_injective he exact hv (b.toBasis.repr.injective (by simpa using hz)) have hh := hpd.dotProduct_mulVec_pos hcoord rw [LinearMap.toMatrix_mulVec_repr] at hh have he (w : E) : (b.toBasis.repr w : ι → ℝ) = WithLp.ofLp (b.repr w) := by ext i exact b.coe_toBasis_repr_apply w i rw [he v] at hh change 0 < star (b.repr v).ofLp ⬝ᵥ (b.toBasis.repr (A v) : ι → ℝ) at hh rw [he (A v)] at hh have hi := b.repr.inner_map_map v (A v) rw [EuclideanSpace.inner_eq_star_dotProduct] at hi simp only [star_trivial] at hh hi rw [dotProduct_comm] at hi rw [hi] at hh simpa only [real_inner_comm] using hh lemma uniform_coercivity (b : OrthonormalBasis ι ℝ E) (C : ℝ) {d : ℝ} (hd : 0 0, ∀ A : E →L[ℝ] E, A.toLinearMap.IsPositive → ‖A‖ ≤ C → d ≤ A.det → ∀ v, δ*‖v‖^2 ≤ ⟪A v,v⟫_ℝ := by let K : Set (E →L[ℝ] E) := {A | A.toLinearMap.IsPositive ∧ ‖A‖ ≤ C ∧ d ≤ A.det} have hKc : IsClosed K := positive_closed.inter ((isClosed_le continuous_norm continuous_const).inter (isClosed_le continuous_const ContinuousLinearMap.continuous_det)) have hK : IsCompact K := (isCompact_closedBall (0 : E →L[ℝ] E) C).of_isClosed_subset hKc (fun A hA => by simpa only [mem_closedBall,dist_zero_right] using hA.2.1) have hS := hK.prod (isCompact_sphere (0:E) 1) obtain ⟨δ,hδ,hbound⟩ := hS.exists_forall_le' (show ContinuousOn (fun p : (E →L[ℝ] E) × E => ⟪p.1 p.2,p.2⟫_ℝ) _ from (by fun_prop : Continuous (fun p : (E →L[ℝ] E) × E => ⟪p.1 p.2,p.2⟫_ℝ)).continuousOn) (fun p hp => positive_inner b hp.1.1 (hd.trans_le hp.1.2.2).ne' p.2 (by intro he simpa only [he,mem_sphere_zero_iff_norm,norm_zero,zero_ne_one] using hp.2)) refine ⟨δ,hδ,fun A hA hC hdA v => ?_⟩ by_cases hv : v=0 · simp [hv] have hn : ‖v‖ ≠ 0 := norm_ne_zero_iff.mpr hv have hunit : ‖v‖⁻¹ • v ∈ sphere (0:E) 1 := by rw [mem_sphere_zero_iff_norm,norm_smul,Real.norm_eq_abs,abs_inv,abs_norm,inv_mul_cancel₀ hn] have hb := hbound (A,‖v‖⁻¹ • v) ⟨⟨hA,hC,hdA⟩,hunit⟩ have heq : ⟪A (‖v‖⁻¹ • v),‖v‖⁻¹ • v⟫_ℝ=‖v‖⁻¹^2*⟪A v,v⟫_ℝ := by simp only [map_smul,real_inner_smul_left,real_inner_smul_right] ring dsimp only at hb rw [heq] at hb have hh := mul_le_mul_of_nonneg_right hb (sq_nonneg ‖v‖) have he : (‖v‖⁻¹^2*⟪A v,v⟫_ℝ)*‖v‖^2=⟪A v,v⟫_ℝ := by field_simp [hn] rwa [he] at hh end LocalEllipticity namespace CompactMomentVariational open MeasureTheory Set Filter Metric open scoped InnerProductSpace Topology variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] variable (μ : Measure E) [μ.IsAddHaarMeasure] variable {ι : Type*} [Fintype ι] [DecidableEq ι] theorem C11_locally_uniformly_elliptic (b : OrthonormalBasis ι ℝ E) {φ V : E → ℝ} (hc : ConvexOn ℝ univ φ) (hd : Differentiable ℝ φ) {L : ℝ≥0} (hl : LipschitzWith L (gradient φ)) (hs : Function.Surjective (gradient φ)) (hV : Continuous V) (hI : Integrable (fun x => Real.exp (-V x)) μ) (hm : Measure.map (gradient φ) (μ.withDensity (fun z => ENNReal.ofReal (Real.exp (-φ z)))) = normalizedSource μ V) (R : ℝ) : ∃ δ > 0, ∀ᵐ z ∂μ, z ∈ closedBall (0:E) R → ∀ v, δ*‖v‖^2 ≤ ⟪fderiv ℝ (gradient φ) z v,v⟫_ℝ := by let Z := ∫ x,Real.exp (-V x) ∂μ let F := fun z => Z*Real.exp (V (gradient φ z)-φ z) have hZ : 0 mul_pos hZ (Real.exp_pos _)) obtain ⟨δ,hδ,hbound⟩ := LocalEllipticity.uniform_coercivity b (L:ℝ) hd0 refine ⟨δ,hδ,?_⟩ filter_upwards [C11_ae_positive_MA μ b hc hd hl hs hV hI hm] with z hz intro hzR v have hdetp : 0 < (fderiv ℝ (gradient φ) z).det := by simpa only [LinearMap.det_toMatrix] using hz.2.1.det_pos have hdet : (fderiv ℝ (gradient φ) z).det=F z := by have he := congrArg Real.exp hz.2.2 rw [Real.exp_log hdetp] at he rw [he] dsimp only [F,Z] rw [show V (gradient φ z)+Real.log (∫ x,Real.exp (-V x) ∂μ)-φ z = Real.log (∫ x,Real.exp (-V x) ∂μ)+(V (gradient φ z)-φ z) by ring, Real.exp_add,Real.exp_log hZ] exact hbound _ (convex_gradient_derivative_positive hc hd hz.1) (norm_fderiv_le_of_lipschitz ℝ hl) (hdet ▸ hdF z hzR) v end CompactMomentVariational namespace MomentLinearization open MeasureTheory Set Filter Matrix CompactMomentVariational open scoped InnerProductSpace variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] variable {ι : Type*} [Fintype ι] [DecidableEq ι] def hessian (b : OrthonormalBasis ι ℝ E) (φ : E → ℝ) (z : E) : Matrix ι ι ℝ := LinearMap.toMatrix b.toBasis b.toBasis (fderiv ℝ (gradient φ) z).toLinearMap def vectorDiff (X : E → E) (h z : E) : E := X (z+h)+X (z-h)-(2:ℝ) • X z def matrixDiff (H : E → Matrix ι ι ℝ) (h z : E) : Matrix ι ι ℝ := H (z+h)+H (z-h)-(2:ℝ) • H z lemma discrete_subsolution {V φ : E → ℝ} {X : E → E} {H : E → Matrix ι ι ℝ} (hV : ConvexOn ℝ univ V) {h z : E} (hdV : DifferentiableAt ℝ V (X z)) {c : ℝ} (h0 : (H z).PosDef) (hp : (H (z+h)).PosDef) (hm : (H (z-h)).PosDef) (he0 : Real.log (H z).det=V (X z)+c-φ z) (hep : Real.log (H (z+h)).det=V (X (z+h))+c-φ (z+h)) (hem : Real.log (H (z-h)).det=V (X (z-h))+c-φ (z-h)) : ⟪gradient V (X z),vectorDiff X h z⟫_ℝ ≤ ((H z)⁻¹*matrixDiff H h z).trace+WeakMomentBound.secondDiff φ h z := by have ht1 := LogDetConcavity.tangent h0 hp have ht2 := LogDetConcavity.tangent h0 hm have hv1 := convex_supporting_gradient hV hdV (X (z+h)) have hv2 := convex_supporting_gradient hV hdV (X (z-h)) have he : ((H z)⁻¹*matrixDiff H h z).trace = ((H z)⁻¹*(H (z+h)-H z)).trace+((H z)⁻¹*(H (z-h)-H z)).trace := by have hh : matrixDiff H h z=(H (z+h)-H z)+(H (z-h)-H z) := by dsimp only [matrixDiff] simp only [two_smul] abel rw [hh,Matrix.mul_add,Matrix.trace_add] rw [he,WeakMomentBound.secondDiff] rw [hep,he0] at ht1 rw [hem,he0] at ht2 simp only [inner_sub_right] at hv1 hv2 simp only [vectorDiff,inner_sub_right,inner_add_right,inner_smul_right] linarith variable [MeasurableSpace E] [BorelSpace E] variable (μ : Measure E) [μ.IsAddHaarMeasure] theorem C11_ae_subsolution (b : OrthonormalBasis ι ℝ E) {φ V : E → ℝ} (hc : ConvexOn ℝ univ φ) (hd : Differentiable ℝ φ) {L : ℝ≥0} (hl : LipschitzWith L (gradient φ)) (hs : Function.Surjective (gradient φ)) (hV : ConvexOn ℝ univ V) (hVd : Differentiable ℝ V) (hI : Integrable (fun x => Real.exp (-V x)) μ) (hmap : Measure.map (gradient φ) (μ.withDensity (fun z => ENNReal.ofReal (Real.exp (-φ z)))) = normalizedSource μ V) (h : E) : ∀ᵐ z ∂μ, ⟪gradient V (gradient φ z),vectorDiff (gradient φ) h z⟫_ℝ ≤ ((hessian b φ z)⁻¹*matrixDiff (hessian b φ) h z).trace+ WeakMomentBound.secondDiff φ h z := by have ha := C11_ae_positive_MA μ b hc hd hl hs hVd.continuous hI hmap have hap := (measurePreserving_add_right μ h).quasiMeasurePreserving.ae ha have ham := (measurePreserving_add_right μ (-h)).quasiMeasurePreserving.ae ha filter_upwards [ha,hap,ham] with z hz hp hm simp only [← sub_eq_add_neg] at hm exact discrete_subsolution hV (hVd _) hz.2.1 hp.2.1 hm.2.1 (by simpa only [hessian,LinearMap.det_toMatrix] using hz.2.2) (by simpa only [hessian,LinearMap.det_toMatrix] using hp.2.2) (by simpa only [hessian,LinearMap.det_toMatrix] using hm.2.2) end MomentLinearization namespace InverseElliptic open Set Metric Matrix open scoped InnerProductSpace Matrix.Norms.Elementwise variable {ι : Type*} [Fintype ι] [DecidableEq ι] local notation "E" => EuclideanSpace ℝ ι local notation "Mat" => Matrix ι ι ℝ def fromMatrix (b : OrthonormalBasis ι ℝ E) : Mat ≃L[ℝ] E →L[ℝ] E := ((LinearMap.toMatrix b.toBasis b.toBasis).symm.trans LinearMap.toContinuousLinearMap).toContinuousLinearEquiv lemma fromMatrix_toMatrix (b : OrthonormalBasis ι ℝ E) (A : E →L[ℝ] E) : fromMatrix b (LinearMap.toMatrix b.toBasis b.toBasis A.toLinearMap)=A := by change LinearMap.toContinuousLinearMap ((LinearMap.toMatrix b.toBasis b.toBasis).symm ((LinearMap.toMatrix b.toBasis b.toBasis) A.toLinearMap))=A rw [LinearEquiv.symm_apply_apply] rfl lemma toMatrix_fromMatrix (b : OrthonormalBasis ι ℝ E) (M : Mat) : LinearMap.toMatrix b.toBasis b.toBasis (fromMatrix b M).toLinearMap=M := by change (LinearMap.toMatrix b.toBasis b.toBasis) ((LinearMap.toMatrix b.toBasis b.toBasis).symm M)=M exact LinearEquiv.apply_symm_apply _ _ lemma inverse_continuousOn {K : Set Mat} (hK : ∀ M∈K,M.PosDef) : ContinuousOn (fun M : Mat => M⁻¹) K := by intro M hM apply ContinuousAt.continuousWithinAt apply continuousAt_matrix_inv simpa only [Ring.inverse_eq_inv'] using continuousAt_inv₀ (hK M hM).det_pos.ne' theorem compact_inverse_bounds (b : OrthonormalBasis ι ℝ E) {K : Set Mat} (hK : IsCompact K) (hpos : ∀ M∈K,M.PosDef) : ∃ ell T Tm : ℝ,0 M⁻¹) '' K have hJ : IsCompact J := hK.image_of_continuousOn (inverse_continuousOn hpos) have hJp : ∀ M∈J,M.PosDef := by rintro _ ⟨M,hM,rfl⟩; exact (hpos M hM).inv let e := fromMatrix b obtain ⟨C,hC⟩ := (hJ.image e.continuous).isBounded.exists_norm_le obtain ⟨d,hd,hdet⟩ := hJ.exists_forall_le' (ContinuousLinearMap.continuous_det.comp e.continuous).continuousOn (fun M hM => by change 0 < (e M).det change 0 < LinearMap.det (fromMatrix b M).toLinearMap rw [← LinearMap.det_toMatrix b.toBasis (fromMatrix b M).toLinearMap,toMatrix_fromMatrix] exact (hJp M hM).det_pos) obtain ⟨ell,hell,hel⟩ := LocalEllipticity.uniform_coercivity b C hd obtain ⟨Tm,hTm⟩ := hJ.isBounded.exists_norm_le obtain ⟨T,hT⟩ := (hJ.image (show Continuous (fun M : Mat => M.trace) by unfold Matrix.trace; fun_prop)).isBounded.exists_norm_le refine ⟨ell,max T 0,Tm,hell,le_max_right _ _,fun M hM => ?_⟩ have hMin : M⁻¹∈J := ⟨M,hM,rfl⟩ have hep : (e M⁻¹).toLinearMap.IsPositive := by apply (LinearMap.posSemidef_toMatrix_iff b).mp dsimp only [e] rw [toMatrix_fromMatrix] exact (hJp M⁻¹ hMin).posSemidef have hec := hC _ (mem_image_of_mem e hMin) have hed := hdet _ hMin have hb := hel _ hep hec hed have heq : LinearMap.toMatrix b.toBasis b.toBasis ((e M⁻¹)-(ell • ContinuousLinearMap.id ℝ E)).toLinearMap=M⁻¹-ell • (1:Mat) := by dsimp only [e] simp only [ContinuousLinearMap.toLinearMap_sub,ContinuousLinearMap.toLinearMap_smul, map_sub,map_smul,ContinuousLinearMap.coe_id,LinearMap.toMatrix_id,toMatrix_fromMatrix] refine ⟨?_,?_,hTm _ hMin⟩ · rw [← heq] apply (LinearMap.posSemidef_toMatrix_iff b).mpr constructor · exact hep.isSymmetric.sub (LinearMap.IsSymmetric.smul rfl LinearMap.IsSymmetric.id) · intro v change 0 ≤ ⟪(e M⁻¹) v-ell • v,v⟫_ℝ simpa only [inner_sub_left,real_inner_smul_left,real_inner_self_eq_norm_sq] using sub_nonneg.mpr (hb v) · have ht : |(M⁻¹).trace| ≤ T := by simpa only [Real.norm_eq_abs] using hT _ (mem_image_of_mem (fun M : Mat => M.trace) hMin) exact (le_abs_self _).trans (ht.trans (le_max_left _ _)) end InverseElliptic namespace MomentLinearization open Set Metric Matrix Filter MeasureTheory CompactMomentVariational open scoped InnerProductSpace NNReal ENNReal Matrix.Norms.Elementwise variable {ι : Type*} [Fintype ι] [DecidableEq ι] local notation "E" => EuclideanSpace ℝ ι local notation "Mat" => Matrix ι ι ℝ omit [DecidableEq ι] in lemma continuous_gradient_of_C1 {V : E → ℝ} (hV : ContDiff ℝ 1 V) : Continuous (gradient V) := (InnerProductSpace.toDual ℝ E).symm.continuous.comp ((contDiff_one_iff_fderiv.mp hV).2) theorem C11_local_coefficients (b : OrthonormalBasis ι ℝ E) {φ V : E → ℝ} (hc : ConvexOn ℝ univ φ) (hφ : ContDiff ℝ 1 φ) {L : ℝ≥0} (hL : LipschitzWith L (gradient φ)) (hV : ContDiff ℝ 1 V) (hI : Integrable (fun x => Real.exp (-V x)) volume) {G : Set E} (hG : ∀ x∈G,DifferentiableAt ℝ (gradient φ) x ∧ (hessian b φ x).PosDef ∧ Real.log (hessian b φ x).det= V (gradient φ x)+Real.log (∫ x,Real.exp (-V x))-φ x) : ∀ c : E,∃ ell T Tm B K R : ℝ,0 Z*Real.exp (V (gradient φ z)-φ z) have hZ : 0 mul_pos hZ (Real.exp_pos _)) let J : Set (E →L[ℝ] E) := {Q | Q.toLinearMap.IsPositive ∧ ‖Q‖≤(L:ℝ) ∧ d≤Q.det} have hJ : IsCompact J := (isCompact_closedBall (0:E →L[ℝ] E) (L:ℝ)).of_isClosed_subset (LocalEllipticity.positive_closed.inter ((isClosed_le continuous_norm continuous_const).inter (isClosed_le continuous_const ContinuousLinearMap.continuous_det))) (fun Q hQ => by simpa only [mem_closedBall,dist_zero_right] using hQ.2.1) let toMat : (E →L[ℝ] E) → Mat := fun Q => LinearMap.toMatrix b.toBasis b.toBasis Q.toLinearMap have htoMat : Continuous toMat := (InverseElliptic.fromMatrix b).symm.continuous have hpos : ∀ M∈toMat '' J,M.PosDef := by rintro _ ⟨Q,hQ,rfl⟩ apply ((LinearMap.posSemidef_toMatrix_iff b).mpr hQ.1).posDef_iff_det_ne_zero.mpr rw [LinearMap.det_toMatrix] exact (hd.trans_le hQ.2.2).ne' obtain ⟨ell,T,Tm,hell,hT,hbounds⟩ := InverseElliptic.compact_inverse_bounds b (hJ.image htoMat) hpos have hgradV := continuous_gradient_of_C1 hV obtain ⟨B,hB⟩ := ((isCompact_closedBall c 1).image (hgradV.comp hL.continuous)).isBounded.exists_norm_le obtain ⟨Kv,U,hU,hKv⟩ := (hV.locallyLipschitz.comp hL.locallyLipschitz) c obtain ⟨Kp,W,hW,hKp⟩ := hφ.locallyLipschitz c obtain ⟨R,hR,hRU⟩ := Metric.mem_nhds_iff.mp (inter_mem hU hW) let r := min R 1 have hr : 0 f (‖x‖^2)) x=(2*f' (‖x‖^2)) • x := by apply (InnerProductSpace.toDual ℝ E).injective rw [toDual_gradient] have hh := (hd _ (sq_nonneg _)).comp_hasFDerivAt x (hasStrictFDerivAt_norm_sq x).hasFDerivAt rw [show (fun x : E => f (‖x‖^2))=f ∘ (fun x : E => ‖x‖^2) from rfl,hh.fderiv] ext v simp only [smul_apply,smul_eq_mul,innerSL_apply_apply, InnerProductSpace.toDual_apply_apply,real_inner_smul_left] ring lemma hessian_radial {f f' f'' : ℝ → ℝ} (hd : ∀ t≥0, HasDerivAt f (f' t) t) (hd' : ∀ t≥0, HasDerivAt f' (f'' t) t) (x v : E) : fderiv ℝ (gradient (fun x : E => f (‖x‖^2))) x v= (2*f' (‖x‖^2)) • v+(4*f'' (‖x‖^2)*⟪x,v⟫_ℝ) • x := by have he : gradient (fun x : E => f (‖x‖^2))=fun x => (2*f' (‖x‖^2)) • x := funext (gradient_radial hd) rw [he] have hh := (((hd' _ (sq_nonneg _)).comp_hasFDerivAt x (hasStrictFDerivAt_norm_sq x).hasFDerivAt).const_smul (2:ℝ)).smul (hasFDerivAt_id x) rw [show (fun x : E => (2*f' (‖x‖^2)) • x)=((2:ℝ) • (f' ∘ (fun x : E => ‖x‖^2))) • id from rfl, hh.fderiv] simp only [add_apply,smul_apply, ContinuousLinearMap.smulRight_apply,ContinuousLinearMap.id_apply, Pi.smul_apply,Function.comp_apply,smul_eq_mul,innerSL_apply_apply,id_eq] congr 1 ring_nf lemma profile_deriv (p t : ℝ) (ht : 0≤t) : HasDerivAt (fun t : ℝ => (1+t)^(-p)) (-p*(1+t)^(-p-1)) t := by have hs : 0<1+t := by linarith simpa only [one_mul,id_eq] using ((hasDerivAt_id t).const_add 1).rpow_const (p:=(-p)) (Or.inl hs.ne') lemma profile_second (p t : ℝ) (ht : 0≤t) : HasDerivAt (fun t : ℝ => -p*(1+t)^(-p-1)) (p*(p+1)*(1+t)^(-p-2)) t := by have hs : 0<1+t := by linarith have hh := ((((hasDerivAt_id t).const_add 1).rpow_const (p:=(-p-1)) (Or.inl hs.ne')).const_mul (-p)) simp only [id_eq,one_mul] at hh convert hh using 1; first | rfl | ring_nf lemma hessian_power (p : ℝ) (x v : E) : fderiv ℝ (gradient (fun x : E => (1+‖x‖^2)^(-p))) x v = (-2*p*(1+‖x‖^2)^(-p-1)) • v+ (4*p*(p+1)*(1+‖x‖^2)^(-p-2)*⟪x,v⟫_ℝ) • x := by rw [hessian_radial (profile_deriv p) (profile_second p)] congr 1 <;> congr 1 <;> ring end section open Set open scoped InnerProductSpace Matrix variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] variable {ι : Type*} [Fintype ι] [DecidableEq ι] omit [FiniteDimensional ℝ E] in lemma matrix_rank_one (b : OrthonormalBasis ι ℝ E) (x : E) {A : E →L[ℝ] E} {a c : ℝ} (hA : ∀ v, A v=a • v+(c*⟪x,v⟫_ℝ) • x) : LinearMap.toMatrix b.toBasis b.toBasis A.toLinearMap= a • (1:Matrix ι ι ℝ)+c • Matrix.vecMulVec (b.repr x).ofLp (b.repr x).ofLp := by ext i j rw [LinearMap.toMatrix_apply'] change b.toBasis.repr (A (b.toBasis j)) i=_ rw [hA,map_add,map_smul,map_smul] simp only [Finsupp.add_apply,Finsupp.smul_apply,smul_eq_mul,Matrix.add_apply, Matrix.smul_apply,Matrix.vecMulVec_apply,Module.Basis.repr_self, Finsupp.single_apply] simp only [b.coe_toBasis_repr_apply,b.repr_apply_apply,b.coe_toBasis] by_cases he : i=j · subst j simp only [ite_true,Matrix.one_apply_eq] rw [real_inner_comm x (b i)] ring · simp only [Ne.symm he,ite_false,Matrix.one_apply_ne he,mul_zero,zero_add] rw [real_inner_comm x (b j)] ring lemma trace_hessian_power (b : OrthonormalBasis ι ℝ E) (A : Matrix ι ι ℝ) (p : ℝ) (x : E) : (A*LinearMap.toMatrix b.toBasis b.toBasis (fderiv ℝ (gradient (fun x : E => (1+‖x‖^2)^(-p))) x).toLinearMap).trace= (-2*p*(1+‖x‖^2)^(-p-1))*A.trace+ (4*p*(p+1)*(1+‖x‖^2)^(-p-2))* ((b.repr x).ofLp ⬝ᵥ A.mulVec (b.repr x).ofLp) := by rw [matrix_rank_one b x (hessian_power p x),Matrix.mul_add,Matrix.mul_smul, Matrix.mul_one,Matrix.mul_smul,Matrix.mul_vecMulVec,Matrix.trace_add, Matrix.trace_smul,Matrix.trace_smul,Matrix.trace_vecMulVec,dotProduct_comm] rfl omit [FiniteDimensional ℝ E] [DecidableEq ι] in lemma coord_dot_self (b : OrthonormalBasis ι ℝ E) (x : E) : (b.repr x).ofLp ⬝ᵥ (b.repr x).ofLp=‖x‖^2 := by have hh := b.repr.inner_map_map x x simpa only [EuclideanSpace.inner_eq_star_dotProduct,star_trivial,real_inner_self_eq_norm_sq] using hh lemma trace_upper {A : Matrix ι ι ℝ} {L : ℝ} (hA : (L • (1:Matrix ι ι ℝ)-A).PosSemidef) : A.trace≤Fintype.card ι*L := by have hh := hA.trace_nonneg rw [Matrix.trace_sub,Matrix.trace_smul,Matrix.trace_one,smul_eq_mul] at hh nlinarith omit [FiniteDimensional ℝ E] in lemma quadratic_lower (b : OrthonormalBasis ι ℝ E) {A : Matrix ι ι ℝ} {ell : ℝ} (hA : (A-ell • (1:Matrix ι ι ℝ)).PosSemidef) (x : E) : ell*‖x‖^2≤(b.repr x).ofLp ⬝ᵥ A.mulVec (b.repr x).ofLp := by have hh := hA.dotProduct_mulVec_nonneg (b.repr x).ofLp simp only [star_trivial,Matrix.sub_mulVec,Matrix.smul_mulVec,Matrix.one_mulVec, dotProduct_sub,dotProduct_smul,smul_eq_mul,coord_dot_self] at hh linarith end open Set open scoped InnerProductSpace Matrix ContDiff variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] variable {ι : Type*} [Fintype ι] [DecidableEq ι] def profile (p : ℝ) (x : E) : ℝ := (1+‖x‖^2)^(-p) lemma power_shift (p t : ℝ) (ht : 0≤t) : (1+t)^(-p-1)=(1+t)^(-p-2)*(1+t) := by calc _ = (1+t)^((-p-2)+1) := by congr 1; ring _ = _ := by rw [Real.rpow_add (by linarith),Real.rpow_one] lemma norm_gradient_profile {p : ℝ} (hp : 0≤p) (x : E) : ‖gradient (profile p) x‖=2*p*(1+‖x‖^2)^(-p-1)*‖x‖ := by unfold profile rw [gradient_radial (profile_deriv p),norm_smul,Real.norm_eq_abs] have hh : 0≤2*p*(1+‖x‖^2)^(-p-1) := by positivity rw [show 2*(-p*(1+‖x‖^2)^(-p-1))=-(2*p*(1+‖x‖^2)^(-p-1)) by ring,abs_neg,abs_of_nonneg hh] lemma trace_lower (b : OrthonormalBasis ι ℝ E) {A : Matrix ι ι ℝ} {p ell T : ℝ} (hp : 0≤p) (hA : (A-ell • (1:Matrix ι ι ℝ)).PosSemidef) (hT : A.trace≤T) (x : E) : 2*p*(1+‖x‖^2)^(-p-2)*(2*(p+1)*ell*‖x‖^2-T*(1+‖x‖^2)) ≤ (A*LinearMap.toMatrix b.toBasis b.toBasis (fderiv ℝ (gradient (profile p)) x).toLinearMap).trace := by unfold profile rw [trace_hessian_power] have hq := quadratic_lower b hA x have hs : 0≤(1+‖x‖^2)^(-p-2) := Real.rpow_nonneg (by positivity) _ have ht := mul_le_mul_of_nonpos_left hT (show -2*p*(1+‖x‖^2)^(-p-1)≤0 by have hpos : 0≤2*p*(1+‖x‖^2)^(-p-1) := by positivity linarith) have hq' := mul_le_mul_of_nonneg_left hq (show 0≤4*p*(p+1)*(1+‖x‖^2)^(-p-2) by positivity) rw [power_shift p _ (sq_nonneg _)] at ht ⊢ nlinarith lemma profile_coarse_bound (b : OrthonormalBasis ι ℝ E) {A : Matrix ι ι ℝ} {p ell T B R : ℝ} (hp : 0≤p) (hell : 0≤ell) (hTn : 0≤T) (hB : 0≤B) (hA : (A-ell • (1:Matrix ι ι ℝ)).PosSemidef) (hT : A.trace≤T) (x : E) (hx : ‖x‖≤R) : -2*p*(T+B*R) ≤ (A*LinearMap.toMatrix b.toBasis b.toBasis (fderiv ℝ (gradient (profile p)) x).toLinearMap).trace- B*‖gradient (profile p) x‖ := by have hq := quadratic_lower b hA x have hqn : 0≤(b.repr x).ofLp ⬝ᵥ A.mulVec (b.repr x).ofLp := (mul_nonneg hell (sq_nonneg _)).trans hq have hs : 0≤(1+‖x‖^2)^(-p-1) := Real.rpow_nonneg (by positivity) _ have hs1 : (1+‖x‖^2)^(-p-1)≤1 := by simpa only [Real.rpow_zero] using Real.rpow_le_rpow_of_exponent_le (show 1≤1+‖x‖^2 by linarith [sq_nonneg ‖x‖]) (show -p-1≤0 by linarith) have hh : 0≤4*p*(p+1)*(1+‖x‖^2)^(-p-2)* ((b.repr x).ofLp ⬝ᵥ A.mulVec (b.repr x).ofLp) := by positivity have ht := mul_le_mul_of_nonpos_left hT (show -2*p*(1+‖x‖^2)^(-p-1)≤0 by have hpos : 0≤2*p*(1+‖x‖^2)^(-p-1) := by positivity linarith) have hb : B*(2*p*(1+‖x‖^2)^(-p-1)*‖x‖)≤B*(2*p*R) := by apply mul_le_mul_of_nonneg_left _ hB calc _ ≤ 2*p*1*R := by gcongr _ = _ := by ring have ht' := mul_le_mul_of_nonneg_left hs1 (show 0≤2*p*T by positivity) rw [norm_gradient_profile hp] unfold profile rw [trace_hessian_power] nlinarith lemma profile_positive_annulus (b : OrthonormalBasis ι ℝ E) {A : Matrix ι ι ℝ} {p ell T B a R : ℝ} (hp : 0≤p) (hell : 0≤ell) (hTn : 0≤T) (hB : 0≤B) (ha : 0≤a) (hA : (A-ell • (1:Matrix ι ι ℝ)).PosSemidef) (hT : A.trace≤T) (hP : T*(1+R^2)+B*(1+R^2)*R+1 ≤ 2*p*ell*a^2) (x : E) (hlo : a≤‖x‖) (hhi : ‖x‖≤R) : 2*p*(1+R^2)^(-p-2) ≤ (A*LinearMap.toMatrix b.toBasis b.toBasis (fderiv ℝ (gradient (profile p)) x).toLinearMap).trace- B*‖gradient (profile p) x‖ := by have hlow := trace_lower b hp hA hT x rw [norm_gradient_profile hp,power_shift p _ (sq_nonneg _)] have hsqlo : a^2≤‖x‖^2 := sq_le_sq₀ ha (norm_nonneg x) |>.mpr hlo have hsqhi : ‖x‖^2≤R^2 := sq_le_sq₀ (norm_nonneg x) ((norm_nonneg x).trans hhi) |>.mpr hhi have h1 := mul_le_mul_of_nonneg_left hsqlo (show 0≤2*p*ell by positivity) have h2 := mul_le_mul_of_nonneg_left (add_le_add_left hsqhi 1) hTn have h3 : B*(1+‖x‖^2)*‖x‖≤B*(1+R^2)*R := by gcongr have hbr : 1≤2*(p+1)*ell*‖x‖^2-T*(1+‖x‖^2)-B*(1+‖x‖^2)*‖x‖ := by nlinarith [mul_nonneg hell (sq_nonneg ‖x‖)] have hs : 0≤2*p*(1+‖x‖^2)^(-p-2) := by positivity have hbr' := mul_le_mul_of_nonneg_left hbr hs have hm := Real.rpow_le_rpow_of_nonpos (show 0<1+‖x‖^2 by positivity) (show 1+‖x‖^2≤1+R^2 by linarith) (show -p-2≤0 by linarith) have hm' := mul_le_mul_of_nonneg_left hm (show 0≤2*p by positivity) nlinarith end RadialBarrier namespace SmoothCompactify open Set Filter Metric open scoped Topology InnerProductSpace ContDiff NNReal variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] lemma gradient_contDiff {u : E → ℝ} (hu : ContDiff ℝ ∞ u) : ContDiff ℝ ∞ (gradient u) := by exact (InnerProductSpace.toDual ℝ E).symm.toContinuousLinearEquiv.contDiff.comp (hu.fderiv_right (m:=∞) (by simp)) lemma gradient_hasCompactSupport {u : E → ℝ} (hu : HasCompactSupport u) : HasCompactSupport (gradient u) := by exact (hu.fderiv ℝ).comp_left (map_zero (InnerProductSpace.toDual ℝ E).symm) lemma gradient_lipschitz {u : E → ℝ} (hu : ContDiff ℝ ∞ u) (hc : HasCompactSupport u) : ∃ L : ℝ≥0, LipschitzWith L (gradient u) := by have hd := gradient_contDiff hu obtain ⟨B,hB⟩ := ((hd.fderiv_right (m:=0) (by simp)).continuous.norm).bddAbove_range_of_hasCompactSupport (((gradient_hasCompactSupport hc).fderiv ℝ).norm) have hn : 0≤B := (norm_nonneg (fderiv ℝ (gradient u) 0)).trans (hB (mem_range_self 0)) refine ⟨⟨B,hn⟩,lipschitzWith_of_nnnorm_fderiv_le (hd.differentiable (by simp)) ?_⟩ intro x exact hB (mem_range_self x) theorem exists_extension {u : E → ℝ} (hu : ContDiff ℝ ∞ u) {R : ℝ} (hR : 0≤R) : ∃ ψ : E → ℝ, ContDiff ℝ ∞ ψ ∧ HasCompactSupport ψ ∧ (∃ L : ℝ≥0, LipschitzWith L (gradient ψ)) ∧ ∀ x∈closedBall (0:E) R, ψ =ᶠ[𝓝 x] u := by let χ : ContDiffBump (0:E) := ⟨R+1,R+2,by linarith,by linarith⟩ let ψ : E → ℝ := fun x => χ x*u x have hd : ContDiff ℝ ∞ ψ := χ.contDiff.mul hu have hc : HasCompactSupport ψ := χ.hasCompactSupport.mul_right refine ⟨ψ,hd,hc,gradient_lipschitz hd hc,?_⟩ intro x hx have hxb : x∈ball (0:E) (R+1) := closedBall_subset_ball (by linarith) hx filter_upwards [isOpen_ball.mem_nhds hxb] with y hy change χ y*u y=u y rw [χ.one_of_mem_closedBall (mem_closedBall.mpr (mem_ball.mp hy).le),one_mul] end SmoothCompactify namespace RadialBarrier open Set Filter Metric open scoped Topology InnerProductSpace Matrix ContDiff NNReal variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] variable {ι : Type*} [Fintype ι] [DecidableEq ι] omit [FiniteDimensional ℝ E] in lemma profile_contDiff (p : ℝ) : ContDiff ℝ ∞ (profile p : E → ℝ) := by exact (contDiff_const.add (contDiff_norm_sq ℝ)).rpow_const_of_ne (fun x => by positivity) lemma gradient_affine {u : E → ℝ} (hu : Differentiable ℝ u) (K c : ℝ) : gradient (fun x => K*(u x-c))=fun x => K • gradient u x := by funext x apply (InnerProductSpace.toDual ℝ E).injective rw [map_smul,toDual_gradient,toDual_gradient] have hh := ((hu x).hasFDerivAt.sub_const c).const_mul K simpa only [smul_eq_mul] using hh.fderiv lemma hessian_affine {u : E → ℝ} (hu : Differentiable ℝ u) (hdu : Differentiable ℝ (gradient u)) (K c : ℝ) (x : E) : fderiv ℝ (gradient (fun x => K*(u x-c))) x=K • fderiv ℝ (gradient u) x := by rw [gradient_affine hu] exact fderiv_const_smul (hdu x) K lemma trace_affine (b : OrthonormalBasis ι ℝ E) {u : E → ℝ} (hu : Differentiable ℝ u) (hdu : Differentiable ℝ (gradient u)) (K c : ℝ) (A : Matrix ι ι ℝ) (x : E) : (A*LinearMap.toMatrix b.toBasis b.toBasis (fderiv ℝ (gradient (fun x => K*(u x-c))) x).toLinearMap).trace= K*(A*LinearMap.toMatrix b.toBasis b.toBasis (fderiv ℝ (gradient u) x).toLinearMap).trace := by rw [hessian_affine hu hdu,ContinuousLinearMap.toLinearMap_smul,map_smul,Matrix.mul_smul, Matrix.trace_smul,smul_eq_mul] theorem exists_elliptic_barrier (b : OrthonormalBasis ι ℝ E) {ell T B a q R r : ℝ} (hell : 0 F) x ≤ (A*LinearMap.toMatrix b.toBasis b.toBasis (fderiv ℝ (gradient ψ) x).toLinearMap).trace- B*‖gradient ψ x‖ := by classical have hR : 0 K*(profile p x-(1+R^2)^(-p)) have hd : ContDiff ℝ ∞ (profile p : E → ℝ) := profile_contDiff p have hu : ContDiff ℝ ∞ u := contDiff_const.mul (hd.sub contDiff_const) have hdg := (SmoothCompactify.gradient_contDiff hd).differentiable (by simp) obtain ⟨ψ,hψ,hψc,⟨L,hL⟩,heq⟩ := SmoothCompactify.exists_extension hu hR.le let M := K+1 let F := 2*p*K*(T+B*R)+1+B*r+1 have huval (x : E) (hx : x∈closedBall (0:E) R) : ψ x=u x := (heq x hx).eq_of_nhds have hugrad (x : E) (hx : x∈closedBall (0:E) R) : gradient ψ x=K • gradient (profile p) x := by rw [(heq x hx).gradient_eq] exact congrFun (gradient_affine (hd.differentiable (by simp)) K ((1+R^2)^(-p))) x have hut (x : E) (hx : x∈closedBall (0:E) R) (A : Matrix ι ι ℝ) : (A*LinearMap.toMatrix b.toBasis b.toBasis (fderiv ℝ (gradient ψ) x).toLinearMap).trace= K*(A*LinearMap.toMatrix b.toBasis b.toBasis (fderiv ℝ (gradient (profile p)) x).toLinearMap).trace := by rw [(heq x hx).gradient.fderiv_eq] exact trace_affine b (hd.differentiable (by simp)) hdg K ((1+R^2)^(-p)) A x refine ⟨ψ,L,M,F,hψ,hL,by dsimp [M]; linarith,by dsimp [F]; positivity,?_,?_,?_,?_⟩ · intro x hx rw [huval x hx] have hpr : profile p x≤1 := by simpa only [profile,Real.rpow_zero] using Real.rpow_le_rpow_of_exponent_le (show 1≤1+‖x‖^2 by nlinarith [sq_nonneg ‖x‖]) (neg_nonpos.mpr hp.le) have hn : 0≤(1+R^2)^(-p) := by positivity have hh := mul_le_mul_of_nonneg_left (show profile p x-(1+R^2)^(-p)≤1 by linarith) hK.le dsimp [u,M] linarith · intro x hx have hxR : ‖x‖=R := by simpa only [frontier_closedBall (0:E) hR.ne',mem_sphere,dist_zero_right] using hx have hxC : x∈closedBall (0:E) R := by simpa only [mem_closedBall,dist_zero_right,hxR] using (le_refl R) rw [huval x hxC] simp only [u,profile,hxR,sub_self,mul_zero,le_refl] · intro x hx have hxq : ‖x‖≤q := by simpa only [mem_closedBall,dist_zero_right] using hx have hxC : x∈closedBall (0:E) R := mem_closedBall.mpr (by simpa using hxq.trans hqR.le) rw [huval x hxC] have hpr : (1+q^2)^(-p)≤profile p x := Real.rpow_le_rpow_of_nonpos (by positivity) (by nlinarith [norm_nonneg x]) (neg_nonpos.mpr hp.le) have hh := mul_le_mul_of_nonneg_left (sub_le_sub_right hpr ((1+R^2)^(-p))) hK.le exact hKh.trans hh · intro x A hx hA hAT have hxR : ‖x‖≤R := by simpa only [mem_closedBall,dist_zero_right] using hx rw [hut x hx A,hugrad x hx,norm_smul,Real.norm_eq_abs,abs_of_pos hK] by_cases hxa : x∈ball (0:E) a · rw [indicator_of_mem hxa] have hh := profile_coarse_bound b hp.le hell.le hT hB hA hAT x hxR have hh' := mul_le_mul_of_nonneg_left hh hK.le dsimp [F] nlinarith · rw [indicator_of_notMem hxa,sub_zero] have hxa' : a≤‖x‖ := le_of_not_gt (by simpa only [mem_ball,dist_zero_right] using hxa) have hh := profile_positive_annulus b hp.le hell.le hT hB ha.le hA hAT hP x hxa' hxR have hh' := mul_le_mul_of_nonneg_left hh hK.le exact hKm.trans (by dsimp [margin] at *; nlinarith) end RadialBarrier namespace ABPGeometry open Set Filter Metric MeasureTheory open scoped Topology InnerProductSpace NNReal ENNReal lemma second_nonpos_at_localMax {g g' : ℝ → ℝ} {a : ℝ} (hg : ∀ t, HasDerivAt g (g' t) t) (hh : HasDerivAt g' a 0) (hm : IsLocalMax g 0) : a ≤ 0 := by by_contra he have ha : 0] (0:ℝ), 0 (hg x).continuousAt)).continuousOn) (fun c _ => hg c) have hpc : 0 u (x+t • v) let g' := fun t : ℝ => ⟪gradient u (x+t • v),v⟫_ℝ have hline (t : ℝ) : HasDerivAt (fun t : ℝ => x+t • v) v t := by simpa only [one_smul,id_eq] using ((hasDerivAt_id t).smul_const v).const_add x have hg (t : ℝ) : HasDerivAt g (g' t) t := by have hh := (hu _).hasFDerivAt.comp_hasDerivAt t (hline t) simpa only [g,g',Function.comp_def,← toDual_gradient,InnerProductSpace.toDual_apply_apply] using hh have hd : HasDerivAt g' ⟪fderiv ℝ (gradient u) x v,v⟫_ℝ 0 := by have hd0 : HasFDerivAt (gradient u) (fderiv ℝ (gradient u) x) (x+(0:ℝ) • v) := by simpa using hH.hasFDerivAt have hh := hd0.comp_hasDerivAt 0 (hline 0) have hh' := hh.inner ℝ (hasDerivAt_const 0 v) simpa only [g',Function.comp_def,inner_zero_right,zero_add] using hh' have hgm : IsLocalMax g 0 := by have hl : Tendsto (fun t : ℝ => x+t • v) (𝓝 0) (𝓝 x) := by simpa only [zero_smul,add_zero] using (hline 0).continuousAt.tendsto change ∀ᶠ t in 𝓝 0, g t≤g 0 simpa only [g,zero_smul,add_zero] using hl.eventually hm exact second_nonpos_at_localMax hg hd hgm def upperContact (u : E → ℝ) (C : Set E) : Set E := {x | x ∈ interior C ∧ ∀ y ∈ C, u y≤u x+⟪gradient u x,y-x⟫_ℝ} lemma upperContact_measurable [MeasurableSpace E] [BorelSpace E] {u : E → ℝ} (hu : Continuous u) (hg : Continuous (gradient u)) (C : Set E) : MeasurableSet (upperContact u C) := by have hc : IsClosed {x | ∀ y ∈ C, u y≤u x+⟪gradient u x,y-x⟫_ℝ} := by simp only [ofPred_forall] exact isClosed_iInter (fun y => isClosed_iInter (fun _ => isClosed_le continuous_const (hu.add (hg.inner (continuous_const.sub continuous_id))))) exact isOpen_interior.measurableSet.inter hc.measurableSet lemma small_slope_in_contact_image {u : E → ℝ} (hu : Differentiable ℝ u) {C : Set E} (hC : IsCompact C) {x : E} (hx : x∈C) {D : ℝ} (hD : ∀ y ∈ C, ‖y-x‖≤D) (hbd : ∀ y ∈ frontier C, u y≤0) {p : E} (hp : ‖p‖*D u z-⟪p,z⟫_ℝ) y := by filter_upwards [isOpen_interior.mem_nhds hyint] with z hz exact hmax (interior_subset hz) have hgrad : gradient u y=p := by have hh := hloc.hasFDerivAt_eq_zero ((hu y).hasFDerivAt.sub (innerSL ℝ p).hasFDerivAt) apply (InnerProductSpace.toDual ℝ E).injective rw [toDual_gradient] exact sub_eq_zero.mp hh refine ⟨y,⟨hyint,?_⟩,hgrad⟩ intro z hz have hh : u z-⟪p,z⟫_ℝ≤u y-⟪p,y⟫_ℝ := hmax hz rw [hgrad,inner_sub_right] linarith lemma gradient_sub_inner {u : E → ℝ} (hu : Differentiable ℝ u) (p x : E) : gradient (fun y => u y-⟪p,y⟫_ℝ) x=gradient u x-p := by apply (InnerProductSpace.toDual ℝ E).injective have hh : HasFDerivAt (fun y => u y-⟪p,y⟫_ℝ) (fderiv ℝ u x-innerSL ℝ p) x := (hu x).hasFDerivAt.sub (innerSL ℝ p).hasFDerivAt rw [toDual_gradient,hh.fderiv] simp only [map_sub,toDual_gradient] rfl lemma hessian_isSymmetric {u : E → ℝ} (hu : Differentiable ℝ u) {x : E} (hH : DifferentiableAt ℝ (gradient u) x) : (fderiv ℝ (gradient u) x).toLinearMap.IsSymmetric := by intro v w have hh := second_derivative_symmetric (fun y => (hu y).hasGradientAt.hasFDerivAt) ((InnerProductSpace.toDual ℝ E).toContinuousLinearEquiv.hasFDerivAt.comp x hH.hasFDerivAt) v w change ⟪(fderiv ℝ (gradient u) x) v,w⟫_ℝ=⟪(fderiv ℝ (gradient u) x) w,v⟫_ℝ at hh exact hh.trans (real_inner_comm _ _) lemma contact_hessian_negative {u : E → ℝ} (hu : Differentiable ℝ u) {C : Set E} {x : E} (hx : x∈upperContact u C) (hH : DifferentiableAt ℝ (gradient u) x) : (-(fderiv ℝ (gradient u) x)).toLinearMap.IsPositive := by refine ⟨?_,fun v => ?_⟩ · intro v w simpa only [ContinuousLinearMap.toLinearMap_neg,LinearMap.neg_apply,inner_neg_left,inner_neg_right] using congrArg Neg.neg (hessian_isSymmetric hu hH v w) let g := fun y => u y-⟪gradient u x,y⟫_ℝ have hg : Differentiable ℝ g := hu.sub (innerSL ℝ (gradient u x)).differentiable have hge : gradient g=fun y => gradient u y-gradient u x := funext (gradient_sub_inner hu (gradient u x)) have hgH : HasFDerivAt (gradient g) (fderiv ℝ (gradient u) x) x := by rw [hge] exact hH.hasFDerivAt.sub_const _ have hm : IsLocalMax g x := by filter_upwards [isOpen_interior.mem_nhds hx.1] with y hy have hh := hx.2 y (interior_subset hy) rw [inner_sub_right] at hh dsimp only [g] linarith have hh := localMax_hessian_nonpos hg hgH.differentiableAt hm v rw [hgH.fderiv] at hh simpa only [ContinuousLinearMap.toLinearMap_neg,LinearMap.neg_apply,ContinuousLinearMap.coe_coe, inner_neg_left,RCLike.re_to_real,neg_nonneg] using hh lemma small_slope_in_positive_contact_image {u : E → ℝ} (hu : Differentiable ℝ u) {C : Set E} (hC : IsCompact C) {x : E} (hx : x∈C) {D : ℝ} (hD : ∀ y ∈ C, ‖y-x‖≤D) (hbd : ∀ y ∈ frontier C, u y≤0) {p : E} (hp : ‖p‖*D hx.2.hasFDerivAt.hasFDerivWithinAt) calc μ (f '' s) ≤ μ (f '' (s∩D))+μ (f '' (s\D)) := by apply (measure_mono (image_mono (show s⊆(s∩D)∪(s\D) from by intro x hx; by_cases hd : x∈D · exact Or.inl ⟨hx,hd⟩ · exact Or.inr ⟨hx,hd⟩))).trans rw [image_union] exact measure_union_le _ _ _ ≤ ∫⁻ x in s∩D, ENNReal.ofReal |(fderiv ℝ f x).det| ∂μ := by simpa only [hn,add_zero] using hh _ ≤ _ := lintegral_mono' (Measure.restrict_mono inter_subset_left le_rfl) (fun _ => le_rfl) lemma positive_height_measure_bound {u : E → ℝ} (hu : Differentiable ℝ u) {L : ℝ≥0} (hl : LipschitzWith L (gradient u)) {C : Set E} (hC : IsCompact C) {x : E} (hx : x∈C) {D : ℝ} (hDp : 0 hB.eigenvalues_nonneg j) (Finset.mem_univ i) _ = _ := by simp only [Finset.prod_const,Finset.card_univ] lemma det_le_of_trace {A B : Matrix ι ι ℝ} {ell f : ℝ} (hell : 0 F) hA hf simpa only [lintegral_const,Measure.restrict_apply_univ] using hh def boundedContact (u : E → ℝ) (C : Set E) (r : ℝ) : Set E := upperContact u C ∩ {y | 0 F) y) ≤ (A y*hessianMatrix b u y).trace) : μ (ball (0:E) r) ≤ ENNReal.ofReal ((F/ell)^Fintype.card ι)* μ (boundedContact u C r ∩ S) := by have hh := abp_bounded_slopes μ b hu hl hC hx hDp hD hbd hr hell A (S.indicator (fun _ => F)) hA hf have he (y : E) : ENNReal.ofReal ((S.indicator (fun _ => F) y/ell)^Fintype.card ι)= S.indicator (fun _ => ENNReal.ofReal ((F/ell)^Fintype.card ι)) y := by by_cases hy : y∈S · simp only [indicator_of_mem hy] · simp only [indicator_of_notMem hy,zero_div,zero_pow (Fintype.card_ne_zero),ENNReal.ofReal_zero] simp_rw [he] at hh rw [lintegral_indicator hS,lintegral_const,Measure.restrict_apply_univ,Measure.restrict_apply hS, inter_comm S] at hh exact hh omit [MeasurableSpace E] [BorelSpace E] in lemma gradient_sub_of_diff {u v : E → ℝ} (hu : Differentiable ℝ u) (hv : Differentiable ℝ v) : gradient (fun x => u x-v x)=fun x => gradient u x-gradient v x := by funext x apply (InnerProductSpace.toDual ℝ E).injective rw [map_sub,toDual_gradient,toDual_gradient,toDual_gradient] exact fderiv_sub (hu x) (hv x) omit [MeasurableSpace E] [BorelSpace E] in lemma hessian_sub_of_diff (b : OrthonormalBasis ι ℝ E) {u v : E → ℝ} (hu : Differentiable ℝ u) (hv : Differentiable ℝ v) {x : E} (hdu : DifferentiableAt ℝ (gradient u) x) (hdv : DifferentiableAt ℝ (gradient v) x) : hessianMatrix b (fun x => u x-v x) x=hessianMatrix b u x-hessianMatrix b v x := by unfold hessianMatrix rw [gradient_sub_of_diff hu hv] change LinearMap.toMatrix _ _ (fderiv ℝ (gradient u-gradient v) x).toLinearMap=_ rw [fderiv_sub hdu hdv,ContinuousLinearMap.toLinearMap_sub,map_sub] theorem barrier_contact_mass [Nonempty ι] (b : OrthonormalBasis ι ℝ E) {v ψ : E → ℝ} (hv : Differentiable ℝ v) (hψ : Differentiable ℝ ψ) {Lv Lψ : ℝ≥0} (hLv : LipschitzWith Lv (gradient v)) (hLψ : LipschitzWith Lψ (gradient ψ)) {C : Set E} (hC : IsCompact C) {x : E} (hx : x∈C) {D r M : ℝ} (hDp : 0 F) y ≤ (A y*hessianMatrix b ψ y).trace-f y-B*(‖gradient ψ y‖+r)) : μ (ball (0:E) r) ≤ ENNReal.ofReal ((F/ell)^Fintype.card ι)*μ (S∩C∩{y | v y ψ y-v y)) := by rw [hge] exact hLψ.sub hLv have hsub (y : E) (hy : y∈boundedContact (fun y => ψ y-v y) C r) : y∈C := interior_subset hy.1.1.1 have hh := abp_localized_contact_mass μ b (hψ.sub hv) hlu hC hx hDp hD (fun y hy => sub_nonpos.mpr ((hbd y hy).trans (hvn y (hC.isClosed.frontier_subset hy)))) hr (F:=F) hell A hS (by filter_upwards [hA] with y hy hyc; exact hy (hsub y hyc)) (by filter_upwards [hvP,hψP,hLv.ae_differentiableAt (μ:=μ),hLψ.ae_differentiableAt (μ:=μ)] with y hyv hyψ hydv hydψ hy have hyC := hsub y hy have hgr : ‖gradient v y‖≤‖gradient ψ y‖+r := by have hle := norm_sub_le (gradient ψ y) (gradient (fun y => ψ y-v y) y) rw [hge] at hle simp only [sub_sub_cancel] at hle have hrs : ‖gradient (fun y => ψ y-v y) y‖≤r := hy.2 rw [hge] at hrs exact hle.trans (add_le_add le_rfl hrs) change -S.indicator (fun _ => F) y ≤ (A y*hessianMatrix b (fun y => ψ y-v y) y).trace rw [hessian_sub_of_diff b hψ hv hydψ hydv,Matrix.mul_sub,Matrix.trace_sub] have := mul_le_mul_of_nonneg_left hgr hB have := hyv hyC have := hyψ hyC linarith) apply hh.trans apply mul_le_mul le_rfl ?_ (by positivity) (by positivity) apply measure_mono intro y hy exact ⟨⟨hy.2,hsub y hy.1⟩,lt_of_lt_of_le (by exact sub_pos.mp hy.1.1.2) (hm y (hsub y hy.1))⟩ end ABPGeometry namespace HarnackOneStep open Set Filter Metric MeasureTheory open scoped Topology InnerProductSpace Matrix ContDiff NNReal ENNReal variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] variable {ι : Type*} [Fintype ι] [DecidableEq ι] [Nonempty ι] variable (μ : Measure E) [μ.IsAddHaarMeasure] theorem exists_mass_constants (b : OrthonormalBasis ι ℝ E) {ell T B a q R : ℝ} (hell : 0 1) isOpen_ball.measurableSet hA hvP (by filter_upwards [hA,hAT] with y hyA hyT hy have hp := hψP y (A y) hy (hyA hy) (hyT hy) change -(ball (0:E) a).indicator (fun _ => F) y ≤ _ unfold ABPGeometry.hessianMatrix linarith) apply hh.trans apply mul_le_mul le_rfl ?_ (by positivity) (by positivity) exact measure_mono (fun _ hy => ⟨hy.1.1,hy.2⟩) end HarnackOneStep namespace DyadicBoxes open Set Metric Filter BoxIntegral open scoped Topology variable {ι : Type*} [Fintype ι] def box (I : Box ι) : List (Set ι) → Box ι | [] => I | s::p => box (I.splitCenterBox s) p omit [Fintype ι] in lemma box_le (I : Box ι) (p : List (Set ι)) : box I p≤I := by induction p generalizing I with | nil => exact le_rfl | cons s p ih => exact (ih _).trans (I.splitCenterBox_le s) omit [Fintype ι] in lemma comparable (I : Box ι) (p q : List (Set ι)) (hle : q.length≤p.length) : (box I p≤box I q) ∨ Disjoint (box I p : Set (ι → ℝ)) (box I q) := by induction q generalizing I p with | nil => exact Or.inl (box_le I p) | cons t q ih => cases p with | nil => simp at hle | cons s p => by_cases he : s=t · subst t exact ih (I.splitCenterBox s) p (by simpa using hle) · exact Or.inr ((I.disjoint_splitCenterBox he).mono (box_le _ p) (box_le _ q)) omit [Fintype ι] in lemma same_level_disjoint (I : Box ι) (p q : List (Set ι)) (hl : p.length=q.length) (hne : p≠q) : Disjoint (box I p : Set (ι → ℝ)) (box I q) := by induction p generalizing I q with | nil => have hq : q=[] := List.length_eq_zero_iff.mp hl.symm exact (hne hq.symm).elim | cons s p ih => cases q with | nil => simp at hl | cons t q => by_cases he : s=t · subst t exact ih _ _ (by simpa using hl) (by simpa using hne) · exact (I.disjoint_splitCenterBox he).mono (box_le _ p) (box_le _ q) omit [Fintype ι] in lemma level_cover (I : Box ι) (n : ℕ) {x : ι → ℝ} (hx : x∈I) : ∃ p : List (Set ι), p.length=n ∧ x∈box I p := by induction n generalizing I with | zero => exact ⟨[],rfl,hx⟩ | succ n ih => obtain ⟨s,hs⟩ := Box.exists_mem_splitCenterBox.mpr hx obtain ⟨p,hp,hxp⟩ := ih (I.splitCenterBox s) hs exact ⟨s::p,by simp [hp],hxp⟩ omit [Fintype ι] in lemma side_length (I : Box ι) (p : List (Set ι)) (i : ι) : (box I p).upper i-(box I p).lower i=(I.upper i-I.lower i)/(2:ℝ)^p.length := by induction p generalizing I with | nil => simp [box] | cons s p ih => rw [box,ih,I.upper_sub_lower_splitCenterBox,List.length_cons,pow_succ',div_div] omit [Fintype ι] in lemma box_append (I : Box ι) (p q : List (Set ι)) : box I (p++q)=box (box I p) q := by induction p generalizing I with | nil => rfl | cons s p ih => exact ih _ lemma diameter_bound (I : Box ι) (p : List (Set ι)) (i : ι) : diam (box I p).Icc≤(I.distortion:ℝ)*(I.upper i-I.lower i)/(2:ℝ)^p.length := by have hd : (box I p).distortion=I.distortion := Box.distortion_eq_of_sub_eq_div (side_length I p) have hh := (box I p).diam_Icc_le_of_distortion_le i (le_of_eq hd) simpa only [side_length,mul_div_assoc] using hh lemma exists_small_level [Nonempty ι] (I : Box ι) {U : Set (ι → ℝ)} (hU : IsOpen U) {x : ι → ℝ} (hx : x∈U) : ∃ n : ℕ, ∀ p : List (Set ι), p.length=n → x∈box I p → (box I p : Set (ι → ℝ))⊆U := by obtain ⟨r,hr,hball⟩ := Metric.isOpen_iff.mp hU x hx let i : ι := Classical.choice inferInstance let D : ℝ := I.distortion*(I.upper i-I.lower i) have ht : Tendsto (fun n : ℕ => D/(2:ℝ)^n) atTop (𝓝 0) := tendsto_const_nhds.div_atTop (tendsto_pow_atTop_atTop_of_one_lt (by norm_num)) obtain ⟨n,hn⟩ := (eventually_atTop.mp (ht.eventually (gt_mem_nhds hr))) refine ⟨n,fun p hp hxp y hyp => hball ?_⟩ have hb := diameter_bound I p i rw [hp] at hb have hxy := dist_le_diam_of_mem (box I p).isBounded_Icc (Box.coe_subset_Icc hyp) (Box.coe_subset_Icc hxp) exact (hxy.trans hb).trans_lt (hn n le_rfl) end DyadicBoxes namespace CubeGeometry open Set Metric MeasureTheory BoxIntegral open scoped Topology ENNReal Pointwise variable {ι : Type*} [Fintype ι] def unitBox : Box ι := ⟨fun _ => -(1/2),fun _ => 1/2,by intro i; norm_num⟩ def center (I : Box ι) : EuclideanSpace ℝ ι := WithLp.toLp 2 (fun i => (I.lower i+I.upper i)/2) def side (p : List (Set ι)) : ℝ := 1/(2:ℝ)^p.length omit [Fintype ι] in lemma side_pos (p : List (Set ι)) : 0 by nlinarith [hx i,abs_le.mp (hx i)]) _ = _ := by simp have hn : (Fintype.card ι:ℝ)≤(Fintype.card ι:ℝ)^2 := by exact_mod_cast (Nat.le_self_pow (by omega : 2≠0) (Fintype.card ι)) have hh := mul_le_mul_of_nonneg_right hn (sq_nonneg r) have hp : 0≤(Fintype.card ι:ℝ)*r := by positivity nlinarith [norm_nonneg x] omit [Fintype ι] in lemma center_mem (I : Box ι) : (center I).ofLp∈I := by intro i have hi := I.lower_lt_upper i change I.lower i < (I.lower i+I.upper i)/2 ∧ (I.lower i+I.upper i)/2≤I.upper i constructor <;> linarith lemma norm_center (p : List (Set ι)) : ‖center (DyadicBoxes.box unitBox p)‖≤(Fintype.card ι:ℝ)/2 := by have hc : (fun i => ((DyadicBoxes.box unitBox p).lower i+(DyadicBoxes.box unitBox p).upper i)/2) ∈ (unitBox : Box ι) := by apply DyadicBoxes.box_le unitBox p intro i have hi := (DyadicBoxes.box unitBox p).lower_lt_upper i constructor <;> dsimp only <;> linarith have hh := norm_le_card_mul (x:=center (DyadicBoxes.box unitBox p)) (r:=1/2) (by norm_num) (by intro i have hi := hc i change -(1/2:ℝ)<((DyadicBoxes.box unitBox p).lower i+(DyadicBoxes.box unitBox p).upper i)/2 ∧ ((DyadicBoxes.box unitBox p).lower i+(DyadicBoxes.box unitBox p).upper i)/2≤1/2 at hi exact abs_le.mpr ⟨hi.1.le,hi.2⟩) simpa only [div_eq_mul_inv,one_mul] using hh omit [Fintype ι] in lemma preimage_box (p : List (Set ι)) : (fun y : EuclideanSpace ℝ ι => center (DyadicBoxes.box unitBox p)+side p • y) ⁻¹' {x | x.ofLp∈DyadicBoxes.box unitBox p} = {y | y.ofLp∈(unitBox : Box ι)} := by ext y change (∀ i, (DyadicBoxes.box unitBox p).lower i < _ ∧ _ ≤ (DyadicBoxes.box unitBox p).upper i) ↔ ∀ i, -(1/2:ℝ) intro hy i <;> have hi := hy i <;> have hw := sides p i · change (DyadicBoxes.box unitBox p).lower i < ((DyadicBoxes.box unitBox p).lower i+(DyadicBoxes.box unitBox p).upper i)/2+side p*y i ∧ ((DyadicBoxes.box unitBox p).lower i+(DyadicBoxes.box unitBox p).upper i)/2+side p*y i≤ (DyadicBoxes.box unitBox p).upper i at hi constructor <;> nlinarith · change (DyadicBoxes.box unitBox p).lower i < ((DyadicBoxes.box unitBox p).lower i+(DyadicBoxes.box unitBox p).upper i)/2+side p*y i ∧ ((DyadicBoxes.box unitBox p).lower i+(DyadicBoxes.box unitBox p).upper i)/2+side p*y i≤ (DyadicBoxes.box unitBox p).upper i constructor <;> nlinarith lemma inner_ball_subset : ball (0:EuclideanSpace ℝ ι) (1/2)⊆{x | x.ofLp∈(unitBox : Box ι)} := by intro x hx i have hn : ‖x‖<1/2 := by simpa only [mem_ball,dist_zero_right] using hx have hi : |x i|<1/2 := (PiLp.norm_apply_le x i).trans_lt hn exact ⟨(abs_lt.mp hi).1,(abs_lt.mp hi).2.le⟩ lemma volume_unitBox : volume ((unitBox : Box ι) : Set (ι → ℝ))=1 := by rw [Box.coe_eq_pi,volume_pi,Measure.pi_pi] simp only [unitBox,Real.volume_Ioc] norm_num lemma volume_unitCube : volume {x : EuclideanSpace ℝ ι | x.ofLp∈(unitBox : Box ι)}=1 := by have h := (PiLp.volume_preserving_toLp ι).measure_preimage ((unitBox : Box ι).measurableSet_coe.preimage (EuclideanSpace.equiv ι ℝ).continuous.measurable).nullMeasurableSet change volume ((unitBox : Box ι) : Set (ι → ℝ))=volume {x : EuclideanSpace ℝ ι | x.ofLp∈(unitBox : Box ι)} at h exact h.symm.trans volume_unitBox omit [Fintype ι] in lemma parent_side (p : List (Set ι)) (a : Set ι) : side p=2*side (p++[a]) := by simp only [side,List.length_append,List.length_singleton,pow_succ] field_simp lemma normalized_parent (p : List (Set ι)) (a : Set ι) {x : ι → ℝ} (hx : x∈DyadicBoxes.box unitBox p) : ‖(side (p++[a]))⁻¹ • (WithLp.toLp 2 x-center (DyadicBoxes.box unitBox (p++[a])))‖≤ 2*(Fintype.card ι:ℝ) := by let J := DyadicBoxes.box unitBox (p++[a]) have hJ : J≤DyadicBoxes.box unitBox p := by dsimp [J] rw [DyadicBoxes.box_append] exact DyadicBoxes.box_le _ [a] have hc := hJ (center_mem J) have hd : ‖WithLp.toLp 2 x-center J‖≤(Fintype.card ι:ℝ)*side p := norm_le_card_mul (side_pos p).le (by intro i have hxi := hx i have hci := hc i have hw := sides p i change |x i-(center J) i| ≤ side p exact abs_le.mpr ⟨by linarith [hxi.1,hxi.2,hci.1,hci.2],by linarith [hxi.1,hxi.2,hci.1,hci.2]⟩) rw [norm_smul,Real.norm_eq_abs,abs_inv,abs_of_pos (side_pos _),← div_eq_inv_mul] apply (div_le_iff₀ (side_pos _)).mpr rw [parent_side p a] at hd dsimp [J] at hd nlinarith lemma global_ball (p : List (Set ι)) {R : ℝ} {x : EuclideanSpace ℝ ι} (hx : x∈closedBall (0:EuclideanSpace ℝ ι) R) : center (DyadicBoxes.box unitBox p)+side p • x∈ closedBall 0 ((Fintype.card ι:ℝ)/2+R) := by have hxn : ‖x‖≤R := by simpa only [mem_closedBall,dist_zero_right] using hx have hc := norm_center p have hh := norm_add_le (center (DyadicBoxes.box unitBox p)) (side p • x) rw [norm_smul,Real.norm_eq_abs,abs_of_pos (side_pos p)] at hh have hs := mul_le_mul (side_le_one p) hxn (norm_nonneg x) (by norm_num : (0:ℝ)≤1) rw [one_mul] at hs rw [mem_closedBall,dist_zero_right] linarith lemma norm_unit {x : ι → ℝ} (hx : x∈(unitBox : Box ι)) : ‖WithLp.toLp 2 x‖≤(Fintype.card ι:ℝ)/2 := by have hh := norm_le_card_mul (x:=WithLp.toLp 2 x) (r:=1/2) (by norm_num) (by intro i have hi := hx i exact abs_le.mpr ⟨hi.1.le,hi.2⟩) simpa only [div_eq_mul_inv,one_mul] using hh end CubeGeometry namespace MassDecay open Set MeasureTheory open scoped ENNReal variable {X : Type*} [MeasurableSpace X] (μ : Measure X) lemma of_positive_mass {Q E F : Set X} (hQ : μ Q=1) (hE : E⊆Q) (hF : F⊆Q) (hd : Disjoint E F) (hmF : MeasurableSet F) {b c : ℝ} (hb : 0 EuclideanSpace ℝ ι theorem exists_decay (b : OrthonormalBasis ι ℝ E) {ell T B q R : ℝ} (hell : 0 < ell) (hT : 0 ≤ T) (hB : 0 ≤ B) (hq : 0 ≤ q) (hqR : q < R) : ∃ (M : ℝ) (theta : ℝ≥0∞), 1 < M ∧ 0 < theta ∧ theta < 1 ∧ ∀ (v : E → ℝ) (L : ℝ≥0) (A : E → Matrix ι ι ℝ), Differentiable ℝ v → LipschitzWith L (gradient v) → (∀ x∈closedBall (0:E) R, 0≤v x) → (∀ᵐ x ∂volume, x∈closedBall (0:E) R → (A x-ell • (1:Matrix ι ι ℝ)).PosSemidef) → (∀ᵐ x ∂volume, x∈closedBall (0:E) R → (A x).trace≤T) → (∀ᵐ x ∂volume, x∈closedBall (0:E) R → (A x*ABPGeometry.hessianMatrix b v x).trace≤1+B*‖gradient v x‖) → (∃ x∈closedBall (0:E) q, v x≤1) → volume ({x | M CubeGeometry.inner_ball_subset hx.1 have hm : ENNReal.ofReal mass ≤ ENNReal.ofReal C*volume (ball (0:E) (1/2)∩{x | v x c+s • x) μ μ := (measurePreserving_add_left μ c).quasiMeasurePreserving.comp (μ.quasiMeasurePreserving_smul hs) lemma affine_image (c : E) {s : ℝ} (hs : 0 ≤ s) (S : Set E) : μ ((fun x : E => c+s • x) '' S)=ENNReal.ofReal (s^Module.finrank ℝ E)*μ S := by have he : (fun x : E => c+s • x) '' S=(fun x : E => c+x) '' (s • S) := by rw [← Set.image_smul,← Set.image_comp] rfl rw [he] have hh : μ ((fun x : E => c+x) '' (s • S))=μ (s • S) := by rw [← measure_preimage_add μ c ((fun x : E => c+x) '' (s • S)), preimage_image_eq _ (add_right_injective c)] rw [hh,μ.addHaar_smul_of_nonneg hs] lemma preimage (c : E) {s : ℝ} (hs : 0 < s) (S : Set E) : μ S=ENNReal.ofReal (s^Module.finrank ℝ E)*μ ((fun x : E => c+s • x) ⁻¹' S) := by rw [← affine_image μ c hs.le] congr 1 symm apply image_preimage_eq intro y refine ⟨s⁻¹ • (y-c),?_⟩ dsimp only rw [smul_inv_smul₀ hs.ne'] abel end AffineMeasure namespace AffineRescale open Set Filter MeasureTheory open scoped Topology InnerProductSpace NNReal variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] omit [FiniteDimensional ℝ E] in lemma hasFDerivAt_map (c : E) (s : ℝ) (x : E) : HasFDerivAt (fun y => c+s • y) (s • ContinuousLinearMap.id ℝ E) x := by exact ((hasFDerivAt_id x).const_smul s).const_add c omit [FiniteDimensional ℝ E] in lemma differentiable {v : E → ℝ} (hv : Differentiable ℝ v) (c : E) (s k : ℝ) : Differentiable ℝ (fun x => k*v (c+s • x)) := fun x => (((hv (c+s • x)).hasFDerivAt.comp x (hasFDerivAt_map c s x)).const_mul k).differentiableAt lemma gradient {v : E → ℝ} (hv : Differentiable ℝ v) (c : E) (s k : ℝ) (x : E) : _root_.gradient (fun x => k*v (c+s • x)) x=(k*s) • _root_.gradient v (c+s • x) := by apply (InnerProductSpace.toDual ℝ E).injective rw [map_smul,toDual_gradient,toDual_gradient] have hh := ((hv (c+s • x)).hasFDerivAt.comp x (hasFDerivAt_map c s x)).const_mul k change HasFDerivAt (fun y => k*v (c+s • y)) _ x at hh rw [hh.fderiv] ext y simp only [smul_apply,ContinuousLinearMap.comp_apply, ContinuousLinearMap.id_apply,map_smul,smul_eq_mul] ring lemma hessian {v : E → ℝ} (hv : Differentiable ℝ v) (c : E) (s k : ℝ) (x : E) (hdg : DifferentiableAt ℝ (_root_.gradient v) (c+s • x)) : fderiv ℝ (_root_.gradient (fun x => k*v (c+s • x))) x= (k*s^2) • fderiv ℝ (_root_.gradient v) (c+s • x) := by have he : _root_.gradient (fun x => k*v (c+s • x))= fun x => (k*s) • _root_.gradient v (c+s • x) := funext (gradient hv c s k) rw [he] have hh := (hdg.hasFDerivAt.comp x (hasFDerivAt_map c s x)).const_smul (k*s) change HasFDerivAt (fun y => (k*s) • _root_.gradient v (c+s • y)) _ x at hh rw [hh.fderiv] ext y simp only [smul_apply,ContinuousLinearMap.comp_apply, ContinuousLinearMap.id_apply,map_smul,smul_smul] congr 1 ring lemma gradient_lipschitz {v : E → ℝ} (hv : Differentiable ℝ v) {L : ℝ≥0} (hl : LipschitzWith L (_root_.gradient v)) (c : E) (s k : ℝ) : LipschitzWith (‖k*s‖₊*(L*‖s‖₊)) (_root_.gradient (fun x => k*v (c+s • x))) := by have he : _root_.gradient (fun x => k*v (c+s • x))= fun x => (k*s) • _root_.gradient v (c+s • x) := funext (gradient hv c s k) rw [he] apply LipschitzWith.of_dist_le_mul intro x y simp only [dist_eq_norm,← smul_sub,norm_smul,Real.norm_eq_abs,NNReal.coe_mul,coe_nnnorm] have hh := hl.norm_sub_le (c+s • x) (c+s • y) have he : c+s • x-(c+s • y)=s • (x-y) := by module rw [he,norm_smul,Real.norm_eq_abs] at hh nlinarith [mul_le_mul_of_nonneg_left hh (abs_nonneg (k*s))] end AffineRescale namespace HarnackScale open Set Filter Metric MeasureTheory MeasureTheory.Measure open scoped Topology InnerProductSpace Matrix NNReal ENNReal variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] variable {ι : Type*} [Fintype ι] [DecidableEq ι] variable (μ : Measure E) [μ.IsAddHaarMeasure] lemma pde_rescale (b : OrthonormalBasis ι ℝ E) {v : E → ℝ} (hv : Differentiable ℝ v) {L : ℝ≥0} (hL : LipschitzWith L (gradient v)) {A : E → Matrix ι ι ℝ} {S : Set E} {B : ℝ} (hB : 0≤B) (hP : ∀ᵐ x ∂μ, x∈S → (A x*ABPGeometry.hessianMatrix b v x).trace≤1+B*‖gradient v x‖) (c : E) {s k : ℝ} (hs : 0 < s) (hs1 : s≤1) (hk : 0 k*v (c+s • y)) x).trace≤ 1+B*‖gradient (fun y => k*v (c+s • y)) x‖ := by have hdg := hL.ae_differentiableAt (μ:=μ) have hQ := AffineMeasure.quasi μ c hs.ne' filter_upwards [hQ.ae hP,hQ.ae hdg] with x hx hxd hxS have hh := hx hxS rw [AffineRescale.gradient hv] unfold ABPGeometry.hessianMatrix rw [AffineRescale.hessian hv c s k x hxd] simp only [ContinuousLinearMap.toLinearMap_smul,map_smul,Matrix.mul_smul,Matrix.trace_smul, smul_eq_mul,norm_smul,Real.norm_eq_abs,abs_of_pos (mul_pos hk hs)] have hks : 0≤k*s^2 := by positivity have hss : s^2≤1 := by nlinarith have hks1 : k*s^2≤1 := by nlinarith have hss' : s^2 ≤ s := by nlinarith have hb : B*(k*s^2*‖gradient v (c+s • x)‖)≤B*(k*s*‖gradient v (c+s • x)‖) := by gcongr have hmul := mul_le_mul_of_nonneg_left hh hks unfold ABPGeometry.hessianMatrix at hmul nlinarith end HarnackScale namespace LaminarCover open Set MeasureTheory open scoped ENNReal variable {X : Type*} {I : Type*} [MeasurableSpace X] [Countable I] def maximal (B : I → Set X) (rank : I → ℕ) (S : Set I) : Set I := {i | i∈S ∧ ∀ j∈S, rank j ∃ j∈S, rank j=k ∧ x∈B j have hp : ∃ k, P k := ⟨rank i,i,hi,rfl,hxi⟩ obtain ⟨j,hj,hr,hxj⟩ := Nat.find_spec hp refine mem_iUnion₂.mpr ⟨j,⟨hj,?_⟩,hxj⟩ intro k hk hkj by_contra hnd have hxk := horder j k hkj hnd hxj have hh : P (rank k) := ⟨k,hk,rfl,hxk⟩ have hm := Nat.find_min' hp hh rw [← hr] at hm exact (not_le_of_gt hkj) hm omit [MeasurableSpace X] [Countable I] in lemma maximal_disjoint (B : I → Set X) (rank : I → ℕ) (S : Set I) (hequal : ∀ i j, rank i=rank j → i≠j → Disjoint (B i) (B j)) : (maximal B rank S).PairwiseDisjoint B := by intro i hi j hj hij rcases lt_trichotomy (rank i) (rank j) with h|h|h · exact (hj.2 i hi.1 h).symm · exact hequal i j h hij · exact hi.2 j hj.1 h theorem measure_le_of_laminar_cover (μ : Measure X) (B : I → Set X) (rank : I → ℕ) (S : Set I) (E F : Set X) (theta : ℝ≥0∞) (hB : ∀ i, MeasurableSet (B i)) (horder : ∀ i j, rank j hdensity i i.property.1) _ = theta*(∑' i : T, μ (B i)) := ENNReal.tsum_mul_left _ = theta*μ (⋃ i∈T, B i) := by rw [measure_biUnion (to_countable T) hdis (fun i _=>hB i)] _ ≤ theta*μ F := by gcongr exact iUnion₂_subset (fun i hi=>hinside i hi.1) end LaminarCover namespace DyadicBoxes open Set MeasureTheory BoxIntegral open scoped ENNReal variable {ι : Type*} [Fintype ι] [Nonempty ι] lemma good_parents_cover (μ : Measure (ι → ℝ)) (I : Box ι) {U : Set (ι → ℝ)} (hU : IsOpen U) {theta : ℝ≥0∞} (htheta : theta<1) (hpos : ∀ p, μ (box I p : Set (ι → ℝ))≠0) (hfin : ∀ p, μ (box I p : Set (ι → ℝ))≠⊤) (hroot : μ (U∩I)≤theta*μ I) : (U∩I) ⊆ ⋃ p ∈ {p : List (Set ι) | μ ((U∩I)∩box I p)≤theta*μ (box I p) ∧ ∃ s : Set ι, theta*μ (box I (p++[s]))<μ ((U∩I)∩box I (p++[s]))}, (box I p : Set (ι → ℝ)) := by classical intro x hx obtain ⟨n,hn⟩ := exists_small_level I hU hx.1 obtain ⟨p,hp,hxp⟩ := level_cover I n hx.2 have hsub : (box I p : Set (ι → ℝ))⊆U∩I := subset_inter (hn p hp hxp) (box_le I p) have hi : (U∩I)∩(box I p : Set (ι → ℝ))=box I p := inter_eq_right.mpr hsub have hbad : theta*μ (box I p)<μ ((U∩I)∩box I p) := by rw [hi] simpa only [one_mul] using ENNReal.mul_lt_mul_left (hpos p) (hfin p) htheta let P : ℕ → Prop := fun k => ∃ p : List (Set ι), p.length=k ∧ x∈box I p ∧ theta*μ (box I p)<μ ((U∩I)∩box I p) have hex : ∃ k,P k := ⟨p.length,p,rfl,hxp,hbad⟩ obtain ⟨q,hq,hxq,hbadq⟩ := Nat.find_spec hex have hqne : q≠[] := by intro he subst q have hb : theta*μ I<μ (U∩I) := by simpa only [box,inter_assoc,inter_self] using hbadq exact (not_lt_of_ge hroot) hb let a := q.dropLast let s := q.getLast hqne have hqa : a++[s]=q := List.dropLast_append_getLast hqne have hxa : x∈box I a := by rw [← hqa,box_append] at hxq exact box_le (box I a) [s] hxq have ha : a.length (box I p : Set (ι → ℝ))) List.length S (U∩I) F theta (fun p => (box I p).measurableSet_coe) · intro p q hpq hnd exact (comparable I p q hpq.le).resolve_right hnd · exact same_level_disjoint I · exact good_parents_cover μ I hU htheta hpos hfin hroot · intro p hp obtain ⟨s,hs⟩ := hp.2 exact hparent p s hs · exact fun p hp => hp.1 theorem superlevel_tail (μ : Measure (ι → ℝ)) (I : Box ι) {v : (ι → ℝ) → ℝ} (hv : Continuous v) {M : ℝ} (hM : 1≤M) {theta : ℝ≥0∞} (htheta : theta<1) (hpos : ∀ p, μ (box I p : Set (ι → ℝ))≠0) (hfin : ∀ p, μ (box I p : Set (ι → ℝ))≠⊤) (hroot : μ ({x | M simpa only [pow_zero,one_mul] using measure_mono (inter_subset_right : ({x | 1 let U : Set (ι → ℝ) := {x | M^(k+1) by intro x hx refine ⟨?_,box_le I p hx⟩ by_contra he have hs := hstep p s k ⟨x,hx,le_of_not_gt he⟩ have hi : (U∩I)∩(box I (p++[s]) : Set (ι → ℝ))=U∩box I (p++[s]) := by ext y constructor · exact fun hy => ⟨hy.1.1,hy.2⟩ · exact fun hy => ⟨⟨hy.1,box_le I (p++[s]) hy.2⟩,hy.2⟩ rw [hi] at hbad exact (not_lt_of_ge hs) hbad) exact hh.trans (by simpa only [pow_succ',mul_assoc] using (mul_le_mul (le_rfl : theta≤theta) ih (by positivity) (by positivity))) end DyadicBoxes namespace WeakHarnack open Set Filter Metric MeasureTheory BoxIntegral open scoped Topology InnerProductSpace Matrix NNReal ENNReal variable {ι : Type*} [Fintype ι] [DecidableEq ι] [Nonempty ι] local notation "E" => EuclideanSpace ℝ ι local notation "I₀" => (CubeGeometry.unitBox : Box ι) omit [DecidableEq ι] [Nonempty ι] in lemma toLp_measure (I : Box ι) {v : E → ℝ} (hv : Continuous v) (t : ℝ) : volume ({x : ι → ℝ | t c+s • x) ⁻¹' {x | M*t hvn x (hsub hx)) (hA.mono (fun x hh hx => hh (hsub hx))) (hAT.mono (fun x hh hx => hh (hsub hx))) (hP.mono (fun x hh hx => hh (hsub hx))) obtain ⟨x,hx,hvx⟩ := hlo refine ⟨WithLp.toLp 2 x,?_,hvx⟩ rw [mem_closedBall,dist_zero_right] have hh := CubeGeometry.norm_unit hx linarith have hlocal (p : List (Set ι)) (a : Set ι) (k : ℕ) (hp : ∃ x∈DyadicBoxes.box I₀ p, v (WithLp.toLp 2 x)≤M^k) : volume ({x : ι → ℝ | M^(k+1) t⁻¹*v (c+s • x) have hs : 0 A (c+s • x)) (AffineRescale.differentiable hv c s t⁻¹) (AffineRescale.gradient_lipschitz hv hL c s t⁻¹) (fun x hx => mul_nonneg hk.le (hvn _ (hb x hx))) ((hQ.ae hA).mono (fun x hh hx => hh (hb x hx))) ((hQ.ae hAT).mono (fun x hh hx => hh (hb x hx))) (hwp.mono (fun x hh hx => hh (hb x hx))) have hloW : ∃ x∈closedBall (0:E) (2*(Fintype.card ι:ℝ)),w x≤1 := by obtain ⟨x,hx,hvx⟩ := hp refine ⟨s⁻¹ • (WithLp.toLp 2 x-c),?_,?_⟩ · rw [mem_closedBall,dist_zero_right] exact CubeGeometry.normalized_parent p a hx · have he : c+s • (s⁻¹ • (WithLp.toLp 2 x-c))=WithLp.toLp 2 x := by rw [smul_inv_smul₀ hs.ne'] abel dsimp only [w] rw [he,← div_eq_inv_mul] exact (div_le_one ht).mpr hvx have hh := rescale_density hv.continuous ht (p++[a]) (hw hloW) simpa only [t,pow_succ',Nat.add_comm] using hh have hh := DyadicBoxes.superlevel_tail volume I₀ (hv.continuous.comp (PiLp.continuous_toLp 2 _)) hM.le hth1 (fun p => box_pos _) (fun p => (Box.measure_coe_lt_top (DyadicBoxes.box I₀ p) volume).ne) hroot (by simpa only [Function.comp_apply] using hlocal) simpa only [CubeGeometry.volume_unitBox,mul_one,Function.comp_apply] using hh end WeakHarnack namespace TailLimit open MeasureTheory Filter Set Topology open scoped ENNReal variable {X : Type*} [MeasurableSpace X] (μ : Measure X) lemma superlevel {v : ℕ → X → ℝ} {w : X → ℝ} {K : Set X} {t : ℝ} {c : ℝ≥0∞} (hv : ∀ᵐ x ∂μ, Tendsto (fun n => v n x) atTop (𝓝 (w x))) (hm : ∀ᶠ n in atTop, μ ({x | t mem_iInter₂.mp hx.2 n (hNM.trans hn)) have hSc (N : ℕ) : μ (S N)≤c := by obtain ⟨i,hi,hiN⟩ := (hm.and (eventually_ge_atTop N)).exists apply le_trans (measure_mono (show S N⊆{x | t hN n hn)⟩ lemma finite_common {ι : Type*} [Fintype ι] {S : ι → Set X} {K : Set X} {c : ℝ≥0∞} (hS : ∀ i, μ (S i∩K)≤c) (hc : (Fintype.card ι:ℝ≥0∞)*c<μ K) : ∃ x∈K, ∀ i, x∉S i := by by_contra! h have hk : K⊆⋃ i,S i∩K := by intro x hx obtain ⟨i,hi⟩ := h x hx exact mem_iUnion.mpr ⟨i,hi,hx⟩ have hh := (measure_mono (μ:=μ) hk).trans (measure_iUnion_le (μ:=μ) (fun i => S i∩K)) have hs : (∑' i, μ (S i∩K))≤(Fintype.card ι:ℝ≥0∞)*c := by rw [tsum_fintype] simpa using Finset.sum_le_sum (fun i (_ : i∈Finset.univ) => hS i) exact (not_lt_of_ge (hh.trans hs)) hc end TailLimit namespace WeakHarnack open MeasureTheory Set Metric Filter BoxIntegral open scoped NNReal ENNReal Topology InnerProductSpace variable {ι : Type*} [Fintype ι] [DecidableEq ι] [Nonempty ι] local notation "E" => EuclideanSpace ℝ ι local notation "I₀" => (CubeGeometry.unitBox : Box ι) theorem exists_limit_tail (b : OrthonormalBasis ι ℝ E) {ell T B : ℝ} (hell : 0 v n x) atTop (𝓝 (w x))) → ∀ k : ℕ, volume ({x : ι → ℝ | M^k φ (x+h)+φ (x-h)-2*φ x) _ z convert (hp'.add hm').sub (h0.hasFDerivAt.const_smul (2:ℝ)) using 1 <;> rfl lemma gradient_scalar {φ : E → ℝ} (hd : Differentiable ℝ φ) (h z : E) : gradient (scalar φ h) z=vector (gradient φ) h z := by apply (InnerProductSpace.toDual ℝ E).injective rw [toDual_gradient,(scalar_hasFDerivAt (hd _) (hd _) (hd _)).fderiv] simp only [vector,map_sub,map_add,map_smul,toDual_gradient] omit [FiniteDimensional ℝ E] in lemma vector_hasFDerivAt {X : E → E} {h z : E} (hp : DifferentiableAt ℝ X (z+h)) (hm : DifferentiableAt ℝ X (z-h)) (h0 : DifferentiableAt ℝ X z) : HasFDerivAt (vector X h) (fderiv ℝ X (z+h)+fderiv ℝ X (z-h)-(2:ℝ) • fderiv ℝ X z) z := by have hp' := hp.hasFDerivAt.comp z ((hasFDerivAt_id z).add_const h) have hm' := hm.hasFDerivAt.comp z ((hasFDerivAt_id z).sub_const h) change HasFDerivAt (fun x => X (x+h)+X (x-h)-(2:ℝ) • X x) _ z convert (hp'.add hm').sub (h0.hasFDerivAt.const_smul (2:ℝ)) using 1 <;> rfl lemma matrix_gradient_scalar {ι : Type*} [Fintype ι] [DecidableEq ι] (b : OrthonormalBasis ι ℝ E) {φ : E → ℝ} (hd : Differentiable ℝ φ) {h z : E} (hp : DifferentiableAt ℝ (gradient φ) (z+h)) (hm : DifferentiableAt ℝ (gradient φ) (z-h)) (h0 : DifferentiableAt ℝ (gradient φ) z) : LinearMap.toMatrix b.toBasis b.toBasis (fderiv ℝ (gradient (scalar φ h)) z).toLinearMap = LinearMap.toMatrix b.toBasis b.toBasis (fderiv ℝ (gradient φ) (z+h)).toLinearMap+ LinearMap.toMatrix b.toBasis b.toBasis (fderiv ℝ (gradient φ) (z-h)).toLinearMap- (2:ℝ) • LinearMap.toMatrix b.toBasis b.toBasis (fderiv ℝ (gradient φ) z).toLinearMap := by rw [show gradient (scalar φ h)=vector (gradient φ) h from funext (gradient_scalar hd h), (vector_hasFDerivAt hp hm h0).fderiv] simp only [ContinuousLinearMap.toLinearMap_sub,ContinuousLinearMap.toLinearMap_add, ContinuousLinearMap.toLinearMap_smul,map_sub,map_add,map_smul] end SecondDifference namespace DeficitQuotient open Set Matrix open scoped InnerProductSpace NNReal variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] variable {ι : Type*} [Fintype ι] [DecidableEq ι] def hessian (b : OrthonormalBasis ι ℝ E) (φ : E → ℝ) (x : E) : Matrix ι ι ℝ := LinearMap.toMatrix b.toBasis b.toBasis (fderiv ℝ (gradient φ) x).toLinearMap def deficit (φ : E → ℝ) (h : E) (M k : ℝ) (x : E) : ℝ := M-k*SecondDifference.scalar φ h x omit [FiniteDimensional ℝ E] in lemma differentiable {φ : E → ℝ} (hd : Differentiable ℝ φ) (h : E) (M k : ℝ) : Differentiable ℝ (deficit φ h M k) := by intro x exact (((SecondDifference.scalar_hasFDerivAt (hd _) (hd _) (hd _)).const_mul k).const_sub M).differentiableAt lemma gradient_deficit {φ : E → ℝ} (hd : Differentiable ℝ φ) (h : E) (M k : ℝ) (x : E) : gradient (deficit φ h M k) x=(-k) • SecondDifference.vector (gradient φ) h x := by apply (InnerProductSpace.toDual ℝ E).injective rw [map_smul,toDual_gradient] have hh := ((SecondDifference.scalar_hasFDerivAt (hd (x+h)) (hd (x-h)) (hd x)).const_mul k).const_sub M rw [show (fun y => M-k*SecondDifference.scalar φ h y)=deficit φ h M k from rfl] at hh rw [hh.fderiv] simp only [SecondDifference.vector,map_sub,map_add,map_smul,toDual_gradient] module lemma gradient_lipschitz {φ : E → ℝ} (hd : Differentiable ℝ φ) {L : ℝ≥0} (hL : LipschitzWith L (gradient φ)) (h : E) (M k : ℝ) : LipschitzWith (‖k‖₊*(L+L+2*L)) (gradient (deficit φ h M k)) := by apply LipschitzWith.of_dist_le_mul intro x y rw [gradient_deficit hd,gradient_deficit hd,dist_eq_norm,← smul_sub,norm_smul] have hp := hL.norm_sub_le (x+h) (y+h) have hm := hL.norm_sub_le (x-h) (y-h) have h0 := hL.norm_sub_le x y simp only [add_sub_add_right_eq_sub] at hp simp only [sub_sub_sub_cancel_right] at hm have he : SecondDifference.vector (gradient φ) h x-SecondDifference.vector (gradient φ) h y = (gradient φ (x+h)-gradient φ (y+h))+(gradient φ (x-h)-gradient φ (y-h))- (2:ℝ) • (gradient φ x-gradient φ y) := by simp only [SecondDifference.vector,smul_sub]; abel rw [he] have hh := norm_sub_le ((gradient φ (x+h)-gradient φ (y+h))+ (gradient φ (x-h)-gradient φ (y-h))) ((2:ℝ) • (gradient φ x-gradient φ y)) have hj := norm_add_le (gradient φ (x+h)-gradient φ (y+h)) (gradient φ (x-h)-gradient φ (y-h)) simp only [norm_smul,Real.norm_eq_abs,abs_of_pos (by norm_num : (0:ℝ)<2)] at hh simp only [norm_neg,NNReal.coe_mul,NNReal.coe_add,NNReal.coe_ofNat,coe_nnnorm,dist_eq_norm] rw [mul_assoc] apply mul_le_mul_of_nonneg_left _ (norm_nonneg k) nlinarith lemma hessian_deficit (b : OrthonormalBasis ι ℝ E) {φ : E → ℝ} (hd : Differentiable ℝ φ) {h x : E} (M k : ℝ) (hp : DifferentiableAt ℝ (gradient φ) (x+h)) (hm : DifferentiableAt ℝ (gradient φ) (x-h)) (h0 : DifferentiableAt ℝ (gradient φ) x) : hessian b (deficit φ h M k) x = (-k) • (hessian b φ (x+h)+hessian b φ (x-h)-(2:ℝ) • hessian b φ x) := by have he : gradient (deficit φ h M k) = fun x => (-k) • SecondDifference.vector (gradient φ) h x := funext (gradient_deficit hd h M k) dsimp only [hessian] rw [he] have hh := (SecondDifference.vector_hasFDerivAt hp hm h0).const_smul (-k) change HasFDerivAt (fun x => (-k) • SecondDifference.vector (gradient φ) h x) _ x at hh rw [hh.fderiv] simp only [ContinuousLinearMap.toLinearMap_sub,ContinuousLinearMap.toLinearMap_add, ContinuousLinearMap.toLinearMap_smul,map_smul,map_sub,map_add] lemma pde (b : OrthonormalBasis ι ℝ E) {φ : E → ℝ} (hd : Differentiable ℝ φ) {h x : E} {M k F B σ : ℝ} (hk : 0≤k) {A : Matrix ι ι ℝ} {v : E} (hp : DifferentiableAt ℝ (gradient φ) (x+h)) (hm : DifferentiableAt ℝ (gradient φ) (x-h)) (h0 : DifferentiableAt ℝ (gradient φ) x) (hv : ‖v‖≤B) (hF : σ*SecondDifference.scalar φ h x≤F) (he : ⟪v,SecondDifference.vector (gradient φ) h x⟫_ℝ ≤ (A*(hessian b φ (x+h)+hessian b φ (x-h)-(2:ℝ) • hessian b φ x)).trace+ σ*SecondDifference.scalar φ h x) : (A*hessian b (deficit φ h M k) x).trace ≤ k*F+B*‖gradient (deficit φ h M k) x‖ := by rw [hessian_deficit b hd M k hp hm h0,Matrix.mul_smul,Matrix.trace_smul] rw [gradient_deficit hd,norm_smul,Real.norm_eq_abs,abs_neg,abs_of_nonneg hk] have hvip := abs_real_inner_le_norm v (SecondDifference.vector (gradient φ) h x) have hw := mul_le_mul_of_nonneg_right hv (norm_nonneg (SecondDifference.vector (gradient φ) h x)) have hc := mul_le_mul_of_nonneg_left (le_trans (neg_le_abs _) (hvip.trans hw)) hk have h1 := mul_le_mul_of_nonneg_left he hk have h2 := mul_le_mul_of_nonneg_left hF hk simp only [smul_eq_mul] nlinarith end DeficitQuotient namespace AESlice section open MeasureTheory MeasureTheory.Measure Set Filter Metric open scoped Topology NNReal variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] variable (μ : Measure E) [μ.IsAddHaarMeasure] lemma ae_lines {P : E → Prop} (hP : ∀ᵐ x ∂μ, P x) (e : E) : ∀ᵐ x ∂μ, ∀ᵐ t ∂(volume : Measure ℝ), P (x+t • e) := by obtain ⟨N,hN,hNm,hN0⟩ := exists_measurable_superset_of_null (ae_iff.mp hP) have hNae : ∀ᵐ x ∂μ, x∉N := by rw [ae_iff] convert hN0 using 2; ext x; simp have hpre : MeasurableSet {p : E×ℝ | p.1+p.2 • e∉N} := by exact (hNm.preimage (show Measurable (fun p : E×ℝ => p.1+p.2 • e) by fun_prop)).compl have ht : ∀ᵐ t ∂(volume : Measure ℝ), ∀ᵐ x ∂μ, x+t • e∉N := by exact ae_of_all _ (fun t => (measurePreserving_add_right μ (t • e)).quasiMeasurePreserving.ae hNae) have hh := (ae_ae_comm hpre).mpr ht filter_upwards [hh] with x hx filter_upwards [hx] with t ht exact not_not.mp (fun hn => ht (hN hn)) omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in lemma line_lipschitz (x e : E) : LipschitzWith ‖e‖₊ (fun t : ℝ => x+t • e) := by rw [lipschitzWith_iff_dist_le_mul] intro s t simp only [dist_eq_norm,add_sub_add_left_eq_sub,← sub_smul,norm_smul,Real.norm_eq_abs] exact le_of_eq (mul_comm _ _) omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in lemma line_deriv (g : E → ℝ) {x e : E} {t : ℝ} (hg : DifferentiableAt ℝ g (x+t • e)) : HasDerivAt (fun s : ℝ => g (x+s • e)) ((fderiv ℝ g (x+t • e)) e) t := by simpa only [id_eq,one_smul,Function.comp_def] using hg.hasFDerivAt.comp_hasDerivAt t (((hasDerivAt_id t).smul_const e).const_add x) lemma difference_le_ae {g : E → ℝ} {L : ℝ≥0} (hg : LipschitzWith L g) {Ω : Set E} (hΩ : IsOpen Ω) (hc : Convex ℝ Ω) {e : E} {M : ℝ} (ha : ∀ᵐ x ∂μ, x∈Ω → DifferentiableAt ℝ g x ∧ fderiv ℝ g x e≤M) {x : E} {a : ℝ} (ha0 : 0≤a) (hx : x∈Ω) (hxa : x+a • e∈Ω) : g (x+a • e)-g x≤M*a := by have hl := ae_lines μ ha e let U : Set E := Ω∩(fun y => y+a • e) ⁻¹' Ω have hU : IsOpen U := hΩ.inter (hΩ.preimage (by fun_prop)) have hxU : x∈U := ⟨hx,hxa⟩ have hgood : ∀ᵐ y ∂μ, y∈U → g (y+a • e)-g y≤M*a := by filter_upwards [hl] with y hy hyU have hs (t : ℝ) (ht : t∈Icc 0 a) : y+t • e∈Ω := by by_cases haZ : a=0 · have htZ : t=0 := by rw [haZ] at ht; linarith [ht.1,ht.2] simpa only [htZ,zero_smul,add_zero] using hyU.1 have haP : 0 g (y+s • e)) 0 a := hline.lipschitzOnWith.absolutelyContinuousOnInterval have hi := hac.intervalIntegrable_deriv have hd : ∀ᵐ t ∂(volume.restrict (Icc 0 a)), deriv (fun s => g (y+s • e)) t≤M := by filter_upwards [ae_restrict_of_ae hy,ae_restrict_mem measurableSet_Icc] with t ht hta rw [(line_deriv g (ht (hs t hta)).1).deriv] exact (ht (hs t hta)).2 have hh := intervalIntegral.integral_mono_ae_restrict ha0 hi (intervalIntegrable_const : IntervalIntegrable (fun _ : ℝ => M) volume 0 a) hd rw [hac.integral_deriv_eq_sub] at hh simpa only [zero_smul,add_zero,intervalIntegral.integral_const,sub_zero,smul_eq_mul,mul_comm] using hh have hdense := μ.dense_of_ae hgood have hcl := hdense.open_subset_closure_inter hU hxU have hclosed : IsClosed {y : E | g (y+a • e)-g y≤M*a} := isClosed_le ((hg.continuous.comp (by fun_prop)).sub hg.continuous) continuous_const exact hclosed.closure_subset_iff.mpr (fun y hy => hy.2 hy.1) hcl end open MeasureTheory MeasureTheory.Measure Set Filter Metric open scoped Topology NNReal variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] variable (μ : Measure E) [μ.IsAddHaarMeasure] open scoped InnerProductSpace lemma second_difference_le {φ : E → ℝ} (hd : Differentiable ℝ φ) {L : ℝ≥0} (hL : LipschitzWith L (gradient φ)) {Ω : Set E} (hΩ : IsOpen Ω) (hc : Convex ℝ Ω) {e : E} {M : ℝ} (ha : ∀ᵐ y ∂μ, y∈Ω → DifferentiableAt ℝ (gradient φ) y ∧ ⟪(fderiv ℝ (gradient φ) y) e,e⟫_ℝ≤M) {x : E} {a : ℝ} (ha0 : 0≤a) (hs : ∀ t∈Icc (-a) a, x+t • e∈Ω) : φ (x+a • e)+φ (x-a • e)-2*φ x≤M*a^2 := by let g : E → ℝ := fun y => ⟪e,gradient φ y⟫_ℝ have hg : LipschitzWith (‖innerSL ℝ e‖₊ * L) g := by exact (innerSL ℝ e).lipschitzWith.comp hL have hga : ∀ᵐ y ∂μ, y∈Ω → DifferentiableAt ℝ g y ∧ fderiv ℝ g y e≤M := by filter_upwards [ha] with y hy hyΩ have hh := (innerSL ℝ e).hasFDerivAt.comp y (hy hyΩ).1.hasFDerivAt refine ⟨hh.differentiableAt,?_⟩ change (fderiv ℝ (⇑(innerSL ℝ e) ∘ gradient φ) y) e≤M rw [hh.fderiv] simpa only [ContinuousLinearMap.comp_apply,innerSL_apply_apply,real_inner_comm] using (hy hyΩ).2 let F : ℝ → ℝ := fun t => φ (x+t • e)+φ (x-t • e)-2*φ x-M*t^2 have hline (t : ℝ) : HasDerivAt (fun s : ℝ => φ (x+s • e)) (g (x+t • e)) t := by have hh := (hd (x+t • e)).hasFDerivAt.comp_hasDerivAt t (((hasDerivAt_id t).smul_const e).const_add x) simpa only [Function.comp_def,id_eq,one_smul,← toDual_gradient, InnerProductSpace.toDual_apply_apply,g,real_inner_comm] using hh have hF (t : ℝ) : HasDerivAt F (g (x+t • e)-g (x-t • e)-2*M*t) t := by have hn := (hline (-t)).comp t (hasDerivAt_neg t) convert ((hline t).add hn |>.sub_const (2*φ x)).sub (((hasDerivAt_id t).pow 2).const_mul M) using 1 <;> first | rfl | (dsimp only [id_eq]; simp only [neg_smul,← sub_eq_add_neg]; ring) | (ext s; dsimp only [F,Function.comp_def,Pi.add_apply,Pi.sub_apply,Pi.pow_apply,id_eq]; simp only [neg_smul,← sub_eq_add_neg]) have hnon (t : ℝ) (ht : t∈Icc 0 a) : deriv F t≤0 := by have hm : x-t • e∈Ω := by simpa only [neg_smul,← sub_eq_add_neg] using hs (-t) (by constructor <;> linarith [ht.1,ht.2]) have hp : x+t • e∈Ω := hs t ⟨by linarith [ht.1],ht.2⟩ have he : x-t • e+(2*t) • e=x+t • e := by module have hh := difference_le_ae μ hg hΩ hc hga (show 0≤2*t by linarith [ht.1]) hm (he.symm ▸ hp) rw [he] at hh rw [(hF t).deriv] nlinarith have hfanti := antitoneOn_of_deriv_nonpos (convex_Icc (0:ℝ) a) (fun t _ => (hF t).continuousAt.continuousWithinAt) (fun t _ => (hF t).differentiableAt.differentiableWithinAt) (fun t ht => hnon t (interior_subset ht)) have hh := hfanti ⟨le_rfl,ha0⟩ ⟨ha0,le_rfl⟩ ha0 change F a≤F 0 at hh dsimp only [F] at hh simp only [zero_smul,add_zero,sub_zero,zero_pow (by decide : 2≠0),mul_zero] at hh linarith end AESlice namespace SecondQuotient open Filter Set Topology Asymptotics open scoped InnerProductSpace lemma scalar_limit {f g : ℝ → ℝ} {A : ℝ} (hf : ∀ t, HasDerivAt f (g t) t) (hg : HasDerivAt g A 0) : Tendsto (fun t => (f t+f (-t)-2*f 0)/t^2) (𝓝[≠] 0) (𝓝 A) := by let R : ℝ → ℝ := fun t => f t-f 0-t*g 0-t^2/2*A have hR (t : ℝ) : HasDerivAt R (g t-g 0-t*A) t := by convert ((hf t).sub_const (f 0) |>.sub ((hasDerivAt_id t).mul_const (g 0))).sub (((hasDerivAt_id t).pow 2).div_const 2 |>.mul_const A) using 1 <;> first | rfl | (dsimp only [R,id_eq]; ring) have hgo : (fun t => g t-g 0-t*A) =o[𝓝[univ] 0] (fun t : ℝ => (t-0)^1) := by simpa only [nhdsWithin_univ,sub_zero,pow_one,smul_eq_mul] using hg.isLittleO have hro := Convex.isLittleO_pow_succ_real convex_univ (mem_univ (0:ℝ)) (fun t (_ : t∈(univ:Set ℝ)) => (hR t).hasDerivWithinAt) hgo have hlim : Tendsto (fun t => R t/t^2) (𝓝 (0:ℝ)) (𝓝 0) := by simpa only [nhdsWithin_univ,show R 0=0 by simp [R],sub_zero] using hro.tendsto_div_nhds_zero have hneg : Tendsto (fun t : ℝ => R (-t)/t^2) (𝓝 (0:ℝ)) (𝓝 0) := by simpa only [Function.comp_def,neg_sq] using hlim.comp (show Tendsto (fun t : ℝ => -t) (𝓝 0) (𝓝 0) from by simpa only [neg_zero] using continuous_neg.tendsto (0:ℝ)) have hsum := ((hlim.add hneg).add_const A).mono_left (nhdsWithin_le_nhds : 𝓝[≠] (0:ℝ)≤𝓝 0) simp only [zero_add] at hsum apply hsum.congr' filter_upwards [self_mem_nhdsWithin] with t ht have ht0 : t≠0 := ht dsimp only [R] field_simp [ht0] ring variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] lemma gradient_limit {φ : E → ℝ} (hd : Differentiable ℝ φ) {x e : E} (hH : DifferentiableAt ℝ (gradient φ) x) : Tendsto (fun t : ℝ => (φ (x+t • e)+φ (x-t • e)-2*φ x)/t^2) (𝓝[≠] 0) (𝓝 (⟪(fderiv ℝ (gradient φ) x) e,e⟫_ℝ)) := by let f : ℝ → ℝ := fun t => φ (x+t • e) let g : ℝ → ℝ := fun t => ⟪gradient φ (x+t • e),e⟫_ℝ have hline (t : ℝ) : HasDerivAt (fun s : ℝ => x+s • e) e t := by simpa only [id_eq,one_smul] using ((hasDerivAt_id t).smul_const e).const_add x have hf (t : ℝ) : HasDerivAt f (g t) t := by have hh := (hd (x+t • e)).hasFDerivAt.comp_hasDerivAt t (hline t) simpa only [f,g,Function.comp_def,← toDual_gradient,InnerProductSpace.toDual_apply_apply] using hh have hg : HasDerivAt g (⟪(fderiv ℝ (gradient φ) x) e,e⟫_ℝ) 0 := by have h0 : x+(0:ℝ) • e=x := by simp have hh := (h0 ▸ hH.hasFDerivAt).comp_hasDerivAt 0 (hline 0) have hj := (innerSL ℝ e).hasFDerivAt.comp_hasDerivAt 0 hh simpa only [g,Function.comp_def,ContinuousLinearMap.comp_apply,innerSL_apply_apply, h0,real_inner_comm] using hj simpa only [f,zero_smul,add_zero,neg_smul,← sub_eq_add_neg] using scalar_limit hf hg end SecondQuotient namespace C11Difference open MeasureTheory Set Filter open scoped InnerProductSpace NNReal Topology variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] omit [MeasurableSpace E] [BorelSpace E] in lemma directional_bound {φ : E → ℝ} {L : ℝ≥0} (hL : LipschitzWith L (gradient φ)) (x e : E) : ⟪(fderiv ℝ (gradient φ) x) e,e⟫_ℝ≤(L:ℝ)*‖e‖^2 := by have h1 := (fderiv ℝ (gradient φ) x).le_opNorm e have h2 := norm_fderiv_le_of_lipschitz ℝ hL (x₀:=x) have h3 := real_inner_le_norm ((fderiv ℝ (gradient φ) x) e) e nlinarith [mul_le_mul_of_nonneg_right h1 (norm_nonneg e), mul_le_mul_of_nonneg_right h2 (sq_nonneg ‖e‖)] lemma scalar_bound {φ : E → ℝ} (hd : Differentiable ℝ φ) {L : ℝ≥0} (hL : LipschitzWith L (gradient φ)) (x e : E) {a : ℝ} (ha : 0≤a) : φ (x+a • e)+φ (x-a • e)-2*φ x≤((L:ℝ)*‖e‖^2)*a^2 := by apply AESlice.second_difference_le volume hd hL isOpen_univ convex_univ _ ha (fun _ _ => mem_univ _) filter_upwards [hL.ae_differentiableAt (μ:=(volume:Measure E))] with y hy _ exact ⟨hy,directional_bound hL y e⟩ omit [MeasurableSpace E] [BorelSpace E] in lemma deficit_limit {φ : E → ℝ} (hd : Differentiable ℝ φ) {x e : E} (hH : DifferentiableAt ℝ (gradient φ) x) {δ : ℕ → ℝ} (hδ : Tendsto δ atTop (𝓝 (0:ℝ))) (hδ0 : ∀ n, δ n≠0) {s : ℝ} (hs : s≠0) (M : ℝ) : Tendsto (fun n => M/s-(1/(s*(δ n)^2))*(φ (x+δ n • e)+φ (x-δ n • e)-2*φ x)) atTop (𝓝 ((M-⟪(fderiv ℝ (gradient φ) x) e,e⟫_ℝ)/s)) := by have hδ' : Tendsto δ atTop (𝓝[≠] (0:ℝ)) := tendsto_nhdsWithin_iff.mpr ⟨hδ,Filter.Eventually.of_forall hδ0⟩ have hh := ((SecondQuotient.gradient_limit (e:=e) hd hH).comp hδ').const_sub M |>.div_const s convert hh using 1 ext n dsimp only [Function.comp_def] field_simp [hs,hδ0 n] end C11Difference namespace HessianTail open MeasureTheory Set Filter Metric BoxIntegral open scoped InnerProductSpace NNReal ENNReal Topology variable {ι : Type*} [Fintype ι] [DecidableEq ι] [Nonempty ι] local notation "E" => EuclideanSpace ℝ ι local notation "D" => ((Fintype.card ι:ℝ)/2+(2*(Fintype.card ι:ℝ)+1)) local notation "I₀" => (CubeGeometry.unitBox : Box ι) theorem exists_constants (b : OrthonormalBasis ι ℝ E) {ell T B : ℝ} (hell : 0 < ell) (hT : 0 ≤ T) (hB : 0 ≤ B) : ∃ (K : ℝ) (theta : ℝ≥0∞), 1 < K ∧ 0 < theta ∧ theta < 1 ∧ ∀ (φ : E → ℝ) (L : ℝ≥0) (A : E → Matrix ι ι ℝ) (β : E → E) (e : E) (M s σ : ℝ) (Ω : Set E) (δ : ℕ → ℝ), Differentiable ℝ φ → LipschitzWith L (gradient φ) → IsOpen Ω → Convex ℝ Ω → 0 < s → 0 ≤ σ → σ*((L:ℝ)*‖e‖^2) ≤ s → (∀ n,0 < δ n) → Tendsto δ atTop (𝓝 0) → (∀ n,∀ x∈closedBall (0:E) D,∀ t∈Icc (-δ n) (δ n),x+t • e∈Ω) → (∀ᵐ x ∂volume, x∈Ω → ⟪(fderiv ℝ (gradient φ) x) e,e⟫_ℝ ≤ M) → (∀ᵐ x ∂volume,x∈closedBall (0:E) D → (A x-ell • (1:Matrix ι ι ℝ)).PosSemidef) → (∀ᵐ x ∂volume,x∈closedBall (0:E) D → (A x).trace ≤ T) → (∀ᵐ x ∂volume,x∈closedBall (0:E) D → ‖β x‖ ≤ B) → (∀ h : E,∀ᵐ x ∂volume,x∈closedBall (0:E) D → ⟪β x,SecondDifference.vector (gradient φ) h x⟫_ℝ ≤ (A x*(DeficitQuotient.hessian b φ (x+h)+DeficitQuotient.hessian b φ (x-h)- (2:ℝ) • DeficitQuotient.hessian b φ x)).trace+σ*SecondDifference.scalar φ h x) → (∃ y : ι → ℝ,y∈I₀ ∧ DifferentiableAt ℝ (gradient φ) (WithLp.toLp 2 y) ∧ (M-⟪(fderiv ℝ (gradient φ) (WithLp.toLp 2 y)) e,e⟫_ℝ)/s < 1) → ∀ k : ℕ, volume ({x : ι → ℝ | K^k < (M-⟪(fderiv ℝ (gradient φ) (WithLp.toLp 2 x)) e,e⟫_ℝ)/s}∩I₀) ≤ theta^k := by obtain ⟨K,theta,hK,ht0,ht1,hh⟩ := WeakHarnack.exists_limit_tail b hell hT hB refine ⟨K,theta,hK,ht0,ht1,?_⟩ intro φ L A β e M s σ Ω δ hd hL hΩ hc hs hσ hsF hδ hδlim hseg hupper hA htrace hβ hP hlo let v : ℕ → E → ℝ := fun n => DeficitQuotient.deficit φ (δ n • e) (M/s) (1/(s*(δ n)^2)) let C : ℕ → ℝ≥0 := fun n => ‖1/(s*(δ n)^2)‖₊*(L+L+2*L) have hv (n : ℕ) : Differentiable ℝ (v n) := DeficitQuotient.differentiable hd _ _ _ have hLv (n : ℕ) : LipschitzWith (C n) (gradient (v n)) := DeficitQuotient.gradient_lipschitz hd hL _ _ _ have hH := hL.ae_differentiableAt (μ:=(volume:Measure E)) have hnn (n : ℕ) (x : E) (hx : x∈closedBall (0:E) D) : 0 ≤ v n x := by have hbd := AESlice.second_difference_le volume hd hL hΩ hc (show ∀ᵐ y ∂volume, y∈Ω → DifferentiableAt ℝ (gradient φ) y ∧ ⟪(fderiv ℝ (gradient φ) y) e,e⟫_ℝ ≤ M by filter_upwards [hH,hupper] with y hy hu hyΩ; exact ⟨hy,hu hyΩ⟩) (hδ n).le (hseg n x hx) have hk : 0 < 1/(s*(δ n)^2) := one_div_pos.mpr (mul_pos hs (sq_pos_of_pos (hδ n))) have hbd' := mul_le_mul_of_nonneg_left hbd hk.le have he : (1/(s*(δ n)^2))*(M*(δ n)^2)=M/s := by field_simp [ne_of_gt hs,ne_of_gt (hδ n)] rw [he] at hbd' exact sub_nonneg.mpr hbd' have hconv : ∀ᵐ x ∂volume,Tendsto (fun n => v n x) atTop (𝓝 ((M-⟪(fderiv ℝ (gradient φ) x) e,e⟫_ℝ)/s)) := by filter_upwards [hH] with x hx exact C11Difference.deficit_limit (e:=e) hd hx hδlim (fun n => ne_of_gt (hδ n)) (ne_of_gt hs) M have hpde (n : ℕ) : ∀ᵐ x ∂volume,x∈closedBall (0:E) D → (A x*ABPGeometry.hessianMatrix b (v n) x).trace ≤ 1+B*‖gradient (v n) x‖ := by have hHp := (measurePreserving_add_right (volume:Measure E) (δ n • e)).quasiMeasurePreserving.ae hH have hHm := (measurePreserving_add_right (volume:Measure E) (-(δ n • e))).quasiMeasurePreserving.ae hH filter_upwards [hH,hHp,hHm,hP (δ n • e),hβ] with x hx hxp hxm hep hb hxD simp only [← sub_eq_add_neg] at hxm have hF := mul_le_mul_of_nonneg_left (C11Difference.scalar_bound hd hL x e (hδ n).le) hσ have hpde := DeficitQuotient.pde b hd (M:=M/s) (k:=1/(s*(δ n)^2)) (by positivity) hxp hxm hx (hb hxD) hF (hep hxD) have he : (1/(s*(δ n)^2))*(σ*(((L:ℝ)*‖e‖^2)*(δ n)^2)) = (σ*((L:ℝ)*‖e‖^2))/s := by field_simp [ne_of_gt hs,ne_of_gt (hδ n)] rw [he] at hpde exact hpde.trans (add_le_add ((div_le_one hs).mpr hsF) le_rfl) have hlow : ∀ᶠ n in atTop,∃ y : ι → ℝ,y∈I₀ ∧ v n (WithLp.toLp 2 y) ≤ 1 := by obtain ⟨y,hy,hyd,hyl⟩ := hlo have hcy := C11Difference.deficit_limit (e:=e) hd hyd hδlim (fun n => ne_of_gt (hδ n)) (ne_of_gt hs) M filter_upwards [hcy.eventually (gt_mem_nhds hyl)] with n hn exact ⟨y,hy,hn.le⟩ exact hh v C (fun _ => A) _ hv hLv hnn (fun _ => hA) (fun _ => htrace) hpde hlow hconv end HessianTail namespace SmallSequence open Filter Set Metric open scoped Topology variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] lemma exists_shift_sequence (e : E) : ∃ δ : ℕ → ℝ, (∀ n,0<δ n) ∧ Tendsto δ atTop (𝓝 0) ∧ ∀ (R : ℝ) (n : ℕ) (x : E),x∈closedBall 0 R → ∀ t∈Icc (-δ n) (δ n),x+t • e∈ball 0 (R+1) := by let a : ℝ := 1/(2*(‖e‖+1)) have ha : 0 a/((n:ℝ)+1) have hδ (n : ℕ) : 0<δ n := div_pos ha (by positivity) have hδle (n : ℕ) : δ n≤a := by apply (div_le_iff₀ (by positivity : 0<(n:ℝ)+1)).mpr nlinarith [Nat.cast_nonneg (α:=ℝ) n] have hlim : Tendsto δ atTop (𝓝 0) := by simpa only [mul_one_div,mul_zero] using tendsto_one_div_add_atTop_nhds_zero_nat.const_mul a refine ⟨δ,hδ,hlim,?_⟩ intro R n x hx t ht have ht' : |t|≤δ n := abs_le.mpr ht have hn : δ n*‖e‖<1 := by have hb : a*‖e‖<1 := by dsimp only [a] rw [one_div_mul_eq_div] apply (div_lt_one (by positivity)).mpr linarith [norm_nonneg e] exact (mul_le_mul_of_nonneg_right (hδle n) (norm_nonneg e)).trans_lt hb rw [mem_ball,dist_zero_right] have hh := norm_add_le x (t • e) rw [norm_smul,Real.norm_eq_abs] at hh have hx' : ‖x‖≤R := by simpa only [mem_closedBall,dist_zero_right] using hx have ht'' := mul_le_mul_of_nonneg_right ht' (norm_nonneg e) linarith end SmallSequence namespace OscillationEnvelope open Set def upper {X : Type*} (f : X → ℝ) (K : Set X) : ℝ := sSup (f '' K) def lower {X : Type*} (f : X → ℝ) (K : Set X) : ℝ := sInf (f '' K) def span {X : Type*} (f : X → ℝ) (K : Set X) : ℝ := upper f K-lower f K variable {X : Type*} {f : X → ℝ} {K J : Set X} lemma le_upper (h : BddAbove (f '' K)) {x : X} (hx : x∈K) : f x ≤ upper f K := le_csSup h (mem_image_of_mem f hx) lemma lower_le (h : BddBelow (f '' K)) {x : X} (hx : x∈K) : lower f K ≤ f x := csInf_le h (mem_image_of_mem f hx) lemma upper_mono (hJK : J⊆K) (hJ : J.Nonempty) (hK : BddAbove (f '' K)) : upper f J ≤ upper f K := csSup_le (hJ.image f) (fun _ hx => le_csSup hK (image_mono hJK hx)) lemma lower_mono (hJK : J⊆K) (hJ : J.Nonempty) (hK : BddBelow (f '' K)) : lower f K ≤ lower f J := le_csInf (hJ.image f) (fun _ hx => csInf_le hK (image_mono hJK hx)) lemma span_nonneg (hK : K.Nonempty) (hu : BddAbove (f '' K)) (hl : BddBelow (f '' K)) : 0 ≤ span f K := by obtain ⟨x,hx⟩ := hK exact sub_nonneg.mpr ((lower_le hl hx).trans (le_upper hu hx)) lemma exists_near_upper (hK : K.Nonempty) {η : ℝ} (hη : 0 < η) : ∃ x∈K,upper f K-η < f x := by obtain ⟨v,hv,hlt⟩ := exists_lt_of_lt_csSup (hK.image f) (show upper f K-η < sSup (f '' K) by dsimp only [upper]; linarith) obtain ⟨x,hx,rfl⟩ := hv exact ⟨x,hx,hlt⟩ lemma span_le_of_osc (hK : K.Nonempty) {C : ℝ} (h : ∀ x∈K,∀ y∈K,f x-f y ≤ C) : span f K ≤ C := by have h1 (x : X) (hx : x∈K) : f x-C ≤ lower f K := by apply le_csInf (hK.image f) rintro _ ⟨y,hy,rfl⟩ linarith [h x hx y hy] have h2 : upper f K ≤ C+lower f K := by apply csSup_le (hK.image f) rintro _ ⟨x,hx,rfl⟩ linarith [h1 x hx] exact sub_le_iff_le_add.mpr (by linarith) lemma span_drop (hJK : J⊆K) (hJ : J.Nonempty) (hl : BddBelow (f '' K)) : span f J ≤ span f K-(upper f K-upper f J) := by have hh := lower_mono hJK hJ hl dsimp only [span] linarith variable {ι : Type*} [Fintype ι] lemma sum_drop {f : ι → X → ℝ} (hJK : J⊆K) (hJ : J.Nonempty) (hl : ∀ i,BddBelow (f i '' K)) : Finset.univ.sum (fun i => span (f i) J) ≤ Finset.univ.sum (fun i => span (f i) K) - Finset.univ.sum (fun i => upper (f i) K - upper (f i) J) := by have hh := Finset.sum_le_sum (s:=Finset.univ) (fun i _ => span_drop (f:=f i) hJK hJ (hl i)) simp only [Finset.sum_sub_distrib] at hh ⊢ exact hh end OscillationEnvelope namespace HessianTail open MeasureTheory Set Filter Metric BoxIntegral OscillationEnvelope open scoped InnerProductSpace NNReal ENNReal Topology variable {ι : Type*} [Fintype ι] [DecidableEq ι] [Nonempty ι] local notation "E" => EuclideanSpace ℝ ι local notation "D" => ((Fintype.card ι:ℝ)/2+(2*(Fintype.card ι:ℝ)+1)) local notation "I₀" => (CubeGeometry.unitBox : Box ι) def cube : Set E := {x | x.ofLp∈I₀} def direction (φ : E → ℝ) (e : E) (x : E) : ℝ := ⟪fderiv ℝ (gradient φ) x e,e⟫_ℝ omit [DecidableEq ι] [Nonempty ι] in lemma direction_bound {φ : E → ℝ} {L : ℝ≥0} (hL : LipschitzWith L (gradient φ)) (e x : E) : |direction φ e x| ≤ (L:ℝ)*‖e‖^2 := by have hh := abs_real_inner_le_norm (fderiv ℝ (gradient φ) x e) e have hb := (ContinuousLinearMap.le_opNorm (fderiv ℝ (gradient φ) x) e).trans (mul_le_mul_of_nonneg_right (norm_fderiv_le_of_lipschitz ℝ hL (x₀:=x)) (norm_nonneg e)) exact hh.trans (by nlinarith [mul_le_mul_of_nonneg_right hb (norm_nonneg e)]) omit [DecidableEq ι] [Nonempty ι] in lemma direction_bddAbove {φ : E → ℝ} {L : ℝ≥0} (hL : LipschitzWith L (gradient φ)) (e : E) (O : Set E) : BddAbove (direction φ e '' O) := by refine ⟨(L:ℝ)*‖e‖^2,?_⟩ rintro _ ⟨x,_,rfl⟩ exact (le_abs_self _).trans (direction_bound hL e x) omit [DecidableEq ι] [Nonempty ι] in lemma direction_bddBelow {φ : E → ℝ} {L : ℝ≥0} (hL : LipschitzWith L (gradient φ)) (e : E) (O : Set E) : BddBelow (direction φ e '' O) := by refine ⟨-((L:ℝ)*‖e‖^2),?_⟩ rintro _ ⟨x,_,rfl⟩ exact (abs_le.mp (direction_bound hL e x)).1 omit [DecidableEq ι] [Nonempty ι] in lemma cube_measure_inter {G : Set E} (hG : ∀ᵐ x ∂volume,x∈G) : volume (cube∩G)=1 := by have he : (cube∩G : Set E) =ᵐ[volume] (cube : Set E) := by filter_upwards [hG] with x hx exact propext ⟨fun h => h.1,fun h => ⟨h,hx⟩⟩ rw [he.measure_eq] exact CubeGeometry.volume_unitCube omit [DecidableEq ι] [Nonempty ι] in lemma small_ball_nonempty {G : Set E} (hG : ∀ᵐ x ∂volume,x∈G) : (ball (0:E) (1/2)∩G).Nonempty := by exact ((volume:Measure E).dense_of_ae hG).inter_open_nonempty _ isOpen_ball (nonempty_ball.mpr (by norm_num)) theorem exists_envelope_constants (b : OrthonormalBasis ι ℝ E) {ell T B : ℝ} (hell : 0 < ell) (hT : 0 ≤ T) (hB : 0 ≤ B) : ∃ (K : ℝ) (theta : ℝ≥0∞), 1 < K ∧ 0 < theta ∧ theta < 1 ∧ ∀ (φ : E → ℝ) (L : ℝ≥0) (A : E → Matrix ι ι ℝ) (β : E → E) (G : Set E) (e : E) (σ F η : ℝ), Differentiable ℝ φ → LipschitzWith L (gradient φ) → (∀ᵐ x ∂volume,x∈G) → (∀ x∈G,DifferentiableAt ℝ (gradient φ) x) → 0 ≤ σ → 0 ≤ F → σ*((L:ℝ)*‖e‖^2) ≤ F → 0 < η → (∀ᵐ x ∂volume,x∈closedBall (0:E) D → (A x-ell • (1:Matrix ι ι ℝ)).PosSemidef) → (∀ᵐ x ∂volume,x∈closedBall (0:E) D → (A x).trace ≤ T) → (∀ᵐ x ∂volume,x∈closedBall (0:E) D → ‖β x‖ ≤ B) → (∀ h : E,∀ᵐ x ∂volume,x∈closedBall (0:E) D → ⟪β x,SecondDifference.vector (gradient φ) h x⟫_ℝ ≤ (A x*(DeficitQuotient.hessian b φ (x+h)+DeficitQuotient.hessian b φ (x-h)- (2:ℝ) • DeficitQuotient.hessian b φ x)).trace+σ*SecondDifference.scalar φ h x) → ∀ k : ℕ, volume ({x | K^k < (upper (direction φ e) (ball 0 (D+1)∩G)-direction φ e x)/ (upper (direction φ e) (ball 0 (D+1)∩G)-upper (direction φ e) (ball 0 (1/2)∩G)+η+F)}∩(cube∩G)) ≤ theta^k := by obtain ⟨K,theta,hK,ht0,ht1,hh⟩ := exists_constants b hell hT hB refine ⟨K,theta,hK,ht0,ht1,?_⟩ intro φ L A β G e σ F η hd hL hG hGd hσ hF hsF hη hA htrace hβ hP k let J : Set E := ball 0 (1/2)∩G let O : Set E := ball 0 (D+1)∩G let M := upper (direction φ e) O let m := upper (direction φ e) J have hJ : J.Nonempty := small_ball_nonempty hG have hJO : J⊆O := by apply inter_subset_inter_left exact ball_subset_ball (by have hn := Nat.cast_nonneg (α:=ℝ) (Fintype.card ι); linarith) have hdrop : 0 ≤ M-m := sub_nonneg.mpr (upper_mono hJO hJ (direction_bddAbove hL e O)) let s := M-m+η+F have hs : 0 < s := by dsimp only [s]; linarith obtain ⟨δ,hδ,hδlim,hseg⟩ := SmallSequence.exists_shift_sequence e have hupper : ∀ᵐ x ∂volume,x∈ball (0:E) (D+1) → direction φ e x ≤ M := by filter_upwards [hG] with x hx hxB exact le_upper (direction_bddAbove hL e O) ⟨hxB,hx⟩ have hlo : ∃ y : ι → ℝ,y∈I₀ ∧ DifferentiableAt ℝ (gradient φ) (WithLp.toLp 2 y) ∧ (M-direction φ e (WithLp.toLp 2 y))/s < 1 := by obtain ⟨y,hy,hyv⟩ := exists_near_upper (f:=direction φ e) hJ hη refine ⟨y.ofLp,CubeGeometry.inner_ball_subset hy.1,hGd y hy.2,?_⟩ apply (div_lt_one hs).mpr change M-direction φ e y < s dsimp only [s,m] at * linarith have hb := hh φ L A β e M s σ (ball 0 (D+1)) δ hd hL isOpen_ball (convex_ball _ _) hs hσ (by dsimp only [s]; linarith) hδ hδlim (fun n x hx t ht => hseg D n x hx t ht) hupper hA htrace hβ hP hlo k let Q : Set E := {x | K^k < (M-direction φ e x)/s}∩cube have hQm : MeasurableSet Q := by apply MeasurableSet.inter · exact measurableSet_lt measurable_const ((measurable_const.sub ((measurable_fderiv_apply_const ℝ (gradient φ) e).inner measurable_const)).div_const s) · exact (CubeGeometry.unitBox : Box ι).measurableSet_coe.preimage (EuclideanSpace.equiv ι ℝ).continuous.measurable have he := (PiLp.volume_preserving_toLp ι).measure_preimage hQm.nullMeasurableSet change volume {x : ι → ℝ | WithLp.toLp 2 x∈Q}=volume Q at he have hQ : volume Q ≤ theta^k := by rw [← he] exact hb exact (measure_mono (show {x | K^k < (M-direction φ e x)/s}∩(cube∩G)⊆Q from fun _ hx => ⟨hx.1,hx.2.1⟩)).trans hQ end HessianTail namespace FiniteElliptic open Set Metric Matrix open scoped MatrixOrder Matrix.Norms.Elementwise variable {ι : Type*} [Fintype ι] [DecidableEq ι] local notation "Mat" => Matrix ι ι ℝ def quadratic (D : Mat) (e : ι → ℝ) : ℝ := e ⬝ᵥ (D *ᵥ e) omit [DecidableEq ι] in lemma quadratic_continuous (e : ι → ℝ) : Continuous (fun D : Mat => quadratic D e) := by unfold quadratic Matrix.mulVec dotProduct fun_prop omit [DecidableEq ι] in lemma quadratic_smul (D : Mat) (e : ι → ℝ) (a : ℝ) : quadratic (a • D) e=a*quadratic D e := by simp only [quadratic,Matrix.smul_mulVec,dotProduct_smul,smul_eq_mul] omit [Fintype ι] [DecidableEq ι] in lemma hermitian_closed : IsClosed {D : Mat | D.IsHermitian} := isClosed_eq continuous_id.matrix_conjTranspose continuous_id omit [DecidableEq ι] in lemma positive_closed : IsClosed {D : Mat | D.PosSemidef} := by have he : {D : Mat | D.PosSemidef}={D | D.IsHermitian}∩⋂ e : ι → ℝ,{D | 0≤quadratic D e} := by ext D simp only [mem_ofPred_eq,mem_inter_iff,mem_iInter,Matrix.posSemidef_iff_dotProduct_mulVec, quadratic,star_trivial] rw [he] exact hermitian_closed.inter (isClosed_iInter (fun e => isClosed_le continuous_const (quadratic_continuous e))) lemma trace_mul_nonneg {A D : Mat} (hA : A.PosSemidef) (hD : D.PosSemidef) : 0≤(A*D).trace := by obtain ⟨Q,hQ⟩ := CStarAlgebra.nonneg_iff_eq_star_mul_self.mp hA.nonneg rw [hQ] change 0≤(Qᴴ*Q*D).trace rw [← Matrix.trace_mul_cycle Q D Qᴴ] exact (hD.mul_mul_conjTranspose_same Q).trace_nonneg lemma trace_mul_pos {A D : Mat} {ell : ℝ} (hell : 0 by simpa only [mem_closedBall,dist_zero_right] using hA.2) have hH : IsCompact H := (isCompact_sphere (0:Mat) 1).of_isClosed_subset (hermitian_closed.inter (isClosed_eq continuous_norm continuous_const)) (fun D hD => by simpa only [mem_sphere_zero_iff_norm] using hD.2) let U : (ι → ℝ) → Set (Mat×Mat) := fun e => {p | 0<(p.1*p.2).trace ∨ quadratic p.2 e<0} have hU (e : ι → ℝ) : IsOpen (U e) := by dsimp only [U] exact (isOpen_lt continuous_const (show Continuous (fun p : Mat×Mat => (p.1*p.2).trace) by unfold Matrix.trace; fun_prop)).union (isOpen_lt ((quadratic_continuous e).comp continuous_snd) continuous_const) have hcover : K×ˢH⊆⋃ e,U e := by intro p hp by_cases ht : 0<(p.1*p.2).trace · exact mem_iUnion.mpr ⟨0,Or.inl ht⟩ have hn : ¬ p.2.PosSemidef := by intro hd apply ht exact trace_mul_pos hell hp.1.1 hd (by intro he; simpa only [he,norm_zero,zero_ne_one] using hp.2.2) have hx : ∃ e,quadratic p.2 e<0 := by by_contra h push Not at h exact hn (Matrix.posSemidef_iff_dotProduct_mulVec.mpr ⟨hp.2.1,by simpa only [quadratic,star_trivial] using h⟩) obtain ⟨e,he⟩ := hx exact mem_iUnion.mpr ⟨e,Or.inr he⟩ obtain ⟨S,hS⟩ := (hK.prod hH).elim_finite_subcover U hU hcover let g : Mat×Mat → ℝ := fun p => max (p.1*p.2).trace 0+∑ e∈S,max (-quadratic p.2 e) 0 have hg : Continuous g := by apply Continuous.add · exact (show Continuous (fun p : Mat×Mat => (p.1*p.2).trace) by unfold Matrix.trace; fun_prop).max continuous_const · exact continuous_finsetSum _ (fun e _ => (((quadratic_continuous e).comp continuous_snd).neg.max continuous_const)) have hgp : ∀ p∈K×ˢH,0 le_max_right _ _) rcases heU with ht|ht · exact add_pos_of_pos_of_nonneg (ht.trans_le (le_max_left _ _)) hn · have hh : 0<∑ e∈S,max (-quadratic p.2 e) 0 := lt_of_lt_of_le ((neg_pos.mpr ht).trans_le (le_max_left _ (0:ℝ))) (Finset.single_le_sum (fun e _ => le_max_right (-quadratic p.2 e) 0) he) exact add_pos_of_nonneg_of_pos (le_max_right _ _) hh obtain ⟨δ,hδ,hdg⟩ := (hK.prod hH).exists_forall_le' hg.continuousOn hgp refine ⟨S,(1+(S.card:ℝ))/δ,by positivity,?_⟩ intro A D d r hA hAT hD hd hr htr hdir by_cases hDz : D=0 · simp only [hDz,norm_zero] positivity have hn : 0<‖D‖ := norm_pos_iff.mpr hDz let D' := ‖D‖⁻¹ • D have hD' : D'∈H := by constructor · exact hD.smul (IsSelfAdjoint.all ‖D‖⁻¹) · dsimp only [D'] rw [norm_smul,Real.norm_eq_abs,abs_inv,abs_norm,inv_mul_cancel₀ hn.ne'] have hlow := hdg (A,D') ⟨⟨hA,hAT⟩,hD'⟩ have hb : g (A,D')≤‖D‖⁻¹*(r+(S.card:ℝ)*d) := by have htr' : (A*D').trace≤‖D‖⁻¹*r := by dsimp only [D'] simpa only [Matrix.mul_smul,Matrix.trace_smul,smul_eq_mul] using mul_le_mul_of_nonneg_left htr (inv_nonneg.mpr hn.le) have he (e : ι → ℝ) (he : e∈S) : max (-quadratic D' e) 0≤‖D‖⁻¹*d := by dsimp only [D'] rw [quadratic_smul] apply max_le · nlinarith [mul_le_mul_of_nonneg_left (hdir e he) (inv_nonneg.mpr hn.le)] · positivity dsimp only [g] calc _ ≤ ‖D‖⁻¹*r+∑ _e∈S,‖D‖⁻¹*d := add_le_add (max_le htr' (by positivity)) (Finset.sum_le_sum he) _ = _ := by simp; ring have hb' : δ*‖D‖≤r+(S.card:ℝ)*d := by have hh := mul_le_mul_of_nonneg_right (hlow.trans hb) hn.le have he : (‖D‖⁻¹*(r+(S.card:ℝ)*d))*‖D‖=r+(S.card:ℝ)*d := by field_simp rwa [he] at hh rw [div_mul_eq_mul_div] apply (le_div_iff₀ hδ).mpr have hh : r+(S.card:ℝ)*d≤(1+(S.card:ℝ))*(d+r) := by nlinarith [mul_nonneg (Nat.cast_nonneg S.card : (0:ℝ)≤S.card) hr] convert hb'.trans hh using 1; ring end FiniteElliptic namespace EllipticOscillation open MeasureTheory Set Filter Matrix FiniteElliptic open scoped ENNReal Matrix.Norms.Elementwise variable {ι : Type*} [Fintype ι] [DecidableEq ι] local notation "Mat" => Matrix ι ι ℝ omit [DecidableEq ι] in lemma quadratic_sub (A D : Mat) (e : ι → ℝ) : quadratic (A-D) e=quadratic A e-quadratic D e := by simp only [quadratic,Matrix.sub_mulVec,dotProduct_sub] omit [DecidableEq ι] in lemma abs_quadratic_le (D : Mat) (e : ι → ℝ) : |quadratic D e|≤(∑ i,|e i|)^2*‖D‖ := by simp only [quadratic,Matrix.mulVec,dotProduct] calc |∑ i,e i*(∑ j,D i j*e j)| ≤ ∑ i,|e i*(∑ j,D i j*e j)| := Finset.abs_sum_le_sum_abs _ _ _ ≤ ∑ i,|e i| *(∑ j,‖D‖*|e j|) := by apply Finset.sum_le_sum intro i _ rw [abs_mul] apply mul_le_mul_of_nonneg_left _ (abs_nonneg _) calc |∑ j,D i j*e j| ≤ ∑ j,|D i j*e j| := Finset.abs_sum_le_sum_abs _ _ _ ≤ ∑ j,‖D‖*|e j| := by apply Finset.sum_le_sum intro j _ rw [abs_mul] exact mul_le_mul_of_nonneg_right (by simpa only [Real.norm_eq_abs] using Matrix.norm_entry_le_entrywise_sup_norm D (i:=i) (j:=j)) (abs_nonneg _) _ = (∑ i,|e i|)^2*‖D‖ := by simp only [← Finset.mul_sum,← Finset.sum_mul]; ring variable {X : Type*} [MeasurableSpace X] (μ : Measure X) theorem high_point_control {ell T : ℝ} (hell : 0 {x | d htail e e.prop) hmass' refine ⟨y,hy,fun x hx => ?_⟩ apply hbound (A y) (H y-H x) d r (hA y hy).1 (hA y hy).2 ((hH y hy).sub (hH x hx)) hd hr (htrace x hx y hy) intro e he have hg : M e-quadratic (H y) e≤d := not_lt.mp (hgood ⟨e,he⟩) rw [quadratic_sub] have hu := hM x hx e he linarith lemma contraction {o i d r C : ℝ} (hC : 0≤C) (hdrop : i≤o-d) (hbound : i≤C*(d+r)) : i≤C/(C+1)*o+C/(C+1)*r := by have hp : 0 Matrix ι ι ℝ variable {X : Type*} [MeasurableSpace X] omit [DecidableEq ι] [MeasurableSpace X] in lemma sum_span_of_high_point (S : Finset (ι → ℝ)) (H : X → Mat) {J : Set X} (hJ : J.Nonempty) {y : X} {a : ℝ} (h : ∀ x∈J, ‖H y-H x‖ ≤ a) : (∑ e : {e // e∈S}, span (fun x => quadratic (H x) e.val) J) ≤ (∑ e : {e // e∈S}, (∑ i, |e.val i|)^2)* (2*a) := by have hm (x z : X) (hx : x∈J) (hz : z∈J) : ‖H x-H z‖ ≤ 2*a := by calc ‖H x-H z‖ = ‖(H y-H z)-(H y-H x)‖ := by congr 1; abel _ ≤ ‖H y-H z‖+‖H y-H x‖ := norm_sub_le _ _ _ ≤ 2*a := by linarith [h x hx,h z hz] have hd (e : {e // e∈S}) : span (fun x => quadratic (H x) e.val) J ≤ (∑ i, |e.val i|)^2*(2*a) := by apply span_le_of_osc hJ intro x hx z hz rw [← EllipticOscillation.quadratic_sub] exact (le_abs_self _).trans ((EllipticOscillation.abs_quadratic_le _ _).trans (mul_le_mul_of_nonneg_left (hm x z hx hz) (sq_nonneg _))) simpa only [Finset.sum_mul] using Finset.sum_le_sum (s:=Finset.univ) (fun e _ => hd e) theorem exists_contraction (μ : Measure X) {ell T K : ℝ} {theta : ℝ≥0∞} (hell : 0 < ell) (hK : 1 < K) (ht : theta < 1) : ∃ (S : Finset (ι → ℝ)) (C rho : ℝ), 0 < C ∧ 0 < rho ∧ rho < 1 ∧ (∀ (A D : Mat) (d r : ℝ), (A-ell • (1:Mat)).PosSemidef → ‖A‖≤T → D.IsHermitian → 0≤d → 0≤r → (A*D).trace≤r → (∀ e∈S, -d≤quadratic D e) → ‖D‖≤C*(d+r)) ∧ ∀ (H A : X → Mat) (J U O : Set X) (F r : ℝ), J.Nonempty → J⊆U → U⊆O → μ U=1 → 0 ≤ F → 0 ≤ r → (∀ x∈U, (A x-ell • (1:Mat)).PosSemidef ∧ ‖A x‖ ≤ T) → (∀ x∈U, (H x).IsHermitian) → (∀ x∈U, ∀ y∈U, (A y*(H y-H x)).trace ≤ r) → (∀ e∈S, BddAbove ((fun x => quadratic (H x) e) '' O)) → (∀ e∈S, BddBelow ((fun x => quadratic (H x) e) '' O)) → (∀ η : ℝ, 0 < η → ∀ e∈S, ∀ k : ℕ, μ ({x | K^k < (upper (fun z => quadratic (H z) e) O-quadratic (H x) e)/ (upper (fun z => quadratic (H z) e) O-upper (fun z => quadratic (H z) e) J+η+F)}∩U) ≤ theta^k) → (∑ e : {e // e∈S}, span (fun x => quadratic (H x) e.val) J) ≤ rho*(∑ e : {e // e∈S}, span (fun x => quadratic (H x) e.val) O)+rho*(F+r) := by classical obtain ⟨S,C,hC,hbound,hcontrol⟩ := EllipticOscillation.high_point_control (ι:=ι) μ (T:=T) hell have hlim : Tendsto (fun k : ℕ => (S.card:ℝ≥0∞)*theta^k) atTop (𝓝 0) := by simpa only [mul_zero] using ENNReal.Tendsto.const_mul (a:=(S.card:ℝ≥0∞)) (ENNReal.tendsto_pow_atTop_nhds_zero_of_lt_one ht) (Or.inr (by simp)) obtain ⟨k,hk⟩ := (hlim.eventually_lt_const (by norm_num : (0:ℝ≥0∞)<1)).exists let W : ℝ := ∑ e : {e // e∈S}, (∑ i,|e.val i|)^2 have hW : 0 ≤ W := Finset.sum_nonneg (fun _ _ => sq_nonneg _) let D : ℝ := 2*W*C*(K^k+1)+1 have hpow : 0 < K^k := pow_pos (by linarith) _ have hD : 0 < D := by dsimp only [D]; positivity let rho : ℝ := D/(D+1) have hrho : 0 < rho := div_pos hD (by linarith) have hrho1 : rho < 1 := (div_lt_one (by linarith : 0 quadratic (H x) e.val let drop : {e // e∈S} → ℝ := fun e => upper (f e) O-upper (f e) J let d : ℝ := ∑ e, drop e have he0 (e : {e // e∈S}) : 0 ≤ drop e := sub_nonneg.mpr (upper_mono (hJU.trans hUO) hJ (hu e.val e.prop)) have hd : 0 ≤ d := Finset.sum_nonneg (fun e _ => he0 e) have hed (e : {e // e∈S}) : drop e ≤ d := Finset.single_le_sum (fun e _ => he0 e) (Finset.mem_univ e) have hi (η : ℝ) (hη : 0 < η) : (∑ e, span (f e) J) ≤ D*(d+η+F+r) := by let a := K^k*(d+η+F) have ha : 0 ≤ a := by dsimp only [a]; positivity have hta (e : ι → ℝ) (he : e∈S) : μ ({x | a < upper (fun z => quadratic (H z) e) O-quadratic (H x) e}∩U) ≤ theta^k := by apply (measure_mono (show {x | a < upper (fun z => quadratic (H z) e) O-quadratic (H x) e}∩U ⊆ {x | K^k < (upper (fun z => quadratic (H z) e) O-quadratic (H x) e)/(drop ⟨e,he⟩+η+F)}∩U from ?_)).trans (htail η hη e he k) intro x hx refine ⟨(lt_div_iff₀ (by linarith [he0 ⟨e,he⟩] : 0 upper (fun z => quadratic (H z) e) O) a r (theta^k) ha hr hA hH htr (fun x hx e he => le_upper (hu e he) (hUO hx)) hta (hμ ▸ hk) have hh := sum_span_of_high_point S H hJ (fun x hx => hyb x (hJU hx)) have hcoef : 2*W*C*(K^k*(d+η+F)+r) ≤ D*(d+η+F+r) := by have h1 : K^k*(d+η+F)+r ≤ (K^k+1)*(d+η+F+r) := by nlinarith have h2 := mul_le_mul_of_nonneg_left h1 (by positivity : 0 ≤ 2*W*C) dsimp only [D] nlinarith change (∑ e, span (f e) J) ≤ W*(2*(C*(a+r))) at hh calc (∑ e, span (f e) J) ≤ W*(2*(C*(a+r))) := hh _ = 2*W*C*(K^k*(d+η+F)+r) := by dsimp only [a]; ring _ ≤ D*(d+η+F+r) := hcoef have hi0 : (∑ e, span (f e) J) ≤ D*(d+F+r) := by by_contra hn have hz : 0 < ((∑ e,span (f e) J)-D*(d+F+r))/(2*D) := div_pos (sub_pos.mpr (lt_of_not_ge hn)) (by positivity) have hh := hi _ hz have he : D*(((∑ e,span (f e) J)-D*(d+F+r))/(2*D)) = ((∑ e,span (f e) J)-D*(d+F+r))/2 := by field_simp nlinarith have hdrop := sum_drop (f:=f) (hJU.trans hUO) hJ (fun e => hl e.val e.prop) have hh := EllipticOscillation.contraction hD.le hdrop (show (∑ e,span (f e) J) ≤ D*(d+(F+r)) by simpa only [add_assoc] using hi0) exact hh end FiniteOscillation namespace HessianCoordinates open Matrix open scoped InnerProductSpace Matrix.Norms.Elementwise variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] variable {ι : Type*} [Fintype ι] [DecidableEq ι] def vector (b : OrthonormalBasis ι ℝ E) (e : ι → ℝ) : E := b.repr.symm (WithLp.toLp 2 e) lemma quadratic_toMatrix (b : OrthonormalBasis ι ℝ E) (A : E →L[ℝ] E) (e : ι → ℝ) : FiniteElliptic.quadratic (LinearMap.toMatrix b.toBasis b.toBasis A.toLinearMap) e = ⟪A (vector b e),vector b e⟫_ℝ := by have he : (b.toBasis.repr (vector b e) : ι → ℝ)=e := by ext i simp only [OrthonormalBasis.coe_toBasis_repr_apply,vector,LinearIsometryEquiv.apply_symm_apply] have hm := LinearMap.toMatrix_mulVec_repr b.toBasis b.toBasis A.toLinearMap (vector b e) rw [he] at hm unfold FiniteElliptic.quadratic rw [hm,← b.repr.inner_map_map (A (vector b e)) (vector b e),EuclideanSpace.inner_eq_star_dotProduct] simp only [vector,LinearIsometryEquiv.apply_symm_apply,star_trivial] rfl end HessianCoordinates namespace InteriorOscillation open Set Filter Metric Matrix MeasureTheory OscillationEnvelope FiniteElliptic open scoped InnerProductSpace NNReal ENNReal Matrix.Norms.Elementwise variable {ι : Type*} [Fintype ι] [DecidableEq ι] [Nonempty ι] local notation "E" => EuclideanSpace ℝ ι local notation "Mat" => Matrix ι ι ℝ local notation "D" => ((Fintype.card ι:ℝ)/2+(2*(Fintype.card ι:ℝ)+1)) def oscillation (S : Finset (ι → ℝ)) (H : E → Mat) (U : Set E) : ℝ := ∑ e : {e // e∈S}, span (fun x => quadratic (H x) e.val) U theorem exists_constants (b : OrthonormalBasis ι ℝ E) {ell T Tm B : ℝ} (hell : 0 < ell) (hT : 0 ≤ T) (hB : 0 ≤ B) : ∃ (S : Finset (ι → ℝ)) (C rho : ℝ), 0 < C ∧ 0 < rho ∧ rho < 1 ∧ (∀ (A H : Mat) (d r : ℝ), (A-ell • (1:Mat)).PosSemidef → ‖A‖≤Tm → H.IsHermitian → 0≤d → 0≤r → (A*H).trace≤r → (∀ e∈S, -d≤quadratic H e) → ‖H‖≤C*(d+r)) ∧ ∀ (φ : E → ℝ) (L : ℝ≥0) (A : E → Mat) (β : E → E) (G : Set E) (σ F r : ℝ), Differentiable ℝ φ → LipschitzWith L (gradient φ) → (∀ᵐ x ∂volume,x∈G) → (∀ x∈G,DifferentiableAt ℝ (gradient φ) x) → 0 ≤ σ → 0 ≤ F → 0 ≤ r → (∀ e∈S,σ*((L:ℝ)*‖HessianCoordinates.vector b e‖^2) ≤ F) → (∀ x∈G, x∈closedBall (0:E) D → (A x-ell • (1:Mat)).PosSemidef ∧ (A x).trace ≤ T ∧ ‖A x‖≤Tm ∧ ‖β x‖≤B) → (∀ x∈G,(DeficitQuotient.hessian b φ x).IsHermitian) → (∀ x∈G, x∈HessianTail.cube → ∀ y∈G, y∈HessianTail.cube → (A y*(DeficitQuotient.hessian b φ y-DeficitQuotient.hessian b φ x)).trace ≤ r) → (∀ h : E,∀ᵐ x ∂volume,x∈closedBall (0:E) D → ⟪β x,SecondDifference.vector (gradient φ) h x⟫_ℝ ≤ (A x*(DeficitQuotient.hessian b φ (x+h)+DeficitQuotient.hessian b φ (x-h)- (2:ℝ) • DeficitQuotient.hessian b φ x)).trace+σ*SecondDifference.scalar φ h x) → oscillation S (DeficitQuotient.hessian b φ) (ball 0 (1/2)∩G) ≤ rho*oscillation S (DeficitQuotient.hessian b φ) (ball 0 (D+1)∩G)+rho*(F+r) := by obtain ⟨K,theta,hK,_,ht,htail⟩ := HessianTail.exists_envelope_constants b hell hT hB obtain ⟨S,C,rho,hC,hr0,hr1,hmat,hcon⟩ := FiniteOscillation.exists_contraction (ι:=ι) (T:=Tm) (volume:Measure E) hell hK ht refine ⟨S,C,rho,hC,hr0,hr1,hmat,?_⟩ intro φ L A β G σ F r hd hL hG hGd hσ hF hr hSF hA hH htr hP have hcube (x : E) (hx : x∈HessianTail.cube) : x∈closedBall (0:E) D := by have hh := CubeGeometry.norm_unit hx rw [mem_closedBall_zero_iff] have hn : (0:ℝ)≤Fintype.card ι := Nat.cast_nonneg _ dsimp only at hh change ‖x‖ ≤ _ at hh linarith have hcoord (e : ι → ℝ) : (fun x => quadratic (DeficitQuotient.hessian b φ x) e)= HessianTail.direction φ (HessianCoordinates.vector b e) := by funext x exact HessianCoordinates.quadratic_toMatrix b _ e have hUO : HessianTail.cube∩G ⊆ ball (0:E) (D+1)∩G := by intro x hx refine ⟨?_,hx.2⟩ exact mem_ball_zero_iff.mpr ((mem_closedBall_zero_iff.mp (hcube x hx.1)).trans_lt (lt_add_one D)) apply hcon (DeficitQuotient.hessian b φ) A (ball 0 (1/2)∩G) (HessianTail.cube∩G) (ball 0 (D+1)∩G) F r (HessianTail.small_ball_nonempty hG) (fun x hx => ⟨CubeGeometry.inner_ball_subset hx.1,hx.2⟩) hUO (HessianTail.cube_measure_inter hG) hF hr (fun x hx => ⟨(hA x hx.2 (hcube x hx.1)).1,(hA x hx.2 (hcube x hx.1)).2.2.1⟩) (fun x hx => hH x hx.2) (fun x hx y hy => htr x hx.2 hx.1 y hy.2 hy.1) · intro e _ rw [hcoord] exact HessianTail.direction_bddAbove hL _ _ · intro e _ rw [hcoord] exact HessianTail.direction_bddBelow hL _ _ · intro η hη e he k simp only [congrFun (hcoord e)] apply htail φ L A β G (HessianCoordinates.vector b e) σ F η hd hL hG hGd hσ hF (hSF e he) hη · filter_upwards [hG] with x hx hxB exact (hA x hx hxB).1 · filter_upwards [hG] with x hx hxB exact (hA x hx hxB).2.1 · filter_upwards [hG] with x hx hxB exact (hA x hx hxB).2.2.2 · exact hP end InteriorOscillation namespace MARescale open Set Filter MeasureTheory Matrix open scoped InnerProductSpace NNReal Topology variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] variable {ι : Type*} [Fintype ι] [DecidableEq ι] def potential (φ : E → ℝ) (c : E) (r : ℝ) (x : E) : ℝ := (1/r^2)*φ (c+r • x) def point (c : E) (r : ℝ) (x : E) : E := c+r • x omit [FiniteDimensional ℝ E] in lemma point_add (c : E) (r : ℝ) (x h : E) : point c r (x+h)=point c r x+r • h := by dsimp only [point]; module omit [FiniteDimensional ℝ E] in lemma point_sub (c : E) (r : ℝ) (x h : E) : point c r (x-h)=point c r x-r • h := by dsimp only [point]; module omit [FiniteDimensional ℝ E] in lemma scalar (φ : E → ℝ) (c : E) (r : ℝ) (h x : E) : SecondDifference.scalar (potential φ c r) h x = (1/r^2)*SecondDifference.scalar φ (r • h) (point c r x) := by change (1/r^2)*φ (point c r (x+h))+(1/r^2)*φ (point c r (x-h))- 2*((1/r^2)*φ (point c r x))=_ rw [point_add,point_sub] dsimp only [SecondDifference.scalar] ring lemma gradient {φ : E → ℝ} (hd : Differentiable ℝ φ) (c : E) {r : ℝ} (hr : r≠0) (x : E) : _root_.gradient (potential φ c r) x=(1/r) • _root_.gradient φ (point c r x) := by rw [show potential φ c r=(fun x => (1/r^2)*φ (c+r • x)) from rfl,AffineRescale.gradient hd] congr 1 field_simp lemma gradient_lipschitz {φ : E → ℝ} (hd : Differentiable ℝ φ) {L : ℝ≥0} (hL : LipschitzWith L (_root_.gradient φ)) (c : E) {r : ℝ} (hr : 0 (1/r^2)*φ (c+r • x))) x).toLinearMap = _ rw [AffineRescale.hessian hd c r (1/r^2) x hg,show (1/r^2)*r^2=1 by field_simp,one_smul] rfl lemma vector {φ : E → ℝ} (hd : Differentiable ℝ φ) (c : E) {r : ℝ} (hr : r≠0) (h x : E) : SecondDifference.vector (_root_.gradient (potential φ c r)) h x= (1/r) • SecondDifference.vector (_root_.gradient φ) (r • h) (point c r x) := by simp only [SecondDifference.vector,gradient hd c hr,point_add,point_sub,smul_add,smul_sub, smul_smul] rw [mul_comm (2:ℝ) (1/r)] lemma pde (b : OrthonormalBasis ι ℝ E) {φ : E → ℝ} (hd : Differentiable ℝ φ) (c : E) {r : ℝ} (hr : r≠0) {x h β : E} {A : Matrix ι ι ℝ} (h0 : DifferentiableAt ℝ (_root_.gradient φ) (point c r x)) (hp : DifferentiableAt ℝ (_root_.gradient φ) (point c r (x+h))) (hm : DifferentiableAt ℝ (_root_.gradient φ) (point c r (x-h))) (he : ⟪β,SecondDifference.vector (_root_.gradient φ) (r • h) (point c r x)⟫_ℝ ≤ (A*(DeficitQuotient.hessian b φ (point c r x+r • h)+DeficitQuotient.hessian b φ (point c r x-r • h)- (2:ℝ) • DeficitQuotient.hessian b φ (point c r x))).trace+ SecondDifference.scalar φ (r • h) (point c r x)) : ⟪r • β,SecondDifference.vector (_root_.gradient (potential φ c r)) h x⟫_ℝ ≤ (A*(DeficitQuotient.hessian b (potential φ c r) (x+h)+DeficitQuotient.hessian b (potential φ c r) (x-h)- (2:ℝ) • DeficitQuotient.hessian b (potential φ c r) x)).trace+ r^2*SecondDifference.scalar (potential φ c r) h x := by rw [vector hd c hr,real_inner_smul_left,real_inner_smul_right, hessian b hd c hr hp,hessian b hd c hr hm,hessian b hd c hr h0,point_add,point_sub,scalar] convert he using 1 <;> field_simp end MARescale namespace OscillationScale open Set Metric OscillationEnvelope open scoped InnerProductSpace variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] lemma dist_point (c : E) {s : ℝ} (hs : 0 ≤ s) (x : E) : dist (c+s • x) c=s*‖x‖ := by rw [dist_eq_norm,add_sub_cancel_left,norm_smul,Real.norm_eq_abs,abs_of_nonneg hs] lemma image_ball (c : E) {s : ℝ} (hs : 0 < s) (R : ℝ) (G : Set E) : (fun x => c+s • x) '' (ball (0:E) R ∩ (fun x => c+s • x) ⁻¹' G)=ball c (s*R)∩G := by ext y constructor · rintro ⟨x,hx,rfl⟩ refine ⟨?_,hx.2⟩ rw [mem_ball,dist_point c hs.le] exact mul_lt_mul_of_pos_left (mem_ball_zero_iff.mp hx.1) hs · intro hy let x := s⁻¹ • (y-c) have he : c+s • x=y := by dsimp only [x]; rw [smul_inv_smul₀ hs.ne']; abel refine ⟨x,⟨?_,by change c+s • x∈G; rw [he]; exact hy.2⟩,he⟩ rw [mem_ball_zero_iff] have hh := hy.1 rw [mem_ball,← he,dist_point c hs.le] at hh exact (mul_lt_mul_iff_right₀ hs).mp (by simpa only [mul_comm] using hh) lemma span_comp {X : Type*} {Y : Type*} (p : X → Y) (f : Y → ℝ) (U : Set X) : span (f ∘ p) U=span f (p '' U) := by unfold span upper lower rw [image_image] rfl lemma span_congr {X : Type*} {f g : X → ℝ} {U : Set X} (h : ∀ x∈U,f x=g x) : span f U=span g U := by have he : f '' U=g '' U := image_congr h unfold span upper lower rw [he] end OscillationScale namespace MARescale open Set Filter MeasureTheory Matrix open scoped InnerProductSpace NNReal Topology variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] omit [FiniteDimensional ℝ E] in lemma differentiable_potential {φ : E → ℝ} (hd : Differentiable ℝ φ) (c : E) (r : ℝ) : Differentiable ℝ (potential φ c r) := by exact (hd.comp ((differentiable_const c).add (differentiable_id.const_smul r))).const_mul _ lemma differentiable_gradient {φ : E → ℝ} (hd : Differentiable ℝ φ) (c : E) {r : ℝ} (hr : r≠0) {x : E} (hg : DifferentiableAt ℝ (_root_.gradient φ) (point c r x)) : DifferentiableAt ℝ (_root_.gradient (potential φ c r)) x := by have he : _root_.gradient (potential φ c r)=(fun y => (1/r) • _root_.gradient φ (c+r • y)) := by funext y exact gradient hd c hr y rw [he] exact (hg.comp x ((differentiableAt_const c).add (differentiableAt_id.const_smul r))).const_smul _ end MARescale namespace InteriorOscillation open Set Filter Metric Matrix MeasureTheory OscillationEnvelope FiniteElliptic open scoped InnerProductSpace NNReal ENNReal Matrix.Norms.Elementwise variable {ι : Type*} [Fintype ι] [DecidableEq ι] [Nonempty ι] local notation "E" => EuclideanSpace ℝ ι local notation "Mat" => Matrix ι ι ℝ local notation "D" => ((Fintype.card ι:ℝ)/2+(2*(Fintype.card ι:ℝ)+1)) theorem exists_scaled_constants (b : OrthonormalBasis ι ℝ E) {ell T Tm B : ℝ} (hell : 0 < ell) (hT : 0 ≤ T) (hB : 0 ≤ B) : ∃ (S : Finset (ι → ℝ)) (C rho : ℝ), 0 < C ∧ 0 < rho ∧ rho < 1 ∧ (∀ (A H : Mat) (d r : ℝ), (A-ell • (1:Mat)).PosSemidef → ‖A‖≤Tm → H.IsHermitian → 0≤d → 0≤r → (A*H).trace≤r → (∀ e∈S, -d≤quadratic H e) → ‖H‖≤C*(d+r)) ∧ ∀ (φ : E → ℝ) (L : ℝ≥0) (A : E → Mat) (β : E → E) (G : Set E) (c : E) (s F r : ℝ), Differentiable ℝ φ → LipschitzWith L (gradient φ) → (∀ᵐ x ∂volume,x∈G) → (∀ x∈G,DifferentiableAt ℝ (gradient φ) x) → 0 < s → s ≤ 1 → 0 ≤ F → 0 ≤ r → (∀ e∈S,s^2*((L:ℝ)*‖HessianCoordinates.vector b e‖^2) ≤ F) → (∀ x∈G, x∈closedBall c (s*D) → (A x-ell • (1:Mat)).PosSemidef ∧ (A x).trace ≤ T ∧ ‖A x‖≤Tm ∧ ‖β x‖≤B) → (∀ x∈G,(DeficitQuotient.hessian b φ x).IsHermitian) → (∀ x∈G, x∈closedBall c (s*D) → ∀ y∈G, y∈closedBall c (s*D) → (A y*(DeficitQuotient.hessian b φ y-DeficitQuotient.hessian b φ x)).trace ≤ r) → (∀ h : E,∀ᵐ x ∂volume, ⟪β x,SecondDifference.vector (gradient φ) h x⟫_ℝ ≤ (A x*(DeficitQuotient.hessian b φ (x+h)+DeficitQuotient.hessian b φ (x-h)- (2:ℝ) • DeficitQuotient.hessian b φ x)).trace+SecondDifference.scalar φ h x) → oscillation S (DeficitQuotient.hessian b φ) (ball c (s/2)∩G) ≤ rho*oscillation S (DeficitQuotient.hessian b φ) (ball c (s*(D+1))∩G)+rho*(F+r) := by obtain ⟨S,C,rho,hC,hr0,hr1,hmat,hcon⟩ := exists_constants b (Tm:=Tm) hell hT hB refine ⟨S,C,rho,hC,hr0,hr1,hmat,?_⟩ intro φ L A β G c s F r hd hL hG hGd hs hs1 hF hr hSF hA hH htr hP let p := MARescale.point c s let ψ := MARescale.potential φ c s let G' := p ⁻¹' G let A' := A ∘ p let β' : E → E := fun x => s • β (p x) have hQ := AffineMeasure.quasi (volume:Measure E) c hs.ne' have hG' : ∀ᵐ x ∂volume,x∈G' := hQ.ae hG have hψ := MARescale.differentiable_potential hd c s have hψL := MARescale.gradient_lipschitz hd hL c hs have hψd (x : E) (hx : x∈G') : DifferentiableAt ℝ (gradient ψ) x := MARescale.differentiable_gradient hd c hs.ne' (hGd (p x) hx) have hess (x : E) (hx : x∈G') : DeficitQuotient.hessian b ψ x=DeficitQuotient.hessian b φ (p x) := MARescale.hessian b hd c hs.ne' (hGd (p x) hx) have hpoint {x : E} (hx : x∈closedBall (0:E) D) : p x∈closedBall c (s*D) := by change dist (c+s • x) c ≤ s*D rw [OscillationScale.dist_point c hs.le] exact mul_le_mul_of_nonneg_left (mem_closedBall_zero_iff.mp hx) hs.le have hcube {x : E} (hx : x∈HessianTail.cube) : x∈closedBall (0:E) D := by rw [mem_closedBall_zero_iff] have hn := Nat.cast_nonneg (α:=ℝ) (Fintype.card ι) have hh := CubeGeometry.norm_unit hx change ‖x‖ ≤ _ at hh linarith have hpde (h : E) : ∀ᵐ x ∂volume,x∈closedBall (0:E) D → ⟪β' x,SecondDifference.vector (gradient ψ) h x⟫_ℝ ≤ (A' x*(DeficitQuotient.hessian b ψ (x+h)+DeficitQuotient.hessian b ψ (x-h)- (2:ℝ) • DeficitQuotient.hessian b ψ x)).trace+s^2*SecondDifference.scalar ψ h x := by have hgplus := (measurePreserving_add_right (volume:Measure E) h).quasiMeasurePreserving.ae hG' have hgminus := (measurePreserving_add_right (volume:Measure E) (-h)).quasiMeasurePreserving.ae hG' filter_upwards [hQ.ae (hP (s • h)),hG',hgplus,hgminus] with x hx hxG hxP hxM _ simp only [← sub_eq_add_neg] at hxM exact MARescale.pde b hd c hs.ne' (hGd (p x) hxG) (hGd (p (x+h)) hxP) (hGd (p (x-h)) hxM) hx have hresult := hcon ψ L A' β' G' (s^2) F r hψ hψL hG' hψd (sq_nonneg s) hF hr hSF (fun x hx hxB => ⟨(hA (p x) hx (hpoint hxB)).1,(hA (p x) hx (hpoint hxB)).2.1, (hA (p x) hx (hpoint hxB)).2.2.1,?_⟩) (fun x hx => by rw [hess x hx]; exact hH (p x) hx) (fun x hx hxB y hy hyB => by rw [hess x hx,hess y hy] exact htr (p x) hx (hpoint (hcube hxB)) (p y) hy (hpoint (hcube hyB))) hpde · have hosc (R : ℝ) : oscillation S (DeficitQuotient.hessian b ψ) (ball 0 R∩G')= oscillation S (DeficitQuotient.hessian b φ) (ball c (s*R)∩G) := by unfold oscillation apply Finset.sum_congr rfl intro e _ calc span (fun x => quadratic (DeficitQuotient.hessian b ψ x) e.val) (ball 0 R∩G') = span ((fun x => quadratic (DeficitQuotient.hessian b φ x) e.val) ∘ p) (ball 0 R∩G') := OscillationScale.span_congr (fun x hx => by rw [hess x hx.2]; rfl) _ = span (fun x => quadratic (DeficitQuotient.hessian b φ x) e.val) (p '' (ball 0 R∩G')) := OscillationScale.span_comp _ _ _ _ = _ := by change span _ ((fun x => c+s • x) '' (ball 0 R∩(fun x => c+s • x) ⁻¹' G))=_ rw [OscillationScale.image_ball c hs R G] rw [hosc (1/2),hosc (D+1)] at hresult simpa only [mul_one_div] using hresult · change ‖s • β (p x)‖≤B rw [norm_smul,Real.norm_eq_abs,abs_of_pos hs] exact (mul_le_mul_of_nonneg_left (hA (p x) hx (hpoint hxB)).2.2.2 hs.le).trans (by simpa only [one_mul] using mul_le_mul_of_nonneg_right hs1 hB) end InteriorOscillation end namespace OscillationIteration open Filter open scoped Topology theorem exists_bound {rho q U C : ℝ} (hr0 : 0 ≤ rho) (hr1 : rho < 1) (hq0 : 0 ≤ q) (hq1 : q < 1) (hU : 0 ≤ U) (hC : 0 ≤ C) : ∃ M theta : ℝ, 0 ≤ M ∧ 0 < theta ∧ theta < 1 ∧ ∀ u : ℕ → ℝ, u 0 ≤ U → (∀ n,u (n+1) ≤ rho*u n+C*q^n) → ∀ n,u n ≤ M*theta^n := by let theta := (max rho q+1)/2 have ht0 : 0 < theta := by dsimp only [theta]; have := le_max_left rho q; linarith have ht1 : theta < 1 := by dsimp only [theta]; have := max_lt hr1 hq1; linarith have hrt : rho < theta := by dsimp only [theta]; have := le_max_left rho q; have := max_lt hr1 hq1; linarith have hqt : q ≤ theta := by dsimp only [theta]; have := le_max_right rho q; have := max_lt hr1 hq1; linarith let M := U+C/(theta-rho) have hden : 0 < theta-rho := sub_pos.mpr hrt have hM : 0 ≤ M := add_nonneg hU (div_nonneg hC hden.le) have hMC : rho*M+C ≤ theta*M := by have he : (theta-rho)*(C/(theta-rho))=C := mul_div_cancel₀ _ (ne_of_gt hden) have hp := mul_nonneg hden.le hU dsimp only [M] nlinarith refine ⟨M,theta,hM,ht0,ht1,?_⟩ intro u hu hrec n induction n with | zero => simpa only [pow_zero,mul_one] using hu.trans (le_add_of_nonneg_right (div_nonneg hC hden.le)) | succ n ih => calc u (n+1) ≤ rho*u n+C*q^n := hrec n _ ≤ rho*(M*theta^n)+C*theta^n := add_le_add (mul_le_mul_of_nonneg_left ih hr0) (mul_le_mul_of_nonneg_left (pow_le_pow_left₀ hq0 hqt _) hC) _ = (rho*M+C)*theta^n := by ring _ ≤ (theta*M)*theta^n := mul_le_mul_of_nonneg_right hMC (pow_nonneg ht0.le _) _ = M*theta^(n+1) := by rw [pow_succ]; ring theorem tendsto_zero {u : ℕ → ℝ} {rho q C : ℝ} (hr0 : 0 ≤ rho) (hr1 : rho < 1) (hq0 : 0 ≤ q) (hq1 : q < 1) (hC : 0 ≤ C) (hu : ∀ n,0 ≤ u n) (hrec : ∀ n,u (n+1) ≤ rho*u n+C*q^n) : Tendsto u atTop (𝓝 0) := by obtain ⟨M,theta,_,ht0,ht1,hb⟩ := exists_bound hr0 hr1 hq0 hq1 (hu 0) hC have hm : Tendsto (fun n : ℕ => M*theta^n) atTop (𝓝 0) := by simpa only [mul_zero] using (tendsto_pow_atTop_nhds_zero_of_lt_one ht0.le ht1).const_mul M exact squeeze_zero hu (hb u le_rfl hrec) hm end OscillationIteration noncomputable section namespace OscillationDecay open Set Filter Metric OscillationEnvelope open scoped Topology variable {E : Type*} [MetricSpace E] {ι : Type*} [Fintype ι] def total (f : ι → E → ℝ) (U : Set E) : ℝ := ∑ i,span (f i) U omit [MetricSpace E] in lemma total_nonneg {f : ι → E → ℝ} {U : Set E} (hU : U.Nonempty) (hu : ∀ i,BddAbove (f i '' U)) (hl : ∀ i,BddBelow (f i '' U)) : 0 ≤ total f U := Finset.sum_nonneg (fun i _ => span_nonneg hU (hu i) (hl i)) omit [MetricSpace E] in lemma difference_le_total {f : ι → E → ℝ} {U : Set E} (hu : ∀ i,BddAbove (f i '' U)) (hl : ∀ i,BddBelow (f i '' U)) {x y : E} (hx : x∈U) (hy : y∈U) (i : ι) : f i x-f i y ≤ total f U := by have h0 (j : ι) : 0 ≤ span (f j) U := span_nonneg ⟨x,hx⟩ (hu j) (hl j) calc f i x-f i y ≤ span (f i) U := sub_le_sub (le_upper (hu i) hx) (lower_le (hl i) hy) _ ≤ total f U := Finset.single_le_sum (fun j _ => h0 j) (Finset.mem_univ i) lemma ball_inter_nonempty {G : Set E} (hG : Dense G) (c : E) {r : ℝ} (hr : 00,∃ δ>0,∀ x∈G,dist x c<δ → ∀ y∈G,dist y c<δ → ∀ i,|f i x-f i y|<ε := by let q := 1/(2*A) have hAp : 0 total f (ball c (s0*A*q^n)∩G) have hu0 (n : ℕ) : 0≤u n := total_nonneg (ball_inter_nonempty hG c (by positivity)) (fun i => (hu i).mono (image_mono inter_subset_right)) (fun i => (hl i).mono (image_mono inter_subset_right)) have hrec (n : ℕ) : u (n+1)≤rho*u n+(C*s0)*q^n := by have hh := hcon (s0*q^n) (mul_pos hs0 (pow_pos hq0 _)) (by simpa only [mul_one] using mul_le_mul_of_nonneg_left (pow_le_one₀ hq0.le hq1.le) hs0.le) have hleft : s0*A*q^(n+1)=s0*q^n/2 := by dsimp only [q]; rw [pow_succ]; field_simp unfold u rw [hleft] convert hh using 1; ring_nf have ht := OscillationIteration.tendsto_zero hr0 hr1 hq0.le hq1 (mul_nonneg hC hs0.le) hu0 hrec intro ε hε obtain ⟨N,hN⟩ := Filter.eventually_atTop.mp (ht.eventually (gt_mem_nhds hε)) refine ⟨s0*A*q^N,by positivity,?_⟩ intro x hx hxB y hy hyB i rw [abs_lt] have hup (j : ι) := (hu j).mono (image_mono (inter_subset_right (s:=ball c (s0*A*q^N)))) have hlo (j : ι) := (hl j).mono (image_mono (inter_subset_right (s:=ball c (s0*A*q^N)))) have hxy := difference_le_total hup hlo ⟨hxB,hx⟩ ⟨hyB,hy⟩ i have hyx := difference_le_total hup hlo ⟨hyB,hy⟩ ⟨hxB,hx⟩ i have hh := hN N le_rfl change u N<ε at hh change f i x-f i y≤u N at hxy change f i y-f i x≤u N at hyx constructor <;> linarith end OscillationDecay namespace MatrixOscillation open Set Metric Matrix FiniteElliptic open scoped Matrix.Norms.Elementwise variable {E : Type*} {ι : Type*} [MetricSpace E] [Fintype ι] [DecidableEq ι] local notation "Mat" => Matrix ι ι ℝ theorem vanishing_at {H A : E → Mat} {G : Set E} {S : Finset (ι → ℝ)} {ell Tm C K R : ℝ} (hC : 00,∃ δ>0,∀ x∈G,dist x c<δ → ∀ y∈G,dist y c<δ → ∀ e∈S,|quadratic (H x) e-quadratic (H y) e|<ε) : ∀ ε>0,∃ δ>0,∀ x∈G,dist x c<δ → ∀ y∈G,dist y c<δ → dist (H x) (H y)<ε := by intro ε hε let d := ε/(4*C) have hd : 0 by have hb := (abs_lt.mp (hdirs x hx hxδ y hy hyδ e he)).1 simpa only [quadratic,Matrix.sub_mulVec,dotProduct_sub] using hb.le) rw [dist_eq_norm] have he : C*(d+d)=ε/2 := by dsimp only [d]; field_simp; ring exact hh.trans_lt (he ▸ (by linarith)) end MatrixOscillation namespace ContinuousEnvelope open Filter Set Metric open scoped Topology variable {E : Type*} {F : Type*} [MetricSpace E] [MetricSpace F] [CompleteSpace F] theorem exists_continuous_extension {G : Set E} (hG : Dense G) (H : E → F) (hosc : ∀ c : E,∀ ε > 0,∃ δ > 0,∀ x∈G,dist x c<δ → ∀ y∈G,dist y c<δ → dist (H x) (H y)<ε) : ∃ A : E → F,Continuous A ∧ ∀ x∈G,A x=H x := by let h := hG.isDenseInducing_val let f : G → F := fun x => H x have hf : Continuous f := by rw [continuous_iff_continuousAt] intro x rw [Metric.continuousAt_iff] intro ε hε obtain ⟨δ,hδ,hb⟩ := hosc x ε hε refine ⟨δ,hδ,fun y hy => ?_⟩ exact hb y y.prop hy x x.prop (by simpa only [dist_self] using hδ) have hc (c : E) : Cauchy (Filter.map f (Filter.comap Subtype.val (𝓝 c))) := by let := h.comap_nhds_neBot c rw [Metric.cauchy_iff] refine ⟨inferInstance,?_⟩ intro ε hε obtain ⟨δ,hδ,hb⟩ := hosc c ε hε let U : Set G := {x | dist (x:E) c<δ} refine ⟨f '' U,?_,?_⟩ · rw [Filter.mem_map] apply Filter.mem_comap.mpr refine ⟨ball c δ,ball_mem_nhds c hδ,?_⟩ intro x hx exact mem_preimage.mpr (mem_image_of_mem f hx) · rintro _ ⟨x,hx,rfl⟩ _ ⟨y,hy,rfl⟩ exact hb x x.prop hx y y.prop hy exact ⟨h.extend f,h.continuous_extend_of_cauchy hc,fun x hx => h.extend_eq hf ⟨x,hx⟩⟩ end ContinuousEnvelope namespace C11InteriorRegularity open Set Filter Metric Matrix MeasureTheory OscillationEnvelope FiniteElliptic open scoped InnerProductSpace NNReal ENNReal Matrix.Norms.Elementwise variable {ι : Type*} [Fintype ι] [DecidableEq ι] [Nonempty ι] local notation "E" => EuclideanSpace ℝ ι local notation "Mat" => Matrix ι ι ℝ local notation "D" => ((Fintype.card ι:ℝ)/2+(2*(Fintype.card ι:ℝ)+1)) theorem continuous_hessian_rep (b : OrthonormalBasis ι ℝ E) {φ : E → ℝ} {L : ℝ≥0} (hd : Differentiable ℝ φ) (hL : LipschitzWith L (gradient φ)) {A : E → Mat} {β : E → E} {G : Set E} (hG : ∀ᵐ x ∂volume,x∈G) (hGd : ∀ x∈G,DifferentiableAt ℝ (gradient φ) x) (hH : ∀ x∈G,(DeficitQuotient.hessian b φ x).IsHermitian) (hlocal : ∀ c : E,∃ ell T Tm B K R : ℝ,0 ⟨(hA x hx hxR).1,(hA x hx hxR).2.2.1⟩) hH htr let f : {e // e∈S} → E → ℝ := fun e x => quadratic (DeficitQuotient.hessian b φ x) e.val have hcoord (e : {e // e∈S}) : f e=fun x => ⟪fderiv ℝ (gradient φ) x (HessianCoordinates.vector b e.val),HessianCoordinates.vector b e.val⟫_ℝ := by funext x exact HessianCoordinates.quadratic_toMatrix b _ _ have hu (e : {e // e∈S}) : BddAbove (f e '' G) := by rw [hcoord] exact HessianTail.direction_bddAbove hL _ _ have hl (e : {e // e∈S}) : BddBelow (f e '' G) := by rw [hcoord] exact HessianTail.direction_bddBelow hL _ _ let F0 := ∑ e∈S,(L:ℝ)*‖HessianCoordinates.vector b e‖^2 have hF0 : 0≤F0 := Finset.sum_nonneg (fun _ _ => by positivity) have hF0e (e) (he : e∈S) : (L:ℝ)*‖HessianCoordinates.vector b e‖^2≤F0 := Finset.single_le_sum (f := fun e => (L:ℝ)*‖HessianCoordinates.vector b e‖^2) (fun _ _ => by positivity) he have hD : 0 mul_le_mul_of_nonneg_left (hF0e e he) (sq_nonneg s)) (fun x hx hxB => hA x hx (hxR hxB)) hH (fun x hx hxB y hy hyB => (htr x hx (hxR hxB) y hy (hxR hyB)).trans (by have hxD := mem_closedBall.mp hxB have hyD := mem_closedBall.mp hyB nlinarith [mul_le_mul_of_nonneg_left hxD hK,mul_le_mul_of_nonneg_left hyD hK])) hP change OscillationDecay.total f _≤rho*OscillationDecay.total f _+rho*(s^2*F0+2*K*D*s) at hh apply hh.trans apply add_le_add_right have hsq : s^2 ≤ s := by nlinarith nlinarith [mul_le_mul_of_nonneg_left hsq hF0,mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_left hsq hF0) hr0.le] have hv := OscillationDecay.vanishing_at hDense c hu hl hD1 hr0.le hr1 (mul_nonneg hr0.le (by positivity)) hs0 hcon' intro ε hε obtain ⟨δ,hδ,hvs⟩ := hv ε hε exact ⟨δ,hδ,fun x hx hxB y hy hyB e he => hvs x hx hxB y hy hyB ⟨e,he⟩⟩ end C11InteriorRegularity namespace AEContinuousDerivative section open Filter Set Metric MeasureTheory open scoped InnerProductSpace Topology NNReal variable {E : Type*} {F : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] [NormedAddCommGroup F] [InnerProductSpace ℝ F] variable (μ : Measure E) [μ.IsAddHaarMeasure] lemma increment_bound {g : E → F} {L : ℝ≥0} (hg : LipschitzWith L g) {Ω : Set E} (hΩ : IsOpen Ω) (hc : Convex ℝ Ω) (A : E →L[ℝ] F) {ε : ℝ} (hε : 0 ≤ ε) (ha : ∀ᵐ z ∂μ, z∈Ω → DifferentiableAt ℝ g z ∧ ‖fderiv ℝ g z-A‖≤ε) {x h : E} (hx : x∈Ω) (hxh : x+h∈Ω) : ‖g (x+h)-g x-A h‖ ≤ ε*‖h‖ := by let v := g (x+h)-g x-A h let f : E → ℝ := fun z => ⟪v,g z-A z⟫_ℝ have hf : LipschitzWith (‖innerSL ℝ v‖₊*(L+‖A‖₊)) f := (innerSL ℝ v).lipschitzWith.comp (hg.sub A.lipschitzWith) have hfa : ∀ᵐ z ∂μ,z∈Ω → DifferentiableAt ℝ f z ∧ fderiv ℝ f z h≤‖v‖*(ε*‖h‖) := by filter_upwards [ha] with z hz hzΩ have hh := (innerSL ℝ v).hasFDerivAt.comp z ((hz hzΩ).1.hasFDerivAt.sub A.hasFDerivAt) refine ⟨hh.differentiableAt,?_⟩ have hfd : fderiv ℝ f z=(innerSL ℝ v).comp (fderiv ℝ g z-A) := hh.fderiv rw [hfd] change ⟪v,(fderiv ℝ g z-A) h⟫_ℝ≤_ exact (real_inner_le_norm _ _).trans (mul_le_mul_of_nonneg_left ((ContinuousLinearMap.le_opNorm _ _).trans (mul_le_mul_of_nonneg_right (hz hzΩ).2 (norm_nonneg h))) (norm_nonneg v)) have hh := AESlice.difference_le_ae μ hf hΩ hc hfa (a:=1) (by norm_num) hx (by simpa only [one_smul] using hxh) have he : f (x+(1:ℝ) • h)-f x=‖v‖^2 := by simp only [one_smul,f,← inner_sub_right] have hv : g (x+h)-A (x+h)-(g x-A x)=v := by dsimp only [v]; rw [map_add]; abel rw [hv,real_inner_self_eq_norm_sq] rw [he,mul_one] at hh by_cases hv : ‖v‖=0 · change ‖v‖≤ε*‖h‖ rw [hv] positivity · have hv0 : 0 < ‖v‖ := lt_of_le_of_ne (norm_nonneg v) (Ne.symm hv) change ‖v‖≤ε*‖h‖ nlinarith theorem hasFDerivAt_of_ae {g : E → F} {L : ℝ≥0} (hg : LipschitzWith L g) {A : E → E →L[ℝ] F} (hA : Continuous A) (ha : ∀ᵐ z ∂μ,HasFDerivAt g (A z) z) (x : E) : HasFDerivAt g (A x) x := by rw [hasFDerivAt_iff_isLittleO_nhds_zero,Asymptotics.isLittleO_iff] intro ε hε obtain ⟨δ,hδ,hball⟩ := Metric.eventually_nhds_iff.mp (hA.continuousAt.eventually (Metric.ball_mem_nhds (A x) hε)) have hh : ∀ᵐ z ∂μ,z∈ball x δ → DifferentiableAt ℝ g z ∧ ‖fderiv ℝ g z-A x‖≤ε := by filter_upwards [ha] with z hz hzB refine ⟨hz.differentiableAt,?_⟩ rw [hz.fderiv] exact le_of_lt (by simpa only [mem_ball,dist_eq_norm] using hball (mem_ball.mp hzB)) filter_upwards [Metric.ball_mem_nhds (0:E) hδ] with h hhB exact increment_bound μ hg isOpen_ball (convex_ball _ _) (A x) hε.le hh (mem_ball_self hδ) (by simpa only [mem_ball,dist_eq_norm,add_sub_cancel_left,sub_zero] using hhB) end open MeasureTheory Set Filter Matrix open scoped InnerProductSpace NNReal Matrix.Norms.Elementwise variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] variable {ι : Type*} [Fintype ι] [DecidableEq ι] theorem contDiff_one_of_matrix_rep (b : OrthonormalBasis ι ℝ E) {g : E → E} {L : ℝ≥0} (hg : LipschitzWith L g) {M : E → Matrix ι ι ℝ} (hM : Continuous M) (hrep : ∀ᵐ x ∂volume,DifferentiableAt ℝ g x ∧ M x=LinearMap.toMatrix b.toBasis b.toBasis (fderiv ℝ g x).toLinearMap) : ContDiff ℝ 1 g := by let e : Matrix ι ι ℝ ≃L[ℝ] E →L[ℝ] E := ((LinearMap.toMatrix b.toBasis b.toBasis).symm.trans LinearMap.toContinuousLinearMap).toContinuousLinearEquiv have hind (A : E →L[ℝ] E) : e (LinearMap.toMatrix b.toBasis b.toBasis A.toLinearMap)=A := by change LinearMap.toContinuousLinearMap ((LinearMap.toMatrix b.toBasis b.toBasis).symm ((LinearMap.toMatrix b.toBasis b.toBasis) A.toLinearMap))=A rw [LinearEquiv.symm_apply_apply] rfl have hA : Continuous (fun x => e (M x)) := e.continuous.comp hM have ha : ∀ᵐ x ∂volume,HasFDerivAt g (e (M x)) x := by filter_upwards [hrep] with x hx rw [hx.2,hind] exact hx.1.hasFDerivAt have hdf (x : E) := hasFDerivAt_of_ae volume hg hA ha x apply contDiff_one_iff_fderiv.mpr refine ⟨fun x => (hdf x).differentiableAt,?_⟩ have he : fderiv ℝ g=fun x => e (M x) := funext fun x => (hdf x).fderiv rw [he] exact hA omit [MeasurableSpace E] [BorelSpace E] in lemma contDiff_two_of_gradient {φ : E → ℝ} (hd : Differentiable ℝ φ) (hg : ContDiff ℝ 1 (gradient φ)) : ContDiff ℝ 2 φ := by have hf : ContDiff ℝ 1 (fderiv ℝ φ) := by have he : fderiv ℝ φ=fun x => (InnerProductSpace.toDual ℝ E) (gradient φ x) := funext fun _ => toDual_gradient.symm rw [he] exact (InnerProductSpace.toDual ℝ E).contDiff.comp hg exact contDiff_succ_iff_fderiv.mpr ⟨hd,(by simp),hf⟩ end AEContinuousDerivative namespace CompactMomentVariational open Set Metric Matrix Filter MeasureTheory open scoped InnerProductSpace NNReal ENNReal Matrix.Norms.Elementwise variable {ι : Type*} [Fintype ι] [DecidableEq ι] [Nonempty ι] local notation "E" => EuclideanSpace ℝ ι theorem C11_to_C2 (b : OrthonormalBasis ι ℝ E) {φ V : E → ℝ} (hc : ConvexOn ℝ univ φ) (hφ : ContDiff ℝ 1 φ) {L : ℝ≥0} (hL : LipschitzWith L (gradient φ)) (hs : Function.Surjective (gradient φ)) (hVc : ConvexOn ℝ univ V) (hV : ContDiff ℝ 1 V) (hI : Integrable (fun x => Real.exp (-V x)) volume) (hm : Measure.map (gradient φ) (volume.withDensity (fun z => ENNReal.ofReal (Real.exp (-φ z)))) = normalizedSource volume V) : ContDiff ℝ 2 φ := by let G : Set E := {x | DifferentiableAt ℝ (gradient φ) x ∧ (MomentLinearization.hessian b φ x).PosDef ∧ Real.log (MomentLinearization.hessian b φ x).det= V (gradient φ x)+Real.log (∫ x,Real.exp (-V x))-φ x} have hd := hφ.differentiable one_ne_zero have hG : ∀ᵐ x ∂volume,x∈G := by filter_upwards [C11_ae_positive_MA volume b hc hd hL hs hV.continuous hI hm] with x hx exact ⟨hx.1,hx.2.1,by simpa only [MomentLinearization.hessian,LinearMap.det_toMatrix] using hx.2.2⟩ have hlocal := MomentLinearization.C11_local_coefficients b hc hφ hL hV hI (G:=G) (fun _ hx => hx) have hP := MomentLinearization.C11_ae_subsolution volume b hc hd hL hs hVc (hV.differentiable one_ne_zero) hI hm obtain ⟨M,hM,hrep⟩ := C11InteriorRegularity.continuous_hessian_rep b hd hL hG (fun _ hx => hx.1) (fun _ hx => hx.2.1.isHermitian) hlocal hP have hg : ContDiff ℝ 1 (gradient φ) := AEContinuousDerivative.contDiff_one_of_matrix_rep b hL hM (by filter_upwards [hG] with x hx exact ⟨hx.1,hrep x hx⟩) exact AEContinuousDerivative.contDiff_two_of_gradient hd hg omit [Nonempty ι] in theorem C2_positive_MA (b : OrthonormalBasis ι ℝ E) {φ V : E → ℝ} (hc : ConvexOn ℝ univ φ) (hφ : ContDiff ℝ 2 φ) {L : ℝ≥0} (hL : LipschitzWith L (gradient φ)) (hs : Function.Surjective (gradient φ)) (hV : Continuous V) (hI : Integrable (fun x => Real.exp (-V x)) volume) (hm : Measure.map (gradient φ) (volume.withDensity (fun z => ENNReal.ofReal (Real.exp (-φ z)))) = normalizedSource volume V) : ∀ x,(MomentLinearization.hessian b φ x).PosDef ∧ Real.log (fderiv ℝ (gradient φ) x).det= V (gradient φ x)+Real.log (∫ x,Real.exp (-V x))-φ x := by have hd := hφ.differentiable (by norm_num) have hg : ContDiff ℝ 1 (gradient φ) := (InnerProductSpace.toDual ℝ E).symm.toContinuousLinearEquiv.contDiff.comp (hφ.fderiv_right (by norm_num)) have hgd := hg.differentiable one_ne_zero let Z := ∫ x,Real.exp (-V x) have hZ : 0 (fderiv ℝ (gradient φ) x).det)=ᵐ[volume] (fun x => Z*Real.exp (V (gradient φ x)-φ x)) := by filter_upwards [C11_ae_positive_MA volume b hc hd hL hs hV hI hm] with x hx have hdet : 0<(fderiv ℝ (gradient φ) x).det := by simpa only [LinearMap.det_toMatrix] using hx.2.1.det_pos have he := congrArg Real.exp hx.2.2 rw [Real.exp_log hdet] at he rw [he] dsimp only [Z] rw [show V (gradient φ x)+Real.log (∫ x,Real.exp (-V x))-φ x= Real.log (∫ x,Real.exp (-V x))+(V (gradient φ x)-φ x) by ring, Real.exp_add,Real.exp_log hZ] have heq := Measure.eq_of_ae_eq hda (ContinuousLinearMap.continuous_det.comp (contDiff_one_iff_fderiv.mp hg).2) (continuous_const.mul ((hV.comp hg.continuous).sub hφ.continuous).rexp) intro x have he := congrFun heq x have hpd : (MomentLinearization.hessian b φ x).PosDef := by apply ((LinearMap.posSemidef_toMatrix_iff b).mpr (convex_gradient_derivative_positive hc hd (hgd x))).posDef_iff_det_ne_zero.mpr change (LinearMap.toMatrix b.toBasis b.toBasis (fderiv ℝ (gradient φ) x).toLinearMap).det ≠ 0 rw [LinearMap.det_toMatrix] change (fderiv ℝ (gradient φ) x).det ≠ 0 rw [he] exact (mul_pos hZ (Real.exp_pos _)).ne' refine ⟨hpd,?_⟩ rw [he,Real.log_mul hZ.ne' (Real.exp_ne_zero _),Real.log_exp] dsimp only [Z] ring end CompactMomentVariational namespace MomentLinearization open Set Metric Matrix Filter MeasureTheory CompactMomentVariational open scoped InnerProductSpace NNReal ENNReal Matrix.Norms.Elementwise variable {ι : Type*} [Fintype ι] [DecidableEq ι] local notation "E" => EuclideanSpace ℝ ι local notation "Mat" => Matrix ι ι ℝ omit [DecidableEq ι] in lemma continuous_gradient_of_C1_pair {V : E → ℝ} (hV : ContDiff ℝ 1 V) : Continuous (gradient V) := (InnerProductSpace.toDual ℝ E).symm.continuous.comp ((contDiff_one_iff_fderiv.mp hV).2) theorem C11_local_coefficients_pair (b : OrthonormalBasis ι ℝ E) {φ V : E → ℝ} (hc : ConvexOn ℝ univ φ) (hφ : ContDiff ℝ 1 φ) {L : ℝ≥0} (hL : LipschitzWith L (gradient φ)) (hV : ContDiff ℝ 1 V) (hI : Integrable (fun x => Real.exp (-V x)) volume) {G : Set E} (hG : ∀ x∈G,DifferentiableAt ℝ (gradient φ) x ∧ (hessian b φ x).PosDef ∧ Real.log (hessian b φ x).det= V (gradient φ x)+Real.log (∫ x,Real.exp (-V x))-φ x) : ∀ c : E,∃ ell T Tm B K R : ℝ,0 Z*Real.exp (V (gradient φ z)-φ z) have hZ : 0 mul_pos hZ (Real.exp_pos _)) let J : Set (E →L[ℝ] E) := {Q | Q.toLinearMap.IsPositive ∧ ‖Q‖≤(L:ℝ) ∧ d≤Q.det} have hJ : IsCompact J := (isCompact_closedBall (0:E →L[ℝ] E) (L:ℝ)).of_isClosed_subset (LocalEllipticity.positive_closed.inter ((isClosed_le continuous_norm continuous_const).inter (isClosed_le continuous_const ContinuousLinearMap.continuous_det))) (fun Q hQ => by simpa only [mem_closedBall,dist_zero_right] using hQ.2.1) let toMat : (E →L[ℝ] E) → Mat := fun Q => LinearMap.toMatrix b.toBasis b.toBasis Q.toLinearMap have htoMat : Continuous toMat := (InverseElliptic.fromMatrix b).symm.continuous have hpos : ∀ M∈toMat '' J,M.PosDef := by rintro _ ⟨Q,hQ,rfl⟩ apply ((LinearMap.posSemidef_toMatrix_iff b).mpr hQ.1).posDef_iff_det_ne_zero.mpr rw [LinearMap.det_toMatrix] exact (hd.trans_le hQ.2.2).ne' obtain ⟨ell,T,Tm,hell,hT,hbounds⟩ := InverseElliptic.compact_inverse_bounds b (hJ.image htoMat) hpos have hgradV := continuous_gradient_of_C1_pair hV obtain ⟨B,hB⟩ := ((isCompact_closedBall c 1).image (hgradV.comp hL.continuous)).isBounded.exists_norm_le obtain ⟨Kv,U,hU,hKv⟩ := (hV.locallyLipschitz.comp hL.locallyLipschitz) c obtain ⟨Kp,W,hW,hKp⟩ := hφ.locallyLipschitz c obtain ⟨R,hR,hRU⟩ := Metric.mem_nhds_iff.mp (inter_mem hU hW) let r := min R 1 have hr : 0 total f (ball c (s0*A*q^n)∩G) have hrec (n : ℕ) : u (n+1)≤rho*u n+(C*s0)*q^n := by have hh := hcon (s0*q^n) (mul_pos hs0 (pow_pos hq0 _)) (by simpa only [mul_one] using mul_le_mul_of_nonneg_left (pow_le_one₀ hq0.le hq1.le) hs0.le) have he : s0*A*q^(n+1)=s0*q^n/2 := by dsimp only [q]; rw [pow_succ]; field_simp unfold u rw [he] convert hh using 1 ring_nf have hub (n : ℕ) : u n≤M*theta^n := (hb u (by simpa only [u,pow_zero,mul_one] using hu0) hrec n).trans (mul_le_mul_of_nonneg_left (pow_le_pow_left₀ hk0.le hkt _) hM) intro n x hx hxB y hy hyB i have hup (j : ι) := (hu j).mono (image_mono (inter_subset_right (s:=ball c (s0*A*q^n)))) have hlo (j : ι) := (hl j).mono (image_mono (inter_subset_right (s:=ball c (s0*A*q^n)))) have hxy := difference_le_total hup hlo ⟨hxB,hx⟩ ⟨hyB,hy⟩ i have hyx := difference_le_total hup hlo ⟨hyB,hy⟩ ⟨hxB,hx⟩ i change f i x-f i y≤u n at hxy change f i y-f i x≤u n at hyx rw [abs_le] constructor <;> linarith [hub n] end OscillationDecay end namespace GridHolder open Metric lemma exponent {q k : ℝ} (hq : 0 EuclideanSpace ℝ ι local notation "Mat" => Matrix ι ι ℝ local notation "D" => ((Fintype.card ι:ℝ)/2+(2*(Fintype.card ι:ℝ)+1)) theorem holder_hessian (b : OrthonormalBasis ι ℝ E) {φ : E → ℝ} {L : ℝ≥0} (hd : Differentiable ℝ φ) (hL : LipschitzWith L (gradient φ)) {A : E → Mat} {β : E → E} {G : Set E} (hG : ∀ᵐ x ∂volume,x∈G) (hGd : ∀ x∈G,DifferentiableAt ℝ (gradient φ) x) (hH : ∀ x∈G,(DeficitQuotient.hessian b φ x).IsHermitian) {ell T Tm B K R : ℝ} {c0 : E} (hell : 0 quadratic (DeficitQuotient.hessian b φ x) e.val have hcoord (e : {e // e∈S}) : f e=HessianTail.direction φ (HessianCoordinates.vector b e.val) := by funext x exact HessianCoordinates.quadratic_toMatrix b _ _ have hu (e : {e // e∈S}) : BddAbove (f e '' G) := by rw [hcoord]; exact HessianTail.direction_bddAbove hL _ _ have hl (e : {e // e∈S}) : BddBelow (f e '' G) := by rw [hcoord]; exact HessianTail.direction_bddBelow hL _ _ let F0 := ∑ e∈S,(L:ℝ)*‖HessianCoordinates.vector b e‖^2 have hF0 : 0≤F0 := Finset.sum_nonneg (fun _ _ => by positivity) have hF0e (e) (he : e∈S) : (L:ℝ)*‖HessianCoordinates.vector b e‖^2≤F0 := Finset.single_le_sum (f := fun e => (L:ℝ)*‖HessianCoordinates.vector b e‖^2) (fun _ _ => by positivity) he have hinit (c : E) (r : ℝ) (hr : 0 2*t) (Finset.sum_coe_sort S (fun e => (L:ℝ)*‖HessianCoordinates.vector b e‖^2)) have hD : 0 mul_le_mul_of_nonneg_left (hF0e e he) (sq_nonneg s)) (fun x hx hxB => hA x hx (hxR hxB)) hH (fun x hx hxB y hy hyB => (htr x hx (hxR hxB) y hy (hxR hyB)).trans (by have hxD := mem_closedBall.mp hxB have hyD := mem_closedBall.mp hyB have ht := dist_triangle x c y rw [dist_comm c y] at ht nlinarith [mul_le_mul_of_nonneg_left ht hK,mul_le_mul_of_nonneg_left hxD hK,mul_le_mul_of_nonneg_left hyD hK])) hP change OscillationDecay.total f _≤rho*OscillationDecay.total f _+rho*(s^2*F0+2*K*D*s) at hh apply hh.trans apply add_le_add_right have hsq : s^2 ≤ s := by nlinarith nlinarith [mul_le_mul_of_nonneg_left hsq hF0,mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_left hsq hF0) hr0.le] obtain ⟨M,theta,hM,hqt,ht1,hgrid⟩ := OscillationDecay.exists_grid_constants («E» := EuclideanSpace ℝ ι) (ι := {e // e∈S}) (C := rho*(F0+2*K*D)) hD1 hr0.le hr1 (mul_nonneg hr0.le (by positivity)) hs0 (show 0≤2*F0 by positivity) let q := 1/(2*(D+1)) have hq0 : 0 DeficitQuotient.hessian b φ x.val have hX {x : X} : dist x.val c0 by have hh := hdir x.val x.property.1 (by simpa only [dist_self] using hp) y.val y.property.1 hdxy ⟨e,he⟩ have hl := (abs_le.mp hh).1 simpa only [H,f,quadratic,Matrix.sub_mulVec,dotProduct_sub] using hl) rw [dist_eq_norm] exact hh.trans_eq (by ring) have hh := GridHolder.of_grid hq0 hq1 ht0 ha hea (show 0≤C*(M+K*R0) by positivity) hR0 hbound refine ⟨a,(C*(M+K*R0)/theta)/R0^a,r,ha,ha1,by positivity,hr,?_⟩ intro x hx hxr y hy hyr let x' : X := ⟨x,hx,hxr⟩ let y' : X := ⟨y,hy,hyr⟩ have hdxy : dist x' y'≤R0 := by have ht := dist_triangle x c0 y rw [dist_comm c0 y] at ht have hxx := (mem_ball.mp hxr).trans_le (min_le_right _ _) have hyy := (mem_ball.mp hyr).trans_le (min_le_right _ _) change dist x y≤R0 linarith have hc := hh x' y' hdxy change dist (DeficitQuotient.hessian b φ x) (DeficitQuotient.hessian b φ y)≤ C*(M+K*R0)/theta*(dist x y/R0)^a at hc convert hc using 1 rw [Real.div_rpow dist_nonneg hR0.le] ring end C11InteriorRegularity namespace CompactMomentVariational open Set Metric Matrix Filter MeasureTheory open scoped InnerProductSpace NNReal ENNReal Matrix.Norms.Elementwise variable {ι : Type*} [Fintype ι] [DecidableEq ι] [Nonempty ι] local notation "E" => EuclideanSpace ℝ ι theorem C2_local_holder (b : OrthonormalBasis ι ℝ E) {φ V : E → ℝ} (hc : ConvexOn ℝ univ φ) (hφ : ContDiff ℝ 2 φ) {L : ℝ≥0} (hL : LipschitzWith L (gradient φ)) (hs : Function.Surjective (gradient φ)) (hVc : ConvexOn ℝ univ V) (hV : ContDiff ℝ 1 V) (hI : Integrable (fun x => Real.exp (-V x)) volume) (hm : Measure.map (gradient φ) (volume.withDensity (fun z => ENNReal.ofReal (Real.exp (-φ z)))) = normalizedSource volume V) (c : E) : ∃ a C r : ℝ,0 hgd x) (fun x _ => (hpos x).1.isHermitian) hell hT hB hK hR hA htr hP exact ⟨a,C,r,ha,ha1,hC,hr,fun x hx y hy => hhold x (mem_univ x) hx y (mem_univ y) hy⟩ end CompactMomentVariational end end section open scoped Real namespace LocalPeetre noncomputable section lemma rpow_compare {a b c r : ℝ} (ha : 0 < a) (hb : 0 < b) (hc : 0 < c) (h₁ : a ≤ b*c) (h₂ : b ≤ a*c) : a^r ≤ c^|r| * b^r := by by_cases hr : 0 ≤ r · rw [abs_of_nonneg hr] calc a^r ≤ (b*c)^r := Real.rpow_le_rpow ha.le h₁ hr _ = c^r*b^r := by rw [Real.mul_rpow hb.le hc.le]; ring · have ht : 0 ≤ -r := neg_nonneg.mpr (le_of_not_ge hr) have hh := Real.rpow_le_rpow hb.le h₂ ht rw [Real.mul_rpow ha.le hc.le, Real.rpow_neg ha.le, Real.rpow_neg hb.le] at hh rw [abs_of_neg (lt_of_not_ge hr), Real.rpow_neg hc.le] have hpa : 0 < a^r := Real.rpow_pos_of_pos ha r have hpb : 0 < b^r := Real.rpow_pos_of_pos hb r have hpc : 0 < c^r := Real.rpow_pos_of_pos hc r rw [Real.rpow_neg hc.le] at hh have hprod : a^r*c^r ≤ b^r := by exact (inv_le_inv₀ hpb (mul_pos hpa hpc)).mp (by simpa only [mul_inv] using hh) rw [mul_comm, ← div_eq_mul_inv] exact (le_div_iff₀ hpc).mpr hprod variable {E : Type*} [SeminormedAddCommGroup E] def weight (s : ℝ) (x : E) : ℝ := (1+‖x‖^2)^(s/2) lemma quadratic_add (x y : E) : 1+‖x+y‖^2 ≤ 2*(1+‖x‖^2)*(1+‖y‖^2) := by have ht := norm_add_le x y have hx := norm_nonneg x have hy := norm_nonneg y have hxy := norm_nonneg (x+y) nlinarith [sq_nonneg (‖x‖-‖y‖), mul_nonneg (sq_nonneg ‖x‖) (sq_nonneg ‖y‖)] lemma weight_pos (s : ℝ) (x : E) : 0 < weight s x := by apply Real.rpow_pos_of_pos positivity theorem weight_sub (s : ℝ) (x y : E) : weight s x ≤ 2^(|s|/2)*weight |s| y*weight s (x-y) := by have h₁ : 1+‖x‖^2 ≤ (1+‖x-y‖^2)*(2*(1+‖y‖^2)) := by simpa only [sub_add_cancel, mul_assoc, mul_left_comm] using quadratic_add (x-y) y have h₂ : 1+‖x-y‖^2 ≤ (1+‖x‖^2)*(2*(1+‖y‖^2)) := by simpa only [← sub_eq_add_neg,norm_neg,mul_assoc,mul_left_comm] using quadratic_add x (-y) have hh := rpow_compare (r:=s/2) (by positivity) (by positivity) (by positivity) h₁ h₂ simpa only [weight, abs_div, abs_of_pos (by norm_num : (0:ℝ) < 2), Real.mul_rpow (by positivity : (0:ℝ) ≤ 2) (by positivity : 0 ≤ 1+‖y‖^2)] using hh end end LocalPeetre open MeasureTheory open scoped Topology namespace LocalConvolution noncomputable section variable {X : Type*} [MeasurableSpace X] {μ : Measure X} lemma integral_mul_le_L2 {c d : X → ℝ} (hc : MemLp c 2 μ) (hd : MemLp d 2 μ) : (∫ x, c x * d x ∂μ) ≤ ‖hc.toLp c‖ * ‖hd.toLp d‖ := by have he : (∫ x, c x * d x ∂μ) = inner ℝ (hc.toLp c) (hd.toLp d) := by rw [L2.inner_def] apply integral_congr_ae filter_upwards [hc.coeFn_toLp, hd.coeFn_toLp] with x hx hy simp [hx,hy,mul_comm] rw [he] exact real_inner_le_norm _ _ lemma integral_sq_eq_norm_sq {d : X → ℝ} (hd : MemLp d 2 μ) : (∫ x, d x ^ 2 ∂μ) = ‖hd.toLp d‖ ^ 2 := by rw [← real_inner_self_eq_norm_sq, L2.inner_def] apply integral_congr_ae filter_upwards [hd.coeFn_toLp] with x hx simp [hx,pow_two] variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] theorem norm_le_convolution_majorant {b c d : E → ℝ} (hb : Integrable b) (hc₁ : Integrable c) (hc : MemLp c 2 volume) (hd : MemLp d 2 volume) (hdcont : Continuous d) (hbn : ∀ x, 0 ≤ b x) (hdn : ∀ x, 0 ≤ d x) (hdBound : ∃ D, ∀ x, ‖d x‖ ≤ D) (hmajor : ∀ x, d x ≤ ∫ y, b y * c (x-y)) : ‖hd.toLp d‖ ≤ (∫ y, b y) * ‖hc.toLp c‖ := by obtain ⟨D,hD⟩ := hdBound have hh₀ : Integrable (fun p : E × E => b p.2 * c (p.1-p.2)) (volume.prod volume) := hb.convolution_integrand (ContinuousLinearMap.mul ℝ ℝ) hc₁ have hh : Integrable (fun p : E × E => d p.1 * (b p.2*c (p.1-p.2))) (volume.prod volume) := hh₀.bdd_mul (hdcont.comp continuous_fst).aestronglyMeasurable (Filter.Eventually.of_forall fun p => hD p.1) have hcs (y : E) : (∫ x, c (x-y)*d x) ≤ ‖hc.toLp c‖*‖hd.toLp d‖ := by have hp : MeasurePreserving (fun x : E => x-y) volume volume := by simpa only [sub_eq_add_neg] using measurePreserving_add_right (volume : Measure E) (-y) have ht := hc.comp_measurePreserving hp have hn : ‖ht.toLp (c ∘ (fun x : E => x-y))‖ = ‖hc.toLp c‖ := Lp.norm_compMeasurePreserving (hc.toLp c) hp simpa only [hn,Function.comp_apply] using integral_mul_le_L2 ht hd have hnorm : ‖hd.toLp d‖^2 ≤ ((∫ y, b y)*‖hc.toLp c‖)*‖hd.toLp d‖ := by calc ‖hd.toLp d‖^2 = ∫ x, d x^2 := (integral_sq_eq_norm_sq hd).symm _ ≤ ∫ x, ∫ y, d x * (b y*c (x-y)) := by apply integral_mono hd.integrable_sq hh.integral_prod_left intro x change d x^2 ≤ ∫ y, d x*(b y*c (x-y)) rw [integral_const_mul] simpa only [pow_two] using mul_le_mul_of_nonneg_left (hmajor x) (hdn x) _ = ∫ y, ∫ x, d x * (b y*c (x-y)) := integral_integral_swap hh _ = ∫ y, b y * (∫ x, c (x-y)*d x) := by congr 1 ext y rw [← integral_const_mul] congr 1 ext x ring _ ≤ ∫ y, b y * (‖hc.toLp c‖*‖hd.toLp d‖) := by apply integral_mono ?_ (hb.mul_const _) · intro y exact mul_le_mul_of_nonneg_left (hcs y) (hbn y) · convert hh.integral_prod_right using 1 ext y rw [← integral_const_mul] congr 1 ext x ring _ = ((∫ y, b y)*‖hc.toLp c‖)*‖hd.toLp d‖ := by rw [integral_mul_const]; ring by_cases he : ‖hd.toLp d‖ = 0 · rw [he] exact mul_nonneg (integral_nonneg hbn) (norm_nonneg _) · have hp : 0 < ‖hd.toLp d‖ := lt_of_le_of_ne (norm_nonneg _) (Ne.symm he) nlinarith end end LocalConvolution open MeasureTheory FourierTransform Convolution open scoped SchwartzMap namespace LocalFourier noncomputable section variable {E : Type*} {F : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] [NormedAddCommGroup F] [NormedSpace ℂ F] [CompleteSpace F] lemma fourierInv_pairing (a : 𝓢(E,ℂ)) (f : 𝓢(E,F)) : 𝓕⁻ (SchwartzMap.pairing (ContinuousLinearMap.lsmul ℂ ℂ) a f) = SchwartzMap.convolution (ContinuousLinearMap.lsmul ℂ ℂ) (𝓕⁻ a) (𝓕⁻ f) := by simp [SchwartzMap.convolution] omit [CompleteSpace F] in lemma fourierInv_apply (f : 𝓢(E,F)) (x : E) : (𝓕⁻ f) x = (𝓕 f) (-x) := rfl lemma fourier_pairing_apply (a : 𝓢(E,ℂ)) (f : 𝓢(E,F)) (x : E) : 𝓕 (SchwartzMap.pairing (ContinuousLinearMap.lsmul ℂ ℂ) a f) x = ∫ y, (𝓕 a) y • (𝓕 f) (x-y) := by have he := congrArg (fun (g : 𝓢(E,F)) => g (-x)) (fourierInv_pairing a f) rw [fourierInv_apply, neg_neg, SchwartzMap.convolution_apply] at he change _ = ∫ y, ((𝓕⁻ a) y) • ((𝓕⁻ f) (-x-y)) at he rw [he] simp only [fourierInv_apply, neg_sub] convert integral_neg_eq_self (fun y : E => (𝓕 a) y • (𝓕 f) (x-y)) volume using 1 congr 1 ext y congr 1 congr 1 abel end end LocalFourier open MeasureTheory FourierTransform TemperedDistribution open scoped SchwartzMap Topology noncomputable section namespace SobolevModel variable {E : Type*} {F : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] [NormedAddCommGroup F] [InnerProductSpace ℂ F] [CompleteSpace F] abbrev Model (E : Type*) (F : Type*) [NormedAddCommGroup F] [MeasureSpace E] : Type _ := Lp F 2 (volume : Measure E) variable (E F) in def embedding (s : ℝ) : Model E F →L[ℂ] 𝓢'(E,F) := besselPotential E F (-s) ∘L Lp.toTemperedDistributionCLM F volume 2 lemma embedding_injective (s : ℝ) : Function.Injective (embedding E F s) := by intro f g h have hh := congrArg (besselPotential E F s) h simp only [embedding, ContinuousLinearMap.comp_apply, besselPotential_besselPotential_apply, neg_add_cancel, besselPotential_zero, ContinuousLinearMap.id_apply] at hh exact LinearMap.ker_eq_bot.mp (Lp.ker_toTemperedDistributionCLM_eq_bot (F:=F) (μ:=volume)) hh lemma embedding_memSobolev (s : ℝ) (f : Model E F) : MemSobolev s 2 (embedding E F s f) := by refine ⟨f, ?_⟩ simp [embedding] lemma memSobolev_iff_range (s : ℝ) (u : 𝓢'(E,F)) : MemSobolev s 2 u ↔ u ∈ Set.range (embedding E F s) := by constructor · rintro ⟨f,hf⟩ refine ⟨f, ?_⟩ change besselPotential E F (-s) (f : 𝓢'(E,F)) = u rw [← hf, besselPotential_besselPotential_apply] simp · rintro ⟨f,rfl⟩ exact embedding_memSobolev s f variable (E F) in def schwartzBessel (s : ℝ) : 𝓢(E,F) →L[ℂ] 𝓢(E,F) := SchwartzMap.fourierMultiplierCLM F (fun x => Complex.ofReal ((1+‖x‖^2)^(s/2))) lemma schwartzBessel_add (s t : ℝ) (f : 𝓢(E,F)) : schwartzBessel E F s (schwartzBessel E F t f) = schwartzBessel E F (s+t) f := by rw [schwartzBessel, schwartzBessel, SchwartzMap.fourierMultiplierCLM_fourierMultiplierCLM_apply (by fun_prop) (by fun_prop)] congr 2 ext x simp only [Pi.mul_apply, ← Complex.ofReal_mul] rw [← Real.rpow_add (by positivity)] congr 2 ring @[simp] lemma schwartzBessel_zero (f : 𝓢(E,F)) : schwartzBessel E F 0 f = f := by simp [schwartzBessel] lemma schwartzBessel_surjective (s : ℝ) : Function.Surjective (schwartzBessel E F s) := by intro f exact ⟨schwartzBessel E F (-s) f, by rw [schwartzBessel_add]; simp⟩ variable (E F) in def coordinate (s : ℝ) : 𝓢(E,F) →L[ℂ] Model E F := SchwartzMap.toLpCLM ℂ F 2 volume ∘L schwartzBessel E F s lemma schwartzBessel_distribution (s : ℝ) (f : 𝓢(E,F)) : (schwartzBessel E F s f : 𝓢'(E,F)) = besselPotential E F s (f : 𝓢'(E,F)) := by exact (TemperedDistribution.fourierMultiplierCLM_toTemperedDistributionCLM_eq (by fun_prop) f).symm @[simp] lemma embedding_coordinate (s : ℝ) (f : 𝓢(E,F)) : embedding E F s (coordinate E F s f) = (f : 𝓢'(E,F)) := by change besselPotential E F (-s) (((schwartzBessel E F s f).toLp 2 volume) : 𝓢'(E,F)) = _ rw [Lp.toTemperedDistribution_toLp_eq, schwartzBessel_distribution, besselPotential_besselPotential_apply] simp lemma denseRange_coordinate (s : ℝ) : DenseRange (coordinate E F s) := by have hd : DenseRange (SchwartzMap.toLpCLM ℂ F 2 (volume : Measure E)) := SchwartzMap.denseRange_toLpCLM (by norm_num) exact hd.comp (schwartzBessel_surjective s).denseRange (SchwartzMap.toLpCLM ℂ F 2 volume).continuous theorem lift_operator {s t C : ℝ} (hC : 0 ≤ C) (P : 𝓢'(E,F) →L[ℂ] 𝓢'(E,F)) (Q : 𝓢(E,F) →L[ℂ] 𝓢(E,F)) (hcompat : ∀ f : 𝓢(E,F), P (f : 𝓢'(E,F)) = (Q f : 𝓢'(E,F))) (hbound : ∀ f, ‖coordinate E F t (Q f)‖ ≤ C * ‖coordinate E F s f‖) : ∃ R : Model E F →L[ℂ] Model E F, ‖R‖ ≤ C ∧ ∀ f, embedding E F t (R f) = P (embedding E F s f) := by let e := (coordinate E F s).toLinearMap let q := ((coordinate E F t).comp Q).toLinearMap have hd : DenseRange e := denseRange_coordinate s let R := q.extendOfNorm e refine ⟨R, LinearMap.opNorm_extendOfNorm_le hd hC hbound, ?_⟩ intro f refine hd.induction_on f (isClosed_eq ((embedding E F t).continuous.comp R.continuous) (P.continuous.comp (embedding E F s).continuous)) ?_ intro g change embedding E F t (q.extendOfNorm e (e g)) = P (embedding E F s (e g)) rw [LinearMap.extendOfNorm_eq hd ⟨C,hbound⟩] change embedding E F t (coordinate E F t (Q g)) = P (embedding E F s (coordinate E F s g)) rw [embedding_coordinate, embedding_coordinate, hcompat] end SobolevModel namespace LocalSobolev section open MeasureTheory FourierTransform open scoped SchwartzMap open LocalPeetre variable {E : Type*} {F : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] [NormedAddCommGroup F] [InnerProductSpace ℂ F] [CompleteSpace F] omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in lemma weight_growth (s : ℝ) : (fun x : E => Complex.ofReal (weight s x)).HasTemperateGrowth := by unfold weight fun_prop def weighted (s : ℝ) : 𝓢(E,F) →L[ℂ] 𝓢(E,F) := SchwartzMap.smulLeftCLM F (fun x => Complex.ofReal (weight s x)) omit [CompleteSpace F] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in lemma weighted_apply (s : ℝ) (f : 𝓢(E,F)) (x : E) : weighted s f x = (Complex.ofReal (weight s x)) • f x := by exact SchwartzMap.smulLeftCLM_apply_apply (weight_growth s) f x omit [CompleteSpace F] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in lemma norm_weighted (s : ℝ) (f : 𝓢(E,F)) (x : E) : ‖weighted s f x‖ = weight s x * ‖f x‖ := by rw [weighted_apply,norm_smul,Complex.norm_real,Real.norm_eq_abs,abs_of_pos (weight_pos s x)] lemma norm_coordinate (s : ℝ) (f : 𝓢(E,F)) : ‖SobolevModel.coordinate E F s f‖ = ‖(weighted s (𝓕 f)).toLp 2‖ := by simp only [SobolevModel.coordinate, ContinuousLinearMap.comp_apply, SchwartzMap.toLpCLM_apply] rw [← SchwartzMap.norm_fourier_toL2_eq (SobolevModel.schwartzBessel E F s f)] simp only [SobolevModel.schwartzBessel, SchwartzMap.fourierMultiplierCLM_apply, fourier_fourierInv_eq] rfl omit [CompleteSpace F] in lemma integrable_norm_product (a : 𝓢(E,ℂ)) (f : 𝓢(E,F)) (x : E) : Integrable (fun y => ‖a y‖ * ‖f (x-y)‖) := by apply a.integrable.norm.mul_bdd ((f.continuous.comp (continuous_const.sub continuous_id)).norm.aestronglyMeasurable) exact Filter.Eventually.of_forall fun y => by simpa using f.norm_le_seminorm ℂ (x-y) lemma weighted_fourier_majorant (s : ℝ) (a : 𝓢(E,ℂ)) (f : 𝓢(E,F)) (x : E) : ‖weighted s (𝓕 (SchwartzMap.pairing (ContinuousLinearMap.lsmul ℂ ℂ) a f)) x‖ ≤ ∫ y, (2^(|s|/2) * ‖weighted |s| (𝓕 a) y‖) * ‖weighted s (𝓕 f) (x-y)‖ := by rw [norm_weighted,LocalFourier.fourier_pairing_apply] calc weight s x * ‖∫ y, (𝓕 a) y • (𝓕 f) (x-y)‖ ≤ weight s x * (∫ y, ‖(𝓕 a) y‖ * ‖(𝓕 f) (x-y)‖) := by apply mul_le_mul_of_nonneg_left _ (weight_pos s x).le calc _ ≤ ∫ y, ‖(𝓕 a) y • (𝓕 f) (x-y)‖ := norm_integral_le_integral_norm _ _ = _ := by congr 1 ext y exact norm_smul ((𝓕 a) y) ((𝓕 f) (x-y)) _ = ∫ y, weight s x * (‖(𝓕 a) y‖ * ‖(𝓕 f) (x-y)‖) := (integral_const_mul _ _).symm _ ≤ _ := by apply integral_mono ((integrable_norm_product (𝓕 a) (𝓕 f) x).const_mul _) (by convert (integrable_norm_product (weighted |s| (𝓕 a)) (weighted s (𝓕 f)) x).const_mul (2^(|s|/2)) using 1 simp only [mul_assoc]) intro y dsimp only rw [norm_weighted,norm_weighted] nlinarith [mul_le_mul_of_nonneg_right (weight_sub s x y) (mul_nonneg (norm_nonneg ((𝓕 a) y)) (norm_nonneg ((𝓕 f) (x-y))))] omit [CompleteSpace F] in lemma toLp_norm_norm (f : 𝓢(E,F)) : ‖(f.memLp 2 volume).norm.toLp (fun x => ‖f x‖)‖ = ‖f.toLp 2‖ := by rw [Lp.norm_toLp,eLpNorm_norm _ f.continuous.aestronglyMeasurable,SchwartzMap.norm_toLp] theorem multiplication_bound (s : ℝ) (a : 𝓢(E,ℂ)) (f : 𝓢(E,F)) : ‖SobolevModel.coordinate E F s (SchwartzMap.pairing (ContinuousLinearMap.lsmul ℂ ℂ) a f)‖ ≤ (2^(|s|/2) * ‖(weighted |s| (𝓕 a)).toLp 1‖) * ‖SobolevModel.coordinate E F s f‖ := by let d := weighted s (𝓕 (SchwartzMap.pairing (ContinuousLinearMap.lsmul ℂ ℂ) a f)) let c := weighted s (𝓕 f) let b := weighted |s| (𝓕 a) have hb : Integrable (fun y => 2^(|s|/2) * ‖b y‖) := b.integrable.norm.const_mul _ have hh := LocalConvolution.norm_le_convolution_majorant hb c.integrable.norm (c.memLp 2 volume).norm (d.memLp 2 volume).norm d.continuous.norm (fun y => mul_nonneg (Real.rpow_nonneg (by norm_num) _) (norm_nonneg _)) (fun y => norm_nonneg (d y)) ⟨SchwartzMap.seminorm ℂ 0 0 d, fun y => by simpa using d.norm_le_seminorm ℂ y⟩ (weighted_fourier_majorant s a f) rw [toLp_norm_norm,toLp_norm_norm,integral_const_mul,← SchwartzMap.norm_toLp_one] at hh simpa only [norm_coordinate,d,c,b] using hh omit [CompleteSpace F] in lemma multiplication_distribution (a : 𝓢(E,ℂ)) (f : 𝓢(E,F)) : TemperedDistribution.smulLeftCLM F a (f : 𝓢'(E,F)) = (SchwartzMap.pairing (ContinuousLinearMap.lsmul ℂ ℂ) a f : 𝓢'(E,F)) := by ext φ rw [TemperedDistribution.smulLeftCLM_apply_apply, SchwartzMap.coe_apply, SchwartzMap.coe_apply] apply integral_congr_ae filter_upwards [] with x rw [SchwartzMap.smulLeftCLM_apply_apply a.hasTemperateGrowth, SchwartzMap.pairing_apply_apply] simpa only [smul_smul, ContinuousLinearMap.lsmul_apply, smul_eq_mul] using smul_comm (a x) (φ x) (f x) theorem multiplication_lift (s : ℝ) (a : 𝓢(E,ℂ)) : ∃ R : SobolevModel.Model E F →L[ℂ] SobolevModel.Model E F, ‖R‖ ≤ 2^(|s|/2) * ‖(weighted |s| (𝓕 a)).toLp 1‖ ∧ ∀ f, SobolevModel.embedding E F s (R f) = TemperedDistribution.smulLeftCLM F a (SobolevModel.embedding E F s f) := by exact SobolevModel.lift_operator (by positivity) (TemperedDistribution.smulLeftCLM F a) (SchwartzMap.pairing (ContinuousLinearMap.lsmul ℂ ℂ) a) (multiplication_distribution a) (multiplication_bound s a) lemma continuous_multiplier_gauge (s : ℝ) : Continuous (fun a : 𝓢(E,ℂ) => 2^(|s|/2) * ‖(weighted |s| (𝓕 a)).toLp 1‖) := by exact continuous_const.mul (((SchwartzMap.toLpCLM ℂ ℂ 1 volume).continuous.comp ((weighted |s|).continuous.comp (fourierCLM ℂ (𝓢(E,ℂ))).continuous)).norm) end open MeasureTheory FourierTransform LocalPeetre open scoped SchwartzMap variable {E : Type*} {F : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] [NormedAddCommGroup F] [InnerProductSpace ℂ F] [CompleteSpace F] omit [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in lemma weight_add (s t : ℝ) (x : E) : weight (s+t) x = weight s x * weight t x := by unfold weight rw [show (s+t)/2=s/2+t/2 by ring, Real.rpow_add (by positivity)] lemma fourier_multiplier_bound {s t C : ℝ} {p : E → ℂ} (hp : p.HasTemperateGrowth) (hb : ∀ x, weight (t-s) x * ‖p x‖ ≤ C) (f : 𝓢(E,F)) : ‖SobolevModel.coordinate E F t (SchwartzMap.fourierMultiplierCLM F p f)‖ ≤ C * ‖SobolevModel.coordinate E F s f‖ := by rw [norm_coordinate, norm_coordinate] apply Lp.norm_le_mul_norm_of_ae_le_mul filter_upwards [SchwartzMap.coeFn_toLp (weighted t (𝓕 (SchwartzMap.fourierMultiplierCLM F p f))) (p:=2) (μ:=volume), SchwartzMap.coeFn_toLp (weighted s (𝓕 f)) (p:=2) (μ:=volume)] with x hx hy rw [hx,hy,norm_weighted,norm_weighted,SchwartzMap.fourierMultiplierCLM_apply, fourier_fourierInv_eq,SchwartzMap.smulLeftCLM_apply_apply hp,norm_smul] have ht : weight t x = weight (t-s) x * weight s x := by rw [← weight_add]; congr 1; ring rw [ht] nlinarith [mul_le_mul_of_nonneg_right (hb x) (mul_nonneg (weight_pos s x).le (norm_nonneg ((𝓕 f) x)))] theorem fourier_multiplier_lift {s t C : ℝ} (hC : 0 ≤ C) {p : E → ℂ} (hp : p.HasTemperateGrowth) (hb : ∀ x, weight (t-s) x * ‖p x‖ ≤ C) : ∃ R : SobolevModel.Model E F →L[ℂ] SobolevModel.Model E F, ‖R‖ ≤ C ∧ ∀ f, SobolevModel.embedding E F t (R f) = TemperedDistribution.fourierMultiplierCLM F p (SobolevModel.embedding E F s f) := by exact SobolevModel.lift_operator hC (TemperedDistribution.fourierMultiplierCLM F p) (SchwartzMap.fourierMultiplierCLM F p) (fun f => TemperedDistribution.fourierMultiplierCLM_toTemperedDistributionCLM_eq hp f) (fourier_multiplier_bound hp hb) end LocalSobolev namespace SobolevModel variable {E : Type*} {F : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] [NormedAddCommGroup F] [InnerProductSpace ℂ F] [CompleteSpace F] lemma kernel_eq_zero_of_small (s : ℝ) (P : 𝓢'(E,F) →L[ℂ] 𝓢'(E,F)) (R : Model E F →L[ℂ] Model E F) (hR : ‖R‖ < 1) (compat : ∀ v, embedding E F s (R v) = P (embedding E F s v)) {u : 𝓢'(E,F)} (hu : MemSobolev s 2 u) (heq : u-P u=0) : u=0 := by obtain ⟨v,rfl⟩ := (memSobolev_iff_range s u).mp hu have he : (1-R) v = 0 := by apply embedding_injective s simp only [map_zero, sub_apply, one_apply_eq_self, map_sub,compat,heq] have hi : Function.Injective ((1-R) : Model E F →L[ℂ] Model E F) := (ContinuousLinearMap.isUnit_iff_bijective.mp (isUnit_one_sub_of_norm_lt_one hR)).1 have hv : v=0 := hi (by simpa using he) simp [hv] theorem regularity_of_small_perturbation {s t : ℝ} (hst : s ≤ t) (P : 𝓢'(E,F) →L[ℂ] 𝓢'(E,F)) (Rs Rt : Model E F →L[ℂ] Model E F) (hs : ‖Rs‖ < 1) (ht : ‖Rt‖ < 1) (cs : ∀ v, embedding E F s (Rs v) = P (embedding E F s v)) (ct : ∀ v, embedding E F t (Rt v) = P (embedding E F t v)) {u : 𝓢'(E,F)} (hu : MemSobolev s 2 u) (hPu : MemSobolev t 2 (u-P u)) : MemSobolev t 2 u := by obtain ⟨w, hw⟩ := (memSobolev_iff_range t (u-P u)).mp hPu obtain ⟨v,hv⟩ := (ContinuousLinearMap.isUnit_iff_bijective.mp (isUnit_one_sub_of_norm_lt_one ht)).2 w have he : embedding E F t v - P (embedding E F t v) = u-P u := by rw [← ct, ← map_sub] exact (congrArg (embedding E F t) hv).trans hw have hmem := (embedding_memSobolev t v).mono hst have hzero : u-embedding E F t v=0 := by apply kernel_eq_zero_of_small s P Rs hs cs (hu.sub hmem) rw [map_sub] calc _ = (u-P u) - (embedding E F t v-P (embedding E F t v)) := by abel _ = 0 := sub_eq_zero.mpr he.symm rw [sub_eq_zero] at hzero rw [hzero] exact embedding_memSobolev t v end SobolevModel namespace LocalParametrix open MeasureTheory FourierTransform TemperedDistribution LocalPeetre LocalSobolev open scoped SchwartzMap BigOperators variable {E : Type*} {F : Type*} {ι : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] [NormedAddCommGroup F] [InnerProductSpace ℂ F] [CompleteSpace F] [Fintype ι] def coefficientGauge (s : ℝ) (a : 𝓢(E,ℂ)) : ℝ := 2^(|s|/2) * ‖(weighted |s| (𝓕 a)).toLp 1‖ lemma coefficientGauge_nonneg (s : ℝ) (a : 𝓢(E,ℂ)) : 0 ≤ coefficientGauge s a := by unfold coefficientGauge positivity @[simp] lemma coefficientGauge_zero (s : ℝ) : coefficientGauge s (0 : 𝓢(E,ℂ)) = 0 := by change 2^(|s|/2) * ‖(SchwartzMap.toLpCLM ℂ ℂ 1 volume) (weighted |s| (𝓕 (0 : 𝓢(E,ℂ))))‖ = 0 change 2^(|s|/2) * ‖(SchwartzMap.toLpCLM ℂ ℂ 1 volume) (weighted |s| ((fourierCLM ℂ (𝓢(E,ℂ))) 0))‖ = 0 simp only [map_zero, norm_zero, mul_zero] lemma continuous_coefficientGauge (s : ℝ) : Continuous (coefficientGauge (E:=E) s) := continuous_multiplier_gauge s def perturbation (q : E → ℂ) (p : ι → E → ℂ) (a : ι → 𝓢(E,ℂ)) : 𝓢'(E,F) →L[ℂ] 𝓢'(E,F) := (TemperedDistribution.fourierMultiplierCLM F q).comp (∑ i, (TemperedDistribution.smulLeftCLM F (a i)).comp (TemperedDistribution.fourierMultiplierCLM F (p i))) theorem perturbation_lift (s m Cq : ℝ) (Cp : ι → ℝ) (hCq : 0 ≤ Cq) (hCp : ∀ i, 0 ≤ Cp i) {q : E → ℂ} (hq : q.HasTemperateGrowth) (hbq : ∀ x, weight m x * ‖q x‖ ≤ Cq) {p : ι → E → ℂ} (hp : ∀ i, (p i).HasTemperateGrowth) (hbp : ∀ i x, weight (-m) x * ‖p i x‖ ≤ Cp i) (a : ι → 𝓢(E,ℂ)) : ∃ R : SobolevModel.Model E F →L[ℂ] SobolevModel.Model E F, ‖R‖ ≤ Cq * ∑ i, coefficientGauge (s-m) (a i) * Cp i ∧ ∀ f, SobolevModel.embedding E F s (R f) = perturbation (F:=F) q p a (SobolevModel.embedding E F s f) := by obtain ⟨Q,hQ,cQ⟩ := fourier_multiplier_lift (s:=s-m) (t:=s) (F:=F) hCq hq (by convert hbq using 1; ring_nf) have hD : ∀ i, ∃ D : SobolevModel.Model E F →L[ℂ] SobolevModel.Model E F, ‖D‖ ≤ Cp i ∧ ∀ f, SobolevModel.embedding E F (s-m) (D f) = TemperedDistribution.fourierMultiplierCLM F (p i) (SobolevModel.embedding E F s f) := by intro i apply fourier_multiplier_lift (hCp i) (hp i) convert hbp i using 1; ring_nf choose D hD cD using hD have hA : ∀ i, ∃ A : SobolevModel.Model E F →L[ℂ] SobolevModel.Model E F, ‖A‖ ≤ coefficientGauge (s-m) (a i) ∧ ∀ f, SobolevModel.embedding E F (s-m) (A f) = TemperedDistribution.smulLeftCLM F (a i) (SobolevModel.embedding E F (s-m) f) := fun i => multiplication_lift (s-m) (a i) choose A hA cA using hA refine ⟨Q.comp (∑ i, (A i).comp (D i)), ?_, ?_⟩ · calc _ ≤ ‖Q‖ * ‖∑ i, (A i).comp (D i)‖ := ContinuousLinearMap.opNorm_comp_le _ _ _ ≤ Cq * ∑ i, coefficientGauge (s-m) (a i) * Cp i := by apply mul_le_mul hQ _ (norm_nonneg _) hCq calc _ ≤ ∑ i, ‖(A i).comp (D i)‖ := norm_sum_le _ _ _ ≤ _ := by apply Finset.sum_le_sum intro i hi exact (ContinuousLinearMap.opNorm_comp_le _ _).trans (mul_le_mul (hA i) (hD i) (norm_nonneg _) (coefficientGauge_nonneg _ _)) · intro f simp only [ContinuousLinearMap.comp_apply, cQ, map_sum, sum_apply, cA, cD, perturbation] theorem gain_of_small_principal {s t m Cq : ℝ} (hst : s ≤ t) (Cp : ι → ℝ) (hCq : 0 ≤ Cq) (hCp : ∀ i, 0 ≤ Cp i) {q : E → ℂ} (hq : q.HasTemperateGrowth) (hbq : ∀ x, weight m x * ‖q x‖ ≤ Cq) {p : ι → E → ℂ} (hp : ∀ i, (p i).HasTemperateGrowth) (hbp : ∀ i x, weight (-m) x * ‖p i x‖ ≤ Cp i) (a : ι → 𝓢(E,ℂ)) (hs : Cq * ∑ i, coefficientGauge (s-m) (a i) * Cp i < 1) (ht : Cq * ∑ i, coefficientGauge (t-m) (a i) * Cp i < 1) {u : 𝓢'(E,F)} (hu : MemSobolev s 2 u) (hf : MemSobolev t 2 (u - perturbation (F:=F) q p a u)) : MemSobolev t 2 u := by obtain ⟨Rs,hRs,cRs⟩ := perturbation_lift (F:=F) s m Cq Cp hCq hCp hq hbq hp hbp a obtain ⟨Rt,hRt,cRt⟩ := perturbation_lift (F:=F) t m Cq Cp hCq hCp hq hbq hp hbp a exact SobolevModel.regularity_of_small_perturbation hst _ Rs Rt (hRs.trans_lt hs) (hRt.trans_lt ht) cRs cRt hu hf theorem eventually_small_coefficients {α : Type*} {l : Filter α} {a : α → ι → 𝓢(E,ℂ)} (ha : ∀ i, Filter.Tendsto (fun r => a r i) l (nhds 0)) (s t m Cq : ℝ) (Cp : ι → ℝ) : ∀ᶠ r in l, Cq * ∑ i, coefficientGauge (s-m) (a r i) * Cp i < 1 ∧ Cq * ∑ i, coefficientGauge (t-m) (a r i) * Cp i < 1 := by have hbound : ∀ z : ℝ, Filter.Tendsto (fun r => Cq * ∑ i, coefficientGauge (z-m) (a r i) * Cp i) l (nhds 0) := by intro z have hi : ∀ i, Filter.Tendsto (fun r => coefficientGauge (z-m) (a r i) * Cp i) l (nhds (0:ℝ)) := by intro i simpa using (((continuous_coefficientGauge (z-m)).continuousAt.tendsto.comp (ha i)).mul_const (Cp i)) simpa using (Filter.Tendsto.const_mul Cq (tendsto_finsetSum Finset.univ (fun i _ => hi i))) exact ((hbound s).eventually (gt_mem_nhds (by norm_num : (0:ℝ)<1))).and ((hbound t).eventually (gt_mem_nhds (by norm_num : (0:ℝ)<1))) end LocalParametrix end open MeasureTheory TemperedDistribution FourierTransform LineDeriv open scoped SchwartzMap ContDiff noncomputable section namespace LocalDifferential variable {E : Type*} {F : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [NormedAddCommGroup F] [InnerProductSpace ℂ F] def product (a b : 𝓢(E,ℂ)) : 𝓢(E,ℂ) := SchwartzMap.smulLeftCLM ℂ a b @[simp] lemma product_apply (a b : 𝓢(E,ℂ)) (x : E) : product a b x = a x * b x := by exact SchwartzMap.smulLeftCLM_apply_apply a.hasTemperateGrowth b x lemma schwartz_product_derivative (v : E) (a b : 𝓢(E,ℂ)) : ∂_{v} (product a b) = product (∂_{v} a) b + product a (∂_{v} b) := by ext x rw [SchwartzMap.lineDerivOp_apply_eq_fderiv] have heq : (product a b : E → ℂ) = (fun y => a y * b y) := funext (product_apply a b) rw [heq] rw [fderiv_fun_mul a.differentiableAt b.differentiableAt] simp [product_apply, SchwartzMap.lineDerivOp_apply_eq_fderiv, mul_comm, add_comm] lemma product_neg_right (a b : 𝓢(E,ℂ)) : product a (-b) = -(product a b) := by ext x; simp theorem derivative_multiply (v : E) (a : 𝓢(E,ℂ)) (u : 𝓢'(E,F)) : ∂_{v} (TemperedDistribution.smulLeftCLM F a u) = TemperedDistribution.smulLeftCLM F (∂_{v} a : 𝓢(E,ℂ)) u + TemperedDistribution.smulLeftCLM F a (∂_{v} u) := by ext φ simp only [TemperedDistribution.lineDerivOp_apply_apply, TemperedDistribution.smulLeftCLM_apply_apply, add_apply, map_neg] change -u (product a (∂_{v} φ)) = u (product (∂_{v} a) φ) + -u (∂_{v} (product a φ)) rw [schwartz_product_derivative, map_add] abel def derivative : List E → 𝓢'(E,F) →L[ℂ] 𝓢'(E,F) | [] => ContinuousLinearMap.id ℂ _ | v::vs => (lineDerivOpCLM ℂ 𝓢'(E,F) v).comp (derivative vs) @[simp] theorem derivative_nil (u : 𝓢'(E,F)) : derivative [] u = u := rfl @[simp] theorem derivative_cons (v : E) (vs : List E) (u : 𝓢'(E,F)) : derivative (v::vs) u = ∂_{v} (derivative vs u) := rfl variable [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] [CompleteSpace F] theorem derivative_sobolev {s : ℝ} {u : 𝓢'(E,F)} (hu : MemSobolev s 2 u) (vs : List E) : MemSobolev (s-(vs.length:ℝ)) 2 (derivative vs u) := by induction vs with | nil => simpa using hu | cons v vs ih => simpa only [derivative_cons, List.length_cons, Nat.cast_add, Nat.cast_one, sub_add_eq_sub_sub] using (ih.lineDerivOp (m:=v)) end LocalDifferential namespace LocalBootstrap open MeasureTheory TemperedDistribution FourierTransform LineDeriv LocalSobolev LocalDifferential open scoped SchwartzMap BigOperators variable {E : Type*} {F : Type*} {ι : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] [NormedAddCommGroup F] [InnerProductSpace ℂ F] [CompleteSpace F] theorem multiply_sobolev {s : ℝ} {u : 𝓢'(E,F)} (hu : MemSobolev s 2 u) (a : 𝓢(E,ℂ)) : MemSobolev s 2 (TemperedDistribution.smulLeftCLM F a u) := by obtain ⟨f,rfl⟩ := (SobolevModel.memSobolev_iff_range s u).mp hu obtain ⟨R,_,hR⟩ := multiplication_lift (F:=F) s a rw [←hR f] exact SobolevModel.embedding_memSobolev s (R f) theorem commutator_sobolev {s : ℝ} {u : 𝓢'(E,F)} (hu : MemSobolev s 2 u) (a : 𝓢(E,ℂ)) (vs : List E) : MemSobolev (s-(vs.length:ℝ)+1) 2 (derivative vs (TemperedDistribution.smulLeftCLM F a u) - TemperedDistribution.smulLeftCLM F a (derivative vs u)) := by induction vs with | nil => simp | cons v vs ih => have heq : derivative (v::vs) (TemperedDistribution.smulLeftCLM F a u) - TemperedDistribution.smulLeftCLM F a (derivative (v::vs) u) = ∂_{v} (derivative vs (TemperedDistribution.smulLeftCLM F a u) - TemperedDistribution.smulLeftCLM F a (derivative vs u)) + TemperedDistribution.smulLeftCLM F (∂_{v} a : 𝓢(E,ℂ)) (derivative vs u) := by simp only [derivative_cons] change _ = (lineDerivOpCLM ℂ 𝓢'(E,F) v) (_ - _) + _ rw [map_sub] change _ = ∂_{v} (derivative vs (TemperedDistribution.smulLeftCLM F a u)) - ∂_{v} (TemperedDistribution.smulLeftCLM F a (derivative vs u)) + _ rw [derivative_multiply] abel rw [heq] have h1 : MemSobolev (s-(vs.length:ℝ)) 2 (∂_{v} (derivative vs (TemperedDistribution.smulLeftCLM F a u) - TemperedDistribution.smulLeftCLM F a (derivative vs u))) := by convert ih.lineDerivOp (m:=v) using 1 ring have h2 := multiply_sobolev (derivative_sobolev hu vs) (∂_{v} a) convert h1.add h2 using 1 simp only [List.length_cons, Nat.cast_add, Nat.cast_one] ring lemma sobolev_finset_sum {s : ℝ} (I : Finset ι) (u : ι → 𝓢'(E,F)) (hu : ∀ i ∈ I, MemSobolev s 2 (u i)) : MemSobolev s 2 (∑ i ∈ I, u i) := by classical induction I using Finset.induction_on with | empty => simp | @insert i I hi ih => simp only [Finset.sum_insert hi] exact (hu i (Finset.mem_insert_self _ _)).add (ih (fun j hj => hu j (Finset.mem_insert_of_mem hj))) theorem lower_order_sobolev [Fintype ι] {s : ℝ} {m : ℕ} {u : 𝓢'(E,F)} (hu : MemSobolev s 2 u) (a : ι → 𝓢(E,ℂ)) (vs : ι → List E) (horder : ∀ i, (vs i).length < m) : MemSobolev (s-(m:ℝ)+1) 2 (∑ i, TemperedDistribution.smulLeftCLM F (a i) (derivative (vs i) u)) := by apply sobolev_finset_sum intro i hi apply (multiply_sobolev (derivative_sobolev hu (vs i)) (a i)).mono have hh : ((vs i).length:ℝ)+1 ≤ (m:ℝ) := by exact_mod_cast horder i linarith theorem gain_from_frozen_equation [Fintype ι] {s m Cq : ℝ} (Cp : ι → ℝ) (hCq : 0 ≤ Cq) (hCp : ∀ i, 0 ≤ Cp i) {q p₀ : E → ℂ} (hq : q.HasTemperateGrowth) (hp₀ : p₀.HasTemperateGrowth) (hinv : ∀ x, p₀ x * q x = 1) (hbq : ∀ x, LocalPeetre.weight m x * ‖q x‖ ≤ Cq) {p : ι → E → ℂ} (hp : ∀ i, (p i).HasTemperateGrowth) (hbp : ∀ i x, LocalPeetre.weight (-m) x * ‖p i x‖ ≤ Cp i) (a : ι → 𝓢(E,ℂ)) (hs : Cq * ∑ i, LocalParametrix.coefficientGauge (s-m) (a i) * Cp i < 1) (ht : Cq * ∑ i, LocalParametrix.coefficientGauge (s+1-m) (a i) * Cp i < 1) {u f : 𝓢'(E,F)} (hu : MemSobolev s 2 u) (hf : MemSobolev (s-m+1) 2 f) (heq : TemperedDistribution.fourierMultiplierCLM F p₀ u - ∑ i, TemperedDistribution.smulLeftCLM F (a i) (TemperedDistribution.fourierMultiplierCLM F (p i) u) = f) : MemSobolev (s+1) 2 u := by apply LocalParametrix.gain_of_small_principal (by linarith) Cp hCq hCp hq hbq hp hbp a hs ht hu obtain ⟨Q,_,hQ⟩ := fourier_multiplier_lift (s:=s-m+1) (t:=s+1) (F:=F) hCq hq (by convert hbq using 1; ring_nf) obtain ⟨v,hv⟩ := (SobolevModel.memSobolev_iff_range (s-m+1) f).mp hf have hreg : MemSobolev (s+1) 2 (TemperedDistribution.fourierMultiplierCLM F q f) := by rw [←hv, ←hQ] exact SobolevModel.embedding_memSobolev (s+1) (Q v) have he := congrArg (TemperedDistribution.fourierMultiplierCLM F q) heq rw [map_sub, TemperedDistribution.fourierMultiplierCLM_fourierMultiplierCLM_apply hp₀ hq] at he have hpq : p₀*q = 1 := by ext x; exact hinv x rw [hpq] at he have hone : TemperedDistribution.fourierMultiplierCLM F (1 : E → ℂ) u = u := by change TemperedDistribution.fourierMultiplierCLM F (fun _ => 1) u = u simp rw [hone] at he have he' : u - LocalParametrix.perturbation (F:=F) q p a u = TemperedDistribution.fourierMultiplierCLM F q f := by simpa only [LocalParametrix.perturbation, ContinuousLinearMap.comp_apply, sum_apply] using he rw [he'] exact hreg end LocalBootstrap namespace LocalDifferential open MeasureTheory FourierTransform TemperedDistribution LineDeriv open scoped SchwartzMap Real variable {E : Type*} {F : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [NormedAddCommGroup F] [InnerProductSpace ℂ F] def symbol : List E → E → ℂ | [] => fun _ => 1 | v::vs => fun x => symbol vs x * ((2 * Real.pi * Complex.I) * Complex.ofReal (inner ℝ x v)) def symbolConstant : List E → ℝ | [] => 1 | v::vs => symbolConstant vs * (‖(2 * Real.pi * Complex.I : ℂ)‖ * ‖v‖) omit [InnerProductSpace ℝ E] in lemma symbolConstant_nonneg (vs : List E) : 0 ≤ symbolConstant vs := by induction vs with | nil => norm_num [symbolConstant] | cons v vs ih => exact mul_nonneg ih (by positivity) lemma symbol_growth (vs : List E) : (symbol vs).HasTemperateGrowth := by induction vs with | nil => exact Function.HasTemperateGrowth.const _ | cons v vs ih => exact ih.mul (by fun_prop) omit [InnerProductSpace ℝ E] in lemma norm_le_weight_one (x : E) : ‖x‖ ≤ (1+‖x‖^2)^((1:ℝ)/2) := by rw [←Real.sqrt_eq_rpow] apply (Real.le_sqrt (norm_nonneg x) (by positivity)).mpr nlinarith lemma symbol_bound (vs : List E) (x : E) : ‖symbol vs x‖ ≤ symbolConstant vs * (1+‖x‖^2)^((vs.length:ℝ)/2) := by induction vs with | nil => simp [symbol, symbolConstant] | cons v vs ih => have h1 : ‖Complex.ofReal (inner ℝ x v)‖ ≤ (1+‖x‖^2)^((1:ℝ)/2) * ‖v‖ := by rw [Complex.norm_real, Real.norm_eq_abs] exact (abs_real_inner_le_norm x v).trans (mul_le_mul_of_nonneg_right (norm_le_weight_one x) (norm_nonneg v)) calc ‖symbol (v::vs) x‖ = ‖symbol vs x‖ * (‖(2 * Real.pi * Complex.I : ℂ)‖ * ‖Complex.ofReal (inner ℝ x v)‖) := by simp only [symbol, norm_mul] _ ≤ (symbolConstant vs * (1+‖x‖^2)^((vs.length:ℝ)/2)) * (‖(2 * Real.pi * Complex.I : ℂ)‖ * ((1+‖x‖^2)^((1:ℝ)/2) * ‖v‖)) := by gcongr exact mul_nonneg (symbolConstant_nonneg vs) (by positivity) _ = symbolConstant (v::vs) * (1+‖x‖^2)^(((v::vs).length:ℝ)/2) := by simp only [symbolConstant, List.length_cons, Nat.cast_add, Nat.cast_one, add_div, Real.rpow_add (by positivity : 0 < 1+‖x‖^2)] ring lemma weighted_symbol_bound (vs : List E) (x : E) : (1+‖x‖^2)^(-(vs.length:ℝ)/2) * ‖symbol vs x‖ ≤ symbolConstant vs := by calc _ ≤ (1+‖x‖^2)^(-(vs.length:ℝ)/2) * (symbolConstant vs * (1+‖x‖^2)^((vs.length:ℝ)/2)) := mul_le_mul_of_nonneg_left (symbol_bound vs x) (by positivity) _ = symbolConstant vs := by rw [neg_div, Real.rpow_neg (by positivity : 0 ≤ 1+‖x‖^2)] field_simp variable [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] lemma derivative_fourier (vs : List E) (u : 𝓢'(E,F)) : derivative vs u = fourierMultiplierCLM F (symbol vs) u := by induction vs with | nil => simp [symbol] | cons v vs ih => rw [derivative_cons, ih, lineDeriv_eq_fourierMultiplierCLM] rw [fourierMultiplierCLM_fourierMultiplierCLM_apply (symbol_growth vs) (by fun_prop)] rw [←smul_apply, ←fourierMultiplierCLM_smul ((symbol_growth vs).mul (by fun_prop))] congr 2 ext x simp only [Pi.mul_apply, Pi.smul_apply, smul_eq_mul, symbol] ring end LocalDifferential namespace LocalSupport open MeasureTheory TemperedDistribution LineDeriv Filter open scoped SchwartzMap Topology variable {E : Type*} {F : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [NormedAddCommGroup F] [InnerProductSpace ℂ F] def SupportedIn (u : 𝓢'(E,F)) (K : Set E) : Prop := ∀ φ : 𝓢(E,ℂ), (∀ x ∈ K, (φ : E → ℂ) =ᶠ[𝓝 x] 0) → u φ = 0 lemma supported_multiply (χ : 𝓢(E,ℂ)) (u : 𝓢'(E,F)) : SupportedIn (smulLeftCLM F χ u) (tsupport χ) := by intro φ hφ rw [smulLeftCLM_apply_apply] have hz : SchwartzMap.smulLeftCLM ℂ χ φ = 0 := by ext x rw [SchwartzMap.smulLeftCLM_apply_apply χ.hasTemperateGrowth] by_cases hx : χ x = 0 · simp [hx] · have hpx := (hφ x (subset_tsupport χ (Function.mem_support.mpr hx))).self_of_nhds simp [hpx] rw [hz, map_zero] lemma SupportedIn.lineDeriv {u : 𝓢'(E,F)} {K : Set E} (hu : SupportedIn u K) (v : E) : SupportedIn (∂_{v} u) K := by intro φ hφ rw [TemperedDistribution.lineDerivOp_apply_apply] rw [map_neg, hu (∂_{v} φ) ?_, neg_zero] intro x hx have he := (hφ x hx).fderiv (𝕜:=ℝ) filter_upwards [he] with y hy simpa only [SchwartzMap.lineDerivOp_apply_eq_fderiv, fderiv_zero, Pi.zero_apply, zero_apply] using congrArg (fun A : E →L[ℝ] ℂ => A v) hy lemma SupportedIn.derivative {u : 𝓢'(E,F)} {K : Set E} (hu : SupportedIn u K) (vs : List E) : SupportedIn (LocalDifferential.derivative vs u) K := by induction vs with | nil => exact hu | cons v vs ih => exact ih.lineDeriv v lemma SupportedIn.multiply_congr {u : 𝓢'(E,F)} {K : Set E} (hu : SupportedIn u K) {a b : E → ℂ} (ha : a.HasTemperateGrowth) (hb : b.HasTemperateGrowth) (hab : ∀ x ∈ K, a =ᶠ[𝓝 x] b) : smulLeftCLM F a u = smulLeftCLM F b u := by ext φ change u (SchwartzMap.smulLeftCLM ℂ a φ) = u (SchwartzMap.smulLeftCLM ℂ b φ) apply sub_eq_zero.mp rw [←map_sub] apply hu intro x hx filter_upwards [hab x hx] with y hy simp only [sub_apply, SchwartzMap.smulLeftCLM_apply_apply ha, SchwartzMap.smulLeftCLM_apply_apply hb, hy, sub_self, Pi.zero_apply] lemma SupportedIn.cutoff_identity {u : 𝓢'(E,F)} {K : Set E} (hu : SupportedIn u K) (η : 𝓢(E,ℂ)) (hη : ∀ x ∈ K, (η : E → ℂ) =ᶠ[𝓝 x] 1) : smulLeftCLM F η u = u := by have he := hu.multiply_congr η.hasTemperateGrowth (Function.HasTemperateGrowth.const (1:ℂ)) hη simpa using he end LocalSupport namespace LocalOperator open MeasureTheory TemperedDistribution FourierTransform LocalDifferential LocalBootstrap LocalSupport open scoped SchwartzMap BigOperators variable {E : Type*} {F : Type*} {ι : Type*} {κ : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [NormedAddCommGroup F] [InnerProductSpace ℂ F] [Fintype ι] def operator (a : ι → 𝓢(E,ℂ)) (vs : ι → List E) : 𝓢'(E,F) →L[ℂ] 𝓢'(E,F) := ∑ i, (smulLeftCLM F (a i)).comp (derivative (vs i)) lemma operator_apply (a : ι → 𝓢(E,ℂ)) (vs : ι → List E) (u : 𝓢'(E,F)) : operator a vs u = ∑ i, smulLeftCLM F (a i) (derivative (vs i) u) := by simp only [operator, sum_apply, ContinuousLinearMap.comp_apply] lemma multiply_comm (a b : 𝓢(E,ℂ)) (u : 𝓢'(E,F)) : smulLeftCLM F a (smulLeftCLM F b u) = smulLeftCLM F b (smulLeftCLM F a u) := by rw [smulLeftCLM_smulLeftCLM_apply b.hasTemperateGrowth a.hasTemperateGrowth, smulLeftCLM_smulLeftCLM_apply a.hasTemperateGrowth b.hasTemperateGrowth, mul_comm] lemma operator_cutoff (a : ι → 𝓢(E,ℂ)) (vs : ι → List E) (χ : 𝓢(E,ℂ)) (u : 𝓢'(E,F)) : operator a vs (smulLeftCLM F χ u) = smulLeftCLM F χ (operator a vs u) + ∑ i, smulLeftCLM F (a i) (derivative (vs i) (smulLeftCLM F χ u) - smulLeftCLM F χ (derivative (vs i) u)) := by simp only [operator_apply, map_sum, map_sub] rw [←Finset.sum_add_distrib] apply Finset.sum_congr rfl intro i hi rw [multiply_comm χ (a i)] abel def perturbCoefficient (c : ι → ℂ) (η : 𝓢(E,ℂ)) (a : ι → 𝓢(E,ℂ)) (i : ι) : 𝓢(E,ℂ) := c i • η - a i omit [Fintype ι] in lemma perturb_on_cutoff (c : ι → ℂ) (η χ : 𝓢(E,ℂ)) (a : ι → 𝓢(E,ℂ)) (hη : ∀ x ∈ tsupport χ, (η : E → ℂ) =ᶠ[nhds x] 1) (vs : ι → List E) (u : 𝓢'(E,F)) (i : ι) : smulLeftCLM F (perturbCoefficient c η a i) (derivative (vs i) (smulLeftCLM F χ u)) = c i • derivative (vs i) (smulLeftCLM F χ u) - smulLeftCLM F (a i) (derivative (vs i) (smulLeftCLM F χ u)) := by have hcut := ((supported_multiply χ u).derivative (vs i)).cutoff_identity η hη change smulLeftCLM F (c i • (η : E → ℂ) - (a i : E → ℂ)) _ = _ have hg : (c i • (η : E → ℂ)).HasTemperateGrowth := by simpa only [Pi.smul_def, Pi.mul_def, smul_eq_mul] using (Function.HasTemperateGrowth.const (c i)).smul η.hasTemperateGrowth rw [smulLeftCLM_sub hg (a i).hasTemperateGrowth, sub_apply, smulLeftCLM_smul η.hasTemperateGrowth, smul_apply, hcut] variable [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] def frozenSymbol (c : ι → ℂ) (vs : ι → List E) : E → ℂ := (fun _ => 1) + (fun x => ∑ i, (c i • symbol (vs i)) x) omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in lemma frozenSymbol_growth (c : ι → ℂ) (vs : ι → List E) : (frozenSymbol c vs).HasTemperateGrowth := by apply (Function.HasTemperateGrowth.const (1:ℂ)).add apply Function.HasTemperateGrowth.sum intro i hi simpa only [Pi.smul_def, Pi.mul_def, smul_eq_mul] using (Function.HasTemperateGrowth.const (c i)).smul (symbol_growth (vs i)) lemma fourier_add {a b : E → ℂ} (ha : a.HasTemperateGrowth) (hb : b.HasTemperateGrowth) (u : 𝓢'(E,F)) : fourierMultiplierCLM F (a+b) u = fourierMultiplierCLM F a u + fourierMultiplierCLM F b u := by simp only [fourierMultiplierCLM_apply, smulLeftCLM_add ha hb, add_apply, fourierInv_add] omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in lemma sumSymbol_growth (c : ι → ℂ) (vs : ι → List E) : (fun x => ∑ i, (c i • symbol (vs i)) x).HasTemperateGrowth := by apply Function.HasTemperateGrowth.sum intro i hi simpa only [Pi.smul_def, Pi.mul_def, smul_eq_mul] using (Function.HasTemperateGrowth.const (c i)).smul (symbol_growth (vs i)) lemma sumSymbol_operator (c : ι → ℂ) (vs : ι → List E) (u : 𝓢'(E,F)) : fourierMultiplierCLM F (fun x => ∑ i, (c i • symbol (vs i)) x) u = ∑ i, c i • derivative (vs i) u := by have hg : ∀ i ∈ (Finset.univ : Finset ι), (c i • symbol (vs i)).HasTemperateGrowth := by intro i hi simpa only [Pi.smul_def, Pi.mul_def, smul_eq_mul] using (Function.HasTemperateGrowth.const (c i)).smul (symbol_growth (vs i)) rw [fourierMultiplierCLM_sum F hg, sum_apply] apply Finset.sum_congr rfl intro i hi rw [fourierMultiplierCLM_smul (symbol_growth (vs i)), smul_apply, ←derivative_fourier] lemma frozenSymbol_operator (c : ι → ℂ) (vs : ι → List E) (u : 𝓢'(E,F)) : fourierMultiplierCLM F (frozenSymbol c vs) u = u + ∑ i, c i • derivative (vs i) u := by rw [frozenSymbol, fourier_add (Function.HasTemperateGrowth.const (1:ℂ)) (sumSymbol_growth c vs), sumSymbol_operator] congr 1 simp only [fourierMultiplierCLM_const, ContinuousLinearMap.id_apply, one_smul] lemma frozen_equation (c : ι → ℂ) (η χ : 𝓢(E,ℂ)) (a : ι → 𝓢(E,ℂ)) (hη : ∀ x ∈ tsupport χ, (η : E → ℂ) =ᶠ[nhds x] 1) (vs : ι → List E) (u : 𝓢'(E,F)) : fourierMultiplierCLM F (frozenSymbol c vs) (smulLeftCLM F χ u) - ∑ i, smulLeftCLM F (perturbCoefficient c η a i) (fourierMultiplierCLM F (symbol (vs i)) (smulLeftCLM F χ u)) = smulLeftCLM F χ u + operator a vs (smulLeftCLM F χ u) := by simp only [frozenSymbol_operator, ←derivative_fourier, perturb_on_cutoff c η χ a hη vs u, operator_apply, Finset.sum_sub_distrib] abel variable [CompleteSpace F] [Fintype κ] theorem gain_for_localized_operator {s Cq : ℝ} {m : ℕ} (hm : 1 ≤ m) (c : ι → ℂ) (η χ : 𝓢(E,ℂ)) (a : ι → 𝓢(E,ℂ)) (b : κ → 𝓢(E,ℂ)) (vs : ι → List E) (ws : κ → List E) (hvs : ∀ i, (vs i).length = m) (hws : ∀ i, (ws i).length < m) (hη : ∀ x ∈ tsupport χ, (η : E → ℂ) =ᶠ[nhds x] 1) {q : E → ℂ} (hq : q.HasTemperateGrowth) (hCq : 0 ≤ Cq) (hinv : ∀ x, frozenSymbol c vs x * q x = 1) (hbq : ∀ x, LocalPeetre.weight (m:ℝ) x * ‖q x‖ ≤ Cq) (hs : Cq * ∑ i, LocalParametrix.coefficientGauge (s-(m:ℝ)) (perturbCoefficient c η a i) * symbolConstant (vs i) < 1) (ht : Cq * ∑ i, LocalParametrix.coefficientGauge (s+1-(m:ℝ)) (perturbCoefficient c η a i) * symbolConstant (vs i) < 1) {u : 𝓢'(E,F)} (hu : MemSobolev s 2 u) (hP : smulLeftCLM F χ (operator a vs u + operator b ws u) = 0) : MemSobolev (s+1) 2 (smulLeftCLM F χ u) := by have hv := multiply_sobolev hu χ have hlow : MemSobolev (s-(m:ℝ)+1) 2 (smulLeftCLM F χ (operator b ws u)) := by apply multiply_sobolev simpa only [operator_apply] using lower_order_sobolev hu b ws hws have hcomm : MemSobolev (s-(m:ℝ)+1) 2 (∑ i, smulLeftCLM F (a i) (derivative (vs i) (smulLeftCLM F χ u) - smulLeftCLM F χ (derivative (vs i) u))) := by apply sobolev_finset_sum intro i hi have hh := multiply_sobolev (commutator_sobolev hu χ (vs i)) (a i) simpa only [hvs i] using hh have hcut : smulLeftCLM F χ (operator a vs u) = - smulLeftCLM F χ (operator b ws u) := by rw [map_add] at hP exact eq_neg_of_add_eq_zero_left hP have hf : MemSobolev (s-(m:ℝ)+1) 2 (smulLeftCLM F χ u + operator a vs (smulLeftCLM F χ u)) := by rw [operator_cutoff, hcut] apply (hv.mono ?_).add (hlow.neg.add hcomm) have hh : (1:ℝ) ≤ (m:ℝ) := by exact_mod_cast hm linarith apply gain_from_frozen_equation (fun i => symbolConstant (vs i)) hCq (fun i => symbolConstant_nonneg (vs i)) hq (frozenSymbol_growth c vs) hinv hbq (fun i => symbol_growth (vs i)) ?_ (perturbCoefficient c η a) hs ht hv hf (frozen_equation c η χ a hη vs u) intro i x simpa only [LocalPeetre.weight, hvs i] using weighted_symbol_bound (vs i) x end LocalOperator end open Filter Function open scoped SchwartzMap Topology ContDiff noncomputable section namespace LocalSchwartz variable {E : Type*} {F : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [NormedAddCommGroup F] [NormedSpace ℝ F] lemma contDiff_partial_iterated (g : ℝ → E → F) (hg : ContDiff ℝ ∞ (Function.uncurry g)) (n : ℕ) : ContDiff ℝ ∞ (fun p : ℝ × E => iteratedFDeriv ℝ n (g p.1) p.2) := by induction n with | zero => simpa +unfoldPartialApp only [iteratedFDeriv_zero_eq_comp,Function.comp_def, Function.uncurry_def, ContinuousLinearEquiv.coe_coe, LinearIsometryEquiv.coe_toContinuousLinearEquiv] using ((continuousMultilinearCurryFin0 ℝ E F).symm : F →L[ℝ] E [×0]→L[ℝ] F).contDiff.comp hg | succ n ih => have hpar : ContDiff ℝ ∞ (fun q : (ℝ × E) × E => iteratedFDeriv ℝ n (g q.1.1) q.2) := ih.comp (contDiff_fst.fst.prodMk contDiff_snd) have hd := ContDiff.fderiv (f:=fun p : ℝ × E => iteratedFDeriv ℝ n (g p.1)) (g:=fun p : ℝ × E => p.2) hpar (contDiff_snd (n:=∞)) (by simp) simpa +unfoldPartialApp only [iteratedFDeriv_succ_eq_comp_left,Function.comp_def, ContinuousLinearEquiv.coe_coe, LinearIsometryEquiv.coe_toContinuousLinearEquiv] using ((continuousMultilinearCurryLeftEquiv ℝ (fun _ : Fin (n+1) => E) F).symm : (E →L[ℝ] E [×n]→L[ℝ] F) →L[ℝ] E [×(n+1)]→L[ℝ] F).contDiff.comp hd lemma tendsto_zero_of_compact_support {a : ℝ → 𝓢(E,F)} {K : Set E} (hK : IsCompact K) (hsupp : ∀ r, tsupport (a r) ⊆ K) (ha0 : a 0 = 0) (hder : ∀ n, Continuous (fun p : ℝ × E => iteratedFDeriv ℝ n (a p.1) p.2)) : Tendsto a (𝓝 0) (𝓝 0) := by rw [(schwartz_withSeminorms ℝ E F).tendsto_nhds] rintro ⟨k,n⟩ ε hε have hc : Continuous (fun p : ℝ × E => ‖p.2‖^k * ‖iteratedFDeriv ℝ n (a p.1) p.2‖) := (continuous_snd.norm.pow k).mul (hder n).norm have he : ∀ᶠ r in 𝓝 (0:ℝ), ∀ x ∈ K, ‖x‖^k * ‖iteratedFDeriv ℝ n (a r) x‖ < ε/2 := by apply hK.eventually_forall_of_forall_eventually intro x hx have hh : ‖x‖^k * ‖iteratedFDeriv ℝ n (a 0) x‖ < ε/2 := by simp [ha0, half_pos hε] exact hc.continuousAt.eventually (gt_mem_nhds hh) filter_upwards [he] with r hr simp only [sub_zero, SchwartzMap.schwartzSeminormFamily_apply] apply lt_of_le_of_lt (SchwartzMap.seminorm_le_bound ℝ k n (a r) (le_of_lt (half_pos hε)) ?_) (half_lt_self hε) intro x by_cases hx : x ∈ K · exact (hr x hx).le · have hz : iteratedFDeriv ℝ n (a r) x = 0 := by apply Function.notMem_support.mp intro hc exact hx (hsupp r (support_iteratedFDeriv_subset n hc)) simp [hz, (half_pos hε).le] variable [NormedSpace ℂ F] def frozenDifference (χ : 𝓢(E,ℂ)) (hχ : HasCompactSupport χ) (v : E → ℂ) (hv : ContDiff ℝ ∞ v) (x₀ : E) (r : ℝ) : 𝓢(E,ℂ) := (hχ.mul_right (f':=fun x => v (x₀+r • x)-v x₀)).toSchwartzMap (χ.smooth'.mul ((hv.comp (contDiff_const.add (contDiff_id.const_smul r))).sub contDiff_const)) theorem frozenDifference_tendsto (χ : 𝓢(E,ℂ)) (hχ : HasCompactSupport χ) (v : E → ℂ) (hv : ContDiff ℝ ∞ v) (x₀ : E) : Tendsto (frozenDifference χ hχ v hv x₀) (𝓝 0) (𝓝 0) := by apply tendsto_zero_of_compact_support hχ · intro r exact tsupport_mul_subset_left · ext x simp [frozenDifference] · intro n apply (contDiff_partial_iterated (fun r x => χ x * (v (x₀+r • x)-v x₀)) ?_ n).continuous exact (χ.smooth'.comp contDiff_snd).mul ((hv.comp (contDiff_const.add (contDiff_fst.smul contDiff_snd))).sub contDiff_const) end LocalSchwartz namespace LocalOperator open MeasureTheory TemperedDistribution Filter LocalDifferential LocalSchwartz open scoped SchwartzMap Topology ContDiff variable {E : Type*} {F : Type*} {ι : Type*} {κ : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] [NormedAddCommGroup F] [InnerProductSpace ℂ F] [CompleteSpace F] [Fintype ι] [Fintype κ] def frozenCoefficient (η : 𝓢(E,ℂ)) (hη : HasCompactSupport η) (a : E → ℂ) (ha : ContDiff ℝ ∞ a) (x₀ : E) (r : ℝ) : 𝓢(E,ℂ) := a x₀ • η + frozenDifference η hη a ha x₀ r omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in @[simp] lemma frozenCoefficient_apply (η : 𝓢(E,ℂ)) (hη : HasCompactSupport η) (a : E → ℂ) (ha : ContDiff ℝ ∞ a) (x₀ : E) (r : ℝ) (x : E) : frozenCoefficient η hη a ha x₀ r x = η x * a (x₀+r • x) := by change a x₀ * η x + η x * (a (x₀+r • x)-a x₀) = _ ring omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] [Fintype ι] in lemma perturb_frozen_tendsto (η : 𝓢(E,ℂ)) (hη : HasCompactSupport η) (a : ι → E → ℂ) (ha : ∀ i, ContDiff ℝ ∞ (a i)) (x₀ : E) (i : ι) : Tendsto (fun r => perturbCoefficient (fun j => a j x₀) η (fun j => frozenCoefficient η hη (a j) (ha j) x₀ r) i) (𝓝 0) (𝓝 0) := by have he : (fun r => perturbCoefficient (fun j => a j x₀) η (fun j => frozenCoefficient η hη (a j) (ha j) x₀ r) i) = fun r => -frozenDifference η hη (a i) (ha i) x₀ r := by funext r simp [perturbCoefficient, frozenCoefficient] rw [he] simpa using (frozenDifference_tendsto η hη (a i) (ha i) x₀).neg theorem frozen_coefficients_eventually_small (η : 𝓢(E,ℂ)) (hη : HasCompactSupport η) (a : ι → E → ℂ) (ha : ∀ i, ContDiff ℝ ∞ (a i)) (x₀ : E) (s t m Cq : ℝ) (vs : ι → List E) : ∀ᶠ r in 𝓝 (0:ℝ), Cq * ∑ i, LocalParametrix.coefficientGauge (s-m) (perturbCoefficient (fun j => a j x₀) η (fun j => frozenCoefficient η hη (a j) (ha j) x₀ r) i) * symbolConstant (vs i) < 1 ∧ Cq * ∑ i, LocalParametrix.coefficientGauge (t-m) (perturbCoefficient (fun j => a j x₀) η (fun j => frozenCoefficient η hη (a j) (ha j) x₀ r) i) * symbolConstant (vs i) < 1 := by exact LocalParametrix.eventually_small_coefficients (perturb_frozen_tendsto η hη a ha x₀) s t m Cq (fun i => symbolConstant (vs i)) theorem eventually_gain_rescaled {s Cq : ℝ} {m : ℕ} (hm : 1 ≤ m) (η χ : 𝓢(E,ℂ)) (hη : HasCompactSupport η) (a : ι → E → ℂ) (ha : ∀ i, ContDiff ℝ ∞ (a i)) (x₀ : E) (vs : ι → List E) (ws : κ → List E) (hvs : ∀ i, (vs i).length = m) (hws : ∀ i, (ws i).length < m) (hcov : ∀ x ∈ tsupport χ, (η : E → ℂ) =ᶠ[nhds x] 1) {q : E → ℂ} (hq : q.HasTemperateGrowth) (hCq : 0 ≤ Cq) (hinv : ∀ x, frozenSymbol (fun i => a i x₀) vs x * q x = 1) (hbq : ∀ x, LocalPeetre.weight (m:ℝ) x * ‖q x‖ ≤ Cq) : ∀ᶠ r in 𝓝 (0:ℝ), ∀ (b : κ → 𝓢(E,ℂ)) (u : 𝓢'(E,F)), MemSobolev s 2 u → smulLeftCLM F χ (operator (fun i => frozenCoefficient η hη (a i) (ha i) x₀ r) vs u + operator b ws u) = 0 → MemSobolev (s+1) 2 (smulLeftCLM F χ u) := by filter_upwards [frozen_coefficients_eventually_small η hη a ha x₀ s (s+1) m Cq vs] with r hr intro b u hu hP exact gain_for_localized_operator hm (fun i => a i x₀) η χ _ b vs ws hvs hws hcov hq hCq hinv hbq hr.1 hr.2 hu hP end LocalOperator namespace AffineDistribution section open MeasureTheory FourierTransform TemperedDistribution LineDeriv open scoped SchwartzMap Real Topology ENNReal variable {E : Type*} {F : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [NormedAddCommGroup F] [InnerProductSpace ℂ F] def homothety (r : ℝ) (hr : r ≠ 0) : E ≃L[ℝ] E := ContinuousLinearEquiv.smulLeft (Units.mk0 r hr) @[simp] lemma homothety_apply (r : ℝ) (hr : r ≠ 0) (x : E) : homothety (E:=E) r hr x = r • x := rfl def translate (a : E) : 𝓢'(E,F) →L[ℂ] 𝓢'(E,F) := PointwiseConvergenceCLM.precomp F (SchwartzMap.compSubConstCLM ℂ a) @[simp] lemma translate_apply (a : E) (u : 𝓢'(E,F)) (φ : 𝓢(E,ℂ)) : translate a u φ = u (SchwartzMap.compSubConstCLM ℂ a φ) := rfl def jac (r : ℝ) : ℝ := |(r ^ Module.finrank ℝ E)⁻¹| def dilate (r : ℝ) (hr : r ≠ 0) : 𝓢'(E,F) →L[ℂ] 𝓢'(E,F) := (Complex.ofReal (jac (E:=E) r)) • PointwiseConvergenceCLM.precomp F (SchwartzMap.compCLMOfContinuousLinearEquiv ℂ (homothety (E:=E) r hr).symm) @[simp] lemma dilate_apply (r : ℝ) (hr : r ≠ 0) (u : 𝓢'(E,F)) (φ : 𝓢(E,ℂ)) : dilate r hr u φ = (Complex.ofReal (jac (E:=E) r)) • u (SchwartzMap.compCLMOfContinuousLinearEquiv ℂ (homothety (E:=E) r hr).symm φ) := rfl @[simp] lemma homothety_symm_apply (r : ℝ) (hr : r ≠ 0) (x : E) : (homothety (E:=E) r hr).symm x = r⁻¹ • x := rfl lemma dilate_lineDeriv (r : ℝ) (hr : r ≠ 0) (v : E) (u : 𝓢'(E,F)) : ∂_{v} (dilate r hr u) = dilate r hr (∂_{r • v} u) := by ext φ simp only [TemperedDistribution.lineDerivOp_apply_apply, dilate_apply] rw [SchwartzMap.lineDerivOp_compCLMOfContinuousLinearEquiv] simp [homothety_symm_apply, smul_smul, hr] lemma dilate_multiply (r : ℝ) (hr : r ≠ 0) (a : E → ℂ) (ha : a.HasTemperateGrowth) (u : 𝓢'(E,F)) : dilate r hr (TemperedDistribution.smulLeftCLM F a u) = TemperedDistribution.smulLeftCLM F (fun x => a (r • x)) (dilate r hr u) := by have ha' : (fun x : E => a (r • x)).HasTemperateGrowth := by fun_prop ext φ simp only [dilate_apply, TemperedDistribution.smulLeftCLM_apply_apply] congr 2 ext x simp [SchwartzMap.smulLeftCLM_apply_apply ha, SchwartzMap.smulLeftCLM_apply_apply ha', homothety_symm_apply, smul_smul, hr] variable [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] [CompleteSpace F] omit [InnerProductSpace ℂ F] [CompleteSpace F] in lemma memLp_dilate {p : ℝ≥0∞} {f : E → F} (hf : MemLp f p volume) (r : ℝ) (hr : r ≠ 0) : MemLp (fun x => f (r • x)) p volume := by have hh := hf.smul_measure (ENNReal.ofReal_ne_top (r:=jac (E:=E) r)) change MemLp f p (ENNReal.ofReal |(r ^ Module.finrank ℝ E)⁻¹| • volume) at hh rw [←Measure.map_addHaar_smul (E:=E) volume hr] at hh exact hh.comp_of_map (by fun_prop) lemma dilate_Lp {p : ℝ≥0∞} [Fact (1 ≤ p)] (f : Lp F p (volume : Measure E)) (r : ℝ) (hr : r ≠ 0) : dilate r hr (f : 𝓢'(E,F)) = ((memLp_dilate (Lp.memLp f) r hr).toLp (fun x => f (r • x)) : 𝓢'(E,F)) := by ext φ simp only [dilate_apply, Lp.toTemperedDistribution_apply] have hrep : (∫ x, φ x • (((memLp_dilate (Lp.memLp f) r hr).toLp (fun y => f (r • y))) : E → F) x) = ∫ x, φ x • f (r • x) := by apply integral_congr_ae filter_upwards [(memLp_dilate (Lp.memLp f) r hr).coeFn_toLp] with x hx rw [hx] rw [hrep] have he := Measure.integral_comp_smul volume (fun x : E => φ (r⁻¹ • x) • f x) r simp only [inv_smul_smul₀ hr] at he simpa only [jac, Complex.coe_smul, SchwartzMap.compCLMOfContinuousLinearEquiv_apply, Function.comp_apply, homothety_symm_apply] using he.symm omit [CompleteSpace F] in lemma fourier_comp_dilate (f : E → F) (r : ℝ) (hr : r ≠ 0) (ξ : E) : 𝓕 (fun x => f (r • x)) ξ = jac (E:=E) r • (𝓕 f) (r⁻¹ • ξ) := by have he := Measure.integral_comp_smul volume (fun x : E => Real.fourierChar (-inner ℝ x (r⁻¹ • ξ)) • f x) r simpa only [Real.fourier_eq, jac, inner_smul_left, inner_smul_right, conj_trivial, inv_mul_cancel_left₀ hr] using he lemma fourier_schwartz_dilate (φ : 𝓢(E,ℂ)) (r : ℝ) (hr : r ≠ 0) : 𝓕 (SchwartzMap.compCLMOfContinuousLinearEquiv ℂ (homothety (E:=E) r hr) φ) = (Complex.ofReal (jac (E:=E) r)) • SchwartzMap.compCLMOfContinuousLinearEquiv ℂ (homothety (E:=E) r hr).symm (𝓕 φ) := by ext ξ change 𝓕 (fun x => φ (r • x)) ξ = (Complex.ofReal (jac (E:=E) r)) • (𝓕 (φ : E → ℂ)) (r⁻¹ • ξ) simpa only [Complex.coe_smul] using fourier_comp_dilate (φ : E → ℂ) r hr ξ omit [CompleteSpace F] in lemma fourier_dilate_test (r : ℝ) (hr : r ≠ 0) (u : 𝓢'(E,F)) (φ : 𝓢(E,ℂ)) : 𝓕 (dilate r hr u) φ = (𝓕 u) (SchwartzMap.compCLMOfContinuousLinearEquiv ℂ (homothety (E:=E) r hr) φ) := by simp only [TemperedDistribution.fourier_apply, dilate_apply, fourier_schwartz_dilate, map_smul] omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in lemma jac_inv (r : ℝ) : jac (E:=E) r⁻¹ = (jac (E:=E) r)⁻¹ := by simp [jac, inv_pow, abs_inv] omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in lemma jac_ne_zero (r : ℝ) (hr : r ≠ 0) : jac (E:=E) r ≠ 0 := by simp [jac, hr] omit [CompleteSpace F] in lemma fourier_dilate (r : ℝ) (hr : r ≠ 0) (u : 𝓢'(E,F)) : 𝓕 (dilate r hr u) = (Complex.ofReal (jac (E:=E) r)) • dilate r⁻¹ (inv_ne_zero hr) (𝓕 u) := by ext φ have heq : (homothety (E:=E) r⁻¹ (inv_ne_zero hr)).symm = homothety r hr := by ext x; simp have hj : Complex.ofReal (jac (E:=E) r) ≠ 0 := by exact_mod_cast jac_ne_zero (E:=E) r hr simp only [smul_apply, dilate_apply, heq, jac_inv, Complex.ofReal_inv, smul_smul, mul_inv_cancel₀ hj, one_smul, fourier_dilate_test] def scaleWeight (s r : ℝ) (x : E) : ℂ := Complex.ofReal ((1+‖r • x‖^2)^(s/2) * (1+‖x‖^2)^(-s/2)) omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in lemma scaleWeight_growth (s r : ℝ) : (scaleWeight (E:=E) s r).HasTemperateGrowth := by have h1 : (fun x : E => (1+‖r • x‖^2)^(s/2)).HasTemperateGrowth := (Function.hasTemperateGrowth_one_add_norm_sq_rpow E (s/2)).comp (by fun_prop) have h2 := Function.hasTemperateGrowth_one_add_norm_sq_rpow E (-s/2) exact (Complex.ofRealCLM.hasTemperateGrowth).comp (h1.mul h2) omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in lemma scaleWeight_bounded (s r : ℝ) (hr : r ≠ 0) : ∃ C, ∀ x : E, ‖scaleWeight s r x‖ ≤ C := by by_cases hs : 0 ≤ s · refine ⟨(max 1 (r^2))^(s/2), fun x => ?_⟩ have hx : 0 < 1+‖x‖^2 := by positivity have he : 1+‖r • x‖^2 ≤ max 1 (r^2)*(1+‖x‖^2) := by have h1 := le_max_left (1:ℝ) (r^2) have h2 := le_max_right (1:ℝ) (r^2) have hn := sq_nonneg ‖x‖ rw [norm_smul, Real.norm_eq_abs, mul_pow, sq_abs] nlinarith have hq : (1+‖r • x‖^2)/(1+‖x‖^2) ≤ max 1 (r^2) := (div_le_iff₀ hx).mpr he have hp : 0 < 1+‖r • x‖^2 := by positivity rw [scaleWeight, Complex.norm_real, Real.norm_eq_abs, abs_of_nonneg (by positivity), neg_div, Real.rpow_neg hx.le, ←div_eq_mul_inv, ←Real.div_rpow hp.le hx.le] exact Real.rpow_le_rpow (by positivity) hq (by positivity) · refine ⟨(min 1 (r^2))^(s/2), fun x => ?_⟩ have hx : 0 < 1+‖x‖^2 := by positivity have hc : 0 < min 1 (r^2) := lt_min (by norm_num) (sq_pos_of_ne_zero hr) have he : min 1 (r^2)*(1+‖x‖^2) ≤ 1+‖r • x‖^2 := by have h1 := min_le_left (1:ℝ) (r^2) have h2 := min_le_right (1:ℝ) (r^2) have hn := sq_nonneg ‖x‖ rw [norm_smul, Real.norm_eq_abs, mul_pow, sq_abs] nlinarith have hq : min 1 (r^2) ≤ (1+‖r • x‖^2)/(1+‖x‖^2) := (le_div_iff₀ hx).mpr he have hp : 0 < 1+‖r • x‖^2 := by positivity rw [scaleWeight, Complex.norm_real, Real.norm_eq_abs, abs_of_nonneg (by positivity), neg_div, Real.rpow_neg hx.le, ←div_eq_mul_inv, ←Real.div_rpow hp.le hx.le] exact Real.rpow_le_rpow_of_nonpos hc hq (by linarith) omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in lemma scaleWeight_mul (s r : ℝ) (x : E) : Complex.ofReal ((1+‖x‖^2)^(s/2)) * scaleWeight s r x = Complex.ofReal ((1+‖r • x‖^2)^(s/2)) := by have hx : 0 < 1+‖x‖^2 := by positivity simp only [scaleWeight, ←Complex.ofReal_mul] congr 1 rw [neg_div, Real.rpow_neg hx.le] field_simp lemma rescaled_fourier_Lp {s : ℝ} {u : 𝓢'(E,F)} (hu : MemSobolev s 2 u) (r : ℝ) (hr : r ≠ 0) : ∃ f' : Lp F 2 (volume : Measure E), smulLeftCLM F (fun x => Complex.ofReal ((1+‖r • x‖^2)^(s/2))) (𝓕 u) = f' := by obtain ⟨f,hf⟩ := memSobolev_iff_exists_smulLeftCLM_fourier.mp hu obtain ⟨C,hC⟩ := scaleWeight_bounded (E:=E) s r hr let a := scaleWeight (E:=E) s r have ha : a.HasTemperateGrowth := scaleWeight_growth s r let ab := BoundedContinuousFunction.ofNormedAddCommGroup a ha.1.continuous C hC let f' : Lp F 2 (volume : Measure E) := (ab.memLp_top.toLp _ (μ := volume)) • f have hf' : (f' : 𝓢'(E,F)) = smulLeftCLM F (fun x => Complex.ofReal ((1+‖r • x‖^2)^(s/2))) (𝓕 u) := by change (((ab.memLp_top.toLp _ (μ := volume)) • f : Lp F 2 volume) : 𝓢'(E,F)) = _ rw [Lp.toTemperedDistribution_smul_eq (by apply ha), ← hf] change smulLeftCLM F a (smulLeftCLM F (fun x : E => Complex.ofReal ((1+‖x‖^2)^(s/2))) (𝓕 u)) = _ rw [smulLeftCLM_smulLeftCLM_apply (by fun_prop : (fun x : E => Complex.ofReal ((1+‖x‖^2)^(s/2))).HasTemperateGrowth) ha] congr 2 ext x exact scaleWeight_mul s r x exact ⟨f', hf'.symm⟩ theorem memSobolev_dilate {s : ℝ} {u : 𝓢'(E,F)} (hu : MemSobolev s 2 u) (r : ℝ) (hr : r ≠ 0) : MemSobolev s 2 (dilate r hr u) := by obtain ⟨f',hf'⟩ := rescaled_fourier_Lp hu r hr rw [memSobolev_iff_exists_smulLeftCLM_fourier] use (Complex.ofReal (jac (E:=E) r)) • (memLp_dilate (Lp.memLp f') r⁻¹ (inv_ne_zero hr)).toLp (fun x => f' (r⁻¹ • x)) rw [←Lp.toTemperedDistributionCLM_apply, map_smul] change _ = (Complex.ofReal (jac (E:=E) r)) • (((memLp_dilate (Lp.memLp f') r⁻¹ (inv_ne_zero hr)).toLp (fun x => f' (r⁻¹ • x))) : 𝓢'(E,F)) rw [←dilate_Lp f' r⁻¹ (inv_ne_zero hr)] rw [fourier_dilate r hr, map_smul, ←hf'] apply congrArg (fun v : 𝓢'(E,F) => (Complex.ofReal (jac (E:=E) r)) • v) have hw : (fun x : E => Complex.ofReal ((1+‖r • x‖^2)^(s/2))).HasTemperateGrowth := (Complex.ofRealCLM.hasTemperateGrowth).comp ((Function.hasTemperateGrowth_one_add_norm_sq_rpow E (s/2)).comp (by fun_prop)) rw [dilate_multiply r⁻¹ (inv_ne_zero hr) _ hw] congr 2 ext x simp [smul_smul, hr] end open MeasureTheory TemperedDistribution LineDeriv LocalDifferential open scoped SchwartzMap variable {E : Type*} {F : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [NormedAddCommGroup F] [InnerProductSpace ℂ F] lemma test_translate_lineDeriv (a v : E) (φ : 𝓢(E,ℂ)) : ∂_{v} (SchwartzMap.compSubConstCLM ℂ a φ) = SchwartzMap.compSubConstCLM ℂ a (∂_{v} φ) := by ext x rw [SchwartzMap.lineDerivOp_apply_eq_fderiv] have he : (SchwartzMap.compSubConstCLM ℂ a φ : E → ℂ) = fun y => φ (y-a) := rfl rw [he] have hd : HasFDerivAt (fun y : E => y-a) (ContinuousLinearMap.id ℝ E) x := (hasFDerivAt_id x).sub_const a have hd' : HasFDerivAt (fun y => φ (y-a)) (fderiv ℝ φ (x-a)) x := by simpa only [Function.comp_def, ContinuousLinearMap.comp_id] using (φ.differentiableAt.hasFDerivAt.comp x hd) rw [hd'.fderiv] rfl lemma translate_lineDeriv (a v : E) (u : 𝓢'(E,F)) : ∂_{v} (translate a u) = translate a (∂_{v} u) := by ext φ simp only [TemperedDistribution.lineDerivOp_apply_apply, translate_apply, map_neg] rw [test_translate_lineDeriv] lemma translate_derivative (a : E) (vs : List E) (u : 𝓢'(E,F)) : derivative vs (translate a u) = translate a (derivative vs u) := by induction vs with | nil => rfl | cons v vs ih => rw [derivative_cons, ih, translate_lineDeriv, derivative_cons] lemma dilate_derivative (r : ℝ) (hr : r ≠ 0) (vs : List E) (u : 𝓢'(E,F)) : derivative vs (dilate r hr u) = (Complex.ofReal (r^vs.length)) • dilate r hr (derivative vs u) := by induction vs with | nil => simp | cons v vs ih => rw [derivative_cons, ih, lineDerivOp_smul, dilate_lineDeriv, lineDerivOp_left_smul, ContinuousLinearMap.map_smul_of_tower] simp only [derivative_cons, List.length_cons, pow_succ, Complex.ofReal_mul, Complex.coe_smul, smul_smul, mul_comm] rw [←Complex.ofReal_mul, Complex.coe_smul] lemma translate_multiply (x₀ : E) (a : E → ℂ) (ha : a.HasTemperateGrowth) (u : 𝓢'(E,F)) : translate x₀ (smulLeftCLM F a u) = smulLeftCLM F (fun x => a (x+x₀)) (translate x₀ u) := by have ha' : (fun x => a (x+x₀)).HasTemperateGrowth := by fun_prop ext φ simp only [translate_apply, TemperedDistribution.smulLeftCLM_apply_apply] congr 1 ext x simp [SchwartzMap.smulLeftCLM_apply_apply ha, SchwartzMap.smulLeftCLM_apply_apply ha'] @[simp] lemma translate_translate (a b : E) (u : 𝓢'(E,F)) : translate a (translate b u) = translate (a+b) u := by ext φ simp only [translate_apply] congr 1 ext x simp @[simp] lemma translate_zero (u : 𝓢'(E,F)) : translate 0 u = u := by ext φ simp only [translate_apply] congr 1 ext x simp @[simp] lemma dilate_inv_dilate (r : ℝ) (hr : r ≠ 0) (u : 𝓢'(E,F)) : dilate r⁻¹ (inv_ne_zero hr) (dilate r hr u) = u := by ext φ simp only [dilate_apply, smul_smul, ←Complex.ofReal_mul, jac_inv, inv_mul_cancel₀ (jac_ne_zero r hr), Complex.ofReal_one, one_smul] congr 1 ext x simp [homothety_symm_apply, smul_smul, hr] lemma dilate_derivative_inverse (r : ℝ) (hr : r ≠ 0) (vs : List E) (u : 𝓢'(E,F)) : dilate r hr (derivative vs u) = (Complex.ofReal (r⁻¹^vs.length)) • derivative vs (dilate r hr u) := by rw [dilate_derivative r hr, smul_smul, ←Complex.ofReal_mul, ←mul_pow, inv_mul_cancel₀ hr, one_pow, Complex.ofReal_one, one_smul] end AffineDistribution namespace TranslationSobolev open MeasureTheory FourierTransform TemperedDistribution open scoped SchwartzMap Real variable {E : Type*} {F : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] [NormedAddCommGroup F] [InnerProductSpace ℂ F] [CompleteSpace F] def translate (a : E) : 𝓢'(E,F) →L[ℂ] 𝓢'(E,F) := PointwiseConvergenceCLM.precomp F (SchwartzMap.compSubConstCLM ℂ a) omit [CompleteSpace F] in lemma translate_schwartz (a : E) (f : 𝓢(E,F)) : translate a (f : 𝓢'(E,F)) = (SchwartzMap.compSubConstCLM ℂ (-a) f : 𝓢'(E,F)) := by ext φ change (∫ x, φ (x-a) • f x) = ∫ x, φ x • f (x-(-a)) have he := integral_add_right_eq_self (μ:=volume) (fun x : E => φ (x-a) • f x) a simpa only [add_sub_cancel_right, sub_neg_eq_add] using he.symm omit [CompleteSpace F] in lemma norm_fourier_translate (a : E) (f : E → F) (ξ : E) : ‖𝓕 (fun x => f (x+a)) ξ‖ = ‖𝓕 f ξ‖ := by have he := congrFun (VectorFourier.fourierIntegral_comp_add_right Real.fourierChar volume (innerₗ E) f a) ξ have hn := congrArg norm he rw [Circle.norm_smul] at hn convert hn using 1; simp only [Real.fourier_eq, VectorFourier.fourierIntegral, Function.comp_apply, innerₗ_apply_apply] def weighted (s : ℝ) : 𝓢(E,F) →L[ℂ] 𝓢(E,F) := SchwartzMap.smulLeftCLM F (fun x => Complex.ofReal ((1+‖x‖^2)^(s/2))) lemma norm_coordinate (s : ℝ) (f : 𝓢(E,F)) : ‖SobolevModel.coordinate E F s f‖ = ‖(weighted s (𝓕 f)).toLp 2‖ := by simp only [SobolevModel.coordinate, ContinuousLinearMap.comp_apply, SchwartzMap.toLpCLM_apply] rw [← SchwartzMap.norm_fourier_toL2_eq (SobolevModel.schwartzBessel E F s f)] simp only [SobolevModel.schwartzBessel, SchwartzMap.fourierMultiplierCLM_apply, fourier_fourierInv_eq] rfl lemma norm_coordinate_translate_le (s : ℝ) (a : E) (f : 𝓢(E,F)) : ‖SobolevModel.coordinate E F s (SchwartzMap.compSubConstCLM ℂ (-a) f)‖ ≤ 1 * ‖SobolevModel.coordinate E F s f‖ := by rw [norm_coordinate, norm_coordinate] apply Lp.norm_le_mul_norm_of_ae_le_mul filter_upwards [SchwartzMap.coeFn_toLp (weighted s (𝓕 (SchwartzMap.compSubConstCLM ℂ (-a) f))) (p:=2) (μ:=volume), SchwartzMap.coeFn_toLp (weighted s (𝓕 f)) (p:=2) (μ:=volume)] with x hx hy rw [hx,hy] simp only [weighted, SchwartzMap.smulLeftCLM_apply_apply (by fun_prop : (fun x : E => Complex.ofReal ((1+‖x‖^2)^(s/2))).HasTemperateGrowth), norm_smul, one_mul] have hn : ‖𝓕 (SchwartzMap.compSubConstCLM ℂ (-a) f) x‖ = ‖𝓕 f x‖ := by change ‖𝓕 (fun x => f (x-(-a))) x‖ = ‖𝓕 (f : E → F) x‖ simpa only [sub_neg_eq_add] using norm_fourier_translate a (f : E → F) x rw [hn] theorem memSobolev_translate {s : ℝ} {u : 𝓢'(E,F)} (hu : MemSobolev s 2 u) (a : E) : MemSobolev s 2 (translate a u) := by obtain ⟨R,_,hR⟩ := SobolevModel.lift_operator (by norm_num : (0:ℝ) ≤ 1) (translate (F:=F) a) (SchwartzMap.compSubConstCLM ℂ (-a)) (translate_schwartz a) (norm_coordinate_translate_le s a) obtain ⟨f,rfl⟩ := (SobolevModel.memSobolev_iff_range s u).mp hu rw [←hR] exact SobolevModel.embedding_memSobolev s (R f) end TranslationSobolev namespace AffineDistribution section open MeasureTheory TemperedDistribution LineDeriv LocalDifferential open scoped SchwartzMap variable {E : Type*} {F : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [NormedAddCommGroup F] [InnerProductSpace ℂ F] def transform (x₀ : E) (r : ℝ) (hr : r ≠ 0) : 𝓢'(E,F) →L[ℂ] 𝓢'(E,F) := (dilate r hr).comp (translate x₀) lemma transform_multiply (x₀ : E) (r : ℝ) (hr : r ≠ 0) (a : E → ℂ) (ha : a.HasTemperateGrowth) (u : 𝓢'(E,F)) : transform x₀ r hr (smulLeftCLM F a u) = smulLeftCLM F (fun x => a (x₀+r • x)) (transform x₀ r hr u) := by change dilate r hr (translate x₀ (smulLeftCLM F a u)) = _ rw [translate_multiply x₀ a ha, dilate_multiply r hr _ (by fun_prop)] simp only [add_comm] rfl lemma transform_derivative (x₀ : E) (r : ℝ) (hr : r ≠ 0) (vs : List E) (u : 𝓢'(E,F)) : transform x₀ r hr (derivative vs u) = Complex.ofReal (r⁻¹^vs.length) • derivative vs (transform x₀ r hr u) := by change dilate r hr (translate x₀ (derivative vs u)) = _ rw [←translate_derivative, dilate_derivative_inverse] rfl def physicalCutoff (x₀ : E) (r : ℝ) (hr : r ≠ 0) (χ : 𝓢(E,ℂ)) : 𝓢(E,ℂ) := SchwartzMap.compSubConstCLM ℂ x₀ (SchwartzMap.compCLMOfContinuousLinearEquiv ℂ (homothety r hr).symm χ) @[simp] lemma physicalCutoff_apply (x₀ : E) (r : ℝ) (hr : r ≠ 0) (χ : 𝓢(E,ℂ)) (x : E) : physicalCutoff x₀ r hr χ x = χ (r⁻¹ • (x-x₀)) := rfl lemma transform_cutoff (x₀ : E) (r : ℝ) (hr : r ≠ 0) (χ : 𝓢(E,ℂ)) (u : 𝓢'(E,F)) : transform x₀ r hr (smulLeftCLM F (physicalCutoff x₀ r hr χ) u) = smulLeftCLM F χ (transform x₀ r hr u) := by rw [transform_multiply x₀ r hr _ (physicalCutoff x₀ r hr χ).hasTemperateGrowth] congr 2 ext x simp [physicalCutoff_apply, smul_smul, hr] lemma inverse_transform (x₀ : E) (r : ℝ) (hr : r ≠ 0) (u : 𝓢'(E,F)) : translate (-x₀) (dilate r⁻¹ (inv_ne_zero hr) (transform x₀ r hr u)) = u := by change translate (-x₀) (dilate r⁻¹ (inv_ne_zero hr) (dilate r hr (translate x₀ u))) = _ rw [dilate_inv_dilate, translate_translate, neg_add_cancel, translate_zero] variable [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] [CompleteSpace F] lemma memSobolev_transform {s : ℝ} {u : 𝓢'(E,F)} (hu : MemSobolev s 2 u) (x₀ : E) (r : ℝ) (hr : r ≠ 0) : MemSobolev s 2 (transform x₀ r hr u) := by have ht : MemSobolev s 2 (translate x₀ u) := TranslationSobolev.memSobolev_translate hu x₀ exact memSobolev_dilate ht r hr lemma memSobolev_of_transform {s : ℝ} {u : 𝓢'(E,F)} (x₀ : E) (r : ℝ) (hr : r ≠ 0) (hu : MemSobolev s 2 (transform x₀ r hr u)) : MemSobolev s 2 u := by have hs := memSobolev_dilate hu r⁻¹ (inv_ne_zero hr) have ht : MemSobolev s 2 (translate (-x₀) (dilate r⁻¹ (inv_ne_zero hr) (transform x₀ r hr u))) := TranslationSobolev.memSobolev_translate hs (-x₀) rwa [inverse_transform] at ht lemma memSobolev_physicalCutoff {s : ℝ} {u : 𝓢'(E,F)} (x₀ : E) (r : ℝ) (hr : r ≠ 0) (χ : 𝓢(E,ℂ)) (hu : MemSobolev s 2 (smulLeftCLM F χ (transform x₀ r hr u))) : MemSobolev s 2 (smulLeftCLM F (physicalCutoff x₀ r hr χ) u) := by apply memSobolev_of_transform x₀ r hr rwa [transform_cutoff] end open MeasureTheory TemperedDistribution LocalDifferential LocalOperator open scoped SchwartzMap variable {E : Type*} {F : Type*} {ι : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [NormedAddCommGroup F] [InnerProductSpace ℂ F] [Fintype ι] lemma frozen_cutoff (η χ : 𝓢(E,ℂ)) (hη : HasCompactSupport η) (hcov : ∀ x ∈ tsupport χ, η x = 1) (a : 𝓢(E,ℂ)) (x₀ : E) (r : ℝ) (u : 𝓢'(E,F)) : smulLeftCLM F χ (smulLeftCLM F (frozenCoefficient η hη a a.smooth' x₀ r) u) = smulLeftCLM F χ (smulLeftCLM F (fun x => a (x₀+r • x)) u) := by rw [smulLeftCLM_smulLeftCLM_apply (frozenCoefficient η hη a a.smooth' x₀ r).hasTemperateGrowth χ.hasTemperateGrowth, smulLeftCLM_smulLeftCLM_apply (by fun_prop) χ.hasTemperateGrowth] congr 2 ext x by_cases hx : x ∈ tsupport χ · simp [frozenCoefficient_apply, hcov x hx] · simp [image_eq_zero_of_notMem_tsupport hx] lemma power_normalize (r : ℝ) (hr : r ≠ 0) {k m : ℕ} (hkm : k ≤ m) : r^m * r⁻¹^k = r^(m-k) := by have he : m = m-k+k := (Nat.sub_add_cancel hkm).symm conv_lhs => rw [he, pow_add] rw [mul_assoc, ←mul_pow, mul_inv_cancel₀ hr, one_pow, mul_one] lemma transform_term (χ a : 𝓢(E,ℂ)) (x₀ : E) (r : ℝ) (hr : r ≠ 0) (vs : List E) (u : 𝓢'(E,F)) : transform x₀ r hr (smulLeftCLM F (physicalCutoff x₀ r hr χ) (smulLeftCLM F a (derivative vs u))) = Complex.ofReal (r⁻¹^vs.length) • smulLeftCLM F χ (smulLeftCLM F (fun x => a (x₀+r • x)) (derivative vs (transform x₀ r hr u))) := by rw [transform_cutoff, transform_multiply x₀ r hr a a.hasTemperateGrowth, transform_derivative, map_smul, map_smul] lemma normalized_term (η χ : 𝓢(E,ℂ)) (hη : HasCompactSupport η) (hcov : ∀ x ∈ tsupport χ, η x = 1) (a : 𝓢(E,ℂ)) (x₀ : E) (r : ℝ) (hr : r ≠ 0) (vs : List E) {m : ℕ} (hvm : vs.length ≤ m) (u : 𝓢'(E,F)) : Complex.ofReal (r^m) • transform x₀ r hr (smulLeftCLM F (physicalCutoff x₀ r hr χ) (smulLeftCLM F a (derivative vs u))) = smulLeftCLM F χ (smulLeftCLM F (Complex.ofReal (r^(m-vs.length)) • (frozenCoefficient η hη a a.smooth' x₀ r : E → ℂ)) (derivative vs (transform x₀ r hr u))) := by rw [transform_term, smul_smul, ←Complex.ofReal_mul, power_normalize r hr hvm, smulLeftCLM_smul (frozenCoefficient η hη a a.smooth' x₀ r).hasTemperateGrowth, smul_apply, map_smul, frozen_cutoff η χ hη hcov] lemma normalized_operator (η χ : 𝓢(E,ℂ)) (hη : HasCompactSupport η) (hcov : ∀ x ∈ tsupport χ, η x = 1) (a : ι → 𝓢(E,ℂ)) (x₀ : E) (r : ℝ) (hr : r ≠ 0) (vs : ι → List E) {m : ℕ} (hvm : ∀ i, (vs i).length ≤ m) (u : 𝓢'(E,F)) : Complex.ofReal (r^m) • transform x₀ r hr (smulLeftCLM F (physicalCutoff x₀ r hr χ) (operator a vs u)) = smulLeftCLM F χ (operator (fun i => Complex.ofReal (r^(m-(vs i).length)) • frozenCoefficient η hη (a i) (a i).smooth' x₀ r) vs (transform x₀ r hr u)) := by simp only [operator_apply, map_sum, Finset.smul_sum] apply Finset.sum_congr rfl intro i hi exact normalized_term η χ hη hcov (a i) x₀ r hr (vs i) (hvm i) u variable {κ : Type*} [Fintype κ] variable [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] [CompleteSpace F] omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] [CompleteSpace F] in lemma normalized_weak_equation (η χ : 𝓢(E,ℂ)) (hη : HasCompactSupport η) (hcov : ∀ x ∈ tsupport χ, η x = 1) (a : ι → 𝓢(E,ℂ)) (b : κ → 𝓢(E,ℂ)) (x₀ : E) (r : ℝ) (hr : r ≠ 0) (vs : ι → List E) (ws : κ → List E) {m : ℕ} (hvs : ∀ i, (vs i).length = m) (hws : ∀ i, (ws i).length ≤ m) (u : 𝓢'(E,F)) (hP : smulLeftCLM F (physicalCutoff x₀ r hr χ) (operator a vs u + operator b ws u) = 0) : smulLeftCLM F χ (operator (fun i => frozenCoefficient η hη (a i) (a i).smooth' x₀ r) vs (transform x₀ r hr u) + operator (fun i => Complex.ofReal (r^(m-(ws i).length)) • frozenCoefficient η hη (b i) (b i).smooth' x₀ r) ws (transform x₀ r hr u)) = 0 := by have he := congrArg (fun v => Complex.ofReal (r^m) • transform x₀ r hr v) hP simp only [map_add, smul_add, map_zero, smul_zero] at he rw [normalized_operator η χ hη hcov a x₀ r hr vs (fun i => (hvs i).le), normalized_operator η χ hη hcov b x₀ r hr ws hws] at he simpa only [hvs, Nat.sub_self, pow_zero, Complex.ofReal_one, one_smul, map_add] using he theorem eventually_physical_gain {s Cq : ℝ} {m : ℕ} (hm : 1 ≤ m) (η χ : 𝓢(E,ℂ)) (hη : HasCompactSupport η) (a : ι → 𝓢(E,ℂ)) (b : κ → 𝓢(E,ℂ)) (x₀ : E) (vs : ι → List E) (ws : κ → List E) (hvs : ∀ i, (vs i).length = m) (hws : ∀ i, (ws i).length < m) (hcov : ∀ x ∈ tsupport χ, (η : E → ℂ) =ᶠ[nhds x] 1) {q : E → ℂ} (hq : q.HasTemperateGrowth) (hCq : 0 ≤ Cq) (hinv : ∀ x, frozenSymbol (fun i => a i x₀) vs x * q x = 1) (hbq : ∀ x, LocalPeetre.weight (m:ℝ) x * ‖q x‖ ≤ Cq) : ∀ᶠ r in nhds (0:ℝ), ∀ (hr : r ≠ 0) (u : 𝓢'(E,F)), MemSobolev s 2 u → smulLeftCLM F (physicalCutoff x₀ r hr χ) (operator a vs u + operator b ws u) = 0 → MemSobolev (s+1) 2 (smulLeftCLM F (physicalCutoff x₀ r hr χ) u) := by filter_upwards [eventually_gain_rescaled (F:=F) hm η χ hη (fun i => (a i : E → ℂ)) (fun i => (a i).smooth') x₀ vs ws hvs hws hcov hq hCq hinv hbq (s:=s)] with r hgain intro hr u hu hP apply memSobolev_physicalCutoff x₀ r hr apply hgain _ _ (memSobolev_transform hu x₀ r hr) exact normalized_weak_equation η χ hη (fun x hx => (hcov x hx).self_of_nhds) a b x₀ r hr vs ws hvs (fun i => (hws i).le) u hP end AffineDistribution namespace LocalSupport open MeasureTheory TemperedDistribution Filter open scoped SchwartzMap Topology variable {E : Type*} {F : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [NormedAddCommGroup F] [InnerProductSpace ℂ F] lemma supported_multiply_growth (a : E → ℂ) (ha : a.HasTemperateGrowth) (u : 𝓢'(E,F)) : SupportedIn (smulLeftCLM F a u) (tsupport a) := by intro φ hφ rw [smulLeftCLM_apply_apply] have hz : SchwartzMap.smulLeftCLM ℂ a φ = 0 := by ext x rw [SchwartzMap.smulLeftCLM_apply_apply ha] by_cases hx : a x = 0 · simp [hx] · have hpx := (hφ x (subset_tsupport a (Function.mem_support.mpr hx))).self_of_nhds simp [hpx] rw [hz, map_zero] lemma SupportedIn.annihilate {u : 𝓢'(E,F)} {K : Set E} (hu : SupportedIn u K) (a : E → ℂ) (ha : a.HasTemperateGrowth) (hz : ∀ x ∈ K, a =ᶠ[𝓝 x] 0) : smulLeftCLM F a u = 0 := by ext φ rw [smulLeftCLM_apply_apply, zero_apply] apply hu intro x hx filter_upwards [hz x hx] with y hy simp only [SchwartzMap.smulLeftCLM_apply_apply ha, hy, Pi.zero_apply, zero_smul] lemma cutoff_derivative_eq (θ χ : 𝓢(E,ℂ)) (hθ : ∀ x ∈ tsupport χ, (θ : E → ℂ) =ᶠ[𝓝 x] 1) (vs : List E) (u : 𝓢'(E,F)) : smulLeftCLM F χ (LocalDifferential.derivative vs (smulLeftCLM F θ u)) = smulLeftCLM F χ (LocalDifferential.derivative vs u) := by have hg : ((1 : E → ℂ) - (θ : E → ℂ)).HasTemperateGrowth := (Function.HasTemperateGrowth.const (1:ℂ)).sub θ.hasTemperateGrowth have hg1 : (1:E → ℂ).HasTemperateGrowth := Function.HasTemperateGrowth.const (1:ℂ) have he : smulLeftCLM F ((1 : E → ℂ) - (θ : E → ℂ)) u = u - smulLeftCLM F θ u := by rw [smulLeftCLM_sub hg1 θ.hasTemperateGrowth, sub_apply] congr 1 change smulLeftCLM F (fun _ : E => (1:ℂ)) u = u rw [smulLeftCLM_const, one_smul] have hs := (supported_multiply_growth ((1 : E → ℂ)-(θ : E → ℂ)) hg u).derivative vs have hz : ∀ x ∈ tsupport ((1 : E → ℂ)-(θ : E → ℂ)), (χ : E → ℂ) =ᶠ[𝓝 x] 0 := by intro x hx apply notMem_tsupport_iff_eventuallyEq.mp intro hxχ apply (notMem_tsupport_iff_eventuallyEq.mpr ?_) hx filter_upwards [hθ x hxχ] with y hy simp only [Pi.sub_apply, Pi.one_apply, hy, sub_self, Pi.zero_apply] have hh := hs.annihilate χ χ.hasTemperateGrowth hz rw [he, map_sub, map_sub] at hh exact (sub_eq_zero.mp hh).symm end LocalSupport namespace SobolevGerms open MeasureTheory TemperedDistribution LocalDifferential LocalBootstrap open scoped SchwartzMap Topology variable {E : Type*} {F : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] [NormedAddCommGroup F] [InnerProductSpace ℂ F] [CompleteSpace F] def At (s : ℝ) (u : 𝓢'(E,F)) (x : E) : Prop := ∃ χ : 𝓢(E,ℂ), (χ : E → ℂ) =ᶠ[𝓝 x] 1 ∧ MemSobolev s 2 (smulLeftCLM F χ u) def aggregate : List (𝓢(E,ℂ)) → 𝓢(E,ℂ) | [] => 0 | a::as => a + aggregate as - product a (aggregate as) omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in lemma aggregate_eq_one {as : List (𝓢(E,ℂ))} {x : E} (h : ∃ a ∈ as, a x = 1) : aggregate as x = 1 := by induction as with | nil => simp at h | cons a as ih => obtain ⟨b,hb,hbx⟩ := h rcases List.mem_cons.mp hb with rfl | hb · simp [aggregate, hbx] · simp [aggregate, ih ⟨b,hb,hbx⟩] lemma aggregate_sobolev {s : ℝ} {u : 𝓢'(E,F)} (as : List (𝓢(E,ℂ))) (h : ∀ a ∈ as, MemSobolev s 2 (smulLeftCLM F a u)) : MemSobolev s 2 (smulLeftCLM F (aggregate as) u) := by induction as with | nil => change MemSobolev s 2 (smulLeftCLM F (fun _ => 0) u) simp | cons a as ih => have ha := h a (List.mem_cons_self ..) have hb := ih (fun b hb => h b (List.mem_cons_of_mem _ hb)) have hab := multiply_sobolev hb a have he : (product a (aggregate as) : E → ℂ) = (aggregate as : E → ℂ) * a := by ext x simp [mul_comm] change MemSobolev s 2 (smulLeftCLM F ((a : E → ℂ) + (aggregate as : E → ℂ) - (product a (aggregate as) : E → ℂ)) u) rw [smulLeftCLM_sub (a.hasTemperateGrowth.add (aggregate as).hasTemperateGrowth) (product a (aggregate as)).hasTemperateGrowth, sub_apply, smulLeftCLM_add a.hasTemperateGrowth (aggregate as).hasTemperateGrowth, add_apply, he, ←smulLeftCLM_smulLeftCLM_apply (aggregate as).hasTemperateGrowth a.hasTemperateGrowth] exact (ha.add hb).sub hab theorem compact_cutoff {s : ℝ} {u : 𝓢'(E,F)} (hu : ∀ x, At s u x) (φ : 𝓢(E,ℂ)) (hφ : HasCompactSupport φ) : MemSobolev s 2 (smulLeftCLM F φ u) := by classical choose χ hχ hreg using hu let U : E → Set E := fun x => interior {y | χ x y = 1} have hxU : ∀ x, x ∈ U x := by intro x exact mem_interior_iff_mem_nhds.mpr (hχ x) obtain ⟨J,hJ⟩ := hφ.elim_finite_subcover U (fun _ => isOpen_interior) (by intro x hx exact Set.mem_iUnion.mpr ⟨x,hxU x⟩) let as := J.toList.map χ have has : MemSobolev s 2 (smulLeftCLM F (aggregate as) u) := by apply aggregate_sobolev intro a ha obtain ⟨x,hx,rfl⟩ := List.mem_map.mp ha exact hreg x have h1 : ∀ x ∈ tsupport φ, aggregate as x = 1 := by intro x hx obtain ⟨y,hy,hxy⟩ := Set.mem_iUnion₂.mp (hJ hx) apply aggregate_eq_one exact ⟨χ y, List.mem_map.mpr ⟨y, Finset.mem_toList.mpr hy, rfl⟩, (show x ∈ {z | χ y z = 1} from interior_subset hxy)⟩ have he : (aggregate as : E → ℂ) * φ = φ := by ext x by_cases hx : x ∈ tsupport φ · simp [h1 x hx] · simp [image_eq_zero_of_notMem_tsupport hx] have hh := multiply_sobolev has φ rw [smulLeftCLM_smulLeftCLM_apply (aggregate as).hasTemperateGrowth φ.hasTemperateGrowth, he] at hh exact hh end SobolevGerms namespace LocalBumps open MeasureTheory Filter Metric open scoped SchwartzMap Topology ContDiff variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] def complexBump (f : ContDiffBump (0:E)) : 𝓢(E,ℂ) := (f.hasCompactSupport.comp_left (by simp : Complex.ofReal (0:ℝ) = 0)).toSchwartzMap (Complex.ofRealCLM.contDiff.comp f.contDiff) @[simp] lemma complexBump_apply (f : ContDiffBump (0:E)) (x : E) : complexBump f x = Complex.ofReal (f x) := rfl lemma complexBump_tsupport (f : ContDiffBump (0:E)) : tsupport (complexBump f) = closedBall 0 f.rOut := by change tsupport (Complex.ofReal ∘ (f : E → ℝ)) = _ rw [tsupport_comp_eq (by simp), f.tsupport_eq] lemma complexBump_compact (f : ContDiffBump (0:E)) : HasCompactSupport (complexBump f) := by rw [HasCompactSupport, complexBump_tsupport] exact isCompact_closedBall _ _ lemma complexBump_one (f : ContDiffBump (0:E)) {x : E} (hx : x ∈ ball 0 f.rIn) : (complexBump f : E → ℂ) =ᶠ[𝓝 x] 1 := by filter_upwards [f.eventuallyEq_one_of_mem_ball hx] with y hy simp only [complexBump_apply, hy, Pi.one_apply, Complex.ofReal_one] def innerBump : ContDiffBump (0:E) := ⟨1/2, 1, by norm_num, by norm_num⟩ def outerBump : ContDiffBump (0:E) := ⟨2, 3, by norm_num, by norm_num⟩ def inner : 𝓢(E,ℂ) := complexBump innerBump def outer : 𝓢(E,ℂ) := complexBump outerBump lemma inner_compact : HasCompactSupport (inner : 𝓢(E,ℂ)) := complexBump_compact _ lemma outer_compact : HasCompactSupport (outer : 𝓢(E,ℂ)) := complexBump_compact _ lemma inner_tsupport : tsupport (inner : 𝓢(E,ℂ)) = closedBall 0 1 := complexBump_tsupport _ lemma inner_one : (inner : E → ℂ) =ᶠ[𝓝 0] 1 := complexBump_one _ (mem_ball_self (by norm_num : (0:ℝ) < 1/2)) lemma outer_covers_inner (x : E) (hx : x ∈ tsupport (inner : 𝓢(E,ℂ))) : (outer : E → ℂ) =ᶠ[𝓝 x] 1 := by apply complexBump_one rw [inner_tsupport, mem_closedBall, dist_zero_right] at hx rw [mem_ball, dist_zero_right] change ‖x‖ < 2 linarith end LocalBumps namespace AffineDistribution open MeasureTheory TemperedDistribution Filter Metric open scoped SchwartzMap Topology variable {E : Type*} {F : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [NormedAddCommGroup F] [InnerProductSpace ℂ F] omit [FiniteDimensional ℝ E] in lemma physicalCutoff_one (x₀ : E) (r : ℝ) (hr : r ≠ 0) (χ : 𝓢(E,ℂ)) (hχ : (χ : E → ℂ) =ᶠ[𝓝 0] 1) : (physicalCutoff x₀ r hr χ : E → ℂ) =ᶠ[𝓝 x₀] 1 := by have ht : Tendsto (fun x : E => r⁻¹ • (x-x₀)) (𝓝 x₀) (𝓝 0) := by simpa using (show Continuous (fun x : E => r⁻¹ • (x-x₀)) by fun_prop).tendsto x₀ filter_upwards [hχ.comp_tendsto ht] with x hx exact hx lemma physical_inner_bound (x₀ : E) (r : ℝ) (hr : r ≠ 0) (x : E) (hx : x ∈ tsupport (physicalCutoff x₀ r hr (LocalBumps.inner : 𝓢(E,ℂ)))) : dist x x₀ ≤ |r| := by have hx' : r⁻¹ • (x-x₀) ∈ tsupport (LocalBumps.inner : 𝓢(E,ℂ)) := tsupport_comp_subset_preimage (f:=fun y : E => r⁻¹ • (y-x₀)) (LocalBumps.inner : E → ℂ) (by fun_prop) hx rw [LocalBumps.inner_tsupport, mem_closedBall, dist_zero_right] at hx' have hid : x-x₀ = r • (r⁻¹ • (x-x₀)) := by simp [smul_smul, hr] calc dist x x₀ = ‖x-x₀‖ := dist_eq_norm _ _ _ = |r| * ‖r⁻¹ • (x-x₀)‖ := by conv_lhs => rw [hid] rw [norm_smul, Real.norm_eq_abs] _ ≤ |r| * 1 := mul_le_mul_of_nonneg_left hx' (abs_nonneg _) _ = |r| := mul_one _ lemma eventually_physical_covered (x₀ : E) (θ : 𝓢(E,ℂ)) (hθ : (θ : E → ℂ) =ᶠ[𝓝 x₀] 1) : ∀ᶠ r in 𝓝 (0:ℝ), ∀ (hr : r ≠ 0) x, x ∈ tsupport (physicalCutoff x₀ r hr (LocalBumps.inner : 𝓢(E,ℂ))) → (θ : E → ℂ) =ᶠ[𝓝 x] 1 := by obtain ⟨ε,hε,hball⟩ := Metric.mem_nhds_iff.mp hθ have he : ∀ᶠ r in 𝓝 (0:ℝ), |r| < ε := (isOpen_lt continuous_abs continuous_const).mem_nhds (by simpa using hε) filter_upwards [he] with r hr intro hr0 x hx have hxball : x ∈ ball x₀ ε := lt_of_le_of_lt (physical_inner_bound x₀ r hr0 x hx) hr exact Filter.mem_of_superset (isOpen_ball.mem_nhds hxball) hball end AffineDistribution namespace LocalSupport open MeasureTheory TemperedDistribution LocalDifferential LocalOperator open scoped SchwartzMap Topology variable {E : Type*} {F : Type*} {ι : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [NormedAddCommGroup F] [InnerProductSpace ℂ F] [Fintype ι] lemma cutoff_operator_eq (θ χ : 𝓢(E,ℂ)) (hθ : ∀ x ∈ tsupport χ, (θ : E → ℂ) =ᶠ[𝓝 x] 1) (a : ι → 𝓢(E,ℂ)) (vs : ι → List E) (u : 𝓢'(E,F)) : smulLeftCLM F χ (operator a vs (smulLeftCLM F θ u)) = smulLeftCLM F χ (operator a vs u) := by simp only [operator_apply, map_sum] apply Finset.sum_congr rfl intro i hi rw [multiply_comm χ (a i), cutoff_derivative_eq θ χ hθ, multiply_comm (a i) χ] lemma cutoff_multiply_eq (θ χ : 𝓢(E,ℂ)) (hθ : ∀ x ∈ tsupport χ, (θ : E → ℂ) =ᶠ[𝓝 x] 1) (u : 𝓢'(E,F)) : smulLeftCLM F χ (smulLeftCLM F θ u) = smulLeftCLM F χ u := by rw [multiply_comm χ θ] exact (supported_multiply χ u).cutoff_identity θ hθ lemma cutoff_zero (θ χ : 𝓢(E,ℂ)) (hθ : ∀ x ∈ tsupport χ, (θ : E → ℂ) =ᶠ[𝓝 x] 1) (u : 𝓢'(E,F)) (hu : smulLeftCLM F θ u = 0) : smulLeftCLM F χ u = 0 := by rw [←cutoff_multiply_eq θ χ hθ u, hu, map_zero] end LocalSupport namespace LocalElliptic open MeasureTheory TemperedDistribution LocalDifferential LocalOperator AffineDistribution open LocalSupport Filter Metric open scoped SchwartzMap Topology variable {E : Type*} {F : Type*} {ι : Type*} {κ : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] [NormedAddCommGroup F] [InnerProductSpace ℂ F] [CompleteSpace F] [Fintype ι] [Fintype κ] theorem gain_at {s Cq : ℝ} {m : ℕ} (hm : 1 ≤ m) (a : ι → 𝓢(E,ℂ)) (b : κ → 𝓢(E,ℂ)) (x₀ : E) (vs : ι → List E) (ws : κ → List E) (hvs : ∀ i, (vs i).length = m) (hws : ∀ i, (ws i).length < m) {q : E → ℂ} (hq : q.HasTemperateGrowth) (hCq : 0 ≤ Cq) (hinv : ∀ x, frozenSymbol (fun i => a i x₀) vs x * q x = 1) (hbq : ∀ x, LocalPeetre.weight (m:ℝ) x * ‖q x‖ ≤ Cq) {u : 𝓢'(E,F)} (hu : SobolevGerms.At s u x₀) (hP : ∃ ψ : 𝓢(E,ℂ), (ψ : E → ℂ) =ᶠ[𝓝 x₀] 1 ∧ smulLeftCLM F ψ (operator a vs u + operator b ws u) = 0) : SobolevGerms.At (s+1) u x₀ := by obtain ⟨θ,hθ,hreg⟩ := hu obtain ⟨ψ,hψ,hzero⟩ := hP have hev := eventually_physical_gain hm LocalBumps.outer LocalBumps.inner LocalBumps.outer_compact a b x₀ vs ws hvs hws LocalBumps.outer_covers_inner hq hCq hinv hbq (s:=s) (F:=F) have hθv := eventually_physical_covered x₀ θ hθ have hψv := eventually_physical_covered x₀ ψ hψ obtain ⟨δ,hδ,hδball⟩ := Metric.mem_nhds_iff.mp ((hev.and hθv).and hψv) have hd : 0 < δ/2 := half_pos hδ have hr : δ/2 ≠ 0 := ne_of_gt hd have hmem : δ/2 ∈ ball (0:ℝ) δ := by rw [mem_ball, dist_zero_right, Real.norm_eq_abs, abs_of_pos hd] exact half_lt_self hδ have hh := hδball hmem let χ := physicalCutoff x₀ (δ/2) hr (LocalBumps.inner : 𝓢(E,ℂ)) have hθχ : ∀ x ∈ tsupport χ, (θ : E → ℂ) =ᶠ[𝓝 x] 1 := hh.1.2 hr have hψχ : ∀ x ∈ tsupport χ, (ψ : E → ℂ) =ᶠ[𝓝 x] 1 := hh.2 hr refine ⟨χ, physicalCutoff_one x₀ (δ/2) hr _ LocalBumps.inner_one, ?_⟩ have heq : smulLeftCLM F χ (operator a vs (smulLeftCLM F θ u) + operator b ws (smulLeftCLM F θ u)) = 0 := by rw [map_add, cutoff_operator_eq θ χ hθχ, cutoff_operator_eq θ χ hθχ, ←map_add] exact cutoff_zero ψ χ hψχ _ hzero have hgain := hh.1.1 hr _ hreg heq rwa [cutoff_multiply_eq θ χ hθχ] at hgain end LocalElliptic namespace SobolevGerms open MeasureTheory TemperedDistribution LocalDifferential LocalBootstrap open scoped SchwartzMap Topology variable {E : Type*} {F : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] [NormedAddCommGroup F] [InnerProductSpace ℂ F] [CompleteSpace F] theorem compact_cutoff_on {s : ℝ} {u : 𝓢'(E,F)} (φ : 𝓢(E,ℂ)) (hφ : HasCompactSupport φ) (hu : ∀ x ∈ tsupport φ, At s u x) : MemSobolev s 2 (smulLeftCLM F φ u) := by classical have hu' : ∀ x : tsupport φ, At s u x := fun x => hu x x.property choose χ hχ hreg using hu' let U : tsupport φ → Set E := fun x => interior {y | χ x y = 1} have hxU : ∀ x : tsupport φ, (x:E) ∈ U x := by intro x exact mem_interior_iff_mem_nhds.mpr (hχ x) obtain ⟨J,hJ⟩ := hφ.elim_finite_subcover U (fun _ => isOpen_interior) (by intro x hx exact Set.mem_iUnion.mpr ⟨⟨x,hx⟩,hxU ⟨x,hx⟩⟩) let as := J.toList.map χ have has : MemSobolev s 2 (smulLeftCLM F (aggregate as) u) := by apply aggregate_sobolev intro a ha obtain ⟨x,hx,rfl⟩ := List.mem_map.mp ha exact hreg x have h1 : ∀ x ∈ tsupport φ, aggregate as x = 1 := by intro x hx obtain ⟨y,hy,hxy⟩ := Set.mem_iUnion₂.mp (hJ hx) apply aggregate_eq_one exact ⟨χ y, List.mem_map.mpr ⟨y, Finset.mem_toList.mpr hy, rfl⟩, (show x ∈ {z | χ y z = 1} from interior_subset hxy)⟩ have he : (aggregate as : E → ℂ) * φ = φ := by ext x by_cases hx : x ∈ tsupport φ · simp [h1 x hx] · simp [image_eq_zero_of_notMem_tsupport hx] have hh := multiply_sobolev has φ rw [smulLeftCLM_smulLeftCLM_apply (aggregate as).hasTemperateGrowth φ.hasTemperateGrowth, he] at hh exact hh end SobolevGerms end open MeasureTheory FourierTransform TemperedDistribution open scoped SchwartzMap Topology ContDiff noncomputable section namespace SobolevSmooth variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] lemma weighted_L1_of_distribution_eq (f g : Lp ℂ 1 (volume : Measure E)) {w : E → ℂ} (hw : w.HasTemperateGrowth) (heq : TemperedDistribution.smulLeftCLM ℂ w (f : 𝓢'(E,ℂ)) = (g : 𝓢'(E,ℂ))) : Integrable (fun x => w x * f x) := by have hae : (fun x => w x * f x) =ᵐ[volume] g := by apply ae_eq_of_integral_contDiff_smul_eq ((Lp.memLp f).locallyIntegrable (by norm_num) |>.continuous_mul hw.1.continuous) ((Lp.memLp g).locallyIntegrable (by norm_num)) intro φ hφ hφc let Φ : 𝓢(E,ℂ) := (hφc.comp_left (show Complex.ofRealCLM 0=0 by simp)).toSchwartzMap (Complex.ofRealCLM.contDiff.comp hφ) have hh := congrArg (fun T : 𝓢'(E,ℂ) => T Φ) heq simp only [TemperedDistribution.smulLeftCLM_apply_apply, Lp.toTemperedDistribution_apply] at hh convert hh using 1 <;> apply integral_congr_ae <;> filter_upwards [] with x · rw [SchwartzMap.smulLeftCLM_apply_apply hw] simp [Φ, smul_eq_mul, mul_assoc, mul_left_comm] · simp [Φ] exact (memLp_one_iff_integrable.mp (Lp.memLp g)).congr hae.symm theorem exists_fourier_all_moments {u : 𝓢'(E,ℂ)} (hu : ∀ n : ℕ, MemSobolev (n:ℝ) 2 u) : ∃ f : Lp ℂ 1 (volume : Measure E), 𝓕 u = (f : 𝓢'(E,ℂ)) ∧ ∀ n : ℕ, Integrable (fun x => ‖x‖^n * ‖f x‖) := by let d := Module.finrank ℝ E + 1 have hd : (Module.finrank ℝ E : ℝ) < 2*(d:ℝ) := by dsimp [d]; norm_cast; omega obtain ⟨f,hf⟩ := (hu d).fourier_memL1 hd refine ⟨f,hf,?_⟩ intro n have hnu : MemSobolev (d:ℝ) 2 (besselPotential E ℂ (n:ℝ) u) := by apply memSobolev_besselPotential_iff.mpr simpa only [Nat.cast_add] using hu (n+d) obtain ⟨g,hg⟩ := hnu.fourier_memL1 hd rw [fourier_besselPotential_eq_smulLeftCLM_fourier_apply,hf] at hg have hi := weighted_L1_of_distribution_eq f g (by fun_prop) hg apply Integrable.mono' hi.norm (by fun_prop : AEStronglyMeasurable (fun x => ‖x‖^n * ‖f x‖) volume) filter_upwards [] with x rw [Real.norm_eq_abs, abs_of_nonneg (by positivity), norm_mul, Complex.norm_real, Real.norm_eq_abs, abs_of_nonneg (by positivity)] apply mul_le_mul_of_nonneg_right _ (norm_nonneg _) have hr : ‖x‖^n = (‖x‖^2)^((n:ℝ)/2) := by rw [← Real.rpow_natCast ‖x‖ n, ← Real.rpow_natCast ‖x‖ 2, ← Real.rpow_mul (norm_nonneg x)] congr 1; ring rw [hr] exact Real.rpow_le_rpow (sq_nonneg _) (by linarith) (by positivity) theorem exists_smooth_fourier_representative {u : 𝓢'(E,ℂ)} (hu : ∀ n : ℕ, MemSobolev (n:ℝ) 2 u) : ∃ f : Lp ℂ 1 (volume : Measure E), 𝓕 u = (f : 𝓢'(E,ℂ)) ∧ ContDiff ℝ ∞ (𝓕 (f : E → ℂ)) := by obtain ⟨f,hf,hm⟩ := exists_fourier_all_moments hu exact ⟨f,hf, Real.contDiff_fourier (fun n _ => hm n)⟩ theorem smooth_representative {u : 𝓢'(E,ℂ)} (hu : ∀ n : ℕ, MemSobolev (n:ℝ) 2 u) : ∃ v : E → ℂ, ContDiff ℝ ∞ v ∧ ∀ φ : 𝓢(E,ℂ), u φ = ∫ x, φ x * v x := by obtain ⟨f,hf,hm⟩ := exists_fourier_all_moments hu refine ⟨𝓕⁻ (f : E → ℂ), ?_, ?_⟩ · have hd : ContDiff ℝ ∞ (𝓕 (f : E → ℂ)) := Real.contDiff_fourier (fun n _ => hm n) have heq : 𝓕⁻ (f : E → ℂ) = (fun x => 𝓕 (f : E → ℂ) (-x)) := funext (Real.fourierInv_eq_fourier_neg _) rw [heq] exact hd.comp contDiff_id.neg · intro φ calc u φ = (𝓕⁻ (𝓕 u)) φ := by rw [fourierInv_fourier_eq] _ = ∫ x, (𝓕⁻ φ) x * f x := by rw [hf, TemperedDistribution.fourierInv_apply, Lp.toTemperedDistribution_apply] simp only [smul_eq_mul] _ = ∫ x, φ x * (𝓕⁻ (f : E → ℂ)) x := by simpa [SchwartzMap.fourierInv_coe, smul_eq_mul, FourierTransformInv.fourierInv, VectorFourier.fourierIntegral, real_inner_comm, SchwartzMap.fourier_coe, Real.fourier_eq] using! (VectorFourier.integral_fourierIntegral_smul_eq_flip (L := -innerₗ E) (μ := volume) (ν := volume) Real.continuous_fourierChar continuous_inner.neg φ.integrable (memLp_one_iff_integrable.mp (Lp.memLp f))) all_goals rfl end SobolevSmooth namespace LocalElliptic open MeasureTheory TemperedDistribution LocalDifferential LocalOperator AffineDistribution open LocalSupport Filter Metric open scoped SchwartzMap Topology variable {E : Type*} {F : Type*} {ι : Type*} {κ : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] [NormedAddCommGroup F] [InnerProductSpace ℂ F] [CompleteSpace F] [Fintype ι] [Fintype κ] theorem all_orders_at {Cq : ℝ} {m : ℕ} (hm : 1 ≤ m) (a : ι → 𝓢(E,ℂ)) (b : κ → 𝓢(E,ℂ)) (x₀ : E) (vs : ι → List E) (ws : κ → List E) (hvs : ∀ i, (vs i).length = m) (hws : ∀ i, (ws i).length < m) {q : E → ℂ} (hq : q.HasTemperateGrowth) (hCq : 0 ≤ Cq) (hinv : ∀ x, frozenSymbol (fun i => a i x₀) vs x * q x = 1) (hbq : ∀ x, LocalPeetre.weight (m:ℝ) x * ‖q x‖ ≤ Cq) {u : 𝓢'(E,F)} (hu : SobolevGerms.At 0 u x₀) (hP : ∃ ψ : 𝓢(E,ℂ), (ψ : E → ℂ) =ᶠ[𝓝 x₀] 1 ∧ smulLeftCLM F ψ (operator a vs u + operator b ws u) = 0) : ∀ n : ℕ, SobolevGerms.At (n:ℝ) u x₀ := by intro n induction n with | zero => simpa only [Nat.cast_zero] using hu | succ n ih => simpa only [Nat.cast_add, Nat.cast_one] using gain_at hm a b x₀ vs ws hvs hws hq hCq hinv hbq ih hP lemma at_of_memSobolev {s : ℝ} {u : 𝓢'(E,F)} (hu : MemSobolev s 2 u) (x₀ : E) : SobolevGerms.At s u x₀ := by refine ⟨physicalCutoff x₀ 1 one_ne_zero LocalBumps.inner, physicalCutoff_one x₀ 1 one_ne_zero _ LocalBumps.inner_one, ?_⟩ exact LocalBootstrap.multiply_sobolev hu _ omit [MeasurableSpace E] [BorelSpace E] in lemma physical_inner_compact (x₀ : E) (r : ℝ) (hr : r ≠ 0) : HasCompactSupport (physicalCutoff x₀ r hr (LocalBumps.inner : 𝓢(E,ℂ))) := by apply (isCompact_closedBall x₀ |r|).of_isClosed_subset (isClosed_tsupport _) intro x hx exact physical_inner_bound x₀ r hr x hx theorem local_smooth_cutoffs {u : 𝓢'(E,ℂ)} (hu : ∀ n : ℕ, ∀ x, SobolevGerms.At (n:ℝ) u x) (x₀ : E) : ∃ χ : 𝓢(E,ℂ), (χ : E → ℂ) =ᶠ[𝓝 x₀] 1 ∧ ∃ v : E → ℂ, ContDiff ℝ ∞ v ∧ ∀ φ : 𝓢(E,ℂ), smulLeftCLM ℂ χ u φ = ∫ x, φ x * v x := by let χ := physicalCutoff x₀ 1 one_ne_zero (LocalBumps.inner : 𝓢(E,ℂ)) refine ⟨χ, physicalCutoff_one x₀ 1 one_ne_zero _ LocalBumps.inner_one, ?_⟩ exact SobolevSmooth.smooth_representative (fun n => SobolevGerms.compact_cutoff (hu n) χ (physical_inner_compact x₀ 1 one_ne_zero)) end LocalElliptic namespace SmoothPatching open MeasureTheory TemperedDistribution Filter open scoped SchwartzMap Topology ContDiff variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] lemma cutoff_rep_ae (f : Lp ℂ 2 (volume : Measure E)) (χ : 𝓢(E,ℂ)) (v : E → ℂ) (hv : Continuous v) (hrep : ∀ φ : 𝓢(E,ℂ), smulLeftCLM ℂ χ (f : 𝓢'(E,ℂ)) φ = ∫ x, φ x * v x) : (fun x => χ x * f x) =ᵐ[volume] v := by apply ae_eq_of_integral_contDiff_smul_eq ((Lp.memLp f).locallyIntegrable (by norm_num) |>.continuous_mul χ.continuous) hv.locallyIntegrable intro φ hφ hφc let Φ : 𝓢(E,ℂ) := (hφc.comp_left (show Complex.ofRealCLM 0=0 by simp)).toSchwartzMap (Complex.ofRealCLM.contDiff.comp hφ) have he := hrep Φ rw [smulLeftCLM_apply_apply, Lp.toTemperedDistribution_apply] at he convert he using 1 <;> apply integral_congr_ae <;> filter_upwards [] with x · rw [SchwartzMap.smulLeftCLM_apply_apply χ.hasTemperateGrowth] simp [Φ, smul_eq_mul, mul_assoc, mul_left_comm] · simp [Φ] theorem patch (f : Lp ℂ 2 (volume : Measure E)) (hlocal : ∀ x₀ : E, ∃ χ : 𝓢(E,ℂ), (χ : E → ℂ) =ᶠ[𝓝 x₀] 1 ∧ ∃ v : E → ℂ, ContDiff ℝ ∞ v ∧ ∀ φ : 𝓢(E,ℂ), smulLeftCLM ℂ χ (f : 𝓢'(E,ℂ)) φ = ∫ x, φ x * v x) : ∃ w : E → ℂ, ContDiff ℝ ∞ w ∧ (f : E → ℂ) =ᵐ[volume] w := by classical choose χ hχ v hv hrep using hlocal have hae (x : E) : (fun y => χ x y * f y) =ᵐ[volume] v x := cutoff_rep_ae f (χ x) (v x) (hv x).continuous (hrep x) have hcompat (x y : E) : (fun z => χ y z * v x z) = (fun z => χ x z * v y z) := by apply Measure.eq_of_ae_eq (μ := volume) _ ((χ y).continuous.mul (hv x).continuous) ((χ x).continuous.mul (hv y).continuous) filter_upwards [hae x, hae y] with z hz₁ hz₂ simp only [Pi.mul_apply] rw [←hz₁, ←hz₂] ring let w : E → ℂ := fun x => v x x have hpoint (x y : E) (hy : χ x y = 1) : w y = v x y := by have he := congrFun (hcompat x y) y have hyy : χ y y = 1 := (hχ y).self_of_nhds simpa only [hy,hyy,one_mul] using he.symm have hgerm (x : E) : w =ᶠ[𝓝 x] v x := by filter_upwards [hχ x] with y hy exact hpoint x y hy have hw : ContDiff ℝ ∞ w := by rw [contDiff_iff_contDiffAt] intro x exact (hv x).contDiffAt.congr_of_eventuallyEq (hgerm x) refine ⟨w,hw,?_⟩ let U : E → Set E := fun x => interior {y | χ x y = 1} have hxU (x : E) : x ∈ U x := mem_interior_iff_mem_nhds.mpr (hχ x) obtain ⟨S,hS,hcover⟩ := isLindelof_univ.elim_countable_subcover U (fun _ => isOpen_interior) (by intro x hx exact Set.mem_iUnion.mpr ⟨x,hxU x⟩) let : Countable S := hS.to_subtype have hloc (x : E) : ∀ᵐ y ∂volume, y ∈ U x → f y = w y := by filter_upwards [hae x] with y hy intro hyU have hχy : χ x y = 1 := (show y ∈ {z | χ x z = 1} from interior_subset hyU) rw [hχy,one_mul] at hy exact hy.trans (hpoint x y hχy).symm have hall : ∀ᵐ y ∂volume, ∀ x : S, y ∈ U x → f y = w y := (ae_all_iff).mpr (fun x => hloc x) filter_upwards [hall] with y hy obtain ⟨x,hxS,hxy⟩ := Set.mem_iUnion₂.mp (hcover (Set.mem_univ y)) exact hy ⟨x,hxS⟩ hxy end SmoothPatching namespace LocalElliptic open MeasureTheory TemperedDistribution LocalDifferential LocalOperator open scoped SchwartzMap Topology variable {E : Type*} {ι : Type*} {κ : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] [Fintype ι] [Fintype κ] theorem smooth_of_elliptic_Lp {m : ℕ} (hm : 1 ≤ m) (a : E → ι → 𝓢(E,ℂ)) (b : E → κ → 𝓢(E,ℂ)) (vs : ι → List E) (ws : κ → List E) (hvs : ∀ i, (vs i).length = m) (hws : ∀ i, (ws i).length < m) (q : E → E → ℂ) (Cq : E → ℝ) (hq : ∀ x₀, (q x₀).HasTemperateGrowth) (hCq : ∀ x₀, 0 ≤ Cq x₀) (hinv : ∀ x₀ x, frozenSymbol (fun i => a x₀ i x₀) vs x * q x₀ x = 1) (hbq : ∀ x₀ x, LocalPeetre.weight (m:ℝ) x * ‖q x₀ x‖ ≤ Cq x₀) (f : Lp ℂ 2 (volume : Measure E)) (hP : ∀ x₀, ∃ ψ : 𝓢(E,ℂ), (ψ : E → ℂ) =ᶠ[𝓝 x₀] 1 ∧ smulLeftCLM ℂ ψ (operator (a x₀) vs (f : 𝓢'(E,ℂ)) + operator (b x₀) ws (f : 𝓢'(E,ℂ))) = 0) : ∃ w : E → ℂ, ContDiff ℝ ∞ w ∧ (f : E → ℂ) =ᵐ[volume] w := by apply SmoothPatching.patch f apply local_smooth_cutoffs intro n x₀ have hf : MemSobolev 0 2 (f : 𝓢'(E,ℂ)) := memSobolev_zero_iff.mpr ⟨f,rfl⟩ exact all_orders_at hm (a x₀) (b x₀) x₀ vs ws hvs hws (hq x₀) (hCq x₀) (hinv x₀) (hbq x₀) (at_of_memSobolev hf x₀) (hP x₀) n end LocalElliptic namespace DistributionExpansion section open MeasureTheory TemperedDistribution LocalDifferential LineDeriv open scoped SchwartzMap variable {E : Type*} {F : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [NormedAddCommGroup F] [InnerProductSpace ℂ F] abbrev Term (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ℝ E] := 𝓢(E,ℂ) × List E def evalTerm (t : Term E) (u : 𝓢'(E,F)) : 𝓢'(E,F) := smulLeftCLM F t.1 (derivative t.2 u) def eval (ts : List (Term E)) (u : 𝓢'(E,F)) : 𝓢'(E,F) := (ts.map (fun t => evalTerm t u)).sum @[simp] lemma eval_nil (u : 𝓢'(E,F)) : eval [] u = 0 := rfl @[simp] lemma eval_cons (t : Term E) (ts : List (Term E)) (u : 𝓢'(E,F)) : eval (t::ts) u = evalTerm t u + eval ts u := rfl lemma derivative_add (v : E) (u w : 𝓢'(E,F)) : ∂_{v} (u+w) = ∂_{v} u + ∂_{v} w := map_add (lineDerivOpCLM ℂ 𝓢'(E,F) v) u w def differentiate (v : E) (ts : List (Term E)) : List (Term E) := ts.flatMap (fun t => [(∂_{v} t.1,t.2),(t.1,v::t.2)]) lemma eval_differentiate (v : E) (ts : List (Term E)) (u : 𝓢'(E,F)) : eval (differentiate v ts) u = ∂_{v} (eval ts u) := by induction ts with | nil => simp [differentiate] | cons t ts ih => change evalTerm (∂_{v} t.1,t.2) u + (evalTerm (t.1,v::t.2) u + eval (differentiate v ts) u) = ∂_{v} (evalTerm t u + eval ts u) rw [ih,derivative_add] simp only [evalTerm,derivative_cons,derivative_multiply] abel lemma differentiate_order {k : ℕ} (v : E) (ts : List (Term E)) (hts : ∀ t ∈ ts, t.2.length ≤ k) : ∀ t ∈ differentiate v ts, t.2.length ≤ k+1 := by intro t ht obtain ⟨t',ht',ht⟩ := List.mem_flatMap.mp ht simp only [List.mem_cons,List.not_mem_nil,or_false] at ht rcases ht with rfl | rfl · exact (hts t' ht').trans (Nat.le_succ _) · simpa using Nat.succ_le_succ (hts t' ht') def lower : List E → 𝓢(E,ℂ) → List (Term E) | [], _ => [] | v::vs, a => (∂_{v} a,vs) :: differentiate v (lower vs a) lemma derivative_multiply_expansion (vs : List E) (a : 𝓢(E,ℂ)) (u : 𝓢'(E,F)) : derivative vs (smulLeftCLM F a u) = smulLeftCLM F a (derivative vs u) + eval (lower vs a) u := by induction vs with | nil => simp [lower] | cons v vs ih => simp only [derivative_cons,lower,eval_cons,eval_differentiate] rw [ih] rw [derivative_add,derivative_multiply] simp only [evalTerm] abel lemma lower_order (vs : List E) (a : 𝓢(E,ℂ)) : ∀ t ∈ lower vs a, t.2.length < vs.length := by induction vs with | nil => simp [lower] | cons v vs ih => intro t ht simp only [lower,List.mem_cons] at ht rcases ht with rfl | ht · simp · obtain ⟨t',ht',ht⟩ := List.mem_flatMap.mp ht simp only [List.mem_cons,List.not_mem_nil,or_false] at ht rcases ht with rfl | rfl · exact (ih t' ht').trans (Nat.lt_succ_self _) · simpa using Nat.succ_lt_succ (ih t' ht') end section open TemperedDistribution LocalDifferential LineDeriv open scoped SchwartzMap variable {E : Type*} {F : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [NormedAddCommGroup F] [InnerProductSpace ℂ F] lemma eval_append (ts ss : List (Term E)) (u : 𝓢'(E,F)) : eval (ts++ss) u = eval ts u + eval ss u := by simp [eval] lemma eval_flatten (tss : List (List (Term E))) (u : 𝓢'(E,F)) : eval tss.flatten u = (tss.map (fun ts => eval ts u)).sum := by induction tss with | nil => rfl | cons ts tss ih => simpa only [List.flatten_cons,eval_append,List.map_cons,List.sum_cons] using congrArg (fun z => eval ts u+z) ih lemma eval_ofFn {N : ℕ} (ts : Fin N → Term E) (u : 𝓢'(E,F)) : eval (List.ofFn ts) u = ∑ i, evalTerm (ts i) u := by simp [eval,List.map_ofFn,List.sum_ofFn] lemma eval_eq_sum (ts : List (Term E)) (u : 𝓢'(E,F)) : eval ts u = ∑ i : Fin ts.length, evalTerm ts[i.val] u := by simpa only [List.ofFn_getElem] using eval_ofFn (fun i : Fin ts.length => ts[i.val]) u lemma eval_flatten_ofFn {N : ℕ} (tss : Fin N → List (Term E)) (u : 𝓢'(E,F)) : eval (List.ofFn tss).flatten u = ∑ i, eval (tss i) u := by rw [eval_flatten,List.map_ofFn,List.sum_ofFn] rfl def divergence {N : ℕ} (a : Fin N → 𝓢(E,ℂ)) (vs : Fin N → List E) (u : 𝓢'(E,F)) : 𝓢'(E,F) := ∑ i, derivative (vs i) (smulLeftCLM F (a i) u) def lowerTerms {N M : ℕ} (a : Fin N → 𝓢(E,ℂ)) (vs : Fin N → List E) (b : Fin M → 𝓢(E,ℂ)) (ws : Fin M → List E) : List (Term E) := (List.ofFn (fun i => lower (vs i) (a i))).flatten ++ (List.ofFn (fun i => (b i,ws i) :: lower (ws i) (b i))).flatten lemma divergence_expansion {N M : ℕ} (a : Fin N → 𝓢(E,ℂ)) (vs : Fin N → List E) (b : Fin M → 𝓢(E,ℂ)) (ws : Fin M → List E) (u : 𝓢'(E,F)) : divergence a vs u + divergence b ws u = (∑ i, smulLeftCLM F (a i) (derivative (vs i) u)) + eval (lowerTerms a vs b ws) u := by simp only [divergence,derivative_multiply_expansion,Finset.sum_add_distrib, lowerTerms,eval_append,eval_flatten_ofFn,eval_cons,evalTerm] abel lemma lowerTerms_order {N M m : ℕ} (a : Fin N → 𝓢(E,ℂ)) (vs : Fin N → List E) (b : Fin M → 𝓢(E,ℂ)) (ws : Fin M → List E) (hvs : ∀ i, (vs i).length = m) (hws : ∀ i, (ws i).length < m) : ∀ t ∈ lowerTerms a vs b ws, t.2.length < m := by intro t ht simp only [lowerTerms,List.mem_append,List.mem_flatten,List.mem_ofFn] at ht rcases ht with ⟨ts,⟨i,rfl⟩,ht⟩ | ⟨ts,⟨i,rfl⟩,ht⟩ · simpa only [hvs i] using lower_order (vs i) (a i) t ht · simp only [List.mem_cons] at ht rcases ht with rfl | ht · exact hws i · exact (lower_order (ws i) (b i) t ht).trans (hws i) end section open MeasureTheory TemperedDistribution LocalDifferential LocalOperator open scoped SchwartzMap Topology variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] theorem smooth_of_divergence_Lp {N M m : ℕ} (hm : 1 ≤ m) (a : E → Fin N → 𝓢(E,ℂ)) (b : E → Fin M → 𝓢(E,ℂ)) (vs : Fin N → List E) (ws : Fin M → List E) (hvs : ∀ i, (vs i).length = m) (hws : ∀ i, (ws i).length < m) (q : E → E → ℂ) (Cq : E → ℝ) (hq : ∀ x₀, (q x₀).HasTemperateGrowth) (hCq : ∀ x₀, 0 ≤ Cq x₀) (hinv : ∀ x₀ x, frozenSymbol (fun i => a x₀ i x₀) vs x * q x₀ x = 1) (hbq : ∀ x₀ x, LocalPeetre.weight (m:ℝ) x * ‖q x₀ x‖ ≤ Cq x₀) (f : Lp ℂ 2 (volume : Measure E)) (hP : ∀ x₀, ∃ ψ : 𝓢(E,ℂ), (ψ : E → ℂ) =ᶠ[𝓝 x₀] 1 ∧ smulLeftCLM ℂ ψ (divergence (a x₀) vs (f : 𝓢'(E,ℂ)) + divergence (b x₀) ws (f : 𝓢'(E,ℂ))) = 0) : ∃ w : E → ℂ, ContDiff ℝ ∞ w ∧ (f : E → ℂ) =ᵐ[volume] w := by classical apply SmoothPatching.patch f apply LocalElliptic.local_smooth_cutoffs intro n x₀ let ts := lowerTerms (a x₀) vs (b x₀) ws let c : Fin ts.length → 𝓢(E,ℂ) := fun i => (ts[i.val]).1 let zs : Fin ts.length → List E := fun i => (ts[i.val]).2 have hzs (i : Fin ts.length) : (zs i).length < m := lowerTerms_order (a x₀) vs (b x₀) ws hvs hws _ (List.getElem_mem i.isLt) have he : operator (a x₀) vs (f : 𝓢'(E,ℂ)) + operator c zs (f : 𝓢'(E,ℂ)) = divergence (a x₀) vs (f : 𝓢'(E,ℂ)) + divergence (b x₀) ws (f : 𝓢'(E,ℂ)) := by rw [divergence_expansion,operator_apply,operator_apply] rw [eval_eq_sum] rfl have hf : MemSobolev 0 2 (f : 𝓢'(E,ℂ)) := memSobolev_zero_iff.mpr ⟨f,rfl⟩ apply LocalElliptic.all_orders_at hm (a x₀) c x₀ vs zs hvs hzs (hq x₀) (hCq x₀) (hinv x₀) (hbq x₀) (LocalElliptic.at_of_memSobolev hf x₀) _ n simpa only [he] using hP x₀ end open MeasureTheory TemperedDistribution LocalDifferential LineDeriv open scoped SchwartzMap variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] def testDerivative : List E → 𝓢(E,ℂ) →L[ℂ] 𝓢(E,ℂ) | [] => ContinuousLinearMap.id ℂ _ | v::vs => (testDerivative vs).comp (lineDerivOpCLM ℂ 𝓢(E,ℂ) v) lemma derivative_pairing (vs : List E) (u : 𝓢'(E,ℂ)) (φ : 𝓢(E,ℂ)) : derivative vs u φ = (-1:ℂ)^vs.length * u (testDerivative vs φ) := by induction vs generalizing φ with | nil => simp [testDerivative] | cons v vs ih => rw [derivative_cons,TemperedDistribution.lineDerivOp_apply_apply,ih] simp only [List.length_cons,pow_succ,testDerivative,ContinuousLinearMap.comp_apply,map_neg] change (-1:ℂ)^vs.length * -u (testDerivative vs (∂_{v} φ)) = ((-1:ℂ)^vs.length * -1) * u (testDerivative vs (∂_{v} φ)) ring def testOperator {N : ℕ} (a : Fin N → 𝓢(E,ℂ)) (vs : Fin N → List E) (φ : 𝓢(E,ℂ)) : 𝓢(E,ℂ) := ∑ i, (-1:ℂ)^(vs i).length • product (a i) (testDerivative (vs i) φ) lemma divergence_pairing {N : ℕ} (a : Fin N → 𝓢(E,ℂ)) (vs : Fin N → List E) (u : 𝓢'(E,ℂ)) (φ : 𝓢(E,ℂ)) : divergence a vs u φ = u (testOperator a vs φ) := by simp only [divergence,sum_apply,derivative_pairing, TemperedDistribution.smulLeftCLM_apply_apply,testOperator,map_sum,map_smul,smul_eq_mul] rfl lemma localized_vanishes {N M : ℕ} (a : Fin N → 𝓢(E,ℂ)) (vs : Fin N → List E) (b : Fin M → 𝓢(E,ℂ)) (ws : Fin M → List E) (χ : 𝓢(E,ℂ)) (u : 𝓢'(E,ℂ)) (hweak : ∀ φ : 𝓢(E,ℂ), u (testOperator a vs (product χ φ) + testOperator b ws (product χ φ)) = 0) : smulLeftCLM ℂ χ (divergence a vs u + divergence b ws u) = 0 := by ext φ rw [TemperedDistribution.smulLeftCLM_apply_apply,add_apply, divergence_pairing,divergence_pairing,←map_add] exact hweak φ variable [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] lemma localized_vanishes_Lp {N M : ℕ} (a : Fin N → 𝓢(E,ℂ)) (vs : Fin N → List E) (b : Fin M → 𝓢(E,ℂ)) (ws : Fin M → List E) (χ : 𝓢(E,ℂ)) (f : Lp ℂ 2 (volume : Measure E)) (hweak : ∀ φ : 𝓢(E,ℂ), (∫ x, (testOperator a vs (product χ φ) x + testOperator b ws (product χ φ) x) * f x) = 0) : smulLeftCLM ℂ χ (divergence a vs (f : 𝓢'(E,ℂ)) + divergence b ws (f : 𝓢'(E,ℂ))) = 0 := by apply localized_vanishes intro φ rw [Lp.toTemperedDistribution_apply] exact hweak φ end DistributionExpansion namespace SchwartzOperator section open LocalDifferential LineDeriv open scoped SchwartzMap variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] abbrev Term (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ℝ E] := 𝓢(E,ℂ) × List E def derivative : List E → 𝓢(E,ℂ) →L[ℂ] 𝓢(E,ℂ) | [] => ContinuousLinearMap.id ℂ _ | v::vs => (lineDerivOpCLM ℂ 𝓢(E,ℂ) v).comp (derivative vs) @[simp] lemma derivative_nil (φ : 𝓢(E,ℂ)) : derivative [] φ = φ := rfl @[simp] lemma derivative_cons (v : E) (vs : List E) (φ : 𝓢(E,ℂ)) : derivative (v::vs) φ = ∂_{v} (derivative vs φ) := rfl lemma derivative_append (vs ws : List E) (φ : 𝓢(E,ℂ)) : derivative (vs++ws) φ = derivative vs (derivative ws φ) := by induction vs with | nil => rfl | cons v vs ih => simp only [List.cons_append,derivative_cons,ih] def term (t : Term E) : 𝓢(E,ℂ) →L[ℂ] 𝓢(E,ℂ) := (SchwartzMap.smulLeftCLM ℂ t.1).comp (derivative t.2) def operator (ts : List (Term E)) : 𝓢(E,ℂ) →L[ℂ] 𝓢(E,ℂ) := (ts.map term).sum @[simp] lemma term_apply (t : Term E) (φ : 𝓢(E,ℂ)) : term t φ = product t.1 (derivative t.2 φ) := rfl @[simp] lemma operator_nil (φ : 𝓢(E,ℂ)) : operator [] φ = 0 := rfl @[simp] lemma operator_cons (t : Term E) (ts : List (Term E)) (φ : 𝓢(E,ℂ)) : operator (t::ts) φ = term t φ + operator ts φ := rfl lemma operator_append (ts ss : List (Term E)) (φ : 𝓢(E,ℂ)) : operator (ts++ss) φ = operator ts φ + operator ss φ := by simp only [operator,List.map_append,List.sum_append,add_apply] lemma operator_map_coefficient (a : 𝓢(E,ℂ)) (ts : List (Term E)) (φ : 𝓢(E,ℂ)) : operator (ts.map (fun t => (product a t.1,t.2))) φ = product a (operator ts φ) := by induction ts with | nil => simp [product] | cons t ts ih => simp only [List.map_cons,operator_cons,term_apply,ih] ext x simp only [product_apply,add_apply] ring def differentiate (v : E) (ts : List (Term E)) : List (Term E) := ts.flatMap (fun t => [(∂_{v} t.1,t.2),(t.1,v::t.2)]) lemma operator_differentiate (v : E) (ts : List (Term E)) (φ : 𝓢(E,ℂ)) : operator (differentiate v ts) φ = ∂_{v} (operator ts φ) := by induction ts with | nil => simp [differentiate] | cons t ts ih => change term (∂_{v} t.1,t.2) φ + (term (t.1,v::t.2) φ + operator (differentiate v ts) φ) = ∂_{v} (term t φ + operator ts φ) rw [ih,lineDerivOp_add] simp only [term_apply,derivative_cons,schwartz_product_derivative] abel def lower : List E → 𝓢(E,ℂ) → List (Term E) | [], _ => [] | v::vs, a => (∂_{v} a,vs) :: differentiate v (lower vs a) lemma derivative_product (vs : List E) (a φ : 𝓢(E,ℂ)) : derivative vs (product a φ) = product a (derivative vs φ) + operator (lower vs a) φ := by induction vs with | nil => simp [lower] | cons v vs ih => simp only [derivative_cons,lower,operator_cons,operator_differentiate] rw [ih,lineDerivOp_add,schwartz_product_derivative] simp only [term_apply] abel lemma lower_order (vs : List E) (a : 𝓢(E,ℂ)) : ∀ t ∈ lower vs a, t.2.length < vs.length := by induction vs with | nil => simp [lower] | cons v vs ih => intro t ht simp only [lower,List.mem_cons] at ht rcases ht with rfl | ht · simp · obtain ⟨t',ht',ht⟩ := List.mem_flatMap.mp ht simp only [List.mem_cons,List.not_mem_nil,or_false] at ht rcases ht with rfl | rfl · exact (ih t' ht').trans (Nat.lt_succ_self _) · simpa using Nat.succ_lt_succ (ih t' ht') lemma operator_append_directions (ts : List (Term E)) (ws : List E) (φ : 𝓢(E,ℂ)) : operator (ts.map (fun t => (t.1,t.2++ws))) φ = operator ts (derivative ws φ) := by induction ts with | nil => rfl | cons t ts ih => simp only [List.map_cons,operator_cons,term_apply,derivative_append,ih] def composeLower (t s : Term E) : List (Term E) := (lower t.2 s.1).map (fun r => (product t.1 r.1,r.2++s.2)) def composeTerm (t s : Term E) : List (Term E) := (product t.1 s.1,t.2++s.2)::composeLower t s lemma operator_composeTerm (t s : Term E) (φ : 𝓢(E,ℂ)) : operator (composeTerm t s) φ = term t (term s φ) := by rw [composeTerm,operator_cons,term_apply,term_apply,term_apply,derivative_append, derivative_product] have he : composeLower t s = ((lower t.2 s.1).map (fun r => (r.1,r.2++s.2))).map (fun r => (product t.1 r.1,r.2)) := by simp [composeLower,List.map_map,Function.comp_def] rw [he,operator_map_coefficient,operator_append_directions] ext x simp only [product_apply,add_apply] ring lemma composeLower_order (t s : Term E) : ∀ r ∈ composeLower t s, r.2.length < t.2.length+s.2.length := by intro r hr change r ∈ (lower t.2 s.1).map (fun r => (product t.1 r.1,r.2++s.2)) at hr obtain ⟨z,hz,rfl⟩ := List.mem_map.mp hr simpa only [List.length_append] using Nat.add_lt_add_right (lower_order t.2 s.1 z hz) s.2.length lemma composeTerm_order (t s : Term E) : ∀ r ∈ composeTerm t s, r.2.length ≤ t.2.length+s.2.length := by intro r hr rcases List.mem_cons.mp hr with rfl | hr · simp · exact (composeLower_order t s r hr).le def compose (ts ss : List (Term E)) : List (Term E) := ts.flatMap (fun t => ss.flatMap (composeTerm t)) def principalCompose (ts ss : List (Term E)) : List (Term E) := ts.flatMap (fun t => ss.map (fun s => (product t.1 s.1,t.2++s.2))) def lowerCompose (ts ss : List (Term E)) : List (Term E) := ts.flatMap (fun t => ss.flatMap (composeLower t)) lemma operator_compose_fixed (t : Term E) (ss : List (Term E)) (φ : 𝓢(E,ℂ)) : operator (ss.flatMap (composeTerm t)) φ = term t (operator ss φ) := by induction ss with | nil => simp [product] | cons s ss ih => simp only [List.flatMap_cons,operator_append,operator_composeTerm,ih,operator_cons,map_add] lemma operator_compose (ts ss : List (Term E)) (φ : 𝓢(E,ℂ)) : operator (compose ts ss) φ = operator ts (operator ss φ) := by induction ts with | nil => simp [compose] | cons t ts ih => simp only [compose,List.flatMap_cons,operator_append,operator_compose_fixed,operator_cons] exact congrArg (fun z => term t (operator ss φ)+z) ih lemma operator_compose_split_fixed (t : Term E) (ss : List (Term E)) (φ : 𝓢(E,ℂ)) : operator (ss.flatMap (composeTerm t)) φ = operator (ss.map (fun s => (product t.1 s.1,t.2++s.2))) φ + operator (ss.flatMap (composeLower t)) φ := by induction ss with | nil => simp [product] | cons s ss ih => simp only [List.flatMap_cons,List.map_cons,operator_append,operator_cons,composeTerm,ih] abel lemma operator_compose_split (ts ss : List (Term E)) (φ : 𝓢(E,ℂ)) : operator (compose ts ss) φ = operator (principalCompose ts ss) φ + operator (lowerCompose ts ss) φ := by induction ts with | nil => simp [compose,principalCompose,lowerCompose] | cons t ts ih => simp only [compose,principalCompose,lowerCompose,List.flatMap_cons,operator_append] rw [operator_compose_split_fixed] change (_+_) + operator (compose ts ss) φ = _ rw [ih] abel lemma principalCompose_order {m n : ℕ} (ts ss : List (Term E)) (ht : ∀ t ∈ ts, t.2.length=m) (hs : ∀ s ∈ ss, s.2.length=n) : ∀ r ∈ principalCompose ts ss, r.2.length=m+n := by intro r hr change r ∈ ts.flatMap _ at hr obtain ⟨t,hts,hr⟩ := List.mem_flatMap.mp hr obtain ⟨s,hss,rfl⟩ := List.mem_map.mp hr simp [ht t hts,hs s hss] lemma lowerCompose_order {m n : ℕ} (ts ss : List (Term E)) (ht : ∀ t ∈ ts, t.2.length=m) (hs : ∀ s ∈ ss, s.2.length=n) : ∀ r ∈ lowerCompose ts ss, r.2.length < m+n := by intro r hr change r ∈ ts.flatMap _ at hr obtain ⟨t,hts,hr⟩ := List.mem_flatMap.mp hr obtain ⟨s,hss,hr⟩ := List.mem_flatMap.mp hr simpa only [ht t hts,hs s hss] using composeLower_order t s r hr lemma compose_order {m n : ℕ} (ts ss : List (Term E)) (ht : ∀ t ∈ ts, t.2.length ≤ m) (hs : ∀ s ∈ ss, s.2.length ≤ n) : ∀ r ∈ compose ts ss, r.2.length ≤ m+n := by intro r hr change r ∈ ts.flatMap _ at hr obtain ⟨t,hts,hr⟩ := List.mem_flatMap.mp hr obtain ⟨s,hss,hr⟩ := List.mem_flatMap.mp hr exact (composeTerm_order t s r hr).trans (Nat.add_le_add (ht t hts) (hs s hss)) def negTerms (ts : List (Term E)) : List (Term E) := ts.map (fun t => (-t.1,t.2)) lemma operator_negTerms (ts : List (Term E)) (φ : 𝓢(E,ℂ)) : operator (negTerms ts) φ = -operator ts φ := by induction ts with | nil => simp [negTerms] | cons t ts ih => change term (-t.1,t.2) φ + operator (negTerms ts) φ = -(term t φ + operator ts φ) rw [ih] ext x simp only [term_apply,product_apply,add_apply,neg_apply] ring def secondOrderRemainder (ts us : List (Term E)) : List (Term E) := lowerCompose ts ts ++ compose ts us ++ compose us ts ++ compose us us ++ negTerms (ts++us) lemma secondOrder_square_expansion (ts us : List (Term E)) (φ : 𝓢(E,ℂ)) : operator (ts++us) (operator (ts++us) φ-φ) = operator (principalCompose ts ts) φ + operator (secondOrderRemainder ts us) φ := by rw [operator_append,map_sub,map_sub] simp only [operator_append,map_add] rw [←operator_compose ts ts,←operator_compose ts us,←operator_compose us ts, ←operator_compose us us,operator_compose_split ts ts] simp only [secondOrderRemainder,operator_append,operator_negTerms] abel lemma secondOrderRemainder_order (ts us : List (Term E)) (ht : ∀ t ∈ ts, t.2.length=2) (hu : ∀ t ∈ us, t.2.length ≤ 1) : ∀ r ∈ secondOrderRemainder ts us, r.2.length < 4 := by intro r hr simp only [secondOrderRemainder,List.mem_append] at hr rcases hr with (((hr|hr)|hr)|hr)|hr · exact lowerCompose_order ts ts ht ht r hr · exact (compose_order ts us (fun t h => (ht t h).le) hu r hr).trans_lt (by decide) · exact (compose_order us ts hu (fun t h => (ht t h).le) r hr).trans_lt (by decide) · exact (compose_order us us hu hu r hr).trans_lt (by decide) · change r ∈ (ts++us).map _ at hr obtain ⟨z,hz,rfl⟩ := List.mem_map.mp hr rcases List.mem_append.mp hz with hz|hz · simp only [ht z hz]; decide · exact (hu z hz).trans_lt (by decide) end open MeasureTheory TemperedDistribution LocalDifferential LineDeriv open scoped SchwartzMap variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] lemma testDerivative_append (vs ws : List E) (φ : 𝓢(E,ℂ)) : DistributionExpansion.testDerivative (vs++ws) φ = DistributionExpansion.testDerivative ws (DistributionExpansion.testDerivative vs φ) := by induction vs generalizing φ with | nil => rfl | cons v vs ih => simpa only [List.cons_append,DistributionExpansion.testDerivative, ContinuousLinearMap.comp_apply] using ih ((lineDerivOpCLM ℂ 𝓢(E,ℂ) v) φ) lemma testDerivative_reverse (vs : List E) (φ : 𝓢(E,ℂ)) : DistributionExpansion.testDerivative vs.reverse φ = derivative vs φ := by induction vs with | nil => rfl | cons v vs ih => rw [List.reverse_cons,testDerivative_append,ih] rfl def adjointTerm (t : Term E) (u : 𝓢'(E,ℂ)) : 𝓢'(E,ℂ) := LocalDifferential.derivative t.2.reverse (smulLeftCLM ℂ ((-1:ℂ)^t.2.length • t.1 : 𝓢(E,ℂ)) u) lemma adjointTerm_pairing (t : Term E) (u : 𝓢'(E,ℂ)) (φ : 𝓢(E,ℂ)) : adjointTerm t u φ = u (term t φ) := by rw [adjointTerm,DistributionExpansion.derivative_pairing,List.length_reverse, TemperedDistribution.smulLeftCLM_apply_apply,testDerivative_reverse] change (-1:ℂ)^t.2.length * u (product ((-1:ℂ)^t.2.length • t.1) (derivative t.2 φ)) = _ have he : product ((-1:ℂ)^t.2.length • t.1) (derivative t.2 φ) = (-1:ℂ)^t.2.length • product t.1 (derivative t.2 φ) := by ext x simp [product_apply,smul_eq_mul,mul_assoc] rw [he,map_smul,smul_eq_mul,←mul_assoc,←mul_pow] simp only [neg_one_mul,neg_neg,one_pow,one_mul,term_apply] def adjoint (ts : List (Term E)) (u : 𝓢'(E,ℂ)) : 𝓢'(E,ℂ) := (ts.map (fun t => adjointTerm t u)).sum lemma adjoint_pairing (ts : List (Term E)) (u : 𝓢'(E,ℂ)) (φ : 𝓢(E,ℂ)) : adjoint ts u φ = u (operator ts φ) := by induction ts with | nil => simp [adjoint] | cons t ts ih => change adjointTerm t u φ + adjoint ts u φ = u (term t φ + operator ts φ) rw [adjointTerm_pairing,ih,map_add] lemma adjoint_ofFn {N : ℕ} (ts : Fin N → Term E) (u : 𝓢'(E,ℂ)) : adjoint (List.ofFn ts) u = DistributionExpansion.divergence (fun i => (-1:ℂ)^(ts i).2.length • (ts i).1) (fun i => (ts i).2.reverse) u := by simp [adjoint,List.map_ofFn,List.sum_ofFn,DistributionExpansion.divergence,adjointTerm] lemma adjoint_eq_divergence (ts : List (Term E)) (u : 𝓢'(E,ℂ)) : adjoint ts u = DistributionExpansion.divergence (fun i : Fin ts.length => (-1:ℂ)^(ts[i.val]).2.length • (ts[i.val]).1) (fun i : Fin ts.length => (ts[i.val]).2.reverse) u := by simpa only [List.ofFn_getElem] using adjoint_ofFn (fun i : Fin ts.length => ts[i.val]) u lemma localized_adjoint_vanishes (ts ss : List (Term E)) (χ : 𝓢(E,ℂ)) (u : 𝓢'(E,ℂ)) (hweak : ∀ φ : 𝓢(E,ℂ), u (operator ts (product χ φ) + operator ss (product χ φ)) = 0) : smulLeftCLM ℂ χ (adjoint ts u + adjoint ss u) = 0 := by ext φ rw [TemperedDistribution.smulLeftCLM_apply_apply,add_apply, adjoint_pairing,adjoint_pairing,←map_add] exact hweak φ end SchwartzOperator namespace LocalSymbol section open Function open scoped Real ContDiff Topology variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] /- Copyright (c) 2025 Moritz Doll. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Moritz Doll, Anatole Dedecker, Sébastien Gouëzel The following temperate growth theorem is adapted from Mathlib.Analysis.Distribution.TemperateGrowth. Source: https://github.com/leanprover-community/mathlib4/blob/d13f23b723b8a846827a245b89c10fc7d3f11612/Mathlib/Analysis/Distribution/TemperateGrowth.lean This code has been modified. -/ lemma rpow_growth {f : E → ℝ} (hf : f.HasTemperateGrowth) (hf_one : ∀ x, 1 ≤ f x) (r : ℝ) : (fun x => f x ^ r).HasTemperateGrowth := by set t := {y : ℝ | 1 / 2 < y} have ht : Set.range f ⊆ t := by rintro - ⟨y, rfl⟩ simp only [Set.mem_ofPred_eq, t] exact lt_of_lt_of_le (by norm_num) (hf_one y) have hdiff : ContDiffOn ℝ ∞ (fun x ↦ x ^ r) t := contDiffOn_fun_id.rpow_const_of_ne fun x hx ↦ (lt_trans (by norm_num) hx).ne' have hunique : UniqueDiffOn ℝ t := (isOpen_lt' (1 / 2)).uniqueDiffOn apply HasTemperateGrowth.comp' ht hunique hdiff _ hf intro N obtain ⟨k, hk⟩ := exists_nat_ge (max r <| (N - r) * Real.log 2 / (Real.log (3 / 2))) have hk₁ : r ≤ k := le_sup_left.trans hk have hk₂ : Real.log 2 * (N - r) ≤ (Real.log (3 / 2)) * k := by have := le_sup_right.trans hk field_simp at this grind use k, ∑ k ∈ Finset.range (N + 1), ‖Polynomial.eval r (descPochhammer ℝ k)‖, by positivity intro n hn x hx have : ContDiffAt ℝ n (fun x ↦ x ^ r) x := Real.contDiffAt_rpow_const <| Or.inl (lt_trans (by norm_num) hx).ne' rw [norm_iteratedFDerivWithin_eq_norm_iteratedDerivWithin, iteratedDerivWithin_eq_iteratedDeriv hunique this hx, iteratedDeriv_eq_iterate, Real.iter_deriv_rpow_const, norm_mul] gcongr 1 · have : n ∈ Finset.range (N + 1) := by grind apply Finset.single_le_sum (fun _ _ ↦ by positivity) this have hx' : 1 / 2 < x := by simpa [t] using hx have hx'' : 0 < x := lt_of_lt_of_le (by norm_num) hx'.le simp only [Real.norm_eq_abs] apply (Real.abs_rpow_le_abs_rpow _ _).trans by_cases! h : 0 ≤ r - n · have : r - n ≤ k := by simpa using hk₁.trans (by simp) rw [← Real.rpow_natCast] exact (Real.rpow_le_rpow (by positivity) (by simp) h).trans (Real.rpow_le_rpow_of_exponent_le (by simp) this) have h : 0 < n - r := by grind calc _ = x ^ (-(n - r)) := by rw [neg_sub] congr simpa using hx''.le _ ≤ (2 : ℝ) ^ (n - r) := by simp only [one_div, Set.mem_ofPred_eq, t] at hx rw [Real.rpow_neg_eq_inv_rpow] gcongr exact ((inv_lt_comm₀ hx'' (by norm_num)).mpr hx).le _ = Real.exp (Real.log 2 * (n - r)) := by rw [Real.rpow_def_of_pos] norm_num _ ≤ Real.exp (Real.log (3 / 2) * k) := by gcongr 1 apply le_trans _ hk₂ gcongr _ ≤ (3 / 2) ^ k := by rw [← Real.rpow_natCast, Real.rpow_def_of_pos] norm_num _ ≤ _ := by gcongr grind def quadratic (A : E →L[ℝ] E) (x : E) : ℝ := inner ℝ x (A x) def principal (A : E →L[ℝ] E) (x : E) : ℂ := Complex.ofReal (quadratic A x)^2 def regularized (A : E →L[ℝ] E) (x : E) : ℂ := 1+principal A x def inverseSymbol (A : E →L[ℝ] E) (x : E) : ℂ := Complex.ofReal (1+quadratic A x ^ 2)⁻¹ lemma quadratic_growth (A : E →L[ℝ] E) : (quadratic A).HasTemperateGrowth := by unfold quadratic exact (innerSL ℝ).bilinear_hasTemperateGrowth (by fun_prop) A.hasTemperateGrowth lemma principal_growth (A : E →L[ℝ] E) : (principal A).HasTemperateGrowth := by exact ((Complex.ofRealCLM.hasTemperateGrowth).comp (quadratic_growth A)).pow 2 lemma regularized_growth (A : E →L[ℝ] E) : (regularized A).HasTemperateGrowth := by exact (Function.HasTemperateGrowth.const _).add (principal_growth A) lemma inverseSymbol_growth (A : E →L[ℝ] E) : (inverseSymbol A).HasTemperateGrowth := by have hf : (fun x => 1+quadratic A x^2).HasTemperateGrowth := (Function.HasTemperateGrowth.const _).add ((quadratic_growth A).pow 2) have hp := rpow_growth hf (by intro x; nlinarith [sq_nonneg (quadratic A x)]) (-1) convert (Complex.ofRealCLM.hasTemperateGrowth).comp hp using 1 ext x simp [inverseSymbol, Real.rpow_neg_one] lemma inverse_identity (A : E →L[ℝ] E) (x : E) : regularized A x * inverseSymbol A x = 1 := by have hp : 0 < 1+quadratic A x^2 := by positivity change (1+Complex.ofReal (quadratic A x)^2) * Complex.ofReal ((1+quadratic A x^2)⁻¹) = 1 rw [←Complex.ofReal_pow, ←Complex.ofReal_one, ←Complex.ofReal_add, ←Complex.ofReal_mul, mul_inv_cancel₀ hp.ne'] lemma inverse_order_bound (A : E →L[ℝ] E) {c : ℝ} (hc : 0 < c) (hA : ∀ x, c*‖x‖^2 ≤ quadratic A x) (x : E) : (1+‖x‖^2)^((4:ℝ)/2) * ‖inverseSymbol A x‖ ≤ 2*(1+c⁻¹^2) := by have h1 : 0 < 1+quadratic A x^2 := by positivity have h2 : 0 ≤ quadratic A x := (by positivity : 0 ≤ c*‖x‖^2).trans (hA x) have h3 : ‖x‖^2 ≤ c⁻¹*quadratic A x := by rw [inv_mul_eq_div] apply (le_div_iff₀ hc).mpr simpa [mul_comm] using hA x have h4 : ‖x‖^4 ≤ c⁻¹^2*quadratic A x^2 := by nlinarith [(sq_le_sq₀ (by positivity : 0 ≤ ‖x‖^2) (by positivity : 0 ≤ c⁻¹*quadratic A x)).mpr h3] have h5 : (1+‖x‖^2)^2 ≤ 2*(1+‖x‖^4) := by nlinarith [sq_nonneg (1-‖x‖^2)] have hb : (1+‖x‖^2)^2 ≤ (2*(1+c⁻¹^2))*(1+quadratic A x^2) := by nlinarith [sq_nonneg c⁻¹, sq_nonneg (quadratic A x), mul_nonneg (sq_nonneg c⁻¹) (sq_nonneg (quadratic A x))] norm_num only [show (4:ℝ)/2=2 by norm_num, Real.rpow_two] rw [inverseSymbol, Complex.norm_real, Real.norm_eq_abs, abs_of_nonneg (by positivity), ←div_eq_mul_inv] exact (div_le_iff₀ h1).mpr hb end open Metric open scoped Real variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] lemma exists_coercivity (A : E →L[ℝ] E) (hA : ∀ x : E, x ≠ 0 → 0 < quadratic A x) : ∃ c : ℝ, 0 < c ∧ ∀ x, c*‖x‖^2 ≤ quadratic A x := by obtain ⟨c,hc,hbound⟩ := (isCompact_sphere (0:E) 1).exists_forall_le' (quadratic_growth A).1.continuous.continuousOn (fun y hy => hA y (by intro he simp [he] at hy)) refine ⟨c,hc,?_⟩ intro x by_cases hx : x=0 · simp [hx,quadratic] have hn : ‖x‖ ≠ 0 := norm_ne_zero_iff.mpr hx have hxunit : ‖x‖⁻¹ • x ∈ sphere (0:E) 1 := by rw [mem_sphere_zero_iff_norm, norm_smul, Real.norm_eq_abs, abs_inv, abs_norm, inv_mul_cancel₀ hn] have he := hbound _ hxunit have hq : quadratic A (‖x‖⁻¹ • x) = ‖x‖⁻¹^2 * quadratic A x := by simp only [quadratic, map_smul, real_inner_smul_left, real_inner_smul_right] ring rw [hq] at he have hp := mul_le_mul_of_nonneg_right he (sq_nonneg ‖x‖) have heq : (‖x‖⁻¹^2 * quadratic A x) * ‖x‖^2 = quadratic A x := by field_simp [hn] rwa [heq] at hp end LocalSymbol namespace FourthOrderSymbol open LocalDifferential LocalSymbol open scoped BigOperators Real variable {E : Type*} {ι : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [Fintype ι] lemma symbol_append (vs ws : List E) (x : E) : symbol (vs++ws) x = symbol vs x * symbol ws x := by induction vs with | nil => simp [symbol] | cons v vs ih => simp only [List.cons_append,symbol,ih]; ring lemma symbol_pair (v w x : E) : symbol [v,w] x = -((2*Real.pi : ℝ)^2 : ℂ) * (inner ℝ x v : ℂ) * (inner ℝ x w : ℂ) := by simp only [symbol,one_mul] push_cast calc _ = (2*(Real.pi : ℂ))^2 * Complex.I^2 * (inner ℝ x v : ℂ) * (inner ℝ x w : ℂ) := by ring _ = _ := by rw [Complex.I_sq]; ring lemma quadratic_expansion (e : OrthonormalBasis ι ℝ E) (A : E →L[ℝ] E) (x : E) : quadratic A x = ∑ i, ∑ j, inner ℝ (e i) (A (e j)) * inner ℝ x (e i) * inner ℝ x (e j) := by have he : A x = ∑ j, inner ℝ x (e j) • A (e j) := by calc A x = A (∑ j, inner ℝ x (e j) • e j) := by congr 1 simpa only [real_inner_comm] using (e.sum_repr' x).symm _ = _ := by simp only [map_sum,map_smul] rw [quadratic,he,inner_sum] simp only [real_inner_smul_right] rw [Finset.sum_comm] apply Finset.sum_congr rfl intro j hj rw [← e.sum_inner_mul_inner x (A (e j)),Finset.mul_sum] apply Finset.sum_congr rfl intro i hi ring lemma second_symbol (e : OrthonormalBasis ι ℝ E) (A : E →L[ℝ] E) (x : E) : (∑ p : ι×ι, (inner ℝ (e p.1) (A (e p.2)) : ℂ) * symbol [e p.1,e p.2] x) = -((2*Real.pi : ℝ)^2 : ℂ) * (quadratic A x : ℂ) := by simp_rw [symbol_pair] rw [quadratic_expansion e A x] push_cast rw [Fintype.sum_prod_type,Finset.mul_sum] apply Finset.sum_congr rfl intro i hi rw [Finset.mul_sum] apply Finset.sum_congr rfl intro j hj ring lemma fourth_symbol (e : OrthonormalBasis ι ℝ E) (A : E →L[ℝ] E) (x : E) : (∑ p : (ι×ι)×(ι×ι), ((inner ℝ (e p.1.1) (A (e p.1.2)) : ℂ) * (inner ℝ (e p.2.1) (A (e p.2.2)) : ℂ)) * symbol [e p.1.1,e p.1.2,e p.2.1,e p.2.2] x) = principal (((2*Real.pi)^2) • A) x := by have hsym (p q : ι×ι) : symbol [e p.1,e p.2,e q.1,e q.2] x = symbol [e p.1,e p.2] x * symbol [e q.1,e q.2] x := symbol_append [e p.1,e p.2] [e q.1,e q.2] x simp_rw [hsym] simp only [Fintype.sum_prod_type] have he : (∑ p : ι×ι, (inner ℝ (e p.1) (A (e p.2)) : ℂ) * symbol [e p.1,e p.2] x)^2 = (∑ i, ∑ j, ∑ k, ∑ l, ((inner ℝ (e i) (A (e j)) : ℂ) * (inner ℝ (e k) (A (e l)) : ℂ)) * (symbol [e i,e j] x * symbol [e k,e l] x)) := by rw [pow_two,Fintype.sum_prod_type,Finset.sum_mul] simp_rw [Finset.sum_mul,Finset.mul_sum] apply Finset.sum_congr rfl intro i hi apply Finset.sum_congr rfl intro j hj apply Finset.sum_congr rfl intro k hk apply Finset.sum_congr rfl intro l hl ring rw [←he,second_symbol] simp only [LocalSymbol.principal,LocalSymbol.quadratic,smul_apply,real_inner_smul_right] push_cast ring end FourthOrderSymbol namespace SchwartzOperator section open LocalDifferential FourthOrderSymbol open scoped SchwartzMap variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] lemma symbol_reverse (vs : List E) (ξ : E) : LocalDifferential.symbol vs.reverse ξ = LocalDifferential.symbol vs ξ := by induction vs with | nil => rfl | cons v vs ih => rw [List.reverse_cons,symbol_append,ih] simp only [LocalDifferential.symbol] ring def testSymbol (ts : List (Term E)) (x ξ : E) : ℂ := (ts.map (fun t => t.1 x * LocalDifferential.symbol t.2 ξ)).sum @[simp] lemma testSymbol_nil (x ξ : E) : testSymbol ([] : List (Term E)) x ξ = 0 := rfl @[simp] lemma testSymbol_cons (t : Term E) (ts : List (Term E)) (x ξ : E) : testSymbol (t::ts) x ξ = t.1 x * LocalDifferential.symbol t.2 ξ + testSymbol ts x ξ := rfl lemma testSymbol_append (ts ss : List (Term E)) (x ξ : E) : testSymbol (ts++ss) x ξ = testSymbol ts x ξ + testSymbol ss x ξ := by simp [testSymbol] lemma testSymbol_principal_fixed (t : Term E) (ss : List (Term E)) (x ξ : E) : testSymbol (ss.map (fun s => (product t.1 s.1,t.2++s.2))) x ξ = (t.1 x * LocalDifferential.symbol t.2 ξ) * testSymbol ss x ξ := by induction ss with | nil => simp | cons s ss ih => simp only [List.map_cons,testSymbol_cons,ih,product_apply,symbol_append] ring lemma testSymbol_principalCompose (ts ss : List (Term E)) (x ξ : E) : testSymbol (principalCompose ts ss) x ξ = testSymbol ts x ξ * testSymbol ss x ξ := by induction ts with | nil => simp [principalCompose] | cons t ts ih => change testSymbol (_ ++ principalCompose ts ss) x ξ = _ rw [testSymbol_append,testSymbol_principal_fixed,ih,testSymbol_cons,add_mul] lemma testSymbol_ofFn {N : ℕ} (ts : Fin N → Term E) (x ξ : E) : testSymbol (List.ofFn ts) x ξ = ∑ i, (ts i).1 x * LocalDifferential.symbol (ts i).2 ξ := by simp [testSymbol,List.map_ofFn,List.sum_ofFn] lemma testSymbol_eq_sum (ts : List (Term E)) (x ξ : E) : testSymbol ts x ξ = ∑ i : Fin ts.length, (ts[i.val]).1 x * LocalDifferential.symbol (ts[i.val]).2 ξ := by simpa only [List.ofFn_getElem] using testSymbol_ofFn (fun i : Fin ts.length => ts[i.val]) x ξ end open MeasureTheory TemperedDistribution LocalDifferential LocalOperator open scoped SchwartzMap Topology variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] theorem smooth_of_weak_square (f : Lp ℂ 2 (volume : Measure E)) (hlocal : ∀ x₀ : E, ∃ ts us : List (Term E), ∃ A : E →L[ℝ] E, (∀ t ∈ ts, t.2.length = 2) ∧ (∀ t ∈ us, t.2.length ≤ 1) ∧ (∀ ξ : E, ξ ≠ 0 → 0 < LocalSymbol.quadratic A ξ) ∧ (∀ ξ, testSymbol ts x₀ ξ = (LocalSymbol.quadratic A ξ : ℂ)) ∧ ∃ ψ : 𝓢(E,ℂ), (ψ : E → ℂ) =ᶠ[𝓝 x₀] 1 ∧ ∀ φ : 𝓢(E,ℂ), (f : 𝓢'(E,ℂ)) (operator (ts++us) (operator (ts++us) (product ψ φ) - product ψ φ)) = 0) : ∃ w : E → ℂ, ContDiff ℝ ∞ w ∧ (f : E → ℂ) =ᵐ[volume] w := by classical apply SmoothPatching.patch f apply LocalElliptic.local_smooth_cutoffs intro n x₀ obtain ⟨ts,us,A,ht,hu,hA,hsym,ψ,hψ,hweak⟩ := hlocal x₀ let ps := principalCompose ts ts let rs := secondOrderRemainder ts us have hp : ∀ t ∈ ps, t.2.length = 4 := principalCompose_order ts ts ht ht have hr : ∀ t ∈ rs, t.2.length < 4 := secondOrderRemainder_order ts us ht hu let a : Fin ps.length → 𝓢(E,ℂ) := fun i => (-1:ℂ)^(ps[i.val]).2.length • (ps[i.val]).1 let vs : Fin ps.length → List E := fun i => (ps[i.val]).2.reverse let b : Fin rs.length → 𝓢(E,ℂ) := fun i => (-1:ℂ)^(rs[i.val]).2.length • (rs[i.val]).1 let ws : Fin rs.length → List E := fun i => (rs[i.val]).2.reverse have hvs (i : Fin ps.length) : (vs i).length = 4 := by simpa only [vs,List.length_reverse] using hp _ (List.getElem_mem i.isLt) have hws (i : Fin rs.length) : (ws i).length < 4 := by simpa only [ws,List.length_reverse] using hr _ (List.getElem_mem i.isLt) have hsymbol (ξ : E) : frozenSymbol (fun i => a i x₀) vs ξ = LocalSymbol.regularized A ξ := by change 1 + (∑ i : Fin ps.length, a i x₀ * LocalDifferential.symbol (vs i) ξ) = _ have hsum : (∑ i : Fin ps.length, a i x₀ * LocalDifferential.symbol (vs i) ξ) = testSymbol ps x₀ ξ := by rw [testSymbol_eq_sum] apply Finset.sum_congr rfl intro i hi have hi4 := hp _ (List.getElem_mem i.isLt) norm_num [a,vs,hi4,symbol_reverse] rw [hsum] change 1+testSymbol (principalCompose ts ts) x₀ ξ = _ rw [testSymbol_principalCompose,hsym] simp only [LocalSymbol.regularized,LocalSymbol.principal] ring obtain ⟨c,hc,hcA⟩ := LocalSymbol.exists_coercivity A hA have hinv (ξ : E) : frozenSymbol (fun i => a i x₀) vs ξ * LocalSymbol.inverseSymbol A ξ = 1 := by rw [hsymbol] exact LocalSymbol.inverse_identity A ξ have hbq (ξ : E) : LocalPeetre.weight (4:ℝ) ξ * ‖LocalSymbol.inverseSymbol A ξ‖ ≤ 2*(1+c⁻¹^2) := LocalSymbol.inverse_order_bound A hc hcA ξ let ls := DistributionExpansion.lowerTerms a vs b ws let d : Fin ls.length → 𝓢(E,ℂ) := fun i => (ls[i.val]).1 let zs : Fin ls.length → List E := fun i => (ls[i.val]).2 have hzs (i : Fin ls.length) : (zs i).length < 4 := DistributionExpansion.lowerTerms_order a vs b ws hvs hws _ (List.getElem_mem i.isLt) have he : LocalOperator.operator a vs (f : 𝓢'(E,ℂ)) + LocalOperator.operator d zs (f : 𝓢'(E,ℂ)) = adjoint ps (f : 𝓢'(E,ℂ)) + adjoint rs (f : 𝓢'(E,ℂ)) := by rw [adjoint_eq_divergence,adjoint_eq_divergence] change _ = DistributionExpansion.divergence a vs _ + DistributionExpansion.divergence b ws _ rw [DistributionExpansion.divergence_expansion,LocalOperator.operator_apply, LocalOperator.operator_apply,DistributionExpansion.eval_eq_sum] rfl have hf : MemSobolev 0 2 (f : 𝓢'(E,ℂ)) := memSobolev_zero_iff.mpr ⟨f,rfl⟩ apply LocalElliptic.all_orders_at (m:=4) (by decide) a d x₀ vs zs hvs hzs (LocalSymbol.inverseSymbol_growth A) (by positivity : 0 ≤ 2*(1+c⁻¹^2)) hinv hbq (LocalElliptic.at_of_memSobolev hf x₀) _ n refine ⟨ψ,hψ,?_⟩ rw [he] apply localized_adjoint_vanishes intro φ simpa only [secondOrder_square_expansion] using hweak φ end SchwartzOperator namespace SmoothOperator section open LocalDifferential Filter open scoped SchwartzMap Topology ContDiff variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] structure Coefficient (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ℝ E] where fn : E → ℂ smooth : ContDiff ℝ ∞ fn instance : CoeFun (Coefficient E) (fun _ => E → ℂ) := ⟨Coefficient.fn⟩ abbrev Term (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ℝ E] := Coefficient E × List E def derivative : List E → (E → ℂ) → E → ℂ | [], f => f | v::vs, f => fun x => fderiv ℝ (derivative vs f) x v lemma derivative_smooth (vs : List E) {f : E → ℂ} (hf : ContDiff ℝ ∞ f) : ContDiff ℝ ∞ (derivative vs f) := by induction vs with | nil => exact hf | cons v vs ih => exact (ih.fderiv_right (m:=∞) (by simp)).clm_apply contDiff_const lemma derivative_eq_schwartz (vs : List E) (φ : 𝓢(E,ℂ)) : derivative vs (φ : E → ℂ) = (SchwartzOperator.derivative vs φ : E → ℂ) := by induction vs with | nil => rfl | cons v vs ih => ext x simp only [derivative,ih,SchwartzOperator.derivative_cons,SchwartzMap.lineDerivOp_apply_eq_fderiv] lemma derivative_support (vs : List E) (f : E → ℂ) : tsupport (derivative vs f) ⊆ tsupport f := by induction vs with | nil => exact Set.Subset.rfl | cons v vs ih => apply Set.Subset.trans _ ((tsupport_fderiv_subset ℝ).trans ih) apply closure_mono intro x hx change fderiv ℝ (derivative vs f) x ≠ 0 intro hz exact hx (by simp [derivative,hz]) lemma derivative_compact (vs : List E) {f : E → ℂ} (hf : HasCompactSupport f) : HasCompactSupport (derivative vs f) := hf.of_isClosed_subset (isClosed_tsupport _) (derivative_support vs f) def operator (ts : List (Term E)) (f : E → ℂ) : E → ℂ := (ts.map (fun t => fun x => t.1 x * derivative t.2 f x)).sum @[simp] lemma operator_nil (f : E → ℂ) : operator ([] : List (Term E)) f = 0 := rfl @[simp] lemma operator_cons (t : Term E) (ts : List (Term E)) (f : E → ℂ) : operator (t::ts) f = (fun x => t.1 x * derivative t.2 f x) + operator ts f := rfl lemma operator_append (ts ss : List (Term E)) (f : E → ℂ) : operator (ts++ss) f = operator ts f + operator ss f := by simp [operator] lemma operator_smooth (ts : List (Term E)) {f : E → ℂ} (hf : ContDiff ℝ ∞ f) : ContDiff ℝ ∞ (operator ts f) := by induction ts with | nil => exact contDiff_const | cons t ts ih => exact (t.1.smooth.mul (derivative_smooth t.2 hf)).add ih lemma operator_support (ts : List (Term E)) (f : E → ℂ) : tsupport (operator ts f) ⊆ tsupport f := by induction ts with | nil => simp | cons t ts ih => change tsupport ((fun x => t.1 x * derivative t.2 f x) + operator ts f) ⊆ _ exact (tsupport_add _ _).trans (Set.union_subset (tsupport_mul_subset_right.trans (derivative_support t.2 f)) ih) lemma operator_compact (ts : List (Term E)) {f : E → ℂ} (hf : HasCompactSupport f) : HasCompactSupport (operator ts f) := hf.of_isClosed_subset (isClosed_tsupport _) (operator_support ts f) def localizeTerm (χ : 𝓢(E,ℂ)) (hχ : HasCompactSupport χ) (t : Term E) : SchwartzOperator.Term E := ((hχ.mul_right (f':=(t.1 : E → ℂ))).toSchwartzMap (χ.smooth'.mul t.1.smooth),t.2) def localize (χ : 𝓢(E,ℂ)) (hχ : HasCompactSupport χ) (ts : List (Term E)) : List (SchwartzOperator.Term E) := ts.map (localizeTerm χ hχ) lemma localize_apply (χ : 𝓢(E,ℂ)) (hχ : HasCompactSupport χ) (t : Term E) (x : E) : (localizeTerm χ hχ t).1 x = χ x * t.1 x := rfl lemma localize_operator (χ : 𝓢(E,ℂ)) (hχ : HasCompactSupport χ) (ts : List (Term E)) (φ : 𝓢(E,ℂ)) : (SchwartzOperator.operator (localize χ hχ ts) φ : E → ℂ) = fun x => χ x * operator ts φ x := by induction ts with | nil => ext; simp [localize] | cons t ts ih => ext x change SchwartzOperator.term (localizeTerm χ hχ t) φ x + SchwartzOperator.operator (localize χ hχ ts) φ x = _ rw [SchwartzOperator.term_apply,product_apply,localize_apply,congrFun ih] rw [operator_cons,Pi.add_apply,←derivative_eq_schwartz] change (χ x * t.1 x) * derivative t.2 φ x + χ x * operator ts φ x = _ ring lemma localize_operator_eq (χ : 𝓢(E,ℂ)) (hχ : HasCompactSupport χ) (ts : List (Term E)) (φ : 𝓢(E,ℂ)) (heq : ∀ x ∈ tsupport φ, χ x = 1) : (SchwartzOperator.operator (localize χ hχ ts) φ : E → ℂ) = operator ts φ := by rw [localize_operator] ext x by_cases hx : x ∈ tsupport φ · rw [heq x hx,one_mul] · have hz : operator ts φ x = 0 := by apply Function.notMem_support.mp intro hz exact hx (operator_support ts φ (subset_tsupport _ hz)) simp [hz] lemma localize_append (χ : 𝓢(E,ℂ)) (hχ : HasCompactSupport χ) (ts ss : List (Term E)) : localize χ hχ (ts++ss) = localize χ hχ ts ++ localize χ hχ ss := List.map_append lemma localize_square (χ : 𝓢(E,ℂ)) (hχ : HasCompactSupport χ) (ts : List (Term E)) (φ : 𝓢(E,ℂ)) (heq : ∀ x ∈ tsupport φ, χ x = 1) : (SchwartzOperator.operator (localize χ hχ ts) (SchwartzOperator.operator (localize χ hχ ts) φ - φ) : E → ℂ) = operator ts (operator ts φ - φ) := by have hfirst := localize_operator_eq χ hχ ts φ heq have hsecond : ∀ x ∈ tsupport (SchwartzOperator.operator (localize χ hχ ts) φ - φ), χ x = 1 := by intro x hx have hsub : ((SchwartzOperator.operator (localize χ hχ ts) φ - φ : 𝓢(E,ℂ)) : E → ℂ) = operator ts φ - φ := by ext y; exact congrArg (fun z => z-φ y) (congrFun hfirst y) rw [hsub] at hx exact heq x ((tsupport_sub _ _).trans (Set.union_subset (operator_support ts φ) Set.Subset.rfl) hx) rw [localize_operator_eq χ hχ ts _ hsecond] congr 1 ext y exact congrArg (fun z => z-φ y) (congrFun hfirst y) end open MeasureTheory LocalDifferential Filter Metric TemperedDistribution open scoped SchwartzMap Topology ContDiff variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] def testSymbol (ts : List (Term E)) (x ξ : E) : ℂ := (ts.map (fun t => t.1 x * LocalDifferential.symbol t.2 ξ)).sum omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in lemma localize_symbol (χ : 𝓢(E,ℂ)) (hχ : HasCompactSupport χ) (ts : List (Term E)) (x ξ : E) : SchwartzOperator.testSymbol (localize χ hχ ts) x ξ = χ x * testSymbol ts x ξ := by induction ts with | nil => simp [localize,testSymbol] | cons t ts ih => change SchwartzOperator.testSymbol (localizeTerm χ hχ t :: localize χ hχ ts) x ξ = _ rw [SchwartzOperator.testSymbol_cons,localize_apply,ih] change (χ x * t.1 x) * LocalDifferential.symbol t.2 ξ + χ x * testSymbol ts x ξ = χ x * (t.1 x * LocalDifferential.symbol t.2 ξ + testSymbol ts x ξ) ring omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in lemma localize_order {m : ℕ} (χ : 𝓢(E,ℂ)) (hχ : HasCompactSupport χ) (ts : List (Term E)) (hts : ∀ t ∈ ts, t.2.length = m) : ∀ t ∈ localize χ hχ ts, t.2.length = m := by intro t ht obtain ⟨z,hz,rfl⟩ := List.mem_map.mp ht exact hts z hz omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in lemma localize_order_le {m : ℕ} (χ : 𝓢(E,ℂ)) (hχ : HasCompactSupport χ) (ts : List (Term E)) (hts : ∀ t ∈ ts, t.2.length ≤ m) : ∀ t ∈ localize χ hχ ts, t.2.length ≤ m := by intro t ht obtain ⟨z,hz,rfl⟩ := List.mem_map.mp ht exact hts z hz omit [MeasurableSpace E] [BorelSpace E] in lemma local_cutoff_pair (x₀ : E) : ∃ ψ χ : 𝓢(E,ℂ), HasCompactSupport ψ ∧ HasCompactSupport χ ∧ (ψ : E → ℂ) =ᶠ[𝓝 x₀] 1 ∧ χ x₀ = 1 ∧ ∀ x ∈ tsupport ψ, χ x = 1 := by let p : ContDiffBump x₀ := ⟨1/2,1,by norm_num,by norm_num⟩ let c : ContDiffBump x₀ := ⟨2,3,by norm_num,by norm_num⟩ let ψ : 𝓢(E,ℂ) := (p.hasCompactSupport.comp_left (show Complex.ofReal (0:ℝ)=0 by simp)).toSchwartzMap (Complex.ofRealCLM.contDiff.comp p.contDiff) let χ : 𝓢(E,ℂ) := (c.hasCompactSupport.comp_left (show Complex.ofReal (0:ℝ)=0 by simp)).toSchwartzMap (Complex.ofRealCLM.contDiff.comp c.contDiff) have hψs : tsupport ψ = closedBall x₀ 1 := by change tsupport (Complex.ofReal ∘ (p : E → ℝ)) = _ rw [tsupport_comp_eq (by simp),p.tsupport_eq] have hχs : tsupport χ = closedBall x₀ 3 := by change tsupport (Complex.ofReal ∘ (c : E → ℝ)) = _ rw [tsupport_comp_eq (by simp),c.tsupport_eq] refine ⟨ψ,χ,?_,?_,?_,?_,?_⟩ · rw [HasCompactSupport,hψs]; exact isCompact_closedBall _ _ · rw [HasCompactSupport,hχs]; exact isCompact_closedBall _ _ · filter_upwards [p.eventuallyEq_one_of_mem_ball (mem_ball_self (by norm_num : (0:ℝ)<1/2))] with y hy change Complex.ofReal (p y) = 1 simp only [hy,Pi.one_apply,Complex.ofReal_one] · change Complex.ofReal (c x₀) = 1 rw [c.one_of_mem_closedBall (mem_closedBall_self (by norm_num : (0:ℝ)≤2))] rfl · intro x hx change Complex.ofReal (c x) = 1 rw [c.one_of_mem_closedBall ?_] · rfl · rw [hψs,mem_closedBall] at hx exact mem_closedBall.mpr (hx.trans (by norm_num : (1:ℝ)≤2)) theorem smooth_of_compact_weak_square (ts us : List (Term E)) (ht : ∀ t ∈ ts, t.2.length = 2) (hu : ∀ t ∈ us, t.2.length ≤ 1) (hprincipal : ∀ x₀ : E, ∃ A : E →L[ℝ] E, (∀ ξ : E, ξ ≠ 0 → 0 < LocalSymbol.quadratic A ξ) ∧ ∀ ξ, testSymbol ts x₀ ξ = (LocalSymbol.quadratic A ξ : ℂ)) (f : Lp ℂ 2 (volume : Measure E)) (hweak : ∀ φ : E → ℂ, ContDiff ℝ ∞ φ → HasCompactSupport φ → (∫ x, operator (ts++us) (operator (ts++us) φ - φ) x * f x) = 0) : ∃ w : E → ℂ, ContDiff ℝ ∞ w ∧ (f : E → ℂ) =ᵐ[volume] w := by apply SchwartzOperator.smooth_of_weak_square f intro x₀ obtain ⟨ψ,χ,hψc,hχc,hψ,hχ₀,hχ⟩ := local_cutoff_pair x₀ obtain ⟨A,hA,hsym⟩ := hprincipal x₀ refine ⟨localize χ hχc ts,localize χ hχc us,A, localize_order χ hχc ts ht,localize_order_le χ hχc us hu,hA,?_,ψ,hψ,?_⟩ · intro ξ rw [localize_symbol,hχ₀,one_mul,hsym] · intro φ rw [Lp.toTemperedDistribution_apply] have hcover : ∀ x ∈ tsupport (product ψ φ), χ x = 1 := by intro x hx apply hχ simp only [show (product ψ φ : E → ℂ) = (fun y => ψ y * φ y) from funext (product_apply ψ φ)] at hx exact tsupport_mul_subset_left hx have heq := localize_square χ hχc (ts++us) (product ψ φ) hcover rw [localize_append] at heq simp_rw [congrFun heq] apply hweak _ (product ψ φ).smooth' change HasCompactSupport ((product ψ φ) : E → ℂ) rw [show (product ψ φ : E → ℂ) = (fun y => ψ y * φ y) from funext (product_apply ψ φ)] exact hψc.mul_right end SmoothOperator namespace RealSmoothOperator section open MeasureTheory open scoped ContDiff variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] structure Coefficient (E : Type*) [NormedAddCommGroup E] [NormedSpace ℝ E] where fn : E → ℝ smooth : ContDiff ℝ ∞ fn instance : CoeFun (Coefficient E) (fun _ => E → ℝ) := ⟨Coefficient.fn⟩ abbrev Term (E : Type*) [NormedAddCommGroup E] [NormedSpace ℝ E] := Coefficient E × List E def derivative : List E → (E → ℝ) → E → ℝ | [], f => f | v::vs, f => fun x => fderiv ℝ (derivative vs f) x v lemma derivative_smooth (vs : List E) {f : E → ℝ} (hf : ContDiff ℝ ∞ f) : ContDiff ℝ ∞ (derivative vs f) := by induction vs with | nil => exact hf | cons v vs ih => exact (ih.fderiv_right (m:=∞) (by simp)).clm_apply contDiff_const lemma derivative_compact (vs : List E) {f : E → ℝ} (hf : HasCompactSupport f) : HasCompactSupport (derivative vs f) := by induction vs with | nil => exact hf | cons v vs ih => exact ih.fderiv_apply ℝ v def operator (ts : List (Term E)) (f : E → ℝ) : E → ℝ := (ts.map (fun t => fun x => t.1 x * derivative t.2 f x)).sum lemma operator_smooth (ts : List (Term E)) {f : E → ℝ} (hf : ContDiff ℝ ∞ f) : ContDiff ℝ ∞ (operator ts f) := by induction ts with | nil => exact contDiff_const | cons t ts ih => exact (t.1.smooth.mul (derivative_smooth t.2 hf)).add ih lemma operator_compact (ts : List (Term E)) {f : E → ℝ} (hf : HasCompactSupport f) : HasCompactSupport (operator ts f) := by induction ts with | nil => simpa only [operator,List.map_nil,List.sum_nil] using (HasCompactSupport.zero : HasCompactSupport (0 : E → ℝ)) | cons t ts ih => exact ((derivative_compact t.2 hf).mul_left).add ih end section variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] def complexifyTerm (t : Term E) : SmoothOperator.Term E := (⟨fun x => (t.1 x : ℂ), Complex.ofRealCLM.contDiff.comp t.1.smooth⟩, t.2) def complexify (ts : List (Term E)) : List (SmoothOperator.Term E) := ts.map complexifyTerm lemma derivative_re (vs : List E) {f : E → ℂ} (hf : ContDiff ℝ ∞ f) : (fun x => (SmoothOperator.derivative vs f x).re) = derivative vs (fun x => (f x).re) := by induction vs with | nil => rfl | cons v vs ih => change (fun x => (fderiv ℝ (SmoothOperator.derivative vs f) x v).re) = fun x => fderiv ℝ (derivative vs (fun x => (f x).re)) x v rw [← ih] ext x have hh := (Complex.reCLM.hasFDerivAt.comp x ((SmoothOperator.derivative_smooth vs hf).differentiable (by simp) x).hasFDerivAt).fderiv exact (congrArg (fun L => L v) hh).symm lemma derivative_im (vs : List E) {f : E → ℂ} (hf : ContDiff ℝ ∞ f) : (fun x => (SmoothOperator.derivative vs f x).im) = derivative vs (fun x => (f x).im) := by induction vs with | nil => rfl | cons v vs ih => change (fun x => (fderiv ℝ (SmoothOperator.derivative vs f) x v).im) = fun x => fderiv ℝ (derivative vs (fun x => (f x).im)) x v rw [← ih] ext x have hh := (Complex.imCLM.hasFDerivAt.comp x ((SmoothOperator.derivative_smooth vs hf).differentiable (by simp) x).hasFDerivAt).fderiv exact (congrArg (fun L => L v) hh).symm lemma operator_re (ts : List (Term E)) {f : E → ℂ} (hf : ContDiff ℝ ∞ f) : (fun x => (SmoothOperator.operator (complexify ts) f x).re) = operator ts (fun x => (f x).re) := by induction ts with | nil => rfl | cons t ts ih => ext x change ((t.1 x : ℂ) * SmoothOperator.derivative t.2 f x + SmoothOperator.operator (complexify ts) f x).re = _ simp only [Complex.add_re,Complex.mul_re,Complex.ofReal_re,Complex.ofReal_im,zero_mul,sub_zero] rw [congrFun (derivative_re t.2 hf) x,congrFun ih x] rfl lemma operator_im (ts : List (Term E)) {f : E → ℂ} (hf : ContDiff ℝ ∞ f) : (fun x => (SmoothOperator.operator (complexify ts) f x).im) = operator ts (fun x => (f x).im) := by induction ts with | nil => rfl | cons t ts ih => ext x change ((t.1 x : ℂ) * SmoothOperator.derivative t.2 f x + SmoothOperator.operator (complexify ts) f x).im = _ simp only [Complex.add_im,Complex.mul_im,Complex.ofReal_re,Complex.ofReal_im,zero_mul,add_zero] rw [congrFun (derivative_im t.2 hf) x,congrFun ih x] rfl lemma square_re (ts : List (Term E)) {f : E → ℂ} (hf : ContDiff ℝ ∞ f) : (fun x => (SmoothOperator.operator (complexify ts) (SmoothOperator.operator (complexify ts) f-f) x).re) = operator ts (operator ts (fun x => (f x).re) - (fun x => (f x).re)) := by rw [operator_re ts (f := SmoothOperator.operator (complexify ts) f-f) ((SmoothOperator.operator_smooth (complexify ts) hf).sub hf)] congr 1 ext x simp only [Pi.sub_apply,Complex.sub_re] rw [congrFun (operator_re ts hf) x] lemma square_im (ts : List (Term E)) {f : E → ℂ} (hf : ContDiff ℝ ∞ f) : (fun x => (SmoothOperator.operator (complexify ts) (SmoothOperator.operator (complexify ts) f-f) x).im) = operator ts (operator ts (fun x => (f x).im) - (fun x => (f x).im)) := by rw [operator_im ts (f := SmoothOperator.operator (complexify ts) f-f) ((SmoothOperator.operator_smooth (complexify ts) hf).sub hf)] congr 1 ext x simp only [Pi.sub_apply,Complex.sub_im] rw [congrFun (operator_im ts hf) x] variable [MeasurableSpace E] (μ : Measure E) [IsFiniteMeasureOnCompacts μ] [BorelSpace E] lemma complex_weak_square (ts : List (Term E)) (f : E → ℝ) (hf : MemLp f 2 μ) (hw : ∀ φ : E → ℝ, ContDiff ℝ ∞ φ → HasCompactSupport φ → (∫ x, operator ts (operator ts φ-φ) x*f x ∂μ)=0) {φ : E → ℂ} (hφ : ContDiff ℝ ∞ φ) (hc : HasCompactSupport φ) : (∫ x, SmoothOperator.operator (complexify ts) (SmoothOperator.operator (complexify ts) φ-φ) x*(f x : ℂ) ∂μ)=0 := by let q := SmoothOperator.operator (complexify ts) (SmoothOperator.operator (complexify ts) φ-φ) have hqs : ContDiff ℝ ∞ q := SmoothOperator.operator_smooth _ ((SmoothOperator.operator_smooth _ hφ).sub hφ) have hqc : HasCompactSupport q := SmoothOperator.operator_compact _ ((SmoothOperator.operator_compact _ hc).sub hc) have hqi : Integrable (fun x => q x*(f x : ℂ)) μ := (hqs.continuous.memLp_of_hasCompactSupport hqc (p:=2)).integrable_mul hf.ofReal have hr := hw (fun x => (φ x).re) (Complex.reCLM.contDiff.comp hφ) (hc.comp_left (show Complex.re (0:ℂ)=0 from rfl)) have hi := hw (fun x => (φ x).im) (Complex.imCLM.contDiff.comp hφ) (hc.comp_left (show Complex.im (0:ℂ)=0 from rfl)) apply Complex.ext · change Complex.reCLM (∫ x, q x*(f x : ℂ) ∂μ) = 0 rw [← Complex.reCLM.integral_comp_comm hqi] change (∫ x, (q x*(f x : ℂ)).re ∂μ) = 0 simp only [Complex.mul_re,Complex.ofReal_re,Complex.ofReal_im,mul_zero,sub_zero] simpa only [q,congrFun (square_re ts hφ)] using hr · change Complex.imCLM (∫ x, q x*(f x : ℂ) ∂μ) = 0 rw [← Complex.imCLM.integral_comp_comm hqi] change (∫ x, (q x*(f x : ℂ)).im ∂μ) = 0 simp only [Complex.mul_im,Complex.ofReal_re,Complex.ofReal_im,mul_zero,zero_add] simpa only [q,congrFun (square_im ts hφ)] using hi end section open MeasureTheory open scoped ContDiff variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in lemma complexify_append (ts us : List (Term E)) : complexify (ts++us) = complexify ts ++ complexify us := List.map_append theorem smooth_of_weak_square (ts us : List (Term E)) (ht : ∀ t ∈ ts, t.2.length = 2) (hu : ∀ t ∈ us, t.2.length ≤ 1) (hsym : ∀ x₀ : E, ∃ A : E →L[ℝ] E, (∀ ξ : E, ξ ≠ 0 → 0 < LocalSymbol.quadratic A ξ) ∧ ∀ ξ, SmoothOperator.testSymbol (complexify ts) x₀ ξ = (LocalSymbol.quadratic A ξ : ℂ)) (f : E → ℝ) (hf : MemLp f 2 (volume : Measure E)) (hw : ∀ φ : E → ℝ, ContDiff ℝ ∞ φ → HasCompactSupport φ → (∫ x, operator (ts++us) (operator (ts++us) φ-φ) x*f x)=0) : ∃ w : E → ℝ, ContDiff ℝ ∞ w ∧ f =ᵐ[volume] w := by let fc : Lp ℂ 2 (volume : Measure E) := hf.ofReal.toLp (fun x => (f x : ℂ)) have hfc : (fc : E → ℂ) =ᵐ[volume] (fun x => (f x : ℂ)) := hf.ofReal.coeFn_toLp have htc : ∀ t ∈ complexify ts, t.2.length = 2 := by intro t ht' obtain ⟨z,hz,rfl⟩ := List.mem_map.mp ht' exact ht z hz have huc : ∀ t ∈ complexify us, t.2.length ≤ 1 := by intro t ht' obtain ⟨z,hz,rfl⟩ := List.mem_map.mp ht' exact hu z hz obtain ⟨w,hwc,hwe⟩ := SmoothOperator.smooth_of_compact_weak_square (complexify ts) (complexify us) htc huc hsym fc (by intro φ hφ hφc rw [← complexify_append] calc _ = ∫ x, SmoothOperator.operator (complexify (ts++us)) (SmoothOperator.operator (complexify (ts++us)) φ-φ) x * (f x : ℂ) := by apply integral_congr_ae filter_upwards [hfc] with x hx rw [hx] _ = 0 := complex_weak_square volume (ts++us) f hf hw hφ hφc) refine ⟨fun x => (w x).re,Complex.reCLM.contDiff.comp hwc,?_⟩ filter_upwards [hfc,hwe] with x hx hy have hh := congrArg Complex.re (hx.symm.trans hy) exact hh end section variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] variable {F : Type*} [NormedAddCommGroup F] [NormedSpace ℝ F] def pushTerm (e : E ≃L[ℝ] F) (t : Term E) : Term F := (⟨t.1.fn ∘ e.symm, t.1.smooth.comp e.symm.contDiff⟩,t.2.map e) def push (e : E ≃L[ℝ] F) (ts : List (Term E)) : List (Term F) := ts.map (pushTerm e) lemma derivative_push (e : E ≃L[ℝ] F) (vs : List E) {f : E → ℝ} (hf : ContDiff ℝ ∞ f) : derivative (vs.map e) (f ∘ e.symm) = derivative vs f ∘ e.symm := by induction vs with | nil => rfl | cons v vs ih => simp only [List.map_cons,derivative] rw [ih] ext x have hh := (((derivative_smooth vs hf).differentiable (by simp) (e.symm x)).hasFDerivAt.comp x e.symm.hasFDerivAt).fderiv rw [hh] simp lemma operator_push (e : E ≃L[ℝ] F) (ts : List (Term E)) {f : E → ℝ} (hf : ContDiff ℝ ∞ f) : operator (push e ts) (f ∘ e.symm) = operator ts f ∘ e.symm := by induction ts with | nil => rfl | cons t ts ih => ext x change t.1 (e.symm x) * derivative (List.map e t.2) (f ∘ e.symm) x + operator (push e ts) (f ∘ e.symm) x = _ rw [congrFun (derivative_push e t.2 hf) x,congrFun ih x] rfl lemma square_push (e : E ≃L[ℝ] F) (ts : List (Term E)) {f : E → ℝ} (hf : ContDiff ℝ ∞ f) : operator (push e ts) (operator (push e ts) (f ∘ e.symm) - (f ∘ e.symm)) = operator ts (operator ts f-f) ∘ e.symm := by rw [operator_push e ts hf] have he : operator ts f ∘ e.symm - f ∘ e.symm = (operator ts f-f) ∘ e.symm := rfl rw [he,operator_push e ts (f := operator ts f-f) ((operator_smooth ts hf).sub hf)] lemma square_pull (e : E ≃L[ℝ] F) (ts : List (Term E)) {f : F → ℝ} (hf : ContDiff ℝ ∞ f) : operator (push e ts) (operator (push e ts) f-f) ∘ e = operator ts (operator ts (f ∘ e) - (f ∘ e)) := by have hh := square_push e ts (hf.comp e.contDiff) have he : (f ∘ e) ∘ e.symm = f := by ext x; simp rw [he] at hh ext x simpa using congrFun hh (e x) end variable {E : Type*} {F : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [NormedAddCommGroup F] [NormedSpace ℝ F] lemma push_append (e : E ≃L[ℝ] F) (ts us : List (Term E)) : push e (ts++us) = push e ts ++ push e us := List.map_append end RealSmoothOperator namespace MatrixOperator section open MeasureTheory RealSmoothOperator Matrix open scoped ContDiff variable {ι : Type*} [Fintype ι] [DecidableEq ι] abbrev Space (ι : Type*) := ι → ℝ abbrev Euclid (ι : Type*) := EuclideanSpace ℝ ι def e (i : ι) : Space ι := Pi.single i 1 def A (τ : Space ι → Matrix ι ι ℝ) (f : Space ι → ℝ) (x : Space ι) : ℝ := (∑ i, x i * fderiv ℝ f x (e i)) - ∑ i, ∑ j, τ x i j * fderiv ℝ (fun y => fderiv ℝ f y (e j)) x (e i) def principal (τ : Space ι → Matrix ι ι ℝ) (hτ : ∀ i j, ContDiff ℝ ∞ (fun x => τ x i j)) : List (Term (Space ι)) := (Finset.univ : Finset (ι×ι)).toList.map (fun p => (⟨fun x => -τ x p.1 p.2,(hτ p.1 p.2).neg⟩,[e p.1,e p.2])) def drift : List (Term (Space ι)) := (Finset.univ : Finset ι).toList.map (fun i => (⟨fun x => x i,(ContinuousLinearMap.proj i : Space ι →L[ℝ] ℝ).contDiff⟩,[e i])) lemma principal_length (τ : Space ι → Matrix ι ι ℝ) (hτ : ∀ i j, ContDiff ℝ ∞ (fun x => τ x i j)) : ∀ t ∈ principal τ hτ, t.2.length = 2 := by intro t ht obtain ⟨p,_,rfl⟩ := List.mem_map.mp ht rfl lemma drift_length : ∀ t ∈ (drift : List (Term (Space ι))), t.2.length ≤ 1 := by intro t ht obtain ⟨i,_,rfl⟩ := List.mem_map.mp ht norm_num lemma operator_actual (τ : Space ι → Matrix ι ι ℝ) (hτ : ∀ i j, ContDiff ℝ ∞ (fun x => τ x i j)) (f : Space ι → ℝ) : operator (principal τ hτ++drift) f = A τ f := by ext x simp only [operator,principal,drift,List.map_append,List.sum_append,List.map_map, Function.comp_def,Finset.sum_map_toList,Finset.sum_apply,Pi.add_apply, Fintype.sum_prod_type,derivative,e,A,neg_mul,Finset.sum_neg_distrib] ring def coordinates : Space ι ≃L[ℝ] Euclid ι := (PiLp.continuousLinearEquiv 2 ℝ (fun _ : ι => ℝ)).symm lemma principal_push_length (τ : Space ι → Matrix ι ι ℝ) (hτ : ∀ i j, ContDiff ℝ ∞ (fun x => τ x i j)) : ∀ t ∈ push coordinates (principal τ hτ), t.2.length = 2 := by intro t ht obtain ⟨s,hs,rfl⟩ := List.mem_map.mp ht simpa [pushTerm] using principal_length τ hτ s hs lemma drift_push_length : ∀ t ∈ push (coordinates (ι:=ι)) drift, t.2.length ≤ 1 := by intro t ht obtain ⟨s,hs,rfl⟩ := List.mem_map.mp ht simpa [pushTerm] using drift_length s hs lemma inner_coordinates_e (ξ : Euclid ι) (i : ι) : inner ℝ ξ (coordinates (e i)) = ξ.ofLp i := by change inner ℝ ξ (EuclideanSpace.single i 1) = _ simp [EuclideanSpace.inner_single_right] lemma symbol_two (ξ : Euclid ι) (i j : ι) : LocalDifferential.symbol [coordinates (e i),coordinates (e j)] ξ = (-(4*Real.pi^2*(ξ.ofLp i)*(ξ.ofLp j)) : ℝ) := by simp only [LocalDifferential.symbol,inner_coordinates_e,one_mul] push_cast calc _ = 4*(Real.pi : ℂ)^2*((ξ.ofLp i : ℂ)*(ξ.ofLp j : ℂ))*Complex.I^2 := by ring _ = _ := by rw [Complex.I_sq]; ring lemma principal_symbol (τ : Space ι → Matrix ι ι ℝ) (hτ : ∀ i j, ContDiff ℝ ∞ (fun x => τ x i j)) (x ξ : Euclid ι) : SmoothOperator.testSymbol (complexify (push coordinates (principal τ hτ))) x ξ = (4*Real.pi^2*(ξ.ofLp ⬝ᵥ (τ x.ofLp *ᵥ ξ.ofLp)) : ℝ) := by simp only [SmoothOperator.testSymbol,complexify,push,principal,List.map_map, Function.comp_def,Finset.sum_map_toList,Fintype.sum_prod_type] change (∑ i, ∑ j, ((-τ x.ofLp i j : ℝ) : ℂ) * LocalDifferential.symbol [coordinates (e i),coordinates (e j)] ξ) = _ simp_rw [symbol_two] simp only [Matrix.mulVec,dotProduct,Finset.mul_sum,Complex.ofReal_sum,Complex.ofReal_mul, Complex.ofReal_neg] apply Finset.sum_congr rfl intro i _ apply Finset.sum_congr rfl intro j _ push_cast ring def frozen (τ : Matrix ι ι ℝ) : Euclid ι →L[ℝ] Euclid ι := (4*Real.pi^2) • (Matrix.toLpLin 2 2 τ).toContinuousLinearMap lemma quadratic_frozen (τ : Matrix ι ι ℝ) (ξ : Euclid ι) : LocalSymbol.quadratic (frozen τ) ξ = 4*Real.pi^2*(ξ.ofLp ⬝ᵥ (τ *ᵥ ξ.ofLp)) := by change inner ℝ ξ ((4*Real.pi^2) • WithLp.toLp 2 (τ *ᵥ ξ.ofLp)) = _ rw [inner_smul_right,EuclideanSpace.inner_eq_star_dotProduct] simp only [star_trivial] rw [dotProduct_comm] lemma principal_elliptic (τ : Space ι → Matrix ι ι ℝ) (hτ : ∀ i j, ContDiff ℝ ∞ (fun x => τ x i j)) (hp : ∀ x, (τ x).PosDef) : ∀ x₀ : Euclid ι, ∃ B : Euclid ι →L[ℝ] Euclid ι, (∀ ξ : Euclid ι, ξ ≠ 0 → 0 < LocalSymbol.quadratic B ξ) ∧ ∀ ξ, SmoothOperator.testSymbol (complexify (push coordinates (principal τ hτ))) x₀ ξ = (LocalSymbol.quadratic B ξ : ℂ) := by intro x₀ refine ⟨frozen (τ x₀.ofLp),?_,?_⟩ · intro ξ hξ rw [quadratic_frozen] apply mul_pos (by positivity) have hne : ξ.ofLp ≠ 0 := by intro he apply hξ exact (WithLp.linearEquiv 2 ℝ (ι → ℝ)).injective he simpa only [star_trivial] using (hp x₀.ofLp).dotProduct_mulVec_pos hne · intro ξ rw [principal_symbol,quadratic_frozen] lemma weak_coordinate_square (τ : Space ι → Matrix ι ι ℝ) (hτ : ∀ i j, ContDiff ℝ ∞ (fun x => τ x i j)) (f : Space ι → ℝ) (hw : ∀ ψ : Space ι → ℝ, ContDiff ℝ ∞ ψ → HasCompactSupport ψ → (∫ x : Space ι, A τ (A τ ψ-ψ) x*f x)=0) (ψ : Euclid ι → ℝ) (hψ : ContDiff ℝ ∞ ψ) (hc : HasCompactSupport ψ) : (∫ x : Euclid ι, operator (push coordinates (principal τ hτ)++push coordinates drift) (operator (push coordinates (principal τ hτ)++push coordinates drift) ψ-ψ) x * f (coordinates.symm x)) = 0 := by let φ : Space ι → ℝ := ψ ∘ coordinates have hφ : ContDiff ℝ ∞ φ := hψ.comp (coordinates (ι:=ι)).contDiff have hφc : HasCompactSupport φ := hc.comp_homeomorph coordinates.toHomeomorph have he : φ ∘ coordinates.symm = ψ := by ext x; simp [φ] have hs := square_push (E := Space ι) (F := Euclid ι) coordinates (principal τ hτ++drift) hφ rw [he,push_append] at hs simp only [operator_actual] at hs rw [hs] change (∫ x : Euclid ι, A τ (A τ φ-φ) (coordinates.symm x)*f (coordinates.symm x)) = 0 have hm := (PiLp.volume_preserving_ofLp ι).integral_comp coordinates.symm.toHomeomorph.measurableEmbedding (fun x : Space ι => A τ (A τ φ-φ) x*f x) change (∫ x : Euclid ι, A τ (A τ φ-φ) (coordinates.symm x)*f (coordinates.symm x)) = _ at hm rw [hm] exact hw φ hφ hφc end open MeasureTheory RealSmoothOperator open scoped ContDiff variable {ι : Type*} [Fintype ι] [DecidableEq ι] theorem smooth_of_weak_square (τ : Space ι → Matrix ι ι ℝ) (hτ : ∀ i j, ContDiff ℝ ∞ (fun x => τ x i j)) (hp : ∀ x, (τ x).PosDef) (f : Space ι → ℝ) (hf : MemLp f 2 volume) (hw : ∀ ψ : Space ι → ℝ, ContDiff ℝ ∞ ψ → HasCompactSupport ψ → (∫ x, A τ (A τ ψ-ψ) x*f x)=0) : ∃ w : Space ι → ℝ, ContDiff ℝ ∞ w ∧ f =ᵐ[volume] w := by let fc : Euclid ι → ℝ := f ∘ (coordinates (ι:=ι)).symm have hfc : MemLp fc 2 volume := hf.comp_measurePreserving (PiLp.volume_preserving_ofLp ι) obtain ⟨w,hws,hwe⟩ := RealSmoothOperator.smooth_of_weak_square (E := Euclid ι) (push (coordinates (ι:=ι)) (principal τ hτ)) (push (coordinates (ι:=ι)) (drift (ι:=ι))) (principal_push_length τ hτ) (drift_push_length (ι:=ι)) (principal_elliptic τ hτ hp) fc hfc (weak_coordinate_square τ hτ f hw) refine ⟨w ∘ (coordinates (ι:=ι)),hws.comp (coordinates (ι:=ι)).contDiff,?_⟩ have hh := (PiLp.volume_preserving_toLp ι).quasiMeasurePreserving.ae hwe filter_upwards [hh] with x hx exact hx end MatrixOperator namespace WeightedRegularity open MeasureTheory open scoped ContDiff variable {E : Type*} [MeasurableSpace E] def densityMeasure (μ : Measure E) (ρ : E → ℝ) : Measure E := μ.withDensity (fun x => ENNReal.ofReal (ρ x)) lemma density_absolutelyContinuous (μ : Measure E) {ρ : E → ℝ} (hm : Measurable ρ) (hp : ∀ x, 0 < ρ x) : μ ≪ densityMeasure μ ρ := by exact withDensity_absolutelyContinuous' (ENNReal.measurable_ofReal.comp hm).aemeasurable (Filter.Eventually.of_forall fun x => by exact (ENNReal.ofReal_pos.mpr (hp x)).ne') lemma integral_density (μ : Measure E) {ρ : E → ℝ} (hm : Measurable ρ) (hp : ∀ x, 0 ≤ ρ x) (f : E → ℝ) : (∫ x, f x ∂densityMeasure μ ρ) = ∫ x, ρ x*f x ∂μ := by have hh := integral_withDensity_eq_integral_toReal_smul (μ:=μ) (f := fun x => ENNReal.ofReal (ρ x)) (ENNReal.measurable_ofReal.comp hm) (Filter.Eventually.of_forall fun _ => ENNReal.ofReal_lt_top) f simpa only [densityMeasure,Function.comp_apply,ENNReal.toReal_ofReal (hp _),smul_eq_mul] using hh lemma density_mul_memLp (μ : Measure E) {ρ : E → ℝ} (hm : Measurable ρ) (hp : ∀ x, 0 < ρ x) {C : ℝ} (hC : ∀ x, ρ x ≤ C) {g : E → ℝ} (hg : MemLp g 2 (densityMeasure μ ρ)) : MemLp (fun x => ρ x*g x) 2 μ := by have hga : AEStronglyMeasurable g μ := hg.aestronglyMeasurable.mono_ac (density_absolutelyContinuous μ hm hp) have ha : AEStronglyMeasurable (fun x => ρ x*g x) μ := hm.aestronglyMeasurable.mul hga apply (memLp_two_iff_integrable_sq ha).mpr have hi : Integrable (fun x => ρ x*(g x)^2) μ := by have hh := (integrable_withDensity_iff_integrable_smul' (ENNReal.measurable_ofReal.comp hm) (Filter.Eventually.of_forall fun _ => ENNReal.ofReal_lt_top)).mp hg.integrable_sq simpa only [Function.comp_apply,ENNReal.toReal_ofReal (hp _).le,smul_eq_mul] using hh apply (hi.const_mul C).mono' (ha.pow 2) filter_upwards [] with x rw [Real.norm_eq_abs,abs_of_nonneg (sq_nonneg _)] have hb := mul_le_mul_of_nonneg_right (hC x) (mul_nonneg (hp x).le (sq_nonneg (g x))) change (ρ x*g x)^2 ≤ C*(ρ x*g x^2) nlinarith lemma weighted_weak (μ : Measure E) {ρ : E → ℝ} (hm : Measurable ρ) (hp : ∀ x, 0 ≤ ρ x) (g q : E → ℝ) (h : (∫ x, q x*g x ∂densityMeasure μ ρ)=0) : (∫ x, q x*(ρ x*g x) ∂μ)=0 := by rw [integral_density μ hm hp] at h simpa only [mul_left_comm (ρ _) (q _)] using h variable [NormedAddCommGroup E] [NormedSpace ℝ E] [BorelSpace E] omit [BorelSpace E] in lemma smooth_density_quotient (μ : Measure E) {ρ g w : E → ℝ} (hρ : ContDiff ℝ ∞ ρ) (hp : ∀ x, 0 < ρ x) (hw : ContDiff ℝ ∞ w) (he : (fun x => ρ x*g x) =ᵐ[μ] w) : ∃ v : E → ℝ, ContDiff ℝ ∞ v ∧ g =ᵐ[densityMeasure μ ρ] v := by refine ⟨fun x => w x/ρ x,hw.div hρ (fun x => (hp x).ne'),?_⟩ apply (withDensity_absolutelyContinuous μ _).ae_le filter_upwards [he] with x hx rw [← hx,mul_div_cancel_left₀ _ (hp x).ne'] omit [NormedSpace ℝ E] in lemma integral_reflect (μ : Measure E) [μ.IsNegInvariant] {ρ : E → ℝ} (hm : Measurable ρ) (hp : ∀ x, 0 ≤ ρ x) (he : ∀ x, ρ (-x)=ρ x) (f : E → ℝ) : (∫ x, f (-x) ∂densityMeasure μ ρ) = ∫ x, f x ∂densityMeasure μ ρ := by rw [integral_density μ hm hp,integral_density μ hm hp] have hh := integral_neg_eq_self (fun x => ρ x*f x) μ simpa only [he] using hh end WeightedRegularity namespace MatrixOperator open MeasureTheory WeightedRegularity open scoped ContDiff variable {ι : Type*} [Fintype ι] [DecidableEq ι] theorem smooth_of_weighted_weak_square (τ : Space ι → Matrix ι ι ℝ) (hτ : ∀ i j, ContDiff ℝ ∞ (fun x => τ x i j)) (hp : ∀ x, (τ x).PosDef) (ρ : Space ι → ℝ) (hρ : ContDiff ℝ ∞ ρ) (hρp : ∀ x, 0 < ρ x) {C : ℝ} (hρC : ∀ x, ρ x ≤ C) (f : Space ι → ℝ) (hf : MemLp f 2 (densityMeasure volume ρ)) (hw : ∀ ψ : Space ι → ℝ, ContDiff ℝ ∞ ψ → HasCompactSupport ψ → (∫ x, A τ (A τ ψ-ψ) x*f x ∂densityMeasure volume ρ)=0) : ∃ w : Space ι → ℝ, ContDiff ℝ ∞ w ∧ f =ᵐ[densityMeasure volume ρ] w := by have hf' := density_mul_memLp volume hρ.continuous.measurable hρp hρC hf obtain ⟨w,hws,hwe⟩ := smooth_of_weak_square τ hτ hp (fun x => ρ x*f x) hf' (by intro ψ hψ hc exact weighted_weak volume hρ.continuous.measurable (fun x => (hρp x).le) f (A τ (A τ ψ-ψ)) (hw ψ hψ hc)) exact smooth_density_quotient volume hρ hρp hws hwe end MatrixOperator end open MeasureTheory open scoped Topology ContDiff noncomputable section namespace WeightedCalculus variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] def D (v : E) (f : E → ℝ) : E → ℝ := fun x => fderiv ℝ f x v def adjoint (V : E → ℝ) (v : E) (f : E → ℝ) : E → ℝ := fun x => D v V x * f x - D v f x def weight (V : E → ℝ) : E → ℝ := fun x => Real.exp (-V x) lemma smooth_D {f : E → ℝ} (hf : ContDiff ℝ ∞ f) (v : E) : ContDiff ℝ ∞ (D v f) := by exact (hf.fderiv_right (by simp)).clm_apply contDiff_const lemma compact_D {f : E → ℝ} (hf : HasCompactSupport f) (v : E) : HasCompactSupport (D v f) := hf.fderiv_apply ℝ v lemma D_add {f g : E → ℝ} (hf : Differentiable ℝ f) (hg : Differentiable ℝ g) (v : E) : D v (fun x => f x + g x) = fun x => D v f x + D v g x := by funext x simp only [D, fderiv_fun_add (hf x) (hg x), add_apply] lemma D_sub {f g : E → ℝ} (hf : Differentiable ℝ f) (hg : Differentiable ℝ g) (v : E) : D v (fun x => f x - g x) = fun x => D v f x - D v g x := by funext x simp only [D, fderiv_fun_sub (hf x) (hg x), sub_apply] lemma D_mul {f g : E → ℝ} (hf : Differentiable ℝ f) (hg : Differentiable ℝ g) (v : E) : D v (fun x => f x * g x) = fun x => D v f x * g x + f x * D v g x := by funext x simp only [D, fderiv_fun_mul (hf x) (hg x), add_apply, smul_apply, smul_eq_mul] ring lemma D_comm {f : E → ℝ} (hf : ContDiff ℝ ∞ f) (v w : E) : D v (D w f) = D w (D v f) := by have hdf := (hf.fderiv_right (m := ∞) (by simp)).differentiable (by simp) funext x change fderiv ℝ (fun x => fderiv ℝ f x w) x v = fderiv ℝ (fun x => fderiv ℝ f x v) x w simp only [fderiv_clm_apply (hdf x) (differentiableAt_const _), fderiv_const_apply, ContinuousLinearMap.comp_zero, zero_add, ContinuousLinearMap.flip_apply] apply hf.contDiffAt.isSymmSndFDerivAt _ v w simp only [minSmoothness_of_isRCLikeNormedField] exact WithTop.coe_le_coe.mpr (le_top : (2 : ℕ∞) ≤ ⊤) lemma smooth_adjoint {V f : E → ℝ} (hV : ContDiff ℝ ∞ V) (hf : ContDiff ℝ ∞ f) (v : E) : ContDiff ℝ ∞ (adjoint V v f) := by exact ((smooth_D hV v).mul hf).sub (smooth_D hf v) lemma compact_adjoint {V f : E → ℝ} (hf : HasCompactSupport f) (v : E) : HasCompactSupport (adjoint V v f) := by exact hf.mul_left.sub (compact_D hf v) lemma smooth_weight {V : E → ℝ} (hV : ContDiff ℝ ∞ V) : ContDiff ℝ ∞ (weight V) := hV.neg.exp lemma D_weight {V : E → ℝ} (hV : ContDiff ℝ ∞ V) (v : E) : D v (weight V) = fun x => -D v V x * weight V x := by funext x have hx := ((hV.differentiable (by simp) x).hasFDerivAt.neg.exp).fderiv change fderiv ℝ (fun x => Real.exp (-V x)) x v = -fderiv ℝ V x v * Real.exp (-V x) simpa [smul_apply, mul_comm] using congrArg (fun A => A v) hx lemma commutator {V f : E → ℝ} (hV : ContDiff ℝ ∞ V) (hf : ContDiff ℝ ∞ f) (v w : E) : D w (adjoint V v f) = fun x => D w (D v V) x * f x + adjoint V v (D w f) x := by have hV' := (smooth_D hV v).differentiable (by simp) have hf' := (smooth_D hf v).differentiable (by simp) unfold adjoint rw [D_sub (f := fun x => D v V x * f x) (g := D v f) (fun x => (hV' x).mul (hf.differentiable (by simp) x)) hf', D_mul hV' (hf.differentiable (by simp)), D_comm hf w v] funext x ring section FiniteDirections variable {ι : Type*} [Fintype ι] lemma D_sum (f : ι → E → ℝ) (hf : ∀ i, Differentiable ℝ (f i)) (v : E) : D v (fun x => ∑ i, f i x) = fun x => ∑ i, D v (f i) x := by funext x simp only [D, fderiv_fun_sum (fun i _ => hf i x), sum_apply] lemma smooth_sum (f : ι → E → ℝ) (hf : ∀ i, ContDiff ℝ ∞ (f i)) : ContDiff ℝ ∞ (fun x => ∑ i, f i x) := ContDiff.sum (fun i _ => hf i) omit [NormedSpace ℝ E] in lemma compact_sum (f : ι → E → ℝ) (hf : ∀ i, HasCompactSupport (f i)) : HasCompactSupport (fun x => ∑ i, f i x) := by have heq : (fun x => ∑ i, f i x) = ∑ i, f i := by funext x exact (Finset.sum_apply x Finset.univ f).symm rw [heq] exact HasCompactSupport.finset_sum (fun i _ => hf i) def divergence (V : E → ℝ) (e : ι → E) (W : ι → E → ℝ) : E → ℝ := fun x => ∑ i, adjoint V (e i) (W i) x lemma smooth_divergence {V : E → ℝ} {e : ι → E} {W : ι → E → ℝ} (hV : ContDiff ℝ ∞ V) (hW : ∀ i, ContDiff ℝ ∞ (W i)) : ContDiff ℝ ∞ (divergence V e W) := smooth_sum _ (fun i => smooth_adjoint hV (hW i) (e i)) lemma compact_divergence {V : E → ℝ} {e : ι → E} {W : ι → E → ℝ} (hW : ∀ i, HasCompactSupport (W i)) : HasCompactSupport (divergence V e W) := compact_sum _ (fun i => compact_adjoint (V := V) (hW i) (e i)) lemma D_divergence {V : E → ℝ} {e : ι → E} {W : ι → E → ℝ} (hV : ContDiff ℝ ∞ V) (hW : ∀ i, ContDiff ℝ ∞ (W i)) (v : E) : D v (divergence V e W) = fun x => ∑ i, (D v (D (e i) V) x * W i x + adjoint V (e i) (D v (W i)) x) := by unfold divergence rw [D_sum _ (fun i => (smooth_adjoint hV (hW i) (e i)).differentiable (by simp))] simp_rw [commutator hV (hW _) _ v] end FiniteDirections variable [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] variable (μ : Measure E) [Measure.IsAddHaarMeasure μ] def expectation (V f : E → ℝ) : ℝ := ∫ x, f x * weight V x ∂μ omit [FiniteDimensional ℝ E] in lemma integrable_weighted {V f : E → ℝ} (hV : ContDiff ℝ ∞ V) (hf : Continuous f) (hfc : HasCompactSupport f) : Integrable (fun x => f x * weight V x) μ := (hf.mul (smooth_weight hV).continuous).integrable_of_hasCompactSupport hfc.mul_right theorem integration_by_parts {V f g : E → ℝ} (hV : ContDiff ℝ ∞ V) (hf : ContDiff ℝ ∞ f) (hg : ContDiff ℝ ∞ g) (hfc : HasCompactSupport f) (v : E) : expectation μ V (fun x => D v g x * f x) = expectation μ V (fun x => g x * adjoint V v f x) := by let fw : E → ℝ := fun x => f x * weight V x have hfw : ContDiff ℝ ∞ fw := hf.mul (smooth_weight hV) have hfwc : HasCompactSupport fw := hfc.mul_right have hi₁ : Integrable (fun x => D v fw x * g x) μ := ((smooth_D hfw v).continuous.mul hg.continuous).integrable_of_hasCompactSupport (compact_D hfwc v).mul_right have hi₂ : Integrable (fun x => fw x * D v g x) μ := (hfw.continuous.mul (smooth_D hg v).continuous).integrable_of_hasCompactSupport hfwc.mul_right have hi₃ : Integrable (fun x => fw x * g x) μ := (hfw.continuous.mul hg.continuous).integrable_of_hasCompactSupport hfwc.mul_right have hp := integral_mul_fderiv_eq_neg_fderiv_mul_of_integrable hi₁ hi₂ hi₃ (fun x _ => hfw.differentiable (by simp) x) (fun x _ => hg.differentiable (by simp) x) calc _ = ∫ x, fw x * D v g x ∂μ := by apply integral_congr_ae filter_upwards [] with x dsimp [expectation, fw] ring _ = -∫ x, D v fw x * g x ∂μ := hp _ = _ := by rw [← integral_neg] apply integral_congr_ae filter_upwards [] with x dsimp [fw] at * rw [D_mul (hf.differentiable (by simp)) ((smooth_weight hV).differentiable (by simp)), D_weight hV v] dsimp [adjoint] ring variable {ι : Type*} [Fintype ι] omit [FiniteDimensional ℝ E] in lemma expectation_add {V f g : E → ℝ} (hV : ContDiff ℝ ∞ V) (hf : Continuous f) (hg : Continuous g) (hfc : HasCompactSupport f) (hgc : HasCompactSupport g) : expectation μ V (fun x => f x + g x) = expectation μ V f + expectation μ V g := by simp only [expectation, add_mul] exact integral_add (integrable_weighted μ hV hf hfc) (integrable_weighted μ hV hg hgc) omit [FiniteDimensional ℝ E] in lemma expectation_sum {V : E → ℝ} (hV : ContDiff ℝ ∞ V) (f : ι → E → ℝ) (hf : ∀ i, Continuous (f i)) (hfc : ∀ i, HasCompactSupport (f i)) : expectation μ V (fun x => ∑ i, f i x) = ∑ i, expectation μ V (f i) := by simp only [expectation, Finset.sum_mul] exact integral_finsetSum _ (fun i _ => integrable_weighted μ hV (hf i) (hfc i)) lemma divergence_adjoint {V g : E → ℝ} (e : ι → E) (W : ι → E → ℝ) (hV : ContDiff ℝ ∞ V) (hW : ∀ i, ContDiff ℝ ∞ (W i)) (hg : ContDiff ℝ ∞ g) (hWc : ∀ i, HasCompactSupport (W i)) : expectation μ V (fun x => g x * divergence V e W x) = ∑ i, expectation μ V (fun x => D (e i) g x * W i x) := by have heq : (fun x => g x * divergence V e W x) = fun x => ∑ i, g x * adjoint V (e i) (W i) x := by funext x simp only [divergence, Finset.mul_sum] rw [heq, expectation_sum μ hV (fun i x => g x * adjoint V (e i) (W i) x) (fun i => hg.continuous.mul (smooth_adjoint hV (hW i) (e i)).continuous) (fun i => (compact_adjoint (V := V) (hWc i) (e i)).mul_left)] apply Finset.sum_congr rfl intro i _ exact (integration_by_parts μ hV (hW i) hg (hWc i) (e i)).symm theorem bochner {V : E → ℝ} (e : ι → E) (W : ι → E → ℝ) (hV : ContDiff ℝ ∞ V) (hW : ∀ i, ContDiff ℝ ∞ (W i)) (hWc : ∀ i, HasCompactSupport (W i)) : expectation μ V (fun x => (divergence V e W x)^2) = (∑ j, ∑ i, expectation μ V (fun x => D (e j) (D (e i) V) x * W i x * W j x)) + ∑ j, ∑ i, expectation μ V (fun x => D (e i) (W j) x * D (e j) (W i) x) := by have hstep (j : ι) : expectation μ V (fun x => D (e j) (divergence V e W) x * W j x) = (∑ i, expectation μ V (fun x => D (e j) (D (e i) V) x * W i x * W j x)) + ∑ i, expectation μ V (fun x => D (e i) (W j) x * D (e j) (W i) x) := by rw [D_divergence hV hW] simp_rw [Finset.sum_mul, add_mul] rw [expectation_sum μ hV _] · rw [← Finset.sum_add_distrib] apply Finset.sum_congr rfl intro i _ rw [expectation_add μ hV] · congr 1 have heq : (fun x => adjoint V (e i) (D (e j) (W i)) x * W j x) = fun x => W j x * adjoint V (e i) (D (e j) (W i)) x := by funext x; ring rw [heq] exact (integration_by_parts μ hV (smooth_D (hW i) (e j)) (hW j) (compact_D (hWc i) (e j)) (e i)).symm · exact (((smooth_D (smooth_D hV (e i)) (e j)).continuous.mul (hW i).continuous).mul (hW j).continuous) · exact (smooth_adjoint hV (smooth_D (hW i) (e j)) (e i)).continuous.mul (hW j).continuous · exact (hWc j).mul_left · exact (hWc j).mul_left · intro i exact ((((smooth_D (smooth_D hV (e i)) (e j)).continuous.mul (hW i).continuous).mul (hW j).continuous).add ((smooth_adjoint hV (smooth_D (hW i) (e j)) (e i)).continuous.mul (hW j).continuous)) · intro i exact ((hWc j).mul_left).add ((hWc j).mul_left) simp_rw [pow_two] rw [divergence_adjoint μ e W hV hW (smooth_divergence hV hW) hWc] simp_rw [hstep] exact Finset.sum_add_distrib end WeightedCalculus namespace MomentCoordinates open WeightedCalculus Matrix open scoped ContDiff variable {ι : Type*} [Fintype ι] [DecidableEq ι] abbrev Space (ι : Type*) := ι → ℝ def basis (i : ι) : Space ι := Pi.single i 1 def pd (i : ι) (f : Space ι → ℝ) : Space ι → ℝ := D (basis i) f def grad (f : Space ι → ℝ) (x : Space ι) : Space ι := fun i => pd i f x def hess (f : Space ι → ℝ) (x : Space ι) : Matrix ι ι ℝ := fun i j => pd j (pd i f) x lemma basis_sum (v : Space ι) : ∑ i, v i • basis i = v := by ext j simp [basis, Finset.sum_apply, Pi.single_apply] lemma linear_coordinates (L : Space ι →L[ℝ] ℝ) (v : Space ι) : L v = ∑ i, L (basis i) * v i := by conv_lhs => rw [← basis_sum v] simp only [map_sum, map_smul, smul_eq_mul] apply Finset.sum_congr rfl intro i _ ring lemma pd_comp {f : Space ι → ℝ} {F : Space ι → Space ι} (hf : Differentiable ℝ f) (hF : Differentiable ℝ F) (j : ι) : pd j (f ∘ F) = fun x => ∑ i, pd i f (F x) * pd j (fun y => F y i) x := by funext x simp only [pd, D, fderiv_comp x (hf (F x)) (hF x), ContinuousLinearMap.comp_apply] rw [linear_coordinates] apply Finset.sum_congr rfl intro i _ rw [fderiv_apply (hF x) i] rfl lemma pd_coord (i j : ι) : pd j (fun x : Space ι => x i) = fun _ => if i = j then 1 else 0 := by funext x change fderiv ℝ (ContinuousLinearMap.proj i : Space ι →L[ℝ] ℝ) x (basis j) = _ simp [basis, Pi.single_apply] lemma smooth_pd {f : Space ι → ℝ} (hf : ContDiff ℝ ∞ f) (i : ι) : ContDiff ℝ ∞ (pd i f) := smooth_D hf (basis i) lemma smooth_grad {f : Space ι → ℝ} (hf : ContDiff ℝ ∞ f) : ContDiff ℝ ∞ (grad f) := contDiff_pi.mpr (fun i => smooth_pd hf i) lemma pd_comm {f : Space ι → ℝ} (hf : ContDiff ℝ ∞ f) (i j : ι) : pd i (pd j f) = pd j (pd i f) := D_comm hf _ _ lemma hess_symm {f : Space ι → ℝ} (hf : ContDiff ℝ ∞ f) (x : Space ι) (i j : ι) : hess f x i j = hess f x j i := congrFun (pd_comm hf j i) x lemma pd_comp_grad {f φ : Space ι → ℝ} (hf : ContDiff ℝ ∞ f) (hφ : ContDiff ℝ ∞ φ) (a : ι) : pd a (f ∘ grad φ) = fun z => ∑ i, hess φ z a i * pd i f (grad φ z) := by rw [pd_comp (hf.differentiable (by simp)) ((smooth_grad hφ).differentiable (by simp))] funext z apply Finset.sum_congr rfl intro i _ change pd i f (grad φ z) * hess φ z i a = _ rw [hess_symm hφ z i a] ring def pullA (φ f : Space ι → ℝ) : Space ι → ℝ := fun z => (∑ i, grad φ z i * pd i f (grad φ z)) - ∑ i, ∑ j, hess φ z i j * hess f (grad φ z) i j def P (φ f : Space ι → ℝ) (a k : ι) : Space ι → ℝ := fun z => ∑ i, hess φ z a i * hess f (grad φ z) i k def W (φ f : Space ι → ℝ) (a : ι) : Space ι → ℝ := divergence φ basis (P φ f a) lemma pd_sum (g : ι → Space ι → ℝ) (hg : ∀ i, ContDiff ℝ ∞ (g i)) (a : ι) : pd a (fun z => ∑ i, g i z) = fun z => ∑ i, pd a (g i) z := D_sum g (fun i => (hg i).differentiable (by simp)) (basis a) lemma pd_sub {g k : Space ι → ℝ} (hg : ContDiff ℝ ∞ g) (hk : ContDiff ℝ ∞ k) (a : ι) : pd a (fun z => g z - k z) = fun z => pd a g z - pd a k z := D_sub (hg.differentiable (by simp)) (hk.differentiable (by simp)) (basis a) lemma pullA_divergence {φ f : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hf : ContDiff ℝ ∞ f) : pullA φ f = divergence φ basis (fun i => pd i f ∘ grad φ) := by funext z simp only [pullA, divergence, adjoint, ← Finset.sum_sub_distrib] apply Finset.sum_congr rfl intro i _ change grad φ z i * pd i f (grad φ z) - ∑ j, hess φ z i j * hess f (grad φ z) i j = pd i φ z * pd i f (grad φ z) - pd i (pd i f ∘ grad φ) z rw [pd_comp_grad (smooth_pd hf i) hφ i] rfl lemma smooth_pullA {φ f : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hf : ContDiff ℝ ∞ f) : ContDiff ℝ ∞ (pullA φ f) := by rw [pullA_divergence hφ hf] exact smooth_divergence hφ (fun i => (smooth_pd hf i).comp (smooth_grad hφ)) lemma P_pd {φ f : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hf : ContDiff ℝ ∞ f) (a i : ι) : P φ f a i = pd a (pd i f ∘ grad φ) := by rw [pd_comp_grad (smooth_pd hf i) hφ a] funext z apply Finset.sum_congr rfl intro j _ change hess φ z a j * hess f (grad φ z) j i = hess φ z a j * hess f (grad φ z) i j rw [hess_symm hf _ j i] lemma smooth_P {φ f : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hf : ContDiff ℝ ∞ f) (a i : ι) : ContDiff ℝ ∞ (P φ f a i) := by rw [P_pd hφ hf] exact smooth_pd ((smooth_pd hf i).comp (smooth_grad hφ)) a lemma smooth_W {φ f : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hf : ContDiff ℝ ∞ f) (a : ι) : ContDiff ℝ ∞ (W φ f a) := smooth_divergence hφ (smooth_P hφ hf a) theorem W_gradient {φ f : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hf : ContDiff ℝ ∞ f) (a : ι) : W φ f a = pd a (fun z => pullA φ f z - f (grad φ z)) := by change W φ f a = pd a (fun z => pullA φ f z - (f ∘ grad φ) z) rw [pd_sub (smooth_pullA hφ hf) (hf.comp (smooth_grad hφ))] have hder := D_divergence (e := basis) hφ (fun i => (smooth_pd hf i).comp (smooth_grad hφ)) (basis a) have hA : pd a (pullA φ f) = fun z => ∑ i, (hess φ z i a * pd i f (grad φ z) + adjoint φ (basis i) (pd a (pd i f ∘ grad φ)) z) := by rw [pullA_divergence hφ hf] exact hder rw [hA, pd_comp_grad hf hφ a] funext z simp only [W, divergence, Finset.sum_add_distrib] have hc : (∑ i, hess φ z i a * pd i f (grad φ z)) = ∑ i, hess φ z a i * pd i f (grad φ z) := by apply Finset.sum_congr rfl intro i _ rw [hess_symm hφ z i a] rw [hc] simp_rw [← P_pd hφ hf] ring lemma W_derivative_symm {φ f : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hf : ContDiff ℝ ∞ f) (a b : ι) : pd b (W φ f a) = pd a (W φ f b) := by simp_rw [W_gradient hφ hf] exact pd_comm ((smooth_pullA hφ hf).sub (hf.comp (smooth_grad hφ))) b a lemma compact_pulled_pd {φ f : Space ι → ℝ} (hfc : HasCompactSupport f) (Φ : Space ι ≃ₜ Space ι) (hΦ : (Φ : Space ι → Space ι) = grad φ) (i : ι) : HasCompactSupport (pd i f ∘ grad φ) := by rw [← hΦ] exact (compact_D hfc (basis i)).comp_homeomorph Φ lemma compact_P {φ f : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hf : ContDiff ℝ ∞ f) (hfc : HasCompactSupport f) (Φ : Space ι ≃ₜ Space ι) (hΦ : (Φ : Space ι → Space ι) = grad φ) (a i : ι) : HasCompactSupport (P φ f a i) := by rw [P_pd hφ hf] exact compact_D (compact_pulled_pd hfc Φ hΦ i) (basis a) lemma compact_W {φ f : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hf : ContDiff ℝ ∞ f) (hfc : HasCompactSupport f) (Φ : Space ι ≃ₜ Space ι) (hΦ : (Φ : Space ι → Space ι) = grad φ) (a : ι) : HasCompactSupport (W φ f a) := compact_divergence (compact_P hφ hf hfc Φ hΦ a) lemma compact_pullA {φ f : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hf : ContDiff ℝ ∞ f) (hfc : HasCompactSupport f) (Φ : Space ι ≃ₜ Space ι) (hΦ : (Φ : Space ι → Space ι) = grad φ) : HasCompactSupport (pullA φ f) := by rw [pullA_divergence hφ hf] exact compact_divergence (compact_pulled_pd hfc Φ hΦ) theorem hessian_identity (μ : Measure (Space ι)) [Measure.IsAddHaarMeasure μ] {φ f : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hf : ContDiff ℝ ∞ f) (hfc : HasCompactSupport f) (Φ : Space ι ≃ₜ Space ι) (hΦ : (Φ : Space ι → Space ι) = grad φ) : expectation μ φ (fun z => pullA φ f z * (pullA φ f z - f (grad φ z))) = ∑ a, ∑ k, expectation μ φ (fun z => P φ f k a z * P φ f a k z) := by let g : Space ι → ℝ := fun z => pullA φ f z - f (grad φ z) have hg : ContDiff ℝ ∞ g := (smooth_pullA hφ hf).sub (hf.comp (smooth_grad hφ)) calc _ = expectation μ φ (fun z => g z * divergence φ basis (fun i => pd i f ∘ grad φ) z) := by congr 1 funext z rw [← pullA_divergence hφ hf] dsimp [g] ring _ = ∑ a, expectation μ φ (fun z => pd a g z * pd a f (grad φ z)) := divergence_adjoint μ basis _ hφ (fun i => (smooth_pd hf i).comp (smooth_grad hφ)) hg (compact_pulled_pd hfc Φ hΦ) _ = ∑ a, expectation μ φ (fun z => pd a f (grad φ z) * W φ f a z) := by apply Finset.sum_congr rfl intro a _ congr 1 funext z rw [W_gradient hφ hf] change pd a g z * pd a f (grad φ z) = pd a f (grad φ z) * pd a g z ring _ = _ := by apply Finset.sum_congr rfl intro a _ change expectation μ φ (fun z => (pd a f ∘ grad φ) z * divergence φ basis (P φ f a) z) = _ rw [divergence_adjoint μ basis _ hφ (smooth_P hφ hf a) ((smooth_pd hf a).comp (smooth_grad hφ)) (compact_P hφ hf hfc Φ hΦ a)] apply Finset.sum_congr rfl intro k _ rw [P_pd hφ hf k a] rfl def B (φ f : Space ι → ℝ) (a l : ι) : Space ι → ℝ := fun z => ∑ k, P φ f a k z * hess φ z k l def R (φ f : Space ι → ℝ) (a l : ι) : Space ι → ℝ := divergence φ basis (fun k => pd l (P φ f a k)) lemma B_eq_matrix (φ f : Space ι → ℝ) (z : Space ι) : (fun a l => B φ f a l z) = hess φ z * hess f (grad φ z) * hess φ z := by ext a l rfl lemma hess_transpose {f : Space ι → ℝ} (hf : ContDiff ℝ ∞ f) (z : Space ι) : (hess f z)ᵀ = hess f z := by ext i j exact hess_symm hf z j i lemma B_symm {φ f : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hf : ContDiff ℝ ∞ f) (z : Space ι) (a l : ι) : B φ f a l z = B φ f l a z := by have ht : (hess φ z * hess f (grad φ z) * hess φ z)ᵀ = hess φ z * hess f (grad φ z) * hess φ z := by simp only [Matrix.transpose_mul, hess_transpose hφ, hess_transpose hf, Matrix.mul_assoc] have heq := congrFun (congrFun ht l) a exact heq lemma W_derivative {φ f : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hf : ContDiff ℝ ∞ f) (a l : ι) : pd l (W φ f a) = fun z => B φ f a l z + R φ f a l z := by change D (basis l) (divergence φ basis (P φ f a)) = _ rw [D_divergence hφ (smooth_P hφ hf a)] funext z simp only [B, R, divergence, Finset.sum_add_distrib] congr 1 apply Finset.sum_congr rfl intro k _ change hess φ z k l * P φ f a k z = P φ f a k z * hess φ z k l ring lemma R_symm {φ f : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hf : ContDiff ℝ ∞ f) (z : Space ι) (a l : ι) : R φ f a l z = R φ f l a z := by have hw := congrFun (W_derivative_symm hφ hf a l) z rw [W_derivative hφ hf a l, W_derivative hφ hf l a] at hw dsimp at hw rw [B_symm hφ hf z a l] at hw linarith end MomentCoordinates end open Matrix open scoped ContDiff Matrix.Norms.Elementwise noncomputable section namespace MomentDifferential variable {ι : Type*} [Fintype ι] [DecidableEq ι] variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] def detMultilinear : ContinuousMultilinearMap ℝ (fun _ : ι => ι → ℝ) ℝ := { (Matrix.detRowAlternating : (ι → ℝ) [⋀^ι]→ₗ[ℝ] ℝ).toMultilinearMap with cont := continuous_id.matrix_det } lemma detMultilinear_apply (A : Matrix ι ι ℝ) : detMultilinear A = A.det := rfl lemma smooth_det : ContDiff ℝ ∞ (fun A : Matrix ι ι ℝ => A.det) := (detMultilinear (ι := ι)).contDiff lemma det_updateRow_eq (A : Matrix ι ι ℝ) (i : ι) (v : ι → ℝ) : (A.updateRow i v).det = ∑ j, A.adjugate j i * v j := by have h := congrFun (Matrix.cramer_eq_adjugate_mulVec Aᵀ v) i simpa only [Matrix.cramer_apply, Matrix.updateCol_transpose, Matrix.det_transpose, ← Matrix.adjugate_transpose, Matrix.mulVec, dotProduct, Matrix.transpose_apply] using h lemma det_linearDeriv (A B : Matrix ι ι ℝ) : detMultilinear.linearDeriv A B = (A.adjugate * B).trace := by change detMultilinear.linearDeriv (fun i j => A i j) (fun i j => B i j) = _ rw [ContinuousMultilinearMap.linearDeriv_apply] change (∑ i, (A.updateRow i (B i)).det) = _ simp_rw [det_updateRow_eq] rw [Finset.sum_comm] rfl theorem fderiv_det_apply (A B : Matrix ι ι ℝ) : fderiv ℝ (fun A : Matrix ι ι ℝ => A.det) A B = (A.adjugate * B).trace := by change fderiv ℝ (detMultilinear (ι := ι)) A B = _ rw [(detMultilinear.hasFDerivAt A).fderiv] exact det_linearDeriv A B lemma smooth_matrix_det {A : E → Matrix ι ι ℝ} (hA : ∀ i j, ContDiff ℝ ∞ (fun z => A z i j)) : ContDiff ℝ ∞ (fun z => (A z).det) := smooth_det.comp (contDiff_pi.mpr (fun i => contDiff_pi.mpr (hA i))) lemma smooth_adjugate_entry {A : E → Matrix ι ι ℝ} (hA : ∀ i j, ContDiff ℝ ∞ (fun z => A z i j)) (i j : ι) : ContDiff ℝ ∞ (fun z => (A z).adjugate i j) := by simp_rw [Matrix.adjugate_apply] apply smooth_matrix_det intro k l by_cases h : j = k · subst k simp only [Matrix.updateRow_apply, ite_true] exact contDiff_const · simpa only [Matrix.updateRow_apply, ite_eq_right (Ne.symm h)] using hA k l lemma smooth_inverse_entry {A : E → Matrix ι ι ℝ} (hA : ∀ i j, ContDiff ℝ ∞ (fun z => A z i j)) (hne : ∀ z, (A z).det ≠ 0) (i j : ι) : ContDiff ℝ ∞ (fun z => (A z)⁻¹ i j) := by simp only [Matrix.inv_def, Ring.inverse_eq_inv, Matrix.smul_apply, smul_eq_mul] exact ((smooth_matrix_det hA).inv hne).mul (smooth_adjugate_entry hA i j) def md (v : E) (A : E → Matrix ι ι ℝ) (z : E) : Matrix ι ι ℝ := fun i j => fderiv ℝ (fun z => A z i j) z v omit [DecidableEq ι] in lemma md_mul {A B : E → Matrix ι ι ℝ} (hA : ∀ i j, ContDiff ℝ ∞ (fun z => A z i j)) (hB : ∀ i j, ContDiff ℝ ∞ (fun z => B z i j)) (v z : E) : md v (fun z => A z * B z) z = md v A z * B z + A z * md v B z := by ext i j simp only [md, Matrix.mul_apply, Matrix.add_apply] rw [fderiv_fun_sum (A := fun k z => A z i k * B z k j) (fun k _ => ((hA i k).differentiable (by simp) z).mul ((hB k j).differentiable (by simp) z))] simp only [_root_.sum_apply, fderiv_fun_mul ((hA _ _).differentiable (by simp) z) ((hB _ _).differentiable (by simp) z), _root_.add_apply, _root_.smul_apply, smul_eq_mul, Finset.sum_add_distrib] rw [add_comm] congr 1 apply Finset.sum_congr rfl intro k _ ring omit [Fintype ι] [DecidableEq ι] in lemma md_const (v z : E) (A : Matrix ι ι ℝ) : md v (fun _ : E => A) z = 0 := by ext i j simp [md] theorem md_inverse {A : E → Matrix ι ι ℝ} (hA : ∀ i j, ContDiff ℝ ∞ (fun z => A z i j)) (hne : ∀ z, (A z).det ≠ 0) (v z : E) : md v (fun z => (A z)⁻¹) z = -(A z)⁻¹ * md v A z * (A z)⁻¹ := by have hAA : (fun z => A z * (A z)⁻¹) = fun _ => (1 : Matrix ι ι ℝ) := by funext z exact Matrix.mul_nonsing_inv (A z) (isUnit_iff_ne_zero.mpr (hne z)) have hd := md_mul hA (smooth_inverse_entry hA hne) v z rw [hAA, md_const] at hd have hm := congrArg (fun B => (A z)⁻¹ * B) hd rw [Matrix.mul_zero, Matrix.mul_add, ← Matrix.mul_assoc, ← Matrix.mul_assoc, Matrix.nonsing_inv_mul (A z) (isUnit_iff_ne_zero.mpr (hne z)), Matrix.one_mul] at hm have he := eq_neg_of_add_eq_zero_right hm.symm simpa only [Matrix.neg_mul, Matrix.mul_assoc] using he omit [DecidableEq ι] in lemma fderiv_matrix_apply {A : E → Matrix ι ι ℝ} (hA : ∀ i j, ContDiff ℝ ∞ (fun z => A z i j)) (v z : E) : fderiv ℝ A z v = md v A z := by have hd : ∀ i, Differentiable ℝ (fun z j => A z i j) := fun i => (contDiff_pi.mpr (hA i)).differentiable (by simp) change fderiv ℝ (fun z i j => A z i j) z v = _ rw [fderiv_pi (fun i => hd i z)] ext i j change fderiv ℝ (fun z j => A z i j) z v j = _ rw [fderiv_pi (fun j => (hA i j).differentiable (by simp) z)] rfl theorem fderiv_logdet {A : E → Matrix ι ι ℝ} (hA : ∀ i j, ContDiff ℝ ∞ (fun z => A z i j)) (hne : ∀ z, (A z).det ≠ 0) (v z : E) : fderiv ℝ (fun z => Real.log (A z).det) z v = ((A z)⁻¹ * md v A z).trace := by have hAd : Differentiable ℝ A := (contDiff_pi.mpr (fun i => contDiff_pi.mpr (hA i))).differentiable (by simp) rw [((smooth_matrix_det hA).differentiable (by simp) z).hasFDerivAt.log (hne z) |>.fderiv] simp only [_root_.smul_apply, smul_eq_mul] have hc := fderiv_comp z (smooth_det.differentiable (by simp) (A z)) (hAd z) change (A z).det⁻¹ * fderiv ℝ ((fun A : Matrix ι ι ℝ => A.det) ∘ A) z v = _ rw [hc, ContinuousLinearMap.comp_apply] erw [fderiv_det_apply (A z) (fderiv ℝ A z v)] rw [fderiv_matrix_apply hA] rw [Matrix.inv_def, Ring.inverse_eq_inv, Matrix.smul_mul, Matrix.trace_smul, smul_eq_mul] end MomentDifferential namespace MomentEquation open WeightedCalculus MomentCoordinates MomentDifferential open scoped ContDiff Matrix.Norms.Elementwise variable {ι : Type*} [Fintype ι] [DecidableEq ι] lemma smooth_hess {φ : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (i j : ι) : ContDiff ℝ ∞ (fun z => hess φ z i j) := smooth_pd (smooth_pd hφ i) j lemma pd_add {f g : Space ι → ℝ} (hf : ContDiff ℝ ∞ f) (hg : ContDiff ℝ ∞ g) (i : ι) : pd i (fun z => f z + g z) = fun z => pd i f z + pd i g z := D_add (hf.differentiable (by simp)) (hg.differentiable (by simp)) _ lemma pd_mul {f g : Space ι → ℝ} (hf : ContDiff ℝ ∞ f) (hg : ContDiff ℝ ∞ g) (i : ι) : pd i (fun z => f z * g z) = fun z => pd i f z * g z + f z * pd i g z := D_mul (hf.differentiable (by simp)) (hg.differentiable (by simp)) _ def C (φ : Space ι → ℝ) (i : ι) : Space ι → Matrix ι ι ℝ := md (basis i) (hess φ) lemma C_apply (φ : Space ι → ℝ) (i : ι) (z : Space ι) (a b : ι) : C φ i z a b = pd i (fun z => hess φ z a b) z := rfl lemma smooth_C {φ : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (i a b : ι) : ContDiff ℝ ∞ (fun z => C φ i z a b) := smooth_pd (smooth_hess hφ a b) i lemma C_symm_last {φ : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (i : ι) (z : Space ι) (a b : ι) : C φ i z a b = C φ i z b a := by simp only [C_apply] congr 1 funext y exact hess_symm hφ y a b lemma C_symm_first {φ : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (i : ι) (z : Space ι) (a b : ι) : C φ i z a b = C φ a z i b := by change pd i (pd b (pd a φ)) z = pd a (pd b (pd i φ)) z rw [pd_comm (smooth_pd hφ a) i b, pd_comm (smooth_pd hφ i) a b, pd_comm hφ i a] lemma pd_trace {A : Space ι → Matrix ι ι ℝ} (hA : ∀ i j, ContDiff ℝ ∞ (fun z => A z i j)) (i : ι) : pd i (fun z => (A z).trace) = fun z => (md (basis i) A z).trace := by change pd i (fun z => ∑ j, A z j j) = _ rw [pd_sum _ (fun j => hA j j)] rfl lemma pd_logdet {φ : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hne : ∀ z, (hess φ z).det ≠ 0) (i : ι) : pd i (fun z => Real.log (hess φ z).det) = fun z => ((hess φ z)⁻¹ * C φ i z).trace := by funext z exact fderiv_logdet (smooth_hess hφ) hne (basis i) z theorem first_moment {φ V : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hV : ContDiff ℝ ∞ V) (hne : ∀ z, (hess φ z).det ≠ 0) {k : ℝ} (heq : ∀ z, Real.log (hess φ z).det = V (grad φ z) + k - φ z) (i : ι) (z : Space ι) : (∑ j, hess φ z i j * pd j V (grad φ z)) = grad φ z i + ((hess φ z)⁻¹ * C φ i z).trace := by have hf : (fun z => Real.log (hess φ z).det) = (fun z => (V ∘ grad φ) z + k - φ z) := funext heq have hd := congrArg (fun f => pd i f z) hf rw [pd_logdet hφ hne, pd_sub ((hV.comp (smooth_grad hφ)).add contDiff_const) hφ, pd_add (hV.comp (smooth_grad hφ)) contDiff_const, pd_comp_grad hV hφ i] at hd simp only [pd, D, fderiv_const_apply, _root_.zero_apply, add_zero] at hd change _ = pd i φ z + _ dsimp only [pd, D] linarith omit [DecidableEq ι] in lemma smooth_matrix_product {A B : Space ι → Matrix ι ι ℝ} (hA : ∀ i j, ContDiff ℝ ∞ (fun z => A z i j)) (hB : ∀ i j, ContDiff ℝ ∞ (fun z => B z i j)) (i j : ι) : ContDiff ℝ ∞ (fun z => (A z * B z) i j) := smooth_sum _ (fun k => (hA i k).mul (hB k j)) omit [DecidableEq ι] in lemma trace_cyclic_four (A B C D : Matrix ι ι ℝ) : (A * B * C * D).trace = (C * D * A * B).trace := by rw [Matrix.mul_assoc A B C, Matrix.mul_assoc A (B*C) D, Matrix.trace_mul_comm A (B*C*D)] simp only [Matrix.mul_assoc] rw [Matrix.trace_mul_comm B (C * (D*A))] simp only [Matrix.mul_assoc] theorem pd_jacobian_term {φ : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hne : ∀ z, (hess φ z).det ≠ 0) (i j : ι) : pd j (fun z => ((hess φ z)⁻¹ * C φ i z).trace) = fun z => ((hess φ z)⁻¹ * md (basis j) (C φ i) z).trace - ((hess φ z)⁻¹ * C φ i z * (hess φ z)⁻¹ * C φ j z).trace := by rw [pd_trace (smooth_matrix_product (smooth_inverse_entry (smooth_hess hφ) hne) (smooth_C hφ i)) j] funext z rw [md_mul (smooth_inverse_entry (smooth_hess hφ) hne) (smooth_C hφ i), md_inverse (smooth_hess hφ) hne] change (-((hess φ z)⁻¹) * C φ j z * (hess φ z)⁻¹ * C φ i z + (hess φ z)⁻¹ * md (basis j) (C φ i) z).trace = _ simp only [Matrix.trace_add, Matrix.neg_mul, Matrix.trace_neg] rw [trace_cyclic_four (hess φ z)⁻¹ (C φ j z) (hess φ z)⁻¹ (C φ i z)] ring lemma pd_hess_gradient {φ V : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hV : ContDiff ℝ ∞ V) (i j : ι) : pd j (fun z => ∑ k, hess φ z i k * pd k V (grad φ z)) = fun z => (∑ k, C φ j z i k * pd k V (grad φ z)) + (hess φ z * hess V (grad φ z) * hess φ z) i j := by erw [pd_sum _ (fun k => (smooth_hess hφ i k).mul ((smooth_pd hV k).comp (smooth_grad hφ)))] simp_rw [pd_mul (smooth_hess hφ i _) ((smooth_pd hV _).comp (smooth_grad hφ)), pd_comp_grad (smooth_pd hV _) hφ] funext z simp only [Finset.sum_add_distrib] congr 1 change (∑ k, hess φ z i k * ∑ l, hess φ z j l * hess V (grad φ z) k l) = _ simp only [Matrix.mul_apply, Finset.mul_sum, Finset.sum_mul] rw [Finset.sum_comm] apply Finset.sum_congr rfl intro k _ apply Finset.sum_congr rfl intro l _ rw [hess_symm hφ z j k] ring theorem twice_moment_raw {φ V : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hV : ContDiff ℝ ∞ V) (hne : ∀ z, (hess φ z).det ≠ 0) {k : ℝ} (heq : ∀ z, Real.log (hess φ z).det = V (grad φ z) + k - φ z) (i j : ι) (z : Space ι) : (hess φ z * hess V (grad φ z) * hess φ z) i j = hess φ z i j + ((hess φ z)⁻¹ * md (basis j) (C φ i) z).trace - ((hess φ z)⁻¹ * C φ i z * (hess φ z)⁻¹ * C φ j z).trace - ∑ l, C φ j z i l * pd l V (grad φ z) := by have he : (fun z => ∑ l, hess φ z i l * pd l V (grad φ z)) = (fun z => grad φ z i + ((hess φ z)⁻¹ * C φ i z).trace) := funext (first_moment hφ hV hne heq i) have hd := congrArg (fun f => pd j f z) he have hs : ContDiff ℝ ∞ (fun z => ((hess φ z)⁻¹ * C φ i z).trace) := smooth_sum _ (fun l => smooth_matrix_product (smooth_inverse_entry (smooth_hess hφ) hne) (smooth_C hφ i) l l) change pd j (fun z => ∑ l, hess φ z i l * pd l V (grad φ z)) z = pd j (fun z => pd i φ z + ((hess φ z)⁻¹ * C φ i z).trace) z at hd rw [pd_hess_gradient hφ hV i j, pd_add (smooth_pd hφ i) hs, pd_jacobian_term hφ hne i j] at hd change _ + _ = hess φ z i j + (_ - _) at hd linarith lemma hess_transpose {φ : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (z : Space ι) : (hess φ z)ᵀ = hess φ z := by ext i j exact hess_symm hφ z j i lemma inverse_transpose {φ : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (z : Space ι) : ((hess φ z)⁻¹)ᵀ = (hess φ z)⁻¹ := by rw [Matrix.transpose_nonsing_inv, hess_transpose hφ] lemma inverse_symm {φ : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (z : Space ι) (i j : ι) : (hess φ z)⁻¹ i j = (hess φ z)⁻¹ j i := by exact congrArg (fun M : Matrix ι ι ℝ => M j i) (inverse_transpose hφ z) omit [DecidableEq ι] in lemma cubic_div_contract (M : Matrix ι ι ℝ) (C : ι → Matrix ι ι ℝ) (hC : ∀ d a b, C d a b = C b a d) (k : ι) : (∑ d, (M * C d * M) d k) = ∑ b, (M * C b).trace * M b k := by simp only [Matrix.trace, Matrix.diag_apply, Matrix.mul_apply, Finset.sum_mul] rw [Finset.sum_comm] apply Finset.sum_congr rfl intro b _ apply Finset.sum_congr rfl intro d _ apply Finset.sum_congr rfl intro a _ rw [hC d a b] theorem inverse_divergence {φ : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hne : ∀ z, (hess φ z).det ≠ 0) (k : ι) (z : Space ι) : (∑ d, pd d (fun y => (hess φ y)⁻¹ d k) z) = -∑ b, ((hess φ z)⁻¹ * C φ b z).trace * (hess φ z)⁻¹ b k := by have hd (d : ι) : pd d (fun y => (hess φ y)⁻¹ d k) z = -((hess φ z)⁻¹ * C φ d z * (hess φ z)⁻¹) d k := by have hm := congrArg (fun M : Matrix ι ι ℝ => M d k) (md_inverse (smooth_hess hφ) hne (basis d) z) simpa only [md, C, pd, D, Matrix.neg_mul, Matrix.neg_apply] using hm simp_rw [hd, Finset.sum_neg_distrib] congr 1 apply cubic_div_contract intro d a b rw [C_symm_last hφ d z a b, C_symm_first hφ d z b a, C_symm_last hφ b z d a] theorem inverse_first_moment {φ V : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hV : ContDiff ℝ ∞ V) (hne : ∀ z, (hess φ z).det ≠ 0) {k : ℝ} (heq : ∀ z, Real.log (hess φ z).det = V (grad φ z) + k - φ z) (a : ι) (z : Space ι) : pd a V (grad φ z) = ∑ d, (grad φ z d + ((hess φ z)⁻¹ * C φ d z).trace) * (hess φ z)⁻¹ d a := by have hv : hess φ z *ᵥ grad V (grad φ z) = fun d => grad φ z d + ((hess φ z)⁻¹ * C φ d z).trace := by ext d exact first_moment hφ hV hne heq d z have hm := congrArg (fun v => ((hess φ z)⁻¹ *ᵥ v) a) hv rw [Matrix.mulVec_mulVec, Matrix.nonsing_inv_mul _ (isUnit_iff_ne_zero.mpr (hne z)), Matrix.one_mulVec] at hm change grad V (grad φ z) a = _ rw [hm] apply Finset.sum_congr rfl intro d _ change (hess φ z)⁻¹ a d * (grad φ z d + ((hess φ z)⁻¹ * C φ d z).trace) = _ erw [inverse_symm hφ z a d] ring theorem weighted_inverse_divergence {φ V : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hV : ContDiff ℝ ∞ V) (hne : ∀ z, (hess φ z).det ≠ 0) {k : ℝ} (heq : ∀ z, Real.log (hess φ z).det = V (grad φ z) + k - φ z) (a : ι) (z : Space ι) : (∑ d, (pd d (fun y => (hess φ y)⁻¹ d a) z - grad φ z d * (hess φ z)⁻¹ d a)) = -pd a V (grad φ z) := by rw [Finset.sum_sub_distrib, inverse_divergence hφ hne a z, inverse_first_moment hφ hV hne heq a z] simp only [add_mul, Finset.sum_add_distrib] ring lemma pd_C_swap {φ : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (i j k d : ι) : pd j (fun z => C φ i z k d) = pd d (fun z => C φ i z j k) := by change pd j (pd i (pd d (pd k φ))) = pd d (pd i (pd k (pd j φ))) rw [pd_comm (smooth_pd (smooth_pd hφ k) d) j i, pd_comm (smooth_pd hφ k) j d, pd_comm (smooth_pd (smooth_pd hφ k) j) i d, pd_comm hφ j k] lemma trace_fourth {φ : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (i j : ι) (z : Space ι) : ((hess φ z)⁻¹ * md (basis j) (C φ i) z).trace = ∑ d, ∑ k, (hess φ z)⁻¹ d k * pd d (fun z => C φ i z j k) z := by simp only [Matrix.trace, Matrix.diag_apply, Matrix.mul_apply] apply Finset.sum_congr rfl intro d _ apply Finset.sum_congr rfl intro k _ change (hess φ z)⁻¹ d k * pd j (fun z => C φ i z k d) z = _ rw [pd_C_swap hφ i j k d] theorem divergence_cubic {φ V : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hV : ContDiff ℝ ∞ V) (hne : ∀ z, (hess φ z).det ≠ 0) {k : ℝ} (heq : ∀ z, Real.log (hess φ z).det = V (grad φ z) + k - φ z) (i j : ι) (z : Space ι) : (∑ d, (pd d (fun y => ∑ a, (hess φ y)⁻¹ d a * C φ i y j a) z - grad φ z d * ∑ a, (hess φ z)⁻¹ d a * C φ i z j a)) = ((hess φ z)⁻¹ * md (basis j) (C φ i) z).trace - ∑ a, C φ j z i a * pd a V (grad φ z) := by have hsM := smooth_inverse_entry (smooth_hess hφ) hne have hd (d : ι) : pd d (fun y => ∑ a, (hess φ y)⁻¹ d a * C φ i y j a) z = ∑ a, (pd d (fun y => (hess φ y)⁻¹ d a) z * C φ i z j a + (hess φ z)⁻¹ d a * pd d (fun y => C φ i y j a) z) := by rw [pd_sum _ (fun a => (hsM d a).mul (smooth_C hφ i j a))] apply Finset.sum_congr rfl intro a _ exact congrFun (pd_mul (hsM d a) (smooth_C hφ i j a) d) z simp_rw [hd] rw [trace_fourth hφ i j z] have halg : (∑ d, ((∑ a, (pd d (fun y => (hess φ y)⁻¹ d a) z * C φ i z j a + (hess φ z)⁻¹ d a * pd d (fun y => C φ i y j a) z)) - grad φ z d * ∑ a, (hess φ z)⁻¹ d a * C φ i z j a)) = (∑ d, ∑ a, (hess φ z)⁻¹ d a * pd d (fun y => C φ i y j a) z) + ∑ a, (∑ d, (pd d (fun y => (hess φ y)⁻¹ d a) z - grad φ z d * (hess φ z)⁻¹ d a)) * C φ i z j a := by simp only [Finset.mul_sum, Finset.sum_mul, sub_mul, Finset.sum_add_distrib, Finset.sum_sub_distrib] rw [Finset.sum_comm (f := fun d a => pd d (fun y => (hess φ y)⁻¹ d a) z * C φ i z j a)] have hc : (∑ d, ∑ a, grad φ z d * ((hess φ z)⁻¹ d a * C φ i z j a)) = ∑ a, ∑ d, grad φ z d * (hess φ z)⁻¹ d a * C φ i z j a := by rw [Finset.sum_comm] simp only [mul_assoc] rw [hc] ring rw [halg] simp_rw [weighted_inverse_divergence hφ hV hne heq] have hr : (∑ a, -pd a V (grad φ z) * C φ i z j a) = -(∑ a, C φ j z i a * pd a V (grad φ z)) := by rw [← Finset.sum_neg_distrib] apply Finset.sum_congr rfl intro a _ rw [C_symm_first hφ i z j a] ring rw [hr] ring theorem twice_moment {φ V : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hV : ContDiff ℝ ∞ V) (hne : ∀ z, (hess φ z).det ≠ 0) {k : ℝ} (heq : ∀ z, Real.log (hess φ z).det = V (grad φ z) + k - φ z) (i j : ι) (z : Space ι) : (hess φ z * hess V (grad φ z) * hess φ z - hess φ z) i j = (∑ d, (pd d (fun y => ∑ a, (hess φ y)⁻¹ d a * C φ i y j a) z - grad φ z d * ∑ a, (hess φ z)⁻¹ d a * C φ i z j a)) - ((hess φ z)⁻¹ * C φ i z * (hess φ z)⁻¹ * C φ j z).trace := by rw [divergence_cubic hφ hV hne heq, Matrix.sub_apply, twice_moment_raw hφ hV hne heq i j z] ring end MomentEquation namespace TargetCoordinates open WeightedCalculus MomentCoordinates MomentDifferential MomentEquation variable {ι : Type*} [Fintype ι] [DecidableEq ι] def target (Φ : Space ι ≃ₜ Space ι) (g : Space ι → ℝ) : Space ι → ℝ := g ∘ Φ.symm lemma target_pull {φ : Space ι → ℝ} (Φ : Space ι ≃ₜ Space ι) (hΦ : (Φ : Space ι → Space ι) = grad φ) (g : Space ι → ℝ) : target Φ g ∘ grad φ = g := by rw [← hΦ] funext z exact congrArg g (Φ.symm_apply_apply z) lemma target_apply {φ : Space ι → ℝ} (Φ : Space ι ≃ₜ Space ι) (hΦ : (Φ : Space ι → Space ι) = grad φ) (g : Space ι → ℝ) (z : Space ι) : target Φ g (grad φ z) = g z := congrFun (target_pull Φ hΦ g) z omit [DecidableEq ι] in lemma smooth_target {Φ : Space ι ≃ₜ Space ι} (hInv : ContDiff ℝ ∞ (Φ.symm : Space ι → Space ι)) {g : Space ι → ℝ} (hg : ContDiff ℝ ∞ g) : ContDiff ℝ ∞ (target Φ g) := hg.comp hInv lemma target_chain {φ g : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hg : ContDiff ℝ ∞ g) (Φ : Space ι ≃ₜ Space ι) (hΦ : (Φ : Space ι → Space ι) = grad φ) (hInv : ContDiff ℝ ∞ (Φ.symm : Space ι → Space ι)) (i : ι) (z : Space ι) : pd i g z = ∑ j, hess φ z i j * pd j (target Φ g) (grad φ z) := by have he := congrFun (pd_comp_grad (smooth_target hInv hg) hφ i) z rw [target_pull Φ hΦ] at he exact he lemma pd_target {φ g : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hg : ContDiff ℝ ∞ g) (hne : ∀ z, (hess φ z).det ≠ 0) (Φ : Space ι ≃ₜ Space ι) (hΦ : (Φ : Space ι → Space ι) = grad φ) (hInv : ContDiff ℝ ∞ (Φ.symm : Space ι → Space ι)) (i : ι) (z : Space ι) : pd i (target Φ g) (grad φ z) = ∑ j, (hess φ z)⁻¹ i j * pd j g z := by have he : grad g z = hess φ z *ᵥ grad (target Φ g) (grad φ z) := by ext k exact target_chain hφ hg Φ hΦ hInv k z change grad (target Φ g) (grad φ z) i = ((hess φ z)⁻¹ *ᵥ grad g z) i rw [he, Matrix.mulVec_mulVec, Matrix.nonsing_inv_mul _ (isUnit_iff_ne_zero.mpr (hne z)), Matrix.one_mulVec] lemma stein {φ V : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hV : ContDiff ℝ ∞ V) (hne : ∀ z, (hess φ z).det ≠ 0) {c : ℝ} (heq : ∀ z, Real.log (hess φ z).det = V (grad φ z) + c - φ z) (Φ : Space ι ≃ₜ Space ι) (hΦ : (Φ : Space ι → Space ι) = grad φ) (hInv : ContDiff ℝ ∞ (Φ.symm : Space ι → Space ι)) (i : ι) (z : Space ι) : divergence V basis (fun j => target Φ (fun y => hess φ y i j)) (grad φ z) = grad φ z i := by change (∑ j, (pd j V (grad φ z) * target Φ (fun y => hess φ y i j) (grad φ z) - pd j (target Φ (fun y => hess φ y i j)) (grad φ z))) = _ simp_rw [target_apply Φ hΦ, pd_target hφ (smooth_hess hφ _ _) hne Φ hΦ hInv] rw [Finset.sum_sub_distrib] have ht : (∑ j, ∑ k, (hess φ z)⁻¹ j k * pd k (fun y => hess φ y i j) z) = ((hess φ z)⁻¹ * C φ i z).trace := by simp only [Matrix.trace, Matrix.diag_apply, Matrix.mul_apply] apply Finset.sum_congr rfl intro j _ apply Finset.sum_congr rfl intro k _ change (hess φ z)⁻¹ j k * C φ k z i j = (hess φ z)⁻¹ j k * C φ i z k j rw [C_symm_first hφ k z i j] rw [ht] have hm := first_moment hφ hV hne heq i z have hs : (∑ j, pd j V (grad φ z) * hess φ z i j) = ∑ j, hess φ z i j * pd j V (grad φ z) := by apply Finset.sum_congr rfl intro j _ ring rw [hs, hm] ring lemma divergence_product {V : Space ι → ℝ} (P : ι → Space ι → ℝ) (T : ι → ι → Space ι → ℝ) (hP : ∀ k, ContDiff ℝ ∞ (P k)) (hT : ∀ k j, ContDiff ℝ ∞ (T k j)) : divergence V basis (fun j z => ∑ k, P k z * T k j z) = fun z => (∑ k, P k z * divergence V basis (T k) z) - ∑ k, ∑ j, pd j (P k) z * T k j z := by funext z change (∑ j, (pd j V z * ∑ k, P k z * T k j z - pd j (fun y => ∑ k, P k y * T k j y) z)) = _ simp_rw [pd_sum _ (fun k => (hP k).mul (hT k _))] simp_rw [pd_mul (hP _) (hT _ _)] simp only [Finset.mul_sum, Finset.sum_sub_distrib, Finset.sum_add_distrib, divergence, adjoint] rw [Finset.sum_comm (f := fun j k => pd j V z * (P k z * T k j z)), Finset.sum_comm (f := fun j k => pd j (P k) z * T k j z), Finset.sum_comm (f := fun j k => P k z * pd j (T k j) z)] simp only [Finset.mul_sum, mul_sub, Finset.sum_sub_distrib, ← mul_assoc] have he : (∑ k, ∑ j, pd j V z * P k z * T k j z) = ∑ k, ∑ j, P k z * D (basis j) V z * T k j z := by apply Finset.sum_congr rfl intro k _ apply Finset.sum_congr rfl intro j _ change pd j V z * P k z * T k j z = P k z * pd j V z * T k j z ring rw [he] change _ - (_ + _) = _ - _ - _ dsimp only [pd] ring lemma row_adjoint {φ V : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hV : ContDiff ℝ ∞ V) (hne : ∀ z, (hess φ z).det ≠ 0) {c : ℝ} (heq : ∀ z, Real.log (hess φ z).det = V (grad φ z) + c - φ z) (Φ : Space ι ≃ₜ Space ι) (hΦ : (Φ : Space ι → Space ι) = grad φ) (hInv : ContDiff ℝ ∞ (Φ.symm : Space ι → Space ι)) (P : ι → Space ι → ℝ) (hP : ∀ k, ContDiff ℝ ∞ (P k)) (z : Space ι) : divergence V basis (fun j => target Φ (fun y => ∑ k, P k y * hess φ y k j)) (grad φ z) = divergence φ basis P z := by have he : (fun j => target Φ (fun y => ∑ k, P k y * hess φ y k j)) = fun j x => ∑ k, target Φ (P k) x * target Φ (fun y => hess φ y k j) x := rfl rw [he, divergence_product _ _ (fun k => smooth_target hInv (hP k)) (fun k j => smooth_target hInv (smooth_hess hφ k j))] simp_rw [target_apply Φ hΦ, stein hφ hV hne heq Φ hΦ hInv] have hc (k : ι) : (∑ j, pd j (target Φ (P k)) (grad φ z) * hess φ z k j) = pd k (P k) z := by rw [target_chain hφ (hP k) Φ hΦ hInv k z] apply Finset.sum_congr rfl intro j _ ring simp_rw [hc] change _ = ∑ k, (pd k φ z * P k z - pd k (P k) z) rw [Finset.sum_sub_distrib] congr 1 apply Finset.sum_congr rfl intro k _ change P k z * pd k φ z = pd k φ z * P k z ring def sourceMeasure (μ : Measure (Space ι)) (φ : Space ι → ℝ) : Measure (Space ι) := μ.withDensity (fun z => ENNReal.ofReal (weight φ z)) def targetMeasure (μ : Measure (Space ι)) (V : Space ι → ℝ) (Z : ℝ) : Measure (Space ι) := μ.withDensity (fun x => ENNReal.ofReal (weight V x / Z)) def normalizedE (μ : Measure (Space ι)) (V : Space ι → ℝ) (Z : ℝ) (F : Space ι → ℝ) : ℝ := expectation μ V F / Z variable (μ : Measure (Space ι)) omit [DecidableEq ι] in lemma source_integral {φ : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (F : Space ι → ℝ) : (∫ z, F z ∂sourceMeasure μ φ) = expectation μ φ F := by rw [sourceMeasure, integral_withDensity_eq_integral_toReal_smul ((smooth_weight hφ).continuous.measurable.ennreal_ofReal) (Filter.Eventually.of_forall (fun _ => ENNReal.ofReal_lt_top))] simp only [smul_eq_mul, expectation] congr 1 funext z rw [ENNReal.toReal_ofReal (show 0 ≤ weight φ z from le_of_lt (Real.exp_pos _))] ring omit [DecidableEq ι] in lemma target_integral {V : Space ι → ℝ} (hV : ContDiff ℝ ∞ V) {Z : ℝ} (hZ : 0 < Z) (F : Space ι → ℝ) : (∫ x, F x ∂targetMeasure μ V Z) = normalizedE μ V Z F := by rw [targetMeasure, integral_withDensity_eq_integral_toReal_smul (((smooth_weight hV).continuous.div_const Z).measurable.ennreal_ofReal) (Filter.Eventually.of_forall (fun _ => ENNReal.ofReal_lt_top))] change (∫ x, (ENNReal.ofReal (weight V x / Z)).toReal • F x ∂μ) = _ have hw (x : Space ι) : 0 ≤ weight V x / Z := div_nonneg (le_of_lt (Real.exp_pos _)) hZ.le simp only [ENNReal.toReal_ofReal (hw _), smul_eq_mul] have he : (fun x => weight V x / Z * F x) = fun x => (F x * weight V x) / Z := by funext x ring rw [he, integral_div] rfl lemma expectation_transport {φ V : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hV : ContDiff ℝ ∞ V) {Z : ℝ} (hZ : 0 < Z) (Φ : Space ι ≃ₜ Space ι) (hΦ : (Φ : Space ι → Space ι) = grad φ) (hmap : Measure.map (grad φ) (sourceMeasure μ φ) = targetMeasure μ V Z) (F : Space ι → ℝ) : expectation μ φ (F ∘ grad φ) = normalizedE μ V Z F := by rw [← source_integral μ hφ, ← target_integral μ hV hZ, ← hmap, ← hΦ] exact (Φ.measurableEmbedding.integral_map F).symm lemma target_expectation {φ V : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hV : ContDiff ℝ ∞ V) {Z : ℝ} (hZ : 0 < Z) (Φ : Space ι ≃ₜ Space ι) (hΦ : (Φ : Space ι → Space ι) = grad φ) (hmap : Measure.map (grad φ) (sourceMeasure μ φ) = targetMeasure μ V Z) (F : Space ι → ℝ) : expectation μ φ F = normalizedE μ V Z (target Φ F) := by rw [← expectation_transport μ hφ hV hZ Φ hΦ hmap, target_pull Φ hΦ] end TargetCoordinates namespace MomentOperator open WeightedCalculus MomentCoordinates MomentDifferential MomentEquation TargetCoordinates variable {ι : Type*} [Fintype ι] [DecidableEq ι] def tau (Φ : Space ι ≃ₜ Space ι) (φ : Space ι → ℝ) (x : Space ι) : Matrix ι ι ℝ := hess φ (Φ.symm x) def A (Φ : Space ι ≃ₜ Space ι) (φ f : Space ι → ℝ) : Space ι → ℝ := fun x => (∑ i, x i * pd i f x) - ∑ i, ∑ j, tau Φ φ x i j * hess f x i j def flux (Φ : Space ι ≃ₜ Space ι) (φ f : Space ι → ℝ) (i : ι) : Space ι → ℝ := fun x => ∑ j, tau Φ φ x i j * pd j f x lemma A_pull {φ f : Space ι → ℝ} (Φ : Space ι ≃ₜ Space ι) (hΦ : (Φ : Space ι → Space ι) = grad φ) : A Φ φ f ∘ grad φ = pullA φ f := by funext z have he : Φ.symm (grad φ z) = z := by rw [← hΦ]; exact Φ.symm_apply_apply z simp only [Function.comp_apply, A, tau, he, pullA] lemma A_target {φ f : Space ι → ℝ} (Φ : Space ι ≃ₜ Space ι) (hΦ : (Φ : Space ι → Space ι) = grad φ) : A Φ φ f = target Φ (pullA φ f) := by funext x obtain ⟨z,rfl⟩ := Φ.surjective x rw [hΦ, target_apply Φ hΦ] exact congrFun (A_pull Φ hΦ) z lemma smooth_A {φ f : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hf : ContDiff ℝ ∞ f) (Φ : Space ι ≃ₜ Space ι) (hΦ : (Φ : Space ι → Space ι) = grad φ) (hInv : ContDiff ℝ ∞ (Φ.symm : Space ι → Space ι)) : ContDiff ℝ ∞ (A Φ φ f) := by rw [A_target Φ hΦ] exact smooth_target hInv (smooth_pullA hφ hf) lemma compact_A {φ f : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hf : ContDiff ℝ ∞ f) (hfc : HasCompactSupport f) (Φ : Space ι ≃ₜ Space ι) (hΦ : (Φ : Space ι → Space ι) = grad φ) : HasCompactSupport (A Φ φ f) := by rw [A_target Φ hΦ] exact (compact_pullA hφ hf hfc Φ hΦ).comp_homeomorph Φ.symm lemma A_divergence {φ V f : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hV : ContDiff ℝ ∞ V) (hf : ContDiff ℝ ∞ f) (hne : ∀ z, (hess φ z).det ≠ 0) {c : ℝ} (heq : ∀ z, Real.log (hess φ z).det = V (grad φ z) + c - φ z) (Φ : Space ι ≃ₜ Space ι) (hΦ : (Φ : Space ι → Space ι) = grad φ) (hInv : ContDiff ℝ ∞ (Φ.symm : Space ι → Space ι)) : divergence V basis (flux Φ φ f) = A Φ φ f := by have he : flux Φ φ f = fun j => target Φ (fun z => ∑ k, pd k f (grad φ z) * hess φ z k j) := by funext j x change (∑ k, hess φ (Φ.symm x) j k * pd k f x) = ∑ k, pd k f (grad φ (Φ.symm x)) * hess φ (Φ.symm x) k j have hcancel : grad φ (Φ.symm x) = x := by rw [← hΦ]; exact Φ.apply_symm_apply x rw [hcancel] apply Finset.sum_congr rfl intro k _ rw [hess_symm hφ _ j k] ring rw [he] funext x obtain ⟨z,rfl⟩ := Φ.surjective x rw [hΦ, row_adjoint hφ hV hne heq Φ hΦ hInv (fun k z => pd k f (grad φ z)) (fun k => (smooth_pd hf k).comp (smooth_grad hφ)) z] change divergence φ basis (fun k => pd k f ∘ grad φ) z = _ rw [← pullA_divergence hφ hf] exact (congrFun (A_pull Φ hΦ) z).symm lemma W_flux {φ f : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hf : ContDiff ℝ ∞ f) (Φ : Space ι ≃ₜ Space ι) (hΦ : (Φ : Space ι → Space ι) = grad φ) (hInv : ContDiff ℝ ∞ (Φ.symm : Space ι → Space ι)) (a : ι) : target Φ (W φ f a) = flux Φ φ (A Φ φ f - f) a := by funext x obtain ⟨z,rfl⟩ := Φ.surjective x rw [hΦ, target_apply Φ hΦ] have he : pullA φ f - f ∘ grad φ = (A Φ φ f - f) ∘ grad φ := by rw [← A_pull Φ hΦ] rfl rw [W_gradient hφ hf a] change pd a (pullA φ f - f ∘ grad φ) z = _ rw [he] change pd a ((fun x => A Φ φ f x - f x) ∘ grad φ) z = _ rw [pd_comp_grad ((smooth_A hφ hf Φ hΦ hInv).sub hf) hφ] change (∑ j, hess φ z a j * pd j (A Φ φ f - f) (grad φ z)) = ∑ j, hess φ (Φ.symm (grad φ z)) a j * pd j (A Φ φ f - f) (grad φ z) have hc : Φ.symm (grad φ z) = z := by rw [← hΦ]; exact Φ.symm_apply_apply z rw [hc] lemma double_divergence {φ V f : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hV : ContDiff ℝ ∞ V) (hf : ContDiff ℝ ∞ f) (hne : ∀ z, (hess φ z).det ≠ 0) {c : ℝ} (heq : ∀ z, Real.log (hess φ z).det = V (grad φ z) + c - φ z) (Φ : Space ι ≃ₜ Space ι) (hΦ : (Φ : Space ι → Space ι) = grad φ) (hInv : ContDiff ℝ ∞ (Φ.symm : Space ι → Space ι)) : divergence V basis (fun a => target Φ (W φ f a)) = A Φ φ (A Φ φ f - f) := by simp_rw [W_flux hφ hf Φ hΦ hInv] exact A_divergence hφ hV ((smooth_A hφ hf Φ hΦ hInv).sub hf) hne heq Φ hΦ hInv variable (μ : Measure (Space ι)) [Measure.IsAddHaarMeasure μ] lemma hessian_identity_target {φ V f : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hV : ContDiff ℝ ∞ V) (hf : ContDiff ℝ ∞ f) (hfc : HasCompactSupport f) {Z : ℝ} (hZ : 0 < Z) (Φ : Space ι ≃ₜ Space ι) (hΦ : (Φ : Space ι → Space ι) = grad φ) (hmap : Measure.map (grad φ) (sourceMeasure μ φ) = targetMeasure μ V Z) : normalizedE μ V Z (fun x => (A Φ φ f x) * (A Φ φ f x - f x)) = normalizedE μ V Z (fun x => ∑ a, ∑ k, (tau Φ φ x * hess f x) k a * (tau Φ φ x * hess f x) a k) := by have ht := MomentCoordinates.hessian_identity μ hφ hf hfc Φ hΦ have hleft : (fun z => pullA φ f z * (pullA φ f z - f (grad φ z))) = (fun x => A Φ φ f x * (A Φ φ f x - f x)) ∘ grad φ := by rw [← A_pull Φ hΦ] rfl rw [hleft, expectation_transport μ hφ hV hZ Φ hΦ hmap] at ht have hs : expectation μ φ (fun z => ∑ a, ∑ k, P φ f k a z * P φ f a k z) = ∑ a, ∑ k, expectation μ φ (fun z => P φ f k a z * P φ f a k z) := by rw [expectation_sum μ hφ _ (fun a => (smooth_sum _ (fun k => (smooth_P hφ hf k a).mul (smooth_P hφ hf a k))).continuous) (fun a => compact_sum _ (fun k => (compact_P hφ hf hfc Φ hΦ k a).mul_right))] apply Finset.sum_congr rfl intro a _ exact expectation_sum μ hφ _ (fun k => ((smooth_P hφ hf k a).mul (smooth_P hφ hf a k)).continuous) (fun k => (compact_P hφ hf hfc Φ hΦ k a).mul_right) rw [← hs] at ht have hr : (fun z => ∑ a, ∑ k, P φ f k a z * P φ f a k z) = (fun x => ∑ a, ∑ k, (tau Φ φ x * hess f x) k a * (tau Φ φ x * hess f x) a k) ∘ grad φ := by funext z have hc : Φ.symm (grad φ z) = z := by rw [← hΦ]; exact Φ.symm_apply_apply z simp only [Function.comp_apply, tau, hc, Matrix.mul_apply, P] rw [hr, expectation_transport μ hφ hV hZ Φ hΦ hmap] at ht exact ht end MomentOperator namespace MomentMatrix open Matrix open scoped MatrixOrder variable {ι : Type*} [Fintype ι] [DecidableEq ι] lemma trace_mul_nonneg {A B : Matrix ι ι ℝ} (hA : A.PosSemidef) (hB : B.PosSemidef) : 0 ≤ (A * B).trace := by obtain ⟨Q, hQ⟩ := CStarAlgebra.nonneg_iff_eq_star_mul_self.mp hA.nonneg rw [hQ] change 0 ≤ (Qᴴ * Q * B).trace rw [← Matrix.trace_mul_cycle Q B Qᴴ] exact (hB.mul_mul_conjTranspose_same Q).trace_nonneg lemma trace_conjugate_nonneg {A H : Matrix ι ι ℝ} (hA : A.PosSemidef) (hH : Hᵀ = H) : 0 ≤ (A * H * A * H).trace := by have hc : (H * A * H).PosSemidef := by simpa only [Matrix.conjTranspose_eq_transpose_of_trivial, hH] using hA.conjTranspose_mul_mul_same H simpa only [Matrix.mul_assoc] using trace_mul_nonneg hA hc lemma trace_energy_nonneg {M H B : Matrix ι ι ℝ} (hM : M.PosSemidef) (hH : H.PosSemidef) (hB : Bᵀ = B) : 0 ≤ (M * B * H * B).trace := by have hc : (B * H * B).PosSemidef := by simpa only [Matrix.conjTranspose_eq_transpose_of_trivial, hB] using hH.conjTranspose_mul_mul_same B simpa only [Matrix.mul_assoc] using trace_mul_nonneg hM hc lemma quadratic_cs (a b c : ℝ) (h : ∀ t : ℝ, 0 ≤ c - 2 * t * b + t^2 * a) : b^2 ≤ a * c := by have hd := discrim_le_zero (a := a) (b := -2 * b) (c := c) (fun t => by have ht := h t nlinarith) dsimp [discrim] at hd nlinarith lemma trace_energy_quadratic (M T H B : Matrix ι ι ℝ) (hMT : M * T = 1) (hTM : T * M = 1) (t : ℝ) : (M * (B - t • T) * H * (B - t • T)).trace = (M * B * H * B).trace - 2 * t * (B * H).trace + t^2 * (T * H).trace := by have hc₁ : (M * B * H * T).trace = (B * H).trace := by rw [Matrix.trace_mul_cycle (M * B) H T, ← Matrix.mul_assoc T M B, hTM, Matrix.one_mul] have hc₂ : (M * T * H * B).trace = (B * H).trace := by rw [hMT, Matrix.one_mul, Matrix.trace_mul_comm H B] have hc₃ : (M * T * H * T).trace = (T * H).trace := by rw [hMT, Matrix.one_mul, Matrix.trace_mul_comm H T] simp only [Matrix.mul_sub, Matrix.sub_mul, Matrix.mul_smul, Matrix.smul_mul, Matrix.trace_sub, Matrix.trace_smul, smul_eq_mul, hc₁, hc₂, hc₃] ring theorem trace_cs {M T H B : Matrix ι ι ℝ} (hM : M.PosSemidef) (hH : H.PosSemidef) (hT : Tᵀ = T) (hB : Bᵀ = B) (hMT : M * T = 1) (hTM : T * M = 1) : (B * H).trace ^ 2 ≤ (T * H).trace * (M * B * H * B).trace := by apply quadratic_cs intro t rw [← trace_energy_quadratic M T H B hMT hTM t] apply trace_energy_nonneg hM hH simp only [Matrix.transpose_sub, Matrix.transpose_smul, hB, hT] omit [DecidableEq ι] in lemma form_symm {H : Matrix ι ι ℝ} (hH : Hᵀ = H) (v w : ι → ℝ) : v ⬝ᵥ (H *ᵥ w) = w ⬝ᵥ (H *ᵥ v) := by rw [dotProduct_mulVec, ← Matrix.mulVec_transpose, hH, dotProduct_comm] omit [DecidableEq ι] in lemma form_nonneg {H : Matrix ι ι ℝ} (hH : H.PosSemidef) (v : ι → ℝ) : 0 ≤ v ⬝ᵥ (H *ᵥ v) := by simpa only [star_trivial] using hH.dotProduct_mulVec_nonneg v omit [DecidableEq ι] in lemma form_quadratic {H : Matrix ι ι ℝ} (hH : Hᵀ = H) (v w : ι → ℝ) (t : ℝ) : (w - t • v) ⬝ᵥ (H *ᵥ (w - t • v)) = w ⬝ᵥ (H *ᵥ w) - 2 * t * (v ⬝ᵥ (H *ᵥ w)) + t^2 * (v ⬝ᵥ (H *ᵥ v)) := by simp only [Matrix.mulVec_sub, Matrix.mulVec_smul, dotProduct_sub, sub_dotProduct, dotProduct_smul, smul_dotProduct, smul_eq_mul] rw [form_symm hH w v] ring open MeasureTheory variable {X : Type*} [MeasurableSpace X] (μ : Measure X) lemma integral_quadratic_cs {a b c : X → ℝ} (ha : Integrable a μ) (hb : Integrable b μ) (hc : Integrable c μ) (h : ∀ t x, 0 ≤ c x - 2 * t * b x + t^2 * a x) : (∫ x, b x ∂μ)^2 ≤ (∫ x, a x ∂μ) * (∫ x, c x ∂μ) := by apply quadratic_cs intro t have ht : 0 ≤ ∫ x, c x - 2 * t * b x + t^2 * a x ∂μ := integral_nonneg (fun x => h t x) rw [integral_add (f := fun x => c x - 2*t*b x) (g := fun x => t^2*a x) (hc.sub (hb.const_mul (2*t))) (ha.const_mul (t^2)), integral_sub (f := c) (g := fun x => 2*t*b x) hc (hb.const_mul (2*t)), integral_const_mul, integral_const_mul] at ht exact ht theorem integral_trace_cs {M T H B : X → Matrix ι ι ℝ} (hM : ∀ x, (M x).PosSemidef) (hH : ∀ x, (H x).PosSemidef) (hT : ∀ x, (T x)ᵀ = T x) (hB : ∀ x, (B x)ᵀ = B x) (hMT : ∀ x, M x * T x = 1) (hTM : ∀ x, T x * M x = 1) (hi₁ : Integrable (fun x => (T x * H x).trace) μ) (hi₂ : Integrable (fun x => (B x * H x).trace) μ) (hi₃ : Integrable (fun x => (M x * B x * H x * B x).trace) μ) : (∫ x, (B x * H x).trace ∂μ)^2 ≤ (∫ x, (T x * H x).trace ∂μ) * (∫ x, (M x * B x * H x * B x).trace ∂μ) := by apply integral_quadratic_cs μ hi₁ hi₂ hi₃ intro t x rw [← trace_energy_quadratic (M x) (T x) (H x) (B x) (hMT x) (hTM x) t] apply trace_energy_nonneg (hM x) (hH x) simp only [Matrix.transpose_sub, Matrix.transpose_smul, hB x, hT x] omit [DecidableEq ι] in theorem integral_form_cs {H : X → Matrix ι ι ℝ} {v w : X → ι → ℝ} (hH : ∀ x, (H x).PosSemidef) (hi₁ : Integrable (fun x => v x ⬝ᵥ (H x *ᵥ v x)) μ) (hi₂ : Integrable (fun x => v x ⬝ᵥ (H x *ᵥ w x)) μ) (hi₃ : Integrable (fun x => w x ⬝ᵥ (H x *ᵥ w x)) μ) : (∫ x, v x ⬝ᵥ (H x *ᵥ w x) ∂μ)^2 ≤ (∫ x, v x ⬝ᵥ (H x *ᵥ v x) ∂μ) * (∫ x, w x ⬝ᵥ (H x *ᵥ w x) ∂μ) := by apply integral_quadratic_cs μ hi₁ hi₂ hi₃ intro t x have hs : (H x)ᵀ = H x := by simpa only [Matrix.conjTranspose_eq_transpose_of_trivial] using (hH x).isHermitian.eq rw [← form_quadratic hs (v x) (w x) t] exact form_nonneg (hH x) _ end MomentMatrix namespace DensityEnergy open MeasureTheory Matrix WeightedCalculus open scoped ContDiff variable {ι : Type*} [Fintype ι] [DecidableEq ι] abbrev Space (ι : Type*) := ι → ℝ def e (i : ι) : Space ι := Pi.single i 1 def grad (f : Space ι → ℝ) (x : Space ι) : ι → ℝ := fun i => D (e i) f x def gamma (τ : Space ι → Matrix ι ι ℝ) (f g : Space ι → ℝ) (x : Space ι) : ℝ := grad f x ⬝ᵥ (τ x *ᵥ grad g x) def A (τ : Space ι → Matrix ι ι ℝ) (f : Space ι → ℝ) (x : Space ι) : ℝ := (∑ i, x i * D (e i) f x) - ∑ i, ∑ j, τ x i j * D (e i) (D (e j) f) x lemma grad_mul {f g : Space ι → ℝ} (hf : ContDiff ℝ ∞ f) (hg : ContDiff ℝ ∞ g) : grad (fun x => f x*g x) = fun x => g x • grad f x + f x • grad g x := by funext x i simpa only [grad, Pi.add_apply, Pi.smul_apply, smul_eq_mul, mul_comm (g x)] using congrFun (D_mul (hf.differentiable (by simp)) (hg.differentiable (by simp)) (e i)) x lemma gamma_symm {τ : Space ι → Matrix ι ι ℝ} (hτ : ∀ x, (τ x)ᵀ = τ x) (f g : Space ι → ℝ) (x : Space ι) : gamma τ f g x = gamma τ g f x := MomentMatrix.form_symm (hτ x) _ _ lemma gamma_nonneg {τ : Space ι → Matrix ι ι ℝ} (hτ : ∀ x, (τ x).PosSemidef) (f : Space ι → ℝ) (x : Space ι) : 0 ≤ gamma τ f f x := MomentMatrix.form_nonneg (hτ x) _ lemma smooth_gamma {τ : Space ι → Matrix ι ι ℝ} (hτ : ∀ i j, ContDiff ℝ ∞ (fun x => τ x i j)) {f g : Space ι → ℝ} (hf : ContDiff ℝ ∞ f) (hg : ContDiff ℝ ∞ g) : ContDiff ℝ ∞ (gamma τ f g) := by unfold gamma grad dotProduct Matrix.mulVec apply ContDiff.sum; intro i _ apply (smooth_D hf _).mul apply ContDiff.sum; intro j _ exact (hτ i j).mul (smooth_D hg _) lemma compact_gamma_left {τ : Space ι → Matrix ι ι ℝ} {f g : Space ι → ℝ} (hf : HasCompactSupport f) : HasCompactSupport (gamma τ f g) := by unfold gamma grad dotProduct Matrix.mulVec exact compact_sum _ (fun i => (compact_D hf (e i)).mul_right) lemma gamma_mul_left {τ : Space ι → Matrix ι ι ℝ} {f g h : Space ι → ℝ} (hf : ContDiff ℝ ∞ f) (hg : ContDiff ℝ ∞ g) (x : Space ι) : gamma τ (fun x => f x*g x) h x = g x*gamma τ f h x + f x*gamma τ g h x := by unfold gamma rw [grad_mul hf hg] simp only [add_dotProduct, smul_dotProduct, smul_eq_mul] lemma gamma_cutoff_square {τ : Space ι → Matrix ι ι ℝ} {η w : Space ι → ℝ} (hη : ContDiff ℝ ∞ η) (hw : ContDiff ℝ ∞ w) (x : Space ι) : gamma τ (fun x => η x^2*w x) w x = η x^2*gamma τ w w x + 2*η x*w x*gamma τ η w x := by simp only [pow_two] rw [gamma_mul_left (hη.mul hη) hw, gamma_mul_left hη hη] ring lemma cutoff_young {τ : Space ι → Matrix ι ι ℝ} (hτ : ∀ x, (τ x).PosSemidef) (η w : Space ι → ℝ) (x : Space ι) : -2*η x*w x*gamma τ η w x ≤ (1/2)*η x^2*gamma τ w w x + 2*w x^2*gamma τ η η x := by have hp := MomentMatrix.form_nonneg (hτ x) (η x • grad w x + (2*w x) • grad η x) have hs : (τ x)ᵀ = τ x := by simpa only [Matrix.conjTranspose_eq_transpose_of_trivial] using (hτ x).isHermitian.eq simp only [Matrix.mulVec_add, Matrix.mulVec_smul, add_dotProduct, dotProduct_add, smul_dotProduct, dotProduct_smul, smul_eq_mul] at hp rw [MomentMatrix.form_symm hs (grad w x) (grad η x)] at hp change _ ≤ (1/2)*η x^2*(grad w x ⬝ᵥ (τ x *ᵥ grad w x)) + 2*w x^2*(grad η x ⬝ᵥ (τ x *ᵥ grad η x)) unfold gamma nlinarith theorem caccioppoli (μ : Measure (Space ι)) [IsFiniteMeasure μ] {τ : Space ι → Matrix ι ι ℝ} (hts : ∀ i j, ContDiff ℝ ∞ (fun x => τ x i j)) (htp : ∀ x, (τ x).PosSemidef) {η w : Space ι → ℝ} (hη : ContDiff ℝ ∞ η) (hηc : HasCompactSupport η) (hw : ContDiff ℝ ∞ w) (hiw : Integrable (fun x => w x^2) μ) (hzero : (∫ x, gamma τ (fun x => η x^2*w x) w x ∂μ) = 0) {c : ℝ} (hbound : ∀ x, gamma τ η η x ≤ c) : (∫ x, η x^2*gamma τ w w x ∂μ) ≤ 4*c*(∫ x, w x^2 ∂μ) := by have hcη : HasCompactSupport (fun x => η x^2) := by rw [show (fun x => η x^2) = η*η by ext x; simp only [Pi.mul_apply, pow_two]] exact hηc.mul_right have hc₂ : HasCompactSupport (fun x => 2*η x) := hηc.mul_left have hi₁ : Integrable (fun x => η x^2*gamma τ w w x) μ := ((hη.pow 2).mul (smooth_gamma hts hw hw)).continuous.integrable_of_hasCompactSupport hcη.mul_right have hi₂ : Integrable (fun x => 2*η x*w x*gamma τ η w x) μ := (((contDiff_const.mul hη).mul hw).mul (smooth_gamma hts hη hw)).continuous.integrable_of_hasCompactSupport hc₂.mul_right.mul_right have hi₃ : Integrable (fun x => w x^2*gamma τ η η x) μ := ((hw.pow 2).mul (smooth_gamma hts hη hη)).continuous.integrable_of_hasCompactSupport (compact_gamma_left hηc).mul_left have het : (∫ x, η x^2*gamma τ w w x ∂μ) = -(∫ x, 2*η x*w x*gamma τ η w x ∂μ) := by simp_rw [gamma_cutoff_square hη hw] at hzero rw [integral_add hi₁ hi₂] at hzero linarith have hh := integral_mono hi₂.neg ((hi₁.const_mul (1/2)).add (hi₃.const_mul 2)) (fun x => by simpa only [Pi.neg_apply, Pi.add_apply, neg_mul, mul_assoc] using cutoff_young htp η w x) simp only [Pi.neg_apply, Pi.add_apply] at hh rw [integral_neg, integral_add (hi₁.const_mul (1/2)) (hi₃.const_mul 2), integral_const_mul, integral_const_mul, ← het] at hh have hb := integral_mono hi₃ (hiw.const_mul c) (fun x => by simpa only [mul_comm c] using mul_le_mul_of_nonneg_left (hbound x) (sq_nonneg (w x))) rw [integral_const_mul] at hb nlinarith end DensityEnergy end open scoped ContDiff Topology noncomputable section namespace SmoothCutoff variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [FiniteDimensional ℝ E] local instance dualNorm : NormedAddCommGroup (E →L[ℝ] ℝ) := inferInstance local instance dualSpace : NormedSpace ℝ (E →L[ℝ] ℝ) := inferInstance def base : ContDiffBump (0:E) := ⟨1,2,by norm_num,by norm_num⟩ def cutoff (r : ℝ) (x : E) : ℝ := (base (E:=E) : E → ℝ) (r⁻¹ • x) lemma base_smooth : ContDiff ℝ ∞ (base (E:=E) : E → ℝ) := (base (E:=E)).contDiff lemma smooth (r : ℝ) : ContDiff ℝ ∞ (cutoff (E:=E) r) := base_smooth.comp (contDiff_const.smul contDiff_id) lemma nonneg (r : ℝ) (x : E) : 0 ≤ cutoff r x := (base (E:=E)).nonneg lemma le_one (r : ℝ) (x : E) : cutoff r x ≤ 1 := (base (E:=E)).le_one lemma even (r : ℝ) : Function.Even (cutoff (E:=E) r) := by intro x simpa only [cutoff, smul_neg] using (base (E:=E)).neg (r⁻¹ • x) lemma eq_one {r : ℝ} (hr : 0 < r) {x : E} (hx : ‖x‖ ≤ r) : cutoff r x = 1 := by apply (base (E:=E)).one_of_mem_closedBall change dist (r⁻¹ • x) 0 ≤ (1:ℝ) rw [dist_zero_right, norm_smul, Real.norm_eq_abs, abs_inv, abs_of_pos hr] exact (inv_mul_le_iff₀ hr).mpr (by simpa using hx) lemma eq_zero {r : ℝ} (hr : 0 < r) {x : E} (hx : 2*r ≤ ‖x‖) : cutoff r x = 0 := by apply (base (E:=E)).zero_of_le_dist change (2:ℝ) ≤ dist (r⁻¹ • x) 0 rw [dist_zero_right, norm_smul, Real.norm_eq_abs, abs_inv, abs_of_pos hr] exact (le_inv_mul_iff₀ hr).mpr (by nlinarith) lemma compact {r : ℝ} (hr : 0 < r) : HasCompactSupport (cutoff (E:=E) r) := by apply HasCompactSupport.intro (isCompact_closedBall (0:E) (2*r)) intro x hx apply eq_zero hr have : 2*r < ‖x‖ := by simpa only [Metric.mem_closedBall, dist_zero_right, not_le] using hx exact this.le lemma first (r : ℝ) (x : E) : fderiv ℝ (cutoff r) x = r⁻¹ • fderiv ℝ (base (E:=E) : E → ℝ) (r⁻¹ • x) := by have hb := base_smooth.differentiable (by simp) (r⁻¹ • x) have hs : HasFDerivAt (fun y : E => r⁻¹ • y) (r⁻¹ • ContinuousLinearMap.id ℝ E) x := (hasFDerivAt_id x).const_smul r⁻¹ have hc := hb.hasFDerivAt.comp x hs rw [show cutoff r = (base (E:=E) : E → ℝ) ∘ (fun y : E => r⁻¹ • y) from rfl, hc.fderiv] ext v simp lemma second (r : ℝ) (x : E) : fderiv ℝ (fderiv ℝ (cutoff r)) x = (r⁻¹)^2 • fderiv ℝ (fderiv ℝ (base (E:=E) : E → ℝ)) (r⁻¹ • x) := by have he : fderiv ℝ (cutoff (E:=E) r) = fun y => r⁻¹ • fderiv ℝ (base (E:=E) : E → ℝ) (r⁻¹ • y) := funext (first r) rw [he] have hb := (base_smooth.fderiv_right (m:=∞) (by simp)).differentiable (by simp) (r⁻¹ • x) have hs : HasFDerivAt (fun y : E => r⁻¹ • y) (r⁻¹ • ContinuousLinearMap.id ℝ E) x := (hasFDerivAt_id x).const_smul r⁻¹ have hc := (hb.hasFDerivAt.comp x hs).const_smul r⁻¹ calc _ = r⁻¹ • (fderiv ℝ (fderiv ℝ (base (E:=E) : E → ℝ)) (r⁻¹ • x)).comp (r⁻¹ • ContinuousLinearMap.id ℝ E) := hc.fderiv _ = _ := by ext v w simp [pow_two, mul_assoc] lemma base_first_bound : ∃ C : ℝ, ∀ x : E, ‖fderiv ℝ (base (E:=E) : E → ℝ) x‖ ≤ C := by have h : Continuous (fderiv ℝ (base (E:=E) : E → ℝ)) := ((base_smooth (E:=E)).fderiv_right (m:=∞) (by simp)).continuous exact ((base (E:=E)).hasCompactSupport.fderiv ℝ).exists_bound_of_continuous h lemma base_second_bound : ∃ C : ℝ, ∀ x : E, ‖fderiv ℝ (fderiv ℝ (base (E:=E) : E → ℝ)) x‖ ≤ C := by have h₁ : ContDiff ℝ ∞ (fderiv ℝ (base (E:=E) : E → ℝ)) := (base_smooth (E:=E)).fderiv_right (m:=∞) (by simp) have h₂ : Continuous (fderiv ℝ (fderiv ℝ (base (E:=E) : E → ℝ))) := h₁.continuous_fderiv (by simp) exact (((base (E:=E)).hasCompactSupport.fderiv ℝ).fderiv ℝ).exists_bound_of_continuous h₂ lemma derivative_bounds : ∃ C : ℝ, 0 < C ∧ ∀ r : ℝ, 0 < r → ∀ x : E, ‖fderiv ℝ (cutoff r) x‖ ≤ C/r ∧ ‖fderiv ℝ (fderiv ℝ (cutoff r)) x‖ ≤ C/r^2 := by obtain ⟨C₁,hC₁⟩ := base_first_bound (E:=E) obtain ⟨C₂,hC₂⟩ := base_second_bound (E:=E) let C := max (max C₁ C₂) 1 have hCC₁ : C₁ ≤ C := (le_max_left C₁ C₂).trans (le_max_left _ 1) have hCC₂ : C₂ ≤ C := (le_max_right C₁ C₂).trans (le_max_left _ 1) refine ⟨C, lt_of_lt_of_le zero_lt_one (le_max_right _ _), ?_⟩ intro r hr x have h₁ : ‖fderiv ℝ (base (E:=E) : E → ℝ) (r⁻¹ • x)‖ ≤ C := (hC₁ _).trans hCC₁ have h₂ : ‖fderiv ℝ (fderiv ℝ (base (E:=E) : E → ℝ)) (r⁻¹ • x)‖ ≤ C := (hC₂ _).trans hCC₂ constructor · rw [first, norm_smul, Real.norm_eq_abs, abs_inv, abs_of_pos hr, div_eq_inv_mul] exact mul_le_mul_of_nonneg_left h₁ (inv_nonneg.mpr hr.le) · rw [second] apply (ContinuousLinearMap.opNorm_smul_le ((r⁻¹)^2) (fderiv ℝ (fderiv ℝ (base (E:=E) : E → ℝ)) (r⁻¹ • x))).trans rw [Real.norm_eq_abs, abs_of_nonneg (sq_nonneg _), div_eq_mul_inv, ← inv_pow] simpa only [mul_comm C] using mul_le_mul_of_nonneg_left h₂ (sq_nonneg (r⁻¹)) lemma eventually_one {r : ℝ} (hr : 0 < r) {x : E} (hx : ‖x‖ < r) : cutoff r =ᶠ[𝓝 x] (fun _ => 1) := by filter_upwards [isOpen_lt continuous_norm continuous_const |>.mem_nhds hx] with y hy exact eq_one hr hy.le lemma first_zero_inside {r : ℝ} (hr : 0 < r) {x : E} (hx : ‖x‖ < r) : fderiv ℝ (cutoff r) x = 0 := by rw [(eventually_one hr hx).fderiv_eq] exact fderiv_const_apply (1:ℝ) lemma second_zero_inside {r : ℝ} (hr : 0 < r) {x : E} (hx : ‖x‖ < r) : fderiv ℝ (fderiv ℝ (cutoff r)) x = 0 := by have he : fderiv ℝ (cutoff r) =ᶠ[𝓝 x] (fun _ => (0:E →L[ℝ] ℝ)) := by filter_upwards [isOpen_lt continuous_norm continuous_const |>.mem_nhds hx] with y hy exact first_zero_inside hr hy rw [he.fderiv_eq] exact fderiv_const_apply _ end SmoothCutoff namespace DensityEnergy open MeasureTheory Matrix WeightedCalculus Filter open scoped ContDiff Topology variable {ι : Type*} [Fintype ι] [DecidableEq ι] omit [DecidableEq ι] in lemma D_eventuallyEq {f g : Space ι → ℝ} {x : Space ι} (h : f =ᶠ[𝓝 x] g) (v : Space ι) : D v f =ᶠ[𝓝 x] D v g := by filter_upwards [h.fderiv (𝕜:=ℝ)] with y hy exact congrArg (fun L : Space ι →L[ℝ] ℝ => L v) hy lemma A_congr {τ : Space ι → Matrix ι ι ℝ} {f g : Space ι → ℝ} {x : Space ι} (h : f =ᶠ[𝓝 x] g) : A τ f x = A τ g x := by unfold A congr 1 · apply Finset.sum_congr rfl; intro i _ rw [(D_eventuallyEq h (e i)).eq_of_nhds] · apply Finset.sum_congr rfl; intro i _ apply Finset.sum_congr rfl; intro j _ rw [(D_eventuallyEq (D_eventuallyEq h (e j)) (e i)).eq_of_nhds] lemma grad_congr {f g : Space ι → ℝ} {x : Space ι} (h : f =ᶠ[𝓝 x] g) : grad f x = grad g x := by funext i exact (D_eventuallyEq h (e i)).eq_of_nhds lemma grad_zero_of_not_tsupport {f : Space ι → ℝ} {x : Space ι} (hx : x ∉ tsupport f) : grad f x = 0 := by have he : f =ᶠ[𝓝 x] (fun _ => 0) := by filter_upwards [(isClosed_tsupport f).isOpen_compl.mem_nhds hx] with y hy exact image_eq_zero_of_notMem_tsupport hy rw [grad_congr he] funext i simp [grad, D] lemma extend_integration (μ : Measure (Space ι)) {τ : Space ι → Matrix ι ι ℝ} (hibp : ∀ f h : Space ι → ℝ, ContDiff ℝ ∞ f → ContDiff ℝ ∞ h → HasCompactSupport f → HasCompactSupport h → (∫ x, h x*A τ f x ∂μ) = ∫ x, gamma τ h f x ∂μ) {f h : Space ι → ℝ} (hf : ContDiff ℝ ∞ f) (hh : ContDiff ℝ ∞ h) (hhc : HasCompactSupport h) : (∫ x, h x*A τ f x ∂μ) = ∫ x, gamma τ h f x ∂μ := by obtain ⟨R,hR⟩ := hhc.isBounded.subset_closedBall (0:Space ι) let r : ℝ := max R 0 + 1 have hr : 0 < r := by dsimp [r]; positivity let f' : Space ι → ℝ := fun x => SmoothCutoff.cutoff r x*f x have hs : ContDiff ℝ ∞ f' := (SmoothCutoff.smooth r).mul hf have hc : HasCompactSupport f' := (SmoothCutoff.compact hr).mul_right have he (x : Space ι) (hx : x ∈ tsupport h) : f' =ᶠ[𝓝 x] f := by have hxR : ‖x‖ ≤ R := by simpa only [Metric.mem_closedBall, dist_zero_right] using hR hx have hxr : ‖x‖ < r := by dsimp [r]; have := le_max_left R 0; linarith filter_upwards [SmoothCutoff.eventually_one hr hxr] with y hy change SmoothCutoff.cutoff r y*f y = f y rw [hy, one_mul] have hl : (fun x => h x*A τ f' x) = fun x => h x*A τ f x := by funext x by_cases hx : x ∈ tsupport h · rw [A_congr (he x hx)] · rw [image_eq_zero_of_notMem_tsupport hx, zero_mul, zero_mul] have hg : gamma τ h f' = gamma τ h f := by funext x by_cases hx : x ∈ tsupport h · unfold gamma; rw [grad_congr (he x hx)] · unfold gamma; rw [grad_zero_of_not_tsupport hx]; simp have hh' := hibp f' h hs hh hc hhc simpa only [hl, hg] using hh' lemma harmonic_test (μ : Measure (Space ι)) {τ : Space ι → Matrix ι ι ℝ} (hibp : ∀ f h : Space ι → ℝ, ContDiff ℝ ∞ f → ContDiff ℝ ∞ h → HasCompactSupport f → HasCompactSupport h → (∫ x, h x*A τ f x ∂μ) = ∫ x, gamma τ h f x ∂μ) {η w : Space ι → ℝ} (hη : ContDiff ℝ ∞ η) (hηc : HasCompactSupport η) (hw : ContDiff ℝ ∞ w) (hAw : A τ w = 0) : (∫ x, gamma τ (fun x => η x^2*w x) w x ∂μ) = 0 := by have hcη : HasCompactSupport (fun x => η x^2) := by rw [show (fun x => η x^2) = η*η by ext x; simp only [Pi.mul_apply, pow_two]] exact hηc.mul_right rw [← extend_integration μ hibp hw ((hη.pow 2).mul hw) hcη.mul_right] simp only [hAw, Pi.zero_apply, mul_zero, integral_zero] lemma grad_le (f : Space ι → ℝ) (x : Space ι) (i : ι) : |grad f x i| ≤ ‖fderiv ℝ f x‖ := by have hh := (fderiv ℝ f x).le_opNorm (e i) simpa only [e, Pi.norm_single, norm_one, mul_one, Real.norm_eq_abs, grad, D] using hh lemma gamma_upper {τ : Space ι → Matrix ι ι ℝ} {Λ : ℝ} (hΛ : 0 ≤ Λ) (hupper : ∀ x, (Λ • (1 : Matrix ι ι ℝ) - τ x).PosSemidef) (f : Space ι → ℝ) (x : Space ι) : gamma τ f f x ≤ Λ * (Fintype.card ι : ℝ) * ‖fderiv ℝ f x‖^2 := by have hh := MomentMatrix.form_nonneg (hupper x) (grad f x) simp only [Matrix.sub_mulVec, Matrix.smul_mulVec, Matrix.one_mulVec, dotProduct_sub, dotProduct_smul, smul_eq_mul] at hh have hs : grad f x ⬝ᵥ grad f x ≤ (Fintype.card ι : ℝ) * ‖fderiv ℝ f x‖^2 := by calc _ = ∑ i, (grad f x i)^2 := by simp only [dotProduct, pow_two] _ ≤ ∑ _ : ι, ‖fderiv ℝ f x‖^2 := by apply Finset.sum_le_sum; intro i _ simpa only [sq_abs] using (sq_le_sq₀ (abs_nonneg _) (norm_nonneg _)).mpr (grad_le f x i) _ = _ := by simp have hm := mul_le_mul_of_nonneg_left hs hΛ unfold gamma nlinarith lemma cutoff_gamma_bound {τ : Space ι → Matrix ι ι ℝ} {Λ : ℝ} (hΛ : 0 ≤ Λ) (hupper : ∀ x, (Λ • (1 : Matrix ι ι ℝ) - τ x).PosSemidef) : ∃ D : ℝ, 0 ≤ D ∧ ∀ (r : ℝ), 0 < r → ∀ x : Space ι, gamma τ (SmoothCutoff.cutoff r) (SmoothCutoff.cutoff r) x ≤ D/r^2 := by obtain ⟨C,hC,hCb⟩ := SmoothCutoff.derivative_bounds (E:=Space ι) refine ⟨Λ*(Fintype.card ι : ℝ)*C^2, by positivity, ?_⟩ intro r hr x calc _ ≤ Λ*(Fintype.card ι : ℝ)*‖fderiv ℝ (SmoothCutoff.cutoff r) x‖^2 := gamma_upper hΛ hupper _ _ _ ≤ Λ*(Fintype.card ι : ℝ)*(C/r)^2 := mul_le_mul_of_nonneg_left (pow_le_pow_left₀ (norm_nonneg _) (hCb r hr x).1 2) (by positivity) _ = _ := by rw [div_pow, mul_div_assoc] end DensityEnergy namespace SmoothCutoff open Filter MeasureTheory open scoped ContDiff Topology section variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [FiniteDimensional ℝ E] def seq (k : ℕ) : E → ℝ := cutoff ((k:ℝ)+1) lemma seq_smooth (k : ℕ) : ContDiff ℝ ∞ (seq (E:=E) k) := smooth _ lemma seq_compact (k : ℕ) : HasCompactSupport (seq (E:=E) k) := compact (by positivity) lemma seq_nonneg (k : ℕ) (x : E) : 0 ≤ seq k x := nonneg _ _ lemma seq_le_one (k : ℕ) (x : E) : seq k x ≤ 1 := le_one _ _ lemma seq_eventually (x : E) : ∀ᶠ k : ℕ in atTop, seq k x = 1 ∧ fderiv ℝ (seq k) x = 0 ∧ fderiv ℝ (fderiv ℝ (seq k)) x = 0 := by obtain ⟨N,hN⟩ := exists_nat_gt ‖x‖ apply eventually_atTop.mpr refine ⟨N,fun k hk => ?_⟩ have hx : ‖x‖ < (k:ℝ)+1 := by have hn : (N:ℝ) ≤ k := Nat.cast_le.mpr hk linarith exact ⟨eq_one (by positivity) hx.le, first_zero_inside (by positivity) hx, second_zero_inside (by positivity) hx⟩ lemma seq_derivative_bounds : ∃ C : ℝ, 0 < C ∧ ∀ k : ℕ, ∀ x : E, ‖fderiv ℝ (seq k) x‖ ≤ C ∧ ‖fderiv ℝ (fderiv ℝ (seq k)) x‖ ≤ C := by obtain ⟨C,hC,h⟩ := derivative_bounds (E:=E) refine ⟨C,hC,fun k x => ?_⟩ have hk : (1:ℝ) ≤ (k:ℝ)+1 := by have := Nat.cast_nonneg (α:=ℝ) k; linarith have hh := h ((k:ℝ)+1) (by positivity) x constructor · exact hh.1.trans ((div_le_self hC.le hk)) · exact hh.2.trans (div_le_self hC.le (by nlinarith)) end variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] lemma integrable_of_cutoff_bound (μ : Measure E) [IsFiniteMeasure μ] {F : E → ℝ} (hF : Continuous F) (hFn : ∀ x, 0 ≤ F x) (p : ℕ) {C : ℝ} (hC : 0 ≤ C) (hbound : ∀ k : ℕ, (∫ x, (seq k x)^p*F x ∂μ) ≤ C) (hi : ∀ k : ℕ, Integrable (fun x => (seq k x)^p*F x) μ) : Integrable F μ ∧ (∫ x, F x ∂μ) ≤ C := by have hff (k : ℕ) : Continuous (fun x => ENNReal.ofReal ((seq k x)^p*F x)) := ENNReal.continuous_ofReal.comp (((seq_smooth k).continuous.pow p).mul hF) have hn (k : ℕ) (x : E) : 0 ≤ (seq k x)^p*F x := mul_nonneg (pow_nonneg (seq_nonneg k x) p) (hFn x) have hl (x : E) : liminf (fun k => ENNReal.ofReal ((seq k x)^p*F x)) atTop = ENNReal.ofReal (F x) := by apply Tendsto.liminf_eq apply tendsto_const_nhds.congr' filter_upwards [seq_eventually x] with k hk simp only [hk.1, one_pow, one_mul] have hb : (∫⁻ x, ENNReal.ofReal (F x) ∂μ) ≤ ENNReal.ofReal C := by calc _ = ∫⁻ x, liminf (fun k => ENNReal.ofReal ((seq k x)^p*F x)) atTop ∂μ := by simp only [hl] _ ≤ liminf (fun k => ∫⁻ x, ENNReal.ofReal ((seq k x)^p*F x) ∂μ) atTop := lintegral_liminf_le (fun k => (hff k).measurable) _ ≤ ENNReal.ofReal C := by apply liminf_le_of_frequently_le (hu_le := isBoundedUnder_of ⟨0, fun _ => bot_le⟩) apply Frequently.of_forall intro k rw [← ofReal_integral_eq_lintegral_ofReal (hi k) (ae_of_all μ (hn k))] exact ENNReal.ofReal_le_ofReal (hbound k) have hf : Integrable F μ := ⟨hF.aestronglyMeasurable, (hasFiniteIntegral_iff_ofReal (ae_of_all μ hFn)).mpr (hb.trans_lt ENNReal.ofReal_lt_top)⟩ refine ⟨hf, ?_⟩ rw [← ofReal_integral_eq_lintegral_ofReal hf (ae_of_all μ hFn)] at hb exact (ENNReal.ofReal_le_ofReal_iff hC).mp hb end SmoothCutoff namespace DensityEnergy open MeasureTheory Matrix WeightedCalculus Filter open scoped ContDiff Topology variable {ι : Type*} [Fintype ι] [DecidableEq ι] lemma energy_estimate (μ : Measure (Space ι)) [IsFiniteMeasure μ] {τ : Space ι → Matrix ι ι ℝ} (hts : ∀ i j, ContDiff ℝ ∞ (fun x => τ x i j)) (htp : ∀ x, (τ x).PosSemidef) (hibp : ∀ f h : Space ι → ℝ, ContDiff ℝ ∞ f → ContDiff ℝ ∞ h → HasCompactSupport f → HasCompactSupport h → (∫ x, h x*A τ f x ∂μ) = ∫ x, gamma τ h f x ∂μ) {η w : Space ι → ℝ} (hη : ContDiff ℝ ∞ η) (hηc : HasCompactSupport η) (hw : ContDiff ℝ ∞ w) (hiw : Integrable (fun x => w x^2) μ) {c : ℝ} (hbound : ∀ x, gamma τ η η x ≤ c) : (∫ x, η x^2*gamma τ w w x ∂μ) ≤ 2*(∫ x, η x^2*w x*A τ w x ∂μ) + 4*c*(∫ x, w x^2 ∂μ) := by have hcη : HasCompactSupport (fun x => η x^2) := by rw [show (fun x => η x^2) = η*η by ext x; simp only [Pi.mul_apply, pow_two]] exact hηc.mul_right have hc₂ : HasCompactSupport (fun x => 2*η x) := hηc.mul_left have hi₁ : Integrable (fun x => η x^2*gamma τ w w x) μ := ((hη.pow 2).mul (smooth_gamma hts hw hw)).continuous.integrable_of_hasCompactSupport hcη.mul_right have hi₂ : Integrable (fun x => 2*η x*w x*gamma τ η w x) μ := (((contDiff_const.mul hη).mul hw).mul (smooth_gamma hts hη hw)).continuous.integrable_of_hasCompactSupport hc₂.mul_right.mul_right have hi₃ : Integrable (fun x => w x^2*gamma τ η η x) μ := ((hw.pow 2).mul (smooth_gamma hts hη hη)).continuous.integrable_of_hasCompactSupport (compact_gamma_left hηc).mul_left have het := extend_integration μ hibp hw ((hη.pow 2).mul hw) hcη.mul_right simp_rw [gamma_cutoff_square hη hw] at het rw [integral_add hi₁ hi₂] at het have hh := integral_mono hi₂.neg ((hi₁.const_mul (1/2)).add (hi₃.const_mul 2)) (fun x => by simpa only [Pi.neg_apply, Pi.add_apply, neg_mul, mul_assoc] using cutoff_young htp η w x) simp only [Pi.neg_apply, Pi.add_apply] at hh rw [integral_neg, integral_add (hi₁.const_mul (1/2)) (hi₃.const_mul 2), integral_const_mul, integral_const_mul] at hh have hb := integral_mono hi₃ (hiw.const_mul c) (fun x => by simpa only [mul_comm c] using mul_le_mul_of_nonneg_left (hbound x) (sq_nonneg (w x))) rw [integral_const_mul] at hb nlinarith lemma eigen_energy_integrable (μ : Measure (Space ι)) [IsFiniteMeasure μ] {τ : Space ι → Matrix ι ι ℝ} (hts : ∀ i j, ContDiff ℝ ∞ (fun x => τ x i j)) (htp : ∀ x, (τ x).PosSemidef) {Λ : ℝ} (hΛ : 0 ≤ Λ) (hupper : ∀ x, (Λ • (1 : Matrix ι ι ℝ)-τ x).PosSemidef) (hibp : ∀ f h : Space ι → ℝ, ContDiff ℝ ∞ f → ContDiff ℝ ∞ h → HasCompactSupport f → HasCompactSupport h → (∫ x, h x*A τ f x ∂μ) = ∫ x, gamma τ h f x ∂μ) {v : Space ι → ℝ} (hv : ContDiff ℝ ∞ v) (hiv : Integrable (fun x => v x^2) μ) (hAv : A τ v = v) : Integrable (gamma τ v v) μ := by obtain ⟨D,hD,hDb⟩ := cutoff_gamma_bound hΛ hupper have hb (k : ℕ) (x : Space ι) : gamma τ (SmoothCutoff.seq k) (SmoothCutoff.seq k) x ≤ D := by apply (hDb _ (by positivity) x).trans exact div_le_self hD (by have := Nat.cast_nonneg (α:=ℝ) k; nlinarith) let C := (2+4*D)*(∫ x, v x^2 ∂μ) have hC : 0 ≤ C := mul_nonneg (by positivity) (integral_nonneg fun x => sq_nonneg _) have hi (k : ℕ) : Integrable (fun x => (SmoothCutoff.seq k x)^2*gamma τ v v x) μ := by have hcη : HasCompactSupport (fun x : Space ι => (SmoothCutoff.seq k x)^2) := by rw [show (fun x : Space ι => (SmoothCutoff.seq k x)^2) = SmoothCutoff.seq k*SmoothCutoff.seq k by ext x; simp only [Pi.mul_apply,pow_two]] exact (SmoothCutoff.seq_compact k).mul_right exact (((SmoothCutoff.seq_smooth k).pow 2).mul (smooth_gamma hts hv hv)).continuous.integrable_of_hasCompactSupport hcη.mul_right apply (SmoothCutoff.integrable_of_cutoff_bound μ (smooth_gamma hts hv hv).continuous (gamma_nonneg htp v) 2 hC (fun k => ?_) hi).1 have hh := energy_estimate μ hts htp hibp (SmoothCutoff.seq_smooth k) (SmoothCutoff.seq_compact k) hv hiv (hb k) have he : (fun x => (SmoothCutoff.seq k x)^2*v x*A τ v x) = fun x => (SmoothCutoff.seq k x)^2*v x^2 := by rw [hAv]; ext x; ring rw [he] at hh have hk (x : Space ι) : (SmoothCutoff.seq k x)^2*v x^2 ≤ v x^2 := by have hη := pow_le_pow_left₀ (SmoothCutoff.seq_nonneg k x) (SmoothCutoff.seq_le_one k x) 2 simpa only [one_pow,one_mul] using mul_le_mul_of_nonneg_right hη (sq_nonneg (v x)) have hir : Integrable (fun x => (SmoothCutoff.seq k x)^2*v x^2) μ := by apply hiv.mono' (((SmoothCutoff.seq_smooth k).pow 2).mul (hv.pow 2)).continuous.aestronglyMeasurable exact ae_of_all μ (fun x => by rw [Real.norm_eq_abs, abs_of_nonneg (mul_nonneg (sq_nonneg _) (sq_nonneg _))]; exact hk x) have hl := integral_mono hir hiv hk dsimp [C] nlinarith lemma DD_mul {f g : Space ι → ℝ} (hf : ContDiff ℝ ∞ f) (hg : ContDiff ℝ ∞ g) (i j : ι) : D (e i) (D (e j) (fun x => f x*g x)) = fun x => g x*D (e i) (D (e j) f) x + f x*D (e i) (D (e j) g) x + D (e i) f x*D (e j) g x + D (e j) f x*D (e i) g x := by rw [D_mul (hf.differentiable (by simp)) (hg.differentiable (by simp)), D_add (((smooth_D hf _).mul hg).differentiable (by simp)) ((hf.mul (smooth_D hg _)).differentiable (by simp)), D_mul ((smooth_D hf _).differentiable (by simp)) (hg.differentiable (by simp)), D_mul (hf.differentiable (by simp)) ((smooth_D hg _).differentiable (by simp))] funext x; ring lemma gamma_sum (τ : Space ι → Matrix ι ι ℝ) (f g : Space ι → ℝ) (x : Space ι) : gamma τ f g x = ∑ i, ∑ j, τ x i j * D (e i) f x * D (e j) g x := by simp only [gamma, grad, Matrix.mulVec, dotProduct, Finset.mul_sum] apply Finset.sum_congr rfl; intro i _ apply Finset.sum_congr rfl; intro j _ ring lemma A_mul {τ : Space ι → Matrix ι ι ℝ} (hτ : ∀ x, (τ x)ᵀ = τ x) {f g : Space ι → ℝ} (hf : ContDiff ℝ ∞ f) (hg : ContDiff ℝ ∞ g) (x : Space ι) : A τ (fun x => f x*g x) x = f x*A τ g x + g x*A τ f x - 2*gamma τ f g x := by have hsym := gamma_symm hτ g f x rw [gamma_sum, gamma_sum] at hsym conv_lhs => unfold A simp only [DD_mul hf hg] simp only [D_mul (hf.differentiable (by simp)) (hg.differentiable (by simp))] have hd : (∑ i, x i * (D (e i) f x*g x+f x*D (e i) g x)) = g x*(∑ i, x i*D (e i) f x) + f x*(∑ i, x i*D (e i) g x) := by simp only [Finset.mul_sum, ← Finset.sum_add_distrib] apply Finset.sum_congr rfl; intro i _; ring rw [hd] have hh : (∑ i, ∑ j, τ x i j * (g x*D (e i) (D (e j) f) x + f x*D (e i) (D (e j) g) x + D (e i) f x*D (e j) g x + D (e j) f x*D (e i) g x)) = g x*(∑ i, ∑ j, τ x i j*D (e i) (D (e j) f) x) + f x*(∑ i, ∑ j, τ x i j*D (e i) (D (e j) g) x) + (∑ i, ∑ j, τ x i j*D (e i) f x*D (e j) g x) + (∑ i, ∑ j, τ x i j*D (e i) g x*D (e j) f x) := by simp only [Finset.mul_sum, ← Finset.sum_add_distrib] apply Finset.sum_congr rfl; intro i _ apply Finset.sum_congr rfl; intro j _; ring rw [hh, hsym] simp only [A, gamma_sum] ring lemma gamma_pow_left {τ : Space ι → Matrix ι ι ℝ} {f g : Space ι → ℝ} (hf : ContDiff ℝ ∞ f) (n : ℕ) (x : Space ι) : gamma τ (fun x => f x^(n+1)) g x = (n+1 : ℝ)*f x^n*gamma τ f g x := by induction n with | zero => simp only [zero_add, pow_one, Nat.cast_zero, zero_add, pow_zero, mul_one, one_mul] | succ n ih => simp only [pow_succ (f _) (n+1)] rw [gamma_mul_left (hf.pow _) hf, ih] push_cast ring lemma A_pow_succ {τ : Space ι → Matrix ι ι ℝ} (hτ : ∀ x, (τ x)ᵀ = τ x) {f : Space ι → ℝ} (hf : ContDiff ℝ ∞ f) (n : ℕ) (x : Space ι) : A τ (fun x => f x^(n+2)) x = (n+2 : ℝ)*f x^(n+1)*A τ f x - (n+2 : ℝ)*(n+1)*f x^n*gamma τ f f x := by induction n with | zero => simp only [zero_add, pow_one, pow_zero, Nat.cast_zero] simp only [pow_two] rw [A_mul hτ hf hf] ring | succ n ih => simp only [show n+1+2 = n+2+1 by omega, pow_succ (f _) (n+2)] rw [A_mul hτ (hf.pow _) hf, ih, gamma_pow_left hf (n+1)] push_cast simp only [pow_succ] ring lemma smooth_A {τ : Space ι → Matrix ι ι ℝ} (ht : ∀ i j, ContDiff ℝ ∞ (fun x => τ x i j)) {f : Space ι → ℝ} (hf : ContDiff ℝ ∞ f) : ContDiff ℝ ∞ (A τ f) := by apply ContDiff.sub · apply ContDiff.sum; intro i _ exact (contDiff_apply ℝ ℝ i).mul (smooth_D hf _) · apply ContDiff.sum; intro i _ apply ContDiff.sum; intro j _ exact (ht i j).mul (smooth_D (smooth_D hf _) _) lemma compact_A {τ : Space ι → Matrix ι ι ℝ} {f : Space ι → ℝ} (hf : HasCompactSupport f) : HasCompactSupport (A τ f) := (compact_sum _ (fun i => (compact_D hf (e i)).mul_left)).sub (compact_sum _ (fun i => compact_sum _ (fun j => ((compact_D (compact_D hf (e j)) (e i))).mul_left))) lemma entries_bound {T : Matrix ι ι ℝ} (hT : T.PosSemidef) {Λ : ℝ} (hΛ : 0 ≤ Λ) (hc : (Λ • (1 : Matrix ι ι ℝ)-T).PosSemidef) (i j : ι) : |T i j| ≤ Λ := by have hd (k : ι) : T k k ≤ Λ := by have hh := hc.diag_nonneg (i:=k) simp only [Matrix.sub_apply, Matrix.smul_apply, Matrix.one_apply_eq, smul_eq_mul, mul_one] at hh linarith have hs : Tᵀ = T := by simpa only [Matrix.conjTranspose_eq_transpose_of_trivial] using hT.isHermitian.eq have hsq : (T i j)^2 ≤ T i i*T j j := by apply MomentMatrix.quadratic_cs intro t have hh := MomentMatrix.form_nonneg hT (e j-t • e i) rw [MomentMatrix.form_quadratic hs] at hh simpa [e, Matrix.mulVec, dotProduct, Pi.single_apply] using hh have hle := mul_le_mul (hd i) (hd j) (hT.diag_nonneg (i:=j)) hΛ apply (sq_le_sq₀ (abs_nonneg _) hΛ).mp rw [sq_abs] nlinarith lemma second_coordinate {f : Space ι → ℝ} (hf : ContDiff ℝ ∞ f) (x : Space ι) (i j : ι) : D (e i) (D (e j) f) x = fderiv ℝ (fderiv ℝ f) x (e i) (e j) := by have hd := (hf.fderiv_right (m:=∞) (by simp)).differentiable (by simp) change fderiv ℝ (fun y => fderiv ℝ f y (e j)) x (e i) = _ simp only [fderiv_clm_apply (hd x) (differentiableAt_const _), fderiv_const_apply, ContinuousLinearMap.comp_zero, zero_add, ContinuousLinearMap.flip_apply] lemma second_coordinate_bound {f : Space ι → ℝ} (hf : ContDiff ℝ ∞ f) (x : Space ι) (i j : ι) : |D (e i) (D (e j) f) x| ≤ ‖fderiv ℝ (fderiv ℝ f) x‖ := by rw [second_coordinate hf x i j, ← Real.norm_eq_abs] have h₁ := (fderiv ℝ (fderiv ℝ f) x (e i)).le_opNorm (e j) have h₂ := (fderiv ℝ (fderiv ℝ f) x).le_opNorm (e i) simp only [e, Pi.norm_single, norm_one, mul_one] at h₁ h₂ exact h₁.trans h₂ lemma A_bound {τ : Space ι → Matrix ι ι ℝ} (ht : ∀ x, (τ x).PosSemidef) {Λ : ℝ} (hΛ : 0 ≤ Λ) (hc : ∀ x, (Λ • (1 : Matrix ι ι ℝ)-τ x).PosSemidef) {f : Space ι → ℝ} (hf : ContDiff ℝ ∞ f) (x : Space ι) : |A τ f x| ≤ (Fintype.card ι : ℝ)*‖x‖*‖fderiv ℝ f x‖ + (Fintype.card ι : ℝ)^2*Λ*‖fderiv ℝ (fderiv ℝ f) x‖ := by unfold A apply (abs_sub _ _).trans apply add_le_add · apply (Finset.abs_sum_le_sum_abs _ _).trans calc _ ≤ ∑ _ : ι, ‖x‖*‖fderiv ℝ f x‖ := by apply Finset.sum_le_sum; intro i _ rw [abs_mul] exact mul_le_mul (by simpa only [Real.norm_eq_abs] using norm_le_pi_norm x i) (grad_le f x i) (abs_nonneg _) (norm_nonneg _) _ = _ := by simp [mul_assoc] · apply (Finset.abs_sum_le_sum_abs _ _).trans calc _ ≤ ∑ _ : ι, ∑ _ : ι, Λ*‖fderiv ℝ (fderiv ℝ f) x‖ := by apply Finset.sum_le_sum; intro i _ apply (Finset.abs_sum_le_sum_abs _ _).trans apply Finset.sum_le_sum; intro j _ rw [abs_mul] exact mul_le_mul (entries_bound (ht x) hΛ (hc x) i j) (second_coordinate_bound hf x i j) (abs_nonneg _) hΛ _ = _ := by simp [pow_two, mul_assoc] lemma cutoff_A_bound {τ : Space ι → Matrix ι ι ℝ} (ht : ∀ x, (τ x).PosSemidef) {Λ : ℝ} (hΛ : 0 ≤ Λ) (hc : ∀ x, (Λ • (1 : Matrix ι ι ℝ)-τ x).PosSemidef) : ∃ K : ℝ, 0 ≤ K ∧ ∀ r : ℝ, 1 ≤ r → ∀ x : Space ι, |A τ (SmoothCutoff.cutoff r) x| ≤ K := by obtain ⟨C,hC,hCb⟩ := SmoothCutoff.derivative_bounds (E:=Space ι) refine ⟨2*(Fintype.card ι : ℝ)*C+(Fintype.card ι : ℝ)^2*Λ*C,by positivity,?_⟩ intro r hr x have hrp : 0 < r := lt_of_lt_of_le zero_lt_one hr by_cases hx : ‖x‖ ≤ 2*r · apply (A_bound ht hΛ hc (SmoothCutoff.smooth r) x).trans have hh := hCb r hrp x have h₁ : ‖x‖*‖fderiv ℝ (SmoothCutoff.cutoff r) x‖ ≤ 2*C := by calc _ ≤ (2*r)*(C/r) := mul_le_mul hx hh.1 (norm_nonneg _) (by positivity) _ = 2*C := by field_simp have h₂ : ‖fderiv ℝ (fderiv ℝ (SmoothCutoff.cutoff r)) x‖ ≤ C := hh.2.trans (div_le_self hC.le (by nlinarith)) nlinarith [mul_le_mul_of_nonneg_left h₁ (Nat.cast_nonneg (α:=ℝ) (Fintype.card ι)), mul_le_mul_of_nonneg_left h₂ (by positivity : 0 ≤ (Fintype.card ι : ℝ)^2*Λ)] · have he : SmoothCutoff.cutoff r =ᶠ[𝓝 x] (0:Space ι → ℝ) := by filter_upwards [isOpen_lt continuous_const continuous_norm |>.mem_nhds (not_le.mp hx)] with y hy exact SmoothCutoff.eq_zero hrp hy.le rw [A_congr he] have hz (i : ι) : D (e i) (0:Space ι → ℝ) = 0 := by funext y; simp [D] simpa only [A, hz, Pi.zero_apply, mul_zero, Finset.sum_const_zero, sub_self, abs_zero] using (show (0:ℝ) ≤ 2*(Fintype.card ι : ℝ)*C+(Fintype.card ι : ℝ)^2*Λ*C from by positivity) lemma gamma_cs {τ : Space ι → Matrix ι ι ℝ} (ht : ∀ x, (τ x).PosSemidef) (f g : Space ι → ℝ) (x : Space ι) : (gamma τ f g x)^2 ≤ gamma τ f f x*gamma τ g g x := by apply MomentMatrix.quadratic_cs intro t have hs : (τ x)ᵀ = τ x := by simpa only [Matrix.conjTranspose_eq_transpose_of_trivial] using (ht x).isHermitian.eq have hh := MomentMatrix.form_nonneg (ht x) (grad g x-t • grad f x) rw [MomentMatrix.form_quadratic hs] at hh exact hh lemma eigen_cutoff_square_bound {τ : Space ι → Matrix ι ι ℝ} (ht : ∀ x, (τ x).PosSemidef) {η v : Space ι → ℝ} (hη : ContDiff ℝ ∞ η) (hv : ContDiff ℝ ∞ v) (hAv : A τ v = v) {D K : ℝ} (_hD : 0 ≤ D) (hK : 0 ≤ K) (hηn : ∀ x, 0 ≤ η x) (hηl : ∀ x, η x ≤ 1) (hηA : ∀ x, |A τ η x| ≤ K) (hηΓ : ∀ x, gamma τ η η x ≤ D) (x : Space ι) : (A τ (fun x => η x*v x) x)^2 ≤ (4+4*K^2)*v x^2+8*D*gamma τ v v x := by have hs (y : Space ι) : (τ y)ᵀ = τ y := by simpa only [Matrix.conjTranspose_eq_transpose_of_trivial] using (ht y).isHermitian.eq rw [A_mul hs hη hv, hAv] have he : (η x)^2 ≤ 1 := by simpa using pow_le_pow_left₀ (hηn x) (hηl x) 2 have ha : (A τ η x)^2 ≤ K^2 := by simpa only [sq_abs] using (sq_le_sq₀ (abs_nonneg _) hK).mpr (hηA x) have hΓ := (gamma_cs ht η v x).trans (mul_le_mul_of_nonneg_right (hηΓ x) (gamma_nonneg ht v x)) have hy : (η x+A τ η x)^2 ≤ 2+2*K^2 := by nlinarith [sq_nonneg (η x-A τ η x)] have hm := mul_le_mul_of_nonneg_right hy (sq_nonneg (v x)) nlinarith [sq_nonneg ((η x+A τ η x)*v x+2*gamma τ η v x), mul_nonneg _hD (gamma_nonneg ht v x)] omit [DecidableEq ι] in lemma cutoff_product_eventually (v : Space ι → ℝ) (x : Space ι) : ∀ᶠ k : ℕ in atTop, (fun y => SmoothCutoff.seq k y*v y) =ᶠ[𝓝 x] v := by obtain ⟨N,hN⟩ := exists_nat_gt ‖x‖ apply eventually_atTop.mpr refine ⟨N,fun k hk => ?_⟩ have hx : ‖x‖ < (k:ℝ)+1 := by have hn : (N:ℝ) ≤ k := Nat.cast_le.mpr hk linarith filter_upwards [SmoothCutoff.eventually_one (by positivity) hx] with y hy change SmoothCutoff.cutoff ((k:ℝ)+1) y*v y = v y rw [hy,one_mul] lemma eigen_graph_integrals (μ : Measure (Space ι)) [IsFiniteMeasure μ] {τ : Space ι → Matrix ι ι ℝ} (hts : ∀ i j, ContDiff ℝ ∞ (fun x => τ x i j)) (htp : ∀ x, (τ x).PosSemidef) {Λ : ℝ} (hΛ : 0 ≤ Λ) (hupper : ∀ x, (Λ • (1 : Matrix ι ι ℝ)-τ x).PosSemidef) (hibp : ∀ f h : Space ι → ℝ, ContDiff ℝ ∞ f → ContDiff ℝ ∞ h → HasCompactSupport f → HasCompactSupport h → (∫ x, h x*A τ f x ∂μ) = ∫ x, gamma τ h f x ∂μ) {v : Space ι → ℝ} (hv : ContDiff ℝ ∞ v) (hiv : Integrable (fun x => v x^2) μ) (hAv : A τ v = v) : Tendsto (fun k : ℕ => ∫ x, (A τ (fun y => SmoothCutoff.seq k y*v y) x)^2 ∂μ) atTop (𝓝 (∫ x, v x^2 ∂μ)) ∧ Tendsto (fun k : ℕ => ∫ x, (SmoothCutoff.seq k x*v x)*A τ (fun y => SmoothCutoff.seq k y*v y) x ∂μ) atTop (𝓝 (∫ x, v x^2 ∂μ)) := by have hiΓ := eigen_energy_integrable μ hts htp hΛ hupper hibp hv hiv hAv obtain ⟨D,hD,hDb⟩ := cutoff_gamma_bound hΛ hupper obtain ⟨K,hK,hKb⟩ := cutoff_A_bound htp hΛ hupper let f (k : ℕ) : Space ι → ℝ := fun x => SmoothCutoff.seq k x*v x have hf (k : ℕ) : ContDiff ℝ ∞ (f k) := (SmoothCutoff.seq_smooth k).mul hv have hbΓ (k : ℕ) (x : Space ι) : gamma τ (SmoothCutoff.seq k) (SmoothCutoff.seq k) x ≤ D := by apply (hDb _ (by positivity) x).trans exact div_le_self hD (by have := Nat.cast_nonneg (α:=ℝ) k; nlinarith) have hbA (k : ℕ) (x : Space ι) : |A τ (SmoothCutoff.seq k) x| ≤ K := hKb _ (by have := Nat.cast_nonneg (α:=ℝ) k; linarith) x let B : Space ι → ℝ := fun x => (4+4*K^2)*v x^2+8*D*gamma τ v v x have hiB : Integrable B μ := (hiv.const_mul _).add (hiΓ.const_mul _) have hb (k : ℕ) (x : Space ι) : (A τ (f k) x)^2 ≤ B x := eigen_cutoff_square_bound htp (SmoothCutoff.seq_smooth k) hv hAv hD hK (SmoothCutoff.seq_nonneg k) (SmoothCutoff.seq_le_one k) (hbA k) (hbΓ k) x have hfb (k : ℕ) (x : Space ι) : (f k x)^2 ≤ v x^2 := by have hη := pow_le_pow_left₀ (SmoothCutoff.seq_nonneg k x) (SmoothCutoff.seq_le_one k x) 2 dsimp [f] simpa only [mul_pow,one_pow,one_mul] using mul_le_mul_of_nonneg_right hη (sq_nonneg (v x)) have hev (x : Space ι) : ∀ᶠ k : ℕ in atTop, f k x = v x ∧ A τ (f k) x = v x := by filter_upwards [cutoff_product_eventually v x] with k hk exact ⟨hk.eq_of_nhds, by rw [A_congr hk,hAv]⟩ constructor · apply tendsto_integral_of_dominated_convergence B · intro k; exact ((smooth_A hts (hf k)).pow 2).continuous.aestronglyMeasurable · exact hiB · intro k; exact ae_of_all μ (fun x => by change ‖(A τ (f k) x)^2‖ ≤ B x rw [Real.norm_eq_abs,abs_of_nonneg (sq_nonneg (A τ (f k) x))] exact hb k x) · apply ae_of_all; intro x apply tendsto_const_nhds.congr' filter_upwards [hev x] with k hk rw [hk.2] · apply tendsto_integral_of_dominated_convergence (fun x => v x^2+B x) · intro k; exact ((hf k).mul (smooth_A hts (hf k))).continuous.aestronglyMeasurable · exact hiv.add hiB · intro k; apply ae_of_all; intro x rw [Real.norm_eq_abs,abs_mul] have hcross := sq_nonneg (|f k x|-|A τ (f k) x|) have hnon := sq_nonneg (A τ (f k) x) have hb' := hb k x have hf' := hfb k x nlinarith [sq_abs (f k x),sq_abs (A τ (f k) x)] · apply ae_of_all; intro x apply tendsto_const_nhds.congr' filter_upwards [hev x] with k hk change v x^2 = f k x*A τ (f k) x rw [hk.1,hk.2,pow_two] omit [DecidableEq ι] in lemma cutoff_eventually_dominate (m : ℕ) : ∀ᶠ k : ℕ in atTop, ∀ x : Space ι, (SmoothCutoff.seq m x)^2 ≤ (SmoothCutoff.seq k x)^2 := by apply eventually_atTop.mpr refine ⟨2*m+1, fun k hk x => ?_⟩ by_cases hx : 2*((m:ℝ)+1) ≤ ‖x‖ · rw [show SmoothCutoff.seq m x = 0 from SmoothCutoff.eq_zero (by positivity) hx] simpa only [zero_pow (by decide : 2 ≠ 0)] using sq_nonneg (SmoothCutoff.seq k x) · have hxr : ‖x‖ ≤ (k:ℝ)+1 := by have hn : ((2*m+1 : ℕ):ℝ) ≤ k := Nat.cast_le.mpr hk push_cast at hn linarith [not_le.mp hx] rw [show SmoothCutoff.seq k x = 1 from SmoothCutoff.eq_one (by positivity) hxr] exact pow_le_pow_left₀ (SmoothCutoff.seq_nonneg m x) (SmoothCutoff.seq_le_one m x) 2 lemma harmonic_energy_zero (μ : Measure (Space ι)) [IsFiniteMeasure μ] [Measure.IsOpenPosMeasure μ] {τ : Space ι → Matrix ι ι ℝ} (hts : ∀ i j, ContDiff ℝ ∞ (fun x => τ x i j)) (htp : ∀ x, (τ x).PosSemidef) {Λ : ℝ} (hΛ : 0 ≤ Λ) (hupper : ∀ x, (Λ • (1 : Matrix ι ι ℝ) - τ x).PosSemidef) (hibp : ∀ f h : Space ι → ℝ, ContDiff ℝ ∞ f → ContDiff ℝ ∞ h → HasCompactSupport f → HasCompactSupport h → (∫ x, h x*A τ f x ∂μ) = ∫ x, gamma τ h f x ∂μ) {w : Space ι → ℝ} (hw : ContDiff ℝ ∞ w) (hiw : Integrable (fun x => w x^2) μ) (hAw : A τ w = 0) : ∀ x, gamma τ w w x = 0 := by let η := SmoothCutoff.seq (E:=Space ι) have hs (k : ℕ) := SmoothCutoff.seq_smooth (E:=Space ι) k have hc (k : ℕ) := SmoothCutoff.seq_compact (E:=Space ι) k obtain ⟨D,hD,hDb⟩ := cutoff_gamma_bound hΛ hupper have hi (k : ℕ) : Integrable (fun x => η k x^2*gamma τ w w x) μ := by have hcη : HasCompactSupport (fun x => η k x^2) := by rw [show (fun x => η k x^2) = η k*η k by ext x; simp only [Pi.mul_apply, pow_two]] exact (hc k).mul_right exact (((hs k).pow 2).mul (smooth_gamma hts hw hw)).continuous.integrable_of_hasCompactSupport hcη.mul_right have hb (k : ℕ) : (∫ x, η k x^2*gamma τ w w x ∂μ) ≤ 4*(D/((k:ℝ)+1)^2)*(∫ x, w x^2 ∂μ) := caccioppoli μ hts htp (hs k) (hc k) hw hiw (harmonic_test μ hibp (hs k) (hc k) hw hAw) (hDb _ (by positivity)) have ht : Tendsto (fun k : ℕ => 4*(D/((k:ℝ)+1)^2)*(∫ x, w x^2 ∂μ)) atTop (𝓝 0) := by have hh := (tendsto_one_div_add_atTop_nhds_zero_nat (𝕜:=ℝ)).pow 2 convert ((hh.const_mul D).const_mul 4).mul_const (∫ x, w x^2 ∂μ) using 1 <;> simp [div_eq_mul_inv] have hz (m : ℕ) : (∫ x, η m x^2*gamma τ w w x ∂μ) = 0 := by apply le_antisymm · apply ge_of_tendsto ht filter_upwards [cutoff_eventually_dominate (ι:=ι) m] with k hk exact (integral_mono (hi m) (hi k) (fun x => mul_le_mul_of_nonneg_right (hk x) (gamma_nonneg htp w x))).trans (hb k) · exact integral_nonneg (fun x => mul_nonneg (sq_nonneg _) (gamma_nonneg htp w x)) have he (m : ℕ) : (fun x => η m x^2*gamma τ w w x) = 0 := by have hae : (fun x => η m x^2*gamma τ w w x) =ᶠ[ae μ] 0 := (integral_eq_zero_iff_of_nonneg (fun x => mul_nonneg (sq_nonneg _) (gamma_nonneg htp w x)) (hi m)).mp (hz m) exact ((((hs m).pow 2).mul (smooth_gamma hts hw hw)).continuous.ae_eq_iff_eq μ continuous_const).mp hae intro x obtain ⟨m,hm⟩ := exists_nat_gt ‖x‖ have hη : η m x = 1 := SmoothCutoff.eq_one (by positivity) (by linarith) have hh := congrFun (he m) x simpa only [hη, one_pow, one_mul, Pi.zero_apply] using hh lemma fderiv_zero_of_grad_zero {w : Space ι → ℝ} {x : Space ι} (h : grad w x = 0) : fderiv ℝ w x = 0 := by ext v have hv : v = ∑ i, v i • e i := by funext j simp [e, Pi.single_apply] rw [hv, map_sum] simp only [map_smul, smul_eq_mul] have hh (i : ι) : fderiv ℝ w x (e i) = 0 := congrFun h i simp only [hh, mul_zero, Finset.sum_const_zero, _root_.zero_apply] theorem harmonic_constant (μ : Measure (Space ι)) [IsFiniteMeasure μ] [Measure.IsOpenPosMeasure μ] {τ : Space ι → Matrix ι ι ℝ} (hts : ∀ i j, ContDiff ℝ ∞ (fun x => τ x i j)) (htp : ∀ x, (τ x).PosDef) {Λ : ℝ} (hΛ : 0 ≤ Λ) (hupper : ∀ x, (Λ • (1 : Matrix ι ι ℝ) - τ x).PosSemidef) (hibp : ∀ f h : Space ι → ℝ, ContDiff ℝ ∞ f → ContDiff ℝ ∞ h → HasCompactSupport f → HasCompactSupport h → (∫ x, h x*A τ f x ∂μ) = ∫ x, gamma τ h f x ∂μ) {w : Space ι → ℝ} (hw : ContDiff ℝ ∞ w) (hiw : Integrable (fun x => w x^2) μ) (hAw : A τ w = 0) : ∀ x y, w x = w y := by have he := harmonic_energy_zero μ hts (fun x => (htp x).posSemidef) hΛ hupper hibp hw hiw hAw have hg (x : Space ι) : grad w x = 0 := by by_contra hn have hp := (htp x).dotProduct_mulVec_pos hn have hz := he x unfold gamma at hz simp only [star_trivial, hz, lt_self_iff_false] at hp have hd (x : Space ι) : fderiv ℝ w x = 0 := fderiv_zero_of_grad_zero (hg x) exact is_const_of_fderiv_eq_zero (hw.differentiable (by simp)) hd end DensityEnergy namespace MomentMatrix open Matrix open scoped MatrixOrder variable {ι : Type*} [Fintype ι] [DecidableEq ι] lemma trace_conjugate_eq_zero {A H : Matrix ι ι ℝ} (hA : A.PosDef) (hH : Hᵀ = H) (hz : (A*H*A*H).trace = 0) : H = 0 := by obtain ⟨S,hS⟩ := CStarAlgebra.nonneg_iff_eq_star_mul_self.mp hA.posSemidef.nonneg have hu : IsUnit S.det := by have hh : IsUnit (Sᴴ.det*S.det) := by rw [← Matrix.det_mul] change IsUnit (star S*S).det rw [← hS] exact (Matrix.isUnit_iff_isUnit_det A).mp hA.isUnit exact isUnit_of_mul_isUnit_right hh have hstar : Hᴴ = H := by simpa only [Matrix.conjTranspose_eq_transpose_of_trivial] using hH have hc : (S*H*Sᴴ)ᴴ = S*H*Sᴴ := by simp only [Matrix.conjTranspose_mul,Matrix.conjTranspose_conjTranspose,hstar,Matrix.mul_assoc] have he : ((S*H*Sᴴ)ᴴ*(S*H*Sᴴ)).trace = (A*H*A*H).trace := by rw [hc,hS] change ((S*H*Sᴴ)*(S*H*Sᴴ)).trace = (Sᴴ*S*H*(Sᴴ*S)*H).trace calc _ = (S*(H*Sᴴ*S*H)*Sᴴ).trace := by simp only [Matrix.mul_assoc] _ = (Sᴴ*S*(H*Sᴴ*S*H)).trace := Matrix.trace_mul_cycle _ _ _ _ = _ := by simp only [Matrix.mul_assoc] have hz' : S*H*Sᴴ = 0 := Matrix.trace_conjTranspose_mul_self_eq_zero_iff.mp (he.trans hz) have hv : IsUnit Sᴴ.det := by simpa only [Matrix.det_conjTranspose,star_trivial] using hu have hh : H*Sᴴ = 0 := by have hh := congrArg (fun M : Matrix ι ι ℝ => S⁻¹*M) hz' simpa only [← Matrix.mul_assoc,Matrix.nonsing_inv_mul S hu,Matrix.one_mul, Matrix.mul_zero] using hh have hh' := congrArg (fun M : Matrix ι ι ℝ => M*(Sᴴ)⁻¹) hh simpa only [Matrix.mul_assoc,Matrix.mul_nonsing_inv Sᴴ hv,Matrix.mul_one, Matrix.zero_mul] using hh' end MomentMatrix end namespace DensityLimit open Filter MeasureTheory open scoped Topology lemma zero_of_local_limit {E : Type*} [TopologicalSpace E] [MeasurableSpace E] [BorelSpace E] (μ : Measure E) [Measure.IsOpenPosMeasure μ] {F : E → ℝ} {f : ℕ → E → ℝ} (hF : Continuous F) (hf : ∀ k, Continuous (f k)) (hFn : ∀ x, 0 ≤ F x) (hfn : ∀ k x, 0 ≤ f k x) (hi : ∀ k, Integrable (f k) μ) (he : ∀ x, ∀ᶠ k in atTop, f k x = F x) (ht : Tendsto (fun k => ∫ x, f k x ∂μ) atTop (𝓝 0)) : F = 0 := by have hl (x : E) : liminf (fun k => ENNReal.ofReal (f k x)) atTop = ENNReal.ofReal (F x) := by apply Tendsto.liminf_eq apply tendsto_const_nhds.congr' filter_upwards [he x] with k hk rw [hk] have hl' : Tendsto (fun k => ∫⁻ x, ENNReal.ofReal (f k x) ∂μ) atTop (𝓝 0) := by have ht' : Tendsto (fun k => ENNReal.ofReal (∫ x, f k x ∂μ)) atTop (𝓝 (ENNReal.ofReal 0)) := ENNReal.continuous_ofReal.continuousAt.tendsto.comp ht simpa only [ofReal_integral_eq_lintegral_ofReal (hi _) (ae_of_all μ (hfn _)), ENNReal.ofReal_zero] using ht' have hb : (∫⁻ x, ENNReal.ofReal (F x) ∂μ) = 0 := by apply le_antisymm _ bot_le calc _ = ∫⁻ x, liminf (fun k => ENNReal.ofReal (f k x)) atTop ∂μ := by simp only [hl] _ ≤ liminf (fun k => ∫⁻ x, ENNReal.ofReal (f k x) ∂μ) atTop := lintegral_liminf_le (fun k => (ENNReal.continuous_ofReal.comp (hf k)).measurable) _ = 0 := hl'.liminf_eq have hae := (lintegral_eq_zero_iff' (ENNReal.continuous_ofReal.comp hF).aemeasurable).mp hb have hae' : F =ᵐ[μ] 0 := by filter_upwards [hae] with x hx exact le_antisymm (ENNReal.ofReal_eq_zero.mp hx) (hFn x) exact (hF.ae_eq_iff_eq μ continuous_const).mp hae' end DensityLimit noncomputable section namespace DensityEnergy open MeasureTheory Matrix WeightedCalculus Filter open scoped ContDiff Topology variable {ι : Type*} [Fintype ι] [DecidableEq ι] def henergy (τ : Space ι → Matrix ι ι ℝ) (f : Space ι → ℝ) (x : Space ι) : ℝ := (τ x*MomentCoordinates.hess f x*τ x*MomentCoordinates.hess f x).trace lemma henergy_nonneg {τ : Space ι → Matrix ι ι ℝ} (ht : ∀ x, (τ x).PosSemidef) {f : Space ι → ℝ} (hf : ContDiff ℝ ∞ f) (x : Space ι) : 0 ≤ henergy τ f x := by apply MomentMatrix.trace_conjugate_nonneg (ht x) ext i j exact MomentCoordinates.hess_symm hf x j i lemma smooth_henergy {τ : Space ι → Matrix ι ι ℝ} (ht : ∀ i j, ContDiff ℝ ∞ (fun x => τ x i j)) {f : Space ι → ℝ} (hf : ContDiff ℝ ∞ f) : ContDiff ℝ ∞ (henergy τ f) := by unfold henergy Matrix.trace Matrix.diag simp only [Matrix.mul_apply] apply ContDiff.sum; intro i _ apply ContDiff.sum; intro j _ apply ContDiff.mul · apply ContDiff.sum; intro k _ apply ContDiff.mul · apply ContDiff.sum; intro l _ exact (ht i l).mul (MomentCoordinates.smooth_pd (MomentCoordinates.smooth_pd hf l) k) · exact ht k j · exact MomentCoordinates.smooth_pd (MomentCoordinates.smooth_pd hf j) i lemma compact_henergy {τ : Space ι → Matrix ι ι ℝ} {f : Space ι → ℝ} (hf : HasCompactSupport f) : HasCompactSupport (henergy τ f) := by unfold henergy Matrix.trace Matrix.diag simp only [Matrix.mul_apply] apply compact_sum; intro i apply compact_sum; intro j exact (compact_D (compact_D hf _) _).mul_left lemma hess_congr {f g : Space ι → ℝ} {x : Space ι} (h : f =ᶠ[𝓝 x] g) : MomentCoordinates.hess f x = MomentCoordinates.hess g x := by ext i j exact (D_eventuallyEq (D_eventuallyEq h (e i)) (e j)).eq_of_nhds lemma eigen_hessian_zero (μ : Measure (Space ι)) [IsFiniteMeasure μ] [Measure.IsOpenPosMeasure μ] {τ : Space ι → Matrix ι ι ℝ} (hts : ∀ i j, ContDiff ℝ ∞ (fun x => τ x i j)) (htp : ∀ x, (τ x).PosDef) {Λ : ℝ} (hΛ : 0 ≤ Λ) (hupper : ∀ x, (Λ • (1 : Matrix ι ι ℝ)-τ x).PosSemidef) (hibp : ∀ f h : Space ι → ℝ, ContDiff ℝ ∞ f → ContDiff ℝ ∞ h → HasCompactSupport f → HasCompactSupport h → (∫ x, h x*A τ f x ∂μ) = ∫ x, gamma τ h f x ∂μ) (hidentity : ∀ f : Space ι → ℝ, ContDiff ℝ ∞ f → HasCompactSupport f → (∫ x, henergy τ f x ∂μ) = (∫ x, (A τ f x)^2 ∂μ)-(∫ x, f x*A τ f x ∂μ)) {v : Space ι → ℝ} (hv : ContDiff ℝ ∞ v) (hiv : Integrable (fun x => v x^2) μ) (hAv : A τ v = v) : ∀ x, MomentCoordinates.hess v x = 0 := by let f (k : ℕ) : Space ι → ℝ := fun x => SmoothCutoff.seq k x*v x have hs (k : ℕ) : ContDiff ℝ ∞ (f k) := (SmoothCutoff.seq_smooth k).mul hv have hc (k : ℕ) : HasCompactSupport (f k) := (SmoothCutoff.seq_compact k).mul_right have hi (k : ℕ) : Integrable (henergy τ (f k)) μ := (smooth_henergy hts (hs k)).continuous.integrable_of_hasCompactSupport (compact_henergy (hc k)) obtain ⟨h1,h2⟩ := eigen_graph_integrals μ hts (fun x => (htp x).posSemidef) hΛ hupper hibp hv hiv hAv have ht : Tendsto (fun k => ∫ x, henergy τ (f k) x ∂μ) atTop (𝓝 0) := by simp only [hidentity _ (hs _) (hc _)] simpa only [sub_self] using h1.sub h2 have he : henergy τ v = 0 := by apply DensityLimit.zero_of_local_limit μ (smooth_henergy hts hv).continuous (fun k => (smooth_henergy hts (hs k)).continuous) (henergy_nonneg (fun x => (htp x).posSemidef) hv) (fun k => henergy_nonneg (fun x => (htp x).posSemidef) (hs k)) hi _ ht intro x filter_upwards [cutoff_product_eventually v x] with k hk unfold henergy rw [hess_congr hk] intro x apply MomentMatrix.trace_conjugate_eq_zero (htp x) · ext i j; exact MomentCoordinates.hess_symm hv x j i · exact congrFun he x theorem eigen_linear (μ : Measure (Space ι)) [IsFiniteMeasure μ] [Measure.IsOpenPosMeasure μ] {τ : Space ι → Matrix ι ι ℝ} (hts : ∀ i j, ContDiff ℝ ∞ (fun x => τ x i j)) (htp : ∀ x, (τ x).PosDef) {Λ : ℝ} (hΛ : 0 ≤ Λ) (hupper : ∀ x, (Λ • (1 : Matrix ι ι ℝ)-τ x).PosSemidef) (hibp : ∀ f h : Space ι → ℝ, ContDiff ℝ ∞ f → ContDiff ℝ ∞ h → HasCompactSupport f → HasCompactSupport h → (∫ x, h x*A τ f x ∂μ) = ∫ x, gamma τ h f x ∂μ) (hidentity : ∀ f : Space ι → ℝ, ContDiff ℝ ∞ f → HasCompactSupport f → (∫ x, henergy τ f x ∂μ) = (∫ x, (A τ f x)^2 ∂μ)-(∫ x, f x*A τ f x ∂μ)) {v : Space ι → ℝ} (hv : ContDiff ℝ ∞ v) (hiv : Integrable (fun x => v x^2) μ) (hAv : A τ v = v) : ∃ b : ι → ℝ, ∀ x, v x = ∑ i, x i*b i := by have hh := eigen_hessian_zero μ hts htp hΛ hupper hibp hidentity hv hiv hAv have hg (i : ι) (x : Space ι) : D (e i) v x = D (e i) v 0 := by apply is_const_of_fderiv_eq_zero ((smooth_D hv (e i)).differentiable (by simp)) intro y apply fderiv_zero_of_grad_zero funext j exact congrArg (fun M : Matrix ι ι ℝ => M i j) (hh y) refine ⟨fun i => D (e i) v 0, fun x => ?_⟩ have hAx := congrFun hAv x have hz (i j : ι) : D (e i) (D (e j) v) x = 0 := congrArg (fun M : Matrix ι ι ℝ => M j i) (hh x) simpa only [A,hz,mul_zero,Finset.sum_const_zero,sub_zero,hg] using hAx.symm omit [Fintype ι] [DecidableEq ι] in lemma compact_pow_succ {f : Space ι → ℝ} (hf : HasCompactSupport f) (n : ℕ) : HasCompactSupport (fun x => f x^(n+1)) := by have hh : HasCompactSupport (fun x => f x^n*f x) := hf.mul_left simpa only [pow_succ] using hh lemma kernel_cutoff_pointwise {τ : Space ι → Matrix ι ι ℝ} (htp : ∀ x, (τ x).PosSemidef) {η g : Space ι → ℝ} (hη : ContDiff ℝ ∞ η) (hg : ContDiff ℝ ∞ g) {D K : ℝ} (hD : 0 ≤ D) (hK : 0 ≤ K) (hηn : ∀ x, 0 ≤ η x) (hηl : ∀ x, η x ≤ 1) (hηA : ∀ x, |A τ η x| ≤ K) (hηΓ : ∀ x, gamma τ η η x ≤ D) (x : Space ι) : η x^4*(A τ g x)^2 ≤ 2*(A τ g x*(A τ (fun y => η y^4*g y) x-η x^4*g x)) + 2*(1+4*K+12*D)^2*g x^2+128*D*η x^2*gamma τ g g x := by have ht (y : Space ι) : (τ y)ᵀ = τ y := by simpa only [Matrix.conjTranspose_eq_transpose_of_trivial] using (htp y).isHermitian.eq have hnΓ := gamma_nonneg htp η x have hgΓ := gamma_nonneg htp g x have hη2 : η x^2 ≤ 1 := by simpa using pow_le_pow_left₀ (hηn x) (hηl x) 2 have hηA' : |η x*A τ η x| ≤ K := by rw [abs_mul,abs_of_nonneg (hηn x)] exact (mul_le_mul_of_nonneg_left (hηA x) (hηn x)).trans (by nlinarith [hηl x]) have he := abs_le.mp hηA' have hq : |4*η x*A τ η x-12*gamma τ η η x-η x^2| ≤ 1+4*K+12*D := by rw [abs_le] constructor <;> nlinarith [hηΓ x,sq_nonneg (η x)] have hq2 : (4*η x*A τ η x-12*gamma τ η η x-η x^2)^2 ≤ (1+4*K+12*D)^2 := by simpa only [sq_abs] using (sq_le_sq₀ (abs_nonneg _) (by positivity)).mpr hq have hqg := mul_le_mul_of_nonneg_right hq2 (sq_nonneg (g x)) have hΓ := (gamma_cs htp η g x).trans (mul_le_mul_of_nonneg_right (hηΓ x) hgΓ) have hΓη := mul_le_mul_of_nonneg_left hΓ (sq_nonneg (η x)) rw [A_mul ht (hη.pow 4) hg, A_pow_succ ht hη 2, gamma_pow_left hη 3] norm_num nlinarith [sq_nonneg (η x^2*A τ g x/2+g x*(4*η x*A τ η x-12*gamma τ η η x-η x^2)), sq_nonneg (η x^2*A τ g x/2-8*η x*gamma τ η g x)] lemma kernel_A_square_integrable (μ : Measure (Space ι)) [IsFiniteMeasure μ] {τ : Space ι → Matrix ι ι ℝ} (hts : ∀ i j, ContDiff ℝ ∞ (fun x => τ x i j)) (htp : ∀ x, (τ x).PosSemidef) {Λ : ℝ} (hΛ : 0 ≤ Λ) (hupper : ∀ x, (Λ • (1 : Matrix ι ι ℝ)-τ x).PosSemidef) (hibp : ∀ f h : Space ι → ℝ, ContDiff ℝ ∞ f → ContDiff ℝ ∞ h → HasCompactSupport f → HasCompactSupport h → (∫ x, h x*A τ f x ∂μ) = ∫ x, gamma τ h f x ∂μ) {g : Space ι → ℝ} (hg : ContDiff ℝ ∞ g) (hig : Integrable (fun x => g x^2) μ) (hweak : ∀ h : Space ι → ℝ, ContDiff ℝ ∞ h → HasCompactSupport h → (∫ x, A τ g x*(A τ h x-h x) ∂μ) = 0) : Integrable (fun x => (A τ g x)^2) μ := by obtain ⟨D,hD,hDb⟩ := cutoff_gamma_bound hΛ hupper obtain ⟨K,hK,hKb⟩ := cutoff_A_bound htp hΛ hupper let v := A τ g have hv : ContDiff ℝ ∞ v := smooth_A hts hg let η (k : ℕ) : Space ι → ℝ := SmoothCutoff.seq k have hs (k : ℕ) : ContDiff ℝ ∞ (η k) := SmoothCutoff.seq_smooth k have hc (k : ℕ) : HasCompactSupport (η k) := SmoothCutoff.seq_compact k have hbΓ (k : ℕ) (x : Space ι) : gamma τ (η k) (η k) x ≤ D := by apply (hDb _ (by positivity) x).trans exact div_le_self hD (by have := Nat.cast_nonneg (α:=ℝ) k; nlinarith) have hbA (k : ℕ) (x : Space ι) : |A τ (η k) x| ≤ K := hKb _ (by have := Nat.cast_nonneg (α:=ℝ) k; linarith) x let G := ∫ x, g x^2 ∂μ let X (k : ℕ) := ∫ x, (η k x)^4*(v x)^2 ∂μ let Y (k : ℕ) := ∫ x, (η k x)^2*gamma τ g g x ∂μ let c := 256*(D+1) let a := 1+4*K+12*D have hc0 : 0 ≤ c := by dsimp [c]; positivity have hc1 : 1 ≤ c-128*D := by dsimp [c]; linarith have hG : 0 ≤ G := integral_nonneg (fun x => sq_nonneg (g x)) have hiX (k : ℕ) : Integrable (fun x => η k x^4*v x^2) μ := (((hs k).pow 4).mul (hv.pow 2)).continuous.integrable_of_hasCompactSupport (compact_pow_succ (hc k) _).mul_right have hiY (k : ℕ) : Integrable (fun x => η k x^2*gamma τ g g x) μ := (((hs k).pow 2).mul (smooth_gamma hts hg hg)).continuous.integrable_of_hasCompactSupport (compact_pow_succ (hc k) _).mul_right have hiT (k : ℕ) : Integrable (fun x => η k x^2*g x*v x) μ := ((((hs k).pow 2).mul hg).mul hv).continuous.integrable_of_hasCompactSupport ((compact_pow_succ (hc k) _).mul_right).mul_right have hx (k : ℕ) : X k ≤ 2*a^2*G+128*D*Y k := by let q : Space ι → ℝ := fun x => η k x^4*g x have hqs : ContDiff ℝ ∞ q := ((hs k).pow 4).mul hg have hqc : HasCompactSupport q := (compact_pow_succ (hc k) _).mul_right have hiJ : Integrable (fun x => v x*(A τ q x-q x)) μ := (hv.mul ((smooth_A hts hqs).sub hqs)).continuous.integrable_of_hasCompactSupport ((compact_A hqc).sub hqc).mul_left have hh := integral_mono (hiX k) (((hiJ.const_mul 2).add (hig.const_mul (2*a^2))).add ((hiY k).const_mul (128*D))) (fun x => by simpa only [Pi.add_apply,mul_assoc] using kernel_cutoff_pointwise htp (hs k) hg hD hK (SmoothCutoff.seq_nonneg k) (SmoothCutoff.seq_le_one k) (hbA k) (hbΓ k) x) simp only [Pi.add_apply] at hh change X k ≤ (∫ x, (2*(v x*(A τ q x-q x))+(2*a^2)*(g x^2)) + (128*D)*(η k x^2*gamma τ g g x) ∂μ) at hh have hadd₁ := integral_add ((hiJ.const_mul 2).add (hig.const_mul (2*a^2))) ((hiY k).const_mul (128*D)) have hadd₂ := integral_add (hiJ.const_mul 2) (hig.const_mul (2*a^2)) simp only [Pi.add_apply] at hadd₁ rw [hadd₁,hadd₂,integral_const_mul,integral_const_mul,integral_const_mul] at hh have hw : (∫ x, v x*(A τ q x-q x) ∂μ) = 0 := hweak q hqs hqc simpa only [hw,mul_zero,zero_add] using hh have hy (k : ℕ) : c*Y k ≤ X k+(c^2+4*c*D)*G := by have he := energy_estimate μ hts htp hibp (hs k) (hc k) hg hig (hbΓ k) have he' := mul_le_mul_of_nonneg_left he hc0 have hyoung := integral_mono ((hiT k).const_mul (2*c)) ((hiX k).add (hig.const_mul (c^2))) (fun x => by simp only [Pi.add_apply] nlinarith [sq_nonneg (η k x^2*v x-c*g x)]) simp only [Pi.add_apply] at hyoung rw [integral_add (hiX k) (hig.const_mul (c^2))] at hyoung simp only [integral_const_mul] at hyoung change c*Y k ≤ _ dsimp [Y,X,G] at * nlinarith let C := (2*c*a^2+128*D*(c^2+4*c*D))*G have hC : 0 ≤ C := by dsimp [C]; positivity have hbound (k : ℕ) : X k ≤ C := by have hX : 0 ≤ X k := integral_nonneg (fun x => mul_nonneg (pow_nonneg (SmoothCutoff.seq_nonneg k x) 4) (sq_nonneg _)) have hx' := mul_le_mul_of_nonneg_left (hx k) hc0 have hy' := mul_le_mul_of_nonneg_left (hy k) (by positivity : 0 ≤ 128*D) have hcX := mul_le_mul_of_nonneg_right hc1 hX dsimp [C] nlinarith exact (SmoothCutoff.integrable_of_cutoff_bound μ (hv.pow 2).continuous (fun x => sq_nonneg (v x)) 4 hC hbound hiX).1 lemma A_zero_of_not_tsupport {τ : Space ι → Matrix ι ι ℝ} {f : Space ι → ℝ} {x : Space ι} (hx : x ∉ tsupport f) : A τ f x = 0 := by have he : f =ᶠ[𝓝 x] (fun _ => 0) := by filter_upwards [(isClosed_tsupport f).isOpen_compl.mem_nhds hx] with y hy exact image_eq_zero_of_notMem_tsupport hy rw [A_congr he] have hz (i : ι) : D (e i) (fun _ : Space ι => (0 : ℝ)) = 0 := by ext y; simp [D] have hz' (i : ι) : D (e i) (0 : Space ι → ℝ) = 0 := hz i simp only [A,hz,hz',Pi.zero_apply,mul_zero,Finset.sum_const_zero,sub_zero] lemma local_symmetry (μ : Measure (Space ι)) {τ : Space ι → Matrix ι ι ℝ} (ht : ∀ x, (τ x)ᵀ = τ x) (hibp : ∀ f h : Space ι → ℝ, ContDiff ℝ ∞ f → ContDiff ℝ ∞ h → HasCompactSupport f → HasCompactSupport h → (∫ x, h x*A τ f x ∂μ) = ∫ x, gamma τ h f x ∂μ) {f g : Space ι → ℝ} (hf : ContDiff ℝ ∞ f) (hg : ContDiff ℝ ∞ g) (hfc : HasCompactSupport f) : (∫ x, g x*A τ f x ∂μ) = ∫ x, f x*A τ g x ∂μ := by obtain ⟨R,hR⟩ := hfc.isBounded.subset_closedBall (0:Space ι) let r : ℝ := max R 0+1 have hr : 0 < r := by dsimp [r]; positivity let g' : Space ι → ℝ := fun x => SmoothCutoff.cutoff r x*g x have hs : ContDiff ℝ ∞ g' := (SmoothCutoff.smooth r).mul hg have hc : HasCompactSupport g' := (SmoothCutoff.compact hr).mul_right have he (x : Space ι) (hx : x ∈ tsupport f) : g' =ᶠ[𝓝 x] g := by have hxR : ‖x‖ ≤ R := by simpa only [Metric.mem_closedBall,dist_zero_right] using hR hx have hxr : ‖x‖ < r := by dsimp [r]; have := le_max_left R 0; linarith filter_upwards [SmoothCutoff.eventually_one hr hxr] with y hy change SmoothCutoff.cutoff r y*g y = g y rw [hy,one_mul] have hleft : (fun x => g' x*A τ f x) = fun x => g x*A τ f x := by ext x by_cases hx : x ∈ tsupport f · rw [(he x hx).eq_of_nhds] · rw [A_zero_of_not_tsupport hx,mul_zero,mul_zero] have hright : gamma τ g' f = gamma τ g f := by ext x by_cases hx : x ∈ tsupport f · unfold gamma; rw [grad_congr (he x hx)] · unfold gamma; rw [grad_zero_of_not_tsupport hx] simp only [Matrix.mulVec_zero,dotProduct_zero] rw [← hleft,hibp f g' hf hs hfc hc,hright,extend_integration μ hibp hg hf hfc] congr 1 ext x exact gamma_symm ht g f x lemma weak_kernel_of_eigen (μ : Measure (Space ι)) [IsFiniteMeasure μ] {τ : Space ι → Matrix ι ι ℝ} (hts : ∀ i j, ContDiff ℝ ∞ (fun x => τ x i j)) (ht : ∀ x, (τ x)ᵀ = τ x) (hibp : ∀ f h : Space ι → ℝ, ContDiff ℝ ∞ f → ContDiff ℝ ∞ h → HasCompactSupport f → HasCompactSupport h → (∫ x, h x*A τ f x ∂μ) = ∫ x, gamma τ h f x ∂μ) {v : Space ι → ℝ} (hv : ContDiff ℝ ∞ v) (hAv : A τ v = v) {h : Space ι → ℝ} (hh : ContDiff ℝ ∞ h) (hc : HasCompactSupport h) : (∫ x, v x*(A τ h x-h x) ∂μ) = 0 := by have hi1 : Integrable (fun x => v x*A τ h x) μ := (hv.mul (smooth_A hts hh)).continuous.integrable_of_hasCompactSupport (compact_A hc).mul_left have hi2 : Integrable (fun x => v x*h x) μ := (hv.mul hh).continuous.integrable_of_hasCompactSupport hc.mul_left simp_rw [mul_sub] rw [integral_sub hi1 hi2,local_symmetry μ ht hibp hh hv hc,hAv] simp only [mul_comm,sub_self] lemma A_sub {τ : Space ι → Matrix ι ι ℝ} {f g : Space ι → ℝ} (hf : ContDiff ℝ ∞ f) (hg : ContDiff ℝ ∞ g) : A τ (f-g) = A τ f-A τ g := by have hd (i : ι) : D (e i) (f-g) = D (e i) f-D (e i) g := D_sub (hf.differentiable (by simp)) (hg.differentiable (by simp)) _ have hdd (i j : ι) : D (e i) (D (e j) f-D (e j) g) = D (e i) (D (e j) f)-D (e i) (D (e j) g) := by exact D_sub ((smooth_D hf _).differentiable (by simp)) ((smooth_D hg _).differentiable (by simp)) _ ext x simp only [A,hdd,hd,Pi.sub_apply,mul_sub,Finset.sum_sub_distrib] ring theorem smooth_kernel_affine (μ : Measure (Space ι)) [IsFiniteMeasure μ] [Measure.IsOpenPosMeasure μ] {τ : Space ι → Matrix ι ι ℝ} (hts : ∀ i j, ContDiff ℝ ∞ (fun x => τ x i j)) (htp : ∀ x, (τ x).PosDef) {Λ : ℝ} (hΛ : 0 ≤ Λ) (hupper : ∀ x, (Λ • (1 : Matrix ι ι ℝ)-τ x).PosSemidef) (hibp : ∀ f h : Space ι → ℝ, ContDiff ℝ ∞ f → ContDiff ℝ ∞ h → HasCompactSupport f → HasCompactSupport h → (∫ x, h x*A τ f x ∂μ) = ∫ x, gamma τ h f x ∂μ) (hidentity : ∀ f : Space ι → ℝ, ContDiff ℝ ∞ f → HasCompactSupport f → (∫ x, henergy τ f x ∂μ) = (∫ x, (A τ f x)^2 ∂μ)-(∫ x, f x*A τ f x ∂μ)) {g : Space ι → ℝ} (hg : ContDiff ℝ ∞ g) (hig : Integrable (fun x => g x^2) μ) (hP : A τ (A τ g-g) = 0) : ∃ c : ℝ, ∃ b : ι → ℝ, ∀ x, g x = c+∑ i, x i*b i := by let v := A τ g have hv : ContDiff ℝ ∞ v := smooth_A hts hg have hAv : A τ v = v := by rw [A_sub hv hg,sub_eq_zero] at hP exact hP have ht (x : Space ι) : (τ x)ᵀ = τ x := by simpa only [Matrix.conjTranspose_eq_transpose_of_trivial] using (htp x).isHermitian.eq have hiv : Integrable (fun x => v x^2) μ := kernel_A_square_integrable μ hts (fun x => (htp x).posSemidef) hΛ hupper hibp hg hig (fun h hh hc => weak_kernel_of_eigen μ hts ht hibp hv hAv hh hc) let w := g-v have hw : ContDiff ℝ ∞ w := hg.sub hv have hiw : Integrable (fun x => w x^2) μ := by apply ((hig.const_mul 2).add (hiv.const_mul 2)).mono' (hw.pow 2).continuous.aestronglyMeasurable apply ae_of_all; intro x rw [Real.norm_eq_abs,abs_of_nonneg (sq_nonneg (w x))] change (g x-v x)^2 ≤ 2*g x^2+2*v x^2 nlinarith [sq_nonneg (g x+v x)] have hAw : A τ w = 0 := by rw [A_sub hg hv,hAv]; exact sub_self _ have hc := harmonic_constant μ hts htp hΛ hupper hibp hw hiw hAw obtain ⟨b,hb⟩ := eigen_linear μ hts htp hΛ hupper hibp hidentity hv hiv hAv refine ⟨w 0,b,fun x => ?_⟩ have hwx := hc x 0 change g x-v x = w 0 at hwx rw [← hb x] linarith theorem smooth_even_kernel_constant (μ : Measure (Space ι)) [IsFiniteMeasure μ] [Measure.IsOpenPosMeasure μ] {τ : Space ι → Matrix ι ι ℝ} (hts : ∀ i j, ContDiff ℝ ∞ (fun x => τ x i j)) (htp : ∀ x, (τ x).PosDef) {Λ : ℝ} (hΛ : 0 ≤ Λ) (hupper : ∀ x, (Λ • (1 : Matrix ι ι ℝ)-τ x).PosSemidef) (hibp : ∀ f h : Space ι → ℝ, ContDiff ℝ ∞ f → ContDiff ℝ ∞ h → HasCompactSupport f → HasCompactSupport h → (∫ x, h x*A τ f x ∂μ) = ∫ x, gamma τ h f x ∂μ) (hidentity : ∀ f : Space ι → ℝ, ContDiff ℝ ∞ f → HasCompactSupport f → (∫ x, henergy τ f x ∂μ) = (∫ x, (A τ f x)^2 ∂μ)-(∫ x, f x*A τ f x ∂μ)) {g : Space ι → ℝ} (hg : ContDiff ℝ ∞ g) (hig : Integrable (fun x => g x^2) μ) (hP : A τ (A τ g-g) = 0) (heven : Function.Even g) : ∀ x, g x = g 0 := by obtain ⟨c,b,hb⟩ := smooth_kernel_affine μ hts htp hΛ hupper hibp hidentity hg hig hP have h0 : g 0 = c := by simpa using hb 0 intro x have h1 := hb x have h2 := hb (-x) rw [heven] at h2 simp only [Pi.neg_apply,neg_mul,Finset.sum_neg_distrib] at h2 rw [h0] linarith end DensityEnergy namespace MomentKernel section open MeasureTheory Matrix WeightedCalculus MomentCoordinates TargetCoordinates open scoped ContDiff section variable {ι : Type*} [Fintype ι] [DecidableEq ι] lemma A_eq_density {φ f : Space ι → ℝ} (hf : ContDiff ℝ ∞ f) (Φ : Space ι ≃ₜ Space ι) : MomentOperator.A Φ φ f = DensityEnergy.A (MomentOperator.tau Φ φ) f := by ext x unfold MomentOperator.A DensityEnergy.A congr 1 apply Finset.sum_congr rfl intro i _ apply Finset.sum_congr rfl intro j _ rw [hess_symm hf x i j] rfl lemma smooth_tau {φ : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (Φ : Space ι ≃ₜ Space ι) (hInv : ContDiff ℝ ∞ (Φ.symm : Space ι → Space ι)) (i j : ι) : ContDiff ℝ ∞ (fun x => MomentOperator.tau Φ φ x i j) := (MomentEquation.smooth_hess hφ i j).comp hInv lemma smooth_flux {φ f : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hf : ContDiff ℝ ∞ f) (Φ : Space ι ≃ₜ Space ι) (hInv : ContDiff ℝ ∞ (Φ.symm : Space ι → Space ι)) (i : ι) : ContDiff ℝ ∞ (MomentOperator.flux Φ φ f i) := smooth_sum _ (fun j => (smooth_tau hφ Φ hInv i j).mul (smooth_pd hf j)) lemma compact_flux {φ f : Space ι → ℝ} (hfc : HasCompactSupport f) (Φ : Space ι ≃ₜ Space ι) (i : ι) : HasCompactSupport (MomentOperator.flux Φ φ f i) := compact_sum _ (fun j => (compact_D hfc (basis j)).mul_left) variable (μ : Measure (Space ι)) [Measure.IsAddHaarMeasure μ] lemma integration_formula {φ V : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hV : ContDiff ℝ ∞ V) (hne : ∀ z, (hess φ z).det ≠ 0) {c Z : ℝ} (hZ : 0 < Z) (heq : ∀ z, Real.log (hess φ z).det = V (grad φ z)+c-φ z) (Φ : Space ι ≃ₜ Space ι) (hΦ : (Φ : Space ι → Space ι) = grad φ) (hInv : ContDiff ℝ ∞ (Φ.symm : Space ι → Space ι)) {f h : Space ι → ℝ} (hf : ContDiff ℝ ∞ f) (hh : ContDiff ℝ ∞ h) (hfc : HasCompactSupport f) : (∫ x, h x*DensityEnergy.A (MomentOperator.tau Φ φ) f x ∂targetMeasure μ V Z) = ∫ x, DensityEnergy.gamma (MomentOperator.tau Φ φ) h f x ∂targetMeasure μ V Z := by rw [target_integral μ hV hZ, target_integral μ hV hZ] unfold normalizedE congr 1 rw [← A_eq_density hf Φ, ← MomentOperator.A_divergence hφ hV hf hne heq Φ hΦ hInv, divergence_adjoint μ basis _ hV (smooth_flux hφ hf Φ hInv) hh (compact_flux hfc Φ)] have he : DensityEnergy.gamma (MomentOperator.tau Φ φ) h f = fun x => ∑ i, D (basis i) h x*MomentOperator.flux Φ φ f i x := rfl rw [he, expectation_sum μ hV _ (fun i => ((smooth_D hh _).mul (smooth_flux hφ hf Φ hInv i)).continuous) (fun i => (compact_flux hfc Φ i).mul_left)] lemma henergy_eq {φ f : Space ι → ℝ} (Φ : Space ι ≃ₜ Space ι) (x : Space ι) : DensityEnergy.henergy (MomentOperator.tau Φ φ) f x = ∑ a, ∑ k, (MomentOperator.tau Φ φ x*hess f x) k a * (MomentOperator.tau Φ φ x*hess f x) a k := by unfold DensityEnergy.henergy rw [Matrix.mul_assoc (MomentOperator.tau Φ φ x*hess f x)] simp only [Matrix.trace,Matrix.diag,Matrix.mul_apply] apply Finset.sum_congr rfl intro a _ apply Finset.sum_congr rfl intro k _ ring lemma hessian_identity {φ V : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hV : ContDiff ℝ ∞ V) {Z : ℝ} (hZ : 0 < Z) [IsFiniteMeasure (targetMeasure μ V Z)] (Φ : Space ι ≃ₜ Space ι) (hΦ : (Φ : Space ι → Space ι) = grad φ) (hInv : ContDiff ℝ ∞ (Φ.symm : Space ι → Space ι)) (hmap : Measure.map (grad φ) (sourceMeasure μ φ) = targetMeasure μ V Z) {f : Space ι → ℝ} (hf : ContDiff ℝ ∞ f) (hfc : HasCompactSupport f) : (∫ x, DensityEnergy.henergy (MomentOperator.tau Φ φ) f x ∂targetMeasure μ V Z) = (∫ x, (DensityEnergy.A (MomentOperator.tau Φ φ) f x)^2 ∂targetMeasure μ V Z)- (∫ x, f x*DensityEnergy.A (MomentOperator.tau Φ φ) f x ∂targetMeasure μ V Z) := by have hid := MomentOperator.hessian_identity_target μ hφ hV hf hfc hZ Φ hΦ hmap rw [← target_integral μ hV hZ, ← target_integral μ hV hZ] at hid rw [A_eq_density hf Φ] at hid have ha := DensityEnergy.smooth_A (smooth_tau hφ Φ hInv) hf have hc := DensityEnergy.compact_A (τ:=MomentOperator.tau Φ φ) hfc have hi₁ : Integrable (fun x => (DensityEnergy.A (MomentOperator.tau Φ φ) f x)^2) (targetMeasure μ V Z) := (ha.pow 2).continuous.integrable_of_hasCompactSupport (DensityEnergy.compact_pow_succ hc 1) have hi₂ : Integrable (fun x => f x*DensityEnergy.A (MomentOperator.tau Φ φ) f x) (targetMeasure μ V Z) := (hf.mul ha).continuous.integrable_of_hasCompactSupport hfc.mul_right have he : (fun x => DensityEnergy.A (MomentOperator.tau Φ φ) f x * (DensityEnergy.A (MomentOperator.tau Φ φ) f x-f x)) = fun x => (DensityEnergy.A (MomentOperator.tau Φ φ) f x)^2-f x*DensityEnergy.A (MomentOperator.tau Φ φ) f x := by ext x; ring rw [he,integral_sub hi₁ hi₂] at hid simpa only [henergy_eq] using hid.symm theorem smooth_kernel_affine {φ V : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hV : ContDiff ℝ ∞ V) (hpos : ∀ z, (hess φ z).PosDef) {c Z Λ : ℝ} (hZ : 0 < Z) [IsFiniteMeasure (targetMeasure μ V Z)] [Measure.IsOpenPosMeasure (targetMeasure μ V Z)] (hΛ : 0 ≤ Λ) (hupper : ∀ z, (Λ • (1 : Matrix ι ι ℝ)-hess φ z).PosSemidef) (heq : ∀ z, Real.log (hess φ z).det = V (grad φ z)+c-φ z) (Φ : Space ι ≃ₜ Space ι) (hΦ : (Φ : Space ι → Space ι) = grad φ) (hInv : ContDiff ℝ ∞ (Φ.symm : Space ι → Space ι)) (hmap : Measure.map (grad φ) (sourceMeasure μ φ) = targetMeasure μ V Z) {g : Space ι → ℝ} (hg : ContDiff ℝ ∞ g) (hig : Integrable (fun x => g x^2) (targetMeasure μ V Z)) (hP : DensityEnergy.A (MomentOperator.tau Φ φ) (DensityEnergy.A (MomentOperator.tau Φ φ) g-g) = 0) : ∃ a : ℝ, ∃ b : ι → ℝ, ∀ x, g x = a+∑ i, x i*b i := by apply DensityEnergy.smooth_kernel_affine (targetMeasure μ V Z) (smooth_tau hφ Φ hInv) (fun x => hpos (Φ.symm x)) hΛ (fun x => hupper (Φ.symm x)) (fun _ _ hf hh hc _ => integration_formula μ hφ hV (fun z => (hpos z).det_pos.ne') hZ heq Φ hΦ hInv hf hh hc) (fun _ hf hc => hessian_identity μ hφ hV hZ Φ hΦ hInv hmap hf hc) hg hig hP end variable {ι : Type*} [Fintype ι] [DecidableEq ι] variable (μ : Measure (Space ι)) [Measure.IsAddHaarMeasure μ] omit [DecidableEq ι] in theorem integration_by_parts_rightcompact {V f g : Space ι → ℝ} (hV : ContDiff ℝ ∞ V) (hf : ContDiff ℝ ∞ f) (hg : ContDiff ℝ ∞ g) (hgc : HasCompactSupport g) (v : Space ι) : expectation μ V (fun x => D v g x * f x) = expectation μ V (fun x => g x * adjoint V v f x) := by let fw : Space ι → ℝ := fun x => f x * weight V x have hfw : ContDiff ℝ ∞ fw := hf.mul (smooth_weight hV) have hi₁ : Integrable (fun x => D v fw x * g x) μ := ((smooth_D hfw v).continuous.mul hg.continuous).integrable_of_hasCompactSupport hgc.mul_left have hi₂ : Integrable (fun x => fw x * D v g x) μ := (hfw.continuous.mul (smooth_D hg v).continuous).integrable_of_hasCompactSupport (compact_D hgc v).mul_left have hi₃ : Integrable (fun x => fw x * g x) μ := (hfw.continuous.mul hg.continuous).integrable_of_hasCompactSupport hgc.mul_left have hp := integral_mul_fderiv_eq_neg_fderiv_mul_of_integrable hi₁ hi₂ hi₃ (fun x _ => hfw.differentiable (by simp) x) (fun x _ => hg.differentiable (by simp) x) calc _ = ∫ x, fw x * D v g x ∂μ := by apply integral_congr_ae filter_upwards [] with x dsimp [expectation, fw] ring _ = -∫ x, D v fw x * g x ∂μ := hp _ = _ := by rw [← integral_neg] apply integral_congr_ae filter_upwards [] with x dsimp [fw] at * rw [D_mul (hf.differentiable (by simp)) ((smooth_weight hV).differentiable (by simp)), D_weight hV v] dsimp [adjoint] ring lemma integration_formula_rightcompact {φ V : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hV : ContDiff ℝ ∞ V) (hne : ∀ z, (hess φ z).det ≠ 0) {c Z : ℝ} (hZ : 0 < Z) (heq : ∀ z, Real.log (hess φ z).det = V (grad φ z)+c-φ z) (Φ : Space ι ≃ₜ Space ι) (hΦ : (Φ : Space ι → Space ι) = grad φ) (hInv : ContDiff ℝ ∞ (Φ.symm : Space ι → Space ι)) {f h : Space ι → ℝ} (hf : ContDiff ℝ ∞ f) (hh : ContDiff ℝ ∞ h) (hhc : HasCompactSupport h) : (∫ x, h x*DensityEnergy.A (MomentOperator.tau Φ φ) f x ∂targetMeasure μ V Z) = ∫ x, DensityEnergy.gamma (MomentOperator.tau Φ φ) h f x ∂targetMeasure μ V Z := by rw [target_integral μ hV hZ, target_integral μ hV hZ] unfold normalizedE congr 1 rw [← A_eq_density hf Φ, ← MomentOperator.A_divergence hφ hV hf hne heq Φ hΦ hInv] have he : (fun x => h x * divergence V basis (MomentOperator.flux Φ φ f) x) = fun x => ∑ i, h x * adjoint V (basis i) (MomentOperator.flux Φ φ f i) x := by ext x; simp only [divergence, Finset.mul_sum] have hg : DensityEnergy.gamma (MomentOperator.tau Φ φ) h f = fun x => ∑ i, D (basis i) h x*MomentOperator.flux Φ φ f i x := rfl rw [he, hg, expectation_sum μ hV _ (fun i => (hh.mul (smooth_adjoint hV (smooth_flux hφ hf Φ hInv i) _)).continuous) (fun _ => hhc.mul_right), expectation_sum μ hV _ (fun i => ((smooth_D hh _).mul (smooth_flux hφ hf Φ hInv i)).continuous) (fun i => (compact_D hhc (basis i)).mul_right)] apply Finset.sum_congr rfl intro i _ exact (integration_by_parts_rightcompact μ hV (smooth_flux hφ hf Φ hInv i) hh hhc (basis i)).symm lemma A_selfadjoint_onecompact {φ V : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hV : ContDiff ℝ ∞ V) (hne : ∀ z, (hess φ z).det ≠ 0) {c Z : ℝ} (hZ : 0 < Z) (heq : ∀ z, Real.log (hess φ z).det = V (grad φ z)+c-φ z) (Φ : Space ι ≃ₜ Space ι) (hΦ : (Φ : Space ι → Space ι) = grad φ) (hInv : ContDiff ℝ ∞ (Φ.symm : Space ι → Space ι)) {f g : Space ι → ℝ} (hf : ContDiff ℝ ∞ f) (hg : ContDiff ℝ ∞ g) (hfc : HasCompactSupport f) : (∫ x, g x*DensityEnergy.A (MomentOperator.tau Φ φ) f x ∂targetMeasure μ V Z) = ∫ x, f x*DensityEnergy.A (MomentOperator.tau Φ φ) g x ∂targetMeasure μ V Z := by rw [integration_formula μ hφ hV hne hZ heq Φ hΦ hInv hf hg hfc, integration_formula_rightcompact μ hφ hV hne hZ heq Φ hΦ hInv hg hf hfc] congr 1; ext x exact DensityEnergy.gamma_symm (fun x => MomentEquation.hess_transpose hφ (Φ.symm x)) g f x lemma P_selfadjoint_onecompact {φ V : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hV : ContDiff ℝ ∞ V) (hne : ∀ z, (hess φ z).det ≠ 0) {c Z : ℝ} (hZ : 0 < Z) [IsFiniteMeasure (targetMeasure μ V Z)] (heq : ∀ z, Real.log (hess φ z).det = V (grad φ z)+c-φ z) (Φ : Space ι ≃ₜ Space ι) (hΦ : (Φ : Space ι → Space ι) = grad φ) (hInv : ContDiff ℝ ∞ (Φ.symm : Space ι → Space ι)) {f g : Space ι → ℝ} (hf : ContDiff ℝ ∞ f) (hg : ContDiff ℝ ∞ g) (hfc : HasCompactSupport f) : (∫ x, g x*DensityEnergy.A (MomentOperator.tau Φ φ) (DensityEnergy.A (MomentOperator.tau Φ φ) f-f) x ∂targetMeasure μ V Z) = ∫ x, f x*DensityEnergy.A (MomentOperator.tau Φ φ) (DensityEnergy.A (MomentOperator.tau Φ φ) g-g) x ∂targetMeasure μ V Z := by let A := DensityEnergy.A (MomentOperator.tau Φ φ) have hs := smooth_tau hφ Φ hInv have hAf := DensityEnergy.smooth_A hs hf have hAg := DensityEnergy.smooth_A hs hg have hAfC := DensityEnergy.compact_A (τ:=MomentOperator.tau Φ φ) hfc have hi₁ : Integrable (fun x => A f x*A g x) (targetMeasure μ V Z) := (hAf.mul hAg).continuous.integrable_of_hasCompactSupport hAfC.mul_right have hi₂ : Integrable (fun x => f x*A g x) (targetMeasure μ V Z) := (hf.mul hAg).continuous.integrable_of_hasCompactSupport hfc.mul_right have hi₃ : Integrable (fun x => f x*A (A g) x) (targetMeasure μ V Z) := (hf.mul (DensityEnergy.smooth_A hs hAg)).continuous.integrable_of_hasCompactSupport hfc.mul_right have hadj := A_selfadjoint_onecompact μ hφ hV hne hZ heq Φ hΦ hInv (f := A f-f) (g := g) (hAf.sub hf) hg (hAfC.sub hfc) change (∫ x, g x*A (A f-f) x ∂targetMeasure μ V Z) = _ at hadj rw [hadj] change (∫ x, (A f x-f x)*A g x ∂targetMeasure μ V Z) = ∫ x, f x*A (A g-g) x ∂targetMeasure μ V Z simp_rw [sub_mul] rw [integral_sub hi₁ hi₂] have ha := A_selfadjoint_onecompact μ hφ hV hne hZ heq Φ hΦ hInv hf hAg hfc simp only [mul_comm (A f _)] change (∫ x, A g x*A f x ∂targetMeasure μ V Z)-_ = _ rw [ha] change _ = ∫ x, f x * DensityEnergy.A (MomentOperator.tau Φ φ) (DensityEnergy.A (MomentOperator.tau Φ φ) g - g) x ∂targetMeasure μ V Z rw [DensityEnergy.A_sub hAg hg] simp only [Pi.sub_apply, mul_sub] exact (integral_sub hi₃ hi₂).symm lemma smooth_weak_kernel_equation {φ V : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hV : ContDiff ℝ ∞ V) (hne : ∀ z, (hess φ z).det ≠ 0) {c Z : ℝ} (hZ : 0 < Z) [IsFiniteMeasure (targetMeasure μ V Z)] [Measure.IsOpenPosMeasure (targetMeasure μ V Z)] (heq : ∀ z, Real.log (hess φ z).det = V (grad φ z)+c-φ z) (Φ : Space ι ≃ₜ Space ι) (hΦ : (Φ : Space ι → Space ι) = grad φ) (hInv : ContDiff ℝ ∞ (Φ.symm : Space ι → Space ι)) {g : Space ι → ℝ} (hg : ContDiff ℝ ∞ g) (hweak : ∀ f : Space ι → ℝ, ContDiff ℝ ∞ f → HasCompactSupport f → (∫ x, g x*DensityEnergy.A (MomentOperator.tau Φ φ) (DensityEnergy.A (MomentOperator.tau Φ φ) f-f) x ∂targetMeasure μ V Z) = 0) : DensityEnergy.A (MomentOperator.tau Φ φ) (DensityEnergy.A (MomentOperator.tau Φ φ) g-g) = 0 := by have hs := smooth_tau hφ Φ hInv have hPg := DensityEnergy.smooth_A hs ((DensityEnergy.smooth_A hs hg).sub hg) have hae := ae_eq_zero_of_integral_contDiff_smul_eq_zero (μ := targetMeasure μ V Z) hPg.continuous.locallyIntegrable (fun f hf hc => ?_) · exact MeasureTheory.Measure.eq_of_ae_eq hae hPg.continuous continuous_zero · change (∫ x, f x*DensityEnergy.A (MomentOperator.tau Φ φ) (DensityEnergy.A (MomentOperator.tau Φ φ) g-g) x ∂targetMeasure μ V Z) = 0 rw [← P_selfadjoint_onecompact μ hφ hV hne hZ heq Φ hΦ hInv hf hg hc] exact hweak f hf hc end open MeasureTheory Matrix WeightedCalculus MomentCoordinates TargetCoordinates open scoped ContDiff variable {ι : Type*} [Fintype ι] [DecidableEq ι] lemma matrix_A_eq (τ : Space ι → Matrix ι ι ℝ) (f : Space ι → ℝ) : MatrixOperator.A τ f = DensityEnergy.A τ f := rfl theorem weak_kernel_smooth {φ V : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hV : ContDiff ℝ ∞ V) (hpos : ∀ z, (hess φ z).PosDef) {Z m : ℝ} (hZ : 0 < Z) (hVlower : ∀ x, m ≤ V x) (Φ : Space ι ≃ₜ Space ι) (hInv : ContDiff ℝ ∞ (Φ.symm : Space ι → Space ι)) {g : Space ι → ℝ} (hg : MemLp g 2 (targetMeasure volume V Z)) (hweak : ∀ f : Space ι → ℝ, ContDiff ℝ ∞ f → HasCompactSupport f → (∫ x, g x*DensityEnergy.A (MomentOperator.tau Φ φ) (DensityEnergy.A (MomentOperator.tau Φ φ) f-f) x ∂targetMeasure volume V Z) = 0) : ∃ w : Space ι → ℝ, ContDiff ℝ ∞ w ∧ g =ᵐ[targetMeasure volume V Z] w := by let ρ : Space ι → ℝ := fun x => weight V x/Z have hρ : ContDiff ℝ ∞ ρ := (smooth_weight hV).div_const Z have hρp (x : Space ι) : 0 < ρ x := div_pos (Real.exp_pos _) hZ have hρC (x : Space ι) : ρ x ≤ Real.exp (-m)/Z := by exact div_le_div_of_nonneg_right (Real.exp_le_exp.mpr (neg_le_neg (hVlower x))) hZ.le have hw : ∀ f : Space ι → ℝ, ContDiff ℝ ∞ f → HasCompactSupport f → (∫ x, MatrixOperator.A (MomentOperator.tau Φ φ) (MatrixOperator.A (MomentOperator.tau Φ φ) f-f) x*g x ∂ WeightedRegularity.densityMeasure volume ρ)=0 := by intro f hf hc have hμ : WeightedRegularity.densityMeasure volume ρ = targetMeasure volume V Z := rfl rw [hμ,matrix_A_eq,matrix_A_eq] change (∫ x, DensityEnergy.A (MomentOperator.tau Φ φ) (DensityEnergy.A (MomentOperator.tau Φ φ) f-f) x*g x ∂targetMeasure volume V Z)=0 simpa only [mul_comm] using hweak f hf hc exact MatrixOperator.smooth_of_weighted_weak_square (ι:=ι) (MomentOperator.tau Φ φ) (smooth_tau hφ Φ hInv) (fun x => hpos (Φ.symm x)) ρ hρ hρp hρC g hg hw theorem weak_kernel_affine {φ V : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hV : ContDiff ℝ ∞ V) (hpos : ∀ z, (hess φ z).PosDef) {c Z Λ m : ℝ} (hZ : 0 < Z) [IsFiniteMeasure (targetMeasure volume V Z)] [Measure.IsOpenPosMeasure (targetMeasure volume V Z)] (hVlower : ∀ x, m ≤ V x) (hΛ : 0 ≤ Λ) (hupper : ∀ z, (Λ • (1 : Matrix ι ι ℝ)-hess φ z).PosSemidef) (heq : ∀ z, Real.log (hess φ z).det = V (grad φ z)+c-φ z) (Φ : Space ι ≃ₜ Space ι) (hΦ : (Φ : Space ι → Space ι) = grad φ) (hInv : ContDiff ℝ ∞ (Φ.symm : Space ι → Space ι)) (hmap : Measure.map (grad φ) (sourceMeasure volume φ) = targetMeasure volume V Z) {g : Space ι → ℝ} (hg : MemLp g 2 (targetMeasure volume V Z)) (hweak : ∀ f : Space ι → ℝ, ContDiff ℝ ∞ f → HasCompactSupport f → (∫ x, g x*DensityEnergy.A (MomentOperator.tau Φ φ) (DensityEnergy.A (MomentOperator.tau Φ φ) f-f) x ∂targetMeasure volume V Z) = 0) : ∃ a : ℝ, ∃ b : ι → ℝ, g =ᵐ[targetMeasure volume V Z] (fun x => a+∑ i, x i*b i) := by obtain ⟨w,hws,hwe⟩ := weak_kernel_smooth (ι:=ι) hφ hV hpos hZ hVlower Φ hInv hg hweak have hwe : g =ᵐ[targetMeasure volume V Z] w := hwe have hwLp : MemLp w 2 (targetMeasure volume V Z) := (memLp_congr_ae hwe).mp hg have hP := smooth_weak_kernel_equation (ι:=ι) (φ:=φ) (V:=V) (Z:=Z) (c:=c) (g:=w) volume hφ hV (fun z => (hpos z).det_pos.ne') hZ heq Φ hΦ hInv hws (by intro f hf hc calc _ = ∫ x, g x*DensityEnergy.A (MomentOperator.tau Φ φ) (DensityEnergy.A (MomentOperator.tau Φ φ) f-f) x ∂targetMeasure volume V Z := by apply integral_congr_ae filter_upwards [hwe] with x hx rw [hx] _ = 0 := hweak f hf hc) obtain ⟨a,b,hab⟩ := smooth_kernel_affine (ι:=ι) (φ:=φ) (V:=V) (Z:=Z) (Λ:=Λ) (c:=c) (g:=w) volume hφ hV hpos hZ hΛ hupper heq Φ hΦ hInv hmap hws hwLp.integrable_sq hP refine ⟨a,b,?_⟩ filter_upwards [hwe] with x hx exact hx.trans (hab x) end MomentKernel namespace RealSmoothOperator open MeasureTheory open scoped ContDiff variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] lemma derivative_add (vs : List E) {f g : E → ℝ} (hf : ContDiff ℝ ∞ f) (hg : ContDiff ℝ ∞ g) : derivative vs (f+g) = derivative vs f+derivative vs g := by induction vs with | nil => rfl | cons v vs ih => change (fun x => fderiv ℝ (derivative vs (f+g)) x v) = _ rw [ih] ext x simp only [Pi.add_apply,derivative, fderiv_add ((derivative_smooth vs hf).differentiable (by simp) x) ((derivative_smooth vs hg).differentiable (by simp) x),_root_.add_apply] lemma derivative_smul (vs : List E) (a : ℝ) {f : E → ℝ} (hf : ContDiff ℝ ∞ f) : derivative vs (a • f) = a • derivative vs f := by induction vs with | nil => rfl | cons v vs ih => change (fun x => fderiv ℝ (derivative vs (a • f)) x v) = _ rw [ih] ext x have hh := (((derivative_smooth vs hf).differentiable (by simp) x).hasFDerivAt.const_smul a).fderiv change fderiv ℝ (a • derivative vs f) x v = a * fderiv ℝ (derivative vs f) x v rw [show fderiv ℝ (a • derivative vs f) x = a • fderiv ℝ (derivative vs f) x from hh] rfl lemma operator_add (ts : List (Term E)) {f g : E → ℝ} (hf : ContDiff ℝ ∞ f) (hg : ContDiff ℝ ∞ g) : operator ts (f+g) = operator ts f+operator ts g := by induction ts with | nil => ext x; simp [operator] | cons t ts ih => ext x change t.1 x*derivative t.2 (f+g) x+operator ts (f+g) x = _ rw [derivative_add t.2 hf hg,ih] change t.1 x*(derivative t.2 f x+derivative t.2 g x)+ (operator ts f x+operator ts g x) = (t.1 x*derivative t.2 f x+operator ts f x)+(t.1 x*derivative t.2 g x+operator ts g x) ring lemma operator_smul (ts : List (Term E)) (a : ℝ) {f : E → ℝ} (hf : ContDiff ℝ ∞ f) : operator ts (a • f) = a • operator ts f := by induction ts with | nil => ext x; simp [operator] | cons t ts ih => ext x change t.1 x*derivative t.2 (a • f) x+operator ts (a • f) x = _ rw [derivative_smul t.2 a hf,ih] change t.1 x*(a*derivative t.2 f x)+a*operator ts f x = a*(t.1 x*derivative t.2 f x+operator ts f x) ring def tests : Submodule ℝ (E → ℝ) where carrier := {f | ContDiff ℝ ∞ f ∧ HasCompactSupport f} zero_mem' := ⟨contDiff_const,HasCompactSupport.zero⟩ add_mem' hf hg := ⟨hf.1.add hg.1,hf.2.add hg.2⟩ smul_mem' a _f hf := ⟨hf.1.const_smul a,hf.2.smul_left⟩ lemma tests_smooth (f : tests (E:=E)) : ContDiff ℝ ∞ (f : E → ℝ) := f.property.1 lemma tests_compact (f : tests (E:=E)) : HasCompactSupport (f : E → ℝ) := f.property.2 def operatorLinear (ts : List (Term E)) : tests (E:=E) →ₗ[ℝ] tests (E:=E) where toFun f := ⟨operator ts f,operator_smooth ts (tests_smooth f),operator_compact ts (tests_compact f)⟩ map_add' f g := Subtype.ext (operator_add ts (tests_smooth f) (tests_smooth g)) map_smul' a f := Subtype.ext (operator_smul ts a (tests_smooth f)) def squareLinear (ts : List (Term E)) : tests (E:=E) →ₗ[ℝ] tests (E:=E) := (operatorLinear ts).comp (operatorLinear ts-LinearMap.id) @[simp] lemma squareLinear_coe (ts : List (Term E)) (f : tests (E:=E)) : ((squareLinear ts f : tests (E:=E)) : E → ℝ) = operator ts (operator ts f-f) := rfl variable [MeasurableSpace E] [BorelSpace E] (μ : Measure E) [IsFiniteMeasureOnCompacts μ] def testsLp (f : tests (E:=E)) : Lp ℝ 2 μ := ((tests_smooth f).continuous.memLp_of_hasCompactSupport (tests_compact f) (p:=2)).toLp f lemma testsLp_coe (f : tests (E:=E)) : (testsLp μ f : E → ℝ) =ᵐ[μ] (f : E → ℝ) := MemLp.coeFn_toLp _ def testsLpLinear : tests (E:=E) →ₗ[ℝ] Lp ℝ 2 μ where toFun := testsLp μ map_add' f g := by apply Lp.ext filter_upwards [testsLp_coe μ (f+g),testsLp_coe μ f,testsLp_coe μ g,Lp.coeFn_add (testsLp μ f) (testsLp μ g)] with x ha hf hg hh rw [ha,hh] change (f : E → ℝ) x+(g : E → ℝ) x=(testsLp μ f : E → ℝ) x+(testsLp μ g : E → ℝ) x rw [hf,hg] map_smul' a f := by apply Lp.ext filter_upwards [testsLp_coe μ (a • f),testsLp_coe μ f,Lp.coeFn_smul a (testsLp μ f)] with x ha hf hh change (testsLp μ (a • f) : E → ℝ) x=(a • testsLp μ f : Lp ℝ 2 μ) x rw [ha,hh] change a*(f : E → ℝ) x=a*(testsLp μ f : E → ℝ) x rw [hf] def squareLp (ts : List (Term E)) : tests (E:=E) →ₗ[ℝ] Lp ℝ 2 μ := (testsLpLinear μ).comp (squareLinear ts) def squareRange (ts : List (Term E)) : Submodule ℝ (Lp ℝ 2 μ) := (squareLp μ ts).range lemma squareLp_coe (ts : List (Term E)) (f : tests (E:=E)) : (squareLp μ ts f : E → ℝ) =ᵐ[μ] operator ts (operator ts f-f) := testsLp_coe μ _ lemma orthogonal_weak (ts : List (Term E)) {g : Lp ℝ 2 μ} (hg : g ∈ (squareRange μ ts)ᗮ) : ∀ f : E → ℝ, ContDiff ℝ ∞ f → HasCompactSupport f → (∫ x, operator ts (operator ts f-f) x*g x ∂μ)=0 := by intro f hf hc have hh := hg (squareLp μ ts ⟨f,hf,hc⟩) ⟨⟨f,hf,hc⟩,rfl⟩ rw [L2.inner_def] at hh calc _ = ∫ x, inner ℝ (squareLp μ ts ⟨f,hf,hc⟩ x) (g x) ∂μ := by apply integral_congr_ae filter_upwards [squareLp_coe μ ts ⟨f,hf,hc⟩] with x hx rw [hx,real_inner_comm] rfl _ = 0 := hh end RealSmoothOperator namespace EvenClosure open MeasureTheory open scoped InnerProductSpace variable {ι : Type*} [Fintype ι] abbrev Space (ι : Type*) := ι → ℝ variable (μ : Measure (Space ι)) [IsFiniteMeasure μ] lemma pair_affine_zero (hreflect : ∀ q : Space ι → ℝ, (∫ x, q (-x) ∂μ) = ∫ x, q x ∂μ) {F : Space ι → ℝ} (hF : MemLp F 2 μ) (hFe : ∀ x, F (-x) = F x) (hFc : (∫ x, F x ∂μ)=0) (a : ℝ) (b : ι → ℝ) (hg : MemLp (fun x : Space ι => a+∑ i, x i*b i) 2 μ) : (∫ x, F x*(a+∑ i, x i*b i) ∂μ)=0 := by let q : Space ι → ℝ := fun x => F x*(a+∑ i, x i*b i) have hqi : Integrable q μ := hF.integrable_mul hg have hFi : Integrable F μ := MemLp.integrable (by norm_num) hF have he (x : Space ι) : q (-x) = (2*a)*F x-q x := by dsimp [q] rw [hFe] simp only [neg_mul,Finset.sum_neg_distrib] ring have hi := hreflect q simp_rw [he] at hi rw [integral_sub (hFi.const_mul _) hqi,integral_const_mul,hFc,mul_zero] at hi change (∫ x, q x ∂μ)=0 linarith theorem mem_closure_of_affine_orthogonal (hreflect : ∀ q : Space ι → ℝ, (∫ x, q (-x) ∂μ) = ∫ x, q x ∂μ) (S : Submodule ℝ (Lp ℝ 2 μ)) (hkernel : ∀ g : Lp ℝ 2 μ, g ∈ Sᗮ → ∃ a : ℝ, ∃ b : ι → ℝ, (g : Space ι → ℝ) =ᵐ[μ] (fun x => a+∑ i, x i*b i)) {F : Space ι → ℝ} (hF : MemLp F 2 μ) (hFe : ∀ x, F (-x)=F x) (hFc : (∫ x, F x ∂μ)=0) : hF.toLp F ∈ closure (S : Set (Lp ℝ 2 μ)) := by change hF.toLp F ∈ S.topologicalClosure rw [← S.orthogonal_orthogonal_eq_closure] intro g hg obtain ⟨a,b,hab⟩ := hkernel g hg have hga : MemLp (fun x : Space ι => a+∑ i, x i*b i) 2 μ := (memLp_congr_ae hab).mp (Lp.memLp g) rw [L2.inner_def] calc _ = ∫ x, F x*(a+∑ i, x i*b i) ∂μ := by apply integral_congr_ae filter_upwards [hF.coeFn_toLp,hab] with x hx hy rw [hx,hy] rfl _ = 0 := pair_affine_zero μ hreflect hF hFe hFc a b hga end EvenClosure namespace MomentKernel open MeasureTheory Matrix WeightedCalculus MomentCoordinates TargetCoordinates open scoped ContDiff variable {ι : Type*} [Fintype ι] [DecidableEq ι] omit [DecidableEq ι] in lemma target_integral_reflect {V : Space ι → ℝ} (hV : ContDiff ℝ ∞ V) (hVe : ∀ x, V (-x)=V x) {Z : ℝ} (hZ : 0 < Z) (q : Space ι → ℝ) : (∫ x, q (-x) ∂targetMeasure volume V Z) = ∫ x, q x ∂targetMeasure volume V Z := by apply WeightedRegularity.integral_reflect (E:=Space ι) volume (ρ:=fun x : Space ι => weight V x/Z) ((smooth_weight hV).div_const Z).continuous.measurable (fun x : Space ι => (div_pos (Real.exp_pos _) hZ).le) (f:=q) intro x dsimp [weight] rw [hVe] theorem centered_even_mem_closure {φ V : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hV : ContDiff ℝ ∞ V) (hVe : ∀ x, V (-x)=V x) (hpos : ∀ z, (hess φ z).PosDef) {c Z Λ m : ℝ} (hZ : 0 < Z) [IsFiniteMeasure (targetMeasure volume V Z)] [Measure.IsOpenPosMeasure (targetMeasure volume V Z)] (hVlower : ∀ x, m ≤ V x) (hΛ : 0 ≤ Λ) (hupper : ∀ z, (Λ • (1 : Matrix ι ι ℝ)-hess φ z).PosSemidef) (heq : ∀ z, Real.log (hess φ z).det = V (grad φ z)+c-φ z) (Φ : Space ι ≃ₜ Space ι) (hΦ : (Φ : Space ι → Space ι) = grad φ) (hInv : ContDiff ℝ ∞ (Φ.symm : Space ι → Space ι)) (hmap : Measure.map (grad φ) (sourceMeasure volume φ) = targetMeasure volume V Z) {F : Space ι → ℝ} (hF : MemLp F 2 (targetMeasure volume V Z)) (hFe : ∀ x, F (-x)=F x) (hFc : (∫ x, F x ∂targetMeasure volume V Z)=0) : hF.toLp F ∈ closure ((RealSmoothOperator.squareRange (E:=Space ι) (targetMeasure volume V Z) (MatrixOperator.principal (MomentOperator.tau Φ φ) (smooth_tau hφ Φ hInv)++ MatrixOperator.drift)) : Set (Lp ℝ 2 (targetMeasure volume V Z))) := by refine EvenClosure.mem_closure_of_affine_orthogonal (ι:=ι) (targetMeasure volume V Z) (S := RealSmoothOperator.squareRange (E:=Space ι) (targetMeasure volume V Z) (MatrixOperator.principal (MomentOperator.tau Φ φ) (smooth_tau hφ Φ hInv)++ MatrixOperator.drift (ι:=ι))) ?_ ?_ hF hFe hFc · exact target_integral_reflect hV hVe hZ · intro g hg apply weak_kernel_affine (ι:=ι) (φ:=φ) (V:=V) (Z:=Z) (Λ:=Λ) (c:=c) (m:=m) (g:=g) hφ hV hpos hZ hVlower hΛ hupper heq Φ hΦ hInv hmap (Lp.memLp g) intro f hf hc have hw := RealSmoothOperator.orthogonal_weak (E:=Space ι) (targetMeasure volume V Z) (MatrixOperator.principal (MomentOperator.tau Φ φ) (smooth_tau hφ Φ hInv)++ MatrixOperator.drift) hg f hf hc rw [MatrixOperator.operator_actual,MatrixOperator.operator_actual] at hw simpa only [matrix_A_eq,mul_comm] using hw end MomentKernel namespace SteinExtension open MeasureTheory Filter open scoped ContDiff Topology variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] theorem extend (μ : Measure E) {b : E → ℝ} {v : E → E} (hb : Continuous b) (hv : Continuous v) {Λ : ℝ} (hbound : ∀ x, ‖v x‖ ≤ Λ) (hstein : ∀ f : E → ℝ, ContDiff ℝ ∞ f → HasCompactSupport f → (∫ x, b x * f x ∂μ) = ∫ x, fderiv ℝ f x (v x) ∂μ) {f : E → ℝ} (hf : ContDiff ℝ ∞ f) (hi : Integrable f μ) (hib : Integrable (fun x => b x*f x) μ) (hid : Integrable (fun x => fderiv ℝ f x (v x)) μ) : (∫ x, b x*f x ∂μ) = ∫ x, fderiv ℝ f x (v x) ∂μ := by let η := SmoothCutoff.seq (E:=E) have hη (k : ℕ) := SmoothCutoff.seq_smooth (E:=E) k have hηc (k : ℕ) := SmoothCutoff.seq_compact (E:=E) k have hηnorm (k : ℕ) (x : E) : ‖η k x‖ ≤ 1 := by rw [Real.norm_eq_abs, abs_of_nonneg (SmoothCutoff.seq_nonneg k x)] exact SmoothCutoff.seq_le_one k x obtain ⟨C,hC,hCbound⟩ := SmoothCutoff.seq_derivative_bounds (E:=E) have he (k : ℕ) (x : E) : fderiv ℝ (fun y => η k y*f y) x (v x) = η k x * fderiv ℝ f x (v x) + f x * fderiv ℝ (η k) x (v x) := by rw [fderiv_fun_mul ((hη k).differentiable (by simp) x) (hf.differentiable (by simp) x)] simp only [_root_.add_apply, _root_.smul_apply, smul_eq_mul] ring have hleft : Tendsto (fun k => ∫ x, b x*(η k x*f x) ∂μ) atTop (𝓝 (∫ x, b x*f x ∂μ)) := by apply tendsto_integral_of_dominated_convergence (fun x => ‖b x*f x‖) (fun k => (hb.mul ((hη k).continuous.mul hf.continuous)).aestronglyMeasurable) hib.norm · intro k exact Filter.Eventually.of_forall (fun x => by change ‖b x*(η k x*f x)‖ ≤ ‖b x*f x‖ rw [show b x*(η k x*f x) = η k x*(b x*f x) by ring, norm_mul] exact (mul_le_mul_of_nonneg_right (hηnorm k x) (norm_nonneg _)).trans_eq (one_mul _)) · exact Filter.Eventually.of_forall (fun x => by apply tendsto_const_nhds.congr' filter_upwards [SmoothCutoff.seq_eventually x] with k hk change b x*f x = b x*(η k x*f x) rw [show η k x = 1 from hk.1, one_mul]) have hright : Tendsto (fun k => ∫ x, fderiv ℝ (fun y => η k y*f y) x (v x) ∂μ) atTop (𝓝 (∫ x, fderiv ℝ f x (v x) ∂μ)) := by apply tendsto_integral_of_dominated_convergence (fun x => ‖fderiv ℝ f x (v x)‖ + (C*Λ)*‖f x‖) · intro k exact (((((hη k).mul hf).fderiv_right (m:=∞) (by simp)).continuous).clm_apply hv).aestronglyMeasurable · exact hid.norm.add (hi.norm.const_mul _) · intro k exact Filter.Eventually.of_forall (fun x => by rw [he] calc _ ≤ ‖η k x * fderiv ℝ f x (v x)‖ + ‖f x * fderiv ℝ (η k) x (v x)‖ := norm_add_le _ _ _ ≤ ‖fderiv ℝ f x (v x)‖ + (C*Λ)*‖f x‖ := by simp only [norm_mul] apply add_le_add · exact (mul_le_mul_of_nonneg_right (hηnorm k x) (norm_nonneg _)).trans_eq (one_mul _) · have hvd : ‖fderiv ℝ (η k) x (v x)‖ ≤ C*Λ := ((fderiv ℝ (η k) x).le_opNorm _).trans (mul_le_mul (hCbound k x).1 (hbound x) (norm_nonneg _) hC.le) simpa only [mul_comm (C*Λ)] using mul_le_mul_of_nonneg_left hvd (norm_nonneg (f x))) · exact Filter.Eventually.of_forall (fun x => by apply tendsto_const_nhds.congr' filter_upwards [SmoothCutoff.seq_eventually x] with k hk rw [he] simp only [η, hk.1, hk.2.1, _root_.zero_apply, mul_zero, add_zero, one_mul]) have hid' (k : ℕ) := hstein (fun y => η k y*f y) ((hη k).mul hf) (hηc k).mul_right exact tendsto_nhds_unique hleft (hright.congr (fun k => (hid' k).symm)) end SteinExtension end open Matrix open scoped BigOperators Kronecker noncomputable section namespace MetricTensor variable {ι : Type*} [Fintype ι] abbrev Idx (ι : Type*) := ι × ι × ι abbrev Tensor (ι : Type*) := Idx ι → ℝ def kernel (T : Matrix ι ι ℝ) : Matrix (Idx ι) (Idx ι) ℝ := T ⊗ₖ (T ⊗ₖ T) def pair (T : Matrix ι ι ℝ) (A B : Tensor ι) : ℝ := A ⬝ᵥ (kernel T *ᵥ B) def sq (T : Matrix ι ι ℝ) (A : Tensor ι) : ℝ := pair T A A def sw : Idx ι ≃ Idx ι where toFun p := (p.2.1, p.1, p.2.2) invFun p := (p.2.1, p.1, p.2.2) left_inv := by rintro ⟨i,j,k⟩; rfl right_inv := by rintro ⟨i,j,k⟩; rfl def cy : Idx ι ≃ Idx ι where toFun p := (p.2.2, p.1, p.2.1) invFun p := (p.2.1, p.2.2, p.1) left_inv := by rintro ⟨i,j,k⟩; rfl right_inv := by rintro ⟨i,j,k⟩; rfl def swap (A : Tensor ι) : Tensor ι := A ∘ sw def cycle (A : Tensor ι) : Tensor ι := A ∘ cy def sym (A : Tensor ι) : Tensor ι := (1/3 : ℝ) • (A + swap A + cycle A) lemma pair_expand (T : Matrix ι ι ℝ) (A B : Tensor ι) : pair T A B = ∑ p, ∑ q, kernel T p q * A p * B q := by simp only [pair, dotProduct, Matrix.mulVec, Finset.mul_sum] congr 1 ext p apply Finset.sum_congr rfl intro q _ ring omit [Fintype ι] in lemma kernel_symm {T : Matrix ι ι ℝ} (hT : Tᵀ = T) : (kernel T)ᵀ = kernel T := by ext ⟨i,j,k⟩ ⟨a,b,c⟩ have hs (a b : ι) : T a b = T b a := congrArg (fun M : Matrix ι ι ℝ => M b a) hT simp only [kernel, Matrix.transpose_apply, Matrix.kronecker_apply] rw [hs a i, hs b j, hs c k] lemma pair_comm {T : Matrix ι ι ℝ} (hT : Tᵀ = T) (A B : Tensor ι) : pair T A B = pair T B A := by rw [pair_expand, pair_expand, Finset.sum_comm] apply Finset.sum_congr rfl intro p _ apply Finset.sum_congr rfl intro q _ have hs := congrArg (fun M : Matrix (Idx ι) (Idx ι) ℝ => M p q) (kernel_symm hT) change kernel T q p = kernel T p q at hs rw [hs] ring lemma sq_nonneg {T : Matrix ι ι ℝ} (hT : T.PosSemidef) (A : Tensor ι) : 0 ≤ sq T A := by have hp : (kernel T).PosSemidef := hT.kronecker (hT.kronecker hT) simpa only [sq, pair, star_trivial] using hp.dotProduct_mulVec_nonneg A lemma pair_comp (T : Matrix ι ι ℝ) (e : Idx ι ≃ Idx ι) (he : ∀ p q, kernel T (e p) (e q) = kernel T p q) (A B : Tensor ι) : pair T (A ∘ e) (B ∘ e) = pair T A B := by simp only [pair_expand, Function.comp_apply] apply Fintype.sum_equiv e intro p apply Fintype.sum_equiv e intro q rw [he] lemma pair_swap (T : Matrix ι ι ℝ) (A B : Tensor ι) : pair T (swap A) (swap B) = pair T A B := by apply pair_comp rintro ⟨i,j,k⟩ ⟨a,b,c⟩ simp only [sw, Equiv.coe_fn_mk, kernel, Matrix.kronecker_apply] ring lemma pair_cycle (T : Matrix ι ι ℝ) (A B : Tensor ι) : pair T (cycle A) (cycle B) = pair T A B := by apply pair_comp rintro ⟨i,j,k⟩ ⟨a,b,c⟩ simp only [cy, Equiv.coe_fn_mk, kernel, Matrix.kronecker_apply] ring lemma pair_add_left (T : Matrix ι ι ℝ) (A B C : Tensor ι) : pair T (A+B) C = pair T A C + pair T B C := by exact add_dotProduct _ _ _ lemma pair_add_right (T : Matrix ι ι ℝ) (A B C : Tensor ι) : pair T A (B+C) = pair T A B + pair T A C := by simp only [pair, Matrix.mulVec_add, dotProduct_add] lemma pair_smul_left (T : Matrix ι ι ℝ) (r : ℝ) (A B : Tensor ι) : pair T (r • A) B = r * pair T A B := by simp only [pair, smul_dotProduct, smul_eq_mul] lemma pair_smul_right (T : Matrix ι ι ℝ) (r : ℝ) (A B : Tensor ι) : pair T A (r • B) = r * pair T A B := by simp only [pair, Matrix.mulVec_smul, dotProduct_smul, smul_eq_mul] lemma sq_add {T : Matrix ι ι ℝ} (hT : Tᵀ = T) (A B : Tensor ι) : sq T (A+B) = sq T A + 2*pair T A B + sq T B := by unfold sq rw [pair_add_left, pair_add_right, pair_add_right, pair_comm hT B A] ring lemma sq_sub {T : Matrix ι ι ℝ} (hT : Tᵀ = T) (A B : Tensor ι) : sq T (A-B) = sq T A - 2*pair T A B + sq T B := by have he : A-B = A + (-1 : ℝ) • B := by ext p; simp [sub_eq_add_neg] rw [he, sq_add hT, pair_smul_right] unfold sq rw [pair_smul_left, pair_smul_right] ring lemma sq_smul (T : Matrix ι ι ℝ) (r : ℝ) (A : Tensor ι) : sq T (r • A) = r^2 * sq T A := by unfold sq rw [pair_smul_left, pair_smul_right] ring omit [Fintype ι] in lemma cycle_swap_of_last (A : Tensor ι) (hA : ∀ i j k, A (i,j,k) = A (i,k,j)) : cycle (swap A) = A := by ext ⟨i,j,k⟩ exact hA i k j omit [Fintype ι] in lemma swap_cycle_of_last (A : Tensor ι) (hA : ∀ i j k, A (i,j,k) = A (i,k,j)) : swap (cycle A) = cycle A := by ext ⟨i,j,k⟩ exact hA k j i lemma pair_cyc_eq {T : Matrix ι ι ℝ} (hT : Tᵀ = T) (A : Tensor ι) (hA : ∀ i j k, A (i,j,k) = A (i,k,j)) : pair T A (cycle A) = pair T A (swap A) := by rw [← pair_cycle T A (swap A), cycle_swap_of_last A hA, pair_comm hT] lemma pair_swap_cyc {T : Matrix ι ι ℝ} (hT : Tᵀ = T) (A : Tensor ι) (hA : ∀ i j k, A (i,j,k) = A (i,k,j)) : pair T (swap A) (cycle A) = pair T A (swap A) := by rw [← swap_cycle_of_last A hA, pair_swap, pair_cyc_eq hT A hA] lemma sq_sym {T : Matrix ι ι ℝ} (hT : Tᵀ = T) (A : Tensor ι) (hA : ∀ i j k, A (i,j,k) = A (i,k,j)) : sq T (sym A) = (sq T A + 2*pair T A (swap A))/3 := by rw [sym, sq_smul, sq_add hT, sq_add hT, pair_add_left, pair_cyc_eq hT A hA, pair_swap_cyc hT A hA] have hs : sq T (swap A) = sq T A := pair_swap T A A have hc : sq T (cycle A) = sq T A := pair_cycle T A A rw [hs, hc] ring lemma pair_sym {T : Matrix ι ι ℝ} (S A : Tensor ι) (hS₁ : swap S = S) (hS₂ : cycle S = S) : pair T S (sym A) = pair T S A := by have hs : pair T S (swap A) = pair T S A := by rw [← hS₁, pair_swap, hS₁] have hc : pair T S (cycle A) = pair T S A := by rw [← hS₂, pair_cycle, hS₂] rw [sym, pair_smul_right, pair_add_right, pair_add_right, hs, hc] ring theorem tensor_squares {T : Matrix ι ι ℝ} (hT : Tᵀ = T) (S J : Tensor ι) (hS₁ : swap S = S) (hS₂ : cycle S = S) (hJ : ∀ i j k, J (i,j,k) = J (i,k,j)) : 2*sq T S + 4*pair T S J + sq T J + pair T J (swap J) = 2*sq T (S + sym J) + (1/6 : ℝ)*sq T (J - swap J) := by rw [sq_add hT, pair_sym S J hS₁ hS₂, sq_sym hT J hJ, sq_sub hT] have hs : sq T (swap J) = sq T J := pair_swap T J J rw [hs] ring theorem remainder_nonneg {T : Matrix ι ι ℝ} (hT : T.PosSemidef) (S J : Tensor ι) (hS₁ : swap S = S) (hS₂ : cycle S = S) (hJ : ∀ i j k, J (i,j,k) = J (i,k,j)) : 0 ≤ 2*sq T S + 4*pair T S J + sq T J + pair T J (swap J) := by have hs : Tᵀ = T := by simpa only [Matrix.conjTranspose_eq_transpose_of_trivial] using hT.isHermitian.eq rw [tensor_squares hs S J hS₁ hS₂ hJ] positivity [sq_nonneg hT (S + sym J), sq_nonneg hT (J - swap J)] def act (A B C : Matrix ι ι ℝ) (X : Tensor ι) : Tensor ι := (A ⊗ₖ (B ⊗ₖ C)) *ᵥ X lemma act_apply (A B C : Matrix ι ι ℝ) (X : Tensor ι) (i j k : ι) : act A B C X (i,j,k) = ∑ a, ∑ b, ∑ c, A i a * B j b * C k c * X (a,b,c) := by simp only [act, Matrix.mulVec, dotProduct, Fintype.sum_prod_type, Matrix.kronecker_apply] apply Finset.sum_congr rfl intro a _ apply Finset.sum_congr rfl intro b _ apply Finset.sum_congr rfl intro c _ ring lemma act_comp (A B C D E F : Matrix ι ι ℝ) (X : Tensor ι) : act A B C (act D E F X) = act (A*D) (B*E) (C*F) X := by unfold act rw [Matrix.mulVec_mulVec, ← Matrix.mul_kronecker_mul, ← Matrix.mul_kronecker_mul] lemma act_dot (A B C : Matrix ι ι ℝ) (X Y : Tensor ι) : act A B C X ⬝ᵥ Y = X ⬝ᵥ act Aᵀ Bᵀ Cᵀ Y := by change ((A ⊗ₖ (B ⊗ₖ C)) *ᵥ X) ⬝ᵥ Y = _ rw [dotProduct_comm, Matrix.dotProduct_mulVec, dotProduct_comm, ← Matrix.mulVec_transpose] congr 2 lemma pair_act (T A B C D E F : Matrix ι ι ℝ) (X Y : Tensor ι) : pair T (act A B C X) (act D E F Y) = X ⬝ᵥ act (Aᵀ*T*D) (Bᵀ*T*E) (Cᵀ*T*F) Y := by change act A B C X ⬝ᵥ act T T T (act D E F Y) = _ rw [act_dot, act_comp, act_comp] lemma swap_act (A B C : Matrix ι ι ℝ) (X : Tensor ι) : swap (act A B C X) = act B A C (swap X) := by ext ⟨i,j,k⟩ change act A B C X (j,i,k) = _ rw [act_apply, act_apply, Finset.sum_comm] apply Finset.sum_congr rfl intro b _ apply Finset.sum_congr rfl intro a _ apply Finset.sum_congr rfl intro c _ change A j a * B i b * C k c * X (a,b,c) = B i b * A j a * C k c * X (a,b,c) ring lemma act_last_symm (A B : Matrix ι ι ℝ) (X : Tensor ι) (hX : ∀ i j k, X (i,j,k) = X (i,k,j)) (i j k : ι) : act A B B X (i,j,k) = act A B B X (i,k,j) := by rw [act_apply, act_apply] apply Finset.sum_congr rfl intro a _ rw [Finset.sum_comm] apply Finset.sum_congr rfl intro b _ apply Finset.sum_congr rfl intro c _ rw [hX a c b] ring lemma cycle_act (A B C : Matrix ι ι ℝ) (X : Tensor ι) : cycle (act A B C X) = act B C A (cycle X) := by ext ⟨i,j,k⟩ change act A B C X (k,i,j) = _ rw [act_apply, act_apply] have hr (f : ι → ι → ι → ℝ) : (∑ a, ∑ b, ∑ c, f a b c) = ∑ b, ∑ c, ∑ a, f a b c := by rw [Finset.sum_comm] apply Finset.sum_congr rfl intro b _ rw [Finset.sum_comm] rw [hr] apply Finset.sum_congr rfl intro b _ apply Finset.sum_congr rfl intro c _ apply Finset.sum_congr rfl intro a _ change A k a * B i b * C j c * X (a,b,c) = B i b * C j c * A k a * X (a,b,c) ring lemma dot_swap (X Y : Tensor ι) : swap X ⬝ᵥ swap Y = X ⬝ᵥ Y := comp_equiv_dotProduct_comp_equiv X Y sw lemma dot_cycle (X Y : Tensor ι) : cycle X ⬝ᵥ cycle Y = X ⬝ᵥ Y := comp_equiv_dotProduct_comp_equiv X Y cy variable [DecidableEq ι] lemma pair_J (T M h : Matrix ι ι ℝ) (hTM : T*M = 1) (S C : Tensor ι) : pair T S (act h M M C) = S ⬝ᵥ act (T*h) 1 1 C := by change S ⬝ᵥ act T T T (act h M M C) = _ rw [act_comp, hTM] lemma sq_J (T M h : Matrix ι ι ℝ) (hM : Mᵀ=M) (hh : hᵀ=h) (hMT : M*T=1) (C : Tensor ι) : sq T (act h M M C) = C ⬝ᵥ act (h*T*h) M M C := by unfold sq rw [pair_act, hh, hM, hMT, Matrix.one_mul] lemma pair_J_swap (T M h : Matrix ι ι ℝ) (hM : Mᵀ=M) (hh : hᵀ=h) (hMT : M*T=1) (hTM : T*M=1) (C : Tensor ι) (hC : swap C=C) : pair T (act h M M C) (swap (act h M M C)) = C ⬝ᵥ act h h M C := by rw [swap_act, hC, pair_act, hh, hM, hMT, Matrix.one_mul, Matrix.mul_assoc h T M, hTM, Matrix.mul_one, Matrix.one_mul] lemma act_one_one (A : Matrix ι ι ℝ) (X : Tensor ι) (i j k : ι) : act A 1 1 X (i,j,k) = ∑ a, A i a * X (a,j,k) := by simp [act_apply, Matrix.one_apply, mul_ite, ite_mul] lemma dot_slot₂ (A : Matrix ι ι ℝ) (S C : Tensor ι) (hS : swap S=S) (hC : swap C=C) : S ⬝ᵥ act 1 A 1 C = S ⬝ᵥ act A 1 1 C := by rw [← dot_swap, hS, swap_act, hC] lemma dot_slot₃ (A : Matrix ι ι ℝ) (S C : Tensor ι) (hS : cycle S=S) (hC : cycle C=C) : S ⬝ᵥ act 1 1 A C = S ⬝ᵥ act A 1 1 C := by rw [← dot_cycle, hS, cycle_act, hC, ← dot_cycle, hS, cycle_act, hC] lemma invariant_cross (T M h : Matrix ι ι ℝ) (hT : Tᵀ=T) (hTM : T*M=1) (S C : Tensor ι) (hS : cycle S=S) (hC : cycle C=C) : (act 1 1 T S) ⬝ᵥ (act 1 1 h C + act T T 1 S) = sq T S + pair T S (act h M M C) := by rw [dotProduct_add, act_dot, act_dot, act_comp, act_comp] simp only [Matrix.transpose_one, hT, Matrix.one_mul, Matrix.mul_one] rw [dot_slot₃ (T*h) S C hS hC, pair_J T M h hTM] change _ + sq T S = _ ring lemma invariant_derivative (T M h : Matrix ι ι ℝ) (hT : Tᵀ=T) (hM : Mᵀ=M) (hh : hᵀ=h) (hTM : T*M=1) (hMT : M*T=1) (S C : Tensor ι) (hS : swap S=S) (hC : swap C=C) : (act 1 (h*T) T S + act (h*T) 1 T S + act h h 1 C) ⬝ᵥ act 1 1 M C = 2*pair T S (act h M M C) + pair T (act h M M C) (swap (act h M M C)) := by rw [add_dotProduct, add_dotProduct, act_dot, act_dot, act_dot, act_comp, act_comp, act_comp] simp only [Matrix.transpose_one, Matrix.transpose_mul, hT, hh, Matrix.one_mul, Matrix.mul_one, hTM] rw [dot_slot₂ (T*h) S C hS hC, pair_J T M h hTM, pair_J_swap T M h hM hh hMT hTM C hC] ring theorem invariant_remainder_nonneg (T M h : Matrix ι ι ℝ) (hT : T.PosSemidef) (hM : Mᵀ=M) (hh : hᵀ=h) (hTM : T*M=1) (hMT : M*T=1) (S C : Tensor ι) (hS₁ : swap S=S) (hS₂ : cycle S=S) (hC₁ : swap C=C) (hC₂ : cycle C=C) (hC₃ : ∀ i j k, C (i,j,k)=C (i,k,j)) : 0 ≤ 2*((act 1 1 T S) ⬝ᵥ (act 1 1 h C + act T T 1 S)) + (act 1 (h*T) T S + act (h*T) 1 T S + act h h 1 C) ⬝ᵥ act 1 1 M C + C ⬝ᵥ act (h*T*h) M M C := by have ht : Tᵀ=T := by simpa only [Matrix.conjTranspose_eq_transpose_of_trivial] using hT.isHermitian.eq rw [invariant_cross T M h ht hTM S C hS₂ hC₂, invariant_derivative T M h ht hM hh hTM hMT S C hS₁ hC₁, ← sq_J T M h hM hh hMT C] have hn := remainder_nonneg hT S (act h M M C) hS₁ hS₂ (act_last_symm h M C hC₃) linarith end MetricTensor namespace TensorEstimate open WeightedCalculus MomentCoordinates MomentDifferential MomentEquation Matrix MetricTensor open scoped ContDiff variable {ι : Type*} [Fintype ι] [DecidableEq ι] def cube (f : Space ι → ℝ) (z : Space ι) : Tensor ι := fun p => C f p.2.2 z p.1 p.2.1 def pulledH (φ f : Space ι → ℝ) : Space ι → Matrix ι ι ℝ := hess f ∘ grad φ def Q (φ f : Space ι → ℝ) (z : Space ι) : Matrix ι ι ℝ := pulledH φ f z * hess φ z * pulledH φ f z lemma cube_swap {f : Space ι → ℝ} (hf : ContDiff ℝ ∞ f) (z : Space ι) : swap (cube f z) = cube f z := by ext ⟨i,j,k⟩ exact C_symm_last hf k z j i lemma cube_cycle {f : Space ι → ℝ} (hf : ContDiff ℝ ∞ f) (z : Space ι) : cycle (cube f z) = cube f z := by ext ⟨i,j,k⟩ change C f j z k i = C f k z i j rw [C_symm_first hf j z k i, C_symm_last hf k z j i] lemma cube_last {f : Space ι → ℝ} (hf : ContDiff ℝ ∞ f) (z : Space ι) (i j k : ι) : cube f z (i,j,k) = cube f z (i,k,j) := by change C f k z i j = C f j z i k rw [C_symm_last hf k z i j, C_symm_first hf k z j i, C_symm_last hf j z k i] lemma act₃_apply (A : Matrix ι ι ℝ) (X : Tensor ι) (i j k : ι) : act 1 1 A X (i,j,k) = ∑ c, A k c * X (i,j,c) := by simp [act_apply, Matrix.one_apply, mul_ite, ite_mul] lemma act₁₃_apply (A B : Matrix ι ι ℝ) (X : Tensor ι) (i j k : ι) : act A 1 B X (i,j,k) = ∑ a, ∑ c, A i a * B k c * X (a,j,c) := by simp [act_apply, Matrix.one_apply, mul_ite, ite_mul] lemma act₁₂_apply (A B : Matrix ι ι ℝ) (X : Tensor ι) (i j k : ι) : act A B 1 X (i,j,k) = ∑ a, ∑ b, A i a * B j b * X (a,b,k) := by simp [act_apply, Matrix.one_apply, mul_ite, ite_mul] lemma act₂₃_apply (A B : Matrix ι ι ℝ) (X : Tensor ι) (i j k : ι) : act 1 A B X (i,j,k) = ∑ b, ∑ c, A j b * B k c * X (i,b,c) := by simp [act_apply, Matrix.one_apply, ite_mul] lemma smooth_pulledH {φ f : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hf : ContDiff ℝ ∞ f) (i j : ι) : ContDiff ℝ ∞ (fun z => pulledH φ f z i j) := (smooth_hess hf i j).comp (smooth_grad hφ) lemma derivative_h {φ f : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hf : ContDiff ℝ ∞ f) (z : Space ι) : (fun p : Idx ι => pd p.2.2 (fun y => pulledH φ f y p.1 p.2.1) z) = act 1 1 (hess φ z) (cube f (grad φ z)) := by ext ⟨i,j,k⟩ change pd k ((fun x => hess f x i j) ∘ grad φ) z = _ rw [pd_comp_grad (smooth_hess hf i j) hφ k, act₃_apply] rfl lemma derivative_P_swap {φ f : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hf : ContDiff ℝ ∞ f) (z : Space ι) : (fun p : Idx ι => pd p.2.1 (P φ f p.1 p.2.2) z) = act 1 1 (pulledH φ f z) (cube φ z) + act (hess φ z) (hess φ z) 1 (cube f (grad φ z)) := by ext ⟨a,l,k⟩ change pd l (fun y => ∑ i, hess φ y a i * pulledH φ f y i k) z = _ rw [pd_sum _ (fun i => (smooth_hess hφ a i).mul (smooth_pulledH hφ hf i k))] have hd (i : ι) := congrFun (pd_mul (smooth_hess hφ a i) (smooth_pulledH hφ hf i k) l) z simp_rw [hd] rw [Finset.sum_add_distrib] change _ = act 1 1 (pulledH φ f z) (cube φ z) (a,l,k) + act (hess φ z) (hess φ z) 1 (cube f (grad φ z)) (a,l,k) rw [act₃_apply, act₁₂_apply] congr 1 · apply Finset.sum_congr rfl intro i _ change C φ l z a i * hess f (grad φ z) i k = hess f (grad φ z) k i * C φ i z a l rw [hess_symm hf _ i k, C_symm_last hφ l z a i, C_symm_first hφ l z i a, C_symm_last hφ i z l a] ring · apply Finset.sum_congr rfl intro i _ change hess φ z a i * pd l ((fun x => hess f x i k) ∘ grad φ) z = _ rw [pd_comp_grad (smooth_hess hf i k) hφ l, Finset.mul_sum] apply Finset.sum_congr rfl intro b _ change hess φ z a i * (hess φ z l b * C f b (grad φ z) i k) = hess φ z a i * hess φ z l b * C f k (grad φ z) i b rw [C_symm_last hf b _ i k, C_symm_first hf b _ k i, C_symm_last hf k _ b i] ring lemma smooth_Q {φ f : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hf : ContDiff ℝ ∞ f) (i j : ι) : ContDiff ℝ ∞ (fun z => Q φ f z i j) := smooth_matrix_product (smooth_matrix_product (smooth_pulledH hφ hf) (smooth_hess hφ)) (smooth_pulledH hφ hf) i j lemma derivative_Q {φ f : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hf : ContDiff ℝ ∞ f) (z : Space ι) : (fun p : Idx ι => pd p.2.2 (fun y => Q φ f y p.1 p.2.1) z) = act 1 (pulledH φ f z * hess φ z) (hess φ z) (cube f (grad φ z)) + act (pulledH φ f z * hess φ z) 1 (hess φ z) (cube f (grad φ z)) + act (pulledH φ f z) (pulledH φ f z) 1 (cube φ z) := by ext ⟨i,j,d⟩ have hd := md_mul (smooth_matrix_product (smooth_pulledH hφ hf) (smooth_hess hφ)) (smooth_pulledH hφ hf) (basis d) z rw [md_mul (smooth_pulledH hφ hf) (smooth_hess hφ), Matrix.add_mul] at hd have hde (a b : ι) : md (basis d) (pulledH φ f) z a b = ∑ c, hess φ z d c * cube f (grad φ z) (a,b,c) := by have he := congrFun (derivative_h hφ hf z) (a,b,d) simpa only [act₃_apply, pd, D, md] using he have hc : md (basis d) (hess φ) z = C φ d z := rfl change md (basis d) (fun y => pulledH φ f y * hess φ y * pulledH φ f y) z i j = _ rw [hd, Matrix.add_apply, Matrix.add_apply, hc] change _ = act 1 (pulledH φ f z * hess φ z) (hess φ z) (cube f (grad φ z)) (i,j,d) + act (pulledH φ f z * hess φ z) 1 (hess φ z) (cube f (grad φ z)) (i,j,d) + act (pulledH φ f z) (pulledH φ f z) 1 (cube φ z) (i,j,d) have he₁ : (md (basis d) (pulledH φ f) z * hess φ z * pulledH φ f z) i j = act 1 (pulledH φ f z * hess φ z) (hess φ z) (cube f (grad φ z)) (i,j,d) := by rw [Matrix.mul_assoc, Matrix.mul_apply, act₂₃_apply] apply Finset.sum_congr rfl intro a _ rw [hde, Finset.sum_mul] apply Finset.sum_congr rfl intro c _ have ht : (hess φ z * pulledH φ f z)ᵀ = pulledH φ f z * hess φ z := by rw [Matrix.transpose_mul, MomentCoordinates.hess_transpose hφ] change (hess f (grad φ z))ᵀ * hess φ z = _ rw [MomentCoordinates.hess_transpose hf] rfl have he := congrArg (fun A : Matrix ι ι ℝ => A j a) ht change (hess φ z * pulledH φ f z) a j = (pulledH φ f z * hess φ z) j a at he rw [he] ring have he₂ : (pulledH φ f z * hess φ z * md (basis d) (pulledH φ f) z) i j = act (pulledH φ f z * hess φ z) 1 (hess φ z) (cube f (grad φ z)) (i,j,d) := by rw [Matrix.mul_apply, act₁₃_apply] apply Finset.sum_congr rfl intro a _ rw [hde, Finset.mul_sum] apply Finset.sum_congr rfl intro c _ ring have he₃ : (pulledH φ f z * C φ d z * pulledH φ f z) i j = act (pulledH φ f z) (pulledH φ f z) 1 (cube φ z) (i,j,d) := by simp only [Matrix.mul_apply, Finset.sum_mul, act₁₂_apply] rw [Finset.sum_comm] apply Finset.sum_congr rfl intro a _ apply Finset.sum_congr rfl intro b _ change hess f (grad φ z) i a * C φ d z a b * hess f (grad φ z) b j = hess f (grad φ z) i a * hess f (grad φ z) j b * C φ d z a b rw [hess_symm hf _ b j] ring rw [he₁, he₂, he₃] ring def slice (X : Tensor ι) (i : ι) : Matrix ι ι ℝ := fun a b => X (i,a,b) omit [DecidableEq ι] in lemma cubic_trace (Q M : Matrix ι ι ℝ) (hM : Mᵀ=M) (X : Tensor ι) (hX : ∀ i j k, X (i,j,k)=X (i,k,j)) : (∑ i, ∑ j, Q i j * (M * slice X i * M * slice X j).trace) = X ⬝ᵥ act Q M M X := by let e : (ι × ι × ι × ι × ι × ι) ≃ (ι × ι × ι × ι × ι × ι) := { toFun := fun (i,j,k,b,l,a) => (i,a,l,j,k,b) invFun := fun (i,a,l,j,k,b) => (i,j,k,b,l,a) left_inv := by rintro ⟨i,j,k,b,l,a⟩; rfl right_inv := by rintro ⟨i,a,l,j,k,b⟩; rfl } have hs (a b : ι) : M a b = M b a := congrArg (fun N : Matrix ι ι ℝ => N b a) hM calc _ = ∑ p : ι × ι × ι × ι × ι × ι, (fun (i,j,k,b,l,a) => Q i j * (M k a * X (i,a,l) * M l b * X (j,b,k))) p := by simp only [Matrix.trace, Matrix.diag_apply, Matrix.mul_apply, Finset.sum_mul, Finset.mul_sum, Fintype.sum_prod_type, slice] _ = ∑ p : ι × ι × ι × ι × ι × ι, (fun (i,a,l,j,k,b) => X (i,a,l) * (Q i j * M a k * M l b * X (j,k,b))) p := by apply Fintype.sum_equiv e rintro ⟨i,j,k,b,l,a⟩ dsimp [e] rw [hs k a, hX j b k] ring _ = _ := by simp only [dotProduct, Fintype.sum_prod_type, act_apply, Finset.mul_sum] lemma cube_eq_C {φ : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (z : Space ι) (i j k : ι) : cube φ z (i,j,k) = C φ i z j k := by change C φ k z i j = C φ i z j k rw [C_symm_first hφ k z i j, C_symm_last hφ i z k j] def cross (φ f : Space ι → ℝ) (z : Space ι) : ℝ := ∑ a, ∑ l, ∑ k, pd k (fun y => pulledH φ f y a l) z * pd l (P φ f a k) z def qder (φ f : Space ι → ℝ) (z : Space ι) : ℝ := ∑ i, ∑ j, ∑ d, pd d (fun y => Q φ f y i j) z * ∑ k, (hess φ z)⁻¹ d k * C φ i z j k def cubic (φ f : Space ι → ℝ) (z : Space ι) : ℝ := ∑ i, ∑ j, Q φ f z i j * ((hess φ z)⁻¹ * C φ i z * (hess φ z)⁻¹ * C φ j z).trace lemma cross_eq {φ f : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hf : ContDiff ℝ ∞ f) (z : Space ι) : cross φ f z = (act 1 1 (hess φ z) (cube f (grad φ z))) ⬝ᵥ (act 1 1 (pulledH φ f z) (cube φ z) + act (hess φ z) (hess φ z) 1 (cube f (grad φ z))) := by rw [← derivative_h hφ hf z, ← derivative_P_swap hφ hf z] simp only [dotProduct, Fintype.sum_prod_type, cross] lemma qder_eq {φ f : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hf : ContDiff ℝ ∞ f) (z : Space ι) : qder φ f z = (act 1 (pulledH φ f z * hess φ z) (hess φ z) (cube f (grad φ z)) + act (pulledH φ f z * hess φ z) 1 (hess φ z) (cube f (grad φ z)) + act (pulledH φ f z) (pulledH φ f z) 1 (cube φ z)) ⬝ᵥ act 1 1 (hess φ z)⁻¹ (cube φ z) := by rw [← derivative_Q hφ hf z] simp only [qder, dotProduct, Fintype.sum_prod_type, act₃_apply, cube_eq_C hφ] lemma cubic_eq {φ f : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (z : Space ι) : cubic φ f z = cube φ z ⬝ᵥ act (Q φ f z) (hess φ z)⁻¹ (hess φ z)⁻¹ (cube φ z) := by rw [← cubic_trace (Q φ f z) _ (inverse_transpose hφ z) _ (cube_last hφ z)] have hs (i : ι) : slice (cube φ z) i = C φ i z := by ext j k exact cube_eq_C hφ z i j k change (∑ i, ∑ j, Q φ f z i j * ((hess φ z)⁻¹ * C φ i z * (hess φ z)⁻¹ * C φ j z).trace) = _ simp_rw [hs] theorem pointwise_remainder {φ f : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hf : ContDiff ℝ ∞ f) (hpos : ∀ z, (hess φ z).PosDef) (z : Space ι) : 0 ≤ 2*cross φ f z + qder φ f z + cubic φ f z := by rw [cross_eq hφ hf z, qder_eq hφ hf z, cubic_eq hφ z] apply invariant_remainder_nonneg _ _ _ (hpos z).posSemidef (inverse_transpose hφ z) (MomentCoordinates.hess_transpose hf (grad φ z)) · exact Matrix.mul_nonsing_inv _ (isUnit_iff_ne_zero.mpr (ne_of_gt (hpos z).det_pos)) · exact Matrix.nonsing_inv_mul _ (isUnit_iff_ne_zero.mpr (ne_of_gt (hpos z).det_pos)) · exact cube_swap hf _ · exact cube_cycle hf _ · exact cube_swap hφ _ · exact cube_cycle hφ _ · exact cube_last hφ _ end TensorEstimate namespace MomentTrace open Matrix variable {ι : Type*} [Fintype ι] lemma cyclic_four (A B C D : Matrix ι ι ℝ) : (A*B*C*D).trace = (D*A*B*C).trace := by rw [Matrix.trace_mul_comm (A*B*C) D] simp only [Matrix.mul_assoc] lemma expansion (M B R h : Matrix ι ι ℝ) (hrel : M*B*M=h) : ((B+R)*M*((B+R)*M)).trace = (M*B*M*B).trace + 2*(h*R).trace + (M*R*M*R).trace := by have h₁ : (B*M*B*M).trace = (M*B*M*B).trace := cyclic_four _ _ _ _ have h₂ : (B*M*R*M).trace = (h*R).trace := by rw [cyclic_four, hrel] have h₃ : (R*M*B*M).trace = (h*R).trace := by rw [Matrix.mul_assoc, Matrix.mul_assoc, Matrix.trace_mul_comm] simp only [← Matrix.mul_assoc, hrel] have h₄ : (R*M*R*M).trace = (M*R*M*R).trace := cyclic_four _ _ _ _ simp only [Matrix.add_mul, Matrix.mul_add, Matrix.trace_add, ← Matrix.mul_assoc] rw [h₁, h₂, h₃, h₄] ring variable [DecidableEq ι] lemma inverse_sandwich (T M h : Matrix ι ι ℝ) (hMT : M*T=1) (hTM : T*M=1) : M*(T*h*T)*M=h := by simp only [Matrix.mul_assoc, hTM, Matrix.mul_one] rw [← Matrix.mul_assoc, hMT, Matrix.one_mul] lemma coefficient_identity (T M h H : Matrix ι ι ℝ) (hMT : M*T=1) : (M*(T*h*T)*H*(T*h*T)).trace = ((h*T*h)*(T*H*T)).trace := by calc _ = (h*(T*H*T)*(h*T)).trace := by simp only [← Matrix.mul_assoc, hMT, Matrix.one_mul] _ = _ := Matrix.trace_mul_cycle h (T*H*T) (h*T) lemma base_identity (T M h : Matrix ι ι ℝ) (hMT : M*T=1) (hTM : T*M=1) : (M*(T*h*T)*M*(T*h*T)).trace = ((h*T*h)*T).trace := by rw [inverse_sandwich T M h hMT hTM] simp only [Matrix.mul_assoc] omit [DecidableEq ι] in lemma trace_contract_symm (Q L : Matrix ι ι ℝ) (hL : Lᵀ=L) : (Q*L).trace = ∑ i, ∑ j, Q i j * L i j := by simp only [Matrix.trace, Matrix.diag_apply, Matrix.mul_apply] apply Finset.sum_congr rfl intro i _ apply Finset.sum_congr rfl intro j _ have he := congrArg (fun A : Matrix ι ι ℝ => A i j) hL change L j i = L i j at he rw [he] lemma H_expansion (T M h H : Matrix ι ι ℝ) (hT : Tᵀ=T) (hH : Hᵀ=H) (hMT : M*T=1) (hTM : T*M=1) : (M*(T*h*T)*H*(T*h*T)).trace = (M*(T*h*T)*M*(T*h*T)).trace + ∑ i, ∑ j, (h*T*h) i j * (T*H*T-T) i j := by have hL : (T*H*T-T)ᵀ = T*H*T-T := by simp only [Matrix.transpose_sub, Matrix.transpose_mul, hT, hH, Matrix.mul_assoc] rw [coefficient_identity T M h H hMT, base_identity T M h hMT hTM, ← trace_contract_symm (h*T*h) _ hL, Matrix.mul_sub, Matrix.trace_sub] ring end MomentTrace namespace IntegratedTensor open WeightedCalculus MomentCoordinates MomentDifferential MomentEquation TensorEstimate Matrix variable {ι : Type*} [Fintype ι] [DecidableEq ι] lemma compact_pulledH {φ f : Space ι → ℝ} (hfc : HasCompactSupport f) (Φ : Space ι ≃ₜ Space ι) (hΦ : (Φ : Space ι → Space ι) = grad φ) (i j : ι) : HasCompactSupport (fun z => pulledH φ f z i j) := by change HasCompactSupport ((pd j (pd i f)) ∘ grad φ) rw [← hΦ] exact (compact_D (compact_D hfc (basis i)) (basis j)).comp_homeomorph Φ omit [DecidableEq ι] in lemma compact_matrix_mul_left {A B : Space ι → Matrix ι ι ℝ} (hA : ∀ i j, HasCompactSupport (fun z => A z i j)) (i j : ι) : HasCompactSupport (fun z => (A z * B z) i j) := compact_sum _ (fun k => (hA i k).mul_right) omit [DecidableEq ι] in lemma compact_matrix_mul_right {A B : Space ι → Matrix ι ι ℝ} (hB : ∀ i j, HasCompactSupport (fun z => B z i j)) (i j : ι) : HasCompactSupport (fun z => (A z * B z) i j) := compact_sum _ (fun k => (hB k j).mul_left) omit [DecidableEq ι] in lemma smooth_matrix_trace {A : Space ι → Matrix ι ι ℝ} (hA : ∀ i j, ContDiff ℝ ∞ (fun z => A z i j)) : ContDiff ℝ ∞ (fun z => (A z).trace) := smooth_sum _ (fun i => hA i i) omit [DecidableEq ι] in lemma compact_matrix_trace {A : Space ι → Matrix ι ι ℝ} (hA : ∀ i j, HasCompactSupport (fun z => A z i j)) : HasCompactSupport (fun z => (A z).trace) := compact_sum _ (fun i => hA i i) lemma compact_Q {φ f : Space ι → ℝ} (hfc : HasCompactSupport f) (Φ : Space ι ≃ₜ Space ι) (hΦ : (Φ : Space ι → Space ι) = grad φ) (i j : ι) : HasCompactSupport (fun z => Q φ f z i j) := compact_matrix_mul_right (compact_pulledH hfc Φ hΦ) i j lemma smooth_R {φ f : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hf : ContDiff ℝ ∞ f) (a l : ι) : ContDiff ℝ ∞ (R φ f a l) := smooth_divergence hφ (fun k => smooth_pd (smooth_P hφ hf a k) l) lemma compact_R {φ f : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hf : ContDiff ℝ ∞ f) (hfc : HasCompactSupport f) (Φ : Space ι ≃ₜ Space ι) (hΦ : (Φ : Space ι → Space ι) = grad φ) (a l : ι) : HasCompactSupport (R φ f a l) := compact_divergence (fun k => compact_D (compact_P hφ hf hfc Φ hΦ a k) (basis l)) lemma smooth_cross {φ f : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hf : ContDiff ℝ ∞ f) : ContDiff ℝ ∞ (cross φ f) := smooth_sum _ (fun a => smooth_sum _ (fun l => smooth_sum _ (fun k => (smooth_pd (smooth_pulledH hφ hf a l) k).mul (smooth_pd (smooth_P hφ hf a k) l)))) lemma compact_cross {φ f : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hf : ContDiff ℝ ∞ f) (hfc : HasCompactSupport f) (Φ : Space ι ≃ₜ Space ι) (hΦ : (Φ : Space ι → Space ι) = grad φ) : HasCompactSupport (cross φ f) := compact_sum _ (fun a => compact_sum _ (fun l => compact_sum _ (fun k => (compact_D (compact_P hφ hf hfc Φ hΦ a k) (basis l)).mul_left))) def rmat (φ f : Space ι → ℝ) (z : Space ι) : Matrix ι ι ℝ := fun a l => R φ f a l z def bmat (φ f : Space ι → ℝ) (z : Space ι) : Matrix ι ι ℝ := hess φ z * pulledH φ f z * hess φ z def base (φ f : Space ι → ℝ) (z : Space ι) : ℝ := ((hess φ z)⁻¹ * bmat φ f z * (hess φ z)⁻¹ * bmat φ f z).trace def rterm (φ f : Space ι → ℝ) (z : Space ι) : ℝ := ((hess φ z)⁻¹ * rmat φ f z * (hess φ z)⁻¹ * rmat φ f z).trace def mixed (φ f : Space ι → ℝ) (z : Space ι) : ℝ := (pulledH φ f z * rmat φ f z).trace lemma rmat_symm {φ f : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hf : ContDiff ℝ ∞ f) (z : Space ι) : (rmat φ f z)ᵀ = rmat φ f z := by ext a l exact R_symm hφ hf z l a variable (μ : Measure (Space ι)) [Measure.IsAddHaarMeasure μ] lemma mixed_integral {φ f : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hf : ContDiff ℝ ∞ f) (hfc : HasCompactSupport f) (Φ : Space ι ≃ₜ Space ι) (hΦ : (Φ : Space ι → Space ι) = grad φ) : expectation μ φ (mixed φ f) = expectation μ φ (cross φ f) := by have he : mixed φ f = fun z => ∑ a, ∑ l, pulledH φ f z a l * R φ f a l z := by funext z exact MomentTrace.trace_contract_symm _ _ (rmat_symm hφ hf z) rw [he] rw [expectation_sum μ hφ _ (fun a => (smooth_sum _ (fun l => (smooth_pulledH hφ hf a l).mul (smooth_R hφ hf a l))).continuous) (fun a => compact_sum _ (fun l => (compact_R hφ hf hfc Φ hΦ a l).mul_left))] change _ = expectation μ φ (fun z => ∑ a, ∑ l, ∑ k, pd k (fun y => pulledH φ f y a l) z * pd l (P φ f a k) z) rw [expectation_sum μ hφ _ (fun a => (smooth_sum _ (fun l => smooth_sum _ (fun k => (smooth_pd (smooth_pulledH hφ hf a l) k).mul (smooth_pd (smooth_P hφ hf a k) l)))).continuous) (fun a => compact_sum _ (fun l => compact_sum _ (fun k => (compact_D (compact_P hφ hf hfc Φ hΦ a k) (basis l)).mul_left)))] apply Finset.sum_congr rfl intro a _ rw [expectation_sum μ hφ _ (fun l => ((smooth_pulledH hφ hf a l).mul (smooth_R hφ hf a l)).continuous) (fun l => (compact_R hφ hf hfc Φ hΦ a l).mul_left)] rw [expectation_sum μ hφ _ (fun l => (smooth_sum _ (fun k => (smooth_pd (smooth_pulledH hφ hf a l) k).mul (smooth_pd (smooth_P hφ hf a k) l))).continuous) (fun l => compact_sum _ (fun k => (compact_D (compact_P hφ hf hfc Φ hΦ a k) (basis l)).mul_left))] apply Finset.sum_congr rfl intro l _ rw [expectation_sum μ hφ _ (fun k => ((smooth_pd (smooth_pulledH hφ hf a l) k).mul (smooth_pd (smooth_P hφ hf a k) l)).continuous) (fun k => (compact_D (compact_P hφ hf hfc Φ hΦ a k) (basis l)).mul_left)] exact divergence_adjoint μ basis _ hφ (fun k => smooth_pd (smooth_P hφ hf a k) l) (smooth_pulledH hφ hf a l) (fun k => compact_D (compact_P hφ hf hfc Φ hΦ a k) (basis l)) omit [DecidableEq ι] in theorem integration_by_parts_rightcompact {V f g : Space ι → ℝ} (hV : ContDiff ℝ ∞ V) (hf : ContDiff ℝ ∞ f) (hg : ContDiff ℝ ∞ g) (hgc : HasCompactSupport g) (v : Space ι) : expectation μ V (fun x => D v g x * f x) = expectation μ V (fun x => g x * adjoint V v f x) := by let fw : Space ι → ℝ := fun x => f x * weight V x have hfw : ContDiff ℝ ∞ fw := hf.mul (smooth_weight hV) have hi₁ : Integrable (fun x => D v fw x * g x) μ := ((smooth_D hfw v).continuous.mul hg.continuous).integrable_of_hasCompactSupport hgc.mul_left have hi₂ : Integrable (fun x => fw x * D v g x) μ := (hfw.continuous.mul (smooth_D hg v).continuous).integrable_of_hasCompactSupport (compact_D hgc v).mul_left have hi₃ : Integrable (fun x => fw x * g x) μ := (hfw.continuous.mul hg.continuous).integrable_of_hasCompactSupport hgc.mul_left have hp := integral_mul_fderiv_eq_neg_fderiv_mul_of_integrable hi₁ hi₂ hi₃ (fun x _ => hfw.differentiable (by simp) x) (fun x _ => hg.differentiable (by simp) x) calc _ = ∫ x, fw x * D v g x ∂μ := by apply integral_congr_ae filter_upwards [] with x dsimp [expectation, fw] ring _ = -∫ x, D v fw x * g x ∂μ := hp _ = _ := by rw [← integral_neg] apply integral_congr_ae filter_upwards [] with x dsimp [fw] at * rw [D_mul (hf.differentiable (by simp)) ((smooth_weight hV).differentiable (by simp)), D_weight hV v] dsimp [adjoint] ring def L (φ : Space ι → ℝ) (i j d : ι) (z : Space ι) : ℝ := ∑ k, (hess φ z)⁻¹ d k * C φ i z j k lemma smooth_L {φ : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hne : ∀ z, (hess φ z).det ≠ 0) (i j d : ι) : ContDiff ℝ ∞ (L φ i j d) := smooth_sum _ (fun k => (smooth_inverse_entry (smooth_hess hφ) hne d k).mul (smooth_C hφ i j k)) lemma smooth_qder {φ f : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hf : ContDiff ℝ ∞ f) (hne : ∀ z, (hess φ z).det ≠ 0) : ContDiff ℝ ∞ (qder φ f) := smooth_sum _ (fun i => smooth_sum _ (fun j => smooth_sum _ (fun d => (smooth_pd (smooth_Q hφ hf i j) d).mul (smooth_L hφ hne i j d)))) lemma compact_qder {φ f : Space ι → ℝ} (hfc : HasCompactSupport f) (Φ : Space ι ≃ₜ Space ι) (hΦ : (Φ : Space ι → Space ι) = grad φ) : HasCompactSupport (qder φ f) := compact_sum _ (fun i => compact_sum _ (fun j => compact_sum _ (fun d => (compact_D (compact_Q hfc Φ hΦ i j) (basis d)).mul_right))) lemma smooth_cubic {φ f : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hf : ContDiff ℝ ∞ f) (hne : ∀ z, (hess φ z).det ≠ 0) : ContDiff ℝ ∞ (cubic φ f) := by have hM := smooth_inverse_entry (smooth_hess hφ) hne exact smooth_sum _ (fun i => smooth_sum _ (fun j => (smooth_Q hφ hf i j).mul (smooth_matrix_trace (smooth_matrix_product (smooth_matrix_product (smooth_matrix_product hM (smooth_C hφ i)) hM) (smooth_C hφ j))))) lemma compact_cubic {φ f : Space ι → ℝ} (hfc : HasCompactSupport f) (Φ : Space ι ≃ₜ Space ι) (hΦ : (Φ : Space ι → Space ι) = grad φ) : HasCompactSupport (cubic φ f) := compact_sum _ (fun i => compact_sum _ (fun j => (compact_Q hfc Φ hΦ i j).mul_right)) def divterm (φ f : Space ι → ℝ) (z : Space ι) : ℝ := ∑ i, ∑ j, Q φ f z i j * divergence φ basis (L φ i j) z lemma smooth_divterm {φ f : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hf : ContDiff ℝ ∞ f) (hne : ∀ z, (hess φ z).det ≠ 0) : ContDiff ℝ ∞ (divterm φ f) := smooth_sum _ (fun i => smooth_sum _ (fun j => (smooth_Q hφ hf i j).mul (smooth_divergence hφ (smooth_L hφ hne i j)))) lemma compact_divterm {φ f : Space ι → ℝ} (hfc : HasCompactSupport f) (Φ : Space ι ≃ₜ Space ι) (hΦ : (Φ : Space ι → Space ι) = grad φ) : HasCompactSupport (divterm φ f) := compact_sum _ (fun i => compact_sum _ (fun j => (compact_Q hfc Φ hΦ i j).mul_right)) lemma divterm_integral {φ f : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hf : ContDiff ℝ ∞ f) (hne : ∀ z, (hess φ z).det ≠ 0) (hfc : HasCompactSupport f) (Φ : Space ι ≃ₜ Space ι) (hΦ : (Φ : Space ι → Space ι) = grad φ) : expectation μ φ (divterm φ f) = expectation μ φ (qder φ f) := by have he : divterm φ f = fun z => ∑ i, ∑ j, ∑ d, Q φ f z i j * adjoint φ (basis d) (L φ i j d) z := by funext z simp only [divterm, divergence, Finset.mul_sum] rw [he] change _ = expectation μ φ (fun z => ∑ i, ∑ j, ∑ d, pd d (fun y => Q φ f y i j) z * L φ i j d z) have hl (i j d : ι) : ContDiff ℝ ∞ (fun z => Q φ f z i j * adjoint φ (basis d) (L φ i j d) z) := (smooth_Q hφ hf i j).mul (smooth_adjoint hφ (smooth_L hφ hne i j d) (basis d)) have hr (i j d : ι) : ContDiff ℝ ∞ (fun z => pd d (fun y => Q φ f y i j) z * L φ i j d z) := (smooth_pd (smooth_Q hφ hf i j) d).mul (smooth_L hφ hne i j d) rw [expectation_sum μ hφ _ (fun i => (smooth_sum _ (fun j => smooth_sum _ (hl i j))).continuous) (fun i => compact_sum _ (fun j => compact_sum _ (fun _ => (compact_Q hfc Φ hΦ i j).mul_right)))] rw [expectation_sum μ hφ _ (fun i => (smooth_sum _ (fun j => smooth_sum _ (hr i j))).continuous) (fun i => compact_sum _ (fun j => compact_sum _ (fun d => (compact_D (compact_Q hfc Φ hΦ i j) (basis d)).mul_right)))] apply Finset.sum_congr rfl intro i _ rw [expectation_sum μ hφ _ (fun j => (smooth_sum _ (hl i j)).continuous) (fun j => compact_sum _ (fun _ => (compact_Q hfc Φ hΦ i j).mul_right))] rw [expectation_sum μ hφ _ (fun j => (smooth_sum _ (hr i j)).continuous) (fun j => compact_sum _ (fun d => (compact_D (compact_Q hfc Φ hΦ i j) (basis d)).mul_right))] apply Finset.sum_congr rfl intro j _ rw [expectation_sum μ hφ _ (fun d => (hl i j d).continuous) (fun _ => (compact_Q hfc Φ hΦ i j).mul_right)] rw [expectation_sum μ hφ _ (fun d => (hr i j d).continuous) (fun d => (compact_D (compact_Q hfc Φ hΦ i j) (basis d)).mul_right)] apply Finset.sum_congr rfl intro d _ exact (integration_by_parts_rightcompact μ hφ (smooth_L hφ hne i j d) (smooth_Q hφ hf i j) (compact_Q hfc Φ hΦ i j) (basis d)).symm lemma smooth_bmat {φ f : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hf : ContDiff ℝ ∞ f) (i j : ι) : ContDiff ℝ ∞ (fun z => bmat φ f z i j) := smooth_matrix_product (smooth_matrix_product (smooth_hess hφ) (smooth_pulledH hφ hf)) (smooth_hess hφ) i j lemma compact_bmat {φ f : Space ι → ℝ} (hfc : HasCompactSupport f) (Φ : Space ι ≃ₜ Space ι) (hΦ : (Φ : Space ι → Space ι) = grad φ) (i j : ι) : HasCompactSupport (fun z => bmat φ f z i j) := compact_matrix_mul_left (compact_matrix_mul_right (compact_pulledH hfc Φ hΦ)) i j lemma smooth_base {φ f : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hf : ContDiff ℝ ∞ f) (hne : ∀ z, (hess φ z).det ≠ 0) : ContDiff ℝ ∞ (base φ f) := by have hM := smooth_inverse_entry (smooth_hess hφ) hne exact smooth_matrix_trace (smooth_matrix_product (smooth_matrix_product (smooth_matrix_product hM (smooth_bmat hφ hf)) hM) (smooth_bmat hφ hf)) lemma compact_base {φ f : Space ι → ℝ} (hfc : HasCompactSupport f) (Φ : Space ι ≃ₜ Space ι) (hΦ : (Φ : Space ι → Space ι) = grad φ) : HasCompactSupport (base φ f) := compact_matrix_trace (compact_matrix_mul_right (compact_bmat hfc Φ hΦ)) lemma smooth_rterm {φ f : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hf : ContDiff ℝ ∞ f) (hne : ∀ z, (hess φ z).det ≠ 0) : ContDiff ℝ ∞ (rterm φ f) := by have hM := smooth_inverse_entry (smooth_hess hφ) hne exact smooth_matrix_trace (smooth_matrix_product (smooth_matrix_product (smooth_matrix_product hM (smooth_R hφ hf)) hM) (smooth_R hφ hf)) lemma compact_rterm {φ f : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hf : ContDiff ℝ ∞ f) (hfc : HasCompactSupport f) (Φ : Space ι ≃ₜ Space ι) (hΦ : (Φ : Space ι → Space ι) = grad φ) : HasCompactSupport (rterm φ f) := compact_matrix_trace (compact_matrix_mul_right (compact_R hφ hf hfc Φ hΦ)) lemma smooth_mixed {φ f : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hf : ContDiff ℝ ∞ f) : ContDiff ℝ ∞ (mixed φ f) := smooth_matrix_trace (smooth_matrix_product (smooth_pulledH hφ hf) (smooth_R hφ hf)) lemma compact_mixed {φ f : Space ι → ℝ} (hfc : HasCompactSupport f) (Φ : Space ι ≃ₜ Space ι) (hΦ : (Φ : Space ι → Space ι) = grad φ) : HasCompactSupport (mixed φ f) := compact_matrix_trace (compact_matrix_mul_left (compact_pulledH hfc Φ hΦ)) def jacW (φ f : Space ι → ℝ) (z : Space ι) : Matrix ι ι ℝ := fun a l => pd l (W φ f a) z def traceL (φ f : Space ι → ℝ) (z : Space ι) : ℝ := (jacW φ f z * (hess φ z)⁻¹ * (jacW φ f z * (hess φ z)⁻¹)).trace def traceH (φ V f : Space ι → ℝ) (z : Space ι) : ℝ := ((hess φ z)⁻¹ * bmat φ f z * hess V (grad φ z) * bmat φ f z).trace lemma traceL_expansion {φ f : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hf : ContDiff ℝ ∞ f) (hne : ∀ z, (hess φ z).det ≠ 0) (z : Space ι) : traceL φ f z = base φ f z + 2*mixed φ f z + rterm φ f z := by have he : jacW φ f z = bmat φ f z + rmat φ f z := by ext a l change pd l (W φ f a) z = _ rw [W_derivative hφ hf a l] rfl have hrel : (hess φ z)⁻¹ * bmat φ f z * (hess φ z)⁻¹ = pulledH φ f z := MomentTrace.inverse_sandwich _ _ _ (Matrix.nonsing_inv_mul _ (isUnit_iff_ne_zero.mpr (hne z))) (Matrix.mul_nonsing_inv _ (isUnit_iff_ne_zero.mpr (hne z))) unfold traceL rw [he, MomentTrace.expansion _ _ _ _ hrel] rfl lemma traceH_expansion {φ V f : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hV : ContDiff ℝ ∞ V) (hne : ∀ z, (hess φ z).det ≠ 0) {c : ℝ} (heq : ∀ z, Real.log (hess φ z).det = V (grad φ z) + c - φ z) (z : Space ι) : traceH φ V f z = base φ f z - divterm φ f z - cubic φ f z := by have ht (i j : ι) : (hess φ z * hess V (grad φ z) * hess φ z - hess φ z) i j = -divergence φ basis (L φ i j) z - ((hess φ z)⁻¹ * C φ i z * (hess φ z)⁻¹ * C φ j z).trace := by rw [twice_moment hφ hV hne heq] congr 1 change (∑ d, (pd d (L φ i j d) z - pd d φ z * L φ i j d z)) = -(∑ d, (pd d φ z * L φ i j d z - pd d (L φ i j d) z)) rw [← Finset.sum_neg_distrib] apply Finset.sum_congr rfl intro d _ ring unfold traceH bmat rw [MomentTrace.H_expansion _ _ _ _ (MomentCoordinates.hess_transpose hφ z) (MomentCoordinates.hess_transpose hV (grad φ z)) (Matrix.nonsing_inv_mul _ (isUnit_iff_ne_zero.mpr (hne z))) (Matrix.mul_nonsing_inv _ (isUnit_iff_ne_zero.mpr (hne z)))] simp only [ht, mul_sub, mul_neg, Finset.sum_sub_distrib, Finset.sum_neg_distrib] change base φ f z + (-divterm φ f z - cubic φ f z) = _ ring lemma rterm_nonneg {φ f : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hf : ContDiff ℝ ∞ f) (hpos : ∀ z, (hess φ z).PosDef) (z : Space ι) : 0 ≤ rterm φ f z := MomentMatrix.trace_conjugate_nonneg (hpos z).inv.posSemidef (rmat_symm hφ hf z) omit [DecidableEq ι] [Fintype ι] [Measure.IsAddHaarMeasure μ] in lemma expectation_const_mul (V F : Space ι → ℝ) (a : ℝ) : expectation μ V (fun z => a*F z) = a * expectation μ V F := by simp only [expectation, mul_assoc, integral_const_mul] omit [DecidableEq ι] in lemma expectation_sub {V F G : Space ι → ℝ} (hV : ContDiff ℝ ∞ V) (hF : Continuous F) (hG : Continuous G) (hFc : HasCompactSupport F) (hGc : HasCompactSupport G) : expectation μ V (fun z => F z-G z) = expectation μ V F - expectation μ V G := by simp only [expectation, sub_mul] exact integral_sub (integrable_weighted μ hV hF hFc) (integrable_weighted μ hV hG hGc) omit [DecidableEq ι] [Fintype ι] [Measure.IsAddHaarMeasure μ] in lemma expectation_nonneg {V F : Space ι → ℝ} (hF : ∀ z, 0 ≤ F z) : 0 ≤ expectation μ V F := integral_nonneg (fun z => mul_nonneg (hF z) (le_of_lt (Real.exp_pos _))) theorem tensor_estimate {φ V f : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hV : ContDiff ℝ ∞ V) (hf : ContDiff ℝ ∞ f) (hfc : HasCompactSupport f) (hpos : ∀ z, (hess φ z).PosDef) {c : ℝ} (heq : ∀ z, Real.log (hess φ z).det = V (grad φ z) + c - φ z) (Φ : Space ι ≃ₜ Space ι) (hΦ : (Φ : Space ι → Space ι) = grad φ) : expectation μ φ (traceH φ V f) ≤ expectation μ φ (traceL φ f) := by have hne (z : Space ι) := ne_of_gt (hpos z).det_pos have sbase := (smooth_base hφ hf hne).continuous have cbase := compact_base hfc Φ hΦ have smixed := (smooth_mixed hφ hf).continuous have cmixed := compact_mixed hfc Φ hΦ have sr := (smooth_rterm hφ hf hne).continuous have cr := compact_rterm hφ hf hfc Φ hΦ have sd := (smooth_divterm hφ hf hne).continuous have cd := compact_divterm hfc Φ hΦ have sc := (smooth_cubic hφ hf hne).continuous have cc := compact_cubic hfc Φ hΦ have sx := (smooth_cross hφ hf).continuous have cx := compact_cross hφ hf hfc Φ hΦ have sq := (smooth_qder hφ hf hne).continuous have cq := compact_qder hfc Φ hΦ have hleft : expectation μ φ (traceL φ f) = expectation μ φ (base φ f) + 2*expectation μ φ (cross φ f) + expectation μ φ (rterm φ f) := by have he : traceL φ f = fun z => base φ f z + 2*mixed φ f z + rterm φ f z := funext (traceL_expansion hφ hf hne) rw [he, expectation_add μ hφ (f := fun z => base φ f z + 2*mixed φ f z) (g := rterm φ f) (sbase.add (continuous_const.mul smixed)) sr (cbase.add cmixed.mul_left) cr, expectation_add μ hφ (f := base φ f) (g := fun z => 2*mixed φ f z) sbase (continuous_const.mul smixed) cbase cmixed.mul_left, expectation_const_mul, mixed_integral μ hφ hf hfc Φ hΦ] have hright : expectation μ φ (traceH φ V f) = expectation μ φ (base φ f) - expectation μ φ (qder φ f) - expectation μ φ (cubic φ f) := by have he : traceH φ V f = fun z => base φ f z - divterm φ f z - cubic φ f z := funext (traceH_expansion hφ hV hne heq) rw [he, expectation_sub μ hφ (F := fun z => base φ f z-divterm φ f z) (G := cubic φ f) (sbase.sub sd) sc (cbase.sub cd) cc, expectation_sub μ hφ sbase sd cbase cd, divterm_integral μ hφ hf hne hfc Φ hΦ] have hr := expectation_nonneg μ (V := φ) (rterm_nonneg hφ hf hpos) have hp := expectation_nonneg μ (V := φ) (TensorEstimate.pointwise_remainder hφ hf hpos) rw [expectation_add μ hφ (f := fun z => 2*cross φ f z+qder φ f z) (g := cubic φ f) ((continuous_const.mul sx).add sq) sc (cx.mul_left.add cq) cc, expectation_add μ hφ (f := fun z => 2*cross φ f z) (g := qder φ f) (continuous_const.mul sx) sq cx.mul_left cq, expectation_const_mul] at hp rw [hleft, hright] linarith end IntegratedTensor namespace FullTensor open WeightedCalculus MomentCoordinates MomentDifferential MomentEquation IntegratedTensor TargetCoordinates Matrix variable {ι : Type*} [Fintype ι] [DecidableEq ι] def wField (Φ : Space ι ≃ₜ Space ι) (φ f : Space ι → ℝ) (a : ι) : Space ι → ℝ := target Φ (W φ f a) def bField (Φ : Space ι ≃ₜ Space ι) (φ f : Space ι → ℝ) (x : Space ι) : Matrix ι ι ℝ := bmat φ f (Φ.symm x) def mField (Φ : Space ι ≃ₜ Space ι) (φ : Space ι → ℝ) (x : Space ι) : Matrix ι ι ℝ := (hess φ (Φ.symm x))⁻¹ def jacobian (Y : ι → Space ι → ℝ) (x : Space ι) : Matrix ι ι ℝ := fun a l => pd l (Y a) x def squareTrace (Y : ι → Space ι → ℝ) (x : Space ι) : ℝ := (jacobian Y x * jacobian Y x).trace def hEnergy (Φ : Space ι ≃ₜ Space ι) (φ V f : Space ι → ℝ) (x : Space ι) : ℝ := (mField Φ φ x * bField Φ φ f x * hess V x * bField Φ φ f x).trace def wEnergy (V : Space ι → ℝ) (Y : ι → Space ι → ℝ) (x : Space ι) : ℝ := ∑ j, ∑ i, hess V x i j * Y i x * Y j x lemma jacobian_pull {φ f : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hf : ContDiff ℝ ∞ f) (hne : ∀ z, (hess φ z).det ≠ 0) (Φ : Space ι ≃ₜ Space ι) (hΦ : (Φ : Space ι → Space ι) = grad φ) (hInv : ContDiff ℝ ∞ (Φ.symm : Space ι → Space ι)) (z : Space ι) : jacobian (wField Φ φ f) (grad φ z) = jacW φ f z * (hess φ z)⁻¹ := by ext a l change pd l (target Φ (W φ f a)) (grad φ z) = _ rw [pd_target hφ (smooth_W hφ hf a) hne Φ hΦ hInv] change (∑ k, (hess φ z)⁻¹ l k * pd k (W φ f a) z) = ∑ k, pd k (W φ f a) z * (hess φ z)⁻¹ k l apply Finset.sum_congr rfl intro k _ rw [inverse_symm hφ z l k] ring lemma squareTrace_pull {φ f : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hf : ContDiff ℝ ∞ f) (hne : ∀ z, (hess φ z).det ≠ 0) (Φ : Space ι ≃ₜ Space ι) (hΦ : (Φ : Space ι → Space ι) = grad φ) (hInv : ContDiff ℝ ∞ (Φ.symm : Space ι → Space ι)) : squareTrace (wField Φ φ f) ∘ grad φ = traceL φ f := by funext z change (jacobian (wField Φ φ f) (grad φ z) * jacobian (wField Φ φ f) (grad φ z)).trace = _ rw [jacobian_pull hφ hf hne Φ hΦ hInv] rfl lemma hEnergy_pull {φ V f : Space ι → ℝ} (Φ : Space ι ≃ₜ Space ι) (hΦ : (Φ : Space ι → Space ι) = grad φ) : hEnergy Φ φ V f ∘ grad φ = traceH φ V f := by funext z have he : Φ.symm (grad φ z) = z := by rw [← hΦ]; exact Φ.symm_apply_apply z simp only [Function.comp_apply, hEnergy, mField, bField, he, traceH] lemma wField_divergence {φ V f : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hV : ContDiff ℝ ∞ V) (hf : ContDiff ℝ ∞ f) (hne : ∀ z, (hess φ z).det ≠ 0) {c : ℝ} (heq : ∀ z, Real.log (hess φ z).det = V (grad φ z) + c - φ z) (Φ : Space ι ≃ₜ Space ι) (hΦ : (Φ : Space ι → Space ι) = grad φ) (hInv : ContDiff ℝ ∞ (Φ.symm : Space ι → Space ι)) (a : ι) : divergence V basis (fun j x => bField Φ φ f x a j) = wField Φ φ f a := by funext x obtain ⟨z, rfl⟩ := Φ.surjective x rw [hΦ] have hr := row_adjoint hφ hV hne heq Φ hΦ hInv (P φ f a) (smooth_P hφ hf a) z change divergence V basis (fun j => target Φ (fun y => ∑ k, P φ f a k y * hess φ y k j)) (grad φ z) = target Φ (W φ f a) (grad φ z) rw [hr, target_apply Φ hΦ] rfl variable (μ : Measure (Space ι)) [Measure.IsAddHaarMeasure μ] lemma bochner_trace {V : Space ι → ℝ} (hV : ContDiff ℝ ∞ V) (Y : ι → Space ι → ℝ) (hY : ∀ i, ContDiff ℝ ∞ (Y i)) (hYc : ∀ i, HasCompactSupport (Y i)) : expectation μ V (fun x => (divergence V basis Y x)^2) = expectation μ V (wEnergy V Y) + expectation μ V (squareTrace Y) := by have h₁ : expectation μ V (wEnergy V Y) = ∑ j, ∑ i, expectation μ V (fun x => hess V x i j * Y i x * Y j x) := by unfold wEnergy rw [expectation_sum μ hV _ (fun j => (smooth_sum _ (fun i => ((smooth_hess hV i j).mul (hY i)).mul (hY j))).continuous) (fun j => compact_sum _ (fun _ => (hYc j).mul_left))] apply Finset.sum_congr rfl intro j _ exact expectation_sum μ hV _ (fun i => (((smooth_hess hV i j).mul (hY i)).mul (hY j)).continuous) (fun _ => (hYc j).mul_left) have h₂ : expectation μ V (squareTrace Y) = ∑ j, ∑ i, expectation μ V (fun x => pd i (Y j) x * pd j (Y i) x) := by have he : squareTrace Y = fun x => ∑ j, ∑ i, pd i (Y j) x * pd j (Y i) x := rfl rw [he, expectation_sum μ hV _ (fun j => (smooth_sum _ (fun i => (smooth_pd (hY j) i).mul (smooth_pd (hY i) j))).continuous) (fun j => compact_sum _ (fun i => (compact_D (hYc j) (basis i)).mul_right))] apply Finset.sum_congr rfl intro j _ exact expectation_sum μ hV _ (fun i => ((smooth_pd (hY j) i).mul (smooth_pd (hY i) j)).continuous) (fun i => (compact_D (hYc j) (basis i)).mul_right) rw [h₁, h₂] exact bochner μ basis Y hV hY hYc theorem tensor_energy {φ V f : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hV : ContDiff ℝ ∞ V) (hf : ContDiff ℝ ∞ f) (hfc : HasCompactSupport f) (hpos : ∀ z, (hess φ z).PosDef) {c Z : ℝ} (hZ : 0 < Z) (heq : ∀ z, Real.log (hess φ z).det = V (grad φ z) + c - φ z) (Φ : Space ι ≃ₜ Space ι) (hΦ : (Φ : Space ι → Space ι) = grad φ) (hInv : ContDiff ℝ ∞ (Φ.symm : Space ι → Space ι)) (hmap : Measure.map (grad φ) (sourceMeasure μ φ) = targetMeasure μ V Z) : normalizedE μ V Z (hEnergy Φ φ V f) ≤ normalizedE μ V Z (squareTrace (wField Φ φ f)) ∧ normalizedE μ V Z (hEnergy Φ φ V f) + normalizedE μ V Z (wEnergy V (wField Φ φ f)) ≤ normalizedE μ V Z (fun x => (divergence V basis (wField Φ φ f) x)^2) := by have ht := IntegratedTensor.tensor_estimate μ hφ hV hf hfc hpos heq Φ hΦ have hne (z : Space ι) := ne_of_gt (hpos z).det_pos rw [← hEnergy_pull (V := V) (f := f) Φ hΦ, ← squareTrace_pull hφ hf hne Φ hΦ hInv, expectation_transport μ hφ hV hZ Φ hΦ hmap, expectation_transport μ hφ hV hZ Φ hΦ hmap] at ht refine ⟨ht, ?_⟩ have hs (i : ι) : ContDiff ℝ ∞ (wField Φ φ f i) := smooth_target hInv (smooth_W hφ hf i) have hc (i : ι) : HasCompactSupport (wField Φ φ f i) := (compact_W hφ hf hfc Φ hΦ i).comp_homeomorph Φ.symm have hb := bochner_trace μ hV (wField Φ φ f) hs hc have hb' : normalizedE μ V Z (fun x => (divergence V basis (wField Φ φ f) x)^2) = normalizedE μ V Z (wEnergy V (wField Φ φ f)) + normalizedE μ V Z (squareTrace (wField Φ φ f)) := by unfold normalizedE rw [hb, add_div] rw [hb'] linarith end FullTensor namespace DualEnergy open MeasureTheory WeightedCalculus MomentCoordinates MomentDifferential MomentEquation IntegratedTensor TargetCoordinates FullTensor MomentMatrix TensorEstimate section variable {ι : Type*} [Fintype ι] [DecidableEq ι] variable (μ : Measure (Space ι)) [Measure.IsAddHaarMeasure μ] lemma integral_divergence {V g : Space ι → ℝ} (hV : ContDiff ℝ ∞ V) {Z : ℝ} (hZ : 0 < Z) (Y : ι → Space ι → ℝ) (hY : ∀ i, ContDiff ℝ ∞ (Y i)) (hYc : ∀ i, HasCompactSupport (Y i)) (hg : ContDiff ℝ ∞ g) : (∫ x, g x * divergence V basis Y x ∂targetMeasure μ V Z) = ∑ i, ∫ x, pd i g x * Y i x ∂targetMeasure μ V Z := by simp only [target_integral μ hV hZ, normalizedE] rw [divergence_adjoint μ basis Y hV hY hg hYc, Finset.sum_div] rfl lemma smooth_bField {φ f : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hf : ContDiff ℝ ∞ f) (Φ : Space ι ≃ₜ Space ι) (hInv : ContDiff ℝ ∞ (Φ.symm : Space ι → Space ι)) (i j : ι) : ContDiff ℝ ∞ (fun x => bField Φ φ f x i j) := (smooth_bmat hφ hf i j).comp hInv lemma compact_bField {φ f : Space ι → ℝ} (hfc : HasCompactSupport f) (Φ : Space ι ≃ₜ Space ι) (hΦ : (Φ : Space ι → Space ι) = grad φ) (i j : ι) : HasCompactSupport (fun x => bField Φ φ f x i j) := (compact_bmat hfc Φ hΦ i j).comp_homeomorph Φ.symm lemma smooth_mField {φ : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hpos : ∀ z, (hess φ z).PosDef) (Φ : Space ι ≃ₜ Space ι) (hInv : ContDiff ℝ ∞ (Φ.symm : Space ι → Space ι)) (i j : ι) : ContDiff ℝ ∞ (fun x => mField Φ φ x i j) := (smooth_inverse_entry (smooth_hess hφ) (fun z => ne_of_gt (hpos z).det_pos) i j).comp hInv lemma bField_symm {φ f : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hf : ContDiff ℝ ∞ f) (Φ : Space ι ≃ₜ Space ι) (x : Space ι) : (bField Φ φ f x)ᵀ = bField Φ φ f x := by unfold bField bmat pulledH simp only [Matrix.transpose_mul, Matrix.mul_assoc, Function.comp_apply] rw [MomentEquation.hess_transpose hφ, MomentEquation.hess_transpose hf] lemma pairings {φ V f ψ : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hV : ContDiff ℝ ∞ V) (hf : ContDiff ℝ ∞ f) (hfc : HasCompactSupport f) (hψ : ContDiff ℝ ∞ ψ) (hne : ∀ z, (hess φ z).det ≠ 0) {c Z : ℝ} (hZ : 0 < Z) [IsFiniteMeasure (targetMeasure μ V Z)] (heq : ∀ z, Real.log (hess φ z).det = V (grad φ z)+c-φ z) (Φ : Space ι ≃ₜ Space ι) (hΦ : (Φ : Space ι → Space ι) = grad φ) (hInv : ContDiff ℝ ∞ (Φ.symm : Space ι → Space ι)) : (∫ x, ψ x * divergence V basis (wField Φ φ f) x ∂targetMeasure μ V Z) = (∫ x, ∑ i, pd i ψ x*wField Φ φ f i x ∂targetMeasure μ V Z) ∧ (∫ x, ψ x * divergence V basis (wField Φ φ f) x ∂targetMeasure μ V Z) = ∫ x, (bField Φ φ f x * hess ψ x).trace ∂targetMeasure μ V Z := by have hW i : ContDiff ℝ ∞ (wField Φ φ f i) := smooth_target hInv (smooth_W hφ hf i) have hWc i : HasCompactSupport (wField Φ φ f i) := (compact_W hφ hf hfc Φ hΦ i).comp_homeomorph Φ.symm have hi i : Integrable (fun x => pd i ψ x*wField Φ φ f i x) (targetMeasure μ V Z) := ((smooth_D hψ (basis i)).mul (hW i)).continuous.integrable_of_hasCompactSupport (hWc i).mul_left have he := integral_divergence μ hV hZ (wField Φ φ f) hW hWc hψ refine ⟨he.trans (integral_finsetSum _ (fun i _ => hi i)).symm, ?_⟩ rw [he] have hr (i : ι) : (∫ x, pd i ψ x*wField Φ φ f i x ∂targetMeasure μ V Z) = ∑ j, ∫ x, hess ψ x i j*bField Φ φ f x i j ∂targetMeasure μ V Z := by rw [← wField_divergence hφ hV hf hne heq Φ hΦ hInv i] exact integral_divergence μ hV hZ _ (smooth_bField hφ hf Φ hInv i) (compact_bField hfc Φ hΦ i) (smooth_D hψ (basis i)) simp_rw [hr] have hij (i j : ι) : Integrable (fun x => hess ψ x i j*bField Φ φ f x i j) (targetMeasure μ V Z) := ((smooth_hess hψ i j).mul (smooth_bField hφ hf Φ hInv i j)).continuous.integrable_of_hasCompactSupport (compact_bField hfc Φ hΦ i j).mul_left have hti : (fun x => (bField Φ φ f x*hess ψ x).trace) = fun x => ∑ i, ∑ j, hess ψ x i j*bField Φ φ f x i j := by funext x simp only [Matrix.trace,Matrix.diag,Matrix.mul_apply] apply Finset.sum_congr rfl intro i _ apply Finset.sum_congr rfl intro j _ rw [hess_symm hψ x j i] ring rw [hti,integral_finsetSum _ (fun i _ => integrable_finsetSum _ (fun j _ => hij i j))] apply Finset.sum_congr rfl intro i _ exact (integral_finsetSum _ (fun j _ => hij i j)).symm end section variable {ι : Type*} [Fintype ι] [DecidableEq ι] variable (μ : Measure (Space ι)) [Measure.IsAddHaarMeasure μ] def tau (Φ : Space ι ≃ₜ Space ι) (φ : Space ι → ℝ) (x : Space ι) : Matrix ι ι ℝ := hess φ (Φ.symm x) omit [Measure.IsAddHaarMeasure μ] in lemma trace_pair_integrable {φ V f ψ : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hf : ContDiff ℝ ∞ f) (hfc : HasCompactSupport f) (hψ : ContDiff ℝ ∞ ψ) {Z : ℝ} [IsFiniteMeasure (targetMeasure μ V Z)] (Φ : Space ι ≃ₜ Space ι) (hΦ : (Φ : Space ι → Space ι) = grad φ) (hInv : ContDiff ℝ ∞ (Φ.symm : Space ι → Space ι)) : Integrable (fun x => (bField Φ φ f x*hess ψ x).trace) (targetMeasure μ V Z) := by apply (smooth_matrix_trace (smooth_matrix_product (smooth_bField hφ hf Φ hInv) (smooth_hess hψ))).continuous.integrable_of_hasCompactSupport exact compact_matrix_trace (compact_matrix_mul_left (compact_bField hfc Φ hΦ)) omit [Measure.IsAddHaarMeasure μ] in lemma first_energy_integrable {φ V f ψ : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hf : ContDiff ℝ ∞ f) (hfc : HasCompactSupport f) (hψ : ContDiff ℝ ∞ ψ) (hpos : ∀ z, (hess φ z).PosDef) {Z : ℝ} [IsFiniteMeasure (targetMeasure μ V Z)] (Φ : Space ι ≃ₜ Space ι) (hΦ : (Φ : Space ι → Space ι) = grad φ) (hInv : ContDiff ℝ ∞ (Φ.symm : Space ι → Space ι)) : Integrable (hEnergy Φ φ ψ f) (targetMeasure μ V Z) := by apply (smooth_matrix_trace (smooth_matrix_product (smooth_matrix_product (smooth_matrix_product (smooth_mField hφ hpos Φ hInv) (smooth_bField hφ hf Φ hInv)) (smooth_hess hψ)) (smooth_bField hφ hf Φ hInv))).continuous.integrable_of_hasCompactSupport exact compact_matrix_trace (compact_matrix_mul_right (compact_bField hfc Φ hΦ)) omit [Measure.IsAddHaarMeasure μ] in lemma second_energy_integrable {φ V f ψ : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hf : ContDiff ℝ ∞ f) (hfc : HasCompactSupport f) (hψ : ContDiff ℝ ∞ ψ) {Z : ℝ} [IsFiniteMeasure (targetMeasure μ V Z)] (Φ : Space ι ≃ₜ Space ι) (hΦ : (Φ : Space ι → Space ι) = grad φ) (hInv : ContDiff ℝ ∞ (Φ.symm : Space ι → Space ι)) : Integrable (wEnergy ψ (wField Φ φ f)) (targetMeasure μ V Z) := by apply (smooth_sum _ (fun j => smooth_sum _ (fun i => ((smooth_hess hψ i j).mul (smooth_target hInv (smooth_W hφ hf i))).mul (smooth_target hInv (smooth_W hφ hf j))))).continuous.integrable_of_hasCompactSupport exact compact_sum _ (fun j => compact_sum _ (fun _ => ((compact_W hφ hf hfc Φ hΦ j).comp_homeomorph Φ.symm).mul_left)) lemma first_cs {φ V f ψ : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hV : ContDiff ℝ ∞ V) (hf : ContDiff ℝ ∞ f) (hfc : HasCompactSupport f) (hψ : ContDiff ℝ ∞ ψ) (hpos : ∀ z, (hess φ z).PosDef) (hψpos : ∀ x, (hess ψ x).PosSemidef) {c Z : ℝ} (hZ : 0 < Z) [IsFiniteMeasure (targetMeasure μ V Z)] (heq : ∀ z, Real.log (hess φ z).det = V (grad φ z)+c-φ z) (Φ : Space ι ≃ₜ Space ι) (hΦ : (Φ : Space ι → Space ι) = grad φ) (hInv : ContDiff ℝ ∞ (Φ.symm : Space ι → Space ι)) (hmi : Integrable (fun x => (tau Φ φ x*hess ψ x).trace) (targetMeasure μ V Z)) : (∫ x, ψ x*divergence V basis (wField Φ φ f) x ∂targetMeasure μ V Z)^2 ≤ (∫ x, (tau Φ φ x*hess ψ x).trace ∂targetMeasure μ V Z) * (∫ x, hEnergy Φ φ ψ f x ∂targetMeasure μ V Z) := by rw [(pairings μ hφ hV hf hfc hψ (fun z => ne_of_gt (hpos z).det_pos) hZ heq Φ hΦ hInv).2] apply integral_trace_cs (targetMeasure μ V Z) (M:=mField Φ φ) (T:=tau Φ φ) (H:=hess ψ) (B:=bField Φ φ f) (fun x => (hpos (Φ.symm x)).inv.posSemidef) hψpos (fun x => MomentEquation.hess_transpose hφ (Φ.symm x)) (bField_symm hφ hf Φ) · intro x exact Matrix.nonsing_inv_mul _ (isUnit_iff_ne_zero.mpr (ne_of_gt (hpos (Φ.symm x)).det_pos)) · intro x exact Matrix.mul_nonsing_inv _ (isUnit_iff_ne_zero.mpr (ne_of_gt (hpos (Φ.symm x)).det_pos)) · exact hmi · exact trace_pair_integrable μ hφ hf hfc hψ Φ hΦ hInv · exact first_energy_integrable μ hφ hf hfc hψ hpos Φ hΦ hInv lemma wEnergy_form (ψ : Space ι → ℝ) (Y : ι → Space ι → ℝ) (x : Space ι) : (fun i => Y i x) ⬝ᵥ (hess ψ x *ᵥ (fun i => Y i x)) = wEnergy ψ Y x := by simp only [dotProduct, Matrix.mulVec, Finset.mul_sum, wEnergy] rw [Finset.sum_comm] apply Finset.sum_congr rfl intro j _ apply Finset.sum_congr rfl intro i _ ring lemma second_cs {φ V f ψ : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hV : ContDiff ℝ ∞ V) (hf : ContDiff ℝ ∞ f) (hfc : HasCompactSupport f) (hψ : ContDiff ℝ ∞ ψ) (hpos : ∀ z, (hess φ z).PosDef) (hψpos : ∀ x, (hess ψ x).PosSemidef) {c Z q : ℝ} (hZ : 0 < Z) [IsFiniteMeasure (targetMeasure μ V Z)] (heq : ∀ z, Real.log (hess φ z).det = V (grad φ z)+c-φ z) (Φ : Space ι ≃ₜ Space ι) (hΦ : (Φ : Space ι → Space ι) = grad φ) (hInv : ContDiff ℝ ∞ (Φ.symm : Space ι → Space ι)) (hiψ : Integrable ψ (targetMeasure μ V Z)) (hEuler : ∀ x, (∑ i, x i*pd i ψ x) = q*ψ x) (hHessEuler : ∀ x i, (∑ j, hess ψ x i j*x j) = (q-1)*pd i ψ x) : (q-1)^2*(∫ x, ψ x*divergence V basis (wField Φ φ f) x ∂targetMeasure μ V Z)^2 ≤ ((q-1)*q*(∫ x, ψ x ∂targetMeasure μ V Z)) * (∫ x, wEnergy ψ (wField Φ φ f) x ∂targetMeasure μ V Z) := by have h₁ (x : Space ι) : x ⬝ᵥ (hess ψ x *ᵥ x) = ((q-1)*q)*ψ x := by change (∑ i, x i*(∑ j, hess ψ x i j*x j)) = _ simp_rw [hHessEuler] rw [show (∑ i, x i*((q-1)*pd i ψ x)) = (q-1)*(∑ i, x i*pd i ψ x) by rw [Finset.mul_sum]; apply Finset.sum_congr rfl; intro i _; ring, hEuler] ring have h₂ (x : Space ι) : x ⬝ᵥ (hess ψ x *ᵥ (fun i => wField Φ φ f i x)) = (q-1)*(∑ i, pd i ψ x*wField Φ φ f i x) := by rw [form_symm (MomentEquation.hess_transpose hψ x)] change (∑ i, wField Φ φ f i x*(∑ j, hess ψ x i j*x j)) = _ simp_rw [hHessEuler] rw [Finset.mul_sum] apply Finset.sum_congr rfl intro i _ ring have hg : Integrable (fun x => ∑ i, pd i ψ x*wField Φ φ f i x) (targetMeasure μ V Z) := by apply integrable_finsetSum intro i _ exact ((smooth_pd hψ i).mul (smooth_target hInv (smooth_W hφ hf i))).continuous.integrable_of_hasCompactSupport ((compact_W hφ hf hfc Φ hΦ i).comp_homeomorph Φ.symm).mul_left have hc := integral_form_cs (targetMeasure μ V Z) (v:=fun x => x) (w:=fun x i => wField Φ φ f i x) hψpos (by simpa only [h₁] using hiψ.const_mul ((q-1)*q)) (by simpa only [h₂] using hg.const_mul (q-1)) (by simpa only [wEnergy_form] using second_energy_integrable μ hφ hf hfc hψ Φ hΦ hInv) simp_rw [h₁,h₂,wEnergy_form,integral_const_mul] at hc rw [← (pairings μ hφ hV hf hfc hψ (fun z => ne_of_gt (hpos z).det_pos) hZ heq Φ hΦ hInv).1] at hc simpa only [mul_pow] using hc end section variable {ι : Type*} [Fintype ι] [DecidableEq ι] variable (μ : Measure (Space ι)) [Measure.IsAddHaarMeasure μ] lemma entries_bound {T : Matrix ι ι ℝ} (hT : T.PosSemidef) {Λ : ℝ} (hΛ : 0 ≤ Λ) (hc : (Λ • (1 : Matrix ι ι ℝ)-T).PosSemidef) (i j : ι) : |T i j| ≤ Λ := by have hd (k : ι) : T k k ≤ Λ := by have hh := hc.diag_nonneg (i:=k) simp only [Matrix.sub_apply, Matrix.smul_apply, Matrix.one_apply_eq, smul_eq_mul, mul_one] at hh linarith have hs : Tᵀ = T := by simpa only [Matrix.conjTranspose_eq_transpose_of_trivial] using hT.isHermitian.eq have hsq : (T i j)^2 ≤ T i i*T j j := by apply MomentMatrix.quadratic_cs intro t have hh := MomentMatrix.form_nonneg hT (basis j-t • basis i) rw [MomentMatrix.form_quadratic hs] at hh simpa [basis, Matrix.mulVec, dotProduct, Pi.single_apply] using hh have hle := mul_le_mul (hd i) (hd j) (hT.diag_nonneg (i:=j)) hΛ apply (sq_le_sq₀ (abs_nonneg _) hΛ).mp rw [sq_abs] nlinarith lemma smooth_tau {φ : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (Φ : Space ι ≃ₜ Space ι) (hInv : ContDiff ℝ ∞ (Φ.symm : Space ι → Space ι)) (i j : ι) : ContDiff ℝ ∞ (fun x => tau Φ φ x i j) := (smooth_hess hφ i j).comp hInv lemma fderiv_tau_row (Φ : Space ι ≃ₜ Space ι) (φ g : Space ι → ℝ) (i : ι) (x : Space ι) : fderiv ℝ g x (fun j => tau Φ φ x i j) = ∑ j, pd j g x*tau Φ φ x i j := linear_coordinates _ _ lemma compact_stein {φ V g : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hV : ContDiff ℝ ∞ V) (hg : ContDiff ℝ ∞ g) (hgc : HasCompactSupport g) (hne : ∀ z, (hess φ z).det ≠ 0) {c Z : ℝ} (hZ : 0 < Z) (heq : ∀ z, Real.log (hess φ z).det = V (grad φ z)+c-φ z) (Φ : Space ι ≃ₜ Space ι) (hΦ : (Φ : Space ι → Space ι) = grad φ) (hInv : ContDiff ℝ ∞ (Φ.symm : Space ι → Space ι)) (i : ι) : (∫ x, x i*g x ∂targetMeasure μ V Z) = ∫ x, fderiv ℝ g x (fun j => tau Φ φ x i j) ∂targetMeasure μ V Z := by have hdiv (x : Space ι) : divergence V basis (fun j y => tau Φ φ y i j) x = x i := by obtain ⟨z,rfl⟩ := Φ.surjective x rw [hΦ] exact stein hφ hV hne heq Φ hΦ hInv i z have hid : expectation μ V (fun x => x i*g x) = expectation μ V (fun x => fderiv ℝ g x (fun j => tau Φ φ x i j)) := by simp_rw [fderiv_tau_row] rw [expectation_sum μ hV _ (fun j => ((smooth_pd hg j).mul (smooth_tau hφ Φ hInv i j)).continuous) (fun j => (compact_D hgc (basis j)).mul_right)] have he (j : ι) : expectation μ V (fun x => pd j g x*tau Φ φ x i j) = expectation μ V (fun x => g x*adjoint V (basis j) (fun y => tau Φ φ y i j) x) := integration_by_parts_rightcompact μ hV (smooth_tau hφ Φ hInv i j) hg hgc (basis j) have heSum := Finset.sum_congr (s₁:=Finset.univ) rfl (fun j _ => he j) rw [heSum] rw [← expectation_sum μ hV _ (fun j => (hg.mul (smooth_adjoint hV (smooth_tau hφ Φ hInv i j) (basis j))).continuous) (fun _ => hgc.mul_right)] congr 1 funext x rw [← Finset.mul_sum] change x i*g x = g x*divergence V basis (fun j y => tau Φ φ y i j) x rw [hdiv] ring simp only [target_integral μ hV hZ, normalizedE, hid] omit [Measure.IsAddHaarMeasure μ] in lemma tau_hessian_integrable {φ V ψ : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hpos : ∀ z, (hess φ z).PosDef) {Z Λ : ℝ} (hΛ : 0 ≤ Λ) (hupper : ∀ z, (Λ • (1 : Matrix ι ι ℝ)-hess φ z).PosSemidef) (Φ : Space ι ≃ₜ Space ι) (hInv : ContDiff ℝ ∞ (Φ.symm : Space ι → Space ι)) (hi : ∀ i j, Integrable (fun x => hess ψ x i j) (targetMeasure μ V Z)) (i j : ι) : Integrable (fun x => tau Φ φ x i j*hess ψ x i j) (targetMeasure μ V Z) := by apply (hi i j).bdd_mul (smooth_tau hφ Φ hInv i j).continuous.aestronglyMeasurable exact Filter.Eventually.of_forall (fun x => by rw [Real.norm_eq_abs] exact entries_bound (hpos (Φ.symm x)).posSemidef hΛ (hupper (Φ.symm x)) i j) lemma homogeneous_trace_moment {φ V ψ : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hV : ContDiff ℝ ∞ V) (hψ : ContDiff ℝ ∞ ψ) (hpos : ∀ z, (hess φ z).PosDef) {c Z q Λ : ℝ} (hZ : 0 < Z) (hΛ : 0 ≤ Λ) (hupper : ∀ z, (Λ • (1 : Matrix ι ι ℝ)-hess φ z).PosSemidef) (heq : ∀ z, Real.log (hess φ z).det = V (grad φ z)+c-φ z) (Φ : Space ι ≃ₜ Space ι) (hΦ : (Φ : Space ι → Space ι) = grad φ) (hInv : ContDiff ℝ ∞ (Φ.symm : Space ι → Space ι)) (hiD : ∀ i, Integrable (pd i ψ) (targetMeasure μ V Z)) (hiXD : ∀ i, Integrable (fun x => x i*pd i ψ x) (targetMeasure μ V Z)) (hiH : ∀ i j, Integrable (fun x => hess ψ x i j) (targetMeasure μ V Z)) (hEuler : ∀ x, (∑ i, x i*pd i ψ x) = q*ψ x) : Integrable (fun x => (tau Φ φ x*hess ψ x).trace) (targetMeasure μ V Z) ∧ (∫ x, (tau Φ φ x*hess ψ x).trace ∂targetMeasure μ V Z) = q*(∫ x, ψ x ∂targetMeasure μ V Z) := by have hi (i j : ι) := tau_hessian_integrable μ hφ hpos hΛ hupper Φ hInv hiH i j have htr (x : Space ι) : (tau Φ φ x*hess ψ x).trace = ∑ i, ∑ j, tau Φ φ x i j*hess ψ x i j := by simp only [Matrix.trace,Matrix.diag,Matrix.mul_apply] apply Finset.sum_congr rfl intro i _ apply Finset.sum_congr rfl intro j _ rw [hess_symm hψ x j i] have hd (i : ι) : (fun x => fderiv ℝ (pd i ψ) x (fun j => tau Φ φ x i j)) = fun x => ∑ j, tau Φ φ x i j*hess ψ x i j := by funext x rw [fderiv_tau_row] apply Finset.sum_congr rfl intro j _ change pd j (pd i ψ) x*tau Φ φ x i j = tau Φ φ x i j*pd j (pd i ψ) x ring have hs (i : ι) : (∫ x, x i*pd i ψ x ∂targetMeasure μ V Z) = ∫ x, ∑ j, tau Φ φ x i j*hess ψ x i j ∂targetMeasure μ V Z := by rw [← hd] apply SteinExtension.extend (targetMeasure μ V Z) (continuous_apply i) (continuous_pi (fun j => (smooth_tau hφ Φ hInv i j).continuous)) · intro x apply (pi_norm_le_iff_of_nonneg hΛ).mpr intro j rw [Real.norm_eq_abs] exact entries_bound (hpos (Φ.symm x)).posSemidef hΛ (hupper (Φ.symm x)) i j · intro g hg hgc exact compact_stein μ hφ hV hg hgc (fun z => ne_of_gt (hpos z).det_pos) hZ heq Φ hΦ hInv i · exact smooth_pd hψ i · exact hiD i · exact hiXD i · rw [hd] exact integrable_finsetSum _ (fun j _ => hi i j) refine ⟨?_, ?_⟩ · simp_rw [htr] exact integrable_finsetSum _ (fun i _ => integrable_finsetSum _ (fun j _ => hi i j)) · simp_rw [htr] rw [integral_finsetSum _ (fun i _ => integrable_finsetSum _ (fun j _ => hi i j))] simp_rw [← hs] rw [← integral_finsetSum _ (fun i _ => hiXD i)] simp_rw [hEuler,integral_const_mul] end variable {ι : Type*} {κ : Type*} [Fintype ι] [DecidableEq ι] [Fintype κ] variable (μ : Measure (Space ι)) [Measure.IsAddHaarMeasure μ] omit [DecidableEq ι] in lemma trace_energy_subsum (M B H : Matrix ι ι ℝ) (Hs : κ → Matrix ι ι ℝ) : (M*B*(H-∑ i, Hs i)*B).trace = (M*B*H*B).trace-∑ i, (M*B*Hs i*B).trace := by simp only [Matrix.mul_sub, Matrix.sub_mul, Matrix.mul_sum, Matrix.sum_mul, Matrix.trace_sub, Matrix.trace_sum] omit [DecidableEq ι] in lemma form_subsum (v : ι → ℝ) (H : Matrix ι ι ℝ) (Hs : κ → Matrix ι ι ℝ) : v ⬝ᵥ ((H-∑ i, Hs i)*ᵥ v) = v ⬝ᵥ (H*ᵥ v)-∑ i, v ⬝ᵥ (Hs i*ᵥ v) := by simp only [Matrix.sub_mulVec, Matrix.sum_mulVec, dotProduct_sub, dotProduct_sum] lemma discard_energy {φ V f : Space ι → ℝ} (ψ : κ → Space ι → ℝ) (hφ : ContDiff ℝ ∞ φ) (hV : ContDiff ℝ ∞ V) (hf : ContDiff ℝ ∞ f) (hfc : HasCompactSupport f) (hψ : ∀ i, ContDiff ℝ ∞ (ψ i)) (hpos : ∀ z, (hess φ z).PosDef) (hrem : ∀ x, (hess V x-∑ i, hess (ψ i) x).PosSemidef) {c Z : ℝ} (hZ : 0 < Z) [IsFiniteMeasure (targetMeasure μ V Z)] (heq : ∀ z, Real.log (hess φ z).det = V (grad φ z)+c-φ z) (Φ : Space ι ≃ₜ Space ι) (hΦ : (Φ : Space ι → Space ι) = grad φ) (hInv : ContDiff ℝ ∞ (Φ.symm : Space ι → Space ι)) (hmap : Measure.map (grad φ) (sourceMeasure μ φ) = targetMeasure μ V Z) : (∑ i, ((∫ x, hEnergy Φ φ (ψ i) f x ∂targetMeasure μ V Z)+ (∫ x, wEnergy (ψ i) (wField Φ φ f) x ∂targetMeasure μ V Z))) ≤ ∫ x, (divergence V basis (wField Φ φ f) x)^2 ∂targetMeasure μ V Z := by have he₁ (i : κ) := first_energy_integrable μ hφ hf hfc (hψ i) hpos Φ hΦ hInv (V:=V) (Z:=Z) have he₂ (i : κ) := second_energy_integrable μ hφ hf hfc (hψ i) Φ hΦ hInv (V:=V) (Z:=Z) have heV₁ := first_energy_integrable μ hφ hf hfc hV hpos Φ hΦ hInv (V:=V) (Z:=Z) have heV₂ := second_energy_integrable μ hφ hf hfc hV Φ hΦ hInv (V:=V) (Z:=Z) have hp₁ (x : Space ι) : (∑ i, hEnergy Φ φ (ψ i) f x) ≤ hEnergy Φ φ V f x := by have hp := trace_energy_nonneg ((hpos (Φ.symm x)).inv.posSemidef) (hrem x) (bField_symm hφ hf Φ x) rw [trace_energy_subsum] at hp exact sub_nonneg.mp hp have hp₂ (x : Space ι) : (∑ i, wEnergy (ψ i) (wField Φ φ f) x) ≤ wEnergy V (wField Φ φ f) x := by have hp := form_nonneg (hrem x) (fun j => wField Φ φ f j x) rw [form_subsum] at hp simp_rw [wEnergy_form] at hp exact sub_nonneg.mp hp have h₁ := integral_mono (integrable_finsetSum _ (fun i _ => he₁ i)) heV₁ hp₁ have h₂ := integral_mono (integrable_finsetSum _ (fun i _ => he₂ i)) heV₂ hp₂ rw [integral_finsetSum _ (fun i _ => he₁ i)] at h₁ rw [integral_finsetSum _ (fun i _ => he₂ i)] at h₂ have ht := (tensor_energy μ hφ hV hf hfc hpos hZ heq Φ hΦ hInv hmap).2 simp_rw [← target_integral μ hV hZ] at ht rw [Finset.sum_add_distrib] linarith end DualEnergy namespace SoftSlab section open WeightedCalculus MomentCoordinates variable {ι : Type*} [Fintype ι] [DecidableEq ι] def linear (p : ι → ℝ) : Space ι →L[ℝ] ℝ := ∑ i, p i • ContinuousLinearMap.proj i omit [DecidableEq ι] in lemma linear_apply (p x : ι → ℝ) : linear p x = ∑ i, p i * x i := by simp [linear] lemma linear_basis (p : ι → ℝ) (i : ι) : linear p (basis i) = p i := by simp [linear_apply, basis, Pi.single_apply] def summand (p : ι → ℝ) (h : ℝ) (q : ℕ) : Space ι → ℝ := fun x => (linear p x / h)^q omit [DecidableEq ι] in omit [DecidableEq ι] in lemma summand_eq (p : ι → ℝ) (h : ℝ) (q : ℕ) (x : Space ι) : summand p h q x = ((∑ i, p i * x i) / h)^q := by rw [summand, linear_apply] omit [DecidableEq ι] in lemma smooth_summand (p : ι → ℝ) (h : ℝ) (q : ℕ) : ContDiff ℝ ∞ (summand p h q) := ((linear p).contDiff.div_const h).pow q lemma pd_summand (p : ι → ℝ) (h : ℝ) (q : ℕ) (i : ι) : pd i (summand p h q) = fun x => (q : ℝ) * (linear p x / h)^(q-1) * (p i / h) := by funext x have hd : HasFDerivAt (summand p h q) (((q : ℝ) * (linear p x / h)^(q-1)) • (h⁻¹ • linear p)) x := by unfold summand simpa only [div_eq_mul_inv, nsmul_eq_mul] using (((linear p).hasFDerivAt (x := x)).mul_const h⁻¹).pow q change fderiv ℝ (summand p h q) x (basis i) = _ rw [hd.fderiv] simp [linear_basis, smul_eq_mul, div_eq_mul_inv, mul_comm] lemma hess_summand (p : ι → ℝ) (h : ℝ) (q : ℕ) (x : Space ι) (i j : ι) : hess (summand p h (q+2)) x i j = ((q+2 : ℕ) : ℝ) * ((q+1 : ℕ) : ℝ) * (linear p x / h)^q * (p i/h) * (p j/h) := by change pd j (pd i (summand p h (q+2))) x = _ rw [pd_summand] simp only [show q+2-1=q+1 by omega] have hbase : HasFDerivAt (fun y => (linear p y / h)^(q+1)) ((((q+1 : ℕ) : ℝ) * (linear p x / h)^q) • (h⁻¹ • linear p)) x := by simpa only [div_eq_mul_inv, Nat.add_sub_cancel, nsmul_eq_mul] using (((linear p).hasFDerivAt (x := x)).mul_const h⁻¹).pow (q+1) have hd := hbase.const_mul (((q+2 : ℕ) : ℝ)) have hd' := hd.mul_const (p i / h) change fderiv ℝ (fun y => ((q+2 : ℕ) : ℝ) * (linear p y / h)^(q+1) * (p i / h)) x (basis j) = _ rw [hd'.fderiv] simp [linear_basis, smul_eq_mul, div_eq_mul_inv] ring omit [DecidableEq ι] in lemma summand_even {q : ℕ} (hq : Even q) (p : ι → ℝ) (h : ℝ) : Function.Even (summand p h q) := by intro x simp only [summand, map_neg, neg_div, hq.neg_pow] omit [DecidableEq ι] in lemma summand_nonneg {q : ℕ} (hq : Even q) (p : ι → ℝ) (h : ℝ) (x : Space ι) : 0 ≤ summand p h q x := hq.pow_nonneg _ lemma hess_summand_posSemidef {q : ℕ} (hq : Even q) (p : ι → ℝ) (h : ℝ) (x : Space ι) : (hess (summand p h (q+2)) x).PosSemidef := by let c : ℝ := ((q+2 : ℕ) : ℝ) * ((q+1 : ℕ) : ℝ) * (linear p x / h)^q have hc : 0 ≤ c := mul_nonneg (mul_nonneg (by positivity) (by positivity)) (hq.pow_nonneg _) have he : hess (summand p h (q+2)) x = c • Matrix.vecMulVec (fun i => p i/h) (fun i => p i/h) := by ext i j rw [hess_summand] simp only [Matrix.smul_apply, Matrix.vecMulVec_apply, smul_eq_mul, c] ring rw [he] apply Matrix.PosSemidef.smul _ hc simpa only [star_trivial] using Matrix.posSemidef_vecMulVec_self_star (fun i => p i/h) lemma euler_summand (p : ι → ℝ) (h : ℝ) (q : ℕ) (x : Space ι) : (∑ i, x i * pd i (summand p h (q+1)) x) = ((q+1 : ℕ) : ℝ) * summand p h (q+1) x := by simp only [pd_summand, Nat.add_sub_cancel, summand] have he : (∑ i, x i * (((q+1 : ℕ) : ℝ) * (linear p x / h)^q * (p i/h))) = (((q+1 : ℕ) : ℝ) * (linear p x / h)^q) * (linear p x / h) := by rw [linear_apply, Finset.sum_div, Finset.mul_sum] apply Finset.sum_congr rfl intro i _ ring rw [he, pow_succ] ring lemma hessian_euler (p : ι → ℝ) (h : ℝ) (q : ℕ) (x : Space ι) (i : ι) : (∑ j, hess (summand p h (q+2)) x i j * x j) = ((q+1 : ℕ) : ℝ) * pd i (summand p h (q+2)) x := by simp only [hess_summand, pd_summand, show q+2-1=q+1 by omega] have he : (∑ j, (((q+2 : ℕ) : ℝ) * ((q+1 : ℕ) : ℝ) * (linear p x / h)^q * (p i/h) * (p j/h)) * x j) = (((q+2 : ℕ) : ℝ) * ((q+1 : ℕ) : ℝ) * (linear p x / h)^q * (p i/h)) * (linear p x / h) := by rw [linear_apply, Finset.sum_div, Finset.mul_sum] apply Finset.sum_congr rfl intro j _ ring rw [he, pow_succ] ring end open MeasureTheory WeightedCalculus MomentCoordinates open scoped BigOperators ContDiff variable {ι : Type*} {κ : Type*} [Fintype ι] [DecidableEq ι] [Fintype κ] def potential (ε : ℝ) (p : κ → ι → ℝ) (h : κ → ℝ) (q : ℕ) (x : Space ι) : ℝ := ε/2*(∑ j, x j^2) + ∑ i, summand (p i) (h i) q x omit [DecidableEq ι] in lemma smooth_potential (ε : ℝ) (p : κ → ι → ℝ) (h : κ → ℝ) (q : ℕ) : ContDiff ℝ ∞ (potential ε p h q) := by apply ContDiff.add · exact contDiff_const.mul (ContDiff.sum (fun j _ => (contDiff_apply ℝ ℝ j).pow 2)) · exact ContDiff.sum (fun i _ => smooth_summand (p i) (h i) q) omit [DecidableEq ι] in lemma potential_even {q : ℕ} (hq : Even q) (ε : ℝ) (p : κ → ι → ℝ) (h : κ → ℝ) : Function.Even (potential ε p h q) := by intro x simp only [potential, Pi.neg_apply, neg_sq] congr 1 exact Finset.sum_congr rfl (fun i _ => summand_even hq (p i) (h i) x) omit [DecidableEq ι] in lemma potential_lower {q : ℕ} (hq : Even q) (ε : ℝ) (p : κ → ι → ℝ) (h : κ → ℝ) (x : Space ι) : ε/2*(∑ j, x j^2) ≤ potential ε p h q x := by unfold potential exact le_add_of_nonneg_right (Finset.sum_nonneg (fun i _ => summand_nonneg hq (p i) (h i) x)) lemma pd_quadratic (ε : ℝ) (i : ι) : pd i (fun x : Space ι => ε/2*(∑ j, x j^2)) = fun x => ε*x i := by funext x have hj (j : ι) : HasFDerivAt (fun x : Space ι => x j^2) ((2*x j) • (ContinuousLinearMap.proj j : Space ι →L[ℝ] ℝ)) x := by simpa using ((ContinuousLinearMap.proj j : Space ι →L[ℝ] ℝ).hasFDerivAt (x:=x) |>.pow 2) have hd := (HasFDerivAt.sum (u:=Finset.univ) (fun j _ => hj j)).const_mul (ε/2) have hd' : HasFDerivAt (fun x : Space ι => ε/2*(∑ j, x j^2)) ((ε/2) • ∑ j, (2*x j) • (ContinuousLinearMap.proj j : Space ι →L[ℝ] ℝ)) x := by simpa only [Finset.sum_apply] using hd change fderiv ℝ (fun x : Space ι => ε/2*(∑ j, x j^2)) x (basis i) = _ rw [hd'.fderiv] simp [basis, Pi.single_apply] ring lemma hess_quadratic (ε : ℝ) (x : Space ι) : hess (fun x : Space ι => ε/2*(∑ j, x j^2)) x = ε • (1 : Matrix ι ι ℝ) := by ext i j change pd j (pd i (fun x : Space ι => ε/2*(∑ k, x k^2))) x = _ rw [pd_quadratic] change fderiv ℝ (ε • (ContinuousLinearMap.proj i : Space ι →L[ℝ] ℝ)) x (basis j) = _ rw [ContinuousLinearMap.fderiv] simp [basis, Pi.single_apply, Matrix.one_apply] lemma hess_add {f g : Space ι → ℝ} (hf : ContDiff ℝ ∞ f) (hg : ContDiff ℝ ∞ g) (x : Space ι) : hess (fun y => f y+g y) x = hess f x+hess g x := by ext i j change D (basis j) (D (basis i) (fun y => f y+g y)) x = _ rw [D_add (hf.differentiable (by simp)) (hg.differentiable (by simp)), D_add ((smooth_D hf _).differentiable (by simp)) ((smooth_D hg _).differentiable (by simp))] rfl lemma hess_sum (f : κ → Space ι → ℝ) (hf : ∀ i, ContDiff ℝ ∞ (f i)) (x : Space ι) : hess (fun y => ∑ i, f i y) x = ∑ i, hess (f i) x := by ext j k change D (basis k) (D (basis j) (fun y => ∑ i, f i y)) x = _ rw [D_sum _ (fun i => (hf i).differentiable (by simp)), D_sum _ (fun i => (smooth_D (hf i) _).differentiable (by simp))] simp only [Matrix.sum_apply] rfl lemma hess_potential (ε : ℝ) (p : κ → ι → ℝ) (h : κ → ℝ) (q : ℕ) (x : Space ι) : hess (potential ε p h q) x = ε • (1 : Matrix ι ι ℝ) + ∑ i, hess (summand (p i) (h i) q) x := by unfold potential rw [hess_add, hess_quadratic, hess_sum] · exact fun i => smooth_summand (p i) (h i) q · exact contDiff_const.mul (ContDiff.sum (fun j _ => (contDiff_apply ℝ ℝ j).pow 2)) · exact ContDiff.sum (fun i _ => smooth_summand (p i) (h i) q) lemma potential_strongly_convex {q : ℕ} (hq : Even q) (ε : ℝ) (p : κ → ι → ℝ) (h : κ → ℝ) (x : Space ι) : (hess (potential ε p h (q+2)) x-ε • (1 : Matrix ι ι ℝ)).PosSemidef := by rw [hess_potential, add_sub_cancel_left] exact Matrix.posSemidef_sum _ (fun i _ => hess_summand_posSemidef hq (p i) (h i) x) end SoftSlab end open MeasureTheory open scoped BigOperators noncomputable section namespace GaussianPolynomial section variable {ι : Type*} [Fintype ι] lemma gaussian_product (b : ℝ) (x : ι → ℝ) : Real.exp (-b * ∑ i, x i ^ 2) = ∏ i, Real.exp (-b * x i ^ 2) := by rw [Finset.mul_sum, Real.exp_sum] lemma monomial_integrable {b : ℝ} (hb : 0 < b) (d : ι → ℕ) : Integrable (fun x : ι → ℝ => (∏ i, x i ^ d i) * Real.exp (-b * ∑ i, x i^2)) := by have hi (i : ι) : Integrable (fun x : ℝ => x ^ d i * Real.exp (-b * x^2)) := by simpa only [Real.rpow_natCast] using integrable_rpow_mul_exp_neg_mul_sq hb (by have := Nat.cast_nonneg (α := ℝ) (d i); linarith : (-1:ℝ) < (d i : ℝ)) have hp := Integrable.fintype_prod hi have he : (fun x : ι → ℝ => (∏ i, x i ^ d i) * Real.exp (-b * ∑ i, x i^2)) = (fun x : ι → ℝ => ∏ i, x i ^ d i * Real.exp (-b * x i^2)) := by funext x rw [gaussian_product, Finset.prod_mul_distrib] rw [he] exact hp lemma polynomial_integrable {b : ℝ} (hb : 0 < b) (P : MvPolynomial ι ℝ) : Integrable (fun x : ι → ℝ => MvPolynomial.eval x P * Real.exp (-b * ∑ i, x i^2)) := by have hi : Integrable (fun x : ι → ℝ => ∑ d ∈ P.support, P.coeff d * ((∏ i, x i ^ d i) * Real.exp (-b * ∑ i, x i^2))) := by exact integrable_finsetSum _ (fun d _ => (monomial_integrable hb d).const_mul _) convert hi using 1 funext x rw [MvPolynomial.eval_eq', Finset.sum_mul] apply Finset.sum_congr rfl intro d _ ring lemma dominated_polynomial {V : (ι → ℝ) → ℝ} (hV : Continuous V) {b c : ℝ} (hb : 0 < b) (hlower : ∀ x, b * (∑ i, x i^2) - c ≤ V x) (P : MvPolynomial ι ℝ) : Integrable (fun x : ι → ℝ => MvPolynomial.eval x P * Real.exp (-V x)) := by have hmaj := (polynomial_integrable hb P).norm.const_mul (Real.exp c) apply hmaj.mono' (((MvPolynomial.continuous_eval P).mul (Real.continuous_exp.comp hV.neg)).aestronglyMeasurable) apply Filter.Eventually.of_forall intro x change ‖MvPolynomial.eval x P * Real.exp (-V x)‖ ≤ Real.exp c * ‖MvPolynomial.eval x P * Real.exp (-b * ∑ i, x i^2)‖ simp only [norm_mul, Real.norm_eq_abs (Real.exp _), abs_of_pos (Real.exp_pos _)] have he : Real.exp (-V x) ≤ Real.exp c * Real.exp (-b * ∑ i, x i^2) := by rw [← Real.exp_add] apply Real.exp_le_exp.mpr linarith [hlower x] calc _ ≤ ‖MvPolynomial.eval x P‖ * (Real.exp c * Real.exp (-b * ∑ i, x i^2)) := mul_le_mul_of_nonneg_left he (norm_nonneg _) _ = _ := by ring lemma partition_integrable {V : (ι → ℝ) → ℝ} (hV : Continuous V) {b c : ℝ} (hb : 0 < b) (hlower : ∀ x, b * (∑ i, x i^2) - c ≤ V x) : Integrable (fun x => Real.exp (-V x)) := by simpa using dominated_polynomial hV hb hlower (1 : MvPolynomial ι ℝ) end open MeasureTheory variable {ι : Type*} [Fintype ι] lemma normalized_polynomial {V : (ι → ℝ) → ℝ} (hV : Continuous V) {b c Z : ℝ} (hb : 0 < b) (hZ : 0 < Z) (hlower : ∀ x, b * (∑ i, x i^2) - c ≤ V x) (P : MvPolynomial ι ℝ) : Integrable (fun x => MvPolynomial.eval x P) (volume.withDensity (fun x => ENNReal.ofReal (Real.exp (-V x)/Z))) := by have hm : Measurable (fun x : ι → ℝ => ENNReal.ofReal (Real.exp (-V x)/Z)) := ((Real.continuous_exp.comp hV.neg).div_const Z).measurable.ennreal_ofReal apply (integrable_withDensity_iff_integrable_smul' (μ:=volume) hm (Filter.Eventually.of_forall (fun _ => ENNReal.ofReal_lt_top))).mpr have he (x : ι → ℝ) : (ENNReal.ofReal (Real.exp (-V x)/Z)).toReal • MvPolynomial.eval x P = (MvPolynomial.eval x P*Real.exp (-V x))/Z := by rw [ENNReal.toReal_ofReal (div_nonneg (Real.exp_pos _).le hZ.le), smul_eq_mul] ring simp_rw [he] exact (dominated_polynomial hV hb hlower P).div_const Z lemma partition_pos {V : (ι → ℝ) → ℝ} (hV : Continuous V) {b c : ℝ} (hb : 0 < b) (hlower : ∀ x, b * (∑ i, x i^2) - c ≤ V x) : 0 < ∫ x, Real.exp (-V x) := integral_exp_pos (partition_integrable hV hb hlower) lemma normalized_probability {V : (ι → ℝ) → ℝ} (hV : Continuous V) {b c : ℝ} (hb : 0 < b) (hlower : ∀ x, b * (∑ i, x i^2) - c ≤ V x) : IsProbabilityMeasure (volume.withDensity (fun x => ENNReal.ofReal (Real.exp (-V x)/(∫ y, Real.exp (-V y))))) := by have hZ := partition_pos hV hb hlower apply isProbabilityMeasure_iff.mpr rw [withDensity_apply _ MeasurableSet.univ, Measure.restrict_univ, ← ofReal_integral_eq_lintegral_ofReal] · simp only [integral_div, div_self (ne_of_gt hZ), ENNReal.ofReal_one] · exact (partition_integrable hV hb hlower).div_const _ · exact Filter.Eventually.of_forall (fun x => div_nonneg (Real.exp_pos _).le hZ.le) end GaussianPolynomial namespace SoftSlab open MeasureTheory WeightedCalculus MomentCoordinates open scoped BigOperators ContDiff variable {ι : Type*} {κ : Type*} [Fintype ι] [DecidableEq ι] [Fintype κ] abbrev law (ε : ℝ) (p : κ → ι → ℝ) (h : κ → ℝ) (q : ℕ) : Measure (Space ι) := volume.withDensity (fun x => ENNReal.ofReal (Real.exp (-potential ε p h q x)/ (∫ y, Real.exp (-potential ε p h q y)))) def linearPolynomial (p : ι → ℝ) (h : ℝ) : MvPolynomial ι ℝ := (∑ j, MvPolynomial.C (p j)*MvPolynomial.X j)*MvPolynomial.C h⁻¹ omit [DecidableEq ι] in lemma eval_linearPolynomial (p : ι → ℝ) (h : ℝ) (x : Space ι) : MvPolynomial.eval x (linearPolynomial p h) = linear p x/h := by simp [linearPolynomial, linear_apply, map_sum, div_eq_mul_inv] omit [DecidableEq ι] in lemma potential_partition_pos {q : ℕ} (hq : Even q) {ε : ℝ} (hε : 0 < ε) (p : κ → ι → ℝ) (h : κ → ℝ) : 0 < ∫ x, Real.exp (-potential ε p h q x) := GaussianPolynomial.partition_pos (c:=0) (smooth_potential ε p h q).continuous (half_pos hε) (by intro x; simpa using potential_lower hq ε p h x) omit [DecidableEq ι] in lemma potential_probability {q : ℕ} (hq : Even q) {ε : ℝ} (hε : 0 < ε) (p : κ → ι → ℝ) (h : κ → ℝ) : IsProbabilityMeasure (law ε p h q) := GaussianPolynomial.normalized_probability (c:=0) (smooth_potential ε p h q).continuous (half_pos hε) (by intro x; simpa using potential_lower hq ε p h x) omit [DecidableEq ι] in lemma polynomial_moment {q : ℕ} (hq : Even q) {ε : ℝ} (hε : 0 < ε) (p : κ → ι → ℝ) (h : κ → ℝ) (P : MvPolynomial ι ℝ) : Integrable (fun x => MvPolynomial.eval x P) (law ε p h q) := GaussianPolynomial.normalized_polynomial (c:=0) (smooth_potential ε p h q).continuous (half_pos hε) (potential_partition_pos hq hε p h) (by intro x; simpa using potential_lower hq ε p h x) P omit [DecidableEq ι] in lemma integrable_summand {q : ℕ} (hq : Even q) {ε : ℝ} (hε : 0 < ε) (p : κ → ι → ℝ) (h : κ → ℝ) (v : ι → ℝ) (r : ℝ) (m : ℕ) : Integrable (summand v r m) (law ε p h q) := by change Integrable (fun x => (linear v x/r)^m) _ simpa only [map_pow, eval_linearPolynomial] using polynomial_moment hq hε p h ((linearPolynomial v r)^m) lemma integrable_pd_summand {q : ℕ} (hq : Even q) {ε : ℝ} (hε : 0 < ε) (p : κ → ι → ℝ) (h : κ → ℝ) (v : ι → ℝ) (r : ℝ) (m : ℕ) (j : ι) : Integrable (pd j (summand v r m)) (law ε p h q) := by rw [pd_summand] exact ((integrable_summand hq hε p h v r (m-1)).const_mul (m:ℝ)).mul_const (v j/r) lemma integrable_x_pd_summand {q : ℕ} (hq : Even q) {ε : ℝ} (hε : 0 < ε) (p : κ → ι → ℝ) (h : κ → ℝ) (v : ι → ℝ) (r : ℝ) (m : ℕ) (j : ι) : Integrable (fun x => x j*pd j (summand v r m) x) (law ε p h q) := by let P : MvPolynomial ι ℝ := MvPolynomial.X j * (MvPolynomial.C (m:ℝ)*(linearPolynomial v r)^(m-1)*MvPolynomial.C (v j/r)) have he (x : Space ι) : MvPolynomial.eval x P = x j*pd j (summand v r m) x := by rw [pd_summand] simp only [P, MvPolynomial.eval_mul, MvPolynomial.eval_pow, MvPolynomial.eval_C, MvPolynomial.eval_X, eval_linearPolynomial] have hi := polynomial_moment hq hε p h P simpa only [he] using hi lemma integrable_hess_summand {q : ℕ} (hq : Even q) {ε : ℝ} (hε : 0 < ε) (p : κ → ι → ℝ) (h : κ → ℝ) (v : ι → ℝ) (r : ℝ) (m : ℕ) (j k : ι) : Integrable (fun x => hess (summand v r (m+2)) x j k) (law ε p h q) := by simp_rw [hess_summand] exact (((integrable_summand hq hε p h v r m).const_mul (((m+2:ℕ):ℝ)*((m+1:ℕ):ℝ))).mul_const (v j/r)).mul_const (v k/r) lemma mean_summand_pos {q : ℕ} (hq : Even q) {ε : ℝ} (hε : 0 < ε) (p : κ → ι → ℝ) (h : κ → ℝ) {v : ι → ℝ} (hv : v ≠ 0) {r : ℝ} (hr : r ≠ 0) {m : ℕ} (hm : Even m) : 0 < ∫ x, summand v r m x ∂law ε p h q := by have hZ := potential_partition_pos hq hε p h have hV := (smooth_potential ε p h q).continuous have hi : Integrable (fun x => summand v r m x*Real.exp (-potential ε p h q x)) := by simpa only [map_pow, eval_linearPolynomial, summand] using GaussianPolynomial.dominated_polynomial (c:=0) hV (half_pos hε) (by intro x; simpa using potential_lower hq ε p h x) ((linearPolynomial v r)^m) have hp : 0 < ∫ x, summand v r m x*Real.exp (-potential ε p h q x) := by obtain ⟨j,hj⟩ : ∃ j, v j ≠ 0 := by by_contra hc push Not at hc exact hv (funext hc) apply integral_pos_of_integrable_nonneg_nonzero ((smooth_summand v r m).continuous.mul (Real.continuous_exp.comp hV.neg)) hi (fun x => mul_nonneg (summand_nonneg hm v r x) (Real.exp_pos _).le) (x:=basis j) exact mul_ne_zero (pow_ne_zero _ (div_ne_zero (by simpa only [linear_basis] using hj) hr)) (Real.exp_ne_zero _) change 0 < ∫ x, summand v r m x ∂volume.withDensity _ have hmeas : Measurable (fun x : Space ι => ENNReal.ofReal (Real.exp (-potential ε p h q x)/ (∫ y, Real.exp (-potential ε p h q y)))) := ((Real.continuous_exp.comp hV.neg).div_const _).measurable.ennreal_ofReal rw [integral_withDensity_eq_integral_toReal_smul hmeas (Filter.Eventually.of_forall (fun _ => ENNReal.ofReal_lt_top))] have he (x : Space ι) : (ENNReal.ofReal (Real.exp (-potential ε p h q x)/ (∫ y, Real.exp (-potential ε p h q y)))).toReal • summand v r m x = (summand v r m x*Real.exp (-potential ε p h q x))/(∫ y, Real.exp (-potential ε p h q y)) := by rw [ENNReal.toReal_ofReal (div_nonneg (Real.exp_pos _).le hZ.le), smul_eq_mul] ring simp_rw [he] rw [integral_div] exact div_pos hp hZ end SoftSlab end open scoped BigOperators InnerProductSpace Topology noncomputable section namespace VarianceDuality variable {ι : Type*} [Fintype ι] lemma quadratic_cs (a b c : ℝ) (h : ∀ t : ℝ, 0 ≤ c - 2*t*b + t^2*a) : b^2 ≤ a*c := by have hd := discrim_le_zero (a := a) (b := -2*b) (c := c) (fun t => by have ht := h t nlinarith) dsimp [discrim] at hd nlinarith lemma weighted_coefficient_cs (a b d : ι → ℝ) (ha : ∀ i, 0 < a i) : (∑ i, b i * d i)^2 ≤ (∑ i, b i^2 * a i) * (∑ i, d i^2 / a i) := by apply quadratic_cs intro t calc _ = ∑ i, (d i - t * a i * b i)^2 / a i := by simp only [Finset.mul_sum, ← Finset.sum_sub_distrib, ← Finset.sum_add_distrib] apply Finset.sum_congr rfl intro i _ field_simp [ne_of_gt (ha i)] ring _ ≥ 0 := Finset.sum_nonneg (fun i _ => div_nonneg (sq_nonneg _) (ha i).le) theorem combine_energies (q E : ℝ) (a d e₁ e₂ : ι → ℝ) (hq : 1 < q) (ha : ∀ i, 0 < a i) (h₁ : ∀ i, d i ^ 2 ≤ (q * a i) * e₁ i) (h₂ : ∀ i, (q-1)^2 * d i^2 ≤ ((q-1) * (q*a i)) * e₂ i) (hE : ∑ i, (e₁ i + e₂ i) ≤ E) : ∑ i, d i^2 / a i ≤ E := by apply le_trans (Finset.sum_le_sum (fun i _ => ?_)) hE have hq0 : 0 < q := by linarith have hm : 0 < q*a i := mul_pos hq0 (ha i) have hqm : 0 < q-1 := by linarith have he₁ : d i^2 / (q*a i) ≤ e₁ i := (div_le_iff₀ hm).mpr (by nlinarith [h₁ i]) have he₂ : (q-1)*d i^2 / (q*a i) ≤ e₂ i := by apply (div_le_iff₀ hm).mpr have hh := h₂ i have ht : (q-1)*((q-1)*d i^2) ≤ (q-1)*((q*a i)*e₂ i) := by nlinarith [hh] exact le_of_mul_le_mul_left (by simpa only [mul_comm (e₂ i) (q * a i)] using ht) hqm calc d i^2 / a i = d i^2 / (q*a i) + (q-1)*d i^2 / (q*a i) := by field_simp ring _ ≤ e₁ i + e₂ i := add_le_add he₁ he₂ variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] theorem extend_dual_bound (a : ι → ℝ) (ψ : ι → E) (S : Set E) (hS : ∀ u ∈ S, ∑ i, ⟪u, ψ i⟫_ℝ ^ 2 / a i ≤ ‖u‖^2) {u : E} (hu : u ∈ closure S) : ∑ i, ⟪u, ψ i⟫_ℝ ^ 2 / a i ≤ ‖u‖^2 := by have hc : IsClosed {u : E | ∑ i, ⟪u, ψ i⟫_ℝ ^ 2 / a i ≤ ‖u‖^2} := by apply isClosed_le · exact continuous_finsetSum _ (fun i _ => ((continuous_id.inner continuous_const).pow 2).div_const (a i)) · exact continuous_norm.pow 2 exact hc.closure_subset_iff.mpr hS hu theorem variance_from_dense_tests (a : ι → ℝ) (ha : ∀ i, 0 < a i) (ψ : ι → E) (S : Set E) (hSdense : Dense S) (hS : ∀ u ∈ S, ∑ i, ⟪u, ψ i⟫_ℝ ^ 2 / a i ≤ ‖u‖^2) (b : ι → ℝ) : ‖∑ i, b i • ψ i‖^2 ≤ ∑ i, b i^2 * a i := by let u : E := ∑ i, b i • ψ i have hdu := extend_dual_bound a ψ S hS (hSdense u) have hpair : (∑ i, b i * ⟪u, ψ i⟫_ℝ) = ‖u‖^2 := by rw [← real_inner_self_eq_norm_sq] change (∑ i, b i * ⟪u, ψ i⟫_ℝ) = ⟪u, ∑ i, b i • ψ i⟫_ℝ simp only [inner_sum, inner_smul_right] have hc := weighted_coefficient_cs a b (fun i => ⟪u, ψ i⟫_ℝ) ha rw [hpair] at hc have hnon : 0 ≤ ∑ i, b i^2 * a i := Finset.sum_nonneg (fun i _ => mul_nonneg (sq_nonneg _) (ha i).le) have hh := mul_le_mul_of_nonneg_left hdu hnon change ‖u‖^2 ≤ _ by_cases hu : ‖u‖^2 = 0 · simpa only [hu] using hnon · have hp : 0 < ‖u‖^2 := lt_of_le_of_ne (sq_nonneg _) (Ne.symm hu) nlinarith end VarianceDuality namespace DualEnergy open MeasureTheory Matrix WeightedCalculus MomentCoordinates MomentDifferential MomentEquation IntegratedTensor TargetCoordinates FullTensor MomentMatrix TensorEstimate open scoped BigOperators ContDiff variable {ι : Type*} {κ : Type*} [Fintype ι] [DecidableEq ι] [Fintype κ] variable (μ : Measure (Space ι)) [Measure.IsAddHaarMeasure μ] lemma compact_dual_generic {φ V f : Space ι → ℝ} (ψ : κ → Space ι → ℝ) (hφ : ContDiff ℝ ∞ φ) (hV : ContDiff ℝ ∞ V) (hf : ContDiff ℝ ∞ f) (hfc : HasCompactSupport f) (hψ : ∀ i, ContDiff ℝ ∞ (ψ i)) (hpos : ∀ z, (hess φ z).PosDef) (hψpos : ∀ i x, (hess (ψ i) x).PosSemidef) {c Z q : ℝ} (hZ : 0 < Z) [IsFiniteMeasure (targetMeasure μ V Z)] (hq : 1 < q) (heq : ∀ z, Real.log (hess φ z).det = V (grad φ z)+c-φ z) (Φ : Space ι ≃ₜ Space ι) (hΦ : (Φ : Space ι → Space ι) = grad φ) (hInv : ContDiff ℝ ∞ (Φ.symm : Space ι → Space ι)) (hmap : Measure.map (grad φ) (sourceMeasure μ φ) = targetMeasure μ V Z) (hiψ : ∀ i, Integrable (ψ i) (targetMeasure μ V Z)) (hmean : ∀ i, 0 < ∫ x, ψ i x ∂targetMeasure μ V Z) (hEuler : ∀ i x, (∑ j, x j*pd j (ψ i) x) = q*ψ i x) (hHessEuler : ∀ i x j, (∑ k, hess (ψ i) x j k*x k) = (q-1)*pd j (ψ i) x) (hmi : ∀ i, Integrable (fun x => (tau Φ φ x*hess (ψ i) x).trace) (targetMeasure μ V Z)) (hm : ∀ i, (∫ x, (tau Φ φ x*hess (ψ i) x).trace ∂targetMeasure μ V Z) = q*(∫ x, ψ i x ∂targetMeasure μ V Z)) (hrem : ∀ x, (hess V x-∑ i, hess (ψ i) x).PosSemidef) : (∑ i, (∫ x, ψ i x*divergence V basis (wField Φ φ f) x ∂targetMeasure μ V Z)^2 / (∫ x, ψ i x ∂targetMeasure μ V Z)) ≤ ∫ x, (divergence V basis (wField Φ φ f) x)^2 ∂targetMeasure μ V Z := by apply VarianceDuality.combine_energies (e₁:=fun i => ∫ x, hEnergy Φ φ (ψ i) f x ∂targetMeasure μ V Z) (e₂:=fun i => ∫ x, wEnergy (ψ i) (wField Φ φ f) x ∂targetMeasure μ V Z) q · exact hq · exact hmean · intro i have hc := first_cs μ hφ hV hf hfc (hψ i) hpos (hψpos i) hZ heq Φ hΦ hInv (hmi i) rw [hm i] at hc exact hc · intro i have hc := second_cs μ hφ hV hf hfc (hψ i) hpos (hψpos i) hZ heq Φ hΦ hInv (hiψ i) (hEuler i) (hHessEuler i) simpa only [mul_assoc] using hc · exact discard_energy μ ψ hφ hV hf hfc hψ hpos hrem hZ heq Φ hΦ hInv hmap end DualEnergy namespace MomentSlab open MeasureTheory WeightedCalculus MomentCoordinates MomentDifferential MomentEquation IntegratedTensor TargetCoordinates FullTensor MomentMatrix TensorEstimate DualEnergy SoftSlab open scoped BigOperators ContDiff variable {ι : Type*} {κ : Type*} [Fintype ι] [DecidableEq ι] [Fintype κ] theorem summand_trace_moment {q : ℕ} (hq : Even q) {ε : ℝ} (hε : 0 < ε) (p : κ → ι → ℝ) (h : κ → ℝ) {φ : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hpos : ∀ z, (hess φ z).PosDef) (hupper : ∀ z, ((4/ε) • (1 : Matrix ι ι ℝ)-hess φ z).PosSemidef) (heq : ∀ z, Real.log (hess φ z).det = potential ε p h (q+2) (grad φ z)+ Real.log (∫ x, Real.exp (-potential ε p h (q+2) x))-φ z) (Φ : Space ι ≃ₜ Space ι) (hΦ : (Φ : Space ι → Space ι) = grad φ) (hInv : ContDiff ℝ ∞ (Φ.symm : Space ι → Space ι)) (i : κ) : Integrable (fun x => (tau Φ φ x*hess (summand (p i) (h i) (q+2)) x).trace) (law ε p h (q+2)) ∧ (∫ x, (tau Φ φ x*hess (summand (p i) (h i) (q+2)) x).trace ∂law ε p h (q+2)) = ((q+2:ℕ):ℝ)*(∫ x, summand (p i) (h i) (q+2) x ∂law ε p h (q+2)) := by have hqe : Even (q+2) := hq.add even_two let : IsProbabilityMeasure (law ε p h (q+2)) := potential_probability hqe hε p h apply homogeneous_trace_moment volume hφ (smooth_potential ε p h (q+2)) (smooth_summand (p i) (h i) (q+2)) hpos (potential_partition_pos hqe hε p h) (div_nonneg (by norm_num) hε.le) hupper heq Φ hΦ hInv · exact fun j => integrable_pd_summand hqe hε p h (p i) (h i) (q+2) j · exact fun j => integrable_x_pd_summand hqe hε p h (p i) (h i) (q+2) j · exact fun j k => integrable_hess_summand hqe hε p h (p i) (h i) q j k · exact euler_summand (p i) (h i) (q+1) theorem compact_dual_bound {q : ℕ} (hq : Even q) {ε : ℝ} (hε : 0 < ε) (p : κ → ι → ℝ) (h : κ → ℝ) (hp : ∀ i, p i ≠ 0) (hh : ∀ i, 0 < h i) {φ f : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hf : ContDiff ℝ ∞ f) (hfc : HasCompactSupport f) (hpos : ∀ z, (hess φ z).PosDef) (hupper : ∀ z, ((4/ε) • (1 : Matrix ι ι ℝ)-hess φ z).PosSemidef) (heq : ∀ z, Real.log (hess φ z).det = potential ε p h (q+2) (grad φ z)+ Real.log (∫ x, Real.exp (-potential ε p h (q+2) x))-φ z) (Φ : Space ι ≃ₜ Space ι) (hΦ : (Φ : Space ι → Space ι) = grad φ) (hInv : ContDiff ℝ ∞ (Φ.symm : Space ι → Space ι)) (hmap : Measure.map (grad φ) (sourceMeasure volume φ) = law ε p h (q+2)) : (∑ i, (∫ x, summand (p i) (h i) (q+2) x * divergence (potential ε p h (q+2)) basis (wField Φ φ f) x ∂law ε p h (q+2))^2 / (∫ x, summand (p i) (h i) (q+2) x ∂law ε p h (q+2))) ≤ ∫ x, (divergence (potential ε p h (q+2)) basis (wField Φ φ f) x)^2 ∂law ε p h (q+2) := by let V := potential ε p h (q+2) let Z := ∫ x, Real.exp (-V x) let ψ (i : κ) := summand (p i) (h i) (q+2) have hqe : Even (q+2) := hq.add even_two have hV : ContDiff ℝ ∞ V := smooth_potential ε p h (q+2) have hZ : 0 < Z := potential_partition_pos hqe hε p h have hψ (i : κ) : ContDiff ℝ ∞ (ψ i) := smooth_summand (p i) (h i) (q+2) have hψpos (i : κ) (x : Space ι) : (hess (ψ i) x).PosSemidef := hess_summand_posSemidef hq (p i) (h i) x let : IsProbabilityMeasure (targetMeasure volume V Z) := potential_probability hqe hε p h have hhom (i : κ) (x : Space ι) : (∑ j, x j*pd j (ψ i) x) = ((q+2:ℕ):ℝ)*ψ i x := euler_summand (p i) (h i) (q+1) x have hhom₂ (i : κ) (x : Space ι) (j : ι) : (∑ k, hess (ψ i) x j k*x k) = (((q+2:ℕ):ℝ)-1)*pd j (ψ i) x := by have he : (((q+2:ℕ):ℝ)-1) = ((q+1:ℕ):ℝ) := by push_cast; ring rw [he] exact hessian_euler (p i) (h i) q x j have hm (i : κ) := summand_trace_moment hq hε p h hφ hpos hupper heq Φ hΦ hInv i apply compact_dual_generic (q := ((q+2 : ℕ) : ℝ)) (φ := φ) (V := V) (f := f) (Z := Z) (c := Real.log Z) volume ψ hφ hV hf hfc hψ hpos hψpos hZ (by exact_mod_cast (show 1 < q+2 by omega)) heq Φ hΦ hInv hmap · exact fun i => integrable_summand hqe hε p h (p i) (h i) (q+2) · exact fun i => mean_summand_pos hqe hε p h (hp i) (ne_of_gt (hh i)) hqe · exact hhom · exact hhom₂ · exact fun i => (hm i).1 · exact fun i => (hm i).2 · intro x change (hess (potential ε p h (q+2)) x-∑ i, hess (ψ i) x).PosSemidef rw [hess_potential] change (ε • (1 : Matrix ι ι ℝ)+(∑ i, hess (ψ i) x)-(∑ i, hess (ψ i) x)).PosSemidef rw [add_sub_cancel_right] exact Matrix.PosSemidef.one.smul hε.le end MomentSlab namespace LpVariance open MeasureTheory open scoped InnerProductSpace variable {X : Type*} {ι : Type*} [MeasurableSpace X] [Fintype ι] variable (μ : Measure X) lemma lp_inner (f g : Lp ℝ 2 μ) : inner ℝ f g = ∫ x, f x*g x ∂μ := by rw [L2.inner_def] apply integral_congr_ae filter_upwards [] with x rw [real_inner_comm] rfl lemma lp_norm_sq (f : Lp ℝ 2 μ) : ‖f‖^2 = ∫ x, (f x)^2 ∂μ := by rw [← real_inner_self_eq_norm_sq,lp_inner] simp only [sq] lemma toLp_inner {f g : X → ℝ} (hf : MemLp f 2 μ) (hg : MemLp g 2 μ) : inner ℝ (hf.toLp f) (hg.toLp g) = ∫ x, f x*g x ∂μ := by rw [lp_inner] apply integral_congr_ae filter_upwards [hf.coeFn_toLp,hg.coeFn_toLp] with x hx hy rw [hx,hy] lemma toLp_norm_sq {f : X → ℝ} (hf : MemLp f 2 μ) : ‖hf.toLp f‖^2 = ∫ x, (f x)^2 ∂μ := by rw [← real_inner_self_eq_norm_sq,toLp_inner] simp only [sq] theorem integral_dual_extend (a : ι → ℝ) (ψ : ι → X → ℝ) (hψ : ∀ i, MemLp (ψ i) 2 μ) (S : Set (Lp ℝ 2 μ)) (hS : ∀ u ∈ S, (∑ i, (∫ x, u x*ψ i x ∂μ)^2/a i) ≤ ∫ x, (u x)^2 ∂μ) {F : X → ℝ} (hF : MemLp F 2 μ) (hclosure : hF.toLp F ∈ closure S) : (∑ i, (∫ x, F x*ψ i x ∂μ)^2/a i) ≤ ∫ x, (F x)^2 ∂μ := by have hd := VarianceDuality.extend_dual_bound a (fun i => (hψ i).toLp (ψ i)) S (by intro u hu have hi (i : ι) : inner ℝ u ((hψ i).toLp (ψ i)) = ∫ x, u x*ψ i x ∂μ := by rw [lp_inner] apply integral_congr_ae filter_upwards [(hψ i).coeFn_toLp] with x hx rw [hx] simp_rw [hi,lp_norm_sq] exact hS u hu) hclosure simpa only [toLp_inner,toLp_norm_sq] using hd variable [IsProbabilityMeasure μ] def sumPotential (ψ : ι → X → ℝ) (b : ι → ℝ) (x : X) : ℝ := ∑ i, b i*ψ i x def centered (f : X → ℝ) (x : X) : ℝ := f x-∫ y, f y ∂μ omit [IsProbabilityMeasure μ] in lemma sum_memLp (ψ : ι → X → ℝ) (hψ : ∀ i, MemLp (ψ i) 2 μ) (b : ι → ℝ) : MemLp (sumPotential ψ b) 2 μ := by apply memLp_finsetSum intro i _ exact (hψ i).const_mul (b i) lemma centered_memLp {f : X → ℝ} (hf : MemLp f 2 μ) : MemLp (centered μ f) 2 μ := hf.sub (memLp_const _) lemma centered_integral {f : X → ℝ} (hf : Integrable f μ) : (∫ x, centered μ f x ∂μ)=0 := by change (∫ x, f x-(∫ y, f y ∂μ) ∂μ)=0 rw [integral_sub hf (integrable_const _),integral_const] simp lemma centered_sq {f : X → ℝ} (hf : MemLp f 2 μ) : (∫ x, (centered μ f x)^2 ∂μ) = (∫ x, (f x)^2 ∂μ)-(∫ x, f x ∂μ)^2 := by have hfi : Integrable f μ := MemLp.integrable (by norm_num) hf have he (x : X) : (centered μ f x)^2 = (f x)^2-(2*(∫ y, f y ∂μ))*f x+(∫ y, f y ∂μ)^2 := by dsimp [centered] ring simp_rw [he] rw [integral_add (f:=fun x => (f x)^2-(2*(∫ y, f y ∂μ))*f x) (g:=fun _ => (∫ y, f y ∂μ)^2) (hf.integrable_sq.sub (hfi.const_mul _)) (integrable_const _), integral_sub hf.integrable_sq (hfi.const_mul _),integral_const_mul,integral_const] simp only [probReal_univ,one_smul] ring lemma centered_pair_sum (ψ : ι → X → ℝ) (hψ : ∀ i, MemLp (ψ i) 2 μ) (b : ι → ℝ) : (∑ i, b i*(∫ x, centered μ (sumPotential ψ b) x*ψ i x ∂μ)) = ∫ x, (centered μ (sumPotential ψ b) x)^2 ∂μ := by let F := sumPotential ψ b have hF : MemLp F 2 μ := sum_memLp μ ψ hψ b have hC := centered_memLp μ hF have hCi : Integrable (centered μ F) μ := MemLp.integrable (by norm_num) hC have hpair : (∫ x, centered μ F x*F x ∂μ) = ∫ x, (centered μ F x)^2 ∂μ := by have he (x : X) : centered μ F x*F x = (centered μ F x)^2 + (∫ y, F y ∂μ)*centered μ F x := by dsimp [centered] ring simp_rw [he] rw [integral_add hC.integrable_sq (hCi.const_mul _),integral_const_mul, centered_integral μ (MemLp.integrable (by norm_num) hF)] ring rw [← hpair] change _ = ∫ x, centered μ F x*(∑ i, b i*ψ i x) ∂μ simp_rw [Finset.mul_sum] rw [integral_finsetSum _ (fun i _ => by simpa only [Pi.mul_apply,mul_left_comm] using (hC.integrable_mul (hψ i)).const_mul (b i))] apply Finset.sum_congr rfl intro i _ rw [← integral_const_mul] apply integral_congr_ae filter_upwards [] with x ring theorem variance_of_centered_dual (a : ι → ℝ) (ha : ∀ i, 0 < a i) (ψ : ι → X → ℝ) (hψ : ∀ i, MemLp (ψ i) 2 μ) (b : ι → ℝ) (hd : (∑ i, (∫ x, centered μ (sumPotential ψ b) x*ψ i x ∂μ)^2/a i) ≤ ∫ x, (centered μ (sumPotential ψ b) x)^2 ∂μ) : (∫ x, (sumPotential ψ b x)^2 ∂μ)-(∫ x, sumPotential ψ b x ∂μ)^2 ≤ ∑ i, b i^2*a i := by let d (i : ι) := ∫ x, centered μ (sumPotential ψ b) x*ψ i x ∂μ let v := ∫ x, (centered μ (sumPotential ψ b) x)^2 ∂μ have hv : 0 ≤ v := integral_nonneg (fun x => sq_nonneg _) have hpair : (∑ i, b i*d i)=v := centered_pair_sum μ ψ hψ b have hc := VarianceDuality.weighted_coefficient_cs a b d ha rw [hpair] at hc have hnon : 0 ≤ ∑ i, b i^2*a i := Finset.sum_nonneg (fun i _ => mul_nonneg (sq_nonneg _) (ha i).le) have hm := mul_le_mul_of_nonneg_left hd hnon have hvbound : v ≤ ∑ i, b i^2*a i := by by_cases hv0 : v=0 · simpa [hv0] using hnon · have hvp : 0 < v := lt_of_le_of_ne hv (Ne.symm hv0) change v^2 ≤ _ at hc change _ ≤ (∑ i, b i^2*a i)*v at hm nlinarith rw [← centered_sq μ (sum_memLp μ ψ hψ b)] exact hvbound end LpVariance namespace PositiveDensity open MeasureTheory variable {E : Type*} [MeasurableSpace E] [TopologicalSpace E] lemma isOpenPos (μ : Measure E) [Measure.IsOpenPosMeasure μ] {ρ : E → ℝ} (hm : Measurable ρ) (hp : ∀ x, 0 < ρ x) : Measure.IsOpenPosMeasure (μ.withDensity (fun x => ENNReal.ofReal (ρ x))) := by have hac : μ ≪ μ.withDensity (fun x => ENNReal.ofReal (ρ x)) := withDensity_absolutelyContinuous' (ENNReal.measurable_ofReal.comp hm).aemeasurable (Filter.Eventually.of_forall fun x => (ENNReal.ofReal_pos.mpr (hp x)).ne') constructor intro U hU hne hz exact hU.measure_ne_zero μ hne (hac hz) end PositiveDensity namespace SoftSlab open MeasureTheory WeightedCalculus MomentCoordinates TargetCoordinates open scoped ContDiff variable {ι : Type*} {κ : Type*} [Fintype ι] [DecidableEq ι] [Fintype κ] omit [DecidableEq ι] in lemma summand_memLp {q : ℕ} (hq : Even q) {ε : ℝ} (hε : 0 < ε) (p : κ → ι → ℝ) (h : κ → ℝ) (v : ι → ℝ) (r : ℝ) (m : ℕ) : MemLp (summand v r m) 2 (law ε p h q) := by rw [memLp_two_iff_integrable_sq ((smooth_summand v r m).continuous.aestronglyMeasurable)] have hi := integrable_summand hq hε p h v r (m*2) change Integrable (fun x => (linear v x/r)^(m*2)) _ at hi simpa only [summand,pow_mul] using hi omit [DecidableEq ι] in lemma potential_nonneg {q : ℕ} (hq : Even q) {ε : ℝ} (hε : 0 ≤ ε) (p : κ → ι → ℝ) (h : κ → ℝ) (x : Space ι) : 0 ≤ potential ε p h q x := by apply le_trans _ (potential_lower hq ε p h x) exact mul_nonneg (div_nonneg hε (by norm_num)) (Finset.sum_nonneg (fun i _ => sq_nonneg _)) omit [DecidableEq ι] in lemma law_openPos {q : ℕ} (hq : Even q) {ε : ℝ} (hε : 0 < ε) (p : κ → ι → ℝ) (h : κ → ℝ) : Measure.IsOpenPosMeasure (law ε p h q) := by apply PositiveDensity.isOpenPos volume · exact ((smooth_weight (smooth_potential ε p h q)).div_const _).continuous.measurable · exact fun x => div_pos (Real.exp_pos _) (potential_partition_pos hq hε p h) end SoftSlab namespace MomentSlab open MeasureTheory WeightedCalculus MomentCoordinates TargetCoordinates SoftSlab FullTensor open scoped ContDiff variable {ι : Type*} {κ : Type*} [Fintype ι] [DecidableEq ι] [Fintype κ] lemma square_double_divergence {φ V f : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hV : ContDiff ℝ ∞ V) (hf : ContDiff ℝ ∞ f) (hne : ∀ z, (hess φ z).det ≠ 0) {c : ℝ} (heq : ∀ z, Real.log (hess φ z).det = V (grad φ z)+c-φ z) (Φ : Space ι ≃ₜ Space ι) (hΦ : (Φ : Space ι → Space ι) = grad φ) (hInv : ContDiff ℝ ∞ (Φ.symm : Space ι → Space ι)) : RealSmoothOperator.operator (MatrixOperator.principal (MomentOperator.tau Φ φ) (MomentKernel.smooth_tau hφ Φ hInv)++MatrixOperator.drift) (RealSmoothOperator.operator (MatrixOperator.principal (MomentOperator.tau Φ φ) (MomentKernel.smooth_tau hφ Φ hInv)++MatrixOperator.drift) f-f) = divergence V basis (wField Φ φ f) := by rw [MatrixOperator.operator_actual,MatrixOperator.operator_actual, MomentKernel.matrix_A_eq,MomentKernel.matrix_A_eq,← MomentKernel.A_eq_density (φ:=φ) hf Φ] change DensityEnergy.A (MomentOperator.tau Φ φ) (fun x => MomentOperator.A Φ φ f x-f x) = _ rw [← MomentKernel.A_eq_density (φ:=φ) ((MomentOperator.smooth_A hφ hf Φ hΦ hInv).sub hf) Φ] exact (MomentOperator.double_divergence hφ hV hf hne heq Φ hΦ hInv).symm lemma range_dual_bound {q : ℕ} (hq : Even q) {ε : ℝ} (hε : 0 < ε) (p : κ → ι → ℝ) (h : κ → ℝ) (hp : ∀ i, p i ≠ 0) (hh : ∀ i, 0 < h i) {φ : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hpos : ∀ z, (hess φ z).PosDef) (hupper : ∀ z, ((4/ε) • (1 : Matrix ι ι ℝ)-hess φ z).PosSemidef) (heq : ∀ z, Real.log (hess φ z).det = potential ε p h (q+2) (grad φ z)+ Real.log (∫ x, Real.exp (-potential ε p h (q+2) x))-φ z) (Φ : Space ι ≃ₜ Space ι) (hΦ : (Φ : Space ι → Space ι) = grad φ) (hInv : ContDiff ℝ ∞ (Φ.symm : Space ι → Space ι)) (hmap : Measure.map (grad φ) (sourceMeasure volume φ) = law ε p h (q+2)) [IsFiniteMeasureOnCompacts (law ε p h (q+2))] (u : Lp ℝ 2 (law ε p h (q+2))) (hu : u ∈ RealSmoothOperator.squareRange (E:=Space ι) (law ε p h (q+2)) (MatrixOperator.principal (MomentOperator.tau Φ φ) (MomentKernel.smooth_tau hφ Φ hInv)++ MatrixOperator.drift)) : (∑ i, (∫ x, u x*summand (p i) (h i) (q+2) x ∂law ε p h (q+2))^2 / (∫ x, summand (p i) (h i) (q+2) x ∂law ε p h (q+2))) ≤ ∫ x, (u x)^2 ∂law ε p h (q+2) := by obtain ⟨f,rfl⟩ := hu have hae := RealSmoothOperator.squareLp_coe (E:=Space ι) (law ε p h (q+2)) (MatrixOperator.principal (MomentOperator.tau Φ φ) (MomentKernel.smooth_tau hφ Φ hInv)++ MatrixOperator.drift) f rw [square_double_divergence hφ (smooth_potential ε p h (q+2)) (RealSmoothOperator.tests_smooth f) (fun z => (hpos z).det_pos.ne') heq Φ hΦ hInv] at hae have hd := compact_dual_bound hq hε p h hp hh hφ (RealSmoothOperator.tests_smooth f) (RealSmoothOperator.tests_compact f) hpos hupper heq Φ hΦ hInv hmap convert hd using 1 · apply Finset.sum_congr rfl intro i _ congr 2 apply integral_congr_ae filter_upwards [hae] with x hx rw [hx,mul_comm] · apply integral_congr_ae filter_upwards [hae] with x hx rw [hx] theorem variance_from_moment {q : ℕ} (hq : Even q) {ε : ℝ} (hε : 0 < ε) (p : κ → ι → ℝ) (h : κ → ℝ) (hp : ∀ i, p i ≠ 0) (hh : ∀ i, 0 < h i) {φ : Space ι → ℝ} (hφ : ContDiff ℝ ∞ φ) (hpos : ∀ z, (hess φ z).PosDef) (hupper : ∀ z, ((4/ε) • (1 : Matrix ι ι ℝ)-hess φ z).PosSemidef) (heq : ∀ z, Real.log (hess φ z).det = potential ε p h (q+2) (grad φ z)+ Real.log (∫ x, Real.exp (-potential ε p h (q+2) x))-φ z) (Φ : Space ι ≃ₜ Space ι) (hΦ : (Φ : Space ι → Space ι) = grad φ) (hInv : ContDiff ℝ ∞ (Φ.symm : Space ι → Space ι)) (hmap : Measure.map (grad φ) (sourceMeasure volume φ) = law ε p h (q+2)) (b : κ → ℝ) : (∫ x, (∑ i, b i*summand (p i) (h i) (q+2) x)^2 ∂law ε p h (q+2))- (∫ x, ∑ i, b i*summand (p i) (h i) (q+2) x ∂law ε p h (q+2))^2 ≤ ∑ i, b i^2*(∫ x, summand (p i) (h i) (q+2) x ∂law ε p h (q+2)) := by let V := potential ε p h (q+2) let Z := ∫ x, Real.exp (-V x) let μ := law ε p h (q+2) let ψ (i : κ) := summand (p i) (h i) (q+2) have hqe := hq.add even_two let : IsProbabilityMeasure μ := potential_probability hqe hε p h let : Measure.IsOpenPosMeasure μ := law_openPos hqe hε p h let : IsProbabilityMeasure (targetMeasure volume V Z) := potential_probability hqe hε p h let : Measure.IsOpenPosMeasure (targetMeasure volume V Z) := law_openPos hqe hε p h have hψ (i : κ) : MemLp (ψ i) 2 μ := summand_memLp hqe hε p h (p i) (h i) (q+2) let F := LpVariance.centered μ (LpVariance.sumPotential ψ b) have hF : MemLp F 2 μ := LpVariance.centered_memLp μ (LpVariance.sum_memLp μ ψ hψ b) have hFe : ∀ x, F (-x)=F x := by intro x change (∑ i, b i*ψ i (-x)) - _ = (∑ i, b i*ψ i x) - _ congr 1 apply Finset.sum_congr rfl intro i _ rw [show ψ i (-x)=ψ i x from summand_even hqe (p i) (h i) x] have hFc : (∫ x, F x ∂μ)=0 := LpVariance.centered_integral μ (MemLp.integrable (by norm_num) (LpVariance.sum_memLp μ ψ hψ b)) have hclosure := MomentKernel.centered_even_mem_closure (ι:=ι) (φ:=φ) (V:=V) (Z:=Z) (Λ:=4/ε) (m:=0) hφ (smooth_potential ε p h (q+2)) (potential_even hqe ε p h) hpos (potential_partition_pos hqe hε p h) (potential_nonneg hqe hε.le p h) (div_nonneg (by norm_num) hε.le) hupper heq Φ hΦ hInv hmap hF hFe hFc apply LpVariance.variance_of_centered_dual μ (fun i => ∫ x, ψ i x ∂μ) (fun i => mean_summand_pos hqe hε p h (hp i) (ne_of_gt (hh i)) hqe) ψ hψ b apply LpVariance.integral_dual_extend μ (fun i => ∫ x, ψ i x ∂μ) ψ hψ ((RealSmoothOperator.squareRange (E:=Space ι) μ (MatrixOperator.principal (MomentOperator.tau Φ φ) (MomentKernel.smooth_tau hφ Φ hInv)++MatrixOperator.drift)) : Set (Lp ℝ 2 μ)) (fun u hu => range_dual_bound hq hε p h hp hh hφ hpos hupper heq Φ hΦ hInv hmap u hu) hF exact hclosure end MomentSlab end end section open Set MeasureTheory open scoped ENNReal InnerProductSpace namespace LogBrunnMinkowski def MainStatement : Prop := ∀ (n : ℕ), 1 ≤ n → ∀ (K L : Set (Space n)), IsConvexBody K → IsConvexBody L → OriginSymmetric K → OriginSymmetric L → ∀ (t : ℝ), 0 ≤ t → t ≤ 1 → (volume K) ^ (1 - t) * (volume L) ^ t ≤ volume (logCombination K L t) lemma body_nonempty {n : ℕ} {K : Set (Space n)} (hK : IsConvexBody K) : K.Nonempty := hK.2.2.mono interior_subset lemma support_attained {n : ℕ} {K : Set (Space n)} (hK : IsConvexBody K) (u : Space n) : ∃ x ∈ K, ⟪x, u⟫_ℝ = support K u := by have hc : Continuous (fun x : Space n => ⟪x, u⟫_ℝ) := continuous_id.inner continuous_const exact (hK.1.image hc).sSup_mem ((body_nonempty hK).image _) lemma inner_le_support {n : ℕ} {K : Set (Space n)} (hK : IsConvexBody K) {x : Space n} (hx : x ∈ K) (u : Space n) : ⟪x, u⟫_ℝ ≤ support K u := by apply le_csSup · exact hK.1.bddAbove_image (continuous_id.inner continuous_const).continuousOn · exact mem_image_of_mem _ hx lemma support_le_iff {n : ℕ} {K : Set (Space n)} (hK : IsConvexBody K) (u : Space n) (a : ℝ) : support K u ≤ a ↔ ∀ x ∈ K, ⟪x, u⟫_ℝ ≤ a := by constructor · intro h x hx exact (inner_le_support hK hx u).trans h · intro h exact csSup_le ((body_nonempty hK).image _) (by rintro y ⟨x, hx, rfl⟩ exact h x hx) lemma support_zero {n : ℕ} {K : Set (Space n)} (hK : IsConvexBody K) : support K 0 = 0 := by obtain ⟨x, hx, h⟩ := support_attained hK 0 simpa using h.symm lemma support_smul {n : ℕ} {K : Set (Space n)} (hK : IsConvexBody K) (u : Space n) {a : ℝ} (ha : 0 ≤ a) : support K (a • u) = a * support K u := by apply le_antisymm · apply (support_le_iff hK _ _).2 intro x hx simpa only [inner_smul_right] using mul_le_mul_of_nonneg_left (inner_le_support hK hx u) ha · obtain ⟨x, hx, h⟩ := support_attained hK u have h' := inner_le_support hK hx (a • u) simpa only [inner_smul_right, h] using h' lemma interior_neg_mem {n : ℕ} {K : Set (Space n)} (hK : OriginSymmetric K) {x : Space n} (hx : x ∈ interior K) : -x ∈ interior K := by have hsub : (fun y : Space n => -y) ⁻¹' interior K ⊆ interior K := by apply interior_maximal · intro y hy exact (hK y).mpr (interior_subset hy) · exact isOpen_interior.preimage continuous_neg apply hsub simpa only [mem_preimage, neg_neg] using hx lemma zero_mem_interior {n : ℕ} {K : Set (Space n)} (hK : IsConvexBody K) (hsK : OriginSymmetric K) : (0 : Space n) ∈ interior K := by obtain ⟨x, hx⟩ := hK.2.2 have h := hK.2.1.interior hx (interior_neg_mem hsK hx) (by norm_num : (0 : ℝ) ≤ 1 / 2) (by norm_num : (0 : ℝ) ≤ 1 / 2) (by norm_num : (1 / 2 : ℝ) + 1 / 2 = 1) simpa only [smul_neg, add_neg_cancel] using h lemma positive_support {n : ℕ} {K : Set (Space n)} (hK : IsConvexBody K) (hsK : OriginSymmetric K) {u : Space n} (hu : ‖u‖ = 1) : 0 < support K u := by obtain ⟨r, hr, hball⟩ := Metric.isOpen_iff.mp isOpen_interior 0 (zero_mem_interior hK hsK) have hru : (r / 2) • u ∈ Metric.ball (0 : Space n) r := by rw [Metric.mem_ball, dist_zero_right, norm_smul, Real.norm_eq_abs, hu, mul_one, abs_of_pos (by positivity : 0 < r / 2)] linarith have h := inner_le_support hK (interior_subset (hball hru)) u have huu : ⟪u,u⟫_ℝ = 1 := by rw [real_inner_self_eq_norm_sq, hu]; norm_num rw [inner_smul_left, huu] at h norm_num at h exact lt_of_lt_of_le (by positivity : 0 < r / 2) h lemma mem_wulff_support_iff {n : ℕ} {K : Set (Space n)} (hK : IsConvexBody K) (x : Space n) : x ∈ wulff (support K) ↔ x ∈ K := by constructor · intro hx by_contra hnot obtain ⟨f, a, hf, hfx⟩ := geometric_hahn_banach_closed_point hK.2.1 hK.1.isClosed hnot let u := (InnerProductSpace.toDual ℝ (Space n)).symm f have hu : ∀ y, ⟪y,u⟫_ℝ = f y := by intro y rw [real_inner_comm] exact InnerProductSpace.toDual_symm_apply have hsep : support K u < ⟪x,u⟫_ℝ := by obtain ⟨y, hy, heq⟩ := support_attained hK u rw [← heq, hu, hu] exact (hf y hy).trans hfx have hune : u ≠ 0 := by intro hz simp only [hz, support_zero hK, inner_zero_right, lt_self_iff_false] at hsep have hnorm : 0 < ‖u‖ := norm_pos_iff.mpr hune have hv : ‖‖u‖⁻¹ • u‖ = 1 := by rw [norm_smul, Real.norm_eq_abs, abs_of_pos (inv_pos.mpr hnorm), inv_mul_cancel₀ hnorm.ne'] have hbound := hx (‖u‖⁻¹ • u) hv rw [inner_smul_right, support_smul hK u (le_of_lt (inv_pos.mpr hnorm))] at hbound have hp : 0 < ‖u‖⁻¹ := inv_pos.mpr hnorm nlinarith · intro hx u _ exact inner_le_support hK hx u lemma wulff_support {n : ℕ} {K : Set (Space n)} (hK : IsConvexBody K) : wulff (support K) = K := by ext x exact mem_wulff_support_iff hK x lemma logCombination_zero {n : ℕ} {K L : Set (Space n)} (hK : IsConvexBody K) : logCombination K L 0 = K := by simp only [logCombination, sub_zero, Real.rpow_one, Real.rpow_zero, mul_one] exact wulff_support hK lemma logCombination_one {n : ℕ} {K L : Set (Space n)} (hL : IsConvexBody L) : logCombination K L 1 = L := by simp only [logCombination, sub_self, Real.rpow_zero, Real.rpow_one, one_mul] exact wulff_support hL lemma main_at_zero {n : ℕ} {K L : Set (Space n)} (hK : IsConvexBody K) : (volume K) ^ (1 - (0 : ℝ)) * (volume L) ^ (0 : ℝ) ≤ volume (logCombination K L 0) := by simp [logCombination_zero hK] lemma main_at_one {n : ℕ} {K L : Set (Space n)} (hL : IsConvexBody L) : (volume K) ^ (1 - (1 : ℝ)) * (volume L) ^ (1 : ℝ) ≤ volume (logCombination K L 1) := by simp [logCombination_one hL] lemma body_volume_pos {n : ℕ} {K : Set (Space n)} (hK : IsConvexBody K) : 0 < volume K := MeasureTheory.Measure.measure_pos_of_nonempty_interior _ hK.2.2 lemma body_volume_ne_top {n : ℕ} {K : Set (Space n)} (hK : IsConvexBody K) : volume K ≠ ⊤ := hK.1.measure_ne_top lemma support_continuous {n : ℕ} {K : Set (Space n)} (hK : IsConvexBody K) : Continuous (support K) := by exact hK.1.continuous_sSup (continuous_snd.inner continuous_fst) lemma support_neg {n : ℕ} {K : Set (Space n)} (hK : IsConvexBody K) (hsK : OriginSymmetric K) (u : Space n) : support K (-u) = support K u := by apply le_antisymm · apply (support_le_iff hK _ _).2 intro x hx simpa only [inner_neg_left, inner_neg_right] using inner_le_support hK ((hsK x).mp hx) u · apply (support_le_iff hK _ _).2 intro x hx simpa only [inner_neg_left, inner_neg_right, neg_neg] using inner_le_support hK ((hsK x).mp hx) (-u) abbrev UnitSphere (n : ℕ) := {u : Space n // ‖u‖ = 1} lemma unitSphere_nonempty {n : ℕ} (hn : 1 ≤ n) : Nonempty (UnitSphere n) := by let i : Fin n := ⟨0, hn⟩ exact ⟨⟨EuclideanSpace.basisFun (Fin n) ℝ i, (EuclideanSpace.basisFun (Fin n) ℝ).norm_eq_one i⟩⟩ def finiteSlabs {n : ℕ} (D : Finset (Space n)) (f : Space n → ℝ) : Set (Space n) := {x | ∀ u ∈ D, |⟪x, u⟫_ℝ| ≤ f u} lemma finiteSlabs_closed {n : ℕ} (D : Finset (Space n)) (f : Space n → ℝ) : IsClosed (finiteSlabs D f) := by simp only [finiteSlabs, ofPred_forall] exact isClosed_iInter fun u => isClosed_iInter fun _ => isClosed_le (continuous_id.inner continuous_const).abs continuous_const lemma finiteSlabs_compact {n : ℕ} (D : Finset (Space n)) (f : Space n → ℝ) (hD : ∀ i : Fin n, EuclideanSpace.basisFun (Fin n) ℝ i ∈ D) : IsCompact (finiteSlabs D f) := by let b := EuclideanSpace.basisFun (Fin n) ℝ let box : Set (Fin n → ℝ) := {x | ∀ i, x i ∈ Icc (-f (b i)) (f (b i))} have hc : IsCompact box := isCompact_pi_infinite fun _ => isCompact_Icc apply ((PiLp.homeomorph 2 (fun _ : Fin n => ℝ)).isCompact_preimage.mpr hc).of_isClosed_subset (finiteSlabs_closed D f) intro x hx i have hi := hx (b i) (hD i) rw [EuclideanSpace.inner_basisFun_real] at hi exact abs_le.mp hi noncomputable def directions {n : ℕ} (d : ℕ → UnitSphere n) (m : ℕ) : Finset (Space n) := (Finset.univ.image (EuclideanSpace.basisFun (Fin n) ℝ)) ∪ ((Finset.range m).image (fun i => (d i).val)) lemma basis_mem_directions {n : ℕ} (d : ℕ → UnitSphere n) (m : ℕ) (i : Fin n) : EuclideanSpace.basisFun (Fin n) ℝ i ∈ directions d m := by classical simp only [directions, Finset.mem_union, Finset.mem_image, Finset.mem_univ, true_and] exact Or.inl ⟨i, rfl⟩ lemma dense_mem_directions {n : ℕ} (d : ℕ → UnitSphere n) (i : ℕ) : (d i).val ∈ directions d (i + 1) := by classical apply Finset.mem_union_right exact Finset.mem_image.mpr ⟨i, Finset.mem_range.mpr (Nat.lt_succ_self i), rfl⟩ lemma directions_unit {n : ℕ} (d : ℕ → UnitSphere n) (m : ℕ) {u : Space n} (hu : u ∈ directions d m) : ‖u‖ = 1 := by classical rcases Finset.mem_union.mp hu with hu | hu · obtain ⟨i, _, rfl⟩ := Finset.mem_image.mp hu exact (EuclideanSpace.basisFun (Fin n) ℝ).norm_eq_one i · obtain ⟨i, _, rfl⟩ := Finset.mem_image.mp hu exact (d i).property lemma directions_mono {n : ℕ} (d : ℕ → UnitSphere n) : Monotone (directions d) := by classical intro i j hij exact Finset.union_subset_union (Finset.Subset.refl _) (Finset.image_subset_image (Finset.range_mono hij)) lemma finiteSlabs_antitone {n : ℕ} (d : ℕ → UnitSphere n) (f : Space n → ℝ) : Antitone (fun m => finiteSlabs (directions d m) f) := by intro i j hij x hx u hu exact hx u (directions_mono d hij hu) lemma iInter_finiteSlabs_eq_wulff {n : ℕ} {d : ℕ → UnitSphere n} (hd : DenseRange d) {f : Space n → ℝ} (hf : Continuous (fun u : UnitSphere n => f u.val)) (heven : ∀ u, f (-u) = f u) : (⋂ m, finiteSlabs (directions d m) f) = wulff f := by ext x constructor · intro hx u hu have hclosed : IsClosed {u : UnitSphere n | |⟪x, u.val⟫_ℝ| ≤ f u.val} := isClosed_le (continuous_const.inner continuous_subtype_val).abs hf have hall : ∀ u : UnitSphere n, |⟪x, u.val⟫_ℝ| ≤ f u.val := by intro u exact hd.induction_on u hclosed (fun i => (mem_iInter.mp hx (i + 1)) (d i).val (dense_mem_directions d i)) exact (le_abs_self _).trans (hall ⟨u, hu⟩) · intro hx apply mem_iInter.mpr intro m u hu have hunit := directions_unit d m hu apply abs_le.mpr constructor · have hneg := hx (-u) (by simpa using hunit) rw [inner_neg_right, heven] at hneg linarith · exact hx u hunit lemma tendsto_volume_finiteSlabs {n : ℕ} {d : ℕ → UnitSphere n} (hd : DenseRange d) {f : Space n → ℝ} (hf : Continuous (fun u : UnitSphere n => f u.val)) (heven : ∀ u, f (-u) = f u) : Filter.Tendsto (fun m => volume (finiteSlabs (directions d m) f)) Filter.atTop (nhds (volume (wulff f))) := by rw [← iInter_finiteSlabs_eq_wulff hd hf heven] exact tendsto_measure_iInter_atTop (fun m => (finiteSlabs_closed (directions d m) f).measurableSet.nullMeasurableSet) (finiteSlabs_antitone d f) ⟨0, (finiteSlabs_compact _ f (basis_mem_directions d 0)).measure_ne_top⟩ noncomputable def interpolatedSupport {n : ℕ} (K L : Set (Space n)) (t : ℝ) (u : Space n) : ℝ := support K u ^ (1 - t) * support L u ^ t lemma interpolatedSupport_sphere_continuous {n : ℕ} {K L : Set (Space n)} (hK : IsConvexBody K) (hL : IsConvexBody L) (hsK : OriginSymmetric K) (hsL : OriginSymmetric L) (t : ℝ) : Continuous (fun u : UnitSphere n => interpolatedSupport K L t u.val) := by apply Continuous.mul · exact ((support_continuous hK).comp continuous_subtype_val).rpow_const (fun u => Or.inl (positive_support hK hsK u.property).ne') · exact ((support_continuous hL).comp continuous_subtype_val).rpow_const (fun u => Or.inl (positive_support hL hsL u.property).ne') lemma interpolatedSupport_even {n : ℕ} {K L : Set (Space n)} (hK : IsConvexBody K) (hL : IsConvexBody L) (hsK : OriginSymmetric K) (hsL : OriginSymmetric L) (t : ℝ) (u : Space n) : interpolatedSupport K L t (-u) = interpolatedSupport K L t u := by simp only [interpolatedSupport, support_neg hK hsK, support_neg hL hsL] lemma main_of_finite_slabs {n : ℕ} (hn : 1 ≤ n) {K L : Set (Space n)} (hK : IsConvexBody K) (hL : IsConvexBody L) (hsK : OriginSymmetric K) (hsL : OriginSymmetric L) {t : ℝ} (ht0 : 0 ≤ t) (ht1 : t ≤ 1) (hslabs : ∀ D : Finset (Space n), (∀ i : Fin n, EuclideanSpace.basisFun (Fin n) ℝ i ∈ D) → (∀ u ∈ D, ‖u‖ = 1) → volume (finiteSlabs D (support K)) ^ (1 - t) * volume (finiteSlabs D (support L)) ^ t ≤ volume (finiteSlabs D (interpolatedSupport K L t))) : volume K ^ (1 - t) * volume L ^ t ≤ volume (logCombination K L t) := by let : Nonempty (UnitSphere n) := unitSphere_nonempty hn obtain ⟨d, hd⟩ := TopologicalSpace.exists_dense_seq (UnitSphere n) have hKlim := tendsto_volume_finiteSlabs hd ((support_continuous hK).comp continuous_subtype_val) (support_neg hK hsK) have hLlim := tendsto_volume_finiteSlabs hd ((support_continuous hL).comp continuous_subtype_val) (support_neg hL hsL) rw [wulff_support hK] at hKlim rw [wulff_support hL] at hLlim have hTlim := tendsto_volume_finiteSlabs hd (interpolatedSupport_sphere_continuous hK hL hsK hsL t) (interpolatedSupport_even hK hL hsK hsL t) have hprod := ENNReal.Tendsto.mul (hKlim.ennrpow_const (1 - t)) (Or.inr (ENNReal.rpow_ne_top_of_nonneg ht0 (body_volume_ne_top hL))) (hLlim.ennrpow_const t) (Or.inr (ENNReal.rpow_ne_top_of_nonneg (sub_nonneg.mpr ht1) (body_volume_ne_top hK))) exact le_of_tendsto_of_tendsto hprod hTlim (Filter.Eventually.of_forall (fun m => hslabs _ (basis_mem_directions d m) (fun _ hu => directions_unit d m hu))) noncomputable def oneEquiv : Space 1 ≃ₗᵢ[ℝ] ℝ := (OrthonormalBasis.singleton (Fin 1) ℝ).repr.symm noncomputable def oneDirection : Space 1 := oneEquiv.symm 1 lemma oneDirection_norm : ‖oneDirection‖ = 1 := by simp [oneDirection] lemma inner_oneDirection (x : Space 1) : ⟪x, oneDirection⟫_ℝ = oneEquiv x := by rw [← oneEquiv.inner_map_map] simp [oneDirection] lemma sphere_one_cases {u : Space 1} (hu : ‖u‖ = 1) : u = oneDirection ∨ u = -oneDirection := by have habs : |oneEquiv u| = 1 := by rw [← Real.norm_eq_abs, oneEquiv.norm_map, hu] rcases (abs_eq (by norm_num : (0 : ℝ) ≤ 1)).mp habs with h | h · left apply oneEquiv.injective simpa [oneDirection] using h · right apply oneEquiv.injective simpa [oneDirection] using h lemma wulff_one_eq {f : Space 1 → ℝ} (heven : ∀ u, f (-u) = f u) : wulff f = oneEquiv ⁻¹' Icc (-f oneDirection) (f oneDirection) := by ext x constructor · intro hx have hp := hx oneDirection oneDirection_norm have hn := hx (-oneDirection) (by simpa using oneDirection_norm) rw [inner_oneDirection] at hp rw [inner_neg_right, inner_oneDirection, heven] at hn exact ⟨by linarith, hp⟩ · intro hx u hu rcases sphere_one_cases hu with rfl | rfl · simpa only [inner_oneDirection] using hx.2 · rw [inner_neg_right, inner_oneDirection, heven] linarith [hx.1] lemma volume_wulff_one {f : Space 1 → ℝ} (heven : ∀ u, f (-u) = f u) : volume (wulff f) = ENNReal.ofReal (2 * f oneDirection) := by rw [wulff_one_eq heven, oneEquiv.measurePreserving.measure_preimage measurableSet_Icc.nullMeasurableSet, Real.volume_Icc] congr 1 ring lemma main_dimension_one {K L : Set (Space 1)} (hK : IsConvexBody K) (hL : IsConvexBody L) (hsK : OriginSymmetric K) (hsL : OriginSymmetric L) {t : ℝ} (ht0 : 0 ≤ t) (ht1 : t ≤ 1) : volume (logCombination K L t) = volume K ^ (1 - t) * volume L ^ t := by have ha := positive_support hK hsK oneDirection_norm have hb := positive_support hL hsL oneDirection_norm have hvK : volume K = ENNReal.ofReal (2 * support K oneDirection) := by conv_lhs => rw [← wulff_support hK] exact volume_wulff_one (support_neg hK hsK) have hvL : volume L = ENNReal.ofReal (2 * support L oneDirection) := by conv_lhs => rw [← wulff_support hL] exact volume_wulff_one (support_neg hL hsL) have hreal : (2 * support K oneDirection) ^ (1 - t) * (2 * support L oneDirection) ^ t = 2 * (support K oneDirection ^ (1 - t) * support L oneDirection ^ t) := by rw [Real.mul_rpow (by norm_num) ha.le, Real.mul_rpow (by norm_num) hb.le] calc _ = ((2 : ℝ) ^ (1 - t) * 2 ^ t) * (support K oneDirection ^ (1 - t) * support L oneDirection ^ t) := by ring _ = _ := by rw [← Real.rpow_add (by norm_num : (0 : ℝ) < 2), sub_add_cancel, Real.rpow_one] change volume (wulff (interpolatedSupport K L t)) = _ rw [volume_wulff_one (interpolatedSupport_even hK hL hsK hsL t), hvK, hvL, ENNReal.ofReal_rpow_of_nonneg (by positivity) (sub_nonneg.mpr ht1), ENNReal.ofReal_rpow_of_nonneg (by positivity) ht0, ← ENNReal.ofReal_mul (by positivity), hreal] rfl end LogBrunnMinkowski open MeasureTheory open scoped BigOperators noncomputable section namespace SlabPartition open Set MeasureTheory open scoped BigOperators variable {ι : Type*} {κ : Type*} [Fintype ι] [Fintype κ] def derivativePoly (ψ : κ → MvPolynomial ι ℝ) (b : κ → ℝ) (k : ℕ) (t : ℝ) : MvPolynomial ι ℝ := ∑ i, MvPolynomial.C (b i ^ k * Real.exp (b i * t)) * ψ i def variation (ψ : κ → MvPolynomial ι ℝ) (b : κ → ℝ) (k : ℕ) (t : ℝ) (x : ι → ℝ) : ℝ := MvPolynomial.eval x (derivativePoly ψ b k t) omit [Fintype ι] in lemma variation_eq (ψ : κ → MvPolynomial ι ℝ) (b : κ → ℝ) (k : ℕ) (t : ℝ) (x : ι → ℝ) : variation ψ b k t x = ∑ i, b i ^ k * Real.exp (b i * t) * MvPolynomial.eval x (ψ i) := by simp [variation, derivativePoly] omit [Fintype ι] in lemma variation_continuous (ψ : κ → MvPolynomial ι ℝ) (b : κ → ℝ) (k : ℕ) (t : ℝ) : Continuous (variation ψ b k t) := MvPolynomial.continuous_eval _ omit [Fintype ι] in lemma variation_hasDerivAt (ψ : κ → MvPolynomial ι ℝ) (b : κ → ℝ) (k : ℕ) (t : ℝ) (x : ι → ℝ) : HasDerivAt (fun s => variation ψ b k s x) (variation ψ b (k+1) t x) t := by have hi (i : κ) : HasDerivAt (fun s => b i ^ k * Real.exp (b i * s) * MvPolynomial.eval x (ψ i)) (b i ^ (k+1) * Real.exp (b i * t) * MvPolynomial.eval x (ψ i)) t := by convert! (((hasDerivAt_id t).const_mul (b i)).exp.const_mul (b i ^ k)).mul_const (MvPolynomial.eval x (ψ i)) using 1 simp only [id_eq, mul_one, pow_succ] ring convert! HasDerivAt.sum (fun i (_ : i ∈ Finset.univ) => hi i) using 1 · funext s simp only [variation_eq, Finset.sum_apply] · exact variation_eq ψ b (k+1) t x def potential (ε : ℝ) (ψ : κ → MvPolynomial ι ℝ) (b : κ → ℝ) (t : ℝ) (x : ι → ℝ) : ℝ := ε / 2 * (∑ j, x j ^ 2) + variation ψ b 0 t x def density (ε : ℝ) (ψ : κ → MvPolynomial ι ℝ) (b : κ → ℝ) (t : ℝ) (x : ι → ℝ) : ℝ := Real.exp (-potential ε ψ b t x) def densityFirst (ε : ℝ) (ψ : κ → MvPolynomial ι ℝ) (b : κ → ℝ) (t : ℝ) (x : ι → ℝ) : ℝ := -variation ψ b 1 t x * density ε ψ b t x def densitySecond (ε : ℝ) (ψ : κ → MvPolynomial ι ℝ) (b : κ → ℝ) (t : ℝ) (x : ι → ℝ) : ℝ := (variation ψ b 1 t x ^ 2 - variation ψ b 2 t x) * density ε ψ b t x lemma potential_continuous (ε : ℝ) (ψ : κ → MvPolynomial ι ℝ) (b : κ → ℝ) (t : ℝ) : Continuous (potential ε ψ b t) := by apply Continuous.add · exact continuous_const.mul (continuous_finsetSum _ fun j _ => (continuous_apply j).pow 2) · exact variation_continuous ψ b 0 t lemma density_continuous (ε : ℝ) (ψ : κ → MvPolynomial ι ℝ) (b : κ → ℝ) (t : ℝ) : Continuous (density ε ψ b t) := Real.continuous_exp.comp (potential_continuous ε ψ b t).neg lemma densityFirst_continuous (ε : ℝ) (ψ : κ → MvPolynomial ι ℝ) (b : κ → ℝ) (t : ℝ) : Continuous (densityFirst ε ψ b t) := (variation_continuous ψ b 1 t).neg.mul (density_continuous ε ψ b t) lemma densitySecond_continuous (ε : ℝ) (ψ : κ → MvPolynomial ι ℝ) (b : κ → ℝ) (t : ℝ) : Continuous (densitySecond ε ψ b t) := ((variation_continuous ψ b 1 t).pow 2 |>.sub (variation_continuous ψ b 2 t)).mul (density_continuous ε ψ b t) lemma density_hasDerivAt (ε : ℝ) (ψ : κ → MvPolynomial ι ℝ) (b : κ → ℝ) (t : ℝ) (x : ι → ℝ) : HasDerivAt (fun s => density ε ψ b s x) (densityFirst ε ψ b t x) t := by have h := ((variation_hasDerivAt ψ b 0 t x).const_add (ε / 2 * ∑ j, x j ^ 2)).neg.exp convert! h using 1 simp [potential, density, densityFirst, mul_comm] lemma densityFirst_hasDerivAt (ε : ℝ) (ψ : κ → MvPolynomial ι ℝ) (b : κ → ℝ) (t : ℝ) (x : ι → ℝ) : HasDerivAt (fun s => densityFirst ε ψ b s x) (densitySecond ε ψ b t x) t := by have h := (variation_hasDerivAt ψ b 1 t x).neg.mul (density_hasDerivAt ε ψ b t x) convert! h using 1 simp only [densitySecond, densityFirst, Pi.neg_apply, Nat.reduceAdd] ring lemma potential_lower (ε : ℝ) {ψ : κ → MvPolynomial ι ℝ} (hψ : ∀ i x, 0 ≤ MvPolynomial.eval x (ψ i)) (b : κ → ℝ) (t : ℝ) (x : ι → ℝ) : ε / 2 * (∑ j, x j ^ 2) ≤ potential ε ψ b t x := by apply le_add_of_nonneg_right rw [variation_eq] exact Finset.sum_nonneg (fun i _ => mul_nonneg (by positivity) (hψ i x)) lemma polynomial_integrable {ε : ℝ} (hε : 0 < ε) {ψ : κ → MvPolynomial ι ℝ} (hψ : ∀ i x, 0 ≤ MvPolynomial.eval x (ψ i)) (b : κ → ℝ) (t : ℝ) (P : MvPolynomial ι ℝ) : Integrable (fun x => MvPolynomial.eval x P * density ε ψ b t x) := by exact GaussianPolynomial.dominated_polynomial (c := 0) (potential_continuous ε ψ b t) (half_pos hε) (fun x => by simpa using potential_lower ε hψ b t x) P lemma density_integrable {ε : ℝ} (hε : 0 < ε) {ψ : κ → MvPolynomial ι ℝ} (hψ : ∀ i x, 0 ≤ MvPolynomial.eval x (ψ i)) (b : κ → ℝ) (t : ℝ) : Integrable (density ε ψ b t) := by simpa using polynomial_integrable hε hψ b t (1 : MvPolynomial ι ℝ) lemma densityFirst_integrable {ε : ℝ} (hε : 0 < ε) {ψ : κ → MvPolynomial ι ℝ} (hψ : ∀ i x, 0 ≤ MvPolynomial.eval x (ψ i)) (b : κ → ℝ) (t : ℝ) : Integrable (densityFirst ε ψ b t) := by change Integrable (fun x => -variation ψ b 1 t x * density ε ψ b t x) simpa only [variation, map_neg] using polynomial_integrable hε hψ b t (-derivativePoly ψ b 1 t) lemma densitySecond_integrable {ε : ℝ} (hε : 0 < ε) {ψ : κ → MvPolynomial ι ℝ} (hψ : ∀ i x, 0 ≤ MvPolynomial.eval x (ψ i)) (b : κ → ℝ) (t : ℝ) : Integrable (densitySecond ε ψ b t) := by change Integrable (fun x => (variation ψ b 1 t x ^ 2 - variation ψ b 2 t x) * density ε ψ b t x) convert! polynomial_integrable hε hψ b t ((derivativePoly ψ b 1 t)^2 - derivativePoly ψ b 2 t) using 1 funext x rw [MvPolynomial.eval_sub, MvPolynomial.eval_pow] rfl def boundPoly (ψ : κ → MvPolynomial ι ℝ) (b : κ → ℝ) (k : ℕ) (t₀ : ℝ) : MvPolynomial ι ℝ := ∑ i, MvPolynomial.C (|b i| ^ k * Real.exp (|b i| * (|t₀| + 1))) * ψ i omit [Fintype ι] in lemma eval_boundPoly (ψ : κ → MvPolynomial ι ℝ) (b : κ → ℝ) (k : ℕ) (t₀ : ℝ) (x : ι → ℝ) : MvPolynomial.eval x (boundPoly ψ b k t₀) = ∑ i, |b i| ^ k * Real.exp (|b i| * (|t₀| + 1)) * MvPolynomial.eval x (ψ i) := by simp [boundPoly] omit [Fintype ι] in lemma boundPoly_nonneg {ψ : κ → MvPolynomial ι ℝ} (hψ : ∀ i x, 0 ≤ MvPolynomial.eval x (ψ i)) (b : κ → ℝ) (k : ℕ) (t₀ : ℝ) (x : ι → ℝ) : 0 ≤ MvPolynomial.eval x (boundPoly ψ b k t₀) := by rw [eval_boundPoly] exact Finset.sum_nonneg (fun i _ => mul_nonneg (by positivity) (hψ i x)) omit [Fintype ι] in lemma norm_variation_le {ψ : κ → MvPolynomial ι ℝ} (hψ : ∀ i x, 0 ≤ MvPolynomial.eval x (ψ i)) (b : κ → ℝ) (k : ℕ) (t₀ : ℝ) {t : ℝ} (ht : t ∈ Metric.ball t₀ 1) (x : ι → ℝ) : ‖variation ψ b k t x‖ ≤ MvPolynomial.eval x (boundPoly ψ b k t₀) := by have ht' : |t - t₀| < 1 := by simpa [Real.dist_eq] using ht have habs : |t| ≤ |t₀| + 1 := by calc |t| = |t - t₀ + t₀| := by congr 1; ring _ ≤ |t - t₀| + |t₀| := abs_add_le _ _ _ ≤ |t₀| + 1 := by linarith rw [variation_eq, eval_boundPoly] apply (norm_sum_le _ _).trans apply Finset.sum_le_sum intro i _ simp only [norm_mul, Real.norm_eq_abs, abs_pow, abs_of_pos (Real.exp_pos _), abs_of_nonneg (hψ i x)] apply mul_le_mul_of_nonneg_right _ (hψ i x) apply mul_le_mul_of_nonneg_left _ (by positivity) apply Real.exp_le_exp.mpr calc b i * t ≤ |b i * t| := le_abs_self _ _ = |b i| * |t| := abs_mul _ _ _ ≤ |b i| * (|t₀| + 1) := mul_le_mul_of_nonneg_left habs (abs_nonneg _) lemma density_le_gaussian (ε : ℝ) {ψ : κ → MvPolynomial ι ℝ} (hψ : ∀ i x, 0 ≤ MvPolynomial.eval x (ψ i)) (b : κ → ℝ) (t : ℝ) (x : ι → ℝ) : density ε ψ b t x ≤ Real.exp (-(ε/2) * ∑ j, x j ^ 2) := by apply Real.exp_le_exp.mpr linarith [potential_lower ε hψ b t x] lemma norm_densityFirst_le (ε : ℝ) {ψ : κ → MvPolynomial ι ℝ} (hψ : ∀ i x, 0 ≤ MvPolynomial.eval x (ψ i)) (b : κ → ℝ) (t₀ : ℝ) {t : ℝ} (ht : t ∈ Metric.ball t₀ 1) (x : ι → ℝ) : ‖densityFirst ε ψ b t x‖ ≤ MvPolynomial.eval x (boundPoly ψ b 1 t₀) * Real.exp (-(ε/2) * ∑ j, x j ^ 2) := by rw [densityFirst, norm_mul, norm_neg, Real.norm_eq_abs (density ε ψ b t x), abs_of_pos (show 0 < density ε ψ b t x from Real.exp_pos _)] exact mul_le_mul (norm_variation_le hψ b 1 t₀ ht x) (density_le_gaussian ε hψ b t x) (Real.exp_pos _).le (boundPoly_nonneg hψ b 1 t₀ x) lemma norm_densitySecond_le (ε : ℝ) {ψ : κ → MvPolynomial ι ℝ} (hψ : ∀ i x, 0 ≤ MvPolynomial.eval x (ψ i)) (b : κ → ℝ) (t₀ : ℝ) {t : ℝ} (ht : t ∈ Metric.ball t₀ 1) (x : ι → ℝ) : ‖densitySecond ε ψ b t x‖ ≤ MvPolynomial.eval x ((boundPoly ψ b 1 t₀)^2 + boundPoly ψ b 2 t₀) * Real.exp (-(ε/2) * ∑ j, x j ^ 2) := by have h₁ := norm_variation_le hψ b 1 t₀ ht x have h₂ := norm_variation_le hψ b 2 t₀ ht x have h₀ := boundPoly_nonneg hψ b 1 t₀ x have h₂₀ := boundPoly_nonneg hψ b 2 t₀ x rw [densitySecond, norm_mul, Real.norm_eq_abs (density _ _ _ _ _), abs_of_pos (show 0 < density ε ψ b t x from Real.exp_pos _)] apply mul_le_mul _ (density_le_gaussian ε hψ b t x) (Real.exp_pos _).le (by simp only [MvPolynomial.eval_add, MvPolynomial.eval_pow]; positivity) simp only [MvPolynomial.eval_add, MvPolynomial.eval_pow] calc ‖variation ψ b 1 t x ^ 2 - variation ψ b 2 t x‖ ≤ ‖variation ψ b 1 t x ^ 2‖ + ‖variation ψ b 2 t x‖ := norm_sub_le _ _ _ ≤ MvPolynomial.eval x (boundPoly ψ b 1 t₀)^2 + MvPolynomial.eval x (boundPoly ψ b 2 t₀) := by rw [norm_pow] exact add_le_add (pow_le_pow_left₀ (norm_nonneg _) h₁ 2) h₂ def partition (ε : ℝ) (ψ : κ → MvPolynomial ι ℝ) (b : κ → ℝ) (t : ℝ) : ℝ := ∫ x, density ε ψ b t x def partitionFirst (ε : ℝ) (ψ : κ → MvPolynomial ι ℝ) (b : κ → ℝ) (t : ℝ) : ℝ := ∫ x, densityFirst ε ψ b t x def partitionSecond (ε : ℝ) (ψ : κ → MvPolynomial ι ℝ) (b : κ → ℝ) (t : ℝ) : ℝ := ∫ x, densitySecond ε ψ b t x lemma partition_pos {ε : ℝ} (hε : 0 < ε) {ψ : κ → MvPolynomial ι ℝ} (hψ : ∀ i x, 0 ≤ MvPolynomial.eval x (ψ i)) (b : κ → ℝ) (t : ℝ) : 0 < partition ε ψ b t := integral_exp_pos (density_integrable hε hψ b t) lemma partition_hasDerivAt {ε : ℝ} (hε : 0 < ε) {ψ : κ → MvPolynomial ι ℝ} (hψ : ∀ i x, 0 ≤ MvPolynomial.eval x (ψ i)) (b : κ → ℝ) (t₀ : ℝ) : HasDerivAt (partition ε ψ b) (partitionFirst ε ψ b t₀) t₀ := by exact (hasDerivAt_integral_of_dominated_loc_of_deriv_le (Metric.ball_mem_nhds t₀ (by norm_num : (0:ℝ) < 1)) (Filter.Eventually.of_forall fun t => (density_continuous ε ψ b t).aestronglyMeasurable) (density_integrable hε hψ b t₀) (densityFirst_continuous ε ψ b t₀).aestronglyMeasurable (Filter.Eventually.of_forall fun x t ht => norm_densityFirst_le ε hψ b t₀ ht x) (GaussianPolynomial.polynomial_integrable (half_pos hε) (boundPoly ψ b 1 t₀)) (Filter.Eventually.of_forall fun x t _ => density_hasDerivAt ε ψ b t x)).2 lemma partitionFirst_hasDerivAt {ε : ℝ} (hε : 0 < ε) {ψ : κ → MvPolynomial ι ℝ} (hψ : ∀ i x, 0 ≤ MvPolynomial.eval x (ψ i)) (b : κ → ℝ) (t₀ : ℝ) : HasDerivAt (partitionFirst ε ψ b) (partitionSecond ε ψ b t₀) t₀ := by exact (hasDerivAt_integral_of_dominated_loc_of_deriv_le (Metric.ball_mem_nhds t₀ (by norm_num : (0:ℝ) < 1)) (Filter.Eventually.of_forall fun t => (densityFirst_continuous ε ψ b t).aestronglyMeasurable) (densityFirst_integrable hε hψ b t₀) (densitySecond_continuous ε ψ b t₀).aestronglyMeasurable (Filter.Eventually.of_forall fun x t ht => norm_densitySecond_le ε hψ b t₀ ht x) (GaussianPolynomial.polynomial_integrable (half_pos hε) ((boundPoly ψ b 1 t₀)^2 + boundPoly ψ b 2 t₀)) (Filter.Eventually.of_forall fun x t _ => densityFirst_hasDerivAt ε ψ b t x)).2 lemma log_partition_hasDerivAt {ε : ℝ} (hε : 0 < ε) {ψ : κ → MvPolynomial ι ℝ} (hψ : ∀ i x, 0 ≤ MvPolynomial.eval x (ψ i)) (b : κ → ℝ) (t₀ : ℝ) : HasDerivAt (fun t => Real.log (partition ε ψ b t)) (partitionFirst ε ψ b t₀ / partition ε ψ b t₀) t₀ := (partition_hasDerivAt hε hψ b t₀).log (partition_pos hε hψ b t₀).ne' lemma log_partition_derivative_hasDerivAt {ε : ℝ} (hε : 0 < ε) {ψ : κ → MvPolynomial ι ℝ} (hψ : ∀ i x, 0 ≤ MvPolynomial.eval x (ψ i)) (b : κ → ℝ) (t₀ : ℝ) : HasDerivAt (fun t => partitionFirst ε ψ b t / partition ε ψ b t) ((partitionSecond ε ψ b t₀ * partition ε ψ b t₀ - partitionFirst ε ψ b t₀ ^ 2) / partition ε ψ b t₀ ^ 2) t₀ := by simpa only [Pi.div_apply, pow_two] using! (partitionFirst_hasDerivAt hε hψ b t₀).div (partition_hasDerivAt hε hψ b t₀) (partition_pos hε hψ b t₀).ne' def mean (ε : ℝ) (ψ : κ → MvPolynomial ι ℝ) (b : κ → ℝ) (t : ℝ) (F : (ι → ℝ) → ℝ) : ℝ := (∫ x, F x * density ε ψ b t x) / partition ε ψ b t def variance (ε : ℝ) (ψ : κ → MvPolynomial ι ℝ) (b : κ → ℝ) (t : ℝ) (F : (ι → ℝ) → ℝ) : ℝ := mean ε ψ b t (fun x => (F x - mean ε ψ b t F)^2) lemma variance_eq {ε : ℝ} (hε : 0 < ε) {ψ : κ → MvPolynomial ι ℝ} (hψ : ∀ i x, 0 ≤ MvPolynomial.eval x (ψ i)) (b : κ → ℝ) (t : ℝ) (P : MvPolynomial ι ℝ) : variance ε ψ b t (fun x => MvPolynomial.eval x P) = mean ε ψ b t (fun x => MvPolynomial.eval x P ^ 2) - mean ε ψ b t (fun x => MvPolynomial.eval x P) ^ 2 := by have hP := polynomial_integrable hε hψ b t P have hP₂ : Integrable (fun x => MvPolynomial.eval x P ^ 2 * density ε ψ b t x) := by convert! polynomial_integrable hε hψ b t (P^2) using 1 funext x rw [map_pow] have hd := density_integrable hε hψ b t let m := mean ε ψ b t (fun x => MvPolynomial.eval x P) have he : (fun x => (MvPolynomial.eval x P-m)^2 * density ε ψ b t x) = (fun x => MvPolynomial.eval x P ^ 2 * density ε ψ b t x - 2*m*(MvPolynomial.eval x P * density ε ψ b t x) + m^2*density ε ψ b t x) := by funext x ring change (∫ x, (MvPolynomial.eval x P-m)^2 * density ε ψ b t x) / partition ε ψ b t = _ have hsub : Integrable (fun x => MvPolynomial.eval x P ^ 2 * density ε ψ b t x - 2*m*(MvPolynomial.eval x P * density ε ψ b t x)) := by simpa only [Pi.sub_apply] using! hP₂.sub (hP.const_mul (2*m)) rw [he, integral_add hsub (hd.const_mul (m^2)), integral_sub hP₂ (hP.const_mul (2*m)), integral_const_mul, integral_const_mul] have hZ := (partition_pos hε hψ b t).ne' dsimp [m, mean, partition] at * field_simp ring lemma partitionFirst_eq (ε : ℝ) (ψ : κ → MvPolynomial ι ℝ) (b : κ → ℝ) (t : ℝ) : partitionFirst ε ψ b t = -(∫ x, variation ψ b 1 t x * density ε ψ b t x) := by simp only [partitionFirst, densityFirst, neg_mul, integral_neg] lemma partitionSecond_eq {ε : ℝ} (hε : 0 < ε) {ψ : κ → MvPolynomial ι ℝ} (hψ : ∀ i x, 0 ≤ MvPolynomial.eval x (ψ i)) (b : κ → ℝ) (t : ℝ) : partitionSecond ε ψ b t = (∫ x, variation ψ b 1 t x ^ 2 * density ε ψ b t x) - (∫ x, variation ψ b 2 t x * density ε ψ b t x) := by have hP₂ : Integrable (fun x => variation ψ b 1 t x ^ 2 * density ε ψ b t x) := by convert! polynomial_integrable hε hψ b t ((derivativePoly ψ b 1 t)^2) using 1 funext x rw [map_pow] rfl simp only [partitionSecond, densitySecond, sub_mul] exact integral_sub hP₂ (polynomial_integrable hε hψ b t (derivativePoly ψ b 2 t)) lemma log_partition_second {ε : ℝ} (hε : 0 < ε) {ψ : κ → MvPolynomial ι ℝ} (hψ : ∀ i x, 0 ≤ MvPolynomial.eval x (ψ i)) (b : κ → ℝ) (t : ℝ) : ((partitionSecond ε ψ b t * partition ε ψ b t - partitionFirst ε ψ b t ^ 2) / partition ε ψ b t ^ 2) = variance ε ψ b t (variation ψ b 1 t) - mean ε ψ b t (variation ψ b 2 t) := by rw [partitionFirst_eq, partitionSecond_eq hε hψ] rw [show variation ψ b 1 t = (fun x => MvPolynomial.eval x (derivativePoly ψ b 1 t)) from rfl, variance_eq hε hψ] have hZ := (partition_pos hε hψ b t).ne' dsimp only [mean, variation] field_simp ring lemma log_partition_concave_of_variance {ε : ℝ} (hε : 0 < ε) {ψ : κ → MvPolynomial ι ℝ} (hψ : ∀ i x, 0 ≤ MvPolynomial.eval x (ψ i)) (b : κ → ℝ) (hvar : ∀ t, variance ε ψ b t (variation ψ b 1 t) ≤ mean ε ψ b t (variation ψ b 2 t)) : ConcaveOn ℝ Set.univ (fun t => Real.log (partition ε ψ b t)) := by apply concaveOn_of_hasDerivWithinAt2_nonpos convex_univ (f' := fun t => partitionFirst ε ψ b t / partition ε ψ b t) (f'' := fun t => (partitionSecond ε ψ b t * partition ε ψ b t - partitionFirst ε ψ b t ^ 2) / partition ε ψ b t ^ 2) · exact (continuous_iff_continuousAt.mpr fun t => (log_partition_hasDerivAt hε hψ b t).continuousAt).continuousOn · exact fun t _ => (log_partition_hasDerivAt hε hψ b t).hasDerivWithinAt · exact fun t _ => (log_partition_derivative_hasDerivAt hε hψ b t).hasDerivWithinAt · intro t _ rw [log_partition_second hε hψ] exact sub_nonpos.mpr (hvar t) lemma partition_rpow_le_of_variance {ε : ℝ} (hε : 0 < ε) {ψ : κ → MvPolynomial ι ℝ} (hψ : ∀ i x, 0 ≤ MvPolynomial.eval x (ψ i)) (b : κ → ℝ) (hvar : ∀ t, variance ε ψ b t (variation ψ b 1 t) ≤ mean ε ψ b t (variation ψ b 2 t)) {t : ℝ} (ht : t ∈ Set.Icc (0:ℝ) 1) : partition ε ψ b 0 ^ (1-t) * partition ε ψ b 1 ^ t ≤ partition ε ψ b t := by have hc := log_partition_concave_of_variance hε hψ b hvar have hh := hc.2 (Set.mem_univ (0:ℝ)) (Set.mem_univ (1:ℝ)) (sub_nonneg.mpr ht.2) ht.1 (by ring : (1-t)+t=1) simp only [smul_eq_mul, mul_zero, mul_one, zero_add] at hh have h₀ := partition_pos hε hψ b 0 have h₁ := partition_pos hε hψ b 1 have ht₀ := partition_pos hε hψ b t rw [Real.rpow_def_of_pos h₀, Real.rpow_def_of_pos h₁, ← Real.exp_add, ← Real.exp_log ht₀] apply Real.exp_le_exp.mpr nlinarith [hh] end SlabPartition namespace SoftSlabLimits open MeasureTheory MeasureTheory.Measure Set Filter open scoped Topology BigOperators variable {ι : Type*} {κ : Type*} [Fintype ι] [Fintype κ] lemma level_null (ℓ : (ι → ℝ) →ₗ[ℝ] ℝ) {t : ℝ} (ht : t ≠ 0) : volume {x | ℓ x = t} = 0 := by let s := (affineSpan ℝ ({t} : Set ℝ)).comap ℓ.toAffineMap have hs : s ≠ ⊤ := by intro h have hz : (0 : ι → ℝ) ∈ s := by rw [h]; trivial have : (0 : ℝ) = t := by simpa [s, AffineSubspace.mem_affineSpan_singleton] using hz exact ht this.symm have hset : {x | ℓ x = t} = (s : Set (ι → ℝ)) := by ext x simp [s] rw [hset] exact addHaar_affineSubspace volume s hs lemma abs_level_ne_ae (ℓ : (ι → ℝ) →ₗ[ℝ] ℝ) : ∀ᵐ x, |ℓ x| ≠ 1 := by have hp : ∀ᵐ x, ℓ x ≠ 1 := by rw [ae_iff]; simpa only [not_not] using level_null ℓ one_ne_zero have hm : ∀ᵐ x, ℓ x ≠ -1 := by rw [ae_iff]; simpa only [not_not] using level_null ℓ (t := -1) (by norm_num) filter_upwards [hp, hm] with x hp hm intro he rcases (abs_eq (by norm_num : (0:ℝ) ≤ 1)).mp he with h | h · exact hp h · exact hm h def body (ℓ : κ → (ι → ℝ) →ₗ[ℝ] ℝ) : Set (ι → ℝ) := {x | ∀ i, |ℓ i x| ≤ 1} def gaussian (ε : ℝ) (x : ι → ℝ) : ℝ := Real.exp (-(ε / 2) * ∑ j, x j ^ 2) def density (ℓ : κ → (ι → ℝ) →ₗ[ℝ] ℝ) (ε : ℝ) (k : ℕ) (x : ι → ℝ) : ℝ := Real.exp (-(ε / 2) * ∑ j, x j ^ 2 - ∑ i, (ℓ i x) ^ (2*k+2)) lemma body_measurable (ℓ : κ → (ι → ℝ) →ₗ[ℝ] ℝ) : MeasurableSet (body ℓ) := by have hb : body ℓ = ⋂ i, {x | |ℓ i x| ≤ 1} := by ext x; simp [body] rw [hb] apply MeasurableSet.iInter intro i exact (isClosed_le ((ℓ i).continuous_of_finiteDimensional.abs) continuous_const).measurableSet lemma continuous_density (ℓ : κ → (ι → ℝ) →ₗ[ℝ] ℝ) (ε : ℝ) (k : ℕ) : Continuous (density ℓ ε k) := by unfold density fun_prop lemma density_le_gaussian (ℓ : κ → (ι → ℝ) →ₗ[ℝ] ℝ) (ε : ℝ) (k : ℕ) (x : ι → ℝ) : ‖density ℓ ε k x‖ ≤ gaussian ε x := by rw [density, Real.norm_eq_abs, abs_of_pos (Real.exp_pos _)] apply Real.exp_le_exp.mpr exact sub_le_self _ (Finset.sum_nonneg fun i _ => Even.pow_nonneg ⟨k+1, by omega⟩ _) lemma gaussian_integrable {ε : ℝ} (hε : 0 < ε) : Integrable (gaussian (ι:=ι) ε) := by unfold gaussian simpa only [map_one, one_mul] using GaussianPolynomial.polynomial_integrable (show 0 < ε/2 by positivity) (1 : MvPolynomial ι ℝ) lemma evenIndex_tendsto : Tendsto (fun k : ℕ => 2*k+2) atTop atTop := tendsto_atTop_mono (fun k : ℕ => by dsimp; omega) tendsto_id lemma density_tendsto (ℓ : κ → (ι → ℝ) →ₗ[ℝ] ℝ) (ε : ℝ) (x : ι → ℝ) (hx : ∀ i, |ℓ i x| ≠ 1) : Tendsto (fun k => density ℓ ε k x) atTop (𝓝 ((body ℓ).indicator (gaussian ε) x)) := by classical by_cases hi : x ∈ body ℓ · have hlt : ∀ i, |ℓ i x| < 1 := fun i => lt_of_le_of_ne (hi i) (hx i) have ht : Tendsto (fun k => ∑ i, (ℓ i x) ^ (2*k+2)) atTop (𝓝 0) := by simpa using tendsto_finsetSum Finset.univ (fun i _ => (tendsto_pow_atTop_nhds_zero_of_abs_lt_one (hlt i)).comp evenIndex_tendsto) rw [indicator_of_mem hi] simpa only [density, gaussian, sub_zero, Function.comp_def] using! Real.continuous_exp.continuousAt.tendsto.comp ((tendsto_const_nhds.sub ht) : Tendsto (fun k => -(ε/2) * ∑ j, x j^2 - ∑ i, (ℓ i x) ^ (2*k+2)) atTop (𝓝 (-(ε/2) * ∑ j, x j^2 - 0))) · have hout : ∃ i, 1 < |ℓ i x| := by simpa only [body, mem_ofPred_eq, not_forall, not_le] using hi obtain ⟨i, hix⟩ := hout have ht : Tendsto (fun k => ∑ j, (ℓ j x) ^ (2*k+2)) atTop atTop := by apply tendsto_atTop_mono (fun k => ?_) ((tendsto_pow_atTop_atTop_of_one_lt hix).comp evenIndex_tendsto) change |ℓ i x| ^ (2*k+2) ≤ _ rw [Even.pow_abs ⟨k+1, by omega⟩] have hn (j : κ) : 0 ≤ (ℓ j x) ^ (2*k+2) := Even.pow_nonneg ⟨k+1, by omega⟩ _ exact Finset.single_le_sum (fun j _ => hn j) (Finset.mem_univ i) rw [indicator_of_notMem hi] have ht' : Tendsto (fun k => (∑ j, (ℓ j x) ^ (2*k+2)) + (ε/2) * ∑ j, x j^2) atTop atTop := ht.atTop_add tendsto_const_nhds have he := Real.tendsto_exp_atBot.comp (tendsto_neg_atTop_atBot.comp ht') convert! he using 1 funext k dsimp [density] congr 1 ring lemma partition_tendsto (ℓ : κ → (ι → ℝ) →ₗ[ℝ] ℝ) {ε : ℝ} (hε : 0 < ε) : Tendsto (fun k => ∫ x, density ℓ ε k x) atTop (𝓝 (∫ x in body ℓ, gaussian ε x)) := by rw [← integral_indicator (body_measurable ℓ)] apply tendsto_integral_of_dominated_convergence (gaussian ε) (fun k => (continuous_density ℓ ε k).aestronglyMeasurable) (gaussian_integrable hε) (fun k => Eventually.of_forall (density_le_gaussian ℓ ε k)) have h : ∀ᵐ x, ∀ i, |ℓ i x| ≠ 1 := ae_all_iff.mpr (fun i => abs_level_ne_ae (ℓ i)) filter_upwards [h] with x hx exact density_tendsto ℓ ε x hx lemma gaussian_tendsto_volume {s : Set (ι → ℝ)} (hs : volume s ≠ ⊤) {ε : ℕ → ℝ} (hε : ∀ k, 0 ≤ ε k) (ht : Tendsto ε atTop (𝓝 0)) : Tendsto (fun k => ∫ x in s, gaussian (ε k) x) atTop (𝓝 (volume.real s)) := by have hi : Integrable (fun _ : ι → ℝ => (1 : ℝ)) (volume.restrict s) := integrableOn_const hs have hc (k : ℕ) : Continuous (gaussian (ι:=ι) (ε k)) := by unfold gaussian; fun_prop have hl := tendsto_integral_of_dominated_convergence (μ := volume.restrict s) (f := fun _ => (1 : ℝ)) (fun _ : ι → ℝ => (1 : ℝ)) (fun k => (hc k).aestronglyMeasurable) hi (fun k => Eventually.of_forall (fun x => ?_)) (Eventually.of_forall (fun x => ?_)) · simpa only [setIntegral_const, smul_eq_mul, mul_one] using hl · rw [gaussian, Real.norm_eq_abs, abs_of_pos (Real.exp_pos _), Real.exp_le_one_iff] exact mul_nonpos_of_nonpos_of_nonneg (neg_nonpos.mpr (div_nonneg (hε k) (by norm_num))) (Finset.sum_nonneg fun j _ => sq_nonneg (x j)) · have hh : Tendsto (fun k => -(ε k/2) * ∑ j, x j^2) atTop (𝓝 0) := by simpa only [zero_div, neg_zero, zero_mul] using (ht.div_const 2).neg.mul_const (∑ j, x j^2) simpa only [gaussian, Real.exp_zero, Function.comp_def] using! Real.continuous_exp.continuousAt.tendsto.comp hh lemma volume_rpow_le_of_partition (ℓ₀ ℓ₁ ℓt : κ → (ι → ℝ) →ₗ[ℝ] ℝ) (h₀ : volume (body ℓ₀) ≠ ⊤) (h₁ : volume (body ℓ₁) ≠ ⊤) (htb : volume (body ℓt) ≠ ⊤) {t : ℝ} (ht : t ∈ Icc (0:ℝ) 1) (hpart : ∀ ε : ℝ, 0 < ε → ∀ k : ℕ, (∫ x, density ℓ₀ ε k x) ^ (1-t) * (∫ x, density ℓ₁ ε k x) ^ t ≤ ∫ x, density ℓt ε k x) : volume.real (body ℓ₀) ^ (1-t) * volume.real (body ℓ₁) ^ t ≤ volume.real (body ℓt) := by have hgauss (ε : ℝ) (hε : 0 < ε) : (∫ x in body ℓ₀, gaussian ε x) ^ (1-t) * (∫ x in body ℓ₁, gaussian ε x) ^ t ≤ ∫ x in body ℓt, gaussian ε x := by exact le_of_tendsto_of_tendsto (((partition_tendsto ℓ₀ hε).rpow_const (Or.inr (sub_nonneg.mpr ht.2))).mul ((partition_tendsto ℓ₁ hε).rpow_const (Or.inr ht.1))) (partition_tendsto ℓt hε) (Eventually.of_forall (hpart ε hε)) let ε : ℕ → ℝ := fun k => 1 / ((k : ℝ) + 1) have hepos (k : ℕ) : 0 < ε k := by dsimp [ε]; positivity have het : Tendsto ε atTop (𝓝 0) := by simpa only [ε, Nat.cast_add, Nat.cast_one, Function.comp_def] using! (tendsto_one_div_atTop_nhds_zero_nat (𝕜:=ℝ)).comp (tendsto_add_atTop_nat 1) exact le_of_tendsto_of_tendsto (((gaussian_tendsto_volume h₀ (fun k => (hepos k).le) het).rpow_const (Or.inr (sub_nonneg.mpr ht.2))).mul ((gaussian_tendsto_volume h₁ (fun k => (hepos k).le) het).rpow_const (Or.inr ht.1))) (gaussian_tendsto_volume htb (fun k => (hepos k).le) het) (Eventually.of_forall (fun k => hgauss (ε k) (hepos k))) end SoftSlabLimits namespace SlabReduction open MeasureTheory Set Filter open scoped BigOperators Topology variable {ι : Type*} {κ : Type*} [Fintype ι] [Fintype κ] def linearPoly (p : ι → ℝ) : MvPolynomial ι ℝ := ∑ j, MvPolynomial.C (p j) * MvPolynomial.X j def feature (p : ι → ℝ) (h : ℝ) (q : ℕ) : MvPolynomial ι ℝ := (MvPolynomial.C h⁻¹ * linearPoly p) ^ q lemma eval_feature (p x : ι → ℝ) (h : ℝ) (q : ℕ) : MvPolynomial.eval x (feature p h q) = (p ⬝ᵥ x / h)^q := by simp [feature, linearPoly, dotProduct, div_eq_mul_inv, mul_comm] def width (h₀ h₁ t : ℝ) : ℝ := h₀ ^ (1-t) * h₁ ^ t def normal (p : ι → ℝ) (h : ℝ) : (ι → ℝ) →ₗ[ℝ] ℝ := h⁻¹ • (dotProductBilin ℝ ℝ p) lemma normal_apply (p x : ι → ℝ) (h : ℝ) : normal p h x = p ⬝ᵥ x / h := by simp [normal, div_eq_mul_inv, mul_comm] def rate (q : ℕ) (h₀ h₁ : ℝ) : ℝ := -(q:ℝ) * Real.log (h₁/h₀) lemma width_pos {h₀ h₁ : ℝ} (ha : 0 < h₀) (hb : 0 < h₁) (t : ℝ) : 0 < width h₀ h₁ t := mul_pos (Real.rpow_pos_of_pos ha _) (Real.rpow_pos_of_pos hb _) lemma width_exponential {h₀ h₁ : ℝ} (ha : 0 < h₀) (hb : 0 < h₁) (t : ℝ) : width h₀ h₁ t = h₀ * Real.exp (t * Real.log (h₁/h₀)) := by dsimp [width] rw [Real.rpow_def_of_pos ha, Real.rpow_def_of_pos hb, ← Real.exp_add, Real.log_div hb.ne' ha.ne'] calc _ = Real.exp (Real.log h₀ + t * (Real.log h₁ - Real.log h₀)) := by congr 1; ring _ = _ := by rw [Real.exp_add, Real.exp_log ha] lemma feature_exponential {h₀ h₁ : ℝ} (ha : 0 < h₀) (hb : 0 < h₁) (p x : ι → ℝ) (q : ℕ) (t : ℝ) : Real.exp (rate q h₀ h₁ * t) * MvPolynomial.eval x (feature p h₀ q) = (normal p (width h₀ h₁ t) x)^q := by rw [eval_feature, normal_apply, width_exponential ha hb] rw [show rate q h₀ h₁ * t = (q:ℝ) * (-(t * Real.log (h₁/h₀))) by dsimp [rate]; ring, Real.exp_nat_mul, ← mul_pow, Real.exp_neg] congr 1 field_simp def features (p : κ → ι → ℝ) (h : κ → ℝ) (q : ℕ) : κ → MvPolynomial ι ℝ := fun i => feature (p i) (h i) q def rates (h₀ h₁ : κ → ℝ) (q : ℕ) : κ → ℝ := fun i => rate q (h₀ i) (h₁ i) def normals (p : κ → ι → ℝ) (h : κ → ℝ) : κ → (ι → ℝ) →ₗ[ℝ] ℝ := fun i => normal (p i) (h i) def widths (h₀ h₁ : κ → ℝ) (t : ℝ) : κ → ℝ := fun i => width (h₀ i) (h₁ i) t omit [Fintype κ] in lemma features_nonneg (p : κ → ι → ℝ) (h : κ → ℝ) {q : ℕ} (hq : Even q) : ∀ i x, 0 ≤ MvPolynomial.eval x (features p h q i) := by intro i x rw [features, eval_feature] exact hq.pow_nonneg _ lemma variation_identification (p : κ → ι → ℝ) {h₀ h₁ : κ → ℝ} (ha : ∀ i, 0 < h₀ i) (hb : ∀ i, 0 < h₁ i) (q k : ℕ) (t : ℝ) (x : ι → ℝ) : SlabPartition.variation (features p h₀ q) (rates h₀ h₁ q) k t x = ∑ i, (rates h₀ h₁ q i)^k * (normal (p i) (width (h₀ i) (h₁ i) t) x)^q := by rw [SlabPartition.variation_eq] apply Finset.sum_congr rfl intro i _ rw [mul_assoc] congr 1 exact feature_exponential (ha i) (hb i) (p i) x q t lemma density_identification (p : κ → ι → ℝ) {h₀ h₁ : κ → ℝ} (ha : ∀ i, 0 < h₀ i) (hb : ∀ i, 0 < h₁ i) (ε : ℝ) (k : ℕ) (t : ℝ) : SlabPartition.density ε (features p h₀ (2*k+2)) (rates h₀ h₁ (2*k+2)) t = SoftSlabLimits.density (normals p (widths h₀ h₁ t)) ε k := by funext x dsimp [SlabPartition.density, SlabPartition.potential, SoftSlabLimits.density] rw [variation_identification p ha hb] simp only [pow_zero, one_mul] congr 1 dsimp [normals, widths] ring omit [Fintype κ] in lemma widths_zero {h₀ h₁ : κ → ℝ} : widths h₀ h₁ 0 = h₀ := by funext i simp [widths, width] omit [Fintype κ] in lemma widths_one {h₀ h₁ : κ → ℝ} : widths h₀ h₁ 1 = h₁ := by funext i simp [widths, width] theorem finite_slabs_of_variance (p : κ → ι → ℝ) {h₀ h₁ : κ → ℝ} (ha : ∀ i, 0 < h₀ i) (hb : ∀ i, 0 < h₁ i) {t : ℝ} (ht : t ∈ Icc (0:ℝ) 1) (hfin₀ : volume (SoftSlabLimits.body (normals p h₀)) ≠ ⊤) (hfin₁ : volume (SoftSlabLimits.body (normals p h₁)) ≠ ⊤) (hfint : volume (SoftSlabLimits.body (normals p (widths h₀ h₁ t))) ≠ ⊤) (hvar : ∀ ε : ℝ, 0 < ε → ∀ k : ℕ, ∀ s : ℝ, SlabPartition.variance ε (features p h₀ (2*k+2)) (rates h₀ h₁ (2*k+2)) s (SlabPartition.variation (features p h₀ (2*k+2)) (rates h₀ h₁ (2*k+2)) 1 s) ≤ SlabPartition.mean ε (features p h₀ (2*k+2)) (rates h₀ h₁ (2*k+2)) s (SlabPartition.variation (features p h₀ (2*k+2)) (rates h₀ h₁ (2*k+2)) 2 s)) : volume.real (SoftSlabLimits.body (normals p h₀)) ^ (1-t) * volume.real (SoftSlabLimits.body (normals p h₁)) ^ t ≤ volume.real (SoftSlabLimits.body (normals p (widths h₀ h₁ t))) := by apply SoftSlabLimits.volume_rpow_le_of_partition _ _ _ hfin₀ hfin₁ hfint ht intro ε hε k have h := SlabPartition.partition_rpow_le_of_variance hε (features_nonneg p h₀ (show Even (2*k+2) from ⟨k+1, by omega⟩)) (rates h₀ h₁ (2*k+2)) (hvar ε hε k) ht simpa only [SlabPartition.partition, density_identification p ha hb, widths_zero, widths_one] using h end SlabReduction namespace LogBrunnMinkowski lemma finiteSlabs_preimage_eq_body {n : ℕ} (D : Finset (Space n)) (f : Space n → ℝ) (hf : ∀ u ∈ D, 0 < f u) : WithLp.toLp 2 ⁻¹' (finiteSlabs D f) = SoftSlabLimits.body (SlabReduction.normals (fun u : D => u.val.ofLp) (fun u : D => f u.val)) := by ext x simp only [Set.mem_preimage, finiteSlabs, SoftSlabLimits.body, Set.mem_ofPred_eq] constructor · intro hx u rw [SlabReduction.normals, SlabReduction.normal_apply, abs_div, abs_of_pos (hf u.val u.property), div_le_one (hf u.val u.property)] simpa [EuclideanSpace.inner_eq_star_dotProduct] using hx u.val u.property · intro hx u hu have h := hx ⟨u, hu⟩ rw [SlabReduction.normals, SlabReduction.normal_apply, abs_div, abs_of_pos (hf u hu), div_le_one (hf u hu)] at h simpa [EuclideanSpace.inner_eq_star_dotProduct] using h lemma volume_finiteSlabs_eq_body {n : ℕ} (D : Finset (Space n)) (f : Space n → ℝ) (hf : ∀ u ∈ D, 0 < f u) : volume (finiteSlabs D f) = volume (SoftSlabLimits.body (SlabReduction.normals (fun u : D => u.val.ofLp) (fun u : D => f u.val))) := by rw [← finiteSlabs_preimage_eq_body D f hf] exact ((PiLp.volume_preserving_toLp (Fin n)).measure_preimage (finiteSlabs_closed D f).measurableSet.nullMeasurableSet).symm lemma ennreal_rpow_le_of_toReal {a b c : ℝ≥0∞} (ha : a ≠ ⊤) (hb : b ≠ ⊤) (hc : c ≠ ⊤) {t : ℝ} (ht : t ∈ Icc (0:ℝ) 1) (h : a.toReal^(1-t)*b.toReal^t ≤ c.toReal) : a^(1-t)*b^t ≤ c := by apply (ENNReal.toReal_le_toReal (ENNReal.mul_ne_top (ENNReal.rpow_ne_top_of_nonneg (sub_nonneg.mpr ht.2) ha) (ENNReal.rpow_ne_top_of_nonneg ht.1 hb)) hc).mp simpa only [ENNReal.toReal_mul, ← ENNReal.toReal_rpow] using h lemma finiteSlabs_volume_of_body_inequality {n : ℕ} (D : Finset (Space n)) (hD : ∀ i : Fin n, EuclideanSpace.basisFun (Fin n) ℝ i ∈ D) (f₀ f₁ : Space n → ℝ) (h₀ : ∀ u ∈ D, 0 < f₀ u) (h₁ : ∀ u ∈ D, 0 < f₁ u) {t : ℝ} (ht : t ∈ Icc (0:ℝ) 1) (h : volume.real (SoftSlabLimits.body (SlabReduction.normals (fun u : D => u.val.ofLp) (fun u : D => f₀ u.val)))^(1-t) * volume.real (SoftSlabLimits.body (SlabReduction.normals (fun u : D => u.val.ofLp) (fun u : D => f₁ u.val)))^t ≤ volume.real (SoftSlabLimits.body (SlabReduction.normals (fun u : D => u.val.ofLp) (fun u : D => f₀ u.val^(1-t)*f₁ u.val^t)))) : volume (finiteSlabs D f₀) ^ (1-t) * volume (finiteSlabs D f₁) ^ t ≤ volume (finiteSlabs D (fun u => f₀ u ^ (1-t) * f₁ u ^ t)) := by let f := fun u => f₀ u ^ (1-t) * f₁ u ^ t have hf : ∀ u ∈ D, 0 < f u := fun u hu => SlabReduction.width_pos (h₀ u hu) (h₁ u hu) t apply ennreal_rpow_le_of_toReal ((finiteSlabs_compact D f₀ hD).measure_ne_top (μ := volume)) ((finiteSlabs_compact D f₁ hD).measure_ne_top (μ := volume)) ((finiteSlabs_compact D f hD).measure_ne_top (μ := volume)) ht simpa only [volume_finiteSlabs_eq_body D f₀ h₀, volume_finiteSlabs_eq_body D f₁ h₁, volume_finiteSlabs_eq_body D f hf, Measure.real] using h lemma volume_body_finiteSlabs_ne_top {n : ℕ} (D : Finset (Space n)) (hD : ∀ i : Fin n, EuclideanSpace.basisFun (Fin n) ℝ i ∈ D) (f : Space n → ℝ) (hf : ∀ u ∈ D, 0 < f u) : volume (SoftSlabLimits.body (SlabReduction.normals (fun u : D => u.val.ofLp) (fun u : D => f u.val))) ≠ ⊤ := by rw [← volume_finiteSlabs_eq_body D f hf] exact (finiteSlabs_compact D f hD).measure_ne_top (μ := volume) lemma finiteSlabs_volume_of_variance {n : ℕ} (D : Finset (Space n)) (hD : ∀ i : Fin n, EuclideanSpace.basisFun (Fin n) ℝ i ∈ D) (f₀ f₁ : Space n → ℝ) (h₀ : ∀ u ∈ D, 0 < f₀ u) (h₁ : ∀ u ∈ D, 0 < f₁ u) {t : ℝ} (ht : t ∈ Icc (0:ℝ) 1) (hvar : ∀ ε : ℝ, 0 < ε → ∀ k : ℕ, ∀ s : ℝ, SlabPartition.variance ε (SlabReduction.features (fun u : D => u.val.ofLp) (fun u : D => f₀ u.val) (2*k+2)) (SlabReduction.rates (fun u : D => f₀ u.val) (fun u : D => f₁ u.val) (2*k+2)) s (SlabPartition.variation (SlabReduction.features (fun u : D => u.val.ofLp) (fun u : D => f₀ u.val) (2*k+2)) (SlabReduction.rates (fun u : D => f₀ u.val) (fun u : D => f₁ u.val) (2*k+2)) 1 s) ≤ SlabPartition.mean ε (SlabReduction.features (fun u : D => u.val.ofLp) (fun u : D => f₀ u.val) (2*k+2)) (SlabReduction.rates (fun u : D => f₀ u.val) (fun u : D => f₁ u.val) (2*k+2)) s (SlabPartition.variation (SlabReduction.features (fun u : D => u.val.ofLp) (fun u : D => f₀ u.val) (2*k+2)) (SlabReduction.rates (fun u : D => f₀ u.val) (fun u : D => f₁ u.val) (2*k+2)) 2 s)) : volume (finiteSlabs D f₀) ^ (1-t) * volume (finiteSlabs D f₁) ^ t ≤ volume (finiteSlabs D (fun u => f₀ u ^ (1-t) * f₁ u ^ t)) := by apply finiteSlabs_volume_of_body_inequality D hD f₀ f₁ h₀ h₁ ht exact SlabReduction.finite_slabs_of_variance (fun u : D => u.val.ofLp) (fun u => h₀ u.val u.property) (fun u => h₁ u.val u.property) ht (volume_body_finiteSlabs_ne_top D hD f₀ h₀) (volume_body_finiteSlabs_ne_top D hD f₁ h₁) (volume_body_finiteSlabs_ne_top D hD (fun u => f₀ u^(1-t)*f₁ u^t) (fun u hu => SlabReduction.width_pos (h₀ u hu) (h₁ u hu) t)) hvar def SoftVarianceStatement : Prop := ∀ (n : ℕ), 2 ≤ n → ∀ (κ : Type) (_ : Fintype κ) (_ : Nonempty κ), ∀ (q : ℕ), Even q → 2 ≤ q → ∀ (ε : ℝ), 0 < ε → ∀ (p : κ → Fin n → ℝ), (∀ i, p i ≠ 0) → ∀ (h : κ → ℝ), (∀ i, 0 < h i) → ∀ (b : κ → ℝ), SlabPartition.variance ε (SlabReduction.features p h q) (fun _ => 0) 0 (fun x => ∑ i, b i * MvPolynomial.eval x (SlabReduction.features p h q i)) ≤ SlabPartition.mean ε (SlabReduction.features p h q) (fun _ => 0) 0 (fun x => ∑ i, b i^2 * MvPolynomial.eval x (SlabReduction.features p h q i)) lemma varying_density_eq {ι : Type*} {κ : Type*} [Fintype ι] [Fintype κ] (p : κ → ι → ℝ) {h₀ h₁ : κ → ℝ} (ha : ∀ i, 0 < h₀ i) (hb : ∀ i, 0 < h₁ i) (ε : ℝ) (q : ℕ) (s : ℝ) : SlabPartition.density ε (SlabReduction.features p h₀ q) (SlabReduction.rates h₀ h₁ q) s = SlabPartition.density ε (SlabReduction.features p (SlabReduction.widths h₀ h₁ s) q) (fun _ => 0) 0 := by classical funext x dsimp [SlabPartition.density, SlabPartition.potential] congr 2 rw [SlabReduction.variation_identification p ha hb, SlabPartition.variation_eq] simp only [pow_zero, zero_mul, Real.exp_zero, one_mul] congr 1 apply Finset.sum_congr rfl intro i _ rw [SlabReduction.features, SlabReduction.eval_feature, SlabReduction.normal_apply] rfl lemma varying_variation_eq {ι : Type*} {κ : Type*} [Fintype ι] [Fintype κ] (p : κ → ι → ℝ) {h₀ h₁ : κ → ℝ} (ha : ∀ i, 0 < h₀ i) (hb : ∀ i, 0 < h₁ i) (q k : ℕ) (s : ℝ) : SlabPartition.variation (SlabReduction.features p h₀ q) (SlabReduction.rates h₀ h₁ q) k s = fun x => ∑ i, (SlabReduction.rates h₀ h₁ q i)^k * MvPolynomial.eval x (SlabReduction.features p (SlabReduction.widths h₀ h₁ s) q i) := by funext x rw [SlabReduction.variation_identification p ha hb] apply Finset.sum_congr rfl intro i _ rw [SlabReduction.features, SlabReduction.eval_feature, SlabReduction.normal_apply] rfl lemma source_variance_at_parameter (hv : SoftVarianceStatement) {n : ℕ} (hn : 2 ≤ n) {κ : Type} [Fintype κ] [Nonempty κ] (p : κ → Fin n → ℝ) (hp : ∀ i, p i ≠ 0) {h₀ h₁ : κ → ℝ} (ha : ∀ i, 0 < h₀ i) (hb : ∀ i, 0 < h₁ i) {ε : ℝ} (hε : 0 < ε) (k : ℕ) (s : ℝ) : SlabPartition.variance ε (SlabReduction.features p h₀ (2*k+2)) (SlabReduction.rates h₀ h₁ (2*k+2)) s (SlabPartition.variation (SlabReduction.features p h₀ (2*k+2)) (SlabReduction.rates h₀ h₁ (2*k+2)) 1 s) ≤ SlabPartition.mean ε (SlabReduction.features p h₀ (2*k+2)) (SlabReduction.rates h₀ h₁ (2*k+2)) s (SlabPartition.variation (SlabReduction.features p h₀ (2*k+2)) (SlabReduction.rates h₀ h₁ (2*k+2)) 2 s) := by have h := hv n hn κ inferInstance inferInstance (2*k+2) ⟨k+1, by omega⟩ (by omega) ε hε p hp (SlabReduction.widths h₀ h₁ s) (fun i => SlabReduction.width_pos (ha i) (hb i) s) (SlabReduction.rates h₀ h₁ (2*k+2)) rw [varying_variation_eq p ha hb, varying_variation_eq p ha hb] simp only [pow_one] simpa only [SlabPartition.variance, SlabPartition.mean, SlabPartition.partition, varying_density_eq p ha hb] using h lemma main_of_softVariance (hv : SoftVarianceStatement) : MainStatement := by intro n hn K L hK hL hsK hsL t ht₀ ht₁ by_cases hn₁ : n = 1 · subst n exact (main_dimension_one hK hL hsK hsL ht₀ ht₁).ge have hn₂ : 2 ≤ n := by omega apply main_of_finite_slabs hn hK hL hsK hsL ht₀ ht₁ intro D hD hunit have ha : ∀ u ∈ D, 0 < support K u := fun u hu => positive_support hK hsK (hunit u hu) have hb : ∀ u ∈ D, 0 < support L u := fun u hu => positive_support hL hsL (hunit u hu) apply finiteSlabs_volume_of_variance D hD (support K) (support L) ha hb ⟨ht₀, ht₁⟩ intro ε hε k s let : Nonempty D := ⟨⟨EuclideanSpace.basisFun (Fin n) ℝ ⟨0, by omega⟩, hD _⟩⟩ apply source_variance_at_parameter hv hn₂ (fun u : D => u.val.ofLp) _ (fun u => ha u.val u.property) (fun u => hb u.val u.property) hε k s intro u hu have hzero : u.val = 0 := by apply WithLp.ofLp_injective exact hu have hnorm := hunit u.val u.property rw [hzero, norm_zero] at hnorm norm_num at hnorm end LogBrunnMinkowski end end noncomputable section namespace SchwartzKernel open Set MeasureTheory Filter Metric FourierTransform open scoped SchwartzMap Topology variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] lemma integral_eq_fourier_zero {F : Type*} [NormedAddCommGroup F] [NormedSpace ℂ F] (K : 𝓢(E,F)) : (∫ t,K t)=(𝓕 K) 0 := by rw [SchwartzMap.fourier_coe,Real.fourier_eq] simp lemma integral_fourierInv (K : 𝓢(E,ℂ)) : (∫ t,(𝓕⁻ K) t)=K 0 := by rw [integral_eq_fourier_zero,FourierTransform.fourier_fourierInv_eq] lemma integral_derivative (K : 𝓢(E,ℂ)) : ∫ t,fderiv ℝ K t=0 := by change (∫ t,(SchwartzMap.fderivCLM ℝ E ℂ K) t)=0 rw [integral_eq_fourier_zero,SchwartzMap.fourier_fderivCLM_eq] ext v simp [SchwartzMap.smulRightCLM_apply_apply] omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in lemma derivative_bound (K : 𝓢(E,ℂ)) : ∃ D,0≤D ∧ ∀ x,‖fderiv ℝ K x‖≤D := by refine ⟨SchwartzMap.seminorm ℝ 0 0 (SchwartzMap.fderivCLM ℝ E ℂ K),by positivity,?_⟩ exact fun x => (SchwartzMap.fderivCLM ℝ E ℂ K).norm_le_seminorm ℝ x theorem hasFDerivAt_convolution (K : 𝓢(E,ℂ)) {f : E → ℂ} (hf : Integrable f volume) (x : E) : HasFDerivAt (fun x => ∫ t,f t*K (x-t)) (∫ t,f t • fderiv ℝ K (x-t)) x := by obtain ⟨D,_hD,hDb⟩ := derivative_bound K have hi (y : E) : Integrable (fun t => f t*K (y-t)) volume := by refine (hf.norm.mul_const (SchwartzMap.seminorm ℝ 0 0 K)).mono' ?_ ?_ · exact hf.aestronglyMeasurable.mul ((K.continuous.comp (continuous_const.sub continuous_id)).aestronglyMeasurable) · filter_upwards with t rw [norm_mul] exact mul_le_mul_of_nonneg_left (K.norm_le_seminorm ℝ _) (norm_nonneg _) have hder (t y : E) : HasFDerivAt (fun y => f t*K (y-t)) (f t • fderiv ℝ K (y-t)) y := by simpa only [ContinuousLinearMap.comp_id,Function.comp_def,id_eq,Pi.smul_apply,smul_eq_mul] using (((K.differentiable (y-t)).hasFDerivAt.comp y ((hasFDerivAt_id y).sub_const t)).const_mul (f t)) apply hasFDerivAt_integral_of_dominated_of_fderiv_le (F' := fun y t => f t • fderiv ℝ K (y-t)) (bound := fun t => ‖f t‖*D) (s:=univ) (by simp) ?_ (hi x) ?_ ?_ ?_ ?_ · exact Filter.Eventually.of_forall (fun y => (hi y).aestronglyMeasurable) · exact hf.aestronglyMeasurable.smul (((K.smooth 1).continuous_fderiv one_ne_zero).comp (continuous_const.sub continuous_id)).aestronglyMeasurable · filter_upwards with t intro y _ rw [norm_smul] exact mul_le_mul_of_nonneg_left (hDb _) (norm_nonneg _) · exact hf.norm.mul_const D · filter_upwards with t intro y _ exact hder t y end SchwartzKernel namespace ScaledKernel open MeasureTheory Set Filter Metric open scoped SchwartzMap Topology variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] variable {F : Type*} [NormedAddCommGroup F] [NormedSpace ℝ F] lemma change_variables (f : E → F) {r : ℝ} (hr : 0 f (x-t)) r (hR:=hr.le) rw [integral_sub_left_eq_self] at he rw [he,smul_smul,mul_inv_cancel₀ (pow_ne_zero _ hr.ne'),one_smul] omit [MeasurableSpace E] [BorelSpace E] in def dilate (K : 𝓢(E,ℂ)) (r : ℝ) (hr : r≠0) : 𝓢(E,ℂ) := SchwartzMap.compCLMOfContinuousLinearEquiv ℂ (LinearEquiv.smulOfNeZero ℝ E r hr).toContinuousLinearEquiv K omit [MeasurableSpace E] [BorelSpace E] in @[simp] lemma dilate_apply (K : 𝓢(E,ℂ)) (r : ℝ) (hr : r≠0) (x : E) : dilate K r hr x=K (r • x) := rfl omit [MeasurableSpace E] [BorelSpace E] in lemma dilate_fderiv (K : 𝓢(E,ℂ)) (r : ℝ) (hr : r≠0) (x : E) : fderiv ℝ (dilate K r hr) x=r • fderiv ℝ K (r • x) := by have hh := (K.differentiable (r • x)).hasFDerivAt.comp x ((hasFDerivAt_id x).const_smul r) change HasFDerivAt (fun y : E => K (r • y)) _ x at hh change fderiv ℝ (fun y : E => K (r • y)) x = _ rw [hh.fderiv] ext v simp def applyKernel (K : 𝓢(E,ℂ)) (r : ℝ) (f : E → ℂ) (x : E) : ℂ := ∫ t,K t*f (x-r • t) lemma apply_eq (K : 𝓢(E,ℂ)) {r : ℝ} (hr : 0 f t*K (r⁻¹ • (x-t))) hr x,smul_smul, inv_mul_cancel₀ (pow_ne_zero _ hr.ne'),one_smul] apply integral_congr_ae filter_upwards with t rw [show x-(x-r • t)=r • t by abel,inv_smul_smul₀ hr.ne'] exact mul_comm _ _ lemma derivative (K : 𝓢(E,ℂ)) {r : ℝ} (hr : 0 (r^Module.finrank ℝ E)⁻¹ • ∫ t,f t*K' (x-t)) := funext (apply_eq K hr f) change HasFDerivAt (fun z => (r^Module.finrank ℝ E)⁻¹ • ∫ t,f t*K' (z-t)) ((r^Module.finrank ℝ E)⁻¹ • ∫ t,f t • fderiv ℝ K' (x-t)) x at hh rw [← hfun] at hh have he : (r^Module.finrank ℝ E)⁻¹ • (∫ t,f t • fderiv ℝ K' (x-t)) = r⁻¹ • ∫ t,f (x-r • t) • fderiv ℝ K t := by simp_rw [K',dilate_fderiv,smul_comm (f _) r⁻¹] rw [integral_smul,change_variables (fun t => f t • fderiv ℝ K (r⁻¹ • (x-t))) hr x] simp_rw [show ∀ t:E,x-(x-r • t)=r • t by intro t; abel,inv_smul_smul₀ hr.ne'] rw [smul_smul,smul_smul] congr 1 field_simp rw [he] at hh exact hh end ScaledKernel namespace AnnularSymbol open Set Filter Metric FourierTransform open scoped SchwartzMap Topology InnerProductSpace ContDiff variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] private def bump : ContDiffBump (0:E) := ⟨1,2,by norm_num,by norm_num⟩ def cutoff (x : E) : ℝ := (bump (E:=E) : E → ℝ) ((1/2:ℝ) • x)-(bump (E:=E) : E → ℝ) x lemma contDiff_cutoff : ContDiff ℝ ∞ (cutoff : E → ℝ) := ((bump (E:=E)).contDiff.comp (contDiff_const.smul contDiff_id)).sub (bump (E:=E)).contDiff lemma compact_cutoff : HasCompactSupport (cutoff : E → ℝ) := ((bump (E:=E)).hasCompactSupport.comp_smul (by norm_num : (1/2:ℝ) ≠ 0)).sub (bump (E:=E)).hasCompactSupport lemma cutoff_zero_near : (cutoff : E → ℝ)=ᶠ[𝓝 0] 0 := by filter_upwards [ball_mem_nhds (0:E) zero_lt_one] with x hx have hx1 : ‖x‖<1 := by simpa only [mem_ball,dist_zero_right] using hx have h1 : x∈closedBall (0:E) (bump (E:=E)).rIn := by change dist x 0≤1 simpa only [dist_zero_right] using hx1.le have h2 : (1/2:ℝ) • x∈closedBall (0:E) (bump (E:=E)).rIn := by change dist ((1/2:ℝ) • x) 0≤1 rw [dist_zero_right,norm_smul,Real.norm_eq_abs,abs_of_nonneg (by norm_num)] linarith [norm_nonneg x] simp only [cutoff,(bump (E:=E)).one_of_mem_closedBall h1,(bump (E:=E)).one_of_mem_closedBall h2,sub_self,Pi.zero_apply] def multiplier (A : E →L[ℝ] E) (v w x : E) : ℂ := Complex.ofReal (cutoff x*(⟪x,v⟫_ℝ * ⟪x,w⟫_ℝ / ⟪x,A x⟫_ℝ)) lemma multiplier_compact (A : E →L[ℝ] E) (v w : E) : HasCompactSupport (multiplier A v w) := (compact_cutoff.mul_right).comp_left (by simp : Complex.ofReal (0:ℝ)=0) lemma multiplier_smooth (A : E →L[ℝ] E) (hA : ∀ x:E,x≠0 → 0<⟪x,A x⟫_ℝ) (v w : E) : ContDiff ℝ ∞ (multiplier A v w) := by rw [contDiff_iff_contDiffAt] intro x by_cases hx : x=0 · subst x apply (show ContDiffAt ℝ ∞ (fun _ : E => (0:ℂ)) 0 from contDiffAt_const).congr_of_eventuallyEq filter_upwards [cutoff_zero_near (E:=E)] with y hy simp only [multiplier,hy,Pi.zero_apply,zero_mul,Complex.ofReal_zero] · exact Complex.ofRealCLM.contDiff.contDiffAt.comp x (contDiff_cutoff.contDiffAt.mul (((contDiffAt_id.inner ℝ contDiffAt_const).mul (contDiffAt_id.inner ℝ contDiffAt_const)).div (contDiffAt_id.inner ℝ A.contDiff.contDiffAt) (hA x hx).ne')) def symbol (A : E →L[ℝ] E) (hA : ∀ x:E,x≠0 → 0<⟪x,A x⟫_ℝ) (v w : E) : 𝓢(E,ℂ) := (multiplier_compact A v w).toSchwartzMap (multiplier_smooth A hA v w) variable [MeasurableSpace E] [BorelSpace E] def kernel (A : E →L[ℝ] E) (hA : ∀ x:E,x≠0 → 0<⟪x,A x⟫_ℝ) (v w : E) : 𝓢(E,ℂ) := 𝓕⁻ (symbol A hA v w) omit [MeasurableSpace E] [BorelSpace E] in lemma symbol_zero (A : E →L[ℝ] E) (hA : ∀ x:E,x≠0 → 0<⟪x,A x⟫_ℝ) (v w : E) : symbol A hA v w 0=0 := by simp [symbol,multiplier] omit [MeasurableSpace E] [BorelSpace E] in lemma inverse_identity (A : E →L[ℝ] E) (hA : ∀ x:E,x≠0 → 0<⟪x,A x⟫_ℝ) (v w x : E) : symbol A hA v w x*Complex.ofReal (⟪x,A x⟫_ℝ)= Complex.ofReal (cutoff x* ⟪x,v⟫_ℝ * ⟪x,w⟫_ℝ) := by by_cases hx : x=0 · subst x; simp [symbol,multiplier] · change Complex.ofReal (cutoff x*(⟪x,v⟫_ℝ * ⟪x,w⟫_ℝ / ⟪x,A x⟫_ℝ))*_=_ rw [← Complex.ofReal_mul] congr 1 field_simp [(hA x hx).ne'] end AnnularSymbol namespace AnnularFourier section open Set MeasureTheory FourierTransform LineDeriv open scoped SchwartzMap InnerProductSpace variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] def product (f g : 𝓢(E,ℂ)) : 𝓢(E,ℂ) := SchwartzMap.pairing (ContinuousLinearMap.mul ℂ ℂ) f g omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in @[simp] lemma product_apply (f g : 𝓢(E,ℂ)) (x : E) : product f g x=f x*g x := rfl def conv (f g : 𝓢(E,ℂ)) : 𝓢(E,ℂ) := SchwartzMap.convolution (ContinuousLinearMap.mul ℂ ℂ) f g lemma fourier_conv (f g : 𝓢(E,ℂ)) : 𝓕 (conv f g)=product (𝓕 f) (𝓕 g) := SchwartzMap.fourier_convolution _ _ _ lemma fourier_dilate (K : 𝓢(E,ℂ)) {r : ℝ} (hr : 0 Real.fourierChar (-⟪t,r⁻¹ • x⟫_ℝ) • K t) r (hR:=hr.le) convert hh using 1 apply integral_congr_ae filter_upwards with t rw [real_inner_smul_left,real_inner_smul_right,mul_inv_cancel_left₀ hr.ne'] rfl lemma fourier_second (u : 𝓢(E,ℂ)) (v w x : E) : 𝓕 (∂_{v} (∂_{w} u)) x= (2*Real.pi*Complex.I)^2*(Complex.ofReal ⟪x,v⟫_ℝ *Complex.ofReal ⟪x,w⟫_ℝ)*𝓕 u x := by have hv : (fun x:E => inner ℝ x v).HasTemperateGrowth := by fun_prop have hw : (fun x:E => inner ℝ x w).HasTemperateGrowth := by fun_prop rw [SchwartzMap.fourier_lineDerivOp_eq,SchwartzMap.fourier_lineDerivOp_eq] simp only [smul_apply,SchwartzMap.smulLeftCLM_apply_apply hv, SchwartzMap.smulLeftCLM_apply_apply hw,smul_eq_mul,Complex.real_smul] ring variable {ι : Type*} [Fintype ι] def elliptic (b : OrthonormalBasis ι ℝ E) (A : E →L[ℝ] E) (u : 𝓢(E,ℂ)) : 𝓢(E,ℂ) := ∑ i,∂_{b i} (∂_{A (b i)} u) omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in lemma quadratic_sum (b : OrthonormalBasis ι ℝ E) (A : E →L[ℝ] E) (x : E) : ∑ i,⟪x,b i⟫_ℝ *⟪x,A (b i)⟫_ℝ =⟪x,A x⟫_ℝ := by calc _ = ⟪x,A (∑ i,(b.repr x) i • b i)⟫_ℝ := by simp only [map_sum,map_smul,inner_sum,real_inner_smul_right,OrthonormalBasis.repr_apply_apply] apply Finset.sum_congr rfl intro i _ rw [real_inner_comm (b i) x] _ = _ := by rw [b.sum_repr] lemma fourier_elliptic (b : OrthonormalBasis ι ℝ E) (A : E →L[ℝ] E) (u : 𝓢(E,ℂ)) (x : E) : 𝓕 (elliptic b A u) x=(2*Real.pi*Complex.I)^2*Complex.ofReal ⟪x,A x⟫_ℝ *𝓕 u x := by simp only [elliptic,FourierTransform.fourier_sum,sum_apply,fourier_second] rw [← Finset.sum_mul,← Finset.mul_sum] simp_rw [← Complex.ofReal_mul] rw [← Complex.ofReal_sum,quadratic_sum] end section open Set MeasureTheory FourierTransform LineDeriv open scoped SchwartzMap InnerProductSpace variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] def normalized (K : 𝓢(E,ℂ)) (r : ℝ) (hr : r≠0) : 𝓢(E,ℂ) := (r^Module.finrank ℝ E)⁻¹ • ScaledKernel.dilate K r⁻¹ (inv_ne_zero hr) lemma fourier_normalized (K : 𝓢(E,ℂ)) {r : ℝ} (hr : 0 K (r⁻¹ • t)*u (x-t)) r (hR:=hr.le) rw [← hh] simp only [inv_smul_smul₀ hr.ne',ScaledKernel.applyKernel] def annulus : 𝓢(E,ℂ) := (AnnularSymbol.compact_cutoff.comp_left (by simp : Complex.ofReal (0:ℝ)=0)).toSchwartzMap (Complex.ofRealCLM.contDiff.comp AnnularSymbol.contDiff_cutoff) omit [MeasurableSpace E] [BorelSpace E] in @[simp] lemma annulus_apply (x : E) : annulus x=Complex.ofReal (AnnularSymbol.cutoff x) := rfl omit [MeasurableSpace E] [BorelSpace E] in lemma inverse_scaled (A : E →L[ℝ] E) (hA : ∀ x:E,x≠0 → 0<⟪x,A x⟫_ℝ) (v w x : E) {r : ℝ} (hr : r≠0) : AnnularSymbol.symbol A hA v w (r • x)*Complex.ofReal ⟪x,A x⟫_ℝ = Complex.ofReal (AnnularSymbol.cutoff (r • x)*⟪x,v⟫_ℝ *⟪x,w⟫_ℝ) := by by_cases hx : x=0 · subst x; simp [AnnularSymbol.symbol,AnnularSymbol.multiplier] · change Complex.ofReal (AnnularSymbol.cutoff (r • x)* (⟪r • x,v⟫_ℝ *⟪r • x,w⟫_ℝ /⟪r • x,A (r • x)⟫_ℝ))*_= _ rw [← Complex.ofReal_mul] congr 1 simp only [map_smul,real_inner_smul_left,real_inner_smul_right] field_simp [(hA x hx).ne',hr] variable {ι : Type*} [Fintype ι] theorem annular_identity (b : OrthonormalBasis ι ℝ E) (A : E →L[ℝ] E) (hA : ∀ x:E,x≠0 → 0<⟪x,A x⟫_ℝ) (v w : E) (u : 𝓢(E,ℂ)) {r : ℝ} (hr : 0 lowFilter u (r n) (hr n) x) atTop (𝓝 (u x)) := by have hh := tendsto_integral_of_dominated_convergence (μ := (volume : Measure E)) (F := fun (n:ℕ) (t:E) => Real.fourierChar ⟪t,x⟫_ℝ • ((lowSymbol : 𝓢(E,ℂ)) (r n • t)*𝓕 u t)) (f := fun t:E => Real.fourierChar ⟪t,x⟫_ℝ • 𝓕 u t) (fun t:E => ‖𝓕 u t‖) (fun n => ((Real.continuous_fourierChar.comp (by fun_prop : Continuous (fun t:E => ⟪t,x⟫_ℝ))).smul (((lowSymbol : 𝓢(E,ℂ)).continuous.comp (continuous_const.smul continuous_id : Continuous (fun t:E => r n • t))).mul (𝓕 u).continuous)).aestronglyMeasurable) (𝓕 u).integrable.norm (fun n => Filter.Eventually.of_forall (fun t => by rw [Circle.norm_smul,norm_mul] exact mul_le_of_le_one_left (norm_nonneg _) (lowSymbol_bound _))) (Filter.Eventually.of_forall (fun t:E => by have hrt : Tendsto (fun n => r n • t) atTop (𝓝 (0:E)) := by simpa using hlim.smul_const t have hchi := ((lowSymbol : 𝓢(E,ℂ)).continuous.tendsto 0).comp hrt rw [lowSymbol_zero] at hchi simpa only [one_mul,Function.comp_def] using (tendsto_const_nhds.smul (hchi.mul_const (𝓕 u t))))) have hu : (∫ t:E,Real.fourierChar ⟪t,x⟫_ℝ • 𝓕 u t)=u x := by rw [← Real.fourierInv_eq,← SchwartzMap.fourierInv_coe,FourierTransform.fourierInv_fourier_eq] rw [hu] at hh simpa only [lowFilter,SchwartzMap.fourierInv_coe,Real.fourierInv_eq,product_apply, ScaledKernel.dilate_apply] using hh lemma inverse_sub (f g : 𝓢(E,ℂ)) : 𝓕⁻ (f-g)=𝓕⁻ f-𝓕⁻ g := map_sub (fourierInvCLM ℂ (𝓢(E,ℂ))) f g lemma piece_telescope (u : 𝓢(E,ℂ)) (n : ℕ) : 𝓕⁻ (product (ScaledKernel.dilate annulus ((1/2:ℝ)^n) (pow_ne_zero _ (by norm_num))) (𝓕 u))= lowFilter u ((1/2:ℝ)^(n+1)) (pow_ne_zero _ (by norm_num))- lowFilter u ((1/2:ℝ)^n) (pow_ne_zero _ (by norm_num)) := by rw [lowFilter,lowFilter,← inverse_sub] congr 1 ext x simp only [product_apply,ScaledKernel.dilate_apply,sub_apply,annulus_low,pow_succ] simp only [smul_smul] rw [mul_comm ((1/2:ℝ)^n) (1/2)] ring end AnnularFourier namespace VectorKernelHolder open MeasureTheory Set Filter Metric open scoped SchwartzMap NNReal Topology variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] lemma rpow_bound {a : ℝ} (ha : 0≤a) (ha1 : a≤1) (t : ℝ) (ht : 0≤t) : t^a≤1+t := by by_cases ht1 : t≤1 · exact (Real.rpow_le_one ht ht1 ha).trans (le_add_of_nonneg_right ht) · have hh := Real.rpow_le_rpow_of_exponent_le (le_of_lt (lt_of_not_ge ht1)) ha1 rw [Real.rpow_one] at hh linarith variable {F : Type*} [NormedAddCommGroup F] [NormedSpace ℂ F] [CompleteSpace F] omit [CompleteSpace F] in lemma integrable_moment (K : 𝓢(E,F)) {a : ℝ} (ha : 0 ‖K t‖*‖t‖^a) volume := by have hi := K.integrable.norm.add (K.integrable_pow_mul volume 1) apply hi.mono' ((K.continuous.norm.mul (continuous_norm.rpow_const (fun _ => Or.inr ha.le))).aestronglyMeasurable) filter_upwards with t change ‖‖K t‖*‖t‖^a‖ ≤ ‖K t‖+‖t‖^1*‖K t‖ rw [Real.norm_eq_abs,abs_of_nonneg (by positivity)] simpa only [pow_one,mul_add,mul_one,mul_comm,add_mul,one_mul] using mul_le_mul_of_nonneg_left (rpow_bound ha.le ha1 ‖t‖ (norm_nonneg _)) (norm_nonneg (K t)) omit [CompleteSpace F] in theorem cancellation_bound (K : 𝓢(E,F)) (hK : ∫ t,K t=0) {a C r : ℝ} (ha : 0 f (x-r • t) • K t) volume := by apply (K.integrable.norm.mul_const B).mono' (((hf.comp (continuous_const.sub (continuous_const.smul continuous_id))).smul K.continuous).aestronglyMeasurable) filter_upwards with t change ‖f (x-r • t) • K t‖≤‖K t‖*B rw [norm_smul] exact (mul_le_mul_of_nonneg_right (hB _) (norm_nonneg _)).trans_eq (mul_comm _ _) have hic : Integrable (fun t => f x • K t) volume := K.integrable.smul _ have he : (∫ t,f (x-r • t) • K t)=∫ t,(f (x-r • t)-f x) • K t := by simp_rw [sub_smul] rw [integral_sub hi hic,integral_smul,hK,smul_zero,sub_zero] rw [he] have hm := integrable_moment K ha ha1 calc _ ≤ ∫ t,‖(f (x-r • t)-f x) • K t‖ := norm_integral_le_integral_norm _ _ ≤ ∫ t,C*r^a*(‖K t‖*‖t‖^a) := by apply integral_mono_of_nonneg (Filter.Eventually.of_forall (fun t => norm_nonneg _)) (hm.const_mul _) filter_upwards with t rw [norm_smul] have hh := hhold (x-r • t) x simp only [dist_eq_norm] at hh rw [show x-r • t-x = -(r • t) by abel,norm_neg,norm_smul, Real.norm_eq_abs,abs_of_pos hr,Real.mul_rpow hr.le (norm_nonneg _)] at hh nlinarith [mul_le_mul_of_nonneg_left hh (norm_nonneg (K t))] _ = _ := integral_const_mul _ _ end VectorKernelHolder namespace ScaleSeries open Set Filter Metric open scoped NNReal Topology variable {E : Type*} {F : Type*} [PseudoMetricSpace E] [NormedAddCommGroup F] [CompleteSpace F] lemma summable_bound {k C : ℝ} (hk0 : 0≤k) (hk : k<1) {f : ℕ → F} (hb : ∀ n,‖f n‖≤C*k^n) : Summable f := by have hs : Summable (fun n : ℕ => k^n) := summable_geometric_of_norm_lt_one (by simpa only [Real.norm_eq_abs,abs_of_nonneg hk0] using hk) exact Summable.of_norm_bounded (hs.mul_left C) hb omit [CompleteSpace F] in lemma tail_bound {k C : ℝ} (hk0 : 0≤k) (hk : k<1) {f : ℕ → F} (hb : ∀ n,‖f n‖≤C*k^n) (N : ℕ) : ‖∑' n,f (n+N)‖≤C*k^N/(1-k) := by have hgeo : Summable (fun n : ℕ => k^n) := summable_geometric_of_norm_lt_one (by simpa only [Real.norm_eq_abs,abs_of_nonneg hk0] using hk) have hg : Summable (fun n => C*k^(n+N)) := by simpa only [pow_add,mul_left_comm,mul_assoc,mul_comm] using hgeo.mul_left (C*k^N) have hnorm : Summable (fun n => ‖f (n+N)‖) := Summable.of_nonneg_of_le (fun _ => norm_nonneg _) (fun n => hb (n+N)) hg calc _ ≤ ∑' n, ‖f (n+N)‖ := norm_tsum_le_tsum_norm hnorm _ ≤ ∑' n, C*k^(n+N) := Summable.tsum_le_tsum (fun n => hb (n+N)) hnorm hg _ = C*k^N/(1-k) := by simp_rw [pow_add,mul_comm (k^_) (k^N),← mul_assoc] rw [tsum_mul_left,tsum_geometric_of_norm_lt_one (by simpa only [Real.norm_eq_abs,abs_of_nonneg hk0] using hk)] ring omit [CompleteSpace F] in lemma finite_bound {r k C : ℝ} (hr : 0 le_rfl) _ ≤ ∑ n∈Finset.range N,C*(k/r)^n*r^N := Finset.sum_le_sum (fun n _ => (hl n x y).trans (mul_le_mul_of_nonneg_left hxy (by positivity))) _ = C*r^N*((k/r)^N-1)/(k/r-1) := by rw [← Finset.sum_mul,← Finset.mul_sum,geom_sum_eq hq.ne'] ring _ ≤ C*r^N*(k/r)^N/(k/r-1) := div_le_div_of_nonneg_right (mul_le_mul_of_nonneg_left (sub_le_self _ zero_le_one) (by positivity)) (by linarith) _ = C/(k/r-1)*k^N := by rw [div_pow]; field_simp theorem modulus_sum {r k C : ℝ} (hr : 0 f n x)) ∧ ∀ N x y,dist x y≤r^N → dist (∑' n,f n x) (∑' n,f n y)≤ (C/(k/r-1)+2*C/(1-k))*k^N := by have hk0 : 0 f n x) := summable_bound hk0.le hk (hb · x) refine ⟨hsum,?_⟩ intro N x y hxy have hfin := finite_bound hr hrk hC hl N x y hxy have htail (z : E) := tail_bound hk0.le hk (hb · z) N rw [← (hsum x).sum_add_tsum_nat_add N,← (hsum y).sum_add_tsum_nat_add N] calc _ ≤ dist (∑ n∈Finset.range N,f n x) (∑ n∈Finset.range N,f n y)+ dist (∑' n,f (n+N) x) (∑' n,f (n+N) y) := dist_add_add_le _ _ _ _ _ ≤ C/(k/r-1)*k^N+(C*k^N/(1-k)+C*k^N/(1-k)) := add_le_add hfin ((dist_le_norm_add_norm _ _).trans (add_le_add (htail x) (htail y))) _ = _ := by ring end ScaleSeries namespace KernelSeries open Set MeasureTheory Metric Filter open scoped SchwartzMap Topology variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] lemma apply_bound (K : 𝓢(E,ℂ)) (hK : ∫ t,K t=0) {a C r : ℝ} (ha : 0 (ScaledKernel.derivative K hr hfi z).differentiableAt) (fun z _ => derivative_bound K ha ha1 hC hr hf hfi hB hhold z) convex_univ (mem_univ y) (mem_univ x) theorem holder_sum (K : 𝓢(E,ℂ)) (hK : ∫ t,K t=0) {a q : ℝ} (ha : 0 ScaledKernel.applyKernel K (q^n) f x)) ∧ ∀ x y,dist x y≤1 → dist (∑' n : ℕ,ScaledKernel.applyKernel K (q^n) f x) (∑' n : ℕ,ScaledKernel.applyKernel K (q^n) f y)≤(T*C)*dist x y^a := by let k := q^a have hk0 : 0 by positivity) have hJ1 : 0≤J1 := integral_nonneg (fun _ => by positivity) let J := max J0 J1 have hJ : 0≤J := hJ0.trans (le_max_left _ _) let T := (J/(k/q-1)+2*J/(1-k))/k have hkq : 1 ScaledKernel.applyKernel (AnnularSymbol.kernel A hA v w) ((1/2:ℝ)^n) (elliptic b A u) x)) : (∂_{v} (∂_{w} u)) x=lowFilter (∂_{v} (∂_{w} u)) 1 one_ne_zero x+ ∑' n : ℕ,ScaledKernel.applyKernel (AnnularSymbol.kernel A hA v w) ((1/2:ℝ)^n) (elliptic b A u) x := by let H := ∂_{v} (∂_{w} u) let K := AnnularSymbol.kernel A hA v w let F := fun n : ℕ => lowFilter H ((1/2:ℝ)^n) (pow_ne_zero _ (by norm_num)) x have hn (n : ℕ) : ScaledKernel.applyKernel K ((1/2:ℝ)^n) (elliptic b A u) x=F (n+1)-F n := by rw [← normalized_conv _ _ (pow_pos (by norm_num : (0:ℝ)<1/2) _),annular_identity (hr := pow_pos (by norm_num : (0:ℝ)<1/2) n), piece_telescope] rfl have htel (N : ℕ) : (∑ n∈Finset.range N,ScaledKernel.applyKernel K ((1/2:ℝ)^n) (elliptic b A u) x)=F N-F 0 := by simp_rw [hn] induction N with | zero => simp | succ N ih => rw [Finset.sum_range_succ,ih]; abel have hlim : Tendsto F atTop (𝓝 (H x)) := lowFilter_tendsto H _ (tendsto_pow_atTop_nhds_zero_of_lt_one (by norm_num : (0:ℝ)≤1/2) (by norm_num)) x change Summable (fun n:ℕ => ScaledKernel.applyKernel K ((1/2:ℝ)^n) (elliptic b A u) x) at hSum have he := tendsto_nhds_unique hSum.hasSum.tendsto_sum_nat (by simpa only [htel] using hlim.sub_const (F 0)) change _=H x-F 0 at he change H x=F 0+_ rw [he] abel omit [Fintype ι] in lemma lowFilter_eq_kernel (u : 𝓢(E,ℂ)) (x : E) : lowFilter u 1 one_ne_zero x=ScaledKernel.applyKernel (lowKernel : 𝓢(E,ℂ)) 1 u x := by rw [← normalized_conv _ _ zero_lt_one] have he : 𝓕 (conv (normalized (lowKernel : 𝓢(E,ℂ)) 1 one_ne_zero) u)= product (ScaledKernel.dilate lowSymbol 1 one_ne_zero) (𝓕 u) := by ext y rw [fourier_conv,product_apply,fourier_normalized _ zero_lt_one, lowKernel,fourier_fourierInv_eq,product_apply,ScaledKernel.dilate_apply] have hh := congrArg (fun f : 𝓢(E,ℂ) => 𝓕⁻ f) he rw [fourierInv_fourier_eq] at hh exact congrArg (fun f : 𝓢(E,ℂ) => f x) hh.symm omit [Fintype ι] in lemma lowFilter_lipschitz (u : 𝓢(E,ℂ)) {B : ℝ} (hB : ∀ x,‖u x‖≤B) (x y : E) : dist (lowFilter u 1 one_ne_zero x) (lowFilter u 1 one_ne_zero y)≤ (B*∫ t,‖fderiv ℝ (lowKernel : 𝓢(E,ℂ)) t‖)*dist x y := by let K : 𝓢(E,ℂ) := lowKernel have hfun : (fun x => lowFilter u 1 one_ne_zero x)=ScaledKernel.applyKernel K 1 u := funext (lowFilter_eq_kernel u) have hd (z : E) := ScaledKernel.derivative K zero_lt_one u.integrable z have hb (z : E) : ‖fderiv ℝ (ScaledKernel.applyKernel K 1 u) z‖≤B*∫ t,‖fderiv ℝ K t‖ := by rw [(hd z).fderiv] simp only [inv_one,one_smul] calc _ ≤ ∫ t,‖u (z-t) • fderiv ℝ K t‖ := norm_integral_le_integral_norm _ _ ≤ ∫ t,B*‖fderiv ℝ K t‖ := by apply integral_mono_of_nonneg (Filter.Eventually.of_forall (fun _ => norm_nonneg _)) ((SchwartzMap.fderivCLM ℝ E ℂ K).integrable.norm.const_mul B) filter_upwards with t rw [norm_smul] exact mul_le_mul_of_nonneg_right (hB _) (norm_nonneg _) _ = _ := integral_const_mul _ _ rw [show lowFilter u 1 one_ne_zero x=ScaledKernel.applyKernel K 1 u x from congrFun hfun x, show lowFilter u 1 one_ne_zero y=ScaledKernel.applyKernel K 1 u y from congrFun hfun y] simpa only [dist_eq_norm] using Convex.norm_image_sub_le_of_norm_fderiv_le (fun z (_ : z∈(univ : Set E)) => (hd z).differentiableAt) (fun z _ => hb z) convex_univ (mem_univ y) (mem_univ x) theorem schwartz_schauder (b : OrthonormalBasis ι ℝ E) (A : E →L[ℝ] E) (hA : ∀ x:E,x≠0 → 0<⟪x,A x⟫_ℝ) (v w : E) {a : ℝ} (ha : 0 norm_nonneg _) refine ⟨max J T,le_max_of_le_left hJ,?_⟩ intro u C B hC hB hUb hHold x y hxy obtain ⟨hSum,hHolder⟩ := hSeries C hC (elliptic b A u) (elliptic b A u).continuous (elliptic b A u).integrable ⟨SchwartzMap.seminorm ℝ 0 0 (elliptic b A u), (elliptic b A u).norm_le_seminorm ℝ⟩ hHold rw [decompose b A hA v w u x (hSum x),decompose b A hA v w u y (hSum y)] apply (dist_add_add_le _ _ _ _).trans have hLow := lowFilter_lipschitz (∂_{v} (∂_{w} u)) hUb x y have hHigh := hHolder x y hxy have hd : dist x y≤dist x y^a := by by_cases h0 : dist x y=0 · rw [h0,Real.zero_rpow (ne_of_gt ha)] · simpa only [Real.rpow_one] using Real.rpow_le_rpow_of_exponent_ge (lt_of_le_of_ne dist_nonneg (Ne.symm h0)) hxy ha1.le have hb := mul_le_mul_of_nonneg_left hd (mul_nonneg hB hJ) have hj := mul_le_mul_of_nonneg_left (le_max_left J T) hB have ht := mul_le_mul_of_nonneg_left (le_max_right J T) hC change _≤B*J*dist x y at hLow apply (add_le_add (hLow.trans hb) hHigh).trans nlinarith [mul_le_mul_of_nonneg_right hj (Real.rpow_nonneg (dist_nonneg : 0≤dist x y) a), mul_le_mul_of_nonneg_right ht (Real.rpow_nonneg (dist_nonneg : 0≤dist x y) a)] end AnnularFourier namespace KernelCommutator open Set MeasureTheory Metric Filter open scoped SchwartzMap Topology variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] lemma integrable_mul (K : 𝓢(E,ℂ)) {f : E → ℂ} (hf : Continuous f) {B : ℝ} (hB : ∀ x,‖f x‖≤B) (r : ℝ) (x : E) : Integrable (fun t => K t*f (x-r • t)) volume := by apply (K.integrable.norm.mul_const B).mono' ((K.continuous.mul (hf.comp (continuous_const.sub (continuous_const.smul continuous_id)))).aestronglyMeasurable) filter_upwards with t change ‖K t*f (x-r • t)‖≤‖K t‖*B rw [norm_mul] exact mul_le_mul_of_nonneg_left (hB _) (norm_nonneg _) lemma apply_bound (K : 𝓢(E,ℂ)) {f : E → ℂ} {B : ℝ} (hB : ∀ x,‖f x‖≤B) (r : ℝ) (x : E) : ‖ScaledKernel.applyKernel K r f x‖≤B*∫ t,‖K t‖ := by apply (norm_integral_le_integral_norm _).trans calc (∫ t,‖K t*f (x-r • t)‖)≤∫ t,B*‖K t‖ := by apply integral_mono_of_nonneg (Filter.Eventually.of_forall (fun _ => norm_nonneg _)) (K.integrable.norm.const_mul B) filter_upwards with t rw [norm_mul] exact (mul_le_mul_of_nonneg_left (hB _) (norm_nonneg _)).trans_eq (mul_comm _ _) _ = _ := integral_const_mul _ _ def anchored (K : 𝓢(E,ℂ)) (r : ℝ) (a f : E → ℂ) (x z : E) : ℂ := ScaledKernel.applyKernel K r (fun t => (a t-a x)*f t) z def commutator (K : 𝓢(E,ℂ)) (r : ℝ) (a f : E → ℂ) (x : E) : ℂ := anchored K r a f x x lemma commutator_bound (K : 𝓢(E,ℂ)) {a f : E → ℂ} {s C B r : ℝ} (hs : 0 norm_nonneg _)) ((VectorKernelHolder.integrable_moment K hs hs1).const_mul _) filter_upwards with t simp only [norm_mul] have hh := hhold (x-r • t) x simp only [dist_eq_norm] at hh rw [show x-r • t-x= -(r • t) by abel,norm_neg,norm_smul, Real.norm_eq_abs,abs_of_pos hr,Real.mul_rpow hr.le (norm_nonneg _)] at hh calc _ ≤ ‖K t‖*((C*(r^s*‖t‖^s))*B) := mul_le_mul_of_nonneg_left (mul_le_mul hh (hB _) (norm_nonneg _) (mul_nonneg hC (by positivity))) (norm_nonneg _) _ = _ := by ring _ = _ := integral_const_mul _ _ lemma integrable_weighted_derivative (K : 𝓢(E,ℂ)) : Integrable (fun t => (1+‖t‖)*‖fderiv ℝ K t‖) volume := by have hi : Integrable (fun t:E => ‖fderiv ℝ K t‖) volume := (SchwartzMap.fderivCLM ℝ E ℂ K).integrable.norm have hi2 : Integrable (fun t:E => ‖t‖*‖fderiv ℝ K t‖) volume := by simpa only [pow_one,SchwartzMap.fderivCLM_apply] using (SchwartzMap.fderivCLM ℝ E ℂ K).integrable_pow_mul volume 1 apply (hi.add hi2).congr filter_upwards with t change ‖fderiv ℝ K t‖+‖t‖*‖fderiv ℝ K t‖=(1+‖t‖)*‖fderiv ℝ K t‖ ring lemma anchored_derivative_bound (K : 𝓢(E,ℂ)) {a f : E → ℂ} (hfi : Integrable f volume) (hafi : Integrable (fun t => a t*f t) volume) {s C B r : ℝ} (hs : 0 (a t-a x)*f t) volume := by apply (hafi.sub (hfi.const_mul (a x))).congr filter_upwards with t change a t*f t-a x*f t=(a t-a x)*f t ring unfold anchored rw [(ScaledKernel.derivative K hr hi z).fderiv,norm_smul,Real.norm_eq_abs,abs_of_pos (inv_pos.mpr hr)] have hanchor (t : E) : ‖a (z-r • t)-a x‖≤C*r^s*(1+‖t‖) := by have hh := hhold (z-r • t) x rw [dist_eq_norm (a (z-r • t)) (a x)] at hh have hd : dist (z-r • t) x≤r*(1+‖t‖) := by have ht := dist_triangle (z-r • t) z x rw [dist_eq_norm (z-r • t) z,show z-r • t-z= -(r • t) by abel, norm_neg,norm_smul,Real.norm_eq_abs,abs_of_pos hr] at ht nlinarith have hp := Real.rpow_le_rpow dist_nonneg hd hs.le rw [Real.mul_rpow hr.le (by positivity : 0≤1+‖t‖)] at hp have hp1 : (1+‖t‖)^s≤1+‖t‖ := by simpa only [Real.rpow_one] using Real.rpow_le_rpow_of_exponent_le (by linarith [norm_nonneg t] : 1≤1+‖t‖) hs1 calc _ ≤ C*dist (z-r • t) x^s := hh _ ≤ C*(r^s*(1+‖t‖)^s) := mul_le_mul_of_nonneg_left hp hC _ ≤ C*(r^s*(1+‖t‖)) := mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_left hp1 (Real.rpow_nonneg hr.le s)) hC _ = _ := by ring have hb : ‖∫ t,((a (z-r • t)-a x)*f (z-r • t)) • fderiv ℝ K t‖≤ (C*B)*r^s*(∫ t,(1+‖t‖)*‖fderiv ℝ K t‖) := by apply (norm_integral_le_integral_norm _).trans calc (∫ t,‖((a (z-r • t)-a x)*f (z-r • t)) • fderiv ℝ K t‖)≤ ∫ t,(C*B)*r^s*((1+‖t‖)*‖fderiv ℝ K t‖) := by apply integral_mono_of_nonneg (Filter.Eventually.of_forall (fun _ => norm_nonneg _)) ((integrable_weighted_derivative K).const_mul _) filter_upwards with t rw [norm_smul,norm_mul] calc _ ≤ (C*r^s*(1+‖t‖)*B)*‖fderiv ℝ K t‖ := mul_le_mul_of_nonneg_right (mul_le_mul (hanchor t) (hB _) (norm_nonneg _) (by positivity)) (norm_nonneg _) _ = _ := by ring _ = _ := integral_const_mul _ _ calc _ ≤ r⁻¹*((C*B)*r^s*(∫ t,(1+‖t‖)*‖fderiv ℝ K t‖)) := mul_le_mul_of_nonneg_left hb (inv_nonneg.mpr hr.le) _ = _ := by ring end KernelCommutator namespace ScaledKernel open Set MeasureTheory Metric Filter open scoped SchwartzMap Topology variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] lemma holder_apply (K : 𝓢(E,ℂ)) {f : E → ℂ} (hf : Continuous f) {a C B r : ℝ} (hB : ∀ x,‖f x‖≤B) (hhold : ∀ x y,dist (f x) (f y)≤C*dist x y^a) (x y : E) : dist (applyKernel K r f x) (applyKernel K r f y)≤ (C*∫ t,‖K t‖)*dist x y^a := by rw [dist_eq_norm,applyKernel,applyKernel,← integral_sub (KernelCommutator.integrable_mul K hf hB r x) (KernelCommutator.integrable_mul K hf hB r y)] apply (norm_integral_le_integral_norm _).trans calc (∫ t,‖K t*f (x-r • t)-K t*f (y-r • t)‖)≤∫ t,(C*dist x y^a)*‖K t‖ := by apply integral_mono_of_nonneg (Filter.Eventually.of_forall (fun _ => norm_nonneg _)) (K.integrable.norm.const_mul _) filter_upwards with t rw [← mul_sub,norm_mul] have hh := hhold (x-r • t) (y-r • t) rw [dist_sub_right,dist_eq_norm (f _) (f _)] at hh exact (mul_le_mul_of_nonneg_left hh (norm_nonneg _)).trans_eq (mul_comm _ _) _ = _ := by rw [integral_const_mul]; ring lemma apply_tendsto (K : 𝓢(E,ℂ)) (hK : ∫ t,K t=1) {f : E → ℂ} (hf : Continuous f) {B : ℝ} (hB : ∀ x,‖f x‖≤B) {r : ℕ → ℝ} (hr : Tendsto r atTop (𝓝 0)) (x : E) : Tendsto (fun n => applyKernel K (r n) f x) atTop (𝓝 (f x)) := by have hh := tendsto_integral_of_dominated_convergence (μ := (volume : Measure E)) (F := fun (n:ℕ) (t:E) => K t*f (x-r n • t)) (f := fun t:E => K t*f x) (fun t:E => ‖K t‖*B) (fun n => (KernelCommutator.integrable_mul K hf hB (r n) x).aestronglyMeasurable) (K.integrable.norm.mul_const B) (fun n => Filter.Eventually.of_forall (fun t => by rw [norm_mul] exact mul_le_mul_of_nonneg_left (hB _) (norm_nonneg _))) (Filter.Eventually.of_forall (fun t:E => by have ht : Tendsto (fun n => x-r n • t) atTop (𝓝 x) := by simpa only [zero_smul,sub_zero] using tendsto_const_nhds.sub (hr.smul_const t) exact tendsto_const_nhds.mul ((hf.tendsto x).comp ht))) rw [integral_mul_const,hK,one_mul] at hh exact hh end ScaledKernel namespace CompactMollification section open Set MeasureTheory Metric Filter LineDeriv open scoped SchwartzMap Topology InnerProductSpace Convolution ContDiff variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] def dd (u : E → ℂ) (v w x : E) : ℂ := fderiv ℝ (fun z => fderiv ℝ u z w) x v lemma conv_eq (K : 𝓢(E,ℂ)) {r : ℝ} (hr : 0 K (r⁻¹ • t)*u (x-t)) r (hR:=hr.le) rw [← hh] simp only [inv_smul_smul₀ hr.ne',ScaledKernel.applyKernel] omit [MeasurableSpace E] [BorelSpace E] in lemma normalized_compact (K : 𝓢(E,ℂ)) (hK : HasCompactSupport (K : E → ℂ)) {r : ℝ} (hr : r≠0) : HasCompactSupport (AnnularFourier.normalized K r hr : E → ℂ) := (hK.comp_smul (inv_ne_zero hr)).smul_left lemma apply_compact (K : 𝓢(E,ℂ)) (hK : HasCompactSupport (K : E → ℂ)) {r : ℝ} (hr : 0 fderiv ℝ u z v) x := by rw [← conv_eq K hr u] rw [(hc.hasFDerivAt_convolution_right (ContinuousLinearMap.mul ℝ ℂ) (AnnularFourier.normalized K r hr.ne').integrable.locallyIntegrable hu x).fderiv] rw [convolution_precompR_apply _ (AnnularFourier.normalized K r hr.ne').integrable.locallyIntegrable (hc.fderiv ℝ) (hu.continuous_fderiv one_ne_zero),conv_eq K hr] omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in lemma derivative_compact {u : E → ℂ} (hc : HasCompactSupport u) (v : E) : HasCompactSupport (fun z => fderiv ℝ u z v) := (hc.fderiv ℝ).comp_left (g := fun T : E →L[ℝ] ℂ => T v) (by simp) omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in lemma derivative_C1 {u : E → ℂ} (hu : ContDiff ℝ 2 u) (v : E) : ContDiff ℝ 1 (fun z => fderiv ℝ u z v) := (hu.fderiv_right (by norm_num)).clm_apply contDiff_const lemma apply_second (K : 𝓢(E,ℂ)) {r : ℝ} (hr : 0 fderiv ℝ (ScaledKernel.applyKernel K r u) z w)= ScaledKernel.applyKernel K r (fun z => fderiv ℝ u z w) from funext (apply_derivative K hr hc (hu.of_le (by norm_num)) w)] exact apply_derivative K hr (derivative_compact hc w) (derivative_C1 hu w) v x omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in lemma dd_continuous {u : E → ℂ} (hu : ContDiff ℝ 2 u) (v w : E) : Continuous (dd u v w) := ((derivative_C1 hu w).continuous_fderiv one_ne_zero).clm_apply continuous_const omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in lemma dd_compact {u : E → ℂ} (hc : HasCompactSupport u) (v w : E) : HasCompactSupport (dd u v w) := derivative_compact (derivative_compact hc w) v omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in lemma dd_schwartz (u : 𝓢(E,ℂ)) (v w x : E) : (∂_{v} (∂_{w} u)) x=dd u v w x := by rw [SchwartzMap.lineDerivOp_apply_eq_fderiv] rw [show ((∂_{w} u : 𝓢(E,ℂ)) : E → ℂ)=(fun z => fderiv ℝ u z w) from funext (fun z => SchwartzMap.lineDerivOp_apply_eq_fderiv w u z)] rfl def mollifier : 𝓢(E,ℂ) := (((AnnularFourier.lowBump (E:=E)).hasCompactSupport_normed (μ:=volume)).comp_left (by simp : Complex.ofReal (0:ℝ)=0)).toSchwartzMap (Complex.ofRealCLM.contDiff.comp (AnnularFourier.lowBump (E:=E)).contDiff_normed) lemma mollifier_compact : HasCompactSupport (mollifier : E → ℂ) := ((AnnularFourier.lowBump (E:=E)).hasCompactSupport_normed (μ:=volume)).comp_left (by simp : Complex.ofReal (0:ℝ)=0) lemma mollifier_integral : ∫ t:E,mollifier t=1 := by have hh := Complex.ofRealCLM.integral_comp_comm ((AnnularFourier.lowBump (E:=E)).integrable_normed (μ:=volume)) rw [(AnnularFourier.lowBump (E:=E)).integral_normed] at hh exact hh lemma mollifier_norm : ∫ t:E,‖mollifier t‖=1 := by change (∫ t:E,‖Complex.ofReal ((AnnularFourier.lowBump (E:=E)).normed volume t)‖)=1 simp only [Complex.norm_real,Real.norm_eq_abs,abs_of_nonneg ((AnnularFourier.lowBump (E:=E)).nonneg_normed (μ:=volume) _)] exact (AnnularFourier.lowBump (E:=E)).integral_normed end open Set MeasureTheory Metric Filter LineDeriv open scoped SchwartzMap Topology InnerProductSpace Convolution ContDiff variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] variable {ι : Type*} [Fintype ι] def elliptic (b : OrthonormalBasis ι ℝ E) (A : E →L[ℝ] E) (u : E → ℂ) (x : E) : ℂ := ∑ i,dd u (b i) (A (b i)) x omit [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in lemma bounded_compact {f : E → ℂ} (hc : HasCompactSupport f) (hf : Continuous f) : ∃ B : ℝ,∀ x,‖f x‖≤B := by obtain ⟨B,hB⟩ := hf.norm.bddAbove_range_of_hasCompactSupport (hc.comp_left (g := fun z : ℂ => ‖z‖) (norm_zero)) exact ⟨B,fun x => hB (mem_range_self x)⟩ omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in lemma elliptic_continuous (b : OrthonormalBasis ι ℝ E) (A : E →L[ℝ] E) {u : E → ℂ} (hu : ContDiff ℝ 2 u) : Continuous (elliptic b A u) := continuous_finsetSum _ (fun i _ => dd_continuous hu (b i) (A (b i))) omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in lemma elliptic_compact (b : OrthonormalBasis ι ℝ E) (A : E →L[ℝ] E) {u : E → ℂ} (hc : HasCompactSupport u) : HasCompactSupport (elliptic b A u) := by change HasCompactSupport (fun x => ∑ i,dd u (b i) (A (b i)) x) have ht := HasCompactSupport.finset_sum (s := Finset.univ) (f := fun i => dd u (b i) (A (b i))) (fun i _ => dd_compact hc (b i) (A (b i))) have heq : (∑ i, dd u (b i) (A (b i))) = (fun x => ∑ i, dd u (b i) (A (b i)) x) := by ext x simp only [Finset.sum_apply] rw [heq] at ht exact ht omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in lemma elliptic_schwartz (b : OrthonormalBasis ι ℝ E) (A : E →L[ℝ] E) (u : 𝓢(E,ℂ)) (x : E) : AnnularFourier.elliptic b A u x=elliptic b A u x := by simp only [AnnularFourier.elliptic,elliptic,sum_apply,dd_schwartz] lemma apply_elliptic (b : OrthonormalBasis ι ℝ E) (A : E →L[ℝ] E) (K : 𝓢(E,ℂ)) {r : ℝ} (hr : 0 (1/2:ℝ)^n have hr (n : ℕ) : 0 g t-g 0-t • H 0 have hdG (t : ℝ) (ht : t∈Icc (-r) r) : HasDerivAt G (H t-H 0) t := by convert ((hg t ht).sub_const (g 0)).sub ((hasDerivAt_id t).smul_const (H 0)) using 1 · rfl · simp only [one_smul] have hbG (t : ℝ) (ht : t∈Icc (-r) r) : ‖G t‖≤M*r := by have hh := (convex_Icc (-r) r).norm_image_sub_le_of_norm_hasDerivWithin_le (fun z hz => (hdG z hz).hasDerivWithinAt) (fun z hz => hH z hz) h0 ht have htabs : |t|≤r := abs_le.mpr ht have hM : 0≤M := by simpa only [sub_self,norm_zero] using hH 0 h0 have hzero : G 0=0 := by simp [G] rw [hzero,sub_zero,sub_zero,Real.norm_eq_abs] at hh exact hh.trans (mul_le_mul_of_nonneg_left htabs hM) let R := fun t => f t-f 0-t • g 0-(t^2/2) • H 0 have hdR (t : ℝ) (ht : t∈Icc (-r) r) : HasDerivAt R (G t) t := by have hquad : HasDerivAt (fun t:ℝ => t^2/2) t t := by have hh := ((hasDerivAt_id t).pow 2).div_const (2:ℝ) simpa using hh convert (((hf t ht).sub_const (f 0)).sub ((hasDerivAt_id t).smul_const (g 0))).sub (hquad.smul_const (H 0)) using 1 · rfl · simp only [G, one_smul] have hbR (t : ℝ) (ht : t∈Icc (-r) r) : ‖R t‖≤M*r^2 := by have hh := (convex_Icc (-r) r).norm_image_sub_le_of_norm_hasDerivWithin_le (fun z hz => (hdR z hz).hasDerivWithinAt) (fun z hz => hbG z hz) h0 ht have htabs : |t|≤r := abs_le.mpr ht have hM : 0≤M := by simpa only [sub_self,norm_zero] using hH 0 h0 have hzero : R 0=0 := by simp [R] rw [hzero,sub_zero,sub_zero,Real.norm_eq_abs] at hh have hm := mul_le_mul_of_nonneg_left htabs (mul_nonneg hM hr.le) nlinarith have hp : r∈Icc (-r) r := ⟨by linarith,le_rfl⟩ have hn : -r∈Icc (-r) r := ⟨le_rfl,by linarith⟩ have he : r^2 • H 0=f r+f (-r)-(2:ℝ) • f 0-(R r+R (-r)) := by simp only [R,neg_smul,neg_sq,sub_eq_add_neg] module have hnrm := norm_add_le (R r) (R (-r)) have hff := norm_add_le (f r) (f (-r)) have h2 : ‖(2:ℝ) • f 0‖=2*‖f 0‖ := by rw [norm_smul]; norm_num have ht := norm_sub_le (f r+f (-r)-(2:ℝ) • f 0) (R r+R (-r)) have ht2 := norm_sub_le (f r+f (-r)) ((2:ℝ) • f 0) have hnorm : ‖r^2 • H 0‖=r^2*‖H 0‖ := by rw [norm_smul,Real.norm_eq_abs,abs_of_nonneg (sq_nonneg r)] rw [← he,hnorm] at ht rw [h2] at ht2 have hpB := hB r hp have hnB := hB (-r) hn have h0B := hB 0 h0 have hpR := hbR r hp have hnR := hbR (-r) hn have hh : r^2*‖H 0‖≤4*B+2*M*r^2 := by linarith calc _ ≤ (4*B+2*M*r^2)/r^2 := by apply (le_div_iff₀ (sq_pos_of_pos hr)).mpr; nlinarith only [hh] _ = _ := by field_simp end ScalarInterpolation namespace HessianInterpolation section open Set Metric open scoped ContDiff variable {E : Type*} {F : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [NormedAddCommGroup F] [NormedSpace ℝ F] def hessian (u : E → F) (x : E) : E →L[ℝ] E →L[ℝ] F := fderiv ℝ (fderiv ℝ u) x lemma ray_second {u : E → F} (hu : ContDiff ℝ 2 u) (x v : E) (t : ℝ) : HasDerivAt (fun t : ℝ => fderiv ℝ u (x+t • v) v) (hessian u (x+t • v) v v) t := by have hd : Differentiable ℝ (fderiv ℝ u) := (hu.fderiv_right (by norm_num : (1:WithTop ℕ∞)+1≤2)).differentiable one_ne_zero have hh := ((hd (x+t • v)).hasFDerivAt.clm_apply (hasFDerivAt_const v (x+t • v))).comp_hasDerivAt t (((hasDerivAt_id t).smul_const v).const_add x) simpa [Function.comp_def, hessian] using hh lemma diagonal_bound {u : E → F} (hu : ContDiff ℝ 2 u) {B S a r : ℝ} (_hB : 0≤B) (hS : 0≤S) (ha : 0≤a) (hr : 0 u (x+t • v)) (fderiv ℝ u (x+t • v) v) t := by have ht := ((hu.differentiable (by norm_num : (2:WithTop ℕ∞)≠0)) (x+t • v)).hasFDerivAt.comp_hasDerivAt t (((hasDerivAt_id t).smul_const v).const_add x) simpa only [one_smul, Function.comp_def, id_eq] using ht have hosc (t : ℝ) (ht : t∈Icc (-r) r) : ‖hessian u (x+t • v) v v-hessian u (x+(0:ℝ) • v) v v‖≤4*S*(2*r)^a := by simp only [zero_smul,add_zero] have hdxy : dist (x+t • v) x≤2*r := by rw [dist_eq_norm,add_sub_cancel_left,norm_smul,Real.norm_eq_abs] nlinarith [abs_le.mpr ht,abs_nonneg t,norm_nonneg v] have hh' := hh (x+t • v) x rw [dist_eq_norm (hessian u _) (hessian u _)] at hh' have hdp := Real.rpow_le_rpow dist_nonneg hdxy ha have hh'' : ‖hessian u (x+t • v)-hessian u x‖≤S*(2*r)^a := hh'.trans (mul_le_mul_of_nonneg_left hdp hS) have he : hessian u (x+t • v) v v-hessian u x v v=(hessian u (x+t • v)-hessian u x) v v := rfl rw [he] have h1 := ((hessian u (x+t • v)-hessian u x) v).le_opNorm v have h2 := (hessian u (x+t • v)-hessian u x).le_opNorm v have h3 := mul_le_mul_of_nonneg_right h2 (norm_nonneg v) have hn : ‖v‖^2≤4 := by nlinarith [norm_nonneg v] calc _ ≤ ‖hessian u (x+t • v)-hessian u x‖*‖v‖^2 := by nlinarith only [h1,h3] _ ≤ (S*(2*r)^a)*‖v‖^2 := mul_le_mul_of_nonneg_right hh'' (sq_nonneg _) _ ≤ (S*(2*r)^a)*4 := mul_le_mul_of_nonneg_left hn (by positivity) _ = _ := by ring have hs := ScalarInterpolation.second_bound hr (fun t _ => hd t) (fun t _ => ray_second hu x v t) hosc (fun t _ => hb (x+t • v)) simpa only [zero_smul,add_zero,show 2*(4*S*(2*r)^a)=8*S*(2*r)^a by ring] using hs theorem norm_bound {u : E → F} (hu : ContDiff ℝ 2 u) {B S a r : ℝ} (hB : 0≤B) (hS : 0≤S) (ha : 0≤a) (hr : 0 norm_sum_le _ _)) _ ≤ ∑ _i:ι,∑ _j:ι,B := by apply Finset.sum_le_sum intro i _ apply Finset.sum_le_sum intro j _ rw [norm_smul,norm_mul] have hprod : ‖(b.repr v) i‖*‖(b.repr w) j‖≤1 := by nlinarith [norm_nonneg ((b.repr v) i),norm_nonneg ((b.repr w) j),hvc i,hwc j] exact (mul_le_mul_of_nonneg_right hprod (norm_nonneg _)).trans (by simpa only [one_mul] using hb i j) _ = _ := by simp only [Finset.sum_const,Finset.card_univ,nsmul_eq_mul]; ring end HessianInterpolation namespace CompactMollification open Set MeasureTheory Metric Filter LineDeriv open scoped SchwartzMap Topology InnerProductSpace ContDiff variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] variable {ι : Type*} [Fintype ι] omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in lemma dd_hessian {u : E → ℂ} (hu : ContDiff ℝ 2 u) (v w x : E) : dd u v w x=HessianInterpolation.hessian u x v w := by have hd : DifferentiableAt ℝ (fderiv ℝ u) x := ((hu.fderiv_right (by norm_num : (1:WithTop ℕ∞)+1≤2)).differentiable one_ne_zero) x have hh := hd.hasFDerivAt.clm_apply (hasFDerivAt_const w x) change fderiv ℝ (fun z => fderiv ℝ u z w) x v=_ rw [hh.fderiv] simp only [ContinuousLinearMap.comp_zero,zero_add,ContinuousLinearMap.flip_apply,HessianInterpolation.hessian] theorem hessian_schauder (b : OrthonormalBasis ι ℝ E) (A : E →L[ℝ] E) (hA : ∀ x:E,x≠0 → 0<⟪x,A x⟫_ℝ) {a : ℝ} (ha : 0 compact_schauder b A hA (b i) (b j) ha ha1 let T0 : ℝ := ∑ i,∑ j,T i j have hT0 : 0≤T0 := Finset.sum_nonneg (fun i _ => Finset.sum_nonneg (fun j _ => hT i j)) have hTi (i j : ι) : T i j≤T0 := (Finset.single_le_sum (fun k _ => hT i k) (Finset.mem_univ j)).trans (Finset.single_le_sum (fun k _ => Finset.sum_nonneg (fun l _ => hT k l)) (Finset.mem_univ i)) refine ⟨(Fintype.card ι:ℝ)^2*T0+2,by positivity,?_⟩ intro u hc hu C B hC hB hBound hHolder x y have hpow := Real.rpow_nonneg (dist_nonneg : 0≤dist x y) a by_cases hxy : dist x y≤1 · rw [dist_eq_norm (HessianInterpolation.hessian u x)] have hcomp (i j : ι) : ‖(HessianInterpolation.hessian u x-HessianInterpolation.hessian u y) (b i) (b j)‖≤ (T0*(B+C)*dist x y^a) := by have hb (z : E) : ‖dd u (b i) (b j) z‖≤B := by rw [dd_hessian hu] apply (((HessianInterpolation.hessian u z) (b i)).le_opNorm (b j)).trans have hn := (HessianInterpolation.hessian u z).le_opNorm (b i) simp only [b.orthonormal.norm_eq_one,mul_one] at hn ⊢ exact hn.trans (hBound z) have hh := hS i j u hc hu C B hC hB hb hHolder x y hxy rw [dist_eq_norm,dd_hessian hu,dd_hessian hu] at hh exact hh.trans (mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_right (hTi i j) (add_nonneg hB hC)) hpow) have hh := HessianInterpolation.bilinear_norm_bound b (HessianInterpolation.hessian u x-HessianInterpolation.hessian u y) (by positivity) hcomp apply hh.trans have hp : 0≤(B+C)*dist x y^a := mul_nonneg (add_nonneg hB hC) hpow nlinarith · have hge : 1≤dist x y^a := Real.one_le_rpow (le_of_lt (lt_of_not_ge hxy)) ha.le have hd := dist_le_norm_add_norm (HessianInterpolation.hessian u x) (HessianInterpolation.hessian u y) have hm := mul_le_mul_of_nonneg_left hge (show 0≤B+C by positivity) have hn : 0≤(Fintype.card ι:ℝ)^2*T0 := by positivity have hn2 := mul_nonneg hn (show 0≤(B+C)*dist x y^a by positivity) nlinarith [hBound x,hBound y] end CompactMollification namespace CoefficientTrace open Set Metric open scoped InnerProductSpace variable {E : Type*} {F : Type*} {ι : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [NormedAddCommGroup F] [NormedSpace ℝ F] [Fintype ι] def trace (b : OrthonormalBasis ι ℝ E) (H : E →L[ℝ] E →L[ℝ] F) (A : E →L[ℝ] E) : F := ∑ i,H (b i) (A (b i)) lemma sub_left (b : OrthonormalBasis ι ℝ E) (H G : E →L[ℝ] E →L[ℝ] F) (A : E →L[ℝ] E) : trace b (H-G) A=trace b H A-trace b G A := by simp only [trace,sub_apply,Finset.sum_sub_distrib] lemma sub_right (b : OrthonormalBasis ι ℝ E) (H : E →L[ℝ] E →L[ℝ] F) (A B : E →L[ℝ] E) : trace b H (A-B)=trace b H A-trace b H B := by simp only [trace,sub_apply,map_sub,Finset.sum_sub_distrib] lemma norm_bound (b : OrthonormalBasis ι ℝ E) (H : E →L[ℝ] E →L[ℝ] F) (A : E →L[ℝ] E) : ‖trace b H A‖≤(Fintype.card ι:ℝ)*‖H‖*‖A‖ := by calc _ ≤ ∑ i,‖H (b i) (A (b i))‖ := norm_sum_le _ _ _ ≤ ∑ _i:ι,‖H‖*‖A‖ := by apply Finset.sum_le_sum intro i _ have h1 := (H (b i)).le_opNorm (A (b i)) have h2 := H.le_opNorm (b i) have h3 := A.le_opNorm (b i) simp only [b.orthonormal.norm_eq_one,mul_one] at h2 h3 exact h1.trans (mul_le_mul h2 h3 (norm_nonneg (A (b i))) (norm_nonneg H)) _ = _ := by simp only [Finset.sum_const,Finset.card_univ,nsmul_eq_mul,mul_assoc] lemma variation (b : OrthonormalBasis ι ℝ E) (H G : E →L[ℝ] E →L[ℝ] F) (A B : E →L[ℝ] E) : dist (trace b H A) (trace b G B)≤(Fintype.card ι:ℝ)*(‖H-G‖*‖A‖+‖G‖*‖A-B‖) := by have he : trace b H A-trace b G B=trace b (H-G) A+trace b G (A-B) := by rw [sub_left,sub_right]; abel rw [dist_eq_norm,he] exact (norm_add_le _ _).trans ((add_le_add (norm_bound b (H-G) A) (norm_bound b G (A-B))).trans_eq (by ring)) lemma holder_error (b : OrthonormalBasis ι ℝ E) (H : E → E →L[ℝ] E →L[ℝ] F) (A : E → E →L[ℝ] E) (A0 : E →L[ℝ] E) {a S B M e : ℝ} (hS : 0≤S) (hB : 0≤B) (_hM : 0≤M) (_he : 0≤e) (hH : ∀ x y,dist (H x) (H y)≤S*dist x y^a) (hHb : ∀ x,‖H x‖≤B) (hA : ∀ x y,dist (A x) (A y)≤M*dist x y^a) (hAb : ∀ x,‖A0-A x‖≤e) : ∀ x y,dist (trace b (H x) (A0-A x)) (trace b (H y) (A0-A y))≤ ((Fintype.card ι:ℝ)*(e*S+M*B))*dist x y^a := by intro x y have hp := Real.rpow_nonneg (dist_nonneg : 0≤dist x y) a have ht := variation b (H x) (H y) (A0-A x) (A0-A y) have heq : A0-A x-(A0-A y)= -(A x-A y) := by abel rw [heq,norm_neg] at ht have hHxy := hH x y rw [dist_eq_norm (H x) (H y)] at hHxy have hAxy := hA x y rw [dist_eq_norm (A x) (A y)] at hAxy have h1 := mul_le_mul hHxy (hAb x) (norm_nonneg _) (mul_nonneg hS hp) have h2 := mul_le_mul (hHb y) hAxy (norm_nonneg _) hB exact ht.trans ((mul_le_mul_of_nonneg_left (add_le_add h1 h2) (Nat.cast_nonneg _)).trans_eq (by ring)) end CoefficientTrace end namespace HolderAbsorption open Filter Metric open scoped Topology variable {X : Type*} {Y : Type*} [PseudoMetricSpace X] [PseudoMetricSpace Y] theorem improve {f : X → Y} {a K S : ℝ} (hK : 0≤K) (hS : 0≤S) (hinit : ∀ x y,dist (f x) (f y)≤S*dist x y^a) (hstep : ∀ s : ℝ, 0 ≤ s → (∀ x y,dist (f x) (f y)≤ s*dist x y^a) → ∀ x y,dist (f x) (f y)≤(K+s/2)*dist x y^a) : ∀ x y,dist (f x) (f y)≤(2*K)*dist x y^a := by have hb (n : ℕ) : ∀ x y,dist (f x) (f y)≤(2*K+S*(1/2:ℝ)^n)*dist x y^a := by induction n with | zero => intro x y apply (hinit x y).trans have hp := Real.rpow_nonneg (dist_nonneg : 0≤dist x y) a norm_num only [pow_zero,mul_one] nlinarith | succ n ih => have hh := hstep (2*K+S*(1/2:ℝ)^n) (by positivity) ih intro x y convert hh x y using 1; ring intro x y have ht : Tendsto (fun n : ℕ => (2*K+S*(1/2:ℝ)^n)*dist x y^a) atTop (𝓝 ((2*K)*dist x y^a)) := by have hp := tendsto_pow_atTop_nhds_zero_of_lt_one (by norm_num : (0:ℝ)≤1/2) (by norm_num : (1/2:ℝ)<1) convert (tendsto_const_nhds.add (tendsto_const_nhds.mul hp)).mul_const (dist x y^a) using 1; simp exact le_of_tendsto_of_tendsto tendsto_const_nhds ht (Filter.Eventually.of_forall fun n => hb n x y) end HolderAbsorption noncomputable section namespace CompactMollification open Set MeasureTheory Metric Filter open scoped SchwartzMap Topology InnerProductSpace ContDiff variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] variable {ι : Type*} [Fintype ι] omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in lemma elliptic_trace (b : OrthonormalBasis ι ℝ E) (A : E →L[ℝ] E) {u : E → ℂ} (hu : ContDiff ℝ 2 u) (x : E) : elliptic b A u x=CoefficientTrace.trace b (HessianInterpolation.hessian u x) A := by simp only [elliptic,CoefficientTrace.trace,dd_hessian hu] theorem variable_schauder (b : OrthonormalBasis ι ℝ E) (A0 : E →L[ℝ] E) (hA0 : ∀ x:E,x≠0 → 0<⟪x,A0 x⟫_ℝ) {a : ℝ} (ha : 0 L (u z)) x=(ContinuousLinearMap.compL ℝ E F G L).comp (hessian u x) := by have hd := hu.differentiable (by norm_num : (2:WithTop ℕ∞)≠0) have hd2 := (hu.fderiv_right (by norm_num : (1:WithTop ℕ∞)+1≤2)).differentiable one_ne_zero have heq : fderiv ℝ (fun z => L (u z))=(fun z => L.comp (fderiv ℝ u z)) := by funext z exact (L.hasFDerivAt.comp z (hd z).hasFDerivAt).fderiv dsimp only [hessian] rw [heq] exact ((ContinuousLinearMap.compL ℝ E F G L).hasFDerivAt.comp x (hd2 x).hasFDerivAt).fderiv def complexLift (H : E →L[ℝ] E →L[ℝ] ℝ) : E →L[ℝ] E →L[ℝ] ℂ := (ContinuousLinearMap.compL ℝ E ℝ ℂ Complex.ofRealCLM).comp H lemma complexLift_apply (H : E →L[ℝ] E →L[ℝ] ℝ) (v w : E) : complexLift H v w=(H v w:ℂ) := rfl lemma complexLift_sub (H G : E →L[ℝ] E →L[ℝ] ℝ) : complexLift (H-G)=complexLift H-complexLift G := by ext v w simp only [complexLift_apply,sub_apply,Complex.ofReal_sub] lemma complexLift_norm (H : E →L[ℝ] E →L[ℝ] ℝ) : ‖complexLift H‖=‖H‖ := by apply le_antisymm · apply ContinuousLinearMap.opNorm_le_bound (f := complexLift H) (norm_nonneg H) intro v apply ContinuousLinearMap.opNorm_le_bound (f := (complexLift H) v) (by positivity) intro w rw [complexLift_apply,Complex.norm_real] have h1 := (H v).le_opNorm w have h2 := H.le_opNorm v exact h1.trans (mul_le_mul_of_nonneg_right h2 (norm_nonneg w)) · apply ContinuousLinearMap.opNorm_le_bound (f := H) (norm_nonneg (complexLift H)) intro v apply ContinuousLinearMap.opNorm_le_bound (f := H v) (by positivity) intro w have h1 := ((complexLift H) v).le_opNorm w have h2 := (complexLift H).le_opNorm v rw [complexLift_apply,Complex.norm_real] at h1 exact h1.trans (mul_le_mul_of_nonneg_right h2 (norm_nonneg w)) lemma complexLift_dist (H G : E →L[ℝ] E →L[ℝ] ℝ) : dist (complexLift H) (complexLift G)=dist H G := by rw [dist_eq_norm (complexLift H) (complexLift G),← complexLift_sub,complexLift_norm,dist_eq_norm H G] lemma hessian_complex {u : E → ℝ} (hu : ContDiff ℝ 2 u) (x : E) : hessian (fun z => (u z:ℂ)) x=complexLift (hessian u x) := hessian_comp Complex.ofRealCLM hu x end HessianInterpolation namespace CompactMollification open Set MeasureTheory Metric Filter open scoped SchwartzMap Topology InnerProductSpace ContDiff variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] variable {ι : Type*} [Fintype ι] omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in lemma trace_complex (b : OrthonormalBasis ι ℝ E) (H : E →L[ℝ] E →L[ℝ] ℝ) (A : E →L[ℝ] E) : CoefficientTrace.trace b (HessianInterpolation.complexLift H) A=Complex.ofReal (CoefficientTrace.trace b H A) := by simp only [CoefficientTrace.trace,HessianInterpolation.complexLift_apply,Complex.ofReal_sum] theorem real_variable_schauder (b : OrthonormalBasis ι ℝ E) (A0 : E →L[ℝ] E) (hA0 : ∀ x:E,x≠0 → 0<⟪x,A0 x⟫_ℝ) {a : ℝ} (ha : 0 (u x:ℂ) have huc : ContDiff ℝ 2 uc := Complex.ofRealCLM.contDiff.comp hu have hcc : HasCompactSupport uc := hc.comp_left (g := fun r : ℝ => (r:ℂ)) (by simp) have hbc (x : E) : ‖uc x‖≤B0 := by simpa only [uc,Complex.norm_real] using hb x have hPc (x y : E) : dist (CoefficientTrace.trace b (HessianInterpolation.hessian uc x) (A x)) (CoefficientTrace.trace b (HessianInterpolation.hessian uc y) (A y))≤C*dist x y^a := by rw [HessianInterpolation.hessian_complex hu,HessianInterpolation.hessian_complex hu,trace_complex,trace_complex] simpa only [Complex.isometry_ofReal.dist_eq] using hP x y obtain ⟨S,hS,hHs⟩ := hFinite have hFinitec : ∃ S : ℝ,0≤S ∧ ∀ x y,dist (HessianInterpolation.hessian uc x) (HessianInterpolation.hessian uc y)≤S*dist x y^a := by refine ⟨S,hS,?_⟩ intro x y rw [HessianInterpolation.hessian_complex hu,HessianInterpolation.hessian_complex hu,HessianInterpolation.complexLift_dist] exact hHs x y intro x y have hh := hbound uc A hcc huc hbc hAb hA hPc hFinitec x y rwa [HessianInterpolation.hessian_complex hu,HessianInterpolation.hessian_complex hu,HessianInterpolation.complexLift_dist] at hh end CompactMollification namespace HolderLocalization open Set Metric variable {E : Type*} {F : Type*} {G : Type*} {H : Type*} [PseudoMetricSpace E] [NormedAddCommGroup F] [NormedSpace ℝ F] [NormedAddCommGroup G] [NormedSpace ℝ G] [NormedAddCommGroup H] [NormedSpace ℝ H] omit [NormedSpace ℝ F] in lemma of_lipschitz_bounded {f : E → F} {L B a : ℝ} (hL : 0≤L) (hB : 0≤B) (ha : 0≤a) (ha1 : a≤1) (hf : ∀ x y,dist (f x) (f y)≤L*dist x y) (hb : ∀ x,‖f x‖≤B) : ∀ x y,dist (f x) (f y)≤(L+2*B)*dist x y^a := by intro x y by_cases hd : dist x y≤1 · have hp : dist x y≤dist x y^a := by by_cases hz : dist x y=0 · rw [hz]; positivity simpa only [Real.rpow_one] using Real.rpow_le_rpow_of_exponent_ge (lt_of_le_of_ne dist_nonneg (Ne.symm hz)) hd ha1 exact (hf x y).trans ((mul_le_mul_of_nonneg_left hp hL).trans (mul_le_mul_of_nonneg_right (by linarith : L≤L+2*B) (Real.rpow_nonneg dist_nonneg a))) · have hp : 1≤dist x y^a := Real.one_le_rpow (le_of_not_ge hd) ha have hm : dist (f x) (f y)≤2*B := by rw [dist_eq_norm] exact (norm_sub_le _ _).trans (by linarith [hb x,hb y]) calc _ ≤ 2*B := hm _ ≤ (L+2*B)*dist x y^a := by nlinarith lemma bilinear_holder (T : F →L[ℝ] G →L[ℝ] H) {s : Set E} {f : E → F} {g : E → G} {B D C K a : ℝ} (hB : 0≤B) (_hD : 0≤D) (hC : 0≤C) (hfb : ∀ x∈s,‖f x‖≤B) (hgb : ∀ x∈s,‖g x‖≤D) (hfc : ∀ x∈s,∀ y∈s,dist (f x) (f y)≤C*dist x y^a) (hgc : ∀ x∈s,∀ y∈s,dist (g x) (g y)≤K*dist x y^a) : ∀ x∈s,∀ y∈s,dist (T (f x) (g x)) (T (f y) (g y))≤‖T‖*(B*K+D*C)*dist x y^a := by intro x hx y hy have he : T (f x) (g x)-T (f y) (g y)=T (f x) (g x-g y)+T (f x-f y) (g y) := by simp only [map_sub,sub_apply] abel rw [dist_eq_norm,he] calc _ ≤ ‖T (f x) (g x-g y)‖+‖T (f x-f y) (g y)‖ := norm_add_le _ _ _ ≤ ‖T‖*B*(K*dist x y^a)+‖T‖*(C*dist x y^a)*D := by apply add_le_add · exact (T.le_opNorm₂ _ _).trans (mul_le_mul (mul_le_mul_of_nonneg_left (hfb x hx) (norm_nonneg T)) (by simpa only [dist_eq_norm] using hgc x hx y hy) (norm_nonneg _) (by positivity)) · exact (T.le_opNorm₂ _ _).trans (mul_le_mul (mul_le_mul_of_nonneg_left (by simpa only [dist_eq_norm] using hfc x hx y hy) (norm_nonneg T)) (hgb y hy) (norm_nonneg _) (by positivity)) _ = _ := by ring lemma cutoff_holder {s : Set E} {χ : E → ℝ} {f : E → F} {B C K a : ℝ} (hB : 0≤B) (hC : 0≤C) (hK : 0≤K) (hb : ∀ x∈s,‖f x‖≤B) (hf : ∀ x∈s,∀ y∈s,dist (f x) (f y)≤C*dist x y^a) (hχb : ∀ x,‖χ x‖≤1) (hχz : ∀ x,x∉s → χ x=0) (hχc : ∀ x y,dist (χ x) (χ y)≤K*dist x y^a) : ∀ x y,dist (χ x • f x) (χ y • f y)≤(C+B*K)*dist x y^a := by have hmain (x : E) (hx : x∈s) (y : E) : dist (χ x • f x) (χ y • f y)≤(C+B*K)*dist x y^a := by by_cases hy : y∈s · have he : χ x • f x-χ y • f y=χ y • (f x-f y)+(χ x-χ y) • f x := by module rw [dist_eq_norm,he] calc _ ≤ ‖χ y • (f x-f y)‖+‖(χ x-χ y) • f x‖ := norm_add_le _ _ _ ≤ 1*(C*dist x y^a)+(K*dist x y^a)*B := by simp only [norm_smul] apply add_le_add · exact mul_le_mul (hχb y) (by simpa only [dist_eq_norm] using hf x hx y hy) (norm_nonneg _) zero_le_one · exact mul_le_mul (by simpa only [dist_eq_norm] using hχc x y) (hb x hx) (norm_nonneg _) (by positivity) _ = _ := by ring · rw [hχz y hy,zero_smul,dist_zero_right,norm_smul] have hc : ‖χ x‖≤K*dist x y^a := by simpa only [hχz y hy,dist_zero_right] using hχc x y calc _ ≤ (K*dist x y^a)*B := mul_le_mul hc (hb x hx) (norm_nonneg _) (by positivity) _ ≤ (C+B*K)*dist x y^a := by nlinarith [Real.rpow_nonneg (dist_nonneg (x:=x) (y:=y)) a] intro x y by_cases hx : x∈s · exact hmain x hx y by_cases hy : y∈s · simpa only [dist_comm] using hmain y hy x · simp only [hχz x hx,hχz y hy,zero_smul,dist_self] positivity lemma localized_bilinear (T : F →L[ℝ] G →L[ℝ] H) {s : Set E} {f : E → F} {g : E → G} {B D C K a : ℝ} (hB : 0≤B) (hD : 0≤D) (hC : 0≤C) (hK : 0≤K) (hfb : ∀ x,‖f x‖≤B) (hfz : ∀ x,x∉s → f x=0) (hgb : ∀ x∈s,‖g x‖≤D) (hfc : ∀ x y,dist (f x) (f y)≤C*dist x y^a) (hgc : ∀ x∈s,∀ y∈s,dist (g x) (g y)≤K*dist x y^a) : (∀ x,‖T (f x) (g x)‖≤‖T‖*B*D) ∧ ∀ x y,dist (T (f x) (g x)) (T (f y) (g y))≤‖T‖*(B*K+D*C)*dist x y^a := by have hb (x : E) : ‖T (f x) (g x)‖≤‖T‖*B*D := by by_cases hx : x∈s · exact (T.le_opNorm₂ _ _).trans (mul_le_mul (mul_le_mul_of_nonneg_left (hfb x) (norm_nonneg T)) (hgb x hx) (norm_nonneg _) (by positivity)) · simp only [hfz x hx,map_zero,zero_apply,norm_zero] positivity refine ⟨hb,?_⟩ have hmain (x : E) (hx : x∈s) (y : E) : dist (T (f x) (g x)) (T (f y) (g y))≤‖T‖*(B*K+D*C)*dist x y^a := by by_cases hy : y∈s · exact bilinear_holder T hB hD hC (fun z _ => hfb z) hgb (fun z _ w _ => hfc z w) hgc x hx y hy · rw [hfz y hy,map_zero,zero_apply,dist_zero_right] have hf : ‖f x‖≤C*dist x y^a := by simpa only [hfz y hy,dist_zero_right] using hfc x y have hp := Real.rpow_nonneg (dist_nonneg : 0≤dist x y) a calc _ ≤ ‖T‖*(C*dist x y^a)*D := (T.le_opNorm₂ _ _).trans (mul_le_mul (mul_le_mul_of_nonneg_left hf (norm_nonneg T)) (hgb x hx) (norm_nonneg _) (by positivity)) _ ≤ ‖T‖*(B*K+D*C)*dist x y^a := by nlinarith [mul_nonneg (mul_nonneg (norm_nonneg T) (mul_nonneg hB hK)) hp] intro x y by_cases hx : x∈s · exact hmain x hx y by_cases hy : y∈s · simpa only [dist_comm] using hmain y hy x · simp only [hfz x hx,hfz y hy,map_zero,zero_apply,dist_self] positivity end HolderLocalization namespace HolderControl section open Set Metric variable {E : Type*} {F : Type*} {G : Type*} {H : Type*} {J : Type*} [PseudoMetricSpace E] [NormedAddCommGroup F] [NormedSpace ℝ F] [NormedAddCommGroup G] [NormedSpace ℝ G] [NormedAddCommGroup H] [NormedSpace ℝ H] def Controlled (a : ℝ) (s : Set E) (f : J → E → F) : Prop := ∃ B C : ℝ,0≤B ∧ 0≤C ∧ (∀ j x,x∈s → ‖f j x‖≤B) ∧ ∀ j x,x∈s → ∀ y,y∈s → dist (f j x) (f j y)≤C*dist x y^a omit [NormedSpace ℝ F] in lemma Controlled.add {a : ℝ} {s : Set E} {f g : J → E → F} (hf : Controlled a s f) (hg : Controlled a s g) : Controlled a s (fun j x => f j x+g j x) := by obtain ⟨B,C,hB,hC,hfb,hfc⟩ := hf obtain ⟨D,K,hD,hK,hgb,hgc⟩ := hg refine ⟨B+D,C+K,by positivity,by positivity,?_,?_⟩ · intro j x hx exact (norm_add_le _ _).trans (add_le_add (hfb j x hx) (hgb j x hx)) · intro j x hx y hy exact (dist_add_add_le _ _ _ _).trans ((add_le_add (hfc j x hx y hy) (hgc j x hx y hy)).trans_eq (by ring)) lemma Controlled.localized_bilinear (T : F →L[ℝ] G →L[ℝ] H) {a : ℝ} {s : Set E} {f : J → E → F} {g : J → E → G} (hf : Controlled a univ f) (hfz : ∀ j x,x∉s → f j x=0) (hg : Controlled a s g) : Controlled a univ (fun j x => T (f j x) (g j x)) := by obtain ⟨B,C,hB,hC,hfb,hfc⟩ := hf obtain ⟨D,K,hD,hK,hgb,hgc⟩ := hg refine ⟨‖T‖*B*D,‖T‖*(B*K+D*C),by positivity,by positivity,?_,?_⟩ · intro j x _ exact (HolderLocalization.localized_bilinear T hB hD hC hK (fun x => hfb j x (mem_univ x)) (hfz j) (hgb j) (fun x y => hfc j x (mem_univ x) y (mem_univ y)) (hgc j)).1 x · intro j x _ y _ exact (HolderLocalization.localized_bilinear T hB hD hC hK (fun x => hfb j x (mem_univ x)) (hfz j) (hgb j) (fun x y => hfc j x (mem_univ x) y (mem_univ y)) (hgc j)).2 x y omit [NormedSpace ℝ F] in lemma Controlled.of_single {a : ℝ} {s : Set E} {f : E → F} (hf : Controlled a s (fun _ : Unit => f)) : Controlled a s (fun _ : J => f) := by obtain ⟨B,C,hB,hC,hfb,hfc⟩ := hf exact ⟨B,C,hB,hC,fun _ => hfb (),fun _ => hfc ()⟩ omit [NormedSpace ℝ F] in lemma Controlled.congr {a : ℝ} {s : Set E} {f g : J → E → F} (hf : Controlled a s f) (he : ∀ j x,x∈s → f j x=g j x) : Controlled a s g := by obtain ⟨B,C,hB,hC,hfb,hfc⟩ := hf exact ⟨B,C,hB,hC,fun j x hx => he j x hx ▸ hfb j x hx, fun j x hx y hy => by rw [← he j x hx,← he j y hy]; exact hfc j x hx y hy⟩ end open Set Metric variable {E : Type*} {F : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [NormedAddCommGroup F] [NormedSpace ℝ F] lemma compact_C1 {a : ℝ} (ha : 0≤a) (ha1 : a≤1) {f : E → F} (hf : ContDiff ℝ 1 f) (hc : HasCompactSupport f) : Controlled a univ (fun _ : Unit => f) := by obtain ⟨B,hB⟩ := hc.exists_bound_of_continuous hf.continuous obtain ⟨D,hD⟩ := hc.fderiv (𝕜:=ℝ) |>.exists_bound_of_continuous (contDiff_one_iff_fderiv.mp hf).2 have hB0 : 0≤B := (norm_nonneg (f 0)).trans (hB 0) have hD0 : 0≤D := (norm_nonneg (fderiv ℝ f 0)).trans (hD 0) have hl : LipschitzWith ⟨D,hD0⟩ f := lipschitzWith_of_nnnorm_fderiv_le (hf.differentiable one_ne_zero) (fun x => hD x) refine ⟨B,D+2*B,hB0,by positivity,fun _ x _ => hB x,?_⟩ intro _ x _ y _ exact HolderLocalization.of_lipschitz_bounded hD0 hB0 ha ha1 hl.dist_le_mul hB x y end HolderControl namespace HessianInterpolation open scoped ContDiff variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] lemma hessian_mul {χ u : E → ℝ} (hχ : ContDiff ℝ 2 χ) (hu : ContDiff ℝ 2 u) (x : E) : hessian (fun z => χ z*u z) x=χ x • hessian u x+ (u x • hessian χ x+(fderiv ℝ χ x).smulRight (fderiv ℝ u x)+ (fderiv ℝ u x).smulRight (fderiv ℝ χ x)) := by have hdχ := (hχ.differentiable (by norm_num : (2:ℕ∞ω)≠0)) have hdu := (hu.differentiable (by norm_num : (2:ℕ∞ω)≠0)) have hDχ := ((hχ.fderiv_right (m:=1) (by norm_num)).differentiable one_ne_zero x).hasFDerivAt have hDu := ((hu.fderiv_right (m:=1) (by norm_num)).differentiable one_ne_zero x).hasFDerivAt have hh := ((hdχ x).hasFDerivAt.smul hDu).add ((hdu x).hasFDerivAt.smul hDχ) have heq : (fun z => χ z • fderiv ℝ u z+u z • fderiv ℝ χ z)= fderiv ℝ (fun z => χ z*u z) := funext fun z => (fderiv_fun_mul (hdχ z) (hdu z)).symm change HasFDerivAt (fun z => χ z • fderiv ℝ u z+u z • fderiv ℝ χ z) _ x at hh rw [heq] at hh unfold hessian rw [hh.fderiv] abel end HessianInterpolation namespace HolderControl section open Set Metric open scoped InnerProductSpace variable {E : Type*} {F : Type*} {J : Type*} {ι : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [NormedAddCommGroup F] [NormedSpace ℝ F] [Fintype ι] lemma Controlled.trace (b : OrthonormalBasis ι ℝ E) {a : ℝ} {s : Set E} {H : J → E → E →L[ℝ] E →L[ℝ] F} {A : J → E → E →L[ℝ] E} (hH : Controlled a s H) (hA : Controlled a s A) : Controlled a s (fun j x => CoefficientTrace.trace b (H j x) (A j x)) := by obtain ⟨B,C,hB,hC,hHb,hHc⟩ := hH obtain ⟨D,K,hD,hK,hAb,hAc⟩ := hA refine ⟨(Fintype.card ι:ℝ)*B*D,(Fintype.card ι:ℝ)*(C*D+B*K),by positivity,by positivity,?_,?_⟩ · intro j x hx exact (CoefficientTrace.norm_bound b _ _).trans (mul_le_mul (mul_le_mul_of_nonneg_left (hHb j x hx) (Nat.cast_nonneg _)) (hAb j x hx) (norm_nonneg _) (by positivity)) · intro j x hx y hy have hHxy : ‖H j x-H j y‖≤C*dist x y^a := by simpa only [dist_eq_norm] using hHc j x hx y hy have hAxy : ‖A j x-A j y‖≤K*dist x y^a := by simpa only [dist_eq_norm] using hAc j x hx y hy refine (CoefficientTrace.variation b _ _ _ _).trans ?_ have h1 := mul_le_mul hHxy (hAb j x hx) (norm_nonneg _) (by positivity : 0≤C*dist x y^a) have h2 := mul_le_mul (hHb j y hy) hAxy (norm_nonneg _) hB exact (mul_le_mul_of_nonneg_left (add_le_add h1 h2) (Nat.cast_nonneg _)).trans_eq (by ring) end section open Set Metric Filter open scoped ContDiff InnerProductSpace Topology variable {E : Type*} {J : Type*} {J' : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] variable {ι : Type*} [Fintype ι] local instance : NormedAddCommGroup (E →L[ℝ] ℝ) := ContinuousLinearMap.toNormedAddCommGroup local instance : NormedSpace ℝ (E →L[ℝ] ℝ) := ContinuousLinearMap.toNormedSpace local instance : NormedAddCommGroup (E →L[ℝ] E →L[ℝ] ℝ) := ContinuousLinearMap.toNormedAddCommGroup local instance : NormedSpace ℝ (E →L[ℝ] E →L[ℝ] ℝ) := ContinuousLinearMap.toNormedSpace omit [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in lemma Controlled.reindex {F : Type*} [NormedAddCommGroup F] {a : ℝ} {s : Set E} {f : J → E → F} (hf : Controlled a s f) (i : J' → J) : Controlled a s (fun j => f (i j)) := by obtain ⟨B,C,hB,hC,hfb,hfc⟩ := hf exact ⟨B,C,hB,hC,fun j => hfb (i j),fun j => hfc (i j)⟩ theorem localized_family (b : OrthonormalBasis ι ℝ E) (A0 : E →L[ℝ] E) (hA0 : ∀ x:E,x≠0 → 0<⟪x,A0 x⟫_ℝ) {a : ℝ} (ha : 0 fderiv ℝ (u j)) → Controlled a s (fun j x => CoefficientTrace.trace b (HessianInterpolation.hessian (u j) x) (A j x)) → (∀ j,Controlled a s (fun _ : Unit => HessianInterpolation.hessian (u j))) → Controlled a t (fun j => HessianInterpolation.hessian (u j)) := by obtain ⟨e,he,hsch⟩ := CompactMollification.real_variable_schauder b A0 hA0 ha ha1 refine ⟨e,he,?_⟩ intro u A χ s t hχ hc hs ht htχ hu hclose hA hub hDu hP hFinite have hχ2 : ContDiff ℝ 2 χ := hχ.of_le (by decide) have hχc : Controlled a univ (fun _ : J => χ) := (compact_C1 ha.le ha1.le (hχ.of_le (by simp)) hc).of_single have hDχ : ContDiff ℝ ∞ (fderiv ℝ χ) := hχ.fderiv_right (by simp) have hD2χ : ContDiff ℝ ∞ (HessianInterpolation.hessian χ) := hDχ.fderiv_right (by simp) have hDχc : Controlled a univ (fun _ : J => fderiv ℝ χ) := (compact_C1 ha.le ha1.le (hDχ.of_le (by simp)) (hc.fderiv ℝ)).of_single have hD2χc : Controlled a univ (fun _ : J => HessianInterpolation.hessian χ) := (compact_C1 ha.le ha1.le (hD2χ.of_le (by simp)) ((hc.fderiv ℝ).fderiv ℝ)).of_single have hz (x : E) (hx : x∉s) : χ x=0 := image_eq_zero_of_notMem_tsupport (fun hh => hx (hs hh)) have hDz (x : E) (hx : x∉s) : fderiv ℝ χ x=0 := fderiv_of_notMem_tsupport ℝ (fun hh => hx (hs hh)) have hD2z (x : E) (hx : x∉s) : HessianInterpolation.hessian χ x=0 := fderiv_of_notMem_tsupport ℝ (fun hh => hx (hs (tsupport_fderiv_subset ℝ hh))) let w : J → E → ℝ := fun j x => χ x*u j x let R : J → E → E →L[ℝ] E →L[ℝ] ℝ := fun j x => u j x • HessianInterpolation.hessian χ x+(fderiv ℝ χ x).smulRight (fderiv ℝ (u j) x)+ (fderiv ℝ (u j) x).smulRight (fderiv ℝ χ x) have hwc : Controlled a univ w := hχc.localized_bilinear (ContinuousLinearMap.lsmul ℝ ℝ) (fun _ => hz) hub have hR : Controlled a univ R := by have h1 := hD2χc.localized_bilinear (ContinuousLinearMap.lsmul ℝ ℝ).flip (fun _ => hD2z) hub have h2 := hDχc.localized_bilinear (ContinuousLinearMap.smulRightL ℝ E (E →L[ℝ] ℝ)) (fun _ => hDz) hDu have h3 := hDχc.localized_bilinear (ContinuousLinearMap.smulRightL ℝ E (E →L[ℝ] ℝ)).flip (fun _ => hDz) hDu exact (h1.add h2).add h3 have hprod (j : J) (x : E) : HessianInterpolation.hessian (w j) x= χ x • HessianInterpolation.hessian (u j) x+R j x := HessianInterpolation.hessian_mul hχ2 (hu j) x have hPw : Controlled a univ (fun j x => CoefficientTrace.trace b (HessianInterpolation.hessian (w j) x) (A j x)) := by have h1 := hχc.localized_bilinear (ContinuousLinearMap.lsmul ℝ ℝ) (fun _ => hz) hP have h2 := hR.trace b hA apply (h1.add h2).congr intro j x _ change χ x*CoefficientTrace.trace b (HessianInterpolation.hessian (u j) x) (A j x)+ CoefficientTrace.trace b (R j x) (A j x)=_ rw [hprod] simp only [CoefficientTrace.trace,add_apply,_root_.smul_apply,smul_eq_mul,Finset.mul_sum,Finset.sum_add_distrib] have hwFinite (j : J) : Controlled a univ (fun _ : Unit => HessianInterpolation.hessian (w j)) := by have h1 := (hχc.reindex (fun _ : Unit => j)).localized_bilinear (ContinuousLinearMap.lsmul ℝ ℝ) (fun _ => hz) (hFinite j) exact (h1.add (hR.reindex (fun _ : Unit => j))).congr (fun _ x _ => (hprod j x).symm) obtain ⟨B,C,hB,hC,hwb,_⟩ := hwc obtain ⟨D,M,hD,hM,_,hAc⟩ := hA obtain ⟨P,N,hP0,hN,_,hPwc⟩ := hPw obtain ⟨U,hU,hUniform⟩ := hsch M B N hM hB hN have hw2 (j : J) : ContDiff ℝ 2 (w j) := hχ2.mul (hu j) have hwH (j : J) : ∀ x y,dist (HessianInterpolation.hessian (w j) x) (HessianInterpolation.hessian (w j) y)≤U*dist x y^a := by obtain ⟨Bj,S,hBj,hS,_,hSj⟩ := hwFinite j exact hUniform (w j) (A j) hc.mul_right (hw2 j) (fun x => hwb j x (mem_univ x)) (hclose j) (fun x y => hAc j x (mem_univ x) y (mem_univ y)) (fun x y => hPwc j x (mem_univ x) y (mem_univ y)) ⟨S,hS,fun x y => hSj () x (mem_univ x) y (mem_univ y)⟩ have heq (j : J) (x : E) (hx : x∈t) : HessianInterpolation.hessian (w j) x=HessianInterpolation.hessian (u j) x := by have hev : w j =ᶠ[𝓝 x] u j := by filter_upwards [ht.eventually_mem hx] with y hy simp only [w,htχ y hy,one_mul] exact hev.fderiv.fderiv_eq refine ⟨2*B+4*U*2^a,U,by positivity,hU,?_,?_⟩ · intro j x hx change ‖HessianInterpolation.hessian (u j) x‖≤_ rw [← heq j x hx] have hh := HessianInterpolation.norm_bound (hw2 j) hB hU ha.le (by norm_num : (0:ℝ)<1) (fun x => hwb j x (mem_univ x)) (hwH j) x simpa using hh · intro j x hx y hy change dist (HessianInterpolation.hessian (u j) x) (HessianInterpolation.hessian (u j) y)≤_ rw [← heq j x hx,← heq j y hy] exact hwH j x y end section open Set Metric variable {E : Type*} {F : Type*} {G : Type*} {H : Type*} {J : Type*} [PseudoMetricSpace E] [NormedAddCommGroup F] [NormedSpace ℝ F] [NormedAddCommGroup G] [NormedSpace ℝ G] [NormedAddCommGroup H] [NormedSpace ℝ H] omit [NormedSpace ℝ F] in lemma Controlled.mono {a:ℝ} {s t:Set E} {f:J→E→F} (hf:Controlled a s f) (ht:t⊆s) : Controlled a t f := by obtain ⟨B,C,hB,hC,hb,hc⟩ := hf exact ⟨B,C,hB,hC,fun j x hx => hb j x (ht hx),fun j x hx y hy => hc j x (ht hx) y (ht hy)⟩ omit [NormedSpace ℝ F] in lemma const (a:ℝ) (s:Set E) (v:F) : Controlled a s (fun _:J => fun _:E => v) := by exact ⟨‖v‖,0,norm_nonneg _,le_rfl,fun _ _ _ => le_rfl,by simp⟩ omit [NormedSpace ℝ F] in lemma Controlled.sub {a:ℝ} {s:Set E} {f g:J→E→F} (hf:Controlled a s f) (hg:Controlled a s g) : Controlled a s (fun j x => f j x-g j x) := by obtain ⟨B,C,hB,hC,hb,hc⟩ := hf obtain ⟨D,K,hD,hK,hd,hk⟩ := hg refine ⟨B+D,C+K,by positivity,by positivity,?_,?_⟩ · intro j x hx exact (norm_sub_le _ _).trans (add_le_add (hb j x hx) (hd j x hx)) · intro j x hx y hy exact (dist_sub_sub_le _ _ _ _).trans ((add_le_add (hc j x hx y hy) (hk j x hx y hy)).trans_eq (by ring)) lemma Controlled.linear (T:F→L[ℝ]G) {a:ℝ} {s:Set E} {f:J→E→F} (hf:Controlled a s f) : Controlled a s (fun j x => T (f j x)) := by obtain ⟨B,C,hB,hC,hb,hc⟩ := hf refine ⟨‖T‖*B,‖T‖*C,by positivity,by positivity,?_,?_⟩ · intro j x hx exact (T.le_opNorm _).trans (mul_le_mul_of_nonneg_left (hb j x hx) (norm_nonneg _)) · intro j x hx y hy rw [dist_eq_norm,← map_sub] exact (T.le_opNorm _).trans ((mul_le_mul_of_nonneg_left (by simpa only [dist_eq_norm] using hc j x hx y hy) (norm_nonneg T)).trans_eq (by ring)) lemma Controlled.bilinear (T:F→L[ℝ]G→L[ℝ]H) {a:ℝ} {s:Set E} {f:J→E→F} {g:J→E→G} (hf:Controlled a s f) (hg:Controlled a s g) : Controlled a s (fun j x => T (f j x) (g j x)) := by obtain ⟨B,C,hB,hC,hb,hc⟩ := hf obtain ⟨D,K,hD,hK,hd,hk⟩ := hg refine ⟨‖T‖*B*D,‖T‖*(B*K+D*C),by positivity,by positivity,?_,?_⟩ · intro j x hx exact (T.le_opNorm₂ _ _).trans (mul_le_mul (mul_le_mul_of_nonneg_left (hb j x hx) (norm_nonneg T)) (hd j x hx) (norm_nonneg _) (by positivity)) · intro j x hx y hy exact HolderLocalization.bilinear_holder T hB hD hC (hb j) (hd j) (hc j) (hk j) x hx y hy end section open Set Metric variable {E : Type*} {F : Type*} {J : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [NormedAddCommGroup F] [NormedSpace ℝ F] lemma extend_field {a e:ℝ} (ha:0≤a) (ha1:a≤1) (he:0≤e) (A0:F) (A:J→E→F) (ψ:E→ℝ) (s t:Set E) (hψ:ContDiff ℝ 1 ψ) (hc:HasCompactSupport ψ) (hz:∀x,x∉s → ψ x=0) (hb:∀x,‖ψ x‖≤1) (h1:∀x∈t,ψ x=1) (hA:Controlled a s A) (hclose:∀ j x,x∈s → ‖A0-A j x‖≤e) : ∃ B:J→E→F,Controlled a univ B ∧ (∀j x,‖A0-B j x‖≤e) ∧ ∀j x,x∈t → B j x=A j x := by let B:J→E→F := fun j x => A0+ψ x • (A j x-A0) have hpc : Controlled a univ (fun _:J => ψ) := (compact_C1 ha ha1 hψ hc).of_single have hAc := hA.sub (const a s A0) have hBc : Controlled a univ B := (const a univ A0).add (hpc.localized_bilinear (ContinuousLinearMap.lsmul ℝ ℝ) (fun _ => hz) hAc) refine ⟨B,hBc,?_,?_⟩ · intro j x by_cases hx:x∈s · have heq : A0-B j x= -(ψ x • (A j x-A0)) := by dsimp only [B]; abel rw [heq,norm_neg,norm_smul] have hdist : ‖A j x-A0‖≤e := by rw [norm_sub_rev]; exact hclose j x hx exact (mul_le_mul (hb x) hdist (norm_nonneg _) zero_le_one).trans_eq (one_mul e) · simpa only [B,hz x hx,zero_smul,add_zero,sub_self,norm_zero] using he · intro j x hx simp only [B,h1 x hx,one_smul,add_sub_cancel] end section open Set Metric Filter open scoped ContDiff InnerProductSpace Topology variable {E : Type*} {J : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] variable {ι : Type*} [Fintype ι] theorem interior_family (b : OrthonormalBasis ι ℝ E) (A0 : E →L[ℝ] E) (hA0 : ∀ x:E,x≠0 → 0<⟪x,A0 x⟫_ℝ) {a : ℝ} (ha : 0 fderiv ℝ (u j)) → Controlled a s (fun j x => CoefficientTrace.trace b (HessianInterpolation.hessian (u j) x) (A j x)) → (∀ j,Controlled a s (fun _ : Unit => HessianInterpolation.hessian (u j))) → Controlled a t (fun j => HessianInterpolation.hessian (u j)) := by obtain ⟨e,he,hsch⟩ := localized_family (J:=J) b A0 hA0 ha ha1 refine ⟨e,he,?_⟩ intro u A ψ χ s s₀ t hχ hc hcs hψ hpc hpz hpb hp1 hs ht h1 hu hclose hA hub hDu hP hF obtain ⟨B,hB,hBc,hBe⟩ := extend_field ha.le ha1.le he.le A0 A ψ s s₀ hψ hpc hpz hpb hp1 hA hclose apply hsch u B χ s₀ t hχ hc hcs ht h1 hu hBc hB (hub.mono hs) (hDu.mono hs) · exact (hP.mono hs).congr (fun j x hx => by rw [hBe j x hx]) · exact fun j => (hF j).mono hs end open Set Metric open scoped ContDiff InnerProductSpace variable {E : Type*} {J : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] variable {ι:Type*} [Fintype ι] theorem interior_ball (b:OrthonormalBasis ι ℝ E) (A0:E→L[ℝ]E) (hA0:∀x:E,x≠0 → 0<⟪x,A0 x⟫_ℝ) {a:ℝ} (ha:0 fderiv ℝ (u j)) → Controlled a (ball c r) (fun j x => CoefficientTrace.trace b (HessianInterpolation.hessian (u j) x) (A j x)) → (∀j,Controlled a (ball c r) (fun _:Unit => HessianInterpolation.hessian (u j))) → Controlled a (ball c (r/4)) (fun j => HessianInterpolation.hessian (u j)) := by obtain ⟨e,he,hs⟩ := interior_family (J:=J) b A0 hA0 ha ha1 refine ⟨e,he,?_⟩ intro c r hr u A hu hc hA hU hDu hP hF let ψ:ContDiffBump c := ⟨r/2,3*r/4,by positivity,by linarith⟩ let χ:ContDiffBump c := ⟨r/4,r/3,by positivity,by linarith⟩ apply hs u A ψ χ (ball c r) (ball c (r/2)) (ball c (r/4)) χ.contDiff χ.hasCompactSupport · rw [χ.tsupport_eq] intro x hx exact mem_ball.mpr ((mem_closedBall.mp hx).trans_lt (by dsimp only [χ]; linarith)) · exact ψ.contDiff · exact ψ.hasCompactSupport · intro x hx exact ψ.zero_of_le_dist (by dsimp only [ψ]; have hh:=not_lt.mp (mt mem_ball.mpr hx); linarith) · intro x rw [Real.norm_eq_abs,abs_of_nonneg ψ.nonneg] exact ψ.le_one · intro x hx exact ψ.one_of_mem_closedBall (mem_closedBall.mpr (mem_ball.mp hx).le) · exact ball_subset_ball (by linarith) · exact isOpen_ball · intro x hx exact χ.one_of_mem_closedBall (mem_closedBall.mpr (mem_ball.mp hx).le) · exact hu · exact hc · exact hA · exact hU · exact hDu · exact hP · exact hF end HolderControl end noncomputable section namespace HessianTrace section open Matrix InnerProductSpace open scoped InnerProductSpace ContDiff Matrix.Norms.Elementwise variable {E : Type*} {ι : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [Fintype ι] [DecidableEq ι] omit [Fintype ι] [DecidableEq ι] in lemma scalar_hessian {u : E → ℝ} (hu : ContDiff ℝ 2 u) (x v w : E) : HessianInterpolation.hessian u x v w=⟪fderiv ℝ (gradient u) x v,w⟫_ℝ := by have hg : ContDiff ℝ 1 (gradient u) := (toDual ℝ E).symm.toContinuousLinearEquiv.contDiff.comp (hu.fderiv_right (by norm_num)) have h := (toDual ℝ E).toContinuousLinearEquiv.toContinuousLinearMap.hasFDerivAt.comp x ((hg.differentiable one_ne_zero x).hasFDerivAt) change HasFDerivAt ((toDual ℝ E) ∘ gradient u) ((toDual ℝ E).toContinuousLinearEquiv.toContinuousLinearMap.comp (fderiv ℝ (gradient u) x)) x at h rw [toDual_comp_gradient] at h have he := congrArg (fun T : E →L[ℝ] E →L[ℝ] ℝ => T v w) h.fderiv exact he lemma trace_eq_matrix {u : E → ℝ} (hu : ContDiff ℝ 2 u) (b : OrthonormalBasis ι ℝ E) (A : E →L[ℝ] E) (x : E) : CoefficientTrace.trace b (HessianInterpolation.hessian u x) A= (LinearMap.toMatrix b.toBasis b.toBasis A.toLinearMap * LinearMap.toMatrix b.toBasis b.toBasis (fderiv ℝ (gradient u) x).toLinearMap).trace := by rw [← LinearMap.toMatrix_mul,← LinearMap.trace_eq_matrix_trace ℝ b.toBasis] rw [LinearMap.trace_mul_comm,LinearMap.trace_eq_sum_inner _ b] unfold CoefficientTrace.trace apply Finset.sum_congr rfl intro i _ rw [show HessianInterpolation.hessian u x (b i) (A (b i))= HessianInterpolation.hessian u x (A (b i)) (b i) from hu.contDiffAt.isSymmSndFDerivAt (by norm_num) _ _] rw [scalar_hessian hu] exact real_inner_comm _ _ local instance : TopologicalSpace (Matrix ι ι ℝ) := (inferInstance : PseudoMetricSpace (Matrix ι ι ℝ)).toUniformSpace.toTopologicalSpace def fromMatrix (b : OrthonormalBasis ι ℝ E) : Matrix ι ι ℝ ≃L[ℝ] E →L[ℝ] E := ((LinearMap.toMatrix b.toBasis b.toBasis).symm.trans LinearMap.toContinuousLinearMap).toContinuousLinearEquiv lemma fromMatrix_toMatrix (b : OrthonormalBasis ι ℝ E) (A : E →L[ℝ] E) : fromMatrix b (LinearMap.toMatrix b.toBasis b.toBasis A.toLinearMap)=A := by change LinearMap.toContinuousLinearMap ((LinearMap.toMatrix b.toBasis b.toBasis).symm ((LinearMap.toMatrix b.toBasis b.toBasis) A.toLinearMap))=A rw [LinearEquiv.symm_apply_apply] rfl omit [Fintype ι] [DecidableEq ι] in lemma hessian_clm {u : E → ℝ} (hu : ContDiff ℝ 2 u) (x : E) : HessianInterpolation.hessian u x= (toDual ℝ E).toContinuousLinearEquiv.toContinuousLinearMap.comp (fderiv ℝ (gradient u) x) := by ext v w exact scalar_hessian hu x v w lemma holder_transfer {u : E → ℝ} (hu : ContDiff ℝ 2 u) (b : OrthonormalBasis ι ℝ E) (x y : E) : dist (HessianInterpolation.hessian u x) (HessianInterpolation.hessian u y)≤ ‖(toDual ℝ E).toContinuousLinearEquiv.toContinuousLinearMap‖*‖(fromMatrix b).toContinuousLinearMap‖* dist (LinearMap.toMatrix b.toBasis b.toBasis (fderiv ℝ (gradient u) x).toLinearMap) (LinearMap.toMatrix b.toBasis b.toBasis (fderiv ℝ (gradient u) y).toLinearMap) := by rw [dist_eq_norm (HessianInterpolation.hessian u x) (HessianInterpolation.hessian u y), hessian_clm hu,hessian_clm hu,← ContinuousLinearMap.comp_sub] have hnorm := ContinuousLinearMap.opNorm_comp_le (toDual ℝ E).toContinuousLinearEquiv.toContinuousLinearMap (fderiv ℝ (gradient u) x-fderiv ℝ (gradient u) y) have hm := (fromMatrix b).toContinuousLinearMap.le_opNorm (LinearMap.toMatrix b.toBasis b.toBasis (fderiv ℝ (gradient u) x).toLinearMap- LinearMap.toMatrix b.toBasis b.toBasis (fderiv ℝ (gradient u) y).toLinearMap) simp only [ContinuousLinearEquiv.coe_coe,map_sub,fromMatrix_toMatrix] at hm exact hnorm.trans ((mul_le_mul_of_nonneg_left hm (norm_nonneg _)).trans_eq (by rw [dist_eq_norm]; ring)) end open Matrix Set InnerProductSpace open scoped InnerProductSpace Matrix.Norms.Elementwise variable {E : Type*} {ι : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [Fintype ι] [DecidableEq ι] local instance : TopologicalSpace (Matrix ι ι ℝ) := (inferInstance : PseudoMetricSpace (Matrix ι ι ℝ)).toUniformSpace.toTopologicalSpace lemma toMatrix_fromMatrix (b:OrthonormalBasis ι ℝ E) (M:Matrix ι ι ℝ) : LinearMap.toMatrix b.toBasis b.toBasis (fromMatrix b M).toLinearMap=M := by change (LinearMap.toMatrix b.toBasis b.toBasis) ((LinearMap.toMatrix b.toBasis b.toBasis).symm M)=M exact LinearEquiv.apply_symm_apply _ _ lemma inner_pos_fromMatrix (b:OrthonormalBasis ι ℝ E) {M:Matrix ι ι ℝ} (hM:M.PosDef) (v:E) (hv:v≠0) : 0<⟪v,fromMatrix b M v⟫_ℝ := by have hcoord:(b.toBasis.repr v:ι→ℝ)≠0 := by intro he have hz:b.toBasis.repr v=0 := DFunLike.coe_injective he exact hv (b.toBasis.repr.injective (by simpa using hz)) have hh := hM.dotProduct_mulVec_pos hcoord rw [← toMatrix_fromMatrix b M,LinearMap.toMatrix_mulVec_repr] at hh have he (w:E) : (b.toBasis.repr w:ι→ℝ)=WithLp.ofLp (b.repr w) := by ext i exact b.coe_toBasis_repr_apply w i rw [he v] at hh change 0 Matrix ι ι ℝ local instance : TopologicalSpace Mat := (inferInstance : PseudoMetricSpace Mat).toUniformSpace.toTopologicalSpace def segmentMatrix (A B : Mat) (t : ℝ) : Mat := A+t • (B-A) omit [Fintype ι] [DecidableEq ι] in lemma segment_pos {A B : Mat} (hA : A.PosDef) (hB : B.PosDef) {t : ℝ} (ht : t∈Icc (0:ℝ) 1) : (segmentMatrix A B t).PosDef := by have heq : segmentMatrix A B t=(1-t) • A+t • B := by unfold segmentMatrix module rw [heq] by_cases ht1 : t=1 · simpa only [ht1,sub_self,zero_smul,one_smul,zero_add] using hB · exact (hA.smul (sub_pos.mpr (lt_of_le_of_ne ht.2 ht1))).add_posSemidef (hB.posSemidef.smul ht.1) omit [DecidableEq ι] in lemma segment_continuous (A B : Mat) : Continuous (segmentMatrix A B) := by unfold segmentMatrix fun_prop lemma segment_inverse_continuous {A B : Mat} (hA : A.PosDef) (hB : B.PosDef) : ContinuousOn (fun t => (segmentMatrix A B t)⁻¹) (Icc (0:ℝ) 1) := by intro t ht apply ContinuousAt.continuousWithinAt apply ContinuousAt.comp (x:=t) _ (segment_continuous A B).continuousAt apply continuousAt_matrix_inv simpa only [Ring.inverse_eq_inv'] using continuousAt_inv₀ (segment_pos hA hB ht).det_pos.ne' lemma hasDerivAt_logdet_segment {A B : Mat} {t : ℝ} (hd : (segmentMatrix A B t).det≠0) : HasDerivAt (fun s => Real.log (segmentMatrix A B s).det) (((segmentMatrix A B t)⁻¹*(B-A)).trace) t := by have hQ : HasDerivAt (segmentMatrix A B) (B-A) t := by change HasDerivAt (fun s:ℝ => A+s • (B-A)) (B-A) t simpa only [segmentMatrix,id_eq,one_smul] using (((hasDerivAt_id t).smul_const (B-A)).const_add A) have hD := (MomentDifferential.detMultilinear.hasFDerivAt (segmentMatrix A B t)).comp_hasDerivAt t hQ have hlog := hD.log hd rw [MomentDifferential.det_linearDeriv] at hlog change HasDerivAt (fun s => Real.log (segmentMatrix A B s).det) (((segmentMatrix A B t).adjugate*(B-A)).trace/(segmentMatrix A B t).det) t at hlog have heq : (((segmentMatrix A B t)⁻¹*(B-A)).trace)= ((segmentMatrix A B t).adjugate*(B-A)).trace/(segmentMatrix A B t).det := by simp only [Matrix.inv_def,Ring.inverse_eq_inv,Matrix.smul_mul,Matrix.trace_smul,smul_eq_mul,div_eq_mul_inv] ring rw [heq] exact hlog def meanInverse (A B : Mat) : Mat := ∫ t in (0:ℝ)..1,(segmentMatrix A B t)⁻¹ def traceRight (D : Mat) : Mat →L[ℝ] ℝ := LinearMap.toContinuousLinearMap { toFun := fun M => (M*D).trace map_add' := by intro M N; simp only [Matrix.add_mul,Matrix.trace_add] map_smul' := by intro c M; simp only [Matrix.smul_mul,Matrix.trace_smul,RingHom.id_apply] } lemma logdet_difference {A B : Mat} (hA : A.PosDef) (hB : B.PosDef) : Real.log B.det-Real.log A.det=(meanInverse A B*(B-A)).trace := by have hc := segment_inverse_continuous hA hB have hi : IntervalIntegrable (fun t => (segmentMatrix A B t)⁻¹) volume (0:ℝ) 1 := (show ContinuousOn (fun t => (segmentMatrix A B t)⁻¹) (uIcc (0:ℝ) 1) by simpa using hc).intervalIntegrable have htr : Continuous (fun M : Mat => (M*(B-A)).trace) := (traceRight (B-A)).continuous have hitr : IntervalIntegrable (fun t => ((segmentMatrix A B t)⁻¹*(B-A)).trace) volume (0:ℝ) 1 := (show ContinuousOn (fun t => ((segmentMatrix A B t)⁻¹*(B-A)).trace) (uIcc (0:ℝ) 1) by simpa only [Function.comp_def,uIcc_of_le (by norm_num : (0:ℝ)≤1)] using htr.comp_continuousOn hc).intervalIntegrable have hft := intervalIntegral.integral_eq_sub_of_hasDerivAt (a:=0) (b:=1) (fun t ht => hasDerivAt_logdet_segment (segment_pos hA hB (by simpa using ht)).det_pos.ne') hitr have hend0 : segmentMatrix A B 0=A := by simp [segmentMatrix] have hend1 : segmentMatrix A B 1=B := by simp [segmentMatrix] rw [hend0,hend1] at hft rw [← hft] exact (traceRight (B-A)).intervalIntegral_comp_comm hi end section open Matrix Set Filter MeasureTheory open scoped ContDiff Matrix.Norms.Elementwise Topology variable {ι : Type*} [Fintype ι] [DecidableEq ι] local notation "Mat" => Matrix ι ι ℝ local instance : TopologicalSpace Mat := (inferInstance : PseudoMetricSpace Mat).toUniformSpace.toTopologicalSpace omit [DecidableEq ι] in lemma matrix_norm_mul (A B : Mat) : ‖A*B‖≤(Fintype.card ι:ℝ)*‖A‖*‖B‖ := by apply Matrix.norm_le_iff (by positivity) |>.mpr intro i j rw [Matrix.mul_apply] calc _ ≤ ∑ k,‖A i k*B k j‖ := norm_sum_le _ _ _ ≤ ∑ _k:ι,‖A‖*‖B‖ := by apply Finset.sum_le_sum intro k _ rw [norm_mul] exact mul_le_mul (Matrix.norm_entry_le_entrywise_sup_norm A) (Matrix.norm_entry_le_entrywise_sup_norm B) (norm_nonneg _) (norm_nonneg _) _ = _ := by simp only [Finset.sum_const,Finset.card_univ,nsmul_eq_mul,mul_assoc] lemma inverse_sub {A B : Mat} (hA : A.det≠0) (hB : B.det≠0) : A⁻¹-B⁻¹=A⁻¹*(B-A)*B⁻¹ := by rw [Matrix.mul_sub,Matrix.sub_mul,Matrix.mul_assoc,B.mul_nonsing_inv (isUnit_iff_ne_zero.mpr hB), Matrix.mul_one,A.nonsing_inv_mul (isUnit_iff_ne_zero.mpr hA),Matrix.one_mul] lemma inverse_lipschitz {A B : Mat} (hA : A.det≠0) (hB : B.det≠0) {C : ℝ} (hC : 0≤C) (hAC : ‖A⁻¹‖≤C) (hBC : ‖B⁻¹‖≤C) : dist A⁻¹ B⁻¹≤(Fintype.card ι:ℝ)^2*C^2*dist A B := by rw [dist_eq_norm,inverse_sub hA hB] have h1 := matrix_norm_mul (A⁻¹*(B-A)) B⁻¹ have h2 := matrix_norm_mul A⁻¹ (B-A) calc _ ≤ (Fintype.card ι:ℝ)*((Fintype.card ι:ℝ)*C*‖B-A‖)*C := h1.trans (mul_le_mul (mul_le_mul_of_nonneg_left (h2.trans (mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left hAC (Nat.cast_nonneg _)) (norm_nonneg _))) (Nat.cast_nonneg _)) hBC (norm_nonneg _) (by positivity)) _ = _ := by rw [← dist_eq_norm,dist_comm]; ring lemma mean_inverse_dist {A B C D : Mat} (hA : A.PosDef) (hB : B.PosDef) (hC : C.PosDef) (hD : D.PosDef) {S : ℝ} (hb : ∀ t∈Icc (0:ℝ) 1,dist (segmentMatrix A B t)⁻¹ (segmentMatrix C D t)⁻¹≤S) : dist (meanInverse A B) (meanInverse C D)≤S := by have hi1 : IntervalIntegrable (fun t => (segmentMatrix A B t)⁻¹) volume (0:ℝ) 1 := (show ContinuousOn (fun t => (segmentMatrix A B t)⁻¹) (uIcc (0:ℝ) 1) by simpa using segment_inverse_continuous hA hB).intervalIntegrable have hi2 : IntervalIntegrable (fun t => (segmentMatrix C D t)⁻¹) volume (0:ℝ) 1 := (show ContinuousOn (fun t => (segmentMatrix C D t)⁻¹) (uIcc (0:ℝ) 1) by simpa using segment_inverse_continuous hC hD).intervalIntegrable rw [dist_eq_norm,meanInverse,meanInverse,← intervalIntegral.integral_sub hi1 hi2] have hi := intervalIntegral.norm_integral_le_of_norm_le_const (a:=(0:ℝ)) (b:=1) (fun t ht => (show ‖(segmentMatrix A B t)⁻¹-(segmentMatrix C D t)⁻¹‖≤S from by simpa only [dist_eq_norm] using hb t ⟨(by simpa using ht.1.le),(by simpa using ht.2)⟩)) simpa using hi end open Matrix Set Metric MeasureTheory open scoped Matrix.Norms.Elementwise Topology variable {ι : Type*} [Fintype ι] [DecidableEq ι] local notation "Mat" => Matrix ι ι ℝ local instance : TopologicalSpace Mat := (inferInstance : PseudoMetricSpace Mat).toUniformSpace.toTopologicalSpace omit [DecidableEq ι] in lemma segment_dist (A B C D : Mat) {t : ℝ} (ht : t∈Icc (0:ℝ) 1) : dist (segmentMatrix A B t) (segmentMatrix C D t)≤(1-t)*dist A C+t*dist B D := by have he : segmentMatrix A B t-segmentMatrix C D t=(1-t) • (A-C)+t • (B-D) := by unfold segmentMatrix; module rw [dist_eq_norm,he] refine (norm_add_le _ _).trans_eq ?_ rw [norm_smul,norm_smul,Real.norm_eq_abs,Real.norm_eq_abs,abs_of_nonneg (sub_nonneg.mpr ht.2),abs_of_nonneg ht.1, ← dist_eq_norm,← dist_eq_norm] lemma mean_inverse_holder {E : Type*} [PseudoMetricSpace E] {H : E → Mat} {s : Set E} (hpos : ∀ x∈s,(H x).PosDef) {B C a : ℝ} (hB : 0≤B) (hH : ∀ x∈s,∀ y∈s,dist (H x) (H y)≤C*dist x y^a) (hb : ∀ x∈s,∀ y∈s,∀ t∈Icc (0:ℝ) 1,‖(segmentMatrix (H x) (H y) t)⁻¹‖≤B) {x x' y y' : E} (hx : x∈s) (hx' : x'∈s) (hy : y∈s) (hy' : y'∈s) (hd : dist x' y'=dist x y) : dist (meanInverse (H x) (H x')) (meanInverse (H y) (H y'))≤ (Fintype.card ι:ℝ)^2*B^2*C*dist x y^a := by apply mean_inverse_dist (hpos x hx) (hpos x' hx') (hpos y hy) (hpos y' hy') intro t ht have hs : dist (segmentMatrix (H x) (H x') t) (segmentMatrix (H y) (H y') t)≤C*dist x y^a := by refine (segment_dist _ _ _ _ ht).trans ?_ have h1 := mul_le_mul_of_nonneg_left (hH x hx y hy) (sub_nonneg.mpr ht.2) have h2 := mul_le_mul_of_nonneg_left (hH x' hx' y' hy') ht.1 rw [hd] at h2 calc _ ≤ (1-t)*(C*dist x y^a)+t*(C*dist x y^a) := add_le_add h1 h2 _ = _ := by ring have h1 := inverse_lipschitz (segment_pos (hpos x hx) (hpos x' hx') ht).det_pos.ne' (segment_pos (hpos y hy) (hpos y' hy') ht).det_pos.ne' hB (hb x hx x' hx' t ht) (hb y hy y' hy' t ht) exact h1.trans ((mul_le_mul_of_nonneg_left hs (by positivity)).trans_eq (by ring)) lemma mean_inverse_self (A : Mat) : meanInverse A A=A⁻¹ := by simp [meanInverse,segmentMatrix] lemma mean_inverse_close {A B M : Mat} (hA : A.PosDef) (hB : B.PosDef) (hM : M.PosDef) {D e : ℝ} (hD : 0≤D) (hbound : ∀ t∈Icc (0:ℝ) 1,‖(segmentMatrix A B t)⁻¹‖≤D) (hMbound : ‖M⁻¹‖≤D) (hAe : dist A M≤e) (hBe : dist B M≤e) : dist (meanInverse A B) M⁻¹≤(Fintype.card ι:ℝ)^2*D^2*e := by rw [← mean_inverse_self M] apply mean_inverse_dist hA hB hM hM intro t ht have hs : segmentMatrix M M t=M := by simp [segmentMatrix] rw [hs] have hb : dist (segmentMatrix A B t) M≤e := by have hh := segment_dist A B M M ht rw [hs] at hh have h1 := mul_le_mul_of_nonneg_left hAe (sub_nonneg.mpr ht.2) have h2 := mul_le_mul_of_nonneg_left hBe ht.1 exact hh.trans ((add_le_add h1 h2).trans_eq (by ring)) exact (inverse_lipschitz (segment_pos hA hB ht).det_pos.ne' hM.det_pos.ne' hD (hbound t ht) hMbound).trans (mul_le_mul_of_nonneg_left hb (by positivity)) end LogDetSegment end namespace LogDetSegment open Matrix Set Metric MeasureTheory open scoped Matrix.Norms.Elementwise Topology variable {ι : Type*} [Fintype ι] [DecidableEq ι] local notation "Mat" => Matrix ι ι ℝ local instance : TopologicalSpace Mat := (inferInstance : PseudoMetricSpace Mat).toUniformSpace.toTopologicalSpace lemma mean_inverse_norm {A B:Mat} {D:ℝ} (hD:∀t∈Icc (0:ℝ) 1,‖(segmentMatrix A B t)⁻¹‖≤D) : ‖meanInverse A B‖≤D := by have hi := intervalIntegral.norm_integral_le_of_norm_le_const (a:=(0:ℝ)) (b:=1) (fun t ht => hD t ⟨by simpa using ht.1.le,by simpa using ht.2⟩) simpa only [meanInverse,sub_zero,abs_one,mul_one] using hi lemma compact_segment_inverse_bound {X:Type*} [TopologicalSpace X] {K:Set X} (hK:IsCompact K) {H:X→Mat} (hH:Continuous H) (hp:∀x∈K,(H x).PosDef) : ∃ D:ℝ,0≤D ∧ ∀x∈K,∀y∈K,∀t∈Icc (0:ℝ) 1, ‖(segmentMatrix (H x) (H y) t)⁻¹‖≤D := by let S:Set (X×X×ℝ) := K ×ˢ (K ×ˢ Icc 0 1) let M:X×X×ℝ→Mat := fun p => segmentMatrix (H p.1) (H p.2.1) p.2.2 have hS:IsCompact S := hK.prod (hK.prod isCompact_Icc) have hM:Continuous M := by dsimp only [M,segmentMatrix]; fun_prop have hMi:ContinuousOn (fun p => (M p)⁻¹) S := by intro p hpS apply ContinuousAt.continuousWithinAt apply (continuousAt_matrix_inv (M p) ?_).comp hM.continuousAt have hd : (M p).det≠0 := (segment_pos (hp p.1 hpS.1) (hp p.2.1 hpS.2.1) hpS.2.2).det_pos.ne' simpa only [Ring.inverse_eq_inv'] using continuousAt_inv₀ hd obtain ⟨D,hD⟩ := (hS.image_of_continuousOn hMi).isBounded.exists_norm_le refine ⟨max D 0,le_max_right _ _,?_⟩ intro x hx y hy t ht exact (hD _ (mem_image_of_mem _ (show (x,y,t)∈S from ⟨hx,hy,ht⟩))).trans (le_max_left _ _) end LogDetSegment namespace HolderControl open Set Metric variable {E : Type*} {F : Type*} {J : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [NormedAddCommGroup F] [NormedSpace ℝ F] lemma compact_convex_C1 {a:ℝ} (ha:0≤a) (ha1:a≤1) {K:Set E} (hK:IsCompact K) (hconv:Convex ℝ K) {f:E→F} (hf:ContDiff ℝ 1 f) : Controlled a K (fun _:J => f) := by obtain ⟨B,hB⟩ := (hK.image hf.continuous).isBounded.exists_norm_le obtain ⟨D,hD⟩ := (hK.image (contDiff_one_iff_fderiv.mp hf).2).isBounded.exists_norm_le let B₀ := max B 0 let D₀ := max D 0 have hB₀ : 0≤B₀ := le_max_right _ _ have hD₀ : 0≤D₀ := le_max_right _ _ have hb (x:E) (hx:x∈K) : ‖f x‖≤B₀ := (hB _ (mem_image_of_mem f hx)).trans (le_max_left _ _) have hd (x:E) (hx:x∈K) : ‖fderiv ℝ f x‖≤D₀ := (hD _ (mem_image_of_mem _ hx)).trans (le_max_left _ _) have hl : LipschitzOnWith ⟨D₀,hD₀⟩ f K := hconv.lipschitzOnWith_of_nnnorm_fderiv_le (fun x _ => hf.differentiable one_ne_zero x) (fun x hx => hd x hx) have hls : ∀x y:K,dist (f x) (f y)≤D₀*dist x y := fun x y => hl.dist_le_mul x x.prop y y.prop refine ⟨B₀,D₀+2*B₀,hB₀,by positivity,fun _ => hb,?_⟩ intro _ x hx y hy exact HolderLocalization.of_lipschitz_bounded hD₀ hB₀ ha ha1 hls (fun x:K => hb x x.prop) ⟨x,hx⟩ ⟨y,hy⟩ end HolderControl namespace LogDetSegment open Matrix Set Metric open scoped Matrix.Norms.Elementwise Topology variable {ι : Type*} [Fintype ι] [DecidableEq ι] local notation "Mat" => Matrix ι ι ℝ local instance : TopologicalSpace Mat := (inferInstance : PseudoMetricSpace Mat).toUniformSpace.toTopologicalSpace variable {E : Type*} {F : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [FiniteDimensional ℝ E] [NormedAddCommGroup F] [NormedSpace ℝ F] lemma local_mean_control (T:Mat→L[ℝ]F) {H:E→Mat} (hH:Continuous H) (hp:∀x,(H x).PosDef) {c:E} {R C a:ℝ} (hR:0 fun x => T (meanInverse (H x) (H (x+v.val)))) ∧ ∀v:{v:E // ‖v‖ hp x) let K:ℝ := ‖T‖*(Fintype.card ι:ℝ)^2*D^2 have hK:0≤K := by dsimp only [K]; positivity let δ:ℝ := e/(1+K) have hδ:0<δ := div_pos he (by positivity) obtain ⟨d,hd,hnear⟩ := Metric.continuousAt_iff.mp (hH.continuousAt (x:=c)) δ hδ let r:ℝ := min R d/4 have hr:0 hDb x (mem_closedBall.mpr (mem_ball.mp (hin hx)).le) (x+v.val) (mem_closedBall.mpr (mem_ball.mp (hshift v.prop hx)).le) t ht)) (norm_nonneg T)) · intro v x hx y hy have hh := mean_inverse_holder (s:=ball c R) (fun x _ => hp x) hD hhold (fun x hx y hy t ht => hDb x (mem_closedBall.mpr (mem_ball.mp hx).le) y (mem_closedBall.mpr (mem_ball.mp hy).le) t ht) (hin hx) (hshift v.prop hx) (hin hy) (hshift v.prop hy) (dist_add_right x y v.val) exact (hTd _ _).trans ((mul_le_mul_of_nonneg_left hh (norm_nonneg T)).trans_eq (by dsimp only [K]; ring)) · intro v x hx have hh := mean_inverse_close (hp x) (hp (x+v.val)) (hp c) hD (fun t ht => hDb x (mem_closedBall.mpr (mem_ball.mp (hin hx)).le) (x+v.val) (mem_closedBall.mpr (mem_ball.mp (hshift v.prop hx)).le) t ht) (by have hc:c∈closedBall c R := mem_closedBall_self hR.le have ht := hDb c hc c hc 0 (by norm_num) simpa only [segmentMatrix,zero_smul,sub_zero,one_smul,add_zero] using ht) (hxn hx) (hshiftn v.prop hx) have hb : dist (T (meanInverse (H x) (H (x+v.val)))) (T ((H c)⁻¹))≤K*δ := (hTd _ _).trans ((mul_le_mul_of_nonneg_left hh (norm_nonneg T)).trans_eq (by dsimp only [K]; ring)) have hKe:K*δ≤e := by dsimp only [δ] rw [← mul_div_assoc,div_le_iff₀ (by positivity : 0<1+K)] nlinarith exact (by simpa only [dist_eq_norm,norm_sub_rev] using hb : ‖T ((H c)⁻¹)-T (meanInverse (H x) (H (x+v.val)))‖≤K*δ).trans hKe end LogDetSegment namespace FiniteDifference section open Set Metric MeasureTheory open scoped ContDiff variable {E : Type*} {F : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [NormedAddCommGroup F] [NormedSpace ℝ F] [CompleteSpace F] def increment (g : E → F) (v x : E) : F := g (x+v)-g x omit [CompleteSpace F] in lemma hasDerivAt_ray {g : E → F} (hg : ContDiff ℝ 1 g) (x v : E) (t : ℝ) : HasDerivAt (fun s : ℝ => g (x+s • v)) (fderiv ℝ g (x+t • v) v) t := by have hr : HasDerivAt (fun s : ℝ => x+s • v) v t := by simpa only [id_eq,one_smul] using (((hasDerivAt_id t).smul_const v).const_add x) exact ((hg.differentiable one_ne_zero _).hasFDerivAt).comp_hasDerivAt t hr omit [CompleteSpace F] in lemma ray_integrable {g : E → F} (hg : ContDiff ℝ 1 g) (x v : E) : IntervalIntegrable (fun t : ℝ => fderiv ℝ g (x+t • v) v) volume (0:ℝ) 1 := by have hc : Continuous (fderiv ℝ g) := (contDiff_one_iff_fderiv.mp hg).2 exact ((hc.comp (show Continuous (fun t : ℝ => x+t • v) by fun_prop)).clm_apply continuous_const).intervalIntegrable 0 1 lemma increment_integral {g : E → F} (hg : ContDiff ℝ 1 g) (x v : E) : increment g v x=∫ t in (0:ℝ)..1,fderiv ℝ g (x+t • v) v := by have h := intervalIntegral.integral_eq_sub_of_hasDerivAt (a:=(0:ℝ)) (b:=1) (fun t _ => hasDerivAt_ray hg x v t) (ray_integrable hg x v) simpa only [one_smul,zero_smul,add_zero,increment] using h.symm omit [NormedAddCommGroup F] [NormedSpace ℝ F] [CompleteSpace F] in lemma ray_mem {Ω : Set E} (hΩ : Convex ℝ Ω) {x v : E} (hx : x∈Ω) (hxv : x+v∈Ω) {t : ℝ} (ht : t∈Icc (0:ℝ) 1) : x+t • v∈Ω := by have hh := hΩ hx hxv (sub_nonneg.mpr ht.2) ht.1 (by ring : (1-t)+t=1) convert hh using 1 module lemma increment_holder {g : E → F} (hg : ContDiff ℝ 1 g) {Ω : Set E} (hΩ : Convex ℝ Ω) {C a : ℝ} (_hC : 0≤C) (hH : ∀ x∈Ω,∀ y∈Ω,dist (fderiv ℝ g x) (fderiv ℝ g y)≤C*dist x y^a) {x y v : E} (hx : x∈Ω) (hy : y∈Ω) (hxv : x+v∈Ω) (hyv : y+v∈Ω) : dist (increment g v x) (increment g v y)≤C*‖v‖*dist x y^a := by rw [dist_eq_norm,increment_integral hg,increment_integral hg,← intervalIntegral.integral_sub (ray_integrable hg x v) (ray_integrable hg y v)] have hb (t : ℝ) (ht : t∈Icc (0:ℝ) 1) : ‖fderiv ℝ g (x+t • v) v-fderiv ℝ g (y+t • v) v‖≤C*‖v‖*dist x y^a := by have hh := hH _ (ray_mem hΩ hx hxv ht) _ (ray_mem hΩ hy hyv ht) rw [dist_add_right,dist_eq_norm] at hh calc _ ≤ ‖fderiv ℝ g (x+t • v)-fderiv ℝ g (y+t • v)‖*‖v‖ := (fderiv ℝ g (x+t • v)-fderiv ℝ g (y+t • v)).le_opNorm v _ ≤ (C*dist x y^a)*‖v‖ := mul_le_mul_of_nonneg_right hh (norm_nonneg _) _ = _ := by ring have hh := intervalIntegral.norm_integral_le_of_norm_le_const (a:=(0:ℝ)) (b:=1) (fun t ht => hb t ⟨(by simpa using ht.1.le),(by simpa using ht.2)⟩) simpa using hh lemma increment_bound {g : E → F} (hg : ContDiff ℝ 1 g) {Ω : Set E} (hΩ : Convex ℝ Ω) {B : ℝ} (hH : ∀ x∈Ω,‖fderiv ℝ g x‖≤B) {x v : E} (hx : x∈Ω) (hxv : x+v∈Ω) : ‖increment g v x‖≤B*‖v‖ := by rw [increment_integral hg] have hb (t : ℝ) (ht : t∈Icc (0:ℝ) 1) : ‖fderiv ℝ g (x+t • v) v‖≤B*‖v‖ := ((fderiv ℝ g (x+t • v)).le_opNorm v).trans (mul_le_mul_of_nonneg_right (hH _ (ray_mem hΩ hx hxv ht)) (norm_nonneg _)) have hh := intervalIntegral.norm_integral_le_of_norm_le_const (a:=(0:ℝ)) (b:=1) (fun t ht => hb t ⟨(by simpa using ht.1.le),(by simpa using ht.2)⟩) simpa using hh end open Set Metric variable {E : Type*} {F : Type*} {J : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [NormedAddCommGroup F] [NormedSpace ℝ F] [CompleteSpace F] def normalized (g : E → F) (v x : E) : F := ‖v‖⁻¹ • increment g v x lemma normalized_controlled {a : ℝ} {Ω s : Set E} (hΩ : Convex ℝ Ω) {g : E → F} (hg : ContDiff ℝ 1 g) (hD : HolderControl.Controlled a Ω (fun _ : Unit => fderiv ℝ g)) (v : J → E) (hs : s⊆Ω) (hshift : ∀ j x,x∈s → x+v j∈Ω) : HolderControl.Controlled a s (fun j => normalized g (v j)) := by obtain ⟨B,C,hB,hC,hDb,hDc⟩ := hD refine ⟨B,C,hB,hC,?_,?_⟩ · intro j x hx change ‖normalized g (v j) x‖≤B by_cases hv : v j=0 · simp only [normalized,hv,norm_zero,inv_zero,zero_smul]; exact hB have hn : 0<‖v j‖ := norm_pos_iff.mpr hv rw [normalized,norm_smul,Real.norm_eq_abs,abs_of_pos (inv_pos.mpr hn)] have hh := increment_bound hg hΩ (hDb ()) (hs hx) (hshift j x hx) exact (mul_le_mul_of_nonneg_left hh (inv_nonneg.mpr hn.le)).trans_eq (by field_simp) · intro j x hx y hy change dist (normalized g (v j) x) (normalized g (v j) y)≤C*dist x y^a by_cases hv : v j=0 · simp only [normalized,hv,norm_zero,inv_zero,zero_smul,dist_self]; positivity have hn : 0<‖v j‖ := norm_pos_iff.mpr hv rw [normalized,normalized,dist_smul₀,Real.norm_eq_abs,abs_of_pos (inv_pos.mpr hn)] have hh := increment_holder hg hΩ hC (hDc ()) (hs hx) (hs hy) (hshift j x hx) (hshift j y hy) exact (mul_le_mul_of_nonneg_left hh (inv_nonneg.mpr hn.le)).trans_eq (by field_simp) omit [CompleteSpace F] in lemma fderiv_normalized {g : E → F} (hg : ContDiff ℝ 1 g) (v x : E) : fderiv ℝ (normalized g v) x=normalized (fderiv ℝ g) v x := by have hd := hg.differentiable one_ne_zero unfold normalized increment rw [fderiv_fun_const_smul (f := fun y => g (y+v)-g y) (((hd (x+v)).comp x (differentiableAt_id.add_const v)).sub (hd x)), fderiv_fun_sub (f := fun y => g (y+v)) (g :=g) ((hd (x+v)).comp x (differentiableAt_id.add_const v)) (hd x),fderiv_comp_add_right] end FiniteDifference namespace MomentQuotient section open Matrix Set InnerProductSpace open scoped ContDiff Matrix.Norms.Elementwise InnerProductSpace variable {E : Type*} {ι : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [Fintype ι] [DecidableEq ι] local instance : TopologicalSpace (Matrix ι ι ℝ) := (inferInstance : PseudoMetricSpace (Matrix ι ι ℝ)).toUniformSpace.toTopologicalSpace def quotient (u : E → ℝ) (v x : E) : ℝ := ‖v‖⁻¹*(u (x+v)-u x) def matrixHessian (b : OrthonormalBasis ι ℝ E) (u : E → ℝ) (x : E) : Matrix ι ι ℝ := LinearMap.toMatrix b.toBasis b.toBasis (fderiv ℝ (gradient u) x).toLinearMap def coefficient (b : OrthonormalBasis ι ℝ E) (u : E → ℝ) (v x : E) : E →L[ℝ] E := HessianTrace.fromMatrix b (LogDetSegment.meanInverse (matrixHessian b u x) (matrixHessian b u (x+v))) omit [FiniteDimensional ℝ E] [Fintype ι] [DecidableEq ι] in lemma quotient_contDiff {u : E → ℝ} (hu : ContDiff ℝ 2 u) (v : E) : ContDiff ℝ 2 (quotient u v) := contDiff_const.mul ((hu.comp (contDiff_id.add contDiff_const)).sub hu) omit [FiniteDimensional ℝ E] [Fintype ι] [DecidableEq ι] in lemma hessian_quotient {u : E → ℝ} (hu : ContDiff ℝ 2 u) (v x : E) : HessianInterpolation.hessian (quotient u v) x= ‖v‖⁻¹ • (HessianInterpolation.hessian u (x+v)-HessianInterpolation.hessian u x) := by have hd := hu.differentiable (by norm_num : (2:ℕ∞ω)≠0) have hD := (hu.fderiv_right (by norm_num : (1:ℕ∞ω)+1≤2)).differentiable one_ne_zero have hq : fderiv ℝ (quotient u v)=fun y => ‖v‖⁻¹ • (fderiv ℝ u (y+v)-fderiv ℝ u y) := by funext y change fderiv ℝ (fun y => ‖v‖⁻¹ • (u (y+v)-u y)) y=_ rw [fderiv_fun_const_smul (f := fun y => u (y+v)-u y) (((hd (y+v)).comp y (differentiableAt_id.add_const v)).sub (hd y)), fderiv_fun_sub (f := fun y => u (y+v)) (g := u) ((hd (y+v)).comp y (differentiableAt_id.add_const v)) (hd y),fderiv_comp_add_right] unfold HessianInterpolation.hessian rw [hq,fderiv_fun_const_smul (f := fun y => fderiv ℝ u (y+v)-fderiv ℝ u y) (((hD (x+v)).comp x (differentiableAt_id.add_const v)).sub (hD x)), fderiv_fun_sub (f := fun y => fderiv ℝ u (y+v)) (g := fderiv ℝ u) ((hD (x+v)).comp x (differentiableAt_id.add_const v)) (hD x),fderiv_comp_add_right] lemma toMatrix_coefficient (b : OrthonormalBasis ι ℝ E) (u : E → ℝ) (v x : E) : LinearMap.toMatrix b.toBasis b.toBasis (coefficient b u v x).toLinearMap= LogDetSegment.meanInverse (matrixHessian b u x) (matrixHessian b u (x+v)) := by change (LinearMap.toMatrix b.toBasis b.toBasis) ((LinearMap.toMatrix b.toBasis b.toBasis).symm _) = _ exact LinearEquiv.apply_symm_apply _ _ lemma equation (b : OrthonormalBasis ι ℝ E) {u V : E → ℝ} (hu : ContDiff ℝ 2 u) {c : ℝ} (heq : ∀ x,Real.log (matrixHessian b u x).det=V (gradient u x)+c-u x) (hpos : ∀ x,(matrixHessian b u x).PosDef) (v x : E) : CoefficientTrace.trace b (HessianInterpolation.hessian (quotient u v) x) (coefficient b u v x)= ‖v‖⁻¹*(V (gradient u (x+v))-V (gradient u x))-quotient u v x := by rw [hessian_quotient hu] have hsm (H : E →L[ℝ] E →L[ℝ] ℝ) (A : E →L[ℝ] E) (r : ℝ) : CoefficientTrace.trace b (r • H) A=r*CoefficientTrace.trace b H A := by simp only [CoefficientTrace.trace,_root_.smul_apply,smul_eq_mul,Finset.mul_sum] rw [hsm,CoefficientTrace.sub_left,HessianTrace.trace_eq_matrix hu,HessianTrace.trace_eq_matrix hu, toMatrix_coefficient,← Matrix.trace_sub,← Matrix.mul_sub] change ‖v‖⁻¹*(LogDetSegment.meanInverse (matrixHessian b u x) (matrixHessian b u (x+v))* (matrixHessian b u (x+v)-matrixHessian b u x)).trace=_ rw [← LogDetSegment.logdet_difference (hpos x) (hpos (x+v)),heq,heq] unfold quotient ring end open Set Metric InnerProductSpace open scoped ContDiff variable {E : Type*} {J : Type*} {ι : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [Fintype ι] [DecidableEq ι] local instance : NormedAddCommGroup (E →L[ℝ] ℝ) := ContinuousLinearMap.toNormedAddCommGroup local instance : NormedSpace ℝ (E →L[ℝ] ℝ) := ContinuousLinearMap.toNormedSpace local instance : NormedAddCommGroup (E →L[ℝ] E →L[ℝ] ℝ) := ContinuousLinearMap.toNormedAddCommGroup local instance : NormedSpace ℝ (E →L[ℝ] E →L[ℝ] ℝ) := ContinuousLinearMap.toNormedSpace omit [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [Fintype ι] [DecidableEq ι] in lemma quotient_normalized (u:E→ℝ) (v:E) : quotient u v=FiniteDifference.normalized u v := rfl omit [Fintype ι] [DecidableEq ι] in lemma derivative_gradient {u:E→ℝ} (hu:ContDiff ℝ 2 u) (x:E) : fderiv ℝ (gradient u) x=(toDual ℝ E).symm.toContinuousLinearEquiv.toContinuousLinearMap.comp (HessianInterpolation.hessian u x) := by exact ((toDual ℝ E).symm.toContinuousLinearEquiv.toContinuousLinearMap.hasFDerivAt.comp x (((hu.fderiv_right (by norm_num : (1:ℕ∞ω)+1≤2)).differentiable one_ne_zero x).hasFDerivAt)).fderiv omit [Fintype ι] [DecidableEq ι] in lemma source_derivative_controlled {u V:E→ℝ} (hu:ContDiff ℝ 2 u) (hV:ContDiff ℝ 2 V) {a:ℝ} (ha:0≤a) (ha1:a≤1) {K:Set E} (hK:IsCompact K) (hconv:Convex ℝ K) (hH:HolderControl.Controlled a K (fun _:Unit => HessianInterpolation.hessian u)) : HolderControl.Controlled a K (fun _:Unit => fderiv ℝ (fun x => V (gradient u x)-u x)) := by have hDu:ContDiff ℝ 1 (fderiv ℝ u) := hu.fderiv_right (by norm_num) have hgu:ContDiff ℝ 1 (gradient u) := (toDual ℝ E).symm.toContinuousLinearEquiv.contDiff.comp hDu have hDV:ContDiff ℝ 1 (fun x => fderiv ℝ V (gradient u x)) := (hV.fderiv_right (by norm_num : (1:ℕ∞ω)+1≤2)).comp hgu have hDuc:HolderControl.Controlled a K (fun _:Unit => fderiv ℝ u) := HolderControl.compact_convex_C1 ha ha1 hK hconv hDu have hDVc:HolderControl.Controlled a K (fun _:Unit => fun x => fderiv ℝ V (gradient u x)) := HolderControl.compact_convex_C1 ha ha1 hK hconv hDV have hDgc:HolderControl.Controlled a K (fun _:Unit => fderiv ℝ (gradient u)) := by have hh := hH.linear ((ContinuousLinearMap.compL ℝ E (E→L[ℝ]ℝ) E) (toDual ℝ E).symm.toContinuousLinearEquiv.toContinuousLinearMap) exact hh.congr (fun _ x _ => (derivative_gradient hu x).symm) have hc := (hDVc.bilinear (ContinuousLinearMap.compL ℝ E E ℝ) hDgc).sub hDuc apply hc.congr intro _ x _ exact (((hV.differentiable (by norm_num : (2:ℕ∞ω)≠0) (gradient u x)).hasFDerivAt.comp x ((hgu.differentiable one_ne_zero x).hasFDerivAt)).sub ((hu.differentiable (by norm_num : (2:ℕ∞ω)≠0) x).hasFDerivAt)).fderiv.symm omit [FiniteDimensional ℝ E] [Fintype ι] [DecidableEq ι] in lemma normalized_hessian_finite {u:E→ℝ} (hu:ContDiff ℝ 2 u) {a:ℝ} {K s:Set E} (hH:HolderControl.Controlled a K (fun _:Unit => HessianInterpolation.hessian u)) (hs:s⊆K) (v:E) (hshift:∀x∈s,x+v∈K) : HolderControl.Controlled a s (fun _:Unit => HessianInterpolation.hessian (quotient u v)) := by obtain ⟨B,C,hB,hC,hb,hc⟩ := hH have hshiftC:HolderControl.Controlled a s (fun _:Unit => fun x => HessianInterpolation.hessian u (x+v)) := by refine ⟨B,C,hB,hC,fun _ x hx => hb () (x+v) (hshift x hx),?_⟩ intro _ x hx y hy simpa only [dist_add_right] using hc () (x+v) (hshift x hx) (y+v) (hshift y hy) have hbase:HolderControl.Controlled a s (fun _:Unit => HessianInterpolation.hessian u) := (show HolderControl.Controlled a K (fun _:Unit => HessianInterpolation.hessian u) from ⟨B,C,hB,hC,hb,hc⟩).mono hs have hdiff := (hshiftC.sub hbase).linear ((ContinuousLinearMap.lsmul ℝ ℝ) ‖v‖⁻¹) exact hdiff.congr (fun _ x _ => (hessian_quotient hu v x).symm) lemma data (b:OrthonormalBasis ι ℝ E) {u V:E→ℝ} (hu:ContDiff ℝ 2 u) (hV:ContDiff ℝ 2 V) {c:ℝ} (heq:∀x,Real.log (matrixHessian b u x).det=V (gradient u x)+c-u x) (hpos:∀x,(matrixHessian b u x).PosDef) {a:ℝ} (ha:0 HessianInterpolation.hessian u)) (v:J→E) (hshift:∀j x,x∈s → x+v j∈K) : HolderControl.Controlled a s (fun j => quotient u (v j)) ∧ HolderControl.Controlled a s (fun j => fderiv ℝ (quotient u (v j))) ∧ HolderControl.Controlled a s (fun j x => CoefficientTrace.trace b (HessianInterpolation.hessian (quotient u (v j)) x) (coefficient b u (v j) x)) ∧ ∀j,HolderControl.Controlled a s (fun _:Unit => HessianInterpolation.hessian (quotient u (v j))) := by have hu1:ContDiff ℝ 1 u := hu.of_le (by norm_num) have hDu:ContDiff ℝ 1 (fderiv ℝ u) := hu.fderiv_right (by norm_num) have hDuc:HolderControl.Controlled a K (fun _:Unit => fderiv ℝ u) := HolderControl.compact_convex_C1 ha.le ha1.le hK hconv hDu have hQ := FiniteDifference.normalized_controlled hconv hu1 hDuc v hs hshift have hDQ := FiniteDifference.normalized_controlled hconv hDu hH v hs hshift have hg:ContDiff ℝ 1 (fun x => V (gradient u x)-u x) := ((hV.of_le (by norm_num : (1:ℕ∞ω)≤2)).comp ((toDual ℝ E).symm.toContinuousLinearEquiv.contDiff.comp hDu)).sub hu1 have hsource := FiniteDifference.normalized_controlled hconv hg (source_derivative_controlled hu hV ha.le ha1.le hK hconv hH) v hs hshift refine ⟨hQ,?_,?_,fun j => normalized_hessian_finite hu hH hs (v j) (hshift j)⟩ · exact hDQ.congr (fun j x _ => (FiniteDifference.fderiv_normalized hu1 (v j) x).symm) · apply hsource.congr intro j x _ rw [equation b hu heq hpos] unfold FiniteDifference.normalized FiniteDifference.increment quotient simp only [smul_eq_mul] ring end MomentQuotient namespace AEDerivativeLocal open Filter Set Metric MeasureTheory open scoped Topology NNReal variable {E : Type*} {F : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] [NormedAddCommGroup F] [NormedSpace ℝ F] variable (μ : Measure E) [μ.IsAddHaarMeasure] lemma increment_bound {g : E → F} {Ω : Set E} {L : ℝ≥0} (hg : LipschitzOnWith L g Ω) (hΩ : IsOpen Ω) (hc : Convex ℝ Ω) (A : E →L[ℝ] F) {e : ℝ} (_he : 0≤e) (ha : ∀ᵐ z ∂μ,z∈Ω → DifferentiableAt ℝ g z ∧ ‖fderiv ℝ g z-A‖≤e) {x h : E} (hx : x∈Ω) (hxh : x+h∈Ω) : ‖g (x+h)-g x-A h‖≤e*‖h‖ := by obtain ⟨ω,hω,hωv⟩ := exists_dual_vector'' ℝ (g (x+h)-g x-A h) let f : E → ℝ := fun z => ω (g z-A z) have hf : LipschitzOnWith (‖ω‖₊*(L+‖A‖₊)) f Ω := ω.lipschitzWith.comp_lipschitzOnWith (hg.sub A.lipschitzWith.lipschitzOnWith) obtain ⟨fbar,hfbar,heq⟩ := hf.extend_real have hevent {z : E} (hz : z∈Ω) : fbar=ᶠ[𝓝 z] f := Filter.Eventually.mono (hΩ.mem_nhds hz) (fun y hy => (heq hy).symm) have ha' : ∀ᵐ z ∂μ,z∈Ω → DifferentiableAt ℝ fbar z ∧ fderiv ℝ fbar z h≤e*‖h‖ := by filter_upwards [ha] with z hz hzΩ have hdg := (hz hzΩ).1.hasFDerivAt.sub A.hasFDerivAt have hd := (ω.hasFDerivAt.comp z hdg).congr_of_eventuallyEq (hevent hzΩ) refine ⟨hd.differentiableAt,?_⟩ rw [hd.fderiv] change ω ((fderiv ℝ g z-A) h)≤_ have hh := (ContinuousLinearMap.le_opNorm (fderiv ℝ g z-A) h).trans (mul_le_mul_of_nonneg_right (hz hzΩ).2 (norm_nonneg h)) calc _ ≤ ‖ω ((fderiv ℝ g z-A) h)‖ := le_abs_self _ _ ≤ ‖ω‖*‖(fderiv ℝ g z-A) h‖ := ω.le_opNorm _ _ ≤ 1*(e*‖h‖) := mul_le_mul hω hh (norm_nonneg _) (by norm_num) _ = _ := one_mul _ have hh := AESlice.difference_le_ae μ hfbar hΩ hc ha' (a:=1) (by norm_num) hx (by simpa only [one_smul] using hxh) simp only [one_smul,mul_one] at hh rw [← heq hx,← heq hxh] at hh have hid : f (x+h)-f x=ω (g (x+h)-g x-A h) := by dsimp only [f] rw [← map_sub,map_add] congr 1 abel rwa [hid,hωv] at hh theorem hasFDerivAt_of_ae {g : E → F} {Ω : Set E} {L : ℝ≥0} (hg : LipschitzOnWith L g Ω) (hΩ : IsOpen Ω) {A : E → E →L[ℝ] F} (hA : ContinuousOn A Ω) (ha : ∀ᵐ z ∂μ,z∈Ω → HasFDerivAt g (A z) z) {x : E} (hx : x∈Ω) : HasFDerivAt g (A x) x := by rw [hasFDerivAt_iff_isLittleO_nhds_zero,Asymptotics.isLittleO_iff] intro e he have hAc : ContinuousAt A x := (hA x hx).continuousAt (hΩ.mem_nhds hx) obtain ⟨r,hr,hball⟩ := Metric.eventually_nhds_iff.mp ((hAc.eventually (Metric.ball_mem_nhds (A x) he)).and (hΩ.mem_nhds hx)) have hs : ball x r⊆Ω := fun z hz => (hball (mem_ball.mp hz)).2 have ha' : ∀ᵐ z ∂μ,z∈ball x r → DifferentiableAt ℝ g z ∧ ‖fderiv ℝ g z-A x‖≤e := by filter_upwards [ha] with z hz hzB refine ⟨(hz (hs hzB)).differentiableAt,?_⟩ rw [(hz (hs hzB)).fderiv] exact le_of_lt (by simpa only [mem_ball,dist_eq_norm] using (hball (mem_ball.mp hzB)).1) filter_upwards [Metric.ball_mem_nhds (0:E) hr] with h hhB exact increment_bound μ (hg.mono hs) isOpen_ball (convex_ball _ _) (A x) he.le ha' (mem_ball_self hr) (by simpa only [mem_ball,dist_eq_norm,add_sub_cancel_left,sub_zero] using hhB) end AEDerivativeLocal namespace QuotientBootstrap open Set Filter Metric MeasureTheory open scoped Topology NNReal variable {E : Type*} {F : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] [NormedAddCommGroup F] [NormedSpace ℝ F] [FiniteDimensional ℝ F] omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] [FiniteDimensional ℝ F] in lemma derivative_holder {g : E → F} {Ω : Set E} (hΩ : IsOpen Ω) {a U : ℝ} (hU : 0≤U) (hQ : ∀ x∈Ω,∀ y∈Ω,∀ v:E,x+v∈Ω → y+v∈Ω → ‖g (x+v)-g x-(g (y+v)-g y)‖≤U*‖v‖*dist x y^a) {x y : E} (hx : x∈Ω) (hy : y∈Ω) (hdx : DifferentiableAt ℝ g x) (hdy : DifferentiableAt ℝ g y) : dist (fderiv ℝ g x) (fderiv ℝ g y)≤U*dist x y^a := by rw [dist_eq_norm] apply ContinuousLinearMap.opNorm_le_bound (f:=fderiv ℝ g x-fderiv ℝ g y) (by positivity) intro v have hxlim := (hdx.hasFDerivAt.hasLineDerivAt v).tendsto_slope_zero_right have hylim := (hdy.hasFDerivAt.hasLineDerivAt v).tendsto_slope_zero_right have hlim := (hxlim.sub hylim).norm have hxev : ∀ᶠ t:ℝ in 𝓝[>] 0,x+t • v∈Ω := by have ht : Tendsto (fun t:ℝ => x+t • v) (𝓝 0) (𝓝 x) := by simpa only [zero_smul,add_zero] using ((show Continuous (fun t:ℝ => x+t • v) from by fun_prop).tendsto (0:ℝ)) exact (ht.eventually (hΩ.mem_nhds hx)).filter_mono nhdsWithin_le_nhds have hyev : ∀ᶠ t:ℝ in 𝓝[>] 0,y+t • v∈Ω := by have ht : Tendsto (fun t:ℝ => y+t • v) (𝓝 0) (𝓝 y) := by simpa only [zero_smul,add_zero] using ((show Continuous (fun t:ℝ => y+t • v) from by fun_prop).tendsto (0:ℝ)) exact (ht.eventually (hΩ.mem_nhds hy)).filter_mono nhdsWithin_le_nhds apply le_of_tendsto hlim filter_upwards [hxev,hyev,self_mem_nhdsWithin] with t hxt hyt ht have ht0 : 0 hz z.prop,fun hz _ => hz⟩ rwa [he] at hd let H : Ω → E →L[ℝ] F := fun z => fderiv ℝ g z have hGH (x : Ω) (hx : x∈G) (y : Ω) (hy : y∈G) : dist (H x) (H y)≤U*dist x y^a := derivative_holder hΩ hU hQ x.prop y.prop hx hy have hp : Continuous (fun p : Ω×Ω => U*dist p.1 p.2^a) := continuous_const.mul ((continuous_fst.dist continuous_snd).rpow_const (fun _ => Or.inr ha.le)) obtain ⟨A,hAc,hArep⟩ := ContinuousEnvelope.exists_continuous_extension hG H (by intro c e he have hz : U*dist c c^a if hz:z∈Ω then A ⟨z,hz⟩ else 0 have hAbar (z : Ω) : Abar z=A z := by simp only [Abar,dite_eq_left z.prop] have hAcbar : ContinuousOn Abar Ω := by rw [continuousOn_iff_continuous_domRestrict] change Continuous (fun z:Ω => Abar z) simpa only [hAbar] using hAc have haA : ∀ᵐ z ∂μ,z∈Ω → HasFDerivAt g (Abar z) z := by filter_upwards [hae] with z hz hzΩ rw [show Abar z=A ⟨z,hzΩ⟩ from hAbar ⟨z,hzΩ⟩,hArep ⟨z,hzΩ⟩ (hz hzΩ)] exact (hz hzΩ).hasFDerivAt have hd (z : E) (hz : z∈Ω) := AEDerivativeLocal.hasFDerivAt_of_ae μ hg hΩ hAcbar haA hz have hc : ContDiffOn ℝ 1 g Ω := by change ContDiffOn ℝ (0+1) g Ω apply (contDiffOn_succ_iff_fderiv_of_isOpen hΩ).mpr refine ⟨fun z hz => (hd z hz).differentiableAt.differentiableWithinAt,(by simp),?_⟩ rw [contDiffOn_zero] exact hAcbar.congr (fun z hz => (hd z hz).fderiv) refine ⟨hc,?_⟩ intro x hx y hy exact derivative_holder hΩ hU hQ hx hy (hd x hx).differentiableAt (hd y hy).differentiableAt end QuotientBootstrap namespace FiniteDifference open Set Metric MeasureTheory open scoped ContDiff NNReal variable {E : Type*} {F : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] [NormedAddCommGroup F] [NormedSpace ℝ F] [FiniteDimensional ℝ F] theorem C1_of_controlled_normalized (μ : Measure E) [μ.IsAddHaarMeasure] {g : E → F} {c : E} {r a : ℝ} (_hr : 0 normalized g v.val)) : ContDiffOn ℝ 1 g (ball c r) ∧ ∃ U:ℝ,0≤U ∧ ∀ x∈ball c r,∀ y∈ball c r, dist (fderiv ℝ g x) (fderiv ℝ g y)≤U*dist x y^a := by obtain ⟨B,U,hB,hU,hb,hc⟩ := hQ have hsmall {x y:E} (hx:x∈ball c r) (hy:y∈ball c r) : ‖y-x‖<2*r := by rw [← dist_eq_norm] exact (dist_triangle y c x).trans_lt (by rw [dist_comm c x]; linarith [mem_ball.mp hy,mem_ball.mp hx]) have hnorm (v x:E) : g (x+v)-g x=‖v‖ • normalized g v x := by by_cases hv:v=0 · simp [hv,normalized,increment] · simp only [normalized,increment,smul_smul,mul_inv_cancel₀ (norm_ne_zero_iff.mpr hv),one_smul] have hLip : LipschitzOnWith ⟨B,hB⟩ g (ball c r) := by apply LipschitzOnWith.of_dist_le_mul intro x hx y hy have hh := hb ⟨y-x,hsmall hx hy⟩ x hx have he : x+(y-x)=y := by abel change dist (g x) (g y)≤B*dist x y rw [dist_comm (g x)] conv_lhs => rw [dist_eq_norm] calc ‖g y-g x‖=‖y-x‖*‖normalized g (y-x) x‖ := by conv_lhs => rw [← he,hnorm] rw [norm_smul,Real.norm_eq_abs,abs_norm] _ ≤ ‖y-x‖*B := mul_le_mul_of_nonneg_left hh (norm_nonneg _) _ = B*dist x y := by rw [← dist_eq_norm,dist_comm y x,mul_comm] have hinc : ∀ x∈ball c r,∀ y∈ball c r,∀ v:E,x+v∈ball c r → y+v∈ball c r → ‖g (x+v)-g x-(g (y+v)-g y)‖≤U*‖v‖*dist x y^a := by intro x hx y hy v hxv _ have hv : ‖v‖<2*r := by simpa only [add_sub_cancel_left] using hsmall hx hxv have hh := hc ⟨v,hv⟩ x hx y hy rw [hnorm v x,hnorm v y,← smul_sub,norm_smul,Real.norm_eq_abs,abs_norm] exact (mul_le_mul_of_nonneg_left (by simpa only [dist_eq_norm] using hh) (norm_nonneg v)).trans_eq (by rw [← dist_eq_norm]; ring) obtain ⟨h1,h2⟩ := QuotientBootstrap.contDiffOn_one_of_quotients μ hLip isOpen_ball ha hU hinc exact ⟨h1,U,hU,h2⟩ end FiniteDifference namespace MomentQuotient open Set Metric InnerProductSpace open scoped ContDiff InnerProductSpace Matrix.Norms.Elementwise variable {E : Type*} {ι : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] [Fintype ι] [DecidableEq ι] local instance : NormedAddCommGroup (E →L[ℝ] ℝ) := ContinuousLinearMap.toNormedAddCommGroup local instance : NormedSpace ℝ (E →L[ℝ] ℝ) := ContinuousLinearMap.toNormedSpace local instance : NormedAddCommGroup (E →L[ℝ] E →L[ℝ] ℝ) := ContinuousLinearMap.toNormedAddCommGroup local instance : NormedSpace ℝ (E →L[ℝ] E →L[ℝ] ℝ) := ContinuousLinearMap.toNormedSpace local instance : TopologicalSpace (Matrix ι ι ℝ) := (inferInstance : PseudoMetricSpace (Matrix ι ι ℝ)).toUniformSpace.toTopologicalSpace theorem C3_local (μ:MeasureTheory.Measure E) [μ.IsAddHaarMeasure] (b:OrthonormalBasis ι ℝ E) {u V:E→ℝ} (hu:ContDiff ℝ 2 u) (hV:ContDiff ℝ 2 V) {d:ℝ} (heq:∀x,Real.log (matrixHessian b u x).det=V (gradient u x)+d-u x) (hp:∀x,(matrixHessian b u x).PosDef) {a C R:ℝ} {c:E} (ha:0 r • w.val have hv (w:{v:E // ‖v‖<1}) : ‖v w‖ HessianInterpolation.hessian u) := by have hhc:Continuous (HessianInterpolation.hessian u) := ((contDiff_one_iff_fderiv.mp (hu.fderiv_right (by norm_num : (1:ℕ∞ω)+1≤2))).2) obtain ⟨B,hB⟩ := (isCompact_closedBall c (R/2)).exists_bound_of_continuousOn hhc.continuousOn let D := ‖(toDual ℝ E).toContinuousLinearEquiv.toContinuousLinearMap‖* ‖(HessianTrace.fromMatrix b).toContinuousLinearMap‖ have hD:0≤D := by dsimp only [D]; positivity refine ⟨max 0 B,D*C,le_max_left _ _,mul_nonneg hD hC,?_,?_⟩ · exact fun _ x hx => (hB x hx).trans (le_max_right _ _) · intro _ x hx y hy have hxR:x∈ball c R := mem_ball.mpr (by linarith [mem_closedBall.mp hx]) have hyR:y∈ball c R := mem_ball.mpr (by linarith [mem_closedBall.mp hy]) exact (HessianTrace.holder_transfer hu b x y).trans ((mul_le_mul_of_nonneg_left (hhold x hxR y hyR) hD).trans_eq (by dsimp only [D]; ring)) obtain ⟨hQ,hDQ,hPQ,hHQ⟩ := data b hu hV heq hp ha ha1 (isCompact_closedBall c (R/2)) (convex_closedBall c (R/2)) hKr hHK v hshift have hAr:HolderControl.Controlled a (ball c r) (fun w => coefficient b u (v w)) := hA.reindex (fun w => ⟨v w,hv w⟩) have hQr := hs c r hr (fun w => quotient u (v w)) (fun w => coefficient b u (v w)) (fun w => quotient_contDiff hu (v w)) (fun w x hx => hclose ⟨v w,hv w⟩ x hx) hAr hQ hDQ hPQ hHQ have hsmall (w:{w:E // ‖w‖<2*(r/4)}) : ‖r⁻¹ • w.val‖<1 := by rw [norm_smul,Real.norm_eq_abs,abs_of_pos (inv_pos.mpr hr)] apply (inv_mul_lt_iff₀ hr).2 nlinarith [w.prop] have hnorm:HolderControl.Controlled a (ball c (r/4)) (fun w:{w:E // ‖w‖<2*(r/4)} => FiniteDifference.normalized (HessianInterpolation.hessian u) w.val) := by have hh := hQr.reindex (fun w:{w:E // ‖w‖<2*(r/4)} => ⟨r⁻¹ • w.val,hsmall w⟩) apply hh.congr intro w x _ rw [hessian_quotient hu] simp only [v,smul_smul,mul_inv_cancel₀ hr.ne',one_smul] rfl obtain ⟨hC1,U,hU,hUH⟩ := FiniteDifference.C1_of_controlled_normalized μ (by positivity : 0.differentiableOn,by simp,hC1⟩ have hC3:ContDiffOn ℝ 3 u (ball c (r/4)) := by rw [show (3:ℕ∞ω)=2+1 from by norm_num,contDiffOn_succ_iff_fderiv_of_isOpen isOpen_ball] exact ⟨(hu.differentiable (by norm_num : (2:ℕ∞ω)≠0)).differentiableOn,by simp,hC2⟩ exact ⟨r/4,by positivity,hC3,U,hU,hUH⟩ end MomentQuotient namespace CoefficientTrace open scoped InnerProductSpace variable {E : Type*} {ι : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [Fintype ι] local instance : NormedAddCommGroup (E →L[ℝ] ℝ) := ContinuousLinearMap.toNormedAddCommGroup local instance : NormedSpace ℝ (E →L[ℝ] ℝ) := ContinuousLinearMap.toNormedSpace local instance : NormedAddCommGroup (E →L[ℝ] E →L[ℝ] ℝ) := ContinuousLinearMap.toNormedAddCommGroup local instance : NormedSpace ℝ (E →L[ℝ] E →L[ℝ] ℝ) := ContinuousLinearMap.toNormedSpace def bilinear (b:OrthonormalBasis ι ℝ E) : (E→L[ℝ]E→L[ℝ]ℝ) →L[ℝ] (E→L[ℝ]E) →L[ℝ] ℝ := (LinearMap.mk₂ ℝ (fun (H:E→L[ℝ]E→L[ℝ]ℝ) (A:E→L[ℝ]E) => trace b H A) (by intros; simp only [trace,add_apply,Finset.sum_add_distrib]) (by intros; simp only [trace,_root_.smul_apply,smul_eq_mul,Finset.mul_sum]) (by intros; simp only [trace,add_apply,map_add,Finset.sum_add_distrib]) (by intros; simp only [trace,_root_.smul_apply,map_smul,smul_eq_mul,Finset.mul_sum])).mkContinuous₂ (Fintype.card ι) (norm_bound b) lemma bilinear_apply (b:OrthonormalBasis ι ℝ E) (H:E→L[ℝ]E→L[ℝ]ℝ) (A:E→L[ℝ]E) : bilinear b H A=trace b H A := rfl end CoefficientTrace namespace LinearSchauder open Set Metric InnerProductSpace MomentQuotient open scoped ContDiff InnerProductSpace variable {E : Type*} {ι : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] [Fintype ι] [DecidableEq ι] local instance : NormedAddCommGroup (E →L[ℝ] ℝ) := ContinuousLinearMap.toNormedAddCommGroup local instance : NormedSpace ℝ (E →L[ℝ] ℝ) := ContinuousLinearMap.toNormedSpace local instance : NormedAddCommGroup (E →L[ℝ] E →L[ℝ] ℝ) := ContinuousLinearMap.toNormedAddCommGroup local instance : NormedSpace ℝ (E →L[ℝ] E →L[ℝ] ℝ) := ContinuousLinearMap.toNormedSpace omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] [DecidableEq ι] in lemma quotient_equation (b:OrthonormalBasis ι ℝ E) {u S:E→ℝ} {A:E→E→L[ℝ]E} (hu:ContDiff ℝ 2 u) (heq:∀x,CoefficientTrace.trace b (HessianInterpolation.hessian u x) (A x)=S x) (v x:E) : CoefficientTrace.trace b (HessianInterpolation.hessian (quotient u v) x) (A x)= FiniteDifference.normalized S v x-CoefficientTrace.trace b (HessianInterpolation.hessian u (x+v)) (FiniteDifference.normalized A v x) := by rw [hessian_quotient hu] change CoefficientTrace.bilinear b (‖v‖⁻¹ • (_-_)) (A x)=_ rw [map_smul,map_sub] change ‖v‖⁻¹*(CoefficientTrace.trace b (HessianInterpolation.hessian u (x+v)) (A x)- CoefficientTrace.trace b (HessianInterpolation.hessian u x) (A x))=_ rw [heq] unfold FiniteDifference.normalized FiniteDifference.increment change _=‖v‖⁻¹*(S (x+v)-S x)-CoefficientTrace.bilinear b (HessianInterpolation.hessian u (x+v)) (‖v‖⁻¹ • (A (x+v)-A x)) rw [map_smul,map_sub] change _=‖v‖⁻¹*(S (x+v)-S x)-‖v‖⁻¹* (CoefficientTrace.trace b (HessianInterpolation.hessian u (x+v)) (A (x+v))- CoefficientTrace.trace b (HessianInterpolation.hessian u (x+v)) (A x)) rw [heq] ring omit [DecidableEq ι] in theorem C3_local (μ:MeasureTheory.Measure E) [μ.IsAddHaarMeasure] (b:OrthonormalBasis ι ℝ E) {u S:E→ℝ} {A:E→E→L[ℝ]E} (hu:ContDiff ℝ 2 u) (hA:ContDiff ℝ 1 A) (hS:ContDiff ℝ 1 S) (heq:∀x,CoefficientTrace.trace b (HessianInterpolation.hessian u x) (A x)=S x) {c:E} (hp:∀x:E,x≠0 → 0<⟪x,A c x⟫_ℝ) {R a:ℝ} (hR:0 HessianInterpolation.hessian u)) (hDA:HolderControl.Controlled a (closedBall c R) (fun _:Unit => fderiv ℝ A)) (hDS:HolderControl.Controlled a (closedBall c R) (fun _:Unit => fderiv ℝ S)) : ∃r:ℝ,0r • w.val have hv (w:{v:E // ‖v‖<1}) : ‖v w‖ HessianInterpolation.hessian u (x+v w)) := by obtain ⟨B,C,hB,hC,hb,hc⟩ := hH refine ⟨B,C,hB,hC,fun w x hx => hb () (x+v w) (hshift w x hx),?_⟩ intro w x hx y hy simpa only [dist_add_right] using hc () (x+v w) (hshift w x hx) (y+v w) (hshift w y hy) have hP := hSQ.sub (hHshift.bilinear (CoefficientTrace.bilinear b) hAQ) have hAc := HolderControl.compact_convex_C1 (J:=Unit) ha.le ha1.le (isCompact_closedBall c R) (convex_closedBall c R) hA have hQr := hs c r hr (fun w => quotient u (v w)) (fun _ x => A x) (fun w => quotient_contDiff hu (v w)) (fun _ x hx => by rw [← dist_eq_norm,dist_comm] exact (hnear (by linarith [mem_ball.mp hx])).le) (hAc.mono hKr).of_single (hQ.congr (fun _ _ _ => rfl)) (hDQ.congr (fun w x _ => (FiniteDifference.fderiv_normalized (hu.of_le (by norm_num : (1:ℕ∞ω)≤2)) (v w) x).symm)) (hP.congr (fun w x _ => (quotient_equation b hu heq (v w) x).symm)) (fun w => normalized_hessian_finite hu hH hKr (v w) (hshift w)) have hsmall (w:{w:E // ‖w‖<2*(r/4)}) : ‖r⁻¹ • w.val‖<1 := by rw [norm_smul,Real.norm_eq_abs,abs_of_pos (inv_pos.mpr hr)] apply (inv_mul_lt_iff₀ hr).2 nlinarith [w.prop] have hnorm:HolderControl.Controlled a (ball c (r/4)) (fun w:{w:E // ‖w‖<2*(r/4)} => FiniteDifference.normalized (HessianInterpolation.hessian u) w.val) := by have hh := hQr.reindex (fun w:{w:E // ‖w‖<2*(r/4)} => ⟨r⁻¹ • w.val,hsmall w⟩) apply hh.congr intro w x _ rw [hessian_quotient hu] simp only [v,smul_smul,mul_inv_cancel₀ hr.ne',one_smul] rfl obtain ⟨hC1,U,hU,hUH⟩ := FiniteDifference.C1_of_controlled_normalized μ (by positivity : 0.differentiableOn,by simp,hC1⟩ have hC3:ContDiffOn ℝ 3 u (ball c (r/4)) := by rw [show (3:ℕ∞ω)=2+1 from by norm_num,contDiffOn_succ_iff_fderiv_of_isOpen isOpen_ball] exact ⟨(hu.differentiable (by norm_num : (2:ℕ∞ω)≠0)).differentiableOn,by simp,hC2⟩ exact ⟨r/4,by positivity,hC3,U,hU,hUH⟩ end LinearSchauder end noncomputable section namespace HolderJets open Set Metric open scoped ContDiff universe u variable {E F G H : Type u} [NormedAddCommGroup E] [NormedSpace ℝ E] [FiniteDimensional ℝ E] [NormedAddCommGroup F] [NormedSpace ℝ F] [NormedAddCommGroup G] [NormedSpace ℝ G] [NormedAddCommGroup H] [NormedSpace ℝ H] def Local (f:E→F) : Prop := ∀c:E,∃a r:ℝ,0 f) lemma Local.of_C1 {f:E→F} (hf:ContDiff ℝ 1 f) : Local f := by intro c exact ⟨1/2,1,by norm_num,by norm_num,by norm_num, HolderControl.compact_convex_C1 (by norm_num) (by norm_num) (isCompact_closedBall c 1) (convex_closedBall c 1) hf⟩ omit [NormedSpace ℝ E] [FiniteDimensional ℝ E] [NormedSpace ℝ F] in lemma restrict_exponent {f:E→F} {a d r R:ℝ} {c:E} (hd:0≤d) (hda:d≤a) (hr:r≤R) (hr1:r≤1/2) (hf:HolderControl.Controlled a (closedBall c R) (fun _:Unit => f)) : HolderControl.Controlled d (closedBall c r) (fun _:Unit => f) := by obtain ⟨B,C,hB,hC,hb,hc⟩ := hf have sub:closedBall c r⊆closedBall c R := closedBall_subset_closedBall hr refine ⟨B,C,hB,hC,fun j x hx=>hb j x (sub hx),?_⟩ intro j x hx y hy apply (hc j x (sub hx) y (sub hy)).trans apply mul_le_mul_of_nonneg_left _ hC apply Real.rpow_le_rpow_of_exponent_ge' dist_nonneg _ hd hda have ht := dist_triangle x c y rw [dist_comm c y] at ht linarith [mem_closedBall.mp hx,mem_closedBall.mp hy] omit [NormedSpace ℝ E] [FiniteDimensional ℝ E] [NormedSpace ℝ F] [NormedSpace ℝ G] in lemma Local.common {f:E→F} {g:E→G} (hf:Local f) (hg:Local g) (c:E) : ∃a r:ℝ,0f) ∧ HolderControl.Controlled a (closedBall c r) (fun _:Unit=>g) := by obtain ⟨a,R,ha,ha1,hR,hf⟩ := hf c obtain ⟨d,S,hd,_,hS,hg⟩ := hg c refine ⟨min a d,min (min R S) (1/2),lt_min ha hd, (min_le_left _ _).trans_lt ha1,lt_min (lt_min hR hS) (by norm_num),?_,?_⟩ · exact restrict_exponent (le_of_lt (lt_min ha hd)) (min_le_left _ _) ((min_le_left _ _).trans (min_le_left _ _)) (min_le_right _ _) hf · exact restrict_exponent (le_of_lt (lt_min ha hd)) (min_le_right _ _) ((min_le_left _ _).trans (min_le_right _ _)) (min_le_right _ _) hg omit [NormedSpace ℝ E] [FiniteDimensional ℝ E] in lemma Local.linear (T:F→L[ℝ]G) {f:E→F} (hf:Local f) : Local (fun x=>T (f x)) := by intro c obtain ⟨a,r,ha,ha1,hr,hf⟩ := hf c exact ⟨a,r,ha,ha1,hr,hf.linear T⟩ omit [NormedSpace ℝ E] [FiniteDimensional ℝ E] [NormedSpace ℝ F] in lemma Local.add {f g:E→F} (hf:Local f) (hg:Local g) : Local (fun x=>f x+g x) := by intro c obtain ⟨a,r,ha,ha1,hr,hf,hg⟩ := hf.common hg c exact ⟨a,r,ha,ha1,hr,hf.add hg⟩ omit [NormedSpace ℝ E] [FiniteDimensional ℝ E] in lemma Local.bilinear (T:F→L[ℝ]G→L[ℝ]H) {f:E→F} {g:E→G} (hf:Local f) (hg:Local g) : Local (fun x=>T (f x) (g x)) := by intro c obtain ⟨a,r,ha,ha1,hr,hf,hg⟩ := hf.common hg c exact ⟨a,r,ha,ha1,hr,hf.bilinear T hg⟩ omit [NormedSpace ℝ E] [FiniteDimensional ℝ E] in lemma Local.comp_C1 {f:E→F} {g:F→G} (hc:Continuous f) (hf:Local f) (hg:∀x,ContDiffAt ℝ 1 g (f x)) : Local (g∘f) := by intro c obtain ⟨a,R,ha,ha1,hR,B,C,hB,hC,hb,hholder⟩ := hf c obtain ⟨K,t,ht,hK⟩ := (hg c).exists_lipschitzOnWith obtain ⟨r,hr,hsub⟩ := Metric.mem_nhds_iff.mp (hc.continuousAt.preimage_mem_nhds ht) let s:=min R r/2 have hs:0 Continuous f ∧ Local f | n+1 => Differentiable ℝ f ∧ Regular n (fderiv ℝ f) termination_by structural n omit [FiniteDimensional ℝ E] in lemma Regular.contDiff {n:ℕ} {f:E→F} (hf:Regular n f) : ContDiff ℝ n f := by induction n generalizing F with | zero => exact contDiff_zero.mpr hf.1 | succ n ih => rw [Nat.cast_add,Nat.cast_one,contDiff_succ_iff_fderiv] exact ⟨hf.1,by simp,ih hf.2⟩ omit [FiniteDimensional ℝ E] in lemma Regular.continuous {n:ℕ} {f:E→F} (hf:Regular n f) : Continuous f := hf.contDiff.continuous lemma Regular.local {n:ℕ} {f:E→F} (hf:Regular n f) : Local f := by cases n with | zero => exact hf.2 | succ n => exact Local.of_C1 (hf.contDiff.of_le (by exact_mod_cast Nat.succ_pos n)) lemma Regular.pred {n:ℕ} {f:E→F} (hf:Regular (n+1) f) : Regular n f := by induction n generalizing F with | zero => exact ⟨hf.continuous,hf.local⟩ | succ n ih => exact ⟨hf.1,ih hf.2⟩ omit [FiniteDimensional ℝ E] in lemma Regular.linear (T:F→L[ℝ]G) {n:ℕ} {f:E→F} (hf:Regular n f) : Regular n (fun x=>T (f x)) := by induction n generalizing F G with | zero => exact ⟨T.continuous.comp hf.1,hf.2.linear T⟩ | succ n ih => have he: fderiv ℝ (fun x=>T (f x))=fun x=>T.comp (fderiv ℝ f x) := by funext x; exact (T.hasFDerivAt.comp x (hf.1 x).hasFDerivAt).fderiv exact ⟨T.differentiable.comp hf.1,he ▸ ih (ContinuousLinearMap.compL ℝ E F G T) hf.2⟩ omit [FiniteDimensional ℝ E] in lemma Regular.add {n:ℕ} {f g:E→F} (hf:Regular n f) (hg:Regular n g) : Regular n (fun x=>f x+g x) := by induction n generalizing F with | zero => exact ⟨hf.1.add hg.1,hf.2.add hg.2⟩ | succ n ih => have he:fderiv ℝ (fun x=>f x+g x)=fun x=>fderiv ℝ f x+fderiv ℝ g x := by funext x; exact ((hf.1 x).hasFDerivAt.add (hg.1 x).hasFDerivAt).fderiv exact ⟨hf.1.add hg.1,he ▸ ih hf.2 hg.2⟩ lemma Regular.bilinear (T:F→L[ℝ]G→L[ℝ]H) {n:ℕ} {f:E→F} {g:E→G} (hf:Regular n f) (hg:Regular n g) : Regular n (fun x=>T (f x) (g x)) := by induction n generalizing F G H with | zero => exact ⟨(T.continuous.comp hf.1).clm_apply hg.1,hf.2.bilinear T hg.2⟩ | succ n ih => have he:fderiv ℝ (fun x=>T (f x) (g x))=fun x=> T.precompR E (f x) (fderiv ℝ g x)+T.precompL E (fderiv ℝ f x) (g x) := by funext x; exact T.fderiv_of_bilinear (hf.1 x) (hg.1 x) refine ⟨fun x=>(T.hasFDerivAt_of_bilinear (hf.1 x).hasFDerivAt (hg.1 x).hasFDerivAt).differentiableAt,?_⟩ rw [he] exact (ih (T.precompR E) hf.pred hg.2).add (ih (T.precompL E) hf.2 hg.pred) lemma Regular.comp_smooth {n:ℕ} {f:E→F} {g:F→G} (hf:Regular n f) (hg:∀x,ContDiffAt ℝ ∞ g (f x)) : Regular n (g∘f) := by induction n generalizing F G with | zero => exact ⟨continuous_iff_continuousAt.mpr (fun x=>(hg x).continuousAt.comp hf.1.continuousAt), hf.2.comp_C1 hf.1 (fun x=>(hg x).of_le (by simp))⟩ | succ n ih => have hdg (x:E) := (hg x).differentiableAt (by simp : (∞:ℕ∞ω)≠0) have he:fderiv ℝ (g∘f)=fun x=>(fderiv ℝ g (f x)).comp (fderiv ℝ f x) := by funext x; exact ((hdg x).hasFDerivAt.comp x (hf.1 x).hasFDerivAt).fderiv refine ⟨fun x=>(hdg x).comp x (hf.1 x),?_⟩ rw [he] exact (ih hf.pred (fun x=>(hg x).fderiv_right (m:=∞) (by simp))).bilinear (ContinuousLinearMap.compL ℝ E F G) hf.2 lemma Regular.of_Cnext {n:ℕ} {f:E→F} (hf:ContDiff ℝ (n+1) f) : Regular n f := by induction n generalizing F with | zero => exact ⟨hf.continuous,Local.of_C1 (by simpa using hf)⟩ | succ n ih => exact ⟨hf.differentiable (by simp),ih (hf.fderiv_right (m:=n+1) (by simp [Nat.cast_add]))⟩ lemma Regular.of_smooth {n:ℕ} {f:E→F} (hf:ContDiff ℝ ∞ f) : Regular n f := Regular.of_Cnext (n:=n) (hf.of_le (by exact_mod_cast (le_top : (n+1:ℕ∞)≤⊤))) lemma Regular.mono {n m:ℕ} {f:E→F} (hf:Regular n f) (hm:m≤n) : Regular m f := by induction n generalizing F m with | zero => have he:m=0:=by omega subst m exact hf | succ n ih => cases m with | zero => exact ⟨hf.continuous,hf.local⟩ | succ m => exact ⟨hf.1,ih hf.2 (by omega)⟩ omit [FiniteDimensional ℝ E] in lemma Regular.prod {n:ℕ} {f:E→F} {g:E→G} (hf:Regular n f) (hg:Regular n g) : Regular n (fun x=>(f x,g x)) := by simpa only [ContinuousLinearMap.inl_apply,ContinuousLinearMap.inr_apply,Prod.mk_add_mk, add_zero,zero_add] using (hf.linear (ContinuousLinearMap.inl ℝ F G)).add (hg.linear (ContinuousLinearMap.inr ℝ F G)) lemma Regular.sum {ι:Type*} (s:Finset ι) {n:ℕ} {f:ι→E→F} (hf:∀i∈s,Regular n (f i)) : Regular n (fun x=>∑i∈s,f i x) := by classical induction s using Finset.induction_on with | empty => simpa using (Regular.of_smooth (n:=n) (contDiff_const (c:=(0:F)))) | @insert i s hi ih => simpa only [Finset.sum_insert hi] using (hf i (Finset.mem_insert_self i s)).add (ih (fun j hj=>hf j (Finset.mem_insert_of_mem hj))) lemma Regular.clm_of_basis {ι:Type*} [Fintype ι] (b:Module.Basis ι ℝ F) [FiniteDimensional ℝ F] {n:ℕ} {f:E→F→L[ℝ]G} (hf:∀i,Regular n (fun x=>f x (b i))) : Regular n f := by let T:ι→G→L[ℝ]F→L[ℝ]G := fun i=>ContinuousLinearMap.smulRightL ℝ F G (b.coord i).toContinuousLinearMap have hs:Regular n (fun x=>∑i,T i (f x (b i))) := Regular.sum Finset.univ (fun i _=>(hf i).linear (T i)) have he:(fun x=>∑i,T i (f x (b i)))=f := by funext x ext v simp only [sum_apply] change (∑i,(b.repr v i) • f x (b i))=f x v simpa only [map_sum,map_smul] using congrArg (f x) (b.sum_repr v) rwa [he] at hs end HolderJets namespace HessianDirectional open scoped ContDiff variable {E : Type*} {F : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [NormedAddCommGroup F] [NormedSpace ℝ F] local notation "Hes" => HessianInterpolation.hessian lemma derivative_direction {u:E→F} (hu:ContDiff ℝ 3 u) (v x:E) : Hes (fun x=>fderiv ℝ u x v) x = (fderiv ℝ (Hes u) x v) := by have hD:ContDiff ℝ 2 (fderiv ℝ u) := hu.fderiv_right (by norm_num) have hH:ContDiff ℝ 1 (Hes u) := hD.fderiv_right (by norm_num) have hd:=hD.differentiable (by norm_num : (2:ℕ∞ω)≠0) have hh:=hH.differentiable one_ne_zero let T:(E→L[ℝ]F)→L[ℝ]F:=ContinuousLinearMap.apply ℝ F v have hfirst : fderiv ℝ (fun x=>fderiv ℝ u x v)=fun x=>T.comp (Hes u x) := by funext x exact (T.hasFDerivAt.comp x (hd x).hasFDerivAt).fderiv have hsecond : Hes (fun x=>fderiv ℝ u x v) x= (ContinuousLinearMap.compL ℝ E (E→L[ℝ]F) F T).comp (fderiv ℝ (Hes u) x) := by unfold HessianInterpolation.hessian rw [hfirst] exact ((ContinuousLinearMap.compL ℝ E (E→L[ℝ]F) F T).hasFDerivAt.comp x (hh x).hasFDerivAt).fderiv have hs (y z:E) : fderiv ℝ (Hes u) x y z v=fderiv ℝ (Hes u) x y v z := by have he:(fun t=>Hes u t z v)=(fun t=>Hes u t v z) := by funext t exact hu.contDiffAt.isSymmSndFDerivAt (by norm_num) z v have hze:=congrArg (fun f:E→F=>fderiv ℝ f x y) he simpa only [fderiv_clm_apply (hh x) (differentiableAt_const _), fderiv_clm_apply ((hh x).clm_apply (differentiableAt_const _)) (differentiableAt_const _), fderiv_const_apply,ContinuousLinearMap.comp_zero,zero_add, ContinuousLinearMap.flip_apply] using hze ext y z rw [hsecond] change fderiv ℝ (Hes u) x y z v=fderiv ℝ (Hes u) x v y z rw [hs] exact congrArg (fun T:E→L[ℝ]F=>T z) (hD.contDiffAt.isSymmSndFDerivAt (by norm_num) y v) end HessianDirectional namespace LinearSchauder open Set Metric HolderJets open scoped ContDiff InnerProductSpace variable {E:Type} {ι:Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] [Fintype ι] local instance : NormedAddCommGroup (E →L[ℝ] ℝ) := ContinuousLinearMap.toNormedAddCommGroup local instance : NormedSpace ℝ (E →L[ℝ] ℝ) := ContinuousLinearMap.toNormedSpace local instance : NormedAddCommGroup (E →L[ℝ] E →L[ℝ] ℝ) := ContinuousLinearMap.toNormedAddCommGroup local instance : NormedSpace ℝ (E →L[ℝ] E →L[ℝ] ℝ) := ContinuousLinearMap.toNormedSpace local instance : NormedAddCommGroup (E →L[ℝ] E) := ContinuousLinearMap.toNormedAddCommGroup local instance : NormedSpace ℝ (E →L[ℝ] E) := ContinuousLinearMap.toNormedSpace local instance : NormedAddCommGroup (E →L[ℝ] E →L[ℝ] E) := ContinuousLinearMap.toNormedAddCommGroup local instance : NormedSpace ℝ (E →L[ℝ] E →L[ℝ] E) := ContinuousLinearMap.toNormedSpace local notation "Hes" => HessianInterpolation.hessian lemma regular_three (μ:MeasureTheory.Measure E) [μ.IsAddHaarMeasure] (b:OrthonormalBasis ι ℝ E) {u S:E→ℝ} {A:E→E→L[ℝ]E} (hu:Regular 2 u) (hA:Regular 1 A) (hS:Regular 1 S) (heq:∀x,CoefficientTrace.trace b (Hes u x) (A x)=S x) (hp:∀c x:E,x≠0 → 0<⟪x,A c x⟫_ℝ) : Regular 3 u := by have hH:Local (Hes u) := hu.2.2.2 have hDA:Regular 0 (fderiv ℝ A) := hA.2 have hDS:Regular 0 (fderiv ℝ S) := hS.2 have hdata:Local (fun x=>(fderiv ℝ A x,fderiv ℝ S x)) := (hDA.prod hDS).local have hgain (c:E) : ∃a r:ℝ,0by obtain ⟨a,r,ha,ha1,hr,hc,hhold⟩ := hgain c exact hc.contDiffAt (ball_mem_nhds c hr)) have hHC:ContDiff ℝ 1 (Hes u) := (hu3.fderiv_right (m:=2) (by norm_num)).fderiv_right (by norm_num) have hDHC:Continuous (fderiv ℝ (Hes u)) := (contDiff_one_iff_fderiv.mp hHC).2 refine ⟨hu.1,hu.2.1,hHC.differentiable one_ne_zero,hDHC,?_⟩ intro c obtain ⟨a,r,ha,ha1,hr,_,C,hC,hhold⟩ := hgain c obtain ⟨B,hB⟩ := (isCompact_closedBall c (r/2)).exists_bound_of_continuousOn hDHC.continuousOn have hsub:closedBall c (r/2)⊆ball c r := closedBall_subset_ball (by linarith) exact ⟨a,r/2,ha,ha1,by positivity,max 0 B,C,le_max_left _ _,hC, fun _ x hx=>(hB x hx).trans (le_max_right _ _),fun _ x hx y hy=>hhold x (hsub hx) y (hsub hy)⟩ omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in lemma differentiated_equation (b:OrthonormalBasis ι ℝ E) {u S:E→ℝ} {A:E→E→L[ℝ]E} (hu:ContDiff ℝ 3 u) (hA:Differentiable ℝ A) (_hS:Differentiable ℝ S) (heq:∀x,CoefficientTrace.trace b (Hes u x) (A x)=S x) (v x:E) : CoefficientTrace.trace b (Hes (fun z=>fderiv ℝ u z v) x) (A x)= fderiv ℝ S x v-CoefficientTrace.trace b (Hes u x) (fderiv ℝ A x v) := by have hH:ContDiff ℝ 1 (Hes u) := (hu.fderiv_right (m:=2) (by norm_num)).fderiv_right (by norm_num) have he:(fun x=>CoefficientTrace.bilinear b (Hes u x) (A x))=S := funext heq have hd:HasFDerivAt S ((CoefficientTrace.bilinear b).precompR E (Hes u x) (fderiv ℝ A x)+ (CoefficientTrace.bilinear b).precompL E (fderiv ℝ (Hes u) x) (A x)) x := by rw [←he] exact (CoefficientTrace.bilinear b).hasFDerivAt_of_bilinear (hH.differentiable one_ne_zero x).hasFDerivAt (hA x).hasFDerivAt have hv:=congrArg (fun T:E→L[ℝ]ℝ=>T v) hd.fderiv rw [HessianDirectional.derivative_direction hu v x] change CoefficientTrace.bilinear b (fderiv ℝ (Hes u) x v) (A x)= fderiv ℝ S x v-CoefficientTrace.bilinear b (Hes u x) (fderiv ℝ A x v) change fderiv ℝ S x v=CoefficientTrace.bilinear b (Hes u x) (fderiv ℝ A x v)+ CoefficientTrace.bilinear b (fderiv ℝ (Hes u) x v) (A x) at hv linarith theorem higher (μ:MeasureTheory.Measure E) [μ.IsAddHaarMeasure] (b:OrthonormalBasis ι ℝ E) (n:ℕ) {u S:E→ℝ} {A:E→E→L[ℝ]E} (hu:Regular 2 u) (hA:Regular (n+1) A) (hS:Regular (n+1) S) (heq:∀x,CoefficientTrace.trace b (Hes u x) (A x)=S x) (hp:∀c x:E,x≠0 → 0<⟪x,A c x⟫_ℝ) : Regular (n+3) u := by induction n generalizing u S with | zero => exact regular_three μ b hu hA hS heq hp | succ n ih => have hug:Regular (n+3) u := ih hu hA.pred hS.pred heq have hu3:ContDiff ℝ 3 u := (hug.mono (m:=3) (by omega)).contDiff have hDu:Regular (n+2) (fderiv ℝ u) := hug.2 have hHu:Regular (n+1) (Hes u) := hDu.2 have hdirs (v:E) : Regular (n+3) (fun x=>fderiv ℝ u x v) := by let Sv:E→ℝ:=fun x=>fderiv ℝ S x v- CoefficientTrace.trace b (Hes u x) (fderiv ℝ A x v) have hSv:Regular (n+1) Sv := by have h₁:=hS.2.linear (ContinuousLinearMap.apply ℝ ℝ v) have h₂:=hHu.bilinear (CoefficientTrace.bilinear b) (hA.2.linear (ContinuousLinearMap.apply ℝ (E→L[ℝ]E) v)) exact h₁.add (h₂.linear (-ContinuousLinearMap.id ℝ ℝ)) apply ih ((hDu.mono (m:=2) (by omega)).linear (ContinuousLinearMap.apply ℝ ℝ v)) hA.pred hSv exact differentiated_equation b hu3 (hA.mono (by omega : 1≤n+1+1)).1 (hS.mono (by omega : 1≤n+1+1)).1 heq v exact ⟨hug.1,Regular.clm_of_basis b.toBasis (fun i=>hdirs (b i))⟩ end LinearSchauder namespace MomentSchauder open Set Metric Matrix InnerProductSpace HolderJets MomentQuotient open scoped ContDiff InnerProductSpace Matrix.Norms.Elementwise variable {E:Type} {ι:Type} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] [Fintype ι] [DecidableEq ι] local instance : NormedAddCommGroup (E →L[ℝ] ℝ) := ContinuousLinearMap.toNormedAddCommGroup local instance : NormedSpace ℝ (E →L[ℝ] ℝ) := ContinuousLinearMap.toNormedSpace local instance : NormedAddCommGroup (E →L[ℝ] E →L[ℝ] ℝ) := ContinuousLinearMap.toNormedAddCommGroup local instance : NormedSpace ℝ (E →L[ℝ] E →L[ℝ] ℝ) := ContinuousLinearMap.toNormedSpace local instance : TopologicalSpace (Matrix ι ι ℝ) := (inferInstance : PseudoMetricSpace (Matrix ι ι ℝ)).toUniformSpace.toTopologicalSpace local notation "Hes" => HessianInterpolation.hessian local notation "Mat" => Matrix ι ι ℝ def scalarToVector : (E→L[ℝ]E→L[ℝ]ℝ) →L[ℝ] (E→L[ℝ]E) := ContinuousLinearMap.compL ℝ E (E→L[ℝ]ℝ) E (toDual ℝ E).symm.toContinuousLinearEquiv.toContinuousLinearMap def scalarToMatrix (b:OrthonormalBasis ι ℝ E) : (E→L[ℝ]E→L[ℝ]ℝ) →L[ℝ] Mat := (HessianTrace.fromMatrix b).symm.toContinuousLinearMap.comp scalarToVector omit [MeasurableSpace E] [BorelSpace E] in lemma scalarToVector_hessian {u:E→ℝ} (hu:ContDiff ℝ 2 u) (x:E) : scalarToVector (Hes u x)=fderiv ℝ (gradient u) x := by have hDu:=hu.fderiv_right (m:=1) (by norm_num) exact ((toDual ℝ E).symm.toContinuousLinearEquiv.toContinuousLinearMap.hasFDerivAt.comp x (hDu.differentiable one_ne_zero x).hasFDerivAt).fderiv.symm omit [MeasurableSpace E] [BorelSpace E] in lemma scalarToMatrix_hessian (b:OrthonormalBasis ι ℝ E) {u:E→ℝ} (hu:ContDiff ℝ 2 u) (x:E) : scalarToMatrix b (Hes u x)=matrixHessian b u x := by change (HessianTrace.fromMatrix b).symm (scalarToVector (Hes u x))=_ rw [scalarToVector_hessian hu] rfl omit [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in lemma inverse_smooth_at {A:Mat} (ha:A.det≠0) : ContDiffAt ℝ ∞ (fun M:Mat=>M⁻¹) A := by have hadj:ContDiff ℝ ∞ (fun M:Mat=>M.adjugate) := by apply contDiff_pi.mpr intro i apply contDiff_pi.mpr intro j simp_rw [Matrix.adjugate_apply] apply MomentDifferential.smooth_det.comp apply contDiff_pi.mpr intro k apply contDiff_pi.mpr intro l by_cases h:j=k · subst k simp only [Matrix.updateRow_apply,ite_true] exact contDiff_const · simp only [Matrix.updateRow_apply,ite_eq_right (Ne.symm h)] let ev : Mat →L[ℝ] ℝ := ({ toFun := fun M => M k l map_add' := fun M N => rfl map_smul' := fun r M => rfl } : Mat →ₗ[ℝ] ℝ).toContinuousLinearMap exact ev.contDiff have hi := (MomentDifferential.smooth_det.contDiffAt.inv ha).smul hadj.contDiffAt convert hi using 1 ext M i j simp only [Matrix.inv_def,Ring.inverse_eq_inv,Matrix.smul_apply] rfl omit [MeasurableSpace E] [BorelSpace E] in lemma trace_scalar_matrix (b:OrthonormalBasis ι ℝ E) {u:E→ℝ} (hu:ContDiff ℝ 2 u) (A:Mat) (x:E) : CoefficientTrace.trace b (Hes u x) (HessianTrace.fromMatrix b A)= (A*scalarToMatrix b (Hes u x)).trace := by rw [HessianTrace.trace_eq_matrix hu,scalarToMatrix_hessian b hu] congr 2 exact (HessianTrace.fromMatrix b).symm_apply_apply A omit [MeasurableSpace E] [BorelSpace E] in lemma equation (b:OrthonormalBasis ι ℝ E) {u V:E→ℝ} (hu:ContDiff ℝ 3 u) (hV:Differentiable ℝ V) {d:ℝ} (heq:∀x,Real.log (matrixHessian b u x).det=V (gradient u x)+d-u x) (hp:∀x,(matrixHessian b u x).PosDef) (v x:E) : CoefficientTrace.trace b (Hes (fun y=>fderiv ℝ u y v) x) (HessianTrace.fromMatrix b ((matrixHessian b u x)⁻¹))= fderiv ℝ V (gradient u x) (scalarToVector (Hes u x) v)-fderiv ℝ u x v := by have hu2:ContDiff ℝ 2 u:=hu.of_le (by norm_num) have hDu:ContDiff ℝ 2 (fderiv ℝ u):=hu.fderiv_right (by norm_num) have hH:ContDiff ℝ 1 (Hes u):=hDu.fderiv_right (by norm_num) have hM:ContDiff ℝ 1 (matrixHessian b u) := by have he:matrixHessian b u=fun y=>scalarToMatrix b (Hes u y):=funext fun y=>(scalarToMatrix_hessian b hu2 y).symm rw [he] exact (scalarToMatrix b).contDiff.comp hH have hMD:fderiv ℝ (matrixHessian b u) x= (scalarToMatrix b).comp (fderiv ℝ (Hes u) x) := by have he:matrixHessian b u=fun y=>scalarToMatrix b (Hes u y):=funext fun y=>(scalarToMatrix_hessian b hu2 y).symm rw [he] exact ((scalarToMatrix b).hasFDerivAt.comp x (hH.differentiable one_ne_zero x).hasFDerivAt).fderiv have hlog:=((MomentDifferential.detMultilinear.hasFDerivAt (matrixHessian b u x)).comp x (hM.differentiable one_ne_zero x).hasFDerivAt).log (hp x).det_pos.ne' have hg:ContDiff ℝ 2 (gradient u) := (toDual ℝ E).symm.toContinuousLinearEquiv.contDiff.comp hDu have hr:=(((hV (gradient u x)).hasFDerivAt.comp x (hg.differentiable (by norm_num) x).hasFDerivAt).add_const d).sub (hu.differentiable (by norm_num) x).hasFDerivAt have hfun:(fun y=>Real.log (matrixHessian b u y).det)=(fun y=>V (gradient u y)+d-u y):=funext heq change HasFDerivAt (fun y=>Real.log (matrixHessian b u y).det) ((matrixHessian b u x).det⁻¹ • (MomentDifferential.detMultilinear.linearDeriv (matrixHessian b u x)).comp (fderiv ℝ (matrixHessian b u) x)) x at hlog rw [hfun] at hlog have hd:=congrArg (fun T:E→L[ℝ]ℝ=>T v) (hlog.unique hr) have hmat: (((matrixHessian b u x)⁻¹)*scalarToMatrix b (fderiv ℝ (Hes u) x v)).trace= (((matrixHessian b u x).adjugate)*scalarToMatrix b (fderiv ℝ (Hes u) x v)).trace / (matrixHessian b u x).det := by simp only [Matrix.inv_def,Ring.inverse_eq_inv,Matrix.smul_mul,Matrix.trace_smul,smul_eq_mul,div_eq_mul_inv] ring have hv2:ContDiff ℝ 2 (fun y=>fderiv ℝ u y v) := (ContinuousLinearMap.apply ℝ ℝ v).contDiff.comp hDu rw [trace_scalar_matrix b hv2, HessianDirectional.derivative_direction hu,hmat] rw [scalarToVector_hessian hu2] change (matrixHessian b u x).det⁻¹ * MomentDifferential.detMultilinear.linearDeriv (matrixHessian b u x) (fderiv ℝ (matrixHessian b u) x v) = fderiv ℝ V (gradient u x) (fderiv ℝ (gradient u) x v)-fderiv ℝ u x v at hd rw [hMD,ContinuousLinearMap.comp_apply,MomentDifferential.det_linearDeriv] at hd simpa only [div_eq_mul_inv,mul_comm] using hd theorem smooth_of_regular_three (μ:MeasureTheory.Measure E) [μ.IsAddHaarMeasure] (b:OrthonormalBasis ι ℝ E) {u V:E→ℝ} (hu:Regular 3 u) (hV:ContDiff ℝ ∞ V) {d:ℝ} (heq:∀x,Real.log (matrixHessian b u x).det=V (gradient u x)+d-u x) (hp:∀x,(matrixHessian b u x).PosDef) : ContDiff ℝ ∞ u := by have hu3:ContDiff ℝ 3 u:=hu.contDiff have hu2:ContDiff ℝ 2 u:=hu3.of_le (by norm_num) let A:E→E→L[ℝ]E:=fun x=>HessianTrace.fromMatrix b ((matrixHessian b u x)⁻¹) have hAp(c x:E)(hx:x≠0):0<⟪x,A c x⟫_ℝ:=HessianTrace.inner_pos_fromMatrix b (hp c).inv x hx have hreg (n:ℕ):Regular (n+3) u := by induction n with | zero => exact hu | succ n ih => have hDu:Regular (n+2) (fderiv ℝ u):=ih.2 have hHu:Regular (n+1) (Hes u):=hDu.2 have hM:Regular (n+1) (matrixHessian b u) := by have hm:=hHu.linear (scalarToMatrix b) simpa only [scalarToMatrix_hessian b hu2] using hm have hA:Regular (n+1) A := (hM.comp_smooth (fun x=>inverse_smooth_at (hp x).det_pos.ne')).linear (HessianTrace.fromMatrix b).toContinuousLinearMap have hgu:Regular (n+1) (gradient u) := (hDu.mono (by omega)).linear (toDual ℝ E).symm.toContinuousLinearEquiv.toContinuousLinearMap have hDV:Regular (n+1) (fun x=>fderiv ℝ V (gradient u x)) := hgu.comp_smooth (fun _=>(hV.fderiv_right (m:=∞) (by simp)).contDiffAt) have hdirs(v:E):Regular (n+3) (fun x=>fderiv ℝ u x v) := by let S:E→ℝ:=fun x=>fderiv ℝ V (gradient u x) (scalarToVector (Hes u x) v)-fderiv ℝ u x v have hS:Regular (n+1) S := by have hgv:Regular (n+1) (fun x=>scalarToVector (Hes u x) v):= (hHu.linear scalarToVector).linear (ContinuousLinearMap.apply ℝ E v) have hP:=hDV.bilinear (ContinuousLinearMap.apply ℝ ℝ).flip hgv exact hP.add (((hDu.mono (by omega)).linear (ContinuousLinearMap.apply ℝ ℝ v)).linear (-ContinuousLinearMap.id ℝ ℝ)) apply LinearSchauder.higher μ b n ((hu.2:Regular 2 (fderiv ℝ u)).linear (ContinuousLinearMap.apply ℝ ℝ v)) hA hS (equation b hu3 (hV.differentiable (by simp)) heq hp v) hAp exact ⟨hu.1,Regular.clm_of_basis b.toBasis (fun i=>hdirs (b i))⟩ rw [contDiff_infty] intro n exact (hreg n).contDiff.of_le (by exact_mod_cast (show n≤n+3 by omega)) end MomentSchauder namespace CompactMomentVariational open Set Metric Matrix Filter MeasureTheory HolderJets open scoped InnerProductSpace NNReal ENNReal ContDiff Matrix.Norms.Elementwise variable {ι : Type} [Fintype ι] [DecidableEq ι] [Nonempty ι] local notation "E" => EuclideanSpace ℝ ι local instance : NormedAddCommGroup (E →L[ℝ] ℝ) := ContinuousLinearMap.toNormedAddCommGroup local instance : NormedSpace ℝ (E →L[ℝ] ℝ) := ContinuousLinearMap.toNormedSpace local instance : NormedAddCommGroup (E →L[ℝ] E →L[ℝ] ℝ) := ContinuousLinearMap.toNormedAddCommGroup local instance : NormedSpace ℝ (E →L[ℝ] E →L[ℝ] ℝ) := ContinuousLinearMap.toNormedSpace theorem C2_to_smooth (b : OrthonormalBasis ι ℝ E) {φ V : E → ℝ} (hc : ConvexOn ℝ univ φ) (hφ : ContDiff ℝ 2 φ) {L : ℝ≥0} (hL : LipschitzWith L (gradient φ)) (hs : Function.Surjective (gradient φ)) (hVc : ConvexOn ℝ univ V) (hV : ContDiff ℝ ∞ V) (hI : Integrable (fun x => Real.exp (-V x)) volume) (hm : Measure.map (gradient φ) (volume.withDensity (fun z => ENNReal.ofReal (Real.exp (-φ z)))) = normalizedSource volume V) : ContDiff ℝ ∞ φ := by have hV2:ContDiff ℝ 2 V:=hV.of_le (WithTop.coe_le_coe.mpr le_top) have hpos := C2_positive_MA b hc hφ hL hs hV.continuous hI hm have hp:∀x,(MomentQuotient.matrixHessian b φ x).PosDef := fun x=>(hpos x).1 have heq:∀x,Real.log (MomentQuotient.matrixHessian b φ x).det= V (gradient φ x)+Real.log (∫ x,Real.exp (-V x))-φ x := by intro x simpa only [MomentQuotient.matrixHessian,LinearMap.det_toMatrix] using (hpos x).2 have hgain (c:E) : ∃a r:ℝ,0by obtain ⟨a,r,ha,ha1,hr,hc,hhold⟩:=hgain c exact hc.contDiffAt (ball_mem_nhds c hr)) have hH:ContDiff ℝ 1 (HessianInterpolation.hessian φ) := (h3.fderiv_right (m:=2) (by norm_num)).fderiv_right (by norm_num) have hDC:Continuous (fderiv ℝ (HessianInterpolation.hessian φ)) := (contDiff_one_iff_fderiv.mp hH).2 have hreg:Regular 3 φ := by refine ⟨h3.differentiable (by norm_num), (h3.fderiv_right (m:=2) (by norm_num)).differentiable (by norm_num), hH.differentiable one_ne_zero,hDC,?_⟩ intro c obtain ⟨a,r,ha,ha1,hr,_,C,hC,hh⟩ := hgain c obtain ⟨B,hB⟩ := (isCompact_closedBall c (r/2)).exists_bound_of_continuousOn hDC.continuousOn have hsub:closedBall c (r/2)⊆ball c r := closedBall_subset_ball (by linarith) exact ⟨a,r/2,ha,ha1,by positivity,max 0 B,C,le_max_left _ _,hC, fun _ x hx=>(hB x hx).trans (le_max_right _ _),fun _ x hx y hy=>hh x (hsub hx) y (hsub hy)⟩ exact MomentSchauder.smooth_of_regular_three volume b hreg hV heq hp end CompactMomentVariational end noncomputable section namespace MomentCoordinatesBridge open MeasureTheory Set Matrix MomentCoordinates open scoped InnerProductSpace ContDiff variable {ι : Type} [Fintype ι] [DecidableEq ι] local notation "E" => EuclideanSpace ℝ ι local notation "P" => (ι → ℝ) def coord : E ≃L[ℝ] P := PiLp.continuousLinearEquiv 2 ℝ (fun _ : ι => ℝ) def ob : OrthonormalBasis ι ℝ E := EuclideanSpace.basisFun ι ℝ lemma coord_basis (i:ι) : (coord (ι:=ι)).symm (basis i)=ob i := by ext j simp [coord,ob,EuclideanSpace.basisFun_apply,basis] lemma grad_pull {φ:E→ℝ} (hφ:Differentiable ℝ φ) (x:P) : grad (fun z=>φ (coord.symm z)) x=coord (gradient φ (coord.symm x)) := by ext i change fderiv ℝ (fun z=>φ (coord.symm z)) x (basis i)=_ have hd:=((hφ (coord.symm x)).hasGradientAt.hasFDerivAt.comp x (coord (ι:=ι)).symm.toContinuousLinearMap.hasFDerivAt).fderiv dsimp only [Function.comp_def] at hd rw [hd,ContinuousLinearMap.comp_apply] change ⟪gradient φ (coord.symm x),coord.symm (basis i)⟫_ℝ=_ rw [coord_basis] exact EuclideanSpace.inner_basisFun_real ι _ i lemma pd_pull {φ:E→ℝ} (hφ:Differentiable ℝ φ) (i:ι) : pd i (fun z=>φ (coord.symm z))=fun x=>(coord (gradient φ (coord.symm x))) i := by funext x exact congrFun (grad_pull hφ x) i lemma hess_pull {φ:E→ℝ} (hφ:ContDiff ℝ ∞ φ) (x:P) : hess (fun z=>φ (coord.symm z)) x= MomentLinearization.hessian ob φ (coord.symm x) := by have hG:ContDiff ℝ ∞ (gradient φ):= (InnerProductSpace.toDual ℝ E).symm.toContinuousLinearEquiv.contDiff.comp (hφ.fderiv_right (by simp)) ext i j change pd j (pd i (fun z=>φ (coord.symm z))) x=_ rw [pd_pull (hφ.differentiable (by simp))] let ev : E→L[ℝ]ℝ := (ContinuousLinearMap.proj i).comp coord.toContinuousLinearMap have hd:=((ev.hasFDerivAt.comp (coord.symm x) (hG.differentiable (by simp) (coord.symm x)).hasFDerivAt).comp x (coord (ι:=ι)).symm.toContinuousLinearMap.hasFDerivAt).fderiv change fderiv ℝ (fun z=>ev (gradient φ (coord.symm z))) x (basis j)=_ dsimp only [Function.comp_def] at hd rw [hd,ContinuousLinearMap.comp_apply,ContinuousLinearMap.comp_apply] simp only [ev,ContinuousLinearMap.comp_apply,ContinuousLinearMap.proj_apply] change (coord ((fderiv ℝ (gradient φ) (coord.symm x)) (coord.symm (basis j)))) i=_ rw [coord_basis] simp [MomentLinearization.hessian,LinearMap.toMatrix_apply,ob,coord, OrthonormalBasis.coe_toBasis_repr_apply] end MomentCoordinatesBridge namespace SoftEuclidean open MeasureTheory Set SoftSlab open scoped InnerProductSpace ContDiff variable {ι κ:Type} [Fintype ι] [Fintype κ] local notation "E" => EuclideanSpace ℝ ι local notation "C" => PiLp.continuousLinearEquiv 2 ℝ (fun _:ι=>ℝ) lemma convex_summand {q:ℕ} (hq:Even q) (p:ι→ℝ) (h:ℝ) : ConvexOn ℝ univ (summand p h q) := by have hh:ConvexOn ℝ univ (fun t:ℝ=>t^q):=hq.convexOn_pow change ConvexOn ℝ univ (fun x => (linear p x/h)^q) simpa only [preimage_univ,Function.comp_def,LinearMap.smul_apply,ContinuousLinearMap.coe_coe,smul_eq_mul,div_eq_mul_inv,mul_comm] using hh.comp_linearMap (h⁻¹ • (linear p).toLinearMap) lemma convex_sum {q:ℕ} (hq:Even q) (p:κ→ι→ℝ) (h:κ→ℝ) : ConvexOn ℝ univ (fun x:E=>∑i,summand (p i) (h i) q (C x)) := by refine ⟨convex_univ,?_⟩ intro x hx y hy a b ha hb hab simp only [map_add,map_smul,smul_eq_mul,Finset.mul_sum,← Finset.sum_add_distrib] exact Finset.sum_le_sum fun i _ => (convex_summand hq (p i) (h i)).2 (mem_univ _) (mem_univ _) ha hb hab lemma midpoint_curvature {q:ℕ} (hq:Even q) (ε:ℝ) (p:κ→ι→ℝ) (h:κ→ℝ) (x y:E) : ε/8*‖x-y‖^2 ≤ (potential ε p h q (C x)+potential ε p h q (C y))/2- potential ε p h q (C ((1/2:ℝ) • (x+y))) := by have hh: (∑i,summand (p i) (h i) q (C ((1/2:ℝ) • (x+y)))) ≤ ((∑i,summand (p i) (h i) q (C x))+(∑i,summand (p i) (h i) q (C y)))/2 := by have ht := (convex_sum hq p h).2 (mem_univ x) (mem_univ y) (by norm_num:(0:ℝ)≤1/2) (by norm_num:(0:ℝ)≤1/2) (by norm_num:(1:ℝ)/2+1/2=1) simp only [← smul_add,smul_eq_mul] at ht linarith have hn (z:E) : ∑i,(C z) i^2=‖z‖^2 := (EuclideanSpace.real_norm_sq_eq z).symm simp only [potential,hn] rw [norm_smul, mul_pow, Real.norm_eq_abs,abs_of_pos (by norm_num:(0:ℝ)<1/2), norm_add_sq_real,norm_sub_sq_real] nlinarith lemma convex_potential {q:ℕ} (hq:Even q) {ε:ℝ} (hε:0≤ε) (p:κ→ι→ℝ) (h:κ→ℝ) : ConvexOn ℝ univ (fun x:E=>potential ε p h q (C x)) := by have hsq : ConvexOn ℝ univ (fun x:E=>∑i,(C x) i^2) := by refine ⟨convex_univ,?_⟩ intro x hx y hy a b ha hb hab simp only [map_add,map_smul,Pi.add_apply,Pi.smul_apply,smul_eq_mul, Finset.mul_sum,← Finset.sum_add_distrib] apply Finset.sum_le_sum intro i _ exact (even_two.convexOn_pow (𝕜:=ℝ)).2 (mem_univ ((C x) i)) (mem_univ ((C y) i)) ha hb hab exact (hsq.smul (div_nonneg hε (by norm_num))).add (convex_sum hq p h) lemma integrable_potential {q:ℕ} (hq:Even q) {ε:ℝ} (hε:0<ε) (p:κ→ι→ℝ) (h:κ→ℝ) : Integrable (fun x:E=>Real.exp (-potential ε p h q (C x))) volume := by have hi := GaussianPolynomial.partition_integrable (smooth_potential ε p h q).continuous (b:=ε/2) (c:=0) (by positivity) (fun x=>by simpa using potential_lower hq ε p h x) exact ((PiLp.volume_preserving_ofLp ι).integrable_comp hi.aestronglyMeasurable).mpr hi end SoftEuclidean namespace MomentHessianCap open MeasureTheory Set Filter Matrix open scoped InnerProductSpace Topology ContDiff variable {E:Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] variable {ι:Type*} [Fintype ι] [DecidableEq ι] lemma inner_cap {φ:E→ℝ} (hφ:ContDiff ℝ 2 φ) {C:ℝ} (hb:∀h z,WeakMomentBound.secondDiff φ h z≤C*‖h‖^2) (x v:E) : ⟪(fderiv ℝ (gradient φ) x) v,v⟫_ℝ≤C*‖v‖^2 := by have hg:ContDiff ℝ 1 (gradient φ):= (InnerProductSpace.toDual ℝ E).symm.toContinuousLinearEquiv.contDiff.comp (hφ.fderiv_right (by norm_num)) apply le_of_tendsto (SecondQuotient.gradient_limit (hφ.differentiable (by norm_num)) (hg.differentiable one_ne_zero x) (e:=v)) filter_upwards [self_mem_nhdsWithin] with t ht have ht0:t≠0:=ht apply (div_le_iff₀ (sq_pos_of_ne_zero ht0)).mpr have hh:=hb (t • v) x simpa only [WeakMomentBound.secondDiff,norm_smul,mul_pow,Real.norm_eq_abs,sq_abs,mul_assoc,mul_comm,mul_left_comm] using hh lemma matrix_cap (b:OrthonormalBasis ι ℝ E) {φ:E→ℝ} (hφ:ContDiff ℝ 2 φ) (hp:∀x,(MomentLinearization.hessian b φ x).PosDef) {C:ℝ} (hb:∀h z,WeakMomentBound.secondDiff φ h z≤C*‖h‖^2) (x:E) : (C • (1:Matrix ι ι ℝ)-MomentLinearization.hessian b φ x).PosSemidef := by apply Matrix.PosSemidef.of_dotProduct_mulVec_nonneg ((Matrix.isHermitian_one.smul (k:=C) (by simp [IsSelfAdjoint])).sub (hp x).isHermitian) intro v have hi:=inner_cap hφ hb x (HessianCoordinates.vector b v) rw [←HessianCoordinates.quadratic_toMatrix b] at hi have hn:‖HessianCoordinates.vector b v‖^2=∑i,v i^2 := by rw [HessianCoordinates.vector,LinearIsometryEquiv.norm_map,EuclideanSpace.real_norm_sq_eq] rw [hn] at hi change FiniteElliptic.quadratic (C • (1:Matrix ι ι ℝ)-MomentLinearization.hessian b φ x) v ≥ 0 simp only [FiniteElliptic.quadratic,Matrix.sub_mulVec,Matrix.smul_mulVec,Matrix.one_mulVec, dotProduct_sub,dotProduct_smul,smul_eq_mul] change 0≤C*(v ⬝ᵥ v)-FiniteElliptic.quadratic (MomentLinearization.hessian b φ x) v rw [show v ⬝ᵥ v=∑i,v i^2 by simp only [dotProduct,pow_two]] exact sub_nonneg.mpr hi lemma positive_derivative (b:OrthonormalBasis ι ℝ E) {φ:E→ℝ} (hp:∀x,(MomentLinearization.hessian b φ x).PosDef) (x v:E) (hv:v≠0) : 0<⟪v,(fderiv ℝ (gradient φ) x) v⟫_ℝ := by let w:ι→ℝ:=fun i=>b.repr v i have hw:w≠0 := by intro hh apply hv apply b.repr.injective ext i simpa [w] using congrFun hh i have hh:0⟪v,G (x+t • v)⟫_ℝ have hf(t:ℝ):HasDerivAt f ⟪v,fderiv ℝ G (x+t • v) v⟫_ℝ t := by have hl:HasDerivAt (fun t:ℝ=>x+t • v) v t := by simpa using ((hasDerivAt_id t).smul_const v).const_add x exact (InnerProductSpace.toDual ℝ E v).hasFDerivAt.comp_hasDerivAt t ((hG (x+t • v)).hasFDerivAt.comp_hasDerivAt t hl) have hh:=strictMono_of_hasDerivAt_pos hf (fun t=>hp _ v hv) (by norm_num : (0:ℝ)<1) dsimp only [f] at hh simp only [zero_smul,add_zero,one_smul] at hh have hsum:x+v=y := by dsimp [v]; abel rw [hsum,he] at hh exact (lt_irrefl _ hh) theorem exists_homeomorph {G:E→E} (hG:ContDiff ℝ ∞ G) (hp:∀x v:E,v≠0 → 0<⟪v,fderiv ℝ G x v⟫_ℝ) (hs:Function.Surjective G) : ∃Φ:E≃ₜE,(Φ:E→E)=G ∧ ContDiff ℝ ∞ (Φ.symm:E→E) := by have hd:=hG.differentiable (by simp) have hbij(x:E):Function.Bijective (fderiv ℝ G x) := by have hi:Function.Injective (fderiv ℝ G x) := by apply LinearMap.ker_eq_bot.mp rw [LinearMap.ker_eq_bot'] intro v hv by_contra hn have hh:=hp x v hn change (fderiv ℝ G x) v=0 at hv simp only [hv,inner_zero_right] at hh exact (lt_irrefl _ hh) exact ⟨hi,(LinearMap.injective_iff_surjective (f:=(fderiv ℝ G x).toLinearMap)).mp hi⟩ let A:E→E≃L[ℝ]E:=fun x=>ContinuousLinearEquiv.ofBijective (fderiv ℝ G x) (LinearMap.ker_eq_bot.mpr (hbij x).1) (LinearMap.range_eq_top.mpr (hbij x).2) have hAd(x:E):HasFDerivAt G (A x:E→L[ℝ]E) x := (hd x).hasFDerivAt have ho:IsOpenMap G:=isOpenMap_of_hasStrictFDerivAt_equiv (fun x=> show HasStrictFDerivAt G (A x:E→L[ℝ]E) x from hG.contDiffAt.hasStrictFDerivAt (by simp)) let Φ:E≃ₜE:=(Equiv.ofBijective G ⟨injective hd hp,hs⟩).toHomeomorphOfContinuousOpen hG.continuous ho exact ⟨Φ,rfl,Φ.contDiff_symm hAd hG⟩ end PositiveDiffeomorphism namespace MeasureCoordinates open MeasureTheory Set variable {E : Type*} {F : Type*} [MeasurableSpace E] [MeasurableSpace F] lemma map_density (e:E≃ᵐF) {μ:Measure E} {ν:Measure F} (he:MeasurePreserving e μ ν) {f:F→ENNReal} (hf:Measurable f) : Measure.map e (μ.withDensity (fun x=>f (e x)))=ν.withDensity f := by ext S hS rw [Measure.map_apply e.measurable hS,withDensity_apply _ (e.measurable hS),withDensity_apply _ hS, ←he.map_eq,setLIntegral_map hS hf e.measurable] end MeasureCoordinates namespace MomentCoordinatesBridge open MeasureTheory MomentCoordinates TargetCoordinates open scoped ContDiff variable {ι:Type} [Fintype ι] local notation "E" => EuclideanSpace ℝ ι local notation "P" => (ι→ℝ) local notation "C" => (coord (ι:=ι)) lemma coord_integral (f:P→ℝ) : (∫x:E,f (C x))=∫x:P,f x := (PiLp.volume_preserving_ofLp ι).integral_comp (C).toHomeomorph.toMeasurableEquiv.measurableEmbedding f lemma coord_density {f:P→ENNReal} (hf:Measurable f) : Measure.map C (volume.withDensity (fun x:E=>f (C x)))=volume.withDensity f := MeasureCoordinates.map_density (C).toHomeomorph.toMeasurableEquiv (PiLp.volume_preserving_ofLp ι) hf lemma coord_source {φ:E→ℝ} (hφ:ContDiff ℝ ∞ φ) : Measure.map C (volume.withDensity (fun x:E=>ENNReal.ofReal (Real.exp (-φ x))))= sourceMeasure volume (fun x:P=>φ ((C).symm x)) := by have ht:=coord_density (ι:=ι) (f:=fun x:P=>ENNReal.ofReal (Real.exp (-φ ((C).symm x)))) ((hφ.comp (C).symm.contDiff).continuous.neg.rexp.measurable.ennreal_ofReal) simpa only [(C).symm_apply_apply,sourceMeasure,WeightedCalculus.weight] using ht lemma coord_normalized {V:P→ℝ} (hV:ContDiff ℝ ∞ V) : Measure.map C (CompactMomentVariational.normalizedSource volume (fun x:E=>V (C x)))= targetMeasure volume V (∫x:P,Real.exp (-V x)) := by unfold CompactMomentVariational.normalizedSource targetMeasure WeightedCalculus.weight rw [coord_integral (ι:=ι) (fun x:P=>Real.exp (-V x))] exact coord_density (ι:=ι) (f:=fun x:P=>ENNReal.ofReal (Real.exp (-V x)/(∫y:P,Real.exp (-V y)))) ((hV.continuous.neg.rexp.div_const (∫y:P,Real.exp (-V y))).measurable.ennreal_ofReal) end MomentCoordinatesBridge namespace ActualMoment section open MeasureTheory Set Matrix MomentCoordinatesBridge open scoped InnerProductSpace ContDiff variable {ι κ:Type} [Fintype ι] [DecidableEq ι] [Nonempty ι] [Fintype κ] local notation "E" => EuclideanSpace ℝ ι local notation "C" => (coord (ι:=ι)) theorem euclidean {q:ℕ} (hq:Even q) {ε:ℝ} (hε:0<ε) (p:κ→ι→ℝ) (h:κ→ℝ) : ∃φ:E→ℝ, ContDiff ℝ ∞ φ ∧ (∀x,(MomentLinearization.hessian ob φ x).PosDef) ∧ (∀x,((4/ε) • (1:Matrix ι ι ℝ)-MomentLinearization.hessian ob φ x).PosSemidef) ∧ (∀x, Real.log (MomentLinearization.hessian ob φ x).det= SoftSlab.potential ε p h q (C (gradient φ x))+ Real.log (∫x:E,Real.exp (-SoftSlab.potential ε p h q (C x)))-φ x) ∧ ∃Φ:E≃ₜE,(Φ:E→E)=gradient φ ∧ ContDiff ℝ ∞ (Φ.symm:E→E) ∧ Measure.map (gradient φ) (volume.withDensity (fun x=>ENNReal.ofReal (Real.exp (-φ x))))= CompactMomentVariational.normalizedSource volume (fun x:E=>SoftSlab.potential ε p h q (C x)) := by let V:E→ℝ:=fun x=>SoftSlab.potential ε p h q (C x) have hV:ContDiff ℝ ∞ V := (SoftSlab.smooth_potential ε p h q).comp (C).contDiff have hVc:=SoftEuclidean.convex_potential hq hε.le p h have hI:=SoftEuclidean.integrable_potential hq hε p h obtain ⟨φ,hc,_,hC1,hL,hcap,_,_,hm,hs⟩:= CompactMomentVariational.exists_C11_global volume ob hV.continuous (fun x=>by simpa only [V,map_neg] using SoftSlab.potential_even hq ε p h (C x)) hI hε (SoftEuclidean.midpoint_curvature hq ε p h) have hC2:=CompactMomentVariational.C11_to_C2 ob hc hC1 hL hs hVc (hV.of_le (by simp)) hI hm have hSmooth:=CompactMomentVariational.C2_to_smooth ob hc hC2 hL hs hVc hV hI hm have hMA:=CompactMomentVariational.C2_positive_MA ob hc hC2 hL hs hV.continuous hI hm have hp:∀x,(MomentLinearization.hessian ob φ x).PosDef:=fun x=>(hMA x).1 have hG:ContDiff ℝ ∞ (gradient φ):= (InnerProductSpace.toDual ℝ E).symm.toContinuousLinearEquiv.contDiff.comp (hSmooth.fderiv_right (by simp)) obtain ⟨Φ,hΦ,hInv⟩:=PositiveDiffeomorphism.exists_homeomorph hG (MomentHessianCap.positive_derivative ob hp) hs refine ⟨φ,hSmooth,hp,MomentHessianCap.matrix_cap ob hC2 hp hcap,?_,Φ,hΦ,hInv,hm⟩ intro x simpa only [MomentLinearization.hessian,LinearMap.det_toMatrix] using (hMA x).2 end section open MeasureTheory Set Matrix MomentCoordinatesBridge MomentCoordinates TargetCoordinates open scoped InnerProductSpace ContDiff variable {ι κ:Type} [Fintype ι] [DecidableEq ι] [Nonempty ι] [Fintype κ] local notation "E" => EuclideanSpace ℝ ι local notation "P" => (ι→ℝ) local notation "C" => (coord (ι:=ι)) theorem coordinates {q:ℕ} (hq:Even q) {ε:ℝ} (hε:0<ε) (p:κ→ι→ℝ) (h:κ→ℝ) : ∃φ:P→ℝ, ContDiff ℝ ∞ φ ∧ (∀x,(hess φ x).PosDef) ∧ (∀x,((4/ε) • (1:Matrix ι ι ℝ)-hess φ x).PosSemidef) ∧ (∀x, Real.log (hess φ x).det=SoftSlab.potential ε p h q (grad φ x)+ Real.log (∫x:P,Real.exp (-SoftSlab.potential ε p h q x))-φ x) ∧ ∃Φ:P≃ₜP,(Φ:P→P)=grad φ ∧ ContDiff ℝ ∞ (Φ.symm:P→P) ∧ Measure.map (grad φ) (sourceMeasure volume φ)=SoftSlab.law ε p h q := by obtain ⟨φ,hφ,hpos,hcap,heq,Φ,hΦ,hInv,hm⟩:=euclidean hq hε p h let ψ:P→ℝ:=fun x=>φ ((C).symm x) have hψ:ContDiff ℝ ∞ ψ:=hφ.comp (C).symm.contDiff let Ψ:P≃ₜP:=((C).symm.toHomeomorph.trans Φ).trans (C).toHomeomorph have hg:∀x,grad ψ x=C (gradient φ ((C).symm x)):=grad_pull (hφ.differentiable (by simp)) have hh:∀x,hess ψ x=MomentLinearization.hessian ob φ ((C).symm x):=hess_pull hφ have hΨ:(Ψ:P→P)=grad ψ := by funext x rw [hg] change C (Φ ((C).symm x))=_ rw [hΦ] have hΨi:ContDiff ℝ ∞ (Ψ.symm:P→P):=(C).contDiff.comp (hInv.comp (C).symm.contDiff) have hZ:=coord_integral (ι:=ι) (fun x:P=>Real.exp (-SoftSlab.potential ε p h q x)) have hsrc:Measure.map C (volume.withDensity (fun x:E=>ENNReal.ofReal (Real.exp (-φ x))))= sourceMeasure volume ψ := coord_source hφ have htar:Measure.map C (CompactMomentVariational.normalizedSource volume (fun x:E=>SoftSlab.potential ε p h q (C x)))=SoftSlab.law ε p h q := coord_normalized (SoftSlab.smooth_potential ε p h q) have hmap:Measure.map (grad ψ) (sourceMeasure volume ψ)=SoftSlab.law ε p h q := by rw [←hsrc,Measure.map_map (smooth_grad hψ).continuous.measurable (C).continuous.measurable] have hgC:(grad ψ) ∘ C=C ∘ (gradient φ) := by funext x simp only [Function.comp_apply,hg,(C).symm_apply_apply] rw [hgC,←Measure.map_map (C).continuous.measurable] · rw [hm,htar] · exact ((InnerProductSpace.toDual ℝ E).symm.toContinuousLinearEquiv.contDiff.comp (hφ.fderiv_right (m:=∞) (by simp))).continuous.measurable refine ⟨ψ,hψ,(fun x=>by rw [hh];exact hpos _), (fun x=>by rw [hh];exact hcap _),?_,Ψ,hΨ,hΨi,hmap⟩ intro x rw [hh,hg] simpa only [hZ] using heq ((C).symm x) end open MeasureTheory Set Matrix MomentCoordinates TargetCoordinates SoftSlab open scoped ContDiff variable {ι κ:Type} [Fintype ι] [Fintype κ] lemma feature_eval (p:ι→ℝ) (h:ℝ) (q:ℕ) (x:ι→ℝ) : MvPolynomial.eval x (SlabReduction.feature p h q)=summand p h q x := by rw [SlabReduction.eval_feature,summand_eq] rfl lemma density_eq (p:κ→ι→ℝ) (h:κ→ℝ) (ε:ℝ) (q:ℕ) : SlabPartition.density ε (SlabReduction.features p h q) (fun _=>0) 0= fun x=>Real.exp (-potential ε p h q x) := by funext x unfold SlabPartition.density SlabPartition.potential potential rw [SlabPartition.variation_eq] simp only [pow_zero,zero_mul,Real.exp_zero,one_mul,SlabReduction.features,feature_eval] lemma mean_eq {q:ℕ} (hq:Even q) {ε:ℝ} (hε:0<ε) (p:κ→ι→ℝ) (h:κ→ℝ) (F:(ι→ℝ)→ℝ) : SlabPartition.mean ε (SlabReduction.features p h q) (fun _=>0) 0 F= ∫x,F x ∂law ε p h q := by change _ = ∫x,F x ∂targetMeasure volume (potential ε p h q) (∫x,Real.exp (-potential ε p h q x)) rw [target_integral volume (smooth_potential ε p h q) (potential_partition_pos hq hε p h)] unfold SlabPartition.mean SlabPartition.partition normalizedE WeightedCalculus.expectation rw [density_eq] rfl lemma variance_eq {q:ℕ} (hq:Even q) {ε:ℝ} (hε:0<ε) (p:κ→ι→ℝ) (h:κ→ℝ) (b:κ→ℝ) : SlabPartition.variance ε (SlabReduction.features p h q) (fun _=>0) 0 (fun x=>∑i,b i*MvPolynomial.eval x (SlabReduction.features p h q i))= (∫x,(∑i,b i*summand (p i) (h i) q x)^2 ∂law ε p h q)- (∫x,∑i,b i*summand (p i) (h i) q x ∂law ε p h q)^2 := by classical let P:MvPolynomial ι ℝ:=∑i,MvPolynomial.C (b i)*SlabReduction.features p h q i have hP: (fun x=>MvPolynomial.eval x P)= (fun x=>∑i,b i*MvPolynomial.eval x (SlabReduction.features p h q i)) := by funext x simp [P] rw [←hP,SlabPartition.variance_eq hε (SlabReduction.features_nonneg p h hq)] simp only [mean_eq hq hε p h,P,map_sum,map_mul,MvPolynomial.eval_C, SlabReduction.features,feature_eval] lemma covariance_rhs {q:ℕ} (hq:Even q) {ε:ℝ} (hε:0<ε) (p:κ→ι→ℝ) (h:κ→ℝ) (b:κ→ℝ) : SlabPartition.mean ε (SlabReduction.features p h q) (fun _=>0) 0 (fun x=>∑i,b i^2*MvPolynomial.eval x (SlabReduction.features p h q i))= ∑i,b i^2*(∫x,summand (p i) (h i) q x ∂law ε p h q) := by rw [mean_eq hq hε p h] simp only [SlabReduction.features,feature_eval] rw [integral_finsetSum _ (fun i _=>(integrable_summand hq hε p h (p i) (h i) q).const_mul _)] simp only [integral_const_mul] end ActualMoment namespace LogBrunnMinkowski open MeasureTheory Set open scoped InnerProductSpace ENNReal ContDiff theorem softVariance : SoftVarianceStatement := by intro n hn κ _ _ q hq hq2 ε hε p hp h hh b classical let : Nonempty (Fin n):=Fin.pos_iff_nonempty.mp (by omega) have hqm:Even (q-2):=(Nat.even_sub hq2).mpr (iff_of_true hq even_two) have hqq:q-2+2=q:=Nat.sub_add_cancel hq2 obtain ⟨φ,hφ,hpos,hcap,heq,Φ,hΦ,hInv,hm⟩:= ActualMoment.coordinates (hqm.add even_two) hε p h have hv:=MomentSlab.variance_from_moment hqm hε p h hp hh hφ hpos hcap heq Φ hΦ hInv hm b simp only [hqq] at hv rw [ActualMoment.variance_eq hq hε p h b,ActualMoment.covariance_rhs hq hε p h b] exact hv theorem main (n : ℕ) (hn : 1 ≤ n) (K L : Set (Space n)) (hK : IsConvexBody K) (hL : IsConvexBody L) (hsK : OriginSymmetric K) (hsL : OriginSymmetric L) (t : ℝ) (ht0 : 0 ≤ t) (ht1 : t ≤ 1) : (volume K) ^ (1 - t) * (volume L) ^ t ≤ volume (logCombination K L t) := by exact main_of_softVariance softVariance n hn K L hK hL hsK hsL t ht0 ht1 end LogBrunnMinkowski end end OAI