lemmaposSemidef_anchor {A : Type*} {K : MatrixAAℝ} (hK : K.PosSemidef) (z : A) :
Matrix.PosSemidef (fun x y =>K x y-K x z-K z y+K z z) :=by
proof · 8
lines
let : FactK.PosSemidef:= ⟨hK⟩
have hh := posSemidef_inner (fun x => kernelFeature K x-kernelFeature K z)
have he (x y : A) : ⟪kernelFeature K x-kernelFeature K z,kernelFeature K y-kernelFeature K z⟫_ℝ=
K x y-K x z-K z y+K z z :=by
rw [inner_sub_left,inner_sub_right,inner_sub_right]
simp only [inner_kernelFeature]
ring
simpa only [he] using hh
have h1 := scaled_taylorOn_tendsto hs hso hf hx 1have h2 := (scaled_taylorOn_tendsto hs hso hf hx (1/2)).const_mul 2have hh := (h1.sub h2).mono_left (nhdsWithin_le_nhds : 𝓝[≠] (0:ℝ)≤𝓝 0)
simp only [sub_zero,mul_zero,one_mul] at hh
havehe : (fune : ℝ=> (f (x+e)-taylorWithinEval f 2 s x (x+e))/e^2-
2*((f (x+(1/2)*e)-taylorWithinEval f 2 s x (x+(1/2)*e))/e^2)) =ᶠ[𝓝[≠] 0]
(fun e => (f (x+e)-2*f (x+e/2)+f x)/e^2-iteratedDeriv 2 f x/4) :=by
filter_upwards [self_mem_nhdsWithin] with e he
havehne : e≠0:= he
have hd (n : ℕ) : iteratedDerivWithin n f s x=iteratedDeriv n f x :=
iteratedDerivWithin_of_isOpen hso hx
simp only [taylorWithinEval_succ,taylor_within_zero_eval,hd]
norm_num
field_simp
ring
have hl := hh.congr' he
have ha := hl.add_const (iteratedDeriv 2 f x/4)
simpa only [sub_add_cancel,zero_add] using ha
classical
letz : s := ⟨hne.choose,hne.choose_spec⟩
letK : Matrix s s ℝ:=fun x y => f ((x+y)/2)-f ((x+z)/2)-f ((z+y)/2)+f z
let : FactK.PosSemidef:= ⟨h z⟩
letT (e : ℝ) (x : s) : s :=ifhx : (x:ℝ)+e∈s then ⟨x+e,hx⟩ else x
letG (e : ℝ) (x : s) := e⁻¹ • (kernelFeature K (T e x)-kernelFeature K x)
have hlim (x y : s) : Tendsto (fun e => ⟪G e x,G e y⟫_ℝ) (𝓝[≠] (0:ℝ))
(𝓝 (iteratedDeriv 2 f ((x+y)/2)/4)) :=byhavehxy : ((x:ℝ)+y)/2∈s :=by
simpa only [midpoint_eq_smul_add,smul_eq_mul,invOf_eq_inv,div_eq_mul_inv,mul_comm] using hs.midpoint_mem x.property y.property
have hh := secondForward_tendsto hs hso hf hxy
apply hh.congr'
havehx : ∀ᶠ e in 𝓝 (0:ℝ),(x:ℝ)+e∈s :=byhave hh := (showContinuous (fune : ℝ=> (x:ℝ)+e) fromby fun_prop).tendsto (0:ℝ)
simp only [add_zero] at hh
exact hh.eventually (hso.mem_nhds x.property)
havehy : ∀ᶠ e in 𝓝 (0:ℝ),(y:ℝ)+e∈s :=byhave hh := (showContinuous (fune : ℝ=> (y:ℝ)+e) fromby fun_prop).tendsto (0:ℝ)
simp only [add_zero] at hh
exact hh.eventually (hso.mem_nhds y.property)
filter_upwards [hx.filter_mono nhdsWithin_le_nhds,hy.filter_mono nhdsWithin_le_nhds]
with e heX heY
simp only [G,real_inner_smul_left,real_inner_smul_right,inner_sub_left,inner_sub_right,
inner_kernelFeature]
simp only [T,dite_eq_left heX,dite_eq_left heY,K]
havehe1 : ((x:ℝ)+e+(y+e))/2=((x:ℝ)+y)/2+e :=by ring
havehe2 : ((x:ℝ)+e+y)/2=((x:ℝ)+y)/2+e/2:=by ring
havehe3 : ((x:ℝ)+(y+e))/2=((x:ℝ)+y)/2+e/2:=by ring
rw [he1,he2,he3]
ring
have hh :=PositiveDefinite.posSemidef_limit (l := 𝓝[≠] (0:ℝ))
(fun e => posSemidef_inner (G e)) hlim
have hp := hh.smul (show (0:ℝ)≤4by norm_num)
haveheq : Matrix.of (funx y : s => iteratedDeriv 2 f ((x+y)/2)) =
(4:ℝ) • Matrix.of (funx y : s => iteratedDeriv 2 f ((x+y)/2)/4) :=by
ext x y
simp only [Matrix.smul_apply,Matrix.of_apply,smul_eq_mul]
ring
change (Matrix.of (funx y : s => iteratedDeriv 2 f ((x+y)/2))).PosSemidef
rw [heq]
exact hp
lemmaHankelCPD.add {f g : ℝ→ℝ} {s : Setℝ}
(hf : HankelCPD f s) (hg : HankelCPD g s) : HankelCPD (fun x => f x+g x) s :=by
proof · 14
lines
intro z
havehe : Matrix.of (funx y : s =>
(f ((x+y)/2)+g ((x+y)/2))-(f ((x+z)/2)+g ((x+z)/2))-
(f ((z+y)/2)+g ((z+y)/2))+(f z+g z)) =
Matrix.of (funx y : s => f ((x+y)/2)-f ((x+z)/2)-f ((z+y)/2)+f z)+
Matrix.of (funx y : s => g ((x+y)/2)-g ((x+z)/2)-g ((z+y)/2)+g z) :=by
ext x y
simp only [Matrix.add_apply,Matrix.of_apply]
ring
change (Matrix.of (funx y : s =>
(f ((x+y)/2)+g ((x+y)/2))-(f ((x+z)/2)+g ((x+z)/2))-
(f ((z+y)/2)+g ((z+y)/2))+(f z+g z))).PosSemidef
rw [he]
exact (hf z).add (hg z)
classical
intro z
letK (r : ℝ) : Matrix s s ℝ:=if0<r thenMatrix.of (fun x y => (F r ((x+y)/2)-F r ((x+z)/2)-F r ((z+y)/2)+F r z)/r) else0have hK (r : ℝ) : (K r).PosSemidef:=by
dsimp only [K]
split_ifs with hr
· havehe : Matrix.of (funx y : s => (F r ((x+y)/2)-F r ((x+z)/2)-F r ((z+y)/2)+F r z)/r)=
r⁻¹ • Matrix.of (funx y : s =>F r ((x+y)/2)-F r ((x+z)/2)-F r ((z+y)/2)+F r z) :=by
ext x y
simp only [Matrix.smul_apply,Matrix.of_apply,smul_eq_mul,div_eq_mul_inv,mul_comm]
rw [he]
exact ((hF r hr).cpd z).smul (inv_nonneg.mpr hr.le)
· exact Matrix.PosSemidef.zero
apply PositiveDefinite.posSemidef_limit (l := 𝓝[>] (0:ℝ)) hK
intro x y
have hm (u v : s) : ((u:ℝ)+v)/2∈s :=by
simpa only [midpoint_eq_smul_add,smul_eq_mul,invOf_eq_inv,div_eq_mul_inv,mul_comm]
using hs.midpoint_mem u.property v.property
have hh := (((ht _ (hm x y)).sub (ht _ (hm x z))).sub (ht _ (hm z y))).add (ht z z.property)
apply hh.congr'
filter_upwards [self_mem_nhdsWithin] with r hr
dsimp only [K]
rw [ite_eq_left (show0<r from hr)]
simp only [Matrix.of_apply]
ring
lemmaHankelPD.midpoint_le {f : ℝ→ℝ} {s : Setℝ} (hf : HankelPD f s)
{x y : ℝ} (hx : x∈s) (hy : y∈s) : 2*f ((x+y)/2)≤f x+f y :=by
proof · 5
lines
letK : Matrix s s ℝ:=fun u v => f ((u+v)/2)
let : FactK.PosSemidef:= ⟨hf⟩
have hh := norm_kernelFeature_sub_sq K ⟨x,hx⟩ ⟨y,hy⟩
simp only [K,add_self_div_two] at hh
nlinarith [sq_nonneg ‖kernelFeature K ⟨x,hx⟩-kernelFeature K ⟨y,hy⟩‖]
lemmaHankelPD.midpoint_lt {f : ℝ→ℝ} {s : Setℝ} (hf : HankelPD f s)
{x y : ℝ} (hx : x∈s) (hy : y∈s) (hne : f x≠f y) : 2*f ((x+y)/2)<f x+f y :=by
proof · 12
lines
letK : Matrix s s ℝ:=fun u v => f ((u+v)/2)
let : FactK.PosSemidef:= ⟨hf⟩
have hh := norm_kernelFeature_sub_sq K ⟨x,hx⟩ ⟨y,hy⟩
simp only [K,add_self_div_two] at hh
havehn : kernelFeature K ⟨x,hx⟩≠kernelFeature K ⟨y,hy⟩ :=by
intro he
apply hne
have hh := congrArg (fun v => ‖v‖^2) he
rw [norm_kernelFeature_sq K,norm_kernelFeature_sq K] at hh
simpa only [K,add_self_div_two] using hh
have hp := sq_pos_of_pos (norm_pos_iff.mpr (sub_ne_zero.mpr hn))
linarith
lemmaposSemidef_weight {A : Type*} {K : MatrixAAℝ} (hK : K.PosSemidef) (w : A→ℝ) :
Matrix.PosSemidef (Matrix.of (fun x y => w x*w y*K x y)) :=by
proof · 9
lines
let : FactK.PosSemidef:= ⟨hK⟩
have hh := posSemidef_inner (fun x => w x • kernelFeature K x)
havehe : Matrix.of (fun x y => w x*w y*K x y)=
Matrix.of (fun x y => ⟪w x • kernelFeature K x,w y • kernelFeature K y⟫_ℝ) :=by
ext x y
simp only [Matrix.of_apply,real_inner_smul_left,real_inner_smul_right,inner_kernelFeature]
ring
rw [he]
exact hh
letκ : s → s →ℝ→ℝ:=fun t u x =>F ((t+u)/2) x
have hmid (t u : s) : ((t:ℝ)+u)/2∈s :=by
simpa only [midpoint_eq_smul_add,smul_eq_mul,invOf_eq_inv,div_eq_mul_inv,mul_comm]
using hsv.midpoint_mem t.property u.property
have hκc (t u : s) : Continuous (κ t u) := hc _ (hmid t u)
have hp := stationary_kernel_heat κ hK hκc (fun t => toNNReal ((t-a)/2))
have he (t u : s) : toNNReal (((t:ℝ)-a)/2)+toNNReal (((u:ℝ)-a)/2)=
toNNReal (((t:ℝ)+u)/2-a) :=by
apply NNReal.eq
rw [NNReal.coe_add,coe_toNNReal _ (by linarith [hs t t.property]),
coe_toNNReal _ (by linarith [hs u u.property]),coe_toNNReal _ (by linarith [hs t t.property,hs u u.property])]
ring
letκ' : s → s →ℝ→ℝ:=fun t u x => heat (toNNReal (((t:ℝ)+u)/2-a)) (κ t u) x
have hc' (t u : s) : Continuous (κ' t u) :=
continuous_heat (hκc t u) (stationary_kernel_bounded κ hK t u) _
havehp' : Matrix.PosSemidef (Matrix.of (funp q : s ×ℝ=> κ' p.1 q.1 (p.2-q.2))) :=by
change (Matrix.of (funp q : s ×ℝ=> heat (toNNReal (((p.1:ℝ)-a)/2)+toNNReal (((q.1:ℝ)-a)/2)) (κ p.1 q.1) (p.2-q.2))).PosSemidef at hp
simpa only [he,κ'] using hp
have hi (t u : s) : Integrable (κ' t u) μ :=Integrable.of_bound (hc' t u).aestronglyMeasurable _
(ae_of_all _ (stationary_kernel_bounded κ' hp' t u))
exact hμ.kernel_integral κ' hp' hc' hi (fun t u =>by dsimp only [κ',κ]; rw [add_comm (t:ℝ) (u:ℝ)])
apply ((ParisiFinite.integrable_exp_abs (M*|s|)).const_mul (C*exp (M*|x|))).mono' (by fun_prop)
filter_upwards [] with z
rw [Real.norm_eq_abs]
exact (hf _).trans (by simpa only [mul_assoc] using mul_le_mul_of_nonneg_left (exp_abs_shift_le hM x s z) hC)
have hh :=SKGaussian.integral_mul_eq_integral_deriv (f :=fun z => f (x+s*z))
(f' :=fun z => s*f' (x+s*z))
(fun z =>by simpa only [Function.comp_def,id_eq,mul_one,mul_comm] using (hd (x+s*z)).comp z (((hasDerivAt_id z).const_mul s).const_add x))
(integrable_scale_gaussian hc hM hC hf x s)
((integrable_scale_gaussian hc' hM hD hf' x s).const_mul s)
(integrable_coord_scale_gaussian hc hM hC hf x s)
simpa only [integral_const_mul] using hh
have hh := hasDerivAt_scale_prod hc hc' hd hM hC hD hf hf' hi s
havehe : (∫p : ℝ×ℝ,p.2*f' (p.1+s*p.2) ∂μ.prod (gaussianReal 01))=
s*∫p : ℝ×ℝ,f'' (p.1+s*p.2) ∂μ.prod (gaussianReal 01) :=by
rw [integral_prod _ (integrable_coord_scale_prod hc' hM hD hf' hi s),
integral_prod _ (integrable_scale_prod hc'' hM hE hf'' hi s),←integral_const_mul]
apply integral_congr_ae
filter_upwards [] with x
exact scale_gaussian_ibp hc' hc'' hd' hM hD hE hf' hf'' x s
rwa [he] at hh
have hh := (hasDerivAt_scale_prod_second hc hc' hc'' hd hd' hM hC hD hE hf hf' hf'' hi (sqrt (t-a))).comp t
(((hasDerivAt_id t).sub_const a).sqrt (sub_pos.mpr ht).ne')
simp only [id_eq] at hh
have he (I : ℝ) : (sqrt (t-a)*I)*(1/(2*sqrt (t-a)))=I/2:=by
field_simp [(sqrt_pos.mpr (sub_pos.mpr ht)).ne']
rw [he] at hh
exact hh
lemmabackwardC_log_integrable {μ : Measureℝ} [IsFiniteMeasure μ]
(hi : Integrable (funx : ℝ=> |x|) μ) {K : ℝ} (hK : 0<K) (d α t : ℝ) :
Integrable (fun x => |log (backwardC d K α t x)|) μ :=by
proof · 7
lines
havehc : Continuous (fun x => log (backwardC d K α t x)) :=by
simp only [backwardC_log d K α t _ hK]
exact continuous_const.add ((continuous_cosh.comp (continuous_const.mul continuous_id)).log (fun x => (cosh_pos _).ne'))
refine ((integrable_const |log K+α^2/2*(d-t)|).add (hi.const_mul |α|)).mono' hc.abs.aestronglyMeasurable ?_
filter_upwards [] with x
rw [Real.norm_eq_abs,abs_abs,backwardC_log d K α t x hK]
exact (abs_add_le _ _).trans (add_le_add_right (by simpa only [abs_mul] using abs_log_cosh_le (α*x)) _)
lemmahankelPD_heatLaw {μ : Measureℝ} [IsFiniteMeasure μ] (hμ : PositiveOnPD μ)
{F : ℝ→ℝ→ℝ} {a : ℝ} {s : Setℝ} (hs : ∀ t∈s,a≤t) (hsv : Convexℝ s)
(hc : ∀ t∈s,Continuous (F t))
(hK : Matrix.PosSemidef (Matrix.of (funp q : s ×ℝ=>F ((p.1+q.1)/2) (p.2-q.2)))) :
HankelPD (fun t =>∫ x,F t x ∂heatLaw μ a t) s :=by
proof · 10
lines
have hh := hankelPD_heat_observation hμ hs hsv hc hK
have he (t : ℝ) (ht : t∈s) : (∫ x,F t x ∂heatLaw μ a t)=∫ x,heat (toNNReal (t-a)) (F t) x ∂μ :=byhave hb := stationary_kernel_bounded (funu v : s =>F ((u+v)/2)) hK ⟨t,ht⟩ ⟨t,ht⟩
simp only [show (t+t)/2=t by ring] at hb
exact integral_heatLaw (Integrable.of_bound (hc t ht).aestronglyMeasurable _ (ae_of_all _ hb))
have hm (x y : s) : ((x:ℝ)+y)/2∈s :=by
simpa only [midpoint_eq_smul_add,smul_eq_mul,invOf_eq_inv,div_eq_mul_inv,mul_comm] using hsv.midpoint_mem x.property y.property
change (Matrix.of (funx y : s =>∫ z,F ((x+y)/2) z ∂heatLaw μ a ((x+y)/2))).PosSemidef
change (Matrix.of (funx y : s =>∫ z,heat (toNNReal (((x:ℝ)+y)/2-a)) (F ((x+y)/2)) z ∂μ)).PosSemidef at hh
simpa only [he _ (hm _ _)] using hh
lemmabackwardG_observation_constant {μ : Measureℝ} [IsFiniteMeasure μ]
{g : ℝ→ℝ} (hg : PositiveDefinite g) (hc : Continuous g) {a d t : ℝ}
(hat : a≤t) (htd : t≤d) :
(∫ x,backwardG d g t x ∂heatLaw μ a t)=∫ x,heat (toNNReal (d-a)) g x ∂μ :=by
proof · 10
lines
have hh := integral_heatLaw (μ := μ) (a := a) (t := t)
(Integrable.of_bound (continuous_heat hc hg.norm_le _).aestronglyMeasurable _
(ae_of_all _ fun x =>by simpa only [Real.norm_eq_abs] using hg.heat_abs_le hc (toNNReal (d-t)) x))
rw [heat_heat hc hg.norm_le] at hh
havehe : toNNReal (t-a)+toNNReal (d-t)=toNNReal (d-a) :=by
apply NNReal.eq
rw [NNReal.coe_add,coe_toNNReal _ (sub_nonneg.mpr hat),coe_toNNReal _ (sub_nonneg.mpr htd),
coe_toNNReal _ (sub_nonneg.mpr (hat.trans htd))]
ring
simpa only [backwardG,he] using hh
lemmahankelCPD_linearEntropy {μ : Measureℝ} [IsFiniteMeasure μ]
(hμ : PositiveOnPD μ) (hi : Integrable (funx : ℝ=> |x|) μ)
{g : ℝ→ℝ} (hg : PositiveDefinite g) (hc : Continuous g)
{a d Kα : ℝ} (hK : 0<K) {s : Setℝ}
(hs : ∀ t∈s,a≤t ∧ t≤d) (hsv : Convexℝ s) :
HankelCPD (fun t =>∫ x,-log (backwardC d K α t x)*backwardG d g t x ∂heatLaw μ a t) s :=by
proof · 32
lines
letF (r t : ℝ) :=∫ x,(backwardC d K α t x)^(-r)*backwardG d g t x ∂heatLaw μ a t
apply HankelCPD.of_rightQuotient (F:=F) (C:=∫ x,heat (toNNReal (d-a)) g x ∂μ) hsv
· intro r hr
apply hankelPD_heatLaw hμ (fun t ht => (hs t ht).1) hsv
· intro t ht
havehcc : Continuous (backwardC d K α t) :=by unfold backwardC; fun_prop
exact (hcc.rpow_const (fun x =>Or.inl (backwardC_pos hK _ _ _ x).ne')).mul (continuous_heat hc hg.norm_le _)
· exact (backwardC_neg_rpow hK hr s).hadamard (backwardG_reflection hg hc (fun t ht => (hs t ht).2))
· intro t ht
letL : ℝ→ℝ:=fun x => log (backwardC d K α t x)
havehLc : ContinuousL:=by
unfold L
simp only [backwardC_log d K α t _ hK]
exact continuous_const.add ((continuous_cosh.comp (continuous_const.mul continuous_id)).log (fun x => (cosh_pos _).ne'))
have hL (x : ℝ) : -|log K+α^2/2*(d-t)|≤L x :=by
dsimp only [L]
rw [backwardC_log d K α t x hK]
have:= log_nonneg (one_le_cosh (α*x))
linarith [neg_abs_le (log K+α^2/2*(d-t))]
have hh := integral_exp_rightDerivative hLc.aestronglyMeasurable
(continuous_heat hc hg.norm_le (toNNReal (d-t))).aestronglyMeasurable
(abs_nonneg (log K+α^2/2*(d-t))) hL (backwardG_bound hg hc d t)
(backwardC_log_integrable (heatLaw_firstMoment hi a t) hK d α t)
change Tendsto (fun r => ((∫ x,exp (-r*L x)*backwardG d g t x ∂heatLaw μ a t)-∫ x,backwardG d g t x ∂heatLaw μ a t)/r) (𝓝[>] (0:ℝ)) (𝓝 (∫ x,-L x*backwardG d g t x ∂heatLaw μ a t)) at hh
rw [backwardG_observation_constant hg hc (hs t ht).1 (hs t ht).2] at hh
apply hh.congr
intro r
dsimp only [F]
congr 2
apply integral_congr_ae
filter_upwards [] with x
simp only [rpow_def_of_pos (backwardC_pos hK _ _ _ _),L,mul_comm]
lemmahankelPD_entropyRemainder {μ : Measureℝ} [IsFiniteMeasure μ]
(hμ : PositiveOnPD μ) {g : ℝ→ℝ} (hg : PositiveDefinite g) (hc : Continuous g)
{a d Kα : ℝ} (hK : 0<K) (hgK : g 0<K) {s : Setℝ}
(hs : ∀ t∈s,a≤t ∧ t≤d) (hsv : Convexℝ s) :
HankelPD (fun t =>∫ x,
(backwardC d K α t x-backwardG d g t x)*log (backwardC d K α t x-backwardG d g t x)-
backwardC d K α t x*log (backwardC d K α t x)+
(1+log (backwardC d K α t x))*backwardG d g t x ∂heatLaw μ a t) s :=by
proof · 26
lines
have hcb (t : ℝ) (ht : t≤d) (x : ℝ) : K≤backwardC d K α t x :=by
unfold backwardC
havehe : 1≤exp (α^2/2*(d-t)) := one_le_exp_iff.mpr (by positivity)
havehh : K≤K*exp (α^2/2*(d-t)) :=by simpa only [mul_one] using mul_le_mul_of_nonneg_left he hK.le
exact hh.trans (le_mul_of_one_le_right (mul_pos hK (exp_pos _)).le (one_le_cosh _))
have hd (t : ℝ) (ht : t≤d) (x : ℝ) : |backwardG d g t x|<backwardC d K α t x :=
(backwardG_bound hg hc d t x).trans_lt (hgK.trans_le (hcb t ht x))
apply hankelPD_heatLaw hμ (fun t ht => (hs t ht).1) hsv
· intro t ht
havehCc : Continuous (backwardC d K α t) :=by unfold backwardC; fun_prop
have hGc := continuous_heat hc hg.norm_le (toNNReal (d-t))
havehdc : Continuous (fun x => backwardC d K α t x-backwardG d g t x) := hCc.sub hGc
have hdp (x : ℝ) : 0<backwardC d K α t x-backwardG d g t x :=byhave:= hd t (hs t ht).2 x
linarith [le_abs_self (backwardG d g t x)]
exact ((hdc.mul (hdc.log (fun x => (hdp x).ne'))).sub
(hCc.mul (hCc.log (fun x => (backwardC_pos hK _ _ _ x).ne')))).add
((continuous_const.add (hCc.log (fun x => (backwardC_pos hK _ _ _ x).ne'))).mul hGc)
· apply posSemidef_entropy_remainder
· intro p q
exact backwardC_pos hK _ _ _ _
· exact backwardG_reflection hg hc (fun t ht => (hs t ht).2)
· intro p q
exact hd _ (by linarith [(hs p.1 p.1.property).2,(hs q.1 q.1.property).2]) _
· intro n
exact backwardC_neg_rpow hK (by positivity) s