introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
8.87 kB
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