Download lean/OAI/Probability/SKGap/Matrix/LipschitzNormedConvolution.lean from roseking/openAI-math-dataset: direct link, hf CLI and curl.
- Browser
- Download file 20.6 kB
-
https://huggingface.co/datasets/roseking/openAI-math-dataset/resolve/main/lean/OAI/Probability/SKGap/Matrix/LipschitzNormedConvolution.lean
- Command line
-
hf download hf://datasets/roseking/openAI-math-dataset/lean/OAI/Probability/SKGap/Matrix/LipschitzNormedConvolution.lean
-
curl -L -o LipschitzNormedConvolution.lean https://huggingface.co/datasets/roseking/openAI-math-dataset/resolve/main/lean/OAI/Probability/SKGap/Matrix/LipschitzNormedConvolution.lean
20.6 kB
| import Mathlib | |
| import OAI.Probability.SKGap.Model | |
| namespace OAI | |
| section | |
| noncomputable section | |
| open MeasureTheory ProbabilityTheory InformationTheory Real Set | |
| open scoped NNReal ENNReal | |
| open Filter | |
| open scoped Topology | |
| noncomputable section | |
| open Matrix Real | |
| open scoped BigOperators Matrix.Norms.Frobenius ENNReal NNReal | |
| noncomputable section | |
| open Matrix Real | |
| open scoped BigOperators Matrix.Norms.Frobenius NNReal | |
| noncomputable section | |
| open MeasureTheory ProbabilityTheory Real Set Filter | |
| open MeasureTheory.Measure | |
| open scoped ENNReal NNReal MeasureTheory Topology | |
| namespace SKGap | |
| section Smoothing | |
| open NormedSpace | |
| open scoped Convolution ContDiff | |
| variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] | |
| [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] | |
| theorem lipschitz_normed_convolution {f : E → ℝ} {L : ℝ≥0} | |
| (hf : LipschitzWith L f) (φ : ContDiffBump (0 : E)) | |
| (μ : Measure E) [μ.IsAddHaarMeasure] : | |
| LipschitzWith L (φ.normed μ ⋆[ContinuousLinearMap.lsmul ℝ ℝ, μ] f) := by | |
| have hcv : ConvolutionExists (φ.normed μ) f (ContinuousLinearMap.lsmul ℝ ℝ) μ := | |
| (φ.hasCompactSupport_normed (μ := μ)).convolutionExists_left | |
| (ContinuousLinearMap.lsmul ℝ ℝ) φ.continuous_normed | |
| (hf.continuous.locallyIntegrable (μ := μ)) | |
| apply LipschitzWith.of_dist_le_mul | |
| intro x y | |
| simp only [dist_eq_norm, convolution_def, ContinuousLinearMap.lsmul_apply, smul_eq_mul] | |
| have hx : Integrable (fun t => φ.normed μ t * f (x - t)) μ := hcv x | |
| have hy : Integrable (fun t => φ.normed μ t * f (y - t)) μ := hcv y | |
| rw [← integral_sub hx hy] | |
| calc | |
| _ ≤ ∫ t, φ.normed μ t * ((L : ℝ) * ‖x - y‖) ∂μ := by | |
| apply norm_integral_le_of_norm_le (φ.integrable_normed.mul_const _) | |
| filter_upwards [] with t | |
| rw [← mul_sub, norm_mul, Real.norm_eq_abs (φ.normed μ t), | |
| abs_of_nonneg (φ.nonneg_normed _)] | |
| apply mul_le_mul_of_nonneg_left _ (φ.nonneg_normed _) | |
| simpa only [sub_sub_sub_cancel_right] using hf.norm_sub_le (x - t) (y - t) | |
| _ = (L : ℝ) * ‖x - y‖ := by rw [integral_mul_const, φ.integral_normed, one_mul] | |
| theorem exists_smooth_lipschitz_approx {f : E → ℝ} {L : ℝ≥0} | |
| (hf : LipschitzWith L f) {ε : ℝ} (hε : 0 < ε) : | |
| ∃ g : E → ℝ, ContDiff ℝ ∞ g ∧ LipschitzWith L g ∧ | |
| ∀ x, dist (g x) (f x) ≤ (L : ℝ) * ε := by | |
| let μ : Measure E := addHaar | |
| let φ : ContDiffBump (0 : E) := ⟨ε / 2, ε, half_pos hε, half_lt_self hε⟩ | |
| let g := φ.normed μ ⋆[ContinuousLinearMap.lsmul ℝ ℝ, μ] f | |
| refine ⟨g, ?_, lipschitz_normed_convolution hf φ μ, ?_⟩ | |
| · exact φ.hasCompactSupport_normed.contDiff_convolution_left | |
| (ContinuousLinearMap.lsmul ℝ ℝ) φ.contDiff_normed hf.continuous.locallyIntegrable | |
| · intro x | |
| apply ContDiffBump.dist_normed_convolution_le hf.continuous.aestronglyMeasurable | |
| intro y hy | |
| apply (hf.dist_le_mul y x).trans | |
| exact mul_le_mul_of_nonneg_left (Metric.mem_ball.mp hy).le L.coe_nonneg | |
| end Smoothing | |
| section GaussianMoments | |
| variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] | |
| [MeasurableSpace E] [BorelSpace E] [SecondCountableTopology E] [CompleteSpace E] | |
| {μ : Measure E} [IsGaussian μ] | |
| theorem gaussian_integrable_exp_norm (a : ℝ) : | |
| Integrable (fun x : E => exp (a * ‖x‖)) μ := by | |
| obtain ⟨C, hC, hI⟩ := IsGaussian.exists_integrable_exp_sq μ | |
| apply (hI.const_mul (exp (a ^ 2 / (4 * C)))).mono' (by fun_prop) | |
| filter_upwards [] with x | |
| rw [Real.norm_eq_abs, abs_of_pos (exp_pos _), ← exp_add] | |
| apply exp_le_exp.mpr | |
| have hs := sq_nonneg (‖x‖ - a / (2 * C)) | |
| have hC0 : C ≠ 0 := ne_of_gt hC | |
| have heq : C * (‖x‖ - a / (2 * C)) ^ 2 = | |
| C * ‖x‖ ^ 2 - a * ‖x‖ + a ^ 2 / (4 * C) := by field_simp; ring | |
| nlinarith [mul_nonneg (le_of_lt hC) hs] | |
| end GaussianMoments | |
| section StandardGaussian | |
| variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] | |
| [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] | |
| theorem stdGaussian_map_dual (L : StrongDual ℝ E) : | |
| (stdGaussian E).map L = gaussianReal 0 (Real.toNNReal (‖L‖ ^ 2)) := by | |
| rw [IsGaussian.map_eq_gaussianReal, integral_strongDual_stdGaussian, | |
| variance_dual_stdGaussian] | |
| theorem stdGaussian_integrable_exp_dual (L : StrongDual ℝ E) (r : ℝ) : | |
| Integrable (fun x => exp (r * L x)) (stdGaussian E) := by | |
| have h := integrable_exp_mul_gaussianReal (μ := 0) | |
| (v := Real.toNNReal (‖L‖ ^ 2)) r | |
| rw [← stdGaussian_map_dual L] at h | |
| exact h.comp_measurable L.continuous.measurable | |
| theorem stdGaussian_integral_exp_dual (L : StrongDual ℝ E) (r : ℝ) : | |
| (∫ x, exp (r * L x) ∂stdGaussian E) = exp (r ^ 2 * ‖L‖ ^ 2 / 2) := by | |
| have hm := mgf_gaussianReal | |
| ⟨L.continuous.measurable.aemeasurable, stdGaussian_map_dual L⟩ r | |
| simpa [mgf, Real.toNNReal_of_nonneg (sq_nonneg _), mul_div_assoc, mul_comm] using hm | |
| theorem gaussian_integrable_exp_lipschitz {μ : Measure E} [IsGaussian μ] | |
| {f : E → ℝ} {L : ℝ≥0} (hf : LipschitzWith L f) (r : ℝ) : | |
| Integrable (fun x => exp (r * f x)) μ := by | |
| have hfc := hf.continuous | |
| have hI := (gaussian_integrable_exp_norm (μ := μ) (|r| * L)).const_mul | |
| (exp (|r| * |f 0|)) | |
| apply hI.mono' (by fun_prop) | |
| filter_upwards [] with x | |
| rw [Real.norm_eq_abs, abs_of_pos (exp_pos _), ← exp_add] | |
| apply exp_le_exp.mpr | |
| have hx : |f x| ≤ |f 0| + L * ‖x‖ := by | |
| have hh := hf.norm_sub_le x 0 | |
| simp only [sub_zero, Real.norm_eq_abs] at hh | |
| have ht := abs_add_le (f x - f 0) (f 0) | |
| rw [sub_add_cancel] at ht | |
| linarith | |
| calc | |
| r * f x ≤ |r * f x| := le_abs_self _ | |
| _ = |r| * |f x| := abs_mul _ _ | |
| _ ≤ |r| * (|f 0| + L * ‖x‖) := mul_le_mul_of_nonneg_left hx (abs_nonneg _) | |
| _ = _ := by ring | |
| theorem gaussian_integrable_lipschitz {μ : Measure E} [IsGaussian μ] | |
| {f : E → ℝ} {L : ℝ≥0} (hf : LipschitzWith L f) : Integrable f μ := by | |
| have hI := ((IsGaussian.integrable_id (μ := μ)).norm.const_mul (L : ℝ)).add | |
| (integrable_const |f 0|) | |
| apply hI.mono' hf.continuous.aestronglyMeasurable | |
| filter_upwards [] with x | |
| change |f x| ≤ (L : ℝ) * ‖x‖ + |f 0| | |
| have hh := hf.norm_sub_le x 0 | |
| simp only [sub_zero, Real.norm_eq_abs] at hh ⊢ | |
| have ht := abs_add_le (f x - f 0) (f 0) | |
| rw [sub_add_cancel] at ht | |
| linarith | |
| end StandardGaussian | |
| theorem exp_interval_average_le {a : ℝ} (ha : 0 < a) {g : ℝ → ℝ} | |
| (hg : Continuous g) : | |
| exp (a⁻¹ * ∫ t in (0 : ℝ)..a, g t) ≤ | |
| a⁻¹ * ∫ t in (0 : ℝ)..a, exp (g t) := by | |
| have h0 : volume (Icc (0 : ℝ) a) ≠ 0 := by | |
| rw [volume_Icc, sub_zero, ENNReal.ofReal_ne_zero_iff] | |
| exact ha | |
| have ht : volume (Icc (0 : ℝ) a) ≠ ∞ := by simp | |
| have hJ := convexOn_exp.map_set_average_le continuous_exp.continuousOn isClosed_univ | |
| h0 ht (by filter_upwards [] with x; exact mem_univ _) | |
| hg.integrableOn_Icc (continuous_exp.comp hg).integrableOn_Icc | |
| have hvol : volume.real (Icc (0 : ℝ) a) = a := by | |
| simp [measureReal_def, volume_Icc, ha.le] | |
| simpa only [setAverage_eq, hvol, smul_eq_mul, | |
| integral_Icc_eq_integral_Ioc, ← intervalIntegral.integral_of_le ha.le] using hJ | |
| section Rotation | |
| variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] | |
| theorem rotation_snd_norm_le (θ : ℝ) (p : E × E) : | |
| ‖(ContinuousLinearMap.rotation θ p).2‖ ≤ ‖p.1‖ + ‖p.2‖ := by | |
| rw [ContinuousLinearMap.rotation_apply] | |
| calc | |
| ‖-sin θ • p.1 + cos θ • p.2‖ ≤ ‖-sin θ • p.1‖ + ‖cos θ • p.2‖ := norm_add_le _ _ | |
| _ = |sin θ| * ‖p.1‖ + |cos θ| * ‖p.2‖ := by simp [norm_smul, Real.norm_eq_abs] | |
| _ ≤ 1 * ‖p.1‖ + 1 * ‖p.2‖ := | |
| add_le_add (mul_le_mul_of_nonneg_right (abs_sin_le_one _) (norm_nonneg _)) | |
| (mul_le_mul_of_nonneg_right (abs_cos_le_one _) (norm_nonneg _)) | |
| _ = _ := by ring | |
| theorem hasDerivAt_rotation_fst (θ : ℝ) (p : E × E) : | |
| HasDerivAt (fun t => (ContinuousLinearMap.rotation t p).1) | |
| (ContinuousLinearMap.rotation θ p).2 θ := by | |
| exact ((hasDerivAt_cos θ).smul_const p.1).add | |
| ((hasDerivAt_sin θ).smul_const p.2) | |
| theorem rotation_fundamental_theorem {f : E → ℝ} {df : E → StrongDual ℝ E} | |
| (hf : ∀ x, HasFDerivAt f (df x) x) (hdf : Continuous df) (p : E × E) : | |
| (∫ θ in (0 : ℝ)..π / 2, | |
| df (ContinuousLinearMap.rotation θ p).1 (ContinuousLinearMap.rotation θ p).2) = | |
| f p.2 - f p.1 := by | |
| have hd : ∀ θ, HasDerivAt (fun t => f (ContinuousLinearMap.rotation t p).1) | |
| (df (ContinuousLinearMap.rotation θ p).1 (ContinuousLinearMap.rotation θ p).2) θ := | |
| fun θ => (hf _).comp_hasDerivAt θ (hasDerivAt_rotation_fst θ p) | |
| have hc : Continuous (fun θ => | |
| df (ContinuousLinearMap.rotation θ p).1 (ContinuousLinearMap.rotation θ p).2) := by | |
| simp only [ContinuousLinearMap.rotation_apply] | |
| fun_prop | |
| have hi := intervalIntegral.integral_eq_sub_of_hasDerivAt (fun θ _ => hd θ) | |
| (hc.intervalIntegrable 0 (π / 2)) | |
| simpa [ContinuousLinearMap.rotation_apply] using hi | |
| theorem rotation_exp_difference_le {f : E → ℝ} {df : E → StrongDual ℝ E} | |
| (hf : ∀ x, HasFDerivAt f (df x) x) (hdf : Continuous df) (r : ℝ) (p : E × E) : | |
| exp (r * (f p.2 - f p.1)) ≤ (π / 2)⁻¹ * | |
| ∫ θ in (0 : ℝ)..π / 2, exp (r * (π / 2) * | |
| df (ContinuousLinearMap.rotation θ p).1 (ContinuousLinearMap.rotation θ p).2) := by | |
| have hc : Continuous (fun θ => r * (π / 2) * | |
| df (ContinuousLinearMap.rotation θ p).1 (ContinuousLinearMap.rotation θ p).2) := by | |
| simp only [ContinuousLinearMap.rotation_apply] | |
| fun_prop | |
| have hJ := exp_interval_average_le (half_pos pi_pos) hc | |
| rw [intervalIntegral.integral_const_mul, rotation_fundamental_theorem hf hdf] at hJ | |
| convert hJ using 1 | |
| congr 1 | |
| field_simp | |
| theorem exp_dual_le {L : ℝ≥0} (D : StrongDual ℝ E) (hD : ‖D‖ ≤ L) (r : ℝ) (y : E) : | |
| exp (r * D y) ≤ exp (|r| * L * ‖y‖) := by | |
| apply exp_le_exp.mpr | |
| calc | |
| r * D y ≤ |r * D y| := le_abs_self _ | |
| _ = |r| * ‖D y‖ := by rw [abs_mul, Real.norm_eq_abs] | |
| _ ≤ |r| * (‖D‖ * ‖y‖) := mul_le_mul_of_nonneg_left (D.le_opNorm y) (abs_nonneg _) | |
| _ ≤ |r| * ((L : ℝ) * ‖y‖) := by gcongr | |
| _ = _ := by ring | |
| theorem rotation_exp_dual_le {L : ℝ≥0} {df : E → StrongDual ℝ E} | |
| (hdf : ∀ x, ‖df x‖ ≤ L) (r θ : ℝ) (p : E × E) : | |
| exp (r * df (ContinuousLinearMap.rotation θ p).1 (ContinuousLinearMap.rotation θ p).2) ≤ | |
| exp (|r| * L * ‖p.1‖) * exp (|r| * L * ‖p.2‖) := by | |
| calc | |
| _ ≤ exp (|r| * L * ‖(ContinuousLinearMap.rotation θ p).2‖) := exp_dual_le _ (hdf _) _ _ | |
| _ ≤ exp (|r| * L * (‖p.1‖ + ‖p.2‖)) := by | |
| gcongr | |
| exact rotation_snd_norm_le θ p | |
| _ = _ := by rw [mul_add, exp_add] | |
| end Rotation | |
| section StandardGaussianRotation | |
| variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] | |
| [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] | |
| theorem stdGaussian_integrable_variable_dual {df : E → StrongDual ℝ E} (hc : Continuous df) | |
| {L : ℝ≥0} (hdf : ∀ x, ‖df x‖ ≤ L) (r : ℝ) : | |
| Integrable (fun p : E × E => exp (r * df p.1 p.2)) | |
| ((stdGaussian E).prod (stdGaussian E)) := by | |
| apply ((gaussian_integrable_exp_norm (μ := stdGaussian E) (|r| * L)).comp_snd | |
| (stdGaussian E)).mono' (by fun_prop) | |
| filter_upwards [] with p | |
| rw [Real.norm_eq_abs, abs_of_pos (exp_pos _)] | |
| exact exp_dual_le _ (hdf _) _ _ | |
| theorem stdGaussian_integral_variable_dual_le {df : E → StrongDual ℝ E} (hc : Continuous df) | |
| {L : ℝ≥0} (hdf : ∀ x, ‖df x‖ ≤ L) (r : ℝ) : | |
| (∫ p : E × E, exp (r * df p.1 p.2) ∂(stdGaussian E).prod (stdGaussian E)) ≤ | |
| exp (r ^ 2 * (L : ℝ) ^ 2 / 2) := by | |
| have hi := stdGaussian_integrable_variable_dual hc hdf r | |
| have hio := hi.integral_prod_left | |
| simp only [stdGaussian_integral_exp_dual] at hio | |
| rw [integral_prod _ hi] | |
| simp only [stdGaussian_integral_exp_dual] | |
| calc | |
| _ ≤ ∫ _x : E, exp (r ^ 2 * (L : ℝ) ^ 2 / 2) ∂stdGaussian E := by | |
| apply integral_mono hio (integrable_const _) | |
| intro x | |
| apply exp_le_exp.mpr | |
| gcongr | |
| exact hdf x | |
| _ = _ := by simp | |
| theorem stdGaussian_integral_rotation_variable_dual_le {df : E → StrongDual ℝ E} | |
| (hc : Continuous df) {L : ℝ≥0} (hdf : ∀ x, ‖df x‖ ≤ L) (r θ : ℝ) : | |
| (∫ p : E × E, exp (r * df (ContinuousLinearMap.rotation θ p).1 | |
| (ContinuousLinearMap.rotation θ p).2) ∂(stdGaussian E).prod (stdGaussian E)) ≤ | |
| exp (r ^ 2 * (L : ℝ) ^ 2 / 2) := by | |
| have hm := IsGaussian.map_rotation_eq_self (μ := stdGaussian E) (by simp) θ | |
| rw [← integral_map (ContinuousLinearMap.rotation θ).continuous.aemeasurable | |
| (f := fun p : E × E => exp (r * df p.1 p.2)) (by fun_prop), hm] | |
| exact stdGaussian_integral_variable_dual_le hc hdf r | |
| theorem stdGaussian_integrable_rotation_variable_dual {df : E → StrongDual ℝ E} | |
| (hc : Continuous df) {L : ℝ≥0} (hdf : ∀ x, ‖df x‖ ≤ L) (r : ℝ) | |
| (ν : Measure ℝ) [IsFiniteMeasure ν] : | |
| Integrable (fun z : ℝ × (E × E) => | |
| exp (r * df (ContinuousLinearMap.rotation z.1 z.2).1 | |
| (ContinuousLinearMap.rotation z.1 z.2).2)) | |
| (ν.prod ((stdGaussian E).prod (stdGaussian E))) := by | |
| have hI := gaussian_integrable_exp_norm (μ := stdGaussian E) (|r| * L) | |
| apply ((hI.mul_prod hI).comp_snd ν).mono' | |
| · simp only [ContinuousLinearMap.rotation_apply] | |
| fun_prop | |
| · filter_upwards [] with z | |
| rw [Real.norm_eq_abs, abs_of_pos (exp_pos _)] | |
| exact rotation_exp_dual_le hdf _ _ _ | |
| omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in | |
| theorem lipschitz_of_bounded_derivative {f : E → ℝ} {df : E → StrongDual ℝ E} | |
| (hf : ∀ x, HasFDerivAt f (df x) x) {L : ℝ≥0} (hdf : ∀ x, ‖df x‖ ≤ L) : | |
| LipschitzWith L f := by | |
| apply lipschitzWith_of_nnnorm_fderiv_le (fun x => (hf x).differentiableAt) | |
| intro x | |
| rw [(hf x).fderiv] | |
| exact hdf x | |
| lemma exp_mul_sub (r a b : ℝ) : exp (r * (a - b)) = exp (-r * b) * exp (r * a) := by | |
| rw [← exp_add] | |
| congr 1 | |
| ring | |
| theorem stdGaussian_integrable_exp_difference {f : E → ℝ} {L : ℝ≥0} | |
| (hf : LipschitzWith L f) (r : ℝ) : | |
| Integrable (fun p : E × E => exp (r * (f p.2 - f p.1))) | |
| ((stdGaussian E).prod (stdGaussian E)) := by | |
| simp_rw [exp_mul_sub] | |
| exact (gaussian_integrable_exp_lipschitz hf (-r)).mul_prod | |
| (gaussian_integrable_exp_lipschitz hf r) | |
| theorem stdGaussian_mgf_difference_le {f : E → ℝ} {df : E → StrongDual ℝ E} | |
| (hf : ∀ x, HasFDerivAt f (df x) x) (hc : Continuous df) | |
| {L : ℝ≥0} (hdf : ∀ x, ‖df x‖ ≤ L) (r : ℝ) : | |
| (∫ p : E × E, exp (r * (f p.2 - f p.1)) ∂(stdGaussian E).prod (stdGaussian E)) ≤ | |
| exp (π ^ 2 * r ^ 2 * (L : ℝ) ^ 2 / 8) := by | |
| let ν : Measure ℝ := volume.restrict (Ioc (0 : ℝ) (π / 2)) | |
| have hν : IsFiniteMeasure ν := by dsimp [ν]; infer_instance | |
| let R := r * (π / 2) | |
| let G : ℝ → E × E → ℝ := fun θ p => exp (R * | |
| df (ContinuousLinearMap.rotation θ p).1 (ContinuousLinearMap.rotation θ p).2) | |
| have hI : Integrable (Function.uncurry G) (ν.prod ((stdGaussian E).prod (stdGaussian E))) := | |
| stdGaussian_integrable_rotation_variable_dual hc hdf R ν | |
| have hD := stdGaussian_integrable_exp_difference (lipschitz_of_bounded_derivative hf hdf) r | |
| have hpos : 0 < π / 2 := half_pos pi_pos | |
| have hvol : ν.real univ = π / 2 := by | |
| simp [ν, measureReal_def, Real.volume_Ioc, hpos.le] | |
| have hpoint (p : E × E) : exp (r * (f p.2 - f p.1)) ≤ | |
| (π / 2)⁻¹ * ∫ θ, G θ p ∂ν := by | |
| simpa only [intervalIntegral.integral_of_le hpos.le] using rotation_exp_difference_le hf hc r p | |
| calc | |
| _ ≤ ∫ p : E × E, (π / 2)⁻¹ * (∫ θ, G θ p ∂ν) | |
| ∂(stdGaussian E).prod (stdGaussian E) := | |
| integral_mono hD (hI.integral_prod_right.const_mul _) hpoint | |
| _ = (π / 2)⁻¹ * ∫ θ, (∫ p : E × E, G θ p | |
| ∂(stdGaussian E).prod (stdGaussian E)) ∂ν := by | |
| rw [integral_const_mul, ← integral_integral_swap hI] | |
| _ ≤ (π / 2)⁻¹ * ∫ _θ, exp (R ^ 2 * (L : ℝ) ^ 2 / 2) ∂ν := by | |
| apply mul_le_mul_of_nonneg_left _ (inv_nonneg.mpr hpos.le) | |
| apply integral_mono hI.integral_prod_left (integrable_const _) | |
| intro θ | |
| exact stdGaussian_integral_rotation_variable_dual_le hc hdf R θ | |
| _ = exp (π ^ 2 * r ^ 2 * (L : ℝ) ^ 2 / 8) := by | |
| rw [integral_const, smul_eq_mul, hvol, ← mul_assoc, inv_mul_cancel₀ hpos.ne', one_mul] | |
| congr 1 | |
| dsimp [R] | |
| ring | |
| theorem stdGaussian_mgf_centered_le {f : E → ℝ} {df : E → StrongDual ℝ E} | |
| (hf : ∀ x, HasFDerivAt f (df x) x) (hc : Continuous df) | |
| {L : ℝ≥0} (hdf : ∀ x, ‖df x‖ ≤ L) (r : ℝ) : | |
| (∫ x, exp (r * (f x - ∫ y, f y ∂stdGaussian E)) ∂stdGaussian E) ≤ | |
| exp (π ^ 2 * r ^ 2 * (L : ℝ) ^ 2 / 8) := by | |
| have hLip := lipschitz_of_bounded_derivative hf hdf | |
| have hF := gaussian_integrable_lipschitz (μ := stdGaussian E) hLip | |
| have hG := gaussian_integrable_exp_lipschitz (μ := stdGaussian E) hLip (-r) | |
| have hpair := stdGaussian_integrable_exp_difference hLip (-r) | |
| have hcenter : Integrable (fun x => exp (r * (f x - ∫ y, f y ∂stdGaussian E))) | |
| (stdGaussian E) := by | |
| simp_rw [exp_mul_sub] | |
| exact (gaussian_integrable_exp_lipschitz hLip r).const_mul _ | |
| have hj (x : E) : exp (r * (f x - ∫ y, f y ∂stdGaussian E)) ≤ | |
| ∫ y, exp (r * (f x - f y)) ∂stdGaussian E := by | |
| have hsub := ((integrable_const (f x)).sub hF).const_mul r | |
| have he : Integrable (fun y => exp (r * (f x - f y))) (stdGaussian E) := by | |
| simp_rw [exp_mul_sub] | |
| exact hG.mul_const _ | |
| have h := convexOn_exp.map_integral_le continuous_exp.continuousOn isClosed_univ | |
| (by filter_upwards [] with y; exact mem_univ _) hsub he | |
| simp only [Pi.sub_apply] at h | |
| simpa only [integral_const_mul, integral_sub (integrable_const _) hF, | |
| integral_const, probReal_univ, one_smul] using h | |
| have heq (x y : E) : r * (f x - f y) = -r * (f y - f x) := by ring | |
| simp_rw [heq] at hj | |
| calc | |
| _ ≤ ∫ x, (∫ y, exp (-r * (f y - f x)) ∂stdGaussian E) ∂stdGaussian E := | |
| integral_mono hcenter hpair.integral_prod_left hj | |
| _ = ∫ p : E × E, exp (-r * (f p.2 - f p.1)) | |
| ∂(stdGaussian E).prod (stdGaussian E) := (integral_prod _ hpair).symm | |
| _ ≤ exp (π ^ 2 * r ^ 2 * (L : ℝ) ^ 2 / 8) := by | |
| simpa using stdGaussian_mgf_difference_le hf hc hdf (-r) | |
| theorem centered_mgf_le_of_uniform_dist {f g : E → ℝ} {L M : ℝ≥0} | |
| (hf : LipschitzWith L f) (hg : LipschitzWith M g) {δ : ℝ} | |
| (hfg : ∀ x, dist (f x) (g x) ≤ δ) (r : ℝ) : | |
| (∫ x, exp (r * (f x - ∫ y, f y ∂stdGaussian E)) ∂stdGaussian E) ≤ | |
| exp (2 * |r| * δ) * | |
| (∫ x, exp (r * (g x - ∫ y, g y ∂stdGaussian E)) ∂stdGaussian E) := by | |
| let μ := stdGaussian E | |
| have hfi : Integrable f μ := gaussian_integrable_lipschitz hf | |
| have hgi : Integrable g μ := gaussian_integrable_lipschitz hg | |
| have hmean : |(∫ y, f y ∂μ) - ∫ y, g y ∂μ| ≤ δ := by | |
| have hi : ‖∫ x, f x - g x ∂μ‖ ≤ δ * μ.real univ := | |
| norm_integral_le_of_norm_le_const (μ := μ) | |
| (Eventually.of_forall (fun x => by simpa only [dist_eq_norm] using hfg x)) | |
| rw [integral_sub hfi hgi] at hi | |
| simpa only [Real.norm_eq_abs, probReal_univ, mul_one] using hi | |
| have he (h : E → ℝ) {K : ℝ≥0} (hh : LipschitzWith K h) : | |
| Integrable (fun x => exp (r * (h x - ∫ y, h y ∂μ))) μ := by | |
| simp_rw [exp_mul_sub] | |
| exact (gaussian_integrable_exp_lipschitz hh r).const_mul _ | |
| rw [← integral_const_mul] | |
| apply integral_mono (he f hf) ((he g hg).const_mul _) | |
| intro x | |
| dsimp only | |
| rw [← exp_add] | |
| apply exp_le_exp.mpr | |
| have hdiff : |(f x - ∫ y, f y ∂μ) - (g x - ∫ y, g y ∂μ)| ≤ 2 * δ := by | |
| have hx : |f x - g x| ≤ δ := by simpa only [Real.dist_eq] using hfg x | |
| calc | |
| _ = |(f x - g x) - ((∫ y, f y ∂μ) - ∫ y, g y ∂μ)| := by congr 1; ring | |
| _ ≤ |f x - g x| + |(∫ y, f y ∂μ) - ∫ y, g y ∂μ| := by | |
| simpa only [Real.norm_eq_abs] using norm_sub_le | |
| (f x - g x) ((∫ y, f y ∂μ) - ∫ y, g y ∂μ) | |
| _ ≤ 2 * δ := by linarith | |
| have hh := le_abs_self (r * ((f x - ∫ y, f y ∂μ) - (g x - ∫ y, g y ∂μ))) | |
| rw [abs_mul] at hh | |
| have hb := mul_le_mul_of_nonneg_left hdiff (abs_nonneg r) | |
| dsimp [μ] at * | |
| nlinarith | |
| end StandardGaussianRotation | |
| end SKGap | |
| end | |
| end | |
| end | |
| end | |
| end | |
| end OAI | |