Download data/lean/OAI/Probability/MemoryPrecision/CubeCaps.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 6.74 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/MemoryPrecision/CubeCaps.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Probability/MemoryPrecision/CubeCaps.lean
-
curl -L -o CubeCaps.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/MemoryPrecision/CubeCaps.lean
6.74 kB
| import Mathlib | |
| import OAI.Probability.GaussianRegression.Main | |
| import OAI.Probability.MemoryPrecision.CubeGeometry | |
| 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 | |
| lemma coordinate_ball_root_volume (n : β) : | |
| volume (coordinateBall n (Real.sqrt n)) β€ ENNReal.ofReal ((12:β)^n) := by | |
| have hpoint (x : Fin n β β) : | |
| (coordinateBall n (Real.sqrt n)).indicator (fun _ => (1:ββ₯0β)) x β€ | |
| ENNReal.ofReal (Real.exp n) * β i, ENNReal.ofReal (Real.exp (-(x i)^2/4)) := by | |
| by_cases hx : x β coordinateBall n (Real.sqrt n) | |
| Β· rw [Set.indicator_of_mem hx, β ENNReal.ofReal_prod_of_nonneg (fun i _ => Real.exp_nonneg _), | |
| β ENNReal.ofReal_mul (Real.exp_nonneg _), β Real.exp_sum, β Real.exp_add] | |
| have hs : (β i, (x i)^2) β€ n := by | |
| have hp := pow_le_pow_leftβ (norm_nonneg _) hx 2 | |
| change coordinateNorm x ^ 2 β€ (Real.sqrt (n:β)) ^ 2 at hp | |
| rw [coordinateNorm_sq, Real.sq_sqrt (by positivity)] at hp | |
| exact hp | |
| have he : 1 β€ Real.exp ((n:β) + β i, -(x i)^2/4) := by | |
| apply Real.one_le_exp_iff.mpr | |
| rw [β Finset.sum_div, Finset.sum_neg_distrib] | |
| have hn : (0:β) β€ n := Nat.cast_nonneg n | |
| linarith | |
| exact_mod_cast (ENNReal.ofReal_le_ofReal he) | |
| Β· rw [Set.indicator_of_notMem hx] | |
| exact zero_le | |
| calc | |
| volume (coordinateBall n (Real.sqrt n)) = | |
| β«β» x : Fin n β β, (coordinateBall n (Real.sqrt n)).indicator (fun _ => (1:ββ₯0β)) x := by | |
| rw [lintegral_indicator_const (measurableSet_coordinateBall _ _), one_mul] | |
| _ β€ β«β» x : Fin n β β, ENNReal.ofReal (Real.exp n) * | |
| β i, ENNReal.ofReal (Real.exp (-(x i)^2/4)) := lintegral_mono hpoint | |
| _ = ENNReal.ofReal (Real.exp n) * | |
| (β«β» z : β, ENNReal.ofReal (Real.exp (-(z^2)/4)))^n := by | |
| rw [lintegral_const_mul _ (by fun_prop), volume_pi, | |
| lintegral_fin_prod volume n (fun _ => fun z : β => ENNReal.ofReal (Real.exp (-(z^2)/4))) (fun _ => by fun_prop)] | |
| simp | |
| _ β€ ENNReal.ofReal (Real.exp n) * (4:ββ₯0β)^n := by | |
| gcongr | |
| exact lintegral_quarterGaussian_le | |
| _ β€ ENNReal.ofReal ((12:β)^n) := by | |
| have he : Real.exp (n:β) β€ (3:β)^n := by | |
| rw [β mul_one (n:β), Real.exp_nat_mul] | |
| exact pow_le_pow_leftβ (Real.exp_nonneg _) Real.exp_one_lt_three.le n | |
| calc | |
| _ β€ ENNReal.ofReal ((3:β)^n) * (4:ββ₯0β)^n := mul_le_mul' (ENNReal.ofReal_le_ofReal he) le_rfl | |
| _ = _ := by rw [ENNReal.ofReal_pow (by norm_num), β mul_pow]; norm_num | |
| lemma cube_scaled_ball_volume (n : β) (z : Space n) {r : β} (hr : 0 < r) : | |
| volume (Metric.closedBall z (Real.sqrt n*r)) β€ ENNReal.ofReal ((12:β)^n*r^n) := by | |
| rw [Measure.addHaar_closedBall_center] | |
| have he : (WithLp.toLp 2 : (Fin n β β) β Space n) β»ΒΉ' Metric.closedBall 0 (Real.sqrt n*r) = | |
| coordinateBall n (r*Real.sqrt n) := by | |
| ext x | |
| simp [Metric.mem_closedBall, dist_zero_right, coordinateBall, coordinateNorm, mul_comm] | |
| rw [β (PiLp.volume_preserving_toLp (Fin n)).measure_preimage (show NullMeasurableSet (Metric.closedBall (0:Space n) (Real.sqrt n*r)) volume from Metric.isClosed_closedBall.measurableSet.nullMeasurableSet), he, | |
| volume_coordinateBall_smul n r (Real.sqrt n) hr] | |
| calc | |
| _ β€ ENNReal.ofReal (r^n) * ENNReal.ofReal ((12:β)^n) := | |
| mul_le_mul' le_rfl (coordinate_ball_root_volume n) | |
| _ = _ := by rw [β ENNReal.ofReal_mul (by positivity)]; congr 1; ring | |
| lemma cubeBall_volume (d : β) (z : Space (d/2)) {r : β} (hr : 0 < r) : | |
| CubeLaw d (CubeBall d z r) β€ ENNReal.ofReal ((12:β)^(d/2)*r^(d/2)) := by | |
| rw [CubeLaw, comap_subtype_coe_apply (cubeSet_measurable _)] | |
| apply (measure_mono (show Subtype.val '' CubeBall d z r β Metric.closedBall z (Real.sqrt (d/2:β)*r) from ?_)).trans | |
| (cube_scaled_ball_volume (d/2) z hr) | |
| rintro _ β¨u,hu,rflβ© | |
| exact hu | |
| lemma cube_cap_local {d : β} (hd : 2 β€ d) (y : Space d) {Ξ΅ : β} (hΞ΅ : 0 < Ξ΅) : | |
| CubeLocal (fun u => capWeight y Ξ΅ (CubeEmbedding d u)) | |
| ((12:β)^(d/2)*Ξ΅^((d/2:β)/4:β)) := by | |
| intro z r hr | |
| let A : Set (Cube d) := CubeEmbedding d β»ΒΉ' Metric.closedBall y Ξ΅ | |
| have hA : MeasurableSet A := Metric.isClosed_closedBall.measurableSet.preimage (cubeEmbedding_measurable d) | |
| have hint : (β«β» u in CubeBall d z r, capWeight y Ξ΅ (CubeEmbedding d u) βCubeLaw d) = | |
| CubeLaw d (A β© CubeBall d z r) := by | |
| change (β«β» u in CubeBall d z r, A.indicator (fun _ => (1:ββ₯0β)) u βCubeLaw d) = _ | |
| rw [lintegral_indicator_const hA, one_mul, Measure.restrict_apply hA] | |
| rw [hint] | |
| have hΞ΅ball : A β CubeBall d (Real.sqrt (d/2:β) β’ cubeProject d y) Ξ΅ := by | |
| intro u hu | |
| exact (cubeProject_parameter_dist hd u y).trans | |
| (mul_le_mul_of_nonneg_left hu (Real.sqrt_nonneg _)) | |
| have hs : (0:β) β€ (d/2:β)/4 := by positivity | |
| have ht : (0:β) β€ 3*(d/2:β)/4 := by positivity | |
| have he (t : β) (ht : 0 < t) : t^(d/2) = t^((d/2:β)/4:β)*t^(3*(d/2:β)/4:β) := by | |
| rw [β Real.rpow_add ht, show ((d/2:β)/4:β)+(3*(d/2:β)/4:β) = (d/2:β) by ring, Real.rpow_natCast] | |
| by_cases hh : r β€ Ξ΅ | |
| Β· apply ((measure_mono Set.inter_subset_right).trans (cubeBall_volume d z hr)).trans | |
| apply ENNReal.ofReal_le_ofReal | |
| rw [he r hr, β mul_assoc] | |
| gcongr | |
| Β· apply ((measure_mono (Set.inter_subset_left.trans hΞ΅ball)).trans | |
| (cubeBall_volume d (Real.sqrt (d/2:β) β’ cubeProject d y) hΞ΅)).trans | |
| apply ENNReal.ofReal_le_ofReal | |
| rw [he Ξ΅ hΞ΅, β mul_assoc] | |
| gcongr | |
| exact le_of_not_ge hh | |
| lemma cubeBall_univ (d : β) : CubeBall d 0 1 = Set.univ := by | |
| ext u | |
| simp only [Set.mem_univ, iff_true] | |
| change dist u.val 0 β€ Real.sqrt (d/2:β)*1 | |
| rw [dist_zero_right, mul_one] | |
| apply nonneg_le_nonneg_of_sq_le_sq (Real.sqrt_nonneg _) | |
| simp only [β pow_two] | |
| rw [Real.sq_sqrt (by positivity), EuclideanSpace.norm_sq_eq] | |
| calc | |
| _ β€ β _i : Fin (d/2), (1:β) := by | |
| apply Finset.sum_le_sum | |
| intro i _ | |
| have h := u.property i | |
| have hab := abs_le.mp h | |
| simp only [Real.norm_eq_abs, sq_abs] | |
| nlinarith | |
| _ = _ := by simp | |
| lemma cube_mass_bound {d : β} {f : Cube d β ββ₯0β} {L : β} (h : CubeLocal f L) : | |
| (β«β» u, f u βCubeLaw d) β€ ENNReal.ofReal L := by | |
| simpa [cubeBall_univ] using h 0 1 zero_lt_one | |
| end MemoryPrecision | |
| end | |
| end OAI | |