math / data /lean /OAI /Probability /MemoryPrecision /CoefficientStep.lean
introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
3.65 kB
import Mathlib
import OAI.Probability.GaussianRegression.Main
import OAI.Probability.MemoryPrecision.KernelModel
import OAI.Probability.MemoryPrecision.WeightedImage
import OAI.Probability.MemoryPrecision.WeightedSelection
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
abbrev Sphere (d : β„•) := Metric.sphere (0 : Space d) 1
def SpherePrior (d : β„•) : Measure (Sphere d) :=
MemoryPrecision.Kernel.UniformSphere d
def SphereBallBound {d : β„•} (h : Sphere d β†’ ℝβ‰₯0∞) (H Ξ± : ℝ) : Prop :=
βˆ€ z : Space d, βˆ€ r : ℝ, 0 < r β†’
(∫⁻ s in {s : Sphere d | dist s.val z ≀ r}, h s βˆ‚SpherePrior d) ≀
ENNReal.ofReal (H * r^Ξ±)
def SphereBlock {d m N : β„•} (h : Fin N β†’ Sphere d β†’ ℝβ‰₯0∞)
(g : Fin N β†’ ((Fin m β†’ Space d) Γ— (Fin m β†’ ℝ)) β†’ ℝβ‰₯0∞)
(s : Sphere d) : ℝβ‰₯0∞ :=
WeightedBlock Subtype.val h g s
def CoefficientStepStatement : Prop :=
let two : ℝ := @OfNat.ofNat ℝ 2 (@instOfNatAtLeastTwo ℝ 2 Real.commRing.toNatCast
(Mathlib.Meta.NormNum.instAtLeastTwo (nat_lit 0)))
βˆƒ C : ℝ, 1 ≀ C ∧ βˆ€ d m N : β„•, 16 ≀ d β†’
1 ≀ m β†’ m ≀ d/8 β†’ 1 ≀ N β†’
βˆ€ Ξ± H : ℝ, ((d:ℝ)-1)/two ≀ Ξ± β†’ Ξ± ≀ (d:ℝ)/two β†’ 0 < H β†’
βˆ€ h : Fin N β†’ Sphere d β†’ ℝβ‰₯0∞,
(βˆ€ w, Measurable (h w)) β†’ (βˆ€ w s, h w s ≀ 1) β†’
(βˆ€ w, SphereBallBound (h w) H Ξ±) β†’
βˆ€ g : Fin N β†’ ((Fin m β†’ Space d) Γ— (Fin m β†’ ℝ)) β†’ ℝβ‰₯0∞,
(βˆ€ w, Measurable (g w)) β†’ (βˆ€ x, βˆ‘ w, g w x ≀ 1) β†’
SphereBallBound (SphereBlock h g) (C^d * (N:ℝ)^(1/((d/8:β„•):ℝ)) * H) Ξ±
theorem coefficient_step : CoefficientStepStatement := by
refine ⟨1344, by norm_num, ?_⟩
intro d m N hd hm hmp hN Ξ± H hΞ±lo hΞ±hi hH h hh hh1 hb g hg hgsum z r hr
have : NeZero d := ⟨by omega⟩
have : IsProbabilityMeasure (SpherePrior d) :=
(show IsProbabilityMeasure (NoiselessRegression.sphereLaw (E := Space d)) from inferInstance)
let Ξ½ (w : Fin N) := ((SpherePrior d).withDensity (h w)).map Subtype.val
let (w : Fin N) : IsFiniteMeasure (Ξ½ w) :=
weighted_image_finite (SpherePrior d) Subtype.val (h w) (hh1 w)
have hΞ½ (w) : AmbientBallBound (Ξ½ w) H Ξ± := by
intro x ρ hρ
rw [show Ξ½ w = ((SpherePrior d).withDensity (h w)).map Subtype.val from rfl,
weighted_image_ball _ measurable_subtype_coe]
exact hb w x ρ hρ
have hp : 2 ≀ d/8 := by omega
have hmd : m ≀ d := hmp.trans (Nat.div_le_self _ _)
have hgap : (m:ℝ)+((d/8:β„•):ℝ)-2 < Ξ± := by
have hm' : (m:ℝ) ≀ (d/8:β„•) := by exact_mod_cast hmp
have hp' : ((d/8:β„•):ℝ)*8 ≀ d := by exact_mod_cast Nat.div_mul_le_self d 8
have hd' : (16:ℝ) ≀ d := by exact_mod_cast hd
linarith
have hJ := fun j hj => (specialized_J_bound d m (d/8) hd rfl hm hmp Ξ± hΞ±lo hΞ±hi j hj).2.2
have hsel := localized_weighted_selection Ξ½ hp hm hmd (by norm_num : (1:ℝ) ≀ 7)
hH hgap hJ hΞ½ g hg hgsum z hr
have he := weightedBlock_mass_identity (SpherePrior d) measurable_subtype_coe hh hh1 hg
(show MeasurableSet (Metric.closedBall z r) from Metric.isClosed_closedBall.measurableSet)
change (∫⁻ s in Subtype.val ⁻¹' Metric.closedBall z r,
WeightedBlock Subtype.val h g s βˆ‚SpherePrior d) ≀ _
rw [he]
convert hsel using 1
norm_num [Ξ½, mul_assoc]
end MemoryPrecision
end
end OAI