File size: 8,865 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 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 | import Mathlib
import OAI.Probability.GaussianRegression.Main
import OAI.Probability.MemoryPrecision.FiniteDensity
import OAI.Probability.MemoryPrecision.KernelModel
import OAI.Probability.MemoryPrecision.LabelTranslations
namespace OAI
open MeasureTheory ProbabilityTheory Set Filter EuclideanGeometry
open scoped ENNReal NNReal RealInnerProductSpace Topology Pointwise
noncomputable section
universe u v
open MeasureTheory ProbabilityTheory Set Filter
open scoped ENNReal NNReal RealInnerProductSpace Topology Pointwise
namespace MemoryPrecision
open NoiselessRegression
def UniformSphere (d : β) : @Measure (Space d)
(WithLp.measurableSpace
(@OfNat.ofNat ββ₯0β 2
(@instOfNatAtLeastTwo ββ₯0β 2 ENNReal.instAddCommMonoidWithOne.toNatCast
(Mathlib.Meta.NormNum.instAtLeastTwo (nat_lit 0)))) (Fin d β β)) :=
let euclideanMeasurable := WithLp.measurableSpace
(@OfNat.ofNat ββ₯0β 2
(@instOfNatAtLeastTwo ββ₯0β 2 ENNReal.instAddCommMonoidWithOne.toNatCast
(Mathlib.Meta.NormNum.instAtLeastTwo (nat_lit 0)))) (Fin d β β)
@Measure.map (Kernel.Sphere d) (Space d)
(MeasurableSpace.comap Subtype.val euclideanMeasurable) euclideanMeasurable
Subtype.val (Kernel.UniformSphere d)
def GaussianRegularization {d : β}
(ΞΌ : @Measure (Space d)
(WithLp.measurableSpace
(@OfNat.ofNat ββ₯0β 2
(@instOfNatAtLeastTwo ββ₯0β 2 ENNReal.instAddCommMonoidWithOne.toNatCast
(Mathlib.Meta.NormNum.instAtLeastTwo (nat_lit 0)))) (Fin d β β)))
(m : β) (Ξ΄ : β)
(Ay : (Fin m β Space d) Γ (Fin m β β)) : β :=
let exponent : ββ₯0β := @OfNat.ofNat ββ₯0β 2
(@instOfNatAtLeastTwo ββ₯0β 2 ENNReal.instAddCommMonoidWithOne.toNatCast
(Mathlib.Meta.NormNum.instAtLeastTwo (nat_lit 0)))
letI : MeasurableSpace (Space d) := WithLp.measurableSpace exponent (Fin d β β)
β« signal, β index, gaussianPDFReal 0 β¨Ξ΄^2, sq_nonneg Ξ΄β©
(Ay.2 index - @inner β (Space d)
(@InnerProductSpace.toInner β (Space d) _
(PiLp.seminormedAddCommGroup exponent (fun _ : Fin d => β))
(PiLp.innerProductSpace (π := β) (fun _ : Fin d => β)))
signal (Ay.1 index)) βΞΌ
lemma gaussianPDF_zero_sub_comm (v : ββ₯0) (a b : β) :
gaussianPDF 0 v (a-b) = gaussianPDF 0 v (b-a) := by
simp only [gaussianPDF, gaussianPDFReal, sub_zero]
congr 4
ring
lemma GaussianRegularization_eq_toReal {d : β} (ΞΌ : Measure (Space d))
[IsFiniteMeasure ΞΌ] (m : β) (Ξ΄ : β)
(x : (Fin m β Space d) Γ (Fin m β β)) :
GaussianRegularization ΞΌ m Ξ΄ x =
(projectionSmoothing ΞΌ (gaussianPDF 0 β¨Ξ΄^2,sq_nonneg Ξ΄β©) m x).toReal := by
let v : ββ₯0 := β¨Ξ΄^2,sq_nonneg Ξ΄β©
change (β« s, β j, gaussianPDFReal 0 v (x.2 j - βͺs,x.1 jβ«) βΞΌ) = _
have hn : β s : Space d, 0 β€ β j, gaussianPDFReal 0 v (x.2 j - βͺs,x.1 jβ«) :=
fun s => Finset.prod_nonneg (fun _ _ => gaussianPDFReal_nonneg _ _ _)
have hm : Measurable (fun s : Space d => β j, gaussianPDFReal 0 v (x.2 j - βͺs,x.1 jβ«)) := by
fun_prop
rw [integral_eq_lintegral_of_nonneg_ae (Eventually.of_forall hn) hm.aestronglyMeasurable]
unfold projectionSmoothing
congr 1
apply lintegral_congr
intro s
rw [ENNReal.ofReal_prod_of_nonneg (fun _ _ => gaussianPDFReal_nonneg _ _ _)]
rfl
lemma GaussianRegularization_ae_eq_average {d : β} (ΞΌ : Measure (Space d))
[IsFiniteMeasure ΞΌ] (m : β)
(F : ((Fin m β Space d) Γ (Fin m β β)) β β)
(hF : Measurable F) (hF0 : β x, 0 β€ F x)
(hden : (MatrixLabelReference d m).withDensity (fun x => ENNReal.ofReal (F x)) =
ProjectionLaw ΞΌ m) (Ξ΄ : β) (hΞ΄ : Ξ΄ β 0) :
GaussianRegularization ΞΌ m Ξ΄ =α΅[MatrixLabelReference d m]
averageTranslate (Measure.pi (fun _ : Fin m => gaussianReal 0 1)) Ξ΄ F := by
have he := projectionSmoothing_ae_eq_fiberSmoothing ΞΌ m
(fun x => ENNReal.ofReal (F x)) hF.ennreal_ofReal hden
(gaussianPDF 0 β¨Ξ΄^2,sq_nonneg Ξ΄β©) (measurable_gaussianPDF _ _)
filter_upwards [he] with x hx
rw [GaussianRegularization_eq_toReal, hx]
unfold averageTranslate
rw [integral_eq_lintegral_of_nonneg_ae (Eventually.of_forall (fun u => hF0 _))
((hF.comp (by fun_prop)).aestronglyMeasurable)]
congr 1
change fiberSmoothing volume (fun x => ENNReal.ofReal (F x))
(fun y : Fin m β β => β j, gaussianPDF 0 _ (y j)) x =
β«β» u : Fin m β β, ENNReal.ofReal (F (x.1,fun j => x.2 j + Ξ΄ * u j))
βMeasure.pi (fun _ => gaussianReal 0 1)
rw [lintegral_gaussian_shift_scale m Ξ΄ hΞ΄ x.2 (fun y => ENNReal.ofReal (F (x.1,y)))
(by fun_prop)]
apply lintegral_congr
intro y
congr 1
apply Finset.prod_congr rfl
intro j _
exact gaussianPDF_zero_sub_comm _ _ _
lemma memLp_density_of_finite {X : Type*} [MeasurableSpace X]
(Ξ½β Ξ· : Measure X) [IsFiniteMeasure Ξ·] {F : X β β}
(hFm : Measurable F) (hF0 : β x, 0 β€ F x)
(hden : Ξ½β.withDensity (fun x => ENNReal.ofReal (F x)) = Ξ·) :
MemLp F 1 Ξ½β := by
rw [memLp_iff, eLpNorm_one_eq_lintegral_enorm hFm.aestronglyMeasurable]
have he : (fun x => βF xββ) = (fun x => ENNReal.ofReal (F x)) := by
funext x
exact Real.enorm_eq_ofReal (hF0 x)
rw [he]
have he2 := congrArg (fun Ξ½ : Measure X => Ξ½ Set.univ) hden
rw [withDensity_apply _ MeasurableSet.univ, Measure.restrict_univ] at he2
rw [he2]
exact measure_lt_top _ _
lemma density_ae_unique_real {X : Type*} [MeasurableSpace X]
(Ξ½β : Measure X) [SigmaFinite Ξ½β] {F G : X β β}
(hFm : Measurable F) (hF0 : β x, 0 β€ F x)
(hGm : Measurable G) (hG0 : β x, 0 β€ G x)
(hden : Ξ½β.withDensity (fun x => ENNReal.ofReal (F x)) =
Ξ½β.withDensity (fun x => ENNReal.ofReal (G x))) : F =α΅[Ξ½β] G := by
have he := (withDensity_eq_iff_of_sigmaFinite hFm.ennreal_ofReal.aemeasurable
hGm.ennreal_ofReal.aemeasurable).mp hden
filter_upwards [he] with x hx
exact (ENNReal.ofReal_eq_ofReal_iff (hF0 x) (hG0 x)).mp hx
def JointL1Statement : Prop :=
let two : β := @OfNat.ofNat β 2 (@instOfNatAtLeastTwo β 2 Real.commRing.toNatCast
(Mathlib.Meta.NormNum.instAtLeastTwo (nat_lit 0)))
let exponent : ββ₯0β := @OfNat.ofNat ββ₯0β 2
(@instOfNatAtLeastTwo ββ₯0β 2 ENNReal.instAddCommMonoidWithOne.toNatCast
(Mathlib.Meta.NormNum.instAtLeastTwo (nat_lit 0)))
β d m p : β,
letI : MeasurableSpace (Space d) := WithLp.measurableSpace exponent (Fin d β β)
2 β€ d β 1 β€ m β m < d β 2 β€ p β
β Ξ² H R : β, (m : β)+(p : β)-two < Ξ² β 0 < H β 0 < R β
β z : Space d, β ΞΌ : Measure (Space d), IsFiniteMeasure ΞΌ β
@Measure.support (Space d)
(PiLp.topologicalSpace (p := exponent) (Ξ² := fun _ : Fin d => β))
(WithLp.measurableSpace exponent (Fin d β β)) ΞΌ β
@Metric.closedBall (Space d)
(PiLp.instPseudoMetricSpace (p := exponent) (Ξ² := fun _ : Fin d => β)) z R β
AmbientBallBound ΞΌ H Ξ² β
ΞΌ βͺ UniformSphere d β
β F : ((Fin m β Space d) Γ (Fin m β β)) β β,
Measurable F β (β x, 0 β€ F x) β
(MatrixLabelReference d m).withDensity (fun x => ENNReal.ofReal (F x)) =
ProjectionLaw ΞΌ m β
Tendsto (fun Ξ΄ => eLpNorm (fun Ay => GaussianRegularization ΞΌ m Ξ΄ Ay - F Ay)
1 (MatrixLabelReference d m)) (π[Set.Ioi 0] 0) (π 0) β§
eLpNorm F (p : ββ₯0β) (MatrixLabelReference d m) β€
ENNReal.ofReal (ProjectionNormScale m p H Ξ² R)
theorem joint_l1 : JointL1Statement := by
intro d m p hd hm hmd hp Ξ² H R hgap hH hR z ΞΌ hΞΌ hs hb hac F hFm hF0 hden
have : IsFiniteMeasure ΞΌ := hΞΌ
have : IsFiniteMeasure (ProjectionLaw ΞΌ m) := by unfold ProjectionLaw; infer_instance
have : SigmaFinite (MatrixLabelReference d m) := by unfold MatrixLabelReference; infer_instance
have hF := memLp_density_of_finite (MatrixLabelReference d m) (ProjectionLaw ΞΌ m) hFm hF0 hden
constructor
Β· have ht := tendsto_eLpNorm_averageTranslate_sub
(Measure.pi (fun _ : Fin m => stdGaussian (Space d)))
(volume : Measure (Fin m β β))
(Measure.pi (fun _ : Fin m => gaussianReal 0 1)) hFm hF
apply (ht.mono_left nhdsWithin_le_nhds).congr'
filter_upwards [self_mem_nhdsWithin] with Ξ΄ hΞ΄
apply eLpNorm_congr_ae
filter_upwards [GaussianRegularization_ae_eq_average ΞΌ m F hFm hF0 hden Ξ΄
(ne_of_gt hΞ΄)] with x hx
exact congrArg (fun t => t - F x) hx.symm
Β· obtain β¨G,hGm,hG0,hGden,hGs,hGnormβ© :=
exact_finite_density d m p hp hm Ξ² H R hgap hH hR z ΞΌ hs hb
have he := density_ae_unique_real (MatrixLabelReference d m) hFm hF0 hGm hG0
(hden.trans hGden.symm)
exact (eLpNorm_congr_ae he).symm βΈ hGnorm
end MemoryPrecision
end
end OAI
|