File size: 8,608 Bytes
4a56cd6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | import Mathlib
import OAI.Probability.Perceptron.Variational.DensityDerivative
import OAI.Probability.Perceptron.Variational.FieldContinuity
namespace OAI
noncomputable section
open MeasureTheory ProbabilityTheory Filter Set
open scoped Topology NNReal ENNReal BigOperators BoundedContinuousFunction
namespace SphericalPerceptronFreeEnergy
lemma poissonRealMean_increment_bound (F : βββ) {C : β} (hC : 0β€C)
(hF : β M, |F (M+1)-F M|β€C) (r : ββ₯0) :
|poissonRealMean (fun M => F (M+1)-F M) r|β€C := by
have hinc (M) : |(F (M+2)-F (M+1))-(F (M+1)-F M)|β€2*C := by
exact (abs_sub _ _).trans (by linarith [hF M,hF (M+1)])
rw [poissonRealMean_eq_integral (by positivity : 0β€2*C) hinc r]
simpa only [Real.norm_eq_abs,probReal_univ,mul_one] using norm_integral_le_of_norm_le_const
(ΞΌ := poissonMeasure r) (f := fun M => F (M+1)-F M)
(ae_of_all _ fun M => by simpa only [Real.norm_eq_abs] using hF M)
lemma poissonRealMean_lipschitz_bound (F : βββ) {C : β} (hC : 0β€C)
(hF : β M, |F (M+1)-F M|β€C) (s t : ββ₯0) :
|poissonRealMean F t-poissonRealMean F s|β€C*|(t:β)-(s:β)| := by
have hb : β r β Ici (0:β), βderiv (poissonRealMean F) rββ€C := by
intro r hr
rw [(hasDerivAt_poissonRealMean hC hF r).deriv,Real.norm_eq_abs]
exact poissonRealMean_increment_bound F hC hF β¨r,hrβ©
simpa only [Real.norm_eq_abs] using Convex.norm_image_sub_le_of_norm_deriv_le
(fun r (_ : rβIci (0:β)) => (hasDerivAt_poissonRealMean hC hF r).differentiableAt)
hb (convex_Ici (0:β)) s.coe_nonneg t.coe_nonneg
lemma sourceExpectedPressure_density_comparison (n k : β) (f : β βα΅ β) (p d : Fin (n+1)ββ)
(h : Fin (k+1)ββ) (z : Fin kββ) (u : Fin (n+1)ββ)
(hz : StrictMono z) (hz0 : β i, 0<z i) (hz1 : β i, z i<1) (s t : ββ₯0) :
|sourceExpectedPressure n k f p d h z t u-sourceExpectedPressure n k f p d h z s u|β€
βfβ*|(t:β)-(s:β)| := by
have hB := poissonRealMean_lipschitz_bound (sourceCountExpectedLog n k f p d h z u)
(norm_nonneg f) (sourceCountExpectedLog_increment n k f p d h z u hz hz0 hz1)
((n+1:β)*s) ((n+1:β)*t)
simp only [sourceExpectedPressure_poissonMean n k f p d h z u hz hz0 hz1]
rw [β mul_sub,abs_mul,abs_of_nonneg (by positivity : (0:β)β€1/(n+1:β))]
calc
_ β€ (1/(n+1:β))*(βfβ*|(((n+1:β)*t:ββ₯0):β)-(((n+1:β)*s:ββ₯0):β)|) :=
mul_le_mul_of_nonneg_left hB (by positivity)
_ = _ := by
simp only [NNReal.coe_mul,NNReal.coe_natCast]
rw [β mul_sub,abs_mul,abs_of_nonneg (Nat.cast_nonneg (n+1))]
field_simp
lemma enrichedFeatureBound_continuous (N : β) :
Continuous (fun u : Fin Nββ => (enrichedFeatureBound N u:β)) := by
change Continuous (fun u : Fin Nββ => Real.sqrt ((N:β)+β j, perturbationAmplitude N u j^2))
unfold perturbationAmplitude
fun_prop
lemma sourceFieldDistance_joint_continuous {N k : β} (p d : Fin Nββ)
(h : Fin (k+1)ββ) : Continuous (fun a : (Fin Nββ)Γ(Fin (k+1)ββ) =>
sourceFieldDistance p d a.1 a.2 h) := by
have hc := (sourceFieldCoefficients_continuous (k := k) p d).comp
(continuous_snd : Continuous (fun a : (Fin Nββ)Γ(Fin (k+1)ββ) => a.2))
have he : Continuous (fun a : (Fin Nββ)Γ(Fin (k+1)ββ) => indexedCoefficientSquare k
(fun l i => sourceFieldCoefficients p d a.2 l i-sourceFieldCoefficients p d h l i)) := by
simpa only [Function.comp_def,Pi.sub_def] using
(indexedCoefficientSquare_continuous (I := EnrichedIndex N N p) k).comp
(hc.sub (continuous_const (y := sourceFieldCoefficients p d h)))
have hf := (enrichedFeatureBound_continuous N).comp
(continuous_fst : Continuous (fun a : (Fin Nββ)Γ(Fin (k+1)ββ) => a.1))
unfold sourceFieldDistance
exact (continuous_const.mul (continuous_const.mul
(((continuous_const.mul (continuous_const.mul (hf.pow 2))).add
(continuous_const.mul (he.mul (hf.pow 2)))).sqrt.mul
(he.mul (hf.pow 2)).sqrt))).add
(((continuous_apply _).comp continuous_snd).sub continuous_const).abs
abbrev SourceContactParameter (n k : β) := ββ₯0 Γ (Fin (k+1)ββ) Γ (Fin (n+1)ββ)
def sourceContactDomain (n k : β) : Set (SourceContactParameter n k) :=
{a | (β l, 0β€a.2.1 l) β§ Monotone a.2.1 β§ β j, a.2.2 jβIcc 1 2}
def sourceJointPressure (n k : β) (f : β βα΅ β) (p d : Fin (n+1)ββ)
(z : Fin kββ) (a : SourceContactParameter n k) : β :=
sourceExpectedPressure n k f p d a.2.1 z a.1 a.2.2
def sourceContactDistance (n k : β) (f : β βα΅ β) (p d : Fin (n+1)ββ)
(a' a : SourceContactParameter n k) : β :=
βfβ*|(a'.1:β)-(a.1:β)|+sourceFieldDistance p d a'.2.2 a'.2.1 a.2.1+
β j : Fin (n+1), (4*perturbationAmplitude (n+1) (fun _ => 1) j^2/(n+1:β))*|a'.2.2 j-a.2.2 j|
lemma sourceContactDistance_continuous (n k : β) (f : β βα΅ β) (p d : Fin (n+1)ββ)
(a : SourceContactParameter n k) : Continuous (fun a' => sourceContactDistance n k f p d a' a) := by
unfold sourceContactDistance
have hf : Continuous (fun a' : SourceContactParameter n k => sourceFieldDistance p d a'.2.2 a'.2.1 a.2.1) :=
(sourceFieldDistance_joint_continuous (N := n+1) (k := k) p d a.2.1).comp
(f := fun a' : SourceContactParameter n k => (a'.2.2,a'.2.1))
((continuous_snd.snd : Continuous (fun a' : SourceContactParameter n k => a'.2.2)).prodMk
(continuous_snd.fst : Continuous (fun a' : SourceContactParameter n k => a'.2.1)))
apply Continuous.add
Β· have ht : Continuous (fun a' : SourceContactParameter n k => βfβ*|(a'.1:β)-(a.1:β)|) := by
exact continuous_const.mul ((NNReal.continuous_coe.comp
(continuous_fst : Continuous (fun a' : SourceContactParameter n k => a'.1))).sub continuous_const).abs
exact ht.add hf
Β· apply continuous_finsetSum
intro j hj
fun_prop
lemma sourceContactDistance_self (n k : β) (f : β βα΅ β) (p d : Fin (n+1)ββ)
(a : SourceContactParameter n k) : sourceContactDistance n k f p d a a=0 := by
simp [sourceContactDistance,sourceFieldDistance_self]
lemma sourceJointPressure_comparison (n k : β) (f : β βα΅ β) (p d : Fin (n+1)ββ)
(z : Fin kββ) (hz : StrictMono z) (hz0 : β i, 0<z i) (hz1 : β i,z i<1)
(a' a : SourceContactParameter n k) (ha' : a'βsourceContactDomain n k) (ha : aβsourceContactDomain n k) :
|sourceJointPressure n k f p d z a'-sourceJointPressure n k f p d z a|β€
sourceContactDistance n k f p d a' a := by
have ht := sourceExpectedPressure_density_comparison n k f p d a'.2.1 z a'.2.2 hz hz0 hz1 a.1 a'.1
have hh := sourceExpectedPressure_field_comparison n k f p d a'.2.2 a'.2.1 a.2.1 z hz hz0 hz1 a.1
have hu := sourceExpectedPressure_box_comparison n k f p d a.2.1 ha.1 ha.2.1 z hz hz0 hz1 a.1
(u := a.2.2) (v := a'.2.2) (fun j => β¨by linarith [(ha.2.2 j).1],(ha.2.2 j).2β©)
(fun j => β¨by linarith [(ha'.2.2 j).1],(ha'.2.2 j).2β©)
change |sourceExpectedPressure n k f p d a'.2.1 z a'.1 a'.2.2-
sourceExpectedPressure n k f p d a.2.1 z a.1 a.2.2|β€_
have hab := abs_sub_le (sourceExpectedPressure n k f p d a'.2.1 z a'.1 a'.2.2)
(sourceExpectedPressure n k f p d a'.2.1 z a.1 a'.2.2)
(sourceExpectedPressure n k f p d a.2.1 z a.1 a.2.2)
have hbc := abs_sub_le (sourceExpectedPressure n k f p d a'.2.1 z a.1 a'.2.2)
(sourceExpectedPressure n k f p d a.2.1 z a.1 a'.2.2)
(sourceExpectedPressure n k f p d a.2.1 z a.1 a.2.2)
change |sourceExpectedPressure n k f p d a.2.1 z a.1 a'.2.2-
sourceExpectedPressure n k f p d a.2.1 z a.1 a.2.2|β€_ at hu
unfold sourceContactDistance
linarith
lemma sourceJointPressure_continuousOn (n k : β) (f : β βα΅ β) (p d : Fin (n+1)ββ)
(z : Fin kββ) (hz : StrictMono z) (hz0 : β i, 0<z i) (hz1 : β i,z i<1) :
ContinuousOn (sourceJointPressure n k f p d z) (sourceContactDomain n k) := by
intro a ha
apply tendsto_iff_norm_sub_tendsto_zero.mpr
have hc : Tendsto (fun a' => sourceContactDistance n k f p d a' a) (π a)
(π (sourceContactDistance n k f p d a a)) :=
(sourceContactDistance_continuous n k f p d a).continuousAt
rw [sourceContactDistance_self] at hc
refine squeeze_zero' (Eventually.of_forall fun _ => norm_nonneg _) ?_
(hc.mono_left nhdsWithin_le_nhds)
filter_upwards [self_mem_nhdsWithin] with a' ha'
simpa only [Real.norm_eq_abs] using sourceJointPressure_comparison n k f p d z hz hz0 hz1 a' a ha' ha
end SphericalPerceptronFreeEnergy
end
end OAI
|