Mathlib.Probability
Probability helpers staged for Mathlib: Bernoulli and signed two-point laws, Gaussian calculations, convergence in distribution, kernel composition, finite marked Poisson experiments, and Stein-method CLT tools.
StdNormalCDF 5 core · 14 supporting This file provides self-contained one-dimensional standard-normal analysis. ★ stdNormalCDF_continuous★ probit_stdNormalCDF
Standard normal CDF and probit
This file provides self-contained one-dimensional standard-normal analysis. It
names the standard-normal density stdNormalPDF, CDF stdNormalCDF, and
probit inverse probit. It proves CDF symmetry, monotonicity, endpoint
limits, continuity, strict monotonicity, positivity, the strict upper bound by
one, and the two exact inversion identities stdNormalCDF_probit and
probit_stdNormalCDF.
For each real number , the standard-normal density at is .
Definition (Lean source)
For each real number , the standard-normal cumulative distribution function at is the probability that a mean-zero, variance-one normal random variable is at most .
Definition (Lean source)
The standard normal CDF Φ is continuous: the standard normal has no atoms.
Formal statement
Proof (Lean source)
For each real number , the probit at is the infimum of the real numbers for which the standard-normal cumulative distribution function at is at least .
Definition (Lean source)
For any real score x, applying the probit transform to Φ(x) recovers x: the probit function Φ⁻¹ is a left inverse of the standard normal CDF Φ.
Formal statement
Proof (Lean source)
14 supporting declarations (lemmas, instances)
-
stdNormalPDF_deflemma — The named standard-normal density is Mathlib's real Gaussian density with mean zero and variance one.Proof (Lean source)
-
stdNormalCDF_deflemma — The named standard-normal CDF is Mathlib's CDF for the standard real Gaussian law.Proof (Lean source)
-
stdNormalCDF_monotonelemma — Φ is monotone (inherited from the StieltjesFunction structure of cdf).conclusionProof (Lean source)
lemma stdNormalCDF_monotone : Monotone stdNormalCDF := by intro a b hab exact (monotone_cdf (gaussianReal 0 1)) hab -
stdNormalCDF_nonneglemma — For each real point, the standard-normal CDF is nonnegative.Proof (Lean source)
lemma stdNormalCDF_nonneg (x : ℝ) : 0 ≤ stdNormalCDF x := cdf_nonneg _ x -
stdNormalCDF_le_onelemma — The standard-normal CDF is at most one at every real point.Proof (Lean source)
lemma stdNormalCDF_le_one (x : ℝ) : stdNormalCDF x ≤ 1 := cdf_le_one _ x -
cdf_neg_of_map_neglemma — The CDF of an atomless probability measure invariant under reflection is symmetric.hypothesesProof (Lean source)
lemma cdf_neg_of_map_neg {μ : Measure ℝ} [IsProbabilityMeasure μ] [NullSingletonClass μ] (hmap : μ.map (fun x : ℝ => -x) = μ) (t : ℝ) : cdf μ (-t) = 1 - cdf μ t := by have hreal : ∀ s : ℝ, cdf μ s = μ.real (Iic s) := by intro s; exact cdf_eq_real _ s -- Reflection symmetry of the law: `Φ(-t) = μ.real (Ici t)`. have hpre : (fun x : ℝ => -x) ⁻¹' Iic (-t) = Ici t := by ext x; simp have step1 : cdf μ (-t) = μ.real (Ici t) := by rw [hreal (-t)] conv_lhs => rw [← hmap] rw [MeasureTheory.map_measureReal_apply measurable_neg measurableSet_Iic, hpre] rw [step1, ← Set.compl_Iio, MeasureTheory.measureReal_compl measurableSet_Iio, MeasureTheory.measureReal_congr MeasureTheory.Iio_ae_eq_Iic, MeasureTheory.probReal_univ, hreal t] -
stdNormalCDF_neglemma — Symmetry of the standard normal CDF: Φ(−t) = 1 − Φ(t), from the reflection symmetry of the Gaussian law and its atomlessness.Proof (Lean source)
lemma stdNormalCDF_neg (t : ℝ) : stdNormalCDF (-t) = 1 - stdNormalCDF t := by have hmap : (gaussianReal 0 1).map (fun x : ℝ => -x) = gaussianReal 0 1 := by rw [gaussianReal_map_neg, neg_zero] haveI : NullSingletonClass (gaussianReal 0 1) := nullSingletonClass_gaussianReal (v := 1) one_ne_zero exact cdf_neg_of_map_neg hmap t -
stdNormalCDF_tendsto_atBotlemma — Φ → 0 at -∞.conclusionProof (Lean source)
-
stdNormalCDF_tendsto_atToplemma — Φ → 1 at +∞.conclusionProof (Lean source)
-
cdf_continuous_of_noAtomslemma — The CDF of an atomless real probability measure is continuous.Proof (Lean source)
@[fun_prop] lemma cdf_continuous_of_noAtoms (μ : Measure ℝ) [IsProbabilityMeasure μ] [NullSingletonClass μ] : Continuous (cdf μ) := by set f := cdf μ with hf refine continuous_iff_continuousAt.2 fun x => ?_ refine (f.mono.continuousAt_iff_leftLim_eq_rightLim).2 ?_ rw [f.rightLim_eq x] have hjump : f.measure {x} = ofReal (f x - Function.leftLim (f : ℝ → ℝ) x) := f.measure_singleton x have hμx : f.measure {x} = 0 := by rw [hf, ProbabilityTheory.measure_cdf] exact measure_singleton x rw [hμx, eq_comm, ENNReal.ofReal_eq_zero] at hjump have hle : Function.leftLim (f : ℝ → ℝ) x ≤ f x := f.mono.leftLim_le (le_refl x) linarith [hjump, hle] -
stdNormalCDF_strictMonolemma — Φ is strictly monotone: the standard normal has full support.conclusionProof (Lean source)
lemma stdNormalCDF_strictMono : StrictMono stdNormalCDF := by intro a b hab have hfi : IntervalIntegrable (gaussianPDFReal 0 1) volume a b := (integrable_gaussianPDFReal 0 1).intervalIntegrable have hposInt : 0 < ∫ x in a..b, gaussianPDFReal 0 1 x := intervalIntegral.intervalIntegral_pos_of_pos hfi (fun x => gaussianPDFReal_pos 0 1 x one_ne_zero) hab have hposSet : 0 < ∫ x in Ioc a b, gaussianPDFReal 0 1 x := by simpa [intervalIntegral.integral_of_le hab.le] using hposInt have hμpos : 0 < (gaussianReal 0 1) (Ioc a b) := by rw [gaussianReal_apply_eq_integral (μ := 0) (v := 1) one_ne_zero] exact ENNReal.ofReal_pos.mpr hposSet have hmeasure : (gaussianReal 0 1) (Ioc a b) = ofReal (cdf (gaussianReal 0 1) b - cdf (gaussianReal 0 1) a) := by calc (gaussianReal 0 1) (Ioc a b) = (cdf (gaussianReal 0 1)).measure (Ioc a b) := by rw [ProbabilityTheory.measure_cdf (gaussianReal 0 1)] _ = ofReal (cdf (gaussianReal 0 1) b - cdf (gaussianReal 0 1) a) := by rw [StieltjesFunction.measure_Ioc] have hdiff : 0 < cdf (gaussianReal 0 1) b - cdf (gaussianReal 0 1) a := by exact ENNReal.ofReal_pos.mp (by simpa [hmeasure] using hμpos) exact sub_pos.mp hdiff -
stdNormalCDF_poslemma — 0 < Φ(x) for every real x (full support of the Gaussian).Proof (Lean source)
lemma stdNormalCDF_pos (x : ℝ) : 0 < stdNormalCDF x := by have hlt := stdNormalCDF_strictMono (by linarith : x - 1 < x) have hnon := stdNormalCDF_nonneg (x - 1) linarith -
stdNormalCDF_lt_onelemma — Φ(x) < 1 for every real x.Proof (Lean source)
lemma stdNormalCDF_lt_one (x : ℝ) : stdNormalCDF x < 1 := by have hlt := stdNormalCDF_strictMono (by linarith : x < x + 1) have hle := stdNormalCDF_le_one (x + 1) linarith -
stdNormalCDF_probitlemma — Φ(Φ⁻¹(p)) = p for p ∈ (0,1) (exact inversion, using continuity + strict monotonicity).Proof (Lean source)
lemma stdNormalCDF_probit {p : ℝ} (h0 : 0 < p) (h1 : p < 1) : stdNormalCDF (probit p) = p := by obtain ⟨a, ha⟩ := Filter.eventually_atBot.mp (stdNormalCDF_tendsto_atBot.eventually_lt_const h0) obtain ⟨b, hb⟩ := Filter.eventually_atTop.mp (stdNormalCDF_tendsto_atTop.eventually_const_lt h1) have hab : a < b := by by_contra hnot have hba : b ≤ a := le_of_not_gt hnot have hmono := stdNormalCDF_monotone hba linarith [ha a le_rfl, hb b le_rfl, hmono] have hpIcc : p ∈ Icc (stdNormalCDF a) (stdNormalCDF b) := ⟨(ha a le_rfl).le, (hb b le_rfl).le⟩ have hpimage : p ∈ stdNormalCDF '' Icc a b := intermediate_value_Icc hab.le stdNormalCDF_continuous.continuousOn hpIcc rcases hpimage with ⟨x, _hxI, hxeq⟩ have hset : {y : ℝ | p ≤ stdNormalCDF y} = Ici x := by ext y change p ≤ stdNormalCDF y ↔ x ≤ y rw [← hxeq] exact stdNormalCDF_strictMono.le_iff_le have hprobit : probit p = x := by rw [probit, hset, csInf_Ici] rw [hprobit, hxeq]
BernoulliMeasure 5 core · 17 supporting This file defines the Bernoulli law on the real line, supported on 0 and 1, and proves its basic probability, support, integral, absolute-continuity, and KL-divergence facts. ★ bernoulliLaw_klDiv_toReal★ bernoulliLaw_klDiv_le_four_sq_sub
Bernoulli measures
This file defines the Bernoulli law on the real line, supported on 0 and
1, and proves its basic probability, support, integral, absolute-continuity,
and KL-divergence facts. It also provides the corresponding Bool-valued law and
its measurability, probability, integral, bind, and map formulas.
For any real number interpreted as a success parameter, the real-valued Bernoulli measure assigns mass to and mass to .
Let be a Bernoulli success probability with , and let be a reference success probability with . Then the Kullback–Leibler divergence from the Bernoulli() law to the Bernoulli() law equals , the usual two-point KL formula: a success contribution plus a failure contribution.
Formal statement
Proof (Lean source)
If both success probabilities and lie in the middle half of the unit interval, and , then the Kullback–Leibler divergence from the Bernoulli() law to the Bernoulli() law is at most four times the squared difference of the probabilities, .
Formal statement
Proof (Lean source)
For any real number interpreted as a success parameter, the Boolean-valued Bernoulli measure assigns mass to true and mass to false.
For a nonnegative number of trials, a real success parameter, and a nonnegative count, the binomial weight is .
17 supporting declarations (lemmas, instances)
-
bernoulliLaw_integrallemma — Two-point integral for the custom bernoulliLaw: since bernoulliLaw p = ENNReal.ofReal p • dirac 1 + ENNReal.ofReal (1-p) • dirac 0, its integral splits via integral_add_measure / integral_smul_measure / integral_dirac into the two-point weighted sum, with 0 ≤ p ≤ 1 collapsing the ENNReal → ℝ coercions to p and 1 - p.hypothesesp :ℝhp0 :0 ≤ php1 :p ≤ 1f :ℝ → ℝconclusion∫ y, f y ∂(bernoulliLaw p) = p * f 1 + (1 - p) * f 0Proof (Lean source)
lemma bernoulliLaw_integral {p : ℝ} (hp0 : 0 ≤ p) (hp1 : p ≤ 1) (f : ℝ → ℝ) : ∫ y, f y ∂(bernoulliLaw p) = p * f 1 + (1 - p) * f 0 := by unfold bernoulliLaw rw [integral_add_measure] · rw [integral_smul_measure, integral_smul_measure] simp [hp0, sub_nonneg.mpr hp1, smul_eq_mul] · exact Integrable.smul_measure (μ := Measure.dirac (1 : ℝ)) (c := ofReal p) (integrable_dirac (f := f) (a := (1 : ℝ)) (by simp [enorm])) (by simp) · exact Integrable.smul_measure (μ := Measure.dirac (0 : ℝ)) (c := ofReal (1 - p)) (integrable_dirac (f := f) (a := (0 : ℝ)) (by simp [enorm])) (by simp) -
bernoulliLaw_isProbabilityMeasurelemma — The custom bernoulliLaw is a probability measure for 0 ≤ p ≤ 1: its total mass is p + (1 - p) = 1.Proof (Lean source)
lemma bernoulliLaw_isProbabilityMeasure {p : ℝ} (hp0 : 0 ≤ p) (hp1 : p ≤ 1) : IsProbabilityMeasure (bernoulliLaw p) := by rw [isProbabilityMeasure_iff] unfold bernoulliLaw rw [Measure.add_apply, Measure.smul_apply, Measure.smul_apply] simp only [Measure.dirac_apply, Set.indicator_of_mem, Set.mem_univ, Pi.one_apply, smul_eq_mul, mul_one] rw [← ENNReal.ofReal_add hp0 (sub_nonneg.mpr hp1)] norm_num -
bernoulliLaw_ae_nonneglemma — The Bernoulli law on the real line is almost surely nonnegative, since all of its mass is placed at 0 and 1.Proof (Lean source)
lemma bernoulliLaw_ae_nonneg {p : ℝ} : 0 ≤ᵐ[bernoulliLaw p] (fun y : ℝ => y) := by change (bernoulliLaw p) {y : ℝ | ¬ 0 ≤ y} = 0 have hset : {y : ℝ | ¬ 0 ≤ y} = {y | y < 0} := by ext y simp [not_le] rw [hset] unfold bernoulliLaw rw [Measure.add_apply, Measure.smul_apply, Measure.smul_apply] simp -
bernoulliLaw_ae_le_onelemma — The Bernoulli law on the real line is almost surely at most one, since all of its mass is placed at 0 and 1.Proof (Lean source)
lemma bernoulliLaw_ae_le_one {p : ℝ} : (fun y : ℝ => y) ≤ᵐ[bernoulliLaw p] fun _ => (1 : ℝ) := by change (bernoulliLaw p) {y : ℝ | ¬ y ≤ 1} = 0 have hset : {y : ℝ | ¬ y ≤ 1} = {y | 1 < y} := by ext y simp [not_le] rw [hset] unfold bernoulliLaw rw [Measure.add_apply, Measure.smul_apply, Measure.smul_apply] simp -
bernoulliLaw_ae_zero_or_onelemma — A draw from the real-valued Bernoulli law is almost surely either 0 or 1.hypothesesp :ℝconclusion∀ᵐ y ∂bernoulliLaw p, y = 0 ∨ y = 1Proof (Lean source)
lemma bernoulliLaw_ae_zero_or_one {p : ℝ} : ∀ᵐ y ∂bernoulliLaw p, y = 0 ∨ y = 1 := by change (bernoulliLaw p) {y : ℝ | ¬ (y = 0 ∨ y = 1)} = 0 unfold bernoulliLaw rw [Measure.add_apply, Measure.smul_apply, Measure.smul_apply] simp -
bernoulliLaw_ac_of_reference_interiorlemma — A Bernoulli law is absolutely continuous with respect to any Bernoulli law whose success probability is strictly between zero and one.Proof (Lean source)
lemma bernoulliLaw_ac_of_reference_interior {p q : ℝ} (hq0 : 0 < q) (hq1 : q < 1) : bernoulliLaw p ≪ bernoulliLaw q := by have hq_ne0 : ofReal q ≠ 0 := by intro h have hle := ENNReal.ofReal_eq_zero.mp h linarith have h1q_ne0 : ofReal (1 - q) ≠ 0 := by intro h have hle := ENNReal.ofReal_eq_zero.mp h linarith refine Measure.AbsolutelyContinuous.mk ?_ intro s hs hzero unfold bernoulliLaw at hzero ⊢ rw [Measure.add_apply, Measure.smul_apply, Measure.smul_apply] at hzero ⊢ by_cases h1 : (1 : ℝ) ∈ s · exfalso by_cases h0 : (0 : ℝ) ∈ s · simp [h1, h0, hq_ne0] at hzero · simp [h1, h0, hq_ne0] at hzero · by_cases h0 : (0 : ℝ) ∈ s · exfalso simp [h1, h0, h1q_ne0] at hzero · simp [h1, h0] -
bernoulliLaw_llr_integrablelemma — The log-likelihood ratio between any two real-parameter Bernoulli laws is integrable under the first law.Proof (Lean source)
@[fun_prop] lemma bernoulliLaw_llr_integrable {p q : ℝ} : Integrable (llr (bernoulliLaw p) (bernoulliLaw q)) (bernoulliLaw p) := by unfold bernoulliLaw rw [integrable_add_measure] constructor · exact Integrable.smul_measure (μ := Measure.dirac (1 : ℝ)) (c := ofReal p) (integrable_dirac (f := llr (ofReal p • Measure.dirac (1 : ℝ) + ofReal (1 - p) • Measure.dirac (0 : ℝ)) (bernoulliLaw q)) (a := (1 : ℝ)) (by simp [enorm])) (by simp) · exact Integrable.smul_measure (μ := Measure.dirac (0 : ℝ)) (c := ofReal (1 - p)) (integrable_dirac (f := llr (ofReal p • Measure.dirac (1 : ℝ) + ofReal (1 - p) • Measure.dirac (0 : ℝ)) (bernoulliLaw q)) (a := (0 : ℝ)) (by simp [enorm])) (by simp) -
bernoulliLaw_lintegral_ofReallemma — ℝ≥0∞/lintegral analogue of bernoulliLaw_integral: a Bernoulli law integrates an ℝ≥0∞-valued function as the two-point weighted sum.Proof (Lean source)
lemma bernoulliLaw_lintegral_ofReal {p : ℝ} (f : ℝ → ENNReal) : ∫⁻ y, f y ∂(bernoulliLaw p) = ofReal p * f 1 + ofReal (1 - p) * f 0 := by unfold bernoulliLaw rw [lintegral_add_measure] · simp [lintegral_smul_measure, mul_comm] -
measurable_bernoulliBoollemma — The Bool-valued Bernoulli distribution varies measurably with its success probability, so a measurable probability parameter can be used to construct a measurable kernel.conclusionProof (Lean source)
@[fun_prop] lemma measurable_bernoulliBool : Measurable bernoulliBool := by unfold bernoulliBool fun_prop -
bernoulliBool_isProbabilityMeasurelemma — A Bool-valued Bernoulli distribution is a probability distribution whenever its success probability lies between zero and one.Proof (Lean source)
lemma bernoulliBool_isProbabilityMeasure {p : ℝ} (hp0 : 0 ≤ p) (hp1 : p ≤ 1) : IsProbabilityMeasure (bernoulliBool p) := by rw [isProbabilityMeasure_iff] unfold bernoulliBool rw [Measure.add_apply, Measure.smul_apply, Measure.smul_apply] simp only [Measure.dirac_apply, Set.indicator_of_mem, Set.mem_univ, Pi.one_apply, smul_eq_mul, mul_one] rw [← ENNReal.ofReal_add hp0 (sub_nonneg.mpr hp1)] convert ENNReal.ofReal_one using 2 all_goals ring -
bernoulliBool_integrallemma — The expectation of a real-valued function of a Bool-valued Bernoulli draw is its value at success times the success probability plus its value at failure times the failure probability.hypothesesProof (Lean source)
lemma bernoulliBool_integral {p : ℝ} (hp0 : 0 ≤ p) (hp1 : p ≤ 1) (f : Bool → ℝ) : ∫ z, f z ∂bernoulliBool p = p * f true + (1 - p) * f false := by unfold bernoulliBool rw [integral_add_measure] · rw [integral_smul_measure, integral_smul_measure] simp [hp0, sub_nonneg.mpr hp1, smul_eq_mul] · exact Integrable.smul_measure (μ := Measure.dirac true) (c := ofReal p) (integrable_dirac (f := f) (a := true) (by simp [enorm])) (by simp) · exact Integrable.smul_measure (μ := Measure.dirac false) (c := ofReal (1 - p)) (integrable_dirac (f := f) (a := false) (by simp [enorm])) (by simp) -
bernoulliBool_bindlemma — Drawing a Bool-valued Bernoulli variable and then selecting a distribution according to its value produces the corresponding success-probability mixture of the two distributions.hypothesesProof (Lean source)
lemma bernoulliBool_bind {β : Type*} [MeasurableSpace β] (p : ℝ) (K : Bool → Measure β) : (bernoulliBool p).bind K = ofReal p • K true + ofReal (1 - p) • K false := by ext A hA rw [Measure.bind_apply hA (measurable_of_finite _).aemeasurable] unfold bernoulliBool rw [lintegral_add_measure, lintegral_smul_measure, lintegral_smul_measure] simp [Measure.add_apply, Measure.smul_apply, smul_eq_mul] -
bernoulliBool_maplemma — Transforming a Bool-valued Bernoulli draw produces a two-point distribution concentrated on the transformed success and failure values with their original probabilities.hypothesesProof (Lean source)
lemma bernoulliBool_map {β : Type*} [MeasurableSpace β] (p : ℝ) (f : Bool → β) : (bernoulliBool p).map f = ofReal p • Measure.dirac (f true) + ofReal (1 - p) • Measure.dirac (f false) := by have hf : Measurable f := measurable_of_finite f unfold bernoulliBool rw [Measure.map_add _ _ hf, Measure.map_smul, Measure.map_smul] rw [Measure.map_dirac' hf, Measure.map_dirac' hf] -
sum_bernoulli_eq_binomiallemma — A Bernoulli-weighted sum of any function of the success count equals the corresponding sum against the binomial mass function.hypothesesProof (Lean source)
lemma sum_bernoulli_eq_binomial {ι : Type*} [Fintype ι] [DecidableEq ι] (p : Real) (F : Nat → Real) : (∑ b : ι → Bool, (∏ i, if b i then p else 1 - p) * F (Finset.univ.filter fun i => b i = true).card) = ∑ j ∈ range (card ι + 1), binomialWeight (card ι) p j * F j := by classical rw [Fintype.sum_equiv (boolFunEquivFinset ι) _ (fun s : Finset ι => p ^ s.card * (1 - p) ^ (card ι - s.card) * F s.card) (fun b => by rw [prod_bernoulli_eq_card] rfl)] rw [show (Finset.univ : Finset (Finset ι)) = Finset.univ.powerset by ext s simp] rw [Finset.sum_powerset] apply Finset.sum_congr rfl intro j hj rw [Finset.sum_powersetCard j Finset.univ (fun j => p ^ j * (1 - p) ^ (card ι - j) * F j)] simp only [Finset.card_univ, binomialWeight] ring -
totalized_inverse_count_lelemma — The reciprocal of a positive integer, totalized to zero at the origin, is at most twice the reciprocal of its successor.Proof (Lean source)
lemma totalized_inverse_count_le (j : Nat) : (if 0 < j then (j : Real)⁻¹ else 0) ≤ 2 * ((j : Real) + 1)⁻¹ := by by_cases hj : 0 < j · rw [if_pos hj, ← div_eq_mul_inv] have hjR : (0 : Real) < j := by exact_mod_cast hj have hj1R : (0 : Real) < (j : Real) + 1 := by positivity apply (le_div_iff₀ hj1R).2 calc (j : Real)⁻¹ * ((j : Real) + 1) = 1 + (j : Real)⁻¹ := by field_simp _ ≤ 2 := by have hinv : (j : Real)⁻¹ ≤ 1 := (inv_le_one₀ hjR).2 (by exact_mod_cast hj) linarith · simp [hj] positivity -
binomial_totalized_inverse_count_lelemma — When the success probability is positive and at most one, the binomial expectation of the zero-safe inverse success count is at most twice the reciprocal of the trial count plus one times that probability.hypothesesconclusionProof (Lean source)
lemma binomial_totalized_inverse_count_le (m : Nat) (p : Real) (hp : 0 < p) (hp1 : p ≤ 1) : (∑ j ∈ range (m + 1), binomialWeight m p j * (if 0 < j then (j : Real)⁻¹ else 0)) ≤ 2 / (((m + 1 : Nat) : Real) * p) := by -- Proof route: compare `1/j` with `2/(j+1)`, shift `choose m j`, -- and evaluate the resulting binomial row by `add_pow`. let d : Real := ((m + 1 : Nat) : Real) * p let S : Real := ∑ j ∈ range (m + 1), binomialWeight m p j * ((j : Real) + 1)⁻¹ have hq : 0 ≤ 1 - p := sub_nonneg.mpr hp1 have hd : 0 < d := by dsimp [d] positivity have hterm (j : Nat) (hj : j ∈ range (m + 1)) : d * (binomialWeight m p j * ((j : Real) + 1)⁻¹) = (Nat.choose (m + 1) (j + 1) : Real) * p ^ (j + 1) * (1 - p) ^ ((m + 1) - (j + 1)) := by have hjlt : j < m + 1 := Finset.mem_range.mp hj have hsub : (m + 1) - (j + 1) = m - j := by omega have hc : (((m + 1 : Nat) : Real) * (Nat.choose m j : Real)) = (Nat.choose (m + 1) (j + 1) : Real) * ((j + 1 : Nat) : Real) := by exact_mod_cast Nat.add_one_mul_choose_eq m j dsimp [d] rw [binomialWeight, hsub, pow_succ] field_simp calc ((m + 1 : Nat) : Real) * (Nat.choose m j : Real) * (1 - p) ^ (m - j) = ((((m + 1 : Nat) : Real) * (Nat.choose m j : Real)) * (1 - p) ^ (m - j)) := by ring _ = (((Nat.choose (m + 1) (j + 1) : Real) * ((j + 1 : Nat) : Real)) * (1 - p) ^ (m - j)) := by rw [hc] _ = (1 - p) ^ (m - j) * ((j : Real) + 1) * (Nat.choose (m + 1) (j + 1) : Real) := by push_cast; ring have hid : d * S = 1 - (1 - p) ^ (m + 1) := by dsimp [S] rw [Finset.mul_sum] calc (∑ j ∈ range (m + 1), d * (binomialWeight m p j * ((j : Real) + 1)⁻¹)) = ∑ j ∈ range (m + 1), p ^ (j + 1) * (1 - p) ^ ((m + 1) - (j + 1)) * (Nat.choose (m + 1) (j + 1) : Real) := by apply Finset.sum_congr rfl intro j hj rw [hterm j hj] ring _ = (p + (1 - p)) ^ (m + 1) - (1 - p) ^ (m + 1) := by rw [add_pow] rw [Finset.sum_range_succ' (fun k => p ^ k * (1 - p) ^ ((m + 1) - k) * (Nat.choose (m + 1) k : Real)) (m + 1)] simp _ = 1 - (1 - p) ^ (m + 1) := by ring have hS : S ≤ 1 / d := by apply (le_div_iff₀ hd).2 rw [mul_comm S d, hid] have hpow := pow_nonneg hq (m + 1) linarith calc (∑ j ∈ range (m + 1), binomialWeight m p j * (if 0 < j then (j : Real)⁻¹ else 0)) ≤ ∑ j ∈ range (m + 1), binomialWeight m p j * (2 * ((j : Real) + 1)⁻¹) := by apply Finset.sum_le_sum intro j hj apply mul_le_mul_of_nonneg_left (totalized_inverse_count_le j) dsimp [binomialWeight] positivity _ = 2 * S := by dsimp [S] rw [Finset.mul_sum] apply Finset.sum_congr rfl intro j hj ring _ ≤ 2 * (1 / d) := by nlinarith _ = 2 / (((m + 1 : Nat) : Real) * p) := by dsimp [d] ring -
binomial_inverse_complementary_counts_interior_lelemma — For a trial count, a success probability, and a parameter margin, if the margin is positive and the probability is at least the margin and at most one minus the margin, the binomial expectation of the inverse success and complementary counts on the interior event is at most four divided by the trial count plus one times the margin.hypothesesProof (Lean source)
lemma binomial_inverse_complementary_counts_interior_le (m : Nat) (p epsilon : Real) (hepsilon : 0 < epsilon) (hlo : epsilon ≤ p) (hhi : p ≤ 1 - epsilon) : (∑ j ∈ range (m + 1), binomialWeight m p j * (if 0 < j ∧ j < m then (j : Real)⁻¹ + ((m - j : Nat) : Real)⁻¹ else 0)) ≤ 4 / (((m + 1 : Nat) : Real) * epsilon) := by -- Apply the preceding estimate to successes with parameter `p` and to -- failures with parameter `1-p`; deleting the two endpoints only lowers -- the nonnegative sums. Then use both overlap inequalities. have hp : 0 < p := lt_of_lt_of_le hepsilon hlo have hp1 : p ≤ 1 := by linarith have hq : 0 < 1 - p := by linarith have hq1 : 1 - p ≤ 1 := by linarith have hinter (j : Nat) : (if 0 < j ∧ j < m then (j : Real)⁻¹ + ((m - j : Nat) : Real)⁻¹ else 0) ≤ (if 0 < j then (j : Real)⁻¹ else 0) + (if 0 < m - j then ((m - j : Nat) : Real)⁻¹ else 0) := by by_cases hj : 0 < j ∧ j < m · have hmj : 0 < m - j := Nat.sub_pos_of_lt hj.2 simp [hj, hmj] · rw [if_neg hj] positivity have hfail : (∑ j ∈ range (m + 1), binomialWeight m p j * (if 0 < m - j then ((m - j : Nat) : Real)⁻¹ else 0)) = ∑ j ∈ range (m + 1), binomialWeight m (1 - p) j * (if 0 < j then (j : Real)⁻¹ else 0) := by rw [← Finset.sum_range_reflect (fun j => binomialWeight m p j * (if 0 < m - j then ((m - j : Nat) : Real)⁻¹ else 0)) (m + 1)] apply Finset.sum_congr rfl intro j hj have hjlt : j < m + 1 := Finset.mem_range.mp hj have hjle : j ≤ m := by omega have hreflect : m + 1 - 1 - j = m - j := by omega have hcancel : m - (m - j) = j := by omega rw [hreflect, binomialWeight, binomialWeight, hcancel, Nat.choose_symm hjle] congr 1 ring have hsuccess := binomial_totalized_inverse_count_le m p hp hp1 have hfailure := binomial_totalized_inverse_count_le m (1 - p) hq hq1 have hn : (0 : Real) < ((m + 1 : Nat) : Real) := by positivity have hnepsilon : ((m + 1 : Nat) : Real) * epsilon ≤ ((m + 1 : Nat) : Real) * p := mul_le_mul_of_nonneg_left hlo hn.le have hnqepsilon : ((m + 1 : Nat) : Real) * epsilon ≤ ((m + 1 : Nat) : Real) * (1 - p) := by apply mul_le_mul_of_nonneg_left _ hn.le linarith have hinvp : 1 / (((m + 1 : Nat) : Real) * p) ≤ 1 / (((m + 1 : Nat) : Real) * epsilon) := one_div_le_one_div_of_le (mul_pos hn hepsilon) hnepsilon have hinvq : 1 / (((m + 1 : Nat) : Real) * (1 - p)) ≤ 1 / (((m + 1 : Nat) : Real) * epsilon) := one_div_le_one_div_of_le (mul_pos hn hepsilon) hnqepsilon calc (∑ j ∈ range (m + 1), binomialWeight m p j * (if 0 < j ∧ j < m then (j : Real)⁻¹ + ((m - j : Nat) : Real)⁻¹ else 0)) ≤ ∑ j ∈ range (m + 1), binomialWeight m p j * ((if 0 < j then (j : Real)⁻¹ else 0) + (if 0 < m - j then ((m - j : Nat) : Real)⁻¹ else 0)) := by apply Finset.sum_le_sum intro j hj apply mul_le_mul_of_nonneg_left (hinter j) dsimp [binomialWeight] positivity _ = (∑ j ∈ range (m + 1), binomialWeight m p j * (if 0 < j then (j : Real)⁻¹ else 0)) + ∑ j ∈ range (m + 1), binomialWeight m p j * (if 0 < m - j then ((m - j : Nat) : Real)⁻¹ else 0) := by rw [← Finset.sum_add_distrib] apply Finset.sum_congr rfl intro j hj ring _ ≤ 2 / (((m + 1 : Nat) : Real) * p) + 2 / (((m + 1 : Nat) : Real) * (1 - p)) := by rw [hfail] linarith _ ≤ 4 / (((m + 1 : Nat) : Real) * epsilon) := by rw [show 2 / (((m + 1 : Nat) : Real) * p) = 2 * (1 / (((m + 1 : Nat) : Real) * p)) by ring, show 2 / (((m + 1 : Nat) : Real) * (1 - p)) = 2 * (1 / (((m + 1 : Nat) : Real) * (1 - p))) by ring, show 4 / (((m + 1 : Nat) : Real) * epsilon) = 4 * (1 / (((m + 1 : Nat) : Real) * epsilon)) by ring] linarith
ConvergenceInDistribution 2 core · 2 supporting This file collects general convergence-in-distribution lemmas that are not specific to the causal-inference layer. ★ const_mul_of_tendsto_const★ tendsto_map_mul_of_tendsto
Convergence in Distribution Helpers
This file collects general convergence-in-distribution lemmas that are not specific to the causal-inference layer. It provides deterministic-scalar Slutsky results for random variables and for weak convergence of probability measures on the real line.
The lemma tendstoInMeasure_const_of_tendsto converts ordinary
convergence of deterministic real scalars into convergence in measure for
constant random variables. TendstoInDistribution.const_mul_of_tendsto_const
then proves random-variable Slutsky for deterministic scalar multiplication,
and ProbabilityMeasure.tendsto_map_mul_of_tendsto gives the analogous
probability-measure pushforward theorem.
Deterministic-scalar Slutsky theorem for random variables. If a sequence of random variables X n converges in distribution to Z, all under the same probability measure μ and a sequence of deterministic real scalars a n converges to a limit a₀, then the scaled sequence a n · X n converges in distribution to a₀ · Z.
Formal statement
Proof (Lean source)
Measure-level deterministic-scalar Slutsky theorem for weak convergence. For a filter l along which a family of probability measures on the reals converges weakly to a limit measure ν and a family of real scalars converges to a limit a₀, then the pushforwards of the measures by scalar multiplication x ↦ aᵢ·x converge weakly to the pushforward of ν by x ↦ a₀·x.
Formal statement
Proof (Lean source)
2 supporting declarations (lemmas, instances)
-
tendstoInMeasure_const_of_tendstolemma — A deterministic sequence in a seminormed additive commutative group that converges in the usual topological sense also converges in measure when regarded as a sequence of constant random variables.hypothesesconclusionTendstoInMeasure μ (fun n => fun _ : Ω => a n) l (fun _ => a₀)Proof (Lean source)
lemma tendstoInMeasure_const_of_tendsto {E : Type*} [SeminormedAddCommGroup E] {a : ι → E} {a₀ : E} (ha : Tendsto a l (𝓝 a₀)) : TendstoInMeasure μ (fun n => fun _ : Ω => a n) l (fun _ => a₀) := by rw [tendstoInMeasure_iff_norm] intro ε hε have hev : ∀ᶠ n in l, ‖a n - a₀‖ < ε := by filter_upwards [(Metric.tendsto_nhds.mp ha) ε hε] with n hn simpa [dist_eq_norm] using hn refine tendsto_const_nhds.congr' ?_ filter_upwards [hev] with n hn have hset : {x : Ω | ε ≤ ‖(fun _ : Ω => a n) x - (fun _ : Ω => a₀) x‖} = ∅ := by ext x simp [not_le.mpr hn] rw [hset] simp -
map_mul_eq_map_prod_diraclemma — Multiplying a deterministic real value and a random draw has the same distribution as scaling that random draw by the deterministic value.hypothesesc :ℝν :conclusion= ν.map ((measurable_const.mul measurable_id).aemeasurable : AEMeasurable (fun x : ℝ => c * x) (ν : Measure ℝ))Proof (Lean source)
lemma map_mul_eq_map_prod_dirac (c : ℝ) (ν : ProbabilityMeasure ℝ) : ((diracProba c).prod ν).map ((by fun_prop : Measurable (fun p : ℝ × ℝ => p.1 * p.2)).aemeasurable) = ν.map ((measurable_const.mul measurable_id).aemeasurable : AEMeasurable (fun x : ℝ => c * x) (ν : Measure ℝ)) := by apply Subtype.ext change Measure.map (fun p : ℝ × ℝ => p.1 * p.2) ((Measure.dirac c).prod (ν : Measure ℝ)) = Measure.map (fun x : ℝ => c * x) (ν : Measure ℝ) rw [Measure.dirac_prod] rw [Measure.map_map] · rfl · fun_prop · fun_prop
CovarianceCauchySchwarz 1 core · 1 supporting For square-integrable statistics X and Y under a finite measure, the squared covariance is at most the product of the variances (covariance_sq_le_variance_mul), equivalently the absolute covariance is at most the product ★ abs_covariance_le_sqrt_mul
Cauchy–Schwarz for covariance
For square-integrable statistics X and Y under a finite measure, the squared covariance is at
most the product of the variances (covariance_sq_le_variance_mul), equivalently the absolute
covariance is at most the product of the standard deviations (abs_covariance_le_sqrt_mul). This
is the covariance form of the Cauchy–Schwarz inequality, filling a gap in Mathlib's covariance API.
Cauchy–Schwarz for covariance. Under a finite measure, if is square-integrable and is square-integrable, then the absolute value of their covariance is at most the product of their standard deviations, .
Proof (Lean source)
1 supporting declaration (lemmas, instances)
-
covariance_sq_le_variance_multheorem — Cauchy–Schwarz for covariance (squared form). For square-integrable statistics under a finite measure, the squared covariance is at most the product of the two variances.Proof (Lean source)
theorem covariance_sq_le_variance_mul [IsFiniteMeasure μ] {X Y : Ω → ℝ} (hX : MemLp X 2 μ) (hY : MemLp Y 2 μ) : covariance X Y μ ^ 2 ≤ variance X μ * variance Y μ := by have hquad : ∀ t : ℝ, 0 ≤ variance X μ - 2 * t * covariance X Y μ + t ^ 2 * variance Y μ := by intro t have hsub : MemLp (t • Y) 2 μ := hY.const_smul t have h := variance_nonneg (fun ω => X ω - (t • Y) ω) μ rw [variance_fun_sub hX hsub, variance_smul, covariance_smul_right] at h simpa [Pi.smul_apply, smul_eq_mul, mul_assoc] using h by_cases hvar : variance Y μ = 0 · have hcov : covariance X Y μ = 0 := by by_contra hcov have h := hquad ((variance X μ + 1) / (2 * covariance X Y μ)) rw [hvar] at h have hvalue : variance X μ - 2 * ((variance X μ + 1) / (2 * covariance X Y μ)) * covariance X Y μ = -1 := by field_simp [hcov] ring rw [hvalue] at h norm_num at h simp [hvar, hcov] · have hvarpos : 0 < variance Y μ := lt_of_le_of_ne (variance_nonneg Y μ) (Ne.symm hvar) apply (div_le_iff₀ hvarpos).mp have h := hquad (covariance X Y μ / variance Y μ) have hvalue : variance X μ - 2 * (covariance X Y μ / variance Y μ) * covariance X Y μ + (covariance X Y μ / variance Y μ) ^ 2 * variance Y μ = variance X μ - covariance X Y μ ^ 2 / variance Y μ := by field_simp [hvar] ring rw [hvalue] at h linarith
EventSelectedMixture 2 core · 4 supporting This module defines a two-branch function selected by an independent measurable event and computes its first moment, second moment, and variance under the product probability law. ★ variance_eventSelectedMixture
Event-selected mixtures under a product law
This module defines a two-branch function selected by an independent measurable event and computes its first moment, second moment, and variance under the product probability law.
Given an event, two branch functions, and a point in the product space, the event-selected mixture uses the first branch on the event and the second branch off the event.
For two probability laws, a measurable event, and two square-integrable branch functions, the selected function's variance is the mixture of branch variances plus the between-branch mean term.
Formal statement
Proof (Lean source)
4 supporting declarations (lemmas, instances)
-
memLp_mul_prod_twolemma — A product of independent square-integrable scalar functions remains square-integrable on the product space. The two factors are square-integrable, and their coordinatewise product is square-integrable under the product measure.hypotheseshf :MemLp f 2 muShg :MemLp g 2 muKconclusionMemLp (fun z : S × K ↦ f z.1 * g z.2) 2 (muS.prod muK)Proof (Lean source)
lemma memLp_mul_prod_two {S K : Type*} [Countable S] [Countable K] [MeasurableSpace S] [MeasurableSpace K] [MeasurableSingletonClass S] [MeasurableSingletonClass K] {muS : Measure S} {muK : Measure K} {f : S → Real} {g : K → Real} (hf : MemLp f 2 muS) (hg : MemLp g 2 muK) : MemLp (fun z : S × K ↦ f z.1 * g z.2) 2 (muS.prod muK) := by apply (memLp_two_iff_integrable_sq (measurable_of_countable _).aestronglyMeasurable).2 apply (hf.integrable_sq.mul_prod hg.integrable_sq).congr filter_upwards [] with z ring -
integral_eventSelectedMixturelemma — For two probability laws, a measurable event, and two integrable branch functions, the selected function's mean is the event-probability mixture of the two branch means.hypothesesJ E :μJ :Measure JμE :Measure EA :Set JhA :P H :E → RealhP :Integrable P μEhH :Integrable H μEconclusion∫ z, eventSelectedMixture A P H z ∂μJ.prod μE= μJ.real A * (∫ e, P e ∂μE) + (1 - μJ.real A) * (∫ e, H e ∂μE)Proof (Lean source)
lemma integral_eventSelectedMixture {J E : Type*} [MeasurableSpace J] [MeasurableSpace E] (μJ : Measure J) (μE : Measure E) [IsProbabilityMeasure μJ] [IsProbabilityMeasure μE] (A : Set J) (hA : MeasurableSet A) (P H : E → Real) (hP : Integrable P μE) (hH : Integrable H μE) : ∫ z, eventSelectedMixture A P H z ∂μJ.prod μE = μJ.real A * (∫ e, P e ∂μE) + (1 - μJ.real A) * (∫ e, H e ∂μE) := by classical let I := eventIndicator A let Ic : J → Real := fun j ↦ 1 - I j have hI : Integrable I μJ := integrable_eventIndicator μJ A hA have hIc : Integrable Ic μJ := (integrable_const 1).sub hI have hpoint : eventSelectedMixture A P H = fun z ↦ I z.1 * P z.2 + Ic z.1 * H z.2 := by funext z by_cases hz : z.1 ∈ A <;> simp [eventSelectedMixture, I, Ic, eventIndicator, hz] rw [hpoint, integral_add (hI.mul_prod hP) (hIc.mul_prod hH), integral_prod_mul, integral_prod_mul, integral_eventIndicator μJ A hA] have hIcInt : (∫ j, Ic j ∂μJ) = 1 - μJ.real A := by dsimp [Ic] rw [integral_sub (integrable_const 1) hI, integral_eventIndicator μJ A hA] simp rw [hIcInt] -
integral_eventSelectedMixture_sqlemma — For two probability laws, a measurable event, and two square-integrable branch functions, the selected function's second moment is the event-probability mixture of the two branch second moments.hypothesesJ E :μJ :Measure JμE :Measure EA :Set JhA :P H :E → RealhP :MemLp P 2 μEhH :MemLp H 2 μEconclusion∫ z, eventSelectedMixture A P H z ^ 2 ∂μJ.prod μE= μJ.real A * (∫ e, P e ^ 2 ∂μE) + (1 - μJ.real A) * (∫ e, H e ^ 2 ∂μE)Proof (Lean source)
lemma integral_eventSelectedMixture_sq {J E : Type*} [MeasurableSpace J] [MeasurableSpace E] (μJ : Measure J) (μE : Measure E) [IsProbabilityMeasure μJ] [IsProbabilityMeasure μE] (A : Set J) (hA : MeasurableSet A) (P H : E → Real) (hP : MemLp P 2 μE) (hH : MemLp H 2 μE) : ∫ z, eventSelectedMixture A P H z ^ 2 ∂μJ.prod μE = μJ.real A * (∫ e, P e ^ 2 ∂μE) + (1 - μJ.real A) * (∫ e, H e ^ 2 ∂μE) := by have h := integral_eventSelectedMixture μJ μE A hA (fun e ↦ P e ^ 2) (fun e ↦ H e ^ 2) hP.integrable_sq hH.integrable_sq rw [← h] apply integral_congr_ae filter_upwards [] with z by_cases hz : z.1 ∈ A <;> simp [eventSelectedMixture, hz] -
memLp_eventSelectedMixturelemma — For two probability laws, a measurable event, and two square-integrable branch functions, the event-selected mixture is square-integrable under the product law.hypothesesJ E :μJ :Measure JμE :Measure EA :Set JhA :P H :E → RealhP :MemLp P 2 μEhH :MemLp H 2 μEconclusionMemLp (eventSelectedMixture A P H) 2 (μJ.prod μE)Proof (Lean source)
lemma memLp_eventSelectedMixture {J E : Type*} [MeasurableSpace J] [MeasurableSpace E] (μJ : Measure J) (μE : Measure E) [IsProbabilityMeasure μJ] [IsProbabilityMeasure μE] (A : Set J) (hA : MeasurableSet A) (P H : E → Real) (hP : MemLp P 2 μE) (hH : MemLp H 2 μE) : MemLp (eventSelectedMixture A P H) 2 (μJ.prod μE) := by have hPA : MemLp ((fst ⁻¹' A).indicator (fun z : J × E ↦ P z.2)) 2 (μJ.prod μE) := (hP.comp_measurePreserving measurePreserving_snd).indicator (hA.preimage measurable_fst) have hHA : MemLp ((fst ⁻¹' A)ᶜ.indicator (fun z : J × E ↦ H z.2)) 2 (μJ.prod μE) := (hH.comp_measurePreserving measurePreserving_snd).indicator (hA.preimage measurable_fst).compl exact hPA.add hHA
FiniteCellConditionalMomentBridge 8 core · 16 supporting This module provides generic probability tools for conditioning on a measurable positive-mass cell by normalizing its restricted measure. ★ eventCondExp_eq_sum_condProb_mul_eventCondExp★ normalizedRestricted_crossMomentMatrix_eq_outer
Finite-cell conditional moments
This module provides generic probability tools for conditioning on a measurable positive-mass cell by normalizing its restricted measure. It turns bounded-test factorization into independence and into finite-coordinate moment factorization.
Given a measurable sample space, a measure on it, and a cell in that sample space, the normalized restricted measure is the measure restricted to the cell and scaled by the reciprocal of the measure of that cell.
Definition (Lean source)
Given a measurable sample space, a normed outcome space, a measure, a cell, and a function, the normalized restricted integral integrates the function against the normalized restriction.
Definition (Lean source)
For a finite index type ι, a measure μ, a measurable set A, measurable cells C that are pairwise disjoint, cover the space, and whose intersections with A have finite mass, and an integrable function f on a measurable space, the mass-ratio cell decomposition holds.
Formal statement
Proof (Lean source)
Given a measurable sample space, two measurable value spaces, a measure, and two random elements, the bounded-test factorization condition holds exactly when, for every pair of measurable bounded real-valued test functions on the two value spaces, the integral of their product after applying the two random elements equals the product of their separate integrals.
Definition (Lean source)
Given a measurable sample space, two measurable value spaces, a measure, a cell, and two random elements, the normalized restricted bounded-test factorization condition is bounded-test factorization of those random elements under the normalized restriction of the measure to the cell.
Definition (Lean source)
Given a measurable sample space, a finite vector dimension, a measure, and a finite-dimensional real random vector, the first-moment vector has at each coordinate the integral of the corresponding coordinate of the random vector.
Definition (Lean source)
Given a measurable sample space, two finite vector dimensions, a measure, and two finite-dimensional real random vectors, the cross-moment matrix has at each ordered pair of coordinates the integral of the product of the corresponding coordinates of the two random vectors.
For a measurable positive-mass cell, measurable finite-coordinate random vectors, integrable individual coordinates, and factorization of every bounded measurable test under the normalized cell law, the complete normalized cross-moment matrix is the outer product of the two normalized first-moment vectors.
Formal statement
Proof (Lean source)
16 supporting declarations (lemmas, instances)
-
eventCondExp_eqlemma — For a measure μ, a set A, a real function g, and a measurable space, the normalized restricted integral is the mass quotient.hypothesesconclusionnormalizedRestrictedIntegral μ A g = (∫ ω in A, g ω ∂μ) / (μ A).toRealProof (Lean source)
lemma eventCondExp_eq (μ : Measure Ω) (A : Set Ω) (g : Ω → ℝ) : normalizedRestrictedIntegral μ A g = (∫ ω in A, g ω ∂μ) / (μ A).toReal := by simp only [normalizedRestrictedIntegral, normalizedRestrict, MeasureTheory.integral_smul_measure, ENNReal.toReal_inv] rw [div_eq_inv_mul, smul_eq_mul] -
eventCondExp_mul_measure_toReallemma — For a measure μ, a set A, finite mass, a real function f, and a measurable space, the normalized integral satisfies the scaling identity.hypothesesconclusionnormalizedRestrictedIntegral μ A f * (μ A).toReal = ∫ ω in A, f ω ∂μProof (Lean source)
lemma eventCondExp_mul_measure_toReal (μ : Measure Ω) (A : Set Ω) (hA_fin : μ A ≠ ⊤) (f : Ω → ℝ) : normalizedRestrictedIntegral μ A f * (μ A).toReal = ∫ ω in A, f ω ∂μ := by simp only [eventCondExp_eq] by_cases h0 : (μ A).toReal = 0 · rw [h0, mul_zero] have hμ0 : μ A = 0 := by rcases (ENNReal.toReal_eq_zero_iff _).mp h0 with h | h · exact h · exact absurd h hA_fin exact (MeasureTheory.setIntegral_measure_zero f hμ0).symm · field_simp -
integral_eq_sum_measure_mul_eventCondExplemma — For a finite index type ι, a finite measure μ, measurable cells A that are measurable, pairwise disjoint, and cover the space, and an integrable real function f on a measurable space, the finite-partition identity holds.hypothesesΩ :sharedType u_1ι :Type*Fintype ιμ :A :ι → Set Ωhmeas :∀ i, MeasurableSet (A i)hcov :(⋃ i, A i) = univf :Ω → ℝhf :Integrable f μconclusion∫ ω, f ω ∂μ = ∑ i, (μ (A i)).toReal * normalizedRestrictedIntegral μ (A i) fProof (Lean source)
lemma integral_eq_sum_measure_mul_eventCondExp {ι : Type*} [Fintype ι] (μ : Measure Ω) [IsFiniteMeasure μ] (A : ι → Set Ω) (hmeas : ∀ i, MeasurableSet (A i)) (hdisj : Pairwise (onFun Disjoint A)) (hcov : (⋃ i, A i) = univ) (f : Ω → ℝ) (hf : Integrable f μ) : ∫ ω, f ω ∂μ = ∑ i, (μ (A i)).toReal * normalizedRestrictedIntegral μ (A i) f := by have hsplit : ∫ ω in (⋃ i, A i), f ω ∂μ = ∑ i, ∫ ω in A i, f ω ∂μ := MeasureTheory.integral_iUnion_fintype hmeas hdisj (fun _ => hf.integrableOn) have hcov' : ∫ ω, f ω ∂μ = ∑ i, ∫ ω in A i, f ω ∂μ := by rw [← hsplit, hcov, setIntegral_univ] rw [hcov'] refine Finset.sum_congr rfl (fun i _ => ?_) rw [mul_comm, ← eventCondExp_mul_measure_toReal μ (A i) (measure_ne_top _ _) f] -
eventCondExp_congr_aelemma — For a measure μ, a set A, a real function f, a real function g, a measurable space, and almost-everywhere agreement, their normalized restricted integrals are equal.hypothesesconclusionnormalizedRestrictedIntegral μ A f = normalizedRestrictedIntegral μ A gProof (Lean source)
lemma eventCondExp_congr_ae (μ : Measure Ω) (A : Set Ω) {f g : Ω → ℝ} (h : f =ᵐ[μ.restrict A] g) : normalizedRestrictedIntegral μ A f = normalizedRestrictedIntegral μ A g := by simp only [eventCondExp_eq] rw [MeasureTheory.integral_congr_ae h] -
eventCondExp_congr_onlemma — For a measure μ, a measurable set A, real functions f and g, a measurable space, and pointwise agreement on A, their normalized restricted integrals are equal.hypothesesconclusionnormalizedRestrictedIntegral μ A f = normalizedRestrictedIntegral μ A gProof (Lean source)
lemma eventCondExp_congr_on (μ : Measure Ω) {A : Set Ω} (hA : MeasurableSet A) {f g : Ω → ℝ} (h : ∀ ω ∈ A, f ω = g ω) : normalizedRestrictedIntegral μ A f = normalizedRestrictedIntegral μ A g := by simp only [eventCondExp_eq] congr 1 exact MeasureTheory.setIntegral_congr_fun hA h -
eventCondExp_mono_aelemma — For a measure μ, a set A, a real function f, a real function g, a measurable space, integrability on A, and almost-everywhere order, the normalized integral order is preserved.hypothesesΩ :sharedType u_1μ :Measure ΩA :Set Ωf g :Ω → ℝhf :IntegrableOn f A μhg :IntegrableOn g A μhfg :f ≤ᵐ[μ.restrict A] gconclusionnormalizedRestrictedIntegral μ A f ≤ normalizedRestrictedIntegral μ A gProof (Lean source)
lemma eventCondExp_mono_ae (μ : Measure Ω) {A : Set Ω} {f g : Ω → ℝ} (hf : IntegrableOn f A μ) (hg : IntegrableOn g A μ) (hfg : f ≤ᵐ[μ.restrict A] g) : normalizedRestrictedIntegral μ A f ≤ normalizedRestrictedIntegral μ A g := by simp only [eventCondExp_eq] have hint_le : ∫ ω in A, f ω ∂μ ≤ ∫ ω in A, g ω ∂μ := MeasureTheory.setIntegral_mono_ae_restrict hf hg hfg have hnn : (0 : ℝ) ≤ (μ A).toReal := ENNReal.toReal_nonneg exact div_le_div_of_nonneg_right hint_le hnn -
eventCondExp_addlemma — For a measure μ, a set A, a real function g₁, a real function g₂, a measurable space, and integrability on A, the normalized restricted integral is additive.hypothesesΩ :sharedType u_1μ :Measure ΩA :Set Ωg₁ g₂ :Ω → ℝh₁ :IntegrableOn g₁ A μh₂ :IntegrableOn g₂ A μconclusionnormalizedRestrictedIntegral μ A (g₁ + g₂)= normalizedRestrictedIntegral μ A g₁ + normalizedRestrictedIntegral μ A g₂Proof (Lean source)
lemma eventCondExp_add (μ : Measure Ω) (A : Set Ω) {g₁ g₂ : Ω → ℝ} (h₁ : IntegrableOn g₁ A μ) (h₂ : IntegrableOn g₂ A μ) : normalizedRestrictedIntegral μ A (g₁ + g₂) = normalizedRestrictedIntegral μ A g₁ + normalizedRestrictedIntegral μ A g₂ := by simp only [eventCondExp_eq, Pi.add_apply, integral_add h₁ h₂, add_div] -
eventCondExp_sublemma — For a measure μ, a set A, a real function g₁, a real function g₂, a measurable space, and integrability on A, the normalized restricted integral preserves subtraction.hypothesesΩ :sharedType u_1μ :Measure ΩA :Set Ωg₁ g₂ :Ω → ℝh₁ :IntegrableOn g₁ A μh₂ :IntegrableOn g₂ A μconclusionnormalizedRestrictedIntegral μ A (g₁ - g₂)= normalizedRestrictedIntegral μ A g₁ - normalizedRestrictedIntegral μ A g₂Proof (Lean source)
lemma eventCondExp_sub (μ : Measure Ω) (A : Set Ω) {g₁ g₂ : Ω → ℝ} (h₁ : IntegrableOn g₁ A μ) (h₂ : IntegrableOn g₂ A μ) : normalizedRestrictedIntegral μ A (g₁ - g₂) = normalizedRestrictedIntegral μ A g₁ - normalizedRestrictedIntegral μ A g₂ := by simp only [eventCondExp_eq, Pi.sub_apply, integral_sub h₁ h₂, sub_div] -
eventCondExp_smullemma — For a measure μ, a set A, a scalar c, a real function g, and a measurable space, the normalized restricted integral commutes with scalar multiplication.hypothesesconclusionnormalizedRestrictedIntegral μ A (fun ω => c * g ω)= c * normalizedRestrictedIntegral μ A gProof (Lean source)
lemma eventCondExp_smul (μ : Measure Ω) (A : Set Ω) (c : ℝ) (g : Ω → ℝ) : normalizedRestrictedIntegral μ A (fun ω => c * g ω) = c * normalizedRestrictedIntegral μ A g := by simp only [eventCondExp_eq, MeasureTheory.integral_const_mul, mul_div_assoc] -
eventCondExp_of_ae_eq_IndepFuntheorem — For measurable spaces, a measure μ, a random element z, a random element B, independence, their measurability, a real function factualF, a measurable real function h, a point x with measurable singleton, agreement on its preimage, and nonzero finite cell mass, the independence identity holds.hypothesesΩ :sharedType u_1α β :μ :Measure Ωz :Ω → αB :Ω → βhInd :IndepFun z B μhz :hB :factualF :Ω → ℝh :β → ℝhh_meas :x :αhx :MeasurableSet ({x} : Set α)hF_eq :factualF =ᵐ[μ.restrict (z ⁻¹' {x})] fun ω => h (B ω)hμA_ne_zero :(μ (z ⁻¹' {x})).toReal ≠ 0conclusionnormalizedRestrictedIntegral μ (z ⁻¹' {x}) factualF = ∫ ω, h (B ω) ∂μProof (Lean source)
theorem eventCondExp_of_ae_eq_IndepFun {α β : Type*} [MeasurableSpace α] [MeasurableSpace β] {μ : Measure Ω} {z : Ω → α} {B : Ω → β} (hInd : IndepFun z B μ) (hz : Measurable z) (hB : Measurable B) {factualF : Ω → ℝ} {h : β → ℝ} (hh_meas : Measurable h) {x : α} (hx : MeasurableSet ({x} : Set α)) (hF_eq : factualF =ᵐ[μ.restrict (z ⁻¹' {x})] fun ω => h (B ω)) (hμA_ne_zero : (μ (z ⁻¹' {x})).toReal ≠ 0) : normalizedRestrictedIntegral μ (z ⁻¹' {x}) factualF = ∫ ω, h (B ω) ∂μ := by simp only [eventCondExp_eq] rw [MeasureTheory.integral_congr_ae hF_eq] rw [hInd.integral_restrict_preimage_eq_mul hz.aemeasurable hB.aemeasurable hx (hz hx) hh_meas.aestronglyMeasurable] field_simp -
normalizedRestrict_isProbabilityMeasuretheorem — For a finite sampling measure, a cell with strictly positive mass has a normalized restricted law that is a probability measure.hypothesesconclusionProof (Lean source)
theorem normalizedRestrict_isProbabilityMeasure {Ω : Type*} [MeasurableSpace Ω] {P : Measure Ω} [IsFiniteMeasure P] {C : Set Ω} (hCpos : 0 < P C) : IsProbabilityMeasure (normalizedRestrict P C) := by have hCne : P C ≠ 0 := ne_of_gt hCpos have hCtop : P C ≠ ⊤ := measure_ne_top P C refine ⟨?_⟩ simp only [normalizedRestrict, Measure.smul_apply, Measure.restrict_apply_univ] exact ENNReal.inv_mul_cancel hCne hCtop -
normalizedRestrict_applytheorem — For a cell and a measurable event, the normalized cell law of that event is its intersection mass divided by the cell mass.hypothesesconclusionnormalizedRestrict P C A = (P C)⁻¹ * P (A ∩ C)Proof (Lean source)
theorem normalizedRestrict_apply {Ω : Type*} [MeasurableSpace Ω] {P : Measure Ω} [IsFiniteMeasure P] {C A : Set Ω} (hA : MeasurableSet A) : normalizedRestrict P C A = (P C)⁻¹ * P (A ∩ C) := by simp [normalizedRestrict, Measure.smul_apply, Measure.restrict_apply hA] -
normalizedRestrictedIntegral_eqtheorem — On a cell, integrating a function under the normalized cell law is the restricted integral rescaled by the reciprocal cell mass.hypothesesconclusionnormalizedRestrictedIntegral P C f = (P C).toReal⁻¹ • ∫ ω in C, f ω ∂PProof (Lean source)
theorem normalizedRestrictedIntegral_eq {Ω E : Type*} [MeasurableSpace Ω] [NormedAddCommGroup E] [NormedSpace ℝ E] {P : Measure Ω} [IsFiniteMeasure P] {C : Set Ω} (f : Ω → E) : normalizedRestrictedIntegral P C f = (P C).toReal⁻¹ • ∫ ω in C, f ω ∂P := by simp [normalizedRestrictedIntegral, normalizedRestrict, MeasureTheory.integral_smul_measure, ENNReal.toReal_inv] -
ae_normalizedRestrict_ifftheorem — On a positive-mass cell, an almost-sure assertion holds under the normalized cell law exactly when it holds under the unnormalized restricted measure.hypothesesconclusion(∀ᵐ ω ∂normalizedRestrict P C, p ω) ↔ (∀ᵐ ω ∂P.restrict C, p ω)Proof (Lean source)
theorem ae_normalizedRestrict_iff {Ω : Type*} [MeasurableSpace Ω] {P : Measure Ω} [IsFiniteMeasure P] {C : Set Ω} (hCpos : 0 < P C) {p : Ω → Prop} : (∀ᵐ ω ∂normalizedRestrict P C, p ω) ↔ (∀ᵐ ω ∂P.restrict C, p ω) := by have hscale : 0 < (P C)⁻¹ ∧ (P C)⁻¹ < ⊤ := ⟨ ENNReal.inv_pos.mpr (measure_ne_top P C), ENNReal.inv_lt_top.mpr hCpos⟩ rw [normalizedRestrict] exact Measure.ae_ennreal_smul_measure_iff hscale.1.ne' -
indepFun_of_boundedTestFactorizationtheorem — Under a probability law, measurable random elements whose all bounded measurable real-valued tests factor are independent.hypothesesconclusionIndepFun X Y μProof (Lean source)
theorem indepFun_of_boundedTestFactorization {Ω S T : Type*} [MeasurableSpace Ω] [MeasurableSpace S] [MeasurableSpace T] {μ : Measure Ω} [IsProbabilityMeasure μ] {X : Ω → S} {Y : Ω → T} (hX : Measurable X) (hY : Measurable Y) (hfactor : BoundedTestFactorization μ X Y) : IndepFun X Y μ := by rw [indepFun_iff_indepSet_preimage hX hY] intro s t hs ht have hsX : MeasurableSet (X ⁻¹' s) := hX hs have htY : MeasurableSet (Y ⁻¹' t) := hY ht rw [indepSet_iff_measure_inter_eq_mul hsX htY μ] apply (ENNReal.toReal_eq_toReal_iff' (measure_ne_top μ (X ⁻¹' s ∩ Y ⁻¹' t)) (ENNReal.mul_ne_top (measure_ne_top μ (X ⁻¹' s)) (measure_ne_top μ (Y ⁻¹' t)))).mp rw [ENNReal.toReal_mul, ← measureReal_def, ← measureReal_def, ← measureReal_def, ← integral_indicator_one (hsX.inter htY), ← integral_indicator_one hsX, ← integral_indicator_one htY] have hfac := hfactor (s.indicator (fun _ => (1 : ℝ))) (t.indicator (fun _ => (1 : ℝ))) (measurable_const.indicator hs) (measurable_const.indicator ht) ⟨1, by intro x; by_cases hx : x ∈ s <;> simp [indicator, hx]⟩ ⟨1, by intro y; by_cases hy : y ∈ t <;> simp [indicator, hy]⟩ have hscomp : (fun ω => s.indicator (fun _ => (1 : ℝ)) (X ω)) = (X ⁻¹' s).indicator (fun _ => 1) := by funext ω by_cases hx : X ω ∈ s <;> simp [indicator, hx] have htcomp : (fun ω => t.indicator (fun _ => (1 : ℝ)) (Y ω)) = (Y ⁻¹' t).indicator (fun _ => 1) := by funext ω by_cases hy : Y ω ∈ t <;> simp [indicator, hy] have hprod : (fun ω => s.indicator (fun _ => (1 : ℝ)) (X ω) * t.indicator (fun _ => (1 : ℝ)) (Y ω)) = (X ⁻¹' s ∩ Y ⁻¹' t).indicator (fun _ => 1) := by funext ω by_cases hx : X ω ∈ s <;> by_cases hy : Y ω ∈ t <;> simp [indicator, hx, hy] rw [hprod, hscomp, htcomp] at hfac exact hfac -
normalizedRestricted_coordinate_factorizationtheorem — For a measurable positive-mass cell, measurable finite-coordinate random vectors, integrable individual coordinates, and factorization of every bounded measurable test under the normalized cell law, each coordinate product is integrable and its cell cross moment factors into the two cell first moments.hypothesesΩ :C :Set ΩhC :hCpos :0 < P ChX :hY :hXint :∀ i, Integrable (fun ω => X ω i) (normalizedRestrict P C)hYint :∀ j, Integrable (fun ω => Y ω j) (normalizedRestrict P C)hfactor :i j :conclusionconclusion 1Integrable (fun ω => X ω i * Y ω j) (normalizedRestrict P C)conclusion 2normalizedRestrictedIntegral P C (fun ω => X ω i * Y ω j)= normalizedRestrictedIntegral P C (fun ω => X ω i) * normalizedRestrictedIntegral P C (fun ω => Y ω j)Proof (Lean source)
theorem normalizedRestricted_coordinate_factorization {Ω : Type*} [MeasurableSpace Ω] {P : Measure Ω} [IsProbabilityMeasure P] {C : Set Ω} (hC : MeasurableSet C) (hCpos : 0 < P C) {m n : ℕ} {X : Ω → Fin m → ℝ} {Y : Ω → Fin n → ℝ} (hX : Measurable X) (hY : Measurable Y) (hXint : ∀ i, Integrable (fun ω => X ω i) (normalizedRestrict P C)) (hYint : ∀ j, Integrable (fun ω => Y ω j) (normalizedRestrict P C)) (hfactor : NormalizedRestrictedBoundedTestFactorization P C X Y) : ∀ i j, Integrable (fun ω => X ω i * Y ω j) (normalizedRestrict P C) ∧ normalizedRestrictedIntegral P C (fun ω => X ω i * Y ω j) = normalizedRestrictedIntegral P C (fun ω => X ω i) * normalizedRestrictedIntegral P C (fun ω => Y ω j) := by let _ : IsProbabilityMeasure (normalizedRestrict P C) := normalizedRestrict_isProbabilityMeasure hCpos have hInd : IndepFun X Y (normalizedRestrict P C) := indepFun_of_boundedTestFactorization hX hY hfactor intro i j have hcoordInd : IndepFun (fun ω => X ω i) (fun ω => Y ω j) (normalizedRestrict P C) := by simpa only [Function.comp_def] using hInd.comp (measurable_pi_apply i) (measurable_pi_apply j) constructor · change Integrable ((fun ω => X ω i) * (fun ω => Y ω j)) (normalizedRestrict P C) exact hcoordInd.integrable_mul (hXint i) (hYint j) · simpa only [normalizedRestrictedIntegral, Pi.mul_apply] using hcoordInd.integral_mul_eq_mul_integral (hXint i).1 (hYint j).1
FiniteMarkovOscillation 5 core · 8 supporting This module provides the backward action of a finite stochastic matrix on functions and the duality between total-variation contraction of distributions and oscillation contraction of functions. ★ oscillationBound_markovOperatorIter
Finite Markov operators and oscillation contraction
This module provides the backward action of a finite stochastic matrix on functions and the
duality between total-variation contraction of distributions and oscillation contraction of
functions. It reuses the finite probability vectors and forward Markov steps from the module
Causalean.Mathlib.Probability.Certified.FiniteKernel, whose declarations live in the namespace
Causalean.Mathlib.Probability.CertifiedFiniteMarkovExpectation.
Given a finite transition matrix, a real-valued function, and a starting state, the backward Markov operator is the transition-weighted sum of the function.
Definition (Lean source)
Given a finite transition matrix, the iterated backward Markov operator applies the matrix a specified number of times to a real-valued function.
Definition (Lean source)
Given an upper bound and a real-valued function, the function has pairwise oscillation at most that bound when every two values differ by at most it.
Definition (Lean source)
Given a finite stochastic matrix, a nonnegative contraction coefficient, half-ℓ¹ contraction of its forward action, an initial oscillation bound, and a number of steps, the iterated backward operator's oscillation is bounded by the coefficient raised to the number of steps times the initial bound, which decays geometrically when the coefficient is below one.
Formal statement
Proof (Lean source)
Given a real vector on a finite carrier that is a probability vector, the carrier is nonempty.
Definition (Lean source)
8 supporting declarations (lemmas, instances)
-
markovOperatorIter_succlemma — For a finite transition matrix, a step count, and a function, the successor iterate is one backward Markov step after the preceding iterate.hypothesesconclusionProof (Lean source)
lemma markovOperatorIter_succ {S : Type*} [Fintype S] (P : S → S → ℝ) (n : Nat) (f : S → ℝ) : markovOperatorIter P (n + 1) f = markovOperator P (markovOperatorIter P n f) := rfl -
oscillationBound_nonneglemma — If a function has an oscillation bound, that bound is nonnegative.Proof (Lean source)
lemma oscillationBound_nonneg {S : Type*} [Nonempty S] {B : ℝ} {f : S → ℝ} (h : OscillationBound B f) : 0 ≤ B := by let x : S := choice inferInstance simpa using h x x -
abs_sum_sub_mul_le_oscillation_halfL1lemma — Given two finite probability vectors and a function with oscillation at most B, the difference of their expectations is at most B times half their ℓ¹ distance.hypothesesconclusion|∑ s, (p s - q s) * f s| ≤ B * ((1 / 2 : ℝ) * ∑ s, |p s - q s|)Proof (Lean source)
lemma abs_sum_sub_mul_le_oscillation_halfL1 {S : Type*} [Fintype S] [Nonempty S] {p q : S → ℝ} (hp : IsProbabilityVector p) (hq : IsProbabilityVector q) {B : ℝ} {f : S → ℝ} (hf : OscillationBound B f) : |∑ s, (p s - q s) * f s| ≤ B * ((1 / 2 : ℝ) * ∑ s, |p s - q s|) := by obtain ⟨imin, -, hmin⟩ := Finset.exists_min_image univ f univ_nonempty obtain ⟨imax, -, hmax⟩ := Finset.exists_max_image univ f univ_nonempty have hB0 := oscillationBound_nonneg hf have hspan : f imax - f imin ≤ B := by have := hf imax imin exact (le_abs_self (f imax - f imin)).trans this let c : ℝ := (f imin + f imax) / 2 have hcenter (s : S) : |f s - c| ≤ B / 2 := by have hlo : f imin ≤ f s := hmin s (Finset.mem_univ s) have hhi : f s ≤ f imax := hmax s (Finset.mem_univ s) rw [abs_le] constructor <;> dsimp [c] <;> linarith have hsum0 : ∑ s, (p s - q s) = 0 := by rw [Finset.sum_sub_distrib, hp.2, hq.2, sub_self] calc |∑ s, (p s - q s) * f s| = |∑ s, (p s - q s) * (f s - c)| := by congr 1 rw [show (∑ s, (p s - q s) * (f s - c)) = (∑ s, (p s - q s) * f s) - (∑ s, (p s - q s)) * c by calc _ = ∑ s, ((p s - q s) * f s - (p s - q s) * c) := by apply Finset.sum_congr rfl intro s _ ring _ = (∑ s, (p s - q s) * f s) - ∑ s, (p s - q s) * c := by rw [Finset.sum_sub_distrib] _ = _ := by rw [← Finset.sum_mul]] rw [hsum0, zero_mul, sub_zero] _ ≤ ∑ s, |(p s - q s) * (f s - c)| := Finset.abs_sum_le_sum_abs _ _ _ ≤ ∑ s, |p s - q s| * (B / 2) := by apply Finset.sum_le_sum intro s _ rw [abs_mul] exact mul_le_mul_of_nonneg_left (hcenter s) (abs_nonneg _) _ = B * ((1 / 2 : ℝ) * ∑ s, |p s - q s|) := by simp only [← Finset.sum_mul] ring -
probability_complex_mean_tv_diameterlemma — Given two finite probability vectors and a complex-valued function whose pairwise distances are at most B, the difference of their complex expectations is at most B times half their ℓ¹ distance.hypothesesS :hp :hq :B :ℝf :S → ℂhf :∀ i j, ‖f i - f j‖ ≤ Bconclusion‖∑ i, ((p i - q i : ℝ) : ℂ) * f i‖ ≤ B * ((1 / 2 : ℝ) * ∑ i, |p i - q i|)Proof (Lean source)
lemma probability_complex_mean_tv_diameter {S : Type*} [Fintype S] [Nonempty S] {p q : S → ℝ} (hp : IsProbabilityVector p) (hq : IsProbabilityVector q) {B : ℝ} {f : S → ℂ} (hf : ∀ i j, ‖f i - f j‖ ≤ B) : ‖∑ i, ((p i - q i : ℝ) : ℂ) * f i‖ ≤ B * ((1 / 2 : ℝ) * ∑ i, |p i - q i|) := by let w : ℂ := ∑ i, ((p i - q i : ℝ) : ℂ) * f i have hB : 0 ≤ B := by obtain ⟨i⟩ := ‹Nonempty S› simpa using hf i i have htv : 0 ≤ (1 / 2 : ℝ) * ∑ i, |p i - q i| := by positivity by_cases hw : w = 0 · change ‖w‖ ≤ _ rw [hw, norm_zero] exact mul_nonneg hB htv have hosc : OscillationBound (‖w‖ * B) (fun i => (star w * f i).re) := by intro i j calc |(star w * f i).re - (star w * f j).re| = |(star w * (f i - f j)).re| := by rw [mul_sub, Complex.sub_re] _ ≤ ‖star w * (f i - f j)‖ := Complex.abs_re_le_norm _ _ = ‖w‖ * ‖f i - f j‖ := by rw [norm_mul, norm_star] _ ≤ ‖w‖ * B := mul_le_mul_of_nonneg_left (hf i j) (norm_nonneg _) have hdual := abs_sum_sub_mul_le_oscillation_halfL1 hp hq hosc have heq : (∑ i, (p i - q i) * (star w * f i).re) = ‖w‖ * ‖w‖ := by calc _ = (star w * w).re := by dsimp [w] rw [Finset.mul_sum, Complex.re_sum] apply Finset.sum_congr rfl intro i _ simp [Complex.mul_re, Complex.mul_im] ring _ = ‖w‖ * ‖w‖ := by simp only [Complex.mul_re, Complex.star_def, Complex.conj_re, Complex.conj_im] rw [Complex.norm_mul_self_eq_normSq, Complex.normSq_apply] ring rw [heq, abs_of_nonneg (mul_nonneg (norm_nonneg w) (norm_nonneg w))] at hdual change ‖w‖ ≤ _ exact le_of_mul_le_mul_left (by simpa only [mul_assoc] using hdual) (norm_pos_iff.mpr hw) -
isProbabilityVector_indicatorlemma — For a state, its point mass is a finite probability vector.Proof (Lean source)
lemma isProbabilityVector_indicator {S : Type*} [Fintype S] [DecidableEq S] (x : S) : IsProbabilityVector (fun y : S ↦ if y = x then 1 else 0) := by constructor · intro y by_cases hy : y = x <;> simp [hy] · simp -
halfL1_indicator_sub_indicator_le_onelemma — For two states, half the ℓ¹ distance between their point masses is at most one.hypothesesS :x y :Sconclusion(1 / 2 : ℝ) * ∑ z, |(if z = x then 1 else 0) - (if z = y then 1 else 0)| ≤ 1Proof (Lean source)
lemma halfL1_indicator_sub_indicator_le_one {S : Type*} [Fintype S] [DecidableEq S] (x y : S) : (1 / 2 : ℝ) * ∑ z, |(if z = x then 1 else 0) - (if z = y then 1 else 0)| ≤ 1 := by let px : S → ℝ := fun z ↦ if z = x then 1 else 0 let py : S → ℝ := fun z ↦ if z = y then 1 else 0 have hpoint (z : S) : |px z - py z| ≤ px z + py z := by calc _ ≤ |px z| + |py z| := abs_sub _ _ _ = _ := by rw [abs_of_nonneg, abs_of_nonneg] · by_cases hz : z = y <;> simp [py, hz] · by_cases hz : z = x <;> simp [px, hz] change (1 / 2 : ℝ) * ∑ z, |px z - py z| ≤ 1 calc _ ≤ (1 / 2 : ℝ) * ∑ z, (px z + py z) := by apply mul_le_mul_of_nonneg_left _ (by norm_num) exact Finset.sum_le_sum fun z _ ↦ hpoint z _ = 1 := by rw [Finset.sum_add_distrib] have hx : ∑ z, px z = 1 := by simpa [px] using (isProbabilityVector_indicator x).2 have hy : ∑ z, py z = 1 := by simpa [py] using (isProbabilityVector_indicator y).2 rw [hx, hy] norm_num -
oscillationBound_markovOperatorlemma — Given a finite stochastic matrix, a nonnegative contraction coefficient, half-ℓ¹ contraction of its forward action, and a function with oscillation at most B, one backward Markov step has oscillation at most alpha * B.hypothesesS :P :S → S → ℝhP :∀ s, IsProbabilityVector (P s)alpha B :ℝhalpha :0 ≤ alphahcontract :∀ p qandthen(1 / 2 : ℝ) * ∑ s, |markovStep p P s - markovStep q P s|≤ alpha * ((1 / 2 : ℝ) * ∑ s, |p s - q s|)f :S → ℝhf :OscillationBound B fconclusionOscillationBound (alpha * B) (markovOperator P f)Proof (Lean source)
lemma oscillationBound_markovOperator {S : Type*} [Fintype S] [Nonempty S] (P : S → S → ℝ) (hP : ∀ s, IsProbabilityVector (P s)) {alpha B : ℝ} (halpha : 0 ≤ alpha) (hcontract : ∀ p q, IsProbabilityVector p → IsProbabilityVector q → (1 / 2 : ℝ) * ∑ s, |markovStep p P s - markovStep q P s| ≤ alpha * ((1 / 2 : ℝ) * ∑ s, |p s - q s|)) {f : S → ℝ} (hf : OscillationBound B f) : OscillationBound (alpha * B) (markovOperator P f) := by classical intro x y let px : S → ℝ := fun z ↦ if z = x then 1 else 0 let py : S → ℝ := fun z ↦ if z = y then 1 else 0 have hpx : IsProbabilityVector px := isProbabilityVector_indicator x have hpy : IsProbabilityVector py := isProbabilityVector_indicator y have happx : markovStep px P = P x := by funext z simp [markovStep, vecMul, dotProduct, px] have happy : markovStep py P = P y := by funext z simp [markovStep, vecMul, dotProduct, py] have htv : (1 / 2 : ℝ) * ∑ s, |P x s - P y s| ≤ alpha := by have hc := hcontract px py hpx hpy rw [happx, happy] at hc exact hc.trans (by simpa [px, py] using mul_le_mul_of_nonneg_left (halfL1_indicator_sub_indicator_le_one x y) halpha) have hdual := abs_sum_sub_mul_le_oscillation_halfL1 (hP x) (hP y) hf unfold markovOperator rw [← Finset.sum_sub_distrib] calc |∑ s, (P x s * f s - P y s * f s)| = |∑ s, (P x s - P y s) * f s| := by congr 1 apply Finset.sum_congr rfl intro s _ ring _ ≤ B * ((1 / 2 : ℝ) * ∑ s, |P x s - P y s|) := hdual _ ≤ B * alpha := mul_le_mul_of_nonneg_left htv (oscillationBound_nonneg hf) _ = alpha * B := mul_comm _ _ -
monolemma — If a function has oscillation at most A and A is at most B, the function has oscillation at most B.hypothesesconclusionOscillationBound B fProof (Lean source)
lemma OscillationBound.mono {S : Type*} {A B : ℝ} {f : S → ℝ} (hf : OscillationBound A f) (hAB : A ≤ B) : OscillationBound B f := fun x y ↦ (hf x y).trans hAB
FiniteMarkovPerturbation 1 core · 4 supporting This module bounds finite-horizon rewards and moments when a finite initial law, transition matrix, or reward function is perturbed in total variation or uniform distance. ★ stochastic_moment_error
Finite Markov perturbation bounds
This module bounds finite-horizon rewards and moments when a finite initial law, transition matrix, or reward function is perturbed in total variation or uniform distance.
For two stochastic transition matrices, two probability initial laws, a unit-range reference reward, an initial-law total-variation error, a uniform row total-variation error, a uniform reward error, and a horizon, the finite-horizon moments differ by at most the sum of the initial, accumulated transition, and reward errors.
Formal statement
Proof (Lean source)
4 supporting declarations (lemmas, instances)
-
probability_mean_unitlemma — A probability-weighted mean of values in the unit interval remains in the unit interval.hypothesesconclusion(∑ i, p i * f i) ∈ Icc (0 : ℝ) 1Proof (Lean source)
lemma probability_mean_unit {S : Type*} [Fintype S] {p f : S → ℝ} (hp : IsProbabilityVector p) (hf : ∀ i, f i ∈ Icc (0 : ℝ) 1) : (∑ i, p i * f i) ∈ Icc (0 : ℝ) 1 := by constructor · exact Finset.sum_nonneg (fun i _ => mul_nonneg (hp.1 i) (hf i).1) · calc _ ≤ ∑ i, p i * 1 := Finset.sum_le_sum (fun i _ => mul_le_mul_of_nonneg_left (hf i).2 (hp.1 i)) _ = 1 := by simpa using hp.2 -
probability_mean_errorlemma — Averaging under a probability vector cannot increase a uniform pointwise error, so the two weighted means differ by at most that error.hypothesesconclusion|(∑ i, p i * f i) - ∑ i, p i * g i| ≤ εProof (Lean source)
lemma probability_mean_error {S : Type*} [Fintype S] {p f g : S → ℝ} {ε : ℝ} (hp : IsProbabilityVector p) (hfg : ∀ i, |f i - g i| ≤ ε) : |(∑ i, p i * f i) - ∑ i, p i * g i| ≤ ε := by rw [← Finset.sum_sub_distrib] calc _ ≤ ∑ i, |p i * f i - p i * g i| := Finset.abs_sum_le_sum_abs _ _ _ ≤ ∑ i, p i * ε := by apply Finset.sum_le_sum intro i _ rw [← mul_sub, abs_mul, abs_of_nonneg (hp.1 i)] exact mul_le_mul_of_nonneg_left (hfg i) (hp.1 i) _ = ε := by rw [← Finset.sum_mul, hp.2, one_mul] -
stochastic_power_reward_unitlemma — Every iterate count of a stochastic transition matrix sends a unit-range reward to another unit-range function.hypothesesProof (Lean source)
lemma stochastic_power_reward_unit {S : Type*} [Fintype S] [DecidableEq S] {P : Matrix S S ℝ} (hP : IsStochasticMatrix P) {r : S → ℝ} (hr : ∀ i, r i ∈ Icc (0 : ℝ) 1) (k : Nat) : ∀ i, ((P ^ k).mulVec r) i ∈ Icc (0 : ℝ) 1 := by induction k with | zero => simpa using hr | succ k ih => rw [pow_succ', ← Matrix.mulVec_mulVec] intro i exact probability_mean_unit ⟨hP.1 i, hP.2 i⟩ ih -
stochastic_power_reward_errorlemma — For two stochastic transition matrices, a unit-range reference reward, a uniform row total-variation error, a uniform reward error, and a horizon, the propagated reward error is at most the horizon times the transition error plus the reward error.hypothesesS :hP :hQ :r s :S → ℝhr :∀ i, r i ∈ Icc (0 : ℝ) 1εP εr :ℝhPQ :∀ i, (1 / 2 : ℝ) * ∑ j, |P i j - Q i j| ≤ εPhrs :∀ i, |r i - s i| ≤ εrk :i :Proof (Lean source)
lemma stochastic_power_reward_error {S : Type*} [Fintype S] [DecidableEq S] {P Q : Matrix S S ℝ} (hP : IsStochasticMatrix P) (hQ : IsStochasticMatrix Q) {r s : S → ℝ} (hr : ∀ i, r i ∈ Icc (0 : ℝ) 1) {εP εr : ℝ} (hPQ : ∀ i, (1 / 2 : ℝ) * ∑ j, |P i j - Q i j| ≤ εP) (hrs : ∀ i, |r i - s i| ≤ εr) (k : Nat) : ∀ i, |((P ^ k).mulVec r) i - ((Q ^ k).mulVec s) i| ≤ (k : ℝ) * εP + εr := by induction k with | zero => simpa using hrs | succ k ih => simp only [pow_succ', ← Matrix.mulVec_mulVec] intro i letI : Nonempty S := nonemptyOfProbabilityVector (P i) ⟨hP.1 i, hP.2 i⟩ have hunit := stochastic_power_reward_unit hP hr k have hosc : OscillationBound 1 ((P ^ k).mulVec r) := by intro x y rw [abs_le] constructor <;> linarith [(hunit x).1, (hunit x).2, (hunit y).1, (hunit y).2] have ht : |(∑ j, P i j * ((P ^ k).mulVec r) j) - ∑ j, Q i j * ((P ^ k).mulVec r) j| ≤ εP := by rw [← Finset.sum_sub_distrib] simpa only [sub_mul] using (abs_sum_sub_mul_le_oscillation_halfL1 ⟨hP.1 i, hP.2 i⟩ ⟨hQ.1 i, hQ.2 i⟩ hosc).trans (by simpa using hPQ i) have he := probability_mean_error ⟨hQ.1 i, hQ.2 i⟩ ih change |(∑ j, P i j * ((P ^ k).mulVec r) j) - ∑ j, Q i j * ((Q ^ k).mulVec s) j| ≤ _ calc _ ≤ |(∑ j, P i j * ((P ^ k).mulVec r) j) - ∑ j, Q i j * ((P ^ k).mulVec r) j| + |(∑ j, Q i j * ((P ^ k).mulVec r) j) - ∑ j, Q i j * ((Q ^ k).mulVec s) j| := abs_sub_le _ _ _ _ ≤ εP + ((k : ℝ) * εP + εr) := add_le_add ht he _ = _ := by push_cast; ring
FinitePartitionConditional 1 core · 1 supporting This module provides the law of total probability over a finite measurable partition, written with Mathlib's conditional measure μ[E | C], and its uniform-bound consequence: a bound on the conditional probability of an e ★ measure_le_of_cond_le_on_finite_partition
Finite-partition aggregation of conditional probabilities
This module provides the law of total probability over a finite measurable partition, written with
Mathlib's conditional measure μ[E | C], and its uniform-bound consequence: a bound on the
conditional probability of an event in every positive-probability cell bounds its unconditional
probability. Zero-probability cells are handled explicitly, so applications only need conditional
estimates on positive-probability cells.
Given a probability measure, a finite collection of cells, measurability of every cell, pairwise disjointness of distinct cells, coverage of the whole sample space, an event, measurability of that event, a probability bound, and that bound conditional on each positive-mass cell, the unconditional event probability is at most the same bound.
Formal statement
Proof (Lean source)
1 supporting declaration (lemmas, instances)
-
measure_eq_sum_mul_cond_of_finite_partitiontheorem — Given a probability measure, a finite collection of cells, measurability of every cell, pairwise disjointness of distinct cells, coverage of the whole sample space, an event, and measurability of that event, its probability equals the finite sum of cell mass times conditional event probability.hypothesesΩ ι :μ :C :ι → Set ΩhC :∀ i, MeasurableSet (C i)hdisj :∀ i jifi ≠ jthenDisjoint (C i) (C j)hcover :(⋃ i, C i) = univE :Set ΩhE :conclusionμ E = ∑ i, μ (C i) * μ[E | C i]Proof (Lean source)
theorem measure_eq_sum_mul_cond_of_finite_partition {Ω ι : Type*} [MeasurableSpace Ω] [Fintype ι] (μ : Measure Ω) [IsProbabilityMeasure μ] (C : ι → Set Ω) (hC : ∀ i, MeasurableSet (C i)) (hdisj : ∀ i j, i ≠ j → Disjoint (C i) (C j)) (hcover : (⋃ i, C i) = univ) (E : Set Ω) (hE : MeasurableSet E) : μ E = ∑ i, μ (C i) * μ[E | C i] := by -- Split `E` across the disjoint cover, then expand `cond_apply`; zero cells cancel separately. have hdisj_inter : Pairwise (fun i j ↦ Disjoint (C i ∩ E) (C j ∩ E)) := by intro i j hij exact (hdisj i j hij).mono inter_subset_left inter_subset_left calc μ E = μ ((⋃ i, C i) ∩ E) := by rw [hcover, univ_inter] _ = μ (⋃ i, C i ∩ E) := by rw [iUnion_inter] _ = ∑' i, μ (C i ∩ E) := measure_iUnion hdisj_inter fun i ↦ (hC i).inter hE _ = ∑ i, μ (C i ∩ E) := tsum_fintype (L := .unconditional ι) (fun i ↦ μ (C i ∩ E)) _ = ∑ i, μ (C i) * μ[E | C i] := by apply Finset.sum_congr rfl intro i _ by_cases hzero : μ (C i) = 0 · have hinter : μ (C i ∩ E) = 0 := measure_mono_null inter_subset_left hzero simp [hzero, hinter] · rw [cond_apply (hC i), ← mul_assoc, ENNReal.mul_inv_cancel hzero (measure_ne_top μ (C i)), one_mul]
GaussianMoments 2 core · 6 supporting This file lifts standard-normal tail identities to a real Gaussian law N(m, v) with variance parameter v > 0. ★ gaussianReal_Ioi_eq★ integral_Ioi_id_gaussianReal
General Gaussian survival and truncated first moment
This file lifts standard-normal tail identities to a real Gaussian law N(m, v) with
variance parameter v > 0. The proofs use the affine change of variables
y = m + sqrt v * z from the standard normal and reuse the standard-normal survival and
truncated-moment formulas.
The public results are:
* gaussianReal_Ioi_eq: the right-tail probability
(gaussianReal m v) (Ioi c) is 1 - stdNormalCDF ((c - m) / sqrt v);
* integral_Ioi_id_gaussianReal: the truncated first moment over (c, infinity) is
`m * (1 - stdNormalCDF ((c - m) / sqrt v))
+ sqrt v * stdNormalPDF ((c - m) / sqrt v)`.
Gaussian survival. For a normal law with mean m and a nonnegative variance parameter v that is nonzero, the probability mass above a threshold c equals one minus the standard-normal CDF evaluated at the standardized threshold (c − m)/√v.
Formal statement
Proof (Lean source)
Gaussian truncated first moment. For a normal law with mean m and a nonnegative variance parameter v that is nonzero, the first moment integrated over the tail above a threshold c equals m·(1 − Φ(t)) + √v·φ(t), where t = (c − m)/√v — the affine image of the standard-normal truncated moment ∫_{t}^∞ z φ(z) dz = φ(t).
Formal statement
Proof (Lean source)
6 supporting declarations (lemmas, instances)
-
gaussianReal_eq_map_stdlemma — A real Gaussian distribution with nonnegative variance is the standard normal distribution after scaling by the standard deviation and shifting by the mean.hypothesesm :ℝv :ℝ≥0conclusionProof (Lean source)
lemma gaussianReal_eq_map_std (m : ℝ) (v : ℝ≥0) : gaussianReal m v = (gaussianReal 0 1).map (fun z => sqrt (v : ℝ) * z + m) := by have hcoe : (⟨(v : ℝ), v.2⟩ : ℝ≥0) = v := by ext simp calc gaussianReal m v = gaussianReal (0 + m) v := by simp _ = (gaussianReal 0 v).map (· + m) := by rw [gaussianReal_map_add_const] _ = ((gaussianReal 0 1).map (sqrt (v : ℝ) * ·)).map (· + m) := by congr 1 rw [gaussianReal_map_const_mul] simp [hcoe] _ = (gaussianReal 0 1).map (fun z => sqrt (v : ℝ) * z + m) := by rw [Measure.map_map] · rfl · exact (continuous_id.add continuous_const).measurable · exact (continuous_const.mul continuous_id).measurable -
affine_preimage_Ioilemma — The inverse image of a right-hand tail under a positive affine transformation is a right-hand tail whose threshold is transformed by the inverse affine formula.hypothesesα :hs :0 < sProof (Lean source)
lemma affine_preimage_Ioi {α : Type*} [Field α] [LinearOrder α] [IsStrictOrderedRing α] {s c m : α} (hs : 0 < s) : (fun z : α => s * z + m) ⁻¹' Ioi c = Ioi ((c - m) / s) := by ext z dsimp [preimage, Ioi] constructor · intro hz have hz' : c - m < z * s := by nlinarith exact (div_lt_iff₀ hs).2 hz' · intro hz have hz' : c - m < z * s := (div_lt_iff₀ hs).1 hz nlinarith [hz'] -
stdNormalMeasure_Ioi_toReal_eq_integrallemma — The standard normal probability of values above t equals the integral of the standard-normal density over that upper-tail region.Proof (Lean source)
lemma stdNormalMeasure_Ioi_toReal_eq_integral (t : ℝ) : ((gaussianReal 0 1) (Ioi t)).toReal = ∫ x in Ioi t, stdNormalPDF x := by have hmeasure := ProbabilityTheory.gaussianReal_apply_eq_integral (μ := 0) (v := 1) (by norm_num) (Ioi t) have hnonneg : 0 ≤ ∫ x in Ioi t, gaussianPDFReal 0 1 x := by exact integral_nonneg fun x => gaussianPDFReal_nonneg 0 1 x rw [hmeasure] rw [ENNReal.toReal_ofReal hnonneg] simp [stdNormalPDF] -
integrable_id_mul_stdNormalPDFlemma — The standard normal density has a finite first absolute moment.conclusionIntegrable (fun x : ℝ => x * stdNormalPDF x)Proof (Lean source)
@[fun_prop] lemma integrable_id_mul_stdNormalPDF : Integrable (fun x : ℝ => x * stdNormalPDF x) := by have hbase : Integrable (fun x : ℝ => x * exp (-(1 / 2 : ℝ) * x ^ 2)) := by simpa using integrable_mul_exp_neg_mul_sq (b := (1 / 2 : ℝ)) (by norm_num) have hpdf : ∀ x : ℝ, gaussianPDFReal 0 1 x = (sqrt (2 * π))⁻¹ * exp (-(1 / 2 : ℝ) * x ^ 2) := by intro x unfold gaussianPDFReal congr 2 · norm_num · norm_num ring convert hbase.const_mul (sqrt (2 * π))⁻¹ using 1 ext x rw [stdNormalPDF, hpdf x] ring -
integral_Ioi_affine_stdNormallemma — Above a threshold, integrating an affine function against the standard-normal density equals its slope times the truncated first moment plus its intercept times the tail mass.Proof (Lean source)
lemma integral_Ioi_affine_stdNormal (s m t : ℝ) : ∫ z in Ioi t, gaussianPDFReal 0 1 z * (s * z + m) = s * (∫ z in Ioi t, z * stdNormalPDF z) + m * (∫ z in Ioi t, stdNormalPDF z) := by have h_int_id : Integrable (fun z : ℝ => z * stdNormalPDF z) (volume.restrict (Ioi t)) := integrable_id_mul_stdNormalPDF.integrableOn have h_int_pdf : Integrable (fun z : ℝ => stdNormalPDF z) (volume.restrict (Ioi t)) := by exact ((integrable_gaussianPDFReal 0 1).integrableOn : Integrable (fun z : ℝ => gaussianPDFReal 0 1 z) (volume.restrict (Ioi t))) calc ∫ z in Ioi t, gaussianPDFReal 0 1 z * (s * z + m) = ∫ z in Ioi t, (s * (z * stdNormalPDF z) + m * stdNormalPDF z) := by congr 1 ext z simp [stdNormalPDF] ring _ = (∫ z in Ioi t, s * (z * stdNormalPDF z)) + ∫ z in Ioi t, m * stdNormalPDF z := by rw [integral_add] · exact h_int_id.const_mul s · exact h_int_pdf.const_mul m _ = s * (∫ z in Ioi t, z * stdNormalPDF z) + m * (∫ z in Ioi t, stdNormalPDF z) := by rw [integral_const_mul, integral_const_mul] -
integral_Ioi_affine_gaussianReal_eq_densitylemma — Above a threshold, the integral of an affine function under the standard-normal law equals the integral of that function against its density.hypothesess m t :ℝconclusion∫ z in Ioi t, (s * z + m) ∂(gaussianReal 0 1)= ∫ z in Ioi t, gaussianPDFReal 0 1 z * (s * z + m)Proof (Lean source)
lemma integral_Ioi_affine_gaussianReal_eq_density (s m t : ℝ) : ∫ z in Ioi t, (s * z + m) ∂(gaussianReal 0 1) = ∫ z in Ioi t, gaussianPDFReal 0 1 z * (s * z + m) := by rw [ProbabilityTheory.gaussianReal_of_var_ne_zero] · rw [setIntegral_withDensity_eq_setIntegral_toReal_smul] · congr 1 ext z simp [ProbabilityTheory.gaussianPDF, ENNReal.toReal_ofReal, gaussianPDFReal_nonneg] · exact ProbabilityTheory.measurable_gaussianPDF 0 1 · exact ae_of_all _ fun _ => ProbabilityTheory.gaussianPDF_lt_top · exact measurableSet_Ioi · norm_num
GaussianWeightedSum 1 core · 0 supporting A fixed linear combination ∑ i, a i * ξ i of independent standard Gaussian random variables has exactly the centred Gaussian law whose variance is ∑ i, (a i)². ★ map_weighted_sum_gaussian
Weighted sums of independent standard Gaussians
A fixed linear combination ∑ i, a i * ξ i of independent standard Gaussian random
variables has exactly the centred Gaussian law whose variance is ∑ i, (a i)².
The main result is map_weighted_sum_gaussian.
A weighted sum of independent standard Gaussians with fixed weights has the centred Gaussian law whose variance is the sum of the squared weights, provided the family is mutually independent, each variable is measurable, and each has the standard Gaussian law.
Formal statement
Proof (Lean source)
HermiteFacts 1 core · 0 supporting This facade combines the exponential generating-series and standard-Gaussian orthogonality theorems for Mathlib’s probabilists’ Hermite polynomials with Mathlib’s zero-order identity in the exact neutral three-part inter ★ classicalHermiteFacts
Classical facts for probabilists’ Hermite polynomials
This facade combines the exponential generating-series and standard-Gaussian orthogonality theorems for Mathlib’s probabilists’ Hermite polynomials with Mathlib’s zero-order identity in the exact neutral three-part interface.
Probabilists' Hermite polynomials satisfy the real exponential generating series, Gaussian orthogonality with factorial norms, and the zero-order identity.
Formal statement
Proof (Lean source)
HermiteGaussian 1 core · 15 supporting This module develops polynomial Gaussian integrability, a polynomial Stein identity, and factorial-normalized orthogonality for Mathlib’s probabilists’ Hermite polynomials under the variance-one Gaussian law. ★ integral_hermite_mul
Gaussian orthogonality of probabilists’ Hermite polynomials
This module develops polynomial Gaussian integrability, a polynomial Stein identity, and factorial-normalized orthogonality for Mathlib’s probabilists’ Hermite polynomials under the variance-one Gaussian law.
Two probabilists' Hermite polynomials have standard Gaussian inner product equal to the order factorial when their orders agree and zero otherwise.
Formal statement
Proof (Lean source)
15 supporting declarations (lemmas, instances)
-
integrable_eval_mul_gaussiantheorem — A real polynomial, multiplied by a Gaussian weight with positive precision, is integrable on the real line.hypothesesp :ℝ[X]b :ℝhb :0 < bconclusionIntegrable (fun x : ℝ => p.eval x * exp (-b * x ^ 2))Proof (Lean source)
theorem integrable_eval_mul_gaussian (p : ℝ[X]) (b : ℝ) (hb : 0 < b) : Integrable (fun x : ℝ => p.eval x * exp (-b * x ^ 2)) := by induction p using Polynomial.induction_on' with | add p q hp hq => simp only [eval_add, add_mul] exact hp.add hq | monomial n a => have hn : (-1 : ℝ) < (n : ℝ) := lt_of_lt_of_le (by norm_num) (Nat.cast_nonneg n) simpa only [eval_monomial, Real.rpow_natCast, mul_assoc] using (integrable_rpow_mul_exp_neg_mul_sq hb hn).const_mul a -
tendsto_eval_mul_gaussian_cocompacttheorem — A real polynomial, multiplied by a Gaussian weight with positive precision, tends to zero at both ends of the real line.hypothesesp :ℝ[X]b :ℝhb :0 < bProof (Lean source)
theorem tendsto_eval_mul_gaussian_cocompact (p : ℝ[X]) (b : ℝ) (hb : 0 < b) : Tendsto (fun x : ℝ => p.eval x * exp (-b * x ^ 2)) (cocompact ℝ) (𝓝 0) := by induction p using Polynomial.induction_on' with | add p q hp hq => simpa only [eval_add, add_mul, zero_add] using hp.add hq | monomial n a => have hn : Tendsto (fun x : ℝ => x ^ n * exp (-b * x ^ 2)) (cocompact ℝ) (𝓝 0) := by rw [tendsto_zero_iff_norm_tendsto_zero] simpa only [Real.norm_eq_abs, abs_mul, abs_pow, abs_of_pos (Real.exp_pos _), Real.rpow_natCast] using tendsto_rpow_abs_mul_exp_neg_mul_sq_cocompact hb (n : ℝ) simpa only [eval_monomial, mul_assoc, mul_zero] using hn.const_mul a -
gaussianPDFReal_standardtheorem — The variance-one, mean-zero Gaussian density at a real point is the normalized exponential of minus half the squared point.Proof (Lean source)
theorem gaussianPDFReal_standard (x : ℝ) : gaussianPDFReal 0 1 x = (sqrt (2 * pi))⁻¹ * exp (-(x ^ 2 / 2)) := by simp [gaussianPDFReal, neg_div] -
integrable_eval_gaussianRealtheorem — Every real polynomial is integrable under the standard Gaussian law.Proof (Lean source)
theorem integrable_eval_gaussianReal (p : ℝ[X]) : Integrable (fun x : ℝ => p.eval x) (gaussianReal 0 1) := by rw [gaussianReal_of_var_ne_zero 0 (by norm_num : (1 : ℝ≥0) ≠ 0)] apply (integrable_withDensity_iff_integrable_smul' (measurable_gaussianPDF 0 1) (ae_of_all _ fun _ => gaussianPDF_lt_top)).2 have h := (integrable_eval_mul_gaussian p (1 / 2) (by norm_num)).const_mul (sqrt (2 * pi))⁻¹ apply h.congr filter_upwards [] with x rw [toReal_gaussianPDF, smul_eq_mul, gaussianPDFReal_standard] have hexp : -(x ^ 2 / 2) = -(1 / 2 : ℝ) * x ^ 2 := by ring rw [hexp] ring -
integral_gaussianReal_standardtheorem — Integrating a real function under the standard Gaussian law equals its Lebesgue integral against the normalized Gaussian weight.hypothesesf :ℝ → ℝProof (Lean source)
theorem integral_gaussianReal_standard (f : ℝ → ℝ) : (∫ x, f x ∂gaussianReal 0 1) = (sqrt (2 * pi))⁻¹ * ∫ x, f x * exp (-(x ^ 2 / 2)) := by rw [integral_gaussianReal_eq_integral_smul (by norm_num : (1 : ℝ≥0) ≠ 0)] simp_rw [gaussianPDFReal_standard, smul_eq_mul, mul_assoc, mul_comm (exp _)] rw [integral_const_mul] -
hermite_eval_succtheorem — Evaluating a successor Hermite polynomial at a real point gives the point times the preceding polynomial minus its polynomial derivative.hypothesesn :ℕx :ℝProof (Lean source)
theorem hermite_eval_succ (n : ℕ) (x : ℝ) : (aeval x (hermite (n + 1)) : ℝ) = x * aeval x (hermite n) - aeval x (derivative (hermite n)) := by rw [hermite_succ, map_sub, map_mul, aeval_X] -
derivative_hermite_succtheorem — Differentiating a successor Hermite polynomial gives its order times the preceding Hermite polynomial.Proof (Lean source)
theorem derivative_hermite_succ (n : ℕ) : derivative (hermite (n + 1)) = C (n + 1 : ℤ) * hermite n := by induction n with | zero => simp [hermite_succ, hermite_zero] | succ n ih => rw [hermite_succ, derivative_sub, derivative_mul, derivative_X, one_mul, ih, derivative_mul, derivative_C, zero_mul, zero_add] rw [hermite_succ] simp only [Nat.cast_add, Nat.cast_one, map_add, map_one] ring -
hasDerivAt_hermite_succtheorem — At a real point, a successor Hermite polynomial has derivative equal to its order times the preceding evaluation.hypothesesn :ℕx :ℝconclusionProof (Lean source)
theorem hasDerivAt_hermite_succ (n : ℕ) (x : ℝ) : HasDerivAt (fun y : ℝ => (aeval y (hermite (n + 1)) : ℝ)) ((n + 1 : ℝ) * aeval x (hermite n)) x := by have h := (hermite (n + 1)).hasDerivAt_aeval x rw [derivative_hermite_succ, map_mul, aeval_C] at h simpa only [map_add, map_natCast, map_one] using h -
deriv_hermite_succtheorem — The analytic derivative of a successor Hermite evaluation at a real point is its order times the preceding evaluation.hypothesesn :ℕx :ℝProof (Lean source)
theorem deriv_hermite_succ (n : ℕ) (x : ℝ) : deriv (fun y : ℝ => (aeval y (hermite (n + 1)) : ℝ)) x = (n + 1 : ℝ) * aeval x (hermite n) := (hasDerivAt_hermite_succ n x).deriv -
hasDerivAt_standardGaussianWeighttheorem — At a real point, the unnormalized standard Gaussian weight has derivative equal to minus the point times the weight.hypothesesx :ℝconclusionProof (Lean source)
theorem hasDerivAt_standardGaussianWeight (x : ℝ) : HasDerivAt (fun y : ℝ => exp (-(y ^ 2 / 2))) (-x * exp (-(x ^ 2 / 2))) x := by simpa [id_eq, pow_one, mul_comm] using (((hasDerivAt_id x).pow 2).div_const 2).neg.exp -
integral_mul_eval_mul_gaussiantheorem — For a real polynomial, its derivative integrated against the unnormalized standard Gaussian weight equals its evaluation multiplied by the variable and integrated against the same weight.hypothesesp :ℝ[X]Proof (Lean source)
theorem integral_mul_eval_mul_gaussian (p : ℝ[X]) : (∫ x : ℝ, (x * p.eval x) * exp (-(x ^ 2 / 2))) = ∫ x : ℝ, p.derivative.eval x * exp (-(x ^ 2 / 2)) := by have hexp (x : ℝ) : -(x ^ 2 / 2) = -(1 / 2 : ℝ) * x ^ 2 := by ring have huv' : Integrable (fun x : ℝ => p.eval x * (-x * exp (-(x ^ 2 / 2)))) := by apply (integrable_eval_mul_gaussian (X * p) (1 / 2) (by norm_num)).neg.congr filter_upwards [] with x simp only [Pi.neg_apply, eval_mul, eval_X, hexp] ring have hu'v : Integrable (fun x : ℝ => p.derivative.eval x * exp (-(x ^ 2 / 2))) := by simpa only [hexp] using integrable_eval_mul_gaussian p.derivative (1 / 2) (by norm_num) have hlim : Tendsto (fun x : ℝ => p.eval x * exp (-(x ^ 2 / 2))) (cocompact ℝ) (𝓝 0) := by simpa only [hexp] using tendsto_eval_mul_gaussian_cocompact p (1 / 2) (by norm_num) have hibp := MeasureTheory.integral_mul_deriv_eq_deriv_mul (u := p.eval) (u' := p.derivative.eval) (v := fun x : ℝ => exp (-(x ^ 2 / 2))) (v' := fun x : ℝ => -x * exp (-(x ^ 2 / 2))) (fun x _ => p.hasDerivAt x) (fun x _ => hasDerivAt_standardGaussianWeight x) huv' hu'v (hlim.mono_left atBot_le_cocompact) (hlim.mono_left atTop_le_cocompact) have hsign (x : ℝ) : p.eval x * (-x * exp (-(x ^ 2 / 2))) = -((x * p.eval x) * exp (-(x ^ 2 / 2))) := by ring simp only [hsign, integral_neg, sub_self, zero_sub] at hibp exact neg_injective hibp -
integral_mul_eval_gaussianRealtheorem — For a real polynomial, the standard Gaussian expectation of the variable times its evaluation equals the expectation of its derivative.hypothesesp :ℝ[X]conclusion(∫ x, x * p.eval x ∂gaussianReal 0 1) = ∫ x, p.derivative.eval x ∂gaussianReal 0 1Proof (Lean source)
theorem integral_mul_eval_gaussianReal (p : ℝ[X]) : (∫ x, x * p.eval x ∂gaussianReal 0 1) = ∫ x, p.derivative.eval x ∂gaussianReal 0 1 := by rw [integral_gaussianReal_standard, integral_gaussianReal_standard, integral_mul_eval_mul_gaussian] -
integrable_hermite_multheorem — Products of two real Hermite evaluations are integrable under the standard Gaussian law.hypothesesj k :ℕconclusionProof (Lean source)
theorem integrable_hermite_mul (j k : ℕ) : Integrable (fun x : ℝ => (aeval x (hermite j) : ℝ) * aeval x (hermite k)) (gaussianReal 0 1) := by simpa [Polynomial.eval_mul, Polynomial.eval_map, Polynomial.aeval_def] using integrable_eval_gaussianReal ((hermite j).map (Int.castRingHom ℝ) * (hermite k).map (Int.castRingHom ℝ)) -
integral_hermite_succtheorem — Every positive-order Hermite polynomial has zero standard Gaussian expectation.Proof (Lean source)
theorem integral_hermite_succ (n : ℕ) : (∫ x, (aeval x (hermite (n + 1)) : ℝ) ∂gaussianReal 0 1) = 0 := by have hx : Integrable (fun x : ℝ => x * aeval x (hermite n)) (gaussianReal 0 1) := by apply (integrable_eval_gaussianReal (X * (hermite n).map (Int.castRingHom ℝ))).congr filter_upwards [] with x simp only [Polynomial.eval_mul, Polynomial.eval_X, Polynomial.eval_map, Polynomial.aeval_def, algebraMap_int_eq] have hd : Integrable (fun x : ℝ => (aeval x (derivative (hermite n)) : ℝ)) (gaussianReal 0 1) := by simpa only [Polynomial.derivative_map, Polynomial.eval_map, Polynomial.aeval_def, algebraMap_int_eq] using integrable_eval_gaussianReal ((hermite n).map (Int.castRingHom ℝ)).derivative have hs : (∫ x, x * (aeval x (hermite n) : ℝ) ∂gaussianReal 0 1) = ∫ x, (aeval x (derivative (hermite n)) : ℝ) ∂gaussianReal 0 1 := by simpa only [Polynomial.derivative_map, Polynomial.eval_map, Polynomial.aeval_def, algebraMap_int_eq] using integral_mul_eval_gaussianReal ((hermite n).map (Int.castRingHom ℝ)) simp_rw [hermite_eval_succ] rw [integral_sub hx hd, hs, sub_self] -
integral_hermite_succ_mul_succtheorem — Raising both Hermite orders by one multiplies their standard Gaussian inner product by the second raised order.hypothesesj k :ℕProof (Lean source)
theorem integral_hermite_succ_mul_succ (j k : ℕ) : (∫ x, (aeval x (hermite (j + 1)) : ℝ) * aeval x (hermite (k + 1)) ∂gaussianReal 0 1) = (k + 1 : ℝ) * ∫ x, (aeval x (hermite j) : ℝ) * aeval x (hermite k) ∂gaussianReal 0 1 := by let p := (hermite j).map (Int.castRingHom ℝ) let q := (hermite (k + 1)).map (Int.castRingHom ℝ) have hx : Integrable (fun x : ℝ => x * (p.eval x * q.eval x)) (gaussianReal 0 1) := by apply (integrable_eval_gaussianReal (X * (p * q))).congr filter_upwards [] with x simp only [Polynomial.eval_mul, Polynomial.eval_X] have hpq : Integrable (fun x : ℝ => p.derivative.eval x * q.eval x) (gaussianReal 0 1) := by apply (integrable_eval_gaussianReal (p.derivative * q)).congr filter_upwards [] with x simp only [Polynomial.eval_mul] have hqp : Integrable (fun x : ℝ => p.eval x * q.derivative.eval x) (gaussianReal 0 1) := by apply (integrable_eval_gaussianReal (p * q.derivative)).congr filter_upwards [] with x simp only [Polynomial.eval_mul] have hs : (∫ x, x * (p.eval x * q.eval x) ∂gaussianReal 0 1) = (∫ x, p.derivative.eval x * q.eval x ∂gaussianReal 0 1) + ∫ x, p.eval x * q.derivative.eval x ∂gaussianReal 0 1 := by have h := integral_mul_eval_gaussianReal (p * q) simp only [Polynomial.eval_mul, Polynomial.derivative_mul, Polynomial.eval_add] at h rw [integral_add hpq hqp] at h exact h calc _ = ∫ x, x * (p.eval x * q.eval x) - p.derivative.eval x * q.eval x ∂gaussianReal 0 1 := by apply integral_congr_ae filter_upwards [] with x rw [hermite_eval_succ j x] simp only [p, q, Polynomial.derivative_map, Polynomial.eval_map, Polynomial.aeval_def, algebraMap_int_eq] ring _ = ∫ x, p.eval x * q.derivative.eval x ∂gaussianReal 0 1 := by rw [integral_sub hx hpq, hs] ring _ = ∫ x, (k + 1 : ℝ) * ((aeval x (hermite j) : ℝ) * aeval x (hermite k)) ∂gaussianReal 0 1 := by apply integral_congr_ae filter_upwards [] with x simp only [p, q, Polynomial.derivative_map, Polynomial.eval_map, derivative_hermite_succ, Polynomial.aeval_def, algebraMap_int_eq, Polynomial.eval₂_mul, Polynomial.eval₂_C, Int.coe_castRingHom, Int.cast_add, Int.cast_natCast, Int.cast_one] ring _ = _ := integral_const_mul _ _
HermiteGenerating 1 core · 7 supporting This module derives the real exponential generating series for Mathlib’s probabilists’ Hermite polynomials from their explicit coefficients and absolutely convergent exponential-series convolution. ★ hasSum_hermite
Probabilists’ Hermite generating series
This module derives the real exponential generating series for Mathlib’s probabilists’ Hermite polynomials from their explicit coefficients and absolutely convergent exponential-series convolution.
The probabilists' Hermite exponential generating series at real point and parameter has sum equal to the exponential of their product minus half the parameter squared.
Formal statement
Proof (Lean source)
7 supporting declarations (lemmas, instances)
-
coeff_hermite_div_factorialtheorem — The coefficient of the specified degree in a Hermite polynomial of that degree plus an even gap, divided by the order factorial, equals the signed reciprocal product of the power of two and two factorials.hypothesesm k :ℕconclusion((hermite (2 * m + k)).coeff k : ℝ) / (Nat.factorial (2 * m + k) : ℝ)= (-1 : ℝ) ^ m / ((2 : ℝ) ^ m * (Nat.factorial m : ℝ) * (Nat.factorial k : ℝ))Proof (Lean source)
theorem coeff_hermite_div_factorial (m k : ℕ) : ((hermite (2 * m + k)).coeff k : ℝ) / (Nat.factorial (2 * m + k) : ℝ) = (-1 : ℝ) ^ m / ((2 : ℝ) ^ m * (Nat.factorial m : ℝ) * (Nat.factorial k : ℝ)) := by have hdf : Nat.factorial (2 * m) = 2 ^ m * Nat.factorial m * Nat.doubleFactorial (2 * m - 1) := by cases m with | zero => simp | succ m => have h := Nat.factorial_eq_mul_doubleFactorial (2 * (m + 1) - 1) rw [show 2 * (m + 1) - 1 + 1 = 2 * (m + 1) by omega, Nat.doubleFactorial_two_mul] at h exact h have hc := Nat.choose_mul_factorial_mul_factorial (show k ≤ 2 * m + k by omega) rw [show 2 * m + k - k = 2 * m by omega, hdf] at hc have hcR : (choose (2 * m + k) k : ℝ) * (Nat.factorial k : ℝ) * ((2 : ℝ) ^ m * (Nat.factorial m : ℝ) * (Nat.doubleFactorial (2 * m - 1) : ℝ)) = (Nat.factorial (2 * m + k) : ℝ) := by exact_mod_cast hc rw [coeff_hermite_explicit] push_cast rw [← hcR] have hk : (Nat.factorial k : ℝ) ≠ 0 := by positivity have hm : (Nat.factorial m : ℝ) ≠ 0 := by positivity have hd : (Nat.doubleFactorial (2 * m - 1) : ℝ) ≠ 0 := by exact_mod_cast (Nat.ne_of_gt (Nat.doubleFactorial_pos _)) have hc0 : (choose (2 * m + k) k : ℝ) ≠ 0 := by exact_mod_cast (Nat.ne_of_gt (Nat.choose_pos (by omega))) field_simp -
hermite_eval_div_factorialtheorem — A factorial-normalized Hermite evaluation equals the finite sum over its even degree gaps.hypothesesn :ℕz :ℝProof (Lean source)
theorem hermite_eval_div_factorial (n : ℕ) (z : ℝ) : (aeval z (hermite n) : ℝ) / (Nat.factorial n : ℝ) = ∑ m ∈ range (n / 2 + 1), (-1 : ℝ) ^ m * z ^ (n - 2 * m) / ((2 : ℝ) ^ m * (Nat.factorial m : ℝ) * (Nat.factorial (n - 2 * m) : ℝ)) := by classical rw [aeval_eq_sum_range, natDegree_hermite, Finset.sum_div] simp only [zsmul_eq_mul] calc ∑ k ∈ range (n + 1), ((hermite n).coeff k : ℝ) * z ^ k / (Nat.factorial n : ℝ) = ∑ k ∈ (range (n + 1)).filter (fun k => Even (n + k)), ((hermite n).coeff k : ℝ) * z ^ k / (Nat.factorial n : ℝ) := by symm apply Finset.sum_subset (filter_subset _ _) intro k hk hnot have ho : Odd (n + k) := Nat.not_even_iff_odd.mp (fun he => hnot (Finset.mem_filter.mpr ⟨hk, he⟩)) simp [coeff_hermite_of_odd_add ho] _ = _ := by symm refine Finset.sum_bij (fun m _ => n - 2 * m) ?_ ?_ ?_ ?_ · intro m hm have hm' := Finset.mem_range.mp hm apply Finset.mem_filter.mpr refine ⟨Finset.mem_range.mpr (by omega), ?_⟩ exact ⟨n - m, by omega⟩ · intro m hm l hl heq have hm' := Finset.mem_range.mp hm have hl' := Finset.mem_range.mp hl omega · intro k hk rcases Finset.mem_filter.mp hk with ⟨hk, ⟨r, hr⟩⟩ have hk' := Finset.mem_range.mp hk refine ⟨(n - k) / 2, Finset.mem_range.mpr (by omega), ?_⟩ omega · intro m hm have hm' := Finset.mem_range.mp hm have hn : 2 * m + (n - 2 * m) = n := by omega have hc := coeff_hermite_div_factorial m (n - 2 * m) rw [hn] at hc rw [mul_div_assoc, mul_comm _ (z ^ _), mul_div_assoc, hc] ring -
hermite_term_eq_convolutiontheorem — A Hermite exponential-series term is the finite convolution of a linear exponential and an even quadratic exponential.hypothesesn :ℕz t :ℝProof (Lean source)
theorem hermite_term_eq_convolution (n : ℕ) (z t : ℝ) : (aeval z (hermite n) : ℝ) * t ^ n / (Nat.factorial n : ℝ) = ∑ kl ∈ Finset.antidiagonal n, ((z * t) ^ kl.1 / (Nat.factorial kl.1 : ℝ)) * (if Even kl.2 then (-(t ^ 2 / 2)) ^ (kl.2 / 2) / (Nat.factorial (kl.2 / 2) : ℝ) else 0) := by classical calc (aeval z (hermite n) : ℝ) * t ^ n / (Nat.factorial n : ℝ) = ((aeval z (hermite n) : ℝ) / (Nat.factorial n : ℝ)) * t ^ n := by ring _ = ∑ m ∈ range (n / 2 + 1), ((-1 : ℝ) ^ m * z ^ (n - 2 * m) / ((2 : ℝ) ^ m * (Nat.factorial m : ℝ) * (Nat.factorial (n - 2 * m) : ℝ))) * t ^ n := by rw [hermite_eval_div_factorial, Finset.sum_mul] _ = ∑ kl ∈ (Finset.antidiagonal n).filter (fun kl => Even kl.2), ((z * t) ^ kl.1 / (Nat.factorial kl.1 : ℝ)) * (if Even kl.2 then (-(t ^ 2 / 2)) ^ (kl.2 / 2) / (Nat.factorial (kl.2 / 2) : ℝ) else 0) := by refine Finset.sum_bij (fun m _ => (n - 2 * m, 2 * m)) ?_ ?_ ?_ ?_ · intro m hm have hm' := Finset.mem_range.mp hm exact Finset.mem_filter.mpr ⟨Finset.mem_antidiagonal.mpr (by omega), ⟨m, by omega⟩⟩ · intro m hm l hl heq have he := congrArg snd heq dsimp at he omega · intro kl hkl rcases Finset.mem_filter.mp hkl with ⟨hkl, ⟨m, hm⟩⟩ have hsum := Finset.mem_antidiagonal.mp hkl refine ⟨m, Finset.mem_range.mpr (by omega), ?_⟩ apply Prod.ext <;> dsimp <;> omega · intro m hm have hm' := Finset.mem_range.mp hm have ht : t ^ n = t ^ (n - 2 * m) * t ^ (2 * m) := by rw [← pow_add] congr 1 omega dsimp rw [if_pos (show Even (2 * m) from ⟨m, by omega⟩), Nat.mul_div_cancel_left _ (Nat.succ_pos 1), mul_pow, neg_pow (t ^ 2 / 2), div_pow, ← pow_mul, ht] have hk : (Nat.factorial (n - 2 * m) : ℝ) ≠ 0 := by positivity have hm0 : (Nat.factorial m : ℝ) ≠ 0 := by positivity field_simp _ = _ := by apply Finset.sum_subset (filter_subset _ _) intro kl hkl hnot have he : ¬ Even kl.2 := fun he => hnot (Finset.mem_filter.mpr ⟨hkl, he⟩) simp [he] -
hasSum_even_expSeriestheorem — Inserting zeros at the odd indices of a real exponential series preserves its sum, the exponential of its argument.hypothesesu :ℝProof (Lean source)
theorem hasSum_even_expSeries (u : ℝ) : HasSum (fun n : ℕ => if Even n then u ^ (n / 2) / (factorial (n / 2) : ℝ) else 0) (exp u) := by have hinj : Injective (fun m : ℕ => 2 * m) := by intro m n h change 2 * m = 2 * n at h omega refine (hinj.hasSum_iff ?_).mp ?_ · intro n hn have hodd : ¬ Even n := by intro heven exact hn ⟨n / 2, Nat.two_mul_div_two_of_even heven⟩ simp only [hodd, if_false] · simpa only [Function.comp_def, even_two_mul, if_true, Nat.mul_div_cancel_left _ (by decide : 0 < 2), Real.exp_eq_exp_ℝ] using NormedSpace.expSeries_div_hasSum_exp u -
summable_norm_even_expSeriestheorem — The absolute values of the exponential series with zeros inserted at odd indices form a summable series.hypothesesu :ℝProof (Lean source)
theorem summable_norm_even_expSeries (u : ℝ) : Summable (fun n : ℕ => ‖if Even n then u ^ (n / 2) / (factorial (n / 2) : ℝ) else 0‖) := by have hinj : Injective (fun m : ℕ => 2 * m) := by intro m n h change 2 * m = 2 * n at h omega refine (hinj.summable_iff ?_).mp ?_ · intro n hn have hodd : ¬ Even n := by intro heven exact hn ⟨n / 2, Nat.two_mul_div_two_of_even heven⟩ simp only [hodd, if_false, norm_zero] · simpa only [Function.comp_def, even_two_mul, if_true, Nat.mul_div_cancel_left _ (by decide : 0 < 2)] using NormedSpace.norm_expSeries_div_summable u -
hasSum_expSeries_convolutiontheorem — The finite Cauchy convolution of a linear exponential argument and an even-position exponential argument has sum equal to the exponential of their sum.hypothesesa u :ℝProof (Lean source)
theorem hasSum_expSeries_convolution (a u : ℝ) : HasSum (fun n : ℕ => ∑ kl ∈ Finset.antidiagonal n, (a ^ kl.1 / (Nat.factorial kl.1 : ℝ)) * (if Even kl.2 then u ^ (kl.2 / 2) / (Nat.factorial (kl.2 / 2) : ℝ) else 0)) (exp (a + u)) := by let f : ℕ → ℝ := fun n => a ^ n / (Nat.factorial n : ℝ) let g : ℕ → ℝ := fun n => if Even n then u ^ (n / 2) / (Nat.factorial (n / 2) : ℝ) else 0 have hf : HasSum f (exp a) := by simpa only [Real.exp_eq_exp_ℝ] using NormedSpace.expSeries_div_hasSum_exp a have hg : HasSum g (exp u) := hasSum_even_expSeries u have hfn : Summable (fun n => ‖f n‖) := NormedSpace.norm_expSeries_div_summable a have hgn : Summable (fun n => ‖g n‖) := summable_norm_even_expSeries u have hs : Summable (fun n => ∑ kl ∈ Finset.antidiagonal n, f kl.1 * g kl.2) := (summable_norm_sum_mul_antidiagonal_of_summable_norm hfn hgn).of_norm have heq : (∑' n, ∑ kl ∈ Finset.antidiagonal n, f kl.1 * g kl.2) = exp (a + u) := by rw [← tsum_mul_tsum_eq_tsum_sum_antidiagonal_of_summable_norm hfn hgn, hf.tsum_eq, hg.tsum_eq, ← Real.exp_add] exact heq ▸ hs.hasSum -
summable_norm_hermitetheorem — The absolute values of the real Hermite exponential-series terms form a summable series.hypothesesz t :ℝProof (Lean source)
theorem summable_norm_hermite (z t : ℝ) : Summable (fun j : ℕ => ‖(aeval z (hermite j) : ℝ) * t ^ j / (Nat.factorial j : ℝ)‖) := by have h := summable_norm_sum_mul_antidiagonal_of_summable_norm (NormedSpace.norm_expSeries_div_summable (z * t)) (summable_norm_even_expSeries (-(t ^ 2 / 2))) exact h.congr (fun n => congrArg (fun x : ℝ => ‖x‖) (hermite_term_eq_convolution n z t).symm)
IidMeanVariance 1 core · 15 supporting This module gives the exact mean and variance of an i.i.d. ★ iid_mean_euclidean_abs_le
Moments and deviation bounds for i.i.d. empirical means
This module gives the exact mean and variance of an i.i.d. empirical average,
as well as scalar and finite-dimensional L² and L¹ deviation bounds under
the corresponding moment assumptions.
The sample index is an arbitrary nonempty finite type; the sample size is then
its cardinality. Each result also has a Fin n specialisation under the
unprimed classical name, so callers using either a finite subtype or Fin n
can use the same lemmas.
The file also records the integrability / L²-membership side conditions of the
Euclidean deviation bound as public lemmas, since they are needed whenever the
bound is combined with another integral estimate.
For a strictly positive sample size n and finitely many square-integrable real-valued statistics indexed by k, each observed on the same n-point independent, identically distributed sample, the expected Euclidean norm of the vector of centered sample averages — one coordinate per statistic — is at most the square root of the sum of the population second moments divided by n.
Formal statement
Proof (Lean source)
15 supporting declarations (lemmas, instances)
-
sqrt_sum_sq_le_sum_abslemma — The Euclidean length of a finite real-valued vector is no greater than the sum of the absolute values of its components.Proof (Lean source)
lemma sqrt_sum_sq_le_sum_abs {ι : Type*} [Fintype ι] (v : ι → ℝ) : sqrt (∑ i, (v i) ^ 2) ≤ ∑ i, |v i| := by rw [Real.sqrt_le_iff] refine ⟨Finset.sum_nonneg fun _ _ => abs_nonneg _, ?_⟩ simpa [sq_abs] using Finset.sum_sq_le_sq_sum_of_nonneg (s := univ) (f := fun i => |v i|) (fun _ _ => abs_nonneg _) -
integrable_euclidean_of_integrabletheorem — The Euclidean length of a finite family of integrable real functions is itself integrable.hypothesesconclusionIntegrable (fun ω => sqrt (∑ i, (v ω i) ^ 2)) μProof (Lean source)
@[fun_prop] theorem integrable_euclidean_of_integrable {Ω ι : Type*} [MeasurableSpace Ω] [Fintype ι] {μ : Measure Ω} (v : Ω → ι → ℝ) (hv : ∀ i, Integrable (fun ω => v ω i) μ) : Integrable (fun ω => sqrt (∑ i, (v ω i) ^ 2)) μ := by have hsum : Integrable (fun ω => ∑ i, |v ω i|) μ := by fun_prop have hmeas : AEStronglyMeasurable (fun ω => sqrt (∑ i, (v ω i) ^ 2)) μ := by fun_prop refine hsum.mono' hmeas (ae_of_all _ fun ω => ?_) rw [Real.norm_of_nonneg (Real.sqrt_nonneg _)] exact sqrt_sum_sq_le_sum_abs (v ω) -
memLp_two_sqrt_sum_sqtheorem — The Euclidean length of a finite family of square-integrable real functions is itself square-integrable.hypothesesΩ ι :hY :∀ k, MemLp (Y k) 2 μProof (Lean source)
theorem memLp_two_sqrt_sum_sq {Ω ι : Type*} [MeasurableSpace Ω] [Fintype ι] {μ : Measure Ω} {Y : ι → Ω → ℝ} (hY : ∀ k, MemLp (Y k) 2 μ) : MemLp (fun ω => sqrt (∑ k, (Y k ω) ^ 2)) 2 μ := by have hsum_int : Integrable (fun ω => ∑ k, (Y k ω) ^ 2) μ := integrable_finset_sum _ fun k _ => (hY k).integrable_sq have hR_ae : AEStronglyMeasurable (fun ω => sqrt (∑ k, (Y k ω) ^ 2)) μ := hsum_int.aemeasurable.sqrt.aestronglyMeasurable apply (memLp_two_iff_integrable_sq hR_ae).2 convert hsum_int using 1 funext ω exact Real.sq_sqrt (Finset.sum_nonneg fun _ _ => sq_nonneg _) -
iid_mean_sq_le_fintypetheorem — The mean squared error of a square-integrable scalar sample average from independent, identically distributed observations is at most the population second moment divided by the sample size.hypothesesconclusion∫ s, ((Fintype.card ι : ℝ)⁻¹ * (∑ i : ι, ξ (s i)) - ∫ ω, ξ ω ∂μ) ^ 2 ∂(Measure.pi fun _ : ι => μ)≤ (∫ ω, (ξ ω) ^ 2 ∂μ) / (Fintype.card ι : ℝ)Proof (Lean source)
theorem iid_mean_sq_le_fintype {Ω ι : Type*} [MeasurableSpace Ω] [Fintype ι] [Nonempty ι] (μ : Measure Ω) [IsProbabilityMeasure μ] (ξ : Ω → ℝ) (hξ : MemLp ξ 2 μ) : ∫ s, ((Fintype.card ι : ℝ)⁻¹ * (∑ i : ι, ξ (s i)) - ∫ ω, ξ ω ∂μ) ^ 2 ∂(Measure.pi fun _ : ι => μ) ≤ (∫ ω, (ξ ω) ^ 2 ∂μ) / (Fintype.card ι : ℝ) := by have hcard : Fintype.card ι ≠ 0 := Fintype.card_ne_zero let P : Measure (ι → Ω) := Measure.pi fun _ : ι => μ let X : (ι → Ω) → ℝ := fun s => ∑ i : ι, ξ (s i) have hXLp : MemLp X 2 P := by simpa [X, P] using memLp_finset_sum univ fun i _ => hξ.comp_measurePreserving (measurePreserving_eval (fun _ : ι => μ) i) have hmean : ∫ s, (Fintype.card ι : ℝ)⁻¹ * X s ∂P = ∫ ω, ξ ω ∂μ := by rw [integral_const_mul] change (Fintype.card ι : ℝ)⁻¹ * ∫ s, ∑ i : ι, ξ (s i) ∂(Measure.pi fun _ : ι => μ) = _ have hsum_integral := integral_finset_sum univ fun i _ => (measurePreserving_eval (fun _ : ι => μ) i).integrable_comp_of_integrable (hξ.integrable (by norm_num)) rw [show (∫ s, ∑ i : ι, ξ (s i) ∂(Measure.pi fun _ : ι => μ)) = ∑ i : ι, ∫ s, ξ (s i) ∂(Measure.pi fun _ : ι => μ) by simpa using hsum_integral] have hcoord (i : ι) : ∫ s, ξ (s i) ∂(Measure.pi fun _ : ι => μ) = ∫ ω, ξ ω ∂μ := integral_comp_eval (μ := fun _ : ι => μ) (i := i) hξ.aestronglyMeasurable simp_rw [hcoord] simp [hcard] calc ∫ s, ((Fintype.card ι : ℝ)⁻¹ * (∑ i : ι, ξ (s i)) - ∫ ω, ξ ω ∂μ) ^ 2 ∂P = variance (fun s => (Fintype.card ι : ℝ)⁻¹ * X s) P := by rw [ProbabilityTheory.variance_eq_integral] · simp only [hmean] rfl · exact hXLp.const_mul (Fintype.card ι : ℝ)⁻¹ |>.aemeasurable _ = ((Fintype.card ι : ℝ)⁻¹) ^ 2 * variance X P := by exact ProbabilityTheory.variance_const_mul _ _ _ _ = ((Fintype.card ι : ℝ)⁻¹) ^ 2 * (∑ _i : ι, variance ξ μ) := by congr 1 change variance (fun s => ∑ i : ι, ξ (s i)) (Measure.pi fun _ : ι => μ) = _ calc variance (fun s => ∑ i : ι, ξ (s i)) (Measure.pi fun _ : ι => μ) = variance (∑ i : ι, fun s => ξ (s i)) (Measure.pi fun _ : ι => μ) := by congr 1 funext s simp _ = _ := ProbabilityTheory.variance_sum_pi (fun _ : ι => hξ) _ ≤ ((Fintype.card ι : ℝ)⁻¹) ^ 2 * (∑ _i : ι, ∫ ω, (ξ ω) ^ 2 ∂μ) := by gcongr exact ProbabilityTheory.variance_le_expectation_sq hξ.aestronglyMeasurable _ = (∫ ω, (ξ ω) ^ 2 ∂μ) / (Fintype.card ι : ℝ) := by simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul] field_simp -
iid_mean_abs_le_fintypetheorem — The mean absolute error of a square-integrable scalar sample average from independent, identically distributed observations is at most the square root of the population second moment divided by the sample size.hypothesesconclusion∫ s, |(Fintype.card ι : ℝ)⁻¹ * (∑ i : ι, ξ (s i))- ∫ ω, ξ ω ∂μ| ∂(Measure.pi fun _ : ι => μ)≤ sqrt ((∫ ω, (ξ ω) ^ 2 ∂μ) / (Fintype.card ι : ℝ))Proof (Lean source)
theorem iid_mean_abs_le_fintype {Ω ι : Type*} [MeasurableSpace Ω] [Fintype ι] [Nonempty ι] (μ : Measure Ω) [IsProbabilityMeasure μ] (ξ : Ω → ℝ) (hξ : MemLp ξ 2 μ) : ∫ s, |(Fintype.card ι : ℝ)⁻¹ * (∑ i : ι, ξ (s i)) - ∫ ω, ξ ω ∂μ| ∂(Measure.pi fun _ : ι => μ) ≤ sqrt ((∫ ω, (ξ ω) ^ 2 ∂μ) / (Fintype.card ι : ℝ)) := by let P : Measure (ι → Ω) := Measure.pi fun _ : ι => μ let Y : (ι → Ω) → ℝ := fun s => (Fintype.card ι : ℝ)⁻¹ * (∑ i : ι, ξ (s i)) - ∫ ω, ξ ω ∂μ have hYLp : MemLp Y 2 P := by apply MemLp.sub (MemLp.const_mul (by simpa [P] using memLp_finset_sum univ fun i _ => hξ.comp_measurePreserving (measurePreserving_eval (fun _ : ι => μ) i)) _) exact memLp_const _ exact (ConvergingTogether.integral_abs_le_sqrt_integral_sq P Y hYLp).trans (by simpa [P, Y] using (Real.sqrt_le_sqrt (iid_mean_sq_le_fintype (ι := ι) μ ξ hξ))) -
memLp_two_iid_mean_euclidean_fintypetheorem — The centred coordinatewise sample averages of finitely many square-integrable statistics form a square-integrable Euclidean length on the product sample space.hypothesesProof (Lean source)
theorem memLp_two_iid_mean_euclidean_fintype {Ω ι κ : Type*} [MeasurableSpace Ω] [Fintype ι] [Fintype κ] (μ : Measure Ω) [IsProbabilityMeasure μ] (ξ : κ → Ω → ℝ) (hξ : ∀ k, MemLp (ξ k) 2 μ) : MemLp (fun s => sqrt (∑ k : κ, ((Fintype.card ι : ℝ)⁻¹ * (∑ i : ι, ξ k (s i)) - ∫ ω, ξ k ω ∂μ) ^ 2)) 2 (Measure.pi fun _ : ι => μ) := by refine memLp_two_sqrt_sum_sq (fun k => ?_) apply MemLp.sub (MemLp.const_mul (by simpa using memLp_finset_sum univ fun i _ => (hξ k).comp_measurePreserving (measurePreserving_eval (fun _ : ι => μ) i)) _) exact memLp_const _ -
iid_mean_euclidean_abs_le_fintypetheorem — The expected Euclidean error of finitely many square-integrable sample averages from the same independent, identically distributed sample is controlled by their summed population second moments and the sample size.hypothesesProof (Lean source)
theorem iid_mean_euclidean_abs_le_fintype {Ω ι κ : Type*} [MeasurableSpace Ω] [Fintype ι] [Nonempty ι] [Fintype κ] (μ : Measure Ω) [IsProbabilityMeasure μ] (ξ : κ → Ω → ℝ) (hξ : ∀ k, MemLp (ξ k) 2 μ) : ∫ s, sqrt (∑ k : κ, ((Fintype.card ι : ℝ)⁻¹ * (∑ i : ι, ξ k (s i)) - ∫ ω, ξ k ω ∂μ) ^ 2) ∂(Measure.pi fun _ : ι => μ) ≤ sqrt ((∑ k : κ, ∫ ω, (ξ k ω) ^ 2 ∂μ) / (Fintype.card ι : ℝ)) := by let P : Measure (ι → Ω) := Measure.pi fun _ : ι => μ let Y : κ → (ι → Ω) → ℝ := fun k s => (Fintype.card ι : ℝ)⁻¹ * (∑ i : ι, ξ k (s i)) - ∫ ω, ξ k ω ∂μ let R : (ι → Ω) → ℝ := fun s => sqrt (∑ k : κ, (Y k s) ^ 2) have hYLp (k : κ) : MemLp (Y k) 2 P := by apply MemLp.sub (MemLp.const_mul (by simpa [P] using memLp_finset_sum univ fun i _ => (hξ k).comp_measurePreserving (measurePreserving_eval (fun _ : ι => μ) i)) _) exact memLp_const _ have hRLp : MemLp R 2 P := memLp_two_sqrt_sum_sq hYLp calc ∫ s, sqrt (∑ k : κ, (Y k s) ^ 2) ∂P ≤ sqrt (∫ s, (R s) ^ 2 ∂P) := by simpa [R, abs_of_nonneg (Real.sqrt_nonneg _)] using ConvergingTogether.integral_abs_le_sqrt_integral_sq P R hRLp _ = sqrt (∑ k : κ, ∫ s, (Y k s) ^ 2 ∂P) := by congr 1 rw [show (fun s => (R s) ^ 2) = fun s => ∑ k : κ, (Y k s) ^ 2 by funext s exact Real.sq_sqrt (Finset.sum_nonneg fun _ _ => sq_nonneg _)] exact integral_finset_sum _ fun k _ => (hYLp k).integrable_sq _ ≤ sqrt ((∑ k : κ, ∫ ω, (ξ k ω) ^ 2 ∂μ) / (Fintype.card ι : ℝ)) := by apply Real.sqrt_le_sqrt calc (∑ k : κ, ∫ s, (Y k s) ^ 2 ∂P) ≤ ∑ k : κ, (∫ ω, (ξ k ω) ^ 2 ∂μ) / (Fintype.card ι : ℝ) := by exact Finset.sum_le_sum fun k _ => iid_mean_sq_le_fintype μ (ξ k) (hξ k) _ = _ := by rw [Finset.sum_div] -
iid_average_integral_fintypelemma — An average of independent, identically distributed observations has the same expectation as the population statistic being averaged.hypothesesconclusion(∫ sample : ι → Ω, (Fintype.card ι : ℝ)⁻¹ * ∑ i, F (sample i) ∂Measure.pi (fun _ : ι => μ))= ∫ o, F o ∂μProof (Lean source)
lemma iid_average_integral_fintype {Ω ι : Type*} [MeasurableSpace Ω] [Fintype ι] [Nonempty ι] (μ : Measure Ω) [IsProbabilityMeasure μ] (F : Ω → ℝ) (hF : Integrable F μ) : (∫ sample : ι → Ω, (Fintype.card ι : ℝ)⁻¹ * ∑ i, F (sample i) ∂Measure.pi (fun _ : ι => μ)) = ∫ o, F o ∂μ := by have hcard : Fintype.card ι ≠ 0 := Fintype.card_ne_zero rw [integral_const_mul] rw [integral_finset_sum] · simp_rw [integral_comp_eval (μ := fun _ : ι => μ) hF.aestronglyMeasurable] simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul] field_simp · intro i _ exact integrable_comp_eval hF -
iid_average_variance_fintypelemma — The variance of an average of independent, identically distributed observations is the population variance divided by the sample size.hypothesesProof (Lean source)
lemma iid_average_variance_fintype {Ω ι : Type*} [MeasurableSpace Ω] [Fintype ι] (μ : Measure Ω) [IsProbabilityMeasure μ] (F : Ω → ℝ) (hF : MemLp F 2 μ) : variance (fun sample : ι → Ω => (Fintype.card ι : ℝ)⁻¹ * ∑ i, F (sample i)) (Measure.pi (fun _ : ι => μ)) = (Fintype.card ι : ℝ)⁻¹ * variance F μ := by by_cases hι : Nonempty ι · letI := hι have hcard : Fintype.card ι ≠ 0 := Fintype.card_ne_zero rw [ProbabilityTheory.variance_const_mul] have hfun : (fun sample : ι → Ω => ∑ i, F (sample i)) = ∑ i, fun sample : ι → Ω => F (sample i) := by funext sample simp rw [hfun] rw [ProbabilityTheory.variance_sum_pi (fun _ => hF)] simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul] field_simp · haveI : IsEmpty ι := not_nonempty_iff.mp hι have hfun : (fun sample : ι → Ω => (Fintype.card ι : ℝ)⁻¹ * ∑ i, F (sample i)) = 0 := by funext sample simp rw [hfun, ProbabilityTheory.variance_zero] simp -
iid_mean_sq_letheorem — The mean squared error of a square-integrable scalar sample average of n independent, identically distributed observations is at most the population second moment divided by n.hypothesesProof (Lean source)
theorem iid_mean_sq_le {Ω : Type*} [MeasurableSpace Ω] (μ : Measure Ω) [IsProbabilityMeasure μ] {n : ℕ} (hn : 0 < n) (ξ : Ω → ℝ) (hξ : MemLp ξ 2 μ) : ∫ s, ((n : ℝ)⁻¹ * (∑ i : Fin n, ξ (s i)) - ∫ ω, ξ ω ∂μ) ^ 2 ∂(Measure.pi fun _ : Fin n => μ) ≤ (∫ ω, (ξ ω) ^ 2 ∂μ) / (n : ℝ) := by haveI : Nonempty (Fin n) := Fin.pos_iff_nonempty.mp hn simpa using iid_mean_sq_le_fintype (ι := Fin n) μ ξ hξ -
iid_mean_abs_letheorem — The mean absolute error of a square-integrable scalar sample average of n independent, identically distributed observations is at most the square root of the population second moment divided by n.hypothesesProof (Lean source)
theorem iid_mean_abs_le {Ω : Type*} [MeasurableSpace Ω] (μ : Measure Ω) [IsProbabilityMeasure μ] {n : ℕ} (hn : 0 < n) (ξ : Ω → ℝ) (hξ : MemLp ξ 2 μ) : ∫ s, |(n : ℝ)⁻¹ * (∑ i : Fin n, ξ (s i)) - ∫ ω, ξ ω ∂μ| ∂(Measure.pi fun _ : Fin n => μ) ≤ sqrt ((∫ ω, (ξ ω) ^ 2 ∂μ) / (n : ℝ)) := by haveI : Nonempty (Fin n) := Fin.pos_iff_nonempty.mp hn simpa using iid_mean_abs_le_fintype (ι := Fin n) μ ξ hξ -
memLp_two_iid_mean_euclideantheorem — The centred coordinatewise sample averages of finitely many square-integrable statistics over an n-point independent, identically distributed sample form a square-integrable Euclidean length.hypothesesProof (Lean source)
theorem memLp_two_iid_mean_euclidean {Ω ι : Type*} [MeasurableSpace Ω] [Fintype ι] (μ : Measure Ω) [IsProbabilityMeasure μ] {n : ℕ} (ξ : ι → Ω → ℝ) (hξ : ∀ k, MemLp (ξ k) 2 μ) : MemLp (fun s => sqrt (∑ k : ι, ((n : ℝ)⁻¹ * (∑ i : Fin n, ξ k (s i)) - ∫ ω, ξ k ω ∂μ) ^ 2)) 2 (Measure.pi fun _ : Fin n => μ) := by simpa using memLp_two_iid_mean_euclidean_fintype (ι := Fin n) (κ := ι) μ ξ hξ -
integrable_iid_mean_euclideantheorem — The centred coordinatewise sample averages of finitely many integrable statistics over an n-point independent, identically distributed sample have integrable Euclidean length.hypothesesconclusionIntegrable (fun s => sqrt (∑ k : ι, ((n : ℝ)⁻¹ * (∑ i : Fin n, ξ k (s i)) - ∫ ω, ξ k ω ∂μ) ^ 2)) (Measure.pi fun _ : Fin n => μ)Proof (Lean source)
theorem integrable_iid_mean_euclidean {Ω ι : Type*} [MeasurableSpace Ω] [Fintype ι] (μ : Measure Ω) [IsProbabilityMeasure μ] {n : ℕ} (ξ : ι → Ω → ℝ) (hξ : ∀ k, Integrable (ξ k) μ) : Integrable (fun s => sqrt (∑ k : ι, ((n : ℝ)⁻¹ * (∑ i : Fin n, ξ k (s i)) - ∫ ω, ξ k ω ∂μ) ^ 2)) (Measure.pi fun _ : Fin n => μ) := by let v : (Fin n → Ω) → ι → ℝ := fun s k => (n : ℝ)⁻¹ * (∑ i : Fin n, ξ k (s i)) - ∫ ω, ξ k ω ∂μ have hv (k : ι) : Integrable (fun s => v s k) (Measure.pi fun _ : Fin n => μ) := by dsimp only [v] apply Integrable.sub · apply Integrable.const_mul exact integrable_finset_sum univ fun i _ => (measurePreserving_eval (fun _ : Fin n => μ) i).integrable_comp_of_integrable (hξ k) · exact integrable_const _ simpa only [v] using integrable_euclidean_of_integrable v hv -
iid_average_integrallemma — An average of n independent, identically distributed observations has the same expectation as the population statistic being averaged.hypothesesProof (Lean source)
lemma iid_average_integral {Ω : Type*} [MeasurableSpace Ω] (μ : Measure Ω) [IsProbabilityMeasure μ] (m : ℕ) (hm : 0 < m) (F : Ω → ℝ) (hF : Integrable F μ) : (∫ sample : Fin m → Ω, (m : ℝ)⁻¹ * ∑ i, F (sample i) ∂Measure.pi (fun _ : Fin m => μ)) = ∫ o, F o ∂μ := by haveI : Nonempty (Fin m) := Fin.pos_iff_nonempty.mp hm simpa using iid_average_integral_fintype (ι := Fin m) μ F hF -
iid_average_variancelemma — The variance of an average of independent, identically distributed observations is the population variance divided by the sample size (including the zero-length case).hypothesesProof (Lean source)
lemma iid_average_variance {Ω : Type*} [MeasurableSpace Ω] (μ : Measure Ω) [IsProbabilityMeasure μ] (m : ℕ) (F : Ω → ℝ) (hF : MemLp F 2 μ) : variance (fun sample : Fin m → Ω => (m : ℝ)⁻¹ * ∑ i, F (sample i)) (Measure.pi (fun _ : Fin m => μ)) = (m : ℝ)⁻¹ * variance F μ := by cases m with | zero => have hfun : (fun sample : Fin 0 → Ω => ((0 : ℕ) : ℝ)⁻¹ * ∑ i, F (sample i)) = 0 := by funext sample simp rw [hfun, ProbabilityTheory.variance_zero] simp | succ m => simpa using iid_average_variance_fintype (ι := Fin (m + 1)) μ F hF
KacBernstein 2 core · 4 supporting This file proves the finite-variance Kac–Bernstein theorem: if two independent real random variables X and Y (with finite second moments) are such that their sum X + Y and difference X − Y are independent, then X and Y a ★ gaussianForm_of_funeq★ bernsteinCharacterization
The Kac–Bernstein theorem (finite-variance case)
This file proves the finite-variance Kac–Bernstein theorem: if two independent
real random variables X and Y (with finite second moments) are such that their
sum X + Y and difference X − Y are independent, then X and Y are each
Gaussian. This fixed two-variable sum/difference characterization is an input and
strict special case of the Darmois–Skitovich theorem; arbitrary nonzero coefficients
and the general finite-family result are not formalized here. The result is an analytic
characterization of Gaussian laws.
The proof works at the level of characteristic functions f = charFun (P.map X)
and g = charFun (P.map Y):
1. bernstein_charFun_funeq — the functional equation obtained by computing
the joint characteristic function of (X, Y) two ways (directly, and through
the independent pair (X + Y, X − Y)):
f (u+v) · g (u−v) = f u · g u · f v · g (−v).
2. charFun_eventually_ne_zero — f and g are nonzero on a neighbourhood of
0, so the logarithmic derivatives f'/f, g'/g are defined there.
3. gaussianForm_of_funeq / bernstein_charFun_gaussian_nhds_zero — the
analytic core: working with the logarithmic derivative h_f = f'/f (no
Complex.log, hence no branch cuts), differentiate the functional equation
once in each of u and v to get h_f'(u+v) = h_g'(u−v); as (u+v, u−v)
ranges over a neighbourhood of 0, both are one constant, so h_f is affine
and f is a Gaussian characteristic function near 0.
4. A doubling bootstrap (the instance f (2t) = f t ^ 2 · g t · g (−t) of the
functional equation) propagates the Gaussian form from a neighbourhood of 0
to all of ℝ; Measure.ext_of_charFun then identifies the law as Gaussian.
The proof is organized into those four steps: a characteristic-function
functional equation, neighbourhood nonvanishing, the local Gaussian-form
argument, and the doubling bootstrap to a global Gaussian law. The supporting
infrastructure comes from Mathlib's charFun, differentiability, independent
sum, measure-extensionality, and real Gaussian characteristic-function APIs.
Pure analytic core: the Bernstein functional equation forces a Gaussian form. Let f, g : ℝ → ℂ be functions that are twice continuously differentiable and equal to 1 at the origin, and suppose they satisfy the Bernstein functional equation f (u+v) · g (u−v) = f u · g u · (f v · g (−v)) for all real u, v. Then there is a single constant c such that, on a neighbourhood of 0, f t = exp (f'(0)·t + c·t²/2) and g t = exp (g'(0)·t + c·t²/2), with the same c in both formulas.
Formal statement
Proof (Lean source)
Kac–Bernstein theorem (finite variance). Let X and Y be real random variables that are independent and each have finite second moment. If their sum X + Y and difference X − Y are independent, then both X and Y have Gaussian laws.
Formal statement
Proof (Lean source)
4 supporting declarations (lemmas, instances)
-
bernstein_charFun_funeqlemma — Functional equation for Bernstein's theorem. If X and Y are independent and the pair (X + Y, X − Y) is independent, then the characteristic functions f = charFun (P.map X) and g = charFun (P.map Y) satisfy f (u+v) · g (u−v) = f u · g u · f v · g (−v) for all u, v.Proof (Lean source)
lemma bernstein_charFun_funeq (mX : Measurable X) (mY : Measurable Y) (hXY : IndepFun X Y P) (hUV : IndepFun (X + Y) (X - Y) P) (u v : ℝ) : charFun (P.map X) (u + v) * charFun (P.map Y) (u - v) = charFun (P.map X) u * charFun (P.map Y) u * (charFun (P.map X) v * charFun (P.map Y) (-v)) := by have hscale : ∀ (Z : Ω → ℝ), Measurable Z → ∀ a t : ℝ, charFun (P.map (fun ω => a * Z ω)) t = charFun (P.map Z) (a * t) := by intro Z mZ a t rw [← charFun_map_mul (μ := P.map Z) a t] rw [Measure.map_map] · rfl · exact measurable_const_mul a · exact mZ have hlin : ∀ {Z W : Ω → ℝ}, Measurable Z → Measurable W → IndepFun Z W P → ∀ a b : ℝ, charFun (P.map (fun ω => a * Z ω + b * W ω)) (1 : ℝ) = charFun (P.map Z) a * charFun (P.map W) b := by intro Z W mZ mW hZW a b have hind : IndepFun (fun ω => a * Z ω) (fun ω => b * W ω) P := hZW.comp (measurable_const_mul a) (measurable_const_mul b) have h := hind.charFun_map_fun_add_eq_mul ((mZ.const_mul a).aemeasurable) ((mW.const_mul b).aemeasurable) have h1 := congrFun h (1 : ℝ) rw [Pi.mul_apply] at h1 rw [hscale Z mZ a 1, hscale W mW b 1] at h1 simpa using h1 have mAdd : Measurable (X + Y) := by fun_prop have mSub : Measurable (X - Y) := by fun_prop have hAdd : ∀ t : ℝ, charFun (P.map (X + Y)) t = charFun (P.map X) t * charFun (P.map Y) t := by intro t calc charFun (P.map (X + Y)) t = charFun (P.map (fun ω => t * (X + Y) ω)) (1 : ℝ) := by rw [hscale (X + Y) mAdd t 1] simp _ = charFun (P.map (fun ω => t * X ω + t * Y ω)) (1 : ℝ) := by congr 2 funext ω simp [Pi.add_apply] ring _ = charFun (P.map X) t * charFun (P.map Y) t := hlin mX mY hXY t t have hSub : ∀ t : ℝ, charFun (P.map (X - Y)) t = charFun (P.map X) t * charFun (P.map Y) (-t) := by intro t calc charFun (P.map (X - Y)) t = charFun (P.map (fun ω => t * (X - Y) ω)) (1 : ℝ) := by rw [hscale (X - Y) mSub t 1] simp _ = charFun (P.map (fun ω => t * X ω + (-t) * Y ω)) (1 : ℝ) := by congr 2 funext ω simp [Pi.sub_apply] ring _ = charFun (P.map X) t * charFun (P.map Y) (-t) := hlin mX mY hXY t (-t) calc charFun (P.map X) (u + v) * charFun (P.map Y) (u - v) = charFun (P.map (fun ω => (u + v) * X ω + (u - v) * Y ω)) (1 : ℝ) := by exact (hlin mX mY hXY (u + v) (u - v)).symm _ = charFun (P.map (fun ω => u * (X + Y) ω + v * (X - Y) ω)) (1 : ℝ) := by congr 2 funext ω simp [Pi.add_apply, Pi.sub_apply] ring _ = charFun (P.map (X + Y)) u * charFun (P.map (X - Y)) v := hlin mAdd mSub hUV u v _ = charFun (P.map X) u * charFun (P.map Y) u * (charFun (P.map X) v * charFun (P.map Y) (-v)) := by rw [hAdd u, hSub v] -
charFun_eventually_ne_zerolemma — The characteristic function of a probability measure on ℝ is nonzero on a neighbourhood of 0: it is continuous and equals 1 at 0. This is what makes the logarithmic derivative (charFun μ)' / charFun μ well defined near 0.Proof (Lean source)
lemma charFun_eventually_ne_zero (μ : Measure ℝ) [IsProbabilityMeasure μ] : ∀ᶠ t in nhds (0 : ℝ), charFun μ t ≠ 0 := by exact (continuous_charFun (μ := μ)).continuousAt.eventually_ne (by simp : charFun μ 0 ≠ 0) -
charFun_contDiff_twolemma — charFun of a pushforward with a finite second moment is C². This is a specialisation of contDiff_charFun (the characteristic function is Cⁿ whenever the n-th moment is finite), transferring MemLp Z 2 P to MemLp id 2 (P.map Z) along the pushforward map.hypothesesProof (Lean source)
lemma charFun_contDiff_two {Z : Ω → ℝ} [IsFiniteMeasure P] (hZ : MemLp Z 2 P) : ContDiff ℝ 2 (charFun (P.map Z)) := by refine contDiff_charFun (μ := P.map Z) ?_ exact (memLp_map_measure_iff aestronglyMeasurable_id hZ.aestronglyMeasurable.aemeasurable).2 (by simpa [Function.comp_def] using hZ) -
bernstein_charFun_gaussian_nhds_zerolemma — Analytic core of Bernstein's theorem. Under the Bernstein hypotheses with finite second moments, the characteristic functions of X and Y coincide, on a neighbourhood of 0, with Gaussian characteristic functions that share one variance σ² ≥ 0 (with means mf, mg). The shared σ² — a consequence of the single constant c from gaussianForm_of_funeq — is exactly what the doubling bootstrap in bernsteinCharacterization needs to extend the Gaussian form to all of ℝ.hypothesesProof (Lean source)
lemma bernstein_charFun_gaussian_nhds_zero (mX : Measurable X) (mY : Measurable Y) (hX2 : MemLp X 2 P) (hY2 : MemLp Y 2 P) (hXY : IndepFun X Y P) (hUV : IndepFun (X + Y) (X - Y) P) : ∃ mf mg σ2 : ℝ, 0 ≤ σ2 ∧ (∀ᶠ t in nhds (0 : ℝ), charFun (P.map X) t = exp (mf * t * I - σ2 * t ^ 2 / 2)) ∧ (∀ᶠ t in nhds (0 : ℝ), charFun (P.map Y) t = exp (mg * t * I - σ2 * t ^ 2 / 2)) := by let μX := P.map X let μY := P.map Y let f := charFun μX let g := charFun μY haveI : IsProbabilityMeasure μX := Measure.isProbabilityMeasure_map mX.aemeasurable haveI : IsProbabilityMeasure μY := Measure.isProbabilityMeasure_map mY.aemeasurable have hf : ContDiff ℝ 2 f := by simpa [f, μX] using charFun_contDiff_two (P := P) (Z := X) hX2 have hg : ContDiff ℝ 2 g := by simpa [g, μY] using charFun_contDiff_two (P := P) (Z := Y) hY2 have hf0 : f 0 = 1 := by simp [f] have hg0 : g 0 = 1 := by simp [g] have hfe : ∀ u v : ℝ, f (u + v) * g (u - v) = f u * g u * (f v * g (-v)) := by intro u v simpa [f, g, μX, μY] using bernstein_charFun_funeq mX mY hXY hUV u v obtain ⟨c, hXform, hYform⟩ := gaussianForm_of_funeq hf hg hf0 hg0 hfe have hXee : f =ᶠ[nhds (0 : ℝ)] fun t : ℝ => exp (deriv f 0 * t + c * t ^ 2 / 2) := hXform have hYee : g =ᶠ[nhds (0 : ℝ)] fun t : ℝ => exp (deriv g 0 * t + c * t ^ 2 / 2) := hYform have hμX2 : MemLp id 2 μX := by exact (memLp_map_measure_iff aestronglyMeasurable_id mX.aemeasurable).2 (by simpa [μX, Function.comp_def] using hX2) have hμX1 : MemLp id 1 μX := hμX2.mono_exponent (by norm_num) have hμY2 : MemLp id 2 μY := by exact (memLp_map_measure_iff aestronglyMeasurable_id mY.aemeasurable).2 (by simpa [μY, Function.comp_def] using hY2) have hμY1 : MemLp id 1 μY := hμY2.mono_exponent (by norm_num) let mf : ℝ := ∫ x, x ∂μX let mg : ℝ := ∫ y, y ∂μY let σ2 : ℝ := variance id μX have hderivX : deriv f 0 = I * (mf : ℂ) := by have hiter := iteratedDeriv_charFun_zero (μ := μX) (n := 1) (by simpa using hμX1) rw [← iteratedDeriv_one] simpa [f, mf] using hiter have hderivY : deriv g 0 = I * (mg : ℂ) := by have hiter := iteratedDeriv_charFun_zero (μ := μY) (n := 1) (by simpa using hμY1) rw [← iteratedDeriv_one] simpa [g, mg] using hiter have hsecondX : iteratedDeriv 2 f 0 = - ((∫ x, x ^ 2 ∂μX : ℝ) : ℂ) := by have hiter := iteratedDeriv_charFun_zero (μ := μX) (n := 2) hμX2 simpa [f] using hiter have hmodelEval (a b : ℂ) : iteratedDeriv 2 (fun t : ℝ => exp (a * t + b * t ^ 2 / 2)) 0 = b + a ^ 2 := by simp only [iteratedDeriv_succ, iteratedDeriv_zero] have hderivModel : deriv (fun t : ℝ => exp (a * t + b * t ^ 2 / 2)) = fun t : ℝ => (a + b * t) * exp (a * t + b * t ^ 2 / 2) := by funext t have hcoe : HasDerivAt (fun y : ℝ => (y : ℂ)) 1 t := HasDerivAt.ofReal_comp (hasDerivAt_id t) have hp : HasDerivAt (fun t : ℝ => a * (t : ℂ) + b * (t : ℂ) ^ 2 / 2) (a + b * (t : ℂ)) t := by exact ((hcoe.const_mul a).fun_add (((hcoe.fun_pow 2).const_mul b).div_const 2)).congr_deriv (by norm_num; ring) convert hp.cexp.deriv using 1 ; ring rw [hderivModel] have hcoe0 : HasDerivAt (fun y : ℝ => (y : ℂ)) 1 0 := HasDerivAt.ofReal_comp (hasDerivAt_id 0) have hp0 : HasDerivAt (fun t : ℝ => a * (t : ℂ) + b * (t : ℂ) ^ 2 / 2) a 0 := by exact ((hcoe0.const_mul a).fun_add (((hcoe0.fun_pow 2).const_mul b).div_const 2)).congr_deriv (by norm_num) have hlin0 : HasDerivAt (fun t : ℝ => a + b * (t : ℂ)) b 0 := by exact ((hcoe0.const_mul b).const_add a).congr_deriv (by ring) have hexp0 : HasDerivAt (fun t : ℝ => exp (a * t + b * t ^ 2 / 2)) a 0 := by exact hp0.cexp.congr_deriv (by norm_num) have hmul := (hlin0.fun_mul hexp0).deriv rw [hmul] norm_num ring have hmodelSecondX : iteratedDeriv 2 f 0 = c + (deriv f 0) ^ 2 := by calc iteratedDeriv 2 f 0 = iteratedDeriv 2 (fun t : ℝ => exp (deriv f 0 * t + c * t ^ 2 / 2)) 0 := hXee.iteratedDeriv_eq 2 _ = c + (deriv f 0) ^ 2 := hmodelEval (deriv f 0) c have hsigma : σ2 = (∫ x, x ^ 2 ∂μX) - mf ^ 2 := by simpa [σ2, mf] using (variance_eq_sub (μ := μX) (X := id) hμX2) have hc : c = - (σ2 : ℂ) := by rw [hsecondX, hderivX] at hmodelSecondX have hc' : c = - ((∫ x, x ^ 2 ∂μX : ℝ) : ℂ) - (I * (mf : ℂ)) ^ 2 := by calc c = (c + (I * (mf : ℂ)) ^ 2) - (I * (mf : ℂ)) ^ 2 := by ring _ = - ((∫ x, x ^ 2 ∂μX : ℝ) : ℂ) - (I * (mf : ℂ)) ^ 2 := by rw [← hmodelSecondX] rw [hc', hsigma] rw [Complex.ext_iff] have hI2 : I ^ 2 = (-1 : ℂ) := by rw [sq, Complex.I_mul_I] constructor · ring_nf rw [hI2] norm_num ring · ring_nf rw [hI2] norm_num refine ⟨mf, mg, σ2, variance_nonneg id μX, ?_, ?_⟩ · refine hXee.mono ?_ intro t ht change f t = exp ((mf : ℂ) * t * I - (σ2 : ℂ) * t ^ 2 / 2) rw [ht] rw [hderivX, hc] ring_nf · refine hYee.mono ?_ intro t ht change g t = exp ((mg : ℂ) * t * I - (σ2 : ℂ) * t ^ 2 / 2) rw [ht] rw [hderivY, hc] ring_nf
MeasurableCondQuantile 2 core · 7 supporting This file constructs a measurable conditional quantile from Mathlib's regular conditional CDF condCDF ρ : α → StieltjesFunction ℝ. ★ measurable_condQuantile_and_attains
Measurable conditional quantile selection
This file constructs a measurable conditional quantile from Mathlib's regular conditional
CDF condCDF ρ : α → StieltjesFunction ℝ. Given a measurable target level
τ : α → ℝ with 0 < τ a < 1, the conditional quantile is the generalized inverse
condQuantile ρ τ a = inf {x | τ a ≤ condCDF ρ a x}.
The key measurability identity is
{a | condQuantile ρ τ a ≤ t} = {a | τ a ≤ condCDF ρ a t}, using monotonicity,
right-continuity, and the atBot/atTop limits of condCDF. The theorem
measurable_condQuantile_and_attains proves that condQuantile ρ τ is measurable and,
when every conditional CDF is continuous at its selected quantile, attains the requested level:
condCDF ρ a (condQuantile ρ τ a) = τ a.
For any measurable parameter space, a measure on the product of that space and the real line, a real-valued target-level function on the parameter space, and a parameter value, the conditional quantile is the infimum of the real response values at which the conditional cumulative distribution function reaches the target level at that parameter value.
Measurable conditional quantile (selection). For a measure ρ on the product of a parameter space and the reals, and a measurable target level function τ that is everywhere strictly positive and everywhere strictly below one, if the conditional cumulative distribution function of ρ is continuous at the selected conditional quantile, for every parameter value, then the conditional quantile map condQuantile ρ τ is measurable and attains the target level — the conditional CDF at the selected quantile equals τ a for every a.
Formal statement
Proof (Lean source)
7 supporting declarations (lemmas, instances)
-
condQuantileSet_up_closedlemma — If a response value's conditional cumulative distribution function reaches a target level, then every larger response value also reaches that level.hypothesesconclusionx' ∈ {y : ℝ | τ a ≤ condCDF ρ a y}Proof (Lean source)
lemma condQuantileSet_up_closed {ρ : Measure (α × ℝ)} {τ : α → ℝ} {a : α} {x x' : ℝ} (hx : x ∈ {y : ℝ | τ a ≤ condCDF ρ a y}) (hxx' : x ≤ x') : x' ∈ {y : ℝ | τ a ≤ condCDF ρ a y} := le_trans hx ((condCDF ρ a).mono hxx') -
bddBelow_condQuantileSetlemma — At a strictly positive conditional-quantile level, the response values whose conditional cumulative distribution function reaches that level are bounded below.hypotheseshτ0 :0 < τ aProof (Lean source)
lemma bddBelow_condQuantileSet {ρ : Measure (α × ℝ)} {τ : α → ℝ} {a : α} (hτ0 : 0 < τ a) : BddBelow {x : ℝ | τ a ≤ condCDF ρ a x} := by obtain ⟨N, hN⟩ := Filter.eventually_atBot.mp ((tendsto_condCDF_atBot ρ a).eventually_lt_const hτ0) refine ⟨N, fun s hs => ?_⟩ by_contra hlt push_neg at hlt exact absurd hs (not_le.mpr (hN s hlt.le)) -
nonempty_condQuantileSetlemma — At a conditional-quantile level strictly below one, some response value has a conditional cumulative distribution function that reaches that level.Proof (Lean source)
lemma nonempty_condQuantileSet {ρ : Measure (α × ℝ)} {τ : α → ℝ} {a : α} (hτ1 : τ a < 1) : ({x : ℝ | τ a ≤ condCDF ρ a x}).Nonempty := by obtain ⟨N, hN⟩ := Filter.eventually_atTop.mp ((tendsto_condCDF_atTop ρ a).eventually_const_lt hτ1) exact ⟨N, (hN N le_rfl).le⟩ -
le_condCDF_condQuantilelemma — At a target level below one, the conditional generalized inverse reaches at least that level in the conditional cumulative distribution function.Proof (Lean source)
lemma le_condCDF_condQuantile {ρ : Measure (α × ℝ)} {τ : α → ℝ} {a : α} (hτ1 : τ a < 1) : τ a ≤ condCDF ρ a (condQuantile ρ τ a) := by set q := condQuantile ρ τ a with hq have hne : ({x : ℝ | τ a ≤ condCDF ρ a x}).Nonempty := nonempty_condQuantileSet hτ1 have hgt : ∀ x, q < x → τ a ≤ condCDF ρ a x := by intro x hx obtain ⟨s, hs, hsx⟩ := exists_lt_of_csInf_lt hne hx exact condQuantileSet_up_closed hs hsx.le have htends : Tendsto (condCDF ρ a) (𝓝[Ioi q] q) (𝓝 (condCDF ρ a q)) := ((condCDF ρ a).right_continuous q).mono_left (nhdsWithin_mono q Set.Ioi_subset_Ici_self) have hev : ∀ᶠ x in 𝓝[Ioi q] q, τ a ≤ condCDF ρ a x := by filter_upwards [self_mem_nhdsWithin] with x hx using hgt x hx exact ge_of_tendsto htends hev -
le_condCDF_of_condQuantile_lelemma — A conditional quantile below a value makes the conditional CDF reach any level below one.hypothesesconclusionτ a ≤ condCDF ρ a xProof (Lean source)
lemma le_condCDF_of_condQuantile_le {ρ : Measure (α × ℝ)} {τ : α → ℝ} {a : α} {x : ℝ} (hτ1 : τ a < 1) (hx : condQuantile ρ τ a ≤ x) : τ a ≤ condCDF ρ a x := le_trans (le_condCDF_condQuantile (ρ := ρ) (τ := τ) (a := a) hτ1) ((condCDF ρ a).mono hx) -
condQuantile_le_of_le_condCDFlemma — When the conditional cumulative distribution function has reached a positive target level at a point, the conditional generalized inverse is no larger than that point.hypothesesconclusioncondQuantile ρ τ a ≤ xProof (Lean source)
lemma condQuantile_le_of_le_condCDF {ρ : Measure (α × ℝ)} {τ : α → ℝ} {a : α} {x : ℝ} (hτ0 : 0 < τ a) (hx : τ a ≤ condCDF ρ a x) : condQuantile ρ τ a ≤ x := csInf_le (bddBelow_condQuantileSet (ρ := ρ) (τ := τ) (a := a) hτ0) hx -
condQuantile_le_ifflemma — At an interior target level, a point is above the conditional generalized inverse exactly when its conditional cumulative distribution function has reached that level.hypothesesconclusioncondQuantile ρ τ a ≤ x ↔ τ a ≤ condCDF ρ a xProof (Lean source)
lemma condQuantile_le_iff {ρ : Measure (α × ℝ)} {τ : α → ℝ} {a : α} {x : ℝ} (hτ0 : 0 < τ a) (hτ1 : τ a < 1) : condQuantile ρ τ a ≤ x ↔ τ a ≤ condCDF ρ a x := ⟨le_condCDF_of_condQuantile_le (ρ := ρ) (τ := τ) (a := a) hτ1, condQuantile_le_of_le_condCDF (ρ := ρ) (τ := τ) (a := a) hτ0⟩
ProductAbsolutelyContinuous 1 core · 1 supporting This file provides product-measure Radon--Nikodym factorization and the absolute-continuity side condition for finite i.i.d. ★ pi_iid_absolutelyContinuous
Absolute continuity of finite product measures
This file provides product-measure Radon--Nikodym factorization and the absolute-continuity side condition for finite i.i.d. product measures. These results are independent of statistical divergence constructions and can therefore be reused by Mathlib-adjacent probability developments.
For two σ-finite measures μ and ν on the same space with μ absolutely continuous with respect to ν, the n-fold product of μ is absolutely continuous with respect to the n-fold product of ν, for every number of factors n.
Formal statement
Proof (Lean source)
1 supporting declaration (lemmas, instances)
-
rnDeriv_prod_eqtheorem — Product density factorization. For μ₁ ≪ ν₁ and μ₂ ≪ ν₂, the Radon–Nikodym density of the product is (a.e.) the product of the marginal densities.hypothesesμ₁ ν₁ :Measure αμ₂ ν₂ :Measure βSigmaFinite ν₁SigmaFinite ν₂SFinite ν₂μ₁.HaveLebesgueDecomposition ν₁μ₂.HaveLebesgueDecomposition ν₂h₁ :μ₁ ≪ ν₁h₂ :μ₂ ≪ ν₂conclusion(μ₁.prod μ₂).rnDeriv (ν₁.prod ν₂)=ᵐ[ν₁.prod ν₂] fun z => μ₁.rnDeriv ν₁ z.1 * μ₂.rnDeriv ν₂ z.2Proof (Lean source)
theorem rnDeriv_prod_eq (μ₁ ν₁ : Measure α) (μ₂ ν₂ : Measure β) [SigmaFinite ν₁] [SigmaFinite ν₂] [SFinite ν₂] [μ₁.HaveLebesgueDecomposition ν₁] [μ₂.HaveLebesgueDecomposition ν₂] (h₁ : μ₁ ≪ ν₁) (h₂ : μ₂ ≪ ν₂) : (μ₁.prod μ₂).rnDeriv (ν₁.prod ν₂) =ᵐ[ν₁.prod ν₂] fun z => μ₁.rnDeriv ν₁ z.1 * μ₂.rnDeriv ν₂ z.2 := by -- Rewrite `μᵢ = νᵢ.withDensity (rnDeriv μᵢ νᵢ)` and use `prod_withDensity₀`. have hfac : μ₁.prod μ₂ = (ν₁.prod ν₂).withDensity (fun z => μ₁.rnDeriv ν₁ z.1 * μ₂.rnDeriv ν₂ z.2) := by conv_lhs => rw [← Measure.withDensity_rnDeriv_eq _ _ h₁, ← Measure.withDensity_rnDeriv_eq _ _ h₂] exact prod_withDensity₀ (Measure.measurable_rnDeriv _ _).aemeasurable (Measure.measurable_rnDeriv _ _).aemeasurable calc (μ₁.prod μ₂).rnDeriv (ν₁.prod ν₂) =ᵐ[ν₁.prod ν₂] ((ν₁.prod ν₂).withDensity (fun z => μ₁.rnDeriv ν₁ z.1 * μ₂.rnDeriv ν₂ z.2)).rnDeriv (ν₁.prod ν₂) := by rw [hfac] _ =ᵐ[ν₁.prod ν₂] fun z => μ₁.rnDeriv ν₁ z.1 * μ₂.rnDeriv ν₂ z.2 := Measure.rnDeriv_withDensity₀ _ (((Measure.measurable_rnDeriv _ _).comp measurable_fst).mul ((Measure.measurable_rnDeriv _ _).comp measurable_snd)).aemeasurable
SignedTwoPoint 2 core · 8 supporting The symmetric two-point outcome law twoPointMean B u supported on {−B, B} with mean u: Q_u(B) = (1 + u/B)/2, Q_u(−B) = (1 − u/B)/2. ★ bernoulli_mean_channel_kl
Symmetric signed two-point mean channel
The symmetric two-point outcome law twoPointMean B u supported on {−B, B} with mean u:
Q_u(B) = (1 + u/B)/2, Q_u(−B) = (1 − u/B)/2. It is the affine image of the {0,1} Bernoulli
law bernoulliLaw under x ↦ 2Bx − B, which lets its Kullback–Leibler divergence inherit the
quadratic band of the Bernoulli KL.
This file provides:
* twoPointMean — the signed two-point channel, with measurable_twoPointMean,
twoPointMean_isProbabilityMeasure, twoPointMean_integral, twoPointMean_mean,
twoPointMean_bad_support_zero;
* klDiv_map_measurableEquiv — KL-divergence invariance under a measurable equivalence;
* twoPointMean_eq_map_bernoulli — the affine-image representation;
* bernoulli_mean_channel_kl — the KL band KL(Q_u, Q_v) ≤ (u − v)²/B² for |u|,|v| ≤ B/2.
It is the reusable least-favorable outcome channel for two-point / Le Cam minimax lower bounds in a mean-estimation setting.
For a real scale and a real target mean, the symmetric two-point mean measure is the sum of a point mass at weighted by and a point mass at weighted by .
KL band for the signed two-point mean channel. For a strictly positive spread parameter B and two channel means u and v each confined to the interval [-B/2, B/2], the Kullback–Leibler divergence between the two-point channels with means u and v is bounded by the quadratic (u − v)²/B². This is the affine transport of the {0,1} Bernoulli KL band onto the {−B, B} mean parametrization.
Formal statement
Proof (Lean source)
8 supporting declarations (lemmas, instances)
-
measurable_twoPointMeanlemma — For a fixed scale B, the signed two-point mean channel is measurable as a function of the target mean u.Proof (Lean source)
@[fun_prop] lemma measurable_twoPointMean (B : ℝ) : Measurable (fun u : ℝ => twoPointMean B u) := by unfold twoPointMean fun_prop -
twoPointMean_coef_nonneglemma — When the scale is positive and the target mean lies within that scale, both weights in the signed two-point distribution are nonnegative.hypothesesB u :ℝhB :0 < Bhu :|u| ≤ Bconclusionconclusion 10 ≤ (1 + u / B) / 2conclusion 20 ≤ (1 - u / B) / 2Proof (Lean source)
lemma twoPointMean_coef_nonneg {B u : ℝ} (hB : 0 < B) (hu : |u| ≤ B) : 0 ≤ (1 + u / B) / 2 ∧ 0 ≤ (1 - u / B) / 2 := by have hbounds := abs_le.mp hu constructor <;> field_simp [ne_of_gt hB] <;> nlinarith [hbounds.1, hbounds.2, hB] -
twoPointMean_isProbabilityMeasurelemma — The signed two-point channel is a probability measure. For 0 < B and |u| ≤ B the total mass of twoPointMean B u is 1.Proof (Lean source)
lemma twoPointMean_isProbabilityMeasure {B u : ℝ} (hB : 0 < B) (hu : |u| ≤ B) : IsProbabilityMeasure (twoPointMean B u) := by rw [isProbabilityMeasure_iff] unfold twoPointMean rw [Measure.add_apply, Measure.smul_apply, Measure.smul_apply] simp only [Measure.dirac_apply, Set.indicator_of_mem, Set.mem_univ, Pi.one_apply, smul_eq_mul, mul_one] rcases twoPointMean_coef_nonneg hB hu with ⟨hplus, hminus⟩ rw [← ENNReal.ofReal_add hplus hminus] rw [show (1 + u / B) / 2 + (1 - u / B) / 2 = (1 : ℝ) by ring] simp -
twoPointMean_integrallemma — Two-point integral. For 0 < B and |u| ≤ B, integrating f against twoPointMean B u returns the two-point weighted average ((1 + u/B)/2)·f(B) + ((1 − u/B)/2)·f(−B).hypothesesB u :ℝhB :0 < Bhu :|u| ≤ Bf :ℝ → ℝconclusion∫ y, f y ∂twoPointMean B u = ((1 + u / B) / 2) * f B + ((1 - u / B) / 2) * f (-B)Proof (Lean source)
lemma twoPointMean_integral {B u : ℝ} (hB : 0 < B) (hu : |u| ≤ B) (f : ℝ → ℝ) : ∫ y, f y ∂twoPointMean B u = ((1 + u / B) / 2) * f B + ((1 - u / B) / 2) * f (-B) := by unfold twoPointMean rw [integral_add_measure] · rw [integral_smul_measure, integral_smul_measure] rcases twoPointMean_coef_nonneg hB hu with ⟨hplus, hminus⟩ simp [hplus, hminus, smul_eq_mul] · exact Integrable.smul_measure (μ := Measure.dirac B) (c := ofReal ((1 + u / B) / 2)) (integrable_dirac (f := f) (a := B) (by simp [enorm])) (by simp) · exact Integrable.smul_measure (μ := Measure.dirac (-B)) (c := ofReal ((1 - u / B) / 2)) (integrable_dirac (f := f) (a := -B) (by simp [enorm])) (by simp) -
twoPointMean_meanlemma — The mean is u. For 0 < B and |u| ≤ B, the expectation of the identity under twoPointMean B u is exactly u.hypothesesB u :ℝhB :0 < Bhu :|u| ≤ Bconclusion∫ y, y ∂twoPointMean B u = uProof (Lean source)
lemma twoPointMean_mean {B u : ℝ} (hB : 0 < B) (hu : |u| ≤ B) : ∫ y, y ∂twoPointMean B u = u := by rw [twoPointMean_integral hB hu] field_simp [ne_of_gt hB] ring -
twoPointMean_bad_support_zerolemma — The channel is supported in [−M, M] whenever |B| ≤ M. The mass that any nonnegative mixture of point masses at B and −B places outside the interval [−M, M] is 0.hypothesesB M :ℝwplus wminus :ℝ≥0∞hBM :|B| ≤ Mconclusion(wplus • Measure.dirac B + wminus • Measure.dirac (-B)) {y | y ∉ Icc (-M) M} = 0Proof (Lean source)
lemma twoPointMean_bad_support_zero {B M : ℝ} (wplus wminus : ℝ≥0∞) (hBM : |B| ≤ M) : (wplus • Measure.dirac B + wminus • Measure.dirac (-B)) {y | y ∉ Icc (-M) M} = 0 := by let S : Set ℝ := {y | y ∉ Icc (-M) M} have hS : MeasurableSet S := measurableSet_Icc.compl change (wplus • Measure.dirac B + wminus • Measure.dirac (-B)) S = 0 rw [Measure.add_apply, Measure.smul_apply, Measure.smul_apply] have hBmem : B ∈ Icc (-M) M := by exact abs_le.mp hBM have hnegBmem : -B ∈ Icc (-M) M := by rw [Set.mem_Icc] constructor <;> linarith [abs_le.mp hBM |>.1, abs_le.mp hBM |>.2] have hBbad : B ∉ S := by simpa [S] using hBmem have hnegBbad : -B ∉ S := by simpa [S] using hnegBmem have hdiracB : Measure.dirac B S = 0 := by rw [Measure.dirac_apply' B hS] simp [hBbad] have hdiracNeg : Measure.dirac (-B) S = 0 := by rw [Measure.dirac_apply' (-B) hS] simp [hnegBbad] rw [hdiracB, hdiracNeg] simp -
klDiv_map_measurableEquivlemma — KL-divergence is invariant under a measurable equivalence. Pushing both finite measures μ, ν forward through a measurable equivalence e leaves their Kullback–Leibler divergence unchanged: KL(e_* μ, e_* ν) = KL(μ, ν).hypothesesα β :e :α ≃ᵐ βμ ν :Proof (Lean source)
lemma klDiv_map_measurableEquiv {α β : Type*} [MeasurableSpace α] [MeasurableSpace β] (e : α ≃ᵐ β) (μ ν : Measure α) [IsFiniteMeasure μ] [IsFiniteMeasure ν] : klDiv (Measure.map e μ) (Measure.map e ν) = klDiv μ ν := by by_cases hμν : μ ≪ ν · have hmap : Measure.map e μ ≪ Measure.map e ν := hμν.map e.measurable rw [InformationTheory.klDiv_eq_lintegral_klFun, InformationTheory.klDiv_eq_lintegral_klFun, if_pos hmap, if_pos hμν] rw [e.measurableEmbedding.lintegral_map] refine lintegral_congr_ae ?_ exact (e.measurableEmbedding.rnDeriv_map μ ν).mono fun _ hx => by simpa using congrArg (fun y : ℝ≥0∞ => ofReal (klFun y.toReal)) hx · have hmap_not : ¬ Measure.map e μ ≪ Measure.map e ν := by intro hmap apply hμν have hback : Measure.map e.symm (Measure.map e μ) ≪ Measure.map e.symm (Measure.map e ν) := hmap.map e.symm.measurable simpa [Measure.map_map, Function.comp_def] using hback rw [InformationTheory.klDiv_eq_lintegral_klFun, InformationTheory.klDiv_eq_lintegral_klFun, if_neg hmap_not, if_neg hμν] -
twoPointMean_eq_map_bernoullilemma — Affine-image representation. The {−B, B} mean channel is the pushforward of the {0,1} Bernoulli law bernoulliLaw ((1 + u/B)/2) under the affine map x ↦ 2Bx − B (for B ≠ 0).hypothesesB u :ℝhB :B ≠ 0conclusiontwoPointMean B u= Measure.map (affineHomeomorph (2 * B) (-B) (mul_ne_zero (by norm_num) hB)).toMeasurableEquiv (bernoulliLaw ((1 + u / B) / 2))Proof (Lean source)
lemma twoPointMean_eq_map_bernoulli (B u : ℝ) (hB : B ≠ 0) : twoPointMean B u = Measure.map (affineHomeomorph (2 * B) (-B) (mul_ne_zero (by norm_num) hB)).toMeasurableEquiv (bernoulliLaw ((1 + u / B) / 2)) := by let e : ℝ ≃ᵐ ℝ := (affineHomeomorph (2 * B) (-B) (mul_ne_zero (by norm_num) hB)).toMeasurableEquiv change twoPointMean B u = Measure.map e (bernoulliLaw ((1 + u / B) / 2)) rw [twoPointMean, bernoulliLaw] rw [Measure.map_add _ _ e.measurable] rw [Measure.map_smul, Measure.map_smul] rw [Measure.map_dirac, Measure.map_dirac] simp only [Homeomorph.toMeasurableEquiv_coe, affineHomeomorph_apply, mul_one, mul_zero, zero_add, e] rw [show 2 * B + -B = B by ring] rw [show 1 - (1 + u / B) / 2 = (1 - u / B) / 2 by ring]
StdNormalMoments 1 core · 1 supporting This file proves two one-dimensional identities for the named standard-normal density stdNormalPDF and CDF stdNormalCDF: * integral_Ioi_stdNormalPDF: the survival integral ∫_{c}^∞ φ(t) dt = 1 - Φ(c); * integral_Ioi_id_mu ★ integral_Ioi_id_mul_stdNormalPDF
Standard normal survival integral and truncated first moment
This file proves two one-dimensional identities for the named standard-normal
density stdNormalPDF and CDF stdNormalCDF:
* integral_Ioi_stdNormalPDF: the survival integral
∫_{c}^∞ φ(t) dt = 1 - Φ(c);
* integral_Ioi_id_mul_stdNormalPDF: the truncated first moment
∫_{c}^∞ t * φ(t) dt = φ(c).
The moment identity follows from d/dt[-φ(t)] = t * φ(t) and supplies a
closed-form Gaussian tail moment.
The standard-normal truncated first moment. For any real cutoff c, the tail integral of t times the standard normal density over (c, ∞) equals the density value at c.
Formal statement
Proof (Lean source)
1 supporting declaration (lemmas, instances)
-
integral_Ioi_stdNormalPDFlemma — The standard-normal survival integral: ∫_{c}^∞ φ(t) dt = 1 − Φ(c).Proof (Lean source)
lemma integral_Ioi_stdNormalPDF (c : ℝ) : ∫ t in Ioi c, stdNormalPDF t = 1 - stdNormalCDF c := by have hmeasure := ProbabilityTheory.gaussianReal_apply_eq_integral (μ := 0) (v := 1) (by norm_num) (Ioi c) have hnonneg_g : 0 ≤ ∫ t in Ioi c, gaussianPDFReal 0 1 t := by exact integral_nonneg fun t => gaussianPDFReal_nonneg 0 1 t have hset_g : ∫ t in Ioi c, gaussianPDFReal 0 1 t = (gaussianReal 0 1).real (Ioi c) := by rw [MeasureTheory.measureReal_def] rw [hmeasure] exact (ENNReal.toReal_ofReal hnonneg_g).symm have hset : ∫ t in Ioi c, stdNormalPDF t = (gaussianReal 0 1).real (Ioi c) := by simpa [stdNormalPDF] using hset_g have hcompl : (gaussianReal 0 1).real (Ioi c) = 1 - (gaussianReal 0 1).real (Iic c) := by have h := MeasureTheory.measureReal_compl (μ := gaussianReal 0 1) (s := Iic c) measurableSet_Iic simpa [Set.compl_Iic, MeasureTheory.probReal_univ] using h have hcdf : (gaussianReal 0 1).real (Iic c) = stdNormalCDF c := by rw [stdNormalCDF, ProbabilityTheory.cdf_eq_real] rw [hset, hcompl, hcdf]
VarianceProd 1 core · 0 supporting This file provides the law of total variance in an explicit form for a statistic of two independent coordinates, using its within-slice variances and slice means. ★ variance_prod_eq_integral_variance_add
Variance decomposition on a product probability space
This file provides the law of total variance in an explicit form for a statistic of two independent coordinates, using its within-slice variances and slice means.
For independent coordinates with laws μ and ν, and a real-valued statistic F on the product that is square-integrable under the product law, suppose that almost every slice of F along the first coordinate, at a fixed value of the second coordinate, is square-integrable, that the map m of slice means is square-integrable under ν, and that m records the correct slice means: the integral of F over the first coordinate at almost every value of the second coordinate equals m there. Then the variance of F under the product measure equals the ν-average of the within-slice variances of F plus the variance, across the second coordinate, of the slice-mean map m.