roseking's picture
Add lean source and binary files (part 122)
b317718 verified
Raw History Blame Contribute Delete
12.2 kB
import OAI.Probability.GaussianReplacement.StreamModel
import OAI.Probability.GaussianRegression.Nets
namespace OAI
open MeasureTheory ProbabilityTheory Set Filter
open scoped ENNReal NNReal RealInnerProductSpace Topology
noncomputable section
universe u
namespace NoiselessRegression
open scoped Topology
section InverseMoments
variable {X : Type*} [MeasurableSpace X]
omit [MeasurableSpace X] in
lemma inverse_pow_dyadic_majorant (f : X → ℝ) (m : ℕ) (hf : ∀ x, 0 ≤ f x) (x : X) :
ENNReal.ofReal ((f x)⁻¹ ^ m) ≤
1 + ∑' k : ℕ, ({x | f x ≤ (1 / 2 : ℝ) ^ k}).indicator
(fun _ => ENNReal.ofReal ((2 : ℝ) ^ (m * (k + 1)))) x := by
classical
by_cases hzero : f x = 0
· simp only [hzero, inv_zero]
exact le_add_of_le_left (by cases m <;> simp)
have hxpos : 0 < f x := lt_of_le_of_ne (hf x) (Ne.symm hzero)
by_cases hxone : 1 ≤ f x
· apply le_add_of_le_left
have h : (f x)⁻¹ ^ m ≤ 1 :=
pow_le_one₀ (inv_nonneg.mpr (hf x)) (inv_le_one_of_one_le₀ hxone)
simpa using ENNReal.ofReal_le_ofReal h
obtain ⟨k, hklo, hkhi⟩ := exists_nat_pow_near_of_lt_one hxpos
(le_of_not_ge hxone) (by norm_num : (0 : ℝ) < 1 / 2) (by norm_num : (1 / 2 : ℝ) < 1)
have hinv : (f x)⁻¹ ≤ (2 : ℝ) ^ (k + 1) := by
have h := (inv_le_inv₀ hxpos (pow_pos (by norm_num : (0 : ℝ) < 1 / 2) _)).2 hklo.le
simpa using h
have hpow : ENNReal.ofReal ((f x)⁻¹ ^ m) ≤
ENNReal.ofReal ((2 : ℝ) ^ (m * (k + 1))) := by
apply ENNReal.ofReal_le_ofReal
simpa [← pow_mul, Nat.mul_comm] using pow_le_pow_left₀ (inv_nonneg.mpr (hf x)) hinv m
calc
ENNReal.ofReal ((f x)⁻¹ ^ m) ≤ ENNReal.ofReal ((2 : ℝ) ^ (m * (k + 1))) := hpow
_ = ({x | f x ≤ (1 / 2 : ℝ) ^ k}).indicator
(fun _ => ENNReal.ofReal ((2 : ℝ) ^ (m * (k + 1)))) x := by
rw [Set.indicator_of_mem (show x ∈ {x | f x ≤ (1 / 2 : ℝ) ^ k} from hkhi)]
_ ≤ ∑' j : ℕ, ({x | f x ≤ (1 / 2 : ℝ) ^ j}).indicator
(fun _ => ENNReal.ofReal ((2 : ℝ) ^ (m * (j + 1)))) x :=
ENNReal.le_tsum (f := fun j => ({x | f x ≤ (1 / 2 : ℝ) ^ j}).indicator
(fun _ => ENNReal.ofReal ((2 : ℝ) ^ (m * (j + 1)))) x) k
_ ≤ 1 + ∑' j : ℕ, ({x | f x ≤ (1 / 2 : ℝ) ^ j}).indicator
(fun _ => ENNReal.ofReal ((2 : ℝ) ^ (m * (j + 1)))) x := le_add_left le_rfl
lemma dyadic_power_cancel (m k : ℕ) :
(2 : ℝ) ^ (m * (k + 1)) * ((1 / 2 : ℝ) ^ k) ^ (m + 1) =
(2 : ℝ) ^ m * (1 / 2 : ℝ) ^ k := by
rw [Nat.mul_add, mul_one, pow_add, pow_succ]
have h : (2 : ℝ) ^ (m * k) * ((1 / 2 : ℝ) ^ k) ^ m = 1 := by
rw [Nat.mul_comm m k, pow_mul, ← mul_pow, ← mul_pow]
norm_num
calc
2 ^ (m * k) * 2 ^ m * (((1 / 2 : ℝ) ^ k) ^ m * (1 / 2 : ℝ) ^ k) =
(2 ^ (m * k) * ((1 / 2 : ℝ) ^ k) ^ m) * (2 ^ m * (1 / 2 : ℝ) ^ k) := by ring
_ = _ := by rw [h, one_mul]
theorem inverse_moment_of_tube_bound (μ : Measure X) (f : X → ℝ) (m : ℕ)
(hf : Measurable f) (hnonneg : ∀ x, 0 ≤ f x) (C : ℝ≥0∞)
(htube : ∀ r : ℝ, 0 < r → r ≤ 1 →
μ {x | f x ≤ r} ≤ C * ENNReal.ofReal (r ^ (m + 1))) :
∫⁻ x, ENNReal.ofReal ((f x)⁻¹ ^ m) ∂μ ≤
μ Set.univ + C * (2 : ℝ≥0∞) ^ (m + 1) := by
classical
let g : ℕ → X → ℝ≥0∞ := fun k =>
({x | f x ≤ (1 / 2 : ℝ) ^ k}).indicator
(fun _ => ENNReal.ofReal ((2 : ℝ) ^ (m * (k + 1))))
have hg : ∀ k, Measurable (g k) := fun k =>
measurable_const.indicator (measurableSet_le hf measurable_const)
calc
∫⁻ x, ENNReal.ofReal ((f x)⁻¹ ^ m) ∂μ ≤ ∫⁻ x, 1 + ∑' k, g k x ∂μ :=
lintegral_mono (inverse_pow_dyadic_majorant f m hnonneg)
_ = μ Set.univ + ∑' k, ∫⁻ x, g k x ∂μ := by
rw [lintegral_add_left measurable_const, lintegral_const, one_mul, lintegral_tsum (fun k => (hg k).aemeasurable)]
_ ≤ μ Set.univ + ∑' k, C * ENNReal.ofReal ((2 : ℝ) ^ m * (1 / 2 : ℝ) ^ k) := by
apply add_le_add le_rfl
apply ENNReal.tsum_le_tsum
intro k
dsimp only [g]
rw [lintegral_indicator (measurableSet_le hf measurable_const), lintegral_const,
Measure.restrict_apply_univ]
calc
ENNReal.ofReal ((2 : ℝ) ^ (m * (k + 1))) * μ {x | f x ≤ (1 / 2 : ℝ) ^ k} ≤
ENNReal.ofReal ((2 : ℝ) ^ (m * (k + 1))) *
(C * ENNReal.ofReal (((1 / 2 : ℝ) ^ k) ^ (m + 1))) := by
gcongr
exact htube _ (by positivity) (pow_le_one₀ (by norm_num) (by norm_num))
_ = _ := by
rw [← mul_assoc, mul_comm _ C, mul_assoc, ← ENNReal.ofReal_mul (by positivity),
dyadic_power_cancel]
_ = μ Set.univ + C * (2 : ℝ≥0∞) ^ (m + 1) := by
simp_rw [ENNReal.ofReal_mul (by positivity : (0 : ℝ) ≤ 2 ^ m),
ENNReal.ofReal_pow (by norm_num : (0 : ℝ) ≤ 1 / 2),
ENNReal.ofReal_pow (by norm_num : (0 : ℝ) ≤ 2)]
rw [ENNReal.tsum_mul_left, ENNReal.tsum_mul_left, ENNReal.tsum_geometric]
norm_num [pow_succ, mul_assoc, ENNReal.ofReal_div_of_pos]
end InverseMoments
section FrostmanGeometry
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
[FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E]
end FrostmanGeometry
section FiniteNets
variable {E : Type*} [PseudoMetricSpace E]
end FiniteNets
section EuclideanNets
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
[FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E]
end EuclideanNets
section AffineTubes
variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E]
[FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E]
open EuclideanGeometry
theorem exists_affine_tube_cover (L : AffineSubspace ℝ E) [Nonempty L]
{r : ℝ} (hr : 0 < r) (hr1 : r ≤ 1) :
∃ s : Finset L.direction,
(s.card : ℝ) ≤ (3 / r) ^ Module.finrank ℝ L.direction ∧
∀ t : E, ‖t‖ ≤ 1 → Metric.infDist t L ≤ r →
∃ y ∈ s, dist t ((y : E) + (orthogonalProjection L 0 : E)) ≤ 2 * r := by
classical
obtain ⟨s, _, hcard, hnet⟩ := exists_unit_ball_net (E := L.direction) hr hr1
refine ⟨s, hcard, ?_⟩
intro t ht hdist
obtain ⟨y, hy, hty⟩ := hnet (L.direction.orthogonalProjectionOnto t)
((L.direction.norm_orthogonalProjectionOnto_apply_le t).trans ht)
refine ⟨y, hy, ?_⟩
have hproj : (orthogonalProjection L t : E) =
(L.direction.orthogonalProjectionOnto t : E) + (orthogonalProjection L 0 : E) := by
have h := (orthogonalProjection L).map_vadd (0 : E) t
simpa only [vadd_eq_add, add_zero, orthogonalProjection_contLinear,
AffineSubspace.coe_vadd] using congrArg (fun x : L => (x : E)) h
have hpdist : dist (orthogonalProjection L t : E)
((y : E) + (orthogonalProjection L 0 : E)) ≤ r := by
rw [hproj, dist_add_right]
exact hty
have hd : dist t (orthogonalProjection L t : E) ≤ r := by
rwa [dist_orthogonalProjection_eq_infDist]
calc
dist t ((y : E) + (orthogonalProjection L 0 : E)) ≤
dist t (orthogonalProjection L t : E) +
dist (orthogonalProjection L t : E) ((y : E) + (orthogonalProjection L 0 : E)) :=
dist_triangle _ _ _
_ ≤ r + r := add_le_add hd hpdist
_ = 2 * r := by ring
theorem HasLocalMassBound.affine_tube {ν : Measure E} {a : ℝ}
(hν : HasLocalMassBound ν a) (hsupport : ν.support ⊆ Metric.closedBall 0 1)
(L : AffineSubspace ℝ E) [Nonempty L] {r : ℝ} (hr : 0 < r) (hr1 : r ≤ 1) :
ν {t | Metric.infDist t L ≤ r} ≤
ENNReal.ofReal ((3 / r) ^ Module.finrank ℝ L.direction * (4 * r) ^ a) := by
classical
obtain ⟨s, hcard, hcover⟩ := exists_affine_tube_cover L hr hr1
let c : L.direction → E := fun y => (y : E) + (orthogonalProjection L 0 : E)
have hsub : {t | Metric.infDist t L ≤ r} ≤ᵐ[ν]
⋃ y ∈ s, Metric.closedBall (c y) (2 * r) := by
filter_upwards [ν.support_mem_ae] with t ht
intro hdist
have htunit : ‖t‖ ≤ 1 := by simpa using hsupport ht
obtain ⟨y, hy, hty⟩ := hcover t htunit hdist
exact mem_iUnion₂.mpr ⟨y, hy, hty⟩
calc
ν {t | Metric.infDist t L ≤ r} ≤ ν (⋃ y ∈ s, Metric.closedBall (c y) (2 * r)) :=
measure_mono_ae hsub
_ ≤ ∑ y ∈ s, ν (Metric.closedBall (c y) (2 * r)) := measure_biUnion_finset_le _ _
_ ≤ ∑ _y ∈ s, ENNReal.ofReal ((4 * r) ^ a) := by
refine Finset.sum_le_sum fun y _ => ?_
simpa only [show (2 : ℝ) * (2 * r) = 4 * r by ring] using
hν.any_center (c y) (r := 2 * r) (by positivity)
_ = (s.card : ℝ≥0∞) * ENNReal.ofReal ((4 * r) ^ a) := by simp
_ ≤ ENNReal.ofReal ((3 / r) ^ Module.finrank ℝ L.direction) *
ENNReal.ofReal ((4 * r) ^ a) := by
gcongr
exact_mod_cast ENNReal.ofReal_le_ofReal hcard
_ = _ := (ENNReal.ofReal_mul (by positivity)).symm
lemma tube_radius_factors (ℓ : ℕ) (a : ℝ) {r : ℝ} (hr : 0 < r) :
(3 / r) ^ ℓ * (4 * r) ^ a =
(3 : ℝ) ^ ℓ * (4 : ℝ) ^ a * r ^ (a - ℓ) := by
rw [div_pow, Real.mul_rpow (by norm_num) hr.le,
Real.rpow_sub_natCast hr.ne']
ring
theorem HasLocalMassBound.affine_tube_pow {ν : Measure E} {a : ℝ}
(hν : HasLocalMassBound ν a) (hsupport : ν.support ⊆ Metric.closedBall 0 1)
(L : AffineSubspace ℝ E) [Nonempty L] (k : ℕ)
(hmargin : (Module.finrank ℝ L.direction : ℝ) + k ≤ a)
{r : ℝ} (hr : 0 < r) (hr1 : r ≤ 1) :
ν {t | Metric.infDist t L ≤ r} ≤
ENNReal.ofReal ((3 : ℝ) ^ Module.finrank ℝ L.direction * (4 : ℝ) ^ a) *
ENNReal.ofReal (r ^ k) := by
refine (hν.affine_tube hsupport L hr hr1).trans ?_
rw [tube_radius_factors _ _ hr, ← ENNReal.ofReal_mul (by positivity)]
apply ENNReal.ofReal_le_ofReal
apply mul_le_mul_of_nonneg_left _ (by positivity)
rw [← Real.rpow_natCast]
exact Real.rpow_le_rpow_of_exponent_ge hr hr1 (by linarith)
theorem HasLocalMassBound.affine_inverse_moment {ν : Measure E} {a : ℝ}
(hν : HasLocalMassBound ν a) (hsupport : ν.support ⊆ Metric.closedBall 0 1)
(L : AffineSubspace ℝ E) [Nonempty L] (m : ℕ)
(hmargin : (Module.finrank ℝ L.direction : ℝ) + (m + 1 : ℕ) ≤ a) :
∫⁻ t, ENNReal.ofReal ((Metric.infDist t L)⁻¹ ^ m) ∂ν ≤
ν Set.univ +
ENNReal.ofReal ((3 : ℝ) ^ Module.finrank ℝ L.direction * (4 : ℝ) ^ a) *
(2 : ℝ≥0∞) ^ (m + 1) := by
apply inverse_moment_of_tube_bound ν _ m (Metric.continuous_infDist_pt _).measurable
(fun _ => Metric.infDist_nonneg)
intro r hr hr1
exact hν.affine_tube_pow hsupport L (m + 1) hmargin hr hr1
theorem HasLocalMassBound.affine_null {ν : Measure E} {a : ℝ}
(hν : HasLocalMassBound ν a) (hsupport : ν.support ⊆ Metric.closedBall 0 1)
(L : AffineSubspace ℝ E) [Nonempty L]
(hmargin : (Module.finrank ℝ L.direction : ℝ) + 1 ≤ a) : ν L = 0 := by
let C : ℝ := (3 : ℝ) ^ Module.finrank ℝ L.direction * (4 : ℝ) ^ a
have hC : 0 ≤ C := by dsimp [C]; positivity
have hb (n : ℕ) : ν L ≤ ENNReal.ofReal (C * (1 / 2 : ℝ) ^ n) := by
have hn : 0 < (1 / 2 : ℝ) ^ n := by positivity
have hn1 : (1 / 2 : ℝ) ^ n ≤ 1 := pow_le_one₀ (by norm_num) (by norm_num)
calc
ν L ≤ ν {t | Metric.infDist t L ≤ (1 / 2 : ℝ) ^ n} := by
apply measure_mono
intro t ht
simp only [mem_ofPred_eq, Metric.infDist_zero_of_mem ht]
exact hn.le
_ ≤ ENNReal.ofReal C * ENNReal.ofReal (((1 / 2 : ℝ) ^ n) ^ 1) :=
hν.affine_tube_pow hsupport L 1 (by simpa using hmargin) hn hn1
_ = _ := by rw [pow_one, ENNReal.ofReal_mul hC]
have hlim : Tendsto (fun n : ℕ => ENNReal.ofReal (C * (1 / 2 : ℝ) ^ n))
atTop (𝓝 0) := by
convert ENNReal.tendsto_ofReal ((tendsto_const_nhds (x := C)).mul
(tendsto_pow_atTop_nhds_zero_of_lt_one (by norm_num : (0 : ℝ) ≤ 1 / 2)
(by norm_num : (1 / 2 : ℝ) < 1))) using 1
simp
exact le_antisymm (ge_of_tendsto' hlim hb) (by positivity)
end AffineTubes
end NoiselessRegression
end
end OAI