Download lean/OAI/Probability/GaussianRegression/Projection.lean from roseking/openAI-math-dataset: direct link, hf CLI and curl.
- Browser
- Download file 5.88 kB
-
https://huggingface.co/datasets/roseking/openAI-math-dataset/resolve/main/lean/OAI/Probability/GaussianRegression/Projection.lean
- Command line
-
hf download hf://datasets/roseking/openAI-math-dataset/lean/OAI/Probability/GaussianRegression/Projection.lean
-
curl -L -o Projection.lean https://huggingface.co/datasets/roseking/openAI-math-dataset/resolve/main/lean/OAI/Probability/GaussianRegression/Projection.lean
5.88 kB
| import OAI.Probability.GaussianRegression.Smoothing | |
| namespace OAI | |
| /-! | |
| Exact noiseless projection laws and completed-event bounds. | |
| -/ | |
| open MeasureTheory ProbabilityTheory Set Filter | |
| open scoped ENNReal NNReal RealInnerProductSpace Topology | |
| open InnerProductSpace | |
| noncomputable section | |
| universe u | |
| namespace NoiselessRegression | |
| section ProjectionCoupling | |
| variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] | |
| [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] | |
| def matrixLabelReference (m : ℕ) : Measure ((Fin m → E) × (Fin m → ℝ)) := | |
| (Measure.pi (fun _ => stdGaussian E)).prod volume | |
| def projectionLaw (ν : Measure E) (m : ℕ) : Measure ((Fin m → E) × (Fin m → ℝ)) := | |
| ((Measure.pi (fun _ => stdGaussian E)).prod ν).map | |
| (fun z => (z.1, fun j => ⟪z.2, z.1 j⟫)) | |
| def gaussianCoupling (ν : Measure E) (m : ℕ) : | |
| Measure ((Fin m → E) × (E × (Fin m → ℝ))) := | |
| (Measure.pi (fun _ => stdGaussian E)).prod | |
| (ν.prod (Measure.pi (fun _ => gaussianReal 0 1))) | |
| def noisyObservation (m : ℕ) (δ : ℝ) | |
| (z : (Fin m → E) × (E × (Fin m → ℝ))) : (Fin m → E) × (Fin m → ℝ) := | |
| (z.1, fun j => ⟪z.2.1, z.1 j⟫ + δ * z.2.2 j) | |
| lemma measurable_noisyObservation (m : ℕ) (δ : ℝ) : | |
| Measurable (noisyObservation (E := E) m δ) := by | |
| unfold noisyObservation | |
| fun_prop | |
| lemma gaussianCoupling_map_noisyObservation_zero (ν : Measure E) [SigmaFinite ν] (m : ℕ) : | |
| (gaussianCoupling ν m).map (noisyObservation m 0) = projectionLaw ν m := by | |
| apply Measure.ext_of_lintegral | |
| intro f hf | |
| rw [lintegral_map hf (measurable_noisyObservation m 0), | |
| projectionLaw, lintegral_map hf (by fun_prop)] | |
| dsimp [gaussianCoupling, noisyObservation] | |
| simp only [zero_mul, add_zero] | |
| rw [lintegral_prod _ (by fun_prop), lintegral_prod _ (by fun_prop)] | |
| apply lintegral_congr | |
| intro A | |
| rw [lintegral_prod _ (by fun_prop)] | |
| simp | |
| lemma gaussianCoupling_map_noisyObservation (ν : Measure E) [SigmaFinite ν] | |
| (m : ℕ) (δ : ℝ) (hδ : δ ≠ 0) : | |
| (gaussianCoupling ν m).map (noisyObservation m δ) = | |
| (matrixLabelReference (E := E) m).withDensity | |
| (projectionSmoothing ν (gaussianPDF 0 (NNReal.mk (δ^2) (sq_nonneg δ))) m) := by | |
| apply Measure.ext_of_lintegral | |
| intro f hf | |
| rw [lintegral_map hf (measurable_noisyObservation m δ), | |
| lintegral_withDensity_eq_lintegral_mul _ | |
| (measurable_projectionSmoothing _ _ (measurable_gaussianPDF _ _) _) hf] | |
| dsimp [gaussianCoupling, matrixLabelReference, noisyObservation] | |
| rw [lintegral_prod _ (by fun_prop), lintegral_prod _ (by | |
| exact ((measurable_projectionSmoothing _ _ (measurable_gaussianPDF _ _) _).mul hf).aemeasurable)] | |
| apply lintegral_congr | |
| intro A | |
| rw [lintegral_prod _ (by fun_prop)] | |
| have he (p : E) := lintegral_gaussian_shift_scale m δ hδ | |
| (fun j => ⟪p, A j⟫) (fun y => f (A, y)) (hf.comp (measurable_const.prodMk measurable_id)) | |
| simp_rw [he] | |
| rw [lintegral_lintegral_swap (by fun_prop)] | |
| apply lintegral_congr | |
| intro y | |
| rw [lintegral_mul_const _ (by fun_prop)] | |
| rfl | |
| lemma matrixLabelReference_outerRegular (m : ℕ) : | |
| (matrixLabelReference (E := E) m).OuterRegular := by | |
| unfold matrixLabelReference | |
| exact (Measure.Regular.of_sigmaCompactSpace_of_isLocallyFiniteMeasure _).toOuterRegular | |
| omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in | |
| lemma tendsto_noisyObservation (m : ℕ) | |
| (z : (Fin m → E) × (E × (Fin m → ℝ))) : | |
| Tendsto (fun k : ℕ => noisyObservation m (1 / ((k : ℝ) + 1)) z) | |
| atTop (𝓝 (noisyObservation m 0 z)) := by | |
| apply Filter.Tendsto.prodMk_nhds tendsto_const_nhds | |
| apply tendsto_pi_nhds.mpr | |
| intro j | |
| exact tendsto_const_nhds.add | |
| (tendsto_one_div_add_atTop_nhds_zero_nat.mul_const _) | |
| theorem projectionLaw_set_bound {ν : Measure E} [IsFiniteMeasure ν] | |
| {a : ℝ} (hν : HasLocalMassBound ν a) | |
| (hsupport : ν.support ⊆ Metric.closedBall 0 1) | |
| (m n : ℕ) (hn : 1 ≤ n) (hmargin : (n : ℝ) + m ≤ a) | |
| (S : Set ((Fin m → E) × (Fin m → ℝ))) : | |
| projectionLaw ν m S ≤ | |
| (ν Set.univ * (replicaConstant ν a m)^n)^(1 / ((n : ℝ) + 1)) * | |
| (matrixLabelReference (E := E) m S)^(1 - 1 / ((n : ℝ) + 1)) := by | |
| have hp : 1 < (n : ℝ) + 1 := by exact_mod_cast (by omega : 1 < n + 1) | |
| have hα : 0 < 1 - 1 / ((n : ℝ) + 1) := by | |
| exact sub_pos.mpr ((div_lt_one (by positivity)).mpr hp) | |
| have hC : ν Set.univ * (replicaConstant ν a m)^n ≠ ∞ := by | |
| unfold replicaConstant | |
| finiteness | |
| have := matrixLabelReference_outerRegular (E := E) m | |
| apply measure_apply_le_of_isOpen _ _ (ENNReal.rpow_ne_top_of_nonneg (by positivity) hC) hα | |
| intro U hU | |
| rw [← gaussianCoupling_map_noisyObservation_zero ν m] | |
| apply map_apply_open_le_of_tendsto (gaussianCoupling ν m) | |
| (matrixLabelReference (E := E) m) (noisyObservation m 0) | |
| (fun k => noisyObservation m (1 / ((k : ℝ) + 1))) | |
| (measurable_noisyObservation m 0) (fun k => measurable_noisyObservation m _) | |
| (tendsto_noisyObservation m) _ _ (U := U) (hU := hU) | |
| intro k V hV | |
| have hδ : (1 / ((k : ℝ) + 1)) ≠ 0 := by positivity | |
| rw [gaussianCoupling_map_noisyObservation ν m _ hδ] | |
| apply withDensity_apply_le_moment _ _ | |
| (measurable_projectionSmoothing _ _ (measurable_gaussianPDF _ _) _) hp _ _ hV.measurableSet | |
| have hv : (NNReal.mk ((1 / ((k : ℝ) + 1)) ^ 2) | |
| (sq_nonneg (1 / ((k : ℝ) + 1)))) ≠ 0 := by | |
| rw [← NNReal.coe_ne_zero] | |
| exact pow_ne_zero 2 hδ | |
| simpa only [← ENNReal.rpow_natCast, Nat.cast_add, Nat.cast_one, matrixLabelReference] | |
| using projectionSmoothing_moment hν hsupport | |
| (gaussianPDF 0 (NNReal.mk ((1 / ((k : ℝ) + 1)) ^ 2) | |
| (sq_nonneg (1 / ((k : ℝ) + 1))))) (measurable_gaussianPDF _ _) | |
| (lintegral_gaussianPDF_eq_one _ hv) m n hmargin | |
| end ProjectionCoupling | |
| end NoiselessRegression | |
| end | |
| end OAI | |