Download data/lean/OAI/Probability/GaussianInformation/Kernel/ReferenceDensity.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 5.31 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/GaussianInformation/Kernel/ReferenceDensity.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Probability/GaussianInformation/Kernel/ReferenceDensity.lean
-
curl -L -o ReferenceDensity.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/GaussianInformation/Kernel/ReferenceDensity.lean
5.31 kB
| import Mathlib | |
| import OAI.Probability.GaussianInformation.Kernel.ReferenceBounds | |
| namespace OAI | |
| open MeasureTheory ProbabilityTheory Metric Set | |
| open scoped ENNReal | |
| open MeasureTheory ProbabilityTheory Set | |
| open scoped ENNReal | |
| namespace ReferenceGaussian | |
| open MeasureTheory ProbabilityTheory Metric Set | |
| open scoped ENNReal | |
| open GaussianTools | |
| lemma integrable_energy_joint {p d : β} (Ο : Measure (Vec d)) [IsProbabilityMeasure Ο] | |
| (s : Vec d) {R : β} (hR : 0 β€ R) (hs : βα΅ u βΟ,u β closedBall s R) | |
| (e : Fin p β β) : | |
| Integrable (fun t : Mat p d Γ Vec d => energy t.1 (s-t.2) e) | |
| ((Measure.pi (fun _ : Fin p => scalarRow d)).prod Ο) := by | |
| have : IsProbabilityMeasure (scalarRow d) := by unfold scalarRow; infer_instance | |
| have hm : Measurable (fun t : Mat p d Γ Vec d => energy t.1 (s-t.2) e) := by | |
| unfold energy applyRows; fun_prop | |
| apply ((((integrable_matEnergy (p := p) (d := d)).comp_fst Ο).const_mul (2*R^2)).add | |
| (integrable_const (2*β i,e i^2))).mono' hm.aestronglyMeasurable | |
| have hae : βα΅ t : Mat p d Γ Vec d β(Measure.pi (fun _ : Fin p => scalarRow d)).prod Ο, | |
| t.2 β closedBall s R := measurePreserving_snd.quasiMeasurePreserving.ae hs | |
| filter_upwards [hae] with t ht | |
| rw [Real.norm_eq_abs,abs_of_nonneg (energy_nonneg _ _ _)] | |
| have ht' : βs-t.2β β€ R := by simpa only [mem_closedBall,dist_eq_norm,norm_sub_rev] using ht | |
| have hb := energy_le t.1 (s-t.2) e | |
| have hsq : βs-t.2β^2 β€ R^2 := (sq_le_sqβ (norm_nonneg _) hR).mpr ht' | |
| change energy t.1 (s-t.2) e β€ 2*R^2*matEnergy t.1+2*β i,e i^2 | |
| nlinarith [mul_le_mul_of_nonneg_left hsq (matEnergy_nonneg t.1)] | |
| lemma energy_rows_local_le {p d : β} (Ο : Measure (Vec d)) [IsProbabilityMeasure Ο] | |
| (s : Vec d) {R : β} (hR : 0 β€ R) (hs : βα΅ u βΟ,u β closedBall s R) | |
| (e : Fin p β β) : | |
| (β« X : Mat p d,β« u,energy X (s-u) e βΟ βMeasure.pi (fun _ : Fin p => scalarRow d)) β€ | |
| 2*(p:β)*R^2+2*β i,e i^2 := by | |
| have : IsProbabilityMeasure (scalarRow d) := by unfold scalarRow; infer_instance | |
| rw [integral_integral_swap (integrable_energy_joint Ο s hR hs e)] | |
| have hi := (integrable_energy_joint Ο s hR hs e).integral_prod_right | |
| calc | |
| _ β€ β« _u,2*(p:β)*R^2+2*β i,e i^2 βΟ := by | |
| apply integral_mono_ae hi (integrable_const _) | |
| filter_upwards [hs] with u hu | |
| have hu' : βs-uβ β€ R := by simpa only [mem_closedBall,dist_eq_norm,norm_sub_rev] using hu | |
| have hsq : βs-uβ^2 β€ R^2 := pow_le_pow_leftβ (norm_nonneg _) hu' 2 | |
| exact (energy_rows_le (s-u) e).trans (by gcongr) | |
| _ = _ := by simp | |
| lemma integrable_log_shift_rows {p d : β} (Ο : Measure (Vec d)) [IsProbabilityMeasure Ο] | |
| (s : Vec d) {R : β} (hR : 0 β€ R) (hs : βα΅ u βΟ,u β closedBall s R) | |
| {r : β} (hr : 0 < r) (e : Fin p β β) : | |
| Integrable (fun X : Mat p d => β« u,Real.log (atDensity r X (applyRows X s+e) u) βΟ) | |
| (Measure.pi (fun _ : Fin p => scalarRow d)) := by | |
| have : IsProbabilityMeasure (scalarRow d) := by unfold scalarRow; infer_instance | |
| have hi := (integrable_energy_joint Ο s hR hs e).integral_prod_left | |
| have he (X : Mat p d) : | |
| (β« u,Real.log (atDensity r X (applyRows X s+e) u) βΟ) = | |
| -(p:β)*Real.log r-(p:β)/2*Real.log (2*Real.pi)-(β« u,energy X (s-u) e βΟ)/(2*r^2) := by | |
| simp_rw [log_atDensity_shift hr] | |
| have hei : Integrable (fun u => energy X (s-u) e) Ο := by | |
| apply continuous_integrable_on_support Ο _ s R hs | |
| unfold energy applyRows; fun_prop | |
| rw [integral_sub (integrable_const _) (hei.div_const _),integral_div] | |
| simp | |
| simp_rw [he] | |
| exact (integrable_const _).sub (hi.div_const _) | |
| lemma log_shift_rows_local_ge {p d : β} (Ο : Measure (Vec d)) [IsProbabilityMeasure Ο] | |
| (s : Vec d) {R : β} (hR : 0 β€ R) (hs : βα΅ u βΟ,u β closedBall s R) | |
| {r : β} (hr : 0 < r) (e : Fin p β β) : | |
| -(p:β)*Real.log r-(p:β)/2*Real.log (2*Real.pi)- | |
| ((p:β)*R^2+β i,e i^2)/r^2 β€ | |
| (β« X : Mat p d,β« u,Real.log (atDensity r X (applyRows X s+e) u) βΟ | |
| βMeasure.pi (fun _ : Fin p => scalarRow d)) := by | |
| have : IsProbabilityMeasure (scalarRow d) := by unfold scalarRow; infer_instance | |
| simp_rw [log_atDensity_shift hr] | |
| have hi := integrable_energy_joint Ο s hR hs e | |
| have he (X : Mat p d) : | |
| (β« u,-(p:β)*Real.log r-(p:β)/2*Real.log (2*Real.pi)-energy X (s-u) e/(2*r^2) βΟ) = | |
| -(p:β)*Real.log r-(p:β)/2*Real.log (2*Real.pi)-(β« u,energy X (s-u) e βΟ)/(2*r^2) := by | |
| have hei : Integrable (fun u => energy X (s-u) e) Ο := by | |
| apply continuous_integrable_on_support Ο _ s R hs | |
| unfold energy applyRows; fun_prop | |
| rw [integral_sub (integrable_const _) (hei.div_const _),integral_div]; simp | |
| simp_rw [he] | |
| rw [integral_sub (integrable_const _) (hi.integral_prod_left.div_const _),integral_div] | |
| simp only [integral_const,measureReal_def,measure_univ,ENNReal.toReal_one,one_smul] | |
| have hb := energy_rows_local_le Ο s hR hs e | |
| have hrr : 0 < r^2 := sq_pos_of_pos hr | |
| have hdiv := (div_le_div_of_nonneg_right hb (by positivity : 0 β€ 2*r^2)) | |
| have heq : (2*(p:β)*R^2+2*β i,e i^2)/(2*r^2)=((p:β)*R^2+β i,e i^2)/r^2 := by ring | |
| rw [heq] at hdiv | |
| linarith | |
| end ReferenceGaussian | |
| end OAI | |