introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
21.2 kB
import OAI.Probability.GaussianRegression.Projection
import OAI.Probability.GaussianRegression.Support
namespace OAI
/-!
Localization, finite selection, and block mass propagation.
-/
open MeasureTheory ProbabilityTheory Set Filter
open scoped ENNReal NNReal RealInnerProductSpace Topology
open InnerProductSpace
open scoped Pointwise
noncomputable section
universe u
namespace NoiselessRegression
section Block
variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E]
[FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E]
def PolynomialMass (Ξ½ : Measure E) (a : β„•) (C : ℝβ‰₯0∞) : Prop :=
βˆ€ z : E, βˆ€ r : ℝ, 0 < r β†’ Ξ½ (Metric.closedBall z r) ≀ C * ENNReal.ofReal (r^a)
def localNormalize (Ξ½ : Measure E) (a : β„•) (C : ℝβ‰₯0∞) (z : E) (r : ℝ) : Measure E :=
(C * ENNReal.ofReal (r^a))⁻¹ β€’ (Ξ½.restrict (Metric.closedBall z r)).map (fun x => r⁻¹ β€’ (x-z))
omit [FiniteDimensional ℝ E] in
lemma localNormalize_univ {Ξ½ : Measure E} {a : β„•} {C : ℝβ‰₯0∞}
(hΞ½ : PolynomialMass Ξ½ a C) (hC : C β‰  0) (hCt : C β‰  ∞) (z : E) {r : ℝ} (hr : 0 < r) :
localNormalize Ξ½ a C z r univ ≀ 1 := by
have hc0 : C * ENNReal.ofReal (r^a) β‰  0 := mul_ne_zero hC (by positivity)
have hct : C * ENNReal.ofReal (r^a) β‰  ∞ := ENNReal.mul_ne_top hCt ENNReal.ofReal_ne_top
simp only [localNormalize, Measure.smul_apply, smul_eq_mul, Measure.map_apply (by fun_prop : Measurable (fun x : E => r⁻¹ β€’ (x-z))) MeasurableSet.univ,
Set.preimage_univ, Measure.restrict_apply MeasurableSet.univ, Set.univ_inter]
exact (mul_le_mul' le_rfl (hΞ½ z r hr)).trans_eq (ENNReal.inv_mul_cancel hc0 hct)
omit [FiniteDimensional ℝ E] in
lemma localNormalize_finite {Ξ½ : Measure E} {a : β„•} {C : ℝβ‰₯0∞}
(hΞ½ : PolynomialMass Ξ½ a C) (hC : C β‰  0) (hCt : C β‰  ∞) (z : E) {r : ℝ} (hr : 0 < r) :
IsFiniteMeasure (localNormalize Ξ½ a C z r) :=
⟨(localNormalize_univ hν hC hCt z hr).trans_lt (by simp)⟩
omit [FiniteDimensional ℝ E] in
lemma localNormalize_support (Ξ½ : Measure E) (a : β„•) (C : ℝβ‰₯0∞) (z : E) {r : ℝ} (hr : 0 < r) :
(localNormalize Ξ½ a C z r).support βŠ† Metric.closedBall 0 1 := by
apply Measure.support_subset_of_isClosed Metric.isClosed_closedBall
rw [mem_ae_iff, localNormalize, Measure.smul_apply, Measure.map_apply (by fun_prop)
Metric.isClosed_closedBall.measurableSet.compl,
Measure.restrict_apply ((by fun_prop : Measurable (fun x : E => r⁻¹ β€’ (x-z)))
Metric.isClosed_closedBall.measurableSet.compl)]
have he : (fun x : E => r⁻¹ β€’ (x-z)) ⁻¹' (Metric.closedBall 0 1)ᢜ ∩ Metric.closedBall z r = βˆ… := by
apply Set.eq_empty_iff_forall_notMem.mpr
intro x ⟨hx,hb⟩
apply hx
rw [Metric.mem_closedBall, dist_zero_right, norm_smul, Real.norm_eq_abs, abs_of_pos (inv_pos.mpr hr)]
exact (inv_mul_le_iffβ‚€ hr).2 (by simpa [dist_eq_norm] using hb)
rw [he, measure_empty, smul_zero]
omit [FiniteDimensional ℝ E] in
lemma localNormalize_local {Ξ½ : Measure E} {a : β„•} {C : ℝβ‰₯0∞}
(hΞ½ : PolynomialMass Ξ½ a C) (hC : C β‰  0) (hCt : C β‰  ∞) (z : E) {r : ℝ} (hr : 0 < r) :
HasLocalMassBound (localNormalize Ξ½ a C z r) (a : ℝ) := by
have hc0 : C * ENNReal.ofReal (r^a) β‰  0 := mul_ne_zero hC (by positivity)
have hct : C * ENNReal.ofReal (r^a) β‰  ∞ := ENNReal.mul_ne_top hCt ENNReal.ofReal_ne_top
intro t _ ρ hρ
rw [localNormalize, Measure.smul_apply, smul_eq_mul,
Measure.map_apply (by fun_prop) Metric.isClosed_closedBall.measurableSet]
have hsub : (fun x : E => r⁻¹ β€’ (x-z)) ⁻¹' Metric.closedBall t ρ βŠ†
Metric.closedBall (z + r β€’ t) (r*ρ) := by
intro x hx
have he : x - (z+r β€’ t) = r β€’ (r⁻¹ β€’ (x-z) - t) := by
rw [smul_sub, smul_smul, mul_inv_cancelβ‚€ hr.ne', one_smul]
abel
rw [Metric.mem_closedBall, dist_eq_norm, he, norm_smul, Real.norm_eq_abs, abs_of_pos hr]
exact mul_le_mul_of_nonneg_left (by simpa only [Set.mem_preimage, Metric.mem_closedBall, dist_eq_norm] using hx) hr.le
calc
_ ≀ (C * ENNReal.ofReal (r^a))⁻¹ * Ξ½ (Metric.closedBall (z+r β€’ t) (r*ρ)) :=
mul_le_mul' le_rfl ((Measure.restrict_le_self _).trans (measure_mono hsub))
_ ≀ (C * ENNReal.ofReal (r^a))⁻¹ * (C * ENNReal.ofReal ((r*ρ)^a)) :=
mul_le_mul' le_rfl (hν _ _ (mul_pos hr hρ))
_ = ENNReal.ofReal (ρ^(a : ℝ)) := by
rw [mul_pow, ENNReal.ofReal_mul (pow_nonneg hr.le a), ← mul_assoc C,
← mul_assoc, ENNReal.inv_mul_cancel hc0 hct, one_mul, Real.rpow_natCast]
omit [FiniteDimensional ℝ E] [BorelSpace E] in
lemma replicaConstant_le {Ξ½ : Measure E} (hΞ½ : Ξ½ univ ≀ 1) {a m : β„•}
(hd : 1 ≀ Module.finrank ℝ E) (ha : a ≀ Module.finrank ℝ E) (hm : m ≀ Module.finrank ℝ E) :
replicaConstant Ξ½ (a : ℝ) m ≀ (128 : ℝβ‰₯0∞) ^ Module.finrank ℝ E := by
let d := Module.finrank ℝ E
have h2 : (2 : ℝβ‰₯0∞) ≀ 2^d := by simpa using pow_le_pow_rightβ‚€ (by norm_num : (1 : ℝβ‰₯0∞) ≀ 2) hd
have hp : (2 : ℝβ‰₯0∞)^(m+1) ≀ 4^d := by
rw [pow_succ]
calc
_ ≀ (2 : ℝβ‰₯0∞)^d * 2^d := mul_le_mul' (pow_le_pow_rightβ‚€ (by norm_num) hm) h2
_ = _ := by rw [← mul_pow]; norm_num
calc
replicaConstant Ξ½ (a : ℝ) m ≀ 1 + (4 : ℝβ‰₯0∞)^d * 4^d * 4^d := by
unfold replicaConstant
rw [Real.rpow_natCast, ENNReal.ofReal_mul (by positivity), ENNReal.ofReal_pow (by norm_num),
ENNReal.ofReal_pow (by norm_num)]
norm_num only [ENNReal.ofReal_ofNat]
gcongr <;> norm_num
_ = 1 + (64 : ℝβ‰₯0∞)^d := by rw [mul_assoc, ← mul_pow, ← mul_pow]; norm_num
_ ≀ (2 : ℝβ‰₯0∞) * 64^d := by
rw [two_mul]
exact add_le_add (one_le_powβ‚€ (by norm_num)) le_rfl
_ ≀ (2 : ℝβ‰₯0∞)^d * 64^d := mul_le_mul' h2 le_rfl
_ = _ := by rw [← mul_pow]; norm_num; rfl
lemma projectionLaw_uniform_set_bound {Ξ½ : Measure E} [IsFiniteMeasure Ξ½]
{a m n : β„•} (hΞ½ : HasLocalMassBound Ξ½ (a : ℝ)) (hΞ½1 : Ξ½ univ ≀ 1)
(hsupport : Ξ½.support βŠ† Metric.closedBall 0 1)
(hd : 1 ≀ Module.finrank ℝ E) (ha : a ≀ Module.finrank ℝ E) (hm : m ≀ Module.finrank ℝ E)
(hn : 1 ≀ n) (hmargin : n+m ≀ a) (S : Set ((Fin m β†’ E) Γ— (Fin m β†’ ℝ))) :
projectionLaw Ξ½ m S ≀ (128 : ℝβ‰₯0∞) ^ Module.finrank ℝ E *
(matrixLabelReference (E := E) m S)^(1 - 1 / ((n : ℝ)+1)) := by
apply (projectionLaw_set_bound hΞ½ hsupport m n hn (by exact_mod_cast hmargin) S).trans
apply mul_le_mul' _ le_rfl
have hn0 : (0 : ℝ) < n+1 := by positivity
calc
_ ≀ (((128 : ℝβ‰₯0∞)^Module.finrank ℝ E) ^ n)^(1 / ((n : ℝ)+1)) := by
apply ENNReal.rpow_le_rpow _ (by positivity)
simpa only [one_mul] using mul_le_mul' hΞ½1 (pow_le_pow_left' (replicaConstant_le hΞ½1 hd ha hm) n)
_ = ((128 : ℝβ‰₯0∞)^Module.finrank ℝ E)^((n : ℝ)/(n+1)) := by
rw [← ENNReal.rpow_natCast, ← ENNReal.rpow_mul]
congr 1
rw [mul_one_div]
_ ≀ ((128 : ℝβ‰₯0∞)^Module.finrank ℝ E)^(1 : ℝ) :=
ENNReal.rpow_le_rpow_of_exponent_le (one_le_powβ‚€ (by norm_num))
((div_le_one hn0).2 (by linarith))
_ = _ := ENNReal.rpow_one _
lemma finite_rpow_holder {J : Type*} [Fintype J] (a : J β†’ ℝβ‰₯0∞) {q : ℝ} (hq : 1 < q) :
(βˆ‘ j, a j ^ (1 - 1/q)) ≀
(Fintype.card J : ℝβ‰₯0∞)^(1/q) * (βˆ‘ j, a j)^(1-1/q) := by
have hh := Real.HolderConjugate.conjExponent hq
have hq' : q.conjExponent β‰  0 := ne_of_gt hh.symm.pos
have hex : 1 - 1/q = q.conjExponent⁻¹ := by simpa only [one_div] using hh.one_sub_inv
rw [hex]
simpa only [one_mul, one_div, ENNReal.one_rpow, ENNReal.rpow_inv_rpow hq',
Finset.sum_const, Finset.card_univ, nsmul_eq_mul, mul_one] using
ENNReal.inner_le_Lp_mul_Lq Finset.univ (fun _ : J => (1 : ℝβ‰₯0∞))
(fun j => a j ^ q.conjExponent⁻¹) hh
lemma normalized_routing_bound {J : Type*} [Fintype J] [MeasurableSpace J]
[MeasurableSingletonClass J] (Ξ½ : J β†’ Measure E) [βˆ€ j, IsFiniteMeasure (Ξ½ j)]
{a m n : β„•} (hΞ½ : βˆ€ j, HasLocalMassBound (Ξ½ j) (a : ℝ))
(hΞ½1 : βˆ€ j, Ξ½ j univ ≀ 1) (hsupport : βˆ€ j, (Ξ½ j).support βŠ† Metric.closedBall 0 1)
(hd : 1 ≀ Module.finrank ℝ E) (ha : a ≀ Module.finrank ℝ E)
(hm : m ≀ Module.finrank ℝ E) (hn : 1 ≀ n) (hmargin : n+m ≀ a)
(Ο† : ((Fin m β†’ E) Γ— (Fin m β†’ ℝ)) β†’ J) (hΟ† : Measurable Ο†) :
(βˆ‘ j, projectionLaw (Ξ½ j) m {x | Ο† x = j}) ≀
(32768 : ℝβ‰₯0∞)^Module.finrank ℝ E * (Fintype.card J : ℝβ‰₯0∞)^(1/((n : ℝ)+1)) := by
classical
obtain ⟨D, hD, hDs, hDV⟩ := exists_projection_support (E := E) m hm
let S : J β†’ Set ((Fin m β†’ E) Γ— (Fin m β†’ ℝ)) := fun j => D ∩ {x | Ο† x = j}
have hS (j : J) : MeasurableSet (S j) := hD.inter (hφ (measurableSet_singleton j))
have hSD (j : J) : projectionLaw (Ξ½ j) m (S j) = projectionLaw (Ξ½ j) m {x | Ο† x = j} := by
apply Measure.measure_inter_eq_of_ae
unfold projectionLaw
apply (ae_map_iff (by fun_prop) hD).2
filter_upwards [Measure.quasiMeasurePreserving_snd.ae (Ξ½ j).support_mem_ae] with x hx
exact hDs x.1 x.2 (by simpa using hsupport j hx)
have hdis : Pairwise (Function.onFun Disjoint S) := by
intro i j hij
apply Set.disjoint_left.mpr
intro x hi hj
exact hij (hi.2.symm.trans hj.2)
have hUnion : (⋃ j, S j) = D := by
ext x
simp only [S, Set.mem_iUnion, Set.mem_inter_iff, Set.mem_ofPred_eq]
exact ⟨fun ⟨_,h,_⟩ => h, fun h => βŸ¨Ο† x,h,rfl⟩⟩
have hsum : βˆ‘ j, matrixLabelReference (E := E) m (S j) = matrixLabelReference (E := E) m D := by
simpa only [hUnion, tsum_fintype] using (measure_iUnion (ΞΌ := matrixLabelReference (E := E) m) hdis hS).symm
have hΞ± : 0 ≀ 1 - 1/((n : ℝ)+1) := by
have : (1 : ℝ) ≀ n := by exact_mod_cast hn
nlinarith [one_div_le_one_div_of_le (by norm_num : (0 : ℝ) < 1) (by linarith : (1 : ℝ) ≀ n+1)]
have hV : (matrixLabelReference (E := E) m D)^(1-1/((n : ℝ)+1)) ≀
(256 : ℝβ‰₯0∞)^Module.finrank ℝ E := by
calc
_ ≀ ((256 : ℝβ‰₯0∞)^Module.finrank ℝ E)^(1-1/((n : ℝ)+1)) :=
ENNReal.rpow_le_rpow (hDV.trans (pow_le_pow_left' (by norm_num) _)) hΞ±
_ ≀ ((256 : ℝβ‰₯0∞)^Module.finrank ℝ E)^ (1 : ℝ) :=
ENNReal.rpow_le_rpow_of_exponent_le (one_le_powβ‚€ (by norm_num)) (sub_le_self _ (by positivity))
_ = _ := ENNReal.rpow_one _
calc
_ = βˆ‘ j, projectionLaw (Ξ½ j) m (S j) := by simp_rw [hSD]
_ ≀ βˆ‘ j, (128 : ℝβ‰₯0∞)^Module.finrank ℝ E *
(matrixLabelReference (E := E) m (S j))^(1-1/((n : ℝ)+1)) :=
Finset.sum_le_sum fun j _ => projectionLaw_uniform_set_bound
(hΞ½ j) (hΞ½1 j) (hsupport j) hd ha hm hn hmargin (S j)
_ = (128 : ℝβ‰₯0∞)^Module.finrank ℝ E *
βˆ‘ j, (matrixLabelReference (E := E) m (S j))^(1-1/((n : ℝ)+1)) := by rw [Finset.mul_sum]
_ ≀ (128 : ℝβ‰₯0∞)^Module.finrank ℝ E *
((Fintype.card J : ℝβ‰₯0∞)^(1/((n : ℝ)+1)) *
(βˆ‘ j, matrixLabelReference (E := E) m (S j))^(1-1/((n : ℝ)+1))) :=
mul_le_mul' le_rfl (finite_rpow_holder _ (by exact_mod_cast Nat.lt_add_one_of_le hn))
_ ≀ (128 : ℝβ‰₯0∞)^Module.finrank ℝ E *
((Fintype.card J : ℝβ‰₯0∞)^(1/((n : ℝ)+1)) * (256 : ℝβ‰₯0∞)^Module.finrank ℝ E) := by
rw [hsum]
exact mul_le_mul' le_rfl (mul_le_mul' le_rfl hV)
_ = _ := by rw [mul_left_comm, ← mul_pow]; norm_num; rw [mul_comm]
omit [FiniteDimensional ℝ E] in
lemma localNormalize_reconstruct (Ξ½ : Measure E) (a : β„•) {C : ℝβ‰₯0∞}
(hC : C β‰  0) (hCt : C β‰  ∞) (z : E) {r : ℝ} (hr : 0 < r) :
(C * ENNReal.ofReal (r^a)) β€’ (localNormalize Ξ½ a C z r).map (fun t => z+r β€’ t) =
Ξ½.restrict (Metric.closedBall z r) := by
have hc0 : C * ENNReal.ofReal (r^a) β‰  0 := mul_ne_zero hC (by positivity)
have hct : C * ENNReal.ofReal (r^a) β‰  ∞ := ENNReal.mul_ne_top hCt ENNReal.ofReal_ne_top
rw [localNormalize, Measure.map_smul _ (by fun_prop), smul_smul, ENNReal.mul_inv_cancel hc0 hct,
one_smul, Measure.map_map (by fun_prop) (by fun_prop)]
have he : (fun t : E => z+r β€’ t) ∘ (fun x => r⁻¹ β€’ (x-z)) = id := by
ext x
simp [smul_smul, hr.ne']
rw [he, Measure.map_id]
lemma projectionLaw_smul (Ξ½ : Measure E) [SFinite Ξ½] (m : β„•) (c : ℝβ‰₯0∞) :
projectionLaw (c β€’ Ξ½) m = c β€’ projectionLaw Ξ½ m := by
rw [projectionLaw, Measure.prod_smul_right, Measure.map_smul _ (by fun_prop)]
rfl
lemma projectionLaw_affine (Ξ½ : Measure E) [SFinite Ξ½] (m : β„•) (z : E) (r : ℝ) :
projectionLaw (Ξ½.map (fun t => z + r β€’ t)) m =
(projectionLaw Ξ½ m).map (fun x => (x.1, fun j => βŸͺz,x.1 j⟫ + r * x.2 j)) := by
unfold projectionLaw
rw [← Measure.map_id (ΞΌ := Measure.pi (fun _ : Fin m => stdGaussian E)),
Measure.map_prod_map _ _ measurable_id (by fun_prop), Measure.map_map (by fun_prop) (by fun_prop),
Measure.map_id, Measure.map_map (by fun_prop) (by fun_prop)]
congr 1
ext x <;> simp [inner_add_left, real_inner_smul_left]
lemma localized_routing_bound {J : Type*} [Fintype J] [MeasurableSpace J]
[MeasurableSingletonClass J] (Ξ½ : J β†’ Measure E) [βˆ€ j, IsFiniteMeasure (Ξ½ j)]
{a m n : β„•} {C : ℝβ‰₯0∞} (hΞ½ : βˆ€ j, PolynomialMass (Ξ½ j) a C)
(hC : C β‰  0) (hCt : C β‰  ∞)
(hd : 1 ≀ Module.finrank ℝ E) (ha : a ≀ Module.finrank ℝ E)
(hm : m ≀ Module.finrank ℝ E) (hn : 1 ≀ n) (hmargin : n+m ≀ a)
(Ο† : ((Fin m β†’ E) Γ— (Fin m β†’ ℝ)) β†’ J) (hΟ† : Measurable Ο†)
(z : E) {r : ℝ} (hr : 0 < r) :
(βˆ‘ j, projectionLaw ((Ξ½ j).restrict (Metric.closedBall z r)) m {x | Ο† x = j}) ≀
(32768 : ℝβ‰₯0∞)^Module.finrank ℝ E * (Fintype.card J : ℝβ‰₯0∞)^(1/((n : ℝ)+1)) *
C * ENNReal.ofReal (r^a) := by
let Ο„ (j : J) := localNormalize (Ξ½ j) a C z r
let F : ((Fin m β†’ E) Γ— (Fin m β†’ ℝ)) β†’ ((Fin m β†’ E) Γ— (Fin m β†’ ℝ)) :=
fun x => (x.1, fun i => βŸͺz,x.1 i⟫ + r * x.2 i)
have hF : Measurable F := by fun_prop
let (j : J) : IsFiniteMeasure (Ο„ j) := localNormalize_finite (hΞ½ j) hC hCt z hr
have hb := normalized_routing_bound Ο„
(fun j => localNormalize_local (hΞ½ j) hC hCt z hr)
(fun j => localNormalize_univ (hΞ½ j) hC hCt z hr)
(fun j => localNormalize_support (Ξ½ j) a C z hr) hd ha hm hn hmargin (Ο† ∘ F) (hΟ†.comp hF)
have he (j : J) : projectionLaw ((Ξ½ j).restrict (Metric.closedBall z r)) m {x | Ο† x = j} =
(C * ENNReal.ofReal (r^a)) * projectionLaw (Ο„ j) m {x | Ο† (F x) = j} := by
rw [← localNormalize_reconstruct (Ξ½ j) a hC hCt z hr, projectionLaw_smul,
projectionLaw_affine, Measure.smul_apply, smul_eq_mul, Measure.map_apply hF
(measurableSet_eq_fun hφ measurable_const)]
rfl
simp_rw [he]
rw [← Finset.mul_sum]
exact (mul_le_mul' le_rfl hb).trans_eq (by ring)
lemma projectionLaw_withDensity_apply (ΞΌ : Measure E) [SFinite ΞΌ] {h : E β†’ ℝβ‰₯0∞}
(hh : Measurable h) [SFinite (ΞΌ.withDensity h)] (m : β„•)
{S : Set ((Fin m β†’ E) Γ— (Fin m β†’ ℝ))} (hS : MeasurableSet S) :
projectionLaw (ΞΌ.withDensity h) m S =
∫⁻ s, h s * (∫⁻ A, S.indicator (fun _ => (1 : ℝβ‰₯0∞)) (A, fun j => βŸͺs,A j⟫)
βˆ‚Measure.pi (fun _ : Fin m => stdGaussian E)) βˆ‚ΞΌ := by
have hobs : Measurable (fun x : (Fin m β†’ E) Γ— E => (x.1, fun j => βŸͺx.2,x.1 j⟫)) := by fun_prop
have hi : Measurable (fun x : (Fin m β†’ E) Γ— E => S.indicator (fun _ => (1 : ℝβ‰₯0∞))
(x.1, fun j => βŸͺx.2,x.1 j⟫)) :=
((measurable_const : Measurable (fun _ => (1 : ℝβ‰₯0∞))).indicator hS).comp hobs
rw [projectionLaw, Measure.map_apply hobs hS]
rw [← one_mul (((Measure.pi (fun _ : Fin m => stdGaussian E)).prod (ΞΌ.withDensity h)) _),
← lintegral_indicator_const (hobs hS) 1]
change (∫⁻ x : (Fin m β†’ E) Γ— E, S.indicator (fun _ => (1 : ℝβ‰₯0∞))
(x.1, fun j => βŸͺx.2,x.1 j⟫) βˆ‚(Measure.pi (fun _ : Fin m => stdGaussian E)).prod (ΞΌ.withDensity h)) = _
rw [lintegral_prod_symm _ hi.aemeasurable,
lintegral_withDensity_eq_lintegral_mul ΞΌ hh hi.lintegral_prod_left]
rfl
def blockValue {J : Type*} [Fintype J] {m : β„•} (h : J β†’ E β†’ ℝβ‰₯0∞)
(Ο† : ((Fin m β†’ E) Γ— (Fin m β†’ ℝ)) β†’ J) (s : E) : ℝβ‰₯0∞ :=
∫⁻ A, h (Ο† (A, fun j => βŸͺs,A j⟫)) s βˆ‚Measure.pi (fun _ : Fin m => stdGaussian E)
lemma measurable_finite_select {X J : Type*} [MeasurableSpace X] [Fintype J]
[MeasurableSpace J] [MeasurableSingletonClass J]
{h : J β†’ X β†’ ℝβ‰₯0∞} (hh : βˆ€ j, Measurable (h j)) {Ο† : X β†’ J} (hΟ† : Measurable Ο†) :
Measurable (fun x => h (Ο† x) x) := by
classical
have he (x : X) : h (Ο† x) x = βˆ‘ j : J, if Ο† x = j then h j x else 0 := by simp
simp_rw [he]
exact Finset.measurable_sum _ fun j _ => Measurable.ite
(measurableSet_eq_fun hφ measurable_const) (hh j) measurable_const
lemma measurable_blockValue {J : Type*} [Fintype J] [MeasurableSpace J]
[MeasurableSingletonClass J] {m : β„•} {h : J β†’ E β†’ ℝβ‰₯0∞}
(hh : βˆ€ j, Measurable (h j)) {Ο† : ((Fin m β†’ E) Γ— (Fin m β†’ ℝ)) β†’ J}
(hφ : Measurable φ) : Measurable (blockValue h φ) := by
apply Measurable.lintegral_prod_left
exact measurable_finite_select (fun j => (hh j).comp measurable_snd)
(hφ.comp (by fun_prop))
lemma blockValue_le_one {J : Type*} [Fintype J] {m : β„•} {h : J β†’ E β†’ ℝβ‰₯0∞}
(hh : βˆ€ j s, h j s ≀ 1) (Ο† : ((Fin m β†’ E) Γ— (Fin m β†’ ℝ)) β†’ J) (s : E) :
blockValue h Ο† s ≀ 1 := by
refine (lintegral_mono (fun A => hh _ s)).trans_eq ?_
simp only [lintegral_const, one_mul, Measure.pi_univ]
apply Finset.prod_eq_one
intro index _
rw [stdGaussian, Measure.map_apply (by fun_prop) MeasurableSet.univ, Set.preimage_univ]
exact measure_univ
lemma blockValue_mass_identity (ΞΌ : Measure E) [IsFiniteMeasure ΞΌ]
{J : Type*} [Fintype J] [MeasurableSpace J] [MeasurableSingletonClass J]
{m : β„•} {h : J β†’ E β†’ ℝβ‰₯0∞} (hh : βˆ€ j, Measurable (h j))
(hh1 : βˆ€ j s, h j s ≀ 1)
{Ο† : ((Fin m β†’ E) Γ— (Fin m β†’ ℝ)) β†’ J} (hΟ† : Measurable Ο†)
{S : Set E} (hS : MeasurableSet S) :
(ΞΌ.withDensity (blockValue h Ο†)) S =
βˆ‘ j, projectionLaw ((ΞΌ.withDensity (h j)).restrict S) m {x | Ο† x = j} := by
classical
let g (j : J) (s : E) (A : Fin m β†’ E) : ℝβ‰₯0∞ :=
if Ο† (A, fun k => βŸͺs,A k⟫) = j then h j s else 0
have hg (j : J) : Measurable (Function.uncurry (g j)) := by
exact Measurable.ite (measurableSet_eq_fun (hφ.comp (by fun_prop)) measurable_const)
((hh j).comp measurable_fst) measurable_const
have hselect (s : E) (A : Fin m β†’ E) : h (Ο† (A, fun k => βŸͺs,A k⟫)) s = βˆ‘ j, g j s A := by
simp [g]
have he (j : J) : projectionLaw ((ΞΌ.withDensity (h j)).restrict S) m {x | Ο† x = j} =
∫⁻ s in S, ∫⁻ A, g j s A βˆ‚Measure.pi (fun _ : Fin m => stdGaussian E) βˆ‚ΞΌ := by
rw [restrict_withDensity hS]
let : IsFiniteMeasure ((ΞΌ.restrict S).withDensity (h j)) :=
isFiniteMeasure_withDensity (ne_of_lt ((lintegral_mono (hh1 j)).trans_lt (by simp)))
rw [projectionLaw_withDensity_apply _ (hh j) _ (measurableSet_eq_fun hφ measurable_const)]
apply lintegral_congr
intro s
rw [← lintegral_const_mul' _ _ (ne_of_lt ((hh1 j s).trans_lt (by simp)))]
apply lintegral_congr
intro A
by_cases hx : Ο† (A, fun k => βŸͺs,A k⟫) = j <;> simp [g, hx]
rw [withDensity_apply _ hS]
calc
_ = ∫⁻ s in S, βˆ‘ j, ∫⁻ A, g j s A βˆ‚Measure.pi (fun _ : Fin m => stdGaussian E) βˆ‚ΞΌ := by
apply lintegral_congr
intro s
unfold blockValue
simp_rw [hselect]
exact lintegral_finsetSum _ (fun j _ => (hg j).comp (measurable_const.prodMk measurable_id))
_ = _ := by
rw [lintegral_finsetSum _ (fun j _ => (hg j).lintegral_prod_right)]
simp_rw [he]
lemma blockValue_mass_bound (ΞΌ : Measure E) [IsFiniteMeasure ΞΌ]
{J : Type*} [Fintype J] [MeasurableSpace J] [MeasurableSingletonClass J]
{a m n : β„•} {C : ℝβ‰₯0∞} {h : J β†’ E β†’ ℝβ‰₯0∞}
(hh : βˆ€ j, Measurable (h j)) (hh1 : βˆ€ j s, h j s ≀ 1)
(hlocal : βˆ€ j, PolynomialMass (ΞΌ.withDensity (h j)) a C)
(hC : C β‰  0) (hCt : C β‰  ∞)
(hd : 1 ≀ Module.finrank ℝ E) (ha : a ≀ Module.finrank ℝ E)
(hm : m ≀ Module.finrank ℝ E) (hn : 1 ≀ n) (hmargin : n+m ≀ a)
{Ο† : ((Fin m β†’ E) Γ— (Fin m β†’ ℝ)) β†’ J} (hΟ† : Measurable Ο†) :
PolynomialMass (ΞΌ.withDensity (blockValue h Ο†)) a
((32768 : ℝβ‰₯0∞)^Module.finrank ℝ E * (Fintype.card J : ℝβ‰₯0∞)^(1/((n : ℝ)+1)) * C) := by
let (j : J) : IsFiniteMeasure (ΞΌ.withDensity (h j)) :=
isFiniteMeasure_withDensity (ne_of_lt ((lintegral_mono (hh1 j)).trans_lt (by simp)))
intro z r hr
rw [blockValue_mass_identity μ hh hh1 hφ Metric.isClosed_closedBall.measurableSet]
exact localized_routing_bound (fun j => μ.withDensity (h j)) hlocal hC hCt hd ha hm hn hmargin φ hφ z hr
end Block
end NoiselessRegression
end
end OAI